deps/0000755000000000000000000000000012666635521010523 5ustar rootrootdeps/ws2_32-sys-0.2.1/0000755000000000000000000000000012666635520013011 5ustar rootrootdeps/ws2_32-sys-0.2.1/README.md0000644000000000000000000000037512620207001014250 0ustar rootroot# ws2_32 # Contains function definitions for the Windows API library ws2_32. See winapi for types and constants. ```toml [dependencies] ws2_32-sys = "0.2.0" ``` ```rust extern crate ws2_32; ``` [Documentation](https://retep998.github.io/doc/ws2_32/) deps/ws2_32-sys-0.2.1/src/0000755000000000000000000000000012666635520013600 5ustar rootrootdeps/ws2_32-sys-0.2.1/src/lib.rs0000644000000000000000000005653012565203572014721 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! FFI bindings to ws2_32. #![cfg(windows)] extern crate winapi; use winapi::*; extern "system" { pub fn FreeAddrInfoEx(pAddrInfoEx: PADDRINFOEXA); pub fn FreeAddrInfoExW(pAddrInfoEx: PADDRINFOEXW); pub fn FreeAddrInfoW(pAddrInfo: PADDRINFOW); pub fn GetAddrInfoExA( pName: PCSTR, pServiceName: PCSTR, dwNameSpace: DWORD, lpNspId: LPGUID, hints: *const ADDRINFOEXA, ppResult: *mut PADDRINFOEXA, timeout: *mut timeval, lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPLOOKUPSERVICE_COMPLETION_ROUTINE, lpNameHandle: LPHANDLE, ) -> INT; pub fn GetAddrInfoExCancel(lpHandle: LPHANDLE) -> INT; pub fn GetAddrInfoExOverlappedResult(lpOverlapped: LPOVERLAPPED) -> INT; pub fn GetAddrInfoExW( pName: PCWSTR, pServiceName: PCWSTR, dwNameSpace: DWORD, lpNspId: LPGUID, hints: *const ADDRINFOEXW, ppResult: *mut PADDRINFOEXW, timeout: *mut timeval, lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPLOOKUPSERVICE_COMPLETION_ROUTINE, lpNameHandle: LPHANDLE, ) -> INT; pub fn GetAddrInfoW( pNodeName: PCWSTR, pServiceName: PCWSTR, pHints: *const ADDRINFOW, ppResult: *mut PADDRINFOW, ) -> INT; pub fn GetHostNameW(name: PWSTR, namelen: c_int) -> c_int; pub fn GetNameInfoW( pSockaddr: *const SOCKADDR, SockaddrLength: socklen_t, pNodeBuffer: PWCHAR, NodeBufferSize: DWORD, pServiceBuffer: PWCHAR, ServiceBufferSize: DWORD, Flags: INT, ) -> INT; pub fn InetNtopW(Family: INT, pAddr: PVOID, pStringBuf: PWSTR, StringBufSize: size_t) -> PCWSTR; pub fn InetPtonW(Family: INT, pszAddrString: PCWSTR, pAddrBuf: PVOID) -> INT; pub fn SetAddrInfoExA( pName: PCSTR, pServiceName: PCSTR, pAddresses: *mut SOCKET_ADDRESS, dwAddressCount: DWORD, lpBlob: LPBLOB, dwFlags: DWORD, dwNameSpace: DWORD, lpNspId: LPGUID, timeout: *mut timeval, lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPLOOKUPSERVICE_COMPLETION_ROUTINE, lpNameHandle: LPHANDLE, ) -> INT; pub fn SetAddrInfoExW( pName: PCWSTR, pServiceName: PCWSTR, pAddresses: *mut SOCKET_ADDRESS, dwAddressCount: DWORD, lpBlob: LPBLOB, dwFlags: DWORD, dwNameSpace: DWORD, lpNspId: LPGUID, timeout: *mut timeval, lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPLOOKUPSERVICE_COMPLETION_ROUTINE, lpNameHandle: LPHANDLE, ) -> INT; // pub fn WEP(); pub fn WPUCompleteOverlappedRequest( s: SOCKET, lpOverlapped: LPWSAOVERLAPPED, dwError: DWORD, cbTransferred: DWORD, lpErrno: LPINT, ) -> c_int; // pub fn WPUGetProviderPathEx(); pub fn WSAAccept( s: SOCKET, addr: *mut SOCKADDR, addrlen: LPINT, lpfnCondition: LPCONDITIONPROC, dwCallbackData: DWORD_PTR, ) -> SOCKET; pub fn WSAAddressToStringA( lpsaAddress: LPSOCKADDR, dwAddressLength: DWORD, lpProtocolInfo: LPWSAPROTOCOL_INFOA, lpszAddressString: LPSTR, lpdwAddressStringLength: LPDWORD, ) -> INT; pub fn WSAAddressToStringW( lpsaAddress: LPSOCKADDR, dwAddressLength: DWORD, lpProtocolInfo: LPWSAPROTOCOL_INFOW, lpszAddressString: LPWSTR, lpdwAddressStringLength: LPDWORD, ) -> INT; pub fn WSAAdvertiseProvider( puuidProviderId: *const GUID, pNSPv2Routine: *const LPCNSPV2_ROUTINE, ) -> INT; pub fn WSAAsyncGetHostByAddr( hWnd: HWND, wMsg: u_int, addr: *const c_char, len: c_int, _type: c_int, buf: *mut c_char, buflen: c_int, ) -> HANDLE; pub fn WSAAsyncGetHostByName( hWnd: HWND, wMsg: u_int, name: *const c_char, buf: *mut c_char, buflen: c_int, ) -> HANDLE; pub fn WSAAsyncGetProtoByName( hWnd: HWND, wMsg: u_int, name: *const c_char, buf: *mut c_char, buflen: c_int, ) -> HANDLE; pub fn WSAAsyncGetProtoByNumber( hWnd: HWND, wMsg: u_int, number: c_int, buf: *mut c_char, buflen: c_int, ) -> HANDLE; pub fn WSAAsyncGetServByName( hWnd: HWND, wMsg: u_int, name: *const c_char, proto: *const c_char, buf: *mut c_char, buflen: c_int, ) -> HANDLE; pub fn WSAAsyncGetServByPort( hWnd: HWND, wMsg: u_int, port: c_int, proto: *const c_char, buf: *mut c_char, buflen: c_int, ) -> HANDLE; pub fn WSAAsyncSelect(s: SOCKET, hWnd: HWND, wMsg: u_int, lEvent: c_long) -> c_int; pub fn WSACancelAsyncRequest(hAsyncTaskHandle: HANDLE) -> c_int; pub fn WSACancelBlockingCall() -> c_int; pub fn WSACleanup() -> c_int; pub fn WSACloseEvent(hEvent: WSAEVENT) -> BOOL; pub fn WSAConnect( s: SOCKET, name: *const SOCKADDR, namelen: c_int, lpCallerData: LPWSABUF, lpCalleeData: LPWSABUF, lpSQOS: LPQOS, lpGQOS: LPQOS, ) -> c_int; pub fn WSAConnectByList( s: SOCKET, SocketAddress: PSOCKET_ADDRESS_LIST, LocalAddressLength: LPDWORD, LocalAddress: LPSOCKADDR, RemoteAddressLength: LPDWORD, RemoteAddress: LPSOCKADDR, timeout: *const timeval, Reserved: LPWSAOVERLAPPED, ) -> BOOL; pub fn WSAConnectByNameA( s: SOCKET, nodename: LPCSTR, servicename: LPCSTR, LocalAddressLength: LPDWORD, LocalAddress: LPSOCKADDR, RemoteAddressLength: LPDWORD, RemoteAddress: LPSOCKADDR, timeout: *const timeval, Reserved: LPWSAOVERLAPPED, ) -> BOOL; pub fn WSAConnectByNameW( s: SOCKET, nodename: LPWSTR, servicename: LPWSTR, LocalAddressLength: LPDWORD, LocalAddress: LPSOCKADDR, RemoteAddressLength: LPDWORD, RemoteAddress: LPSOCKADDR, timeout: *const timeval, Reserved: LPWSAOVERLAPPED, ) -> BOOL; pub fn WSACreateEvent() -> WSAEVENT; pub fn WSADuplicateSocketA( s: SOCKET, dwProcessId: DWORD, lpProtocolInfo: LPWSAPROTOCOL_INFOA, ) -> c_int; pub fn WSADuplicateSocketW( s: SOCKET, dwProcessId: DWORD, lpProtocolInfo: LPWSAPROTOCOL_INFOW, ) -> c_int; pub fn WSAEnumNameSpaceProvidersA( lpdwBufferLength: LPDWORD, lpnspBuffer: LPWSANAMESPACE_INFOA, ) -> INT; pub fn WSAEnumNameSpaceProvidersExA( lpdwBufferLength: LPDWORD, lpnspBuffer: LPWSANAMESPACE_INFOEXA, ) -> INT; pub fn WSAEnumNameSpaceProvidersExW( lpdwBufferLength: LPDWORD, lpnspBuffer: LPWSANAMESPACE_INFOEXW, ) -> INT; pub fn WSAEnumNameSpaceProvidersW( lpdwBufferLength: LPDWORD, lpnspBuffer: LPWSANAMESPACE_INFOW, ) -> INT; pub fn WSAEnumNetworkEvents( s: SOCKET, hEventObject: WSAEVENT, lpNetworkEvents: LPWSANETWORKEVENTS, ) -> c_int; pub fn WSAEnumProtocolsA( lpiProtocols: LPINT, lpProtocolBuffer: LPWSAPROTOCOL_INFOA, lpdwBufferLength: LPDWORD, ) -> c_int; pub fn WSAEnumProtocolsW( lpiProtocols: LPINT, lpProtocolBuffer: LPWSAPROTOCOL_INFOW, lpdwBufferLength: LPDWORD, ) -> c_int; pub fn WSAEventSelect(s: SOCKET, hEventObject: WSAEVENT, lNetworkEvents: c_long) -> c_int; pub fn WSAGetLastError() -> c_int; pub fn WSAGetOverlappedResult( s: SOCKET, lpOverlapped: LPWSAOVERLAPPED, lpcbTransfer: LPDWORD, fWait: BOOL, lpdwFlags: LPDWORD, ) -> BOOL; pub fn WSAGetQOSByName(s: SOCKET, lpQOSName: LPWSABUF, lpQOS: LPQOS) -> BOOL; pub fn WSAGetServiceClassInfoA( lpProviderId: LPGUID, lpServiceClassId: LPGUID, lpdwBufSize: LPDWORD, lpServiceClassInfo: LPWSASERVICECLASSINFOA, ) -> INT; pub fn WSAGetServiceClassInfoW( lpProviderId: LPGUID, lpServiceClassId: LPGUID, lpdwBufSize: LPDWORD, lpServiceClassInfo: LPWSASERVICECLASSINFOW, ) -> INT; pub fn WSAGetServiceClassNameByClassIdA( lpServiceClassId: LPGUID, lpszServiceClassName: LPSTR, lpdwBufferLength: LPDWORD, ) -> INT; pub fn WSAGetServiceClassNameByClassIdW( lpServiceClassId: LPGUID, lpszServiceClassName: LPWSTR, lpdwBufferLength: LPDWORD, ) -> INT; pub fn WSAHtonl(s: SOCKET, hostlong: u_long, lpnetlong: *mut u_long) -> c_int; pub fn WSAHtons(s: SOCKET, hostshort: u_short, lpnetshort: *mut u_short) -> c_int; pub fn WSAInstallServiceClassA(lpServiceClassInfo: LPWSASERVICECLASSINFOA) -> INT; pub fn WSAInstallServiceClassW(lpServiceClassInfo: LPWSASERVICECLASSINFOW) -> INT; pub fn WSAIoctl( s: SOCKET, dwIoControlCode: DWORD, lpvInBuffer: LPVOID, cbInBuffer: DWORD, lpvOutBuffer: LPVOID, cbOutBuffer: DWORD, lpcbBytesReturned: LPDWORD, lpOverlapped: LPWSAOVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, ) -> c_int; pub fn WSAIsBlocking() -> BOOL; pub fn WSAJoinLeaf( s: SOCKET, name: *const SOCKADDR, namelen: c_int, lpCallerData: LPWSABUF, lpCalleeData: LPWSABUF, lpSQOS: LPQOS, lpGQOS: LPQOS, dwFlags: DWORD, ) -> SOCKET; pub fn WSALookupServiceBeginA( lpqsRestrictions: LPWSAQUERYSETA, dwControlFlags: DWORD, lphLookup: LPHANDLE, ) -> INT; pub fn WSALookupServiceBeginW( lpqsRestrictions: LPWSAQUERYSETW, dwControlFlags: DWORD, lphLookup: LPHANDLE, ) -> INT; pub fn WSALookupServiceEnd(hLookup: HANDLE) -> INT; pub fn WSALookupServiceNextA( hLookup: HANDLE, dwControlFlags: DWORD, lpdwBufferLength: LPDWORD, lpqsResults: LPWSAQUERYSETA, ) -> INT; pub fn WSALookupServiceNextW( hLookup: HANDLE, dwControlFlags: DWORD, lpdwBufferLength: LPDWORD, lpqsResults: LPWSAQUERYSETW, ) -> INT; pub fn WSANSPIoctl( hLookup: HANDLE, dwControlFlags: DWORD, lpvInBuffer: LPVOID, cbInBuffer: DWORD, lpvOutBuffer: LPVOID, cbOutBuffer: DWORD, lpcbBytesReturned: LPDWORD, lpCompletion: LPWSACOMPLETION, ) -> INT; pub fn WSANtohl(s: SOCKET, netlong: u_long, lphostlong: *mut c_long) -> c_int; pub fn WSANtohs(s: SOCKET, netshort: u_short, lphostshort: *mut c_short) -> c_int; pub fn WSAPoll(fdArray: LPWSAPOLLFD, fds: ULONG, timeout: INT) -> c_int; pub fn WSAProviderCompleteAsyncCall(hAsyncCall: HANDLE, iRetCode: INT) -> INT; pub fn WSAProviderConfigChange( lpNotificationHandle: LPHANDLE, lpOverlapped: LPWSAOVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, ) -> INT; pub fn WSARecv( s: SOCKET, lpBuffers: LPWSABUF, dwBufferCount: DWORD, lpNumberOfBytesRecvd: LPDWORD, lpFlags: LPDWORD, lpOverlapped: LPWSAOVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, ) -> c_int; pub fn WSARecvDisconnect(s: SOCKET, lpInboundDisconnectData: LPWSABUF) -> c_int; pub fn WSARecvFrom( s: SOCKET, lpBuffers: LPWSABUF, dwBufferCount: DWORD, lpNumberOfBytesRecvd: LPDWORD, lpFlags: LPDWORD, lpFrom: *mut SOCKADDR, lpFromlen: LPINT, lpOverlapped: LPWSAOVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, ) -> c_int; pub fn WSARemoveServiceClass(lpServiceClassId: LPGUID) -> INT; pub fn WSAResetEvent(hEvent: WSAEVENT) -> BOOL; pub fn WSASend( s: SOCKET, lpBuffers: LPWSABUF, dwBufferCount: DWORD, lpNumberOfBytesSent: LPDWORD, dwFlags: DWORD, lpOverlapped: LPWSAOVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, ) -> c_int; pub fn WSASendDisconnect(s: SOCKET, lpOutboundDisconnectData: LPWSABUF) -> c_int; pub fn WSASendMsg( Handle: SOCKET, lpMsg: LPWSAMSG, dwFlags: DWORD, lpNumberOfBytesSent: LPDWORD, lpOverlapped: LPWSAOVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, ) -> c_int; pub fn WSASendTo( s: SOCKET, lpBuffers: LPWSABUF, dwBufferCount: DWORD, lpNumberOfBytesSent: LPDWORD, dwFlags: DWORD, lpTo: *const SOCKADDR, iToLen: c_int, lpOverlapped: LPWSAOVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, ) -> c_int; pub fn WSASetBlockingHook(lpBlockFunc: FARPROC) -> FARPROC; pub fn WSASetEvent(hEvent: WSAEVENT) -> BOOL; pub fn WSASetLastError(iError: c_int); pub fn WSASetServiceA( lpqsRegInfo: LPWSAQUERYSETA, essoperation: WSAESETSERVICEOP, dwControlFlags: DWORD, ) -> INT; pub fn WSASetServiceW( lpqsRegInfo: LPWSAQUERYSETW, essoperation: WSAESETSERVICEOP, dwControlFlags: DWORD, ) -> INT; pub fn WSASocketA( af: c_int, _type: c_int, protocol: c_int, lpProtocolInfo: LPWSAPROTOCOL_INFOA, g: GROUP, dwFlags: DWORD, ) -> SOCKET; pub fn WSASocketW( af: c_int, _type: c_int, protocol: c_int, lpProtocolInfo: LPWSAPROTOCOL_INFOW, g: GROUP, dwFlags: DWORD, ) -> SOCKET; pub fn WSAStartup(wVersionRequested: WORD, lpWSAData: LPWSADATA) -> c_int; pub fn WSAStringToAddressA( AddressString: LPSTR, AddressFamily: INT, lpProtocolInfo: LPWSAPROTOCOL_INFOA, lpAddress: LPSOCKADDR, lpAddressLength: LPINT, ) -> INT; pub fn WSAStringToAddressW( AddressString: LPWSTR, AddressFamily: INT, lpProtocolInfo: LPWSAPROTOCOL_INFOW, lpAddress: LPSOCKADDR, lpAddressLength: LPINT, ) -> INT; pub fn WSAUnadvertiseProvider(puuidProviderId: *const GUID) -> INT; pub fn WSAUnhookBlockingHook() -> c_int; pub fn WSAWaitForMultipleEvents( cEvents: DWORD, lphEvents: *const WSAEVENT, fWaitAll: BOOL, dwTimeout: DWORD, fAlertable: BOOL, ) -> DWORD; pub fn WSCDeinstallProvider(lpProviderId: LPGUID, lpErrno: LPINT) -> c_int; // pub fn WSCDeinstallProviderEx(); pub fn WSCEnableNSProvider(lpProviderId: LPGUID, fEnable: BOOL) -> INT; pub fn WSCEnumProtocols( lpiProtocols: LPINT, lpProtocolBuffer: LPWSAPROTOCOL_INFOW, lpdwBufferLength: LPDWORD, lpErrno: LPINT, ) -> c_int; // pub fn WSCEnumProtocolsEx(); pub fn WSCGetApplicationCategory( Path: LPCWSTR, PathLength: DWORD, Extra: LPCWSTR, ExtraLength: DWORD, pPermittedLspCategories: *mut DWORD, lpErrno: LPINT, ) -> c_int; // pub fn WSCGetApplicationCategoryEx(); pub fn WSCGetProviderInfo( lpProviderId: LPGUID, InfoType: WSC_PROVIDER_INFO_TYPE, Info: PBYTE, InfoSize: *mut size_t, Flags: DWORD, lpErrno: LPINT, ) -> c_int; pub fn WSCGetProviderPath( lpProviderId: LPGUID, lpszProviderDllPath: *mut WCHAR, lpProviderDllPathLen: LPINT, lpErrno: LPINT, ) -> c_int; pub fn WSCInstallNameSpace( lpszIdentifier: LPWSTR, lpszPathName: LPWSTR, dwNameSpace: DWORD, dwVersion: DWORD, lpProviderId: LPGUID, ) -> INT; pub fn WSCInstallNameSpaceEx( lpszIdentifier: LPWSTR, lpszPathName: LPWSTR, dwNameSpace: DWORD, dwVersion: DWORD, lpProviderId: LPGUID, lpProviderSpecific: LPBLOB, ) -> INT; // pub fn WSCInstallNameSpaceEx2(); pub fn WSCInstallProvider( lpProviderId: LPGUID, lpszProviderDllPath: *const WCHAR, lpProtocolInfoList: LPWSAPROTOCOL_INFOW, dwNumberOfEntries: DWORD, lpErrno: LPINT, ) -> c_int; // pub fn WSCInstallProviderEx(); pub fn WSCSetApplicationCategory( Path: LPCWSTR, PathLength: DWORD, Extra: LPCWSTR, ExtraLength: DWORD, PermittedLspCategories: DWORD, pPrevPermLspCat: *mut DWORD, lpErrno: LPINT, ) -> c_int; // pub fn WSCSetApplicationCategoryEx(); pub fn WSCSetProviderInfo( lpProviderId: LPGUID, InfoType: WSC_PROVIDER_INFO_TYPE, Info: PBYTE, InfoSize: size_t, Flags: DWORD, lpErrno: LPINT, ) -> c_int; pub fn WSCUnInstallNameSpace(lpProviderId: LPGUID) -> INT; // pub fn WSCUnInstallNameSpaceEx2(); pub fn WSCUpdateProvider( lpProviderId: LPGUID, lpszProviderDllPath: *const WCHAR, lpProtocolInfoList: LPWSAPROTOCOL_INFOW, dwNumberOfEntries: DWORD, lpErrno: LPINT, ) -> c_int; // pub fn WSCUpdateProviderEx(); pub fn WSCWriteNameSpaceOrder(lpProviderId: LPGUID, dwNumberOfEntries: DWORD) -> c_int; pub fn WSCWriteProviderOrder(lpwdCatalogEntryId: LPDWORD, dwNumberOfEntries: DWORD) -> c_int; // pub fn WSCWriteProviderOrderEx(); // pub fn WahCloseApcHelper(); // pub fn WahCloseHandleHelper(); // pub fn WahCloseNotificationHandleHelper(); // pub fn WahCloseSocketHandle(); // pub fn WahCloseThread(); // pub fn WahCompleteRequest(); // pub fn WahCreateHandleContextTable(); // pub fn WahCreateNotificationHandle(); // pub fn WahCreateSocketHandle(); // pub fn WahDestroyHandleContextTable(); // pub fn WahDisableNonIFSHandleSupport(); // pub fn WahEnableNonIFSHandleSupport(); // pub fn WahEnumerateHandleContexts(); // pub fn WahInsertHandleContext(); // pub fn WahNotifyAllProcesses(); // pub fn WahOpenApcHelper(); // pub fn WahOpenCurrentThread(); // pub fn WahOpenHandleHelper(); // pub fn WahOpenNotificationHandleHelper(); // pub fn WahQueueUserApc(); // pub fn WahReferenceContextByHandle(); // pub fn WahRemoveHandleContext(); // pub fn WahWaitForNotification(); // pub fn WahWriteLSPEvent(); pub fn __WSAFDIsSet(fd: SOCKET, _: *mut fd_set) -> c_int; pub fn accept(s: SOCKET, addr: *mut SOCKADDR, addrlen: *mut c_int) -> SOCKET; pub fn bind(s: SOCKET, name: *const SOCKADDR, namelen: c_int) -> c_int; pub fn closesocket(s: SOCKET) -> c_int; pub fn connect(s: SOCKET, name: *const SOCKADDR, namelen: c_int) -> c_int; pub fn freeaddrinfo(pAddrInfo: PADDRINFOA); pub fn getaddrinfo( pNodeName: PCSTR, pServiceName: PCSTR, pHints: *const ADDRINFOA, ppResult: *mut PADDRINFOA, ) -> INT; pub fn gethostbyaddr(addr: *const c_char, len: c_int, _type: c_int) -> *mut hostent; pub fn gethostbyname(name: *const c_char) -> *mut hostent; pub fn gethostname(name: *mut c_char, namelen: c_int) -> c_int; pub fn getnameinfo( pSockaddr: *const SOCKADDR, SockaddrLength: socklen_t, pNodeBuffer: PCHAR, NodeBufferSize: DWORD, pServiceBuffer: PCHAR, ServiceBufferSize: DWORD, Flags: INT, ) -> INT; pub fn getpeername(s: SOCKET, name: *mut SOCKADDR, namelen: *mut c_int) -> c_int; pub fn getprotobyname(name: *const c_char) -> *mut protoent; pub fn getprotobynumber(number: c_int) -> *mut protoent; pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent; pub fn getservbyport(port: c_int, proto: *const c_char) -> *mut servent; pub fn getsockname(s: SOCKET, name: *mut SOCKADDR, namelen: *mut c_int) -> c_int; pub fn getsockopt( s: SOCKET, level: c_int, optname: c_int, optval: *mut c_char, optlen: *mut c_int, ) -> c_int; pub fn htonl(hostlong: u_long) -> u_long; pub fn htons(hostshort: u_short) -> u_short; pub fn inet_addr(cp: *const c_char) -> c_ulong; pub fn inet_ntoa(_in: in_addr) -> *mut c_char; pub fn inet_ntop(Family: INT, pAddr: PVOID, pStringBuf: PSTR, StringBufSize: size_t) -> PCSTR; pub fn inet_pton(Family: INT, pszAddrString: PCSTR, pAddrBuf: PVOID) -> INT; pub fn ioctlsocket(s: SOCKET, cmd: c_long, argp: *mut u_long) -> c_int; pub fn listen(s: SOCKET, backlog: c_int) -> c_int; pub fn ntohl(netlong: u_long) -> u_long; pub fn ntohs(netshort: u_short) -> u_short; pub fn recv(s: SOCKET, buf: *mut c_char, len: c_int, flags: c_int) -> c_int; pub fn recvfrom( s: SOCKET, buf: *mut c_char, len: c_int, flags: c_int, from: *mut SOCKADDR, fromlen: *mut c_int, ) -> c_int; pub fn select( nfds: c_int, readfds: *mut fd_set, writefds: *mut fd_set, exceptfds: *mut fd_set, timeout: *const timeval, ) -> c_int; pub fn send(s: SOCKET, buf: *const c_char, len: c_int, flags: c_int) -> c_int; pub fn sendto( s: SOCKET, buf: *const c_char, len: c_int, flags: c_int, to: *const SOCKADDR, tolen: c_int, ) -> c_int; pub fn setsockopt( s: SOCKET, level: c_int, optname: c_int, optval: *const c_char, optlen: c_int, ) -> c_int; pub fn shutdown(s: SOCKET, how: c_int) -> c_int; pub fn socket(af: c_int, _type: c_int, protocol: c_int) -> SOCKET; } #[cfg(any(target_arch = "x86", target_arch = "arm"))] extern "system" { pub fn WSCInstallProviderAndChains( lpProviderId: LPGUID, lpszProviderDllPath: LPWSTR, lpszLspName: LPWSTR, dwServiceFlags: DWORD, lpProtocolInfoList: LPWSAPROTOCOL_INFOW, dwNumberOfEntries: DWORD, lpdwCatalogEntryId: LPDWORD, lpErrno: LPINT, ) -> c_int; } #[cfg(target_arch = "x86_64")] extern "system" { pub fn WSCDeinstallProvider32(lpProviderId: LPGUID, lpErrno: LPINT) -> c_int; pub fn WSCEnableNSProvider32(lpProviderId: LPGUID, fEnable: BOOL) -> INT; pub fn WSCEnumNameSpaceProviders32( lpdwBufferLength: LPDWORD, lpnspBuffer: LPWSANAMESPACE_INFOW, ) -> INT; pub fn WSCEnumNameSpaceProvidersEx32( lpdwBufferLength: LPDWORD, lpnspBuffer: LPWSANAMESPACE_INFOEXW, ) -> INT; pub fn WSCEnumProtocols32( lpiProtocols: LPINT, lpProtocolBuffer: LPWSAPROTOCOL_INFOW, lpdwBufferLength: LPDWORD, lpErrno: LPINT, ) -> c_int; pub fn WSCGetProviderInfo32( lpProviderId: LPGUID, InfoType: WSC_PROVIDER_INFO_TYPE, Info: PBYTE, InfoSize: *mut size_t, Flags: DWORD, lpErrno: LPINT, ) -> c_int; pub fn WSCGetProviderPath32( lpProviderId: LPGUID, lpszProviderDllPath: *mut WCHAR, lpProviderDllPathLen: LPINT, lpErrno: LPINT, ) -> c_int; pub fn WSCInstallNameSpace32( lpszIdentifier: LPWSTR, lpszPathName: LPWSTR, dwNameSpace: DWORD, dwVersion: DWORD, lpProviderId: LPGUID, ) -> INT; pub fn WSCInstallNameSpaceEx32( lpszIdentifier: LPWSTR, lpszPathName: LPWSTR, dwNameSpace: DWORD, dwVersion: DWORD, lpProviderId: LPGUID, lpProviderSpecific: LPBLOB, ) -> INT; pub fn WSCInstallProvider64_32( lpProviderId: LPGUID, lpszProviderDllPath: *const WCHAR, lpProtocolInfoList: LPWSAPROTOCOL_INFOW, dwNumberOfEntries: DWORD, lpErrno: LPINT, ) -> c_int; pub fn WSCInstallProviderAndChains64_32( lpProviderId: LPGUID, lpszProviderDllPath: LPWSTR, lpszProviderDllPath32: LPWSTR, lpszLspName: LPWSTR, dwServiceFlags: DWORD, lpProtocolInfoList: LPWSAPROTOCOL_INFOW, dwNumberOfEntries: DWORD, lpdwCatalogEntryId: LPDWORD, lpErrno: LPINT, ) -> c_int; pub fn WSCSetProviderInfo32( lpProviderId: LPGUID, InfoType: WSC_PROVIDER_INFO_TYPE, Info: PBYTE, InfoSize: size_t, Flags: DWORD, lpErrno: LPINT, ) -> c_int; pub fn WSCUnInstallNameSpace32(lpProviderId: LPGUID) -> INT; pub fn WSCUpdateProvider32( lpProviderId: LPGUID, lpszProviderDllPath: *const WCHAR, lpProtocolInfoList: LPWSAPROTOCOL_INFOW, dwNumberOfEntries: DWORD, lpErrno: LPINT, ) -> c_int; pub fn WSCWriteNameSpaceOrder32(lpProviderId: LPGUID, dwNumberOfEntries: DWORD) -> c_int; pub fn WSCWriteProviderOrder32(lpwdCatalogEntryId: LPDWORD, dwNumberOfEntries: DWORD) -> c_int; } extern { // pub static AddressFamilyInformation; // pub static eui48_broadcast; // pub static in4addr_alligmpv3routersonlink; // pub static in4addr_allnodesonlink; // pub static in4addr_allroutersonlink; // pub static in4addr_allteredohostsonlink; // pub static in4addr_any; // pub static in4addr_broadcast; // pub static in4addr_linklocalprefix; // pub static in4addr_loopback; // pub static in4addr_multicastprefix; // pub static in6addr_6to4prefix; // pub static in6addr_allmldv2routersonlink; // pub static in6addr_allnodesonlink; // pub static in6addr_allnodesonnode; // pub static in6addr_allroutersonlink; // pub static in6addr_any; // pub static in6addr_linklocalprefix; // pub static in6addr_loopback; // pub static in6addr_multicastprefix; // pub static in6addr_solicitednodemulticastprefix; // pub static in6addr_teredoinitiallinklocaladdress; // pub static in6addr_teredoprefix; // pub static in6addr_teredoprefix_old; // pub static in6addr_v4mappedprefix; // pub static scopeid_unspecified; // pub static sockaddr_size; } deps/ws2_32-sys-0.2.1/Cargo.toml0000644000000000000000000000111112620726764014734 0ustar rootroot[package] name = "ws2_32-sys" version = "0.2.1" authors = ["Peter Atashian "] description = "Contains function definitions for the Windows API library ws2_32. See winapi for types and constants." documentation = "https://retep998.github.io/doc/ws2_32/" repository = "https://github.com/retep998/winapi-rs" readme = "README.md" keywords = ["windows", "ffi", "win32"] license = "MIT" build = "build.rs" [lib] name = "ws2_32" [dependencies] winapi = { version = "0.2.5", path = "../.." } [build-dependencies] winapi-build = { version = "0.1.1", path = "../../build" } deps/ws2_32-sys-0.2.1/build.rs0000644000000000000000000000022712620207001014432 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License extern crate build; fn main() { build::link("ws2_32", false) } deps/gdi32-sys-0.1.1/0000755000000000000000000000000012666635520012701 5ustar rootrootdeps/gdi32-sys-0.1.1/README.md0000644000000000000000000000014112505610122014133 0ustar rootroot# gdi32-sys # FFI bindings to gdi32. [Documentation](https://retep998.github.io/doc/gdi32-sys/) deps/gdi32-sys-0.1.1/src/0000755000000000000000000000000012666635520013470 5ustar rootrootdeps/gdi32-sys-0.1.1/src/lib.rs0000644000000000000000000005305112533152124014573 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! FFI bindings to gdi32. #![cfg(all(windows, any(target_arch = "x86", target_arch = "x86_64")))] extern crate winapi; use winapi::*; extern "system" { // pub fn AbortDoc(); // pub fn AbortPath(); // pub fn AddFontMemResourceEx(); // pub fn AddFontResourceA(); // pub fn AddFontResourceExA(); // pub fn AddFontResourceExW(); // pub fn AddFontResourceW(); pub fn AngleArc( hdc: HDC, X: c_int, Y: c_int, dwRadius: DWORD, eStartAngle: FLOAT, eSweepAngle: FLOAT, ) -> BOOL; // pub fn AnimatePalette(); pub fn Arc( hdc: HDC, nLeftRect: c_int, nTopRect: c_int, nRightRect: c_int, nBottomRect: c_int, nXStartArc: c_int, nYStartArc: c_int, nXEndArc: c_int, nYEndArc: c_int, ) -> BOOL; pub fn ArcTo( hdc: HDC, nLeftRect: c_int, nTopRect: c_int, nRightRect: c_int, nBottomRect: c_int, nXRadial1: c_int, nYRadial1: c_int, nXRadial2: c_int, nYRadial2: c_int, ) -> BOOL; // pub fn BeginPath(); pub fn BitBlt( hdc: HDC, x: c_int, y: c_int, cx: c_int, cy: c_int, hdcSrc: HDC, x1: c_int, y1: c_int, rop: DWORD, ) -> BOOL; // pub fn CancelDC(); // pub fn CheckColorsInGamut(); pub fn ChoosePixelFormat(hdc: HDC, ppfd: *const PIXELFORMATDESCRIPTOR) -> c_int; pub fn Chord( hdc: HDC, nLeftRect: c_int, nTopRect: c_int, nRightRect: c_int, nBottomRect: c_int, nXRadial1: c_int, nYRadial1: c_int, nXRadial2: c_int, nYRadial2: c_int, ) -> BOOL; // pub fn CloseEnhMetaFile(); // pub fn CloseFigure(); // pub fn CloseMetaFile(); // pub fn ColorCorrectPalette(); // pub fn ColorMatchToTarget(); pub fn CombineRgn( hrgnDst: HRGN, hrgnSrc1: HRGN, hrgnSrc2: HRGN, fnCombineMode: c_int, ) -> c_int; // pub fn CombineTransform(); // pub fn CopyEnhMetaFileA(); // pub fn CopyEnhMetaFileW(); // pub fn CopyMetaFileA(); // pub fn CopyMetaFileW(); pub fn CreateBitmap( nWidth: c_int, nHeight: c_int, nPlanes: UINT, nBitCount: UINT, lpBits: *const c_void, ) -> HBITMAP; pub fn CreateBitmapIndirect(pbm: *const BITMAP) -> HBITMAP; // pub fn CreateBrushIndirect(); // pub fn CreateColorSpaceA(); // pub fn CreateColorSpaceW(); pub fn CreateCompatibleBitmap(hdc: HDC, cx: c_int, cy: c_int) -> HBITMAP; pub fn CreateCompatibleDC(hdc: HDC) -> HDC; pub fn CreateDCA( lpszDriver: LPCSTR, lpszDevice: LPCSTR, lpszOutput: LPCSTR, lpInitData: *const DEVMODEA, ) -> HDC; pub fn CreateDCW( lpszDriver: LPCWSTR, lpszDevice: LPCWSTR, lpszOutput: LPCWSTR, lpInitData: *const DEVMODEW, ) -> HDC; // pub fn CreateDIBPatternBrush(); // pub fn CreateDIBPatternBrushPt(); pub fn CreateDIBSection( hdc: HDC, lpbmi: *const BITMAPINFO, usage: UINT, ppvBits: *mut *mut c_void, hSection: HANDLE, offset: DWORD, ) -> HBITMAP; pub fn CreateDIBitmap( hdc: HDC, pbmih: *const BITMAPINFOHEADER, flInit: DWORD, pjBits: *const c_void, pbmi: *const BITMAPINFO, iUsage: UINT, ) -> HBITMAP; // pub fn CreateDiscardableBitmap(); // pub fn CreateEllipticRgn(); // pub fn CreateEllipticRgnIndirect(); // pub fn CreateEnhMetaFileA(); // pub fn CreateEnhMetaFileW(); pub fn CreateFontA( cHeight: c_int, cWidth: c_int, cEscapement: c_int, cOrientation: c_int, cWeight: c_int, bItalic: DWORD, bUnderline: DWORD, bStrikeOut: DWORD, iCharSet: DWORD, iOutPrecision: DWORD, iClipPrecision: DWORD, iQuality: DWORD, iPitchAndFamily: DWORD, pszFaceName: LPCSTR, ) -> HFONT; pub fn CreateFontIndirectA(lplf: *const LOGFONTA) -> HFONT; // pub fn CreateFontIndirectExA(); // pub fn CreateFontIndirectExW(); pub fn CreateFontIndirectW(lplf: *const LOGFONTW) -> HFONT; pub fn CreateFontW( cHeight: c_int, cWidth: c_int, cEscapement: c_int, cOrientation: c_int, cWeight: c_int, bItalic: DWORD, bUnderline: DWORD, bStrikeOut: DWORD, iCharSet: DWORD, iOutPrecision: DWORD, iClipPrecision: DWORD, iQuality: DWORD, iPitchAndFamily: DWORD, pszFaceName: LPCWSTR, ) -> HFONT; // pub fn CreateHalftonePalette(); // pub fn CreateHatchBrush(); // pub fn CreateICA(); // pub fn CreateICW(); // pub fn CreateMetaFileA(); // pub fn CreateMetaFileW(); // pub fn CreatePalette(); // pub fn CreatePatternBrush(); // pub fn CreatePen(); // pub fn CreatePenIndirect(); // pub fn CreatePolyPolygonRgn(); // pub fn CreatePolygonRgn(); pub fn CreateRectRgn( nLeftRect: c_int, nTopRect: c_int, nRightRect: c_int, nBottomRect: c_int, ) -> HRGN; // pub fn CreateRectRgnIndirect(); // pub fn CreateRoundRectRgn(); // pub fn CreateScalableFontResourceA(); // pub fn CreateScalableFontResourceW(); pub fn CreateSolidBrush(color: COLORREF) -> HBRUSH; // pub fn D3DKMTAcquireKeyedMutex(); // pub fn D3DKMTAcquireKeyedMutex2(); // pub fn D3DKMTCacheHybridQueryValue(); // pub fn D3DKMTCheckExclusiveOwnership(); // pub fn D3DKMTCheckMonitorPowerState(); // pub fn D3DKMTCheckMultiPlaneOverlaySupport(); // pub fn D3DKMTCheckOcclusion(); // pub fn D3DKMTCheckSharedResourceAccess(); // pub fn D3DKMTCheckVidPnExclusiveOwnership(); // pub fn D3DKMTCloseAdapter(); // pub fn D3DKMTConfigureSharedResource(); // pub fn D3DKMTCreateAllocation(); // pub fn D3DKMTCreateAllocation2(); // pub fn D3DKMTCreateContext(); // pub fn D3DKMTCreateDCFromMemory(); // pub fn D3DKMTCreateDevice(); // pub fn D3DKMTCreateKeyedMutex(); // pub fn D3DKMTCreateKeyedMutex2(); // pub fn D3DKMTCreateOutputDupl(); // pub fn D3DKMTCreateOverlay(); // pub fn D3DKMTCreateSynchronizationObject(); // pub fn D3DKMTCreateSynchronizationObject2(); // pub fn D3DKMTDestroyAllocation(); // pub fn D3DKMTDestroyContext(); // pub fn D3DKMTDestroyDCFromMemory(); // pub fn D3DKMTDestroyDevice(); // pub fn D3DKMTDestroyKeyedMutex(); // pub fn D3DKMTDestroyOutputDupl(); // pub fn D3DKMTDestroyOverlay(); // pub fn D3DKMTDestroySynchronizationObject(); // pub fn D3DKMTEnumAdapters(); // pub fn D3DKMTEscape(); // pub fn D3DKMTFlipOverlay(); // pub fn D3DKMTGetCachedHybridQueryValue(); // pub fn D3DKMTGetContextInProcessSchedulingPriority(); // pub fn D3DKMTGetContextSchedulingPriority(); // pub fn D3DKMTGetDeviceState(); // pub fn D3DKMTGetDisplayModeList(); // pub fn D3DKMTGetMultisampleMethodList(); // pub fn D3DKMTGetOverlayState(); // pub fn D3DKMTGetPresentHistory(); // pub fn D3DKMTGetPresentQueueEvent(); // pub fn D3DKMTGetProcessSchedulingPriorityClass(); // pub fn D3DKMTGetRuntimeData(); // pub fn D3DKMTGetScanLine(); // pub fn D3DKMTGetSharedPrimaryHandle(); // pub fn D3DKMTGetSharedResourceAdapterLuid(); // pub fn D3DKMTInvalidateActiveVidPn(); // pub fn D3DKMTLock(); // pub fn D3DKMTNetDispGetNextChunkInfo(); // pub fn D3DKMTNetDispQueryMiracastDisplayDeviceStatus(); // pub fn D3DKMTNetDispQueryMiracastDisplayDeviceSupport(); // pub fn D3DKMTNetDispStartMiracastDisplayDevice2(); // pub fn D3DKMTNetDispStopMiracastDisplayDevice(); // pub fn D3DKMTOfferAllocations(); // pub fn D3DKMTOpenAdapterFromDeviceName(); // pub fn D3DKMTOpenAdapterFromGdiDisplayName(); // pub fn D3DKMTOpenAdapterFromHdc(); // pub fn D3DKMTOpenAdapterFromLuid(); // pub fn D3DKMTOpenKeyedMutex(); // pub fn D3DKMTOpenKeyedMutex2(); // pub fn D3DKMTOpenNtHandleFromName(); // pub fn D3DKMTOpenResource(); // pub fn D3DKMTOpenResource2(); // pub fn D3DKMTOpenResourceFromNtHandle(); // pub fn D3DKMTOpenSyncObjectFromNtHandle(); // pub fn D3DKMTOpenSynchronizationObject(); // pub fn D3DKMTOutputDuplGetFrameInfo(); // pub fn D3DKMTOutputDuplGetMetaData(); // pub fn D3DKMTOutputDuplGetPointerShapeData(); // pub fn D3DKMTOutputDuplPresent(); // pub fn D3DKMTOutputDuplReleaseFrame(); // pub fn D3DKMTPinDirectFlipResources(); // pub fn D3DKMTPollDisplayChildren(); // pub fn D3DKMTPresent(); // pub fn D3DKMTPresentMultiPlaneOverlay(); // pub fn D3DKMTQueryAdapterInfo(); // pub fn D3DKMTQueryAllocationResidency(); // pub fn D3DKMTQueryRemoteVidPnSourceFromGdiDisplayName(); // pub fn D3DKMTQueryResourceInfo(); // pub fn D3DKMTQueryResourceInfoFromNtHandle(); // pub fn D3DKMTQueryStatistics(); // pub fn D3DKMTReclaimAllocations(); // pub fn D3DKMTReleaseKeyedMutex(); // pub fn D3DKMTReleaseKeyedMutex2(); // pub fn D3DKMTReleaseProcessVidPnSourceOwners(); // pub fn D3DKMTRender(); // pub fn D3DKMTSetAllocationPriority(); // pub fn D3DKMTSetContextInProcessSchedulingPriority(); // pub fn D3DKMTSetContextSchedulingPriority(); // pub fn D3DKMTSetDisplayMode(); // pub fn D3DKMTSetDisplayPrivateDriverFormat(); // pub fn D3DKMTSetGammaRamp(); // pub fn D3DKMTSetProcessSchedulingPriorityClass(); // pub fn D3DKMTSetQueuedLimit(); // pub fn D3DKMTSetStereoEnabled(); // pub fn D3DKMTSetVidPnSourceOwner(); // pub fn D3DKMTSetVidPnSourceOwner1(); // pub fn D3DKMTShareObjects(); // pub fn D3DKMTSharedPrimaryLockNotification(); // pub fn D3DKMTSharedPrimaryUnLockNotification(); // pub fn D3DKMTSignalSynchronizationObject(); // pub fn D3DKMTSignalSynchronizationObject2(); // pub fn D3DKMTUnlock(); // pub fn D3DKMTUnpinDirectFlipResources(); // pub fn D3DKMTUpdateOverlay(); // pub fn D3DKMTWaitForIdle(); // pub fn D3DKMTWaitForSynchronizationObject(); // pub fn D3DKMTWaitForSynchronizationObject2(); // pub fn D3DKMTWaitForVerticalBlankEvent(); // pub fn D3DKMTWaitForVerticalBlankEvent2(); // pub fn DPtoLP(); // pub fn DeleteColorSpace(); pub fn DeleteDC(hdc: HDC) -> BOOL; // pub fn DeleteEnhMetaFile(); // pub fn DeleteMetaFile(); pub fn DeleteObject(ho: HGDIOBJ) -> BOOL; pub fn DescribePixelFormat( hdc: HDC, iPixelFormat: c_int, nBytes: UINT, ppfd: LPPIXELFORMATDESCRIPTOR, ) -> c_int; // pub fn DeviceCapabilitiesExA(); // pub fn DeviceCapabilitiesExW(); // pub fn DrawEscape(); pub fn Ellipse(hdc: HDC, left: c_int, top: c_int, right: c_int, bottom: c_int) -> BOOL; // pub fn EnableEUDC(); // pub fn EndDoc(); // pub fn EndFormPage(); // pub fn EndPage(); // pub fn EndPath(); // pub fn EnumEnhMetaFile(); // pub fn EnumFontFamiliesA(); // pub fn EnumFontFamiliesExA(); // pub fn EnumFontFamiliesExW(); // pub fn EnumFontFamiliesW(); // pub fn EnumFontsA(); // pub fn EnumFontsW(); // pub fn EnumICMProfilesA(); // pub fn EnumICMProfilesW(); // pub fn EnumMetaFile(); // pub fn EnumObjects(); // pub fn EqualRgn(); // pub fn Escape(); // pub fn EudcLoadLinkW(); // pub fn EudcUnloadLinkW(); // pub fn ExcludeClipRect(); // pub fn ExtCreatePen(); // pub fn ExtCreateRegion(); // pub fn ExtEscape(); // pub fn ExtFloodFill(); pub fn ExtSelectClipRgn(hdc: HDC, hrgn: HRGN, mode: c_int) -> c_int; // pub fn ExtTextOutA(); // pub fn ExtTextOutW(); // pub fn FillPath(); // pub fn FillRgn(); // pub fn FixBrushOrgEx(); // pub fn FlattenPath(); // pub fn FloodFill(); // pub fn FrameRgn(); // pub fn GdiAlphaBlend(); // pub fn GdiArtificialDecrementDriver(); // pub fn GdiComment(); // pub fn GdiDeleteSpoolFileHandle(); // pub fn GdiEndDocEMF(); // pub fn GdiEndPageEMF(); // pub fn GdiFlush(); // pub fn GdiGetBatchLimit(); // pub fn GdiGetDC(); // pub fn GdiGetDevmodeForPage(); // pub fn GdiGetPageCount(); // pub fn GdiGetPageHandle(); // pub fn GdiGetSpoolFileHandle(); // pub fn GdiGradientFill(); // pub fn GdiPlayDCScript(); // pub fn GdiPlayEMF(); // pub fn GdiPlayJournal(); // pub fn GdiPlayPageEMF(); // pub fn GdiPlayPrivatePageEMF(); // pub fn GdiPlayScript(); // pub fn GdiResetDCEMF(); // pub fn GdiSetBatchLimit(); // pub fn GdiStartDocEMF(); // pub fn GdiStartPageEMF(); // pub fn GdiTransparentBlt(); pub fn GetArcDirection(hdc: HDC) -> c_int; // pub fn GetAspectRatioFilterEx(); // pub fn GetBitmapBits(); // pub fn GetBitmapDimensionEx(); // pub fn GetBkColor(); // pub fn GetBkMode(); // pub fn GetBoundsRect(); // pub fn GetBrushOrgEx(); // pub fn GetCharABCWidthsA(); // pub fn GetCharABCWidthsFloatA(); // pub fn GetCharABCWidthsFloatW(); // pub fn GetCharABCWidthsI(); // pub fn GetCharABCWidthsW(); // pub fn GetCharWidth32A(); // pub fn GetCharWidth32W(); // pub fn GetCharWidthA(); // pub fn GetCharWidthFloatA(); // pub fn GetCharWidthFloatW(); // pub fn GetCharWidthI(); // pub fn GetCharWidthW(); // pub fn GetCharacterPlacementA(); // pub fn GetCharacterPlacementW(); // pub fn GetClipBox(); // pub fn GetClipRgn(); // pub fn GetColorAdjustment(); // pub fn GetColorSpace(); // pub fn GetCurrentObject(); // pub fn GetCurrentPositionEx(); // pub fn GetDCBrushColor(); // pub fn GetDCOrgEx(); // pub fn GetDCPenColor(); // pub fn GetDIBColorTable(); pub fn GetDIBits( hdc: HDC, hbm: HBITMAP, start: UINT, cLines: UINT, lpvBits: LPVOID, lpbmi: LPBITMAPINFO, usage: UINT ) -> c_int; // pub fn GetDeviceCaps(); // pub fn GetDeviceGammaRamp(); // pub fn GetEnhMetaFileA(); // pub fn GetEnhMetaFileBits(); // pub fn GetEnhMetaFileDescriptionA(); // pub fn GetEnhMetaFileDescriptionW(); // pub fn GetEnhMetaFileHeader(); // pub fn GetEnhMetaFilePaletteEntries(); // pub fn GetEnhMetaFilePixelFormat(); // pub fn GetEnhMetaFileW(); // pub fn GetFontAssocStatus(); // pub fn GetFontData(); // pub fn GetFontLanguageInfo(); // pub fn GetFontResourceInfoW(); // pub fn GetFontUnicodeRanges(); // pub fn GetGlyphIndicesA(); // pub fn GetGlyphIndicesW(); // pub fn GetGlyphOutline(); // pub fn GetGlyphOutlineA(); // pub fn GetGlyphOutlineW(); // pub fn GetGraphicsMode(); // pub fn GetICMProfileA(); // pub fn GetICMProfileW(); // pub fn GetKerningPairs(); // pub fn GetKerningPairsA(); // pub fn GetKerningPairsW(); // pub fn GetLayout(); // pub fn GetLogColorSpaceA(); // pub fn GetLogColorSpaceW(); // pub fn GetMapMode(); // pub fn GetMetaFileA(); // pub fn GetMetaFileBitsEx(); // pub fn GetMetaFileW(); // pub fn GetMetaRgn(); // pub fn GetMiterLimit(); // pub fn GetNearestColor(); // pub fn GetNearestPaletteIndex(); // pub fn GetObjectA(); // pub fn GetObjectType(); // pub fn GetObjectW(); // pub fn GetOutlineTextMetricsA(); // pub fn GetOutlineTextMetricsW(); // pub fn GetPaletteEntries(); // pub fn GetPath(); // pub fn GetPixel(); // pub fn GetPixelFormat(); // pub fn GetPolyFillMode(); // pub fn GetROP2(); // pub fn GetRandomRgn(); // pub fn GetRasterizerCaps(); // pub fn GetRegionData(); // pub fn GetRelAbs(); // pub fn GetRgnBox(); pub fn GetStockObject(i: c_int) -> HGDIOBJ; // pub fn GetStretchBltMode(); // pub fn GetSystemPaletteEntries(); // pub fn GetSystemPaletteUse(); // pub fn GetTextAlign(); // pub fn GetTextCharacterExtra(); // pub fn GetTextCharset(); // pub fn GetTextCharsetInfo(); // pub fn GetTextColor(); // pub fn GetTextExtentExPointA(); // pub fn GetTextExtentExPointI(); // pub fn GetTextExtentExPointW(); // pub fn GetTextExtentPoint32A(); // pub fn GetTextExtentPoint32W(); // pub fn GetTextExtentPointA(); // pub fn GetTextExtentPointI(); // pub fn GetTextExtentPointW(); // pub fn GetTextFaceA(); // pub fn GetTextFaceW(); // pub fn GetTextMetricsA(); // pub fn GetTextMetricsW(); // pub fn GetViewportExtEx(); // pub fn GetViewportOrgEx(); // pub fn GetWinMetaFileBits(); // pub fn GetWindowExtEx(); // pub fn GetWindowOrgEx(); // pub fn GetWorldTransform(); // pub fn IntersectClipRect(); // pub fn InvertRgn(); // pub fn LPtoDP(); pub fn LineDDA( nXStart: c_int, nYStart: c_int, nXEnd: c_int, nYEnd: c_int, lpLineFunc: LINEDDAPROC, lpData: LPARAM, ) -> BOOL; pub fn LineTo(hdc: HDC, nXEnd: c_int, nYEnd: c_int); // pub fn MaskBlt(); // pub fn ModifyWorldTransform(); pub fn MoveToEx(hdc: HDC, X: c_int, Y: c_int, lpPoint:LPPOINT) -> BOOL; // pub fn OffsetClipRgn(); // pub fn OffsetRgn(); // pub fn OffsetViewportOrgEx(); // pub fn OffsetWindowOrgEx(); // pub fn PaintRgn(); pub fn PatBlt( hdc: HDC, nXLeft: c_int, nYLeft: c_int, nWidth: c_int, nHeight: c_int, dwRop: DWORD ) -> BOOL; // pub fn PathToRegion(); pub fn Pie( hdc: HDC, nLeftRect: c_int, nTopRect: c_int, nBottomRect: c_int, nXRadial1: c_int, nYRadial1: c_int, nXRadial2: c_int, nYRadial2: c_int, ) -> BOOL; // pub fn PlayEnhMetaFile(); // pub fn PlayEnhMetaFileRecord(); // pub fn PlayMetaFile(); // pub fn PlayMetaFileRecord(); // pub fn PlgBlt(); pub fn PolyBezier(hdc: HDC, lppt: *const POINT, cPoints: DWORD) -> BOOL; pub fn PolyBezierTo(hdc: HDC, lppt: *const POINT, cPoints: DWORD) -> BOOL; pub fn PolyDraw(hdc: HDC, lppt: *const POINT, lpbTypes: *const BYTE, cCount: c_int) -> BOOL; pub fn PolyPolygon( hdc: HDC, lpPoints: *const POINT, lpPolyCounts: *const INT, cCount: DWORD, ) -> BOOL; pub fn PolyPolyline( hdc: HDC, lppt: *const POINT, lpdwPolyPoints: *const DWORD, cCount: DWORD, ) -> BOOL; // pub fn PolyTextOutA(); // pub fn PolyTextOutW(); pub fn Polygon(hdc: HDC, lpPoints: *const POINT, nCount: c_int) -> BOOL; pub fn Polyline(hdc: HDC, lppt: *const POINT, cCount: c_int) -> BOOL; pub fn PolylineTo(hdc: HDC, lppt: *const POINT, cCount: DWORD) -> BOOL; // pub fn PtInRegion(); // pub fn PtVisible(); // pub fn RealizePalette(); // pub fn RectInRegion(); // pub fn RectVisible(); pub fn Rectangle(hdc: HDC, left: c_int, top: c_int, right: c_int, bottom: c_int) -> BOOL; // pub fn RemoveFontMemResourceEx(); // pub fn RemoveFontResourceA(); // pub fn RemoveFontResourceExA(); // pub fn RemoveFontResourceExW(); // pub fn RemoveFontResourceW(); // pub fn ResetDCA(); // pub fn ResetDCW(); // pub fn ResizePalette(); // pub fn RestoreDC(); pub fn RoundRect( hdc: HDC, nLeftRect: c_int, nTopRect: c_int, nRightRect: c_int, nBottomRect: c_int, nWidth: c_int, nHeight: c_int, ) -> BOOL; // pub fn SaveDC(); // pub fn ScaleViewportExtEx(); // pub fn ScaleWindowExtEx(); // pub fn SelectBrushLocal(); // pub fn SelectClipPath(); pub fn SelectClipRgn(hdc: HDC, hrgn: HRGN) -> c_int; // pub fn SelectFontLocal(); pub fn SelectObject(hdc: HDC, h: HGDIOBJ) -> HGDIOBJ; // pub fn SelectPalette(); // pub fn SetAbortProc(); pub fn SetArcDirection(hdc: HDC, ArcDirection: c_int) -> c_int; // pub fn SetBitmapBits(); // pub fn SetBitmapDimensionEx(); pub fn SetBkColor(hdc: HDC, color: COLORREF) -> COLORREF; // pub fn SetBkMode(); // pub fn SetBoundsRect(); // pub fn SetBrushOrgEx(); // pub fn SetColorAdjustment(); // pub fn SetColorSpace(); pub fn SetDCBrushColor(hdc: HDC, color: COLORREF) -> COLORREF; // pub fn SetDCPenColor(); // pub fn SetDIBColorTable(); // pub fn SetDIBits(); // pub fn SetDIBitsToDevice(); // pub fn SetDeviceGammaRamp(); // pub fn SetEnhMetaFileBits(); // pub fn SetFontEnumeration(); // pub fn SetGraphicsMode(); // pub fn SetICMMode(); // pub fn SetICMProfileA(); // pub fn SetICMProfileW(); // pub fn SetLayout(); // pub fn SetMagicColors(); // pub fn SetMapMode(); // pub fn SetMapperFlags(); // pub fn SetMetaFileBitsEx(); // pub fn SetMetaRgn(); // pub fn SetMiterLimit(); // pub fn SetPaletteEntries(); // pub fn SetPixel(); pub fn SetPixelFormat( hdc: HDC, iPixelFormat: c_int, ppfd: *const PIXELFORMATDESCRIPTOR, ) -> BOOL; // pub fn SetPixelV(); // pub fn SetPolyFillMode(); // pub fn SetROP2(); pub fn SetRectRgn(hrgn: HRGN, left: c_int, top: c_int, right: c_int, bottom: c_int) -> BOOL; // pub fn SetRelAbs(); // pub fn SetStretchBltMode(); // pub fn SetSystemPaletteUse(); // pub fn SetTextAlign(); // pub fn SetTextCharacterExtra(); pub fn SetTextColor(hdc: HDC, color: COLORREF) -> COLORREF; // pub fn SetTextJustification(); // pub fn SetViewportExtEx(); // pub fn SetViewportOrgEx(); // pub fn SetWinMetaFileBits(); // pub fn SetWindowExtEx(); // pub fn SetWindowOrgEx(); // pub fn SetWorldTransform(); // pub fn StartDocA(); // pub fn StartDocW(); // pub fn StartFormPage(); // pub fn StartPage(); // pub fn StretchBlt(); pub fn StretchDIBits( hdc: HDC, XDest: c_int, YDest: c_int, nDestWidth: c_int, nDestHeight: c_int, XSrc: c_int, YSrc: c_int, nSrcWidth: c_int, nSrcHeight: c_int, lpBits: *const VOID, lpBitsInfo: *const BITMAPINFO, iUsage: UINT, dwRop: DWORD ) -> c_int; // pub fn StrokeAndFillPath(); // pub fn StrokePath(); pub fn SwapBuffers(hdc: HDC) -> BOOL; pub fn TextOutA(hdc: HDC, x: c_int, y: c_int, lpString: LPCSTR, c: c_int) -> BOOL; pub fn TextOutW(hdc: HDC, x: c_int, y: c_int, lpString: LPCWSTR, c: c_int) -> BOOL; // pub fn TranslateCharsetInfo(); // pub fn UnrealizeObject(); // pub fn UpdateColors(); // pub fn UpdateICMRegKeyA(); // pub fn UpdateICMRegKeyW(); // pub fn WidenPath(); // pub fn gdiPlaySpoolStream(); } deps/gdi32-sys-0.1.1/Cargo.toml0000644000000000000000000000066312534714260014627 0ustar rootroot[package] name = "gdi32-sys" version = "0.1.1" authors = ["Peter Atashian "] description = "FFI bindings to gdi32." documentation = "https://retep998.github.io/doc/gdi32-sys/" repository = "https://github.com/retep998/winapi-rs" readme = "README.md" keywords = ["Windows", "FFI", "WinSDK"] license = "MIT" build = "build.rs" links = "gdi32" [lib] name = "gdi32" [dependencies.winapi] version = "*" path = "../.." deps/gdi32-sys-0.1.1/build.rs0000644000000000000000000000022412506114475014336 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License fn main() { println!("cargo:rustc-link-lib=dylib=gdi32"); } deps/gcc-0.3.21/0000755000000000000000000000000012666635520011775 5ustar rootrootdeps/gcc-0.3.21/LICENSE-APACHE0000664000175000017500000002513712425060127012141 0ustar Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/gcc-0.3.21/LICENSE-MIT0000664000175000017500000000204112425060135011635 0ustar Copyright (c) 2014 Alex Crichton Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/gcc-0.3.21/.travis.yml0000664000175000017500000000246612614201502012320 0ustar language: rust rust: - 1.0.0 - beta - nightly sudo: false install: - if [ "$TRAVIS_OS_NAME" = "linux" ]; then OS=unknown-linux-gnu; else OS=apple-darwin; fi - export TARGET=$ARCH-$OS - if [ "$TRAVIS_RUST_VERSION" = "1.0.0" ]; then PKG=rustc; else PKG=rust-std-$TARGET; fi - curl -sO https://static.rust-lang.org/dist/rust-$TRAVIS_RUST_VERSION-$TARGET.tar.gz - tar xf rust-$TRAVIS_RUST_VERSION-$TARGET.tar.gz - rm -rf $HOME/rust/lib/rustlib/$TARGET - mv rust-$TRAVIS_RUST_VERSION-$TARGET/$PKG/lib/rustlib/$TARGET $HOME/rust/lib/rustlib before_script: - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH script: - cargo build --verbose - cargo test --verbose - cargo test --manifest-path gcc-test/Cargo.toml --target $TARGET - cargo test --manifest-path gcc-test/Cargo.toml --target $TARGET --release - cargo doc - rustdoc --test README.md -L target/debug after_success: - travis-cargo --only nightly doc-upload env: global: secure: ilbcq9zX+UaiBcwqkBGldeanbEQus9npLsi0/nF1PUxKbQsoWSVtVOehAD8Hy92D3hX2npIRyNL8GxBn85XEcBYc1h7DiWUhLcXfZie79v8Ly/qboHCfZLXlB1ofbypbyQfouEdOE9zHf0ZILYVpAgUkliv6KuVShsrKNlbn4QE= matrix: - ARCH=x86_64 - ARCH=i686 notifications: email: on_success: never os: - linux - osx addons: apt: packages: - g++-multilib deps/gcc-0.3.21/README.md0000664000175000017500000001027512634601144011473 0ustar # gcc-rs [![Build Status](https://travis-ci.org/alexcrichton/gcc-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/gcc-rs) [![Build status](https://ci.appveyor.com/api/projects/status/onu270iw98h81nwv?svg=true)](https://ci.appveyor.com/project/alexcrichton/gcc-rs) [Documentation](http://alexcrichton.com/gcc-rs/gcc/index.html) A simple library meant to be used as a build dependency with Cargo packages in order to build a set of C files into a static archive. ```rust,no_run extern crate gcc; fn main() { gcc::compile_library("libfoo.a", &["foo.c", "bar.c"]); } ``` # External configuration via environment variables To control the programs and flags used for building, the builder can set a number of different environment variables. * `CFLAGS` - a series of space separated flags passed to "gcc". Note that individual flags cannot currently contain spaces, so doing something like: "-L=foo\ bar" is not possible. * `CC` - the actual C compiler used. Note that this is used as an exact executable name, so (for example) no extra flags can be passed inside this variable, and the builder must ensure that there aren't any trailing spaces. This compiler must understand the `-c` flag. For certain `TARGET`s, it also is assumed to know about other flags (most common is `-fPIC`). * `AR` - the `ar` (archiver) executable to use to build the static library. Each of these variables can also be supplied with certain prefixes and suffixes, in the following prioritized order: 1. `_` - for example, `CC_x86_64-unknown-linux-gnu` 2. `_` - for example, `CC_x86_64_unknown_linux_gnu` 3. `_` - for example, `HOST_CC` or `TARGET_CFLAGS` 4. `` - a plain `CC`, `AR` as above. If none of these variables exist, gcc-rs uses built-in defaults In addition to the the above optional environment variables, `gcc-rs` has some functions with hard requirements on some variables supplied by [cargo's build-script driver][cargo] that it has the `TARGET`, `OUT_DIR`, `OPT_LEVEL`, and `HOST` variables. [cargo]: http://doc.crates.io/build-script.html#inputs-to-the-build-script # Compile-time Requirements To work properly this crate needs access to a C compiler when the build script is being run. This crate does not ship a C compiler with it. The compiler required varies per platform, but there are three broad categories: * Unix platforms require `cc` to be the C compiler. This can be found by installing gcc/clang on Linux distributions and Xcode on OSX, for example. * Windows platforms targeting MSVC (e.g. your target triple ends in `-msvc`) require `cl.exe` to be available and in `PATH`. This is typically found in standard Visual Studio installations and the `PATH` can be set up by running the appropriate developer tools shell. * Windows platforms targeting MinGW (e.g. your target triple ends in `-gnu`) require `gcc` to be available in `PATH`. We recommend the [MinGW-w64](http://mingw-w64.sourceforge.net) distribution ([direct link to the installer][mingw-installer]). You may also acquire it via [MSYS2](http://msys2.github.io), as explained [here][msys2-help]. Make sure to install the appropriate architecture corresponding to your installation of rustc. GCC from older [MinGW](http://www.mingw.org) project is compatible only with 32-bit rust compiler. [mingw-installer]: http://sourceforge.net/projects/mingw-w64/files/latest/download [msys2-help]: http://github.com/rust-lang/rust#building-on-windows # C++ support `gcc-rs` supports C++ libraries compilation by using the `cpp` method on `Config`: ```rust,no_run extern crate gcc; fn main() { gcc::Config::new() .cpp(true) // Switch to C++ library compilation. .file("foo.cpp") .compile("libfoo.a"); } ``` When using C++ library compilation switch, the `CXX` and `CXXFLAGS` env variables are used instead of `CC` and `CFLAGS` and the C++ standard library is linked to the crate target. # License `gcc-rs` is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses. See LICENSE-APACHE, and LICENSE-MIT for details. deps/gcc-0.3.21/.gitignore0000664000175000017500000000002212551312410012162 0ustar target Cargo.lock deps/gcc-0.3.21/src/0000755000000000000000000000000012666635520012564 5ustar rootrootdeps/gcc-0.3.21/src/lib.rs0000664000175000017500000006452512634601145012127 0ustar //! A library for build scripts to compile custom C code //! //! This library is intended to be used as a `build-dependencies` entry in //! `Cargo.toml`: //! //! ```toml //! [build-dependencies] //! gcc = "0.3" //! ``` //! //! The purpose of this crate is to provide the utility functions necessary to //! compile C code into a static archive which is then linked into a Rust crate. //! The top-level `compile_library` function serves as a convenience and more //! advanced configuration is available through the `Config` builder. //! //! This crate will automatically detect situations such as cross compilation or //! other environment variables set by Cargo and will build code appropriately. //! //! # Examples //! //! Use the default configuration: //! //! ```no_run //! extern crate gcc; //! //! fn main() { //! gcc::compile_library("libfoo.a", &["src/foo.c"]); //! } //! ``` //! //! Use more advanced configuration: //! //! ```no_run //! extern crate gcc; //! //! fn main() { //! gcc::Config::new() //! .file("src/foo.c") //! .define("FOO", Some("bar")) //! .include("src") //! .compile("libfoo.a"); //! } //! ``` #![doc(html_root_url = "http://alexcrichton.com/gcc-rs")] #![cfg_attr(test, deny(warnings))] #![deny(missing_docs)] use std::env; use std::ffi::{OsString, OsStr}; use std::fs; use std::io; use std::path::{PathBuf, Path}; use std::process::{Command, Stdio}; #[cfg(windows)] mod registry; pub mod windows_registry; /// Extra configuration to pass to gcc. pub struct Config { include_directories: Vec, definitions: Vec<(String, Option)>, objects: Vec, flags: Vec, files: Vec, cpp: bool, cpp_link_stdlib: Option>, cpp_set_stdlib: Option, target: Option, host: Option, out_dir: Option, opt_level: Option, debug: Option, env: Vec<(OsString, OsString)>, compiler: Option, archiver: Option, cargo_metadata: bool, } /// Configuration used to represent an invocation of a C compiler. /// /// This can be used to figure out what compiler is in use, what the arguments /// to it are, and what the environment variables look like for the compiler. /// This can be used to further configure other build systems (e.g. forward /// along CC and/or CFLAGS) or the `to_command` method can be used to run the /// compiler itself. pub struct Tool { path: PathBuf, args: Vec, env: Vec<(OsString, OsString)>, } /// Compile a library from the given set of input C files. /// /// This will simply compile all files into object files and then assemble them /// into the output. This will read the standard environment variables to detect /// cross compilations and such. /// /// This function will also print all metadata on standard output for Cargo. /// /// # Example /// /// ```no_run /// gcc::compile_library("libfoo.a", &["foo.c", "bar.c"]); /// ``` pub fn compile_library(output: &str, files: &[&str]) { let mut c = Config::new(); for f in files.iter() { c.file(*f); } c.compile(output) } impl Config { /// Construct a new instance of a blank set of configuration. /// /// This builder is finished with the `compile` function. pub fn new() -> Config { Config { include_directories: Vec::new(), definitions: Vec::new(), objects: Vec::new(), flags: Vec::new(), files: Vec::new(), cpp: false, cpp_link_stdlib: None, cpp_set_stdlib: None, target: None, host: None, out_dir: None, opt_level: None, debug: None, env: Vec::new(), compiler: None, archiver: None, cargo_metadata: true } } /// Add a directory to the `-I` or include path for headers pub fn include>(&mut self, dir: P) -> &mut Config { self.include_directories.push(dir.as_ref().to_path_buf()); self } /// Specify a `-D` variable with an optional value. pub fn define(&mut self, var: &str, val: Option<&str>) -> &mut Config { self.definitions.push((var.to_string(), val.map(|s| s.to_string()))); self } /// Add an arbitrary object file to link in pub fn object>(&mut self, obj: P) -> &mut Config { self.objects.push(obj.as_ref().to_path_buf()); self } /// Add an arbitrary flag to the invocation of the compiler pub fn flag(&mut self, flag: &str) -> &mut Config { self.flags.push(flag.to_string()); self } /// Add a file which will be compiled pub fn file>(&mut self, p: P) -> &mut Config { self.files.push(p.as_ref().to_path_buf()); self } /// Set C++ support. /// /// The other `cpp_*` options will only become active if this is set to /// `true`. pub fn cpp(&mut self, cpp: bool) -> &mut Config { self.cpp = cpp; self } /// Set the standard library to link against when compiling with C++ /// support. /// /// The default value of this property depends on the current target: On /// OS X `Some("c++")` is used, when compiling for a Visual Studio based /// target `None` is used and for other targets `Some("stdc++")` is used. /// /// A value of `None` indicates that no automatic linking should happen, /// otherwise cargo will link against the specified library. /// /// The given library name must not contain the `lib` prefix. pub fn cpp_link_stdlib(&mut self, cpp_link_stdlib: Option<&str>) -> &mut Config { self.cpp_link_stdlib = Some(cpp_link_stdlib.map(|s| s.into())); self } /// Force the C++ compiler to use the specified standard library. /// /// Setting this option will automatically set `cpp_link_stdlib` to the same /// value. /// /// The default value of this option is always `None`. /// /// This option has no effect when compiling for a Visual Studio based /// target. /// /// This option sets the `-stdlib` flag, which is only supported by some /// compilers (clang, icc) but not by others (gcc). The library will not /// detect which compiler is used, as such it is the responsibility of the /// caller to ensure that this option is only used in conjuction with a /// compiler which supports the `-stdlib` flag. /// /// A value of `None` indicates that no specific C++ standard library should /// be used, otherwise `-stdlib` is added to the compile invocation. /// /// The given library name must not contain the `lib` prefix. pub fn cpp_set_stdlib(&mut self, cpp_set_stdlib: Option<&str>) -> &mut Config { self.cpp_set_stdlib = cpp_set_stdlib.map(|s| s.into()); self.cpp_link_stdlib(cpp_set_stdlib); self } /// Configures the target this configuration will be compiling for. /// /// This option is automatically scraped from the `TARGET` environment /// variable by build scripts, so it's not required to call this function. pub fn target(&mut self, target: &str) -> &mut Config { self.target = Some(target.to_string()); self } /// Configures the host assumed by this configuration. /// /// This option is automatically scraped from the `HOST` environment /// variable by build scripts, so it's not required to call this function. pub fn host(&mut self, host: &str) -> &mut Config { self.host = Some(host.to_string()); self } /// Configures the optimization level of the generated object files. /// /// This option is automatically scraped from the `OPT_LEVEL` environment /// variable by build scripts, so it's not required to call this function. pub fn opt_level(&mut self, opt_level: u32) -> &mut Config { self.opt_level = Some(opt_level); self } /// Configures whether the compiler will emit debug information when /// generating object files. /// /// This option is automatically scraped from the `PROFILE` environment /// variable by build scripts (only enabled when the profile is "debug"), so /// it's not required to call this function. pub fn debug(&mut self, debug: bool) -> &mut Config { self.debug = Some(debug); self } /// Configures the output directory where all object files and static /// libraries will be located. /// /// This option is automatically scraped from the `OUT_DIR` environment /// variable by build scripts, so it's not required to call this function. pub fn out_dir>(&mut self, out_dir: P) -> &mut Config { self.out_dir = Some(out_dir.as_ref().to_owned()); self } /// Configures the compiler to be used to produce output. /// /// This option is automatically determined from the target platform or a /// number of environment variables, so it's not required to call this /// function. pub fn compiler>(&mut self, compiler: P) -> &mut Config { self.compiler = Some(compiler.as_ref().to_owned()); self } /// Configures the tool used to assemble archives. /// /// This option is automatically determined from the target platform or a /// number of environment variables, so it's not required to call this /// function. pub fn archiver>(&mut self, archiver: P) -> &mut Config { self.archiver = Some(archiver.as_ref().to_owned()); self } /// Define whether metadata should be emitted for cargo allowing it to /// automatically link the binary. Defaults to `true`. pub fn cargo_metadata(&mut self, cargo_metadata: bool) -> &mut Config { self.cargo_metadata = cargo_metadata; self } #[doc(hidden)] pub fn __set_env(&mut self, a: A, b: B) -> &mut Config where A: AsRef, B: AsRef { self.env.push((a.as_ref().to_owned(), b.as_ref().to_owned())); self } /// Run the compiler, generating the file `output` /// /// The name `output` must begin with `lib` and end with `.a` pub fn compile(&self, output: &str) { assert!(output.starts_with("lib")); assert!(output.ends_with(".a")); let lib_name = &output[3..output.len() - 2]; let dst = self.get_out_dir(); let mut objects = Vec::new(); for file in self.files.iter() { let obj = dst.join(file).with_extension("o"); self.compile_object(file, &obj); objects.push(obj); } self.assemble(lib_name, &dst.join(output), &objects); self.print(&format!("cargo:rustc-link-lib=static={}", &output[3..output.len() - 2])); self.print(&format!("cargo:rustc-link-search=native={}", dst.display())); // Add specific C++ libraries, if enabled. if self.cpp { if let Some(stdlib) = self.get_cpp_link_stdlib() { self.print(&format!("cargo:rustc-link-lib={}", stdlib)); } } } fn compile_object(&self, file: &Path, dst: &Path) { let is_asm = file.extension().and_then(|s| s.to_str()) == Some("asm"); let msvc = self.get_target().contains("msvc"); let (mut cmd, name) = if msvc && is_asm { self.msvc_macro_assembler() } else { let compiler = self.get_compiler(); let mut cmd = compiler.to_command(); for &(ref a, ref b) in self.env.iter() { cmd.env(a, b); } (cmd, compiler.path.file_name().unwrap() .to_string_lossy().into_owned()) }; fs::create_dir_all(&dst.parent().unwrap()).unwrap(); if msvc && is_asm { cmd.arg("/Fo").arg(dst); } else if msvc { let mut s = OsString::from("/Fo"); s.push(&dst); cmd.arg(s); } else { cmd.arg("-o").arg(&dst); } cmd.arg(if msvc {"/c"} else {"-c"}); cmd.arg(file); run(&mut cmd, &name); } /// Get the compiler that's in use for this configuration. /// /// This function will return a `Tool` which represents the culmination /// of this configuration at a snapshot in time. The returned compiler can /// be inspected (e.g. the path, arguments, environment) to forward along to /// other tools, or the `to_command` method can be used to invoke the /// compiler itself. /// /// This method will take into account all configuration such as debug /// information, optimization level, include directories, defines, etc. /// Additionally, the compiler binary in use follows the standard /// conventions for this path, e.g. looking at the explicitly set compiler, /// environment variables (a number of which are inspected here), and then /// falling back to the default configuration. pub fn get_compiler(&self) -> Tool { let opt_level = self.get_opt_level(); let debug = self.get_debug(); let target = self.get_target(); let msvc = target.contains("msvc"); self.print(&format!("debug={} opt-level={}", debug, opt_level)); let mut cmd = self.get_base_compiler(); if msvc { cmd.args.push("/nologo".into()); cmd.args.push("/MD".into()); // link against msvcrt.dll for now if opt_level != 0 { cmd.args.push("/O2".into()); } } else { cmd.args.push(format!("-O{}", opt_level).into()); cmd.args.push("-ffunction-sections".into()); cmd.args.push("-fdata-sections".into()); } for arg in self.envflags(if self.cpp {"CXXFLAGS"} else {"CFLAGS"}) { cmd.args.push(arg.into()); } if debug { cmd.args.push(if msvc {"/Z7"} else {"-g"}.into()); } if target.contains("-ios") { self.ios_flags(&mut cmd); } else if !msvc { if target.contains("i686") { cmd.args.push("-m32".into()); } else if target.contains("x86_64") { cmd.args.push("-m64".into()); } if !target.contains("i686") && !target.contains("windows-gnu") { cmd.args.push("-fPIC".into()); } if target.contains("musl") { cmd.args.push("-static".into()); } } if self.cpp && !msvc { if let Some(ref stdlib) = self.cpp_set_stdlib { cmd.args.push(format!("-stdlib=lib{}", stdlib).into()); } } for directory in self.include_directories.iter() { cmd.args.push(if msvc {"/I"} else {"-I"}.into()); cmd.args.push(directory.into()); } for flag in self.flags.iter() { cmd.args.push(flag.into()); } for &(ref key, ref value) in self.definitions.iter() { let lead = if msvc {"/"} else {"-"}; if let &Some(ref value) = value { cmd.args.push(format!("{}D{}={}", lead, key, value).into()); } else { cmd.args.push(format!("{}D{}", lead, key).into()); } } cmd } fn msvc_macro_assembler(&self) -> (Command, String) { let target = self.get_target(); let tool = if target.contains("x86_64") {"ml64.exe"} else {"ml.exe"}; let mut cmd = windows_registry::find(&target, tool).unwrap_or_else(|| { self.cmd(tool) }); for directory in self.include_directories.iter() { cmd.arg("/I").arg(directory); } for &(ref key, ref value) in self.definitions.iter() { if let &Some(ref value) = value { cmd.arg(&format!("/D{}={}", key, value)); } else { cmd.arg(&format!("/D{}", key)); } } (cmd, tool.to_string()) } fn assemble(&self, lib_name: &str, dst: &Path, objects: &[PathBuf]) { let target = self.get_target(); if target.contains("msvc") { let mut cmd = match self.archiver { Some(ref s) => self.cmd(s), None => windows_registry::find(&target, "lib.exe") .unwrap_or(self.cmd("lib.exe")), }; let mut out = OsString::from("/OUT:"); out.push(dst); run(cmd.arg(out).arg("/nologo") .args(objects) .args(&self.objects), "lib.exe"); // The Rust compiler will look for libfoo.a and foo.lib, but the // MSVC linker will also be passed foo.lib, so be sure that both // exist for now. let lib_dst = dst.with_file_name(format!("{}.lib", lib_name)); let _ = fs::remove_file(&lib_dst); fs::hard_link(&dst, &lib_dst).or_else(|_| { //if hard-link fails, just copy (ignoring the number of bytes written) fs::copy(&dst, &lib_dst).map(|_| ()) }).ok().expect("Copying from {:?} to {:?} failed.");; } else { let ar = self.get_ar(); let cmd = ar.file_name().unwrap().to_string_lossy(); run(self.cmd(&ar).arg("crus") .arg(dst) .args(objects) .args(&self.objects), &cmd); } } fn ios_flags(&self, cmd: &mut Tool) { enum ArchSpec { Device(&'static str), Simulator(&'static str), } let target = self.get_target(); let arch = target.split('-').nth(0).unwrap(); let arch = match arch { "arm" | "armv7" | "thumbv7" => ArchSpec::Device("armv7"), "armv7s" | "thumbv7s" => ArchSpec::Device("armv7s"), "arm64" | "aarch64" => ArchSpec::Device("arm64"), "i386" | "i686" => ArchSpec::Simulator("-m32"), "x86_64" => ArchSpec::Simulator("-m64"), _ => fail("Unknown arch for iOS target") }; let sdk = match arch { ArchSpec::Device(arch) => { cmd.args.push("-arch".into()); cmd.args.push(arch.into()); cmd.args.push("-miphoneos-version-min=7.0".into()); "iphoneos" }, ArchSpec::Simulator(arch) => { cmd.args.push(arch.into()); cmd.args.push("-mios-simulator-version-min=7.0".into()); "iphonesimulator" } }; self.print(&format!("Detecting iOS SDK path for {}", sdk)); let sdk_path = self.cmd("xcrun") .arg("--show-sdk-path") .arg("--sdk") .arg(sdk) .stderr(Stdio::inherit()) .output() .unwrap() .stdout; let sdk_path = String::from_utf8(sdk_path).unwrap(); cmd.args.push("-isysroot".into()); cmd.args.push(sdk_path.trim().into()); } fn cmd>(&self, prog: P) -> Command { let mut cmd = Command::new(prog); for &(ref a, ref b) in self.env.iter() { cmd.env(a, b); } return cmd } fn get_base_compiler(&self) -> Tool { if let Some(ref c) = self.compiler { return Tool::new(c.clone()) } let host = self.get_host(); let target = self.get_target(); let (env, msvc, gnu, default) = if self.cpp { ("CXX", "cl.exe", "g++", "c++") } else { ("CC", "cl.exe", "gcc", "cc") }; self.get_var(env).ok().map(|env| { Tool::new(PathBuf::from(env)) }).or_else(|| { windows_registry::find_tool(&target, "cl.exe") }).unwrap_or_else(|| { let compiler = if host.contains("windows") && target.contains("windows") { if target.contains("msvc") { msvc.to_string() } else { format!("{}.exe", gnu) } } else if target.contains("android") { format!("{}-{}", target, gnu) } else if self.get_host() != target { let prefix = match &target[..] { "aarch64-unknown-linux-gnu" => Some("aarch64-linux-gnu"), "arm-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"), "arm-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"), "powerpc-unknown-linux-gnu" => Some("powerpc-linux-gnu"), "mips-unknown-linux-gnu" => Some("mips-linux-gnu"), "i686-pc-windows-gnu" => Some("i686-w64-mingw32"), "x86_64-pc-windows-gnu" => Some("x86_64-w64-mingw32"), "x86_64-unknown-linux-musl" => Some("musl"), "x86_64-rumprun-netbsd" => Some("x86_64-rumprun-netbsd"), _ => None, }; match prefix { Some(prefix) => format!("{}-{}", prefix, gnu), None => default.to_string(), } } else { default.to_string() }; Tool::new(PathBuf::from(compiler)) }) } fn get_var(&self, var_base: &str) -> Result { let target = self.get_target(); let host = self.get_host(); let kind = if host == target {"HOST"} else {"TARGET"}; let target_u = target.replace("-", "_"); let res = self.getenv(&format!("{}_{}", var_base, target)) .or_else(|| self.getenv(&format!("{}_{}", var_base, target_u))) .or_else(|| self.getenv(&format!("{}_{}", kind, var_base))) .or_else(|| self.getenv(var_base)); match res { Some(res) => Ok(res), None => Err("Could not get environment variable".to_string()), } } fn envflags(&self, name: &str) -> Vec { self.get_var(name).unwrap_or(String::new()) .split(|c: char| c.is_whitespace()).filter(|s| !s.is_empty()) .map(|s| s.to_string()) .collect() } /// Returns the default C++ standard library for the current target: `libc++` /// for OS X and `libstdc++` for anything else. fn get_cpp_link_stdlib(&self) -> Option { self.cpp_link_stdlib.clone().unwrap_or_else(|| { let target = self.get_target(); if target.contains("msvc") { None } else if target.contains("darwin") { Some("c++".to_string()) } else { Some("stdc++".to_string()) } }) } fn get_ar(&self) -> PathBuf { self.archiver.clone().or_else(|| { self.get_var("AR").map(PathBuf::from).ok() }).unwrap_or_else(|| { if self.get_target().contains("android") { PathBuf::from(format!("{}-ar", self.get_target())) } else { PathBuf::from("ar") } }) } fn get_target(&self) -> String { self.target.clone().unwrap_or_else(|| self.getenv_unwrap("TARGET")) } fn get_host(&self) -> String { self.host.clone().unwrap_or_else(|| self.getenv_unwrap("HOST")) } fn get_opt_level(&self) -> u32 { self.opt_level.unwrap_or_else(|| { self.getenv_unwrap("OPT_LEVEL").parse().unwrap() }) } fn get_debug(&self) -> bool { self.debug.unwrap_or_else(|| self.getenv_unwrap("PROFILE") == "debug") } fn get_out_dir(&self) -> PathBuf { self.out_dir.clone().unwrap_or_else(|| { env::var_os("OUT_DIR").map(PathBuf::from).unwrap() }) } fn getenv(&self, v: &str) -> Option { let r = env::var(v).ok(); self.print(&format!("{} = {:?}", v, r)); r } fn getenv_unwrap(&self, v: &str) -> String { match self.getenv(v) { Some(s) => s, None => fail(&format!("environment variable `{}` not defined", v)), } } fn print(&self, s: &str) { if self.cargo_metadata { println!("{}", s); } } } impl Tool { fn new(path: PathBuf) -> Tool { Tool { path: path, args: Vec::new(), env: Vec::new(), } } /// Converts this compiler into a `Command` that's ready to be run. /// /// This is useful for when the compiler needs to be executed and the /// command returned will already have the initial arguments and environment /// variables configured. pub fn to_command(&self) -> Command { let mut cmd = Command::new(&self.path); cmd.args(&self.args); for &(ref k, ref v) in self.env.iter() { cmd.env(k, v); } return cmd } /// Returns the path for this compiler. /// /// Note that this may not be a path to a file on the filesystem, e.g. "cc", /// but rather something which will be resolved when a process is spawned. pub fn path(&self) -> &Path { &self.path } /// Returns the default set of arguments to the compiler needed to produce /// executables for the target this compiler generates. pub fn args(&self) -> &[OsString] { &self.args } /// Returns the set of environment variables needed for this compiler to /// operate. /// /// This is typically only used for MSVC compilers currently. pub fn env(&self) -> &[(OsString, OsString)] { &self.env } } fn run(cmd: &mut Command, program: &str) { println!("running: {:?}", cmd); let status = match cmd.status() { Ok(status) => status, Err(ref e) if e.kind() == io::ErrorKind::NotFound => { let extra = if cfg!(windows) { " (see https://github.com/alexcrichton/gcc-rs#compile-time-requirements \ for help)" } else { "" }; fail(&format!("failed to execute command: {}\nIs `{}` \ not installed?{}", e, program, extra)); } Err(e) => fail(&format!("failed to execute command: {}", e)), }; println!("{:?}", status); if !status.success() { fail(&format!("command did not execute successfully, got: {}", status)); } } fn fail(s: &str) -> ! { println!("\n\n{}\n\n", s); panic!() } deps/gcc-0.3.21/src/registry.rs0000664000175000017500000001031512554000120013200 0ustar // Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. extern crate winapi; extern crate advapi32; use std::io; use std::ffi::{OsString, OsStr}; use std::os::windows::prelude::*; use std::ops::RangeFrom; use self::winapi::*; use self::advapi32::*; pub struct RegistryKey(Repr); struct OwnedKey(HKEY); enum Repr { Const(HKEY), Owned(OwnedKey), } pub struct Iter<'a> { idx: RangeFrom, key: &'a RegistryKey, } unsafe impl Sync for Repr {} unsafe impl Send for Repr {} pub static LOCAL_MACHINE: RegistryKey = RegistryKey(Repr::Const(HKEY_LOCAL_MACHINE)); impl RegistryKey { fn raw(&self) -> HKEY { match self.0 { Repr::Const(val) => val, Repr::Owned(ref val) => val.0, } } pub fn open(&self, key: &OsStr) -> io::Result { let key = key.encode_wide().chain(Some(0)).collect::>(); let mut ret = 0 as *mut _; let err = unsafe { RegOpenKeyExW(self.raw(), key.as_ptr(), 0, KEY_READ | KEY_WOW64_32KEY, &mut ret) }; if err == ERROR_SUCCESS as LONG { Ok(RegistryKey(Repr::Owned(OwnedKey(ret)))) } else { Err(io::Error::from_raw_os_error(err as i32)) } } pub fn iter(&self) -> Iter { Iter { idx: 0.., key: self } } pub fn query_str(&self, name: &str) -> io::Result { let name: &OsStr = name.as_ref(); let name = name.encode_wide().chain(Some(0)).collect::>(); let mut len = 0; let mut kind = 0; unsafe { let err = RegQueryValueExW(self.raw(), name.as_ptr(), 0 as *mut _, &mut kind, 0 as *mut _, &mut len); if err != ERROR_SUCCESS as LONG { return Err(io::Error::from_raw_os_error(err as i32)) } if kind != REG_SZ { return Err(io::Error::new(io::ErrorKind::Other, "registry key wasn't a string")) } // The length here is the length in bytes, but we're using wide // characters so we need to be sure to halve it for the capacity // passed in. let mut v = Vec::with_capacity(len as usize / 2); let err = RegQueryValueExW(self.raw(), name.as_ptr(), 0 as *mut _, 0 as *mut _, v.as_mut_ptr() as *mut _, &mut len); if err != ERROR_SUCCESS as LONG { return Err(io::Error::from_raw_os_error(err as i32)) } v.set_len(len as usize / 2); // Some registry keys may have a terminating nul character, but // we're not interested in that, so chop it off if it's there. if v[v.len() - 1] == 0 { v.pop(); } Ok(OsString::from_wide(&v)) } } } impl Drop for OwnedKey { fn drop(&mut self) { unsafe { RegCloseKey(self.0); } } } impl<'a> Iterator for Iter<'a> { type Item = io::Result; fn next(&mut self) -> Option> { self.idx.next().and_then(|i| unsafe { let mut v = Vec::with_capacity(256); let mut len = v.capacity() as DWORD; let ret = RegEnumKeyExW(self.key.raw(), i, v.as_mut_ptr(), &mut len, 0 as *mut _, 0 as *mut _, 0 as *mut _, 0 as *mut _); if ret == ERROR_NO_MORE_ITEMS as LONG { None } else if ret != ERROR_SUCCESS as LONG { Some(Err(io::Error::from_raw_os_error(ret as i32))) } else { v.set_len(len as usize); Some(Ok(OsString::from_wide(&v))) } }) } } deps/gcc-0.3.21/src/windows_registry.rs0000664000175000017500000003256212601705222014772 0ustar // Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! A helper module to probe the Windows Registry when looking for //! windows-specific tools. use std::process::Command; use Tool; /// Attempts to find a tool within an MSVC installation using the Windows /// registry as a point to search from. /// /// The `target` argument is the target that the tool should work for (e.g. /// compile or link for) and the `tool` argument is the tool to find (e.g. /// `cl.exe` or `link.exe`). /// /// This function will return `None` if the tool could not be found, or it will /// return `Some(cmd)` which represents a command that's ready to execute the /// tool with the appropriate environment variables set. /// /// Note that this function always returns `None` for non-MSVC targets. pub fn find(target: &str, tool: &str) -> Option { find_tool(target, tool).map(|c| c.to_command()) } /// Similar to the `find` function above, this function will attempt the same /// operation (finding a MSVC tool in a local install) but instead returns a /// `Tool` which may be introspected. #[cfg(not(windows))] pub fn find_tool(_target: &str, _tool: &str) -> Option { None } /// Documented above. #[cfg(windows)] pub fn find_tool(target: &str, tool: &str) -> Option { use std::env; use std::ffi::OsString; use std::io; use std::fs; use std::path::{Path, PathBuf}; use registry::{RegistryKey, LOCAL_MACHINE}; if !target.contains("msvc") { return None } // When finding binaries the 32-bit version is at the top level but the // versions to cross to other architectures are stored in sub-folders. // Unknown architectures also just bail out early to return the standard // `link.exe` command. let extra = if target.starts_with("i686") { "" } else if target.starts_with("x86_64") { "amd64" } else if target.starts_with("arm") { "arm" } else { return None }; let vs_install_dir = get_vs_install_dir(); let mut path_to_add = None; // First up, we need to find the `link.exe` binary itself, and there's a few // locations that we can look. First up is the standard VCINSTALLDIR // environment variable which is normally set by the vcvarsall.bat file. If // an environment is set up manually by whomever's driving the compiler then // we shouldn't muck with that decision and should instead respect that. // // Finally we read the Windows registry to discover the VS install root. // From here we probe just to make sure that it exists. let mut cmd = env::var_os("VCINSTALLDIR").and_then(|dir| { let mut p = PathBuf::from(dir); p.push("bin"); p.push(extra); let tool = p.join(tool); if fs::metadata(&tool).is_ok() { path_to_add = Some(p); Some(tool) } else { None } }).or_else(|| { env::var_os("PATH").and_then(|path| { env::split_paths(&path).map(|p| p.join(tool)).find(|path| { fs::metadata(path).is_ok() }) }) }).or_else(|| { vs_install_dir.as_ref().and_then(|p| { let mut p = p.join("VC/bin"); p.push(extra); let tool = p.join(tool); if fs::metadata(&tool).is_ok() { path_to_add = Some(p); Some(tool) } else { None } }) }).map(|tool| { Tool::new(tool.into()) }).unwrap_or_else(|| { Tool::new(tool.into()) }); let mut paths = Vec::new(); if let Some(path) = path_to_add { paths.push(path); if let Some(root) = get_windows_sdk_bin_path(target) { paths.push(root); } } if let Some(path) = env::var_os("PATH") { paths.extend(env::split_paths(&path)); } cmd.env.push(("PATH".into(), env::join_paths(&paths).unwrap().into())); // The MSVC compiler uses the INCLUDE environment variable as the default // lookup path for headers. This environment variable is normally set up // by the VS shells, so we only want to start adding our own pieces if it's // not set. // // If we're adding our own pieces, then we need to add two primary // directories to the default search path for the linker. The first is in // the VS install direcotry and the next is the Windows SDK directory. if env::var_os("INCLUDE").is_none() { let mut includes = Vec::new(); if let Some(ref vs_install_dir) = vs_install_dir { includes.push(vs_install_dir.join("VC/include")); if let Some((ucrt_root, vers)) = ucrt_install_dir(vs_install_dir) { let include = ucrt_root.join("Include").join(vers); includes.push(include.join("ucrt")); includes.push(include.join("um")); includes.push(include.join("winrt")); includes.push(include.join("shared")); } } if let Some((path, major)) = get_windows_sdk_path() { if major >= 8 { includes.push(path.join("include/shared")); includes.push(path.join("include/um")); includes.push(path.join("include/winrt")); } else { includes.push(path.join("include")); } } else if let Some(ref vs_install_dir) = vs_install_dir { includes.push(vs_install_dir.clone()); } cmd.env.push(("INCLUDE".into(), env::join_paths(&includes).unwrap().into())); } // Similarly with INCLUDE above, let's set LIB if it's not defined. if env::var_os("LIB").is_none() { let mut libs = Vec::new(); if let Some(ref vs_install_dir) = vs_install_dir { libs.push(vs_install_dir.join("VC/lib").join(extra)); if let Some((ucrt_root, vers)) = ucrt_install_dir(vs_install_dir) { if let Some(arch) = windows_sdk_v8_subdir(target) { let lib = ucrt_root.join("Lib").join(vers); libs.push(lib.join("ucrt").join(arch)); libs.push(lib.join("um").join(arch)); } } } if let Some(path) = get_windows_sdk_lib_path(target) { libs.push(path); } cmd.env.push(("LIB".into(), env::join_paths(&libs).unwrap().into())); } return Some(cmd); // When looking for the Visual Studio installation directory we look in a // number of locations in varying degrees of precedence: // // 1. The Visual Studio registry keys // 2. The Visual Studio Express registry keys // 3. A number of somewhat standard environment variables // // If we find a hit from any of these keys then we strip off the IDE/Tools // folders which are typically found at the end. // // As a final note, when we take a look at the registry keys they're // typically found underneath the version of what's installed, but we don't // quite know what's installed. As a result we probe all sub-keys of the two // keys we're looking at to find out the maximum version of what's installed // and we use that root directory. fn get_vs_install_dir() -> Option { LOCAL_MACHINE.open(r"SOFTWARE\Microsoft\VisualStudio".as_ref()).or_else(|_| { LOCAL_MACHINE.open(r"SOFTWARE\Microsoft\VCExpress".as_ref()) }).ok().and_then(|key| { max_version(&key).and_then(|(_vers, key)| { key.query_str("InstallDir").ok() }) }).or_else(|| { env::var_os("VS120COMNTOOLS") }).or_else(|| { env::var_os("VS100COMNTOOLS") }).or_else(|| { env::var_os("VS90COMNTOOLS") }).or_else(|| { env::var_os("VS80COMNTOOLS") }).map(PathBuf::from).and_then(|mut dir| { if dir.ends_with("Common7/IDE") || dir.ends_with("Common7/Tools") { dir.pop(); dir.pop(); Some(dir) } else { None } }) } // Given a registry key, look at all the sub keys and find the one which has // the maximal numeric value. // // Returns the name of the maximal key as well as the opened maximal key. fn max_version(key: &RegistryKey) -> Option<(OsString, RegistryKey)> { let mut max_vers = 0; let mut max_key = None; for subkey in key.iter().filter_map(|k| k.ok()) { let val = subkey.to_str().and_then(|s| { s.trim_left_matches("v").replace(".", "").parse().ok() }); let val = match val { Some(s) => s, None => continue, }; if val > max_vers { if let Ok(k) = key.open(&subkey) { max_vers = val; max_key = Some((subkey, k)); } } } return max_key } fn get_windows_sdk_path() -> Option<(PathBuf, usize)> { let key = r"SOFTWARE\Microsoft\Microsoft SDKs\Windows"; let key = LOCAL_MACHINE.open(key.as_ref()); let (n, k) = match key.ok().as_ref().and_then(max_version) { Some(p) => p, None => return None, }; let mut parts = n.to_str().unwrap().trim_left_matches("v").splitn(2, "."); let major = parts.next().unwrap().parse::().unwrap(); let _minor = parts.next().unwrap().parse::().unwrap(); k.query_str("InstallationFolder").ok().map(|p| { (PathBuf::from(p), major) }) } fn get_windows_sdk_lib_path(target: &str) -> Option { let (mut root, major) = match get_windows_sdk_path() { Some(pair) => pair, None => return None, }; root.push("Lib"); if major <= 7 { // In Windows SDK 7.x, x86 libraries are directly in the Lib // folder, x64 libraries are inside, and it's not necessary to // link agains the SDK 7.x when targeting ARM or other // architectures. if target.starts_with("i686") { Some(root) } else if target.starts_with("x86_64") { Some(root.join("x64")) } else { None } } else { // Windows SDK 8.x installes libraries in a folder whose names // depend on the version of the OS you're targeting. By default // choose the newest, which usually corresponds to the version of // the OS you've installed the SDK on. let extra = match windows_sdk_v8_subdir(target) { Some(extra) => extra, None => return None, }; ["winv6.3", "win8", "win7"].iter().map(|p| root.join(p)).find(|part| { fs::metadata(part).is_ok() }).map(|path| { path.join("um").join(extra) }) } } fn get_windows_sdk_bin_path(target: &str) -> Option { let (mut root, major) = match get_windows_sdk_path() { Some(pair) => pair, None => return None, }; root.push("bin"); if major <= 7 { None // untested path, not sure if this dir exists } else { root.push(match windows_sdk_v8_subdir(target) { Some(extra) => extra, None => return None, }); if fs::metadata(&root).is_ok() {Some(root)} else {None} } } fn windows_sdk_v8_subdir(target: &str) -> Option<&'static str> { if target.starts_with("i686") { Some("x86") } else if target.starts_with("x86_64") { Some("x64") } else if target.starts_with("arm") { Some("arm") } else { None } } fn ucrt_install_dir(vs_install_dir: &Path) -> Option<(PathBuf, String)> { let is_vs_14 = vs_install_dir.iter().filter_map(|p| p.to_str()).any(|s| { s == "Microsoft Visual Studio 14.0" }); if !is_vs_14 { return None } let key = r"SOFTWARE\Microsoft\Windows Kits\Installed Roots"; let sdk_dir = LOCAL_MACHINE.open(key.as_ref()).and_then(|p| { p.query_str("KitsRoot10") }).map(PathBuf::from); let sdk_dir = match sdk_dir { Ok(p) => p, Err(..) => return None, }; (move || -> io::Result<_> { let mut max = None; let mut max_s = None; for entry in try!(fs::read_dir(&sdk_dir.join("Lib"))) { let entry = try!(entry); if let Ok(s) = entry.file_name().into_string() { if let Ok(u) = s.replace(".", "").parse::() { if Some(u) > max { max = Some(u); max_s = Some(s); } } } } Ok(max_s.map(|m| (sdk_dir, m))) })().ok().and_then(|x| x) } } deps/gcc-0.3.21/src/bin/0000755000000000000000000000000012666635520013334 5ustar rootrootdeps/gcc-0.3.21/src/bin/gcc-shim.rs0000664000175000017500000000113012601705751013604 0ustar #![cfg_attr(test, allow(dead_code))] use std::env; use std::fs::{self, File}; use std::io::prelude::*; use std::path::PathBuf; fn main() { let out_dir = PathBuf::from(env::var_os("GCCTEST_OUT_DIR").unwrap()); for i in 0.. { let candidate = out_dir.join(format!("out{}", i)); if fs::metadata(&candidate).is_ok() { continue } let mut f = File::create(candidate).unwrap(); for arg in env::args().skip(1) { writeln!(f, "{}", arg).unwrap(); } File::create(out_dir.join("libfoo.a")).unwrap(); break } } deps/gcc-0.3.21/tests/0000755000000000000000000000000012666635520013137 5ustar rootrootdeps/gcc-0.3.21/tests/test.rs0000664000175000017500000001421512611736251012704 0ustar extern crate gcc; extern crate tempdir; use std::env; use std::ffi::OsStr; use std::fs::{self, File}; use std::io::prelude::*; use std::path::PathBuf; use tempdir::TempDir; struct Test { td: TempDir, gcc: PathBuf, msvc: bool, } struct Execution { args: Vec, } impl Test { fn new() -> Test { let mut gcc = PathBuf::from(env::current_exe().unwrap()); gcc.pop(); gcc.push(format!("gcc-shim{}", env::consts::EXE_SUFFIX)); Test { td: TempDir::new("gcc-test").unwrap(), gcc: gcc, msvc: false, } } fn gnu() -> Test { let t = Test::new(); t.shim("cc").shim("ar"); return t } fn msvc() -> Test { let mut t = Test::new(); t.shim("cl").shim("lib.exe"); t.msvc = true; return t } fn shim(&self, name: &str) -> &Test { let fname = format!("{}{}", name, env::consts::EXE_SUFFIX); fs::hard_link(&self.gcc, self.td.path().join(&fname)).or_else(|_| { fs::copy(&self.gcc, self.td.path().join(&fname)).map(|_| ()) }).unwrap(); self } fn gcc(&self) -> gcc::Config { let mut cfg = gcc::Config::new(); let mut path = env::split_paths(&env::var_os("PATH").unwrap()) .collect::>(); path.insert(0, self.td.path().to_owned()); let target = if self.msvc { "x86_64-pc-windows-msvc" } else { "x86_64-unknown-linux-gnu" }; cfg.target(target).host(target) .opt_level(2) .debug(false) .out_dir(self.td.path()) .__set_env("PATH", env::join_paths(path).unwrap()) .__set_env("GCCTEST_OUT_DIR", self.td.path()); if self.msvc { cfg.compiler(self.td.path().join("cl")); cfg.archiver(self.td.path().join("lib.exe")); } return cfg } fn cmd(&self, i: u32) -> Execution { let mut s = String::new(); File::open(self.td.path().join(format!("out{}", i))).unwrap() .read_to_string(&mut s).unwrap(); Execution { args: s.lines().map(|s| s.to_string()).collect(), } } } impl Execution { fn must_have>(&self, p: P) -> &Execution { if !self.has(p.as_ref()) { panic!("didn't find {:?} in {:?}", p.as_ref(), self.args); } else { self } } fn must_not_have>(&self, p: P) -> &Execution { if self.has(p.as_ref()) { panic!("found {:?}", p.as_ref()); } else { self } } fn has(&self, p: &OsStr) -> bool { self.args.iter().any(|arg| { OsStr::new(arg) == p }) } } #[test] fn gnu_smoke() { let test = Test::gnu(); test.gcc() .file("foo.c").compile("libfoo.a"); test.cmd(0).must_have("-O2") .must_have("foo.c") .must_not_have("-g") .must_have("-c") .must_have("-ffunction-sections") .must_have("-fdata-sections"); test.cmd(1).must_have(test.td.path().join("foo.o")); } #[test] fn gnu_opt_level_1() { let test = Test::gnu(); test.gcc() .opt_level(1) .file("foo.c").compile("libfoo.a"); test.cmd(0).must_have("-O1") .must_not_have("-O2"); } #[test] fn gnu_debug() { let test = Test::gnu(); test.gcc() .debug(true) .file("foo.c").compile("libfoo.a"); test.cmd(0).must_have("-g"); } #[test] fn gnu_x86_64() { for vendor in &["unknown-linux-gnu", "apple-darwin"] { let target = format!("x86_64-{}", vendor); let test = Test::gnu(); test.gcc() .target(&target) .host(&target) .file("foo.c").compile("libfoo.a"); test.cmd(0).must_have("-fPIC") .must_have("-m64"); } } #[test] fn gnu_i686() { for vendor in &["unknown-linux-gnu", "apple-darwin"] { let target = format!("i686-{}", vendor); let test = Test::gnu(); test.gcc() .target(&target) .host(&target) .file("foo.c").compile("libfoo.a"); test.cmd(0).must_not_have("-fPIC") .must_have("-m32"); } } #[test] fn gnu_set_stdlib() { let test = Test::gnu(); test.gcc() .cpp_set_stdlib(Some("foo")) .file("foo.c").compile("libfoo.a"); test.cmd(0).must_not_have("-stdlib=foo"); } #[test] fn gnu_include() { let test = Test::gnu(); test.gcc() .include("foo/bar") .file("foo.c").compile("libfoo.a"); test.cmd(0).must_have("-I").must_have("foo/bar"); } #[test] fn gnu_define() { let test = Test::gnu(); test.gcc() .define("FOO", Some("bar")) .define("BAR", None) .file("foo.c").compile("libfoo.a"); test.cmd(0).must_have("-DFOO=bar").must_have("-DBAR"); } #[test] fn gnu_compile_assembly() { let test = Test::gnu(); test.gcc() .file("foo.S").compile("libfoo.a"); test.cmd(0).must_have("foo.S"); } #[test] fn msvc_smoke() { let test = Test::msvc(); test.gcc() .file("foo.c").compile("libfoo.a"); test.cmd(0).must_have("/O2") .must_have("foo.c") .must_not_have("/Z7") .must_have("/c"); test.cmd(1).must_have(test.td.path().join("foo.o")); } #[test] fn msvc_opt_level_0() { let test = Test::msvc(); test.gcc() .opt_level(0) .file("foo.c").compile("libfoo.a"); test.cmd(0).must_not_have("/O2"); } #[test] fn msvc_debug() { let test = Test::msvc(); test.gcc() .debug(true) .file("foo.c").compile("libfoo.a"); test.cmd(0).must_have("/Z7"); } #[test] fn msvc_include() { let test = Test::msvc(); test.gcc() .include("foo/bar") .file("foo.c").compile("libfoo.a"); test.cmd(0).must_have("/I").must_have("foo/bar"); } #[test] fn msvc_define() { let test = Test::msvc(); test.gcc() .define("FOO", Some("bar")) .define("BAR", None) .file("foo.c").compile("libfoo.a"); test.cmd(0).must_have("/DFOO=bar").must_have("/DBAR"); } deps/gcc-0.3.21/appveyor.yml0000664000175000017500000000221212614757540012606 0ustar environment: matrix: - TARGET: x86_64-pc-windows-msvc ARCH: amd64 VS: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat - TARGET: x86_64-pc-windows-msvc ARCH: amd64 VS: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat - TARGET: i686-pc-windows-msvc ARCH: x86 VS: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat - TARGET: i686-pc-windows-msvc ARCH: x86 VS: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat - TARGET: x86_64-pc-windows-gnu MSYS_BITS: 64 - TARGET: i686-pc-windows-gnu MSYS_BITS: 32 install: - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - if defined VS call "%VS%" %ARCH% - set PATH=%PATH%;C:\Program Files (x86)\Rust\bin - if defined MSYS_BITS set PATH=%PATH%;C:\msys64\mingw%MSYS_BITS%\bin - rustc -V - cargo -V build: false test_script: - cargo test - cargo test --manifest-path gcc-test/Cargo.toml - cargo test --manifest-path gcc-test/Cargo.toml --release deps/gcc-0.3.21/Cargo.toml0000664000175000017500000000146412634601175012150 0ustar [package] name = "gcc" version = "0.3.21" authors = ["Alex Crichton "] license = "MIT/Apache-2.0" repository = "https://github.com/alexcrichton/gcc-rs" documentation = "http://alexcrichton.com/gcc-rs" description = """ A build-time dependency for Cargo build scripts to assist in invoking the native C compiler to compile native C code into a static archive to be linked into Rust code. """ keywords = ["build-dependencies"] [target.i686-pc-windows-msvc.dependencies] winapi = "0.2.1" advapi32-sys = "0.1.2" [target.x86_64-pc-windows-msvc.dependencies] winapi = "0.2.1" advapi32-sys = "0.1.2" [target.i686-pc-windows-gnu.dependencies] winapi = "0.2.1" advapi32-sys = "0.1.2" [target.x86_64-pc-windows-gnu.dependencies] winapi = "0.2.1" advapi32-sys = "0.1.2" [dev-dependencies] tempdir = "0.3" deps/curl-sys-0.1.29/0000755000000000000000000000000012666635521013031 5ustar rootrootdeps/curl-sys-0.1.29/lib.rs0000664000175000017500000006721312616764272012403 0ustar #![allow(non_camel_case_types, raw_pointer_derive)] extern crate libc; #[cfg(not(target_env = "msvc"))] extern crate libz_sys; #[cfg(all(unix, not(target_os = "macos")))] extern crate openssl_sys; use libc::{c_void, c_int, c_char, c_uint, c_long}; pub type CURLINFO = c_int; pub type CURL = c_void; pub type curl_slist = c_void; pub type CURLoption = c_int; #[repr(C)] #[derive(Clone, Copy)] pub enum CURLversion { CURL_VERSION_FIRST, CURL_VERSION_SECOND, CURL_VERSION_THIRD, CURL_VERSION_FOURTH, CURL_VERSION_LAST /* never actually use this */ } #[repr(C)] #[derive(Copy)] pub struct curl_version_info_data { pub age: CURLversion, pub version: *const c_char, pub version_num: c_uint, pub host: *const c_char, pub features: c_int, pub ssl_version: *const c_char, pub ssl_version_num: c_long, pub libz_version: *const c_char, /* protocols is terminated by an entry with a NULL protoname */ pub protocols: *const *const c_char, /* The fields below this were added in CURL_VERSION_SECOND */ pub ares: *const c_char, pub ares_num: c_int, /* This field was added in CURL_VERSION_THIRD */ pub libidn: *const c_char, /* These field were added in CURL_VERSION_FOURTH */ pub iconv_ver_num: c_int, pub libssh_version: *const c_char, } impl Clone for curl_version_info_data { fn clone(&self) -> Self { *self } } pub const CURL_READFUNC_ABORT: c_int = 0x10000000; pub const CURLINFO_STRING: c_int = 0x100000; pub const CURLINFO_LONG: c_int = 0x200000; pub const CURLINFO_DOUBLE: c_int = 0x300000; pub const CURLINFO_SLIST: c_int = 0x400000; pub const CURLINFO_MASK: c_int = 0x0fffff; pub const CURLINFO_TYPEMASK: c_int = 0xf00000; pub const CURLINFO_EFFECTIVE_URL: CURLINFO = CURLINFO_STRING + 1; pub const CURLINFO_RESPONSE_CODE: CURLINFO = CURLINFO_LONG + 2; pub const CURLINFO_TOTAL_TIME: CURLINFO = CURLINFO_DOUBLE + 5; pub const CURLOPTTYPE_LONG: c_int = 0; pub const CURLOPTTYPE_OBJECTPOINT: c_int = 10_000; pub const CURLOPTTYPE_FUNCTIONPOINT: c_int = 20_000; pub const CURLOPTTYPE_OFF_T: c_int = 30_000; pub const CURL_VERSION_NOW: CURLversion = CURLversion::CURL_VERSION_FOURTH; pub const CURL_VERSION_IPV6: c_int = (1 << 0); pub const CURL_VERSION_KERBEROS4: c_int = (1 << 1); pub const CURL_VERSION_SSL: c_int = (1 << 2); pub const CURL_VERSION_LIBZ: c_int = (1 << 3); pub const CURL_VERSION_NTLM: c_int = (1 << 4); pub const CURL_VERSION_GSSNEGOTIATE: c_int = (1 << 5); pub const CURL_VERSION_DEBUG: c_int = (1 << 6); pub const CURL_VERSION_ASYNCHDNS: c_int = (1 << 7); pub const CURL_VERSION_SPNEGO: c_int = (1 << 8); pub const CURL_VERSION_LARGEFILE: c_int = (1 << 9); pub const CURL_VERSION_IDN: c_int = (1 << 10); pub const CURL_VERSION_SSPI: c_int = (1 << 11); pub const CURL_VERSION_CONV: c_int = (1 << 12); pub const CURL_VERSION_CURLDEBUG: c_int = (1 << 13); pub const CURL_VERSION_TLSAUTH_SRP: c_int = (1 << 14); pub const CURL_VERSION_NTLM_WB: c_int = (1 << 15); pub const CURL_VERSION_HTTP2: c_int = (1 << 16); #[repr(C)] #[derive(Copy, Clone, Debug)] pub enum CURLcode { CURLE_OK = 0, CURLE_UNSUPPORTED_PROTOCOL, /* 1 */ CURLE_FAILED_INIT, /* 2 */ CURLE_URL_MALFORMAT, /* 3 */ CURLE_NOT_BUILT_IN, /* 4 - [was obsoleted in August 2007 for 7.17.0, reused in April 2011 for 7.21.5] */ CURLE_COULDNT_RESOLVE_PROXY, /* 5 */ CURLE_COULDNT_RESOLVE_HOST, /* 6 */ CURLE_COULDNT_CONNECT, /* 7 */ CURLE_FTP_WEIRD_SERVER_REPLY, /* 8 */ CURLE_REMOTE_ACCESS_DENIED, /* 9 a service was denied by the server due to lack of access - when login fails this is not returned. */ CURLE_FTP_ACCEPT_FAILED, /* 10 - [was obsoleted in April 2006 for 7.15.4, reused in Dec 2011 for 7.24.0]*/ CURLE_FTP_WEIRD_PASS_REPLY, /* 11 */ CURLE_FTP_ACCEPT_TIMEOUT, /* 12 - timeout occurred accepting server [was obsoleted in August 2007 for 7.17.0, reused in Dec 2011 for 7.24.0]*/ CURLE_FTP_WEIRD_PASV_REPLY, /* 13 */ CURLE_FTP_WEIRD_227_FORMAT, /* 14 */ CURLE_FTP_CANT_GET_HOST, /* 15 */ CURLE_OBSOLETE16, /* 16 - NOT USED */ CURLE_FTP_COULDNT_SET_TYPE, /* 17 */ CURLE_PARTIAL_FILE, /* 18 */ CURLE_FTP_COULDNT_RETR_FILE, /* 19 */ CURLE_OBSOLETE20, /* 20 - NOT USED */ CURLE_QUOTE_ERROR, /* 21 - quote command failure */ CURLE_HTTP_RETURNED_ERROR, /* 22 */ CURLE_WRITE_ERROR, /* 23 */ CURLE_OBSOLETE24, /* 24 - NOT USED */ CURLE_UPLOAD_FAILED, /* 25 - failed upload "command" */ CURLE_READ_ERROR, /* 26 - couldn't open/read from file */ CURLE_OUT_OF_MEMORY, /* 27 */ /* Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error instead of a memory allocation error if CURL_DOES_CONVERSIONS is defined */ CURLE_OPERATION_TIMEDOUT, /* 28 - the timeout time was reached */ CURLE_OBSOLETE29, /* 29 - NOT USED */ CURLE_FTP_PORT_FAILED, /* 30 - FTP PORT operation failed */ CURLE_FTP_COULDNT_USE_REST, /* 31 - the REST command failed */ CURLE_OBSOLETE32, /* 32 - NOT USED */ CURLE_RANGE_ERROR, /* 33 - RANGE "command" didn't work */ CURLE_HTTP_POST_ERROR, /* 34 */ CURLE_SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */ CURLE_BAD_DOWNLOAD_RESUME, /* 36 - couldn't resume download */ CURLE_FILE_COULDNT_READ_FILE, /* 37 */ CURLE_LDAP_CANNOT_BIND, /* 38 */ CURLE_LDAP_SEARCH_FAILED, /* 39 */ CURLE_OBSOLETE40, /* 40 - NOT USED */ CURLE_FUNCTION_NOT_FOUND, /* 41 */ CURLE_ABORTED_BY_CALLBACK, /* 42 */ CURLE_BAD_FUNCTION_ARGUMENT, /* 43 */ CURLE_OBSOLETE44, /* 44 - NOT USED */ CURLE_INTERFACE_FAILED, /* 45 - CURLOPT_INTERFACE failed */ CURLE_OBSOLETE46, /* 46 - NOT USED */ CURLE_TOO_MANY_REDIRECTS , /* 47 - catch endless re-direct loops */ CURLE_UNKNOWN_OPTION, /* 48 - User specified an unknown option */ CURLE_TELNET_OPTION_SYNTAX , /* 49 - Malformed telnet option */ CURLE_OBSOLETE50, /* 50 - NOT USED */ CURLE_PEER_FAILED_VERIFICATION, /* 51 - peer's certificate or fingerprint wasn't verified fine */ CURLE_GOT_NOTHING, /* 52 - when this is a specific error */ CURLE_SSL_ENGINE_NOTFOUND, /* 53 - SSL crypto engine not found */ CURLE_SSL_ENGINE_SETFAILED, /* 54 - can not set SSL crypto engine as default */ CURLE_SEND_ERROR, /* 55 - failed sending network data */ CURLE_RECV_ERROR, /* 56 - failure in receiving network data */ CURLE_OBSOLETE57, /* 57 - NOT IN USE */ CURLE_SSL_CERTPROBLEM, /* 58 - problem with the local certificate */ CURLE_SSL_CIPHER, /* 59 - couldn't use specified cipher */ CURLE_SSL_CACERT, /* 60 - problem with the CA cert (path?) */ CURLE_BAD_CONTENT_ENCODING, /* 61 - Unrecognized/bad encoding */ CURLE_LDAP_INVALID_URL, /* 62 - Invalid LDAP URL */ CURLE_FILESIZE_EXCEEDED, /* 63 - Maximum file size exceeded */ CURLE_USE_SSL_FAILED, /* 64 - Requested FTP SSL level failed */ CURLE_SEND_FAIL_REWIND, /* 65 - Sending the data requires a rewind that failed */ CURLE_SSL_ENGINE_INITFAILED, /* 66 - failed to initialise ENGINE */ CURLE_LOGIN_DENIED, /* 67 - user, password or similar was not accepted and we failed to login */ CURLE_TFTP_NOTFOUND, /* 68 - file not found on server */ CURLE_TFTP_PERM, /* 69 - permission problem on server */ CURLE_REMOTE_DISK_FULL, /* 70 - out of disk space on server */ CURLE_TFTP_ILLEGAL, /* 71 - Illegal TFTP operation */ CURLE_TFTP_UNKNOWNID, /* 72 - Unknown transfer ID */ CURLE_REMOTE_FILE_EXISTS, /* 73 - File already exists */ CURLE_TFTP_NOSUCHUSER, /* 74 - No such user */ CURLE_CONV_FAILED, /* 75 - conversion failed */ CURLE_CONV_REQD, /* 76 - caller must register conversion callbacks using curl_easy_setopt options CURLOPT_CONV_FROM_NETWORK_FUNCTION, CURLOPT_CONV_TO_NETWORK_FUNCTION, and CURLOPT_CONV_FROM_UTF8_FUNCTION */ CURLE_SSL_CACERT_BADFILE, /* 77 - could not load CACERT file, missing or wrong format */ CURLE_REMOTE_FILE_NOT_FOUND, /* 78 - remote file not found */ CURLE_SSH, /* 79 - error from the SSH layer, somewhat generic so the error message will be of interest when this has happened */ CURLE_SSL_SHUTDOWN_FAILED, /* 80 - Failed to shut down the SSL connection */ CURLE_AGAIN, /* 81 - socket is not ready for send/recv, wait till it's ready and try again (Added in 7.18.2) */ CURLE_SSL_CRL_BADFILE, /* 82 - could not load CRL file, missing or wrong format (Added in 7.19.0) */ CURLE_SSL_ISSUER_ERROR, /* 83 - Issuer check failed. (Added in 7.19.0) */ CURLE_FTP_PRET_FAILED, /* 84 - a PRET command failed */ CURLE_RTSP_CSEQ_ERROR, /* 85 - mismatch of RTSP CSeq numbers */ CURLE_RTSP_SESSION_ERROR, /* 86 - mismatch of RTSP Session Ids */ CURLE_FTP_BAD_FILE_LIST, /* 87 - unable to parse FTP file list */ CURLE_CHUNK_FAILED, /* 88 - chunk callback reported error */ CURLE_NO_CONNECTION_AVAILABLE, /* 89 - No connection available, the session will be queued */ CURLE_LAST /* never use! */ } macro_rules! DEFOPT { ($name:ident, $ty:ident, $num:expr) => ( #[allow(dead_code)] pub const $name: CURLoption = $ty + $num; ) } macro_rules! ALIAS { ($name:ident, $to:ident) => ( #[allow(dead_code)] pub const $name: CURLoption = $to; ) } DEFOPT!(CURLOPT_FILE, CURLOPTTYPE_OBJECTPOINT, 1); DEFOPT!(CURLOPT_URL, CURLOPTTYPE_OBJECTPOINT, 2); DEFOPT!(CURLOPT_PORT, CURLOPTTYPE_LONG, 3); DEFOPT!(CURLOPT_PROXY, CURLOPTTYPE_OBJECTPOINT, 4); DEFOPT!(CURLOPT_USERPWD, CURLOPTTYPE_OBJECTPOINT, 5); DEFOPT!(CURLOPT_PROXYUSERPWD, CURLOPTTYPE_OBJECTPOINT, 6); DEFOPT!(CURLOPT_RANGE, CURLOPTTYPE_OBJECTPOINT, 7); /* 8: not used */ DEFOPT!(CURLOPT_INFILE, CURLOPTTYPE_OBJECTPOINT, 9); DEFOPT!(CURLOPT_ERRORBUFFER, CURLOPTTYPE_OBJECTPOINT, 10); DEFOPT!(CURLOPT_WRITEFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 11); DEFOPT!(CURLOPT_READFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 12); DEFOPT!(CURLOPT_TIMEOUT, CURLOPTTYPE_LONG, 13); DEFOPT!(CURLOPT_INFILESIZE, CURLOPTTYPE_LONG, 14); DEFOPT!(CURLOPT_POSTFIELDS, CURLOPTTYPE_OBJECTPOINT, 15); DEFOPT!(CURLOPT_REFERER, CURLOPTTYPE_OBJECTPOINT, 16); DEFOPT!(CURLOPT_FTPPORT, CURLOPTTYPE_OBJECTPOINT, 17); DEFOPT!(CURLOPT_USERAGENT, CURLOPTTYPE_OBJECTPOINT, 18); DEFOPT!(CURLOPT_LOW_SPEED_LIMIT, CURLOPTTYPE_LONG, 19); DEFOPT!(CURLOPT_LOW_SPEED_TIME, CURLOPTTYPE_LONG, 20); DEFOPT!(CURLOPT_RESUME_FROM, CURLOPTTYPE_LONG, 21); DEFOPT!(CURLOPT_COOKIE, CURLOPTTYPE_OBJECTPOINT, 22); DEFOPT!(CURLOPT_HTTPHEADER, CURLOPTTYPE_OBJECTPOINT, 23); DEFOPT!(CURLOPT_HTTPPOST, CURLOPTTYPE_OBJECTPOINT, 24); DEFOPT!(CURLOPT_SSLCERT, CURLOPTTYPE_OBJECTPOINT, 25); DEFOPT!(CURLOPT_KEYPASSWD, CURLOPTTYPE_OBJECTPOINT, 26); DEFOPT!(CURLOPT_CRLF, CURLOPTTYPE_LONG, 27); DEFOPT!(CURLOPT_QUOTE, CURLOPTTYPE_OBJECTPOINT, 28); DEFOPT!(CURLOPT_WRITEHEADER, CURLOPTTYPE_OBJECTPOINT, 29); /* 30: not used */ DEFOPT!(CURLOPT_COOKIEFILE, CURLOPTTYPE_OBJECTPOINT, 31); DEFOPT!(CURLOPT_SSLVERSION, CURLOPTTYPE_LONG, 32); DEFOPT!(CURLOPT_TIMECONDITION, CURLOPTTYPE_LONG, 33); DEFOPT!(CURLOPT_TIMEVALUE, CURLOPTTYPE_LONG, 34); /* 35: not used */ DEFOPT!(CURLOPT_CUSTOMREQUEST, CURLOPTTYPE_OBJECTPOINT, 36); DEFOPT!(CURLOPT_STDERR, CURLOPTTYPE_OBJECTPOINT, 37); /* 38: not used */ DEFOPT!(CURLOPT_POSTQUOTE, CURLOPTTYPE_OBJECTPOINT, 39); DEFOPT!(CURLOPT_WRITEINFO, CURLOPTTYPE_OBJECTPOINT, 40); DEFOPT!(CURLOPT_VERBOSE, CURLOPTTYPE_LONG, 41); DEFOPT!(CURLOPT_HEADER, CURLOPTTYPE_LONG, 42); DEFOPT!(CURLOPT_NOPROGRESS, CURLOPTTYPE_LONG, 43); DEFOPT!(CURLOPT_NOBODY, CURLOPTTYPE_LONG, 44); DEFOPT!(CURLOPT_FAILONERROR, CURLOPTTYPE_LONG, 45); DEFOPT!(CURLOPT_UPLOAD, CURLOPTTYPE_LONG, 46); DEFOPT!(CURLOPT_POST, CURLOPTTYPE_LONG, 47); DEFOPT!(CURLOPT_DIRLISTONLY, CURLOPTTYPE_LONG, 48); DEFOPT!(CURLOPT_APPEND, CURLOPTTYPE_LONG, 50); DEFOPT!(CURLOPT_NETRC, CURLOPTTYPE_LONG, 51); DEFOPT!(CURLOPT_FOLLOWLOCATION, CURLOPTTYPE_LONG, 52); DEFOPT!(CURLOPT_TRANSFERTEXT, CURLOPTTYPE_LONG, 53); DEFOPT!(CURLOPT_PUT, CURLOPTTYPE_LONG, 54); /* 55: not used */ DEFOPT!(CURLOPT_PROGRESSFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 56); DEFOPT!(CURLOPT_PROGRESSDATA, CURLOPTTYPE_OBJECTPOINT, 57); DEFOPT!(CURLOPT_AUTOREFERER, CURLOPTTYPE_LONG, 58); DEFOPT!(CURLOPT_PROXYPORT, CURLOPTTYPE_LONG, 59); DEFOPT!(CURLOPT_POSTFIELDSIZE, CURLOPTTYPE_LONG, 60); DEFOPT!(CURLOPT_HTTPPROXYTUNNEL, CURLOPTTYPE_LONG, 61); DEFOPT!(CURLOPT_INTERFACE, CURLOPTTYPE_OBJECTPOINT, 62); DEFOPT!(CURLOPT_KRBLEVEL, CURLOPTTYPE_OBJECTPOINT, 63); DEFOPT!(CURLOPT_SSL_VERIFYPEER, CURLOPTTYPE_LONG, 64); DEFOPT!(CURLOPT_CAINFO, CURLOPTTYPE_OBJECTPOINT, 65); /* 66: not used */ /* 67: not used */ DEFOPT!(CURLOPT_MAXREDIRS, CURLOPTTYPE_LONG, 68); DEFOPT!(CURLOPT_FILETIME, CURLOPTTYPE_LONG, 69); DEFOPT!(CURLOPT_TELNETOPTIONS, CURLOPTTYPE_OBJECTPOINT, 70); DEFOPT!(CURLOPT_MAXCONNECTS, CURLOPTTYPE_LONG, 71); DEFOPT!(CURLOPT_CLOSEPOLICY, CURLOPTTYPE_LONG, 72); /* 73: not used */ DEFOPT!(CURLOPT_FRESH_CONNECT, CURLOPTTYPE_LONG, 74); DEFOPT!(CURLOPT_FORBID_REUSE, CURLOPTTYPE_LONG, 75); DEFOPT!(CURLOPT_RANDOM_FILE, CURLOPTTYPE_OBJECTPOINT, 76); DEFOPT!(CURLOPT_EGDSOCKET, CURLOPTTYPE_OBJECTPOINT, 77); DEFOPT!(CURLOPT_CONNECTTIMEOUT, CURLOPTTYPE_LONG, 78); DEFOPT!(CURLOPT_HEADERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 79); DEFOPT!(CURLOPT_HTTPGET, CURLOPTTYPE_LONG, 80); DEFOPT!(CURLOPT_SSL_VERIFYHOST, CURLOPTTYPE_LONG, 81); DEFOPT!(CURLOPT_COOKIEJAR, CURLOPTTYPE_OBJECTPOINT, 82); DEFOPT!(CURLOPT_SSL_CIPHER_LIST, CURLOPTTYPE_OBJECTPOINT, 83); DEFOPT!(CURLOPT_HTTP_VERSION, CURLOPTTYPE_LONG, 84); DEFOPT!(CURLOPT_FTP_USE_EPSV, CURLOPTTYPE_LONG, 85); DEFOPT!(CURLOPT_SSLCERTTYPE, CURLOPTTYPE_OBJECTPOINT, 86); DEFOPT!(CURLOPT_SSLKEY, CURLOPTTYPE_OBJECTPOINT, 87); DEFOPT!(CURLOPT_SSLKEYTYPE, CURLOPTTYPE_OBJECTPOINT, 88); DEFOPT!(CURLOPT_SSLENGINE, CURLOPTTYPE_OBJECTPOINT, 89); DEFOPT!(CURLOPT_SSLENGINE_DEFAULT, CURLOPTTYPE_LONG, 90); DEFOPT!(CURLOPT_DNS_USE_GLOBAL_CACHE, CURLOPTTYPE_LONG, 91); DEFOPT!(CURLOPT_DNS_CACHE_TIMEOUT, CURLOPTTYPE_LONG, 92); DEFOPT!(CURLOPT_PREQUOTE, CURLOPTTYPE_OBJECTPOINT, 93); DEFOPT!(CURLOPT_DEBUGFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 94); DEFOPT!(CURLOPT_DEBUGDATA, CURLOPTTYPE_OBJECTPOINT, 95); DEFOPT!(CURLOPT_COOKIESESSION, CURLOPTTYPE_LONG, 96); DEFOPT!(CURLOPT_CAPATH, CURLOPTTYPE_OBJECTPOINT, 97); DEFOPT!(CURLOPT_BUFFERSIZE, CURLOPTTYPE_LONG, 98); DEFOPT!(CURLOPT_NOSIGNAL, CURLOPTTYPE_LONG, 99); DEFOPT!(CURLOPT_SHARE, CURLOPTTYPE_OBJECTPOINT, 100); DEFOPT!(CURLOPT_PROXYTYPE, CURLOPTTYPE_LONG, 101); DEFOPT!(CURLOPT_ACCEPT_ENCODING, CURLOPTTYPE_OBJECTPOINT, 102); DEFOPT!(CURLOPT_PRIVATE, CURLOPTTYPE_OBJECTPOINT, 103); DEFOPT!(CURLOPT_HTTP200ALIASES, CURLOPTTYPE_OBJECTPOINT, 104); DEFOPT!(CURLOPT_UNRESTRICTED_AUTH, CURLOPTTYPE_LONG, 105); DEFOPT!(CURLOPT_FTP_USE_EPRT, CURLOPTTYPE_LONG, 106); DEFOPT!(CURLOPT_HTTPAUTH, CURLOPTTYPE_LONG, 107); DEFOPT!(CURLOPT_SSL_CTX_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 108); DEFOPT!(CURLOPT_SSL_CTX_DATA, CURLOPTTYPE_OBJECTPOINT, 109); DEFOPT!(CURLOPT_FTP_CREATE_MISSING_DIRS, CURLOPTTYPE_LONG, 110); DEFOPT!(CURLOPT_PROXYAUTH, CURLOPTTYPE_LONG, 111); DEFOPT!(CURLOPT_FTP_RESPONSE_TIMEOUT, CURLOPTTYPE_LONG, 112); DEFOPT!(CURLOPT_IPRESOLVE, CURLOPTTYPE_LONG, 113); DEFOPT!(CURLOPT_MAXFILESIZE, CURLOPTTYPE_LONG, 114); DEFOPT!(CURLOPT_INFILESIZE_LARGE, CURLOPTTYPE_OFF_T, 115); DEFOPT!(CURLOPT_RESUME_FROM_LARGE, CURLOPTTYPE_OFF_T, 116); DEFOPT!(CURLOPT_MAXFILESIZE_LARGE, CURLOPTTYPE_OFF_T, 117); DEFOPT!(CURLOPT_NETRC_FILE, CURLOPTTYPE_OBJECTPOINT, 118); DEFOPT!(CURLOPT_USE_SSL, CURLOPTTYPE_LONG, 119); DEFOPT!(CURLOPT_POSTFIELDSIZE_LARGE, CURLOPTTYPE_OFF_T, 120); DEFOPT!(CURLOPT_TCP_NODELAY, CURLOPTTYPE_LONG, 121); /* 122 - 128: not used */ DEFOPT!(CURLOPT_FTPSSLAUTH, CURLOPTTYPE_LONG, 129); DEFOPT!(CURLOPT_IOCTLFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 130); DEFOPT!(CURLOPT_IOCTLDATA, CURLOPTTYPE_OBJECTPOINT, 131); /* 132, CURLOPTTYPE_133: not used */ DEFOPT!(CURLOPT_FTP_ACCOUNT, CURLOPTTYPE_OBJECTPOINT, 134); DEFOPT!(CURLOPT_COOKIELIST, CURLOPTTYPE_OBJECTPOINT, 135); DEFOPT!(CURLOPT_IGNORE_CONTENT_LENGTH, CURLOPTTYPE_LONG, 136); DEFOPT!(CURLOPT_FTP_SKIP_PASV_IP, CURLOPTTYPE_LONG, 137); DEFOPT!(CURLOPT_FTP_FILEMETHOD, CURLOPTTYPE_LONG, 138); DEFOPT!(CURLOPT_LOCALPORT, CURLOPTTYPE_LONG, 139); DEFOPT!(CURLOPT_LOCALPORTRANGE, CURLOPTTYPE_LONG, 140); DEFOPT!(CURLOPT_CONNECT_ONLY, CURLOPTTYPE_LONG, 141); DEFOPT!(CURLOPT_CONV_FROM_NETWORK_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 142); DEFOPT!(CURLOPT_CONV_TO_NETWORK_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 143); DEFOPT!(CURLOPT_CONV_FROM_UTF8_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 144); DEFOPT!(CURLOPT_MAX_SEND_SPEED_LARGE, CURLOPTTYPE_OFF_T, 145); DEFOPT!(CURLOPT_MAX_RECV_SPEED_LARGE, CURLOPTTYPE_OFF_T, 146); DEFOPT!(CURLOPT_FTP_ALTERNATIVE_TO_USER, CURLOPTTYPE_OBJECTPOINT, 147); DEFOPT!(CURLOPT_SOCKOPTFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 148); DEFOPT!(CURLOPT_SOCKOPTDATA, CURLOPTTYPE_OBJECTPOINT, 149); DEFOPT!(CURLOPT_SSL_SESSIONID_CACHE, CURLOPTTYPE_LONG, 150); DEFOPT!(CURLOPT_SSH_AUTH_TYPES, CURLOPTTYPE_LONG, 151); DEFOPT!(CURLOPT_SSH_PUBLIC_KEYFILE, CURLOPTTYPE_OBJECTPOINT, 152); DEFOPT!(CURLOPT_SSH_PRIVATE_KEYFILE, CURLOPTTYPE_OBJECTPOINT, 153); DEFOPT!(CURLOPT_FTP_SSL_CCC, CURLOPTTYPE_LONG, 154); DEFOPT!(CURLOPT_TIMEOUT_MS, CURLOPTTYPE_LONG, 155); DEFOPT!(CURLOPT_CONNECTTIMEOUT_MS, CURLOPTTYPE_LONG, 156); DEFOPT!(CURLOPT_HTTP_TRANSFER_DECODING, CURLOPTTYPE_LONG, 157); DEFOPT!(CURLOPT_HTTP_CONTENT_DECODING, CURLOPTTYPE_LONG, 158); DEFOPT!(CURLOPT_NEW_FILE_PERMS, CURLOPTTYPE_LONG, 159); DEFOPT!(CURLOPT_NEW_DIRECTORY_PERMS, CURLOPTTYPE_LONG, 160); DEFOPT!(CURLOPT_POSTREDIR, CURLOPTTYPE_LONG, 161); DEFOPT!(CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, CURLOPTTYPE_OBJECTPOINT, 162); DEFOPT!(CURLOPT_OPENSOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 163); DEFOPT!(CURLOPT_OPENSOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 164); DEFOPT!(CURLOPT_COPYPOSTFIELDS, CURLOPTTYPE_OBJECTPOINT, 165); DEFOPT!(CURLOPT_PROXY_TRANSFER_MODE, CURLOPTTYPE_LONG, 166); DEFOPT!(CURLOPT_SEEKFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 167); DEFOPT!(CURLOPT_SEEKDATA, CURLOPTTYPE_OBJECTPOINT, 168); DEFOPT!(CURLOPT_CRLFILE, CURLOPTTYPE_OBJECTPOINT, 169); DEFOPT!(CURLOPT_ISSUERCERT, CURLOPTTYPE_OBJECTPOINT, 170); DEFOPT!(CURLOPT_ADDRESS_SCOPE, CURLOPTTYPE_LONG, 171); DEFOPT!(CURLOPT_CERTINFO, CURLOPTTYPE_LONG, 172); DEFOPT!(CURLOPT_USERNAME, CURLOPTTYPE_OBJECTPOINT, 173); DEFOPT!(CURLOPT_PASSWORD, CURLOPTTYPE_OBJECTPOINT, 174); DEFOPT!(CURLOPT_PROXYUSERNAME, CURLOPTTYPE_OBJECTPOINT, 175); DEFOPT!(CURLOPT_PROXYPASSWORD, CURLOPTTYPE_OBJECTPOINT, 176); DEFOPT!(CURLOPT_NOPROXY, CURLOPTTYPE_OBJECTPOINT, 177); DEFOPT!(CURLOPT_TFTP_BLKSIZE, CURLOPTTYPE_LONG, 178); DEFOPT!(CURLOPT_SOCKS5_GSSAPI_SERVICE, CURLOPTTYPE_OBJECTPOINT, 179); DEFOPT!(CURLOPT_SOCKS5_GSSAPI_NEC, CURLOPTTYPE_LONG, 180); DEFOPT!(CURLOPT_PROTOCOLS, CURLOPTTYPE_LONG, 181); DEFOPT!(CURLOPT_REDIR_PROTOCOLS, CURLOPTTYPE_LONG, 182); DEFOPT!(CURLOPT_SSH_KNOWNHOSTS, CURLOPTTYPE_OBJECTPOINT, 183); DEFOPT!(CURLOPT_SSH_KEYFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 184); DEFOPT!(CURLOPT_SSH_KEYDATA, CURLOPTTYPE_OBJECTPOINT, 185); DEFOPT!(CURLOPT_MAIL_FROM, CURLOPTTYPE_OBJECTPOINT, 186); DEFOPT!(CURLOPT_MAIL_RCPT, CURLOPTTYPE_OBJECTPOINT, 187); DEFOPT!(CURLOPT_FTP_USE_PRET, CURLOPTTYPE_LONG, 188); DEFOPT!(CURLOPT_RTSP_REQUEST, CURLOPTTYPE_LONG, 189); DEFOPT!(CURLOPT_RTSP_SESSION_ID, CURLOPTTYPE_OBJECTPOINT, 190); DEFOPT!(CURLOPT_RTSP_STREAM_URI, CURLOPTTYPE_OBJECTPOINT, 191); DEFOPT!(CURLOPT_RTSP_TRANSPORT, CURLOPTTYPE_OBJECTPOINT, 192); DEFOPT!(CURLOPT_RTSP_CLIENT_CSEQ, CURLOPTTYPE_LONG, 193); DEFOPT!(CURLOPT_RTSP_SERVER_CSEQ, CURLOPTTYPE_LONG, 194); DEFOPT!(CURLOPT_INTERLEAVEDATA, CURLOPTTYPE_OBJECTPOINT, 195); DEFOPT!(CURLOPT_INTERLEAVEFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 196); DEFOPT!(CURLOPT_WILDCARDMATCH, CURLOPTTYPE_LONG, 197); DEFOPT!(CURLOPT_CHUNK_BGN_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 198); DEFOPT!(CURLOPT_CHUNK_END_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 199); DEFOPT!(CURLOPT_FNMATCH_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 200); DEFOPT!(CURLOPT_CHUNK_DATA, CURLOPTTYPE_OBJECTPOINT, 201); DEFOPT!(CURLOPT_FNMATCH_DATA, CURLOPTTYPE_OBJECTPOINT, 202); DEFOPT!(CURLOPT_RESOLVE, CURLOPTTYPE_OBJECTPOINT, 203); DEFOPT!(CURLOPT_TLSAUTH_USERNAME, CURLOPTTYPE_OBJECTPOINT, 204); DEFOPT!(CURLOPT_TLSAUTH_PASSWORD, CURLOPTTYPE_OBJECTPOINT, 205); DEFOPT!(CURLOPT_TLSAUTH_TYPE, CURLOPTTYPE_OBJECTPOINT, 206); DEFOPT!(CURLOPT_TRANSFER_ENCODING, CURLOPTTYPE_LONG, 207); DEFOPT!(CURLOPT_CLOSESOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 208); DEFOPT!(CURLOPT_CLOSESOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 209); DEFOPT!(CURLOPT_GSSAPI_DELEGATION, CURLOPTTYPE_LONG, 210); DEFOPT!(CURLOPT_DNS_SERVERS, CURLOPTTYPE_OBJECTPOINT, 211); DEFOPT!(CURLOPT_ACCEPTTIMEOUT_MS, CURLOPTTYPE_LONG, 212); DEFOPT!(CURLOPT_TCP_KEEPALIVE, CURLOPTTYPE_LONG, 213); DEFOPT!(CURLOPT_TCP_KEEPIDLE, CURLOPTTYPE_LONG, 214); DEFOPT!(CURLOPT_TCP_KEEPINTVL, CURLOPTTYPE_LONG, 215); DEFOPT!(CURLOPT_SSL_OPTIONS, CURLOPTTYPE_LONG, 216); DEFOPT!(CURLOPT_MAIL_AUTH, CURLOPTTYPE_OBJECTPOINT, 217); DEFOPT!(CURLOPT_SASL_IR, CURLOPTTYPE_LONG, 218); DEFOPT!(CURLOPT_XFERINFOFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 219); DEFOPT!(CURLOPT_XOAUTH2_BEARER, CURLOPTTYPE_OBJECTPOINT, 220); DEFOPT!(CURLOPT_DNS_INTERFACE, CURLOPTTYPE_OBJECTPOINT, 221); DEFOPT!(CURLOPT_DNS_LOCAL_IP4, CURLOPTTYPE_OBJECTPOINT, 222); DEFOPT!(CURLOPT_DNS_LOCAL_IP6, CURLOPTTYPE_OBJECTPOINT, 223); DEFOPT!(CURLOPT_LOGIN_OPTIONS, CURLOPTTYPE_OBJECTPOINT, 224); DEFOPT!(CURLOPT_SSL_ENABLE_NPN, CURLOPTTYPE_LONG, 225); DEFOPT!(CURLOPT_SSL_ENABLE_ALPN, CURLOPTTYPE_LONG, 226); DEFOPT!(CURLOPT_EXPECT_100_TIMEOUT_MS, CURLOPTTYPE_LONG, 227); DEFOPT!(CURLOPT_PROXYHEADER, CURLOPTTYPE_OBJECTPOINT, 228); DEFOPT!(CURLOPT_HEADEROPT, CURLOPTTYPE_LONG, 229); // Option aliases ALIAS!(CURLOPT_POST301, CURLOPT_POSTREDIR); ALIAS!(CURLOPT_SSLKEYPASSWD, CURLOPT_KEYPASSWD); ALIAS!(CURLOPT_FTPAPPEND, CURLOPT_APPEND); ALIAS!(CURLOPT_FTPLISTONLY, CURLOPT_DIRLISTONLY); ALIAS!(CURLOPT_FTP_SSL, CURLOPT_USE_SSL); ALIAS!(CURLOPT_SSLCERTPASSWD, CURLOPT_KEYPASSWD); ALIAS!(CURLOPT_KRB4LEVEL, CURLOPT_KRBLEVEL); ALIAS!(CURLOPT_READDATA, CURLOPT_INFILE); ALIAS!(CURLOPT_WRITEDATA, CURLOPT_FILE); ALIAS!(CURLOPT_HEADERDATA, CURLOPT_WRITEHEADER); ALIAS!(CURLOPT_XFERINFODATA, CURLOPT_PROGRESSDATA); extern { pub fn curl_easy_strerror(code: CURLcode) -> *const c_char; pub fn curl_easy_init() -> *mut CURL; pub fn curl_easy_setopt(curl: *mut CURL, option: CURLoption, ...) -> CURLcode; pub fn curl_easy_perform(curl: *mut CURL) -> CURLcode; pub fn curl_easy_cleanup(curl: *mut CURL); pub fn curl_easy_getinfo(curl: *const CURL, info: CURLINFO, ...) -> CURLcode; pub fn curl_global_cleanup(); pub fn curl_slist_append(list: *mut curl_slist, val: *const u8) -> *mut curl_slist; pub fn curl_slist_free_all(list: *mut curl_slist); pub fn curl_version() -> *const c_char; pub fn curl_version_info(t: CURLversion) -> *mut curl_version_info_data; } deps/curl-sys-0.1.29/Cargo.toml0000664000175000017500000000235612624411620013175 0ustar [package] name = "curl-sys" version = "0.1.29" authors = ["Carl Lerche (match $e { Ok(t) => t, Err(e) => panic!("{} return the error {}", stringify!($e), e), }) } #[allow(deprecated)] // needed for `connect()`, since Rust 1.1 is supported fn main() { let target = env::var("TARGET").unwrap(); let src = env::current_dir().unwrap(); let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); let windows = target.contains("windows"); // OSX ships libcurl by default, so we just use that version // unconditionally. if target.contains("apple") { return println!("cargo:rustc-flags=-l curl"); } // Next, fall back and try to use pkg-config if its available. match pkg_config::find_library("libcurl") { Ok(..) => return, Err(e) => println!("Couldn't find libcurl from \ pkgconfig ({:?}), compiling it from source...", e), } println!("cargo:rustc-link-search={}/lib", dst.display()); println!("cargo:rustc-link-lib=static=curl"); println!("cargo:root={}", dst.display()); println!("cargo:include={}/include", dst.display()); if windows { println!("cargo:rustc-flags=-l ws2_32"); } // MSVC builds are just totally different if target.contains("msvc") { return build_msvc(&target); } let cfg = gcc::Config::new(); let compiler = cfg.get_compiler(); let _ = fs::create_dir(&dst.join("build")); let mut cmd = Command::new("sh"); let mut cflags = OsString::new(); for arg in compiler.args() { cflags.push(arg); cflags.push(" "); } cmd.env("CC", compiler.path()) .env("CFLAGS", cflags) .env("LD", &which("ld").unwrap()) .current_dir(&dst.join("build")) .arg(src.join("curl/configure").to_str().unwrap() .replace("C:\\", "/c/") .replace("\\", "/")); if windows { cmd.arg("--with-winssl"); } else { cmd.arg("--without-ca-bundle"); cmd.arg("--without-ca-path"); if let Ok(s) = env::var("DEP_OPENSSL_ROOT") { cmd.arg(format!("--with-ssl={}", s)); } } cmd.arg("--enable-static=yes"); cmd.arg("--enable-shared=no"); cmd.arg("--enable-optimize"); cmd.arg(format!("--prefix={}", dst.display())); cmd.arg("--without-librtmp"); cmd.arg("--without-libidn"); cmd.arg("--without-libssh2"); cmd.arg("--without-nghttp2"); cmd.arg("--disable-ldap"); cmd.arg("--disable-ldaps"); cmd.arg("--disable-ftp"); cmd.arg("--disable-rtsp"); cmd.arg("--disable-dict"); cmd.arg("--disable-telnet"); cmd.arg("--disable-tftp"); cmd.arg("--disable-pop3"); cmd.arg("--disable-imap"); cmd.arg("--disable-smtp"); cmd.arg("--disable-gopher"); cmd.arg("--disable-manual"); // Can't run ./configure directly on msys2 b/c we're handing in // Windows-style paths (those starting with C:\), but it chokes on those. // For that reason we build up a shell script with paths converted to // posix versions hopefully... // // Also apparently the buildbots choke unless we manually set LD, who knows // why?! run(&mut cmd); run(Command::new(make()) .arg(&format!("-j{}", env::var("NUM_JOBS").unwrap())) .current_dir(&dst.join("build"))); // Don't run `make install` because apparently it's a little buggy on mingw // for windows. let _ = fs::create_dir_all(&dst.join("lib/pkgconfig")); // Which one does windows generate? Who knows! let p1 = dst.join("build/lib/.libs/libcurl.a"); let p2 = dst.join("build/lib/.libs/libcurl.lib"); if fs::metadata(&p1).is_ok() { t!(fs::copy(&p1, &dst.join("lib/libcurl.a"))); } else { t!(fs::copy(&p2, &dst.join("lib/libcurl.a"))); } t!(fs::copy(&dst.join("build/libcurl.pc"), &dst.join("lib/pkgconfig/libcurl.pc"))); } fn run(cmd: &mut Command) { println!("running: {:?}", cmd); assert!(t!(cmd.status()).success()); } fn make() -> &'static str { if cfg!(target_os = "freebsd") {"gmake"} else {"make"} } fn which(cmd: &str) -> Option { let cmd = format!("{}{}", cmd, env::consts::EXE_SUFFIX); let paths = env::var_os("PATH").unwrap(); env::split_paths(&paths).map(|p| p.join(&cmd)).find(|p| { fs::metadata(p).is_ok() }) } fn build_msvc(target: &str) { let cmd = gcc::windows_registry::find(target, "nmake.exe"); let mut cmd = cmd.unwrap_or(Command::new("nmake.exe")); let src = env::current_dir().unwrap(); let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); let machine = if target.starts_with("x86_64") { "x64" } else if target.starts_with("i686") { "x86" } else { panic!("unknown msvc target: {}", target); }; t!(fs::create_dir_all(dst.join("include/curl"))); t!(fs::create_dir_all(dst.join("lib"))); cmd.current_dir(src.join("curl/winbuild")); cmd.arg("/f").arg("Makefile.vc") .arg("MODE=static") .arg("ENABLE_IDN=yes") .arg("DEBUG=no") .arg("GEN_PDB=no") .arg("ENABLE_WINSSL=yes") .arg("ENABLE_SSPI=yes") .arg(format!("MACHINE={}", machine)); if let Some(inc) = env::var_os("DEP_Z_ROOT") { let inc = PathBuf::from(inc); let mut s = OsString::from("WITH_DEVEL="); s.push(&inc); cmd.arg("WITH_ZLIB=static").arg(s); // the build system for curl expects this library to be called // zlib_a.lib, so make sure it's named correctly (where libz-sys just // produces zlib.lib) let _ = fs::remove_file(&inc.join("lib/zlib_a.lib")); t!(fs::hard_link(inc.join("lib/zlib.lib"), inc.join("lib/zlib_a.lib"))); } run(&mut cmd); let name = format!("libcurl-vc-{}-release-static-zlib-static-\ ipv6-sspi-winssl", machine); let libs = src.join("curl/builds").join(name); t!(fs::copy(libs.join("lib/libcurl_a.lib"), dst.join("lib/curl.lib"))); for f in t!(fs::read_dir(libs.join("include/curl"))) { let path = t!(f).path(); let dst = dst.join("include/curl").join(path.file_name().unwrap()); t!(fs::copy(path, dst)); } t!(fs::remove_dir_all(src.join("curl/builds"))); println!("cargo:rustc-link-lib=wldap32"); println!("cargo:rustc-link-lib=advapi32"); println!("cargo:rustc-link-lib=normaliz"); } deps/tempdir-0.3.4/0000755000000000000000000000000012666635520012626 5ustar rootrootdeps/tempdir-0.3.4/LICENSE-APACHE0000664000000000000000000002513712476117745014567 0ustar rootroot Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/tempdir-0.3.4/LICENSE-MIT0000664000000000000000000000205712476117745014273 0ustar rootrootCopyright (c) 2014 The Rust Project Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/tempdir-0.3.4/.travis.yml0000664000000000000000000000127712476120217014737 0ustar rootrootlanguage: rust sudo: false script: - cargo build --verbose - cargo test --verbose - cargo doc --no-deps after_success: | [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && echo '' > target/doc/index.html && pip install ghp-import --user $USER && $HOME/.local/bin/ghp-import -n target/doc && git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages env: global: secure: GzgRe6TWVJLBly53nUwyvYnap6vlq3stS5iYnE51n305CxOinA9sKbNev4g/nYegfAvKM12Tmy4hySBVyWaHL43rTMivoBTqHMyVohf5xR9avi/em198GlL0AM005j6w67fiWgmbb0iDC2NcKN358ga8AnIWB6KNd4C4Jm5X+ew= notifications: email: on_success: never deps/tempdir-0.3.4/README.md0000664000000000000000000000070412476120036014076 0ustar rootroottempdir ======= A Rust library for creating a temporary directory and deleting its entire contents when the directory is dropped. [![Build Status](https://travis-ci.org/rust-lang/tempdir.svg?branch=master)](https://travis-ci.org/rust-lang/tempdir) [Documentation](http://doc.rust-lang.org/tempdir) ## Usage Add this to your `Cargo.toml`: ```toml [dependencies] tempdir = "0.3" ``` and this to your crate root: ```rust extern crate tempdir; ``` deps/tempdir-0.3.4/.gitignore0000664000000000000000000000002212476116340014603 0ustar rootroottarget Cargo.lock deps/tempdir-0.3.4/src/0000755000000000000000000000000012666635520013415 5ustar rootrootdeps/tempdir-0.3.4/src/lib.rs0000664000000000000000000001122312507266050014522 0ustar rootroot// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/tempdir/")] #![cfg_attr(test, deny(warnings))] extern crate rand; use std::env; use std::io::{self, Error, ErrorKind}; use std::fs; use std::path::{self, PathBuf, Path}; use rand::{thread_rng, Rng}; /// A wrapper for a path to temporary directory implementing automatic /// scope-based deletion. pub struct TempDir { path: Option, } // How many times should we (re)try finding an unused random name? It should be // enough that an attacker will run out of luck before we run out of patience. const NUM_RETRIES: u32 = 1 << 31; // How many characters should we include in a random file name? It needs to // be enough to dissuade an attacker from trying to preemptively create names // of that length, but not so huge that we unnecessarily drain the random number // generator of entropy. const NUM_RAND_CHARS: usize = 12; impl TempDir { /// Attempts to make a temporary directory inside of `tmpdir` whose name /// will have the prefix `prefix`. The directory will be automatically /// deleted once the returned wrapper is destroyed. /// /// If no directory can be created, `Err` is returned. pub fn new_in>(tmpdir: P, prefix: &str) -> io::Result { let storage; let mut tmpdir = tmpdir.as_ref(); if !tmpdir.is_absolute() { let cur_dir = try!(env::current_dir()); storage = cur_dir.join(tmpdir); tmpdir = &storage; // return TempDir::new_in(&cur_dir.join(tmpdir), prefix); } let mut rng = thread_rng(); for _ in 0..NUM_RETRIES { let suffix: String = rng.gen_ascii_chars().take(NUM_RAND_CHARS).collect(); let leaf = if prefix.len() > 0 { format!("{}.{}", prefix, suffix) } else { // If we're given an empty string for a prefix, then creating a // directory starting with "." would lead to it being // semi-invisible on some systems. suffix }; let path = tmpdir.join(&leaf); match fs::create_dir(&path) { Ok(_) => return Ok(TempDir { path: Some(path) }), Err(ref e) if e.kind() == ErrorKind::AlreadyExists => {} Err(e) => return Err(e) } } Err(Error::new(ErrorKind::AlreadyExists, "too many temporary directories already exist")) } /// Attempts to make a temporary directory inside of `env::temp_dir()` whose /// name will have the prefix `prefix`. The directory will be automatically /// deleted once the returned wrapper is destroyed. /// /// If no directory can be created, `Err` is returned. pub fn new(prefix: &str) -> io::Result { TempDir::new_in(&env::temp_dir(), prefix) } /// Unwrap the wrapped `std::path::Path` from the `TempDir` wrapper. /// This discards the wrapper so that the automatic deletion of the /// temporary directory is prevented. pub fn into_path(mut self) -> PathBuf { self.path.take().unwrap() } /// Access the wrapped `std::path::Path` to the temporary directory. pub fn path(&self) -> &path::Path { self.path.as_ref().unwrap() } /// Close and remove the temporary directory /// /// Although `TempDir` removes the directory on drop, in the destructor /// any errors are ignored. To detect errors cleaning up the temporary /// directory, call `close` instead. pub fn close(mut self) -> io::Result<()> { self.cleanup_dir() } fn cleanup_dir(&mut self) -> io::Result<()> { match self.path { Some(ref p) => fs::remove_dir_all(p), None => Ok(()) } } } impl Drop for TempDir { fn drop(&mut self) { let _ = self.cleanup_dir(); } } // the tests for this module need to change the path using change_dir, // and this doesn't play nicely with other tests so these unit tests are located // in src/test/run-pass/tempfile.rs deps/tempdir-0.3.4/tests/0000755000000000000000000000000012666635520013770 5ustar rootrootdeps/tempdir-0.3.4/tests/smoke.rs0000664000000000000000000001375712501224656015463 0ustar rootroot// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(path_ext)] extern crate tempdir; use std::env; use std::fs; use std::io::prelude::*; use std::path::Path; use std::sync::mpsc::channel; use std::thread; use tempdir::TempDir; macro_rules! t { ($e:expr) => (match $e { Ok(n) => n, Err(e) => panic!("error: {}", e) }) } fn test_tempdir() { let path = { let p = t!(TempDir::new_in(&Path::new("."), "foobar")); let p = p.path(); assert!(p.to_str().unwrap().contains("foobar")); p.to_path_buf() }; assert!(!path.exists()); } fn test_rm_tempdir() { let (tx, rx) = channel(); let f = move|| -> () { let tmp = t!(TempDir::new("test_rm_tempdir")); tx.send(tmp.path().to_path_buf()).unwrap(); panic!("panic to unwind past `tmp`"); }; let _ = thread::spawn(f).join(); let path = rx.recv().unwrap(); assert!(!path.exists()); let tmp = t!(TempDir::new("test_rm_tempdir")); let path = tmp.path().to_path_buf(); let f = move|| -> () { let _tmp = tmp; panic!("panic to unwind past `tmp`"); }; let _ = thread::spawn(f).join(); assert!(!path.exists()); let path; { let f = move || { t!(TempDir::new("test_rm_tempdir")) }; // FIXME(#16640) `: TempDir` annotation shouldn't be necessary let tmp: TempDir = thread::scoped(f).join(); path = tmp.path().to_path_buf(); assert!(path.exists()); } assert!(!path.exists()); let path; { let tmp = t!(TempDir::new("test_rm_tempdir")); path = tmp.into_path(); } assert!(path.exists()); t!(fs::remove_dir_all(&path)); assert!(!path.exists()); } fn test_rm_tempdir_close() { let (tx, rx) = channel(); let f = move|| -> () { let tmp = t!(TempDir::new("test_rm_tempdir")); tx.send(tmp.path().to_path_buf()).unwrap(); t!(tmp.close()); panic!("panic when unwinding past `tmp`"); }; let _ = thread::spawn(f).join(); let path = rx.recv().unwrap(); assert!(!path.exists()); let tmp = t!(TempDir::new("test_rm_tempdir")); let path = tmp.path().to_path_buf(); let f = move|| -> () { let tmp = tmp; t!(tmp.close()); panic!("panic when unwinding past `tmp`"); }; let _ = thread::spawn(f).join(); assert!(!path.exists()); let path; { let f = move || { t!(TempDir::new("test_rm_tempdir")) }; // FIXME(#16640) `: TempDir` annotation shouldn't be necessary let tmp: TempDir = thread::scoped(f).join(); path = tmp.path().to_path_buf(); assert!(path.exists()); t!(tmp.close()); } assert!(!path.exists()); let path; { let tmp = t!(TempDir::new("test_rm_tempdir")); path = tmp.into_path(); } assert!(path.exists()); t!(fs::remove_dir_all(&path)); assert!(!path.exists()); } // Ideally these would be in std::os but then core would need // to depend on std fn recursive_mkdir_rel() { let path = Path::new("frob"); let cwd = env::current_dir().unwrap(); println!("recursive_mkdir_rel: Making: {} in cwd {} [{}]", path.display(), cwd.display(), path.exists()); t!(fs::create_dir(&path)); assert!(path.is_dir()); t!(fs::create_dir_all(&path)); assert!(path.is_dir()); } fn recursive_mkdir_dot() { let dot = Path::new("."); t!(fs::create_dir_all(&dot)); let dotdot = Path::new(".."); t!(fs::create_dir_all(&dotdot)); } fn recursive_mkdir_rel_2() { let path = Path::new("./frob/baz"); let cwd = env::current_dir().unwrap(); println!("recursive_mkdir_rel_2: Making: {} in cwd {} [{}]", path.display(), cwd.display(), path.exists()); t!(fs::create_dir_all(&path)); assert!(path.is_dir()); assert!(path.parent().unwrap().is_dir()); let path2 = Path::new("quux/blat"); println!("recursive_mkdir_rel_2: Making: {} in cwd {}", path2.display(), cwd.display()); t!(fs::create_dir("quux")); t!(fs::create_dir_all(&path2)); assert!(path2.is_dir()); assert!(path2.parent().unwrap().is_dir()); } // Ideally this would be in core, but needs TempFile pub fn test_remove_dir_all_ok() { let tmpdir = t!(TempDir::new("test")); let tmpdir = tmpdir.path(); let root = tmpdir.join("foo"); println!("making {}", root.display()); t!(fs::create_dir(&root)); t!(fs::create_dir(&root.join("foo"))); t!(fs::create_dir(&root.join("foo").join("bar"))); t!(fs::create_dir(&root.join("foo").join("bar").join("blat"))); t!(fs::remove_dir_all(&root)); assert!(!root.exists()); assert!(!root.join("bar").exists()); assert!(!root.join("bar").join("blat").exists()); } pub fn dont_double_panic() { let r: Result<(), _> = thread::spawn(move|| { let tmpdir = TempDir::new("test").unwrap(); // Remove the temporary directory so that TempDir sees // an error on drop t!(fs::remove_dir(tmpdir.path())); // Panic. If TempDir panics *again* due to the rmdir // error then the process will abort. panic!(); }).join(); assert!(r.is_err()); } fn in_tmpdir(f: F) where F: FnOnce() { let tmpdir = t!(TempDir::new("test")); assert!(env::set_current_dir(tmpdir.path()).is_ok()); f(); } #[test] fn main() { in_tmpdir(test_tempdir); in_tmpdir(test_rm_tempdir); in_tmpdir(test_rm_tempdir_close); in_tmpdir(recursive_mkdir_rel); in_tmpdir(recursive_mkdir_dot); in_tmpdir(recursive_mkdir_rel_2); in_tmpdir(test_remove_dir_all_ok); in_tmpdir(dont_double_panic); } deps/tempdir-0.3.4/Cargo.toml0000664000000000000000000000065612507266061014561 0ustar rootroot[package] name = "tempdir" version = "0.3.4" authors = ["The Rust Project Developers"] license = "MIT/Apache-2.0" readme = "README.md" repository = "https://github.com/rust-lang/tempdir" homepage = "https://github.com/rust-lang/tempdir" documentation = "http://doc.rust-lang.org/tempdir" description = """ A library for managing a temporary directory and deleting all contents when it's dropped. """ [dependencies] rand = "0.3" deps/docopt-0.6.78/0000755000000000000000000000000012666635520012550 5ustar rootrootdeps/docopt-0.6.78/UNLICENSE0000644000175000001440000000227312346146654013324 0ustar usersThis is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to deps/docopt-0.6.78/LICENSE-MIT0000644000175000001440000000207112513562722013476 0ustar usersThe MIT License (MIT) Copyright (c) 2015 Andrew Gallant Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/docopt-0.6.78/ctags.rust0000644000175000001440000000160612346146650014067 0ustar users--langdef=Rust --langmap=Rust:.rs --regex-Rust=/^[ \t]*(#\[[^\]]\][ \t]*)*(pub[ \t]+)?(extern[ \t]+)?("[^"]+"[ \t]+)?(unsafe[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\6/f,functions,function definitions/ --regex-Rust=/^[ \t]*(pub[ \t]+)?type[ \t]+([a-zA-Z0-9_]+)/\2/T,types,type definitions/ --regex-Rust=/^[ \t]*(pub[ \t]+)?enum[ \t]+([a-zA-Z0-9_]+)/\2/g,enum,enumeration names/ --regex-Rust=/^[ \t]*(pub[ \t]+)?struct[ \t]+([a-zA-Z0-9_]+)/\2/s,structure names/ --regex-Rust=/^[ \t]*(pub[ \t]+)?mod[ \t]+([a-zA-Z0-9_]+)/\2/m,modules,module names/ --regex-Rust=/^[ \t]*(pub[ \t]+)?static[ \t]+([a-zA-Z0-9_]+)/\2/c,consts,static constants/ --regex-Rust=/^[ \t]*(pub[ \t]+)?trait[ \t]+([a-zA-Z0-9_]+)/\2/t,traits,traits/ --regex-Rust=/^[ \t]*(pub[ \t]+)?impl([ \t\n]+<.*>)?[ \t]+([a-zA-Z0-9_]+)/\3/i,impls,trait implementations/ --regex-Rust=/^[ \t]*macro_rules![ \t]+([a-zA-Z0-9_]+)/\1/d,macros,macro definitions/ deps/docopt-0.6.78/examples/0000755000000000000000000000000012666635520014366 5ustar rootrootdeps/docopt-0.6.78/examples/cp.rs0000644000175000001440000000112012570617740014626 0ustar usersextern crate rustc_serialize; extern crate docopt; use docopt::Docopt; // Write the Docopt usage string. const USAGE: &'static str = " Usage: cp [-a] cp [-a] ... Options: -a, --archive Copy everything. "; #[derive(Debug, RustcDecodable)] struct Args { arg_source: Vec, arg_dest: String, arg_dir: String, flag_archive: bool, } fn main() { let args: Args = Docopt::new(USAGE) .and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); println!("{:?}", args); } deps/docopt-0.6.78/examples/cargo.rs0000644000175000001440000000252312627144034015321 0ustar usersextern crate rustc_serialize; extern crate docopt; use docopt::Docopt; // Write the Docopt usage string. const USAGE: &'static str = " Rust's package manager Usage: cargo [...] cargo [options] Options: -h, --help Display this message -V, --version Print version info and exit --list List installed commands -v, --verbose Use verbose output Some common cargo commands are: build Compile the current project clean Remove the target directory doc Build this project's and its dependencies' documentation new Create a new cargo project run Build and execute src/main.rs test Run the tests bench Run the benchmarks update Update dependencies listed in Cargo.lock See 'cargo help ' for more information on a specific command. "; #[derive(Debug, RustcDecodable)] struct Args { arg_command: Option, arg_args: Vec, flag_list: bool, flag_verbose: bool, } #[derive(Debug, RustcDecodable)] enum Command { Build, Clean, Doc, New, Run, Test, Bench, Update, } fn main() { let args: Args = Docopt::new(USAGE) .and_then(|d| d.options_first(true).decode()) .unwrap_or_else(|e| e.exit()); println!("{:?}", args); } deps/docopt-0.6.78/examples/hashmap.rs0000644000175000001440000000236212613270722015647 0ustar usersextern crate docopt; use docopt::Docopt; const USAGE: &'static str = " Naval Fate. Usage: naval_fate.py ship new ... naval_fate.py ship move [--speed=] naval_fate.py ship shoot naval_fate.py mine (set|remove) [--moored | --drifting] naval_fate.py (-h | --help) naval_fate.py --version Options: -h --help Show this screen. --version Show version. --speed= Speed in knots [default: 10]. --moored Moored (anchored) mine. --drifting Drifting mine. "; fn main() { let version = "1.2.3".to_owned(); let args = Docopt::new(USAGE) .and_then(|dopt| dopt.version(Some(version)).parse()) .unwrap_or_else(|e| e.exit()); println!("{:?}", args); // You can conveniently access values with `get_{bool,count,str,vec}` // functions. If the key doesn't exist (or if, e.g., you use `get_str` on // a switch), then a sensible default value is returned. println!("\nSome values:"); println!(" Speed: {}", args.get_str("--speed")); println!(" Drifting? {}", args.get_bool("--drifting")); println!(" Names: {:?}", args.get_vec("")); println!(" Command 'ship' invoked? {:?}", args.get_bool("ship")); } deps/docopt-0.6.78/examples/decode.rs0000644000175000001440000000230212570617740015452 0ustar usersextern crate rustc_serialize; extern crate docopt; use docopt::Docopt; const USAGE: &'static str = " Naval Fate. Usage: naval_fate.py ship new ... naval_fate.py ship move [--speed=] naval_fate.py ship shoot naval_fate.py mine (set|remove) [--moored | --drifting] naval_fate.py (-h | --help) naval_fate.py --version Options: -h --help Show this screen. --version Show version. --speed= Speed in knots [default: 10]. --moored Moored (anchored) mine. --drifting Drifting mine. "; #[derive(Debug, RustcDecodable)] struct Args { flag_speed: isize, flag_drifting: bool, arg_name: Vec, arg_x: Option, arg_y: Option, cmd_ship: bool, cmd_mine: bool, } fn main() { let args: Args = Docopt::new(USAGE) .and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); println!("{:?}", args); println!("\nSome values:"); println!(" Speed: {}", args.flag_speed); println!(" Drifting? {}", args.flag_drifting); println!(" Names: {:?}", args.arg_name); println!(" Command 'ship' invoked? {:?}", args.cmd_ship); } deps/docopt-0.6.78/examples/optional_command.rs0000644000175000001440000000231712570617740017560 0ustar users// This example shows how to implement a command with a "catch all." // // This requires writing your own impl for `Decodable` because docopt's // decoder uses `Option` to mean "T may not be present" rather than // "T may be present but incorrect." extern crate rustc_serialize; extern crate docopt; use docopt::Docopt; use rustc_serialize::{Decodable, Decoder}; // Write the Docopt usage string. const USAGE: &'static str = " Rust's package manager Usage: mycli [] Options: -h, --help Display this message "; #[derive(Debug, RustcDecodable)] struct Args { arg_command: Command, } impl Decodable for Command { fn decode(d: &mut D) -> Result { let s = try!(d.read_str()); Ok(match &*s { "" => Command::None, "A" => Command::A, "B" => Command::B, "C" => Command::C, s => Command::Unknown(s.to_string()), }) } } #[derive(Debug)] enum Command { A, B, C, Unknown(String), None } fn main() { let args: Args = Docopt::new(USAGE) .and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); println!("{:?}", args); } deps/docopt-0.6.78/examples/verbose_multiple.rs0000644000175000001440000000162612570617740017617 0ustar usersextern crate rustc_serialize; extern crate docopt; use docopt::Docopt; // This shows how to implement multiple levels of verbosity. // // When you have multiple patterns, I think the only way to carry the // repeated flag through all of them is to specify it for each pattern // explicitly. // // This is unfortunate. const USAGE: &'static str = " Usage: cp [options] [-v | -vv | -vvv] cp [options] [-v | -vv | -vvv] ... Options: -a, --archive Copy everything. -v, --verbose Show extra log output. "; #[derive(Debug, RustcDecodable)] struct Args { arg_source: Vec, arg_dest: String, arg_dir: String, flag_archive: bool, flag_verbose: usize, } fn main() { let args: Args = Docopt::new(USAGE) .and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); println!("{:?}", args); } deps/docopt-0.6.78/.travis.yml0000644000175000001440000000042312555533701014153 0ustar userslanguage: rust rust: - 1.0.0 - 1.1.0 - beta - nightly script: - cargo build --verbose - cargo test --verbose - cargo doc - if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then cd docopt_macros; cargo build --verbose; cargo test --verbose; fi deps/docopt-0.6.78/README.md0000644000175000001440000002401312570620010013305 0ustar usersDocopt for Rust with automatic type based decoding (i.e., data validation). This implementation conforms to the [official description of Docopt](http://docopt.org/) and [passes its test suite](https://github.com/docopt/docopt/pull/201). [![Build status](https://api.travis-ci.org/docopt/docopt.rs.svg)](https://travis-ci.org/docopt/docopt.rs) [![](http://meritbadge.herokuapp.com/docopt)](https://crates.io/crates/docopt) Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). ### Current status Fully functional but the design of the API is up for debate. **I am seeking feedback**. ### Documentation [http://burntsushi.net/rustdoc/docopt](http://burntsushi.net/rustdoc/docopt/index.html) ### Installation This crate is fully compatible with Cargo. Just add it to your `Cargo.toml`: ```toml [dependencies] docopt = "0.6" rustc-serialize = "0.3" # if you're using `derive(RustcDecodable)` ``` If you want to use the macro, then add `docopt_macros = "0.6"` instead. Note that the **`docopt!` macro only works on a nightly Rust compiler** because it is a compiler plugin. ### Quick example Here is a full working example. Notice that you can specify the types of each of the named values in the Docopt usage string. Values will be automatically converted to those types (or an error will be reported). ```rust extern crate rustc_serialize; extern crate docopt; use docopt::Docopt; const USAGE: &'static str = " Naval Fate. Usage: naval_fate.py ship new ... naval_fate.py ship move [--speed=] naval_fate.py ship shoot naval_fate.py mine (set|remove) [--moored | --drifting] naval_fate.py (-h | --help) naval_fate.py --version Options: -h --help Show this screen. --version Show version. --speed= Speed in knots [default: 10]. --moored Moored (anchored) mine. --drifting Drifting mine. "; #[derive(Debug, RustcDecodable)] struct Args { flag_speed: isize, flag_drifting: bool, arg_name: Vec, arg_x: Option, arg_y: Option, cmd_ship: bool, cmd_mine: bool, } fn main() { let args: Args = Docopt::new(USAGE) .and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); println!("{:?}", args); } ``` Here is the same example, but with the use of the `docopt!` macro, which will *generate a struct for you*. Note that this uses a compiler plugin, so it only works on a **nightly Rust compiler**: ```rust #![feature(plugin)] #![plugin(docopt_macros)] extern crate rustc_serialize; extern crate docopt; use docopt::Docopt; docopt!(Args derive Debug, " Naval Fate. Usage: naval_fate.py ship new ... naval_fate.py ship move [--speed=] naval_fate.py ship shoot naval_fate.py mine (set|remove) [--moored | --drifting] naval_fate.py (-h | --help) naval_fate.py --version Options: -h --help Show this screen. --version Show version. --speed= Speed in knots [default: 10]. --moored Moored (anchored) mine. --drifting Drifting mine. "); fn main() { let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit()); println!("{:?}", args); } ``` The `Args` struct has one static method defined for it: `docopt`. The method returns a normal `Docopt` value, which can be used to set configuration options, `argv` and parse or decode command line arguments. ### Struct field name mapping The field names of the struct map like this: ``` -g => flag_g --group => flag_group --group => flag_group FILE => arg_FILE => arg_file build => cmd_build ``` ### Data validation example Here's another example that shows how to specify the types of your arguments: ```rust #![feature(plugin)] #![plugin(docopt_macros)] extern crate rustc_serialize; extern crate docopt; docopt!(Args, "Usage: add ", arg_x: i32, arg_y: i32); fn main() { let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit()); println!("x: {}, y: {}", args.arg_x, args.arg_y); } ``` In this example, specific type annotations were added. They will be automatically inserted into the generated struct. You can override as many (or as few) fields as you want. If you don't specify a type, then one of `bool`, `u64`, `String` or `Vec` will be chosen depending on the type of argument. In this case, both `arg_x` and `arg_y` would have been `String`. If any value cannot be decoded into a value with the right type, then an error will be shown to the user. And of course, you don't need the macro to do this. You can do the same thing with a manually written struct too. ### Modeling `rustc` Here's a selected subset for some of `rustc`'s options. This also shows how to restrict values to a list of choices via an `enum` type and demonstrates more Docopt features. ```rust #![feature(plugin)] #![plugin(docopt_macros)] extern crate rustc_serialize; extern crate docopt; docopt!(Args derive Debug, " Usage: rustc [options] [--cfg SPEC... -L PATH...] INPUT rustc (--help | --version) Options: -h, --help Show this message. --version Show the version of rustc. --cfg SPEC Configure the compilation environment. -L PATH Add a directory to the library search path. --emit TYPE Configure the output that rustc will produce. Valid values: asm, ir, bc, obj, link. --opt-level LEVEL Optimize with possible levels 0-3. ", flag_opt_level: Option, flag_emit: Option); #[derive(RustcDecodable, Debug)] enum Emit { Asm, Ir, Bc, Obj, Link } #[derive(Debug)] enum OptLevel { Zero, One, Two, Three } impl rustc_serialize::Decodable for OptLevel { fn decode(d: &mut D) -> Result { Ok(match try!(d.read_usize()) { 0 => OptLevel::Zero, 1 => OptLevel::One, 2 => OptLevel::Two, 3 => OptLevel::Three, n => { let err = format!("Could not decode '{}' as opt-level.", n); return Err(d.error(&*err)); } }) } } fn main() { let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit()); println!("{:?}", args); } ``` ### Viewing the generated struct Generating a struct is pretty magical, but if you want, you can look at it by expanding all macros. Say you wrote the above example for `Usage: add ` into a file called `add.rs`. Then running: ```bash rustc -L path/containing/docopt/lib -Z unstable-options --pretty=expanded add.rs ``` Will show all macros expanded. In the generated code, you should be able to find the generated struct: ```rust struct Args { pub arg_x: int, pub arg_y: int, } ``` ### Traditional Docopt API The reference implementation of Docopt returns a Python dictionary with names like `` or `--flag`. If you prefer this access pattern, then you can use `docopt::ArgvMap`. The disadvantage is that you have to do all of your type conversion manually. Here's the canonical Docopt example with a hash table: ```rust extern crate docopt; use docopt::Docopt; const USAGE: &'static str = " Naval Fate. Usage: naval_fate.py ship new ... naval_fate.py ship move [--speed=] naval_fate.py ship shoot naval_fate.py mine (set|remove) [--moored | --drifting] naval_fate.py (-h | --help) naval_fate.py --version Options: -h --help Show this screen. --version Show version. --speed= Speed in knots [default: 10]. --moored Moored (anchored) mine. --drifting Drifting mine. "; fn main() { let args = Docopt::new(USAGE) .and_then(|dopt| dopt.parse()) .unwrap_or_else(|e| e.exit()); println!("{:?}", args); // You can conveniently access values with `get_{bool,count,str,vec}` // functions. If the key doesn't exist (or if, e.g., you use `get_str` on // a switch), then a sensible default value is returned. println!("\nSome values:"); println!(" Speed: {}", args.get_str("--speed")); println!(" Drifting? {}", args.get_bool("--drifting")); println!(" Names: {:?}", args.get_vec("")); } ``` ### Tab completion support This particular implementation bundles a command called `docopt-wordlist` that can be used to automate tab completion. This repository also collects some basic completion support for various shells (currently only bash) in the `completions` directory. You can use them to setup tab completion on your system. It should work with any program that uses Docopt (or rather, any program that outputs usage messages that look like Docopt). For example, to get tab completion support for Cargo, you'll have to install `docopt-wordlist` and add some voodoo to your `$HOME/.bash_completion` file (this may vary for other shells). Here it is step by step: ```bash # Download and build `docopt-wordlist` (as part of the Docopt package) $ git clone git://github.com/docopt/docopt.rs $ cd docopt.rs $ cargo build --release # Now setup tab completion (for bash) $ echo "DOCOPT_WORDLIST_BIN=\"$(pwd)/target/release/docopt-wordlist\"" >> $HOME/.bash_completion $ echo "source \"$(pwd)/completions/docopt-wordlist.bash\"" >> $HOME/.bash_completion $ echo "complete -F _docopt_wordlist_commands cargo" >> $HOME/.bash_completion ``` My [CSV toolkit](https://github.com/BurntSushi/xsv) is supported too: ```bash # shameless plug... $ echo "complete -F _docopt_wordlist_commands xsv" >> $HOME/.bash_completion ``` Note that this is emphatically a first pass. There are several improvements that I'd like to make: 1. Take context into account when completing. For example, it should be possible to only show completions that can lead to a valid Docopt match. This may be hard. (i.e., It may require restructuring Docopt's internals.) 2. Support more shells. (I'll happily accept pull requests on this one. I doubt I'll venture outside of bash any time soon.) 3. Make tab completion support more seamless. The way it works right now is pretty hacky by intermingling file/directory completion. deps/docopt-0.6.78/.gitignore0000644000175000001440000000005312425561633014032 0ustar users.*.swp doc tags target scratch* Cargo.lock deps/docopt-0.6.78/src/0000755000000000000000000000000012666635520013337 5ustar rootrootdeps/docopt-0.6.78/src/parse.rs0000644000175000001440000014325712570617740014331 0ustar users// I am overall pretty displeased with the quality of code in this module. // I wrote it while simultaneously trying to build a mental model of Docopt's // specification (hint: one does not exist in written form). As a result, there // is a lot of coupling and some duplication. // // Some things that I think are good about the following code: // // - The representation of a "usage pattern." I think it is a minimal // representation of a pattern's syntax. (One possible tweak: // `Optional>` -> `Optional>`.) // - Some disciplined use of regexes. I use a pretty basic state machine // for parsing patterns, but for teasing out the patterns and options // from the Docopt string and for picking out flags with arguments, I // think regexes aren't too bad. There may be one or two scary ones though. // - The core matching algorithm is reasonably simple and concise, but I // think writing down some contracts will help me figure out how to make // the code clearer. // // Some bad things: // // - I tried several times to split some of the pieces in this module into // separate modules. I could find no clear separation. This suggests that // there is too much coupling between parsing components. I'm not convinced // that the coupling is necessary. // - The parsers for patterns and argv share some structure. There may be // an easy abstraction waiting there. // - It is not efficient in the slightest. I tried to be conservative with // copying strings, but I think I failed. (It may not be worthwhile to fix // this if it makes the code more awkward. Docopt does not need to be // efficient.) // // Some things to do immediately: // // - Document representation and invariants. // - Less important: write contracts for functions. // // Long term: // // - Write a specification for Docopt. pub use self::Argument::{Zero, One}; pub use self::Atom::{Short, Long, Command, Positional}; use self::Pattern::{Alternates, Sequence, Optional, Repeat, PatAtom}; use std::borrow::ToOwned; use std::collections::{HashMap, HashSet}; use std::collections::hash_map::Entry::{Vacant, Occupied}; use std::cmp::Ordering; use std::fmt; use regex; use regex::Regex; use strsim::levenshtein; use dopt::Value::{self, Switch, Counted, Plain, List}; use synonym::SynonymMap; macro_rules! err( ($($arg:tt)*) => (return Err(format!($($arg)*))) ); #[derive(Clone)] pub struct Parser { pub program: String, pub full_doc: String, pub usage: String, pub descs: SynonymMap, usages: Vec, last_atom_added: Option, // context for [default: ...] } impl Parser { pub fn new(doc: &str) -> Result { let mut d = Parser { program: "".to_string(), full_doc: doc.to_string(), usage: "".to_string(), usages: vec!(), descs: SynonymMap::new(), last_atom_added: None, }; try!(d.parse(doc)); Ok(d) } pub fn matches(&self, argv: &Argv) -> Option> { for usage in self.usages.iter() { match Matcher::matches(argv, usage) { None => continue, Some(vals) => return Some(vals), } } None } pub fn parse_argv<'a>(&'a self, argv: Vec, options_first: bool) -> Result, String> { Argv::new(self, argv, options_first) } } impl Parser { fn options_atoms(&self) -> Vec { let mut atoms = vec!(); for (atom, _) in self.descs.iter().filter(|&(_, opts)| opts.is_desc) { atoms.push(atom.clone()); } atoms } fn has_arg(&self, atom: &Atom) -> bool { match self.descs.find(atom) { None => false, Some(opts) => opts.arg.has_arg(), } } fn has_repeat(&self, atom: &Atom) -> bool { match self.descs.find(atom) { None => false, Some(opts) => opts.repeats, } } fn parse(&mut self, doc: &str) -> Result<(), String> { let musage = regex!(r"(?s)(?i:usage):\s*(?P\S+)(?P.*?)(?:$|\n\s*\n)"); let caps = match musage.captures(doc) { None => err!("Could not find usage patterns in doc string."), Some(caps) => caps, }; if caps.name("prog").unwrap_or("").is_empty() { err!("Could not find program name in doc string.") } self.program = caps.name("prog").unwrap_or("").to_string(); self.usage = caps.at(0).unwrap_or("").to_string(); // Before we parse the usage patterns, we look for option descriptions. // We do this because the information in option descriptions can be // used to resolve ambiguities in usage patterns (i.e., whether // `--flag ARG` is a flag with an argument or not). // // From the docopt page, "every" line starting with a `-` or a `--` // is considered an option description. Instead, we restrict the lines // to any line *not* in the usage pattern section. // // *sigh* Apparently the above is not true. The official test suite // includes `Options: -a ...`, which means some lines not beginning // with `-` can actually have options. let (pstart, pend) = caps.pos(0).unwrap(); let (before, after) = (&doc[..pstart], &doc[pend..]); // We process every line here (instead of restricting to lines starting // with "-") because we need to check every line for a default value. // The default value always belongs to the most recently defined desc. for line in before.lines().chain(after.lines()) { try!(self.parse_desc(line)); } let mprog = format!( "^(?:{})?\\s*(.*?)\\s*$", regex::quote(caps.name("prog").unwrap_or(""))); let pats = Regex::new(&*mprog).unwrap(); if caps.name("pats").unwrap_or("") == "" { let pattern = try!(PatParser::new(self, "").parse()); self.usages.push(pattern); } else { for line in caps.name("pats").unwrap_or("").lines() { for pat in pats.captures_iter(line.trim()) { let pattern = try!( PatParser::new(self, pat.at(1).unwrap_or("")).parse()); self.usages.push(pattern); } } } Ok(()) } fn parse_desc(&mut self, full_desc: &str) -> Result<(), String> { let desc = regex!(r"^\s*(?i:options:)\s*").replace(full_desc.trim(), ""); let desc = &*desc; if !regex!(r"^(-\S|--\S)").is_match(desc) { try!(self.parse_default(full_desc)); return Ok(()) } // Get rid of the description, which must be at least two spaces // after the flag or argument. let desc = regex!(" .*$").replace(desc, ""); // Normalize `-x, --xyz` to `-x --xyz`. let desc = regex!(r"([^-\s]), -").replace(&desc, "$1 -"); let desc = desc.trim(); let rflags = regex!(r"(?x) (?:(?P--[^\x20\t=]+)|(?P-[^\x20\t=]+)) (?:(?:\x20|=)(?P[^.-]\S*))? (?P\x20\.\.\.)? "); let (mut short, mut long) = ("".to_string(), "".to_string()); let mut has_arg = false; let mut last_end = 0; let mut repeated = false; for flags in rflags.captures_iter(desc) { last_end = flags.pos(0).unwrap().1; if !flags.name("repeated").unwrap_or("").is_empty() { // If the "repeated" subcapture is not empty, then we have // a valid repeated option. repeated = true; } let (s, l) = ( flags.name("short").unwrap_or(""), flags.name("long").unwrap_or(""), ); if !s.is_empty() { if !short.is_empty() { err!("Only one short flag is allowed in an option \ description, but found '{}' and '{}'.", short, s) } short = s.to_string() } if !l.is_empty() { if !long.is_empty() { err!("Only one long flag is allowed in an option \ description, but found '{}' and '{}'.", long, l) } long = l.to_string() } if !flags.name("arg").unwrap_or("").is_empty() { let arg = flags.name("arg").unwrap_or(""); if !Atom::is_arg(arg) { err!("Argument '{}' is not of the form ARG or .", arg) } has_arg = true; // may be changed to default later } } // Make sure that we consumed everything. If there are leftovers, // then there is some malformed description. Alert the user. assert!(last_end <= desc.len()); if last_end < desc.len() { err!("Extraneous text '{}' in option description '{}'.", &desc[last_end..], desc) } try!(self.add_desc(&short, &long, has_arg, repeated)); // Looking for default in this line must come after adding the // description, otherwise `parse_default` won't know which option // to assign it to. self.parse_default(full_desc) } fn parse_default(&mut self, desc: &str) -> Result<(), String> { let rdefault = regex!(r"\[(?i:default):(?P[^]]*)\]"); let defval = match rdefault.captures(desc) { None => return Ok(()), Some(c) => c.name("val").unwrap_or("").trim(), }; let last_atom = match self.last_atom_added { None => err!("Found default value '{}' in '{}' before first \ option description.", defval, desc), Some(ref atom) => atom, }; let opts = self.descs .find_mut(last_atom) .expect(&*format!("BUG: last opt desc key ('{:?}') is invalid.", last_atom)); match opts.arg { One(None) => {}, // OK Zero => err!("Cannot assign default value '{}' to flag '{}' \ that has no arguments.", defval, last_atom), One(Some(ref curval)) => err!("Flag '{}' already has a default value \ of '{}' (second default value: '{}').", last_atom, curval, defval), } opts.arg = One(Some(defval.to_string())); Ok(()) } fn add_desc( &mut self, short: &str, long: &str, has_arg: bool, repeated: bool, ) -> Result<(), String> { assert!(!short.is_empty() || !long.is_empty()); if !short.is_empty() && short.chars().count() != 2 { // It looks like the reference implementation just ignores // these lines. return Ok(()); } let mut opts = Options::new( repeated, if has_arg { One(None) } else { Zero }); opts.is_desc = true; if !short.is_empty() && !long.is_empty() { let (short, long) = (Atom::new(short), Atom::new(long)); self.descs.insert(long.clone(), opts); self.descs.insert_synonym(short, long.clone()); self.last_atom_added = Some(long); } else if !short.is_empty() { let short = Atom::new(short); self.descs.insert(short.clone(), opts); self.last_atom_added = Some(short); } else if !long.is_empty() { let long = Atom::new(long); self.descs.insert(long.clone(), opts); self.last_atom_added = Some(long); } Ok(()) } } impl fmt::Debug for Parser { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { fn sorted(mut xs: Vec) -> Vec { xs.sort(); xs } try!(writeln!(f, "=====")); try!(writeln!(f, "Program: {}", self.program)); try!(writeln!(f, "Option descriptions:")); let keys = sorted(self.descs.keys().collect()); for &k in keys.iter() { try!(writeln!(f, " '{}' => {:?}", k, self.descs.get(k))); } try!(writeln!(f, "Synonyms:")); let keys: Vec<(&Atom, &Atom)> = sorted(self.descs.synonyms().collect()); for &(from, to) in keys.iter() { try!(writeln!(f, " {:?} => {:?}", from, to)); } try!(writeln!(f, "Usages:")); for pat in self.usages.iter() { try!(writeln!(f, " {:?}", pat)); } writeln!(f, "=====") } } struct PatParser<'a> { dopt: &'a mut Parser, tokens: Vec, // used while parsing a single usage pattern curi: usize, // ^^ index into pattern chars expecting: Vec, // stack of expected ']' or ')' } impl<'a> PatParser<'a> { fn new(dopt: &'a mut Parser, pat: &str) -> PatParser<'a> { PatParser { dopt: dopt, tokens: pattern_tokens(pat), curi: 0, expecting: vec!(), } } fn parse(&mut self) -> Result { // let mut seen = HashSet::new(); let mut p = try!(self.pattern()); match self.expecting.pop() { None => {}, Some(c) => err!("Unclosed group. Expected '{}'.", c), } p.add_options_shortcut(self.dopt); p.tag_repeats(&mut self.dopt.descs); Ok(p) } fn pattern(&mut self) -> Result { let mut alts = vec!(); let mut seq = vec!(); while !self.is_eof() { match self.cur() { "..." => { err!("'...' must appear directly after a group, argument, \ flag or command.") } "-" | "--" => { // As per specification, `-` and `--` by themselves are // just commands that should be interpreted conventionally. seq.push(try!(self.command())); } "|" => { if seq.is_empty() { err!("Unexpected '|'. Not in form 'a | b | c'.") } try!(self.next_noeof("pattern")); alts.push(Sequence(seq)); seq = vec!(); } "]" | ")" => { if seq.is_empty() { err!("Unexpected '{}'. Empty groups are not allowed.", self.cur()) } match self.expecting.pop() { None => err!("Unexpected '{}'. No open bracket found.", self.cur()), Some(c) => { if c != self.cur().chars().next().unwrap() { err!("Expected '{}' but got '{}'.", c, self.cur()) } } } let mk: fn(Vec) -> Pattern = if self.cur() == "]" { Optional } else { Sequence }; self.next(); return if alts.is_empty() { Ok(mk(seq)) } else { alts.push(Sequence(seq)); Ok(mk(vec!(Alternates(alts)))) } } "[" => { // Check for special '[options]' shortcut. if self.atis(1, "options") && self.atis(2, "]") { self.next(); // cur == options self.next(); // cur == ] self.next(); seq.push(self.maybe_repeat(Optional(vec!()))); continue } self.expecting.push(']'); seq.push(try!(self.group())); } "(" => { self.expecting.push(')'); seq.push(try!(self.group())); } _ => { if Atom::is_short(self.cur()) { seq.extend(try!(self.flag_short()).into_iter()); } else if Atom::is_long(self.cur()) { seq.push(try!(self.flag_long())); } else if Atom::is_arg(self.cur()) { // These are always positional. // Arguments for -s and --short are picked up // when parsing flags. seq.push(try!(self.positional())); } else if Atom::is_cmd(self.cur()) { seq.push(try!(self.command())); } else { err!("Unknown token type '{}'.", self.cur()) } } } } if alts.is_empty() { Ok(Sequence(seq)) } else { alts.push(Sequence(seq)); Ok(Alternates(alts)) } } fn flag_short(&mut self) -> Result, String> { let mut seq = vec!(); let stacked: String = self.cur()[1..].to_string(); for (i, c) in stacked.chars().enumerate() { let atom = self.dopt.descs.resolve(&Short(c)); let mut pat = PatAtom(atom.clone()); if self.dopt.has_repeat(&atom) { pat = Pattern::repeat(pat); } seq.push(pat); // The only way for a short option to have an argument is if // it's specified in an option description. if !self.dopt.has_arg(&atom) { self.add_atom_ifnotexists(Zero, &atom); } else { // At this point, the flag MUST have an argument. Therefore, // we interpret the "rest" of the characters as the argument. // If the "rest" is empty, then we peek to find and make sure // there is an argument. let rest = &stacked[i+1..]; if rest.is_empty() { try!(self.next_flag_arg(&atom)); } else { try!(self.errif_invalid_flag_arg(&atom, rest)); } // We either error'd or consumed the rest of the short stack as // an argument. break } } self.next(); // This is a little weird. We've got to manually look for a repeat // operator right after the stack, and then apply it to each short // flag we generated. // If "sequences" never altered semantics, then we could just use that // here to group a short stack. if self.atis(0, "...") { self.next(); seq = seq.into_iter().map(|p| Pattern::repeat(p)).collect(); } Ok(seq) } fn flag_long(&mut self) -> Result { let (atom, arg) = try!(parse_long_equal(self.cur())); let atom = self.dopt.descs.resolve(&atom); if self.dopt.descs.contains_key(&atom) { // Options already exist for this atom, so we must check to make // sure things are consistent. let has_arg = self.dopt.has_arg(&atom); if arg.has_arg() && !has_arg { // Found `=` in usage, but previous usage of this flag // didn't specify an argument. err!("Flag '{}' does not take any arguments.", atom) } else if !arg.has_arg() && has_arg { // Didn't find any `=` in usage for this flag, but previous // usage of this flag specifies an argument. // So look for `--flag ARG` try!(self.next_flag_arg(&atom)); // We don't care about the value of `arg` since options // already exist. (In which case, the argument value can never // change.) } } self.add_atom_ifnotexists(arg, &atom); self.next(); let pat = if self.dopt.has_repeat(&atom) { Pattern::repeat(PatAtom(atom)) } else { PatAtom(atom) }; Ok(self.maybe_repeat(pat)) } fn next_flag_arg(&mut self, atom: &Atom) -> Result<(), String> { try!(self.next_noeof(&*format!("argument for flag '{}'", atom))); self.errif_invalid_flag_arg(atom, self.cur()) } fn errif_invalid_flag_arg(&self, atom: &Atom, arg: &str) -> Result<(), String> { if !Atom::is_arg(arg) { err!("Expected argument for flag '{}', but found \ malformed argument '{}'.", atom, arg) } Ok(()) } fn command(&mut self) -> Result { let atom = Atom::new(self.cur()); self.add_atom_ifnotexists(Zero, &atom); self.next(); Ok(self.maybe_repeat(PatAtom(atom))) } fn positional(&mut self) -> Result { let atom = Atom::new(self.cur()); self.add_atom_ifnotexists(Zero, &atom); self.next(); Ok(self.maybe_repeat(PatAtom(atom))) } fn add_atom_ifnotexists(&mut self, arg: Argument, atom: &Atom) { if !self.dopt.descs.contains_key(atom) { let opts = Options::new(false, arg); self.dopt.descs.insert(atom.clone(), opts); } } fn group(&mut self) -> Result { try!(self.next_noeof("pattern")); let pat = try!(self.pattern()); Ok(self.maybe_repeat(pat)) } fn maybe_repeat(&mut self, pat: Pattern) -> Pattern { if self.atis(0, "...") { self.next(); Pattern::repeat(pat) } else { pat } } fn is_eof(&self) -> bool { self.curi == self.tokens.len() } fn next(&mut self) { if self.curi == self.tokens.len() { return } self.curi += 1; } fn next_noeof(&mut self, expected: &str) -> Result<(), String> { self.next(); if self.curi == self.tokens.len() { err!("Expected {} but reached end of usage pattern.", expected) } Ok(()) } fn cur<'r>(&'r self) -> &'r str { &*self.tokens[self.curi] } fn atis(&self, offset: usize, is: &str) -> bool { let i = self.curi + offset; i < self.tokens.len() && self.tokens[i] == is } } #[derive(Clone, Debug)] enum Pattern { Alternates(Vec), Sequence(Vec), Optional(Vec), Repeat(Box), PatAtom(Atom), } #[derive(PartialEq, Eq, Ord, Hash, Clone, Debug)] pub enum Atom { Short(char), Long(String), Command(String), Positional(String), } #[derive(Clone, Debug)] pub struct Options { /// Set to true if this atom is ever repeated in any context. /// For positional arguments, non-argument flags and commands, repetition /// means that they become countable. /// For flags with arguments, repetition means multiple distinct values /// can be specified (and are represented as a Vec). pub repeats: bool, /// This specifies whether this atom has any arguments. /// For commands and positional arguments, this is always Zero. /// Flags can have zero or one argument, with an optionally default value. pub arg: Argument, /// Whether it shows up in the "options description" second. pub is_desc: bool, } #[derive(Clone, Debug, PartialEq)] pub enum Argument { Zero, One(Option), // optional default value } impl Pattern { fn add_options_shortcut(&mut self, par: &Parser) { fn add(pat: &mut Pattern, all_atoms: &HashSet, par: &Parser) { match *pat { Alternates(ref mut ps) | Sequence(ref mut ps) => { for p in ps.iter_mut() { add(p, all_atoms, par) } } Repeat(ref mut p) => add(&mut **p, all_atoms, par), PatAtom(_) => {} Optional(ref mut ps) => { if !ps.is_empty() { for p in ps.iter_mut() { add(p, all_atoms, par) } } else { for atom in par.options_atoms().into_iter() { if !all_atoms.contains(&atom) { if par.has_repeat(&atom) { ps.push(Pattern::repeat(PatAtom(atom))); } else { ps.push(PatAtom(atom)); } } } } } } } let all_atoms = self.all_atoms(); add(self, &all_atoms, par); } fn all_atoms(&self) -> HashSet { fn all_atoms(pat: &Pattern, set: &mut HashSet) { match *pat { Alternates(ref ps) | Sequence(ref ps) | Optional(ref ps) => { for p in ps.iter() { all_atoms(p, set) } } Repeat(ref p) => all_atoms(&**p, set), PatAtom(ref a) => { set.insert(a.clone()); } } } let mut set = HashSet::new(); all_atoms(self, &mut set); set } fn tag_repeats(&self, map: &mut SynonymMap) { fn dotag(p: &Pattern, rep: bool, map: &mut SynonymMap, seen: &mut HashSet) { match *p { Alternates(ref ps) => { // This is a bit tricky. Basically, we don't want the // existence of an item in mutually exclusive alternations // to affect whether it repeats or not. // However, we still need to record seeing each item in // each alternation. let fresh = seen.clone(); for p in ps.iter() { let mut isolated = fresh.clone(); dotag(p, rep, map, &mut isolated); for a in isolated.into_iter() { seen.insert(a); } } } Sequence(ref ps) => { for p in ps.iter() { dotag(p, rep, map, seen) } } Optional(ref ps) => { for p in ps.iter() { dotag(p, rep, map, seen) } } Repeat(ref p) => dotag(&**p, true, map, seen), PatAtom(ref atom) => { let opt = map.find_mut(atom).expect("bug: no atom found"); opt.repeats = opt.repeats || rep || seen.contains(atom); seen.insert(atom.clone()); } } } let mut seen = HashSet::new(); dotag(self, false, map, &mut seen); } fn repeat(p: Pattern) -> Pattern { match p { p @ Repeat(_) => p, p => Repeat(Box::new(p)), } } } impl Atom { pub fn new(s: &str) -> Atom { if Atom::is_short(s) { Short(s[1..].chars().next().unwrap()) } else if Atom::is_long(s) { Long(s[2..].to_string()) } else if Atom::is_arg(s) { if s.starts_with("<") && s.ends_with(">") { Positional(s[1..s.len()-1].to_string()) } else { Positional(s.to_string()) } } else if Atom::is_cmd(s) { Command(s.to_string()) } else { panic!("Unknown atom string: '{}'", s) } } fn is_short(s: &str) -> bool { regex!(r"^-[^-]+$").is_match(s) } fn is_long(s: &str) -> bool { regex!(r"^--\S+(?:<[^>]+>)?$").is_match(s) } fn is_long_argv(s: &str) -> bool { regex!(r"^--\S+(=.+)?$").is_match(s) } fn is_arg(s: &str) -> bool { regex!(r"^(\p{Lu}+|<[^>]+>)$").is_match(s) } fn is_cmd(s: &str) -> bool { regex!(r"^(-|--|[^-]\S*)$").is_match(s) } // Assigns an integer to each variant of Atom. (For easier sorting.) fn type_as_usize(&self) -> usize { match *self { Short(_) => 0, Long(_) => 1, Command(_) => 2, Positional(_) => 3, } } } impl PartialOrd for Atom { fn partial_cmp(&self, other: &Atom) -> Option { match (self, other) { (&Short(c1), &Short(c2)) => c1.partial_cmp(&c2), (&Long(ref s1), &Long(ref s2)) => s1.partial_cmp(s2), (&Command(ref s1), &Command(ref s2)) => s1.partial_cmp(s2), (&Positional(ref s1), &Positional(ref s2)) => s1.partial_cmp(s2), (a1, a2) => a1.type_as_usize().partial_cmp(&a2.type_as_usize()), } } } impl fmt::Display for Atom { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Short(c) => write!(f, "-{}", c), Long(ref s) => write!(f, "--{}", s), Command(ref s) => write!(f, "{}", s), Positional(ref s) => { if s.chars().all(|c| c.is_uppercase()) { write!(f, "{}", s) } else { write!(f, "<{}>", s) } } } } } impl Options { fn new(rep: bool, arg: Argument) -> Options { Options { repeats: rep, arg: arg, is_desc: false, } } } impl Argument { fn has_arg(&self) -> bool { match *self { Zero => false, One(_) => true, } } } #[doc(hidden)] pub struct Argv<'a> { /// A representation of an argv string as an ordered list of tokens. /// This contains only positional arguments and commands. positional: Vec, /// Same as positional, but contains short and long flags. /// Each flag may have an argument string. flags: Vec, /// Counts the number of times each flag appears. counts: HashMap, // State for parser. dopt: &'a Parser, argv: Vec, curi: usize, options_first: bool, } #[derive(Clone, Debug)] struct ArgvToken { atom: Atom, arg: Option, } impl<'a> Argv<'a> { fn new(dopt: &'a Parser, argv: Vec, options_first: bool) -> Result, String> { let mut a = Argv { positional: vec!(), flags: vec!(), counts: HashMap::new(), dopt: dopt, argv: argv.iter().map(|s| s.to_string()).collect(), curi: 0, options_first: options_first, }; try!(a.parse()); for flag in a.flags.iter() { match a.counts.entry(flag.atom.clone()) { Vacant(v) => { v.insert(1); } Occupied(mut v) => { *v.get_mut() += 1; } } } Ok(a) } fn parse(&mut self) -> Result<(), String> { let mut seen_double_dash = false; while self.curi < self.argv.len() { let do_flags = !seen_double_dash && (!self.options_first || self.positional.is_empty()); if do_flags && Atom::is_short(self.cur()) { let stacked: String = self.cur()[1..].to_string(); for (i, c) in stacked.chars().enumerate() { let mut tok = ArgvToken { atom: self.dopt.descs.resolve(&Short(c)), arg: None, }; if !self.dopt.descs.contains_key(&tok.atom) { err!("Unknown flag: '{}'", &tok.atom); } if !self.dopt.has_arg(&tok.atom) { self.flags.push(tok); } else { let rest = &stacked[i+1..]; tok.arg = Some( if rest.is_empty() { let arg = try!(self.next_arg(&tok.atom)); arg.to_string() } else { rest.to_string() } ); self.flags.push(tok); // We've either produced an error or gobbled up the // rest of these stacked short flags, so stop. break } } } else if do_flags && Atom::is_long_argv(self.cur()) { let (atom, mut arg) = parse_long_equal_argv(self.cur()); let atom = self.dopt.descs.resolve(&atom); if !self.dopt.descs.contains_key(&atom) { return self.err_unknown_flag(&atom) } if arg.is_some() && !self.dopt.has_arg(&atom) { err!("Flag '{}' cannot have an argument, but found '{:?}'.", &atom, &arg) } else if arg.is_none() && self.dopt.has_arg(&atom) { try!(self.next_noeof(&*format!("argument for flag '{}'", &atom))); arg = Some(self.cur().to_string()); } self.flags.push(ArgvToken { atom: atom, arg: arg }); } else { if !seen_double_dash && self.cur() == "--" { seen_double_dash = true; } else { // Yup, we *always* insert a positional argument, which // means we completely neglect `Command` here. // This is because we can't tell whether something is a // `command` or not until we start pattern matching. let tok = ArgvToken { atom: Positional(self.cur().to_string()), arg: None, }; self.positional.push(tok); } } self.next() } Ok(()) } fn err_unknown_flag(&self, atom: &Atom) -> Result<(), String> { use std::usize::MAX; let mut best: String = "".to_string(); let flag = atom.to_string(); let mut min = MAX; let mut possibles = Vec::new(); for (key, _) in self.dopt.descs.synonyms() { possibles.push(key); } for key in self.dopt.descs.keys() { possibles.push(key); } for key in possibles.iter() { match *key { &Long(_) | &Command(_) => { let name = key.to_string(); let dist = levenshtein(&flag, &name); if dist < 3 && dist < min { min = dist; best = name; } } _ => {} } } if best.is_empty() { err!("Unknown flag: '{}'", &atom); } else { err!("Unknown flag: '{}'. Did you mean '{}'?", &atom, &best) } } fn cur<'b>(&'b self) -> &'b str { self.at(0) } fn at<'b>(&'b self, i: usize) -> &'b str { &*self.argv[self.curi + i] } fn next(&mut self) { if self.curi < self.argv.len() { self.curi += 1 } } fn next_arg<'b>(&'b mut self, atom: &Atom) -> Result<&'b str, String> { let expected = format!("argument for flag '{}'", atom); try!(self.next_noeof(&*expected)); Ok(self.cur()) } fn next_noeof(&mut self, expected: &str) -> Result<(), String> { self.next(); if self.curi == self.argv.len() { err!("Expected {} but reached end of arguments.", expected) } Ok(()) } } impl<'a> fmt::Debug for Argv<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { try!(writeln!(f, "Positional: {:?}", self.positional)); try!(writeln!(f, "Flags: {:?}", self.flags)); try!(writeln!(f, "Counts: {:?}", self.counts)); Ok(()) } } struct Matcher<'a, 'b:'a> { argv: &'a Argv<'b>, } #[derive(Clone, Debug, PartialEq)] struct MState { argvi: usize, // index into Argv.positional counts: HashMap, // flags remaining for pattern consumption max_counts: HashMap, // optional flag appearances vals: HashMap, } impl MState { fn fill_value(&mut self, key: Atom, rep: bool, arg: Option) -> bool { match (arg, rep) { (None, false) => { self.vals.insert(key, Switch(true)); } (Some(arg), false) => { self.vals.insert(key, Plain(Some(arg))); } (None, true) => { match self.vals.entry(key) { Vacant(v) => { v.insert(Counted(1)); } Occupied(mut v) => { match *v.get_mut() { Counted(ref mut c) => { *c += 1; } _ => return false, } } } } (Some(arg), true) => { match self.vals.entry(key) { Vacant(v) => { v.insert(List(vec!(arg))); } Occupied(mut v) => { match *v.get_mut() { List(ref mut vs) => vs.push(arg), _ => return false, } } } } } true } fn add_value(&mut self, opts: &Options, spec: &Atom, atom: &Atom, arg: &Option) -> bool { assert!(opts.arg.has_arg() == arg.is_some(), "'{:?}' should have an argument but doesn't", atom); match *atom { Short(_) | Long(_) => { self.fill_value(spec.clone(), opts.repeats, arg.clone()) } Positional(ref v) => { assert!(!opts.arg.has_arg()); self.fill_value(spec.clone(), opts.repeats, Some(v.clone())) } Command(_) => { assert!(!opts.arg.has_arg()); self.fill_value(spec.clone(), opts.repeats, None) } } } fn use_flag(&mut self, flag: &Atom) -> bool { match self.max_counts.entry(flag.clone()) { Vacant(v) => { v.insert(0); } Occupied(_) => {} } match self.counts.entry(flag.clone()) { Vacant(_) => { false } Occupied(mut v) => { let c = v.get_mut(); if *c == 0 { false } else { *c -= 1; true } } } } fn use_optional_flag(&mut self, flag: &Atom) { match self.max_counts.entry(flag.clone()) { Vacant(v) => { v.insert(1); } Occupied(mut v) => { *v.get_mut() += 1; } } } fn match_cmd_or_posarg(&mut self, spec: &Atom, argv: &ArgvToken) -> Option { match (spec, &argv.atom) { (_, &Command(_)) => { // This is impossible because the argv parser doesn't know // how to produce `Command` values. unreachable!() } (&Command(ref n1), &Positional(ref n2)) if n1 == n2 => { // Coerce a positional to a command because the pattern // demands it and the positional argument matches it. self.argvi += 1; Some(ArgvToken { atom: spec.clone(), arg: None }) } (&Positional(_), _) => { self.argvi += 1; Some(argv.clone()) } _ => None, } } } impl<'a, 'b> Matcher<'a, 'b> { fn matches(argv: &'a Argv, pat: &Pattern) -> Option> { let m = Matcher { argv: argv }; let init = MState { argvi: 0, counts: argv.counts.clone(), max_counts: HashMap::new(), vals: HashMap::new(), }; m.states(pat, &init) .into_iter() .filter(|s| m.state_consumed_all_argv(s)) .filter(|s| m.state_has_valid_flags(s)) .filter(|s| m.state_valid_num_flags(s)) .collect::>() .into_iter() .next() .map(|mut s| { m.add_flag_values(&mut s); m.add_default_values(&mut s); // Build a synonym map so that it's easier to look up values. let mut synmap: SynonymMap = s.vals.into_iter() .map(|(k, v)| (k.to_string(), v)) .collect(); for (from, to) in argv.dopt.descs.synonyms() { let (from, to) = (from.to_string(), to.to_string()); if synmap.contains_key(&to) { synmap.insert_synonym(from, to); } } synmap }) } fn token_from(&'a self, state: &MState) -> Option<&'a ArgvToken> { self.argv.positional.get(state.argvi) } fn add_value(&self, state: &mut MState, atom_spec: &Atom, atom: &Atom, arg: &Option) -> bool { let opts = self.argv.dopt.descs.get(atom_spec); state.add_value(opts, atom_spec, atom, arg) } fn add_flag_values(&self, state: &mut MState) { for tok in self.argv.flags.iter() { self.add_value(state, &tok.atom, &tok.atom, &tok.arg); } } fn add_default_values(&self, state: &mut MState) { let vs = &mut state.vals; for (a, opts) in self.argv.dopt.descs.iter() { if vs.contains_key(a) { continue } let atom = a.clone(); match (opts.repeats, &opts.arg) { (false, &Zero) => { match a { &Positional(_) => vs.insert(atom, Plain(None)), _ => vs.insert(atom, Switch(false)), }; } (true, &Zero) => { match a { &Positional(_) => vs.insert(atom, List(vec!())), _ => vs.insert(atom, Counted(0)), }; } (false, &One(None)) => { vs.insert(atom, Plain(None)); } (true, &One(None)) => { vs.insert(atom, List(vec!())); } (false, &One(Some(ref v))) => { vs.insert(atom, Plain(Some(v.clone()))); } (true, &One(Some(ref v))) => { let words = regex!(r"\s+") .split(v) .map(|s| s.to_owned()) .collect(); vs.insert(atom, List(words)); } } } } fn state_consumed_all_argv(&self, state: &MState) -> bool { self.argv.positional.len() == state.argvi } fn state_has_valid_flags(&self, state: &MState) -> bool { self.argv.counts.keys().all(|flag| state.max_counts.contains_key(flag)) } fn state_valid_num_flags(&self, state: &MState) -> bool { state.counts.iter().all( |(flag, count)| count <= &state.max_counts[flag]) } fn states(&self, pat: &Pattern, init: &MState) -> Vec { match *pat { Alternates(ref ps) => { let mut alt_states = vec!(); for p in ps.iter() { alt_states.extend(self.states(p, init).into_iter()); } alt_states } Sequence(ref ps) => { let (mut states, mut next) = (vec!(), vec!()); let mut iter = ps.iter(); match iter.next() { None => return vec!(init.clone()), Some(p) => states.extend(self.states(p, init).into_iter()), } for p in iter { for s in states.into_iter() { next.extend(self.states(p, &s).into_iter()); } states = vec!(); states.extend(next.into_iter()); next = vec!(); } states } Optional(ref ps) => { let mut base = init.clone(); let mut noflags = vec!(); for p in ps.iter() { match p { &PatAtom(ref a @ Short(_)) | &PatAtom(ref a @ Long(_)) => { let argv_count = self.argv.counts.get(a) .map(|&x|x).unwrap_or(0); let max_count = base.max_counts.get(a) .map(|&x|x).unwrap_or(0); if argv_count > max_count { base.use_optional_flag(a); } } other => { noflags.push(other); } } } let mut states = vec!(); self.all_option_states(&base, &mut states, &*noflags); states } Repeat(ref p) => { let mut grouped_states = vec!(self.states(&**p, init)); loop { let mut nextss = vec!(); for s in grouped_states.last().unwrap().iter() { nextss.extend( self.states(&**p, s) .into_iter() .filter(|snext| snext != s)); } if nextss.is_empty() { break } grouped_states.push(nextss); } grouped_states .into_iter() .flat_map(|ss| ss.into_iter()) .collect::>() } PatAtom(ref atom) => { let mut state = init.clone(); match *atom { Short(_) | Long(_) => { if !state.use_flag(atom) { return vec!() } } Command(_) | Positional(_) => { let tok = match self.token_from(init) { None => return vec!(), Some(tok) => tok, }; let tok = match state.match_cmd_or_posarg(atom, tok) { None => return vec!(), Some(tok) => tok, }; if !self.add_value(&mut state, atom, &tok.atom, &tok.arg) { return vec!() } } } vec!(state) } } } fn all_option_states(&self, base: &MState, states: &mut Vec, pats: &[&Pattern]) { if pats.is_empty() { states.push(base.clone()); } else { let (pat, rest) = (*pats.first().unwrap(), &pats[1..]); for s in self.states(pat, base).into_iter() { self.all_option_states(&s, states, rest); } // Order is important here! This must come after the loop above // because we prefer presence over absence. The first state wins. self.all_option_states(base, states, &pats[1..]); } } } // Tries to parse a long flag of the form '--flag[=arg]' and returns a tuple // with the flag atom and whether there is an argument or not. // If '=arg' exists and 'arg' isn't a valid argument, an error is returned. fn parse_long_equal(flag: &str) -> Result<(Atom, Argument), String> { let long_equal = regex!("^(?P[^=]+)=(?P.+)$"); match long_equal.captures(flag) { None => Ok((Atom::new(flag), Zero)), Some(cap) => { let arg = cap.name("arg").unwrap_or("").to_string(); if !Atom::is_arg(&*arg) { err!("Argument '{}' for flag '{}' is not in the \ form ARG or .", flag, arg) } Ok((Atom::new(cap.name("name").unwrap_or("")), One(None))) } } } fn parse_long_equal_argv(flag: &str) -> (Atom, Option) { let long_equal = regex!("^(?P[^=]+)=(?P.*)$"); match long_equal.captures(flag) { None => (Atom::new(flag), None), Some(cap) => ( Atom::new(cap.name("name").unwrap_or("")), Some(cap.name("arg").unwrap_or("").to_string()), ), } } // Tokenizes a usage pattern. // Beware: regex hack ahead. Tokenizes based on whitespace separated words. // It first normalizes `[xyz]` -> `[ xyz ]` so that delimiters are tokens. // Similarly for `...`, `(`, `)` and `|`. // One hitch: `--flag=` is allowed, so we use a regex to pick out // words. fn pattern_tokens(pat: &str) -> Vec { let rpat = regex!(r"\.\.\.|\[|\]|\(|\)|\|"); let rwords = regex!(r"--\S+?=<[^>]+>|<[^>]+>|\S+"); // alt order matters let pat = rpat.replace_all(pat.trim(), " $0 "); let mut words = vec!(); for cap in rwords.captures_iter(&*pat) { words.push(cap.at(0).unwrap_or("").to_string()); } words } deps/docopt-0.6.78/src/lib.rs0000644000175000001440000001772612570617740013766 0ustar users//! Docopt for Rust. This implementation conforms to the //! [official description of Docopt](http://docopt.org/) and //! [passes its test suite](https://github.com/docopt/docopt/pull/201). //! //! This library is [on GitHub](https://github.com/docopt/docopt.rs). //! //! Fundamentally, Docopt is a command line argument parser. The detail that //! distinguishes it from most parsers is that the parser is derived from the //! usage string. Here's a simple example: //! //! ```rust //! use docopt::Docopt; //! //! // Write the Docopt usage string. //! const USAGE: &'static str = " //! Usage: cp [-a] //! cp [-a] ... //! //! Options: //! -a, --archive Copy everything. //! "; //! //! // The argv. Normally you'd just use `parse` which will automatically //! // use `std::env::args()`. //! let argv = || vec!["cp", "-a", "file1", "file2", "dest/"]; //! //! // Parse argv and exit the program with an error message if it fails. //! let args = Docopt::new(USAGE) //! .and_then(|d| d.argv(argv().into_iter()).parse()) //! .unwrap_or_else(|e| e.exit()); //! //! // Now access your argv values. Synonyms work just fine! //! assert!(args.get_bool("-a") && args.get_bool("--archive")); //! assert_eq!(args.get_vec(""), vec!["file1", "file2"]); //! assert_eq!(args.get_str(""), "dest/"); //! assert_eq!(args.get_str(""), ""); //! ``` //! //! # Type based decoding //! //! Often, command line values aren't just strings or booleans---sometimes //! they are integers, or enums, or something more elaborate. Using the //! standard Docopt interface can be inconvenient for this purpose, because //! you'll need to convert all of the values explicitly. Instead, this crate //! provides a `Decoder` that converts an `ArgvMap` to your custom struct. //! Here is the same example as above using type based decoding: //! //! ```rust //! # extern crate docopt; //! # extern crate rustc_serialize; //! # fn main() { //! use docopt::Docopt; //! //! // Write the Docopt usage string. //! const USAGE: &'static str = " //! Usage: cp [-a] //! cp [-a] ... //! //! Options: //! -a, --archive Copy everything. //! "; //! //! #[derive(RustcDecodable)] //! struct Args { //! arg_source: Vec, //! arg_dest: String, //! arg_dir: String, //! flag_archive: bool, //! } //! //! let argv = || vec!["cp", "-a", "file1", "file2", "dest/"]; //! let args: Args = Docopt::new(USAGE) //! .and_then(|d| d.argv(argv().into_iter()).decode()) //! .unwrap_or_else(|e| e.exit()); //! //! // Now access your argv values. //! fn s(x: &str) -> String { x.to_string() } //! assert!(args.flag_archive); //! assert_eq!(args.arg_source, vec![s("file1"), s("file2")]); //! assert_eq!(args.arg_dir, s("dest/")); //! assert_eq!(args.arg_dest, s("")); //! # } //! ``` //! //! # Command line arguments for `rustc` //! //! Here's an example with a subset of `rustc`'s command line arguments that //! shows more of Docopt and some of the benefits of type based decoding. //! //! ```rust //! # extern crate docopt; //! # extern crate rustc_serialize; //! # fn main() { //! # #![allow(non_snake_case)] //! use docopt::Docopt; //! //! // Write the Docopt usage string. //! const USAGE: &'static str = " //! Usage: rustc [options] [--cfg SPEC... -L PATH...] INPUT //! rustc (--help | --version) //! //! Options: //! -h, --help Show this message. //! --version Show the version of rustc. //! --cfg SPEC Configure the compilation environment. //! -L PATH Add a directory to the library search path. //! --emit TYPE Configure the output that rustc will produce. //! Valid values: asm, ir, bc, obj, link. //! --opt-level LEVEL Optimize with possible levels 0-3. //! "; //! //! #[derive(RustcDecodable)] //! struct Args { //! arg_INPUT: String, //! flag_emit: Option, //! flag_opt_level: Option, //! flag_cfg: Vec, //! flag_L: Vec, //! flag_help: bool, //! flag_version: bool, //! } //! //! // This is easy. The decoder will automatically restrict values to //! // strings that match one of the enum variants. //! #[derive(RustcDecodable)] //! # #[derive(Debug, PartialEq)] //! enum Emit { Asm, Ir, Bc, Obj, Link } //! //! // This one is harder because we want the user to specify an integer, //! // but restrict it to a specific range. So we implement `Decodable` //! // ourselves. //! # #[derive(Debug, PartialEq)] //! enum OptLevel { Zero, One, Two, Three } //! //! impl rustc_serialize::Decodable for OptLevel { //! fn decode(d: &mut D) //! -> Result { //! Ok(match try!(d.read_usize()) { //! 0 => OptLevel::Zero, 1 => OptLevel::One, //! 2 => OptLevel::Two, 3 => OptLevel::Three, //! n => { //! let err = format!( //! "Could not decode '{}' as opt-level.", n); //! return Err(d.error(&*err)); //! } //! }) //! } //! } //! //! let argv = || vec!["rustc", "-L", ".", "-L", "..", "--cfg", "a", //! "--opt-level", "2", "--emit=ir", "docopt.rs"]; //! let args: Args = Docopt::new(USAGE) //! .and_then(|d| d.argv(argv().into_iter()).decode()) //! .unwrap_or_else(|e| e.exit()); //! //! // Now access your argv values. //! fn s(x: &str) -> String { x.to_string() } //! assert_eq!(args.arg_INPUT, "docopt.rs".to_string()); //! assert_eq!(args.flag_L, vec![s("."), s("..")]); //! assert_eq!(args.flag_cfg, vec![s("a")]); //! assert_eq!(args.flag_opt_level, Some(OptLevel::Two)); //! assert_eq!(args.flag_emit, Some(Emit::Ir)); //! # } //! ``` //! //! # The `docopt!` macro //! //! This package comes bundled with an additional crate, `docopt_macros`, //! which provides a `docopt!` syntax extension. Its purpose is to automate //! the creation of a Rust struct from a Docopt usage string. In particular, //! this provides a single point of truth about the definition of command line //! arguments in your program. //! //! Another advantage of using the macro is that errors in your Docopt usage //! string will be caught at compile time. Stated differently, your program //! will not compile with an invalid Docopt usage string. //! //! The example above using type based decoding can be simplified to this: //! //! ```ignore //! #![feature(plugin)] //! #![plugin(docopt_macros)] //! //! extern crate rustc_serialize; //! //! extern crate docopt; //! //! // Write the Docopt usage string with the `docopt!` macro. //! docopt!(Args, " //! Usage: cp [-a] //! cp [-a] ... //! //! Options: //! -a, --archive Copy everything. //! ") //! //! fn main() { //! let argv = || vec!["cp", "-a", "file1", "file2", "dest/"]; //! //! // Your `Args` struct has a single static method defined on it, //! // `docopt`, which will return a normal `Docopt` value. //! let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit()); //! //! // Now access your argv values. //! fn s(x: &str) -> String { x.to_string() } //! assert!(args.flag_archive); //! assert_eq!(args.arg_source, vec![s("file1"), s("file2")]); //! assert_eq!(args.arg_dir, s("dest/")); //! assert_eq!(args.arg_dest, s("")); //! } //! ``` #![crate_name = "docopt"] #![doc(html_root_url = "http://burntsushi.net/rustdoc/docopt")] #![deny(missing_docs)] extern crate regex; extern crate rustc_serialize; extern crate strsim; pub use dopt::{ArgvMap, Decoder, Docopt, Error, Value}; macro_rules! werr( ($($arg:tt)*) => ({ use std::io::{Write, stderr}; write!(&mut stderr(), $($arg)*).unwrap(); }) ); // cheat until we get syntax extensions back :-( macro_rules! regex( ($s:expr) => (::regex::Regex::new($s).unwrap()); ); mod dopt; #[doc(hidden)] pub mod parse; mod synonym; #[cfg(test)] mod test; deps/docopt-0.6.78/src/dopt.rs0000644000175000001440000007255212570617740014164 0ustar usersuse std::collections::HashMap; use std::error::Error as StdError; use std::fmt; use rustc_serialize::Decodable; use parse::Parser; use synonym::SynonymMap; use self::Value::{Switch, Counted, Plain, List}; use self::Error::{Usage, Argv, NoMatch, Decode, WithProgramUsage, Help, Version}; /// Represents the different types of Docopt errors. /// /// This error type has a lot of variants. In the common case, you probably /// don't care why Docopt has failed, and would rather just quit the program /// and show an error message instead. The `exit` method defined on the `Error` /// type will do just that. It will also set the exit code appropriately /// (no error for `--help` or `--version`, but an error code for bad usage, /// bad argv, no match or bad decode). /// /// ### Example /// /// Generally, you want to parse the usage string, try to match the argv /// and then quit the program if there was an error reported at any point /// in that process. This can be achieved like so: /// /// ```no_run /// use docopt::Docopt; /// /// const USAGE: &'static str = " /// Usage: ... /// "; /// /// let args = Docopt::new(USAGE) /// .and_then(|d| d.parse()) /// .unwrap_or_else(|e| e.exit()); /// ``` #[derive(Debug)] pub enum Error { /// Parsing the usage string failed. /// /// This error can only be triggered by the programmer, i.e., the writer /// of the Docopt usage string. This error is usually indicative of a bug /// in your program. Usage(String), /// Parsing the argv specified failed. /// /// The payload is a string describing why the arguments provided could not /// be parsed. /// /// This is distinct from `NoMatch` because it will catch errors like /// using flags that aren't defined in the usage string. Argv(String), /// The given argv parsed successfully, but it did not match any example /// usage of the program. /// /// Regrettably, there is no descriptive message describing *why* the /// given argv didn't match any of the usage strings. NoMatch, /// This indicates a problem decoding a successful argv match into a /// decodable value. Decode(String), /// Parsing failed, and the program usage should be printed next to the /// failure message. Typically this wraps `Argv` and `NoMatch` errors. WithProgramUsage(Box, String), /// Decoding or parsing failed because the command line specified that the /// help message should be printed. Help, /// Decoding or parsing failed because the command line specified that the /// version should be printed /// /// The version is included as a payload to this variant. Version(String), } impl Error { /// Return whether this was a fatal error or not. /// /// Non-fatal errors include requests to print the help or version /// information of a program, while fatal errors include those such as /// failing to decode or parse. pub fn fatal(&self) -> bool { match *self { Help | Version(..) => false, Usage(..) | Argv(..) | NoMatch | Decode(..) => true, WithProgramUsage(ref b, _) => b.fatal(), } } /// Print this error and immediately exit the program. /// /// If the error is non-fatal (e.g., `Help` or `Version`), then the /// error is printed to stdout and the exit status will be `0`. Otherwise, /// when the error is fatal, the error is printed to stderr and the /// exit status will be `1`. pub fn exit(&self) -> ! { if self.fatal() { werr!("{}\n", self); ::std::process::exit(1) } else { println!("{}", self); ::std::process::exit(0) } } } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { WithProgramUsage(ref other, ref usage) => { let other = other.to_string(); if other.is_empty() { write!(f, "{}", usage) } else { write!(f, "{}\n\n{}", other, usage) } } Help => write!(f, ""), NoMatch => write!(f, "Invalid arguments."), Usage(ref s) | Argv(ref s) | Decode(ref s) | Version(ref s) => { write!(f, "{}", s) } } } } impl StdError for Error { fn description(&self) -> &str { match *self { Usage(..) => "invalid usage string", Argv(..) => "failed to parse specified argv", NoMatch => "could not match specified argv", Decode(..) => "failed to decode", WithProgramUsage(..) => "failed to parse specified argv", Help => "help message requested", Version(..) => "version message requested", } } fn cause(&self) -> Option<&StdError> { match *self { WithProgramUsage(ref cause, _) => Some(&**cause), _ => None, } } } /// The main Docopt type, which is constructed with a Docopt usage string. /// /// This can be used to match command line arguments to produce a `ArgvMap`. #[derive(Clone, Debug)] pub struct Docopt { p: Parser, argv: Option>, options_first: bool, help: bool, version: Option, } impl Docopt { /// Parse the Docopt usage string given. /// /// The `Docopt` value returned may be used immediately to parse command /// line arguments with a default configuration. /// /// If there was a problem parsing the usage string, a `Usage` error /// is returned. pub fn new(usage: S) -> Result where S: ::std::ops::Deref { Parser::new(usage.deref()) .map_err(Usage) .map(|p| Docopt { p: p, argv: None, options_first: false, help: true, version: None, }) } /// Parse and decode the given argv. /// /// This is a convenience method for /// `parse().and_then(|vals| vals.decode())`. /// /// For details on how decoding works, please see the documentation for /// `ArgvMap`. pub fn decode(&self) -> Result where D: Decodable { self.parse().and_then(|vals| vals.decode()) } /// Parse command line arguments and try to match them against a usage /// pattern specified in the Docopt string. /// /// If there is a match, then an `ArgvMap` is returned, which maps /// flags, commands and arguments to values. /// /// If parsing the command line arguments fails, then an `Argv` error is /// returned. If parsing succeeds but there is no match, then a `NoMatch` /// error is returned. Both of these errors are always returned inside a /// `WithProgramUsage` error. /// /// If special handling of `help` or `version` is enabled (the former is /// enabled by default), then `Help` or `Version` errors are returned /// if `--help` or `--version` is present. pub fn parse(&self) -> Result { let argv = self.argv.clone().unwrap_or_else(|| Docopt::get_argv()); let vals = try!( self.p.parse_argv(argv, self.options_first) .map_err(|s| self.err_with_usage(Argv(s))) .and_then(|argv| match self.p.matches(&argv) { Some(m) => Ok(ArgvMap { map: m }), None => Err(self.err_with_usage(NoMatch)), })); if self.help && vals.get_bool("--help") { return Err(self.err_with_full_doc(Help)); } match self.version { Some(ref v) if vals.get_bool("--version") => { return Err(Version(v.clone())) } _ => {}, } Ok(vals) } /// Set the argv to be used for Docopt parsing. /// /// By default, when no argv is set, and it is automatically taken from /// `std::env::args()`. /// /// The `argv` given *must* be the full set of `argv` passed to the /// program. e.g., `["cp", "src", "dest"]` is right while `["src", "dest"]` /// is wrong. pub fn argv(mut self, argv: I) -> Docopt where I: IntoIterator, S: AsRef { self.argv = Some( argv.into_iter().skip(1).map(|s| s.as_ref().to_owned()).collect() ); self } /// Enables the "options first" Docopt behavior. /// /// The options first behavior means that all flags *must* appear before /// position arguments. That is, after the first position argument is /// seen, all proceeding arguments are interpreted as positional /// arguments unconditionally. pub fn options_first(mut self, yes: bool) -> Docopt { self.options_first = yes; self } /// Enables automatic handling of `--help`. /// /// When this is enabled and `--help` appears anywhere in the arguments, /// then a `Help` error will be returned. You may then use the `exit` /// method on the error value to conveniently quit the program (which will /// print the full usage string to stdout). /// /// Note that for this to work, `--help` must be a valid pattern. /// /// When disabled, there is no special handling of `--help`. pub fn help(mut self, yes: bool) -> Docopt { self.help = yes; self } /// Enables automatic handling of `--version`. /// /// When this is enabled and `--version` appears anywhere in the arguments, /// then a `Version(s)` error will be returned, where `s` is the string /// given here. You may then use the `exit` method on the error value to /// convenient quit the program (which will print the version to stdout). /// /// When disabled (a `None` value), there is no special handling of /// `--version`. pub fn version(mut self, version: Option) -> Docopt { self.version = version; self } #[doc(hidden)] // Exposed for use in `docopt_macros`. pub fn parser<'a>(&'a self) -> &'a Parser { &self.p } fn err_with_usage(&self, e: Error) -> Error { WithProgramUsage( Box::new(e), self.p.usage.trim().to_string()) } fn err_with_full_doc(&self, e: Error) -> Error { WithProgramUsage( Box::new(e), self.p.full_doc.trim().to_string()) } fn get_argv() -> Vec { // Hmm, we should probably handle a Unicode decode error here... ---AG ::std::env::args().skip(1).map(|v| v.to_string()).collect() } } /// A map containing matched values from command line arguments. /// /// The keys are just as specified in Docopt: `--flag` for a long flag or /// `-f` for a short flag. (If `-f` is a synonym for `--flag`, then either /// key will work.) `ARG` or `` specify a positional argument and `cmd` /// specifies a command. #[derive(Clone)] pub struct ArgvMap { #[doc(hidden)] pub map: SynonymMap, } impl ArgvMap { /// Tries to decode the map of values into a struct. /// /// This method should always be called to decode a `ArgvMap` into /// a struct. All fields of the struct must map to a corresponding key /// in the `ArgvMap`. To this end, each member must have a special prefix /// corresponding to the different kinds of patterns in Docopt. There are /// three prefixes: `flag_`, `arg_` and `cmd_` which respectively /// correspond to short/long flags, positional arguments and commands. /// /// If a Docopt item has a `-` in its name, then it is converted to an `_`. /// /// # Example /// /// ```rust /// # extern crate docopt; /// # extern crate rustc_serialize; /// # fn main() { /// use docopt::Docopt; /// /// const USAGE: &'static str = " /// Usage: cargo [options] (build | test) /// cargo --help /// /// Options: -v, --verbose /// -h, --help /// "; /// /// #[derive(RustcDecodable)] /// struct Args { /// cmd_build: bool, /// cmd_test: bool, /// flag_verbose: bool, /// flag_h: bool, /// } /// /// let argv = || vec!["cargo", "build", "-v"].into_iter(); /// let args: Args = Docopt::new(USAGE) /// .and_then(|d| d.argv(argv()).decode()) /// .unwrap_or_else(|e| e.exit()); /// assert!(args.cmd_build && !args.cmd_test /// && args.flag_verbose && !args.flag_h); /// # } /// ``` /// /// Note that in the above example, `flag_h` is used but `flag_help` /// could also be used. (In fact, both could be used at the same time.) /// /// In this example, only the `bool` type was used, but any type satisfying /// the `Decodable` trait is valid. pub fn decode(self) -> Result { Decodable::decode(&mut Decoder { vals: self, stack: vec!() }) } /// Finds the value corresponding to `key` and calls `as_bool()` on it. /// If the key does not exist, `false` is returned. pub fn get_bool(&self, key: &str) -> bool { self.find(key).map(|v| v.as_bool()).unwrap_or(false) } /// Finds the value corresponding to `key` and calls `as_count()` on it. /// If the key does not exist, `0` is returned. pub fn get_count(&self, key: &str) -> u64 { self.find(key).map(|v| v.as_count()).unwrap_or(0) } /// Finds the value corresponding to `key` and calls `as_str()` on it. /// If the key does not exist, `""` is returned. pub fn get_str<'a>(&'a self, key: &str) -> &'a str { self.find(key).map(|v| v.as_str()).unwrap_or("") } /// Finds the value corresponding to `key` and calls `as_vec()` on it. /// If the key does not exist, `vec!()` is returned. pub fn get_vec<'a>(&'a self, key: &str) -> Vec<&'a str> { self.find(key).map(|v| v.as_vec()).unwrap_or(vec!()) } /// Return the raw value corresponding to some `key`. /// /// `key` should be a string in the traditional Docopt format. e.g., /// `` or `--flag`. pub fn find<'a>(&'a self, key: &str) -> Option<&'a Value> { self.map.find(&key.to_string()) } /// Return the number of values, not including synonyms. pub fn len(&self) -> usize { self.map.len() } /// Converts a Docopt key to a struct field name. /// This makes a half-hearted attempt at making the key a valid struct /// field name (like replacing `-` with `_`), but it does not otherwise /// guarantee that the result is a valid struct field name. #[doc(hidden)] pub fn key_to_struct_field(name: &str) -> String { fn sanitize(name: &str) -> String { name.replace("-", "_") } let r = regex!(r"^(?:--?(?P\S+)|(?:(?P\p{Lu}+)|<(?P[^>]+)>)|(?P\S+))$"); r.replace(name, |cap: &::regex::Captures| { let (flag, cmd) = ( cap.name("flag").unwrap_or(""), cap.name("cmd").unwrap_or(""), ); let (argu, argb) = ( cap.name("argu").unwrap_or(""), cap.name("argb").unwrap_or(""), ); let (prefix, name) = if !flag.is_empty() { ("flag_", flag) } else if !argu.is_empty() { ("arg_", argu) } else if !argb.is_empty() { ("arg_", argb) } else if !cmd.is_empty() { ("cmd_", cmd) } else { panic!("Unknown ArgvMap key: '{}'", name) }; let mut prefix = prefix.to_string(); prefix.push_str(&sanitize(name)); prefix }) } /// Converts a struct field name to a Docopt key. #[doc(hidden)] pub fn struct_field_to_key(field: &str) -> String { fn desanitize(name: &str) -> String { name.replace("_", "-") } let name = if field.starts_with("flag_") { let name = regex!(r"^flag_").replace(field, ""); let mut pre_name = (if name.len() == 1 { "-" } else { "--" }) .to_string(); pre_name.push_str(&*name); pre_name } else if field.starts_with("arg_") { let name = regex!(r"^arg_").replace(field, ""); if regex!(r"^\p{Lu}+$").is_match(&name) { name } else { let mut pre_name = "<".to_string(); pre_name.push_str(&*name); pre_name.push('>'); pre_name } } else if field.starts_with("cmd_") { { regex!(r"^cmd_") }.replace(field, "") } else { panic!("Unrecognized struct field: '{}'", field) }; desanitize(&*name) } } impl fmt::Debug for ArgvMap { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if self.len() == 0 { return write!(f, "{{EMPTY}}"); } // This is a little crazy, but we want to group synonyms with // their keys and sort them for predictable output. let reverse: HashMap<&String, &String> = self.map.synonyms().map(|(from, to)| (to, from)).collect(); let mut keys: Vec<&String> = self.map.keys().collect(); keys.sort(); let mut first = true; for &k in keys.iter() { if !first { try!(write!(f, "\n")); } else { first = false; } match reverse.get(&k) { None => { try!(write!(f, "{} => {:?}", k, self.map.get(k))) } Some(s) => { try!(write!(f, "{}, {} => {:?}", s, k, self.map.get(k))) } } } Ok(()) } } /// A matched command line value. /// /// The value can be a boolean, counted repetition, a plain string or a list /// of strings. /// /// The various `as_{bool,count,str,vec}` methods provide convenient access /// to values without destructuring manually. #[derive(Clone, Debug, PartialEq)] pub enum Value { /// A boolean value from a flag that has no argument. /// /// The presence of a flag means `true` and the absence of a flag /// means `false`. Switch(bool), /// The number of occurrences of a repeated flag. Counted(u64), /// A positional or flag argument. /// /// This is `None` when the positional argument or flag is not present. /// Note that it is possible to have `Some("")` for a present but empty /// argument. Plain(Option), /// A List of positional or flag arguments. /// /// This list may be empty when no arguments or flags are present. List(Vec), } impl Value { /// Returns the value as a bool. /// /// Counted repetitions are `false` if `0` and `true` otherwise. /// Plain strings are `true` if present and `false` otherwise. /// Lists are `true` if non-empty and `false` otherwise. pub fn as_bool(&self) -> bool { match *self { Switch(b) => b, Counted(n) => n > 0, Plain(None) => false, Plain(Some(_)) => true, List(ref vs) => !vs.is_empty(), } } /// Returns the value as a count of the number of times it occurred. /// /// Booleans are `1` if `true` and `0` otherwise. /// Plain strings are `1` if present and `0` otherwise. /// Lists correspond to its length. pub fn as_count(&self) -> u64 { match *self { Switch(b) => if b { 1 } else { 0 }, Counted(n) => n, Plain(None) => 0, Plain(Some(_)) => 1, List(ref vs) => vs.len() as u64, } } /// Returns the value as a string. /// /// All values return an empty string except for a non-empty plain string. pub fn as_str<'a>(&'a self) -> &'a str { match *self { Switch(_) | Counted(_) | Plain(None) | List(_) => "", Plain(Some(ref s)) => &**s, } } /// Returns the value as a list of strings. /// /// Booleans, repetitions and empty strings correspond to an empty list. /// Plain strings correspond to a list of length `1`. pub fn as_vec<'a>(&'a self) -> Vec<&'a str> { match *self { Switch(_) | Counted(_) | Plain(None) => vec![], Plain(Some(ref s)) => vec![&**s], List(ref vs) => vs.iter().map(|s| &**s).collect(), } } } /// Decoder for `ArgvMap` into your own `Decodable` types. /// /// In general, you shouldn't have to use this type directly. It is exposed /// in case you want to write a generic function that produces a decodable /// value. For example, here's a function that takes a usage string, an argv /// and produces a decodable value: /// /// ```rust /// # extern crate docopt; /// # extern crate rustc_serialize; /// # fn main() { /// use docopt::Docopt; /// use rustc_serialize::Decodable; /// /// fn decode(usage: &str, argv: &[&str]) /// -> Result { /// Docopt::new(usage) /// .and_then(|d| d.argv(argv.iter().cloned()).decode()) /// } /// # } pub struct Decoder { vals: ArgvMap, stack: Vec, } #[derive(Debug)] struct DecoderItem { key: String, struct_field: String, val: Option, } macro_rules! derr( ($($arg:tt)*) => (return Err(Decode(format!($($arg)*)))) ); impl Decoder { fn push(&mut self, struct_field: &str) { let key = ArgvMap::struct_field_to_key(struct_field); self.stack.push(DecoderItem { key: key.clone(), struct_field: struct_field.to_string(), val: self.vals.find(&*key).map(|v| v.clone()), }); } fn pop(&mut self) -> Result { match self.stack.pop() { None => derr!("Could not decode value into unknown key."), Some(it) => Ok(it), } } fn pop_key_val(&mut self) -> Result<(String, Value), Error> { let it = try!(self.pop()); match it.val { None => derr!( "Could not find argument '{}' (from struct field '{}'). Note that each struct field must have the right key prefix, which must be one of `cmd_`, `flag_` or `arg_`.", it.key, it.struct_field), Some(v) => Ok((it.key, v)), } } fn pop_val(&mut self) -> Result { let (_, v) = try!(self.pop_key_val()); Ok(v) } fn to_number(&mut self, expect: &str) -> Result { let (k, v) = try!(self.pop_key_val()); match v { Counted(n) => Ok(n), _ => { if v.as_str().trim().is_empty() { Ok(0) } else { match v.as_str().parse() { Err(_) => { derr!("Could not decode '{}' to {} for '{}'.", v.as_str(), expect, k) } Ok(v) => Ok(v), } } } } } fn to_float(&mut self, expect: &str) -> Result { let (k, v) = try!(self.pop_key_val()); match v { Counted(n) => Ok(n as f64), _ => { match v.as_str().parse() { Err(_) => derr!("Could not decode '{}' to {} for '{}'.", v.as_str(), expect, k), Ok(v) => Ok(v), } } } } } macro_rules! read_num { ($name:ident, $ty:ty) => ( fn $name(&mut self) -> Result<$ty, Error> { self.to_number(stringify!($ty)).map(|n| n as $ty) } ); } impl ::rustc_serialize::Decoder for Decoder { type Error = Error; fn error(&mut self, err: &str) -> Error { Decode(err.to_string()) } fn read_nil(&mut self) -> Result<(), Error> { // I don't know what the right thing is here, so just fail for now. panic!("I don't know how to read into a nil value.") } read_num!(read_usize, usize); read_num!(read_u64, u64); read_num!(read_u32, u32); read_num!(read_u16, u16); read_num!(read_u8, u8); read_num!(read_isize, isize); read_num!(read_i64, i64); read_num!(read_i32, i32); read_num!(read_i16, i16); read_num!(read_i8, i8); fn read_bool(&mut self) -> Result { self.pop_val().map(|v| v.as_bool()) } fn read_f64(&mut self) -> Result { self.to_float("f64") } fn read_f32(&mut self) -> Result { self.to_float("f32").map(|n| n as f32) } fn read_char(&mut self) -> Result { let (k, v) = try!(self.pop_key_val()); let vstr = v.as_str(); match vstr.chars().count() { 1 => Ok(vstr.chars().next().unwrap()), _ => derr!("Could not decode '{}' into char for '{}'.", vstr, k), } } fn read_str(&mut self) -> Result { self.pop_val().map(|v| v.as_str().to_string()) } fn read_enum(&mut self, _: &str, f: F) -> Result where F: FnOnce(&mut Decoder) -> Result { f(self) } fn read_enum_variant(&mut self, names: &[&str], mut f: F) -> Result where F: FnMut(&mut Decoder, usize) -> Result { let v = to_lowercase(try!(self.pop_val()).as_str()); let i = match names.iter().map(|&n| to_lowercase(n)).position(|n| n == v) { Some(i) => i, None => { derr!("Could not match '{}' with any of \ the allowed variants: {:?}", v, names) } }; f(self, i) } fn read_enum_variant_arg(&mut self, _: usize, _: F) -> Result where F: FnOnce(&mut Decoder) -> Result { unimplemented!() } fn read_enum_struct_variant(&mut self, _: &[&str], _: F) -> Result where F: FnMut(&mut Decoder, usize) -> Result { unimplemented!() } fn read_enum_struct_variant_field(&mut self, _: &str, _: usize, _: F) -> Result where F: FnOnce(&mut Decoder) -> Result { unimplemented!() } fn read_struct(&mut self, _: &str, _: usize, f: F) -> Result where F: FnOnce(&mut Decoder) -> Result { f(self) } fn read_struct_field(&mut self, f_name: &str, _: usize, f: F) -> Result where F: FnOnce(&mut Decoder) -> Result { self.push(f_name); f(self) } fn read_tuple(&mut self, _: usize, _: F) -> Result where F: FnOnce(&mut Decoder) -> Result { unimplemented!() } fn read_tuple_arg(&mut self, _: usize, _: F) -> Result where F: FnOnce(&mut Decoder) -> Result { unimplemented!() } fn read_tuple_struct(&mut self, _: &str, _: usize, _: F) -> Result where F: FnOnce(&mut Decoder) -> Result { unimplemented!() } fn read_tuple_struct_arg(&mut self, _: usize, _: F) -> Result where F: FnOnce(&mut Decoder) -> Result { unimplemented!() } fn read_option(&mut self, mut f: F) -> Result where F: FnMut(&mut Decoder, bool) -> Result { let option = match self.stack.last() { None => derr!("Could not decode value into unknown key."), Some(it) => it.val.as_ref() .map(|v| v.as_bool()) .unwrap_or(false), }; f(self, option) } fn read_seq(&mut self, f: F) -> Result where F: FnOnce(&mut Decoder, usize) -> Result { let it = try!(self.pop()); let list = it.val.unwrap_or(List(vec!())); let vals = list.as_vec(); for val in vals.iter().rev() { self.stack.push(DecoderItem { key: it.key.clone(), struct_field: it.struct_field.clone(), val: Some(Plain(Some(val.to_string()))), }) } f(self, vals.len()) } fn read_seq_elt(&mut self, _: usize, f: F) -> Result where F: FnOnce(&mut Decoder) -> Result { f(self) } fn read_map(&mut self, _: F) -> Result where F: FnOnce(&mut Decoder, usize) -> Result { unimplemented!() } fn read_map_elt_key(&mut self, _: usize, _: F) -> Result where F: FnOnce(&mut Decoder) -> Result { unimplemented!() } fn read_map_elt_val(&mut self, _: usize, _: F) -> Result where F: FnOnce(&mut Decoder) -> Result { unimplemented!() } } fn to_lowercase>(s: S) -> String { s.into().chars().map(|c| c.to_lowercase().next().unwrap()).collect() } deps/docopt-0.6.78/src/test/0000755000000000000000000000000012666635520014316 5ustar rootrootdeps/docopt-0.6.78/src/test/suggestions.rs0000644000175000001440000000410612517176611016533 0ustar usersuse {Docopt, Error}; fn get_suggestion(doc: &str, argv: &[&'static str]) -> Error { let dopt = match Docopt::new(doc) { Err(err) => panic!("Invalid usage: {}", err), Ok(dopt) => dopt, }; let mut argv: Vec<_> = argv.iter().map(|x| x.to_string()).collect(); argv.insert(0, "prog".to_string()); match dopt.argv(argv.into_iter()).parse() { Err(err) => err, Ok(_) => panic!("Should have been a user error"), } } macro_rules! test_suggest( ($name:ident, $doc:expr, $args:expr, $expected:expr) => ( #[test] fn $name() { let sg = get_suggestion($doc, $args); println!("{}", sg); match sg { Error::WithProgramUsage(e, _) => { match *e { Error::Argv(msg) => { println!("{:?}",msg); assert_eq!(msg, $expected); } err => panic!("Error other than argv: {:?}", err) } }, _ => panic!("Error without program usage") } } ); ); test_suggest!(test_suggest_1, "Usage: prog [--release]", &["--releas"], "Unknown flag: '--releas'. Did you mean '--release'?"); test_suggest!(test_suggest_2, "Usage: prog [-a] prog [-a] ... prog [-e] Options: -a, --archive Copy everything. ", &["-d"], "Unknown flag: '-d'"); test_suggest!(test_suggest_3, "Usage: prog [-a] prog [-a] ... prog [-e] Options: -a, --archive Copy everything. -e, --export Export all the things. ", &["--expotr"], "Unknown flag: '--expotr'. Did you mean '--export'?"); test_suggest!(test_suggest_4, "Usage: prog [--import] [--complete] ", &["--mport", "--complte"], "Unknown flag: '--mport'. Did you mean '--import'?"); test_suggest!(test_suggest_5, "Usage: prog [--import] [--complete] ", &["--import", "--complte"], "Unknown flag: '--complte'. Did you mean '--complete'?"); deps/docopt-0.6.78/src/test/testcases.docopt0000644000175000001440000003314012555551214017021 0ustar usersr"""Usage: prog """ $ prog {} $ prog --xxx "user-error" r"""Usage: prog [options] Options: -a All. """ $ prog {"-a": false} $ prog -a {"-a": true} $ prog -x "user-error" r"""Usage: prog [options] Options: --all All. """ $ prog {"--all": false} $ prog --all {"--all": true} $ prog --xxx "user-error" r"""Usage: prog [options] Options: -v, --verbose Verbose. """ $ prog --verbose {"--verbose": true} $ prog --ver "user-error" $ prog -v {"--verbose": true} r"""Usage: prog [options] Options: -p PATH """ $ prog -p home/ {"-p": "home/"} $ prog -phome/ {"-p": "home/"} $ prog -p "user-error" r"""Usage: prog [options] Options: --path """ $ prog --path home/ {"--path": "home/"} $ prog --path=home/ {"--path": "home/"} $ prog --pa home/ "user-error" $ prog --pa=home/ "user-error" $ prog --path "user-error" r"""Usage: prog [options] Options: -p PATH, --path= Path to files. """ $ prog -proot {"--path": "root"} r"""Usage: prog [options] Options: -p --path PATH Path to files. """ $ prog -p root {"--path": "root"} $ prog --path root {"--path": "root"} r"""Usage: prog [options] Options: -p PATH Path to files [default: ./] """ $ prog {"-p": "./"} $ prog -phome {"-p": "home"} r"""UsAgE: prog [options] OpTiOnS: --path= Path to files [dEfAuLt: /root] """ $ prog {"--path": "/root"} $ prog --path=home {"--path": "home"} r"""usage: prog [options] options: -a Add -r Remote -m Message """ $ prog -a -r -m Hello {"-a": true, "-r": true, "-m": "Hello"} $ prog -armyourass {"-a": true, "-r": true, "-m": "yourass"} $ prog -a -r {"-a": true, "-r": true, "-m": null} r"""Usage: prog [options] Options: --version --verbose """ $ prog --version {"--version": true, "--verbose": false} $ prog --verbose {"--version": false, "--verbose": true} $ prog --ver "user-error" $ prog --verb "user-error" r"""usage: prog [-a -r -m ] options: -a Add -r Remote -m Message """ $ prog -armyourass {"-a": true, "-r": true, "-m": "yourass"} r"""usage: prog [-armMSG] options: -a Add -r Remote -m Message """ $ prog -a -r -m Hello {"-a": true, "-r": true, "-m": "Hello"} r"""usage: prog -a -b options: -a -b """ $ prog -a -b {"-a": true, "-b": true} $ prog -b -a {"-a": true, "-b": true} $ prog -a "user-error" $ prog "user-error" r"""usage: prog (-a -b) options: -a -b """ $ prog -a -b {"-a": true, "-b": true} $ prog -b -a {"-a": true, "-b": true} $ prog -a "user-error" $ prog "user-error" r"""usage: prog [-a] -b options: -a -b """ $ prog -a -b {"-a": true, "-b": true} $ prog -b -a {"-a": true, "-b": true} $ prog -a "user-error" $ prog -b {"-a": false, "-b": true} $ prog "user-error" r"""usage: prog [(-a -b)] options: -a -b """ $ prog -a -b {"-a": true, "-b": true} $ prog -b -a {"-a": true, "-b": true} $ prog -a "user-error" $ prog -b "user-error" $ prog {"-a": false, "-b": false} r"""usage: prog (-a|-b) options: -a -b """ $ prog -a -b "user-error" $ prog "user-error" $ prog -a {"-a": true, "-b": false} $ prog -b {"-a": false, "-b": true} r"""usage: prog [ -a | -b ] options: -a -b """ $ prog -a -b "user-error" $ prog {"-a": false, "-b": false} $ prog -a {"-a": true, "-b": false} $ prog -b {"-a": false, "-b": true} r"""usage: prog """ $ prog 10 {"": "10"} $ prog 10 20 "user-error" $ prog "user-error" r"""usage: prog []""" $ prog 10 {"": "10"} $ prog 10 20 "user-error" $ prog {"": null} r"""usage: prog """ $ prog 10 20 40 {"": "10", "": "20", "": "40"} $ prog 10 20 "user-error" $ prog "user-error" r"""usage: prog [ ]""" $ prog 10 20 40 {"": "10", "": "20", "": "40"} $ prog 10 20 {"": "10", "": "20", "": null} $ prog "user-error" r"""usage: prog [ | ]""" $ prog 10 20 40 "user-error" $ prog 20 40 {"": null, "": "20", "": "40"} $ prog {"": null, "": null, "": null} r"""usage: prog ( --all | ) options: --all """ $ prog 10 --all {"": "10", "--all": true, "": null} $ prog 10 {"": null, "--all": false, "": "10"} $ prog "user-error" r"""usage: prog [ ]""" $ prog 10 20 {"": ["10", "20"]} $ prog 10 {"": ["10"]} $ prog {"": []} r"""usage: prog [( )]""" $ prog 10 20 {"": ["10", "20"]} $ prog 10 "user-error" $ prog {"": []} r"""usage: prog NAME...""" $ prog 10 20 {"NAME": ["10", "20"]} $ prog 10 {"NAME": ["10"]} $ prog "user-error" r"""usage: prog [NAME]...""" $ prog 10 20 {"NAME": ["10", "20"]} $ prog 10 {"NAME": ["10"]} $ prog {"NAME": []} r"""usage: prog [NAME...]""" $ prog 10 20 {"NAME": ["10", "20"]} $ prog 10 {"NAME": ["10"]} $ prog {"NAME": []} r"""usage: prog [NAME [NAME ...]]""" $ prog 10 20 {"NAME": ["10", "20"]} $ prog 10 {"NAME": ["10"]} $ prog {"NAME": []} r"""usage: prog (NAME | --foo NAME) options: --foo """ $ prog 10 {"NAME": "10", "--foo": false} $ prog --foo 10 {"NAME": "10", "--foo": true} $ prog --foo=10 "user-error" r"""usage: prog (NAME | --foo) [--bar | NAME] options: --foo options: --bar """ $ prog 10 {"NAME": ["10"], "--foo": false, "--bar": false} $ prog 10 20 {"NAME": ["10", "20"], "--foo": false, "--bar": false} $ prog --foo --bar {"NAME": [], "--foo": true, "--bar": true} r"""Naval Fate. Usage: prog ship new ... prog ship [] move [--speed=] prog ship shoot prog mine (set|remove) [--moored|--drifting] prog -h | --help prog --version Options: -h --help Show this screen. --version Show version. --speed= Speed in knots [default: 10]. --moored Mored (anchored) mine. --drifting Drifting mine. """ $ prog ship Guardian move 150 300 --speed=20 {"--drifting": false, "--help": false, "--moored": false, "--speed": "20", "--version": false, "": ["Guardian"], "": "150", "": "300", "mine": false, "move": true, "new": false, "remove": false, "set": false, "ship": true, "shoot": false} r"""usage: prog --hello""" $ prog --hello {"--hello": true} r"""usage: prog [--hello=]""" $ prog {"--hello": null} $ prog --hello wrld {"--hello": "wrld"} r"""usage: prog [-o]""" $ prog {"-o": false} $ prog -o {"-o": true} r"""usage: prog [-opr]""" $ prog -op {"-o": true, "-p": true, "-r": false} r"""usage: prog --aabb | --aa""" $ prog --aa {"--aabb": false, "--aa": true} $ prog --a "user-error" # not a unique prefix # # Counting number of flags # r"""Usage: prog -v""" $ prog -v {"-v": true} r"""Usage: prog [-v -v]""" $ prog {"-v": 0} $ prog -v {"-v": 1} $ prog -vv {"-v": 2} r"""Usage: prog -v ...""" $ prog "user-error" $ prog -v {"-v": 1} $ prog -vv {"-v": 2} $ prog -vvvvvv {"-v": 6} r"""Usage: prog [-v | -vv | -vvv] This one is probably most readable user-friednly variant. """ $ prog {"-v": 0} $ prog -v {"-v": 1} $ prog -vv {"-v": 2} $ prog -vvvv "user-error" r"""usage: prog [--ver --ver]""" $ prog --ver --ver {"--ver": 2} # # Counting commands # r"""usage: prog [go]""" $ prog go {"go": true} r"""usage: prog [go go]""" $ prog {"go": 0} $ prog go {"go": 1} $ prog go go {"go": 2} $ prog go go go "user-error" r"""usage: prog go...""" $ prog go go go go go {"go": 5} # # [options] does not include options from usage-pattern # r"""usage: prog [options] [-a] options: -a -b """ $ prog -a {"-a": true, "-b": false} $ prog -aa "user-error" # # Test [options] shourtcut # r"""Usage: prog [options] A Options: -q Be quiet -v Be verbose. """ $ prog arg {"A": "arg", "-v": false, "-q": false} $ prog -v arg {"A": "arg", "-v": true, "-q": false} $ prog -q arg {"A": "arg", "-v": false, "-q": true} # # Test single dash # r"""usage: prog [-]""" $ prog - {"-": true} $ prog {"-": false} # # If argument is repeated, its value should always be a list # r"""usage: prog [NAME [NAME ...]]""" $ prog a b {"NAME": ["a", "b"]} $ prog {"NAME": []} # # Option's argument defaults to null/None # r"""usage: prog [options] options: -a Add -m Message """ $ prog -a {"-m": null, "-a": true} # # Test options without description # r"""usage: prog --hello""" $ prog --hello {"--hello": true} r"""usage: prog [--hello=]""" $ prog {"--hello": null} $ prog --hello wrld {"--hello": "wrld"} r"""usage: prog [-o]""" $ prog {"-o": false} $ prog -o {"-o": true} r"""usage: prog [-opr]""" $ prog -op {"-o": true, "-p": true, "-r": false} r"""usage: git [-v | --verbose]""" $ prog -v {"-v": true, "--verbose": false} r"""usage: git remote [-v | --verbose]""" $ prog remote -v {"remote": true, "-v": true, "--verbose": false} # # Test empty usage pattern # r"""usage: prog""" $ prog {} r"""usage: prog prog """ $ prog 1 2 {"": "1", "": "2"} $ prog {"": null, "": null} r"""usage: prog prog """ $ prog {"": null, "": null} # # Option's argument should not capture default value from usage pattern # r"""usage: prog [--file=]""" $ prog {"--file": null} r"""usage: prog [--file=] options: --file """ $ prog {"--file": null} r"""Usage: prog [-a ] Options: -a, --address TCP address [default: localhost:6283]. """ $ prog {"--address": "localhost:6283"} # # If option with argument could be repeated, # its arguments should be accumulated into a list # r"""usage: prog --long= ...""" $ prog --long one {"--long": ["one"]} $ prog --long one --long two {"--long": ["one", "two"]} # # Test multiple elements repeated at once # r"""usage: prog (go --speed=)...""" $ prog go left --speed=5 go right --speed=9 {"go": 2, "": ["left", "right"], "--speed": ["5", "9"]} # # Required options should work with option shortcut # r"""usage: prog [options] -a options: -a """ $ prog -a {"-a": true} # # If option could be repeated its defaults should be split into a list # r"""usage: prog [-o ]... options: -o [default: x] """ $ prog -o this -o that {"-o": ["this", "that"]} $ prog {"-o": ["x"]} r"""usage: prog [-o ]... options: -o [default: x y] """ $ prog -o this {"-o": ["this"]} $ prog {"-o": ["x", "y"]} # # Test stacked option's argument # r"""usage: prog -pPATH options: -p PATH """ $ prog -pHOME {"-p": "HOME"} # # Issue 56: Repeated mutually exclusive args give nested lists sometimes # r"""Usage: foo (--xx=X|--yy=Y)...""" $ prog --xx=1 --yy=2 {"--xx": ["1"], "--yy": ["2"]} # # POSIXly correct tokenization # r"""usage: prog []""" $ prog f.txt {"": "f.txt"} r"""usage: prog [--input=]...""" $ prog --input a.txt --input=b.txt {"--input": ["a.txt", "b.txt"]} # # Issue 85: `[options]` shourtcut with multiple subcommands # r"""usage: prog good [options] prog fail [options] options: --loglevel=N """ $ prog fail --loglevel 5 {"--loglevel": "5", "fail": true, "good": false} # # Usage-section syntax # r"""usage:prog --foo""" $ prog --foo {"--foo": true} r"""PROGRAM USAGE: prog --foo""" $ prog --foo {"--foo": true} r"""Usage: prog --foo prog --bar NOT PART OF SECTION""" $ prog --foo {"--foo": true, "--bar": false} r"""Usage: prog --foo prog --bar NOT PART OF SECTION""" $ prog --foo {"--foo": true, "--bar": false} r"""Usage: prog --foo prog --bar NOT PART OF SECTION""" $ prog --foo {"--foo": true, "--bar": false} # # Options-section syntax # r"""Usage: prog [options] global options: --foo local options: --baz --bar other options: --egg --spam -not-an-option- """ $ prog --bar --egg {"--bar": true, "--egg": true, "--spam": false} r"""Usage: prog [-a] [--] [...]""" $ program -a {"-a": true, "": []} r"""Usage: prog [-a] [--] [...]""" $ program -- {"-a": false, "": []} r"""Usage: prog [-a] [--] [...]""" $ program -a -- -b {"-a": true, "": ["-b"]} r"""Usage: prog [-a] [--] [...]""" $ program -a -- -a {"-a": true, "": ["-a"]} r"""Usage: prog [-a] [--] [...]""" $ program -- -a {"-a": false, "": ["-a"]} r"""Usage: prog test [options] [--] [...]""" $ program test a -- -b {"": ["a", "-b"]} r"""Usage: prog test [options] [--] [...]""" $ program test -- -b {"": ["-b"]} r"""Usage: prog test [options] [--] [...]""" $ program test a -b "user-error" r"""Usage: prog test [options] [--] [...]""" $ program test -- -b -- {"": ["-b", "--"]} r"""Usage: prog [options] Options: -a ... Foo """ $ program {"-a": 0} $ program -a {"-a": 1} $ program -a -a {"-a": 2} $ program -aa {"-a": 2} $ program -a -a -a {"-a": 3} $ program -aaa {"-a": 3} r"""Usage: prog [options] Options: -a, --all ... Foo """ $ program {"-a": 0} $ program -a {"-a": 1} $ program -a --all {"-a": 2} $ program -aa --all {"-a": 3} $ program --all {"-a": 1} $ program --all --all {"-a": 2} r"""Usage: prog [options] Options: -a, --all ARG ... Foo """ $ program {"-a": []} $ program -a 1 {"-a": ["1"]} $ program -a 2 --all 3 {"-a": ["2", "3"]} $ program -a4 -a5 --all 6 {"-a": ["4", "5", "6"]} $ program --all 7 {"-a": ["7"]} $ program --all 8 --all 9 {"-a": ["8", "9"]} r"""Usage: prog [options] Options: --all ... Foo """ $ program {"--all": 0} $ program --all {"--all": 1} $ program --all --all {"--all": 2} r"""Usage: prog [options] Options: --all=ARG ... Foo """ $ program {"--all": []} $ program --all 1 {"--all": ["1"]} $ program --all 2 --all 3 {"--all": ["2", "3"]} r"""Usage: prog [options] Options: --all ... Foo """ $ program --all --all "user-error" r"""Usage: prog [options] Options: --all ARG ... Foo """ $ program --all foo --all bar "user-error" deps/docopt-0.6.78/src/test/mod.rs0000644000175000001440000000523512570617740014746 0ustar usersuse std::collections::HashMap; use {Docopt, ArgvMap}; use Value::{self, Switch, Plain}; fn get_args(doc: &str, argv: &[&'static str]) -> ArgvMap { let dopt = match Docopt::new(doc) { Err(err) => panic!("Invalid usage: {}", err), Ok(dopt) => dopt, }; match dopt.argv(vec!["cmd"].iter().chain(argv.iter())).parse() { Err(err) => panic!("{}", err), Ok(vals) => vals, } } fn map_from_alist(alist: Vec<(&'static str, Value)>) -> HashMap { alist.into_iter().map(|(k, v)| (k.to_string(), v)).collect() } fn same_args(expected: &HashMap, got: &ArgvMap) { for (k, ve) in expected.iter() { match got.map.find(k) { None => panic!("EXPECTED has '{}' but GOT does not.", k), Some(vg) => { assert!(ve == vg, "{}: EXPECTED = '{:?}' != '{:?}' = GOT", k, ve, vg) } } } for (k, vg) in got.map.iter() { match got.map.find(k) { None => panic!("GOT has '{}' but EXPECTED does not.", k), Some(ve) => { assert!(vg == ve, "{}: GOT = '{:?}' != '{:?}' = EXPECTED", k, vg, ve) } } } } macro_rules! test_expect( ($name:ident, $doc:expr, $args:expr, $expected:expr) => ( #[test] fn $name() { let vals = get_args($doc, $args); let expected = map_from_alist($expected); same_args(&expected, &vals); } ); ); macro_rules! test_user_error( ($name:ident, $doc:expr, $args:expr) => ( #[test] #[should_panic] fn $name() { get_args($doc, $args); } ); ); test_expect!(test_issue_13, "Usage: prog file ", &["file", "file"], vec![("file", Switch(true)), ("", Plain(Some("file".to_string())))]); test_expect!(test_issue_129, "Usage: prog [options] Options: --foo ARG Foo foo.", &["--foo=a b"], vec![("--foo", Plain(Some("a b".into())))]); #[test] fn regression_issue_12() { const USAGE: &'static str = " Usage: whisper info whisper update whisper mark "; #[derive(RustcDecodable, Debug)] struct Args { arg_file: String, cmd_info: bool, cmd_update: bool, arg_timestamp: u64, arg_value: f64 } let dopt: Args = Docopt::new(USAGE).unwrap() .argv(&["whisper", "mark", "./p/blah", "100"]) .decode().unwrap(); assert_eq!(dopt.arg_timestamp, 0); } mod testcases; mod suggestions; deps/docopt-0.6.78/src/test/testcases.rs0000644000175000001440000007166712555551217016200 0ustar users// !!! ATTENTION !!! // This file is automatically generated by `scripts/mk-testcases`. // Please do not edit this file directly! use Value::{Switch, Counted, Plain, List}; use test::{get_args, map_from_alist, same_args}; test_expect!(test_0_testcases, "Usage: prog", &[], vec!()); test_user_error!(test_1_testcases, "Usage: prog", &["--xxx"]); test_expect!(test_2_testcases, "Usage: prog [options] Options: -a All.", &[], vec!(("-a", Switch(false)))); test_expect!(test_3_testcases, "Usage: prog [options] Options: -a All.", &["-a"], vec!(("-a", Switch(true)))); test_user_error!(test_4_testcases, "Usage: prog [options] Options: -a All.", &["-x"]); test_expect!(test_5_testcases, "Usage: prog [options] Options: --all All.", &[], vec!(("--all", Switch(false)))); test_expect!(test_6_testcases, "Usage: prog [options] Options: --all All.", &["--all"], vec!(("--all", Switch(true)))); test_user_error!(test_7_testcases, "Usage: prog [options] Options: --all All.", &["--xxx"]); test_expect!(test_8_testcases, "Usage: prog [options] Options: -v, --verbose Verbose.", &["--verbose"], vec!(("--verbose", Switch(true)))); test_user_error!(test_9_testcases, "Usage: prog [options] Options: -v, --verbose Verbose.", &["--ver"]); test_expect!(test_10_testcases, "Usage: prog [options] Options: -v, --verbose Verbose.", &["-v"], vec!(("--verbose", Switch(true)))); test_expect!(test_11_testcases, "Usage: prog [options] Options: -p PATH", &["-p", "home/"], vec!(("-p", Plain(Some("home/".to_string()))))); test_expect!(test_12_testcases, "Usage: prog [options] Options: -p PATH", &["-phome/"], vec!(("-p", Plain(Some("home/".to_string()))))); test_user_error!(test_13_testcases, "Usage: prog [options] Options: -p PATH", &["-p"]); test_expect!(test_14_testcases, "Usage: prog [options] Options: --path ", &["--path", "home/"], vec!(("--path", Plain(Some("home/".to_string()))))); test_expect!(test_15_testcases, "Usage: prog [options] Options: --path ", &["--path=home/"], vec!(("--path", Plain(Some("home/".to_string()))))); test_user_error!(test_16_testcases, "Usage: prog [options] Options: --path ", &["--pa", "home/"]); test_user_error!(test_17_testcases, "Usage: prog [options] Options: --path ", &["--pa=home/"]); test_user_error!(test_18_testcases, "Usage: prog [options] Options: --path ", &["--path"]); test_expect!(test_19_testcases, "Usage: prog [options] Options: -p PATH, --path= Path to files.", &["-proot"], vec!(("--path", Plain(Some("root".to_string()))))); test_expect!(test_20_testcases, "Usage: prog [options] Options: -p --path PATH Path to files.", &["-p", "root"], vec!(("--path", Plain(Some("root".to_string()))))); test_expect!(test_21_testcases, "Usage: prog [options] Options: -p --path PATH Path to files.", &["--path", "root"], vec!(("--path", Plain(Some("root".to_string()))))); test_expect!(test_22_testcases, "Usage: prog [options] Options: -p PATH Path to files [default: ./]", &[], vec!(("-p", Plain(Some("./".to_string()))))); test_expect!(test_23_testcases, "Usage: prog [options] Options: -p PATH Path to files [default: ./]", &["-phome"], vec!(("-p", Plain(Some("home".to_string()))))); test_expect!(test_24_testcases, "UsAgE: prog [options] OpTiOnS: --path= Path to files [dEfAuLt: /root]", &[], vec!(("--path", Plain(Some("/root".to_string()))))); test_expect!(test_25_testcases, "UsAgE: prog [options] OpTiOnS: --path= Path to files [dEfAuLt: /root]", &["--path=home"], vec!(("--path", Plain(Some("home".to_string()))))); test_expect!(test_26_testcases, "usage: prog [options] options: -a Add -r Remote -m Message", &["-a", "-r", "-m", "Hello"], vec!(("-m", Plain(Some("Hello".to_string()))), ("-a", Switch(true)), ("-r", Switch(true)))); test_expect!(test_27_testcases, "usage: prog [options] options: -a Add -r Remote -m Message", &["-armyourass"], vec!(("-m", Plain(Some("yourass".to_string()))), ("-a", Switch(true)), ("-r", Switch(true)))); test_expect!(test_28_testcases, "usage: prog [options] options: -a Add -r Remote -m Message", &["-a", "-r"], vec!(("-m", Plain(None)), ("-a", Switch(true)), ("-r", Switch(true)))); test_expect!(test_29_testcases, "Usage: prog [options] Options: --version --verbose", &["--version"], vec!(("--verbose", Switch(false)), ("--version", Switch(true)))); test_expect!(test_30_testcases, "Usage: prog [options] Options: --version --verbose", &["--verbose"], vec!(("--verbose", Switch(true)), ("--version", Switch(false)))); test_user_error!(test_31_testcases, "Usage: prog [options] Options: --version --verbose", &["--ver"]); test_user_error!(test_32_testcases, "Usage: prog [options] Options: --version --verbose", &["--verb"]); test_expect!(test_33_testcases, "usage: prog [-a -r -m ] options: -a Add -r Remote -m Message", &["-armyourass"], vec!(("-m", Plain(Some("yourass".to_string()))), ("-a", Switch(true)), ("-r", Switch(true)))); test_expect!(test_34_testcases, "usage: prog [-armMSG] options: -a Add -r Remote -m Message", &["-a", "-r", "-m", "Hello"], vec!(("-m", Plain(Some("Hello".to_string()))), ("-a", Switch(true)), ("-r", Switch(true)))); test_expect!(test_35_testcases, "usage: prog -a -b options: -a -b", &["-a", "-b"], vec!(("-a", Switch(true)), ("-b", Switch(true)))); test_expect!(test_36_testcases, "usage: prog -a -b options: -a -b", &["-b", "-a"], vec!(("-a", Switch(true)), ("-b", Switch(true)))); test_user_error!(test_37_testcases, "usage: prog -a -b options: -a -b", &["-a"]); test_user_error!(test_38_testcases, "usage: prog -a -b options: -a -b", &[]); test_expect!(test_39_testcases, "usage: prog (-a -b) options: -a -b", &["-a", "-b"], vec!(("-a", Switch(true)), ("-b", Switch(true)))); test_expect!(test_40_testcases, "usage: prog (-a -b) options: -a -b", &["-b", "-a"], vec!(("-a", Switch(true)), ("-b", Switch(true)))); test_user_error!(test_41_testcases, "usage: prog (-a -b) options: -a -b", &["-a"]); test_user_error!(test_42_testcases, "usage: prog (-a -b) options: -a -b", &[]); test_expect!(test_43_testcases, "usage: prog [-a] -b options: -a -b", &["-a", "-b"], vec!(("-a", Switch(true)), ("-b", Switch(true)))); test_expect!(test_44_testcases, "usage: prog [-a] -b options: -a -b", &["-b", "-a"], vec!(("-a", Switch(true)), ("-b", Switch(true)))); test_user_error!(test_45_testcases, "usage: prog [-a] -b options: -a -b", &["-a"]); test_expect!(test_46_testcases, "usage: prog [-a] -b options: -a -b", &["-b"], vec!(("-a", Switch(false)), ("-b", Switch(true)))); test_user_error!(test_47_testcases, "usage: prog [-a] -b options: -a -b", &[]); test_expect!(test_48_testcases, "usage: prog [(-a -b)] options: -a -b", &["-a", "-b"], vec!(("-a", Switch(true)), ("-b", Switch(true)))); test_expect!(test_49_testcases, "usage: prog [(-a -b)] options: -a -b", &["-b", "-a"], vec!(("-a", Switch(true)), ("-b", Switch(true)))); test_user_error!(test_50_testcases, "usage: prog [(-a -b)] options: -a -b", &["-a"]); test_user_error!(test_51_testcases, "usage: prog [(-a -b)] options: -a -b", &["-b"]); test_expect!(test_52_testcases, "usage: prog [(-a -b)] options: -a -b", &[], vec!(("-a", Switch(false)), ("-b", Switch(false)))); test_user_error!(test_53_testcases, "usage: prog (-a|-b) options: -a -b", &["-a", "-b"]); test_user_error!(test_54_testcases, "usage: prog (-a|-b) options: -a -b", &[]); test_expect!(test_55_testcases, "usage: prog (-a|-b) options: -a -b", &["-a"], vec!(("-a", Switch(true)), ("-b", Switch(false)))); test_expect!(test_56_testcases, "usage: prog (-a|-b) options: -a -b", &["-b"], vec!(("-a", Switch(false)), ("-b", Switch(true)))); test_user_error!(test_57_testcases, "usage: prog [ -a | -b ] options: -a -b", &["-a", "-b"]); test_expect!(test_58_testcases, "usage: prog [ -a | -b ] options: -a -b", &[], vec!(("-a", Switch(false)), ("-b", Switch(false)))); test_expect!(test_59_testcases, "usage: prog [ -a | -b ] options: -a -b", &["-a"], vec!(("-a", Switch(true)), ("-b", Switch(false)))); test_expect!(test_60_testcases, "usage: prog [ -a | -b ] options: -a -b", &["-b"], vec!(("-a", Switch(false)), ("-b", Switch(true)))); test_expect!(test_61_testcases, "usage: prog ", &["10"], vec!(("", Plain(Some("10".to_string()))))); test_user_error!(test_62_testcases, "usage: prog ", &["10", "20"]); test_user_error!(test_63_testcases, "usage: prog ", &[]); test_expect!(test_64_testcases, "usage: prog []", &["10"], vec!(("", Plain(Some("10".to_string()))))); test_user_error!(test_65_testcases, "usage: prog []", &["10", "20"]); test_expect!(test_66_testcases, "usage: prog []", &[], vec!(("", Plain(None)))); test_expect!(test_67_testcases, "usage: prog ", &["10", "20", "40"], vec!(("", Plain(Some("40".to_string()))), ("", Plain(Some("10".to_string()))), ("", Plain(Some("20".to_string()))))); test_user_error!(test_68_testcases, "usage: prog ", &["10", "20"]); test_user_error!(test_69_testcases, "usage: prog ", &[]); test_expect!(test_70_testcases, "usage: prog [ ]", &["10", "20", "40"], vec!(("", Plain(Some("40".to_string()))), ("", Plain(Some("10".to_string()))), ("", Plain(Some("20".to_string()))))); test_expect!(test_71_testcases, "usage: prog [ ]", &["10", "20"], vec!(("", Plain(None)), ("", Plain(Some("10".to_string()))), ("", Plain(Some("20".to_string()))))); test_user_error!(test_72_testcases, "usage: prog [ ]", &[]); test_user_error!(test_73_testcases, "usage: prog [ | ]", &["10", "20", "40"]); test_expect!(test_74_testcases, "usage: prog [ | ]", &["20", "40"], vec!(("", Plain(Some("40".to_string()))), ("", Plain(None)), ("", Plain(Some("20".to_string()))))); test_expect!(test_75_testcases, "usage: prog [ | ]", &[], vec!(("", Plain(None)), ("", Plain(None)), ("", Plain(None)))); test_expect!(test_76_testcases, "usage: prog ( --all | ) options: --all", &["10", "--all"], vec!(("--all", Switch(true)), ("", Plain(Some("10".to_string()))), ("", Plain(None)))); test_expect!(test_77_testcases, "usage: prog ( --all | ) options: --all", &["10"], vec!(("--all", Switch(false)), ("", Plain(None)), ("", Plain(Some("10".to_string()))))); test_user_error!(test_78_testcases, "usage: prog ( --all | ) options: --all", &[]); test_expect!(test_79_testcases, "usage: prog [ ]", &["10", "20"], vec!(("", List(vec!("10".to_string(), "20".to_string()))))); test_expect!(test_80_testcases, "usage: prog [ ]", &["10"], vec!(("", List(vec!("10".to_string()))))); test_expect!(test_81_testcases, "usage: prog [ ]", &[], vec!(("", List(vec!())))); test_expect!(test_82_testcases, "usage: prog [( )]", &["10", "20"], vec!(("", List(vec!("10".to_string(), "20".to_string()))))); test_user_error!(test_83_testcases, "usage: prog [( )]", &["10"]); test_expect!(test_84_testcases, "usage: prog [( )]", &[], vec!(("", List(vec!())))); test_expect!(test_85_testcases, "usage: prog NAME...", &["10", "20"], vec!(("NAME", List(vec!("10".to_string(), "20".to_string()))))); test_expect!(test_86_testcases, "usage: prog NAME...", &["10"], vec!(("NAME", List(vec!("10".to_string()))))); test_user_error!(test_87_testcases, "usage: prog NAME...", &[]); test_expect!(test_88_testcases, "usage: prog [NAME]...", &["10", "20"], vec!(("NAME", List(vec!("10".to_string(), "20".to_string()))))); test_expect!(test_89_testcases, "usage: prog [NAME]...", &["10"], vec!(("NAME", List(vec!("10".to_string()))))); test_expect!(test_90_testcases, "usage: prog [NAME]...", &[], vec!(("NAME", List(vec!())))); test_expect!(test_91_testcases, "usage: prog [NAME...]", &["10", "20"], vec!(("NAME", List(vec!("10".to_string(), "20".to_string()))))); test_expect!(test_92_testcases, "usage: prog [NAME...]", &["10"], vec!(("NAME", List(vec!("10".to_string()))))); test_expect!(test_93_testcases, "usage: prog [NAME...]", &[], vec!(("NAME", List(vec!())))); test_expect!(test_94_testcases, "usage: prog [NAME [NAME ...]]", &["10", "20"], vec!(("NAME", List(vec!("10".to_string(), "20".to_string()))))); test_expect!(test_95_testcases, "usage: prog [NAME [NAME ...]]", &["10"], vec!(("NAME", List(vec!("10".to_string()))))); test_expect!(test_96_testcases, "usage: prog [NAME [NAME ...]]", &[], vec!(("NAME", List(vec!())))); test_expect!(test_97_testcases, "usage: prog (NAME | --foo NAME) options: --foo", &["10"], vec!(("NAME", Plain(Some("10".to_string()))), ("--foo", Switch(false)))); test_expect!(test_98_testcases, "usage: prog (NAME | --foo NAME) options: --foo", &["--foo", "10"], vec!(("NAME", Plain(Some("10".to_string()))), ("--foo", Switch(true)))); test_user_error!(test_99_testcases, "usage: prog (NAME | --foo NAME) options: --foo", &["--foo=10"]); test_expect!(test_100_testcases, "usage: prog (NAME | --foo) [--bar | NAME] options: --foo options: --bar", &["10"], vec!(("--bar", Switch(false)), ("NAME", List(vec!("10".to_string()))), ("--foo", Switch(false)))); test_expect!(test_101_testcases, "usage: prog (NAME | --foo) [--bar | NAME] options: --foo options: --bar", &["10", "20"], vec!(("--bar", Switch(false)), ("NAME", List(vec!("10".to_string(), "20".to_string()))), ("--foo", Switch(false)))); test_expect!(test_102_testcases, "usage: prog (NAME | --foo) [--bar | NAME] options: --foo options: --bar", &["--foo", "--bar"], vec!(("--bar", Switch(true)), ("NAME", List(vec!())), ("--foo", Switch(true)))); test_expect!(test_103_testcases, "Naval Fate. Usage: prog ship new ... prog ship [] move [--speed=] prog ship shoot prog mine (set|remove) [--moored|--drifting] prog -h | --help prog --version Options: -h --help Show this screen. --version Show version. --speed= Speed in knots [default: 10]. --moored Mored (anchored) mine. --drifting Drifting mine.", &["ship", "Guardian", "move", "150", "300", "--speed=20"], vec!(("shoot", Switch(false)), ("--moored", Switch(false)), ("--drifting", Switch(false)), ("move", Switch(true)), ("--speed", Plain(Some("20".to_string()))), ("mine", Switch(false)), ("new", Switch(false)), ("--version", Switch(false)), ("set", Switch(false)), ("remove", Switch(false)), ("", List(vec!("Guardian".to_string()))), ("ship", Switch(true)), ("", Plain(Some("150".to_string()))), ("", Plain(Some("300".to_string()))), ("--help", Switch(false)))); test_expect!(test_104_testcases, "usage: prog --hello", &["--hello"], vec!(("--hello", Switch(true)))); test_expect!(test_105_testcases, "usage: prog [--hello=]", &[], vec!(("--hello", Plain(None)))); test_expect!(test_106_testcases, "usage: prog [--hello=]", &["--hello", "wrld"], vec!(("--hello", Plain(Some("wrld".to_string()))))); test_expect!(test_107_testcases, "usage: prog [-o]", &[], vec!(("-o", Switch(false)))); test_expect!(test_108_testcases, "usage: prog [-o]", &["-o"], vec!(("-o", Switch(true)))); test_expect!(test_109_testcases, "usage: prog [-opr]", &["-op"], vec!(("-o", Switch(true)), ("-p", Switch(true)), ("-r", Switch(false)))); test_expect!(test_110_testcases, "usage: prog --aabb | --aa", &["--aa"], vec!(("--aa", Switch(true)), ("--aabb", Switch(false)))); test_user_error!(test_111_testcases, "usage: prog --aabb | --aa", &["--a"]); test_expect!(test_112_testcases, "Usage: prog -v", &["-v"], vec!(("-v", Switch(true)))); test_expect!(test_113_testcases, "Usage: prog [-v -v]", &[], vec!(("-v", Counted(0)))); test_expect!(test_114_testcases, "Usage: prog [-v -v]", &["-v"], vec!(("-v", Counted(1)))); test_expect!(test_115_testcases, "Usage: prog [-v -v]", &["-vv"], vec!(("-v", Counted(2)))); test_user_error!(test_116_testcases, "Usage: prog -v ...", &[]); test_expect!(test_117_testcases, "Usage: prog -v ...", &["-v"], vec!(("-v", Counted(1)))); test_expect!(test_118_testcases, "Usage: prog -v ...", &["-vv"], vec!(("-v", Counted(2)))); test_expect!(test_119_testcases, "Usage: prog -v ...", &["-vvvvvv"], vec!(("-v", Counted(6)))); test_expect!(test_120_testcases, "Usage: prog [-v | -vv | -vvv] This one is probably most readable user-friednly variant.", &[], vec!(("-v", Counted(0)))); test_expect!(test_121_testcases, "Usage: prog [-v | -vv | -vvv] This one is probably most readable user-friednly variant.", &["-v"], vec!(("-v", Counted(1)))); test_expect!(test_122_testcases, "Usage: prog [-v | -vv | -vvv] This one is probably most readable user-friednly variant.", &["-vv"], vec!(("-v", Counted(2)))); test_user_error!(test_123_testcases, "Usage: prog [-v | -vv | -vvv] This one is probably most readable user-friednly variant.", &["-vvvv"]); test_expect!(test_124_testcases, "usage: prog [--ver --ver]", &["--ver", "--ver"], vec!(("--ver", Counted(2)))); test_expect!(test_125_testcases, "usage: prog [go]", &["go"], vec!(("go", Switch(true)))); test_expect!(test_126_testcases, "usage: prog [go go]", &[], vec!(("go", Counted(0)))); test_expect!(test_127_testcases, "usage: prog [go go]", &["go"], vec!(("go", Counted(1)))); test_expect!(test_128_testcases, "usage: prog [go go]", &["go", "go"], vec!(("go", Counted(2)))); test_user_error!(test_129_testcases, "usage: prog [go go]", &["go", "go", "go"]); test_expect!(test_130_testcases, "usage: prog go...", &["go", "go", "go", "go", "go"], vec!(("go", Counted(5)))); test_expect!(test_131_testcases, "usage: prog [options] [-a] options: -a -b", &["-a"], vec!(("-a", Switch(true)), ("-b", Switch(false)))); test_user_error!(test_132_testcases, "usage: prog [options] [-a] options: -a -b", &["-aa"]); test_expect!(test_133_testcases, "Usage: prog [options] A Options: -q Be quiet -v Be verbose.", &["arg"], vec!(("A", Plain(Some("arg".to_string()))), ("-v", Switch(false)), ("-q", Switch(false)))); test_expect!(test_134_testcases, "Usage: prog [options] A Options: -q Be quiet -v Be verbose.", &["-v", "arg"], vec!(("A", Plain(Some("arg".to_string()))), ("-v", Switch(true)), ("-q", Switch(false)))); test_expect!(test_135_testcases, "Usage: prog [options] A Options: -q Be quiet -v Be verbose.", &["-q", "arg"], vec!(("A", Plain(Some("arg".to_string()))), ("-v", Switch(false)), ("-q", Switch(true)))); test_expect!(test_136_testcases, "usage: prog [-]", &["-"], vec!(("-", Switch(true)))); test_expect!(test_137_testcases, "usage: prog [-]", &[], vec!(("-", Switch(false)))); test_expect!(test_138_testcases, "usage: prog [NAME [NAME ...]]", &["a", "b"], vec!(("NAME", List(vec!("a".to_string(), "b".to_string()))))); test_expect!(test_139_testcases, "usage: prog [NAME [NAME ...]]", &[], vec!(("NAME", List(vec!())))); test_expect!(test_140_testcases, "usage: prog [options] options: -a Add -m Message", &["-a"], vec!(("-m", Plain(None)), ("-a", Switch(true)))); test_expect!(test_141_testcases, "usage: prog --hello", &["--hello"], vec!(("--hello", Switch(true)))); test_expect!(test_142_testcases, "usage: prog [--hello=]", &[], vec!(("--hello", Plain(None)))); test_expect!(test_143_testcases, "usage: prog [--hello=]", &["--hello", "wrld"], vec!(("--hello", Plain(Some("wrld".to_string()))))); test_expect!(test_144_testcases, "usage: prog [-o]", &[], vec!(("-o", Switch(false)))); test_expect!(test_145_testcases, "usage: prog [-o]", &["-o"], vec!(("-o", Switch(true)))); test_expect!(test_146_testcases, "usage: prog [-opr]", &["-op"], vec!(("-o", Switch(true)), ("-p", Switch(true)), ("-r", Switch(false)))); test_expect!(test_147_testcases, "usage: git [-v | --verbose]", &["-v"], vec!(("-v", Switch(true)), ("--verbose", Switch(false)))); test_expect!(test_148_testcases, "usage: git remote [-v | --verbose]", &["remote", "-v"], vec!(("-v", Switch(true)), ("remote", Switch(true)), ("--verbose", Switch(false)))); test_expect!(test_149_testcases, "usage: prog", &[], vec!()); test_expect!(test_150_testcases, "usage: prog prog ", &["1", "2"], vec!(("", Plain(Some("1".to_string()))), ("", Plain(Some("2".to_string()))))); test_expect!(test_151_testcases, "usage: prog prog ", &[], vec!(("", Plain(None)), ("", Plain(None)))); test_expect!(test_152_testcases, "usage: prog prog", &[], vec!(("", Plain(None)), ("", Plain(None)))); test_expect!(test_153_testcases, "usage: prog [--file=]", &[], vec!(("--file", Plain(None)))); test_expect!(test_154_testcases, "usage: prog [--file=] options: --file ", &[], vec!(("--file", Plain(None)))); test_expect!(test_155_testcases, "Usage: prog [-a ] Options: -a, --address TCP address [default: localhost:6283].", &[], vec!(("--address", Plain(Some("localhost:6283".to_string()))))); test_expect!(test_156_testcases, "usage: prog --long= ...", &["--long", "one"], vec!(("--long", List(vec!("one".to_string()))))); test_expect!(test_157_testcases, "usage: prog --long= ...", &["--long", "one", "--long", "two"], vec!(("--long", List(vec!("one".to_string(), "two".to_string()))))); test_expect!(test_158_testcases, "usage: prog (go --speed=)...", &["go", "left", "--speed=5", "go", "right", "--speed=9"], vec!(("go", Counted(2)), ("", List(vec!("left".to_string(), "right".to_string()))), ("--speed", List(vec!("5".to_string(), "9".to_string()))))); test_expect!(test_159_testcases, "usage: prog [options] -a options: -a", &["-a"], vec!(("-a", Switch(true)))); test_expect!(test_160_testcases, "usage: prog [-o ]... options: -o [default: x]", &["-o", "this", "-o", "that"], vec!(("-o", List(vec!("this".to_string(), "that".to_string()))))); test_expect!(test_161_testcases, "usage: prog [-o ]... options: -o [default: x]", &[], vec!(("-o", List(vec!("x".to_string()))))); test_expect!(test_162_testcases, "usage: prog [-o ]... options: -o [default: x y]", &["-o", "this"], vec!(("-o", List(vec!("this".to_string()))))); test_expect!(test_163_testcases, "usage: prog [-o ]... options: -o [default: x y]", &[], vec!(("-o", List(vec!("x".to_string(), "y".to_string()))))); test_expect!(test_164_testcases, "usage: prog -pPATH options: -p PATH", &["-pHOME"], vec!(("-p", Plain(Some("HOME".to_string()))))); test_expect!(test_165_testcases, "Usage: foo (--xx=X|--yy=Y)...", &["--xx=1", "--yy=2"], vec!(("--yy", List(vec!("2".to_string()))), ("--xx", List(vec!("1".to_string()))))); test_expect!(test_166_testcases, "usage: prog []", &["f.txt"], vec!(("", Plain(Some("f.txt".to_string()))))); test_expect!(test_167_testcases, "usage: prog [--input=]...", &["--input", "a.txt", "--input=b.txt"], vec!(("--input", List(vec!("a.txt".to_string(), "b.txt".to_string()))))); test_expect!(test_168_testcases, "usage: prog good [options] prog fail [options] options: --loglevel=N", &["fail", "--loglevel", "5"], vec!(("fail", Switch(true)), ("good", Switch(false)), ("--loglevel", Plain(Some("5".to_string()))))); test_expect!(test_169_testcases, "usage:prog --foo", &["--foo"], vec!(("--foo", Switch(true)))); test_expect!(test_170_testcases, "PROGRAM USAGE: prog --foo", &["--foo"], vec!(("--foo", Switch(true)))); test_expect!(test_171_testcases, "Usage: prog --foo prog --bar NOT PART OF SECTION", &["--foo"], vec!(("--bar", Switch(false)), ("--foo", Switch(true)))); test_expect!(test_172_testcases, "Usage: prog --foo prog --bar NOT PART OF SECTION", &["--foo"], vec!(("--bar", Switch(false)), ("--foo", Switch(true)))); test_expect!(test_173_testcases, "Usage: prog --foo prog --bar NOT PART OF SECTION", &["--foo"], vec!(("--bar", Switch(false)), ("--foo", Switch(true)))); test_expect!(test_174_testcases, "Usage: prog [options] global options: --foo local options: --baz --bar other options: --egg --spam -not-an-option-", &["--bar", "--egg"], vec!(("--bar", Switch(true)), ("--egg", Switch(true)), ("--spam", Switch(false)))); test_expect!(test_175_testcases, "Usage: prog [-a] [--] [...]", &["-a"], vec!(("", List(vec!())), ("-a", Switch(true)))); test_expect!(test_176_testcases, "Usage: prog [-a] [--] [...]", &["--"], vec!(("", List(vec!())), ("-a", Switch(false)))); test_expect!(test_177_testcases, "Usage: prog [-a] [--] [...]", &["-a", "--", "-b"], vec!(("", List(vec!("-b".to_string()))), ("-a", Switch(true)))); test_expect!(test_178_testcases, "Usage: prog [-a] [--] [...]", &["-a", "--", "-a"], vec!(("", List(vec!("-a".to_string()))), ("-a", Switch(true)))); test_expect!(test_179_testcases, "Usage: prog [-a] [--] [...]", &["--", "-a"], vec!(("", List(vec!("-a".to_string()))), ("-a", Switch(false)))); test_expect!(test_180_testcases, "Usage: prog test [options] [--] [...]", &["test", "a", "--", "-b"], vec!(("", List(vec!("a".to_string(), "-b".to_string()))))); test_expect!(test_181_testcases, "Usage: prog test [options] [--] [...]", &["test", "--", "-b"], vec!(("", List(vec!("-b".to_string()))))); test_user_error!(test_182_testcases, "Usage: prog test [options] [--] [...]", &["test", "a", "-b"]); test_expect!(test_183_testcases, "Usage: prog test [options] [--] [...]", &["test", "--", "-b", "--"], vec!(("", List(vec!("-b".to_string(), "--".to_string()))))); test_expect!(test_184_testcases, "Usage: prog [options] Options: -a ... Foo", &[], vec!(("-a", Counted(0)))); test_expect!(test_185_testcases, "Usage: prog [options] Options: -a ... Foo", &["-a"], vec!(("-a", Counted(1)))); test_expect!(test_186_testcases, "Usage: prog [options] Options: -a ... Foo", &["-a", "-a"], vec!(("-a", Counted(2)))); test_expect!(test_187_testcases, "Usage: prog [options] Options: -a ... Foo", &["-aa"], vec!(("-a", Counted(2)))); test_expect!(test_188_testcases, "Usage: prog [options] Options: -a ... Foo", &["-a", "-a", "-a"], vec!(("-a", Counted(3)))); test_expect!(test_189_testcases, "Usage: prog [options] Options: -a ... Foo", &["-aaa"], vec!(("-a", Counted(3)))); test_expect!(test_190_testcases, "Usage: prog [options] Options: -a, --all ... Foo", &[], vec!(("-a", Counted(0)))); test_expect!(test_191_testcases, "Usage: prog [options] Options: -a, --all ... Foo", &["-a"], vec!(("-a", Counted(1)))); test_expect!(test_192_testcases, "Usage: prog [options] Options: -a, --all ... Foo", &["-a", "--all"], vec!(("-a", Counted(2)))); test_expect!(test_193_testcases, "Usage: prog [options] Options: -a, --all ... Foo", &["-aa", "--all"], vec!(("-a", Counted(3)))); test_expect!(test_194_testcases, "Usage: prog [options] Options: -a, --all ... Foo", &["--all"], vec!(("-a", Counted(1)))); test_expect!(test_195_testcases, "Usage: prog [options] Options: -a, --all ... Foo", &["--all", "--all"], vec!(("-a", Counted(2)))); test_expect!(test_196_testcases, "Usage: prog [options] Options: -a, --all ARG ... Foo", &[], vec!(("-a", List(vec!())))); test_expect!(test_197_testcases, "Usage: prog [options] Options: -a, --all ARG ... Foo", &["-a", "1"], vec!(("-a", List(vec!("1".to_string()))))); test_expect!(test_198_testcases, "Usage: prog [options] Options: -a, --all ARG ... Foo", &["-a", "2", "--all", "3"], vec!(("-a", List(vec!("2".to_string(), "3".to_string()))))); test_expect!(test_199_testcases, "Usage: prog [options] Options: -a, --all ARG ... Foo", &["-a4", "-a5", "--all", "6"], vec!(("-a", List(vec!("4".to_string(), "5".to_string(), "6".to_string()))))); test_expect!(test_200_testcases, "Usage: prog [options] Options: -a, --all ARG ... Foo", &["--all", "7"], vec!(("-a", List(vec!("7".to_string()))))); test_expect!(test_201_testcases, "Usage: prog [options] Options: -a, --all ARG ... Foo", &["--all", "8", "--all", "9"], vec!(("-a", List(vec!("8".to_string(), "9".to_string()))))); test_expect!(test_202_testcases, "Usage: prog [options] Options: --all ... Foo", &[], vec!(("--all", Counted(0)))); test_expect!(test_203_testcases, "Usage: prog [options] Options: --all ... Foo", &["--all"], vec!(("--all", Counted(1)))); test_expect!(test_204_testcases, "Usage: prog [options] Options: --all ... Foo", &["--all", "--all"], vec!(("--all", Counted(2)))); test_expect!(test_205_testcases, "Usage: prog [options] Options: --all=ARG ... Foo", &[], vec!(("--all", List(vec!())))); test_expect!(test_206_testcases, "Usage: prog [options] Options: --all=ARG ... Foo", &["--all", "1"], vec!(("--all", List(vec!("1".to_string()))))); test_expect!(test_207_testcases, "Usage: prog [options] Options: --all=ARG ... Foo", &["--all", "2", "--all", "3"], vec!(("--all", List(vec!("2".to_string(), "3".to_string()))))); test_user_error!(test_208_testcases, "Usage: prog [options] Options: --all ... Foo", &["--all", "--all"]); test_user_error!(test_209_testcases, "Usage: prog [options] Options: --all ARG ... Foo", &["--all", "foo", "--all", "bar"]); deps/docopt-0.6.78/src/synonym.rs0000644000175000001440000000520712504646100014710 0ustar usersuse std::collections::HashMap; use std::collections::hash_map::{Iter, Keys}; use std::fmt::Debug; use std::hash::Hash; use std::iter::{FromIterator, IntoIterator}; use std::mem; #[derive(Clone)] pub struct SynonymMap { vals: HashMap, syns: HashMap, } impl SynonymMap { pub fn new() -> SynonymMap { SynonymMap { vals: HashMap::new(), syns: HashMap::new(), } } pub fn insert_synonym(&mut self, from: K, to: K) -> bool { assert!(self.vals.contains_key(&to)); self.syns.insert(from, to).is_none() } pub fn keys<'a>(&'a self) -> Keys<'a, K, V> { self.vals.keys() } pub fn iter<'a>(&'a self) -> Iter<'a, K, V> { self.vals.iter() } pub fn synonyms<'a>(&'a self) -> Iter<'a, K, K> { self.syns.iter() } pub fn find<'a>(&'a self, k: &K) -> Option<&'a V> { self.with_key(k, |k| self.vals.get(k)) } pub fn contains_key(&self, k: &K) -> bool { self.with_key(k, |k| self.vals.contains_key(k)) } pub fn len(&self) -> usize { self.vals.len() } fn with_key(&self, k: &K, with: F) -> T where F: FnOnce(&K) -> T { if self.syns.contains_key(k) { with(&self.syns[k]) } else { with(k) } } } impl SynonymMap { pub fn resolve(&self, k: &K) -> K { self.with_key(k, |k| k.clone()) } pub fn get<'a>(&'a self, k: &K) -> &'a V { self.find(k).unwrap() } pub fn find_mut<'a>(&'a mut self, k: &K) -> Option<&'a mut V> { if self.syns.contains_key(k) { self.vals.get_mut(&self.syns[k]) } else { self.vals.get_mut(k) } } pub fn swap(&mut self, k: K, mut new: V) -> Option { if self.syns.contains_key(&k) { let old = self.vals.get_mut(&k).unwrap(); mem::swap(old, &mut new); Some(new) } else { self.vals.insert(k, new) } } pub fn insert(&mut self, k: K, v: V) -> bool { self.swap(k, v).is_none() } } impl FromIterator<(K, V)> for SynonymMap { fn from_iter>(iter: T) -> SynonymMap { let mut map = SynonymMap::new(); for (k, v) in iter { map.insert(k, v); } map } } impl Debug for SynonymMap { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { try!(self.vals.fmt(f)); write!(f, " (synomyns: {:?})", self.syns) } } deps/docopt-0.6.78/src/wordlist.rs0000644000175000001440000000612412570617740015055 0ustar usersextern crate regex; extern crate rustc_serialize; extern crate strsim; use std::collections::HashMap; use std::io::{self, Read, Write}; use dopt::Docopt; use parse::{Atom, Parser}; // cheat until we get syntax extensions back :-( macro_rules! regex( ($s:expr) => (::regex::Regex::new($s).unwrap()); ); macro_rules! werr( ($($arg:tt)*) => ({ use std::io::{Write, stderr}; write!(&mut stderr(), $($arg)*).unwrap(); }) ); #[allow(dead_code)] mod dopt; #[allow(dead_code)] mod parse; #[allow(dead_code)] mod synonym; const USAGE: &'static str = " Usage: docopt-wordlist [( )] ... docopt-wordlist prints a list of available flags and commands arguments for the given usage (provided on stdin). Example use: your-command --help | docopt-wordlist This command also supports completing positional arguments when given a list of choices. The choices are included in the word list if and only if the argument name appears in the usage string. For example: your-command --help | docopt-wordlist 'arg' 'a b c' Which will only include 'a', 'b' and 'c' in the wordlist if 'your-command --help' contains a positional argument named 'arg'. "; #[derive(Debug, RustcDecodable)] struct Args { arg_name: Vec, arg_possibles: Vec, } fn main() { let args: Args = Docopt::new(USAGE) .and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(args) { Ok(_) => {}, Err(err) => { write!(&mut io::stderr(), "{}", err).unwrap(); ::std::process::exit(1) } } } fn run(args: Args) -> Result<(), String> { let mut usage = String::new(); try!(io::stdin().read_to_string(&mut usage).map_err(|e| e.to_string())); let parsed = try!(Parser::new(&usage).map_err(|e| e.to_string())); let arg_possibles: HashMap> = args.arg_name.iter() .zip(args.arg_possibles.iter()) .map(|(name, possibles)| { let choices = regex!(r"[ \t]+").split(&**possibles) .map(|s| s.to_string()) .collect::>(); (name.clone(), choices) }) .collect(); let mut words = vec![]; for k in parsed.descs.keys() { if let Atom::Positional(ref arg_name) = *k { if let Some(choices) = arg_possibles.get(arg_name) { words.extend(choices.iter().map(|s| s.clone())); } // If the user hasn't given choices for this positional argument, // then there's really nothing to complete here. } else { words.push(k.to_string()); } } for (k, _) in parsed.descs.synonyms() { // We don't need to do anything special here since synonyms can // only be flags, which we always include in the wordlist. words.push(k.to_string()); } println!("{}", words.connect(" ")); Ok(()) } deps/docopt-0.6.78/session.vim0000644000175000001440000000023512353432044014235 0ustar usersau BufWritePost *.rs silent!make ctags > /dev/null 2>&1 " let g:syntastic_rust_rustc_fname = "src/lib.rs" " let g:syntastic_rust_rustc_args = "--no-trans" deps/docopt-0.6.78/scripts/0000755000000000000000000000000012666635520014237 5ustar rootrootdeps/docopt-0.6.78/scripts/mk-testcases0000755000175000001440000000526512445324046016071 0ustar users#!/usr/bin/env python2 from __future__ import absolute_import, division, print_function import argparse import json import re retests = re.compile('(.*?)"""(.*?)(r"""|\s*$)', re.DOTALL) reinvokes = re.compile('(.+?$)(.+?)\s*(\$|\Z)', re.DOTALL | re.MULTILINE) p = argparse.ArgumentParser( description="Outputs src/test/testcases.rs to stdout") p.add_argument("testcases", metavar="FILE", help="The testcases.docopt language agnostic test suite.") args = p.parse_args() with open(args.testcases) as f: alltests = f.read() alltests = re.sub('^r"""', '', alltests) alltests = re.sub('^\s*#.*$', '', alltests, flags=re.MULTILINE) tests = [] # [{usage, args, expect}] (expect is None ==> user-error) for m in retests.finditer(alltests): usage, invokes = m.group(1).strip(), m.group(2).strip() assert invokes.startswith('$'), 'Bad test: "%s"' % invokes invokes = re.sub('^\$', '', invokes) for mi in reinvokes.finditer(invokes): invoke, expect = mi.group(1).strip(), mi.group(2).strip() err = expect.startswith('"user-error"') tests.append({ 'usage': usage, 'args': invoke.split()[1:], 'expect': None if err else json.loads(expect), }) def show_test(i, t): def show_expect(e): kvs = [] for k, v in e.iteritems(): kvs.append('("%s", %s)' % (k, show_value(v))) return ', '.join(kvs) def show_value(v): if v is None: return 'Plain(None)' elif isinstance(v, basestring): return 'Plain(Some("%s".to_string()))' % v elif isinstance(v, bool): return 'Switch(%s)' % ('true' if v else 'false') elif isinstance(v, int): return 'Counted(%d)' % v elif isinstance(v, list): elms = ', '.join(['"%s".to_string()' % el for el in v]) return 'List(vec!(%s))' % elms else: raise ValueError('Unrecognized value: "%s" (type: %s)' % (v, type(v))) args = ', '.join(['"%s"' % arg for arg in t['args']]) if t['expect'] is None: return 'test_user_error!(test_%d_testcases, "%s", &[%s]);' \ % (i, t['usage'], args) else: expect = show_expect(t['expect']) return 'test_expect!(test_%d_testcases, "%s", &[%s], vec!(%s));' \ % (i, t['usage'], args, expect) print( """// !!! ATTENTION !!! // This file is automatically generated by `scripts/mk-testcases`. // Please do not edit this file directly! use Value::{{Switch, Counted, Plain, List}}; use test::{{get_args, map_from_alist, same_args}}; {tests} """.format(tests='\n\n'.join([show_test(i, t) for i, t in enumerate(tests)]))) deps/docopt-0.6.78/completions/0000755000000000000000000000000012666635520015104 5ustar rootrootdeps/docopt-0.6.78/completions/docopt-wordlist.bash0000644000175000001440000000476412437476471020417 0ustar users# This is your basic tab completion that will work well with commands that # have only one usage (i.e., no distinct sub-commands). # # Completion works by simply taking the command name and running `$cmd --help` # to get the usage (which is then parsed for possible completions). function _docopt_wordlist { if [ -z "$DOCOPT_WORDLIST_BIN" ]; then DOCOPT_WORDLIST_BIN=/usr/local/bin/docopt-wordlist fi cword=$(_get_cword) cmd="${COMP_WORDS[0]}" wordlist=$("$cmd" --help 2>&1 | "$DOCOPT_WORDLIST_BIN") gen "$cword" "$wordlist" } # This is a fancier version of the above that supports commands that have # multiple sub-commands (i.e., distinct usages like Cargo). # # This supports sub-command completion only if `$cmd --list` shows a list of # available sub-commands. # # Otherwise, the usage for the command `a b c d` is taken from the first # command that exits successfully: # # a b c d --help # a b c --help # a b --help # a --help # # So for example, if you've typed `cargo test --jo`, then the following # happens: # # cargo test --jo --help # error # cargo test --help # gives 'test' sub-command usage! # # As a special case, if only the initial command has been typed, then the # sub-commands (taken from `$cmd --list`) are added to the wordlist. function _docopt_wordlist_commands { if [ -z "$DOCOPT_WORDLIST_BIN" ]; then DOCOPT_WORDLIST_BIN=/usr/local/bin/docopt-wordlist fi cword=$(_get_cword) if [ "$COMP_CWORD" = 1 ]; then cmd="${COMP_WORDS[0]}" wordlist=$("$cmd" --help 2>&1 | "$DOCOPT_WORDLIST_BIN") wordlist+=" $("$cmd" --list | egrep '^ +\w' | awk '{print $1}')" gen "$cword" "$wordlist" else for ((i="$COMP_CWORD"; i >= 1; i++)); do cmd="${COMP_WORDS[@]::$i}" wordlist=$($cmd --help 2>&1 | "$DOCOPT_WORDLIST_BIN") if [ $? = 0 ]; then gen "$cword" "$wordlist" break fi done fi } # A helper function for running `compgen`, which is responsible for taking # a prefix and presenting possible completions. # # If the current prefix starts with a `.` or a `/`, then file/directory # completion is done. Otherwise, Docopt completion is done. If Docopt # completion is empty, then it falls back to file/directory completion. function gen { cword="$1" wordlist="$2" if [[ "$cword" = .* || "$cword" = /* ]]; then COMPREPLY=($(compgen -A file -- "$cword")) else COMPREPLY=($(compgen -W "$wordlist" -- "$cword")) if [ -z "$COMPREPLY" ]; then COMPREPLY=($(compgen -A file -- "$cword")) fi fi } deps/docopt-0.6.78/Cargo.toml0000644000175000001440000000111012627144256013767 0ustar users[package] name = "docopt" version = "0.6.78" #:version authors = ["Andrew Gallant "] description = "Command line argument parsing." documentation = "http://burntsushi.net/rustdoc/docopt/" homepage = "https://github.com/docopt/docopt.rs" repository = "https://github.com/docopt/docopt.rs" readme = "README.md" keywords = ["docopt", "argument", "command", "argv"] license = "Unlicense/MIT" [lib] name = "docopt" [[bin]] name = "docopt-wordlist" path = "src/wordlist.rs" doc = false test = false [dependencies] regex = "0.1" rustc-serialize = "0.3" strsim = "0.3" deps/docopt-0.6.78/Makefile0000644000175000001440000000066612533425144013510 0ustar usersall: @echo Nothing to do docs: $(LIB_FILES) cargo doc # WTF is rustdoc doing? in-dir ./target/doc fix-perms rscp ./target/doc/* gopher:~/www/burntsushi.net/rustdoc/ src/test/testcases.rs: src/test/testcases.docopt scripts/mk-testcases ./scripts/mk-testcases ./src/test/testcases.docopt > ./src/test/testcases.rs ctags: ctags --recurse --options=ctags.rust --languages=Rust push: git push github master git push origin master deps/docopt-0.6.78/COPYING0000644000175000001440000000017612513562722013101 0ustar usersThis project is dual-licensed under the Unlicense and MIT licenses. You may use this code under the terms of either license. deps/pkg-config-0.3.6/0000755000000000000000000000000012666635520013210 5ustar rootrootdeps/pkg-config-0.3.6/LICENSE-APACHE0000664000175000017500000002513712425062731013357 0ustar Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/pkg-config-0.3.6/LICENSE-MIT0000664000175000017500000000204112425062731013054 0ustar Copyright (c) 2014 Alex Crichton Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/pkg-config-0.3.6/.travis.yml0000664000175000017500000000146212525500255013536 0ustar language: rust rust: - 1.0.0 - beta - nightly sudo: false script: - cargo build --verbose - | [ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose - cargo doc after_success: | [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && [ $TRAVIS_RUST_VERSION = nightly ] && echo '' > target/doc/index.html && pip install ghp-import --user $USER && $HOME/.local/bin/ghp-import -n target/doc && git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages env: global: secure: XlfwiQ+fPgRWqFwHbyPTma2FAVtgN+IXFpkiIdh1sKxWEeHMqABrTtOKf/NugDYCGsOJfr2vb5qFL6teBV2lTXOffUIWj+1hMd0N/FbVKWzABBV02XdxQi8w2ptPez5LPRTEfXJRRHmJpc8ww2aCTIrdT3AQE2oqZM/jHJTi/1U= notifications: email: on_success: never deps/pkg-config-0.3.6/README.md0000664000175000017500000000131712510027741012701 0ustar # pkg-config-rs [![Build Status](https://travis-ci.org/alexcrichton/pkg-config-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/pkg-config-rs) [Documentation](http://alexcrichton.com/pkg-config-rs) A simple library meant to be used as a build dependency with Cargo packages in order to use the system `pkg-config` tool (if available) to determine where a library is located. ```rust extern crate pkg_config; fn main() { pkg_config::find_library("foo").unwrap(); } ``` # License `pkg-config-rs` is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses. See LICENSE-APACHE, and LICENSE-MIT for details. deps/pkg-config-0.3.6/.gitignore0000600000175000017500000000002412425062630013373 0ustar /target /Cargo.lock deps/pkg-config-0.3.6/src/0000755000000000000000000000000012666635520013777 5ustar rootrootdeps/pkg-config-0.3.6/src/lib.rs0000664000175000017500000002277012604531750013337 0ustar //! A build dependency for Cargo libraries to find system artifacts through the //! `pkg-config` utility. //! //! This library will shell out to `pkg-config` as part of build scripts and //! probe the system to determine how to link to a specified library. The //! `Config` structure serves as a method of configuring how `pkg-config` is //! invoked in a builder style. //! //! A number of environment variables are available to globally configure how //! this crate will invoke `pkg-config`: //! //! * `PKG_CONFIG_ALLOW_CROSS` - if this variable is not set, then `pkg-config` //! will automatically be disabled for all cross compiles. //! * `FOO_NO_PKG_CONFIG` - if set, this will disable running `pkg-config` when //! probing for the library named `foo`. //! //! There are also a number of environment variables which can configure how a //! library is linked to (dynamically vs statically). These variables control //! whether the `--static` flag is passed. Note that this behavior can be //! overridden by configuring explicitly on `Config`. The variables are checked //! in the following order: //! //! * `FOO_STATIC` - pass `--static` for the library `foo` //! * `FOO_DYNAMIC` - do not pass `--static` for the library `foo` //! * `PKG_CONFIG_ALL_STATIC` - pass `--static` for all libraries //! * `PKG_CONFIG_ALL_DYNAMIC` - do not pass `--static` for all libraries //! //! After running `pkg-config` all appropriate Cargo metadata will be printed on //! stdout if the search was successful. //! //! # Example //! //! Find the system library named `foo`. //! //! ```no_run //! extern crate pkg_config; //! //! fn main() { //! pkg_config::find_library("foo").unwrap(); //! } //! ``` //! //! Configure how library `foo` is linked to. //! //! ```no_run //! extern crate pkg_config; //! //! fn main() { //! pkg_config::Config::new().statik(true).find("foo").unwrap(); //! } //! ``` #![doc(html_root_url = "http://alexcrichton.com/pkg-config-rs")] #![cfg_attr(test, deny(warnings))] use std::ascii::AsciiExt; use std::env; use std::ffi::{OsStr, OsString}; use std::fs; use std::path::{PathBuf, Path}; use std::process::Command; use std::str; pub fn target_supported() -> bool { let target = env::var("TARGET").unwrap_or(String::new()); let host = env::var("HOST").unwrap_or(String::new()); // Only use pkg-config in host == target situations by default (allowing an // override) and then also don't use pkg-config on MSVC as it's really not // meant to work there but when building MSVC code in a MSYS shell we may be // able to run pkg-config anyway. (host == target || env::var_os("PKG_CONFIG_ALLOW_CROSS").is_some()) && !target.contains("msvc") } #[derive(Clone)] pub struct Config { statik: Option, atleast_version: Option, extra_args: Vec, } #[derive(Debug)] pub struct Library { pub libs: Vec, pub link_paths: Vec, pub frameworks: Vec, pub framework_paths: Vec, pub include_paths: Vec, pub version: String, _priv: (), } /// Simple shortcut for using all default options for finding a library. pub fn find_library(name: &str) -> Result { Config::new().find(name) } impl Config { /// Creates a new set of configuration options which are all initially set /// to "blank". pub fn new() -> Config { Config { statik: None, atleast_version: None, extra_args: vec![], } } /// Indicate whether the `--static` flag should be passed. /// /// This will override the inference from environment variables described in /// the crate documentation. pub fn statik(&mut self, statik: bool) -> &mut Config { self.statik = Some(statik); self } /// Indicate that the library must be at least version `vers`. pub fn atleast_version(&mut self, vers: &str) -> &mut Config { self.atleast_version = Some(vers.to_string()); self } /// Add an argument to pass to pkg-config. /// /// It's placed after all of the arguments generated by this library. pub fn arg>(&mut self, arg: S) -> &mut Config { self.extra_args.push(arg.as_ref().to_os_string()); self } /// Run `pkg-config` to find the library `name`. /// /// This will use all configuration previously set to specify how /// `pkg-config` is run. pub fn find(&self, name: &str) -> Result { if env::var_os(&format!("{}_NO_PKG_CONFIG", envify(name))).is_some() { return Err(format!("pkg-config requested to be aborted for {}", name)) } else if !target_supported() { return Err("pkg-config doesn't handle cross compilation. Use \ PKG_CONFIG_ALLOW_CROSS=1 to override".to_string()); } let mut library = Library::new(); let output = try!(run(self.command(name, &["--libs", "--cflags"]))); library.parse_libs_cflags(name, &output, self); let output = try!(run(self.command(name, &["--modversion"]))); library.parse_modversion(&output); Ok(library) } /// Run `pkg-config` to get the value of a variable from a package using /// --variable. pub fn get_variable(package: &str, variable: &str) -> Result { let arg = format!("--variable={}", variable); let cfg = Config::new(); Ok(try!(run(cfg.command(package, &[&arg]))).trim_right().to_owned()) } fn is_static(&self, name: &str) -> bool { self.statik.unwrap_or_else(|| infer_static(name)) } fn command(&self, name: &str, args: &[&str]) -> Command { let mut cmd = Command::new("pkg-config"); if self.is_static(name) { cmd.arg("--static"); } cmd.args(args) .args(&self.extra_args) .env("PKG_CONFIG_ALLOW_SYSTEM_LIBS", "1"); if let Some(ref version) = self.atleast_version { cmd.arg(&format!("{} >= {}", name, version)); } else { cmd.arg(name); } cmd } } impl Library { fn new() -> Library { Library { libs: Vec::new(), link_paths: Vec::new(), include_paths: Vec::new(), frameworks: Vec::new(), framework_paths: Vec::new(), version: String::new(), _priv: (), } } fn parse_libs_cflags(&mut self, name: &str, output: &str, config: &Config) { let parts = output.split(' ') .filter(|l| l.len() > 2) .map(|arg| (&arg[0..2], &arg[2..])) .collect::>(); let mut dirs = Vec::new(); let statik = config.is_static(name); for &(flag, val) in parts.iter() { match flag { "-L" => { println!("cargo:rustc-link-search=native={}", val); dirs.push(PathBuf::from(val)); self.link_paths.push(PathBuf::from(val)); } "-F" => { println!("cargo:rustc-link-search=framework={}", val); self.framework_paths.push(PathBuf::from(val)); } "-I" => { self.include_paths.push(PathBuf::from(val)); } "-l" => { self.libs.push(val.to_string()); if statik && !is_system(val, &dirs) { println!("cargo:rustc-link-lib=static={}", val); } else { println!("cargo:rustc-link-lib={}", val); } } _ => {} } } let mut iter = output.split(' '); while let Some(part) = iter.next() { if part != "-framework" { continue } if let Some(lib) = iter.next() { println!("cargo:rustc-link-lib=framework={}", lib); self.frameworks.push(lib.to_string()); } } } fn parse_modversion(&mut self, output: &str) { self.version.push_str(output.trim()); } } fn infer_static(name: &str) -> bool { let name = envify(name); if env::var_os(&format!("{}_STATIC", name)).is_some() { true } else if env::var_os(&format!("{}_DYNAMIC", name)).is_some() { false } else if env::var_os("PKG_CONFIG_ALL_STATIC").is_some() { true } else if env::var_os("PKG_CONFIG_ALL_DYNAMIC").is_some() { false } else { false } } fn envify(name: &str) -> String { name.chars().map(|c| c.to_ascii_uppercase()).map(|c| { if c == '-' {'_'} else {c} }).collect() } fn is_system(name: &str, dirs: &[PathBuf]) -> bool { let libname = format!("lib{}.a", name); let root = Path::new("/usr"); !dirs.iter().any(|d| { !d.starts_with(root) && fs::metadata(&d.join(&libname)).is_ok() }) } fn run(mut cmd: Command) -> Result { let out = try!(cmd.output().map_err(|e| { format!("failed to run `{:?}`: {}", cmd, e) })); let stdout = String::from_utf8(out.stdout).unwrap(); if out.status.success() { return Ok(stdout); } let stderr = str::from_utf8(&out.stderr).unwrap(); let mut msg = format!("`{:?}` did not exit successfully: {}", cmd, out.status); if stdout.len() > 0 { msg.push_str("\n--- stdout\n"); msg.push_str(&stdout); } if stderr.len() > 0 { msg.push_str("\n--- stderr\n"); msg.push_str(stderr); } return Err(msg); } deps/pkg-config-0.3.6/tests/0000755000000000000000000000000012666635520014352 5ustar rootrootdeps/pkg-config-0.3.6/tests/test.rs0000664000175000017500000000370312541040161014105 0ustar #![feature(static_mutex)] extern crate pkg_config; use std::env; use std::sync::{StaticMutex, MUTEX_INIT}; use std::path::PathBuf; static LOCK: StaticMutex = MUTEX_INIT; fn reset() { for (k, _) in env::vars() { if k.contains("PKG_CONFIG") || k.contains("DYNAMIC") || k.contains("STATIC") { env::remove_var(&k); } } env::remove_var("TARGET"); env::remove_var("HOST"); env::set_var("PKG_CONFIG_PATH", &env::current_dir().unwrap().join("tests")); } fn find(name: &str) -> Result { pkg_config::find_library(name) } #[test] fn cross_disabled() { let _g = LOCK.lock(); reset(); env::set_var("TARGET", "foo"); env::set_var("HOST", "bar"); find("foo").unwrap_err(); } #[test] fn cross_enabled() { let _g = LOCK.lock(); reset(); env::set_var("TARGET", "foo"); env::set_var("HOST", "bar"); env::set_var("PKG_CONFIG_ALLOW_CROSS", "1"); find("foo").unwrap(); } #[test] fn package_disabled() { let _g = LOCK.lock(); reset(); env::set_var("FOO_NO_PKG_CONFIG", "1"); find("foo").unwrap_err(); } #[test] fn output_ok() { let _g = LOCK.lock(); reset(); let lib = find("foo").unwrap(); assert!(lib.libs.contains(&"gcc".to_string())); assert!(lib.libs.contains(&"coregrind-amd64-linux".to_string())); assert!(lib.link_paths.contains(&PathBuf::from("/usr/lib/valgrind"))); } #[test] fn framework() { let _g = LOCK.lock(); reset(); let lib = find("framework").unwrap(); assert!(lib.frameworks.contains(&"foo".to_string())); assert!(lib.framework_paths.contains(&PathBuf::from("/usr/lib"))); } #[test] fn get_variable() { let _g = LOCK.lock(); reset(); let prefix = pkg_config::Config::get_variable("foo", "prefix").unwrap(); assert_eq!(prefix, "/usr"); } #[test] fn version() { let _g = LOCK.lock(); reset(); assert_eq!(&find("foo").unwrap().version[..], "3.10.0.SVN"); } deps/pkg-config-0.3.6/tests/framework.pc0000664000175000017500000000051012464733554015115 0ustar prefix=/usr exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include/valgrind arch=amd64 os=linux platform=amd64-linux valt_load_address=0x38000000 Name: Valgrind Description: A dynamic binary instrumentation framework Version: 3.10.0.SVN Requires: Libs: -F${libdir} -framework foo Cflags: -I${includedir} deps/pkg-config-0.3.6/tests/foo.pc0000664000175000017500000000056212464732010013674 0ustar prefix=/usr exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include/valgrind arch=amd64 os=linux platform=amd64-linux valt_load_address=0x38000000 Name: Valgrind Description: A dynamic binary instrumentation framework Version: 3.10.0.SVN Requires: Libs: -L${libdir}/valgrind -lcoregrind-amd64-linux -lvex-amd64-linux -lgcc Cflags: -I${includedir} deps/pkg-config-0.3.6/Cargo.toml0000664000175000017500000000062312604531770013357 0ustar [package] name = "pkg-config" version = "0.3.6" authors = ["Alex Crichton "] license = "MIT/Apache-2.0" repository = "https://github.com/alexcrichton/pkg-config-rs" documentation = "http://alexcrichton.com/pkg-config-rs" description = """ A library to run the pkg-config system tool at build time in order to be used in Cargo build scripts. """ keywords = ["build-dependencies"] deps/num_cpus-0.2.10/0000755000000000000000000000000012666635520013067 5ustar rootrootdeps/num_cpus-0.2.10/README.md0000664000175000017500000000040712623450224012560 0ustar # num_cpus A replacement for the deprecated `std::os::num_cpus`. ## Usage Add to Cargo.toml: ``` [dependencies] num_cpus = "0.2" ``` In your `main.rs` or `lib.rs`: ```rust extern crate num_cpus; // elsewhere let num = num_cpus::get(); ``` ## License MIT deps/num_cpus-0.2.10/.gitignore0000664000175000017500000000002212501616024013257 0ustar target Cargo.lock deps/num_cpus-0.2.10/LICENSE0000664000175000017500000000202412501621523012300 0ustar Copyright (c) 2015 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/num_cpus-0.2.10/src/0000755000000000000000000000000012666635520013656 5ustar rootrootdeps/num_cpus-0.2.10/src/lib.rs0000664000175000017500000000420212626116225013204 0ustar //! Replaces the deprecated functionality of std::os::num_cpus. #![cfg_attr(test, deny(warnings))] #![deny(missing_docs)] #![allow(non_snake_case)] extern crate libc; #[cfg(windows)] extern crate winapi; #[cfg(windows)] extern crate kernel32; /// Returns the number of CPUs of the current machine. #[inline] pub fn get() -> usize { get_num_cpus() } #[cfg(windows)] fn get_num_cpus() -> usize { unsafe { let mut sysinfo: winapi::SYSTEM_INFO = ::std::mem::uninitialized(); kernel32::GetSystemInfo(&mut sysinfo); sysinfo.dwNumberOfProcessors as usize } } #[cfg( any( target_os = "freebsd", target_os = "dragonfly", target_os = "bitrig", target_os = "openbsd", target_os = "netbsd" ) )] fn get_num_cpus() -> usize { use libc::{c_int, c_uint}; use libc::sysctl; use std::ptr; //XXX: uplift to libc? const CTL_HW: c_int = 6; const HW_AVAILCPU: c_int = 25; const HW_NCPU: c_int = 3; let mut cpus: c_uint = 0; let mut CPUS_SIZE = ::std::mem::size_of::(); let mut mib: [c_int; 4] = [CTL_HW, HW_AVAILCPU, 0, 0]; unsafe { sysctl(mib.as_mut_ptr(), 2, &mut cpus as *mut _ as *mut _, &mut CPUS_SIZE as *mut _ as *mut _, ptr::null_mut(), 0); } if cpus < 1 { mib[1] = HW_NCPU; unsafe { sysctl(mib.as_mut_ptr(), 2, &mut cpus as *mut _ as *mut _, &mut CPUS_SIZE as *mut _ as *mut _, ptr::null_mut(), 0); } if cpus < 1 { cpus = 1; } } cpus as usize } #[cfg( any( target_os = "linux", target_os = "nacl", target_os = "macos", target_os = "ios" ) )] fn get_num_cpus() -> usize { unsafe { libc::sysconf(libc::_SC_NPROCESSORS_ONLN) as usize } } #[cfg(target_os= "android")] fn get_num_cpus() -> usize { //to-do: replace with libc::_SC_NPROCESSORS_ONLN once available unsafe { libc::sysconf(97) as usize } } #[test] fn lower_bound() { assert!(get() > 0); } #[test] fn upper_bound() { assert!(get() < 236_451); } deps/num_cpus-0.2.10/Cargo.toml0000664000175000017500000000044312626116246013237 0ustar [package] name = "num_cpus" version = "0.2.10" description = "Get the number of CPUs on a machine." authors = ["Sean McArthur "] license = "MIT" repository = "https://github.com/seanmonstar/num_cpus" [dependencies] libc = "0.2" winapi = "0.2" kernel32-sys = "0.2" deps/pnacl-build-helper-1.4.10/0000755000000000000000000000000012666635520014710 5ustar rootrootdeps/pnacl-build-helper-1.4.10/README.md0000664000175000017500000000016012427233756014410 0ustar cargo-pnacl-helper ================== Helper functions for build.rs that need to compile a bit of C/CXX codes. deps/pnacl-build-helper-1.4.10/.gitignore0000664000175000017500000000002612455543711015116 0ustar *~ target/ Cargo.lock deps/pnacl-build-helper-1.4.10/src/0000755000000000000000000000000012666635520015477 5ustar rootrootdeps/pnacl-build-helper-1.4.10/src/lib.rs0000664000175000017500000005121712557173363015046 0ustar #![feature(fs_walk)] #![feature(path_ext)] extern crate tempdir; use std::cell::Cell; use std::collections::VecDeque; use std::default::Default; use std::process::{Command}; use std::env::set_current_dir; use std::fmt; use std::path::{Path, PathBuf}; #[cfg(unix)] use std::os::unix::fs::MetadataExt; use tempdir::TempDir; #[derive(Debug, Eq, PartialEq, Clone, Hash, Copy)] pub enum NaClMode { Portable, Native(&'static str), } impl fmt::Display for NaClMode { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let s = match self { &NaClMode::Portable => "le32", &NaClMode::Native(s) => s, }; write!(f, "{}", s) } } #[cfg(all(unix, not(target_os = "macos")))] fn get_platform_str() -> &'static str { "linux" } #[cfg(all(unix, target_os = "macos"))] fn get_platform_str() -> &'static str { "mac" } #[cfg(windows)] fn get_platform_str() -> &'static str { "win" } pub fn get_sdk_root() -> PathBuf { match getenv("NACL_SDK_ROOT") { None => panic!("Please set NACL_SDK_ROOT to your local pepper sdk"), Some(p) => Path::new(&p).to_path_buf(), } } pub fn get_nacl_target(v: &str) -> Option { match v { "le32-unknown-nacl" => Some(NaClMode::Portable), "i686-unknown-nacl" => Some(NaClMode::Native("i686")), "x86_64-unknown-nacl" => Some(NaClMode::Native("x86_64")), "arm-unknown-nacl" => Some(NaClMode::Native("arm")), _ => None, } } fn getenv(v: &str) -> Option { use std::env::var; use std::env::VarError::NotPresent; let r = match var(v) { Ok(v) => Some(v), Err(NotPresent) => None, Err(_) => { panic!("`{}` value isn't unicode", v); } }; println!("{} = {:?}", v, r); r } mod non_nacl { use std::path::{Path, PathBuf}; use super::getenv; fn get_var(var_base: &str) -> Result { let target = getenv("TARGET") .expect("Environment variable 'TARGET' is unset"); let host = match getenv("HOST") { None => { return Err("Environment variable 'HOST' is unset".to_string()); } Some(x) => x }; let kind = if host == target { "HOST" } else { "TARGET" }; let target_u = target.split('-') .collect::>() .connect("_"); let res = getenv(&format!("{}_{}", var_base, target)[..]) .or_else(|| getenv(&format!("{}_{}", var_base, target_u)[..])) .or_else(|| getenv(&format!("{}_{}", kind, var_base)[..])) .or_else(|| getenv(var_base)); match res { Some(res) => Ok(res), None => Err("Could not get environment variable".to_string()), } } pub fn gcc(target: &str) -> PathBuf { let is_android = target.find("android").is_some(); let r = get_var("CC").unwrap_or(if cfg!(windows) { "gcc".to_string() } else if is_android { format!("{}-gcc", target) } else { "cc".to_string() }); Path::new(&r) .to_path_buf() } pub fn gxx(target: &str) -> PathBuf { let is_android = target.find("android").is_some(); let r = get_var("CXX").unwrap_or(if cfg!(windows) { "g++".to_string() } else if is_android { format!("{}-g++", target) } else { "c++".to_string() }); Path::new(&r) .to_path_buf() } pub fn ar(target: &str) -> PathBuf { let is_android = target.find("android").is_some(); let r = get_var("AR").unwrap_or(if is_android { format!("{}-ar", target) } else { "ar".to_string() }); Path::new(&r) .to_path_buf() } pub fn ranlib(target: &str) -> PathBuf { let is_android = target.find("android").is_some(); let r = get_var("RANLIB").unwrap_or(if cfg!(windows) { "ranlib".to_string() } else if is_android { format!("{}-ranlib", target) } else { "ranlib".to_string() }); Path::new(&r) .to_path_buf() } } #[derive(Clone, Hash)] pub struct NativeTools { pub is_nacl: bool, pub cc: PathBuf, pub cxx: PathBuf, pub ar: PathBuf, pub ranlib: PathBuf, } impl NativeTools { pub fn new(target: &str) -> NativeTools { let mode = get_nacl_target(target); if mode.is_none() { NativeTools { is_nacl: false, cc: non_nacl::gcc(&target[..]), cxx: non_nacl::gxx(&target[..]), ar: non_nacl::ar(&target[..]), ranlib: non_nacl::ranlib(&target[..]), } } else { let mode = mode.unwrap(); let pepper = get_sdk_root().join("toolchain"); let (cc, cxx, ar, ranlib) = match mode { NaClMode::Portable => { let cc = "pnacl-clang"; let cxx = "pnacl-clang++"; let ar = "pnacl-ar"; let ranlib = "pnacl-ranlib"; let tc: String = [get_platform_str(), "_pnacl"].concat(); let pepper: PathBuf = pepper.join(tc); let pepper = pepper.join("bin"); (pepper.join(cc), pepper.join(cxx), pepper.join(ar), pepper.join(ranlib)) } NaClMode::Native(arch) if arch == "i686" || arch == "x86_64" => { let cc: String = [arch, "-nacl-gcc"].concat(); let cxx: String = [arch, "-nacl-g++"].concat(); let ar: String = [arch, "-nacl-ar"].concat(); let ranlib: String = [arch, "-nacl-ranlib"].concat(); let pepper = pepper .join(format!("{}_x86_glibc", get_platform_str())); let pepper = pepper.join("bin"); (pepper.join(cc), pepper.join(cxx), pepper.join(ar), pepper.join(ranlib)) } NaClMode::Native("arm") => { let cc = "arm-nacl-gcc"; let cxx = "arm-nacl-g++"; let ar = "arm-nacl-ar"; let ranlib = "arm-nacl-ranlib"; let pepper = pepper .join(format!("{}_arm_newlib", get_platform_str())); let pepper = pepper.join("bin"); (pepper.join(cc), pepper.join(cxx), pepper.join(ar), pepper.join(ranlib)) } NaClMode::Native(_) => unreachable!(), }; NativeTools { is_nacl: true, cc: cc, cxx: cxx, ar: ar, ranlib: ranlib, } } } } impl Default for NativeTools { fn default() -> NativeTools { let target = getenv("TARGET").unwrap(); NativeTools::new(&target[..]) } } #[cfg(not(target_os = "nacl"))] pub fn print_lib_paths() { let mode = get_nacl_target(getenv("TARGET").unwrap().as_ref()); if mode.is_none() { return; } let mode = mode.unwrap(); let root = get_sdk_root(); let pepper = root.join("toolchain"); let tc: String = [get_platform_str(), "_pnacl"].concat(); let mut pepper: PathBuf = pepper.join(tc); let (ports, arch, lib) = match mode { NaClMode::Portable => ("pnacl", "le32", "lib"), _ => unimplemented!(), }; pepper.push(format!("{}-nacl", arch)); let main = pepper.join(lib); let installed = pepper.join("usr/lib"); let ports = root.join("lib") .join(ports) .join(if getenv("DEBUG") == Some("true".to_string()) { "Debug" } else { "Release" }); println!("cargo:rustc-link-search=native={}", main.display()); println!("cargo:rustc-link-search=native={}", installed.display()); println!("cargo:rustc-link-search=native={}", ports.display()); } #[cfg(target_os = "nacl")] pub fn print_lib_paths() { } #[cfg(not(target_os = "nacl"))] pub fn set_pkg_config_envs() { use std::env; let mode = get_nacl_target(getenv("TARGET").unwrap().as_ref()); if mode.is_none() { return; } let mode = mode.unwrap(); let pepper = get_sdk_root().join("toolchain"); let tc: String = [get_platform_str(), "_pnacl"].concat(); let mut pepper: PathBuf = pepper.join(tc); let arch = match mode { NaClMode::Portable => "le32", _ => unimplemented!(), }; pepper.push(format!("{}-nacl", arch)); pepper.push("usr/lib/pkgconfig"); //$NACL_SDK_ROOT/toolchain/$($NACL_SDK_ROOT/tools/getos.py)_pnacl/le32-nacl/usr/lib/pkgconfig let mut new_paths: Vec = Vec::with_capacity(1); new_paths.push(pepper); if let Some(paths) = getenv("PKG_CONFIG_LIBDIR") { new_paths.extend(env::split_paths(&paths)) } env::set_var("PKG_CONFIG_LIBDIR", env::join_paths(new_paths).unwrap()); env::set_var("PKG_CONFIG_ALLOW_CROSS", "1"); } #[cfg(target_os = "nacl")] pub fn set_pkg_config_envs() { } pub struct ConfigureMake { tools: NativeTools, args: Vec, built_libs: VecDeque<(PathBuf, String)>, make_only_dirs: Option>, out_dir: PathBuf, src_dir: PathBuf, fresh: Cell>, } impl ConfigureMake { pub fn new(args: &[String], built_libs: &[(PathBuf, String)], src_dir: PathBuf) -> ConfigureMake { let sdk = get_sdk_root(); let triple = getenv("TARGET").unwrap(); let target = get_nacl_target(&triple[..]); let tools: NativeTools = NativeTools::new(&triple[..]); let extra_flags = format!("-I{}/include", sdk.display()); let extra_flags = match target { Some(NaClMode::Portable) => format!("{} -I{}/include/pnacl", extra_flags, sdk.display()), _ => extra_flags, }; let extra_flags = if tools.is_nacl { format!("{} -D__USE_GNU", extra_flags) } else { extra_flags }; let args = args.iter() .map(|str| { if str.starts_with("CFLAGS=") || str.starts_with("CXXFLAGS=") { format!("{} {}", str, extra_flags) } else { str.to_string() } }).collect(); ConfigureMake { tools: tools, args: args, built_libs: built_libs.iter().map(|&(ref p, ref l): &(PathBuf, String)| { assert!(p.is_relative()); // map old style `foo:static` into `static=foo`. let mut split = l.split(':'); let l = if let Some(lib) = split.next() { let mut lib = lib.to_string(); let mut kind = if let Some(k) = split.next() { k } else { return (p.clone(), l.clone()); }; loop { let next = match split.next() { None => { break; }, Some(next) => next, }; lib = format!("{}:{}", lib, kind); kind = next; } format!("{}={}", kind, lib) } else { l.clone() }; (p.clone(), l.clone()) }).collect(), make_only_dirs: None, out_dir: Path::new(&getenv("OUT_DIR").unwrap()).to_path_buf(), src_dir: src_dir, fresh: Cell::new(None), } } pub fn make_only_dir(&mut self, dir: PathBuf) -> &mut ConfigureMake { let mut m = self.make_only_dirs .take() .unwrap_or_else(|| VecDeque::new() ); m.push_front(dir); self.make_only_dirs = Some(m); self } pub fn make_all(&mut self) { self.make_only_dirs = None; } /// Do we need to rebuild this? pub fn is_fresh(&self) -> bool { use std::fs::{metadata, walk_dir, read_dir}; use std::cmp::{max, min}; if self.fresh.get().is_some() { return self.fresh.get().unwrap(); } else { println!("checking freshness:"); // get the mtime of the outputs: let built_libs: Vec = self.built_libs .iter() .map(|&(ref p, ref s)| (p, s.split(':').next().expect("invalid extern lib spec?")) ) // TODO: PNaCl always uses lib.a, but this convention is not constant for other targets. .map(|(p, s)| p.join(format!("lib{}.a", s)) ) .collect(); let mut oldest_lib: i64 = i64::max_value(); for lib in built_libs.into_iter() { let lib = self.out_dir.join(lib); let stat = metadata(&lib); if stat.is_err() { println!("not fresh: stat on output library failed: `{}`", lib.display()); // not fresh. non-existant files will hit this too. self.fresh.set(Some(false)); return false; } let stat = stat.unwrap(); oldest_lib = min(oldest_lib, stat.mtime() as i64); } let mut newest_timestamp: i64 = 0; let dir_iter = walk_dir(&self.src_dir).unwrap(); for dir in dir_iter { if dir.is_err() { continue; } let dir = dir.unwrap().path(); let files = read_dir(&dir); if !files.is_ok() { continue; } for file in files.unwrap() { if file.is_err() { continue; } let file = file.unwrap().path(); let stat = metadata(&file); if !stat.is_ok() { continue; } let stat = stat.unwrap(); newest_timestamp = max(newest_timestamp, stat.mtime() as i64); } } if oldest_lib >= newest_timestamp { // fresh println!("fresh: `{}` >= `{}`!", oldest_lib, newest_timestamp); self.fresh.set(Some(true)); } else { println!("not fresh: `{}` < `{}`!", oldest_lib, newest_timestamp); // not fresh self.fresh.set(Some(false)); } println!(""); println!(""); return self.fresh.get().unwrap(); } } pub fn configure(&self) { if self.is_fresh() { return; } let cfg = self.src_dir.join("configure"); set_current_dir(&self.out_dir).unwrap(); let mut cmd = Command::new(&cfg); cmd.args(&self.args[..]); cmd.arg(format!("--host={}", getenv("TARGET").unwrap())); let cc_arg = format!("CC={}", self.tools.cc.display()); let cxx_arg = format!("CXX={}", self.tools.cxx.display()); let ar_arg = format!("AR={}", self.tools.ar.display()); let ranlib_arg = format!("RANLIB={}", self.tools.ranlib.display()); cmd.arg(cc_arg); cmd.arg(cxx_arg); cmd.arg(ar_arg); cmd.arg(ranlib_arg); run_tool(cmd); println!(""); println!(""); set_current_dir(&self.src_dir).unwrap(); } pub fn make(self) { if !self.is_fresh() { let make = getenv("MAKE") .unwrap_or_else(|| "make".to_string() ); let make_prog = Path::new(&make); set_current_dir(&self.out_dir).unwrap(); let mut cmd = Command::new(&make_prog); cmd.arg("-j") .arg(getenv("NUM_JOBS").unwrap_or_else(|| "1".to_string() )); match self.make_only_dirs { Some(ref dirs) => { for dir in dirs.iter() { let mut cmd = Command::new(&make_prog); cmd.arg("-j") .arg(getenv("NUM_JOBS").unwrap_or_else(|| "1".to_string() )); cmd.arg("-C") .arg(dir.display().to_string()); run_tool(cmd); } } None => run_tool(cmd), } println!(""); println!(""); set_current_dir(&self.src_dir).unwrap(); } for (p, l) in self.built_libs.into_iter() { let p = self.out_dir.join(p); println!("cargo:rustc-link-lib={}", l); println!("cargo:rustc-link-search=native={}", p.display()); println!("cargo:libdir={}", p.display()); } } } fn run_tool(mut cmd: Command) { use std::process::Stdio; println!("{:?}", cmd); cmd.stdout(Stdio::inherit()); cmd.stderr(Stdio::inherit()); assert!(cmd.status().unwrap().success()); } pub struct Archive { tools: NativeTools, tmp: TempDir, doubles: u64, obj_files: VecDeque, libname: String, output: PathBuf, } impl Archive { pub fn new(out_stem: &str) -> Archive { let out_dir = getenv("OUT_DIR").unwrap(); let d: String = ["lib", out_stem, "-objs"].concat(); let lib_file: String = ["lib", out_stem, ".a"].concat(); Archive { tools: Default::default(), tmp: TempDir::new(&d[..]).unwrap(), doubles: 1, obj_files: VecDeque::new(), libname: out_stem.to_string(), output: Path::new(&out_dir).join(lib_file), } } fn src_obj(&mut self, src: &str) -> (PathBuf, PathBuf) { use std::fs::PathExt; let src = Path::new(src); let stem = src.file_stem() .expect("provided source is not a filename"); let obj = Path::new(stem).with_extension("o"); let obj = self.tmp.path().join(obj); let obj = if obj.exists() { let obj_str = format!("{}{}.o", stem.to_str().unwrap(), { let d = self.doubles; self.doubles += 1; d }); let obj = Path::new(&obj_str); self.tmp.path().join(obj) } else { obj }; self.obj_files.push_front(obj.clone()); (src.to_path_buf(), obj) } fn run(&mut self, cmd: Command) -> &mut Archive { run_tool(cmd); self } fn nacl_build_cflags() -> Vec { let mut a = Vec::new(); let sdk = get_sdk_root(); let triple = getenv("TARGET").unwrap(); let target = get_nacl_target(&triple[..]); a.push(format!("-I{}/include", sdk.display())); match target { Some(NaClMode::Portable) => { a.push(format!("-I{}/include/pnacl", sdk.display())) } _ => (), } a } pub fn cc(&mut self, src: &str, args: &[String]) -> &mut Archive { let (src, obj) = self.src_obj(src); let mut cmd = Command::new(&self.tools.cc); cmd.arg("-c") .arg(src) .arg("-o") .arg(obj) .args(args); if self.tools.is_nacl { cmd.args(&Archive::nacl_build_cflags()[..]); } self.run(cmd) } pub fn cxx(&mut self, src: &str, args: &[String]) -> &mut Archive { let (src, obj) = self.src_obj(src); let mut cmd = Command::new(&self.tools.cxx); cmd.arg("-c") .arg(src) .arg("-o") .arg(obj) .args(args); if self.tools.is_nacl { cmd.args(&Archive::nacl_build_cflags()[..]); } self.run(cmd) } pub fn archive(mut self) { let ar_cmds = "crus"; let mut cmd = Command::new(&self.tools.ar); cmd.arg(ar_cmds) .arg(self.output.clone()); for f in self.obj_files.iter() { cmd.arg(f.display().to_string()); } self.run(cmd); let out_dir = self.output.parent().unwrap(); println!("cargo:rustc-link-search=native={}", out_dir.display()); println!("cargo:rustc-link-lib=static={}", self.libname); } } deps/pnacl-build-helper-1.4.10/Cargo.toml0000664000175000017500000000057312557436057015074 0ustar [package] name = "pnacl-build-helper" version = "1.4.10" authors = ["Richard Diamond "] description = "Build script helper for building PNaCl/NaCl C/CXX libraries from source" license = "MPL-2.0" repository = "https://github.com/DiamondLovesYou/cargo-pnacl-helper" [lib] name = "pnacl_build_helper" path = "src/lib.rs" [dependencies] tempdir = "*" deps/filetime-0.1.8/0000755000000000000000000000000012666635521012763 5ustar rootrootdeps/filetime-0.1.8/LICENSE-APACHE0000664000175000017500000002513712521775150013134 0ustar Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/filetime-0.1.8/LICENSE-MIT0000664000175000017500000000204112521775150012631 0ustar Copyright (c) 2014 Alex Crichton Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/filetime-0.1.8/.travis.yml0000664000175000017500000000137312572110370013306 0ustar language: rust rust: - nightly - beta - 1.1.0 sudo: false script: - cargo build --verbose - cargo test --verbose - cargo doc --no-deps after_success: | [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && echo '' > target/doc/index.html && pip install ghp-import --user $USER && $HOME/.local/bin/ghp-import -n target/doc && git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages notifications: email: on_success: never env: global: secure: dsIj09BQvGF872zKmqzG+WwCl7gfqwsnxcm3GZlAMgyLYm4juvHOwCRhIERCN3BCxPvdlSRKhe9Rwmp1RkiKuqTK3ITUTAy29Maf2vuL1T+zcdpZE0t6JSCU1gbEwzCA2foB1jzgy7Q47EzeJusmGNwibscjYmXKlH6JCFwTobM= os: - linux - osx deps/filetime-0.1.8/README.md0000664000175000017500000000161412536671634012471 0ustar # filetime [![Build Status](https://travis-ci.org/alexcrichton/filetime.svg?branch=master)](https://travis-ci.org/alexcrichton/filetime) [![Build status](https://ci.appveyor.com/api/projects/status/9tatexq47i3ee13k?svg=true)](https://ci.appveyor.com/project/alexcrichton/filetime) [Documentation](http://alexcrichton.com/filetime/filetime/index.html) A helper library for inspecting the various timestamps of files in Rust. This library takes into account cross-platform differences in terms of where the timestamps are located, what they are called, and how to convert them into a platform-independent representation. ```toml # Cargo.toml [dependencies] filetime = "0.1" ``` # License `filetime` is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses. See LICENSE-APACHE, and LICENSE-MIT for details. deps/filetime-0.1.8/.gitignore0000664000175000017500000000002212521772777013176 0ustar target Cargo.lock deps/filetime-0.1.8/src/0000755000000000000000000000000012666635521013552 5ustar rootrootdeps/filetime-0.1.8/src/lib.rs0000664000175000017500000002320512614716744013114 0ustar //! Timestamps for files in Rust //! //! This library provides platform-agnostic inspection of the various timestamps //! present in the standard `fs::Metadata` structure. //! //! # Installation //! //! Add this to you `Cargo.toml`: //! //! ```toml //! [dependencies] //! filetime = "0.1" //! ``` //! //! # Usage //! //! ```no_run //! use std::fs; //! use filetime::FileTime; //! //! let metadata = fs::metadata("foo.txt").unwrap(); //! //! let mtime = FileTime::from_last_modification_time(&metadata); //! println!("{}", mtime); //! //! let atime = FileTime::from_last_access_time(&metadata); //! assert!(mtime < atime); //! //! // Inspect values that can be interpreted across platforms //! println!("{}", mtime.seconds_relative_to_1970()); //! println!("{}", mtime.nanoseconds()); //! //! // Print the platform-specific value of seconds //! println!("{}", mtime.seconds()); //! ``` extern crate libc; extern crate winapi; extern crate kernel32; #[cfg(unix)] use std::os::unix::prelude::*; #[cfg(windows)] use std::os::windows::prelude::*; use std::fmt; use std::fs; use std::io; use std::path::Path; /// A helper structure to represent a timestamp for a file. /// /// The actual value contined within is platform-specific and does not have the /// same meaning across platforms, but comparisons and stringification can be /// significant among the same platform. #[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Copy, Clone, Hash)] pub struct FileTime { seconds: u64, nanos: u32, } impl FileTime { /// Creates a new timestamp representing a 0 time. /// /// Useful for creating the base of a cmp::max chain of times. pub fn zero() -> FileTime { FileTime { seconds: 0, nanos: 0 } } /// Creates a new instance of `FileTime` with a number of seconds and /// nanoseconds relative to January 1, 1970. /// /// Note that this is typically the relative point that Unix time stamps are /// from, but on Windows the native time stamp is relative to January 1, /// 1601 so the return value of `seconds` from the returned `FileTime` /// instance may not be the same as that passed in. pub fn from_seconds_since_1970(seconds: u64, nanos: u32) -> FileTime { FileTime { seconds: seconds + if cfg!(windows) {11644473600} else {0}, nanos: nanos, } } /// Creates a new timestamp from the last modification time listed in the /// specified metadata. /// /// The returned value corresponds to the `mtime` field of `stat` on Unix /// platforms and the `ftLastWriteTime` field on Windows platforms. pub fn from_last_modification_time(meta: &fs::Metadata) -> FileTime { #[cfg(unix)] fn imp(meta: &fs::Metadata) -> FileTime { FileTime::from_os_repr(meta.mtime() as u64, meta.mtime_nsec() as u32) } #[cfg(windows)] fn imp(meta: &fs::Metadata) -> FileTime { FileTime::from_os_repr(meta.last_write_time()) } imp(meta) } /// Creates a new timestamp from the last access time listed in the /// specified metadata. /// /// The returned value corresponds to the `atime` field of `stat` on Unix /// platforms and the `ftLastAccessTime` field on Windows platforms. pub fn from_last_access_time(meta: &fs::Metadata) -> FileTime { #[cfg(unix)] fn imp(meta: &fs::Metadata) -> FileTime { FileTime::from_os_repr(meta.atime() as u64, meta.atime_nsec() as u32) } #[cfg(windows)] fn imp(meta: &fs::Metadata) -> FileTime { FileTime::from_os_repr(meta.last_access_time()) } imp(meta) } /// Creates a new timestamp from the creation time listed in the specified /// metadata. /// /// The returned value corresponds to the `birthtime` field of `stat` on /// Unix platforms and the `ftCreationTime` field on Windows platforms. Note /// that not all Unix platforms have this field available and may return /// `None` in some circumstances. pub fn from_creation_time(meta: &fs::Metadata) -> Option { macro_rules! birthtim { ($(($e:expr, $i:ident)),*) => { #[cfg(any($(target_os = $e),*))] fn imp(meta: &fs::Metadata) -> Option { $( #[cfg(target_os = $e)] use std::os::$i::fs::MetadataExt; )* let raw = meta.as_raw_stat(); Some(FileTime::from_os_repr(raw.st_birthtime as u64, raw.st_birthtime_nsec as u32)) } #[cfg(all(not(windows), $(not(target_os = $e)),*))] fn imp(_meta: &fs::Metadata) -> Option { None } } } birthtim! { ("bitrig", bitrig), ("freebsd", freebsd), ("ios", ios), ("macos", macos), ("openbsd", openbsd) } #[cfg(windows)] fn imp(meta: &fs::Metadata) -> Option { Some(FileTime::from_os_repr(meta.last_access_time())) } imp(meta) } #[cfg(windows)] fn from_os_repr(time: u64) -> FileTime { // Windows write times are in 100ns intervals, so do a little math to // get it into the right representation. FileTime { seconds: time / (1_000_000_000 / 100), nanos: ((time % (1_000_000_000 / 100)) * 100) as u32, } } #[cfg(unix)] fn from_os_repr(seconds: u64, nanos: u32) -> FileTime { FileTime { seconds: seconds, nanos: nanos } } /// Returns the whole number of seconds represented by this timestamp. /// /// Note that this value's meaning is **platform specific**. On Unix /// platform time stamps are typically relative to January 1, 1970, but on /// Windows platforms time stamps are relative to January 1, 1601. pub fn seconds(&self) -> u64 { self.seconds } /// Returns the whole number of seconds represented by this timestamp, /// relative to the Unix epoch start of January 1, 1970. /// /// Note that this does not return the same value as `seconds` for Windows /// platforms as seconds are relative to a different date there. pub fn seconds_relative_to_1970(&self) -> u64 { self.seconds - if cfg!(windows) {11644473600} else {0} } /// Returns the nanosecond precision of this timestamp. /// /// The returned value is always less than one billion and represents a /// portion of a second forward from the seconds returned by the `seconds` /// method. pub fn nanoseconds(&self) -> u32 { self.nanos } } impl fmt::Display for FileTime { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}.{:09}s", self.seconds, self.nanos) } } /// Set the last access and modification times for a file on the filesystem. /// /// This function will set the `atime` and `mtime` metadata fields for a file /// on the local filesystem, returning any error encountered. pub fn set_file_times

(p: P, atime: FileTime, mtime: FileTime) -> io::Result<()> where P: AsRef { set_file_times_(p.as_ref(), atime, mtime) } #[cfg(unix)] fn set_file_times_(p: &Path, atime: FileTime, mtime: FileTime) -> io::Result<()> { use std::ffi::CString; use libc::{timeval, time_t, suseconds_t, utimes}; let times = [to_timeval(&atime), to_timeval(&mtime)]; let p = try!(CString::new(p.as_os_str().as_bytes())); return unsafe { if utimes(p.as_ptr(), times.as_ptr()) == 0 { Ok(()) } else { Err(io::Error::last_os_error()) } }; fn to_timeval(ft: &FileTime) -> timeval { timeval { tv_sec: ft.seconds() as time_t, tv_usec: (ft.nanoseconds() / 1000) as suseconds_t, } } } #[cfg(windows)] fn set_file_times_(p: &Path, atime: FileTime, mtime: FileTime) -> io::Result<()> { use std::fs::OpenOptions; use winapi::{FILETIME, DWORD}; let f = try!(OpenOptions::new().write(true).open(p)); let atime = to_filetime(&atime); let mtime = to_filetime(&mtime); return unsafe { let ret = kernel32::SetFileTime(f.as_raw_handle() as *mut _, 0 as *const _, &atime, &mtime); if ret != 0 { Ok(()) } else { Err(io::Error::last_os_error()) } }; fn to_filetime(ft: &FileTime) -> FILETIME { let intervals = ft.seconds() * (1_000_000_000 / 100) + ((ft.nanoseconds() as u64) / 100); FILETIME { dwLowDateTime: intervals as DWORD, dwHighDateTime: (intervals >> 32) as DWORD, } } } #[cfg(test)] mod tests { extern crate tempdir; use std::fs::{self, File}; use self::tempdir::TempDir; use super::{FileTime, set_file_times}; #[test] fn set_file_times_test() { let td = TempDir::new("filetime").unwrap(); let path = td.path().join("foo.txt"); File::create(&path).unwrap(); let metadata = fs::metadata(&path).unwrap(); let mtime = FileTime::from_last_modification_time(&metadata); let atime = FileTime::from_last_access_time(&metadata); set_file_times(&path, atime, mtime).unwrap(); let new_mtime = FileTime::from_seconds_since_1970(10_000, 0); set_file_times(&path, atime, new_mtime).unwrap(); let metadata = fs::metadata(&path).unwrap(); let mtime = FileTime::from_last_modification_time(&metadata); assert_eq!(mtime, new_mtime); } } deps/filetime-0.1.8/appveyor.yml0000664000175000017500000000073612556741164013604 0ustar environment: matrix: - TARGET: x86_64-pc-windows-msvc - TARGET: i686-pc-windows-msvc - TARGET: i686-pc-windows-gnu install: - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin - SET PATH=%PATH%;C:\MinGW\bin - rustc -V - cargo -V build: false test_script: - cargo test --verbose deps/filetime-0.1.8/Cargo.toml0000664000175000017500000000101312623702354013122 0ustar [package] name = "filetime" authors = ["Alex Crichton "] version = "0.1.8" license = "MIT/Apache-2.0" readme = "README.md" keywords = ["timestamp", "mtime"] repository = "https://github.com/alexcrichton/filetime" homepage = "https://github.com/alexcrichton/filetime" documentation = "http://alexcrichton.com/filetime" description = """ Platform-agnostic accessors of timestamps in File metadata """ [dependencies] libc = "0.2" kernel32-sys = "0.2" winapi = "0.2" [dev-dependencies] tempdir = "0.3" deps/libressl-pnacl-sys-2.1.6/0000755000000000000000000000000012666635521014713 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/0000755000000000000000000000000012666635521016532 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/m4/0000755000000000000000000000000012666635521017052 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/m4/libtool.m40000444000175000017500000105721612360020747017201 0ustar # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]) # serial 57 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_CC_BASENAME(CC) # ------------------- # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. m4_defun([_LT_CC_BASENAME], [for cc_temp in $1""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ]) # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from `configure', and `config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # `config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain="$ac_aux_dir/ltmain.sh" ])# _LT_PROG_LTMAIN ## ------------------------------------- ## ## Accumulate code for creating libtool. ## ## ------------------------------------- ## # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the `libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) ## ------------------------ ## ## FIXME: Eliminate VARNAME ## ## ------------------------ ## # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to `config.status' so that its # declaration there will have the same value as in `configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags="_LT_TAGS"dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the `libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into `config.status', and then the shell code to quote escape them in # for loops in `config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # `#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test $lt_write_fail = 0 && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ \`$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test $[#] != 0 do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try \`$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try \`$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. lt_cl_success=: test "$silent" = yes && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # _LT_COPYING _LT_LIBTOOL_TAGS # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_REPLACE_SHELLFNS mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG m4_ifndef([AC_PROG_GO], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_GO. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_GO], [AC_LANG_PUSH(Go)dnl AC_ARG_VAR([GOC], [Go compiler command])dnl AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl _AC_ARG_VAR_LDFLAGS()dnl AC_CHECK_TOOL(GOC, gccgo) if test -z "$GOC"; then if test -n "$ac_tool_prefix"; then AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) fi fi if test -z "$GOC"; then AC_CHECK_PROG(GOC, gccgo, gccgo, false) fi ])#m4_defun ])#m4_ifndef # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([AC_PROG_GO], [LT_LANG(GO)], [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[[012]]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES([TAG]) # --------------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" m4_if([$1], [CXX], [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX([TAGNAME]) # ---------------------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script which will find a shell with a builtin # printf (which we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case "$ECHO" in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [ --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified).], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([${with_sysroot}]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and in which our libraries should be installed.])]) # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" ])# _LT_ENABLE_LOCK # _LT_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) _LT_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test x"[$]$2" = xyes; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" ]) if test x"[$]$2" = xyes; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n $lt_cv_sys_max_cmd_len ; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "$cross_compiling" = yes; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) ]) ]) ]) ]) ]) ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links="nottested" if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test "$hard_links" = no; then AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", [Define to the sub-directory in which libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then # We can hardcode non-existent directories. if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[[4-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[23]].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([], [sys_lib_dlsearch_path_spec], [2], [Run-time system search path for libraries]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program which can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$1; then lt_cv_path_MAGIC_CMD="$ac_dir/$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac]) MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program which can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test "$withval" = no || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method = "file_magic"]) _LT_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi]) if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi AC_SUBST([DUMPBIN]) if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # _LT_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM="-lm") ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test "$GCC" = yes; then case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT@&t@_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd*) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; *Sun\ F* | *Sun*Fortran*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; *Intel*\ [[CF]]*Compiler*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; *Portland\ Group*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS="$save_LDFLAGS"]) if test "$lt_cv_irix_exported_symbol" = yes; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' else case $host_os in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' ;; esac fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting ${shlibpath_var} if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC="$CC" AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report which library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC="$lt_save_CC" ])# _LT_LANG_C_CONFIG # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared # libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ func_to_tool_file "$lt_outputfile"~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; gnu*) ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd2*) # C++ shared libraries are fairly broken _LT_TAGVAR(ld_shlibs, $1)=no ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(GCC, $1)="$GXX" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF package foo func foo() { } _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case ${prev}${p} in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test "$pre_test_object_deps_done" = no; then case ${prev} in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)="${prev}${p}" else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)="$p" else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)="$p" else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_LANG_PUSH(Fortran 77) if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_F77" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$G77" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" CFLAGS="$lt_save_CFLAGS" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_LANG_PUSH(Fortran) if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_FC" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test "$_lt_disable_FC" != yes AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_GO_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Go compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GO_CONFIG], [AC_REQUIRE([LT_PROG_GO])dnl AC_LANG_SAVE # Source file extension for Go test sources. ac_ext=go # Object file extension for compiled Go test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="package main; func main() { }" # Code to be used in simple link tests lt_simple_link_test_code='package main; func main() { }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GOC-"gccgo"} CFLAGS=$GOFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # Go did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GO_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code="$lt_simple_compile_test_code" # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_GO # ---------- AC_DEFUN([LT_PROG_GO], [AC_CHECK_TOOL(GOC, gccgo,) ]) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f $lt_ac_sed && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test $lt_ac_count -gt 10 && break lt_ac_count=`expr $lt_ac_count + 1` if test $lt_ac_count -gt $lt_ac_max; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [AC_MSG_CHECKING([whether the shell understands some XSI constructs]) # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes AC_MSG_RESULT([$xsi_shell]) _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) AC_MSG_CHECKING([whether the shell understands "+="]) lt_shell_append=no ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes AC_MSG_RESULT([$lt_shell_append]) _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) # ------------------------------------------------------ # In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and # '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. m4_defun([_LT_PROG_FUNCTION_REPLACE], [dnl { sed -e '/^$1 ()$/,/^} # $1 /c\ $1 ()\ {\ m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) } # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: ]) # _LT_PROG_REPLACE_SHELLFNS # ------------------------- # Replace existing portable implementations of several shell functions with # equivalent extended shell implementations where those features are available.. m4_defun([_LT_PROG_REPLACE_SHELLFNS], [if test x"$xsi_shell" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"}]) _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl func_split_long_opt_name=${1%%=*} func_split_long_opt_arg=${1#*=}]) _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) fi if test x"$lt_shell_append" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl func_quote_for_eval "${2}" dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) fi ]) # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine which file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS deps/libressl-pnacl-sys-2.1.6/libressl/m4/ltversion.m40000444000175000017500000000126212360020750017541 0ustar # ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # @configure_input@ # serial 3337 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.4.2]) m4_define([LT_PACKAGE_REVISION], [1.3337]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.4.2' macro_revision='1.3337' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) deps/libressl-pnacl-sys-2.1.6/libressl/m4/ltoptions.m40000444000175000017500000003007312360020747017557 0ustar # Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, # Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 7 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option `$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl `shared' nor `disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) ]) ])# _LT_SET_OPTIONS ## --------------------------------- ## ## Macros to handle LT_INIT options. ## ## --------------------------------- ## # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the `shared' and # `disable-shared' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the `static' and # `disable-static' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the `fast-install' # and `disable-fast-install' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the `pic-only' and `no-pic' # LT_INIT options. # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) ## ----------------- ## ## LTDL_INIT Options ## ## ----------------- ## m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) deps/libressl-pnacl-sys-2.1.6/libressl/m4/ltsugar.m40000444000175000017500000001042412360020750017175 0ustar # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59 which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) deps/libressl-pnacl-sys-2.1.6/libressl/m4/lt~obsolete.m40000444000175000017500000001375612360020750020101 0ustar # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 5 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) deps/libressl-pnacl-sys-2.1.6/libressl/README0000644000175000017500000000204112360006676015623 0ustar This package is the official portable version of LibreSSL (http://www.libressl.org). LibreSSL is a fork of OpenSSL developed by the OpenBSD project (http://www.openbsd.org). LibreSSL is developed on OpenBSD. This package then adds portability shims for other operating systems. Official release tarballs are available at your friendly neighborhood OpenBSD mirror in directory LibreSSL, e.g.: http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/ although it is suggested you use a mirror. Development is done in the upstream OpenBSD codebase. A github clone of the official repositories is kept at: https://github.com/libressl-portable We update this repository from the OpenBSD respositories semi-frequently, so changes may not show up in GitHub immediately. The GitHub repository should be used for informational purposes only. ./configure && make check && make install See crypto/compat for the bulk of the local compatibility code. It will likely build on any reasonably modern version of Linux, Solaris, or OSX with a sane compiler and C library. deps/libressl-pnacl-sys-2.1.6/libressl/aclocal.m40000664000175000017500000012213412433547746016624 0ustar # generated automatically by aclocal 1.14.1 -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # Copyright (C) 2002-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.14' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.14.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.14.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each '.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi ]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) m4_include([m4/ltversion.m4]) m4_include([m4/lt~obsolete.m4]) deps/libressl-pnacl-sys-2.1.6/libressl/ssl/0000755000000000000000000000000012666635521017333 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/ssl/ssl_err.c0000644000175000017500000011741312360020705017360 0ustar /* $OpenBSD: ssl_err.c,v 1.24 2014/06/13 04:29:13 miod Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_SSL,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_SSL,0,reason) static ERR_STRING_DATA SSL_str_functs[]= { {ERR_FUNC(SSL_F_CLIENT_CERTIFICATE), "CLIENT_CERTIFICATE"}, {ERR_FUNC(SSL_F_CLIENT_FINISHED), "CLIENT_FINISHED"}, {ERR_FUNC(SSL_F_CLIENT_HELLO), "CLIENT_HELLO"}, {ERR_FUNC(SSL_F_CLIENT_MASTER_KEY), "CLIENT_MASTER_KEY"}, {ERR_FUNC(SSL_F_D2I_SSL_SESSION), "d2i_SSL_SESSION"}, {ERR_FUNC(SSL_F_DO_DTLS1_WRITE), "DO_DTLS1_WRITE"}, {ERR_FUNC(SSL_F_DO_SSL3_WRITE), "DO_SSL3_WRITE"}, {ERR_FUNC(SSL_F_DTLS1_ACCEPT), "DTLS1_ACCEPT"}, {ERR_FUNC(SSL_F_DTLS1_ADD_CERT_TO_BUF), "DTLS1_ADD_CERT_TO_BUF"}, {ERR_FUNC(SSL_F_DTLS1_BUFFER_RECORD), "DTLS1_BUFFER_RECORD"}, {ERR_FUNC(SSL_F_DTLS1_CHECK_TIMEOUT_NUM), "DTLS1_CHECK_TIMEOUT_NUM"}, {ERR_FUNC(SSL_F_DTLS1_CLIENT_HELLO), "DTLS1_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_DTLS1_CONNECT), "DTLS1_CONNECT"}, {ERR_FUNC(SSL_F_DTLS1_ENC), "DTLS1_ENC"}, {ERR_FUNC(SSL_F_DTLS1_GET_HELLO_VERIFY), "DTLS1_GET_HELLO_VERIFY"}, {ERR_FUNC(SSL_F_DTLS1_GET_MESSAGE), "DTLS1_GET_MESSAGE"}, {ERR_FUNC(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT), "DTLS1_GET_MESSAGE_FRAGMENT"}, {ERR_FUNC(SSL_F_DTLS1_GET_RECORD), "DTLS1_GET_RECORD"}, {ERR_FUNC(SSL_F_DTLS1_HANDLE_TIMEOUT), "DTLS1_HANDLE_TIMEOUT"}, {ERR_FUNC(SSL_F_DTLS1_HEARTBEAT), "DTLS1_HEARTBEAT"}, {ERR_FUNC(SSL_F_DTLS1_OUTPUT_CERT_CHAIN), "DTLS1_OUTPUT_CERT_CHAIN"}, {ERR_FUNC(SSL_F_DTLS1_PREPROCESS_FRAGMENT), "DTLS1_PREPROCESS_FRAGMENT"}, {ERR_FUNC(SSL_F_DTLS1_PROCESS_OUT_OF_SEQ_MESSAGE), "DTLS1_PROCESS_OUT_OF_SEQ_MESSAGE"}, {ERR_FUNC(SSL_F_DTLS1_PROCESS_RECORD), "DTLS1_PROCESS_RECORD"}, {ERR_FUNC(SSL_F_DTLS1_READ_BYTES), "DTLS1_READ_BYTES"}, {ERR_FUNC(SSL_F_DTLS1_READ_FAILED), "DTLS1_READ_FAILED"}, {ERR_FUNC(SSL_F_DTLS1_SEND_CERTIFICATE_REQUEST), "DTLS1_SEND_CERTIFICATE_REQUEST"}, {ERR_FUNC(SSL_F_DTLS1_SEND_CLIENT_CERTIFICATE), "DTLS1_SEND_CLIENT_CERTIFICATE"}, {ERR_FUNC(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE), "DTLS1_SEND_CLIENT_KEY_EXCHANGE"}, {ERR_FUNC(SSL_F_DTLS1_SEND_CLIENT_VERIFY), "DTLS1_SEND_CLIENT_VERIFY"}, {ERR_FUNC(SSL_F_DTLS1_SEND_HELLO_VERIFY_REQUEST), "DTLS1_SEND_HELLO_VERIFY_REQUEST"}, {ERR_FUNC(SSL_F_DTLS1_SEND_SERVER_CERTIFICATE), "DTLS1_SEND_SERVER_CERTIFICATE"}, {ERR_FUNC(SSL_F_DTLS1_SEND_SERVER_HELLO), "DTLS1_SEND_SERVER_HELLO"}, {ERR_FUNC(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE), "DTLS1_SEND_SERVER_KEY_EXCHANGE"}, {ERR_FUNC(SSL_F_DTLS1_WRITE_APP_DATA_BYTES), "DTLS1_WRITE_APP_DATA_BYTES"}, {ERR_FUNC(SSL_F_GET_CLIENT_FINISHED), "GET_CLIENT_FINISHED"}, {ERR_FUNC(SSL_F_GET_CLIENT_HELLO), "GET_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_GET_CLIENT_MASTER_KEY), "GET_CLIENT_MASTER_KEY"}, {ERR_FUNC(SSL_F_GET_SERVER_FINISHED), "GET_SERVER_FINISHED"}, {ERR_FUNC(SSL_F_GET_SERVER_HELLO), "GET_SERVER_HELLO"}, {ERR_FUNC(SSL_F_GET_SERVER_VERIFY), "GET_SERVER_VERIFY"}, {ERR_FUNC(SSL_F_I2D_SSL_SESSION), "i2d_SSL_SESSION"}, {ERR_FUNC(SSL_F_READ_N), "READ_N"}, {ERR_FUNC(SSL_F_REQUEST_CERTIFICATE), "REQUEST_CERTIFICATE"}, {ERR_FUNC(SSL_F_SERVER_FINISH), "SERVER_FINISH"}, {ERR_FUNC(SSL_F_SERVER_HELLO), "SERVER_HELLO"}, {ERR_FUNC(SSL_F_SERVER_VERIFY), "SERVER_VERIFY"}, {ERR_FUNC(SSL_F_SSL23_ACCEPT), "SSL23_ACCEPT"}, {ERR_FUNC(SSL_F_SSL23_CLIENT_HELLO), "SSL23_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL23_CONNECT), "SSL23_CONNECT"}, {ERR_FUNC(SSL_F_SSL23_GET_CLIENT_HELLO), "SSL23_GET_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL23_GET_SERVER_HELLO), "SSL23_GET_SERVER_HELLO"}, {ERR_FUNC(SSL_F_SSL23_PEEK), "SSL23_PEEK"}, {ERR_FUNC(SSL_F_SSL23_READ), "SSL23_READ"}, {ERR_FUNC(SSL_F_SSL23_WRITE), "SSL23_WRITE"}, {ERR_FUNC(SSL_F_SSL2_ACCEPT), "SSL2_ACCEPT"}, {ERR_FUNC(SSL_F_SSL2_CONNECT), "SSL2_CONNECT"}, {ERR_FUNC(SSL_F_SSL2_ENC_INIT), "SSL2_ENC_INIT"}, {ERR_FUNC(SSL_F_SSL2_GENERATE_KEY_MATERIAL), "SSL2_GENERATE_KEY_MATERIAL"}, {ERR_FUNC(SSL_F_SSL2_PEEK), "SSL2_PEEK"}, {ERR_FUNC(SSL_F_SSL2_READ), "SSL2_READ"}, {ERR_FUNC(SSL_F_SSL2_READ_INTERNAL), "SSL2_READ_INTERNAL"}, {ERR_FUNC(SSL_F_SSL2_SET_CERTIFICATE), "SSL2_SET_CERTIFICATE"}, {ERR_FUNC(SSL_F_SSL2_WRITE), "SSL2_WRITE"}, {ERR_FUNC(SSL_F_SSL3_ACCEPT), "SSL3_ACCEPT"}, {ERR_FUNC(SSL_F_SSL3_ADD_CERT_TO_BUF), "SSL3_ADD_CERT_TO_BUF"}, {ERR_FUNC(SSL_F_SSL3_CALLBACK_CTRL), "SSL3_CALLBACK_CTRL"}, {ERR_FUNC(SSL_F_SSL3_CHANGE_CIPHER_STATE), "SSL3_CHANGE_CIPHER_STATE"}, {ERR_FUNC(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM), "SSL3_CHECK_CERT_AND_ALGORITHM"}, {ERR_FUNC(SSL_F_SSL3_CHECK_CLIENT_HELLO), "SSL3_CHECK_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_CLIENT_HELLO), "SSL3_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_CONNECT), "SSL3_CONNECT"}, {ERR_FUNC(SSL_F_SSL3_CTRL), "SSL3_CTRL"}, {ERR_FUNC(SSL_F_SSL3_CTX_CTRL), "SSL3_CTX_CTRL"}, {ERR_FUNC(SSL_F_SSL3_DIGEST_CACHED_RECORDS), "SSL3_DIGEST_CACHED_RECORDS"}, {ERR_FUNC(SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC), "SSL3_DO_CHANGE_CIPHER_SPEC"}, {ERR_FUNC(SSL_F_SSL3_ENC), "SSL3_ENC"}, {ERR_FUNC(SSL_F_SSL3_GENERATE_KEY_BLOCK), "SSL3_GENERATE_KEY_BLOCK"}, {ERR_FUNC(SSL_F_SSL3_GET_CERTIFICATE_REQUEST), "SSL3_GET_CERTIFICATE_REQUEST"}, {ERR_FUNC(SSL_F_SSL3_GET_CERT_STATUS), "SSL3_GET_CERT_STATUS"}, {ERR_FUNC(SSL_F_SSL3_GET_CERT_VERIFY), "SSL3_GET_CERT_VERIFY"}, {ERR_FUNC(SSL_F_SSL3_GET_CLIENT_CERTIFICATE), "SSL3_GET_CLIENT_CERTIFICATE"}, {ERR_FUNC(SSL_F_SSL3_GET_CLIENT_HELLO), "SSL3_GET_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE), "SSL3_GET_CLIENT_KEY_EXCHANGE"}, {ERR_FUNC(SSL_F_SSL3_GET_FINISHED), "SSL3_GET_FINISHED"}, {ERR_FUNC(SSL_F_SSL3_GET_KEY_EXCHANGE), "SSL3_GET_KEY_EXCHANGE"}, {ERR_FUNC(SSL_F_SSL3_GET_MESSAGE), "SSL3_GET_MESSAGE"}, {ERR_FUNC(SSL_F_SSL3_GET_NEW_SESSION_TICKET), "SSL3_GET_NEW_SESSION_TICKET"}, {ERR_FUNC(SSL_F_SSL3_GET_NEXT_PROTO), "SSL3_GET_NEXT_PROTO"}, {ERR_FUNC(SSL_F_SSL3_GET_RECORD), "SSL3_GET_RECORD"}, {ERR_FUNC(SSL_F_SSL3_GET_SERVER_CERTIFICATE), "SSL3_GET_SERVER_CERTIFICATE"}, {ERR_FUNC(SSL_F_SSL3_GET_SERVER_DONE), "SSL3_GET_SERVER_DONE"}, {ERR_FUNC(SSL_F_SSL3_GET_SERVER_HELLO), "SSL3_GET_SERVER_HELLO"}, {ERR_FUNC(SSL_F_SSL3_HANDSHAKE_MAC), "ssl3_handshake_mac"}, {ERR_FUNC(SSL_F_SSL3_NEW_SESSION_TICKET), "SSL3_NEW_SESSION_TICKET"}, {ERR_FUNC(SSL_F_SSL3_OUTPUT_CERT_CHAIN), "SSL3_OUTPUT_CERT_CHAIN"}, {ERR_FUNC(SSL_F_SSL3_PEEK), "SSL3_PEEK"}, {ERR_FUNC(SSL_F_SSL3_READ_BYTES), "SSL3_READ_BYTES"}, {ERR_FUNC(SSL_F_SSL3_READ_N), "SSL3_READ_N"}, {ERR_FUNC(SSL_F_SSL3_SEND_CERTIFICATE_REQUEST), "SSL3_SEND_CERTIFICATE_REQUEST"}, {ERR_FUNC(SSL_F_SSL3_SEND_CLIENT_CERTIFICATE), "SSL3_SEND_CLIENT_CERTIFICATE"}, {ERR_FUNC(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE), "SSL3_SEND_CLIENT_KEY_EXCHANGE"}, {ERR_FUNC(SSL_F_SSL3_SEND_CLIENT_VERIFY), "SSL3_SEND_CLIENT_VERIFY"}, {ERR_FUNC(SSL_F_SSL3_SEND_SERVER_CERTIFICATE), "SSL3_SEND_SERVER_CERTIFICATE"}, {ERR_FUNC(SSL_F_SSL3_SEND_SERVER_HELLO), "SSL3_SEND_SERVER_HELLO"}, {ERR_FUNC(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE), "SSL3_SEND_SERVER_KEY_EXCHANGE"}, {ERR_FUNC(SSL_F_SSL3_SETUP_KEY_BLOCK), "SSL3_SETUP_KEY_BLOCK"}, {ERR_FUNC(SSL_F_SSL3_SETUP_READ_BUFFER), "SSL3_SETUP_READ_BUFFER"}, {ERR_FUNC(SSL_F_SSL3_SETUP_WRITE_BUFFER), "SSL3_SETUP_WRITE_BUFFER"}, {ERR_FUNC(SSL_F_SSL3_WRITE_BYTES), "SSL3_WRITE_BYTES"}, {ERR_FUNC(SSL_F_SSL3_WRITE_PENDING), "SSL3_WRITE_PENDING"}, {ERR_FUNC(SSL_F_SSL_ADD_CLIENTHELLO_RENEGOTIATE_EXT), "SSL_ADD_CLIENTHELLO_RENEGOTIATE_EXT"}, {ERR_FUNC(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT), "SSL_ADD_CLIENTHELLO_TLSEXT"}, {ERR_FUNC(SSL_F_SSL_ADD_CLIENTHELLO_USE_SRTP_EXT), "SSL_ADD_CLIENTHELLO_USE_SRTP_EXT"}, {ERR_FUNC(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK), "SSL_add_dir_cert_subjects_to_stack"}, {ERR_FUNC(SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK), "SSL_add_file_cert_subjects_to_stack"}, {ERR_FUNC(SSL_F_SSL_ADD_SERVERHELLO_RENEGOTIATE_EXT), "SSL_ADD_SERVERHELLO_RENEGOTIATE_EXT"}, {ERR_FUNC(SSL_F_SSL_ADD_SERVERHELLO_TLSEXT), "SSL_ADD_SERVERHELLO_TLSEXT"}, {ERR_FUNC(SSL_F_SSL_ADD_SERVERHELLO_USE_SRTP_EXT), "SSL_ADD_SERVERHELLO_USE_SRTP_EXT"}, {ERR_FUNC(SSL_F_SSL_BAD_METHOD), "SSL_BAD_METHOD"}, {ERR_FUNC(SSL_F_SSL_BYTES_TO_CIPHER_LIST), "SSL_BYTES_TO_CIPHER_LIST"}, {ERR_FUNC(SSL_F_SSL_CERT_DUP), "SSL_CERT_DUP"}, {ERR_FUNC(SSL_F_SSL_CERT_INST), "SSL_CERT_INST"}, {ERR_FUNC(SSL_F_SSL_CERT_INSTANTIATE), "SSL_CERT_INSTANTIATE"}, {ERR_FUNC(SSL_F_SSL_CERT_NEW), "SSL_CERT_NEW"}, {ERR_FUNC(SSL_F_SSL_CHECK_PRIVATE_KEY), "SSL_check_private_key"}, {ERR_FUNC(SSL_F_SSL_CHECK_SERVERHELLO_TLSEXT), "SSL_CHECK_SERVERHELLO_TLSEXT"}, {ERR_FUNC(SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG), "SSL_CHECK_SRVR_ECC_CERT_AND_ALG"}, {ERR_FUNC(SSL_F_SSL_CIPHER_PROCESS_RULESTR), "SSL_CIPHER_PROCESS_RULESTR"}, {ERR_FUNC(SSL_F_SSL_CIPHER_STRENGTH_SORT), "SSL_CIPHER_STRENGTH_SORT"}, {ERR_FUNC(SSL_F_SSL_CLEAR), "SSL_clear"}, {ERR_FUNC(SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD), "SSL_COMP_add_compression_method"}, {ERR_FUNC(SSL_F_SSL_CREATE_CIPHER_LIST), "SSL_CREATE_CIPHER_LIST"}, {ERR_FUNC(SSL_F_SSL_CTRL), "SSL_ctrl"}, {ERR_FUNC(SSL_F_SSL_CTX_CHECK_PRIVATE_KEY), "SSL_CTX_check_private_key"}, {ERR_FUNC(SSL_F_SSL_CTX_MAKE_PROFILES), "SSL_CTX_MAKE_PROFILES"}, {ERR_FUNC(SSL_F_SSL_CTX_NEW), "SSL_CTX_new"}, {ERR_FUNC(SSL_F_SSL_CTX_SET_CIPHER_LIST), "SSL_CTX_set_cipher_list"}, {ERR_FUNC(SSL_F_SSL_CTX_SET_CLIENT_CERT_ENGINE), "SSL_CTX_set_client_cert_engine"}, {ERR_FUNC(SSL_F_SSL_CTX_SET_PURPOSE), "SSL_CTX_set_purpose"}, {ERR_FUNC(SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT), "SSL_CTX_set_session_id_context"}, {ERR_FUNC(SSL_F_SSL_CTX_SET_SSL_VERSION), "SSL_CTX_set_ssl_version"}, {ERR_FUNC(SSL_F_SSL_CTX_SET_TRUST), "SSL_CTX_set_trust"}, {ERR_FUNC(SSL_F_SSL_CTX_USE_CERTIFICATE), "SSL_CTX_use_certificate"}, {ERR_FUNC(SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1), "SSL_CTX_use_certificate_ASN1"}, {ERR_FUNC(SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE), "SSL_CTX_use_certificate_chain_file"}, {ERR_FUNC(SSL_F_SSL_CTX_USE_CERTIFICATE_FILE), "SSL_CTX_use_certificate_file"}, {ERR_FUNC(SSL_F_SSL_CTX_USE_PRIVATEKEY), "SSL_CTX_use_PrivateKey"}, {ERR_FUNC(SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1), "SSL_CTX_use_PrivateKey_ASN1"}, {ERR_FUNC(SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE), "SSL_CTX_use_PrivateKey_file"}, {ERR_FUNC(SSL_F_SSL_CTX_USE_PSK_IDENTITY_HINT), "SSL_CTX_use_psk_identity_hint"}, {ERR_FUNC(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY), "SSL_CTX_use_RSAPrivateKey"}, {ERR_FUNC(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1), "SSL_CTX_use_RSAPrivateKey_ASN1"}, {ERR_FUNC(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE), "SSL_CTX_use_RSAPrivateKey_file"}, {ERR_FUNC(SSL_F_SSL_DO_HANDSHAKE), "SSL_do_handshake"}, {ERR_FUNC(SSL_F_SSL_GET_NEW_SESSION), "SSL_GET_NEW_SESSION"}, {ERR_FUNC(SSL_F_SSL_GET_PREV_SESSION), "SSL_GET_PREV_SESSION"}, {ERR_FUNC(SSL_F_SSL_GET_SERVER_SEND_CERT), "SSL_GET_SERVER_SEND_CERT"}, {ERR_FUNC(SSL_F_SSL_GET_SERVER_SEND_PKEY), "SSL_GET_SERVER_SEND_PKEY"}, {ERR_FUNC(SSL_F_SSL_GET_SIGN_PKEY), "SSL_GET_SIGN_PKEY"}, {ERR_FUNC(SSL_F_SSL_INIT_WBIO_BUFFER), "SSL_INIT_WBIO_BUFFER"}, {ERR_FUNC(SSL_F_SSL_LOAD_CLIENT_CA_FILE), "SSL_load_client_CA_file"}, {ERR_FUNC(SSL_F_SSL_NEW), "SSL_new"}, {ERR_FUNC(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT), "SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT"}, {ERR_FUNC(SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT), "SSL_PARSE_CLIENTHELLO_TLSEXT"}, {ERR_FUNC(SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT), "SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT"}, {ERR_FUNC(SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT), "SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT"}, {ERR_FUNC(SSL_F_SSL_PARSE_SERVERHELLO_TLSEXT), "SSL_PARSE_SERVERHELLO_TLSEXT"}, {ERR_FUNC(SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT), "SSL_PARSE_SERVERHELLO_USE_SRTP_EXT"}, {ERR_FUNC(SSL_F_SSL_PEEK), "SSL_peek"}, {ERR_FUNC(SSL_F_SSL_PREPARE_CLIENTHELLO_TLSEXT), "SSL_PREPARE_CLIENTHELLO_TLSEXT"}, {ERR_FUNC(SSL_F_SSL_PREPARE_SERVERHELLO_TLSEXT), "SSL_PREPARE_SERVERHELLO_TLSEXT"}, {ERR_FUNC(SSL_F_SSL_READ), "SSL_read"}, {ERR_FUNC(SSL_F_SSL_RSA_PRIVATE_DECRYPT), "SSL_RSA_PRIVATE_DECRYPT"}, {ERR_FUNC(SSL_F_SSL_RSA_PUBLIC_ENCRYPT), "SSL_RSA_PUBLIC_ENCRYPT"}, {ERR_FUNC(SSL_F_SSL_SESSION_NEW), "SSL_SESSION_new"}, {ERR_FUNC(SSL_F_SSL_SESSION_PRINT_FP), "SSL_SESSION_print_fp"}, {ERR_FUNC(SSL_F_SSL_SESSION_SET1_ID_CONTEXT), "SSL_SESSION_set1_id_context"}, {ERR_FUNC(SSL_F_SSL_SESS_CERT_NEW), "SSL_SESS_CERT_NEW"}, {ERR_FUNC(SSL_F_SSL_SET_CERT), "SSL_SET_CERT"}, {ERR_FUNC(SSL_F_SSL_SET_CIPHER_LIST), "SSL_set_cipher_list"}, {ERR_FUNC(SSL_F_SSL_SET_FD), "SSL_set_fd"}, {ERR_FUNC(SSL_F_SSL_SET_PKEY), "SSL_SET_PKEY"}, {ERR_FUNC(SSL_F_SSL_SET_PURPOSE), "SSL_set_purpose"}, {ERR_FUNC(SSL_F_SSL_SET_RFD), "SSL_set_rfd"}, {ERR_FUNC(SSL_F_SSL_SET_SESSION), "SSL_set_session"}, {ERR_FUNC(SSL_F_SSL_SET_SESSION_ID_CONTEXT), "SSL_set_session_id_context"}, {ERR_FUNC(SSL_F_SSL_SET_SESSION_TICKET_EXT), "SSL_set_session_ticket_ext"}, {ERR_FUNC(SSL_F_SSL_SET_TRUST), "SSL_set_trust"}, {ERR_FUNC(SSL_F_SSL_SET_WFD), "SSL_set_wfd"}, {ERR_FUNC(SSL_F_SSL_SHUTDOWN), "SSL_shutdown"}, {ERR_FUNC(SSL_F_SSL_SRP_CTX_INIT), "SSL_SRP_CTX_init"}, {ERR_FUNC(SSL_F_SSL_UNDEFINED_CONST_FUNCTION), "SSL_UNDEFINED_CONST_FUNCTION"}, {ERR_FUNC(SSL_F_SSL_UNDEFINED_FUNCTION), "SSL_UNDEFINED_FUNCTION"}, {ERR_FUNC(SSL_F_SSL_UNDEFINED_VOID_FUNCTION), "SSL_UNDEFINED_VOID_FUNCTION"}, {ERR_FUNC(SSL_F_SSL_USE_CERTIFICATE), "SSL_use_certificate"}, {ERR_FUNC(SSL_F_SSL_USE_CERTIFICATE_ASN1), "SSL_use_certificate_ASN1"}, {ERR_FUNC(SSL_F_SSL_USE_CERTIFICATE_FILE), "SSL_use_certificate_file"}, {ERR_FUNC(SSL_F_SSL_USE_PRIVATEKEY), "SSL_use_PrivateKey"}, {ERR_FUNC(SSL_F_SSL_USE_PRIVATEKEY_ASN1), "SSL_use_PrivateKey_ASN1"}, {ERR_FUNC(SSL_F_SSL_USE_PRIVATEKEY_FILE), "SSL_use_PrivateKey_file"}, {ERR_FUNC(SSL_F_SSL_USE_PSK_IDENTITY_HINT), "SSL_use_psk_identity_hint"}, {ERR_FUNC(SSL_F_SSL_USE_RSAPRIVATEKEY), "SSL_use_RSAPrivateKey"}, {ERR_FUNC(SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1), "SSL_use_RSAPrivateKey_ASN1"}, {ERR_FUNC(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE), "SSL_use_RSAPrivateKey_file"}, {ERR_FUNC(SSL_F_SSL_VERIFY_CERT_CHAIN), "SSL_VERIFY_CERT_CHAIN"}, {ERR_FUNC(SSL_F_SSL_WRITE), "SSL_write"}, {ERR_FUNC(SSL_F_TLS1_AEAD_CTX_INIT), "TLS1_AEAD_CTX_INIT"}, {ERR_FUNC(SSL_F_TLS1_CERT_VERIFY_MAC), "tls1_cert_verify_mac"}, {ERR_FUNC(SSL_F_TLS1_CHANGE_CIPHER_STATE), "TLS1_CHANGE_CIPHER_STATE"}, {ERR_FUNC(SSL_F_TLS1_CHANGE_CIPHER_STATE_AEAD), "TLS1_CHANGE_CIPHER_STATE_AEAD"}, {ERR_FUNC(SSL_F_TLS1_CHANGE_CIPHER_STATE_CIPHER), "TLS1_CHANGE_CIPHER_STATE_CIPHER"}, {ERR_FUNC(SSL_F_TLS1_CHECK_SERVERHELLO_TLSEXT), "TLS1_CHECK_SERVERHELLO_TLSEXT"}, {ERR_FUNC(SSL_F_TLS1_ENC), "TLS1_ENC"}, {ERR_FUNC(SSL_F_TLS1_EXPORT_KEYING_MATERIAL), "TLS1_EXPORT_KEYING_MATERIAL"}, {ERR_FUNC(SSL_F_TLS1_HEARTBEAT), "SSL_F_TLS1_HEARTBEAT"}, {ERR_FUNC(SSL_F_TLS1_PREPARE_CLIENTHELLO_TLSEXT), "TLS1_PREPARE_CLIENTHELLO_TLSEXT"}, {ERR_FUNC(SSL_F_TLS1_PREPARE_SERVERHELLO_TLSEXT), "TLS1_PREPARE_SERVERHELLO_TLSEXT"}, {ERR_FUNC(SSL_F_TLS1_PRF), "tls1_prf"}, {ERR_FUNC(SSL_F_TLS1_SETUP_KEY_BLOCK), "TLS1_SETUP_KEY_BLOCK"}, {ERR_FUNC(SSL_F_WRITE_PENDING), "WRITE_PENDING"}, {0, NULL} }; static ERR_STRING_DATA SSL_str_reasons[]= { {ERR_REASON(SSL_R_APP_DATA_IN_HANDSHAKE) , "app data in handshake"}, {ERR_REASON(SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT), "attempt to reuse session in different context"}, {ERR_REASON(SSL_R_BAD_ALERT_RECORD) , "bad alert record"}, {ERR_REASON(SSL_R_BAD_AUTHENTICATION_TYPE), "bad authentication type"}, {ERR_REASON(SSL_R_BAD_CHANGE_CIPHER_SPEC), "bad change cipher spec"}, {ERR_REASON(SSL_R_BAD_CHECKSUM) , "bad checksum"}, {ERR_REASON(SSL_R_BAD_DATA_RETURNED_BY_CALLBACK), "bad data returned by callback"}, {ERR_REASON(SSL_R_BAD_DECOMPRESSION) , "bad decompression"}, {ERR_REASON(SSL_R_BAD_DH_G_LENGTH) , "bad dh g length"}, {ERR_REASON(SSL_R_BAD_DH_PUB_KEY_LENGTH) , "bad dh pub key length"}, {ERR_REASON(SSL_R_BAD_DH_P_LENGTH) , "bad dh p length"}, {ERR_REASON(SSL_R_BAD_DIGEST_LENGTH) , "bad digest length"}, {ERR_REASON(SSL_R_BAD_DSA_SIGNATURE) , "bad dsa signature"}, {ERR_REASON(SSL_R_BAD_ECC_CERT) , "bad ecc cert"}, {ERR_REASON(SSL_R_BAD_ECDSA_SIGNATURE) , "bad ecdsa signature"}, {ERR_REASON(SSL_R_BAD_ECPOINT) , "bad ecpoint"}, {ERR_REASON(SSL_R_BAD_HANDSHAKE_LENGTH) , "bad handshake length"}, {ERR_REASON(SSL_R_BAD_HELLO_REQUEST) , "bad hello request"}, {ERR_REASON(SSL_R_BAD_LENGTH) , "bad length"}, {ERR_REASON(SSL_R_BAD_MAC_DECODE) , "bad mac decode"}, {ERR_REASON(SSL_R_BAD_MAC_LENGTH) , "bad mac length"}, {ERR_REASON(SSL_R_BAD_MESSAGE_TYPE) , "bad message type"}, {ERR_REASON(SSL_R_BAD_PACKET_LENGTH) , "bad packet length"}, {ERR_REASON(SSL_R_BAD_PROTOCOL_VERSION_NUMBER), "bad protocol version number"}, {ERR_REASON(SSL_R_BAD_PSK_IDENTITY_HINT_LENGTH), "bad psk identity hint length"}, {ERR_REASON(SSL_R_BAD_RESPONSE_ARGUMENT) , "bad response argument"}, {ERR_REASON(SSL_R_BAD_RSA_DECRYPT) , "bad rsa decrypt"}, {ERR_REASON(SSL_R_BAD_RSA_ENCRYPT) , "bad rsa encrypt"}, {ERR_REASON(SSL_R_BAD_RSA_E_LENGTH) , "bad rsa e length"}, {ERR_REASON(SSL_R_BAD_RSA_MODULUS_LENGTH), "bad rsa modulus length"}, {ERR_REASON(SSL_R_BAD_RSA_SIGNATURE) , "bad rsa signature"}, {ERR_REASON(SSL_R_BAD_SIGNATURE) , "bad signature"}, {ERR_REASON(SSL_R_BAD_SRP_A_LENGTH) , "bad srp a length"}, {ERR_REASON(SSL_R_BAD_SRP_B_LENGTH) , "bad srp b length"}, {ERR_REASON(SSL_R_BAD_SRP_G_LENGTH) , "bad srp g length"}, {ERR_REASON(SSL_R_BAD_SRP_N_LENGTH) , "bad srp n length"}, {ERR_REASON(SSL_R_BAD_SRP_S_LENGTH) , "bad srp s length"}, {ERR_REASON(SSL_R_BAD_SRTP_MKI_VALUE) , "bad srtp mki value"}, {ERR_REASON(SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST), "bad srtp protection profile list"}, {ERR_REASON(SSL_R_BAD_SSL_FILETYPE) , "bad ssl filetype"}, {ERR_REASON(SSL_R_BAD_SSL_SESSION_ID_LENGTH), "bad ssl session id length"}, {ERR_REASON(SSL_R_BAD_STATE) , "bad state"}, {ERR_REASON(SSL_R_BAD_WRITE_RETRY) , "bad write retry"}, {ERR_REASON(SSL_R_BIO_NOT_SET) , "bio not set"}, {ERR_REASON(SSL_R_BLOCK_CIPHER_PAD_IS_WRONG), "block cipher pad is wrong"}, {ERR_REASON(SSL_R_BN_LIB) , "bn lib"}, {ERR_REASON(SSL_R_CA_DN_LENGTH_MISMATCH) , "ca dn length mismatch"}, {ERR_REASON(SSL_R_CA_DN_TOO_LONG) , "ca dn too long"}, {ERR_REASON(SSL_R_CCS_RECEIVED_EARLY) , "ccs received early"}, {ERR_REASON(SSL_R_CERTIFICATE_VERIFY_FAILED), "certificate verify failed"}, {ERR_REASON(SSL_R_CERT_LENGTH_MISMATCH) , "cert length mismatch"}, {ERR_REASON(SSL_R_CHALLENGE_IS_DIFFERENT), "challenge is different"}, {ERR_REASON(SSL_R_CIPHER_CODE_WRONG_LENGTH), "cipher code wrong length"}, {ERR_REASON(SSL_R_CIPHER_COMPRESSION_UNAVAILABLE), "cipher compression unavailable"}, {ERR_REASON(SSL_R_CIPHER_OR_HASH_UNAVAILABLE), "cipher or hash unavailable"}, {ERR_REASON(SSL_R_CIPHER_TABLE_SRC_ERROR), "cipher table src error"}, {ERR_REASON(SSL_R_CLIENTHELLO_TLSEXT) , "clienthello tlsext"}, {ERR_REASON(SSL_R_COMPRESSED_LENGTH_TOO_LONG), "compressed length too long"}, {ERR_REASON(SSL_R_COMPRESSION_DISABLED) , "compression disabled"}, {ERR_REASON(SSL_R_COMPRESSION_FAILURE) , "compression failure"}, {ERR_REASON(SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE), "compression id not within private range"}, {ERR_REASON(SSL_R_COMPRESSION_LIBRARY_ERROR), "compression library error"}, {ERR_REASON(SSL_R_CONNECTION_ID_IS_DIFFERENT), "connection id is different"}, {ERR_REASON(SSL_R_CONNECTION_TYPE_NOT_SET), "connection type not set"}, {ERR_REASON(SSL_R_COOKIE_MISMATCH) , "cookie mismatch"}, {ERR_REASON(SSL_R_DATA_BETWEEN_CCS_AND_FINISHED), "data between ccs and finished"}, {ERR_REASON(SSL_R_DATA_LENGTH_TOO_LONG) , "data length too long"}, {ERR_REASON(SSL_R_DECRYPTION_FAILED) , "decryption failed"}, {ERR_REASON(SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC), "decryption failed or bad record mac"}, {ERR_REASON(SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG), "dh public value length is wrong"}, {ERR_REASON(SSL_R_DIGEST_CHECK_FAILED) , "digest check failed"}, {ERR_REASON(SSL_R_DTLS_MESSAGE_TOO_BIG) , "dtls message too big"}, {ERR_REASON(SSL_R_DUPLICATE_COMPRESSION_ID), "duplicate compression id"}, {ERR_REASON(SSL_R_ECC_CERT_NOT_FOR_KEY_AGREEMENT), "ecc cert not for key agreement"}, {ERR_REASON(SSL_R_ECC_CERT_NOT_FOR_SIGNING), "ecc cert not for signing"}, {ERR_REASON(SSL_R_ECC_CERT_SHOULD_HAVE_RSA_SIGNATURE), "ecc cert should have rsa signature"}, {ERR_REASON(SSL_R_ECC_CERT_SHOULD_HAVE_SHA1_SIGNATURE), "ecc cert should have sha1 signature"}, {ERR_REASON(SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER), "ecgroup too large for cipher"}, {ERR_REASON(SSL_R_EMPTY_SRTP_PROTECTION_PROFILE_LIST), "empty srtp protection profile list"}, {ERR_REASON(SSL_R_ENCRYPTED_LENGTH_TOO_LONG), "encrypted length too long"}, {ERR_REASON(SSL_R_ERROR_GENERATING_TMP_RSA_KEY), "error generating tmp rsa key"}, {ERR_REASON(SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST), "error in received cipher list"}, {ERR_REASON(SSL_R_EXCESSIVE_MESSAGE_SIZE), "excessive message size"}, {ERR_REASON(SSL_R_EXTRA_DATA_IN_MESSAGE) , "extra data in message"}, {ERR_REASON(SSL_R_GOT_A_FIN_BEFORE_A_CCS), "got a fin before a ccs"}, {ERR_REASON(SSL_R_GOT_NEXT_PROTO_BEFORE_A_CCS), "got next proto before a ccs"}, {ERR_REASON(SSL_R_GOT_NEXT_PROTO_WITHOUT_EXTENSION), "got next proto without seeing extension"}, {ERR_REASON(SSL_R_HTTPS_PROXY_REQUEST) , "https proxy request"}, {ERR_REASON(SSL_R_HTTP_REQUEST) , "http request"}, {ERR_REASON(SSL_R_ILLEGAL_PADDING) , "illegal padding"}, {ERR_REASON(SSL_R_INCONSISTENT_COMPRESSION), "inconsistent compression"}, {ERR_REASON(SSL_R_INVALID_CHALLENGE_LENGTH), "invalid challenge length"}, {ERR_REASON(SSL_R_INVALID_COMMAND) , "invalid command"}, {ERR_REASON(SSL_R_INVALID_COMPRESSION_ALGORITHM), "invalid compression algorithm"}, {ERR_REASON(SSL_R_INVALID_PURPOSE) , "invalid purpose"}, {ERR_REASON(SSL_R_INVALID_SRP_USERNAME) , "invalid srp username"}, {ERR_REASON(SSL_R_INVALID_STATUS_RESPONSE), "invalid status response"}, {ERR_REASON(SSL_R_INVALID_TICKET_KEYS_LENGTH), "invalid ticket keys length"}, {ERR_REASON(SSL_R_INVALID_TRUST) , "invalid trust"}, {ERR_REASON(SSL_R_KEY_ARG_TOO_LONG) , "key arg too long"}, {ERR_REASON(SSL_R_KRB5) , "krb5"}, {ERR_REASON(SSL_R_KRB5_C_CC_PRINC) , "krb5 client cc principal (no tkt?)"}, {ERR_REASON(SSL_R_KRB5_C_GET_CRED) , "krb5 client get cred"}, {ERR_REASON(SSL_R_KRB5_C_INIT) , "krb5 client init"}, {ERR_REASON(SSL_R_KRB5_C_MK_REQ) , "krb5 client mk_req (expired tkt?)"}, {ERR_REASON(SSL_R_KRB5_S_BAD_TICKET) , "krb5 server bad ticket"}, {ERR_REASON(SSL_R_KRB5_S_INIT) , "krb5 server init"}, {ERR_REASON(SSL_R_KRB5_S_RD_REQ) , "krb5 server rd_req (keytab perms?)"}, {ERR_REASON(SSL_R_KRB5_S_TKT_EXPIRED) , "krb5 server tkt expired"}, {ERR_REASON(SSL_R_KRB5_S_TKT_NYV) , "krb5 server tkt not yet valid"}, {ERR_REASON(SSL_R_KRB5_S_TKT_SKEW) , "krb5 server tkt skew"}, {ERR_REASON(SSL_R_LENGTH_MISMATCH) , "length mismatch"}, {ERR_REASON(SSL_R_LENGTH_TOO_SHORT) , "length too short"}, {ERR_REASON(SSL_R_LIBRARY_BUG) , "library bug"}, {ERR_REASON(SSL_R_LIBRARY_HAS_NO_CIPHERS), "library has no ciphers"}, {ERR_REASON(SSL_R_MESSAGE_TOO_LONG) , "message too long"}, {ERR_REASON(SSL_R_MISSING_DH_DSA_CERT) , "missing dh dsa cert"}, {ERR_REASON(SSL_R_MISSING_DH_KEY) , "missing dh key"}, {ERR_REASON(SSL_R_MISSING_DH_RSA_CERT) , "missing dh rsa cert"}, {ERR_REASON(SSL_R_MISSING_DSA_SIGNING_CERT), "missing dsa signing cert"}, {ERR_REASON(SSL_R_MISSING_EXPORT_TMP_DH_KEY), "missing export tmp dh key"}, {ERR_REASON(SSL_R_MISSING_EXPORT_TMP_RSA_KEY), "missing export tmp rsa key"}, {ERR_REASON(SSL_R_MISSING_RSA_CERTIFICATE), "missing rsa certificate"}, {ERR_REASON(SSL_R_MISSING_RSA_ENCRYPTING_CERT), "missing rsa encrypting cert"}, {ERR_REASON(SSL_R_MISSING_RSA_SIGNING_CERT), "missing rsa signing cert"}, {ERR_REASON(SSL_R_MISSING_SRP_PARAM) , "can't find SRP server param"}, {ERR_REASON(SSL_R_MISSING_TMP_DH_KEY) , "missing tmp dh key"}, {ERR_REASON(SSL_R_MISSING_TMP_ECDH_KEY) , "missing tmp ecdh key"}, {ERR_REASON(SSL_R_MISSING_TMP_RSA_KEY) , "missing tmp rsa key"}, {ERR_REASON(SSL_R_MISSING_TMP_RSA_PKEY) , "missing tmp rsa pkey"}, {ERR_REASON(SSL_R_MISSING_VERIFY_MESSAGE), "missing verify message"}, {ERR_REASON(SSL_R_MULTIPLE_SGC_RESTARTS) , "multiple sgc restarts"}, {ERR_REASON(SSL_R_NON_SSLV2_INITIAL_PACKET), "non sslv2 initial packet"}, {ERR_REASON(SSL_R_NO_CERTIFICATES_RETURNED), "no certificates returned"}, {ERR_REASON(SSL_R_NO_CERTIFICATE_ASSIGNED), "no certificate assigned"}, {ERR_REASON(SSL_R_NO_CERTIFICATE_RETURNED), "no certificate returned"}, {ERR_REASON(SSL_R_NO_CERTIFICATE_SET) , "no certificate set"}, {ERR_REASON(SSL_R_NO_CERTIFICATE_SPECIFIED), "no certificate specified"}, {ERR_REASON(SSL_R_NO_CIPHERS_AVAILABLE) , "no ciphers available"}, {ERR_REASON(SSL_R_NO_CIPHERS_PASSED) , "no ciphers passed"}, {ERR_REASON(SSL_R_NO_CIPHERS_SPECIFIED) , "no ciphers specified"}, {ERR_REASON(SSL_R_NO_CIPHER_LIST) , "no cipher list"}, {ERR_REASON(SSL_R_NO_CIPHER_MATCH) , "no cipher match"}, {ERR_REASON(SSL_R_NO_CLIENT_CERT_METHOD) , "no client cert method"}, {ERR_REASON(SSL_R_NO_CLIENT_CERT_RECEIVED), "no client cert received"}, {ERR_REASON(SSL_R_NO_COMPRESSION_SPECIFIED), "no compression specified"}, {ERR_REASON(SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER), "Peer haven't sent GOST certificate, required for selected ciphersuite"}, {ERR_REASON(SSL_R_NO_METHOD_SPECIFIED) , "no method specified"}, {ERR_REASON(SSL_R_NO_PRIVATEKEY) , "no privatekey"}, {ERR_REASON(SSL_R_NO_PRIVATE_KEY_ASSIGNED), "no private key assigned"}, {ERR_REASON(SSL_R_NO_PROTOCOLS_AVAILABLE), "no protocols available"}, {ERR_REASON(SSL_R_NO_PUBLICKEY) , "no publickey"}, {ERR_REASON(SSL_R_NO_RENEGOTIATION) , "no renegotiation"}, {ERR_REASON(SSL_R_NO_REQUIRED_DIGEST) , "digest requred for handshake isn't computed"}, {ERR_REASON(SSL_R_NO_SHARED_CIPHER) , "no shared cipher"}, {ERR_REASON(SSL_R_NO_SRTP_PROFILES) , "no srtp profiles"}, {ERR_REASON(SSL_R_NO_VERIFY_CALLBACK) , "no verify callback"}, {ERR_REASON(SSL_R_NULL_SSL_CTX) , "null ssl ctx"}, {ERR_REASON(SSL_R_NULL_SSL_METHOD_PASSED), "null ssl method passed"}, {ERR_REASON(SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED), "old session cipher not returned"}, {ERR_REASON(SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED), "old session compression algorithm not returned"}, {ERR_REASON(SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE), "only tls allowed in fips mode"}, {ERR_REASON(SSL_R_PACKET_LENGTH_TOO_LONG), "packet length too long"}, {ERR_REASON(SSL_R_PARSE_TLSEXT) , "parse tlsext"}, {ERR_REASON(SSL_R_PATH_TOO_LONG) , "path too long"}, {ERR_REASON(SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE), "peer did not return a certificate"}, {ERR_REASON(SSL_R_PEER_ERROR) , "peer error"}, {ERR_REASON(SSL_R_PEER_ERROR_CERTIFICATE), "peer error certificate"}, {ERR_REASON(SSL_R_PEER_ERROR_NO_CERTIFICATE), "peer error no certificate"}, {ERR_REASON(SSL_R_PEER_ERROR_NO_CIPHER) , "peer error no cipher"}, {ERR_REASON(SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE), "peer error unsupported certificate type"}, {ERR_REASON(SSL_R_PRE_MAC_LENGTH_TOO_LONG), "pre mac length too long"}, {ERR_REASON(SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS), "problems mapping cipher functions"}, {ERR_REASON(SSL_R_PROTOCOL_IS_SHUTDOWN) , "protocol is shutdown"}, {ERR_REASON(SSL_R_PSK_IDENTITY_NOT_FOUND), "psk identity not found"}, {ERR_REASON(SSL_R_PSK_NO_CLIENT_CB) , "psk no client cb"}, {ERR_REASON(SSL_R_PSK_NO_SERVER_CB) , "psk no server cb"}, {ERR_REASON(SSL_R_PUBLIC_KEY_ENCRYPT_ERROR), "public key encrypt error"}, {ERR_REASON(SSL_R_PUBLIC_KEY_IS_NOT_RSA) , "public key is not rsa"}, {ERR_REASON(SSL_R_PUBLIC_KEY_NOT_RSA) , "public key not rsa"}, {ERR_REASON(SSL_R_READ_BIO_NOT_SET) , "read bio not set"}, {ERR_REASON(SSL_R_READ_TIMEOUT_EXPIRED) , "read timeout expired"}, {ERR_REASON(SSL_R_READ_WRONG_PACKET_TYPE), "read wrong packet type"}, {ERR_REASON(SSL_R_RECORD_LENGTH_MISMATCH), "record length mismatch"}, {ERR_REASON(SSL_R_RECORD_TOO_LARGE) , "record too large"}, {ERR_REASON(SSL_R_RECORD_TOO_SMALL) , "record too small"}, {ERR_REASON(SSL_R_RENEGOTIATE_EXT_TOO_LONG), "renegotiate ext too long"}, {ERR_REASON(SSL_R_RENEGOTIATION_ENCODING_ERR), "renegotiation encoding err"}, {ERR_REASON(SSL_R_RENEGOTIATION_MISMATCH), "renegotiation mismatch"}, {ERR_REASON(SSL_R_REQUIRED_CIPHER_MISSING), "required cipher missing"}, {ERR_REASON(SSL_R_REQUIRED_COMPRESSSION_ALGORITHM_MISSING), "required compresssion algorithm missing"}, {ERR_REASON(SSL_R_REUSE_CERT_LENGTH_NOT_ZERO), "reuse cert length not zero"}, {ERR_REASON(SSL_R_REUSE_CERT_TYPE_NOT_ZERO), "reuse cert type not zero"}, {ERR_REASON(SSL_R_REUSE_CIPHER_LIST_NOT_ZERO), "reuse cipher list not zero"}, {ERR_REASON(SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING), "scsv received when renegotiating"}, {ERR_REASON(SSL_R_SERVERHELLO_TLSEXT) , "serverhello tlsext"}, {ERR_REASON(SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED), "session id context uninitialized"}, {ERR_REASON(SSL_R_SHORT_READ) , "short read"}, {ERR_REASON(SSL_R_SIGNATURE_ALGORITHMS_ERROR), "signature algorithms error"}, {ERR_REASON(SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE), "signature for non signing certificate"}, {ERR_REASON(SSL_R_SRP_A_CALC) , "error with the srp params"}, {ERR_REASON(SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES), "srtp could not allocate profiles"}, {ERR_REASON(SSL_R_SRTP_PROTECTION_PROFILE_LIST_TOO_LONG), "srtp protection profile list too long"}, {ERR_REASON(SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE), "srtp unknown protection profile"}, {ERR_REASON(SSL_R_SSL23_DOING_SESSION_ID_REUSE), "ssl23 doing session id reuse"}, {ERR_REASON(SSL_R_SSL2_CONNECTION_ID_TOO_LONG), "ssl2 connection id too long"}, {ERR_REASON(SSL_R_SSL3_EXT_INVALID_ECPOINTFORMAT), "ssl3 ext invalid ecpointformat"}, {ERR_REASON(SSL_R_SSL3_EXT_INVALID_SERVERNAME), "ssl3 ext invalid servername"}, {ERR_REASON(SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE), "ssl3 ext invalid servername type"}, {ERR_REASON(SSL_R_SSL3_SESSION_ID_TOO_LONG), "ssl3 session id too long"}, {ERR_REASON(SSL_R_SSL3_SESSION_ID_TOO_SHORT), "ssl3 session id too short"}, {ERR_REASON(SSL_R_SSLV3_ALERT_BAD_CERTIFICATE), "sslv3 alert bad certificate"}, {ERR_REASON(SSL_R_SSLV3_ALERT_BAD_RECORD_MAC), "sslv3 alert bad record mac"}, {ERR_REASON(SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED), "sslv3 alert certificate expired"}, {ERR_REASON(SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED), "sslv3 alert certificate revoked"}, {ERR_REASON(SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN), "sslv3 alert certificate unknown"}, {ERR_REASON(SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE), "sslv3 alert decompression failure"}, {ERR_REASON(SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE), "sslv3 alert handshake failure"}, {ERR_REASON(SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER), "sslv3 alert illegal parameter"}, {ERR_REASON(SSL_R_SSLV3_ALERT_NO_CERTIFICATE), "sslv3 alert no certificate"}, {ERR_REASON(SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE), "sslv3 alert unexpected message"}, {ERR_REASON(SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE), "sslv3 alert unsupported certificate"}, {ERR_REASON(SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION), "ssl ctx has no default ssl version"}, {ERR_REASON(SSL_R_SSL_HANDSHAKE_FAILURE) , "ssl handshake failure"}, {ERR_REASON(SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS), "ssl library has no ciphers"}, {ERR_REASON(SSL_R_SSL_SESSION_ID_CALLBACK_FAILED), "ssl session id callback failed"}, {ERR_REASON(SSL_R_SSL_SESSION_ID_CONFLICT), "ssl session id conflict"}, {ERR_REASON(SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG), "ssl session id context too long"}, {ERR_REASON(SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH), "ssl session id has bad length"}, {ERR_REASON(SSL_R_SSL_SESSION_ID_IS_DIFFERENT), "ssl session id is different"}, {ERR_REASON(SSL_R_TLSV1_ALERT_ACCESS_DENIED), "tlsv1 alert access denied"}, {ERR_REASON(SSL_R_TLSV1_ALERT_DECODE_ERROR), "tlsv1 alert decode error"}, {ERR_REASON(SSL_R_TLSV1_ALERT_DECRYPTION_FAILED), "tlsv1 alert decryption failed"}, {ERR_REASON(SSL_R_TLSV1_ALERT_DECRYPT_ERROR), "tlsv1 alert decrypt error"}, {ERR_REASON(SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION), "tlsv1 alert export restriction"}, {ERR_REASON(SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY), "tlsv1 alert insufficient security"}, {ERR_REASON(SSL_R_TLSV1_ALERT_INTERNAL_ERROR), "tlsv1 alert internal error"}, {ERR_REASON(SSL_R_TLSV1_ALERT_NO_RENEGOTIATION), "tlsv1 alert no renegotiation"}, {ERR_REASON(SSL_R_TLSV1_ALERT_PROTOCOL_VERSION), "tlsv1 alert protocol version"}, {ERR_REASON(SSL_R_TLSV1_ALERT_RECORD_OVERFLOW), "tlsv1 alert record overflow"}, {ERR_REASON(SSL_R_TLSV1_ALERT_UNKNOWN_CA), "tlsv1 alert unknown ca"}, {ERR_REASON(SSL_R_TLSV1_ALERT_USER_CANCELLED), "tlsv1 alert user cancelled"}, {ERR_REASON(SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE), "tlsv1 bad certificate hash value"}, {ERR_REASON(SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE), "tlsv1 bad certificate status response"}, {ERR_REASON(SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE), "tlsv1 certificate unobtainable"}, {ERR_REASON(SSL_R_TLSV1_UNRECOGNIZED_NAME), "tlsv1 unrecognized name"}, {ERR_REASON(SSL_R_TLSV1_UNSUPPORTED_EXTENSION), "tlsv1 unsupported extension"}, {ERR_REASON(SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER), "tls client cert req with anon cipher"}, {ERR_REASON(SSL_R_TLS_HEARTBEAT_PEER_DOESNT_ACCEPT), "peer does not accept heartbeats"}, {ERR_REASON(SSL_R_TLS_HEARTBEAT_PENDING) , "heartbeat request already pending"}, {ERR_REASON(SSL_R_TLS_ILLEGAL_EXPORTER_LABEL), "tls illegal exporter label"}, {ERR_REASON(SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST), "tls invalid ecpointformat list"}, {ERR_REASON(SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST), "tls peer did not respond with certificate list"}, {ERR_REASON(SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG), "tls rsa encrypted value length is wrong"}, {ERR_REASON(SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER), "tried to use unsupported cipher"}, {ERR_REASON(SSL_R_UNABLE_TO_DECODE_DH_CERTS), "unable to decode dh certs"}, {ERR_REASON(SSL_R_UNABLE_TO_DECODE_ECDH_CERTS), "unable to decode ecdh certs"}, {ERR_REASON(SSL_R_UNABLE_TO_EXTRACT_PUBLIC_KEY), "unable to extract public key"}, {ERR_REASON(SSL_R_UNABLE_TO_FIND_DH_PARAMETERS), "unable to find dh parameters"}, {ERR_REASON(SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS), "unable to find ecdh parameters"}, {ERR_REASON(SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS), "unable to find public key parameters"}, {ERR_REASON(SSL_R_UNABLE_TO_FIND_SSL_METHOD), "unable to find ssl method"}, {ERR_REASON(SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES), "unable to load ssl2 md5 routines"}, {ERR_REASON(SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES), "unable to load ssl3 md5 routines"}, {ERR_REASON(SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES), "unable to load ssl3 sha1 routines"}, {ERR_REASON(SSL_R_UNEXPECTED_MESSAGE) , "unexpected message"}, {ERR_REASON(SSL_R_UNEXPECTED_RECORD) , "unexpected record"}, {ERR_REASON(SSL_R_UNINITIALIZED) , "uninitialized"}, {ERR_REASON(SSL_R_UNKNOWN_ALERT_TYPE) , "unknown alert type"}, {ERR_REASON(SSL_R_UNKNOWN_CERTIFICATE_TYPE), "unknown certificate type"}, {ERR_REASON(SSL_R_UNKNOWN_CIPHER_RETURNED), "unknown cipher returned"}, {ERR_REASON(SSL_R_UNKNOWN_CIPHER_TYPE) , "unknown cipher type"}, {ERR_REASON(SSL_R_UNKNOWN_DIGEST) , "unknown digest"}, {ERR_REASON(SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE), "unknown key exchange type"}, {ERR_REASON(SSL_R_UNKNOWN_PKEY_TYPE) , "unknown pkey type"}, {ERR_REASON(SSL_R_UNKNOWN_PROTOCOL) , "unknown protocol"}, {ERR_REASON(SSL_R_UNKNOWN_REMOTE_ERROR_TYPE), "unknown remote error type"}, {ERR_REASON(SSL_R_UNKNOWN_SSL_VERSION) , "unknown ssl version"}, {ERR_REASON(SSL_R_UNKNOWN_STATE) , "unknown state"}, {ERR_REASON(SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED), "unsafe legacy renegotiation disabled"}, {ERR_REASON(SSL_R_UNSUPPORTED_CIPHER) , "unsupported cipher"}, {ERR_REASON(SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM), "unsupported compression algorithm"}, {ERR_REASON(SSL_R_UNSUPPORTED_DIGEST_TYPE), "unsupported digest type"}, {ERR_REASON(SSL_R_UNSUPPORTED_ELLIPTIC_CURVE), "unsupported elliptic curve"}, {ERR_REASON(SSL_R_UNSUPPORTED_PROTOCOL) , "unsupported protocol"}, {ERR_REASON(SSL_R_UNSUPPORTED_SSL_VERSION), "unsupported ssl version"}, {ERR_REASON(SSL_R_UNSUPPORTED_STATUS_TYPE), "unsupported status type"}, {ERR_REASON(SSL_R_USE_SRTP_NOT_NEGOTIATED), "use srtp not negotiated"}, {ERR_REASON(SSL_R_WRITE_BIO_NOT_SET) , "write bio not set"}, {ERR_REASON(SSL_R_WRONG_CIPHER_RETURNED) , "wrong cipher returned"}, {ERR_REASON(SSL_R_WRONG_MESSAGE_TYPE) , "wrong message type"}, {ERR_REASON(SSL_R_WRONG_NUMBER_OF_KEY_BITS), "wrong number of key bits"}, {ERR_REASON(SSL_R_WRONG_SIGNATURE_LENGTH), "wrong signature length"}, {ERR_REASON(SSL_R_WRONG_SIGNATURE_SIZE) , "wrong signature size"}, {ERR_REASON(SSL_R_WRONG_SIGNATURE_TYPE) , "wrong signature type"}, {ERR_REASON(SSL_R_WRONG_SSL_VERSION) , "wrong ssl version"}, {ERR_REASON(SSL_R_WRONG_VERSION_NUMBER) , "wrong version number"}, {ERR_REASON(SSL_R_X509_LIB) , "x509 lib"}, {ERR_REASON(SSL_R_X509_VERIFICATION_SETUP_PROBLEMS), "x509 verification setup problems"}, {0, NULL} }; #endif void ERR_load_SSL_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(SSL_str_functs[0].error) == NULL) { ERR_load_strings(0, SSL_str_functs); ERR_load_strings(0, SSL_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/ssl_rsa.c0000644000175000017500000004253212360020705017354 0ustar /* $OpenBSD: ssl_rsa.c,v 1.14 2014/06/12 15:49:31 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "ssl_locl.h" #include #include #include #include #include static int ssl_set_cert(CERT *c, X509 *x509); static int ssl_set_pkey(CERT *c, EVP_PKEY *pkey); int SSL_use_certificate(SSL *ssl, X509 *x) { if (x == NULL) { SSLerr(SSL_F_SSL_USE_CERTIFICATE, ERR_R_PASSED_NULL_PARAMETER); return (0); } if (!ssl_cert_inst(&ssl->cert)) { SSLerr(SSL_F_SSL_USE_CERTIFICATE, ERR_R_MALLOC_FAILURE); return (0); } return (ssl_set_cert(ssl->cert, x)); } int SSL_use_certificate_file(SSL *ssl, const char *file, int type) { int j; BIO *in; int ret = 0; X509 *x = NULL; in = BIO_new(BIO_s_file_internal()); if (in == NULL) { SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, ERR_R_BUF_LIB); goto end; } if (BIO_read_filename(in, file) <= 0) { SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, ERR_R_SYS_LIB); goto end; } if (type == SSL_FILETYPE_ASN1) { j = ERR_R_ASN1_LIB; x = d2i_X509_bio(in, NULL); } else if (type == SSL_FILETYPE_PEM) { j = ERR_R_PEM_LIB; x = PEM_read_bio_X509(in, NULL, ssl->ctx->default_passwd_callback, ssl->ctx->default_passwd_callback_userdata); } else { SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, SSL_R_BAD_SSL_FILETYPE); goto end; } if (x == NULL) { SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, j); goto end; } ret = SSL_use_certificate(ssl, x); end: if (x != NULL) X509_free(x); BIO_free(in); return (ret); } int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len) { X509 *x; int ret; x = d2i_X509(NULL, &d,(long)len); if (x == NULL) { SSLerr(SSL_F_SSL_USE_CERTIFICATE_ASN1, ERR_R_ASN1_LIB); return (0); } ret = SSL_use_certificate(ssl, x); X509_free(x); return (ret); } int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa) { EVP_PKEY *pkey; int ret; if (rsa == NULL) { SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY, ERR_R_PASSED_NULL_PARAMETER); return (0); } if (!ssl_cert_inst(&ssl->cert)) { SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY, ERR_R_MALLOC_FAILURE); return (0); } if ((pkey = EVP_PKEY_new()) == NULL) { SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY, ERR_R_EVP_LIB); return (0); } RSA_up_ref(rsa); EVP_PKEY_assign_RSA(pkey, rsa); ret = ssl_set_pkey(ssl->cert, pkey); EVP_PKEY_free(pkey); return (ret); } static int ssl_set_pkey(CERT *c, EVP_PKEY *pkey) { int i; i = ssl_cert_type(NULL, pkey); if (i < 0) { SSLerr(SSL_F_SSL_SET_PKEY, SSL_R_UNKNOWN_CERTIFICATE_TYPE); return (0); } if (c->pkeys[i].x509 != NULL) { EVP_PKEY *pktmp; pktmp = X509_get_pubkey(c->pkeys[i].x509); EVP_PKEY_copy_parameters(pktmp, pkey); EVP_PKEY_free(pktmp); ERR_clear_error(); /* * Don't check the public/private key, this is mostly * for smart cards. */ if ((pkey->type == EVP_PKEY_RSA) && (RSA_flags(pkey->pkey.rsa) & RSA_METHOD_FLAG_NO_CHECK)) ; else if (!X509_check_private_key(c->pkeys[i].x509, pkey)) { X509_free(c->pkeys[i].x509); c->pkeys[i].x509 = NULL; return 0; } } if (c->pkeys[i].privatekey != NULL) EVP_PKEY_free(c->pkeys[i].privatekey); CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY); c->pkeys[i].privatekey = pkey; c->key = &(c->pkeys[i]); c->valid = 0; return (1); } int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type) { int j, ret = 0; BIO *in; RSA *rsa = NULL; in = BIO_new(BIO_s_file_internal()); if (in == NULL) { SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE, ERR_R_BUF_LIB); goto end; } if (BIO_read_filename(in, file) <= 0) { SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE, ERR_R_SYS_LIB); goto end; } if (type == SSL_FILETYPE_ASN1) { j = ERR_R_ASN1_LIB; rsa = d2i_RSAPrivateKey_bio(in, NULL); } else if (type == SSL_FILETYPE_PEM) { j = ERR_R_PEM_LIB; rsa = PEM_read_bio_RSAPrivateKey(in, NULL, ssl->ctx->default_passwd_callback, ssl->ctx->default_passwd_callback_userdata); } else { SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE, SSL_R_BAD_SSL_FILETYPE); goto end; } if (rsa == NULL) { SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE, j); goto end; } ret = SSL_use_RSAPrivateKey(ssl, rsa); RSA_free(rsa); end: BIO_free(in); return (ret); } int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len) { int ret; const unsigned char *p; RSA *rsa; p = d; if ((rsa = d2i_RSAPrivateKey(NULL, &p,(long)len)) == NULL) { SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1, ERR_R_ASN1_LIB); return (0); } ret = SSL_use_RSAPrivateKey(ssl, rsa); RSA_free(rsa); return (ret); } int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey) { int ret; if (pkey == NULL) { SSLerr(SSL_F_SSL_USE_PRIVATEKEY, ERR_R_PASSED_NULL_PARAMETER); return (0); } if (!ssl_cert_inst(&ssl->cert)) { SSLerr(SSL_F_SSL_USE_PRIVATEKEY, ERR_R_MALLOC_FAILURE); return (0); } ret = ssl_set_pkey(ssl->cert, pkey); return (ret); } int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type) { int j, ret = 0; BIO *in; EVP_PKEY *pkey = NULL; in = BIO_new(BIO_s_file_internal()); if (in == NULL) { SSLerr(SSL_F_SSL_USE_PRIVATEKEY_FILE, ERR_R_BUF_LIB); goto end; } if (BIO_read_filename(in, file) <= 0) { SSLerr(SSL_F_SSL_USE_PRIVATEKEY_FILE, ERR_R_SYS_LIB); goto end; } if (type == SSL_FILETYPE_PEM) { j = ERR_R_PEM_LIB; pkey = PEM_read_bio_PrivateKey(in, NULL, ssl->ctx->default_passwd_callback, ssl->ctx->default_passwd_callback_userdata); } else if (type == SSL_FILETYPE_ASN1) { j = ERR_R_ASN1_LIB; pkey = d2i_PrivateKey_bio(in, NULL); } else { SSLerr(SSL_F_SSL_USE_PRIVATEKEY_FILE, SSL_R_BAD_SSL_FILETYPE); goto end; } if (pkey == NULL) { SSLerr(SSL_F_SSL_USE_PRIVATEKEY_FILE, j); goto end; } ret = SSL_use_PrivateKey(ssl, pkey); EVP_PKEY_free(pkey); end: BIO_free(in); return (ret); } int SSL_use_PrivateKey_ASN1(int type, SSL *ssl, const unsigned char *d, long len) { int ret; const unsigned char *p; EVP_PKEY *pkey; p = d; if ((pkey = d2i_PrivateKey(type, NULL, &p,(long)len)) == NULL) { SSLerr(SSL_F_SSL_USE_PRIVATEKEY_ASN1, ERR_R_ASN1_LIB); return (0); } ret = SSL_use_PrivateKey(ssl, pkey); EVP_PKEY_free(pkey); return (ret); } int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x) { if (x == NULL) { SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE, ERR_R_PASSED_NULL_PARAMETER); return (0); } if (!ssl_cert_inst(&ctx->cert)) { SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE, ERR_R_MALLOC_FAILURE); return (0); } return (ssl_set_cert(ctx->cert, x)); } static int ssl_set_cert(CERT *c, X509 *x) { EVP_PKEY *pkey; int i; pkey = X509_get_pubkey(x); if (pkey == NULL) { SSLerr(SSL_F_SSL_SET_CERT, SSL_R_X509_LIB); return (0); } i = ssl_cert_type(x, pkey); if (i < 0) { SSLerr(SSL_F_SSL_SET_CERT, SSL_R_UNKNOWN_CERTIFICATE_TYPE); EVP_PKEY_free(pkey); return (0); } if (c->pkeys[i].privatekey != NULL) { EVP_PKEY_copy_parameters(pkey, c->pkeys[i].privatekey); ERR_clear_error(); /* * Don't check the public/private key, this is mostly * for smart cards. */ if ((c->pkeys[i].privatekey->type == EVP_PKEY_RSA) && (RSA_flags(c->pkeys[i].privatekey->pkey.rsa) & RSA_METHOD_FLAG_NO_CHECK)) ; else if (!X509_check_private_key(x, c->pkeys[i].privatekey)) { /* * don't fail for a cert/key mismatch, just free * current private key (when switching to a different * cert & key, first this function should be used, * then ssl_set_pkey */ EVP_PKEY_free(c->pkeys[i].privatekey); c->pkeys[i].privatekey = NULL; /* clear error queue */ ERR_clear_error(); } } EVP_PKEY_free(pkey); if (c->pkeys[i].x509 != NULL) X509_free(c->pkeys[i].x509); CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509); c->pkeys[i].x509 = x; c->key = &(c->pkeys[i]); c->valid = 0; return (1); } int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type) { int j; BIO *in; int ret = 0; X509 *x = NULL; in = BIO_new(BIO_s_file_internal()); if (in == NULL) { SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_FILE, ERR_R_BUF_LIB); goto end; } if (BIO_read_filename(in, file) <= 0) { SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_FILE, ERR_R_SYS_LIB); goto end; } if (type == SSL_FILETYPE_ASN1) { j = ERR_R_ASN1_LIB; x = d2i_X509_bio(in, NULL); } else if (type == SSL_FILETYPE_PEM) { j = ERR_R_PEM_LIB; x = PEM_read_bio_X509(in, NULL, ctx->default_passwd_callback, ctx->default_passwd_callback_userdata); } else { SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_FILE, SSL_R_BAD_SSL_FILETYPE); goto end; } if (x == NULL) { SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_FILE, j); goto end; } ret = SSL_CTX_use_certificate(ctx, x); end: if (x != NULL) X509_free(x); BIO_free(in); return (ret); } int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, const unsigned char *d) { X509 *x; int ret; x = d2i_X509(NULL, &d,(long)len); if (x == NULL) { SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1, ERR_R_ASN1_LIB); return (0); } ret = SSL_CTX_use_certificate(ctx, x); X509_free(x); return (ret); } int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa) { int ret; EVP_PKEY *pkey; if (rsa == NULL) { SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY, ERR_R_PASSED_NULL_PARAMETER); return (0); } if (!ssl_cert_inst(&ctx->cert)) { SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY, ERR_R_MALLOC_FAILURE); return (0); } if ((pkey = EVP_PKEY_new()) == NULL) { SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY, ERR_R_EVP_LIB); return (0); } RSA_up_ref(rsa); EVP_PKEY_assign_RSA(pkey, rsa); ret = ssl_set_pkey(ctx->cert, pkey); EVP_PKEY_free(pkey); return (ret); } int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type) { int j, ret = 0; BIO *in; RSA *rsa = NULL; in = BIO_new(BIO_s_file_internal()); if (in == NULL) { SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE, ERR_R_BUF_LIB); goto end; } if (BIO_read_filename(in, file) <= 0) { SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE, ERR_R_SYS_LIB); goto end; } if (type == SSL_FILETYPE_ASN1) { j = ERR_R_ASN1_LIB; rsa = d2i_RSAPrivateKey_bio(in, NULL); } else if (type == SSL_FILETYPE_PEM) { j = ERR_R_PEM_LIB; rsa = PEM_read_bio_RSAPrivateKey(in, NULL, ctx->default_passwd_callback, ctx->default_passwd_callback_userdata); } else { SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE, SSL_R_BAD_SSL_FILETYPE); goto end; } if (rsa == NULL) { SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE, j); goto end; } ret = SSL_CTX_use_RSAPrivateKey(ctx, rsa); RSA_free(rsa); end: BIO_free(in); return (ret); } int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, long len) { int ret; const unsigned char *p; RSA *rsa; p = d; if ((rsa = d2i_RSAPrivateKey(NULL, &p,(long)len)) == NULL) { SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1, ERR_R_ASN1_LIB); return (0); } ret = SSL_CTX_use_RSAPrivateKey(ctx, rsa); RSA_free(rsa); return (ret); } int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey) { if (pkey == NULL) { SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY, ERR_R_PASSED_NULL_PARAMETER); return (0); } if (!ssl_cert_inst(&ctx->cert)) { SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY, ERR_R_MALLOC_FAILURE); return (0); } return (ssl_set_pkey(ctx->cert, pkey)); } int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type) { int j, ret = 0; BIO *in; EVP_PKEY *pkey = NULL; in = BIO_new(BIO_s_file_internal()); if (in == NULL) { SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE, ERR_R_BUF_LIB); goto end; } if (BIO_read_filename(in, file) <= 0) { SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE, ERR_R_SYS_LIB); goto end; } if (type == SSL_FILETYPE_PEM) { j = ERR_R_PEM_LIB; pkey = PEM_read_bio_PrivateKey(in, NULL, ctx->default_passwd_callback, ctx->default_passwd_callback_userdata); } else if (type == SSL_FILETYPE_ASN1) { j = ERR_R_ASN1_LIB; pkey = d2i_PrivateKey_bio(in, NULL); } else { SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE, SSL_R_BAD_SSL_FILETYPE); goto end; } if (pkey == NULL) { SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE, j); goto end; } ret = SSL_CTX_use_PrivateKey(ctx, pkey); EVP_PKEY_free(pkey); end: BIO_free(in); return (ret); } int SSL_CTX_use_PrivateKey_ASN1(int type, SSL_CTX *ctx, const unsigned char *d, long len) { int ret; const unsigned char *p; EVP_PKEY *pkey; p = d; if ((pkey = d2i_PrivateKey(type, NULL, &p,(long)len)) == NULL) { SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1, ERR_R_ASN1_LIB); return (0); } ret = SSL_CTX_use_PrivateKey(ctx, pkey); EVP_PKEY_free(pkey); return (ret); } /* * Read a file that contains our certificate in "PEM" format, * possibly followed by a sequence of CA certificates that should be * sent to the peer in the Certificate message. */ int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file) { BIO *in; int ret = 0; X509 *x = NULL; ERR_clear_error(); /* clear error stack for SSL_CTX_use_certificate() */ in = BIO_new(BIO_s_file_internal()); if (in == NULL) { SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE, ERR_R_BUF_LIB); goto end; } if (BIO_read_filename(in, file) <= 0) { SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE, ERR_R_SYS_LIB); goto end; } x = PEM_read_bio_X509_AUX(in, NULL, ctx->default_passwd_callback, ctx->default_passwd_callback_userdata); if (x == NULL) { SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE, ERR_R_PEM_LIB); goto end; } ret = SSL_CTX_use_certificate(ctx, x); if (ERR_peek_error() != 0) ret = 0; /* Key/certificate mismatch doesn't imply ret==0 ... */ if (ret) { /* * If we could set up our certificate, now proceed to * the CA certificates. */ X509 *ca; int r; unsigned long err; if (ctx->extra_certs != NULL) { sk_X509_pop_free(ctx->extra_certs, X509_free); ctx->extra_certs = NULL; } while ((ca = PEM_read_bio_X509(in, NULL, ctx->default_passwd_callback, ctx->default_passwd_callback_userdata)) != NULL) { r = SSL_CTX_add_extra_chain_cert(ctx, ca); if (!r) { X509_free(ca); ret = 0; goto end; } /* * Note that we must not free r if it was successfully * added to the chain (while we must free the main * certificate, since its reference count is increased * by SSL_CTX_use_certificate). */ } /* When the while loop ends, it's usually just EOF. */ err = ERR_peek_last_error(); if (ERR_GET_LIB(err) == ERR_LIB_PEM && ERR_GET_REASON(err) == PEM_R_NO_START_LINE) ERR_clear_error(); else ret = 0; /* some real error */ } end: if (x != NULL) X509_free(x); BIO_free(in); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/d1_pkt.c0000644000175000017500000013014512360020705017066 0ustar /* $OpenBSD: d1_pkt.c,v 1.31 2014/07/09 16:06:14 miod Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. */ /* ==================================================================== * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include "ssl_locl.h" #include #include #include #include "pqueue.h" /* mod 128 saturating subtract of two 64-bit values in big-endian order */ static int satsub64be(const unsigned char *v1, const unsigned char *v2) { int ret, sat, brw, i; if (sizeof(long) == 8) do { long l; if (BYTE_ORDER == LITTLE_ENDIAN) break; /* not reached on little-endians */ /* following test is redundant, because input is * always aligned, but I take no chances... */ if (((size_t)v1 | (size_t)v2) & 0x7) break; l = *((long *)v1); l -= *((long *)v2); if (l > 128) return 128; else if (l<-128) return -128; else return (int)l; } while (0); ret = (int)v1[7] - (int)v2[7]; sat = 0; brw = ret >> 8; /* brw is either 0 or -1 */ if (ret & 0x80) { for (i = 6; i >= 0; i--) { brw += (int)v1[i]-(int)v2[i]; sat |= ~brw; brw >>= 8; } } else { for (i = 6; i >= 0; i--) { brw += (int)v1[i]-(int)v2[i]; sat |= brw; brw >>= 8; } } brw <<= 8; /* brw is either 0 or -256 */ if (sat & 0xff) return brw | 0x80; else return brw + (ret & 0xFF); } static int have_handshake_fragment(SSL *s, int type, unsigned char *buf, int len, int peek); static int dtls1_record_replay_check(SSL *s, DTLS1_BITMAP *bitmap); static void dtls1_record_bitmap_update(SSL *s, DTLS1_BITMAP *bitmap); static DTLS1_BITMAP *dtls1_get_bitmap(SSL *s, SSL3_RECORD *rr, unsigned int *is_next_epoch); static int dtls1_buffer_record(SSL *s, record_pqueue *q, unsigned char *priority); static int dtls1_process_record(SSL *s); /* copy buffered record into SSL structure */ static int dtls1_copy_record(SSL *s, pitem *item) { DTLS1_RECORD_DATA *rdata; rdata = (DTLS1_RECORD_DATA *)item->data; free(s->s3->rbuf.buf); s->packet = rdata->packet; s->packet_length = rdata->packet_length; memcpy(&(s->s3->rbuf), &(rdata->rbuf), sizeof(SSL3_BUFFER)); memcpy(&(s->s3->rrec), &(rdata->rrec), sizeof(SSL3_RECORD)); /* Set proper sequence number for mac calculation */ memcpy(&(s->s3->read_sequence[2]), &(rdata->packet[5]), 6); return (1); } static int dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority) { DTLS1_RECORD_DATA *rdata; pitem *item; /* Limit the size of the queue to prevent DOS attacks */ if (pqueue_size(queue->q) >= 100) return 0; rdata = malloc(sizeof(DTLS1_RECORD_DATA)); item = pitem_new(priority, rdata); if (rdata == NULL || item == NULL) goto err; rdata->packet = s->packet; rdata->packet_length = s->packet_length; memcpy(&(rdata->rbuf), &(s->s3->rbuf), sizeof(SSL3_BUFFER)); memcpy(&(rdata->rrec), &(s->s3->rrec), sizeof(SSL3_RECORD)); item->data = rdata; #ifndef OPENSSL_NO_SCTP /* Store bio_dgram_sctp_rcvinfo struct */ if (BIO_dgram_is_sctp(SSL_get_rbio(s)) && (s->state == SSL3_ST_SR_FINISHED_A || s->state == SSL3_ST_CR_FINISHED_A)) { BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SCTP_GET_RCVINFO, sizeof(rdata->recordinfo), &rdata->recordinfo); } #endif s->packet = NULL; s->packet_length = 0; memset(&(s->s3->rbuf), 0, sizeof(SSL3_BUFFER)); memset(&(s->s3->rrec), 0, sizeof(SSL3_RECORD)); if (!ssl3_setup_buffers(s)) goto err; /* insert should not fail, since duplicates are dropped */ if (pqueue_insert(queue->q, item) == NULL) goto err; return (1); err: SSLerr(SSL_F_DTLS1_BUFFER_RECORD, ERR_R_INTERNAL_ERROR); free(rdata); pitem_free(item); return (0); } static int dtls1_retrieve_buffered_record(SSL *s, record_pqueue *queue) { pitem *item; item = pqueue_pop(queue->q); if (item) { dtls1_copy_record(s, item); free(item->data); pitem_free(item); return (1); } return (0); } /* retrieve a buffered record that belongs to the new epoch, i.e., not processed * yet */ #define dtls1_get_unprocessed_record(s) \ dtls1_retrieve_buffered_record((s), \ &((s)->d1->unprocessed_rcds)) /* retrieve a buffered record that belongs to the current epoch, ie, processed */ #define dtls1_get_processed_record(s) \ dtls1_retrieve_buffered_record((s), \ &((s)->d1->processed_rcds)) static int dtls1_process_buffered_records(SSL *s) { pitem *item; item = pqueue_peek(s->d1->unprocessed_rcds.q); if (item) { /* Check if epoch is current. */ if (s->d1->unprocessed_rcds.epoch != s->d1->r_epoch) return (1); /* Nothing to do. */ /* Process all the records. */ while (pqueue_peek(s->d1->unprocessed_rcds.q)) { dtls1_get_unprocessed_record(s); if (! dtls1_process_record(s)) return (0); dtls1_buffer_record(s, &(s->d1->processed_rcds), s->s3->rrec.seq_num); } } /* sync epoch numbers once all the unprocessed records * have been processed */ s->d1->processed_rcds.epoch = s->d1->r_epoch; s->d1->unprocessed_rcds.epoch = s->d1->r_epoch + 1; return (1); } static int dtls1_process_record(SSL *s) { int i, al; int enc_err; SSL_SESSION *sess; SSL3_RECORD *rr; unsigned int mac_size, orig_len; unsigned char md[EVP_MAX_MD_SIZE]; rr = &(s->s3->rrec); sess = s->session; /* At this point, s->packet_length == SSL3_RT_HEADER_LNGTH + rr->length, * and we have that many bytes in s->packet */ rr->input = &(s->packet[DTLS1_RT_HEADER_LENGTH]); /* ok, we can now read from 's->packet' data into 'rr' * rr->input points at rr->length bytes, which * need to be copied into rr->data by either * the decryption or by the decompression * When the data is 'copied' into the rr->data buffer, * rr->input will be pointed at the new buffer */ /* We now have - encrypted [ MAC [ compressed [ plain ] ] ] * rr->length bytes of encrypted compressed stuff. */ /* check is not needed I believe */ if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH) { al = SSL_AD_RECORD_OVERFLOW; SSLerr(SSL_F_DTLS1_PROCESS_RECORD, SSL_R_ENCRYPTED_LENGTH_TOO_LONG); goto f_err; } /* decrypt in place in 'rr->input' */ rr->data = rr->input; enc_err = s->method->ssl3_enc->enc(s, 0); /* enc_err is: * 0: (in non-constant time) if the record is publically invalid. * 1: if the padding is valid * -1: if the padding is invalid */ if (enc_err == 0) { /* For DTLS we simply ignore bad packets. */ rr->length = 0; s->packet_length = 0; goto err; } /* r->length is now the compressed data plus mac */ if ((sess != NULL) && (s->enc_read_ctx != NULL) && (EVP_MD_CTX_md(s->read_hash) != NULL)) { /* s->read_hash != NULL => mac_size != -1 */ unsigned char *mac = NULL; unsigned char mac_tmp[EVP_MAX_MD_SIZE]; mac_size = EVP_MD_CTX_size(s->read_hash); OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE); /* kludge: *_cbc_remove_padding passes padding length in rr->type */ orig_len = rr->length + ((unsigned int)rr->type >> 8); /* orig_len is the length of the record before any padding was * removed. This is public information, as is the MAC in use, * therefore we can safely process the record in a different * amount of time if it's too short to possibly contain a MAC. */ if (orig_len < mac_size || /* CBC records must have a padding length byte too. */ (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE && orig_len < mac_size + 1)) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_DTLS1_PROCESS_RECORD, SSL_R_LENGTH_TOO_SHORT); goto f_err; } if (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE) { /* We update the length so that the TLS header bytes * can be constructed correctly but we need to extract * the MAC in constant time from within the record, * without leaking the contents of the padding bytes. * */ mac = mac_tmp; ssl3_cbc_copy_mac(mac_tmp, rr, mac_size, orig_len); rr->length -= mac_size; } else { /* In this case there's no padding, so |orig_len| * equals |rec->length| and we checked that there's * enough bytes for |mac_size| above. */ rr->length -= mac_size; mac = &rr->data[rr->length]; } i = s->method->ssl3_enc->mac(s, md, 0 /* not send */); if (i < 0 || mac == NULL || timingsafe_memcmp(md, mac, (size_t)mac_size) != 0) enc_err = -1; if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH + mac_size) enc_err = -1; } if (enc_err < 0) { /* decryption failed, silently discard message */ rr->length = 0; s->packet_length = 0; goto err; } if (rr->length > SSL3_RT_MAX_PLAIN_LENGTH) { al = SSL_AD_RECORD_OVERFLOW; SSLerr(SSL_F_DTLS1_PROCESS_RECORD, SSL_R_DATA_LENGTH_TOO_LONG); goto f_err; } rr->off = 0; /* So at this point the following is true * ssl->s3->rrec.type is the type of record * ssl->s3->rrec.length == number of bytes in record * ssl->s3->rrec.off == offset to first valid byte * ssl->s3->rrec.data == where to take bytes from, increment * after use :-). */ /* we have pulled in a full packet so zero things */ s->packet_length = 0; dtls1_record_bitmap_update(s, &(s->d1->bitmap));/* Mark receipt of record. */ return (1); f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: return (0); } /* Call this to get a new input record. * It will return <= 0 if more data is needed, normally due to an error * or non-blocking IO. * When it finishes, one packet has been decoded and can be found in * ssl->s3->rrec.type - is the type of record * ssl->s3->rrec.data, - data * ssl->s3->rrec.length, - number of bytes */ /* used only by dtls1_read_bytes */ int dtls1_get_record(SSL *s) { int ssl_major, ssl_minor; int i, n; SSL3_RECORD *rr; unsigned char *p = NULL; unsigned short version; DTLS1_BITMAP *bitmap; unsigned int is_next_epoch; rr = &(s->s3->rrec); /* The epoch may have changed. If so, process all the * pending records. This is a non-blocking operation. */ dtls1_process_buffered_records(s); /* if we're renegotiating, then there may be buffered records */ if (dtls1_get_processed_record(s)) return 1; /* get something from the wire */ again: /* check if we have the header */ if ((s->rstate != SSL_ST_READ_BODY) || (s->packet_length < DTLS1_RT_HEADER_LENGTH)) { n = ssl3_read_n(s, DTLS1_RT_HEADER_LENGTH, s->s3->rbuf.len, 0); /* read timeout is handled by dtls1_read_bytes */ if (n <= 0) return(n); /* error or non-blocking */ /* this packet contained a partial record, dump it */ if (s->packet_length != DTLS1_RT_HEADER_LENGTH) { s->packet_length = 0; goto again; } s->rstate = SSL_ST_READ_BODY; p = s->packet; /* Pull apart the header into the DTLS1_RECORD */ rr->type= *(p++); ssl_major= *(p++); ssl_minor= *(p++); version = (ssl_major << 8)|ssl_minor; /* sequence number is 64 bits, with top 2 bytes = epoch */ n2s(p, rr->epoch); memcpy(&(s->s3->read_sequence[2]), p, 6); p += 6; n2s(p, rr->length); /* Lets check version */ if (!s->first_packet) { if (version != s->version) { /* unexpected version, silently discard */ rr->length = 0; s->packet_length = 0; goto again; } } if ((version & 0xff00) != (s->version & 0xff00)) { /* wrong version, silently discard record */ rr->length = 0; s->packet_length = 0; goto again; } if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH) { /* record too long, silently discard it */ rr->length = 0; s->packet_length = 0; goto again; } /* now s->rstate == SSL_ST_READ_BODY */ } /* s->rstate == SSL_ST_READ_BODY, get and decode the data */ if (rr->length > s->packet_length - DTLS1_RT_HEADER_LENGTH) { /* now s->packet_length == DTLS1_RT_HEADER_LENGTH */ i = rr->length; n = ssl3_read_n(s, i, i, 1); if (n <= 0) return(n); /* error or non-blocking io */ /* this packet contained a partial record, dump it */ if (n != i) { rr->length = 0; s->packet_length = 0; goto again; } /* now n == rr->length, * and s->packet_length == DTLS1_RT_HEADER_LENGTH + rr->length */ } s->rstate = SSL_ST_READ_HEADER; /* set state for later operations */ /* match epochs. NULL means the packet is dropped on the floor */ bitmap = dtls1_get_bitmap(s, rr, &is_next_epoch); if (bitmap == NULL) { rr->length = 0; s->packet_length = 0; /* dump this record */ goto again; /* get another record */ } #ifndef OPENSSL_NO_SCTP /* Only do replay check if no SCTP bio */ if (!BIO_dgram_is_sctp(SSL_get_rbio(s))) { #endif /* Check whether this is a repeat, or aged record. * Don't check if we're listening and this message is * a ClientHello. They can look as if they're replayed, * since they arrive from different connections and * would be dropped unnecessarily. */ if (!(s->d1->listen && rr->type == SSL3_RT_HANDSHAKE && *p == SSL3_MT_CLIENT_HELLO) && !dtls1_record_replay_check(s, bitmap)) { rr->length = 0; s->packet_length=0; /* dump this record */ goto again; /* get another record */ } #ifndef OPENSSL_NO_SCTP } #endif /* just read a 0 length packet */ if (rr->length == 0) goto again; /* If this record is from the next epoch (either HM or ALERT), * and a handshake is currently in progress, buffer it since it * cannot be processed at this time. However, do not buffer * anything while listening. */ if (is_next_epoch) { if ((SSL_in_init(s) || s->in_handshake) && !s->d1->listen) { dtls1_buffer_record(s, &(s->d1->unprocessed_rcds), rr->seq_num); } rr->length = 0; s->packet_length = 0; goto again; } if (!dtls1_process_record(s)) { rr->length = 0; s->packet_length = 0; /* dump this record */ goto again; /* get another record */ } return (1); } /* Return up to 'len' payload bytes received in 'type' records. * 'type' is one of the following: * * - SSL3_RT_HANDSHAKE (when ssl3_get_message calls us) * - SSL3_RT_APPLICATION_DATA (when ssl3_read calls us) * - 0 (during a shutdown, no data has to be returned) * * If we don't have stored data to work from, read a SSL/TLS record first * (possibly multiple records if we still don't have anything to return). * * This function must handle any surprises the peer may have for us, such as * Alert records (e.g. close_notify), ChangeCipherSpec records (not really * a surprise, but handled as if it were), or renegotiation requests. * Also if record payloads contain fragments too small to process, we store * them until there is enough for the respective protocol (the record protocol * may use arbitrary fragmentation and even interleaving): * Change cipher spec protocol * just 1 byte needed, no need for keeping anything stored * Alert protocol * 2 bytes needed (AlertLevel, AlertDescription) * Handshake protocol * 4 bytes needed (HandshakeType, uint24 length) -- we just have * to detect unexpected Client Hello and Hello Request messages * here, anything else is handled by higher layers * Application data protocol * none of our business */ int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) { int al, i, j, ret; unsigned int n; SSL3_RECORD *rr; void (*cb)(const SSL *ssl, int type2, int val) = NULL; if (s->s3->rbuf.buf == NULL) /* Not initialized yet */ if (!ssl3_setup_buffers(s)) return (-1); if ((type && type != SSL3_RT_APPLICATION_DATA && type != SSL3_RT_HANDSHAKE) || (peek && (type != SSL3_RT_APPLICATION_DATA))) { SSLerr(SSL_F_DTLS1_READ_BYTES, ERR_R_INTERNAL_ERROR); return -1; } /* check whether there's a handshake message (client hello?) waiting */ if ((ret = have_handshake_fragment(s, type, buf, len, peek))) return ret; /* Now s->d1->handshake_fragment_len == 0 if type == SSL3_RT_HANDSHAKE. */ #ifndef OPENSSL_NO_SCTP /* Continue handshake if it had to be interrupted to read * app data with SCTP. */ if ((!s->in_handshake && SSL_in_init(s)) || (BIO_dgram_is_sctp(SSL_get_rbio(s)) && (s->state == DTLS1_SCTP_ST_SR_READ_SOCK || s->state == DTLS1_SCTP_ST_CR_READ_SOCK) && s->s3->in_read_app_data != 2)) #else if (!s->in_handshake && SSL_in_init(s)) #endif { /* type == SSL3_RT_APPLICATION_DATA */ i = s->handshake_func(s); if (i < 0) return (i); if (i == 0) { SSLerr(SSL_F_DTLS1_READ_BYTES, SSL_R_SSL_HANDSHAKE_FAILURE); return (-1); } } start: s->rwstate = SSL_NOTHING; /* s->s3->rrec.type - is the type of record * s->s3->rrec.data, - data * s->s3->rrec.off, - offset into 'data' for next read * s->s3->rrec.length, - number of bytes. */ rr = &(s->s3->rrec); /* We are not handshaking and have no data yet, * so process data buffered during the last handshake * in advance, if any. */ if (s->state == SSL_ST_OK && rr->length == 0) { pitem *item; item = pqueue_pop(s->d1->buffered_app_data.q); if (item) { #ifndef OPENSSL_NO_SCTP /* Restore bio_dgram_sctp_rcvinfo struct */ if (BIO_dgram_is_sctp(SSL_get_rbio(s))) { DTLS1_RECORD_DATA *rdata = (DTLS1_RECORD_DATA *) item->data; BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SCTP_SET_RCVINFO, sizeof(rdata->recordinfo), &rdata->recordinfo); } #endif dtls1_copy_record(s, item); free(item->data); pitem_free(item); } } /* Check for timeout */ if (dtls1_handle_timeout(s) > 0) goto start; /* get new packet if necessary */ if ((rr->length == 0) || (s->rstate == SSL_ST_READ_BODY)) { ret = dtls1_get_record(s); if (ret <= 0) { ret = dtls1_read_failed(s, ret); /* anything other than a timeout is an error */ if (ret <= 0) return (ret); else goto start; } } if (s->d1->listen && rr->type != SSL3_RT_HANDSHAKE) { rr->length = 0; goto start; } /* we now have a packet which can be read and processed */ if (s->s3->change_cipher_spec /* set when we receive ChangeCipherSpec, * reset by ssl3_get_finished */ && (rr->type != SSL3_RT_HANDSHAKE)) { /* We now have application data between CCS and Finished. * Most likely the packets were reordered on their way, so * buffer the application data for later processing rather * than dropping the connection. */ dtls1_buffer_record(s, &(s->d1->buffered_app_data), rr->seq_num); rr->length = 0; goto start; } /* If the other end has shut down, throw anything we read away * (even in 'peek' mode) */ if (s->shutdown & SSL_RECEIVED_SHUTDOWN) { rr->length = 0; s->rwstate = SSL_NOTHING; return (0); } if (type == rr->type) /* SSL3_RT_APPLICATION_DATA or SSL3_RT_HANDSHAKE */ { /* make sure that we are not getting application data when we * are doing a handshake for the first time */ if (SSL_in_init(s) && (type == SSL3_RT_APPLICATION_DATA) && (s->enc_read_ctx == NULL)) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_DTLS1_READ_BYTES, SSL_R_APP_DATA_IN_HANDSHAKE); goto f_err; } if (len <= 0) return (len); if ((unsigned int)len > rr->length) n = rr->length; else n = (unsigned int)len; memcpy(buf, &(rr->data[rr->off]), n); if (!peek) { rr->length -= n; rr->off += n; if (rr->length == 0) { s->rstate = SSL_ST_READ_HEADER; rr->off = 0; } } #ifndef OPENSSL_NO_SCTP /* We were about to renegotiate but had to read * belated application data first, so retry. */ if (BIO_dgram_is_sctp(SSL_get_rbio(s)) && rr->type == SSL3_RT_APPLICATION_DATA && (s->state == DTLS1_SCTP_ST_SR_READ_SOCK || s->state == DTLS1_SCTP_ST_CR_READ_SOCK)) { s->rwstate = SSL_READING; BIO_clear_retry_flags(SSL_get_rbio(s)); BIO_set_retry_read(SSL_get_rbio(s)); } /* We might had to delay a close_notify alert because * of reordered app data. If there was an alert and there * is no message to read anymore, finally set shutdown. */ if (BIO_dgram_is_sctp(SSL_get_rbio(s)) && s->d1->shutdown_received && !BIO_dgram_sctp_msg_waiting(SSL_get_rbio(s))) { s->shutdown |= SSL_RECEIVED_SHUTDOWN; return (0); } #endif return (n); } /* If we get here, then type != rr->type; if we have a handshake * message, then it was unexpected (Hello Request or Client Hello). */ /* In case of record types for which we have 'fragment' storage, * fill that so that we can process the data at a fixed place. */ { unsigned int k, dest_maxlen = 0; unsigned char *dest = NULL; unsigned int *dest_len = NULL; if (rr->type == SSL3_RT_HANDSHAKE) { dest_maxlen = sizeof s->d1->handshake_fragment; dest = s->d1->handshake_fragment; dest_len = &s->d1->handshake_fragment_len; } else if (rr->type == SSL3_RT_ALERT) { dest_maxlen = sizeof(s->d1->alert_fragment); dest = s->d1->alert_fragment; dest_len = &s->d1->alert_fragment_len; } /* else it's a CCS message, or application data or wrong */ else if (rr->type != SSL3_RT_CHANGE_CIPHER_SPEC) { /* Application data while renegotiating * is allowed. Try again reading. */ if (rr->type == SSL3_RT_APPLICATION_DATA) { BIO *bio; s->s3->in_read_app_data = 2; bio = SSL_get_rbio(s); s->rwstate = SSL_READING; BIO_clear_retry_flags(bio); BIO_set_retry_read(bio); return (-1); } /* Not certain if this is the right error handling */ al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_DTLS1_READ_BYTES, SSL_R_UNEXPECTED_RECORD); goto f_err; } if (dest_maxlen > 0) { /* XDTLS: In a pathalogical case, the Client Hello * may be fragmented--don't always expect dest_maxlen bytes */ if (rr->length < dest_maxlen) { #ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE /* * for normal alerts rr->length is 2, while * dest_maxlen is 7 if we were to handle this * non-existing alert... */ FIX ME #endif s->rstate = SSL_ST_READ_HEADER; rr->length = 0; goto start; } /* now move 'n' bytes: */ for ( k = 0; k < dest_maxlen; k++) { dest[k] = rr->data[rr->off++]; rr->length--; } *dest_len = dest_maxlen; } } /* s->d1->handshake_fragment_len == 12 iff rr->type == SSL3_RT_HANDSHAKE; * s->d1->alert_fragment_len == 7 iff rr->type == SSL3_RT_ALERT. * (Possibly rr is 'empty' now, i.e. rr->length may be 0.) */ /* If we are a client, check for an incoming 'Hello Request': */ if ((!s->server) && (s->d1->handshake_fragment_len >= DTLS1_HM_HEADER_LENGTH) && (s->d1->handshake_fragment[0] == SSL3_MT_HELLO_REQUEST) && (s->session != NULL) && (s->session->cipher != NULL)) { s->d1->handshake_fragment_len = 0; if ((s->d1->handshake_fragment[1] != 0) || (s->d1->handshake_fragment[2] != 0) || (s->d1->handshake_fragment[3] != 0)) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_DTLS1_READ_BYTES, SSL_R_BAD_HELLO_REQUEST); goto err; } /* no need to check sequence number on HELLO REQUEST messages */ if (s->msg_callback) s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->d1->handshake_fragment, 4, s, s->msg_callback_arg); if (SSL_is_init_finished(s) && !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) && !s->s3->renegotiate) { s->d1->handshake_read_seq++; s->new_session = 1; ssl3_renegotiate(s); if (ssl3_renegotiate_check(s)) { i = s->handshake_func(s); if (i < 0) return (i); if (i == 0) { SSLerr(SSL_F_DTLS1_READ_BYTES, SSL_R_SSL_HANDSHAKE_FAILURE); return (-1); } if (!(s->mode & SSL_MODE_AUTO_RETRY)) { if (s->s3->rbuf.left == 0) /* no read-ahead left? */ { BIO *bio; /* In the case where we try to read application data, * but we trigger an SSL handshake, we return -1 with * the retry option set. Otherwise renegotiation may * cause nasty problems in the blocking world */ s->rwstate = SSL_READING; bio = SSL_get_rbio(s); BIO_clear_retry_flags(bio); BIO_set_retry_read(bio); return (-1); } } } } /* we either finished a handshake or ignored the request, * now try again to obtain the (application) data we were asked for */ goto start; } if (s->d1->alert_fragment_len >= DTLS1_AL_HEADER_LENGTH) { int alert_level = s->d1->alert_fragment[0]; int alert_descr = s->d1->alert_fragment[1]; s->d1->alert_fragment_len = 0; if (s->msg_callback) s->msg_callback(0, s->version, SSL3_RT_ALERT, s->d1->alert_fragment, 2, s, s->msg_callback_arg); if (s->info_callback != NULL) cb = s->info_callback; else if (s->ctx->info_callback != NULL) cb = s->ctx->info_callback; if (cb != NULL) { j = (alert_level << 8) | alert_descr; cb(s, SSL_CB_READ_ALERT, j); } if (alert_level == 1) /* warning */ { s->s3->warn_alert = alert_descr; if (alert_descr == SSL_AD_CLOSE_NOTIFY) { #ifndef OPENSSL_NO_SCTP /* With SCTP and streams the socket may deliver app data * after a close_notify alert. We have to check this * first so that nothing gets discarded. */ if (BIO_dgram_is_sctp(SSL_get_rbio(s)) && BIO_dgram_sctp_msg_waiting(SSL_get_rbio(s))) { s->d1->shutdown_received = 1; s->rwstate = SSL_READING; BIO_clear_retry_flags(SSL_get_rbio(s)); BIO_set_retry_read(SSL_get_rbio(s)); return -1; } #endif s->shutdown |= SSL_RECEIVED_SHUTDOWN; return (0); } } else if (alert_level == 2) /* fatal */ { s->rwstate = SSL_NOTHING; s->s3->fatal_alert = alert_descr; SSLerr(SSL_F_DTLS1_READ_BYTES, SSL_AD_REASON_OFFSET + alert_descr); ERR_asprintf_error_data("SSL alert number %d", alert_descr); s->shutdown|=SSL_RECEIVED_SHUTDOWN; SSL_CTX_remove_session(s->ctx, s->session); return (0); } else { al = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_DTLS1_READ_BYTES, SSL_R_UNKNOWN_ALERT_TYPE); goto f_err; } goto start; } if (s->shutdown & SSL_SENT_SHUTDOWN) /* but we have not received a shutdown */ { s->rwstate = SSL_NOTHING; rr->length = 0; return (0); } if (rr->type == SSL3_RT_CHANGE_CIPHER_SPEC) { struct ccs_header_st ccs_hdr; unsigned int ccs_hdr_len = DTLS1_CCS_HEADER_LENGTH; dtls1_get_ccs_header(rr->data, &ccs_hdr); if (s->version == DTLS1_BAD_VER) ccs_hdr_len = 3; /* 'Change Cipher Spec' is just a single byte, so we know * exactly what the record payload has to look like */ /* XDTLS: check that epoch is consistent */ if ((rr->length != ccs_hdr_len) || (rr->off != 0) || (rr->data[0] != SSL3_MT_CCS)) { i = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_DTLS1_READ_BYTES, SSL_R_BAD_CHANGE_CIPHER_SPEC); goto err; } rr->length = 0; if (s->msg_callback) s->msg_callback(0, s->version, SSL3_RT_CHANGE_CIPHER_SPEC, rr->data, 1, s, s->msg_callback_arg); /* We can't process a CCS now, because previous handshake * messages are still missing, so just drop it. */ if (!s->d1->change_cipher_spec_ok) { goto start; } s->d1->change_cipher_spec_ok = 0; s->s3->change_cipher_spec = 1; if (!ssl3_do_change_cipher_spec(s)) goto err; /* do this whenever CCS is processed */ dtls1_reset_seq_numbers(s, SSL3_CC_READ); if (s->version == DTLS1_BAD_VER) s->d1->handshake_read_seq++; #ifndef OPENSSL_NO_SCTP /* Remember that a CCS has been received, * so that an old key of SCTP-Auth can be * deleted when a CCS is sent. Will be ignored * if no SCTP is used */ BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD, 1, NULL); #endif goto start; } /* Unexpected handshake message (Client Hello, or protocol violation) */ if ((s->d1->handshake_fragment_len >= DTLS1_HM_HEADER_LENGTH) && !s->in_handshake) { struct hm_header_st msg_hdr; /* this may just be a stale retransmit */ dtls1_get_message_header(rr->data, &msg_hdr); if (rr->epoch != s->d1->r_epoch) { rr->length = 0; goto start; } /* If we are server, we may have a repeated FINISHED of the * client here, then retransmit our CCS and FINISHED. */ if (msg_hdr.type == SSL3_MT_FINISHED) { if (dtls1_check_timeout_num(s) < 0) return -1; dtls1_retransmit_buffered_messages(s); rr->length = 0; goto start; } if (((s->state&SSL_ST_MASK) == SSL_ST_OK) && !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)) { s->state = s->server ? SSL_ST_ACCEPT : SSL_ST_CONNECT; s->renegotiate = 1; s->new_session = 1; } i = s->handshake_func(s); if (i < 0) return (i); if (i == 0) { SSLerr(SSL_F_DTLS1_READ_BYTES, SSL_R_SSL_HANDSHAKE_FAILURE); return (-1); } if (!(s->mode & SSL_MODE_AUTO_RETRY)) { if (s->s3->rbuf.left == 0) /* no read-ahead left? */ { BIO *bio; /* In the case where we try to read application data, * but we trigger an SSL handshake, we return -1 with * the retry option set. Otherwise renegotiation may * cause nasty problems in the blocking world */ s->rwstate = SSL_READING; bio = SSL_get_rbio(s); BIO_clear_retry_flags(bio); BIO_set_retry_read(bio); return (-1); } } goto start; } switch (rr->type) { default: /* TLS just ignores unknown message types */ if (s->version == TLS1_VERSION) { rr->length = 0; goto start; } al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_DTLS1_READ_BYTES, SSL_R_UNEXPECTED_RECORD); goto f_err; case SSL3_RT_CHANGE_CIPHER_SPEC: case SSL3_RT_ALERT: case SSL3_RT_HANDSHAKE: /* we already handled all of these, with the possible exception * of SSL3_RT_HANDSHAKE when s->in_handshake is set, but that * should not happen when type != rr->type */ al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_DTLS1_READ_BYTES, ERR_R_INTERNAL_ERROR); goto f_err; case SSL3_RT_APPLICATION_DATA: /* At this point, we were expecting handshake data, * but have application data. If the library was * running inside ssl3_read() (i.e. in_read_app_data * is set) and it makes sense to read application data * at this point (session renegotiation not yet started), * we will indulge it. */ if (s->s3->in_read_app_data && (s->s3->total_renegotiations != 0) && (((s->state & SSL_ST_CONNECT) && (s->state >= SSL3_ST_CW_CLNT_HELLO_A) && (s->state <= SSL3_ST_CR_SRVR_HELLO_A)) || ( (s->state & SSL_ST_ACCEPT) && (s->state <= SSL3_ST_SW_HELLO_REQ_A) && (s->state >= SSL3_ST_SR_CLNT_HELLO_A)))) { s->s3->in_read_app_data = 2; return (-1); } else { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_DTLS1_READ_BYTES, SSL_R_UNEXPECTED_RECORD); goto f_err; } } /* not reached */ f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: return (-1); } int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf_, int len) { int i; #ifndef OPENSSL_NO_SCTP /* Check if we have to continue an interrupted handshake * for reading belated app data with SCTP. */ if ((SSL_in_init(s) && !s->in_handshake) || (BIO_dgram_is_sctp(SSL_get_wbio(s)) && (s->state == DTLS1_SCTP_ST_SR_READ_SOCK || s->state == DTLS1_SCTP_ST_CR_READ_SOCK))) #else if (SSL_in_init(s) && !s->in_handshake) #endif { i = s->handshake_func(s); if (i < 0) return (i); if (i == 0) { SSLerr(SSL_F_DTLS1_WRITE_APP_DATA_BYTES, SSL_R_SSL_HANDSHAKE_FAILURE); return -1; } } if (len > SSL3_RT_MAX_PLAIN_LENGTH) { SSLerr(SSL_F_DTLS1_WRITE_APP_DATA_BYTES, SSL_R_DTLS_MESSAGE_TOO_BIG); return -1; } i = dtls1_write_bytes(s, type, buf_, len); return i; } /* this only happens when a client hello is received and a handshake * is started. */ static int have_handshake_fragment(SSL *s, int type, unsigned char *buf, int len, int peek) { if ((type == SSL3_RT_HANDSHAKE) && (s->d1->handshake_fragment_len > 0)) /* (partially) satisfy request from storage */ { unsigned char *src = s->d1->handshake_fragment; unsigned char *dst = buf; unsigned int k, n; /* peek == 0 */ n = 0; while ((len > 0) && (s->d1->handshake_fragment_len > 0)) { *dst++ = *src++; len--; s->d1->handshake_fragment_len--; n++; } /* move any remaining fragment bytes: */ for (k = 0; k < s->d1->handshake_fragment_len; k++) s->d1->handshake_fragment[k] = *src++; return n; } return 0; } /* Call this to write data in records of type 'type' * It will return <= 0 if not all data has been sent or non-blocking IO. */ int dtls1_write_bytes(SSL *s, int type, const void *buf, int len) { int i; OPENSSL_assert(len <= SSL3_RT_MAX_PLAIN_LENGTH); s->rwstate = SSL_NOTHING; i = do_dtls1_write(s, type, buf, len); return i; } int do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len) { unsigned char *p, *pseq; int i, mac_size, clear = 0; int prefix_len = 0; SSL3_RECORD *wr; SSL3_BUFFER *wb; SSL_SESSION *sess; int bs; /* first check if there is a SSL3_BUFFER still being written * out. This will happen with non blocking IO */ if (s->s3->wbuf.left != 0) { OPENSSL_assert(0); /* XDTLS: want to see if we ever get here */ return (ssl3_write_pending(s, type, buf, len)); } /* If we have an alert to send, lets send it */ if (s->s3->alert_dispatch) { i = s->method->ssl_dispatch_alert(s); if (i <= 0) return (i); /* if it went, fall through and send more stuff */ } if (len == 0) return 0; wr = &(s->s3->wrec); wb = &(s->s3->wbuf); sess = s->session; if ((sess == NULL) || (s->enc_write_ctx == NULL) || (EVP_MD_CTX_md(s->write_hash) == NULL)) clear = 1; if (clear) mac_size = 0; else { mac_size = EVP_MD_CTX_size(s->write_hash); if (mac_size < 0) goto err; } /* DTLS implements explicit IV, so no need for empty fragments. */ p = wb->buf + prefix_len; /* write the header */ *(p++) = type&0xff; wr->type = type; *(p++) = (s->version >> 8); *(p++) = s->version&0xff; /* field where we are to write out packet epoch, seq num and len */ pseq = p; p += 10; /* lets setup the record stuff. */ /* Make space for the explicit IV in case of CBC. * (this is a bit of a boundary violation, but what the heck). */ if (s->enc_write_ctx && (EVP_CIPHER_mode( s->enc_write_ctx->cipher ) & EVP_CIPH_CBC_MODE)) bs = EVP_CIPHER_block_size(s->enc_write_ctx->cipher); else bs = 0; wr->data = p + bs; /* make room for IV in case of CBC */ wr->length = (int)len; wr->input = (unsigned char *)buf; /* we now 'read' from wr->input, wr->length bytes into * wr->data */ memcpy(wr->data, wr->input, wr->length); wr->input = wr->data; /* we should still have the output to wr->data and the input * from wr->input. Length should be wr->length. * wr->data still points in the wb->buf */ if (mac_size != 0) { if (s->method->ssl3_enc->mac(s, &(p[wr->length + bs]), 1) < 0) goto err; wr->length += mac_size; } /* this is true regardless of mac size */ wr->input = p; wr->data = p; /* ssl3_enc can only have an error on read */ if (bs) /* bs != 0 in case of CBC */ { RAND_pseudo_bytes(p, bs); /* master IV and last CBC residue stand for * the rest of randomness */ wr->length += bs; } s->method->ssl3_enc->enc(s, 1); /* record length after mac and block padding */ /* if (type == SSL3_RT_APPLICATION_DATA || (type == SSL3_RT_ALERT && ! SSL_in_init(s))) */ /* there's only one epoch between handshake and app data */ s2n(s->d1->w_epoch, pseq); /* XDTLS: ?? */ /* else s2n(s->d1->handshake_epoch, pseq); */ memcpy(pseq, &(s->s3->write_sequence[2]), 6); pseq += 6; s2n(wr->length, pseq); /* we should now have * wr->data pointing to the encrypted data, which is * wr->length long */ wr->type=type; /* not needed but helps for debugging */ wr->length += DTLS1_RT_HEADER_LENGTH; ssl3_record_sequence_increment(s->s3->write_sequence); /* now let's set up wb */ wb->left = prefix_len + wr->length; wb->offset = 0; /* memorize arguments so that ssl3_write_pending can detect bad write retries later */ s->s3->wpend_tot = len; s->s3->wpend_buf = buf; s->s3->wpend_type = type; s->s3->wpend_ret = len; /* we now just need to write the buffer */ return ssl3_write_pending(s, type, buf, len); err: return -1; } static int dtls1_record_replay_check(SSL *s, DTLS1_BITMAP *bitmap) { int cmp; unsigned int shift; const unsigned char *seq = s->s3->read_sequence; cmp = satsub64be(seq, bitmap->max_seq_num); if (cmp > 0) { memcpy (s->s3->rrec.seq_num, seq, 8); return 1; /* this record in new */ } shift = -cmp; if (shift >= sizeof(bitmap->map)*8) return 0; /* stale, outside the window */ else if (bitmap->map & (1UL << shift)) return 0; /* record previously received */ memcpy(s->s3->rrec.seq_num, seq, 8); return 1; } static void dtls1_record_bitmap_update(SSL *s, DTLS1_BITMAP *bitmap) { int cmp; unsigned int shift; const unsigned char *seq = s->s3->read_sequence; cmp = satsub64be(seq, bitmap->max_seq_num); if (cmp > 0) { shift = cmp; if (shift < sizeof(bitmap->map)*8) bitmap->map <<= shift, bitmap->map |= 1UL; else bitmap->map = 1UL; memcpy(bitmap->max_seq_num, seq, 8); } else { shift = -cmp; if (shift < sizeof(bitmap->map) * 8) bitmap->map |= 1UL << shift; } } int dtls1_dispatch_alert(SSL *s) { int i, j; void (*cb)(const SSL *ssl, int type, int val) = NULL; unsigned char buf[DTLS1_AL_HEADER_LENGTH]; unsigned char *ptr = &buf[0]; s->s3->alert_dispatch = 0; memset(buf, 0x00, sizeof(buf)); *ptr++ = s->s3->send_alert[0]; *ptr++ = s->s3->send_alert[1]; #ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE if (s->s3->send_alert[1] == DTLS1_AD_MISSING_HANDSHAKE_MESSAGE) { s2n(s->d1->handshake_read_seq, ptr); l2n3(s->d1->r_msg_hdr.frag_off, ptr); } #endif i = do_dtls1_write(s, SSL3_RT_ALERT, &buf[0], sizeof(buf)); if (i <= 0) { s->s3->alert_dispatch = 1; /* fprintf( stderr, "not done with alert\n" ); */ } else { if (s->s3->send_alert[0] == SSL3_AL_FATAL #ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE || s->s3->send_alert[1] == DTLS1_AD_MISSING_HANDSHAKE_MESSAGE #endif ) (void)BIO_flush(s->wbio); if (s->msg_callback) s->msg_callback(1, s->version, SSL3_RT_ALERT, s->s3->send_alert, 2, s, s->msg_callback_arg); if (s->info_callback != NULL) cb = s->info_callback; else if (s->ctx->info_callback != NULL) cb = s->ctx->info_callback; if (cb != NULL) { j = (s->s3->send_alert[0]<<8)|s->s3->send_alert[1]; cb(s, SSL_CB_WRITE_ALERT, j); } } return (i); } static DTLS1_BITMAP * dtls1_get_bitmap(SSL *s, SSL3_RECORD *rr, unsigned int *is_next_epoch) { *is_next_epoch = 0; /* In current epoch, accept HM, CCS, DATA, & ALERT */ if (rr->epoch == s->d1->r_epoch) return &s->d1->bitmap; /* Only HM and ALERT messages can be from the next epoch */ else if (rr->epoch == (unsigned long)(s->d1->r_epoch + 1) && (rr->type == SSL3_RT_HANDSHAKE || rr->type == SSL3_RT_ALERT)) { *is_next_epoch = 1; return &s->d1->next_bitmap; } return NULL; } void dtls1_reset_seq_numbers(SSL *s, int rw) { unsigned char *seq; unsigned int seq_bytes = sizeof(s->s3->read_sequence); if (rw & SSL3_CC_READ) { seq = s->s3->read_sequence; s->d1->r_epoch++; memcpy(&(s->d1->bitmap), &(s->d1->next_bitmap), sizeof(DTLS1_BITMAP)); memset(&(s->d1->next_bitmap), 0x00, sizeof(DTLS1_BITMAP)); } else { seq = s->s3->write_sequence; memcpy(s->d1->last_write_sequence, seq, sizeof(s->s3->write_sequence)); s->d1->w_epoch++; } memset(seq, 0x00, seq_bytes); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/t1_lib.c0000644000175000017500000016551712360020705017071 0ustar /* $OpenBSD: t1_lib.c,v 1.48 2014/06/19 21:29:51 tedu Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include "ssl_locl.h" static int tls_decrypt_ticket(SSL *s, const unsigned char *tick, int ticklen, const unsigned char *sess_id, int sesslen, SSL_SESSION **psess); SSL3_ENC_METHOD TLSv1_enc_data = { .enc = tls1_enc, .mac = tls1_mac, .setup_key_block = tls1_setup_key_block, .generate_master_secret = tls1_generate_master_secret, .change_cipher_state = tls1_change_cipher_state, .final_finish_mac = tls1_final_finish_mac, .finish_mac_length = TLS1_FINISH_MAC_LENGTH, .cert_verify_mac = tls1_cert_verify_mac, .client_finished_label = TLS_MD_CLIENT_FINISH_CONST, .client_finished_label_len = TLS_MD_CLIENT_FINISH_CONST_SIZE, .server_finished_label = TLS_MD_SERVER_FINISH_CONST, .server_finished_label_len = TLS_MD_SERVER_FINISH_CONST_SIZE, .alert_value = tls1_alert_code, .export_keying_material = tls1_export_keying_material, .enc_flags = 0, }; SSL3_ENC_METHOD TLSv1_1_enc_data = { .enc = tls1_enc, .mac = tls1_mac, .setup_key_block = tls1_setup_key_block, .generate_master_secret = tls1_generate_master_secret, .change_cipher_state = tls1_change_cipher_state, .final_finish_mac = tls1_final_finish_mac, .finish_mac_length = TLS1_FINISH_MAC_LENGTH, .cert_verify_mac = tls1_cert_verify_mac, .client_finished_label = TLS_MD_CLIENT_FINISH_CONST, .client_finished_label_len = TLS_MD_CLIENT_FINISH_CONST_SIZE, .server_finished_label = TLS_MD_SERVER_FINISH_CONST, .server_finished_label_len = TLS_MD_SERVER_FINISH_CONST_SIZE, .alert_value = tls1_alert_code, .export_keying_material = tls1_export_keying_material, .enc_flags = SSL_ENC_FLAG_EXPLICIT_IV, }; SSL3_ENC_METHOD TLSv1_2_enc_data = { .enc = tls1_enc, .mac = tls1_mac, .setup_key_block = tls1_setup_key_block, .generate_master_secret = tls1_generate_master_secret, .change_cipher_state = tls1_change_cipher_state, .final_finish_mac = tls1_final_finish_mac, .finish_mac_length = TLS1_FINISH_MAC_LENGTH, .cert_verify_mac = tls1_cert_verify_mac, .client_finished_label = TLS_MD_CLIENT_FINISH_CONST, .client_finished_label_len = TLS_MD_CLIENT_FINISH_CONST_SIZE, .server_finished_label = TLS_MD_SERVER_FINISH_CONST, .server_finished_label_len = TLS_MD_SERVER_FINISH_CONST_SIZE, .alert_value = tls1_alert_code, .export_keying_material = tls1_export_keying_material, .enc_flags = SSL_ENC_FLAG_EXPLICIT_IV|SSL_ENC_FLAG_SIGALGS| SSL_ENC_FLAG_SHA256_PRF|SSL_ENC_FLAG_TLS1_2_CIPHERS, }; long tls1_default_timeout(void) { /* 2 hours, the 24 hours mentioned in the TLSv1 spec * is way too long for http, the cache would over fill */ return (60 * 60 * 2); } int tls1_new(SSL *s) { if (!ssl3_new(s)) return (0); s->method->ssl_clear(s); return (1); } void tls1_free(SSL *s) { free(s->tlsext_session_ticket); ssl3_free(s); } void tls1_clear(SSL *s) { ssl3_clear(s); s->version = s->method->version; } static int nid_list[] = { NID_sect163k1, /* sect163k1 (1) */ NID_sect163r1, /* sect163r1 (2) */ NID_sect163r2, /* sect163r2 (3) */ NID_sect193r1, /* sect193r1 (4) */ NID_sect193r2, /* sect193r2 (5) */ NID_sect233k1, /* sect233k1 (6) */ NID_sect233r1, /* sect233r1 (7) */ NID_sect239k1, /* sect239k1 (8) */ NID_sect283k1, /* sect283k1 (9) */ NID_sect283r1, /* sect283r1 (10) */ NID_sect409k1, /* sect409k1 (11) */ NID_sect409r1, /* sect409r1 (12) */ NID_sect571k1, /* sect571k1 (13) */ NID_sect571r1, /* sect571r1 (14) */ NID_secp160k1, /* secp160k1 (15) */ NID_secp160r1, /* secp160r1 (16) */ NID_secp160r2, /* secp160r2 (17) */ NID_secp192k1, /* secp192k1 (18) */ NID_X9_62_prime192v1, /* secp192r1 (19) */ NID_secp224k1, /* secp224k1 (20) */ NID_secp224r1, /* secp224r1 (21) */ NID_secp256k1, /* secp256k1 (22) */ NID_X9_62_prime256v1, /* secp256r1 (23) */ NID_secp384r1, /* secp384r1 (24) */ NID_secp521r1, /* secp521r1 (25) */ NID_brainpoolP256r1, /* brainpoolP256r1 (26) */ NID_brainpoolP384r1, /* brainpoolP384r1 (27) */ NID_brainpoolP512r1 /* brainpoolP512r1 (28) */ }; static int pref_list[] = { NID_sect571r1, /* sect571r1 (14) */ NID_sect571k1, /* sect571k1 (13) */ NID_secp521r1, /* secp521r1 (25) */ NID_brainpoolP512r1, /* brainpoolP512r1 (28) */ NID_sect409k1, /* sect409k1 (11) */ NID_sect409r1, /* sect409r1 (12) */ NID_brainpoolP384r1, /* brainpoolP384r1 (27) */ NID_secp384r1, /* secp384r1 (24) */ NID_sect283k1, /* sect283k1 (9) */ NID_sect283r1, /* sect283r1 (10) */ NID_brainpoolP256r1, /* brainpoolP256r1 (26) */ NID_secp256k1, /* secp256k1 (22) */ NID_X9_62_prime256v1, /* secp256r1 (23) */ NID_sect239k1, /* sect239k1 (8) */ NID_sect233k1, /* sect233k1 (6) */ NID_sect233r1, /* sect233r1 (7) */ NID_secp224k1, /* secp224k1 (20) */ NID_secp224r1, /* secp224r1 (21) */ NID_sect193r1, /* sect193r1 (4) */ NID_sect193r2, /* sect193r2 (5) */ NID_secp192k1, /* secp192k1 (18) */ NID_X9_62_prime192v1, /* secp192r1 (19) */ NID_sect163k1, /* sect163k1 (1) */ NID_sect163r1, /* sect163r1 (2) */ NID_sect163r2, /* sect163r2 (3) */ NID_secp160k1, /* secp160k1 (15) */ NID_secp160r1, /* secp160r1 (16) */ NID_secp160r2, /* secp160r2 (17) */ }; int tls1_ec_curve_id2nid(int curve_id) { /* ECC curves from draft-ietf-tls-ecc-12.txt (Oct. 17, 2005) */ if ((curve_id < 1) || ((unsigned int)curve_id > sizeof(nid_list) / sizeof(nid_list[0]))) return 0; return nid_list[curve_id - 1]; } int tls1_ec_nid2curve_id(int nid) { /* ECC curves from draft-ietf-tls-ecc-12.txt (Oct. 17, 2005) */ switch (nid) { case NID_sect163k1: /* sect163k1 (1) */ return 1; case NID_sect163r1: /* sect163r1 (2) */ return 2; case NID_sect163r2: /* sect163r2 (3) */ return 3; case NID_sect193r1: /* sect193r1 (4) */ return 4; case NID_sect193r2: /* sect193r2 (5) */ return 5; case NID_sect233k1: /* sect233k1 (6) */ return 6; case NID_sect233r1: /* sect233r1 (7) */ return 7; case NID_sect239k1: /* sect239k1 (8) */ return 8; case NID_sect283k1: /* sect283k1 (9) */ return 9; case NID_sect283r1: /* sect283r1 (10) */ return 10; case NID_sect409k1: /* sect409k1 (11) */ return 11; case NID_sect409r1: /* sect409r1 (12) */ return 12; case NID_sect571k1: /* sect571k1 (13) */ return 13; case NID_sect571r1: /* sect571r1 (14) */ return 14; case NID_secp160k1: /* secp160k1 (15) */ return 15; case NID_secp160r1: /* secp160r1 (16) */ return 16; case NID_secp160r2: /* secp160r2 (17) */ return 17; case NID_secp192k1: /* secp192k1 (18) */ return 18; case NID_X9_62_prime192v1: /* secp192r1 (19) */ return 19; case NID_secp224k1: /* secp224k1 (20) */ return 20; case NID_secp224r1: /* secp224r1 (21) */ return 21; case NID_secp256k1: /* secp256k1 (22) */ return 22; case NID_X9_62_prime256v1: /* secp256r1 (23) */ return 23; case NID_secp384r1: /* secp384r1 (24) */ return 24; case NID_secp521r1: /* secp521r1 (25) */ return 25; case NID_brainpoolP256r1: /* brainpoolP256r1 (26) */ return 26; case NID_brainpoolP384r1: /* brainpoolP384r1 (27) */ return 27; case NID_brainpoolP512r1: /* brainpoolP512r1 (28) */ return 28; default: return 0; } } /* List of supported signature algorithms and hashes. Should make this * customisable at some point, for now include everything we support. */ #define tlsext_sigalg_rsa(md) md, TLSEXT_signature_rsa, #define tlsext_sigalg_dsa(md) md, TLSEXT_signature_dsa, #define tlsext_sigalg_ecdsa(md) md, TLSEXT_signature_ecdsa, #define tlsext_sigalg(md) \ tlsext_sigalg_rsa(md) \ tlsext_sigalg_dsa(md) \ tlsext_sigalg_ecdsa(md) static unsigned char tls12_sigalgs[] = { tlsext_sigalg(TLSEXT_hash_sha512) tlsext_sigalg(TLSEXT_hash_sha384) tlsext_sigalg(TLSEXT_hash_sha256) tlsext_sigalg(TLSEXT_hash_sha224) tlsext_sigalg(TLSEXT_hash_sha1) }; int tls12_get_req_sig_algs(SSL *s, unsigned char *p) { size_t slen = sizeof(tls12_sigalgs); if (p) memcpy(p, tls12_sigalgs, slen); return (int)slen; } unsigned char * ssl_add_clienthello_tlsext(SSL *s, unsigned char *p, unsigned char *limit) { int extdatalen = 0; unsigned char *ret = p; /* don't add extensions for SSLv3 unless doing secure renegotiation */ if (s->client_version == SSL3_VERSION && !s->s3->send_connection_binding) return p; ret += 2; if (ret >= limit) return NULL; /* this really never occurs, but ... */ if (s->tlsext_hostname != NULL) { /* Add TLS extension servername to the Client Hello message */ size_t size_str, lenmax; /* check for enough space. 4 for the servername type and extension length 2 for servernamelist length 1 for the hostname type 2 for hostname length + hostname length */ if ((size_t)(limit - ret) < 9) return NULL; lenmax = limit - ret - 9; if ((size_str = strlen(s->tlsext_hostname)) > lenmax) return NULL; /* extension type and length */ s2n(TLSEXT_TYPE_server_name, ret); s2n(size_str + 5, ret); /* length of servername list */ s2n(size_str + 3, ret); /* hostname type, length and hostname */ *(ret++) = (unsigned char) TLSEXT_NAMETYPE_host_name; s2n(size_str, ret); memcpy(ret, s->tlsext_hostname, size_str); ret += size_str; } /* Add RI if renegotiating */ if (s->renegotiate) { int el; if (!ssl_add_clienthello_renegotiate_ext(s, 0, &el, 0)) { SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } if ((size_t)(limit - ret) < 4 + el) return NULL; s2n(TLSEXT_TYPE_renegotiate, ret); s2n(el, ret); if (!ssl_add_clienthello_renegotiate_ext(s, ret, &el, el)) { SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } ret += el; } if (s->tlsext_ecpointformatlist != NULL && s->version != DTLS1_VERSION) { /* Add TLS extension ECPointFormats to the ClientHello message */ size_t lenmax; if ((size_t)(limit - ret) < 5) return NULL; lenmax = limit - ret - 5; if (s->tlsext_ecpointformatlist_length > lenmax) return NULL; if (s->tlsext_ecpointformatlist_length > 255) { SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } s2n(TLSEXT_TYPE_ec_point_formats, ret); s2n(s->tlsext_ecpointformatlist_length + 1, ret); *(ret++) = (unsigned char) s->tlsext_ecpointformatlist_length; memcpy(ret, s->tlsext_ecpointformatlist, s->tlsext_ecpointformatlist_length); ret += s->tlsext_ecpointformatlist_length; } if (s->tlsext_ellipticcurvelist != NULL && s->version != DTLS1_VERSION) { /* Add TLS extension EllipticCurves to the ClientHello message */ size_t lenmax; if ((size_t)(limit - ret) < 6) return NULL; lenmax = limit - ret - 6; if (s->tlsext_ellipticcurvelist_length > lenmax) return NULL; if (s->tlsext_ellipticcurvelist_length > 65532) { SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } s2n(TLSEXT_TYPE_elliptic_curves, ret); s2n(s->tlsext_ellipticcurvelist_length + 2, ret); /* NB: draft-ietf-tls-ecc-12.txt uses a one-byte prefix for * elliptic_curve_list, but the examples use two bytes. * http://www1.ietf.org/mail-archive/web/tls/current/msg00538.html * resolves this to two bytes. */ s2n(s->tlsext_ellipticcurvelist_length, ret); memcpy(ret, s->tlsext_ellipticcurvelist, s->tlsext_ellipticcurvelist_length); ret += s->tlsext_ellipticcurvelist_length; } if (!(SSL_get_options(s) & SSL_OP_NO_TICKET)) { int ticklen; if (!s->new_session && s->session && s->session->tlsext_tick) ticklen = s->session->tlsext_ticklen; else if (s->session && s->tlsext_session_ticket && s->tlsext_session_ticket->data) { ticklen = s->tlsext_session_ticket->length; s->session->tlsext_tick = malloc(ticklen); if (!s->session->tlsext_tick) return NULL; memcpy(s->session->tlsext_tick, s->tlsext_session_ticket->data, ticklen); s->session->tlsext_ticklen = ticklen; } else ticklen = 0; if (ticklen == 0 && s->tlsext_session_ticket && s->tlsext_session_ticket->data == NULL) goto skip_ext; /* Check for enough room 2 for extension type, 2 for len * rest for ticket */ if ((size_t)(limit - ret) < 4 + ticklen) return NULL; s2n(TLSEXT_TYPE_session_ticket, ret); s2n(ticklen, ret); if (ticklen) { memcpy(ret, s->session->tlsext_tick, ticklen); ret += ticklen; } } skip_ext: if (TLS1_get_client_version(s) >= TLS1_2_VERSION) { if ((size_t)(limit - ret) < sizeof(tls12_sigalgs) + 6) return NULL; s2n(TLSEXT_TYPE_signature_algorithms, ret); s2n(sizeof(tls12_sigalgs) + 2, ret); s2n(sizeof(tls12_sigalgs), ret); memcpy(ret, tls12_sigalgs, sizeof(tls12_sigalgs)); ret += sizeof(tls12_sigalgs); } if (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp && s->version != DTLS1_VERSION) { int i; long extlen, idlen, itmp; OCSP_RESPID *id; idlen = 0; for (i = 0; i < sk_OCSP_RESPID_num(s->tlsext_ocsp_ids); i++) { id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i); itmp = i2d_OCSP_RESPID(id, NULL); if (itmp <= 0) return NULL; idlen += itmp + 2; } if (s->tlsext_ocsp_exts) { extlen = i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, NULL); if (extlen < 0) return NULL; } else extlen = 0; if ((size_t)(limit - ret) < 7 + extlen + idlen) return NULL; s2n(TLSEXT_TYPE_status_request, ret); if (extlen + idlen > 0xFFF0) return NULL; s2n(extlen + idlen + 5, ret); *(ret++) = TLSEXT_STATUSTYPE_ocsp; s2n(idlen, ret); for (i = 0; i < sk_OCSP_RESPID_num(s->tlsext_ocsp_ids); i++) { /* save position of id len */ unsigned char *q = ret; id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i); /* skip over id len */ ret += 2; itmp = i2d_OCSP_RESPID(id, &ret); /* write id len */ s2n(itmp, q); } s2n(extlen, ret); if (extlen > 0) i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, &ret); } #ifndef OPENSSL_NO_NEXTPROTONEG if (s->ctx->next_proto_select_cb && !s->s3->tmp.finish_md_len) { /* The client advertises an emtpy extension to indicate its * support for Next Protocol Negotiation */ if ((size_t)(limit - ret) < 4) return NULL; s2n(TLSEXT_TYPE_next_proto_neg, ret); s2n(0, ret); } #endif #ifndef OPENSSL_NO_SRTP if (SSL_get_srtp_profiles(s)) { int el; ssl_add_clienthello_use_srtp_ext(s, 0, &el, 0); if ((size_t)(limit - ret) < 4 + el) return NULL; s2n(TLSEXT_TYPE_use_srtp, ret); s2n(el, ret); if (ssl_add_clienthello_use_srtp_ext(s, ret, &el, el)) { SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } ret += el; } #endif #ifdef TLSEXT_TYPE_padding /* Add padding to workaround bugs in F5 terminators. * See https://tools.ietf.org/html/draft-agl-tls-padding-03 * * NB: because this code works out the length of all existing * extensions it MUST always appear last. */ { int hlen = ret - (unsigned char *)s->init_buf->data; /* The code in s23_clnt.c to build ClientHello messages includes the * 5-byte record header in the buffer, while the code in s3_clnt.c does * not. */ if (s->state == SSL23_ST_CW_CLNT_HELLO_A) hlen -= 5; if (hlen > 0xff && hlen < 0x200) { hlen = 0x200 - hlen; if (hlen >= 4) hlen -= 4; else hlen = 0; s2n(TLSEXT_TYPE_padding, ret); s2n(hlen, ret); memset(ret, 0, hlen); ret += hlen; } } #endif if ((extdatalen = ret - p - 2) == 0) return p; s2n(extdatalen, p); return ret; } unsigned char * ssl_add_serverhello_tlsext(SSL *s, unsigned char *p, unsigned char *limit) { int extdatalen = 0; unsigned char *ret = p; #ifndef OPENSSL_NO_NEXTPROTONEG int next_proto_neg_seen; #endif /* don't add extensions for SSLv3, unless doing secure renegotiation */ if (s->version == SSL3_VERSION && !s->s3->send_connection_binding) return p; ret += 2; if (ret >= limit) return NULL; /* this really never occurs, but ... */ if (!s->hit && s->servername_done == 1 && s->session->tlsext_hostname != NULL) { if ((size_t)(limit - ret) < 4) return NULL; s2n(TLSEXT_TYPE_server_name, ret); s2n(0, ret); } if (s->s3->send_connection_binding) { int el; if (!ssl_add_serverhello_renegotiate_ext(s, 0, &el, 0)) { SSLerr(SSL_F_SSL_ADD_SERVERHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } if ((size_t)(limit - ret) < 4 + el) return NULL; s2n(TLSEXT_TYPE_renegotiate, ret); s2n(el, ret); if (!ssl_add_serverhello_renegotiate_ext(s, ret, &el, el)) { SSLerr(SSL_F_SSL_ADD_SERVERHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } ret += el; } if (s->tlsext_ecpointformatlist != NULL && s->version != DTLS1_VERSION) { /* Add TLS extension ECPointFormats to the ServerHello message */ size_t lenmax; if ((size_t)(limit - ret) < 5) return NULL; lenmax = limit - ret - 5; if (s->tlsext_ecpointformatlist_length > lenmax) return NULL; if (s->tlsext_ecpointformatlist_length > 255) { SSLerr(SSL_F_SSL_ADD_SERVERHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } s2n(TLSEXT_TYPE_ec_point_formats, ret); s2n(s->tlsext_ecpointformatlist_length + 1, ret); *(ret++) = (unsigned char) s->tlsext_ecpointformatlist_length; memcpy(ret, s->tlsext_ecpointformatlist, s->tlsext_ecpointformatlist_length); ret += s->tlsext_ecpointformatlist_length; } /* Currently the server should not respond with a SupportedCurves extension */ if (s->tlsext_ticket_expected && !(SSL_get_options(s) & SSL_OP_NO_TICKET)) { if ((size_t)(limit - ret) < 4) return NULL; s2n(TLSEXT_TYPE_session_ticket, ret); s2n(0, ret); } if (s->tlsext_status_expected) { if ((size_t)(limit - ret) < 4) return NULL; s2n(TLSEXT_TYPE_status_request, ret); s2n(0, ret); } #ifndef OPENSSL_NO_SRTP if (s->srtp_profile) { int el; ssl_add_serverhello_use_srtp_ext(s, 0, &el, 0); if ((size_t)(limit - ret) < 4 + el) return NULL; s2n(TLSEXT_TYPE_use_srtp, ret); s2n(el, ret); if (ssl_add_serverhello_use_srtp_ext(s, ret, &el, el)) { SSLerr(SSL_F_SSL_ADD_SERVERHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } ret += el; } #endif if (((s->s3->tmp.new_cipher->id & 0xFFFF) == 0x80 || (s->s3->tmp.new_cipher->id & 0xFFFF) == 0x81) && (SSL_get_options(s) & SSL_OP_CRYPTOPRO_TLSEXT_BUG)) { static const unsigned char cryptopro_ext[36] = { 0xfd, 0xe8, /*65000*/ 0x00, 0x20, /*32 bytes length*/ 0x30, 0x1e, 0x30, 0x08, 0x06, 0x06, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x09, 0x30, 0x08, 0x06, 0x06, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x16, 0x30, 0x08, 0x06, 0x06, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x17 }; if ((size_t)(limit - ret) < sizeof(cryptopro_ext)) return NULL; memcpy(ret, cryptopro_ext, sizeof(cryptopro_ext)); ret += sizeof(cryptopro_ext); } #ifndef OPENSSL_NO_NEXTPROTONEG next_proto_neg_seen = s->s3->next_proto_neg_seen; s->s3->next_proto_neg_seen = 0; if (next_proto_neg_seen && s->ctx->next_protos_advertised_cb) { const unsigned char *npa; unsigned int npalen; int r; r = s->ctx->next_protos_advertised_cb(s, &npa, &npalen, s->ctx->next_protos_advertised_cb_arg); if (r == SSL_TLSEXT_ERR_OK) { if ((size_t)(limit - ret) < 4 + npalen) return NULL; s2n(TLSEXT_TYPE_next_proto_neg, ret); s2n(npalen, ret); memcpy(ret, npa, npalen); ret += npalen; s->s3->next_proto_neg_seen = 1; } } #endif if ((extdatalen = ret - p - 2) == 0) return p; s2n(extdatalen, p); return ret; } /* ssl_check_for_safari attempts to fingerprint Safari using OS X * SecureTransport using the TLS extension block in |d|, of length |n|. * Safari, since 10.6, sends exactly these extensions, in this order: * SNI, * elliptic_curves * ec_point_formats * * We wish to fingerprint Safari because they broke ECDHE-ECDSA support in 10.8, * but they advertise support. So enabling ECDHE-ECDSA ciphers breaks them. * Sadly we cannot differentiate 10.6, 10.7 and 10.8.4 (which work), from * 10.8..10.8.3 (which don't work). */ static void ssl_check_for_safari(SSL *s, const unsigned char *data, const unsigned char *d, int n) { unsigned short type, size; static const unsigned char kSafariExtensionsBlock[] = { 0x00, 0x0a, /* elliptic_curves extension */ 0x00, 0x08, /* 8 bytes */ 0x00, 0x06, /* 6 bytes of curve ids */ 0x00, 0x17, /* P-256 */ 0x00, 0x18, /* P-384 */ 0x00, 0x19, /* P-521 */ 0x00, 0x0b, /* ec_point_formats */ 0x00, 0x02, /* 2 bytes */ 0x01, /* 1 point format */ 0x00, /* uncompressed */ }; /* The following is only present in TLS 1.2 */ static const unsigned char kSafariTLS12ExtensionsBlock[] = { 0x00, 0x0d, /* signature_algorithms */ 0x00, 0x0c, /* 12 bytes */ 0x00, 0x0a, /* 10 bytes */ 0x05, 0x01, /* SHA-384/RSA */ 0x04, 0x01, /* SHA-256/RSA */ 0x02, 0x01, /* SHA-1/RSA */ 0x04, 0x03, /* SHA-256/ECDSA */ 0x02, 0x03, /* SHA-1/ECDSA */ }; if (data >= (d + n - 2)) return; data += 2; if (data > (d + n - 4)) return; n2s(data, type); n2s(data, size); if (type != TLSEXT_TYPE_server_name) return; if (data + size > d + n) return; data += size; if (TLS1_get_client_version(s) >= TLS1_2_VERSION) { const size_t len1 = sizeof(kSafariExtensionsBlock); const size_t len2 = sizeof(kSafariTLS12ExtensionsBlock); if (data + len1 + len2 != d + n) return; if (memcmp(data, kSafariExtensionsBlock, len1) != 0) return; if (memcmp(data + len1, kSafariTLS12ExtensionsBlock, len2) != 0) return; } else { const size_t len = sizeof(kSafariExtensionsBlock); if (data + len != d + n) return; if (memcmp(data, kSafariExtensionsBlock, len) != 0) return; } s->s3->is_probably_safari = 1; } int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, int n, int *al) { unsigned short type; unsigned short size; unsigned short len; unsigned char *data = *p; int renegotiate_seen = 0; int sigalg_seen = 0; s->servername_done = 0; s->tlsext_status_type = -1; #ifndef OPENSSL_NO_NEXTPROTONEG s->s3->next_proto_neg_seen = 0; #endif if (s->options & SSL_OP_SAFARI_ECDHE_ECDSA_BUG) ssl_check_for_safari(s, data, d, n); if (data >= (d + n - 2)) goto ri_check; n2s(data, len); if (data > (d + n - len)) goto ri_check; while (data <= (d + n - 4)) { n2s(data, type); n2s(data, size); if (data + size > (d + n)) goto ri_check; if (s->tlsext_debug_cb) s->tlsext_debug_cb(s, 0, type, data, size, s->tlsext_debug_arg); /* The servername extension is treated as follows: - Only the hostname type is supported with a maximum length of 255. - The servername is rejected if too long or if it contains zeros, in which case an fatal alert is generated. - The servername field is maintained together with the session cache. - When a session is resumed, the servername call back invoked in order to allow the application to position itself to the right context. - The servername is acknowledged if it is new for a session or when it is identical to a previously used for the same session. Applications can control the behaviour. They can at any time set a 'desirable' servername for a new SSL object. This can be the case for example with HTTPS when a Host: header field is received and a renegotiation is requested. In this case, a possible servername presented in the new client hello is only acknowledged if it matches the value of the Host: field. - Applications must use SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION if they provide for changing an explicit servername context for the session, i.e. when the session has been established with a servername extension. - On session reconnect, the servername extension may be absent. */ if (type == TLSEXT_TYPE_server_name) { unsigned char *sdata; int servname_type; int dsize; if (size < 2) { *al = SSL_AD_DECODE_ERROR; return 0; } n2s(data, dsize); size -= 2; if (dsize > size) { *al = SSL_AD_DECODE_ERROR; return 0; } sdata = data; while (dsize > 3) { servname_type = *(sdata++); n2s(sdata, len); dsize -= 3; if (len > dsize) { *al = SSL_AD_DECODE_ERROR; return 0; } if (s->servername_done == 0) switch (servname_type) { case TLSEXT_NAMETYPE_host_name: if (!s->hit) { if (s->session->tlsext_hostname) { *al = SSL_AD_DECODE_ERROR; return 0; } if (len > TLSEXT_MAXLEN_host_name) { *al = TLS1_AD_UNRECOGNIZED_NAME; return 0; } if ((s->session->tlsext_hostname = malloc(len + 1)) == NULL) { *al = TLS1_AD_INTERNAL_ERROR; return 0; } memcpy(s->session->tlsext_hostname, sdata, len); s->session->tlsext_hostname[len] = '\0'; if (strlen(s->session->tlsext_hostname) != len) { free(s->session->tlsext_hostname); s->session->tlsext_hostname = NULL; *al = TLS1_AD_UNRECOGNIZED_NAME; return 0; } s->servername_done = 1; } else { s->servername_done = s->session->tlsext_hostname && strlen(s->session->tlsext_hostname) == len && strncmp(s->session->tlsext_hostname, (char *)sdata, len) == 0; } break; default: break; } dsize -= len; } if (dsize != 0) { *al = SSL_AD_DECODE_ERROR; return 0; } } else if (type == TLSEXT_TYPE_ec_point_formats && s->version != DTLS1_VERSION) { unsigned char *sdata = data; int ecpointformatlist_length = *(sdata++); if (ecpointformatlist_length != size - 1) { *al = TLS1_AD_DECODE_ERROR; return 0; } if (!s->hit) { free(s->session->tlsext_ecpointformatlist); s->session->tlsext_ecpointformatlist_length = 0; if ((s->session->tlsext_ecpointformatlist = malloc(ecpointformatlist_length)) == NULL) { *al = TLS1_AD_INTERNAL_ERROR; return 0; } s->session->tlsext_ecpointformatlist_length = ecpointformatlist_length; memcpy(s->session->tlsext_ecpointformatlist, sdata, ecpointformatlist_length); } } else if (type == TLSEXT_TYPE_elliptic_curves && s->version != DTLS1_VERSION) { unsigned char *sdata = data; int ellipticcurvelist_length = (*(sdata++) << 8); ellipticcurvelist_length += (*(sdata++)); if (ellipticcurvelist_length != size - 2 || ellipticcurvelist_length < 1) { *al = TLS1_AD_DECODE_ERROR; return 0; } if (!s->hit) { if (s->session->tlsext_ellipticcurvelist) { *al = TLS1_AD_DECODE_ERROR; return 0; } s->session->tlsext_ellipticcurvelist_length = 0; if ((s->session->tlsext_ellipticcurvelist = malloc(ellipticcurvelist_length)) == NULL) { *al = TLS1_AD_INTERNAL_ERROR; return 0; } s->session->tlsext_ellipticcurvelist_length = ellipticcurvelist_length; memcpy(s->session->tlsext_ellipticcurvelist, sdata, ellipticcurvelist_length); } } else if (type == TLSEXT_TYPE_session_ticket) { if (s->tls_session_ticket_ext_cb && !s->tls_session_ticket_ext_cb(s, data, size, s->tls_session_ticket_ext_cb_arg)) { *al = TLS1_AD_INTERNAL_ERROR; return 0; } } else if (type == TLSEXT_TYPE_renegotiate) { if (!ssl_parse_clienthello_renegotiate_ext(s, data, size, al)) return 0; renegotiate_seen = 1; } else if (type == TLSEXT_TYPE_signature_algorithms) { int dsize; if (sigalg_seen || size < 2) { *al = SSL_AD_DECODE_ERROR; return 0; } sigalg_seen = 1; n2s(data, dsize); size -= 2; if (dsize != size || dsize & 1) { *al = SSL_AD_DECODE_ERROR; return 0; } if (!tls1_process_sigalgs(s, data, dsize)) { *al = SSL_AD_DECODE_ERROR; return 0; } } else if (type == TLSEXT_TYPE_status_request && s->version != DTLS1_VERSION) { if (size < 5) { *al = SSL_AD_DECODE_ERROR; return 0; } s->tlsext_status_type = *data++; size--; if (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp) { const unsigned char *sdata; int dsize; /* Read in responder_id_list */ n2s(data, dsize); size -= 2; if (dsize > size ) { *al = SSL_AD_DECODE_ERROR; return 0; } while (dsize > 0) { OCSP_RESPID *id; int idsize; if (dsize < 4) { *al = SSL_AD_DECODE_ERROR; return 0; } n2s(data, idsize); dsize -= 2 + idsize; size -= 2 + idsize; if (dsize < 0) { *al = SSL_AD_DECODE_ERROR; return 0; } sdata = data; data += idsize; id = d2i_OCSP_RESPID(NULL, &sdata, idsize); if (!id) { *al = SSL_AD_DECODE_ERROR; return 0; } if (data != sdata) { OCSP_RESPID_free(id); *al = SSL_AD_DECODE_ERROR; return 0; } if (!s->tlsext_ocsp_ids && !(s->tlsext_ocsp_ids = sk_OCSP_RESPID_new_null())) { OCSP_RESPID_free(id); *al = SSL_AD_INTERNAL_ERROR; return 0; } if (!sk_OCSP_RESPID_push( s->tlsext_ocsp_ids, id)) { OCSP_RESPID_free(id); *al = SSL_AD_INTERNAL_ERROR; return 0; } } /* Read in request_extensions */ if (size < 2) { *al = SSL_AD_DECODE_ERROR; return 0; } n2s(data, dsize); size -= 2; if (dsize != size) { *al = SSL_AD_DECODE_ERROR; return 0; } sdata = data; if (dsize > 0) { if (s->tlsext_ocsp_exts) { sk_X509_EXTENSION_pop_free(s->tlsext_ocsp_exts, X509_EXTENSION_free); } s->tlsext_ocsp_exts = d2i_X509_EXTENSIONS(NULL, &sdata, dsize); if (!s->tlsext_ocsp_exts || (data + dsize != sdata)) { *al = SSL_AD_DECODE_ERROR; return 0; } } } else { /* We don't know what to do with any other type * so ignore it. */ s->tlsext_status_type = -1; } } #ifndef OPENSSL_NO_NEXTPROTONEG else if (type == TLSEXT_TYPE_next_proto_neg && s->s3->tmp.finish_md_len == 0) { /* We shouldn't accept this extension on a * renegotiation. * * s->new_session will be set on renegotiation, but we * probably shouldn't rely that it couldn't be set on * the initial renegotation too in certain cases (when * there's some other reason to disallow resuming an * earlier session -- the current code won't be doing * anything like that, but this might change). * A valid sign that there's been a previous handshake * in this connection is if s->s3->tmp.finish_md_len > * 0. (We are talking about a check that will happen * in the Hello protocol round, well before a new * Finished message could have been computed.) */ s->s3->next_proto_neg_seen = 1; } #endif /* session ticket processed earlier */ #ifndef OPENSSL_NO_SRTP else if (type == TLSEXT_TYPE_use_srtp) { if (ssl_parse_clienthello_use_srtp_ext(s, data, size, al)) return 0; } #endif data += size; } *p = data; ri_check: /* Need RI if renegotiating */ if (!renegotiate_seen && s->renegotiate) { *al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT, SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); return 0; } return 1; } #ifndef OPENSSL_NO_NEXTPROTONEG /* ssl_next_proto_validate validates a Next Protocol Negotiation block. No * elements of zero length are allowed and the set of elements must exactly fill * the length of the block. */ static char ssl_next_proto_validate(unsigned char *d, unsigned len) { unsigned int off = 0; while (off < len) { if (d[off] == 0) return 0; off += d[off]; off++; } return off == len; } #endif int ssl_parse_serverhello_tlsext(SSL *s, unsigned char **p, unsigned char *d, int n, int *al) { unsigned short length; unsigned short type; unsigned short size; unsigned char *data = *p; int tlsext_servername = 0; int renegotiate_seen = 0; #ifndef OPENSSL_NO_NEXTPROTONEG s->s3->next_proto_neg_seen = 0; #endif if (data >= (d + n - 2)) goto ri_check; n2s(data, length); if (data + length != d + n) { *al = SSL_AD_DECODE_ERROR; return 0; } while (data <= (d + n - 4)) { n2s(data, type); n2s(data, size); if (data + size > (d + n)) goto ri_check; if (s->tlsext_debug_cb) s->tlsext_debug_cb(s, 1, type, data, size, s->tlsext_debug_arg); if (type == TLSEXT_TYPE_server_name) { if (s->tlsext_hostname == NULL || size > 0) { *al = TLS1_AD_UNRECOGNIZED_NAME; return 0; } tlsext_servername = 1; } else if (type == TLSEXT_TYPE_ec_point_formats && s->version != DTLS1_VERSION) { unsigned char *sdata = data; int ecpointformatlist_length = *(sdata++); if (ecpointformatlist_length != size - 1 || ecpointformatlist_length < 1) { *al = TLS1_AD_DECODE_ERROR; return 0; } s->session->tlsext_ecpointformatlist_length = 0; free(s->session->tlsext_ecpointformatlist); if ((s->session->tlsext_ecpointformatlist = malloc(ecpointformatlist_length)) == NULL) { *al = TLS1_AD_INTERNAL_ERROR; return 0; } s->session->tlsext_ecpointformatlist_length = ecpointformatlist_length; memcpy(s->session->tlsext_ecpointformatlist, sdata, ecpointformatlist_length); } else if (type == TLSEXT_TYPE_session_ticket) { if (s->tls_session_ticket_ext_cb && !s->tls_session_ticket_ext_cb(s, data, size, s->tls_session_ticket_ext_cb_arg)) { *al = TLS1_AD_INTERNAL_ERROR; return 0; } if ((SSL_get_options(s) & SSL_OP_NO_TICKET) || (size > 0)) { *al = TLS1_AD_UNSUPPORTED_EXTENSION; return 0; } s->tlsext_ticket_expected = 1; } else if (type == TLSEXT_TYPE_status_request && s->version != DTLS1_VERSION) { /* MUST be empty and only sent if we've requested * a status request message. */ if ((s->tlsext_status_type == -1) || (size > 0)) { *al = TLS1_AD_UNSUPPORTED_EXTENSION; return 0; } /* Set flag to expect CertificateStatus message */ s->tlsext_status_expected = 1; } #ifndef OPENSSL_NO_NEXTPROTONEG else if (type == TLSEXT_TYPE_next_proto_neg && s->s3->tmp.finish_md_len == 0) { unsigned char *selected; unsigned char selected_len; /* We must have requested it. */ if (s->ctx->next_proto_select_cb == NULL) { *al = TLS1_AD_UNSUPPORTED_EXTENSION; return 0; } /* The data must be valid */ if (!ssl_next_proto_validate(data, size)) { *al = TLS1_AD_DECODE_ERROR; return 0; } if (s->ctx->next_proto_select_cb(s, &selected, &selected_len, data, size, s->ctx->next_proto_select_cb_arg) != SSL_TLSEXT_ERR_OK) { *al = TLS1_AD_INTERNAL_ERROR; return 0; } s->next_proto_negotiated = malloc(selected_len); if (!s->next_proto_negotiated) { *al = TLS1_AD_INTERNAL_ERROR; return 0; } memcpy(s->next_proto_negotiated, selected, selected_len); s->next_proto_negotiated_len = selected_len; s->s3->next_proto_neg_seen = 1; } #endif else if (type == TLSEXT_TYPE_renegotiate) { if (!ssl_parse_serverhello_renegotiate_ext(s, data, size, al)) return 0; renegotiate_seen = 1; } #ifndef OPENSSL_NO_SRTP else if (type == TLSEXT_TYPE_use_srtp) { if (ssl_parse_serverhello_use_srtp_ext(s, data, size, al)) return 0; } #endif data += size; } if (data != d + n) { *al = SSL_AD_DECODE_ERROR; return 0; } if (!s->hit && tlsext_servername == 1) { if (s->tlsext_hostname) { if (s->session->tlsext_hostname == NULL) { s->session->tlsext_hostname = BUF_strdup(s->tlsext_hostname); if (!s->session->tlsext_hostname) { *al = SSL_AD_UNRECOGNIZED_NAME; return 0; } } else { *al = SSL_AD_DECODE_ERROR; return 0; } } } *p = data; ri_check: /* Determine if we need to see RI. Strictly speaking if we want to * avoid an attack we should *always* see RI even on initial server * hello because the client doesn't see any renegotiation during an * attack. However this would mean we could not connect to any server * which doesn't support RI so for the immediate future tolerate RI * absence on initial connect only. */ if (!renegotiate_seen && !(s->options & SSL_OP_LEGACY_SERVER_CONNECT)) { *al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_TLSEXT, SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); return 0; } return 1; } int ssl_prepare_clienthello_tlsext(SSL *s) { /* If we are client and using an elliptic curve cryptography cipher suite, send the point formats * and elliptic curves we support. */ int using_ecc = 0; int i; unsigned char *j; unsigned long alg_k, alg_a; STACK_OF(SSL_CIPHER) *cipher_stack = SSL_get_ciphers(s); for (i = 0; i < sk_SSL_CIPHER_num(cipher_stack); i++) { SSL_CIPHER *c = sk_SSL_CIPHER_value(cipher_stack, i); alg_k = c->algorithm_mkey; alg_a = c->algorithm_auth; if ((alg_k & (SSL_kEECDH|SSL_kECDHr|SSL_kECDHe) || (alg_a & SSL_aECDSA))) { using_ecc = 1; break; } } using_ecc = using_ecc && (s->version >= TLS1_VERSION); if (using_ecc) { free(s->tlsext_ecpointformatlist); if ((s->tlsext_ecpointformatlist = malloc(3)) == NULL) { SSLerr(SSL_F_SSL_PREPARE_CLIENTHELLO_TLSEXT, ERR_R_MALLOC_FAILURE); return -1; } s->tlsext_ecpointformatlist_length = 3; s->tlsext_ecpointformatlist[0] = TLSEXT_ECPOINTFORMAT_uncompressed; s->tlsext_ecpointformatlist[1] = TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime; s->tlsext_ecpointformatlist[2] = TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2; /* we support all named elliptic curves in draft-ietf-tls-ecc-12 */ free(s->tlsext_ellipticcurvelist); s->tlsext_ellipticcurvelist_length = sizeof(pref_list) / sizeof(pref_list[0]) * 2; if ((s->tlsext_ellipticcurvelist = malloc(s->tlsext_ellipticcurvelist_length)) == NULL) { s->tlsext_ellipticcurvelist_length = 0; SSLerr(SSL_F_SSL_PREPARE_CLIENTHELLO_TLSEXT, ERR_R_MALLOC_FAILURE); return -1; } for (i = 0, j = s->tlsext_ellipticcurvelist; (unsigned int)i < sizeof(pref_list) / sizeof(pref_list[0]); i++) { int id = tls1_ec_nid2curve_id(pref_list[i]); s2n(id, j); } } return 1; } int ssl_prepare_serverhello_tlsext(SSL *s) { /* If we are server and using an ECC cipher suite, send the point formats we support * if the client sent us an ECPointsFormat extension. Note that the server is not * supposed to send an EllipticCurves extension. */ unsigned long alg_k = s->s3->tmp.new_cipher->algorithm_mkey; unsigned long alg_a = s->s3->tmp.new_cipher->algorithm_auth; int using_ecc = (alg_k & (SSL_kEECDH|SSL_kECDHr|SSL_kECDHe)) || (alg_a & SSL_aECDSA); using_ecc = using_ecc && (s->session->tlsext_ecpointformatlist != NULL); if (using_ecc) { free(s->tlsext_ecpointformatlist); if ((s->tlsext_ecpointformatlist = malloc(3)) == NULL) { SSLerr(SSL_F_SSL_PREPARE_SERVERHELLO_TLSEXT, ERR_R_MALLOC_FAILURE); return -1; } s->tlsext_ecpointformatlist_length = 3; s->tlsext_ecpointformatlist[0] = TLSEXT_ECPOINTFORMAT_uncompressed; s->tlsext_ecpointformatlist[1] = TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime; s->tlsext_ecpointformatlist[2] = TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2; } return 1; } int ssl_check_clienthello_tlsext_early(SSL *s) { int ret = SSL_TLSEXT_ERR_NOACK; int al = SSL_AD_UNRECOGNIZED_NAME; /* The handling of the ECPointFormats extension is done elsewhere, namely in * ssl3_choose_cipher in s3_lib.c. */ /* The handling of the EllipticCurves extension is done elsewhere, namely in * ssl3_choose_cipher in s3_lib.c. */ if (s->ctx != NULL && s->ctx->tlsext_servername_callback != 0) ret = s->ctx->tlsext_servername_callback(s, &al, s->ctx->tlsext_servername_arg); else if (s->initial_ctx != NULL && s->initial_ctx->tlsext_servername_callback != 0) ret = s->initial_ctx->tlsext_servername_callback(s, &al, s->initial_ctx->tlsext_servername_arg); switch (ret) { case SSL_TLSEXT_ERR_ALERT_FATAL: ssl3_send_alert(s, SSL3_AL_FATAL, al); return -1; case SSL_TLSEXT_ERR_ALERT_WARNING: ssl3_send_alert(s, SSL3_AL_WARNING, al); return 1; case SSL_TLSEXT_ERR_NOACK: s->servername_done = 0; default: return 1; } } int ssl_check_clienthello_tlsext_late(SSL *s) { int ret = SSL_TLSEXT_ERR_OK; int al = 0; /* XXX gcc3 */ /* If status request then ask callback what to do. * Note: this must be called after servername callbacks in case * the certificate has changed, and must be called after the cipher * has been chosen because this may influence which certificate is sent */ if ((s->tlsext_status_type != -1) && s->ctx && s->ctx->tlsext_status_cb) { int r; CERT_PKEY *certpkey; certpkey = ssl_get_server_send_pkey(s); /* If no certificate can't return certificate status */ if (certpkey == NULL) { s->tlsext_status_expected = 0; return 1; } /* Set current certificate to one we will use so * SSL_get_certificate et al can pick it up. */ s->cert->key = certpkey; r = s->ctx->tlsext_status_cb(s, s->ctx->tlsext_status_arg); switch (r) { /* We don't want to send a status request response */ case SSL_TLSEXT_ERR_NOACK: s->tlsext_status_expected = 0; break; /* status request response should be sent */ case SSL_TLSEXT_ERR_OK: if (s->tlsext_ocsp_resp) s->tlsext_status_expected = 1; else s->tlsext_status_expected = 0; break; /* something bad happened */ case SSL_TLSEXT_ERR_ALERT_FATAL: ret = SSL_TLSEXT_ERR_ALERT_FATAL; al = SSL_AD_INTERNAL_ERROR; goto err; } } else s->tlsext_status_expected = 0; err: switch (ret) { case SSL_TLSEXT_ERR_ALERT_FATAL: ssl3_send_alert(s, SSL3_AL_FATAL, al); return -1; case SSL_TLSEXT_ERR_ALERT_WARNING: ssl3_send_alert(s, SSL3_AL_WARNING, al); return 1; default: return 1; } } int ssl_check_serverhello_tlsext(SSL *s) { int ret = SSL_TLSEXT_ERR_NOACK; int al = SSL_AD_UNRECOGNIZED_NAME; /* If we are client and using an elliptic curve cryptography cipher * suite, then if server returns an EC point formats lists extension * it must contain uncompressed. */ unsigned long alg_k = s->s3->tmp.new_cipher->algorithm_mkey; unsigned long alg_a = s->s3->tmp.new_cipher->algorithm_auth; if ((s->tlsext_ecpointformatlist != NULL) && (s->tlsext_ecpointformatlist_length > 0) && (s->session->tlsext_ecpointformatlist != NULL) && (s->session->tlsext_ecpointformatlist_length > 0) && ((alg_k & (SSL_kEECDH|SSL_kECDHr|SSL_kECDHe)) || (alg_a & SSL_aECDSA))) { /* we are using an ECC cipher */ size_t i; unsigned char *list; int found_uncompressed = 0; list = s->session->tlsext_ecpointformatlist; for (i = 0; i < s->session->tlsext_ecpointformatlist_length; i++) { if (*(list++) == TLSEXT_ECPOINTFORMAT_uncompressed) { found_uncompressed = 1; break; } } if (!found_uncompressed) { SSLerr(SSL_F_SSL_CHECK_SERVERHELLO_TLSEXT, SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST); return -1; } } ret = SSL_TLSEXT_ERR_OK; if (s->ctx != NULL && s->ctx->tlsext_servername_callback != 0) ret = s->ctx->tlsext_servername_callback(s, &al, s->ctx->tlsext_servername_arg); else if (s->initial_ctx != NULL && s->initial_ctx->tlsext_servername_callback != 0) ret = s->initial_ctx->tlsext_servername_callback(s, &al, s->initial_ctx->tlsext_servername_arg); /* If we've requested certificate status and we wont get one * tell the callback */ if ((s->tlsext_status_type != -1) && !(s->tlsext_status_expected) && s->ctx && s->ctx->tlsext_status_cb) { int r; /* Set resp to NULL, resplen to -1 so callback knows * there is no response. */ free(s->tlsext_ocsp_resp); s->tlsext_ocsp_resp = NULL; s->tlsext_ocsp_resplen = -1; r = s->ctx->tlsext_status_cb(s, s->ctx->tlsext_status_arg); if (r == 0) { al = SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE; ret = SSL_TLSEXT_ERR_ALERT_FATAL; } if (r < 0) { al = SSL_AD_INTERNAL_ERROR; ret = SSL_TLSEXT_ERR_ALERT_FATAL; } } switch (ret) { case SSL_TLSEXT_ERR_ALERT_FATAL: ssl3_send_alert(s, SSL3_AL_FATAL, al); return -1; case SSL_TLSEXT_ERR_ALERT_WARNING: ssl3_send_alert(s, SSL3_AL_WARNING, al); return 1; case SSL_TLSEXT_ERR_NOACK: s->servername_done = 0; default: return 1; } } /* Since the server cache lookup is done early on in the processing of the * ClientHello, and other operations depend on the result, we need to handle * any TLS session ticket extension at the same time. * * session_id: points at the session ID in the ClientHello. This code will * read past the end of this in order to parse out the session ticket * extension, if any. * len: the length of the session ID. * limit: a pointer to the first byte after the ClientHello. * ret: (output) on return, if a ticket was decrypted, then this is set to * point to the resulting session. * * If s->tls_session_secret_cb is set then we are expecting a pre-shared key * ciphersuite, in which case we have no use for session tickets and one will * never be decrypted, nor will s->tlsext_ticket_expected be set to 1. * * Returns: * -1: fatal error, either from parsing or decrypting the ticket. * 0: no ticket was found (or was ignored, based on settings). * 1: a zero length extension was found, indicating that the client supports * session tickets but doesn't currently have one to offer. * 2: either s->tls_session_secret_cb was set, or a ticket was offered but * couldn't be decrypted because of a non-fatal error. * 3: a ticket was successfully decrypted and *ret was set. * * Side effects: * Sets s->tlsext_ticket_expected to 1 if the server will have to issue * a new session ticket to the client because the client indicated support * (and s->tls_session_secret_cb is NULL) but the client either doesn't have * a session ticket or we couldn't use the one it gave us, or if * s->ctx->tlsext_ticket_key_cb asked to renew the client's ticket. * Otherwise, s->tlsext_ticket_expected is set to 0. */ int tls1_process_ticket(SSL *s, unsigned char *session_id, int len, const unsigned char *limit, SSL_SESSION **ret) { /* Point after session ID in client hello */ const unsigned char *p = session_id + len; unsigned short i; *ret = NULL; s->tlsext_ticket_expected = 0; /* If tickets disabled behave as if no ticket present * to permit stateful resumption. */ if (SSL_get_options(s) & SSL_OP_NO_TICKET) return 0; if ((s->version <= SSL3_VERSION) || !limit) return 0; if (p >= limit) return -1; /* Skip past DTLS cookie */ if (SSL_IS_DTLS(s)) { i = *(p++); p += i; if (p >= limit) return -1; } /* Skip past cipher list */ n2s(p, i); p += i; if (p >= limit) return -1; /* Skip past compression algorithm list */ i = *(p++); p += i; if (p > limit) return -1; /* Now at start of extensions */ if ((p + 2) >= limit) return 0; n2s(p, i); while ((p + 4) <= limit) { unsigned short type, size; n2s(p, type); n2s(p, size); if (p + size > limit) return 0; if (type == TLSEXT_TYPE_session_ticket) { int r; if (size == 0) { /* The client will accept a ticket but doesn't * currently have one. */ s->tlsext_ticket_expected = 1; return 1; } if (s->tls_session_secret_cb) { /* Indicate that the ticket couldn't be * decrypted rather than generating the session * from ticket now, trigger abbreviated * handshake based on external mechanism to * calculate the master secret later. */ return 2; } r = tls_decrypt_ticket(s, p, size, session_id, len, ret); switch (r) { case 2: /* ticket couldn't be decrypted */ s->tlsext_ticket_expected = 1; return 2; case 3: /* ticket was decrypted */ return r; case 4: /* ticket decrypted but need to renew */ s->tlsext_ticket_expected = 1; return 3; default: /* fatal error */ return -1; } } p += size; } return 0; } /* tls_decrypt_ticket attempts to decrypt a session ticket. * * etick: points to the body of the session ticket extension. * eticklen: the length of the session tickets extenion. * sess_id: points at the session ID. * sesslen: the length of the session ID. * psess: (output) on return, if a ticket was decrypted, then this is set to * point to the resulting session. * * Returns: * -1: fatal error, either from parsing or decrypting the ticket. * 2: the ticket couldn't be decrypted. * 3: a ticket was successfully decrypted and *psess was set. * 4: same as 3, but the ticket needs to be renewed. */ static int tls_decrypt_ticket(SSL *s, const unsigned char *etick, int eticklen, const unsigned char *sess_id, int sesslen, SSL_SESSION **psess) { SSL_SESSION *sess; unsigned char *sdec; const unsigned char *p; int slen, mlen, renew_ticket = 0; unsigned char tick_hmac[EVP_MAX_MD_SIZE]; HMAC_CTX hctx; EVP_CIPHER_CTX ctx; SSL_CTX *tctx = s->initial_ctx; /* Need at least keyname + iv + some encrypted data */ if (eticklen < 48) return 2; /* Initialize session ticket encryption and HMAC contexts */ HMAC_CTX_init(&hctx); EVP_CIPHER_CTX_init(&ctx); if (tctx->tlsext_ticket_key_cb) { unsigned char *nctick = (unsigned char *)etick; int rv = tctx->tlsext_ticket_key_cb(s, nctick, nctick + 16, &ctx, &hctx, 0); if (rv < 0) { EVP_CIPHER_CTX_cleanup(&ctx); return -1; } if (rv == 0) { EVP_CIPHER_CTX_cleanup(&ctx); return 2; } if (rv == 2) renew_ticket = 1; } else { /* Check key name matches */ if (timingsafe_memcmp(etick, tctx->tlsext_tick_key_name, 16)) return 2; HMAC_Init_ex(&hctx, tctx->tlsext_tick_hmac_key, 16, tlsext_tick_md(), NULL); EVP_DecryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, tctx->tlsext_tick_aes_key, etick + 16); } /* Attempt to process session ticket, first conduct sanity and * integrity checks on ticket. */ mlen = HMAC_size(&hctx); if (mlen < 0) { EVP_CIPHER_CTX_cleanup(&ctx); return -1; } eticklen -= mlen; /* Check HMAC of encrypted ticket */ HMAC_Update(&hctx, etick, eticklen); HMAC_Final(&hctx, tick_hmac, NULL); HMAC_CTX_cleanup(&hctx); if (timingsafe_memcmp(tick_hmac, etick + eticklen, mlen)) { EVP_CIPHER_CTX_cleanup(&ctx); return 2; } /* Attempt to decrypt session data */ /* Move p after IV to start of encrypted ticket, update length */ p = etick + 16 + EVP_CIPHER_CTX_iv_length(&ctx); eticklen -= 16 + EVP_CIPHER_CTX_iv_length(&ctx); sdec = malloc(eticklen); if (!sdec) { EVP_CIPHER_CTX_cleanup(&ctx); return -1; } EVP_DecryptUpdate(&ctx, sdec, &slen, p, eticklen); if (EVP_DecryptFinal(&ctx, sdec + slen, &mlen) <= 0) { free(sdec); EVP_CIPHER_CTX_cleanup(&ctx); return 2; } slen += mlen; EVP_CIPHER_CTX_cleanup(&ctx); p = sdec; sess = d2i_SSL_SESSION(NULL, &p, slen); free(sdec); if (sess) { /* The session ID, if non-empty, is used by some clients to * detect that the ticket has been accepted. So we copy it to * the session structure. If it is empty set length to zero * as required by standard. */ if (sesslen) memcpy(sess->session_id, sess_id, sesslen); sess->session_id_length = sesslen; *psess = sess; if (renew_ticket) return 4; else return 3; } ERR_clear_error(); /* For session parse failure, indicate that we need to send a new * ticket. */ return 2; } /* Tables to translate from NIDs to TLS v1.2 ids */ typedef struct { int nid; int id; } tls12_lookup; static tls12_lookup tls12_md[] = { {NID_md5, TLSEXT_hash_md5}, {NID_sha1, TLSEXT_hash_sha1}, {NID_sha224, TLSEXT_hash_sha224}, {NID_sha256, TLSEXT_hash_sha256}, {NID_sha384, TLSEXT_hash_sha384}, {NID_sha512, TLSEXT_hash_sha512} }; static tls12_lookup tls12_sig[] = { {EVP_PKEY_RSA, TLSEXT_signature_rsa}, {EVP_PKEY_DSA, TLSEXT_signature_dsa}, {EVP_PKEY_EC, TLSEXT_signature_ecdsa} }; static int tls12_find_id(int nid, tls12_lookup *table, size_t tlen) { size_t i; for (i = 0; i < tlen; i++) { if (table[i].nid == nid) return table[i].id; } return -1; } int tls12_get_sigandhash(unsigned char *p, const EVP_PKEY *pk, const EVP_MD *md) { int sig_id, md_id; if (!md) return 0; md_id = tls12_find_id(EVP_MD_type(md), tls12_md, sizeof(tls12_md) / sizeof(tls12_lookup)); if (md_id == -1) return 0; sig_id = tls12_get_sigid(pk); if (sig_id == -1) return 0; p[0] = (unsigned char)md_id; p[1] = (unsigned char)sig_id; return 1; } int tls12_get_sigid(const EVP_PKEY *pk) { return tls12_find_id(pk->type, tls12_sig, sizeof(tls12_sig) / sizeof(tls12_lookup)); } const EVP_MD * tls12_get_hash(unsigned char hash_alg) { switch (hash_alg) { case TLSEXT_hash_sha1: return EVP_sha1(); case TLSEXT_hash_sha224: return EVP_sha224(); case TLSEXT_hash_sha256: return EVP_sha256(); case TLSEXT_hash_sha384: return EVP_sha384(); case TLSEXT_hash_sha512: return EVP_sha512(); default: return NULL; } } /* Set preferred digest for each key type */ int tls1_process_sigalgs(SSL *s, const unsigned char *data, int dsize) { int i, idx; const EVP_MD *md; CERT *c = s->cert; /* Extension ignored for inappropriate versions */ if (!SSL_USE_SIGALGS(s)) return 1; /* Should never happen */ if (!c) return 0; c->pkeys[SSL_PKEY_DSA_SIGN].digest = NULL; c->pkeys[SSL_PKEY_RSA_SIGN].digest = NULL; c->pkeys[SSL_PKEY_RSA_ENC].digest = NULL; c->pkeys[SSL_PKEY_ECC].digest = NULL; for (i = 0; i < dsize; i += 2) { unsigned char hash_alg = data[i], sig_alg = data[i + 1]; switch (sig_alg) { case TLSEXT_signature_rsa: idx = SSL_PKEY_RSA_SIGN; break; case TLSEXT_signature_dsa: idx = SSL_PKEY_DSA_SIGN; break; case TLSEXT_signature_ecdsa: idx = SSL_PKEY_ECC; break; default: continue; } if (c->pkeys[idx].digest == NULL) { md = tls12_get_hash(hash_alg); if (md) { c->pkeys[idx].digest = md; if (idx == SSL_PKEY_RSA_SIGN) c->pkeys[SSL_PKEY_RSA_ENC].digest = md; } } } /* Set any remaining keys to default values. NOTE: if alg is not * supported it stays as NULL. */ if (!c->pkeys[SSL_PKEY_DSA_SIGN].digest) c->pkeys[SSL_PKEY_DSA_SIGN].digest = EVP_sha1(); if (!c->pkeys[SSL_PKEY_RSA_SIGN].digest) { c->pkeys[SSL_PKEY_RSA_SIGN].digest = EVP_sha1(); c->pkeys[SSL_PKEY_RSA_ENC].digest = EVP_sha1(); } if (!c->pkeys[SSL_PKEY_ECC].digest) c->pkeys[SSL_PKEY_ECC].digest = EVP_sha1(); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/s23_lib.c0000644000175000017500000001117012360020705017135 0ustar /* $OpenBSD: s23_lib.c,v 1.15 2014/06/12 15:49:31 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include "ssl_locl.h" long ssl23_default_timeout(void) { return (300); } int ssl23_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p) { long l; /* We can write SSLv2 and SSLv3 ciphers */ if (p != NULL) { l = c->id; p[0] = ((unsigned char)(l >> 16L))&0xFF; p[1] = ((unsigned char)(l >> 8L))&0xFF; p[2] = ((unsigned char)(l ))&0xFF; } return (3); } int ssl23_read(SSL *s, void *buf, int len) { int n; errno = 0; if (SSL_in_init(s) && (!s->in_handshake)) { n = s->handshake_func(s); if (n < 0) return (n); if (n == 0) { SSLerr(SSL_F_SSL23_READ, SSL_R_SSL_HANDSHAKE_FAILURE); return (-1); } return (SSL_read(s, buf, len)); } else { ssl_undefined_function(s); return (-1); } } int ssl23_peek(SSL *s, void *buf, int len) { int n; errno = 0; if (SSL_in_init(s) && (!s->in_handshake)) { n = s->handshake_func(s); if (n < 0) return (n); if (n == 0) { SSLerr(SSL_F_SSL23_PEEK, SSL_R_SSL_HANDSHAKE_FAILURE); return (-1); } return (SSL_peek(s, buf, len)); } else { ssl_undefined_function(s); return (-1); } } int ssl23_write(SSL *s, const void *buf, int len) { int n; errno = 0; if (SSL_in_init(s) && (!s->in_handshake)) { n = s->handshake_func(s); if (n < 0) return (n); if (n == 0) { SSLerr(SSL_F_SSL23_WRITE, SSL_R_SSL_HANDSHAKE_FAILURE); return (-1); } return (SSL_write(s, buf, len)); } else { ssl_undefined_function(s); return (-1); } } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/t1_meth.c0000644000175000017500000001535612360020705017253 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include "ssl_locl.h" static const SSL_METHOD *tls1_get_method(int ver); const SSL_METHOD TLSv1_method_data = { .version = TLS1_VERSION, .ssl_new = tls1_new, .ssl_clear = tls1_clear, .ssl_free = tls1_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl3_connect, .ssl_read = ssl3_read, .ssl_peek = ssl3_peek, .ssl_write = ssl3_write, .ssl_shutdown = ssl3_shutdown, .ssl_renegotiate = ssl3_renegotiate, .ssl_renegotiate_check = ssl3_renegotiate_check, .ssl_get_message = ssl3_get_message, .ssl_read_bytes = ssl3_read_bytes, .ssl_write_bytes = ssl3_write_bytes, .ssl_dispatch_alert = ssl3_dispatch_alert, .ssl_ctrl = ssl3_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl3_put_cipher_by_char, .ssl_pending = ssl3_pending, .num_ciphers = ssl3_num_ciphers, .get_cipher = ssl3_get_cipher, .get_ssl_method = tls1_get_method, .get_timeout = tls1_default_timeout, .ssl3_enc = &TLSv1_enc_data, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD TLSv1_1_method_data = { .version = TLS1_1_VERSION, .ssl_new = tls1_new, .ssl_clear = tls1_clear, .ssl_free = tls1_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl3_connect, .ssl_read = ssl3_read, .ssl_peek = ssl3_peek, .ssl_write = ssl3_write, .ssl_shutdown = ssl3_shutdown, .ssl_renegotiate = ssl3_renegotiate, .ssl_renegotiate_check = ssl3_renegotiate_check, .ssl_get_message = ssl3_get_message, .ssl_read_bytes = ssl3_read_bytes, .ssl_write_bytes = ssl3_write_bytes, .ssl_dispatch_alert = ssl3_dispatch_alert, .ssl_ctrl = ssl3_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl3_put_cipher_by_char, .ssl_pending = ssl3_pending, .num_ciphers = ssl3_num_ciphers, .get_cipher = ssl3_get_cipher, .get_ssl_method = tls1_get_method, .get_timeout = tls1_default_timeout, .ssl3_enc = &TLSv1_1_enc_data, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD TLSv1_2_method_data = { .version = TLS1_2_VERSION, .ssl_new = tls1_new, .ssl_clear = tls1_clear, .ssl_free = tls1_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl3_connect, .ssl_read = ssl3_read, .ssl_peek = ssl3_peek, .ssl_write = ssl3_write, .ssl_shutdown = ssl3_shutdown, .ssl_renegotiate = ssl3_renegotiate, .ssl_renegotiate_check = ssl3_renegotiate_check, .ssl_get_message = ssl3_get_message, .ssl_read_bytes = ssl3_read_bytes, .ssl_write_bytes = ssl3_write_bytes, .ssl_dispatch_alert = ssl3_dispatch_alert, .ssl_ctrl = ssl3_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl3_put_cipher_by_char, .ssl_pending = ssl3_pending, .num_ciphers = ssl3_num_ciphers, .get_cipher = ssl3_get_cipher, .get_ssl_method = tls1_get_method, .get_timeout = tls1_default_timeout, .ssl3_enc = &TLSv1_2_enc_data, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD * TLSv1_method(void) { return &TLSv1_method_data; } const SSL_METHOD * TLSv1_1_method(void) { return &TLSv1_1_method_data; } const SSL_METHOD * TLSv1_2_method(void) { return &TLSv1_2_method_data; } static const SSL_METHOD * tls1_get_method(int ver) { if (ver == TLS1_2_VERSION) return (TLSv1_2_method()); if (ver == TLS1_1_VERSION) return (TLSv1_1_method()); if (ver == TLS1_VERSION) return (TLSv1_method()); return (NULL); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/ssl_locl.h0000644000175000017500000010226712360020705017527 0ustar /* $OpenBSD: ssl_locl.h,v 1.58 2014/07/10 10:09:54 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * ECC cipher suite support in OpenSSL originally developed by * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. */ /* ==================================================================== * Copyright 2005 Nokia. All rights reserved. * * The portions of the attached software ("Contribution") is developed by * Nokia Corporation and is licensed pursuant to the OpenSSL open source * license. * * The Contribution, originally written by Mika Kousa and Pasi Eronen of * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites * support (see RFC 4279) to OpenSSL. * * No patent licenses or other rights except those expressly stated in * the OpenSSL open source license shall be deemed granted or received * expressly, by implication, estoppel, or otherwise. * * No assurances are provided by Nokia that the Contribution does not * infringe the patent or other intellectual property rights of any third * party or that the license provides you with all the necessary rights * to make use of the Contribution. * * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR * OTHERWISE. */ #ifndef HEADER_SSL_LOCL_H #define HEADER_SSL_LOCL_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define c2l(c,l) (l = ((unsigned long)(*((c)++))) , \ l|=(((unsigned long)(*((c)++)))<< 8), \ l|=(((unsigned long)(*((c)++)))<<16), \ l|=(((unsigned long)(*((c)++)))<<24)) /* NOTE - c is not incremented as per c2l */ #define c2ln(c,l1,l2,n) { \ c+=n; \ l1=l2=0; \ switch (n) { \ case 8: l2 =((unsigned long)(*(--(c))))<<24; \ case 7: l2|=((unsigned long)(*(--(c))))<<16; \ case 6: l2|=((unsigned long)(*(--(c))))<< 8; \ case 5: l2|=((unsigned long)(*(--(c)))); \ case 4: l1 =((unsigned long)(*(--(c))))<<24; \ case 3: l1|=((unsigned long)(*(--(c))))<<16; \ case 2: l1|=((unsigned long)(*(--(c))))<< 8; \ case 1: l1|=((unsigned long)(*(--(c)))); \ } \ } #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ *((c)++)=(unsigned char)(((l)>>16)&0xff), \ *((c)++)=(unsigned char)(((l)>>24)&0xff)) #define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24, \ l|=((unsigned long)(*((c)++)))<<16, \ l|=((unsigned long)(*((c)++)))<< 8, \ l|=((unsigned long)(*((c)++)))) #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \ *((c)++)=(unsigned char)(((l)>>16)&0xff), \ *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ *((c)++)=(unsigned char)(((l) )&0xff)) #define l2n8(l,c) (*((c)++)=(unsigned char)(((l)>>56)&0xff), \ *((c)++)=(unsigned char)(((l)>>48)&0xff), \ *((c)++)=(unsigned char)(((l)>>40)&0xff), \ *((c)++)=(unsigned char)(((l)>>32)&0xff), \ *((c)++)=(unsigned char)(((l)>>24)&0xff), \ *((c)++)=(unsigned char)(((l)>>16)&0xff), \ *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ *((c)++)=(unsigned char)(((l) )&0xff)) /* NOTE - c is not incremented as per l2c */ #define l2cn(l1,l2,c,n) { \ c+=n; \ switch (n) { \ case 8: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ case 7: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ case 6: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ case 4: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ case 3: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ case 2: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ } \ } #define n2s(c,s) ((s=(((unsigned int)(c[0]))<< 8)| \ (((unsigned int)(c[1])) )),c+=2) #define s2n(s,c) ((c[0]=(unsigned char)(((s)>> 8)&0xff), \ c[1]=(unsigned char)(((s) )&0xff)),c+=2) #define n2l3(c,l) ((l =(((unsigned long)(c[0]))<<16)| \ (((unsigned long)(c[1]))<< 8)| \ (((unsigned long)(c[2])) )),c+=3) #define l2n3(l,c) ((c[0]=(unsigned char)(((l)>>16)&0xff), \ c[1]=(unsigned char)(((l)>> 8)&0xff), \ c[2]=(unsigned char)(((l) )&0xff)),c+=3) /* LOCAL STUFF */ #define SSL_DECRYPT 0 #define SSL_ENCRYPT 1 /* * Define the Bitmasks for SSL_CIPHER.algorithms. * This bits are used packed as dense as possible. If new methods/ciphers * etc will be added, the bits a likely to change, so this information * is for internal library use only, even though SSL_CIPHER.algorithms * can be publicly accessed. * Use the according functions for cipher management instead. * * The bit mask handling in the selection and sorting scheme in * ssl_create_cipher_list() has only limited capabilities, reflecting * that the different entities within are mutually exclusive: * ONLY ONE BIT PER MASK CAN BE SET AT A TIME. */ /* Bits for algorithm_mkey (key exchange algorithm) */ #define SSL_kRSA 0x00000001L /* RSA key exchange */ #define SSL_kDHr 0x00000002L /* DH cert, RSA CA cert */ /* no such ciphersuites supported! */ #define SSL_kDHd 0x00000004L /* DH cert, DSA CA cert */ /* no such ciphersuite supported! */ #define SSL_kEDH 0x00000008L /* tmp DH key no DH cert */ #define SSL_kKRB5 0x00000010L /* Kerberos5 key exchange */ #define SSL_kECDHr 0x00000020L /* ECDH cert, RSA CA cert */ #define SSL_kECDHe 0x00000040L /* ECDH cert, ECDSA CA cert */ #define SSL_kEECDH 0x00000080L /* ephemeral ECDH */ #define SSL_kPSK 0x00000100L /* PSK */ #define SSL_kGOST 0x00000200L /* GOST key exchange */ #define SSL_kSRP 0x00000400L /* SRP */ /* Bits for algorithm_auth (server authentication) */ #define SSL_aRSA 0x00000001L /* RSA auth */ #define SSL_aDSS 0x00000002L /* DSS auth */ #define SSL_aNULL 0x00000004L /* no auth (i.e. use ADH or AECDH) */ #define SSL_aDH 0x00000008L /* Fixed DH auth (kDHd or kDHr) */ /* no such ciphersuites supported! */ #define SSL_aECDH 0x00000010L /* Fixed ECDH auth (kECDHe or kECDHr) */ #define SSL_aKRB5 0x00000020L /* KRB5 auth */ #define SSL_aECDSA 0x00000040L /* ECDSA auth*/ #define SSL_aPSK 0x00000080L /* PSK auth */ #define SSL_aGOST94 0x00000100L /* GOST R 34.10-94 signature auth */ #define SSL_aGOST01 0x00000200L /* GOST R 34.10-2001 signature auth */ /* Bits for algorithm_enc (symmetric encryption) */ #define SSL_DES 0x00000001L #define SSL_3DES 0x00000002L #define SSL_RC4 0x00000004L #define SSL_RC2 0x00000008L #define SSL_IDEA 0x00000010L #define SSL_eNULL 0x00000020L #define SSL_AES128 0x00000040L #define SSL_AES256 0x00000080L #define SSL_CAMELLIA128 0x00000100L #define SSL_CAMELLIA256 0x00000200L #define SSL_eGOST2814789CNT 0x00000400L #define SSL_SEED 0x00000800L #define SSL_AES128GCM 0x00001000L #define SSL_AES256GCM 0x00002000L #define SSL_CHACHA20POLY1305 0x00004000L #define SSL_AES (SSL_AES128|SSL_AES256|SSL_AES128GCM|SSL_AES256GCM) #define SSL_CAMELLIA (SSL_CAMELLIA128|SSL_CAMELLIA256) /* Bits for algorithm_mac (symmetric authentication) */ #define SSL_MD5 0x00000001L #define SSL_SHA1 0x00000002L #define SSL_GOST94 0x00000004L #define SSL_GOST89MAC 0x00000008L #define SSL_SHA256 0x00000010L #define SSL_SHA384 0x00000020L /* Not a real MAC, just an indication it is part of cipher */ #define SSL_AEAD 0x00000040L /* Bits for algorithm_ssl (protocol version) */ #define SSL_SSLV2 0x00000001L #define SSL_SSLV3 0x00000002L #define SSL_TLSV1 SSL_SSLV3 /* for now */ #define SSL_TLSV1_2 0x00000004L /* Bits for algorithm2 (handshake digests and other extra flags) */ #define SSL_HANDSHAKE_MAC_MD5 0x10 #define SSL_HANDSHAKE_MAC_SHA 0x20 #define SSL_HANDSHAKE_MAC_GOST94 0x40 #define SSL_HANDSHAKE_MAC_SHA256 0x80 #define SSL_HANDSHAKE_MAC_SHA384 0x100 #define SSL_HANDSHAKE_MAC_DEFAULT (SSL_HANDSHAKE_MAC_MD5 | SSL_HANDSHAKE_MAC_SHA) /* When adding new digest in the ssl_ciph.c and increment SSM_MD_NUM_IDX * make sure to update this constant too */ #define SSL_MAX_DIGEST 6 #define TLS1_PRF_DGST_MASK (0xff << TLS1_PRF_DGST_SHIFT) #define TLS1_PRF_DGST_SHIFT 10 #define TLS1_PRF_MD5 (SSL_HANDSHAKE_MAC_MD5 << TLS1_PRF_DGST_SHIFT) #define TLS1_PRF_SHA1 (SSL_HANDSHAKE_MAC_SHA << TLS1_PRF_DGST_SHIFT) #define TLS1_PRF_SHA256 (SSL_HANDSHAKE_MAC_SHA256 << TLS1_PRF_DGST_SHIFT) #define TLS1_PRF_SHA384 (SSL_HANDSHAKE_MAC_SHA384 << TLS1_PRF_DGST_SHIFT) #define TLS1_PRF_GOST94 (SSL_HANDSHAKE_MAC_GOST94 << TLS1_PRF_DGST_SHIFT) #define TLS1_PRF (TLS1_PRF_MD5 | TLS1_PRF_SHA1) /* Stream MAC for GOST ciphersuites from cryptopro draft * (currently this also goes into algorithm2) */ #define TLS1_STREAM_MAC 0x04 /* * SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD is an algorithm2 flag that * indicates that the variable part of the nonce is included as a prefix of * the record (AES-GCM, for example, does this with an 8-byte variable nonce.) */ #define SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD (1 << 22) /* * SSL_CIPHER_ALGORITHM2_AEAD is an algorithm2 flag that indicates the cipher * is implemented via an EVP_AEAD. */ #define SSL_CIPHER_ALGORITHM2_AEAD (1 << 23) /* * SSL_CIPHER_AEAD_FIXED_NONCE_LEN returns the number of bytes of fixed nonce * for an SSL_CIPHER with the SSL_CIPHER_ALGORITHM2_AEAD flag. */ #define SSL_CIPHER_AEAD_FIXED_NONCE_LEN(ssl_cipher) \ (((ssl_cipher->algorithm2 >> 24) & 0xf) * 2) /* * Cipher strength information. */ #define SSL_STRONG_MASK 0x000001fcL #define SSL_STRONG_NONE 0x00000004L #define SSL_LOW 0x00000020L #define SSL_MEDIUM 0x00000040L #define SSL_HIGH 0x00000080L /* Check if an SSL structure is using DTLS. */ #define SSL_IS_DTLS(s) (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_DTLS) /* See if we need explicit IV. */ #define SSL_USE_EXPLICIT_IV(s) \ (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_EXPLICIT_IV) /* See if we use signature algorithms extension. */ #define SSL_USE_SIGALGS(s) \ (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_SIGALGS) /* Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2. */ #define SSL_USE_TLS1_2_CIPHERS(s) \ (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_TLS1_2_CIPHERS) /* Mostly for SSLv3 */ #define SSL_PKEY_RSA_ENC 0 #define SSL_PKEY_RSA_SIGN 1 #define SSL_PKEY_DSA_SIGN 2 #define SSL_PKEY_DH_RSA 3 #define SSL_PKEY_DH_DSA 4 #define SSL_PKEY_ECC 5 #define SSL_PKEY_GOST94 6 #define SSL_PKEY_GOST01 7 #define SSL_PKEY_NUM 8 /* SSL_kRSA <- RSA_ENC | (RSA_TMP & RSA_SIGN) | * <- (EXPORT & (RSA_ENC | RSA_TMP) & RSA_SIGN) * SSL_kDH <- DH_ENC & (RSA_ENC | RSA_SIGN | DSA_SIGN) * SSL_kEDH <- RSA_ENC | RSA_SIGN | DSA_SIGN * SSL_aRSA <- RSA_ENC | RSA_SIGN * SSL_aDSS <- DSA_SIGN */ /* #define CERT_INVALID 0 #define CERT_PUBLIC_KEY 1 #define CERT_PRIVATE_KEY 2 */ /* From ECC-TLS draft, used in encoding the curve type in * ECParameters */ #define EXPLICIT_PRIME_CURVE_TYPE 1 #define EXPLICIT_CHAR2_CURVE_TYPE 2 #define NAMED_CURVE_TYPE 3 typedef struct cert_pkey_st { X509 *x509; EVP_PKEY *privatekey; /* Digest to use when signing */ const EVP_MD *digest; } CERT_PKEY; typedef struct cert_st { /* Current active set */ CERT_PKEY *key; /* ALWAYS points to an element of the pkeys array * Probably it would make more sense to store * an index, not a pointer. */ /* The following masks are for the key and auth * algorithms that are supported by the certs below */ int valid; unsigned long mask_k; unsigned long mask_a; RSA *rsa_tmp; RSA *(*rsa_tmp_cb)(SSL *ssl, int is_export, int keysize); DH *dh_tmp; DH *(*dh_tmp_cb)(SSL *ssl, int is_export, int keysize); EC_KEY *ecdh_tmp; /* Callback for generating ephemeral ECDH keys */ EC_KEY *(*ecdh_tmp_cb)(SSL *ssl, int is_export, int keysize); CERT_PKEY pkeys[SSL_PKEY_NUM]; int references; /* >1 only if SSL_copy_session_id is used */ } CERT; typedef struct sess_cert_st { STACK_OF(X509) *cert_chain; /* as received from peer */ /* The 'peer_...' members are used only by clients. */ int peer_cert_type; CERT_PKEY *peer_key; /* points to an element of peer_pkeys (never NULL!) */ CERT_PKEY peer_pkeys[SSL_PKEY_NUM]; /* Obviously we don't have the private keys of these, * so maybe we shouldn't even use the CERT_PKEY type here. */ RSA *peer_rsa_tmp; DH *peer_dh_tmp; EC_KEY *peer_ecdh_tmp; int references; /* actually always 1 at the moment */ } SESS_CERT; /*#define SSL_DEBUG */ /*#define RSA_DEBUG */ #define ssl_put_cipher_by_char(ssl,ciph,ptr) \ ((ssl)->method->put_cipher_by_char((ciph),(ptr))) #define ssl_get_cipher_by_char(ssl,ptr) \ ((ssl)->method->get_cipher_by_char(ptr)) /* This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff * It is a bit of a mess of functions, but hell, think of it as * an opaque structure :-) */ typedef struct ssl3_enc_method { int (*enc)(SSL *, int); int (*mac)(SSL *, unsigned char *, int); int (*setup_key_block)(SSL *); int (*generate_master_secret)(SSL *, unsigned char *, unsigned char *, int); int (*change_cipher_state)(SSL *, int); int (*final_finish_mac)(SSL *, const char *, int, unsigned char *); int finish_mac_length; int (*cert_verify_mac)(SSL *, int, unsigned char *); const char *client_finished_label; int client_finished_label_len; const char *server_finished_label; int server_finished_label_len; int (*alert_value)(int); int (*export_keying_material)(SSL *, unsigned char *, size_t, const char *, size_t, const unsigned char *, size_t, int use_context); /* Flags indicating protocol version requirements. */ unsigned int enc_flags; } SSL3_ENC_METHOD; /* * Flag values for enc_flags. */ /* Uses explicit IV. */ #define SSL_ENC_FLAG_EXPLICIT_IV (1 << 0) /* Uses signature algorithms extension. */ #define SSL_ENC_FLAG_SIGALGS (1 << 1) /* Uses SHA256 default PRF. */ #define SSL_ENC_FLAG_SHA256_PRF (1 << 2) /* Is DTLS. */ #define SSL_ENC_FLAG_DTLS (1 << 3) /* Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2. */ #define SSL_ENC_FLAG_TLS1_2_CIPHERS (1 << 4) /* * ssl_aead_ctx_st contains information about an AEAD that is being used to * encrypt an SSL connection. */ struct ssl_aead_ctx_st { EVP_AEAD_CTX ctx; /* * fixed_nonce contains any bytes of the nonce that are fixed for all * records. */ unsigned char fixed_nonce[8]; unsigned char fixed_nonce_len; unsigned char variable_nonce_len; unsigned char tag_len; /* * variable_nonce_in_record is non-zero if the variable nonce * for a record is included as a prefix before the ciphertext. */ char variable_nonce_in_record; }; extern SSL3_ENC_METHOD ssl3_undef_enc_method; extern SSL_CIPHER ssl3_ciphers[]; SSL_METHOD *ssl_bad_method(int ver); extern SSL3_ENC_METHOD TLSv1_enc_data; extern SSL3_ENC_METHOD TLSv1_1_enc_data; extern SSL3_ENC_METHOD TLSv1_2_enc_data; extern SSL3_ENC_METHOD SSLv3_enc_data; extern SSL3_ENC_METHOD DTLSv1_enc_data; void ssl_clear_cipher_ctx(SSL *s); int ssl_clear_bad_session(SSL *s); CERT *ssl_cert_new(void); CERT *ssl_cert_dup(CERT *cert); int ssl_cert_inst(CERT **o); void ssl_cert_free(CERT *c); SESS_CERT *ssl_sess_cert_new(void); void ssl_sess_cert_free(SESS_CERT *sc); int ssl_set_peer_cert_type(SESS_CERT *c, int type); int ssl_get_new_session(SSL *s, int session); int ssl_get_prev_session(SSL *s, unsigned char *session, int len, const unsigned char *limit); int ssl_cipher_id_cmp(const SSL_CIPHER *a, const SSL_CIPHER *b); DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(SSL_CIPHER, SSL_CIPHER, ssl_cipher_id); int ssl_cipher_ptr_id_cmp(const SSL_CIPHER * const *ap, const SSL_CIPHER * const *bp); STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, unsigned char *p, int num, STACK_OF(SSL_CIPHER) **skp); int ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *sk, unsigned char *p, int (*put_cb)(const SSL_CIPHER *, unsigned char *)); STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *meth, STACK_OF(SSL_CIPHER) **pref, STACK_OF(SSL_CIPHER) **sorted, const char *rule_str); void ssl_update_cache(SSL *s, int mode); int ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc, const EVP_MD **md, int *mac_pkey_type, int *mac_secret_size); int ssl_cipher_get_evp_aead(const SSL_SESSION *s, const EVP_AEAD **aead); int ssl_get_handshake_digest(int i, long *mask, const EVP_MD **md); int ssl_verify_cert_chain(SSL *s, STACK_OF(X509) *sk); int ssl_undefined_function(SSL *s); int ssl_undefined_void_function(void); int ssl_undefined_const_function(const SSL *s); CERT_PKEY *ssl_get_server_send_pkey(const SSL *s); X509 *ssl_get_server_send_cert(const SSL *); EVP_PKEY *ssl_get_sign_pkey(SSL *s, const SSL_CIPHER *c, const EVP_MD **pmd); int ssl_cert_type(X509 *x, EVP_PKEY *pkey); void ssl_set_cert_masks(CERT *c, const SSL_CIPHER *cipher); STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s); int ssl_verify_alarm_type(long type); void ssl_load_ciphers(void); const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p); int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p); void ssl3_init_finished_mac(SSL *s); int ssl3_send_server_certificate(SSL *s); int ssl3_send_newsession_ticket(SSL *s); int ssl3_send_cert_status(SSL *s); int ssl3_get_finished(SSL *s, int state_a, int state_b); int ssl3_setup_key_block(SSL *s); int ssl3_send_change_cipher_spec(SSL *s, int state_a, int state_b); int ssl3_change_cipher_state(SSL *s, int which); void ssl3_cleanup_key_block(SSL *s); int ssl3_do_write(SSL *s, int type); int ssl3_send_alert(SSL *s, int level, int desc); int ssl3_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p, int len); int ssl3_get_req_cert_type(SSL *s, unsigned char *p); long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok); int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen); int ssl3_num_ciphers(void); const SSL_CIPHER *ssl3_get_cipher(unsigned int u); int ssl3_renegotiate(SSL *ssl); int ssl3_renegotiate_check(SSL *ssl); int ssl3_dispatch_alert(SSL *s); int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek); int ssl3_write_bytes(SSL *s, int type, const void *buf, int len); int ssl3_final_finish_mac(SSL *s, const char *sender, int slen, unsigned char *p); int ssl3_cert_verify_mac(SSL *s, int md_nid, unsigned char *p); void ssl3_finish_mac(SSL *s, const unsigned char *buf, int len); int ssl3_enc(SSL *s, int send_data); int n_ssl3_mac(SSL *ssl, unsigned char *md, int send_data); void ssl3_free_digest_list(SSL *s); unsigned long ssl3_output_cert_chain(SSL *s, X509 *x); SSL_CIPHER *ssl3_choose_cipher(SSL *ssl, STACK_OF(SSL_CIPHER) *clnt, STACK_OF(SSL_CIPHER) *srvr); int ssl3_setup_buffers(SSL *s); int ssl3_setup_read_buffer(SSL *s); int ssl3_setup_write_buffer(SSL *s); int ssl3_release_read_buffer(SSL *s); int ssl3_release_write_buffer(SSL *s); int ssl3_digest_cached_records(SSL *s); int ssl3_new(SSL *s); void ssl3_free(SSL *s); int ssl3_accept(SSL *s); int ssl3_connect(SSL *s); int ssl3_read(SSL *s, void *buf, int len); int ssl3_peek(SSL *s, void *buf, int len); int ssl3_write(SSL *s, const void *buf, int len); int ssl3_shutdown(SSL *s); void ssl3_clear(SSL *s); long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg); long ssl3_ctx_ctrl(SSL_CTX *s, int cmd, long larg, void *parg); long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)(void)); long ssl3_ctx_callback_ctrl(SSL_CTX *s, int cmd, void (*fp)(void)); int ssl3_pending(const SSL *s); void ssl3_record_sequence_increment(unsigned char *seq); int ssl3_do_change_cipher_spec(SSL *ssl); long ssl3_default_timeout(void); int ssl23_read(SSL *s, void *buf, int len); int ssl23_peek(SSL *s, void *buf, int len); int ssl23_write(SSL *s, const void *buf, int len); int ssl23_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p); long ssl23_default_timeout(void); long tls1_default_timeout(void); int dtls1_do_write(SSL *s, int type); int ssl3_read_n(SSL *s, int n, int max, int extend); int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek); int ssl3_write_pending(SSL *s, int type, const unsigned char *buf, unsigned int len); unsigned char *dtls1_set_message_header(SSL *s, unsigned char *p, unsigned char mt, unsigned long len, unsigned long frag_off, unsigned long frag_len); int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf, int len); int dtls1_write_bytes(SSL *s, int type, const void *buf, int len); int dtls1_send_change_cipher_spec(SSL *s, int a, int b); int dtls1_send_finished(SSL *s, int a, int b, const char *sender, int slen); unsigned long dtls1_output_cert_chain(SSL *s, X509 *x); int dtls1_read_failed(SSL *s, int code); int dtls1_buffer_message(SSL *s, int ccs); int dtls1_retransmit_message(SSL *s, unsigned short seq, unsigned long frag_off, int *found); int dtls1_get_queue_priority(unsigned short seq, int is_ccs); int dtls1_retransmit_buffered_messages(SSL *s); void dtls1_clear_record_buffer(SSL *s); void dtls1_get_message_header(unsigned char *data, struct hm_header_st *msg_hdr); void dtls1_get_ccs_header(unsigned char *data, struct ccs_header_st *ccs_hdr); void dtls1_reset_seq_numbers(SSL *s, int rw); void dtls1_build_sequence_number(unsigned char *dst, unsigned char *seq, unsigned short epoch); long dtls1_default_timeout(void); struct timeval* dtls1_get_timeout(SSL *s, struct timeval* timeleft); int dtls1_check_timeout_num(SSL *s); int dtls1_handle_timeout(SSL *s); const SSL_CIPHER *dtls1_get_cipher(unsigned int u); void dtls1_start_timer(SSL *s); void dtls1_stop_timer(SSL *s); int dtls1_is_timer_expired(SSL *s); void dtls1_double_timeout(SSL *s); int dtls1_send_newsession_ticket(SSL *s); unsigned int dtls1_min_mtu(void); /* some client-only functions */ int ssl3_client_hello(SSL *s); int ssl3_get_server_hello(SSL *s); int ssl3_get_certificate_request(SSL *s); int ssl3_get_new_session_ticket(SSL *s); int ssl3_get_cert_status(SSL *s); int ssl3_get_server_done(SSL *s); int ssl3_send_client_verify(SSL *s); int ssl3_send_client_certificate(SSL *s); int ssl_do_client_cert_cb(SSL *s, X509 **px509, EVP_PKEY **ppkey); int ssl3_send_client_key_exchange(SSL *s); int ssl3_get_key_exchange(SSL *s); int ssl3_get_server_certificate(SSL *s); int ssl3_check_cert_and_algorithm(SSL *s); int ssl3_check_finished(SSL *s); # ifndef OPENSSL_NO_NEXTPROTONEG int ssl3_send_next_proto(SSL *s); # endif int dtls1_client_hello(SSL *s); int dtls1_send_client_certificate(SSL *s); int dtls1_send_client_key_exchange(SSL *s); int dtls1_send_client_verify(SSL *s); /* some server-only functions */ int ssl3_get_client_hello(SSL *s); int ssl3_send_server_hello(SSL *s); int ssl3_send_hello_request(SSL *s); int ssl3_send_server_key_exchange(SSL *s); int ssl3_send_certificate_request(SSL *s); int ssl3_send_server_done(SSL *s); int ssl3_check_client_hello(SSL *s); int ssl3_get_client_certificate(SSL *s); int ssl3_get_client_key_exchange(SSL *s); int ssl3_get_cert_verify(SSL *s); #ifndef OPENSSL_NO_NEXTPROTONEG int ssl3_get_next_proto(SSL *s); #endif int dtls1_send_hello_request(SSL *s); int dtls1_send_server_hello(SSL *s); int dtls1_send_server_certificate(SSL *s); int dtls1_send_server_key_exchange(SSL *s); int dtls1_send_certificate_request(SSL *s); int dtls1_send_server_done(SSL *s); int ssl23_accept(SSL *s); int ssl23_connect(SSL *s); int ssl23_read_bytes(SSL *s, int n); int ssl23_write_bytes(SSL *s); int tls1_new(SSL *s); void tls1_free(SSL *s); void tls1_clear(SSL *s); long tls1_ctrl(SSL *s, int cmd, long larg, void *parg); long tls1_callback_ctrl(SSL *s, int cmd, void (*fp)(void)); int dtls1_new(SSL *s); int dtls1_accept(SSL *s); int dtls1_connect(SSL *s); void dtls1_free(SSL *s); void dtls1_clear(SSL *s); long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg); int dtls1_shutdown(SSL *s); long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok); int dtls1_get_record(SSL *s); int do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len); int dtls1_dispatch_alert(SSL *s); int dtls1_enc(SSL *s, int snd); int ssl_init_wbio_buffer(SSL *s, int push); void ssl_free_wbio_buffer(SSL *s); int tls1_change_cipher_state(SSL *s, int which); int tls1_setup_key_block(SSL *s); int tls1_enc(SSL *s, int snd); int tls1_final_finish_mac(SSL *s, const char *str, int slen, unsigned char *p); int tls1_cert_verify_mac(SSL *s, int md_nid, unsigned char *p); int tls1_mac(SSL *ssl, unsigned char *md, int snd); int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p, int len); int tls1_export_keying_material(SSL *s, unsigned char *out, size_t olen, const char *label, size_t llen, const unsigned char *p, size_t plen, int use_context); int tls1_alert_code(int code); int ssl3_alert_code(int code); int ssl_ok(SSL *s); int ssl_check_srvr_ecc_cert_and_alg(X509 *x, SSL *s); SSL_COMP *ssl3_comp_find(STACK_OF(SSL_COMP) *sk, int n); int tls1_ec_curve_id2nid(int curve_id); int tls1_ec_nid2curve_id(int nid); unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *p, unsigned char *limit); unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *p, unsigned char *limit); int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **data, unsigned char *d, int n, int *al); int ssl_parse_serverhello_tlsext(SSL *s, unsigned char **data, unsigned char *d, int n, int *al); int ssl_prepare_clienthello_tlsext(SSL *s); int ssl_prepare_serverhello_tlsext(SSL *s); int ssl_check_clienthello_tlsext_early(SSL *s); int ssl_check_clienthello_tlsext_late(SSL *s); int ssl_check_serverhello_tlsext(SSL *s); #define tlsext_tick_md EVP_sha256 int tls1_process_ticket(SSL *s, unsigned char *session_id, int len, const unsigned char *limit, SSL_SESSION **ret); int tls12_get_sigandhash(unsigned char *p, const EVP_PKEY *pk, const EVP_MD *md); int tls12_get_sigid(const EVP_PKEY *pk); const EVP_MD *tls12_get_hash(unsigned char hash_alg); EVP_MD_CTX* ssl_replace_hash(EVP_MD_CTX **hash, const EVP_MD *md); void ssl_clear_hash_ctx(EVP_MD_CTX **hash); int ssl_add_serverhello_renegotiate_ext(SSL *s, unsigned char *p, int *len, int maxlen); int ssl_parse_serverhello_renegotiate_ext(SSL *s, unsigned char *d, int len, int *al); int ssl_add_clienthello_renegotiate_ext(SSL *s, unsigned char *p, int *len, int maxlen); int ssl_parse_clienthello_renegotiate_ext(SSL *s, unsigned char *d, int len, int *al); long ssl_get_algorithm2(SSL *s); int tls1_process_sigalgs(SSL *s, const unsigned char *data, int dsize); int tls12_get_req_sig_algs(SSL *s, unsigned char *p); int ssl_add_clienthello_use_srtp_ext(SSL *s, unsigned char *p, int *len, int maxlen); int ssl_parse_clienthello_use_srtp_ext(SSL *s, unsigned char *d, int len, int *al); int ssl_add_serverhello_use_srtp_ext(SSL *s, unsigned char *p, int *len, int maxlen); int ssl_parse_serverhello_use_srtp_ext(SSL *s, unsigned char *d, int len, int *al); /* s3_cbc.c */ void ssl3_cbc_copy_mac(unsigned char *out, const SSL3_RECORD *rec, unsigned md_size, unsigned orig_len); int ssl3_cbc_remove_padding(const SSL *s, SSL3_RECORD *rec, unsigned block_size, unsigned mac_size); int tls1_cbc_remove_padding(const SSL *s, SSL3_RECORD *rec, unsigned block_size, unsigned mac_size); char ssl3_cbc_record_digest_supported(const EVP_MD_CTX *ctx); void ssl3_cbc_digest_record(const EVP_MD_CTX *ctx, unsigned char *md_out, size_t *md_out_size, const unsigned char header[13], const unsigned char *data, size_t data_plus_mac_size, size_t data_plus_mac_plus_padding_size, const unsigned char *mac_secret, unsigned mac_secret_length, char is_sslv3); #endif deps/libressl-pnacl-sys-2.1.6/libressl/ssl/s3_pkt.c0000644000175000017500000012150412360020705017106 0ustar /* $OpenBSD: s3_pkt.c,v 1.48 2014/06/19 21:29:51 tedu Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "ssl_locl.h" #include #include #include static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len, int create_empty_fragment); static int ssl3_get_record(SSL *s); /* If extend == 0, obtain new n-byte packet; if extend == 1, increase * packet by another n bytes. * The packet will be in the sub-array of s->s3->rbuf.buf specified * by s->packet and s->packet_length. * (If s->read_ahead is set, 'max' bytes may be stored in rbuf * [plus s->packet_length bytes if extend == 1].) */ int ssl3_read_n(SSL *s, int n, int max, int extend) { int i, len, left; long align = 0; unsigned char *pkt; SSL3_BUFFER *rb; if (n <= 0) return n; rb = &(s->s3->rbuf); if (rb->buf == NULL) if (!ssl3_setup_read_buffer(s)) return -1; left = rb->left; #if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0 align = (long)rb->buf + SSL3_RT_HEADER_LENGTH; align = (-align)&(SSL3_ALIGN_PAYLOAD - 1); #endif if (!extend) { /* start with empty packet ... */ if (left == 0) rb->offset = align; else if (align != 0 && left >= SSL3_RT_HEADER_LENGTH) { /* check if next packet length is large * enough to justify payload alignment... */ pkt = rb->buf + rb->offset; if (pkt[0] == SSL3_RT_APPLICATION_DATA && (pkt[3]<<8|pkt[4]) >= 128) { /* Note that even if packet is corrupted * and its length field is insane, we can * only be led to wrong decision about * whether memmove will occur or not. * Header values has no effect on memmove * arguments and therefore no buffer * overrun can be triggered. */ memmove(rb->buf + align, pkt, left); rb->offset = align; } } s->packet = rb->buf + rb->offset; s->packet_length = 0; /* ... now we can act as if 'extend' was set */ } /* For DTLS/UDP reads should not span multiple packets * because the read operation returns the whole packet * at once (as long as it fits into the buffer). */ if (SSL_IS_DTLS(s)) { if (left > 0 && n > left) n = left; } /* if there is enough in the buffer from a previous read, take some */ if (left >= n) { s->packet_length += n; rb->left = left - n; rb->offset += n; return (n); } /* else we need to read more data */ len = s->packet_length; pkt = rb->buf + align; /* Move any available bytes to front of buffer: * 'len' bytes already pointed to by 'packet', * 'left' extra ones at the end */ if (s->packet != pkt) { /* len > 0 */ memmove(pkt, s->packet, len + left); s->packet = pkt; rb->offset = len + align; } if (n > (int)(rb->len - rb->offset)) { /* does not happen */ SSLerr(SSL_F_SSL3_READ_N, ERR_R_INTERNAL_ERROR); return -1; } if (!s->read_ahead) { /* ignore max parameter */ max = n; } else { if (max < n) max = n; if (max > (int)(rb->len - rb->offset)) max = rb->len - rb->offset; } while (left < n) { /* Now we have len+left bytes at the front of s->s3->rbuf.buf * and need to read in more until we have len+n (up to * len+max if possible) */ errno = 0; if (s->rbio != NULL) { s->rwstate = SSL_READING; i = BIO_read(s->rbio, pkt + len + left, max - left); } else { SSLerr(SSL_F_SSL3_READ_N, SSL_R_READ_BIO_NOT_SET); i = -1; } if (i <= 0) { rb->left = left; if (s->mode & SSL_MODE_RELEASE_BUFFERS && !SSL_IS_DTLS(s)) { if (len + left == 0) ssl3_release_read_buffer(s); } return (i); } left += i; /* * reads should *never* span multiple packets for DTLS because * the underlying transport protocol is message oriented as * opposed to byte oriented as in the TLS case. */ if (SSL_IS_DTLS(s)) { if (n > left) n = left; /* makes the while condition false */ } } /* done reading, now the book-keeping */ rb->offset += n; rb->left = left - n; s->packet_length += n; s->rwstate = SSL_NOTHING; return (n); } /* Call this to get a new input record. * It will return <= 0 if more data is needed, normally due to an error * or non-blocking IO. * When it finishes, one packet has been decoded and can be found in * ssl->s3->rrec.type - is the type of record * ssl->s3->rrec.data, - data * ssl->s3->rrec.length, - number of bytes */ /* used only by ssl3_read_bytes */ static int ssl3_get_record(SSL *s) { int ssl_major, ssl_minor, al; int enc_err, n, i, ret = -1; SSL3_RECORD *rr; SSL_SESSION *sess; unsigned char *p; unsigned char md[EVP_MAX_MD_SIZE]; short version; unsigned mac_size, orig_len; size_t extra; rr = &(s->s3->rrec); sess = s->session; if (s->options & SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER) extra = SSL3_RT_MAX_EXTRA; else extra = 0; if (extra && !s->s3->init_extra) { /* An application error: SLS_OP_MICROSOFT_BIG_SSLV3_BUFFER * set after ssl3_setup_buffers() was done */ SSLerr(SSL_F_SSL3_GET_RECORD, ERR_R_INTERNAL_ERROR); return -1; } again: /* check if we have the header */ if ((s->rstate != SSL_ST_READ_BODY) || (s->packet_length < SSL3_RT_HEADER_LENGTH)) { n = ssl3_read_n(s, SSL3_RT_HEADER_LENGTH, s->s3->rbuf.len, 0); if (n <= 0) return(n); /* error or non-blocking */ s->rstate = SSL_ST_READ_BODY; p = s->packet; /* Pull apart the header into the SSL3_RECORD */ rr->type= *(p++); ssl_major= *(p++); ssl_minor= *(p++); version = (ssl_major << 8)|ssl_minor; n2s(p, rr->length); /* Lets check version */ if (!s->first_packet) { if (version != s->version) { SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_WRONG_VERSION_NUMBER); if ((s->version & 0xFF00) == (version & 0xFF00) && !s->enc_write_ctx && !s->write_hash) /* Send back error using their minor version number :-) */ s->version = (unsigned short)version; al = SSL_AD_PROTOCOL_VERSION; goto f_err; } } if ((version >> 8) != SSL3_VERSION_MAJOR) { SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_WRONG_VERSION_NUMBER); goto err; } if (rr->length > s->s3->rbuf.len - SSL3_RT_HEADER_LENGTH) { al = SSL_AD_RECORD_OVERFLOW; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_PACKET_LENGTH_TOO_LONG); goto f_err; } /* now s->rstate == SSL_ST_READ_BODY */ } /* s->rstate == SSL_ST_READ_BODY, get and decode the data */ if (rr->length > s->packet_length - SSL3_RT_HEADER_LENGTH) { /* now s->packet_length == SSL3_RT_HEADER_LENGTH */ i = rr->length; n = ssl3_read_n(s, i, i, 1); if (n <= 0) return(n); /* error or non-blocking io */ /* now n == rr->length, * and s->packet_length == SSL3_RT_HEADER_LENGTH + rr->length */ } s->rstate=SSL_ST_READ_HEADER; /* set state for later operations */ /* At this point, s->packet_length == SSL3_RT_HEADER_LNGTH + rr->length, * and we have that many bytes in s->packet */ rr->input = &(s->packet[SSL3_RT_HEADER_LENGTH]); /* ok, we can now read from 's->packet' data into 'rr' * rr->input points at rr->length bytes, which * need to be copied into rr->data by either * the decryption or by the decompression * When the data is 'copied' into the rr->data buffer, * rr->input will be pointed at the new buffer */ /* We now have - encrypted [ MAC [ compressed [ plain ] ] ] * rr->length bytes of encrypted compressed stuff. */ /* check is not needed I believe */ if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH + extra) { al = SSL_AD_RECORD_OVERFLOW; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_ENCRYPTED_LENGTH_TOO_LONG); goto f_err; } /* decrypt in place in 'rr->input' */ rr->data = rr->input; enc_err = s->method->ssl3_enc->enc(s, 0); /* enc_err is: * 0: (in non-constant time) if the record is publically invalid. * 1: if the padding is valid * -1: if the padding is invalid */ if (enc_err == 0) { al = SSL_AD_DECRYPTION_FAILED; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_BLOCK_CIPHER_PAD_IS_WRONG); goto f_err; } /* r->length is now the compressed data plus mac */ if ((sess != NULL) && (s->enc_read_ctx != NULL) && (EVP_MD_CTX_md(s->read_hash) != NULL)) { /* s->read_hash != NULL => mac_size != -1 */ unsigned char *mac = NULL; unsigned char mac_tmp[EVP_MAX_MD_SIZE]; mac_size = EVP_MD_CTX_size(s->read_hash); OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE); /* kludge: *_cbc_remove_padding passes padding length in rr->type */ orig_len = rr->length + ((unsigned int)rr->type >> 8); /* orig_len is the length of the record before any padding was * removed. This is public information, as is the MAC in use, * therefore we can safely process the record in a different * amount of time if it's too short to possibly contain a MAC. */ if (orig_len < mac_size || /* CBC records must have a padding length byte too. */ (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE && orig_len < mac_size + 1)) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_LENGTH_TOO_SHORT); goto f_err; } if (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE) { /* We update the length so that the TLS header bytes * can be constructed correctly but we need to extract * the MAC in constant time from within the record, * without leaking the contents of the padding bytes. * */ mac = mac_tmp; ssl3_cbc_copy_mac(mac_tmp, rr, mac_size, orig_len); rr->length -= mac_size; } else { /* In this case there's no padding, so |orig_len| * equals |rec->length| and we checked that there's * enough bytes for |mac_size| above. */ rr->length -= mac_size; mac = &rr->data[rr->length]; } i = s->method->ssl3_enc->mac(s,md,0 /* not send */); if (i < 0 || mac == NULL || timingsafe_memcmp(md, mac, (size_t)mac_size) != 0) enc_err = -1; if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH + extra + mac_size) enc_err = -1; } if (enc_err < 0) { /* * A separate 'decryption_failed' alert was introduced with * TLS 1.0, SSL 3.0 only has 'bad_record_mac'. But unless a * decryption failure is directly visible from the ciphertext * anyway, we should not reveal which kind of error * occurred -- this might become visible to an attacker * (e.g. via a logfile) */ al = SSL_AD_BAD_RECORD_MAC; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC); goto f_err; } if (rr->length > SSL3_RT_MAX_PLAIN_LENGTH + extra) { al = SSL_AD_RECORD_OVERFLOW; SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_DATA_LENGTH_TOO_LONG); goto f_err; } rr->off = 0; /* * So at this point the following is true * * ssl->s3->rrec.type is the type of record * ssl->s3->rrec.length == number of bytes in record * ssl->s3->rrec.off == offset to first valid byte * ssl->s3->rrec.data == where to take bytes from, increment * after use :-). */ /* we have pulled in a full packet so zero things */ s->packet_length = 0; /* just read a 0 length packet */ if (rr->length == 0) goto again; return (1); f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: return (ret); } /* Call this to write data in records of type 'type' * It will return <= 0 if not all data has been sent or non-blocking IO. */ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len) { const unsigned char *buf = buf_; unsigned int tot, n, nw; int i; if (len < 0) { SSLerr(SSL_F_SSL3_WRITE_BYTES, ERR_R_INTERNAL_ERROR); return -1; } s->rwstate = SSL_NOTHING; tot = s->s3->wnum; s->s3->wnum = 0; if (SSL_in_init(s) && !s->in_handshake) { i = s->handshake_func(s); if (i < 0) return (i); if (i == 0) { SSLerr(SSL_F_SSL3_WRITE_BYTES, SSL_R_SSL_HANDSHAKE_FAILURE); return -1; } } if (len < tot) len = tot; n = (len - tot); for (;;) { if (n > s->max_send_fragment) nw = s->max_send_fragment; else nw = n; i = do_ssl3_write(s, type, &(buf[tot]), nw, 0); if (i <= 0) { s->s3->wnum = tot; return i; } if ((i == (int)n) || (type == SSL3_RT_APPLICATION_DATA && (s->mode & SSL_MODE_ENABLE_PARTIAL_WRITE))) { /* * Next chunk of data should get another prepended * empty fragment in ciphersuites with known-IV * weakness. */ s->s3->empty_fragment_done = 0; return tot + i; } n -= i; tot += i; } } static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len, int create_empty_fragment) { unsigned char *p, *plen; int i, mac_size, clear = 0; int prefix_len = 0; int eivlen; long align = 0; SSL3_RECORD *wr; SSL3_BUFFER *wb = &(s->s3->wbuf); SSL_SESSION *sess; if (wb->buf == NULL) if (!ssl3_setup_write_buffer(s)) return -1; /* first check if there is a SSL3_BUFFER still being written * out. This will happen with non blocking IO */ if (wb->left != 0) return (ssl3_write_pending(s, type, buf, len)); /* If we have an alert to send, lets send it */ if (s->s3->alert_dispatch) { i = s->method->ssl_dispatch_alert(s); if (i <= 0) return (i); /* if it went, fall through and send more stuff */ /* we may have released our buffer, so get it again */ if (wb->buf == NULL) if (!ssl3_setup_write_buffer(s)) return -1; } if (len == 0 && !create_empty_fragment) return 0; wr = &(s->s3->wrec); sess = s->session; if ((sess == NULL) || (s->enc_write_ctx == NULL) || (EVP_MD_CTX_md(s->write_hash) == NULL)) { clear = s->enc_write_ctx ? 0 : 1; /* must be AEAD cipher */ mac_size = 0; } else { mac_size = EVP_MD_CTX_size(s->write_hash); if (mac_size < 0) goto err; } /* * 'create_empty_fragment' is true only when this function calls * itself. */ if (!clear && !create_empty_fragment && !s->s3->empty_fragment_done) { /* * Countermeasure against known-IV weakness in CBC ciphersuites * (see http://www.openssl.org/~bodo/tls-cbc.txt) */ if (s->s3->need_empty_fragments && type == SSL3_RT_APPLICATION_DATA) { /* recursive function call with 'create_empty_fragment' set; * this prepares and buffers the data for an empty fragment * (these 'prefix_len' bytes are sent out later * together with the actual payload) */ prefix_len = do_ssl3_write(s, type, buf, 0, 1); if (prefix_len <= 0) goto err; if (prefix_len > (SSL3_RT_HEADER_LENGTH + SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD)) { /* insufficient space */ SSLerr(SSL_F_DO_SSL3_WRITE, ERR_R_INTERNAL_ERROR); goto err; } } s->s3->empty_fragment_done = 1; } if (create_empty_fragment) { #if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0 /* extra fragment would be couple of cipher blocks, * which would be multiple of SSL3_ALIGN_PAYLOAD, so * if we want to align the real payload, then we can * just pretent we simply have two headers. */ align = (long)wb->buf + 2*SSL3_RT_HEADER_LENGTH; align = (-align)&(SSL3_ALIGN_PAYLOAD - 1); #endif p = wb->buf + align; wb->offset = align; } else if (prefix_len) { p = wb->buf + wb->offset + prefix_len; } else { #if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0 align = (long)wb->buf + SSL3_RT_HEADER_LENGTH; align = (-align)&(SSL3_ALIGN_PAYLOAD - 1); #endif p = wb->buf + align; wb->offset = align; } /* write the header */ *(p++) = type&0xff; wr->type = type; *(p++) = (s->version >> 8); /* Some servers hang if iniatial client hello is larger than 256 * bytes and record version number > TLS 1.0 */ if (s->state == SSL3_ST_CW_CLNT_HELLO_B && !s->renegotiate && TLS1_get_version(s) > TLS1_VERSION) *(p++) = 0x1; else *(p++) = s->version&0xff; /* field where we are to write out packet length */ plen = p; p += 2; /* Explicit IV length. */ if (s->enc_write_ctx && SSL_USE_EXPLICIT_IV(s)) { int mode = EVP_CIPHER_CTX_mode(s->enc_write_ctx); if (mode == EVP_CIPH_CBC_MODE) { eivlen = EVP_CIPHER_CTX_iv_length(s->enc_write_ctx); if (eivlen <= 1) eivlen = 0; } /* Need explicit part of IV for GCM mode */ else if (mode == EVP_CIPH_GCM_MODE) eivlen = EVP_GCM_TLS_EXPLICIT_IV_LEN; else eivlen = 0; } else if (s->aead_write_ctx != NULL && s->aead_write_ctx->variable_nonce_in_record) { eivlen = s->aead_write_ctx->variable_nonce_len; } else eivlen = 0; /* lets setup the record stuff. */ wr->data = p + eivlen; wr->length = (int)len; wr->input = (unsigned char *)buf; /* we now 'read' from wr->input, wr->length bytes into wr->data */ memcpy(wr->data, wr->input, wr->length); wr->input = wr->data; /* we should still have the output to wr->data and the input * from wr->input. Length should be wr->length. * wr->data still points in the wb->buf */ if (mac_size != 0) { if (s->method->ssl3_enc->mac(s, &(p[wr->length + eivlen]), 1) < 0) goto err; wr->length += mac_size; } wr->input = p; wr->data = p; if (eivlen) { /* if (RAND_pseudo_bytes(p, eivlen) <= 0) goto err; */ wr->length += eivlen; } /* ssl3_enc can only have an error on read */ s->method->ssl3_enc->enc(s, 1); /* record length after mac and block padding */ s2n(wr->length, plen); /* we should now have * wr->data pointing to the encrypted data, which is * wr->length long */ wr->type=type; /* not needed but helps for debugging */ wr->length += SSL3_RT_HEADER_LENGTH; if (create_empty_fragment) { /* we are in a recursive call; * just return the length, don't write out anything here */ return wr->length; } /* now let's set up wb */ wb->left = prefix_len + wr->length; /* memorize arguments so that ssl3_write_pending can detect * bad write retries later */ s->s3->wpend_tot = len; s->s3->wpend_buf = buf; s->s3->wpend_type = type; s->s3->wpend_ret = len; /* we now just need to write the buffer */ return ssl3_write_pending(s, type, buf, len); err: return -1; } /* if s->s3->wbuf.left != 0, we need to call this */ int ssl3_write_pending(SSL *s, int type, const unsigned char *buf, unsigned int len) { int i; SSL3_BUFFER *wb = &(s->s3->wbuf); /* XXXX */ if ((s->s3->wpend_tot > (int)len) || ((s->s3->wpend_buf != buf) && !(s->mode & SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER)) || (s->s3->wpend_type != type)) { SSLerr(SSL_F_SSL3_WRITE_PENDING, SSL_R_BAD_WRITE_RETRY); return (-1); } for (;;) { errno = 0; if (s->wbio != NULL) { s->rwstate = SSL_WRITING; i = BIO_write(s->wbio, (char *)&(wb->buf[wb->offset]), (unsigned int)wb->left); } else { SSLerr(SSL_F_SSL3_WRITE_PENDING, SSL_R_BIO_NOT_SET); i = -1; } if (i == wb->left) { wb->left = 0; wb->offset += i; if (s->mode & SSL_MODE_RELEASE_BUFFERS && !SSL_IS_DTLS(s)) ssl3_release_write_buffer(s); s->rwstate = SSL_NOTHING; return (s->s3->wpend_ret); } else if (i <= 0) { /* * For DTLS, just drop it. That's kind of the * whole point in using a datagram service. */ if (SSL_IS_DTLS(s)) wb->left = 0; return (i); } wb->offset += i; wb->left -= i; } } /* Return up to 'len' payload bytes received in 'type' records. * 'type' is one of the following: * * - SSL3_RT_HANDSHAKE (when ssl3_get_message calls us) * - SSL3_RT_APPLICATION_DATA (when ssl3_read calls us) * - 0 (during a shutdown, no data has to be returned) * * If we don't have stored data to work from, read a SSL/TLS record first * (possibly multiple records if we still don't have anything to return). * * This function must handle any surprises the peer may have for us, such as * Alert records (e.g. close_notify), ChangeCipherSpec records (not really * a surprise, but handled as if it were), or renegotiation requests. * Also if record payloads contain fragments too small to process, we store * them until there is enough for the respective protocol (the record protocol * may use arbitrary fragmentation and even interleaving): * Change cipher spec protocol * just 1 byte needed, no need for keeping anything stored * Alert protocol * 2 bytes needed (AlertLevel, AlertDescription) * Handshake protocol * 4 bytes needed (HandshakeType, uint24 length) -- we just have * to detect unexpected Client Hello and Hello Request messages * here, anything else is handled by higher layers * Application data protocol * none of our business */ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) { int al, i, j, ret; unsigned int n; SSL3_RECORD *rr; void (*cb)(const SSL *ssl, int type2, int val) = NULL; if (s->s3->rbuf.buf == NULL) /* Not initialized yet */ if (!ssl3_setup_read_buffer(s)) return (-1); if (len < 0) { SSLerr(SSL_F_SSL3_READ_BYTES, ERR_R_INTERNAL_ERROR); return -1; } if ((type && type != SSL3_RT_APPLICATION_DATA && type != SSL3_RT_HANDSHAKE) || (peek && (type != SSL3_RT_APPLICATION_DATA))) { SSLerr(SSL_F_SSL3_READ_BYTES, ERR_R_INTERNAL_ERROR); return -1; } if ((type == SSL3_RT_HANDSHAKE) && (s->s3->handshake_fragment_len > 0)) { /* (partially) satisfy request from storage */ unsigned char *src = s->s3->handshake_fragment; unsigned char *dst = buf; unsigned int k; /* peek == 0 */ n = 0; while ((len > 0) && (s->s3->handshake_fragment_len > 0)) { *dst++ = *src++; len--; s->s3->handshake_fragment_len--; n++; } /* move any remaining fragment bytes: */ for (k = 0; k < s->s3->handshake_fragment_len; k++) s->s3->handshake_fragment[k] = *src++; return n; } /* * Now s->s3->handshake_fragment_len == 0 if * type == SSL3_RT_HANDSHAKE. */ if (!s->in_handshake && SSL_in_init(s)) { /* type == SSL3_RT_APPLICATION_DATA */ i = s->handshake_func(s); if (i < 0) return (i); if (i == 0) { SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_SSL_HANDSHAKE_FAILURE); return (-1); } } start: s->rwstate = SSL_NOTHING; /* * s->s3->rrec.type - is the type of record * s->s3->rrec.data, - data * s->s3->rrec.off, - offset into 'data' for next read * s->s3->rrec.length, - number of bytes. */ rr = &(s->s3->rrec); /* get new packet if necessary */ if ((rr->length == 0) || (s->rstate == SSL_ST_READ_BODY)) { ret = ssl3_get_record(s); if (ret <= 0) return (ret); } /* we now have a packet which can be read and processed */ if (s->s3->change_cipher_spec /* set when we receive ChangeCipherSpec, * reset by ssl3_get_finished */ && (rr->type != SSL3_RT_HANDSHAKE)) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_DATA_BETWEEN_CCS_AND_FINISHED); goto f_err; } /* If the other end has shut down, throw anything we read away * (even in 'peek' mode) */ if (s->shutdown & SSL_RECEIVED_SHUTDOWN) { rr->length = 0; s->rwstate = SSL_NOTHING; return (0); } /* SSL3_RT_APPLICATION_DATA or SSL3_RT_HANDSHAKE */ if (type == rr->type) { /* make sure that we are not getting application data when we * are doing a handshake for the first time */ if (SSL_in_init(s) && (type == SSL3_RT_APPLICATION_DATA) && (s->enc_read_ctx == NULL)) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_APP_DATA_IN_HANDSHAKE); goto f_err; } if (len <= 0) return (len); if ((unsigned int)len > rr->length) n = rr->length; else n = (unsigned int)len; memcpy(buf, &(rr->data[rr->off]), n); if (!peek) { rr->length -= n; rr->off += n; if (rr->length == 0) { s->rstate = SSL_ST_READ_HEADER; rr->off = 0; if (s->mode & SSL_MODE_RELEASE_BUFFERS && s->s3->rbuf.left == 0) ssl3_release_read_buffer(s); } } return (n); } /* If we get here, then type != rr->type; if we have a handshake * message, then it was unexpected (Hello Request or Client Hello). */ { /* * In case of record types for which we have 'fragment' * storage, * fill that so that we can process the data * at a fixed place. */ unsigned int dest_maxlen = 0; unsigned char *dest = NULL; unsigned int *dest_len = NULL; if (rr->type == SSL3_RT_HANDSHAKE) { dest_maxlen = sizeof s->s3->handshake_fragment; dest = s->s3->handshake_fragment; dest_len = &s->s3->handshake_fragment_len; } else if (rr->type == SSL3_RT_ALERT) { dest_maxlen = sizeof s->s3->alert_fragment; dest = s->s3->alert_fragment; dest_len = &s->s3->alert_fragment_len; } if (dest_maxlen > 0) { /* available space in 'dest' */ n = dest_maxlen - *dest_len; if (rr->length < n) n = rr->length; /* available bytes */ /* now move 'n' bytes: */ while (n-- > 0) { dest[(*dest_len)++] = rr->data[rr->off++]; rr->length--; } if (*dest_len < dest_maxlen) goto start; /* fragment was too small */ } } /* s->s3->handshake_fragment_len == 4 iff rr->type == SSL3_RT_HANDSHAKE; * s->s3->alert_fragment_len == 2 iff rr->type == SSL3_RT_ALERT. * (Possibly rr is 'empty' now, i.e. rr->length may be 0.) */ /* If we are a client, check for an incoming 'Hello Request': */ if ((!s->server) && (s->s3->handshake_fragment_len >= 4) && (s->s3->handshake_fragment[0] == SSL3_MT_HELLO_REQUEST) && (s->session != NULL) && (s->session->cipher != NULL)) { s->s3->handshake_fragment_len = 0; if ((s->s3->handshake_fragment[1] != 0) || (s->s3->handshake_fragment[2] != 0) || (s->s3->handshake_fragment[3] != 0)) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_BAD_HELLO_REQUEST); goto f_err; } if (s->msg_callback) s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->s3->handshake_fragment, 4, s, s->msg_callback_arg); if (SSL_is_init_finished(s) && !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) && !s->s3->renegotiate) { ssl3_renegotiate(s); if (ssl3_renegotiate_check(s)) { i = s->handshake_func(s); if (i < 0) return (i); if (i == 0) { SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_SSL_HANDSHAKE_FAILURE); return (-1); } if (!(s->mode & SSL_MODE_AUTO_RETRY)) { if (s->s3->rbuf.left == 0) { /* no read-ahead left? */ BIO *bio; /* In the case where we try to read application data, * but we trigger an SSL handshake, we return -1 with * the retry option set. Otherwise renegotiation may * cause nasty problems in the blocking world */ s->rwstate = SSL_READING; bio = SSL_get_rbio(s); BIO_clear_retry_flags(bio); BIO_set_retry_read(bio); return (-1); } } } } /* we either finished a handshake or ignored the request, * now try again to obtain the (application) data we were asked for */ goto start; } /* If we are a server and get a client hello when renegotiation isn't * allowed send back a no renegotiation alert and carry on. * WARNING: experimental code, needs reviewing (steve) */ if (s->server && SSL_is_init_finished(s) && !s->s3->send_connection_binding && (s->version > SSL3_VERSION) && (s->s3->handshake_fragment_len >= 4) && (s->s3->handshake_fragment[0] == SSL3_MT_CLIENT_HELLO) && (s->session != NULL) && (s->session->cipher != NULL)) { /*s->s3->handshake_fragment_len = 0;*/ rr->length = 0; ssl3_send_alert(s, SSL3_AL_WARNING, SSL_AD_NO_RENEGOTIATION); goto start; } if (s->s3->alert_fragment_len >= 2) { int alert_level = s->s3->alert_fragment[0]; int alert_descr = s->s3->alert_fragment[1]; s->s3->alert_fragment_len = 0; if (s->msg_callback) s->msg_callback(0, s->version, SSL3_RT_ALERT, s->s3->alert_fragment, 2, s, s->msg_callback_arg); if (s->info_callback != NULL) cb = s->info_callback; else if (s->ctx->info_callback != NULL) cb = s->ctx->info_callback; if (cb != NULL) { j = (alert_level << 8) | alert_descr; cb(s, SSL_CB_READ_ALERT, j); } if (alert_level == 1) { /* warning */ s->s3->warn_alert = alert_descr; if (alert_descr == SSL_AD_CLOSE_NOTIFY) { s->shutdown |= SSL_RECEIVED_SHUTDOWN; return (0); } /* This is a warning but we receive it if we requested * renegotiation and the peer denied it. Terminate with * a fatal alert because if application tried to * renegotiatie it presumably had a good reason and * expects it to succeed. * * In future we might have a renegotiation where we * don't care if the peer refused it where we carry on. */ else if (alert_descr == SSL_AD_NO_RENEGOTIATION) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_NO_RENEGOTIATION); goto f_err; } #ifdef SSL_AD_MISSING_SRP_USERNAME else if (alert_descr == SSL_AD_MISSING_SRP_USERNAME) return (0); #endif } else if (alert_level == 2) { /* fatal */ s->rwstate = SSL_NOTHING; s->s3->fatal_alert = alert_descr; SSLerr(SSL_F_SSL3_READ_BYTES, SSL_AD_REASON_OFFSET + alert_descr); ERR_asprintf_error_data("SSL alert number %d", alert_descr); s->shutdown |= SSL_RECEIVED_SHUTDOWN; SSL_CTX_remove_session(s->ctx, s->session); return (0); } else { al = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_UNKNOWN_ALERT_TYPE); goto f_err; } goto start; } if (s->shutdown & SSL_SENT_SHUTDOWN) { /* but we have not received a shutdown */ s->rwstate = SSL_NOTHING; rr->length = 0; return (0); } if (rr->type == SSL3_RT_CHANGE_CIPHER_SPEC) { /* 'Change Cipher Spec' is just a single byte, so we know * exactly what the record payload has to look like */ if ((rr->length != 1) || (rr->off != 0) || (rr->data[0] != SSL3_MT_CCS)) { al = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_BAD_CHANGE_CIPHER_SPEC); goto f_err; } /* Check we have a cipher to change to */ if (s->s3->tmp.new_cipher == NULL) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_CCS_RECEIVED_EARLY); goto f_err; } /* Check that we should be receiving a Change Cipher Spec. */ if (!(s->s3->flags & SSL3_FLAGS_CCS_OK)) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_CCS_RECEIVED_EARLY); goto f_err; } s->s3->flags &= ~SSL3_FLAGS_CCS_OK; rr->length = 0; if (s->msg_callback) { s->msg_callback(0, s->version, SSL3_RT_CHANGE_CIPHER_SPEC, rr->data, 1, s, s->msg_callback_arg); } s->s3->change_cipher_spec = 1; if (!ssl3_do_change_cipher_spec(s)) goto err; else goto start; } /* Unexpected handshake message (Client Hello, or protocol violation) */ if ((s->s3->handshake_fragment_len >= 4) && !s->in_handshake) { if (((s->state&SSL_ST_MASK) == SSL_ST_OK) && !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)) { s->state = s->server ? SSL_ST_ACCEPT : SSL_ST_CONNECT; s->renegotiate = 1; s->new_session = 1; } i = s->handshake_func(s); if (i < 0) return (i); if (i == 0) { SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_SSL_HANDSHAKE_FAILURE); return (-1); } if (!(s->mode & SSL_MODE_AUTO_RETRY)) { if (s->s3->rbuf.left == 0) { /* no read-ahead left? */ BIO *bio; /* In the case where we try to read application data, * but we trigger an SSL handshake, we return -1 with * the retry option set. Otherwise renegotiation may * cause nasty problems in the blocking world */ s->rwstate = SSL_READING; bio = SSL_get_rbio(s); BIO_clear_retry_flags(bio); BIO_set_retry_read(bio); return (-1); } } goto start; } switch (rr->type) { default: /* * TLS up to v1.1 just ignores unknown message types: * TLS v1.2 give an unexpected message alert. */ if (s->version >= TLS1_VERSION && s->version <= TLS1_1_VERSION) { rr->length = 0; goto start; } al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_UNEXPECTED_RECORD); goto f_err; case SSL3_RT_CHANGE_CIPHER_SPEC: case SSL3_RT_ALERT: case SSL3_RT_HANDSHAKE: /* we already handled all of these, with the possible exception * of SSL3_RT_HANDSHAKE when s->in_handshake is set, but that * should not happen when type != rr->type */ al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_READ_BYTES, ERR_R_INTERNAL_ERROR); goto f_err; case SSL3_RT_APPLICATION_DATA: /* At this point, we were expecting handshake data, * but have application data. If the library was * running inside ssl3_read() (i.e. in_read_app_data * is set) and it makes sense to read application data * at this point (session renegotiation not yet started), * we will indulge it. */ if (s->s3->in_read_app_data && (s->s3->total_renegotiations != 0) && (((s->state & SSL_ST_CONNECT) && (s->state >= SSL3_ST_CW_CLNT_HELLO_A) && (s->state <= SSL3_ST_CR_SRVR_HELLO_A)) || ((s->state & SSL_ST_ACCEPT) && (s->state <= SSL3_ST_SW_HELLO_REQ_A) && (s->state >= SSL3_ST_SR_CLNT_HELLO_A)))) { s->s3->in_read_app_data = 2; return (-1); } else { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_UNEXPECTED_RECORD); goto f_err; } } /* not reached */ f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: return (-1); } int ssl3_do_change_cipher_spec(SSL *s) { int i; const char *sender; int slen; if (s->state & SSL_ST_ACCEPT) i = SSL3_CHANGE_CIPHER_SERVER_READ; else i = SSL3_CHANGE_CIPHER_CLIENT_READ; if (s->s3->tmp.key_block == NULL) { if (s->session == NULL || s->session->master_key_length == 0) { /* might happen if dtls1_read_bytes() calls this */ SSLerr(SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC, SSL_R_CCS_RECEIVED_EARLY); return (0); } s->session->cipher = s->s3->tmp.new_cipher; if (!s->method->ssl3_enc->setup_key_block(s)) return (0); } if (!s->method->ssl3_enc->change_cipher_state(s, i)) return (0); /* we have to record the message digest at * this point so we can get it before we read * the finished message */ if (s->state & SSL_ST_CONNECT) { sender = s->method->ssl3_enc->server_finished_label; slen = s->method->ssl3_enc->server_finished_label_len; } else { sender = s->method->ssl3_enc->client_finished_label; slen = s->method->ssl3_enc->client_finished_label_len; } i = s->method->ssl3_enc->final_finish_mac(s, sender, slen, s->s3->tmp.peer_finish_md); if (i == 0) { SSLerr(SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC, ERR_R_INTERNAL_ERROR); return 0; } s->s3->tmp.peer_finish_md_len = i; return (1); } int ssl3_send_alert(SSL *s, int level, int desc) { /* Map tls/ssl alert value to correct one */ desc = s->method->ssl3_enc->alert_value(desc); if (s->version == SSL3_VERSION && desc == SSL_AD_PROTOCOL_VERSION) { /* SSL 3.0 does not have protocol_version alerts */ desc = SSL_AD_HANDSHAKE_FAILURE; } if (desc < 0) return -1; /* If a fatal one, remove from cache */ if ((level == 2) && (s->session != NULL)) SSL_CTX_remove_session(s->ctx, s->session); s->s3->alert_dispatch = 1; s->s3->send_alert[0] = level; s->s3->send_alert[1] = desc; if (s->s3->wbuf.left == 0) /* data still being written out? */ return s->method->ssl_dispatch_alert(s); /* else data is still being written out, we will get written * some time in the future */ return -1; } int ssl3_dispatch_alert(SSL *s) { int i, j; void (*cb)(const SSL *ssl, int type, int val) = NULL; s->s3->alert_dispatch = 0; i = do_ssl3_write(s, SSL3_RT_ALERT, &s->s3->send_alert[0], 2, 0); if (i <= 0) { s->s3->alert_dispatch = 1; } else { /* Alert sent to BIO. If it is important, flush it now. * If the message does not get sent due to non-blocking IO, * we will not worry too much. */ if (s->s3->send_alert[0] == SSL3_AL_FATAL) (void)BIO_flush(s->wbio); if (s->msg_callback) s->msg_callback(1, s->version, SSL3_RT_ALERT, s->s3->send_alert, 2, s, s->msg_callback_arg); if (s->info_callback != NULL) cb = s->info_callback; else if (s->ctx->info_callback != NULL) cb = s->ctx->info_callback; if (cb != NULL) { j = (s->s3->send_alert[0]<<8)|s->s3->send_alert[1]; cb(s, SSL_CB_WRITE_ALERT, j); } } return (i); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/d1_srtp.c0000644000175000017500000003163312360020705017262 0ustar /* $OpenBSD: d1_srtp.c,v 1.6 2014/06/28 18:05:27 logan Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* * DTLS code by Eric Rescorla * * Copyright (C) 2006, Network Resonance, Inc. * Copyright (C) 2011, RTFM, Inc. */ #include #include #include "ssl_locl.h" #ifndef OPENSSL_NO_SRTP #include "srtp.h" static SRTP_PROTECTION_PROFILE srtp_known_profiles[] = { { "SRTP_AES128_CM_SHA1_80", SRTP_AES128_CM_SHA1_80, }, { "SRTP_AES128_CM_SHA1_32", SRTP_AES128_CM_SHA1_32, }, {0} }; static int find_profile_by_name(char *profile_name, SRTP_PROTECTION_PROFILE **pptr, unsigned len) { SRTP_PROTECTION_PROFILE *p; p = srtp_known_profiles; while (p->name) { if ((len == strlen(p->name)) && !strncmp(p->name, profile_name, len)) { *pptr = p; return 0; } p++; } return 1; } static int find_profile_by_num(unsigned profile_num, SRTP_PROTECTION_PROFILE **pptr) { SRTP_PROTECTION_PROFILE *p; p = srtp_known_profiles; while (p->name) { if (p->id == profile_num) { *pptr = p; return 0; } p++; } return 1; } static int ssl_ctx_make_profiles(const char *profiles_string, STACK_OF(SRTP_PROTECTION_PROFILE) **out) { STACK_OF(SRTP_PROTECTION_PROFILE) *profiles; char *col; char *ptr = (char *)profiles_string; SRTP_PROTECTION_PROFILE *p; if (!(profiles = sk_SRTP_PROTECTION_PROFILE_new_null())) { SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES, SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES); return 1; } do { col = strchr(ptr, ':'); if (!find_profile_by_name(ptr, &p, col ? col - ptr : (int)strlen(ptr))) { sk_SRTP_PROTECTION_PROFILE_push(profiles, p); } else { SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES, SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE); sk_SRTP_PROTECTION_PROFILE_free(profiles); return 1; } if (col) ptr = col + 1; } while (col); *out = profiles; return 0; } int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles) { return ssl_ctx_make_profiles(profiles, &ctx->srtp_profiles); } int SSL_set_tlsext_use_srtp(SSL *s, const char *profiles) { return ssl_ctx_make_profiles(profiles, &s->srtp_profiles); } STACK_OF(SRTP_PROTECTION_PROFILE) * SSL_get_srtp_profiles(SSL *s) { if (s != NULL) { if (s->srtp_profiles != NULL) { return s->srtp_profiles; } else if ((s->ctx != NULL) && (s->ctx->srtp_profiles != NULL)) { return s->ctx->srtp_profiles; } } return NULL; } SRTP_PROTECTION_PROFILE * SSL_get_selected_srtp_profile(SSL *s) { return s->srtp_profile; } /* Note: this function returns 0 length if there are no profiles specified */ int ssl_add_clienthello_use_srtp_ext(SSL *s, unsigned char *p, int *len, int maxlen) { int ct = 0; int i; STACK_OF(SRTP_PROTECTION_PROFILE) *clnt = 0; SRTP_PROTECTION_PROFILE *prof; clnt = SSL_get_srtp_profiles(s); ct = sk_SRTP_PROTECTION_PROFILE_num(clnt); /* -1 if clnt == 0 */ if (p) { if (ct == 0) { SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_USE_SRTP_EXT, SSL_R_EMPTY_SRTP_PROTECTION_PROFILE_LIST); return 1; } if ((2 + ct * 2 + 1) > maxlen) { SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_USE_SRTP_EXT, SSL_R_SRTP_PROTECTION_PROFILE_LIST_TOO_LONG); return 1; } /* Add the length */ s2n(ct * 2, p); for (i = 0; i < ct; i++) { prof = sk_SRTP_PROTECTION_PROFILE_value(clnt, i); s2n(prof->id, p); } /* Add an empty use_mki value */ *p++ = 0; } *len = 2 + ct*2 + 1; return 0; } int ssl_parse_clienthello_use_srtp_ext(SSL *s, unsigned char *d, int len, int *al) { SRTP_PROTECTION_PROFILE *cprof, *sprof; STACK_OF(SRTP_PROTECTION_PROFILE) *clnt = 0, *srvr; int ct; int mki_len; int i, j; int id; int ret; /* Length value + the MKI length */ if (len < 3) { SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT, SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST); *al = SSL_AD_DECODE_ERROR; return 1; } /* Pull off the length of the cipher suite list */ n2s(d, ct); len -= 2; /* Check that it is even */ if (ct % 2) { SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT, SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST); *al = SSL_AD_DECODE_ERROR; return 1; } /* Check that lengths are consistent */ if (len < (ct + 1)) { SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT, SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST); *al = SSL_AD_DECODE_ERROR; return 1; } clnt = sk_SRTP_PROTECTION_PROFILE_new_null(); while (ct) { n2s(d, id); ct -= 2; len -= 2; if (!find_profile_by_num(id, &cprof)) { sk_SRTP_PROTECTION_PROFILE_push(clnt, cprof); } else { ; /* Ignore */ } } /* Extract the MKI value as a sanity check, but discard it for now. */ mki_len = *d; d++; len--; if (mki_len != len) { SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT, SSL_R_BAD_SRTP_MKI_VALUE); *al = SSL_AD_DECODE_ERROR; sk_SRTP_PROTECTION_PROFILE_free(clnt); return 1; } srvr = SSL_get_srtp_profiles(s); /* * Pick our most preferred profile. If no profiles have been * configured then the outer loop doesn't run * (sk_SRTP_PROTECTION_PROFILE_num() = -1) * and so we just return without doing anything. */ for (i = 0; i < sk_SRTP_PROTECTION_PROFILE_num(srvr); i++) { sprof = sk_SRTP_PROTECTION_PROFILE_value(srvr, i); for (j = 0; j < sk_SRTP_PROTECTION_PROFILE_num(clnt); j++) { cprof = sk_SRTP_PROTECTION_PROFILE_value(clnt, j); if (cprof->id == sprof->id) { s->srtp_profile = sprof; *al = 0; ret = 0; goto done; } } } ret = 0; done: if (clnt) sk_SRTP_PROTECTION_PROFILE_free(clnt); return ret; } int ssl_add_serverhello_use_srtp_ext(SSL *s, unsigned char *p, int *len, int maxlen) { if (p) { if (maxlen < 5) { SSLerr(SSL_F_SSL_ADD_SERVERHELLO_USE_SRTP_EXT, SSL_R_SRTP_PROTECTION_PROFILE_LIST_TOO_LONG); return 1; } if (s->srtp_profile == 0) { SSLerr(SSL_F_SSL_ADD_SERVERHELLO_USE_SRTP_EXT, SSL_R_USE_SRTP_NOT_NEGOTIATED); return 1; } s2n(2, p); s2n(s->srtp_profile->id, p); *p++ = 0; } *len = 5; return 0; } int ssl_parse_serverhello_use_srtp_ext(SSL *s, unsigned char *d, int len, int *al) { STACK_OF(SRTP_PROTECTION_PROFILE) *clnt; SRTP_PROTECTION_PROFILE *prof; unsigned id; int i; int ct; if (len != 5) { SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT, SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST); *al = SSL_AD_DECODE_ERROR; return 1; } n2s(d, ct); if (ct != 2) { SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT, SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST); *al = SSL_AD_DECODE_ERROR; return 1; } n2s(d, id); if (*d) { /* Must be no MKI, since we never offer one. */ SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT, SSL_R_BAD_SRTP_MKI_VALUE); *al = SSL_AD_ILLEGAL_PARAMETER; return 1; } clnt = SSL_get_srtp_profiles(s); /* Throw an error if the server gave us an unsolicited extension. */ if (clnt == NULL) { SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT, SSL_R_NO_SRTP_PROFILES); *al = SSL_AD_DECODE_ERROR; return 1; } /* * Check to see if the server gave us something we support * (and presumably offered). */ for (i = 0; i < sk_SRTP_PROTECTION_PROFILE_num(clnt); i++) { prof = sk_SRTP_PROTECTION_PROFILE_value(clnt, i); if (prof->id == id) { s->srtp_profile = prof; *al = 0; return 0; } } SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT, SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST); *al = SSL_AD_DECODE_ERROR; return 1; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/ssl/t1_srvr.c0000644000175000017500000001575412360020705017314 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "ssl_locl.h" #include #include #include #include #include static const SSL_METHOD *tls1_get_server_method(int ver); const SSL_METHOD TLSv1_server_method_data = { .version = TLS1_VERSION, .ssl_new = tls1_new, .ssl_clear = tls1_clear, .ssl_free = tls1_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl_undefined_function, .ssl_read = ssl3_read, .ssl_peek = ssl3_peek, .ssl_write = ssl3_write, .ssl_shutdown = ssl3_shutdown, .ssl_renegotiate = ssl3_renegotiate, .ssl_renegotiate_check = ssl3_renegotiate_check, .ssl_get_message = ssl3_get_message, .ssl_read_bytes = ssl3_read_bytes, .ssl_write_bytes = ssl3_write_bytes, .ssl_dispatch_alert = ssl3_dispatch_alert, .ssl_ctrl = ssl3_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl3_put_cipher_by_char, .ssl_pending = ssl3_pending, .num_ciphers = ssl3_num_ciphers, .get_cipher = ssl3_get_cipher, .get_ssl_method = tls1_get_server_method, .get_timeout = tls1_default_timeout, .ssl3_enc = &TLSv1_enc_data, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD TLSv1_1_server_method_data = { .version = TLS1_1_VERSION, .ssl_new = tls1_new, .ssl_clear = tls1_clear, .ssl_free = tls1_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl_undefined_function, .ssl_read = ssl3_read, .ssl_peek = ssl3_peek, .ssl_write = ssl3_write, .ssl_shutdown = ssl3_shutdown, .ssl_renegotiate = ssl3_renegotiate, .ssl_renegotiate_check = ssl3_renegotiate_check, .ssl_get_message = ssl3_get_message, .ssl_read_bytes = ssl3_read_bytes, .ssl_write_bytes = ssl3_write_bytes, .ssl_dispatch_alert = ssl3_dispatch_alert, .ssl_ctrl = ssl3_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl3_put_cipher_by_char, .ssl_pending = ssl3_pending, .num_ciphers = ssl3_num_ciphers, .get_cipher = ssl3_get_cipher, .get_ssl_method = tls1_get_server_method, .get_timeout = tls1_default_timeout, .ssl3_enc = &TLSv1_1_enc_data, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD TLSv1_2_server_method_data = { .version = TLS1_2_VERSION, .ssl_new = tls1_new, .ssl_clear = tls1_clear, .ssl_free = tls1_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl_undefined_function, .ssl_read = ssl3_read, .ssl_peek = ssl3_peek, .ssl_write = ssl3_write, .ssl_shutdown = ssl3_shutdown, .ssl_renegotiate = ssl3_renegotiate, .ssl_renegotiate_check = ssl3_renegotiate_check, .ssl_get_message = ssl3_get_message, .ssl_read_bytes = ssl3_read_bytes, .ssl_write_bytes = ssl3_write_bytes, .ssl_dispatch_alert = ssl3_dispatch_alert, .ssl_ctrl = ssl3_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl3_put_cipher_by_char, .ssl_pending = ssl3_pending, .num_ciphers = ssl3_num_ciphers, .get_cipher = ssl3_get_cipher, .get_ssl_method = tls1_get_server_method, .get_timeout = tls1_default_timeout, .ssl3_enc = &TLSv1_2_enc_data, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD * TLSv1_server_method(void) { return &TLSv1_server_method_data; } const SSL_METHOD * TLSv1_1_server_method(void) { return &TLSv1_1_server_method_data; } const SSL_METHOD * TLSv1_2_server_method(void) { return &TLSv1_2_server_method_data; } static const SSL_METHOD * tls1_get_server_method(int ver) { if (ver == TLS1_2_VERSION) return (TLSv1_2_server_method()); if (ver == TLS1_1_VERSION) return (TLSv1_1_server_method()); if (ver == TLS1_VERSION) return (TLSv1_server_method()); return (NULL); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/d1_lib.c0000644000175000017500000003013112360020705017030 0ustar /* $OpenBSD: d1_lib.c,v 1.22 2014/07/09 11:10:51 bcook Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. */ /* ==================================================================== * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include "pqueue.h" #include "ssl_locl.h" int dtls1_listen(SSL *s, struct sockaddr *client); SSL3_ENC_METHOD DTLSv1_enc_data = { .enc = dtls1_enc, .mac = tls1_mac, .setup_key_block = tls1_setup_key_block, .generate_master_secret = tls1_generate_master_secret, .change_cipher_state = tls1_change_cipher_state, .final_finish_mac = tls1_final_finish_mac, .finish_mac_length = TLS1_FINISH_MAC_LENGTH, .cert_verify_mac = tls1_cert_verify_mac, .client_finished_label = TLS_MD_CLIENT_FINISH_CONST, .client_finished_label_len = TLS_MD_CLIENT_FINISH_CONST_SIZE, .server_finished_label = TLS_MD_SERVER_FINISH_CONST, .server_finished_label_len = TLS_MD_SERVER_FINISH_CONST_SIZE, .alert_value = tls1_alert_code, .export_keying_material = tls1_export_keying_material, .enc_flags = SSL_ENC_FLAG_DTLS|SSL_ENC_FLAG_EXPLICIT_IV, }; long dtls1_default_timeout(void) { /* 2 hours, the 24 hours mentioned in the DTLSv1 spec * is way too long for http, the cache would over fill */ return (60*60*2); } int dtls1_new(SSL *s) { DTLS1_STATE *d1; if (!ssl3_new(s)) return (0); if ((d1 = calloc(1, sizeof *d1)) == NULL) { ssl3_free(s); return (0); } /* d1->handshake_epoch=0; */ d1->unprocessed_rcds.q = pqueue_new(); d1->processed_rcds.q = pqueue_new(); d1->buffered_messages = pqueue_new(); d1->sent_messages = pqueue_new(); d1->buffered_app_data.q = pqueue_new(); if (s->server) { d1->cookie_len = sizeof(s->d1->cookie); } if (!d1->unprocessed_rcds.q || !d1->processed_rcds.q || !d1->buffered_messages || !d1->sent_messages || !d1->buffered_app_data.q) { if (d1->unprocessed_rcds.q) pqueue_free(d1->unprocessed_rcds.q); if (d1->processed_rcds.q) pqueue_free(d1->processed_rcds.q); if (d1->buffered_messages) pqueue_free(d1->buffered_messages); if (d1->sent_messages) pqueue_free(d1->sent_messages); if (d1->buffered_app_data.q) pqueue_free(d1->buffered_app_data.q); free(d1); ssl3_free(s); return (0); } s->d1 = d1; s->method->ssl_clear(s); return (1); } static void dtls1_clear_queues(SSL *s) { pitem *item = NULL; hm_fragment *frag = NULL; DTLS1_RECORD_DATA *rdata; while ((item = pqueue_pop(s->d1->unprocessed_rcds.q)) != NULL) { rdata = (DTLS1_RECORD_DATA *) item->data; free(rdata->rbuf.buf); free(item->data); pitem_free(item); } while ((item = pqueue_pop(s->d1->processed_rcds.q)) != NULL) { rdata = (DTLS1_RECORD_DATA *) item->data; free(rdata->rbuf.buf); free(item->data); pitem_free(item); } while ((item = pqueue_pop(s->d1->buffered_messages)) != NULL) { frag = (hm_fragment *)item->data; free(frag->fragment); free(frag); pitem_free(item); } while ((item = pqueue_pop(s->d1->sent_messages)) != NULL) { frag = (hm_fragment *)item->data; free(frag->fragment); free(frag); pitem_free(item); } while ((item = pqueue_pop(s->d1->buffered_app_data.q)) != NULL) { rdata = (DTLS1_RECORD_DATA *) item->data; free(rdata->rbuf.buf); free(item->data); pitem_free(item); } } void dtls1_free(SSL *s) { ssl3_free(s); dtls1_clear_queues(s); pqueue_free(s->d1->unprocessed_rcds.q); pqueue_free(s->d1->processed_rcds.q); pqueue_free(s->d1->buffered_messages); pqueue_free(s->d1->sent_messages); pqueue_free(s->d1->buffered_app_data.q); OPENSSL_cleanse(s->d1, sizeof *s->d1); free(s->d1); s->d1 = NULL; } void dtls1_clear(SSL *s) { pqueue unprocessed_rcds; pqueue processed_rcds; pqueue buffered_messages; pqueue sent_messages; pqueue buffered_app_data; unsigned int mtu; if (s->d1) { unprocessed_rcds = s->d1->unprocessed_rcds.q; processed_rcds = s->d1->processed_rcds.q; buffered_messages = s->d1->buffered_messages; sent_messages = s->d1->sent_messages; buffered_app_data = s->d1->buffered_app_data.q; mtu = s->d1->mtu; dtls1_clear_queues(s); memset(s->d1, 0, sizeof(*(s->d1))); if (s->server) { s->d1->cookie_len = sizeof(s->d1->cookie); } if (SSL_get_options(s) & SSL_OP_NO_QUERY_MTU) { s->d1->mtu = mtu; } s->d1->unprocessed_rcds.q = unprocessed_rcds; s->d1->processed_rcds.q = processed_rcds; s->d1->buffered_messages = buffered_messages; s->d1->sent_messages = sent_messages; s->d1->buffered_app_data.q = buffered_app_data; } ssl3_clear(s); if (s->options & SSL_OP_CISCO_ANYCONNECT) s->version = DTLS1_BAD_VER; else s->version = DTLS1_VERSION; } long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg) { int ret = 0; switch (cmd) { case DTLS_CTRL_GET_TIMEOUT: if (dtls1_get_timeout(s, (struct timeval*) parg) != NULL) { ret = 1; } break; case DTLS_CTRL_HANDLE_TIMEOUT: ret = dtls1_handle_timeout(s); break; case DTLS_CTRL_LISTEN: ret = dtls1_listen(s, parg); break; default: ret = ssl3_ctrl(s, cmd, larg, parg); break; } return (ret); } /* * As it's impossible to use stream ciphers in "datagram" mode, this * simple filter is designed to disengage them in DTLS. Unfortunately * there is no universal way to identify stream SSL_CIPHER, so we have * to explicitly list their SSL_* codes. Currently RC4 is the only one * available, but if new ones emerge, they will have to be added... */ const SSL_CIPHER * dtls1_get_cipher(unsigned int u) { const SSL_CIPHER *ciph = ssl3_get_cipher(u); if (ciph != NULL) { if (ciph->algorithm_enc == SSL_RC4) return NULL; } return ciph; } void dtls1_start_timer(SSL *s) { #ifndef OPENSSL_NO_SCTP /* Disable timer for SCTP */ if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { memset(&(s->d1->next_timeout), 0, sizeof(struct timeval)); return; } #endif /* If timer is not set, initialize duration with 1 second */ if (s->d1->next_timeout.tv_sec == 0 && s->d1->next_timeout.tv_usec == 0) { s->d1->timeout_duration = 1; } /* Set timeout to current time */ gettimeofday(&(s->d1->next_timeout), NULL); /* Add duration to current time */ s->d1->next_timeout.tv_sec += s->d1->timeout_duration; BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0, &(s->d1->next_timeout)); } struct timeval* dtls1_get_timeout(SSL *s, struct timeval* timeleft) { struct timeval timenow; /* If no timeout is set, just return NULL */ if (s->d1->next_timeout.tv_sec == 0 && s->d1->next_timeout.tv_usec == 0) { return NULL; } /* Get current time */ gettimeofday(&timenow, NULL); /* If timer already expired, set remaining time to 0 */ if (s->d1->next_timeout.tv_sec < timenow.tv_sec || (s->d1->next_timeout.tv_sec == timenow.tv_sec && s->d1->next_timeout.tv_usec <= timenow.tv_usec)) { memset(timeleft, 0, sizeof(struct timeval)); return timeleft; } /* Calculate time left until timer expires */ memcpy(timeleft, &(s->d1->next_timeout), sizeof(struct timeval)); timeleft->tv_sec -= timenow.tv_sec; timeleft->tv_usec -= timenow.tv_usec; if (timeleft->tv_usec < 0) { timeleft->tv_sec--; timeleft->tv_usec += 1000000; } /* If remaining time is less than 15 ms, set it to 0 * to prevent issues because of small devergences with * socket timeouts. */ if (timeleft->tv_sec == 0 && timeleft->tv_usec < 15000) { memset(timeleft, 0, sizeof(struct timeval)); } return timeleft; } int dtls1_is_timer_expired(SSL *s) { struct timeval timeleft; /* Get time left until timeout, return false if no timer running */ if (dtls1_get_timeout(s, &timeleft) == NULL) { return 0; } /* Return false if timer is not expired yet */ if (timeleft.tv_sec > 0 || timeleft.tv_usec > 0) { return 0; } /* Timer expired, so return true */ return 1; } void dtls1_double_timeout(SSL *s) { s->d1->timeout_duration *= 2; if (s->d1->timeout_duration > 60) s->d1->timeout_duration = 60; dtls1_start_timer(s); } void dtls1_stop_timer(SSL *s) { /* Reset everything */ memset(&(s->d1->timeout), 0, sizeof(struct dtls1_timeout_st)); memset(&(s->d1->next_timeout), 0, sizeof(struct timeval)); s->d1->timeout_duration = 1; BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0, &(s->d1->next_timeout)); /* Clear retransmission buffer */ dtls1_clear_record_buffer(s); } int dtls1_check_timeout_num(SSL *s) { s->d1->timeout.num_alerts++; /* Reduce MTU after 2 unsuccessful retransmissions */ if (s->d1->timeout.num_alerts > 2) { s->d1->mtu = BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_GET_FALLBACK_MTU, 0, NULL); } if (s->d1->timeout.num_alerts > DTLS1_TMO_ALERT_COUNT) { /* fail the connection, enough alerts have been sent */ SSLerr(SSL_F_DTLS1_CHECK_TIMEOUT_NUM, SSL_R_READ_TIMEOUT_EXPIRED); return -1; } return 0; } int dtls1_handle_timeout(SSL *s) { /* if no timer is expired, don't do anything */ if (!dtls1_is_timer_expired(s)) { return 0; } dtls1_double_timeout(s); if (dtls1_check_timeout_num(s) < 0) return -1; s->d1->timeout.read_timeouts++; if (s->d1->timeout.read_timeouts > DTLS1_TMO_READ_COUNT) { s->d1->timeout.read_timeouts = 1; } dtls1_start_timer(s); return dtls1_retransmit_buffered_messages(s); } int dtls1_listen(SSL *s, struct sockaddr *client) { int ret; SSL_set_options(s, SSL_OP_COOKIE_EXCHANGE); s->d1->listen = 1; ret = SSL_accept(s); if (ret <= 0) return ret; (void)BIO_dgram_get_peer(SSL_get_rbio(s), client); return 1; } void dtls1_build_sequence_number(unsigned char *dst, unsigned char *seq, unsigned short epoch) { unsigned char dtlsseq[SSL3_SEQUENCE_SIZE]; unsigned char *p; p = dtlsseq; s2n(epoch, p); memcpy(p, &seq[2], SSL3_SEQUENCE_SIZE - 2); memcpy(dst, dtlsseq, SSL3_SEQUENCE_SIZE); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/s23_clnt.c0000644000175000017500000004075612360020705017343 0ustar /* $OpenBSD: s23_clnt.c,v 1.30 2014/07/10 08:51:14 tedu Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include "ssl_locl.h" #include #include #include #include static const SSL_METHOD *ssl23_get_client_method(int ver); static int ssl23_client_hello(SSL *s); static int ssl23_get_server_hello(SSL *s); const SSL_METHOD SSLv23_client_method_data = { .version = TLS1_2_VERSION, .ssl_new = tls1_new, .ssl_clear = tls1_clear, .ssl_free = tls1_free, .ssl_accept = ssl_undefined_function, .ssl_connect = ssl23_connect, .ssl_read = ssl23_read, .ssl_peek = ssl23_peek, .ssl_write = ssl23_write, .ssl_shutdown = ssl_undefined_function, .ssl_renegotiate = ssl_undefined_function, .ssl_renegotiate_check = ssl_ok, .ssl_get_message = ssl3_get_message, .ssl_read_bytes = ssl3_read_bytes, .ssl_write_bytes = ssl3_write_bytes, .ssl_dispatch_alert = ssl3_dispatch_alert, .ssl_ctrl = ssl3_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl23_put_cipher_by_char, .ssl_pending = ssl_undefined_const_function, .num_ciphers = ssl3_num_ciphers, .get_cipher = ssl3_get_cipher, .get_ssl_method = ssl23_get_client_method, .get_timeout = ssl23_default_timeout, .ssl3_enc = &ssl3_undef_enc_method, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD * SSLv23_client_method(void) { return &SSLv23_client_method_data; } static const SSL_METHOD * ssl23_get_client_method(int ver) { if (ver == SSL3_VERSION) return (SSLv3_client_method()); if (ver == TLS1_VERSION) return (TLSv1_client_method()); if (ver == TLS1_1_VERSION) return (TLSv1_1_client_method()); if (ver == TLS1_2_VERSION) return (TLSv1_2_client_method()); return (NULL); } int ssl23_connect(SSL *s) { BUF_MEM *buf = NULL; void (*cb)(const SSL *ssl, int type, int val) = NULL; int ret = -1; int new_state, state; ERR_clear_error(); errno = 0; if (s->info_callback != NULL) cb = s->info_callback; else if (s->ctx->info_callback != NULL) cb = s->ctx->info_callback; s->in_handshake++; if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); for (;;) { state = s->state; switch (s->state) { case SSL_ST_BEFORE: case SSL_ST_CONNECT: case SSL_ST_BEFORE|SSL_ST_CONNECT: case SSL_ST_OK|SSL_ST_CONNECT: if (s->session != NULL) { SSLerr(SSL_F_SSL23_CONNECT, SSL_R_SSL23_DOING_SESSION_ID_REUSE); ret = -1; goto end; } s->server = 0; if (cb != NULL) cb(s, SSL_CB_HANDSHAKE_START, 1); /* s->version=TLS1_VERSION; */ s->type = SSL_ST_CONNECT; if (s->init_buf == NULL) { if ((buf = BUF_MEM_new()) == NULL) { ret = -1; goto end; } if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { ret = -1; goto end; } s->init_buf = buf; buf = NULL; } if (!ssl3_setup_buffers(s)) { ret = -1; goto end; } ssl3_init_finished_mac(s); s->state = SSL23_ST_CW_CLNT_HELLO_A; s->ctx->stats.sess_connect++; s->init_num = 0; break; case SSL23_ST_CW_CLNT_HELLO_A: case SSL23_ST_CW_CLNT_HELLO_B: s->shutdown = 0; ret = ssl23_client_hello(s); if (ret <= 0) goto end; s->state = SSL23_ST_CR_SRVR_HELLO_A; s->init_num = 0; break; case SSL23_ST_CR_SRVR_HELLO_A: case SSL23_ST_CR_SRVR_HELLO_B: ret = ssl23_get_server_hello(s); if (ret >= 0) cb = NULL; goto end; /* break; */ default: SSLerr(SSL_F_SSL23_CONNECT, SSL_R_UNKNOWN_STATE); ret = -1; goto end; /* break; */ } if (s->debug) { (void)BIO_flush(s->wbio); } if ((cb != NULL) && (s->state != state)) { new_state = s->state; s->state = state; cb(s, SSL_CB_CONNECT_LOOP, 1); s->state = new_state; } } end: s->in_handshake--; if (buf != NULL) BUF_MEM_free(buf); if (cb != NULL) cb(s, SSL_CB_CONNECT_EXIT, ret); return (ret); } static int ssl23_client_hello(SSL *s) { unsigned char *buf; unsigned char *p, *d; int i; unsigned long l; int version = 0, version_major, version_minor; int ret; unsigned long mask, options = s->options; /* * SSL_OP_NO_X disables all protocols above X *if* there are * some protocols below X enabled. This is required in order * to maintain "version capability" vector contiguous. So * that if application wants to disable TLS1.0 in favour of * TLS1>=1, it would be insufficient to pass SSL_NO_TLSv1, the * answer is SSL_OP_NO_TLSv1|SSL_OP_NO_SSLv3|SSL_OP_NO_SSLv2. */ mask = SSL_OP_NO_TLSv1_1|SSL_OP_NO_TLSv1|SSL_OP_NO_SSLv3; version = TLS1_2_VERSION; if ((options & SSL_OP_NO_TLSv1_2) && (options & mask) != mask) version = TLS1_1_VERSION; mask &= ~SSL_OP_NO_TLSv1_1; if ((options & SSL_OP_NO_TLSv1_1) && (options & mask) != mask) version = TLS1_VERSION; mask &= ~SSL_OP_NO_TLSv1; if ((options & SSL_OP_NO_TLSv1) && (options & mask) != mask) version = SSL3_VERSION; mask &= ~SSL_OP_NO_SSLv3; buf = (unsigned char *)s->init_buf->data; if (s->state == SSL23_ST_CW_CLNT_HELLO_A) { p = s->s3->client_random; RAND_pseudo_bytes(p, SSL3_RANDOM_SIZE); if (version == TLS1_2_VERSION) { version_major = TLS1_2_VERSION_MAJOR; version_minor = TLS1_2_VERSION_MINOR; } else if (version == TLS1_1_VERSION) { version_major = TLS1_1_VERSION_MAJOR; version_minor = TLS1_1_VERSION_MINOR; } else if (version == TLS1_VERSION) { version_major = TLS1_VERSION_MAJOR; version_minor = TLS1_VERSION_MINOR; } else if (version == SSL3_VERSION) { version_major = SSL3_VERSION_MAJOR; version_minor = SSL3_VERSION_MINOR; } else { SSLerr(SSL_F_SSL23_CLIENT_HELLO, SSL_R_NO_PROTOCOLS_AVAILABLE); return (-1); } s->client_version = version; /* create Client Hello in SSL 3.0/TLS 1.0 format */ /* * Do the record header (5 bytes) and handshake * message header (4 bytes) last */ d = p = &(buf[9]); *(p++) = version_major; *(p++) = version_minor; /* Random stuff */ memcpy(p, s->s3->client_random, SSL3_RANDOM_SIZE); p += SSL3_RANDOM_SIZE; /* Session ID (zero since there is no reuse) */ *(p++) = 0; /* Ciphers supported (using SSL 3.0/TLS 1.0 format) */ i = ssl_cipher_list_to_bytes(s, SSL_get_ciphers(s), &(p[2]), ssl3_put_cipher_by_char); if (i == 0) { SSLerr(SSL_F_SSL23_CLIENT_HELLO, SSL_R_NO_CIPHERS_AVAILABLE); return -1; } #ifdef OPENSSL_MAX_TLS1_2_CIPHER_LENGTH /* * Some servers hang if client hello > 256 bytes * as hack workaround chop number of supported ciphers * to keep it well below this if we use TLS v1.2 */ if (TLS1_get_version(s) >= TLS1_2_VERSION && i > OPENSSL_MAX_TLS1_2_CIPHER_LENGTH) i = OPENSSL_MAX_TLS1_2_CIPHER_LENGTH & ~1; #endif s2n(i, p); p += i; /* add in (no) COMPRESSION */ *(p++) = 1; /* Add the NULL method */ *(p++) = 0; /* TLS extensions*/ if (ssl_prepare_clienthello_tlsext(s) <= 0) { SSLerr(SSL_F_SSL23_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); return -1; } if ((p = ssl_add_clienthello_tlsext(s, p, buf + SSL3_RT_MAX_PLAIN_LENGTH)) == NULL) { SSLerr(SSL_F_SSL23_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); return -1; } l = p - d; /* fill in 4-byte handshake header */ d = &(buf[5]); *(d++) = SSL3_MT_CLIENT_HELLO; l2n3(l, d); l += 4; if (l > SSL3_RT_MAX_PLAIN_LENGTH) { SSLerr(SSL_F_SSL23_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); return -1; } /* fill in 5-byte record header */ d = buf; *(d++) = SSL3_RT_HANDSHAKE; *(d++) = version_major; /* * Some servers hang if we use long client hellos * and a record number > TLS 1.0. */ if (TLS1_get_client_version(s) > TLS1_VERSION) *(d++) = 1; else *(d++) = version_minor; s2n((int)l, d); /* number of bytes to write */ s->init_num = p - buf; s->init_off = 0; ssl3_finish_mac(s, &(buf[5]), s->init_num - 5); s->state = SSL23_ST_CW_CLNT_HELLO_B; s->init_off = 0; } /* SSL3_ST_CW_CLNT_HELLO_B */ ret = ssl23_write_bytes(s); if ((ret >= 2) && s->msg_callback) { /* Client Hello has been sent; tell msg_callback */ s->msg_callback(1, version, SSL3_RT_HANDSHAKE, s->init_buf->data + 5, ret - 5, s, s->msg_callback_arg); } return ret; } static int ssl23_get_server_hello(SSL *s) { char buf[8]; unsigned char *p; int i; int n; n = ssl23_read_bytes(s, 7); if (n != 7) return (n); p = s->packet; memcpy(buf, p, n); /* Old unsupported sslv2 handshake */ if ((p[0] & 0x80) && (p[2] == SSL2_MT_SERVER_HELLO) && (p[5] == 0x00) && (p[6] == 0x02)) { SSLerr(SSL_F_SSL23_GET_SERVER_HELLO, SSL_R_UNSUPPORTED_PROTOCOL); goto err; } if (p[1] == SSL3_VERSION_MAJOR && p[2] <= TLS1_2_VERSION_MINOR && ((p[0] == SSL3_RT_HANDSHAKE && p[5] == SSL3_MT_SERVER_HELLO) || (p[0] == SSL3_RT_ALERT && p[3] == 0 && p[4] == 2))) { /* we have sslv3 or tls1 (server hello or alert) */ if ((p[2] == SSL3_VERSION_MINOR) && !(s->options & SSL_OP_NO_SSLv3)) { s->version = SSL3_VERSION; s->method = SSLv3_client_method(); } else if ((p[2] == TLS1_VERSION_MINOR) && !(s->options & SSL_OP_NO_TLSv1)) { s->version = TLS1_VERSION; s->method = TLSv1_client_method(); } else if ((p[2] == TLS1_1_VERSION_MINOR) && !(s->options & SSL_OP_NO_TLSv1_1)) { s->version = TLS1_1_VERSION; s->method = TLSv1_1_client_method(); } else if ((p[2] == TLS1_2_VERSION_MINOR) && !(s->options & SSL_OP_NO_TLSv1_2)) { s->version = TLS1_2_VERSION; s->method = TLSv1_2_client_method(); } else { SSLerr(SSL_F_SSL23_GET_SERVER_HELLO, SSL_R_UNSUPPORTED_PROTOCOL); goto err; } if (p[0] == SSL3_RT_ALERT && p[5] != SSL3_AL_WARNING) { /* fatal alert */ void (*cb)(const SSL *ssl, int type, int val) = NULL; int j; if (s->info_callback != NULL) cb = s->info_callback; else if (s->ctx->info_callback != NULL) cb = s->ctx->info_callback; i = p[5]; if (cb != NULL) { j = (i << 8) | p[6]; cb(s, SSL_CB_READ_ALERT, j); } if (s->msg_callback) s->msg_callback(0, s->version, SSL3_RT_ALERT, p + 5, 2, s, s->msg_callback_arg); s->rwstate = SSL_NOTHING; SSLerr(SSL_F_SSL23_GET_SERVER_HELLO, SSL_AD_REASON_OFFSET + p[6]); goto err; } if (!ssl_init_wbio_buffer(s, 1)) goto err; /* we are in this state */ s->state = SSL3_ST_CR_SRVR_HELLO_A; /* put the 7 bytes we have read into the input buffer * for SSLv3 */ s->rstate = SSL_ST_READ_HEADER; s->packet_length = n; if (s->s3->rbuf.buf == NULL) if (!ssl3_setup_read_buffer(s)) goto err; s->packet = &(s->s3->rbuf.buf[0]); memcpy(s->packet, buf, n); s->s3->rbuf.left = n; s->s3->rbuf.offset = 0; s->handshake_func = s->method->ssl_connect; } else { SSLerr(SSL_F_SSL23_GET_SERVER_HELLO, SSL_R_UNKNOWN_PROTOCOL); goto err; } s->init_num = 0; /* * Since, if we are sending a ssl23 client hello, we are not * reusing a session-id */ if (!ssl_get_new_session(s, 0)) goto err; return (SSL_connect(s)); err: return (-1); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/s3_both.c0000644000175000017500000004771012360020705017252 0ustar /* $OpenBSD: s3_both.c,v 1.25 2014/06/19 21:29:51 tedu Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * ECC cipher suite support in OpenSSL originally developed by * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. */ #include #include #include #include "ssl_locl.h" #include #include #include #include #include /* send s->init_buf in records of type 'type' (SSL3_RT_HANDSHAKE or SSL3_RT_CHANGE_CIPHER_SPEC) */ int ssl3_do_write(SSL *s, int type) { int ret; ret = ssl3_write_bytes(s, type, &s->init_buf->data[s->init_off], s->init_num); if (ret < 0) return (-1); if (type == SSL3_RT_HANDSHAKE) /* should not be done for 'Hello Request's, but in that case * we'll ignore the result anyway */ ssl3_finish_mac(s,(unsigned char *)&s->init_buf->data[s->init_off], ret); if (ret == s->init_num) { if (s->msg_callback) s->msg_callback(1, s->version, type, s->init_buf->data, (size_t)(s->init_off + s->init_num), s, s->msg_callback_arg); return (1); } s->init_off += ret; s->init_num -= ret; return (0); } int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen) { unsigned char *p, *d; int i; unsigned long l; if (s->state == a) { d = (unsigned char *)s->init_buf->data; p = &(d[4]); i = s->method->ssl3_enc->final_finish_mac(s, sender, slen, s->s3->tmp.finish_md); if (i == 0) return 0; s->s3->tmp.finish_md_len = i; memcpy(p, s->s3->tmp.finish_md, i); p += i; l = i; /* Copy the finished so we can use it for renegotiation checks */ if (s->type == SSL_ST_CONNECT) { OPENSSL_assert(i <= EVP_MAX_MD_SIZE); memcpy(s->s3->previous_client_finished, s->s3->tmp.finish_md, i); s->s3->previous_client_finished_len = i; } else { OPENSSL_assert(i <= EVP_MAX_MD_SIZE); memcpy(s->s3->previous_server_finished, s->s3->tmp.finish_md, i); s->s3->previous_server_finished_len = i; } *(d++) = SSL3_MT_FINISHED; l2n3(l, d); s->init_num = (int)l + 4; s->init_off = 0; s->state = b; } /* SSL3_ST_SEND_xxxxxx_HELLO_B */ return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); } #ifndef OPENSSL_NO_NEXTPROTONEG /* ssl3_take_mac calculates the Finished MAC for the handshakes messages seen to far. */ static void ssl3_take_mac(SSL *s) { const char *sender; int slen; /* If no new cipher setup return immediately: other functions will * set the appropriate error. */ if (s->s3->tmp.new_cipher == NULL) return; if (s->state & SSL_ST_CONNECT) { sender = s->method->ssl3_enc->server_finished_label; slen = s->method->ssl3_enc->server_finished_label_len; } else { sender = s->method->ssl3_enc->client_finished_label; slen = s->method->ssl3_enc->client_finished_label_len; } s->s3->tmp.peer_finish_md_len = s->method->ssl3_enc->final_finish_mac(s, sender, slen, s->s3->tmp.peer_finish_md); } #endif int ssl3_get_finished(SSL *s, int a, int b) { int al, i, ok; long n; unsigned char *p; #ifdef OPENSSL_NO_NEXTPROTONEG /* the mac has already been generated when we received the * change cipher spec message and is in s->s3->tmp.peer_finish_md. */ #endif n = s->method->ssl_get_message(s, a, b, SSL3_MT_FINISHED, 64, /* should actually be 36+4 :-) */ &ok); if (!ok) return ((int)n); /* If this occurs, we have missed a message */ if (!s->s3->change_cipher_spec) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_GET_FINISHED, SSL_R_GOT_A_FIN_BEFORE_A_CCS); goto f_err; } s->s3->change_cipher_spec = 0; p = (unsigned char *)s->init_msg; i = s->s3->tmp.peer_finish_md_len; if (i != n) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_FINISHED, SSL_R_BAD_DIGEST_LENGTH); goto f_err; } if (timingsafe_memcmp(p, s->s3->tmp.peer_finish_md, i) != 0) { al = SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_FINISHED, SSL_R_DIGEST_CHECK_FAILED); goto f_err; } /* Copy the finished so we can use it for renegotiation checks */ if (s->type == SSL_ST_ACCEPT) { OPENSSL_assert(i <= EVP_MAX_MD_SIZE); memcpy(s->s3->previous_client_finished, s->s3->tmp.peer_finish_md, i); s->s3->previous_client_finished_len = i; } else { OPENSSL_assert(i <= EVP_MAX_MD_SIZE); memcpy(s->s3->previous_server_finished, s->s3->tmp.peer_finish_md, i); s->s3->previous_server_finished_len = i; } return (1); f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); return (0); } /* for these 2 messages, we need to * ssl->enc_read_ctx re-init * ssl->s3->read_sequence zero * ssl->s3->read_mac_secret re-init * ssl->session->read_sym_enc assign * ssl->session->read_hash assign */ int ssl3_send_change_cipher_spec(SSL *s, int a, int b) { unsigned char *p; if (s->state == a) { p = (unsigned char *)s->init_buf->data; *p = SSL3_MT_CCS; s->init_num = 1; s->init_off = 0; s->state = b; } /* SSL3_ST_CW_CHANGE_B */ return (ssl3_do_write(s, SSL3_RT_CHANGE_CIPHER_SPEC)); } static int ssl3_add_cert_to_buf(BUF_MEM *buf, unsigned long *l, X509 *x) { int n; unsigned char *p; n = i2d_X509(x, NULL); if (!BUF_MEM_grow_clean(buf, n + (*l) + 3)) { SSLerr(SSL_F_SSL3_ADD_CERT_TO_BUF, ERR_R_BUF_LIB); return (-1); } p = (unsigned char *)&(buf->data[*l]); l2n3(n, p); i2d_X509(x, &p); *l += n + 3; return (0); } unsigned long ssl3_output_cert_chain(SSL *s, X509 *x) { unsigned char *p; int i; unsigned long l = 7; BUF_MEM *buf; int no_chain; if ((s->mode & SSL_MODE_NO_AUTO_CHAIN) || s->ctx->extra_certs) no_chain = 1; else no_chain = 0; /* TLSv1 sends a chain with nothing in it, instead of an alert */ buf = s->init_buf; if (!BUF_MEM_grow_clean(buf, 10)) { SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN, ERR_R_BUF_LIB); return (0); } if (x != NULL) { if (no_chain) { if (ssl3_add_cert_to_buf(buf, &l, x)) return (0); } else { X509_STORE_CTX xs_ctx; if (!X509_STORE_CTX_init(&xs_ctx, s->ctx->cert_store, x, NULL)) { SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN, ERR_R_X509_LIB); return (0); } X509_verify_cert(&xs_ctx); /* Don't leave errors in the queue */ ERR_clear_error(); for (i = 0; i < sk_X509_num(xs_ctx.chain); i++) { x = sk_X509_value(xs_ctx.chain, i); if (ssl3_add_cert_to_buf(buf, &l, x)) { X509_STORE_CTX_cleanup(&xs_ctx); return 0; } } X509_STORE_CTX_cleanup(&xs_ctx); } } /* Thawte special :-) */ for (i = 0; i < sk_X509_num(s->ctx->extra_certs); i++) { x = sk_X509_value(s->ctx->extra_certs, i); if (ssl3_add_cert_to_buf(buf, &l, x)) return (0); } l -= 7; p = (unsigned char *)&(buf->data[4]); l2n3(l, p); l += 3; p = (unsigned char *)&(buf->data[0]); *(p++) = SSL3_MT_CERTIFICATE; l2n3(l, p); l += 4; return (l); } /* Obtain handshake message of message type 'mt' (any if mt == -1), * maximum acceptable body length 'max'. * The first four bytes (msg_type and length) are read in state 'st1', * the body is read in state 'stn'. */ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok) { unsigned char *p; unsigned long l; long n; int i, al; if (s->s3->tmp.reuse_message) { s->s3->tmp.reuse_message = 0; if ((mt >= 0) && (s->s3->tmp.message_type != mt)) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_GET_MESSAGE, SSL_R_UNEXPECTED_MESSAGE); goto f_err; } *ok = 1; s->init_msg = s->init_buf->data + 4; s->init_num = (int)s->s3->tmp.message_size; return s->init_num; } p = (unsigned char *)s->init_buf->data; if (s->state == st1) /* s->init_num < 4 */ { int skip_message; do { while (s->init_num < 4) { i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, &p[s->init_num], 4 - s->init_num, 0); if (i <= 0) { s->rwstate = SSL_READING; *ok = 0; return i; } s->init_num += i; } skip_message = 0; if (!s->server && p[0] == SSL3_MT_HELLO_REQUEST) { /* * The server may always send 'Hello Request' * messages -- we are doing a handshake anyway * now, so ignore them if their format is * correct. Does not count for 'Finished' MAC. */ if (p[1] == 0 && p[2] == 0 &&p[3] == 0) { s->init_num = 0; skip_message = 1; if (s->msg_callback) s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, p, 4, s, s->msg_callback_arg); } } } while (skip_message); /* s->init_num == 4 */ if ((mt >= 0) && (*p != mt)) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_GET_MESSAGE, SSL_R_UNEXPECTED_MESSAGE); goto f_err; } if ((mt < 0) && (*p == SSL3_MT_CLIENT_HELLO) && (st1 == SSL3_ST_SR_CERT_A) && (stn == SSL3_ST_SR_CERT_B)) { /* At this point we have got an MS SGC second client * hello (maybe we should always allow the client to * start a new handshake?). We need to restart the mac. * Don't increment {num,total}_renegotiations because * we have not completed the handshake. */ ssl3_init_finished_mac(s); } s->s3->tmp.message_type= *(p++); n2l3(p, l); if (l > (unsigned long)max) { al = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_SSL3_GET_MESSAGE, SSL_R_EXCESSIVE_MESSAGE_SIZE); goto f_err; } if (l && !BUF_MEM_grow_clean(s->init_buf, l + 4)) { SSLerr(SSL_F_SSL3_GET_MESSAGE, ERR_R_BUF_LIB); goto err; } s->s3->tmp.message_size = l; s->state = stn; s->init_msg = s->init_buf->data + 4; s->init_num = 0; } /* next state (stn) */ p = s->init_msg; n = s->s3->tmp.message_size - s->init_num; while (n > 0) { i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, &p[s->init_num], n, 0); if (i <= 0) { s->rwstate = SSL_READING; *ok = 0; return i; } s->init_num += i; n -= i; } #ifndef OPENSSL_NO_NEXTPROTONEG /* If receiving Finished, record MAC of prior handshake messages for * Finished verification. */ if (*s->init_buf->data == SSL3_MT_FINISHED) ssl3_take_mac(s); #endif /* Feed this message into MAC computation. */ ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, s->init_num + 4); if (s->msg_callback) s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->init_buf->data, (size_t)s->init_num + 4, s, s->msg_callback_arg); *ok = 1; return s->init_num; f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: *ok = 0; return (-1); } int ssl_cert_type(X509 *x, EVP_PKEY *pkey) { EVP_PKEY *pk; int ret = -1, i; if (pkey == NULL) pk = X509_get_pubkey(x); else pk = pkey; if (pk == NULL) goto err; i = pk->type; if (i == EVP_PKEY_RSA) { ret = SSL_PKEY_RSA_ENC; } else if (i == EVP_PKEY_DSA) { ret = SSL_PKEY_DSA_SIGN; } else if (i == EVP_PKEY_EC) { ret = SSL_PKEY_ECC; } else if (i == NID_id_GostR3410_94 || i == NID_id_GostR3410_94_cc) { ret = SSL_PKEY_GOST94; } else if (i == NID_id_GostR3410_2001 || i == NID_id_GostR3410_2001_cc) { ret = SSL_PKEY_GOST01; } err: if (!pkey) EVP_PKEY_free(pk); return (ret); } int ssl_verify_alarm_type(long type) { int al; switch (type) { case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: case X509_V_ERR_UNABLE_TO_GET_CRL: case X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER: al = SSL_AD_UNKNOWN_CA; break; case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: case X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: case X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: case X509_V_ERR_CERT_NOT_YET_VALID: case X509_V_ERR_CRL_NOT_YET_VALID: case X509_V_ERR_CERT_UNTRUSTED: case X509_V_ERR_CERT_REJECTED: al = SSL_AD_BAD_CERTIFICATE; break; case X509_V_ERR_CERT_SIGNATURE_FAILURE: case X509_V_ERR_CRL_SIGNATURE_FAILURE: al = SSL_AD_DECRYPT_ERROR; break; case X509_V_ERR_CERT_HAS_EXPIRED: case X509_V_ERR_CRL_HAS_EXPIRED: al = SSL_AD_CERTIFICATE_EXPIRED; break; case X509_V_ERR_CERT_REVOKED: al = SSL_AD_CERTIFICATE_REVOKED; break; case X509_V_ERR_OUT_OF_MEM: al = SSL_AD_INTERNAL_ERROR; break; case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: case X509_V_ERR_CERT_CHAIN_TOO_LONG: case X509_V_ERR_PATH_LENGTH_EXCEEDED: case X509_V_ERR_INVALID_CA: al = SSL_AD_UNKNOWN_CA; break; case X509_V_ERR_APPLICATION_VERIFICATION: al = SSL_AD_HANDSHAKE_FAILURE; break; case X509_V_ERR_INVALID_PURPOSE: al = SSL_AD_UNSUPPORTED_CERTIFICATE; break; default: al = SSL_AD_CERTIFICATE_UNKNOWN; break; } return (al); } int ssl3_setup_read_buffer(SSL *s) { unsigned char *p; size_t len, align = 0, headerlen; if (SSL_IS_DTLS(s)) headerlen = DTLS1_RT_HEADER_LENGTH; else headerlen = SSL3_RT_HEADER_LENGTH; #if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0 align = (-SSL3_RT_HEADER_LENGTH)&(SSL3_ALIGN_PAYLOAD - 1); #endif if (s->s3->rbuf.buf == NULL) { len = SSL3_RT_MAX_PLAIN_LENGTH + SSL3_RT_MAX_ENCRYPTED_OVERHEAD + headerlen + align; if (s->options & SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER) { s->s3->init_extra = 1; len += SSL3_RT_MAX_EXTRA; } if ((p = malloc(len)) == NULL) goto err; s->s3->rbuf.buf = p; s->s3->rbuf.len = len; } s->packet = &(s->s3->rbuf.buf[0]); return 1; err: SSLerr(SSL_F_SSL3_SETUP_READ_BUFFER, ERR_R_MALLOC_FAILURE); return 0; } int ssl3_setup_write_buffer(SSL *s) { unsigned char *p; size_t len, align = 0, headerlen; if (SSL_IS_DTLS(s)) headerlen = DTLS1_RT_HEADER_LENGTH + 1; else headerlen = SSL3_RT_HEADER_LENGTH; #if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0 align = (-SSL3_RT_HEADER_LENGTH)&(SSL3_ALIGN_PAYLOAD - 1); #endif if (s->s3->wbuf.buf == NULL) { len = s->max_send_fragment + SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD + headerlen + align; if (!(s->options & SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)) len += headerlen + align + SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD; if ((p = malloc(len)) == NULL) goto err; s->s3->wbuf.buf = p; s->s3->wbuf.len = len; } return 1; err: SSLerr(SSL_F_SSL3_SETUP_WRITE_BUFFER, ERR_R_MALLOC_FAILURE); return 0; } int ssl3_setup_buffers(SSL *s) { if (!ssl3_setup_read_buffer(s)) return 0; if (!ssl3_setup_write_buffer(s)) return 0; return 1; } int ssl3_release_write_buffer(SSL *s) { free(s->s3->wbuf.buf); s->s3->wbuf.buf = NULL; return 1; } int ssl3_release_read_buffer(SSL *s) { free(s->s3->rbuf.buf); s->s3->rbuf.buf = NULL; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/s3_cbc.c0000644000175000017500000006272412360020705017047 0ustar /* $OpenBSD: s3_cbc.c,v 1.7 2014/06/12 15:49:31 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 2012 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "ssl_locl.h" #include #include /* MAX_HASH_BIT_COUNT_BYTES is the maximum number of bytes in the hash's length * field. (SHA-384/512 have 128-bit length.) */ #define MAX_HASH_BIT_COUNT_BYTES 16 /* MAX_HASH_BLOCK_SIZE is the maximum hash block size that we'll support. * Currently SHA-384/512 has a 128-byte block size and that's the largest * supported by TLS.) */ #define MAX_HASH_BLOCK_SIZE 128 /* Some utility functions are needed: * * These macros return the given value with the MSB copied to all the other * bits. They use the fact that arithmetic shift shifts-in the sign bit. * However, this is not ensured by the C standard so you may need to replace * them with something else on odd CPUs. */ #define DUPLICATE_MSB_TO_ALL(x) ((unsigned)((int)(x) >> (sizeof(int) * 8 - 1))) #define DUPLICATE_MSB_TO_ALL_8(x) ((unsigned char)(DUPLICATE_MSB_TO_ALL(x))) /* constant_time_lt returns 0xff if a=b and 0x00 otherwise. */ static unsigned constant_time_ge(unsigned a, unsigned b) { a -= b; return DUPLICATE_MSB_TO_ALL(~a); } /* constant_time_eq_8 returns 0xff if a==b and 0x00 otherwise. */ static unsigned char constant_time_eq_8(unsigned a, unsigned b) { unsigned c = a ^ b; c--; return DUPLICATE_MSB_TO_ALL_8(c); } /* ssl3_cbc_remove_padding removes padding from the decrypted, SSLv3, CBC * record in |rec| by updating |rec->length| in constant time. * * block_size: the block size of the cipher used to encrypt the record. * returns: * 0: (in non-constant time) if the record is publicly invalid. * 1: if the padding was valid * -1: otherwise. */ int ssl3_cbc_remove_padding(const SSL* s, SSL3_RECORD *rec, unsigned block_size, unsigned mac_size) { unsigned padding_length, good; const unsigned overhead = 1 /* padding length byte */ + mac_size; /* These lengths are all public so we can test them in non-constant * time. */ if (overhead > rec->length) return 0; padding_length = rec->data[rec->length - 1]; good = constant_time_ge(rec->length, padding_length + overhead); /* SSLv3 requires that the padding is minimal. */ good &= constant_time_ge(block_size, padding_length + 1); padding_length = good & (padding_length + 1); rec->length -= padding_length; rec->type |= padding_length << 8; /* kludge: pass padding length */ return (int)((good & 1) | (~good & -1)); } /* tls1_cbc_remove_padding removes the CBC padding from the decrypted, TLS, CBC * record in |rec| in constant time and returns 1 if the padding is valid and * -1 otherwise. It also removes any explicit IV from the start of the record * without leaking any timing about whether there was enough space after the * padding was removed. * * block_size: the block size of the cipher used to encrypt the record. * returns: * 0: (in non-constant time) if the record is publicly invalid. * 1: if the padding was valid * -1: otherwise. */ int tls1_cbc_remove_padding(const SSL* s, SSL3_RECORD *rec, unsigned block_size, unsigned mac_size) { unsigned padding_length, good, to_check, i; const unsigned overhead = 1 /* padding length byte */ + mac_size; /* Check if version requires explicit IV */ if (SSL_USE_EXPLICIT_IV(s)) { /* These lengths are all public so we can test them in * non-constant time. */ if (overhead + block_size > rec->length) return 0; /* We can now safely skip explicit IV */ rec->data += block_size; rec->input += block_size; rec->length -= block_size; } else if (overhead > rec->length) return 0; padding_length = rec->data[rec->length - 1]; /* NB: if compression is in operation the first packet may not be of * even length so the padding bug check cannot be performed. This bug * workaround has been around since SSLeay so hopefully it is either * fixed now or no buggy implementation supports compression [steve] * (We don't support compression either, so it's not in operation.) */ if ((s->options & SSL_OP_TLS_BLOCK_PADDING_BUG)) { /* First packet is even in size, so check */ if ((memcmp(s->s3->read_sequence, "\0\0\0\0\0\0\0\0", SSL3_SEQUENCE_SIZE) == 0) && !(padding_length & 1)) { s->s3->flags|=TLS1_FLAGS_TLS_PADDING_BUG; } if ((s->s3->flags & TLS1_FLAGS_TLS_PADDING_BUG) && padding_length > 0) { padding_length--; } } if (EVP_CIPHER_flags(s->enc_read_ctx->cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) { /* padding is already verified */ rec->length -= padding_length + 1; return 1; } good = constant_time_ge(rec->length, overhead + padding_length); /* The padding consists of a length byte at the end of the record and * then that many bytes of padding, all with the same value as the * length byte. Thus, with the length byte included, there are i+1 * bytes of padding. * * We can't check just |padding_length+1| bytes because that leaks * decrypted information. Therefore we always have to check the maximum * amount of padding possible. (Again, the length of the record is * public information so we can use it.) */ to_check = 255; /* maximum amount of padding. */ if (to_check > rec->length - 1) to_check = rec->length - 1; for (i = 0; i < to_check; i++) { unsigned char mask = constant_time_ge(padding_length, i); unsigned char b = rec->data[rec->length - 1 - i]; /* The final |padding_length+1| bytes should all have the value * |padding_length|. Therefore the XOR should be zero. */ good &= ~(mask&(padding_length ^ b)); } /* If any of the final |padding_length+1| bytes had the wrong value, * one or more of the lower eight bits of |good| will be cleared. We * AND the bottom 8 bits together and duplicate the result to all the * bits. */ good &= good >> 4; good &= good >> 2; good &= good >> 1; good <<= sizeof(good)*8 - 1; good = DUPLICATE_MSB_TO_ALL(good); padding_length = good & (padding_length + 1); rec->length -= padding_length; rec->type |= padding_length<<8; /* kludge: pass padding length */ return (int)((good & 1) | (~good & -1)); } /* ssl3_cbc_copy_mac copies |md_size| bytes from the end of |rec| to |out| in * constant time (independent of the concrete value of rec->length, which may * vary within a 256-byte window). * * ssl3_cbc_remove_padding or tls1_cbc_remove_padding must be called prior to * this function. * * On entry: * rec->orig_len >= md_size * md_size <= EVP_MAX_MD_SIZE * * If CBC_MAC_ROTATE_IN_PLACE is defined then the rotation is performed with * variable accesses in a 64-byte-aligned buffer. Assuming that this fits into * a single or pair of cache-lines, then the variable memory accesses don't * actually affect the timing. CPUs with smaller cache-lines [if any] are * not multi-core and are not considered vulnerable to cache-timing attacks. */ #define CBC_MAC_ROTATE_IN_PLACE void ssl3_cbc_copy_mac(unsigned char* out, const SSL3_RECORD *rec, unsigned md_size, unsigned orig_len) { #if defined(CBC_MAC_ROTATE_IN_PLACE) unsigned char rotated_mac_buf[64 + EVP_MAX_MD_SIZE]; unsigned char *rotated_mac; #else unsigned char rotated_mac[EVP_MAX_MD_SIZE]; #endif /* mac_end is the index of |rec->data| just after the end of the MAC. */ unsigned mac_end = rec->length; unsigned mac_start = mac_end - md_size; /* scan_start contains the number of bytes that we can ignore because * the MAC's position can only vary by 255 bytes. */ unsigned scan_start = 0; unsigned i, j; unsigned div_spoiler; unsigned rotate_offset; OPENSSL_assert(orig_len >= md_size); OPENSSL_assert(md_size <= EVP_MAX_MD_SIZE); #if defined(CBC_MAC_ROTATE_IN_PLACE) rotated_mac = rotated_mac_buf + ((0 - (size_t)rotated_mac_buf)&63); #endif /* This information is public so it's safe to branch based on it. */ if (orig_len > md_size + 255 + 1) scan_start = orig_len - (md_size + 255 + 1); /* div_spoiler contains a multiple of md_size that is used to cause the * modulo operation to be constant time. Without this, the time varies * based on the amount of padding when running on Intel chips at least. * * The aim of right-shifting md_size is so that the compiler doesn't * figure out that it can remove div_spoiler as that would require it * to prove that md_size is always even, which I hope is beyond it. */ div_spoiler = md_size >> 1; div_spoiler <<= (sizeof(div_spoiler) - 1) * 8; rotate_offset = (div_spoiler + mac_start - scan_start) % md_size; memset(rotated_mac, 0, md_size); for (i = scan_start, j = 0; i < orig_len; i++) { unsigned char mac_started = constant_time_ge(i, mac_start); unsigned char mac_ended = constant_time_ge(i, mac_end); unsigned char b = rec->data[i]; rotated_mac[j++] |= b & mac_started & ~mac_ended; j &= constant_time_lt(j, md_size); } /* Now rotate the MAC */ #if defined(CBC_MAC_ROTATE_IN_PLACE) j = 0; for (i = 0; i < md_size; i++) { /* in case cache-line is 32 bytes, touch second line */ ((volatile unsigned char *)rotated_mac)[rotate_offset^32]; out[j++] = rotated_mac[rotate_offset++]; rotate_offset &= constant_time_lt(rotate_offset, md_size); } #else memset(out, 0, md_size); rotate_offset = md_size - rotate_offset; rotate_offset &= constant_time_lt(rotate_offset, md_size); for (i = 0; i < md_size; i++) { for (j = 0; j < md_size; j++) out[j] |= rotated_mac[i] & constant_time_eq_8(j, rotate_offset); rotate_offset++; rotate_offset &= constant_time_lt(rotate_offset, md_size); } #endif } /* u32toLE serialises an unsigned, 32-bit number (n) as four bytes at (p) in * little-endian order. The value of p is advanced by four. */ #define u32toLE(n, p) \ (*((p)++)=(unsigned char)(n), \ *((p)++)=(unsigned char)(n>>8), \ *((p)++)=(unsigned char)(n>>16), \ *((p)++)=(unsigned char)(n>>24)) /* These functions serialize the state of a hash and thus perform the standard * "final" operation without adding the padding and length that such a function * typically does. */ static void tls1_md5_final_raw(void* ctx, unsigned char *md_out) { MD5_CTX *md5 = ctx; u32toLE(md5->A, md_out); u32toLE(md5->B, md_out); u32toLE(md5->C, md_out); u32toLE(md5->D, md_out); } static void tls1_sha1_final_raw(void* ctx, unsigned char *md_out) { SHA_CTX *sha1 = ctx; l2n(sha1->h0, md_out); l2n(sha1->h1, md_out); l2n(sha1->h2, md_out); l2n(sha1->h3, md_out); l2n(sha1->h4, md_out); } #define LARGEST_DIGEST_CTX SHA_CTX static void tls1_sha256_final_raw(void* ctx, unsigned char *md_out) { SHA256_CTX *sha256 = ctx; unsigned i; for (i = 0; i < 8; i++) { l2n(sha256->h[i], md_out); } } #undef LARGEST_DIGEST_CTX #define LARGEST_DIGEST_CTX SHA256_CTX static void tls1_sha512_final_raw(void* ctx, unsigned char *md_out) { SHA512_CTX *sha512 = ctx; unsigned i; for (i = 0; i < 8; i++) { l2n8(sha512->h[i], md_out); } } #undef LARGEST_DIGEST_CTX #define LARGEST_DIGEST_CTX SHA512_CTX /* ssl3_cbc_record_digest_supported returns 1 iff |ctx| uses a hash function * which ssl3_cbc_digest_record supports. */ char ssl3_cbc_record_digest_supported(const EVP_MD_CTX *ctx) { switch (EVP_MD_CTX_type(ctx)) { case NID_md5: case NID_sha1: case NID_sha224: case NID_sha256: case NID_sha384: case NID_sha512: return 1; default: return 0; } } /* ssl3_cbc_digest_record computes the MAC of a decrypted, padded SSLv3/TLS * record. * * ctx: the EVP_MD_CTX from which we take the hash function. * ssl3_cbc_record_digest_supported must return true for this EVP_MD_CTX. * md_out: the digest output. At most EVP_MAX_MD_SIZE bytes will be written. * md_out_size: if non-NULL, the number of output bytes is written here. * header: the 13-byte, TLS record header. * data: the record data itself, less any preceeding explicit IV. * data_plus_mac_size: the secret, reported length of the data and MAC * once the padding has been removed. * data_plus_mac_plus_padding_size: the public length of the whole * record, including padding. * is_sslv3: non-zero if we are to use SSLv3. Otherwise, TLS. * * On entry: by virtue of having been through one of the remove_padding * functions, above, we know that data_plus_mac_size is large enough to contain * a padding byte and MAC. (If the padding was invalid, it might contain the * padding too. ) */ void ssl3_cbc_digest_record(const EVP_MD_CTX *ctx, unsigned char* md_out, size_t* md_out_size, const unsigned char header[13], const unsigned char *data, size_t data_plus_mac_size, size_t data_plus_mac_plus_padding_size, const unsigned char *mac_secret, unsigned mac_secret_length, char is_sslv3) { union { double align; unsigned char c[sizeof(LARGEST_DIGEST_CTX)]; } md_state; void (*md_final_raw)(void *ctx, unsigned char *md_out); void (*md_transform)(void *ctx, const unsigned char *block); unsigned md_size, md_block_size = 64; unsigned sslv3_pad_length = 40, header_length, variance_blocks, len, max_mac_bytes, num_blocks, num_starting_blocks, k, mac_end_offset, c, index_a, index_b; unsigned int bits; /* at most 18 bits */ unsigned char length_bytes[MAX_HASH_BIT_COUNT_BYTES]; /* hmac_pad is the masked HMAC key. */ unsigned char hmac_pad[MAX_HASH_BLOCK_SIZE]; unsigned char first_block[MAX_HASH_BLOCK_SIZE]; unsigned char mac_out[EVP_MAX_MD_SIZE]; unsigned i, j, md_out_size_u; EVP_MD_CTX md_ctx; /* mdLengthSize is the number of bytes in the length field that terminates * the hash. */ unsigned md_length_size = 8; char length_is_big_endian = 1; /* This is a, hopefully redundant, check that allows us to forget about * many possible overflows later in this function. */ OPENSSL_assert(data_plus_mac_plus_padding_size < 1024*1024); switch (EVP_MD_CTX_type(ctx)) { case NID_md5: MD5_Init((MD5_CTX*)md_state.c); md_final_raw = tls1_md5_final_raw; md_transform = (void(*)(void *ctx, const unsigned char *block)) MD5_Transform; md_size = 16; sslv3_pad_length = 48; length_is_big_endian = 0; break; case NID_sha1: SHA1_Init((SHA_CTX*)md_state.c); md_final_raw = tls1_sha1_final_raw; md_transform = (void(*)(void *ctx, const unsigned char *block)) SHA1_Transform; md_size = 20; break; case NID_sha224: SHA224_Init((SHA256_CTX*)md_state.c); md_final_raw = tls1_sha256_final_raw; md_transform = (void(*)(void *ctx, const unsigned char *block)) SHA256_Transform; md_size = 224/8; break; case NID_sha256: SHA256_Init((SHA256_CTX*)md_state.c); md_final_raw = tls1_sha256_final_raw; md_transform = (void(*)(void *ctx, const unsigned char *block)) SHA256_Transform; md_size = 32; break; case NID_sha384: SHA384_Init((SHA512_CTX*)md_state.c); md_final_raw = tls1_sha512_final_raw; md_transform = (void(*)(void *ctx, const unsigned char *block)) SHA512_Transform; md_size = 384/8; md_block_size = 128; md_length_size = 16; break; case NID_sha512: SHA512_Init((SHA512_CTX*)md_state.c); md_final_raw = tls1_sha512_final_raw; md_transform = (void(*)(void *ctx, const unsigned char *block)) SHA512_Transform; md_size = 64; md_block_size = 128; md_length_size = 16; break; default: /* ssl3_cbc_record_digest_supported should have been * called first to check that the hash function is * supported. */ OPENSSL_assert(0); if (md_out_size) *md_out_size = -1; return; } OPENSSL_assert(md_length_size <= MAX_HASH_BIT_COUNT_BYTES); OPENSSL_assert(md_block_size <= MAX_HASH_BLOCK_SIZE); OPENSSL_assert(md_size <= EVP_MAX_MD_SIZE); header_length = 13; if (is_sslv3) { header_length = mac_secret_length + sslv3_pad_length + 8 /* sequence number */ + 1 /* record type */ + 2 /* record length */; } /* variance_blocks is the number of blocks of the hash that we have to * calculate in constant time because they could be altered by the * padding value. * * In SSLv3, the padding must be minimal so the end of the plaintext * varies by, at most, 15+20 = 35 bytes. (We conservatively assume that * the MAC size varies from 0..20 bytes.) In case the 9 bytes of hash * termination (0x80 + 64-bit length) don't fit in the final block, we * say that the final two blocks can vary based on the padding. * * TLSv1 has MACs up to 48 bytes long (SHA-384) and the padding is not * required to be minimal. Therefore we say that the final six blocks * can vary based on the padding. * * Later in the function, if the message is short and there obviously * cannot be this many blocks then variance_blocks can be reduced. */ variance_blocks = is_sslv3 ? 2 : 6; /* From now on we're dealing with the MAC, which conceptually has 13 * bytes of `header' before the start of the data (TLS) or 71/75 bytes * (SSLv3) */ len = data_plus_mac_plus_padding_size + header_length; /* max_mac_bytes contains the maximum bytes of bytes in the MAC, including * |header|, assuming that there's no padding. */ max_mac_bytes = len - md_size - 1; /* num_blocks is the maximum number of hash blocks. */ num_blocks = (max_mac_bytes + 1 + md_length_size + md_block_size - 1) / md_block_size; /* In order to calculate the MAC in constant time we have to handle * the final blocks specially because the padding value could cause the * end to appear somewhere in the final |variance_blocks| blocks and we * can't leak where. However, |num_starting_blocks| worth of data can * be hashed right away because no padding value can affect whether * they are plaintext. */ num_starting_blocks = 0; /* k is the starting byte offset into the conceptual header||data where * we start processing. */ k = 0; /* mac_end_offset is the index just past the end of the data to be * MACed. */ mac_end_offset = data_plus_mac_size + header_length - md_size; /* c is the index of the 0x80 byte in the final hash block that * contains application data. */ c = mac_end_offset % md_block_size; /* index_a is the hash block number that contains the 0x80 terminating * value. */ index_a = mac_end_offset / md_block_size; /* index_b is the hash block number that contains the 64-bit hash * length, in bits. */ index_b = (mac_end_offset + md_length_size) / md_block_size; /* bits is the hash-length in bits. It includes the additional hash * block for the masked HMAC key, or whole of |header| in the case of * SSLv3. */ /* For SSLv3, if we're going to have any starting blocks then we need * at least two because the header is larger than a single block. */ if (num_blocks > variance_blocks + (is_sslv3 ? 1 : 0)) { num_starting_blocks = num_blocks - variance_blocks; k = md_block_size*num_starting_blocks; } bits = 8*mac_end_offset; if (!is_sslv3) { /* Compute the initial HMAC block. For SSLv3, the padding and * secret bytes are included in |header| because they take more * than a single block. */ bits += 8*md_block_size; memset(hmac_pad, 0, md_block_size); OPENSSL_assert(mac_secret_length <= sizeof(hmac_pad)); memcpy(hmac_pad, mac_secret, mac_secret_length); for (i = 0; i < md_block_size; i++) hmac_pad[i] ^= 0x36; md_transform(md_state.c, hmac_pad); } if (length_is_big_endian) { memset(length_bytes, 0, md_length_size - 4); length_bytes[md_length_size - 4] = (unsigned char)(bits >> 24); length_bytes[md_length_size - 3] = (unsigned char)(bits >> 16); length_bytes[md_length_size - 2] = (unsigned char)(bits >> 8); length_bytes[md_length_size - 1] = (unsigned char)bits; } else { memset(length_bytes, 0, md_length_size); length_bytes[md_length_size - 5] = (unsigned char)(bits >> 24); length_bytes[md_length_size - 6] = (unsigned char)(bits >> 16); length_bytes[md_length_size - 7] = (unsigned char)(bits >> 8); length_bytes[md_length_size - 8] = (unsigned char)bits; } if (k > 0) { if (is_sslv3) { /* The SSLv3 header is larger than a single block. * overhang is the number of bytes beyond a single * block that the header consumes: either 7 bytes * (SHA1) or 11 bytes (MD5). */ unsigned overhang = header_length - md_block_size; md_transform(md_state.c, header); memcpy(first_block, header + md_block_size, overhang); memcpy(first_block + overhang, data, md_block_size - overhang); md_transform(md_state.c, first_block); for (i = 1; i < k/md_block_size - 1; i++) md_transform(md_state.c, data + md_block_size*i - overhang); } else { /* k is a multiple of md_block_size. */ memcpy(first_block, header, 13); memcpy(first_block + 13, data, md_block_size - 13); md_transform(md_state.c, first_block); for (i = 1; i < k/md_block_size; i++) md_transform(md_state.c, data + md_block_size*i - 13); } } memset(mac_out, 0, sizeof(mac_out)); /* We now process the final hash blocks. For each block, we construct * it in constant time. If the |i==index_a| then we'll include the 0x80 * bytes and zero pad etc. For each block we selectively copy it, in * constant time, to |mac_out|. */ for (i = num_starting_blocks; i <= num_starting_blocks + variance_blocks; i++) { unsigned char block[MAX_HASH_BLOCK_SIZE]; unsigned char is_block_a = constant_time_eq_8(i, index_a); unsigned char is_block_b = constant_time_eq_8(i, index_b); for (j = 0; j < md_block_size; j++) { unsigned char b = 0, is_past_c, is_past_cp1; if (k < header_length) b = header[k]; else if (k < data_plus_mac_plus_padding_size + header_length) b = data[k - header_length]; k++; is_past_c = is_block_a & constant_time_ge(j, c); is_past_cp1 = is_block_a & constant_time_ge(j, c + 1); /* If this is the block containing the end of the * application data, and we are at the offset for the * 0x80 value, then overwrite b with 0x80. */ b = (b&~is_past_c) | (0x80&is_past_c); /* If this the the block containing the end of the * application data and we're past the 0x80 value then * just write zero. */ b = b&~is_past_cp1; /* If this is index_b (the final block), but not * index_a (the end of the data), then the 64-bit * length didn't fit into index_a and we're having to * add an extra block of zeros. */ b &= ~is_block_b | is_block_a; /* The final bytes of one of the blocks contains the * length. */ if (j >= md_block_size - md_length_size) { /* If this is index_b, write a length byte. */ b = (b&~is_block_b) | (is_block_b&length_bytes[j - (md_block_size - md_length_size)]); } block[j] = b; } md_transform(md_state.c, block); md_final_raw(md_state.c, block); /* If this is index_b, copy the hash value to |mac_out|. */ for (j = 0; j < md_size; j++) mac_out[j] |= block[j]&is_block_b; } EVP_MD_CTX_init(&md_ctx); EVP_DigestInit_ex(&md_ctx, ctx->digest, NULL /* engine */); if (is_sslv3) { /* We repurpose |hmac_pad| to contain the SSLv3 pad2 block. */ memset(hmac_pad, 0x5c, sslv3_pad_length); EVP_DigestUpdate(&md_ctx, mac_secret, mac_secret_length); EVP_DigestUpdate(&md_ctx, hmac_pad, sslv3_pad_length); EVP_DigestUpdate(&md_ctx, mac_out, md_size); } else { /* Complete the HMAC in the standard manner. */ for (i = 0; i < md_block_size; i++) hmac_pad[i] ^= 0x6a; EVP_DigestUpdate(&md_ctx, hmac_pad, md_block_size); EVP_DigestUpdate(&md_ctx, mac_out, md_size); } EVP_DigestFinal(&md_ctx, md_out, &md_out_size_u); if (md_out_size) *md_out_size = md_out_size_u; EVP_MD_CTX_cleanup(&md_ctx); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/t1_clnt.c0000644000175000017500000001571712360020705017257 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "ssl_locl.h" #include #include #include #include static const SSL_METHOD *tls1_get_client_method(int ver); const SSL_METHOD TLSv1_client_method_data = { .version = TLS1_VERSION, .ssl_new = tls1_new, .ssl_clear = tls1_clear, .ssl_free = tls1_free, .ssl_accept = ssl_undefined_function, .ssl_connect = ssl3_connect, .ssl_read = ssl3_read, .ssl_peek = ssl3_peek, .ssl_write = ssl3_write, .ssl_shutdown = ssl3_shutdown, .ssl_renegotiate = ssl3_renegotiate, .ssl_renegotiate_check = ssl3_renegotiate_check, .ssl_get_message = ssl3_get_message, .ssl_read_bytes = ssl3_read_bytes, .ssl_write_bytes = ssl3_write_bytes, .ssl_dispatch_alert = ssl3_dispatch_alert, .ssl_ctrl = ssl3_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl3_put_cipher_by_char, .ssl_pending = ssl3_pending, .num_ciphers = ssl3_num_ciphers, .get_cipher = ssl3_get_cipher, .get_ssl_method = tls1_get_client_method, .get_timeout = tls1_default_timeout, .ssl3_enc = &TLSv1_enc_data, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD TLSv1_1_client_method_data = { .version = TLS1_1_VERSION, .ssl_new = tls1_new, .ssl_clear = tls1_clear, .ssl_free = tls1_free, .ssl_accept = ssl_undefined_function, .ssl_connect = ssl3_connect, .ssl_read = ssl3_read, .ssl_peek = ssl3_peek, .ssl_write = ssl3_write, .ssl_shutdown = ssl3_shutdown, .ssl_renegotiate = ssl3_renegotiate, .ssl_renegotiate_check = ssl3_renegotiate_check, .ssl_get_message = ssl3_get_message, .ssl_read_bytes = ssl3_read_bytes, .ssl_write_bytes = ssl3_write_bytes, .ssl_dispatch_alert = ssl3_dispatch_alert, .ssl_ctrl = ssl3_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl3_put_cipher_by_char, .ssl_pending = ssl3_pending, .num_ciphers = ssl3_num_ciphers, .get_cipher = ssl3_get_cipher, .get_ssl_method = tls1_get_client_method, .get_timeout = tls1_default_timeout, .ssl3_enc = &TLSv1_1_enc_data, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD TLSv1_2_client_method_data = { .version = TLS1_2_VERSION, .ssl_new = tls1_new, .ssl_clear = tls1_clear, .ssl_free = tls1_free, .ssl_accept = ssl_undefined_function, .ssl_connect = ssl3_connect, .ssl_read = ssl3_read, .ssl_peek = ssl3_peek, .ssl_write = ssl3_write, .ssl_shutdown = ssl3_shutdown, .ssl_renegotiate = ssl3_renegotiate, .ssl_renegotiate_check = ssl3_renegotiate_check, .ssl_get_message = ssl3_get_message, .ssl_read_bytes = ssl3_read_bytes, .ssl_write_bytes = ssl3_write_bytes, .ssl_dispatch_alert = ssl3_dispatch_alert, .ssl_ctrl = ssl3_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl3_put_cipher_by_char, .ssl_pending = ssl3_pending, .num_ciphers = ssl3_num_ciphers, .get_cipher = ssl3_get_cipher, .get_ssl_method = tls1_get_client_method, .get_timeout = tls1_default_timeout, .ssl3_enc = &TLSv1_2_enc_data, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD * TLSv1_client_method(void) { return &TLSv1_client_method_data; } const SSL_METHOD * TLSv1_1_client_method(void) { return &TLSv1_1_client_method_data; } const SSL_METHOD * TLSv1_2_client_method(void) { return &TLSv1_2_client_method_data; } static const SSL_METHOD * tls1_get_client_method(int ver) { if (ver == TLS1_2_VERSION) return (TLSv1_2_client_method()); if (ver == TLS1_1_VERSION) return (TLSv1_1_client_method()); if (ver == TLS1_VERSION) return (TLSv1_client_method()); return (NULL); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/d1_enc.c0000644000175000017500000002026312360020705017034 0ustar /* $OpenBSD: d1_enc.c,v 1.5 2014/06/12 15:49:31 deraadt Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. */ /* ==================================================================== * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "ssl_locl.h" #include #include #include #include /* dtls1_enc encrypts/decrypts the record in |s->wrec| / |s->rrec|, respectively. * * Returns: * 0: (in non-constant time) if the record is publically invalid (i.e. too * short etc). * 1: if the record's padding is valid / the encryption was successful. * -1: if the record's padding/AEAD-authenticator is invalid or, if sending, * an internal error occured. */ int dtls1_enc(SSL *s, int send) { SSL3_RECORD *rec; EVP_CIPHER_CTX *ds; unsigned long l; int bs, i, j, k, mac_size = 0; const EVP_CIPHER *enc; if (send) { if (EVP_MD_CTX_md(s->write_hash)) { mac_size = EVP_MD_CTX_size(s->write_hash); if (mac_size < 0) return -1; } ds = s->enc_write_ctx; rec = &(s->s3->wrec); if (s->enc_write_ctx == NULL) enc = NULL; else { enc = EVP_CIPHER_CTX_cipher(s->enc_write_ctx); if (rec->data != rec->input) /* we can't write into the input stream */ fprintf(stderr, "%s:%d: rec->data != rec->input\n", __FILE__, __LINE__); else if (EVP_CIPHER_block_size(ds->cipher) > 1) { if (RAND_bytes(rec->input, EVP_CIPHER_block_size(ds->cipher)) <= 0) return -1; } } } else { if (EVP_MD_CTX_md(s->read_hash)) { mac_size = EVP_MD_CTX_size(s->read_hash); OPENSSL_assert(mac_size >= 0); } ds = s->enc_read_ctx; rec = &(s->s3->rrec); if (s->enc_read_ctx == NULL) enc = NULL; else enc = EVP_CIPHER_CTX_cipher(s->enc_read_ctx); } if ((s->session == NULL) || (ds == NULL) || (enc == NULL)) { memmove(rec->data, rec->input, rec->length); rec->input = rec->data; } else { l = rec->length; bs = EVP_CIPHER_block_size(ds->cipher); if ((bs != 1) && send) { i = bs - ((int)l % bs); /* Add weird padding of upto 256 bytes */ /* we need to add 'i' padding bytes of value j */ j = i - 1; if (s->options & SSL_OP_TLS_BLOCK_PADDING_BUG) { if (s->s3->flags & TLS1_FLAGS_TLS_PADDING_BUG) j++; } for (k = (int)l; k < (int)(l + i); k++) rec->input[k] = j; l += i; rec->length += i; } if (!send) { if (l == 0 || l % bs != 0) return 0; } EVP_Cipher(ds, rec->data, rec->input, l); if ((bs != 1) && !send) return tls1_cbc_remove_padding(s, rec, bs, mac_size); } return (1); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/s3_enc.c0000644000175000017500000006134312360020705017061 0ustar /* $OpenBSD: s3_enc.c,v 1.51 2014/07/09 11:25:42 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2005 Nokia. All rights reserved. * * The portions of the attached software ("Contribution") is developed by * Nokia Corporation and is licensed pursuant to the OpenSSL open source * license. * * The Contribution, originally written by Mika Kousa and Pasi Eronen of * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites * support (see RFC 4279) to OpenSSL. * * No patent licenses or other rights except those expressly stated in * the OpenSSL open source license shall be deemed granted or received * expressly, by implication, estoppel, or otherwise. * * No assurances are provided by Nokia that the Contribution does not * infringe the patent or other intellectual property rights of any third * party or that the license provides you with all the necessary rights * to make use of the Contribution. * * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR * OTHERWISE. */ #include #include "ssl_locl.h" #include #include static unsigned char ssl3_pad_1[48] = { 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 }; static unsigned char ssl3_pad_2[48] = { 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c }; static int ssl3_handshake_mac(SSL *s, int md_nid, const char *sender, int len, unsigned char *p); static int ssl3_generate_key_block(SSL *s, unsigned char *km, int num) { EVP_MD_CTX m5; EVP_MD_CTX s1; unsigned char buf[16], smd[SHA_DIGEST_LENGTH]; unsigned char c = 'A'; unsigned int i, j, k; k = 0; EVP_MD_CTX_init(&m5); EVP_MD_CTX_init(&s1); for (i = 0; (int)i < num; i += MD5_DIGEST_LENGTH) { k++; if (k > sizeof buf) { /* bug: 'buf' is too small for this ciphersuite */ SSLerr(SSL_F_SSL3_GENERATE_KEY_BLOCK, ERR_R_INTERNAL_ERROR); return 0; } for (j = 0; j < k; j++) buf[j] = c; c++; EVP_DigestInit_ex(&s1, EVP_sha1(), NULL); EVP_DigestUpdate(&s1, buf, k); EVP_DigestUpdate(&s1, s->session->master_key, s->session->master_key_length); EVP_DigestUpdate(&s1, s->s3->server_random, SSL3_RANDOM_SIZE); EVP_DigestUpdate(&s1, s->s3->client_random, SSL3_RANDOM_SIZE); EVP_DigestFinal_ex(&s1, smd, NULL); EVP_DigestInit_ex(&m5, EVP_md5(), NULL); EVP_DigestUpdate(&m5, s->session->master_key, s->session->master_key_length); EVP_DigestUpdate(&m5, smd, SHA_DIGEST_LENGTH); if ((int)(i + MD5_DIGEST_LENGTH) > num) { EVP_DigestFinal_ex(&m5, smd, NULL); memcpy(km, smd, (num - i)); } else EVP_DigestFinal_ex(&m5, km, NULL); km += MD5_DIGEST_LENGTH; } OPENSSL_cleanse(smd, SHA_DIGEST_LENGTH); EVP_MD_CTX_cleanup(&m5); EVP_MD_CTX_cleanup(&s1); return 1; } int ssl3_change_cipher_state(SSL *s, int which) { const unsigned char *client_write_mac_secret, *server_write_mac_secret; const unsigned char *client_write_key, *server_write_key; const unsigned char *client_write_iv, *server_write_iv; const unsigned char *mac_secret, *key, *iv; unsigned char *key_block; int mac_len, key_len, iv_len; char is_read, use_client_keys; EVP_CIPHER_CTX *cipher_ctx; const EVP_CIPHER *cipher; const EVP_MD *mac; cipher = s->s3->tmp.new_sym_enc; mac = s->s3->tmp.new_hash; /* mac == NULL will lead to a crash later */ OPENSSL_assert(mac); /* * is_read is true if we have just read a ChangeCipherSpec message, * that is we need to update the read cipherspec. Otherwise we have * just written one. */ is_read = (which & SSL3_CC_READ) != 0; /* * use_client_keys is true if we wish to use the keys for the "client * write" direction. This is the case if we're a client sending a * ChangeCipherSpec, or a server reading a client's ChangeCipherSpec. */ use_client_keys = ((which == SSL3_CHANGE_CIPHER_CLIENT_WRITE) || (which == SSL3_CHANGE_CIPHER_SERVER_READ)); if (is_read) { EVP_CIPHER_CTX_free(s->enc_read_ctx); s->enc_read_ctx = NULL; if ((cipher_ctx = EVP_CIPHER_CTX_new()) == NULL) goto err; s->enc_read_ctx = cipher_ctx; if (ssl_replace_hash(&s->read_hash, mac) == NULL) goto err; } else { EVP_CIPHER_CTX_free(s->enc_write_ctx); s->enc_write_ctx = NULL; if ((cipher_ctx = EVP_CIPHER_CTX_new()) == NULL) goto err; s->enc_write_ctx = cipher_ctx; if (ssl_replace_hash(&s->write_hash, mac) == NULL) goto err; } memset(is_read ? s->s3->read_sequence : s->s3->write_sequence, 0, SSL3_SEQUENCE_SIZE); mac_len = EVP_MD_size(mac); key_len = EVP_CIPHER_key_length(cipher); iv_len = EVP_CIPHER_iv_length(cipher); if (mac_len < 0) goto err2; key_block = s->s3->tmp.key_block; client_write_mac_secret = key_block; key_block += mac_len; server_write_mac_secret = key_block; key_block += mac_len; client_write_key = key_block; key_block += key_len; server_write_key = key_block; key_block += key_len; client_write_iv = key_block; key_block += iv_len; server_write_iv = key_block; key_block += iv_len; if (use_client_keys) { mac_secret = client_write_mac_secret; key = client_write_key; iv = client_write_iv; } else { mac_secret = server_write_mac_secret; key = server_write_key; iv = server_write_iv; } if (key_block - s->s3->tmp.key_block != s->s3->tmp.key_block_length) { SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR); goto err2; } memcpy(is_read ? s->s3->read_mac_secret : s->s3->write_mac_secret, mac_secret, mac_len); EVP_CipherInit_ex(cipher_ctx, cipher, NULL, key, iv, !is_read); return (1); err: SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE, ERR_R_MALLOC_FAILURE); err2: return (0); } int ssl3_setup_key_block(SSL *s) { int key_block_len, mac_len, key_len, iv_len; unsigned char *key_block; const EVP_CIPHER *cipher; const EVP_MD *mac; int ret = 0; if (s->s3->tmp.key_block_length != 0) return (1); if (!ssl_cipher_get_evp(s->session, &cipher, &mac, NULL, NULL)) { SSLerr(SSL_F_SSL3_SETUP_KEY_BLOCK, SSL_R_CIPHER_OR_HASH_UNAVAILABLE); return (0); } s->s3->tmp.new_sym_enc = cipher; s->s3->tmp.new_hash = mac; mac_len = EVP_MD_size(mac); key_len = EVP_CIPHER_key_length(cipher); iv_len = EVP_CIPHER_iv_length(cipher); if (mac_len < 0) return 0; key_block_len = (mac_len + key_len + iv_len) * 2; ssl3_cleanup_key_block(s); if ((key_block = malloc(key_block_len)) == NULL) goto err; s->s3->tmp.key_block_length = key_block_len; s->s3->tmp.key_block = key_block; ret = ssl3_generate_key_block(s, key_block, key_block_len); if (!(s->options & SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)) { /* * Enable vulnerability countermeasure for CBC ciphers with * known-IV problem (http://www.openssl.org/~bodo/tls-cbc.txt) */ s->s3->need_empty_fragments = 1; if (s->session->cipher != NULL) { if (s->session->cipher->algorithm_enc == SSL_eNULL) s->s3->need_empty_fragments = 0; #ifndef OPENSSL_NO_RC4 if (s->session->cipher->algorithm_enc == SSL_RC4) s->s3->need_empty_fragments = 0; #endif } } return ret; err: SSLerr(SSL_F_SSL3_SETUP_KEY_BLOCK, ERR_R_MALLOC_FAILURE); return (0); } void ssl3_cleanup_key_block(SSL *s) { if (s->s3->tmp.key_block != NULL) { OPENSSL_cleanse(s->s3->tmp.key_block, s->s3->tmp.key_block_length); free(s->s3->tmp.key_block); s->s3->tmp.key_block = NULL; } s->s3->tmp.key_block_length = 0; } /* ssl3_enc encrypts/decrypts the record in |s->wrec| / |s->rrec|, respectively. * * Returns: * 0: (in non-constant time) if the record is publically invalid (i.e. too * short etc). * 1: if the record's padding is valid / the encryption was successful. * -1: if the record's padding is invalid or, if sending, an internal error * occured. */ int ssl3_enc(SSL *s, int send) { SSL3_RECORD *rec; EVP_CIPHER_CTX *ds; unsigned long l; int bs, i, mac_size = 0; const EVP_CIPHER *enc; if (send) { ds = s->enc_write_ctx; rec = &(s->s3->wrec); if (s->enc_write_ctx == NULL) enc = NULL; else enc = EVP_CIPHER_CTX_cipher(s->enc_write_ctx); } else { ds = s->enc_read_ctx; rec = &(s->s3->rrec); if (s->enc_read_ctx == NULL) enc = NULL; else enc = EVP_CIPHER_CTX_cipher(s->enc_read_ctx); } if ((s->session == NULL) || (ds == NULL) || (enc == NULL)) { memmove(rec->data, rec->input, rec->length); rec->input = rec->data; } else { l = rec->length; bs = EVP_CIPHER_block_size(ds->cipher); /* COMPRESS */ if ((bs != 1) && send) { i = bs - ((int)l % bs); /* we need to add 'i-1' padding bytes */ l += i; /* the last of these zero bytes will be overwritten * with the padding length. */ memset(&rec->input[rec->length], 0, i); rec->length += i; rec->input[l - 1] = (i - 1); } if (!send) { if (l == 0 || l % bs != 0) return 0; /* otherwise, rec->length >= bs */ } EVP_Cipher(ds, rec->data, rec->input, l); if (EVP_MD_CTX_md(s->read_hash) != NULL) mac_size = EVP_MD_CTX_size(s->read_hash); if ((bs != 1) && !send) return ssl3_cbc_remove_padding(s, rec, bs, mac_size); } return (1); } void ssl3_init_finished_mac(SSL *s) { BIO_free(s->s3->handshake_buffer); ssl3_free_digest_list(s); s->s3->handshake_buffer = BIO_new(BIO_s_mem()); (void)BIO_set_close(s->s3->handshake_buffer, BIO_CLOSE); } void ssl3_free_digest_list(SSL *s) { int i; if (s->s3->handshake_dgst == NULL) return; for (i = 0; i < SSL_MAX_DIGEST; i++) { if (s->s3->handshake_dgst[i]) EVP_MD_CTX_destroy(s->s3->handshake_dgst[i]); } free(s->s3->handshake_dgst); s->s3->handshake_dgst = NULL; } void ssl3_finish_mac(SSL *s, const unsigned char *buf, int len) { if (s->s3->handshake_buffer && !(s->s3->flags & TLS1_FLAGS_KEEP_HANDSHAKE)) { BIO_write(s->s3->handshake_buffer, (void *)buf, len); } else { int i; for (i = 0; i < SSL_MAX_DIGEST; i++) { if (s->s3->handshake_dgst[i]!= NULL) EVP_DigestUpdate(s->s3->handshake_dgst[i], buf, len); } } } int ssl3_digest_cached_records(SSL *s) { int i; long mask; const EVP_MD *md; long hdatalen; void *hdata; ssl3_free_digest_list(s); s->s3->handshake_dgst = calloc(SSL_MAX_DIGEST, sizeof(EVP_MD_CTX *)); if (s->s3->handshake_dgst == NULL) { SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, ERR_R_MALLOC_FAILURE); return 0; } hdatalen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata); if (hdatalen <= 0) { SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, SSL_R_BAD_HANDSHAKE_LENGTH); return 0; } /* Loop through bits of the algorithm2 field and create MD contexts. */ for (i = 0; ssl_get_handshake_digest(i, &mask, &md); i++) { if ((mask & ssl_get_algorithm2(s)) && md) { s->s3->handshake_dgst[i] = EVP_MD_CTX_create(); if (s->s3->handshake_dgst[i] == NULL) { SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, ERR_R_MALLOC_FAILURE); return 0; } if (!EVP_DigestInit_ex(s->s3->handshake_dgst[i], md, NULL)) return 0; if (!EVP_DigestUpdate(s->s3->handshake_dgst[i], hdata, hdatalen)) return 0; } } if (!(s->s3->flags & TLS1_FLAGS_KEEP_HANDSHAKE)) { BIO_free(s->s3->handshake_buffer); s->s3->handshake_buffer = NULL; } return 1; } int ssl3_cert_verify_mac(SSL *s, int md_nid, unsigned char *p) { return (ssl3_handshake_mac(s, md_nid, NULL, 0, p)); } int ssl3_final_finish_mac(SSL *s, const char *sender, int len, unsigned char *p) { int ret_md5, ret_sha1; ret_md5 = ssl3_handshake_mac(s, NID_md5, sender, len, p); if (ret_md5 == 0) return 0; p += ret_md5; ret_sha1 = ssl3_handshake_mac(s, NID_sha1, sender, len, p); if (ret_sha1 == 0) return 0; return (ret_md5 + ret_sha1); } static int ssl3_handshake_mac(SSL *s, int md_nid, const char *sender, int len, unsigned char *p) { unsigned int ret; int npad, n; unsigned int i; unsigned char md_buf[EVP_MAX_MD_SIZE]; EVP_MD_CTX ctx, *d = NULL; if (s->s3->handshake_buffer) if (!ssl3_digest_cached_records(s)) return 0; /* Search for digest of specified type in the handshake_dgst array. */ for (i = 0; i < SSL_MAX_DIGEST; i++) { if (s->s3->handshake_dgst[i] && EVP_MD_CTX_type(s->s3->handshake_dgst[i]) == md_nid) { d = s->s3->handshake_dgst[i]; break; } } if (!d) { SSLerr(SSL_F_SSL3_HANDSHAKE_MAC, SSL_R_NO_REQUIRED_DIGEST); return 0; } EVP_MD_CTX_init(&ctx); if (!EVP_MD_CTX_copy_ex(&ctx, d)) return 0; n = EVP_MD_CTX_size(&ctx); if (n < 0) return 0; npad = (48 / n) * n; if (sender != NULL) EVP_DigestUpdate(&ctx, sender, len); EVP_DigestUpdate(&ctx, s->session->master_key, s->session->master_key_length); EVP_DigestUpdate(&ctx, ssl3_pad_1, npad); EVP_DigestFinal_ex(&ctx, md_buf, &i); EVP_DigestInit_ex(&ctx, EVP_MD_CTX_md(&ctx), NULL); EVP_DigestUpdate(&ctx, s->session->master_key, s->session->master_key_length); EVP_DigestUpdate(&ctx, ssl3_pad_2, npad); EVP_DigestUpdate(&ctx, md_buf, i); EVP_DigestFinal_ex(&ctx, p, &ret); EVP_MD_CTX_cleanup(&ctx); return ((int)ret); } int n_ssl3_mac(SSL *ssl, unsigned char *md, int send) { SSL3_RECORD *rec; unsigned char *mac_sec, *seq; EVP_MD_CTX md_ctx; const EVP_MD_CTX *hash; unsigned char *p, rec_char; size_t md_size, orig_len; int npad; int t; if (send) { rec = &(ssl->s3->wrec); mac_sec = &(ssl->s3->write_mac_secret[0]); seq = &(ssl->s3->write_sequence[0]); hash = ssl->write_hash; } else { rec = &(ssl->s3->rrec); mac_sec = &(ssl->s3->read_mac_secret[0]); seq = &(ssl->s3->read_sequence[0]); hash = ssl->read_hash; } t = EVP_MD_CTX_size(hash); if (t < 0) return -1; md_size = t; npad = (48 / md_size) * md_size; /* kludge: ssl3_cbc_remove_padding passes padding length in rec->type */ orig_len = rec->length + md_size + ((unsigned int)rec->type >> 8); rec->type &= 0xff; if (!send && EVP_CIPHER_CTX_mode(ssl->enc_read_ctx) == EVP_CIPH_CBC_MODE && ssl3_cbc_record_digest_supported(hash)) { /* This is a CBC-encrypted record. We must avoid leaking any * timing-side channel information about how many blocks of * data we are hashing because that gives an attacker a * timing-oracle. */ /* npad is, at most, 48 bytes and that's with MD5: * 16 + 48 + 8 (sequence bytes) + 1 + 2 = 75. * * With SHA-1 (the largest hash speced for SSLv3) the hash size * goes up 4, but npad goes down by 8, resulting in a smaller * total size. */ unsigned char header[75]; unsigned j = 0; memcpy(header + j, mac_sec, md_size); j += md_size; memcpy(header + j, ssl3_pad_1, npad); j += npad; memcpy(header + j, seq, 8); j += 8; header[j++] = rec->type; header[j++] = rec->length >> 8; header[j++] = rec->length & 0xff; ssl3_cbc_digest_record(hash, md, &md_size, header, rec->input, rec->length + md_size, orig_len, mac_sec, md_size, 1 /* is SSLv3 */); } else { unsigned int md_size_u; /* Chop the digest off the end :-) */ EVP_MD_CTX_init(&md_ctx); if (!EVP_MD_CTX_copy_ex(&md_ctx, hash)) return (-1); EVP_DigestUpdate(&md_ctx, mac_sec, md_size); EVP_DigestUpdate(&md_ctx, ssl3_pad_1, npad); EVP_DigestUpdate(&md_ctx, seq, 8); rec_char = rec->type; EVP_DigestUpdate(&md_ctx, &rec_char, 1); p = md; s2n(rec->length, p); EVP_DigestUpdate(&md_ctx, md, 2); EVP_DigestUpdate(&md_ctx, rec->input, rec->length); EVP_DigestFinal_ex(&md_ctx, md, NULL); if (!EVP_MD_CTX_copy_ex(&md_ctx, hash)) return (-1); EVP_DigestUpdate(&md_ctx, mac_sec, md_size); EVP_DigestUpdate(&md_ctx, ssl3_pad_2, npad); EVP_DigestUpdate(&md_ctx, md, md_size); EVP_DigestFinal_ex(&md_ctx, md, &md_size_u); md_size = md_size_u; EVP_MD_CTX_cleanup(&md_ctx); } ssl3_record_sequence_increment(seq); return (md_size); } void ssl3_record_sequence_increment(unsigned char *seq) { int i; for (i = SSL3_SEQUENCE_SIZE - 1; i >= 0; i--) { if (++seq[i] != 0) break; } } int ssl3_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p, int len) { static const unsigned char *salt[3] = { "A", "BB", "CCC", }; unsigned char buf[EVP_MAX_MD_SIZE]; EVP_MD_CTX ctx; int i, ret = 0; unsigned int n; EVP_MD_CTX_init(&ctx); for (i = 0; i < 3; i++) { EVP_DigestInit_ex(&ctx, s->ctx->sha1, NULL); EVP_DigestUpdate(&ctx, salt[i], strlen((const char *)salt[i])); EVP_DigestUpdate(&ctx, p, len); EVP_DigestUpdate(&ctx, s->s3->client_random, SSL3_RANDOM_SIZE); EVP_DigestUpdate(&ctx, s->s3->server_random, SSL3_RANDOM_SIZE); EVP_DigestFinal_ex(&ctx, buf, &n); EVP_DigestInit_ex(&ctx, s->ctx->md5, NULL); EVP_DigestUpdate(&ctx, p, len); EVP_DigestUpdate(&ctx, buf, n); EVP_DigestFinal_ex(&ctx, out, &n); out += n; ret += n; } EVP_MD_CTX_cleanup(&ctx); return (ret); } int ssl3_alert_code(int code) { switch (code) { case SSL_AD_CLOSE_NOTIFY: return (SSL3_AD_CLOSE_NOTIFY); case SSL_AD_UNEXPECTED_MESSAGE: return (SSL3_AD_UNEXPECTED_MESSAGE); case SSL_AD_BAD_RECORD_MAC: return (SSL3_AD_BAD_RECORD_MAC); case SSL_AD_DECRYPTION_FAILED: return (SSL3_AD_BAD_RECORD_MAC); case SSL_AD_RECORD_OVERFLOW: return (SSL3_AD_BAD_RECORD_MAC); case SSL_AD_DECOMPRESSION_FAILURE: return (SSL3_AD_DECOMPRESSION_FAILURE); case SSL_AD_HANDSHAKE_FAILURE: return (SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_NO_CERTIFICATE: return (SSL3_AD_NO_CERTIFICATE); case SSL_AD_BAD_CERTIFICATE: return (SSL3_AD_BAD_CERTIFICATE); case SSL_AD_UNSUPPORTED_CERTIFICATE: return (SSL3_AD_UNSUPPORTED_CERTIFICATE); case SSL_AD_CERTIFICATE_REVOKED: return (SSL3_AD_CERTIFICATE_REVOKED); case SSL_AD_CERTIFICATE_EXPIRED: return (SSL3_AD_CERTIFICATE_EXPIRED); case SSL_AD_CERTIFICATE_UNKNOWN: return (SSL3_AD_CERTIFICATE_UNKNOWN); case SSL_AD_ILLEGAL_PARAMETER: return (SSL3_AD_ILLEGAL_PARAMETER); case SSL_AD_UNKNOWN_CA: return (SSL3_AD_BAD_CERTIFICATE); case SSL_AD_ACCESS_DENIED: return (SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_DECODE_ERROR: return (SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_DECRYPT_ERROR: return (SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_EXPORT_RESTRICTION: return (SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_PROTOCOL_VERSION: return (SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_INSUFFICIENT_SECURITY: return (SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_INTERNAL_ERROR: return (SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_USER_CANCELLED: return (SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_NO_RENEGOTIATION: return(-1); /* Don't send it :-) */ case SSL_AD_UNSUPPORTED_EXTENSION: return (SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_CERTIFICATE_UNOBTAINABLE: return (SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_UNRECOGNIZED_NAME: return (SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE: return (SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_BAD_CERTIFICATE_HASH_VALUE: return (SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_UNKNOWN_PSK_IDENTITY: return (TLS1_AD_UNKNOWN_PSK_IDENTITY); default: return (-1); } } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/Makefile.am0000644000175000017500000000272112360020706017573 0ustar include $(top_srcdir)/Makefile.am.common lib_LTLIBRARIES = libssl.la libssl_la_LDFLAGS = -version-info 26:0:0 libssl_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS) libssl_la_SOURCES = noinst_HEADERS = libssl_la_SOURCES += bio_ssl.c libssl_la_SOURCES += d1_both.c libssl_la_SOURCES += d1_clnt.c libssl_la_SOURCES += d1_enc.c libssl_la_SOURCES += d1_lib.c libssl_la_SOURCES += d1_meth.c libssl_la_SOURCES += d1_pkt.c libssl_la_SOURCES += d1_srtp.c libssl_la_SOURCES += d1_srvr.c libssl_la_SOURCES += pqueue.c libssl_la_SOURCES += s23_clnt.c libssl_la_SOURCES += s23_lib.c libssl_la_SOURCES += s23_meth.c libssl_la_SOURCES += s23_pkt.c libssl_la_SOURCES += s23_srvr.c libssl_la_SOURCES += s3_both.c libssl_la_SOURCES += s3_cbc.c libssl_la_SOURCES += s3_clnt.c libssl_la_SOURCES += s3_enc.c libssl_la_SOURCES += s3_lib.c libssl_la_SOURCES += s3_meth.c libssl_la_SOURCES += s3_pkt.c libssl_la_SOURCES += s3_srvr.c libssl_la_SOURCES += ssl_algs.c libssl_la_SOURCES += ssl_asn1.c libssl_la_SOURCES += ssl_cert.c libssl_la_SOURCES += ssl_ciph.c libssl_la_SOURCES += ssl_err.c libssl_la_SOURCES += ssl_err2.c libssl_la_SOURCES += ssl_lib.c libssl_la_SOURCES += ssl_rsa.c libssl_la_SOURCES += ssl_sess.c libssl_la_SOURCES += ssl_stat.c libssl_la_SOURCES += ssl_txt.c libssl_la_SOURCES += t1_clnt.c libssl_la_SOURCES += t1_enc.c libssl_la_SOURCES += t1_lib.c libssl_la_SOURCES += t1_meth.c libssl_la_SOURCES += t1_reneg.c libssl_la_SOURCES += t1_srvr.c noinst_HEADERS += srtp.h noinst_HEADERS += ssl_locl.h deps/libressl-pnacl-sys-2.1.6/libressl/ssl/Makefile.in0000664000175000017500000020101112437255271017613 0ustar # Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ DIST_COMMON = $(top_srcdir)/Makefile.am.common $(srcdir)/Makefile.in \ $(srcdir)/Makefile.am $(top_srcdir)/depcomp $(noinst_HEADERS) subdir = ssl ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libssl_la_LIBADD = am_libssl_la_OBJECTS = libssl_la-bio_ssl.lo libssl_la-d1_both.lo \ libssl_la-d1_clnt.lo libssl_la-d1_enc.lo libssl_la-d1_lib.lo \ libssl_la-d1_meth.lo libssl_la-d1_pkt.lo libssl_la-d1_srtp.lo \ libssl_la-d1_srvr.lo libssl_la-pqueue.lo libssl_la-s23_clnt.lo \ libssl_la-s23_lib.lo libssl_la-s23_meth.lo \ libssl_la-s23_pkt.lo libssl_la-s23_srvr.lo \ libssl_la-s3_both.lo libssl_la-s3_cbc.lo libssl_la-s3_clnt.lo \ libssl_la-s3_enc.lo libssl_la-s3_lib.lo libssl_la-s3_meth.lo \ libssl_la-s3_pkt.lo libssl_la-s3_srvr.lo libssl_la-ssl_algs.lo \ libssl_la-ssl_asn1.lo libssl_la-ssl_cert.lo \ libssl_la-ssl_ciph.lo libssl_la-ssl_err.lo \ libssl_la-ssl_err2.lo libssl_la-ssl_lib.lo \ libssl_la-ssl_rsa.lo libssl_la-ssl_sess.lo \ libssl_la-ssl_stat.lo libssl_la-ssl_txt.lo \ libssl_la-t1_clnt.lo libssl_la-t1_enc.lo libssl_la-t1_lib.lo \ libssl_la-t1_meth.lo libssl_la-t1_reneg.lo \ libssl_la-t1_srvr.lo libssl_la_OBJECTS = $(am_libssl_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libssl_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libssl_la_CFLAGS) \ $(CFLAGS) $(libssl_la_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libssl_la_SOURCES) DIST_SOURCES = $(libssl_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac HEADERS = $(noinst_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ NO_ARC4RANDOM_BUF = @NO_ARC4RANDOM_BUF@ NO_GETENTROPY = @NO_GETENTROPY@ NO_ISSETUGID = @NO_ISSETUGID@ NO_REALLOCARRAY = @NO_REALLOCARRAY@ NO_STRLCAT = @NO_STRLCAT@ NO_STRLCPY = @NO_STRLCPY@ NO_STRTONUM = @NO_STRTONUM@ NO_TIMINGSAFE_BCMP = @NO_TIMINGSAFE_BCMP@ NO_TIMINGSAFE_MEMCMP = @NO_TIMINGSAFE_MEMCMP@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PLATFORM_LDADD = @PLATFORM_LDADD@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ USER_CFLAGS = @USER_CFLAGS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = -I$(top_srcdir)/include -DOPENSSL_NO_ASM \ -DHAVE_CRYPTODEV -DLIBRESSL_INTERNAL lib_LTLIBRARIES = libssl.la libssl_la_LDFLAGS = -version-info 26:0:0 libssl_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS) libssl_la_SOURCES = bio_ssl.c d1_both.c d1_clnt.c d1_enc.c d1_lib.c \ d1_meth.c d1_pkt.c d1_srtp.c d1_srvr.c pqueue.c s23_clnt.c \ s23_lib.c s23_meth.c s23_pkt.c s23_srvr.c s3_both.c s3_cbc.c \ s3_clnt.c s3_enc.c s3_lib.c s3_meth.c s3_pkt.c s3_srvr.c \ ssl_algs.c ssl_asn1.c ssl_cert.c ssl_ciph.c ssl_err.c \ ssl_err2.c ssl_lib.c ssl_rsa.c ssl_sess.c ssl_stat.c ssl_txt.c \ t1_clnt.c t1_enc.c t1_lib.c t1_meth.c t1_reneg.c t1_srvr.c noinst_HEADERS = srtp.h ssl_locl.h all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.am.common $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ssl/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu ssl/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_srcdir)/Makefile.am.common: $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libssl.la: $(libssl_la_OBJECTS) $(libssl_la_DEPENDENCIES) $(EXTRA_libssl_la_DEPENDENCIES) $(AM_V_CCLD)$(libssl_la_LINK) -rpath $(libdir) $(libssl_la_OBJECTS) $(libssl_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-bio_ssl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-d1_both.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-d1_clnt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-d1_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-d1_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-d1_meth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-d1_pkt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-d1_srtp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-d1_srvr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-pqueue.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-s23_clnt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-s23_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-s23_meth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-s23_pkt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-s23_srvr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-s3_both.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-s3_cbc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-s3_clnt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-s3_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-s3_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-s3_meth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-s3_pkt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-s3_srvr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_algs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_asn1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_cert.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_ciph.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_err2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_rsa.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_sess.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_stat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_txt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-t1_clnt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-t1_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-t1_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-t1_meth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-t1_reneg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-t1_srvr.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< libssl_la-bio_ssl.lo: bio_ssl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-bio_ssl.lo -MD -MP -MF $(DEPDIR)/libssl_la-bio_ssl.Tpo -c -o libssl_la-bio_ssl.lo `test -f 'bio_ssl.c' || echo '$(srcdir)/'`bio_ssl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-bio_ssl.Tpo $(DEPDIR)/libssl_la-bio_ssl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio_ssl.c' object='libssl_la-bio_ssl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-bio_ssl.lo `test -f 'bio_ssl.c' || echo '$(srcdir)/'`bio_ssl.c libssl_la-d1_both.lo: d1_both.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-d1_both.lo -MD -MP -MF $(DEPDIR)/libssl_la-d1_both.Tpo -c -o libssl_la-d1_both.lo `test -f 'd1_both.c' || echo '$(srcdir)/'`d1_both.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-d1_both.Tpo $(DEPDIR)/libssl_la-d1_both.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='d1_both.c' object='libssl_la-d1_both.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-d1_both.lo `test -f 'd1_both.c' || echo '$(srcdir)/'`d1_both.c libssl_la-d1_clnt.lo: d1_clnt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-d1_clnt.lo -MD -MP -MF $(DEPDIR)/libssl_la-d1_clnt.Tpo -c -o libssl_la-d1_clnt.lo `test -f 'd1_clnt.c' || echo '$(srcdir)/'`d1_clnt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-d1_clnt.Tpo $(DEPDIR)/libssl_la-d1_clnt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='d1_clnt.c' object='libssl_la-d1_clnt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-d1_clnt.lo `test -f 'd1_clnt.c' || echo '$(srcdir)/'`d1_clnt.c libssl_la-d1_enc.lo: d1_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-d1_enc.lo -MD -MP -MF $(DEPDIR)/libssl_la-d1_enc.Tpo -c -o libssl_la-d1_enc.lo `test -f 'd1_enc.c' || echo '$(srcdir)/'`d1_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-d1_enc.Tpo $(DEPDIR)/libssl_la-d1_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='d1_enc.c' object='libssl_la-d1_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-d1_enc.lo `test -f 'd1_enc.c' || echo '$(srcdir)/'`d1_enc.c libssl_la-d1_lib.lo: d1_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-d1_lib.lo -MD -MP -MF $(DEPDIR)/libssl_la-d1_lib.Tpo -c -o libssl_la-d1_lib.lo `test -f 'd1_lib.c' || echo '$(srcdir)/'`d1_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-d1_lib.Tpo $(DEPDIR)/libssl_la-d1_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='d1_lib.c' object='libssl_la-d1_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-d1_lib.lo `test -f 'd1_lib.c' || echo '$(srcdir)/'`d1_lib.c libssl_la-d1_meth.lo: d1_meth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-d1_meth.lo -MD -MP -MF $(DEPDIR)/libssl_la-d1_meth.Tpo -c -o libssl_la-d1_meth.lo `test -f 'd1_meth.c' || echo '$(srcdir)/'`d1_meth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-d1_meth.Tpo $(DEPDIR)/libssl_la-d1_meth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='d1_meth.c' object='libssl_la-d1_meth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-d1_meth.lo `test -f 'd1_meth.c' || echo '$(srcdir)/'`d1_meth.c libssl_la-d1_pkt.lo: d1_pkt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-d1_pkt.lo -MD -MP -MF $(DEPDIR)/libssl_la-d1_pkt.Tpo -c -o libssl_la-d1_pkt.lo `test -f 'd1_pkt.c' || echo '$(srcdir)/'`d1_pkt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-d1_pkt.Tpo $(DEPDIR)/libssl_la-d1_pkt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='d1_pkt.c' object='libssl_la-d1_pkt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-d1_pkt.lo `test -f 'd1_pkt.c' || echo '$(srcdir)/'`d1_pkt.c libssl_la-d1_srtp.lo: d1_srtp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-d1_srtp.lo -MD -MP -MF $(DEPDIR)/libssl_la-d1_srtp.Tpo -c -o libssl_la-d1_srtp.lo `test -f 'd1_srtp.c' || echo '$(srcdir)/'`d1_srtp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-d1_srtp.Tpo $(DEPDIR)/libssl_la-d1_srtp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='d1_srtp.c' object='libssl_la-d1_srtp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-d1_srtp.lo `test -f 'd1_srtp.c' || echo '$(srcdir)/'`d1_srtp.c libssl_la-d1_srvr.lo: d1_srvr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-d1_srvr.lo -MD -MP -MF $(DEPDIR)/libssl_la-d1_srvr.Tpo -c -o libssl_la-d1_srvr.lo `test -f 'd1_srvr.c' || echo '$(srcdir)/'`d1_srvr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-d1_srvr.Tpo $(DEPDIR)/libssl_la-d1_srvr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='d1_srvr.c' object='libssl_la-d1_srvr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-d1_srvr.lo `test -f 'd1_srvr.c' || echo '$(srcdir)/'`d1_srvr.c libssl_la-pqueue.lo: pqueue.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-pqueue.lo -MD -MP -MF $(DEPDIR)/libssl_la-pqueue.Tpo -c -o libssl_la-pqueue.lo `test -f 'pqueue.c' || echo '$(srcdir)/'`pqueue.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-pqueue.Tpo $(DEPDIR)/libssl_la-pqueue.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pqueue.c' object='libssl_la-pqueue.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-pqueue.lo `test -f 'pqueue.c' || echo '$(srcdir)/'`pqueue.c libssl_la-s23_clnt.lo: s23_clnt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-s23_clnt.lo -MD -MP -MF $(DEPDIR)/libssl_la-s23_clnt.Tpo -c -o libssl_la-s23_clnt.lo `test -f 's23_clnt.c' || echo '$(srcdir)/'`s23_clnt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-s23_clnt.Tpo $(DEPDIR)/libssl_la-s23_clnt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s23_clnt.c' object='libssl_la-s23_clnt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-s23_clnt.lo `test -f 's23_clnt.c' || echo '$(srcdir)/'`s23_clnt.c libssl_la-s23_lib.lo: s23_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-s23_lib.lo -MD -MP -MF $(DEPDIR)/libssl_la-s23_lib.Tpo -c -o libssl_la-s23_lib.lo `test -f 's23_lib.c' || echo '$(srcdir)/'`s23_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-s23_lib.Tpo $(DEPDIR)/libssl_la-s23_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s23_lib.c' object='libssl_la-s23_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-s23_lib.lo `test -f 's23_lib.c' || echo '$(srcdir)/'`s23_lib.c libssl_la-s23_meth.lo: s23_meth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-s23_meth.lo -MD -MP -MF $(DEPDIR)/libssl_la-s23_meth.Tpo -c -o libssl_la-s23_meth.lo `test -f 's23_meth.c' || echo '$(srcdir)/'`s23_meth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-s23_meth.Tpo $(DEPDIR)/libssl_la-s23_meth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s23_meth.c' object='libssl_la-s23_meth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-s23_meth.lo `test -f 's23_meth.c' || echo '$(srcdir)/'`s23_meth.c libssl_la-s23_pkt.lo: s23_pkt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-s23_pkt.lo -MD -MP -MF $(DEPDIR)/libssl_la-s23_pkt.Tpo -c -o libssl_la-s23_pkt.lo `test -f 's23_pkt.c' || echo '$(srcdir)/'`s23_pkt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-s23_pkt.Tpo $(DEPDIR)/libssl_la-s23_pkt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s23_pkt.c' object='libssl_la-s23_pkt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-s23_pkt.lo `test -f 's23_pkt.c' || echo '$(srcdir)/'`s23_pkt.c libssl_la-s23_srvr.lo: s23_srvr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-s23_srvr.lo -MD -MP -MF $(DEPDIR)/libssl_la-s23_srvr.Tpo -c -o libssl_la-s23_srvr.lo `test -f 's23_srvr.c' || echo '$(srcdir)/'`s23_srvr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-s23_srvr.Tpo $(DEPDIR)/libssl_la-s23_srvr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s23_srvr.c' object='libssl_la-s23_srvr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-s23_srvr.lo `test -f 's23_srvr.c' || echo '$(srcdir)/'`s23_srvr.c libssl_la-s3_both.lo: s3_both.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-s3_both.lo -MD -MP -MF $(DEPDIR)/libssl_la-s3_both.Tpo -c -o libssl_la-s3_both.lo `test -f 's3_both.c' || echo '$(srcdir)/'`s3_both.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-s3_both.Tpo $(DEPDIR)/libssl_la-s3_both.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s3_both.c' object='libssl_la-s3_both.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-s3_both.lo `test -f 's3_both.c' || echo '$(srcdir)/'`s3_both.c libssl_la-s3_cbc.lo: s3_cbc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-s3_cbc.lo -MD -MP -MF $(DEPDIR)/libssl_la-s3_cbc.Tpo -c -o libssl_la-s3_cbc.lo `test -f 's3_cbc.c' || echo '$(srcdir)/'`s3_cbc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-s3_cbc.Tpo $(DEPDIR)/libssl_la-s3_cbc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s3_cbc.c' object='libssl_la-s3_cbc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-s3_cbc.lo `test -f 's3_cbc.c' || echo '$(srcdir)/'`s3_cbc.c libssl_la-s3_clnt.lo: s3_clnt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-s3_clnt.lo -MD -MP -MF $(DEPDIR)/libssl_la-s3_clnt.Tpo -c -o libssl_la-s3_clnt.lo `test -f 's3_clnt.c' || echo '$(srcdir)/'`s3_clnt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-s3_clnt.Tpo $(DEPDIR)/libssl_la-s3_clnt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s3_clnt.c' object='libssl_la-s3_clnt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-s3_clnt.lo `test -f 's3_clnt.c' || echo '$(srcdir)/'`s3_clnt.c libssl_la-s3_enc.lo: s3_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-s3_enc.lo -MD -MP -MF $(DEPDIR)/libssl_la-s3_enc.Tpo -c -o libssl_la-s3_enc.lo `test -f 's3_enc.c' || echo '$(srcdir)/'`s3_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-s3_enc.Tpo $(DEPDIR)/libssl_la-s3_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s3_enc.c' object='libssl_la-s3_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-s3_enc.lo `test -f 's3_enc.c' || echo '$(srcdir)/'`s3_enc.c libssl_la-s3_lib.lo: s3_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-s3_lib.lo -MD -MP -MF $(DEPDIR)/libssl_la-s3_lib.Tpo -c -o libssl_la-s3_lib.lo `test -f 's3_lib.c' || echo '$(srcdir)/'`s3_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-s3_lib.Tpo $(DEPDIR)/libssl_la-s3_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s3_lib.c' object='libssl_la-s3_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-s3_lib.lo `test -f 's3_lib.c' || echo '$(srcdir)/'`s3_lib.c libssl_la-s3_meth.lo: s3_meth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-s3_meth.lo -MD -MP -MF $(DEPDIR)/libssl_la-s3_meth.Tpo -c -o libssl_la-s3_meth.lo `test -f 's3_meth.c' || echo '$(srcdir)/'`s3_meth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-s3_meth.Tpo $(DEPDIR)/libssl_la-s3_meth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s3_meth.c' object='libssl_la-s3_meth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-s3_meth.lo `test -f 's3_meth.c' || echo '$(srcdir)/'`s3_meth.c libssl_la-s3_pkt.lo: s3_pkt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-s3_pkt.lo -MD -MP -MF $(DEPDIR)/libssl_la-s3_pkt.Tpo -c -o libssl_la-s3_pkt.lo `test -f 's3_pkt.c' || echo '$(srcdir)/'`s3_pkt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-s3_pkt.Tpo $(DEPDIR)/libssl_la-s3_pkt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s3_pkt.c' object='libssl_la-s3_pkt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-s3_pkt.lo `test -f 's3_pkt.c' || echo '$(srcdir)/'`s3_pkt.c libssl_la-s3_srvr.lo: s3_srvr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-s3_srvr.lo -MD -MP -MF $(DEPDIR)/libssl_la-s3_srvr.Tpo -c -o libssl_la-s3_srvr.lo `test -f 's3_srvr.c' || echo '$(srcdir)/'`s3_srvr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-s3_srvr.Tpo $(DEPDIR)/libssl_la-s3_srvr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s3_srvr.c' object='libssl_la-s3_srvr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-s3_srvr.lo `test -f 's3_srvr.c' || echo '$(srcdir)/'`s3_srvr.c libssl_la-ssl_algs.lo: ssl_algs.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_algs.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_algs.Tpo -c -o libssl_la-ssl_algs.lo `test -f 'ssl_algs.c' || echo '$(srcdir)/'`ssl_algs.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_algs.Tpo $(DEPDIR)/libssl_la-ssl_algs.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_algs.c' object='libssl_la-ssl_algs.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_algs.lo `test -f 'ssl_algs.c' || echo '$(srcdir)/'`ssl_algs.c libssl_la-ssl_asn1.lo: ssl_asn1.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_asn1.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_asn1.Tpo -c -o libssl_la-ssl_asn1.lo `test -f 'ssl_asn1.c' || echo '$(srcdir)/'`ssl_asn1.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_asn1.Tpo $(DEPDIR)/libssl_la-ssl_asn1.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_asn1.c' object='libssl_la-ssl_asn1.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_asn1.lo `test -f 'ssl_asn1.c' || echo '$(srcdir)/'`ssl_asn1.c libssl_la-ssl_cert.lo: ssl_cert.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_cert.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_cert.Tpo -c -o libssl_la-ssl_cert.lo `test -f 'ssl_cert.c' || echo '$(srcdir)/'`ssl_cert.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_cert.Tpo $(DEPDIR)/libssl_la-ssl_cert.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_cert.c' object='libssl_la-ssl_cert.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_cert.lo `test -f 'ssl_cert.c' || echo '$(srcdir)/'`ssl_cert.c libssl_la-ssl_ciph.lo: ssl_ciph.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_ciph.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_ciph.Tpo -c -o libssl_la-ssl_ciph.lo `test -f 'ssl_ciph.c' || echo '$(srcdir)/'`ssl_ciph.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_ciph.Tpo $(DEPDIR)/libssl_la-ssl_ciph.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_ciph.c' object='libssl_la-ssl_ciph.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_ciph.lo `test -f 'ssl_ciph.c' || echo '$(srcdir)/'`ssl_ciph.c libssl_la-ssl_err.lo: ssl_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_err.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_err.Tpo -c -o libssl_la-ssl_err.lo `test -f 'ssl_err.c' || echo '$(srcdir)/'`ssl_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_err.Tpo $(DEPDIR)/libssl_la-ssl_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_err.c' object='libssl_la-ssl_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_err.lo `test -f 'ssl_err.c' || echo '$(srcdir)/'`ssl_err.c libssl_la-ssl_err2.lo: ssl_err2.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_err2.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_err2.Tpo -c -o libssl_la-ssl_err2.lo `test -f 'ssl_err2.c' || echo '$(srcdir)/'`ssl_err2.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_err2.Tpo $(DEPDIR)/libssl_la-ssl_err2.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_err2.c' object='libssl_la-ssl_err2.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_err2.lo `test -f 'ssl_err2.c' || echo '$(srcdir)/'`ssl_err2.c libssl_la-ssl_lib.lo: ssl_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_lib.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_lib.Tpo -c -o libssl_la-ssl_lib.lo `test -f 'ssl_lib.c' || echo '$(srcdir)/'`ssl_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_lib.Tpo $(DEPDIR)/libssl_la-ssl_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_lib.c' object='libssl_la-ssl_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_lib.lo `test -f 'ssl_lib.c' || echo '$(srcdir)/'`ssl_lib.c libssl_la-ssl_rsa.lo: ssl_rsa.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_rsa.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_rsa.Tpo -c -o libssl_la-ssl_rsa.lo `test -f 'ssl_rsa.c' || echo '$(srcdir)/'`ssl_rsa.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_rsa.Tpo $(DEPDIR)/libssl_la-ssl_rsa.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_rsa.c' object='libssl_la-ssl_rsa.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_rsa.lo `test -f 'ssl_rsa.c' || echo '$(srcdir)/'`ssl_rsa.c libssl_la-ssl_sess.lo: ssl_sess.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_sess.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_sess.Tpo -c -o libssl_la-ssl_sess.lo `test -f 'ssl_sess.c' || echo '$(srcdir)/'`ssl_sess.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_sess.Tpo $(DEPDIR)/libssl_la-ssl_sess.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_sess.c' object='libssl_la-ssl_sess.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_sess.lo `test -f 'ssl_sess.c' || echo '$(srcdir)/'`ssl_sess.c libssl_la-ssl_stat.lo: ssl_stat.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_stat.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_stat.Tpo -c -o libssl_la-ssl_stat.lo `test -f 'ssl_stat.c' || echo '$(srcdir)/'`ssl_stat.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_stat.Tpo $(DEPDIR)/libssl_la-ssl_stat.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_stat.c' object='libssl_la-ssl_stat.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_stat.lo `test -f 'ssl_stat.c' || echo '$(srcdir)/'`ssl_stat.c libssl_la-ssl_txt.lo: ssl_txt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_txt.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_txt.Tpo -c -o libssl_la-ssl_txt.lo `test -f 'ssl_txt.c' || echo '$(srcdir)/'`ssl_txt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_txt.Tpo $(DEPDIR)/libssl_la-ssl_txt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_txt.c' object='libssl_la-ssl_txt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_txt.lo `test -f 'ssl_txt.c' || echo '$(srcdir)/'`ssl_txt.c libssl_la-t1_clnt.lo: t1_clnt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-t1_clnt.lo -MD -MP -MF $(DEPDIR)/libssl_la-t1_clnt.Tpo -c -o libssl_la-t1_clnt.lo `test -f 't1_clnt.c' || echo '$(srcdir)/'`t1_clnt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-t1_clnt.Tpo $(DEPDIR)/libssl_la-t1_clnt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t1_clnt.c' object='libssl_la-t1_clnt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-t1_clnt.lo `test -f 't1_clnt.c' || echo '$(srcdir)/'`t1_clnt.c libssl_la-t1_enc.lo: t1_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-t1_enc.lo -MD -MP -MF $(DEPDIR)/libssl_la-t1_enc.Tpo -c -o libssl_la-t1_enc.lo `test -f 't1_enc.c' || echo '$(srcdir)/'`t1_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-t1_enc.Tpo $(DEPDIR)/libssl_la-t1_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t1_enc.c' object='libssl_la-t1_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-t1_enc.lo `test -f 't1_enc.c' || echo '$(srcdir)/'`t1_enc.c libssl_la-t1_lib.lo: t1_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-t1_lib.lo -MD -MP -MF $(DEPDIR)/libssl_la-t1_lib.Tpo -c -o libssl_la-t1_lib.lo `test -f 't1_lib.c' || echo '$(srcdir)/'`t1_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-t1_lib.Tpo $(DEPDIR)/libssl_la-t1_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t1_lib.c' object='libssl_la-t1_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-t1_lib.lo `test -f 't1_lib.c' || echo '$(srcdir)/'`t1_lib.c libssl_la-t1_meth.lo: t1_meth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-t1_meth.lo -MD -MP -MF $(DEPDIR)/libssl_la-t1_meth.Tpo -c -o libssl_la-t1_meth.lo `test -f 't1_meth.c' || echo '$(srcdir)/'`t1_meth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-t1_meth.Tpo $(DEPDIR)/libssl_la-t1_meth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t1_meth.c' object='libssl_la-t1_meth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-t1_meth.lo `test -f 't1_meth.c' || echo '$(srcdir)/'`t1_meth.c libssl_la-t1_reneg.lo: t1_reneg.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-t1_reneg.lo -MD -MP -MF $(DEPDIR)/libssl_la-t1_reneg.Tpo -c -o libssl_la-t1_reneg.lo `test -f 't1_reneg.c' || echo '$(srcdir)/'`t1_reneg.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-t1_reneg.Tpo $(DEPDIR)/libssl_la-t1_reneg.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t1_reneg.c' object='libssl_la-t1_reneg.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-t1_reneg.lo `test -f 't1_reneg.c' || echo '$(srcdir)/'`t1_reneg.c libssl_la-t1_srvr.lo: t1_srvr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -MT libssl_la-t1_srvr.lo -MD -MP -MF $(DEPDIR)/libssl_la-t1_srvr.Tpo -c -o libssl_la-t1_srvr.lo `test -f 't1_srvr.c' || echo '$(srcdir)/'`t1_srvr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-t1_srvr.Tpo $(DEPDIR)/libssl_la-t1_srvr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t1_srvr.c' object='libssl_la-t1_srvr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libssl_la_CFLAGS) $(CFLAGS) -c -o libssl_la-t1_srvr.lo `test -f 't1_srvr.c' || echo '$(srcdir)/'`t1_srvr.c mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-libLTLIBRARIES install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: deps/libressl-pnacl-sys-2.1.6/libressl/ssl/ssl_lib.c0000644000175000017500000021437412360020705017342 0ustar /* $OpenBSD: ssl_lib.c,v 1.73 2014/07/10 11:58:08 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * ECC cipher suite support in OpenSSL originally developed by * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. */ /* ==================================================================== * Copyright 2005 Nokia. All rights reserved. * * The portions of the attached software ("Contribution") is developed by * Nokia Corporation and is licensed pursuant to the OpenSSL open source * license. * * The Contribution, originally written by Mika Kousa and Pasi Eronen of * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites * support (see RFC 4279) to OpenSSL. * * No patent licenses or other rights except those expressly stated in * the OpenSSL open source license shall be deemed granted or received * expressly, by implication, estoppel, or otherwise. * * No assurances are provided by Nokia that the Contribution does not * infringe the patent or other intellectual property rights of any third * party or that the license provides you with all the necessary rights * to make use of the Contribution. * * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR * OTHERWISE. */ #include #include "ssl_locl.h" #include #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif const char *SSL_version_str = OPENSSL_VERSION_TEXT; SSL3_ENC_METHOD ssl3_undef_enc_method = { /* * Evil casts, but these functions are only called if there's a * library bug. */ .enc = (int (*)(SSL *, int))ssl_undefined_function, .mac = (int (*)(SSL *, unsigned char *, int))ssl_undefined_function, .setup_key_block = ssl_undefined_function, .generate_master_secret = (int (*)(SSL *, unsigned char *, unsigned char *, int))ssl_undefined_function, .change_cipher_state = (int (*)(SSL*, int))ssl_undefined_function, .final_finish_mac = (int (*)(SSL *, const char*, int, unsigned char *))ssl_undefined_function, .finish_mac_length = 0, .cert_verify_mac = (int (*)(SSL *, int, unsigned char *))ssl_undefined_function, .client_finished_label = NULL, .client_finished_label_len = 0, .server_finished_label = NULL, .server_finished_label_len = 0, .alert_value = (int (*)(int))ssl_undefined_function, .export_keying_material = (int (*)(SSL *, unsigned char *, size_t, const char *, size_t, const unsigned char *, size_t, int use_context))ssl_undefined_function, .enc_flags = 0, }; int SSL_clear(SSL *s) { if (s->method == NULL) { SSLerr(SSL_F_SSL_CLEAR, SSL_R_NO_METHOD_SPECIFIED); return (0); } if (ssl_clear_bad_session(s)) { SSL_SESSION_free(s->session); s->session = NULL; } s->error = 0; s->hit = 0; s->shutdown = 0; if (s->renegotiate) { SSLerr(SSL_F_SSL_CLEAR, ERR_R_INTERNAL_ERROR); return (0); } s->type = 0; s->state = SSL_ST_BEFORE|((s->server) ? SSL_ST_ACCEPT : SSL_ST_CONNECT); s->version = s->method->version; s->client_version = s->version; s->rwstate = SSL_NOTHING; s->rstate = SSL_ST_READ_HEADER; if (s->init_buf != NULL) { BUF_MEM_free(s->init_buf); s->init_buf = NULL; } ssl_clear_cipher_ctx(s); ssl_clear_hash_ctx(&s->read_hash); ssl_clear_hash_ctx(&s->write_hash); s->first_packet = 0; /* * Check to see if we were changed into a different method, if * so, revert back if we are not doing session-id reuse. */ if (!s->in_handshake && (s->session == NULL) && (s->method != s->ctx->method)) { s->method->ssl_free(s); s->method = s->ctx->method; if (!s->method->ssl_new(s)) return (0); } else s->method->ssl_clear(s); return (1); } /* Used to change an SSL_CTXs default SSL method type */ int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth) { STACK_OF(SSL_CIPHER) *sk; ctx->method = meth; sk = ssl_create_cipher_list(ctx->method, &(ctx->cipher_list), &(ctx->cipher_list_by_id), SSL_DEFAULT_CIPHER_LIST); if ((sk == NULL) || (sk_SSL_CIPHER_num(sk) <= 0)) { SSLerr(SSL_F_SSL_CTX_SET_SSL_VERSION, SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS); return (0); } return (1); } SSL * SSL_new(SSL_CTX *ctx) { SSL *s; if (ctx == NULL) { SSLerr(SSL_F_SSL_NEW, SSL_R_NULL_SSL_CTX); return (NULL); } if (ctx->method == NULL) { SSLerr(SSL_F_SSL_NEW, SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION); return (NULL); } s = calloc(1, sizeof(SSL)); if (s == NULL) goto err; s->options = ctx->options; s->mode = ctx->mode; s->max_cert_list = ctx->max_cert_list; if (ctx->cert != NULL) { /* * Earlier library versions used to copy the pointer to * the CERT, not its contents; only when setting new * parameters for the per-SSL copy, ssl_cert_new would be * called (and the direct reference to the per-SSL_CTX * settings would be lost, but those still were indirectly * accessed for various purposes, and for that reason they * used to be known as s->ctx->default_cert). * Now we don't look at the SSL_CTX's CERT after having * duplicated it once. */ s->cert = ssl_cert_dup(ctx->cert); if (s->cert == NULL) goto err; } else s->cert=NULL; /* Cannot really happen (see SSL_CTX_new) */ s->read_ahead = ctx->read_ahead; s->msg_callback = ctx->msg_callback; s->msg_callback_arg = ctx->msg_callback_arg; s->verify_mode = ctx->verify_mode; s->sid_ctx_length = ctx->sid_ctx_length; OPENSSL_assert(s->sid_ctx_length <= sizeof s->sid_ctx); memcpy(&s->sid_ctx, &ctx->sid_ctx, sizeof(s->sid_ctx)); s->verify_callback = ctx->default_verify_callback; s->generate_session_id = ctx->generate_session_id; s->param = X509_VERIFY_PARAM_new(); if (!s->param) goto err; X509_VERIFY_PARAM_inherit(s->param, ctx->param); s->quiet_shutdown = ctx->quiet_shutdown; s->max_send_fragment = ctx->max_send_fragment; CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX); s->ctx = ctx; s->tlsext_debug_cb = 0; s->tlsext_debug_arg = NULL; s->tlsext_ticket_expected = 0; s->tlsext_status_type = -1; s->tlsext_status_expected = 0; s->tlsext_ocsp_ids = NULL; s->tlsext_ocsp_exts = NULL; s->tlsext_ocsp_resp = NULL; s->tlsext_ocsp_resplen = -1; CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX); s->initial_ctx = ctx; # ifndef OPENSSL_NO_NEXTPROTONEG s->next_proto_negotiated = NULL; # endif s->verify_result = X509_V_OK; s->method = ctx->method; if (!s->method->ssl_new(s)) goto err; s->references = 1; s->server = (ctx->method->ssl_accept == ssl_undefined_function) ? 0 : 1; SSL_clear(s); CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data); return (s); err: if (s != NULL) { if (s->cert != NULL) ssl_cert_free(s->cert); if (s->ctx != NULL) SSL_CTX_free(s->ctx); /* decrement reference count */ free(s); } SSLerr(SSL_F_SSL_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx, unsigned int sid_ctx_len) { if (sid_ctx_len > sizeof ctx->sid_ctx) { SSLerr(SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT, SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG); return (0); } ctx->sid_ctx_length = sid_ctx_len; memcpy(ctx->sid_ctx, sid_ctx, sid_ctx_len); return (1); } int SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx, unsigned int sid_ctx_len) { if (sid_ctx_len > SSL_MAX_SID_CTX_LENGTH) { SSLerr(SSL_F_SSL_SET_SESSION_ID_CONTEXT, SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG); return (0); } ssl->sid_ctx_length = sid_ctx_len; memcpy(ssl->sid_ctx, sid_ctx, sid_ctx_len); return (1); } int SSL_CTX_set_generate_session_id(SSL_CTX *ctx, GEN_SESSION_CB cb) { CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); ctx->generate_session_id = cb; CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); return (1); } int SSL_set_generate_session_id(SSL *ssl, GEN_SESSION_CB cb) { CRYPTO_w_lock(CRYPTO_LOCK_SSL); ssl->generate_session_id = cb; CRYPTO_w_unlock(CRYPTO_LOCK_SSL); return (1); } int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id, unsigned int id_len) { /* * A quick examination of SSL_SESSION_hash and SSL_SESSION_cmp * shows how we can "construct" a session to give us the desired * check - ie. to find if there's a session in the hash table * that would conflict with any new session built out of this * id/id_len and the ssl_version in use by this SSL. */ SSL_SESSION r, *p; if (id_len > sizeof r.session_id) return (0); r.ssl_version = ssl->version; r.session_id_length = id_len; memcpy(r.session_id, id, id_len); CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); p = lh_SSL_SESSION_retrieve(ssl->ctx->sessions, &r); CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); return (p != NULL); } int SSL_CTX_set_purpose(SSL_CTX *s, int purpose) { return (X509_VERIFY_PARAM_set_purpose(s->param, purpose)); } int SSL_set_purpose(SSL *s, int purpose) { return (X509_VERIFY_PARAM_set_purpose(s->param, purpose)); } int SSL_CTX_set_trust(SSL_CTX *s, int trust) { return (X509_VERIFY_PARAM_set_trust(s->param, trust)); } int SSL_set_trust(SSL *s, int trust) { return (X509_VERIFY_PARAM_set_trust(s->param, trust)); } int SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm) { return (X509_VERIFY_PARAM_set1(ctx->param, vpm)); } int SSL_set1_param(SSL *ssl, X509_VERIFY_PARAM *vpm) { return (X509_VERIFY_PARAM_set1(ssl->param, vpm)); } void SSL_free(SSL *s) { int i; if (s == NULL) return; i = CRYPTO_add(&s->references, -1, CRYPTO_LOCK_SSL); if (i > 0) return; if (s->param) X509_VERIFY_PARAM_free(s->param); CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data); if (s->bbio != NULL) { /* If the buffering BIO is in place, pop it off */ if (s->bbio == s->wbio) { s->wbio = BIO_pop(s->wbio); } BIO_free(s->bbio); s->bbio = NULL; } if (s->rbio != NULL) BIO_free_all(s->rbio); if ((s->wbio != NULL) && (s->wbio != s->rbio)) BIO_free_all(s->wbio); if (s->init_buf != NULL) BUF_MEM_free(s->init_buf); /* add extra stuff */ if (s->cipher_list != NULL) sk_SSL_CIPHER_free(s->cipher_list); if (s->cipher_list_by_id != NULL) sk_SSL_CIPHER_free(s->cipher_list_by_id); /* Make the next call work :-) */ if (s->session != NULL) { ssl_clear_bad_session(s); SSL_SESSION_free(s->session); } ssl_clear_cipher_ctx(s); ssl_clear_hash_ctx(&s->read_hash); ssl_clear_hash_ctx(&s->write_hash); if (s->cert != NULL) ssl_cert_free(s->cert); /* Free up if allocated */ free(s->tlsext_hostname); if (s->initial_ctx) SSL_CTX_free(s->initial_ctx); free(s->tlsext_ecpointformatlist); free(s->tlsext_ellipticcurvelist); if (s->tlsext_ocsp_exts) sk_X509_EXTENSION_pop_free(s->tlsext_ocsp_exts, X509_EXTENSION_free); if (s->tlsext_ocsp_ids) sk_OCSP_RESPID_pop_free(s->tlsext_ocsp_ids, OCSP_RESPID_free); free(s->tlsext_ocsp_resp); if (s->client_CA != NULL) sk_X509_NAME_pop_free(s->client_CA, X509_NAME_free); if (s->method != NULL) s->method->ssl_free(s); if (s->ctx) SSL_CTX_free(s->ctx); #ifndef OPENSSL_NO_NEXTPROTONEG free(s->next_proto_negotiated); #endif #ifndef OPENSSL_NO_SRTP if (s->srtp_profiles) sk_SRTP_PROTECTION_PROFILE_free(s->srtp_profiles); #endif free(s); } void SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio) { /* If the output buffering BIO is still in place, remove it */ if (s->bbio != NULL) { if (s->wbio == s->bbio) { s->wbio = s->wbio->next_bio; s->bbio->next_bio = NULL; } } if ((s->rbio != NULL) && (s->rbio != rbio)) BIO_free_all(s->rbio); if ((s->wbio != NULL) && (s->wbio != wbio) && (s->rbio != s->wbio)) BIO_free_all(s->wbio); s->rbio = rbio; s->wbio = wbio; } BIO * SSL_get_rbio(const SSL *s) { return (s->rbio); } BIO * SSL_get_wbio(const SSL *s) { return (s->wbio); } int SSL_get_fd(const SSL *s) { return (SSL_get_rfd(s)); } int SSL_get_rfd(const SSL *s) { int ret = -1; BIO *b, *r; b = SSL_get_rbio(s); r = BIO_find_type(b, BIO_TYPE_DESCRIPTOR); if (r != NULL) BIO_get_fd(r, &ret); return (ret); } int SSL_get_wfd(const SSL *s) { int ret = -1; BIO *b, *r; b = SSL_get_wbio(s); r = BIO_find_type(b, BIO_TYPE_DESCRIPTOR); if (r != NULL) BIO_get_fd(r, &ret); return (ret); } int SSL_set_fd(SSL *s, int fd) { int ret = 0; BIO *bio = NULL; bio = BIO_new(BIO_s_socket()); if (bio == NULL) { SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB); goto err; } BIO_set_fd(bio, fd, BIO_NOCLOSE); SSL_set_bio(s, bio, bio); ret = 1; err: return (ret); } int SSL_set_wfd(SSL *s, int fd) { int ret = 0; BIO *bio = NULL; if ((s->rbio == NULL) || (BIO_method_type(s->rbio) != BIO_TYPE_SOCKET) || ((int)BIO_get_fd(s->rbio, NULL) != fd)) { bio = BIO_new(BIO_s_socket()); if (bio == NULL) { SSLerr(SSL_F_SSL_SET_WFD, ERR_R_BUF_LIB); goto err; } BIO_set_fd(bio, fd, BIO_NOCLOSE); SSL_set_bio(s, SSL_get_rbio(s), bio); } else SSL_set_bio(s, SSL_get_rbio(s), SSL_get_rbio(s)); ret = 1; err: return (ret); } int SSL_set_rfd(SSL *s, int fd) { int ret = 0; BIO *bio = NULL; if ((s->wbio == NULL) || (BIO_method_type(s->wbio) != BIO_TYPE_SOCKET) || ((int)BIO_get_fd(s->wbio, NULL) != fd)) { bio = BIO_new(BIO_s_socket()); if (bio == NULL) { SSLerr(SSL_F_SSL_SET_RFD, ERR_R_BUF_LIB); goto err; } BIO_set_fd(bio, fd, BIO_NOCLOSE); SSL_set_bio(s, bio, SSL_get_wbio(s)); } else SSL_set_bio(s, SSL_get_wbio(s), SSL_get_wbio(s)); ret = 1; err: return (ret); } /* return length of latest Finished message we sent, copy to 'buf' */ size_t SSL_get_finished(const SSL *s, void *buf, size_t count) { size_t ret = 0; if (s->s3 != NULL) { ret = s->s3->tmp.finish_md_len; if (count > ret) count = ret; memcpy(buf, s->s3->tmp.finish_md, count); } return (ret); } /* return length of latest Finished message we expected, copy to 'buf' */ size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count) { size_t ret = 0; if (s->s3 != NULL) { ret = s->s3->tmp.peer_finish_md_len; if (count > ret) count = ret; memcpy(buf, s->s3->tmp.peer_finish_md, count); } return (ret); } int SSL_get_verify_mode(const SSL *s) { return (s->verify_mode); } int SSL_get_verify_depth(const SSL *s) { return (X509_VERIFY_PARAM_get_depth(s->param)); } int (*SSL_get_verify_callback(const SSL *s))(int, X509_STORE_CTX *) { return (s->verify_callback); } int SSL_CTX_get_verify_mode(const SSL_CTX *ctx) { return (ctx->verify_mode); } int SSL_CTX_get_verify_depth(const SSL_CTX *ctx) { return (X509_VERIFY_PARAM_get_depth(ctx->param)); } int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(int, X509_STORE_CTX *) { return (ctx->default_verify_callback); } void SSL_set_verify(SSL *s, int mode, int (*callback)(int ok, X509_STORE_CTX *ctx)) { s->verify_mode = mode; if (callback != NULL) s->verify_callback = callback; } void SSL_set_verify_depth(SSL *s, int depth) { X509_VERIFY_PARAM_set_depth(s->param, depth); } void SSL_set_read_ahead(SSL *s, int yes) { s->read_ahead = yes; } int SSL_get_read_ahead(const SSL *s) { return (s->read_ahead); } int SSL_pending(const SSL *s) { /* * SSL_pending cannot work properly if read-ahead is enabled * (SSL_[CTX_]ctrl(..., SSL_CTRL_SET_READ_AHEAD, 1, NULL)), * and it is impossible to fix since SSL_pending cannot report * errors that may be observed while scanning the new data. * (Note that SSL_pending() is often used as a boolean value, * so we'd better not return -1.) */ return (s->method->ssl_pending(s)); } X509 * SSL_get_peer_certificate(const SSL *s) { X509 *r; if ((s == NULL) || (s->session == NULL)) r = NULL; else r = s->session->peer; if (r == NULL) return (r); CRYPTO_add(&r->references, 1, CRYPTO_LOCK_X509); return (r); } STACK_OF(X509) * SSL_get_peer_cert_chain(const SSL *s) { STACK_OF(X509) *r; if ((s == NULL) || (s->session == NULL) || (s->session->sess_cert == NULL)) r = NULL; else r = s->session->sess_cert->cert_chain; /* * If we are a client, cert_chain includes the peer's own * certificate; * if we are a server, it does not. */ return (r); } /* * Now in theory, since the calling process own 't' it should be safe to * modify. We need to be able to read f without being hassled */ void SSL_copy_session_id(SSL *t, const SSL *f) { CERT *tmp; /* Do we need to to SSL locking? */ SSL_set_session(t, SSL_get_session(f)); /* * What if we are setup as SSLv2 but want to talk SSLv3 or * vice-versa. */ if (t->method != f->method) { t->method->ssl_free(t); /* cleanup current */ t->method=f->method; /* change method */ t->method->ssl_new(t); /* setup new */ } tmp = t->cert; if (f->cert != NULL) { CRYPTO_add(&f->cert->references, 1, CRYPTO_LOCK_SSL_CERT); t->cert = f->cert; } else t->cert = NULL; if (tmp != NULL) ssl_cert_free(tmp); SSL_set_session_id_context(t, f->sid_ctx, f->sid_ctx_length); } /* Fix this so it checks all the valid key/cert options */ int SSL_CTX_check_private_key(const SSL_CTX *ctx) { if ((ctx == NULL) || (ctx->cert == NULL) || (ctx->cert->key->x509 == NULL)) { SSLerr(SSL_F_SSL_CTX_CHECK_PRIVATE_KEY, SSL_R_NO_CERTIFICATE_ASSIGNED); return (0); } if (ctx->cert->key->privatekey == NULL) { SSLerr(SSL_F_SSL_CTX_CHECK_PRIVATE_KEY, SSL_R_NO_PRIVATE_KEY_ASSIGNED); return (0); } return (X509_check_private_key(ctx->cert->key->x509, ctx->cert->key->privatekey)); } /* Fix this function so that it takes an optional type parameter */ int SSL_check_private_key(const SSL *ssl) { if (ssl == NULL) { SSLerr(SSL_F_SSL_CHECK_PRIVATE_KEY, ERR_R_PASSED_NULL_PARAMETER); return (0); } if (ssl->cert == NULL) { SSLerr(SSL_F_SSL_CHECK_PRIVATE_KEY, SSL_R_NO_CERTIFICATE_ASSIGNED); return (0); } if (ssl->cert->key->x509 == NULL) { SSLerr(SSL_F_SSL_CHECK_PRIVATE_KEY, SSL_R_NO_CERTIFICATE_ASSIGNED); return (0); } if (ssl->cert->key->privatekey == NULL) { SSLerr(SSL_F_SSL_CHECK_PRIVATE_KEY, SSL_R_NO_PRIVATE_KEY_ASSIGNED); return (0); } return (X509_check_private_key(ssl->cert->key->x509, ssl->cert->key->privatekey)); } int SSL_accept(SSL *s) { if (s->handshake_func == 0) SSL_set_accept_state(s); /* Not properly initialized yet */ return (s->method->ssl_accept(s)); } int SSL_connect(SSL *s) { if (s->handshake_func == 0) SSL_set_connect_state(s); /* Not properly initialized yet */ return (s->method->ssl_connect(s)); } long SSL_get_default_timeout(const SSL *s) { return (s->method->get_timeout()); } int SSL_read(SSL *s, void *buf, int num) { if (s->handshake_func == 0) { SSLerr(SSL_F_SSL_READ, SSL_R_UNINITIALIZED); return (-1); } if (s->shutdown & SSL_RECEIVED_SHUTDOWN) { s->rwstate = SSL_NOTHING; return (0); } return (s->method->ssl_read(s, buf, num)); } int SSL_peek(SSL *s, void *buf, int num) { if (s->handshake_func == 0) { SSLerr(SSL_F_SSL_PEEK, SSL_R_UNINITIALIZED); return (-1); } if (s->shutdown & SSL_RECEIVED_SHUTDOWN) { return (0); } return (s->method->ssl_peek(s, buf, num)); } int SSL_write(SSL *s, const void *buf, int num) { if (s->handshake_func == 0) { SSLerr(SSL_F_SSL_WRITE, SSL_R_UNINITIALIZED); return (-1); } if (s->shutdown & SSL_SENT_SHUTDOWN) { s->rwstate = SSL_NOTHING; SSLerr(SSL_F_SSL_WRITE, SSL_R_PROTOCOL_IS_SHUTDOWN); return (-1); } return (s->method->ssl_write(s, buf, num)); } int SSL_shutdown(SSL *s) { /* * Note that this function behaves differently from what one might * expect. Return values are 0 for no success (yet), * 1 for success; but calling it once is usually not enough, * even if blocking I/O is used (see ssl3_shutdown). */ if (s->handshake_func == 0) { SSLerr(SSL_F_SSL_SHUTDOWN, SSL_R_UNINITIALIZED); return (-1); } if ((s != NULL) && !SSL_in_init(s)) return (s->method->ssl_shutdown(s)); else return (1); } int SSL_renegotiate(SSL *s) { if (s->renegotiate == 0) s->renegotiate = 1; s->new_session = 1; return (s->method->ssl_renegotiate(s)); } int SSL_renegotiate_abbreviated(SSL *s) { if (s->renegotiate == 0) s->renegotiate = 1; s->new_session = 0; return (s->method->ssl_renegotiate(s)); } int SSL_renegotiate_pending(SSL *s) { /* * Becomes true when negotiation is requested; * false again once a handshake has finished. */ return (s->renegotiate != 0); } long SSL_ctrl(SSL *s, int cmd, long larg, void *parg) { long l; switch (cmd) { case SSL_CTRL_GET_READ_AHEAD: return (s->read_ahead); case SSL_CTRL_SET_READ_AHEAD: l = s->read_ahead; s->read_ahead = larg; return (l); case SSL_CTRL_SET_MSG_CALLBACK_ARG: s->msg_callback_arg = parg; return (1); case SSL_CTRL_OPTIONS: return (s->options|=larg); case SSL_CTRL_CLEAR_OPTIONS: return (s->options&=~larg); case SSL_CTRL_MODE: return (s->mode|=larg); case SSL_CTRL_CLEAR_MODE: return (s->mode &=~larg); case SSL_CTRL_GET_MAX_CERT_LIST: return (s->max_cert_list); case SSL_CTRL_SET_MAX_CERT_LIST: l = s->max_cert_list; s->max_cert_list = larg; return (l); case SSL_CTRL_SET_MTU: #ifndef OPENSSL_NO_DTLS1 if (larg < (long)dtls1_min_mtu()) return (0); #endif if (SSL_IS_DTLS(s)) { s->d1->mtu = larg; return (larg); } return (0); case SSL_CTRL_SET_MAX_SEND_FRAGMENT: if (larg < 512 || larg > SSL3_RT_MAX_PLAIN_LENGTH) return (0); s->max_send_fragment = larg; return (1); case SSL_CTRL_GET_RI_SUPPORT: if (s->s3) return (s->s3->send_connection_binding); else return (0); default: return (s->method->ssl_ctrl(s, cmd, larg, parg)); } } long SSL_callback_ctrl(SSL *s, int cmd, void (*fp)(void)) { switch (cmd) { case SSL_CTRL_SET_MSG_CALLBACK: s->msg_callback = (void (*)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg))(fp); return (1); default: return (s->method->ssl_callback_ctrl(s, cmd, fp)); } } LHASH_OF(SSL_SESSION) * SSL_CTX_sessions(SSL_CTX *ctx) { return (ctx->sessions); } long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg) { long l; switch (cmd) { case SSL_CTRL_GET_READ_AHEAD: return (ctx->read_ahead); case SSL_CTRL_SET_READ_AHEAD: l = ctx->read_ahead; ctx->read_ahead = larg; return (l); case SSL_CTRL_SET_MSG_CALLBACK_ARG: ctx->msg_callback_arg = parg; return (1); case SSL_CTRL_GET_MAX_CERT_LIST: return (ctx->max_cert_list); case SSL_CTRL_SET_MAX_CERT_LIST: l = ctx->max_cert_list; ctx->max_cert_list = larg; return (l); case SSL_CTRL_SET_SESS_CACHE_SIZE: l = ctx->session_cache_size; ctx->session_cache_size = larg; return (l); case SSL_CTRL_GET_SESS_CACHE_SIZE: return (ctx->session_cache_size); case SSL_CTRL_SET_SESS_CACHE_MODE: l = ctx->session_cache_mode; ctx->session_cache_mode = larg; return (l); case SSL_CTRL_GET_SESS_CACHE_MODE: return (ctx->session_cache_mode); case SSL_CTRL_SESS_NUMBER: return (lh_SSL_SESSION_num_items(ctx->sessions)); case SSL_CTRL_SESS_CONNECT: return (ctx->stats.sess_connect); case SSL_CTRL_SESS_CONNECT_GOOD: return (ctx->stats.sess_connect_good); case SSL_CTRL_SESS_CONNECT_RENEGOTIATE: return (ctx->stats.sess_connect_renegotiate); case SSL_CTRL_SESS_ACCEPT: return (ctx->stats.sess_accept); case SSL_CTRL_SESS_ACCEPT_GOOD: return (ctx->stats.sess_accept_good); case SSL_CTRL_SESS_ACCEPT_RENEGOTIATE: return (ctx->stats.sess_accept_renegotiate); case SSL_CTRL_SESS_HIT: return (ctx->stats.sess_hit); case SSL_CTRL_SESS_CB_HIT: return (ctx->stats.sess_cb_hit); case SSL_CTRL_SESS_MISSES: return (ctx->stats.sess_miss); case SSL_CTRL_SESS_TIMEOUTS: return (ctx->stats.sess_timeout); case SSL_CTRL_SESS_CACHE_FULL: return (ctx->stats.sess_cache_full); case SSL_CTRL_OPTIONS: return (ctx->options|=larg); case SSL_CTRL_CLEAR_OPTIONS: return (ctx->options&=~larg); case SSL_CTRL_MODE: return (ctx->mode|=larg); case SSL_CTRL_CLEAR_MODE: return (ctx->mode&=~larg); case SSL_CTRL_SET_MAX_SEND_FRAGMENT: if (larg < 512 || larg > SSL3_RT_MAX_PLAIN_LENGTH) return (0); ctx->max_send_fragment = larg; return (1); default: return (ctx->method->ssl_ctx_ctrl(ctx, cmd, larg, parg)); } } long SSL_CTX_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void)) { switch (cmd) { case SSL_CTRL_SET_MSG_CALLBACK: ctx->msg_callback = (void (*)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg))(fp); return (1); default: return (ctx->method->ssl_ctx_callback_ctrl(ctx, cmd, fp)); } } int ssl_cipher_id_cmp(const SSL_CIPHER *a, const SSL_CIPHER *b) { long l; l = a->id - b->id; if (l == 0L) return (0); else return ((l > 0) ? 1:-1); } int ssl_cipher_ptr_id_cmp(const SSL_CIPHER * const *ap, const SSL_CIPHER * const *bp) { long l; l = (*ap)->id - (*bp)->id; if (l == 0L) return (0); else return ((l > 0) ? 1:-1); } /* * Return a STACK of the ciphers available for the SSL and in order of * preference. */ STACK_OF(SSL_CIPHER) * SSL_get_ciphers(const SSL *s) { if (s != NULL) { if (s->cipher_list != NULL) { return (s->cipher_list); } else if ((s->ctx != NULL) && (s->ctx->cipher_list != NULL)) { return (s->ctx->cipher_list); } } return (NULL); } /* * Return a STACK of the ciphers available for the SSL and in order of * algorithm id. */ STACK_OF(SSL_CIPHER) * ssl_get_ciphers_by_id(SSL *s) { if (s != NULL) { if (s->cipher_list_by_id != NULL) { return (s->cipher_list_by_id); } else if ((s->ctx != NULL) && (s->ctx->cipher_list_by_id != NULL)) { return (s->ctx->cipher_list_by_id); } } return (NULL); } /* The old interface to get the same thing as SSL_get_ciphers(). */ const char * SSL_get_cipher_list(const SSL *s, int n) { SSL_CIPHER *c; STACK_OF(SSL_CIPHER) *sk; if (s == NULL) return (NULL); sk = SSL_get_ciphers(s); if ((sk == NULL) || (sk_SSL_CIPHER_num(sk) <= n)) return (NULL); c = sk_SSL_CIPHER_value(sk, n); if (c == NULL) return (NULL); return (c->name); } /* Specify the ciphers to be used by default by the SSL_CTX. */ int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str) { STACK_OF(SSL_CIPHER) *sk; sk = ssl_create_cipher_list(ctx->method, &ctx->cipher_list, &ctx->cipher_list_by_id, str); /* * ssl_create_cipher_list may return an empty stack if it * was unable to find a cipher matching the given rule string * (for example if the rule string specifies a cipher which * has been disabled). This is not an error as far as * ssl_create_cipher_list is concerned, and hence * ctx->cipher_list and ctx->cipher_list_by_id has been * updated. */ if (sk == NULL) return (0); else if (sk_SSL_CIPHER_num(sk) == 0) { SSLerr(SSL_F_SSL_CTX_SET_CIPHER_LIST, SSL_R_NO_CIPHER_MATCH); return (0); } return (1); } /* Specify the ciphers to be used by the SSL. */ int SSL_set_cipher_list(SSL *s, const char *str) { STACK_OF(SSL_CIPHER) *sk; sk = ssl_create_cipher_list(s->ctx->method, &s->cipher_list, &s->cipher_list_by_id, str); /* see comment in SSL_CTX_set_cipher_list */ if (sk == NULL) return (0); else if (sk_SSL_CIPHER_num(sk) == 0) { SSLerr(SSL_F_SSL_SET_CIPHER_LIST, SSL_R_NO_CIPHER_MATCH); return (0); } return (1); } /* works well for SSLv2, not so good for SSLv3 */ char * SSL_get_shared_ciphers(const SSL *s, char *buf, int len) { char *end; STACK_OF(SSL_CIPHER) *sk; SSL_CIPHER *c; size_t curlen = 0; int i; if ((s->session == NULL) || (s->session->ciphers == NULL) || (len < 2)) return (NULL); sk = s->session->ciphers; buf[0] = '\0'; for (i = 0; i < sk_SSL_CIPHER_num(sk); i++) { c = sk_SSL_CIPHER_value(sk, i); end = buf + curlen; if (strlcat(buf, c->name, len) >= len || (curlen = strlcat(buf, ":", len)) >= len) { /* remove truncated cipher from list */ *end = '\0'; break; } } /* remove trailing colon */ if ((end = strrchr(buf, ':')) != NULL) *end = '\0'; return (buf); } int ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *sk, unsigned char *p, int (*put_cb)(const SSL_CIPHER *, unsigned char *)) { int i, j = 0; SSL_CIPHER *c; unsigned char *q; if (sk == NULL) return (0); q = p; for (i = 0; i < sk_SSL_CIPHER_num(sk); i++) { c = sk_SSL_CIPHER_value(sk, i); /* Skip TLS v1.2 only ciphersuites if lower than v1.2 */ if ((c->algorithm_ssl & SSL_TLSV1_2) && (TLS1_get_client_version(s) < TLS1_2_VERSION)) continue; j = put_cb ? put_cb(c, p) : ssl_put_cipher_by_char(s, c, p); p += j; } /* * If p == q, no ciphers and caller indicates an error. Otherwise * add SCSV if not renegotiating. */ if (p != q && !s->renegotiate) { static SSL_CIPHER scsv = { 0, NULL, SSL3_CK_SCSV, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; j = put_cb ? put_cb(&scsv, p) : ssl_put_cipher_by_char(s, &scsv, p); p += j; } return (p - q); } STACK_OF(SSL_CIPHER) * ssl_bytes_to_cipher_list(SSL *s, unsigned char *p, int num, STACK_OF(SSL_CIPHER) **skp) { const SSL_CIPHER *c; STACK_OF(SSL_CIPHER) *sk; int i, n; if (s->s3) s->s3->send_connection_binding = 0; n = ssl_put_cipher_by_char(s, NULL, NULL); if ((num % n) != 0) { SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST); return (NULL); } if ((skp == NULL) || (*skp == NULL)) sk=sk_SSL_CIPHER_new_null(); /* change perhaps later */ else { sk= *skp; sk_SSL_CIPHER_zero(sk); } for (i = 0; i < num; i += n) { /* Check for SCSV */ if (s->s3 && (n != 3 || !p[0]) && (p[n - 2] == ((SSL3_CK_SCSV >> 8) & 0xff)) && (p[n - 1] == (SSL3_CK_SCSV & 0xff))) { /* SCSV fatal if renegotiating */ if (s->renegotiate) { SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING); ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); goto err; } s->s3->send_connection_binding = 1; p += n; continue; } c = ssl_get_cipher_by_char(s, p); p += n; if (c != NULL) { if (!sk_SSL_CIPHER_push(sk, c)) { SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE); goto err; } } } if (skp != NULL) *skp = sk; return (sk); err: if ((skp == NULL) || (*skp == NULL)) sk_SSL_CIPHER_free(sk); return (NULL); } /* * Return a servername extension value if provided in Client Hello, or NULL. * So far, only host_name types are defined (RFC 3546). */ const char * SSL_get_servername(const SSL *s, const int type) { if (type != TLSEXT_NAMETYPE_host_name) return (NULL); return (s->session && !s->tlsext_hostname ? s->session->tlsext_hostname : s->tlsext_hostname); } int SSL_get_servername_type(const SSL *s) { if (s->session && (!s->tlsext_hostname ? s->session->tlsext_hostname : s->tlsext_hostname)) return (TLSEXT_NAMETYPE_host_name); return (-1); } # ifndef OPENSSL_NO_NEXTPROTONEG /* * SSL_select_next_proto implements the standard protocol selection. It is * expected that this function is called from the callback set by * SSL_CTX_set_next_proto_select_cb. * * The protocol data is assumed to be a vector of 8-bit, length prefixed byte * strings. The length byte itself is not included in the length. A byte * string of length 0 is invalid. No byte string may be truncated. * * The current, but experimental algorithm for selecting the protocol is: * * 1) If the server doesn't support NPN then this is indicated to the * callback. In this case, the client application has to abort the connection * or have a default application level protocol. * * 2) If the server supports NPN, but advertises an empty list then the * client selects the first protcol in its list, but indicates via the * API that this fallback case was enacted. * * 3) Otherwise, the client finds the first protocol in the server's list * that it supports and selects this protocol. This is because it's * assumed that the server has better information about which protocol * a client should use. * * 4) If the client doesn't support any of the server's advertised * protocols, then this is treated the same as case 2. * * It returns either * OPENSSL_NPN_NEGOTIATED if a common protocol was found, or * OPENSSL_NPN_NO_OVERLAP if the fallback case was reached. */ int SSL_select_next_proto(unsigned char **out, unsigned char *outlen, const unsigned char *server, unsigned int server_len, const unsigned char *client, unsigned int client_len) { unsigned int i, j; const unsigned char *result; int status = OPENSSL_NPN_UNSUPPORTED; /* * For each protocol in server preference order, * see if we support it. */ for (i = 0; i < server_len; ) { for (j = 0; j < client_len; ) { if (server[i] == client[j] && memcmp(&server[i + 1], &client[j + 1], server[i]) == 0) { /* We found a match */ result = &server[i]; status = OPENSSL_NPN_NEGOTIATED; goto found; } j += client[j]; j++; } i += server[i]; i++; } /* There's no overlap between our protocols and the server's list. */ result = client; status = OPENSSL_NPN_NO_OVERLAP; found: *out = (unsigned char *) result + 1; *outlen = result[0]; return (status); } /* * SSL_get0_next_proto_negotiated sets *data and *len to point to the client's * requested protocol for this connection and returns 0. If the client didn't * request any protocol, then *data is set to NULL. * * Note that the client can request any protocol it chooses. The value returned * from this function need not be a member of the list of supported protocols * provided by the callback. */ void SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data, unsigned *len) { *data = s->next_proto_negotiated; if (!*data) { *len = 0; } else { *len = s->next_proto_negotiated_len; } } /* * SSL_CTX_set_next_protos_advertised_cb sets a callback that is called when a * TLS server needs a list of supported protocols for Next Protocol * Negotiation. The returned list must be in wire format. The list is returned * by setting |out| to point to it and |outlen| to its length. This memory will * not be modified, but one should assume that the SSL* keeps a reference to * it. * * The callback should return SSL_TLSEXT_ERR_OK if it wishes to advertise. * Otherwise, no such extension will be included in the ServerHello. */ void SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *ctx, int (*cb) (SSL *ssl, const unsigned char **out, unsigned int *outlen, void *arg), void *arg) { ctx->next_protos_advertised_cb = cb; ctx->next_protos_advertised_cb_arg = arg; } /* * SSL_CTX_set_next_proto_select_cb sets a callback that is called when a * client needs to select a protocol from the server's provided list. |out| * must be set to point to the selected protocol (which may be within |in|). * The length of the protocol name must be written into |outlen|. The server's * advertised protocols are provided in |in| and |inlen|. The callback can * assume that |in| is syntactically valid. * * The client must select a protocol. It is fatal to the connection if this * callback returns a value other than SSL_TLSEXT_ERR_OK. */ void SSL_CTX_set_next_proto_select_cb(SSL_CTX *ctx, int (*cb) (SSL *s, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg), void *arg) { ctx->next_proto_select_cb = cb; ctx->next_proto_select_cb_arg = arg; } # endif int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen, const char *label, size_t llen, const unsigned char *p, size_t plen, int use_context) { if (s->version < TLS1_VERSION) return (-1); return (s->method->ssl3_enc->export_keying_material(s, out, olen, label, llen, p, plen, use_context)); } static unsigned long ssl_session_hash(const SSL_SESSION *a) { unsigned long l; l = (unsigned long) ((unsigned int) a->session_id[0] )| ((unsigned int) a->session_id[1]<< 8L)| ((unsigned long)a->session_id[2]<<16L)| ((unsigned long)a->session_id[3]<<24L); return (l); } /* * NB: If this function (or indeed the hash function which uses a sort of * coarser function than this one) is changed, ensure * SSL_CTX_has_matching_session_id() is checked accordingly. It relies on being * able to construct an SSL_SESSION that will collide with any existing session * with a matching session ID. */ static int ssl_session_cmp(const SSL_SESSION *a, const SSL_SESSION *b) { if (a->ssl_version != b->ssl_version) return (1); if (a->session_id_length != b->session_id_length) return (1); if (timingsafe_memcmp(a->session_id, b->session_id, a->session_id_length) != 0) return (1); return (0); } /* * These wrapper functions should remain rather than redeclaring * SSL_SESSION_hash and SSL_SESSION_cmp for void* types and casting each * variable. The reason is that the functions aren't static, they're exposed via * ssl.h. */ static IMPLEMENT_LHASH_HASH_FN(ssl_session, SSL_SESSION) static IMPLEMENT_LHASH_COMP_FN(ssl_session, SSL_SESSION) SSL_CTX * SSL_CTX_new(const SSL_METHOD *meth) { SSL_CTX *ret = NULL; if (meth == NULL) { SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_NULL_SSL_METHOD_PASSED); return (NULL); } if (SSL_get_ex_data_X509_STORE_CTX_idx() < 0) { SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_X509_VERIFICATION_SETUP_PROBLEMS); goto err; } ret = calloc(1, sizeof(SSL_CTX)); if (ret == NULL) goto err; ret->method = meth; ret->cert_store = NULL; ret->session_cache_mode = SSL_SESS_CACHE_SERVER; ret->session_cache_size = SSL_SESSION_CACHE_MAX_SIZE_DEFAULT; ret->session_cache_head = NULL; ret->session_cache_tail = NULL; /* We take the system default */ ret->session_timeout = meth->get_timeout(); ret->new_session_cb = 0; ret->remove_session_cb = 0; ret->get_session_cb = 0; ret->generate_session_id = 0; memset((char *)&ret->stats, 0, sizeof(ret->stats)); ret->references = 1; ret->quiet_shutdown = 0; ret->info_callback = NULL; ret->app_verify_callback = 0; ret->app_verify_arg = NULL; ret->max_cert_list = SSL_MAX_CERT_LIST_DEFAULT; ret->read_ahead = 0; ret->msg_callback = 0; ret->msg_callback_arg = NULL; ret->verify_mode = SSL_VERIFY_NONE; ret->sid_ctx_length = 0; ret->default_verify_callback = NULL; if ((ret->cert = ssl_cert_new()) == NULL) goto err; ret->default_passwd_callback = 0; ret->default_passwd_callback_userdata = NULL; ret->client_cert_cb = 0; ret->app_gen_cookie_cb = 0; ret->app_verify_cookie_cb = 0; ret->sessions = lh_SSL_SESSION_new(); if (ret->sessions == NULL) goto err; ret->cert_store = X509_STORE_new(); if (ret->cert_store == NULL) goto err; ssl_create_cipher_list(ret->method, &ret->cipher_list, &ret->cipher_list_by_id, SSL_DEFAULT_CIPHER_LIST); if (ret->cipher_list == NULL || sk_SSL_CIPHER_num(ret->cipher_list) <= 0) { SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_LIBRARY_HAS_NO_CIPHERS); goto err2; } ret->param = X509_VERIFY_PARAM_new(); if (!ret->param) goto err; if ((ret->md5 = EVP_get_digestbyname("ssl3-md5")) == NULL) { SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES); goto err2; } if ((ret->sha1 = EVP_get_digestbyname("ssl3-sha1")) == NULL) { SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES); goto err2; } if ((ret->client_CA = sk_X509_NAME_new_null()) == NULL) goto err; CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_CTX, ret, &ret->ex_data); ret->extra_certs = NULL; ret->max_send_fragment = SSL3_RT_MAX_PLAIN_LENGTH; ret->tlsext_servername_callback = 0; ret->tlsext_servername_arg = NULL; /* Setup RFC4507 ticket keys */ if ((RAND_pseudo_bytes(ret->tlsext_tick_key_name, 16) <= 0) || (RAND_bytes(ret->tlsext_tick_hmac_key, 16) <= 0) || (RAND_bytes(ret->tlsext_tick_aes_key, 16) <= 0)) ret->options |= SSL_OP_NO_TICKET; ret->tlsext_status_cb = 0; ret->tlsext_status_arg = NULL; # ifndef OPENSSL_NO_NEXTPROTONEG ret->next_protos_advertised_cb = 0; ret->next_proto_select_cb = 0; # endif #ifndef OPENSSL_NO_ENGINE ret->client_cert_engine = NULL; #ifdef OPENSSL_SSL_CLIENT_ENGINE_AUTO #define eng_strx(x) #x #define eng_str(x) eng_strx(x) /* Use specific client engine automatically... ignore errors */ { ENGINE *eng; eng = ENGINE_by_id(eng_str(OPENSSL_SSL_CLIENT_ENGINE_AUTO)); if (!eng) { ERR_clear_error(); ENGINE_load_builtin_engines(); eng = ENGINE_by_id(eng_str( OPENSSL_SSL_CLIENT_ENGINE_AUTO)); } if (!eng || !SSL_CTX_set_client_cert_engine(ret, eng)) ERR_clear_error(); } #endif #endif /* * Default is to connect to non-RI servers. When RI is more widely * deployed might change this. */ ret->options |= SSL_OP_LEGACY_SERVER_CONNECT; return (ret); err: SSLerr(SSL_F_SSL_CTX_NEW, ERR_R_MALLOC_FAILURE); err2: if (ret != NULL) SSL_CTX_free(ret); return (NULL); } void SSL_CTX_free(SSL_CTX *a) { int i; if (a == NULL) return; i = CRYPTO_add(&a->references, -1, CRYPTO_LOCK_SSL_CTX); if (i > 0) return; if (a->param) X509_VERIFY_PARAM_free(a->param); /* * Free internal session cache. However: the remove_cb() may reference * the ex_data of SSL_CTX, thus the ex_data store can only be removed * after the sessions were flushed. * As the ex_data handling routines might also touch the session cache, * the most secure solution seems to be: empty (flush) the cache, then * free ex_data, then finally free the cache. * (See ticket [openssl.org #212].) */ if (a->sessions != NULL) SSL_CTX_flush_sessions(a, 0); CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data); if (a->sessions != NULL) lh_SSL_SESSION_free(a->sessions); if (a->cert_store != NULL) X509_STORE_free(a->cert_store); if (a->cipher_list != NULL) sk_SSL_CIPHER_free(a->cipher_list); if (a->cipher_list_by_id != NULL) sk_SSL_CIPHER_free(a->cipher_list_by_id); if (a->cert != NULL) ssl_cert_free(a->cert); if (a->client_CA != NULL) sk_X509_NAME_pop_free(a->client_CA, X509_NAME_free); if (a->extra_certs != NULL) sk_X509_pop_free(a->extra_certs, X509_free); #ifndef OPENSSL_NO_SRTP if (a->srtp_profiles) sk_SRTP_PROTECTION_PROFILE_free(a->srtp_profiles); #endif #ifndef OPENSSL_NO_ENGINE if (a->client_cert_engine) ENGINE_finish(a->client_cert_engine); #endif free(a); } void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb) { ctx->default_passwd_callback = cb; } void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u) { ctx->default_passwd_callback_userdata = u; } void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *, void *), void *arg) { ctx->app_verify_callback = cb; ctx->app_verify_arg = arg; } void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, int (*cb)(int, X509_STORE_CTX *)) { ctx->verify_mode = mode; ctx->default_verify_callback = cb; } void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth) { X509_VERIFY_PARAM_set_depth(ctx->param, depth); } void ssl_set_cert_masks(CERT *c, const SSL_CIPHER *cipher) { CERT_PKEY *cpk; int rsa_enc, rsa_tmp, rsa_sign, dh_tmp, dh_rsa, dh_dsa, dsa_sign; unsigned long mask_k, mask_a; int have_ecc_cert, ecdh_ok, ecdsa_ok; int have_ecdh_tmp; X509 *x = NULL; EVP_PKEY *ecc_pkey = NULL; int signature_nid = 0, pk_nid = 0, md_nid = 0; if (c == NULL) return; rsa_tmp = (c->rsa_tmp != NULL || c->rsa_tmp_cb != NULL); dh_tmp = (c->dh_tmp != NULL || c->dh_tmp_cb != NULL); have_ecdh_tmp = (c->ecdh_tmp != NULL || c->ecdh_tmp_cb != NULL); cpk = &(c->pkeys[SSL_PKEY_RSA_ENC]); rsa_enc = (cpk->x509 != NULL && cpk->privatekey != NULL); cpk = &(c->pkeys[SSL_PKEY_RSA_SIGN]); rsa_sign = (cpk->x509 != NULL && cpk->privatekey != NULL); cpk = &(c->pkeys[SSL_PKEY_DSA_SIGN]); dsa_sign = (cpk->x509 != NULL && cpk->privatekey != NULL); cpk = &(c->pkeys[SSL_PKEY_DH_RSA]); dh_rsa = (cpk->x509 != NULL && cpk->privatekey != NULL); cpk = &(c->pkeys[SSL_PKEY_DH_DSA]); /* FIX THIS EAY EAY EAY */ dh_dsa = (cpk->x509 != NULL && cpk->privatekey != NULL); cpk = &(c->pkeys[SSL_PKEY_ECC]); have_ecc_cert = (cpk->x509 != NULL && cpk->privatekey != NULL); mask_k = 0; mask_a = 0; cpk = &(c->pkeys[SSL_PKEY_GOST01]); if (cpk->x509 != NULL && cpk->privatekey !=NULL) { mask_k |= SSL_kGOST; mask_a |= SSL_aGOST01; } cpk = &(c->pkeys[SSL_PKEY_GOST94]); if (cpk->x509 != NULL && cpk->privatekey !=NULL) { mask_k |= SSL_kGOST; mask_a |= SSL_aGOST94; } if (rsa_enc || (rsa_tmp && rsa_sign)) mask_k|=SSL_kRSA; if (dh_tmp) mask_k|=SSL_kEDH; if (dh_rsa) mask_k|=SSL_kDHr; if (dh_dsa) mask_k|=SSL_kDHd; if (rsa_enc || rsa_sign) mask_a|=SSL_aRSA; if (dsa_sign) mask_a|=SSL_aDSS; mask_a|=SSL_aNULL; /* * An ECC certificate may be usable for ECDH and/or * ECDSA cipher suites depending on the key usage extension. */ if (have_ecc_cert) { /* This call populates extension flags (ex_flags) */ x = (c->pkeys[SSL_PKEY_ECC]).x509; X509_check_purpose(x, -1, 0); ecdh_ok = (x->ex_flags & EXFLAG_KUSAGE) ? (x->ex_kusage & X509v3_KU_KEY_AGREEMENT) : 1; ecdsa_ok = (x->ex_flags & EXFLAG_KUSAGE) ? (x->ex_kusage & X509v3_KU_DIGITAL_SIGNATURE) : 1; ecc_pkey = X509_get_pubkey(x); EVP_PKEY_free(ecc_pkey); if ((x->sig_alg) && (x->sig_alg->algorithm)) { signature_nid = OBJ_obj2nid(x->sig_alg->algorithm); OBJ_find_sigid_algs(signature_nid, &md_nid, &pk_nid); } if (ecdh_ok) { if (pk_nid == NID_rsaEncryption || pk_nid == NID_rsa) { mask_k|=SSL_kECDHr; mask_a|=SSL_aECDH; } if (pk_nid == NID_X9_62_id_ecPublicKey) { mask_k|=SSL_kECDHe; mask_a|=SSL_aECDH; } } if (ecdsa_ok) mask_a|=SSL_aECDSA; } if (have_ecdh_tmp) { mask_k|=SSL_kEECDH; } c->mask_k = mask_k; c->mask_a = mask_a; c->valid = 1; } /* This handy macro borrowed from crypto/x509v3/v3_purp.c */ #define ku_reject(x, usage) \ (((x)->ex_flags & EXFLAG_KUSAGE) && !((x)->ex_kusage & (usage))) int ssl_check_srvr_ecc_cert_and_alg(X509 *x, SSL *s) { unsigned long alg_k, alg_a; int signature_nid = 0, md_nid = 0, pk_nid = 0; const SSL_CIPHER *cs = s->s3->tmp.new_cipher; alg_k = cs->algorithm_mkey; alg_a = cs->algorithm_auth; /* This call populates the ex_flags field correctly */ X509_check_purpose(x, -1, 0); if ((x->sig_alg) && (x->sig_alg->algorithm)) { signature_nid = OBJ_obj2nid(x->sig_alg->algorithm); OBJ_find_sigid_algs(signature_nid, &md_nid, &pk_nid); } if (alg_k & SSL_kECDHe || alg_k & SSL_kECDHr) { /* key usage, if present, must allow key agreement */ if (ku_reject(x, X509v3_KU_KEY_AGREEMENT)) { SSLerr(SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG, SSL_R_ECC_CERT_NOT_FOR_KEY_AGREEMENT); return (0); } if ((alg_k & SSL_kECDHe) && TLS1_get_version(s) < TLS1_2_VERSION) { /* signature alg must be ECDSA */ if (pk_nid != NID_X9_62_id_ecPublicKey) { SSLerr(SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG, SSL_R_ECC_CERT_SHOULD_HAVE_SHA1_SIGNATURE); return (0); } } if ((alg_k & SSL_kECDHr) && TLS1_get_version(s) < TLS1_2_VERSION) { /* signature alg must be RSA */ if (pk_nid != NID_rsaEncryption && pk_nid != NID_rsa) { SSLerr(SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG, SSL_R_ECC_CERT_SHOULD_HAVE_RSA_SIGNATURE); return (0); } } } if (alg_a & SSL_aECDSA) { /* key usage, if present, must allow signing */ if (ku_reject(x, X509v3_KU_DIGITAL_SIGNATURE)) { SSLerr(SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG, SSL_R_ECC_CERT_NOT_FOR_SIGNING); return (0); } } return (1); /* all checks are ok */ } /* THIS NEEDS CLEANING UP */ CERT_PKEY * ssl_get_server_send_pkey(const SSL *s) { unsigned long alg_k, alg_a; CERT *c; int i; c = s->cert; ssl_set_cert_masks(c, s->s3->tmp.new_cipher); alg_k = s->s3->tmp.new_cipher->algorithm_mkey; alg_a = s->s3->tmp.new_cipher->algorithm_auth; if (alg_k & (SSL_kECDHr|SSL_kECDHe)) { /* * We don't need to look at SSL_kEECDH * since no certificate is needed for * anon ECDH and for authenticated * EECDH, the check for the auth * algorithm will set i correctly * NOTE: For ECDH-RSA, we need an ECC * not an RSA cert but for EECDH-RSA * we need an RSA cert. Placing the * checks for SSL_kECDH before RSA * checks ensures the correct cert is chosen. */ i = SSL_PKEY_ECC; } else if (alg_a & SSL_aECDSA) { i = SSL_PKEY_ECC; } else if (alg_k & SSL_kDHr) { i = SSL_PKEY_DH_RSA; } else if (alg_k & SSL_kDHd) { i = SSL_PKEY_DH_DSA; } else if (alg_a & SSL_aDSS) { i = SSL_PKEY_DSA_SIGN; } else if (alg_a & SSL_aRSA) { if (c->pkeys[SSL_PKEY_RSA_ENC].x509 == NULL) i = SSL_PKEY_RSA_SIGN; else i = SSL_PKEY_RSA_ENC; } else if (alg_a & SSL_aKRB5) { /* VRS something else here? */ return (NULL); } else if (alg_a & SSL_aGOST94) { i = SSL_PKEY_GOST94; } else if (alg_a & SSL_aGOST01) { i = SSL_PKEY_GOST01; } else { /* if (alg_a & SSL_aNULL) */ SSLerr(SSL_F_SSL_GET_SERVER_SEND_PKEY, ERR_R_INTERNAL_ERROR); return (NULL); } return (c->pkeys + i); } X509 * ssl_get_server_send_cert(const SSL *s) { CERT_PKEY *cpk; cpk = ssl_get_server_send_pkey(s); if (!cpk) return (NULL); return (cpk->x509); } EVP_PKEY * ssl_get_sign_pkey(SSL *s, const SSL_CIPHER *cipher, const EVP_MD **pmd) { unsigned long alg_a; CERT *c; int idx = -1; alg_a = cipher->algorithm_auth; c = s->cert; if ((alg_a & SSL_aDSS) && (c->pkeys[SSL_PKEY_DSA_SIGN].privatekey != NULL)) idx = SSL_PKEY_DSA_SIGN; else if (alg_a & SSL_aRSA) { if (c->pkeys[SSL_PKEY_RSA_SIGN].privatekey != NULL) idx = SSL_PKEY_RSA_SIGN; else if (c->pkeys[SSL_PKEY_RSA_ENC].privatekey != NULL) idx = SSL_PKEY_RSA_ENC; } else if ((alg_a & SSL_aECDSA) && (c->pkeys[SSL_PKEY_ECC].privatekey != NULL)) idx = SSL_PKEY_ECC; if (idx == -1) { SSLerr(SSL_F_SSL_GET_SIGN_PKEY, ERR_R_INTERNAL_ERROR); return (NULL); } if (pmd) *pmd = c->pkeys[idx].digest; return (c->pkeys[idx].privatekey); } void ssl_update_cache(SSL *s, int mode) { int i; /* * If the session_id_length is 0, we are not supposed to cache it, * and it would be rather hard to do anyway :-) */ if (s->session->session_id_length == 0) return; i = s->session_ctx->session_cache_mode; if ((i & mode) && (!s->hit) && ((i & SSL_SESS_CACHE_NO_INTERNAL_STORE) || SSL_CTX_add_session(s->session_ctx, s->session)) && (s->session_ctx->new_session_cb != NULL)) { CRYPTO_add(&s->session->references, 1, CRYPTO_LOCK_SSL_SESSION); if (!s->session_ctx->new_session_cb(s, s->session)) SSL_SESSION_free(s->session); } /* auto flush every 255 connections */ if ((!(i & SSL_SESS_CACHE_NO_AUTO_CLEAR)) && ((i & mode) == mode)) { if ((((mode & SSL_SESS_CACHE_CLIENT) ? s->session_ctx->stats.sess_connect_good : s->session_ctx->stats.sess_accept_good) & 0xff) == 0xff) { SSL_CTX_flush_sessions(s->session_ctx, time(NULL)); } } } const SSL_METHOD * SSL_get_ssl_method(SSL *s) { return (s->method); } int SSL_set_ssl_method(SSL *s, const SSL_METHOD *meth) { int conn = -1; int ret = 1; if (s->method != meth) { if (s->handshake_func != NULL) conn = (s->handshake_func == s->method->ssl_connect); if (s->method->version == meth->version) s->method = meth; else { s->method->ssl_free(s); s->method = meth; ret = s->method->ssl_new(s); } if (conn == 1) s->handshake_func = meth->ssl_connect; else if (conn == 0) s->handshake_func = meth->ssl_accept; } return (ret); } int SSL_get_error(const SSL *s, int i) { int reason; unsigned long l; BIO *bio; if (i > 0) return (SSL_ERROR_NONE); /* Make things return SSL_ERROR_SYSCALL when doing SSL_do_handshake * etc, where we do encode the error */ if ((l = ERR_peek_error()) != 0) { if (ERR_GET_LIB(l) == ERR_LIB_SYS) return (SSL_ERROR_SYSCALL); else return (SSL_ERROR_SSL); } if ((i < 0) && SSL_want_read(s)) { bio = SSL_get_rbio(s); if (BIO_should_read(bio)) { return (SSL_ERROR_WANT_READ); } else if (BIO_should_write(bio)) { /* * This one doesn't make too much sense... We never * try to write to the rbio, and an application * program where rbio and wbio are separate couldn't * even know what it should wait for. However if we * ever set s->rwstate incorrectly (so that we have * SSL_want_read(s) instead of SSL_want_write(s)) * and rbio and wbio *are* the same, this test works * around that bug; so it might be safer to keep it. */ return (SSL_ERROR_WANT_WRITE); } else if (BIO_should_io_special(bio)) { reason = BIO_get_retry_reason(bio); if (reason == BIO_RR_CONNECT) return (SSL_ERROR_WANT_CONNECT); else if (reason == BIO_RR_ACCEPT) return (SSL_ERROR_WANT_ACCEPT); else return (SSL_ERROR_SYSCALL); /* unknown */ } } if ((i < 0) && SSL_want_write(s)) { bio = SSL_get_wbio(s); if (BIO_should_write(bio)) { return (SSL_ERROR_WANT_WRITE); } else if (BIO_should_read(bio)) { /* * See above (SSL_want_read(s) with * BIO_should_write(bio)) */ return (SSL_ERROR_WANT_READ); } else if (BIO_should_io_special(bio)) { reason = BIO_get_retry_reason(bio); if (reason == BIO_RR_CONNECT) return (SSL_ERROR_WANT_CONNECT); else if (reason == BIO_RR_ACCEPT) return (SSL_ERROR_WANT_ACCEPT); else return (SSL_ERROR_SYSCALL); } } if ((i < 0) && SSL_want_x509_lookup(s)) { return (SSL_ERROR_WANT_X509_LOOKUP); } if (i == 0) { if ((s->shutdown & SSL_RECEIVED_SHUTDOWN) && (s->s3->warn_alert == SSL_AD_CLOSE_NOTIFY)) return (SSL_ERROR_ZERO_RETURN); } return (SSL_ERROR_SYSCALL); } int SSL_do_handshake(SSL *s) { int ret = 1; if (s->handshake_func == NULL) { SSLerr(SSL_F_SSL_DO_HANDSHAKE, SSL_R_CONNECTION_TYPE_NOT_SET); return (-1); } s->method->ssl_renegotiate_check(s); if (SSL_in_init(s) || SSL_in_before(s)) { ret = s->handshake_func(s); } return (ret); } /* * For the next 2 functions, SSL_clear() sets shutdown and so * one of these calls will reset it */ void SSL_set_accept_state(SSL *s) { s->server = 1; s->shutdown = 0; s->state = SSL_ST_ACCEPT|SSL_ST_BEFORE; s->handshake_func = s->method->ssl_accept; /* clear the current cipher */ ssl_clear_cipher_ctx(s); ssl_clear_hash_ctx(&s->read_hash); ssl_clear_hash_ctx(&s->write_hash); } void SSL_set_connect_state(SSL *s) { s->server = 0; s->shutdown = 0; s->state = SSL_ST_CONNECT|SSL_ST_BEFORE; s->handshake_func = s->method->ssl_connect; /* clear the current cipher */ ssl_clear_cipher_ctx(s); ssl_clear_hash_ctx(&s->read_hash); ssl_clear_hash_ctx(&s->write_hash); } int ssl_undefined_function(SSL *s) { SSLerr(SSL_F_SSL_UNDEFINED_FUNCTION, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return (0); } int ssl_undefined_void_function(void) { SSLerr(SSL_F_SSL_UNDEFINED_VOID_FUNCTION, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return (0); } int ssl_undefined_const_function(const SSL *s) { SSLerr(SSL_F_SSL_UNDEFINED_CONST_FUNCTION, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return (0); } SSL_METHOD * ssl_bad_method(int ver) { SSLerr(SSL_F_SSL_BAD_METHOD, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return (NULL); } const char * SSL_get_version(const SSL *s) { if (s->version == TLS1_2_VERSION) return ("TLSv1.2"); else if (s->version == TLS1_1_VERSION) return ("TLSv1.1"); else if (s->version == TLS1_VERSION) return ("TLSv1"); else if (s->version == SSL3_VERSION) return ("SSLv3"); else return ("unknown"); } SSL * SSL_dup(SSL *s) { STACK_OF(X509_NAME) *sk; X509_NAME *xn; SSL *ret; int i; if ((ret = SSL_new(SSL_get_SSL_CTX(s))) == NULL) return (NULL); ret->version = s->version; ret->type = s->type; ret->method = s->method; if (s->session != NULL) { /* This copies session-id, SSL_METHOD, sid_ctx, and 'cert' */ SSL_copy_session_id(ret, s); } else { /* * No session has been established yet, so we have to expect * that s->cert or ret->cert will be changed later -- * they should not both point to the same object, * and thus we can't use SSL_copy_session_id. */ ret->method->ssl_free(ret); ret->method = s->method; ret->method->ssl_new(ret); if (s->cert != NULL) { if (ret->cert != NULL) { ssl_cert_free(ret->cert); } ret->cert = ssl_cert_dup(s->cert); if (ret->cert == NULL) goto err; } SSL_set_session_id_context(ret, s->sid_ctx, s->sid_ctx_length); } ret->options = s->options; ret->mode = s->mode; SSL_set_max_cert_list(ret, SSL_get_max_cert_list(s)); SSL_set_read_ahead(ret, SSL_get_read_ahead(s)); ret->msg_callback = s->msg_callback; ret->msg_callback_arg = s->msg_callback_arg; SSL_set_verify(ret, SSL_get_verify_mode(s), SSL_get_verify_callback(s)); SSL_set_verify_depth(ret, SSL_get_verify_depth(s)); ret->generate_session_id = s->generate_session_id; SSL_set_info_callback(ret, SSL_get_info_callback(s)); ret->debug = s->debug; /* copy app data, a little dangerous perhaps */ if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_SSL, &ret->ex_data, &s->ex_data)) goto err; /* setup rbio, and wbio */ if (s->rbio != NULL) { if (!BIO_dup_state(s->rbio,(char *)&ret->rbio)) goto err; } if (s->wbio != NULL) { if (s->wbio != s->rbio) { if (!BIO_dup_state(s->wbio,(char *)&ret->wbio)) goto err; } else ret->wbio = ret->rbio; } ret->rwstate = s->rwstate; ret->in_handshake = s->in_handshake; ret->handshake_func = s->handshake_func; ret->server = s->server; ret->renegotiate = s->renegotiate; ret->new_session = s->new_session; ret->quiet_shutdown = s->quiet_shutdown; ret->shutdown = s->shutdown; /* SSL_dup does not really work at any state, though */ ret->state=s->state; ret->rstate = s->rstate; /* * Would have to copy ret->init_buf, ret->init_msg, ret->init_num, * ret->init_off */ ret->init_num = 0; ret->hit = s->hit; X509_VERIFY_PARAM_inherit(ret->param, s->param); /* dup the cipher_list and cipher_list_by_id stacks */ if (s->cipher_list != NULL) { if ((ret->cipher_list = sk_SSL_CIPHER_dup(s->cipher_list)) == NULL) goto err; } if (s->cipher_list_by_id != NULL) { if ((ret->cipher_list_by_id = sk_SSL_CIPHER_dup(s->cipher_list_by_id)) == NULL) goto err; } /* Dup the client_CA list */ if (s->client_CA != NULL) { if ((sk = sk_X509_NAME_dup(s->client_CA)) == NULL) goto err; ret->client_CA = sk; for (i = 0; i < sk_X509_NAME_num(sk); i++) { xn = sk_X509_NAME_value(sk, i); if (sk_X509_NAME_set(sk, i, X509_NAME_dup(xn)) == NULL) { X509_NAME_free(xn); goto err; } } } if (0) { err: if (ret != NULL) SSL_free(ret); ret = NULL; } return (ret); } void ssl_clear_cipher_ctx(SSL *s) { EVP_CIPHER_CTX_free(s->enc_read_ctx); s->enc_read_ctx = NULL; EVP_CIPHER_CTX_free(s->enc_write_ctx); s->enc_write_ctx = NULL; if (s->aead_read_ctx != NULL) { EVP_AEAD_CTX_cleanup(&s->aead_read_ctx->ctx); free(s->aead_read_ctx); s->aead_read_ctx = NULL; } if (s->aead_write_ctx != NULL) { EVP_AEAD_CTX_cleanup(&s->aead_write_ctx->ctx); free(s->aead_write_ctx); s->aead_write_ctx = NULL; } } /* Fix this function so that it takes an optional type parameter */ X509 * SSL_get_certificate(const SSL *s) { if (s->cert != NULL) return (s->cert->key->x509); else return (NULL); } /* Fix this function so that it takes an optional type parameter */ EVP_PKEY * SSL_get_privatekey(SSL *s) { if (s->cert != NULL) return (s->cert->key->privatekey); else return (NULL); } const SSL_CIPHER * SSL_get_current_cipher(const SSL *s) { if ((s->session != NULL) && (s->session->cipher != NULL)) return (s->session->cipher); return (NULL); } const void * SSL_get_current_compression(SSL *s) { return (NULL); } const void * SSL_get_current_expansion(SSL *s) { return (NULL); } int ssl_init_wbio_buffer(SSL *s, int push) { BIO *bbio; if (s->bbio == NULL) { bbio = BIO_new(BIO_f_buffer()); if (bbio == NULL) return (0); s->bbio = bbio; } else { bbio = s->bbio; if (s->bbio == s->wbio) s->wbio = BIO_pop(s->wbio); } (void)BIO_reset(bbio); /* if (!BIO_set_write_buffer_size(bbio,16*1024)) */ if (!BIO_set_read_buffer_size(bbio, 1)) { SSLerr(SSL_F_SSL_INIT_WBIO_BUFFER, ERR_R_BUF_LIB); return (0); } if (push) { if (s->wbio != bbio) s->wbio = BIO_push(bbio, s->wbio); } else { if (s->wbio == bbio) s->wbio = BIO_pop(bbio); } return (1); } void ssl_free_wbio_buffer(SSL *s) { if (s->bbio == NULL) return; if (s->bbio == s->wbio) { /* remove buffering */ s->wbio = BIO_pop(s->wbio); } BIO_free(s->bbio); s->bbio = NULL; } void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode) { ctx->quiet_shutdown = mode; } int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx) { return (ctx->quiet_shutdown); } void SSL_set_quiet_shutdown(SSL *s, int mode) { s->quiet_shutdown = mode; } int SSL_get_quiet_shutdown(const SSL *s) { return (s->quiet_shutdown); } void SSL_set_shutdown(SSL *s, int mode) { s->shutdown = mode; } int SSL_get_shutdown(const SSL *s) { return (s->shutdown); } int SSL_version(const SSL *s) { return (s->version); } SSL_CTX * SSL_get_SSL_CTX(const SSL *ssl) { return (ssl->ctx); } SSL_CTX * SSL_set_SSL_CTX(SSL *ssl, SSL_CTX* ctx) { if (ssl->ctx == ctx) return (ssl->ctx); if (ctx == NULL) ctx = ssl->initial_ctx; if (ssl->cert != NULL) ssl_cert_free(ssl->cert); ssl->cert = ssl_cert_dup(ctx->cert); CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX); if (ssl->ctx != NULL) SSL_CTX_free(ssl->ctx); /* decrement reference count */ ssl->ctx = ctx; return (ssl->ctx); } int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx) { return (X509_STORE_set_default_paths(ctx->cert_store)); } int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, const char *CApath) { return (X509_STORE_load_locations(ctx->cert_store, CAfile, CApath)); } void SSL_set_info_callback(SSL *ssl, void (*cb)(const SSL *ssl, int type, int val)) { ssl->info_callback = cb; } void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl, int type, int val) { return (ssl->info_callback); } int SSL_state(const SSL *ssl) { return (ssl->state); } void SSL_set_state(SSL *ssl, int state) { ssl->state = state; } void SSL_set_verify_result(SSL *ssl, long arg) { ssl->verify_result = arg; } long SSL_get_verify_result(const SSL *ssl) { return (ssl->verify_result); } int SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { return (CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, argl, argp, new_func, dup_func, free_func)); } int SSL_set_ex_data(SSL *s, int idx, void *arg) { return (CRYPTO_set_ex_data(&s->ex_data, idx, arg)); } void * SSL_get_ex_data(const SSL *s, int idx) { return (CRYPTO_get_ex_data(&s->ex_data, idx)); } int SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { return (CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_CTX, argl, argp, new_func, dup_func, free_func)); } int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg) { return (CRYPTO_set_ex_data(&s->ex_data, idx, arg)); } void * SSL_CTX_get_ex_data(const SSL_CTX *s, int idx) { return (CRYPTO_get_ex_data(&s->ex_data, idx)); } int ssl_ok(SSL *s) { return (1); } X509_STORE * SSL_CTX_get_cert_store(const SSL_CTX *ctx) { return (ctx->cert_store); } void SSL_CTX_set_cert_store(SSL_CTX *ctx, X509_STORE *store) { if (ctx->cert_store != NULL) X509_STORE_free(ctx->cert_store); ctx->cert_store = store; } int SSL_want(const SSL *s) { return (s->rwstate); } void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx, RSA *(*cb)(SSL *ssl, int is_export, int keylength)) { SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_TMP_RSA_CB,(void (*)(void))cb); } void SSL_set_tmp_rsa_callback(SSL *ssl, RSA *(*cb)(SSL *ssl, int is_export, int keylength)) { SSL_callback_ctrl(ssl, SSL_CTRL_SET_TMP_RSA_CB,(void (*)(void))cb); } void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, DH *(*dh)(SSL *ssl, int is_export, int keylength)) { SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_TMP_DH_CB,(void (*)(void))dh); } void SSL_set_tmp_dh_callback(SSL *ssl, DH *(*dh)(SSL *ssl, int is_export, int keylength)) { SSL_callback_ctrl(ssl, SSL_CTRL_SET_TMP_DH_CB,(void (*)(void))dh); } void SSL_CTX_set_tmp_ecdh_callback(SSL_CTX *ctx, EC_KEY *(*ecdh)(SSL *ssl, int is_export, int keylength)) { SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_TMP_ECDH_CB, (void (*)(void))ecdh); } void SSL_set_tmp_ecdh_callback(SSL *ssl, EC_KEY *(*ecdh)(SSL *ssl, int is_export, int keylength)) { SSL_callback_ctrl(ssl, SSL_CTRL_SET_TMP_ECDH_CB,(void (*)(void))ecdh); } void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)) { SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_MSG_CALLBACK, (void (*)(void))cb); } void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)) { SSL_callback_ctrl(ssl, SSL_CTRL_SET_MSG_CALLBACK, (void (*)(void))cb); } /* * Allocates new EVP_MD_CTX and sets pointer to it into given pointer * variable, freeing EVP_MD_CTX previously stored in that variable, if * any. If EVP_MD pointer is passed, initializes ctx with this md * Returns newly allocated ctx; */ EVP_MD_CTX * ssl_replace_hash(EVP_MD_CTX **hash, const EVP_MD *md) { ssl_clear_hash_ctx(hash); *hash = EVP_MD_CTX_create(); if (*hash != NULL && md != NULL) EVP_DigestInit_ex(*hash, md, NULL); return (*hash); } void ssl_clear_hash_ctx(EVP_MD_CTX **hash) { if (*hash) EVP_MD_CTX_destroy(*hash); *hash = NULL; } void SSL_set_debug(SSL *s, int debug) { s->debug = debug; } int SSL_cache_hit(SSL *s) { return (s->hit); } IMPLEMENT_STACK_OF(SSL_CIPHER) IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(SSL_CIPHER, SSL_CIPHER, ssl_cipher_id); deps/libressl-pnacl-sys-2.1.6/libressl/ssl/d1_srvr.c0000644000175000017500000012472512360020705017273 0ustar /* $OpenBSD: d1_srvr.c,v 1.29 2014/07/10 08:51:14 tedu Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "ssl_locl.h" #include #include #include #include #include #include #include #include static const SSL_METHOD *dtls1_get_server_method(int ver); static int dtls1_send_hello_verify_request(SSL *s); const SSL_METHOD DTLSv1_server_method_data = { .version = DTLS1_VERSION, .ssl_new = dtls1_new, .ssl_clear = dtls1_clear, .ssl_free = dtls1_free, .ssl_accept = dtls1_accept, .ssl_connect = ssl_undefined_function, .ssl_read = ssl3_read, .ssl_peek = ssl3_peek, .ssl_write = ssl3_write, .ssl_shutdown = dtls1_shutdown, .ssl_renegotiate = ssl3_renegotiate, .ssl_renegotiate_check = ssl3_renegotiate_check, .ssl_get_message = dtls1_get_message, .ssl_read_bytes = dtls1_read_bytes, .ssl_write_bytes = dtls1_write_app_data_bytes, .ssl_dispatch_alert = dtls1_dispatch_alert, .ssl_ctrl = dtls1_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl3_put_cipher_by_char, .ssl_pending = ssl3_pending, .num_ciphers = ssl3_num_ciphers, .get_cipher = dtls1_get_cipher, .get_ssl_method = dtls1_get_server_method, .get_timeout = dtls1_default_timeout, .ssl3_enc = &DTLSv1_enc_data, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD * DTLSv1_server_method(void) { return &DTLSv1_server_method_data; } static const SSL_METHOD * dtls1_get_server_method(int ver) { if (ver == DTLS1_VERSION) return (DTLSv1_server_method()); return (NULL); } int dtls1_accept(SSL *s) { void (*cb)(const SSL *ssl, int type, int val) = NULL; unsigned long alg_k; int ret = -1; int new_state, state, skip = 0; int listen; #ifndef OPENSSL_NO_SCTP unsigned char sctpauthkey[64]; char labelbuffer[sizeof(DTLS1_SCTP_AUTH_LABEL)]; #endif ERR_clear_error(); errno = 0; if (s->info_callback != NULL) cb = s->info_callback; else if (s->ctx->info_callback != NULL) cb = s->ctx->info_callback; listen = s->d1->listen; /* init things to blank */ s->in_handshake++; if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); s->d1->listen = listen; #ifndef OPENSSL_NO_SCTP /* Notify SCTP BIO socket to enter handshake * mode and prevent stream identifier other * than 0. Will be ignored if no SCTP is used. */ BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE, s->in_handshake, NULL); #endif if (s->cert == NULL) { SSLerr(SSL_F_DTLS1_ACCEPT, SSL_R_NO_CERTIFICATE_SET); return (-1); } for (;;) { state = s->state; switch (s->state) { case SSL_ST_RENEGOTIATE: s->renegotiate = 1; /* s->state=SSL_ST_ACCEPT; */ case SSL_ST_BEFORE: case SSL_ST_ACCEPT: case SSL_ST_BEFORE|SSL_ST_ACCEPT: case SSL_ST_OK|SSL_ST_ACCEPT: s->server = 1; if (cb != NULL) cb(s, SSL_CB_HANDSHAKE_START, 1); if ((s->version & 0xff00) != (DTLS1_VERSION & 0xff00)) { SSLerr(SSL_F_DTLS1_ACCEPT, ERR_R_INTERNAL_ERROR); return -1; } s->type = SSL_ST_ACCEPT; if (s->init_buf == NULL) { BUF_MEM *buf; if ((buf = BUF_MEM_new()) == NULL) { ret = -1; goto end; } if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { BUF_MEM_free(buf); ret = -1; goto end; } s->init_buf = buf; } if (!ssl3_setup_buffers(s)) { ret = -1; goto end; } s->init_num = 0; if (s->state != SSL_ST_RENEGOTIATE) { /* Ok, we now need to push on a buffering BIO so that * the output is sent in a way that TCP likes :-) * ...but not with SCTP :-) */ #ifndef OPENSSL_NO_SCTP if (!BIO_dgram_is_sctp(SSL_get_wbio(s))) #endif if (!ssl_init_wbio_buffer(s, 1)) { ret = -1; goto end; } ssl3_init_finished_mac(s); s->state = SSL3_ST_SR_CLNT_HELLO_A; s->ctx->stats.sess_accept++; } else { /* s->state == SSL_ST_RENEGOTIATE, * we will just send a HelloRequest */ s->ctx->stats.sess_accept_renegotiate++; s->state = SSL3_ST_SW_HELLO_REQ_A; } break; case SSL3_ST_SW_HELLO_REQ_A: case SSL3_ST_SW_HELLO_REQ_B: s->shutdown = 0; dtls1_clear_record_buffer(s); dtls1_start_timer(s); ret = dtls1_send_hello_request(s); if (ret <= 0) goto end; s->s3->tmp.next_state = SSL3_ST_SR_CLNT_HELLO_A; s->state = SSL3_ST_SW_FLUSH; s->init_num = 0; ssl3_init_finished_mac(s); break; case SSL3_ST_SW_HELLO_REQ_C: s->state = SSL_ST_OK; break; case SSL3_ST_SR_CLNT_HELLO_A: case SSL3_ST_SR_CLNT_HELLO_B: case SSL3_ST_SR_CLNT_HELLO_C: s->shutdown = 0; ret = ssl3_get_client_hello(s); if (ret <= 0) goto end; dtls1_stop_timer(s); if (ret == 1 && (SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE)) s->state = DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A; else s->state = SSL3_ST_SW_SRVR_HELLO_A; s->init_num = 0; /* Reflect ClientHello sequence to remain stateless while listening */ if (listen) { memcpy(s->s3->write_sequence, s->s3->read_sequence, sizeof(s->s3->write_sequence)); } /* If we're just listening, stop here */ if (listen && s->state == SSL3_ST_SW_SRVR_HELLO_A) { ret = 2; s->d1->listen = 0; /* Set expected sequence numbers * to continue the handshake. */ s->d1->handshake_read_seq = 2; s->d1->handshake_write_seq = 1; s->d1->next_handshake_write_seq = 1; goto end; } break; case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A: case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B: ret = dtls1_send_hello_verify_request(s); if (ret <= 0) goto end; s->state = SSL3_ST_SW_FLUSH; s->s3->tmp.next_state = SSL3_ST_SR_CLNT_HELLO_A; /* HelloVerifyRequest resets Finished MAC */ if (s->version != DTLS1_BAD_VER) ssl3_init_finished_mac(s); break; #ifndef OPENSSL_NO_SCTP case DTLS1_SCTP_ST_SR_READ_SOCK: if (BIO_dgram_sctp_msg_waiting(SSL_get_rbio(s))) { s->s3->in_read_app_data = 2; s->rwstate = SSL_READING; BIO_clear_retry_flags(SSL_get_rbio(s)); BIO_set_retry_read(SSL_get_rbio(s)); ret = -1; goto end; } s->state = SSL3_ST_SR_FINISHED_A; break; case DTLS1_SCTP_ST_SW_WRITE_SOCK: ret = BIO_dgram_sctp_wait_for_dry(SSL_get_wbio(s)); if (ret < 0) goto end; if (ret == 0) { if (s->d1->next_state != SSL_ST_OK) { s->s3->in_read_app_data = 2; s->rwstate = SSL_READING; BIO_clear_retry_flags(SSL_get_rbio(s)); BIO_set_retry_read(SSL_get_rbio(s)); ret = -1; goto end; } } s->state = s->d1->next_state; break; #endif case SSL3_ST_SW_SRVR_HELLO_A: case SSL3_ST_SW_SRVR_HELLO_B: s->renegotiate = 2; dtls1_start_timer(s); ret = dtls1_send_server_hello(s); if (ret <= 0) goto end; if (s->hit) { #ifndef OPENSSL_NO_SCTP /* Add new shared key for SCTP-Auth, * will be ignored if no SCTP used. */ snprintf((char*)labelbuffer, sizeof(DTLS1_SCTP_AUTH_LABEL), DTLS1_SCTP_AUTH_LABEL); SSL_export_keying_material(s, sctpauthkey, sizeof(sctpauthkey), labelbuffer, sizeof(labelbuffer), NULL, 0, 0); BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY, sizeof(sctpauthkey), sctpauthkey); #endif if (s->tlsext_ticket_expected) s->state = SSL3_ST_SW_SESSION_TICKET_A; else s->state = SSL3_ST_SW_CHANGE_A; } else s->state = SSL3_ST_SW_CERT_A; s->init_num = 0; break; case SSL3_ST_SW_CERT_A: case SSL3_ST_SW_CERT_B: /* Check if it is anon DH or normal PSK */ if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { dtls1_start_timer(s); ret = dtls1_send_server_certificate(s); if (ret <= 0) goto end; if (s->tlsext_status_expected) s->state = SSL3_ST_SW_CERT_STATUS_A; else s->state = SSL3_ST_SW_KEY_EXCH_A; } else { skip = 1; s->state = SSL3_ST_SW_KEY_EXCH_A; } s->init_num = 0; break; case SSL3_ST_SW_KEY_EXCH_A: case SSL3_ST_SW_KEY_EXCH_B: alg_k = s->s3->tmp.new_cipher->algorithm_mkey; /* clear this, it may get reset by * send_server_key_exchange */ if ((s->options & SSL_OP_EPHEMERAL_RSA) ) /* option SSL_OP_EPHEMERAL_RSA sends temporary RSA key * even when forbidden by protocol specs * (handshake may fail as clients are not required to * be able to handle this) */ s->s3->tmp.use_rsa_tmp = 1; else s->s3->tmp.use_rsa_tmp = 0; /* only send if a DH key exchange or * RSA but we have a sign only certificate */ if (s->s3->tmp.use_rsa_tmp || (alg_k & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) || (alg_k & SSL_kEECDH) || ((alg_k & SSL_kRSA) && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL ) ) ) { dtls1_start_timer(s); ret = dtls1_send_server_key_exchange(s); if (ret <= 0) goto end; } else skip = 1; s->state = SSL3_ST_SW_CERT_REQ_A; s->init_num = 0; break; case SSL3_ST_SW_CERT_REQ_A: case SSL3_ST_SW_CERT_REQ_B: if (/* don't request cert unless asked for it: */ !(s->verify_mode & SSL_VERIFY_PEER) || /* if SSL_VERIFY_CLIENT_ONCE is set, * don't request cert during re-negotiation: */ ((s->session->peer != NULL) && (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) || /* never request cert in anonymous ciphersuites * (see section "Certificate request" in SSL 3 drafts * and in RFC 2246): */ ((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && /* ... except when the application insists on verification * (against the specs, but s3_clnt.c accepts this for SSL 3) */ !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) || /* never request cert in Kerberos ciphersuites */ (s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) /* With normal PSK Certificates and * Certificate Requests are omitted */ || (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { /* no cert request */ skip = 1; s->s3->tmp.cert_request = 0; s->state = SSL3_ST_SW_SRVR_DONE_A; #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { s->d1->next_state = SSL3_ST_SW_SRVR_DONE_A; s->state = DTLS1_SCTP_ST_SW_WRITE_SOCK; } #endif } else { s->s3->tmp.cert_request = 1; dtls1_start_timer(s); ret = dtls1_send_certificate_request(s); if (ret <= 0) goto end; #ifndef NETSCAPE_HANG_BUG s->state = SSL3_ST_SW_SRVR_DONE_A; #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { s->d1->next_state = SSL3_ST_SW_SRVR_DONE_A; s->state = DTLS1_SCTP_ST_SW_WRITE_SOCK; } #endif #else s->state = SSL3_ST_SW_FLUSH; s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { s->d1->next_state = s->s3->tmp.next_state; s->s3->tmp.next_state = DTLS1_SCTP_ST_SW_WRITE_SOCK; } #endif #endif s->init_num = 0; } break; case SSL3_ST_SW_SRVR_DONE_A: case SSL3_ST_SW_SRVR_DONE_B: dtls1_start_timer(s); ret = dtls1_send_server_done(s); if (ret <= 0) goto end; s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; s->state = SSL3_ST_SW_FLUSH; s->init_num = 0; break; case SSL3_ST_SW_FLUSH: s->rwstate = SSL_WRITING; if (BIO_flush(s->wbio) <= 0) { /* If the write error was fatal, stop trying */ if (!BIO_should_retry(s->wbio)) { s->rwstate = SSL_NOTHING; s->state = s->s3->tmp.next_state; } ret = -1; goto end; } s->rwstate = SSL_NOTHING; s->state = s->s3->tmp.next_state; break; case SSL3_ST_SR_CERT_A: case SSL3_ST_SR_CERT_B: /* Check for second client hello (MS SGC) */ ret = ssl3_check_client_hello(s); if (ret <= 0) goto end; if (ret == 2) { dtls1_stop_timer(s); s->state = SSL3_ST_SR_CLNT_HELLO_C; } else { /* could be sent for a DH cert, even if we * have not asked for it :-) */ ret = ssl3_get_client_certificate(s); if (ret <= 0) goto end; s->init_num = 0; s->state = SSL3_ST_SR_KEY_EXCH_A; } break; case SSL3_ST_SR_KEY_EXCH_A: case SSL3_ST_SR_KEY_EXCH_B: ret = ssl3_get_client_key_exchange(s); if (ret <= 0) goto end; #ifndef OPENSSL_NO_SCTP /* Add new shared key for SCTP-Auth, * will be ignored if no SCTP used. */ snprintf((char *)labelbuffer, sizeof(DTLS1_SCTP_AUTH_LABEL), DTLS1_SCTP_AUTH_LABEL); SSL_export_keying_material(s, sctpauthkey, sizeof(sctpauthkey), labelbuffer, sizeof(labelbuffer), NULL, 0, 0); BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY, sizeof(sctpauthkey), sctpauthkey); #endif s->state = SSL3_ST_SR_CERT_VRFY_A; s->init_num = 0; if (ret == 2) { /* For the ECDH ciphersuites when * the client sends its ECDH pub key in * a certificate, the CertificateVerify * message is not sent. */ s->state = SSL3_ST_SR_FINISHED_A; s->init_num = 0; } else { s->state = SSL3_ST_SR_CERT_VRFY_A; s->init_num = 0; /* We need to get hashes here so if there is * a client cert, it can be verified */ s->method->ssl3_enc->cert_verify_mac(s, NID_md5, &(s->s3->tmp.cert_verify_md[0])); s->method->ssl3_enc->cert_verify_mac(s, NID_sha1, &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH])); } break; case SSL3_ST_SR_CERT_VRFY_A: case SSL3_ST_SR_CERT_VRFY_B: s->d1->change_cipher_spec_ok = 1; /* we should decide if we expected this one */ ret = ssl3_get_cert_verify(s); if (ret <= 0) goto end; #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s)) && state == SSL_ST_RENEGOTIATE) s->state = DTLS1_SCTP_ST_SR_READ_SOCK; else #endif s->state = SSL3_ST_SR_FINISHED_A; s->init_num = 0; break; case SSL3_ST_SR_FINISHED_A: case SSL3_ST_SR_FINISHED_B: s->d1->change_cipher_spec_ok = 1; ret = ssl3_get_finished(s, SSL3_ST_SR_FINISHED_A, SSL3_ST_SR_FINISHED_B); if (ret <= 0) goto end; dtls1_stop_timer(s); if (s->hit) s->state = SSL_ST_OK; else if (s->tlsext_ticket_expected) s->state = SSL3_ST_SW_SESSION_TICKET_A; else s->state = SSL3_ST_SW_CHANGE_A; s->init_num = 0; break; case SSL3_ST_SW_SESSION_TICKET_A: case SSL3_ST_SW_SESSION_TICKET_B: ret = dtls1_send_newsession_ticket(s); if (ret <= 0) goto end; s->state = SSL3_ST_SW_CHANGE_A; s->init_num = 0; break; case SSL3_ST_SW_CERT_STATUS_A: case SSL3_ST_SW_CERT_STATUS_B: ret = ssl3_send_cert_status(s); if (ret <= 0) goto end; s->state = SSL3_ST_SW_KEY_EXCH_A; s->init_num = 0; break; case SSL3_ST_SW_CHANGE_A: case SSL3_ST_SW_CHANGE_B: s->session->cipher = s->s3->tmp.new_cipher; if (!s->method->ssl3_enc->setup_key_block(s)) { ret = -1; goto end; } ret = dtls1_send_change_cipher_spec(s, SSL3_ST_SW_CHANGE_A, SSL3_ST_SW_CHANGE_B); if (ret <= 0) goto end; #ifndef OPENSSL_NO_SCTP if (!s->hit) { /* Change to new shared key of SCTP-Auth, * will be ignored if no SCTP used. */ BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL); } #endif s->state = SSL3_ST_SW_FINISHED_A; s->init_num = 0; if (!s->method->ssl3_enc->change_cipher_state(s, SSL3_CHANGE_CIPHER_SERVER_WRITE)) { ret = -1; goto end; } dtls1_reset_seq_numbers(s, SSL3_CC_WRITE); break; case SSL3_ST_SW_FINISHED_A: case SSL3_ST_SW_FINISHED_B: ret = dtls1_send_finished(s, SSL3_ST_SW_FINISHED_A, SSL3_ST_SW_FINISHED_B, s->method->ssl3_enc->server_finished_label, s->method->ssl3_enc->server_finished_label_len); if (ret <= 0) goto end; s->state = SSL3_ST_SW_FLUSH; if (s->hit) { s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A; #ifndef OPENSSL_NO_SCTP /* Change to new shared key of SCTP-Auth, * will be ignored if no SCTP used. */ BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL); #endif } else { s->s3->tmp.next_state = SSL_ST_OK; #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { s->d1->next_state = s->s3->tmp.next_state; s->s3->tmp.next_state = DTLS1_SCTP_ST_SW_WRITE_SOCK; } #endif } s->init_num = 0; break; case SSL_ST_OK: /* clean a few things up */ ssl3_cleanup_key_block(s); /* remove buffering on output */ ssl_free_wbio_buffer(s); s->init_num = 0; if (s->renegotiate == 2) /* skipped if we just sent a HelloRequest */ { s->renegotiate = 0; s->new_session = 0; ssl_update_cache(s, SSL_SESS_CACHE_SERVER); s->ctx->stats.sess_accept_good++; /* s->server=1; */ s->handshake_func = dtls1_accept; if (cb != NULL) cb(s, SSL_CB_HANDSHAKE_DONE, 1); } ret = 1; /* done handshaking, next message is client hello */ s->d1->handshake_read_seq = 0; /* next message is server hello */ s->d1->handshake_write_seq = 0; s->d1->next_handshake_write_seq = 0; goto end; /* break; */ default: SSLerr(SSL_F_DTLS1_ACCEPT, SSL_R_UNKNOWN_STATE); ret = -1; goto end; /* break; */ } if (!s->s3->tmp.reuse_message && !skip) { if (s->debug) { if ((ret = BIO_flush(s->wbio)) <= 0) goto end; } if ((cb != NULL) && (s->state != state)) { new_state = s->state; s->state = state; cb(s, SSL_CB_ACCEPT_LOOP, 1); s->state = new_state; } } skip = 0; } end: /* BIO_flush(s->wbio); */ s->in_handshake--; #ifndef OPENSSL_NO_SCTP /* Notify SCTP BIO socket to leave handshake * mode and prevent stream identifier other * than 0. Will be ignored if no SCTP is used. */ BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE, s->in_handshake, NULL); #endif if (cb != NULL) cb(s, SSL_CB_ACCEPT_EXIT, ret); return (ret); } int dtls1_send_hello_request(SSL *s) { unsigned char *p; if (s->state == SSL3_ST_SW_HELLO_REQ_A) { p = (unsigned char *)s->init_buf->data; p = dtls1_set_message_header(s, p, SSL3_MT_HELLO_REQUEST, 0, 0, 0); s->state = SSL3_ST_SW_HELLO_REQ_B; /* number of bytes to write */ s->init_num = DTLS1_HM_HEADER_LENGTH; s->init_off = 0; /* no need to buffer this message, since there are no retransmit * requests for it */ } /* SSL3_ST_SW_HELLO_REQ_B */ return (dtls1_do_write(s, SSL3_RT_HANDSHAKE)); } int dtls1_send_hello_verify_request(SSL *s) { unsigned int msg_len; unsigned char *msg, *buf, *p; if (s->state == DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A) { buf = (unsigned char *)s->init_buf->data; msg = p = &(buf[DTLS1_HM_HEADER_LENGTH]); *(p++) = s->version >> 8; *(p++) = s->version & 0xFF; if (s->ctx->app_gen_cookie_cb == NULL || s->ctx->app_gen_cookie_cb(s, s->d1->cookie, &(s->d1->cookie_len)) == 0) { SSLerr(SSL_F_DTLS1_SEND_HELLO_VERIFY_REQUEST, ERR_R_INTERNAL_ERROR); return 0; } *(p++) = (unsigned char) s->d1->cookie_len; memcpy(p, s->d1->cookie, s->d1->cookie_len); p += s->d1->cookie_len; msg_len = p - msg; dtls1_set_message_header(s, buf, DTLS1_MT_HELLO_VERIFY_REQUEST, msg_len, 0, msg_len); s->state = DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B; /* number of bytes to write */ s->init_num = p - buf; s->init_off = 0; } /* s->state = DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B */ return (dtls1_do_write(s, SSL3_RT_HANDSHAKE)); } int dtls1_send_server_hello(SSL *s) { unsigned char *buf; unsigned char *p, *d; int i; unsigned int sl; unsigned long l; if (s->state == SSL3_ST_SW_SRVR_HELLO_A) { buf = (unsigned char *)s->init_buf->data; p = s->s3->server_random; RAND_pseudo_bytes(p, SSL3_RANDOM_SIZE); /* Do the message type and length last */ d = p= &(buf[DTLS1_HM_HEADER_LENGTH]); *(p++) = s->version >> 8; *(p++) = s->version&0xff; /* Random stuff */ memcpy(p, s->s3->server_random, SSL3_RANDOM_SIZE); p += SSL3_RANDOM_SIZE; /* now in theory we have 3 options to sending back the * session id. If it is a re-use, we send back the * old session-id, if it is a new session, we send * back the new session-id or we send back a 0 length * session-id if we want it to be single use. * Currently I will not implement the '0' length session-id * 12-Jan-98 - I'll now support the '0' length stuff. */ if (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_SERVER)) s->session->session_id_length = 0; sl = s->session->session_id_length; if (sl > sizeof s->session->session_id) { SSLerr(SSL_F_DTLS1_SEND_SERVER_HELLO, ERR_R_INTERNAL_ERROR); return -1; } *(p++) = sl; memcpy(p, s->session->session_id, sl); p += sl; /* put the cipher */ if (s->s3->tmp.new_cipher == NULL) return -1; i = ssl3_put_cipher_by_char(s->s3->tmp.new_cipher, p); p += i; /* put the compression method */ *(p++) = 0; if ((p = ssl_add_serverhello_tlsext(s, p, buf + SSL3_RT_MAX_PLAIN_LENGTH)) == NULL) { SSLerr(SSL_F_DTLS1_SEND_SERVER_HELLO, ERR_R_INTERNAL_ERROR); return -1; } /* do the header */ l = (p - d); d = buf; d = dtls1_set_message_header(s, d, SSL3_MT_SERVER_HELLO, l, 0, l); s->state = SSL3_ST_SW_SRVR_HELLO_B; /* number of bytes to write */ s->init_num = p - buf; s->init_off = 0; /* buffer the message to handle re-xmits */ dtls1_buffer_message(s, 0); } /* SSL3_ST_SW_SRVR_HELLO_B */ return (dtls1_do_write(s, SSL3_RT_HANDSHAKE)); } int dtls1_send_server_done(SSL *s) { unsigned char *p; if (s->state == SSL3_ST_SW_SRVR_DONE_A) { p = (unsigned char *)s->init_buf->data; /* do the header */ p = dtls1_set_message_header(s, p, SSL3_MT_SERVER_DONE, 0, 0, 0); s->state = SSL3_ST_SW_SRVR_DONE_B; /* number of bytes to write */ s->init_num = DTLS1_HM_HEADER_LENGTH; s->init_off = 0; /* buffer the message to handle re-xmits */ dtls1_buffer_message(s, 0); } /* SSL3_ST_SW_SRVR_DONE_B */ return (dtls1_do_write(s, SSL3_RT_HANDSHAKE)); } int dtls1_send_server_key_exchange(SSL *s) { unsigned char *q; int j, num; RSA *rsa; unsigned char md_buf[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH]; unsigned int u; DH *dh = NULL, *dhp; EC_KEY *ecdh = NULL, *ecdhp; unsigned char *encodedPoint = NULL; int encodedlen = 0; int curve_id = 0; BN_CTX *bn_ctx = NULL; EVP_PKEY *pkey; unsigned char *p, *d; int al, i; unsigned long type; int n; CERT *cert; BIGNUM *r[4]; int nr[4], kn; BUF_MEM *buf; EVP_MD_CTX md_ctx; EVP_MD_CTX_init(&md_ctx); if (s->state == SSL3_ST_SW_KEY_EXCH_A) { type = s->s3->tmp.new_cipher->algorithm_mkey; cert = s->cert; buf = s->init_buf; r[0] = r[1] = r[2] = r[3] = NULL; n = 0; if (type & SSL_kRSA) { rsa = cert->rsa_tmp; if ((rsa == NULL) && (s->cert->rsa_tmp_cb != NULL)) { rsa = s->cert->rsa_tmp_cb(s, 0, 0); if (rsa == NULL) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, SSL_R_ERROR_GENERATING_TMP_RSA_KEY); goto f_err; } RSA_up_ref(rsa); cert->rsa_tmp = rsa; } if (rsa == NULL) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, SSL_R_MISSING_TMP_RSA_KEY); goto f_err; } r[0] = rsa->n; r[1] = rsa->e; s->s3->tmp.use_rsa_tmp = 1; } else if (type & SSL_kEDH) { dhp = cert->dh_tmp; if ((dhp == NULL) && (s->cert->dh_tmp_cb != NULL)) dhp = s->cert->dh_tmp_cb(s, 0, 0); if (dhp == NULL) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, SSL_R_MISSING_TMP_DH_KEY); goto f_err; } if (s->s3->tmp.dh != NULL) { DH_free(dh); SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } if ((dh = DHparams_dup(dhp)) == NULL) { SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB); goto err; } s->s3->tmp.dh = dh; if ((dhp->pub_key == NULL || dhp->priv_key == NULL || (s->options & SSL_OP_SINGLE_DH_USE))) { if (!DH_generate_key(dh)) { SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB); goto err; } } else { dh->pub_key = BN_dup(dhp->pub_key); dh->priv_key = BN_dup(dhp->priv_key); if ((dh->pub_key == NULL) || (dh->priv_key == NULL)) { SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB); goto err; } } r[0] = dh->p; r[1] = dh->g; r[2] = dh->pub_key; } else if (type & SSL_kEECDH) { const EC_GROUP *group; ecdhp = cert->ecdh_tmp; if (ecdhp == NULL && s->cert->ecdh_tmp_cb != NULL) ecdhp = s->cert->ecdh_tmp_cb(s, 0, 0); if (ecdhp == NULL) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, SSL_R_MISSING_TMP_ECDH_KEY); goto f_err; } if (s->s3->tmp.ecdh != NULL) { EC_KEY_free(s->s3->tmp.ecdh); SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } /* Duplicate the ECDH structure. */ if (ecdhp == NULL) { SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } if ((ecdh = EC_KEY_dup(ecdhp)) == NULL) { SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } s->s3->tmp.ecdh = ecdh; if ((EC_KEY_get0_public_key(ecdh) == NULL) || (EC_KEY_get0_private_key(ecdh) == NULL) || (s->options & SSL_OP_SINGLE_ECDH_USE)) { if (!EC_KEY_generate_key(ecdh)) { SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } } if (((group = EC_KEY_get0_group(ecdh)) == NULL) || (EC_KEY_get0_public_key(ecdh) == NULL) || (EC_KEY_get0_private_key(ecdh) == NULL)) { SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } /* XXX: For now, we only support ephemeral ECDH * keys over named (not generic) curves. For * supported named curves, curve_id is non-zero. */ if ((curve_id = tls1_ec_nid2curve_id( EC_GROUP_get_curve_name(group))) == 0) { SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, SSL_R_UNSUPPORTED_ELLIPTIC_CURVE); goto err; } /* Encode the public key. * First check the size of encoding and * allocate memory accordingly. */ encodedlen = EC_POINT_point2oct(group, EC_KEY_get0_public_key(ecdh), POINT_CONVERSION_UNCOMPRESSED, NULL, 0, NULL); encodedPoint = malloc(encodedlen); bn_ctx = BN_CTX_new(); if ((encodedPoint == NULL) || (bn_ctx == NULL)) { SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } encodedlen = EC_POINT_point2oct(group, EC_KEY_get0_public_key(ecdh), POINT_CONVERSION_UNCOMPRESSED, encodedPoint, encodedlen, bn_ctx); if (encodedlen == 0) { SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } BN_CTX_free(bn_ctx); bn_ctx = NULL; /* XXX: For now, we only support named (not * generic) curves in ECDH ephemeral key exchanges. * In this situation, we need four additional bytes * to encode the entire ServerECDHParams * structure. */ n = 4 + encodedlen; /* We'll generate the serverKeyExchange message * explicitly so we can set these to NULLs */ r[0] = NULL; r[1] = NULL; r[2] = NULL; r[3] = NULL; } else { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE); goto f_err; } for (i = 0; r[i] != NULL; i++) { nr[i] = BN_num_bytes(r[i]); n += 2 + nr[i]; } if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { if ((pkey = ssl_get_sign_pkey(s, s->s3->tmp.new_cipher, NULL)) == NULL) { al = SSL_AD_DECODE_ERROR; goto f_err; } kn = EVP_PKEY_size(pkey); } else { pkey = NULL; kn = 0; } if (!BUF_MEM_grow_clean(buf, n + DTLS1_HM_HEADER_LENGTH + kn)) { SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, ERR_LIB_BUF); goto err; } d = (unsigned char *)s->init_buf->data; p = &(d[DTLS1_HM_HEADER_LENGTH]); for (i = 0; r[i] != NULL; i++) { s2n(nr[i], p); BN_bn2bin(r[i], p); p += nr[i]; } if (type & SSL_kEECDH) { /* XXX: For now, we only support named (not generic) curves. * In this situation, the serverKeyExchange message has: * [1 byte CurveType], [2 byte CurveName] * [1 byte length of encoded point], followed by * the actual encoded point itself */ *p = NAMED_CURVE_TYPE; p += 1; *p = 0; p += 1; *p = curve_id; p += 1; *p = encodedlen; p += 1; memcpy((unsigned char*)p, (unsigned char *)encodedPoint, encodedlen); free(encodedPoint); encodedPoint = NULL; p += encodedlen; } /* not anonymous */ if (pkey != NULL) { /* n is the length of the params, they start at * &(d[DTLS1_HM_HEADER_LENGTH]) and p points to the space * at the end. */ if (pkey->type == EVP_PKEY_RSA) { q = md_buf; j = 0; for (num = 2; num > 0; num--) { EVP_DigestInit_ex(&md_ctx, (num == 2) ? s->ctx->md5 : s->ctx->sha1, NULL); EVP_DigestUpdate(&md_ctx, &(s->s3->client_random[0]), SSL3_RANDOM_SIZE); EVP_DigestUpdate(&md_ctx, &(s->s3->server_random[0]), SSL3_RANDOM_SIZE); EVP_DigestUpdate(&md_ctx, &(d[DTLS1_HM_HEADER_LENGTH]), n); EVP_DigestFinal_ex(&md_ctx, q, (unsigned int *)&i); q += i; j += i; } if (RSA_sign(NID_md5_sha1, md_buf, j, &(p[2]), &u, pkey->pkey.rsa) <= 0) { SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, ERR_LIB_RSA); goto err; } s2n(u, p); n += u + 2; } else if (pkey->type == EVP_PKEY_DSA) { /* lets do DSS */ EVP_SignInit_ex(&md_ctx, EVP_dss1(), NULL); EVP_SignUpdate(&md_ctx, &(s->s3->client_random[0]), SSL3_RANDOM_SIZE); EVP_SignUpdate(&md_ctx, &(s->s3->server_random[0]), SSL3_RANDOM_SIZE); EVP_SignUpdate(&md_ctx, &(d[DTLS1_HM_HEADER_LENGTH]), n); if (!EVP_SignFinal(&md_ctx, &(p[2]), (unsigned int *)&i, pkey)) { SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, ERR_LIB_DSA); goto err; } s2n(i, p); n += i + 2; } else if (pkey->type == EVP_PKEY_EC) { /* let's do ECDSA */ EVP_SignInit_ex(&md_ctx, EVP_ecdsa(), NULL); EVP_SignUpdate(&md_ctx, &(s->s3->client_random[0]), SSL3_RANDOM_SIZE); EVP_SignUpdate(&md_ctx, &(s->s3->server_random[0]), SSL3_RANDOM_SIZE); EVP_SignUpdate(&md_ctx, &(d[DTLS1_HM_HEADER_LENGTH]), n); if (!EVP_SignFinal(&md_ctx, &(p[2]), (unsigned int *)&i, pkey)) { SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, ERR_LIB_ECDSA); goto err; } s2n(i, p); n += i + 2; } else { /* Is this error check actually needed? */ al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, SSL_R_UNKNOWN_PKEY_TYPE); goto f_err; } } d = dtls1_set_message_header(s, d, SSL3_MT_SERVER_KEY_EXCHANGE, n, 0, n); /* we should now have things packed up, so lets send * it off */ s->init_num = n + DTLS1_HM_HEADER_LENGTH; s->init_off = 0; /* buffer the message to handle re-xmits */ dtls1_buffer_message(s, 0); } s->state = SSL3_ST_SW_KEY_EXCH_B; EVP_MD_CTX_cleanup(&md_ctx); return (dtls1_do_write(s, SSL3_RT_HANDSHAKE)); f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: free(encodedPoint); BN_CTX_free(bn_ctx); EVP_MD_CTX_cleanup(&md_ctx); return (-1); } int dtls1_send_certificate_request(SSL *s) { unsigned char *p, *d; int i, j, nl, off, n; STACK_OF(X509_NAME) *sk = NULL; X509_NAME *name; BUF_MEM *buf; unsigned int msg_len; if (s->state == SSL3_ST_SW_CERT_REQ_A) { buf = s->init_buf; d = p=(unsigned char *)&(buf->data[DTLS1_HM_HEADER_LENGTH]); /* get the list of acceptable cert types */ p++; n = ssl3_get_req_cert_type(s, p); d[0] = n; p += n; n++; off = n; p += 2; n += 2; sk = SSL_get_client_CA_list(s); nl = 0; if (sk != NULL) { for (i = 0; i < sk_X509_NAME_num(sk); i++) { name = sk_X509_NAME_value(sk, i); j = i2d_X509_NAME(name, NULL); if (!BUF_MEM_grow_clean(buf, DTLS1_HM_HEADER_LENGTH + n + j + 2)) { SSLerr(SSL_F_DTLS1_SEND_CERTIFICATE_REQUEST, ERR_R_BUF_LIB); goto err; } p = (unsigned char *)&(buf->data[DTLS1_HM_HEADER_LENGTH + n]); if (!(s->options & SSL_OP_NETSCAPE_CA_DN_BUG)) { s2n(j, p); i2d_X509_NAME(name, &p); n += 2 + j; nl += 2 + j; } else { d = p; i2d_X509_NAME(name, &p); j -= 2; s2n(j, d); j += 2; n += j; nl += j; } } } /* else no CA names */ p = (unsigned char *)&(buf->data[DTLS1_HM_HEADER_LENGTH + off]); s2n(nl, p); d = (unsigned char *)buf->data; *(d++) = SSL3_MT_CERTIFICATE_REQUEST; l2n3(n, d); s2n(s->d1->handshake_write_seq, d); s->d1->handshake_write_seq++; /* we should now have things packed up, so lets send * it off */ s->init_num = n + DTLS1_HM_HEADER_LENGTH; s->init_off = 0; #ifdef NETSCAPE_HANG_BUG /* XXX: what to do about this? */ p = (unsigned char *)s->init_buf->data + s->init_num; /* do the header */ *(p++) = SSL3_MT_SERVER_DONE; *(p++) = 0; *(p++) = 0; *(p++) = 0; s->init_num += 4; #endif /* XDTLS: set message header ? */ msg_len = s->init_num - DTLS1_HM_HEADER_LENGTH; dtls1_set_message_header(s, (void *)s->init_buf->data, SSL3_MT_CERTIFICATE_REQUEST, msg_len, 0, msg_len); /* buffer the message to handle re-xmits */ dtls1_buffer_message(s, 0); s->state = SSL3_ST_SW_CERT_REQ_B; } /* SSL3_ST_SW_CERT_REQ_B */ return (dtls1_do_write(s, SSL3_RT_HANDSHAKE)); err: return (-1); } int dtls1_send_server_certificate(SSL *s) { unsigned long l; X509 *x; if (s->state == SSL3_ST_SW_CERT_A) { x = ssl_get_server_send_cert(s); if (x == NULL) { /* VRS: allow null cert if auth == KRB5 */ if ((s->s3->tmp.new_cipher->algorithm_mkey != SSL_kKRB5) || (s->s3->tmp.new_cipher->algorithm_auth != SSL_aKRB5)) { SSLerr(SSL_F_DTLS1_SEND_SERVER_CERTIFICATE, ERR_R_INTERNAL_ERROR); return (0); } } l = dtls1_output_cert_chain(s, x); s->state = SSL3_ST_SW_CERT_B; s->init_num = (int)l; s->init_off = 0; /* buffer the message to handle re-xmits */ dtls1_buffer_message(s, 0); } /* SSL3_ST_SW_CERT_B */ return (dtls1_do_write(s, SSL3_RT_HANDSHAKE)); } int dtls1_send_newsession_ticket(SSL *s) { if (s->state == SSL3_ST_SW_SESSION_TICKET_A) { unsigned char *p, *senc, *macstart; int len, slen; unsigned int hlen, msg_len; EVP_CIPHER_CTX ctx; HMAC_CTX hctx; SSL_CTX *tctx = s->initial_ctx; unsigned char iv[EVP_MAX_IV_LENGTH]; unsigned char key_name[16]; /* get session encoding length */ slen = i2d_SSL_SESSION(s->session, NULL); /* Some length values are 16 bits, so forget it if session is * too long */ if (slen > 0xFF00) return -1; /* Grow buffer if need be: the length calculation is as * follows 12 (DTLS handshake message header) + * 4 (ticket lifetime hint) + 2 (ticket length) + * 16 (key name) + max_iv_len (iv length) + * session_length + max_enc_block_size (max encrypted session * length) + max_md_size (HMAC). */ if (!BUF_MEM_grow(s->init_buf, DTLS1_HM_HEADER_LENGTH + 22 + EVP_MAX_IV_LENGTH + EVP_MAX_BLOCK_LENGTH + EVP_MAX_MD_SIZE + slen)) return -1; senc = malloc(slen); if (!senc) return -1; p = senc; i2d_SSL_SESSION(s->session, &p); p = (unsigned char *)&(s->init_buf->data[DTLS1_HM_HEADER_LENGTH]); EVP_CIPHER_CTX_init(&ctx); HMAC_CTX_init(&hctx); /* Initialize HMAC and cipher contexts. If callback present * it does all the work otherwise use generated values * from parent ctx. */ if (tctx->tlsext_ticket_key_cb) { if (tctx->tlsext_ticket_key_cb(s, key_name, iv, &ctx, &hctx, 1) < 0) { free(senc); return -1; } } else { RAND_pseudo_bytes(iv, 16); EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, tctx->tlsext_tick_aes_key, iv); HMAC_Init_ex(&hctx, tctx->tlsext_tick_hmac_key, 16, tlsext_tick_md(), NULL); memcpy(key_name, tctx->tlsext_tick_key_name, 16); } l2n(s->session->tlsext_tick_lifetime_hint, p); /* Skip ticket length for now */ p += 2; /* Output key name */ macstart = p; memcpy(p, key_name, 16); p += 16; /* output IV */ memcpy(p, iv, EVP_CIPHER_CTX_iv_length(&ctx)); p += EVP_CIPHER_CTX_iv_length(&ctx); /* Encrypt session data */ EVP_EncryptUpdate(&ctx, p, &len, senc, slen); p += len; EVP_EncryptFinal(&ctx, p, &len); p += len; EVP_CIPHER_CTX_cleanup(&ctx); HMAC_Update(&hctx, macstart, p - macstart); HMAC_Final(&hctx, p, &hlen); HMAC_CTX_cleanup(&hctx); p += hlen; /* Now write out lengths: p points to end of data written */ /* Total length */ len = p - (unsigned char *)(s->init_buf->data); /* Ticket length */ p = (unsigned char *)&(s->init_buf->data[DTLS1_HM_HEADER_LENGTH]) + 4; s2n(len - DTLS1_HM_HEADER_LENGTH - 6, p); /* number of bytes to write */ s->init_num = len; s->state = SSL3_ST_SW_SESSION_TICKET_B; s->init_off = 0; free(senc); /* XDTLS: set message header ? */ msg_len = s->init_num - DTLS1_HM_HEADER_LENGTH; dtls1_set_message_header(s, (void *)s->init_buf->data, SSL3_MT_NEWSESSION_TICKET, msg_len, 0, msg_len); /* buffer the message to handle re-xmits */ dtls1_buffer_message(s, 0); } /* SSL3_ST_SW_SESSION_TICKET_B */ return (dtls1_do_write(s, SSL3_RT_HANDSHAKE)); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/ssl_cert.c0000644000175000017500000004615412360020705017530 0ustar /* $OpenBSD: ssl_cert.c,v 1.40 2014/07/09 11:25:42 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * ECC cipher suite support in OpenSSL originally developed by * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. */ #include #include #include #include #include #include #include #include #include #include #include #include "ssl_locl.h" int SSL_get_ex_data_X509_STORE_CTX_idx(void) { static volatile int ssl_x509_store_ctx_idx = -1; int got_write_lock = 0; CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); if (ssl_x509_store_ctx_idx < 0) { CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); got_write_lock = 1; if (ssl_x509_store_ctx_idx < 0) { ssl_x509_store_ctx_idx = X509_STORE_CTX_get_ex_new_index( 0, "SSL for verify callback", NULL, NULL, NULL); } } if (got_write_lock) CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); else CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); return ssl_x509_store_ctx_idx; } static void ssl_cert_set_default_md(CERT *cert) { /* Set digest values to defaults */ cert->pkeys[SSL_PKEY_DSA_SIGN].digest = EVP_sha1(); cert->pkeys[SSL_PKEY_RSA_SIGN].digest = EVP_sha1(); cert->pkeys[SSL_PKEY_RSA_ENC].digest = EVP_sha1(); cert->pkeys[SSL_PKEY_ECC].digest = EVP_sha1(); } CERT * ssl_cert_new(void) { CERT *ret; ret = calloc(1, sizeof(CERT)); if (ret == NULL) { SSLerr(SSL_F_SSL_CERT_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } ret->key = &(ret->pkeys[SSL_PKEY_RSA_ENC]); ret->references = 1; ssl_cert_set_default_md(ret); return (ret); } CERT * ssl_cert_dup(CERT *cert) { CERT *ret; int i; ret = calloc(1, sizeof(CERT)); if (ret == NULL) { SSLerr(SSL_F_SSL_CERT_DUP, ERR_R_MALLOC_FAILURE); return (NULL); } /* * same as ret->key = ret->pkeys + (cert->key - cert->pkeys), * if you find that more readable */ ret->key = &ret->pkeys[cert->key - &cert->pkeys[0]]; ret->valid = cert->valid; ret->mask_k = cert->mask_k; ret->mask_a = cert->mask_a; if (cert->rsa_tmp != NULL) { RSA_up_ref(cert->rsa_tmp); ret->rsa_tmp = cert->rsa_tmp; } ret->rsa_tmp_cb = cert->rsa_tmp_cb; if (cert->dh_tmp != NULL) { ret->dh_tmp = DHparams_dup(cert->dh_tmp); if (ret->dh_tmp == NULL) { SSLerr(SSL_F_SSL_CERT_DUP, ERR_R_DH_LIB); goto err; } if (cert->dh_tmp->priv_key) { BIGNUM *b = BN_dup(cert->dh_tmp->priv_key); if (!b) { SSLerr(SSL_F_SSL_CERT_DUP, ERR_R_BN_LIB); goto err; } ret->dh_tmp->priv_key = b; } if (cert->dh_tmp->pub_key) { BIGNUM *b = BN_dup(cert->dh_tmp->pub_key); if (!b) { SSLerr(SSL_F_SSL_CERT_DUP, ERR_R_BN_LIB); goto err; } ret->dh_tmp->pub_key = b; } } ret->dh_tmp_cb = cert->dh_tmp_cb; if (cert->ecdh_tmp) { ret->ecdh_tmp = EC_KEY_dup(cert->ecdh_tmp); if (ret->ecdh_tmp == NULL) { SSLerr(SSL_F_SSL_CERT_DUP, ERR_R_EC_LIB); goto err; } } ret->ecdh_tmp_cb = cert->ecdh_tmp_cb; for (i = 0; i < SSL_PKEY_NUM; i++) { if (cert->pkeys[i].x509 != NULL) { ret->pkeys[i].x509 = cert->pkeys[i].x509; CRYPTO_add(&ret->pkeys[i].x509->references, 1, CRYPTO_LOCK_X509); } if (cert->pkeys[i].privatekey != NULL) { ret->pkeys[i].privatekey = cert->pkeys[i].privatekey; CRYPTO_add(&ret->pkeys[i].privatekey->references, 1, CRYPTO_LOCK_EVP_PKEY); switch (i) { /* * If there was anything special to do for * certain types of keys, we'd do it here. * (Nothing at the moment, I think.) */ case SSL_PKEY_RSA_ENC: case SSL_PKEY_RSA_SIGN: /* We have an RSA key. */ break; case SSL_PKEY_DSA_SIGN: /* We have a DSA key. */ break; case SSL_PKEY_DH_RSA: case SSL_PKEY_DH_DSA: /* We have a DH key. */ break; case SSL_PKEY_ECC: /* We have an ECC key */ break; default: /* Can't happen. */ SSLerr(SSL_F_SSL_CERT_DUP, SSL_R_LIBRARY_BUG); } } } /* * ret->extra_certs *should* exist, but currently the own certificate * chain is held inside SSL_CTX */ ret->references = 1; /* * Set digests to defaults. NB: we don't copy existing values * as they will be set during handshake. */ ssl_cert_set_default_md(ret); return (ret); err: RSA_free(ret->rsa_tmp); DH_free(ret->dh_tmp); EC_KEY_free(ret->ecdh_tmp); for (i = 0; i < SSL_PKEY_NUM; i++) { if (ret->pkeys[i].x509 != NULL) X509_free(ret->pkeys[i].x509); EVP_PKEY_free(ret->pkeys[i].privatekey); } free (ret); return NULL; } void ssl_cert_free(CERT *c) { int i; if (c == NULL) return; i = CRYPTO_add(&c->references, -1, CRYPTO_LOCK_SSL_CERT); if (i > 0) return; RSA_free(c->rsa_tmp); DH_free(c->dh_tmp); EC_KEY_free(c->ecdh_tmp); for (i = 0; i < SSL_PKEY_NUM; i++) { if (c->pkeys[i].x509 != NULL) X509_free(c->pkeys[i].x509); EVP_PKEY_free(c->pkeys[i].privatekey); } free(c); } int ssl_cert_inst(CERT **o) { /* * Create a CERT if there isn't already one * (which cannot really happen, as it is initially created in * SSL_CTX_new; but the earlier code usually allows for that one * being non-existant, so we follow that behaviour, as it might * turn out that there actually is a reason for it -- but I'm * not sure that *all* of the existing code could cope with * s->cert being NULL, otherwise we could do without the * initialization in SSL_CTX_new). */ if (o == NULL) { SSLerr(SSL_F_SSL_CERT_INST, ERR_R_PASSED_NULL_PARAMETER); return (0); } if (*o == NULL) { if ((*o = ssl_cert_new()) == NULL) { SSLerr(SSL_F_SSL_CERT_INST, ERR_R_MALLOC_FAILURE); return (0); } } return (1); } SESS_CERT * ssl_sess_cert_new(void) { SESS_CERT *ret; ret = calloc(1, sizeof *ret); if (ret == NULL) { SSLerr(SSL_F_SSL_SESS_CERT_NEW, ERR_R_MALLOC_FAILURE); return NULL; } ret->peer_key = &(ret->peer_pkeys[SSL_PKEY_RSA_ENC]); ret->references = 1; return ret; } void ssl_sess_cert_free(SESS_CERT *sc) { int i; if (sc == NULL) return; i = CRYPTO_add(&sc->references, -1, CRYPTO_LOCK_SSL_SESS_CERT); if (i > 0) return; /* i == 0 */ if (sc->cert_chain != NULL) sk_X509_pop_free(sc->cert_chain, X509_free); for (i = 0; i < SSL_PKEY_NUM; i++) { if (sc->peer_pkeys[i].x509 != NULL) X509_free(sc->peer_pkeys[i].x509); } RSA_free(sc->peer_rsa_tmp); DH_free(sc->peer_dh_tmp); EC_KEY_free(sc->peer_ecdh_tmp); free(sc); } int ssl_set_peer_cert_type(SESS_CERT *sc, int type) { sc->peer_cert_type = type; return (1); } int ssl_verify_cert_chain(SSL *s, STACK_OF(X509) *sk) { X509_STORE_CTX ctx; X509 *x; int ret; if ((sk == NULL) || (sk_X509_num(sk) == 0)) return (0); x = sk_X509_value(sk, 0); if (!X509_STORE_CTX_init(&ctx, s->ctx->cert_store, x, sk)) { SSLerr(SSL_F_SSL_VERIFY_CERT_CHAIN, ERR_R_X509_LIB); return (0); } X509_STORE_CTX_set_ex_data(&ctx, SSL_get_ex_data_X509_STORE_CTX_idx(), s); /* * We need to inherit the verify parameters. These can be * determined by the context: if its a server it will verify * SSL client certificates or vice versa. */ X509_STORE_CTX_set_default(&ctx, s->server ? "ssl_client" : "ssl_server"); /* * Anything non-default in "param" should overwrite anything * in the ctx. */ X509_VERIFY_PARAM_set1(X509_STORE_CTX_get0_param(&ctx), s->param); if (s->verify_callback) X509_STORE_CTX_set_verify_cb(&ctx, s->verify_callback); if (s->ctx->app_verify_callback != NULL) ret = s->ctx->app_verify_callback(&ctx, s->ctx->app_verify_arg); else ret = X509_verify_cert(&ctx); s->verify_result = ctx.error; X509_STORE_CTX_cleanup(&ctx); return (ret); } static void set_client_CA_list(STACK_OF(X509_NAME) **ca_list, STACK_OF(X509_NAME) *name_list) { if (*ca_list != NULL) sk_X509_NAME_pop_free(*ca_list, X509_NAME_free); *ca_list = name_list; } STACK_OF(X509_NAME) * SSL_dup_CA_list(STACK_OF(X509_NAME) *sk) { int i; STACK_OF(X509_NAME) *ret; X509_NAME *name; ret = sk_X509_NAME_new_null(); for (i = 0; i < sk_X509_NAME_num(sk); i++) { name = X509_NAME_dup(sk_X509_NAME_value(sk, i)); if ((name == NULL) || !sk_X509_NAME_push(ret, name)) { sk_X509_NAME_pop_free(ret, X509_NAME_free); return (NULL); } } return (ret); } void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list) { set_client_CA_list(&(s->client_CA), name_list); } void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list) { set_client_CA_list(&(ctx->client_CA), name_list); } STACK_OF(X509_NAME) * SSL_CTX_get_client_CA_list(const SSL_CTX *ctx) { return (ctx->client_CA); } STACK_OF(X509_NAME) * SSL_get_client_CA_list(const SSL *s) { if (s->type == SSL_ST_CONNECT) { /* We are in the client. */ if (((s->version >> 8) == SSL3_VERSION_MAJOR) && (s->s3 != NULL)) return (s->s3->tmp.ca_names); else return (NULL); } else { if (s->client_CA != NULL) return (s->client_CA); else return (s->ctx->client_CA); } } static int add_client_CA(STACK_OF(X509_NAME) **sk, X509 *x) { X509_NAME *name; if (x == NULL) return (0); if ((*sk == NULL) && ((*sk = sk_X509_NAME_new_null()) == NULL)) return (0); if ((name = X509_NAME_dup(X509_get_subject_name(x))) == NULL) return (0); if (!sk_X509_NAME_push(*sk, name)) { X509_NAME_free(name); return (0); } return (1); } int SSL_add_client_CA(SSL *ssl, X509 *x) { return (add_client_CA(&(ssl->client_CA), x)); } int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x) { return (add_client_CA(&(ctx->client_CA), x)); } static int xname_cmp(const X509_NAME * const *a, const X509_NAME * const *b) { return (X509_NAME_cmp(*a, *b)); } /*! * Load CA certs from a file into a ::STACK. Note that it is somewhat misnamed; * it doesn't really have anything to do with clients (except that a common use * for a stack of CAs is to send it to the client). Actually, it doesn't have * much to do with CAs, either, since it will load any old cert. * \param file the file containing one or more certs. * \return a ::STACK containing the certs. */ STACK_OF(X509_NAME) * SSL_load_client_CA_file(const char *file) { BIO *in; X509 *x = NULL; X509_NAME *xn = NULL; STACK_OF(X509_NAME) *ret = NULL, *sk; sk = sk_X509_NAME_new(xname_cmp); in = BIO_new(BIO_s_file_internal()); if ((sk == NULL) || (in == NULL)) { SSLerr(SSL_F_SSL_LOAD_CLIENT_CA_FILE, ERR_R_MALLOC_FAILURE); goto err; } if (!BIO_read_filename(in, file)) goto err; for (;;) { if (PEM_read_bio_X509(in, &x, NULL, NULL) == NULL) break; if (ret == NULL) { ret = sk_X509_NAME_new_null(); if (ret == NULL) { SSLerr(SSL_F_SSL_LOAD_CLIENT_CA_FILE, ERR_R_MALLOC_FAILURE); goto err; } } if ((xn = X509_get_subject_name(x)) == NULL) goto err; /* check for duplicates */ xn = X509_NAME_dup(xn); if (xn == NULL) goto err; if (sk_X509_NAME_find(sk, xn) >= 0) X509_NAME_free(xn); else { sk_X509_NAME_push(sk, xn); sk_X509_NAME_push(ret, xn); } } if (0) { err: if (ret != NULL) sk_X509_NAME_pop_free(ret, X509_NAME_free); ret = NULL; } if (sk != NULL) sk_X509_NAME_free(sk); BIO_free(in); if (x != NULL) X509_free(x); if (ret != NULL) ERR_clear_error(); return (ret); } /*! * Add a file of certs to a stack. * \param stack the stack to add to. * \param file the file to add from. All certs in this file that are not * already in the stack will be added. * \return 1 for success, 0 for failure. Note that in the case of failure some * certs may have been added to \c stack. */ int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, const char *file) { BIO *in; X509 *x = NULL; X509_NAME *xn = NULL; int ret = 1; int (*oldcmp)(const X509_NAME * const *a, const X509_NAME * const *b); oldcmp = sk_X509_NAME_set_cmp_func(stack, xname_cmp); in = BIO_new(BIO_s_file_internal()); if (in == NULL) { SSLerr(SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK, ERR_R_MALLOC_FAILURE); goto err; } if (!BIO_read_filename(in, file)) goto err; for (;;) { if (PEM_read_bio_X509(in, &x, NULL, NULL) == NULL) break; if ((xn = X509_get_subject_name(x)) == NULL) goto err; xn = X509_NAME_dup(xn); if (xn == NULL) goto err; if (sk_X509_NAME_find(stack, xn) >= 0) X509_NAME_free(xn); else sk_X509_NAME_push(stack, xn); } ERR_clear_error(); if (0) { err: ret = 0; } BIO_free(in); if (x != NULL) X509_free(x); (void)sk_X509_NAME_set_cmp_func(stack, oldcmp); return ret; } /*! * Add a directory of certs to a stack. * \param stack the stack to append to. * \param dir the directory to append from. All files in this directory will be * examined as potential certs. Any that are acceptable to * SSL_add_dir_cert_subjects_to_stack() that are not already in the stack will * be included. * \return 1 for success, 0 for failure. Note that in the case of failure some * certs may have been added to \c stack. */ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, const char *dir) { DIR *dirp = NULL; char *path = NULL; int ret = 0; CRYPTO_w_lock(CRYPTO_LOCK_READDIR); dirp = opendir(dir); if (dirp) { struct dirent *dp; while ((dp = readdir(dirp)) != NULL) { if (asprintf(&path, "%s/%s", dir, dp->d_name) != -1) { ret = SSL_add_file_cert_subjects_to_stack( stack, path); free(path); } if (!ret) break; } (void) closedir(dirp); } if (!ret) { SYSerr(SYS_F_OPENDIR, errno); ERR_asprintf_error_data("opendir ('%s')", dir); SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK, ERR_R_SYS_LIB); } CRYPTO_w_unlock(CRYPTO_LOCK_READDIR); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/ssl_algs.c0000644000175000017500000001164112360020705017512 0ustar /* $OpenBSD: ssl_algs.c,v 1.18 2014/06/12 15:49:31 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include "ssl_locl.h" int SSL_library_init(void) { #ifndef OPENSSL_NO_DES EVP_add_cipher(EVP_des_cbc()); EVP_add_cipher(EVP_des_ede3_cbc()); #endif #ifndef OPENSSL_NO_IDEA EVP_add_cipher(EVP_idea_cbc()); #endif #ifndef OPENSSL_NO_RC4 EVP_add_cipher(EVP_rc4()); #if !defined(OPENSSL_NO_MD5) && (defined(__x86_64) || defined(__x86_64__)) EVP_add_cipher(EVP_rc4_hmac_md5()); #endif #endif #ifndef OPENSSL_NO_RC2 EVP_add_cipher(EVP_rc2_cbc()); /* Not actually used for SSL/TLS but this makes PKCS#12 work * if an application only calls SSL_library_init(). */ EVP_add_cipher(EVP_rc2_40_cbc()); #endif EVP_add_cipher(EVP_aes_128_cbc()); EVP_add_cipher(EVP_aes_192_cbc()); EVP_add_cipher(EVP_aes_256_cbc()); EVP_add_cipher(EVP_aes_128_gcm()); EVP_add_cipher(EVP_aes_256_gcm()); EVP_add_cipher(EVP_aes_128_cbc_hmac_sha1()); EVP_add_cipher(EVP_aes_256_cbc_hmac_sha1()); #ifndef OPENSSL_NO_CAMELLIA EVP_add_cipher(EVP_camellia_128_cbc()); EVP_add_cipher(EVP_camellia_256_cbc()); #endif EVP_add_digest(EVP_md5()); EVP_add_digest_alias(SN_md5, "ssl2-md5"); EVP_add_digest_alias(SN_md5, "ssl3-md5"); EVP_add_digest(EVP_sha1()); /* RSA with sha1 */ EVP_add_digest_alias(SN_sha1, "ssl3-sha1"); EVP_add_digest_alias(SN_sha1WithRSAEncryption, SN_sha1WithRSA); EVP_add_digest(EVP_sha224()); EVP_add_digest(EVP_sha256()); EVP_add_digest(EVP_sha384()); EVP_add_digest(EVP_sha512()); EVP_add_digest(EVP_dss1()); /* DSA with sha1 */ EVP_add_digest_alias(SN_dsaWithSHA1, SN_dsaWithSHA1_2); EVP_add_digest_alias(SN_dsaWithSHA1, "DSS1"); EVP_add_digest_alias(SN_dsaWithSHA1, "dss1"); EVP_add_digest(EVP_ecdsa()); /* initialize cipher/digest methods table */ ssl_load_ciphers(); return (1); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/t1_reneg.c0000644000175000017500000002353212360020705017411 0ustar /* $OpenBSD: t1_reneg.c,v 1.7 2014/06/19 21:29:51 tedu Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2009 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "ssl_locl.h" /* Add the client's renegotiation binding */ int ssl_add_clienthello_renegotiate_ext(SSL *s, unsigned char *p, int *len, int maxlen) { if (p) { if ((s->s3->previous_client_finished_len + 1) > maxlen) { SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_RENEGOTIATE_EXT, SSL_R_RENEGOTIATE_EXT_TOO_LONG); return 0; } /* Length byte */ *p = s->s3->previous_client_finished_len; p++; memcpy(p, s->s3->previous_client_finished, s->s3->previous_client_finished_len); } *len = s->s3->previous_client_finished_len + 1; return 1; } /* Parse the client's renegotiation binding and abort if it's not right */ int ssl_parse_clienthello_renegotiate_ext(SSL *s, unsigned char *d, int len, int *al) { int ilen; /* Parse the length byte */ if (len < 1) { SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT, SSL_R_RENEGOTIATION_ENCODING_ERR); *al = SSL_AD_ILLEGAL_PARAMETER; return 0; } ilen = *d; d++; /* Consistency check */ if ((ilen + 1) != len) { SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT, SSL_R_RENEGOTIATION_ENCODING_ERR); *al = SSL_AD_ILLEGAL_PARAMETER; return 0; } /* Check that the extension matches */ if (ilen != s->s3->previous_client_finished_len) { SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT, SSL_R_RENEGOTIATION_MISMATCH); *al = SSL_AD_HANDSHAKE_FAILURE; return 0; } if (timingsafe_memcmp(d, s->s3->previous_client_finished, s->s3->previous_client_finished_len) != 0) { SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT, SSL_R_RENEGOTIATION_MISMATCH); *al = SSL_AD_HANDSHAKE_FAILURE; return 0; } s->s3->send_connection_binding = 1; return 1; } /* Add the server's renegotiation binding */ int ssl_add_serverhello_renegotiate_ext(SSL *s, unsigned char *p, int *len, int maxlen) { if (p) { if ((s->s3->previous_client_finished_len + s->s3->previous_server_finished_len + 1) > maxlen) { SSLerr(SSL_F_SSL_ADD_SERVERHELLO_RENEGOTIATE_EXT, SSL_R_RENEGOTIATE_EXT_TOO_LONG); return 0; } /* Length byte */ *p = s->s3->previous_client_finished_len + s->s3->previous_server_finished_len; p++; memcpy(p, s->s3->previous_client_finished, s->s3->previous_client_finished_len); p += s->s3->previous_client_finished_len; memcpy(p, s->s3->previous_server_finished, s->s3->previous_server_finished_len); } *len = s->s3->previous_client_finished_len + s->s3->previous_server_finished_len + 1; return 1; } /* Parse the server's renegotiation binding and abort if it's not right */ int ssl_parse_serverhello_renegotiate_ext(SSL *s, unsigned char *d, int len, int *al) { int expected_len = s->s3->previous_client_finished_len + s->s3->previous_server_finished_len; int ilen; /* Check for logic errors */ OPENSSL_assert(!expected_len || s->s3->previous_client_finished_len); OPENSSL_assert(!expected_len || s->s3->previous_server_finished_len); /* Parse the length byte */ if (len < 1) { SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT, SSL_R_RENEGOTIATION_ENCODING_ERR); *al = SSL_AD_ILLEGAL_PARAMETER; return 0; } ilen = *d; d++; /* Consistency check */ if (ilen + 1 != len) { SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT, SSL_R_RENEGOTIATION_ENCODING_ERR); *al = SSL_AD_ILLEGAL_PARAMETER; return 0; } /* Check that the extension matches */ if (ilen != expected_len) { SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT, SSL_R_RENEGOTIATION_MISMATCH); *al = SSL_AD_HANDSHAKE_FAILURE; return 0; } if (timingsafe_memcmp(d, s->s3->previous_client_finished, s->s3->previous_client_finished_len) != 0) { SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT, SSL_R_RENEGOTIATION_MISMATCH); *al = SSL_AD_HANDSHAKE_FAILURE; return 0; } d += s->s3->previous_client_finished_len; if (timingsafe_memcmp(d, s->s3->previous_server_finished, s->s3->previous_server_finished_len)) { SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT, SSL_R_RENEGOTIATION_MISMATCH); *al = SSL_AD_ILLEGAL_PARAMETER; return 0; } s->s3->send_connection_binding = 1; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/t1_enc.c0000644000175000017500000011015312360020705017052 0ustar /* $OpenBSD: t1_enc.c,v 1.66 2014/07/10 08:51:15 tedu Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2005 Nokia. All rights reserved. * * The portions of the attached software ("Contribution") is developed by * Nokia Corporation and is licensed pursuant to the OpenSSL open source * license. * * The Contribution, originally written by Mika Kousa and Pasi Eronen of * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites * support (see RFC 4279) to OpenSSL. * * No patent licenses or other rights except those expressly stated in * the OpenSSL open source license shall be deemed granted or received * expressly, by implication, estoppel, or otherwise. * * No assurances are provided by Nokia that the Contribution does not * infringe the patent or other intellectual property rights of any third * party or that the license provides you with all the necessary rights * to make use of the Contribution. * * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR * OTHERWISE. */ #include #include "ssl_locl.h" #include #include #include #include /* seed1 through seed5 are virtually concatenated */ static int tls1_P_hash(const EVP_MD *md, const unsigned char *sec, int sec_len, const void *seed1, int seed1_len, const void *seed2, int seed2_len, const void *seed3, int seed3_len, const void *seed4, int seed4_len, const void *seed5, int seed5_len, unsigned char *out, int olen) { int chunk; size_t j; EVP_MD_CTX ctx, ctx_tmp; EVP_PKEY *mac_key; unsigned char A1[EVP_MAX_MD_SIZE]; size_t A1_len; int ret = 0; chunk = EVP_MD_size(md); OPENSSL_assert(chunk >= 0); EVP_MD_CTX_init(&ctx); EVP_MD_CTX_init(&ctx_tmp); mac_key = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, sec, sec_len); if (!mac_key) goto err; if (!EVP_DigestSignInit(&ctx, NULL, md, NULL, mac_key)) goto err; if (!EVP_DigestSignInit(&ctx_tmp, NULL, md, NULL, mac_key)) goto err; if (seed1 && !EVP_DigestSignUpdate(&ctx, seed1, seed1_len)) goto err; if (seed2 && !EVP_DigestSignUpdate(&ctx, seed2, seed2_len)) goto err; if (seed3 && !EVP_DigestSignUpdate(&ctx, seed3, seed3_len)) goto err; if (seed4 && !EVP_DigestSignUpdate(&ctx, seed4, seed4_len)) goto err; if (seed5 && !EVP_DigestSignUpdate(&ctx, seed5, seed5_len)) goto err; if (!EVP_DigestSignFinal(&ctx, A1, &A1_len)) goto err; for (;;) { /* Reinit mac contexts */ if (!EVP_DigestSignInit(&ctx, NULL, md, NULL, mac_key)) goto err; if (!EVP_DigestSignInit(&ctx_tmp, NULL, md, NULL, mac_key)) goto err; if (!EVP_DigestSignUpdate(&ctx, A1, A1_len)) goto err; if (!EVP_DigestSignUpdate(&ctx_tmp, A1, A1_len)) goto err; if (seed1 && !EVP_DigestSignUpdate(&ctx, seed1, seed1_len)) goto err; if (seed2 && !EVP_DigestSignUpdate(&ctx, seed2, seed2_len)) goto err; if (seed3 && !EVP_DigestSignUpdate(&ctx, seed3, seed3_len)) goto err; if (seed4 && !EVP_DigestSignUpdate(&ctx, seed4, seed4_len)) goto err; if (seed5 && !EVP_DigestSignUpdate(&ctx, seed5, seed5_len)) goto err; if (olen > chunk) { if (!EVP_DigestSignFinal(&ctx, out, &j)) goto err; out += j; olen -= j; /* calc the next A1 value */ if (!EVP_DigestSignFinal(&ctx_tmp, A1, &A1_len)) goto err; } else { /* last one */ if (!EVP_DigestSignFinal(&ctx, A1, &A1_len)) goto err; memcpy(out, A1, olen); break; } } ret = 1; err: EVP_PKEY_free(mac_key); EVP_MD_CTX_cleanup(&ctx); EVP_MD_CTX_cleanup(&ctx_tmp); OPENSSL_cleanse(A1, sizeof(A1)); return ret; } /* seed1 through seed5 are virtually concatenated */ static int tls1_PRF(long digest_mask, const void *seed1, int seed1_len, const void *seed2, int seed2_len, const void *seed3, int seed3_len, const void *seed4, int seed4_len, const void *seed5, int seed5_len, const unsigned char *sec, int slen, unsigned char *out1, unsigned char *out2, int olen) { int len, i, idx, count; const unsigned char *S1; long m; const EVP_MD *md; int ret = 0; /* Count number of digests and partition sec evenly */ count = 0; for (idx = 0; ssl_get_handshake_digest(idx, &m, &md); idx++) { if ((m << TLS1_PRF_DGST_SHIFT) & digest_mask) count++; } if (count == 0) { SSLerr(SSL_F_TLS1_PRF, SSL_R_SSL_HANDSHAKE_FAILURE); goto err; } len = slen / count; if (count == 1) slen = 0; S1 = sec; memset(out1, 0, olen); for (idx = 0; ssl_get_handshake_digest(idx, &m, &md); idx++) { if ((m << TLS1_PRF_DGST_SHIFT) & digest_mask) { if (!md) { SSLerr(SSL_F_TLS1_PRF, SSL_R_UNSUPPORTED_DIGEST_TYPE); goto err; } if (!tls1_P_hash(md , S1, len + (slen&1), seed1, seed1_len, seed2, seed2_len, seed3, seed3_len, seed4, seed4_len, seed5, seed5_len, out2, olen)) goto err; S1 += len; for (i = 0; i < olen; i++) { out1[i] ^= out2[i]; } } } ret = 1; err: return ret; } static int tls1_generate_key_block(SSL *s, unsigned char *km, unsigned char *tmp, int num) { int ret; ret = tls1_PRF(ssl_get_algorithm2(s), TLS_MD_KEY_EXPANSION_CONST, TLS_MD_KEY_EXPANSION_CONST_SIZE, s->s3->server_random, SSL3_RANDOM_SIZE, s->s3->client_random, SSL3_RANDOM_SIZE, NULL, 0, NULL, 0, s->session->master_key, s->session->master_key_length, km, tmp, num); return ret; } /* * tls1_aead_ctx_init allocates aead_ctx, if needed. It returns 1 on success * and 0 on failure. */ static int tls1_aead_ctx_init(SSL_AEAD_CTX **aead_ctx) { if (*aead_ctx != NULL) { EVP_AEAD_CTX_cleanup(&(*aead_ctx)->ctx); return (1); } *aead_ctx = malloc(sizeof(SSL_AEAD_CTX)); if (*aead_ctx == NULL) { SSLerr(SSL_F_TLS1_AEAD_CTX_INIT, ERR_R_MALLOC_FAILURE); return (0); } return (1); } static int tls1_change_cipher_state_aead(SSL *s, char is_read, const unsigned char *key, unsigned key_len, const unsigned char *iv, unsigned iv_len) { const EVP_AEAD *aead = s->s3->tmp.new_aead; SSL_AEAD_CTX *aead_ctx; if (is_read) { if (!tls1_aead_ctx_init(&s->aead_read_ctx)) return 0; aead_ctx = s->aead_read_ctx; } else { if (!tls1_aead_ctx_init(&s->aead_write_ctx)) return 0; aead_ctx = s->aead_write_ctx; } if (!EVP_AEAD_CTX_init(&aead_ctx->ctx, aead, key, key_len, EVP_AEAD_DEFAULT_TAG_LENGTH, NULL)) return (0); if (iv_len > sizeof(aead_ctx->fixed_nonce)) { SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE_AEAD, ERR_R_INTERNAL_ERROR); return (0); } memcpy(aead_ctx->fixed_nonce, iv, iv_len); aead_ctx->fixed_nonce_len = iv_len; aead_ctx->variable_nonce_len = 8; /* always the case, currently. */ aead_ctx->variable_nonce_in_record = (s->s3->tmp.new_cipher->algorithm2 & SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD) != 0; if (aead_ctx->variable_nonce_len + aead_ctx->fixed_nonce_len != EVP_AEAD_nonce_length(aead)) { SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE_AEAD, ERR_R_INTERNAL_ERROR); return (0); } aead_ctx->tag_len = EVP_AEAD_max_overhead(aead); return (1); } /* * tls1_change_cipher_state_cipher performs the work needed to switch cipher * states when using EVP_CIPHER. The argument is_read is true iff this function * is being called due to reading, as opposed to writing, a ChangeCipherSpec * message. In order to support export ciphersuites, use_client_keys indicates * whether the key material provided is in the "client write" direction. */ static int tls1_change_cipher_state_cipher(SSL *s, char is_read, char use_client_keys, const unsigned char *mac_secret, unsigned int mac_secret_size, const unsigned char *key, unsigned int key_len, const unsigned char *iv, unsigned int iv_len) { EVP_CIPHER_CTX *cipher_ctx; const EVP_CIPHER *cipher; EVP_MD_CTX *mac_ctx; const EVP_MD *mac; int mac_type; cipher = s->s3->tmp.new_sym_enc; mac = s->s3->tmp.new_hash; mac_type = s->s3->tmp.new_mac_pkey_type; if (is_read) { if (s->s3->tmp.new_cipher->algorithm2 & TLS1_STREAM_MAC) s->mac_flags |= SSL_MAC_FLAG_READ_MAC_STREAM; else s->mac_flags &= ~SSL_MAC_FLAG_READ_MAC_STREAM; EVP_CIPHER_CTX_free(s->enc_read_ctx); s->enc_read_ctx = NULL; EVP_MD_CTX_destroy(s->read_hash); s->read_hash = NULL; if ((cipher_ctx = EVP_CIPHER_CTX_new()) == NULL) goto err; s->enc_read_ctx = cipher_ctx; if ((mac_ctx = EVP_MD_CTX_create()) == NULL) goto err; s->read_hash = mac_ctx; } else { if (s->s3->tmp.new_cipher->algorithm2 & TLS1_STREAM_MAC) s->mac_flags |= SSL_MAC_FLAG_WRITE_MAC_STREAM; else s->mac_flags &= ~SSL_MAC_FLAG_WRITE_MAC_STREAM; /* * DTLS fragments retain a pointer to the compression, cipher * and hash contexts, so that it can restore state in order * to perform retransmissions. As such, we cannot free write * contexts that are used for DTLS - these are instead freed * by DTLS when its frees a ChangeCipherSpec fragment. */ if (!SSL_IS_DTLS(s)) { EVP_CIPHER_CTX_free(s->enc_write_ctx); s->enc_write_ctx = NULL; EVP_MD_CTX_destroy(s->write_hash); s->write_hash = NULL; } if ((cipher_ctx = EVP_CIPHER_CTX_new()) == NULL) goto err; s->enc_write_ctx = cipher_ctx; if ((mac_ctx = EVP_MD_CTX_create()) == NULL) goto err; s->write_hash = mac_ctx; } if (EVP_CIPHER_mode(cipher) == EVP_CIPH_GCM_MODE) { EVP_CipherInit_ex(cipher_ctx, cipher, NULL, key, NULL, !is_read); EVP_CIPHER_CTX_ctrl(cipher_ctx, EVP_CTRL_GCM_SET_IV_FIXED, iv_len, (unsigned char *)iv); } else EVP_CipherInit_ex(cipher_ctx, cipher, NULL, key, iv, !is_read); if (!(EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER)) { EVP_PKEY *mac_key = EVP_PKEY_new_mac_key(mac_type, NULL, mac_secret, mac_secret_size); if (mac_key == NULL) goto err; EVP_DigestSignInit(mac_ctx, NULL, mac, NULL, mac_key); EVP_PKEY_free(mac_key); } else if (mac_secret_size > 0) { /* Needed for "composite" AEADs, such as RC4-HMAC-MD5 */ EVP_CIPHER_CTX_ctrl(cipher_ctx, EVP_CTRL_AEAD_SET_MAC_KEY, mac_secret_size, (unsigned char *)mac_secret); } return (1); err: SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE_CIPHER, ERR_R_MALLOC_FAILURE); return (0); } int tls1_change_cipher_state(SSL *s, int which) { const unsigned char *client_write_mac_secret, *server_write_mac_secret; const unsigned char *client_write_key, *server_write_key; const unsigned char *client_write_iv, *server_write_iv; const unsigned char *mac_secret, *key, *iv; int mac_secret_size, key_len, iv_len; unsigned char *key_block, *seq; const EVP_CIPHER *cipher; const EVP_AEAD *aead; char is_read, use_client_keys; cipher = s->s3->tmp.new_sym_enc; aead = s->s3->tmp.new_aead; /* * is_read is true if we have just read a ChangeCipherSpec message, * that is we need to update the read cipherspec. Otherwise we have * just written one. */ is_read = (which & SSL3_CC_READ) != 0; /* * use_client_keys is true if we wish to use the keys for the "client * write" direction. This is the case if we're a client sending a * ChangeCipherSpec, or a server reading a client's ChangeCipherSpec. */ use_client_keys = ((which == SSL3_CHANGE_CIPHER_CLIENT_WRITE) || (which == SSL3_CHANGE_CIPHER_SERVER_READ)); /* * Reset sequence number to zero - for DTLS this is handled in * dtls1_reset_seq_numbers(). */ if (!SSL_IS_DTLS(s)) { seq = is_read ? s->s3->read_sequence : s->s3->write_sequence; memset(seq, 0, SSL3_SEQUENCE_SIZE); } if (aead != NULL) { key_len = EVP_AEAD_key_length(aead); iv_len = SSL_CIPHER_AEAD_FIXED_NONCE_LEN(s->s3->tmp.new_cipher); } else { key_len = EVP_CIPHER_key_length(cipher); iv_len = EVP_CIPHER_iv_length(cipher); /* If GCM mode only part of IV comes from PRF. */ if (EVP_CIPHER_mode(cipher) == EVP_CIPH_GCM_MODE) iv_len = EVP_GCM_TLS_FIXED_IV_LEN; } mac_secret_size = s->s3->tmp.new_mac_secret_size; key_block = s->s3->tmp.key_block; client_write_mac_secret = key_block; key_block += mac_secret_size; server_write_mac_secret = key_block; key_block += mac_secret_size; client_write_key = key_block; key_block += key_len; server_write_key = key_block; key_block += key_len; client_write_iv = key_block; key_block += iv_len; server_write_iv = key_block; key_block += iv_len; if (use_client_keys) { mac_secret = client_write_mac_secret; key = client_write_key; iv = client_write_iv; } else { mac_secret = server_write_mac_secret; key = server_write_key; iv = server_write_iv; } if (key_block - s->s3->tmp.key_block != s->s3->tmp.key_block_length) { SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR); goto err2; } if (is_read) { memcpy(s->s3->read_mac_secret, mac_secret, mac_secret_size); s->s3->read_mac_secret_size = mac_secret_size; } else { memcpy(s->s3->write_mac_secret, mac_secret, mac_secret_size); s->s3->write_mac_secret_size = mac_secret_size; } if (aead != NULL) { return tls1_change_cipher_state_aead(s, is_read, key, key_len, iv, iv_len); } return tls1_change_cipher_state_cipher(s, is_read, use_client_keys, mac_secret, mac_secret_size, key, key_len, iv, iv_len); err2: return (0); } int tls1_setup_key_block(SSL *s) { unsigned char *key_block, *tmp_block = NULL; int mac_type = NID_undef, mac_secret_size = 0; int key_block_len, key_len, iv_len; const EVP_CIPHER *cipher = NULL; const EVP_AEAD *aead = NULL; const EVP_MD *mac = NULL; int ret = 0; if (s->s3->tmp.key_block_length != 0) return (1); if (s->session->cipher && (s->session->cipher->algorithm2 & SSL_CIPHER_ALGORITHM2_AEAD)) { if (!ssl_cipher_get_evp_aead(s->session, &aead)) { SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK, SSL_R_CIPHER_OR_HASH_UNAVAILABLE); return (0); } key_len = EVP_AEAD_key_length(aead); iv_len = SSL_CIPHER_AEAD_FIXED_NONCE_LEN(s->session->cipher); } else { if (!ssl_cipher_get_evp(s->session, &cipher, &mac, &mac_type, &mac_secret_size)) { SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK, SSL_R_CIPHER_OR_HASH_UNAVAILABLE); return (0); } key_len = EVP_CIPHER_key_length(cipher); iv_len = EVP_CIPHER_iv_length(cipher); /* If GCM mode only part of IV comes from PRF. */ if (EVP_CIPHER_mode(cipher) == EVP_CIPH_GCM_MODE) iv_len = EVP_GCM_TLS_FIXED_IV_LEN; } s->s3->tmp.new_aead = aead; s->s3->tmp.new_sym_enc = cipher; s->s3->tmp.new_hash = mac; s->s3->tmp.new_mac_pkey_type = mac_type; s->s3->tmp.new_mac_secret_size = mac_secret_size; key_block_len = (mac_secret_size + key_len + iv_len) * 2; ssl3_cleanup_key_block(s); if ((key_block = malloc(key_block_len)) == NULL) { SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK, ERR_R_MALLOC_FAILURE); goto err; } s->s3->tmp.key_block_length = key_block_len; s->s3->tmp.key_block = key_block; if ((tmp_block = malloc(key_block_len)) == NULL) { SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK, ERR_R_MALLOC_FAILURE); goto err; } if (!tls1_generate_key_block(s, key_block, tmp_block, key_block_len)) goto err; if (!(s->options & SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS) && s->method->version <= TLS1_VERSION) { /* * Enable vulnerability countermeasure for CBC ciphers with * known-IV problem (http://www.openssl.org/~bodo/tls-cbc.txt) */ s->s3->need_empty_fragments = 1; if (s->session->cipher != NULL) { if (s->session->cipher->algorithm_enc == SSL_eNULL) s->s3->need_empty_fragments = 0; #ifndef OPENSSL_NO_RC4 if (s->session->cipher->algorithm_enc == SSL_RC4) s->s3->need_empty_fragments = 0; #endif } } ret = 1; err: if (tmp_block) { OPENSSL_cleanse(tmp_block, key_block_len); free(tmp_block); } return (ret); } /* tls1_enc encrypts/decrypts the record in |s->wrec| / |s->rrec|, respectively. * * Returns: * 0: (in non-constant time) if the record is publically invalid (i.e. too * short etc). * 1: if the record's padding is valid / the encryption was successful. * -1: if the record's padding/AEAD-authenticator is invalid or, if sending, * an internal error occured. */ int tls1_enc(SSL *s, int send) { const SSL_AEAD_CTX *aead; const EVP_CIPHER *enc; EVP_CIPHER_CTX *ds; SSL3_RECORD *rec; unsigned char *seq; unsigned long l; int bs, i, j, k, pad = 0, ret, mac_size = 0; if (send) { aead = s->aead_write_ctx; rec = &s->s3->wrec; seq = s->s3->write_sequence; } else { aead = s->aead_read_ctx; rec = &s->s3->rrec; seq = s->s3->read_sequence; } if (aead) { unsigned char ad[13], *in, *out, nonce[16]; unsigned nonce_used; ssize_t n; if (SSL_IS_DTLS(s)) { dtls1_build_sequence_number(ad, seq, send ? s->d1->w_epoch : s->d1->r_epoch); } else { memcpy(ad, seq, SSL3_SEQUENCE_SIZE); ssl3_record_sequence_increment(seq); } ad[8] = rec->type; ad[9] = (unsigned char)(s->version >> 8); ad[10] = (unsigned char)(s->version); if (aead->fixed_nonce_len + aead->variable_nonce_len > sizeof(nonce) || aead->variable_nonce_len > 8) return -1; /* internal error - should never happen. */ memcpy(nonce, aead->fixed_nonce, aead->fixed_nonce_len); nonce_used = aead->fixed_nonce_len; if (send) { size_t len = rec->length; size_t eivlen = 0; in = rec->input; out = rec->data; /* * When sending we use the sequence number as the * variable part of the nonce. */ if (aead->variable_nonce_len > 8) return -1; memcpy(nonce + nonce_used, ad, aead->variable_nonce_len); nonce_used += aead->variable_nonce_len; /* * In do_ssl3_write, rec->input is moved forward by * variable_nonce_len in order to leave space for the * variable nonce. Thus we can copy the sequence number * bytes into place without overwriting any of the * plaintext. */ if (aead->variable_nonce_in_record) { memcpy(out, ad, aead->variable_nonce_len); len -= aead->variable_nonce_len; eivlen = aead->variable_nonce_len; } ad[11] = len >> 8; ad[12] = len & 0xff; if (!EVP_AEAD_CTX_seal(&aead->ctx, out + eivlen, &n, len + aead->tag_len, nonce, nonce_used, in + eivlen, len, ad, sizeof(ad))) return -1; if (n >= 0 && aead->variable_nonce_in_record) n += aead->variable_nonce_len; } else { /* receive */ size_t len = rec->length; if (rec->data != rec->input) return -1; /* internal error - should never happen. */ out = in = rec->input; if (len < aead->variable_nonce_len) return 0; memcpy(nonce + nonce_used, aead->variable_nonce_in_record ? in : ad, aead->variable_nonce_len); nonce_used += aead->variable_nonce_len; if (aead->variable_nonce_in_record) { in += aead->variable_nonce_len; len -= aead->variable_nonce_len; out += aead->variable_nonce_len; } if (len < aead->tag_len) return 0; len -= aead->tag_len; ad[11] = len >> 8; ad[12] = len & 0xff; if (!EVP_AEAD_CTX_open(&aead->ctx, out, &n, len, nonce, nonce_used, in, len + aead->tag_len, ad, sizeof(ad))) return -1; rec->data = rec->input = out; } if (n == -1) return -1; rec->length = n; return 1; } if (send) { if (EVP_MD_CTX_md(s->write_hash)) { int n = EVP_MD_CTX_size(s->write_hash); OPENSSL_assert(n >= 0); } ds = s->enc_write_ctx; if (s->enc_write_ctx == NULL) enc = NULL; else { int ivlen = 0; enc = EVP_CIPHER_CTX_cipher(s->enc_write_ctx); if (SSL_USE_EXPLICIT_IV(s) && EVP_CIPHER_mode(enc) == EVP_CIPH_CBC_MODE) ivlen = EVP_CIPHER_iv_length(enc); if (ivlen > 1) { if (rec->data != rec->input) /* we can't write into the input stream: * Can this ever happen?? (steve) */ fprintf(stderr, "%s:%d: rec->data != rec->input\n", __FILE__, __LINE__); else if (RAND_bytes(rec->input, ivlen) <= 0) return -1; } } } else { if (EVP_MD_CTX_md(s->read_hash)) { int n = EVP_MD_CTX_size(s->read_hash); OPENSSL_assert(n >= 0); } ds = s->enc_read_ctx; if (s->enc_read_ctx == NULL) enc = NULL; else enc = EVP_CIPHER_CTX_cipher(s->enc_read_ctx); } if ((s->session == NULL) || (ds == NULL) || (enc == NULL)) { memmove(rec->data, rec->input, rec->length); rec->input = rec->data; ret = 1; } else { l = rec->length; bs = EVP_CIPHER_block_size(ds->cipher); if (EVP_CIPHER_flags(ds->cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) { unsigned char buf[13]; if (SSL_IS_DTLS(s)) { dtls1_build_sequence_number(buf, seq, send ? s->d1->w_epoch : s->d1->r_epoch); } else { memcpy(buf, seq, SSL3_SEQUENCE_SIZE); ssl3_record_sequence_increment(seq); } buf[8] = rec->type; buf[9] = (unsigned char)(s->version >> 8); buf[10] = (unsigned char)(s->version); buf[11] = rec->length >> 8; buf[12] = rec->length & 0xff; pad = EVP_CIPHER_CTX_ctrl(ds, EVP_CTRL_AEAD_TLS1_AAD, 13, buf); if (send) { l += pad; rec->length += pad; } } else if ((bs != 1) && send) { i = bs - ((int)l % bs); /* Add weird padding of upto 256 bytes */ /* we need to add 'i' padding bytes of value j */ j = i - 1; if (s->options & SSL_OP_TLS_BLOCK_PADDING_BUG) { if (s->s3->flags & TLS1_FLAGS_TLS_PADDING_BUG) j++; } for (k = (int)l; k < (int)(l + i); k++) rec->input[k] = j; l += i; rec->length += i; } if (!send) { if (l == 0 || l % bs != 0) return 0; } i = EVP_Cipher(ds, rec->data, rec->input, l); if ((EVP_CIPHER_flags(ds->cipher) & EVP_CIPH_FLAG_CUSTOM_CIPHER) ? (i < 0) : (i == 0)) return -1; /* AEAD can fail to verify MAC */ if (EVP_CIPHER_mode(enc) == EVP_CIPH_GCM_MODE && !send) { rec->data += EVP_GCM_TLS_EXPLICIT_IV_LEN; rec->input += EVP_GCM_TLS_EXPLICIT_IV_LEN; rec->length -= EVP_GCM_TLS_EXPLICIT_IV_LEN; } ret = 1; if (EVP_MD_CTX_md(s->read_hash) != NULL) mac_size = EVP_MD_CTX_size(s->read_hash); if ((bs != 1) && !send) ret = tls1_cbc_remove_padding(s, rec, bs, mac_size); if (pad && !send) rec->length -= pad; } return ret; } int tls1_cert_verify_mac(SSL *s, int md_nid, unsigned char *out) { EVP_MD_CTX ctx, *d = NULL; unsigned int ret; int i; if (s->s3->handshake_buffer) if (!ssl3_digest_cached_records(s)) return 0; for (i = 0; i < SSL_MAX_DIGEST; i++) { if (s->s3->handshake_dgst[i] && EVP_MD_CTX_type(s->s3->handshake_dgst[i]) == md_nid) { d = s->s3->handshake_dgst[i]; break; } } if (d == NULL) { SSLerr(SSL_F_TLS1_CERT_VERIFY_MAC, SSL_R_NO_REQUIRED_DIGEST); return 0; } EVP_MD_CTX_init(&ctx); if (!EVP_MD_CTX_copy_ex(&ctx, d)) return 0; EVP_DigestFinal_ex(&ctx, out, &ret); EVP_MD_CTX_cleanup(&ctx); return ((int)ret); } int tls1_final_finish_mac(SSL *s, const char *str, int slen, unsigned char *out) { unsigned int i; EVP_MD_CTX ctx; unsigned char buf[2*EVP_MAX_MD_SIZE]; unsigned char *q, buf2[12]; int idx; long mask; int err = 0; const EVP_MD *md; q = buf; if (s->s3->handshake_buffer) if (!ssl3_digest_cached_records(s)) return 0; EVP_MD_CTX_init(&ctx); for (idx = 0; ssl_get_handshake_digest(idx, &mask, &md); idx++) { if (ssl_get_algorithm2(s) & mask) { int hashsize = EVP_MD_size(md); EVP_MD_CTX *hdgst = s->s3->handshake_dgst[idx]; if (!hdgst || hashsize < 0 || hashsize > (int)(sizeof buf - (size_t)(q - buf))) { /* internal error: 'buf' is too small for this cipersuite! */ err = 1; } else { if (!EVP_MD_CTX_copy_ex(&ctx, hdgst) || !EVP_DigestFinal_ex(&ctx, q, &i) || (i != (unsigned int)hashsize)) err = 1; q += hashsize; } } } if (!tls1_PRF(ssl_get_algorithm2(s), str, slen, buf, (int)(q - buf), NULL, 0, NULL, 0, NULL, 0, s->session->master_key, s->session->master_key_length, out, buf2, sizeof buf2)) err = 1; EVP_MD_CTX_cleanup(&ctx); if (err) return 0; else return sizeof buf2; } int tls1_mac(SSL *ssl, unsigned char *md, int send) { SSL3_RECORD *rec; unsigned char *seq; EVP_MD_CTX *hash; size_t md_size, orig_len; EVP_MD_CTX hmac, *mac_ctx; unsigned char header[13]; int stream_mac = (send ? (ssl->mac_flags & SSL_MAC_FLAG_WRITE_MAC_STREAM) : (ssl->mac_flags & SSL_MAC_FLAG_READ_MAC_STREAM)); int t; if (send) { rec = &(ssl->s3->wrec); seq = &(ssl->s3->write_sequence[0]); hash = ssl->write_hash; } else { rec = &(ssl->s3->rrec); seq = &(ssl->s3->read_sequence[0]); hash = ssl->read_hash; } t = EVP_MD_CTX_size(hash); OPENSSL_assert(t >= 0); md_size = t; /* I should fix this up TLS TLS TLS TLS TLS XXXXXXXX */ if (stream_mac) { mac_ctx = hash; } else { if (!EVP_MD_CTX_copy(&hmac, hash)) return -1; mac_ctx = &hmac; } if (SSL_IS_DTLS(ssl)) dtls1_build_sequence_number(header, seq, send ? ssl->d1->w_epoch : ssl->d1->r_epoch); else memcpy(header, seq, SSL3_SEQUENCE_SIZE); /* kludge: tls1_cbc_remove_padding passes padding length in rec->type */ orig_len = rec->length + md_size + ((unsigned int)rec->type >> 8); rec->type &= 0xff; header[8] = rec->type; header[9] = (unsigned char)(ssl->version >> 8); header[10] = (unsigned char)(ssl->version); header[11] = (rec->length) >> 8; header[12] = (rec->length) & 0xff; if (!send && EVP_CIPHER_CTX_mode(ssl->enc_read_ctx) == EVP_CIPH_CBC_MODE && ssl3_cbc_record_digest_supported(mac_ctx)) { /* This is a CBC-encrypted record. We must avoid leaking any * timing-side channel information about how many blocks of * data we are hashing because that gives an attacker a * timing-oracle. */ ssl3_cbc_digest_record(mac_ctx, md, &md_size, header, rec->input, rec->length + md_size, orig_len, ssl->s3->read_mac_secret, ssl->s3->read_mac_secret_size, 0 /* not SSLv3 */); } else { EVP_DigestSignUpdate(mac_ctx, header, sizeof(header)); EVP_DigestSignUpdate(mac_ctx, rec->input, rec->length); t = EVP_DigestSignFinal(mac_ctx, md, &md_size); OPENSSL_assert(t > 0); } if (!stream_mac) EVP_MD_CTX_cleanup(&hmac); if (!SSL_IS_DTLS(ssl)) ssl3_record_sequence_increment(seq); return (md_size); } int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p, int len) { unsigned char buff[SSL_MAX_MASTER_KEY_LENGTH]; const void *co = NULL, *so = NULL; int col = 0, sol = 0; tls1_PRF(ssl_get_algorithm2(s), TLS_MD_MASTER_SECRET_CONST, TLS_MD_MASTER_SECRET_CONST_SIZE, s->s3->client_random, SSL3_RANDOM_SIZE, co, col, s->s3->server_random, SSL3_RANDOM_SIZE, so, sol, p, len, s->session->master_key, buff, sizeof buff); return (SSL3_MASTER_SECRET_SIZE); } int tls1_export_keying_material(SSL *s, unsigned char *out, size_t olen, const char *label, size_t llen, const unsigned char *context, size_t contextlen, int use_context) { unsigned char *buff; unsigned char *val = NULL; size_t vallen, currentvalpos; int rv; buff = malloc(olen); if (buff == NULL) goto err2; /* construct PRF arguments * we construct the PRF argument ourself rather than passing separate * values into the TLS PRF to ensure that the concatenation of values * does not create a prohibited label. */ vallen = llen + SSL3_RANDOM_SIZE * 2; if (use_context) { vallen += 2 + contextlen; } val = malloc(vallen); if (val == NULL) goto err2; currentvalpos = 0; memcpy(val + currentvalpos, (unsigned char *) label, llen); currentvalpos += llen; memcpy(val + currentvalpos, s->s3->client_random, SSL3_RANDOM_SIZE); currentvalpos += SSL3_RANDOM_SIZE; memcpy(val + currentvalpos, s->s3->server_random, SSL3_RANDOM_SIZE); currentvalpos += SSL3_RANDOM_SIZE; if (use_context) { val[currentvalpos] = (contextlen >> 8) & 0xff; currentvalpos++; val[currentvalpos] = contextlen & 0xff; currentvalpos++; if ((contextlen > 0) || (context != NULL)) { memcpy(val + currentvalpos, context, contextlen); } } /* disallow prohibited labels * note that SSL3_RANDOM_SIZE > max(prohibited label len) = * 15, so size of val > max(prohibited label len) = 15 and the * comparisons won't have buffer overflow */ if (memcmp(val, TLS_MD_CLIENT_FINISH_CONST, TLS_MD_CLIENT_FINISH_CONST_SIZE) == 0) goto err1; if (memcmp(val, TLS_MD_SERVER_FINISH_CONST, TLS_MD_SERVER_FINISH_CONST_SIZE) == 0) goto err1; if (memcmp(val, TLS_MD_MASTER_SECRET_CONST, TLS_MD_MASTER_SECRET_CONST_SIZE) == 0) goto err1; if (memcmp(val, TLS_MD_KEY_EXPANSION_CONST, TLS_MD_KEY_EXPANSION_CONST_SIZE) == 0) goto err1; rv = tls1_PRF(ssl_get_algorithm2(s), val, vallen, NULL, 0, NULL, 0, NULL, 0, NULL, 0, s->session->master_key, s->session->master_key_length, out, buff, olen); goto ret; err1: SSLerr(SSL_F_TLS1_EXPORT_KEYING_MATERIAL, SSL_R_TLS_ILLEGAL_EXPORTER_LABEL); rv = 0; goto ret; err2: SSLerr(SSL_F_TLS1_EXPORT_KEYING_MATERIAL, ERR_R_MALLOC_FAILURE); rv = 0; ret: free(buff); free(val); return (rv); } int tls1_alert_code(int code) { switch (code) { case SSL_AD_CLOSE_NOTIFY: return (SSL3_AD_CLOSE_NOTIFY); case SSL_AD_UNEXPECTED_MESSAGE: return (SSL3_AD_UNEXPECTED_MESSAGE); case SSL_AD_BAD_RECORD_MAC: return (SSL3_AD_BAD_RECORD_MAC); case SSL_AD_DECRYPTION_FAILED: return (TLS1_AD_DECRYPTION_FAILED); case SSL_AD_RECORD_OVERFLOW: return (TLS1_AD_RECORD_OVERFLOW); case SSL_AD_DECOMPRESSION_FAILURE: return (SSL3_AD_DECOMPRESSION_FAILURE); case SSL_AD_HANDSHAKE_FAILURE: return (SSL3_AD_HANDSHAKE_FAILURE); case SSL_AD_NO_CERTIFICATE: return (-1); case SSL_AD_BAD_CERTIFICATE: return (SSL3_AD_BAD_CERTIFICATE); case SSL_AD_UNSUPPORTED_CERTIFICATE: return (SSL3_AD_UNSUPPORTED_CERTIFICATE); case SSL_AD_CERTIFICATE_REVOKED: return (SSL3_AD_CERTIFICATE_REVOKED); case SSL_AD_CERTIFICATE_EXPIRED: return (SSL3_AD_CERTIFICATE_EXPIRED); case SSL_AD_CERTIFICATE_UNKNOWN: return (SSL3_AD_CERTIFICATE_UNKNOWN); case SSL_AD_ILLEGAL_PARAMETER: return (SSL3_AD_ILLEGAL_PARAMETER); case SSL_AD_UNKNOWN_CA: return (TLS1_AD_UNKNOWN_CA); case SSL_AD_ACCESS_DENIED: return (TLS1_AD_ACCESS_DENIED); case SSL_AD_DECODE_ERROR: return (TLS1_AD_DECODE_ERROR); case SSL_AD_DECRYPT_ERROR: return (TLS1_AD_DECRYPT_ERROR); case SSL_AD_EXPORT_RESTRICTION: return (TLS1_AD_EXPORT_RESTRICTION); case SSL_AD_PROTOCOL_VERSION: return (TLS1_AD_PROTOCOL_VERSION); case SSL_AD_INSUFFICIENT_SECURITY: return (TLS1_AD_INSUFFICIENT_SECURITY); case SSL_AD_INTERNAL_ERROR: return (TLS1_AD_INTERNAL_ERROR); case SSL_AD_USER_CANCELLED: return (TLS1_AD_USER_CANCELLED); case SSL_AD_NO_RENEGOTIATION: return (TLS1_AD_NO_RENEGOTIATION); case SSL_AD_UNSUPPORTED_EXTENSION: return (TLS1_AD_UNSUPPORTED_EXTENSION); case SSL_AD_CERTIFICATE_UNOBTAINABLE: return (TLS1_AD_CERTIFICATE_UNOBTAINABLE); case SSL_AD_UNRECOGNIZED_NAME: return (TLS1_AD_UNRECOGNIZED_NAME); case SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE: return (TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE); case SSL_AD_BAD_CERTIFICATE_HASH_VALUE: return (TLS1_AD_BAD_CERTIFICATE_HASH_VALUE); case SSL_AD_UNKNOWN_PSK_IDENTITY: return (TLS1_AD_UNKNOWN_PSK_IDENTITY); default: return (-1); } } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/ssl_txt.c0000644000175000017500000001605612360020705017410 0ustar /* $OpenBSD: ssl_txt.c,v 1.22 2014/07/10 08:51:15 tedu Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright 2005 Nokia. All rights reserved. * * The portions of the attached software ("Contribution") is developed by * Nokia Corporation and is licensed pursuant to the OpenSSL open source * license. * * The Contribution, originally written by Mika Kousa and Pasi Eronen of * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites * support (see RFC 4279) to OpenSSL. * * No patent licenses or other rights except those expressly stated in * the OpenSSL open source license shall be deemed granted or received * expressly, by implication, estoppel, or otherwise. * * No assurances are provided by Nokia that the Contribution does not * infringe the patent or other intellectual property rights of any third * party or that the license provides you with all the necessary rights * to make use of the Contribution. * * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR * OTHERWISE. */ #include #include #include "ssl_locl.h" int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *x) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file_internal())) == NULL) { SSLerr(SSL_F_SSL_SESSION_PRINT_FP, ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, fp, BIO_NOCLOSE); ret = SSL_SESSION_print(b, x); BIO_free(b); return (ret); } int SSL_SESSION_print(BIO *bp, const SSL_SESSION *x) { unsigned int i; const char *s; if (x == NULL) goto err; if (BIO_puts(bp, "SSL-Session:\n") <= 0) goto err; if (x->ssl_version == SSL3_VERSION) s = "SSLv3"; else if (x->ssl_version == TLS1_2_VERSION) s = "TLSv1.2"; else if (x->ssl_version == TLS1_1_VERSION) s = "TLSv1.1"; else if (x->ssl_version == TLS1_VERSION) s = "TLSv1"; else if (x->ssl_version == DTLS1_VERSION) s = "DTLSv1"; else if (x->ssl_version == DTLS1_BAD_VER) s = "DTLSv1-bad"; else s = "unknown"; if (BIO_printf(bp, " Protocol : %s\n", s) <= 0) goto err; if (x->cipher == NULL) { if (((x->cipher_id) & 0xff000000) == 0x02000000) { if (BIO_printf(bp, " Cipher : %06lX\n", x->cipher_id&0xffffff) <= 0) goto err; } else { if (BIO_printf(bp, " Cipher : %04lX\n", x->cipher_id&0xffff) <= 0) goto err; } } else { if (BIO_printf(bp, " Cipher : %s\n",((x->cipher == NULL)?"unknown":x->cipher->name)) <= 0) goto err; } if (BIO_puts(bp, " Session-ID: ") <= 0) goto err; for (i = 0; i < x->session_id_length; i++) { if (BIO_printf(bp, "%02X", x->session_id[i]) <= 0) goto err; } if (BIO_puts(bp, "\n Session-ID-ctx: ") <= 0) goto err; for (i = 0; i < x->sid_ctx_length; i++) { if (BIO_printf(bp, "%02X", x->sid_ctx[i]) <= 0) goto err; } if (BIO_puts(bp, "\n Master-Key: ") <= 0) goto err; for (i = 0; i < (unsigned int)x->master_key_length; i++) { if (BIO_printf(bp, "%02X", x->master_key[i]) <= 0) goto err; } if (x->tlsext_tick_lifetime_hint) { if (BIO_printf(bp, "\n TLS session ticket lifetime hint: %ld (seconds)", x->tlsext_tick_lifetime_hint) <= 0) goto err; } if (x->tlsext_tick) { if (BIO_puts(bp, "\n TLS session ticket:\n") <= 0) goto err; if (BIO_dump_indent(bp, (char *)x->tlsext_tick, x->tlsext_ticklen, 4) <= 0) goto err; } if (x->time != 0) { if (BIO_printf(bp, "\n Start Time: %lld", (long long)x->time) <= 0) goto err; } if (x->timeout != 0L) { if (BIO_printf(bp, "\n Timeout : %ld (sec)", x->timeout) <= 0) goto err; } if (BIO_puts(bp, "\n") <= 0) goto err; if (BIO_puts(bp, " Verify return code: ") <= 0) goto err; if (BIO_printf(bp, "%ld (%s)\n", x->verify_result, X509_verify_cert_error_string(x->verify_result)) <= 0) goto err; return (1); err: return (0); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/s23_pkt.c0000644000175000017500000001013412360020705017164 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include "ssl_locl.h" #include #include int ssl23_write_bytes(SSL *s) { int i, num, tot; char *buf; buf = s->init_buf->data; tot = s->init_off; num = s->init_num; for (;;) { s->rwstate = SSL_WRITING; i = BIO_write(s->wbio, &(buf[tot]), num); if (i <= 0) { s->init_off = tot; s->init_num = num; return (i); } s->rwstate = SSL_NOTHING; if (i == num) return (tot + i); num -= i; tot += i; } } /* return regularly only when we have read (at least) 'n' bytes */ int ssl23_read_bytes(SSL *s, int n) { unsigned char *p; int j; if (s->packet_length < (unsigned int)n) { p = s->packet; for (;;) { s->rwstate = SSL_READING; j = BIO_read(s->rbio, (char *)&(p[s->packet_length]), n - s->packet_length); if (j <= 0) return (j); s->rwstate = SSL_NOTHING; s->packet_length += j; if (s->packet_length >= (unsigned int)n) return (s->packet_length); } } return (n); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/s23_srvr.c0000644000175000017500000004174012360020705017371 0ustar /* $OpenBSD: s23_srvr.c,v 1.30 2014/07/10 08:51:14 tedu Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include "ssl_locl.h" #include #include #include #include static const SSL_METHOD *ssl23_get_server_method(int ver); int ssl23_get_client_hello(SSL *s); const SSL_METHOD SSLv23_server_method_data = { .version = TLS1_2_VERSION, .ssl_new = tls1_new, .ssl_clear = tls1_clear, .ssl_free = tls1_free, .ssl_accept = ssl23_accept, .ssl_connect = ssl_undefined_function, .ssl_read = ssl23_read, .ssl_peek = ssl23_peek, .ssl_write = ssl23_write, .ssl_shutdown = ssl_undefined_function, .ssl_renegotiate = ssl_undefined_function, .ssl_renegotiate_check = ssl_ok, .ssl_get_message = ssl3_get_message, .ssl_read_bytes = ssl3_read_bytes, .ssl_write_bytes = ssl3_write_bytes, .ssl_dispatch_alert = ssl3_dispatch_alert, .ssl_ctrl = ssl3_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl23_put_cipher_by_char, .ssl_pending = ssl_undefined_const_function, .num_ciphers = ssl3_num_ciphers, .get_cipher = ssl3_get_cipher, .get_ssl_method = ssl23_get_server_method, .get_timeout = ssl23_default_timeout, .ssl3_enc = &ssl3_undef_enc_method, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD * SSLv23_server_method(void) { return &SSLv23_server_method_data; } static const SSL_METHOD * ssl23_get_server_method(int ver) { if (ver == SSL3_VERSION) return (SSLv3_server_method()); if (ver == TLS1_VERSION) return (TLSv1_server_method()); if (ver == TLS1_1_VERSION) return (TLSv1_1_server_method()); if (ver == TLS1_2_VERSION) return (TLSv1_2_server_method()); return (NULL); } int ssl23_accept(SSL *s) { void (*cb)(const SSL *ssl, int type, int val) = NULL; int ret = -1; int new_state, state; ERR_clear_error(); errno = 0; if (s->info_callback != NULL) cb = s->info_callback; else if (s->ctx->info_callback != NULL) cb = s->ctx->info_callback; s->in_handshake++; if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); for (;;) { state = s->state; switch (s->state) { case SSL_ST_BEFORE: case SSL_ST_ACCEPT: case SSL_ST_BEFORE|SSL_ST_ACCEPT: case SSL_ST_OK|SSL_ST_ACCEPT: s->server = 1; if (cb != NULL) cb(s, SSL_CB_HANDSHAKE_START, 1); /* s->version=SSL3_VERSION; */ s->type = SSL_ST_ACCEPT; if (s->init_buf == NULL) { BUF_MEM *buf; if ((buf = BUF_MEM_new()) == NULL) { ret = -1; goto end; } if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { BUF_MEM_free(buf); ret = -1; goto end; } s->init_buf = buf; } ssl3_init_finished_mac(s); s->state = SSL23_ST_SR_CLNT_HELLO_A; s->ctx->stats.sess_accept++; s->init_num = 0; break; case SSL23_ST_SR_CLNT_HELLO_A: case SSL23_ST_SR_CLNT_HELLO_B: s->shutdown = 0; ret = ssl23_get_client_hello(s); if (ret >= 0) cb = NULL; goto end; /* break; */ default: SSLerr(SSL_F_SSL23_ACCEPT, SSL_R_UNKNOWN_STATE); ret = -1; goto end; /* break; */ } if ((cb != NULL) && (s->state != state)) { new_state = s->state; s->state = state; cb(s, SSL_CB_ACCEPT_LOOP, 1); s->state = new_state; } } end: s->in_handshake--; if (cb != NULL) cb(s, SSL_CB_ACCEPT_EXIT, ret); return (ret); } int ssl23_get_client_hello(SSL *s) { char buf[11]; /* * sizeof(buf) == 11, because we'll need to request this many bytes in * the initial read. * We can detect SSL 3.0/TLS 1.0 Client Hellos ('type == 3') correctly * only when the following is in a single record, which is not * guaranteed by the protocol specification: * Byte Content * 0 type \ * 1/2 version > record header * 3/4 length / * 5 msg_type \ * 6-8 length > Client Hello message * 9/10 client_version / */ unsigned char *p, *d, *d_len, *dd; unsigned int i; unsigned int csl, sil, cl; int n = 0, j; int type = 0; int v[2]; if (s->state == SSL23_ST_SR_CLNT_HELLO_A) { /* read the initial header */ v[0] = v[1] = 0; if (!ssl3_setup_buffers(s)) return -1; n = ssl23_read_bytes(s, sizeof buf); if (n != sizeof buf) return(n); p = s->packet; memcpy(buf, p, n); if ((p[0] & 0x80) && (p[2] == SSL2_MT_CLIENT_HELLO)) { /* * SSLv2 header */ if ((p[3] == 0x00) && (p[4] == 0x02)) { v[0] = p[3]; v[1] = p[4]; /* SSLv2 */ if (!(s->options & SSL_OP_NO_SSLv2)) type = 1; } else if (p[3] == SSL3_VERSION_MAJOR) { v[0] = p[3]; v[1] = p[4]; /* SSLv3/TLSv1 */ if (p[4] >= TLS1_VERSION_MINOR) { if (p[4] >= TLS1_2_VERSION_MINOR && !(s->options & SSL_OP_NO_TLSv1_2)) { s->version = TLS1_2_VERSION; s->state = SSL23_ST_SR_CLNT_HELLO_B; } else if (p[4] >= TLS1_1_VERSION_MINOR && !(s->options & SSL_OP_NO_TLSv1_1)) { s->version = TLS1_1_VERSION; /* type=2; */ /* done later to survive restarts */ s->state = SSL23_ST_SR_CLNT_HELLO_B; } else if (!(s->options & SSL_OP_NO_TLSv1)) { s->version = TLS1_VERSION; /* type=2; */ /* done later to survive restarts */ s->state = SSL23_ST_SR_CLNT_HELLO_B; } else if (!(s->options & SSL_OP_NO_SSLv3)) { s->version = SSL3_VERSION; /* type=2; */ s->state = SSL23_ST_SR_CLNT_HELLO_B; } else if (!(s->options & SSL_OP_NO_SSLv2)) { type = 1; } } else if (!(s->options & SSL_OP_NO_SSLv3)) { s->version = SSL3_VERSION; /* type=2; */ s->state = SSL23_ST_SR_CLNT_HELLO_B; } else if (!(s->options & SSL_OP_NO_SSLv2)) type = 1; } } else if ((p[0] == SSL3_RT_HANDSHAKE) && (p[1] == SSL3_VERSION_MAJOR) && (p[5] == SSL3_MT_CLIENT_HELLO) && ((p[3] == 0 && p[4] < 5 /* silly record length? */) || (p[9] >= p[1]))) { /* * SSLv3 or tls1 header */ v[0] = p[1]; /* major version (= SSL3_VERSION_MAJOR) */ /* We must look at client_version inside the Client Hello message * to get the correct minor version. * However if we have only a pathologically small fragment of the * Client Hello message, this would be difficult, and we'd have * to read more records to find out. * No known SSL 3.0 client fragments ClientHello like this, * so we simply assume TLS 1.0 to avoid protocol version downgrade * attacks. */ if (p[3] == 0 && p[4] < 6) { v[1] = TLS1_VERSION_MINOR; } /* if major version number > 3 set minor to a value * which will use the highest version 3 we support. * If TLS 2.0 ever appears we will need to revise * this.... */ else if (p[9] > SSL3_VERSION_MAJOR) v[1] = 0xff; else v[1] = p[10]; /* minor version according to client_version */ if (v[1] >= TLS1_VERSION_MINOR) { if (v[1] >= TLS1_2_VERSION_MINOR && !(s->options & SSL_OP_NO_TLSv1_2)) { s->version = TLS1_2_VERSION; type = 3; } else if (v[1] >= TLS1_1_VERSION_MINOR && !(s->options & SSL_OP_NO_TLSv1_1)) { s->version = TLS1_1_VERSION; type = 3; } else if (!(s->options & SSL_OP_NO_TLSv1)) { s->version = TLS1_VERSION; type = 3; } else if (!(s->options & SSL_OP_NO_SSLv3)) { s->version = SSL3_VERSION; type = 3; } } else { /* client requests SSL 3.0 */ if (!(s->options & SSL_OP_NO_SSLv3)) { s->version = SSL3_VERSION; type = 3; } else if (!(s->options & SSL_OP_NO_TLSv1)) { /* we won't be able to use TLS of course, * but this will send an appropriate alert */ s->version = TLS1_VERSION; type = 3; } } } else if ((strncmp("GET ", (char *)p, 4) == 0) || (strncmp("POST ",(char *)p, 5) == 0) || (strncmp("HEAD ",(char *)p, 5) == 0) || (strncmp("PUT ", (char *)p, 4) == 0)) { SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO, SSL_R_HTTP_REQUEST); return -1; } else if (strncmp("CONNECT", (char *)p, 7) == 0) { SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO, SSL_R_HTTPS_PROXY_REQUEST); return -1; } } if (s->state == SSL23_ST_SR_CLNT_HELLO_B) { /* we have SSLv3/TLSv1 in an SSLv2 header * (other cases skip this state) */ type = 2; p = s->packet; v[0] = p[3]; /* == SSL3_VERSION_MAJOR */ v[1] = p[4]; n = ((p[0] & 0x7f) << 8) | p[1]; if (n > (1024 * 4)) { SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO, SSL_R_RECORD_TOO_LARGE); return -1; } j = ssl23_read_bytes(s, n + 2); if (j <= 0) return (j); ssl3_finish_mac(s, s->packet + 2, s->packet_length - 2); if (s->msg_callback) s->msg_callback(0, SSL2_VERSION, 0, s->packet + 2, s->packet_length - 2, s, s->msg_callback_arg); p = s->packet; p += 5; n2s(p, csl); n2s(p, sil); n2s(p, cl); d = (unsigned char *)s->init_buf->data; if ((csl + sil + cl + 11) != s->packet_length) { /* * We can't have TLS extensions in SSL 2.0 format * Client Hello, can we ? Error condition should be * '>' otherwise */ SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO, SSL_R_RECORD_LENGTH_MISMATCH); return -1; } /* record header: msg_type ... */ *(d++) = SSL3_MT_CLIENT_HELLO; /* ... and length (actual value will be written later) */ d_len = d; d += 3; /* client_version */ *(d++) = SSL3_VERSION_MAJOR; /* == v[0] */ *(d++) = v[1]; /* lets populate the random area */ /* get the challenge_length */ i = (cl > SSL3_RANDOM_SIZE) ? SSL3_RANDOM_SIZE : cl; memset(d, 0, SSL3_RANDOM_SIZE); memcpy(&(d[SSL3_RANDOM_SIZE - i]), &(p[csl + sil]), i); d += SSL3_RANDOM_SIZE; /* no session-id reuse */ *(d++) = 0; /* ciphers */ j = 0; dd = d; d += 2; for (i = 0; i < csl; i += 3) { if (p[i] != 0) continue; *(d++) = p[i + 1]; *(d++) = p[i + 2]; j += 2; } s2n(j, dd); /* add in (no) COMPRESSION */ *(d++) = 1; *(d++) = 0; i = (d - (unsigned char *)s->init_buf->data) - 4; l2n3((long)i, d_len); /* get the data reused from the init_buf */ s->s3->tmp.reuse_message = 1; s->s3->tmp.message_type = SSL3_MT_CLIENT_HELLO; s->s3->tmp.message_size = i; } /* imaginary new state (for program structure): */ /* s->state = SSL23_SR_CLNT_HELLO_C */ if (type == 1) { SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO, SSL_R_UNSUPPORTED_PROTOCOL); return -1; } if ((type == 2) || (type == 3)) { /* we have SSLv3/TLSv1 (type 2: SSL2 style, type 3: SSL3/TLS style) */ if (!ssl_init_wbio_buffer(s, 1)) return -1; /* we are in this state */ s->state = SSL3_ST_SR_CLNT_HELLO_A; if (type == 3) { /* put the 'n' bytes we have read into the input buffer * for SSLv3 */ s->rstate = SSL_ST_READ_HEADER; s->packet_length = n; if (s->s3->rbuf.buf == NULL) if (!ssl3_setup_read_buffer(s)) return -1; s->packet = &(s->s3->rbuf.buf[0]); memcpy(s->packet, buf, n); s->s3->rbuf.left = n; s->s3->rbuf.offset = 0; } else { s->packet_length = 0; s->s3->rbuf.left = 0; s->s3->rbuf.offset = 0; } if (s->version == TLS1_2_VERSION) s->method = TLSv1_2_server_method(); else if (s->version == TLS1_1_VERSION) s->method = TLSv1_1_server_method(); else if (s->version == TLS1_VERSION) s->method = TLSv1_server_method(); else s->method = SSLv3_server_method(); s->handshake_func = s->method->ssl_accept; } if ((type < 1) || (type > 3)) { /* bad, very bad */ SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO, SSL_R_UNKNOWN_PROTOCOL); return -1; } s->init_num = 0; return (SSL_accept(s)); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/srtp.h0000644000175000017500000001476212360020705016707 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* * DTLS code by Eric Rescorla * * Copyright (C) 2006, Network Resonance, Inc. * Copyright (C) 2011, RTFM, Inc. */ #ifndef HEADER_D1_SRTP_H #define HEADER_D1_SRTP_H #ifdef __cplusplus extern "C" { #endif #define SRTP_AES128_CM_SHA1_80 0x0001 #define SRTP_AES128_CM_SHA1_32 0x0002 #define SRTP_AES128_F8_SHA1_80 0x0003 #define SRTP_AES128_F8_SHA1_32 0x0004 #define SRTP_NULL_SHA1_80 0x0005 #define SRTP_NULL_SHA1_32 0x0006 int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles); int SSL_set_tlsext_use_srtp(SSL *ctx, const char *profiles); SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s); STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl); SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s); #ifdef __cplusplus } #endif #endif deps/libressl-pnacl-sys-2.1.6/libressl/ssl/ssl_stat.c0000644000175000017500000004401112360020705017534 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright 2005 Nokia. All rights reserved. * * The portions of the attached software ("Contribution") is developed by * Nokia Corporation and is licensed pursuant to the OpenSSL open source * license. * * The Contribution, originally written by Mika Kousa and Pasi Eronen of * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites * support (see RFC 4279) to OpenSSL. * * No patent licenses or other rights except those expressly stated in * the OpenSSL open source license shall be deemed granted or received * expressly, by implication, estoppel, or otherwise. * * No assurances are provided by Nokia that the Contribution does not * infringe the patent or other intellectual property rights of any third * party or that the license provides you with all the necessary rights * to make use of the Contribution. * * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR * OTHERWISE. */ #include #include "ssl_locl.h" const char * SSL_state_string_long(const SSL *s) { const char *str; switch (s->state) { case SSL_ST_BEFORE: str="before SSL initialization"; break; case SSL_ST_ACCEPT: str="before accept initialization"; break; case SSL_ST_CONNECT: str="before connect initialization"; break; case SSL_ST_OK: str="SSL negotiation finished successfully"; break; case SSL_ST_RENEGOTIATE: str="SSL renegotiate ciphers"; break; case SSL_ST_BEFORE|SSL_ST_CONNECT: str="before/connect initialization"; break; case SSL_ST_OK|SSL_ST_CONNECT: str="ok/connect SSL initialization"; break; case SSL_ST_BEFORE|SSL_ST_ACCEPT: str="before/accept initialization"; break; case SSL_ST_OK|SSL_ST_ACCEPT: str="ok/accept SSL initialization"; break; /* SSLv3 additions */ case SSL3_ST_CW_CLNT_HELLO_A: str="SSLv3 write client hello A"; break; case SSL3_ST_CW_CLNT_HELLO_B: str="SSLv3 write client hello B"; break; case SSL3_ST_CR_SRVR_HELLO_A: str="SSLv3 read server hello A"; break; case SSL3_ST_CR_SRVR_HELLO_B: str="SSLv3 read server hello B"; break; case SSL3_ST_CR_CERT_A: str="SSLv3 read server certificate A"; break; case SSL3_ST_CR_CERT_B: str="SSLv3 read server certificate B"; break; case SSL3_ST_CR_KEY_EXCH_A: str="SSLv3 read server key exchange A"; break; case SSL3_ST_CR_KEY_EXCH_B: str="SSLv3 read server key exchange B"; break; case SSL3_ST_CR_CERT_REQ_A: str="SSLv3 read server certificate request A"; break; case SSL3_ST_CR_CERT_REQ_B: str="SSLv3 read server certificate request B"; break; case SSL3_ST_CR_SESSION_TICKET_A: str="SSLv3 read server session ticket A";break; case SSL3_ST_CR_SESSION_TICKET_B: str="SSLv3 read server session ticket B";break; case SSL3_ST_CR_SRVR_DONE_A: str="SSLv3 read server done A"; break; case SSL3_ST_CR_SRVR_DONE_B: str="SSLv3 read server done B"; break; case SSL3_ST_CW_CERT_A: str="SSLv3 write client certificate A"; break; case SSL3_ST_CW_CERT_B: str="SSLv3 write client certificate B"; break; case SSL3_ST_CW_CERT_C: str="SSLv3 write client certificate C"; break; case SSL3_ST_CW_CERT_D: str="SSLv3 write client certificate D"; break; case SSL3_ST_CW_KEY_EXCH_A: str="SSLv3 write client key exchange A"; break; case SSL3_ST_CW_KEY_EXCH_B: str="SSLv3 write client key exchange B"; break; case SSL3_ST_CW_CERT_VRFY_A: str="SSLv3 write certificate verify A"; break; case SSL3_ST_CW_CERT_VRFY_B: str="SSLv3 write certificate verify B"; break; case SSL3_ST_CW_CHANGE_A: case SSL3_ST_SW_CHANGE_A: str="SSLv3 write change cipher spec A"; break; case SSL3_ST_CW_CHANGE_B: case SSL3_ST_SW_CHANGE_B: str="SSLv3 write change cipher spec B"; break; case SSL3_ST_CW_FINISHED_A: case SSL3_ST_SW_FINISHED_A: str="SSLv3 write finished A"; break; case SSL3_ST_CW_FINISHED_B: case SSL3_ST_SW_FINISHED_B: str="SSLv3 write finished B"; break; case SSL3_ST_CR_CHANGE_A: case SSL3_ST_SR_CHANGE_A: str="SSLv3 read change cipher spec A"; break; case SSL3_ST_CR_CHANGE_B: case SSL3_ST_SR_CHANGE_B: str="SSLv3 read change cipher spec B"; break; case SSL3_ST_CR_FINISHED_A: case SSL3_ST_SR_FINISHED_A: str="SSLv3 read finished A"; break; case SSL3_ST_CR_FINISHED_B: case SSL3_ST_SR_FINISHED_B: str="SSLv3 read finished B"; break; case SSL3_ST_CW_FLUSH: case SSL3_ST_SW_FLUSH: str="SSLv3 flush data"; break; case SSL3_ST_SR_CLNT_HELLO_A: str="SSLv3 read client hello A"; break; case SSL3_ST_SR_CLNT_HELLO_B: str="SSLv3 read client hello B"; break; case SSL3_ST_SR_CLNT_HELLO_C: str="SSLv3 read client hello C"; break; case SSL3_ST_SW_HELLO_REQ_A: str="SSLv3 write hello request A"; break; case SSL3_ST_SW_HELLO_REQ_B: str="SSLv3 write hello request B"; break; case SSL3_ST_SW_HELLO_REQ_C: str="SSLv3 write hello request C"; break; case SSL3_ST_SW_SRVR_HELLO_A: str="SSLv3 write server hello A"; break; case SSL3_ST_SW_SRVR_HELLO_B: str="SSLv3 write server hello B"; break; case SSL3_ST_SW_CERT_A: str="SSLv3 write certificate A"; break; case SSL3_ST_SW_CERT_B: str="SSLv3 write certificate B"; break; case SSL3_ST_SW_KEY_EXCH_A: str="SSLv3 write key exchange A"; break; case SSL3_ST_SW_KEY_EXCH_B: str="SSLv3 write key exchange B"; break; case SSL3_ST_SW_CERT_REQ_A: str="SSLv3 write certificate request A"; break; case SSL3_ST_SW_CERT_REQ_B: str="SSLv3 write certificate request B"; break; case SSL3_ST_SW_SESSION_TICKET_A: str="SSLv3 write session ticket A"; break; case SSL3_ST_SW_SESSION_TICKET_B: str="SSLv3 write session ticket B"; break; case SSL3_ST_SW_SRVR_DONE_A: str="SSLv3 write server done A"; break; case SSL3_ST_SW_SRVR_DONE_B: str="SSLv3 write server done B"; break; case SSL3_ST_SR_CERT_A: str="SSLv3 read client certificate A"; break; case SSL3_ST_SR_CERT_B: str="SSLv3 read client certificate B"; break; case SSL3_ST_SR_KEY_EXCH_A: str="SSLv3 read client key exchange A"; break; case SSL3_ST_SR_KEY_EXCH_B: str="SSLv3 read client key exchange B"; break; case SSL3_ST_SR_CERT_VRFY_A: str="SSLv3 read certificate verify A"; break; case SSL3_ST_SR_CERT_VRFY_B: str="SSLv3 read certificate verify B"; break; /* DTLS */ case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A: str="DTLS1 read hello verify request A"; break; case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B: str="DTLS1 read hello verify request B"; break; case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A: str="DTLS1 write hello verify request A"; break; case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B: str="DTLS1 write hello verify request B"; break; default: str="unknown state"; break; } return (str); } const char * SSL_rstate_string_long(const SSL *s) { const char *str; switch (s->rstate) { case SSL_ST_READ_HEADER: str="read header"; break; case SSL_ST_READ_BODY: str="read body"; break; case SSL_ST_READ_DONE: str="read done"; break; default: str="unknown"; break; } return (str); } const char * SSL_state_string(const SSL *s) { const char *str; switch (s->state) { case SSL_ST_BEFORE: str="PINIT "; break; case SSL_ST_ACCEPT: str="AINIT "; break; case SSL_ST_CONNECT: str="CINIT "; break; case SSL_ST_OK: str="SSLOK "; break; /* SSLv3 additions */ case SSL3_ST_SW_FLUSH: case SSL3_ST_CW_FLUSH: str="3FLUSH"; break; case SSL3_ST_CW_CLNT_HELLO_A: str="3WCH_A"; break; case SSL3_ST_CW_CLNT_HELLO_B: str="3WCH_B"; break; case SSL3_ST_CR_SRVR_HELLO_A: str="3RSH_A"; break; case SSL3_ST_CR_SRVR_HELLO_B: str="3RSH_B"; break; case SSL3_ST_CR_CERT_A: str="3RSC_A"; break; case SSL3_ST_CR_CERT_B: str="3RSC_B"; break; case SSL3_ST_CR_KEY_EXCH_A: str="3RSKEA"; break; case SSL3_ST_CR_KEY_EXCH_B: str="3RSKEB"; break; case SSL3_ST_CR_CERT_REQ_A: str="3RCR_A"; break; case SSL3_ST_CR_CERT_REQ_B: str="3RCR_B"; break; case SSL3_ST_CR_SRVR_DONE_A: str="3RSD_A"; break; case SSL3_ST_CR_SRVR_DONE_B: str="3RSD_B"; break; case SSL3_ST_CW_CERT_A: str="3WCC_A"; break; case SSL3_ST_CW_CERT_B: str="3WCC_B"; break; case SSL3_ST_CW_CERT_C: str="3WCC_C"; break; case SSL3_ST_CW_CERT_D: str="3WCC_D"; break; case SSL3_ST_CW_KEY_EXCH_A: str="3WCKEA"; break; case SSL3_ST_CW_KEY_EXCH_B: str="3WCKEB"; break; case SSL3_ST_CW_CERT_VRFY_A: str="3WCV_A"; break; case SSL3_ST_CW_CERT_VRFY_B: str="3WCV_B"; break; case SSL3_ST_SW_CHANGE_A: case SSL3_ST_CW_CHANGE_A: str="3WCCSA"; break; case SSL3_ST_SW_CHANGE_B: case SSL3_ST_CW_CHANGE_B: str="3WCCSB"; break; case SSL3_ST_SW_FINISHED_A: case SSL3_ST_CW_FINISHED_A: str="3WFINA"; break; case SSL3_ST_SW_FINISHED_B: case SSL3_ST_CW_FINISHED_B: str="3WFINB"; break; case SSL3_ST_SR_CHANGE_A: case SSL3_ST_CR_CHANGE_A: str="3RCCSA"; break; case SSL3_ST_SR_CHANGE_B: case SSL3_ST_CR_CHANGE_B: str="3RCCSB"; break; case SSL3_ST_SR_FINISHED_A: case SSL3_ST_CR_FINISHED_A: str="3RFINA"; break; case SSL3_ST_SR_FINISHED_B: case SSL3_ST_CR_FINISHED_B: str="3RFINB"; break; case SSL3_ST_SW_HELLO_REQ_A: str="3WHR_A"; break; case SSL3_ST_SW_HELLO_REQ_B: str="3WHR_B"; break; case SSL3_ST_SW_HELLO_REQ_C: str="3WHR_C"; break; case SSL3_ST_SR_CLNT_HELLO_A: str="3RCH_A"; break; case SSL3_ST_SR_CLNT_HELLO_B: str="3RCH_B"; break; case SSL3_ST_SR_CLNT_HELLO_C: str="3RCH_C"; break; case SSL3_ST_SW_SRVR_HELLO_A: str="3WSH_A"; break; case SSL3_ST_SW_SRVR_HELLO_B: str="3WSH_B"; break; case SSL3_ST_SW_CERT_A: str="3WSC_A"; break; case SSL3_ST_SW_CERT_B: str="3WSC_B"; break; case SSL3_ST_SW_KEY_EXCH_A: str="3WSKEA"; break; case SSL3_ST_SW_KEY_EXCH_B: str="3WSKEB"; break; case SSL3_ST_SW_CERT_REQ_A: str="3WCR_A"; break; case SSL3_ST_SW_CERT_REQ_B: str="3WCR_B"; break; case SSL3_ST_SW_SRVR_DONE_A: str="3WSD_A"; break; case SSL3_ST_SW_SRVR_DONE_B: str="3WSD_B"; break; case SSL3_ST_SR_CERT_A: str="3RCC_A"; break; case SSL3_ST_SR_CERT_B: str="3RCC_B"; break; case SSL3_ST_SR_KEY_EXCH_A: str="3RCKEA"; break; case SSL3_ST_SR_KEY_EXCH_B: str="3RCKEB"; break; case SSL3_ST_SR_CERT_VRFY_A: str="3RCV_A"; break; case SSL3_ST_SR_CERT_VRFY_B: str="3RCV_B"; break; /* DTLS */ case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A: str="DRCHVA"; break; case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B: str="DRCHVB"; break; case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A: str="DWCHVA"; break; case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B: str="DWCHVB"; break; default: str="UNKWN "; break; } return (str); } const char * SSL_alert_type_string_long(int value) { value>>=8; if (value == SSL3_AL_WARNING) return("warning"); else if (value == SSL3_AL_FATAL) return("fatal"); else return("unknown"); } const char * SSL_alert_type_string(int value) { value>>=8; if (value == SSL3_AL_WARNING) return("W"); else if (value == SSL3_AL_FATAL) return("F"); else return("U"); } const char * SSL_alert_desc_string(int value) { const char *str; switch (value & 0xff) { case SSL3_AD_CLOSE_NOTIFY: str="CN"; break; case SSL3_AD_UNEXPECTED_MESSAGE: str="UM"; break; case SSL3_AD_BAD_RECORD_MAC: str="BM"; break; case SSL3_AD_DECOMPRESSION_FAILURE: str="DF"; break; case SSL3_AD_HANDSHAKE_FAILURE: str="HF"; break; case SSL3_AD_NO_CERTIFICATE: str="NC"; break; case SSL3_AD_BAD_CERTIFICATE: str="BC"; break; case SSL3_AD_UNSUPPORTED_CERTIFICATE: str="UC"; break; case SSL3_AD_CERTIFICATE_REVOKED: str="CR"; break; case SSL3_AD_CERTIFICATE_EXPIRED: str="CE"; break; case SSL3_AD_CERTIFICATE_UNKNOWN: str="CU"; break; case SSL3_AD_ILLEGAL_PARAMETER: str="IP"; break; case TLS1_AD_DECRYPTION_FAILED: str="DC"; break; case TLS1_AD_RECORD_OVERFLOW: str="RO"; break; case TLS1_AD_UNKNOWN_CA: str="CA"; break; case TLS1_AD_ACCESS_DENIED: str="AD"; break; case TLS1_AD_DECODE_ERROR: str="DE"; break; case TLS1_AD_DECRYPT_ERROR: str="CY"; break; case TLS1_AD_EXPORT_RESTRICTION: str="ER"; break; case TLS1_AD_PROTOCOL_VERSION: str="PV"; break; case TLS1_AD_INSUFFICIENT_SECURITY: str="IS"; break; case TLS1_AD_INTERNAL_ERROR: str="IE"; break; case TLS1_AD_USER_CANCELLED: str="US"; break; case TLS1_AD_NO_RENEGOTIATION: str="NR"; break; case TLS1_AD_UNSUPPORTED_EXTENSION: str="UE"; break; case TLS1_AD_CERTIFICATE_UNOBTAINABLE: str="CO"; break; case TLS1_AD_UNRECOGNIZED_NAME: str="UN"; break; case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE: str="BR"; break; case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE: str="BH"; break; case TLS1_AD_UNKNOWN_PSK_IDENTITY: str="UP"; break; default: str="UK"; break; } return (str); } const char * SSL_alert_desc_string_long(int value) { const char *str; switch (value & 0xff) { case SSL3_AD_CLOSE_NOTIFY: str="close notify"; break; case SSL3_AD_UNEXPECTED_MESSAGE: str="unexpected_message"; break; case SSL3_AD_BAD_RECORD_MAC: str="bad record mac"; break; case SSL3_AD_DECOMPRESSION_FAILURE: str="decompression failure"; break; case SSL3_AD_HANDSHAKE_FAILURE: str="handshake failure"; break; case SSL3_AD_NO_CERTIFICATE: str="no certificate"; break; case SSL3_AD_BAD_CERTIFICATE: str="bad certificate"; break; case SSL3_AD_UNSUPPORTED_CERTIFICATE: str="unsupported certificate"; break; case SSL3_AD_CERTIFICATE_REVOKED: str="certificate revoked"; break; case SSL3_AD_CERTIFICATE_EXPIRED: str="certificate expired"; break; case SSL3_AD_CERTIFICATE_UNKNOWN: str="certificate unknown"; break; case SSL3_AD_ILLEGAL_PARAMETER: str="illegal parameter"; break; case TLS1_AD_DECRYPTION_FAILED: str="decryption failed"; break; case TLS1_AD_RECORD_OVERFLOW: str="record overflow"; break; case TLS1_AD_UNKNOWN_CA: str="unknown CA"; break; case TLS1_AD_ACCESS_DENIED: str="access denied"; break; case TLS1_AD_DECODE_ERROR: str="decode error"; break; case TLS1_AD_DECRYPT_ERROR: str="decrypt error"; break; case TLS1_AD_EXPORT_RESTRICTION: str="export restriction"; break; case TLS1_AD_PROTOCOL_VERSION: str="protocol version"; break; case TLS1_AD_INSUFFICIENT_SECURITY: str="insufficient security"; break; case TLS1_AD_INTERNAL_ERROR: str="internal error"; break; case TLS1_AD_USER_CANCELLED: str="user canceled"; break; case TLS1_AD_NO_RENEGOTIATION: str="no renegotiation"; break; case TLS1_AD_UNSUPPORTED_EXTENSION: str="unsupported extension"; break; case TLS1_AD_CERTIFICATE_UNOBTAINABLE: str="certificate unobtainable"; break; case TLS1_AD_UNRECOGNIZED_NAME: str="unrecognized name"; break; case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE: str="bad certificate status response"; break; case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE: str="bad certificate hash value"; break; case TLS1_AD_UNKNOWN_PSK_IDENTITY: str="unknown PSK identity"; break; default: str="unknown"; break; } return (str); } const char * SSL_rstate_string(const SSL *s) { const char *str; switch (s->rstate) { case SSL_ST_READ_HEADER: str="RH"; break; case SSL_ST_READ_BODY: str="RB"; break; case SSL_ST_READ_DONE: str="RD"; break; default: str="unknown"; break; } return (str); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/d1_meth.c0000644000175000017500000001010112360020705017212 0ustar /* $OpenBSD$ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. */ /* ==================================================================== * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "ssl_locl.h" static const SSL_METHOD *dtls1_get_method(int ver); const SSL_METHOD DTLSv1_method_data = { .version = DTLS1_VERSION, .ssl_new = dtls1_new, .ssl_clear = dtls1_clear, .ssl_free = dtls1_free, .ssl_accept = dtls1_accept, .ssl_connect = dtls1_connect, .ssl_read = ssl3_read, .ssl_peek = ssl3_peek, .ssl_write = ssl3_write, .ssl_shutdown = dtls1_shutdown, .ssl_renegotiate = ssl3_renegotiate, .ssl_renegotiate_check = ssl3_renegotiate_check, .ssl_get_message = dtls1_get_message, .ssl_read_bytes = dtls1_read_bytes, .ssl_write_bytes = dtls1_write_app_data_bytes, .ssl_dispatch_alert = dtls1_dispatch_alert, .ssl_ctrl = dtls1_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl3_put_cipher_by_char, .ssl_pending = ssl3_pending, .num_ciphers = ssl3_num_ciphers, .get_cipher = dtls1_get_cipher, .get_ssl_method = dtls1_get_method, .get_timeout = dtls1_default_timeout, .ssl3_enc = &DTLSv1_enc_data, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD * DTLSv1_method(void) { return &DTLSv1_method_data; } static const SSL_METHOD * dtls1_get_method(int ver) { if (ver == DTLS1_VERSION) return (DTLSv1_method()); return (NULL); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/s3_lib.c0000644000175000017500000025754112360020705017071 0ustar /* $OpenBSD: s3_lib.c,v 1.68 2014/07/10 08:51:14 tedu Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * Portions of the attached software ("Contribution") are developed by * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. * * The Contribution is licensed pursuant to the OpenSSL open source * license provided above. * * ECC cipher suite support in OpenSSL originally written by * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories. * */ /* ==================================================================== * Copyright 2005 Nokia. All rights reserved. * * The portions of the attached software ("Contribution") is developed by * Nokia Corporation and is licensed pursuant to the OpenSSL open source * license. * * The Contribution, originally written by Mika Kousa and Pasi Eronen of * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites * support (see RFC 4279) to OpenSSL. * * No patent licenses or other rights except those expressly stated in * the OpenSSL open source license shall be deemed granted or received * expressly, by implication, estoppel, or otherwise. * * No assurances are provided by Nokia that the Contribution does not * infringe the patent or other intellectual property rights of any third * party or that the license provides you with all the necessary rights * to make use of the Contribution. * * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR * OTHERWISE. */ #include #include #include "ssl_locl.h" #include "../crypto/ec/ec_lcl.h" #include #include #define SSL3_NUM_CIPHERS (sizeof(ssl3_ciphers) / sizeof(SSL_CIPHER)) /* * FIXED_NONCE_LEN is a macro that provides in the correct value to set the * fixed nonce length in algorithms2. It is the inverse of the * SSL_CIPHER_AEAD_FIXED_NONCE_LEN macro. */ #define FIXED_NONCE_LEN(x) (((x / 2) & 0xf) << 24) /* list of available SSLv3 ciphers (sorted by id) */ SSL_CIPHER ssl3_ciphers[] = { /* The RSA ciphers */ /* Cipher 01 */ { .valid = 1, .name = SSL3_TXT_RSA_NULL_MD5, .id = SSL3_CK_RSA_NULL_MD5, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_eNULL, .algorithm_mac = SSL_MD5, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_STRONG_NONE, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 0, .alg_bits = 0, }, /* Cipher 02 */ { .valid = 1, .name = SSL3_TXT_RSA_NULL_SHA, .id = SSL3_CK_RSA_NULL_SHA, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_eNULL, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_STRONG_NONE, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 0, .alg_bits = 0, }, /* Cipher 03 */ { .valid = 0, /* Weakened 40-bit export cipher. */ .name = SSL3_TXT_RSA_RC4_40_MD5, .id = SSL3_CK_RSA_RC4_40_MD5, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_RC4, .algorithm_mac = SSL_MD5, .algorithm_ssl = SSL_SSLV3, .algo_strength = 0, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 40, .alg_bits = 128, }, /* Cipher 04 */ { .valid = 1, .name = SSL3_TXT_RSA_RC4_128_MD5, .id = SSL3_CK_RSA_RC4_128_MD5, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_RC4, .algorithm_mac = SSL_MD5, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_MEDIUM, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 05 */ { .valid = 1, .name = SSL3_TXT_RSA_RC4_128_SHA, .id = SSL3_CK_RSA_RC4_128_SHA, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_RC4, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_MEDIUM, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 06 */ { .valid = 0, /* Weakened 40-bit export cipher. */ .name = SSL3_TXT_RSA_RC2_40_MD5, .id = SSL3_CK_RSA_RC2_40_MD5, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_RC2, .algorithm_mac = SSL_MD5, .algorithm_ssl = SSL_SSLV3, .algo_strength = 0, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 40, .alg_bits = 128, }, /* Cipher 07 */ #ifndef OPENSSL_NO_IDEA { .valid = 1, .name = SSL3_TXT_RSA_IDEA_128_SHA, .id = SSL3_CK_RSA_IDEA_128_SHA, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_IDEA, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_MEDIUM, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, #endif /* Cipher 08 */ { .valid = 0, /* Weakened 40-bit export cipher. */ .name = SSL3_TXT_RSA_DES_40_CBC_SHA, .id = SSL3_CK_RSA_DES_40_CBC_SHA, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = 0, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 40, .alg_bits = 56, }, /* Cipher 09 */ { .valid = 1, .name = SSL3_TXT_RSA_DES_64_CBC_SHA, .id = SSL3_CK_RSA_DES_64_CBC_SHA, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_LOW, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 56, .alg_bits = 56, }, /* Cipher 0A */ { .valid = 1, .name = SSL3_TXT_RSA_DES_192_CBC3_SHA, .id = SSL3_CK_RSA_DES_192_CBC3_SHA, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_3DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 112, .alg_bits = 168, }, /* The DH ciphers */ /* Cipher 0B */ { .valid = 0, /* Weakened 40-bit export cipher. */ .name = SSL3_TXT_DH_DSS_DES_40_CBC_SHA, .id = SSL3_CK_DH_DSS_DES_40_CBC_SHA, .algorithm_mkey = SSL_kDHd, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = 0, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 40, .alg_bits = 56, }, /* Cipher 0C */ { .valid = 0, /* not implemented (non-ephemeral DH) */ .name = SSL3_TXT_DH_DSS_DES_64_CBC_SHA, .id = SSL3_CK_DH_DSS_DES_64_CBC_SHA, .algorithm_mkey = SSL_kDHd, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_LOW, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 56, .alg_bits = 56, }, /* Cipher 0D */ { .valid = 0, /* not implemented (non-ephemeral DH) */ .name = SSL3_TXT_DH_DSS_DES_192_CBC3_SHA, .id = SSL3_CK_DH_DSS_DES_192_CBC3_SHA, .algorithm_mkey = SSL_kDHd, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_3DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 112, .alg_bits = 168, }, /* Cipher 0E */ { .valid = 0, /* not implemented (non-ephemeral DH) */ .name = SSL3_TXT_DH_RSA_DES_40_CBC_SHA, .id = SSL3_CK_DH_RSA_DES_40_CBC_SHA, .algorithm_mkey = SSL_kDHr, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = 0, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 40, .alg_bits = 56, }, /* Cipher 0F */ { .valid = 0, /* not implemented (non-ephemeral DH) */ .name = SSL3_TXT_DH_RSA_DES_64_CBC_SHA, .id = SSL3_CK_DH_RSA_DES_64_CBC_SHA, .algorithm_mkey = SSL_kDHr, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_LOW, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 56, .alg_bits = 56, }, /* Cipher 10 */ { .valid = 0, /* not implemented (non-ephemeral DH) */ .name = SSL3_TXT_DH_RSA_DES_192_CBC3_SHA, .id = SSL3_CK_DH_RSA_DES_192_CBC3_SHA, .algorithm_mkey = SSL_kDHr, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_3DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 112, .alg_bits = 168, }, /* The Ephemeral DH ciphers */ /* Cipher 11 */ { .valid = 0, /* Weakened 40-bit export cipher. */ .name = SSL3_TXT_EDH_DSS_DES_40_CBC_SHA, .id = SSL3_CK_EDH_DSS_DES_40_CBC_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aDSS, .algorithm_enc = SSL_DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = 0, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 40, .alg_bits = 56, }, /* Cipher 12 */ { .valid = 1, .name = SSL3_TXT_EDH_DSS_DES_64_CBC_SHA, .id = SSL3_CK_EDH_DSS_DES_64_CBC_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aDSS, .algorithm_enc = SSL_DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_LOW, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 56, .alg_bits = 56, }, /* Cipher 13 */ { .valid = 1, .name = SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA, .id = SSL3_CK_EDH_DSS_DES_192_CBC3_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aDSS, .algorithm_enc = SSL_3DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 112, .alg_bits = 168, }, /* Cipher 14 */ { .valid = 0, /* Weakened 40-bit export cipher. */ .name = SSL3_TXT_EDH_RSA_DES_40_CBC_SHA, .id = SSL3_CK_EDH_RSA_DES_40_CBC_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = 0, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 40, .alg_bits = 56, }, /* Cipher 15 */ { .valid = 1, .name = SSL3_TXT_EDH_RSA_DES_64_CBC_SHA, .id = SSL3_CK_EDH_RSA_DES_64_CBC_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_LOW, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 56, .alg_bits = 56, }, /* Cipher 16 */ { .valid = 1, .name = SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA, .id = SSL3_CK_EDH_RSA_DES_192_CBC3_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_3DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 112, .alg_bits = 168, }, /* Cipher 17 */ { .valid = 0, /* Weakened 40-bit export cipher. */ .name = SSL3_TXT_ADH_RC4_40_MD5, .id = SSL3_CK_ADH_RC4_40_MD5, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_RC4, .algorithm_mac = SSL_MD5, .algorithm_ssl = SSL_SSLV3, .algo_strength = 0, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 40, .alg_bits = 128, }, /* Cipher 18 */ { .valid = 1, .name = SSL3_TXT_ADH_RC4_128_MD5, .id = SSL3_CK_ADH_RC4_128_MD5, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_RC4, .algorithm_mac = SSL_MD5, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_MEDIUM, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 19 */ { .valid = 0, /* Weakened 40-bit export cipher. */ .name = SSL3_TXT_ADH_DES_40_CBC_SHA, .id = SSL3_CK_ADH_DES_40_CBC_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = 0, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 40, .alg_bits = 128, }, /* Cipher 1A */ { .valid = 1, .name = SSL3_TXT_ADH_DES_64_CBC_SHA, .id = SSL3_CK_ADH_DES_64_CBC_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_LOW, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 56, .alg_bits = 56, }, /* Cipher 1B */ { .valid = 1, .name = SSL3_TXT_ADH_DES_192_CBC_SHA, .id = SSL3_CK_ADH_DES_192_CBC_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_3DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_SSLV3, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 112, .alg_bits = 168, }, /* New AES ciphersuites */ /* Cipher 2F */ { .valid = 1, .name = TLS1_TXT_RSA_WITH_AES_128_SHA, .id = TLS1_CK_RSA_WITH_AES_128_SHA, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 30 */ { .valid = 0, .name = TLS1_TXT_DH_DSS_WITH_AES_128_SHA, .id = TLS1_CK_DH_DSS_WITH_AES_128_SHA, .algorithm_mkey = SSL_kDHd, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 31 */ { .valid = 0, .name = TLS1_TXT_DH_RSA_WITH_AES_128_SHA, .id = TLS1_CK_DH_RSA_WITH_AES_128_SHA, .algorithm_mkey = SSL_kDHr, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 32 */ { .valid = 1, .name = TLS1_TXT_DHE_DSS_WITH_AES_128_SHA, .id = TLS1_CK_DHE_DSS_WITH_AES_128_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aDSS, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 33 */ { .valid = 1, .name = TLS1_TXT_DHE_RSA_WITH_AES_128_SHA, .id = TLS1_CK_DHE_RSA_WITH_AES_128_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 34 */ { .valid = 1, .name = TLS1_TXT_ADH_WITH_AES_128_SHA, .id = TLS1_CK_ADH_WITH_AES_128_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 35 */ { .valid = 1, .name = TLS1_TXT_RSA_WITH_AES_256_SHA, .id = TLS1_CK_RSA_WITH_AES_256_SHA, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher 36 */ { .valid = 0, .name = TLS1_TXT_DH_DSS_WITH_AES_256_SHA, .id = TLS1_CK_DH_DSS_WITH_AES_256_SHA, .algorithm_mkey = SSL_kDHd, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher 37 */ { .valid = 0, /* not implemented (non-ephemeral DH) */ .name = TLS1_TXT_DH_RSA_WITH_AES_256_SHA, .id = TLS1_CK_DH_RSA_WITH_AES_256_SHA, .algorithm_mkey = SSL_kDHr, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher 38 */ { .valid = 1, .name = TLS1_TXT_DHE_DSS_WITH_AES_256_SHA, .id = TLS1_CK_DHE_DSS_WITH_AES_256_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aDSS, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher 39 */ { .valid = 1, .name = TLS1_TXT_DHE_RSA_WITH_AES_256_SHA, .id = TLS1_CK_DHE_RSA_WITH_AES_256_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher 3A */ { .valid = 1, .name = TLS1_TXT_ADH_WITH_AES_256_SHA, .id = TLS1_CK_ADH_WITH_AES_256_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* TLS v1.2 ciphersuites */ /* Cipher 3B */ { .valid = 1, .name = TLS1_TXT_RSA_WITH_NULL_SHA256, .id = TLS1_CK_RSA_WITH_NULL_SHA256, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_eNULL, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_STRONG_NONE, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 0, .alg_bits = 0, }, /* Cipher 3C */ { .valid = 1, .name = TLS1_TXT_RSA_WITH_AES_128_SHA256, .id = TLS1_CK_RSA_WITH_AES_128_SHA256, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 3D */ { .valid = 1, .name = TLS1_TXT_RSA_WITH_AES_256_SHA256, .id = TLS1_CK_RSA_WITH_AES_256_SHA256, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher 3E */ { .valid = 0, /* not implemented (non-ephemeral DH) */ .name = TLS1_TXT_DH_DSS_WITH_AES_128_SHA256, .id = TLS1_CK_DH_DSS_WITH_AES_128_SHA256, .algorithm_mkey = SSL_kDHd, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 3F */ { .valid = 0, /* not implemented (non-ephemeral DH) */ .name = TLS1_TXT_DH_RSA_WITH_AES_128_SHA256, .id = TLS1_CK_DH_RSA_WITH_AES_128_SHA256, .algorithm_mkey = SSL_kDHr, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 40 */ { .valid = 1, .name = TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256, .id = TLS1_CK_DHE_DSS_WITH_AES_128_SHA256, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aDSS, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, #ifndef OPENSSL_NO_CAMELLIA /* Camellia ciphersuites from RFC4132 (128-bit portion) */ /* Cipher 41 */ { .valid = 1, .name = TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA, .id = TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_CAMELLIA128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 42 */ { .valid = 0, /* not implemented (non-ephemeral DH) */ .name = TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA, .id = TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA, .algorithm_mkey = SSL_kDHd, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_CAMELLIA128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 43 */ { .valid = 0, /* not implemented (non-ephemeral DH) */ .name = TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA, .id = TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA, .algorithm_mkey = SSL_kDHr, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_CAMELLIA128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 44 */ { .valid = 1, .name = TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA, .id = TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aDSS, .algorithm_enc = SSL_CAMELLIA128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 45 */ { .valid = 1, .name = TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA, .id = TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_CAMELLIA128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 46 */ { .valid = 1, .name = TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA, .id = TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_CAMELLIA128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, #endif /* OPENSSL_NO_CAMELLIA */ /* TLS v1.2 ciphersuites */ /* Cipher 67 */ { .valid = 1, .name = TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256, .id = TLS1_CK_DHE_RSA_WITH_AES_128_SHA256, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 68 */ { .valid = 0, /* not implemented (non-ephemeral DH) */ .name = TLS1_TXT_DH_DSS_WITH_AES_256_SHA256, .id = TLS1_CK_DH_DSS_WITH_AES_256_SHA256, .algorithm_mkey = SSL_kDHd, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher 69 */ { .valid = 0, /* not implemented (non-ephemeral DH) */ .name = TLS1_TXT_DH_RSA_WITH_AES_256_SHA256, .id = TLS1_CK_DH_RSA_WITH_AES_256_SHA256, .algorithm_mkey = SSL_kDHr, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher 6A */ { .valid = 1, .name = TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256, .id = TLS1_CK_DHE_DSS_WITH_AES_256_SHA256, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aDSS, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher 6B */ { .valid = 1, .name = TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256, .id = TLS1_CK_DHE_RSA_WITH_AES_256_SHA256, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher 6C */ { .valid = 1, .name = TLS1_TXT_ADH_WITH_AES_128_SHA256, .id = TLS1_CK_ADH_WITH_AES_128_SHA256, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 6D */ { .valid = 1, .name = TLS1_TXT_ADH_WITH_AES_256_SHA256, .id = TLS1_CK_ADH_WITH_AES_256_SHA256, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* GOST Ciphersuites */ { .valid = 1, .name = "GOST94-GOST89-GOST89", .id = 0x3000080, .algorithm_mkey = SSL_kGOST, .algorithm_auth = SSL_aGOST94, .algorithm_enc = SSL_eGOST2814789CNT, .algorithm_mac = SSL_GOST89MAC, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_GOST94|TLS1_PRF_GOST94| TLS1_STREAM_MAC, .strength_bits = 256, .alg_bits = 256 }, { .valid = 1, .name = "GOST2001-GOST89-GOST89", .id = 0x3000081, .algorithm_mkey = SSL_kGOST, .algorithm_auth = SSL_aGOST01, .algorithm_enc = SSL_eGOST2814789CNT, .algorithm_mac = SSL_GOST89MAC, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_GOST94|TLS1_PRF_GOST94| TLS1_STREAM_MAC, .strength_bits = 256, .alg_bits = 256 }, { .valid = 1, .name = "GOST94-NULL-GOST94", .id = 0x3000082, .algorithm_mkey = SSL_kGOST, .algorithm_auth = SSL_aGOST94, .algorithm_enc = SSL_eNULL, .algorithm_mac = SSL_GOST94, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_STRONG_NONE, .algorithm2 = SSL_HANDSHAKE_MAC_GOST94|TLS1_PRF_GOST94, .strength_bits = 0, .alg_bits = 0 }, { .valid = 1, .name = "GOST2001-NULL-GOST94", .id = 0x3000083, .algorithm_mkey = SSL_kGOST, .algorithm_auth = SSL_aGOST01, .algorithm_enc = SSL_eNULL, .algorithm_mac = SSL_GOST94, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_STRONG_NONE, .algorithm2 = SSL_HANDSHAKE_MAC_GOST94|TLS1_PRF_GOST94, .strength_bits = 0, .alg_bits = 0 }, #ifndef OPENSSL_NO_CAMELLIA /* Camellia ciphersuites from RFC4132 (256-bit portion) */ /* Cipher 84 */ { .valid = 1, .name = TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA, .id = TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_CAMELLIA256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher 85 */ { .valid = 0, /* not implemented (non-ephemeral DH) */ .name = TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA, .id = TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA, .algorithm_mkey = SSL_kDHd, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_CAMELLIA256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher 86 */ { .valid = 0, /* not implemented (non-ephemeral DH) */ .name = TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA, .id = TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA, .algorithm_mkey = SSL_kDHr, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_CAMELLIA256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher 87 */ { .valid = 1, .name = TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA, .id = TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aDSS, .algorithm_enc = SSL_CAMELLIA256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher 88 */ { .valid = 1, .name = TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA, .id = TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_CAMELLIA256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher 89 */ { .valid = 1, .name = TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA, .id = TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_CAMELLIA256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, #endif /* OPENSSL_NO_CAMELLIA */ /* GCM ciphersuites from RFC5288 */ /* Cipher 9C */ { .valid = 1, .name = TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256, .id = TLS1_CK_RSA_WITH_AES_128_GCM_SHA256, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES128GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 9D */ { .valid = 1, .name = TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384, .id = TLS1_CK_RSA_WITH_AES_256_GCM_SHA384, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES256GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 256, .alg_bits = 256, }, /* Cipher 9E */ { .valid = 1, .name = TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256, .id = TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES128GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 128, .alg_bits = 128, }, /* Cipher 9F */ { .valid = 1, .name = TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384, .id = TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES256GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 256, .alg_bits = 256, }, /* Cipher A0 */ { .valid = 0, .name = TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256, .id = TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256, .algorithm_mkey = SSL_kDHr, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_AES128GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 128, .alg_bits = 128, }, /* Cipher A1 */ { .valid = 0, .name = TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384, .id = TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384, .algorithm_mkey = SSL_kDHr, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_AES256GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 256, .alg_bits = 256, }, /* Cipher A2 */ { .valid = 1, .name = TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256, .id = TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aDSS, .algorithm_enc = SSL_AES128GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 128, .alg_bits = 128, }, /* Cipher A3 */ { .valid = 1, .name = TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384, .id = TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aDSS, .algorithm_enc = SSL_AES256GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 256, .alg_bits = 256, }, /* Cipher A4 */ { .valid = 0, .name = TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256, .id = TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256, .algorithm_mkey = SSL_kDHd, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_AES128GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 128, .alg_bits = 128, }, /* Cipher A5 */ { .valid = 0, .name = TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384, .id = TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384, .algorithm_mkey = SSL_kDHd, .algorithm_auth = SSL_aDH, .algorithm_enc = SSL_AES256GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 256, .alg_bits = 256, }, /* Cipher A6 */ { .valid = 1, .name = TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256, .id = TLS1_CK_ADH_WITH_AES_128_GCM_SHA256, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_AES128GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 128, .alg_bits = 128, }, /* Cipher A7 */ { .valid = 1, .name = TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384, .id = TLS1_CK_ADH_WITH_AES_256_GCM_SHA384, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_AES256GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 256, .alg_bits = 256, }, /* Cipher C001 */ { .valid = 1, .name = TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA, .id = TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA, .algorithm_mkey = SSL_kECDHe, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_eNULL, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_STRONG_NONE, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 0, .alg_bits = 0, }, /* Cipher C002 */ { .valid = 1, .name = TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA, .id = TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA, .algorithm_mkey = SSL_kECDHe, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_RC4, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_MEDIUM, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C003 */ { .valid = 1, .name = TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA, .id = TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA, .algorithm_mkey = SSL_kECDHe, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_3DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 112, .alg_bits = 168, }, /* Cipher C004 */ { .valid = 1, .name = TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA, .id = TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA, .algorithm_mkey = SSL_kECDHe, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C005 */ { .valid = 1, .name = TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA, .id = TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA, .algorithm_mkey = SSL_kECDHe, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher C006 */ { .valid = 1, .name = TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA, .id = TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aECDSA, .algorithm_enc = SSL_eNULL, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_STRONG_NONE, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 0, .alg_bits = 0, }, /* Cipher C007 */ { .valid = 1, .name = TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA, .id = TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aECDSA, .algorithm_enc = SSL_RC4, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_MEDIUM, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C008 */ { .valid = 1, .name = TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA, .id = TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aECDSA, .algorithm_enc = SSL_3DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 112, .alg_bits = 168, }, /* Cipher C009 */ { .valid = 1, .name = TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, .id = TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aECDSA, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C00A */ { .valid = 1, .name = TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, .id = TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aECDSA, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher C00B */ { .valid = 1, .name = TLS1_TXT_ECDH_RSA_WITH_NULL_SHA, .id = TLS1_CK_ECDH_RSA_WITH_NULL_SHA, .algorithm_mkey = SSL_kECDHr, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_eNULL, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_STRONG_NONE, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 0, .alg_bits = 0, }, /* Cipher C00C */ { .valid = 1, .name = TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA, .id = TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA, .algorithm_mkey = SSL_kECDHr, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_RC4, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_MEDIUM, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C00D */ { .valid = 1, .name = TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA, .id = TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA, .algorithm_mkey = SSL_kECDHr, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_3DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 112, .alg_bits = 168, }, /* Cipher C00E */ { .valid = 1, .name = TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA, .id = TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA, .algorithm_mkey = SSL_kECDHr, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C00F */ { .valid = 1, .name = TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA, .id = TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA, .algorithm_mkey = SSL_kECDHr, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher C010 */ { .valid = 1, .name = TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA, .id = TLS1_CK_ECDHE_RSA_WITH_NULL_SHA, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_eNULL, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_STRONG_NONE, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 0, .alg_bits = 0, }, /* Cipher C011 */ { .valid = 1, .name = TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA, .id = TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_RC4, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_MEDIUM, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C012 */ { .valid = 1, .name = TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA, .id = TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_3DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 112, .alg_bits = 168, }, /* Cipher C013 */ { .valid = 1, .name = TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA, .id = TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C014 */ { .valid = 1, .name = TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA, .id = TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* Cipher C015 */ { .valid = 1, .name = TLS1_TXT_ECDH_anon_WITH_NULL_SHA, .id = TLS1_CK_ECDH_anon_WITH_NULL_SHA, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_eNULL, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_STRONG_NONE, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 0, .alg_bits = 0, }, /* Cipher C016 */ { .valid = 1, .name = TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA, .id = TLS1_CK_ECDH_anon_WITH_RC4_128_SHA, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_RC4, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_MEDIUM, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C017 */ { .valid = 1, .name = TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA, .id = TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_3DES, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 112, .alg_bits = 168, }, /* Cipher C018 */ { .valid = 1, .name = TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA, .id = TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C019 */ { .valid = 1, .name = TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA, .id = TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA1, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, /* HMAC based TLS v1.2 ciphersuites from RFC5289 */ /* Cipher C023 */ { .valid = 1, .name = TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256, .id = TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aECDSA, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C024 */ { .valid = 1, .name = TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384, .id = TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aECDSA, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA384, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384, .strength_bits = 256, .alg_bits = 256, }, /* Cipher C025 */ { .valid = 1, .name = TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256, .id = TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256, .algorithm_mkey = SSL_kECDHe, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C026 */ { .valid = 1, .name = TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384, .id = TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384, .algorithm_mkey = SSL_kECDHe, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA384, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384, .strength_bits = 256, .alg_bits = 256, }, /* Cipher C027 */ { .valid = 1, .name = TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256, .id = TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C028 */ { .valid = 1, .name = TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384, .id = TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA384, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384, .strength_bits = 256, .alg_bits = 256, }, /* Cipher C029 */ { .valid = 1, .name = TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256, .id = TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256, .algorithm_mkey = SSL_kECDHr, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_AES128, .algorithm_mac = SSL_SHA256, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C02A */ { .valid = 1, .name = TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384, .id = TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384, .algorithm_mkey = SSL_kECDHr, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_AES256, .algorithm_mac = SSL_SHA384, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384, .strength_bits = 256, .alg_bits = 256, }, /* GCM based TLS v1.2 ciphersuites from RFC5289 */ /* Cipher C02B */ { .valid = 1, .name = TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, .id = TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aECDSA, .algorithm_enc = SSL_AES128GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C02C */ { .valid = 1, .name = TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, .id = TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aECDSA, .algorithm_enc = SSL_AES256GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 256, .alg_bits = 256, }, /* Cipher C02D */ { .valid = 1, .name = TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, .id = TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, .algorithm_mkey = SSL_kECDHe, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_AES128GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C02E */ { .valid = 1, .name = TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, .id = TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, .algorithm_mkey = SSL_kECDHe, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_AES256GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 256, .alg_bits = 256, }, /* Cipher C02F */ { .valid = 1, .name = TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256, .id = TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES128GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C030 */ { .valid = 1, .name = TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384, .id = TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_AES256GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 256, .alg_bits = 256, }, /* Cipher C031 */ { .valid = 1, .name = TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256, .id = TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256, .algorithm_mkey = SSL_kECDHr, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_AES128GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 128, .alg_bits = 128, }, /* Cipher C032 */ { .valid = 1, .name = TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384, .id = TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384, .algorithm_mkey = SSL_kECDHr, .algorithm_auth = SSL_aECDH, .algorithm_enc = SSL_AES256GCM, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(4)| SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_IN_RECORD, .strength_bits = 256, .alg_bits = 256, }, #ifdef TEMP_GOST_TLS /* Cipher FF00 */ { .valid = 1, .name = "GOST-MD5", .id = 0x0300ff00, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_eGOST2814789CNT, .algorithm_mac = SSL_MD5, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256, }, { .valid = 1, .name = "GOST-GOST94", .id = 0x0300ff01, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_eGOST2814789CNT, .algorithm_mac = SSL_GOST94, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256 }, { .valid = 1, .name = "GOST-GOST89MAC", .id = 0x0300ff02, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_eGOST2814789CNT, .algorithm_mac = SSL_GOST89MAC, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, .strength_bits = 256, .alg_bits = 256 }, { .valid = 1, .name = "GOST-GOST89STREAM", .id = 0x0300ff03, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_eGOST2814789CNT, .algorithm_mac = SSL_GOST89MAC, .algorithm_ssl = SSL_TLSV1, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF| TLS1_STREAM_MAC, .strength_bits = 256, .alg_bits = 256 }, #endif #if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) { .valid = 1, .name = TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305, .id = TLS1_CK_ECDHE_RSA_CHACHA20_POLY1305, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_CHACHA20POLY1305, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(0), .strength_bits = 256, .alg_bits = 0, }, { .valid = 1, .name = TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, .id = TLS1_CK_ECDHE_ECDSA_CHACHA20_POLY1305, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aECDSA, .algorithm_enc = SSL_CHACHA20POLY1305, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(0), .strength_bits = 256, .alg_bits = 0, }, { .valid = 1, .name = TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305, .id = TLS1_CK_DHE_RSA_CHACHA20_POLY1305, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aRSA, .algorithm_enc = SSL_CHACHA20POLY1305, .algorithm_mac = SSL_AEAD, .algorithm_ssl = SSL_TLSV1_2, .algo_strength = SSL_HIGH, .algorithm2 = SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256| SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(0), .strength_bits = 256, .alg_bits = 0, }, #endif /* end of list */ }; SSL3_ENC_METHOD SSLv3_enc_data = { .enc = ssl3_enc, .mac = n_ssl3_mac, .setup_key_block = ssl3_setup_key_block, .generate_master_secret = ssl3_generate_master_secret, .change_cipher_state = ssl3_change_cipher_state, .final_finish_mac = ssl3_final_finish_mac, .finish_mac_length = MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, .cert_verify_mac = ssl3_cert_verify_mac, .client_finished_label = SSL3_MD_CLIENT_FINISHED_CONST, .client_finished_label_len = 4, .server_finished_label = SSL3_MD_SERVER_FINISHED_CONST, .server_finished_label_len = 4, .alert_value = ssl3_alert_code, .export_keying_material = (int (*)(SSL *, unsigned char *, size_t, const char *, size_t, const unsigned char *, size_t, int use_context))ssl_undefined_function, .enc_flags = 0, }; long ssl3_default_timeout(void) { /* * 2 hours, the 24 hours mentioned in the SSLv3 spec * is way too long for http, the cache would over fill */ return (60 * 60 * 2); } int ssl3_num_ciphers(void) { return (SSL3_NUM_CIPHERS); } const SSL_CIPHER * ssl3_get_cipher(unsigned int u) { if (u < SSL3_NUM_CIPHERS) return (&(ssl3_ciphers[SSL3_NUM_CIPHERS - 1 - u])); else return (NULL); } int ssl3_pending(const SSL *s) { if (s->rstate == SSL_ST_READ_BODY) return 0; return (s->s3->rrec.type == SSL3_RT_APPLICATION_DATA) ? s->s3->rrec.length : 0; } int ssl3_new(SSL *s) { SSL3_STATE *s3; if ((s3 = calloc(1, sizeof *s3)) == NULL) goto err; memset(s3->rrec.seq_num, 0, sizeof(s3->rrec.seq_num)); memset(s3->wrec.seq_num, 0, sizeof(s3->wrec.seq_num)); s->s3 = s3; s->method->ssl_clear(s); return (1); err: return (0); } void ssl3_free(SSL *s) { if (s == NULL) return; ssl3_cleanup_key_block(s); ssl3_release_read_buffer(s); ssl3_release_write_buffer(s); DH_free(s->s3->tmp.dh); EC_KEY_free(s->s3->tmp.ecdh); if (s->s3->tmp.ca_names != NULL) sk_X509_NAME_pop_free(s->s3->tmp.ca_names, X509_NAME_free); BIO_free(s->s3->handshake_buffer); ssl3_free_digest_list(s); OPENSSL_cleanse(s->s3, sizeof *s->s3); free(s->s3); s->s3 = NULL; } void ssl3_clear(SSL *s) { unsigned char *rp, *wp; size_t rlen, wlen; int init_extra; ssl3_cleanup_key_block(s); if (s->s3->tmp.ca_names != NULL) sk_X509_NAME_pop_free(s->s3->tmp.ca_names, X509_NAME_free); DH_free(s->s3->tmp.dh); s->s3->tmp.dh = NULL; EC_KEY_free(s->s3->tmp.ecdh); s->s3->tmp.ecdh = NULL; s->s3->is_probably_safari = 0; rp = s->s3->rbuf.buf; wp = s->s3->wbuf.buf; rlen = s->s3->rbuf.len; wlen = s->s3->wbuf.len; init_extra = s->s3->init_extra; BIO_free(s->s3->handshake_buffer); s->s3->handshake_buffer = NULL; ssl3_free_digest_list(s); memset(s->s3, 0, sizeof *s->s3); s->s3->rbuf.buf = rp; s->s3->wbuf.buf = wp; s->s3->rbuf.len = rlen; s->s3->wbuf.len = wlen; s->s3->init_extra = init_extra; ssl_free_wbio_buffer(s); s->packet_length = 0; s->s3->renegotiate = 0; s->s3->total_renegotiations = 0; s->s3->num_renegotiations = 0; s->s3->in_read_app_data = 0; s->version = SSL3_VERSION; #ifndef OPENSSL_NO_NEXTPROTONEG free(s->next_proto_negotiated); s->next_proto_negotiated = NULL; s->next_proto_negotiated_len = 0; #endif } long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg) { int ret = 0; if (cmd == SSL_CTRL_SET_TMP_RSA || cmd == SSL_CTRL_SET_TMP_RSA_CB || cmd == SSL_CTRL_SET_TMP_DH || cmd == SSL_CTRL_SET_TMP_DH_CB) { if (!ssl_cert_inst(&s->cert)) { SSLerr(SSL_F_SSL3_CTRL, ERR_R_MALLOC_FAILURE); return (0); } } switch (cmd) { case SSL_CTRL_GET_SESSION_REUSED: ret = s->hit; break; case SSL_CTRL_GET_CLIENT_CERT_REQUEST: break; case SSL_CTRL_GET_NUM_RENEGOTIATIONS: ret = s->s3->num_renegotiations; break; case SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS: ret = s->s3->num_renegotiations; s->s3->num_renegotiations = 0; break; case SSL_CTRL_GET_TOTAL_RENEGOTIATIONS: ret = s->s3->total_renegotiations; break; case SSL_CTRL_GET_FLAGS: ret = (int)(s->s3->flags); break; case SSL_CTRL_NEED_TMP_RSA: if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) && ((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) || (EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) > (512 / 8)))) ret = 1; break; case SSL_CTRL_SET_TMP_RSA: { RSA *rsa = (RSA *)parg; if (rsa == NULL) { SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER); return (ret); } if ((rsa = RSAPrivateKey_dup(rsa)) == NULL) { SSLerr(SSL_F_SSL3_CTRL, ERR_R_RSA_LIB); return (ret); } RSA_free(s->cert->rsa_tmp); s->cert->rsa_tmp = rsa; ret = 1; } break; case SSL_CTRL_SET_TMP_RSA_CB: { SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return (ret); } break; case SSL_CTRL_SET_TMP_DH: { DH *dh = (DH *)parg; if (dh == NULL) { SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER); return (ret); } if ((dh = DHparams_dup(dh)) == NULL) { SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB); return (ret); } if (!(s->options & SSL_OP_SINGLE_DH_USE)) { if (!DH_generate_key(dh)) { DH_free(dh); SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB); return (ret); } } DH_free(s->cert->dh_tmp); s->cert->dh_tmp = dh; ret = 1; } break; case SSL_CTRL_SET_TMP_DH_CB: { SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return (ret); } break; case SSL_CTRL_SET_TMP_ECDH: { EC_KEY *ecdh = NULL; if (parg == NULL) { SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER); return (ret); } if (!EC_KEY_up_ref((EC_KEY *)parg)) { SSLerr(SSL_F_SSL3_CTRL, ERR_R_ECDH_LIB); return (ret); } ecdh = (EC_KEY *)parg; if (!(s->options & SSL_OP_SINGLE_ECDH_USE)) { if (!EC_KEY_generate_key(ecdh)) { EC_KEY_free(ecdh); SSLerr(SSL_F_SSL3_CTRL, ERR_R_ECDH_LIB); return (ret); } } EC_KEY_free(s->cert->ecdh_tmp); s->cert->ecdh_tmp = ecdh; ret = 1; } break; case SSL_CTRL_SET_TMP_ECDH_CB: { SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return (ret); } break; case SSL_CTRL_SET_TLSEXT_HOSTNAME: if (larg == TLSEXT_NAMETYPE_host_name) { free(s->tlsext_hostname); s->tlsext_hostname = NULL; ret = 1; if (parg == NULL) break; if (strlen((char *)parg) > TLSEXT_MAXLEN_host_name) { SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME); return 0; } if ((s->tlsext_hostname = BUF_strdup((char *)parg)) == NULL) { SSLerr(SSL_F_SSL3_CTRL, ERR_R_INTERNAL_ERROR); return 0; } } else { SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE); return 0; } break; case SSL_CTRL_SET_TLSEXT_DEBUG_ARG: s->tlsext_debug_arg = parg; ret = 1; break; case SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE: s->tlsext_status_type = larg; ret = 1; break; case SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS: *(STACK_OF(X509_EXTENSION) **)parg = s->tlsext_ocsp_exts; ret = 1; break; case SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS: s->tlsext_ocsp_exts = parg; ret = 1; break; case SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS: *(STACK_OF(OCSP_RESPID) **)parg = s->tlsext_ocsp_ids; ret = 1; break; case SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS: s->tlsext_ocsp_ids = parg; ret = 1; break; case SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP: *(unsigned char **)parg = s->tlsext_ocsp_resp; return s->tlsext_ocsp_resplen; case SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP: free(s->tlsext_ocsp_resp); s->tlsext_ocsp_resp = parg; s->tlsext_ocsp_resplen = larg; ret = 1; break; default: break; } return (ret); } long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)(void)) { int ret = 0; if (cmd == SSL_CTRL_SET_TMP_RSA_CB || cmd == SSL_CTRL_SET_TMP_DH_CB) { if (!ssl_cert_inst(&s->cert)) { SSLerr(SSL_F_SSL3_CALLBACK_CTRL, ERR_R_MALLOC_FAILURE); return (0); } } switch (cmd) { case SSL_CTRL_SET_TMP_RSA_CB: { s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp; } break; case SSL_CTRL_SET_TMP_DH_CB: { s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp; } break; case SSL_CTRL_SET_TMP_ECDH_CB: { s->cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp; } break; case SSL_CTRL_SET_TLSEXT_DEBUG_CB: s->tlsext_debug_cb = (void (*)(SSL *, int , int, unsigned char *, int, void *))fp; break; default: break; } return (ret); } long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg) { CERT *cert; cert = ctx->cert; switch (cmd) { case SSL_CTRL_NEED_TMP_RSA: if ((cert->rsa_tmp == NULL) && ((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) || (EVP_PKEY_size(cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) > (512 / 8)))) return (1); else return (0); /* break; */ case SSL_CTRL_SET_TMP_RSA: { RSA *rsa; int i; rsa = (RSA *)parg; i = 1; if (rsa == NULL) i = 0; else { if ((rsa = RSAPrivateKey_dup(rsa)) == NULL) i = 0; } if (!i) { SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_RSA_LIB); return (0); } else { RSA_free(cert->rsa_tmp); cert->rsa_tmp = rsa; return (1); } } /* break; */ case SSL_CTRL_SET_TMP_RSA_CB: { SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return (0); } break; case SSL_CTRL_SET_TMP_DH: { DH *new = NULL, *dh; dh = (DH *)parg; if ((new = DHparams_dup(dh)) == NULL) { SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_DH_LIB); return 0; } if (!(ctx->options & SSL_OP_SINGLE_DH_USE)) { if (!DH_generate_key(new)) { SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_DH_LIB); DH_free(new); return 0; } } DH_free(cert->dh_tmp); cert->dh_tmp = new; return 1; } /*break; */ case SSL_CTRL_SET_TMP_DH_CB: { SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return (0); } break; case SSL_CTRL_SET_TMP_ECDH: { EC_KEY *ecdh = NULL; if (parg == NULL) { SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_ECDH_LIB); return 0; } ecdh = EC_KEY_dup((EC_KEY *)parg); if (ecdh == NULL) { SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_EC_LIB); return 0; } if (!(ctx->options & SSL_OP_SINGLE_ECDH_USE)) { if (!EC_KEY_generate_key(ecdh)) { EC_KEY_free(ecdh); SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_ECDH_LIB); return 0; } } EC_KEY_free(cert->ecdh_tmp); cert->ecdh_tmp = ecdh; return 1; } /* break; */ case SSL_CTRL_SET_TMP_ECDH_CB: { SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return (0); } break; case SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG: ctx->tlsext_servername_arg = parg; break; case SSL_CTRL_SET_TLSEXT_TICKET_KEYS: case SSL_CTRL_GET_TLSEXT_TICKET_KEYS: { unsigned char *keys = parg; if (!keys) return 48; if (larg != 48) { SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_INVALID_TICKET_KEYS_LENGTH); return 0; } if (cmd == SSL_CTRL_SET_TLSEXT_TICKET_KEYS) { memcpy(ctx->tlsext_tick_key_name, keys, 16); memcpy(ctx->tlsext_tick_hmac_key, keys + 16, 16); memcpy(ctx->tlsext_tick_aes_key, keys + 32, 16); } else { memcpy(keys, ctx->tlsext_tick_key_name, 16); memcpy(keys + 16, ctx->tlsext_tick_hmac_key, 16); memcpy(keys + 32, ctx->tlsext_tick_aes_key, 16); } return 1; } case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG: ctx->tlsext_status_arg = parg; return 1; break; /* A Thawte special :-) */ case SSL_CTRL_EXTRA_CHAIN_CERT: if (ctx->extra_certs == NULL) { if ((ctx->extra_certs = sk_X509_new_null()) == NULL) return (0); } sk_X509_push(ctx->extra_certs,(X509 *)parg); break; case SSL_CTRL_GET_EXTRA_CHAIN_CERTS: *(STACK_OF(X509) **)parg = ctx->extra_certs; break; case SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS: if (ctx->extra_certs) { sk_X509_pop_free(ctx->extra_certs, X509_free); ctx->extra_certs = NULL; } break; default: return (0); } return (1); } long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void)) { CERT *cert; cert = ctx->cert; switch (cmd) { case SSL_CTRL_SET_TMP_RSA_CB: { cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp; } break; case SSL_CTRL_SET_TMP_DH_CB: { cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp; } break; case SSL_CTRL_SET_TMP_ECDH_CB: { cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp; } break; case SSL_CTRL_SET_TLSEXT_SERVERNAME_CB: ctx->tlsext_servername_callback = (int (*)(SSL *, int *, void *))fp; break; case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB: ctx->tlsext_status_cb = (int (*)(SSL *, void *))fp; break; case SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB: ctx->tlsext_ticket_key_cb = (int (*)(SSL *, unsigned char *, unsigned char *, EVP_CIPHER_CTX *, HMAC_CTX *, int))fp; break; default: return (0); } return (1); } /* This function needs to check if the ciphers required are actually * available */ const SSL_CIPHER * ssl3_get_cipher_by_char(const unsigned char *p) { SSL_CIPHER c; const SSL_CIPHER *cp; unsigned long id; id = 0x03000000L | ((unsigned long)p[0] << 8L) | (unsigned long)p[1]; c.id = id; cp = OBJ_bsearch_ssl_cipher_id(&c, ssl3_ciphers, SSL3_NUM_CIPHERS); #ifdef DEBUG_PRINT_UNKNOWN_CIPHERSUITES if (cp == NULL) fprintf(stderr, "Unknown cipher ID %x\n", (p[0] << 8) | p[1]); #endif if (cp == NULL || cp->valid == 0) return NULL; else return cp; } int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p) { long l; if (p != NULL) { l = c->id; if ((l & 0xff000000) != 0x03000000) return (0); p[0] = ((unsigned char)(l >> 8L)) & 0xFF; p[1] = ((unsigned char)(l)) & 0xFF; } return (2); } SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt, STACK_OF(SSL_CIPHER) *srvr) { SSL_CIPHER *c, *ret = NULL; STACK_OF(SSL_CIPHER) *prio, *allow; int i, ii, ok; unsigned int j; int ec_ok, ec_nid; unsigned char ec_search1 = 0, ec_search2 = 0; CERT *cert; unsigned long alg_k, alg_a, mask_k, mask_a; /* Let's see which ciphers we can support */ cert = s->cert; /* * Do not set the compare functions, because this may lead to a * reordering by "id". We want to keep the original ordering. * We may pay a price in performance during sk_SSL_CIPHER_find(), * but would have to pay with the price of sk_SSL_CIPHER_dup(). */ if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE) { prio = srvr; allow = clnt; } else { prio = clnt; allow = srvr; } for (i = 0; i < sk_SSL_CIPHER_num(prio); i++) { c = sk_SSL_CIPHER_value(prio, i); /* Skip TLS v1.2 only ciphersuites if not supported. */ if ((c->algorithm_ssl & SSL_TLSV1_2) && !SSL_USE_TLS1_2_CIPHERS(s)) continue; ssl_set_cert_masks(cert, c); mask_k = cert->mask_k; mask_a = cert->mask_a; alg_k = c->algorithm_mkey; alg_a = c->algorithm_auth; ok = (alg_k & mask_k) && (alg_a & mask_a); if ( /* * if we are considering an ECC cipher suite that uses our * certificate */ (alg_a & SSL_aECDSA || alg_a & SSL_aECDH) /* and we have an ECC certificate */ && (s->cert->pkeys[SSL_PKEY_ECC].x509 != NULL) /* * and the client specified a Supported Point Formats * extension */ && ((s->session->tlsext_ecpointformatlist_length > 0) && (s->session->tlsext_ecpointformatlist != NULL)) /* and our certificate's point is compressed */ && ( (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info != NULL) && (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key != NULL) && (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key != NULL) && (s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key->data != NULL) && ( (*(s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key->data) == POINT_CONVERSION_COMPRESSED) || (*(s->cert->pkeys[SSL_PKEY_ECC].x509->cert_info->key->public_key->data) == POINT_CONVERSION_COMPRESSED + 1) ) ) ) { ec_ok = 0; /* * If our certificate's curve is over a field type * that the client does not support then do not allow * this cipher suite to be negotiated */ if ( (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec != NULL) && (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group != NULL) && (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth != NULL) && (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_prime_field) ) { for (j = 0; j < s->session->tlsext_ecpointformatlist_length; j++) { if (s->session->tlsext_ecpointformatlist[j] == TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime) { ec_ok = 1; break; } } } else if (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_characteristic_two_field) { for (j = 0; j < s->session->tlsext_ecpointformatlist_length; j++) { if (s->session->tlsext_ecpointformatlist[j] == TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2) { ec_ok = 1; break; } } } ok = ok && ec_ok; } if ( /* * If we are considering an ECC cipher suite that uses our * certificate */ (alg_a & SSL_aECDSA || alg_a & SSL_aECDH) /* and we have an ECC certificate */ && (s->cert->pkeys[SSL_PKEY_ECC].x509 != NULL) /* and the client specified an EllipticCurves extension */ && ((s->session->tlsext_ellipticcurvelist_length > 0) && (s->session->tlsext_ellipticcurvelist != NULL)) ) { ec_ok = 0; if ( (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec != NULL) && (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group != NULL) ) { ec_nid = EC_GROUP_get_curve_name(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group); if ((ec_nid == 0) && (s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth != NULL) ) { if (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_prime_field) { ec_search1 = 0xFF; ec_search2 = 0x01; } else if (EC_METHOD_get_field_type(s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec->group->meth) == NID_X9_62_characteristic_two_field) { ec_search1 = 0xFF; ec_search2 = 0x02; } } else { ec_search1 = 0x00; ec_search2 = tls1_ec_nid2curve_id(ec_nid); } if ((ec_search1 != 0) || (ec_search2 != 0)) { for (j = 0; j < s->session->tlsext_ellipticcurvelist_length / 2; j++) { if ((s->session->tlsext_ellipticcurvelist[2*j] == ec_search1) && (s->session->tlsext_ellipticcurvelist[2*j + 1] == ec_search2)) { ec_ok = 1; break; } } } } ok = ok && ec_ok; } if ( /* * if we are considering an ECC cipher suite that uses an * ephemeral EC key */ (alg_k & SSL_kEECDH) /* and we have an ephemeral EC key */ && (s->cert->ecdh_tmp != NULL) /* and the client specified an EllipticCurves extension */ && ((s->session->tlsext_ellipticcurvelist_length > 0) && (s->session->tlsext_ellipticcurvelist != NULL)) ) { ec_ok = 0; if (s->cert->ecdh_tmp->group != NULL) { ec_nid = EC_GROUP_get_curve_name(s->cert->ecdh_tmp->group); if ((ec_nid == 0) && (s->cert->ecdh_tmp->group->meth != NULL) ) { if (EC_METHOD_get_field_type(s->cert->ecdh_tmp->group->meth) == NID_X9_62_prime_field) { ec_search1 = 0xFF; ec_search2 = 0x01; } else if (EC_METHOD_get_field_type(s->cert->ecdh_tmp->group->meth) == NID_X9_62_characteristic_two_field) { ec_search1 = 0xFF; ec_search2 = 0x02; } } else { ec_search1 = 0x00; ec_search2 = tls1_ec_nid2curve_id(ec_nid); } if ((ec_search1 != 0) || (ec_search2 != 0)) { for (j = 0; j < s->session->tlsext_ellipticcurvelist_length / 2; j++) { if ((s->session->tlsext_ellipticcurvelist[2*j] == ec_search1) && (s->session->tlsext_ellipticcurvelist[2*j + 1] == ec_search2)) { ec_ok = 1; break; } } } } ok = ok && ec_ok; } if (!ok) continue; ii = sk_SSL_CIPHER_find(allow, c); if (ii >= 0) { if ((alg_k & SSL_kEECDH) && (alg_a & SSL_aECDSA) && s->s3->is_probably_safari) { if (!ret) ret = sk_SSL_CIPHER_value(allow, ii); continue; } ret = sk_SSL_CIPHER_value(allow, ii); break; } } return (ret); } int ssl3_get_req_cert_type(SSL *s, unsigned char *p) { int ret = 0; unsigned long alg_k; alg_k = s->s3->tmp.new_cipher->algorithm_mkey; #ifndef OPENSSL_NO_GOST if (s->version >= TLS1_VERSION) { if (alg_k & SSL_kGOST) { p[ret++] = TLS_CT_GOST94_SIGN; p[ret++] = TLS_CT_GOST01_SIGN; return (ret); } } #endif if (alg_k & (SSL_kDHr|SSL_kEDH)) { p[ret++] = SSL3_CT_RSA_FIXED_DH; p[ret++] = SSL3_CT_DSS_FIXED_DH; } if ((s->version == SSL3_VERSION) && (alg_k & (SSL_kEDH|SSL_kDHd|SSL_kDHr))) { p[ret++] = SSL3_CT_RSA_EPHEMERAL_DH; p[ret++] = SSL3_CT_DSS_EPHEMERAL_DH; } p[ret++] = SSL3_CT_RSA_SIGN; p[ret++] = SSL3_CT_DSS_SIGN; if ((alg_k & (SSL_kECDHr|SSL_kECDHe)) && (s->version >= TLS1_VERSION)) { p[ret++] = TLS_CT_RSA_FIXED_ECDH; p[ret++] = TLS_CT_ECDSA_FIXED_ECDH; } /* * ECDSA certs can be used with RSA cipher suites as well * so we don't need to check for SSL_kECDH or SSL_kEECDH */ if (s->version >= TLS1_VERSION) { p[ret++] = TLS_CT_ECDSA_SIGN; } return (ret); } int ssl3_shutdown(SSL *s) { int ret; /* * Don't do anything much if we have not done the handshake or * we don't want to send messages :-) */ if ((s->quiet_shutdown) || (s->state == SSL_ST_BEFORE)) { s->shutdown = (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); return (1); } if (!(s->shutdown & SSL_SENT_SHUTDOWN)) { s->shutdown|=SSL_SENT_SHUTDOWN; ssl3_send_alert(s, SSL3_AL_WARNING, SSL_AD_CLOSE_NOTIFY); /* * Our shutdown alert has been sent now, and if it still needs * to be written, s->s3->alert_dispatch will be true */ if (s->s3->alert_dispatch) return(-1); /* return WANT_WRITE */ } else if (s->s3->alert_dispatch) { /* resend it if not sent */ ret = s->method->ssl_dispatch_alert(s); if (ret == -1) { /* * We only get to return -1 here the 2nd/Nth * invocation, we must have already signalled * return 0 upon a previous invoation, * return WANT_WRITE */ return (ret); } } else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) { /* If we are waiting for a close from our peer, we are closed */ s->method->ssl_read_bytes(s, 0, NULL, 0, 0); if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) { return(-1); /* return WANT_READ */ } } if ((s->shutdown == (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN)) && !s->s3->alert_dispatch) return (1); else return (0); } int ssl3_write(SSL *s, const void *buf, int len) { int ret, n; #if 0 if (s->shutdown & SSL_SEND_SHUTDOWN) { s->rwstate = SSL_NOTHING; return (0); } #endif errno = 0; if (s->s3->renegotiate) ssl3_renegotiate_check(s); /* * This is an experimental flag that sends the * last handshake message in the same packet as the first * use data - used to see if it helps the TCP protocol during * session-id reuse */ /* The second test is because the buffer may have been removed */ if ((s->s3->flags & SSL3_FLAGS_POP_BUFFER) && (s->wbio == s->bbio)) { /* First time through, we write into the buffer */ if (s->s3->delay_buf_pop_ret == 0) { ret = ssl3_write_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len); if (ret <= 0) return (ret); s->s3->delay_buf_pop_ret = ret; } s->rwstate = SSL_WRITING; n = BIO_flush(s->wbio); if (n <= 0) return (n); s->rwstate = SSL_NOTHING; /* We have flushed the buffer, so remove it */ ssl_free_wbio_buffer(s); s->s3->flags&= ~SSL3_FLAGS_POP_BUFFER; ret = s->s3->delay_buf_pop_ret; s->s3->delay_buf_pop_ret = 0; } else { ret = s->method->ssl_write_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len); if (ret <= 0) return (ret); } return (ret); } static int ssl3_read_internal(SSL *s, void *buf, int len, int peek) { int ret; errno = 0; if (s->s3->renegotiate) ssl3_renegotiate_check(s); s->s3->in_read_app_data = 1; ret = s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len, peek); if ((ret == -1) && (s->s3->in_read_app_data == 2)) { /* * ssl3_read_bytes decided to call s->handshake_func, which * called ssl3_read_bytes to read handshake data. * However, ssl3_read_bytes actually found application data * and thinks that application data makes sense here; so disable * handshake processing and try to read application data again. */ s->in_handshake++; ret = s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len, peek); s->in_handshake--; } else s->s3->in_read_app_data = 0; return (ret); } int ssl3_read(SSL *s, void *buf, int len) { return ssl3_read_internal(s, buf, len, 0); } int ssl3_peek(SSL *s, void *buf, int len) { return ssl3_read_internal(s, buf, len, 1); } int ssl3_renegotiate(SSL *s) { if (s->handshake_func == NULL) return (1); if (s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) return (0); s->s3->renegotiate = 1; return (1); } int ssl3_renegotiate_check(SSL *s) { int ret = 0; if (s->s3->renegotiate) { if ((s->s3->rbuf.left == 0) && (s->s3->wbuf.left == 0) && !SSL_in_init(s)) { /* * If we are the server, and we have sent * a 'RENEGOTIATE' message, we need to go * to SSL_ST_ACCEPT. */ /* SSL_ST_ACCEPT */ s->state = SSL_ST_RENEGOTIATE; s->s3->renegotiate = 0; s->s3->num_renegotiations++; s->s3->total_renegotiations++; ret = 1; } } return (ret); } /* * If we are using TLS v1.2 or later and default SHA1+MD5 algorithms switch * to new SHA256 PRF and handshake macs */ long ssl_get_algorithm2(SSL *s) { long alg2 = s->s3->tmp.new_cipher->algorithm2; if (s->method->version == TLS1_2_VERSION && alg2 == (SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF)) return SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256; return alg2; } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/ssl_sess.c0000644000175000017500000007476512360020705017561 0ustar /* $OpenBSD: ssl_sess.c,v 1.35 2014/07/10 08:51:15 tedu Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2005 Nokia. All rights reserved. * * The portions of the attached software ("Contribution") is developed by * Nokia Corporation and is licensed pursuant to the OpenSSL open source * license. * * The Contribution, originally written by Mika Kousa and Pasi Eronen of * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites * support (see RFC 4279) to OpenSSL. * * No patent licenses or other rights except those expressly stated in * the OpenSSL open source license shall be deemed granted or received * expressly, by implication, estoppel, or otherwise. * * No assurances are provided by Nokia that the Contribution does not * infringe the patent or other intellectual property rights of any third * party or that the license provides you with all the necessary rights * to make use of the Contribution. * * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR * OTHERWISE. */ #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif #include "ssl_locl.h" static void SSL_SESSION_list_remove(SSL_CTX *ctx, SSL_SESSION *s); static void SSL_SESSION_list_add(SSL_CTX *ctx, SSL_SESSION *s); static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck); /* aka SSL_get0_session; gets 0 objects, just returns a copy of the pointer */ SSL_SESSION * SSL_get_session(const SSL *ssl) { return (ssl->session); } /* variant of SSL_get_session: caller really gets something */ SSL_SESSION * SSL_get1_session(SSL *ssl) { SSL_SESSION *sess; /* Need to lock this all up rather than just use CRYPTO_add so that * somebody doesn't free ssl->session between when we check it's * non-null and when we up the reference count. */ CRYPTO_w_lock(CRYPTO_LOCK_SSL_SESSION); sess = ssl->session; if (sess) sess->references++; CRYPTO_w_unlock(CRYPTO_LOCK_SSL_SESSION); return (sess); } int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_SESSION, argl, argp, new_func, dup_func, free_func); } int SSL_SESSION_set_ex_data(SSL_SESSION *s, int idx, void *arg) { return (CRYPTO_set_ex_data(&s->ex_data, idx, arg)); } void * SSL_SESSION_get_ex_data(const SSL_SESSION *s, int idx) { return (CRYPTO_get_ex_data(&s->ex_data, idx)); } SSL_SESSION * SSL_SESSION_new(void) { SSL_SESSION *ss; ss = calloc(1, sizeof(SSL_SESSION)); if (ss == NULL) { SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE); return (0); } ss->verify_result = 1; /* avoid 0 (= X509_V_OK) just in case */ ss->references = 1; ss->timeout=60*5+4; /* 5 minute timeout by default */ ss->time = time(NULL); ss->prev = NULL; ss->next = NULL; ss->tlsext_hostname = NULL; ss->tlsext_ecpointformatlist_length = 0; ss->tlsext_ecpointformatlist = NULL; ss->tlsext_ellipticcurvelist_length = 0; ss->tlsext_ellipticcurvelist = NULL; CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data); return (ss); } const unsigned char * SSL_SESSION_get_id(const SSL_SESSION *s, unsigned int *len) { if (len) *len = s->session_id_length; return s->session_id; } unsigned int SSL_SESSION_get_compress_id(const SSL_SESSION *s) { return 0; } /* Even with SSLv2, we have 16 bytes (128 bits) of session ID space. SSLv3/TLSv1 * has 32 bytes (256 bits). As such, filling the ID with random gunk repeatedly * until we have no conflict is going to complete in one iteration pretty much * "most" of the time (btw: understatement). So, if it takes us 10 iterations * and we still can't avoid a conflict - well that's a reasonable point to call * it quits. Either the RAND code is broken or someone is trying to open roughly * very close to 2^128 (or 2^256) SSL sessions to our server. How you might * store that many sessions is perhaps a more interesting question ... */ #define MAX_SESS_ID_ATTEMPTS 10 static int def_generate_session_id(const SSL *ssl, unsigned char *id, unsigned int *id_len) { unsigned int retry = 0; do if (RAND_pseudo_bytes(id, *id_len) <= 0) return 0; while (SSL_has_matching_session_id(ssl, id, *id_len) && (++retry < MAX_SESS_ID_ATTEMPTS)); if (retry < MAX_SESS_ID_ATTEMPTS) return 1; /* else - woops a session_id match */ /* XXX We should also check the external cache -- * but the probability of a collision is negligible, and * we could not prevent the concurrent creation of sessions * with identical IDs since we currently don't have means * to atomically check whether a session ID already exists * and make a reservation for it if it does not * (this problem applies to the internal cache as well). */ return 0; } int ssl_get_new_session(SSL *s, int session) { /* This gets used by clients and servers. */ unsigned int tmp; SSL_SESSION *ss = NULL; GEN_SESSION_CB cb = def_generate_session_id; if ((ss = SSL_SESSION_new()) == NULL) return (0); /* If the context has a default timeout, use it */ if (s->session_ctx->session_timeout == 0) ss->timeout = SSL_get_default_timeout(s); else ss->timeout = s->session_ctx->session_timeout; if (s->session != NULL) { SSL_SESSION_free(s->session); s->session = NULL; } if (session) { switch (s->version) { case SSL3_VERSION: case TLS1_VERSION: case TLS1_1_VERSION: case TLS1_2_VERSION: case DTLS1_BAD_VER: case DTLS1_VERSION: ss->ssl_version = s->version; ss->session_id_length = SSL3_SSL_SESSION_ID_LENGTH; break; default: SSLerr(SSL_F_SSL_GET_NEW_SESSION, SSL_R_UNSUPPORTED_SSL_VERSION); SSL_SESSION_free(ss); return (0); } /* If RFC4507 ticket use empty session ID */ if (s->tlsext_ticket_expected) { ss->session_id_length = 0; goto sess_id_done; } /* Choose which callback will set the session ID */ CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); if (s->generate_session_id) cb = s->generate_session_id; else if (s->session_ctx->generate_session_id) cb = s->session_ctx->generate_session_id; CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); /* Choose a session ID */ tmp = ss->session_id_length; if (!cb(s, ss->session_id, &tmp)) { /* The callback failed */ SSLerr(SSL_F_SSL_GET_NEW_SESSION, SSL_R_SSL_SESSION_ID_CALLBACK_FAILED); SSL_SESSION_free(ss); return (0); } /* Don't allow the callback to set the session length to zero. * nor set it higher than it was. */ if (!tmp || (tmp > ss->session_id_length)) { /* The callback set an illegal length */ SSLerr(SSL_F_SSL_GET_NEW_SESSION, SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH); SSL_SESSION_free(ss); return (0); } ss->session_id_length = tmp; /* Finally, check for a conflict */ if (SSL_has_matching_session_id(s, ss->session_id, ss->session_id_length)) { SSLerr(SSL_F_SSL_GET_NEW_SESSION, SSL_R_SSL_SESSION_ID_CONFLICT); SSL_SESSION_free(ss); return (0); } sess_id_done: if (s->tlsext_hostname) { ss->tlsext_hostname = BUF_strdup(s->tlsext_hostname); if (ss->tlsext_hostname == NULL) { SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_INTERNAL_ERROR); SSL_SESSION_free(ss); return 0; } } if (s->tlsext_ecpointformatlist) { free(ss->tlsext_ecpointformatlist); if ((ss->tlsext_ecpointformatlist = malloc(s->tlsext_ecpointformatlist_length)) == NULL) { SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_MALLOC_FAILURE); SSL_SESSION_free(ss); return 0; } ss->tlsext_ecpointformatlist_length = s->tlsext_ecpointformatlist_length; memcpy(ss->tlsext_ecpointformatlist, s->tlsext_ecpointformatlist, s->tlsext_ecpointformatlist_length); } if (s->tlsext_ellipticcurvelist) { free(ss->tlsext_ellipticcurvelist); if ((ss->tlsext_ellipticcurvelist = malloc(s->tlsext_ellipticcurvelist_length)) == NULL) { SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_MALLOC_FAILURE); SSL_SESSION_free(ss); return 0; } ss->tlsext_ellipticcurvelist_length = s->tlsext_ellipticcurvelist_length; memcpy(ss->tlsext_ellipticcurvelist, s->tlsext_ellipticcurvelist, s->tlsext_ellipticcurvelist_length); } } else { ss->session_id_length = 0; } if (s->sid_ctx_length > sizeof ss->sid_ctx) { SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_INTERNAL_ERROR); SSL_SESSION_free(ss); return 0; } memcpy(ss->sid_ctx, s->sid_ctx, s->sid_ctx_length); ss->sid_ctx_length = s->sid_ctx_length; s->session = ss; ss->ssl_version = s->version; ss->verify_result = X509_V_OK; return (1); } /* ssl_get_prev attempts to find an SSL_SESSION to be used to resume this * connection. It is only called by servers. * * session_id: points at the session ID in the ClientHello. This code will * read past the end of this in order to parse out the session ticket * extension, if any. * len: the length of the session ID. * limit: a pointer to the first byte after the ClientHello. * * Returns: * -1: error * 0: a session may have been found. * * Side effects: * - If a session is found then s->session is pointed at it (after freeing an * existing session if need be) and s->verify_result is set from the session. * - Both for new and resumed sessions, s->tlsext_ticket_expected is set to 1 * if the server should issue a new session ticket (to 0 otherwise). */ int ssl_get_prev_session(SSL *s, unsigned char *session_id, int len, const unsigned char *limit) { /* This is used only by servers. */ SSL_SESSION *ret = NULL; int fatal = 0; int try_session_cache = 1; int r; if (len > SSL_MAX_SSL_SESSION_ID_LENGTH) goto err; if (len == 0) try_session_cache = 0; r = tls1_process_ticket(s, session_id, len, limit, &ret); /* sets s->tlsext_ticket_expected */ switch (r) { case -1: /* Error during processing */ fatal = 1; goto err; case 0: /* No ticket found */ case 1: /* Zero length ticket found */ break; /* Ok to carry on processing session id. */ case 2: /* Ticket found but not decrypted. */ case 3: /* Ticket decrypted, *ret has been set. */ try_session_cache = 0; break; default: abort(); } if (try_session_cache && ret == NULL && !(s->session_ctx->session_cache_mode & SSL_SESS_CACHE_NO_INTERNAL_LOOKUP)) { SSL_SESSION data; data.ssl_version = s->version; data.session_id_length = len; if (len == 0) return 0; memcpy(data.session_id, session_id, len); CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); ret = lh_SSL_SESSION_retrieve(s->session_ctx->sessions, &data); if (ret != NULL) { /* don't allow other threads to steal it: */ CRYPTO_add(&ret->references, 1, CRYPTO_LOCK_SSL_SESSION); } CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); if (ret == NULL) s->session_ctx->stats.sess_miss++; } if (try_session_cache && ret == NULL && s->session_ctx->get_session_cb != NULL) { int copy = 1; if ((ret = s->session_ctx->get_session_cb(s, session_id, len, ©))) { s->session_ctx->stats.sess_cb_hit++; /* Increment reference count now if the session callback * asks us to do so (note that if the session structures * returned by the callback are shared between threads, * it must handle the reference count itself [i.e. copy == 0], * or things won't be thread-safe). */ if (copy) CRYPTO_add(&ret->references, 1, CRYPTO_LOCK_SSL_SESSION); /* Add the externally cached session to the internal * cache as well if and only if we are supposed to. */ if (!(s->session_ctx->session_cache_mode & SSL_SESS_CACHE_NO_INTERNAL_STORE)) /* The following should not return 1, otherwise, * things are very strange */ SSL_CTX_add_session(s->session_ctx, ret); } } if (ret == NULL) goto err; /* Now ret is non-NULL and we own one of its reference counts. */ if (ret->sid_ctx_length != s->sid_ctx_length || timingsafe_memcmp(ret->sid_ctx, s->sid_ctx, ret->sid_ctx_length) != 0) { /* We have the session requested by the client, but we don't * want to use it in this context. */ goto err; /* treat like cache miss */ } if ((s->verify_mode & SSL_VERIFY_PEER) && s->sid_ctx_length == 0) { /* We can't be sure if this session is being used out of * context, which is especially important for SSL_VERIFY_PEER. * The application should have used SSL[_CTX]_set_session_id_context. * * For this error case, we generate an error instead of treating * the event like a cache miss (otherwise it would be easy for * applications to effectively disable the session cache by * accident without anyone noticing). */ SSLerr(SSL_F_SSL_GET_PREV_SESSION, SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED); fatal = 1; goto err; } if (ret->cipher == NULL) { unsigned char buf[5], *p; unsigned long l; p = buf; l = ret->cipher_id; l2n(l, p); if ((ret->ssl_version >> 8) >= SSL3_VERSION_MAJOR) ret->cipher = ssl_get_cipher_by_char(s, &(buf[2])); else ret->cipher = ssl_get_cipher_by_char(s, &(buf[1])); if (ret->cipher == NULL) goto err; } if (ret->timeout < (time(NULL) - ret->time)) /* timeout */ { s->session_ctx->stats.sess_timeout++; if (try_session_cache) { /* session was from the cache, so remove it */ SSL_CTX_remove_session(s->session_ctx, ret); } goto err; } s->session_ctx->stats.sess_hit++; if (s->session != NULL) SSL_SESSION_free(s->session); s->session = ret; s->verify_result = s->session->verify_result; return 1; err: if (ret != NULL) { SSL_SESSION_free(ret); if (!try_session_cache) { /* The session was from a ticket, so we should * issue a ticket for the new session */ s->tlsext_ticket_expected = 1; } } if (fatal) return -1; else return 0; } int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *c) { int ret = 0; SSL_SESSION *s; /* add just 1 reference count for the SSL_CTX's session cache * even though it has two ways of access: each session is in a * doubly linked list and an lhash */ CRYPTO_add(&c->references, 1, CRYPTO_LOCK_SSL_SESSION); /* if session c is in already in cache, we take back the increment later */ CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); s = lh_SSL_SESSION_insert(ctx->sessions, c); /* s != NULL iff we already had a session with the given PID. * In this case, s == c should hold (then we did not really modify * ctx->sessions), or we're in trouble. */ if (s != NULL && s != c) { /* We *are* in trouble ... */ SSL_SESSION_list_remove(ctx, s); SSL_SESSION_free(s); /* ... so pretend the other session did not exist in cache * (we cannot handle two SSL_SESSION structures with identical * session ID in the same cache, which could happen e.g. when * two threads concurrently obtain the same session from an external * cache) */ s = NULL; } /* Put at the head of the queue unless it is already in the cache */ if (s == NULL) SSL_SESSION_list_add(ctx, c); if (s != NULL) { /* existing cache entry -- decrement previously incremented reference * count because it already takes into account the cache */ SSL_SESSION_free(s); /* s == c */ ret = 0; } else { /* new cache entry -- remove old ones if cache has become too large */ ret = 1; if (SSL_CTX_sess_get_cache_size(ctx) > 0) { while (SSL_CTX_sess_number(ctx) > SSL_CTX_sess_get_cache_size(ctx)) { if (!remove_session_lock(ctx, ctx->session_cache_tail, 0)) break; else ctx->stats.sess_cache_full++; } } } CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); return (ret); } int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c) { return remove_session_lock(ctx, c, 1); } static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck) { SSL_SESSION *r; int ret = 0; if ((c != NULL) && (c->session_id_length != 0)) { if (lck) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) { ret = 1; r = lh_SSL_SESSION_delete(ctx->sessions, c); SSL_SESSION_list_remove(ctx, c); } if (lck) CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); if (ret) { r->not_resumable = 1; if (ctx->remove_session_cb != NULL) ctx->remove_session_cb(ctx, r); SSL_SESSION_free(r); } } else ret = 0; return (ret); } void SSL_SESSION_free(SSL_SESSION *ss) { int i; if (ss == NULL) return; i = CRYPTO_add(&ss->references, -1, CRYPTO_LOCK_SSL_SESSION); if (i > 0) return; CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data); OPENSSL_cleanse(ss->master_key, sizeof ss->master_key); OPENSSL_cleanse(ss->session_id, sizeof ss->session_id); if (ss->sess_cert != NULL) ssl_sess_cert_free(ss->sess_cert); if (ss->peer != NULL) X509_free(ss->peer); if (ss->ciphers != NULL) sk_SSL_CIPHER_free(ss->ciphers); free(ss->tlsext_hostname); free(ss->tlsext_tick); ss->tlsext_ecpointformatlist_length = 0; free(ss->tlsext_ecpointformatlist); ss->tlsext_ellipticcurvelist_length = 0; free(ss->tlsext_ellipticcurvelist); OPENSSL_cleanse(ss, sizeof(*ss)); free(ss); } int SSL_set_session(SSL *s, SSL_SESSION *session) { int ret = 0; const SSL_METHOD *meth; if (session != NULL) { meth = s->ctx->method->get_ssl_method(session->ssl_version); if (meth == NULL) meth = s->method->get_ssl_method(session->ssl_version); if (meth == NULL) { SSLerr(SSL_F_SSL_SET_SESSION, SSL_R_UNABLE_TO_FIND_SSL_METHOD); return (0); } if (meth != s->method) { if (!SSL_set_ssl_method(s, meth)) return (0); } /* CRYPTO_w_lock(CRYPTO_LOCK_SSL);*/ CRYPTO_add(&session->references, 1, CRYPTO_LOCK_SSL_SESSION); if (s->session != NULL) SSL_SESSION_free(s->session); s->session = session; s->verify_result = s->session->verify_result; /* CRYPTO_w_unlock(CRYPTO_LOCK_SSL);*/ ret = 1; } else { if (s->session != NULL) { SSL_SESSION_free(s->session); s->session = NULL; } meth = s->ctx->method; if (meth != s->method) { if (!SSL_set_ssl_method(s, meth)) return (0); } ret = 1; } return (ret); } long SSL_SESSION_set_timeout(SSL_SESSION *s, long t) { if (s == NULL) return (0); s->timeout = t; return (1); } long SSL_SESSION_get_timeout(const SSL_SESSION *s) { if (s == NULL) return (0); return (s->timeout); } /* XXX 2038 */ long SSL_SESSION_get_time(const SSL_SESSION *s) { if (s == NULL) return (0); return (s->time); } /* XXX 2038 */ long SSL_SESSION_set_time(SSL_SESSION *s, long t) { if (s == NULL) return (0); s->time = t; return (t); } X509 * SSL_SESSION_get0_peer(SSL_SESSION *s) { return s->peer; } int SSL_SESSION_set1_id_context(SSL_SESSION *s, const unsigned char *sid_ctx, unsigned int sid_ctx_len) { if (sid_ctx_len > SSL_MAX_SID_CTX_LENGTH) { SSLerr(SSL_F_SSL_SESSION_SET1_ID_CONTEXT, SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG); return 0; } s->sid_ctx_length = sid_ctx_len; memcpy(s->sid_ctx, sid_ctx, sid_ctx_len); return 1; } long SSL_CTX_set_timeout(SSL_CTX *s, long t) { long l; if (s == NULL) return (0); l = s->session_timeout; s->session_timeout = t; return (l); } long SSL_CTX_get_timeout(const SSL_CTX *s) { if (s == NULL) return (0); return (s->session_timeout); } int SSL_set_session_secret_cb(SSL *s, int (*tls_session_secret_cb)(SSL *s, void *secret, int *secret_len, STACK_OF(SSL_CIPHER) *peer_ciphers, SSL_CIPHER **cipher, void *arg), void *arg) { if (s == NULL) return (0); s->tls_session_secret_cb = tls_session_secret_cb; s->tls_session_secret_cb_arg = arg; return (1); } int SSL_set_session_ticket_ext_cb(SSL *s, tls_session_ticket_ext_cb_fn cb, void *arg) { if (s == NULL) return (0); s->tls_session_ticket_ext_cb = cb; s->tls_session_ticket_ext_cb_arg = arg; return (1); } int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len) { if (s->version >= TLS1_VERSION) { free(s->tlsext_session_ticket); s->tlsext_session_ticket = malloc(sizeof(TLS_SESSION_TICKET_EXT) + ext_len); if (!s->tlsext_session_ticket) { SSLerr(SSL_F_SSL_SET_SESSION_TICKET_EXT, ERR_R_MALLOC_FAILURE); return 0; } if (ext_data) { s->tlsext_session_ticket->length = ext_len; s->tlsext_session_ticket->data = s->tlsext_session_ticket + 1; memcpy(s->tlsext_session_ticket->data, ext_data, ext_len); } else { s->tlsext_session_ticket->length = 0; s->tlsext_session_ticket->data = NULL; } return 1; } return 0; } typedef struct timeout_param_st { SSL_CTX *ctx; long time; LHASH_OF(SSL_SESSION) *cache; } TIMEOUT_PARAM; static void timeout_doall_arg(SSL_SESSION *s, TIMEOUT_PARAM *p) { if ((p->time == 0) || (p->time > (s->time + s->timeout))) /* timeout */ { /* The reason we don't call SSL_CTX_remove_session() is to * save on locking overhead */ (void)lh_SSL_SESSION_delete(p->cache, s); SSL_SESSION_list_remove(p->ctx, s); s->not_resumable = 1; if (p->ctx->remove_session_cb != NULL) p->ctx->remove_session_cb(p->ctx, s); SSL_SESSION_free(s); } } static IMPLEMENT_LHASH_DOALL_ARG_FN(timeout, SSL_SESSION, TIMEOUT_PARAM) /* XXX 2038 */ void SSL_CTX_flush_sessions(SSL_CTX *s, long t) { unsigned long i; TIMEOUT_PARAM tp; tp.ctx = s; tp.cache = s->sessions; if (tp.cache == NULL) return; tp.time = t; CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); i = CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load; CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load = 0; lh_SSL_SESSION_doall_arg(tp.cache, LHASH_DOALL_ARG_FN(timeout), TIMEOUT_PARAM, &tp); CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load = i; CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); } int ssl_clear_bad_session(SSL *s) { if ((s->session != NULL) && !(s->shutdown & SSL_SENT_SHUTDOWN) && !(SSL_in_init(s) || SSL_in_before(s))) { SSL_CTX_remove_session(s->ctx, s->session); return (1); } else return (0); } /* locked by SSL_CTX in the calling function */ static void SSL_SESSION_list_remove(SSL_CTX *ctx, SSL_SESSION *s) { if ((s->next == NULL) || (s->prev == NULL)) return; if (s->next == (SSL_SESSION *)&(ctx->session_cache_tail)) { /* last element in list */ if (s->prev == (SSL_SESSION *)&(ctx->session_cache_head)) { /* only one element in list */ ctx->session_cache_head = NULL; ctx->session_cache_tail = NULL; } else { ctx->session_cache_tail = s->prev; s->prev->next = (SSL_SESSION *)&(ctx->session_cache_tail); } } else { if (s->prev == (SSL_SESSION *)&(ctx->session_cache_head)) { /* first element in list */ ctx->session_cache_head = s->next; s->next->prev = (SSL_SESSION *)&(ctx->session_cache_head); } else { /* middle of list */ s->next->prev = s->prev; s->prev->next = s->next; } } s->prev = s->next = NULL; } static void SSL_SESSION_list_add(SSL_CTX *ctx, SSL_SESSION *s) { if ((s->next != NULL) && (s->prev != NULL)) SSL_SESSION_list_remove(ctx, s); if (ctx->session_cache_head == NULL) { ctx->session_cache_head = s; ctx->session_cache_tail = s; s->prev = (SSL_SESSION *)&(ctx->session_cache_head); s->next = (SSL_SESSION *)&(ctx->session_cache_tail); } else { s->next = ctx->session_cache_head; s->next->prev = s; s->prev = (SSL_SESSION *)&(ctx->session_cache_head); ctx->session_cache_head = s; } } void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx, int (*cb)(struct ssl_st *ssl, SSL_SESSION *sess)) { ctx->new_session_cb = cb; } int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))(SSL *ssl, SSL_SESSION *sess) { return ctx->new_session_cb; } void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx, void (*cb)(SSL_CTX *ctx, SSL_SESSION *sess)) { ctx->remove_session_cb = cb; } void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))(SSL_CTX * ctx, SSL_SESSION *sess) { return ctx->remove_session_cb; } void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx, SSL_SESSION *(*cb)(struct ssl_st *ssl, unsigned char *data, int len, int *copy)) { ctx->get_session_cb = cb; } SSL_SESSION * (*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(SSL *ssl, unsigned char *data, int len, int *copy) { return ctx->get_session_cb; } void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*cb)(const SSL *ssl, int type, int val)) { ctx->info_callback = cb; } void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(const SSL *ssl, int type, int val) { return ctx->info_callback; } void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, int (*cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey)) { ctx->client_cert_cb = cb; } int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL * ssl, X509 ** x509 , EVP_PKEY **pkey) { return ctx->client_cert_cb; } #ifndef OPENSSL_NO_ENGINE int SSL_CTX_set_client_cert_engine(SSL_CTX *ctx, ENGINE *e) { if (!ENGINE_init(e)) { SSLerr(SSL_F_SSL_CTX_SET_CLIENT_CERT_ENGINE, ERR_R_ENGINE_LIB); return 0; } if (!ENGINE_get_ssl_client_cert_function(e)) { SSLerr(SSL_F_SSL_CTX_SET_CLIENT_CERT_ENGINE, SSL_R_NO_CLIENT_CERT_METHOD); ENGINE_finish(e); return 0; } ctx->client_cert_engine = e; return 1; } #endif void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx, int (*cb)(SSL *ssl, unsigned char *cookie, unsigned int *cookie_len)) { ctx->app_gen_cookie_cb = cb; } void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx, int (*cb)(SSL *ssl, unsigned char *cookie, unsigned int cookie_len)) { ctx->app_verify_cookie_cb = cb; } IMPLEMENT_PEM_rw(SSL_SESSION, SSL_SESSION, PEM_STRING_SSL_SESSION, SSL_SESSION) deps/libressl-pnacl-sys-2.1.6/libressl/ssl/ssl_asn1.c0000644000175000017500000003323112360020705017425 0ustar /* $OpenBSD: ssl_asn1.c,v 1.28 2014/07/11 09:24:44 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright 2005 Nokia. All rights reserved. * * The portions of the attached software ("Contribution") is developed by * Nokia Corporation and is licensed pursuant to the OpenSSL open source * license. * * The Contribution, originally written by Mika Kousa and Pasi Eronen of * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites * support (see RFC 4279) to OpenSSL. * * No patent licenses or other rights except those expressly stated in * the OpenSSL open source license shall be deemed granted or received * expressly, by implication, estoppel, or otherwise. * * No assurances are provided by Nokia that the Contribution does not * infringe the patent or other intellectual property rights of any third * party or that the license provides you with all the necessary rights * to make use of the Contribution. * * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR * OTHERWISE. */ #include #include #include "ssl_locl.h" #include #include #include typedef struct ssl_session_asn1_st { ASN1_INTEGER version; ASN1_INTEGER ssl_version; ASN1_OCTET_STRING cipher; ASN1_OCTET_STRING comp_id; ASN1_OCTET_STRING master_key; ASN1_OCTET_STRING session_id; ASN1_OCTET_STRING session_id_context; ASN1_INTEGER time; ASN1_INTEGER timeout; ASN1_INTEGER verify_result; ASN1_OCTET_STRING tlsext_hostname; ASN1_INTEGER tlsext_tick_lifetime; ASN1_OCTET_STRING tlsext_tick; } SSL_SESSION_ASN1; int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) { #define LSIZE2 (sizeof(long)*2) int v1 = 0, v2 = 0, v3 = 0, v4 = 0, v5 = 0; unsigned char buf[4], ibuf1[LSIZE2], ibuf2[LSIZE2]; unsigned char ibuf3[LSIZE2], ibuf4[LSIZE2], ibuf5[LSIZE2]; int v6 = 0, v9 = 0, v10 = 0; unsigned char ibuf6[LSIZE2]; long l; SSL_SESSION_ASN1 a; M_ASN1_I2D_vars(in); if ((in == NULL) || ((in->cipher == NULL) && (in->cipher_id == 0))) return (0); /* Note that I cheat in the following 2 assignments. I know * that if the ASN1_INTEGER passed to ASN1_INTEGER_set * is > sizeof(long)+1, the buffer will not be re-malloc()ed. * This is a bit evil but makes things simple, no dynamic allocation * to clean up :-) */ a.version.length = LSIZE2; a.version.type = V_ASN1_INTEGER; a.version.data = ibuf1; ASN1_INTEGER_set(&(a.version), SSL_SESSION_ASN1_VERSION); a.ssl_version.length = LSIZE2; a.ssl_version.type = V_ASN1_INTEGER; a.ssl_version.data = ibuf2; ASN1_INTEGER_set(&(a.ssl_version), in->ssl_version); a.cipher.type = V_ASN1_OCTET_STRING; a.cipher.data = buf; if (in->cipher == NULL) l = in->cipher_id; else l = in->cipher->id; a.cipher.length = 2; buf[0] = ((unsigned char)(l >> 8L))&0xff; buf[1] = ((unsigned char)(l ))&0xff; a.master_key.length = in->master_key_length; a.master_key.type = V_ASN1_OCTET_STRING; a.master_key.data = in->master_key; a.session_id.length = in->session_id_length; a.session_id.type = V_ASN1_OCTET_STRING; a.session_id.data = in->session_id; a.session_id_context.length = in->sid_ctx_length; a.session_id_context.type = V_ASN1_OCTET_STRING; a.session_id_context.data = in->sid_ctx; if (in->time != 0L) { a.time.length = LSIZE2; a.time.type = V_ASN1_INTEGER; a.time.data = ibuf3; ASN1_INTEGER_set(&(a.time), in->time); /* XXX 2038 */ } if (in->timeout != 0L) { a.timeout.length = LSIZE2; a.timeout.type = V_ASN1_INTEGER; a.timeout.data = ibuf4; ASN1_INTEGER_set(&(a.timeout), in->timeout); } if (in->verify_result != X509_V_OK) { a.verify_result.length = LSIZE2; a.verify_result.type = V_ASN1_INTEGER; a.verify_result.data = ibuf5; ASN1_INTEGER_set(&a.verify_result, in->verify_result); } if (in->tlsext_hostname) { a.tlsext_hostname.length = strlen(in->tlsext_hostname); a.tlsext_hostname.type = V_ASN1_OCTET_STRING; a.tlsext_hostname.data = (unsigned char *)in->tlsext_hostname; } if (in->tlsext_tick) { a.tlsext_tick.length = in->tlsext_ticklen; a.tlsext_tick.type = V_ASN1_OCTET_STRING; a.tlsext_tick.data = (unsigned char *)in->tlsext_tick; } if (in->tlsext_tick_lifetime_hint > 0) { a.tlsext_tick_lifetime.length = LSIZE2; a.tlsext_tick_lifetime.type = V_ASN1_INTEGER; a.tlsext_tick_lifetime.data = ibuf6; ASN1_INTEGER_set(&a.tlsext_tick_lifetime, in->tlsext_tick_lifetime_hint); } M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER); M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER); M_ASN1_I2D_len(&(a.cipher), i2d_ASN1_OCTET_STRING); M_ASN1_I2D_len(&(a.session_id), i2d_ASN1_OCTET_STRING); M_ASN1_I2D_len(&(a.master_key), i2d_ASN1_OCTET_STRING); if (in->time != 0L) M_ASN1_I2D_len_EXP_opt(&(a.time), i2d_ASN1_INTEGER, 1, v1); if (in->timeout != 0L) M_ASN1_I2D_len_EXP_opt(&(a.timeout), i2d_ASN1_INTEGER, 2, v2); if (in->peer != NULL) M_ASN1_I2D_len_EXP_opt(in->peer, i2d_X509, 3, v3); M_ASN1_I2D_len_EXP_opt(&a.session_id_context, i2d_ASN1_OCTET_STRING, 4, v4); if (in->verify_result != X509_V_OK) M_ASN1_I2D_len_EXP_opt(&(a.verify_result), i2d_ASN1_INTEGER, 5, v5); if (in->tlsext_tick_lifetime_hint > 0) M_ASN1_I2D_len_EXP_opt(&a.tlsext_tick_lifetime, i2d_ASN1_INTEGER, 9, v9); if (in->tlsext_tick) M_ASN1_I2D_len_EXP_opt(&(a.tlsext_tick), i2d_ASN1_OCTET_STRING, 10, v10); if (in->tlsext_hostname) M_ASN1_I2D_len_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRING, 6, v6); M_ASN1_I2D_seq_total(); M_ASN1_I2D_put(&(a.version), i2d_ASN1_INTEGER); M_ASN1_I2D_put(&(a.ssl_version), i2d_ASN1_INTEGER); M_ASN1_I2D_put(&(a.cipher), i2d_ASN1_OCTET_STRING); M_ASN1_I2D_put(&(a.session_id), i2d_ASN1_OCTET_STRING); M_ASN1_I2D_put(&(a.master_key), i2d_ASN1_OCTET_STRING); if (in->time != 0L) M_ASN1_I2D_put_EXP_opt(&(a.time), i2d_ASN1_INTEGER, 1, v1); if (in->timeout != 0L) M_ASN1_I2D_put_EXP_opt(&(a.timeout), i2d_ASN1_INTEGER, 2, v2); if (in->peer != NULL) M_ASN1_I2D_put_EXP_opt(in->peer, i2d_X509, 3, v3); M_ASN1_I2D_put_EXP_opt(&a.session_id_context, i2d_ASN1_OCTET_STRING, 4, v4); if (in->verify_result != X509_V_OK) M_ASN1_I2D_put_EXP_opt(&a.verify_result, i2d_ASN1_INTEGER, 5, v5); if (in->tlsext_hostname) M_ASN1_I2D_put_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRING, 6, v6); if (in->tlsext_tick_lifetime_hint > 0) M_ASN1_I2D_put_EXP_opt(&a.tlsext_tick_lifetime, i2d_ASN1_INTEGER, 9, v9); if (in->tlsext_tick) M_ASN1_I2D_put_EXP_opt(&(a.tlsext_tick), i2d_ASN1_OCTET_STRING, 10, v10); M_ASN1_I2D_finish(); } SSL_SESSION * d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, long length) { int ssl_version = 0, i; long id; ASN1_INTEGER ai, *aip; ASN1_OCTET_STRING os, *osp; M_ASN1_D2I_vars(a, SSL_SESSION *, SSL_SESSION_new); aip = &ai; osp = &os; M_ASN1_D2I_Init(); M_ASN1_D2I_start_sequence(); ai.data = NULL; ai.length = 0; M_ASN1_D2I_get_x(ASN1_INTEGER, aip, d2i_ASN1_INTEGER); if (ai.data != NULL) { free(ai.data); ai.data = NULL; ai.length = 0; } /* we don't care about the version right now :-) */ M_ASN1_D2I_get_x(ASN1_INTEGER, aip, d2i_ASN1_INTEGER); ssl_version = (int)ASN1_INTEGER_get(aip); ret->ssl_version = ssl_version; if (ai.data != NULL) { free(ai.data); ai.data = NULL; ai.length = 0; } os.data = NULL; os.length = 0; M_ASN1_D2I_get_x(ASN1_OCTET_STRING, osp, d2i_ASN1_OCTET_STRING); if ((ssl_version >> 8) >= SSL3_VERSION_MAJOR) { if (os.length != 2) { c.error = SSL_R_CIPHER_CODE_WRONG_LENGTH; c.line = __LINE__; goto err; } id = 0x03000000L| ((unsigned long)os.data[0]<<8L)| (unsigned long)os.data[1]; } else { c.error = SSL_R_UNKNOWN_SSL_VERSION; c.line = __LINE__; goto err; } ret->cipher = NULL; ret->cipher_id = id; M_ASN1_D2I_get_x(ASN1_OCTET_STRING, osp, d2i_ASN1_OCTET_STRING); i = SSL3_MAX_SSL_SESSION_ID_LENGTH; if (os.length > i) os.length = i; if (os.length > (int)sizeof(ret->session_id)) /* can't happen */ os.length = sizeof(ret->session_id); ret->session_id_length = os.length; OPENSSL_assert(os.length <= (int)sizeof(ret->session_id)); memcpy(ret->session_id, os.data, os.length); M_ASN1_D2I_get_x(ASN1_OCTET_STRING, osp, d2i_ASN1_OCTET_STRING); if (os.length > SSL_MAX_MASTER_KEY_LENGTH) ret->master_key_length = SSL_MAX_MASTER_KEY_LENGTH; else ret->master_key_length = os.length; memcpy(ret->master_key, os.data, ret->master_key_length); os.length = 0; ai.length = 0; M_ASN1_D2I_get_EXP_opt(aip, d2i_ASN1_INTEGER, 1); /* XXX 2038 */ if (ai.data != NULL) { ret->time = ASN1_INTEGER_get(aip); free(ai.data); ai.data = NULL; ai.length = 0; } else ret->time = time(NULL); ai.length = 0; M_ASN1_D2I_get_EXP_opt(aip, d2i_ASN1_INTEGER, 2); if (ai.data != NULL) { ret->timeout = ASN1_INTEGER_get(aip); free(ai.data); ai.data = NULL; ai.length = 0; } else ret->timeout = 3; if (ret->peer != NULL) { X509_free(ret->peer); ret->peer = NULL; } M_ASN1_D2I_get_EXP_opt(ret->peer, d2i_X509, 3); os.length = 0; os.data = NULL; M_ASN1_D2I_get_EXP_opt(osp, d2i_ASN1_OCTET_STRING, 4); if (os.data != NULL) { if (os.length > SSL_MAX_SID_CTX_LENGTH) { c.error = SSL_R_BAD_LENGTH; c.line = __LINE__; goto err; } else { ret->sid_ctx_length = os.length; memcpy(ret->sid_ctx, os.data, os.length); } free(os.data); os.data = NULL; os.length = 0; } else ret->sid_ctx_length = 0; ai.length = 0; M_ASN1_D2I_get_EXP_opt(aip, d2i_ASN1_INTEGER, 5); if (ai.data != NULL) { ret->verify_result = ASN1_INTEGER_get(aip); free(ai.data); ai.data = NULL; ai.length = 0; } else ret->verify_result = X509_V_OK; os.length = 0; os.data = NULL; M_ASN1_D2I_get_EXP_opt(osp, d2i_ASN1_OCTET_STRING, 6); if (os.data) { ret->tlsext_hostname = BUF_strndup((char *)os.data, os.length); free(os.data); os.data = NULL; os.length = 0; } else ret->tlsext_hostname = NULL; ai.length = 0; M_ASN1_D2I_get_EXP_opt(aip, d2i_ASN1_INTEGER, 9); if (ai.data != NULL) { ret->tlsext_tick_lifetime_hint = ASN1_INTEGER_get(aip); free(ai.data); ai.data = NULL; ai.length = 0; } else if (ret->tlsext_ticklen && ret->session_id_length) ret->tlsext_tick_lifetime_hint = -1; else ret->tlsext_tick_lifetime_hint = 0; os.length = 0; os.data = NULL; M_ASN1_D2I_get_EXP_opt(osp, d2i_ASN1_OCTET_STRING, 10); if (os.data) { ret->tlsext_tick = os.data; ret->tlsext_ticklen = os.length; os.data = NULL; os.length = 0; } else ret->tlsext_tick = NULL; M_ASN1_D2I_Finish(a, SSL_SESSION_free, SSL_F_D2I_SSL_SESSION); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/s3_meth.c0000644000175000017500000001067612360020705017254 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include "ssl_locl.h" static const SSL_METHOD *ssl3_get_method(int ver); const SSL_METHOD SSLv3_method_data = { .version = SSL3_VERSION, .ssl_new = ssl3_new, .ssl_clear = ssl3_clear, .ssl_free = ssl3_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl3_connect, .ssl_read = ssl3_read, .ssl_peek = ssl3_peek, .ssl_write = ssl3_write, .ssl_shutdown = ssl3_shutdown, .ssl_renegotiate = ssl3_renegotiate, .ssl_renegotiate_check = ssl3_renegotiate_check, .ssl_get_message = ssl3_get_message, .ssl_read_bytes = ssl3_read_bytes, .ssl_write_bytes = ssl3_write_bytes, .ssl_dispatch_alert = ssl3_dispatch_alert, .ssl_ctrl = ssl3_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl3_put_cipher_by_char, .ssl_pending = ssl3_pending, .num_ciphers = ssl3_num_ciphers, .get_cipher = ssl3_get_cipher, .get_ssl_method = ssl3_get_method, .get_timeout = ssl3_default_timeout, .ssl3_enc = &SSLv3_enc_data, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD * SSLv3_method(void) { return &SSLv3_method_data; } static const SSL_METHOD * ssl3_get_method(int ver) { if (ver == SSL3_VERSION) return (SSLv3_method()); return (NULL); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/s23_meth.c0000644000175000017500000001127012360020705017325 0ustar /* $OpenBSD: s23_meth.c,v 1.13 2014/06/12 15:49:31 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include "ssl_locl.h" static const SSL_METHOD *ssl23_get_method(int ver); const SSL_METHOD SSLv23_method_data = { .version = TLS1_2_VERSION, .ssl_new = tls1_new, .ssl_clear = tls1_clear, .ssl_free = tls1_free, .ssl_accept = ssl23_accept, .ssl_connect = ssl23_connect, .ssl_read = ssl23_read, .ssl_peek = ssl23_peek, .ssl_write = ssl23_write, .ssl_shutdown = ssl_undefined_function, .ssl_renegotiate = ssl_undefined_function, .ssl_renegotiate_check = ssl_ok, .ssl_get_message = ssl3_get_message, .ssl_read_bytes = ssl3_read_bytes, .ssl_write_bytes = ssl3_write_bytes, .ssl_dispatch_alert = ssl3_dispatch_alert, .ssl_ctrl = ssl3_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl23_put_cipher_by_char, .ssl_pending = ssl_undefined_const_function, .num_ciphers = ssl3_num_ciphers, .get_cipher = ssl3_get_cipher, .get_ssl_method = ssl23_get_method, .get_timeout = ssl23_default_timeout, .ssl3_enc = &ssl3_undef_enc_method, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD * SSLv23_method(void) { return &SSLv23_method_data; } static const SSL_METHOD * ssl23_get_method(int ver) { if (ver == SSL3_VERSION) return (SSLv3_method()); if (ver == TLS1_VERSION) return (TLSv1_method()); if (ver == TLS1_1_VERSION) return (TLSv1_1_method()); if (ver == TLS1_2_VERSION) return (TLSv1_2_method()); return (NULL); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/d1_clnt.c0000644000175000017500000011075512360020705017235 0ustar /* $OpenBSD: d1_clnt.c,v 1.27 2014/07/10 08:51:14 tedu Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "ssl_locl.h" #include #include #include #include #include #include #include static const SSL_METHOD *dtls1_get_client_method(int ver); static int dtls1_get_hello_verify(SSL *s); const SSL_METHOD DTLSv1_client_method_data = { .version = DTLS1_VERSION, .ssl_new = dtls1_new, .ssl_clear = dtls1_clear, .ssl_free = dtls1_free, .ssl_accept = ssl_undefined_function, .ssl_connect = dtls1_connect, .ssl_read = ssl3_read, .ssl_peek = ssl3_peek, .ssl_write = ssl3_write, .ssl_shutdown = dtls1_shutdown, .ssl_renegotiate = ssl3_renegotiate, .ssl_renegotiate_check = ssl3_renegotiate_check, .ssl_get_message = dtls1_get_message, .ssl_read_bytes = dtls1_read_bytes, .ssl_write_bytes = dtls1_write_app_data_bytes, .ssl_dispatch_alert = dtls1_dispatch_alert, .ssl_ctrl = dtls1_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl3_put_cipher_by_char, .ssl_pending = ssl3_pending, .num_ciphers = ssl3_num_ciphers, .get_cipher = dtls1_get_cipher, .get_ssl_method = dtls1_get_client_method, .get_timeout = dtls1_default_timeout, .ssl3_enc = &DTLSv1_enc_data, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD * DTLSv1_client_method(void) { return &DTLSv1_client_method_data; } static const SSL_METHOD * dtls1_get_client_method(int ver) { if (ver == DTLS1_VERSION || ver == DTLS1_BAD_VER) return (DTLSv1_client_method()); return (NULL); } int dtls1_connect(SSL *s) { BUF_MEM *buf = NULL; void (*cb)(const SSL *ssl, int type, int val) = NULL; int ret = -1; int new_state, state, skip = 0; #ifndef OPENSSL_NO_SCTP unsigned char sctpauthkey[64]; char labelbuffer[sizeof(DTLS1_SCTP_AUTH_LABEL)]; #endif ERR_clear_error(); errno = 0; if (s->info_callback != NULL) cb = s->info_callback; else if (s->ctx->info_callback != NULL) cb = s->ctx->info_callback; s->in_handshake++; if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); #ifndef OPENSSL_NO_SCTP /* Notify SCTP BIO socket to enter handshake * mode and prevent stream identifier other * than 0. Will be ignored if no SCTP is used. */ BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE, s->in_handshake, NULL); #endif for (;;) { state = s->state; switch (s->state) { case SSL_ST_RENEGOTIATE: s->renegotiate = 1; s->state = SSL_ST_CONNECT; s->ctx->stats.sess_connect_renegotiate++; /* break */ case SSL_ST_BEFORE: case SSL_ST_CONNECT: case SSL_ST_BEFORE|SSL_ST_CONNECT: case SSL_ST_OK|SSL_ST_CONNECT: s->server = 0; if (cb != NULL) cb(s, SSL_CB_HANDSHAKE_START, 1); if ((s->version & 0xff00 ) != (DTLS1_VERSION & 0xff00) && (s->version & 0xff00 ) != (DTLS1_BAD_VER & 0xff00)) { SSLerr(SSL_F_DTLS1_CONNECT, ERR_R_INTERNAL_ERROR); ret = -1; goto end; } /* s->version=SSL3_VERSION; */ s->type = SSL_ST_CONNECT; if (s->init_buf == NULL) { if ((buf = BUF_MEM_new()) == NULL) { ret = -1; goto end; } if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { ret = -1; goto end; } s->init_buf = buf; buf = NULL; } if (!ssl3_setup_buffers(s)) { ret = -1; goto end; } /* setup buffing BIO */ if (!ssl_init_wbio_buffer(s, 0)) { ret = -1; goto end; } /* don't push the buffering BIO quite yet */ s->state = SSL3_ST_CW_CLNT_HELLO_A; s->ctx->stats.sess_connect++; s->init_num = 0; /* mark client_random uninitialized */ memset(s->s3->client_random, 0, sizeof(s->s3->client_random)); s->d1->send_cookie = 0; s->hit = 0; break; #ifndef OPENSSL_NO_SCTP case DTLS1_SCTP_ST_CR_READ_SOCK: if (BIO_dgram_sctp_msg_waiting(SSL_get_rbio(s))) { s->s3->in_read_app_data = 2; s->rwstate = SSL_READING; BIO_clear_retry_flags(SSL_get_rbio(s)); BIO_set_retry_read(SSL_get_rbio(s)); ret = -1; goto end; } s->state = s->s3->tmp.next_state; break; case DTLS1_SCTP_ST_CW_WRITE_SOCK: /* read app data until dry event */ ret = BIO_dgram_sctp_wait_for_dry(SSL_get_wbio(s)); if (ret < 0) goto end; if (ret == 0) { s->s3->in_read_app_data = 2; s->rwstate = SSL_READING; BIO_clear_retry_flags(SSL_get_rbio(s)); BIO_set_retry_read(SSL_get_rbio(s)); ret = -1; goto end; } s->state = s->d1->next_state; break; #endif case SSL3_ST_CW_CLNT_HELLO_A: case SSL3_ST_CW_CLNT_HELLO_B: s->shutdown = 0; /* every DTLS ClientHello resets Finished MAC */ ssl3_init_finished_mac(s); dtls1_start_timer(s); ret = dtls1_client_hello(s); if (ret <= 0) goto end; if (s->d1->send_cookie) { s->state = SSL3_ST_CW_FLUSH; s->s3->tmp.next_state = SSL3_ST_CR_SRVR_HELLO_A; } else s->state = SSL3_ST_CR_SRVR_HELLO_A; s->init_num = 0; #ifndef OPENSSL_NO_SCTP /* Disable buffering for SCTP */ if (!BIO_dgram_is_sctp(SSL_get_wbio(s))) { #endif /* turn on buffering for the next lot of output */ if (s->bbio != s->wbio) s->wbio = BIO_push(s->bbio, s->wbio); #ifndef OPENSSL_NO_SCTP } #endif break; case SSL3_ST_CR_SRVR_HELLO_A: case SSL3_ST_CR_SRVR_HELLO_B: ret = ssl3_get_server_hello(s); if (ret <= 0) goto end; else { if (s->hit) { #ifndef OPENSSL_NO_SCTP /* Add new shared key for SCTP-Auth, * will be ignored if no SCTP used. */ snprintf((char*) labelbuffer, sizeof(DTLS1_SCTP_AUTH_LABEL), DTLS1_SCTP_AUTH_LABEL); SSL_export_keying_material(s, sctpauthkey, sizeof(sctpauthkey), labelbuffer, sizeof(labelbuffer), NULL, 0, 0); BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY, sizeof(sctpauthkey), sctpauthkey); #endif s->state = SSL3_ST_CR_FINISHED_A; } else s->state = DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A; } s->init_num = 0; break; case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A: case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B: ret = dtls1_get_hello_verify(s); if (ret <= 0) goto end; dtls1_stop_timer(s); if ( s->d1->send_cookie) /* start again, with a cookie */ s->state = SSL3_ST_CW_CLNT_HELLO_A; else s->state = SSL3_ST_CR_CERT_A; s->init_num = 0; break; case SSL3_ST_CR_CERT_A: case SSL3_ST_CR_CERT_B: ret = ssl3_check_finished(s); if (ret <= 0) goto end; if (ret == 2) { s->hit = 1; if (s->tlsext_ticket_expected) s->state = SSL3_ST_CR_SESSION_TICKET_A; else s->state = SSL3_ST_CR_FINISHED_A; s->init_num = 0; break; } /* Check if it is anon DH or PSK */ if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { ret = ssl3_get_server_certificate(s); if (ret <= 0) goto end; if (s->tlsext_status_expected) s->state = SSL3_ST_CR_CERT_STATUS_A; else s->state = SSL3_ST_CR_KEY_EXCH_A; } else { skip = 1; s->state = SSL3_ST_CR_KEY_EXCH_A; } s->init_num = 0; break; case SSL3_ST_CR_KEY_EXCH_A: case SSL3_ST_CR_KEY_EXCH_B: ret = ssl3_get_key_exchange(s); if (ret <= 0) goto end; s->state = SSL3_ST_CR_CERT_REQ_A; s->init_num = 0; /* at this point we check that we have the * required stuff from the server */ if (!ssl3_check_cert_and_algorithm(s)) { ret = -1; goto end; } break; case SSL3_ST_CR_CERT_REQ_A: case SSL3_ST_CR_CERT_REQ_B: ret = ssl3_get_certificate_request(s); if (ret <= 0) goto end; s->state = SSL3_ST_CR_SRVR_DONE_A; s->init_num = 0; break; case SSL3_ST_CR_SRVR_DONE_A: case SSL3_ST_CR_SRVR_DONE_B: ret = ssl3_get_server_done(s); if (ret <= 0) goto end; dtls1_stop_timer(s); if (s->s3->tmp.cert_req) s->s3->tmp.next_state = SSL3_ST_CW_CERT_A; else s->s3->tmp.next_state = SSL3_ST_CW_KEY_EXCH_A; s->init_num = 0; #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s)) && state == SSL_ST_RENEGOTIATE) s->state = DTLS1_SCTP_ST_CR_READ_SOCK; else #endif s->state = s->s3->tmp.next_state; break; case SSL3_ST_CW_CERT_A: case SSL3_ST_CW_CERT_B: case SSL3_ST_CW_CERT_C: case SSL3_ST_CW_CERT_D: dtls1_start_timer(s); ret = dtls1_send_client_certificate(s); if (ret <= 0) goto end; s->state = SSL3_ST_CW_KEY_EXCH_A; s->init_num = 0; break; case SSL3_ST_CW_KEY_EXCH_A: case SSL3_ST_CW_KEY_EXCH_B: dtls1_start_timer(s); ret = dtls1_send_client_key_exchange(s); if (ret <= 0) goto end; #ifndef OPENSSL_NO_SCTP /* Add new shared key for SCTP-Auth, * will be ignored if no SCTP used. */ snprintf((char*)labelbuffer, sizeof(DTLS1_SCTP_AUTH_LABEL), DTLS1_SCTP_AUTH_LABEL); SSL_export_keying_material(s, sctpauthkey, sizeof(sctpauthkey), labelbuffer, sizeof(labelbuffer), NULL, 0, 0); BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY, sizeof(sctpauthkey), sctpauthkey); #endif /* EAY EAY EAY need to check for DH fix cert * sent back */ /* For TLS, cert_req is set to 2, so a cert chain * of nothing is sent, but no verify packet is sent */ if (s->s3->tmp.cert_req == 1) { s->state = SSL3_ST_CW_CERT_VRFY_A; } else { #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { s->d1->next_state = SSL3_ST_CW_CHANGE_A; s->state = DTLS1_SCTP_ST_CW_WRITE_SOCK; } else #endif s->state = SSL3_ST_CW_CHANGE_A; s->s3->change_cipher_spec = 0; } s->init_num = 0; break; case SSL3_ST_CW_CERT_VRFY_A: case SSL3_ST_CW_CERT_VRFY_B: dtls1_start_timer(s); ret = dtls1_send_client_verify(s); if (ret <= 0) goto end; #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { s->d1->next_state = SSL3_ST_CW_CHANGE_A; s->state = DTLS1_SCTP_ST_CW_WRITE_SOCK; } else #endif s->state = SSL3_ST_CW_CHANGE_A; s->init_num = 0; s->s3->change_cipher_spec = 0; break; case SSL3_ST_CW_CHANGE_A: case SSL3_ST_CW_CHANGE_B: if (!s->hit) dtls1_start_timer(s); ret = dtls1_send_change_cipher_spec(s, SSL3_ST_CW_CHANGE_A, SSL3_ST_CW_CHANGE_B); if (ret <= 0) goto end; s->state = SSL3_ST_CW_FINISHED_A; s->init_num = 0; s->session->cipher = s->s3->tmp.new_cipher; if (!s->method->ssl3_enc->setup_key_block(s)) { ret = -1; goto end; } if (!s->method->ssl3_enc->change_cipher_state(s, SSL3_CHANGE_CIPHER_CLIENT_WRITE)) { ret = -1; goto end; } #ifndef OPENSSL_NO_SCTP if (s->hit) { /* Change to new shared key of SCTP-Auth, * will be ignored if no SCTP used. */ BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL); } #endif dtls1_reset_seq_numbers(s, SSL3_CC_WRITE); break; case SSL3_ST_CW_FINISHED_A: case SSL3_ST_CW_FINISHED_B: if (!s->hit) dtls1_start_timer(s); ret = dtls1_send_finished(s, SSL3_ST_CW_FINISHED_A, SSL3_ST_CW_FINISHED_B, s->method->ssl3_enc->client_finished_label, s->method->ssl3_enc->client_finished_label_len); if (ret <= 0) goto end; s->state = SSL3_ST_CW_FLUSH; /* clear flags */ s->s3->flags&= ~SSL3_FLAGS_POP_BUFFER; if (s->hit) { s->s3->tmp.next_state = SSL_ST_OK; #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { s->d1->next_state = s->s3->tmp.next_state; s->s3->tmp.next_state = DTLS1_SCTP_ST_CW_WRITE_SOCK; } #endif if (s->s3->flags & SSL3_FLAGS_DELAY_CLIENT_FINISHED) { s->state = SSL_ST_OK; #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { s->d1->next_state = SSL_ST_OK; s->state = DTLS1_SCTP_ST_CW_WRITE_SOCK; } #endif s->s3->flags |= SSL3_FLAGS_POP_BUFFER; s->s3->delay_buf_pop_ret = 0; } } else { #ifndef OPENSSL_NO_SCTP /* Change to new shared key of SCTP-Auth, * will be ignored if no SCTP used. */ BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, 0, NULL); #endif /* Allow NewSessionTicket if ticket expected */ if (s->tlsext_ticket_expected) s->s3->tmp.next_state = SSL3_ST_CR_SESSION_TICKET_A; else s->s3->tmp.next_state = SSL3_ST_CR_FINISHED_A; } s->init_num = 0; break; case SSL3_ST_CR_SESSION_TICKET_A: case SSL3_ST_CR_SESSION_TICKET_B: ret = ssl3_get_new_session_ticket(s); if (ret <= 0) goto end; s->state = SSL3_ST_CR_FINISHED_A; s->init_num = 0; break; case SSL3_ST_CR_CERT_STATUS_A: case SSL3_ST_CR_CERT_STATUS_B: ret = ssl3_get_cert_status(s); if (ret <= 0) goto end; s->state = SSL3_ST_CR_KEY_EXCH_A; s->init_num = 0; break; case SSL3_ST_CR_FINISHED_A: case SSL3_ST_CR_FINISHED_B: s->d1->change_cipher_spec_ok = 1; ret = ssl3_get_finished(s, SSL3_ST_CR_FINISHED_A, SSL3_ST_CR_FINISHED_B); if (ret <= 0) goto end; dtls1_stop_timer(s); if (s->hit) s->state = SSL3_ST_CW_CHANGE_A; else s->state = SSL_ST_OK; #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s)) && state == SSL_ST_RENEGOTIATE) { s->d1->next_state = s->state; s->state = DTLS1_SCTP_ST_CW_WRITE_SOCK; } #endif s->init_num = 0; break; case SSL3_ST_CW_FLUSH: s->rwstate = SSL_WRITING; if (BIO_flush(s->wbio) <= 0) { /* If the write error was fatal, stop trying */ if (!BIO_should_retry(s->wbio)) { s->rwstate = SSL_NOTHING; s->state = s->s3->tmp.next_state; } ret = -1; goto end; } s->rwstate = SSL_NOTHING; s->state = s->s3->tmp.next_state; break; case SSL_ST_OK: /* clean a few things up */ ssl3_cleanup_key_block(s); /* If we are not 'joining' the last two packets, * remove the buffering now */ if (!(s->s3->flags & SSL3_FLAGS_POP_BUFFER)) ssl_free_wbio_buffer(s); /* else do it later in ssl3_write */ s->init_num = 0; s->renegotiate = 0; s->new_session = 0; ssl_update_cache(s, SSL_SESS_CACHE_CLIENT); if (s->hit) s->ctx->stats.sess_hit++; ret = 1; /* s->server=0; */ s->handshake_func = dtls1_connect; s->ctx->stats.sess_connect_good++; if (cb != NULL) cb(s, SSL_CB_HANDSHAKE_DONE, 1); /* done with handshaking */ s->d1->handshake_read_seq = 0; s->d1->next_handshake_write_seq = 0; goto end; /* break; */ default: SSLerr(SSL_F_DTLS1_CONNECT, SSL_R_UNKNOWN_STATE); ret = -1; goto end; /* break; */ } /* did we do anything */ if (!s->s3->tmp.reuse_message && !skip) { if (s->debug) { if ((ret = BIO_flush(s->wbio)) <= 0) goto end; } if ((cb != NULL) && (s->state != state)) { new_state = s->state; s->state = state; cb(s, SSL_CB_CONNECT_LOOP, 1); s->state = new_state; } } skip = 0; } end: s->in_handshake--; #ifndef OPENSSL_NO_SCTP /* Notify SCTP BIO socket to leave handshake * mode and allow stream identifier other * than 0. Will be ignored if no SCTP is used. */ BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE, s->in_handshake, NULL); #endif if (buf != NULL) BUF_MEM_free(buf); if (cb != NULL) cb(s, SSL_CB_CONNECT_EXIT, ret); return (ret); } int dtls1_client_hello(SSL *s) { unsigned char *buf; unsigned char *p, *d; unsigned int i; unsigned long l; buf = (unsigned char *)s->init_buf->data; if (s->state == SSL3_ST_CW_CLNT_HELLO_A) { SSL_SESSION *sess = s->session; if ((s->session == NULL) || (s->session->ssl_version != s->version) || (!sess->session_id_length && !sess->tlsext_tick) || (s->session->not_resumable)) { if (!ssl_get_new_session(s, 0)) goto err; } /* else use the pre-loaded session */ p = s->s3->client_random; /* if client_random is initialized, reuse it, we are * required to use same upon reply to HelloVerify */ for (i = 0; p[i]=='\0' && i < sizeof(s->s3->client_random); i++) ; if (i == sizeof(s->s3->client_random)) RAND_pseudo_bytes(p, sizeof(s->s3->client_random)); /* Do the message type and length last */ d = p = &(buf[DTLS1_HM_HEADER_LENGTH]); *(p++) = s->version >> 8; *(p++) = s->version&0xff; s->client_version = s->version; /* Random stuff */ memcpy(p, s->s3->client_random, SSL3_RANDOM_SIZE); p += SSL3_RANDOM_SIZE; /* Session ID */ if (s->new_session) i = 0; else i = s->session->session_id_length; *(p++) = i; if (i != 0) { if (i > sizeof s->session->session_id) { SSLerr(SSL_F_DTLS1_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } memcpy(p, s->session->session_id, i); p += i; } /* cookie stuff */ if (s->d1->cookie_len > sizeof(s->d1->cookie)) { SSLerr(SSL_F_DTLS1_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } *(p++) = s->d1->cookie_len; memcpy(p, s->d1->cookie, s->d1->cookie_len); p += s->d1->cookie_len; /* Ciphers supported */ i = ssl_cipher_list_to_bytes(s, SSL_get_ciphers(s), &(p[2]), 0); if (i == 0) { SSLerr(SSL_F_DTLS1_CLIENT_HELLO, SSL_R_NO_CIPHERS_AVAILABLE); goto err; } s2n(i, p); p += i; /* add in (no) COMPRESSION */ *(p++) = 1; *(p++) = 0; /* Add the NULL method */ if ((p = ssl_add_clienthello_tlsext(s, p, buf + SSL3_RT_MAX_PLAIN_LENGTH)) == NULL) { SSLerr(SSL_F_DTLS1_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } l = (p - d); d = buf; d = dtls1_set_message_header(s, d, SSL3_MT_CLIENT_HELLO, l, 0, l); s->state = SSL3_ST_CW_CLNT_HELLO_B; /* number of bytes to write */ s->init_num = p - buf; s->init_off = 0; /* buffer the message to handle re-xmits */ dtls1_buffer_message(s, 0); } /* SSL3_ST_CW_CLNT_HELLO_B */ return (dtls1_do_write(s, SSL3_RT_HANDSHAKE)); err: return (-1); } static int dtls1_get_hello_verify(SSL *s) { int n, al, ok = 0; unsigned char *data; unsigned int cookie_len; n = s->method->ssl_get_message(s, DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A, DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B, -1, s->max_cert_list, &ok); if (!ok) return ((int)n); if (s->s3->tmp.message_type != DTLS1_MT_HELLO_VERIFY_REQUEST) { s->d1->send_cookie = 0; s->s3->tmp.reuse_message = 1; return (1); } data = (unsigned char *)s->init_msg; if ((data[0] != (s->version >> 8)) || (data[1] != (s->version&0xff))) { SSLerr(SSL_F_DTLS1_GET_HELLO_VERIFY, SSL_R_WRONG_SSL_VERSION); s->version = (s->version & 0xff00) | data[1]; al = SSL_AD_PROTOCOL_VERSION; goto f_err; } data += 2; cookie_len = *(data++); if (cookie_len > sizeof(s->d1->cookie)) { al = SSL_AD_ILLEGAL_PARAMETER; goto f_err; } memcpy(s->d1->cookie, data, cookie_len); s->d1->cookie_len = cookie_len; s->d1->send_cookie = 1; return 1; f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); return -1; } int dtls1_send_client_key_exchange(SSL *s) { unsigned char *p, *d; int n; unsigned long alg_k; unsigned char *q; EVP_PKEY *pkey = NULL; EC_KEY *clnt_ecdh = NULL; const EC_POINT *srvr_ecpoint = NULL; EVP_PKEY *srvr_pub_pkey = NULL; unsigned char *encodedPoint = NULL; int encoded_pt_len = 0; BN_CTX * bn_ctx = NULL; if (s->state == SSL3_ST_CW_KEY_EXCH_A) { d = (unsigned char *)s->init_buf->data; p = &(d[DTLS1_HM_HEADER_LENGTH]); alg_k = s->s3->tmp.new_cipher->algorithm_mkey; if (alg_k & SSL_kRSA) { RSA *rsa; unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH]; if (s->session->sess_cert->peer_rsa_tmp != NULL) rsa = s->session->sess_cert->peer_rsa_tmp; else { pkey = X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509); if ((pkey == NULL) || (pkey->type != EVP_PKEY_RSA) || (pkey->pkey.rsa == NULL)) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } rsa = pkey->pkey.rsa; EVP_PKEY_free(pkey); } tmp_buf[0] = s->client_version >> 8; tmp_buf[1] = s->client_version&0xff; if (RAND_bytes(&(tmp_buf[2]), sizeof tmp_buf - 2) <= 0) goto err; s->session->master_key_length = sizeof tmp_buf; q = p; /* Fix buf for TLS and [incidentally] DTLS */ if (s->version > SSL3_VERSION) p += 2; n = RSA_public_encrypt(sizeof tmp_buf, tmp_buf, p, rsa, RSA_PKCS1_PADDING); if (n <= 0) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, SSL_R_BAD_RSA_ENCRYPT); goto err; } /* Fix buf for TLS and [incidentally] DTLS */ if (s->version > SSL3_VERSION) { s2n(n, q); n += 2; } s->session->master_key_length = s->method->ssl3_enc->generate_master_secret(s, s->session->master_key, tmp_buf, sizeof tmp_buf); OPENSSL_cleanse(tmp_buf, sizeof tmp_buf); } else if (alg_k & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) { DH *dh_srvr, *dh_clnt; if (s->session->sess_cert->peer_dh_tmp != NULL) dh_srvr = s->session->sess_cert->peer_dh_tmp; else { /* we get them from the cert */ ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, SSL_R_UNABLE_TO_FIND_DH_PARAMETERS); goto err; } /* generate a new random key */ if ((dh_clnt = DHparams_dup(dh_srvr)) == NULL) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB); goto err; } if (!DH_generate_key(dh_clnt)) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB); goto err; } /* use the 'p' output buffer for the DH key, but * make sure to clear it out afterwards */ n = DH_compute_key(p, dh_srvr->pub_key, dh_clnt); if (n <= 0) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB); goto err; } /* generate master key from the result */ s->session->master_key_length = s->method->ssl3_enc->generate_master_secret( s, s->session->master_key, p, n); /* clean up */ memset(p, 0, n); /* send off the data */ n = BN_num_bytes(dh_clnt->pub_key); s2n(n, p); BN_bn2bin(dh_clnt->pub_key, p); n += 2; DH_free(dh_clnt); /* perhaps clean things up a bit EAY EAY EAY EAY*/ } else if (alg_k & (SSL_kEECDH|SSL_kECDHr|SSL_kECDHe)) { const EC_GROUP *srvr_group = NULL; EC_KEY *tkey; int ecdh_clnt_cert = 0; int field_size = 0; /* Did we send out the client's * ECDH share for use in premaster * computation as part of client certificate? * If so, set ecdh_clnt_cert to 1. */ if ((alg_k & (SSL_kECDHr|SSL_kECDHe)) && (s->cert != NULL)) { /* XXX: For now, we do not support client * authentication using ECDH certificates. * To add such support, one needs to add * code that checks for appropriate * conditions and sets ecdh_clnt_cert to 1. * For example, the cert have an ECC * key on the same curve as the server's * and the key should be authorized for * key agreement. * * One also needs to add code in ssl3_connect * to skip sending the certificate verify * message. * * if ((s->cert->key->privatekey != NULL) && * (s->cert->key->privatekey->type == * EVP_PKEY_EC) && ...) * ecdh_clnt_cert = 1; */ } if (s->session->sess_cert->peer_ecdh_tmp != NULL) { tkey = s->session->sess_cert->peer_ecdh_tmp; } else { /* Get the Server Public Key from Cert */ srvr_pub_pkey = X509_get_pubkey(s->session-> \ sess_cert->peer_pkeys[SSL_PKEY_ECC].x509); if ((srvr_pub_pkey == NULL) || (srvr_pub_pkey->type != EVP_PKEY_EC) || (srvr_pub_pkey->pkey.ec == NULL)) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } tkey = srvr_pub_pkey->pkey.ec; } srvr_group = EC_KEY_get0_group(tkey); srvr_ecpoint = EC_KEY_get0_public_key(tkey); if ((srvr_group == NULL) || (srvr_ecpoint == NULL)) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } if ((clnt_ecdh = EC_KEY_new()) == NULL) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } if (!EC_KEY_set_group(clnt_ecdh, srvr_group)) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); goto err; } if (ecdh_clnt_cert) { /* Reuse key info from our certificate * We only need our private key to perform * the ECDH computation. */ const BIGNUM *priv_key; tkey = s->cert->key->privatekey->pkey.ec; priv_key = EC_KEY_get0_private_key(tkey); if (priv_key == NULL) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } if (!EC_KEY_set_private_key(clnt_ecdh, priv_key)) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); goto err; } } else { /* Generate a new ECDH key pair */ if (!(EC_KEY_generate_key(clnt_ecdh))) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } } /* use the 'p' output buffer for the ECDH key, but * make sure to clear it out afterwards */ field_size = EC_GROUP_get_degree(srvr_group); if (field_size <= 0) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } n = ECDH_compute_key(p, (field_size + 7)/8, srvr_ecpoint, clnt_ecdh, NULL); if (n <= 0) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } /* generate master key from the result */ s->session->master_key_length = s->method->ssl3_enc->generate_master_secret( s, s->session->master_key, p, n); memset(p, 0, n); /* clean up */ if (ecdh_clnt_cert) { /* Send empty client key exch message */ n = 0; } else { /* First check the size of encoding and * allocate memory accordingly. */ encoded_pt_len = EC_POINT_point2oct(srvr_group, EC_KEY_get0_public_key(clnt_ecdh), POINT_CONVERSION_UNCOMPRESSED, NULL, 0, NULL); encodedPoint = malloc(encoded_pt_len); bn_ctx = BN_CTX_new(); if ((encodedPoint == NULL) || (bn_ctx == NULL)) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } /* Encode the public key */ n = EC_POINT_point2oct(srvr_group, EC_KEY_get0_public_key(clnt_ecdh), POINT_CONVERSION_UNCOMPRESSED, encodedPoint, encoded_pt_len, bn_ctx); *p = n; /* length of encoded point */ /* Encoded point will be copied here */ p += 1; /* copy the point */ memcpy((unsigned char *)p, encodedPoint, n); /* increment n to account for length field */ n += 1; } /* Free allocated memory */ BN_CTX_free(bn_ctx); free(encodedPoint); EC_KEY_free(clnt_ecdh); EVP_PKEY_free(srvr_pub_pkey); } else { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } d = dtls1_set_message_header(s, d, SSL3_MT_CLIENT_KEY_EXCHANGE, n, 0, n); /* *(d++)=SSL3_MT_CLIENT_KEY_EXCHANGE; l2n3(n,d); l2n(s->d1->handshake_write_seq,d); s->d1->handshake_write_seq++; */ s->state = SSL3_ST_CW_KEY_EXCH_B; /* number of bytes to write */ s->init_num = n + DTLS1_HM_HEADER_LENGTH; s->init_off = 0; /* buffer the message to handle re-xmits */ dtls1_buffer_message(s, 0); } /* SSL3_ST_CW_KEY_EXCH_B */ return (dtls1_do_write(s, SSL3_RT_HANDSHAKE)); err: BN_CTX_free(bn_ctx); free(encodedPoint); EC_KEY_free(clnt_ecdh); EVP_PKEY_free(srvr_pub_pkey); return (-1); } int dtls1_send_client_verify(SSL *s) { unsigned char *p, *d; unsigned char data[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH]; EVP_PKEY *pkey; unsigned u = 0; unsigned long n; int j; if (s->state == SSL3_ST_CW_CERT_VRFY_A) { d = (unsigned char *)s->init_buf->data; p = &(d[DTLS1_HM_HEADER_LENGTH]); pkey = s->cert->key->privatekey; s->method->ssl3_enc->cert_verify_mac(s, NID_sha1, &(data[MD5_DIGEST_LENGTH])); if (pkey->type == EVP_PKEY_RSA) { s->method->ssl3_enc->cert_verify_mac(s, NID_md5, &(data[0])); if (RSA_sign(NID_md5_sha1, data, MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, &(p[2]), &u, pkey->pkey.rsa) <= 0 ) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_VERIFY, ERR_R_RSA_LIB); goto err; } s2n(u, p); n = u + 2; } else if (pkey->type == EVP_PKEY_DSA) { if (!DSA_sign(pkey->save_type, &(data[MD5_DIGEST_LENGTH]), SHA_DIGEST_LENGTH, &(p[2]), (unsigned int *)&j, pkey->pkey.dsa)) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_VERIFY, ERR_R_DSA_LIB); goto err; } s2n(j, p); n = j + 2; } else if (pkey->type == EVP_PKEY_EC) { if (!ECDSA_sign(pkey->save_type, &(data[MD5_DIGEST_LENGTH]), SHA_DIGEST_LENGTH, &(p[2]), (unsigned int *)&j, pkey->pkey.ec)) { SSLerr(SSL_F_DTLS1_SEND_CLIENT_VERIFY, ERR_R_ECDSA_LIB); goto err; } s2n(j, p); n = j + 2; } else { SSLerr(SSL_F_DTLS1_SEND_CLIENT_VERIFY, ERR_R_INTERNAL_ERROR); goto err; } d = dtls1_set_message_header(s, d, SSL3_MT_CERTIFICATE_VERIFY, n, 0, n); s->init_num = (int)n + DTLS1_HM_HEADER_LENGTH; s->init_off = 0; /* buffer the message to handle re-xmits */ dtls1_buffer_message(s, 0); s->state = SSL3_ST_CW_CERT_VRFY_B; } /* s->state = SSL3_ST_CW_CERT_VRFY_B */ return (dtls1_do_write(s, SSL3_RT_HANDSHAKE)); err: return (-1); } int dtls1_send_client_certificate(SSL *s) { X509 *x509 = NULL; EVP_PKEY *pkey = NULL; int i; unsigned long l; if (s->state == SSL3_ST_CW_CERT_A) { if ((s->cert == NULL) || (s->cert->key->x509 == NULL) || (s->cert->key->privatekey == NULL)) s->state = SSL3_ST_CW_CERT_B; else s->state = SSL3_ST_CW_CERT_C; } /* We need to get a client cert */ if (s->state == SSL3_ST_CW_CERT_B) { /* If we get an error, we need to * ssl->rwstate=SSL_X509_LOOKUP; return(-1); * We then get retied later */ i = 0; i = ssl_do_client_cert_cb(s, &x509, &pkey); if (i < 0) { s->rwstate = SSL_X509_LOOKUP; return (-1); } s->rwstate = SSL_NOTHING; if ((i == 1) && (pkey != NULL) && (x509 != NULL)) { s->state = SSL3_ST_CW_CERT_B; if (!SSL_use_certificate(s, x509) || !SSL_use_PrivateKey(s, pkey)) i = 0; } else if (i == 1) { i = 0; SSLerr(SSL_F_DTLS1_SEND_CLIENT_CERTIFICATE, SSL_R_BAD_DATA_RETURNED_BY_CALLBACK); } if (x509 != NULL) X509_free(x509); EVP_PKEY_free(pkey); if (i == 0) { if (s->version == SSL3_VERSION) { s->s3->tmp.cert_req = 0; ssl3_send_alert(s, SSL3_AL_WARNING, SSL_AD_NO_CERTIFICATE); return (1); } else { s->s3->tmp.cert_req = 2; } } /* Ok, we have a cert */ s->state = SSL3_ST_CW_CERT_C; } if (s->state == SSL3_ST_CW_CERT_C) { s->state = SSL3_ST_CW_CERT_D; l = dtls1_output_cert_chain(s, (s->s3->tmp.cert_req == 2) ? NULL : s->cert->key->x509); s->init_num = (int)l; s->init_off = 0; /* set header called by dtls1_output_cert_chain() */ /* buffer the message to handle re-xmits */ dtls1_buffer_message(s, 0); } /* SSL3_ST_CW_CERT_D */ return (dtls1_do_write(s, SSL3_RT_HANDSHAKE)); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/ssl_err2.c0000644000175000017500000000646212360020705017443 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include void SSL_load_error_strings(void) { #ifndef OPENSSL_NO_ERR ERR_load_crypto_strings(); ERR_load_SSL_strings(); #endif } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/s3_clnt.c0000644000175000017500000021352212360020705017252 0ustar /* $OpenBSD: s3_clnt.c,v 1.76 2014/07/11 13:21:15 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * Portions of the attached software ("Contribution") are developed by * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. * * The Contribution is licensed pursuant to the OpenSSL open source * license provided above. * * ECC cipher suite support in OpenSSL originally written by * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories. * */ /* ==================================================================== * Copyright 2005 Nokia. All rights reserved. * * The portions of the attached software ("Contribution") is developed by * Nokia Corporation and is licensed pursuant to the OpenSSL open source * license. * * The Contribution, originally written by Mika Kousa and Pasi Eronen of * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites * support (see RFC 4279) to OpenSSL. * * No patent licenses or other rights except those expressly stated in * the OpenSSL open source license shall be deemed granted or received * expressly, by implication, estoppel, or otherwise. * * No assurances are provided by Nokia that the Contribution does not * infringe the patent or other intellectual property rights of any third * party or that the license provides you with all the necessary rights * to make use of the Contribution. * * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR * OTHERWISE. */ #include #include "ssl_locl.h" #include #include #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif static const SSL_METHOD *ssl3_get_client_method(int ver); static int ca_dn_cmp(const X509_NAME * const *a, const X509_NAME * const *b); const SSL_METHOD SSLv3_client_method_data = { .version = SSL3_VERSION, .ssl_new = ssl3_new, .ssl_clear = ssl3_clear, .ssl_free = ssl3_free, .ssl_accept = ssl_undefined_function, .ssl_connect = ssl3_connect, .ssl_read = ssl3_read, .ssl_peek = ssl3_peek, .ssl_write = ssl3_write, .ssl_shutdown = ssl3_shutdown, .ssl_renegotiate = ssl3_renegotiate, .ssl_renegotiate_check = ssl3_renegotiate_check, .ssl_get_message = ssl3_get_message, .ssl_read_bytes = ssl3_read_bytes, .ssl_write_bytes = ssl3_write_bytes, .ssl_dispatch_alert = ssl3_dispatch_alert, .ssl_ctrl = ssl3_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl3_put_cipher_by_char, .ssl_pending = ssl3_pending, .num_ciphers = ssl3_num_ciphers, .get_cipher = ssl3_get_cipher, .get_ssl_method = ssl3_get_client_method, .get_timeout = ssl3_default_timeout, .ssl3_enc = &SSLv3_enc_data, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD * SSLv3_client_method(void) { return &SSLv3_client_method_data; } static const SSL_METHOD * ssl3_get_client_method(int ver) { if (ver == SSL3_VERSION) return (SSLv3_client_method()); return (NULL); } int ssl3_connect(SSL *s) { BUF_MEM *buf = NULL; void (*cb)(const SSL *ssl, int type, int val) = NULL; int ret = -1; int new_state, state, skip = 0; ERR_clear_error(); errno = 0; if (s->info_callback != NULL) cb = s->info_callback; else if (s->ctx->info_callback != NULL) cb = s->ctx->info_callback; s->in_handshake++; if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); for (;;) { state = s->state; switch (s->state) { case SSL_ST_RENEGOTIATE: s->renegotiate = 1; s->state = SSL_ST_CONNECT; s->ctx->stats.sess_connect_renegotiate++; /* break */ case SSL_ST_BEFORE: case SSL_ST_CONNECT: case SSL_ST_BEFORE|SSL_ST_CONNECT: case SSL_ST_OK|SSL_ST_CONNECT: s->server = 0; if (cb != NULL) cb(s, SSL_CB_HANDSHAKE_START, 1); if ((s->version & 0xff00 ) != 0x0300) { SSLerr(SSL_F_SSL3_CONNECT, ERR_R_INTERNAL_ERROR); ret = -1; goto end; } /* s->version=SSL3_VERSION; */ s->type = SSL_ST_CONNECT; if (s->init_buf == NULL) { if ((buf = BUF_MEM_new()) == NULL) { ret = -1; goto end; } if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { ret = -1; goto end; } s->init_buf = buf; buf = NULL; } if (!ssl3_setup_buffers(s)) { ret = -1; goto end; } /* setup buffing BIO */ if (!ssl_init_wbio_buffer(s, 0)) { ret = -1; goto end; } /* don't push the buffering BIO quite yet */ ssl3_init_finished_mac(s); s->state = SSL3_ST_CW_CLNT_HELLO_A; s->ctx->stats.sess_connect++; s->init_num = 0; break; case SSL3_ST_CW_CLNT_HELLO_A: case SSL3_ST_CW_CLNT_HELLO_B: s->shutdown = 0; ret = ssl3_client_hello(s); if (ret <= 0) goto end; s->state = SSL3_ST_CR_SRVR_HELLO_A; s->init_num = 0; /* turn on buffering for the next lot of output */ if (s->bbio != s->wbio) s->wbio = BIO_push(s->bbio, s->wbio); break; case SSL3_ST_CR_SRVR_HELLO_A: case SSL3_ST_CR_SRVR_HELLO_B: ret = ssl3_get_server_hello(s); if (ret <= 0) goto end; if (s->hit) { s->state = SSL3_ST_CR_FINISHED_A; if (s->tlsext_ticket_expected) { /* receive renewed session ticket */ s->state = SSL3_ST_CR_SESSION_TICKET_A; } } else s->state = SSL3_ST_CR_CERT_A; s->init_num = 0; break; case SSL3_ST_CR_CERT_A: case SSL3_ST_CR_CERT_B: ret = ssl3_check_finished(s); if (ret <= 0) goto end; if (ret == 2) { s->hit = 1; if (s->tlsext_ticket_expected) s->state = SSL3_ST_CR_SESSION_TICKET_A; else s->state = SSL3_ST_CR_FINISHED_A; s->init_num = 0; break; } /* Check if it is anon DH/ECDH or PSK */ if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { ret = ssl3_get_server_certificate(s); if (ret <= 0) goto end; if (s->tlsext_status_expected) s->state = SSL3_ST_CR_CERT_STATUS_A; else s->state = SSL3_ST_CR_KEY_EXCH_A; } else { skip = 1; s->state = SSL3_ST_CR_KEY_EXCH_A; } s->init_num = 0; break; case SSL3_ST_CR_KEY_EXCH_A: case SSL3_ST_CR_KEY_EXCH_B: ret = ssl3_get_key_exchange(s); if (ret <= 0) goto end; s->state = SSL3_ST_CR_CERT_REQ_A; s->init_num = 0; /* * At this point we check that we have the * required stuff from the server. */ if (!ssl3_check_cert_and_algorithm(s)) { ret = -1; goto end; } break; case SSL3_ST_CR_CERT_REQ_A: case SSL3_ST_CR_CERT_REQ_B: ret = ssl3_get_certificate_request(s); if (ret <= 0) goto end; s->state = SSL3_ST_CR_SRVR_DONE_A; s->init_num = 0; break; case SSL3_ST_CR_SRVR_DONE_A: case SSL3_ST_CR_SRVR_DONE_B: ret = ssl3_get_server_done(s); if (ret <= 0) goto end; if (s->s3->tmp.cert_req) s->state = SSL3_ST_CW_CERT_A; else s->state = SSL3_ST_CW_KEY_EXCH_A; s->init_num = 0; break; case SSL3_ST_CW_CERT_A: case SSL3_ST_CW_CERT_B: case SSL3_ST_CW_CERT_C: case SSL3_ST_CW_CERT_D: ret = ssl3_send_client_certificate(s); if (ret <= 0) goto end; s->state = SSL3_ST_CW_KEY_EXCH_A; s->init_num = 0; break; case SSL3_ST_CW_KEY_EXCH_A: case SSL3_ST_CW_KEY_EXCH_B: ret = ssl3_send_client_key_exchange(s); if (ret <= 0) goto end; /* * EAY EAY EAY need to check for DH fix cert * sent back */ /* * For TLS, cert_req is set to 2, so a cert chain * of nothing is sent, but no verify packet is sent */ /* * XXX: For now, we do not support client * authentication in ECDH cipher suites with * ECDH (rather than ECDSA) certificates. * We need to skip the certificate verify * message when client's ECDH public key is sent * inside the client certificate. */ if (s->s3->tmp.cert_req == 1) { s->state = SSL3_ST_CW_CERT_VRFY_A; } else { s->state = SSL3_ST_CW_CHANGE_A; s->s3->change_cipher_spec = 0; } if (s->s3->flags & TLS1_FLAGS_SKIP_CERT_VERIFY) { s->state = SSL3_ST_CW_CHANGE_A; s->s3->change_cipher_spec = 0; } s->init_num = 0; break; case SSL3_ST_CW_CERT_VRFY_A: case SSL3_ST_CW_CERT_VRFY_B: ret = ssl3_send_client_verify(s); if (ret <= 0) goto end; s->state = SSL3_ST_CW_CHANGE_A; s->init_num = 0; s->s3->change_cipher_spec = 0; break; case SSL3_ST_CW_CHANGE_A: case SSL3_ST_CW_CHANGE_B: ret = ssl3_send_change_cipher_spec(s, SSL3_ST_CW_CHANGE_A, SSL3_ST_CW_CHANGE_B); if (ret <= 0) goto end; #ifdef OPENSSL_NO_NEXTPROTONEG s->state = SSL3_ST_CW_FINISHED_A; #else if (s->s3->next_proto_neg_seen) s->state = SSL3_ST_CW_NEXT_PROTO_A; else s->state = SSL3_ST_CW_FINISHED_A; #endif s->init_num = 0; s->session->cipher = s->s3->tmp.new_cipher; if (!s->method->ssl3_enc->setup_key_block(s)) { ret = -1; goto end; } if (!s->method->ssl3_enc->change_cipher_state(s, SSL3_CHANGE_CIPHER_CLIENT_WRITE)) { ret = -1; goto end; } break; #ifndef OPENSSL_NO_NEXTPROTONEG case SSL3_ST_CW_NEXT_PROTO_A: case SSL3_ST_CW_NEXT_PROTO_B: ret = ssl3_send_next_proto(s); if (ret <= 0) goto end; s->state = SSL3_ST_CW_FINISHED_A; break; #endif case SSL3_ST_CW_FINISHED_A: case SSL3_ST_CW_FINISHED_B: ret = ssl3_send_finished(s, SSL3_ST_CW_FINISHED_A, SSL3_ST_CW_FINISHED_B, s->method->ssl3_enc->client_finished_label, s->method->ssl3_enc->client_finished_label_len); if (ret <= 0) goto end; s->s3->flags |= SSL3_FLAGS_CCS_OK; s->state = SSL3_ST_CW_FLUSH; /* clear flags */ s->s3->flags &= ~SSL3_FLAGS_POP_BUFFER; if (s->hit) { s->s3->tmp.next_state = SSL_ST_OK; if (s->s3->flags & SSL3_FLAGS_DELAY_CLIENT_FINISHED) { s->state = SSL_ST_OK; s->s3->flags|=SSL3_FLAGS_POP_BUFFER; s->s3->delay_buf_pop_ret = 0; } } else { /* Allow NewSessionTicket if ticket expected */ if (s->tlsext_ticket_expected) s->s3->tmp.next_state = SSL3_ST_CR_SESSION_TICKET_A; else s->s3->tmp.next_state = SSL3_ST_CR_FINISHED_A; } s->init_num = 0; break; case SSL3_ST_CR_SESSION_TICKET_A: case SSL3_ST_CR_SESSION_TICKET_B: ret = ssl3_get_new_session_ticket(s); if (ret <= 0) goto end; s->state = SSL3_ST_CR_FINISHED_A; s->init_num = 0; break; case SSL3_ST_CR_CERT_STATUS_A: case SSL3_ST_CR_CERT_STATUS_B: ret = ssl3_get_cert_status(s); if (ret <= 0) goto end; s->state = SSL3_ST_CR_KEY_EXCH_A; s->init_num = 0; break; case SSL3_ST_CR_FINISHED_A: case SSL3_ST_CR_FINISHED_B: s->s3->flags |= SSL3_FLAGS_CCS_OK; ret = ssl3_get_finished(s, SSL3_ST_CR_FINISHED_A, SSL3_ST_CR_FINISHED_B); if (ret <= 0) goto end; if (s->hit) s->state = SSL3_ST_CW_CHANGE_A; else s->state = SSL_ST_OK; s->init_num = 0; break; case SSL3_ST_CW_FLUSH: s->rwstate = SSL_WRITING; if (BIO_flush(s->wbio) <= 0) { ret = -1; goto end; } s->rwstate = SSL_NOTHING; s->state = s->s3->tmp.next_state; break; case SSL_ST_OK: /* clean a few things up */ ssl3_cleanup_key_block(s); if (s->init_buf != NULL) { BUF_MEM_free(s->init_buf); s->init_buf = NULL; } /* * If we are not 'joining' the last two packets, * remove the buffering now */ if (!(s->s3->flags & SSL3_FLAGS_POP_BUFFER)) ssl_free_wbio_buffer(s); /* else do it later in ssl3_write */ s->init_num = 0; s->renegotiate = 0; s->new_session = 0; ssl_update_cache(s, SSL_SESS_CACHE_CLIENT); if (s->hit) s->ctx->stats.sess_hit++; ret = 1; /* s->server=0; */ s->handshake_func = ssl3_connect; s->ctx->stats.sess_connect_good++; if (cb != NULL) cb(s, SSL_CB_HANDSHAKE_DONE, 1); goto end; /* break; */ default: SSLerr(SSL_F_SSL3_CONNECT, SSL_R_UNKNOWN_STATE); ret = -1; goto end; /* break; */ } /* did we do anything */ if (!s->s3->tmp.reuse_message && !skip) { if (s->debug) { if ((ret = BIO_flush(s->wbio)) <= 0) goto end; } if ((cb != NULL) && (s->state != state)) { new_state = s->state; s->state = state; cb(s, SSL_CB_CONNECT_LOOP, 1); s->state = new_state; } } skip = 0; } end: s->in_handshake--; if (buf != NULL) BUF_MEM_free(buf); if (cb != NULL) cb(s, SSL_CB_CONNECT_EXIT, ret); return (ret); } int ssl3_client_hello(SSL *s) { unsigned char *buf; unsigned char *p, *d; int i; unsigned long l; buf = (unsigned char *)s->init_buf->data; if (s->state == SSL3_ST_CW_CLNT_HELLO_A) { SSL_SESSION *sess = s->session; if ((sess == NULL) || (sess->ssl_version != s->version) || (!sess->session_id_length && !sess->tlsext_tick) || (sess->not_resumable)) { if (!ssl_get_new_session(s, 0)) goto err; } /* else use the pre-loaded session */ p = s->s3->client_random; RAND_pseudo_bytes(p, SSL3_RANDOM_SIZE); /* Do the message type and length last */ d = p = &(buf[4]); /* * Version indicates the negotiated version: for example from * an SSLv2/v3 compatible client hello). The client_version * field is the maximum version we permit and it is also * used in RSA encrypted premaster secrets. Some servers can * choke if we initially report a higher version then * renegotiate to a lower one in the premaster secret. This * didn't happen with TLS 1.0 as most servers supported it * but it can with TLS 1.1 or later if the server only supports * 1.0. * * Possible scenario with previous logic: * 1. Client hello indicates TLS 1.2 * 2. Server hello says TLS 1.0 * 3. RSA encrypted premaster secret uses 1.2. * 4. Handhaked proceeds using TLS 1.0. * 5. Server sends hello request to renegotiate. * 6. Client hello indicates TLS v1.0 as we now * know that is maximum server supports. * 7. Server chokes on RSA encrypted premaster secret * containing version 1.0. * * For interoperability it should be OK to always use the * maximum version we support in client hello and then rely * on the checking of version to ensure the servers isn't * being inconsistent: for example initially negotiating with * TLS 1.0 and renegotiating with TLS 1.2. We do this by using * client_version in client hello and not resetting it to * the negotiated version. */ *(p++) = s->client_version >> 8; *(p++) = s->client_version & 0xff; /* Random stuff */ memcpy(p, s->s3->client_random, SSL3_RANDOM_SIZE); p += SSL3_RANDOM_SIZE; /* Session ID */ if (s->new_session) i = 0; else i = s->session->session_id_length; *(p++) = i; if (i != 0) { if (i > (int)sizeof(s->session->session_id)) { SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } memcpy(p, s->session->session_id, i); p += i; } /* Ciphers supported */ i = ssl_cipher_list_to_bytes(s, SSL_get_ciphers(s), &(p[2]), 0); if (i == 0) { SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_NO_CIPHERS_AVAILABLE); goto err; } #ifdef OPENSSL_MAX_TLS1_2_CIPHER_LENGTH /* * Some servers hang if client hello > 256 bytes * as hack workaround chop number of supported ciphers * to keep it well below this if we use TLS v1.2 */ if (TLS1_get_version(s) >= TLS1_2_VERSION && i > OPENSSL_MAX_TLS1_2_CIPHER_LENGTH) i = OPENSSL_MAX_TLS1_2_CIPHER_LENGTH & ~1; #endif s2n(i, p); p += i; /* add in (no) COMPRESSION */ *(p++) = 1; *(p++) = 0; /* Add the NULL method */ /* TLS extensions*/ if (ssl_prepare_clienthello_tlsext(s) <= 0) { SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); goto err; } if ((p = ssl_add_clienthello_tlsext(s, p, buf + SSL3_RT_MAX_PLAIN_LENGTH)) == NULL) { SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } l = (p - d); d = buf; *(d++) = SSL3_MT_CLIENT_HELLO; l2n3(l, d); s->state = SSL3_ST_CW_CLNT_HELLO_B; /* number of bytes to write */ s->init_num = p - buf; s->init_off = 0; } /* SSL3_ST_CW_CLNT_HELLO_B */ return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); err: return (-1); } int ssl3_get_server_hello(SSL *s) { STACK_OF(SSL_CIPHER) *sk; const SSL_CIPHER *c; unsigned char *p, *d; int i, al, ok; unsigned int j; long n; n = s->method->ssl_get_message(s, SSL3_ST_CR_SRVR_HELLO_A, SSL3_ST_CR_SRVR_HELLO_B, -1, 20000, /* ?? */ &ok); if (!ok) return ((int)n); if (SSL_IS_DTLS(s)) { if (s->s3->tmp.message_type == DTLS1_MT_HELLO_VERIFY_REQUEST) { if (s->d1->send_cookie == 0) { s->s3->tmp.reuse_message = 1; return (1); } else { /* Already sent a cookie. */ al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_BAD_MESSAGE_TYPE); goto f_err; } } } if (s->s3->tmp.message_type != SSL3_MT_SERVER_HELLO) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_BAD_MESSAGE_TYPE); goto f_err; } d = p = (unsigned char *)s->init_msg; if ((p[0] != (s->version >> 8)) || (p[1] != (s->version & 0xff))) { SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_WRONG_SSL_VERSION); s->version = (s->version&0xff00) | p[1]; al = SSL_AD_PROTOCOL_VERSION; goto f_err; } p += 2; /* load the server hello data */ /* load the server random */ memcpy(s->s3->server_random, p, SSL3_RANDOM_SIZE); p += SSL3_RANDOM_SIZE; /* get the session-id */ j= *(p++); if ((j > sizeof s->session->session_id) || (j > SSL3_SESSION_ID_SIZE)) { al = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_SSL3_SESSION_ID_TOO_LONG); goto f_err; } /* * Check if we want to resume the session based on external * pre-shared secret */ if (s->version >= TLS1_VERSION && s->tls_session_secret_cb) { SSL_CIPHER *pref_cipher = NULL; s->session->master_key_length = sizeof(s->session->master_key); if (s->tls_session_secret_cb(s, s->session->master_key, &s->session->master_key_length, NULL, &pref_cipher, s->tls_session_secret_cb_arg)) { s->session->cipher = pref_cipher ? pref_cipher : ssl_get_cipher_by_char(s, p + j); s->s3->flags |= SSL3_FLAGS_CCS_OK; } } if (j != 0 && j == s->session->session_id_length && timingsafe_memcmp(p, s->session->session_id, j) == 0) { if (s->sid_ctx_length != s->session->sid_ctx_length || timingsafe_memcmp(s->session->sid_ctx, s->sid_ctx, s->sid_ctx_length) != 0) { /* actually a client application bug */ al = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT); goto f_err; } s->s3->flags |= SSL3_FLAGS_CCS_OK; s->hit = 1; } else { /* a miss or crap from the other end */ /* If we were trying for session-id reuse, make a new * SSL_SESSION so we don't stuff up other people */ s->hit = 0; if (s->session->session_id_length > 0) { if (!ssl_get_new_session(s, 0)) { al = SSL_AD_INTERNAL_ERROR; goto f_err; } } s->session->session_id_length = j; memcpy(s->session->session_id,p,j); /* j could be 0 */ } p += j; c = ssl_get_cipher_by_char(s, p); if (c == NULL) { /* unknown cipher */ al = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_UNKNOWN_CIPHER_RETURNED); goto f_err; } /* TLS v1.2 only ciphersuites require v1.2 or later */ if ((c->algorithm_ssl & SSL_TLSV1_2) && (TLS1_get_version(s) < TLS1_2_VERSION)) { al = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_WRONG_CIPHER_RETURNED); goto f_err; } p += ssl_put_cipher_by_char(s, NULL, NULL); sk = ssl_get_ciphers_by_id(s); i = sk_SSL_CIPHER_find(sk, c); if (i < 0) { /* we did not say we would use this cipher */ al = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_WRONG_CIPHER_RETURNED); goto f_err; } /* * Depending on the session caching (internal/external), the cipher * and/or cipher_id values may not be set. Make sure that * cipher_id is set and use it for comparison. */ if (s->session->cipher) s->session->cipher_id = s->session->cipher->id; if (s->hit && (s->session->cipher_id != c->id)) { al = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED); goto f_err; } s->s3->tmp.new_cipher = c; /* * Don't digest cached records if no sigalgs: we may need them for * client authentication. */ if (!SSL_USE_SIGALGS(s) && !ssl3_digest_cached_records(s)) { al = SSL_AD_INTERNAL_ERROR; goto f_err; } /* lets get the compression algorithm */ /* COMPRESSION */ if (*(p++) != 0) { al = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM); goto f_err; } /* TLS extensions*/ if (s->version >= SSL3_VERSION) { if (!ssl_parse_serverhello_tlsext(s, &p, d, n, &al)) { /* 'al' set by ssl_parse_serverhello_tlsext */ SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_PARSE_TLSEXT); goto f_err; } if (ssl_check_serverhello_tlsext(s) <= 0) { SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_SERVERHELLO_TLSEXT); goto err; } } if (p != (d + n)) { /* wrong packet length */ al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_BAD_PACKET_LENGTH); goto f_err; } return (1); f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: return (-1); } int ssl3_get_server_certificate(SSL *s) { int al, i, ok, ret = -1; unsigned long n, nc, llen, l; X509 *x = NULL; const unsigned char *q, *p; unsigned char *d; STACK_OF(X509) *sk = NULL; SESS_CERT *sc; EVP_PKEY *pkey = NULL; /* VRS: 0=> will allow null cert if auth == KRB5 */ int need_cert = 1; n = s->method->ssl_get_message(s, SSL3_ST_CR_CERT_A, SSL3_ST_CR_CERT_B, -1, s->max_cert_list, &ok); if (!ok) return ((int)n); if ((s->s3->tmp.message_type == SSL3_MT_SERVER_KEY_EXCHANGE) || ((s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) && (s->s3->tmp.message_type == SSL3_MT_SERVER_DONE))) { s->s3->tmp.reuse_message = 1; return (1); } if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, SSL_R_BAD_MESSAGE_TYPE); goto f_err; } p = d = (unsigned char *)s->init_msg; if ((sk = sk_X509_new_null()) == NULL) { SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, ERR_R_MALLOC_FAILURE); goto err; } n2l3(p, llen); if (llen + 3 != n) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, SSL_R_LENGTH_MISMATCH); goto f_err; } for (nc = 0; nc < llen; ) { n2l3(p, l); if ((l + nc + 3) > llen) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, SSL_R_CERT_LENGTH_MISMATCH); goto f_err; } q = p; x = d2i_X509(NULL, &q, l); if (x == NULL) { al = SSL_AD_BAD_CERTIFICATE; SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, ERR_R_ASN1_LIB); goto f_err; } if (q != (p + l)) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, SSL_R_CERT_LENGTH_MISMATCH); goto f_err; } if (!sk_X509_push(sk, x)) { SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, ERR_R_MALLOC_FAILURE); goto err; } x = NULL; nc += l + 3; p = q; } i = ssl_verify_cert_chain(s, sk); if ((s->verify_mode != SSL_VERIFY_NONE) && (i <= 0)) { al = ssl_verify_alarm_type(s->verify_result); SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, SSL_R_CERTIFICATE_VERIFY_FAILED); goto f_err; } ERR_clear_error(); /* but we keep s->verify_result */ sc = ssl_sess_cert_new(); if (sc == NULL) goto err; if (s->session->sess_cert) ssl_sess_cert_free(s->session->sess_cert); s->session->sess_cert = sc; sc->cert_chain = sk; /* * Inconsistency alert: cert_chain does include the peer's * certificate, which we don't include in s3_srvr.c */ x = sk_X509_value(sk, 0); sk = NULL; /* VRS 19990621: possible memory leak; sk=null ==> !sk_pop_free() @end*/ pkey = X509_get_pubkey(x); /* VRS: allow null cert if auth == KRB5 */ need_cert = ((s->s3->tmp.new_cipher->algorithm_mkey & SSL_kKRB5) && (s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5)) ? 0 : 1; if (need_cert && ((pkey == NULL) || EVP_PKEY_missing_parameters(pkey))) { x = NULL; al = SSL3_AL_FATAL; SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS); goto f_err; } i = ssl_cert_type(x, pkey); if (need_cert && i < 0) { x = NULL; al = SSL3_AL_FATAL; SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, SSL_R_UNKNOWN_CERTIFICATE_TYPE); goto f_err; } if (need_cert) { sc->peer_cert_type = i; CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509); /* * Why would the following ever happen? * We just created sc a couple of lines ago. */ if (sc->peer_pkeys[i].x509 != NULL) X509_free(sc->peer_pkeys[i].x509); sc->peer_pkeys[i].x509 = x; sc->peer_key = &(sc->peer_pkeys[i]); if (s->session->peer != NULL) X509_free(s->session->peer); CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509); s->session->peer = x; } else { sc->peer_cert_type = i; sc->peer_key = NULL; if (s->session->peer != NULL) X509_free(s->session->peer); s->session->peer = NULL; } s->session->verify_result = s->verify_result; x = NULL; ret = 1; if (0) { f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); } err: EVP_PKEY_free(pkey); X509_free(x); sk_X509_pop_free(sk, X509_free); return (ret); } int ssl3_get_key_exchange(SSL *s) { unsigned char *q, md_buf[EVP_MAX_MD_SIZE*2]; EVP_MD_CTX md_ctx; unsigned char *param, *p; int al, i, j, param_len, ok; long n, alg_k, alg_a; EVP_PKEY *pkey = NULL; const EVP_MD *md = NULL; RSA *rsa = NULL; DH *dh = NULL; EC_KEY *ecdh = NULL; BN_CTX *bn_ctx = NULL; EC_POINT *srvr_ecpoint = NULL; int curve_nid = 0; int encoded_pt_len = 0; /* * Use same message size as in ssl3_get_certificate_request() * as ServerKeyExchange message may be skipped. */ n = s->method->ssl_get_message(s, SSL3_ST_CR_KEY_EXCH_A, SSL3_ST_CR_KEY_EXCH_B, -1, s->max_cert_list, &ok); if (!ok) return ((int)n); if (s->s3->tmp.message_type != SSL3_MT_SERVER_KEY_EXCHANGE) { s->s3->tmp.reuse_message = 1; return (1); } param = p = (unsigned char *)s->init_msg; if (s->session->sess_cert != NULL) { RSA_free(s->session->sess_cert->peer_rsa_tmp); s->session->sess_cert->peer_rsa_tmp = NULL; DH_free(s->session->sess_cert->peer_dh_tmp); s->session->sess_cert->peer_dh_tmp = NULL; EC_KEY_free(s->session->sess_cert->peer_ecdh_tmp); s->session->sess_cert->peer_ecdh_tmp = NULL; } else { s->session->sess_cert = ssl_sess_cert_new(); if (s->session->sess_cert == NULL) goto err; } param_len = 0; alg_k = s->s3->tmp.new_cipher->algorithm_mkey; alg_a = s->s3->tmp.new_cipher->algorithm_auth; EVP_MD_CTX_init(&md_ctx); if (alg_k & SSL_kRSA) { if ((rsa = RSA_new()) == NULL) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } n2s(p, i); param_len = i + 2; if (param_len > n) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_RSA_MODULUS_LENGTH); goto f_err; } if (!(rsa->n = BN_bin2bn(p, i, rsa->n))) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); goto err; } p += i; n2s(p, i); param_len += i + 2; if (param_len > n) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_RSA_E_LENGTH); goto f_err; } if (!(rsa->e = BN_bin2bn(p, i, rsa->e))) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); goto err; } p += i; n -= param_len; /* * This should be because we are using an * export cipher */ if (alg_a & SSL_aRSA) pkey = X509_get_pubkey( s->session->sess_cert->peer_pkeys[ SSL_PKEY_RSA_ENC].x509); else { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } s->session->sess_cert->peer_rsa_tmp = rsa; rsa = NULL; } else if (alg_k & SSL_kEDH) { if ((dh = DH_new()) == NULL) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_DH_LIB); goto err; } n2s(p, i); param_len = i + 2; if (param_len > n) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_P_LENGTH); goto f_err; } if (!(dh->p = BN_bin2bn(p, i, NULL))) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); goto err; } p += i; n2s(p, i); param_len += i + 2; if (param_len > n) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_G_LENGTH); goto f_err; } if (!(dh->g = BN_bin2bn(p, i, NULL))) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); goto err; } p += i; n2s(p, i); param_len += i + 2; if (param_len > n) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_PUB_KEY_LENGTH); goto f_err; } if (!(dh->pub_key = BN_bin2bn(p, i, NULL))) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); goto err; } p += i; n -= param_len; if (alg_a & SSL_aRSA) pkey = X509_get_pubkey( s->session->sess_cert->peer_pkeys[ SSL_PKEY_RSA_ENC].x509); else if (alg_a & SSL_aDSS) pkey = X509_get_pubkey( s->session->sess_cert->peer_pkeys[ SSL_PKEY_DSA_SIGN].x509); /* else anonymous DH, so no certificate or pkey. */ s->session->sess_cert->peer_dh_tmp = dh; dh = NULL; } else if ((alg_k & SSL_kDHr) || (alg_k & SSL_kDHd)) { al = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER); goto f_err; } else if (alg_k & SSL_kEECDH) { EC_GROUP *ngroup; const EC_GROUP *group; if ((ecdh = EC_KEY_new()) == NULL) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } /* * Extract elliptic curve parameters and the * server's ephemeral ECDH public key. * Keep accumulating lengths of various components in * param_len and make sure it never exceeds n. */ /* * XXX: For now we only support named (not generic) curves * and the ECParameters in this case is just three bytes. */ param_len = 3; if ((param_len > n) || (*p != NAMED_CURVE_TYPE) || ((curve_nid = tls1_ec_curve_id2nid(*(p + 2))) == 0)) { al = SSL_AD_INTERNAL_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS); goto f_err; } ngroup = EC_GROUP_new_by_curve_name(curve_nid); if (ngroup == NULL) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_EC_LIB); goto err; } if (EC_KEY_set_group(ecdh, ngroup) == 0) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_EC_LIB); goto err; } EC_GROUP_free(ngroup); group = EC_KEY_get0_group(ecdh); p += 3; /* Next, get the encoded ECPoint */ if (((srvr_ecpoint = EC_POINT_new(group)) == NULL) || ((bn_ctx = BN_CTX_new()) == NULL)) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } encoded_pt_len = *p; /* length of encoded point */ p += 1; param_len += (1 + encoded_pt_len); if ((param_len > n) || (EC_POINT_oct2point(group, srvr_ecpoint, p, encoded_pt_len, bn_ctx) == 0)) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_ECPOINT); goto f_err; } n -= param_len; p += encoded_pt_len; /* * The ECC/TLS specification does not mention the use * of DSA to sign ECParameters in the server key * exchange message. We do support RSA and ECDSA. */ if (alg_a & SSL_aRSA) pkey = X509_get_pubkey( s->session->sess_cert->peer_pkeys[ SSL_PKEY_RSA_ENC].x509); else if (alg_a & SSL_aECDSA) pkey = X509_get_pubkey( s->session->sess_cert->peer_pkeys[ SSL_PKEY_ECC].x509); /* Else anonymous ECDH, so no certificate or pkey. */ EC_KEY_set_public_key(ecdh, srvr_ecpoint); s->session->sess_cert->peer_ecdh_tmp = ecdh; ecdh = NULL; BN_CTX_free(bn_ctx); bn_ctx = NULL; EC_POINT_free(srvr_ecpoint); srvr_ecpoint = NULL; } else if (alg_k) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_UNEXPECTED_MESSAGE); goto f_err; } /* p points to the next byte, there are 'n' bytes left */ /* if it was signed, check the signature */ if (pkey != NULL) { if (SSL_USE_SIGALGS(s)) { int sigalg = tls12_get_sigid(pkey); /* Should never happen */ if (sigalg == -1) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } /* * Check key type is consistent * with signature */ if (sigalg != (int)p[1]) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_WRONG_SIGNATURE_TYPE); al = SSL_AD_DECODE_ERROR; goto f_err; } md = tls12_get_hash(p[0]); if (md == NULL) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_UNKNOWN_DIGEST); al = SSL_AD_DECODE_ERROR; goto f_err; } p += 2; n -= 2; } else md = EVP_sha1(); n2s(p, i); n -= 2; j = EVP_PKEY_size(pkey); if ((i != n) || (n > j) || (n <= 0)) { /* wrong packet length */ al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_WRONG_SIGNATURE_LENGTH); goto f_err; } if (pkey->type == EVP_PKEY_RSA && !SSL_USE_SIGALGS(s)) { int num; j = 0; q = md_buf; for (num = 2; num > 0; num--) { EVP_DigestInit_ex(&md_ctx, (num == 2) ? s->ctx->md5 : s->ctx->sha1, NULL); EVP_DigestUpdate(&md_ctx, &(s->s3->client_random[0]), SSL3_RANDOM_SIZE); EVP_DigestUpdate(&md_ctx, &(s->s3->server_random[0]), SSL3_RANDOM_SIZE); EVP_DigestUpdate(&md_ctx, param, param_len); EVP_DigestFinal_ex(&md_ctx, q, (unsigned int *)&i); q += i; j += i; } i = RSA_verify(NID_md5_sha1, md_buf, j, p, n, pkey->pkey.rsa); if (i < 0) { al = SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_RSA_DECRYPT); goto f_err; } if (i == 0) { /* bad signature */ al = SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SIGNATURE); goto f_err; } } else { EVP_VerifyInit_ex(&md_ctx, md, NULL); EVP_VerifyUpdate(&md_ctx, &(s->s3->client_random[0]), SSL3_RANDOM_SIZE); EVP_VerifyUpdate(&md_ctx, &(s->s3->server_random[0]), SSL3_RANDOM_SIZE); EVP_VerifyUpdate(&md_ctx, param, param_len); if (EVP_VerifyFinal(&md_ctx, p,(int)n, pkey) <= 0) { /* bad signature */ al = SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SIGNATURE); goto f_err; } } } else { /* aNULL or kPSK do not need public keys */ if (!(alg_a & SSL_aNULL) && !(alg_k & SSL_kPSK)) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } /* still data left over */ if (n != 0) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_EXTRA_DATA_IN_MESSAGE); goto f_err; } } EVP_PKEY_free(pkey); EVP_MD_CTX_cleanup(&md_ctx); return (1); f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: EVP_PKEY_free(pkey); RSA_free(rsa); DH_free(dh); BN_CTX_free(bn_ctx); EC_POINT_free(srvr_ecpoint); EC_KEY_free(ecdh); EVP_MD_CTX_cleanup(&md_ctx); return (-1); } int ssl3_get_certificate_request(SSL *s) { int ok, ret = 0; unsigned long n, nc, l; unsigned int llen, ctype_num, i; X509_NAME *xn = NULL; const unsigned char *p, *q; unsigned char *d; STACK_OF(X509_NAME) *ca_sk = NULL; n = s->method->ssl_get_message(s, SSL3_ST_CR_CERT_REQ_A, SSL3_ST_CR_CERT_REQ_B, -1, s->max_cert_list, &ok); if (!ok) return ((int)n); s->s3->tmp.cert_req = 0; if (s->s3->tmp.message_type == SSL3_MT_SERVER_DONE) { s->s3->tmp.reuse_message = 1; /* * If we get here we don't need any cached handshake records * as we wont be doing client auth. */ if (s->s3->handshake_buffer) { if (!ssl3_digest_cached_records(s)) goto err; } return (1); } if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE_REQUEST) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE); SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_WRONG_MESSAGE_TYPE); goto err; } /* TLS does not like anon-DH with client cert */ if (s->version > SSL3_VERSION) { if (s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE); SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER); goto err; } } p = d = (unsigned char *)s->init_msg; if ((ca_sk = sk_X509_NAME_new(ca_dn_cmp)) == NULL) { SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE); goto err; } /* get the certificate types */ ctype_num= *(p++); if (ctype_num > SSL3_CT_NUMBER) ctype_num = SSL3_CT_NUMBER; for (i = 0; i < ctype_num; i++) s->s3->tmp.ctype[i] = p[i]; p += ctype_num; if (SSL_USE_SIGALGS(s)) { n2s(p, llen); /* Check we have enough room for signature algorithms and * following length value. */ if ((unsigned long)(p - d + llen + 2) > n) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_DATA_LENGTH_TOO_LONG); goto err; } if ((llen & 1) || !tls1_process_sigalgs(s, p, llen)) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_SIGNATURE_ALGORITHMS_ERROR); goto err; } p += llen; } /* get the CA RDNs */ n2s(p, llen); if ((unsigned long)(p - d + llen) != n) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_LENGTH_MISMATCH); goto err; } for (nc = 0; nc < llen; ) { n2s(p, l); if ((l + nc + 2) > llen) { if ((s->options & SSL_OP_NETSCAPE_CA_DN_BUG)) goto cont; /* netscape bugs */ ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_CA_DN_TOO_LONG); goto err; } q = p; if ((xn = d2i_X509_NAME(NULL, &q, l)) == NULL) { /* If netscape tolerance is on, ignore errors */ if (s->options & SSL_OP_NETSCAPE_CA_DN_BUG) goto cont; else { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_ASN1_LIB); goto err; } } if (q != (p + l)) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_CA_DN_LENGTH_MISMATCH); goto err; } if (!sk_X509_NAME_push(ca_sk, xn)) { SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE); goto err; } p += l; nc += l + 2; } if (0) { cont: ERR_clear_error(); } /* we should setup a certificate to return.... */ s->s3->tmp.cert_req = 1; s->s3->tmp.ctype_num = ctype_num; if (s->s3->tmp.ca_names != NULL) sk_X509_NAME_pop_free(s->s3->tmp.ca_names, X509_NAME_free); s->s3->tmp.ca_names = ca_sk; ca_sk = NULL; ret = 1; err: if (ca_sk != NULL) sk_X509_NAME_pop_free(ca_sk, X509_NAME_free); return (ret); } static int ca_dn_cmp(const X509_NAME * const *a, const X509_NAME * const *b) { return (X509_NAME_cmp(*a, *b)); } int ssl3_get_new_session_ticket(SSL *s) { int ok, al, ret = 0, ticklen; long n; const unsigned char *p; unsigned char *d; n = s->method->ssl_get_message(s, SSL3_ST_CR_SESSION_TICKET_A, SSL3_ST_CR_SESSION_TICKET_B, -1, 16384, &ok); if (!ok) return ((int)n); if (s->s3->tmp.message_type == SSL3_MT_FINISHED) { s->s3->tmp.reuse_message = 1; return (1); } if (s->s3->tmp.message_type != SSL3_MT_NEWSESSION_TICKET) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, SSL_R_BAD_MESSAGE_TYPE); goto f_err; } if (n < 6) { /* need at least ticket_lifetime_hint + ticket length */ al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, SSL_R_LENGTH_MISMATCH); goto f_err; } p = d = (unsigned char *)s->init_msg; n2l(p, s->session->tlsext_tick_lifetime_hint); n2s(p, ticklen); /* ticket_lifetime_hint + ticket_length + ticket */ if (ticklen + 6 != n) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, SSL_R_LENGTH_MISMATCH); goto f_err; } free(s->session->tlsext_tick); s->session->tlsext_ticklen = 0; s->session->tlsext_tick = malloc(ticklen); if (!s->session->tlsext_tick) { SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, ERR_R_MALLOC_FAILURE); goto err; } memcpy(s->session->tlsext_tick, p, ticklen); s->session->tlsext_ticklen = ticklen; /* * There are two ways to detect a resumed ticket sesion. * One is to set an appropriate session ID and then the server * must return a match in ServerHello. This allows the normal * client session ID matching to work and we know much * earlier that the ticket has been accepted. * * The other way is to set zero length session ID when the * ticket is presented and rely on the handshake to determine * session resumption. * * We choose the former approach because this fits in with * assumptions elsewhere in OpenSSL. The session ID is set * to the SHA256 (or SHA1 is SHA256 is disabled) hash of the * ticket. */ EVP_Digest(p, ticklen, s->session->session_id, &s->session->session_id_length, EVP_sha256(), NULL); ret = 1; return (ret); f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: return (-1); } int ssl3_get_cert_status(SSL *s) { int ok, al; unsigned long resplen, n; const unsigned char *p; n = s->method->ssl_get_message(s, SSL3_ST_CR_CERT_STATUS_A, SSL3_ST_CR_CERT_STATUS_B, SSL3_MT_CERTIFICATE_STATUS, 16384, &ok); if (!ok) return ((int)n); if (n < 4) { /* need at least status type + length */ al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_STATUS, SSL_R_LENGTH_MISMATCH); goto f_err; } p = (unsigned char *)s->init_msg; if (*p++ != TLSEXT_STATUSTYPE_ocsp) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_STATUS, SSL_R_UNSUPPORTED_STATUS_TYPE); goto f_err; } n2l3(p, resplen); if (resplen + 4 != n) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_STATUS, SSL_R_LENGTH_MISMATCH); goto f_err; } free(s->tlsext_ocsp_resp); s->tlsext_ocsp_resp = BUF_memdup(p, resplen); if (!s->tlsext_ocsp_resp) { al = SSL_AD_INTERNAL_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_STATUS, ERR_R_MALLOC_FAILURE); goto f_err; } s->tlsext_ocsp_resplen = resplen; if (s->ctx->tlsext_status_cb) { int ret; ret = s->ctx->tlsext_status_cb(s, s->ctx->tlsext_status_arg); if (ret == 0) { al = SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE; SSLerr(SSL_F_SSL3_GET_CERT_STATUS, SSL_R_INVALID_STATUS_RESPONSE); goto f_err; } if (ret < 0) { al = SSL_AD_INTERNAL_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_STATUS, ERR_R_MALLOC_FAILURE); goto f_err; } } return (1); f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); return (-1); } int ssl3_get_server_done(SSL *s) { int ok, ret = 0; long n; n = s->method->ssl_get_message(s, SSL3_ST_CR_SRVR_DONE_A, SSL3_ST_CR_SRVR_DONE_B, SSL3_MT_SERVER_DONE, 30, /* should be very small, like 0 :-) */ &ok); if (!ok) return ((int)n); if (n > 0) { /* should contain no data */ ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); SSLerr(SSL_F_SSL3_GET_SERVER_DONE, SSL_R_LENGTH_MISMATCH); return (-1); } ret = 1; return (ret); } int ssl3_send_client_key_exchange(SSL *s) { unsigned char *p, *d; int n; unsigned long alg_k; unsigned char *q; EVP_PKEY *pkey = NULL; EC_KEY *clnt_ecdh = NULL; const EC_POINT *srvr_ecpoint = NULL; EVP_PKEY *srvr_pub_pkey = NULL; unsigned char *encodedPoint = NULL; int encoded_pt_len = 0; BN_CTX *bn_ctx = NULL; if (s->state == SSL3_ST_CW_KEY_EXCH_A) { d = (unsigned char *)s->init_buf->data; p = &(d[4]); alg_k = s->s3->tmp.new_cipher->algorithm_mkey; if (alg_k & SSL_kRSA) { RSA *rsa; unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH]; if (s->session->sess_cert->peer_rsa_tmp != NULL) rsa = s->session->sess_cert->peer_rsa_tmp; else { pkey = X509_get_pubkey( s->session->sess_cert->peer_pkeys[ SSL_PKEY_RSA_ENC].x509); if ((pkey == NULL) || (pkey->type != EVP_PKEY_RSA) || (pkey->pkey.rsa == NULL)) { SSLerr( SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } rsa = pkey->pkey.rsa; EVP_PKEY_free(pkey); } tmp_buf[0] = s->client_version >> 8; tmp_buf[1] = s->client_version & 0xff; if (RAND_bytes(&(tmp_buf[2]), sizeof tmp_buf - 2) <= 0) goto err; s->session->master_key_length = sizeof tmp_buf; q = p; /* Fix buf for TLS and beyond */ if (s->version > SSL3_VERSION) p += 2; n = RSA_public_encrypt(sizeof tmp_buf, tmp_buf, p, rsa, RSA_PKCS1_PADDING); if (n <= 0) { SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, SSL_R_BAD_RSA_ENCRYPT); goto err; } /* Fix buf for TLS and beyond */ if (s->version > SSL3_VERSION) { s2n(n, q); n += 2; } s->session->master_key_length = s->method->ssl3_enc->generate_master_secret( s, s->session->master_key, tmp_buf, sizeof tmp_buf); OPENSSL_cleanse(tmp_buf, sizeof tmp_buf); } else if (alg_k & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) { DH *dh_srvr, *dh_clnt; if (s->session->sess_cert == NULL) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE); SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, SSL_R_UNEXPECTED_MESSAGE); goto err; } if (s->session->sess_cert->peer_dh_tmp != NULL) dh_srvr = s->session->sess_cert->peer_dh_tmp; else { /* We get them from the cert. */ ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, SSL_R_UNABLE_TO_FIND_DH_PARAMETERS); goto err; } /* Generate a new random key. */ if ((dh_clnt = DHparams_dup(dh_srvr)) == NULL) { SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB); goto err; } if (!DH_generate_key(dh_clnt)) { SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB); DH_free(dh_clnt); goto err; } /* * Use the 'p' output buffer for the DH key, but * make sure to clear it out afterwards. */ n = DH_compute_key(p, dh_srvr->pub_key, dh_clnt); if (n <= 0) { SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB); DH_free(dh_clnt); goto err; } /* Generate master key from the result. */ s->session->master_key_length = s->method->ssl3_enc->generate_master_secret(s, s->session->master_key, p, n); /* Clean up. */ memset(p, 0, n); /* Send off the data. */ n = BN_num_bytes(dh_clnt->pub_key); s2n(n, p); BN_bn2bin(dh_clnt->pub_key, p); n += 2; DH_free(dh_clnt); /* perhaps clean things up a bit EAY EAY EAY EAY*/ } else if (alg_k & (SSL_kEECDH|SSL_kECDHr|SSL_kECDHe)) { const EC_GROUP *srvr_group = NULL; EC_KEY *tkey; int ecdh_clnt_cert = 0; int field_size = 0; if (s->session->sess_cert == NULL) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE); SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, SSL_R_UNEXPECTED_MESSAGE); goto err; } /* * Did we send out the client's ECDH share for use * in premaster computation as part of client * certificate? If so, set ecdh_clnt_cert to 1. */ if ((alg_k & (SSL_kECDHr|SSL_kECDHe)) && (s->cert != NULL)) { /* * XXX: For now, we do not support client * authentication using ECDH certificates. * To add such support, one needs to add * code that checks for appropriate * conditions and sets ecdh_clnt_cert to 1. * For example, the cert have an ECC * key on the same curve as the server's * and the key should be authorized for * key agreement. * * One also needs to add code in ssl3_connect * to skip sending the certificate verify * message. * * if ((s->cert->key->privatekey != NULL) && * (s->cert->key->privatekey->type == * EVP_PKEY_EC) && ...) * ecdh_clnt_cert = 1; */ } if (s->session->sess_cert->peer_ecdh_tmp != NULL) { tkey = s->session->sess_cert->peer_ecdh_tmp; } else { /* Get the Server Public Key from Cert */ srvr_pub_pkey = X509_get_pubkey(s->session-> \ sess_cert->peer_pkeys[SSL_PKEY_ECC].x509); if ((srvr_pub_pkey == NULL) || (srvr_pub_pkey->type != EVP_PKEY_EC) || (srvr_pub_pkey->pkey.ec == NULL)) { SSLerr( SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } tkey = srvr_pub_pkey->pkey.ec; } srvr_group = EC_KEY_get0_group(tkey); srvr_ecpoint = EC_KEY_get0_public_key(tkey); if ((srvr_group == NULL) || (srvr_ecpoint == NULL)) { SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } if ((clnt_ecdh = EC_KEY_new()) == NULL) { SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } if (!EC_KEY_set_group(clnt_ecdh, srvr_group)) { SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); goto err; } if (ecdh_clnt_cert) { /* * Reuse key info from our certificate * We only need our private key to perform * the ECDH computation. */ const BIGNUM *priv_key; tkey = s->cert->key->privatekey->pkey.ec; priv_key = EC_KEY_get0_private_key(tkey); if (priv_key == NULL) { SSLerr( SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } if (!EC_KEY_set_private_key(clnt_ecdh, priv_key)) { SSLerr( SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); goto err; } } else { /* Generate a new ECDH key pair */ if (!(EC_KEY_generate_key(clnt_ecdh))) { SSLerr( SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } } /* * Use the 'p' output buffer for the ECDH key, but * make sure to clear it out afterwards. */ field_size = EC_GROUP_get_degree(srvr_group); if (field_size <= 0) { SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } n = ECDH_compute_key(p, (field_size + 7)/8, srvr_ecpoint, clnt_ecdh, NULL); if (n <= 0) { SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } /* generate master key from the result */ s->session->master_key_length = s->method->ssl3_enc \ -> generate_master_secret(s, s->session->master_key, p, n); memset(p, 0, n); /* clean up */ if (ecdh_clnt_cert) { /* Send empty client key exch message. */ n = 0; } else { /* * First check the size of encoding and * allocate memory accordingly. */ encoded_pt_len = EC_POINT_point2oct( srvr_group, EC_KEY_get0_public_key(clnt_ecdh), POINT_CONVERSION_UNCOMPRESSED, NULL, 0, NULL); encodedPoint = malloc(encoded_pt_len); bn_ctx = BN_CTX_new(); if ((encodedPoint == NULL) || (bn_ctx == NULL)) { SSLerr( SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } /* Encode the public key */ n = EC_POINT_point2oct(srvr_group, EC_KEY_get0_public_key(clnt_ecdh), POINT_CONVERSION_UNCOMPRESSED, encodedPoint, encoded_pt_len, bn_ctx); *p = n; /* length of encoded point */ /* Encoded point will be copied here */ p += 1; /* copy the point */ memcpy((unsigned char *)p, encodedPoint, n); /* increment n to account for length field */ n += 1; } /* Free allocated memory */ BN_CTX_free(bn_ctx); free(encodedPoint); EC_KEY_free(clnt_ecdh); EVP_PKEY_free(srvr_pub_pkey); } else if (alg_k & SSL_kGOST) { /* GOST key exchange message creation */ EVP_PKEY_CTX *pkey_ctx; X509 *peer_cert; size_t msglen; unsigned int md_len; int keytype; unsigned char premaster_secret[32], shared_ukm[32], tmp[256]; EVP_MD_CTX *ukm_hash; EVP_PKEY *pub_key; /* Get server sertificate PKEY and create ctx from it */ peer_cert = s->session->sess_cert->peer_pkeys[( keytype = SSL_PKEY_GOST01)].x509; if (!peer_cert) peer_cert = s->session->sess_cert->peer_pkeys[ (keytype = SSL_PKEY_GOST94)].x509; if (!peer_cert) { SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER); goto err; } pkey_ctx = EVP_PKEY_CTX_new( pub_key = X509_get_pubkey(peer_cert), NULL); /* * If we have send a certificate, and certificate key * parameters match those of server certificate, use * certificate key for key exchange. * Otherwise, generate ephemeral key pair. */ EVP_PKEY_encrypt_init(pkey_ctx); /* Generate session key. */ RAND_bytes(premaster_secret, 32); /* * If we have client certificate, use its secret * as peer key. */ if (s->s3->tmp.cert_req && s->cert->key->privatekey) { if (EVP_PKEY_derive_set_peer(pkey_ctx, s->cert->key->privatekey) <=0) { /* * If there was an error - * just ignore it. Ephemeral key * would be used */ ERR_clear_error(); } } /* * Compute shared IV and store it in algorithm-specific * context data */ ukm_hash = EVP_MD_CTX_create(); if (ukm_hash == NULL) { SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } EVP_DigestInit(ukm_hash, EVP_get_digestbynid(NID_id_GostR3411_94)); EVP_DigestUpdate(ukm_hash, s->s3->client_random, SSL3_RANDOM_SIZE); EVP_DigestUpdate(ukm_hash, s->s3->server_random, SSL3_RANDOM_SIZE); EVP_DigestFinal_ex(ukm_hash, shared_ukm, &md_len); EVP_MD_CTX_destroy(ukm_hash); if (EVP_PKEY_CTX_ctrl(pkey_ctx, -1, EVP_PKEY_OP_ENCRYPT, EVP_PKEY_CTRL_SET_IV, 8, shared_ukm) < 0) { SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, SSL_R_LIBRARY_BUG); goto err; } /* * Make GOST keytransport blob message, * encapsulate it into sequence. */ *(p++) = V_ASN1_SEQUENCE | V_ASN1_CONSTRUCTED; msglen = 255; if (EVP_PKEY_encrypt(pkey_ctx, tmp, &msglen, premaster_secret, 32) < 0) { SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, SSL_R_LIBRARY_BUG); goto err; } if (msglen >= 0x80) { *(p++) = 0x81; *(p++) = msglen & 0xff; n = msglen + 3; } else { *(p++) = msglen & 0xff; n = msglen + 2; } memcpy(p, tmp, msglen); /* Check if pubkey from client certificate was used. */ if (EVP_PKEY_CTX_ctrl(pkey_ctx, -1, -1, EVP_PKEY_CTRL_PEER_KEY, 2, NULL) > 0) { /* Set flag "skip certificate verify". */ s->s3->flags |= TLS1_FLAGS_SKIP_CERT_VERIFY; } EVP_PKEY_CTX_free(pkey_ctx); s->session->master_key_length = s->method->ssl3_enc->generate_master_secret(s, s->session->master_key, premaster_secret, 32); EVP_PKEY_free(pub_key); } else { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } *(d++) = SSL3_MT_CLIENT_KEY_EXCHANGE; l2n3(n, d); s->state = SSL3_ST_CW_KEY_EXCH_B; /* number of bytes to write */ s->init_num = n + 4; s->init_off = 0; } /* SSL3_ST_CW_KEY_EXCH_B */ return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); err: BN_CTX_free(bn_ctx); free(encodedPoint); EC_KEY_free(clnt_ecdh); EVP_PKEY_free(srvr_pub_pkey); return (-1); } int ssl3_send_client_verify(SSL *s) { unsigned char *p, *d; unsigned char data[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH]; EVP_PKEY *pkey; EVP_PKEY_CTX *pctx = NULL; EVP_MD_CTX mctx; unsigned u = 0; unsigned long n; int j; EVP_MD_CTX_init(&mctx); if (s->state == SSL3_ST_CW_CERT_VRFY_A) { d = (unsigned char *)s->init_buf->data; p = &(d[4]); pkey = s->cert->key->privatekey; /* * Create context from key and test if sha1 is allowed as * digest. */ pctx = EVP_PKEY_CTX_new(pkey, NULL); EVP_PKEY_sign_init(pctx); if (EVP_PKEY_CTX_set_signature_md(pctx, EVP_sha1()) > 0) { if (!SSL_USE_SIGALGS(s)) s->method->ssl3_enc->cert_verify_mac(s, NID_sha1, &(data[MD5_DIGEST_LENGTH])); } else { ERR_clear_error(); } /* * For TLS v1.2 send signature algorithm and signature * using agreed digest and cached handshake records. */ if (SSL_USE_SIGALGS(s)) { long hdatalen = 0; void *hdata; const EVP_MD *md = s->cert->key->digest; hdatalen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata); if (hdatalen <= 0 || !tls12_get_sigandhash(p, pkey, md)) { SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_INTERNAL_ERROR); goto err; } p += 2; if (!EVP_SignInit_ex(&mctx, md, NULL) || !EVP_SignUpdate(&mctx, hdata, hdatalen) || !EVP_SignFinal(&mctx, p + 2, &u, pkey)) { SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_EVP_LIB); goto err; } s2n(u, p); n = u + 4; if (!ssl3_digest_cached_records(s)) goto err; } else if (pkey->type == EVP_PKEY_RSA) { s->method->ssl3_enc->cert_verify_mac( s, NID_md5, &(data[0])); if (RSA_sign(NID_md5_sha1, data, MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, &(p[2]), &u, pkey->pkey.rsa) <= 0 ) { SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_RSA_LIB); goto err; } s2n(u, p); n = u + 2; } else if (pkey->type == EVP_PKEY_DSA) { if (!DSA_sign(pkey->save_type, &(data[MD5_DIGEST_LENGTH]), SHA_DIGEST_LENGTH, &(p[2]), (unsigned int *)&j, pkey->pkey.dsa)) { SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_DSA_LIB); goto err; } s2n(j, p); n = j + 2; } else if (pkey->type == EVP_PKEY_EC) { if (!ECDSA_sign(pkey->save_type, &(data[MD5_DIGEST_LENGTH]), SHA_DIGEST_LENGTH, &(p[2]), (unsigned int *)&j, pkey->pkey.ec)) { SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_ECDSA_LIB); goto err; } s2n(j, p); n = j + 2; } else if (pkey->type == NID_id_GostR3410_94 || pkey->type == NID_id_GostR3410_2001) { unsigned char signbuf[64]; int i; size_t sigsize = 64; s->method->ssl3_enc->cert_verify_mac(s, NID_id_GostR3411_94, data); if (EVP_PKEY_sign(pctx, signbuf, &sigsize, data, 32) <= 0) { SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_INTERNAL_ERROR); goto err; } for (i = 63, j = 0; i >= 0; j++, i--) { p[2 + j] = signbuf[i]; } s2n(j, p); n = j + 2; } else { SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_INTERNAL_ERROR); goto err; } *(d++) = SSL3_MT_CERTIFICATE_VERIFY; l2n3(n, d); s->state = SSL3_ST_CW_CERT_VRFY_B; s->init_num = (int)n + 4; s->init_off = 0; } EVP_MD_CTX_cleanup(&mctx); EVP_PKEY_CTX_free(pctx); return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); err: EVP_MD_CTX_cleanup(&mctx); EVP_PKEY_CTX_free(pctx); return (-1); } int ssl3_send_client_certificate(SSL *s) { X509 *x509 = NULL; EVP_PKEY *pkey = NULL; int i; unsigned long l; if (s->state == SSL3_ST_CW_CERT_A) { if ((s->cert == NULL) || (s->cert->key->x509 == NULL) || (s->cert->key->privatekey == NULL)) s->state = SSL3_ST_CW_CERT_B; else s->state = SSL3_ST_CW_CERT_C; } /* We need to get a client cert */ if (s->state == SSL3_ST_CW_CERT_B) { /* * If we get an error, we need to * ssl->rwstate=SSL_X509_LOOKUP; return(-1); * We then get retied later */ i = ssl_do_client_cert_cb(s, &x509, &pkey); if (i < 0) { s->rwstate = SSL_X509_LOOKUP; return (-1); } s->rwstate = SSL_NOTHING; if ((i == 1) && (pkey != NULL) && (x509 != NULL)) { s->state = SSL3_ST_CW_CERT_B; if (!SSL_use_certificate(s, x509) || !SSL_use_PrivateKey(s, pkey)) i = 0; } else if (i == 1) { i = 0; SSLerr(SSL_F_SSL3_SEND_CLIENT_CERTIFICATE, SSL_R_BAD_DATA_RETURNED_BY_CALLBACK); } if (x509 != NULL) X509_free(x509); EVP_PKEY_free(pkey); if (i == 0) { if (s->version == SSL3_VERSION) { s->s3->tmp.cert_req = 0; ssl3_send_alert(s, SSL3_AL_WARNING, SSL_AD_NO_CERTIFICATE); return (1); } else { s->s3->tmp.cert_req = 2; } } /* Ok, we have a cert */ s->state = SSL3_ST_CW_CERT_C; } if (s->state == SSL3_ST_CW_CERT_C) { s->state = SSL3_ST_CW_CERT_D; l = ssl3_output_cert_chain(s, (s->s3->tmp.cert_req == 2) ? NULL : s->cert->key->x509); s->init_num = (int)l; s->init_off = 0; } /* SSL3_ST_CW_CERT_D */ return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); } #define has_bits(i,m) (((i)&(m)) == (m)) int ssl3_check_cert_and_algorithm(SSL *s) { int i, idx; long alg_k, alg_a; EVP_PKEY *pkey = NULL; SESS_CERT *sc; RSA *rsa; DH *dh; alg_k = s->s3->tmp.new_cipher->algorithm_mkey; alg_a = s->s3->tmp.new_cipher->algorithm_auth; /* We don't have a certificate. */ if ((alg_a & (SSL_aDH|SSL_aNULL|SSL_aKRB5)) || (alg_k & SSL_kPSK)) return (1); sc = s->session->sess_cert; if (sc == NULL) { SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, ERR_R_INTERNAL_ERROR); goto err; } rsa = s->session->sess_cert->peer_rsa_tmp; dh = s->session->sess_cert->peer_dh_tmp; /* This is the passed certificate. */ idx = sc->peer_cert_type; if (idx == SSL_PKEY_ECC) { if (ssl_check_srvr_ecc_cert_and_alg(sc->peer_pkeys[idx].x509, s) == 0) { /* check failed */ SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_BAD_ECC_CERT); goto f_err; } else { return (1); } } pkey = X509_get_pubkey(sc->peer_pkeys[idx].x509); i = X509_certificate_type(sc->peer_pkeys[idx].x509, pkey); EVP_PKEY_free(pkey); /* Check that we have a certificate if we require one */ if ((alg_a & SSL_aRSA) && !has_bits(i, EVP_PK_RSA|EVP_PKT_SIGN)) { SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_RSA_SIGNING_CERT); goto f_err; } else if ((alg_a & SSL_aDSS) && !has_bits(i, EVP_PK_DSA|EVP_PKT_SIGN)) { SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_DSA_SIGNING_CERT); goto f_err; } if ((alg_k & SSL_kRSA) && !(has_bits(i, EVP_PK_RSA|EVP_PKT_ENC) || (rsa != NULL))) { SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_RSA_ENCRYPTING_CERT); goto f_err; } if ((alg_k & SSL_kEDH) && !(has_bits(i, EVP_PK_DH|EVP_PKT_EXCH) || (dh != NULL))) { SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_DH_KEY); goto f_err; } else if ((alg_k & SSL_kDHr) && !has_bits(i, EVP_PK_DH|EVP_PKS_RSA)) { SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_DH_RSA_CERT); goto f_err; } else if ((alg_k & SSL_kDHd) && !has_bits(i, EVP_PK_DH|EVP_PKS_DSA)) { SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_DH_DSA_CERT); goto f_err; } return (1); f_err: ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); err: return (0); } #ifndef OPENSSL_NO_NEXTPROTONEG int ssl3_send_next_proto(SSL *s) { unsigned int len, padding_len; unsigned char *d; if (s->state == SSL3_ST_CW_NEXT_PROTO_A) { len = s->next_proto_negotiated_len; padding_len = 32 - ((len + 2) % 32); d = (unsigned char *)s->init_buf->data; d[4] = len; memcpy(d + 5, s->next_proto_negotiated, len); d[5 + len] = padding_len; memset(d + 6 + len, 0, padding_len); *(d++) = SSL3_MT_NEXT_PROTO; l2n3(2 + len + padding_len, d); s->state = SSL3_ST_CW_NEXT_PROTO_B; s->init_num = 4 + 2 + len + padding_len; s->init_off = 0; } return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); } #endif /* !OPENSSL_NO_NEXTPROTONEG */ /* * Check to see if handshake is full or resumed. Usually this is just a * case of checking to see if a cache hit has occurred. In the case of * session tickets we have to check the next message to be sure. */ int ssl3_check_finished(SSL *s) { int ok; long n; /* If we have no ticket it cannot be a resumed session. */ if (!s->session->tlsext_tick) return (1); /* this function is called when we really expect a Certificate * message, so permit appropriate message length */ n = s->method->ssl_get_message(s, SSL3_ST_CR_CERT_A, SSL3_ST_CR_CERT_B, -1, s->max_cert_list, &ok); if (!ok) return ((int)n); s->s3->tmp.reuse_message = 1; if ((s->s3->tmp.message_type == SSL3_MT_FINISHED) || (s->s3->tmp.message_type == SSL3_MT_NEWSESSION_TICKET)) return (2); return (1); } int ssl_do_client_cert_cb(SSL *s, X509 **px509, EVP_PKEY **ppkey) { int i = 0; #ifndef OPENSSL_NO_ENGINE if (s->ctx->client_cert_engine) { i = ENGINE_load_ssl_client_cert(s->ctx->client_cert_engine, s, SSL_get_client_CA_list(s), px509, ppkey, NULL, NULL, NULL); if (i != 0) return (i); } #endif if (s->ctx->client_cert_cb) i = s->ctx->client_cert_cb(s, px509, ppkey); return (i); } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/pqueue.c0000644000175000017500000001131212360020705017202 0ustar /* $OpenBSD$ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. */ /* ==================================================================== * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "pqueue.h" typedef struct _pqueue { pitem *items; int count; } pqueue_s; pitem * pitem_new(unsigned char *prio64be, void *data) { pitem *item = malloc(sizeof(pitem)); if (item == NULL) return NULL; memcpy(item->priority, prio64be, sizeof(item->priority)); item->data = data; item->next = NULL; return item; } void pitem_free(pitem *item) { free(item); } pqueue_s * pqueue_new(void) { return calloc(1, sizeof(pqueue_s)); } void pqueue_free(pqueue_s *pq) { free(pq); } pitem * pqueue_insert(pqueue_s *pq, pitem *item) { pitem *curr, *next; if (pq->items == NULL) { pq->items = item; return item; } for (curr = NULL, next = pq->items; next != NULL; curr = next, next = next->next) { /* we can compare 64-bit value in big-endian encoding * with memcmp:-) */ int cmp = memcmp(next->priority, item->priority, sizeof(item->priority)); if (cmp > 0) { /* next > item */ item->next = next; if (curr == NULL) pq->items = item; else curr->next = item; return item; } else if (cmp == 0) /* duplicates not allowed */ return NULL; } item->next = NULL; curr->next = item; return item; } pitem * pqueue_peek(pqueue_s *pq) { return pq->items; } pitem * pqueue_pop(pqueue_s *pq) { pitem *item = pq->items; if (pq->items != NULL) pq->items = pq->items->next; return item; } pitem * pqueue_find(pqueue_s *pq, unsigned char *prio64be) { pitem *next; for (next = pq->items; next != NULL; next = next->next) if (memcmp(next->priority, prio64be, sizeof(next->priority)) == 0) return next; return NULL; } pitem * pqueue_iterator(pqueue_s *pq) { return pqueue_peek(pq); } pitem * pqueue_next(pitem **item) { pitem *ret; if (item == NULL || *item == NULL) return NULL; /* *item != NULL */ ret = *item; *item = (*item)->next; return ret; } int pqueue_size(pqueue_s *pq) { pitem *item = pq->items; int count = 0; while (item != NULL) { count++; item = item->next; } return count; } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/d1_both.c0000644000175000017500000011441312360020705017224 0ustar /* $OpenBSD: d1_both.c,v 1.23 2014/07/10 08:25:00 guenther Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. */ /* ==================================================================== * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include "ssl_locl.h" #include #include #include #include #include #include "pqueue.h" #define RSMBLY_BITMASK_SIZE(msg_len) (((msg_len) + 7) / 8) #define RSMBLY_BITMASK_MARK(bitmask, start, end) { \ if ((end) - (start) <= 8) { \ long ii; \ for (ii = (start); ii < (end); ii++) bitmask[((ii) >> 3)] |= (1 << ((ii) & 7)); \ } else { \ long ii; \ bitmask[((start) >> 3)] |= bitmask_start_values[((start) & 7)]; \ for (ii = (((start) >> 3) + 1); ii < ((((end) - 1)) >> 3); ii++) bitmask[ii] = 0xff; \ bitmask[(((end) - 1) >> 3)] |= bitmask_end_values[((end) & 7)]; \ } } #define RSMBLY_BITMASK_IS_COMPLETE(bitmask, msg_len, is_complete) { \ long ii; \ OPENSSL_assert((msg_len) > 0); \ is_complete = 1; \ if (bitmask[(((msg_len) - 1) >> 3)] != bitmask_end_values[((msg_len) & 7)]) is_complete = 0; \ if (is_complete) for (ii = (((msg_len) - 1) >> 3) - 1; ii >= 0 ; ii--) \ if (bitmask[ii] != 0xff) { is_complete = 0; break; } } static unsigned char bitmask_start_values[] = { 0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80 }; static unsigned char bitmask_end_values[] = { 0xff, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f }; /* XDTLS: figure out the right values */ static unsigned int g_probable_mtu[] = {1500 - 28, 512 - 28, 256 - 28}; static unsigned int dtls1_guess_mtu(unsigned int curr_mtu); static void dtls1_fix_message_header(SSL *s, unsigned long frag_off, unsigned long frag_len); static unsigned char *dtls1_write_message_header(SSL *s, unsigned char *p); static void dtls1_set_message_header_int(SSL *s, unsigned char mt, unsigned long len, unsigned short seq_num, unsigned long frag_off, unsigned long frag_len); static long dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok); static hm_fragment * dtls1_hm_fragment_new(unsigned long frag_len, int reassembly) { hm_fragment *frag = NULL; unsigned char *buf = NULL; unsigned char *bitmask = NULL; frag = malloc(sizeof(hm_fragment)); if (frag == NULL) return NULL; if (frag_len) { buf = malloc(frag_len); if (buf == NULL) { free(frag); return NULL; } } /* zero length fragment gets zero frag->fragment */ frag->fragment = buf; /* Initialize reassembly bitmask if necessary */ if (reassembly) { bitmask = malloc(RSMBLY_BITMASK_SIZE(frag_len)); if (bitmask == NULL) { free(buf); free(frag); return NULL; } memset(bitmask, 0, RSMBLY_BITMASK_SIZE(frag_len)); } frag->reassembly = bitmask; return frag; } static void dtls1_hm_fragment_free(hm_fragment *frag) { if (frag->msg_header.is_ccs) { EVP_CIPHER_CTX_free( frag->msg_header.saved_retransmit_state.enc_write_ctx); EVP_MD_CTX_destroy( frag->msg_header.saved_retransmit_state.write_hash); } free(frag->fragment); free(frag->reassembly); free(frag); } /* send s->init_buf in records of type 'type' (SSL3_RT_HANDSHAKE or SSL3_RT_CHANGE_CIPHER_SPEC) */ int dtls1_do_write(SSL *s, int type) { int ret; int curr_mtu; unsigned int len, frag_off, mac_size, blocksize; /* AHA! Figure out the MTU, and stick to the right size */ if (s->d1->mtu < dtls1_min_mtu() && !(SSL_get_options(s) & SSL_OP_NO_QUERY_MTU)) { s->d1->mtu = BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_QUERY_MTU, 0, NULL); /* * I've seen the kernel return bogus numbers when it * doesn't know the MTU (ie., the initial write), so just * make sure we have a reasonable number */ if (s->d1->mtu < dtls1_min_mtu()) { s->d1->mtu = 0; s->d1->mtu = dtls1_guess_mtu(s->d1->mtu); BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SET_MTU, s->d1->mtu, NULL); } } OPENSSL_assert(s->d1->mtu >= dtls1_min_mtu()); /* should have something reasonable now */ if (s->init_off == 0 && type == SSL3_RT_HANDSHAKE) OPENSSL_assert(s->init_num == (int)s->d1->w_msg_hdr.msg_len + DTLS1_HM_HEADER_LENGTH); if (s->write_hash) mac_size = EVP_MD_CTX_size(s->write_hash); else mac_size = 0; if (s->enc_write_ctx && (EVP_CIPHER_mode( s->enc_write_ctx->cipher) & EVP_CIPH_CBC_MODE)) blocksize = 2 * EVP_CIPHER_block_size(s->enc_write_ctx->cipher); else blocksize = 0; frag_off = 0; while (s->init_num) { curr_mtu = s->d1->mtu - BIO_wpending(SSL_get_wbio(s)) - DTLS1_RT_HEADER_LENGTH - mac_size - blocksize; if (curr_mtu <= DTLS1_HM_HEADER_LENGTH) { /* grr.. we could get an error if MTU picked was wrong */ ret = BIO_flush(SSL_get_wbio(s)); if (ret <= 0) return ret; curr_mtu = s->d1->mtu - DTLS1_RT_HEADER_LENGTH - mac_size - blocksize; } if (s->init_num > curr_mtu) len = curr_mtu; else len = s->init_num; /* XDTLS: this function is too long. split out the CCS part */ if (type == SSL3_RT_HANDSHAKE) { if (s->init_off != 0) { OPENSSL_assert(s->init_off > DTLS1_HM_HEADER_LENGTH); s->init_off -= DTLS1_HM_HEADER_LENGTH; s->init_num += DTLS1_HM_HEADER_LENGTH; if (s->init_num > curr_mtu) len = curr_mtu; else len = s->init_num; } dtls1_fix_message_header(s, frag_off, len - DTLS1_HM_HEADER_LENGTH); dtls1_write_message_header(s, (unsigned char *)&s->init_buf->data[s->init_off]); OPENSSL_assert(len >= DTLS1_HM_HEADER_LENGTH); } ret = dtls1_write_bytes(s, type, &s->init_buf->data[s->init_off], len); if (ret < 0) { /* * Might need to update MTU here, but we don't know * which previous packet caused the failure -- so * can't really retransmit anything. continue as * if everything is fine and wait for an alert to * handle the retransmit */ if (BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_MTU_EXCEEDED, 0, NULL) > 0) s->d1->mtu = BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_QUERY_MTU, 0, NULL); else return (-1); } else { /* * Bad if this assert fails, only part of the * handshake message got sent. but why would * this happen? */ OPENSSL_assert(len == (unsigned int)ret); if (type == SSL3_RT_HANDSHAKE && !s->d1->retransmitting) { /* * Should not be done for 'Hello Request's, * but in that case we'll ignore the result * anyway */ unsigned char *p = (unsigned char *)&s->init_buf->data[s->init_off]; const struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr; int xlen; if (frag_off == 0 && s->version != DTLS1_BAD_VER) { /* * Reconstruct message header is if it * is being sent in single fragment */ *p++ = msg_hdr->type; l2n3(msg_hdr->msg_len, p); s2n (msg_hdr->seq, p); l2n3(0, p); l2n3(msg_hdr->msg_len, p); p -= DTLS1_HM_HEADER_LENGTH; xlen = ret; } else { p += DTLS1_HM_HEADER_LENGTH; xlen = ret - DTLS1_HM_HEADER_LENGTH; } ssl3_finish_mac(s, p, xlen); } if (ret == s->init_num) { if (s->msg_callback) s->msg_callback(1, s->version, type, s->init_buf->data, (size_t)(s->init_off + s->init_num), s, s->msg_callback_arg); s->init_off = 0; /* done writing this message */ s->init_num = 0; return (1); } s->init_off += ret; s->init_num -= ret; frag_off += (ret -= DTLS1_HM_HEADER_LENGTH); } } return (0); } /* * Obtain handshake message of message type 'mt' (any if mt == -1), * maximum acceptable body length 'max'. * Read an entire handshake message. Handshake messages arrive in * fragments. */ long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok) { int i, al; struct hm_header_st *msg_hdr; unsigned char *p; unsigned long msg_len; /* * s3->tmp is used to store messages that are unexpected, caused * by the absence of an optional handshake message */ if (s->s3->tmp.reuse_message) { s->s3->tmp.reuse_message = 0; if ((mt >= 0) && (s->s3->tmp.message_type != mt)) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_DTLS1_GET_MESSAGE, SSL_R_UNEXPECTED_MESSAGE); goto f_err; } *ok = 1; s->init_msg = s->init_buf->data + DTLS1_HM_HEADER_LENGTH; s->init_num = (int)s->s3->tmp.message_size; return s->init_num; } msg_hdr = &s->d1->r_msg_hdr; memset(msg_hdr, 0x00, sizeof(struct hm_header_st)); again: i = dtls1_get_message_fragment(s, st1, stn, max, ok); if (i == DTLS1_HM_BAD_FRAGMENT || i == DTLS1_HM_FRAGMENT_RETRY) /* bad fragment received */ goto again; else if (i <= 0 && !*ok) return i; p = (unsigned char *)s->init_buf->data; msg_len = msg_hdr->msg_len; /* reconstruct message header */ *(p++) = msg_hdr->type; l2n3(msg_len, p); s2n (msg_hdr->seq, p); l2n3(0, p); l2n3(msg_len, p); if (s->version != DTLS1_BAD_VER) { p -= DTLS1_HM_HEADER_LENGTH; msg_len += DTLS1_HM_HEADER_LENGTH; } ssl3_finish_mac(s, p, msg_len); if (s->msg_callback) s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, p, msg_len, s, s->msg_callback_arg); memset(msg_hdr, 0x00, sizeof(struct hm_header_st)); /* Don't change sequence numbers while listening */ if (!s->d1->listen) s->d1->handshake_read_seq++; s->init_msg = s->init_buf->data + DTLS1_HM_HEADER_LENGTH; return s->init_num; f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); *ok = 0; return -1; } static int dtls1_preprocess_fragment(SSL *s, struct hm_header_st *msg_hdr, int max) { size_t frag_off, frag_len, msg_len; msg_len = msg_hdr->msg_len; frag_off = msg_hdr->frag_off; frag_len = msg_hdr->frag_len; /* sanity checking */ if ((frag_off + frag_len) > msg_len) { SSLerr(SSL_F_DTLS1_PREPROCESS_FRAGMENT, SSL_R_EXCESSIVE_MESSAGE_SIZE); return SSL_AD_ILLEGAL_PARAMETER; } if ((frag_off + frag_len) > (unsigned long)max) { SSLerr(SSL_F_DTLS1_PREPROCESS_FRAGMENT, SSL_R_EXCESSIVE_MESSAGE_SIZE); return SSL_AD_ILLEGAL_PARAMETER; } if ( s->d1->r_msg_hdr.frag_off == 0) /* first fragment */ { /* * msg_len is limited to 2^24, but is effectively checked * against max above */ if (!BUF_MEM_grow_clean(s->init_buf, msg_len + DTLS1_HM_HEADER_LENGTH)) { SSLerr(SSL_F_DTLS1_PREPROCESS_FRAGMENT, ERR_R_BUF_LIB); return SSL_AD_INTERNAL_ERROR; } s->s3->tmp.message_size = msg_len; s->d1->r_msg_hdr.msg_len = msg_len; s->s3->tmp.message_type = msg_hdr->type; s->d1->r_msg_hdr.type = msg_hdr->type; s->d1->r_msg_hdr.seq = msg_hdr->seq; } else if (msg_len != s->d1->r_msg_hdr.msg_len) { /* * They must be playing with us! BTW, failure to enforce * upper limit would open possibility for buffer overrun. */ SSLerr(SSL_F_DTLS1_PREPROCESS_FRAGMENT, SSL_R_EXCESSIVE_MESSAGE_SIZE); return SSL_AD_ILLEGAL_PARAMETER; } return 0; /* no error */ } static int dtls1_retrieve_buffered_fragment(SSL *s, long max, int *ok) { /* * (0) check whether the desired fragment is available * if so: * (1) copy over the fragment to s->init_buf->data[] * (2) update s->init_num */ pitem *item; hm_fragment *frag; int al; *ok = 0; item = pqueue_peek(s->d1->buffered_messages); if (item == NULL) return 0; frag = (hm_fragment *)item->data; /* Don't return if reassembly still in progress */ if (frag->reassembly != NULL) return 0; if (s->d1->handshake_read_seq == frag->msg_header.seq) { unsigned long frag_len = frag->msg_header.frag_len; pqueue_pop(s->d1->buffered_messages); al = dtls1_preprocess_fragment(s, &frag->msg_header, max); if (al == 0) /* no alert */ { unsigned char *p = (unsigned char *)s->init_buf->data + DTLS1_HM_HEADER_LENGTH; memcpy(&p[frag->msg_header.frag_off], frag->fragment, frag->msg_header.frag_len); } dtls1_hm_fragment_free(frag); pitem_free(item); if (al == 0) { *ok = 1; return frag_len; } ssl3_send_alert(s, SSL3_AL_FATAL, al); s->init_num = 0; *ok = 0; return -1; } else return 0; } static int dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok) { hm_fragment *frag = NULL; pitem *item = NULL; int i = -1, is_complete; unsigned char seq64be[8]; unsigned long frag_len = msg_hdr->frag_len, max_len; if ((msg_hdr->frag_off + frag_len) > msg_hdr->msg_len) goto err; /* * Determine maximum allowed message size. Depends on (user set) * maximum certificate length, but 16k is minimum. */ if (DTLS1_HM_HEADER_LENGTH + SSL3_RT_MAX_ENCRYPTED_LENGTH < s->max_cert_list) max_len = s->max_cert_list; else max_len = DTLS1_HM_HEADER_LENGTH + SSL3_RT_MAX_ENCRYPTED_LENGTH; if ((msg_hdr->frag_off + frag_len) > max_len) goto err; /* Try to find item in queue */ memset(seq64be, 0, sizeof(seq64be)); seq64be[6] = (unsigned char)(msg_hdr->seq >> 8); seq64be[7] = (unsigned char)msg_hdr->seq; item = pqueue_find(s->d1->buffered_messages, seq64be); if (item == NULL) { frag = dtls1_hm_fragment_new(msg_hdr->msg_len, 1); if (frag == NULL) goto err; memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr)); frag->msg_header.frag_len = frag->msg_header.msg_len; frag->msg_header.frag_off = 0; } else { frag = (hm_fragment*)item->data; if (frag->msg_header.msg_len != msg_hdr->msg_len) { item = NULL; frag = NULL; goto err; } } /* * If message is already reassembled, this must be a * retransmit and can be dropped. */ if (frag->reassembly == NULL) { unsigned char devnull [256]; while (frag_len) { i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, devnull, frag_len > sizeof(devnull) ? sizeof(devnull) : frag_len, 0); if (i <= 0) goto err; frag_len -= i; } i = DTLS1_HM_FRAGMENT_RETRY; goto err; } /* read the body of the fragment (header has already been read */ i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, frag->fragment + msg_hdr->frag_off, frag_len, 0); if (i <= 0 || (unsigned long)i != frag_len) goto err; RSMBLY_BITMASK_MARK(frag->reassembly, (long)msg_hdr->frag_off, (long)(msg_hdr->frag_off + frag_len)); RSMBLY_BITMASK_IS_COMPLETE(frag->reassembly, (long)msg_hdr->msg_len, is_complete); if (is_complete) { free(frag->reassembly); frag->reassembly = NULL; } if (item == NULL) { memset(seq64be, 0, sizeof(seq64be)); seq64be[6] = (unsigned char)(msg_hdr->seq >> 8); seq64be[7] = (unsigned char)(msg_hdr->seq); item = pitem_new(seq64be, frag); if (item == NULL) { i = -1; goto err; } pqueue_insert(s->d1->buffered_messages, item); } return DTLS1_HM_FRAGMENT_RETRY; err: if (item == NULL && frag != NULL) dtls1_hm_fragment_free(frag); *ok = 0; return i; } static int dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok) { int i = -1; hm_fragment *frag = NULL; pitem *item = NULL; unsigned char seq64be[8]; unsigned long frag_len = msg_hdr->frag_len; if ((msg_hdr->frag_off + frag_len) > msg_hdr->msg_len) goto err; /* Try to find item in queue, to prevent duplicate entries */ memset(seq64be, 0, sizeof(seq64be)); seq64be[6] = (unsigned char) (msg_hdr->seq >> 8); seq64be[7] = (unsigned char) msg_hdr->seq; item = pqueue_find(s->d1->buffered_messages, seq64be); /* * If we already have an entry and this one is a fragment, * don't discard it and rather try to reassemble it. */ if (item != NULL && frag_len < msg_hdr->msg_len) item = NULL; /* * Discard the message if sequence number was already there, is * too far in the future, already in the queue or if we received * a FINISHED before the SERVER_HELLO, which then must be a stale * retransmit. */ if (msg_hdr->seq <= s->d1->handshake_read_seq || msg_hdr->seq > s->d1->handshake_read_seq + 10 || item != NULL || (s->d1->handshake_read_seq == 0 && msg_hdr->type == SSL3_MT_FINISHED)) { unsigned char devnull [256]; while (frag_len) { i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, devnull, frag_len > sizeof(devnull) ? sizeof(devnull) : frag_len, 0); if (i <= 0) goto err; frag_len -= i; } } else { if (frag_len && frag_len < msg_hdr->msg_len) return dtls1_reassemble_fragment(s, msg_hdr, ok); frag = dtls1_hm_fragment_new(frag_len, 0); if (frag == NULL) goto err; memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr)); if (frag_len) { /* read the body of the fragment (header has already been read */ i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, frag->fragment, frag_len, 0); if (i <= 0 || (unsigned long)i != frag_len) goto err; } memset(seq64be, 0, sizeof(seq64be)); seq64be[6] = (unsigned char)(msg_hdr->seq >> 8); seq64be[7] = (unsigned char)(msg_hdr->seq); item = pitem_new(seq64be, frag); if (item == NULL) goto err; pqueue_insert(s->d1->buffered_messages, item); } return DTLS1_HM_FRAGMENT_RETRY; err: if (item == NULL && frag != NULL) dtls1_hm_fragment_free(frag); *ok = 0; return i; } static long dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok) { unsigned char wire[DTLS1_HM_HEADER_LENGTH]; unsigned long len, frag_off, frag_len; int i, al; struct hm_header_st msg_hdr; again: /* see if we have the required fragment already */ if ((frag_len = dtls1_retrieve_buffered_fragment(s, max, ok)) || *ok) { if (*ok) s->init_num = frag_len; return frag_len; } /* read handshake message header */ i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, wire, DTLS1_HM_HEADER_LENGTH, 0); if (i <= 0) /* nbio, or an error */ { s->rwstate = SSL_READING; *ok = 0; return i; } /* Handshake fails if message header is incomplete */ if (i != DTLS1_HM_HEADER_LENGTH) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT, SSL_R_UNEXPECTED_MESSAGE); goto f_err; } /* parse the message fragment header */ dtls1_get_message_header(wire, &msg_hdr); /* * if this is a future (or stale) message it gets buffered * (or dropped)--no further processing at this time * While listening, we accept seq 1 (ClientHello with cookie) * although we're still expecting seq 0 (ClientHello) */ if (msg_hdr.seq != s->d1->handshake_read_seq && !(s->d1->listen && msg_hdr.seq == 1)) return dtls1_process_out_of_seq_message(s, &msg_hdr, ok); len = msg_hdr.msg_len; frag_off = msg_hdr.frag_off; frag_len = msg_hdr.frag_len; if (frag_len && frag_len < len) return dtls1_reassemble_fragment(s, &msg_hdr, ok); if (!s->server && s->d1->r_msg_hdr.frag_off == 0 && wire[0] == SSL3_MT_HELLO_REQUEST) { /* * The server may always send 'Hello Request' messages -- * we are doing a handshake anyway now, so ignore them * if their format is correct. Does not count for * 'Finished' MAC. */ if (wire[1] == 0 && wire[2] == 0 && wire[3] == 0) { if (s->msg_callback) s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, wire, DTLS1_HM_HEADER_LENGTH, s, s->msg_callback_arg); s->init_num = 0; goto again; } else /* Incorrectly formated Hello request */ { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT, SSL_R_UNEXPECTED_MESSAGE); goto f_err; } } if ((al = dtls1_preprocess_fragment(s, &msg_hdr, max))) goto f_err; /* XDTLS: ressurect this when restart is in place */ s->state = stn; if (frag_len > 0) { unsigned char *p = (unsigned char *)s->init_buf->data + DTLS1_HM_HEADER_LENGTH; i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, &p[frag_off], frag_len, 0); /* XDTLS: fix this--message fragments cannot span multiple packets */ if (i <= 0) { s->rwstate = SSL_READING; *ok = 0; return i; } } else i = 0; /* * XDTLS: an incorrectly formatted fragment should cause the * handshake to fail */ if (i != (int)frag_len) { al = SSL3_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT, SSL3_AD_ILLEGAL_PARAMETER); goto f_err; } *ok = 1; /* * Note that s->init_num is *not* used as current offset in * s->init_buf->data, but as a counter summing up fragments' * lengths: as soon as they sum up to handshake packet * length, we assume we have got all the fragments. */ s->init_num = frag_len; return frag_len; f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); s->init_num = 0; *ok = 0; return (-1); } int dtls1_send_finished(SSL *s, int a, int b, const char *sender, int slen) { unsigned char *p, *d; int i; unsigned long l; if (s->state == a) { d = (unsigned char *)s->init_buf->data; p = &(d[DTLS1_HM_HEADER_LENGTH]); i = s->method->ssl3_enc->final_finish_mac(s, sender, slen, s->s3->tmp.finish_md); s->s3->tmp.finish_md_len = i; memcpy(p, s->s3->tmp.finish_md, i); p += i; l = i; /* * Copy the finished so we can use it for * renegotiation checks */ if (s->type == SSL_ST_CONNECT) { OPENSSL_assert(i <= EVP_MAX_MD_SIZE); memcpy(s->s3->previous_client_finished, s->s3->tmp.finish_md, i); s->s3->previous_client_finished_len = i; } else { OPENSSL_assert(i <= EVP_MAX_MD_SIZE); memcpy(s->s3->previous_server_finished, s->s3->tmp.finish_md, i); s->s3->previous_server_finished_len = i; } d = dtls1_set_message_header(s, d, SSL3_MT_FINISHED, l, 0, l); s->init_num = (int)l + DTLS1_HM_HEADER_LENGTH; s->init_off = 0; /* buffer the message to handle re-xmits */ dtls1_buffer_message(s, 0); s->state = b; } /* SSL3_ST_SEND_xxxxxx_HELLO_B */ return (dtls1_do_write(s, SSL3_RT_HANDSHAKE)); } /* * for these 2 messages, we need to * ssl->enc_read_ctx re-init * ssl->s3->read_sequence zero * ssl->s3->read_mac_secret re-init * ssl->session->read_sym_enc assign * ssl->session->read_hash assign */ int dtls1_send_change_cipher_spec(SSL *s, int a, int b) { unsigned char *p; if (s->state == a) { p = (unsigned char *)s->init_buf->data; *p++=SSL3_MT_CCS; s->d1->handshake_write_seq = s->d1->next_handshake_write_seq; s->init_num = DTLS1_CCS_HEADER_LENGTH; if (s->version == DTLS1_BAD_VER) { s->d1->next_handshake_write_seq++; s2n(s->d1->handshake_write_seq, p); s->init_num += 2; } s->init_off = 0; dtls1_set_message_header_int(s, SSL3_MT_CCS, 0, s->d1->handshake_write_seq, 0, 0); /* buffer the message to handle re-xmits */ dtls1_buffer_message(s, 1); s->state = b; } /* SSL3_ST_CW_CHANGE_B */ return (dtls1_do_write(s, SSL3_RT_CHANGE_CIPHER_SPEC)); } static int dtls1_add_cert_to_buf(BUF_MEM *buf, unsigned long *l, X509 *x) { int n; unsigned char *p; n = i2d_X509(x, NULL); if (!BUF_MEM_grow_clean(buf, n + (*l) + 3)) { SSLerr(SSL_F_DTLS1_ADD_CERT_TO_BUF, ERR_R_BUF_LIB); return 0; } p = (unsigned char *)&(buf->data[*l]); l2n3(n, p); i2d_X509(x, &p); *l += n + 3; return 1; } unsigned long dtls1_output_cert_chain(SSL *s, X509 *x) { unsigned char *p; int i; unsigned long l = 3 + DTLS1_HM_HEADER_LENGTH; BUF_MEM *buf; /* TLSv1 sends a chain with nothing in it, instead of an alert */ buf = s->init_buf; if (!BUF_MEM_grow_clean(buf, 10)) { SSLerr(SSL_F_DTLS1_OUTPUT_CERT_CHAIN, ERR_R_BUF_LIB); return (0); } if (x != NULL) { X509_STORE_CTX xs_ctx; if (!X509_STORE_CTX_init(&xs_ctx, s->ctx->cert_store, x, NULL)) { SSLerr(SSL_F_DTLS1_OUTPUT_CERT_CHAIN, ERR_R_X509_LIB); return (0); } X509_verify_cert(&xs_ctx); /* Don't leave errors in the queue */ ERR_clear_error(); for (i = 0; i < sk_X509_num(xs_ctx.chain); i++) { x = sk_X509_value(xs_ctx.chain, i); if (!dtls1_add_cert_to_buf(buf, &l, x)) { X509_STORE_CTX_cleanup(&xs_ctx); return 0; } } X509_STORE_CTX_cleanup(&xs_ctx); } /* Thawte special :-) */ for (i = 0; i < sk_X509_num(s->ctx->extra_certs); i++) { x = sk_X509_value(s->ctx->extra_certs, i); if (!dtls1_add_cert_to_buf(buf, &l, x)) return 0; } l -= (3 + DTLS1_HM_HEADER_LENGTH); p = (unsigned char *)&(buf->data[DTLS1_HM_HEADER_LENGTH]); l2n3(l, p); l += 3; p = (unsigned char *)&(buf->data[0]); p = dtls1_set_message_header(s, p, SSL3_MT_CERTIFICATE, l, 0, l); l += DTLS1_HM_HEADER_LENGTH; return (l); } int dtls1_read_failed(SSL *s, int code) { if (code > 0) { fprintf(stderr, "invalid state reached %s:%d", __FILE__, __LINE__); return 1; } if (!dtls1_is_timer_expired(s)) { /* * not a timeout, none of our business, let higher layers * handle this. in fact it's probably an error */ return code; } if (!SSL_in_init(s)) /* done, no need to send a retransmit */ { BIO_set_flags(SSL_get_rbio(s), BIO_FLAGS_READ); return code; } return dtls1_handle_timeout(s); } int dtls1_get_queue_priority(unsigned short seq, int is_ccs) { /* * The index of the retransmission queue actually is the message * sequence number, since the queue only contains messages of a * single handshake. However, the ChangeCipherSpec has no message * sequence number and so using only the sequence will result in * the CCS and Finished having the same index. To prevent this, the * sequence number is multiplied by 2. In case of a CCS 1 is * subtracted. This does not only differ CSS and Finished, it also * maintains the order of the index (important for priority queues) * and fits in the unsigned short variable. */ return seq * 2 - is_ccs; } int dtls1_retransmit_buffered_messages(SSL *s) { pqueue sent = s->d1->sent_messages; piterator iter; pitem *item; hm_fragment *frag; int found = 0; iter = pqueue_iterator(sent); for (item = pqueue_next(&iter); item != NULL; item = pqueue_next(&iter)) { frag = (hm_fragment *)item->data; if (dtls1_retransmit_message(s, (unsigned short)dtls1_get_queue_priority( frag->msg_header.seq, frag->msg_header.is_ccs), 0, &found) <= 0 && found) { fprintf(stderr, "dtls1_retransmit_message() failed\n"); return -1; } } return 1; } int dtls1_buffer_message(SSL *s, int is_ccs) { pitem *item; hm_fragment *frag; unsigned char seq64be[8]; /* * This function is called immediately after a message has * been serialized */ OPENSSL_assert(s->init_off == 0); frag = dtls1_hm_fragment_new(s->init_num, 0); if (frag == NULL) return 0; memcpy(frag->fragment, s->init_buf->data, s->init_num); if (is_ccs) { OPENSSL_assert(s->d1->w_msg_hdr.msg_len + ((s->version == DTLS1_VERSION) ? DTLS1_CCS_HEADER_LENGTH : 3) == (unsigned int)s->init_num); } else { OPENSSL_assert(s->d1->w_msg_hdr.msg_len + DTLS1_HM_HEADER_LENGTH == (unsigned int)s->init_num); } frag->msg_header.msg_len = s->d1->w_msg_hdr.msg_len; frag->msg_header.seq = s->d1->w_msg_hdr.seq; frag->msg_header.type = s->d1->w_msg_hdr.type; frag->msg_header.frag_off = 0; frag->msg_header.frag_len = s->d1->w_msg_hdr.msg_len; frag->msg_header.is_ccs = is_ccs; /* save current state*/ frag->msg_header.saved_retransmit_state.enc_write_ctx = s->enc_write_ctx; frag->msg_header.saved_retransmit_state.write_hash = s->write_hash; frag->msg_header.saved_retransmit_state.session = s->session; frag->msg_header.saved_retransmit_state.epoch = s->d1->w_epoch; memset(seq64be, 0, sizeof(seq64be)); seq64be[6] = (unsigned char)(dtls1_get_queue_priority( frag->msg_header.seq, frag->msg_header.is_ccs) >> 8); seq64be[7] = (unsigned char)(dtls1_get_queue_priority( frag->msg_header.seq, frag->msg_header.is_ccs)); item = pitem_new(seq64be, frag); if (item == NULL) { dtls1_hm_fragment_free(frag); return 0; } pqueue_insert(s->d1->sent_messages, item); return 1; } int dtls1_retransmit_message(SSL *s, unsigned short seq, unsigned long frag_off, int *found) { int ret; /* XDTLS: for now assuming that read/writes are blocking */ pitem *item; hm_fragment *frag; unsigned long header_length; unsigned char seq64be[8]; struct dtls1_retransmit_state saved_state; unsigned char save_write_sequence[8]; /* OPENSSL_assert(s->init_num == 0); OPENSSL_assert(s->init_off == 0); */ /* XDTLS: the requested message ought to be found, otherwise error */ memset(seq64be, 0, sizeof(seq64be)); seq64be[6] = (unsigned char)(seq >> 8); seq64be[7] = (unsigned char)seq; item = pqueue_find(s->d1->sent_messages, seq64be); if (item == NULL) { fprintf(stderr, "retransmit: message %d non-existant\n", seq); *found = 0; return 0; } *found = 1; frag = (hm_fragment *)item->data; if (frag->msg_header.is_ccs) header_length = DTLS1_CCS_HEADER_LENGTH; else header_length = DTLS1_HM_HEADER_LENGTH; memcpy(s->init_buf->data, frag->fragment, frag->msg_header.msg_len + header_length); s->init_num = frag->msg_header.msg_len + header_length; dtls1_set_message_header_int(s, frag->msg_header.type, frag->msg_header.msg_len, frag->msg_header.seq, 0, frag->msg_header.frag_len); /* save current state */ saved_state.enc_write_ctx = s->enc_write_ctx; saved_state.write_hash = s->write_hash; saved_state.session = s->session; saved_state.epoch = s->d1->w_epoch; s->d1->retransmitting = 1; /* restore state in which the message was originally sent */ s->enc_write_ctx = frag->msg_header.saved_retransmit_state.enc_write_ctx; s->write_hash = frag->msg_header.saved_retransmit_state.write_hash; s->session = frag->msg_header.saved_retransmit_state.session; s->d1->w_epoch = frag->msg_header.saved_retransmit_state.epoch; if (frag->msg_header.saved_retransmit_state.epoch == saved_state.epoch - 1) { memcpy(save_write_sequence, s->s3->write_sequence, sizeof(s->s3->write_sequence)); memcpy(s->s3->write_sequence, s->d1->last_write_sequence, sizeof(s->s3->write_sequence)); } ret = dtls1_do_write(s, frag->msg_header.is_ccs ? SSL3_RT_CHANGE_CIPHER_SPEC : SSL3_RT_HANDSHAKE); /* restore current state */ s->enc_write_ctx = saved_state.enc_write_ctx; s->write_hash = saved_state.write_hash; s->session = saved_state.session; s->d1->w_epoch = saved_state.epoch; if (frag->msg_header.saved_retransmit_state.epoch == saved_state.epoch - 1) { memcpy(s->d1->last_write_sequence, s->s3->write_sequence, sizeof(s->s3->write_sequence)); memcpy(s->s3->write_sequence, save_write_sequence, sizeof(s->s3->write_sequence)); } s->d1->retransmitting = 0; (void)BIO_flush(SSL_get_wbio(s)); return ret; } /* call this function when the buffered messages are no longer needed */ void dtls1_clear_record_buffer(SSL *s) { pitem *item; for(item = pqueue_pop(s->d1->sent_messages); item != NULL; item = pqueue_pop(s->d1->sent_messages)) { dtls1_hm_fragment_free((hm_fragment *)item->data); pitem_free(item); } } unsigned char * dtls1_set_message_header(SSL *s, unsigned char *p, unsigned char mt, unsigned long len, unsigned long frag_off, unsigned long frag_len) { /* Don't change sequence numbers while listening */ if (frag_off == 0 && !s->d1->listen) { s->d1->handshake_write_seq = s->d1->next_handshake_write_seq; s->d1->next_handshake_write_seq++; } dtls1_set_message_header_int(s, mt, len, s->d1->handshake_write_seq, frag_off, frag_len); return p += DTLS1_HM_HEADER_LENGTH; } /* don't actually do the writing, wait till the MTU has been retrieved */ static void dtls1_set_message_header_int(SSL *s, unsigned char mt, unsigned long len, unsigned short seq_num, unsigned long frag_off, unsigned long frag_len) { struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr; msg_hdr->type = mt; msg_hdr->msg_len = len; msg_hdr->seq = seq_num; msg_hdr->frag_off = frag_off; msg_hdr->frag_len = frag_len; } static void dtls1_fix_message_header(SSL *s, unsigned long frag_off, unsigned long frag_len) { struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr; msg_hdr->frag_off = frag_off; msg_hdr->frag_len = frag_len; } static unsigned char * dtls1_write_message_header(SSL *s, unsigned char *p) { struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr; *p++ = msg_hdr->type; l2n3(msg_hdr->msg_len, p); s2n(msg_hdr->seq, p); l2n3(msg_hdr->frag_off, p); l2n3(msg_hdr->frag_len, p); return p; } unsigned int dtls1_min_mtu(void) { return (g_probable_mtu[(sizeof(g_probable_mtu) / sizeof(g_probable_mtu[0])) - 1]); } static unsigned int dtls1_guess_mtu(unsigned int curr_mtu) { unsigned int i; if (curr_mtu == 0) return g_probable_mtu[0]; for (i = 0; i < sizeof(g_probable_mtu) / sizeof(g_probable_mtu[0]); i++) if (curr_mtu > g_probable_mtu[i]) return g_probable_mtu[i]; return curr_mtu; } void dtls1_get_message_header(unsigned char *data, struct hm_header_st *msg_hdr) { memset(msg_hdr, 0x00, sizeof(struct hm_header_st)); msg_hdr->type = *(data++); n2l3(data, msg_hdr->msg_len); n2s(data, msg_hdr->seq); n2l3(data, msg_hdr->frag_off); n2l3(data, msg_hdr->frag_len); } void dtls1_get_ccs_header(unsigned char *data, struct ccs_header_st *ccs_hdr) { memset(ccs_hdr, 0x00, sizeof(struct ccs_header_st)); ccs_hdr->type = *(data++); } int dtls1_shutdown(SSL *s) { int ret; #ifndef OPENSSL_NO_SCTP if (BIO_dgram_is_sctp(SSL_get_wbio(s)) && !(s->shutdown & SSL_SENT_SHUTDOWN)) { ret = BIO_dgram_sctp_wait_for_dry(SSL_get_wbio(s)); if (ret < 0) return -1; if (ret == 0) BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN, 1, NULL); } #endif ret = ssl3_shutdown(s); #ifndef OPENSSL_NO_SCTP BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN, 0, NULL); #endif return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/bio_ssl.c0000644000175000017500000003326312360020705017341 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include static int ssl_write(BIO *h, const char *buf, int num); static int ssl_read(BIO *h, char *buf, int size); static int ssl_puts(BIO *h, const char *str); static long ssl_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int ssl_new(BIO *h); static int ssl_free(BIO *data); static long ssl_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); typedef struct bio_ssl_st { SSL *ssl; /* The ssl handle :-) */ /* re-negotiate every time the total number of bytes is this size */ int num_renegotiates; unsigned long renegotiate_count; unsigned long byte_count; unsigned long renegotiate_timeout; unsigned long last_time; } BIO_SSL; static BIO_METHOD methods_sslp = { .type = BIO_TYPE_SSL, .name = "ssl", .bwrite = ssl_write, .bread = ssl_read, .bputs = ssl_puts, .ctrl = ssl_ctrl, .create = ssl_new, .destroy = ssl_free, .callback_ctrl = ssl_callback_ctrl, }; BIO_METHOD * BIO_f_ssl(void) { return (&methods_sslp); } static int ssl_new(BIO *bi) { BIO_SSL *bs; bs = calloc(1, sizeof(BIO_SSL)); if (bs == NULL) { BIOerr(BIO_F_SSL_NEW, ERR_R_MALLOC_FAILURE); return (0); } bi->init = 0; bi->ptr = (char *)bs; bi->flags = 0; return (1); } static int ssl_free(BIO *a) { BIO_SSL *bs; if (a == NULL) return (0); bs = (BIO_SSL *)a->ptr; if (bs->ssl != NULL) SSL_shutdown(bs->ssl); if (a->shutdown) { if (a->init && (bs->ssl != NULL)) SSL_free(bs->ssl); a->init = 0; a->flags = 0; } free(a->ptr); return (1); } static int ssl_read(BIO *b, char *out, int outl) { int ret = 1; BIO_SSL *sb; SSL *ssl; int retry_reason = 0; int r = 0; if (out == NULL) return (0); sb = (BIO_SSL *)b->ptr; ssl = sb->ssl; BIO_clear_retry_flags(b); ret = SSL_read(ssl, out, outl); switch (SSL_get_error(ssl, ret)) { case SSL_ERROR_NONE: if (ret <= 0) break; if (sb->renegotiate_count > 0) { sb->byte_count += ret; if (sb->byte_count > sb->renegotiate_count) { sb->byte_count = 0; sb->num_renegotiates++; SSL_renegotiate(ssl); r = 1; } } if ((sb->renegotiate_timeout > 0) && (!r)) { unsigned long tm; tm = (unsigned long)time(NULL); if (tm > sb->last_time + sb->renegotiate_timeout) { sb->last_time = tm; sb->num_renegotiates++; SSL_renegotiate(ssl); } } break; case SSL_ERROR_WANT_READ: BIO_set_retry_read(b); break; case SSL_ERROR_WANT_WRITE: BIO_set_retry_write(b); break; case SSL_ERROR_WANT_X509_LOOKUP: BIO_set_retry_special(b); retry_reason = BIO_RR_SSL_X509_LOOKUP; break; case SSL_ERROR_WANT_ACCEPT: BIO_set_retry_special(b); retry_reason = BIO_RR_ACCEPT; break; case SSL_ERROR_WANT_CONNECT: BIO_set_retry_special(b); retry_reason = BIO_RR_CONNECT; break; case SSL_ERROR_SYSCALL: case SSL_ERROR_SSL: case SSL_ERROR_ZERO_RETURN: default: break; } b->retry_reason = retry_reason; return (ret); } static int ssl_write(BIO *b, const char *out, int outl) { int ret, r = 0; int retry_reason = 0; SSL *ssl; BIO_SSL *bs; if (out == NULL) return (0); bs = (BIO_SSL *)b->ptr; ssl = bs->ssl; BIO_clear_retry_flags(b); /* ret=SSL_do_handshake(ssl); if (ret > 0) */ ret = SSL_write(ssl, out, outl); switch (SSL_get_error(ssl, ret)) { case SSL_ERROR_NONE: if (ret <= 0) break; if (bs->renegotiate_count > 0) { bs->byte_count += ret; if (bs->byte_count > bs->renegotiate_count) { bs->byte_count = 0; bs->num_renegotiates++; SSL_renegotiate(ssl); r = 1; } } if ((bs->renegotiate_timeout > 0) && (!r)) { unsigned long tm; tm = (unsigned long)time(NULL); if (tm > bs->last_time + bs->renegotiate_timeout) { bs->last_time = tm; bs->num_renegotiates++; SSL_renegotiate(ssl); } } break; case SSL_ERROR_WANT_WRITE: BIO_set_retry_write(b); break; case SSL_ERROR_WANT_READ: BIO_set_retry_read(b); break; case SSL_ERROR_WANT_X509_LOOKUP: BIO_set_retry_special(b); retry_reason = BIO_RR_SSL_X509_LOOKUP; break; case SSL_ERROR_WANT_CONNECT: BIO_set_retry_special(b); retry_reason = BIO_RR_CONNECT; case SSL_ERROR_SYSCALL: case SSL_ERROR_SSL: default: break; } b->retry_reason = retry_reason; return (ret); } static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr) { SSL **sslp, *ssl; BIO_SSL *bs; BIO *dbio, *bio; long ret = 1; bs = (BIO_SSL *)b->ptr; ssl = bs->ssl; if ((ssl == NULL) && (cmd != BIO_C_SET_SSL)) return (0); switch (cmd) { case BIO_CTRL_RESET: SSL_shutdown(ssl); if (ssl->handshake_func == ssl->method->ssl_connect) SSL_set_connect_state(ssl); else if (ssl->handshake_func == ssl->method->ssl_accept) SSL_set_accept_state(ssl); SSL_clear(ssl); if (b->next_bio != NULL) ret = BIO_ctrl(b->next_bio, cmd, num, ptr); else if (ssl->rbio != NULL) ret = BIO_ctrl(ssl->rbio, cmd, num, ptr); else ret = 1; break; case BIO_CTRL_INFO: ret = 0; break; case BIO_C_SSL_MODE: if (num) /* client mode */ SSL_set_connect_state(ssl); else SSL_set_accept_state(ssl); break; case BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT: ret = bs->renegotiate_timeout; if (num < 60) num = 5; bs->renegotiate_timeout = (unsigned long)num; bs->last_time = (unsigned long)time(NULL); break; case BIO_C_SET_SSL_RENEGOTIATE_BYTES: ret = bs->renegotiate_count; if ((long)num >=512) bs->renegotiate_count = (unsigned long)num; break; case BIO_C_GET_SSL_NUM_RENEGOTIATES: ret = bs->num_renegotiates; break; case BIO_C_SET_SSL: if (ssl != NULL) { ssl_free(b); if (!ssl_new(b)) return 0; } b->shutdown = (int)num; ssl = (SSL *)ptr; ((BIO_SSL *)b->ptr)->ssl = ssl; bio = SSL_get_rbio(ssl); if (bio != NULL) { if (b->next_bio != NULL) BIO_push(bio, b->next_bio); b->next_bio = bio; CRYPTO_add(&bio->references, 1, CRYPTO_LOCK_BIO); } b->init = 1; break; case BIO_C_GET_SSL: if (ptr != NULL) { sslp = (SSL **)ptr; *sslp = ssl; } else ret = 0; break; case BIO_CTRL_GET_CLOSE: ret = b->shutdown; break; case BIO_CTRL_SET_CLOSE: b->shutdown = (int)num; break; case BIO_CTRL_WPENDING: ret = BIO_ctrl(ssl->wbio, cmd, num, ptr); break; case BIO_CTRL_PENDING: ret = SSL_pending(ssl); if (ret == 0) ret = BIO_pending(ssl->rbio); break; case BIO_CTRL_FLUSH: BIO_clear_retry_flags(b); ret = BIO_ctrl(ssl->wbio, cmd, num, ptr); BIO_copy_next_retry(b); break; case BIO_CTRL_PUSH: if ((b->next_bio != NULL) && (b->next_bio != ssl->rbio)) { SSL_set_bio(ssl, b->next_bio, b->next_bio); CRYPTO_add(&b->next_bio->references, 1, CRYPTO_LOCK_BIO); } break; case BIO_CTRL_POP: /* Only detach if we are the BIO explicitly being popped */ if (b == ptr) { /* Shouldn't happen in practice because the * rbio and wbio are the same when pushed. */ if (ssl->rbio != ssl->wbio) BIO_free_all(ssl->wbio); if (b->next_bio != NULL) CRYPTO_add(&b->next_bio->references, -1, CRYPTO_LOCK_BIO); ssl->wbio = NULL; ssl->rbio = NULL; } break; case BIO_C_DO_STATE_MACHINE: BIO_clear_retry_flags(b); b->retry_reason = 0; ret = (int)SSL_do_handshake(ssl); switch (SSL_get_error(ssl, (int)ret)) { case SSL_ERROR_WANT_READ: BIO_set_flags(b, BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY); break; case SSL_ERROR_WANT_WRITE: BIO_set_flags(b, BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY); break; case SSL_ERROR_WANT_CONNECT: BIO_set_flags(b, BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY); b->retry_reason = b->next_bio->retry_reason; break; default: break; } break; case BIO_CTRL_DUP: dbio = (BIO *)ptr; if (((BIO_SSL *)dbio->ptr)->ssl != NULL) SSL_free(((BIO_SSL *)dbio->ptr)->ssl); ((BIO_SSL *)dbio->ptr)->ssl = SSL_dup(ssl); ((BIO_SSL *)dbio->ptr)->renegotiate_count = ((BIO_SSL *)b->ptr)->renegotiate_count; ((BIO_SSL *)dbio->ptr)->byte_count = ((BIO_SSL *)b->ptr)->byte_count; ((BIO_SSL *)dbio->ptr)->renegotiate_timeout = ((BIO_SSL *)b->ptr)->renegotiate_timeout; ((BIO_SSL *)dbio->ptr)->last_time = ((BIO_SSL *)b->ptr)->last_time; ret = (((BIO_SSL *)dbio->ptr)->ssl != NULL); break; case BIO_C_GET_FD: ret = BIO_ctrl(ssl->rbio, cmd, num, ptr); break; case BIO_CTRL_SET_CALLBACK: { ret = 0; } break; case BIO_CTRL_GET_CALLBACK: { void (**fptr)(const SSL *xssl, int type, int val); fptr = (void (**)(const SSL *xssl, int type, int val))ptr; *fptr = SSL_get_info_callback(ssl); } break; default: ret = BIO_ctrl(ssl->rbio, cmd, num, ptr); break; } return (ret); } static long ssl_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) { SSL *ssl; BIO_SSL *bs; long ret = 1; bs = (BIO_SSL *)b->ptr; ssl = bs->ssl; switch (cmd) { case BIO_CTRL_SET_CALLBACK: { /* FIXME: setting this via a completely different prototype seems like a crap idea */ SSL_set_info_callback(ssl, (void (*)(const SSL *, int, int))fp); } break; default: ret = BIO_callback_ctrl(ssl->rbio, cmd, fp); break; } return (ret); } static int ssl_puts(BIO *bp, const char *str) { int n, ret; n = strlen(str); ret = BIO_write(bp, str, n); return (ret); } BIO * BIO_new_buffer_ssl_connect(SSL_CTX *ctx) { BIO *ret = NULL, *buf = NULL, *ssl = NULL; if ((buf = BIO_new(BIO_f_buffer())) == NULL) goto err; if ((ssl = BIO_new_ssl_connect(ctx)) == NULL) goto err; if ((ret = BIO_push(buf, ssl)) == NULL) goto err; return (ret); err: BIO_free(buf); BIO_free(ssl); return (NULL); } BIO * BIO_new_ssl_connect(SSL_CTX *ctx) { BIO *ret = NULL, *con = NULL, *ssl = NULL; if ((con = BIO_new(BIO_s_connect())) == NULL) goto err; if ((ssl = BIO_new_ssl(ctx, 1)) == NULL) goto err; if ((ret = BIO_push(ssl, con)) == NULL) goto err; return (ret); err: BIO_free(con); BIO_free(ssl); return (NULL); } BIO * BIO_new_ssl(SSL_CTX *ctx, int client) { BIO *ret; SSL *ssl; if ((ret = BIO_new(BIO_f_ssl())) == NULL) goto err; if ((ssl = SSL_new(ctx)) == NULL) goto err; if (client) SSL_set_connect_state(ssl); else SSL_set_accept_state(ssl); BIO_set_ssl(ret, ssl, BIO_CLOSE); return (ret); err: BIO_free(ret); return (NULL); } int BIO_ssl_copy_session_id(BIO *t, BIO *f) { t = BIO_find_type(t, BIO_TYPE_SSL); f = BIO_find_type(f, BIO_TYPE_SSL); if ((t == NULL) || (f == NULL)) return (0); if ((((BIO_SSL *)t->ptr)->ssl == NULL) || (((BIO_SSL *)f->ptr)->ssl == NULL)) return (0); SSL_copy_session_id(((BIO_SSL *)t->ptr)->ssl, ((BIO_SSL *)f->ptr)->ssl); return (1); } void BIO_ssl_shutdown(BIO *b) { SSL *s; while (b != NULL) { if (b->method->type == BIO_TYPE_SSL) { s = ((BIO_SSL *)b->ptr)->ssl; SSL_shutdown(s); break; } b = b->next_bio; } } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/ssl_ciph.c0000644000175000017500000013457612360020705017524 0ustar /* $OpenBSD: ssl_ciph.c,v 1.62 2014/07/10 11:58:08 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * ECC cipher suite support in OpenSSL originally developed by * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. */ /* ==================================================================== * Copyright 2005 Nokia. All rights reserved. * * The portions of the attached software ("Contribution") is developed by * Nokia Corporation and is licensed pursuant to the OpenSSL open source * license. * * The Contribution, originally written by Mika Kousa and Pasi Eronen of * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites * support (see RFC 4279) to OpenSSL. * * No patent licenses or other rights except those expressly stated in * the OpenSSL open source license shall be deemed granted or received * expressly, by implication, estoppel, or otherwise. * * No assurances are provided by Nokia that the Contribution does not * infringe the patent or other intellectual property rights of any third * party or that the license provides you with all the necessary rights * to make use of the Contribution. * * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR * OTHERWISE. */ #include #include #ifndef OPENSSL_NO_ENGINE #include #endif #include "ssl_locl.h" #define SSL_ENC_DES_IDX 0 #define SSL_ENC_3DES_IDX 1 #define SSL_ENC_RC4_IDX 2 #define SSL_ENC_RC2_IDX 3 #define SSL_ENC_IDEA_IDX 4 #define SSL_ENC_NULL_IDX 5 #define SSL_ENC_AES128_IDX 6 #define SSL_ENC_AES256_IDX 7 #define SSL_ENC_CAMELLIA128_IDX 8 #define SSL_ENC_CAMELLIA256_IDX 9 #define SSL_ENC_GOST89_IDX 10 #define SSL_ENC_SEED_IDX 11 #define SSL_ENC_AES128GCM_IDX 12 #define SSL_ENC_AES256GCM_IDX 13 #define SSL_ENC_NUM_IDX 14 static const EVP_CIPHER *ssl_cipher_methods[SSL_ENC_NUM_IDX] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; #define SSL_MD_MD5_IDX 0 #define SSL_MD_SHA1_IDX 1 #define SSL_MD_GOST94_IDX 2 #define SSL_MD_GOST89MAC_IDX 3 #define SSL_MD_SHA256_IDX 4 #define SSL_MD_SHA384_IDX 5 /*Constant SSL_MAX_DIGEST equal to size of digests array should be * defined in the * ssl_locl.h */ #define SSL_MD_NUM_IDX SSL_MAX_DIGEST static const EVP_MD *ssl_digest_methods[SSL_MD_NUM_IDX] = { NULL, NULL, NULL, NULL, NULL, NULL }; /* PKEY_TYPE for GOST89MAC is known in advance, but, because * implementation is engine-provided, we'll fill it only if * corresponding EVP_PKEY_METHOD is found */ static int ssl_mac_pkey_id[SSL_MD_NUM_IDX] = { EVP_PKEY_HMAC, EVP_PKEY_HMAC, EVP_PKEY_HMAC, NID_undef, EVP_PKEY_HMAC, EVP_PKEY_HMAC }; static int ssl_mac_secret_size[SSL_MD_NUM_IDX] = { 0, 0, 0, 0, 0, 0 }; static int ssl_handshake_digest_flag[SSL_MD_NUM_IDX] = { SSL_HANDSHAKE_MAC_MD5, SSL_HANDSHAKE_MAC_SHA, SSL_HANDSHAKE_MAC_GOST94, 0, SSL_HANDSHAKE_MAC_SHA256, SSL_HANDSHAKE_MAC_SHA384 }; #define CIPHER_ADD 1 #define CIPHER_KILL 2 #define CIPHER_DEL 3 #define CIPHER_ORD 4 #define CIPHER_SPECIAL 5 typedef struct cipher_order_st { const SSL_CIPHER *cipher; int active; int dead; struct cipher_order_st *next, *prev; } CIPHER_ORDER; static const SSL_CIPHER cipher_aliases[] = { /* "ALL" doesn't include eNULL (must be specifically enabled) */ { .name = SSL_TXT_ALL, .algorithm_enc = ~SSL_eNULL, }, /* "COMPLEMENTOFALL" */ { .name = SSL_TXT_CMPALL, .algorithm_enc = SSL_eNULL, }, /* * "COMPLEMENTOFDEFAULT" * (does *not* include ciphersuites not found in ALL!) */ { .name = SSL_TXT_CMPDEF, .algorithm_mkey = SSL_kEDH|SSL_kEECDH, .algorithm_auth = SSL_aNULL, .algorithm_enc = ~SSL_eNULL, }, /* * key exchange aliases * (some of those using only a single bit here combine multiple key * exchange algs according to the RFCs, e.g. kEDH combines DHE_DSS * and DHE_RSA) */ { .name = SSL_TXT_kRSA, .algorithm_mkey = SSL_kRSA, }, { /* no such ciphersuites supported! */ .name = SSL_TXT_kDHr, .algorithm_mkey = SSL_kDHr, }, { /* no such ciphersuites supported! */ .name = SSL_TXT_kDHd, .algorithm_mkey = SSL_kDHd, }, { /* no such ciphersuites supported! */ .name = SSL_TXT_kDH, .algorithm_mkey = SSL_kDHr|SSL_kDHd, }, { .name = SSL_TXT_kEDH, .algorithm_mkey = SSL_kEDH, }, { .name = SSL_TXT_DH, .algorithm_mkey = SSL_kDHr|SSL_kDHd|SSL_kEDH, }, { .name = SSL_TXT_kKRB5, .algorithm_mkey = SSL_kKRB5, }, { .name = SSL_TXT_kECDHr, .algorithm_mkey = SSL_kECDHr, }, { .name = SSL_TXT_kECDHe, .algorithm_mkey = SSL_kECDHe, }, { .name = SSL_TXT_kECDH, .algorithm_mkey = SSL_kECDHr|SSL_kECDHe, }, { .name = SSL_TXT_kEECDH, .algorithm_mkey = SSL_kEECDH, }, { .name = SSL_TXT_ECDH, .algorithm_mkey = SSL_kECDHr|SSL_kECDHe|SSL_kEECDH, }, { .name = SSL_TXT_kPSK, .algorithm_mkey = SSL_kPSK, }, { .name = SSL_TXT_kSRP, .algorithm_mkey = SSL_kSRP, }, { .name = SSL_TXT_kGOST, .algorithm_mkey = SSL_kGOST, }, /* server authentication aliases */ { .name = SSL_TXT_aRSA, .algorithm_auth = SSL_aRSA, }, { .name = SSL_TXT_aDSS, .algorithm_auth = SSL_aDSS, }, { .name = SSL_TXT_DSS, .algorithm_auth = SSL_aDSS, }, { .name = SSL_TXT_aKRB5, .algorithm_auth = SSL_aKRB5, }, { .name = SSL_TXT_aNULL, .algorithm_auth = SSL_aNULL, }, { /* no such ciphersuites supported! */ .name = SSL_TXT_aDH, .algorithm_auth = SSL_aDH, }, { .name = SSL_TXT_aECDH, .algorithm_auth = SSL_aECDH, }, { .name = SSL_TXT_aECDSA, .algorithm_auth = SSL_aECDSA, }, { .name = SSL_TXT_ECDSA, .algorithm_auth = SSL_aECDSA, }, { .name = SSL_TXT_aPSK, .algorithm_auth = SSL_aPSK, }, { .name = SSL_TXT_aGOST94, .algorithm_auth = SSL_aGOST94, }, { .name = SSL_TXT_aGOST01, .algorithm_auth = SSL_aGOST01, }, { .name = SSL_TXT_aGOST, .algorithm_auth = SSL_aGOST94|SSL_aGOST01, }, /* aliases combining key exchange and server authentication */ { .name = SSL_TXT_EDH, .algorithm_mkey = SSL_kEDH, .algorithm_auth = ~SSL_aNULL, }, { .name = SSL_TXT_EECDH, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = ~SSL_aNULL, }, { .name = SSL_TXT_NULL, .algorithm_enc = SSL_eNULL, }, { .name = SSL_TXT_KRB5, .algorithm_mkey = SSL_kKRB5, .algorithm_auth = SSL_aKRB5, }, { .name = SSL_TXT_RSA, .algorithm_mkey = SSL_kRSA, .algorithm_auth = SSL_aRSA, }, { .name = SSL_TXT_ADH, .algorithm_mkey = SSL_kEDH, .algorithm_auth = SSL_aNULL, }, { .name = SSL_TXT_AECDH, .algorithm_mkey = SSL_kEECDH, .algorithm_auth = SSL_aNULL, }, { .name = SSL_TXT_PSK, .algorithm_mkey = SSL_kPSK, .algorithm_auth = SSL_aPSK, }, { .name = SSL_TXT_SRP, .algorithm_mkey = SSL_kSRP, }, /* symmetric encryption aliases */ { .name = SSL_TXT_DES, .algorithm_enc = SSL_DES, }, { .name = SSL_TXT_3DES, .algorithm_enc = SSL_3DES, }, { .name = SSL_TXT_RC4, .algorithm_enc = SSL_RC4, }, { .name = SSL_TXT_RC2, .algorithm_enc = SSL_RC2, }, { .name = SSL_TXT_IDEA, .algorithm_enc = SSL_IDEA, }, { .name = SSL_TXT_SEED, .algorithm_enc = SSL_SEED, }, { .name = SSL_TXT_eNULL, .algorithm_enc = SSL_eNULL, }, { .name = SSL_TXT_AES128, .algorithm_enc = SSL_AES128|SSL_AES128GCM, }, { .name = SSL_TXT_AES256, .algorithm_enc = SSL_AES256|SSL_AES256GCM, }, { .name = SSL_TXT_AES, .algorithm_enc = SSL_AES, }, { .name = SSL_TXT_AES_GCM, .algorithm_enc = SSL_AES128GCM|SSL_AES256GCM, }, { .name = SSL_TXT_CAMELLIA128, .algorithm_enc = SSL_CAMELLIA128, }, { .name = SSL_TXT_CAMELLIA256, .algorithm_enc = SSL_CAMELLIA256, }, { .name = SSL_TXT_CAMELLIA, .algorithm_enc = SSL_CAMELLIA128|SSL_CAMELLIA256, }, /* MAC aliases */ { .name = SSL_TXT_MD5, .algorithm_mac = SSL_MD5, }, { .name = SSL_TXT_SHA1, .algorithm_mac = SSL_SHA1, }, { .name = SSL_TXT_SHA, .algorithm_mac = SSL_SHA1, }, { .name = SSL_TXT_GOST94, .algorithm_mac = SSL_GOST94, }, { .name = SSL_TXT_GOST89MAC, .algorithm_mac = SSL_GOST89MAC, }, { .name = SSL_TXT_SHA256, .algorithm_mac = SSL_SHA256, }, { .name = SSL_TXT_SHA384, .algorithm_mac = SSL_SHA384, }, /* protocol version aliases */ { .name = SSL_TXT_SSLV2, .algorithm_ssl = SSL_SSLV2, }, { .name = SSL_TXT_SSLV3, .algorithm_ssl = SSL_SSLV3, }, { .name = SSL_TXT_TLSV1, .algorithm_ssl = SSL_TLSV1, }, { .name = SSL_TXT_TLSV1_2, .algorithm_ssl = SSL_TLSV1_2, }, /* strength classes */ { .name = SSL_TXT_LOW, .algo_strength = SSL_LOW, }, { .name = SSL_TXT_MEDIUM, .algo_strength = SSL_MEDIUM, }, { .name = SSL_TXT_HIGH, .algo_strength = SSL_HIGH, }, }; /* Search for public key algorithm with given name and * return its pkey_id if it is available. Otherwise return 0 */ #ifdef OPENSSL_NO_ENGINE static int get_optional_pkey_id(const char *pkey_name) { const EVP_PKEY_ASN1_METHOD *ameth; int pkey_id = 0; ameth = EVP_PKEY_asn1_find_str(NULL, pkey_name, -1); if (ameth) { EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL, ameth); } return pkey_id; } #else static int get_optional_pkey_id(const char *pkey_name) { const EVP_PKEY_ASN1_METHOD *ameth; ENGINE *tmpeng = NULL; int pkey_id = 0; ameth = EVP_PKEY_asn1_find_str(&tmpeng, pkey_name, -1); if (ameth) { EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL, ameth); } if (tmpeng) ENGINE_finish(tmpeng); return pkey_id; } #endif void ssl_load_ciphers(void) { ssl_cipher_methods[SSL_ENC_DES_IDX]= EVP_get_cipherbyname(SN_des_cbc); ssl_cipher_methods[SSL_ENC_3DES_IDX]= EVP_get_cipherbyname(SN_des_ede3_cbc); ssl_cipher_methods[SSL_ENC_RC4_IDX]= EVP_get_cipherbyname(SN_rc4); ssl_cipher_methods[SSL_ENC_RC2_IDX]= EVP_get_cipherbyname(SN_rc2_cbc); #ifndef OPENSSL_NO_IDEA ssl_cipher_methods[SSL_ENC_IDEA_IDX]= EVP_get_cipherbyname(SN_idea_cbc); #else ssl_cipher_methods[SSL_ENC_IDEA_IDX] = NULL; #endif ssl_cipher_methods[SSL_ENC_AES128_IDX]= EVP_get_cipherbyname(SN_aes_128_cbc); ssl_cipher_methods[SSL_ENC_AES256_IDX]= EVP_get_cipherbyname(SN_aes_256_cbc); ssl_cipher_methods[SSL_ENC_CAMELLIA128_IDX]= EVP_get_cipherbyname(SN_camellia_128_cbc); ssl_cipher_methods[SSL_ENC_CAMELLIA256_IDX]= EVP_get_cipherbyname(SN_camellia_256_cbc); ssl_cipher_methods[SSL_ENC_GOST89_IDX]= EVP_get_cipherbyname(SN_gost89_cnt); ssl_cipher_methods[SSL_ENC_SEED_IDX]= EVP_get_cipherbyname(SN_seed_cbc); ssl_cipher_methods[SSL_ENC_AES128GCM_IDX]= EVP_get_cipherbyname(SN_aes_128_gcm); ssl_cipher_methods[SSL_ENC_AES256GCM_IDX]= EVP_get_cipherbyname(SN_aes_256_gcm); ssl_digest_methods[SSL_MD_MD5_IDX]= EVP_get_digestbyname(SN_md5); ssl_mac_secret_size[SSL_MD_MD5_IDX]= EVP_MD_size(ssl_digest_methods[SSL_MD_MD5_IDX]); OPENSSL_assert(ssl_mac_secret_size[SSL_MD_MD5_IDX] >= 0); ssl_digest_methods[SSL_MD_SHA1_IDX]= EVP_get_digestbyname(SN_sha1); ssl_mac_secret_size[SSL_MD_SHA1_IDX]= EVP_MD_size(ssl_digest_methods[SSL_MD_SHA1_IDX]); OPENSSL_assert(ssl_mac_secret_size[SSL_MD_SHA1_IDX] >= 0); ssl_digest_methods[SSL_MD_GOST94_IDX]= EVP_get_digestbyname(SN_id_GostR3411_94); if (ssl_digest_methods[SSL_MD_GOST94_IDX]) { ssl_mac_secret_size[SSL_MD_GOST94_IDX]= EVP_MD_size(ssl_digest_methods[SSL_MD_GOST94_IDX]); OPENSSL_assert(ssl_mac_secret_size[SSL_MD_GOST94_IDX] >= 0); } ssl_digest_methods[SSL_MD_GOST89MAC_IDX]= EVP_get_digestbyname(SN_id_Gost28147_89_MAC); ssl_mac_pkey_id[SSL_MD_GOST89MAC_IDX] = get_optional_pkey_id("gost-mac"); if (ssl_mac_pkey_id[SSL_MD_GOST89MAC_IDX]) { ssl_mac_secret_size[SSL_MD_GOST89MAC_IDX] = 32; } ssl_digest_methods[SSL_MD_SHA256_IDX]= EVP_get_digestbyname(SN_sha256); ssl_mac_secret_size[SSL_MD_SHA256_IDX]= EVP_MD_size(ssl_digest_methods[SSL_MD_SHA256_IDX]); ssl_digest_methods[SSL_MD_SHA384_IDX]= EVP_get_digestbyname(SN_sha384); ssl_mac_secret_size[SSL_MD_SHA384_IDX]= EVP_MD_size(ssl_digest_methods[SSL_MD_SHA384_IDX]); } int ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc, const EVP_MD **md, int *mac_pkey_type, int *mac_secret_size) { const SSL_CIPHER *c; int i; c = s->cipher; if (c == NULL) return (0); /* * This function does not handle EVP_AEAD. * See ssl_cipher_get_aead_evp instead. */ if (c->algorithm2 & SSL_CIPHER_ALGORITHM2_AEAD) return(0); if ((enc == NULL) || (md == NULL)) return (0); switch (c->algorithm_enc) { case SSL_DES: i = SSL_ENC_DES_IDX; break; case SSL_3DES: i = SSL_ENC_3DES_IDX; break; case SSL_RC4: i = SSL_ENC_RC4_IDX; break; case SSL_RC2: i = SSL_ENC_RC2_IDX; break; case SSL_IDEA: i = SSL_ENC_IDEA_IDX; break; case SSL_eNULL: i = SSL_ENC_NULL_IDX; break; case SSL_AES128: i = SSL_ENC_AES128_IDX; break; case SSL_AES256: i = SSL_ENC_AES256_IDX; break; case SSL_CAMELLIA128: i = SSL_ENC_CAMELLIA128_IDX; break; case SSL_CAMELLIA256: i = SSL_ENC_CAMELLIA256_IDX; break; case SSL_eGOST2814789CNT: i = SSL_ENC_GOST89_IDX; break; case SSL_SEED: i = SSL_ENC_SEED_IDX; break; case SSL_AES128GCM: i = SSL_ENC_AES128GCM_IDX; break; case SSL_AES256GCM: i = SSL_ENC_AES256GCM_IDX; break; default: i = -1; break; } if ((i < 0) || (i >= SSL_ENC_NUM_IDX)) *enc = NULL; else { if (i == SSL_ENC_NULL_IDX) *enc = EVP_enc_null(); else *enc = ssl_cipher_methods[i]; } switch (c->algorithm_mac) { case SSL_MD5: i = SSL_MD_MD5_IDX; break; case SSL_SHA1: i = SSL_MD_SHA1_IDX; break; case SSL_SHA256: i = SSL_MD_SHA256_IDX; break; case SSL_SHA384: i = SSL_MD_SHA384_IDX; break; case SSL_GOST94: i = SSL_MD_GOST94_IDX; break; case SSL_GOST89MAC: i = SSL_MD_GOST89MAC_IDX; break; default: i = -1; break; } if ((i < 0) || (i >= SSL_MD_NUM_IDX)) { *md = NULL; if (mac_pkey_type != NULL) *mac_pkey_type = NID_undef; if (mac_secret_size != NULL) *mac_secret_size = 0; if (c->algorithm_mac == SSL_AEAD) mac_pkey_type = NULL; } else { *md = ssl_digest_methods[i]; if (mac_pkey_type != NULL) *mac_pkey_type = ssl_mac_pkey_id[i]; if (mac_secret_size != NULL) *mac_secret_size = ssl_mac_secret_size[i]; } if ((*enc != NULL) && (*md != NULL || (EVP_CIPHER_flags(*enc)&EVP_CIPH_FLAG_AEAD_CIPHER)) && (!mac_pkey_type || *mac_pkey_type != NID_undef)) { const EVP_CIPHER *evp; if (s->ssl_version >> 8 != TLS1_VERSION_MAJOR || s->ssl_version < TLS1_VERSION) return 1; if (c->algorithm_enc == SSL_RC4 && c->algorithm_mac == SSL_MD5 && (evp = EVP_get_cipherbyname("RC4-HMAC-MD5"))) *enc = evp, *md = NULL; else if (c->algorithm_enc == SSL_AES128 && c->algorithm_mac == SSL_SHA1 && (evp = EVP_get_cipherbyname("AES-128-CBC-HMAC-SHA1"))) *enc = evp, *md = NULL; else if (c->algorithm_enc == SSL_AES256 && c->algorithm_mac == SSL_SHA1 && (evp = EVP_get_cipherbyname("AES-256-CBC-HMAC-SHA1"))) *enc = evp, *md = NULL; return (1); } else return (0); } /* * ssl_cipher_get_evp_aead sets aead to point to the correct EVP_AEAD object * for s->cipher. It returns 1 on success and 0 on error. */ int ssl_cipher_get_evp_aead(const SSL_SESSION *s, const EVP_AEAD **aead) { const SSL_CIPHER *c = s->cipher; *aead = NULL; if (c == NULL) return 0; if ((c->algorithm2 & SSL_CIPHER_ALGORITHM2_AEAD) == 0) return 0; switch (c->algorithm_enc) { #ifndef OPENSSL_NO_AES case SSL_AES128GCM: *aead = EVP_aead_aes_128_gcm(); return 1; case SSL_AES256GCM: *aead = EVP_aead_aes_256_gcm(); return 1; #endif #if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) case SSL_CHACHA20POLY1305: *aead = EVP_aead_chacha20_poly1305(); return 1; #endif default: break; } return 0; } int ssl_get_handshake_digest(int idx, long *mask, const EVP_MD **md) { if (idx < 0 || idx >= SSL_MD_NUM_IDX) { return 0; } *mask = ssl_handshake_digest_flag[idx]; if (*mask) *md = ssl_digest_methods[idx]; else *md = NULL; return 1; } #define ITEM_SEP(a) \ (((a) == ':') || ((a) == ' ') || ((a) == ';') || ((a) == ',')) static void ll_append_tail(CIPHER_ORDER **head, CIPHER_ORDER *curr, CIPHER_ORDER **tail) { if (curr == *tail) return; if (curr == *head) *head = curr->next; if (curr->prev != NULL) curr->prev->next = curr->next; if (curr->next != NULL) curr->next->prev = curr->prev; (*tail)->next = curr; curr->prev= *tail; curr->next = NULL; *tail = curr; } static void ll_append_head(CIPHER_ORDER **head, CIPHER_ORDER *curr, CIPHER_ORDER **tail) { if (curr == *head) return; if (curr == *tail) *tail = curr->prev; if (curr->next != NULL) curr->next->prev = curr->prev; if (curr->prev != NULL) curr->prev->next = curr->next; (*head)->prev = curr; curr->next= *head; curr->prev = NULL; *head = curr; } static void ssl_cipher_get_disabled(unsigned long *mkey, unsigned long *auth, unsigned long *enc, unsigned long *mac, unsigned long *ssl) { *mkey = 0; *auth = 0; *enc = 0; *mac = 0; *ssl = 0; *mkey |= SSL_kDHr|SSL_kDHd; /* no such ciphersuites supported! */ *auth |= SSL_aDH; *mkey |= SSL_kKRB5; *auth |= SSL_aKRB5; *mkey |= SSL_kPSK; *auth |= SSL_aPSK; *mkey |= SSL_kSRP; /* Check for presence of GOST 34.10 algorithms, and if they * do not present, disable appropriate auth and key exchange */ if (!get_optional_pkey_id("gost94")) { *auth |= SSL_aGOST94; } if (!get_optional_pkey_id("gost2001")) { *auth |= SSL_aGOST01; } /* Disable GOST key exchange if no GOST signature algs are available * */ if ((*auth & (SSL_aGOST94|SSL_aGOST01)) == (SSL_aGOST94|SSL_aGOST01)) { *mkey |= SSL_kGOST; } #ifdef SSL_FORBID_ENULL *enc |= SSL_eNULL; #endif *enc |= (ssl_cipher_methods[SSL_ENC_DES_IDX ] == NULL) ? SSL_DES : 0; *enc |= (ssl_cipher_methods[SSL_ENC_3DES_IDX] == NULL) ? SSL_3DES : 0; *enc |= (ssl_cipher_methods[SSL_ENC_RC4_IDX ] == NULL) ? SSL_RC4 : 0; *enc |= (ssl_cipher_methods[SSL_ENC_RC2_IDX ] == NULL) ? SSL_RC2 : 0; *enc |= (ssl_cipher_methods[SSL_ENC_IDEA_IDX] == NULL) ? SSL_IDEA : 0; *enc |= (ssl_cipher_methods[SSL_ENC_AES128_IDX] == NULL) ? SSL_AES128 : 0; *enc |= (ssl_cipher_methods[SSL_ENC_AES256_IDX] == NULL) ? SSL_AES256 : 0; *enc |= (ssl_cipher_methods[SSL_ENC_AES128GCM_IDX] == NULL) ? SSL_AES128GCM : 0; *enc |= (ssl_cipher_methods[SSL_ENC_AES256GCM_IDX] == NULL) ? SSL_AES256GCM : 0; *enc |= (ssl_cipher_methods[SSL_ENC_CAMELLIA128_IDX] == NULL) ? SSL_CAMELLIA128 : 0; *enc |= (ssl_cipher_methods[SSL_ENC_CAMELLIA256_IDX] == NULL) ? SSL_CAMELLIA256 : 0; *enc |= (ssl_cipher_methods[SSL_ENC_GOST89_IDX] == NULL) ? SSL_eGOST2814789CNT : 0; *enc |= (ssl_cipher_methods[SSL_ENC_SEED_IDX] == NULL) ? SSL_SEED : 0; *mac |= (ssl_digest_methods[SSL_MD_MD5_IDX ] == NULL) ? SSL_MD5 : 0; *mac |= (ssl_digest_methods[SSL_MD_SHA1_IDX] == NULL) ? SSL_SHA1 : 0; *mac |= (ssl_digest_methods[SSL_MD_SHA256_IDX] == NULL) ? SSL_SHA256 : 0; *mac |= (ssl_digest_methods[SSL_MD_SHA384_IDX] == NULL) ? SSL_SHA384 : 0; *mac |= (ssl_digest_methods[SSL_MD_GOST94_IDX] == NULL) ? SSL_GOST94 : 0; *mac |= (ssl_digest_methods[SSL_MD_GOST89MAC_IDX] == NULL || ssl_mac_pkey_id[SSL_MD_GOST89MAC_IDX]==NID_undef) ? SSL_GOST89MAC : 0; } static void ssl_cipher_collect_ciphers(const SSL_METHOD *ssl_method, int num_of_ciphers, unsigned long disabled_mkey, unsigned long disabled_auth, unsigned long disabled_enc, unsigned long disabled_mac, unsigned long disabled_ssl, CIPHER_ORDER *co_list, CIPHER_ORDER **head_p, CIPHER_ORDER **tail_p) { int i, co_list_num; const SSL_CIPHER *c; /* * We have num_of_ciphers descriptions compiled in, depending on the * method selected (SSLv2 and/or SSLv3, TLSv1 etc). * These will later be sorted in a linked list with at most num * entries. */ /* Get the initial list of ciphers */ co_list_num = 0; /* actual count of ciphers */ for (i = 0; i < num_of_ciphers; i++) { c = ssl_method->get_cipher(i); /* drop those that use any of that is not available */ if ((c != NULL) && c->valid && !(c->algorithm_mkey & disabled_mkey) && !(c->algorithm_auth & disabled_auth) && !(c->algorithm_enc & disabled_enc) && !(c->algorithm_mac & disabled_mac) && !(c->algorithm_ssl & disabled_ssl)) { co_list[co_list_num].cipher = c; co_list[co_list_num].next = NULL; co_list[co_list_num].prev = NULL; co_list[co_list_num].active = 0; co_list_num++; /* if (!sk_push(ca_list,(char *)c)) goto err; */ } } /* * Prepare linked list from list entries */ if (co_list_num > 0) { co_list[0].prev = NULL; if (co_list_num > 1) { co_list[0].next = &co_list[1]; for (i = 1; i < co_list_num - 1; i++) { co_list[i].prev = &co_list[i - 1]; co_list[i].next = &co_list[i + 1]; } co_list[co_list_num - 1].prev = &co_list[co_list_num - 2]; } co_list[co_list_num - 1].next = NULL; *head_p = &co_list[0]; *tail_p = &co_list[co_list_num - 1]; } } static void ssl_cipher_collect_aliases(const SSL_CIPHER **ca_list, int num_of_group_aliases, unsigned long disabled_mkey, unsigned long disabled_auth, unsigned long disabled_enc, unsigned long disabled_mac, unsigned long disabled_ssl, CIPHER_ORDER *head) { CIPHER_ORDER *ciph_curr; const SSL_CIPHER **ca_curr; int i; unsigned long mask_mkey = ~disabled_mkey; unsigned long mask_auth = ~disabled_auth; unsigned long mask_enc = ~disabled_enc; unsigned long mask_mac = ~disabled_mac; unsigned long mask_ssl = ~disabled_ssl; /* * First, add the real ciphers as already collected */ ciph_curr = head; ca_curr = ca_list; while (ciph_curr != NULL) { *ca_curr = ciph_curr->cipher; ca_curr++; ciph_curr = ciph_curr->next; } /* * Now we add the available ones from the cipher_aliases[] table. * They represent either one or more algorithms, some of which * in any affected category must be supported (set in enabled_mask), * or represent a cipher strength value (will be added in any case because algorithms=0). */ for (i = 0; i < num_of_group_aliases; i++) { unsigned long algorithm_mkey = cipher_aliases[i].algorithm_mkey; unsigned long algorithm_auth = cipher_aliases[i].algorithm_auth; unsigned long algorithm_enc = cipher_aliases[i].algorithm_enc; unsigned long algorithm_mac = cipher_aliases[i].algorithm_mac; unsigned long algorithm_ssl = cipher_aliases[i].algorithm_ssl; if (algorithm_mkey) if ((algorithm_mkey & mask_mkey) == 0) continue; if (algorithm_auth) if ((algorithm_auth & mask_auth) == 0) continue; if (algorithm_enc) if ((algorithm_enc & mask_enc) == 0) continue; if (algorithm_mac) if ((algorithm_mac & mask_mac) == 0) continue; if (algorithm_ssl) if ((algorithm_ssl & mask_ssl) == 0) continue; *ca_curr = (SSL_CIPHER *)(cipher_aliases + i); ca_curr++; } *ca_curr = NULL; /* end of list */ } static void ssl_cipher_apply_rule(unsigned long cipher_id, unsigned long alg_mkey, unsigned long alg_auth, unsigned long alg_enc, unsigned long alg_mac, unsigned long alg_ssl, unsigned long algo_strength, int rule, int strength_bits, CIPHER_ORDER **head_p, CIPHER_ORDER **tail_p) { CIPHER_ORDER *head, *tail, *curr, *curr2, *last; const SSL_CIPHER *cp; int reverse = 0; if (rule == CIPHER_DEL) reverse = 1; /* needed to maintain sorting between currently deleted ciphers */ head = *head_p; tail = *tail_p; if (reverse) { curr = tail; last = head; } else { curr = head; last = tail; } curr2 = curr; for (;;) { if ((curr == NULL) || (curr == last)) break; curr = curr2; curr2 = reverse ? curr->prev : curr->next; cp = curr->cipher; /* * Selection criteria is either the value of strength_bits * or the algorithms used. */ if (strength_bits >= 0) { if (strength_bits != cp->strength_bits) continue; } else { if (alg_mkey && !(alg_mkey & cp->algorithm_mkey)) continue; if (alg_auth && !(alg_auth & cp->algorithm_auth)) continue; if (alg_enc && !(alg_enc & cp->algorithm_enc)) continue; if (alg_mac && !(alg_mac & cp->algorithm_mac)) continue; if (alg_ssl && !(alg_ssl & cp->algorithm_ssl)) continue; if ((algo_strength & SSL_STRONG_MASK) && !(algo_strength & SSL_STRONG_MASK & cp->algo_strength)) continue; } /* add the cipher if it has not been added yet. */ if (rule == CIPHER_ADD) { /* reverse == 0 */ if (!curr->active) { ll_append_tail(&head, curr, &tail); curr->active = 1; } } /* Move the added cipher to this location */ else if (rule == CIPHER_ORD) { /* reverse == 0 */ if (curr->active) { ll_append_tail(&head, curr, &tail); } } else if (rule == CIPHER_DEL) { /* reverse == 1 */ if (curr->active) { /* most recently deleted ciphersuites get best positions * for any future CIPHER_ADD (note that the CIPHER_DEL loop * works in reverse to maintain the order) */ ll_append_head(&head, curr, &tail); curr->active = 0; } } else if (rule == CIPHER_KILL) { /* reverse == 0 */ if (head == curr) head = curr->next; else curr->prev->next = curr->next; if (tail == curr) tail = curr->prev; curr->active = 0; if (curr->next != NULL) curr->next->prev = curr->prev; if (curr->prev != NULL) curr->prev->next = curr->next; curr->next = NULL; curr->prev = NULL; } } *head_p = head; *tail_p = tail; } static int ssl_cipher_strength_sort(CIPHER_ORDER **head_p, CIPHER_ORDER **tail_p) { int max_strength_bits, i, *number_uses; CIPHER_ORDER *curr; /* * This routine sorts the ciphers with descending strength. The sorting * must keep the pre-sorted sequence, so we apply the normal sorting * routine as '+' movement to the end of the list. */ max_strength_bits = 0; curr = *head_p; while (curr != NULL) { if (curr->active && (curr->cipher->strength_bits > max_strength_bits)) max_strength_bits = curr->cipher->strength_bits; curr = curr->next; } number_uses = calloc((max_strength_bits + 1), sizeof(int)); if (!number_uses) { SSLerr(SSL_F_SSL_CIPHER_STRENGTH_SORT, ERR_R_MALLOC_FAILURE); return (0); } /* * Now find the strength_bits values actually used */ curr = *head_p; while (curr != NULL) { if (curr->active) number_uses[curr->cipher->strength_bits]++; curr = curr->next; } /* * Go through the list of used strength_bits values in descending * order. */ for (i = max_strength_bits; i >= 0; i--) if (number_uses[i] > 0) ssl_cipher_apply_rule(0, 0, 0, 0, 0, 0, 0, CIPHER_ORD, i, head_p, tail_p); free(number_uses); return (1); } static int ssl_cipher_process_rulestr(const char *rule_str, CIPHER_ORDER **head_p, CIPHER_ORDER **tail_p, const SSL_CIPHER **ca_list) { unsigned long alg_mkey, alg_auth, alg_enc, alg_mac, alg_ssl; unsigned long algo_strength; int j, multi, found, rule, retval, ok, buflen; unsigned long cipher_id = 0; const char *l, *buf; char ch; retval = 1; l = rule_str; for (;;) { ch = *l; if (ch == '\0') break; if (ch == '-') { rule = CIPHER_DEL; l++; } else if (ch == '+') { rule = CIPHER_ORD; l++; } else if (ch == '!') { rule = CIPHER_KILL; l++; } else if (ch == '@') { rule = CIPHER_SPECIAL; l++; } else { rule = CIPHER_ADD; } if (ITEM_SEP(ch)) { l++; continue; } alg_mkey = 0; alg_auth = 0; alg_enc = 0; alg_mac = 0; alg_ssl = 0; algo_strength = 0; for (;;) { ch = *l; buf = l; buflen = 0; while (((ch >= 'A') && (ch <= 'Z')) || ((ch >= '0') && (ch <= '9')) || ((ch >= 'a') && (ch <= 'z')) || (ch == '-') || (ch == '.')) { ch = *(++l); buflen++; } if (buflen == 0) { /* * We hit something we cannot deal with, * it is no command or separator nor * alphanumeric, so we call this an error. */ SSLerr(SSL_F_SSL_CIPHER_PROCESS_RULESTR, SSL_R_INVALID_COMMAND); retval = found = 0; l++; break; } if (rule == CIPHER_SPECIAL) { /* unused -- avoid compiler warning */ found = 0; /* special treatment */ break; } /* check for multi-part specification */ if (ch == '+') { multi = 1; l++; } else multi = 0; /* * Now search for the cipher alias in the ca_list. * Be careful with the strncmp, because the "buflen" * limitation will make the rule "ADH:SOME" and the * cipher "ADH-MY-CIPHER" look like a match for * buflen=3. So additionally check whether the cipher * name found has the correct length. We can save a * strlen() call: just checking for the '\0' at the * right place is sufficient, we have to strncmp() * anyway (we cannot use strcmp(), because buf is not * '\0' terminated.) */ j = found = 0; cipher_id = 0; while (ca_list[j]) { if (!strncmp(buf, ca_list[j]->name, buflen) && (ca_list[j]->name[buflen] == '\0')) { found = 1; break; } else j++; } if (!found) break; /* ignore this entry */ if (ca_list[j]->algorithm_mkey) { if (alg_mkey) { alg_mkey &= ca_list[j]->algorithm_mkey; if (!alg_mkey) { found = 0; break; } } else alg_mkey = ca_list[j]->algorithm_mkey; } if (ca_list[j]->algorithm_auth) { if (alg_auth) { alg_auth &= ca_list[j]->algorithm_auth; if (!alg_auth) { found = 0; break; } } else alg_auth = ca_list[j]->algorithm_auth; } if (ca_list[j]->algorithm_enc) { if (alg_enc) { alg_enc &= ca_list[j]->algorithm_enc; if (!alg_enc) { found = 0; break; } } else alg_enc = ca_list[j]->algorithm_enc; } if (ca_list[j]->algorithm_mac) { if (alg_mac) { alg_mac &= ca_list[j]->algorithm_mac; if (!alg_mac) { found = 0; break; } } else alg_mac = ca_list[j]->algorithm_mac; } if (ca_list[j]->algo_strength & SSL_STRONG_MASK) { if (algo_strength & SSL_STRONG_MASK) { algo_strength &= (ca_list[j]->algo_strength & SSL_STRONG_MASK) | ~SSL_STRONG_MASK; if (!(algo_strength & SSL_STRONG_MASK)) { found = 0; break; } } else algo_strength |= ca_list[j]->algo_strength & SSL_STRONG_MASK; } if (ca_list[j]->valid) { /* * explicit ciphersuite found; its protocol * version does not become part of the search * pattern! */ cipher_id = ca_list[j]->id; } else { /* * not an explicit ciphersuite; only in this * case, the protocol version is considered * part of the search pattern */ if (ca_list[j]->algorithm_ssl) { if (alg_ssl) { alg_ssl &= ca_list[j]->algorithm_ssl; if (!alg_ssl) { found = 0; break; } } else alg_ssl = ca_list[j]->algorithm_ssl; } } if (!multi) break; } /* * Ok, we have the rule, now apply it */ if (rule == CIPHER_SPECIAL) { /* special command */ ok = 0; if ((buflen == 8) && !strncmp(buf, "STRENGTH", 8)) ok = ssl_cipher_strength_sort(head_p, tail_p); else SSLerr(SSL_F_SSL_CIPHER_PROCESS_RULESTR, SSL_R_INVALID_COMMAND); if (ok == 0) retval = 0; /* * We do not support any "multi" options * together with "@", so throw away the * rest of the command, if any left, until * end or ':' is found. */ while ((*l != '\0') && !ITEM_SEP(*l)) l++; } else if (found) { ssl_cipher_apply_rule(cipher_id, alg_mkey, alg_auth, alg_enc, alg_mac, alg_ssl, algo_strength, rule, -1, head_p, tail_p); } else { while ((*l != '\0') && !ITEM_SEP(*l)) l++; } if (*l == '\0') break; /* done */ } return (retval); } STACK_OF(SSL_CIPHER) * ssl_create_cipher_list(const SSL_METHOD *ssl_method, STACK_OF(SSL_CIPHER) **cipher_list, STACK_OF(SSL_CIPHER) **cipher_list_by_id, const char *rule_str) { int ok, num_of_ciphers, num_of_alias_max, num_of_group_aliases; unsigned long disabled_mkey, disabled_auth, disabled_enc, disabled_mac, disabled_ssl; STACK_OF(SSL_CIPHER) *cipherstack, *tmp_cipher_list; const char *rule_p; CIPHER_ORDER *co_list = NULL, *head = NULL, *tail = NULL, *curr; const SSL_CIPHER **ca_list = NULL; /* * Return with error if nothing to do. */ if (rule_str == NULL || cipher_list == NULL || cipher_list_by_id == NULL) return NULL; /* * To reduce the work to do we only want to process the compiled * in algorithms, so we first get the mask of disabled ciphers. */ ssl_cipher_get_disabled(&disabled_mkey, &disabled_auth, &disabled_enc, &disabled_mac, &disabled_ssl); /* * Now we have to collect the available ciphers from the compiled * in ciphers. We cannot get more than the number compiled in, so * it is used for allocation. */ num_of_ciphers = ssl_method->num_ciphers(); co_list = reallocarray(NULL, num_of_ciphers, sizeof(CIPHER_ORDER)); if (co_list == NULL) { SSLerr(SSL_F_SSL_CREATE_CIPHER_LIST, ERR_R_MALLOC_FAILURE); return(NULL); /* Failure */ } ssl_cipher_collect_ciphers(ssl_method, num_of_ciphers, disabled_mkey, disabled_auth, disabled_enc, disabled_mac, disabled_ssl, co_list, &head, &tail); /* Now arrange all ciphers by preference: */ /* Everything else being equal, prefer ephemeral ECDH over other key exchange mechanisms */ ssl_cipher_apply_rule(0, SSL_kEECDH, 0, 0, 0, 0, 0, CIPHER_ADD, -1, &head, &tail); ssl_cipher_apply_rule(0, SSL_kEECDH, 0, 0, 0, 0, 0, CIPHER_DEL, -1, &head, &tail); /* * CHACHA20 is fast and safe on all hardware and is thus our preferred * symmetric cipher, with AES second. */ ssl_cipher_apply_rule(0, 0, 0, SSL_CHACHA20POLY1305, 0, 0, 0, CIPHER_ADD, -1, &head, &tail); ssl_cipher_apply_rule(0, 0, 0, SSL_AES, 0, 0, 0, CIPHER_ADD, -1, &head, &tail); /* Temporarily enable everything else for sorting */ ssl_cipher_apply_rule(0, 0, 0, 0, 0, 0, 0, CIPHER_ADD, -1, &head, &tail); /* Low priority for MD5 */ ssl_cipher_apply_rule(0, 0, 0, 0, SSL_MD5, 0, 0, CIPHER_ORD, -1, &head, &tail); /* Move anonymous ciphers to the end. Usually, these will remain disabled. * (For applications that allow them, they aren't too bad, but we prefer * authenticated ciphers.) */ ssl_cipher_apply_rule(0, 0, SSL_aNULL, 0, 0, 0, 0, CIPHER_ORD, -1, &head, &tail); /* Move ciphers without forward secrecy to the end */ ssl_cipher_apply_rule(0, 0, SSL_aECDH, 0, 0, 0, 0, CIPHER_ORD, -1, &head, &tail); /* ssl_cipher_apply_rule(0, 0, SSL_aDH, 0, 0, 0, 0, CIPHER_ORD, -1, &head, &tail); */ ssl_cipher_apply_rule(0, SSL_kRSA, 0, 0, 0, 0, 0, CIPHER_ORD, -1, &head, &tail); ssl_cipher_apply_rule(0, SSL_kPSK, 0, 0, 0, 0, 0, CIPHER_ORD, -1, &head, &tail); ssl_cipher_apply_rule(0, SSL_kKRB5, 0, 0, 0, 0, 0, CIPHER_ORD, -1, &head, &tail); /* RC4 is sort-of broken -- move the the end */ ssl_cipher_apply_rule(0, 0, 0, SSL_RC4, 0, 0, 0, CIPHER_ORD, -1, &head, &tail); /* Now sort by symmetric encryption strength. The above ordering remains * in force within each class */ if (!ssl_cipher_strength_sort(&head, &tail)) { free(co_list); return NULL; } /* Now disable everything (maintaining the ordering!) */ ssl_cipher_apply_rule(0, 0, 0, 0, 0, 0, 0, CIPHER_DEL, -1, &head, &tail); /* * We also need cipher aliases for selecting based on the rule_str. * There might be two types of entries in the rule_str: 1) names * of ciphers themselves 2) aliases for groups of ciphers. * For 1) we need the available ciphers and for 2) the cipher * groups of cipher_aliases added together in one list (otherwise * we would be happy with just the cipher_aliases table). */ num_of_group_aliases = sizeof(cipher_aliases) / sizeof(SSL_CIPHER); num_of_alias_max = num_of_ciphers + num_of_group_aliases + 1; ca_list = reallocarray(NULL, num_of_alias_max, sizeof(SSL_CIPHER *)); if (ca_list == NULL) { free(co_list); SSLerr(SSL_F_SSL_CREATE_CIPHER_LIST, ERR_R_MALLOC_FAILURE); return(NULL); /* Failure */ } ssl_cipher_collect_aliases(ca_list, num_of_group_aliases, disabled_mkey, disabled_auth, disabled_enc, disabled_mac, disabled_ssl, head); /* * If the rule_string begins with DEFAULT, apply the default rule * before using the (possibly available) additional rules. */ ok = 1; rule_p = rule_str; if (strncmp(rule_str, "DEFAULT", 7) == 0) { ok = ssl_cipher_process_rulestr(SSL_DEFAULT_CIPHER_LIST, &head, &tail, ca_list); rule_p += 7; if (*rule_p == ':') rule_p++; } if (ok && (strlen(rule_p) > 0)) ok = ssl_cipher_process_rulestr(rule_p, &head, &tail, ca_list); free((void *)ca_list); /* Not needed anymore */ if (!ok) { /* Rule processing failure */ free(co_list); return (NULL); } /* * Allocate new "cipherstack" for the result, return with error * if we cannot get one. */ if ((cipherstack = sk_SSL_CIPHER_new_null()) == NULL) { free(co_list); return (NULL); } /* * The cipher selection for the list is done. The ciphers are added * to the resulting precedence to the STACK_OF(SSL_CIPHER). */ for (curr = head; curr != NULL; curr = curr->next) { if (curr->active) { sk_SSL_CIPHER_push(cipherstack, curr->cipher); } } free(co_list); /* Not needed any longer */ tmp_cipher_list = sk_SSL_CIPHER_dup(cipherstack); if (tmp_cipher_list == NULL) { sk_SSL_CIPHER_free(cipherstack); return NULL; } if (*cipher_list != NULL) sk_SSL_CIPHER_free(*cipher_list); *cipher_list = cipherstack; if (*cipher_list_by_id != NULL) sk_SSL_CIPHER_free(*cipher_list_by_id); *cipher_list_by_id = tmp_cipher_list; (void)sk_SSL_CIPHER_set_cmp_func(*cipher_list_by_id, ssl_cipher_ptr_id_cmp); sk_SSL_CIPHER_sort(*cipher_list_by_id); return (cipherstack); } char * SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int len) { static const char *fmt="%-23s %s Kx=%-8s Au=%-4s Enc=%-9s Mac=%-4s\n"; unsigned long alg_mkey, alg_auth, alg_enc, alg_mac, alg_ssl, alg2; const char *ver, *kx, *au, *enc, *mac; char *ret; int l; alg_mkey = cipher->algorithm_mkey; alg_auth = cipher->algorithm_auth; alg_enc = cipher->algorithm_enc; alg_mac = cipher->algorithm_mac; alg_ssl = cipher->algorithm_ssl; alg2 = cipher->algorithm2; if (alg_ssl & SSL_SSLV2) ver = "SSLv2"; else if (alg_ssl & SSL_SSLV3) ver = "SSLv3"; else if (alg_ssl & SSL_TLSV1_2) ver = "TLSv1.2"; else ver = "unknown"; switch (alg_mkey) { case SSL_kRSA: kx = "RSA"; break; case SSL_kDHr: kx = "DH/RSA"; break; case SSL_kDHd: kx = "DH/DSS"; break; case SSL_kKRB5: kx = "KRB5"; break; case SSL_kEDH: kx = "DH"; break; case SSL_kECDHr: kx = "ECDH/RSA"; break; case SSL_kECDHe: kx = "ECDH/ECDSA"; break; case SSL_kEECDH: kx = "ECDH"; break; case SSL_kPSK: kx = "PSK"; break; case SSL_kSRP: kx = "SRP"; break; default: kx = "unknown"; } switch (alg_auth) { case SSL_aRSA: au = "RSA"; break; case SSL_aDSS: au = "DSS"; break; case SSL_aDH: au = "DH"; break; case SSL_aKRB5: au = "KRB5"; break; case SSL_aECDH: au = "ECDH"; break; case SSL_aNULL: au = "None"; break; case SSL_aECDSA: au = "ECDSA"; break; case SSL_aPSK: au = "PSK"; break; default: au = "unknown"; break; } switch (alg_enc) { case SSL_DES: enc = "DES(56)"; break; case SSL_3DES: enc = "3DES(168)"; break; case SSL_RC4: enc = alg2 & SSL2_CF_8_BYTE_ENC ? "RC4(64)" : "RC4(128)"; break; case SSL_RC2: enc = "RC2(128)"; break; case SSL_IDEA: enc = "IDEA(128)"; break; case SSL_eNULL: enc = "None"; break; case SSL_AES128: enc = "AES(128)"; break; case SSL_AES256: enc = "AES(256)"; break; case SSL_AES128GCM: enc = "AESGCM(128)"; break; case SSL_AES256GCM: enc = "AESGCM(256)"; break; case SSL_CAMELLIA128: enc = "Camellia(128)"; break; case SSL_CAMELLIA256: enc = "Camellia(256)"; break; case SSL_SEED: enc = "SEED(128)"; break; case SSL_CHACHA20POLY1305: enc = "ChaCha20-Poly1305"; break; default: enc = "unknown"; break; } switch (alg_mac) { case SSL_MD5: mac = "MD5"; break; case SSL_SHA1: mac = "SHA1"; break; case SSL_SHA256: mac = "SHA256"; break; case SSL_SHA384: mac = "SHA384"; break; case SSL_AEAD: mac = "AEAD"; break; default: mac = "unknown"; break; } if (asprintf(&ret, fmt, cipher->name, ver, kx, au, enc, mac) == -1) return "OPENSSL_malloc Error"; if (buf != NULL) { l = strlcpy(buf, ret, len); free(ret); ret = buf; if (l >= len) ret = "Buffer too small"; } return (ret); } char * SSL_CIPHER_get_version(const SSL_CIPHER *c) { int i; if (c == NULL) return("(NONE)"); i = (int)(c->id >> 24L); if (i == 3) return("TLSv1/SSLv3"); else if (i == 2) return("SSLv2"); else return("unknown"); } /* return the actual cipher being used */ const char * SSL_CIPHER_get_name(const SSL_CIPHER *c) { if (c != NULL) return (c->name); return("(NONE)"); } /* number of bits for symmetric cipher */ int SSL_CIPHER_get_bits(const SSL_CIPHER *c, int *alg_bits) { int ret = 0; if (c != NULL) { if (alg_bits != NULL) *alg_bits = c->alg_bits; ret = c->strength_bits; } return (ret); } unsigned long SSL_CIPHER_get_id(const SSL_CIPHER *c) { return c->id; } void * SSL_COMP_get_compression_methods(void) { return NULL; } int SSL_COMP_add_compression_method(int id, void *cm) { return 1; } const char * SSL_COMP_get_name(const void *comp) { return NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/ssl/s3_srvr.c0000644000175000017500000022527512360020705017316 0ustar /* $OpenBSD: s3_srvr.c,v 1.73 2014/07/11 12:24:51 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * Portions of the attached software ("Contribution") are developed by * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. * * The Contribution is licensed pursuant to the OpenSSL open source * license provided above. * * ECC cipher suite support in OpenSSL originally written by * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories. * */ /* ==================================================================== * Copyright 2005 Nokia. All rights reserved. * * The portions of the attached software ("Contribution") is developed by * Nokia Corporation and is licensed pursuant to the OpenSSL open source * license. * * The Contribution, originally written by Mika Kousa and Pasi Eronen of * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites * support (see RFC 4279) to OpenSSL. * * No patent licenses or other rights except those expressly stated in * the OpenSSL open source license shall be deemed granted or received * expressly, by implication, estoppel, or otherwise. * * No assurances are provided by Nokia that the Contribution does not * infringe the patent or other intellectual property rights of any third * party or that the license provides you with all the necessary rights * to make use of the Contribution. * * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR * OTHERWISE. */ #define REUSE_CIPHER_BUG #define NETSCAPE_HANG_BUG #include #include "ssl_locl.h" #include #include #include #include #include #include #include #include #include static const SSL_METHOD *ssl3_get_server_method(int ver); const SSL_METHOD SSLv3_server_method_data = { .version = SSL3_VERSION, .ssl_new = ssl3_new, .ssl_clear = ssl3_clear, .ssl_free = ssl3_free, .ssl_accept = ssl3_accept, .ssl_connect = ssl_undefined_function, .ssl_read = ssl3_read, .ssl_peek = ssl3_peek, .ssl_write = ssl3_write, .ssl_shutdown = ssl3_shutdown, .ssl_renegotiate = ssl3_renegotiate, .ssl_renegotiate_check = ssl3_renegotiate_check, .ssl_get_message = ssl3_get_message, .ssl_read_bytes = ssl3_read_bytes, .ssl_write_bytes = ssl3_write_bytes, .ssl_dispatch_alert = ssl3_dispatch_alert, .ssl_ctrl = ssl3_ctrl, .ssl_ctx_ctrl = ssl3_ctx_ctrl, .get_cipher_by_char = ssl3_get_cipher_by_char, .put_cipher_by_char = ssl3_put_cipher_by_char, .ssl_pending = ssl3_pending, .num_ciphers = ssl3_num_ciphers, .get_cipher = ssl3_get_cipher, .get_ssl_method = ssl3_get_server_method, .get_timeout = ssl3_default_timeout, .ssl3_enc = &SSLv3_enc_data, .ssl_version = ssl_undefined_void_function, .ssl_callback_ctrl = ssl3_callback_ctrl, .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, }; const SSL_METHOD * SSLv3_server_method(void) { return &SSLv3_server_method_data; } static const SSL_METHOD * ssl3_get_server_method(int ver) { if (ver == SSL3_VERSION) return (SSLv3_server_method()); return (NULL); } int ssl3_accept(SSL *s) { unsigned long alg_k; void (*cb)(const SSL *ssl, int type, int val) = NULL; int ret = -1; int new_state, state, skip = 0; ERR_clear_error(); errno = 0; if (s->info_callback != NULL) cb = s->info_callback; else if (s->ctx->info_callback != NULL) cb = s->ctx->info_callback; /* init things to blank */ s->in_handshake++; if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); if (s->cert == NULL) { SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_NO_CERTIFICATE_SET); return (-1); } for (;;) { state = s->state; switch (s->state) { case SSL_ST_RENEGOTIATE: s->renegotiate = 1; /* s->state=SSL_ST_ACCEPT; */ case SSL_ST_BEFORE: case SSL_ST_ACCEPT: case SSL_ST_BEFORE|SSL_ST_ACCEPT: case SSL_ST_OK|SSL_ST_ACCEPT: s->server = 1; if (cb != NULL) cb(s, SSL_CB_HANDSHAKE_START, 1); if ((s->version >> 8) != 3) { SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); return (-1); } s->type = SSL_ST_ACCEPT; if (s->init_buf == NULL) { BUF_MEM *buf; if ((buf = BUF_MEM_new()) == NULL) { ret = -1; goto end; } if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { BUF_MEM_free(buf); ret = -1; goto end; } s->init_buf = buf; } if (!ssl3_setup_buffers(s)) { ret = -1; goto end; } s->init_num = 0; s->s3->flags &= ~SSL3_FLAGS_SGC_RESTART_DONE; if (s->state != SSL_ST_RENEGOTIATE) { /* * Ok, we now need to push on a buffering BIO * so that the output is sent in a way that * TCP likes :-) */ if (!ssl_init_wbio_buffer(s, 1)) { ret = -1; goto end; } ssl3_init_finished_mac(s); s->state = SSL3_ST_SR_CLNT_HELLO_A; s->ctx->stats.sess_accept++; } else if (!s->s3->send_connection_binding) { /* * Server attempting to renegotiate with * client that doesn't support secure * renegotiation. */ SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); ret = -1; goto end; } else { /* * s->state == SSL_ST_RENEGOTIATE, * we will just send a HelloRequest */ s->ctx->stats.sess_accept_renegotiate++; s->state = SSL3_ST_SW_HELLO_REQ_A; } break; case SSL3_ST_SW_HELLO_REQ_A: case SSL3_ST_SW_HELLO_REQ_B: s->shutdown = 0; ret = ssl3_send_hello_request(s); if (ret <= 0) goto end; s->s3->tmp.next_state = SSL3_ST_SW_HELLO_REQ_C; s->state = SSL3_ST_SW_FLUSH; s->init_num = 0; ssl3_init_finished_mac(s); break; case SSL3_ST_SW_HELLO_REQ_C: s->state = SSL_ST_OK; break; case SSL3_ST_SR_CLNT_HELLO_A: case SSL3_ST_SR_CLNT_HELLO_B: case SSL3_ST_SR_CLNT_HELLO_C: s->shutdown = 0; if (s->rwstate != SSL_X509_LOOKUP) { ret = ssl3_get_client_hello(s); if (ret <= 0) goto end; } s->renegotiate = 2; s->state = SSL3_ST_SW_SRVR_HELLO_A; s->init_num = 0; break; case SSL3_ST_SW_SRVR_HELLO_A: case SSL3_ST_SW_SRVR_HELLO_B: ret = ssl3_send_server_hello(s); if (ret <= 0) goto end; if (s->hit) { if (s->tlsext_ticket_expected) s->state = SSL3_ST_SW_SESSION_TICKET_A; else s->state = SSL3_ST_SW_CHANGE_A; } else s->state = SSL3_ST_SW_CERT_A; s->init_num = 0; break; case SSL3_ST_SW_CERT_A: case SSL3_ST_SW_CERT_B: /* Check if it is anon DH or anon ECDH, */ /* normal PSK or KRB5 or SRP */ if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK) && !(s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5)) { ret = ssl3_send_server_certificate(s); if (ret <= 0) goto end; if (s->tlsext_status_expected) s->state = SSL3_ST_SW_CERT_STATUS_A; else s->state = SSL3_ST_SW_KEY_EXCH_A; } else { skip = 1; s->state = SSL3_ST_SW_KEY_EXCH_A; } s->init_num = 0; break; case SSL3_ST_SW_KEY_EXCH_A: case SSL3_ST_SW_KEY_EXCH_B: alg_k = s->s3->tmp.new_cipher->algorithm_mkey; /* * Clear this, it may get reset by * send_server_key_exchange. */ if ((s->options & SSL_OP_EPHEMERAL_RSA) ) /* * option SSL_OP_EPHEMERAL_RSA sends temporary * RSA key even when forbidden by protocol * specs (handshake may fail as clients are * not required to be able to handle this) */ s->s3->tmp.use_rsa_tmp = 1; else s->s3->tmp.use_rsa_tmp = 0; /* * Only send if a DH key exchange, fortezza or * RSA but we have a sign only certificate * * PSK: send ServerKeyExchange if PSK identity * hint is provided * * For ECC ciphersuites, we send a serverKeyExchange * message only if the cipher suite is either * ECDH-anon or ECDHE. In other cases, the * server certificate contains the server's * public key for key exchange. */ if (s->s3->tmp.use_rsa_tmp || (alg_k & (SSL_kDHr|SSL_kDHd|SSL_kEDH)) || (alg_k & SSL_kEECDH) || ((alg_k & SSL_kRSA) && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL ))) { ret = ssl3_send_server_key_exchange(s); if (ret <= 0) goto end; } else skip = 1; s->state = SSL3_ST_SW_CERT_REQ_A; s->init_num = 0; break; case SSL3_ST_SW_CERT_REQ_A: case SSL3_ST_SW_CERT_REQ_B: if (/* Don't request cert unless asked for it: */ !(s->verify_mode & SSL_VERIFY_PEER) || /* * If SSL_VERIFY_CLIENT_ONCE is set, * don't request cert during re-negotiation: */ ((s->session->peer != NULL) && (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) || /* * Never request cert in anonymous ciphersuites * (see section "Certificate request" in SSL 3 * drafts and in RFC 2246): */ ((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && /* * ... except when the application insists on * verification (against the specs, but * s3_clnt.c accepts this for SSL 3) */ !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) || /* never request cert in Kerberos ciphersuites */ (s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) /* * With normal PSK Certificates and * Certificate Requests are omitted */ || (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { /* No cert request */ skip = 1; s->s3->tmp.cert_request = 0; s->state = SSL3_ST_SW_SRVR_DONE_A; if (s->s3->handshake_buffer) if (!ssl3_digest_cached_records(s)) return (-1); } else { s->s3->tmp.cert_request = 1; ret = ssl3_send_certificate_request(s); if (ret <= 0) goto end; #ifndef NETSCAPE_HANG_BUG s->state = SSL3_ST_SW_SRVR_DONE_A; #else s->state = SSL3_ST_SW_FLUSH; s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; #endif s->init_num = 0; } break; case SSL3_ST_SW_SRVR_DONE_A: case SSL3_ST_SW_SRVR_DONE_B: ret = ssl3_send_server_done(s); if (ret <= 0) goto end; s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; s->state = SSL3_ST_SW_FLUSH; s->init_num = 0; break; case SSL3_ST_SW_FLUSH: /* * This code originally checked to see if * any data was pending using BIO_CTRL_INFO * and then flushed. This caused problems * as documented in PR#1939. The proposed * fix doesn't completely resolve this issue * as buggy implementations of BIO_CTRL_PENDING * still exist. So instead we just flush * unconditionally. */ s->rwstate = SSL_WRITING; if (BIO_flush(s->wbio) <= 0) { ret = -1; goto end; } s->rwstate = SSL_NOTHING; s->state = s->s3->tmp.next_state; break; case SSL3_ST_SR_CERT_A: case SSL3_ST_SR_CERT_B: /* Check for second client hello (MS SGC) */ ret = ssl3_check_client_hello(s); if (ret <= 0) goto end; if (ret == 2) s->state = SSL3_ST_SR_CLNT_HELLO_C; else { if (s->s3->tmp.cert_request) { ret = ssl3_get_client_certificate(s); if (ret <= 0) goto end; } s->init_num = 0; s->state = SSL3_ST_SR_KEY_EXCH_A; } break; case SSL3_ST_SR_KEY_EXCH_A: case SSL3_ST_SR_KEY_EXCH_B: ret = ssl3_get_client_key_exchange(s); if (ret <= 0) goto end; if (ret == 2) { /* * For the ECDH ciphersuites when * the client sends its ECDH pub key in * a certificate, the CertificateVerify * message is not sent. * Also for GOST ciphersuites when * the client uses its key from the certificate * for key exchange. */ #ifdef OPENSSL_NO_NEXTPROTONEG s->state = SSL3_ST_SR_FINISHED_A; #else if (s->s3->next_proto_neg_seen) s->state = SSL3_ST_SR_NEXT_PROTO_A; else s->state = SSL3_ST_SR_FINISHED_A; #endif s->init_num = 0; } else if (SSL_USE_SIGALGS(s)) { s->state = SSL3_ST_SR_CERT_VRFY_A; s->init_num = 0; if (!s->session->peer) break; /* * For sigalgs freeze the handshake buffer * at this point and digest cached records. */ if (!s->s3->handshake_buffer) { SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); return (-1); } s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE; if (!ssl3_digest_cached_records(s)) return (-1); } else { int offset = 0; int dgst_num; s->state = SSL3_ST_SR_CERT_VRFY_A; s->init_num = 0; /* * We need to get hashes here so if there is * a client cert, it can be verified * FIXME - digest processing for * CertificateVerify should be generalized. * But it is next step */ if (s->s3->handshake_buffer) if (!ssl3_digest_cached_records(s)) return (-1); for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; dgst_num++) if (s->s3->handshake_dgst[dgst_num]) { int dgst_size; s->method->ssl3_enc->cert_verify_mac(s, EVP_MD_CTX_type( s->s3->handshake_dgst[dgst_num]), &(s->s3->tmp.cert_verify_md[offset])); dgst_size = EVP_MD_CTX_size( s->s3->handshake_dgst[dgst_num]); if (dgst_size < 0) { ret = -1; goto end; } offset += dgst_size; } } break; case SSL3_ST_SR_CERT_VRFY_A: case SSL3_ST_SR_CERT_VRFY_B: s->s3->flags |= SSL3_FLAGS_CCS_OK; /* we should decide if we expected this one */ ret = ssl3_get_cert_verify(s); if (ret <= 0) goto end; #ifdef OPENSSL_NO_NEXTPROTONEG s->state = SSL3_ST_SR_FINISHED_A; #else if (s->s3->next_proto_neg_seen) s->state = SSL3_ST_SR_NEXT_PROTO_A; else s->state = SSL3_ST_SR_FINISHED_A; #endif s->init_num = 0; break; #ifndef OPENSSL_NO_NEXTPROTONEG case SSL3_ST_SR_NEXT_PROTO_A: case SSL3_ST_SR_NEXT_PROTO_B: ret = ssl3_get_next_proto(s); if (ret <= 0) goto end; s->init_num = 0; s->state = SSL3_ST_SR_FINISHED_A; break; #endif case SSL3_ST_SR_FINISHED_A: case SSL3_ST_SR_FINISHED_B: s->s3->flags |= SSL3_FLAGS_CCS_OK; ret = ssl3_get_finished(s, SSL3_ST_SR_FINISHED_A, SSL3_ST_SR_FINISHED_B); if (ret <= 0) goto end; if (s->hit) s->state = SSL_ST_OK; else if (s->tlsext_ticket_expected) s->state = SSL3_ST_SW_SESSION_TICKET_A; else s->state = SSL3_ST_SW_CHANGE_A; s->init_num = 0; break; case SSL3_ST_SW_SESSION_TICKET_A: case SSL3_ST_SW_SESSION_TICKET_B: ret = ssl3_send_newsession_ticket(s); if (ret <= 0) goto end; s->state = SSL3_ST_SW_CHANGE_A; s->init_num = 0; break; case SSL3_ST_SW_CERT_STATUS_A: case SSL3_ST_SW_CERT_STATUS_B: ret = ssl3_send_cert_status(s); if (ret <= 0) goto end; s->state = SSL3_ST_SW_KEY_EXCH_A; s->init_num = 0; break; case SSL3_ST_SW_CHANGE_A: case SSL3_ST_SW_CHANGE_B: s->session->cipher = s->s3->tmp.new_cipher; if (!s->method->ssl3_enc->setup_key_block(s)) { ret = -1; goto end; } ret = ssl3_send_change_cipher_spec(s, SSL3_ST_SW_CHANGE_A, SSL3_ST_SW_CHANGE_B); if (ret <= 0) goto end; s->state = SSL3_ST_SW_FINISHED_A; s->init_num = 0; if (!s->method->ssl3_enc->change_cipher_state( s, SSL3_CHANGE_CIPHER_SERVER_WRITE)) { ret = -1; goto end; } break; case SSL3_ST_SW_FINISHED_A: case SSL3_ST_SW_FINISHED_B: ret = ssl3_send_finished(s, SSL3_ST_SW_FINISHED_A, SSL3_ST_SW_FINISHED_B, s->method->ssl3_enc->server_finished_label, s->method->ssl3_enc->server_finished_label_len); if (ret <= 0) goto end; s->state = SSL3_ST_SW_FLUSH; if (s->hit) { #ifdef OPENSSL_NO_NEXTPROTONEG s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A; #else if (s->s3->next_proto_neg_seen) { s->s3->flags |= SSL3_FLAGS_CCS_OK; s->s3->tmp.next_state = SSL3_ST_SR_NEXT_PROTO_A; } else s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A; #endif } else s->s3->tmp.next_state = SSL_ST_OK; s->init_num = 0; break; case SSL_ST_OK: /* clean a few things up */ ssl3_cleanup_key_block(s); BUF_MEM_free(s->init_buf); s->init_buf = NULL; /* remove buffering on output */ ssl_free_wbio_buffer(s); s->init_num = 0; /* skipped if we just sent a HelloRequest */ if (s->renegotiate == 2) { s->renegotiate = 0; s->new_session = 0; ssl_update_cache(s, SSL_SESS_CACHE_SERVER); s->ctx->stats.sess_accept_good++; /* s->server=1; */ s->handshake_func = ssl3_accept; if (cb != NULL) cb(s, SSL_CB_HANDSHAKE_DONE, 1); } ret = 1; goto end; /* break; */ default: SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNKNOWN_STATE); ret = -1; goto end; /* break; */ } if (!s->s3->tmp.reuse_message && !skip) { if (s->debug) { if ((ret = BIO_flush(s->wbio)) <= 0) goto end; } if ((cb != NULL) && (s->state != state)) { new_state = s->state; s->state = state; cb(s, SSL_CB_ACCEPT_LOOP, 1); s->state = new_state; } } skip = 0; } end: /* BIO_flush(s->wbio); */ s->in_handshake--; if (cb != NULL) cb(s, SSL_CB_ACCEPT_EXIT, ret); return (ret); } int ssl3_send_hello_request(SSL *s) { unsigned char *p; if (s->state == SSL3_ST_SW_HELLO_REQ_A) { p = (unsigned char *)s->init_buf->data; *(p++) = SSL3_MT_HELLO_REQUEST; *(p++) = 0; *(p++) = 0; *(p++) = 0; s->state = SSL3_ST_SW_HELLO_REQ_B; /* number of bytes to write */ s->init_num = 4; s->init_off = 0; } /* SSL3_ST_SW_HELLO_REQ_B */ return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); } int ssl3_check_client_hello(SSL *s) { int ok; long n; /* * This function is called when we really expect a Certificate message, * so permit appropriate message length */ n = s->method->ssl_get_message(s, SSL3_ST_SR_CERT_A, SSL3_ST_SR_CERT_B, -1, s->max_cert_list, &ok); if (!ok) return ((int)n); s->s3->tmp.reuse_message = 1; if (s->s3->tmp.message_type == SSL3_MT_CLIENT_HELLO) { /* * We only allow the client to restart the handshake once per * negotiation. */ if (s->s3->flags & SSL3_FLAGS_SGC_RESTART_DONE) { SSLerr(SSL_F_SSL3_CHECK_CLIENT_HELLO, SSL_R_MULTIPLE_SGC_RESTARTS); return (-1); } /* * Throw away what we have done so far in the current handshake, * which will now be aborted. (A full SSL_clear would be too * much.) */ DH_free(s->s3->tmp.dh); s->s3->tmp.dh = NULL; EC_KEY_free(s->s3->tmp.ecdh); s->s3->tmp.ecdh = NULL; s->s3->flags |= SSL3_FLAGS_SGC_RESTART_DONE; return (2); } return (1); } int ssl3_get_client_hello(SSL *s) { int i, j, ok, al, ret = -1; unsigned int cookie_len; long n; unsigned long id; unsigned char *p, *d; SSL_CIPHER *c; STACK_OF(SSL_CIPHER) *ciphers = NULL; /* * We do this so that we will respond with our native type. * If we are TLSv1 and we get SSLv3, we will respond with TLSv1, * This down switching should be handled by a different method. * If we are SSLv3, we will respond with SSLv3, even if prompted with * TLSv1. */ if (s->state == SSL3_ST_SR_CLNT_HELLO_A) { s->state = SSL3_ST_SR_CLNT_HELLO_B; } s->first_packet = 1; n = s->method->ssl_get_message(s, SSL3_ST_SR_CLNT_HELLO_B, SSL3_ST_SR_CLNT_HELLO_C, SSL3_MT_CLIENT_HELLO, SSL3_RT_MAX_PLAIN_LENGTH, &ok); if (!ok) return ((int)n); s->first_packet = 0; d = p=(unsigned char *)s->init_msg; /* * Use version from inside client hello, not from record header. * (may differ: see RFC 2246, Appendix E, second paragraph) */ s->client_version = (((int)p[0]) << 8)|(int)p[1]; p += 2; if ((s->version == DTLS1_VERSION && s->client_version > s->version) || (s->version != DTLS1_VERSION && s->client_version < s->version)) { SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_WRONG_VERSION_NUMBER); if ((s->client_version >> 8) == SSL3_VERSION_MAJOR && !s->enc_write_ctx && !s->write_hash) { /* * Similar to ssl3_get_record, send alert using remote * version number */ s->version = s->client_version; } al = SSL_AD_PROTOCOL_VERSION; goto f_err; } /* * If we require cookies and this ClientHello doesn't * contain one, just return since we do not want to * allocate any memory yet. So check cookie length... */ if (SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) { unsigned int session_length, cookie_length; session_length = *(p + SSL3_RANDOM_SIZE); cookie_length = *(p + SSL3_RANDOM_SIZE + session_length + 1); if (cookie_length == 0) return (1); } /* load the client random */ memcpy(s->s3->client_random, p, SSL3_RANDOM_SIZE); p += SSL3_RANDOM_SIZE; /* get the session-id */ j= *(p++); s->hit = 0; /* * Versions before 0.9.7 always allow clients to resume sessions in * renegotiation. 0.9.7 and later allow this by default, but optionally * ignore resumption requests with flag * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION (it's a new flag * rather than a change to default behavior so that applications * relying on this for security won't even compile against older * library versions). * * 1.0.1 and later also have a function SSL_renegotiate_abbreviated() * to request renegotiation but not a new session (s->new_session * remains unset): for servers, this essentially just means that the * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION setting will be * ignored. */ if ((s->new_session && (s->options & SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION))) { if (!ssl_get_new_session(s, 1)) goto err; } else { i = ssl_get_prev_session(s, p, j, d + n); if (i == 1) { /* previous session */ s->hit = 1; } else if (i == -1) goto err; else { /* i == 0 */ if (!ssl_get_new_session(s, 1)) goto err; } } p += j; if (SSL_IS_DTLS(s)) { /* cookie stuff */ cookie_len = *(p++); /* * The ClientHello may contain a cookie even if the * HelloVerify message has not been sent--make sure that it * does not cause an overflow. */ if (cookie_len > sizeof(s->d1->rcvd_cookie)) { /* too much data */ al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH); goto f_err; } /* verify the cookie if appropriate option is set. */ if ((SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) && cookie_len > 0) { memcpy(s->d1->rcvd_cookie, p, cookie_len); if (s->ctx->app_verify_cookie_cb != NULL) { if (s->ctx->app_verify_cookie_cb(s, s->d1->rcvd_cookie, cookie_len) == 0) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH); goto f_err; } /* else cookie verification succeeded */ } else if (timingsafe_memcmp(s->d1->rcvd_cookie, s->d1->cookie, s->d1->cookie_len) != 0) { /* default verification */ al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH); goto f_err; } ret = 2; } p += cookie_len; } n2s(p, i); if ((i == 0) && (j != 0)) { /* we need a cipher if we are not resuming a session */ al = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_CIPHERS_SPECIFIED); goto f_err; } if ((p + i) >= (d + n)) { /* not enough data */ al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH); goto f_err; } if ((i > 0) && (ssl_bytes_to_cipher_list(s, p, i, &(ciphers)) == NULL)) { goto err; } p += i; /* If it is a hit, check that the cipher is in the list */ if ((s->hit) && (i > 0)) { j = 0; id = s->session->cipher->id; for (i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) { c = sk_SSL_CIPHER_value(ciphers, i); if (c->id == id) { j = 1; break; } } if (j == 0) { /* * We need to have the cipher in the cipher * list if we are asked to reuse it */ al = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_REQUIRED_CIPHER_MISSING); goto f_err; } } /* compression */ i= *(p++); if ((p + i) > (d + n)) { /* not enough data */ al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH); goto f_err; } for (j = 0; j < i; j++) { if (p[j] == 0) break; } p += i; if (j >= i) { /* no compress */ al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_COMPRESSION_SPECIFIED); goto f_err; } /* TLS extensions*/ if (s->version >= SSL3_VERSION) { if (!ssl_parse_clienthello_tlsext(s, &p, d, n, &al)) { /* 'al' set by ssl_parse_clienthello_tlsext */ SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_PARSE_TLSEXT); goto f_err; } } if (ssl_check_clienthello_tlsext_early(s) <= 0) { SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); goto err; } /* * Check if we want to use external pre-shared secret for this * handshake for not reused session only. We need to generate * server_random before calling tls_session_secret_cb in order to allow * SessionTicket processing to use it in key derivation. */ { unsigned char *pos; pos = s->s3->server_random; RAND_pseudo_bytes(pos, SSL3_RANDOM_SIZE); } if (!s->hit && s->version >= TLS1_VERSION && s->tls_session_secret_cb) { SSL_CIPHER *pref_cipher = NULL; s->session->master_key_length = sizeof(s->session->master_key); if (s->tls_session_secret_cb(s, s->session->master_key, &s->session->master_key_length, ciphers, &pref_cipher, s->tls_session_secret_cb_arg)) { s->hit = 1; s->session->ciphers = ciphers; s->session->verify_result = X509_V_OK; ciphers = NULL; /* check if some cipher was preferred by call back */ pref_cipher = pref_cipher ? pref_cipher : ssl3_choose_cipher(s, s->session->ciphers, SSL_get_ciphers(s)); if (pref_cipher == NULL) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_SHARED_CIPHER); goto f_err; } s->session->cipher = pref_cipher; if (s->cipher_list) sk_SSL_CIPHER_free(s->cipher_list); if (s->cipher_list_by_id) sk_SSL_CIPHER_free(s->cipher_list_by_id); s->cipher_list = sk_SSL_CIPHER_dup(s->session->ciphers); s->cipher_list_by_id = sk_SSL_CIPHER_dup(s->session->ciphers); } } /* * Given s->session->ciphers and SSL_get_ciphers, we must * pick a cipher */ if (!s->hit) { if (s->session->ciphers != NULL) sk_SSL_CIPHER_free(s->session->ciphers); s->session->ciphers = ciphers; if (ciphers == NULL) { al = SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_CIPHERS_PASSED); goto f_err; } ciphers = NULL; c = ssl3_choose_cipher(s, s->session->ciphers, SSL_get_ciphers(s)); if (c == NULL) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_SHARED_CIPHER); goto f_err; } s->s3->tmp.new_cipher = c; } else { /* Session-id reuse */ #ifdef REUSE_CIPHER_BUG STACK_OF(SSL_CIPHER) *sk; SSL_CIPHER *nc = NULL; SSL_CIPHER *ec = NULL; if (s->options & SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG) { sk = s->session->ciphers; for (i = 0; i < sk_SSL_CIPHER_num(sk); i++) { c = sk_SSL_CIPHER_value(sk, i); if (c->algorithm_enc & SSL_eNULL) nc = c; } if (nc != NULL) s->s3->tmp.new_cipher = nc; else if (ec != NULL) s->s3->tmp.new_cipher = ec; else s->s3->tmp.new_cipher = s->session->cipher; } else #endif s->s3->tmp.new_cipher = s->session->cipher; } if (!SSL_USE_SIGALGS(s) || !(s->verify_mode & SSL_VERIFY_PEER)) { if (!ssl3_digest_cached_records(s)) { al = SSL_AD_INTERNAL_ERROR; goto f_err; } } /* * We now have the following setup. * client_random * cipher_list - our prefered list of ciphers * ciphers - the clients prefered list of ciphers * compression - basically ignored right now * ssl version is set - sslv3 * s->session - The ssl session has been setup. * s->hit - session reuse flag * s->tmp.new_cipher - the new cipher to use. */ /* Handles TLS extensions that we couldn't check earlier */ if (s->version >= SSL3_VERSION) { if (ssl_check_clienthello_tlsext_late(s) <= 0) { SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); goto err; } } if (ret < 0) ret = 1; if (0) { f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); } err: if (ciphers != NULL) sk_SSL_CIPHER_free(ciphers); return (ret); } int ssl3_send_server_hello(SSL *s) { unsigned char *buf; unsigned char *p, *d; int i, sl; unsigned long l; if (s->state == SSL3_ST_SW_SRVR_HELLO_A) { buf = (unsigned char *)s->init_buf->data; /* Do the message type and length last */ d = p= &(buf[4]); *(p++) = s->version >> 8; *(p++) = s->version&0xff; /* Random stuff */ memcpy(p, s->s3->server_random, SSL3_RANDOM_SIZE); p += SSL3_RANDOM_SIZE; /* * There are several cases for the session ID to send * back in the server hello: * * - For session reuse from the session cache, * we send back the old session ID. * - If stateless session reuse (using a session ticket) * is successful, we send back the client's "session ID" * (which doesn't actually identify the session). * - If it is a new session, we send back the new * session ID. * - However, if we want the new session to be single-use, * we send back a 0-length session ID. * * s->hit is non-zero in either case of session reuse, * so the following won't overwrite an ID that we're supposed * to send back. */ if (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_SERVER) && !s->hit) s->session->session_id_length = 0; sl = s->session->session_id_length; if (sl > (int)sizeof(s->session->session_id)) { SSLerr(SSL_F_SSL3_SEND_SERVER_HELLO, ERR_R_INTERNAL_ERROR); return (-1); } *(p++) = sl; memcpy(p, s->session->session_id, sl); p += sl; /* put the cipher */ i = ssl3_put_cipher_by_char(s->s3->tmp.new_cipher, p); p += i; /* put the compression method */ *(p++) = 0; if (ssl_prepare_serverhello_tlsext(s) <= 0) { SSLerr(SSL_F_SSL3_SEND_SERVER_HELLO, SSL_R_SERVERHELLO_TLSEXT); return (-1); } if ((p = ssl_add_serverhello_tlsext(s, p, buf + SSL3_RT_MAX_PLAIN_LENGTH)) == NULL) { SSLerr(SSL_F_SSL3_SEND_SERVER_HELLO, ERR_R_INTERNAL_ERROR); return (-1); } /* do the header */ l = (p - d); d = buf; *(d++) = SSL3_MT_SERVER_HELLO; l2n3(l, d); s->state = SSL3_ST_SW_SRVR_HELLO_B; /* number of bytes to write */ s->init_num = p - buf; s->init_off = 0; } /* SSL3_ST_SW_SRVR_HELLO_B */ return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); } int ssl3_send_server_done(SSL *s) { unsigned char *p; if (s->state == SSL3_ST_SW_SRVR_DONE_A) { p = (unsigned char *)s->init_buf->data; /* do the header */ *(p++) = SSL3_MT_SERVER_DONE; *(p++) = 0; *(p++) = 0; *(p++) = 0; s->state = SSL3_ST_SW_SRVR_DONE_B; /* number of bytes to write */ s->init_num = 4; s->init_off = 0; } /* SSL3_ST_SW_SRVR_DONE_B */ return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); } int ssl3_send_server_key_exchange(SSL *s) { unsigned char *q; int j, num; RSA *rsa; unsigned char md_buf[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH]; unsigned int u; DH *dh = NULL, *dhp; EC_KEY *ecdh = NULL, *ecdhp; unsigned char *encodedPoint = NULL; int encodedlen = 0; int curve_id = 0; BN_CTX *bn_ctx = NULL; EVP_PKEY *pkey; const EVP_MD *md = NULL; unsigned char *p, *d; int al, i; unsigned long type; int n; CERT *cert; BIGNUM *r[4]; int nr[4], kn; BUF_MEM *buf; EVP_MD_CTX md_ctx; EVP_MD_CTX_init(&md_ctx); if (s->state == SSL3_ST_SW_KEY_EXCH_A) { type = s->s3->tmp.new_cipher->algorithm_mkey; cert = s->cert; buf = s->init_buf; r[0] = r[1] = r[2] = r[3] = NULL; n = 0; if (type & SSL_kRSA) { rsa = cert->rsa_tmp; if ((rsa == NULL) && (s->cert->rsa_tmp_cb != NULL)) { rsa = s->cert->rsa_tmp_cb(s, 0, 0); if (rsa == NULL) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr( SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, SSL_R_ERROR_GENERATING_TMP_RSA_KEY); goto f_err; } RSA_up_ref(rsa); cert->rsa_tmp = rsa; } if (rsa == NULL) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, SSL_R_MISSING_TMP_RSA_KEY); goto f_err; } r[0] = rsa->n; r[1] = rsa->e; s->s3->tmp.use_rsa_tmp = 1; } else if (type & SSL_kEDH) { dhp = cert->dh_tmp; if ((dhp == NULL) && (s->cert->dh_tmp_cb != NULL)) dhp = s->cert->dh_tmp_cb(s, 0, 0); if (dhp == NULL) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, SSL_R_MISSING_TMP_DH_KEY); goto f_err; } if (s->s3->tmp.dh != NULL) { SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } if ((dh = DHparams_dup(dhp)) == NULL) { SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB); goto err; } s->s3->tmp.dh = dh; if ((dhp->pub_key == NULL || dhp->priv_key == NULL || (s->options & SSL_OP_SINGLE_DH_USE))) { if (!DH_generate_key(dh)) { SSLerr( SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB); goto err; } } else { dh->pub_key = BN_dup(dhp->pub_key); dh->priv_key = BN_dup(dhp->priv_key); if ((dh->pub_key == NULL) || (dh->priv_key == NULL)) { SSLerr( SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB); goto err; } } r[0] = dh->p; r[1] = dh->g; r[2] = dh->pub_key; } else if (type & SSL_kEECDH) { const EC_GROUP *group; ecdhp = cert->ecdh_tmp; if (ecdhp == NULL && s->cert->ecdh_tmp_cb != NULL) ecdhp = s->cert->ecdh_tmp_cb(s, 0, 0); if (ecdhp == NULL) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, SSL_R_MISSING_TMP_ECDH_KEY); goto f_err; } if (s->s3->tmp.ecdh != NULL) { SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } /* Duplicate the ECDH structure. */ if (ecdhp == NULL) { SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } if ((ecdh = EC_KEY_dup(ecdhp)) == NULL) { SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } s->s3->tmp.ecdh = ecdh; if ((EC_KEY_get0_public_key(ecdh) == NULL) || (EC_KEY_get0_private_key(ecdh) == NULL) || (s->options & SSL_OP_SINGLE_ECDH_USE)) { if (!EC_KEY_generate_key(ecdh)) { SSLerr( SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } } if (((group = EC_KEY_get0_group(ecdh)) == NULL) || (EC_KEY_get0_public_key(ecdh) == NULL) || (EC_KEY_get0_private_key(ecdh) == NULL)) { SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } /* * XXX: For now, we only support ephemeral ECDH * keys over named (not generic) curves. For * supported named curves, curve_id is non-zero. */ if ((curve_id = tls1_ec_nid2curve_id( EC_GROUP_get_curve_name(group))) == 0) { SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, SSL_R_UNSUPPORTED_ELLIPTIC_CURVE); goto err; } /* * Encode the public key. * First check the size of encoding and * allocate memory accordingly. */ encodedlen = EC_POINT_point2oct(group, EC_KEY_get0_public_key(ecdh), POINT_CONVERSION_UNCOMPRESSED, NULL, 0, NULL); encodedPoint = malloc(encodedlen); bn_ctx = BN_CTX_new(); if ((encodedPoint == NULL) || (bn_ctx == NULL)) { SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } encodedlen = EC_POINT_point2oct(group, EC_KEY_get0_public_key(ecdh), POINT_CONVERSION_UNCOMPRESSED, encodedPoint, encodedlen, bn_ctx); if (encodedlen == 0) { SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } BN_CTX_free(bn_ctx); bn_ctx = NULL; /* * XXX: For now, we only support named (not * generic) curves in ECDH ephemeral key exchanges. * In this situation, we need four additional bytes * to encode the entire ServerECDHParams * structure. */ n = 4 + encodedlen; /* * We'll generate the serverKeyExchange message * explicitly so we can set these to NULLs */ r[0] = NULL; r[1] = NULL; r[2] = NULL; r[3] = NULL; } else { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE); goto f_err; } for (i = 0; i < 4 && r[i] != NULL; i++) { nr[i] = BN_num_bytes(r[i]); n += 2 + nr[i]; } if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { if ((pkey = ssl_get_sign_pkey( s, s->s3->tmp.new_cipher, &md)) == NULL) { al = SSL_AD_DECODE_ERROR; goto f_err; } kn = EVP_PKEY_size(pkey); } else { pkey = NULL; kn = 0; } if (!BUF_MEM_grow_clean(buf, n + 4 + kn)) { SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_LIB_BUF); goto err; } d = (unsigned char *)s->init_buf->data; p = &(d[4]); for (i = 0; i < 4 && r[i] != NULL; i++) { s2n(nr[i], p); BN_bn2bin(r[i], p); p += nr[i]; } if (type & SSL_kEECDH) { /* * XXX: For now, we only support named (not generic) * curves. * In this situation, the serverKeyExchange message has: * [1 byte CurveType], [2 byte CurveName] * [1 byte length of encoded point], followed by * the actual encoded point itself */ *p = NAMED_CURVE_TYPE; p += 1; *p = 0; p += 1; *p = curve_id; p += 1; *p = encodedlen; p += 1; memcpy((unsigned char*)p, (unsigned char *)encodedPoint, encodedlen); free(encodedPoint); encodedPoint = NULL; p += encodedlen; } /* not anonymous */ if (pkey != NULL) { /* * n is the length of the params, they start at &(d[4]) * and p points to the space at the end. */ if (pkey->type == EVP_PKEY_RSA && !SSL_USE_SIGALGS(s)) { q = md_buf; j = 0; for (num = 2; num > 0; num--) { EVP_DigestInit_ex(&md_ctx, (num == 2) ? s->ctx->md5 : s->ctx->sha1, NULL); EVP_DigestUpdate(&md_ctx, &(s->s3->client_random[0]), SSL3_RANDOM_SIZE); EVP_DigestUpdate(&md_ctx, &(s->s3->server_random[0]), SSL3_RANDOM_SIZE); EVP_DigestUpdate(&md_ctx, &(d[4]), n); EVP_DigestFinal_ex(&md_ctx, q, (unsigned int *)&i); q += i; j += i; } if (RSA_sign(NID_md5_sha1, md_buf, j, &(p[2]), &u, pkey->pkey.rsa) <= 0) { SSLerr( SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_LIB_RSA); goto err; } s2n(u, p); n += u + 2; } else if (md) { /* Send signature algorithm. */ if (SSL_USE_SIGALGS(s)) { if (!tls12_get_sigandhash(p, pkey, md)) { /* Should never happen */ al = SSL_AD_INTERNAL_ERROR; SSLerr( SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto f_err; } p += 2; } EVP_SignInit_ex(&md_ctx, md, NULL); EVP_SignUpdate(&md_ctx, &(s->s3->client_random[0]), SSL3_RANDOM_SIZE); EVP_SignUpdate(&md_ctx, &(s->s3->server_random[0]), SSL3_RANDOM_SIZE); EVP_SignUpdate(&md_ctx, &(d[4]), n); if (!EVP_SignFinal(&md_ctx, &(p[2]), (unsigned int *)&i, pkey)) { SSLerr( SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_LIB_EVP); goto err; } s2n(i, p); n += i + 2; if (SSL_USE_SIGALGS(s)) n += 2; } else { /* Is this error check actually needed? */ al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, SSL_R_UNKNOWN_PKEY_TYPE); goto f_err; } } *(d++) = SSL3_MT_SERVER_KEY_EXCHANGE; l2n3(n, d); /* we should now have things packed up, so lets send it off */ s->init_num = n + 4; s->init_off = 0; } s->state = SSL3_ST_SW_KEY_EXCH_B; EVP_MD_CTX_cleanup(&md_ctx); return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: free(encodedPoint); BN_CTX_free(bn_ctx); EVP_MD_CTX_cleanup(&md_ctx); return (-1); } int ssl3_send_certificate_request(SSL *s) { unsigned char *p, *d; int i, j, nl, off, n; STACK_OF(X509_NAME) *sk = NULL; X509_NAME *name; BUF_MEM *buf; if (s->state == SSL3_ST_SW_CERT_REQ_A) { buf = s->init_buf; d = p = (unsigned char *)&(buf->data[4]); /* get the list of acceptable cert types */ p++; n = ssl3_get_req_cert_type(s, p); d[0] = n; p += n; n++; if (SSL_USE_SIGALGS(s)) { nl = tls12_get_req_sig_algs(s, p + 2); s2n(nl, p); p += nl + 2; n += nl + 2; } off = n; p += 2; n += 2; sk = SSL_get_client_CA_list(s); nl = 0; if (sk != NULL) { for (i = 0; i < sk_X509_NAME_num(sk); i++) { name = sk_X509_NAME_value(sk, i); j = i2d_X509_NAME(name, NULL); if (!BUF_MEM_grow_clean(buf, 4 + n + j + 2)) { SSLerr( SSL_F_SSL3_SEND_CERTIFICATE_REQUEST, ERR_R_BUF_LIB); goto err; } p = (unsigned char *)&(buf->data[4 + n]); if (!(s->options & SSL_OP_NETSCAPE_CA_DN_BUG)) { s2n(j, p); i2d_X509_NAME(name, &p); n += 2 + j; nl += 2 + j; } else { d = p; i2d_X509_NAME(name, &p); j -= 2; s2n(j, d); j += 2; n += j; nl += j; } } } /* else no CA names */ p = (unsigned char *)&(buf->data[4 + off]); s2n(nl, p); d = (unsigned char *)buf->data; *(d++) = SSL3_MT_CERTIFICATE_REQUEST; l2n3(n, d); /* we should now have things packed up, so lets send it off */ s->init_num = n + 4; s->init_off = 0; #ifdef NETSCAPE_HANG_BUG if (!BUF_MEM_grow(buf, s->init_num + 4)) { SSLerr(SSL_F_SSL3_SEND_CERTIFICATE_REQUEST, ERR_R_BUF_LIB); goto err; } p = (unsigned char *)buf->data + s->init_num; /* do the header */ *(p++) = SSL3_MT_SERVER_DONE; *(p++) = 0; *(p++) = 0; *(p++) = 0; s->init_num += 4; #endif s->state = SSL3_ST_SW_CERT_REQ_B; } /* SSL3_ST_SW_CERT_REQ_B */ return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); err: return (-1); } int ssl3_get_client_key_exchange(SSL *s) { int i, al, ok; long n; unsigned long alg_k; unsigned char *p; RSA *rsa = NULL; EVP_PKEY *pkey = NULL; BIGNUM *pub = NULL; DH *dh_srvr; EC_KEY *srvr_ecdh = NULL; EVP_PKEY *clnt_pub_pkey = NULL; EC_POINT *clnt_ecpoint = NULL; BN_CTX *bn_ctx = NULL; /* 2048 maxlen is a guess. How long a key does that permit? */ n = s->method->ssl_get_message(s, SSL3_ST_SR_KEY_EXCH_A, SSL3_ST_SR_KEY_EXCH_B, SSL3_MT_CLIENT_KEY_EXCHANGE, 2048, &ok); if (!ok) return ((int)n); p = (unsigned char *)s->init_msg; alg_k = s->s3->tmp.new_cipher->algorithm_mkey; if (alg_k & SSL_kRSA) { /* FIX THIS UP EAY EAY EAY EAY */ if (s->s3->tmp.use_rsa_tmp) { if ((s->cert != NULL) && (s->cert->rsa_tmp != NULL)) rsa = s->cert->rsa_tmp; /* * Don't do a callback because rsa_tmp should * be sent already */ if (rsa == NULL) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_MISSING_TMP_RSA_PKEY); goto f_err; } } else { pkey = s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey; if ((pkey == NULL) || (pkey->type != EVP_PKEY_RSA) || (pkey->pkey.rsa == NULL)) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_MISSING_RSA_CERTIFICATE); goto f_err; } rsa = pkey->pkey.rsa; } /* TLS and [incidentally] DTLS{0xFEFF} */ if (s->version > SSL3_VERSION && s->version != DTLS1_BAD_VER) { n2s(p, i); if (n != i + 2) { if (!(s->options & SSL_OP_TLS_D5_BUG)) { SSLerr( SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG); goto err; } else p -= 2; } else n = i; } i = RSA_private_decrypt((int)n, p, p, rsa, RSA_PKCS1_PADDING); al = -1; if (i != SSL_MAX_MASTER_KEY_LENGTH) { al = SSL_AD_DECODE_ERROR; /* SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_RSA_DECRYPT); */ } if ((al == -1) && !((p[0] == (s->client_version >> 8)) && (p[1] == (s->client_version & 0xff)))) { /* * The premaster secret must contain the same version * number as the ClientHello to detect version rollback * attacks (strangely, the protocol does not offer such * protection for DH ciphersuites). * However, buggy clients exist that send the negotiated * protocol version instead if the server does not * support the requested protocol version. * If SSL_OP_TLS_ROLLBACK_BUG is set, tolerate such * clients. */ if (!((s->options & SSL_OP_TLS_ROLLBACK_BUG) && (p[0] == (s->version >> 8)) && (p[1] == (s->version & 0xff)))) { al = SSL_AD_DECODE_ERROR; /* SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_PROTOCOL_VERSION_NUMBER); */ /* * The Klima-Pokorny-Rosa extension of * Bleichenbacher's attack * (http://eprint.iacr.org/2003/052/) exploits * the version number check as a "bad version * oracle" -- an alert would reveal that the * plaintext corresponding to some ciphertext * made up by the adversary is properly * formatted except that the version number is * wrong. * To avoid such attacks, we should treat this * just like any other decryption error. */ } } if (al != -1) { /* * Some decryption failure -- use random value instead * as countermeasure against Bleichenbacher's attack * on PKCS #1 v1.5 RSA padding (see RFC 2246, * section 7.4.7.1). */ ERR_clear_error(); i = SSL_MAX_MASTER_KEY_LENGTH; p[0] = s->client_version >> 8; p[1] = s->client_version & 0xff; RAND_bytes(p+2, i-2); } s->session->master_key_length = s->method->ssl3_enc->generate_master_secret(s, s->session->master_key, p, i); OPENSSL_cleanse(p, i); } else if (alg_k & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) { n2s(p, i); if (n != i + 2) { if (!(s->options & SSL_OP_SSLEAY_080_CLIENT_DH_BUG)) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG); goto err; } else { p -= 2; i = (int)n; } } if (n == 0L) { /* the parameters are in the cert */ al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_UNABLE_TO_DECODE_DH_CERTS); goto f_err; } else { if (s->s3->tmp.dh == NULL) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_MISSING_TMP_DH_KEY); goto f_err; } else dh_srvr = s->s3->tmp.dh; } pub = BN_bin2bn(p, i, NULL); if (pub == NULL) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_BN_LIB); goto err; } i = DH_compute_key(p, pub, dh_srvr); if (i <= 0) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB); BN_clear_free(pub); goto err; } DH_free(s->s3->tmp.dh); s->s3->tmp.dh = NULL; BN_clear_free(pub); pub = NULL; s->session->master_key_length = s->method->ssl3_enc->generate_master_secret( s, s->session->master_key, p, i); OPENSSL_cleanse(p, i); } else if (alg_k & (SSL_kEECDH|SSL_kECDHr|SSL_kECDHe)) { int ret = 1; int field_size = 0; const EC_KEY *tkey; const EC_GROUP *group; const BIGNUM *priv_key; /* Initialize structures for server's ECDH key pair. */ if ((srvr_ecdh = EC_KEY_new()) == NULL) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } /* Let's get server private key and group information. */ if (alg_k & (SSL_kECDHr|SSL_kECDHe)) { /* Use the certificate */ tkey = s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec; } else { /* * Use the ephermeral values we saved when * generating the ServerKeyExchange msg. */ tkey = s->s3->tmp.ecdh; } group = EC_KEY_get0_group(tkey); priv_key = EC_KEY_get0_private_key(tkey); if (!EC_KEY_set_group(srvr_ecdh, group) || !EC_KEY_set_private_key(srvr_ecdh, priv_key)) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); goto err; } /* Let's get client's public key */ if ((clnt_ecpoint = EC_POINT_new(group)) == NULL) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } if (n == 0L) { /* Client Publickey was in Client Certificate */ if (alg_k & SSL_kEECDH) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_MISSING_TMP_ECDH_KEY); goto f_err; } if (((clnt_pub_pkey = X509_get_pubkey( s->session->peer)) == NULL) || (clnt_pub_pkey->type != EVP_PKEY_EC)) { /* * XXX: For now, we do not support client * authentication using ECDH certificates * so this branch (n == 0L) of the code is * never executed. When that support is * added, we ought to ensure the key * received in the certificate is * authorized for key agreement. * ECDH_compute_key implicitly checks that * the two ECDH shares are for the same * group. */ al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_UNABLE_TO_DECODE_ECDH_CERTS); goto f_err; } if (EC_POINT_copy(clnt_ecpoint, EC_KEY_get0_public_key(clnt_pub_pkey->pkey.ec)) == 0) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); goto err; } ret = 2; /* Skip certificate verify processing */ } else { /* * Get client's public key from encoded point * in the ClientKeyExchange message. */ if ((bn_ctx = BN_CTX_new()) == NULL) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } /* Get encoded point length */ i = *p; p += 1; if (n != 1 + i) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); goto err; } if (EC_POINT_oct2point(group, clnt_ecpoint, p, i, bn_ctx) == 0) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); goto err; } /* * p is pointing to somewhere in the buffer * currently, so set it to the start. */ p = (unsigned char *)s->init_buf->data; } /* Compute the shared pre-master secret */ field_size = EC_GROUP_get_degree(group); if (field_size <= 0) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } i = ECDH_compute_key(p, (field_size + 7)/8, clnt_ecpoint, srvr_ecdh, NULL); if (i <= 0) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); goto err; } EVP_PKEY_free(clnt_pub_pkey); EC_POINT_free(clnt_ecpoint); EC_KEY_free(srvr_ecdh); BN_CTX_free(bn_ctx); EC_KEY_free(s->s3->tmp.ecdh); s->s3->tmp.ecdh = NULL; /* Compute the master secret */ s->session->master_key_length = s->method->ssl3_enc-> \ generate_master_secret(s, s->session->master_key, p, i); OPENSSL_cleanse(p, i); return (ret); } else if (alg_k & SSL_kGOST) { int ret = 0; EVP_PKEY_CTX *pkey_ctx; EVP_PKEY *client_pub_pkey = NULL, *pk = NULL; unsigned char premaster_secret[32], *start; size_t outlen = 32, inlen; unsigned long alg_a; int Ttag, Tclass; long Tlen; /* Get our certificate private key*/ alg_a = s->s3->tmp.new_cipher->algorithm_auth; if (alg_a & SSL_aGOST94) pk = s->cert->pkeys[SSL_PKEY_GOST94].privatekey; else if (alg_a & SSL_aGOST01) pk = s->cert->pkeys[SSL_PKEY_GOST01].privatekey; pkey_ctx = EVP_PKEY_CTX_new(pk, NULL); EVP_PKEY_decrypt_init(pkey_ctx); /* * If client certificate is present and is of the same type, * maybe use it for key exchange. * Don't mind errors from EVP_PKEY_derive_set_peer, because * it is completely valid to use a client certificate for * authorization only. */ client_pub_pkey = X509_get_pubkey(s->session->peer); if (client_pub_pkey) { if (EVP_PKEY_derive_set_peer(pkey_ctx, client_pub_pkey) <= 0) ERR_clear_error(); } /* Decrypt session key */ if (ASN1_get_object((const unsigned char **)&p, &Tlen, &Ttag, &Tclass, n) != V_ASN1_CONSTRUCTED || Ttag != V_ASN1_SEQUENCE || Tclass != V_ASN1_UNIVERSAL) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_DECRYPTION_FAILED); goto gerr; } start = p; inlen = Tlen; if (EVP_PKEY_decrypt(pkey_ctx, premaster_secret, &outlen, start, inlen) <=0) { SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_DECRYPTION_FAILED); goto gerr; } /* Generate master secret */ s->session->master_key_length = s->method->ssl3_enc->generate_master_secret( s, s->session->master_key, premaster_secret, 32); /* Check if pubkey from client certificate was used */ if (EVP_PKEY_CTX_ctrl(pkey_ctx, -1, -1, EVP_PKEY_CTRL_PEER_KEY, 2, NULL) > 0) ret = 2; else ret = 1; gerr: EVP_PKEY_free(client_pub_pkey); EVP_PKEY_CTX_free(pkey_ctx); if (ret) return (ret); else goto err; } else { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_UNKNOWN_CIPHER_TYPE); goto f_err; } return (1); f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: EVP_PKEY_free(clnt_pub_pkey); EC_POINT_free(clnt_ecpoint); EC_KEY_free(srvr_ecdh); BN_CTX_free(bn_ctx); return (-1); } int ssl3_get_cert_verify(SSL *s) { EVP_PKEY *pkey = NULL; unsigned char *p; int al, ok, ret = 0; long n; int type = 0, i, j; X509 *peer; const EVP_MD *md = NULL; EVP_MD_CTX mctx; EVP_MD_CTX_init(&mctx); n = s->method->ssl_get_message(s, SSL3_ST_SR_CERT_VRFY_A, SSL3_ST_SR_CERT_VRFY_B, -1, SSL3_RT_MAX_PLAIN_LENGTH, &ok); if (!ok) return ((int)n); if (s->session->peer != NULL) { peer = s->session->peer; pkey = X509_get_pubkey(peer); type = X509_certificate_type(peer, pkey); } else { peer = NULL; pkey = NULL; } if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE_VERIFY) { s->s3->tmp.reuse_message = 1; if ((peer != NULL) && (type & EVP_PKT_SIGN)) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_MISSING_VERIFY_MESSAGE); goto f_err; } ret = 1; goto end; } if (peer == NULL) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_NO_CLIENT_CERT_RECEIVED); al = SSL_AD_UNEXPECTED_MESSAGE; goto f_err; } if (!(type & EVP_PKT_SIGN)) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE); al = SSL_AD_ILLEGAL_PARAMETER; goto f_err; } if (s->s3->change_cipher_spec) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_CCS_RECEIVED_EARLY); al = SSL_AD_UNEXPECTED_MESSAGE; goto f_err; } /* we now have a signature that we need to verify */ p = (unsigned char *)s->init_msg; /* * Check for broken implementations of GOST ciphersuites. * * If key is GOST and n is exactly 64, it is a bare * signature without length field. */ if (n == 64 && (pkey->type == NID_id_GostR3410_94 || pkey->type == NID_id_GostR3410_2001) ) { i = 64; } else { if (SSL_USE_SIGALGS(s)) { int sigalg = tls12_get_sigid(pkey); /* Should never happen */ if (sigalg == -1) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_INTERNAL_ERROR); al = SSL_AD_INTERNAL_ERROR; goto f_err; } /* Check key type is consistent with signature */ if (sigalg != (int)p[1]) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_WRONG_SIGNATURE_TYPE); al = SSL_AD_DECODE_ERROR; goto f_err; } md = tls12_get_hash(p[0]); if (md == NULL) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_UNKNOWN_DIGEST); al = SSL_AD_DECODE_ERROR; goto f_err; } p += 2; n -= 2; } n2s(p, i); n -= 2; if (i > n) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_LENGTH_MISMATCH); al = SSL_AD_DECODE_ERROR; goto f_err; } } j = EVP_PKEY_size(pkey); if ((i > j) || (n > j) || (n <= 0)) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_WRONG_SIGNATURE_SIZE); al = SSL_AD_DECODE_ERROR; goto f_err; } if (SSL_USE_SIGALGS(s)) { long hdatalen = 0; void *hdata; hdatalen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata); if (hdatalen <= 0) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_INTERNAL_ERROR); al = SSL_AD_INTERNAL_ERROR; goto f_err; } if (!EVP_VerifyInit_ex(&mctx, md, NULL) || !EVP_VerifyUpdate(&mctx, hdata, hdatalen)) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_EVP_LIB); al = SSL_AD_INTERNAL_ERROR; goto f_err; } if (EVP_VerifyFinal(&mctx, p , i, pkey) <= 0) { al = SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_SIGNATURE); goto f_err; } } else if (pkey->type == EVP_PKEY_RSA) { i = RSA_verify(NID_md5_sha1, s->s3->tmp.cert_verify_md, MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, p, i, pkey->pkey.rsa); if (i < 0) { al = SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_RSA_DECRYPT); goto f_err; } if (i == 0) { al = SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_RSA_SIGNATURE); goto f_err; } } else if (pkey->type == EVP_PKEY_DSA) { j = DSA_verify(pkey->save_type, &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]), SHA_DIGEST_LENGTH, p, i, pkey->pkey.dsa); if (j <= 0) { /* bad signature */ al = SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_DSA_SIGNATURE); goto f_err; } } else if (pkey->type == EVP_PKEY_EC) { j = ECDSA_verify(pkey->save_type, &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]), SHA_DIGEST_LENGTH, p, i, pkey->pkey.ec); if (j <= 0) { /* bad signature */ al = SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_ECDSA_SIGNATURE); goto f_err; } } else if (pkey->type == NID_id_GostR3410_94 || pkey->type == NID_id_GostR3410_2001) { unsigned char signature[64]; int idx; EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new(pkey, NULL); EVP_PKEY_verify_init(pctx); if (i != 64) { fprintf(stderr, "GOST signature length is %d", i); } for (idx = 0; idx < 64; idx++) { signature[63 - idx] = p[idx]; } j = EVP_PKEY_verify(pctx, signature, 64, s->s3->tmp.cert_verify_md, 32); EVP_PKEY_CTX_free(pctx); if (j <= 0) { al = SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_ECDSA_SIGNATURE); goto f_err; } } else { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_INTERNAL_ERROR); al = SSL_AD_UNSUPPORTED_CERTIFICATE; goto f_err; } ret = 1; if (0) { f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); } end: if (s->s3->handshake_buffer) { BIO_free(s->s3->handshake_buffer); s->s3->handshake_buffer = NULL; s->s3->flags &= ~TLS1_FLAGS_KEEP_HANDSHAKE; } EVP_MD_CTX_cleanup(&mctx); EVP_PKEY_free(pkey); return (ret); } int ssl3_get_client_certificate(SSL *s) { int i, ok, al, ret = -1; X509 *x = NULL; unsigned long l, nc, llen, n; const unsigned char *p, *q; unsigned char *d; STACK_OF(X509) *sk = NULL; n = s->method->ssl_get_message(s, SSL3_ST_SR_CERT_A, SSL3_ST_SR_CERT_B, -1, s->max_cert_list, &ok); if (!ok) return ((int)n); if (s->s3->tmp.message_type == SSL3_MT_CLIENT_KEY_EXCHANGE) { if ((s->verify_mode & SSL_VERIFY_PEER) && (s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) { SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE); al = SSL_AD_HANDSHAKE_FAILURE; goto f_err; } /* * If tls asked for a client cert, * the client must return a 0 list. */ if ((s->version > SSL3_VERSION) && s->s3->tmp.cert_request) { SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST ); al = SSL_AD_UNEXPECTED_MESSAGE; goto f_err; } s->s3->tmp.reuse_message = 1; return (1); } if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, SSL_R_WRONG_MESSAGE_TYPE); goto f_err; } p = d = (unsigned char *)s->init_msg; if ((sk = sk_X509_new_null()) == NULL) { SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE); goto err; } n2l3(p, llen); if (llen + 3 != n) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, SSL_R_LENGTH_MISMATCH); goto f_err; } for (nc = 0; nc < llen;) { n2l3(p, l); if ((l + nc + 3) > llen) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, SSL_R_CERT_LENGTH_MISMATCH); goto f_err; } q = p; x = d2i_X509(NULL, &p, l); if (x == NULL) { SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_ASN1_LIB); goto err; } if (p != (q + l)) { al = SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, SSL_R_CERT_LENGTH_MISMATCH); goto f_err; } if (!sk_X509_push(sk, x)) { SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE); goto err; } x = NULL; nc += l + 3; } if (sk_X509_num(sk) <= 0) { /* TLS does not mind 0 certs returned */ if (s->version == SSL3_VERSION) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, SSL_R_NO_CERTIFICATES_RETURNED); goto f_err; } /* Fail for TLS only if we required a certificate */ else if ((s->verify_mode & SSL_VERIFY_PEER) && (s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) { SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE); al = SSL_AD_HANDSHAKE_FAILURE; goto f_err; } /* No client certificate so digest cached records */ if (s->s3->handshake_buffer && !ssl3_digest_cached_records(s)) { al = SSL_AD_INTERNAL_ERROR; goto f_err; } } else { i = ssl_verify_cert_chain(s, sk); if (i <= 0) { al = ssl_verify_alarm_type(s->verify_result); SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, SSL_R_NO_CERTIFICATE_RETURNED); goto f_err; } } if (s->session->peer != NULL) /* This should not be needed */ X509_free(s->session->peer); s->session->peer = sk_X509_shift(sk); s->session->verify_result = s->verify_result; /* * With the current implementation, sess_cert will always be NULL * when we arrive here */ if (s->session->sess_cert == NULL) { s->session->sess_cert = ssl_sess_cert_new(); if (s->session->sess_cert == NULL) { SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE); goto err; } } if (s->session->sess_cert->cert_chain != NULL) sk_X509_pop_free(s->session->sess_cert->cert_chain, X509_free); s->session->sess_cert->cert_chain = sk; /* * Inconsistency alert: cert_chain does *not* include the * peer's own certificate, while we do include it in s3_clnt.c */ sk = NULL; ret = 1; if (0) { f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); } err: if (x != NULL) X509_free(x); if (sk != NULL) sk_X509_pop_free(sk, X509_free); return (ret); } int ssl3_send_server_certificate(SSL *s) { unsigned long l; X509 *x; if (s->state == SSL3_ST_SW_CERT_A) { x = ssl_get_server_send_cert(s); if (x == NULL) { /* VRS: allow null cert if auth == KRB5 */ if ((s->s3->tmp.new_cipher->algorithm_auth != SSL_aKRB5) || (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kKRB5)) { SSLerr(SSL_F_SSL3_SEND_SERVER_CERTIFICATE, ERR_R_INTERNAL_ERROR); return (0); } } l = ssl3_output_cert_chain(s, x); s->state = SSL3_ST_SW_CERT_B; s->init_num = (int)l; s->init_off = 0; } /* SSL3_ST_SW_CERT_B */ return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); } /* send a new session ticket (not necessarily for a new session) */ int ssl3_send_newsession_ticket(SSL *s) { if (s->state == SSL3_ST_SW_SESSION_TICKET_A) { unsigned char *p, *senc, *macstart; const unsigned char *const_p; int len, slen_full, slen; SSL_SESSION *sess; unsigned int hlen; EVP_CIPHER_CTX ctx; HMAC_CTX hctx; SSL_CTX *tctx = s->initial_ctx; unsigned char iv[EVP_MAX_IV_LENGTH]; unsigned char key_name[16]; /* get session encoding length */ slen_full = i2d_SSL_SESSION(s->session, NULL); /* * Some length values are 16 bits, so forget it if session is * too long */ if (slen_full > 0xFF00) return (-1); senc = malloc(slen_full); if (!senc) return (-1); p = senc; i2d_SSL_SESSION(s->session, &p); /* * Create a fresh copy (not shared with other threads) to * clean up */ const_p = senc; sess = d2i_SSL_SESSION(NULL, &const_p, slen_full); if (sess == NULL) { free(senc); return (-1); } /* ID is irrelevant for the ticket */ sess->session_id_length = 0; slen = i2d_SSL_SESSION(sess, NULL); if (slen > slen_full) { /* shouldn't ever happen */ free(senc); return (-1); } p = senc; i2d_SSL_SESSION(sess, &p); SSL_SESSION_free(sess); /* * Grow buffer if need be: the length calculation is as * follows 1 (size of message name) + 3 (message length * bytes) + 4 (ticket lifetime hint) + 2 (ticket length) + * 16 (key name) + max_iv_len (iv length) + * session_length + max_enc_block_size (max encrypted session * length) + max_md_size (HMAC). */ if (!BUF_MEM_grow(s->init_buf, 26 + EVP_MAX_IV_LENGTH + EVP_MAX_BLOCK_LENGTH + EVP_MAX_MD_SIZE + slen)) { free(senc); return (-1); } p = (unsigned char *)s->init_buf->data; /* do the header */ *(p++) = SSL3_MT_NEWSESSION_TICKET; /* Skip message length for now */ p += 3; EVP_CIPHER_CTX_init(&ctx); HMAC_CTX_init(&hctx); /* * Initialize HMAC and cipher contexts. If callback present * it does all the work otherwise use generated values * from parent ctx. */ if (tctx->tlsext_ticket_key_cb) { if (tctx->tlsext_ticket_key_cb(s, key_name, iv, &ctx, &hctx, 1) < 0) { free(senc); return (-1); } } else { RAND_pseudo_bytes(iv, 16); EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, tctx->tlsext_tick_aes_key, iv); HMAC_Init_ex(&hctx, tctx->tlsext_tick_hmac_key, 16, tlsext_tick_md(), NULL); memcpy(key_name, tctx->tlsext_tick_key_name, 16); } /* * Ticket lifetime hint (advisory only): * We leave this unspecified for resumed session * (for simplicity), and guess that tickets for new * sessions will live as long as their sessions. */ l2n(s->hit ? 0 : s->session->timeout, p); /* Skip ticket length for now */ p += 2; /* Output key name */ macstart = p; memcpy(p, key_name, 16); p += 16; /* output IV */ memcpy(p, iv, EVP_CIPHER_CTX_iv_length(&ctx)); p += EVP_CIPHER_CTX_iv_length(&ctx); /* Encrypt session data */ EVP_EncryptUpdate(&ctx, p, &len, senc, slen); p += len; EVP_EncryptFinal(&ctx, p, &len); p += len; EVP_CIPHER_CTX_cleanup(&ctx); HMAC_Update(&hctx, macstart, p - macstart); HMAC_Final(&hctx, p, &hlen); HMAC_CTX_cleanup(&hctx); p += hlen; /* Now write out lengths: p points to end of data written */ /* Total length */ len = p - (unsigned char *)s->init_buf->data; p = (unsigned char *)s->init_buf->data + 1; l2n3(len - 4, p); /* Message length */ p += 4; s2n(len - 10, p); /* Ticket length */ /* number of bytes to write */ s->init_num = len; s->state = SSL3_ST_SW_SESSION_TICKET_B; s->init_off = 0; free(senc); } /* SSL3_ST_SW_SESSION_TICKET_B */ return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); } int ssl3_send_cert_status(SSL *s) { if (s->state == SSL3_ST_SW_CERT_STATUS_A) { unsigned char *p; /* * Grow buffer if need be: the length calculation is as * follows 1 (message type) + 3 (message length) + * 1 (ocsp response type) + 3 (ocsp response length) * + (ocsp response) */ if (!BUF_MEM_grow(s->init_buf, 8 + s->tlsext_ocsp_resplen)) return (-1); p = (unsigned char *)s->init_buf->data; /* do the header */ *(p++) = SSL3_MT_CERTIFICATE_STATUS; /* message length */ l2n3(s->tlsext_ocsp_resplen + 4, p); /* status type */ *(p++) = s->tlsext_status_type; /* length of OCSP response */ l2n3(s->tlsext_ocsp_resplen, p); /* actual response */ memcpy(p, s->tlsext_ocsp_resp, s->tlsext_ocsp_resplen); /* number of bytes to write */ s->init_num = 8 + s->tlsext_ocsp_resplen; s->state = SSL3_ST_SW_CERT_STATUS_B; s->init_off = 0; } /* SSL3_ST_SW_CERT_STATUS_B */ return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); } # ifndef OPENSSL_NO_NEXTPROTONEG /* * ssl3_get_next_proto reads a Next Protocol Negotiation handshake message. * It sets the next_proto member in s if found */ int ssl3_get_next_proto(SSL *s) { int ok; int proto_len, padding_len; long n; const unsigned char *p; /* * Clients cannot send a NextProtocol message if we didn't see the * extension in their ClientHello */ if (!s->s3->next_proto_neg_seen) { SSLerr(SSL_F_SSL3_GET_NEXT_PROTO, SSL_R_GOT_NEXT_PROTO_WITHOUT_EXTENSION); return (-1); } /* 514 maxlen is enough for the payload format below */ n = s->method->ssl_get_message(s, SSL3_ST_SR_NEXT_PROTO_A, SSL3_ST_SR_NEXT_PROTO_B, SSL3_MT_NEXT_PROTO, 514, &ok); if (!ok) return ((int)n); /* * s->state doesn't reflect whether ChangeCipherSpec has been received * in this handshake, but s->s3->change_cipher_spec does (will be reset * by ssl3_get_finished). */ if (!s->s3->change_cipher_spec) { SSLerr(SSL_F_SSL3_GET_NEXT_PROTO, SSL_R_GOT_NEXT_PROTO_BEFORE_A_CCS); return (-1); } if (n < 2) return (0); /* The body must be > 1 bytes long */ p = (unsigned char *)s->init_msg; /* * The payload looks like: * uint8 proto_len; * uint8 proto[proto_len]; * uint8 padding_len; * uint8 padding[padding_len]; */ proto_len = p[0]; if (proto_len + 2 > s->init_num) return (0); padding_len = p[proto_len + 1]; if (proto_len + padding_len + 2 != s->init_num) return (0); s->next_proto_negotiated = malloc(proto_len); if (!s->next_proto_negotiated) { SSLerr(SSL_F_SSL3_GET_NEXT_PROTO, ERR_R_MALLOC_FAILURE); return (0); } memcpy(s->next_proto_negotiated, p + 1, proto_len); s->next_proto_negotiated_len = proto_len; return (1); } # endif deps/libressl-pnacl-sys-2.1.6/libressl/Makefile.am0000644000175000017500000000010412357730077017002 0ustar SUBDIRS = crypto ssl include apps tests man ACLOCAL_AMFLAGS = -I m4 deps/libressl-pnacl-sys-2.1.6/libressl/crypto/0000755000000000000000000000000012666635521020052 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/dh/0000755000000000000000000000000012666635521020445 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/dh/dh_asn1.c0000644000175000017500000000700112360020705020325 0ustar /* $OpenBSD: dh_asn1.c,v 1.5 2014/07/09 13:26:47 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include /* Override the default free and new methods */ static int dh_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { if (operation == ASN1_OP_NEW_PRE) { *pval = (ASN1_VALUE *)DH_new(); if (*pval) return 2; return 0; } else if (operation == ASN1_OP_FREE_PRE) { DH_free((DH *)*pval); *pval = NULL; return 2; } return 1; } ASN1_SEQUENCE_cb(DHparams, dh_cb) = { ASN1_SIMPLE(DH, p, BIGNUM), ASN1_SIMPLE(DH, g, BIGNUM), ASN1_OPT(DH, length, ZLONG), } ASN1_SEQUENCE_END_cb(DH, DHparams) IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DH, DHparams, DHparams) DH * DHparams_dup(DH *dh) { return ASN1_item_dup(ASN1_ITEM_rptr(DHparams), dh); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dh/dh_lib.c0000644000175000017500000001511612360020705020237 0ustar /* $OpenBSD: dh_lib.c,v 1.18 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif static const DH_METHOD *default_DH_method = NULL; void DH_set_default_method(const DH_METHOD *meth) { default_DH_method = meth; } const DH_METHOD * DH_get_default_method(void) { if (!default_DH_method) default_DH_method = DH_OpenSSL(); return default_DH_method; } int DH_set_method(DH *dh, const DH_METHOD *meth) { /* * NB: The caller is specifically setting a method, so it's not up to us * to deal with which ENGINE it comes from. */ const DH_METHOD *mtmp; mtmp = dh->meth; if (mtmp->finish) mtmp->finish(dh); #ifndef OPENSSL_NO_ENGINE if (dh->engine) { ENGINE_finish(dh->engine); dh->engine = NULL; } #endif dh->meth = meth; if (meth->init) meth->init(dh); return 1; } DH * DH_new(void) { return DH_new_method(NULL); } DH * DH_new_method(ENGINE *engine) { DH *ret; ret = malloc(sizeof(DH)); if (ret == NULL) { DHerr(DH_F_DH_NEW_METHOD, ERR_R_MALLOC_FAILURE); return NULL; } ret->meth = DH_get_default_method(); #ifndef OPENSSL_NO_ENGINE if (engine) { if (!ENGINE_init(engine)) { DHerr(DH_F_DH_NEW_METHOD, ERR_R_ENGINE_LIB); free(ret); return NULL; } ret->engine = engine; } else ret->engine = ENGINE_get_default_DH(); if(ret->engine) { ret->meth = ENGINE_get_DH(ret->engine); if (!ret->meth) { DHerr(DH_F_DH_NEW_METHOD, ERR_R_ENGINE_LIB); ENGINE_finish(ret->engine); free(ret); return NULL; } } #endif ret->pad = 0; ret->version = 0; ret->p = NULL; ret->g = NULL; ret->length = 0; ret->pub_key = NULL; ret->priv_key = NULL; ret->q = NULL; ret->j = NULL; ret->seed = NULL; ret->seedlen = 0; ret->counter = NULL; ret->method_mont_p=NULL; ret->references = 1; ret->flags = ret->meth->flags & ~DH_FLAG_NON_FIPS_ALLOW; CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data); if (ret->meth->init != NULL && !ret->meth->init(ret)) { #ifndef OPENSSL_NO_ENGINE if (ret->engine) ENGINE_finish(ret->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data); free(ret); ret = NULL; } return ret; } void DH_free(DH *r) { int i; if (r == NULL) return; i = CRYPTO_add(&r->references, -1, CRYPTO_LOCK_DH); if (i > 0) return; if (r->meth->finish) r->meth->finish(r); #ifndef OPENSSL_NO_ENGINE if (r->engine) ENGINE_finish(r->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, r, &r->ex_data); if (r->p != NULL) BN_clear_free(r->p); if (r->g != NULL) BN_clear_free(r->g); if (r->q != NULL) BN_clear_free(r->q); if (r->j != NULL) BN_clear_free(r->j); free(r->seed); if (r->counter != NULL) BN_clear_free(r->counter); if (r->pub_key != NULL) BN_clear_free(r->pub_key); if (r->priv_key != NULL) BN_clear_free(r->priv_key); free(r); } int DH_up_ref(DH *r) { int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_DH); return i > 1 ? 1 : 0; } int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DH, argl, argp, new_func, dup_func, free_func); } int DH_set_ex_data(DH *d, int idx, void *arg) { return CRYPTO_set_ex_data(&d->ex_data, idx, arg); } void * DH_get_ex_data(DH *d, int idx) { return CRYPTO_get_ex_data(&d->ex_data, idx); } int DH_size(const DH *dh) { return BN_num_bytes(dh->p); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dh/dh_gen.c0000644000175000017500000001466212360020705020247 0ustar /* $OpenBSD: dh_gen.c,v 1.12 2014/07/09 13:26:47 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* NB: These functions have been upgraded - the previous prototypes are in * dh_depr.c as wrappers to these ones. * - Geoff */ #include #include #include #include static int dh_builtin_genparams(DH *ret, int prime_len, int generator, BN_GENCB *cb); int DH_generate_parameters_ex(DH *ret, int prime_len, int generator, BN_GENCB *cb) { if (ret->meth->generate_params) return ret->meth->generate_params(ret, prime_len, generator, cb); return dh_builtin_genparams(ret, prime_len, generator, cb); } /* * We generate DH parameters as follows: * find a prime q which is prime_len/2 bits long. * p=(2*q)+1 or (p-1)/2 = q * For this case, g is a generator if * g^((p-1)/q) mod p != 1 for values of q which are the factors of p-1. * Since the factors of p-1 are q and 2, we just need to check * g^2 mod p != 1 and g^q mod p != 1. * * Having said all that, * there is another special case method for the generators 2, 3 and 5. * for 2, p mod 24 == 11 * for 3, p mod 12 == 5 <<<<< does not work for safe primes. * for 5, p mod 10 == 3 or 7 * * Thanks to Phil Karn for the pointers about the * special generators and for answering some of my questions. * * I've implemented the second simple method :-). * Since DH should be using a safe prime (both p and q are prime), * this generator function can take a very very long time to run. */ /* Actually there is no reason to insist that 'generator' be a generator. * It's just as OK (and in some sense better) to use a generator of the * order-q subgroup. */ static int dh_builtin_genparams(DH *ret, int prime_len, int generator, BN_GENCB *cb) { BIGNUM *t1, *t2; int g, ok = -1; BN_CTX *ctx = NULL; ctx = BN_CTX_new(); if (ctx == NULL) goto err; BN_CTX_start(ctx); t1 = BN_CTX_get(ctx); t2 = BN_CTX_get(ctx); if (t1 == NULL || t2 == NULL) goto err; /* Make sure 'ret' has the necessary elements */ if (!ret->p && ((ret->p = BN_new()) == NULL)) goto err; if (!ret->g && ((ret->g = BN_new()) == NULL)) goto err; if (generator <= 1) { DHerr(DH_F_DH_BUILTIN_GENPARAMS, DH_R_BAD_GENERATOR); goto err; } if (generator == DH_GENERATOR_2) { if (!BN_set_word(t1, 24)) goto err; if (!BN_set_word(t2, 11)) goto err; g = 2; #if 0 /* does not work for safe primes */ } else if (generator == DH_GENERATOR_3) { if (!BN_set_word(t1, 12)) goto err; if (!BN_set_word(t2, 5)) goto err; g = 3; #endif } else if (generator == DH_GENERATOR_5) { if (!BN_set_word(t1, 10)) goto err; if (!BN_set_word(t2, 3)) goto err; /* BN_set_word(t3,7); just have to miss * out on these ones :-( */ g = 5; } else { /* * in the general case, don't worry if 'generator' is a * generator or not: since we are using safe primes, * it will generate either an order-q or an order-2q group, * which both is OK */ if (!BN_set_word(t1, 2)) goto err; if (!BN_set_word(t2, 1)) goto err; g = generator; } if (!BN_generate_prime_ex(ret->p, prime_len, 1, t1, t2, cb)) goto err; if (!BN_GENCB_call(cb, 3, 0)) goto err; if (!BN_set_word(ret->g, g)) goto err; ok = 1; err: if (ok == -1) { DHerr(DH_F_DH_BUILTIN_GENPARAMS, ERR_R_BN_LIB); ok = 0; } if (ctx != NULL) { BN_CTX_end(ctx); BN_CTX_free(ctx); } return ok; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dh/dh_depr.c0000644000175000017500000000627312360020705020427 0ustar /* $OpenBSD: dh_depr.c,v 1.5 2014/07/10 22:45:56 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* This file contains deprecated functions as wrappers to the new ones */ #include #include #include #include #ifndef OPENSSL_NO_DEPRECATED DH * DH_generate_parameters(int prime_len, int generator, void (*callback)(int, int, void *), void *cb_arg) { BN_GENCB cb; DH *ret = NULL; if ((ret = DH_new()) == NULL) return NULL; BN_GENCB_set_old(&cb, callback, cb_arg); if (DH_generate_parameters_ex(ret, prime_len, generator, &cb)) return ret; DH_free(ret); return NULL; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dh/dh_ameth.c0000644000175000017500000002613312360020705020570 0ustar /* $OpenBSD: dh_ameth.c,v 1.10 2014/07/09 22:55:17 tedu Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include "asn1_locl.h" static void int_dh_free(EVP_PKEY *pkey) { DH_free(pkey->pkey.dh); } static int dh_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) { const unsigned char *p, *pm; int pklen, pmlen; int ptype; void *pval; ASN1_STRING *pstr; X509_ALGOR *palg; ASN1_INTEGER *public_key = NULL; DH *dh = NULL; if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, &palg, pubkey)) return 0; X509_ALGOR_get0(NULL, &ptype, &pval, palg); if (ptype != V_ASN1_SEQUENCE) { DHerr(DH_F_DH_PUB_DECODE, DH_R_PARAMETER_ENCODING_ERROR); goto err; } pstr = pval; pm = pstr->data; pmlen = pstr->length; if (!(dh = d2i_DHparams(NULL, &pm, pmlen))) { DHerr(DH_F_DH_PUB_DECODE, DH_R_DECODE_ERROR); goto err; } if (!(public_key=d2i_ASN1_INTEGER(NULL, &p, pklen))) { DHerr(DH_F_DH_PUB_DECODE, DH_R_DECODE_ERROR); goto err; } /* We have parameters now set public key */ if (!(dh->pub_key = ASN1_INTEGER_to_BN(public_key, NULL))) { DHerr(DH_F_DH_PUB_DECODE, DH_R_BN_DECODE_ERROR); goto err; } ASN1_INTEGER_free(public_key); EVP_PKEY_assign_DH(pkey, dh); return 1; err: if (public_key) ASN1_INTEGER_free(public_key); if (dh) DH_free(dh); return 0; } static int dh_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) { DH *dh; int ptype; unsigned char *penc = NULL; int penclen; ASN1_STRING *str; ASN1_INTEGER *pub_key = NULL; dh=pkey->pkey.dh; str = ASN1_STRING_new(); if (str == NULL) { DHerr(DH_F_DH_PUB_ENCODE, ERR_R_MALLOC_FAILURE); goto err; } str->length = i2d_DHparams(dh, &str->data); if (str->length <= 0) { DHerr(DH_F_DH_PUB_ENCODE, ERR_R_MALLOC_FAILURE); goto err; } ptype = V_ASN1_SEQUENCE; pub_key = BN_to_ASN1_INTEGER(dh->pub_key, NULL); if (!pub_key) goto err; penclen = i2d_ASN1_INTEGER(pub_key, &penc); ASN1_INTEGER_free(pub_key); if (penclen <= 0) { DHerr(DH_F_DH_PUB_ENCODE, ERR_R_MALLOC_FAILURE); goto err; } if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_DH), ptype, (void *)str, penc, penclen)) return 1; err: free(penc); ASN1_STRING_free(str); return 0; } /* * PKCS#8 DH is defined in PKCS#11 of all places. It is similar to DH in * that the AlgorithmIdentifier contains the paramaters, the private key * is explcitly included and the pubkey must be recalculated. */ static int dh_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8) { const unsigned char *p, *pm; int pklen, pmlen; int ptype; void *pval; ASN1_STRING *pstr; X509_ALGOR *palg; ASN1_INTEGER *privkey = NULL; DH *dh = NULL; if (!PKCS8_pkey_get0(NULL, &p, &pklen, &palg, p8)) return 0; X509_ALGOR_get0(NULL, &ptype, &pval, palg); if (ptype != V_ASN1_SEQUENCE) goto decerr; if (!(privkey=d2i_ASN1_INTEGER(NULL, &p, pklen))) goto decerr; pstr = pval; pm = pstr->data; pmlen = pstr->length; if (!(dh = d2i_DHparams(NULL, &pm, pmlen))) goto decerr; /* We have parameters now set private key */ if (!(dh->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) { DHerr(DH_F_DH_PRIV_DECODE, DH_R_BN_ERROR); goto dherr; } /* Calculate public key */ if (!DH_generate_key(dh)) goto dherr; EVP_PKEY_assign_DH(pkey, dh); ASN1_INTEGER_free(privkey); return 1; decerr: DHerr(DH_F_DH_PRIV_DECODE, EVP_R_DECODE_ERROR); dherr: DH_free(dh); return 0; } static int dh_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) { ASN1_STRING *params = NULL; ASN1_INTEGER *prkey = NULL; unsigned char *dp = NULL; int dplen; params = ASN1_STRING_new(); if (!params) { DHerr(DH_F_DH_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); goto err; } params->length = i2d_DHparams(pkey->pkey.dh, ¶ms->data); if (params->length <= 0) { DHerr(DH_F_DH_PRIV_ENCODE,ERR_R_MALLOC_FAILURE); goto err; } params->type = V_ASN1_SEQUENCE; /* Get private key into integer */ prkey = BN_to_ASN1_INTEGER(pkey->pkey.dh->priv_key, NULL); if (!prkey) { DHerr(DH_F_DH_PRIV_ENCODE, DH_R_BN_ERROR); goto err; } dplen = i2d_ASN1_INTEGER(prkey, &dp); ASN1_INTEGER_free(prkey); if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(NID_dhKeyAgreement), 0, V_ASN1_SEQUENCE, params, dp, dplen)) goto err; return 1; err: free(dp); ASN1_STRING_free(params); ASN1_INTEGER_free(prkey); return 0; } static void update_buflen(const BIGNUM *b, size_t *pbuflen) { size_t i; if (!b) return; if (*pbuflen < (i = (size_t)BN_num_bytes(b))) *pbuflen = i; } static int dh_param_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) { DH *dh; if (!(dh = d2i_DHparams(NULL, pder, derlen))) { DHerr(DH_F_DH_PARAM_DECODE, ERR_R_DH_LIB); return 0; } EVP_PKEY_assign_DH(pkey, dh); return 1; } static int dh_param_encode(const EVP_PKEY *pkey, unsigned char **pder) { return i2d_DHparams(pkey->pkey.dh, pder); } static int do_dh_print(BIO *bp, const DH *x, int indent, ASN1_PCTX *ctx, int ptype) { unsigned char *m = NULL; int reason = ERR_R_BUF_LIB, ret = 0; size_t buf_len = 0; const char *ktype = NULL; BIGNUM *priv_key, *pub_key; if (ptype == 2) priv_key = x->priv_key; else priv_key = NULL; if (ptype > 0) pub_key = x->pub_key; else pub_key = NULL; update_buflen(x->p, &buf_len); if (buf_len == 0) { reason = ERR_R_PASSED_NULL_PARAMETER; goto err; } update_buflen(x->g, &buf_len); update_buflen(pub_key, &buf_len); update_buflen(priv_key, &buf_len); if (ptype == 2) ktype = "PKCS#3 DH Private-Key"; else if (ptype == 1) ktype = "PKCS#3 DH Public-Key"; else ktype = "PKCS#3 DH Parameters"; m= malloc(buf_len + 10); if (m == NULL) { reason = ERR_R_MALLOC_FAILURE; goto err; } BIO_indent(bp, indent, 128); if (BIO_printf(bp, "%s: (%d bit)\n", ktype, BN_num_bits(x->p)) <= 0) goto err; indent += 4; if (!ASN1_bn_print(bp, "private-key:", priv_key, m, indent)) goto err; if (!ASN1_bn_print(bp, "public-key:", pub_key, m, indent)) goto err; if (!ASN1_bn_print(bp, "prime:", x->p, m, indent)) goto err; if (!ASN1_bn_print(bp, "generator:", x->g, m, indent)) goto err; if (x->length != 0) { BIO_indent(bp, indent, 128); if (BIO_printf(bp, "recommended-private-length: %d bits\n", (int)x->length) <= 0) goto err; } ret = 1; if (0) { err: DHerr(DH_F_DO_DH_PRINT,reason); } free(m); return(ret); } static int int_dh_size(const EVP_PKEY *pkey) { return DH_size(pkey->pkey.dh); } static int dh_bits(const EVP_PKEY *pkey) { return BN_num_bits(pkey->pkey.dh->p); } static int dh_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b) { if (BN_cmp(a->pkey.dh->p, b->pkey.dh->p) || BN_cmp(a->pkey.dh->g, b->pkey.dh->g)) return 0; else return 1; } static int dh_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from) { BIGNUM *a; if ((a = BN_dup(from->pkey.dh->p)) == NULL) return 0; if (to->pkey.dh->p != NULL) BN_free(to->pkey.dh->p); to->pkey.dh->p = a; if ((a = BN_dup(from->pkey.dh->g)) == NULL) return 0; if (to->pkey.dh->g != NULL) BN_free(to->pkey.dh->g); to->pkey.dh->g = a; return 1; } static int dh_missing_parameters(const EVP_PKEY *a) { if (!a->pkey.dh->p || !a->pkey.dh->g) return 1; return 0; } static int dh_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b) { if (dh_cmp_parameters(a, b) == 0) return 0; if (BN_cmp(b->pkey.dh->pub_key, a->pkey.dh->pub_key) != 0) return 0; else return 1; } static int dh_param_print(BIO *bp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx) { return do_dh_print(bp, pkey->pkey.dh, indent, ctx, 0); } static int dh_public_print(BIO *bp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx) { return do_dh_print(bp, pkey->pkey.dh, indent, ctx, 1); } static int dh_private_print(BIO *bp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx) { return do_dh_print(bp, pkey->pkey.dh, indent, ctx, 2); } int DHparams_print(BIO *bp, const DH *x) { return do_dh_print(bp, x, 4, NULL, 0); } const EVP_PKEY_ASN1_METHOD dh_asn1_meth = { .pkey_id = EVP_PKEY_DH, .pkey_base_id = EVP_PKEY_DH, .pem_str = "DH", .info = "OpenSSL PKCS#3 DH method", .pub_decode = dh_pub_decode, .pub_encode = dh_pub_encode, .pub_cmp = dh_pub_cmp, .pub_print = dh_public_print, .priv_decode = dh_priv_decode, .priv_encode = dh_priv_encode, .priv_print = dh_private_print, .pkey_size = int_dh_size, .pkey_bits = dh_bits, .param_decode = dh_param_decode, .param_encode = dh_param_encode, .param_missing = dh_missing_parameters, .param_copy = dh_copy_parameters, .param_cmp = dh_cmp_parameters, .param_print = dh_param_print, .pkey_free = int_dh_free, }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dh/dh_check.c0000644000175000017500000001141612360020705020545 0ustar /* $OpenBSD: dh_check.c,v 1.12 2014/07/09 13:30:00 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include /* * Check that p is a safe prime and * if g is 2, 3 or 5, check that it is a suitable generator * where * for 2, p mod 24 == 11 * for 3, p mod 12 == 5 * for 5, p mod 10 == 3 or 7 * should hold. */ int DH_check(const DH *dh, int *ret) { int ok = 0; BN_CTX *ctx = NULL; BN_ULONG l; BIGNUM *q = NULL; *ret = 0; ctx = BN_CTX_new(); if (ctx == NULL) goto err; q = BN_new(); if (q == NULL) goto err; if (BN_is_word(dh->g, DH_GENERATOR_2)) { l = BN_mod_word(dh->p, 24); if (l != 11) *ret |= DH_NOT_SUITABLE_GENERATOR; #if 0 } else if (BN_is_word(dh->g, DH_GENERATOR_3)) { l = BN_mod_word(dh->p, 12); if (l != 5) *ret |= DH_NOT_SUITABLE_GENERATOR; #endif } else if (BN_is_word(dh->g, DH_GENERATOR_5)) { l = BN_mod_word(dh->p, 10); if (l != 3 && l != 7) *ret |= DH_NOT_SUITABLE_GENERATOR; } else *ret |= DH_UNABLE_TO_CHECK_GENERATOR; if (!BN_is_prime_ex(dh->p, BN_prime_checks, ctx, NULL)) *ret |= DH_CHECK_P_NOT_PRIME; else { if (!BN_rshift1(q, dh->p)) goto err; if (!BN_is_prime_ex(q, BN_prime_checks, ctx, NULL)) *ret |= DH_CHECK_P_NOT_SAFE_PRIME; } ok = 1; err: if (ctx != NULL) BN_CTX_free(ctx); if (q != NULL) BN_free(q); return ok; } int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret) { BIGNUM *q = NULL; *ret = 0; q = BN_new(); if (q == NULL) return 0; BN_set_word(q, 1); if (BN_cmp(pub_key, q) <= 0) *ret |= DH_CHECK_PUBKEY_TOO_SMALL; BN_copy(q, dh->p); BN_sub_word(q, 1); if (BN_cmp(pub_key, q) >= 0) *ret |= DH_CHECK_PUBKEY_TOO_LARGE; BN_free(q); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dh/dh_prn.c0000644000175000017500000000700612360020705020267 0ustar /* $OpenBSD: dh_prn.c,v 1.4 2014/07/09 13:26:47 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include int DHparams_print_fp(FILE *fp, const DH *x) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { DHerr(DH_F_DHPARAMS_PRINT_FP, ERR_R_BUF_LIB); return 0; } BIO_set_fp(b,fp,BIO_NOCLOSE); ret = DHparams_print(b, x); BIO_free(b); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dh/dh_err.c0000644000175000017500000001202412360020705020254 0ustar /* $OpenBSD: dh_err.c,v 1.14 2014/06/12 15:49:28 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_DH,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_DH,0,reason) static ERR_STRING_DATA DH_str_functs[]= { {ERR_FUNC(DH_F_COMPUTE_KEY), "COMPUTE_KEY"}, {ERR_FUNC(DH_F_DHPARAMS_PRINT_FP), "DHparams_print_fp"}, {ERR_FUNC(DH_F_DH_BUILTIN_GENPARAMS), "DH_BUILTIN_GENPARAMS"}, {ERR_FUNC(DH_F_DH_COMPUTE_KEY), "DH_compute_key"}, {ERR_FUNC(DH_F_DH_GENERATE_KEY), "DH_generate_key"}, {ERR_FUNC(DH_F_DH_GENERATE_PARAMETERS_EX), "DH_generate_parameters_ex"}, {ERR_FUNC(DH_F_DH_NEW_METHOD), "DH_new_method"}, {ERR_FUNC(DH_F_DH_PARAM_DECODE), "DH_PARAM_DECODE"}, {ERR_FUNC(DH_F_DH_PRIV_DECODE), "DH_PRIV_DECODE"}, {ERR_FUNC(DH_F_DH_PRIV_ENCODE), "DH_PRIV_ENCODE"}, {ERR_FUNC(DH_F_DH_PUB_DECODE), "DH_PUB_DECODE"}, {ERR_FUNC(DH_F_DH_PUB_ENCODE), "DH_PUB_ENCODE"}, {ERR_FUNC(DH_F_DO_DH_PRINT), "DO_DH_PRINT"}, {ERR_FUNC(DH_F_GENERATE_KEY), "GENERATE_KEY"}, {ERR_FUNC(DH_F_GENERATE_PARAMETERS), "GENERATE_PARAMETERS"}, {ERR_FUNC(DH_F_PKEY_DH_DERIVE), "PKEY_DH_DERIVE"}, {ERR_FUNC(DH_F_PKEY_DH_KEYGEN), "PKEY_DH_KEYGEN"}, {0,NULL} }; static ERR_STRING_DATA DH_str_reasons[]= { {ERR_REASON(DH_R_BAD_GENERATOR) ,"bad generator"}, {ERR_REASON(DH_R_BN_DECODE_ERROR) ,"bn decode error"}, {ERR_REASON(DH_R_BN_ERROR) ,"bn error"}, {ERR_REASON(DH_R_DECODE_ERROR) ,"decode error"}, {ERR_REASON(DH_R_INVALID_PUBKEY) ,"invalid public key"}, {ERR_REASON(DH_R_KEYS_NOT_SET) ,"keys not set"}, {ERR_REASON(DH_R_KEY_SIZE_TOO_SMALL) ,"key size too small"}, {ERR_REASON(DH_R_MODULUS_TOO_LARGE) ,"modulus too large"}, {ERR_REASON(DH_R_NON_FIPS_METHOD) ,"non fips method"}, {ERR_REASON(DH_R_NO_PARAMETERS_SET) ,"no parameters set"}, {ERR_REASON(DH_R_NO_PRIVATE_VALUE) ,"no private value"}, {ERR_REASON(DH_R_PARAMETER_ENCODING_ERROR),"parameter encoding error"}, {0,NULL} }; #endif void ERR_load_DH_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(DH_str_functs[0].error) == NULL) { ERR_load_strings(0,DH_str_functs); ERR_load_strings(0,DH_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dh/dh_key.c0000644000175000017500000001650412360020705020263 0ustar /* $OpenBSD: dh_key.c,v 1.19 2014/07/09 13:26:47 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include static int generate_key(DH *dh); static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh); static int dh_bn_mod_exp(const DH *dh, BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); static int dh_init(DH *dh); static int dh_finish(DH *dh); int DH_generate_key(DH *dh) { return dh->meth->generate_key(dh); } int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh) { return dh->meth->compute_key(key, pub_key, dh); } static DH_METHOD dh_ossl = { .name = "OpenSSL DH Method", .generate_key = generate_key, .compute_key = compute_key, .bn_mod_exp = dh_bn_mod_exp, .init = dh_init, .finish = dh_finish, }; const DH_METHOD * DH_OpenSSL(void) { return &dh_ossl; } static int generate_key(DH *dh) { int ok = 0; int generate_new_key = 0; unsigned l; BN_CTX *ctx; BN_MONT_CTX *mont = NULL; BIGNUM *pub_key = NULL, *priv_key = NULL; ctx = BN_CTX_new(); if (ctx == NULL) goto err; if (dh->priv_key == NULL) { priv_key = BN_new(); if (priv_key == NULL) goto err; generate_new_key = 1; } else priv_key = dh->priv_key; if (dh->pub_key == NULL) { pub_key = BN_new(); if (pub_key == NULL) goto err; } else pub_key = dh->pub_key; if (dh->flags & DH_FLAG_CACHE_MONT_P) { mont = BN_MONT_CTX_set_locked(&dh->method_mont_p, CRYPTO_LOCK_DH, dh->p, ctx); if (!mont) goto err; } if (generate_new_key) { if (dh->q) { do { if (!BN_rand_range(priv_key, dh->q)) goto err; } while (BN_is_zero(priv_key) || BN_is_one(priv_key)); } else { /* secret exponent length */ l = dh->length ? dh->length : BN_num_bits(dh->p) - 1; if (!BN_rand(priv_key, l, 0, 0)) goto err; } } { BIGNUM local_prk; BIGNUM *prk; if ((dh->flags & DH_FLAG_NO_EXP_CONSTTIME) == 0) { BN_init(&local_prk); prk = &local_prk; BN_with_flags(prk, priv_key, BN_FLG_CONSTTIME); } else prk = priv_key; if (!dh->meth->bn_mod_exp(dh, pub_key, dh->g, prk, dh->p, ctx, mont)) goto err; } dh->pub_key = pub_key; dh->priv_key = priv_key; ok = 1; err: if (ok != 1) DHerr(DH_F_GENERATE_KEY, ERR_R_BN_LIB); if (pub_key != NULL && dh->pub_key == NULL) BN_free(pub_key); if (priv_key != NULL && dh->priv_key == NULL) BN_free(priv_key); BN_CTX_free(ctx); return ok; } static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh) { BN_CTX *ctx = NULL; BN_MONT_CTX *mont = NULL; BIGNUM *tmp; int ret = -1; int check_result; if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS) { DHerr(DH_F_COMPUTE_KEY, DH_R_MODULUS_TOO_LARGE); goto err; } ctx = BN_CTX_new(); if (ctx == NULL) goto err; BN_CTX_start(ctx); tmp = BN_CTX_get(ctx); if (dh->priv_key == NULL) { DHerr(DH_F_COMPUTE_KEY, DH_R_NO_PRIVATE_VALUE); goto err; } if (dh->flags & DH_FLAG_CACHE_MONT_P) { mont = BN_MONT_CTX_set_locked(&dh->method_mont_p, CRYPTO_LOCK_DH, dh->p, ctx); if ((dh->flags & DH_FLAG_NO_EXP_CONSTTIME) == 0) { /* XXX */ BN_set_flags(dh->priv_key, BN_FLG_CONSTTIME); } if (!mont) goto err; } if (!DH_check_pub_key(dh, pub_key, &check_result) || check_result) { DHerr(DH_F_COMPUTE_KEY, DH_R_INVALID_PUBKEY); goto err; } if (!dh->meth->bn_mod_exp(dh, tmp, pub_key, dh->priv_key, dh->p, ctx, mont)) { DHerr(DH_F_COMPUTE_KEY, ERR_R_BN_LIB); goto err; } ret = BN_bn2bin(tmp, key); err: if (ctx != NULL) { BN_CTX_end(ctx); BN_CTX_free(ctx); } return ret; } static int dh_bn_mod_exp(const DH *dh, BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) { /* * If a is only one word long and constant time is false, use the faster * exponenentiation function. */ if (a->top == 1 && (dh->flags & DH_FLAG_NO_EXP_CONSTTIME) != 0) { BN_ULONG A = a->d[0]; return BN_mod_exp_mont_word(r, A, p, m, ctx, m_ctx); } else return BN_mod_exp_mont(r, a, p, m, ctx, m_ctx); } static int dh_init(DH *dh) { dh->flags |= DH_FLAG_CACHE_MONT_P; return 1; } static int dh_finish(DH *dh) { if (dh->method_mont_p) BN_MONT_CTX_free(dh->method_mont_p); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dh/dh_pmeth.c0000644000175000017500000001513312360020705020605 0ustar /* $OpenBSD: dh_pmeth.c,v 1.8 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include #include #include "evp_locl.h" /* DH pkey context structure */ typedef struct { /* Parameter gen parameters */ int prime_len; int generator; int use_dsa; /* Keygen callback info */ int gentmp[2]; /* message digest */ } DH_PKEY_CTX; static int pkey_dh_init(EVP_PKEY_CTX *ctx) { DH_PKEY_CTX *dctx; dctx = malloc(sizeof(DH_PKEY_CTX)); if (!dctx) return 0; dctx->prime_len = 1024; dctx->generator = 2; dctx->use_dsa = 0; ctx->data = dctx; ctx->keygen_info = dctx->gentmp; ctx->keygen_info_count = 2; return 1; } static int pkey_dh_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src) { DH_PKEY_CTX *dctx, *sctx; if (!pkey_dh_init(dst)) return 0; sctx = src->data; dctx = dst->data; dctx->prime_len = sctx->prime_len; dctx->generator = sctx->generator; dctx->use_dsa = sctx->use_dsa; return 1; } static void pkey_dh_cleanup(EVP_PKEY_CTX *ctx) { DH_PKEY_CTX *dctx = ctx->data; free(dctx); } static int pkey_dh_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) { DH_PKEY_CTX *dctx = ctx->data; switch (type) { case EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN: if (p1 < 256) return -2; dctx->prime_len = p1; return 1; case EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR: dctx->generator = p1; return 1; case EVP_PKEY_CTRL_PEER_KEY: /* Default behaviour is OK */ return 1; default: return -2; } } static int pkey_dh_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) { long lval; char *ep; int len; if (!strcmp(type, "dh_paramgen_prime_len")) { errno = 0; lval = strtol(value, &ep, 10); if (value[0] == '\0' || *ep != '\0') goto not_a_number; if ((errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN)) || (lval > INT_MAX || lval < INT_MIN)) goto out_of_range; len = lval; return EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len); } else if (!strcmp(type, "dh_paramgen_generator")) { errno = 0; lval = strtol(value, &ep, 10); if (value[0] == '\0' || *ep != '\0') goto not_a_number; if ((errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN)) || (lval > INT_MAX || lval < INT_MIN)) goto out_of_range; len = lval; return EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, len); } not_a_number: out_of_range: return -2; } static int pkey_dh_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) { DH *dh = NULL; DH_PKEY_CTX *dctx = ctx->data; BN_GENCB *pcb, cb; int ret; if (ctx->pkey_gencb) { pcb = &cb; evp_pkey_set_cb_translate(pcb, ctx); } else pcb = NULL; dh = DH_new(); if (!dh) return 0; ret = DH_generate_parameters_ex(dh, dctx->prime_len, dctx->generator, pcb); if (ret) EVP_PKEY_assign_DH(pkey, dh); else DH_free(dh); return ret; } static int pkey_dh_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) { DH *dh = NULL; if (ctx->pkey == NULL) { DHerr(DH_F_PKEY_DH_KEYGEN, DH_R_NO_PARAMETERS_SET); return 0; } dh = DH_new(); if (!dh) return 0; EVP_PKEY_assign_DH(pkey, dh); /* Note: if error return, pkey is freed by parent routine */ if (!EVP_PKEY_copy_parameters(pkey, ctx->pkey)) return 0; return DH_generate_key(pkey->pkey.dh); } static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen) { int ret; if (!ctx->pkey || !ctx->peerkey) { DHerr(DH_F_PKEY_DH_DERIVE, DH_R_KEYS_NOT_SET); return 0; } ret = DH_compute_key(key, ctx->peerkey->pkey.dh->pub_key, ctx->pkey->pkey.dh); if (ret < 0) return ret; *keylen = ret; return 1; } const EVP_PKEY_METHOD dh_pkey_meth = { .pkey_id = EVP_PKEY_DH, .flags = EVP_PKEY_FLAG_AUTOARGLEN, .init = pkey_dh_init, .copy = pkey_dh_copy, .cleanup = pkey_dh_cleanup, .paramgen = pkey_dh_paramgen, .keygen = pkey_dh_keygen, .derive = pkey_dh_derive, .ctrl = pkey_dh_ctrl, .ctrl_str = pkey_dh_ctrl_str }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ecdsa/0000755000000000000000000000000012666635521021131 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/ecdsa/ecs_ossl.c0000644000175000017500000003017012360020705021311 0ustar /* $OpenBSD: ecs_ossl.c,v 1.3 2014/06/12 15:49:29 deraadt Exp $ */ /* * Written by Nils Larsch for the OpenSSL project */ /* ==================================================================== * Copyright (c) 1998-2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include "ecs_locl.h" #include #include #include static ECDSA_SIG *ecdsa_do_sign(const unsigned char *dgst, int dlen, const BIGNUM *, const BIGNUM *, EC_KEY *eckey); static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); static int ecdsa_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, EC_KEY *eckey); static ECDSA_METHOD openssl_ecdsa_meth = { .name = "OpenSSL ECDSA method", .ecdsa_do_sign = ecdsa_do_sign, .ecdsa_sign_setup = ecdsa_sign_setup, .ecdsa_do_verify = ecdsa_do_verify }; const ECDSA_METHOD *ECDSA_OpenSSL(void) { return &openssl_ecdsa_meth; } static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) { BN_CTX *ctx = NULL; BIGNUM *k = NULL, *r = NULL, *order = NULL, *X = NULL; EC_POINT *tmp_point=NULL; const EC_GROUP *group; int ret = 0; if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL) { ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_PASSED_NULL_PARAMETER); return 0; } if (ctx_in == NULL) { if ((ctx = BN_CTX_new()) == NULL) { ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP,ERR_R_MALLOC_FAILURE); return 0; } } else ctx = ctx_in; k = BN_new(); /* this value is later returned in *kinvp */ r = BN_new(); /* this value is later returned in *rp */ order = BN_new(); X = BN_new(); if (!k || !r || !order || !X) { ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_MALLOC_FAILURE); goto err; } if ((tmp_point = EC_POINT_new(group)) == NULL) { ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB); goto err; } if (!EC_GROUP_get_order(group, order, ctx)) { ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB); goto err; } do { /* get random k */ do if (!BN_rand_range(k, order)) { ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED); goto err; } while (BN_is_zero(k)); /* We do not want timing information to leak the length of k, * so we compute G*k using an equivalent scalar of fixed * bit-length. */ if (!BN_add(k, k, order)) goto err; if (BN_num_bits(k) <= BN_num_bits(order)) if (!BN_add(k, k, order)) goto err; /* compute r the x-coordinate of generator * k */ if (!EC_POINT_mul(group, tmp_point, k, NULL, NULL, ctx)) { ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB); goto err; } if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field) { if (!EC_POINT_get_affine_coordinates_GFp(group, tmp_point, X, NULL, ctx)) { ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP,ERR_R_EC_LIB); goto err; } } #ifndef OPENSSL_NO_EC2M else /* NID_X9_62_characteristic_two_field */ { if (!EC_POINT_get_affine_coordinates_GF2m(group, tmp_point, X, NULL, ctx)) { ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP,ERR_R_EC_LIB); goto err; } } #endif if (!BN_nnmod(r, X, order, ctx)) { ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB); goto err; } } while (BN_is_zero(r)); /* compute the inverse of k */ if (!BN_mod_inverse(k, k, order, ctx)) { ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB); goto err; } /* clear old values if necessary */ if (*rp != NULL) BN_clear_free(*rp); if (*kinvp != NULL) BN_clear_free(*kinvp); /* save the pre-computed values */ *rp = r; *kinvp = k; ret = 1; err: if (!ret) { if (k != NULL) BN_clear_free(k); if (r != NULL) BN_clear_free(r); } if (ctx_in == NULL) BN_CTX_free(ctx); if (order != NULL) BN_free(order); if (tmp_point != NULL) EC_POINT_free(tmp_point); if (X) BN_clear_free(X); return(ret); } static ECDSA_SIG *ecdsa_do_sign(const unsigned char *dgst, int dgst_len, const BIGNUM *in_kinv, const BIGNUM *in_r, EC_KEY *eckey) { int ok = 0, i; BIGNUM *kinv=NULL, *s, *m=NULL,*tmp=NULL,*order=NULL; const BIGNUM *ckinv; BN_CTX *ctx = NULL; const EC_GROUP *group; ECDSA_SIG *ret; ECDSA_DATA *ecdsa; const BIGNUM *priv_key; ecdsa = ecdsa_check(eckey); group = EC_KEY_get0_group(eckey); priv_key = EC_KEY_get0_private_key(eckey); if (group == NULL || priv_key == NULL || ecdsa == NULL) { ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_PASSED_NULL_PARAMETER); return NULL; } ret = ECDSA_SIG_new(); if (!ret) { ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_MALLOC_FAILURE); return NULL; } s = ret->s; if ((ctx = BN_CTX_new()) == NULL || (order = BN_new()) == NULL || (tmp = BN_new()) == NULL || (m = BN_new()) == NULL) { ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_MALLOC_FAILURE); goto err; } if (!EC_GROUP_get_order(group, order, ctx)) { ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_EC_LIB); goto err; } i = BN_num_bits(order); /* Need to truncate digest if it is too long: first truncate whole * bytes. */ if (8 * dgst_len > i) dgst_len = (i + 7)/8; if (!BN_bin2bn(dgst, dgst_len, m)) { ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_BN_LIB); goto err; } /* If still too long truncate remaining bits with a shift */ if ((8 * dgst_len > i) && !BN_rshift(m, m, 8 - (i & 0x7))) { ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_BN_LIB); goto err; } do { if (in_kinv == NULL || in_r == NULL) { if (!ECDSA_sign_setup(eckey, ctx, &kinv, &ret->r)) { ECDSAerr(ECDSA_F_ECDSA_DO_SIGN,ERR_R_ECDSA_LIB); goto err; } ckinv = kinv; } else { ckinv = in_kinv; if (BN_copy(ret->r, in_r) == NULL) { ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_MALLOC_FAILURE); goto err; } } if (!BN_mod_mul(tmp, priv_key, ret->r, order, ctx)) { ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_BN_LIB); goto err; } if (!BN_mod_add_quick(s, tmp, m, order)) { ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_BN_LIB); goto err; } if (!BN_mod_mul(s, s, ckinv, order, ctx)) { ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_BN_LIB); goto err; } if (BN_is_zero(s)) { /* if kinv and r have been supplied by the caller * don't to generate new kinv and r values */ if (in_kinv != NULL && in_r != NULL) { ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ECDSA_R_NEED_NEW_SETUP_VALUES); goto err; } } else /* s != 0 => we have a valid signature */ break; } while (1); ok = 1; err: if (!ok) { ECDSA_SIG_free(ret); ret = NULL; } if (ctx) BN_CTX_free(ctx); if (m) BN_clear_free(m); if (tmp) BN_clear_free(tmp); if (order) BN_free(order); if (kinv) BN_clear_free(kinv); return ret; } static int ecdsa_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, EC_KEY *eckey) { int ret = -1, i; BN_CTX *ctx; BIGNUM *order, *u1, *u2, *m, *X; EC_POINT *point = NULL; const EC_GROUP *group; const EC_POINT *pub_key; /* check input values */ if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL || (pub_key = EC_KEY_get0_public_key(eckey)) == NULL || sig == NULL) { ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ECDSA_R_MISSING_PARAMETERS); return -1; } ctx = BN_CTX_new(); if (!ctx) { ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_MALLOC_FAILURE); return -1; } BN_CTX_start(ctx); order = BN_CTX_get(ctx); u1 = BN_CTX_get(ctx); u2 = BN_CTX_get(ctx); m = BN_CTX_get(ctx); X = BN_CTX_get(ctx); if (!X) { ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); goto err; } if (!EC_GROUP_get_order(group, order, ctx)) { ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_EC_LIB); goto err; } if (BN_is_zero(sig->r) || BN_is_negative(sig->r) || BN_ucmp(sig->r, order) >= 0 || BN_is_zero(sig->s) || BN_is_negative(sig->s) || BN_ucmp(sig->s, order) >= 0) { ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ECDSA_R_BAD_SIGNATURE); ret = 0; /* signature is invalid */ goto err; } /* calculate tmp1 = inv(S) mod order */ if (!BN_mod_inverse(u2, sig->s, order, ctx)) { ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); goto err; } /* digest -> m */ i = BN_num_bits(order); /* Need to truncate digest if it is too long: first truncate whole * bytes. */ if (8 * dgst_len > i) dgst_len = (i + 7)/8; if (!BN_bin2bn(dgst, dgst_len, m)) { ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); goto err; } /* If still too long truncate remaining bits with a shift */ if ((8 * dgst_len > i) && !BN_rshift(m, m, 8 - (i & 0x7))) { ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); goto err; } /* u1 = m * tmp mod order */ if (!BN_mod_mul(u1, m, u2, order, ctx)) { ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); goto err; } /* u2 = r * w mod q */ if (!BN_mod_mul(u2, sig->r, u2, order, ctx)) { ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); goto err; } if ((point = EC_POINT_new(group)) == NULL) { ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_MALLOC_FAILURE); goto err; } if (!EC_POINT_mul(group, point, u1, pub_key, u2, ctx)) { ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_EC_LIB); goto err; } if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field) { if (!EC_POINT_get_affine_coordinates_GFp(group, point, X, NULL, ctx)) { ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_EC_LIB); goto err; } } #ifndef OPENSSL_NO_EC2M else /* NID_X9_62_characteristic_two_field */ { if (!EC_POINT_get_affine_coordinates_GF2m(group, point, X, NULL, ctx)) { ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_EC_LIB); goto err; } } #endif if (!BN_nnmod(u1, X, order, ctx)) { ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); goto err; } /* if the signature is correct u1 is equal to sig->r */ ret = (BN_ucmp(u1, sig->r) == 0); err: BN_CTX_end(ctx); BN_CTX_free(ctx); if (point) EC_POINT_free(point); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ecdsa/ecs_asn1.c0000644000175000017500000000566512360020705021206 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "ecs_locl.h" #include #include ASN1_SEQUENCE(ECDSA_SIG) = { ASN1_SIMPLE(ECDSA_SIG, r, CBIGNUM), ASN1_SIMPLE(ECDSA_SIG, s, CBIGNUM) } ASN1_SEQUENCE_END(ECDSA_SIG) DECLARE_ASN1_FUNCTIONS_const(ECDSA_SIG) DECLARE_ASN1_ENCODE_FUNCTIONS_const(ECDSA_SIG, ECDSA_SIG) IMPLEMENT_ASN1_FUNCTIONS_const(ECDSA_SIG) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ecdsa/ecs_err.c0000644000175000017500000001040412360020705021117 0ustar /* $OpenBSD: ecs_err.c,v 1.2 2014/06/12 15:49:29 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_ECDSA,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_ECDSA,0,reason) static ERR_STRING_DATA ECDSA_str_functs[]= { {ERR_FUNC(ECDSA_F_ECDSA_CHECK), "ECDSA_CHECK"}, {ERR_FUNC(ECDSA_F_ECDSA_DATA_NEW_METHOD), "ECDSA_DATA_NEW_METHOD"}, {ERR_FUNC(ECDSA_F_ECDSA_DO_SIGN), "ECDSA_do_sign"}, {ERR_FUNC(ECDSA_F_ECDSA_DO_VERIFY), "ECDSA_do_verify"}, {ERR_FUNC(ECDSA_F_ECDSA_SIGN_SETUP), "ECDSA_sign_setup"}, {0,NULL} }; static ERR_STRING_DATA ECDSA_str_reasons[]= { {ERR_REASON(ECDSA_R_BAD_SIGNATURE) ,"bad signature"}, {ERR_REASON(ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),"data too large for key size"}, {ERR_REASON(ECDSA_R_ERR_EC_LIB) ,"err ec lib"}, {ERR_REASON(ECDSA_R_MISSING_PARAMETERS) ,"missing parameters"}, {ERR_REASON(ECDSA_R_NEED_NEW_SETUP_VALUES),"need new setup values"}, {ERR_REASON(ECDSA_R_NON_FIPS_METHOD) ,"non fips method"}, {ERR_REASON(ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED),"random number generation failed"}, {ERR_REASON(ECDSA_R_SIGNATURE_MALLOC_FAILED),"signature malloc failed"}, {0,NULL} }; #endif void ERR_load_ECDSA_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(ECDSA_str_functs[0].error) == NULL) { ERR_load_strings(0,ECDSA_str_functs); ERR_load_strings(0,ECDSA_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ecdsa/ecs_locl.h0000644000175000017500000001011212360020705021261 0ustar /* $OpenBSD$ */ /* * Written by Nils Larsch for the OpenSSL project */ /* ==================================================================== * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #ifndef HEADER_ECS_LOCL_H #define HEADER_ECS_LOCL_H #include #ifdef __cplusplus extern "C" { #endif struct ecdsa_method { const char *name; ECDSA_SIG *(*ecdsa_do_sign)(const unsigned char *dgst, int dgst_len, const BIGNUM *inv, const BIGNUM *rp, EC_KEY *eckey); int (*ecdsa_sign_setup)(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, BIGNUM **r); int (*ecdsa_do_verify)(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, EC_KEY *eckey); #if 0 int (*init)(EC_KEY *eckey); int (*finish)(EC_KEY *eckey); #endif int flags; char *app_data; }; /* If this flag is set the ECDSA method is FIPS compliant and can be used * in FIPS mode. This is set in the validated module method. If an * application sets this flag in its own methods it is its responsibility * to ensure the result is compliant. */ #define ECDSA_FLAG_FIPS_METHOD 0x1 typedef struct ecdsa_data_st { /* EC_KEY_METH_DATA part */ int (*init)(EC_KEY *); /* method (ECDSA) specific part */ ENGINE *engine; int flags; const ECDSA_METHOD *meth; CRYPTO_EX_DATA ex_data; } ECDSA_DATA; /** ecdsa_check * checks whether ECKEY->meth_data is a pointer to a ECDSA_DATA structure * and if not it removes the old meth_data and creates a ECDSA_DATA structure. * \param eckey pointer to a EC_KEY object * \return pointer to a ECDSA_DATA structure */ ECDSA_DATA *ecdsa_check(EC_KEY *eckey); #ifdef __cplusplus } #endif #endif /* HEADER_ECS_LOCL_H */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ecdsa/ecs_vrf.c0000644000175000017500000000712412360020705021131 0ustar /* $OpenBSD: ecs_vrf.c,v 1.2 2014/06/12 15:49:29 deraadt Exp $ */ /* * Written by Nils Larsch for the OpenSSL project */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include "ecs_locl.h" #ifndef OPENSSL_NO_ENGINE #include #endif /* returns * 1: correct signature * 0: incorrect signature * -1: error */ int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, EC_KEY *eckey) { ECDSA_DATA *ecdsa = ecdsa_check(eckey); if (ecdsa == NULL) return 0; return ecdsa->meth->ecdsa_do_verify(dgst, dgst_len, sig, eckey); } /* returns * 1: correct signature * 0: incorrect signature * -1: error */ int ECDSA_verify(int type, const unsigned char *dgst, int dgst_len, const unsigned char *sigbuf, int sig_len, EC_KEY *eckey) { ECDSA_SIG *s; int ret=-1; s = ECDSA_SIG_new(); if (s == NULL) return(ret); if (d2i_ECDSA_SIG(&s, &sigbuf, sig_len) == NULL) goto err; ret=ECDSA_do_verify(dgst, dgst_len, s, eckey); err: ECDSA_SIG_free(s); return(ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ecdsa/ecs_sign.c0000644000175000017500000000767012360020705021302 0ustar /* $OpenBSD: ecs_sign.c,v 1.3 2014/06/12 15:49:29 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include "ecs_locl.h" #ifndef OPENSSL_NO_ENGINE #include #endif #include ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) { return ECDSA_do_sign_ex(dgst, dlen, NULL, NULL, eckey); } ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dlen, const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey) { ECDSA_DATA *ecdsa = ecdsa_check(eckey); if (ecdsa == NULL) return NULL; return ecdsa->meth->ecdsa_do_sign(dgst, dlen, kinv, rp, eckey); } int ECDSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, unsigned int *siglen, EC_KEY *eckey) { return ECDSA_sign_ex(type, dgst, dlen, sig, siglen, NULL, NULL, eckey); } int ECDSA_sign_ex(int type, const unsigned char *dgst, int dlen, unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey) { ECDSA_SIG *s; s = ECDSA_do_sign_ex(dgst, dlen, kinv, r, eckey); if (s == NULL) { *siglen=0; return 0; } *siglen = i2d_ECDSA_SIG(s, &sig); ECDSA_SIG_free(s); return 1; } int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) { ECDSA_DATA *ecdsa = ecdsa_check(eckey); if (ecdsa == NULL) return 0; return ecdsa->meth->ecdsa_sign_setup(eckey, ctx_in, kinvp, rp); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ecdsa/ecs_lib.c0000644000175000017500000001546012360020705021104 0ustar /* $OpenBSD: ecs_lib.c,v 1.6 2014/07/09 11:10:50 bcook Exp $ */ /* ==================================================================== * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "ecs_locl.h" #ifndef OPENSSL_NO_ENGINE #include #endif #include #include static const ECDSA_METHOD *default_ECDSA_method = NULL; static void *ecdsa_data_new(void); static void *ecdsa_data_dup(void *); static void ecdsa_data_free(void *); void ECDSA_set_default_method(const ECDSA_METHOD *meth) { default_ECDSA_method = meth; } const ECDSA_METHOD *ECDSA_get_default_method(void) { if(!default_ECDSA_method) { default_ECDSA_method = ECDSA_OpenSSL(); } return default_ECDSA_method; } int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth) { ECDSA_DATA *ecdsa; ecdsa = ecdsa_check(eckey); if (ecdsa == NULL) return 0; #ifndef OPENSSL_NO_ENGINE if (ecdsa->engine) { ENGINE_finish(ecdsa->engine); ecdsa->engine = NULL; } #endif ecdsa->meth = meth; return 1; } static ECDSA_DATA *ECDSA_DATA_new_method(ENGINE *engine) { ECDSA_DATA *ret; ret = malloc(sizeof(ECDSA_DATA)); if (ret == NULL) { ECDSAerr(ECDSA_F_ECDSA_DATA_NEW_METHOD, ERR_R_MALLOC_FAILURE); return(NULL); } ret->init = NULL; ret->meth = ECDSA_get_default_method(); ret->engine = engine; #ifndef OPENSSL_NO_ENGINE if (!ret->engine) ret->engine = ENGINE_get_default_ECDSA(); if (ret->engine) { ret->meth = ENGINE_get_ECDSA(ret->engine); if (!ret->meth) { ECDSAerr(ECDSA_F_ECDSA_DATA_NEW_METHOD, ERR_R_ENGINE_LIB); ENGINE_finish(ret->engine); free(ret); return NULL; } } #endif ret->flags = ret->meth->flags; CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ECDSA, ret, &ret->ex_data); #if 0 if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDSA, ret, &ret->ex_data); free(ret); ret=NULL; } #endif return(ret); } static void *ecdsa_data_new(void) { return (void *)ECDSA_DATA_new_method(NULL); } static void *ecdsa_data_dup(void *data) { ECDSA_DATA *r = (ECDSA_DATA *)data; /* XXX: dummy operation */ if (r == NULL) return NULL; return ecdsa_data_new(); } static void ecdsa_data_free(void *data) { ECDSA_DATA *r = (ECDSA_DATA *)data; #ifndef OPENSSL_NO_ENGINE if (r->engine) ENGINE_finish(r->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDSA, r, &r->ex_data); OPENSSL_cleanse((void *)r, sizeof(ECDSA_DATA)); free(r); } ECDSA_DATA *ecdsa_check(EC_KEY *key) { ECDSA_DATA *ecdsa_data; void *data = EC_KEY_get_key_method_data(key, ecdsa_data_dup, ecdsa_data_free, ecdsa_data_free); if (data == NULL) { ecdsa_data = (ECDSA_DATA *)ecdsa_data_new(); if (ecdsa_data == NULL) return NULL; data = EC_KEY_insert_key_method_data(key, (void *)ecdsa_data, ecdsa_data_dup, ecdsa_data_free, ecdsa_data_free); if (data != NULL) { /* Another thread raced us to install the key_method * data and won. */ ecdsa_data_free(ecdsa_data); ecdsa_data = (ECDSA_DATA *)data; } } else ecdsa_data = (ECDSA_DATA *)data; return ecdsa_data; } int ECDSA_size(const EC_KEY *r) { int ret,i; ASN1_INTEGER bs; BIGNUM *order=NULL; unsigned char buf[4]; const EC_GROUP *group; if (r == NULL) return 0; group = EC_KEY_get0_group(r); if (group == NULL) return 0; if ((order = BN_new()) == NULL) return 0; if (!EC_GROUP_get_order(group,order,NULL)) { BN_clear_free(order); return 0; } i=BN_num_bits(order); bs.length=(i+7)/8; bs.data=buf; bs.type=V_ASN1_INTEGER; /* If the top bit is set the asn1 encoding is 1 larger. */ buf[0]=0xff; i=i2d_ASN1_INTEGER(&bs,NULL); i+=i; /* r and s */ ret=ASN1_object_size(1,i,V_ASN1_SEQUENCE); BN_clear_free(order); return(ret); } int ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ECDSA, argl, argp, new_func, dup_func, free_func); } int ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg) { ECDSA_DATA *ecdsa; ecdsa = ecdsa_check(d); if (ecdsa == NULL) return 0; return(CRYPTO_set_ex_data(&ecdsa->ex_data,idx,arg)); } void *ECDSA_get_ex_data(EC_KEY *d, int idx) { ECDSA_DATA *ecdsa; ecdsa = ecdsa_check(d); if (ecdsa == NULL) return NULL; return(CRYPTO_get_ex_data(&ecdsa->ex_data,idx)); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rc2/0000755000000000000000000000000012666635521020540 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/rc2/rc2_ecb.c0000644000175000017500000000742612360020706020416 0ustar /* $OpenBSD: rc2_ecb.c,v 1.5 2014/06/12 15:49:30 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "rc2_locl.h" #include /* RC2 as implemented frm a posting from * Newsgroups: sci.crypt * Sender: pgut01@cs.auckland.ac.nz (Peter Gutmann) * Subject: Specification for Ron Rivests Cipher No.2 * Message-ID: <4fk39f$f70@net.auckland.ac.nz> * Date: 11 Feb 1996 06:45:03 GMT */ void RC2_ecb_encrypt(const unsigned char *in, unsigned char *out, RC2_KEY *ks, int encrypt) { unsigned long l,d[2]; c2l(in,l); d[0]=l; c2l(in,l); d[1]=l; if (encrypt) RC2_encrypt(d,ks); else RC2_decrypt(d,ks); l=d[0]; l2c(l,out); l=d[1]; l2c(l,out); l=d[0]=d[1]=0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rc2/rc2cfb64.c0000644000175000017500000001057512360020706020431 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "rc2_locl.h" /* The input and output encrypted as though 64bit cfb mode is being * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ void RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, RC2_KEY *schedule, unsigned char *ivec, int *num, int encrypt) { register unsigned long v0,v1,t; register int n= *num; register long l=length; unsigned long ti[2]; unsigned char *iv,c,cc; iv=(unsigned char *)ivec; if (encrypt) { while (l--) { if (n == 0) { c2l(iv,v0); ti[0]=v0; c2l(iv,v1); ti[1]=v1; RC2_encrypt((unsigned long *)ti,schedule); iv=(unsigned char *)ivec; t=ti[0]; l2c(t,iv); t=ti[1]; l2c(t,iv); iv=(unsigned char *)ivec; } c= *(in++)^iv[n]; *(out++)=c; iv[n]=c; n=(n+1)&0x07; } } else { while (l--) { if (n == 0) { c2l(iv,v0); ti[0]=v0; c2l(iv,v1); ti[1]=v1; RC2_encrypt((unsigned long *)ti,schedule); iv=(unsigned char *)ivec; t=ti[0]; l2c(t,iv); t=ti[1]; l2c(t,iv); iv=(unsigned char *)ivec; } cc= *(in++); c=iv[n]; iv[n]=cc; *(out++)=c^cc; n=(n+1)&0x07; } } v0=v1=ti[0]=ti[1]=t=c=cc=0; *num=n; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rc2/rc2_locl.h0000644000175000017500000001501012360020706020607 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #undef c2l #define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ l|=((unsigned long)(*((c)++)))<< 8L, \ l|=((unsigned long)(*((c)++)))<<16L, \ l|=((unsigned long)(*((c)++)))<<24L) /* NOTE - c is not incremented as per c2l */ #undef c2ln #define c2ln(c,l1,l2,n) { \ c+=n; \ l1=l2=0; \ switch (n) { \ case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ case 5: l2|=((unsigned long)(*(--(c)))); \ case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ case 1: l1|=((unsigned long)(*(--(c)))); \ } \ } #undef l2c #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>>24L)&0xff)) /* NOTE - c is not incremented as per l2c */ #undef l2cn #define l2cn(l1,l2,c,n) { \ c+=n; \ switch (n) { \ case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ } \ } /* NOTE - c is not incremented as per n2l */ #define n2ln(c,l1,l2,n) { \ c+=n; \ l1=l2=0; \ switch (n) { \ case 8: l2 =((unsigned long)(*(--(c)))) ; \ case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ case 6: l2|=((unsigned long)(*(--(c))))<<16; \ case 5: l2|=((unsigned long)(*(--(c))))<<24; \ case 4: l1 =((unsigned long)(*(--(c)))) ; \ case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ case 2: l1|=((unsigned long)(*(--(c))))<<16; \ case 1: l1|=((unsigned long)(*(--(c))))<<24; \ } \ } /* NOTE - c is not incremented as per l2n */ #define l2nn(l1,l2,c,n) { \ c+=n; \ switch (n) { \ case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ } \ } #undef n2l #define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ l|=((unsigned long)(*((c)++)))<<16L, \ l|=((unsigned long)(*((c)++)))<< 8L, \ l|=((unsigned long)(*((c)++)))) #undef l2n #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l) )&0xff)) #define C_RC2(n) \ t=(x0+(x1& ~x3)+(x2&x3)+ *(p0++))&0xffff; \ x0=(t<<1)|(t>>15); \ t=(x1+(x2& ~x0)+(x3&x0)+ *(p0++))&0xffff; \ x1=(t<<2)|(t>>14); \ t=(x2+(x3& ~x1)+(x0&x1)+ *(p0++))&0xffff; \ x2=(t<<3)|(t>>13); \ t=(x3+(x0& ~x2)+(x1&x2)+ *(p0++))&0xffff; \ x3=(t<<5)|(t>>11); deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rc2/rc2_skey.c0000644000175000017500000001323112360020706020627 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include "rc2_locl.h" static const unsigned char key_table[256]={ 0xd9,0x78,0xf9,0xc4,0x19,0xdd,0xb5,0xed,0x28,0xe9,0xfd,0x79, 0x4a,0xa0,0xd8,0x9d,0xc6,0x7e,0x37,0x83,0x2b,0x76,0x53,0x8e, 0x62,0x4c,0x64,0x88,0x44,0x8b,0xfb,0xa2,0x17,0x9a,0x59,0xf5, 0x87,0xb3,0x4f,0x13,0x61,0x45,0x6d,0x8d,0x09,0x81,0x7d,0x32, 0xbd,0x8f,0x40,0xeb,0x86,0xb7,0x7b,0x0b,0xf0,0x95,0x21,0x22, 0x5c,0x6b,0x4e,0x82,0x54,0xd6,0x65,0x93,0xce,0x60,0xb2,0x1c, 0x73,0x56,0xc0,0x14,0xa7,0x8c,0xf1,0xdc,0x12,0x75,0xca,0x1f, 0x3b,0xbe,0xe4,0xd1,0x42,0x3d,0xd4,0x30,0xa3,0x3c,0xb6,0x26, 0x6f,0xbf,0x0e,0xda,0x46,0x69,0x07,0x57,0x27,0xf2,0x1d,0x9b, 0xbc,0x94,0x43,0x03,0xf8,0x11,0xc7,0xf6,0x90,0xef,0x3e,0xe7, 0x06,0xc3,0xd5,0x2f,0xc8,0x66,0x1e,0xd7,0x08,0xe8,0xea,0xde, 0x80,0x52,0xee,0xf7,0x84,0xaa,0x72,0xac,0x35,0x4d,0x6a,0x2a, 0x96,0x1a,0xd2,0x71,0x5a,0x15,0x49,0x74,0x4b,0x9f,0xd0,0x5e, 0x04,0x18,0xa4,0xec,0xc2,0xe0,0x41,0x6e,0x0f,0x51,0xcb,0xcc, 0x24,0x91,0xaf,0x50,0xa1,0xf4,0x70,0x39,0x99,0x7c,0x3a,0x85, 0x23,0xb8,0xb4,0x7a,0xfc,0x02,0x36,0x5b,0x25,0x55,0x97,0x31, 0x2d,0x5d,0xfa,0x98,0xe3,0x8a,0x92,0xae,0x05,0xdf,0x29,0x10, 0x67,0x6c,0xba,0xc9,0xd3,0x00,0xe6,0xcf,0xe1,0x9e,0xa8,0x2c, 0x63,0x16,0x01,0x3f,0x58,0xe2,0x89,0xa9,0x0d,0x38,0x34,0x1b, 0xab,0x33,0xff,0xb0,0xbb,0x48,0x0c,0x5f,0xb9,0xb1,0xcd,0x2e, 0xc5,0xf3,0xdb,0x47,0xe5,0xa5,0x9c,0x77,0x0a,0xa6,0x20,0x68, 0xfe,0x7f,0xc1,0xad, }; /* It has come to my attention that there are 2 versions of the RC2 * key schedule. One which is normal, and anther which has a hook to * use a reduced key length. * BSAFE uses the 'retarded' version. What I previously shipped is * the same as specifying 1024 for the 'bits' parameter. Bsafe uses * a version where the bits parameter is the same as len*8 */ void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits) { int i,j; unsigned char *k; RC2_INT *ki; unsigned int c,d; k= (unsigned char *)&(key->data[0]); *k=0; /* for if there is a zero length key */ if (len > 128) len=128; if (bits <= 0) bits=1024; if (bits > 1024) bits=1024; for (i=0; i>3; i=128-j; c= (0xff>>(-bits & 0x07)); d=key_table[k[i]&c]; k[i]=d; while (i--) { d=key_table[k[i+j]^d]; k[i]=d; } /* copy from bytes into RC2_INT's */ ki= &(key->data[63]); for (i=127; i>=0; i-=2) *(ki--)=((k[i]<<8)|k[i-1])&0xffff; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rc2/rc2_cbc.c0000644000175000017500000001444312360020706020411 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "rc2_locl.h" void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, RC2_KEY *ks, unsigned char *iv, int encrypt) { register unsigned long tin0,tin1; register unsigned long tout0,tout1,xor0,xor1; register long l=length; unsigned long tin[2]; if (encrypt) { c2l(iv,tout0); c2l(iv,tout1); iv-=8; for (l-=8; l>=0; l-=8) { c2l(in,tin0); c2l(in,tin1); tin0^=tout0; tin1^=tout1; tin[0]=tin0; tin[1]=tin1; RC2_encrypt(tin,ks); tout0=tin[0]; l2c(tout0,out); tout1=tin[1]; l2c(tout1,out); } if (l != -8) { c2ln(in,tin0,tin1,l+8); tin0^=tout0; tin1^=tout1; tin[0]=tin0; tin[1]=tin1; RC2_encrypt(tin,ks); tout0=tin[0]; l2c(tout0,out); tout1=tin[1]; l2c(tout1,out); } l2c(tout0,iv); l2c(tout1,iv); } else { c2l(iv,xor0); c2l(iv,xor1); iv-=8; for (l-=8; l>=0; l-=8) { c2l(in,tin0); tin[0]=tin0; c2l(in,tin1); tin[1]=tin1; RC2_decrypt(tin,ks); tout0=tin[0]^xor0; tout1=tin[1]^xor1; l2c(tout0,out); l2c(tout1,out); xor0=tin0; xor1=tin1; } if (l != -8) { c2l(in,tin0); tin[0]=tin0; c2l(in,tin1); tin[1]=tin1; RC2_decrypt(tin,ks); tout0=tin[0]^xor0; tout1=tin[1]^xor1; l2cn(tout0,tout1,out,l+8); xor0=tin0; xor1=tin1; } l2c(xor0,iv); l2c(xor1,iv); } tin0=tin1=tout0=tout1=xor0=xor1=0; tin[0]=tin[1]=0; } void RC2_encrypt(unsigned long *d, RC2_KEY *key) { int i,n; register RC2_INT *p0,*p1; register RC2_INT x0,x1,x2,x3,t; unsigned long l; l=d[0]; x0=(RC2_INT)l&0xffff; x1=(RC2_INT)(l>>16L); l=d[1]; x2=(RC2_INT)l&0xffff; x3=(RC2_INT)(l>>16L); n=3; i=5; p0=p1= &(key->data[0]); for (;;) { t=(x0+(x1& ~x3)+(x2&x3)+ *(p0++))&0xffff; x0=(t<<1)|(t>>15); t=(x1+(x2& ~x0)+(x3&x0)+ *(p0++))&0xffff; x1=(t<<2)|(t>>14); t=(x2+(x3& ~x1)+(x0&x1)+ *(p0++))&0xffff; x2=(t<<3)|(t>>13); t=(x3+(x0& ~x2)+(x1&x2)+ *(p0++))&0xffff; x3=(t<<5)|(t>>11); if (--i == 0) { if (--n == 0) break; i=(n == 2)?6:5; x0+=p1[x3&0x3f]; x1+=p1[x0&0x3f]; x2+=p1[x1&0x3f]; x3+=p1[x2&0x3f]; } } d[0]=(unsigned long)(x0&0xffff)|((unsigned long)(x1&0xffff)<<16L); d[1]=(unsigned long)(x2&0xffff)|((unsigned long)(x3&0xffff)<<16L); } void RC2_decrypt(unsigned long *d, RC2_KEY *key) { int i,n; register RC2_INT *p0,*p1; register RC2_INT x0,x1,x2,x3,t; unsigned long l; l=d[0]; x0=(RC2_INT)l&0xffff; x1=(RC2_INT)(l>>16L); l=d[1]; x2=(RC2_INT)l&0xffff; x3=(RC2_INT)(l>>16L); n=3; i=5; p0= &(key->data[63]); p1= &(key->data[0]); for (;;) { t=((x3<<11)|(x3>>5))&0xffff; x3=(t-(x0& ~x2)-(x1&x2)- *(p0--))&0xffff; t=((x2<<13)|(x2>>3))&0xffff; x2=(t-(x3& ~x1)-(x0&x1)- *(p0--))&0xffff; t=((x1<<14)|(x1>>2))&0xffff; x1=(t-(x2& ~x0)-(x3&x0)- *(p0--))&0xffff; t=((x0<<15)|(x0>>1))&0xffff; x0=(t-(x1& ~x3)-(x2&x3)- *(p0--))&0xffff; if (--i == 0) { if (--n == 0) break; i=(n == 2)?6:5; x3=(x3-p1[x2&0x3f])&0xffff; x2=(x2-p1[x1&0x3f])&0xffff; x1=(x1-p1[x0&0x3f])&0xffff; x0=(x0-p1[x3&0x3f])&0xffff; } } d[0]=(unsigned long)(x0&0xffff)|((unsigned long)(x1&0xffff)<<16L); d[1]=(unsigned long)(x2&0xffff)|((unsigned long)(x3&0xffff)<<16L); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rc2/rc2ofb64.c0000644000175000017500000001016112360020706020434 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "rc2_locl.h" /* The input and output encrypted as though 64bit ofb mode is being * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ void RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, RC2_KEY *schedule, unsigned char *ivec, int *num) { register unsigned long v0,v1,t; register int n= *num; register long l=length; unsigned char d[8]; register char *dp; unsigned long ti[2]; unsigned char *iv; int save=0; iv=(unsigned char *)ivec; c2l(iv,v0); c2l(iv,v1); ti[0]=v0; ti[1]=v1; dp=(char *)d; l2c(v0,dp); l2c(v1,dp); while (l--) { if (n == 0) { RC2_encrypt((unsigned long *)ti,schedule); dp=(char *)d; t=ti[0]; l2c(t,dp); t=ti[1]; l2c(t,dp); save++; } *(out++)= *(in++)^d[n]; n=(n+1)&0x07; } if (save) { v0=ti[0]; v1=ti[1]; iv=(unsigned char *)ivec; l2c(v0,iv); l2c(v1,iv); } t=v0=v1=ti[0]=ti[1]=0; *num=n; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/0000755000000000000000000000000012666635521020557 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509name.c0000644000175000017500000002543512360020706020504 0ustar /* $OpenBSD: x509name.c,v 1.11 2014/07/10 13:58:23 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len) { ASN1_OBJECT *obj; obj = OBJ_nid2obj(nid); if (obj == NULL) return (-1); return (X509_NAME_get_text_by_OBJ(name, obj, buf, len)); } int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, char *buf, int len) { int i; ASN1_STRING *data; i = X509_NAME_get_index_by_OBJ(name, obj, -1); if (i < 0) return (-1); data = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name, i)); i = (data->length > (len - 1)) ? (len - 1) : data->length; if (buf == NULL) return (data->length); memcpy(buf, data->data, i); buf[i] = '\0'; return (i); } int X509_NAME_entry_count(X509_NAME *name) { if (name == NULL) return (0); return (sk_X509_NAME_ENTRY_num(name->entries)); } int X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos) { ASN1_OBJECT *obj; obj = OBJ_nid2obj(nid); if (obj == NULL) return (-2); return (X509_NAME_get_index_by_OBJ(name, obj, lastpos)); } /* NOTE: you should be passsing -1, not 0 as lastpos */ int X509_NAME_get_index_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int lastpos) { int n; X509_NAME_ENTRY *ne; STACK_OF(X509_NAME_ENTRY) *sk; if (name == NULL) return (-1); if (lastpos < 0) lastpos = -1; sk = name->entries; n = sk_X509_NAME_ENTRY_num(sk); for (lastpos++; lastpos < n; lastpos++) { ne = sk_X509_NAME_ENTRY_value(sk, lastpos); if (OBJ_cmp(ne->object, obj) == 0) return (lastpos); } return (-1); } X509_NAME_ENTRY * X509_NAME_get_entry(X509_NAME *name, int loc) { if (name == NULL || sk_X509_NAME_ENTRY_num(name->entries) <= loc || loc < 0) return (NULL); else return (sk_X509_NAME_ENTRY_value(name->entries, loc)); } X509_NAME_ENTRY * X509_NAME_delete_entry(X509_NAME *name, int loc) { X509_NAME_ENTRY *ret; int i, n, set_prev, set_next; STACK_OF(X509_NAME_ENTRY) *sk; if (name == NULL || sk_X509_NAME_ENTRY_num(name->entries) <= loc || loc < 0) return (NULL); sk = name->entries; ret = sk_X509_NAME_ENTRY_delete(sk, loc); n = sk_X509_NAME_ENTRY_num(sk); name->modified = 1; if (loc == n) return (ret); /* else we need to fixup the set field */ if (loc != 0) set_prev = (sk_X509_NAME_ENTRY_value(sk, loc - 1))->set; else set_prev = ret->set - 1; set_next = sk_X509_NAME_ENTRY_value(sk, loc)->set; /* set_prev is the previous set * set is the current set * set_next is the following * prev 1 1 1 1 1 1 1 1 * set 1 1 2 2 * next 1 1 2 2 2 2 3 2 * so basically only if prev and next differ by 2, then * re-number down by 1 */ if (set_prev + 1 < set_next) for (i = loc; i < n; i++) sk_X509_NAME_ENTRY_value(sk, i)->set--; return (ret); } int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type, unsigned char *bytes, int len, int loc, int set) { X509_NAME_ENTRY *ne; int ret; ne = X509_NAME_ENTRY_create_by_OBJ(NULL, obj, type, bytes, len); if (!ne) return 0; ret = X509_NAME_add_entry(name, ne, loc, set); X509_NAME_ENTRY_free(ne); return ret; } int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, unsigned char *bytes, int len, int loc, int set) { X509_NAME_ENTRY *ne; int ret; ne = X509_NAME_ENTRY_create_by_NID(NULL, nid, type, bytes, len); if (!ne) return 0; ret = X509_NAME_add_entry(name, ne, loc, set); X509_NAME_ENTRY_free(ne); return ret; } int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, const unsigned char *bytes, int len, int loc, int set) { X509_NAME_ENTRY *ne; int ret; ne = X509_NAME_ENTRY_create_by_txt(NULL, field, type, bytes, len); if (!ne) return 0; ret = X509_NAME_add_entry(name, ne, loc, set); X509_NAME_ENTRY_free(ne); return ret; } /* if set is -1, append to previous set, 0 'a new one', and 1, * prepend to the guy we are about to stomp on. */ int X509_NAME_add_entry(X509_NAME *name, X509_NAME_ENTRY *ne, int loc, int set) { X509_NAME_ENTRY *new_name = NULL; int n, i, inc; STACK_OF(X509_NAME_ENTRY) *sk; if (name == NULL) return (0); sk = name->entries; n = sk_X509_NAME_ENTRY_num(sk); if (loc > n) loc = n; else if (loc < 0) loc = n; name->modified = 1; if (set == -1) { if (loc == 0) { set = 0; inc = 1; } else { set = sk_X509_NAME_ENTRY_value(sk, loc - 1)->set; inc = 0; } } else /* if (set >= 0) */ { if (loc >= n) { if (loc != 0) set = sk_X509_NAME_ENTRY_value(sk, loc - 1)->set + 1; else set = 0; } else set = sk_X509_NAME_ENTRY_value(sk, loc)->set; inc = (set == 0) ? 1 : 0; } if ((new_name = X509_NAME_ENTRY_dup(ne)) == NULL) goto err; new_name->set = set; if (!sk_X509_NAME_ENTRY_insert(sk, new_name, loc)) { X509err(X509_F_X509_NAME_ADD_ENTRY, ERR_R_MALLOC_FAILURE); goto err; } if (inc) { n = sk_X509_NAME_ENTRY_num(sk); for (i = loc + 1; i < n; i++) sk_X509_NAME_ENTRY_value(sk, i - 1)->set += 1; } return (1); err: if (new_name != NULL) X509_NAME_ENTRY_free(new_name); return (0); } X509_NAME_ENTRY * X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, const char *field, int type, const unsigned char *bytes, int len) { ASN1_OBJECT *obj; X509_NAME_ENTRY *nentry; obj = OBJ_txt2obj(field, 0); if (obj == NULL) { X509err(X509_F_X509_NAME_ENTRY_CREATE_BY_TXT, X509_R_INVALID_FIELD_NAME); ERR_asprintf_error_data("name=%s", field); return (NULL); } nentry = X509_NAME_ENTRY_create_by_OBJ(ne, obj, type, bytes, len); ASN1_OBJECT_free(obj); return nentry; } X509_NAME_ENTRY * X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, int type, unsigned char *bytes, int len) { ASN1_OBJECT *obj; X509_NAME_ENTRY *nentry; obj = OBJ_nid2obj(nid); if (obj == NULL) { X509err(X509_F_X509_NAME_ENTRY_CREATE_BY_NID, X509_R_UNKNOWN_NID); return (NULL); } nentry = X509_NAME_ENTRY_create_by_OBJ(ne, obj, type, bytes, len); ASN1_OBJECT_free(obj); return nentry; } X509_NAME_ENTRY * X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, ASN1_OBJECT *obj, int type, const unsigned char *bytes, int len) { X509_NAME_ENTRY *ret; if ((ne == NULL) || (*ne == NULL)) { if ((ret = X509_NAME_ENTRY_new()) == NULL) return (NULL); } else ret= *ne; if (!X509_NAME_ENTRY_set_object(ret, obj)) goto err; if (!X509_NAME_ENTRY_set_data(ret, type, bytes, len)) goto err; if ((ne != NULL) && (*ne == NULL)) *ne = ret; return (ret); err: if ((ne == NULL) || (ret != *ne)) X509_NAME_ENTRY_free(ret); return (NULL); } int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, ASN1_OBJECT *obj) { if ((ne == NULL) || (obj == NULL)) { X509err(X509_F_X509_NAME_ENTRY_SET_OBJECT, ERR_R_PASSED_NULL_PARAMETER); return (0); } ASN1_OBJECT_free(ne->object); ne->object = OBJ_dup(obj); return ((ne->object == NULL) ? 0 : 1); } int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, const unsigned char *bytes, int len) { int i; if ((ne == NULL) || ((bytes == NULL) && (len != 0))) return (0); if ((type > 0) && (type & MBSTRING_FLAG)) return ASN1_STRING_set_by_NID(&ne->value, bytes, len, type, OBJ_obj2nid(ne->object)) ? 1 : 0; if (len < 0) len = strlen((const char *)bytes); i = ASN1_STRING_set(ne->value, bytes, len); if (!i) return (0); if (type != V_ASN1_UNDEF) { if (type == V_ASN1_APP_CHOOSE) ne->value->type = ASN1_PRINTABLE_type(bytes, len); else ne->value->type = type; } return (1); } ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne) { if (ne == NULL) return (NULL); return (ne->object); } ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne) { if (ne == NULL) return (NULL); return (ne->value); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_vfy.c0000644000175000017500000015027512360020706020530 0ustar /* $OpenBSD: x509_vfy.c,v 1.33 2014/07/11 08:44:49 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "x509_lcl.h" /* CRL score values */ /* No unhandled critical extensions */ #define CRL_SCORE_NOCRITICAL 0x100 /* certificate is within CRL scope */ #define CRL_SCORE_SCOPE 0x080 /* CRL times valid */ #define CRL_SCORE_TIME 0x040 /* Issuer name matches certificate */ #define CRL_SCORE_ISSUER_NAME 0x020 /* If this score or above CRL is probably valid */ #define CRL_SCORE_VALID (CRL_SCORE_NOCRITICAL|CRL_SCORE_TIME|CRL_SCORE_SCOPE) /* CRL issuer is certificate issuer */ #define CRL_SCORE_ISSUER_CERT 0x018 /* CRL issuer is on certificate path */ #define CRL_SCORE_SAME_PATH 0x008 /* CRL issuer matches CRL AKID */ #define CRL_SCORE_AKID 0x004 /* Have a delta CRL with valid times */ #define CRL_SCORE_TIME_DELTA 0x002 static int null_callback(int ok, X509_STORE_CTX *e); static int check_issued(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); static X509 *find_issuer(X509_STORE_CTX *ctx, STACK_OF(X509) *sk, X509 *x); static int check_chain_extensions(X509_STORE_CTX *ctx); static int check_name_constraints(X509_STORE_CTX *ctx); static int check_trust(X509_STORE_CTX *ctx); static int check_revocation(X509_STORE_CTX *ctx); static int check_cert(X509_STORE_CTX *ctx); static int check_policy(X509_STORE_CTX *ctx); static int get_crl_score(X509_STORE_CTX *ctx, X509 **pissuer, unsigned int *preasons, X509_CRL *crl, X509 *x); static int get_crl_delta(X509_STORE_CTX *ctx, X509_CRL **pcrl, X509_CRL **pdcrl, X509 *x); static void get_delta_sk(X509_STORE_CTX *ctx, X509_CRL **dcrl, int *pcrl_score, X509_CRL *base, STACK_OF(X509_CRL) *crls); static void crl_akid_check(X509_STORE_CTX *ctx, X509_CRL *crl, X509 **pissuer, int *pcrl_score); static int crl_crldp_check(X509 *x, X509_CRL *crl, int crl_score, unsigned int *preasons); static int check_crl_path(X509_STORE_CTX *ctx, X509 *x); static int check_crl_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *cert_path, STACK_OF(X509) *crl_path); static int internal_verify(X509_STORE_CTX *ctx); static int null_callback(int ok, X509_STORE_CTX *e) { return ok; } #if 0 static int x509_subject_cmp(X509 **a, X509 **b) { return X509_subject_name_cmp(*a, *b); } #endif int X509_verify_cert(X509_STORE_CTX *ctx) { X509 *x, *xtmp, *chain_ss = NULL; int bad_chain = 0; X509_VERIFY_PARAM *param = ctx->param; int depth, i, ok = 0; int num; int (*cb)(int xok, X509_STORE_CTX *xctx); STACK_OF(X509) *sktmp = NULL; if (ctx->cert == NULL) { X509err(X509_F_X509_VERIFY_CERT, X509_R_NO_CERT_SET_FOR_US_TO_VERIFY); return -1; } cb = ctx->verify_cb; /* first we make sure the chain we are going to build is * present and that the first entry is in place */ if (ctx->chain == NULL) { if (((ctx->chain = sk_X509_new_null()) == NULL) || (!sk_X509_push(ctx->chain, ctx->cert))) { X509err(X509_F_X509_VERIFY_CERT, ERR_R_MALLOC_FAILURE); goto end; } CRYPTO_add(&ctx->cert->references, 1, CRYPTO_LOCK_X509); ctx->last_untrusted = 1; } /* We use a temporary STACK so we can chop and hack at it */ if (ctx->untrusted != NULL && (sktmp = sk_X509_dup(ctx->untrusted)) == NULL) { X509err(X509_F_X509_VERIFY_CERT, ERR_R_MALLOC_FAILURE); goto end; } num = sk_X509_num(ctx->chain); x = sk_X509_value(ctx->chain, num - 1); depth = param->depth; for (;;) { /* If we have enough, we break */ if (depth < num) break; /* FIXME: If this happens, we should take * note of it and, if appropriate, use the * X509_V_ERR_CERT_CHAIN_TOO_LONG error * code later. */ /* If we are self signed, we break */ if (ctx->check_issued(ctx, x, x)) break; /* If we were passed a cert chain, use it first */ if (ctx->untrusted != NULL) { xtmp = find_issuer(ctx, sktmp, x); if (xtmp != NULL) { if (!sk_X509_push(ctx->chain, xtmp)) { X509err(X509_F_X509_VERIFY_CERT, ERR_R_MALLOC_FAILURE); goto end; } CRYPTO_add(&xtmp->references, 1, CRYPTO_LOCK_X509); (void)sk_X509_delete_ptr(sktmp, xtmp); ctx->last_untrusted++; x = xtmp; num++; /* reparse the full chain for * the next one */ continue; } } break; } /* at this point, chain should contain a list of untrusted * certificates. We now need to add at least one trusted one, * if possible, otherwise we complain. */ /* Examine last certificate in chain and see if it * is self signed. */ i = sk_X509_num(ctx->chain); x = sk_X509_value(ctx->chain, i - 1); if (ctx->check_issued(ctx, x, x)) { /* we have a self signed certificate */ if (sk_X509_num(ctx->chain) == 1) { /* We have a single self signed certificate: see if * we can find it in the store. We must have an exact * match to avoid possible impersonation. */ ok = ctx->get_issuer(&xtmp, ctx, x); if ((ok <= 0) || X509_cmp(x, xtmp)) { ctx->error = X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT; ctx->current_cert = x; ctx->error_depth = i - 1; if (ok == 1) X509_free(xtmp); bad_chain = 1; ok = cb(0, ctx); if (!ok) goto end; } else { /* We have a match: replace certificate with store version * so we get any trust settings. */ X509_free(x); x = xtmp; (void)sk_X509_set(ctx->chain, i - 1, x); ctx->last_untrusted = 0; } } else { /* extract and save self signed certificate for later use */ chain_ss = sk_X509_pop(ctx->chain); ctx->last_untrusted--; num--; x = sk_X509_value(ctx->chain, num - 1); } } /* We now lookup certs from the certificate store */ for (;;) { /* If we have enough, we break */ if (depth < num) break; /* If we are self signed, we break */ if (ctx->check_issued(ctx, x, x)) break; ok = ctx->get_issuer(&xtmp, ctx, x); if (ok < 0) return ok; if (ok == 0) break; x = xtmp; if (!sk_X509_push(ctx->chain, x)) { X509_free(xtmp); X509err(X509_F_X509_VERIFY_CERT, ERR_R_MALLOC_FAILURE); return 0; } num++; } /* we now have our chain, lets check it... */ /* Is last certificate looked up self signed? */ if (!ctx->check_issued(ctx, x, x)) { if ((chain_ss == NULL) || !ctx->check_issued(ctx, x, chain_ss)) { if (ctx->last_untrusted >= num) ctx->error = X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY; else ctx->error = X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT; ctx->current_cert = x; } else { if (!sk_X509_push(ctx->chain, chain_ss)) { X509_free(chain_ss); X509err(X509_F_X509_VERIFY_CERT, ERR_R_MALLOC_FAILURE); return 0; } num++; ctx->last_untrusted = num; ctx->current_cert = chain_ss; ctx->error = X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN; chain_ss = NULL; } ctx->error_depth = num - 1; bad_chain = 1; ok = cb(0, ctx); if (!ok) goto end; } /* We have the chain complete: now we need to check its purpose */ ok = check_chain_extensions(ctx); if (!ok) goto end; /* Check name constraints */ ok = check_name_constraints(ctx); if (!ok) goto end; /* The chain extensions are OK: check trust */ if (param->trust > 0) ok = check_trust(ctx); if (!ok) goto end; /* We may as well copy down any DSA parameters that are required */ X509_get_pubkey_parameters(NULL, ctx->chain); /* Check revocation status: we do this after copying parameters * because they may be needed for CRL signature verification. */ ok = ctx->check_revocation(ctx); if (!ok) goto end; /* At this point, we have a chain and need to verify it */ if (ctx->verify != NULL) ok = ctx->verify(ctx); else ok = internal_verify(ctx); if (!ok) goto end; #ifndef OPENSSL_NO_RFC3779 /* RFC 3779 path validation, now that CRL check has been done */ ok = v3_asid_validate_path(ctx); if (!ok) goto end; ok = v3_addr_validate_path(ctx); if (!ok) goto end; #endif /* If we get this far evaluate policies */ if (!bad_chain && (ctx->param->flags & X509_V_FLAG_POLICY_CHECK)) ok = ctx->check_policy(ctx); if (!ok) goto end; if (0) { end: X509_get_pubkey_parameters(NULL, ctx->chain); } if (sktmp != NULL) sk_X509_free(sktmp); if (chain_ss != NULL) X509_free(chain_ss); return ok; } /* Given a STACK_OF(X509) find the issuer of cert (if any) */ static X509 * find_issuer(X509_STORE_CTX *ctx, STACK_OF(X509) *sk, X509 *x) { int i; X509 *issuer, *rv = NULL; for (i = 0; i < sk_X509_num(sk); i++) { issuer = sk_X509_value(sk, i); if (ctx->check_issued(ctx, x, issuer)) { rv = issuer; if (x509_check_cert_time(ctx, rv, 1)) break; } } return rv; } /* Given a possible certificate and issuer check them */ static int check_issued(X509_STORE_CTX *ctx, X509 *x, X509 *issuer) { int ret; ret = X509_check_issued(issuer, x); if (ret == X509_V_OK) return 1; /* If we haven't asked for issuer errors don't set ctx */ if (!(ctx->param->flags & X509_V_FLAG_CB_ISSUER_CHECK)) return 0; ctx->error = ret; ctx->current_cert = x; ctx->current_issuer = issuer; return ctx->verify_cb(0, ctx); } /* Alternative lookup method: look from a STACK stored in other_ctx */ static int get_issuer_sk(X509 **issuer, X509_STORE_CTX *ctx, X509 *x) { *issuer = find_issuer(ctx, ctx->other_ctx, x); if (*issuer) { CRYPTO_add(&(*issuer)->references, 1, CRYPTO_LOCK_X509); return 1; } else return 0; } /* Check a certificate chains extensions for consistency * with the supplied purpose */ static int check_chain_extensions(X509_STORE_CTX *ctx) { #ifdef OPENSSL_NO_CHAIN_VERIFY return 1; #else int i, ok = 0, must_be_ca, plen = 0; X509 *x; int (*cb)(int xok, X509_STORE_CTX *xctx); int proxy_path_length = 0; int purpose; int allow_proxy_certs; cb = ctx->verify_cb; /* must_be_ca can have 1 of 3 values: -1: we accept both CA and non-CA certificates, to allow direct use of self-signed certificates (which are marked as CA). 0: we only accept non-CA certificates. This is currently not used, but the possibility is present for future extensions. 1: we only accept CA certificates. This is currently used for all certificates in the chain except the leaf certificate. */ must_be_ca = -1; /* CRL path validation */ if (ctx->parent) { allow_proxy_certs = 0; purpose = X509_PURPOSE_CRL_SIGN; } else { allow_proxy_certs = !!(ctx->param->flags & X509_V_FLAG_ALLOW_PROXY_CERTS); /* A hack to keep people who don't want to modify their software happy */ if (issetugid() == 0 && getenv("OPENSSL_ALLOW_PROXY_CERTS")) allow_proxy_certs = 1; purpose = ctx->param->purpose; } /* Check all untrusted certificates */ for (i = 0; i < ctx->last_untrusted; i++) { int ret; x = sk_X509_value(ctx->chain, i); if (!(ctx->param->flags & X509_V_FLAG_IGNORE_CRITICAL) && (x->ex_flags & EXFLAG_CRITICAL)) { ctx->error = X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION; ctx->error_depth = i; ctx->current_cert = x; ok = cb(0, ctx); if (!ok) goto end; } if (!allow_proxy_certs && (x->ex_flags & EXFLAG_PROXY)) { ctx->error = X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED; ctx->error_depth = i; ctx->current_cert = x; ok = cb(0, ctx); if (!ok) goto end; } ret = X509_check_ca(x); switch (must_be_ca) { case -1: if ((ctx->param->flags & X509_V_FLAG_X509_STRICT) && (ret != 1) && (ret != 0)) { ret = 0; ctx->error = X509_V_ERR_INVALID_CA; } else ret = 1; break; case 0: if (ret != 0) { ret = 0; ctx->error = X509_V_ERR_INVALID_NON_CA; } else ret = 1; break; default: if ((ret == 0) || ((ctx->param->flags & X509_V_FLAG_X509_STRICT) && (ret != 1))) { ret = 0; ctx->error = X509_V_ERR_INVALID_CA; } else ret = 1; break; } if (ret == 0) { ctx->error_depth = i; ctx->current_cert = x; ok = cb(0, ctx); if (!ok) goto end; } if (ctx->param->purpose > 0) { ret = X509_check_purpose(x, purpose, must_be_ca > 0); if ((ret == 0) || ((ctx->param->flags & X509_V_FLAG_X509_STRICT) && (ret != 1))) { ctx->error = X509_V_ERR_INVALID_PURPOSE; ctx->error_depth = i; ctx->current_cert = x; ok = cb(0, ctx); if (!ok) goto end; } } /* Check pathlen if not self issued */ if ((i > 1) && !(x->ex_flags & EXFLAG_SI) && (x->ex_pathlen != -1) && (plen > (x->ex_pathlen + proxy_path_length + 1))) { ctx->error = X509_V_ERR_PATH_LENGTH_EXCEEDED; ctx->error_depth = i; ctx->current_cert = x; ok = cb(0, ctx); if (!ok) goto end; } /* Increment path length if not self issued */ if (!(x->ex_flags & EXFLAG_SI)) plen++; /* If this certificate is a proxy certificate, the next certificate must be another proxy certificate or a EE certificate. If not, the next certificate must be a CA certificate. */ if (x->ex_flags & EXFLAG_PROXY) { if (x->ex_pcpathlen != -1 && i > x->ex_pcpathlen) { ctx->error = X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED; ctx->error_depth = i; ctx->current_cert = x; ok = cb(0, ctx); if (!ok) goto end; } proxy_path_length++; must_be_ca = 0; } else must_be_ca = 1; } ok = 1; end: return ok; #endif } static int check_name_constraints(X509_STORE_CTX *ctx) { X509 *x; int i, j, rv; /* Check name constraints for all certificates */ for (i = sk_X509_num(ctx->chain) - 1; i >= 0; i--) { x = sk_X509_value(ctx->chain, i); /* Ignore self issued certs unless last in chain */ if (i && (x->ex_flags & EXFLAG_SI)) continue; /* Check against constraints for all certificates higher in * chain including trust anchor. Trust anchor not strictly * speaking needed but if it includes constraints it is to be * assumed it expects them to be obeyed. */ for (j = sk_X509_num(ctx->chain) - 1; j > i; j--) { NAME_CONSTRAINTS *nc = sk_X509_value(ctx->chain, j)->nc; if (nc) { rv = NAME_CONSTRAINTS_check(x, nc); if (rv != X509_V_OK) { ctx->error = rv; ctx->error_depth = i; ctx->current_cert = x; if (!ctx->verify_cb(0, ctx)) return 0; } } } } return 1; } static int check_trust(X509_STORE_CTX *ctx) { #ifdef OPENSSL_NO_CHAIN_VERIFY return 1; #else int i, ok; X509 *x; int (*cb)(int xok, X509_STORE_CTX *xctx); cb = ctx->verify_cb; /* For now just check the last certificate in the chain */ i = sk_X509_num(ctx->chain) - 1; x = sk_X509_value(ctx->chain, i); ok = X509_check_trust(x, ctx->param->trust, 0); if (ok == X509_TRUST_TRUSTED) return 1; ctx->error_depth = i; ctx->current_cert = x; if (ok == X509_TRUST_REJECTED) ctx->error = X509_V_ERR_CERT_REJECTED; else ctx->error = X509_V_ERR_CERT_UNTRUSTED; ok = cb(0, ctx); return ok; #endif } static int check_revocation(X509_STORE_CTX *ctx) { int i, last, ok; if (!(ctx->param->flags & X509_V_FLAG_CRL_CHECK)) return 1; if (ctx->param->flags & X509_V_FLAG_CRL_CHECK_ALL) last = sk_X509_num(ctx->chain) - 1; else { /* If checking CRL paths this isn't the EE certificate */ if (ctx->parent) return 1; last = 0; } for (i = 0; i <= last; i++) { ctx->error_depth = i; ok = check_cert(ctx); if (!ok) return ok; } return 1; } static int check_cert(X509_STORE_CTX *ctx) { X509_CRL *crl = NULL, *dcrl = NULL; X509 *x; int ok, cnum; unsigned int last_reasons; cnum = ctx->error_depth; x = sk_X509_value(ctx->chain, cnum); ctx->current_cert = x; ctx->current_issuer = NULL; ctx->current_crl_score = 0; ctx->current_reasons = 0; while (ctx->current_reasons != CRLDP_ALL_REASONS) { last_reasons = ctx->current_reasons; /* Try to retrieve relevant CRL */ if (ctx->get_crl) ok = ctx->get_crl(ctx, &crl, x); else ok = get_crl_delta(ctx, &crl, &dcrl, x); /* If error looking up CRL, nothing we can do except * notify callback */ if (!ok) { ctx->error = X509_V_ERR_UNABLE_TO_GET_CRL; ok = ctx->verify_cb(0, ctx); goto err; } ctx->current_crl = crl; ok = ctx->check_crl(ctx, crl); if (!ok) goto err; if (dcrl) { ok = ctx->check_crl(ctx, dcrl); if (!ok) goto err; ok = ctx->cert_crl(ctx, dcrl, x); if (!ok) goto err; } else ok = 1; /* Don't look in full CRL if delta reason is removefromCRL */ if (ok != 2) { ok = ctx->cert_crl(ctx, crl, x); if (!ok) goto err; } X509_CRL_free(crl); X509_CRL_free(dcrl); crl = NULL; dcrl = NULL; /* If reasons not updated we wont get anywhere by * another iteration, so exit loop. */ if (last_reasons == ctx->current_reasons) { ctx->error = X509_V_ERR_UNABLE_TO_GET_CRL; ok = ctx->verify_cb(0, ctx); goto err; } } err: X509_CRL_free(crl); X509_CRL_free(dcrl); ctx->current_crl = NULL; return ok; } /* Check CRL times against values in X509_STORE_CTX */ static int check_crl_time(X509_STORE_CTX *ctx, X509_CRL *crl, int notify) { time_t *ptime; int i; if (notify) ctx->current_crl = crl; if (ctx->param->flags & X509_V_FLAG_USE_CHECK_TIME) ptime = &ctx->param->check_time; else ptime = NULL; i = X509_cmp_time(X509_CRL_get_lastUpdate(crl), ptime); if (i == 0) { if (!notify) return 0; ctx->error = X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD; if (!ctx->verify_cb(0, ctx)) return 0; } if (i > 0) { if (!notify) return 0; ctx->error = X509_V_ERR_CRL_NOT_YET_VALID; if (!ctx->verify_cb(0, ctx)) return 0; } if (X509_CRL_get_nextUpdate(crl)) { i = X509_cmp_time(X509_CRL_get_nextUpdate(crl), ptime); if (i == 0) { if (!notify) return 0; ctx->error = X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD; if (!ctx->verify_cb(0, ctx)) return 0; } /* Ignore expiry of base CRL is delta is valid */ if ((i < 0) && !(ctx->current_crl_score & CRL_SCORE_TIME_DELTA)) { if (!notify) return 0; ctx->error = X509_V_ERR_CRL_HAS_EXPIRED; if (!ctx->verify_cb(0, ctx)) return 0; } } if (notify) ctx->current_crl = NULL; return 1; } static int get_crl_sk(X509_STORE_CTX *ctx, X509_CRL **pcrl, X509_CRL **pdcrl, X509 **pissuer, int *pscore, unsigned int *preasons, STACK_OF(X509_CRL) *crls) { int i, crl_score, best_score = *pscore; unsigned int reasons, best_reasons = 0; X509 *x = ctx->current_cert; X509_CRL *crl, *best_crl = NULL; X509 *crl_issuer = NULL, *best_crl_issuer = NULL; for (i = 0; i < sk_X509_CRL_num(crls); i++) { crl = sk_X509_CRL_value(crls, i); reasons = *preasons; crl_score = get_crl_score(ctx, &crl_issuer, &reasons, crl, x); if (crl_score > best_score) { best_crl = crl; best_crl_issuer = crl_issuer; best_score = crl_score; best_reasons = reasons; } } if (best_crl) { if (*pcrl) X509_CRL_free(*pcrl); *pcrl = best_crl; *pissuer = best_crl_issuer; *pscore = best_score; *preasons = best_reasons; CRYPTO_add(&best_crl->references, 1, CRYPTO_LOCK_X509_CRL); if (*pdcrl) { X509_CRL_free(*pdcrl); *pdcrl = NULL; } get_delta_sk(ctx, pdcrl, pscore, best_crl, crls); } if (best_score >= CRL_SCORE_VALID) return 1; return 0; } /* Compare two CRL extensions for delta checking purposes. They should be * both present or both absent. If both present all fields must be identical. */ static int crl_extension_match(X509_CRL *a, X509_CRL *b, int nid) { ASN1_OCTET_STRING *exta, *extb; int i; i = X509_CRL_get_ext_by_NID(a, nid, -1); if (i >= 0) { /* Can't have multiple occurrences */ if (X509_CRL_get_ext_by_NID(a, nid, i) != -1) return 0; exta = X509_EXTENSION_get_data(X509_CRL_get_ext(a, i)); } else exta = NULL; i = X509_CRL_get_ext_by_NID(b, nid, -1); if (i >= 0) { if (X509_CRL_get_ext_by_NID(b, nid, i) != -1) return 0; extb = X509_EXTENSION_get_data(X509_CRL_get_ext(b, i)); } else extb = NULL; if (!exta && !extb) return 1; if (!exta || !extb) return 0; if (ASN1_OCTET_STRING_cmp(exta, extb)) return 0; return 1; } /* See if a base and delta are compatible */ static int check_delta_base(X509_CRL *delta, X509_CRL *base) { /* Delta CRL must be a delta */ if (!delta->base_crl_number) return 0; /* Base must have a CRL number */ if (!base->crl_number) return 0; /* Issuer names must match */ if (X509_NAME_cmp(X509_CRL_get_issuer(base), X509_CRL_get_issuer(delta))) return 0; /* AKID and IDP must match */ if (!crl_extension_match(delta, base, NID_authority_key_identifier)) return 0; if (!crl_extension_match(delta, base, NID_issuing_distribution_point)) return 0; /* Delta CRL base number must not exceed Full CRL number. */ if (ASN1_INTEGER_cmp(delta->base_crl_number, base->crl_number) > 0) return 0; /* Delta CRL number must exceed full CRL number */ if (ASN1_INTEGER_cmp(delta->crl_number, base->crl_number) > 0) return 1; return 0; } /* For a given base CRL find a delta... maybe extend to delta scoring * or retrieve a chain of deltas... */ static void get_delta_sk(X509_STORE_CTX *ctx, X509_CRL **dcrl, int *pscore, X509_CRL *base, STACK_OF(X509_CRL) *crls) { X509_CRL *delta; int i; if (!(ctx->param->flags & X509_V_FLAG_USE_DELTAS)) return; if (!((ctx->current_cert->ex_flags | base->flags) & EXFLAG_FRESHEST)) return; for (i = 0; i < sk_X509_CRL_num(crls); i++) { delta = sk_X509_CRL_value(crls, i); if (check_delta_base(delta, base)) { if (check_crl_time(ctx, delta, 0)) *pscore |= CRL_SCORE_TIME_DELTA; CRYPTO_add(&delta->references, 1, CRYPTO_LOCK_X509_CRL); *dcrl = delta; return; } } *dcrl = NULL; } /* For a given CRL return how suitable it is for the supplied certificate 'x'. * The return value is a mask of several criteria. * If the issuer is not the certificate issuer this is returned in *pissuer. * The reasons mask is also used to determine if the CRL is suitable: if * no new reasons the CRL is rejected, otherwise reasons is updated. */ static int get_crl_score(X509_STORE_CTX *ctx, X509 **pissuer, unsigned int *preasons, X509_CRL *crl, X509 *x) { int crl_score = 0; unsigned int tmp_reasons = *preasons, crl_reasons; /* First see if we can reject CRL straight away */ /* Invalid IDP cannot be processed */ if (crl->idp_flags & IDP_INVALID) return 0; /* Reason codes or indirect CRLs need extended CRL support */ if (!(ctx->param->flags & X509_V_FLAG_EXTENDED_CRL_SUPPORT)) { if (crl->idp_flags & (IDP_INDIRECT | IDP_REASONS)) return 0; } else if (crl->idp_flags & IDP_REASONS) { /* If no new reasons reject */ if (!(crl->idp_reasons & ~tmp_reasons)) return 0; } /* Don't process deltas at this stage */ else if (crl->base_crl_number) return 0; /* If issuer name doesn't match certificate need indirect CRL */ if (X509_NAME_cmp(X509_get_issuer_name(x), X509_CRL_get_issuer(crl))) { if (!(crl->idp_flags & IDP_INDIRECT)) return 0; } else crl_score |= CRL_SCORE_ISSUER_NAME; if (!(crl->flags & EXFLAG_CRITICAL)) crl_score |= CRL_SCORE_NOCRITICAL; /* Check expiry */ if (check_crl_time(ctx, crl, 0)) crl_score |= CRL_SCORE_TIME; /* Check authority key ID and locate certificate issuer */ crl_akid_check(ctx, crl, pissuer, &crl_score); /* If we can't locate certificate issuer at this point forget it */ if (!(crl_score & CRL_SCORE_AKID)) return 0; /* Check cert for matching CRL distribution points */ if (crl_crldp_check(x, crl, crl_score, &crl_reasons)) { /* If no new reasons reject */ if (!(crl_reasons & ~tmp_reasons)) return 0; tmp_reasons |= crl_reasons; crl_score |= CRL_SCORE_SCOPE; } *preasons = tmp_reasons; return crl_score; } static void crl_akid_check(X509_STORE_CTX *ctx, X509_CRL *crl, X509 **pissuer, int *pcrl_score) { X509 *crl_issuer = NULL; X509_NAME *cnm = X509_CRL_get_issuer(crl); int cidx = ctx->error_depth; int i; if (cidx != sk_X509_num(ctx->chain) - 1) cidx++; crl_issuer = sk_X509_value(ctx->chain, cidx); if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) { if (*pcrl_score & CRL_SCORE_ISSUER_NAME) { *pcrl_score |= CRL_SCORE_AKID|CRL_SCORE_ISSUER_CERT; *pissuer = crl_issuer; return; } } for (cidx++; cidx < sk_X509_num(ctx->chain); cidx++) { crl_issuer = sk_X509_value(ctx->chain, cidx); if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm)) continue; if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) { *pcrl_score |= CRL_SCORE_AKID|CRL_SCORE_SAME_PATH; *pissuer = crl_issuer; return; } } /* Anything else needs extended CRL support */ if (!(ctx->param->flags & X509_V_FLAG_EXTENDED_CRL_SUPPORT)) return; /* Otherwise the CRL issuer is not on the path. Look for it in the * set of untrusted certificates. */ for (i = 0; i < sk_X509_num(ctx->untrusted); i++) { crl_issuer = sk_X509_value(ctx->untrusted, i); if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm)) continue; if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) { *pissuer = crl_issuer; *pcrl_score |= CRL_SCORE_AKID; return; } } } /* Check the path of a CRL issuer certificate. This creates a new * X509_STORE_CTX and populates it with most of the parameters from the * parent. This could be optimised somewhat since a lot of path checking * will be duplicated by the parent, but this will rarely be used in * practice. */ static int check_crl_path(X509_STORE_CTX *ctx, X509 *x) { X509_STORE_CTX crl_ctx; int ret; /* Don't allow recursive CRL path validation */ if (ctx->parent) return 0; if (!X509_STORE_CTX_init(&crl_ctx, ctx->ctx, x, ctx->untrusted)) return -1; crl_ctx.crls = ctx->crls; /* Copy verify params across */ X509_STORE_CTX_set0_param(&crl_ctx, ctx->param); crl_ctx.parent = ctx; crl_ctx.verify_cb = ctx->verify_cb; /* Verify CRL issuer */ ret = X509_verify_cert(&crl_ctx); if (ret <= 0) goto err; /* Check chain is acceptable */ ret = check_crl_chain(ctx, ctx->chain, crl_ctx.chain); err: X509_STORE_CTX_cleanup(&crl_ctx); return ret; } /* RFC3280 says nothing about the relationship between CRL path * and certificate path, which could lead to situations where a * certificate could be revoked or validated by a CA not authorised * to do so. RFC5280 is more strict and states that the two paths must * end in the same trust anchor, though some discussions remain... * until this is resolved we use the RFC5280 version */ static int check_crl_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *cert_path, STACK_OF(X509) *crl_path) { X509 *cert_ta, *crl_ta; cert_ta = sk_X509_value(cert_path, sk_X509_num(cert_path) - 1); crl_ta = sk_X509_value(crl_path, sk_X509_num(crl_path) - 1); if (!X509_cmp(cert_ta, crl_ta)) return 1; return 0; } /* Check for match between two dist point names: three separate cases. * 1. Both are relative names and compare X509_NAME types. * 2. One full, one relative. Compare X509_NAME to GENERAL_NAMES. * 3. Both are full names and compare two GENERAL_NAMES. * 4. One is NULL: automatic match. */ static int idp_check_dp(DIST_POINT_NAME *a, DIST_POINT_NAME *b) { X509_NAME *nm = NULL; GENERAL_NAMES *gens = NULL; GENERAL_NAME *gena, *genb; int i, j; if (!a || !b) return 1; if (a->type == 1) { if (!a->dpname) return 0; /* Case 1: two X509_NAME */ if (b->type == 1) { if (!b->dpname) return 0; if (!X509_NAME_cmp(a->dpname, b->dpname)) return 1; else return 0; } /* Case 2: set name and GENERAL_NAMES appropriately */ nm = a->dpname; gens = b->name.fullname; } else if (b->type == 1) { if (!b->dpname) return 0; /* Case 2: set name and GENERAL_NAMES appropriately */ gens = a->name.fullname; nm = b->dpname; } /* Handle case 2 with one GENERAL_NAMES and one X509_NAME */ if (nm) { for (i = 0; i < sk_GENERAL_NAME_num(gens); i++) { gena = sk_GENERAL_NAME_value(gens, i); if (gena->type != GEN_DIRNAME) continue; if (!X509_NAME_cmp(nm, gena->d.directoryName)) return 1; } return 0; } /* Else case 3: two GENERAL_NAMES */ for (i = 0; i < sk_GENERAL_NAME_num(a->name.fullname); i++) { gena = sk_GENERAL_NAME_value(a->name.fullname, i); for (j = 0; j < sk_GENERAL_NAME_num(b->name.fullname); j++) { genb = sk_GENERAL_NAME_value(b->name.fullname, j); if (!GENERAL_NAME_cmp(gena, genb)) return 1; } } return 0; } static int crldp_check_crlissuer(DIST_POINT *dp, X509_CRL *crl, int crl_score) { int i; X509_NAME *nm = X509_CRL_get_issuer(crl); /* If no CRLissuer return is successful iff don't need a match */ if (!dp->CRLissuer) return !!(crl_score & CRL_SCORE_ISSUER_NAME); for (i = 0; i < sk_GENERAL_NAME_num(dp->CRLissuer); i++) { GENERAL_NAME *gen = sk_GENERAL_NAME_value(dp->CRLissuer, i); if (gen->type != GEN_DIRNAME) continue; if (!X509_NAME_cmp(gen->d.directoryName, nm)) return 1; } return 0; } /* Check CRLDP and IDP */ static int crl_crldp_check(X509 *x, X509_CRL *crl, int crl_score, unsigned int *preasons) { int i; if (crl->idp_flags & IDP_ONLYATTR) return 0; if (x->ex_flags & EXFLAG_CA) { if (crl->idp_flags & IDP_ONLYUSER) return 0; } else { if (crl->idp_flags & IDP_ONLYCA) return 0; } *preasons = crl->idp_reasons; for (i = 0; i < sk_DIST_POINT_num(x->crldp); i++) { DIST_POINT *dp = sk_DIST_POINT_value(x->crldp, i); if (crldp_check_crlissuer(dp, crl, crl_score)) { if (!crl->idp || idp_check_dp(dp->distpoint, crl->idp->distpoint)) { *preasons &= dp->dp_reasons; return 1; } } } if ((!crl->idp || !crl->idp->distpoint) && (crl_score & CRL_SCORE_ISSUER_NAME)) return 1; return 0; } /* Retrieve CRL corresponding to current certificate. * If deltas enabled try to find a delta CRL too */ static int get_crl_delta(X509_STORE_CTX *ctx, X509_CRL **pcrl, X509_CRL **pdcrl, X509 *x) { int ok; X509 *issuer = NULL; int crl_score = 0; unsigned int reasons; X509_CRL *crl = NULL, *dcrl = NULL; STACK_OF(X509_CRL) *skcrl; X509_NAME *nm = X509_get_issuer_name(x); reasons = ctx->current_reasons; ok = get_crl_sk(ctx, &crl, &dcrl, &issuer, &crl_score, &reasons, ctx->crls); if (ok) goto done; /* Lookup CRLs from store */ skcrl = ctx->lookup_crls(ctx, nm); /* If no CRLs found and a near match from get_crl_sk use that */ if (!skcrl && crl) goto done; get_crl_sk(ctx, &crl, &dcrl, &issuer, &crl_score, &reasons, skcrl); sk_X509_CRL_pop_free(skcrl, X509_CRL_free); done: /* If we got any kind of CRL use it and return success */ if (crl) { ctx->current_issuer = issuer; ctx->current_crl_score = crl_score; ctx->current_reasons = reasons; *pcrl = crl; *pdcrl = dcrl; return 1; } return 0; } /* Check CRL validity */ static int check_crl(X509_STORE_CTX *ctx, X509_CRL *crl) { X509 *issuer = NULL; EVP_PKEY *ikey = NULL; int ok = 0, chnum, cnum; cnum = ctx->error_depth; chnum = sk_X509_num(ctx->chain) - 1; /* if we have an alternative CRL issuer cert use that */ if (ctx->current_issuer) { issuer = ctx->current_issuer; } else if (cnum < chnum) { /* Else find CRL issuer: if not last certificate then issuer * is next certificate in chain. */ issuer = sk_X509_value(ctx->chain, cnum + 1); } else { issuer = sk_X509_value(ctx->chain, chnum); /* If not self signed, can't check signature */ if (!ctx->check_issued(ctx, issuer, issuer)) { ctx->error = X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER; ok = ctx->verify_cb(0, ctx); if (!ok) goto err; } } if (issuer) { /* Skip most tests for deltas because they have already * been done */ if (!crl->base_crl_number) { /* Check for cRLSign bit if keyUsage present */ if ((issuer->ex_flags & EXFLAG_KUSAGE) && !(issuer->ex_kusage & KU_CRL_SIGN)) { ctx->error = X509_V_ERR_KEYUSAGE_NO_CRL_SIGN; ok = ctx->verify_cb(0, ctx); if (!ok) goto err; } if (!(ctx->current_crl_score & CRL_SCORE_SCOPE)) { ctx->error = X509_V_ERR_DIFFERENT_CRL_SCOPE; ok = ctx->verify_cb(0, ctx); if (!ok) goto err; } if (!(ctx->current_crl_score & CRL_SCORE_SAME_PATH)) { if (check_crl_path(ctx, ctx->current_issuer) <= 0) { ctx->error = X509_V_ERR_CRL_PATH_VALIDATION_ERROR; ok = ctx->verify_cb(0, ctx); if (!ok) goto err; } } if (crl->idp_flags & IDP_INVALID) { ctx->error = X509_V_ERR_INVALID_EXTENSION; ok = ctx->verify_cb(0, ctx); if (!ok) goto err; } } if (!(ctx->current_crl_score & CRL_SCORE_TIME)) { ok = check_crl_time(ctx, crl, 1); if (!ok) goto err; } /* Attempt to get issuer certificate public key */ ikey = X509_get_pubkey(issuer); if (!ikey) { ctx->error = X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY; ok = ctx->verify_cb(0, ctx); if (!ok) goto err; } else { /* Verify CRL signature */ if (X509_CRL_verify(crl, ikey) <= 0) { ctx->error = X509_V_ERR_CRL_SIGNATURE_FAILURE; ok = ctx->verify_cb(0, ctx); if (!ok) goto err; } } } ok = 1; err: EVP_PKEY_free(ikey); return ok; } /* Check certificate against CRL */ static int cert_crl(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x) { int ok; X509_REVOKED *rev; /* The rules changed for this... previously if a CRL contained * unhandled critical extensions it could still be used to indicate * a certificate was revoked. This has since been changed since * critical extension can change the meaning of CRL entries. */ if (!(ctx->param->flags & X509_V_FLAG_IGNORE_CRITICAL) && (crl->flags & EXFLAG_CRITICAL)) { ctx->error = X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION; ok = ctx->verify_cb(0, ctx); if (!ok) return 0; } /* Look for serial number of certificate in CRL * If found make sure reason is not removeFromCRL. */ if (X509_CRL_get0_by_cert(crl, &rev, x)) { if (rev->reason == CRL_REASON_REMOVE_FROM_CRL) return 2; ctx->error = X509_V_ERR_CERT_REVOKED; ok = ctx->verify_cb(0, ctx); if (!ok) return 0; } return 1; } static int check_policy(X509_STORE_CTX *ctx) { int ret; if (ctx->parent) return 1; ret = X509_policy_check(&ctx->tree, &ctx->explicit_policy, ctx->chain, ctx->param->policies, ctx->param->flags); if (ret == 0) { X509err(X509_F_CHECK_POLICY, ERR_R_MALLOC_FAILURE); return 0; } /* Invalid or inconsistent extensions */ if (ret == -1) { /* Locate certificates with bad extensions and notify * callback. */ X509 *x; int i; for (i = 1; i < sk_X509_num(ctx->chain); i++) { x = sk_X509_value(ctx->chain, i); if (!(x->ex_flags & EXFLAG_INVALID_POLICY)) continue; ctx->current_cert = x; ctx->error = X509_V_ERR_INVALID_POLICY_EXTENSION; if (!ctx->verify_cb(0, ctx)) return 0; } return 1; } if (ret == -2) { ctx->current_cert = NULL; ctx->error = X509_V_ERR_NO_EXPLICIT_POLICY; return ctx->verify_cb(0, ctx); } if (ctx->param->flags & X509_V_FLAG_NOTIFY_POLICY) { ctx->current_cert = NULL; ctx->error = X509_V_OK; if (!ctx->verify_cb(2, ctx)) return 0; } return 1; } int x509_check_cert_time(X509_STORE_CTX *ctx, X509 *x, int quiet) { time_t *ptime; int i; if (ctx->param->flags & X509_V_FLAG_USE_CHECK_TIME) ptime = &ctx->param->check_time; else ptime = NULL; i = X509_cmp_time(X509_get_notBefore(x), ptime); if (i == 0) { if (quiet) return 0; ctx->error = X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD; ctx->current_cert = x; if (!ctx->verify_cb(0, ctx)) return 0; } if (i > 0) { if (quiet) return 0; ctx->error = X509_V_ERR_CERT_NOT_YET_VALID; ctx->current_cert = x; if (!ctx->verify_cb(0, ctx)) return 0; } i = X509_cmp_time(X509_get_notAfter(x), ptime); if (i == 0) { if (quiet) return 0; ctx->error = X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD; ctx->current_cert = x; if (!ctx->verify_cb(0, ctx)) return 0; } if (i < 0) { if (quiet) return 0; ctx->error = X509_V_ERR_CERT_HAS_EXPIRED; ctx->current_cert = x; if (!ctx->verify_cb(0, ctx)) return 0; } return 1; } static int internal_verify(X509_STORE_CTX *ctx) { int ok = 0, n; X509 *xs, *xi; EVP_PKEY *pkey = NULL; int (*cb)(int xok, X509_STORE_CTX *xctx); cb = ctx->verify_cb; n = sk_X509_num(ctx->chain); ctx->error_depth = n - 1; n--; xi = sk_X509_value(ctx->chain, n); if (ctx->check_issued(ctx, xi, xi)) xs = xi; else { if (n <= 0) { ctx->error = X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE; ctx->current_cert = xi; ok = cb(0, ctx); goto end; } else { n--; ctx->error_depth = n; xs = sk_X509_value(ctx->chain, n); } } /* ctx->error=0; not needed */ while (n >= 0) { ctx->error_depth = n; /* Skip signature check for self signed certificates unless * explicitly asked for. It doesn't add any security and * just wastes time. */ if (!xs->valid && (xs != xi || (ctx->param->flags & X509_V_FLAG_CHECK_SS_SIGNATURE))) { if ((pkey = X509_get_pubkey(xi)) == NULL) { ctx->error = X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY; ctx->current_cert = xi; ok = (*cb)(0, ctx); if (!ok) goto end; } else if (X509_verify(xs, pkey) <= 0) { ctx->error = X509_V_ERR_CERT_SIGNATURE_FAILURE; ctx->current_cert = xs; ok = (*cb)(0, ctx); if (!ok) { EVP_PKEY_free(pkey); goto end; } } EVP_PKEY_free(pkey); pkey = NULL; } xs->valid = 1; ok = x509_check_cert_time(ctx, xs, 0); if (!ok) goto end; /* The last error (if any) is still in the error value */ ctx->current_issuer = xi; ctx->current_cert = xs; ok = (*cb)(1, ctx); if (!ok) goto end; n--; if (n >= 0) { xi = xs; xs = sk_X509_value(ctx->chain, n); } } ok = 1; end: return ok; } int X509_cmp_current_time(const ASN1_TIME *ctm) { return X509_cmp_time(ctm, NULL); } int X509_cmp_time(const ASN1_TIME *ctm, time_t *cmp_time) { char *str; ASN1_TIME atm; long offset; char buff1[24], buff2[24], *p; int i, j; p = buff1; i = ctm->length; str = (char *)ctm->data; if (ctm->type == V_ASN1_UTCTIME) { if ((i < 11) || (i > 17)) return 0; memcpy(p, str, 10); p += 10; str += 10; } else { if (i < 13) return 0; memcpy(p, str, 12); p += 12; str += 12; } if ((*str == 'Z') || (*str == '-') || (*str == '+')) { *(p++) = '0'; *(p++) = '0'; } else { *(p++) = *(str++); *(p++) = *(str++); /* Skip any fractional seconds... */ if (*str == '.') { str++; while ((*str >= '0') && (*str <= '9')) str++; } } *(p++) = 'Z'; *(p++) = '\0'; if (*str == 'Z') offset = 0; else { if ((*str != '+') && (*str != '-')) return 0; offset = ((str[1] - '0') * 10 + (str[2] - '0')) * 60; offset += (str[3] - '0') * 10 + (str[4] - '0'); if (*str == '-') offset = -offset; } atm.type = ctm->type; atm.flags = 0; atm.length = sizeof(buff2); atm.data = (unsigned char *)buff2; if (X509_time_adj(&atm, offset * 60, cmp_time) == NULL) return 0; if (ctm->type == V_ASN1_UTCTIME) { i = (buff1[0] - '0') * 10 + (buff1[1] - '0'); if (i < 50) i += 100; /* cf. RFC 2459 */ j = (buff2[0] - '0') * 10 + (buff2[1] - '0'); if (j < 50) j += 100; if (i < j) return -1; if (i > j) return 1; } i = strcmp(buff1, buff2); if (i == 0) /* wait a second then return younger :-) */ return -1; else return i; } ASN1_TIME * X509_gmtime_adj(ASN1_TIME *s, long adj) { return X509_time_adj(s, adj, NULL); } ASN1_TIME * X509_time_adj(ASN1_TIME *s, long offset_sec, time_t *in_tm) { return X509_time_adj_ex(s, 0, offset_sec, in_tm); } ASN1_TIME * X509_time_adj_ex(ASN1_TIME *s, int offset_day, long offset_sec, time_t *in_tm) { time_t t; if (in_tm) t = *in_tm; else time(&t); if (s && !(s->flags & ASN1_STRING_FLAG_MSTRING)) { if (s->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_adj(s, t, offset_day, offset_sec); if (s->type == V_ASN1_GENERALIZEDTIME) return ASN1_GENERALIZEDTIME_adj(s, t, offset_day, offset_sec); } return ASN1_TIME_adj(s, t, offset_day, offset_sec); } int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain) { EVP_PKEY *ktmp = NULL, *ktmp2; int i, j; if ((pkey != NULL) && !EVP_PKEY_missing_parameters(pkey)) return 1; for (i = 0; i < sk_X509_num(chain); i++) { ktmp = X509_get_pubkey(sk_X509_value(chain, i)); if (ktmp == NULL) { X509err(X509_F_X509_GET_PUBKEY_PARAMETERS, X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY); return 0; } if (!EVP_PKEY_missing_parameters(ktmp)) break; else { EVP_PKEY_free(ktmp); ktmp = NULL; } } if (ktmp == NULL) { X509err(X509_F_X509_GET_PUBKEY_PARAMETERS, X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN); return 0; } /* first, populate the other certs */ for (j = i - 1; j >= 0; j--) { ktmp2 = X509_get_pubkey(sk_X509_value(chain, j)); EVP_PKEY_copy_parameters(ktmp2, ktmp); EVP_PKEY_free(ktmp2); } if (pkey != NULL) EVP_PKEY_copy_parameters(pkey, ktmp); EVP_PKEY_free(ktmp); return 1; } int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { /* This function is (usually) called only once, by * SSL_get_ex_data_X509_STORE_CTX_idx (ssl/ssl_cert.c). */ return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE_CTX, argl, argp, new_func, dup_func, free_func); } int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data) { return CRYPTO_set_ex_data(&ctx->ex_data, idx, data); } void * X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx) { return CRYPTO_get_ex_data(&ctx->ex_data, idx); } int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx) { return ctx->error; } void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int err) { ctx->error = err; } int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx) { return ctx->error_depth; } X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx) { return ctx->current_cert; } STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx) { return ctx->chain; } STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx) { int i; X509 *x; STACK_OF(X509) *chain; if (!ctx->chain || !(chain = sk_X509_dup(ctx->chain))) return NULL; for (i = 0; i < sk_X509_num(chain); i++) { x = sk_X509_value(chain, i); CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509); } return chain; } X509 * X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx) { return ctx->current_issuer; } X509_CRL * X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx) { return ctx->current_crl; } X509_STORE_CTX * X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx) { return ctx->parent; } void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x) { ctx->cert = x; } void X509_STORE_CTX_set_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *sk) { ctx->untrusted = sk; } void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk) { ctx->crls = sk; } int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose) { return X509_STORE_CTX_purpose_inherit(ctx, 0, purpose, 0); } int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust) { return X509_STORE_CTX_purpose_inherit(ctx, 0, 0, trust); } /* This function is used to set the X509_STORE_CTX purpose and trust * values. This is intended to be used when another structure has its * own trust and purpose values which (if set) will be inherited by * the ctx. If they aren't set then we will usually have a default * purpose in mind which should then be used to set the trust value. * An example of this is SSL use: an SSL structure will have its own * purpose and trust settings which the application can set: if they * aren't set then we use the default of SSL client/server. */ int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, int purpose, int trust) { int idx; /* If purpose not set use default */ if (!purpose) purpose = def_purpose; /* If we have a purpose then check it is valid */ if (purpose) { X509_PURPOSE *ptmp; idx = X509_PURPOSE_get_by_id(purpose); if (idx == -1) { X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT, X509_R_UNKNOWN_PURPOSE_ID); return 0; } ptmp = X509_PURPOSE_get0(idx); if (ptmp->trust == X509_TRUST_DEFAULT) { idx = X509_PURPOSE_get_by_id(def_purpose); if (idx == -1) { X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT, X509_R_UNKNOWN_PURPOSE_ID); return 0; } ptmp = X509_PURPOSE_get0(idx); } /* If trust not set then get from purpose default */ if (!trust) trust = ptmp->trust; } if (trust) { idx = X509_TRUST_get_by_id(trust); if (idx == -1) { X509err(X509_F_X509_STORE_CTX_PURPOSE_INHERIT, X509_R_UNKNOWN_TRUST_ID); return 0; } } if (purpose && !ctx->param->purpose) ctx->param->purpose = purpose; if (trust && !ctx->param->trust) ctx->param->trust = trust; return 1; } X509_STORE_CTX * X509_STORE_CTX_new(void) { X509_STORE_CTX *ctx; ctx = calloc(1, sizeof(X509_STORE_CTX)); if (!ctx) { X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE); return NULL; } return ctx; } void X509_STORE_CTX_free(X509_STORE_CTX *ctx) { X509_STORE_CTX_cleanup(ctx); free(ctx); } int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509, STACK_OF(X509) *chain) { int ret = 1; ctx->ctx = store; ctx->current_method = 0; ctx->cert = x509; ctx->untrusted = chain; ctx->crls = NULL; ctx->last_untrusted = 0; ctx->other_ctx = NULL; ctx->valid = 0; ctx->chain = NULL; ctx->error = 0; ctx->explicit_policy = 0; ctx->error_depth = 0; ctx->current_cert = NULL; ctx->current_issuer = NULL; ctx->current_crl = NULL; ctx->current_crl_score = 0; ctx->current_reasons = 0; ctx->tree = NULL; ctx->parent = NULL; ctx->param = X509_VERIFY_PARAM_new(); if (!ctx->param) { X509err(X509_F_X509_STORE_CTX_INIT, ERR_R_MALLOC_FAILURE); return 0; } /* Inherit callbacks and flags from X509_STORE if not set * use defaults. */ if (store) ret = X509_VERIFY_PARAM_inherit(ctx->param, store->param); else ctx->param->inh_flags |= X509_VP_FLAG_DEFAULT|X509_VP_FLAG_ONCE; if (store) { ctx->verify_cb = store->verify_cb; ctx->cleanup = store->cleanup; } else ctx->cleanup = 0; if (ret) ret = X509_VERIFY_PARAM_inherit(ctx->param, X509_VERIFY_PARAM_lookup("default")); if (ret == 0) { X509err(X509_F_X509_STORE_CTX_INIT, ERR_R_MALLOC_FAILURE); return 0; } if (store && store->check_issued) ctx->check_issued = store->check_issued; else ctx->check_issued = check_issued; if (store && store->get_issuer) ctx->get_issuer = store->get_issuer; else ctx->get_issuer = X509_STORE_CTX_get1_issuer; if (store && store->verify_cb) ctx->verify_cb = store->verify_cb; else ctx->verify_cb = null_callback; if (store && store->verify) ctx->verify = store->verify; else ctx->verify = internal_verify; if (store && store->check_revocation) ctx->check_revocation = store->check_revocation; else ctx->check_revocation = check_revocation; if (store && store->get_crl) ctx->get_crl = store->get_crl; else ctx->get_crl = NULL; if (store && store->check_crl) ctx->check_crl = store->check_crl; else ctx->check_crl = check_crl; if (store && store->cert_crl) ctx->cert_crl = store->cert_crl; else ctx->cert_crl = cert_crl; if (store && store->lookup_certs) ctx->lookup_certs = store->lookup_certs; else ctx->lookup_certs = X509_STORE_get1_certs; if (store && store->lookup_crls) ctx->lookup_crls = store->lookup_crls; else ctx->lookup_crls = X509_STORE_get1_crls; ctx->check_policy = check_policy; /* This memset() can't make any sense anyway, so it's removed. As * X509_STORE_CTX_cleanup does a proper "free" on the ex_data, we put a * corresponding "new" here and remove this bogus initialisation. */ /* memset(&(ctx->ex_data),0,sizeof(CRYPTO_EX_DATA)); */ if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE_CTX, ctx, &(ctx->ex_data))) { free(ctx); X509err(X509_F_X509_STORE_CTX_INIT, ERR_R_MALLOC_FAILURE); return 0; } return 1; } /* Set alternative lookup method: just a STACK of trusted certificates. * This avoids X509_STORE nastiness where it isn't needed. */ void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk) { ctx->other_ctx = sk; ctx->get_issuer = get_issuer_sk; } void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx) { if (ctx->cleanup) ctx->cleanup(ctx); if (ctx->param != NULL) { if (ctx->parent == NULL) X509_VERIFY_PARAM_free(ctx->param); ctx->param = NULL; } if (ctx->tree != NULL) { X509_policy_tree_free(ctx->tree); ctx->tree = NULL; } if (ctx->chain != NULL) { sk_X509_pop_free(ctx->chain, X509_free); ctx->chain = NULL; } CRYPTO_free_ex_data(CRYPTO_EX_INDEX_X509_STORE_CTX, ctx, &(ctx->ex_data)); memset(&ctx->ex_data, 0, sizeof(CRYPTO_EX_DATA)); } void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth) { X509_VERIFY_PARAM_set_depth(ctx->param, depth); } void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags) { X509_VERIFY_PARAM_set_flags(ctx->param, flags); } void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, time_t t) { X509_VERIFY_PARAM_set_time(ctx->param, t); } void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, int (*verify_cb)(int, X509_STORE_CTX *)) { ctx->verify_cb = verify_cb; } X509_POLICY_TREE * X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx) { return ctx->tree; } int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx) { return ctx->explicit_policy; } int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name) { const X509_VERIFY_PARAM *param; param = X509_VERIFY_PARAM_lookup(name); if (!param) return 0; return X509_VERIFY_PARAM_inherit(ctx->param, param); } X509_VERIFY_PARAM * X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx) { return ctx->param; } void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param) { if (ctx->param) X509_VERIFY_PARAM_free(ctx->param); ctx->param = param; } IMPLEMENT_STACK_OF(X509) IMPLEMENT_ASN1_SET_OF(X509) IMPLEMENT_STACK_OF(X509_NAME) IMPLEMENT_STACK_OF(X509_ATTRIBUTE) IMPLEMENT_ASN1_SET_OF(X509_ATTRIBUTE) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_obj.c0000644000175000017500000001307112360020706020466 0ustar /* $OpenBSD: x509_obj.c,v 1.15 2014/07/10 13:58:23 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include char * X509_NAME_oneline(X509_NAME *a, char *buf, int len) { X509_NAME_ENTRY *ne; int i; int n, lold, l, l1, l2, num, j, type; const char *s; char *p; unsigned char *q; BUF_MEM *b = NULL; static const char hex[17] = "0123456789ABCDEF"; int gs_doit[4]; char tmp_buf[80]; if (buf == NULL) { if ((b = BUF_MEM_new()) == NULL) goto err; if (!BUF_MEM_grow(b, 200)) goto err; b->data[0] = '\0'; len = 200; } if (a == NULL) { if (b) { buf = b->data; free(b); } strlcpy(buf, "NO X509_NAME", len); return buf; } len--; /* space for '\0' */ l = 0; for (i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) { ne = sk_X509_NAME_ENTRY_value(a->entries, i); n = OBJ_obj2nid(ne->object); if ((n == NID_undef) || ((s = OBJ_nid2sn(n)) == NULL)) { i2t_ASN1_OBJECT(tmp_buf, sizeof(tmp_buf), ne->object); s = tmp_buf; } l1 = strlen(s); type = ne->value->type; num = ne->value->length; q = ne->value->data; if ((type == V_ASN1_GENERALSTRING) && ((num % 4) == 0)) { gs_doit[0] = gs_doit[1] = gs_doit[2] = gs_doit[3] = 0; for (j = 0; j < num; j++) if (q[j] != 0) gs_doit[j & 3] = 1; if (gs_doit[0]|gs_doit[1]|gs_doit[2]) gs_doit[0] = gs_doit[1] = gs_doit[2] = gs_doit[3] = 1; else { gs_doit[0] = gs_doit[1] = gs_doit[2] = 0; gs_doit[3] = 1; } } else gs_doit[0] = gs_doit[1] = gs_doit[2] = gs_doit[3] = 1; for (l2 = j=0; j < num; j++) { if (!gs_doit[j&3]) continue; l2++; if ((q[j] < ' ') || (q[j] > '~')) l2 += 3; } lold = l; l += 1 + l1 + 1 + l2; if (b != NULL) { if (!BUF_MEM_grow(b, l + 1)) goto err; p = &(b->data[lold]); } else if (l > len) { break; } else p = &(buf[lold]); *(p++) = '/'; memcpy(p, s, l1); p += l1; *(p++) = '='; q = ne->value->data; for (j = 0; j < num; j++) { if (!gs_doit[j & 3]) continue; n = q[j]; if ((n < ' ') || (n > '~')) { *(p++) = '\\'; *(p++) = 'x'; *(p++) = hex[(n >> 4) & 0x0f]; *(p++) = hex[n & 0x0f]; } else *(p++) = n; } *p = '\0'; } if (b != NULL) { p = b->data; free(b); } else p = buf; if (i == 0) *p = '\0'; return (p); err: X509err(X509_F_X509_NAME_ONELINE, ERR_R_MALLOC_FAILURE); if (b != NULL) BUF_MEM_free(b); return (NULL); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509type.c0000644000175000017500000001064412360020706020541 0ustar /* $OpenBSD: x509type.c,v 1.10 2014/06/12 15:49:31 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include int X509_certificate_type(X509 *x, EVP_PKEY *pkey) { EVP_PKEY *pk; int ret = 0, i; if (x == NULL) return (0); if (pkey == NULL) pk = X509_get_pubkey(x); else pk = pkey; if (pk == NULL) return (0); switch (pk->type) { case EVP_PKEY_RSA: ret = EVP_PK_RSA|EVP_PKT_SIGN; /* if (!sign only extension) */ ret |= EVP_PKT_ENC; break; case EVP_PKEY_DSA: ret = EVP_PK_DSA|EVP_PKT_SIGN; break; case EVP_PKEY_EC: ret = EVP_PK_EC|EVP_PKT_SIGN|EVP_PKT_EXCH; break; case EVP_PKEY_DH: ret = EVP_PK_DH|EVP_PKT_EXCH; break; case NID_id_GostR3410_94: case NID_id_GostR3410_2001: ret = EVP_PKT_EXCH|EVP_PKT_SIGN; break; default: break; } i = OBJ_obj2nid(x->sig_alg->algorithm); if (i && OBJ_find_sigid_algs(i, NULL, &i)) { switch (i) { case NID_rsaEncryption: case NID_rsa: ret |= EVP_PKS_RSA; break; case NID_dsa: case NID_dsa_2: ret |= EVP_PKS_DSA; break; case NID_X9_62_id_ecPublicKey: ret |= EVP_PKS_EC; break; default: break; } } if (EVP_PKEY_size(pk) <= 1024/8)/* /8 because it's 1024 bits we look for, not bytes */ ret |= EVP_PKT_EXP; if (pkey == NULL) EVP_PKEY_free(pk); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_d2.c0000644000175000017500000001041012360020706020213 0ustar /* $OpenBSD: x509_d2.c,v 1.8 2014/06/12 15:49:31 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include int X509_STORE_set_default_paths(X509_STORE *ctx) { X509_LOOKUP *lookup; lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file()); if (lookup == NULL) return (0); X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT); lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir()); if (lookup == NULL) return (0); X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT); /* clear any errors */ ERR_clear_error(); return (1); } int X509_STORE_load_locations(X509_STORE *ctx, const char *file, const char *path) { X509_LOOKUP *lookup; if (file != NULL) { lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file()); if (lookup == NULL) return (0); if (X509_LOOKUP_load_file(lookup, file, X509_FILETYPE_PEM) != 1) return (0); } if (path != NULL) { lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir()); if (lookup == NULL) return (0); if (X509_LOOKUP_add_dir(lookup, path, X509_FILETYPE_PEM) != 1) return (0); } if ((path == NULL) && (file == NULL)) return (0); return (1); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_v3.c0000644000175000017500000001733712360020706020255 0ustar /* $OpenBSD: x509_v3.c,v 1.9 2014/06/12 15:49:31 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x) { if (x == NULL) return (0); return (sk_X509_EXTENSION_num(x)); } int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, int nid, int lastpos) { ASN1_OBJECT *obj; obj = OBJ_nid2obj(nid); if (obj == NULL) return (-2); return (X509v3_get_ext_by_OBJ(x, obj, lastpos)); } int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *sk, ASN1_OBJECT *obj, int lastpos) { int n; X509_EXTENSION *ex; if (sk == NULL) return (-1); lastpos++; if (lastpos < 0) lastpos = 0; n = sk_X509_EXTENSION_num(sk); for (; lastpos < n; lastpos++) { ex = sk_X509_EXTENSION_value(sk, lastpos); if (OBJ_cmp(ex->object, obj) == 0) return (lastpos); } return (-1); } int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *sk, int crit, int lastpos) { int n; X509_EXTENSION *ex; if (sk == NULL) return (-1); lastpos++; if (lastpos < 0) lastpos = 0; n = sk_X509_EXTENSION_num(sk); for (; lastpos < n; lastpos++) { ex = sk_X509_EXTENSION_value(sk, lastpos); if (((ex->critical > 0) && crit) || ((ex->critical <= 0) && !crit)) return (lastpos); } return (-1); } X509_EXTENSION * X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc) { if (x == NULL || sk_X509_EXTENSION_num(x) <= loc || loc < 0) return NULL; else return sk_X509_EXTENSION_value(x, loc); } X509_EXTENSION * X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc) { X509_EXTENSION *ret; if (x == NULL || sk_X509_EXTENSION_num(x) <= loc || loc < 0) return (NULL); ret = sk_X509_EXTENSION_delete(x, loc); return (ret); } STACK_OF(X509_EXTENSION) * X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, X509_EXTENSION *ex, int loc) { X509_EXTENSION *new_ex = NULL; int n; STACK_OF(X509_EXTENSION) *sk = NULL; if (x == NULL) { X509err(X509_F_X509V3_ADD_EXT, ERR_R_PASSED_NULL_PARAMETER); goto err2; } if (*x == NULL) { if ((sk = sk_X509_EXTENSION_new_null()) == NULL) goto err; } else sk= *x; n = sk_X509_EXTENSION_num(sk); if (loc > n) loc = n; else if (loc < 0) loc = n; if ((new_ex = X509_EXTENSION_dup(ex)) == NULL) goto err2; if (!sk_X509_EXTENSION_insert(sk, new_ex, loc)) goto err; if (*x == NULL) *x = sk; return (sk); err: X509err(X509_F_X509V3_ADD_EXT, ERR_R_MALLOC_FAILURE); err2: if (new_ex != NULL) X509_EXTENSION_free(new_ex); if (sk != NULL) sk_X509_EXTENSION_free(sk); return (NULL); } X509_EXTENSION * X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, int nid, int crit, ASN1_OCTET_STRING *data) { ASN1_OBJECT *obj; X509_EXTENSION *ret; obj = OBJ_nid2obj(nid); if (obj == NULL) { X509err(X509_F_X509_EXTENSION_CREATE_BY_NID, X509_R_UNKNOWN_NID); return (NULL); } ret = X509_EXTENSION_create_by_OBJ(ex, obj, crit, data); if (ret == NULL) ASN1_OBJECT_free(obj); return (ret); } X509_EXTENSION * X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, ASN1_OBJECT *obj, int crit, ASN1_OCTET_STRING *data) { X509_EXTENSION *ret; if ((ex == NULL) || (*ex == NULL)) { if ((ret = X509_EXTENSION_new()) == NULL) { X509err(X509_F_X509_EXTENSION_CREATE_BY_OBJ, ERR_R_MALLOC_FAILURE); return (NULL); } } else ret= *ex; if (!X509_EXTENSION_set_object(ret, obj)) goto err; if (!X509_EXTENSION_set_critical(ret, crit)) goto err; if (!X509_EXTENSION_set_data(ret, data)) goto err; if ((ex != NULL) && (*ex == NULL)) *ex = ret; return (ret); err: if ((ex == NULL) || (ret != *ex)) X509_EXTENSION_free(ret); return (NULL); } int X509_EXTENSION_set_object(X509_EXTENSION *ex, ASN1_OBJECT *obj) { if ((ex == NULL) || (obj == NULL)) return (0); ASN1_OBJECT_free(ex->object); ex->object = OBJ_dup(obj); return (1); } int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit) { if (ex == NULL) return (0); ex->critical = (crit) ? 0xFF : -1; return (1); } int X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data) { int i; if (ex == NULL) return (0); i = M_ASN1_OCTET_STRING_set(ex->value, data->data, data->length); if (!i) return (0); return (1); } ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex) { if (ex == NULL) return (NULL); return (ex->object); } ASN1_OCTET_STRING * X509_EXTENSION_get_data(X509_EXTENSION *ex) { if (ex == NULL) return (NULL); return (ex->value); } int X509_EXTENSION_get_critical(X509_EXTENSION *ex) { if (ex == NULL) return (0); if (ex->critical > 0) return 1; return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_lcl.h0000644000175000017500000000536212360020706020477 0ustar /* x509_lcl.h */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2013. */ /* ==================================================================== * Copyright (c) 2013 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ int x509_check_cert_time(X509_STORE_CTX *ctx, X509 *x, int quiet); deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509rset.c0000644000175000017500000000741112360020706020533 0ustar /* $OpenBSD: x509rset.c,v 1.5 2014/06/12 15:49:31 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include int X509_REQ_set_version(X509_REQ *x, long version) { if (x == NULL) return (0); return (ASN1_INTEGER_set(x->req_info->version, version)); } int X509_REQ_set_subject_name(X509_REQ *x, X509_NAME *name) { if ((x == NULL) || (x->req_info == NULL)) return (0); return (X509_NAME_set(&x->req_info->subject, name)); } int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey) { if ((x == NULL) || (x->req_info == NULL)) return (0); return (X509_PUBKEY_set(&x->req_info->pubkey, pkey)); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_def.c0000644000175000017500000000725112360020706020455 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "cryptlib.h" #include #include const char * X509_get_default_private_dir(void) { return (X509_PRIVATE_DIR); } const char * X509_get_default_cert_area(void) { return (X509_CERT_AREA); } const char * X509_get_default_cert_dir(void) { return (X509_CERT_DIR); } const char * X509_get_default_cert_file(void) { return (X509_CERT_FILE); } const char * X509_get_default_cert_dir_env(void) { return (X509_CERT_DIR_EVP); } const char * X509_get_default_cert_file_env(void) { return (X509_CERT_FILE_EVP); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_err.c0000644000175000017500000002012612360020706020503 0ustar /* $OpenBSD: x509_err.c,v 1.11 2014/06/12 15:49:31 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_X509,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_X509,0,reason) static ERR_STRING_DATA X509_str_functs[] = { {ERR_FUNC(X509_F_ADD_CERT_DIR), "ADD_CERT_DIR"}, {ERR_FUNC(X509_F_BY_FILE_CTRL), "BY_FILE_CTRL"}, {ERR_FUNC(X509_F_CHECK_POLICY), "CHECK_POLICY"}, {ERR_FUNC(X509_F_DIR_CTRL), "DIR_CTRL"}, {ERR_FUNC(X509_F_GET_CERT_BY_SUBJECT), "GET_CERT_BY_SUBJECT"}, {ERR_FUNC(X509_F_NETSCAPE_SPKI_B64_DECODE), "NETSCAPE_SPKI_b64_decode"}, {ERR_FUNC(X509_F_NETSCAPE_SPKI_B64_ENCODE), "NETSCAPE_SPKI_b64_encode"}, {ERR_FUNC(X509_F_X509AT_ADD1_ATTR), "X509at_add1_attr"}, {ERR_FUNC(X509_F_X509V3_ADD_EXT), "X509v3_add_ext"}, {ERR_FUNC(X509_F_X509_ATTRIBUTE_CREATE_BY_NID), "X509_ATTRIBUTE_create_by_NID"}, {ERR_FUNC(X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ), "X509_ATTRIBUTE_create_by_OBJ"}, {ERR_FUNC(X509_F_X509_ATTRIBUTE_CREATE_BY_TXT), "X509_ATTRIBUTE_create_by_txt"}, {ERR_FUNC(X509_F_X509_ATTRIBUTE_GET0_DATA), "X509_ATTRIBUTE_get0_data"}, {ERR_FUNC(X509_F_X509_ATTRIBUTE_SET1_DATA), "X509_ATTRIBUTE_set1_data"}, {ERR_FUNC(X509_F_X509_CHECK_PRIVATE_KEY), "X509_check_private_key"}, {ERR_FUNC(X509_F_X509_CRL_PRINT_FP), "X509_CRL_print_fp"}, {ERR_FUNC(X509_F_X509_EXTENSION_CREATE_BY_NID), "X509_EXTENSION_create_by_NID"}, {ERR_FUNC(X509_F_X509_EXTENSION_CREATE_BY_OBJ), "X509_EXTENSION_create_by_OBJ"}, {ERR_FUNC(X509_F_X509_GET_PUBKEY_PARAMETERS), "X509_get_pubkey_parameters"}, {ERR_FUNC(X509_F_X509_LOAD_CERT_CRL_FILE), "X509_load_cert_crl_file"}, {ERR_FUNC(X509_F_X509_LOAD_CERT_FILE), "X509_load_cert_file"}, {ERR_FUNC(X509_F_X509_LOAD_CRL_FILE), "X509_load_crl_file"}, {ERR_FUNC(X509_F_X509_NAME_ADD_ENTRY), "X509_NAME_add_entry"}, {ERR_FUNC(X509_F_X509_NAME_ENTRY_CREATE_BY_NID), "X509_NAME_ENTRY_create_by_NID"}, {ERR_FUNC(X509_F_X509_NAME_ENTRY_CREATE_BY_TXT), "X509_NAME_ENTRY_create_by_txt"}, {ERR_FUNC(X509_F_X509_NAME_ENTRY_SET_OBJECT), "X509_NAME_ENTRY_set_object"}, {ERR_FUNC(X509_F_X509_NAME_ONELINE), "X509_NAME_oneline"}, {ERR_FUNC(X509_F_X509_NAME_PRINT), "X509_NAME_print"}, {ERR_FUNC(X509_F_X509_PRINT_EX_FP), "X509_print_ex_fp"}, {ERR_FUNC(X509_F_X509_PUBKEY_GET), "X509_PUBKEY_get"}, {ERR_FUNC(X509_F_X509_PUBKEY_SET), "X509_PUBKEY_set"}, {ERR_FUNC(X509_F_X509_REQ_CHECK_PRIVATE_KEY), "X509_REQ_check_private_key"}, {ERR_FUNC(X509_F_X509_REQ_PRINT_EX), "X509_REQ_print_ex"}, {ERR_FUNC(X509_F_X509_REQ_PRINT_FP), "X509_REQ_print_fp"}, {ERR_FUNC(X509_F_X509_REQ_TO_X509), "X509_REQ_to_X509"}, {ERR_FUNC(X509_F_X509_STORE_ADD_CERT), "X509_STORE_add_cert"}, {ERR_FUNC(X509_F_X509_STORE_ADD_CRL), "X509_STORE_add_crl"}, {ERR_FUNC(X509_F_X509_STORE_CTX_GET1_ISSUER), "X509_STORE_CTX_get1_issuer"}, {ERR_FUNC(X509_F_X509_STORE_CTX_INIT), "X509_STORE_CTX_init"}, {ERR_FUNC(X509_F_X509_STORE_CTX_NEW), "X509_STORE_CTX_new"}, {ERR_FUNC(X509_F_X509_STORE_CTX_PURPOSE_INHERIT), "X509_STORE_CTX_purpose_inherit"}, {ERR_FUNC(X509_F_X509_TO_X509_REQ), "X509_to_X509_REQ"}, {ERR_FUNC(X509_F_X509_TRUST_ADD), "X509_TRUST_add"}, {ERR_FUNC(X509_F_X509_TRUST_SET), "X509_TRUST_set"}, {ERR_FUNC(X509_F_X509_VERIFY_CERT), "X509_verify_cert"}, {0, NULL} }; static ERR_STRING_DATA X509_str_reasons[] = { {ERR_REASON(X509_R_BAD_X509_FILETYPE) , "bad x509 filetype"}, {ERR_REASON(X509_R_BASE64_DECODE_ERROR) , "base64 decode error"}, {ERR_REASON(X509_R_CANT_CHECK_DH_KEY) , "cant check dh key"}, {ERR_REASON(X509_R_CERT_ALREADY_IN_HASH_TABLE), "cert already in hash table"}, {ERR_REASON(X509_R_ERR_ASN1_LIB) , "err asn1 lib"}, {ERR_REASON(X509_R_INVALID_DIRECTORY) , "invalid directory"}, {ERR_REASON(X509_R_INVALID_FIELD_NAME) , "invalid field name"}, {ERR_REASON(X509_R_INVALID_TRUST) , "invalid trust"}, {ERR_REASON(X509_R_KEY_TYPE_MISMATCH) , "key type mismatch"}, {ERR_REASON(X509_R_KEY_VALUES_MISMATCH) , "key values mismatch"}, {ERR_REASON(X509_R_LOADING_CERT_DIR) , "loading cert dir"}, {ERR_REASON(X509_R_LOADING_DEFAULTS) , "loading defaults"}, {ERR_REASON(X509_R_METHOD_NOT_SUPPORTED) , "method not supported"}, {ERR_REASON(X509_R_NO_CERT_SET_FOR_US_TO_VERIFY), "no cert set for us to verify"}, {ERR_REASON(X509_R_PUBLIC_KEY_DECODE_ERROR), "public key decode error"}, {ERR_REASON(X509_R_PUBLIC_KEY_ENCODE_ERROR), "public key encode error"}, {ERR_REASON(X509_R_SHOULD_RETRY) , "should retry"}, {ERR_REASON(X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN), "unable to find parameters in chain"}, {ERR_REASON(X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY), "unable to get certs public key"}, {ERR_REASON(X509_R_UNKNOWN_KEY_TYPE) , "unknown key type"}, {ERR_REASON(X509_R_UNKNOWN_NID) , "unknown nid"}, {ERR_REASON(X509_R_UNKNOWN_PURPOSE_ID) , "unknown purpose id"}, {ERR_REASON(X509_R_UNKNOWN_TRUST_ID) , "unknown trust id"}, {ERR_REASON(X509_R_UNSUPPORTED_ALGORITHM), "unsupported algorithm"}, {ERR_REASON(X509_R_WRONG_LOOKUP_TYPE) , "wrong lookup type"}, {ERR_REASON(X509_R_WRONG_TYPE) , "wrong type"}, {0, NULL} }; #endif void ERR_load_X509_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(X509_str_functs[0].error) == NULL) { ERR_load_strings(0, X509_str_functs); ERR_load_strings(0, X509_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_att.c0000644000175000017500000002523212360020706020506 0ustar /* $OpenBSD: x509_att.c,v 1.10 2014/07/03 21:21:11 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x) { return sk_X509_ATTRIBUTE_num(x); } int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid, int lastpos) { ASN1_OBJECT *obj; obj = OBJ_nid2obj(nid); if (obj == NULL) return (-2); return (X509at_get_attr_by_OBJ(x, obj, lastpos)); } int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj, int lastpos) { int n; X509_ATTRIBUTE *ex; if (sk == NULL) return (-1); lastpos++; if (lastpos < 0) lastpos = 0; n = sk_X509_ATTRIBUTE_num(sk); for (; lastpos < n; lastpos++) { ex = sk_X509_ATTRIBUTE_value(sk, lastpos); if (OBJ_cmp(ex->object, obj) == 0) return (lastpos); } return (-1); } X509_ATTRIBUTE * X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc) { if (x == NULL || sk_X509_ATTRIBUTE_num(x) <= loc || loc < 0) return NULL; else return sk_X509_ATTRIBUTE_value(x, loc); } X509_ATTRIBUTE * X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc) { X509_ATTRIBUTE *ret; if (x == NULL || sk_X509_ATTRIBUTE_num(x) <= loc || loc < 0) return (NULL); ret = sk_X509_ATTRIBUTE_delete(x, loc); return (ret); } STACK_OF(X509_ATTRIBUTE) * X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x, X509_ATTRIBUTE *attr) { X509_ATTRIBUTE *new_attr = NULL; STACK_OF(X509_ATTRIBUTE) *sk = NULL; if (x == NULL) { X509err(X509_F_X509AT_ADD1_ATTR, ERR_R_PASSED_NULL_PARAMETER); goto err2; } if (*x == NULL) { if ((sk = sk_X509_ATTRIBUTE_new_null()) == NULL) goto err; } else sk= *x; if ((new_attr = X509_ATTRIBUTE_dup(attr)) == NULL) goto err2; if (!sk_X509_ATTRIBUTE_push(sk, new_attr)) goto err; if (*x == NULL) *x = sk; return (sk); err: X509err(X509_F_X509AT_ADD1_ATTR, ERR_R_MALLOC_FAILURE); err2: if (new_attr != NULL) X509_ATTRIBUTE_free(new_attr); if (sk != NULL) sk_X509_ATTRIBUTE_free(sk); return (NULL); } STACK_OF(X509_ATTRIBUTE) * X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x, const ASN1_OBJECT *obj, int type, const unsigned char *bytes, int len) { X509_ATTRIBUTE *attr; STACK_OF(X509_ATTRIBUTE) *ret; attr = X509_ATTRIBUTE_create_by_OBJ(NULL, obj, type, bytes, len); if (!attr) return 0; ret = X509at_add1_attr(x, attr); X509_ATTRIBUTE_free(attr); return ret; } STACK_OF(X509_ATTRIBUTE) * X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x, int nid, int type, const unsigned char *bytes, int len) { X509_ATTRIBUTE *attr; STACK_OF(X509_ATTRIBUTE) *ret; attr = X509_ATTRIBUTE_create_by_NID(NULL, nid, type, bytes, len); if (!attr) return 0; ret = X509at_add1_attr(x, attr); X509_ATTRIBUTE_free(attr); return ret; } STACK_OF(X509_ATTRIBUTE) * X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x, const char *attrname, int type, const unsigned char *bytes, int len) { X509_ATTRIBUTE *attr; STACK_OF(X509_ATTRIBUTE) *ret; attr = X509_ATTRIBUTE_create_by_txt(NULL, attrname, type, bytes, len); if (!attr) return 0; ret = X509at_add1_attr(x, attr); X509_ATTRIBUTE_free(attr); return ret; } void * X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x, ASN1_OBJECT *obj, int lastpos, int type) { int i; X509_ATTRIBUTE *at; i = X509at_get_attr_by_OBJ(x, obj, lastpos); if (i == -1) return NULL; if ((lastpos <= -2) && (X509at_get_attr_by_OBJ(x, obj, i) != -1)) return NULL; at = X509at_get_attr(x, i); if (lastpos <= -3 && (X509_ATTRIBUTE_count(at) != 1)) return NULL; return X509_ATTRIBUTE_get0_data(at, 0, type, NULL); } X509_ATTRIBUTE * X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, int atrtype, const void *data, int len) { ASN1_OBJECT *obj; X509_ATTRIBUTE *ret; obj = OBJ_nid2obj(nid); if (obj == NULL) { X509err(X509_F_X509_ATTRIBUTE_CREATE_BY_NID, X509_R_UNKNOWN_NID); return (NULL); } ret = X509_ATTRIBUTE_create_by_OBJ(attr, obj, atrtype, data, len); if (ret == NULL) ASN1_OBJECT_free(obj); return (ret); } X509_ATTRIBUTE * X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, const ASN1_OBJECT *obj, int atrtype, const void *data, int len) { X509_ATTRIBUTE *ret; if ((attr == NULL) || (*attr == NULL)) { if ((ret = X509_ATTRIBUTE_new()) == NULL) { X509err(X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ, ERR_R_MALLOC_FAILURE); return (NULL); } } else ret= *attr; if (!X509_ATTRIBUTE_set1_object(ret, obj)) goto err; if (!X509_ATTRIBUTE_set1_data(ret, atrtype, data, len)) goto err; if ((attr != NULL) && (*attr == NULL)) *attr = ret; return (ret); err: if ((attr == NULL) || (ret != *attr)) X509_ATTRIBUTE_free(ret); return (NULL); } X509_ATTRIBUTE * X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, const char *atrname, int type, const unsigned char *bytes, int len) { ASN1_OBJECT *obj; X509_ATTRIBUTE *nattr; obj = OBJ_txt2obj(atrname, 0); if (obj == NULL) { X509err(X509_F_X509_ATTRIBUTE_CREATE_BY_TXT, X509_R_INVALID_FIELD_NAME); ERR_asprintf_error_data("name=%s", atrname); return (NULL); } nattr = X509_ATTRIBUTE_create_by_OBJ(attr, obj, type, bytes, len); ASN1_OBJECT_free(obj); return nattr; } int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj) { if ((attr == NULL) || (obj == NULL)) return (0); ASN1_OBJECT_free(attr->object); attr->object = OBJ_dup(obj); return (1); } int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len) { ASN1_TYPE *ttmp = NULL; ASN1_STRING *stmp = NULL; int atype = 0; if (!attr) return 0; if (attrtype & MBSTRING_FLAG) { stmp = ASN1_STRING_set_by_NID(NULL, data, len, attrtype, OBJ_obj2nid(attr->object)); if (!stmp) { X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_ASN1_LIB); return 0; } atype = stmp->type; } else if (len != -1){ if (!(stmp = ASN1_STRING_type_new(attrtype))) goto err; if (!ASN1_STRING_set(stmp, data, len)) goto err; atype = attrtype; } if (!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err; attr->single = 0; /* This is a bit naughty because the attribute should really have * at least one value but some types use and zero length SET and * require this. */ if (attrtype == 0) { ASN1_STRING_free(stmp); return 1; } if (!(ttmp = ASN1_TYPE_new())) goto err; if ((len == -1) && !(attrtype & MBSTRING_FLAG)) { if (!ASN1_TYPE_set1(ttmp, attrtype, data)) goto err; } else ASN1_TYPE_set(ttmp, atype, stmp); if (!sk_ASN1_TYPE_push(attr->value.set, ttmp)) goto err; return 1; err: ASN1_TYPE_free(ttmp); ASN1_STRING_free(stmp); X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_MALLOC_FAILURE); return 0; } int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr) { if (!attr->single) return sk_ASN1_TYPE_num(attr->value.set); if (attr->value.single) return 1; return 0; } ASN1_OBJECT * X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr) { if (attr == NULL) return (NULL); return (attr->object); } void * X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype, void *data) { ASN1_TYPE *ttmp; ttmp = X509_ATTRIBUTE_get0_type(attr, idx); if (!ttmp) return NULL; if (atrtype != ASN1_TYPE_get(ttmp)){ X509err(X509_F_X509_ATTRIBUTE_GET0_DATA, X509_R_WRONG_TYPE); return NULL; } return ttmp->value.ptr; } ASN1_TYPE * X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx) { if (attr == NULL) return (NULL); if (idx >= X509_ATTRIBUTE_count(attr)) return NULL; if (!attr->single) return sk_ASN1_TYPE_value(attr->value.set, idx); else return attr->value.single; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509cset.c0000644000175000017500000001144312360020706020514 0ustar /* $OpenBSD: x509cset.c,v 1.7 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include int X509_CRL_set_version(X509_CRL *x, long version) { if (x == NULL) return (0); if (x->crl->version == NULL) { if ((x->crl->version = M_ASN1_INTEGER_new()) == NULL) return (0); } return (ASN1_INTEGER_set(x->crl->version, version)); } int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name) { if ((x == NULL) || (x->crl == NULL)) return (0); return (X509_NAME_set(&x->crl->issuer, name)); } int X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm) { ASN1_TIME *in; if (x == NULL) return (0); in = x->crl->lastUpdate; if (in != tm) { in = M_ASN1_TIME_dup(tm); if (in != NULL) { M_ASN1_TIME_free(x->crl->lastUpdate); x->crl->lastUpdate = in; } } return (in != NULL); } int X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm) { ASN1_TIME *in; if (x == NULL) return (0); in = x->crl->nextUpdate; if (in != tm) { in = M_ASN1_TIME_dup(tm); if (in != NULL) { M_ASN1_TIME_free(x->crl->nextUpdate); x->crl->nextUpdate = in; } } return (in != NULL); } int X509_CRL_sort(X509_CRL *c) { int i; X509_REVOKED *r; /* sort the data so it will be written in serial * number order */ sk_X509_REVOKED_sort(c->crl->revoked); for (i = 0; i < sk_X509_REVOKED_num(c->crl->revoked); i++) { r = sk_X509_REVOKED_value(c->crl->revoked, i); r->sequence = i; } c->crl->enc.modified = 1; return 1; } int X509_REVOKED_set_revocationDate(X509_REVOKED *x, ASN1_TIME *tm) { ASN1_TIME *in; if (x == NULL) return (0); in = x->revocationDate; if (in != tm) { in = M_ASN1_TIME_dup(tm); if (in != NULL) { M_ASN1_TIME_free(x->revocationDate); x->revocationDate = in; } } return (in != NULL); } int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial) { ASN1_INTEGER *in; if (x == NULL) return (0); in = x->serialNumber; if (in != serial) { in = M_ASN1_INTEGER_dup(serial); if (in != NULL) { M_ASN1_INTEGER_free(x->serialNumber); x->serialNumber = in; } } return (in != NULL); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_lu.c0000644000175000017500000004323512360020706020341 0ustar /* $OpenBSD: x509_lu.c,v 1.16 2014/07/11 08:44:49 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include "x509_lcl.h" X509_LOOKUP * X509_LOOKUP_new(X509_LOOKUP_METHOD *method) { X509_LOOKUP *ret; ret = malloc(sizeof(X509_LOOKUP)); if (ret == NULL) return NULL; ret->init = 0; ret->skip = 0; ret->method = method; ret->method_data = NULL; ret->store_ctx = NULL; if ((method->new_item != NULL) && !method->new_item(ret)) { free(ret); return NULL; } return ret; } void X509_LOOKUP_free(X509_LOOKUP *ctx) { if (ctx == NULL) return; if ((ctx->method != NULL) && (ctx->method->free != NULL)) (*ctx->method->free)(ctx); free(ctx); } int X509_LOOKUP_init(X509_LOOKUP *ctx) { if (ctx->method == NULL) return 0; if (ctx->method->init != NULL) return ctx->method->init(ctx); else return 1; } int X509_LOOKUP_shutdown(X509_LOOKUP *ctx) { if (ctx->method == NULL) return 0; if (ctx->method->shutdown != NULL) return ctx->method->shutdown(ctx); else return 1; } int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret) { if (ctx->method == NULL) return -1; if (ctx->method->ctrl != NULL) return ctx->method->ctrl(ctx, cmd, argc, argl, ret); else return 1; } int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name, X509_OBJECT *ret) { if ((ctx->method == NULL) || (ctx->method->get_by_subject == NULL)) return X509_LU_FAIL; if (ctx->skip) return 0; return ctx->method->get_by_subject(ctx, type, name, ret); } int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name, ASN1_INTEGER *serial, X509_OBJECT *ret) { if ((ctx->method == NULL) || (ctx->method->get_by_issuer_serial == NULL)) return X509_LU_FAIL; return ctx->method->get_by_issuer_serial(ctx, type, name, serial, ret); } int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type, unsigned char *bytes, int len, X509_OBJECT *ret) { if ((ctx->method == NULL) || (ctx->method->get_by_fingerprint == NULL)) return X509_LU_FAIL; return ctx->method->get_by_fingerprint(ctx, type, bytes, len, ret); } int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str, int len, X509_OBJECT *ret) { if ((ctx->method == NULL) || (ctx->method->get_by_alias == NULL)) return X509_LU_FAIL; return ctx->method->get_by_alias(ctx, type, str, len, ret); } static int x509_object_cmp(const X509_OBJECT * const *a, const X509_OBJECT * const *b) { int ret; ret = ((*a)->type - (*b)->type); if (ret) return ret; switch ((*a)->type) { case X509_LU_X509: ret = X509_subject_name_cmp((*a)->data.x509, (*b)->data.x509); break; case X509_LU_CRL: ret = X509_CRL_cmp((*a)->data.crl, (*b)->data.crl); break; default: /* abort(); */ return 0; } return ret; } X509_STORE * X509_STORE_new(void) { X509_STORE *ret; if ((ret = malloc(sizeof(X509_STORE))) == NULL) return NULL; ret->objs = sk_X509_OBJECT_new(x509_object_cmp); ret->cache = 1; ret->get_cert_methods = sk_X509_LOOKUP_new_null(); ret->verify = 0; ret->verify_cb = 0; if ((ret->param = X509_VERIFY_PARAM_new()) == NULL) { sk_X509_OBJECT_free(ret->objs); free(ret); return NULL; } ret->get_issuer = 0; ret->check_issued = 0; ret->check_revocation = 0; ret->get_crl = 0; ret->check_crl = 0; ret->cert_crl = 0; ret->lookup_certs = 0; ret->lookup_crls = 0; ret->cleanup = 0; if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE, ret, &ret->ex_data)) { sk_X509_OBJECT_free(ret->objs); free(ret); return NULL; } ret->references = 1; return ret; } static void cleanup(X509_OBJECT *a) { if (a->type == X509_LU_X509) { X509_free(a->data.x509); } else if (a->type == X509_LU_CRL) { X509_CRL_free(a->data.crl); } else { /* abort(); */ } free(a); } void X509_STORE_free(X509_STORE *vfy) { int i; STACK_OF(X509_LOOKUP) *sk; X509_LOOKUP *lu; if (vfy == NULL) return; sk = vfy->get_cert_methods; for (i = 0; i < sk_X509_LOOKUP_num(sk); i++) { lu = sk_X509_LOOKUP_value(sk, i); X509_LOOKUP_shutdown(lu); X509_LOOKUP_free(lu); } sk_X509_LOOKUP_free(sk); sk_X509_OBJECT_pop_free(vfy->objs, cleanup); CRYPTO_free_ex_data(CRYPTO_EX_INDEX_X509_STORE, vfy, &vfy->ex_data); if (vfy->param) X509_VERIFY_PARAM_free(vfy->param); free(vfy); } X509_LOOKUP * X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m) { int i; STACK_OF(X509_LOOKUP) *sk; X509_LOOKUP *lu; sk = v->get_cert_methods; for (i = 0; i < sk_X509_LOOKUP_num(sk); i++) { lu = sk_X509_LOOKUP_value(sk, i); if (m == lu->method) { return lu; } } /* a new one */ lu = X509_LOOKUP_new(m); if (lu == NULL) return NULL; else { lu->store_ctx = v; if (sk_X509_LOOKUP_push(v->get_cert_methods, lu)) return lu; else { X509_LOOKUP_free(lu); return NULL; } } } int X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name, X509_OBJECT *ret) { X509_STORE *ctx = vs->ctx; X509_LOOKUP *lu; X509_OBJECT stmp, *tmp; int i, j; CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); tmp = X509_OBJECT_retrieve_by_subject(ctx->objs, type, name); CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); if (tmp == NULL || type == X509_LU_CRL) { for (i = vs->current_method; i < sk_X509_LOOKUP_num(ctx->get_cert_methods); i++) { lu = sk_X509_LOOKUP_value(ctx->get_cert_methods, i); j = X509_LOOKUP_by_subject(lu, type, name, &stmp); if (j < 0) { vs->current_method = j; return j; } else if (j) { tmp = &stmp; break; } } vs->current_method = 0; if (tmp == NULL) return 0; } /* if (ret->data.ptr != NULL) X509_OBJECT_free_contents(ret); */ ret->type = tmp->type; ret->data.ptr = tmp->data.ptr; X509_OBJECT_up_ref_count(ret); return 1; } int X509_STORE_add_cert(X509_STORE *ctx, X509 *x) { X509_OBJECT *obj; int ret = 1; if (x == NULL) return 0; obj = malloc(sizeof(X509_OBJECT)); if (obj == NULL) { X509err(X509_F_X509_STORE_ADD_CERT, ERR_R_MALLOC_FAILURE); return 0; } obj->type = X509_LU_X509; obj->data.x509 = x; CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); X509_OBJECT_up_ref_count(obj); if (X509_OBJECT_retrieve_match(ctx->objs, obj)) { X509_OBJECT_free_contents(obj); free(obj); X509err(X509_F_X509_STORE_ADD_CERT, X509_R_CERT_ALREADY_IN_HASH_TABLE); ret = 0; } else sk_X509_OBJECT_push(ctx->objs, obj); CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); return ret; } int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x) { X509_OBJECT *obj; int ret = 1; if (x == NULL) return 0; obj = malloc(sizeof(X509_OBJECT)); if (obj == NULL) { X509err(X509_F_X509_STORE_ADD_CRL, ERR_R_MALLOC_FAILURE); return 0; } obj->type = X509_LU_CRL; obj->data.crl = x; CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); X509_OBJECT_up_ref_count(obj); if (X509_OBJECT_retrieve_match(ctx->objs, obj)) { X509_OBJECT_free_contents(obj); free(obj); X509err(X509_F_X509_STORE_ADD_CRL, X509_R_CERT_ALREADY_IN_HASH_TABLE); ret = 0; } else sk_X509_OBJECT_push(ctx->objs, obj); CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); return ret; } void X509_OBJECT_up_ref_count(X509_OBJECT *a) { switch (a->type) { case X509_LU_X509: CRYPTO_add(&a->data.x509->references, 1, CRYPTO_LOCK_X509); break; case X509_LU_CRL: CRYPTO_add(&a->data.crl->references, 1, CRYPTO_LOCK_X509_CRL); break; } } void X509_OBJECT_free_contents(X509_OBJECT *a) { switch (a->type) { case X509_LU_X509: X509_free(a->data.x509); break; case X509_LU_CRL: X509_CRL_free(a->data.crl); break; } } static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, int type, X509_NAME *name, int *pnmatch) { X509_OBJECT stmp; X509 x509_s; X509_CINF cinf_s; X509_CRL crl_s; X509_CRL_INFO crl_info_s; int idx; stmp.type = type; switch (type) { case X509_LU_X509: stmp.data.x509 = &x509_s; x509_s.cert_info = &cinf_s; cinf_s.subject = name; break; case X509_LU_CRL: stmp.data.crl = &crl_s; crl_s.crl = &crl_info_s; crl_info_s.issuer = name; break; default: /* abort(); */ return -1; } idx = sk_X509_OBJECT_find(h, &stmp); if (idx >= 0 && pnmatch) { int tidx; const X509_OBJECT *tobj, *pstmp; *pnmatch = 1; pstmp = &stmp; for (tidx = idx + 1; tidx < sk_X509_OBJECT_num(h); tidx++) { tobj = sk_X509_OBJECT_value(h, tidx); if (x509_object_cmp(&tobj, &pstmp)) break; (*pnmatch)++; } } return idx; } int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type, X509_NAME *name) { return x509_object_idx_cnt(h, type, name, NULL); } X509_OBJECT * X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, int type, X509_NAME *name) { int idx; idx = X509_OBJECT_idx_by_subject(h, type, name); if (idx == -1) return NULL; return sk_X509_OBJECT_value(h, idx); } STACK_OF(X509) * X509_STORE_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm) { int i, idx, cnt; STACK_OF(X509) *sk; X509 *x; X509_OBJECT *obj; sk = sk_X509_new_null(); CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt); if (idx < 0) { /* Nothing found in cache: do lookup to possibly add new * objects to cache */ X509_OBJECT xobj; CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); if (!X509_STORE_get_by_subject(ctx, X509_LU_X509, nm, &xobj)) { sk_X509_free(sk); return NULL; } X509_OBJECT_free_contents(&xobj); CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt); if (idx < 0) { CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); sk_X509_free(sk); return NULL; } } for (i = 0; i < cnt; i++, idx++) { obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx); x = obj->data.x509; CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509); if (!sk_X509_push(sk, x)) { CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); X509_free(x); sk_X509_pop_free(sk, X509_free); return NULL; } } CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); return sk; } STACK_OF(X509_CRL) * X509_STORE_get1_crls(X509_STORE_CTX *ctx, X509_NAME *nm) { int i, idx, cnt; STACK_OF(X509_CRL) *sk; X509_CRL *x; X509_OBJECT *obj, xobj; sk = sk_X509_CRL_new_null(); CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); /* Check cache first */ idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_CRL, nm, &cnt); /* Always do lookup to possibly add new CRLs to cache */ CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); if (!X509_STORE_get_by_subject(ctx, X509_LU_CRL, nm, &xobj)) { sk_X509_CRL_free(sk); return NULL; } X509_OBJECT_free_contents(&xobj); CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_CRL, nm, &cnt); if (idx < 0) { CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); sk_X509_CRL_free(sk); return NULL; } for (i = 0; i < cnt; i++, idx++) { obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx); x = obj->data.crl; CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509_CRL); if (!sk_X509_CRL_push(sk, x)) { CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); X509_CRL_free(x); sk_X509_CRL_pop_free(sk, X509_CRL_free); return NULL; } } CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); return sk; } X509_OBJECT * X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x) { int idx, i; X509_OBJECT *obj; idx = sk_X509_OBJECT_find(h, x); if (idx == -1) return NULL; if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL)) return sk_X509_OBJECT_value(h, idx); for (i = idx; i < sk_X509_OBJECT_num(h); i++) { obj = sk_X509_OBJECT_value(h, i); if (x509_object_cmp((const X509_OBJECT **)&obj, (const X509_OBJECT **)&x)) return NULL; if (x->type == X509_LU_X509) { if (!X509_cmp(obj->data.x509, x->data.x509)) return obj; } else if (x->type == X509_LU_CRL) { if (!X509_CRL_match(obj->data.crl, x->data.crl)) return obj; } else return obj; } return NULL; } /* Try to get issuer certificate from store. Due to limitations * of the API this can only retrieve a single certificate matching * a given subject name. However it will fill the cache with all * matching certificates, so we can examine the cache for all * matches. * * Return values are: * 1 lookup successful. * 0 certificate not found. * -1 some other error. */ int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x) { X509_NAME *xn; X509_OBJECT obj, *pobj; int i, ok, idx, ret; *issuer = NULL; xn = X509_get_issuer_name(x); ok = X509_STORE_get_by_subject(ctx, X509_LU_X509, xn, &obj); if (ok != X509_LU_X509) { if (ok == X509_LU_RETRY) { X509_OBJECT_free_contents(&obj); X509err(X509_F_X509_STORE_CTX_GET1_ISSUER, X509_R_SHOULD_RETRY); return -1; } else if (ok != X509_LU_FAIL) { X509_OBJECT_free_contents(&obj); /* not good :-(, break anyway */ return -1; } return 0; } /* If certificate matches all OK */ if (ctx->check_issued(ctx, x, obj.data.x509)) { if (x509_check_cert_time(ctx, obj.data.x509, 1)) { *issuer = obj.data.x509; return 1; } } X509_OBJECT_free_contents(&obj); /* Else find index of first cert accepted by 'check_issued' */ ret = 0; CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); idx = X509_OBJECT_idx_by_subject(ctx->ctx->objs, X509_LU_X509, xn); if (idx != -1) /* should be true as we've had at least one match */ { /* Look through all matching certs for suitable issuer */ for (i = idx; i < sk_X509_OBJECT_num(ctx->ctx->objs); i++) { pobj = sk_X509_OBJECT_value(ctx->ctx->objs, i); /* See if we've run past the matches */ if (pobj->type != X509_LU_X509) break; if (X509_NAME_cmp(xn, X509_get_subject_name(pobj->data.x509))) break; if (ctx->check_issued(ctx, x, pobj->data.x509)) { *issuer = pobj->data.x509; ret = 1; /* * If times check, exit with match, * otherwise keep looking. Leave last * match in issuer so we return nearest * match if no certificate time is OK. */ if (x509_check_cert_time(ctx, *issuer, 1)) break; } } } CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); if (*issuer) CRYPTO_add(&(*issuer)->references, 1, CRYPTO_LOCK_X509); return ret; } int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags) { return X509_VERIFY_PARAM_set_flags(ctx->param, flags); } int X509_STORE_set_depth(X509_STORE *ctx, int depth) { X509_VERIFY_PARAM_set_depth(ctx->param, depth); return 1; } int X509_STORE_set_purpose(X509_STORE *ctx, int purpose) { return X509_VERIFY_PARAM_set_purpose(ctx->param, purpose); } int X509_STORE_set_trust(X509_STORE *ctx, int trust) { return X509_VERIFY_PARAM_set_trust(ctx->param, trust); } int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *param) { return X509_VERIFY_PARAM_set1(ctx->param, param); } void X509_STORE_set_verify_cb(X509_STORE *ctx, int (*verify_cb)(int, X509_STORE_CTX *)) { ctx->verify_cb = verify_cb; } IMPLEMENT_STACK_OF(X509_LOOKUP) IMPLEMENT_STACK_OF(X509_OBJECT) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_ext.c0000644000175000017500000001565612360020706020527 0ustar /* $OpenBSD: x509_ext.c,v 1.7 2014/06/12 15:49:31 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include int X509_CRL_get_ext_count(X509_CRL *x) { return (X509v3_get_ext_count(x->crl->extensions)); } int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos) { return (X509v3_get_ext_by_NID(x->crl->extensions, nid, lastpos)); } int X509_CRL_get_ext_by_OBJ(X509_CRL *x, ASN1_OBJECT *obj, int lastpos) { return (X509v3_get_ext_by_OBJ(x->crl->extensions, obj, lastpos)); } int X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos) { return (X509v3_get_ext_by_critical(x->crl->extensions, crit, lastpos)); } X509_EXTENSION * X509_CRL_get_ext(X509_CRL *x, int loc) { return (X509v3_get_ext(x->crl->extensions, loc)); } X509_EXTENSION * X509_CRL_delete_ext(X509_CRL *x, int loc) { return (X509v3_delete_ext(x->crl->extensions, loc)); } void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx) { return X509V3_get_d2i(x->crl->extensions, nid, crit, idx); } int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit, unsigned long flags) { return X509V3_add1_i2d(&x->crl->extensions, nid, value, crit, flags); } int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc) { return (X509v3_add_ext(&(x->crl->extensions), ex, loc) != NULL); } int X509_get_ext_count(X509 *x) { return (X509v3_get_ext_count(x->cert_info->extensions)); } int X509_get_ext_by_NID(X509 *x, int nid, int lastpos) { return (X509v3_get_ext_by_NID(x->cert_info->extensions, nid, lastpos)); } int X509_get_ext_by_OBJ(X509 *x, ASN1_OBJECT *obj, int lastpos) { return (X509v3_get_ext_by_OBJ(x->cert_info->extensions, obj, lastpos)); } int X509_get_ext_by_critical(X509 *x, int crit, int lastpos) { return (X509v3_get_ext_by_critical(x->cert_info->extensions, crit, lastpos)); } X509_EXTENSION * X509_get_ext(X509 *x, int loc) { return (X509v3_get_ext(x->cert_info->extensions, loc)); } X509_EXTENSION * X509_delete_ext(X509 *x, int loc) { return (X509v3_delete_ext(x->cert_info->extensions, loc)); } int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc) { return (X509v3_add_ext(&(x->cert_info->extensions), ex, loc) != NULL); } void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx) { return X509V3_get_d2i(x->cert_info->extensions, nid, crit, idx); } int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, unsigned long flags) { return X509V3_add1_i2d(&x->cert_info->extensions, nid, value, crit, flags); } int X509_REVOKED_get_ext_count(X509_REVOKED *x) { return (X509v3_get_ext_count(x->extensions)); } int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos) { return (X509v3_get_ext_by_NID(x->extensions, nid, lastpos)); } int X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x, ASN1_OBJECT *obj, int lastpos) { return (X509v3_get_ext_by_OBJ(x->extensions, obj, lastpos)); } int X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos) { return (X509v3_get_ext_by_critical(x->extensions, crit, lastpos)); } X509_EXTENSION * X509_REVOKED_get_ext(X509_REVOKED *x, int loc) { return (X509v3_get_ext(x->extensions, loc)); } X509_EXTENSION * X509_REVOKED_delete_ext(X509_REVOKED *x, int loc) { return (X509v3_delete_ext(x->extensions, loc)); } int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc) { return (X509v3_add_ext(&(x->extensions), ex, loc) != NULL); } void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx) { return X509V3_get_d2i(x->extensions, nid, crit, idx); } int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, unsigned long flags) { return X509V3_add1_i2d(&x->extensions, nid, value, crit, flags); } IMPLEMENT_STACK_OF(X509_EXTENSION) IMPLEMENT_ASN1_SET_OF(X509_EXTENSION) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509spki.c0000644000175000017500000001055712360020706020531 0ustar /* $OpenBSD: x509spki.c,v 1.11 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey) { if ((x == NULL) || (x->spkac == NULL)) return (0); return (X509_PUBKEY_set(&(x->spkac->pubkey), pkey)); } EVP_PKEY * NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x) { if ((x == NULL) || (x->spkac == NULL)) return (NULL); return (X509_PUBKEY_get(x->spkac->pubkey)); } /* Load a Netscape SPKI from a base64 encoded string */ NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len) { unsigned char *spki_der; const unsigned char *p; int spki_len; NETSCAPE_SPKI *spki; if (len <= 0) len = strlen(str); if (!(spki_der = malloc(len + 1))) { X509err(X509_F_NETSCAPE_SPKI_B64_DECODE, ERR_R_MALLOC_FAILURE); return NULL; } spki_len = EVP_DecodeBlock(spki_der, (const unsigned char *)str, len); if (spki_len < 0) { X509err(X509_F_NETSCAPE_SPKI_B64_DECODE, X509_R_BASE64_DECODE_ERROR); free(spki_der); return NULL; } p = spki_der; spki = d2i_NETSCAPE_SPKI(NULL, &p, spki_len); free(spki_der); return spki; } /* Generate a base64 encoded string from an SPKI */ char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *spki) { unsigned char *der_spki, *p; char *b64_str; int der_len; der_len = i2d_NETSCAPE_SPKI(spki, NULL); der_spki = malloc(der_len); b64_str = reallocarray(NULL, der_len, 2); if (!der_spki || !b64_str) { X509err(X509_F_NETSCAPE_SPKI_B64_ENCODE, ERR_R_MALLOC_FAILURE); free(der_spki); free(b64_str); return NULL; } p = der_spki; i2d_NETSCAPE_SPKI(spki, &p); EVP_EncodeBlock((unsigned char *)b64_str, der_spki, der_len); free(der_spki); return b64_str; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_r2x.c0000644000175000017500000001063112360020706020426 0ustar /* $OpenBSD: x509_r2x.c,v 1.8 2014/06/12 15:49:31 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include X509 * X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey) { X509 *ret = NULL; X509_CINF *xi = NULL; X509_NAME *xn; if ((ret = X509_new()) == NULL) { X509err(X509_F_X509_REQ_TO_X509, ERR_R_MALLOC_FAILURE); goto err; } /* duplicate the request */ xi = ret->cert_info; if (sk_X509_ATTRIBUTE_num(r->req_info->attributes) != 0) { if ((xi->version = M_ASN1_INTEGER_new()) == NULL) goto err; if (!ASN1_INTEGER_set(xi->version, 2)) goto err; /* xi->extensions=ri->attributes; <- bad, should not ever be done ri->attributes=NULL; */ } xn = X509_REQ_get_subject_name(r); if (X509_set_subject_name(ret, X509_NAME_dup(xn)) == 0) goto err; if (X509_set_issuer_name(ret, X509_NAME_dup(xn)) == 0) goto err; if (X509_gmtime_adj(xi->validity->notBefore, 0) == NULL) goto err; if (X509_gmtime_adj(xi->validity->notAfter, (long)60 * 60 * 24 * days) == NULL) goto err; X509_set_pubkey(ret, X509_REQ_get_pubkey(r)); if (!X509_sign(ret, pkey, EVP_md5())) goto err; if (0) { err: X509_free(ret); ret = NULL; } return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_vpm.c0000644000175000017500000002721312360020706020521 0ustar /* $OpenBSD: x509_vpm.c,v 1.8 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include /* X509_VERIFY_PARAM functions */ static void x509_verify_param_zero(X509_VERIFY_PARAM *param) { if (!param) return; param->name = NULL; param->purpose = 0; param->trust = 0; /*param->inh_flags = X509_VP_FLAG_DEFAULT;*/ param->inh_flags = 0; param->flags = 0; param->depth = -1; if (param->policies) { sk_ASN1_OBJECT_pop_free(param->policies, ASN1_OBJECT_free); param->policies = NULL; } } X509_VERIFY_PARAM * X509_VERIFY_PARAM_new(void) { X509_VERIFY_PARAM *param; param = calloc(1, sizeof(X509_VERIFY_PARAM)); x509_verify_param_zero(param); return param; } void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param) { x509_verify_param_zero(param); free(param); } /* This function determines how parameters are "inherited" from one structure * to another. There are several different ways this can happen. * * 1. If a child structure needs to have its values initialized from a parent * they are simply copied across. For example SSL_CTX copied to SSL. * 2. If the structure should take on values only if they are currently unset. * For example the values in an SSL structure will take appropriate value * for SSL servers or clients but only if the application has not set new * ones. * * The "inh_flags" field determines how this function behaves. * * Normally any values which are set in the default are not copied from the * destination and verify flags are ORed together. * * If X509_VP_FLAG_DEFAULT is set then anything set in the source is copied * to the destination. Effectively the values in "to" become default values * which will be used only if nothing new is set in "from". * * If X509_VP_FLAG_OVERWRITE is set then all value are copied across whether * they are set or not. Flags is still Ored though. * * If X509_VP_FLAG_RESET_FLAGS is set then the flags value is copied instead * of ORed. * * If X509_VP_FLAG_LOCKED is set then no values are copied. * * If X509_VP_FLAG_ONCE is set then the current inh_flags setting is zeroed * after the next call. */ /* Macro to test if a field should be copied from src to dest */ #define test_x509_verify_param_copy(field, def) \ (to_overwrite || \ ((src->field != def) && (to_default || (dest->field == def)))) /* Macro to test and copy a field if necessary */ #define x509_verify_param_copy(field, def) \ if (test_x509_verify_param_copy(field, def)) \ dest->field = src->field int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *dest, const X509_VERIFY_PARAM *src) { unsigned long inh_flags; int to_default, to_overwrite; if (!src) return 1; inh_flags = dest->inh_flags | src->inh_flags; if (inh_flags & X509_VP_FLAG_ONCE) dest->inh_flags = 0; if (inh_flags & X509_VP_FLAG_LOCKED) return 1; if (inh_flags & X509_VP_FLAG_DEFAULT) to_default = 1; else to_default = 0; if (inh_flags & X509_VP_FLAG_OVERWRITE) to_overwrite = 1; else to_overwrite = 0; x509_verify_param_copy(purpose, 0); x509_verify_param_copy(trust, 0); x509_verify_param_copy(depth, -1); /* If overwrite or check time not set, copy across */ if (to_overwrite || !(dest->flags & X509_V_FLAG_USE_CHECK_TIME)) { dest->check_time = src->check_time; dest->flags &= ~X509_V_FLAG_USE_CHECK_TIME; /* Don't need to copy flag: that is done below */ } if (inh_flags & X509_VP_FLAG_RESET_FLAGS) dest->flags = 0; dest->flags |= src->flags; if (test_x509_verify_param_copy(policies, NULL)) { if (!X509_VERIFY_PARAM_set1_policies(dest, src->policies)) return 0; } return 1; } int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, const X509_VERIFY_PARAM *from) { unsigned long save_flags = to->inh_flags; int ret; to->inh_flags |= X509_VP_FLAG_DEFAULT; ret = X509_VERIFY_PARAM_inherit(to, from); to->inh_flags = save_flags; return ret; } int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name) { free(param->name); param->name = BUF_strdup(name); if (param->name) return 1; return 0; } int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags) { param->flags |= flags; if (flags & X509_V_FLAG_POLICY_MASK) param->flags |= X509_V_FLAG_POLICY_CHECK; return 1; } int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, unsigned long flags) { param->flags &= ~flags; return 1; } unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param) { return param->flags; } int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose) { return X509_PURPOSE_set(¶m->purpose, purpose); } int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust) { return X509_TRUST_set(¶m->trust, trust); } void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth) { param->depth = depth; } void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t) { param->check_time = t; param->flags |= X509_V_FLAG_USE_CHECK_TIME; } int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, ASN1_OBJECT *policy) { if (!param->policies) { param->policies = sk_ASN1_OBJECT_new_null(); if (!param->policies) return 0; } if (!sk_ASN1_OBJECT_push(param->policies, policy)) return 0; return 1; } int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, STACK_OF(ASN1_OBJECT) *policies) { int i; ASN1_OBJECT *oid, *doid; if (!param) return 0; if (param->policies) sk_ASN1_OBJECT_pop_free(param->policies, ASN1_OBJECT_free); if (!policies) { param->policies = NULL; return 1; } param->policies = sk_ASN1_OBJECT_new_null(); if (!param->policies) return 0; for (i = 0; i < sk_ASN1_OBJECT_num(policies); i++) { oid = sk_ASN1_OBJECT_value(policies, i); doid = OBJ_dup(oid); if (!doid) return 0; if (!sk_ASN1_OBJECT_push(param->policies, doid)) { ASN1_OBJECT_free(doid); return 0; } } param->flags |= X509_V_FLAG_POLICY_CHECK; return 1; } int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param) { return param->depth; } /* Default verify parameters: these are used for various * applications and can be overridden by the user specified table. * NB: the 'name' field *must* be in alphabetical order because it * will be searched using OBJ_search. */ static const X509_VERIFY_PARAM default_table[] = { { "default", /* X509 default parameters */ 0, /* Check time */ 0, /* internal flags */ 0, /* flags */ 0, /* purpose */ 0, /* trust */ 100, /* depth */ NULL /* policies */ }, { "pkcs7", /* S/MIME sign parameters */ 0, /* Check time */ 0, /* internal flags */ 0, /* flags */ X509_PURPOSE_SMIME_SIGN, /* purpose */ X509_TRUST_EMAIL, /* trust */ -1, /* depth */ NULL /* policies */ }, { "smime_sign", /* S/MIME sign parameters */ 0, /* Check time */ 0, /* internal flags */ 0, /* flags */ X509_PURPOSE_SMIME_SIGN, /* purpose */ X509_TRUST_EMAIL, /* trust */ -1, /* depth */ NULL /* policies */ }, { "ssl_client", /* SSL/TLS client parameters */ 0, /* Check time */ 0, /* internal flags */ 0, /* flags */ X509_PURPOSE_SSL_CLIENT, /* purpose */ X509_TRUST_SSL_CLIENT, /* trust */ -1, /* depth */ NULL /* policies */ }, { "ssl_server", /* SSL/TLS server parameters */ 0, /* Check time */ 0, /* internal flags */ 0, /* flags */ X509_PURPOSE_SSL_SERVER, /* purpose */ X509_TRUST_SSL_SERVER, /* trust */ -1, /* depth */ NULL /* policies */ } }; static STACK_OF(X509_VERIFY_PARAM) *param_table = NULL; static int table_cmp(const X509_VERIFY_PARAM *a, const X509_VERIFY_PARAM *b) { return strcmp(a->name, b->name); } DECLARE_OBJ_BSEARCH_CMP_FN(X509_VERIFY_PARAM, X509_VERIFY_PARAM, table); IMPLEMENT_OBJ_BSEARCH_CMP_FN(X509_VERIFY_PARAM, X509_VERIFY_PARAM, table); static int param_cmp(const X509_VERIFY_PARAM * const *a, const X509_VERIFY_PARAM * const *b) { return strcmp((*a)->name, (*b)->name); } int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param) { int idx; X509_VERIFY_PARAM *ptmp; if (!param_table) { param_table = sk_X509_VERIFY_PARAM_new(param_cmp); if (!param_table) return 0; } else { idx = sk_X509_VERIFY_PARAM_find(param_table, param); if (idx != -1) { ptmp = sk_X509_VERIFY_PARAM_value(param_table, idx); X509_VERIFY_PARAM_free(ptmp); (void)sk_X509_VERIFY_PARAM_delete(param_table, idx); } } if (!sk_X509_VERIFY_PARAM_push(param_table, param)) return 0; return 1; } const X509_VERIFY_PARAM * X509_VERIFY_PARAM_lookup(const char *name) { int idx; X509_VERIFY_PARAM pm; pm.name = (char *)name; if (param_table) { idx = sk_X509_VERIFY_PARAM_find(param_table, &pm); if (idx != -1) return sk_X509_VERIFY_PARAM_value(param_table, idx); } return OBJ_bsearch_table(&pm, default_table, sizeof(default_table)/sizeof(X509_VERIFY_PARAM)); } void X509_VERIFY_PARAM_table_cleanup(void) { if (param_table) sk_X509_VERIFY_PARAM_pop_free(param_table, X509_VERIFY_PARAM_free); param_table = NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_trs.c0000644000175000017500000002127512360020706020531 0ustar /* $OpenBSD: x509_trs.c,v 1.14 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include static int tr_cmp(const X509_TRUST * const *a, const X509_TRUST * const *b); static void trtable_free(X509_TRUST *p); static int trust_1oidany(X509_TRUST *trust, X509 *x, int flags); static int trust_1oid(X509_TRUST *trust, X509 *x, int flags); static int trust_compat(X509_TRUST *trust, X509 *x, int flags); static int obj_trust(int id, X509 *x, int flags); static int (*default_trust)(int id, X509 *x, int flags) = obj_trust; /* WARNING: the following table should be kept in order of trust * and without any gaps so we can just subtract the minimum trust * value to get an index into the table */ static X509_TRUST trstandard[] = { {X509_TRUST_COMPAT, 0, trust_compat, "compatible", 0, NULL}, {X509_TRUST_SSL_CLIENT, 0, trust_1oidany, "SSL Client", NID_client_auth, NULL}, {X509_TRUST_SSL_SERVER, 0, trust_1oidany, "SSL Server", NID_server_auth, NULL}, {X509_TRUST_EMAIL, 0, trust_1oidany, "S/MIME email", NID_email_protect, NULL}, {X509_TRUST_OBJECT_SIGN, 0, trust_1oidany, "Object Signer", NID_code_sign, NULL}, {X509_TRUST_OCSP_SIGN, 0, trust_1oid, "OCSP responder", NID_OCSP_sign, NULL}, {X509_TRUST_OCSP_REQUEST, 0, trust_1oid, "OCSP request", NID_ad_OCSP, NULL}, {X509_TRUST_TSA, 0, trust_1oidany, "TSA server", NID_time_stamp, NULL} }; #define X509_TRUST_COUNT (sizeof(trstandard)/sizeof(X509_TRUST)) IMPLEMENT_STACK_OF(X509_TRUST) static STACK_OF(X509_TRUST) *trtable = NULL; static int tr_cmp(const X509_TRUST * const *a, const X509_TRUST * const *b) { return (*a)->trust - (*b)->trust; } int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int) { int (*oldtrust)(int , X509 *, int); oldtrust = default_trust; default_trust = trust; return oldtrust; } int X509_check_trust(X509 *x, int id, int flags) { X509_TRUST *pt; int idx; if (id == -1) return 1; idx = X509_TRUST_get_by_id(id); if (idx == -1) return default_trust(id, x, flags); pt = X509_TRUST_get0(idx); return pt->check_trust(pt, x, flags); } int X509_TRUST_get_count(void) { if (!trtable) return X509_TRUST_COUNT; return sk_X509_TRUST_num(trtable) + X509_TRUST_COUNT; } X509_TRUST * X509_TRUST_get0(int idx) { if (idx < 0) return NULL; if (idx < (int)X509_TRUST_COUNT) return trstandard + idx; return sk_X509_TRUST_value(trtable, idx - X509_TRUST_COUNT); } int X509_TRUST_get_by_id(int id) { X509_TRUST tmp; int idx; if ((id >= X509_TRUST_MIN) && (id <= X509_TRUST_MAX)) return id - X509_TRUST_MIN; tmp.trust = id; if (!trtable) return -1; idx = sk_X509_TRUST_find(trtable, &tmp); if (idx == -1) return -1; return idx + X509_TRUST_COUNT; } int X509_TRUST_set(int *t, int trust) { if (X509_TRUST_get_by_id(trust) == -1) { X509err(X509_F_X509_TRUST_SET, X509_R_INVALID_TRUST); return 0; } *t = trust; return 1; } int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), char *name, int arg1, void *arg2) { int idx; X509_TRUST *trtmp; /* This is set according to what we change: application can't set it */ flags &= ~X509_TRUST_DYNAMIC; /* This will always be set for application modified trust entries */ flags |= X509_TRUST_DYNAMIC_NAME; /* Get existing entry if any */ idx = X509_TRUST_get_by_id(id); /* Need a new entry */ if (idx == -1) { if (!(trtmp = malloc(sizeof(X509_TRUST)))) { X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE); return 0; } trtmp->flags = X509_TRUST_DYNAMIC; } else trtmp = X509_TRUST_get0(idx); /* free existing name if dynamic */ if (trtmp->flags & X509_TRUST_DYNAMIC_NAME) free(trtmp->name); /* dup supplied name */ if (!(trtmp->name = BUF_strdup(name))) { X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE); return 0; } /* Keep the dynamic flag of existing entry */ trtmp->flags &= X509_TRUST_DYNAMIC; /* Set all other flags */ trtmp->flags |= flags; trtmp->trust = id; trtmp->check_trust = ck; trtmp->arg1 = arg1; trtmp->arg2 = arg2; /* If its a new entry manage the dynamic table */ if (idx == -1) { if (!trtable && !(trtable = sk_X509_TRUST_new(tr_cmp))) { X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE); return 0; } if (!sk_X509_TRUST_push(trtable, trtmp)) { X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE); return 0; } } return 1; } static void trtable_free(X509_TRUST *p) { if (!p) return; if (p->flags & X509_TRUST_DYNAMIC) { if (p->flags & X509_TRUST_DYNAMIC_NAME) free(p->name); free(p); } } void X509_TRUST_cleanup(void) { unsigned int i; for (i = 0; i < X509_TRUST_COUNT; i++) trtable_free(trstandard + i); sk_X509_TRUST_pop_free(trtable, trtable_free); trtable = NULL; } int X509_TRUST_get_flags(X509_TRUST *xp) { return xp->flags; } char * X509_TRUST_get0_name(X509_TRUST *xp) { return xp->name; } int X509_TRUST_get_trust(X509_TRUST *xp) { return xp->trust; } static int trust_1oidany(X509_TRUST *trust, X509 *x, int flags) { if (x->aux && (x->aux->trust || x->aux->reject)) return obj_trust(trust->arg1, x, flags); /* we don't have any trust settings: for compatibility * we return trusted if it is self signed */ return trust_compat(trust, x, flags); } static int trust_1oid(X509_TRUST *trust, X509 *x, int flags) { if (x->aux) return obj_trust(trust->arg1, x, flags); return X509_TRUST_UNTRUSTED; } static int trust_compat(X509_TRUST *trust, X509 *x, int flags) { X509_check_purpose(x, -1, 0); if (x->ex_flags & EXFLAG_SS) return X509_TRUST_TRUSTED; else return X509_TRUST_UNTRUSTED; } static int obj_trust(int id, X509 *x, int flags) { ASN1_OBJECT *obj; int i; X509_CERT_AUX *ax; ax = x->aux; if (!ax) return X509_TRUST_UNTRUSTED; if (ax->reject) { for (i = 0; i < sk_ASN1_OBJECT_num(ax->reject); i++) { obj = sk_ASN1_OBJECT_value(ax->reject, i); if (OBJ_obj2nid(obj) == id) return X509_TRUST_REJECTED; } } if (ax->trust) { for (i = 0; i < sk_ASN1_OBJECT_num(ax->trust); i++) { obj = sk_ASN1_OBJECT_value(ax->trust, i); if (OBJ_obj2nid(obj) == id) return X509_TRUST_TRUSTED; } } return X509_TRUST_UNTRUSTED; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x_all.c0000644000175000017500000003416512360020706020235 0ustar /* $OpenBSD: x_all.c,v 1.17 2014/07/10 22:45:58 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #ifndef OPENSSL_NO_DSA #include #endif #ifndef OPENSSL_NO_RSA #include #endif int X509_verify(X509 *a, EVP_PKEY *r) { return(ASN1_item_verify(ASN1_ITEM_rptr(X509_CINF), a->sig_alg, a->signature, a->cert_info, r)); } int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r) { return( ASN1_item_verify(ASN1_ITEM_rptr(X509_REQ_INFO), a->sig_alg, a->signature, a->req_info, r)); } int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r) { return(ASN1_item_verify(ASN1_ITEM_rptr(NETSCAPE_SPKAC), a->sig_algor, a->signature, a->spkac, r)); } int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md) { x->cert_info->enc.modified = 1; return (ASN1_item_sign(ASN1_ITEM_rptr(X509_CINF), x->cert_info->signature, x->sig_alg, x->signature, x->cert_info, pkey, md)); } int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx) { x->cert_info->enc.modified = 1; return ASN1_item_sign_ctx(ASN1_ITEM_rptr(X509_CINF), x->cert_info->signature, x->sig_alg, x->signature, x->cert_info, ctx); } int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md) { return (ASN1_item_sign(ASN1_ITEM_rptr(X509_REQ_INFO), x->sig_alg, NULL, x->signature, x->req_info, pkey, md)); } int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx) { return ASN1_item_sign_ctx(ASN1_ITEM_rptr(X509_REQ_INFO), x->sig_alg, NULL, x->signature, x->req_info, ctx); } int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md) { x->crl->enc.modified = 1; return(ASN1_item_sign(ASN1_ITEM_rptr(X509_CRL_INFO), x->crl->sig_alg, x->sig_alg, x->signature, x->crl, pkey, md)); } int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx) { x->crl->enc.modified = 1; return ASN1_item_sign_ctx(ASN1_ITEM_rptr(X509_CRL_INFO), x->crl->sig_alg, x->sig_alg, x->signature, x->crl, ctx); } int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md) { return (ASN1_item_sign(ASN1_ITEM_rptr(NETSCAPE_SPKAC), x->sig_algor, NULL, x->signature, x->spkac, pkey, md)); } X509 * d2i_X509_fp(FILE *fp, X509 **x509) { return ASN1_item_d2i_fp(ASN1_ITEM_rptr(X509), fp, x509); } int i2d_X509_fp(FILE *fp, X509 *x509) { return ASN1_item_i2d_fp(ASN1_ITEM_rptr(X509), fp, x509); } X509 * d2i_X509_bio(BIO *bp, X509 **x509) { return ASN1_item_d2i_bio(ASN1_ITEM_rptr(X509), bp, x509); } int i2d_X509_bio(BIO *bp, X509 *x509) { return ASN1_item_i2d_bio(ASN1_ITEM_rptr(X509), bp, x509); } X509_CRL * d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl) { return ASN1_item_d2i_fp(ASN1_ITEM_rptr(X509_CRL), fp, crl); } int i2d_X509_CRL_fp(FILE *fp, X509_CRL *crl) { return ASN1_item_i2d_fp(ASN1_ITEM_rptr(X509_CRL), fp, crl); } X509_CRL * d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl) { return ASN1_item_d2i_bio(ASN1_ITEM_rptr(X509_CRL), bp, crl); } int i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl) { return ASN1_item_i2d_bio(ASN1_ITEM_rptr(X509_CRL), bp, crl); } PKCS7 * d2i_PKCS7_fp(FILE *fp, PKCS7 **p7) { return ASN1_item_d2i_fp(ASN1_ITEM_rptr(PKCS7), fp, p7); } int i2d_PKCS7_fp(FILE *fp, PKCS7 *p7) { return ASN1_item_i2d_fp(ASN1_ITEM_rptr(PKCS7), fp, p7); } PKCS7 * d2i_PKCS7_bio(BIO *bp, PKCS7 **p7) { return ASN1_item_d2i_bio(ASN1_ITEM_rptr(PKCS7), bp, p7); } int i2d_PKCS7_bio(BIO *bp, PKCS7 *p7) { return ASN1_item_i2d_bio(ASN1_ITEM_rptr(PKCS7), bp, p7); } X509_REQ * d2i_X509_REQ_fp(FILE *fp, X509_REQ **req) { return ASN1_item_d2i_fp(ASN1_ITEM_rptr(X509_REQ), fp, req); } int i2d_X509_REQ_fp(FILE *fp, X509_REQ *req) { return ASN1_item_i2d_fp(ASN1_ITEM_rptr(X509_REQ), fp, req); } X509_REQ * d2i_X509_REQ_bio(BIO *bp, X509_REQ **req) { return ASN1_item_d2i_bio(ASN1_ITEM_rptr(X509_REQ), bp, req); } int i2d_X509_REQ_bio(BIO *bp, X509_REQ *req) { return ASN1_item_i2d_bio(ASN1_ITEM_rptr(X509_REQ), bp, req); } #ifndef OPENSSL_NO_RSA RSA * d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa) { return ASN1_item_d2i_fp(ASN1_ITEM_rptr(RSAPrivateKey), fp, rsa); } int i2d_RSAPrivateKey_fp(FILE *fp, RSA *rsa) { return ASN1_item_i2d_fp(ASN1_ITEM_rptr(RSAPrivateKey), fp, rsa); } RSA * d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa) { return ASN1_item_d2i_fp(ASN1_ITEM_rptr(RSAPublicKey), fp, rsa); } RSA * d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa) { return ASN1_d2i_fp((void *(*)(void))RSA_new, (D2I_OF(void))d2i_RSA_PUBKEY, fp, (void **)rsa); } int i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa) { return ASN1_item_i2d_fp(ASN1_ITEM_rptr(RSAPublicKey), fp, rsa); } int i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa) { return ASN1_i2d_fp((I2D_OF(void))i2d_RSA_PUBKEY, fp, rsa); } RSA * d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa) { return ASN1_item_d2i_bio(ASN1_ITEM_rptr(RSAPrivateKey), bp, rsa); } int i2d_RSAPrivateKey_bio(BIO *bp, RSA *rsa) { return ASN1_item_i2d_bio(ASN1_ITEM_rptr(RSAPrivateKey), bp, rsa); } RSA * d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa) { return ASN1_item_d2i_bio(ASN1_ITEM_rptr(RSAPublicKey), bp, rsa); } RSA * d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa) { return ASN1_d2i_bio_of(RSA, RSA_new, d2i_RSA_PUBKEY, bp, rsa); } int i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa) { return ASN1_item_i2d_bio(ASN1_ITEM_rptr(RSAPublicKey), bp, rsa); } int i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa) { return ASN1_i2d_bio_of(RSA, i2d_RSA_PUBKEY, bp, rsa); } #endif #ifndef OPENSSL_NO_DSA DSA * d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa) { return ASN1_d2i_fp_of(DSA, DSA_new, d2i_DSAPrivateKey, fp, dsa); } int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa) { return ASN1_i2d_fp_of_const(DSA, i2d_DSAPrivateKey, fp, dsa); } DSA * d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa) { return ASN1_d2i_fp_of(DSA, DSA_new, d2i_DSA_PUBKEY, fp, dsa); } int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa) { return ASN1_i2d_fp_of(DSA, i2d_DSA_PUBKEY, fp, dsa); } DSA * d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa) { return ASN1_d2i_bio_of(DSA, DSA_new, d2i_DSAPrivateKey, bp, dsa); } int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa) { return ASN1_i2d_bio_of_const(DSA, i2d_DSAPrivateKey, bp, dsa); } DSA * d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa) { return ASN1_d2i_bio_of(DSA, DSA_new, d2i_DSA_PUBKEY, bp, dsa); } int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa) { return ASN1_i2d_bio_of(DSA, i2d_DSA_PUBKEY, bp, dsa); } #endif #ifndef OPENSSL_NO_EC EC_KEY * d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey) { return ASN1_d2i_fp_of(EC_KEY, EC_KEY_new, d2i_EC_PUBKEY, fp, eckey); } int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey) { return ASN1_i2d_fp_of(EC_KEY, i2d_EC_PUBKEY, fp, eckey); } EC_KEY * d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey) { return ASN1_d2i_fp_of(EC_KEY, EC_KEY_new, d2i_ECPrivateKey, fp, eckey); } int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey) { return ASN1_i2d_fp_of(EC_KEY, i2d_ECPrivateKey, fp, eckey); } EC_KEY * d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey) { return ASN1_d2i_bio_of(EC_KEY, EC_KEY_new, d2i_EC_PUBKEY, bp, eckey); } int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *ecdsa) { return ASN1_i2d_bio_of(EC_KEY, i2d_EC_PUBKEY, bp, ecdsa); } EC_KEY * d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey) { return ASN1_d2i_bio_of(EC_KEY, EC_KEY_new, d2i_ECPrivateKey, bp, eckey); } int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey) { return ASN1_i2d_bio_of(EC_KEY, i2d_ECPrivateKey, bp, eckey); } #endif int X509_pubkey_digest(const X509 *data, const EVP_MD *type, unsigned char *md, unsigned int *len) { ASN1_BIT_STRING *key; key = X509_get0_pubkey_bitstr(data); if (!key) return 0; return EVP_Digest(key->data, key->length, md, len, type, NULL); } int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md, unsigned int *len) { return (ASN1_item_digest(ASN1_ITEM_rptr(X509), type, (char *)data, md, len)); } int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, unsigned char *md, unsigned int *len) { return (ASN1_item_digest(ASN1_ITEM_rptr(X509_CRL), type, (char *)data, md, len)); } int X509_REQ_digest(const X509_REQ *data, const EVP_MD *type, unsigned char *md, unsigned int *len) { return (ASN1_item_digest(ASN1_ITEM_rptr(X509_REQ), type, (char *)data, md, len)); } int X509_NAME_digest(const X509_NAME *data, const EVP_MD *type, unsigned char *md, unsigned int *len) { return (ASN1_item_digest(ASN1_ITEM_rptr(X509_NAME), type, (char *)data, md, len)); } int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, const EVP_MD *type, unsigned char *md, unsigned int *len) { return(ASN1_item_digest(ASN1_ITEM_rptr(PKCS7_ISSUER_AND_SERIAL), type, (char *)data, md, len)); } X509_SIG * d2i_PKCS8_fp(FILE *fp, X509_SIG **p8) { return ASN1_d2i_fp_of(X509_SIG, X509_SIG_new, d2i_X509_SIG, fp, p8); } int i2d_PKCS8_fp(FILE *fp, X509_SIG *p8) { return ASN1_i2d_fp_of(X509_SIG, i2d_X509_SIG, fp, p8); } X509_SIG * d2i_PKCS8_bio(BIO *bp, X509_SIG **p8) { return ASN1_d2i_bio_of(X509_SIG, X509_SIG_new, d2i_X509_SIG, bp, p8); } int i2d_PKCS8_bio(BIO *bp, X509_SIG *p8) { return ASN1_i2d_bio_of(X509_SIG, i2d_X509_SIG, bp, p8); } PKCS8_PRIV_KEY_INFO * d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO **p8inf) { return ASN1_d2i_fp_of(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO_new, d2i_PKCS8_PRIV_KEY_INFO, fp, p8inf); } int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf) { return ASN1_i2d_fp_of(PKCS8_PRIV_KEY_INFO, i2d_PKCS8_PRIV_KEY_INFO, fp, p8inf); } int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key) { PKCS8_PRIV_KEY_INFO *p8inf; int ret; p8inf = EVP_PKEY2PKCS8(key); if (!p8inf) return 0; ret = i2d_PKCS8_PRIV_KEY_INFO_fp(fp, p8inf); PKCS8_PRIV_KEY_INFO_free(p8inf); return ret; } int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey) { return ASN1_i2d_fp_of(EVP_PKEY, i2d_PrivateKey, fp, pkey); } EVP_PKEY * d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a) { return ASN1_d2i_fp_of(EVP_PKEY, EVP_PKEY_new, d2i_AutoPrivateKey, fp, a); } int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey) { return ASN1_i2d_fp_of(EVP_PKEY, i2d_PUBKEY, fp, pkey); } EVP_PKEY * d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a) { return ASN1_d2i_fp_of(EVP_PKEY, EVP_PKEY_new, d2i_PUBKEY, fp, a); } PKCS8_PRIV_KEY_INFO * d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO **p8inf) { return ASN1_d2i_bio_of(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO_new, d2i_PKCS8_PRIV_KEY_INFO, bp, p8inf); } int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf) { return ASN1_i2d_bio_of(PKCS8_PRIV_KEY_INFO, i2d_PKCS8_PRIV_KEY_INFO, bp, p8inf); } int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key) { PKCS8_PRIV_KEY_INFO *p8inf; int ret; p8inf = EVP_PKEY2PKCS8(key); if (!p8inf) return 0; ret = i2d_PKCS8_PRIV_KEY_INFO_bio(bp, p8inf); PKCS8_PRIV_KEY_INFO_free(p8inf); return ret; } int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey) { return ASN1_i2d_bio_of(EVP_PKEY, i2d_PrivateKey, bp, pkey); } EVP_PKEY * d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a) { return ASN1_d2i_bio_of(EVP_PKEY, EVP_PKEY_new, d2i_AutoPrivateKey, bp, a); } int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey) { return ASN1_i2d_bio_of(EVP_PKEY, i2d_PUBKEY, bp, pkey); } EVP_PKEY * d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a) { return ASN1_d2i_bio_of(EVP_PKEY, EVP_PKEY_new, d2i_PUBKEY, bp, a); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_cmp.c0000644000175000017500000002272612360020706020502 0ustar /* $OpenBSD: x509_cmp.c,v 1.21 2014/07/10 22:45:58 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #include int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b) { int i; X509_CINF *ai, *bi; ai = a->cert_info; bi = b->cert_info; i = M_ASN1_INTEGER_cmp(ai->serialNumber, bi->serialNumber); if (i) return (i); return (X509_NAME_cmp(ai->issuer, bi->issuer)); } #ifndef OPENSSL_NO_MD5 unsigned long X509_issuer_and_serial_hash(X509 *a) { unsigned long ret = 0; EVP_MD_CTX ctx; unsigned char md[16]; char *f; EVP_MD_CTX_init(&ctx); f = X509_NAME_oneline(a->cert_info->issuer, NULL, 0); if (!EVP_DigestInit_ex(&ctx, EVP_md5(), NULL)) goto err; if (!EVP_DigestUpdate(&ctx, (unsigned char *)f, strlen(f))) goto err; free(f); if (!EVP_DigestUpdate(&ctx, (unsigned char *)a->cert_info->serialNumber->data, (unsigned long)a->cert_info->serialNumber->length)) goto err; if (!EVP_DigestFinal_ex(&ctx, &(md[0]), NULL)) goto err; ret = (((unsigned long)md[0]) | ((unsigned long)md[1] << 8L) | ((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)) & 0xffffffffL; err: EVP_MD_CTX_cleanup(&ctx); return (ret); } #endif int X509_issuer_name_cmp(const X509 *a, const X509 *b) { return (X509_NAME_cmp(a->cert_info->issuer, b->cert_info->issuer)); } int X509_subject_name_cmp(const X509 *a, const X509 *b) { return (X509_NAME_cmp(a->cert_info->subject, b->cert_info->subject)); } int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b) { return (X509_NAME_cmp(a->crl->issuer, b->crl->issuer)); } #ifndef OPENSSL_NO_SHA int X509_CRL_match(const X509_CRL *a, const X509_CRL *b) { return memcmp(a->sha1_hash, b->sha1_hash, 20); } #endif X509_NAME * X509_get_issuer_name(X509 *a) { return (a->cert_info->issuer); } unsigned long X509_issuer_name_hash(X509 *x) { return (X509_NAME_hash(x->cert_info->issuer)); } #ifndef OPENSSL_NO_MD5 unsigned long X509_issuer_name_hash_old(X509 *x) { return (X509_NAME_hash_old(x->cert_info->issuer)); } #endif X509_NAME * X509_get_subject_name(X509 *a) { return (a->cert_info->subject); } ASN1_INTEGER * X509_get_serialNumber(X509 *a) { return (a->cert_info->serialNumber); } unsigned long X509_subject_name_hash(X509 *x) { return (X509_NAME_hash(x->cert_info->subject)); } #ifndef OPENSSL_NO_MD5 unsigned long X509_subject_name_hash_old(X509 *x) { return (X509_NAME_hash_old(x->cert_info->subject)); } #endif #ifndef OPENSSL_NO_SHA /* Compare two certificates: they must be identical for * this to work. NB: Although "cmp" operations are generally * prototyped to take "const" arguments (eg. for use in * STACKs), the way X509 handling is - these operations may * involve ensuring the hashes are up-to-date and ensuring * certain cert information is cached. So this is the point * where the "depth-first" constification tree has to halt * with an evil cast. */ int X509_cmp(const X509 *a, const X509 *b) { /* ensure hash is valid */ X509_check_purpose((X509 *)a, -1, 0); X509_check_purpose((X509 *)b, -1, 0); return memcmp(a->sha1_hash, b->sha1_hash, SHA_DIGEST_LENGTH); } #endif int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b) { int ret; /* Ensure canonical encoding is present and up to date */ if (!a->canon_enc || a->modified) { ret = i2d_X509_NAME((X509_NAME *)a, NULL); if (ret < 0) return -2; } if (!b->canon_enc || b->modified) { ret = i2d_X509_NAME((X509_NAME *)b, NULL); if (ret < 0) return -2; } ret = a->canon_enclen - b->canon_enclen; if (ret) return ret; return memcmp(a->canon_enc, b->canon_enc, a->canon_enclen); } unsigned long X509_NAME_hash(X509_NAME *x) { unsigned long ret = 0; unsigned char md[SHA_DIGEST_LENGTH]; /* Make sure X509_NAME structure contains valid cached encoding */ i2d_X509_NAME(x, NULL); if (!EVP_Digest(x->canon_enc, x->canon_enclen, md, NULL, EVP_sha1(), NULL)) return 0; ret = (((unsigned long)md[0]) | ((unsigned long)md[1] << 8L) | ((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)) & 0xffffffffL; return (ret); } #ifndef OPENSSL_NO_MD5 /* I now DER encode the name and hash it. Since I cache the DER encoding, * this is reasonably efficient. */ unsigned long X509_NAME_hash_old(X509_NAME *x) { EVP_MD_CTX md_ctx; unsigned long ret = 0; unsigned char md[16]; /* Make sure X509_NAME structure contains valid cached encoding */ i2d_X509_NAME(x, NULL); EVP_MD_CTX_init(&md_ctx); if (EVP_DigestInit_ex(&md_ctx, EVP_md5(), NULL) && EVP_DigestUpdate(&md_ctx, x->bytes->data, x->bytes->length) && EVP_DigestFinal_ex(&md_ctx, md, NULL)) ret = (((unsigned long)md[0]) | ((unsigned long)md[1] << 8L) | ((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)) & 0xffffffffL; EVP_MD_CTX_cleanup(&md_ctx); return (ret); } #endif /* Search a stack of X509 for a match */ X509 * X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name, ASN1_INTEGER *serial) { int i; X509_CINF cinf; X509 x, *x509 = NULL; if (!sk) return NULL; x.cert_info = &cinf; cinf.serialNumber = serial; cinf.issuer = name; for (i = 0; i < sk_X509_num(sk); i++) { x509 = sk_X509_value(sk, i); if (X509_issuer_and_serial_cmp(x509, &x) == 0) return (x509); } return (NULL); } X509 * X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name) { X509 *x509; int i; for (i = 0; i < sk_X509_num(sk); i++) { x509 = sk_X509_value(sk, i); if (X509_NAME_cmp(X509_get_subject_name(x509), name) == 0) return (x509); } return (NULL); } EVP_PKEY * X509_get_pubkey(X509 *x) { if ((x == NULL) || (x->cert_info == NULL)) return (NULL); return (X509_PUBKEY_get(x->cert_info->key)); } ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x) { if (!x) return NULL; return x->cert_info->key->public_key; } int X509_check_private_key(X509 *x, EVP_PKEY *k) { EVP_PKEY *xk; int ret; xk = X509_get_pubkey(x); if (xk) ret = EVP_PKEY_cmp(xk, k); else ret = -2; switch (ret) { case 1: break; case 0: X509err(X509_F_X509_CHECK_PRIVATE_KEY, X509_R_KEY_VALUES_MISMATCH); break; case -1: X509err(X509_F_X509_CHECK_PRIVATE_KEY, X509_R_KEY_TYPE_MISMATCH); break; case -2: X509err(X509_F_X509_CHECK_PRIVATE_KEY, X509_R_UNKNOWN_KEY_TYPE); } if (xk) EVP_PKEY_free(xk); if (ret > 0) return 1; return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_req.c0000644000175000017500000002243212360020706020504 0ustar /* $OpenBSD: x509_req.c,v 1.14 2014/07/10 22:45:58 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #include #include #include X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md) { X509_REQ *ret; X509_REQ_INFO *ri; int i; EVP_PKEY *pktmp; ret = X509_REQ_new(); if (ret == NULL) { X509err(X509_F_X509_TO_X509_REQ, ERR_R_MALLOC_FAILURE); goto err; } ri = ret->req_info; ri->version->length = 1; ri->version->data = malloc(1); if (ri->version->data == NULL) goto err; ri->version->data[0] = 0; /* version == 0 */ if (!X509_REQ_set_subject_name(ret, X509_get_subject_name(x))) goto err; pktmp = X509_get_pubkey(x); i = X509_REQ_set_pubkey(ret, pktmp); EVP_PKEY_free(pktmp); if (!i) goto err; if (pkey != NULL) { if (!X509_REQ_sign(ret, pkey, md)) goto err; } return (ret); err: X509_REQ_free(ret); return (NULL); } EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req) { if ((req == NULL) || (req->req_info == NULL)) return (NULL); return (X509_PUBKEY_get(req->req_info->pubkey)); } int X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k) { EVP_PKEY *xk = NULL; int ok = 0; xk = X509_REQ_get_pubkey(x); switch (EVP_PKEY_cmp(xk, k)) { case 1: ok = 1; break; case 0: X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY, X509_R_KEY_VALUES_MISMATCH); break; case -1: X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY, X509_R_KEY_TYPE_MISMATCH); break; case -2: #ifndef OPENSSL_NO_EC if (k->type == EVP_PKEY_EC) { X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY, ERR_R_EC_LIB); break; } #endif #ifndef OPENSSL_NO_DH if (k->type == EVP_PKEY_DH) { /* No idea */ X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY, X509_R_CANT_CHECK_DH_KEY); break; } #endif X509err(X509_F_X509_REQ_CHECK_PRIVATE_KEY, X509_R_UNKNOWN_KEY_TYPE); } EVP_PKEY_free(xk); return (ok); } /* It seems several organisations had the same idea of including a list of * extensions in a certificate request. There are at least two OIDs that are * used and there may be more: so the list is configurable. */ static int ext_nid_list[] = {NID_ext_req, NID_ms_ext_req, NID_undef}; static int *ext_nids = ext_nid_list; int X509_REQ_extension_nid(int req_nid) { int i, nid; for (i = 0; ; i++) { nid = ext_nids[i]; if (nid == NID_undef) return 0; else if (req_nid == nid) return 1; } } int * X509_REQ_get_extension_nids(void) { return ext_nids; } void X509_REQ_set_extension_nids(int *nids) { ext_nids = nids; } STACK_OF(X509_EXTENSION) * X509_REQ_get_extensions(X509_REQ *req) { X509_ATTRIBUTE *attr; ASN1_TYPE *ext = NULL; int idx, *pnid; const unsigned char *p; if ((req == NULL) || (req->req_info == NULL) || !ext_nids) return (NULL); for (pnid = ext_nids; *pnid != NID_undef; pnid++) { idx = X509_REQ_get_attr_by_NID(req, *pnid, -1); if (idx == -1) continue; attr = X509_REQ_get_attr(req, idx); if (attr->single) ext = attr->value.single; else if (sk_ASN1_TYPE_num(attr->value.set)) ext = sk_ASN1_TYPE_value(attr->value.set, 0); break; } if (!ext || (ext->type != V_ASN1_SEQUENCE)) return NULL; p = ext->value.sequence->data; return (STACK_OF(X509_EXTENSION) *)ASN1_item_d2i(NULL, &p, ext->value.sequence->length, ASN1_ITEM_rptr(X509_EXTENSIONS)); } /* Add a STACK_OF extensions to a certificate request: allow alternative OIDs * in case we want to create a non standard one. */ int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts, int nid) { ASN1_TYPE *at = NULL; X509_ATTRIBUTE *attr = NULL; if (!(at = ASN1_TYPE_new()) || !(at->value.sequence = ASN1_STRING_new())) goto err; at->type = V_ASN1_SEQUENCE; /* Generate encoding of extensions */ at->value.sequence->length = ASN1_item_i2d((ASN1_VALUE *)exts, &at->value.sequence->data, ASN1_ITEM_rptr(X509_EXTENSIONS)); if (!(attr = X509_ATTRIBUTE_new())) goto err; if (!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err; if (!sk_ASN1_TYPE_push(attr->value.set, at)) goto err; at = NULL; attr->single = 0; attr->object = OBJ_nid2obj(nid); if (!req->req_info->attributes) { if (!(req->req_info->attributes = sk_X509_ATTRIBUTE_new_null())) goto err; } if (!sk_X509_ATTRIBUTE_push(req->req_info->attributes, attr)) goto err; return 1; err: X509_ATTRIBUTE_free(attr); ASN1_TYPE_free(at); return 0; } /* This is the normal usage: use the "official" OID */ int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts) { return X509_REQ_add_extensions_nid(req, exts, NID_ext_req); } /* Request attribute functions */ int X509_REQ_get_attr_count(const X509_REQ *req) { return X509at_get_attr_count(req->req_info->attributes); } int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos) { return X509at_get_attr_by_NID(req->req_info->attributes, nid, lastpos); } int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj, int lastpos) { return X509at_get_attr_by_OBJ(req->req_info->attributes, obj, lastpos); } X509_ATTRIBUTE * X509_REQ_get_attr(const X509_REQ *req, int loc) { return X509at_get_attr(req->req_info->attributes, loc); } X509_ATTRIBUTE * X509_REQ_delete_attr(X509_REQ *req, int loc) { return X509at_delete_attr(req->req_info->attributes, loc); } int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr) { if (X509at_add1_attr(&req->req_info->attributes, attr)) return 1; return 0; } int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, const ASN1_OBJECT *obj, int type, const unsigned char *bytes, int len) { if (X509at_add1_attr_by_OBJ(&req->req_info->attributes, obj, type, bytes, len)) return 1; return 0; } int X509_REQ_add1_attr_by_NID(X509_REQ *req, int nid, int type, const unsigned char *bytes, int len) { if (X509at_add1_attr_by_NID(&req->req_info->attributes, nid, type, bytes, len)) return 1; return 0; } int X509_REQ_add1_attr_by_txt(X509_REQ *req, const char *attrname, int type, const unsigned char *bytes, int len) { if (X509at_add1_attr_by_txt(&req->req_info->attributes, attrname, type, bytes, len)) return 1; return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/by_file.c0000644000175000017500000001760512360020706020547 0ustar /* $OpenBSD: by_file.c,v 1.14 2014/07/10 13:58:23 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #include static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret); X509_LOOKUP_METHOD x509_file_lookup = { "Load file into cache", NULL, /* new */ NULL, /* free */ NULL, /* init */ NULL, /* shutdown */ by_file_ctrl, /* ctrl */ NULL, /* get_by_subject */ NULL, /* get_by_issuer_serial */ NULL, /* get_by_fingerprint */ NULL, /* get_by_alias */ }; X509_LOOKUP_METHOD * X509_LOOKUP_file(void) { return (&x509_file_lookup); } static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl, char **ret) { int ok = 0; char *file = NULL; switch (cmd) { case X509_L_FILE_LOAD: if (argl == X509_FILETYPE_DEFAULT) { if (issetugid() == 0) file = getenv(X509_get_default_cert_file_env()); if (file) ok = (X509_load_cert_crl_file(ctx, file, X509_FILETYPE_PEM) != 0); else ok = (X509_load_cert_crl_file(ctx, X509_get_default_cert_file(), X509_FILETYPE_PEM) != 0); if (!ok) { X509err(X509_F_BY_FILE_CTRL, X509_R_LOADING_DEFAULTS); } } else { if (argl == X509_FILETYPE_PEM) ok = (X509_load_cert_crl_file(ctx, argp, X509_FILETYPE_PEM) != 0); else ok = (X509_load_cert_file(ctx, argp, (int)argl) != 0); } break; } return (ok); } int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type) { int ret = 0; BIO *in = NULL; int i, count = 0; X509 *x = NULL; if (file == NULL) return (1); in = BIO_new(BIO_s_file_internal()); if ((in == NULL) || (BIO_read_filename(in, file) <= 0)) { X509err(X509_F_X509_LOAD_CERT_FILE, ERR_R_SYS_LIB); goto err; } if (type == X509_FILETYPE_PEM) { for (;;) { x = PEM_read_bio_X509_AUX(in, NULL, NULL, NULL); if (x == NULL) { if ((ERR_GET_REASON(ERR_peek_last_error()) == PEM_R_NO_START_LINE) && (count > 0)) { ERR_clear_error(); break; } else { X509err(X509_F_X509_LOAD_CERT_FILE, ERR_R_PEM_LIB); goto err; } } i = X509_STORE_add_cert(ctx->store_ctx, x); if (!i) goto err; count++; X509_free(x); x = NULL; } ret = count; } else if (type == X509_FILETYPE_ASN1) { x = d2i_X509_bio(in, NULL); if (x == NULL) { X509err(X509_F_X509_LOAD_CERT_FILE, ERR_R_ASN1_LIB); goto err; } i = X509_STORE_add_cert(ctx->store_ctx, x); if (!i) goto err; ret = i; } else { X509err(X509_F_X509_LOAD_CERT_FILE, X509_R_BAD_X509_FILETYPE); goto err; } err: if (x != NULL) X509_free(x); if (in != NULL) BIO_free(in); return (ret); } int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type) { int ret = 0; BIO *in = NULL; int i, count = 0; X509_CRL *x = NULL; if (file == NULL) return (1); in = BIO_new(BIO_s_file_internal()); if ((in == NULL) || (BIO_read_filename(in, file) <= 0)) { X509err(X509_F_X509_LOAD_CRL_FILE, ERR_R_SYS_LIB); goto err; } if (type == X509_FILETYPE_PEM) { for (;;) { x = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL); if (x == NULL) { if ((ERR_GET_REASON(ERR_peek_last_error()) == PEM_R_NO_START_LINE) && (count > 0)) { ERR_clear_error(); break; } else { X509err(X509_F_X509_LOAD_CRL_FILE, ERR_R_PEM_LIB); goto err; } } i = X509_STORE_add_crl(ctx->store_ctx, x); if (!i) goto err; count++; X509_CRL_free(x); x = NULL; } ret = count; } else if (type == X509_FILETYPE_ASN1) { x = d2i_X509_CRL_bio(in, NULL); if (x == NULL) { X509err(X509_F_X509_LOAD_CRL_FILE, ERR_R_ASN1_LIB); goto err; } i = X509_STORE_add_crl(ctx->store_ctx, x); if (!i) goto err; ret = i; } else { X509err(X509_F_X509_LOAD_CRL_FILE, X509_R_BAD_X509_FILETYPE); goto err; } err: if (x != NULL) X509_CRL_free(x); if (in != NULL) BIO_free(in); return (ret); } int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type) { STACK_OF(X509_INFO) *inf; X509_INFO *itmp; BIO *in; int i, count = 0; if (type != X509_FILETYPE_PEM) return X509_load_cert_file(ctx, file, type); in = BIO_new_file(file, "r"); if (!in) { X509err(X509_F_X509_LOAD_CERT_CRL_FILE, ERR_R_SYS_LIB); return 0; } inf = PEM_X509_INFO_read_bio(in, NULL, NULL, NULL); BIO_free(in); if (!inf) { X509err(X509_F_X509_LOAD_CERT_CRL_FILE, ERR_R_PEM_LIB); return 0; } for (i = 0; i < sk_X509_INFO_num(inf); i++) { itmp = sk_X509_INFO_value(inf, i); if (itmp->x509) { X509_STORE_add_cert(ctx->store_ctx, itmp->x509); count++; } if (itmp->crl) { X509_STORE_add_crl(ctx->store_ctx, itmp->crl); count++; } } sk_X509_INFO_pop_free(inf, X509_INFO_free); return count; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_set.c0000644000175000017500000001212412360020706020505 0ustar /* $OpenBSD: x509_set.c,v 1.8 2014/06/12 15:49:31 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include int X509_set_version(X509 *x, long version) { if (x == NULL) return (0); if (x->cert_info->version == NULL) { if ((x->cert_info->version = M_ASN1_INTEGER_new()) == NULL) return (0); } return (ASN1_INTEGER_set(x->cert_info->version, version)); } int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial) { ASN1_INTEGER *in; if (x == NULL) return (0); in = x->cert_info->serialNumber; if (in != serial) { in = M_ASN1_INTEGER_dup(serial); if (in != NULL) { M_ASN1_INTEGER_free(x->cert_info->serialNumber); x->cert_info->serialNumber = in; } } return (in != NULL); } int X509_set_issuer_name(X509 *x, X509_NAME *name) { if ((x == NULL) || (x->cert_info == NULL)) return (0); return (X509_NAME_set(&x->cert_info->issuer, name)); } int X509_set_subject_name(X509 *x, X509_NAME *name) { if ((x == NULL) || (x->cert_info == NULL)) return (0); return (X509_NAME_set(&x->cert_info->subject, name)); } int X509_set_notBefore(X509 *x, const ASN1_TIME *tm) { ASN1_TIME *in; if ((x == NULL) || (x->cert_info->validity == NULL)) return (0); in = x->cert_info->validity->notBefore; if (in != tm) { in = M_ASN1_TIME_dup(tm); if (in != NULL) { M_ASN1_TIME_free(x->cert_info->validity->notBefore); x->cert_info->validity->notBefore = in; } } return (in != NULL); } int X509_set_notAfter(X509 *x, const ASN1_TIME *tm) { ASN1_TIME *in; if ((x == NULL) || (x->cert_info->validity == NULL)) return (0); in = x->cert_info->validity->notAfter; if (in != tm) { in = M_ASN1_TIME_dup(tm); if (in != NULL) { M_ASN1_TIME_free(x->cert_info->validity->notAfter); x->cert_info->validity->notAfter = in; } } return (in != NULL); } int X509_set_pubkey(X509 *x, EVP_PKEY *pkey) { if ((x == NULL) || (x->cert_info == NULL)) return (0); return (X509_PUBKEY_set(&(x->cert_info->key), pkey)); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/x509_txt.c0000644000175000017500000002027012360020706020532 0ustar /* $OpenBSD: x509_txt.c,v 1.18 2014/06/12 15:49:31 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #include const char * X509_verify_cert_error_string(long n) { static char buf[100]; switch ((int)n) { case X509_V_OK: return("ok"); case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: return("unable to get issuer certificate"); case X509_V_ERR_UNABLE_TO_GET_CRL: return("unable to get certificate CRL"); case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: return("unable to decrypt certificate's signature"); case X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: return("unable to decrypt CRL's signature"); case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: return("unable to decode issuer public key"); case X509_V_ERR_CERT_SIGNATURE_FAILURE: return("certificate signature failure"); case X509_V_ERR_CRL_SIGNATURE_FAILURE: return("CRL signature failure"); case X509_V_ERR_CERT_NOT_YET_VALID: return("certificate is not yet valid"); case X509_V_ERR_CRL_NOT_YET_VALID: return("CRL is not yet valid"); case X509_V_ERR_CERT_HAS_EXPIRED: return("certificate has expired"); case X509_V_ERR_CRL_HAS_EXPIRED: return("CRL has expired"); case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: return("format error in certificate's notBefore field"); case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: return("format error in certificate's notAfter field"); case X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: return("format error in CRL's lastUpdate field"); case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: return("format error in CRL's nextUpdate field"); case X509_V_ERR_OUT_OF_MEM: return("out of memory"); case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: return("self signed certificate"); case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: return("self signed certificate in certificate chain"); case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: return("unable to get local issuer certificate"); case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: return("unable to verify the first certificate"); case X509_V_ERR_CERT_CHAIN_TOO_LONG: return("certificate chain too long"); case X509_V_ERR_CERT_REVOKED: return("certificate revoked"); case X509_V_ERR_INVALID_CA: return ("invalid CA certificate"); case X509_V_ERR_INVALID_NON_CA: return ("invalid non-CA certificate (has CA markings)"); case X509_V_ERR_PATH_LENGTH_EXCEEDED: return ("path length constraint exceeded"); case X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED: return("proxy path length constraint exceeded"); case X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED: return("proxy certificates not allowed, please set the appropriate flag"); case X509_V_ERR_INVALID_PURPOSE: return ("unsupported certificate purpose"); case X509_V_ERR_CERT_UNTRUSTED: return ("certificate not trusted"); case X509_V_ERR_CERT_REJECTED: return ("certificate rejected"); case X509_V_ERR_APPLICATION_VERIFICATION: return("application verification failure"); case X509_V_ERR_SUBJECT_ISSUER_MISMATCH: return("subject issuer mismatch"); case X509_V_ERR_AKID_SKID_MISMATCH: return("authority and subject key identifier mismatch"); case X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: return("authority and issuer serial number mismatch"); case X509_V_ERR_KEYUSAGE_NO_CERTSIGN: return("key usage does not include certificate signing"); case X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER: return("unable to get CRL issuer certificate"); case X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION: return("unhandled critical extension"); case X509_V_ERR_KEYUSAGE_NO_CRL_SIGN: return("key usage does not include CRL signing"); case X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE: return("key usage does not include digital signature"); case X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION: return("unhandled critical CRL extension"); case X509_V_ERR_INVALID_EXTENSION: return("invalid or inconsistent certificate extension"); case X509_V_ERR_INVALID_POLICY_EXTENSION: return("invalid or inconsistent certificate policy extension"); case X509_V_ERR_NO_EXPLICIT_POLICY: return("no explicit policy"); case X509_V_ERR_DIFFERENT_CRL_SCOPE: return("Different CRL scope"); case X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE: return("Unsupported extension feature"); case X509_V_ERR_UNNESTED_RESOURCE: return("RFC 3779 resource not subset of parent's resources"); case X509_V_ERR_PERMITTED_VIOLATION: return("permitted subtree violation"); case X509_V_ERR_EXCLUDED_VIOLATION: return("excluded subtree violation"); case X509_V_ERR_SUBTREE_MINMAX: return("name constraints minimum and maximum not supported"); case X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE: return("unsupported name constraint type"); case X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX: return("unsupported or invalid name constraint syntax"); case X509_V_ERR_UNSUPPORTED_NAME_SYNTAX: return("unsupported or invalid name syntax"); case X509_V_ERR_CRL_PATH_VALIDATION_ERROR: return("CRL path validation error"); default: (void) snprintf(buf, sizeof buf, "error number %ld", n); return(buf); } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509/by_dir.c0000644000175000017500000002632212360020706020402 0ustar /* $OpenBSD: by_dir.c,v 1.31 2014/07/10 22:45:58 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_POSIX_IO # include #endif typedef struct lookup_dir_hashes_st { unsigned long hash; int suffix; } BY_DIR_HASH; typedef struct lookup_dir_entry_st { char *dir; int dir_type; STACK_OF(BY_DIR_HASH) *hashes; } BY_DIR_ENTRY; typedef struct lookup_dir_st { BUF_MEM *buffer; STACK_OF(BY_DIR_ENTRY) *dirs; } BY_DIR; DECLARE_STACK_OF(BY_DIR_HASH) DECLARE_STACK_OF(BY_DIR_ENTRY) static int dir_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl, char **ret); static int new_dir(X509_LOOKUP *lu); static void free_dir(X509_LOOKUP *lu); static int add_cert_dir(BY_DIR *ctx, const char *dir, int type); static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name, X509_OBJECT *ret); X509_LOOKUP_METHOD x509_dir_lookup = { "Load certs from files in a directory", new_dir, /* new */ free_dir, /* free */ NULL, /* init */ NULL, /* shutdown */ dir_ctrl, /* ctrl */ get_cert_by_subject, /* get_by_subject */ NULL, /* get_by_issuer_serial */ NULL, /* get_by_fingerprint */ NULL, /* get_by_alias */ }; X509_LOOKUP_METHOD * X509_LOOKUP_hash_dir(void) { return (&x509_dir_lookup); } static int dir_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl, char **retp) { int ret = 0; BY_DIR *ld; char *dir = NULL; ld = (BY_DIR *)ctx->method_data; switch (cmd) { case X509_L_ADD_DIR: if (argl == X509_FILETYPE_DEFAULT) { if (issetugid() == 0) dir = getenv(X509_get_default_cert_dir_env()); if (dir) ret = add_cert_dir(ld, dir, X509_FILETYPE_PEM); else ret = add_cert_dir(ld, X509_get_default_cert_dir(), X509_FILETYPE_PEM); if (!ret) { X509err(X509_F_DIR_CTRL, X509_R_LOADING_CERT_DIR); } } else ret = add_cert_dir(ld, argp, (int)argl); break; } return (ret); } static int new_dir(X509_LOOKUP *lu) { BY_DIR *a; if ((a = malloc(sizeof(BY_DIR))) == NULL) return (0); if ((a->buffer = BUF_MEM_new()) == NULL) { free(a); return (0); } a->dirs = NULL; lu->method_data = (char *)a; return (1); } static void by_dir_hash_free(BY_DIR_HASH *hash) { free(hash); } static int by_dir_hash_cmp(const BY_DIR_HASH * const *a, const BY_DIR_HASH * const *b) { if ((*a)->hash > (*b)->hash) return 1; if ((*a)->hash < (*b)->hash) return -1; return 0; } static void by_dir_entry_free(BY_DIR_ENTRY *ent) { free(ent->dir); if (ent->hashes) sk_BY_DIR_HASH_pop_free(ent->hashes, by_dir_hash_free); free(ent); } static void free_dir(X509_LOOKUP *lu) { BY_DIR *a; a = (BY_DIR *)lu->method_data; if (a->dirs != NULL) sk_BY_DIR_ENTRY_pop_free(a->dirs, by_dir_entry_free); if (a->buffer != NULL) BUF_MEM_free(a->buffer); free(a); } static int add_cert_dir(BY_DIR *ctx, const char *dir, int type) { int j, len; const char *s, *ss, *p; if (dir == NULL || !*dir) { X509err(X509_F_ADD_CERT_DIR, X509_R_INVALID_DIRECTORY); return 0; } s = dir; p = s; do { if ((*p == ':') || (*p == '\0')) { BY_DIR_ENTRY *ent; ss = s; s = p + 1; len = (int)(p - ss); if (len == 0) continue; for (j = 0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++) { ent = sk_BY_DIR_ENTRY_value(ctx->dirs, j); if (strlen(ent->dir) == (size_t)len && strncmp(ent->dir, ss, (unsigned int)len) == 0) break; } if (j < sk_BY_DIR_ENTRY_num(ctx->dirs)) continue; if (ctx->dirs == NULL) { ctx->dirs = sk_BY_DIR_ENTRY_new_null(); if (!ctx->dirs) { X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE); return 0; } } ent = malloc(sizeof(BY_DIR_ENTRY)); if (!ent) { X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE); return 0; } ent->dir_type = type; ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp); ent->dir = strdup(ss); if (!ent->dir || !ent->hashes) { X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE); by_dir_entry_free(ent); return 0; } if (!sk_BY_DIR_ENTRY_push(ctx->dirs, ent)) { X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE); by_dir_entry_free(ent); return 0; } } } while (*p++ != '\0'); return 1; } static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name, X509_OBJECT *ret) { BY_DIR *ctx; union { struct { X509 st_x509; X509_CINF st_x509_cinf; } x509; struct { X509_CRL st_crl; X509_CRL_INFO st_crl_info; } crl; } data; int ok = 0; int i, j, k; unsigned long h; BUF_MEM *b = NULL; X509_OBJECT stmp, *tmp; const char *postfix=""; if (name == NULL) return (0); stmp.type = type; if (type == X509_LU_X509) { data.x509.st_x509.cert_info = &data.x509.st_x509_cinf; data.x509.st_x509_cinf.subject = name; stmp.data.x509 = &data.x509.st_x509; postfix=""; } else if (type == X509_LU_CRL) { data.crl.st_crl.crl = &data.crl.st_crl_info; data.crl.st_crl_info.issuer = name; stmp.data.crl = &data.crl.st_crl; postfix="r"; } else { X509err(X509_F_GET_CERT_BY_SUBJECT, X509_R_WRONG_LOOKUP_TYPE); goto finish; } if ((b = BUF_MEM_new()) == NULL) { X509err(X509_F_GET_CERT_BY_SUBJECT, ERR_R_BUF_LIB); goto finish; } ctx = (BY_DIR *)xl->method_data; h = X509_NAME_hash(name); for (i = 0; i < sk_BY_DIR_ENTRY_num(ctx->dirs); i++) { BY_DIR_ENTRY *ent; int idx; BY_DIR_HASH htmp, *hent; ent = sk_BY_DIR_ENTRY_value(ctx->dirs, i); j = strlen(ent->dir) + 1 + 8 + 6 + 1 + 1; if (!BUF_MEM_grow(b, j)) { X509err(X509_F_GET_CERT_BY_SUBJECT, ERR_R_MALLOC_FAILURE); goto finish; } if (type == X509_LU_CRL && ent->hashes) { htmp.hash = h; CRYPTO_r_lock(CRYPTO_LOCK_X509_STORE); idx = sk_BY_DIR_HASH_find(ent->hashes, &htmp); if (idx >= 0) { hent = sk_BY_DIR_HASH_value(ent->hashes, idx); k = hent->suffix; } else { hent = NULL; k = 0; } CRYPTO_r_unlock(CRYPTO_LOCK_X509_STORE); } else { k = 0; hent = NULL; } for (;;) { (void) snprintf(b->data, b->max, "%s/%08lx.%s%d", ent->dir, h, postfix, k); #ifndef OPENSSL_NO_POSIX_IO { struct stat st; if (stat(b->data, &st) < 0) break; } #endif /* found one. */ if (type == X509_LU_X509) { if ((X509_load_cert_file(xl, b->data, ent->dir_type)) == 0) break; } else if (type == X509_LU_CRL) { if ((X509_load_crl_file(xl, b->data, ent->dir_type)) == 0) break; } /* else case will caught higher up */ k++; } /* we have added it to the cache so now pull it out again */ CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); j = sk_X509_OBJECT_find(xl->store_ctx->objs, &stmp); if (j != -1) tmp = sk_X509_OBJECT_value(xl->store_ctx->objs, j); else tmp = NULL; CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); /* If a CRL, update the last file suffix added for this */ if (type == X509_LU_CRL) { CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); /* * Look for entry again in case another thread added * an entry first. */ if (!hent) { htmp.hash = h; idx = sk_BY_DIR_HASH_find(ent->hashes, &htmp); if (idx >= 0) hent = sk_BY_DIR_HASH_value( ent->hashes, idx); } if (!hent) { hent = malloc(sizeof(BY_DIR_HASH)); if (!hent) { X509err(X509_F_GET_CERT_BY_SUBJECT, ERR_R_MALLOC_FAILURE); CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); ok = 0; goto finish; } hent->hash = h; hent->suffix = k; if (!sk_BY_DIR_HASH_push(ent->hashes, hent)) { X509err(X509_F_GET_CERT_BY_SUBJECT, ERR_R_MALLOC_FAILURE); CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); free(hent); ok = 0; goto finish; } } else if (hent->suffix < k) hent->suffix = k; CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); } if (tmp != NULL) { ok = 1; ret->type = tmp->type; memcpy(&ret->data, &tmp->data, sizeof(ret->data)); /* * If we were going to up the reference count, * we would need to do it on a perl 'type' basis */ /* CRYPTO_add(&tmp->data.x509->references,1, CRYPTO_LOCK_X509);*/ goto finish; } } finish: if (b != NULL) BUF_MEM_free(b); return (ok); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ripemd/0000755000000000000000000000000012666635521021332 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/ripemd/rmd_dgst.c0000644000175000017500000002354712360020706021516 0ustar /* $OpenBSD: rmd_dgst.c,v 1.14 2014/06/12 15:49:30 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "rmd_locl.h" #include #include # ifdef RMD160_ASM void ripemd160_block_x86(RIPEMD160_CTX *c, unsigned long *p,size_t num); # define ripemd160_block ripemd160_block_x86 # else void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,size_t num); # endif int RIPEMD160_Init(RIPEMD160_CTX *c) { memset (c,0,sizeof(*c)); c->A=RIPEMD160_A; c->B=RIPEMD160_B; c->C=RIPEMD160_C; c->D=RIPEMD160_D; c->E=RIPEMD160_E; return 1; } #ifndef ripemd160_block_data_order #ifdef X #undef X #endif void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, size_t num) { const unsigned char *data=p; register unsigned MD32_REG_T A,B,C,D,E; unsigned MD32_REG_T a,b,c,d,e,l; #ifndef MD32_XARRAY /* See comment in crypto/sha/sha_locl.h for details. */ unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; # define X(i) XX##i #else RIPEMD160_LONG XX[16]; # define X(i) XX[i] #endif for (;num--;) { A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E; (void)HOST_c2l(data,l); X( 0)=l;(void)HOST_c2l(data,l); X( 1)=l; RIP1(A,B,C,D,E,WL00,SL00); (void)HOST_c2l(data,l); X( 2)=l; RIP1(E,A,B,C,D,WL01,SL01); (void)HOST_c2l(data,l); X( 3)=l; RIP1(D,E,A,B,C,WL02,SL02); (void)HOST_c2l(data,l); X( 4)=l; RIP1(C,D,E,A,B,WL03,SL03); (void)HOST_c2l(data,l); X( 5)=l; RIP1(B,C,D,E,A,WL04,SL04); (void)HOST_c2l(data,l); X( 6)=l; RIP1(A,B,C,D,E,WL05,SL05); (void)HOST_c2l(data,l); X( 7)=l; RIP1(E,A,B,C,D,WL06,SL06); (void)HOST_c2l(data,l); X( 8)=l; RIP1(D,E,A,B,C,WL07,SL07); (void)HOST_c2l(data,l); X( 9)=l; RIP1(C,D,E,A,B,WL08,SL08); (void)HOST_c2l(data,l); X(10)=l; RIP1(B,C,D,E,A,WL09,SL09); (void)HOST_c2l(data,l); X(11)=l; RIP1(A,B,C,D,E,WL10,SL10); (void)HOST_c2l(data,l); X(12)=l; RIP1(E,A,B,C,D,WL11,SL11); (void)HOST_c2l(data,l); X(13)=l; RIP1(D,E,A,B,C,WL12,SL12); (void)HOST_c2l(data,l); X(14)=l; RIP1(C,D,E,A,B,WL13,SL13); (void)HOST_c2l(data,l); X(15)=l; RIP1(B,C,D,E,A,WL14,SL14); RIP1(A,B,C,D,E,WL15,SL15); RIP2(E,A,B,C,D,WL16,SL16,KL1); RIP2(D,E,A,B,C,WL17,SL17,KL1); RIP2(C,D,E,A,B,WL18,SL18,KL1); RIP2(B,C,D,E,A,WL19,SL19,KL1); RIP2(A,B,C,D,E,WL20,SL20,KL1); RIP2(E,A,B,C,D,WL21,SL21,KL1); RIP2(D,E,A,B,C,WL22,SL22,KL1); RIP2(C,D,E,A,B,WL23,SL23,KL1); RIP2(B,C,D,E,A,WL24,SL24,KL1); RIP2(A,B,C,D,E,WL25,SL25,KL1); RIP2(E,A,B,C,D,WL26,SL26,KL1); RIP2(D,E,A,B,C,WL27,SL27,KL1); RIP2(C,D,E,A,B,WL28,SL28,KL1); RIP2(B,C,D,E,A,WL29,SL29,KL1); RIP2(A,B,C,D,E,WL30,SL30,KL1); RIP2(E,A,B,C,D,WL31,SL31,KL1); RIP3(D,E,A,B,C,WL32,SL32,KL2); RIP3(C,D,E,A,B,WL33,SL33,KL2); RIP3(B,C,D,E,A,WL34,SL34,KL2); RIP3(A,B,C,D,E,WL35,SL35,KL2); RIP3(E,A,B,C,D,WL36,SL36,KL2); RIP3(D,E,A,B,C,WL37,SL37,KL2); RIP3(C,D,E,A,B,WL38,SL38,KL2); RIP3(B,C,D,E,A,WL39,SL39,KL2); RIP3(A,B,C,D,E,WL40,SL40,KL2); RIP3(E,A,B,C,D,WL41,SL41,KL2); RIP3(D,E,A,B,C,WL42,SL42,KL2); RIP3(C,D,E,A,B,WL43,SL43,KL2); RIP3(B,C,D,E,A,WL44,SL44,KL2); RIP3(A,B,C,D,E,WL45,SL45,KL2); RIP3(E,A,B,C,D,WL46,SL46,KL2); RIP3(D,E,A,B,C,WL47,SL47,KL2); RIP4(C,D,E,A,B,WL48,SL48,KL3); RIP4(B,C,D,E,A,WL49,SL49,KL3); RIP4(A,B,C,D,E,WL50,SL50,KL3); RIP4(E,A,B,C,D,WL51,SL51,KL3); RIP4(D,E,A,B,C,WL52,SL52,KL3); RIP4(C,D,E,A,B,WL53,SL53,KL3); RIP4(B,C,D,E,A,WL54,SL54,KL3); RIP4(A,B,C,D,E,WL55,SL55,KL3); RIP4(E,A,B,C,D,WL56,SL56,KL3); RIP4(D,E,A,B,C,WL57,SL57,KL3); RIP4(C,D,E,A,B,WL58,SL58,KL3); RIP4(B,C,D,E,A,WL59,SL59,KL3); RIP4(A,B,C,D,E,WL60,SL60,KL3); RIP4(E,A,B,C,D,WL61,SL61,KL3); RIP4(D,E,A,B,C,WL62,SL62,KL3); RIP4(C,D,E,A,B,WL63,SL63,KL3); RIP5(B,C,D,E,A,WL64,SL64,KL4); RIP5(A,B,C,D,E,WL65,SL65,KL4); RIP5(E,A,B,C,D,WL66,SL66,KL4); RIP5(D,E,A,B,C,WL67,SL67,KL4); RIP5(C,D,E,A,B,WL68,SL68,KL4); RIP5(B,C,D,E,A,WL69,SL69,KL4); RIP5(A,B,C,D,E,WL70,SL70,KL4); RIP5(E,A,B,C,D,WL71,SL71,KL4); RIP5(D,E,A,B,C,WL72,SL72,KL4); RIP5(C,D,E,A,B,WL73,SL73,KL4); RIP5(B,C,D,E,A,WL74,SL74,KL4); RIP5(A,B,C,D,E,WL75,SL75,KL4); RIP5(E,A,B,C,D,WL76,SL76,KL4); RIP5(D,E,A,B,C,WL77,SL77,KL4); RIP5(C,D,E,A,B,WL78,SL78,KL4); RIP5(B,C,D,E,A,WL79,SL79,KL4); a=A; b=B; c=C; d=D; e=E; /* Do other half */ A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E; RIP5(A,B,C,D,E,WR00,SR00,KR0); RIP5(E,A,B,C,D,WR01,SR01,KR0); RIP5(D,E,A,B,C,WR02,SR02,KR0); RIP5(C,D,E,A,B,WR03,SR03,KR0); RIP5(B,C,D,E,A,WR04,SR04,KR0); RIP5(A,B,C,D,E,WR05,SR05,KR0); RIP5(E,A,B,C,D,WR06,SR06,KR0); RIP5(D,E,A,B,C,WR07,SR07,KR0); RIP5(C,D,E,A,B,WR08,SR08,KR0); RIP5(B,C,D,E,A,WR09,SR09,KR0); RIP5(A,B,C,D,E,WR10,SR10,KR0); RIP5(E,A,B,C,D,WR11,SR11,KR0); RIP5(D,E,A,B,C,WR12,SR12,KR0); RIP5(C,D,E,A,B,WR13,SR13,KR0); RIP5(B,C,D,E,A,WR14,SR14,KR0); RIP5(A,B,C,D,E,WR15,SR15,KR0); RIP4(E,A,B,C,D,WR16,SR16,KR1); RIP4(D,E,A,B,C,WR17,SR17,KR1); RIP4(C,D,E,A,B,WR18,SR18,KR1); RIP4(B,C,D,E,A,WR19,SR19,KR1); RIP4(A,B,C,D,E,WR20,SR20,KR1); RIP4(E,A,B,C,D,WR21,SR21,KR1); RIP4(D,E,A,B,C,WR22,SR22,KR1); RIP4(C,D,E,A,B,WR23,SR23,KR1); RIP4(B,C,D,E,A,WR24,SR24,KR1); RIP4(A,B,C,D,E,WR25,SR25,KR1); RIP4(E,A,B,C,D,WR26,SR26,KR1); RIP4(D,E,A,B,C,WR27,SR27,KR1); RIP4(C,D,E,A,B,WR28,SR28,KR1); RIP4(B,C,D,E,A,WR29,SR29,KR1); RIP4(A,B,C,D,E,WR30,SR30,KR1); RIP4(E,A,B,C,D,WR31,SR31,KR1); RIP3(D,E,A,B,C,WR32,SR32,KR2); RIP3(C,D,E,A,B,WR33,SR33,KR2); RIP3(B,C,D,E,A,WR34,SR34,KR2); RIP3(A,B,C,D,E,WR35,SR35,KR2); RIP3(E,A,B,C,D,WR36,SR36,KR2); RIP3(D,E,A,B,C,WR37,SR37,KR2); RIP3(C,D,E,A,B,WR38,SR38,KR2); RIP3(B,C,D,E,A,WR39,SR39,KR2); RIP3(A,B,C,D,E,WR40,SR40,KR2); RIP3(E,A,B,C,D,WR41,SR41,KR2); RIP3(D,E,A,B,C,WR42,SR42,KR2); RIP3(C,D,E,A,B,WR43,SR43,KR2); RIP3(B,C,D,E,A,WR44,SR44,KR2); RIP3(A,B,C,D,E,WR45,SR45,KR2); RIP3(E,A,B,C,D,WR46,SR46,KR2); RIP3(D,E,A,B,C,WR47,SR47,KR2); RIP2(C,D,E,A,B,WR48,SR48,KR3); RIP2(B,C,D,E,A,WR49,SR49,KR3); RIP2(A,B,C,D,E,WR50,SR50,KR3); RIP2(E,A,B,C,D,WR51,SR51,KR3); RIP2(D,E,A,B,C,WR52,SR52,KR3); RIP2(C,D,E,A,B,WR53,SR53,KR3); RIP2(B,C,D,E,A,WR54,SR54,KR3); RIP2(A,B,C,D,E,WR55,SR55,KR3); RIP2(E,A,B,C,D,WR56,SR56,KR3); RIP2(D,E,A,B,C,WR57,SR57,KR3); RIP2(C,D,E,A,B,WR58,SR58,KR3); RIP2(B,C,D,E,A,WR59,SR59,KR3); RIP2(A,B,C,D,E,WR60,SR60,KR3); RIP2(E,A,B,C,D,WR61,SR61,KR3); RIP2(D,E,A,B,C,WR62,SR62,KR3); RIP2(C,D,E,A,B,WR63,SR63,KR3); RIP1(B,C,D,E,A,WR64,SR64); RIP1(A,B,C,D,E,WR65,SR65); RIP1(E,A,B,C,D,WR66,SR66); RIP1(D,E,A,B,C,WR67,SR67); RIP1(C,D,E,A,B,WR68,SR68); RIP1(B,C,D,E,A,WR69,SR69); RIP1(A,B,C,D,E,WR70,SR70); RIP1(E,A,B,C,D,WR71,SR71); RIP1(D,E,A,B,C,WR72,SR72); RIP1(C,D,E,A,B,WR73,SR73); RIP1(B,C,D,E,A,WR74,SR74); RIP1(A,B,C,D,E,WR75,SR75); RIP1(E,A,B,C,D,WR76,SR76); RIP1(D,E,A,B,C,WR77,SR77); RIP1(C,D,E,A,B,WR78,SR78); RIP1(B,C,D,E,A,WR79,SR79); D =ctx->B+c+D; ctx->B=ctx->C+d+E; ctx->C=ctx->D+e+A; ctx->D=ctx->E+a+B; ctx->E=ctx->A+b+C; ctx->A=D; } } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ripemd/rmd_locl.h0000644000175000017500000001311012360020706021474 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #ifndef RIPEMD160_LONG_LOG2 #define RIPEMD160_LONG_LOG2 2 /* default to 32 bits */ #endif /* * DO EXAMINE COMMENTS IN crypto/md5/md5_locl.h & crypto/md5/md5_dgst.c * FOR EXPLANATIONS ON FOLLOWING "CODE." * */ #ifdef RMD160_ASM # if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) # define ripemd160_block_data_order ripemd160_block_asm_data_order # endif #endif void ripemd160_block_data_order (RIPEMD160_CTX *c, const void *p,size_t num); #define DATA_ORDER_IS_LITTLE_ENDIAN #define HASH_LONG RIPEMD160_LONG #define HASH_CTX RIPEMD160_CTX #define HASH_CBLOCK RIPEMD160_CBLOCK #define HASH_UPDATE RIPEMD160_Update #define HASH_TRANSFORM RIPEMD160_Transform #define HASH_FINAL RIPEMD160_Final #define HASH_MAKE_STRING(c,s) do { \ unsigned long ll; \ ll=(c)->A; (void)HOST_l2c(ll,(s)); \ ll=(c)->B; (void)HOST_l2c(ll,(s)); \ ll=(c)->C; (void)HOST_l2c(ll,(s)); \ ll=(c)->D; (void)HOST_l2c(ll,(s)); \ ll=(c)->E; (void)HOST_l2c(ll,(s)); \ } while (0) #define HASH_BLOCK_DATA_ORDER ripemd160_block_data_order #include "md32_common.h" #if 0 #define F1(x,y,z) ((x)^(y)^(z)) #define F2(x,y,z) (((x)&(y))|((~x)&z)) #define F3(x,y,z) (((x)|(~y))^(z)) #define F4(x,y,z) (((x)&(z))|((y)&(~(z)))) #define F5(x,y,z) ((x)^((y)|(~(z)))) #else /* * Transformed F2 and F4 are courtesy of Wei Dai */ #define F1(x,y,z) ((x) ^ (y) ^ (z)) #define F2(x,y,z) ((((y) ^ (z)) & (x)) ^ (z)) #define F3(x,y,z) (((~(y)) | (x)) ^ (z)) #define F4(x,y,z) ((((x) ^ (y)) & (z)) ^ (y)) #define F5(x,y,z) (((~(z)) | (y)) ^ (x)) #endif #define RIPEMD160_A 0x67452301L #define RIPEMD160_B 0xEFCDAB89L #define RIPEMD160_C 0x98BADCFEL #define RIPEMD160_D 0x10325476L #define RIPEMD160_E 0xC3D2E1F0L #include "rmdconst.h" #define RIP1(a,b,c,d,e,w,s) { \ a+=F1(b,c,d)+X(w); \ a=ROTATE(a,s)+e; \ c=ROTATE(c,10); } #define RIP2(a,b,c,d,e,w,s,K) { \ a+=F2(b,c,d)+X(w)+K; \ a=ROTATE(a,s)+e; \ c=ROTATE(c,10); } #define RIP3(a,b,c,d,e,w,s,K) { \ a+=F3(b,c,d)+X(w)+K; \ a=ROTATE(a,s)+e; \ c=ROTATE(c,10); } #define RIP4(a,b,c,d,e,w,s,K) { \ a+=F4(b,c,d)+X(w)+K; \ a=ROTATE(a,s)+e; \ c=ROTATE(c,10); } #define RIP5(a,b,c,d,e,w,s,K) { \ a+=F5(b,c,d)+X(w)+K; \ a=ROTATE(a,s)+e; \ c=ROTATE(c,10); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ripemd/rmdconst.h0000644000175000017500000002055512360020706021545 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #define KL0 0x00000000L #define KL1 0x5A827999L #define KL2 0x6ED9EBA1L #define KL3 0x8F1BBCDCL #define KL4 0xA953FD4EL #define KR0 0x50A28BE6L #define KR1 0x5C4DD124L #define KR2 0x6D703EF3L #define KR3 0x7A6D76E9L #define KR4 0x00000000L #define WL00 0 #define SL00 11 #define WL01 1 #define SL01 14 #define WL02 2 #define SL02 15 #define WL03 3 #define SL03 12 #define WL04 4 #define SL04 5 #define WL05 5 #define SL05 8 #define WL06 6 #define SL06 7 #define WL07 7 #define SL07 9 #define WL08 8 #define SL08 11 #define WL09 9 #define SL09 13 #define WL10 10 #define SL10 14 #define WL11 11 #define SL11 15 #define WL12 12 #define SL12 6 #define WL13 13 #define SL13 7 #define WL14 14 #define SL14 9 #define WL15 15 #define SL15 8 #define WL16 7 #define SL16 7 #define WL17 4 #define SL17 6 #define WL18 13 #define SL18 8 #define WL19 1 #define SL19 13 #define WL20 10 #define SL20 11 #define WL21 6 #define SL21 9 #define WL22 15 #define SL22 7 #define WL23 3 #define SL23 15 #define WL24 12 #define SL24 7 #define WL25 0 #define SL25 12 #define WL26 9 #define SL26 15 #define WL27 5 #define SL27 9 #define WL28 2 #define SL28 11 #define WL29 14 #define SL29 7 #define WL30 11 #define SL30 13 #define WL31 8 #define SL31 12 #define WL32 3 #define SL32 11 #define WL33 10 #define SL33 13 #define WL34 14 #define SL34 6 #define WL35 4 #define SL35 7 #define WL36 9 #define SL36 14 #define WL37 15 #define SL37 9 #define WL38 8 #define SL38 13 #define WL39 1 #define SL39 15 #define WL40 2 #define SL40 14 #define WL41 7 #define SL41 8 #define WL42 0 #define SL42 13 #define WL43 6 #define SL43 6 #define WL44 13 #define SL44 5 #define WL45 11 #define SL45 12 #define WL46 5 #define SL46 7 #define WL47 12 #define SL47 5 #define WL48 1 #define SL48 11 #define WL49 9 #define SL49 12 #define WL50 11 #define SL50 14 #define WL51 10 #define SL51 15 #define WL52 0 #define SL52 14 #define WL53 8 #define SL53 15 #define WL54 12 #define SL54 9 #define WL55 4 #define SL55 8 #define WL56 13 #define SL56 9 #define WL57 3 #define SL57 14 #define WL58 7 #define SL58 5 #define WL59 15 #define SL59 6 #define WL60 14 #define SL60 8 #define WL61 5 #define SL61 6 #define WL62 6 #define SL62 5 #define WL63 2 #define SL63 12 #define WL64 4 #define SL64 9 #define WL65 0 #define SL65 15 #define WL66 5 #define SL66 5 #define WL67 9 #define SL67 11 #define WL68 7 #define SL68 6 #define WL69 12 #define SL69 8 #define WL70 2 #define SL70 13 #define WL71 10 #define SL71 12 #define WL72 14 #define SL72 5 #define WL73 1 #define SL73 12 #define WL74 3 #define SL74 13 #define WL75 8 #define SL75 14 #define WL76 11 #define SL76 11 #define WL77 6 #define SL77 8 #define WL78 15 #define SL78 5 #define WL79 13 #define SL79 6 #define WR00 5 #define SR00 8 #define WR01 14 #define SR01 9 #define WR02 7 #define SR02 9 #define WR03 0 #define SR03 11 #define WR04 9 #define SR04 13 #define WR05 2 #define SR05 15 #define WR06 11 #define SR06 15 #define WR07 4 #define SR07 5 #define WR08 13 #define SR08 7 #define WR09 6 #define SR09 7 #define WR10 15 #define SR10 8 #define WR11 8 #define SR11 11 #define WR12 1 #define SR12 14 #define WR13 10 #define SR13 14 #define WR14 3 #define SR14 12 #define WR15 12 #define SR15 6 #define WR16 6 #define SR16 9 #define WR17 11 #define SR17 13 #define WR18 3 #define SR18 15 #define WR19 7 #define SR19 7 #define WR20 0 #define SR20 12 #define WR21 13 #define SR21 8 #define WR22 5 #define SR22 9 #define WR23 10 #define SR23 11 #define WR24 14 #define SR24 7 #define WR25 15 #define SR25 7 #define WR26 8 #define SR26 12 #define WR27 12 #define SR27 7 #define WR28 4 #define SR28 6 #define WR29 9 #define SR29 15 #define WR30 1 #define SR30 13 #define WR31 2 #define SR31 11 #define WR32 15 #define SR32 9 #define WR33 5 #define SR33 7 #define WR34 1 #define SR34 15 #define WR35 3 #define SR35 11 #define WR36 7 #define SR36 8 #define WR37 14 #define SR37 6 #define WR38 6 #define SR38 6 #define WR39 9 #define SR39 14 #define WR40 11 #define SR40 12 #define WR41 8 #define SR41 13 #define WR42 12 #define SR42 5 #define WR43 2 #define SR43 14 #define WR44 10 #define SR44 13 #define WR45 0 #define SR45 13 #define WR46 4 #define SR46 7 #define WR47 13 #define SR47 5 #define WR48 8 #define SR48 15 #define WR49 6 #define SR49 5 #define WR50 4 #define SR50 8 #define WR51 1 #define SR51 11 #define WR52 3 #define SR52 14 #define WR53 11 #define SR53 14 #define WR54 15 #define SR54 6 #define WR55 0 #define SR55 14 #define WR56 5 #define SR56 6 #define WR57 12 #define SR57 9 #define WR58 2 #define SR58 12 #define WR59 13 #define SR59 9 #define WR60 9 #define SR60 12 #define WR61 7 #define SR61 5 #define WR62 10 #define SR62 15 #define WR63 14 #define SR63 8 #define WR64 12 #define SR64 8 #define WR65 15 #define SR65 5 #define WR66 10 #define SR66 12 #define WR67 4 #define SR67 9 #define WR68 1 #define SR68 12 #define WR69 5 #define SR69 5 #define WR70 8 #define SR70 14 #define WR71 7 #define SR71 6 #define WR72 6 #define SR72 8 #define WR73 2 #define SR73 13 #define WR74 13 #define SR74 6 #define WR75 14 #define SR75 5 #define WR76 0 #define SR76 15 #define WR77 3 #define SR77 13 #define WR78 9 #define SR78 11 #define WR79 11 #define SR79 11 deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ripemd/rmd_one.c0000644000175000017500000000706012360020706021326 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include unsigned char *RIPEMD160(const unsigned char *d, size_t n, unsigned char *md) { RIPEMD160_CTX c; static unsigned char m[RIPEMD160_DIGEST_LENGTH]; if (md == NULL) md=m; if (!RIPEMD160_Init(&c)) return NULL; RIPEMD160_Update(&c,d,n); RIPEMD160_Final(md,&c); OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */ return(md); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/md5/0000755000000000000000000000000012666635521020537 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/md5/md5_locl.h0000644000175000017500000001210612360020706020610 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #ifndef MD5_LONG_LOG2 #define MD5_LONG_LOG2 2 /* default to 32 bits */ #endif #ifdef MD5_ASM # if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) || \ defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64) # define md5_block_data_order md5_block_asm_data_order # elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) # define md5_block_data_order md5_block_asm_data_order # endif #endif void md5_block_data_order (MD5_CTX *c, const void *p,size_t num); #define DATA_ORDER_IS_LITTLE_ENDIAN #define HASH_LONG MD5_LONG #define HASH_CTX MD5_CTX #define HASH_CBLOCK MD5_CBLOCK #define HASH_UPDATE MD5_Update #define HASH_TRANSFORM MD5_Transform #define HASH_FINAL MD5_Final #define HASH_MAKE_STRING(c,s) do { \ unsigned long ll; \ ll=(c)->A; (void)HOST_l2c(ll,(s)); \ ll=(c)->B; (void)HOST_l2c(ll,(s)); \ ll=(c)->C; (void)HOST_l2c(ll,(s)); \ ll=(c)->D; (void)HOST_l2c(ll,(s)); \ } while (0) #define HASH_BLOCK_DATA_ORDER md5_block_data_order #include "md32_common.h" /* #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z))) #define G(x,y,z) (((x) & (z)) | ((y) & (~(z)))) */ /* As pointed out by Wei Dai , the above can be * simplified to the code below. Wei attributes these optimizations * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel. */ #define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) #define G(b,c,d) ((((b) ^ (c)) & (d)) ^ (c)) #define H(b,c,d) ((b) ^ (c) ^ (d)) #define I(b,c,d) (((~(d)) | (b)) ^ (c)) #define R0(a,b,c,d,k,s,t) { \ a+=((k)+(t)+F((b),(c),(d))); \ a=ROTATE(a,s); \ a+=b; };\ #define R1(a,b,c,d,k,s,t) { \ a+=((k)+(t)+G((b),(c),(d))); \ a=ROTATE(a,s); \ a+=b; }; #define R2(a,b,c,d,k,s,t) { \ a+=((k)+(t)+H((b),(c),(d))); \ a=ROTATE(a,s); \ a+=b; }; #define R3(a,b,c,d,k,s,t) { \ a+=((k)+(t)+I((b),(c),(d))); \ a=ROTATE(a,s); \ a+=b; }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/md5/md5_one.c0000644000175000017500000000700312360020706020433 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md) { MD5_CTX c; static unsigned char m[MD5_DIGEST_LENGTH]; if (md == NULL) md=m; if (!MD5_Init(&c)) return NULL; MD5_Update(&c,d,n); MD5_Final(md,&c); OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */ return(md); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/md5/md5_dgst.c0000644000175000017500000001563712360020706020627 0ustar /* $OpenBSD: md5_dgst.c,v 1.12 2014/06/12 15:49:29 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "md5_locl.h" #include #include /* Implemented from RFC1321 The MD5 Message-Digest Algorithm */ #define INIT_DATA_A (unsigned long)0x67452301L #define INIT_DATA_B (unsigned long)0xefcdab89L #define INIT_DATA_C (unsigned long)0x98badcfeL #define INIT_DATA_D (unsigned long)0x10325476L int MD5_Init(MD5_CTX *c) { memset (c,0,sizeof(*c)); c->A=INIT_DATA_A; c->B=INIT_DATA_B; c->C=INIT_DATA_C; c->D=INIT_DATA_D; return 1; } #ifndef md5_block_data_order #ifdef X #undef X #endif void md5_block_data_order (MD5_CTX *c, const void *data_, size_t num) { const unsigned char *data=data_; register unsigned MD32_REG_T A,B,C,D,l; #ifndef MD32_XARRAY /* See comment in crypto/sha/sha_locl.h for details. */ unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; # define X(i) XX##i #else MD5_LONG XX[MD5_LBLOCK]; # define X(i) XX[i] #endif A=c->A; B=c->B; C=c->C; D=c->D; for (;num--;) { HOST_c2l(data,l); X( 0)=l; HOST_c2l(data,l); X( 1)=l; /* Round 0 */ R0(A,B,C,D,X( 0), 7,0xd76aa478L); HOST_c2l(data,l); X( 2)=l; R0(D,A,B,C,X( 1),12,0xe8c7b756L); HOST_c2l(data,l); X( 3)=l; R0(C,D,A,B,X( 2),17,0x242070dbL); HOST_c2l(data,l); X( 4)=l; R0(B,C,D,A,X( 3),22,0xc1bdceeeL); HOST_c2l(data,l); X( 5)=l; R0(A,B,C,D,X( 4), 7,0xf57c0fafL); HOST_c2l(data,l); X( 6)=l; R0(D,A,B,C,X( 5),12,0x4787c62aL); HOST_c2l(data,l); X( 7)=l; R0(C,D,A,B,X( 6),17,0xa8304613L); HOST_c2l(data,l); X( 8)=l; R0(B,C,D,A,X( 7),22,0xfd469501L); HOST_c2l(data,l); X( 9)=l; R0(A,B,C,D,X( 8), 7,0x698098d8L); HOST_c2l(data,l); X(10)=l; R0(D,A,B,C,X( 9),12,0x8b44f7afL); HOST_c2l(data,l); X(11)=l; R0(C,D,A,B,X(10),17,0xffff5bb1L); HOST_c2l(data,l); X(12)=l; R0(B,C,D,A,X(11),22,0x895cd7beL); HOST_c2l(data,l); X(13)=l; R0(A,B,C,D,X(12), 7,0x6b901122L); HOST_c2l(data,l); X(14)=l; R0(D,A,B,C,X(13),12,0xfd987193L); HOST_c2l(data,l); X(15)=l; R0(C,D,A,B,X(14),17,0xa679438eL); R0(B,C,D,A,X(15),22,0x49b40821L); /* Round 1 */ R1(A,B,C,D,X( 1), 5,0xf61e2562L); R1(D,A,B,C,X( 6), 9,0xc040b340L); R1(C,D,A,B,X(11),14,0x265e5a51L); R1(B,C,D,A,X( 0),20,0xe9b6c7aaL); R1(A,B,C,D,X( 5), 5,0xd62f105dL); R1(D,A,B,C,X(10), 9,0x02441453L); R1(C,D,A,B,X(15),14,0xd8a1e681L); R1(B,C,D,A,X( 4),20,0xe7d3fbc8L); R1(A,B,C,D,X( 9), 5,0x21e1cde6L); R1(D,A,B,C,X(14), 9,0xc33707d6L); R1(C,D,A,B,X( 3),14,0xf4d50d87L); R1(B,C,D,A,X( 8),20,0x455a14edL); R1(A,B,C,D,X(13), 5,0xa9e3e905L); R1(D,A,B,C,X( 2), 9,0xfcefa3f8L); R1(C,D,A,B,X( 7),14,0x676f02d9L); R1(B,C,D,A,X(12),20,0x8d2a4c8aL); /* Round 2 */ R2(A,B,C,D,X( 5), 4,0xfffa3942L); R2(D,A,B,C,X( 8),11,0x8771f681L); R2(C,D,A,B,X(11),16,0x6d9d6122L); R2(B,C,D,A,X(14),23,0xfde5380cL); R2(A,B,C,D,X( 1), 4,0xa4beea44L); R2(D,A,B,C,X( 4),11,0x4bdecfa9L); R2(C,D,A,B,X( 7),16,0xf6bb4b60L); R2(B,C,D,A,X(10),23,0xbebfbc70L); R2(A,B,C,D,X(13), 4,0x289b7ec6L); R2(D,A,B,C,X( 0),11,0xeaa127faL); R2(C,D,A,B,X( 3),16,0xd4ef3085L); R2(B,C,D,A,X( 6),23,0x04881d05L); R2(A,B,C,D,X( 9), 4,0xd9d4d039L); R2(D,A,B,C,X(12),11,0xe6db99e5L); R2(C,D,A,B,X(15),16,0x1fa27cf8L); R2(B,C,D,A,X( 2),23,0xc4ac5665L); /* Round 3 */ R3(A,B,C,D,X( 0), 6,0xf4292244L); R3(D,A,B,C,X( 7),10,0x432aff97L); R3(C,D,A,B,X(14),15,0xab9423a7L); R3(B,C,D,A,X( 5),21,0xfc93a039L); R3(A,B,C,D,X(12), 6,0x655b59c3L); R3(D,A,B,C,X( 3),10,0x8f0ccc92L); R3(C,D,A,B,X(10),15,0xffeff47dL); R3(B,C,D,A,X( 1),21,0x85845dd1L); R3(A,B,C,D,X( 8), 6,0x6fa87e4fL); R3(D,A,B,C,X(15),10,0xfe2ce6e0L); R3(C,D,A,B,X( 6),15,0xa3014314L); R3(B,C,D,A,X(13),21,0x4e0811a1L); R3(A,B,C,D,X( 4), 6,0xf7537e82L); R3(D,A,B,C,X(11),10,0xbd3af235L); R3(C,D,A,B,X( 2),15,0x2ad7d2bbL); R3(B,C,D,A,X( 9),21,0xeb86d391L); A = c->A += A; B = c->B += B; C = c->C += C; D = c->D += D; } } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/krb5/0000755000000000000000000000000012666635521020715 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/krb5/krb5_asn.c0000644000175000017500000001407512360020706020776 0ustar /* $OpenBSD$ */ /* Written by Vern Staats for the OpenSSL project, ** using ocsp/{*.h,*asn*.c} as a starting point */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include ASN1_SEQUENCE(KRB5_ENCDATA) = { ASN1_EXP(KRB5_ENCDATA, etype, ASN1_INTEGER, 0), ASN1_EXP_OPT(KRB5_ENCDATA, kvno, ASN1_INTEGER, 1), ASN1_EXP(KRB5_ENCDATA, cipher, ASN1_OCTET_STRING,2) } ASN1_SEQUENCE_END(KRB5_ENCDATA) IMPLEMENT_ASN1_FUNCTIONS(KRB5_ENCDATA) ASN1_SEQUENCE(KRB5_PRINCNAME) = { ASN1_EXP(KRB5_PRINCNAME, nametype, ASN1_INTEGER, 0), ASN1_EXP_SEQUENCE_OF(KRB5_PRINCNAME, namestring, ASN1_GENERALSTRING, 1) } ASN1_SEQUENCE_END(KRB5_PRINCNAME) IMPLEMENT_ASN1_FUNCTIONS(KRB5_PRINCNAME) /* [APPLICATION 1] = 0x61 */ ASN1_SEQUENCE(KRB5_TKTBODY) = { ASN1_EXP(KRB5_TKTBODY, tktvno, ASN1_INTEGER, 0), ASN1_EXP(KRB5_TKTBODY, realm, ASN1_GENERALSTRING, 1), ASN1_EXP(KRB5_TKTBODY, sname, KRB5_PRINCNAME, 2), ASN1_EXP(KRB5_TKTBODY, encdata, KRB5_ENCDATA, 3) } ASN1_SEQUENCE_END(KRB5_TKTBODY) IMPLEMENT_ASN1_FUNCTIONS(KRB5_TKTBODY) ASN1_ITEM_TEMPLATE(KRB5_TICKET) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_EXPTAG|ASN1_TFLG_APPLICATION, 1, KRB5_TICKET, KRB5_TKTBODY) ASN1_ITEM_TEMPLATE_END(KRB5_TICKET) IMPLEMENT_ASN1_FUNCTIONS(KRB5_TICKET) /* [APPLICATION 14] = 0x6e */ ASN1_SEQUENCE(KRB5_APREQBODY) = { ASN1_EXP(KRB5_APREQBODY, pvno, ASN1_INTEGER, 0), ASN1_EXP(KRB5_APREQBODY, msgtype, ASN1_INTEGER, 1), ASN1_EXP(KRB5_APREQBODY, apoptions, ASN1_BIT_STRING, 2), ASN1_EXP(KRB5_APREQBODY, ticket, KRB5_TICKET, 3), ASN1_EXP(KRB5_APREQBODY, authenticator, KRB5_ENCDATA, 4), } ASN1_SEQUENCE_END(KRB5_APREQBODY) IMPLEMENT_ASN1_FUNCTIONS(KRB5_APREQBODY) ASN1_ITEM_TEMPLATE(KRB5_APREQ) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_EXPTAG|ASN1_TFLG_APPLICATION, 14, KRB5_APREQ, KRB5_APREQBODY) ASN1_ITEM_TEMPLATE_END(KRB5_APREQ) IMPLEMENT_ASN1_FUNCTIONS(KRB5_APREQ) /* Authenticator stuff */ ASN1_SEQUENCE(KRB5_CHECKSUM) = { ASN1_EXP(KRB5_CHECKSUM, ctype, ASN1_INTEGER, 0), ASN1_EXP(KRB5_CHECKSUM, checksum, ASN1_OCTET_STRING,1) } ASN1_SEQUENCE_END(KRB5_CHECKSUM) IMPLEMENT_ASN1_FUNCTIONS(KRB5_CHECKSUM) ASN1_SEQUENCE(KRB5_ENCKEY) = { ASN1_EXP(KRB5_ENCKEY, ktype, ASN1_INTEGER, 0), ASN1_EXP(KRB5_ENCKEY, keyvalue, ASN1_OCTET_STRING,1) } ASN1_SEQUENCE_END(KRB5_ENCKEY) IMPLEMENT_ASN1_FUNCTIONS(KRB5_ENCKEY) /* SEQ OF SEQ; see ASN1_EXP_SEQUENCE_OF_OPT() below */ ASN1_SEQUENCE(KRB5_AUTHDATA) = { ASN1_EXP(KRB5_AUTHDATA, adtype, ASN1_INTEGER, 0), ASN1_EXP(KRB5_AUTHDATA, addata, ASN1_OCTET_STRING,1) } ASN1_SEQUENCE_END(KRB5_AUTHDATA) IMPLEMENT_ASN1_FUNCTIONS(KRB5_AUTHDATA) /* [APPLICATION 2] = 0x62 */ ASN1_SEQUENCE(KRB5_AUTHENTBODY) = { ASN1_EXP(KRB5_AUTHENTBODY, avno, ASN1_INTEGER, 0), ASN1_EXP(KRB5_AUTHENTBODY, crealm, ASN1_GENERALSTRING, 1), ASN1_EXP(KRB5_AUTHENTBODY, cname, KRB5_PRINCNAME, 2), ASN1_EXP_OPT(KRB5_AUTHENTBODY, cksum, KRB5_CHECKSUM, 3), ASN1_EXP(KRB5_AUTHENTBODY, cusec, ASN1_INTEGER, 4), ASN1_EXP(KRB5_AUTHENTBODY, ctime, ASN1_GENERALIZEDTIME, 5), ASN1_EXP_OPT(KRB5_AUTHENTBODY, subkey, KRB5_ENCKEY, 6), ASN1_EXP_OPT(KRB5_AUTHENTBODY, seqnum, ASN1_INTEGER, 7), ASN1_EXP_SEQUENCE_OF_OPT (KRB5_AUTHENTBODY, authorization, KRB5_AUTHDATA, 8), } ASN1_SEQUENCE_END(KRB5_AUTHENTBODY) IMPLEMENT_ASN1_FUNCTIONS(KRB5_AUTHENTBODY) ASN1_ITEM_TEMPLATE(KRB5_AUTHENT) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_EXPTAG|ASN1_TFLG_APPLICATION, 2, KRB5_AUTHENT, KRB5_AUTHENTBODY) ASN1_ITEM_TEMPLATE_END(KRB5_AUTHENT) IMPLEMENT_ASN1_FUNCTIONS(KRB5_AUTHENT) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/err/0000755000000000000000000000000012666635521020642 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/err/err_all.c0000644000175000017500000001243012360020705020627 0ustar /* $OpenBSD: err_all.c,v 1.16 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #ifndef OPENSSL_NO_EC #include #endif #include #include #ifndef OPENSSL_NO_COMP #include #endif #ifndef OPENSSL_NO_RSA #include #endif #ifndef OPENSSL_NO_DH #include #endif #ifndef OPENSSL_NO_DSA #include #endif #ifndef OPENSSL_NO_ECDSA #include #endif #ifndef OPENSSL_NO_ECDH #include #endif #include #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif #include #include #include #include #ifndef OPENSSL_NO_CMS #include #endif void ERR_load_crypto_strings(void) { #ifndef OPENSSL_NO_ERR ERR_load_ERR_strings(); /* include error strings for SYSerr */ ERR_load_BN_strings(); #ifndef OPENSSL_NO_RSA ERR_load_RSA_strings(); #endif #ifndef OPENSSL_NO_DH ERR_load_DH_strings(); #endif ERR_load_EVP_strings(); ERR_load_BUF_strings(); ERR_load_OBJ_strings(); ERR_load_PEM_strings(); #ifndef OPENSSL_NO_DSA ERR_load_DSA_strings(); #endif ERR_load_X509_strings(); ERR_load_ASN1_strings(); ERR_load_CONF_strings(); ERR_load_CRYPTO_strings(); #ifndef OPENSSL_NO_COMP ERR_load_COMP_strings(); #endif #ifndef OPENSSL_NO_EC ERR_load_EC_strings(); #endif #ifndef OPENSSL_NO_ECDSA ERR_load_ECDSA_strings(); #endif #ifndef OPENSSL_NO_ECDH ERR_load_ECDH_strings(); #endif /* skip ERR_load_SSL_strings() because it is not in this library */ ERR_load_BIO_strings(); ERR_load_PKCS7_strings(); ERR_load_X509V3_strings(); ERR_load_PKCS12_strings(); ERR_load_RAND_strings(); ERR_load_DSO_strings(); ERR_load_TS_strings(); #ifndef OPENSSL_NO_ENGINE ERR_load_ENGINE_strings(); #endif ERR_load_OCSP_strings(); ERR_load_UI_strings(); #ifndef OPENSSL_NO_CMS ERR_load_CMS_strings(); #endif #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/err/err.c0000644000175000017500000007202212360020705020002 0ustar /* $OpenBSD: err.c,v 1.37 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include #include DECLARE_LHASH_OF(ERR_STRING_DATA); DECLARE_LHASH_OF(ERR_STATE); static void err_load_strings(int lib, ERR_STRING_DATA *str); static void ERR_STATE_free(ERR_STATE *s); #ifndef OPENSSL_NO_ERR static ERR_STRING_DATA ERR_str_libraries[] = { {ERR_PACK(ERR_LIB_NONE,0,0), "unknown library"}, {ERR_PACK(ERR_LIB_SYS,0,0), "system library"}, {ERR_PACK(ERR_LIB_BN,0,0), "bignum routines"}, {ERR_PACK(ERR_LIB_RSA,0,0), "rsa routines"}, {ERR_PACK(ERR_LIB_DH,0,0), "Diffie-Hellman routines"}, {ERR_PACK(ERR_LIB_EVP,0,0), "digital envelope routines"}, {ERR_PACK(ERR_LIB_BUF,0,0), "memory buffer routines"}, {ERR_PACK(ERR_LIB_OBJ,0,0), "object identifier routines"}, {ERR_PACK(ERR_LIB_PEM,0,0), "PEM routines"}, {ERR_PACK(ERR_LIB_DSA,0,0), "dsa routines"}, {ERR_PACK(ERR_LIB_X509,0,0), "x509 certificate routines"}, {ERR_PACK(ERR_LIB_ASN1,0,0), "asn1 encoding routines"}, {ERR_PACK(ERR_LIB_CONF,0,0), "configuration file routines"}, {ERR_PACK(ERR_LIB_CRYPTO,0,0), "common libcrypto routines"}, {ERR_PACK(ERR_LIB_EC,0,0), "elliptic curve routines"}, {ERR_PACK(ERR_LIB_SSL,0,0), "SSL routines"}, {ERR_PACK(ERR_LIB_BIO,0,0), "BIO routines"}, {ERR_PACK(ERR_LIB_PKCS7,0,0), "PKCS7 routines"}, {ERR_PACK(ERR_LIB_X509V3,0,0), "X509 V3 routines"}, {ERR_PACK(ERR_LIB_PKCS12,0,0), "PKCS12 routines"}, {ERR_PACK(ERR_LIB_RAND,0,0), "random number generator"}, {ERR_PACK(ERR_LIB_DSO,0,0), "DSO support routines"}, {ERR_PACK(ERR_LIB_TS,0,0), "time stamp routines"}, {ERR_PACK(ERR_LIB_ENGINE,0,0), "engine routines"}, {ERR_PACK(ERR_LIB_OCSP,0,0), "OCSP routines"}, {ERR_PACK(ERR_LIB_FIPS,0,0), "FIPS routines"}, {ERR_PACK(ERR_LIB_CMS,0,0), "CMS routines"}, {ERR_PACK(ERR_LIB_HMAC,0,0), "HMAC routines"}, {0, NULL}, }; static ERR_STRING_DATA ERR_str_functs[] = { {ERR_PACK(0,SYS_F_FOPEN, 0), "fopen"}, {ERR_PACK(0,SYS_F_CONNECT, 0), "connect"}, {ERR_PACK(0,SYS_F_GETSERVBYNAME, 0), "getservbyname"}, {ERR_PACK(0,SYS_F_SOCKET, 0), "socket"}, {ERR_PACK(0,SYS_F_IOCTLSOCKET, 0), "ioctl"}, {ERR_PACK(0,SYS_F_BIND, 0), "bind"}, {ERR_PACK(0,SYS_F_LISTEN, 0), "listen"}, {ERR_PACK(0,SYS_F_ACCEPT, 0), "accept"}, {ERR_PACK(0,SYS_F_OPENDIR, 0), "opendir"}, {ERR_PACK(0,SYS_F_FREAD, 0), "fread"}, {0, NULL}, }; static ERR_STRING_DATA ERR_str_reasons[] = { {ERR_R_SYS_LIB, "system lib"}, {ERR_R_BN_LIB, "BN lib"}, {ERR_R_RSA_LIB, "RSA lib"}, {ERR_R_DH_LIB, "DH lib"}, {ERR_R_EVP_LIB, "EVP lib"}, {ERR_R_BUF_LIB, "BUF lib"}, {ERR_R_OBJ_LIB, "OBJ lib"}, {ERR_R_PEM_LIB, "PEM lib"}, {ERR_R_DSA_LIB, "DSA lib"}, {ERR_R_X509_LIB, "X509 lib"}, {ERR_R_ASN1_LIB, "ASN1 lib"}, {ERR_R_CONF_LIB, "CONF lib"}, {ERR_R_CRYPTO_LIB, "CRYPTO lib"}, {ERR_R_EC_LIB, "EC lib"}, {ERR_R_SSL_LIB, "SSL lib"}, {ERR_R_BIO_LIB, "BIO lib"}, {ERR_R_PKCS7_LIB, "PKCS7 lib"}, {ERR_R_X509V3_LIB, "X509V3 lib"}, {ERR_R_PKCS12_LIB, "PKCS12 lib"}, {ERR_R_RAND_LIB, "RAND lib"}, {ERR_R_DSO_LIB, "DSO lib"}, {ERR_R_ENGINE_LIB, "ENGINE lib"}, {ERR_R_OCSP_LIB, "OCSP lib"}, {ERR_R_TS_LIB, "TS lib"}, {ERR_R_NESTED_ASN1_ERROR, "nested asn1 error"}, {ERR_R_BAD_ASN1_OBJECT_HEADER, "bad asn1 object header"}, {ERR_R_BAD_GET_ASN1_OBJECT_CALL, "bad get asn1 object call"}, {ERR_R_EXPECTING_AN_ASN1_SEQUENCE, "expecting an asn1 sequence"}, {ERR_R_ASN1_LENGTH_MISMATCH, "asn1 length mismatch"}, {ERR_R_MISSING_ASN1_EOS, "missing asn1 eos"}, {ERR_R_FATAL, "fatal"}, {ERR_R_MALLOC_FAILURE, "malloc failure"}, {ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED, "called a function you should not call"}, {ERR_R_PASSED_NULL_PARAMETER, "passed a null parameter"}, {ERR_R_INTERNAL_ERROR, "internal error"}, {ERR_R_DISABLED , "called a function that was disabled at compile-time"}, {0, NULL}, }; #endif /* Define the predeclared (but externally opaque) "ERR_FNS" type */ struct st_ERR_FNS { /* Works on the "error_hash" string table */ LHASH_OF(ERR_STRING_DATA) *(*cb_err_get)(int create); void (*cb_err_del)(void); ERR_STRING_DATA *(*cb_err_get_item)(const ERR_STRING_DATA *); ERR_STRING_DATA *(*cb_err_set_item)(ERR_STRING_DATA *); ERR_STRING_DATA *(*cb_err_del_item)(ERR_STRING_DATA *); /* Works on the "thread_hash" error-state table */ LHASH_OF(ERR_STATE) *(*cb_thread_get)(int create); void (*cb_thread_release)(LHASH_OF(ERR_STATE) **hash); ERR_STATE *(*cb_thread_get_item)(const ERR_STATE *); ERR_STATE *(*cb_thread_set_item)(ERR_STATE *); void (*cb_thread_del_item)(const ERR_STATE *); /* Returns the next available error "library" numbers */ int (*cb_get_next_lib)(void); }; /* Predeclarations of the "err_defaults" functions */ static LHASH_OF(ERR_STRING_DATA) *int_err_get(int create); static void int_err_del(void); static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *); static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *); static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *); static LHASH_OF(ERR_STATE) *int_thread_get(int create); static void int_thread_release(LHASH_OF(ERR_STATE) **hash); static ERR_STATE *int_thread_get_item(const ERR_STATE *); static ERR_STATE *int_thread_set_item(ERR_STATE *); static void int_thread_del_item(const ERR_STATE *); static int int_err_get_next_lib(void); /* The static ERR_FNS table using these defaults functions */ static const ERR_FNS err_defaults = { int_err_get, int_err_del, int_err_get_item, int_err_set_item, int_err_del_item, int_thread_get, int_thread_release, int_thread_get_item, int_thread_set_item, int_thread_del_item, int_err_get_next_lib }; /* The replacable table of ERR_FNS functions we use at run-time */ static const ERR_FNS *err_fns = NULL; /* Eg. rather than using "err_get()", use "ERRFN(err_get)()". */ #define ERRFN(a) err_fns->cb_##a /* The internal state used by "err_defaults" - as such, the setting, reading, * creating, and deleting of this data should only be permitted via the * "err_defaults" functions. This way, a linked module can completely defer all * ERR state operation (together with requisite locking) to the implementations * and state in the loading application. */ static LHASH_OF(ERR_STRING_DATA) *int_error_hash = NULL; static LHASH_OF(ERR_STATE) *int_thread_hash = NULL; static int int_thread_hash_references = 0; static int int_err_library_number = ERR_LIB_USER; /* Internal function that checks whether "err_fns" is set and if not, sets it to * the defaults. */ static void err_fns_check(void) { if (err_fns) return; CRYPTO_w_lock(CRYPTO_LOCK_ERR); if (!err_fns) err_fns = &err_defaults; CRYPTO_w_unlock(CRYPTO_LOCK_ERR); } /* API functions to get or set the underlying ERR functions. */ const ERR_FNS * ERR_get_implementation(void) { err_fns_check(); return err_fns; } int ERR_set_implementation(const ERR_FNS *fns) { int ret = 0; CRYPTO_w_lock(CRYPTO_LOCK_ERR); /* It's too late if 'err_fns' is non-NULL. BTW: not much point setting * an error is there?! */ if (!err_fns) { err_fns = fns; ret = 1; } CRYPTO_w_unlock(CRYPTO_LOCK_ERR); return ret; } /* These are the callbacks provided to "lh_new()" when creating the LHASH tables * internal to the "err_defaults" implementation. */ static unsigned long get_error_values(int inc, int top, const char **file, int *line, const char **data, int *flags); /* The internal functions used in the "err_defaults" implementation */ static unsigned long err_string_data_hash(const ERR_STRING_DATA *a) { unsigned long ret, l; l = a->error; ret = l^ERR_GET_LIB(l)^ERR_GET_FUNC(l); return (ret^ret % 19*13); } static IMPLEMENT_LHASH_HASH_FN(err_string_data, ERR_STRING_DATA) static int err_string_data_cmp(const ERR_STRING_DATA *a, const ERR_STRING_DATA *b) { return (int)(a->error - b->error); } static IMPLEMENT_LHASH_COMP_FN(err_string_data, ERR_STRING_DATA) static LHASH_OF(ERR_STRING_DATA) *int_err_get(int create) { LHASH_OF(ERR_STRING_DATA) *ret = NULL; CRYPTO_w_lock(CRYPTO_LOCK_ERR); if (!int_error_hash && create) { CRYPTO_push_info("int_err_get (err.c)"); int_error_hash = lh_ERR_STRING_DATA_new(); CRYPTO_pop_info(); } if (int_error_hash) ret = int_error_hash; CRYPTO_w_unlock(CRYPTO_LOCK_ERR); return ret; } static void int_err_del(void) { CRYPTO_w_lock(CRYPTO_LOCK_ERR); if (int_error_hash) { lh_ERR_STRING_DATA_free(int_error_hash); int_error_hash = NULL; } CRYPTO_w_unlock(CRYPTO_LOCK_ERR); } static ERR_STRING_DATA * int_err_get_item(const ERR_STRING_DATA *d) { ERR_STRING_DATA *p; LHASH_OF(ERR_STRING_DATA) *hash; err_fns_check(); hash = ERRFN(err_get)(0); if (!hash) return NULL; CRYPTO_r_lock(CRYPTO_LOCK_ERR); p = lh_ERR_STRING_DATA_retrieve(hash, d); CRYPTO_r_unlock(CRYPTO_LOCK_ERR); return p; } static ERR_STRING_DATA * int_err_set_item(ERR_STRING_DATA *d) { ERR_STRING_DATA *p; LHASH_OF(ERR_STRING_DATA) *hash; err_fns_check(); hash = ERRFN(err_get)(1); if (!hash) return NULL; CRYPTO_w_lock(CRYPTO_LOCK_ERR); p = lh_ERR_STRING_DATA_insert(hash, d); CRYPTO_w_unlock(CRYPTO_LOCK_ERR); return p; } static ERR_STRING_DATA * int_err_del_item(ERR_STRING_DATA *d) { ERR_STRING_DATA *p; LHASH_OF(ERR_STRING_DATA) *hash; err_fns_check(); hash = ERRFN(err_get)(0); if (!hash) return NULL; CRYPTO_w_lock(CRYPTO_LOCK_ERR); p = lh_ERR_STRING_DATA_delete(hash, d); CRYPTO_w_unlock(CRYPTO_LOCK_ERR); return p; } static unsigned long err_state_hash(const ERR_STATE *a) { return CRYPTO_THREADID_hash(&a->tid) * 13; } static IMPLEMENT_LHASH_HASH_FN(err_state, ERR_STATE) static int err_state_cmp(const ERR_STATE *a, const ERR_STATE *b) { return CRYPTO_THREADID_cmp(&a->tid, &b->tid); } static IMPLEMENT_LHASH_COMP_FN(err_state, ERR_STATE) static LHASH_OF(ERR_STATE) *int_thread_get(int create) { LHASH_OF(ERR_STATE) *ret = NULL; CRYPTO_w_lock(CRYPTO_LOCK_ERR); if (!int_thread_hash && create) { CRYPTO_push_info("int_thread_get (err.c)"); int_thread_hash = lh_ERR_STATE_new(); CRYPTO_pop_info(); } if (int_thread_hash) { int_thread_hash_references++; ret = int_thread_hash; } CRYPTO_w_unlock(CRYPTO_LOCK_ERR); return ret; } static void int_thread_release(LHASH_OF(ERR_STATE) **hash) { int i; if (hash == NULL || *hash == NULL) return; i = CRYPTO_add(&int_thread_hash_references, -1, CRYPTO_LOCK_ERR); if (i > 0) return; *hash = NULL; } static ERR_STATE * int_thread_get_item(const ERR_STATE *d) { ERR_STATE *p; LHASH_OF(ERR_STATE) *hash; err_fns_check(); hash = ERRFN(thread_get)(0); if (!hash) return NULL; CRYPTO_r_lock(CRYPTO_LOCK_ERR); p = lh_ERR_STATE_retrieve(hash, d); CRYPTO_r_unlock(CRYPTO_LOCK_ERR); ERRFN(thread_release)(&hash); return p; } static ERR_STATE * int_thread_set_item(ERR_STATE *d) { ERR_STATE *p; LHASH_OF(ERR_STATE) *hash; err_fns_check(); hash = ERRFN(thread_get)(1); if (!hash) return NULL; CRYPTO_w_lock(CRYPTO_LOCK_ERR); p = lh_ERR_STATE_insert(hash, d); CRYPTO_w_unlock(CRYPTO_LOCK_ERR); ERRFN(thread_release)(&hash); return p; } static void int_thread_del_item(const ERR_STATE *d) { ERR_STATE *p; LHASH_OF(ERR_STATE) *hash; err_fns_check(); hash = ERRFN(thread_get)(0); if (!hash) return; CRYPTO_w_lock(CRYPTO_LOCK_ERR); p = lh_ERR_STATE_delete(hash, d); /* make sure we don't leak memory */ if (int_thread_hash_references == 1 && int_thread_hash && lh_ERR_STATE_num_items(int_thread_hash) == 0) { lh_ERR_STATE_free(int_thread_hash); int_thread_hash = NULL; } CRYPTO_w_unlock(CRYPTO_LOCK_ERR); ERRFN(thread_release)(&hash); if (p) ERR_STATE_free(p); } static int int_err_get_next_lib(void) { int ret; CRYPTO_w_lock(CRYPTO_LOCK_ERR); ret = int_err_library_number++; CRYPTO_w_unlock(CRYPTO_LOCK_ERR); return ret; } #ifndef OPENSSL_NO_ERR #define NUM_SYS_STR_REASONS 127 #define LEN_SYS_STR_REASON 32 static ERR_STRING_DATA SYS_str_reasons[NUM_SYS_STR_REASONS + 1]; /* SYS_str_reasons is filled with copies of strerror() results at * initialization. * 'errno' values up to 127 should cover all usual errors, * others will be displayed numerically by ERR_error_string. * It is crucial that we have something for each reason code * that occurs in ERR_str_reasons, or bogus reason strings * will be returned for SYSerr(), which always gets an errno * value and never one of those 'standard' reason codes. */ static void build_SYS_str_reasons(void) { /* malloc cannot be used here, use static storage instead */ static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON]; int i; static int init = 1; CRYPTO_r_lock(CRYPTO_LOCK_ERR); if (!init) { CRYPTO_r_unlock(CRYPTO_LOCK_ERR); return; } CRYPTO_r_unlock(CRYPTO_LOCK_ERR); CRYPTO_w_lock(CRYPTO_LOCK_ERR); if (!init) { CRYPTO_w_unlock(CRYPTO_LOCK_ERR); return; } for (i = 1; i <= NUM_SYS_STR_REASONS; i++) { ERR_STRING_DATA *str = &SYS_str_reasons[i - 1]; str->error = (unsigned long)i; if (str->string == NULL) { char (*dest)[LEN_SYS_STR_REASON] = &(strerror_tab[i - 1]); char *src = strerror(i); if (src != NULL) { strlcpy(*dest, src, sizeof *dest); str->string = *dest; } } if (str->string == NULL) str->string = "unknown"; } /* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL}, * as required by ERR_load_strings. */ init = 0; CRYPTO_w_unlock(CRYPTO_LOCK_ERR); } #endif #define err_clear_data(p,i) \ do { \ if (((p)->err_data[i] != NULL) && \ (p)->err_data_flags[i] & ERR_TXT_MALLOCED) { \ free((p)->err_data[i]); \ (p)->err_data[i] = NULL; \ } \ (p)->err_data_flags[i] = 0; \ } while(0) #define err_clear(p,i) \ do { \ (p)->err_flags[i] = 0; \ (p)->err_buffer[i] = 0; \ err_clear_data(p, i); \ (p)->err_file[i] = NULL; \ (p)->err_line[i] = -1; \ } while(0) static void ERR_STATE_free(ERR_STATE *s) { int i; if (s == NULL) return; for (i = 0; i < ERR_NUM_ERRORS; i++) { err_clear_data(s, i); } free(s); } void ERR_load_ERR_strings(void) { err_fns_check(); #ifndef OPENSSL_NO_ERR err_load_strings(0, ERR_str_libraries); err_load_strings(0, ERR_str_reasons); err_load_strings(ERR_LIB_SYS, ERR_str_functs); build_SYS_str_reasons(); err_load_strings(ERR_LIB_SYS, SYS_str_reasons); #endif } static void err_load_strings(int lib, ERR_STRING_DATA *str) { while (str->error) { if (lib) str->error |= ERR_PACK(lib, 0, 0); ERRFN(err_set_item)(str); str++; } } void ERR_load_strings(int lib, ERR_STRING_DATA *str) { ERR_load_ERR_strings(); err_load_strings(lib, str); } void ERR_unload_strings(int lib, ERR_STRING_DATA *str) { while (str->error) { if (lib) str->error |= ERR_PACK(lib, 0, 0); ERRFN(err_del_item)(str); str++; } } void ERR_free_strings(void) { err_fns_check(); ERRFN(err_del)(); } /********************************************************/ void ERR_put_error(int lib, int func, int reason, const char *file, int line) { ERR_STATE *es; int save_errno = errno; es = ERR_get_state(); es->top = (es->top + 1) % ERR_NUM_ERRORS; if (es->top == es->bottom) es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS; es->err_flags[es->top] = 0; es->err_buffer[es->top] = ERR_PACK(lib, func, reason); es->err_file[es->top] = file; es->err_line[es->top] = line; err_clear_data(es, es->top); errno = save_errno; } void ERR_clear_error(void) { int i; ERR_STATE *es; es = ERR_get_state(); for (i = 0; i < ERR_NUM_ERRORS; i++) { err_clear(es, i); } es->top = es->bottom = 0; } unsigned long ERR_get_error(void) { return (get_error_values(1, 0, NULL, NULL, NULL, NULL)); } unsigned long ERR_get_error_line(const char **file, int *line) { return (get_error_values(1, 0, file, line, NULL, NULL)); } unsigned long ERR_get_error_line_data(const char **file, int *line, const char **data, int *flags) { return (get_error_values(1, 0, file, line, data, flags)); } unsigned long ERR_peek_error(void) { return (get_error_values(0, 0, NULL, NULL, NULL, NULL)); } unsigned long ERR_peek_error_line(const char **file, int *line) { return (get_error_values(0, 0, file, line, NULL, NULL)); } unsigned long ERR_peek_error_line_data(const char **file, int *line, const char **data, int *flags) { return (get_error_values(0, 0, file, line, data, flags)); } unsigned long ERR_peek_last_error(void) { return (get_error_values(0, 1, NULL, NULL, NULL, NULL)); } unsigned long ERR_peek_last_error_line(const char **file, int *line) { return (get_error_values(0, 1, file, line, NULL, NULL)); } unsigned long ERR_peek_last_error_line_data(const char **file, int *line, const char **data, int *flags) { return (get_error_values(0, 1, file, line, data, flags)); } static unsigned long get_error_values(int inc, int top, const char **file, int *line, const char **data, int *flags) { int i = 0; ERR_STATE *es; unsigned long ret; es = ERR_get_state(); if (inc && top) { if (file) *file = ""; if (line) *line = 0; if (data) *data = ""; if (flags) *flags = 0; return ERR_R_INTERNAL_ERROR; } if (es->bottom == es->top) return 0; if (top) i = es->top; /* last error */ else i = (es->bottom + 1) % ERR_NUM_ERRORS; /* first error */ ret = es->err_buffer[i]; if (inc) { es->bottom = i; es->err_buffer[i] = 0; } if ((file != NULL) && (line != NULL)) { if (es->err_file[i] == NULL) { *file = "NA"; if (line != NULL) *line = 0; } else { *file = es->err_file[i]; if (line != NULL) *line = es->err_line[i]; } } if (data == NULL) { if (inc) { err_clear_data(es, i); } } else { if (es->err_data[i] == NULL) { *data = ""; if (flags != NULL) *flags = 0; } else { *data = es->err_data[i]; if (flags != NULL) *flags = es->err_data_flags[i]; } } return ret; } void ERR_error_string_n(unsigned long e, char *buf, size_t len) { char lsbuf[30], fsbuf[30], rsbuf[30]; const char *ls, *fs, *rs; int l, f, r, ret; l = ERR_GET_LIB(e); f = ERR_GET_FUNC(e); r = ERR_GET_REASON(e); ls = ERR_lib_error_string(e); fs = ERR_func_error_string(e); rs = ERR_reason_error_string(e); if (ls == NULL) { (void) snprintf(lsbuf, sizeof(lsbuf), "lib(%d)", l); ls = lsbuf; } if (fs == NULL) { (void) snprintf(fsbuf, sizeof(fsbuf), "func(%d)", f); fs = fsbuf; } if (rs == NULL) { (void) snprintf(rsbuf, sizeof(rsbuf), "reason(%d)", r); rs = rsbuf; } ret = snprintf(buf, len, "error:%08lX:%s:%s:%s", e, ls, fs, rs); if (ret == -1) return; /* can't happen, and can't do better if it does */ if (ret >= len) { /* output may be truncated; make sure we always have 5 * colon-separated fields, i.e. 4 colons ... */ #define NUM_COLONS 4 if (len > NUM_COLONS) /* ... if possible */ { int i; char *s = buf; for (i = 0; i < NUM_COLONS; i++) { char *colon = strchr(s, ':'); if (colon == NULL || colon > &buf[len - 1] - NUM_COLONS + i) { /* set colon no. i at last possible position * (buf[len-1] is the terminating 0)*/ colon = &buf[len - 1] - NUM_COLONS + i; *colon = ':'; } s = colon + 1; } } } } /* BAD for multi-threading: uses a local buffer if ret == NULL */ /* ERR_error_string_n should be used instead for ret != NULL * as ERR_error_string cannot know how large the buffer is */ char * ERR_error_string(unsigned long e, char *ret) { static char buf[256]; if (ret == NULL) ret = buf; ERR_error_string_n(e, ret, 256); return ret; } LHASH_OF(ERR_STRING_DATA) *ERR_get_string_table(void) { err_fns_check(); return ERRFN(err_get)(0); } LHASH_OF(ERR_STATE) *ERR_get_err_state_table(void) { err_fns_check(); return ERRFN(thread_get)(0); } void ERR_release_err_state_table(LHASH_OF(ERR_STATE) **hash) { err_fns_check(); ERRFN(thread_release)(hash); } const char * ERR_lib_error_string(unsigned long e) { ERR_STRING_DATA d, *p; unsigned long l; err_fns_check(); l = ERR_GET_LIB(e); d.error = ERR_PACK(l, 0, 0); p = ERRFN(err_get_item)(&d); return ((p == NULL) ? NULL : p->string); } const char * ERR_func_error_string(unsigned long e) { ERR_STRING_DATA d, *p; unsigned long l, f; err_fns_check(); l = ERR_GET_LIB(e); f = ERR_GET_FUNC(e); d.error = ERR_PACK(l, f, 0); p = ERRFN(err_get_item)(&d); return ((p == NULL) ? NULL : p->string); } const char * ERR_reason_error_string(unsigned long e) { ERR_STRING_DATA d, *p = NULL; unsigned long l, r; err_fns_check(); l = ERR_GET_LIB(e); r = ERR_GET_REASON(e); d.error = ERR_PACK(l, 0, r); p = ERRFN(err_get_item)(&d); if (!p) { d.error = ERR_PACK(0, 0, r); p = ERRFN(err_get_item)(&d); } return ((p == NULL) ? NULL : p->string); } void ERR_remove_thread_state(const CRYPTO_THREADID *id) { ERR_STATE tmp; if (id) CRYPTO_THREADID_cpy(&tmp.tid, id); else CRYPTO_THREADID_current(&tmp.tid); err_fns_check(); /* thread_del_item automatically destroys the LHASH if the number of * items reaches zero. */ ERRFN(thread_del_item)(&tmp); } #ifndef OPENSSL_NO_DEPRECATED void ERR_remove_state(unsigned long pid) { ERR_remove_thread_state(NULL); } #endif ERR_STATE * ERR_get_state(void) { static ERR_STATE fallback; ERR_STATE *ret, tmp, *tmpp = NULL; int i; CRYPTO_THREADID tid; err_fns_check(); CRYPTO_THREADID_current(&tid); CRYPTO_THREADID_cpy(&tmp.tid, &tid); ret = ERRFN(thread_get_item)(&tmp); /* ret == the error state, if NULL, make a new one */ if (ret == NULL) { ret = malloc(sizeof(ERR_STATE)); if (ret == NULL) return (&fallback); CRYPTO_THREADID_cpy(&ret->tid, &tid); ret->top = 0; ret->bottom = 0; for (i = 0; i < ERR_NUM_ERRORS; i++) { ret->err_data[i] = NULL; ret->err_data_flags[i] = 0; } tmpp = ERRFN(thread_set_item)(ret); /* To check if insertion failed, do a get. */ if (ERRFN(thread_get_item)(ret) != ret) { ERR_STATE_free(ret); /* could not insert it */ return (&fallback); } /* If a race occured in this function and we came second, tmpp * is the first one that we just replaced. */ if (tmpp) ERR_STATE_free(tmpp); } return ret; } int ERR_get_next_error_library(void) { err_fns_check(); return ERRFN(get_next_lib)(); } void ERR_set_error_data(char *data, int flags) { ERR_STATE *es; int i; es = ERR_get_state(); i = es->top; if (i == 0) i = ERR_NUM_ERRORS - 1; err_clear_data(es, i); es->err_data[i] = data; es->err_data_flags[i] = flags; } void ERR_asprintf_error_data(char * format, ...) { char *errbuf = NULL; va_list ap; int r; va_start(ap, format); r = vasprintf(&errbuf, format, ap); va_end(ap); if (r == -1) ERR_set_error_data("malloc failed", ERR_TXT_STRING); else ERR_set_error_data(errbuf, ERR_TXT_MALLOCED|ERR_TXT_STRING); } void ERR_add_error_data(int num, ...) { va_list args; va_start(args, num); ERR_add_error_vdata(num, args); va_end(args); } void ERR_add_error_vdata(int num, va_list args) { char format[129]; char *errbuf; format[0] = '\0'; int i; for (i = 0; i < num; i++) { if (strlcat(format, "%s", sizeof(format)) >= sizeof(format)) { ERR_set_error_data("too many errors", ERR_TXT_STRING); return; } } if (vasprintf(&errbuf, format, args) == -1) ERR_set_error_data("malloc failed", ERR_TXT_STRING); else ERR_set_error_data(errbuf, ERR_TXT_MALLOCED|ERR_TXT_STRING); } int ERR_set_mark(void) { ERR_STATE *es; es = ERR_get_state(); if (es->bottom == es->top) return 0; es->err_flags[es->top] |= ERR_FLAG_MARK; return 1; } int ERR_pop_to_mark(void) { ERR_STATE *es; es = ERR_get_state(); while (es->bottom != es->top && (es->err_flags[es->top] & ERR_FLAG_MARK) == 0) { err_clear(es, es->top); es->top -= 1; if (es->top == -1) es->top = ERR_NUM_ERRORS - 1; } if (es->bottom == es->top) return 0; es->err_flags[es->top]&=~ERR_FLAG_MARK; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/err/err_prn.c0000644000175000017500000001053012360020705020655 0ustar /* $OpenBSD: err_prn.c,v 1.15 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), void *u) { unsigned long l; char buf[256]; char buf2[4096]; const char *file, *data; int line, flags; unsigned long es; CRYPTO_THREADID cur; CRYPTO_THREADID_current(&cur); es = CRYPTO_THREADID_hash(&cur); while ((l = ERR_get_error_line_data(&file, &line, &data, &flags)) != 0) { ERR_error_string_n(l, buf, sizeof buf); (void) snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", es, buf, file, line, (flags & ERR_TXT_STRING) ? data : ""); if (cb(buf2, strlen(buf2), u) <= 0) break; /* abort outputting the error report */ } } static int print_fp(const char *str, size_t len, void *fp) { BIO bio; BIO_set(&bio, BIO_s_file()); BIO_set_fp(&bio, fp, BIO_NOCLOSE); return BIO_printf(&bio, "%s", str); } void ERR_print_errors_fp(FILE *fp) { ERR_print_errors_cb(print_fp, fp); } static int print_bio(const char *str, size_t len, void *bp) { return BIO_write((BIO *)bp, str, len); } void ERR_print_errors(BIO *bp) { ERR_print_errors_cb(print_bio, bp); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/md32_common.h0000644000175000017500000002734512360020705020554 0ustar /* $OpenBSD: md32_common.h,v 1.15 2014/06/12 15:49:27 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * */ /* * This is a generic 32 bit "collector" for message digest algorithms. * Whenever needed it collects input character stream into chunks of * 32 bit values and invokes a block function that performs actual hash * calculations. * * Porting guide. * * Obligatory macros: * * DATA_ORDER_IS_BIG_ENDIAN or DATA_ORDER_IS_LITTLE_ENDIAN * this macro defines byte order of input stream. * HASH_CBLOCK * size of a unit chunk HASH_BLOCK operates on. * HASH_LONG * has to be at lest 32 bit wide, if it's wider, then * HASH_LONG_LOG2 *has to* be defined along * HASH_CTX * context structure that at least contains following * members: * typedef struct { * ... * HASH_LONG Nl,Nh; * either { * HASH_LONG data[HASH_LBLOCK]; * unsigned char data[HASH_CBLOCK]; * }; * unsigned int num; * ... * } HASH_CTX; * data[] vector is expected to be zeroed upon first call to * HASH_UPDATE. * HASH_UPDATE * name of "Update" function, implemented here. * HASH_TRANSFORM * name of "Transform" function, implemented here. * HASH_FINAL * name of "Final" function, implemented here. * HASH_BLOCK_DATA_ORDER * name of "block" function capable of treating *unaligned* input * message in original (data) byte order, implemented externally. * HASH_MAKE_STRING * macro convering context variables to an ASCII hash string. * * MD5 example: * * #define DATA_ORDER_IS_LITTLE_ENDIAN * * #define HASH_LONG MD5_LONG * #define HASH_LONG_LOG2 MD5_LONG_LOG2 * #define HASH_CTX MD5_CTX * #define HASH_CBLOCK MD5_CBLOCK * #define HASH_UPDATE MD5_Update * #define HASH_TRANSFORM MD5_Transform * #define HASH_FINAL MD5_Final * #define HASH_BLOCK_DATA_ORDER md5_block_data_order * * */ #include #if !defined(DATA_ORDER_IS_BIG_ENDIAN) && !defined(DATA_ORDER_IS_LITTLE_ENDIAN) #error "DATA_ORDER must be defined!" #endif #ifndef HASH_CBLOCK #error "HASH_CBLOCK must be defined!" #endif #ifndef HASH_LONG #error "HASH_LONG must be defined!" #endif #ifndef HASH_CTX #error "HASH_CTX must be defined!" #endif #ifndef HASH_UPDATE #error "HASH_UPDATE must be defined!" #endif #ifndef HASH_TRANSFORM #error "HASH_TRANSFORM must be defined!" #endif #ifndef HASH_FINAL #error "HASH_FINAL must be defined!" #endif #ifndef HASH_BLOCK_DATA_ORDER #error "HASH_BLOCK_DATA_ORDER must be defined!" #endif /* * Engage compiler specific rotate intrinsic function if available. */ #undef ROTATE #if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) /* * Some GNU C inline assembler templates. Note that these are * rotates by *constant* number of bits! But that's exactly * what we need here... * */ # if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) # define ROTATE(a,n) ({ register unsigned int ret; \ asm ( \ "roll %1,%0" \ : "=r"(ret) \ : "I"(n), "0"((unsigned int)(a)) \ : "cc"); \ ret; \ }) # elif defined(_ARCH_PPC) || defined(_ARCH_PPC64) || \ defined(__powerpc) || defined(__ppc__) || defined(__powerpc64__) # define ROTATE(a,n) ({ register unsigned int ret; \ asm ( \ "rlwinm %0,%1,%2,0,31" \ : "=r"(ret) \ : "r"(a), "I"(n)); \ ret; \ }) # elif defined(__s390x__) # define ROTATE(a,n) ({ register unsigned int ret; \ asm ("rll %0,%1,%2" \ : "=r"(ret) \ : "r"(a), "I"(n)); \ ret; \ }) # endif #endif #ifndef ROTATE #define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n)))) #endif #if defined(DATA_ORDER_IS_BIG_ENDIAN) #if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) # if ((defined(__i386) || defined(__i386__)) && !defined(I386_ONLY)) || \ (defined(__x86_64) || defined(__x86_64__)) /* * This gives ~30-40% performance improvement in SHA-256 compiled * with gcc [on P4]. Well, first macro to be frank. We can pull * this trick on x86* platforms only, because these CPUs can fetch * unaligned data without raising an exception. */ # define HOST_c2l(c,l) ({ unsigned int r=*((const unsigned int *)(c)); \ asm ("bswapl %0":"=r"(r):"0"(r)); \ (c)+=4; (l)=r; }) # define HOST_l2c(l,c) ({ unsigned int r=(l); \ asm ("bswapl %0":"=r"(r):"0"(r)); \ *((unsigned int *)(c))=r; (c)+=4; r; }) # endif #endif #if defined(__s390__) || defined(__s390x__) # define HOST_c2l(c,l) ((l)=*((const unsigned int *)(c)), (c)+=4, (l)) # define HOST_l2c(l,c) (*((unsigned int *)(c))=(l), (c)+=4, (l)) #endif #ifndef HOST_c2l #define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++)))<<24), \ l|=(((unsigned long)(*((c)++)))<<16), \ l|=(((unsigned long)(*((c)++)))<< 8), \ l|=(((unsigned long)(*((c)++))) ), \ l) #endif #ifndef HOST_l2c #define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \ *((c)++)=(unsigned char)(((l)>>16)&0xff), \ *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ *((c)++)=(unsigned char)(((l) )&0xff), \ l) #endif #elif defined(DATA_ORDER_IS_LITTLE_ENDIAN) #if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) # if defined(__s390x__) # define HOST_c2l(c,l) ({ asm ("lrv %0,%1" \ :"=d"(l) :"m"(*(const unsigned int *)(c)));\ (c)+=4; (l); }) # define HOST_l2c(l,c) ({ asm ("strv %1,%0" \ :"=m"(*(unsigned int *)(c)) :"d"(l));\ (c)+=4; (l); }) # endif #endif #if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) # define HOST_c2l(c,l) ((l)=*((const unsigned int *)(c)), (c)+=4, l) # define HOST_l2c(l,c) (*((unsigned int *)(c))=(l), (c)+=4, l) #endif #ifndef HOST_c2l #define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \ l|=(((unsigned long)(*((c)++)))<< 8), \ l|=(((unsigned long)(*((c)++)))<<16), \ l|=(((unsigned long)(*((c)++)))<<24), \ l) #endif #ifndef HOST_l2c #define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ *((c)++)=(unsigned char)(((l)>>16)&0xff), \ *((c)++)=(unsigned char)(((l)>>24)&0xff), \ l) #endif #endif /* * Time for some action:-) */ int HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len) { const unsigned char *data = data_; unsigned char *p; HASH_LONG l; size_t n; if (len == 0) return 1; l = (c->Nl + (((HASH_LONG)len) << 3))&0xffffffffUL; /* 95-05-24 eay Fixed a bug with the overflow handling, thanks to * Wei Dai for pointing it out. */ if (l < c->Nl) /* overflow */ c->Nh++; c->Nh+=(HASH_LONG)(len>>29); /* might cause compiler warning on 16-bit */ c->Nl = l; n = c->num; if (n != 0) { p = (unsigned char *)c->data; if (len >= HASH_CBLOCK || len + n >= HASH_CBLOCK) { memcpy (p + n, data, HASH_CBLOCK - n); HASH_BLOCK_DATA_ORDER (c, p, 1); n = HASH_CBLOCK - n; data += n; len -= n; c->num = 0; memset (p,0,HASH_CBLOCK); /* keep it zeroed */ } else { memcpy (p + n, data, len); c->num += (unsigned int)len; return 1; } } n = len/HASH_CBLOCK; if (n > 0) { HASH_BLOCK_DATA_ORDER (c, data, n); n *= HASH_CBLOCK; data += n; len -= n; } if (len != 0) { p = (unsigned char *)c->data; c->num = (unsigned int)len; memcpy (p, data, len); } return 1; } void HASH_TRANSFORM (HASH_CTX *c, const unsigned char *data) { HASH_BLOCK_DATA_ORDER (c, data, 1); } int HASH_FINAL (unsigned char *md, HASH_CTX *c) { unsigned char *p = (unsigned char *)c->data; size_t n = c->num; p[n] = 0x80; /* there is always room for one */ n++; if (n > (HASH_CBLOCK - 8)) { memset (p + n, 0, HASH_CBLOCK - n); n = 0; HASH_BLOCK_DATA_ORDER (c, p, 1); } memset (p + n, 0, HASH_CBLOCK - 8 - n); p += HASH_CBLOCK - 8; #if defined(DATA_ORDER_IS_BIG_ENDIAN) (void)HOST_l2c(c->Nh, p); (void)HOST_l2c(c->Nl, p); #elif defined(DATA_ORDER_IS_LITTLE_ENDIAN) (void)HOST_l2c(c->Nl, p); (void)HOST_l2c(c->Nh, p); #endif p -= HASH_CBLOCK; HASH_BLOCK_DATA_ORDER (c, p, 1); c->num = 0; memset (p, 0, HASH_CBLOCK); #ifndef HASH_MAKE_STRING #error "HASH_MAKE_STRING must be defined!" #else HASH_MAKE_STRING(c, md); #endif return 1; } #ifndef MD32_REG_T #if defined(__alpha) || defined(__sparcv9) || defined(__mips) #define MD32_REG_T long /* * This comment was originaly written for MD5, which is why it * discusses A-D. But it basically applies to all 32-bit digests, * which is why it was moved to common header file. * * In case you wonder why A-D are declared as long and not * as MD5_LONG. Doing so results in slight performance * boost on LP64 architectures. The catch is we don't * really care if 32 MSBs of a 64-bit register get polluted * with eventual overflows as we *save* only 32 LSBs in * *either* case. Now declaring 'em long excuses the compiler * from keeping 32 MSBs zeroed resulting in 13% performance * improvement under SPARC Solaris7/64 and 5% under AlphaLinux. * Well, to be honest it should say that this *prevents* * performance degradation. * */ #else /* * Above is not absolute and there are LP64 compilers that * generate better code if MD32_REG_T is defined int. The above * pre-processor condition reflects the circumstances under which * the conclusion was made and is subject to further extension. * */ #define MD32_REG_T int #endif #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/mdc2/0000755000000000000000000000000012666635521020677 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/mdc2/mdc2dgst.c0000644000175000017500000001267512360020706020767 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #undef c2l #define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \ l|=((DES_LONG)(*((c)++)))<< 8L, \ l|=((DES_LONG)(*((c)++)))<<16L, \ l|=((DES_LONG)(*((c)++)))<<24L) #undef l2c #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>>24L)&0xff)) static void mdc2_body(MDC2_CTX *c, const unsigned char *in, size_t len); int MDC2_Init(MDC2_CTX *c) { c->num=0; c->pad_type=1; memset(&(c->h[0]),0x52,MDC2_BLOCK); memset(&(c->hh[0]),0x25,MDC2_BLOCK); return 1; } int MDC2_Update(MDC2_CTX *c, const unsigned char *in, size_t len) { size_t i,j; i=c->num; if (i != 0) { if (i+len < MDC2_BLOCK) { /* partial block */ memcpy(&(c->data[i]),in,len); c->num+=(int)len; return 1; } else { /* filled one */ j=MDC2_BLOCK-i; memcpy(&(c->data[i]),in,j); len-=j; in+=j; c->num=0; mdc2_body(c,&(c->data[0]),MDC2_BLOCK); } } i=len&~((size_t)MDC2_BLOCK-1); if (i > 0) mdc2_body(c,in,i); j=len-i; if (j > 0) { memcpy(&(c->data[0]),&(in[i]),j); c->num=(int)j; } return 1; } static void mdc2_body(MDC2_CTX *c, const unsigned char *in, size_t len) { register DES_LONG tin0,tin1; register DES_LONG ttin0,ttin1; DES_LONG d[2],dd[2]; DES_key_schedule k; unsigned char *p; size_t i; for (i=0; ih[0]=(c->h[0]&0x9f)|0x40; c->hh[0]=(c->hh[0]&0x9f)|0x20; DES_set_odd_parity(&c->h); DES_set_key_unchecked(&c->h,&k); DES_encrypt1(d,&k,1); DES_set_odd_parity(&c->hh); DES_set_key_unchecked(&c->hh,&k); DES_encrypt1(dd,&k,1); ttin0=tin0^dd[0]; ttin1=tin1^dd[1]; tin0^=d[0]; tin1^=d[1]; p=c->h; l2c(tin0,p); l2c(ttin1,p); p=c->hh; l2c(ttin0,p); l2c(tin1,p); } } int MDC2_Final(unsigned char *md, MDC2_CTX *c) { unsigned int i; int j; i=c->num; j=c->pad_type; if ((i > 0) || (j == 2)) { if (j == 2) c->data[i++]=0x80; memset(&(c->data[i]),0,MDC2_BLOCK-i); mdc2_body(c,c->data,MDC2_BLOCK); } memcpy(md,(char *)c->h,MDC2_BLOCK); memcpy(&(md[MDC2_BLOCK]),(char *)c->hh,MDC2_BLOCK); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/mdc2/mdc2_one.c0000644000175000017500000000706112360020706020737 0ustar /* $OpenBSD: mdc2_one.c,v 1.3 2014/06/12 15:49:29 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include unsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md) { MDC2_CTX c; static unsigned char m[MDC2_DIGEST_LENGTH]; if (md == NULL) md=m; if (!MDC2_Init(&c)) return NULL; MDC2_Update(&c,d,n); MDC2_Final(md,&c); OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */ return(md); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/idea/0000755000000000000000000000000012666635521020754 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/idea/i_cbc.c0000644000175000017500000001200512360020705020356 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "idea_lcl.h" void idea_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int encrypt) { register unsigned long tin0,tin1; register unsigned long tout0,tout1,xor0,xor1; register long l=length; unsigned long tin[2]; if (encrypt) { n2l(iv,tout0); n2l(iv,tout1); iv-=8; for (l-=8; l>=0; l-=8) { n2l(in,tin0); n2l(in,tin1); tin0^=tout0; tin1^=tout1; tin[0]=tin0; tin[1]=tin1; idea_encrypt(tin,ks); tout0=tin[0]; l2n(tout0,out); tout1=tin[1]; l2n(tout1,out); } if (l != -8) { n2ln(in,tin0,tin1,l+8); tin0^=tout0; tin1^=tout1; tin[0]=tin0; tin[1]=tin1; idea_encrypt(tin,ks); tout0=tin[0]; l2n(tout0,out); tout1=tin[1]; l2n(tout1,out); } l2n(tout0,iv); l2n(tout1,iv); } else { n2l(iv,xor0); n2l(iv,xor1); iv-=8; for (l-=8; l>=0; l-=8) { n2l(in,tin0); tin[0]=tin0; n2l(in,tin1); tin[1]=tin1; idea_encrypt(tin,ks); tout0=tin[0]^xor0; tout1=tin[1]^xor1; l2n(tout0,out); l2n(tout1,out); xor0=tin0; xor1=tin1; } if (l != -8) { n2l(in,tin0); tin[0]=tin0; n2l(in,tin1); tin[1]=tin1; idea_encrypt(tin,ks); tout0=tin[0]^xor0; tout1=tin[1]^xor1; l2nn(tout0,tout1,out,l+8); xor0=tin0; xor1=tin1; } l2n(xor0,iv); l2n(xor1,iv); } tin0=tin1=tout0=tout1=xor0=xor1=0; tin[0]=tin[1]=0; } void idea_encrypt(unsigned long *d, IDEA_KEY_SCHEDULE *key) { register IDEA_INT *p; register unsigned long x1,x2,x3,x4,t0,t1,ul; x2=d[0]; x1=(x2>>16); x4=d[1]; x3=(x4>>16); p= &(key->data[0][0]); E_IDEA(0); E_IDEA(1); E_IDEA(2); E_IDEA(3); E_IDEA(4); E_IDEA(5); E_IDEA(6); E_IDEA(7); x1&=0xffff; idea_mul(x1,x1,*p,ul); p++; t0= x3+ *(p++); t1= x2+ *(p++); x4&=0xffff; idea_mul(x4,x4,*p,ul); d[0]=(t0&0xffff)|((x1&0xffff)<<16); d[1]=(x4&0xffff)|((t1&0xffff)<<16); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/idea/i_ofb64.c0000644000175000017500000001016212360020705020551 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "idea_lcl.h" /* The input and output encrypted as though 64bit ofb mode is being * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ void idea_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, IDEA_KEY_SCHEDULE *schedule, unsigned char *ivec, int *num) { register unsigned long v0,v1,t; register int n= *num; register long l=length; unsigned char d[8]; register char *dp; unsigned long ti[2]; unsigned char *iv; int save=0; iv=(unsigned char *)ivec; n2l(iv,v0); n2l(iv,v1); ti[0]=v0; ti[1]=v1; dp=(char *)d; l2n(v0,dp); l2n(v1,dp); while (l--) { if (n == 0) { idea_encrypt((unsigned long *)ti,schedule); dp=(char *)d; t=ti[0]; l2n(t,dp); t=ti[1]; l2n(t,dp); save++; } *(out++)= *(in++)^d[n]; n=(n+1)&0x07; } if (save) { v0=ti[0]; v1=ti[1]; iv=(unsigned char *)ivec; l2n(v0,iv); l2n(v1,iv); } t=v0=v1=ti[0]=ti[1]=0; *num=n; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/idea/i_skey.c0000644000175000017500000001161012360020705020603 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include "idea_lcl.h" static IDEA_INT inverse(unsigned int xin); void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks) { int i; register IDEA_INT *kt,*kf,r0,r1,r2; kt= &(ks->data[0][0]); n2s(key,kt[0]); n2s(key,kt[1]); n2s(key,kt[2]); n2s(key,kt[3]); n2s(key,kt[4]); n2s(key,kt[5]); n2s(key,kt[6]); n2s(key,kt[7]); kf=kt; kt+=8; for (i=0; i<6; i++) { r2= kf[1]; r1= kf[2]; *(kt++)= ((r2<<9) | (r1>>7))&0xffff; r0= kf[3]; *(kt++)= ((r1<<9) | (r0>>7))&0xffff; r1= kf[4]; *(kt++)= ((r0<<9) | (r1>>7))&0xffff; r0= kf[5]; *(kt++)= ((r1<<9) | (r0>>7))&0xffff; r1= kf[6]; *(kt++)= ((r0<<9) | (r1>>7))&0xffff; r0= kf[7]; *(kt++)= ((r1<<9) | (r0>>7))&0xffff; r1= kf[0]; if (i >= 5) break; *(kt++)= ((r0<<9) | (r1>>7))&0xffff; *(kt++)= ((r1<<9) | (r2>>7))&0xffff; kf+=8; } } void idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk) { int r; register IDEA_INT *fp,*tp,t; tp= &(dk->data[0][0]); fp= &(ek->data[8][0]); for (r=0; r<9; r++) { *(tp++)=inverse(fp[0]); *(tp++)=((int)(0x10000L-fp[2])&0xffff); *(tp++)=((int)(0x10000L-fp[1])&0xffff); *(tp++)=inverse(fp[3]); if (r == 8) break; fp-=6; *(tp++)=fp[4]; *(tp++)=fp[5]; } tp= &(dk->data[0][0]); t=tp[1]; tp[1]=tp[2]; tp[2]=t; t=tp[49]; tp[49]=tp[50]; tp[50]=t; } /* taken directly from the 'paper' I'll have a look at it later */ static IDEA_INT inverse(unsigned int xin) { long n1,n2,q,r,b1,b2,t; if (xin == 0) b2=0; else { n1=0x10001; n2=xin; b2=1; b1=0; do { r=(n1%n2); q=(n1-r)/n2; if (r == 0) { if (b2 < 0) b2=0x10001+b2; } else { n1=n2; n2=r; t=b2; b2=b1-q*b2; b1=t; } } while (r != 0); } return((IDEA_INT)b2); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/idea/idea_lcl.h0000644000175000017500000002005712360020705021066 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* The new form of this macro (check if the a*b == 0) was suggested by * Colin Plumb */ /* Removal of the inner if from from Wei Dai 24/4/96 */ #define idea_mul(r,a,b,ul) \ ul=(unsigned long)a*b; \ if (ul != 0) \ { \ r=(ul&0xffff)-(ul>>16); \ r-=((r)>>16); \ } \ else \ r=(-(int)a-b+1); /* assuming a or b is 0 and in range */ #ifdef undef #define idea_mul(r,a,b,ul,sl) \ if (a == 0) r=(0x10001-b)&0xffff; \ else if (b == 0) r=(0x10001-a)&0xffff; \ else { \ ul=(unsigned long)a*b; \ sl=(ul&0xffff)-(ul>>16); \ if (sl <= 0) sl+=0x10001; \ r=sl; \ } #endif /* 7/12/95 - Many thanks to Rhys Weatherley * for pointing out that I was assuming little endian * byte order for all quantities what idea * actually used bigendian. No where in the spec does it mention * this, it is all in terms of 16 bit numbers and even the example * does not use byte streams for the input example :-(. * If you byte swap each pair of input, keys and iv, the functions * would produce the output as the old version :-(. */ /* NOTE - c is not incremented as per n2l */ #define n2ln(c,l1,l2,n) { \ c+=n; \ l1=l2=0; \ switch (n) { \ case 8: l2 =((unsigned long)(*(--(c)))) ; \ case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ case 6: l2|=((unsigned long)(*(--(c))))<<16; \ case 5: l2|=((unsigned long)(*(--(c))))<<24; \ case 4: l1 =((unsigned long)(*(--(c)))) ; \ case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ case 2: l1|=((unsigned long)(*(--(c))))<<16; \ case 1: l1|=((unsigned long)(*(--(c))))<<24; \ } \ } /* NOTE - c is not incremented as per l2n */ #define l2nn(l1,l2,c,n) { \ c+=n; \ switch (n) { \ case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ } \ } #undef n2l #define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ l|=((unsigned long)(*((c)++)))<<16L, \ l|=((unsigned long)(*((c)++)))<< 8L, \ l|=((unsigned long)(*((c)++)))) #undef l2n #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l) )&0xff)) #undef s2n #define s2n(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff)) #undef n2s #define n2s(c,l) (l =((IDEA_INT)(*((c)++)))<< 8L, \ l|=((IDEA_INT)(*((c)++))) ) #ifdef undef /* NOTE - c is not incremented as per c2l */ #define c2ln(c,l1,l2,n) { \ c+=n; \ l1=l2=0; \ switch (n) { \ case 8: l2 =((unsigned long)(*(--(c))))<<24; \ case 7: l2|=((unsigned long)(*(--(c))))<<16; \ case 6: l2|=((unsigned long)(*(--(c))))<< 8; \ case 5: l2|=((unsigned long)(*(--(c)))); \ case 4: l1 =((unsigned long)(*(--(c))))<<24; \ case 3: l1|=((unsigned long)(*(--(c))))<<16; \ case 2: l1|=((unsigned long)(*(--(c))))<< 8; \ case 1: l1|=((unsigned long)(*(--(c)))); \ } \ } /* NOTE - c is not incremented as per l2c */ #define l2cn(l1,l2,c,n) { \ c+=n; \ switch (n) { \ case 8: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ case 7: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ case 6: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ case 4: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ case 3: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ case 2: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ } \ } #undef c2s #define c2s(c,l) (l =((unsigned long)(*((c)++))) , \ l|=((unsigned long)(*((c)++)))<< 8L) #undef s2c #define s2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff)) #undef c2l #define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ l|=((unsigned long)(*((c)++)))<< 8L, \ l|=((unsigned long)(*((c)++)))<<16L, \ l|=((unsigned long)(*((c)++)))<<24L) #undef l2c #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>>24L)&0xff)) #endif #define E_IDEA(num) \ x1&=0xffff; \ idea_mul(x1,x1,*p,ul); p++; \ x2+= *(p++); \ x3+= *(p++); \ x4&=0xffff; \ idea_mul(x4,x4,*p,ul); p++; \ t0=(x1^x3)&0xffff; \ idea_mul(t0,t0,*p,ul); p++; \ t1=(t0+(x2^x4))&0xffff; \ idea_mul(t1,t1,*p,ul); p++; \ t0+=t1; \ x1^=t1; \ x4^=t0; \ ul=x2^t0; /* do the swap to x3 */ \ x2=x3^t1; \ x3=ul; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/idea/i_cfb64.c0000644000175000017500000001057712360020705020547 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "idea_lcl.h" /* The input and output encrypted as though 64bit cfb mode is being * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ void idea_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, IDEA_KEY_SCHEDULE *schedule, unsigned char *ivec, int *num, int encrypt) { register unsigned long v0,v1,t; register int n= *num; register long l=length; unsigned long ti[2]; unsigned char *iv,c,cc; iv=(unsigned char *)ivec; if (encrypt) { while (l--) { if (n == 0) { n2l(iv,v0); ti[0]=v0; n2l(iv,v1); ti[1]=v1; idea_encrypt((unsigned long *)ti,schedule); iv=(unsigned char *)ivec; t=ti[0]; l2n(t,iv); t=ti[1]; l2n(t,iv); iv=(unsigned char *)ivec; } c= *(in++)^iv[n]; *(out++)=c; iv[n]=c; n=(n+1)&0x07; } } else { while (l--) { if (n == 0) { n2l(iv,v0); ti[0]=v0; n2l(iv,v1); ti[1]=v1; idea_encrypt((unsigned long *)ti,schedule); iv=(unsigned char *)ivec; t=ti[0]; l2n(t,iv); t=ti[1]; l2n(t,iv); iv=(unsigned char *)ivec; } cc= *(in++); c=iv[n]; iv[n]=cc; *(out++)=c^cc; n=(n+1)&0x07; } } v0=v1=ti[0]=ti[1]=t=c=cc=0; *num=n; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/idea/i_ecb.c0000644000175000017500000000717312360020705020372 0ustar /* $OpenBSD: i_ecb.c,v 1.2 2014/06/12 15:49:29 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "idea_lcl.h" #include const char *idea_options(void) { if (sizeof(short) != sizeof(IDEA_INT)) return("idea(int)"); else return("idea(short)"); } void idea_ecb_encrypt(const unsigned char *in, unsigned char *out, IDEA_KEY_SCHEDULE *ks) { unsigned long l0,l1,d[2]; n2l(in,l0); d[0]=l0; n2l(in,l1); d[1]=l1; idea_encrypt(d,ks); l0=d[0]; l2n(l0,out); l1=d[1]; l2n(l1,out); l0=l1=d[0]=d[1]=0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ocsp/0000755000000000000000000000000012666635521021016 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/ocsp/ocsp_srv.c0000644000175000017500000001717412360020706021234 0ustar /* $OpenBSD: ocsp_srv.c,v 1.5 2014/06/12 15:49:30 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include /* Utility functions related to sending OCSP responses and extracting * relevant information from the request. */ int OCSP_request_onereq_count(OCSP_REQUEST *req) { return sk_OCSP_ONEREQ_num(req->tbsRequest->requestList); } OCSP_ONEREQ * OCSP_request_onereq_get0(OCSP_REQUEST *req, int i) { return sk_OCSP_ONEREQ_value(req->tbsRequest->requestList, i); } OCSP_CERTID * OCSP_onereq_get0_id(OCSP_ONEREQ *one) { return one->reqCert; } int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd, ASN1_OCTET_STRING **pikeyHash, ASN1_INTEGER **pserial, OCSP_CERTID *cid) { if (!cid) return 0; if (pmd) *pmd = cid->hashAlgorithm->algorithm; if (piNameHash) *piNameHash = cid->issuerNameHash; if (pikeyHash) *pikeyHash = cid->issuerKeyHash; if (pserial) *pserial = cid->serialNumber; return 1; } int OCSP_request_is_signed(OCSP_REQUEST *req) { if (req->optionalSignature) return 1; return 0; } /* Create an OCSP response and encode an optional basic response */ OCSP_RESPONSE * OCSP_response_create(int status, OCSP_BASICRESP *bs) { OCSP_RESPONSE *rsp = NULL; if (!(rsp = OCSP_RESPONSE_new())) goto err; if (!(ASN1_ENUMERATED_set(rsp->responseStatus, status))) goto err; if (!bs) return rsp; if (!(rsp->responseBytes = OCSP_RESPBYTES_new())) goto err; rsp->responseBytes->responseType = OBJ_nid2obj(NID_id_pkix_OCSP_basic); if (!ASN1_item_pack(bs, ASN1_ITEM_rptr(OCSP_BASICRESP), &rsp->responseBytes->response)) goto err; return rsp; err: if (rsp) OCSP_RESPONSE_free(rsp); return NULL; } OCSP_SINGLERESP * OCSP_basic_add1_status(OCSP_BASICRESP *rsp, OCSP_CERTID *cid, int status, int reason, ASN1_TIME *revtime, ASN1_TIME *thisupd, ASN1_TIME *nextupd) { OCSP_SINGLERESP *single = NULL; OCSP_CERTSTATUS *cs; OCSP_REVOKEDINFO *ri; if (!rsp->tbsResponseData->responses && !(rsp->tbsResponseData->responses = sk_OCSP_SINGLERESP_new_null())) goto err; if (!(single = OCSP_SINGLERESP_new())) goto err; if (!ASN1_TIME_to_generalizedtime(thisupd, &single->thisUpdate)) goto err; if (nextupd && !ASN1_TIME_to_generalizedtime(nextupd, &single->nextUpdate)) goto err; OCSP_CERTID_free(single->certId); if (!(single->certId = OCSP_CERTID_dup(cid))) goto err; cs = single->certStatus; switch (cs->type = status) { case V_OCSP_CERTSTATUS_REVOKED: if (!revtime) { OCSPerr(OCSP_F_OCSP_BASIC_ADD1_STATUS, OCSP_R_NO_REVOKED_TIME); goto err; } if (!(cs->value.revoked = ri = OCSP_REVOKEDINFO_new())) goto err; if (!ASN1_TIME_to_generalizedtime(revtime, &ri->revocationTime)) goto err; if (reason != OCSP_REVOKED_STATUS_NOSTATUS) { if (!(ri->revocationReason = ASN1_ENUMERATED_new())) goto err; if (!(ASN1_ENUMERATED_set(ri->revocationReason, reason))) goto err; } break; case V_OCSP_CERTSTATUS_GOOD: cs->value.good = ASN1_NULL_new(); break; case V_OCSP_CERTSTATUS_UNKNOWN: cs->value.unknown = ASN1_NULL_new(); break; default: goto err; } if (!(sk_OCSP_SINGLERESP_push(rsp->tbsResponseData->responses, single))) goto err; return single; err: OCSP_SINGLERESP_free(single); return NULL; } /* Add a certificate to an OCSP request */ int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert) { if (!resp->certs && !(resp->certs = sk_X509_new_null())) return 0; if (!sk_X509_push(resp->certs, cert)) return 0; CRYPTO_add(&cert->references, 1, CRYPTO_LOCK_X509); return 1; } int OCSP_basic_sign(OCSP_BASICRESP *brsp, X509 *signer, EVP_PKEY *key, const EVP_MD *dgst, STACK_OF(X509) *certs, unsigned long flags) { int i; OCSP_RESPID *rid; if (!X509_check_private_key(signer, key)) { OCSPerr(OCSP_F_OCSP_BASIC_SIGN, OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE); goto err; } if (!(flags & OCSP_NOCERTS)) { if (!OCSP_basic_add1_cert(brsp, signer)) goto err; for (i = 0; i < sk_X509_num(certs); i++) { X509 *tmpcert = sk_X509_value(certs, i); if (!OCSP_basic_add1_cert(brsp, tmpcert)) goto err; } } rid = brsp->tbsResponseData->responderId; if (flags & OCSP_RESPID_KEY) { unsigned char md[SHA_DIGEST_LENGTH]; X509_pubkey_digest(signer, EVP_sha1(), md, NULL); if (!(rid->value.byKey = ASN1_OCTET_STRING_new())) goto err; if (!(ASN1_OCTET_STRING_set(rid->value.byKey, md, SHA_DIGEST_LENGTH))) goto err; rid->type = V_OCSP_RESPID_KEY; } else { if (!X509_NAME_set(&rid->value.byName, X509_get_subject_name(signer))) goto err; rid->type = V_OCSP_RESPID_NAME; } if (!(flags & OCSP_NOTIME) && !X509_gmtime_adj(brsp->tbsResponseData->producedAt, 0)) goto err; /* Right now, I think that not doing double hashing is the right thing. -- Richard Levitte */ if (!OCSP_BASICRESP_sign(brsp, key, dgst, 0)) goto err; return 1; err: return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ocsp/ocsp_lib.c0000644000175000017500000001604612360020706021165 0ustar /* $OpenBSD: ocsp_lib.c,v 1.13 2014/07/10 22:45:57 jsing Exp $ */ /* Written by Tom Titchener for the OpenSSL * project. */ /* History: This file was transfered to Richard Levitte from CertCo by Kathy Weinhold in mid-spring 2000 to be included in OpenSSL or released as a patch kit. */ /* ==================================================================== * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include #include #include #include /* Convert a certificate and its issuer to an OCSP_CERTID */ OCSP_CERTID * OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer) { X509_NAME *iname; ASN1_INTEGER *serial; ASN1_BIT_STRING *ikey; #ifndef OPENSSL_NO_SHA1 if (!dgst) dgst = EVP_sha1(); #endif if (subject) { iname = X509_get_issuer_name(subject); serial = X509_get_serialNumber(subject); } else { iname = X509_get_subject_name(issuer); serial = NULL; } ikey = X509_get0_pubkey_bitstr(issuer); return OCSP_cert_id_new(dgst, iname, ikey, serial); } OCSP_CERTID * OCSP_cert_id_new(const EVP_MD *dgst, X509_NAME *issuerName, ASN1_BIT_STRING* issuerKey, ASN1_INTEGER *serialNumber) { int nid; unsigned int i; X509_ALGOR *alg; OCSP_CERTID *cid = NULL; unsigned char md[EVP_MAX_MD_SIZE]; if (!(cid = OCSP_CERTID_new())) goto err; alg = cid->hashAlgorithm; if (alg->algorithm != NULL) ASN1_OBJECT_free(alg->algorithm); if ((nid = EVP_MD_type(dgst)) == NID_undef) { OCSPerr(OCSP_F_OCSP_CERT_ID_NEW, OCSP_R_UNKNOWN_NID); goto err; } if (!(alg->algorithm = OBJ_nid2obj(nid))) goto err; if ((alg->parameter = ASN1_TYPE_new()) == NULL) goto err; alg->parameter->type = V_ASN1_NULL; if (!X509_NAME_digest(issuerName, dgst, md, &i)) goto digerr; if (!(ASN1_OCTET_STRING_set(cid->issuerNameHash, md, i))) goto err; /* Calculate the issuerKey hash, excluding tag and length */ if (!EVP_Digest(issuerKey->data, issuerKey->length, md, &i, dgst, NULL)) goto err; if (!(ASN1_OCTET_STRING_set(cid->issuerKeyHash, md, i))) goto err; if (serialNumber) { ASN1_INTEGER_free(cid->serialNumber); if (!(cid->serialNumber = ASN1_INTEGER_dup(serialNumber))) goto err; } return cid; digerr: OCSPerr(OCSP_F_OCSP_CERT_ID_NEW, OCSP_R_DIGEST_ERR); err: if (cid) OCSP_CERTID_free(cid); return NULL; } int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b) { int ret; ret = OBJ_cmp(a->hashAlgorithm->algorithm, b->hashAlgorithm->algorithm); if (ret) return ret; ret = ASN1_OCTET_STRING_cmp(a->issuerNameHash, b->issuerNameHash); if (ret) return ret; return ASN1_OCTET_STRING_cmp(a->issuerKeyHash, b->issuerKeyHash); } int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b) { int ret; ret = OCSP_id_issuer_cmp(a, b); if (ret) return ret; return ASN1_INTEGER_cmp(a->serialNumber, b->serialNumber); } /* Parse a URL and split it up into host, port and path components and whether * it is SSL. */ int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl) { char *p, *buf; char *host, *port; *phost = NULL; *pport = NULL; *ppath = NULL; /* dup the buffer since we are going to mess with it */ buf = BUF_strdup(url); if (!buf) goto mem_err; /* Check for initial colon */ p = strchr(buf, ':'); if (!p) goto parse_err; *(p++) = '\0'; if (!strcmp(buf, "http")) { *pssl = 0; port = "80"; } else if (!strcmp(buf, "https")) { *pssl = 1; port = "443"; } else goto parse_err; /* Check for double slash */ if ((p[0] != '/') || (p[1] != '/')) goto parse_err; p += 2; host = p; /* Check for trailing part of path */ p = strchr(p, '/'); if (!p) *ppath = BUF_strdup("/"); else { *ppath = BUF_strdup(p); /* Set start of path to 0 so hostname is valid */ *p = '\0'; } if (!*ppath) goto mem_err; /* Look for optional ':' for port number */ if ((p = strchr(host, ':'))) { *p = 0; port = p + 1; } else { /* Not found: set default port */ if (*pssl) port = "443"; else port = "80"; } *pport = BUF_strdup(port); if (!*pport) goto mem_err; *phost = BUF_strdup(host); if (!*phost) goto mem_err; free(buf); return 1; mem_err: OCSPerr(OCSP_F_OCSP_PARSE_URL, ERR_R_MALLOC_FAILURE); goto err; parse_err: OCSPerr(OCSP_F_OCSP_PARSE_URL, OCSP_R_ERROR_PARSING_URL); err: free(buf); free(*ppath); free(*pport); free(*phost); *phost = NULL; *pport = NULL; *ppath = NULL; return 0; } IMPLEMENT_ASN1_DUP_FUNCTION(OCSP_CERTID) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ocsp/ocsp_asn.c0000644000175000017500000001607712360020706021204 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include ASN1_SEQUENCE(OCSP_SIGNATURE) = { ASN1_SIMPLE(OCSP_SIGNATURE, signatureAlgorithm, X509_ALGOR), ASN1_SIMPLE(OCSP_SIGNATURE, signature, ASN1_BIT_STRING), ASN1_EXP_SEQUENCE_OF_OPT(OCSP_SIGNATURE, certs, X509, 0) } ASN1_SEQUENCE_END(OCSP_SIGNATURE) IMPLEMENT_ASN1_FUNCTIONS(OCSP_SIGNATURE) ASN1_SEQUENCE(OCSP_CERTID) = { ASN1_SIMPLE(OCSP_CERTID, hashAlgorithm, X509_ALGOR), ASN1_SIMPLE(OCSP_CERTID, issuerNameHash, ASN1_OCTET_STRING), ASN1_SIMPLE(OCSP_CERTID, issuerKeyHash, ASN1_OCTET_STRING), ASN1_SIMPLE(OCSP_CERTID, serialNumber, ASN1_INTEGER) } ASN1_SEQUENCE_END(OCSP_CERTID) IMPLEMENT_ASN1_FUNCTIONS(OCSP_CERTID) ASN1_SEQUENCE(OCSP_ONEREQ) = { ASN1_SIMPLE(OCSP_ONEREQ, reqCert, OCSP_CERTID), ASN1_EXP_SEQUENCE_OF_OPT(OCSP_ONEREQ, singleRequestExtensions, X509_EXTENSION, 0) } ASN1_SEQUENCE_END(OCSP_ONEREQ) IMPLEMENT_ASN1_FUNCTIONS(OCSP_ONEREQ) ASN1_SEQUENCE(OCSP_REQINFO) = { ASN1_EXP_OPT(OCSP_REQINFO, version, ASN1_INTEGER, 0), ASN1_EXP_OPT(OCSP_REQINFO, requestorName, GENERAL_NAME, 1), ASN1_SEQUENCE_OF(OCSP_REQINFO, requestList, OCSP_ONEREQ), ASN1_EXP_SEQUENCE_OF_OPT(OCSP_REQINFO, requestExtensions, X509_EXTENSION, 2) } ASN1_SEQUENCE_END(OCSP_REQINFO) IMPLEMENT_ASN1_FUNCTIONS(OCSP_REQINFO) ASN1_SEQUENCE(OCSP_REQUEST) = { ASN1_SIMPLE(OCSP_REQUEST, tbsRequest, OCSP_REQINFO), ASN1_EXP_OPT(OCSP_REQUEST, optionalSignature, OCSP_SIGNATURE, 0) } ASN1_SEQUENCE_END(OCSP_REQUEST) IMPLEMENT_ASN1_FUNCTIONS(OCSP_REQUEST) /* OCSP_RESPONSE templates */ ASN1_SEQUENCE(OCSP_RESPBYTES) = { ASN1_SIMPLE(OCSP_RESPBYTES, responseType, ASN1_OBJECT), ASN1_SIMPLE(OCSP_RESPBYTES, response, ASN1_OCTET_STRING) } ASN1_SEQUENCE_END(OCSP_RESPBYTES) IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPBYTES) ASN1_SEQUENCE(OCSP_RESPONSE) = { ASN1_SIMPLE(OCSP_RESPONSE, responseStatus, ASN1_ENUMERATED), ASN1_EXP_OPT(OCSP_RESPONSE, responseBytes, OCSP_RESPBYTES, 0) } ASN1_SEQUENCE_END(OCSP_RESPONSE) IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPONSE) ASN1_CHOICE(OCSP_RESPID) = { ASN1_EXP(OCSP_RESPID, value.byName, X509_NAME, 1), ASN1_EXP(OCSP_RESPID, value.byKey, ASN1_OCTET_STRING, 2) } ASN1_CHOICE_END(OCSP_RESPID) IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPID) ASN1_SEQUENCE(OCSP_REVOKEDINFO) = { ASN1_SIMPLE(OCSP_REVOKEDINFO, revocationTime, ASN1_GENERALIZEDTIME), ASN1_EXP_OPT(OCSP_REVOKEDINFO, revocationReason, ASN1_ENUMERATED, 0) } ASN1_SEQUENCE_END(OCSP_REVOKEDINFO) IMPLEMENT_ASN1_FUNCTIONS(OCSP_REVOKEDINFO) ASN1_CHOICE(OCSP_CERTSTATUS) = { ASN1_IMP(OCSP_CERTSTATUS, value.good, ASN1_NULL, 0), ASN1_IMP(OCSP_CERTSTATUS, value.revoked, OCSP_REVOKEDINFO, 1), ASN1_IMP(OCSP_CERTSTATUS, value.unknown, ASN1_NULL, 2) } ASN1_CHOICE_END(OCSP_CERTSTATUS) IMPLEMENT_ASN1_FUNCTIONS(OCSP_CERTSTATUS) ASN1_SEQUENCE(OCSP_SINGLERESP) = { ASN1_SIMPLE(OCSP_SINGLERESP, certId, OCSP_CERTID), ASN1_SIMPLE(OCSP_SINGLERESP, certStatus, OCSP_CERTSTATUS), ASN1_SIMPLE(OCSP_SINGLERESP, thisUpdate, ASN1_GENERALIZEDTIME), ASN1_EXP_OPT(OCSP_SINGLERESP, nextUpdate, ASN1_GENERALIZEDTIME, 0), ASN1_EXP_SEQUENCE_OF_OPT(OCSP_SINGLERESP, singleExtensions, X509_EXTENSION, 1) } ASN1_SEQUENCE_END(OCSP_SINGLERESP) IMPLEMENT_ASN1_FUNCTIONS(OCSP_SINGLERESP) ASN1_SEQUENCE(OCSP_RESPDATA) = { ASN1_EXP_OPT(OCSP_RESPDATA, version, ASN1_INTEGER, 0), ASN1_SIMPLE(OCSP_RESPDATA, responderId, OCSP_RESPID), ASN1_SIMPLE(OCSP_RESPDATA, producedAt, ASN1_GENERALIZEDTIME), ASN1_SEQUENCE_OF(OCSP_RESPDATA, responses, OCSP_SINGLERESP), ASN1_EXP_SEQUENCE_OF_OPT(OCSP_RESPDATA, responseExtensions, X509_EXTENSION, 1) } ASN1_SEQUENCE_END(OCSP_RESPDATA) IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPDATA) ASN1_SEQUENCE(OCSP_BASICRESP) = { ASN1_SIMPLE(OCSP_BASICRESP, tbsResponseData, OCSP_RESPDATA), ASN1_SIMPLE(OCSP_BASICRESP, signatureAlgorithm, X509_ALGOR), ASN1_SIMPLE(OCSP_BASICRESP, signature, ASN1_BIT_STRING), ASN1_EXP_SEQUENCE_OF_OPT(OCSP_BASICRESP, certs, X509, 0) } ASN1_SEQUENCE_END(OCSP_BASICRESP) IMPLEMENT_ASN1_FUNCTIONS(OCSP_BASICRESP) ASN1_SEQUENCE(OCSP_CRLID) = { ASN1_EXP_OPT(OCSP_CRLID, crlUrl, ASN1_IA5STRING, 0), ASN1_EXP_OPT(OCSP_CRLID, crlNum, ASN1_INTEGER, 1), ASN1_EXP_OPT(OCSP_CRLID, crlTime, ASN1_GENERALIZEDTIME, 2) } ASN1_SEQUENCE_END(OCSP_CRLID) IMPLEMENT_ASN1_FUNCTIONS(OCSP_CRLID) ASN1_SEQUENCE(OCSP_SERVICELOC) = { ASN1_SIMPLE(OCSP_SERVICELOC, issuer, X509_NAME), ASN1_SEQUENCE_OF_OPT(OCSP_SERVICELOC, locator, ACCESS_DESCRIPTION) } ASN1_SEQUENCE_END(OCSP_SERVICELOC) IMPLEMENT_ASN1_FUNCTIONS(OCSP_SERVICELOC) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ocsp/ocsp_prn.c0000644000175000017500000002323312360020706021212 0ustar /* $OpenBSD$ */ /* Written by Tom Titchener for the OpenSSL * project. */ /* History: This file was originally part of ocsp.c and was transfered to Richard Levitte from CertCo by Kathy Weinhold in mid-spring 2000 to be included in OpenSSL or released as a patch kit. */ /* ==================================================================== * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include static int ocsp_certid_print(BIO *bp, OCSP_CERTID* a, int indent) { BIO_printf(bp, "%*sCertificate ID:\n", indent, ""); indent += 2; BIO_printf(bp, "%*sHash Algorithm: ", indent, ""); i2a_ASN1_OBJECT(bp, a->hashAlgorithm->algorithm); BIO_printf(bp, "\n%*sIssuer Name Hash: ", indent, ""); i2a_ASN1_STRING(bp, a->issuerNameHash, V_ASN1_OCTET_STRING); BIO_printf(bp, "\n%*sIssuer Key Hash: ", indent, ""); i2a_ASN1_STRING(bp, a->issuerKeyHash, V_ASN1_OCTET_STRING); BIO_printf(bp, "\n%*sSerial Number: ", indent, ""); i2a_ASN1_INTEGER(bp, a->serialNumber); BIO_printf(bp, "\n"); return 1; } typedef struct { long t; const char *m; } OCSP_TBLSTR; static const char * table2string(long s, const OCSP_TBLSTR *ts, int len) { const OCSP_TBLSTR *p; for (p = ts; p < ts + len; p++) if (p->t == s) return p->m; return "(UNKNOWN)"; } const char * OCSP_response_status_str(long s) { static const OCSP_TBLSTR rstat_tbl[] = { { OCSP_RESPONSE_STATUS_SUCCESSFUL, "successful" }, { OCSP_RESPONSE_STATUS_MALFORMEDREQUEST, "malformedrequest" }, { OCSP_RESPONSE_STATUS_INTERNALERROR, "internalerror" }, { OCSP_RESPONSE_STATUS_TRYLATER, "trylater" }, { OCSP_RESPONSE_STATUS_SIGREQUIRED, "sigrequired" }, { OCSP_RESPONSE_STATUS_UNAUTHORIZED, "unauthorized" } }; return table2string(s, rstat_tbl, 6); } const char * OCSP_cert_status_str(long s) { static const OCSP_TBLSTR cstat_tbl[] = { { V_OCSP_CERTSTATUS_GOOD, "good" }, { V_OCSP_CERTSTATUS_REVOKED, "revoked" }, { V_OCSP_CERTSTATUS_UNKNOWN, "unknown" } }; return table2string(s, cstat_tbl, 3); } const char * OCSP_crl_reason_str(long s) { static const OCSP_TBLSTR reason_tbl[] = { { OCSP_REVOKED_STATUS_UNSPECIFIED, "unspecified" }, { OCSP_REVOKED_STATUS_KEYCOMPROMISE, "keyCompromise" }, { OCSP_REVOKED_STATUS_CACOMPROMISE, "cACompromise" }, { OCSP_REVOKED_STATUS_AFFILIATIONCHANGED, "affiliationChanged" }, { OCSP_REVOKED_STATUS_SUPERSEDED, "superseded" }, { OCSP_REVOKED_STATUS_CESSATIONOFOPERATION, "cessationOfOperation" }, { OCSP_REVOKED_STATUS_CERTIFICATEHOLD, "certificateHold" }, { OCSP_REVOKED_STATUS_REMOVEFROMCRL, "removeFromCRL" } }; return table2string(s, reason_tbl, 8); } int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* o, unsigned long flags) { int i; long l; OCSP_CERTID* cid = NULL; OCSP_ONEREQ *one = NULL; OCSP_REQINFO *inf = o->tbsRequest; OCSP_SIGNATURE *sig = o->optionalSignature; if (BIO_write(bp, "OCSP Request Data:\n", 19) <= 0) goto err; l = ASN1_INTEGER_get(inf->version); if (BIO_printf(bp, " Version: %lu (0x%lx)", l+1, l) <= 0) goto err; if (inf->requestorName != NULL) { if (BIO_write(bp, "\n Requestor Name: ", 21) <= 0) goto err; GENERAL_NAME_print(bp, inf->requestorName); } if (BIO_write(bp, "\n Requestor List:\n", 21) <= 0) goto err; for (i = 0; i < sk_OCSP_ONEREQ_num(inf->requestList); i++) { one = sk_OCSP_ONEREQ_value(inf->requestList, i); cid = one->reqCert; ocsp_certid_print(bp, cid, 8); if (!X509V3_extensions_print(bp, "Request Single Extensions", one->singleRequestExtensions, flags, 8)) goto err; } if (!X509V3_extensions_print(bp, "Request Extensions", inf->requestExtensions, flags, 4)) goto err; if (sig) { X509_signature_print(bp, sig->signatureAlgorithm, sig->signature); for (i = 0; i < sk_X509_num(sig->certs); i++) { X509_print(bp, sk_X509_value(sig->certs, i)); PEM_write_bio_X509(bp, sk_X509_value(sig->certs, i)); } } return 1; err: return 0; } int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags) { int i, ret = 0; long l; OCSP_CERTID *cid = NULL; OCSP_BASICRESP *br = NULL; OCSP_RESPID *rid = NULL; OCSP_RESPDATA *rd = NULL; OCSP_CERTSTATUS *cst = NULL; OCSP_REVOKEDINFO *rev = NULL; OCSP_SINGLERESP *single = NULL; OCSP_RESPBYTES *rb = o->responseBytes; if (BIO_puts(bp, "OCSP Response Data:\n") <= 0) goto err; l = ASN1_ENUMERATED_get(o->responseStatus); if (BIO_printf(bp, " OCSP Response Status: %s (0x%lx)\n", OCSP_response_status_str(l), l) <= 0) goto err; if (rb == NULL) return 1; if (BIO_puts(bp, " Response Type: ") <= 0) goto err; if (i2a_ASN1_OBJECT(bp, rb->responseType) <= 0) goto err; if (OBJ_obj2nid(rb->responseType) != NID_id_pkix_OCSP_basic) { BIO_puts(bp, " (unknown response type)\n"); return 1; } i = ASN1_STRING_length(rb->response); if (!(br = OCSP_response_get1_basic(o))) goto err; rd = br->tbsResponseData; l = ASN1_INTEGER_get(rd->version); if (BIO_printf(bp, "\n Version: %lu (0x%lx)\n", l+1, l) <= 0) goto err; if (BIO_puts(bp, " Responder Id: ") <= 0) goto err; rid = rd->responderId; switch (rid->type) { case V_OCSP_RESPID_NAME: X509_NAME_print_ex(bp, rid->value.byName, 0, XN_FLAG_ONELINE); break; case V_OCSP_RESPID_KEY: i2a_ASN1_STRING(bp, rid->value.byKey, V_ASN1_OCTET_STRING); break; } if (BIO_printf(bp, "\n Produced At: ")<=0) goto err; if (!ASN1_GENERALIZEDTIME_print(bp, rd->producedAt)) goto err; if (BIO_printf(bp, "\n Responses:\n") <= 0) goto err; for (i = 0; i < sk_OCSP_SINGLERESP_num(rd->responses); i++) { if (! sk_OCSP_SINGLERESP_value(rd->responses, i)) continue; single = sk_OCSP_SINGLERESP_value(rd->responses, i); cid = single->certId; if (ocsp_certid_print(bp, cid, 4) <= 0) goto err; cst = single->certStatus; if (BIO_printf(bp, " Cert Status: %s", OCSP_cert_status_str(cst->type)) <= 0) goto err; if (cst->type == V_OCSP_CERTSTATUS_REVOKED) { rev = cst->value.revoked; if (BIO_printf(bp, "\n Revocation Time: ") <= 0) goto err; if (!ASN1_GENERALIZEDTIME_print(bp, rev->revocationTime)) goto err; if (rev->revocationReason) { l = ASN1_ENUMERATED_get(rev->revocationReason); if (BIO_printf(bp, "\n Revocation Reason: %s (0x%lx)", OCSP_crl_reason_str(l), l) <= 0) goto err; } } if (BIO_printf(bp, "\n This Update: ") <= 0) goto err; if (!ASN1_GENERALIZEDTIME_print(bp, single->thisUpdate)) goto err; if (single->nextUpdate) { if (BIO_printf(bp, "\n Next Update: ") <= 0) goto err; if (!ASN1_GENERALIZEDTIME_print(bp, single->nextUpdate)) goto err; } if (BIO_write(bp, "\n", 1) <= 0) goto err; if (!X509V3_extensions_print(bp, "Response Single Extensions", single->singleExtensions, flags, 8)) goto err; if (BIO_write(bp, "\n", 1) <= 0) goto err; } if (!X509V3_extensions_print(bp, "Response Extensions", rd->responseExtensions, flags, 4)) goto err; if (X509_signature_print(bp, br->signatureAlgorithm, br->signature) <= 0) goto err; for (i = 0; i < sk_X509_num(br->certs); i++) { X509_print(bp, sk_X509_value(br->certs, i)); PEM_write_bio_X509(bp, sk_X509_value(br->certs, i)); } ret = 1; err: OCSP_BASICRESP_free(br); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ocsp/ocsp_ext.c0000644000175000017500000003752712360020706021226 0ustar /* $OpenBSD: ocsp_ext.c,v 1.10 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Tom Titchener for the OpenSSL * project. */ /* History: This file was transfered to Richard Levitte from CertCo by Kathy Weinhold in mid-spring 2000 to be included in OpenSSL or released as a patch kit. */ /* ==================================================================== * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include /* Standard wrapper functions for extensions */ /* OCSP request extensions */ int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x) { return X509v3_get_ext_count(x->tbsRequest->requestExtensions); } int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos) { return X509v3_get_ext_by_NID(x->tbsRequest->requestExtensions, nid, lastpos); } int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj, int lastpos) { return X509v3_get_ext_by_OBJ(x->tbsRequest->requestExtensions, obj, lastpos); } int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos) { return X509v3_get_ext_by_critical(x->tbsRequest->requestExtensions, crit, lastpos); } X509_EXTENSION * OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc) { return X509v3_get_ext(x->tbsRequest->requestExtensions, loc); } X509_EXTENSION * OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc) { return X509v3_delete_ext(x->tbsRequest->requestExtensions, loc); } void * OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx) { return X509V3_get_d2i(x->tbsRequest->requestExtensions, nid, crit, idx); } int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit, unsigned long flags) { return X509V3_add1_i2d(&x->tbsRequest->requestExtensions, nid, value, crit, flags); } int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc) { return X509v3_add_ext(&(x->tbsRequest->requestExtensions), ex, loc) != NULL; } /* Single extensions */ int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x) { return X509v3_get_ext_count(x->singleRequestExtensions); } int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos) { return X509v3_get_ext_by_NID(x->singleRequestExtensions, nid, lastpos); } int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos) { return X509v3_get_ext_by_OBJ(x->singleRequestExtensions, obj, lastpos); } int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos) { return X509v3_get_ext_by_critical(x->singleRequestExtensions, crit, lastpos); } X509_EXTENSION * OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc) { return X509v3_get_ext(x->singleRequestExtensions, loc); } X509_EXTENSION * OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc) { return X509v3_delete_ext(x->singleRequestExtensions, loc); } void * OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx) { return X509V3_get_d2i(x->singleRequestExtensions, nid, crit, idx); } int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit, unsigned long flags) { return X509V3_add1_i2d(&x->singleRequestExtensions, nid, value, crit, flags); } int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc) { return X509v3_add_ext(&(x->singleRequestExtensions), ex, loc) != NULL; } /* OCSP Basic response */ int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x) { return X509v3_get_ext_count(x->tbsResponseData->responseExtensions); } int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos) { return X509v3_get_ext_by_NID(x->tbsResponseData->responseExtensions, nid, lastpos); } int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj, int lastpos) { return X509v3_get_ext_by_OBJ(x->tbsResponseData->responseExtensions, obj, lastpos); } int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, int lastpos) { return X509v3_get_ext_by_critical( x->tbsResponseData->responseExtensions, crit, lastpos); } X509_EXTENSION * OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc) { return X509v3_get_ext(x->tbsResponseData->responseExtensions, loc); } X509_EXTENSION * OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc) { return X509v3_delete_ext(x->tbsResponseData->responseExtensions, loc); } void * OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, int *idx) { return X509V3_get_d2i(x->tbsResponseData->responseExtensions, nid, crit, idx); } int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, int crit, unsigned long flags) { return X509V3_add1_i2d(&x->tbsResponseData->responseExtensions, nid, value, crit, flags); } int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc) { return X509v3_add_ext(&(x->tbsResponseData->responseExtensions), ex, loc) != NULL; } /* OCSP single response extensions */ int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x) { return X509v3_get_ext_count(x->singleExtensions); } int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos) { return X509v3_get_ext_by_NID(x->singleExtensions, nid, lastpos); } int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj, int lastpos) { return X509v3_get_ext_by_OBJ(x->singleExtensions, obj, lastpos); } int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, int lastpos) { return X509v3_get_ext_by_critical(x->singleExtensions, crit, lastpos); } X509_EXTENSION * OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc) { return X509v3_get_ext(x->singleExtensions, loc); } X509_EXTENSION * OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc) { return X509v3_delete_ext(x->singleExtensions, loc); } void * OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit, int *idx) { return X509V3_get_d2i(x->singleExtensions, nid, crit, idx); } int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, int crit, unsigned long flags) { return X509V3_add1_i2d(&x->singleExtensions, nid, value, crit, flags); } int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc) { return X509v3_add_ext(&(x->singleExtensions), ex, loc) != NULL; } /* also CRL Entry Extensions */ #if 0 ASN1_STRING * ASN1_STRING_encode(ASN1_STRING *s, i2d_of_void *i2d, void *data, STACK_OF(ASN1_OBJECT) *sk) { int i; unsigned char *p, *b = NULL; if (data) { if ((i = i2d(data, NULL)) <= 0) goto err; if (!(b = p = malloc((unsigned int)i))) goto err; if (i2d(data, &p) <= 0) goto err; } else if (sk) { if ((i = i2d_ASN1_SET_OF_ASN1_OBJECT(sk, NULL, (I2D_OF(ASN1_OBJECT))i2d, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, IS_SEQUENCE)) <= 0) goto err; if (!(b = p = malloc((unsigned int)i))) goto err; if (i2d_ASN1_SET_OF_ASN1_OBJECT(sk, &p, (I2D_OF(ASN1_OBJECT))i2d, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, IS_SEQUENCE) <= 0) goto err; } else { OCSPerr(OCSP_F_ASN1_STRING_ENCODE, OCSP_R_BAD_DATA); goto err; } if (!s && !(s = ASN1_STRING_new())) goto err; if (!(ASN1_STRING_set(s, b, i))) goto err; free(b); return s; err: free(b); return NULL; } #endif /* Nonce handling functions */ /* Add a nonce to an extension stack. A nonce can be specificed or if NULL * a random nonce will be generated. * Note: OpenSSL 0.9.7d and later create an OCTET STRING containing the * nonce, previous versions used the raw nonce. */ static int ocsp_add1_nonce(STACK_OF(X509_EXTENSION) **exts, unsigned char *val, int len) { unsigned char *tmpval; ASN1_OCTET_STRING os; int ret = 0; if (len <= 0) len = OCSP_DEFAULT_NONCE_LENGTH; /* Create the OCTET STRING manually by writing out the header and * appending the content octets. This avoids an extra memory allocation * operation in some cases. Applications should *NOT* do this because * it relies on library internals. */ os.length = ASN1_object_size(0, len, V_ASN1_OCTET_STRING); os.data = malloc(os.length); if (os.data == NULL) goto err; tmpval = os.data; ASN1_put_object(&tmpval, 0, len, V_ASN1_OCTET_STRING, V_ASN1_UNIVERSAL); if (val) memcpy(tmpval, val, len); else RAND_pseudo_bytes(tmpval, len); if (!X509V3_add1_i2d(exts, NID_id_pkix_OCSP_Nonce, &os, 0, X509V3_ADD_REPLACE)) goto err; ret = 1; err: free(os.data); return ret; } /* Add nonce to an OCSP request */ int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len) { return ocsp_add1_nonce(&req->tbsRequest->requestExtensions, val, len); } /* Same as above but for a response */ int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len) { return ocsp_add1_nonce(&resp->tbsResponseData->responseExtensions, val, len); } /* Check nonce validity in a request and response. * Return value reflects result: * 1: nonces present and equal. * 2: nonces both absent. * 3: nonce present in response only. * 0: nonces both present and not equal. * -1: nonce in request only. * * For most responders clients can check return > 0. * If responder doesn't handle nonces return != 0 may be * necessary. return == 0 is always an error. */ int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs) { /* * Since we are only interested in the presence or absence of * the nonce and comparing its value there is no need to use * the X509V3 routines: this way we can avoid them allocating an * ASN1_OCTET_STRING structure for the value which would be * freed immediately anyway. */ int req_idx, resp_idx; X509_EXTENSION *req_ext, *resp_ext; req_idx = OCSP_REQUEST_get_ext_by_NID(req, NID_id_pkix_OCSP_Nonce, -1); resp_idx = OCSP_BASICRESP_get_ext_by_NID(bs, NID_id_pkix_OCSP_Nonce, -1); /* Check both absent */ if (req_idx < 0 && resp_idx < 0) return 2; /* Check in request only */ if (req_idx >= 0 && resp_idx < 0) return -1; /* Check in response but not request */ if (req_idx < 0 && resp_idx >= 0) return 3; /* Otherwise nonce in request and response so retrieve the extensions */ req_ext = OCSP_REQUEST_get_ext(req, req_idx); resp_ext = OCSP_BASICRESP_get_ext(bs, resp_idx); if (ASN1_OCTET_STRING_cmp(req_ext->value, resp_ext->value)) return 0; return 1; } /* Copy the nonce value (if any) from an OCSP request to * a response. */ int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req) { X509_EXTENSION *req_ext; int req_idx; /* Check for nonce in request */ req_idx = OCSP_REQUEST_get_ext_by_NID(req, NID_id_pkix_OCSP_Nonce, -1); /* If no nonce that's OK */ if (req_idx < 0) return 2; req_ext = OCSP_REQUEST_get_ext(req, req_idx); return OCSP_BASICRESP_add_ext(resp, req_ext, -1); } X509_EXTENSION * OCSP_crlID_new(char *url, long *n, char *tim) { X509_EXTENSION *x = NULL; OCSP_CRLID *cid = NULL; if (!(cid = OCSP_CRLID_new())) goto err; if (url) { if (!(cid->crlUrl = ASN1_IA5STRING_new())) goto err; if (!(ASN1_STRING_set(cid->crlUrl, url, -1))) goto err; } if (n) { if (!(cid->crlNum = ASN1_INTEGER_new())) goto err; if (!(ASN1_INTEGER_set(cid->crlNum, *n))) goto err; } if (tim) { if (!(cid->crlTime = ASN1_GENERALIZEDTIME_new())) goto err; if (!(ASN1_GENERALIZEDTIME_set_string(cid->crlTime, tim))) goto err; } x = X509V3_EXT_i2d(NID_id_pkix_OCSP_CrlID, 0, cid); err: if (cid) OCSP_CRLID_free(cid); return x; } /* AcceptableResponses ::= SEQUENCE OF OBJECT IDENTIFIER */ X509_EXTENSION * OCSP_accept_responses_new(char **oids) { int nid; STACK_OF(ASN1_OBJECT) *sk = NULL; ASN1_OBJECT *o = NULL; X509_EXTENSION *x = NULL; if (!(sk = sk_ASN1_OBJECT_new_null())) return NULL; while (oids && *oids) { if ((nid = OBJ_txt2nid(*oids)) != NID_undef && (o = OBJ_nid2obj(nid))) sk_ASN1_OBJECT_push(sk, o); oids++; } x = X509V3_EXT_i2d(NID_id_pkix_OCSP_acceptableResponses, 0, sk); sk_ASN1_OBJECT_pop_free(sk, ASN1_OBJECT_free); return x; } /* ArchiveCutoff ::= GeneralizedTime */ X509_EXTENSION * OCSP_archive_cutoff_new(char* tim) { X509_EXTENSION *x = NULL; ASN1_GENERALIZEDTIME *gt = NULL; if (!(gt = ASN1_GENERALIZEDTIME_new())) return NULL; if (!(ASN1_GENERALIZEDTIME_set_string(gt, tim))) goto err; x = X509V3_EXT_i2d(NID_id_pkix_OCSP_archiveCutoff, 0, gt); err: if (gt) ASN1_GENERALIZEDTIME_free(gt); return x; } /* per ACCESS_DESCRIPTION parameter are oids, of which there are currently * two--NID_ad_ocsp, NID_id_ad_caIssuers--and GeneralName value. This * method forces NID_ad_ocsp and uniformResourceLocator [6] IA5String. */ X509_EXTENSION * OCSP_url_svcloc_new(X509_NAME* issuer, char **urls) { X509_EXTENSION *x = NULL; ASN1_IA5STRING *ia5 = NULL; OCSP_SERVICELOC *sloc = NULL; ACCESS_DESCRIPTION *ad = NULL; if (!(sloc = OCSP_SERVICELOC_new())) goto err; if (!(sloc->issuer = X509_NAME_dup(issuer))) goto err; if (urls && *urls && !(sloc->locator = sk_ACCESS_DESCRIPTION_new_null())) goto err; while (urls && *urls) { if (!(ad = ACCESS_DESCRIPTION_new())) goto err; if (!(ad->method = OBJ_nid2obj(NID_ad_OCSP))) goto err; if (!(ad->location = GENERAL_NAME_new())) goto err; if (!(ia5 = ASN1_IA5STRING_new())) goto err; if (!ASN1_STRING_set((ASN1_STRING*)ia5, *urls, -1)) goto err; ad->location->type = GEN_URI; ad->location->d.ia5 = ia5; ia5 = NULL; if (!sk_ACCESS_DESCRIPTION_push(sloc->locator, ad)) goto err; ad = NULL; urls++; } x = X509V3_EXT_i2d(NID_id_pkix_OCSP_serviceLocator, 0, sloc); err: if (ia5) ASN1_IA5STRING_free(ia5); if (ad) ACCESS_DESCRIPTION_free(ad); if (sloc) OCSP_SERVICELOC_free(sloc); return x; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ocsp/ocsp_ht.c0000644000175000017500000002631312360020706021030 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include /* Stateful OCSP request code, supporting non-blocking I/O */ /* Opaque OCSP request status structure */ struct ocsp_req_ctx_st { int state; /* Current I/O state */ unsigned char *iobuf; /* Line buffer */ int iobuflen; /* Line buffer length */ BIO *io; /* BIO to perform I/O with */ BIO *mem; /* Memory BIO response is built into */ unsigned long asn1_len; /* ASN1 length of response */ }; #define OCSP_MAX_REQUEST_LENGTH (100 * 1024) #define OCSP_MAX_LINE_LEN 4096; /* OCSP states */ /* If set no reading should be performed */ #define OHS_NOREAD 0x1000 /* Error condition */ #define OHS_ERROR (0 | OHS_NOREAD) /* First line being read */ #define OHS_FIRSTLINE 1 /* MIME headers being read */ #define OHS_HEADERS 2 /* OCSP initial header (tag + length) being read */ #define OHS_ASN1_HEADER 3 /* OCSP content octets being read */ #define OHS_ASN1_CONTENT 4 /* Request being sent */ #define OHS_ASN1_WRITE (6 | OHS_NOREAD) /* Request being flushed */ #define OHS_ASN1_FLUSH (7 | OHS_NOREAD) /* Completed */ #define OHS_DONE (8 | OHS_NOREAD) static int parse_http_line1(char *line); void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx) { if (rctx->mem) BIO_free(rctx->mem); free(rctx->iobuf); free(rctx); } int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req) { static const char req_hdr[] = "Content-Type: application/ocsp-request\r\n" "Content-Length: %d\r\n\r\n"; if (BIO_printf(rctx->mem, req_hdr, i2d_OCSP_REQUEST(req, NULL)) <= 0) return 0; if (i2d_OCSP_REQUEST_bio(rctx->mem, req) <= 0) return 0; rctx->state = OHS_ASN1_WRITE; rctx->asn1_len = BIO_get_mem_data(rctx->mem, NULL); return 1; } int OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx, const char *name, const char *value) { if (!name) return 0; if (BIO_puts(rctx->mem, name) <= 0) return 0; if (value) { if (BIO_write(rctx->mem, ": ", 2) != 2) return 0; if (BIO_puts(rctx->mem, value) <= 0) return 0; } if (BIO_write(rctx->mem, "\r\n", 2) != 2) return 0; return 1; } OCSP_REQ_CTX * OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req, int maxline) { static const char post_hdr[] = "POST %s HTTP/1.0\r\n"; OCSP_REQ_CTX *rctx; rctx = malloc(sizeof(OCSP_REQ_CTX)); if (rctx == NULL) return NULL; rctx->state = OHS_ERROR; rctx->mem = BIO_new(BIO_s_mem()); rctx->io = io; rctx->asn1_len = 0; if (maxline > 0) rctx->iobuflen = maxline; else rctx->iobuflen = OCSP_MAX_LINE_LEN; rctx->iobuf = malloc(rctx->iobuflen); if (!rctx->iobuf) { BIO_free(rctx->mem); free(rctx); return NULL; } if (!path) path = "/"; if (BIO_printf(rctx->mem, post_hdr, path) <= 0) { free(rctx->iobuf); BIO_free(rctx->mem); free(rctx); return NULL; } if (req && !OCSP_REQ_CTX_set1_req(rctx, req)) { free(rctx->iobuf); BIO_free(rctx->mem); free(rctx); return NULL; } return rctx; } /* Parse the HTTP response. This will look like this: * "HTTP/1.0 200 OK". We need to obtain the numeric code and * (optional) informational message. */ static int parse_http_line1(char *line) { int retcode; char *p, *q, *r; /* Skip to first white space (passed protocol info) */ for (p = line; *p && !isspace((unsigned char)*p); p++) continue; if (!*p) { OCSPerr(OCSP_F_PARSE_HTTP_LINE1, OCSP_R_SERVER_RESPONSE_PARSE_ERROR); return 0; } /* Skip past white space to start of response code */ while (*p && isspace((unsigned char)*p)) p++; if (!*p) { OCSPerr(OCSP_F_PARSE_HTTP_LINE1, OCSP_R_SERVER_RESPONSE_PARSE_ERROR); return 0; } /* Find end of response code: first whitespace after start of code */ for (q = p; *q && !isspace((unsigned char)*q); q++) continue; if (!*q) { OCSPerr(OCSP_F_PARSE_HTTP_LINE1, OCSP_R_SERVER_RESPONSE_PARSE_ERROR); return 0; } /* Set end of response code and start of message */ *q++ = 0; /* Attempt to parse numeric code */ retcode = strtoul(p, &r, 10); if (*r) return 0; /* Skip over any leading white space in message */ while (*q && isspace((unsigned char)*q)) q++; if (*q) { /* Finally zap any trailing white space in message (include * CRLF) */ /* We know q has a non white space character so this is OK */ for (r = q + strlen(q) - 1; isspace((unsigned char)*r); r--) *r = 0; } if (retcode != 200) { OCSPerr(OCSP_F_PARSE_HTTP_LINE1, OCSP_R_SERVER_RESPONSE_ERROR); if (!*q) ERR_asprintf_error_data("Code=%s", p); else ERR_asprintf_error_data("Code=%s,Reason=%s", p, q); return 0; } return 1; } int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx) { int i, n; const unsigned char *p; next_io: if (!(rctx->state & OHS_NOREAD)) { n = BIO_read(rctx->io, rctx->iobuf, rctx->iobuflen); if (n <= 0) { if (BIO_should_retry(rctx->io)) return -1; return 0; } /* Write data to memory BIO */ if (BIO_write(rctx->mem, rctx->iobuf, n) != n) return 0; } switch (rctx->state) { case OHS_ASN1_WRITE: n = BIO_get_mem_data(rctx->mem, &p); i = BIO_write(rctx->io, p + (n - rctx->asn1_len), rctx->asn1_len); if (i <= 0) { if (BIO_should_retry(rctx->io)) return -1; rctx->state = OHS_ERROR; return 0; } rctx->asn1_len -= i; if (rctx->asn1_len > 0) goto next_io; rctx->state = OHS_ASN1_FLUSH; (void)BIO_reset(rctx->mem); /* FALLTHROUGH */ case OHS_ASN1_FLUSH: i = BIO_flush(rctx->io); if (i > 0) { rctx->state = OHS_FIRSTLINE; goto next_io; } if (BIO_should_retry(rctx->io)) return -1; rctx->state = OHS_ERROR; return 0; case OHS_ERROR: return 0; case OHS_FIRSTLINE: case OHS_HEADERS: /* Attempt to read a line in */ next_line: /* Due to &%^*$" memory BIO behaviour with BIO_gets we * have to check there's a complete line in there before * calling BIO_gets or we'll just get a partial read. */ n = BIO_get_mem_data(rctx->mem, &p); if ((n <= 0) || !memchr(p, '\n', n)) { if (n >= rctx->iobuflen) { rctx->state = OHS_ERROR; return 0; } goto next_io; } n = BIO_gets(rctx->mem, (char *)rctx->iobuf, rctx->iobuflen); if (n <= 0) { if (BIO_should_retry(rctx->mem)) goto next_io; rctx->state = OHS_ERROR; return 0; } /* Don't allow excessive lines */ if (n == rctx->iobuflen) { rctx->state = OHS_ERROR; return 0; } /* First line */ if (rctx->state == OHS_FIRSTLINE) { if (parse_http_line1((char *)rctx->iobuf)) { rctx->state = OHS_HEADERS; goto next_line; } else { rctx->state = OHS_ERROR; return 0; } } else { /* Look for blank line: end of headers */ for (p = rctx->iobuf; *p; p++) { if ((*p != '\r') && (*p != '\n')) break; } if (*p) goto next_line; rctx->state = OHS_ASN1_HEADER; } /* FALLTRHOUGH */ case OHS_ASN1_HEADER: /* Now reading ASN1 header: can read at least 2 bytes which * is enough for ASN1 SEQUENCE header and either length field * or at least the length of the length field. */ n = BIO_get_mem_data(rctx->mem, &p); if (n < 2) goto next_io; /* Check it is an ASN1 SEQUENCE */ if (*p++ != (V_ASN1_SEQUENCE|V_ASN1_CONSTRUCTED)) { rctx->state = OHS_ERROR; return 0; } /* Check out length field */ if (*p & 0x80) { /* If MSB set on initial length octet we can now * always read 6 octets: make sure we have them. */ if (n < 6) goto next_io; n = *p & 0x7F; /* Not NDEF or excessive length */ if (!n || (n > 4)) { rctx->state = OHS_ERROR; return 0; } p++; rctx->asn1_len = 0; for (i = 0; i < n; i++) { rctx->asn1_len <<= 8; rctx->asn1_len |= *p++; } if (rctx->asn1_len > OCSP_MAX_REQUEST_LENGTH) { rctx->state = OHS_ERROR; return 0; } rctx->asn1_len += n + 2; } else rctx->asn1_len = *p + 2; rctx->state = OHS_ASN1_CONTENT; /* FALLTHROUGH */ case OHS_ASN1_CONTENT: n = BIO_get_mem_data(rctx->mem, &p); if (n < (int)rctx->asn1_len) goto next_io; *presp = d2i_OCSP_RESPONSE(NULL, &p, rctx->asn1_len); if (*presp) { rctx->state = OHS_DONE; return 1; } rctx->state = OHS_ERROR; return 0; case OHS_DONE: return 1; } return 0; } /* Blocking OCSP request handler: now a special case of non-blocking I/O */ OCSP_RESPONSE * OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req) { OCSP_RESPONSE *resp = NULL; OCSP_REQ_CTX *ctx; int rv; ctx = OCSP_sendreq_new(b, path, req, -1); if (ctx == NULL) return NULL; do { rv = OCSP_sendreq_nbio(&resp, ctx); } while ((rv == -1) && BIO_should_retry(b)); OCSP_REQ_CTX_free(ctx); if (rv) return resp; return NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ocsp/ocsp_cl.c0000644000175000017500000002502612360020706021013 0ustar /* $OpenBSD: ocsp_cl.c,v 1.6 2014/06/12 15:49:30 deraadt Exp $ */ /* Written by Tom Titchener for the OpenSSL * project. */ /* History: This file was transfered to Richard Levitte from CertCo by Kathy Weinhold in mid-spring 2000 to be included in OpenSSL or released as a patch kit. */ /* ==================================================================== * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include #include /* Utility functions related to sending OCSP requests and extracting * relevant information from the response. */ /* Add an OCSP_CERTID to an OCSP request. Return new OCSP_ONEREQ * pointer: useful if we want to add extensions. */ OCSP_ONEREQ * OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid) { OCSP_ONEREQ *one = NULL; if (!(one = OCSP_ONEREQ_new())) goto err; if (one->reqCert) OCSP_CERTID_free(one->reqCert); one->reqCert = cid; if (req && !sk_OCSP_ONEREQ_push(req->tbsRequest->requestList, one)) goto err; return one; err: OCSP_ONEREQ_free(one); return NULL; } /* Set requestorName from an X509_NAME structure */ int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm) { GENERAL_NAME *gen; gen = GENERAL_NAME_new(); if (gen == NULL) return 0; if (!X509_NAME_set(&gen->d.directoryName, nm)) { GENERAL_NAME_free(gen); return 0; } gen->type = GEN_DIRNAME; if (req->tbsRequest->requestorName) GENERAL_NAME_free(req->tbsRequest->requestorName); req->tbsRequest->requestorName = gen; return 1; } /* Add a certificate to an OCSP request */ int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert) { OCSP_SIGNATURE *sig; if (!req->optionalSignature) req->optionalSignature = OCSP_SIGNATURE_new(); sig = req->optionalSignature; if (!sig) return 0; if (!cert) return 1; if (!sig->certs && !(sig->certs = sk_X509_new_null())) return 0; if (!sk_X509_push(sig->certs, cert)) return 0; CRYPTO_add(&cert->references, 1, CRYPTO_LOCK_X509); return 1; } /* Sign an OCSP request set the requestorName to the subjec * name of an optional signers certificate and include one * or more optional certificates in the request. Behaves * like PKCS7_sign(). */ int OCSP_request_sign(OCSP_REQUEST *req, X509 *signer, EVP_PKEY *key, const EVP_MD *dgst, STACK_OF(X509) *certs, unsigned long flags) { int i; OCSP_SIGNATURE *sig; X509 *x; if (!OCSP_request_set1_name(req, X509_get_subject_name(signer))) goto err; if (!(req->optionalSignature = sig = OCSP_SIGNATURE_new())) goto err; if (key) { if (!X509_check_private_key(signer, key)) { OCSPerr(OCSP_F_OCSP_REQUEST_SIGN, OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE); goto err; } if (!OCSP_REQUEST_sign(req, key, dgst)) goto err; } if (!(flags & OCSP_NOCERTS)) { if (!OCSP_request_add1_cert(req, signer)) goto err; for (i = 0; i < sk_X509_num(certs); i++) { x = sk_X509_value(certs, i); if (!OCSP_request_add1_cert(req, x)) goto err; } } return 1; err: OCSP_SIGNATURE_free(req->optionalSignature); req->optionalSignature = NULL; return 0; } /* Get response status */ int OCSP_response_status(OCSP_RESPONSE *resp) { return ASN1_ENUMERATED_get(resp->responseStatus); } /* Extract basic response from OCSP_RESPONSE or NULL if * no basic response present. */ OCSP_BASICRESP * OCSP_response_get1_basic(OCSP_RESPONSE *resp) { OCSP_RESPBYTES *rb; rb = resp->responseBytes; if (!rb) { OCSPerr(OCSP_F_OCSP_RESPONSE_GET1_BASIC, OCSP_R_NO_RESPONSE_DATA); return NULL; } if (OBJ_obj2nid(rb->responseType) != NID_id_pkix_OCSP_basic) { OCSPerr(OCSP_F_OCSP_RESPONSE_GET1_BASIC, OCSP_R_NOT_BASIC_RESPONSE); return NULL; } return ASN1_item_unpack(rb->response, ASN1_ITEM_rptr(OCSP_BASICRESP)); } /* Return number of OCSP_SINGLERESP reponses present in * a basic response. */ int OCSP_resp_count(OCSP_BASICRESP *bs) { if (!bs) return -1; return sk_OCSP_SINGLERESP_num(bs->tbsResponseData->responses); } /* Extract an OCSP_SINGLERESP response with a given index */ OCSP_SINGLERESP * OCSP_resp_get0(OCSP_BASICRESP *bs, int idx) { if (!bs) return NULL; return sk_OCSP_SINGLERESP_value(bs->tbsResponseData->responses, idx); } /* Look single response matching a given certificate ID */ int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last) { int i; STACK_OF(OCSP_SINGLERESP) *sresp; OCSP_SINGLERESP *single; if (!bs) return -1; if (last < 0) last = 0; else last++; sresp = bs->tbsResponseData->responses; for (i = last; i < sk_OCSP_SINGLERESP_num(sresp); i++) { single = sk_OCSP_SINGLERESP_value(sresp, i); if (!OCSP_id_cmp(id, single->certId)) return i; } return -1; } /* Extract status information from an OCSP_SINGLERESP structure. * Note: the revtime and reason values are only set if the * certificate status is revoked. Returns numerical value of * status. */ int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason, ASN1_GENERALIZEDTIME **revtime, ASN1_GENERALIZEDTIME **thisupd, ASN1_GENERALIZEDTIME **nextupd) { int ret; OCSP_CERTSTATUS *cst; if (!single) return -1; cst = single->certStatus; ret = cst->type; if (ret == V_OCSP_CERTSTATUS_REVOKED) { OCSP_REVOKEDINFO *rev = cst->value.revoked; if (revtime) *revtime = rev->revocationTime; if (reason) { if (rev->revocationReason) *reason = ASN1_ENUMERATED_get( rev->revocationReason); else *reason = -1; } } if (thisupd) *thisupd = single->thisUpdate; if (nextupd) *nextupd = single->nextUpdate; return ret; } /* This function combines the previous ones: look up a certificate ID and * if found extract status information. Return 0 is successful. */ int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status, int *reason, ASN1_GENERALIZEDTIME **revtime, ASN1_GENERALIZEDTIME **thisupd, ASN1_GENERALIZEDTIME **nextupd) { int i; OCSP_SINGLERESP *single; i = OCSP_resp_find(bs, id, -1); /* Maybe check for multiple responses and give an error? */ if (i < 0) return 0; single = OCSP_resp_get0(bs, i); i = OCSP_single_get0_status(single, reason, revtime, thisupd, nextupd); if (status) *status = i; return 1; } /* Check validity of thisUpdate and nextUpdate fields. It is possible that the request will * take a few seconds to process and/or the time wont be totally accurate. Therefore to avoid * rejecting otherwise valid time we allow the times to be within 'nsec' of the current time. * Also to avoid accepting very old responses without a nextUpdate field an optional maxage * parameter specifies the maximum age the thisUpdate field can be. */ int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd, ASN1_GENERALIZEDTIME *nextupd, long nsec, long maxsec) { int ret = 1; time_t t_now, t_tmp; time(&t_now); /* Check thisUpdate is valid and not more than nsec in the future */ if (!ASN1_GENERALIZEDTIME_check(thisupd)) { OCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_ERROR_IN_THISUPDATE_FIELD); ret = 0; } else { t_tmp = t_now + nsec; if (X509_cmp_time(thisupd, &t_tmp) > 0) { OCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_STATUS_NOT_YET_VALID); ret = 0; } /* If maxsec specified check thisUpdate is not more than maxsec in the past */ if (maxsec >= 0) { t_tmp = t_now - maxsec; if (X509_cmp_time(thisupd, &t_tmp) < 0) { OCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_STATUS_TOO_OLD); ret = 0; } } } if (!nextupd) return ret; /* Check nextUpdate is valid and not more than nsec in the past */ if (!ASN1_GENERALIZEDTIME_check(nextupd)) { OCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_ERROR_IN_NEXTUPDATE_FIELD); ret = 0; } else { t_tmp = t_now - nsec; if (X509_cmp_time(nextupd, &t_tmp) < 0) { OCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_STATUS_EXPIRED); ret = 0; } } /* Also don't allow nextUpdate to precede thisUpdate */ if (ASN1_STRING_cmp(nextupd, thisupd) < 0) { OCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE); ret = 0; } return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ocsp/ocsp_err.c0000644000175000017500000001523512360020706021206 0ustar /* $OpenBSD: ocsp_err.c,v 1.6 2014/06/12 15:49:30 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_OCSP,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_OCSP,0,reason) static ERR_STRING_DATA OCSP_str_functs[]= { {ERR_FUNC(OCSP_F_ASN1_STRING_ENCODE), "ASN1_STRING_encode"}, {ERR_FUNC(OCSP_F_D2I_OCSP_NONCE), "D2I_OCSP_NONCE"}, {ERR_FUNC(OCSP_F_OCSP_BASIC_ADD1_STATUS), "OCSP_basic_add1_status"}, {ERR_FUNC(OCSP_F_OCSP_BASIC_SIGN), "OCSP_basic_sign"}, {ERR_FUNC(OCSP_F_OCSP_BASIC_VERIFY), "OCSP_basic_verify"}, {ERR_FUNC(OCSP_F_OCSP_CERT_ID_NEW), "OCSP_cert_id_new"}, {ERR_FUNC(OCSP_F_OCSP_CHECK_DELEGATED), "OCSP_CHECK_DELEGATED"}, {ERR_FUNC(OCSP_F_OCSP_CHECK_IDS), "OCSP_CHECK_IDS"}, {ERR_FUNC(OCSP_F_OCSP_CHECK_ISSUER), "OCSP_CHECK_ISSUER"}, {ERR_FUNC(OCSP_F_OCSP_CHECK_VALIDITY), "OCSP_check_validity"}, {ERR_FUNC(OCSP_F_OCSP_MATCH_ISSUERID), "OCSP_MATCH_ISSUERID"}, {ERR_FUNC(OCSP_F_OCSP_PARSE_URL), "OCSP_parse_url"}, {ERR_FUNC(OCSP_F_OCSP_REQUEST_SIGN), "OCSP_request_sign"}, {ERR_FUNC(OCSP_F_OCSP_REQUEST_VERIFY), "OCSP_request_verify"}, {ERR_FUNC(OCSP_F_OCSP_RESPONSE_GET1_BASIC), "OCSP_response_get1_basic"}, {ERR_FUNC(OCSP_F_OCSP_SENDREQ_BIO), "OCSP_sendreq_bio"}, {ERR_FUNC(OCSP_F_OCSP_SENDREQ_NBIO), "OCSP_sendreq_nbio"}, {ERR_FUNC(OCSP_F_PARSE_HTTP_LINE1), "PARSE_HTTP_LINE1"}, {ERR_FUNC(OCSP_F_REQUEST_VERIFY), "REQUEST_VERIFY"}, {0, NULL} }; static ERR_STRING_DATA OCSP_str_reasons[]= { {ERR_REASON(OCSP_R_BAD_DATA) , "bad data"}, {ERR_REASON(OCSP_R_CERTIFICATE_VERIFY_ERROR), "certificate verify error"}, {ERR_REASON(OCSP_R_DIGEST_ERR) , "digest err"}, {ERR_REASON(OCSP_R_ERROR_IN_NEXTUPDATE_FIELD), "error in nextupdate field"}, {ERR_REASON(OCSP_R_ERROR_IN_THISUPDATE_FIELD), "error in thisupdate field"}, {ERR_REASON(OCSP_R_ERROR_PARSING_URL) , "error parsing url"}, {ERR_REASON(OCSP_R_MISSING_OCSPSIGNING_USAGE), "missing ocspsigning usage"}, {ERR_REASON(OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE), "nextupdate before thisupdate"}, {ERR_REASON(OCSP_R_NOT_BASIC_RESPONSE) , "not basic response"}, {ERR_REASON(OCSP_R_NO_CERTIFICATES_IN_CHAIN), "no certificates in chain"}, {ERR_REASON(OCSP_R_NO_CONTENT) , "no content"}, {ERR_REASON(OCSP_R_NO_PUBLIC_KEY) , "no public key"}, {ERR_REASON(OCSP_R_NO_RESPONSE_DATA) , "no response data"}, {ERR_REASON(OCSP_R_NO_REVOKED_TIME) , "no revoked time"}, {ERR_REASON(OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE), "private key does not match certificate"}, {ERR_REASON(OCSP_R_REQUEST_NOT_SIGNED) , "request not signed"}, {ERR_REASON(OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA), "response contains no revocation data"}, {ERR_REASON(OCSP_R_ROOT_CA_NOT_TRUSTED) , "root ca not trusted"}, {ERR_REASON(OCSP_R_SERVER_READ_ERROR) , "server read error"}, {ERR_REASON(OCSP_R_SERVER_RESPONSE_ERROR), "server response error"}, {ERR_REASON(OCSP_R_SERVER_RESPONSE_PARSE_ERROR), "server response parse error"}, {ERR_REASON(OCSP_R_SERVER_WRITE_ERROR) , "server write error"}, {ERR_REASON(OCSP_R_SIGNATURE_FAILURE) , "signature failure"}, {ERR_REASON(OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND), "signer certificate not found"}, {ERR_REASON(OCSP_R_STATUS_EXPIRED) , "status expired"}, {ERR_REASON(OCSP_R_STATUS_NOT_YET_VALID) , "status not yet valid"}, {ERR_REASON(OCSP_R_STATUS_TOO_OLD) , "status too old"}, {ERR_REASON(OCSP_R_UNKNOWN_MESSAGE_DIGEST), "unknown message digest"}, {ERR_REASON(OCSP_R_UNKNOWN_NID) , "unknown nid"}, {ERR_REASON(OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE), "unsupported requestorname type"}, {0, NULL} }; #endif void ERR_load_OCSP_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(OCSP_str_functs[0].error) == NULL) { ERR_load_strings(0, OCSP_str_functs); ERR_load_strings(0, OCSP_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ocsp/ocsp_vfy.c0000644000175000017500000003062212360020706021217 0ustar /* $OpenBSD: ocsp_vfy.c,v 1.11 2014/06/12 15:49:30 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000-2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include static int ocsp_find_signer(X509 **psigner, OCSP_BASICRESP *bs, STACK_OF(X509) *certs, X509_STORE *st, unsigned long flags); static X509 *ocsp_find_signer_sk(STACK_OF(X509) *certs, OCSP_RESPID *id); static int ocsp_check_issuer(OCSP_BASICRESP *bs, STACK_OF(X509) *chain, unsigned long flags); static int ocsp_check_ids(STACK_OF(OCSP_SINGLERESP) *sresp, OCSP_CERTID **ret); static int ocsp_match_issuerid(X509 *cert, OCSP_CERTID *cid, STACK_OF(OCSP_SINGLERESP) *sresp); static int ocsp_check_delegated(X509 *x, int flags); static int ocsp_req_find_signer(X509 **psigner, OCSP_REQUEST *req, X509_NAME *nm, STACK_OF(X509) *certs, X509_STORE *st, unsigned long flags); /* Verify a basic response message */ int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs, X509_STORE *st, unsigned long flags) { X509 *signer, *x; STACK_OF(X509) *chain = NULL; X509_STORE_CTX ctx; int i, ret = 0; ret = ocsp_find_signer(&signer, bs, certs, st, flags); if (!ret) { OCSPerr(OCSP_F_OCSP_BASIC_VERIFY, OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND); goto end; } if ((ret == 2) && (flags & OCSP_TRUSTOTHER)) flags |= OCSP_NOVERIFY; if (!(flags & OCSP_NOSIGS)) { EVP_PKEY *skey; skey = X509_get_pubkey(signer); if (skey) { ret = OCSP_BASICRESP_verify(bs, skey, 0); EVP_PKEY_free(skey); } if (!skey || ret <= 0) { OCSPerr(OCSP_F_OCSP_BASIC_VERIFY, OCSP_R_SIGNATURE_FAILURE); goto end; } } if (!(flags & OCSP_NOVERIFY)) { int init_res; if (flags & OCSP_NOCHAIN) init_res = X509_STORE_CTX_init(&ctx, st, signer, NULL); else init_res = X509_STORE_CTX_init(&ctx, st, signer, bs->certs); if (!init_res) { ret = -1; OCSPerr(OCSP_F_OCSP_BASIC_VERIFY, ERR_R_X509_LIB); goto end; } X509_STORE_CTX_set_purpose(&ctx, X509_PURPOSE_OCSP_HELPER); ret = X509_verify_cert(&ctx); chain = X509_STORE_CTX_get1_chain(&ctx); X509_STORE_CTX_cleanup(&ctx); if (ret <= 0) { i = X509_STORE_CTX_get_error(&ctx); OCSPerr(OCSP_F_OCSP_BASIC_VERIFY, OCSP_R_CERTIFICATE_VERIFY_ERROR); ERR_asprintf_error_data("Verify error:%s", X509_verify_cert_error_string(i)); goto end; } if (flags & OCSP_NOCHECKS) { ret = 1; goto end; } /* At this point we have a valid certificate chain * need to verify it against the OCSP issuer criteria. */ ret = ocsp_check_issuer(bs, chain, flags); /* If fatal error or valid match then finish */ if (ret != 0) goto end; /* Easy case: explicitly trusted. Get root CA and * check for explicit trust */ if (flags & OCSP_NOEXPLICIT) goto end; x = sk_X509_value(chain, sk_X509_num(chain) - 1); if (X509_check_trust(x, NID_OCSP_sign, 0) != X509_TRUST_TRUSTED) { OCSPerr(OCSP_F_OCSP_BASIC_VERIFY, OCSP_R_ROOT_CA_NOT_TRUSTED); goto end; } ret = 1; } end: if (chain) sk_X509_pop_free(chain, X509_free); return ret; } static int ocsp_find_signer(X509 **psigner, OCSP_BASICRESP *bs, STACK_OF(X509) *certs, X509_STORE *st, unsigned long flags) { X509 *signer; OCSP_RESPID *rid = bs->tbsResponseData->responderId; if ((signer = ocsp_find_signer_sk(certs, rid))) { *psigner = signer; return 2; } if (!(flags & OCSP_NOINTERN) && (signer = ocsp_find_signer_sk(bs->certs, rid))) { *psigner = signer; return 1; } /* Maybe lookup from store if by subject name */ *psigner = NULL; return 0; } static X509 * ocsp_find_signer_sk(STACK_OF(X509) *certs, OCSP_RESPID *id) { int i; unsigned char tmphash[SHA_DIGEST_LENGTH], *keyhash; X509 *x; /* Easy if lookup by name */ if (id->type == V_OCSP_RESPID_NAME) return X509_find_by_subject(certs, id->value.byName); /* Lookup by key hash */ /* If key hash isn't SHA1 length then forget it */ if (id->value.byKey->length != SHA_DIGEST_LENGTH) return NULL; keyhash = id->value.byKey->data; /* Calculate hash of each key and compare */ for (i = 0; i < sk_X509_num(certs); i++) { x = sk_X509_value(certs, i); X509_pubkey_digest(x, EVP_sha1(), tmphash, NULL); if (!memcmp(keyhash, tmphash, SHA_DIGEST_LENGTH)) return x; } return NULL; } static int ocsp_check_issuer(OCSP_BASICRESP *bs, STACK_OF(X509) *chain, unsigned long flags) { STACK_OF(OCSP_SINGLERESP) *sresp; X509 *signer, *sca; OCSP_CERTID *caid = NULL; int i; sresp = bs->tbsResponseData->responses; if (sk_X509_num(chain) <= 0) { OCSPerr(OCSP_F_OCSP_CHECK_ISSUER, OCSP_R_NO_CERTIFICATES_IN_CHAIN); return -1; } /* See if the issuer IDs match. */ i = ocsp_check_ids(sresp, &caid); /* If ID mismatch or other error then return */ if (i <= 0) return i; signer = sk_X509_value(chain, 0); /* Check to see if OCSP responder CA matches request CA */ if (sk_X509_num(chain) > 1) { sca = sk_X509_value(chain, 1); i = ocsp_match_issuerid(sca, caid, sresp); if (i < 0) return i; if (i) { /* We have a match, if extensions OK then success */ if (ocsp_check_delegated(signer, flags)) return 1; return 0; } } /* Otherwise check if OCSP request signed directly by request CA */ return ocsp_match_issuerid(signer, caid, sresp); } /* Check the issuer certificate IDs for equality. If there is a mismatch with the same * algorithm then there's no point trying to match any certificates against the issuer. * If the issuer IDs all match then we just need to check equality against one of them. */ static int ocsp_check_ids(STACK_OF(OCSP_SINGLERESP) *sresp, OCSP_CERTID **ret) { OCSP_CERTID *tmpid, *cid; int i, idcount; idcount = sk_OCSP_SINGLERESP_num(sresp); if (idcount <= 0) { OCSPerr(OCSP_F_OCSP_CHECK_IDS, OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA); return -1; } cid = sk_OCSP_SINGLERESP_value(sresp, 0)->certId; *ret = NULL; for (i = 1; i < idcount; i++) { tmpid = sk_OCSP_SINGLERESP_value(sresp, i)->certId; /* Check to see if IDs match */ if (OCSP_id_issuer_cmp(cid, tmpid)) { return 0; } } /* All IDs match: only need to check one ID */ *ret = cid; return 1; } static int ocsp_match_issuerid(X509 *cert, OCSP_CERTID *cid, STACK_OF(OCSP_SINGLERESP) *sresp) { /* If only one ID to match then do it */ if (cid) { const EVP_MD *dgst; X509_NAME *iname; int mdlen; unsigned char md[EVP_MAX_MD_SIZE]; if (!(dgst = EVP_get_digestbyobj(cid->hashAlgorithm->algorithm))) { OCSPerr(OCSP_F_OCSP_MATCH_ISSUERID, OCSP_R_UNKNOWN_MESSAGE_DIGEST); return -1; } mdlen = EVP_MD_size(dgst); if (mdlen < 0) return -1; if (cid->issuerNameHash->length != mdlen || cid->issuerKeyHash->length != mdlen) return 0; iname = X509_get_subject_name(cert); if (!X509_NAME_digest(iname, dgst, md, NULL)) return -1; if (memcmp(md, cid->issuerNameHash->data, mdlen)) return 0; X509_pubkey_digest(cert, dgst, md, NULL); if (memcmp(md, cid->issuerKeyHash->data, mdlen)) return 0; return 1; } else { /* We have to match the whole lot */ int i, ret; OCSP_CERTID *tmpid; for (i = 0; i < sk_OCSP_SINGLERESP_num(sresp); i++) { tmpid = sk_OCSP_SINGLERESP_value(sresp, i)->certId; ret = ocsp_match_issuerid(cert, tmpid, NULL); if (ret <= 0) return ret; } return 1; } } static int ocsp_check_delegated(X509 *x, int flags) { X509_check_purpose(x, -1, 0); if ((x->ex_flags & EXFLAG_XKUSAGE) && (x->ex_xkusage & XKU_OCSP_SIGN)) return 1; OCSPerr(OCSP_F_OCSP_CHECK_DELEGATED, OCSP_R_MISSING_OCSPSIGNING_USAGE); return 0; } /* Verify an OCSP request. This is fortunately much easier than OCSP * response verify. Just find the signers certificate and verify it * against a given trust value. */ int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs, X509_STORE *store, unsigned long flags) { X509 *signer; X509_NAME *nm; GENERAL_NAME *gen; int ret; X509_STORE_CTX ctx; if (!req->optionalSignature) { OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_REQUEST_NOT_SIGNED); return 0; } gen = req->tbsRequest->requestorName; if (!gen || gen->type != GEN_DIRNAME) { OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE); return 0; } nm = gen->d.directoryName; ret = ocsp_req_find_signer(&signer, req, nm, certs, store, flags); if (ret <= 0) { OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND); return 0; } if ((ret == 2) && (flags & OCSP_TRUSTOTHER)) flags |= OCSP_NOVERIFY; if (!(flags & OCSP_NOSIGS)) { EVP_PKEY *skey; skey = X509_get_pubkey(signer); ret = OCSP_REQUEST_verify(req, skey); EVP_PKEY_free(skey); if (ret <= 0) { OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_SIGNATURE_FAILURE); return 0; } } if (!(flags & OCSP_NOVERIFY)) { int init_res; if (flags & OCSP_NOCHAIN) init_res = X509_STORE_CTX_init(&ctx, store, signer, NULL); else init_res = X509_STORE_CTX_init(&ctx, store, signer, req->optionalSignature->certs); if (!init_res) { OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, ERR_R_X509_LIB); return 0; } X509_STORE_CTX_set_purpose(&ctx, X509_PURPOSE_OCSP_HELPER); X509_STORE_CTX_set_trust(&ctx, X509_TRUST_OCSP_REQUEST); ret = X509_verify_cert(&ctx); X509_STORE_CTX_cleanup(&ctx); if (ret <= 0) { ret = X509_STORE_CTX_get_error(&ctx); OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_CERTIFICATE_VERIFY_ERROR); ERR_asprintf_error_data("Verify error:%s", X509_verify_cert_error_string(ret)); return 0; } } return 1; } static int ocsp_req_find_signer(X509 **psigner, OCSP_REQUEST *req, X509_NAME *nm, STACK_OF(X509) *certs, X509_STORE *st, unsigned long flags) { X509 *signer; if (!(flags & OCSP_NOINTERN)) { signer = X509_find_by_subject(req->optionalSignature->certs, nm); *psigner = signer; return 1; } signer = X509_find_by_subject(certs, nm); if (signer) { *psigner = signer; return 2; } return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/compat/0000755000000000000000000000000012666635521021335 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/compat/issetugid_linux.c0000644000175000017500000000216012357514212023127 0ustar /* * issetugid implementation for Linux * Public domain */ #include #include #include #include #include /* * Linux-specific glibc 2.16+ interface for determining if a process was * launched setuid/setgid or with additional capabilities. */ #ifdef HAVE_GETAUXVAL #include #endif int issetugid(void) { #ifdef HAVE_GETAUXVAL /* * The API for glibc < 2.19 does not indicate if there is an error with * getauxval. While it should not be the case that any 2.6 or greater * kernel ever does not supply AT_SECURE, an emulated software environment * might rewrite the aux vector. * * See https://sourceware.org/bugzilla/show_bug.cgi?id=15846 * * Perhaps this code should just read the aux vector itself, so we have * backward-compatibility and error handling in older glibc versions. * info: http://lwn.net/Articles/519085/ * */ const char *glcv = gnu_get_libc_version(); if (strverscmp(glcv, "2.19") >= 0) { errno = 0; if (getauxval(AT_SECURE) == 0) { if (errno != ENOENT) { return 0; } } } #endif return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/compat/explicit_bzero.c0000644000175000017500000000051312360020705022723 0ustar /* $OpenBSD: explicit_bzero.c,v 1.2 2014/06/10 04:17:37 deraadt Exp $ */ /* * Public domain. * Written by Matthew Dempsky. */ #include __attribute__((weak)) void __explicit_bzero_hook(void *buf, size_t len) { } void explicit_bzero(void *buf, size_t len) { memset(buf, 0, len); __explicit_bzero_hook(buf, len); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/compat/arc4random.c0000644000175000017500000001333012360020705021734 0ustar /* $OpenBSD: arc4random.c,v 1.38 2014/06/26 19:23:15 deraadt Exp $ */ /* * Copyright (c) 1996, David Mazieres * Copyright (c) 2008, Damien Miller * Copyright (c) 2013, Markus Friedl * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * ChaCha based random number generator for OpenBSD. */ #include #include #include #include #include #include #include #include #include #include #include #include "thread_private.h" #define KEYSTREAM_ONLY #include "chacha_private.h" #define min(a, b) ((a) < (b) ? (a) : (b)) #ifdef __GNUC__ #define inline __inline #else /* !__GNUC__ */ #define inline #endif /* !__GNUC__ */ #define KEYSZ 32 #define IVSZ 8 #define BLOCKSZ 64 #define RSBUFSZ (16*BLOCKSZ) /* Marked MAP_INHERIT_ZERO, so zero'd out in fork children. */ static struct { size_t rs_have; /* valid bytes at end of rs_buf */ size_t rs_count; /* bytes till reseed */ } *rs; /* Preserved in fork children. */ static struct { chacha_ctx rs_chacha; /* chacha context for random keystream */ u_char rs_buf[RSBUFSZ]; /* keystream blocks */ } *rsx; static inline void _rs_rekey(u_char *dat, size_t datlen); static inline void _rs_init(u_char *buf, size_t n) { if (n < KEYSZ + IVSZ) return; if (rs == NULL) { if ((rs = mmap(NULL, sizeof(*rs), PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) abort(); #ifdef MAP_INHERIT_ZERO if (minherit(rs, sizeof(*rs), MAP_INHERIT_ZERO) == -1) abort(); #endif } if (rsx == NULL) { if ((rsx = mmap(NULL, sizeof(*rsx), PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) abort(); } chacha_keysetup(&rsx->rs_chacha, buf, KEYSZ * 8, 0); chacha_ivsetup(&rsx->rs_chacha, buf + KEYSZ); } static void _rs_stir(void) { u_char rnd[KEYSZ + IVSZ]; if (getentropy(rnd, sizeof rnd) == -1) raise(SIGKILL); if (!rs) _rs_init(rnd, sizeof(rnd)); else _rs_rekey(rnd, sizeof(rnd)); explicit_bzero(rnd, sizeof(rnd)); /* discard source seed */ /* invalidate rs_buf */ rs->rs_have = 0; memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf)); rs->rs_count = 1600000; } static inline void _rs_stir_if_needed(size_t len) { #ifndef MAP_INHERIT_ZERO static pid_t _rs_pid = 0; pid_t pid = getpid(); /* If a system lacks MAP_INHERIT_ZERO, resort to getpid() */ if (_rs_pid == 0 || _rs_pid != pid) { _rs_pid = pid; if (rs) rs->rs_count = 0; } #endif if (!rs || rs->rs_count <= len) _rs_stir(); if (rs->rs_count <= len) rs->rs_count = 0; else rs->rs_count -= len; } static inline void _rs_rekey(u_char *dat, size_t datlen) { #ifndef KEYSTREAM_ONLY memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf)); #endif /* fill rs_buf with the keystream */ chacha_encrypt_bytes(&rsx->rs_chacha, rsx->rs_buf, rsx->rs_buf, sizeof(rsx->rs_buf)); /* mix in optional user provided data */ if (dat) { size_t i, m; m = min(datlen, KEYSZ + IVSZ); for (i = 0; i < m; i++) rsx->rs_buf[i] ^= dat[i]; } /* immediately reinit for backtracking resistance */ _rs_init(rsx->rs_buf, KEYSZ + IVSZ); memset(rsx->rs_buf, 0, KEYSZ + IVSZ); rs->rs_have = sizeof(rsx->rs_buf) - KEYSZ - IVSZ; } static inline void _rs_random_buf(void *_buf, size_t n) { u_char *buf = (u_char *)_buf; u_char *keystream; size_t m; _rs_stir_if_needed(n); while (n > 0) { if (rs->rs_have > 0) { m = min(n, rs->rs_have); keystream = rsx->rs_buf + sizeof(rsx->rs_buf) - rs->rs_have; memcpy(buf, keystream, m); memset(keystream, 0, m); buf += m; n -= m; rs->rs_have -= m; } if (rs->rs_have == 0) _rs_rekey(NULL, 0); } } static inline void _rs_random_u32(uint32_t *val) { u_char *keystream; _rs_stir_if_needed(sizeof(*val)); if (rs->rs_have < sizeof(*val)) _rs_rekey(NULL, 0); keystream = rsx->rs_buf + sizeof(rsx->rs_buf) - rs->rs_have; memcpy(val, keystream, sizeof(*val)); memset(keystream, 0, sizeof(*val)); rs->rs_have -= sizeof(*val); } uint32_t arc4random(void) { uint32_t val; _ARC4_LOCK(); _rs_random_u32(&val); _ARC4_UNLOCK(); return val; } void arc4random_buf(void *buf, size_t n) { _ARC4_LOCK(); _rs_random_buf(buf, n); _ARC4_UNLOCK(); } /* * Calculate a uniformly distributed random number less than upper_bound * avoiding "modulo bias". * * Uniformity is achieved by generating new random numbers until the one * returned is outside the range [0, 2**32 % upper_bound). This * guarantees the selected random number will be inside * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound) * after reduction modulo upper_bound. */ uint32_t arc4random_uniform(uint32_t upper_bound) { uint32_t r, min; if (upper_bound < 2) return 0; /* 2**32 % x == (2**32 - x) % x */ min = -upper_bound % upper_bound; /* * This could theoretically loop forever but each retry has * p > 0.5 (worst case, usually far better) of selecting a * number inside the range we need, so it should rarely need * to re-roll. */ for (;;) { r = arc4random(); if (r >= min) break; } return r % upper_bound; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/compat/thread_private.h0000644000175000017500000000032212357514212022714 0ustar #include static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; #define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx) #define _ARC4_UNLOCK() pthread_mutex_unlock(&arc4random_mtx) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/compat/getentropy_solaris.c0000644000175000017500000002313512360020705023642 0ustar /* $OpenBSD: getentropy_linux.c,v 1.14 2014/06/26 13:48:11 deraadt Exp $ */ /* * Copyright (c) 2014 Theo de Raadt * Copyright (c) 2014 Bob Beck * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define SHA512_Init SHA512Init #define SHA512_Update SHA512Update #define SHA512_Final SHA512Final #include #include #include #define REPEAT 5 #define min(a, b) (((a) < (b)) ? (a) : (b)) #define HX(a, b) \ do { \ if ((a)) \ HD(errno); \ else \ HD(b); \ } while (0) #define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l))) #define HD(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (x))) int getentropy(void *buf, size_t len); extern int main(int, char *argv[]); static int gotdata(char *buf, size_t len); static int getentropy_urandom(void *buf, size_t len); static int getentropy_fallback(void *buf, size_t len); int getentropy(void *buf, size_t len) { int ret = -1; if (len > 256) { errno = EIO; return -1; } /* * Try to get entropy with /dev/urandom * * This can fail if the process is inside a chroot or if file * descriptors are exhausted. */ ret = getentropy_urandom(buf, len); if (ret != -1) return (ret); /* * Entropy collection via /dev/urandom and sysctl have failed. * * No other API exists for collecting entropy, and we have * no failsafe way to get it on Solaris that is not sensitive * to resource exhaustion. * * We have very few options: * - Even syslog_r is unsafe to call at this low level, so * there is no way to alert the user or program. * - Cannot call abort() because some systems have unsafe * corefiles. * - Could raise(SIGKILL) resulting in silent program termination. * - Return EIO, to hint that arc4random's stir function * should raise(SIGKILL) * - Do the best under the circumstances.... * * This code path exists to bring light to the issue that Solaris * does not provide a failsafe API for entropy collection. * * We hope this demonstrates that Solaris should consider * providing a new failsafe API which works in a chroot or * when file descriptors are exhausted. */ #undef FAIL_WHEN_SYSTEM_ENTROPY_FAILS #ifdef FAIL_WHEN_SYSTEM_ENTROPY_FAILS raise(SIGKILL); #endif ret = getentropy_fallback(buf, len); if (ret != -1) return (ret); errno = EIO; return (ret); } /* * Basic sanity checking; wish we could do better. */ static int gotdata(char *buf, size_t len) { char any_set = 0; size_t i; for (i = 0; i < len; ++i) any_set |= buf[i]; if (any_set == 0) return -1; return 0; } static int getentropy_urandom(void *buf, size_t len) { struct stat st; size_t i; int fd, flags; int save_errno = errno; start: flags = O_RDONLY; #ifdef O_NOFOLLOW flags |= O_NOFOLLOW; #endif #ifdef O_CLOEXEC flags |= O_CLOEXEC; #endif /* * Solaris provides /dev/urandom as a symbolic link. * /devices/pseudo/random@0:urandom should be the * real device path, and we do want O_NOFOLLOW. */ fd = open("/devices/pseudo/random@0:urandom", flags, 0); if (fd == -1) { if (errno == EINTR) goto start; goto nodevrandom; } #ifndef O_CLOEXEC fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); #endif /* Lightly verify that the device node looks sane */ if (fstat(fd, &st) == -1 || !S_ISCHR(st.st_mode)) { close(fd); goto nodevrandom; } for (i = 0; i < len; ) { size_t wanted = len - i; ssize_t ret = read(fd, buf + i, wanted); if (ret == -1) { if (errno == EAGAIN || errno == EINTR) continue; close(fd); goto nodevrandom; } i += ret; } close(fd); if (gotdata(buf, len) == 0) { errno = save_errno; return 0; /* satisfied */ } nodevrandom: errno = EIO; return -1; } static int cl[] = { CLOCK_REALTIME, #ifdef CLOCK_MONOTONIC CLOCK_MONOTONIC, #endif #ifdef CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC_RAW, #endif #ifdef CLOCK_TAI CLOCK_TAI, #endif #ifdef CLOCK_VIRTUAL CLOCK_VIRTUAL, #endif #ifdef CLOCK_UPTIME CLOCK_UPTIME, #endif #ifdef CLOCK_PROCESS_CPUTIME_ID CLOCK_PROCESS_CPUTIME_ID, #endif #ifdef CLOCK_THREAD_CPUTIME_ID CLOCK_THREAD_CPUTIME_ID, #endif }; static int getentropy_fallback(void *buf, size_t len) { uint8_t results[SHA512_DIGEST_LENGTH]; int save_errno = errno, e, m, pgs = getpagesize(), faster = 0, repeat; static int cnt; struct timespec ts; struct timeval tv; double loadavg[3]; struct rusage ru; sigset_t sigset; struct stat st; SHA512_CTX ctx; static pid_t lastpid; pid_t pid; size_t i, ii; char *p; pid = getpid(); if (lastpid == pid) { faster = 1; repeat = 2; } else { faster = 0; lastpid = pid; repeat = REPEAT; } for (i = 0; i < len; ) { int j; SHA512_Init(&ctx); for (j = 0; j < repeat; j++) { HX((e = gettimeofday(&tv, NULL)) == -1, tv); if (e != -1) { cnt += (int)tv.tv_sec; cnt += (int)tv.tv_usec; } for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++) HX(clock_gettime(cl[ii], &ts) == -1, ts); HX((pid = getpid()) == -1, pid); HX((pid = getsid(pid)) == -1, pid); HX((pid = getppid()) == -1, pid); HX((pid = getpgid(0)) == -1, pid); HX((m = getpriority(0, 0)) == -1, m); HX((getloadavg(loadavg, 3) == -1), loadavg); if (!faster) { ts.tv_sec = 0; ts.tv_nsec = 1; (void) nanosleep(&ts, NULL); } HX(sigpending(&sigset) == -1, sigset); HX(sigprocmask(SIG_BLOCK, NULL, &sigset) == -1, sigset); HD(main); /* an addr in program */ HD(getentropy); /* an addr in this library */ HD(printf); /* an addr in libc */ p = (char *)&p; HD(p); /* an addr on stack */ p = (char *)&errno; HD(p); /* the addr of errno */ if (i == 0) { struct sockaddr_storage ss; struct statvfs stvfs; struct termios tios; socklen_t ssl; off_t off; /* * Prime-sized mappings encourage fragmentation; * thus exposing some address entropy. */ struct mm { size_t npg; void *p; } mm[] = { { 17, MAP_FAILED }, { 3, MAP_FAILED }, { 11, MAP_FAILED }, { 2, MAP_FAILED }, { 5, MAP_FAILED }, { 3, MAP_FAILED }, { 7, MAP_FAILED }, { 1, MAP_FAILED }, { 57, MAP_FAILED }, { 3, MAP_FAILED }, { 131, MAP_FAILED }, { 1, MAP_FAILED }, }; for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { HX(mm[m].p = mmap(NULL, mm[m].npg * pgs, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, (off_t)0), mm[m].p); if (mm[m].p != MAP_FAILED) { size_t mo; /* Touch some memory... */ p = mm[m].p; mo = cnt % (mm[m].npg * pgs - 1); p[mo] = 1; cnt += (int)((long)(mm[m].p) / pgs); } /* Check cnts and times... */ for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++) { HX((e = clock_gettime(cl[ii], &ts)) == -1, ts); if (e != -1) cnt += (int)ts.tv_nsec; } HX((e = getrusage(RUSAGE_SELF, &ru)) == -1, ru); if (e != -1) { cnt += (int)ru.ru_utime.tv_sec; cnt += (int)ru.ru_utime.tv_usec; } } for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { if (mm[m].p != MAP_FAILED) munmap(mm[m].p, mm[m].npg * pgs); mm[m].p = MAP_FAILED; } HX(stat(".", &st) == -1, st); HX(statvfs(".", &stvfs) == -1, stvfs); HX(stat("/", &st) == -1, st); HX(statvfs("/", &stvfs) == -1, stvfs); HX((e = fstat(0, &st)) == -1, st); if (e == -1) { if (S_ISREG(st.st_mode) || S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { HX(fstatvfs(0, &stvfs) == -1, stvfs); HX((off = lseek(0, (off_t)0, SEEK_CUR)) < 0, off); } if (S_ISCHR(st.st_mode)) { HX(tcgetattr(0, &tios) == -1, tios); } else if (S_ISSOCK(st.st_mode)) { memset(&ss, 0, sizeof ss); ssl = sizeof(ss); HX(getpeername(0, (void *)&ss, &ssl) == -1, ss); } } HX((e = getrusage(RUSAGE_CHILDREN, &ru)) == -1, ru); if (e != -1) { cnt += (int)ru.ru_utime.tv_sec; cnt += (int)ru.ru_utime.tv_usec; } } else { /* Subsequent hashes absorb previous result */ HD(results); } HX((e = gettimeofday(&tv, NULL)) == -1, tv); if (e != -1) { cnt += (int)tv.tv_sec; cnt += (int)tv.tv_usec; } HD(cnt); } SHA512_Final(results, &ctx); memcpy(buf + i, results, min(sizeof(results), len - i)); i += min(sizeof(results), len - i); } memset(results, 0, sizeof results); if (gotdata(buf, len) == 0) { errno = save_errno; return 0; /* satisfied */ } errno = EIO; return -1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/compat/strlcat.c0000644000175000017500000000322212360020705021355 0ustar /* $OpenBSD: strlcat.c,v 1.12 2005/03/30 20:13:52 otto Exp $ */ /* * Copyright (c) 1998 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include /* * Appends src to string dst of size siz (unlike strncat, siz is the * full size of dst, not space left). At most siz-1 characters * will be copied. Always NUL terminates (unless siz <= strlen(dst)). * Returns strlen(src) + MIN(siz, strlen(initial dst)). * If retval >= siz, truncation occurred. */ size_t strlcat(char *dst, const char *src, size_t siz) { char *d = dst; const char *s = src; size_t n = siz; size_t dlen; /* Find the end of dst and adjust bytes left but don't go past end */ while (n-- != 0 && *d != '\0') d++; dlen = d - dst; n = siz - dlen; if (n == 0) return(dlen + strlen(s)); while (*s != '\0') { if (n != 1) { *d++ = *s; n--; } s++; } *d = '\0'; return(dlen + (s - src)); /* count does not include NUL */ } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/compat/strlcpy.c0000644000175000017500000000302712360020705021404 0ustar /* $OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $ */ /* * Copyright (c) 1998 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include /* * Copy src to string dst of size siz. At most siz-1 characters * will be copied. Always NUL terminates (unless siz == 0). * Returns strlen(src); if retval >= siz, truncation occurred. */ size_t strlcpy(char *dst, const char *src, size_t siz) { char *d = dst; const char *s = src; size_t n = siz; /* Copy as many bytes as will fit */ if (n != 0) { while (--n != 0) { if ((*d++ = *s++) == '\0') break; } } /* Not enough room in dst, add NUL and traverse rest of src */ if (n == 0) { if (siz != 0) *d = '\0'; /* NUL-terminate dst */ while (*s++) ; } return(s - src - 1); /* count does not include NUL */ } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/compat/getentropy_nacl.c0000664000175000017500000000450712430034550023110 0ustar /* $OpenBSD: getentropy_linux.c,v 1.17 2014/07/08 09:30:33 beck Exp $ */ /* * Copyright (c) 2014 Theo de Raadt * Copyright (c) 2014 Richard Diamond * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include /* NOTE: There is no fallback. Don't try to write one. If we can't access the * virtual /dev/urandom, we return -1. End of story. */ /* * Basic sanity checking; wish we could do better. */ static int gotdata(char *buf, size_t len) { char any_set = 0; size_t i; for (i = 0; i < len; ++i) any_set |= buf[i]; if (any_set == 0) return -1; return 0; } int getentropy(void *buf, size_t len) { struct stat st; size_t i; int fd, flags; int save_errno = errno; start: flags = O_RDONLY; #ifdef O_NOFOLLOW flags |= O_NOFOLLOW; #endif #ifdef O_CLOEXEC flags |= O_CLOEXEC; #endif fd = open("/dev/urandom", flags, 0); if (fd == -1) { if (errno == EINTR) goto start; goto nodevrandom; } #ifndef O_CLOEXEC fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); #endif /* Lightly verify that the device node looks sane */ if (fstat(fd, &st) == -1 || !S_ISCHR(st.st_mode)) { close(fd); goto nodevrandom; } for (i = 0; i < len; ) { size_t wanted = len - i; ssize_t ret = read(fd, buf + i, wanted); if (ret == -1) { if (errno == EAGAIN || errno == EINTR) continue; close(fd); goto nodevrandom; } i += ret; } close(fd); if (gotdata(buf, len) == 0) { errno = save_errno; return 0; /* satisfied */ } nodevrandom: errno = EIO; return -1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/compat/getentropy_osx.c0000644000175000017500000002503712360020705023002 0ustar /* $OpenBSD: getentropy_osx.c,v 1.1 2014/07/08 10:45:35 beck Exp $ */ /* * Copyright (c) 2014 Theo de Raadt * Copyright (c) 2014 Bob Beck * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define SHA512_Update(a, b, c) (CC_SHA512_Update((a), (b), (c))) #define SHA512_Init(xxx) (CC_SHA512_Init((xxx))) #define SHA512_Final(xxx, yyy) (CC_SHA512_Final((xxx), (yyy))) #define SHA512_CTX CC_SHA512_CTX #define SHA512_DIGEST_LENGTH CC_SHA512_DIGEST_LENGTH #define REPEAT 5 #define min(a, b) (((a) < (b)) ? (a) : (b)) #define HX(a, b) \ do { \ if ((a)) \ HD(errno); \ else \ HD(b); \ } while (0) #define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l))) #define HD(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (x))) int getentropy(void *buf, size_t len); extern int main(int, char *argv[]); static int gotdata(char *buf, size_t len); static int getentropy_urandom(void *buf, size_t len); static int getentropy_fallback(void *buf, size_t len); int getentropy(void *buf, size_t len) { int ret = -1; if (len > 256) { errno = EIO; return -1; } /* * Try to get entropy with /dev/urandom * * This can fail if the process is inside a chroot or if file * descriptors are exhausted. */ ret = getentropy_urandom(buf, len); if (ret != -1) return (ret); /* * Entropy collection via /dev/urandom and sysctl have failed. * * No other API exists for collecting entropy, and we have * no failsafe way to get it on OSX that is not sensitive * to resource exhaustion. * * We have very few options: * - Even syslog_r is unsafe to call at this low level, so * there is no way to alert the user or program. * - Cannot call abort() because some systems have unsafe * corefiles. * - Could raise(SIGKILL) resulting in silent program termination. * - Return EIO, to hint that arc4random's stir function * should raise(SIGKILL) * - Do the best under the circumstances.... * * This code path exists to bring light to the issue that OSX * does not provide a failsafe API for entropy collection. * * We hope this demonstrates that OSX should consider * providing a new failsafe API which works in a chroot or * when file descriptors are exhausted. */ #undef FAIL_WHEN_SYSTEM_ENTROPY_FAILS #ifdef FAIL_WHEN_SYSTEM_ENTROPY_FAILS raise(SIGKILL); #endif ret = getentropy_fallback(buf, len); if (ret != -1) return (ret); errno = EIO; return (ret); } /* * Basic sanity checking; wish we could do better. */ static int gotdata(char *buf, size_t len) { char any_set = 0; size_t i; for (i = 0; i < len; ++i) any_set |= buf[i]; if (any_set == 0) return -1; return 0; } static int getentropy_urandom(void *buf, size_t len) { struct stat st; size_t i; int fd, flags; int save_errno = errno; start: flags = O_RDONLY; #ifdef O_NOFOLLOW flags |= O_NOFOLLOW; #endif #ifdef O_CLOEXEC flags |= O_CLOEXEC; #endif fd = open("/dev/urandom", flags, 0); if (fd == -1) { if (errno == EINTR) goto start; goto nodevrandom; } #ifndef O_CLOEXEC fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); #endif /* Lightly verify that the device node looks sane */ if (fstat(fd, &st) == -1 || !S_ISCHR(st.st_mode)) { close(fd); goto nodevrandom; } for (i = 0; i < len; ) { size_t wanted = len - i; ssize_t ret = read(fd, buf + i, wanted); if (ret == -1) { if (errno == EAGAIN || errno == EINTR) continue; close(fd); goto nodevrandom; } i += ret; } close(fd); if (gotdata(buf, len) == 0) { errno = save_errno; return 0; /* satisfied */ } nodevrandom: errno = EIO; return -1; } static int getentropy_fallback(void *buf, size_t len) { int tcpmib[] = { CTL_NET, AF_INET, IPPROTO_TCP, TCPCTL_STATS }; int udpmib[] = { CTL_NET, AF_INET, IPPROTO_UDP, UDPCTL_STATS }; int ipmib[] = { CTL_NET, AF_INET, IPPROTO_IP, IPCTL_STATS }; int kmib[] = { CTL_KERN, KERN_USRSTACK }; int hwmib[] = { CTL_HW, HW_USERMEM }; int save_errno = errno, e, m, pgs = getpagesize(), faster = 0, repeat; uint8_t results[SHA512_DIGEST_LENGTH]; struct tcpstat tcpstat; struct udpstat udpstat; struct ipstat ipstat; u_int64_t mach_time; unsigned int idata; struct timespec ts; struct timeval tv; struct rusage ru; sigset_t sigset; struct stat st; static int cnt; SHA512_CTX ctx; static pid_t lastpid; void * addr; pid_t pid; size_t i; char *p; pid = getpid(); if (lastpid == pid) { faster = 1; repeat = 2; } else { faster = 0; lastpid = pid; repeat = REPEAT; } for (i = 0; i < len; ) { int j; SHA512_Init(&ctx); for (j = 0; j < repeat; j++) { size_t len; HX((e = gettimeofday(&tv, NULL)) == -1, tv); if (e != -1) { cnt += (int)tv.tv_sec; cnt += (int)tv.tv_usec; } mach_time = mach_absolute_time(); HD(mach_time); len = sizeof(addr); HX(sysctl(kmib, sizeof(kmib) / sizeof(kmib[0]), &addr, &len, NULL, 0) == -1, addr); len = sizeof(idata); HX(sysctl(hwmib, sizeof(hwmib) / sizeof(hwmib[0]), &idata, &len, NULL, 0) == -1, idata); len = sizeof(tcpstat); HX(sysctl(tcpmib, sizeof(tcpmib) / sizeof(tcpmib[0]), &tcpstat, &len, NULL, 0) == -1, tcpstat); len = sizeof(udpstat); HX(sysctl(udpmib, sizeof(udpmib) / sizeof(udpmib[0]), &udpstat, &len, NULL, 0) == -1, udpstat); len = sizeof(ipstat); HX(sysctl(ipmib, sizeof(ipmib) / sizeof(ipmib[0]), &ipstat, &len, NULL, 0) == -1, ipstat); HX((pid = getpid()) == -1, pid); HX((pid = getsid(pid)) == -1, pid); HX((pid = getppid()) == -1, pid); HX((pid = getpgid(0)) == -1, pid); HX((m = getpriority(0, 0)) == -1, m); if (!faster) { ts.tv_sec = 0; ts.tv_nsec = 1; (void) nanosleep(&ts, NULL); } HX(sigpending(&sigset) == -1, sigset); HX(sigprocmask(SIG_BLOCK, NULL, &sigset) == -1, sigset); HD(main); /* an addr in program */ HD(getentropy); /* an addr in this library */ HD(printf); /* an addr in libc */ p = (char *)&p; HD(p); /* an addr on stack */ p = (char *)&errno; HD(p); /* the addr of errno */ if (i == 0) { struct sockaddr_storage ss; struct statvfs stvfs; struct termios tios; struct statfs stfs; socklen_t ssl; off_t off; /* * Prime-sized mappings encourage fragmentation; * thus exposing some address entropy. */ struct mm { size_t npg; void *p; } mm[] = { { 17, MAP_FAILED }, { 3, MAP_FAILED }, { 11, MAP_FAILED }, { 2, MAP_FAILED }, { 5, MAP_FAILED }, { 3, MAP_FAILED }, { 7, MAP_FAILED }, { 1, MAP_FAILED }, { 57, MAP_FAILED }, { 3, MAP_FAILED }, { 131, MAP_FAILED }, { 1, MAP_FAILED }, }; for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { HX(mm[m].p = mmap(NULL, mm[m].npg * pgs, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, (off_t)0), mm[m].p); if (mm[m].p != MAP_FAILED) { size_t mo; /* Touch some memory... */ p = mm[m].p; mo = cnt % (mm[m].npg * pgs - 1); p[mo] = 1; cnt += (int)((long)(mm[m].p) / pgs); } /* Check cnts and times... */ mach_time = mach_absolute_time(); HD(mach_time); cnt += (int)mach_time; HX((e = getrusage(RUSAGE_SELF, &ru)) == -1, ru); if (e != -1) { cnt += (int)ru.ru_utime.tv_sec; cnt += (int)ru.ru_utime.tv_usec; } } for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { if (mm[m].p != MAP_FAILED) munmap(mm[m].p, mm[m].npg * pgs); mm[m].p = MAP_FAILED; } HX(stat(".", &st) == -1, st); HX(statvfs(".", &stvfs) == -1, stvfs); HX(statfs(".", &stfs) == -1, stfs); HX(stat("/", &st) == -1, st); HX(statvfs("/", &stvfs) == -1, stvfs); HX(statfs("/", &stfs) == -1, stfs); HX((e = fstat(0, &st)) == -1, st); if (e == -1) { if (S_ISREG(st.st_mode) || S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { HX(fstatvfs(0, &stvfs) == -1, stvfs); HX(fstatfs(0, &stfs) == -1, stfs); HX((off = lseek(0, (off_t)0, SEEK_CUR)) < 0, off); } if (S_ISCHR(st.st_mode)) { HX(tcgetattr(0, &tios) == -1, tios); } else if (S_ISSOCK(st.st_mode)) { memset(&ss, 0, sizeof ss); ssl = sizeof(ss); HX(getpeername(0, (void *)&ss, &ssl) == -1, ss); } } HX((e = getrusage(RUSAGE_CHILDREN, &ru)) == -1, ru); if (e != -1) { cnt += (int)ru.ru_utime.tv_sec; cnt += (int)ru.ru_utime.tv_usec; } } else { /* Subsequent hashes absorb previous result */ HD(results); } HX((e = gettimeofday(&tv, NULL)) == -1, tv); if (e != -1) { cnt += (int)tv.tv_sec; cnt += (int)tv.tv_usec; } HD(cnt); } SHA512_Final(results, &ctx); memcpy(buf + i, results, min(sizeof(results), len - i)); i += min(sizeof(results), len - i); } memset(results, 0, sizeof results); if (gotdata(buf, len) == 0) { errno = save_errno; return 0; /* satisfied */ } errno = EIO; return -1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/compat/chacha_private.h0000644000175000017500000001233012360020705022647 0ustar /* chacha-merged.c version 20080118 D. J. Bernstein Public domain. */ /* $OpenBSD$ */ typedef unsigned char u8; typedef unsigned int u32; typedef struct { u32 input[16]; /* could be compressed */ } chacha_ctx; #define U8C(v) (v##U) #define U32C(v) (v##U) #define U8V(v) ((u8)(v) & U8C(0xFF)) #define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF)) #define ROTL32(v, n) \ (U32V((v) << (n)) | ((v) >> (32 - (n)))) #define U8TO32_LITTLE(p) \ (((u32)((p)[0]) ) | \ ((u32)((p)[1]) << 8) | \ ((u32)((p)[2]) << 16) | \ ((u32)((p)[3]) << 24)) #define U32TO8_LITTLE(p, v) \ do { \ (p)[0] = U8V((v) ); \ (p)[1] = U8V((v) >> 8); \ (p)[2] = U8V((v) >> 16); \ (p)[3] = U8V((v) >> 24); \ } while (0) #define ROTATE(v,c) (ROTL32(v,c)) #define XOR(v,w) ((v) ^ (w)) #define PLUS(v,w) (U32V((v) + (w))) #define PLUSONE(v) (PLUS((v),1)) #define QUARTERROUND(a,b,c,d) \ a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \ c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \ a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \ c = PLUS(c,d); b = ROTATE(XOR(b,c), 7); static const char sigma[16] = "expand 32-byte k"; static const char tau[16] = "expand 16-byte k"; static void chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits,u32 ivbits) { const char *constants; x->input[4] = U8TO32_LITTLE(k + 0); x->input[5] = U8TO32_LITTLE(k + 4); x->input[6] = U8TO32_LITTLE(k + 8); x->input[7] = U8TO32_LITTLE(k + 12); if (kbits == 256) { /* recommended */ k += 16; constants = sigma; } else { /* kbits == 128 */ constants = tau; } x->input[8] = U8TO32_LITTLE(k + 0); x->input[9] = U8TO32_LITTLE(k + 4); x->input[10] = U8TO32_LITTLE(k + 8); x->input[11] = U8TO32_LITTLE(k + 12); x->input[0] = U8TO32_LITTLE(constants + 0); x->input[1] = U8TO32_LITTLE(constants + 4); x->input[2] = U8TO32_LITTLE(constants + 8); x->input[3] = U8TO32_LITTLE(constants + 12); } static void chacha_ivsetup(chacha_ctx *x,const u8 *iv) { x->input[12] = 0; x->input[13] = 0; x->input[14] = U8TO32_LITTLE(iv + 0); x->input[15] = U8TO32_LITTLE(iv + 4); } static void chacha_encrypt_bytes(chacha_ctx *x,const u8 *m,u8 *c,u32 bytes) { u32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15; u32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15; u8 *ctarget = NULL; u8 tmp[64]; u_int i; if (!bytes) return; j0 = x->input[0]; j1 = x->input[1]; j2 = x->input[2]; j3 = x->input[3]; j4 = x->input[4]; j5 = x->input[5]; j6 = x->input[6]; j7 = x->input[7]; j8 = x->input[8]; j9 = x->input[9]; j10 = x->input[10]; j11 = x->input[11]; j12 = x->input[12]; j13 = x->input[13]; j14 = x->input[14]; j15 = x->input[15]; for (;;) { if (bytes < 64) { for (i = 0;i < bytes;++i) tmp[i] = m[i]; m = tmp; ctarget = c; c = tmp; } x0 = j0; x1 = j1; x2 = j2; x3 = j3; x4 = j4; x5 = j5; x6 = j6; x7 = j7; x8 = j8; x9 = j9; x10 = j10; x11 = j11; x12 = j12; x13 = j13; x14 = j14; x15 = j15; for (i = 20;i > 0;i -= 2) { QUARTERROUND( x0, x4, x8,x12) QUARTERROUND( x1, x5, x9,x13) QUARTERROUND( x2, x6,x10,x14) QUARTERROUND( x3, x7,x11,x15) QUARTERROUND( x0, x5,x10,x15) QUARTERROUND( x1, x6,x11,x12) QUARTERROUND( x2, x7, x8,x13) QUARTERROUND( x3, x4, x9,x14) } x0 = PLUS(x0,j0); x1 = PLUS(x1,j1); x2 = PLUS(x2,j2); x3 = PLUS(x3,j3); x4 = PLUS(x4,j4); x5 = PLUS(x5,j5); x6 = PLUS(x6,j6); x7 = PLUS(x7,j7); x8 = PLUS(x8,j8); x9 = PLUS(x9,j9); x10 = PLUS(x10,j10); x11 = PLUS(x11,j11); x12 = PLUS(x12,j12); x13 = PLUS(x13,j13); x14 = PLUS(x14,j14); x15 = PLUS(x15,j15); #ifndef KEYSTREAM_ONLY x0 = XOR(x0,U8TO32_LITTLE(m + 0)); x1 = XOR(x1,U8TO32_LITTLE(m + 4)); x2 = XOR(x2,U8TO32_LITTLE(m + 8)); x3 = XOR(x3,U8TO32_LITTLE(m + 12)); x4 = XOR(x4,U8TO32_LITTLE(m + 16)); x5 = XOR(x5,U8TO32_LITTLE(m + 20)); x6 = XOR(x6,U8TO32_LITTLE(m + 24)); x7 = XOR(x7,U8TO32_LITTLE(m + 28)); x8 = XOR(x8,U8TO32_LITTLE(m + 32)); x9 = XOR(x9,U8TO32_LITTLE(m + 36)); x10 = XOR(x10,U8TO32_LITTLE(m + 40)); x11 = XOR(x11,U8TO32_LITTLE(m + 44)); x12 = XOR(x12,U8TO32_LITTLE(m + 48)); x13 = XOR(x13,U8TO32_LITTLE(m + 52)); x14 = XOR(x14,U8TO32_LITTLE(m + 56)); x15 = XOR(x15,U8TO32_LITTLE(m + 60)); #endif j12 = PLUSONE(j12); if (!j12) { j13 = PLUSONE(j13); /* stopping at 2^70 bytes per nonce is user's responsibility */ } U32TO8_LITTLE(c + 0,x0); U32TO8_LITTLE(c + 4,x1); U32TO8_LITTLE(c + 8,x2); U32TO8_LITTLE(c + 12,x3); U32TO8_LITTLE(c + 16,x4); U32TO8_LITTLE(c + 20,x5); U32TO8_LITTLE(c + 24,x6); U32TO8_LITTLE(c + 28,x7); U32TO8_LITTLE(c + 32,x8); U32TO8_LITTLE(c + 36,x9); U32TO8_LITTLE(c + 40,x10); U32TO8_LITTLE(c + 44,x11); U32TO8_LITTLE(c + 48,x12); U32TO8_LITTLE(c + 52,x13); U32TO8_LITTLE(c + 56,x14); U32TO8_LITTLE(c + 60,x15); if (bytes <= 64) { if (bytes < 64) { for (i = 0;i < bytes;++i) ctarget[i] = c[i]; } x->input[12] = j12; x->input[13] = j13; return; } bytes -= 64; c += 64; #ifndef KEYSTREAM_ONLY m += 64; #endif } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/compat/timingsafe_memcmp.c0000644000175000017500000000304112360020705023364 0ustar /* $OpenBSD$ */ /* * Copyright (c) 2014 Google Inc. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include int timingsafe_memcmp(const void *b1, const void *b2, size_t len) { const unsigned char *p1 = b1, *p2 = b2; size_t i; int res = 0, done = 0; for (i = 0; i < len; i++) { /* lt is -1 if p1[i] < p2[i]; else 0. */ int lt = (p1[i] - p2[i]) >> CHAR_BIT; /* gt is -1 if p1[i] > p2[i]; else 0. */ int gt = (p2[i] - p1[i]) >> CHAR_BIT; /* cmp is 1 if p1[i] > p2[i]; -1 if p1[i] < p2[i]; else 0. */ int cmp = lt - gt; /* set res = cmp if !done. */ res |= cmp & ~done; /* set done if p1[i] != p2[i]. */ done |= lt | gt; } return (res); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/compat/getentropy_linux.c0000644000175000017500000002700212360020705023322 0ustar /* $OpenBSD: getentropy_linux.c,v 1.17 2014/07/08 09:30:33 beck Exp $ */ /* * Copyright (c) 2014 Theo de Raadt * Copyright (c) 2014 Bob Beck * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #define _POSIX_C_SOURCE 199309L #define _GNU_SOURCE 1 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_GETAUXVAL #include #endif #include #define REPEAT 5 #define min(a, b) (((a) < (b)) ? (a) : (b)) #define HX(a, b) \ do { \ if ((a)) \ HD(errno); \ else \ HD(b); \ } while (0) #define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l))) #define HD(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (x))) int getentropy(void *buf, size_t len); extern int main(int, char *argv[]); static int gotdata(char *buf, size_t len); static int getentropy_urandom(void *buf, size_t len); #ifdef CTL_MAXNAME static int getentropy_sysctl(void *buf, size_t len); #endif static int getentropy_fallback(void *buf, size_t len); int getentropy(void *buf, size_t len) { int ret = -1; if (len > 256) { errno = EIO; return -1; } /* * Try to get entropy with /dev/urandom * * This can fail if the process is inside a chroot or if file * descriptors are exhausted. */ ret = getentropy_urandom(buf, len); if (ret != -1) return (ret); #ifdef CTL_MAXNAME /* * Try to use sysctl CTL_KERN, KERN_RANDOM, RANDOM_UUID. * sysctl is a failsafe API, so it guarantees a result. This * should work inside a chroot, or when file descriptors are * exhuasted. * * However this can fail if the Linux kernel removes support * for sysctl. Starting in 2007, there have been efforts to * deprecate the sysctl API/ABI, and push callers towards use * of the chroot-unavailable fd-using /proc mechanism -- * essentially the same problems as /dev/urandom. * * Numerous setbacks have been encountered in their deprecation * schedule, so as of June 2014 the kernel ABI still exists on * most Linux architectures. The sysctl() stub in libc is missing * on some systems. There are also reports that some kernels * spew messages to the console. */ ret = getentropy_sysctl(buf, len); if (ret != -1) return (ret); #endif /* CTL_MAXNAME */ /* * Entropy collection via /dev/urandom and sysctl have failed. * * No other API exists for collecting entropy. See the large * comment block above. * * We have very few options: * - Even syslog_r is unsafe to call at this low level, so * there is no way to alert the user or program. * - Cannot call abort() because some systems have unsafe * corefiles. * - Could raise(SIGKILL) resulting in silent program termination. * - Return EIO, to hint that arc4random's stir function * should raise(SIGKILL) * - Do the best under the circumstances.... * * This code path exists to bring light to the issue that Linux * does not provide a failsafe API for entropy collection. * * We hope this demonstrates that Linux should either retain their * sysctl ABI, or consider providing a new failsafe API which * works in a chroot or when file descriptors are exhausted. */ #undef FAIL_HARD_WHEN_LINUX_DEPRECATES_SYSCTL #ifdef FAIL_HARD_WHEN_LINUX_DEPRECATES_SYSCTL raise(SIGKILL); #endif ret = getentropy_fallback(buf, len); if (ret != -1) return (ret); errno = EIO; return (ret); } /* * Basic sanity checking; wish we could do better. */ static int gotdata(char *buf, size_t len) { char any_set = 0; size_t i; for (i = 0; i < len; ++i) any_set |= buf[i]; if (any_set == 0) return -1; return 0; } static int getentropy_urandom(void *buf, size_t len) { struct stat st; size_t i; int fd, cnt, flags; int save_errno = errno; start: flags = O_RDONLY; #ifdef O_NOFOLLOW flags |= O_NOFOLLOW; #endif #ifdef O_CLOEXEC flags |= O_CLOEXEC; #endif fd = open("/dev/urandom", flags, 0); if (fd == -1) { if (errno == EINTR) goto start; goto nodevrandom; } #ifndef O_CLOEXEC fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); #endif /* Lightly verify that the device node looks sane */ if (fstat(fd, &st) == -1 || !S_ISCHR(st.st_mode)) { close(fd); goto nodevrandom; } if (ioctl(fd, RNDGETENTCNT, &cnt) == -1) { close(fd); goto nodevrandom; } for (i = 0; i < len; ) { size_t wanted = len - i; ssize_t ret = read(fd, buf + i, wanted); if (ret == -1) { if (errno == EAGAIN || errno == EINTR) continue; close(fd); goto nodevrandom; } i += ret; } close(fd); if (gotdata(buf, len) == 0) { errno = save_errno; return 0; /* satisfied */ } nodevrandom: errno = EIO; return -1; } #ifdef CTL_MAXNAME static int getentropy_sysctl(void *buf, size_t len) { static int mib[] = { CTL_KERN, KERN_RANDOM, RANDOM_UUID }; size_t i, chunk; int save_errno = errno; for (i = 0; i < len; ) { chunk = min(len - i, 16); /* SYS__sysctl because some systems already removed sysctl() */ struct __sysctl_args args = { .name = mib, .nlen = 3, .oldval = buf + i, .oldlenp = &chunk, }; if (syscall(SYS__sysctl, &args) != 0) goto sysctlfailed; i += chunk; } if (gotdata(buf, len) == 0) { errno = save_errno; return (0); /* satisfied */ } sysctlfailed: errno = EIO; return -1; } #endif /* CTL_MAXNAME */ static int cl[] = { CLOCK_REALTIME, #ifdef CLOCK_MONOTONIC CLOCK_MONOTONIC, #endif #ifdef CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC_RAW, #endif #ifdef CLOCK_TAI CLOCK_TAI, #endif #ifdef CLOCK_VIRTUAL CLOCK_VIRTUAL, #endif #ifdef CLOCK_UPTIME CLOCK_UPTIME, #endif #ifdef CLOCK_PROCESS_CPUTIME_ID CLOCK_PROCESS_CPUTIME_ID, #endif #ifdef CLOCK_THREAD_CPUTIME_ID CLOCK_THREAD_CPUTIME_ID, #endif }; static int getentropy_fallback(void *buf, size_t len) { uint8_t results[SHA512_DIGEST_LENGTH]; int save_errno = errno, e, m, pgs = getpagesize(), faster = 0, repeat; static int cnt; struct timespec ts; struct timeval tv; struct rusage ru; sigset_t sigset; struct stat st; SHA512_CTX ctx; static pid_t lastpid; pid_t pid; size_t i, ii; char *p; pid = getpid(); if (lastpid == pid) { faster = 1; repeat = 2; } else { faster = 0; lastpid = pid; repeat = REPEAT; } for (i = 0; i < len; ) { int j; SHA512_Init(&ctx); for (j = 0; j < repeat; j++) { HX((e = gettimeofday(&tv, NULL)) == -1, tv); if (e != -1) { cnt += (int)tv.tv_sec; cnt += (int)tv.tv_usec; } for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++) HX(clock_gettime(cl[ii], &ts) == -1, ts); HX((pid = getpid()) == -1, pid); HX((pid = getsid(pid)) == -1, pid); HX((pid = getppid()) == -1, pid); HX((pid = getpgid(0)) == -1, pid); HX((m = getpriority(0, 0)) == -1, m); if (!faster) { ts.tv_sec = 0; ts.tv_nsec = 1; (void) nanosleep(&ts, NULL); } HX(sigpending(&sigset) == -1, sigset); HX(sigprocmask(SIG_BLOCK, NULL, &sigset) == -1, sigset); HD(main); /* an addr in program */ HD(getentropy); /* an addr in this library */ HD(printf); /* an addr in libc */ p = (char *)&p; HD(p); /* an addr on stack */ p = (char *)&errno; HD(p); /* the addr of errno */ if (i == 0) { struct sockaddr_storage ss; struct statvfs stvfs; struct termios tios; struct statfs stfs; socklen_t ssl; off_t off; /* * Prime-sized mappings encourage fragmentation; * thus exposing some address entropy. */ struct mm { size_t npg; void *p; } mm[] = { { 17, MAP_FAILED }, { 3, MAP_FAILED }, { 11, MAP_FAILED }, { 2, MAP_FAILED }, { 5, MAP_FAILED }, { 3, MAP_FAILED }, { 7, MAP_FAILED }, { 1, MAP_FAILED }, { 57, MAP_FAILED }, { 3, MAP_FAILED }, { 131, MAP_FAILED }, { 1, MAP_FAILED }, }; for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { HX(mm[m].p = mmap(NULL, mm[m].npg * pgs, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, (off_t)0), mm[m].p); if (mm[m].p != MAP_FAILED) { size_t mo; /* Touch some memory... */ p = mm[m].p; mo = cnt % (mm[m].npg * pgs - 1); p[mo] = 1; cnt += (int)((long)(mm[m].p) / pgs); } /* Check cnts and times... */ for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++) { HX((e = clock_gettime(cl[ii], &ts)) == -1, ts); if (e != -1) cnt += (int)ts.tv_nsec; } HX((e = getrusage(RUSAGE_SELF, &ru)) == -1, ru); if (e != -1) { cnt += (int)ru.ru_utime.tv_sec; cnt += (int)ru.ru_utime.tv_usec; } } for (m = 0; m < sizeof mm/sizeof(mm[0]); m++) { if (mm[m].p != MAP_FAILED) munmap(mm[m].p, mm[m].npg * pgs); mm[m].p = MAP_FAILED; } HX(stat(".", &st) == -1, st); HX(statvfs(".", &stvfs) == -1, stvfs); HX(statfs(".", &stfs) == -1, stfs); HX(stat("/", &st) == -1, st); HX(statvfs("/", &stvfs) == -1, stvfs); HX(statfs("/", &stfs) == -1, stfs); HX((e = fstat(0, &st)) == -1, st); if (e == -1) { if (S_ISREG(st.st_mode) || S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { HX(fstatvfs(0, &stvfs) == -1, stvfs); HX(fstatfs(0, &stfs) == -1, stfs); HX((off = lseek(0, (off_t)0, SEEK_CUR)) < 0, off); } if (S_ISCHR(st.st_mode)) { HX(tcgetattr(0, &tios) == -1, tios); } else if (S_ISSOCK(st.st_mode)) { memset(&ss, 0, sizeof ss); ssl = sizeof(ss); HX(getpeername(0, (void *)&ss, &ssl) == -1, ss); } } HX((e = getrusage(RUSAGE_CHILDREN, &ru)) == -1, ru); if (e != -1) { cnt += (int)ru.ru_utime.tv_sec; cnt += (int)ru.ru_utime.tv_usec; } } else { /* Subsequent hashes absorb previous result */ HD(results); } HX((e = gettimeofday(&tv, NULL)) == -1, tv); if (e != -1) { cnt += (int)tv.tv_sec; cnt += (int)tv.tv_usec; } HD(cnt); } #ifdef AT_RANDOM /* Not as random as you think but we take what we are given */ p = (char *) getauxval(AT_RANDOM); if (p) HR(p, 16); #endif #ifdef AT_SYSINFO_EHDR p = (char *) getauxval(AT_SYSINFO_EHDR); if (p) HR(p, pgs); #endif #ifdef AT_BASE p = (char *) getauxval(AT_BASE); if (p) HD(p); #endif SHA512_Final(results, &ctx); memcpy(buf + i, results, min(sizeof(results), len - i)); i += min(sizeof(results), len - i); } memset(results, 0, sizeof results); if (gotdata(buf, len) == 0) { errno = save_errno; return 0; /* satisfied */ } errno = EIO; return -1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/compat/reallocarray.c0000644000175000017500000000250612360020705022365 0ustar /* $OpenBSD: malloc.c,v 1.160 2014/05/07 20:07:59 halex Exp $ */ /* * Copyright (c) 2008 Otto Moerbeek * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include /* * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW */ #define MUL_NO_OVERFLOW (1UL << (sizeof(size_t) * 4)) void * reallocarray(void *optr, size_t nmemb, size_t size) { if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) && nmemb > 0 && SIZE_MAX / nmemb < size) { errno = ENOMEM; return NULL; } return realloc(optr, size * nmemb); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/compat/timingsafe_bcmp.c0000644000175000017500000000206512360020705023034 0ustar /* $OpenBSD: timingsafe_bcmp.c,v 1.1 2010/09/24 13:33:00 matthew Exp $ */ /* * Copyright (c) 2010 Damien Miller. All rights reserved. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include int timingsafe_bcmp(const void *b1, const void *b2, size_t n) { const unsigned char *p1 = b1, *p2 = b2; int ret = 0; for (; n > 0; n--) ret |= *p1++ ^ *p2++; return (ret != 0); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ecdh/0000755000000000000000000000000012666635521020755 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/ecdh/ech_ossl.c0000644000175000017500000001420012360020705021116 0ustar /* $OpenBSD: ech_ossl.c,v 1.6 2014/07/10 22:45:57 jsing Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * The Elliptic Curve Public-Key Crypto Library (ECC Code) included * herein is developed by SUN MICROSYSTEMS, INC., and is contributed * to the OpenSSL project. * * The ECC Code is licensed pursuant to the OpenSSL open source * license provided below. * * The ECDH software is originally written by Douglas Stebila of * Sun Microsystems Laboratories. * */ /* ==================================================================== * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include "ech_locl.h" static int ecdh_compute_key(void *out, size_t len, const EC_POINT *pub_key, EC_KEY *ecdh, void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); static ECDH_METHOD openssl_ecdh_meth = { .name = "OpenSSL ECDH method", .compute_key = ecdh_compute_key }; const ECDH_METHOD *ECDH_OpenSSL(void) { return &openssl_ecdh_meth; } /* This implementation is based on the following primitives in the IEEE 1363 standard: * - ECKAS-DH1 * - ECSVDP-DH * Finally an optional KDF is applied. */ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh, void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)) { BN_CTX *ctx; EC_POINT *tmp=NULL; BIGNUM *x=NULL, *y=NULL; const BIGNUM *priv_key; const EC_GROUP* group; int ret= -1; size_t buflen, len; unsigned char *buf=NULL; if (outlen > INT_MAX) { ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_MALLOC_FAILURE); /* sort of, anyway */ return -1; } if ((ctx = BN_CTX_new()) == NULL) goto err; BN_CTX_start(ctx); x = BN_CTX_get(ctx); y = BN_CTX_get(ctx); priv_key = EC_KEY_get0_private_key(ecdh); if (priv_key == NULL) { ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ECDH_R_NO_PRIVATE_VALUE); goto err; } group = EC_KEY_get0_group(ecdh); if ((tmp=EC_POINT_new(group)) == NULL) { ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_MALLOC_FAILURE); goto err; } if (!EC_POINT_mul(group, tmp, NULL, pub_key, priv_key, ctx)) { ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ECDH_R_POINT_ARITHMETIC_FAILURE); goto err; } if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field) { if (!EC_POINT_get_affine_coordinates_GFp(group, tmp, x, y, ctx)) { ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ECDH_R_POINT_ARITHMETIC_FAILURE); goto err; } } #ifndef OPENSSL_NO_EC2M else { if (!EC_POINT_get_affine_coordinates_GF2m(group, tmp, x, y, ctx)) { ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ECDH_R_POINT_ARITHMETIC_FAILURE); goto err; } } #endif buflen = (EC_GROUP_get_degree(group) + 7)/8; len = BN_num_bytes(x); if (len > buflen) { ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_INTERNAL_ERROR); goto err; } if ((buf = malloc(buflen)) == NULL) { ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_MALLOC_FAILURE); goto err; } memset(buf, 0, buflen - len); if (len != (size_t)BN_bn2bin(x, buf + buflen - len)) { ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_BN_LIB); goto err; } if (KDF != 0) { if (KDF(buf, buflen, out, &outlen) == NULL) { ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ECDH_R_KDF_FAILED); goto err; } ret = outlen; } else { /* no KDF, just copy as much as we can */ if (outlen > buflen) outlen = buflen; memcpy(out, buf, outlen); ret = outlen; } err: if (tmp) EC_POINT_free(tmp); if (ctx) BN_CTX_end(ctx); if (ctx) BN_CTX_free(ctx); free(buf); return(ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ecdh/ech_lib.c0000644000175000017500000001534012360020705020712 0ustar /* $OpenBSD: ech_lib.c,v 1.6 2014/07/09 11:10:50 bcook Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * The Elliptic Curve Public-Key Crypto Library (ECC Code) included * herein is developed by SUN MICROSYSTEMS, INC., and is contributed * to the OpenSSL project. * * The ECC Code is licensed pursuant to the OpenSSL open source * license provided below. * * The ECDH software is originally written by Douglas Stebila of * Sun Microsystems Laboratories. * */ /* ==================================================================== * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "ech_locl.h" #ifndef OPENSSL_NO_ENGINE #include #endif #include static const ECDH_METHOD *default_ECDH_method = NULL; static void *ecdh_data_new(void); static void *ecdh_data_dup(void *); static void ecdh_data_free(void *); void ECDH_set_default_method(const ECDH_METHOD *meth) { default_ECDH_method = meth; } const ECDH_METHOD *ECDH_get_default_method(void) { if(!default_ECDH_method) { default_ECDH_method = ECDH_OpenSSL(); } return default_ECDH_method; } int ECDH_set_method(EC_KEY *eckey, const ECDH_METHOD *meth) { ECDH_DATA *ecdh; ecdh = ecdh_check(eckey); if (ecdh == NULL) return 0; #if 0 mtmp = ecdh->meth; if (mtmp->finish) mtmp->finish(eckey); #endif #ifndef OPENSSL_NO_ENGINE if (ecdh->engine) { ENGINE_finish(ecdh->engine); ecdh->engine = NULL; } #endif ecdh->meth = meth; #if 0 if (meth->init) meth->init(eckey); #endif return 1; } static ECDH_DATA *ECDH_DATA_new_method(ENGINE *engine) { ECDH_DATA *ret; ret = malloc(sizeof(ECDH_DATA)); if (ret == NULL) { ECDHerr(ECDH_F_ECDH_DATA_NEW_METHOD, ERR_R_MALLOC_FAILURE); return(NULL); } ret->init = NULL; ret->meth = ECDH_get_default_method(); ret->engine = engine; #ifndef OPENSSL_NO_ENGINE if (!ret->engine) ret->engine = ENGINE_get_default_ECDH(); if (ret->engine) { ret->meth = ENGINE_get_ECDH(ret->engine); if (!ret->meth) { ECDHerr(ECDH_F_ECDH_DATA_NEW_METHOD, ERR_R_ENGINE_LIB); ENGINE_finish(ret->engine); free(ret); return NULL; } } #endif ret->flags = ret->meth->flags; CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ECDH, ret, &ret->ex_data); #if 0 if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDH, ret, &ret->ex_data); free(ret); ret=NULL; } #endif return(ret); } static void *ecdh_data_new(void) { return (void *)ECDH_DATA_new_method(NULL); } static void *ecdh_data_dup(void *data) { ECDH_DATA *r = (ECDH_DATA *)data; /* XXX: dummy operation */ if (r == NULL) return NULL; return (void *)ecdh_data_new(); } void ecdh_data_free(void *data) { ECDH_DATA *r = (ECDH_DATA *)data; #ifndef OPENSSL_NO_ENGINE if (r->engine) ENGINE_finish(r->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDH, r, &r->ex_data); OPENSSL_cleanse((void *)r, sizeof(ECDH_DATA)); free(r); } ECDH_DATA *ecdh_check(EC_KEY *key) { ECDH_DATA *ecdh_data; void *data = EC_KEY_get_key_method_data(key, ecdh_data_dup, ecdh_data_free, ecdh_data_free); if (data == NULL) { ecdh_data = (ECDH_DATA *)ecdh_data_new(); if (ecdh_data == NULL) return NULL; data = EC_KEY_insert_key_method_data(key, (void *)ecdh_data, ecdh_data_dup, ecdh_data_free, ecdh_data_free); if (data != NULL) { /* Another thread raced us to install the key_method * data and won. */ ecdh_data_free(ecdh_data); ecdh_data = (ECDH_DATA *)data; } } else ecdh_data = (ECDH_DATA *)data; return ecdh_data; } int ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ECDH, argl, argp, new_func, dup_func, free_func); } int ECDH_set_ex_data(EC_KEY *d, int idx, void *arg) { ECDH_DATA *ecdh; ecdh = ecdh_check(d); if (ecdh == NULL) return 0; return(CRYPTO_set_ex_data(&ecdh->ex_data,idx,arg)); } void *ECDH_get_ex_data(EC_KEY *d, int idx) { ECDH_DATA *ecdh; ecdh = ecdh_check(d); if (ecdh == NULL) return NULL; return(CRYPTO_get_ex_data(&ecdh->ex_data,idx)); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ecdh/ech_err.c0000644000175000017500000000753412360020705020742 0ustar /* $OpenBSD: ech_err.c,v 1.2 2014/06/12 15:49:29 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_ECDH,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_ECDH,0,reason) static ERR_STRING_DATA ECDH_str_functs[]= { {ERR_FUNC(ECDH_F_ECDH_CHECK), "ECDH_CHECK"}, {ERR_FUNC(ECDH_F_ECDH_COMPUTE_KEY), "ECDH_compute_key"}, {ERR_FUNC(ECDH_F_ECDH_DATA_NEW_METHOD), "ECDH_DATA_new_method"}, {0,NULL} }; static ERR_STRING_DATA ECDH_str_reasons[]= { {ERR_REASON(ECDH_R_KDF_FAILED) ,"KDF failed"}, {ERR_REASON(ECDH_R_NON_FIPS_METHOD) ,"non fips method"}, {ERR_REASON(ECDH_R_NO_PRIVATE_VALUE) ,"no private value"}, {ERR_REASON(ECDH_R_POINT_ARITHMETIC_FAILURE),"point arithmetic failure"}, {0,NULL} }; #endif void ERR_load_ECDH_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(ECDH_str_functs[0].error) == NULL) { ERR_load_strings(0,ECDH_str_functs); ERR_load_strings(0,ECDH_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ecdh/ech_locl.h0000644000175000017500000000714712360020705021110 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #ifndef HEADER_ECH_LOCL_H #define HEADER_ECH_LOCL_H #include #ifdef __cplusplus extern "C" { #endif struct ecdh_method { const char *name; int (*compute_key)(void *key, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh, void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); #if 0 int (*init)(EC_KEY *eckey); int (*finish)(EC_KEY *eckey); #endif int flags; char *app_data; }; /* If this flag is set the ECDH method is FIPS compliant and can be used * in FIPS mode. This is set in the validated module method. If an * application sets this flag in its own methods it is its responsibility * to ensure the result is compliant. */ #define ECDH_FLAG_FIPS_METHOD 0x1 typedef struct ecdh_data_st { /* EC_KEY_METH_DATA part */ int (*init)(EC_KEY *); /* method specific part */ ENGINE *engine; int flags; const ECDH_METHOD *meth; CRYPTO_EX_DATA ex_data; } ECDH_DATA; ECDH_DATA *ecdh_check(EC_KEY *); #ifdef __cplusplus } #endif #endif /* HEADER_ECH_LOCL_H */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ecdh/ech_key.c0000644000175000017500000000662612360020705020743 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * The Elliptic Curve Public-Key Crypto Library (ECC Code) included * herein is developed by SUN MICROSYSTEMS, INC., and is contributed * to the OpenSSL project. * * The ECC Code is licensed pursuant to the OpenSSL open source * license provided below. * * The ECDH software is originally written by Douglas Stebila of * Sun Microsystems Laboratories. * */ /* ==================================================================== * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "ech_locl.h" int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *eckey, void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)) { ECDH_DATA *ecdh = ecdh_check(eckey); if (ecdh == NULL) return 0; return ecdh->meth->compute_key(out, outlen, pub_key, eckey, KDF); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/0000755000000000000000000000000012666635521021030 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_alt.c0000644000175000017500000003663712360020706020605 0ustar /* $OpenBSD: v3_alt.c,v 1.20 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ /* ==================================================================== * Copyright (c) 1999-2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include static GENERAL_NAMES *v2i_subject_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); static GENERAL_NAMES *v2i_issuer_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); static int copy_email(X509V3_CTX *ctx, GENERAL_NAMES *gens, int move_p); static int copy_issuer(X509V3_CTX *ctx, GENERAL_NAMES *gens); static int do_othername(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx); static int do_dirname(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx); const X509V3_EXT_METHOD v3_alt[] = { { NID_subject_alt_name, 0, ASN1_ITEM_ref(GENERAL_NAMES), 0, 0, 0, 0, 0, 0, (X509V3_EXT_I2V)i2v_GENERAL_NAMES, (X509V3_EXT_V2I)v2i_subject_alt, NULL, NULL, NULL }, { NID_issuer_alt_name, 0, ASN1_ITEM_ref(GENERAL_NAMES), 0, 0, 0, 0, 0, 0, (X509V3_EXT_I2V)i2v_GENERAL_NAMES, (X509V3_EXT_V2I)v2i_issuer_alt, NULL, NULL, NULL }, { NID_certificate_issuer, 0, ASN1_ITEM_ref(GENERAL_NAMES), 0, 0, 0, 0, 0, 0, (X509V3_EXT_I2V)i2v_GENERAL_NAMES, NULL, NULL, NULL, NULL }, }; STACK_OF(CONF_VALUE) * i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, GENERAL_NAMES *gens, STACK_OF(CONF_VALUE) *ret) { int i; GENERAL_NAME *gen; for (i = 0; i < sk_GENERAL_NAME_num(gens); i++) { gen = sk_GENERAL_NAME_value(gens, i); ret = i2v_GENERAL_NAME(method, gen, ret); } if (!ret) return sk_CONF_VALUE_new_null(); return ret; } STACK_OF(CONF_VALUE) * i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret) { unsigned char *p; char oline[256], htmp[5]; int i; switch (gen->type) { case GEN_OTHERNAME: X509V3_add_value("othername", "", &ret); break; case GEN_X400: X509V3_add_value("X400Name", "", &ret); break; case GEN_EDIPARTY: X509V3_add_value("EdiPartyName", "", &ret); break; case GEN_EMAIL: X509V3_add_value_uchar("email", gen->d.ia5->data, &ret); break; case GEN_DNS: X509V3_add_value_uchar("DNS", gen->d.ia5->data, &ret); break; case GEN_URI: X509V3_add_value_uchar("URI", gen->d.ia5->data, &ret); break; case GEN_DIRNAME: X509_NAME_oneline(gen->d.dirn, oline, 256); X509V3_add_value("DirName", oline, &ret); break; case GEN_IPADD: p = gen->d.ip->data; if (gen->d.ip->length == 4) (void) snprintf(oline, sizeof oline, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); else if (gen->d.ip->length == 16) { oline[0] = 0; for (i = 0; i < 8; i++) { (void) snprintf(htmp, sizeof htmp, "%X", p[0] << 8 | p[1]); p += 2; strlcat(oline, htmp, sizeof(oline)); if (i != 7) strlcat(oline, ":", sizeof(oline)); } } else { X509V3_add_value("IP Address", "", &ret); break; } X509V3_add_value("IP Address", oline, &ret); break; case GEN_RID: i2t_ASN1_OBJECT(oline, 256, gen->d.rid); X509V3_add_value("Registered ID", oline, &ret); break; } return ret; } int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen) { unsigned char *p; int i; switch (gen->type) { case GEN_OTHERNAME: BIO_printf(out, "othername:"); break; case GEN_X400: BIO_printf(out, "X400Name:"); break; case GEN_EDIPARTY: /* Maybe fix this: it is supported now */ BIO_printf(out, "EdiPartyName:"); break; case GEN_EMAIL: BIO_printf(out, "email:%s", gen->d.ia5->data); break; case GEN_DNS: BIO_printf(out, "DNS:%s", gen->d.ia5->data); break; case GEN_URI: BIO_printf(out, "URI:%s", gen->d.ia5->data); break; case GEN_DIRNAME: BIO_printf(out, "DirName: "); X509_NAME_print_ex(out, gen->d.dirn, 0, XN_FLAG_ONELINE); break; case GEN_IPADD: p = gen->d.ip->data; if (gen->d.ip->length == 4) BIO_printf(out, "IP Address:%d.%d.%d.%d", p[0], p[1], p[2], p[3]); else if (gen->d.ip->length == 16) { BIO_printf(out, "IP Address"); for (i = 0; i < 8; i++) { BIO_printf(out, ":%X", p[0] << 8 | p[1]); p += 2; } BIO_puts(out, "\n"); } else { BIO_printf(out, "IP Address:"); break; } break; case GEN_RID: BIO_printf(out, "Registered ID"); i2a_ASN1_OBJECT(out, gen->d.rid); break; } return 1; } static GENERAL_NAMES * v2i_issuer_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { GENERAL_NAMES *gens = NULL; CONF_VALUE *cnf; int i; if (!(gens = sk_GENERAL_NAME_new_null())) { X509V3err(X509V3_F_V2I_ISSUER_ALT, ERR_R_MALLOC_FAILURE); return NULL; } for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { cnf = sk_CONF_VALUE_value(nval, i); if (!name_cmp(cnf->name, "issuer") && cnf->value && !strcmp(cnf->value, "copy")) { if (!copy_issuer(ctx, gens)) goto err; } else { GENERAL_NAME *gen; if (!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) goto err; sk_GENERAL_NAME_push(gens, gen); } } return gens; err: sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); return NULL; } /* Append subject altname of issuer to issuer alt name of subject */ static int copy_issuer(X509V3_CTX *ctx, GENERAL_NAMES *gens) { GENERAL_NAMES *ialt; GENERAL_NAME *gen; X509_EXTENSION *ext; int i; if (ctx && (ctx->flags == CTX_TEST)) return 1; if (!ctx || !ctx->issuer_cert) { X509V3err(X509V3_F_COPY_ISSUER, X509V3_R_NO_ISSUER_DETAILS); goto err; } i = X509_get_ext_by_NID(ctx->issuer_cert, NID_subject_alt_name, -1); if (i < 0) return 1; if (!(ext = X509_get_ext(ctx->issuer_cert, i)) || !(ialt = X509V3_EXT_d2i(ext))) { X509V3err(X509V3_F_COPY_ISSUER, X509V3_R_ISSUER_DECODE_ERROR); goto err; } for (i = 0; i < sk_GENERAL_NAME_num(ialt); i++) { gen = sk_GENERAL_NAME_value(ialt, i); if (!sk_GENERAL_NAME_push(gens, gen)) { X509V3err(X509V3_F_COPY_ISSUER, ERR_R_MALLOC_FAILURE); goto err; } } sk_GENERAL_NAME_free(ialt); return 1; err: return 0; } static GENERAL_NAMES * v2i_subject_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { GENERAL_NAMES *gens = NULL; CONF_VALUE *cnf; int i; if (!(gens = sk_GENERAL_NAME_new_null())) { X509V3err(X509V3_F_V2I_SUBJECT_ALT, ERR_R_MALLOC_FAILURE); return NULL; } for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { cnf = sk_CONF_VALUE_value(nval, i); if (!name_cmp(cnf->name, "email") && cnf->value && !strcmp(cnf->value, "copy")) { if (!copy_email(ctx, gens, 0)) goto err; } else if (!name_cmp(cnf->name, "email") && cnf->value && !strcmp(cnf->value, "move")) { if (!copy_email(ctx, gens, 1)) goto err; } else { GENERAL_NAME *gen; if (!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) goto err; sk_GENERAL_NAME_push(gens, gen); } } return gens; err: sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); return NULL; } /* Copy any email addresses in a certificate or request to * GENERAL_NAMES */ static int copy_email(X509V3_CTX *ctx, GENERAL_NAMES *gens, int move_p) { X509_NAME *nm; ASN1_IA5STRING *email = NULL; X509_NAME_ENTRY *ne; GENERAL_NAME *gen = NULL; int i; if (ctx != NULL && ctx->flags == CTX_TEST) return 1; if (!ctx || (!ctx->subject_cert && !ctx->subject_req)) { X509V3err(X509V3_F_COPY_EMAIL, X509V3_R_NO_SUBJECT_DETAILS); goto err; } /* Find the subject name */ if (ctx->subject_cert) nm = X509_get_subject_name(ctx->subject_cert); else nm = X509_REQ_get_subject_name(ctx->subject_req); /* Now add any email address(es) to STACK */ i = -1; while ((i = X509_NAME_get_index_by_NID(nm, NID_pkcs9_emailAddress, i)) >= 0) { ne = X509_NAME_get_entry(nm, i); email = M_ASN1_IA5STRING_dup(X509_NAME_ENTRY_get_data(ne)); if (move_p) { X509_NAME_delete_entry(nm, i); X509_NAME_ENTRY_free(ne); i--; } if (!email || !(gen = GENERAL_NAME_new())) { X509V3err(X509V3_F_COPY_EMAIL, ERR_R_MALLOC_FAILURE); goto err; } gen->d.ia5 = email; email = NULL; gen->type = GEN_EMAIL; if (!sk_GENERAL_NAME_push(gens, gen)) { X509V3err(X509V3_F_COPY_EMAIL, ERR_R_MALLOC_FAILURE); goto err; } gen = NULL; } return 1; err: GENERAL_NAME_free(gen); M_ASN1_IA5STRING_free(email); return 0; } GENERAL_NAMES * v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { GENERAL_NAME *gen; GENERAL_NAMES *gens = NULL; CONF_VALUE *cnf; int i; if (!(gens = sk_GENERAL_NAME_new_null())) { X509V3err(X509V3_F_V2I_GENERAL_NAMES, ERR_R_MALLOC_FAILURE); return NULL; } for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { cnf = sk_CONF_VALUE_value(nval, i); if (!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) goto err; sk_GENERAL_NAME_push(gens, gen); } return gens; err: sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); return NULL; } GENERAL_NAME * v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, CONF_VALUE *cnf) { return v2i_GENERAL_NAME_ex(NULL, method, ctx, cnf, 0); } GENERAL_NAME * a2i_GENERAL_NAME(GENERAL_NAME *out, const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, int gen_type, char *value, int is_nc) { char is_string = 0; GENERAL_NAME *gen = NULL; if (!value) { X509V3err(X509V3_F_A2I_GENERAL_NAME, X509V3_R_MISSING_VALUE); return NULL; } if (out) gen = out; else { gen = GENERAL_NAME_new(); if (gen == NULL) { X509V3err(X509V3_F_A2I_GENERAL_NAME, ERR_R_MALLOC_FAILURE); return NULL; } } switch (gen_type) { case GEN_URI: case GEN_EMAIL: case GEN_DNS: is_string = 1; break; case GEN_RID: { ASN1_OBJECT *obj; if (!(obj = OBJ_txt2obj(value, 0))) { X509V3err(X509V3_F_A2I_GENERAL_NAME, X509V3_R_BAD_OBJECT); ERR_asprintf_error_data("value=%s", value); goto err; } gen->d.rid = obj; } break; case GEN_IPADD: if (is_nc) gen->d.ip = a2i_IPADDRESS_NC(value); else gen->d.ip = a2i_IPADDRESS(value); if (gen->d.ip == NULL) { X509V3err(X509V3_F_A2I_GENERAL_NAME, X509V3_R_BAD_IP_ADDRESS); ERR_asprintf_error_data("value=%s", value); goto err; } break; case GEN_DIRNAME: if (!do_dirname(gen, value, ctx)) { X509V3err(X509V3_F_A2I_GENERAL_NAME, X509V3_R_DIRNAME_ERROR); goto err; } break; case GEN_OTHERNAME: if (!do_othername(gen, value, ctx)) { X509V3err(X509V3_F_A2I_GENERAL_NAME, X509V3_R_OTHERNAME_ERROR); goto err; } break; default: X509V3err(X509V3_F_A2I_GENERAL_NAME, X509V3_R_UNSUPPORTED_TYPE); goto err; } if (is_string) { if (!(gen->d.ia5 = M_ASN1_IA5STRING_new()) || !ASN1_STRING_set(gen->d.ia5, (unsigned char*)value, strlen(value))) { X509V3err(X509V3_F_A2I_GENERAL_NAME, ERR_R_MALLOC_FAILURE); goto err; } } gen->type = gen_type; return gen; err: if (!out) GENERAL_NAME_free(gen); return NULL; } GENERAL_NAME * v2i_GENERAL_NAME_ex(GENERAL_NAME *out, const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc) { int type; char *name, *value; name = cnf->name; value = cnf->value; if (!value) { X509V3err(X509V3_F_V2I_GENERAL_NAME_EX, X509V3_R_MISSING_VALUE); return NULL; } if (!name_cmp(name, "email")) type = GEN_EMAIL; else if (!name_cmp(name, "URI")) type = GEN_URI; else if (!name_cmp(name, "DNS")) type = GEN_DNS; else if (!name_cmp(name, "RID")) type = GEN_RID; else if (!name_cmp(name, "IP")) type = GEN_IPADD; else if (!name_cmp(name, "dirName")) type = GEN_DIRNAME; else if (!name_cmp(name, "otherName")) type = GEN_OTHERNAME; else { X509V3err(X509V3_F_V2I_GENERAL_NAME_EX, X509V3_R_UNSUPPORTED_OPTION); ERR_asprintf_error_data("name=%s", name); return NULL; } return a2i_GENERAL_NAME(out, method, ctx, type, value, is_nc); } static int do_othername(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx) { char *objtmp = NULL, *p; int objlen; if (!(p = strchr(value, ';'))) return 0; if (!(gen->d.otherName = OTHERNAME_new())) return 0; /* Free this up because we will overwrite it. * no need to free type_id because it is static */ ASN1_TYPE_free(gen->d.otherName->value); if (!(gen->d.otherName->value = ASN1_generate_v3(p + 1, ctx))) return 0; objlen = p - value; objtmp = malloc(objlen + 1); if (objtmp) { strlcpy(objtmp, value, objlen + 1); gen->d.otherName->type_id = OBJ_txt2obj(objtmp, 0); free(objtmp); } else gen->d.otherName->type_id = NULL; if (!gen->d.otherName->type_id) return 0; return 1; } static int do_dirname(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx) { int ret; STACK_OF(CONF_VALUE) *sk; X509_NAME *nm; if (!(nm = X509_NAME_new())) return 0; sk = X509V3_get_section(ctx, value); if (!sk) { X509V3err(X509V3_F_DO_DIRNAME, X509V3_R_SECTION_NOT_FOUND); ERR_asprintf_error_data("section=%s", value); X509_NAME_free(nm); return 0; } /* FIXME: should allow other character types... */ ret = X509V3_NAME_from_section(nm, sk, MBSTRING_ASC); if (!ret) X509_NAME_free(nm); gen->d.dirn = nm; X509V3_section_free(ctx, sk); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/pcy_data.c0000644000175000017500000001040712360020706021164 0ustar /* $OpenBSD: pcy_data.c,v 1.7 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "pcy_int.h" /* Policy Node routines */ void policy_data_free(X509_POLICY_DATA *data) { ASN1_OBJECT_free(data->valid_policy); /* Don't free qualifiers if shared */ if (!(data->flags & POLICY_DATA_FLAG_SHARED_QUALIFIERS)) sk_POLICYQUALINFO_pop_free(data->qualifier_set, POLICYQUALINFO_free); sk_ASN1_OBJECT_pop_free(data->expected_policy_set, ASN1_OBJECT_free); free(data); } /* Create a data based on an existing policy. If 'id' is NULL use the * oid in the policy, otherwise use 'id'. This behaviour covers the two * types of data in RFC3280: data with from a CertificatePolcies extension * and additional data with just the qualifiers of anyPolicy and ID from * another source. */ X509_POLICY_DATA * policy_data_new(POLICYINFO *policy, const ASN1_OBJECT *cid, int crit) { X509_POLICY_DATA *ret; ASN1_OBJECT *id; if (!policy && !cid) return NULL; if (cid) { id = OBJ_dup(cid); if (!id) return NULL; } else id = NULL; ret = malloc(sizeof(X509_POLICY_DATA)); if (!ret) return NULL; ret->expected_policy_set = sk_ASN1_OBJECT_new_null(); if (!ret->expected_policy_set) { free(ret); if (id) ASN1_OBJECT_free(id); return NULL; } if (crit) ret->flags = POLICY_DATA_FLAG_CRITICAL; else ret->flags = 0; if (id) ret->valid_policy = id; else { ret->valid_policy = policy->policyid; policy->policyid = NULL; } if (policy) { ret->qualifier_set = policy->qualifiers; policy->qualifiers = NULL; } else ret->qualifier_set = NULL; return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_ocsp.c0000644000175000017500000002043612360020706020757 0ustar /* $OpenBSD: v3_ocsp.c,v 1.9 2014/07/10 22:45:58 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #ifndef OPENSSL_NO_OCSP #include #include #include #include #include /* OCSP extensions and a couple of CRL entry extensions */ static int i2r_ocsp_crlid(const X509V3_EXT_METHOD *method, void *nonce, BIO *out, int indent); static int i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *nonce, BIO *out, int indent); static int i2r_object(const X509V3_EXT_METHOD *method, void *obj, BIO *out, int indent); static void *ocsp_nonce_new(void); static int i2d_ocsp_nonce(void *a, unsigned char **pp); static void *d2i_ocsp_nonce(void *a, const unsigned char **pp, long length); static void ocsp_nonce_free(void *a); static int i2r_ocsp_nonce(const X509V3_EXT_METHOD *method, void *nonce, BIO *out, int indent); static int i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method, void *nocheck, BIO *out, int indent); static void *s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, const char *str); static int i2r_ocsp_serviceloc(const X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind); const X509V3_EXT_METHOD v3_ocsp_crlid = { NID_id_pkix_OCSP_CrlID, 0, ASN1_ITEM_ref(OCSP_CRLID), 0, 0, 0, 0, 0, 0, 0, 0, i2r_ocsp_crlid, 0, NULL }; const X509V3_EXT_METHOD v3_ocsp_acutoff = { NID_id_pkix_OCSP_archiveCutoff, 0, ASN1_ITEM_ref(ASN1_GENERALIZEDTIME), 0, 0, 0, 0, 0, 0, 0, 0, i2r_ocsp_acutoff, 0, NULL }; const X509V3_EXT_METHOD v3_crl_invdate = { NID_invalidity_date, 0, ASN1_ITEM_ref(ASN1_GENERALIZEDTIME), 0, 0, 0, 0, 0, 0, 0, 0, i2r_ocsp_acutoff, 0, NULL }; const X509V3_EXT_METHOD v3_crl_hold = { NID_hold_instruction_code, 0, ASN1_ITEM_ref(ASN1_OBJECT), 0, 0, 0, 0, 0, 0, 0, 0, i2r_object, 0, NULL }; const X509V3_EXT_METHOD v3_ocsp_nonce = { NID_id_pkix_OCSP_Nonce, 0, NULL, ocsp_nonce_new, ocsp_nonce_free, d2i_ocsp_nonce, i2d_ocsp_nonce, 0, 0, 0, 0, i2r_ocsp_nonce, 0, NULL }; const X509V3_EXT_METHOD v3_ocsp_nocheck = { NID_id_pkix_OCSP_noCheck, 0, ASN1_ITEM_ref(ASN1_NULL), 0, 0, 0, 0, 0, s2i_ocsp_nocheck, 0, 0, i2r_ocsp_nocheck, 0, NULL }; const X509V3_EXT_METHOD v3_ocsp_serviceloc = { NID_id_pkix_OCSP_serviceLocator, 0, ASN1_ITEM_ref(OCSP_SERVICELOC), 0, 0, 0, 0, 0, 0, 0, 0, i2r_ocsp_serviceloc, 0, NULL }; static int i2r_ocsp_crlid(const X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind) { OCSP_CRLID *a = in; if (a->crlUrl) { if (BIO_printf(bp, "%*scrlUrl: ", ind, "") <= 0) goto err; if (!ASN1_STRING_print(bp, (ASN1_STRING*)a->crlUrl)) goto err; if (BIO_write(bp, "\n", 1) <= 0) goto err; } if (a->crlNum) { if (BIO_printf(bp, "%*scrlNum: ", ind, "") <= 0) goto err; if (i2a_ASN1_INTEGER(bp, a->crlNum) <= 0) goto err; if (BIO_write(bp, "\n", 1) <= 0) goto err; } if (a->crlTime) { if (BIO_printf(bp, "%*scrlTime: ", ind, "") <= 0) goto err; if (!ASN1_GENERALIZEDTIME_print(bp, a->crlTime)) goto err; if (BIO_write(bp, "\n", 1) <= 0) goto err; } return 1; err: return 0; } static int i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *cutoff, BIO *bp, int ind) { if (BIO_printf(bp, "%*s", ind, "") <= 0) return 0; if (!ASN1_GENERALIZEDTIME_print(bp, cutoff)) return 0; return 1; } static int i2r_object(const X509V3_EXT_METHOD *method, void *oid, BIO *bp, int ind) { if (BIO_printf(bp, "%*s", ind, "") <= 0) return 0; if (i2a_ASN1_OBJECT(bp, oid) <= 0) return 0; return 1; } /* OCSP nonce. This is needs special treatment because it doesn't have * an ASN1 encoding at all: it just contains arbitrary data. */ static void * ocsp_nonce_new(void) { return ASN1_OCTET_STRING_new(); } static int i2d_ocsp_nonce(void *a, unsigned char **pp) { ASN1_OCTET_STRING *os = a; if (pp) { memcpy(*pp, os->data, os->length); *pp += os->length; } return os->length; } static void * d2i_ocsp_nonce(void *a, const unsigned char **pp, long length) { ASN1_OCTET_STRING *os, **pos; pos = a; if (!pos || !*pos) os = ASN1_OCTET_STRING_new(); else os = *pos; if (!ASN1_OCTET_STRING_set(os, *pp, length)) goto err; *pp += length; if (pos) *pos = os; return os; err: if (os && (!pos || (*pos != os))) M_ASN1_OCTET_STRING_free(os); OCSPerr(OCSP_F_D2I_OCSP_NONCE, ERR_R_MALLOC_FAILURE); return NULL; } static void ocsp_nonce_free(void *a) { M_ASN1_OCTET_STRING_free(a); } static int i2r_ocsp_nonce(const X509V3_EXT_METHOD *method, void *nonce, BIO *out, int indent) { if (BIO_printf(out, "%*s", indent, "") <= 0) return 0; if (i2a_ASN1_STRING(out, nonce, V_ASN1_OCTET_STRING) <= 0) return 0; return 1; } /* Nocheck is just a single NULL. Don't print anything and always set it */ static int i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method, void *nocheck, BIO *out, int indent) { return 1; } static void * s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, const char *str) { return ASN1_NULL_new(); } static int i2r_ocsp_serviceloc(const X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind) { int i; OCSP_SERVICELOC *a = in; ACCESS_DESCRIPTION *ad; if (BIO_printf(bp, "%*sIssuer: ", ind, "") <= 0) goto err; if (X509_NAME_print_ex(bp, a->issuer, 0, XN_FLAG_ONELINE) <= 0) goto err; for (i = 0; i < sk_ACCESS_DESCRIPTION_num(a->locator); i++) { ad = sk_ACCESS_DESCRIPTION_value(a->locator, i); if (BIO_printf(bp, "\n%*s", (2 * ind), "") <= 0) goto err; if (i2a_ASN1_OBJECT(bp, ad->method) <= 0) goto err; if (BIO_puts(bp, " - ") <= 0) goto err; if (GENERAL_NAME_print(bp, ad->location) <= 0) goto err; } return 1; err: return 0; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/pcy_cache.c0000644000175000017500000001676512360020706021333 0ustar /* $OpenBSD: pcy_cache.c,v 1.4 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "pcy_int.h" static int policy_data_cmp(const X509_POLICY_DATA * const *a, const X509_POLICY_DATA * const *b); static int policy_cache_set_int(long *out, ASN1_INTEGER *value); /* Set cache entry according to CertificatePolicies extension. * Note: this destroys the passed CERTIFICATEPOLICIES structure. */ static int policy_cache_create(X509 *x, CERTIFICATEPOLICIES *policies, int crit) { int i; int ret = 0; X509_POLICY_CACHE *cache = x->policy_cache; X509_POLICY_DATA *data = NULL; POLICYINFO *policy; if (sk_POLICYINFO_num(policies) == 0) goto bad_policy; cache->data = sk_X509_POLICY_DATA_new(policy_data_cmp); if (!cache->data) goto bad_policy; for (i = 0; i < sk_POLICYINFO_num(policies); i++) { policy = sk_POLICYINFO_value(policies, i); data = policy_data_new(policy, NULL, crit); if (!data) goto bad_policy; /* Duplicate policy OIDs are illegal: reject if matches * found. */ if (OBJ_obj2nid(data->valid_policy) == NID_any_policy) { if (cache->anyPolicy) { ret = -1; goto bad_policy; } cache->anyPolicy = data; } else if (sk_X509_POLICY_DATA_find(cache->data, data) != -1) { ret = -1; goto bad_policy; } else if (!sk_X509_POLICY_DATA_push(cache->data, data)) goto bad_policy; data = NULL; } ret = 1; bad_policy: if (ret == -1) x->ex_flags |= EXFLAG_INVALID_POLICY; if (data) policy_data_free(data); sk_POLICYINFO_pop_free(policies, POLICYINFO_free); if (ret <= 0) { sk_X509_POLICY_DATA_pop_free(cache->data, policy_data_free); cache->data = NULL; } return ret; } static int policy_cache_new(X509 *x) { X509_POLICY_CACHE *cache; ASN1_INTEGER *ext_any = NULL; POLICY_CONSTRAINTS *ext_pcons = NULL; CERTIFICATEPOLICIES *ext_cpols = NULL; POLICY_MAPPINGS *ext_pmaps = NULL; int i; cache = malloc(sizeof(X509_POLICY_CACHE)); if (!cache) return 0; cache->anyPolicy = NULL; cache->data = NULL; cache->any_skip = -1; cache->explicit_skip = -1; cache->map_skip = -1; x->policy_cache = cache; /* Handle requireExplicitPolicy *first*. Need to process this * even if we don't have any policies. */ ext_pcons = X509_get_ext_d2i(x, NID_policy_constraints, &i, NULL); if (!ext_pcons) { if (i != -1) goto bad_cache; } else { if (!ext_pcons->requireExplicitPolicy && !ext_pcons->inhibitPolicyMapping) goto bad_cache; if (!policy_cache_set_int(&cache->explicit_skip, ext_pcons->requireExplicitPolicy)) goto bad_cache; if (!policy_cache_set_int(&cache->map_skip, ext_pcons->inhibitPolicyMapping)) goto bad_cache; } /* Process CertificatePolicies */ ext_cpols = X509_get_ext_d2i(x, NID_certificate_policies, &i, NULL); /* If no CertificatePolicies extension or problem decoding then * there is no point continuing because the valid policies will be * NULL. */ if (!ext_cpols) { /* If not absent some problem with extension */ if (i != -1) goto bad_cache; return 1; } i = policy_cache_create(x, ext_cpols, i); /* NB: ext_cpols freed by policy_cache_set_policies */ if (i <= 0) return i; ext_pmaps = X509_get_ext_d2i(x, NID_policy_mappings, &i, NULL); if (!ext_pmaps) { /* If not absent some problem with extension */ if (i != -1) goto bad_cache; } else { i = policy_cache_set_mapping(x, ext_pmaps); if (i <= 0) goto bad_cache; } ext_any = X509_get_ext_d2i(x, NID_inhibit_any_policy, &i, NULL); if (!ext_any) { if (i != -1) goto bad_cache; } else if (!policy_cache_set_int(&cache->any_skip, ext_any)) goto bad_cache; if (0) { bad_cache: x->ex_flags |= EXFLAG_INVALID_POLICY; } if (ext_pcons) POLICY_CONSTRAINTS_free(ext_pcons); if (ext_any) ASN1_INTEGER_free(ext_any); return 1; } void policy_cache_free(X509_POLICY_CACHE *cache) { if (!cache) return; if (cache->anyPolicy) policy_data_free(cache->anyPolicy); if (cache->data) sk_X509_POLICY_DATA_pop_free(cache->data, policy_data_free); free(cache); } const X509_POLICY_CACHE * policy_cache_set(X509 *x) { if (x->policy_cache == NULL) { CRYPTO_w_lock(CRYPTO_LOCK_X509); policy_cache_new(x); CRYPTO_w_unlock(CRYPTO_LOCK_X509); } return x->policy_cache; } X509_POLICY_DATA * policy_cache_find_data(const X509_POLICY_CACHE *cache, const ASN1_OBJECT *id) { int idx; X509_POLICY_DATA tmp; tmp.valid_policy = (ASN1_OBJECT *)id; idx = sk_X509_POLICY_DATA_find(cache->data, &tmp); if (idx == -1) return NULL; return sk_X509_POLICY_DATA_value(cache->data, idx); } static int policy_data_cmp(const X509_POLICY_DATA * const *a, const X509_POLICY_DATA * const *b) { return OBJ_cmp((*a)->valid_policy, (*b)->valid_policy); } static int policy_cache_set_int(long *out, ASN1_INTEGER *value) { if (value == NULL) return 1; if (value->type == V_ASN1_NEG_INTEGER) return 0; *out = ASN1_INTEGER_get(value); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_prn.c0000644000175000017500000001514412360020706020612 0ustar /* $OpenBSD: v3_prn.c,v 1.16 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* X509 v3 extension utilities */ #include #include #include /* Extension printing routines */ static int unknown_ext_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent, int supported); /* Print out a name+value stack */ void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, int ml) { int i; CONF_VALUE *nval; if (!val) return; if (!ml || !sk_CONF_VALUE_num(val)) { BIO_printf(out, "%*s", indent, ""); if (!sk_CONF_VALUE_num(val)) BIO_puts(out, "\n"); } for (i = 0; i < sk_CONF_VALUE_num(val); i++) { if (ml) BIO_printf(out, "%*s", indent, ""); else if (i > 0) BIO_printf(out, ", "); nval = sk_CONF_VALUE_value(val, i); if (!nval->name) BIO_puts(out, nval->value); else if (!nval->value) BIO_puts(out, nval->name); else BIO_printf(out, "%s:%s", nval->name, nval->value); if (ml) BIO_puts(out, "\n"); } } /* Main routine: print out a general extension */ int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent) { void *ext_str = NULL; char *value = NULL; const unsigned char *p; const X509V3_EXT_METHOD *method; STACK_OF(CONF_VALUE) *nval = NULL; int ok = 1; if (!(method = X509V3_EXT_get(ext))) return unknown_ext_print(out, ext, flag, indent, 0); p = ext->value->data; if (method->it) ext_str = ASN1_item_d2i(NULL, &p, ext->value->length, ASN1_ITEM_ptr(method->it)); else ext_str = method->d2i(NULL, &p, ext->value->length); if (!ext_str) return unknown_ext_print(out, ext, flag, indent, 1); if (method->i2s) { if (!(value = method->i2s(method, ext_str))) { ok = 0; goto err; } BIO_printf(out, "%*s%s", indent, "", value); } else if (method->i2v) { if (!(nval = method->i2v(method, ext_str, NULL))) { ok = 0; goto err; } X509V3_EXT_val_prn(out, nval, indent, method->ext_flags & X509V3_EXT_MULTILINE); } else if (method->i2r) { if (!method->i2r(method, ext_str, out, indent)) ok = 0; } else ok = 0; err: sk_CONF_VALUE_pop_free(nval, X509V3_conf_free); free(value); if (method->it) ASN1_item_free(ext_str, ASN1_ITEM_ptr(method->it)); else method->ext_free(ext_str); return ok; } int X509V3_extensions_print(BIO *bp, char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent) { int i, j; if (sk_X509_EXTENSION_num(exts) <= 0) return 1; if (title) { BIO_printf(bp, "%*s%s:\n",indent, "", title); indent += 4; } for (i = 0; i < sk_X509_EXTENSION_num(exts); i++) { ASN1_OBJECT *obj; X509_EXTENSION *ex; ex = sk_X509_EXTENSION_value(exts, i); if (indent && BIO_printf(bp, "%*s",indent, "") <= 0) return 0; obj = X509_EXTENSION_get_object(ex); i2a_ASN1_OBJECT(bp, obj); j = X509_EXTENSION_get_critical(ex); if (BIO_printf(bp, ": %s\n",j?"critical":"") <= 0) return 0; if (!X509V3_EXT_print(bp, ex, flag, indent + 4)) { BIO_printf(bp, "%*s", indent + 4, ""); M_ASN1_OCTET_STRING_print(bp, ex->value); } if (BIO_write(bp, "\n",1) <= 0) return 0; } return 1; } static int unknown_ext_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent, int supported) { switch (flag & X509V3_EXT_UNKNOWN_MASK) { case X509V3_EXT_DEFAULT: return 0; case X509V3_EXT_ERROR_UNKNOWN: if (supported) BIO_printf(out, "%*s", indent, ""); else BIO_printf(out, "%*s", indent, ""); return 1; case X509V3_EXT_PARSE_UNKNOWN: return ASN1_parse_dump(out, ext->value->data, ext->value->length, indent, -1); case X509V3_EXT_DUMP_UNKNOWN: return BIO_dump_indent(out, (char *)ext->value->data, ext->value->length, indent); default: return 1; } } int X509V3_EXT_print_fp(FILE *fp, X509_EXTENSION *ext, int flag, int indent) { BIO *bio_tmp; int ret; if (!(bio_tmp = BIO_new_fp(fp, BIO_NOCLOSE))) return 0; ret = X509V3_EXT_print(bio_tmp, ext, flag, indent); BIO_free(bio_tmp); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3err.c0000644000175000017500000003023212360020706020437 0ustar /* $OpenBSD: v3err.c,v 1.10 2014/06/12 15:49:31 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_X509V3,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_X509V3,0,reason) static ERR_STRING_DATA X509V3_str_functs[] = { {ERR_FUNC(X509V3_F_A2I_GENERAL_NAME), "A2I_GENERAL_NAME"}, {ERR_FUNC(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE), "ASIDENTIFIERCHOICE_CANONIZE"}, {ERR_FUNC(X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL), "ASIDENTIFIERCHOICE_IS_CANONICAL"}, {ERR_FUNC(X509V3_F_COPY_EMAIL), "COPY_EMAIL"}, {ERR_FUNC(X509V3_F_COPY_ISSUER), "COPY_ISSUER"}, {ERR_FUNC(X509V3_F_DO_DIRNAME), "DO_DIRNAME"}, {ERR_FUNC(X509V3_F_DO_EXT_CONF), "DO_EXT_CONF"}, {ERR_FUNC(X509V3_F_DO_EXT_I2D), "DO_EXT_I2D"}, {ERR_FUNC(X509V3_F_DO_EXT_NCONF), "DO_EXT_NCONF"}, {ERR_FUNC(X509V3_F_DO_I2V_NAME_CONSTRAINTS), "DO_I2V_NAME_CONSTRAINTS"}, {ERR_FUNC(X509V3_F_GNAMES_FROM_SECTNAME), "GNAMES_FROM_SECTNAME"}, {ERR_FUNC(X509V3_F_HEX_TO_STRING), "hex_to_string"}, {ERR_FUNC(X509V3_F_I2S_ASN1_ENUMERATED), "i2s_ASN1_ENUMERATED"}, {ERR_FUNC(X509V3_F_I2S_ASN1_IA5STRING), "I2S_ASN1_IA5STRING"}, {ERR_FUNC(X509V3_F_I2S_ASN1_INTEGER), "i2s_ASN1_INTEGER"}, {ERR_FUNC(X509V3_F_I2V_AUTHORITY_INFO_ACCESS), "I2V_AUTHORITY_INFO_ACCESS"}, {ERR_FUNC(X509V3_F_NOTICE_SECTION), "NOTICE_SECTION"}, {ERR_FUNC(X509V3_F_NREF_NOS), "NREF_NOS"}, {ERR_FUNC(X509V3_F_POLICY_SECTION), "POLICY_SECTION"}, {ERR_FUNC(X509V3_F_PROCESS_PCI_VALUE), "PROCESS_PCI_VALUE"}, {ERR_FUNC(X509V3_F_R2I_CERTPOL), "R2I_CERTPOL"}, {ERR_FUNC(X509V3_F_R2I_PCI), "R2I_PCI"}, {ERR_FUNC(X509V3_F_S2I_ASN1_IA5STRING), "S2I_ASN1_IA5STRING"}, {ERR_FUNC(X509V3_F_S2I_ASN1_INTEGER), "s2i_ASN1_INTEGER"}, {ERR_FUNC(X509V3_F_S2I_ASN1_OCTET_STRING), "s2i_ASN1_OCTET_STRING"}, {ERR_FUNC(X509V3_F_S2I_ASN1_SKEY_ID), "S2I_ASN1_SKEY_ID"}, {ERR_FUNC(X509V3_F_S2I_SKEY_ID), "S2I_SKEY_ID"}, {ERR_FUNC(X509V3_F_SET_DIST_POINT_NAME), "SET_DIST_POINT_NAME"}, {ERR_FUNC(X509V3_F_STRING_TO_HEX), "string_to_hex"}, {ERR_FUNC(X509V3_F_SXNET_ADD_ID_ASC), "SXNET_add_id_asc"}, {ERR_FUNC(X509V3_F_SXNET_ADD_ID_INTEGER), "SXNET_add_id_INTEGER"}, {ERR_FUNC(X509V3_F_SXNET_ADD_ID_ULONG), "SXNET_add_id_ulong"}, {ERR_FUNC(X509V3_F_SXNET_GET_ID_ASC), "SXNET_get_id_asc"}, {ERR_FUNC(X509V3_F_SXNET_GET_ID_ULONG), "SXNET_get_id_ulong"}, {ERR_FUNC(X509V3_F_V2I_ASIDENTIFIERS), "V2I_ASIDENTIFIERS"}, {ERR_FUNC(X509V3_F_V2I_ASN1_BIT_STRING), "v2i_ASN1_BIT_STRING"}, {ERR_FUNC(X509V3_F_V2I_AUTHORITY_INFO_ACCESS), "V2I_AUTHORITY_INFO_ACCESS"}, {ERR_FUNC(X509V3_F_V2I_AUTHORITY_KEYID), "V2I_AUTHORITY_KEYID"}, {ERR_FUNC(X509V3_F_V2I_BASIC_CONSTRAINTS), "V2I_BASIC_CONSTRAINTS"}, {ERR_FUNC(X509V3_F_V2I_CRLD), "V2I_CRLD"}, {ERR_FUNC(X509V3_F_V2I_EXTENDED_KEY_USAGE), "V2I_EXTENDED_KEY_USAGE"}, {ERR_FUNC(X509V3_F_V2I_GENERAL_NAMES), "v2i_GENERAL_NAMES"}, {ERR_FUNC(X509V3_F_V2I_GENERAL_NAME_EX), "v2i_GENERAL_NAME_ex"}, {ERR_FUNC(X509V3_F_V2I_IDP), "V2I_IDP"}, {ERR_FUNC(X509V3_F_V2I_IPADDRBLOCKS), "V2I_IPADDRBLOCKS"}, {ERR_FUNC(X509V3_F_V2I_ISSUER_ALT), "V2I_ISSUER_ALT"}, {ERR_FUNC(X509V3_F_V2I_NAME_CONSTRAINTS), "V2I_NAME_CONSTRAINTS"}, {ERR_FUNC(X509V3_F_V2I_POLICY_CONSTRAINTS), "V2I_POLICY_CONSTRAINTS"}, {ERR_FUNC(X509V3_F_V2I_POLICY_MAPPINGS), "V2I_POLICY_MAPPINGS"}, {ERR_FUNC(X509V3_F_V2I_SUBJECT_ALT), "V2I_SUBJECT_ALT"}, {ERR_FUNC(X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL), "V3_ADDR_VALIDATE_PATH_INTERNAL"}, {ERR_FUNC(X509V3_F_V3_GENERIC_EXTENSION), "V3_GENERIC_EXTENSION"}, {ERR_FUNC(X509V3_F_X509V3_ADD1_I2D), "X509V3_add1_i2d"}, {ERR_FUNC(X509V3_F_X509V3_ADD_VALUE), "X509V3_add_value"}, {ERR_FUNC(X509V3_F_X509V3_EXT_ADD), "X509V3_EXT_add"}, {ERR_FUNC(X509V3_F_X509V3_EXT_ADD_ALIAS), "X509V3_EXT_add_alias"}, {ERR_FUNC(X509V3_F_X509V3_EXT_CONF), "X509V3_EXT_conf"}, {ERR_FUNC(X509V3_F_X509V3_EXT_I2D), "X509V3_EXT_i2d"}, {ERR_FUNC(X509V3_F_X509V3_EXT_NCONF), "X509V3_EXT_nconf"}, {ERR_FUNC(X509V3_F_X509V3_GET_SECTION), "X509V3_get_section"}, {ERR_FUNC(X509V3_F_X509V3_GET_STRING), "X509V3_get_string"}, {ERR_FUNC(X509V3_F_X509V3_GET_VALUE_BOOL), "X509V3_get_value_bool"}, {ERR_FUNC(X509V3_F_X509V3_PARSE_LIST), "X509V3_parse_list"}, {ERR_FUNC(X509V3_F_X509_PURPOSE_ADD), "X509_PURPOSE_add"}, {ERR_FUNC(X509V3_F_X509_PURPOSE_SET), "X509_PURPOSE_set"}, {0, NULL} }; static ERR_STRING_DATA X509V3_str_reasons[] = { {ERR_REASON(X509V3_R_BAD_IP_ADDRESS) , "bad ip address"}, {ERR_REASON(X509V3_R_BAD_OBJECT) , "bad object"}, {ERR_REASON(X509V3_R_BN_DEC2BN_ERROR) , "bn dec2bn error"}, {ERR_REASON(X509V3_R_BN_TO_ASN1_INTEGER_ERROR), "bn to asn1 integer error"}, {ERR_REASON(X509V3_R_DIRNAME_ERROR) , "dirname error"}, {ERR_REASON(X509V3_R_DISTPOINT_ALREADY_SET), "distpoint already set"}, {ERR_REASON(X509V3_R_DUPLICATE_ZONE_ID) , "duplicate zone id"}, {ERR_REASON(X509V3_R_ERROR_CONVERTING_ZONE), "error converting zone"}, {ERR_REASON(X509V3_R_ERROR_CREATING_EXTENSION), "error creating extension"}, {ERR_REASON(X509V3_R_ERROR_IN_EXTENSION) , "error in extension"}, {ERR_REASON(X509V3_R_EXPECTED_A_SECTION_NAME), "expected a section name"}, {ERR_REASON(X509V3_R_EXTENSION_EXISTS) , "extension exists"}, {ERR_REASON(X509V3_R_EXTENSION_NAME_ERROR), "extension name error"}, {ERR_REASON(X509V3_R_EXTENSION_NOT_FOUND), "extension not found"}, {ERR_REASON(X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED), "extension setting not supported"}, {ERR_REASON(X509V3_R_EXTENSION_VALUE_ERROR), "extension value error"}, {ERR_REASON(X509V3_R_ILLEGAL_EMPTY_EXTENSION), "illegal empty extension"}, {ERR_REASON(X509V3_R_ILLEGAL_HEX_DIGIT) , "illegal hex digit"}, {ERR_REASON(X509V3_R_INCORRECT_POLICY_SYNTAX_TAG), "incorrect policy syntax tag"}, {ERR_REASON(X509V3_R_INVALID_MULTIPLE_RDNS), "invalid multiple rdns"}, {ERR_REASON(X509V3_R_INVALID_ASNUMBER) , "invalid asnumber"}, {ERR_REASON(X509V3_R_INVALID_ASRANGE) , "invalid asrange"}, {ERR_REASON(X509V3_R_INVALID_BOOLEAN_STRING), "invalid boolean string"}, {ERR_REASON(X509V3_R_INVALID_EXTENSION_STRING), "invalid extension string"}, {ERR_REASON(X509V3_R_INVALID_INHERITANCE), "invalid inheritance"}, {ERR_REASON(X509V3_R_INVALID_IPADDRESS) , "invalid ipaddress"}, {ERR_REASON(X509V3_R_INVALID_NAME) , "invalid name"}, {ERR_REASON(X509V3_R_INVALID_NULL_ARGUMENT), "invalid null argument"}, {ERR_REASON(X509V3_R_INVALID_NULL_NAME) , "invalid null name"}, {ERR_REASON(X509V3_R_INVALID_NULL_VALUE) , "invalid null value"}, {ERR_REASON(X509V3_R_INVALID_NUMBER) , "invalid number"}, {ERR_REASON(X509V3_R_INVALID_NUMBERS) , "invalid numbers"}, {ERR_REASON(X509V3_R_INVALID_OBJECT_IDENTIFIER), "invalid object identifier"}, {ERR_REASON(X509V3_R_INVALID_OPTION) , "invalid option"}, {ERR_REASON(X509V3_R_INVALID_POLICY_IDENTIFIER), "invalid policy identifier"}, {ERR_REASON(X509V3_R_INVALID_PROXY_POLICY_SETTING), "invalid proxy policy setting"}, {ERR_REASON(X509V3_R_INVALID_PURPOSE) , "invalid purpose"}, {ERR_REASON(X509V3_R_INVALID_SAFI) , "invalid safi"}, {ERR_REASON(X509V3_R_INVALID_SECTION) , "invalid section"}, {ERR_REASON(X509V3_R_INVALID_SYNTAX) , "invalid syntax"}, {ERR_REASON(X509V3_R_ISSUER_DECODE_ERROR), "issuer decode error"}, {ERR_REASON(X509V3_R_MISSING_VALUE) , "missing value"}, {ERR_REASON(X509V3_R_NEED_ORGANIZATION_AND_NUMBERS), "need organization and numbers"}, {ERR_REASON(X509V3_R_NO_CONFIG_DATABASE) , "no config database"}, {ERR_REASON(X509V3_R_NO_ISSUER_CERTIFICATE), "no issuer certificate"}, {ERR_REASON(X509V3_R_NO_ISSUER_DETAILS) , "no issuer details"}, {ERR_REASON(X509V3_R_NO_POLICY_IDENTIFIER), "no policy identifier"}, {ERR_REASON(X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED), "no proxy cert policy language defined"}, {ERR_REASON(X509V3_R_NO_PUBLIC_KEY) , "no public key"}, {ERR_REASON(X509V3_R_NO_SUBJECT_DETAILS) , "no subject details"}, {ERR_REASON(X509V3_R_ODD_NUMBER_OF_DIGITS), "odd number of digits"}, {ERR_REASON(X509V3_R_OPERATION_NOT_DEFINED), "operation not defined"}, {ERR_REASON(X509V3_R_OTHERNAME_ERROR) , "othername error"}, {ERR_REASON(X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED), "policy language already defined"}, {ERR_REASON(X509V3_R_POLICY_PATH_LENGTH) , "policy path length"}, {ERR_REASON(X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED), "policy path length already defined"}, {ERR_REASON(X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED), "policy syntax not currently supported"}, {ERR_REASON(X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY), "policy when proxy language requires no policy"}, {ERR_REASON(X509V3_R_SECTION_NOT_FOUND) , "section not found"}, {ERR_REASON(X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS), "unable to get issuer details"}, {ERR_REASON(X509V3_R_UNABLE_TO_GET_ISSUER_KEYID), "unable to get issuer keyid"}, {ERR_REASON(X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT), "unknown bit string argument"}, {ERR_REASON(X509V3_R_UNKNOWN_EXTENSION) , "unknown extension"}, {ERR_REASON(X509V3_R_UNKNOWN_EXTENSION_NAME), "unknown extension name"}, {ERR_REASON(X509V3_R_UNKNOWN_OPTION) , "unknown option"}, {ERR_REASON(X509V3_R_UNSUPPORTED_OPTION) , "unsupported option"}, {ERR_REASON(X509V3_R_UNSUPPORTED_TYPE) , "unsupported type"}, {ERR_REASON(X509V3_R_USER_TOO_LONG) , "user too long"}, {0, NULL} }; #endif void ERR_load_X509V3_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(X509V3_str_functs[0].error) == NULL) { ERR_load_strings(0, X509V3_str_functs); ERR_load_strings(0, X509V3_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_lib.c0000644000175000017500000002241012360020706020553 0ustar /* $OpenBSD: v3_lib.c,v 1.12 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* X509 v3 extension utilities */ #include #include #include #include #include "ext_dat.h" static STACK_OF(X509V3_EXT_METHOD) *ext_list = NULL; static int ext_cmp(const X509V3_EXT_METHOD * const *a, const X509V3_EXT_METHOD * const *b); static void ext_list_free(X509V3_EXT_METHOD *ext); int X509V3_EXT_add(X509V3_EXT_METHOD *ext) { if (!ext_list && !(ext_list = sk_X509V3_EXT_METHOD_new(ext_cmp))) { X509V3err(X509V3_F_X509V3_EXT_ADD, ERR_R_MALLOC_FAILURE); return 0; } if (!sk_X509V3_EXT_METHOD_push(ext_list, ext)) { X509V3err(X509V3_F_X509V3_EXT_ADD, ERR_R_MALLOC_FAILURE); return 0; } return 1; } static int ext_cmp(const X509V3_EXT_METHOD * const *a, const X509V3_EXT_METHOD * const *b) { return ((*a)->ext_nid - (*b)->ext_nid); } DECLARE_OBJ_BSEARCH_CMP_FN(const X509V3_EXT_METHOD *, const X509V3_EXT_METHOD *, ext); IMPLEMENT_OBJ_BSEARCH_CMP_FN(const X509V3_EXT_METHOD *, const X509V3_EXT_METHOD *, ext); const X509V3_EXT_METHOD * X509V3_EXT_get_nid(int nid) { X509V3_EXT_METHOD tmp; const X509V3_EXT_METHOD *t = &tmp, * const *ret; int idx; if (nid < 0) return NULL; tmp.ext_nid = nid; ret = OBJ_bsearch_ext(&t, standard_exts, STANDARD_EXTENSION_COUNT); if (ret) return *ret; if (!ext_list) return NULL; idx = sk_X509V3_EXT_METHOD_find(ext_list, &tmp); if (idx == -1) return NULL; return sk_X509V3_EXT_METHOD_value(ext_list, idx); } const X509V3_EXT_METHOD * X509V3_EXT_get(X509_EXTENSION *ext) { int nid; if ((nid = OBJ_obj2nid(ext->object)) == NID_undef) return NULL; return X509V3_EXT_get_nid(nid); } int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist) { for (; extlist->ext_nid!=-1; extlist++) if (!X509V3_EXT_add(extlist)) return 0; return 1; } int X509V3_EXT_add_alias(int nid_to, int nid_from) { const X509V3_EXT_METHOD *ext; X509V3_EXT_METHOD *tmpext; if (!(ext = X509V3_EXT_get_nid(nid_from))) { X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS, X509V3_R_EXTENSION_NOT_FOUND); return 0; } if (!(tmpext = malloc(sizeof(X509V3_EXT_METHOD)))) { X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS, ERR_R_MALLOC_FAILURE); return 0; } *tmpext = *ext; tmpext->ext_nid = nid_to; tmpext->ext_flags |= X509V3_EXT_DYNAMIC; return X509V3_EXT_add(tmpext); } void X509V3_EXT_cleanup(void) { sk_X509V3_EXT_METHOD_pop_free(ext_list, ext_list_free); ext_list = NULL; } static void ext_list_free(X509V3_EXT_METHOD *ext) { if (ext->ext_flags & X509V3_EXT_DYNAMIC) free(ext); } /* Legacy function: we don't need to add standard extensions * any more because they are now kept in ext_dat.h. */ int X509V3_add_standard_extensions(void) { return 1; } /* Return an extension internal structure */ void * X509V3_EXT_d2i(X509_EXTENSION *ext) { const X509V3_EXT_METHOD *method; const unsigned char *p; if (!(method = X509V3_EXT_get(ext))) return NULL; p = ext->value->data; if (method->it) return ASN1_item_d2i(NULL, &p, ext->value->length, ASN1_ITEM_ptr(method->it)); return method->d2i(NULL, &p, ext->value->length); } /* Get critical flag and decoded version of extension from a NID. * The "idx" variable returns the last found extension and can * be used to retrieve multiple extensions of the same NID. * However multiple extensions with the same NID is usually * due to a badly encoded certificate so if idx is NULL we * choke if multiple extensions exist. * The "crit" variable is set to the critical value. * The return value is the decoded extension or NULL on * error. The actual error can have several different causes, * the value of *crit reflects the cause: * >= 0, extension found but not decoded (reflects critical value). * -1 extension not found. * -2 extension occurs more than once. */ void * X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx) { int lastpos, i; X509_EXTENSION *ex, *found_ex = NULL; if (!x) { if (idx) *idx = -1; if (crit) *crit = -1; return NULL; } if (idx) lastpos = *idx + 1; else lastpos = 0; if (lastpos < 0) lastpos = 0; for (i = lastpos; i < sk_X509_EXTENSION_num(x); i++) { ex = sk_X509_EXTENSION_value(x, i); if (OBJ_obj2nid(ex->object) == nid) { if (idx) { *idx = i; found_ex = ex; break; } else if (found_ex) { /* Found more than one */ if (crit) *crit = -2; return NULL; } found_ex = ex; } } if (found_ex) { /* Found it */ if (crit) *crit = X509_EXTENSION_get_critical(found_ex); return X509V3_EXT_d2i(found_ex); } /* Extension not found */ if (idx) *idx = -1; if (crit) *crit = -1; return NULL; } /* This function is a general extension append, replace and delete utility. * The precise operation is governed by the 'flags' value. The 'crit' and * 'value' arguments (if relevant) are the extensions internal structure. */ int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, int crit, unsigned long flags) { int extidx = -1; int errcode; X509_EXTENSION *ext, *extmp; unsigned long ext_op = flags & X509V3_ADD_OP_MASK; /* If appending we don't care if it exists, otherwise * look for existing extension. */ if (ext_op != X509V3_ADD_APPEND) extidx = X509v3_get_ext_by_NID(*x, nid, -1); /* See if extension exists */ if (extidx >= 0) { /* If keep existing, nothing to do */ if (ext_op == X509V3_ADD_KEEP_EXISTING) return 1; /* If default then its an error */ if (ext_op == X509V3_ADD_DEFAULT) { errcode = X509V3_R_EXTENSION_EXISTS; goto err; } /* If delete, just delete it */ if (ext_op == X509V3_ADD_DELETE) { if (!sk_X509_EXTENSION_delete(*x, extidx)) return -1; return 1; } } else { /* If replace existing or delete, error since * extension must exist */ if ((ext_op == X509V3_ADD_REPLACE_EXISTING) || (ext_op == X509V3_ADD_DELETE)) { errcode = X509V3_R_EXTENSION_NOT_FOUND; goto err; } } /* If we get this far then we have to create an extension: * could have some flags for alternative encoding schemes... */ ext = X509V3_EXT_i2d(nid, crit, value); if (!ext) { X509V3err(X509V3_F_X509V3_ADD1_I2D, X509V3_R_ERROR_CREATING_EXTENSION); return 0; } /* If extension exists replace it.. */ if (extidx >= 0) { extmp = sk_X509_EXTENSION_value(*x, extidx); X509_EXTENSION_free(extmp); if (!sk_X509_EXTENSION_set(*x, extidx, ext)) return -1; return 1; } if (!*x && !(*x = sk_X509_EXTENSION_new_null())) return -1; if (!sk_X509_EXTENSION_push(*x, ext)) return -1; return 1; err: if (!(flags & X509V3_ADD_SILENT)) X509V3err(X509V3_F_X509V3_ADD1_I2D, errcode); return 0; } IMPLEMENT_STACK_OF(X509V3_EXT_METHOD) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/pcy_node.c0000644000175000017500000001264112360020706021202 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include "pcy_int.h" static int node_cmp(const X509_POLICY_NODE * const *a, const X509_POLICY_NODE * const *b) { return OBJ_cmp((*a)->data->valid_policy, (*b)->data->valid_policy); } STACK_OF(X509_POLICY_NODE) *policy_node_cmp_new(void) { return sk_X509_POLICY_NODE_new(node_cmp); } X509_POLICY_NODE * tree_find_sk(STACK_OF(X509_POLICY_NODE) *nodes, const ASN1_OBJECT *id) { X509_POLICY_DATA n; X509_POLICY_NODE l; int idx; n.valid_policy = (ASN1_OBJECT *)id; l.data = &n; idx = sk_X509_POLICY_NODE_find(nodes, &l); if (idx == -1) return NULL; return sk_X509_POLICY_NODE_value(nodes, idx); } X509_POLICY_NODE * level_find_node(const X509_POLICY_LEVEL *level, const X509_POLICY_NODE *parent, const ASN1_OBJECT *id) { X509_POLICY_NODE *node; int i; for (i = 0; i < sk_X509_POLICY_NODE_num(level->nodes); i++) { node = sk_X509_POLICY_NODE_value(level->nodes, i); if (node->parent == parent) { if (!OBJ_cmp(node->data->valid_policy, id)) return node; } } return NULL; } X509_POLICY_NODE * level_add_node(X509_POLICY_LEVEL *level, const X509_POLICY_DATA *data, X509_POLICY_NODE *parent, X509_POLICY_TREE *tree) { X509_POLICY_NODE *node; node = malloc(sizeof(X509_POLICY_NODE)); if (!node) return NULL; node->data = data; node->parent = parent; node->nchild = 0; if (level) { if (OBJ_obj2nid(data->valid_policy) == NID_any_policy) { if (level->anyPolicy) goto node_error; level->anyPolicy = node; } else { if (!level->nodes) level->nodes = policy_node_cmp_new(); if (!level->nodes) goto node_error; if (!sk_X509_POLICY_NODE_push(level->nodes, node)) goto node_error; } } if (tree) { if (!tree->extra_data) tree->extra_data = sk_X509_POLICY_DATA_new_null(); if (!tree->extra_data) goto node_error; if (!sk_X509_POLICY_DATA_push(tree->extra_data, data)) goto node_error; } if (parent) parent->nchild++; return node; node_error: policy_node_free(node); return 0; } void policy_node_free(X509_POLICY_NODE *node) { free(node); } /* See if a policy node matches a policy OID. If mapping enabled look through * expected policy set otherwise just valid policy. */ int policy_node_match(const X509_POLICY_LEVEL *lvl, const X509_POLICY_NODE *node, const ASN1_OBJECT *oid) { int i; ASN1_OBJECT *policy_oid; const X509_POLICY_DATA *x = node->data; if ((lvl->flags & X509_V_FLAG_INHIBIT_MAP) || !(x->flags & POLICY_DATA_FLAG_MAP_MASK)) { if (!OBJ_cmp(x->valid_policy, oid)) return 1; return 0; } for (i = 0; i < sk_ASN1_OBJECT_num(x->expected_policy_set); i++) { policy_oid = sk_ASN1_OBJECT_value(x->expected_policy_set, i); if (!OBJ_cmp(policy_oid, oid)) return 1; } return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/pcy_int.h0000644000175000017500000001547312360020706021062 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ typedef struct X509_POLICY_DATA_st X509_POLICY_DATA; DECLARE_STACK_OF(X509_POLICY_DATA) /* Internal structures */ /* This structure and the field names correspond to the Policy 'node' of * RFC3280. NB this structure contains no pointers to parent or child * data: X509_POLICY_NODE contains that. This means that the main policy data * can be kept static and cached with the certificate. */ struct X509_POLICY_DATA_st { unsigned int flags; /* Policy OID and qualifiers for this data */ ASN1_OBJECT *valid_policy; STACK_OF(POLICYQUALINFO) *qualifier_set; STACK_OF(ASN1_OBJECT) *expected_policy_set; }; /* X509_POLICY_DATA flags values */ /* This flag indicates the structure has been mapped using a policy mapping * extension. If policy mapping is not active its references get deleted. */ #define POLICY_DATA_FLAG_MAPPED 0x1 /* This flag indicates the data doesn't correspond to a policy in Certificate * Policies: it has been mapped to any policy. */ #define POLICY_DATA_FLAG_MAPPED_ANY 0x2 /* AND with flags to see if any mapping has occurred */ #define POLICY_DATA_FLAG_MAP_MASK 0x3 /* qualifiers are shared and shouldn't be freed */ #define POLICY_DATA_FLAG_SHARED_QUALIFIERS 0x4 /* Parent node is an extra node and should be freed */ #define POLICY_DATA_FLAG_EXTRA_NODE 0x8 /* Corresponding CertificatePolicies is critical */ #define POLICY_DATA_FLAG_CRITICAL 0x10 /* This structure is cached with a certificate */ struct X509_POLICY_CACHE_st { /* anyPolicy data or NULL if no anyPolicy */ X509_POLICY_DATA *anyPolicy; /* other policy data */ STACK_OF(X509_POLICY_DATA) *data; /* If InhibitAnyPolicy present this is its value or -1 if absent. */ long any_skip; /* If policyConstraints and requireExplicitPolicy present this is its * value or -1 if absent. */ long explicit_skip; /* If policyConstraints and policyMapping present this is its * value or -1 if absent. */ long map_skip; }; /*#define POLICY_CACHE_FLAG_CRITICAL POLICY_DATA_FLAG_CRITICAL*/ /* This structure represents the relationship between nodes */ struct X509_POLICY_NODE_st { /* node data this refers to */ const X509_POLICY_DATA *data; /* Parent node */ X509_POLICY_NODE *parent; /* Number of child nodes */ int nchild; }; struct X509_POLICY_LEVEL_st { /* Cert for this level */ X509 *cert; /* nodes at this level */ STACK_OF(X509_POLICY_NODE) *nodes; /* anyPolicy node */ X509_POLICY_NODE *anyPolicy; /* Extra data */ /*STACK_OF(X509_POLICY_DATA) *extra_data;*/ unsigned int flags; }; struct X509_POLICY_TREE_st { /* This is the tree 'level' data */ X509_POLICY_LEVEL *levels; int nlevel; /* Extra policy data when additional nodes (not from the certificate) * are required. */ STACK_OF(X509_POLICY_DATA) *extra_data; /* This is the authority constained policy set */ STACK_OF(X509_POLICY_NODE) *auth_policies; STACK_OF(X509_POLICY_NODE) *user_policies; unsigned int flags; }; /* Set if anyPolicy present in user policies */ #define POLICY_FLAG_ANY_POLICY 0x2 /* Useful macros */ #define node_data_critical(data) (data->flags & POLICY_DATA_FLAG_CRITICAL) #define node_critical(node) node_data_critical(node->data) /* Internal functions */ X509_POLICY_DATA *policy_data_new(POLICYINFO *policy, const ASN1_OBJECT *id, int crit); void policy_data_free(X509_POLICY_DATA *data); X509_POLICY_DATA *policy_cache_find_data(const X509_POLICY_CACHE *cache, const ASN1_OBJECT *id); int policy_cache_set_mapping(X509 *x, POLICY_MAPPINGS *maps); STACK_OF(X509_POLICY_NODE) *policy_node_cmp_new(void); void policy_cache_init(void); void policy_cache_free(X509_POLICY_CACHE *cache); X509_POLICY_NODE *level_find_node(const X509_POLICY_LEVEL *level, const X509_POLICY_NODE *parent, const ASN1_OBJECT *id); X509_POLICY_NODE *tree_find_sk(STACK_OF(X509_POLICY_NODE) *sk, const ASN1_OBJECT *id); X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level, const X509_POLICY_DATA *data, X509_POLICY_NODE *parent, X509_POLICY_TREE *tree); void policy_node_free(X509_POLICY_NODE *node); int policy_node_match(const X509_POLICY_LEVEL *lvl, const X509_POLICY_NODE *node, const ASN1_OBJECT *oid); const X509_POLICY_CACHE *policy_cache_set(X509 *x); deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_bitst.c0000644000175000017500000001202712360020706021135 0ustar /* $OpenBSD: v3_bitst.c,v 1.9 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include static BIT_STRING_BITNAME ns_cert_type_table[] = { {0, "SSL Client", "client"}, {1, "SSL Server", "server"}, {2, "S/MIME", "email"}, {3, "Object Signing", "objsign"}, {4, "Unused", "reserved"}, {5, "SSL CA", "sslCA"}, {6, "S/MIME CA", "emailCA"}, {7, "Object Signing CA", "objCA"}, {-1, NULL, NULL} }; static BIT_STRING_BITNAME key_usage_type_table[] = { {0, "Digital Signature", "digitalSignature"}, {1, "Non Repudiation", "nonRepudiation"}, {2, "Key Encipherment", "keyEncipherment"}, {3, "Data Encipherment", "dataEncipherment"}, {4, "Key Agreement", "keyAgreement"}, {5, "Certificate Sign", "keyCertSign"}, {6, "CRL Sign", "cRLSign"}, {7, "Encipher Only", "encipherOnly"}, {8, "Decipher Only", "decipherOnly"}, {-1, NULL, NULL} }; const X509V3_EXT_METHOD v3_nscert = EXT_BITSTRING(NID_netscape_cert_type, ns_cert_type_table); const X509V3_EXT_METHOD v3_key_usage = EXT_BITSTRING(NID_key_usage, key_usage_type_table); STACK_OF(CONF_VALUE) * i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, ASN1_BIT_STRING *bits, STACK_OF(CONF_VALUE) *ret) { BIT_STRING_BITNAME *bnam; for (bnam = method->usr_data; bnam->lname; bnam++) { if (ASN1_BIT_STRING_get_bit(bits, bnam->bitnum)) X509V3_add_value(bnam->lname, NULL, &ret); } return ret; } ASN1_BIT_STRING * v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { CONF_VALUE *val; ASN1_BIT_STRING *bs; int i; BIT_STRING_BITNAME *bnam; if (!(bs = M_ASN1_BIT_STRING_new())) { X509V3err(X509V3_F_V2I_ASN1_BIT_STRING, ERR_R_MALLOC_FAILURE); return NULL; } for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { val = sk_CONF_VALUE_value(nval, i); for (bnam = method->usr_data; bnam->lname; bnam++) { if (!strcmp(bnam->sname, val->name) || !strcmp(bnam->lname, val->name) ) { if (!ASN1_BIT_STRING_set_bit(bs, bnam->bitnum, 1)) { X509V3err(X509V3_F_V2I_ASN1_BIT_STRING, ERR_R_MALLOC_FAILURE); M_ASN1_BIT_STRING_free(bs); return NULL; } break; } } if (!bnam->lname) { X509V3err(X509V3_F_V2I_ASN1_BIT_STRING, X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT); X509V3_conf_err(val); M_ASN1_BIT_STRING_free(bs); return NULL; } } return bs; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_int.c0000644000175000017500000000664312360020706020611 0ustar /* $OpenBSD: v3_int.c,v 1.8 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include const X509V3_EXT_METHOD v3_crl_num = { NID_crl_number, 0, ASN1_ITEM_ref(ASN1_INTEGER), 0, 0, 0, 0, (X509V3_EXT_I2S)i2s_ASN1_INTEGER, 0, 0, 0, 0, 0, NULL }; const X509V3_EXT_METHOD v3_delta_crl = { NID_delta_crl, 0, ASN1_ITEM_ref(ASN1_INTEGER), 0, 0, 0, 0, (X509V3_EXT_I2S)i2s_ASN1_INTEGER, 0, 0, 0, 0, 0, NULL }; static void * s2i_asn1_int(X509V3_EXT_METHOD *meth, X509V3_CTX *ctx, char *value) { return s2i_ASN1_INTEGER(meth, value); } const X509V3_EXT_METHOD v3_inhibit_anyp = { NID_inhibit_any_policy, 0, ASN1_ITEM_ref(ASN1_INTEGER), 0, 0, 0, 0, (X509V3_EXT_I2S)i2s_ASN1_INTEGER, (X509V3_EXT_S2I)s2i_asn1_int, 0, 0, 0, 0, NULL }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_pmaps.c0000644000175000017500000001266212360020706021135 0ustar /* $OpenBSD: v3_pmaps.c,v 1.3 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ /* ==================================================================== * Copyright (c) 2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include static void *v2i_POLICY_MAPPINGS(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); static STACK_OF(CONF_VALUE) *i2v_POLICY_MAPPINGS( const X509V3_EXT_METHOD *method, void *pmps, STACK_OF(CONF_VALUE) *extlist); const X509V3_EXT_METHOD v3_policy_mappings = { NID_policy_mappings, 0, ASN1_ITEM_ref(POLICY_MAPPINGS), 0, 0, 0, 0, 0, 0, i2v_POLICY_MAPPINGS, v2i_POLICY_MAPPINGS, 0, 0, NULL }; ASN1_SEQUENCE(POLICY_MAPPING) = { ASN1_SIMPLE(POLICY_MAPPING, issuerDomainPolicy, ASN1_OBJECT), ASN1_SIMPLE(POLICY_MAPPING, subjectDomainPolicy, ASN1_OBJECT) } ASN1_SEQUENCE_END(POLICY_MAPPING) ASN1_ITEM_TEMPLATE(POLICY_MAPPINGS) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, POLICY_MAPPINGS, POLICY_MAPPING) ASN1_ITEM_TEMPLATE_END(POLICY_MAPPINGS) IMPLEMENT_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING) static STACK_OF(CONF_VALUE) * i2v_POLICY_MAPPINGS(const X509V3_EXT_METHOD *method, void *a, STACK_OF(CONF_VALUE) *ext_list) { POLICY_MAPPINGS *pmaps = a; POLICY_MAPPING *pmap; int i; char obj_tmp1[80]; char obj_tmp2[80]; for (i = 0; i < sk_POLICY_MAPPING_num(pmaps); i++) { pmap = sk_POLICY_MAPPING_value(pmaps, i); i2t_ASN1_OBJECT(obj_tmp1, 80, pmap->issuerDomainPolicy); i2t_ASN1_OBJECT(obj_tmp2, 80, pmap->subjectDomainPolicy); X509V3_add_value(obj_tmp1, obj_tmp2, &ext_list); } return ext_list; } static void * v2i_POLICY_MAPPINGS(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { POLICY_MAPPINGS *pmaps; POLICY_MAPPING *pmap; ASN1_OBJECT *obj1, *obj2; CONF_VALUE *val; int i; if (!(pmaps = sk_POLICY_MAPPING_new_null())) { X509V3err(X509V3_F_V2I_POLICY_MAPPINGS, ERR_R_MALLOC_FAILURE); return NULL; } for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { val = sk_CONF_VALUE_value(nval, i); if (!val->value || !val->name) { sk_POLICY_MAPPING_pop_free(pmaps, POLICY_MAPPING_free); X509V3err(X509V3_F_V2I_POLICY_MAPPINGS, X509V3_R_INVALID_OBJECT_IDENTIFIER); X509V3_conf_err(val); return NULL; } obj1 = OBJ_txt2obj(val->name, 0); obj2 = OBJ_txt2obj(val->value, 0); if (!obj1 || !obj2) { sk_POLICY_MAPPING_pop_free(pmaps, POLICY_MAPPING_free); X509V3err(X509V3_F_V2I_POLICY_MAPPINGS, X509V3_R_INVALID_OBJECT_IDENTIFIER); X509V3_conf_err(val); return NULL; } pmap = POLICY_MAPPING_new(); if (!pmap) { sk_POLICY_MAPPING_pop_free(pmaps, POLICY_MAPPING_free); X509V3err(X509V3_F_V2I_POLICY_MAPPINGS, ERR_R_MALLOC_FAILURE); return NULL; } pmap->issuerDomainPolicy = obj1; pmap->subjectDomainPolicy = obj2; sk_POLICY_MAPPING_push(pmaps, pmap); } return pmaps; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_pci.c0000644000175000017500000002145112360020706020564 0ustar /* $OpenBSD: v3_pci.c,v 1.7 2014/07/10 21:57:20 miod Exp $ */ /* Contributed to the OpenSSL Project 2004 * by Richard Levitte (richard@levitte.org) */ /* Copyright (c) 2004 Kungliga Tekniska Hgskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. Neither the name of the Institute 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 THE INSTITUTE AND CONTRIBUTORS ``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 THE INSTITUTE OR CONTRIBUTORS 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. */ #include #include #include #include #include static int i2r_pci(X509V3_EXT_METHOD *method, PROXY_CERT_INFO_EXTENSION *ext, BIO *out, int indent); static PROXY_CERT_INFO_EXTENSION *r2i_pci(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); const X509V3_EXT_METHOD v3_pci = { NID_proxyCertInfo, 0, ASN1_ITEM_ref(PROXY_CERT_INFO_EXTENSION), 0, 0, 0, 0, 0, 0, NULL, NULL, (X509V3_EXT_I2R)i2r_pci, (X509V3_EXT_R2I)r2i_pci, NULL, }; static int i2r_pci(X509V3_EXT_METHOD *method, PROXY_CERT_INFO_EXTENSION *pci, BIO *out, int indent) { BIO_printf(out, "%*sPath Length Constraint: ", indent, ""); if (pci->pcPathLengthConstraint) i2a_ASN1_INTEGER(out, pci->pcPathLengthConstraint); else BIO_printf(out, "infinite"); BIO_puts(out, "\n"); BIO_printf(out, "%*sPolicy Language: ", indent, ""); i2a_ASN1_OBJECT(out, pci->proxyPolicy->policyLanguage); BIO_puts(out, "\n"); if (pci->proxyPolicy->policy && pci->proxyPolicy->policy->data) BIO_printf(out, "%*sPolicy Text: %s\n", indent, "", pci->proxyPolicy->policy->data); return 1; } static int process_pci_value(CONF_VALUE *val, ASN1_OBJECT **language, ASN1_INTEGER **pathlen, ASN1_OCTET_STRING **policy) { int free_policy = 0; if (strcmp(val->name, "language") == 0) { if (*language) { X509V3err(X509V3_F_PROCESS_PCI_VALUE, X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED); X509V3_conf_err(val); return 0; } if (!(*language = OBJ_txt2obj(val->value, 0))) { X509V3err(X509V3_F_PROCESS_PCI_VALUE, X509V3_R_INVALID_OBJECT_IDENTIFIER); X509V3_conf_err(val); return 0; } } else if (strcmp(val->name, "pathlen") == 0) { if (*pathlen) { X509V3err(X509V3_F_PROCESS_PCI_VALUE, X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED); X509V3_conf_err(val); return 0; } if (!X509V3_get_value_int(val, pathlen)) { X509V3err(X509V3_F_PROCESS_PCI_VALUE, X509V3_R_POLICY_PATH_LENGTH); X509V3_conf_err(val); return 0; } } else if (strcmp(val->name, "policy") == 0) { unsigned char *tmp_data = NULL; long val_len; if (!*policy) { *policy = ASN1_OCTET_STRING_new(); if (!*policy) { X509V3err(X509V3_F_PROCESS_PCI_VALUE, ERR_R_MALLOC_FAILURE); X509V3_conf_err(val); return 0; } free_policy = 1; } if (strncmp(val->value, "hex:", 4) == 0) { unsigned char *tmp_data2 = string_to_hex(val->value + 4, &val_len); if (!tmp_data2) { X509V3err(X509V3_F_PROCESS_PCI_VALUE, X509V3_R_ILLEGAL_HEX_DIGIT); X509V3_conf_err(val); goto err; } tmp_data = realloc((*policy)->data, (*policy)->length + val_len + 1); if (tmp_data) { (*policy)->data = tmp_data; memcpy(&(*policy)->data[(*policy)->length], tmp_data2, val_len); (*policy)->length += val_len; (*policy)->data[(*policy)->length] = '\0'; } else { free(tmp_data2); free((*policy)->data); (*policy)->data = NULL; (*policy)->length = 0; X509V3err(X509V3_F_PROCESS_PCI_VALUE, ERR_R_MALLOC_FAILURE); X509V3_conf_err(val); goto err; } free(tmp_data2); } else if (strncmp(val->value, "file:", 5) == 0) { unsigned char buf[2048]; int n; BIO *b = BIO_new_file(val->value + 5, "r"); if (!b) { X509V3err(X509V3_F_PROCESS_PCI_VALUE, ERR_R_BIO_LIB); X509V3_conf_err(val); goto err; } while ((n = BIO_read(b, buf, sizeof(buf))) > 0 || (n == 0 && BIO_should_retry(b))) { if (!n) continue; tmp_data = realloc((*policy)->data, (*policy)->length + n + 1); if (!tmp_data) break; (*policy)->data = tmp_data; memcpy(&(*policy)->data[(*policy)->length], buf, n); (*policy)->length += n; (*policy)->data[(*policy)->length] = '\0'; } BIO_free_all(b); if (n < 0) { X509V3err(X509V3_F_PROCESS_PCI_VALUE, ERR_R_BIO_LIB); X509V3_conf_err(val); goto err; } } else if (strncmp(val->value, "text:", 5) == 0) { val_len = strlen(val->value + 5); tmp_data = realloc((*policy)->data, (*policy)->length + val_len + 1); if (tmp_data) { (*policy)->data = tmp_data; memcpy(&(*policy)->data[(*policy)->length], val->value + 5, val_len); (*policy)->length += val_len; (*policy)->data[(*policy)->length] = '\0'; } else { free((*policy)->data); (*policy)->data = NULL; (*policy)->length = 0; X509V3err(X509V3_F_PROCESS_PCI_VALUE, ERR_R_MALLOC_FAILURE); X509V3_conf_err(val); goto err; } } else { X509V3err(X509V3_F_PROCESS_PCI_VALUE, X509V3_R_INCORRECT_POLICY_SYNTAX_TAG); X509V3_conf_err(val); goto err; } if (!tmp_data) { X509V3err(X509V3_F_PROCESS_PCI_VALUE, ERR_R_MALLOC_FAILURE); X509V3_conf_err(val); goto err; } } return 1; err: if (free_policy) { ASN1_OCTET_STRING_free(*policy); *policy = NULL; } return 0; } static PROXY_CERT_INFO_EXTENSION * r2i_pci(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *value) { PROXY_CERT_INFO_EXTENSION *pci = NULL; STACK_OF(CONF_VALUE) *vals; ASN1_OBJECT *language = NULL; ASN1_INTEGER *pathlen = NULL; ASN1_OCTET_STRING *policy = NULL; int i, j; vals = X509V3_parse_list(value); for (i = 0; i < sk_CONF_VALUE_num(vals); i++) { CONF_VALUE *cnf = sk_CONF_VALUE_value(vals, i); if (!cnf->name || (*cnf->name != '@' && !cnf->value)) { X509V3err(X509V3_F_R2I_PCI, X509V3_R_INVALID_PROXY_POLICY_SETTING); X509V3_conf_err(cnf); goto err; } if (*cnf->name == '@') { STACK_OF(CONF_VALUE) *sect; int success_p = 1; sect = X509V3_get_section(ctx, cnf->name + 1); if (!sect) { X509V3err(X509V3_F_R2I_PCI, X509V3_R_INVALID_SECTION); X509V3_conf_err(cnf); goto err; } for (j = 0; success_p && j < sk_CONF_VALUE_num(sect); j++) { success_p = process_pci_value( sk_CONF_VALUE_value(sect, j), &language, &pathlen, &policy); } X509V3_section_free(ctx, sect); if (!success_p) goto err; } else { if (!process_pci_value(cnf, &language, &pathlen, &policy)) { X509V3_conf_err(cnf); goto err; } } } /* Language is mandatory */ if (!language) { X509V3err(X509V3_F_R2I_PCI, X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED); goto err; } i = OBJ_obj2nid(language); if ((i == NID_Independent || i == NID_id_ppl_inheritAll) && policy) { X509V3err(X509V3_F_R2I_PCI, X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY); goto err; } pci = PROXY_CERT_INFO_EXTENSION_new(); if (!pci) { X509V3err(X509V3_F_R2I_PCI, ERR_R_MALLOC_FAILURE); goto err; } pci->proxyPolicy->policyLanguage = language; language = NULL; pci->proxyPolicy->policy = policy; policy = NULL; pci->pcPathLengthConstraint = pathlen; pathlen = NULL; goto end; err: if (language) { ASN1_OBJECT_free(language); language = NULL; } if (pathlen) { ASN1_INTEGER_free(pathlen); pathlen = NULL; } if (policy) { ASN1_OCTET_STRING_free(policy); policy = NULL; } if (pci) { PROXY_CERT_INFO_EXTENSION_free(pci); pci = NULL; } end: sk_CONF_VALUE_pop_free(vals, X509V3_conf_free); return pci; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_purp.c0000644000175000017500000005544712360020706021013 0ustar /* $OpenBSD: v3_purp.c,v 1.20 2014/07/10 22:45:58 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include static void x509v3_cache_extensions(X509 *x); static int check_ssl_ca(const X509 *x); static int check_purpose_ssl_client(const X509_PURPOSE *xp, const X509 *x, int ca); static int check_purpose_ssl_server(const X509_PURPOSE *xp, const X509 *x, int ca); static int check_purpose_ns_ssl_server(const X509_PURPOSE *xp, const X509 *x, int ca); static int purpose_smime(const X509 *x, int ca); static int check_purpose_smime_sign(const X509_PURPOSE *xp, const X509 *x, int ca); static int check_purpose_smime_encrypt(const X509_PURPOSE *xp, const X509 *x, int ca); static int check_purpose_crl_sign(const X509_PURPOSE *xp, const X509 *x, int ca); static int check_purpose_timestamp_sign(const X509_PURPOSE *xp, const X509 *x, int ca); static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca); static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca); static int xp_cmp(const X509_PURPOSE * const *a, const X509_PURPOSE * const *b); static void xptable_free(X509_PURPOSE *p); static X509_PURPOSE xstandard[] = { {X509_PURPOSE_SSL_CLIENT, X509_TRUST_SSL_CLIENT, 0, check_purpose_ssl_client, "SSL client", "sslclient", NULL}, {X509_PURPOSE_SSL_SERVER, X509_TRUST_SSL_SERVER, 0, check_purpose_ssl_server, "SSL server", "sslserver", NULL}, {X509_PURPOSE_NS_SSL_SERVER, X509_TRUST_SSL_SERVER, 0, check_purpose_ns_ssl_server, "Netscape SSL server", "nssslserver", NULL}, {X509_PURPOSE_SMIME_SIGN, X509_TRUST_EMAIL, 0, check_purpose_smime_sign, "S/MIME signing", "smimesign", NULL}, {X509_PURPOSE_SMIME_ENCRYPT, X509_TRUST_EMAIL, 0, check_purpose_smime_encrypt, "S/MIME encryption", "smimeencrypt", NULL}, {X509_PURPOSE_CRL_SIGN, X509_TRUST_COMPAT, 0, check_purpose_crl_sign, "CRL signing", "crlsign", NULL}, {X509_PURPOSE_ANY, X509_TRUST_DEFAULT, 0, no_check, "Any Purpose", "any", NULL}, {X509_PURPOSE_OCSP_HELPER, X509_TRUST_COMPAT, 0, ocsp_helper, "OCSP helper", "ocsphelper", NULL}, {X509_PURPOSE_TIMESTAMP_SIGN, X509_TRUST_TSA, 0, check_purpose_timestamp_sign, "Time Stamp signing", "timestampsign", NULL}, }; #define X509_PURPOSE_COUNT (sizeof(xstandard)/sizeof(X509_PURPOSE)) IMPLEMENT_STACK_OF(X509_PURPOSE) static STACK_OF(X509_PURPOSE) *xptable = NULL; static int xp_cmp(const X509_PURPOSE * const *a, const X509_PURPOSE * const *b) { return (*a)->purpose - (*b)->purpose; } /* As much as I'd like to make X509_check_purpose use a "const" X509* * I really can't because it does recalculate hashes and do other non-const * things. */ int X509_check_purpose(X509 *x, int id, int ca) { int idx; const X509_PURPOSE *pt; if (!(x->ex_flags & EXFLAG_SET)) { CRYPTO_w_lock(CRYPTO_LOCK_X509); x509v3_cache_extensions(x); CRYPTO_w_unlock(CRYPTO_LOCK_X509); } if (id == -1) return 1; idx = X509_PURPOSE_get_by_id(id); if (idx == -1) return -1; pt = X509_PURPOSE_get0(idx); return pt->check_purpose(pt, x, ca); } int X509_PURPOSE_set(int *p, int purpose) { if (X509_PURPOSE_get_by_id(purpose) == -1) { X509V3err(X509V3_F_X509_PURPOSE_SET, X509V3_R_INVALID_PURPOSE); return 0; } *p = purpose; return 1; } int X509_PURPOSE_get_count(void) { if (!xptable) return X509_PURPOSE_COUNT; return sk_X509_PURPOSE_num(xptable) + X509_PURPOSE_COUNT; } X509_PURPOSE * X509_PURPOSE_get0(int idx) { if (idx < 0) return NULL; if (idx < (int)X509_PURPOSE_COUNT) return xstandard + idx; return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT); } int X509_PURPOSE_get_by_sname(char *sname) { int i; X509_PURPOSE *xptmp; for (i = 0; i < X509_PURPOSE_get_count(); i++) { xptmp = X509_PURPOSE_get0(i); if (!strcmp(xptmp->sname, sname)) return i; } return -1; } int X509_PURPOSE_get_by_id(int purpose) { X509_PURPOSE tmp; int idx; if ((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX)) return purpose - X509_PURPOSE_MIN; tmp.purpose = purpose; if (!xptable) return -1; idx = sk_X509_PURPOSE_find(xptable, &tmp); if (idx == -1) return -1; return idx + X509_PURPOSE_COUNT; } int X509_PURPOSE_add(int id, int trust, int flags, int (*ck)(const X509_PURPOSE *, const X509 *, int), char *name, char *sname, void *arg) { int idx; X509_PURPOSE *ptmp; /* This is set according to what we change: application can't set it */ flags &= ~X509_PURPOSE_DYNAMIC; /* This will always be set for application modified trust entries */ flags |= X509_PURPOSE_DYNAMIC_NAME; /* Get existing entry if any */ idx = X509_PURPOSE_get_by_id(id); /* Need a new entry */ if (idx == -1) { if (!(ptmp = malloc(sizeof(X509_PURPOSE)))) { X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE); return 0; } ptmp->flags = X509_PURPOSE_DYNAMIC; } else ptmp = X509_PURPOSE_get0(idx); /* free existing name if dynamic */ if (ptmp->flags & X509_PURPOSE_DYNAMIC_NAME) { free(ptmp->name); free(ptmp->sname); } /* dup supplied name */ ptmp->name = BUF_strdup(name); ptmp->sname = BUF_strdup(sname); if (!ptmp->name || !ptmp->sname) { free(ptmp->name); free(ptmp->sname); free(ptmp); X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE); return 0; } /* Keep the dynamic flag of existing entry */ ptmp->flags &= X509_PURPOSE_DYNAMIC; /* Set all other flags */ ptmp->flags |= flags; ptmp->purpose = id; ptmp->trust = trust; ptmp->check_purpose = ck; ptmp->usr_data = arg; /* If its a new entry manage the dynamic table */ if (idx == -1) { if (!xptable && !(xptable = sk_X509_PURPOSE_new(xp_cmp))) { free(ptmp->name); free(ptmp->sname); free(ptmp); X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE); return 0; } if (!sk_X509_PURPOSE_push(xptable, ptmp)) { free(ptmp->name); free(ptmp->sname); free(ptmp); X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE); return 0; } } return 1; } static void xptable_free(X509_PURPOSE *p) { if (!p) return; if (p->flags & X509_PURPOSE_DYNAMIC) { if (p->flags & X509_PURPOSE_DYNAMIC_NAME) { free(p->name); free(p->sname); } free(p); } } void X509_PURPOSE_cleanup(void) { unsigned int i; sk_X509_PURPOSE_pop_free(xptable, xptable_free); for(i = 0; i < X509_PURPOSE_COUNT; i++) xptable_free(xstandard + i); xptable = NULL; } int X509_PURPOSE_get_id(X509_PURPOSE *xp) { return xp->purpose; } char * X509_PURPOSE_get0_name(X509_PURPOSE *xp) { return xp->name; } char * X509_PURPOSE_get0_sname(X509_PURPOSE *xp) { return xp->sname; } int X509_PURPOSE_get_trust(X509_PURPOSE *xp) { return xp->trust; } static int nid_cmp(const int *a, const int *b) { return *a - *b; } DECLARE_OBJ_BSEARCH_CMP_FN(int, int, nid); IMPLEMENT_OBJ_BSEARCH_CMP_FN(int, int, nid); int X509_supported_extension(X509_EXTENSION *ex) { /* This table is a list of the NIDs of supported extensions: * that is those which are used by the verify process. If * an extension is critical and doesn't appear in this list * then the verify process will normally reject the certificate. * The list must be kept in numerical order because it will be * searched using bsearch. */ static const int supported_nids[] = { NID_netscape_cert_type, /* 71 */ NID_key_usage, /* 83 */ NID_subject_alt_name, /* 85 */ NID_basic_constraints, /* 87 */ NID_certificate_policies, /* 89 */ NID_ext_key_usage, /* 126 */ #ifndef OPENSSL_NO_RFC3779 NID_sbgp_ipAddrBlock, /* 290 */ NID_sbgp_autonomousSysNum, /* 291 */ #endif NID_policy_constraints, /* 401 */ NID_proxyCertInfo, /* 663 */ NID_name_constraints, /* 666 */ NID_policy_mappings, /* 747 */ NID_inhibit_any_policy /* 748 */ }; int ex_nid = OBJ_obj2nid(X509_EXTENSION_get_object(ex)); if (ex_nid == NID_undef) return 0; if (OBJ_bsearch_nid(&ex_nid, supported_nids, sizeof(supported_nids) / sizeof(int))) return 1; return 0; } static void setup_dp(X509 *x, DIST_POINT *dp) { X509_NAME *iname = NULL; int i; if (dp->reasons) { if (dp->reasons->length > 0) dp->dp_reasons = dp->reasons->data[0]; if (dp->reasons->length > 1) dp->dp_reasons |= (dp->reasons->data[1] << 8); dp->dp_reasons &= CRLDP_ALL_REASONS; } else dp->dp_reasons = CRLDP_ALL_REASONS; if (!dp->distpoint || (dp->distpoint->type != 1)) return; for (i = 0; i < sk_GENERAL_NAME_num(dp->CRLissuer); i++) { GENERAL_NAME *gen = sk_GENERAL_NAME_value(dp->CRLissuer, i); if (gen->type == GEN_DIRNAME) { iname = gen->d.directoryName; break; } } if (!iname) iname = X509_get_issuer_name(x); DIST_POINT_set_dpname(dp->distpoint, iname); } static void setup_crldp(X509 *x) { int i; x->crldp = X509_get_ext_d2i(x, NID_crl_distribution_points, NULL, NULL); for (i = 0; i < sk_DIST_POINT_num(x->crldp); i++) setup_dp(x, sk_DIST_POINT_value(x->crldp, i)); } static void x509v3_cache_extensions(X509 *x) { BASIC_CONSTRAINTS *bs; PROXY_CERT_INFO_EXTENSION *pci; ASN1_BIT_STRING *usage; ASN1_BIT_STRING *ns; EXTENDED_KEY_USAGE *extusage; X509_EXTENSION *ex; int i; if (x->ex_flags & EXFLAG_SET) return; #ifndef OPENSSL_NO_SHA X509_digest(x, EVP_sha1(), x->sha1_hash, NULL); #endif /* Does subject name match issuer ? */ if (!X509_NAME_cmp(X509_get_subject_name(x), X509_get_issuer_name(x))) x->ex_flags |= EXFLAG_SI; /* V1 should mean no extensions ... */ if (!X509_get_version(x)) x->ex_flags |= EXFLAG_V1; /* Handle basic constraints */ if ((bs = X509_get_ext_d2i(x, NID_basic_constraints, NULL, NULL))) { if (bs->ca) x->ex_flags |= EXFLAG_CA; if (bs->pathlen) { if ((bs->pathlen->type == V_ASN1_NEG_INTEGER) || !bs->ca) { x->ex_flags |= EXFLAG_INVALID; x->ex_pathlen = 0; } else x->ex_pathlen = ASN1_INTEGER_get(bs->pathlen); } else x->ex_pathlen = -1; BASIC_CONSTRAINTS_free(bs); x->ex_flags |= EXFLAG_BCONS; } /* Handle proxy certificates */ if ((pci = X509_get_ext_d2i(x, NID_proxyCertInfo, NULL, NULL))) { if (x->ex_flags & EXFLAG_CA || X509_get_ext_by_NID(x, NID_subject_alt_name, -1) >= 0 || X509_get_ext_by_NID(x, NID_issuer_alt_name, -1) >= 0) { x->ex_flags |= EXFLAG_INVALID; } if (pci->pcPathLengthConstraint) { x->ex_pcpathlen = ASN1_INTEGER_get(pci->pcPathLengthConstraint); } else x->ex_pcpathlen = -1; PROXY_CERT_INFO_EXTENSION_free(pci); x->ex_flags |= EXFLAG_PROXY; } /* Handle key usage */ if ((usage = X509_get_ext_d2i(x, NID_key_usage, NULL, NULL))) { if (usage->length > 0) { x->ex_kusage = usage->data[0]; if (usage->length > 1) x->ex_kusage |= usage->data[1] << 8; } else x->ex_kusage = 0; x->ex_flags |= EXFLAG_KUSAGE; ASN1_BIT_STRING_free(usage); } x->ex_xkusage = 0; if ((extusage = X509_get_ext_d2i(x, NID_ext_key_usage, NULL, NULL))) { x->ex_flags |= EXFLAG_XKUSAGE; for (i = 0; i < sk_ASN1_OBJECT_num(extusage); i++) { switch (OBJ_obj2nid(sk_ASN1_OBJECT_value(extusage, i))) { case NID_server_auth: x->ex_xkusage |= XKU_SSL_SERVER; break; case NID_client_auth: x->ex_xkusage |= XKU_SSL_CLIENT; break; case NID_email_protect: x->ex_xkusage |= XKU_SMIME; break; case NID_code_sign: x->ex_xkusage |= XKU_CODE_SIGN; break; case NID_ms_sgc: case NID_ns_sgc: x->ex_xkusage |= XKU_SGC; break; case NID_OCSP_sign: x->ex_xkusage |= XKU_OCSP_SIGN; break; case NID_time_stamp: x->ex_xkusage |= XKU_TIMESTAMP; break; case NID_dvcs: x->ex_xkusage |= XKU_DVCS; break; } } sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free); } if ((ns = X509_get_ext_d2i(x, NID_netscape_cert_type, NULL, NULL))) { if (ns->length > 0) x->ex_nscert = ns->data[0]; else x->ex_nscert = 0; x->ex_flags |= EXFLAG_NSCERT; ASN1_BIT_STRING_free(ns); } x->skid = X509_get_ext_d2i(x, NID_subject_key_identifier, NULL, NULL); x->akid = X509_get_ext_d2i(x, NID_authority_key_identifier, NULL, NULL); x->altname = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL); x->nc = X509_get_ext_d2i(x, NID_name_constraints, &i, NULL); if (!x->nc && (i != -1)) x->ex_flags |= EXFLAG_INVALID; setup_crldp(x); #ifndef OPENSSL_NO_RFC3779 x->rfc3779_addr = X509_get_ext_d2i(x, NID_sbgp_ipAddrBlock, NULL, NULL); x->rfc3779_asid = X509_get_ext_d2i(x, NID_sbgp_autonomousSysNum, NULL, NULL); #endif for (i = 0; i < X509_get_ext_count(x); i++) { ex = X509_get_ext(x, i); if (OBJ_obj2nid(X509_EXTENSION_get_object(ex)) == NID_freshest_crl) x->ex_flags |= EXFLAG_FRESHEST; if (!X509_EXTENSION_get_critical(ex)) continue; if (!X509_supported_extension(ex)) { x->ex_flags |= EXFLAG_CRITICAL; break; } } x->ex_flags |= EXFLAG_SET; } /* CA checks common to all purposes * return codes: * 0 not a CA * 1 is a CA * 2 basicConstraints absent so "maybe" a CA * 3 basicConstraints absent but self signed V1. * 4 basicConstraints absent but keyUsage present and keyCertSign asserted. */ #define V1_ROOT (EXFLAG_V1|EXFLAG_SS) #define ku_reject(x, usage) \ (((x)->ex_flags & EXFLAG_KUSAGE) && !((x)->ex_kusage & (usage))) #define xku_reject(x, usage) \ (((x)->ex_flags & EXFLAG_XKUSAGE) && !((x)->ex_xkusage & (usage))) #define ns_reject(x, usage) \ (((x)->ex_flags & EXFLAG_NSCERT) && !((x)->ex_nscert & (usage))) static int check_ca(const X509 *x) { /* keyUsage if present should allow cert signing */ if (ku_reject(x, KU_KEY_CERT_SIGN)) return 0; if (x->ex_flags & EXFLAG_BCONS) { if (x->ex_flags & EXFLAG_CA) return 1; /* If basicConstraints says not a CA then say so */ else return 0; } else { /* we support V1 roots for... uh, I don't really know why. */ if ((x->ex_flags & V1_ROOT) == V1_ROOT) return 3; /* If key usage present it must have certSign so tolerate it */ else if (x->ex_flags & EXFLAG_KUSAGE) return 4; /* Older certificates could have Netscape-specific CA types */ else if (x->ex_flags & EXFLAG_NSCERT && x->ex_nscert & NS_ANY_CA) return 5; /* can this still be regarded a CA certificate? I doubt it */ return 0; } } int X509_check_ca(X509 *x) { if (!(x->ex_flags & EXFLAG_SET)) { CRYPTO_w_lock(CRYPTO_LOCK_X509); x509v3_cache_extensions(x); CRYPTO_w_unlock(CRYPTO_LOCK_X509); } return check_ca(x); } /* Check SSL CA: common checks for SSL client and server */ static int check_ssl_ca(const X509 *x) { int ca_ret; ca_ret = check_ca(x); if (!ca_ret) return 0; /* check nsCertType if present */ if (ca_ret != 5 || x->ex_nscert & NS_SSL_CA) return ca_ret; else return 0; } static int check_purpose_ssl_client(const X509_PURPOSE *xp, const X509 *x, int ca) { if (xku_reject(x, XKU_SSL_CLIENT)) return 0; if (ca) return check_ssl_ca(x); /* We need to do digital signatures with it */ if (ku_reject(x, KU_DIGITAL_SIGNATURE)) return 0; /* nsCertType if present should allow SSL client use */ if (ns_reject(x, NS_SSL_CLIENT)) return 0; return 1; } static int check_purpose_ssl_server(const X509_PURPOSE *xp, const X509 *x, int ca) { if (xku_reject(x, XKU_SSL_SERVER|XKU_SGC)) return 0; if (ca) return check_ssl_ca(x); if (ns_reject(x, NS_SSL_SERVER)) return 0; /* Now as for keyUsage: we'll at least need to sign OR encipher */ if (ku_reject(x, KU_DIGITAL_SIGNATURE|KU_KEY_ENCIPHERMENT)) return 0; return 1; } static int check_purpose_ns_ssl_server(const X509_PURPOSE *xp, const X509 *x, int ca) { int ret; ret = check_purpose_ssl_server(xp, x, ca); if (!ret || ca) return ret; /* We need to encipher or Netscape complains */ if (ku_reject(x, KU_KEY_ENCIPHERMENT)) return 0; return ret; } /* common S/MIME checks */ static int purpose_smime(const X509 *x, int ca) { if (xku_reject(x, XKU_SMIME)) return 0; if (ca) { int ca_ret; ca_ret = check_ca(x); if (!ca_ret) return 0; /* check nsCertType if present */ if (ca_ret != 5 || x->ex_nscert & NS_SMIME_CA) return ca_ret; else return 0; } if (x->ex_flags & EXFLAG_NSCERT) { if (x->ex_nscert & NS_SMIME) return 1; /* Workaround for some buggy certificates */ if (x->ex_nscert & NS_SSL_CLIENT) return 2; return 0; } return 1; } static int check_purpose_smime_sign(const X509_PURPOSE *xp, const X509 *x, int ca) { int ret; ret = purpose_smime(x, ca); if (!ret || ca) return ret; if (ku_reject(x, KU_DIGITAL_SIGNATURE|KU_NON_REPUDIATION)) return 0; return ret; } static int check_purpose_smime_encrypt(const X509_PURPOSE *xp, const X509 *x, int ca) { int ret; ret = purpose_smime(x, ca); if (!ret || ca) return ret; if (ku_reject(x, KU_KEY_ENCIPHERMENT)) return 0; return ret; } static int check_purpose_crl_sign(const X509_PURPOSE *xp, const X509 *x, int ca) { if (ca) { int ca_ret; if ((ca_ret = check_ca(x)) != 2) return ca_ret; else return 0; } if (ku_reject(x, KU_CRL_SIGN)) return 0; return 1; } /* OCSP helper: this is *not* a full OCSP check. It just checks that * each CA is valid. Additional checks must be made on the chain. */ static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca) { /* Must be a valid CA. Should we really support the "I don't know" value (2)? */ if (ca) return check_ca(x); /* leaf certificate is checked in OCSP_verify() */ return 1; } static int check_purpose_timestamp_sign(const X509_PURPOSE *xp, const X509 *x, int ca) { int i_ext; /* If ca is true we must return if this is a valid CA certificate. */ if (ca) return check_ca(x); /* * Check the optional key usage field: * if Key Usage is present, it must be one of digitalSignature * and/or nonRepudiation (other values are not consistent and shall * be rejected). */ if ((x->ex_flags & EXFLAG_KUSAGE) && ((x->ex_kusage & ~(KU_NON_REPUDIATION | KU_DIGITAL_SIGNATURE)) || !(x->ex_kusage & (KU_NON_REPUDIATION | KU_DIGITAL_SIGNATURE)))) return 0; /* Only time stamp key usage is permitted and it's required. */ if (!(x->ex_flags & EXFLAG_XKUSAGE) || x->ex_xkusage != XKU_TIMESTAMP) return 0; /* Extended Key Usage MUST be critical */ i_ext = X509_get_ext_by_NID((X509 *) x, NID_ext_key_usage, -1); if (i_ext >= 0) { X509_EXTENSION *ext = X509_get_ext((X509 *) x, i_ext); if (!X509_EXTENSION_get_critical(ext)) return 0; } return 1; } static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca) { return 1; } /* Various checks to see if one certificate issued the second. * This can be used to prune a set of possible issuer certificates * which have been looked up using some simple method such as by * subject name. * These are: * 1. Check issuer_name(subject) == subject_name(issuer) * 2. If akid(subject) exists check it matches issuer * 3. If key_usage(issuer) exists check it supports certificate signing * returns 0 for OK, positive for reason for mismatch, reasons match * codes for X509_verify_cert() */ int X509_check_issued(X509 *issuer, X509 *subject) { if (X509_NAME_cmp(X509_get_subject_name(issuer), X509_get_issuer_name(subject))) return X509_V_ERR_SUBJECT_ISSUER_MISMATCH; x509v3_cache_extensions(issuer); x509v3_cache_extensions(subject); if (subject->akid) { int ret = X509_check_akid(issuer, subject->akid); if (ret != X509_V_OK) return ret; } if (subject->ex_flags & EXFLAG_PROXY) { if (ku_reject(issuer, KU_DIGITAL_SIGNATURE)) return X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE; } else if (ku_reject(issuer, KU_KEY_CERT_SIGN)) return X509_V_ERR_KEYUSAGE_NO_CERTSIGN; return X509_V_OK; } int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid) { if (!akid) return X509_V_OK; /* Check key ids (if present) */ if (akid->keyid && issuer->skid && ASN1_OCTET_STRING_cmp(akid->keyid, issuer->skid) ) return X509_V_ERR_AKID_SKID_MISMATCH; /* Check serial number */ if (akid->serial && ASN1_INTEGER_cmp(X509_get_serialNumber(issuer), akid->serial)) return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH; /* Check issuer name */ if (akid->issuer) { /* Ugh, for some peculiar reason AKID includes * SEQUENCE OF GeneralName. So look for a DirName. * There may be more than one but we only take any * notice of the first. */ GENERAL_NAMES *gens; GENERAL_NAME *gen; X509_NAME *nm = NULL; int i; gens = akid->issuer; for (i = 0; i < sk_GENERAL_NAME_num(gens); i++) { gen = sk_GENERAL_NAME_value(gens, i); if (gen->type == GEN_DIRNAME) { nm = gen->d.dirn; break; } } if (nm && X509_NAME_cmp(nm, X509_get_issuer_name(issuer))) return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH; } return X509_V_OK; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/pcy_tree.c0000644000175000017500000005071012360020706021213 0ustar /* $OpenBSD: pcy_tree.c,v 1.11 2014/07/09 16:59:33 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "pcy_int.h" /* Enable this to print out the complete policy tree at various point during * evaluation. */ /*#define OPENSSL_POLICY_DEBUG*/ #ifdef OPENSSL_POLICY_DEBUG static void expected_print(BIO *err, X509_POLICY_LEVEL *lev, X509_POLICY_NODE *node, int indent) { if ((lev->flags & X509_V_FLAG_INHIBIT_MAP) || !(node->data->flags & POLICY_DATA_FLAG_MAP_MASK)) BIO_puts(err, " Not Mapped\n"); else { int i; STACK_OF(ASN1_OBJECT) *pset = node->data->expected_policy_set; ASN1_OBJECT *oid; BIO_puts(err, " Expected: "); for (i = 0; i < sk_ASN1_OBJECT_num(pset); i++) { oid = sk_ASN1_OBJECT_value(pset, i); if (i) BIO_puts(err, ", "); i2a_ASN1_OBJECT(err, oid); } BIO_puts(err, "\n"); } } static void tree_print(char *str, X509_POLICY_TREE *tree, X509_POLICY_LEVEL *curr) { X509_POLICY_LEVEL *plev; X509_POLICY_NODE *node; int i; BIO *err; err = BIO_new_fp(stderr, BIO_NOCLOSE); if (!curr) curr = tree->levels + tree->nlevel; else curr++; BIO_printf(err, "Level print after %s\n", str); BIO_printf(err, "Printing Up to Level %ld\n", curr - tree->levels); for (plev = tree->levels; plev != curr; plev++) { BIO_printf(err, "Level %ld, flags = %x\n", plev - tree->levels, plev->flags); for (i = 0; i < sk_X509_POLICY_NODE_num(plev->nodes); i++) { node = sk_X509_POLICY_NODE_value(plev->nodes, i); X509_POLICY_NODE_print(err, node, 2); expected_print(err, plev, node, 2); BIO_printf(err, " Flags: %x\n", node->data->flags); } if (plev->anyPolicy) X509_POLICY_NODE_print(err, plev->anyPolicy, 2); } BIO_free(err); } #else #define tree_print(a,b,c) /* */ #endif /* Initialize policy tree. Return values: * 0 Some internal error occured. * -1 Inconsistent or invalid extensions in certificates. * 1 Tree initialized OK. * 2 Policy tree is empty. * 5 Tree OK and requireExplicitPolicy true. * 6 Tree empty and requireExplicitPolicy true. */ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs, unsigned int flags) { X509_POLICY_TREE *tree; X509_POLICY_LEVEL *level; const X509_POLICY_CACHE *cache; X509_POLICY_DATA *data = NULL; X509 *x; int ret = 1; int i, n; int explicit_policy; int any_skip; int map_skip; *ptree = NULL; n = sk_X509_num(certs); #if 0 /* Disable policy mapping for now... */ flags |= X509_V_FLAG_INHIBIT_MAP; #endif if (flags & X509_V_FLAG_EXPLICIT_POLICY) explicit_policy = 0; else explicit_policy = n + 1; if (flags & X509_V_FLAG_INHIBIT_ANY) any_skip = 0; else any_skip = n + 1; if (flags & X509_V_FLAG_INHIBIT_MAP) map_skip = 0; else map_skip = n + 1; /* Can't do anything with just a trust anchor */ if (n == 1) return 1; /* First setup policy cache in all certificates apart from the * trust anchor. Note any bad cache results on the way. Also can * calculate explicit_policy value at this point. */ for (i = n - 2; i >= 0; i--) { x = sk_X509_value(certs, i); X509_check_purpose(x, -1, -1); cache = policy_cache_set(x); /* If cache NULL something bad happened: return immediately */ if (cache == NULL) return 0; /* If inconsistent extensions keep a note of it but continue */ if (x->ex_flags & EXFLAG_INVALID_POLICY) ret = -1; /* Otherwise if we have no data (hence no CertificatePolicies) * and haven't already set an inconsistent code note it. */ else if ((ret == 1) && !cache->data) ret = 2; if (explicit_policy > 0) { if (!(x->ex_flags & EXFLAG_SI)) explicit_policy--; if ((cache->explicit_skip != -1) && (cache->explicit_skip < explicit_policy)) explicit_policy = cache->explicit_skip; } } if (ret != 1) { if (ret == 2 && !explicit_policy) return 6; return ret; } /* If we get this far initialize the tree */ tree = malloc(sizeof(X509_POLICY_TREE)); if (!tree) return 0; tree->flags = 0; tree->levels = calloc(n, sizeof(X509_POLICY_LEVEL)); tree->nlevel = 0; tree->extra_data = NULL; tree->auth_policies = NULL; tree->user_policies = NULL; if (!tree->levels) { free(tree); return 0; } tree->nlevel = n; level = tree->levels; /* Root data: initialize to anyPolicy */ data = policy_data_new(NULL, OBJ_nid2obj(NID_any_policy), 0); if (!data || !level_add_node(level, data, NULL, tree)) goto bad_tree; for (i = n - 2; i >= 0; i--) { level++; x = sk_X509_value(certs, i); cache = policy_cache_set(x); CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509); level->cert = x; if (!cache->anyPolicy) level->flags |= X509_V_FLAG_INHIBIT_ANY; /* Determine inhibit any and inhibit map flags */ if (any_skip == 0) { /* Any matching allowed if certificate is self * issued and not the last in the chain. */ if (!(x->ex_flags & EXFLAG_SI) || (i == 0)) level->flags |= X509_V_FLAG_INHIBIT_ANY; } else { if (!(x->ex_flags & EXFLAG_SI)) any_skip--; if ((cache->any_skip >= 0) && (cache->any_skip < any_skip)) any_skip = cache->any_skip; } if (map_skip == 0) level->flags |= X509_V_FLAG_INHIBIT_MAP; else { if (!(x->ex_flags & EXFLAG_SI)) map_skip--; if ((cache->map_skip >= 0) && (cache->map_skip < map_skip)) map_skip = cache->map_skip; } } *ptree = tree; if (explicit_policy) return 1; else return 5; bad_tree: X509_policy_tree_free(tree); return 0; } static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr, const X509_POLICY_DATA *data) { X509_POLICY_LEVEL *last = curr - 1; X509_POLICY_NODE *node; int i, matched = 0; /* Iterate through all in nodes linking matches */ for (i = 0; i < sk_X509_POLICY_NODE_num(last->nodes); i++) { node = sk_X509_POLICY_NODE_value(last->nodes, i); if (policy_node_match(last, node, data->valid_policy)) { if (!level_add_node(curr, data, node, NULL)) return 0; matched = 1; } } if (!matched && last->anyPolicy) { if (!level_add_node(curr, data, last->anyPolicy, NULL)) return 0; } return 1; } /* This corresponds to RFC3280 6.1.3(d)(1): * link any data from CertificatePolicies onto matching parent * or anyPolicy if no match. */ static int tree_link_nodes(X509_POLICY_LEVEL *curr, const X509_POLICY_CACHE *cache) { int i; X509_POLICY_DATA *data; for (i = 0; i < sk_X509_POLICY_DATA_num(cache->data); i++) { data = sk_X509_POLICY_DATA_value(cache->data, i); /* If a node is mapped any it doesn't have a corresponding * CertificatePolicies entry. * However such an identical node would be created * if anyPolicy matching is enabled because there would be * no match with the parent valid_policy_set. So we create * link because then it will have the mapping flags * right and we can prune it later. */ #if 0 if ((data->flags & POLICY_DATA_FLAG_MAPPED_ANY) && !(curr->flags & X509_V_FLAG_INHIBIT_ANY)) continue; #endif /* Look for matching nodes in previous level */ if (!tree_link_matching_nodes(curr, data)) return 0; } return 1; } /* This corresponds to RFC3280 6.1.3(d)(2): * Create new data for any unmatched policies in the parent and link * to anyPolicy. */ static int tree_add_unmatched(X509_POLICY_LEVEL *curr, const X509_POLICY_CACHE *cache, const ASN1_OBJECT *id, X509_POLICY_NODE *node, X509_POLICY_TREE *tree) { X509_POLICY_DATA *data; if (id == NULL) id = node->data->valid_policy; /* Create a new node with qualifiers from anyPolicy and * id from unmatched node. */ data = policy_data_new(NULL, id, node_critical(node)); if (data == NULL) return 0; /* Curr may not have anyPolicy */ data->qualifier_set = cache->anyPolicy->qualifier_set; data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS; if (!level_add_node(curr, data, node, tree)) { policy_data_free(data); return 0; } return 1; } static int tree_link_unmatched(X509_POLICY_LEVEL *curr, const X509_POLICY_CACHE *cache, X509_POLICY_NODE *node, X509_POLICY_TREE *tree) { const X509_POLICY_LEVEL *last = curr - 1; int i; if ((last->flags & X509_V_FLAG_INHIBIT_MAP) || !(node->data->flags & POLICY_DATA_FLAG_MAPPED)) { /* If no policy mapping: matched if one child present */ if (node->nchild) return 1; if (!tree_add_unmatched(curr, cache, NULL, node, tree)) return 0; /* Add it */ } else { /* If mapping: matched if one child per expected policy set */ STACK_OF(ASN1_OBJECT) *expset = node->data->expected_policy_set; if (node->nchild == sk_ASN1_OBJECT_num(expset)) return 1; /* Locate unmatched nodes */ for (i = 0; i < sk_ASN1_OBJECT_num(expset); i++) { ASN1_OBJECT *oid = sk_ASN1_OBJECT_value(expset, i); if (level_find_node(curr, node, oid)) continue; if (!tree_add_unmatched(curr, cache, oid, node, tree)) return 0; } } return 1; } static int tree_link_any(X509_POLICY_LEVEL *curr, const X509_POLICY_CACHE *cache, X509_POLICY_TREE *tree) { int i; /*X509_POLICY_DATA *data;*/ X509_POLICY_NODE *node; X509_POLICY_LEVEL *last = curr - 1; for (i = 0; i < sk_X509_POLICY_NODE_num(last->nodes); i++) { node = sk_X509_POLICY_NODE_value(last->nodes, i); if (!tree_link_unmatched(curr, cache, node, tree)) return 0; #if 0 /* Skip any node with any children: we only want unmathced * nodes. * * Note: need something better for policy mapping * because each node may have multiple children */ if (node->nchild) continue; /* Create a new node with qualifiers from anyPolicy and * id from unmatched node. */ data = policy_data_new(NULL, node->data->valid_policy, node_critical(node)); if (data == NULL) return 0; /* Curr may not have anyPolicy */ data->qualifier_set = cache->anyPolicy->qualifier_set; data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS; if (!level_add_node(curr, data, node, tree)) { policy_data_free(data); return 0; } #endif } /* Finally add link to anyPolicy */ if (last->anyPolicy) { if (!level_add_node(curr, cache->anyPolicy, last->anyPolicy, NULL)) return 0; } return 1; } /* Prune the tree: delete any child mapped child data on the current level * then proceed up the tree deleting any data with no children. If we ever * have no data on a level we can halt because the tree will be empty. */ static int tree_prune(X509_POLICY_TREE *tree, X509_POLICY_LEVEL *curr) { STACK_OF(X509_POLICY_NODE) *nodes; X509_POLICY_NODE *node; int i; nodes = curr->nodes; if (curr->flags & X509_V_FLAG_INHIBIT_MAP) { for (i = sk_X509_POLICY_NODE_num(nodes) - 1; i >= 0; i--) { node = sk_X509_POLICY_NODE_value(nodes, i); /* Delete any mapped data: see RFC3280 XXXX */ if (node->data->flags & POLICY_DATA_FLAG_MAP_MASK) { node->parent->nchild--; free(node); (void)sk_X509_POLICY_NODE_delete(nodes, i); } } } for (;;) { --curr; nodes = curr->nodes; for (i = sk_X509_POLICY_NODE_num(nodes) - 1; i >= 0; i--) { node = sk_X509_POLICY_NODE_value(nodes, i); if (node->nchild == 0) { node->parent->nchild--; free(node); (void)sk_X509_POLICY_NODE_delete(nodes, i); } } if (curr->anyPolicy && !curr->anyPolicy->nchild) { if (curr->anyPolicy->parent) curr->anyPolicy->parent->nchild--; free(curr->anyPolicy); curr->anyPolicy = NULL; } if (curr == tree->levels) { /* If we zapped anyPolicy at top then tree is empty */ if (!curr->anyPolicy) return 2; return 1; } } return 1; } static int tree_add_auth_node(STACK_OF(X509_POLICY_NODE) **pnodes, X509_POLICY_NODE *pcy) { if (!*pnodes) { *pnodes = policy_node_cmp_new(); if (!*pnodes) return 0; } else if (sk_X509_POLICY_NODE_find(*pnodes, pcy) != -1) return 1; if (!sk_X509_POLICY_NODE_push(*pnodes, pcy)) return 0; return 1; } /* Calculate the authority set based on policy tree. * The 'pnodes' parameter is used as a store for the set of policy nodes * used to calculate the user set. If the authority set is not anyPolicy * then pnodes will just point to the authority set. If however the authority * set is anyPolicy then the set of valid policies (other than anyPolicy) * is store in pnodes. The return value of '2' is used in this case to indicate * that pnodes should be freed. */ static int tree_calculate_authority_set(X509_POLICY_TREE *tree, STACK_OF(X509_POLICY_NODE) **pnodes) { X509_POLICY_LEVEL *curr; X509_POLICY_NODE *node, *anyptr; STACK_OF(X509_POLICY_NODE) **addnodes; int i, j; curr = tree->levels + tree->nlevel - 1; /* If last level contains anyPolicy set is anyPolicy */ if (curr->anyPolicy) { if (!tree_add_auth_node(&tree->auth_policies, curr->anyPolicy)) return 0; addnodes = pnodes; } else /* Add policies to authority set */ addnodes = &tree->auth_policies; curr = tree->levels; for (i = 1; i < tree->nlevel; i++) { /* If no anyPolicy node on this this level it can't * appear on lower levels so end search. */ if (!(anyptr = curr->anyPolicy)) break; curr++; for (j = 0; j < sk_X509_POLICY_NODE_num(curr->nodes); j++) { node = sk_X509_POLICY_NODE_value(curr->nodes, j); if ((node->parent == anyptr) && !tree_add_auth_node(addnodes, node)) return 0; } } if (addnodes == pnodes) return 2; *pnodes = tree->auth_policies; return 1; } static int tree_calculate_user_set(X509_POLICY_TREE *tree, STACK_OF(ASN1_OBJECT) *policy_oids, STACK_OF(X509_POLICY_NODE) *auth_nodes) { int i; X509_POLICY_NODE *node; ASN1_OBJECT *oid; X509_POLICY_NODE *anyPolicy; X509_POLICY_DATA *extra; /* Check if anyPolicy present in authority constrained policy set: * this will happen if it is a leaf node. */ if (sk_ASN1_OBJECT_num(policy_oids) <= 0) return 1; anyPolicy = tree->levels[tree->nlevel - 1].anyPolicy; for (i = 0; i < sk_ASN1_OBJECT_num(policy_oids); i++) { oid = sk_ASN1_OBJECT_value(policy_oids, i); if (OBJ_obj2nid(oid) == NID_any_policy) { tree->flags |= POLICY_FLAG_ANY_POLICY; return 1; } } for (i = 0; i < sk_ASN1_OBJECT_num(policy_oids); i++) { oid = sk_ASN1_OBJECT_value(policy_oids, i); node = tree_find_sk(auth_nodes, oid); if (!node) { if (!anyPolicy) continue; /* Create a new node with policy ID from user set * and qualifiers from anyPolicy. */ extra = policy_data_new(NULL, oid, node_critical(anyPolicy)); if (!extra) return 0; extra->qualifier_set = anyPolicy->data->qualifier_set; extra->flags = POLICY_DATA_FLAG_SHARED_QUALIFIERS | POLICY_DATA_FLAG_EXTRA_NODE; node = level_add_node(NULL, extra, anyPolicy->parent, tree); } if (!tree->user_policies) { tree->user_policies = sk_X509_POLICY_NODE_new_null(); if (!tree->user_policies) return 1; } if (!sk_X509_POLICY_NODE_push(tree->user_policies, node)) return 0; } return 1; } static int tree_evaluate(X509_POLICY_TREE *tree) { int ret, i; X509_POLICY_LEVEL *curr = tree->levels + 1; const X509_POLICY_CACHE *cache; for (i = 1; i < tree->nlevel; i++, curr++) { cache = policy_cache_set(curr->cert); if (!tree_link_nodes(curr, cache)) return 0; if (!(curr->flags & X509_V_FLAG_INHIBIT_ANY) && !tree_link_any(curr, cache, tree)) return 0; tree_print("before tree_prune()", tree, curr); ret = tree_prune(tree, curr); if (ret != 1) return ret; } return 1; } static void exnode_free(X509_POLICY_NODE *node) { if (node->data && (node->data->flags & POLICY_DATA_FLAG_EXTRA_NODE)) free(node); } void X509_policy_tree_free(X509_POLICY_TREE *tree) { X509_POLICY_LEVEL *curr; int i; if (!tree) return; sk_X509_POLICY_NODE_free(tree->auth_policies); sk_X509_POLICY_NODE_pop_free(tree->user_policies, exnode_free); for (i = 0, curr = tree->levels; i < tree->nlevel; i++, curr++) { if (curr->cert) X509_free(curr->cert); if (curr->nodes) sk_X509_POLICY_NODE_pop_free(curr->nodes, policy_node_free); if (curr->anyPolicy) policy_node_free(curr->anyPolicy); } if (tree->extra_data) sk_X509_POLICY_DATA_pop_free(tree->extra_data, policy_data_free); free(tree->levels); free(tree); } /* Application policy checking function. * Return codes: * 0 Internal Error. * 1 Successful. * -1 One or more certificates contain invalid or inconsistent extensions * -2 User constrained policy set empty and requireExplicit true. */ int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, STACK_OF(X509) *certs, STACK_OF(ASN1_OBJECT) *policy_oids, unsigned int flags) { int ret; X509_POLICY_TREE *tree = NULL; STACK_OF(X509_POLICY_NODE) *nodes, *auth_nodes = NULL; *ptree = NULL; *pexplicit_policy = 0; ret = tree_init(&tree, certs, flags); switch (ret) { /* Tree empty requireExplicit False: OK */ case 2: return 1; /* Some internal error */ case -1: return -1; /* Some internal error */ case 0: return 0; /* Tree empty requireExplicit True: Error */ case 6: *pexplicit_policy = 1; return -2; /* Tree OK requireExplicit True: OK and continue */ case 5: *pexplicit_policy = 1; break; /* Tree OK: continue */ case 1: if (!tree) /* * tree_init() returns success and a null tree * if it's just looking at a trust anchor. * I'm not sure that returning success here is * correct, but I'm sure that reporting this * as an internal error which our caller * interprets as a malloc failure is wrong. */ return 1; break; } if (!tree) goto error; ret = tree_evaluate(tree); tree_print("tree_evaluate()", tree, NULL); if (ret <= 0) goto error; /* Return value 2 means tree empty */ if (ret == 2) { X509_policy_tree_free(tree); if (*pexplicit_policy) return -2; else return 1; } /* Tree is not empty: continue */ ret = tree_calculate_authority_set(tree, &auth_nodes); if (!ret) goto error; if (!tree_calculate_user_set(tree, policy_oids, auth_nodes)) goto error; if (ret == 2) sk_X509_POLICY_NODE_free(auth_nodes); if (tree) *ptree = tree; if (*pexplicit_policy) { nodes = X509_policy_tree_get0_user_policies(tree); if (sk_X509_POLICY_NODE_num(nodes) <= 0) return -2; } return 1; error: X509_policy_tree_free(tree); return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_bcons.c0000644000175000017500000001123012360020706021107 0ustar /* $OpenBSD: v3_bcons.c,v 1.9 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include static STACK_OF(CONF_VALUE) *i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, BASIC_CONSTRAINTS *bcons, STACK_OF(CONF_VALUE) *extlist); static BASIC_CONSTRAINTS *v2i_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values); const X509V3_EXT_METHOD v3_bcons = { NID_basic_constraints, 0, ASN1_ITEM_ref(BASIC_CONSTRAINTS), 0, 0, 0, 0, 0, 0, (X509V3_EXT_I2V)i2v_BASIC_CONSTRAINTS, (X509V3_EXT_V2I)v2i_BASIC_CONSTRAINTS, NULL, NULL, NULL }; ASN1_SEQUENCE(BASIC_CONSTRAINTS) = { ASN1_OPT(BASIC_CONSTRAINTS, ca, ASN1_FBOOLEAN), ASN1_OPT(BASIC_CONSTRAINTS, pathlen, ASN1_INTEGER) } ASN1_SEQUENCE_END(BASIC_CONSTRAINTS) IMPLEMENT_ASN1_FUNCTIONS(BASIC_CONSTRAINTS) static STACK_OF(CONF_VALUE) * i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, BASIC_CONSTRAINTS *bcons, STACK_OF(CONF_VALUE) *extlist) { X509V3_add_value_bool("CA", bcons->ca, &extlist); X509V3_add_value_int("pathlen", bcons->pathlen, &extlist); return extlist; } static BASIC_CONSTRAINTS * v2i_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values) { BASIC_CONSTRAINTS *bcons = NULL; CONF_VALUE *val; int i; if (!(bcons = BASIC_CONSTRAINTS_new())) { X509V3err(X509V3_F_V2I_BASIC_CONSTRAINTS, ERR_R_MALLOC_FAILURE); return NULL; } for (i = 0; i < sk_CONF_VALUE_num(values); i++) { val = sk_CONF_VALUE_value(values, i); if (!strcmp(val->name, "CA")) { if (!X509V3_get_value_bool(val, &bcons->ca)) goto err; } else if (!strcmp(val->name, "pathlen")) { if (!X509V3_get_value_int(val, &bcons->pathlen)) goto err; } else { X509V3err(X509V3_F_V2I_BASIC_CONSTRAINTS, X509V3_R_INVALID_NAME); X509V3_conf_err(val); goto err; } } return bcons; err: BASIC_CONSTRAINTS_free(bcons); return NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_info.c0000644000175000017500000001514712360020706020751 0ustar /* $OpenBSD: v3_info.c,v 1.17 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS( X509V3_EXT_METHOD *method, AUTHORITY_INFO_ACCESS *ainfo, STACK_OF(CONF_VALUE) *ret); static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS( X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); const X509V3_EXT_METHOD v3_info = { NID_info_access, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(AUTHORITY_INFO_ACCESS), 0, 0, 0, 0, 0, 0, (X509V3_EXT_I2V)i2v_AUTHORITY_INFO_ACCESS, (X509V3_EXT_V2I)v2i_AUTHORITY_INFO_ACCESS, 0, 0, NULL }; const X509V3_EXT_METHOD v3_sinfo = { NID_sinfo_access, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(AUTHORITY_INFO_ACCESS), 0, 0, 0, 0, 0, 0, (X509V3_EXT_I2V)i2v_AUTHORITY_INFO_ACCESS, (X509V3_EXT_V2I)v2i_AUTHORITY_INFO_ACCESS, 0, 0, NULL }; ASN1_SEQUENCE(ACCESS_DESCRIPTION) = { ASN1_SIMPLE(ACCESS_DESCRIPTION, method, ASN1_OBJECT), ASN1_SIMPLE(ACCESS_DESCRIPTION, location, GENERAL_NAME) } ASN1_SEQUENCE_END(ACCESS_DESCRIPTION) IMPLEMENT_ASN1_FUNCTIONS(ACCESS_DESCRIPTION) ASN1_ITEM_TEMPLATE(AUTHORITY_INFO_ACCESS) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, GeneralNames, ACCESS_DESCRIPTION) ASN1_ITEM_TEMPLATE_END(AUTHORITY_INFO_ACCESS) IMPLEMENT_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS) static STACK_OF(CONF_VALUE) * i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method, AUTHORITY_INFO_ACCESS *ainfo, STACK_OF(CONF_VALUE) *ret) { ACCESS_DESCRIPTION *desc; int i, nlen; char objtmp[80], *ntmp; CONF_VALUE *vtmp; for (i = 0; i < sk_ACCESS_DESCRIPTION_num(ainfo); i++) { desc = sk_ACCESS_DESCRIPTION_value(ainfo, i); ret = i2v_GENERAL_NAME(method, desc->location, ret); if (!ret) break; vtmp = sk_CONF_VALUE_value(ret, i); i2t_ASN1_OBJECT(objtmp, sizeof objtmp, desc->method); nlen = strlen(objtmp) + strlen(vtmp->name) + 5; ntmp = malloc(nlen); if (!ntmp) { X509V3err(X509V3_F_I2V_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE); return NULL; } strlcpy(ntmp, objtmp, nlen); strlcat(ntmp, " - ", nlen); strlcat(ntmp, vtmp->name, nlen); free(vtmp->name); vtmp->name = ntmp; } if (!ret) return sk_CONF_VALUE_new_null(); return ret; } static AUTHORITY_INFO_ACCESS * v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { AUTHORITY_INFO_ACCESS *ainfo = NULL; CONF_VALUE *cnf, ctmp; ACCESS_DESCRIPTION *acc; int i, objlen; char *objtmp, *ptmp; if (!(ainfo = sk_ACCESS_DESCRIPTION_new_null())) { X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE); return NULL; } for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { cnf = sk_CONF_VALUE_value(nval, i); if (!(acc = ACCESS_DESCRIPTION_new()) || !sk_ACCESS_DESCRIPTION_push(ainfo, acc)) { X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE); goto err; } ptmp = strchr(cnf->name, ';'); if (!ptmp) { X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, X509V3_R_INVALID_SYNTAX); goto err; } objlen = ptmp - cnf->name; ctmp.name = ptmp + 1; ctmp.value = cnf->value; if (!v2i_GENERAL_NAME_ex(acc->location, method, ctx, &ctmp, 0)) goto err; if (!(objtmp = malloc(objlen + 1))) { X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE); goto err; } strlcpy(objtmp, cnf->name, objlen + 1); acc->method = OBJ_txt2obj(objtmp, 0); if (!acc->method) { X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, X509V3_R_BAD_OBJECT); ERR_asprintf_error_data("value=%s", objtmp); free(objtmp); goto err; } free(objtmp); } return ainfo; err: sk_ACCESS_DESCRIPTION_pop_free(ainfo, ACCESS_DESCRIPTION_free); return NULL; } int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a) { i2a_ASN1_OBJECT(bp, a->method); #ifdef UNDEF i2a_GENERAL_NAME(bp, a->location); #endif return 2; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_extku.c0000644000175000017500000001166212360020706021154 0ustar /* $OpenBSD: v3_extku.c,v 1.8 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE( const X509V3_EXT_METHOD *method, void *eku, STACK_OF(CONF_VALUE) *extlist); const X509V3_EXT_METHOD v3_ext_ku = { NID_ext_key_usage, 0, ASN1_ITEM_ref(EXTENDED_KEY_USAGE), 0, 0, 0, 0, 0, 0, i2v_EXTENDED_KEY_USAGE, v2i_EXTENDED_KEY_USAGE, 0, 0, NULL }; /* NB OCSP acceptable responses also is a SEQUENCE OF OBJECT */ const X509V3_EXT_METHOD v3_ocsp_accresp = { NID_id_pkix_OCSP_acceptableResponses, 0, ASN1_ITEM_ref(EXTENDED_KEY_USAGE), 0, 0, 0, 0, 0, 0, i2v_EXTENDED_KEY_USAGE, v2i_EXTENDED_KEY_USAGE, 0, 0, NULL }; ASN1_ITEM_TEMPLATE(EXTENDED_KEY_USAGE) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, EXTENDED_KEY_USAGE, ASN1_OBJECT) ASN1_ITEM_TEMPLATE_END(EXTENDED_KEY_USAGE) IMPLEMENT_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) static STACK_OF(CONF_VALUE) * i2v_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, void *a, STACK_OF(CONF_VALUE) *ext_list) { EXTENDED_KEY_USAGE *eku = a; int i; ASN1_OBJECT *obj; char obj_tmp[80]; for (i = 0; i < sk_ASN1_OBJECT_num(eku); i++) { obj = sk_ASN1_OBJECT_value(eku, i); i2t_ASN1_OBJECT(obj_tmp, 80, obj); X509V3_add_value(NULL, obj_tmp, &ext_list); } return ext_list; } static void * v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { EXTENDED_KEY_USAGE *extku; char *extval; ASN1_OBJECT *objtmp; CONF_VALUE *val; int i; if (!(extku = sk_ASN1_OBJECT_new_null())) { X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE, ERR_R_MALLOC_FAILURE); return NULL; } for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { val = sk_CONF_VALUE_value(nval, i); if (val->value) extval = val->value; else extval = val->name; if (!(objtmp = OBJ_txt2obj(extval, 0))) { sk_ASN1_OBJECT_pop_free(extku, ASN1_OBJECT_free); X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE, X509V3_R_INVALID_OBJECT_IDENTIFIER); X509V3_conf_err(val); return NULL; } sk_ASN1_OBJECT_push(extku, objtmp); } return extku; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_pcia.c0000644000175000017500000000443412360020706020727 0ustar /* $OpenBSD$ */ /* Contributed to the OpenSSL Project 2004 * by Richard Levitte (richard@levitte.org) */ /* Copyright (c) 2004 Kungliga Tekniska Hgskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. Neither the name of the Institute 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 THE INSTITUTE AND CONTRIBUTORS ``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 THE INSTITUTE OR CONTRIBUTORS 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. */ #include #include #include ASN1_SEQUENCE(PROXY_POLICY) = { ASN1_SIMPLE(PROXY_POLICY, policyLanguage, ASN1_OBJECT), ASN1_OPT(PROXY_POLICY, policy, ASN1_OCTET_STRING) } ASN1_SEQUENCE_END(PROXY_POLICY) IMPLEMENT_ASN1_FUNCTIONS(PROXY_POLICY) ASN1_SEQUENCE(PROXY_CERT_INFO_EXTENSION) = { ASN1_OPT(PROXY_CERT_INFO_EXTENSION, pcPathLengthConstraint, ASN1_INTEGER), ASN1_SIMPLE(PROXY_CERT_INFO_EXTENSION, proxyPolicy, PROXY_POLICY) } ASN1_SEQUENCE_END(PROXY_CERT_INFO_EXTENSION) IMPLEMENT_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_skey.c0000644000175000017500000001134212360020706020762 0ustar /* $OpenBSD: v3_skey.c,v 1.9 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); const X509V3_EXT_METHOD v3_skey_id = { NID_subject_key_identifier, 0, ASN1_ITEM_ref(ASN1_OCTET_STRING), 0, 0, 0, 0, (X509V3_EXT_I2S)i2s_ASN1_OCTET_STRING, (X509V3_EXT_S2I)s2i_skey_id, 0, 0, 0, 0, NULL }; char * i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *oct) { return hex_to_string(oct->data, oct->length); } ASN1_OCTET_STRING * s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str) { ASN1_OCTET_STRING *oct; long length; if (!(oct = M_ASN1_OCTET_STRING_new())) { X509V3err(X509V3_F_S2I_ASN1_OCTET_STRING, ERR_R_MALLOC_FAILURE); return NULL; } if (!(oct->data = string_to_hex(str, &length))) { M_ASN1_OCTET_STRING_free(oct); return NULL; } oct->length = length; return oct; } static ASN1_OCTET_STRING * s2i_skey_id(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str) { ASN1_OCTET_STRING *oct; ASN1_BIT_STRING *pk; unsigned char pkey_dig[EVP_MAX_MD_SIZE]; unsigned int diglen; if (strcmp(str, "hash")) return s2i_ASN1_OCTET_STRING(method, ctx, str); if (!(oct = M_ASN1_OCTET_STRING_new())) { X509V3err(X509V3_F_S2I_SKEY_ID, ERR_R_MALLOC_FAILURE); return NULL; } if (ctx && (ctx->flags == CTX_TEST)) return oct; if (!ctx || (!ctx->subject_req && !ctx->subject_cert)) { X509V3err(X509V3_F_S2I_SKEY_ID, X509V3_R_NO_PUBLIC_KEY); goto err; } if (ctx->subject_req) pk = ctx->subject_req->req_info->pubkey->public_key; else pk = ctx->subject_cert->cert_info->key->public_key; if (!pk) { X509V3err(X509V3_F_S2I_SKEY_ID, X509V3_R_NO_PUBLIC_KEY); goto err; } if (!EVP_Digest(pk->data, pk->length, pkey_dig, &diglen, EVP_sha1(), NULL)) goto err; if (!M_ASN1_OCTET_STRING_set(oct, pkey_dig, diglen)) { X509V3err(X509V3_F_S2I_SKEY_ID, ERR_R_MALLOC_FAILURE); goto err; } return oct; err: M_ASN1_OCTET_STRING_free(oct); return NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/ext_dat.h0000644000175000017500000001117512360020706021040 0ustar /* $OpenBSD: ext_dat.h,v 1.10 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include /* This file contains a table of "standard" extensions */ extern X509V3_EXT_METHOD v3_bcons, v3_nscert, v3_key_usage, v3_ext_ku; extern X509V3_EXT_METHOD v3_pkey_usage_period, v3_sxnet, v3_info, v3_sinfo; extern X509V3_EXT_METHOD v3_ns_ia5_list[], v3_alt[], v3_skey_id, v3_akey_id; extern X509V3_EXT_METHOD v3_crl_num, v3_crl_reason, v3_crl_invdate; extern X509V3_EXT_METHOD v3_delta_crl, v3_cpols, v3_crld, v3_freshest_crl; extern X509V3_EXT_METHOD v3_ocsp_nonce, v3_ocsp_accresp, v3_ocsp_acutoff; extern X509V3_EXT_METHOD v3_ocsp_crlid, v3_ocsp_nocheck, v3_ocsp_serviceloc; extern X509V3_EXT_METHOD v3_crl_hold, v3_pci; extern X509V3_EXT_METHOD v3_policy_mappings, v3_policy_constraints; extern X509V3_EXT_METHOD v3_name_constraints, v3_inhibit_anyp, v3_idp; extern X509V3_EXT_METHOD v3_addr, v3_asid; /* This table will be searched using OBJ_bsearch so it *must* kept in * order of the ext_nid values. */ static const X509V3_EXT_METHOD *standard_exts[] = { &v3_nscert, &v3_ns_ia5_list[0], &v3_ns_ia5_list[1], &v3_ns_ia5_list[2], &v3_ns_ia5_list[3], &v3_ns_ia5_list[4], &v3_ns_ia5_list[5], &v3_ns_ia5_list[6], &v3_skey_id, &v3_key_usage, &v3_pkey_usage_period, &v3_alt[0], &v3_alt[1], &v3_bcons, &v3_crl_num, &v3_cpols, &v3_akey_id, &v3_crld, &v3_ext_ku, &v3_delta_crl, &v3_crl_reason, #ifndef OPENSSL_NO_OCSP &v3_crl_invdate, #endif &v3_sxnet, &v3_info, #ifndef OPENSSL_NO_RFC3779 &v3_addr, &v3_asid, #endif #ifndef OPENSSL_NO_OCSP &v3_ocsp_nonce, &v3_ocsp_crlid, &v3_ocsp_accresp, &v3_ocsp_nocheck, &v3_ocsp_acutoff, &v3_ocsp_serviceloc, #endif &v3_sinfo, &v3_policy_constraints, #ifndef OPENSSL_NO_OCSP &v3_crl_hold, #endif &v3_pci, &v3_name_constraints, &v3_policy_mappings, &v3_inhibit_anyp, &v3_idp, &v3_alt[2], &v3_freshest_crl, }; /* Number of standard extensions */ #define STANDARD_EXTENSION_COUNT (sizeof(standard_exts)/sizeof(X509V3_EXT_METHOD *)) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_akeya.c0000644000175000017500000000621512360020706021104 0ustar /* $OpenBSD: v3_akeya.c,v 1.4 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include ASN1_SEQUENCE(AUTHORITY_KEYID) = { ASN1_IMP_OPT(AUTHORITY_KEYID, keyid, ASN1_OCTET_STRING, 0), ASN1_IMP_SEQUENCE_OF_OPT(AUTHORITY_KEYID, issuer, GENERAL_NAME, 1), ASN1_IMP_OPT(AUTHORITY_KEYID, serial, ASN1_INTEGER, 2) } ASN1_SEQUENCE_END(AUTHORITY_KEYID) IMPLEMENT_ASN1_FUNCTIONS(AUTHORITY_KEYID) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/pcy_map.c0000644000175000017500000001077312360020706021036 0ustar /* $OpenBSD: pcy_map.c,v 1.3 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "pcy_int.h" /* Set policy mapping entries in cache. * Note: this modifies the passed POLICY_MAPPINGS structure */ int policy_cache_set_mapping(X509 *x, POLICY_MAPPINGS *maps) { POLICY_MAPPING *map; X509_POLICY_DATA *data; X509_POLICY_CACHE *cache = x->policy_cache; int i; int ret = 0; if (sk_POLICY_MAPPING_num(maps) == 0) { ret = -1; goto bad_mapping; } for (i = 0; i < sk_POLICY_MAPPING_num(maps); i++) { map = sk_POLICY_MAPPING_value(maps, i); /* Reject if map to or from anyPolicy */ if ((OBJ_obj2nid(map->subjectDomainPolicy) == NID_any_policy) || (OBJ_obj2nid(map->issuerDomainPolicy) == NID_any_policy)) { ret = -1; goto bad_mapping; } /* Attempt to find matching policy data */ data = policy_cache_find_data(cache, map->issuerDomainPolicy); /* If we don't have anyPolicy can't map */ if (!data && !cache->anyPolicy) continue; /* Create a NODE from anyPolicy */ if (!data) { data = policy_data_new(NULL, map->issuerDomainPolicy, cache->anyPolicy->flags & POLICY_DATA_FLAG_CRITICAL); if (!data) goto bad_mapping; data->qualifier_set = cache->anyPolicy->qualifier_set; /*map->issuerDomainPolicy = NULL;*/ data->flags |= POLICY_DATA_FLAG_MAPPED_ANY; data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS; if (!sk_X509_POLICY_DATA_push(cache->data, data)) { policy_data_free(data); goto bad_mapping; } } else data->flags |= POLICY_DATA_FLAG_MAPPED; if (!sk_ASN1_OBJECT_push(data->expected_policy_set, map->subjectDomainPolicy)) goto bad_mapping; map->subjectDomainPolicy = NULL; } ret = 1; bad_mapping: if (ret == -1) x->ex_flags |= EXFLAG_INVALID_POLICY; sk_POLICY_MAPPING_pop_free(maps, POLICY_MAPPING_free); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_enum.c0000644000175000017500000001000212360020706020743 0ustar /* $OpenBSD: v3_enum.c,v 1.8 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include static ENUMERATED_NAMES crl_reasons[] = { {CRL_REASON_UNSPECIFIED, "Unspecified", "unspecified"}, {CRL_REASON_KEY_COMPROMISE, "Key Compromise", "keyCompromise"}, {CRL_REASON_CA_COMPROMISE, "CA Compromise", "CACompromise"}, {CRL_REASON_AFFILIATION_CHANGED, "Affiliation Changed", "affiliationChanged"}, {CRL_REASON_SUPERSEDED, "Superseded", "superseded"}, {CRL_REASON_CESSATION_OF_OPERATION, "Cessation Of Operation", "cessationOfOperation"}, {CRL_REASON_CERTIFICATE_HOLD, "Certificate Hold", "certificateHold"}, {CRL_REASON_REMOVE_FROM_CRL, "Remove From CRL", "removeFromCRL"}, {CRL_REASON_PRIVILEGE_WITHDRAWN, "Privilege Withdrawn", "privilegeWithdrawn"}, {CRL_REASON_AA_COMPROMISE, "AA Compromise", "AACompromise"}, {-1, NULL, NULL} }; const X509V3_EXT_METHOD v3_crl_reason = { NID_crl_reason, 0, ASN1_ITEM_ref(ASN1_ENUMERATED), 0, 0, 0, 0, (X509V3_EXT_I2S)i2s_ASN1_ENUMERATED_TABLE, 0, 0, 0, 0, 0, crl_reasons }; char * i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method, ASN1_ENUMERATED *e) { ENUMERATED_NAMES *enam; long strval; strval = ASN1_ENUMERATED_get(e); for (enam = method->usr_data; enam->lname; enam++) { if (strval == enam->bitnum) return BUF_strdup(enam->lname); } return i2s_ASN1_ENUMERATED(method, e); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_ia5.c0000644000175000017500000001033712360020706020470 0ustar /* $OpenBSD: v3_ia5.c,v 1.12 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include static char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5); static ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); const X509V3_EXT_METHOD v3_ns_ia5_list[] = { EXT_IA5STRING(NID_netscape_base_url), EXT_IA5STRING(NID_netscape_revocation_url), EXT_IA5STRING(NID_netscape_ca_revocation_url), EXT_IA5STRING(NID_netscape_renewal_url), EXT_IA5STRING(NID_netscape_ca_policy_url), EXT_IA5STRING(NID_netscape_ssl_server_name), EXT_IA5STRING(NID_netscape_comment), EXT_END }; static char * i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5) { char *tmp; if (!ia5 || !ia5->length) return NULL; if (!(tmp = malloc(ia5->length + 1))) { X509V3err(X509V3_F_I2S_ASN1_IA5STRING, ERR_R_MALLOC_FAILURE); return NULL; } memcpy(tmp, ia5->data, ia5->length); tmp[ia5->length] = 0; return tmp; } static ASN1_IA5STRING * s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str) { ASN1_IA5STRING *ia5; if (!str) { X509V3err(X509V3_F_S2I_ASN1_IA5STRING, X509V3_R_INVALID_NULL_ARGUMENT); return NULL; } if (!(ia5 = M_ASN1_IA5STRING_new())) goto err; if (!ASN1_STRING_set((ASN1_STRING *)ia5, (unsigned char*)str, strlen(str))) { M_ASN1_IA5STRING_free(ia5); goto err; } return ia5; err: X509V3err(X509V3_F_S2I_ASN1_IA5STRING, ERR_R_MALLOC_FAILURE); return NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_ncons.c0000644000175000017500000003317012360020706021132 0ustar /* $OpenBSD: v3_ncons.c,v 1.4 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ /* ==================================================================== * Copyright (c) 2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include static void *v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); static int i2r_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method, void *a, BIO *bp, int ind); static int do_i2r_name_constraints(const X509V3_EXT_METHOD *method, STACK_OF(GENERAL_SUBTREE) *trees, BIO *bp, int ind, char *name); static int print_nc_ipadd(BIO *bp, ASN1_OCTET_STRING *ip); static int nc_match(GENERAL_NAME *gen, NAME_CONSTRAINTS *nc); static int nc_match_single(GENERAL_NAME *sub, GENERAL_NAME *gen); static int nc_dn(X509_NAME *sub, X509_NAME *nm); static int nc_dns(ASN1_IA5STRING *sub, ASN1_IA5STRING *dns); static int nc_email(ASN1_IA5STRING *sub, ASN1_IA5STRING *eml); static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base); const X509V3_EXT_METHOD v3_name_constraints = { NID_name_constraints, 0, ASN1_ITEM_ref(NAME_CONSTRAINTS), 0, 0, 0, 0, 0, 0, 0, v2i_NAME_CONSTRAINTS, i2r_NAME_CONSTRAINTS, 0, NULL }; ASN1_SEQUENCE(GENERAL_SUBTREE) = { ASN1_SIMPLE(GENERAL_SUBTREE, base, GENERAL_NAME), ASN1_IMP_OPT(GENERAL_SUBTREE, minimum, ASN1_INTEGER, 0), ASN1_IMP_OPT(GENERAL_SUBTREE, maximum, ASN1_INTEGER, 1) } ASN1_SEQUENCE_END(GENERAL_SUBTREE) ASN1_SEQUENCE(NAME_CONSTRAINTS) = { ASN1_IMP_SEQUENCE_OF_OPT(NAME_CONSTRAINTS, permittedSubtrees, GENERAL_SUBTREE, 0), ASN1_IMP_SEQUENCE_OF_OPT(NAME_CONSTRAINTS, excludedSubtrees, GENERAL_SUBTREE, 1), } ASN1_SEQUENCE_END(NAME_CONSTRAINTS) IMPLEMENT_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) IMPLEMENT_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) static void * v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { int i; CONF_VALUE tval, *val; STACK_OF(GENERAL_SUBTREE) **ptree = NULL; NAME_CONSTRAINTS *ncons = NULL; GENERAL_SUBTREE *sub = NULL; ncons = NAME_CONSTRAINTS_new(); if (!ncons) goto memerr; for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { val = sk_CONF_VALUE_value(nval, i); if (!strncmp(val->name, "permitted", 9) && val->name[9]) { ptree = &ncons->permittedSubtrees; tval.name = val->name + 10; } else if (!strncmp(val->name, "excluded", 8) && val->name[8]) { ptree = &ncons->excludedSubtrees; tval.name = val->name + 9; } else { X509V3err(X509V3_F_V2I_NAME_CONSTRAINTS, X509V3_R_INVALID_SYNTAX); goto err; } tval.value = val->value; sub = GENERAL_SUBTREE_new(); if (!v2i_GENERAL_NAME_ex(sub->base, method, ctx, &tval, 1)) goto err; if (!*ptree) *ptree = sk_GENERAL_SUBTREE_new_null(); if (!*ptree || !sk_GENERAL_SUBTREE_push(*ptree, sub)) goto memerr; sub = NULL; } return ncons; memerr: X509V3err(X509V3_F_V2I_NAME_CONSTRAINTS, ERR_R_MALLOC_FAILURE); err: if (ncons) NAME_CONSTRAINTS_free(ncons); if (sub) GENERAL_SUBTREE_free(sub); return NULL; } static int i2r_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method, void *a, BIO *bp, int ind) { NAME_CONSTRAINTS *ncons = a; do_i2r_name_constraints(method, ncons->permittedSubtrees, bp, ind, "Permitted"); do_i2r_name_constraints(method, ncons->excludedSubtrees, bp, ind, "Excluded"); return 1; } static int do_i2r_name_constraints(const X509V3_EXT_METHOD *method, STACK_OF(GENERAL_SUBTREE) *trees, BIO *bp, int ind, char *name) { GENERAL_SUBTREE *tree; int i; if (sk_GENERAL_SUBTREE_num(trees) > 0) BIO_printf(bp, "%*s%s:\n", ind, "", name); for (i = 0; i < sk_GENERAL_SUBTREE_num(trees); i++) { tree = sk_GENERAL_SUBTREE_value(trees, i); BIO_printf(bp, "%*s", ind + 2, ""); if (tree->base->type == GEN_IPADD) print_nc_ipadd(bp, tree->base->d.ip); else GENERAL_NAME_print(bp, tree->base); BIO_puts(bp, "\n"); } return 1; } static int print_nc_ipadd(BIO *bp, ASN1_OCTET_STRING *ip) { int i, len; unsigned char *p; p = ip->data; len = ip->length; BIO_puts(bp, "IP:"); if (len == 8) { BIO_printf(bp, "%d.%d.%d.%d/%d.%d.%d.%d", p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); } else if (len == 32) { for (i = 0; i < 16; i++) { BIO_printf(bp, "%X", p[0] << 8 | p[1]); p += 2; if (i == 7) BIO_puts(bp, "/"); else if (i != 15) BIO_puts(bp, ":"); } } else BIO_printf(bp, "IP Address:"); return 1; } /* Check a certificate conforms to a specified set of constraints. * Return values: * X509_V_OK: All constraints obeyed. * X509_V_ERR_PERMITTED_VIOLATION: Permitted subtree violation. * X509_V_ERR_EXCLUDED_VIOLATION: Excluded subtree violation. * X509_V_ERR_SUBTREE_MINMAX: Min or max values present and matching type. * X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE: Unsupported constraint type. * X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX: bad unsupported constraint syntax. * X509_V_ERR_UNSUPPORTED_NAME_SYNTAX: bad or unsupported syntax of name */ int NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc) { int r, i; X509_NAME *nm; nm = X509_get_subject_name(x); if (X509_NAME_entry_count(nm) > 0) { GENERAL_NAME gntmp; gntmp.type = GEN_DIRNAME; gntmp.d.directoryName = nm; r = nc_match(&gntmp, nc); if (r != X509_V_OK) return r; gntmp.type = GEN_EMAIL; /* Process any email address attributes in subject name */ for (i = -1;;) { X509_NAME_ENTRY *ne; i = X509_NAME_get_index_by_NID(nm, NID_pkcs9_emailAddress, i); if (i == -1) break; ne = X509_NAME_get_entry(nm, i); gntmp.d.rfc822Name = X509_NAME_ENTRY_get_data(ne); if (gntmp.d.rfc822Name->type != V_ASN1_IA5STRING) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; r = nc_match(&gntmp, nc); if (r != X509_V_OK) return r; } } for (i = 0; i < sk_GENERAL_NAME_num(x->altname); i++) { GENERAL_NAME *gen = sk_GENERAL_NAME_value(x->altname, i); r = nc_match(gen, nc); if (r != X509_V_OK) return r; } return X509_V_OK; } static int nc_match(GENERAL_NAME *gen, NAME_CONSTRAINTS *nc) { GENERAL_SUBTREE *sub; int i, r, match = 0; /* Permitted subtrees: if any subtrees exist of matching the type * at least one subtree must match. */ for (i = 0; i < sk_GENERAL_SUBTREE_num(nc->permittedSubtrees); i++) { sub = sk_GENERAL_SUBTREE_value(nc->permittedSubtrees, i); if (gen->type != sub->base->type) continue; if (sub->minimum || sub->maximum) return X509_V_ERR_SUBTREE_MINMAX; /* If we already have a match don't bother trying any more */ if (match == 2) continue; if (match == 0) match = 1; r = nc_match_single(gen, sub->base); if (r == X509_V_OK) match = 2; else if (r != X509_V_ERR_PERMITTED_VIOLATION) return r; } if (match == 1) return X509_V_ERR_PERMITTED_VIOLATION; /* Excluded subtrees: must not match any of these */ for (i = 0; i < sk_GENERAL_SUBTREE_num(nc->excludedSubtrees); i++) { sub = sk_GENERAL_SUBTREE_value(nc->excludedSubtrees, i); if (gen->type != sub->base->type) continue; if (sub->minimum || sub->maximum) return X509_V_ERR_SUBTREE_MINMAX; r = nc_match_single(gen, sub->base); if (r == X509_V_OK) return X509_V_ERR_EXCLUDED_VIOLATION; else if (r != X509_V_ERR_PERMITTED_VIOLATION) return r; } return X509_V_OK; } static int nc_match_single(GENERAL_NAME *gen, GENERAL_NAME *base) { switch (base->type) { case GEN_DIRNAME: return nc_dn(gen->d.directoryName, base->d.directoryName); case GEN_DNS: return nc_dns(gen->d.dNSName, base->d.dNSName); case GEN_EMAIL: return nc_email(gen->d.rfc822Name, base->d.rfc822Name); case GEN_URI: return nc_uri(gen->d.uniformResourceIdentifier, base->d.uniformResourceIdentifier); default: return X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE; } } /* directoryName name constraint matching. * The canonical encoding of X509_NAME makes this comparison easy. It is * matched if the subtree is a subset of the name. */ static int nc_dn(X509_NAME *nm, X509_NAME *base) { /* Ensure canonical encodings are up to date. */ if (nm->modified && i2d_X509_NAME(nm, NULL) < 0) return X509_V_ERR_OUT_OF_MEM; if (base->modified && i2d_X509_NAME(base, NULL) < 0) return X509_V_ERR_OUT_OF_MEM; if (base->canon_enclen > nm->canon_enclen) return X509_V_ERR_PERMITTED_VIOLATION; if (memcmp(base->canon_enc, nm->canon_enc, base->canon_enclen)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; } static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base) { char *baseptr = (char *)base->data; char *dnsptr = (char *)dns->data; /* Empty matches everything */ if (!*baseptr) return X509_V_OK; /* Otherwise can add zero or more components on the left so * compare RHS and if dns is longer and expect '.' as preceding * character. */ if (dns->length > base->length) { dnsptr += dns->length - base->length; if (dnsptr[-1] != '.') return X509_V_ERR_PERMITTED_VIOLATION; } if (strcasecmp(baseptr, dnsptr)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; } static int nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base) { const char *baseptr = (char *)base->data; const char *emlptr = (char *)eml->data; const char *baseat = strchr(baseptr, '@'); const char *emlat = strchr(emlptr, '@'); if (!emlat) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; /* Special case: inital '.' is RHS match */ if (!baseat && (*baseptr == '.')) { if (eml->length > base->length) { emlptr += eml->length - base->length; if (!strcasecmp(baseptr, emlptr)) return X509_V_OK; } return X509_V_ERR_PERMITTED_VIOLATION; } /* If we have anything before '@' match local part */ if (baseat) { if (baseat != baseptr) { if ((baseat - baseptr) != (emlat - emlptr)) return X509_V_ERR_PERMITTED_VIOLATION; /* Case sensitive match of local part */ if (strncmp(baseptr, emlptr, emlat - emlptr)) return X509_V_ERR_PERMITTED_VIOLATION; } /* Position base after '@' */ baseptr = baseat + 1; } emlptr = emlat + 1; /* Just have hostname left to match: case insensitive */ if (strcasecmp(baseptr, emlptr)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; } static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) { const char *baseptr = (char *)base->data; const char *hostptr = (char *)uri->data; const char *p = strchr(hostptr, ':'); int hostlen; /* Check for foo:// and skip past it */ if (!p || (p[1] != '/') || (p[2] != '/')) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; hostptr = p + 3; /* Determine length of hostname part of URI */ /* Look for a port indicator as end of hostname first */ p = strchr(hostptr, ':'); /* Otherwise look for trailing slash */ if (!p) p = strchr(hostptr, '/'); if (!p) hostlen = strlen(hostptr); else hostlen = p - hostptr; if (hostlen == 0) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; /* Special case: inital '.' is RHS match */ if (*baseptr == '.') { if (hostlen > base->length) { p = hostptr + hostlen - base->length; if (!strncasecmp(p, baseptr, base->length)) return X509_V_OK; } return X509_V_ERR_PERMITTED_VIOLATION; } if ((base->length != (int)hostlen) || strncasecmp(hostptr, baseptr, hostlen)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_pku.c0000644000175000017500000001015212360020706020604 0ustar /* $OpenBSD: v3_pku.c,v 1.8 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, PKEY_USAGE_PERIOD *usage, BIO *out, int indent); /* static PKEY_USAGE_PERIOD *v2i_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values); */ const X509V3_EXT_METHOD v3_pkey_usage_period = { NID_private_key_usage_period, 0, ASN1_ITEM_ref(PKEY_USAGE_PERIOD), 0, 0, 0, 0, 0, 0, 0, 0, (X509V3_EXT_I2R)i2r_PKEY_USAGE_PERIOD, NULL, NULL }; ASN1_SEQUENCE(PKEY_USAGE_PERIOD) = { ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notBefore, ASN1_GENERALIZEDTIME, 0), ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notAfter, ASN1_GENERALIZEDTIME, 1) } ASN1_SEQUENCE_END(PKEY_USAGE_PERIOD) IMPLEMENT_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, PKEY_USAGE_PERIOD *usage, BIO *out, int indent) { BIO_printf(out, "%*s", indent, ""); if (usage->notBefore) { BIO_write(out, "Not Before: ", 12); ASN1_GENERALIZEDTIME_print(out, usage->notBefore); if (usage->notAfter) BIO_write(out, ", ", 2); } if (usage->notAfter) { BIO_write(out, "Not After: ", 11); ASN1_GENERALIZEDTIME_print(out, usage->notAfter); } return 1; } /* static PKEY_USAGE_PERIOD *v2i_PKEY_USAGE_PERIOD(method, ctx, values) X509V3_EXT_METHOD *method; X509V3_CTX *ctx; STACK_OF(CONF_VALUE) *values; { return NULL; } */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_conf.c0000644000175000017500000003507212360020706020742 0ustar /* $OpenBSD: v3_conf.c,v 1.14 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* extension creation utilities */ #include #include #include #include #include #include #include static int v3_check_critical(char **value); static int v3_check_generic(char **value); static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid, int crit, char *value); static X509_EXTENSION *v3_generic_extension(const char *ext, char *value, int crit, int type, X509V3_CTX *ctx); static char *conf_lhash_get_string(void *db, char *section, char *value); static STACK_OF(CONF_VALUE) *conf_lhash_get_section(void *db, char *section); static X509_EXTENSION *do_ext_i2d(const X509V3_EXT_METHOD *method, int ext_nid, int crit, void *ext_struc); static unsigned char *generic_asn1(char *value, X509V3_CTX *ctx, long *ext_len); /* CONF *conf: Config file */ /* char *name: Name */ /* char *value: Value */ X509_EXTENSION * X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, char *value) { int crit; int ext_type; X509_EXTENSION *ret; crit = v3_check_critical(&value); if ((ext_type = v3_check_generic(&value))) return v3_generic_extension(name, value, crit, ext_type, ctx); ret = do_ext_nconf(conf, ctx, OBJ_sn2nid(name), crit, value); if (!ret) { X509V3err(X509V3_F_X509V3_EXT_NCONF, X509V3_R_ERROR_IN_EXTENSION); ERR_asprintf_error_data("name=%s, value=%s", name, value); } return ret; } /* CONF *conf: Config file */ /* char *value: Value */ X509_EXTENSION * X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value) { int crit; int ext_type; crit = v3_check_critical(&value); if ((ext_type = v3_check_generic(&value))) return v3_generic_extension(OBJ_nid2sn(ext_nid), value, crit, ext_type, ctx); return do_ext_nconf(conf, ctx, ext_nid, crit, value); } /* CONF *conf: Config file */ /* char *value: Value */ static X509_EXTENSION * do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid, int crit, char *value) { const X509V3_EXT_METHOD *method; X509_EXTENSION *ext; STACK_OF(CONF_VALUE) *nval; void *ext_struc; if (ext_nid == NID_undef) { X509V3err(X509V3_F_DO_EXT_NCONF, X509V3_R_UNKNOWN_EXTENSION_NAME); return NULL; } if (!(method = X509V3_EXT_get_nid(ext_nid))) { X509V3err(X509V3_F_DO_EXT_NCONF, X509V3_R_UNKNOWN_EXTENSION); return NULL; } /* Now get internal extension representation based on type */ if (method->v2i) { if (*value == '@') nval = NCONF_get_section(conf, value + 1); else nval = X509V3_parse_list(value); if (sk_CONF_VALUE_num(nval) <= 0) { X509V3err(X509V3_F_DO_EXT_NCONF, X509V3_R_INVALID_EXTENSION_STRING); ERR_asprintf_error_data("name=%s,section=%s", OBJ_nid2sn(ext_nid), value); return NULL; } ext_struc = method->v2i(method, ctx, nval); if (*value != '@') sk_CONF_VALUE_pop_free(nval, X509V3_conf_free); if (!ext_struc) return NULL; } else if (method->s2i) { if (!(ext_struc = method->s2i(method, ctx, value))) return NULL; } else if (method->r2i) { if (!ctx->db || !ctx->db_meth) { X509V3err(X509V3_F_DO_EXT_NCONF, X509V3_R_NO_CONFIG_DATABASE); return NULL; } if (!(ext_struc = method->r2i(method, ctx, value))) return NULL; } else { X509V3err(X509V3_F_DO_EXT_NCONF, X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED); ERR_asprintf_error_data("name=%s", OBJ_nid2sn(ext_nid)); return NULL; } ext = do_ext_i2d(method, ext_nid, crit, ext_struc); if (method->it) ASN1_item_free(ext_struc, ASN1_ITEM_ptr(method->it)); else method->ext_free(ext_struc); return ext; } static X509_EXTENSION * do_ext_i2d(const X509V3_EXT_METHOD *method, int ext_nid, int crit, void *ext_struc) { unsigned char *ext_der; int ext_len; ASN1_OCTET_STRING *ext_oct; X509_EXTENSION *ext; /* Convert internal representation to DER */ if (method->it) { ext_der = NULL; ext_len = ASN1_item_i2d(ext_struc, &ext_der, ASN1_ITEM_ptr(method->it)); if (ext_len < 0) goto merr; } else { unsigned char *p; ext_len = method->i2d(ext_struc, NULL); if (!(ext_der = malloc(ext_len))) goto merr; p = ext_der; method->i2d(ext_struc, &p); } if (!(ext_oct = M_ASN1_OCTET_STRING_new())) goto merr; ext_oct->data = ext_der; ext_oct->length = ext_len; ext = X509_EXTENSION_create_by_NID(NULL, ext_nid, crit, ext_oct); if (!ext) goto merr; M_ASN1_OCTET_STRING_free(ext_oct); return ext; merr: X509V3err(X509V3_F_DO_EXT_I2D, ERR_R_MALLOC_FAILURE); return NULL; } /* Given an internal structure, nid and critical flag create an extension */ X509_EXTENSION * X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc) { const X509V3_EXT_METHOD *method; if (!(method = X509V3_EXT_get_nid(ext_nid))) { X509V3err(X509V3_F_X509V3_EXT_I2D, X509V3_R_UNKNOWN_EXTENSION); return NULL; } return do_ext_i2d(method, ext_nid, crit, ext_struc); } /* Check the extension string for critical flag */ static int v3_check_critical(char **value) { char *p = *value; if ((strlen(p) < 9) || strncmp(p, "critical,", 9)) return 0; p += 9; while (isspace((unsigned char)*p)) p++; *value = p; return 1; } /* Check extension string for generic extension and return the type */ static int v3_check_generic(char **value) { int gen_type = 0; char *p = *value; if ((strlen(p) >= 4) && !strncmp(p, "DER:", 4)) { p += 4; gen_type = 1; } else if ((strlen(p) >= 5) && !strncmp(p, "ASN1:", 5)) { p += 5; gen_type = 2; } else return 0; while (isspace((unsigned char)*p)) p++; *value = p; return gen_type; } /* Create a generic extension: for now just handle DER type */ static X509_EXTENSION * v3_generic_extension(const char *ext, char *value, int crit, int gen_type, X509V3_CTX *ctx) { unsigned char *ext_der = NULL; long ext_len; ASN1_OBJECT *obj = NULL; ASN1_OCTET_STRING *oct = NULL; X509_EXTENSION *extension = NULL; if (!(obj = OBJ_txt2obj(ext, 0))) { X509V3err(X509V3_F_V3_GENERIC_EXTENSION, X509V3_R_EXTENSION_NAME_ERROR); ERR_asprintf_error_data("name=%s", ext); goto err; } if (gen_type == 1) ext_der = string_to_hex(value, &ext_len); else if (gen_type == 2) ext_der = generic_asn1(value, ctx, &ext_len); if (ext_der == NULL) { X509V3err(X509V3_F_V3_GENERIC_EXTENSION, X509V3_R_EXTENSION_VALUE_ERROR); ERR_asprintf_error_data("value=%s", value); goto err; } if (!(oct = M_ASN1_OCTET_STRING_new())) { X509V3err(X509V3_F_V3_GENERIC_EXTENSION, ERR_R_MALLOC_FAILURE); goto err; } oct->data = ext_der; oct->length = ext_len; ext_der = NULL; extension = X509_EXTENSION_create_by_OBJ(NULL, obj, crit, oct); err: ASN1_OBJECT_free(obj); M_ASN1_OCTET_STRING_free(oct); free(ext_der); return extension; } static unsigned char * generic_asn1(char *value, X509V3_CTX *ctx, long *ext_len) { ASN1_TYPE *typ; unsigned char *ext_der = NULL; typ = ASN1_generate_v3(value, ctx); if (typ == NULL) return NULL; *ext_len = i2d_ASN1_TYPE(typ, &ext_der); ASN1_TYPE_free(typ); return ext_der; } /* This is the main function: add a bunch of extensions based on a config file * section to an extension STACK. */ int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, STACK_OF(X509_EXTENSION) **sk) { X509_EXTENSION *ext; STACK_OF(CONF_VALUE) *nval; CONF_VALUE *val; int i; if (!(nval = NCONF_get_section(conf, section))) return 0; for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { val = sk_CONF_VALUE_value(nval, i); if (!(ext = X509V3_EXT_nconf(conf, ctx, val->name, val->value))) return 0; if (sk) X509v3_add_ext(sk, ext, -1); X509_EXTENSION_free(ext); } return 1; } /* Convenience functions to add extensions to a certificate, CRL and request */ int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert) { STACK_OF(X509_EXTENSION) **sk = NULL; if (cert) sk = &cert->cert_info->extensions; return X509V3_EXT_add_nconf_sk(conf, ctx, section, sk); } /* Same as above but for a CRL */ int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl) { STACK_OF(X509_EXTENSION) **sk = NULL; if (crl) sk = &crl->crl->extensions; return X509V3_EXT_add_nconf_sk(conf, ctx, section, sk); } /* Add extensions to certificate request */ int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req) { STACK_OF(X509_EXTENSION) *extlist = NULL, **sk = NULL; int i; if (req) sk = &extlist; i = X509V3_EXT_add_nconf_sk(conf, ctx, section, sk); if (!i || !sk) return i; i = X509_REQ_add_extensions(req, extlist); sk_X509_EXTENSION_pop_free(extlist, X509_EXTENSION_free); return i; } /* Config database functions */ char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section) { if (!ctx->db || !ctx->db_meth || !ctx->db_meth->get_string) { X509V3err(X509V3_F_X509V3_GET_STRING, X509V3_R_OPERATION_NOT_DEFINED); return NULL; } if (ctx->db_meth->get_string) return ctx->db_meth->get_string(ctx->db, name, section); return NULL; } STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section) { if (!ctx->db || !ctx->db_meth || !ctx->db_meth->get_section) { X509V3err(X509V3_F_X509V3_GET_SECTION, X509V3_R_OPERATION_NOT_DEFINED); return NULL; } if (ctx->db_meth->get_section) return ctx->db_meth->get_section(ctx->db, section); return NULL; } void X509V3_string_free(X509V3_CTX *ctx, char *str) { if (!str) return; if (ctx->db_meth->free_string) ctx->db_meth->free_string(ctx->db, str); } void X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section) { if (!section) return; if (ctx->db_meth->free_section) ctx->db_meth->free_section(ctx->db, section); } static char * nconf_get_string(void *db, char *section, char *value) { return NCONF_get_string(db, section, value); } static STACK_OF(CONF_VALUE) *nconf_get_section(void *db, char *section) { return NCONF_get_section(db, section); } static X509V3_CONF_METHOD nconf_method = { nconf_get_string, nconf_get_section, NULL, NULL }; void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf) { ctx->db_meth = &nconf_method; ctx->db = conf; } void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subj, X509_REQ *req, X509_CRL *crl, int flags) { ctx->issuer_cert = issuer; ctx->subject_cert = subj; ctx->crl = crl; ctx->subject_req = req; ctx->flags = flags; } /* Old conf compatibility functions */ X509_EXTENSION * X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, char *name, char *value) { CONF ctmp; CONF_set_nconf(&ctmp, conf); return X509V3_EXT_nconf(&ctmp, ctx, name, value); } /* LHASH *conf: Config file */ /* char *value: Value */ X509_EXTENSION * X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, int ext_nid, char *value) { CONF ctmp; CONF_set_nconf(&ctmp, conf); return X509V3_EXT_nconf_nid(&ctmp, ctx, ext_nid, value); } static char * conf_lhash_get_string(void *db, char *section, char *value) { return CONF_get_string(db, section, value); } static STACK_OF(CONF_VALUE) * conf_lhash_get_section(void *db, char *section) { return CONF_get_section(db, section); } static X509V3_CONF_METHOD conf_lhash_method = { conf_lhash_get_string, conf_lhash_get_section, NULL, NULL }; void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash) { ctx->db_meth = &conf_lhash_method; ctx->db = lhash; } int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, char *section, X509 *cert) { CONF ctmp; CONF_set_nconf(&ctmp, conf); return X509V3_EXT_add_nconf(&ctmp, ctx, section, cert); } /* Same as above but for a CRL */ int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl) { CONF ctmp; CONF_set_nconf(&ctmp, conf); return X509V3_EXT_CRL_add_nconf(&ctmp, ctx, section, crl); } /* Add extensions to certificate request */ int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, char *section, X509_REQ *req) { CONF ctmp; CONF_set_nconf(&ctmp, conf); return X509V3_EXT_REQ_add_nconf(&ctmp, ctx, section, req); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_crld.c0000644000175000017500000003634112360020706020741 0ustar /* $OpenBSD: v3_crld.c,v 1.11 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include static void *v2i_crld(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); static int i2r_crldp(const X509V3_EXT_METHOD *method, void *pcrldp, BIO *out, int indent); const X509V3_EXT_METHOD v3_crld = { NID_crl_distribution_points, 0, ASN1_ITEM_ref(CRL_DIST_POINTS), 0, 0, 0, 0, 0, 0, 0, v2i_crld, i2r_crldp, 0, NULL }; const X509V3_EXT_METHOD v3_freshest_crl = { NID_freshest_crl, 0, ASN1_ITEM_ref(CRL_DIST_POINTS), 0, 0, 0, 0, 0, 0, 0, v2i_crld, i2r_crldp, 0, NULL }; static STACK_OF(GENERAL_NAME) *gnames_from_sectname(X509V3_CTX *ctx, char *sect) { STACK_OF(CONF_VALUE) *gnsect; STACK_OF(GENERAL_NAME) *gens; if (*sect == '@') gnsect = X509V3_get_section(ctx, sect + 1); else gnsect = X509V3_parse_list(sect); if (!gnsect) { X509V3err(X509V3_F_GNAMES_FROM_SECTNAME, X509V3_R_SECTION_NOT_FOUND); return NULL; } gens = v2i_GENERAL_NAMES(NULL, ctx, gnsect); if (*sect == '@') X509V3_section_free(ctx, gnsect); else sk_CONF_VALUE_pop_free(gnsect, X509V3_conf_free); return gens; } static int set_dist_point_name(DIST_POINT_NAME **pdp, X509V3_CTX *ctx, CONF_VALUE *cnf) { STACK_OF(GENERAL_NAME) *fnm = NULL; STACK_OF(X509_NAME_ENTRY) *rnm = NULL; if (!strncmp(cnf->name, "fullname", 9)) { fnm = gnames_from_sectname(ctx, cnf->value); if (!fnm) goto err; } else if (!strcmp(cnf->name, "relativename")) { int ret; STACK_OF(CONF_VALUE) *dnsect; X509_NAME *nm; nm = X509_NAME_new(); if (!nm) return -1; dnsect = X509V3_get_section(ctx, cnf->value); if (!dnsect) { X509V3err(X509V3_F_SET_DIST_POINT_NAME, X509V3_R_SECTION_NOT_FOUND); return -1; } ret = X509V3_NAME_from_section(nm, dnsect, MBSTRING_ASC); X509V3_section_free(ctx, dnsect); rnm = nm->entries; nm->entries = NULL; X509_NAME_free(nm); if (!ret || sk_X509_NAME_ENTRY_num(rnm) <= 0) goto err; /* Since its a name fragment can't have more than one * RDNSequence */ if (sk_X509_NAME_ENTRY_value(rnm, sk_X509_NAME_ENTRY_num(rnm) - 1)->set) { X509V3err(X509V3_F_SET_DIST_POINT_NAME, X509V3_R_INVALID_MULTIPLE_RDNS); goto err; } } else return 0; if (*pdp) { X509V3err(X509V3_F_SET_DIST_POINT_NAME, X509V3_R_DISTPOINT_ALREADY_SET); goto err; } *pdp = DIST_POINT_NAME_new(); if (!*pdp) goto err; if (fnm) { (*pdp)->type = 0; (*pdp)->name.fullname = fnm; } else { (*pdp)->type = 1; (*pdp)->name.relativename = rnm; } return 1; err: if (fnm) sk_GENERAL_NAME_pop_free(fnm, GENERAL_NAME_free); if (rnm) sk_X509_NAME_ENTRY_pop_free(rnm, X509_NAME_ENTRY_free); return -1; } static const BIT_STRING_BITNAME reason_flags[] = { {0, "Unused", "unused"}, {1, "Key Compromise", "keyCompromise"}, {2, "CA Compromise", "CACompromise"}, {3, "Affiliation Changed", "affiliationChanged"}, {4, "Superseded", "superseded"}, {5, "Cessation Of Operation", "cessationOfOperation"}, {6, "Certificate Hold", "certificateHold"}, {7, "Privilege Withdrawn", "privilegeWithdrawn"}, {8, "AA Compromise", "AACompromise"}, {-1, NULL, NULL} }; static int set_reasons(ASN1_BIT_STRING **preas, char *value) { STACK_OF(CONF_VALUE) *rsk = NULL; const BIT_STRING_BITNAME *pbn; const char *bnam; int i, ret = 0; rsk = X509V3_parse_list(value); if (!rsk) return 0; if (*preas) return 0; for (i = 0; i < sk_CONF_VALUE_num(rsk); i++) { bnam = sk_CONF_VALUE_value(rsk, i)->name; if (!*preas) { *preas = ASN1_BIT_STRING_new(); if (!*preas) goto err; } for (pbn = reason_flags; pbn->lname; pbn++) { if (!strcmp(pbn->sname, bnam)) { if (!ASN1_BIT_STRING_set_bit(*preas, pbn->bitnum, 1)) goto err; break; } } if (!pbn->lname) goto err; } ret = 1; err: sk_CONF_VALUE_pop_free(rsk, X509V3_conf_free); return ret; } static int print_reasons(BIO *out, const char *rname, ASN1_BIT_STRING *rflags, int indent) { int first = 1; const BIT_STRING_BITNAME *pbn; BIO_printf(out, "%*s%s:\n%*s", indent, "", rname, indent + 2, ""); for (pbn = reason_flags; pbn->lname; pbn++) { if (ASN1_BIT_STRING_get_bit(rflags, pbn->bitnum)) { if (first) first = 0; else BIO_puts(out, ", "); BIO_puts(out, pbn->lname); } } if (first) BIO_puts(out, "\n"); else BIO_puts(out, "\n"); return 1; } static DIST_POINT * crldp_from_section(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { int i; CONF_VALUE *cnf; DIST_POINT *point = NULL; point = DIST_POINT_new(); if (!point) goto err; for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { int ret; cnf = sk_CONF_VALUE_value(nval, i); ret = set_dist_point_name(&point->distpoint, ctx, cnf); if (ret > 0) continue; if (ret < 0) goto err; if (!strcmp(cnf->name, "reasons")) { if (!set_reasons(&point->reasons, cnf->value)) goto err; } else if (!strcmp(cnf->name, "CRLissuer")) { point->CRLissuer = gnames_from_sectname(ctx, cnf->value); if (!point->CRLissuer) goto err; } } return point; err: if (point) DIST_POINT_free(point); return NULL; } static void * v2i_crld(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { STACK_OF(DIST_POINT) *crld = NULL; GENERAL_NAMES *gens = NULL; GENERAL_NAME *gen = NULL; CONF_VALUE *cnf; int i; if (!(crld = sk_DIST_POINT_new_null())) goto merr; for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { DIST_POINT *point; cnf = sk_CONF_VALUE_value(nval, i); if (!cnf->value) { STACK_OF(CONF_VALUE) *dpsect; dpsect = X509V3_get_section(ctx, cnf->name); if (!dpsect) goto err; point = crldp_from_section(ctx, dpsect); X509V3_section_free(ctx, dpsect); if (!point) goto err; if (!sk_DIST_POINT_push(crld, point)) { DIST_POINT_free(point); goto merr; } } else { if (!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) goto err; if (!(gens = GENERAL_NAMES_new())) goto merr; if (!sk_GENERAL_NAME_push(gens, gen)) goto merr; gen = NULL; if (!(point = DIST_POINT_new())) goto merr; if (!sk_DIST_POINT_push(crld, point)) { DIST_POINT_free(point); goto merr; } if (!(point->distpoint = DIST_POINT_NAME_new())) goto merr; point->distpoint->name.fullname = gens; point->distpoint->type = 0; gens = NULL; } } return crld; merr: X509V3err(X509V3_F_V2I_CRLD, ERR_R_MALLOC_FAILURE); err: GENERAL_NAME_free(gen); GENERAL_NAMES_free(gens); sk_DIST_POINT_pop_free(crld, DIST_POINT_free); return NULL; } IMPLEMENT_STACK_OF(DIST_POINT) IMPLEMENT_ASN1_SET_OF(DIST_POINT) static int dpn_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { DIST_POINT_NAME *dpn = (DIST_POINT_NAME *)*pval; switch (operation) { case ASN1_OP_NEW_POST: dpn->dpname = NULL; break; case ASN1_OP_FREE_POST: if (dpn->dpname) X509_NAME_free(dpn->dpname); break; } return 1; } ASN1_CHOICE_cb(DIST_POINT_NAME, dpn_cb) = { ASN1_IMP_SEQUENCE_OF(DIST_POINT_NAME, name.fullname, GENERAL_NAME, 0), ASN1_IMP_SET_OF(DIST_POINT_NAME, name.relativename, X509_NAME_ENTRY, 1) } ASN1_CHOICE_END_cb(DIST_POINT_NAME, DIST_POINT_NAME, type) IMPLEMENT_ASN1_FUNCTIONS(DIST_POINT_NAME) ASN1_SEQUENCE(DIST_POINT) = { ASN1_EXP_OPT(DIST_POINT, distpoint, DIST_POINT_NAME, 0), ASN1_IMP_OPT(DIST_POINT, reasons, ASN1_BIT_STRING, 1), ASN1_IMP_SEQUENCE_OF_OPT(DIST_POINT, CRLissuer, GENERAL_NAME, 2) } ASN1_SEQUENCE_END(DIST_POINT) IMPLEMENT_ASN1_FUNCTIONS(DIST_POINT) ASN1_ITEM_TEMPLATE(CRL_DIST_POINTS) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, CRLDistributionPoints, DIST_POINT) ASN1_ITEM_TEMPLATE_END(CRL_DIST_POINTS) IMPLEMENT_ASN1_FUNCTIONS(CRL_DIST_POINTS) ASN1_SEQUENCE(ISSUING_DIST_POINT) = { ASN1_EXP_OPT(ISSUING_DIST_POINT, distpoint, DIST_POINT_NAME, 0), ASN1_IMP_OPT(ISSUING_DIST_POINT, onlyuser, ASN1_FBOOLEAN, 1), ASN1_IMP_OPT(ISSUING_DIST_POINT, onlyCA, ASN1_FBOOLEAN, 2), ASN1_IMP_OPT(ISSUING_DIST_POINT, onlysomereasons, ASN1_BIT_STRING, 3), ASN1_IMP_OPT(ISSUING_DIST_POINT, indirectCRL, ASN1_FBOOLEAN, 4), ASN1_IMP_OPT(ISSUING_DIST_POINT, onlyattr, ASN1_FBOOLEAN, 5) } ASN1_SEQUENCE_END(ISSUING_DIST_POINT) IMPLEMENT_ASN1_FUNCTIONS(ISSUING_DIST_POINT) static int i2r_idp(const X509V3_EXT_METHOD *method, void *pidp, BIO *out, int indent); static void *v2i_idp(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); const X509V3_EXT_METHOD v3_idp = { NID_issuing_distribution_point, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(ISSUING_DIST_POINT), 0, 0, 0, 0, 0, 0, 0, v2i_idp, i2r_idp, 0, NULL }; static void * v2i_idp(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { ISSUING_DIST_POINT *idp = NULL; CONF_VALUE *cnf; char *name, *val; int i, ret; idp = ISSUING_DIST_POINT_new(); if (!idp) goto merr; for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { cnf = sk_CONF_VALUE_value(nval, i); name = cnf->name; val = cnf->value; ret = set_dist_point_name(&idp->distpoint, ctx, cnf); if (ret > 0) continue; if (ret < 0) goto err; if (!strcmp(name, "onlyuser")) { if (!X509V3_get_value_bool(cnf, &idp->onlyuser)) goto err; } else if (!strcmp(name, "onlyCA")) { if (!X509V3_get_value_bool(cnf, &idp->onlyCA)) goto err; } else if (!strcmp(name, "onlyAA")) { if (!X509V3_get_value_bool(cnf, &idp->onlyattr)) goto err; } else if (!strcmp(name, "indirectCRL")) { if (!X509V3_get_value_bool(cnf, &idp->indirectCRL)) goto err; } else if (!strcmp(name, "onlysomereasons")) { if (!set_reasons(&idp->onlysomereasons, val)) goto err; } else { X509V3err(X509V3_F_V2I_IDP, X509V3_R_INVALID_NAME); X509V3_conf_err(cnf); goto err; } } return idp; merr: X509V3err(X509V3_F_V2I_IDP, ERR_R_MALLOC_FAILURE); err: ISSUING_DIST_POINT_free(idp); return NULL; } static int print_gens(BIO *out, STACK_OF(GENERAL_NAME) *gens, int indent) { int i; for (i = 0; i < sk_GENERAL_NAME_num(gens); i++) { BIO_printf(out, "%*s", indent + 2, ""); GENERAL_NAME_print(out, sk_GENERAL_NAME_value(gens, i)); BIO_puts(out, "\n"); } return 1; } static int print_distpoint(BIO *out, DIST_POINT_NAME *dpn, int indent) { if (dpn->type == 0) { BIO_printf(out, "%*sFull Name:\n", indent, ""); print_gens(out, dpn->name.fullname, indent); } else { X509_NAME ntmp; ntmp.entries = dpn->name.relativename; BIO_printf(out, "%*sRelative Name:\n%*s", indent, "", indent + 2, ""); X509_NAME_print_ex(out, &ntmp, 0, XN_FLAG_ONELINE); BIO_puts(out, "\n"); } return 1; } static int i2r_idp(const X509V3_EXT_METHOD *method, void *pidp, BIO *out, int indent) { ISSUING_DIST_POINT *idp = pidp; if (idp->distpoint) print_distpoint(out, idp->distpoint, indent); if (idp->onlyuser > 0) BIO_printf(out, "%*sOnly User Certificates\n", indent, ""); if (idp->onlyCA > 0) BIO_printf(out, "%*sOnly CA Certificates\n", indent, ""); if (idp->indirectCRL > 0) BIO_printf(out, "%*sIndirect CRL\n", indent, ""); if (idp->onlysomereasons) print_reasons(out, "Only Some Reasons", idp->onlysomereasons, indent); if (idp->onlyattr > 0) BIO_printf(out, "%*sOnly Attribute Certificates\n", indent, ""); if (!idp->distpoint && (idp->onlyuser <= 0) && (idp->onlyCA <= 0) && (idp->indirectCRL <= 0) && !idp->onlysomereasons && (idp->onlyattr <= 0)) BIO_printf(out, "%*s\n", indent, ""); return 1; } static int i2r_crldp(const X509V3_EXT_METHOD *method, void *pcrldp, BIO *out, int indent) { STACK_OF(DIST_POINT) *crld = pcrldp; DIST_POINT *point; int i; for (i = 0; i < sk_DIST_POINT_num(crld); i++) { BIO_puts(out, "\n"); point = sk_DIST_POINT_value(crld, i); if (point->distpoint) print_distpoint(out, point->distpoint, indent); if (point->reasons) print_reasons(out, "Reasons", point->reasons, indent); if (point->CRLissuer) { BIO_printf(out, "%*sCRL Issuer:\n", indent, ""); print_gens(out, point->CRLissuer, indent); } } return 1; } int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname) { int i; STACK_OF(X509_NAME_ENTRY) *frag; X509_NAME_ENTRY *ne; if (!dpn || (dpn->type != 1)) return 1; frag = dpn->name.relativename; dpn->dpname = X509_NAME_dup(iname); if (!dpn->dpname) return 0; for (i = 0; i < sk_X509_NAME_ENTRY_num(frag); i++) { ne = sk_X509_NAME_ENTRY_value(frag, i); if (!X509_NAME_add_entry(dpn->dpname, ne, -1, i ? 0 : 1)) { X509_NAME_free(dpn->dpname); dpn->dpname = NULL; return 0; } } /* generate cached encoding of name */ if (i2d_X509_NAME(dpn->dpname, NULL) < 0) { X509_NAME_free(dpn->dpname); dpn->dpname = NULL; return 0; } return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_pcons.c0000644000175000017500000001201712360020706021131 0ustar /* $OpenBSD: v3_pcons.c,v 1.4 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ /* ==================================================================== * Copyright (c) 2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include static STACK_OF(CONF_VALUE) * i2v_POLICY_CONSTRAINTS(const X509V3_EXT_METHOD *method, void *bcons, STACK_OF(CONF_VALUE) *extlist); static void *v2i_POLICY_CONSTRAINTS(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values); const X509V3_EXT_METHOD v3_policy_constraints = { NID_policy_constraints, 0, ASN1_ITEM_ref(POLICY_CONSTRAINTS), 0, 0, 0, 0, 0, 0, i2v_POLICY_CONSTRAINTS, v2i_POLICY_CONSTRAINTS, NULL, NULL, NULL }; ASN1_SEQUENCE(POLICY_CONSTRAINTS) = { ASN1_IMP_OPT(POLICY_CONSTRAINTS, requireExplicitPolicy, ASN1_INTEGER, 0), ASN1_IMP_OPT(POLICY_CONSTRAINTS, inhibitPolicyMapping, ASN1_INTEGER, 1) } ASN1_SEQUENCE_END(POLICY_CONSTRAINTS) IMPLEMENT_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS) static STACK_OF(CONF_VALUE) * i2v_POLICY_CONSTRAINTS(const X509V3_EXT_METHOD *method, void *a, STACK_OF(CONF_VALUE) *extlist) { POLICY_CONSTRAINTS *pcons = a; X509V3_add_value_int("Require Explicit Policy", pcons->requireExplicitPolicy, &extlist); X509V3_add_value_int("Inhibit Policy Mapping", pcons->inhibitPolicyMapping, &extlist); return extlist; } static void * v2i_POLICY_CONSTRAINTS(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values) { POLICY_CONSTRAINTS *pcons = NULL; CONF_VALUE *val; int i; if (!(pcons = POLICY_CONSTRAINTS_new())) { X509V3err(X509V3_F_V2I_POLICY_CONSTRAINTS, ERR_R_MALLOC_FAILURE); return NULL; } for (i = 0; i < sk_CONF_VALUE_num(values); i++) { val = sk_CONF_VALUE_value(values, i); if (!strcmp(val->name, "requireExplicitPolicy")) { if (!X509V3_get_value_int(val, &pcons->requireExplicitPolicy)) goto err; } else if (!strcmp(val->name, "inhibitPolicyMapping")) { if (!X509V3_get_value_int(val, &pcons->inhibitPolicyMapping)) goto err; } else { X509V3err(X509V3_F_V2I_POLICY_CONSTRAINTS, X509V3_R_INVALID_NAME); X509V3_conf_err(val); goto err; } } if (!pcons->inhibitPolicyMapping && !pcons->requireExplicitPolicy) { X509V3err(X509V3_F_V2I_POLICY_CONSTRAINTS, X509V3_R_ILLEGAL_EMPTY_EXTENSION); goto err; } return pcons; err: POLICY_CONSTRAINTS_free(pcons); return NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_sxnet.c0000644000175000017500000001744312360020706021160 0ustar /* $OpenBSD: v3_sxnet.c,v 1.10 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include /* Support for Thawte strong extranet extension */ #define SXNET_TEST static int sxnet_i2r(X509V3_EXT_METHOD *method, SXNET *sx, BIO *out, int indent); #ifdef SXNET_TEST static SXNET * sxnet_v2i(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); #endif const X509V3_EXT_METHOD v3_sxnet = { NID_sxnet, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(SXNET), 0, 0, 0, 0, 0, 0, 0, #ifdef SXNET_TEST (X509V3_EXT_V2I)sxnet_v2i, #else 0, #endif (X509V3_EXT_I2R)sxnet_i2r, 0, NULL }; ASN1_SEQUENCE(SXNETID) = { ASN1_SIMPLE(SXNETID, zone, ASN1_INTEGER), ASN1_SIMPLE(SXNETID, user, ASN1_OCTET_STRING) } ASN1_SEQUENCE_END(SXNETID) IMPLEMENT_ASN1_FUNCTIONS(SXNETID) ASN1_SEQUENCE(SXNET) = { ASN1_SIMPLE(SXNET, version, ASN1_INTEGER), ASN1_SEQUENCE_OF(SXNET, ids, SXNETID) } ASN1_SEQUENCE_END(SXNET) IMPLEMENT_ASN1_FUNCTIONS(SXNET) static int sxnet_i2r(X509V3_EXT_METHOD *method, SXNET *sx, BIO *out, int indent) { long v; char *tmp; SXNETID *id; int i; v = ASN1_INTEGER_get(sx->version); BIO_printf(out, "%*sVersion: %ld (0x%lX)", indent, "", v + 1, v); for (i = 0; i < sk_SXNETID_num(sx->ids); i++) { id = sk_SXNETID_value(sx->ids, i); tmp = i2s_ASN1_INTEGER(NULL, id->zone); BIO_printf(out, "\n%*sZone: %s, User: ", indent, "", tmp); free(tmp); M_ASN1_OCTET_STRING_print(out, id->user); } return 1; } #ifdef SXNET_TEST /* NBB: this is used for testing only. It should *not* be used for anything * else because it will just take static IDs from the configuration file and * they should really be separate values for each user. */ static SXNET * sxnet_v2i(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { CONF_VALUE *cnf; SXNET *sx = NULL; int i; for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { cnf = sk_CONF_VALUE_value(nval, i); if (!SXNET_add_id_asc(&sx, cnf->name, cnf->value, -1)) return NULL; } return sx; } #endif /* Strong Extranet utility functions */ /* Add an id given the zone as an ASCII number */ int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen) { ASN1_INTEGER *izone = NULL; if (!(izone = s2i_ASN1_INTEGER(NULL, zone))) { X509V3err(X509V3_F_SXNET_ADD_ID_ASC, X509V3_R_ERROR_CONVERTING_ZONE); return 0; } return SXNET_add_id_INTEGER(psx, izone, user, userlen); } /* Add an id given the zone as an unsigned long */ int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen) { ASN1_INTEGER *izone = NULL; if (!(izone = M_ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) { X509V3err(X509V3_F_SXNET_ADD_ID_ULONG, ERR_R_MALLOC_FAILURE); M_ASN1_INTEGER_free(izone); return 0; } return SXNET_add_id_INTEGER(psx, izone, user, userlen); } /* Add an id given the zone as an ASN1_INTEGER. * Note this version uses the passed integer and doesn't make a copy so don't * free it up afterwards. */ int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *zone, char *user, int userlen) { SXNET *sx = NULL; SXNETID *id = NULL; if (!psx || !zone || !user) { X509V3err(X509V3_F_SXNET_ADD_ID_INTEGER, X509V3_R_INVALID_NULL_ARGUMENT); return 0; } if (userlen == -1) userlen = strlen(user); if (userlen > 64) { X509V3err(X509V3_F_SXNET_ADD_ID_INTEGER, X509V3_R_USER_TOO_LONG); return 0; } if (!*psx) { if (!(sx = SXNET_new())) goto err; if (!ASN1_INTEGER_set(sx->version, 0)) goto err; *psx = sx; } else sx = *psx; if (SXNET_get_id_INTEGER(sx, zone)) { X509V3err(X509V3_F_SXNET_ADD_ID_INTEGER, X509V3_R_DUPLICATE_ZONE_ID); return 0; } if (!(id = SXNETID_new())) goto err; if (userlen == -1) userlen = strlen(user); if (!M_ASN1_OCTET_STRING_set(id->user, user, userlen)) goto err; if (!sk_SXNETID_push(sx->ids, id)) goto err; id->zone = zone; return 1; err: X509V3err(X509V3_F_SXNET_ADD_ID_INTEGER, ERR_R_MALLOC_FAILURE); SXNETID_free(id); SXNET_free(sx); *psx = NULL; return 0; } ASN1_OCTET_STRING * SXNET_get_id_asc(SXNET *sx, char *zone) { ASN1_INTEGER *izone = NULL; ASN1_OCTET_STRING *oct; if (!(izone = s2i_ASN1_INTEGER(NULL, zone))) { X509V3err(X509V3_F_SXNET_GET_ID_ASC, X509V3_R_ERROR_CONVERTING_ZONE); return NULL; } oct = SXNET_get_id_INTEGER(sx, izone); M_ASN1_INTEGER_free(izone); return oct; } ASN1_OCTET_STRING * SXNET_get_id_ulong(SXNET *sx, unsigned long lzone) { ASN1_INTEGER *izone = NULL; ASN1_OCTET_STRING *oct; if (!(izone = M_ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) { X509V3err(X509V3_F_SXNET_GET_ID_ULONG, ERR_R_MALLOC_FAILURE); M_ASN1_INTEGER_free(izone); return NULL; } oct = SXNET_get_id_INTEGER(sx, izone); M_ASN1_INTEGER_free(izone); return oct; } ASN1_OCTET_STRING * SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone) { SXNETID *id; int i; for (i = 0; i < sk_SXNETID_num(sx->ids); i++) { id = sk_SXNETID_value(sx->ids, i); if (!M_ASN1_INTEGER_cmp(id->zone, zone)) return id->user; } return NULL; } IMPLEMENT_STACK_OF(SXNETID) IMPLEMENT_ASN1_SET_OF(SXNETID) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/pcy_lib.c0000644000175000017500000001111712360020706021020 0ustar /* $OpenBSD: pcy_lib.c,v 1.3 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "pcy_int.h" /* accessor functions */ /* X509_POLICY_TREE stuff */ int X509_policy_tree_level_count(const X509_POLICY_TREE *tree) { if (!tree) return 0; return tree->nlevel; } X509_POLICY_LEVEL * X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i) { if (!tree || (i < 0) || (i >= tree->nlevel)) return NULL; return tree->levels + i; } STACK_OF(X509_POLICY_NODE) * X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree) { if (!tree) return NULL; return tree->auth_policies; } STACK_OF(X509_POLICY_NODE) * X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree) { if (!tree) return NULL; if (tree->flags & POLICY_FLAG_ANY_POLICY) return tree->auth_policies; else return tree->user_policies; } /* X509_POLICY_LEVEL stuff */ int X509_policy_level_node_count(X509_POLICY_LEVEL *level) { int n; if (!level) return 0; if (level->anyPolicy) n = 1; else n = 0; if (level->nodes) n += sk_X509_POLICY_NODE_num(level->nodes); return n; } X509_POLICY_NODE * X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i) { if (!level) return NULL; if (level->anyPolicy) { if (i == 0) return level->anyPolicy; i--; } return sk_X509_POLICY_NODE_value(level->nodes, i); } /* X509_POLICY_NODE stuff */ const ASN1_OBJECT * X509_policy_node_get0_policy(const X509_POLICY_NODE *node) { if (!node) return NULL; return node->data->valid_policy; } #if 0 int X509_policy_node_get_critical(const X509_POLICY_NODE *node) { if (node_critical(node)) return 1; return 0; } #endif STACK_OF(POLICYQUALINFO) * X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node) { if (!node) return NULL; return node->data->qualifier_set; } const X509_POLICY_NODE * X509_policy_node_get0_parent(const X509_POLICY_NODE *node) { if (!node) return NULL; return node->parent; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_utl.c0000644000175000017500000005013612360020706020617 0ustar /* $OpenBSD: v3_utl.c,v 1.21 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ /* ==================================================================== * Copyright (c) 1999-2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* X509 v3 extension utilities */ #include #include #include #include #include #include #include static char *strip_spaces(char *name); static int sk_strcmp(const char * const *a, const char * const *b); static STACK_OF(OPENSSL_STRING) *get_email(X509_NAME *name, GENERAL_NAMES *gens); static void str_free(OPENSSL_STRING str); static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, ASN1_IA5STRING *email); static int ipv4_from_asc(unsigned char *v4, const char *in); static int ipv6_from_asc(unsigned char *v6, const char *in); static int ipv6_cb(const char *elem, int len, void *usr); static int ipv6_hex(unsigned char *out, const char *in, int inlen); /* Add a CONF_VALUE name value pair to stack */ int X509V3_add_value(const char *name, const char *value, STACK_OF(CONF_VALUE) **extlist) { CONF_VALUE *vtmp = NULL; char *tname = NULL, *tvalue = NULL; if (name && !(tname = BUF_strdup(name))) goto err; if (value && !(tvalue = BUF_strdup(value))) goto err; if (!(vtmp = malloc(sizeof(CONF_VALUE)))) goto err; if (!*extlist && !(*extlist = sk_CONF_VALUE_new_null())) goto err; vtmp->section = NULL; vtmp->name = tname; vtmp->value = tvalue; if (!sk_CONF_VALUE_push(*extlist, vtmp)) goto err; return 1; err: X509V3err(X509V3_F_X509V3_ADD_VALUE, ERR_R_MALLOC_FAILURE); free(vtmp); free(tname); free(tvalue); return 0; } int X509V3_add_value_uchar(const char *name, const unsigned char *value, STACK_OF(CONF_VALUE) **extlist) { return X509V3_add_value(name, (const char *)value, extlist); } /* Free function for STACK_OF(CONF_VALUE) */ void X509V3_conf_free(CONF_VALUE *conf) { if (!conf) return; free(conf->name); free(conf->value); free(conf->section); free(conf); } int X509V3_add_value_bool(const char *name, int asn1_bool, STACK_OF(CONF_VALUE) **extlist) { if (asn1_bool) return X509V3_add_value(name, "TRUE", extlist); return X509V3_add_value(name, "FALSE", extlist); } int X509V3_add_value_bool_nf(char *name, int asn1_bool, STACK_OF(CONF_VALUE) **extlist) { if (asn1_bool) return X509V3_add_value(name, "TRUE", extlist); return 1; } char * i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *method, ASN1_ENUMERATED *a) { BIGNUM *bntmp = NULL; char *strtmp = NULL; if (!a) return NULL; if (!(bntmp = ASN1_ENUMERATED_to_BN(a, NULL)) || !(strtmp = BN_bn2dec(bntmp))) X509V3err(X509V3_F_I2S_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE); BN_free(bntmp); return strtmp; } char * i2s_ASN1_INTEGER(X509V3_EXT_METHOD *method, ASN1_INTEGER *a) { BIGNUM *bntmp = NULL; char *strtmp = NULL; if (!a) return NULL; if (!(bntmp = ASN1_INTEGER_to_BN(a, NULL)) || !(strtmp = BN_bn2dec(bntmp))) X509V3err(X509V3_F_I2S_ASN1_INTEGER, ERR_R_MALLOC_FAILURE); BN_free(bntmp); return strtmp; } ASN1_INTEGER * s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, char *value) { BIGNUM *bn = NULL; ASN1_INTEGER *aint; int isneg, ishex; int ret; if (!value) { X509V3err(X509V3_F_S2I_ASN1_INTEGER, X509V3_R_INVALID_NULL_VALUE); return 0; } bn = BN_new(); if (value[0] == '-') { value++; isneg = 1; } else isneg = 0; if (value[0] == '0' && ((value[1] == 'x') || (value[1] == 'X'))) { value += 2; ishex = 1; } else ishex = 0; if (ishex) ret = BN_hex2bn(&bn, value); else ret = BN_dec2bn(&bn, value); if (!ret || value[ret]) { BN_free(bn); X509V3err(X509V3_F_S2I_ASN1_INTEGER, X509V3_R_BN_DEC2BN_ERROR); return 0; } if (isneg && BN_is_zero(bn)) isneg = 0; aint = BN_to_ASN1_INTEGER(bn, NULL); BN_free(bn); if (!aint) { X509V3err(X509V3_F_S2I_ASN1_INTEGER, X509V3_R_BN_TO_ASN1_INTEGER_ERROR); return 0; } if (isneg) aint->type |= V_ASN1_NEG; return aint; } int X509V3_add_value_int(const char *name, ASN1_INTEGER *aint, STACK_OF(CONF_VALUE) **extlist) { char *strtmp; int ret; if (!aint) return 1; if (!(strtmp = i2s_ASN1_INTEGER(NULL, aint))) return 0; ret = X509V3_add_value(name, strtmp, extlist); free(strtmp); return ret; } int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool) { char *btmp; if (!(btmp = value->value)) goto err; if (!strcmp(btmp, "TRUE") || !strcmp(btmp, "true") || !strcmp(btmp, "Y") || !strcmp(btmp, "y") || !strcmp(btmp, "YES") || !strcmp(btmp, "yes")) { *asn1_bool = 0xff; return 1; } else if (!strcmp(btmp, "FALSE") || !strcmp(btmp, "false") || !strcmp(btmp, "N") || !strcmp(btmp, "n") || !strcmp(btmp, "NO") || !strcmp(btmp, "no")) { *asn1_bool = 0; return 1; } err: X509V3err(X509V3_F_X509V3_GET_VALUE_BOOL, X509V3_R_INVALID_BOOLEAN_STRING); X509V3_conf_err(value); return 0; } int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint) { ASN1_INTEGER *itmp; if (!(itmp = s2i_ASN1_INTEGER(NULL, value->value))) { X509V3_conf_err(value); return 0; } *aint = itmp; return 1; } #define HDR_NAME 1 #define HDR_VALUE 2 /*#define DEBUG*/ STACK_OF(CONF_VALUE) * X509V3_parse_list(const char *line) { char *p, *q, c; char *ntmp, *vtmp; STACK_OF(CONF_VALUE) *values = NULL; char *linebuf; int state; /* We are going to modify the line so copy it first */ linebuf = BUF_strdup(line); state = HDR_NAME; ntmp = NULL; /* Go through all characters */ for (p = linebuf, q = linebuf; (c = *p) && (c != '\r') && (c != '\n'); p++) { switch (state) { case HDR_NAME: if (c == ':') { state = HDR_VALUE; *p = 0; ntmp = strip_spaces(q); if (!ntmp) { X509V3err(X509V3_F_X509V3_PARSE_LIST, X509V3_R_INVALID_NULL_NAME); goto err; } q = p + 1; } else if (c == ',') { *p = 0; ntmp = strip_spaces(q); q = p + 1; #if 0 printf("%s\n", ntmp); #endif if (!ntmp) { X509V3err(X509V3_F_X509V3_PARSE_LIST, X509V3_R_INVALID_NULL_NAME); goto err; } X509V3_add_value(ntmp, NULL, &values); } break; case HDR_VALUE: if (c == ',') { state = HDR_NAME; *p = 0; vtmp = strip_spaces(q); #if 0 printf("%s\n", ntmp); #endif if (!vtmp) { X509V3err(X509V3_F_X509V3_PARSE_LIST, X509V3_R_INVALID_NULL_VALUE); goto err; } X509V3_add_value(ntmp, vtmp, &values); ntmp = NULL; q = p + 1; } } } if (state == HDR_VALUE) { vtmp = strip_spaces(q); #if 0 printf("%s=%s\n", ntmp, vtmp); #endif if (!vtmp) { X509V3err(X509V3_F_X509V3_PARSE_LIST, X509V3_R_INVALID_NULL_VALUE); goto err; } X509V3_add_value(ntmp, vtmp, &values); } else { ntmp = strip_spaces(q); #if 0 printf("%s\n", ntmp); #endif if (!ntmp) { X509V3err(X509V3_F_X509V3_PARSE_LIST, X509V3_R_INVALID_NULL_NAME); goto err; } X509V3_add_value(ntmp, NULL, &values); } free(linebuf); return values; err: free(linebuf); sk_CONF_VALUE_pop_free(values, X509V3_conf_free); return NULL; } /* Delete leading and trailing spaces from a string */ static char * strip_spaces(char *name) { char *p, *q; /* Skip over leading spaces */ p = name; while (*p && isspace((unsigned char)*p)) p++; if (!*p) return NULL; q = p + strlen(p) - 1; while ((q != p) && isspace((unsigned char)*q)) q--; if (p != q) q[1] = 0; if (!*p) return NULL; return p; } /* hex string utilities */ /* Given a buffer of length 'len' return a malloc'ed string with its * hex representation */ char * hex_to_string(const unsigned char *buffer, long len) { char *tmp, *q; const unsigned char *p; int i; static const char hexdig[] = "0123456789ABCDEF"; if (!buffer || !len) return NULL; if (!(tmp = malloc(len * 3 + 1))) { X509V3err(X509V3_F_HEX_TO_STRING, ERR_R_MALLOC_FAILURE); return NULL; } q = tmp; for (i = 0, p = buffer; i < len; i++, p++) { *q++ = hexdig[(*p >> 4) & 0xf]; *q++ = hexdig[*p & 0xf]; *q++ = ':'; } q[-1] = 0; return tmp; } /* Give a string of hex digits convert to * a buffer */ unsigned char * string_to_hex(const char *str, long *len) { unsigned char *hexbuf, *q; unsigned char ch, cl, *p; if (!str) { X509V3err(X509V3_F_STRING_TO_HEX, X509V3_R_INVALID_NULL_ARGUMENT); return NULL; } if (!(hexbuf = malloc(strlen(str) >> 1))) goto err; for (p = (unsigned char *)str, q = hexbuf; *p; ) { ch = *p++; if (ch == ':') continue; cl = *p++; if (!cl) { X509V3err(X509V3_F_STRING_TO_HEX, X509V3_R_ODD_NUMBER_OF_DIGITS); free(hexbuf); return NULL; } ch = tolower(ch); cl = tolower(cl); if ((ch >= '0') && (ch <= '9')) ch -= '0'; else if ((ch >= 'a') && (ch <= 'f')) ch -= 'a' - 10; else goto badhex; if ((cl >= '0') && (cl <= '9')) cl -= '0'; else if ((cl >= 'a') && (cl <= 'f')) cl -= 'a' - 10; else goto badhex; *q++ = (ch << 4) | cl; } if (len) *len = q - hexbuf; return hexbuf; err: free(hexbuf); X509V3err(X509V3_F_STRING_TO_HEX, ERR_R_MALLOC_FAILURE); return NULL; badhex: free(hexbuf); X509V3err(X509V3_F_STRING_TO_HEX, X509V3_R_ILLEGAL_HEX_DIGIT); return NULL; } /* V2I name comparison function: returns zero if 'name' matches * cmp or cmp.* */ int name_cmp(const char *name, const char *cmp) { int len, ret; char c; len = strlen(cmp); if ((ret = strncmp(name, cmp, len))) return ret; c = name[len]; if (!c || (c=='.')) return 0; return 1; } static int sk_strcmp(const char * const *a, const char * const *b) { return strcmp(*a, *b); } STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x) { GENERAL_NAMES *gens; STACK_OF(OPENSSL_STRING) *ret; gens = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL); ret = get_email(X509_get_subject_name(x), gens); sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); return ret; } STACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x) { AUTHORITY_INFO_ACCESS *info; STACK_OF(OPENSSL_STRING) *ret = NULL; int i; info = X509_get_ext_d2i(x, NID_info_access, NULL, NULL); if (!info) return NULL; for (i = 0; i < sk_ACCESS_DESCRIPTION_num(info); i++) { ACCESS_DESCRIPTION *ad = sk_ACCESS_DESCRIPTION_value(info, i); if (OBJ_obj2nid(ad->method) == NID_ad_OCSP) { if (ad->location->type == GEN_URI) { if (!append_ia5(&ret, ad->location->d.uniformResourceIdentifier)) break; } } } AUTHORITY_INFO_ACCESS_free(info); return ret; } STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x) { GENERAL_NAMES *gens; STACK_OF(X509_EXTENSION) *exts; STACK_OF(OPENSSL_STRING) *ret; exts = X509_REQ_get_extensions(x); gens = X509V3_get_d2i(exts, NID_subject_alt_name, NULL, NULL); ret = get_email(X509_REQ_get_subject_name(x), gens); sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free); return ret; } static STACK_OF(OPENSSL_STRING) *get_email(X509_NAME *name, GENERAL_NAMES *gens) { STACK_OF(OPENSSL_STRING) *ret = NULL; X509_NAME_ENTRY *ne; ASN1_IA5STRING *email; GENERAL_NAME *gen; int i; /* Now add any email address(es) to STACK */ i = -1; /* First supplied X509_NAME */ while ((i = X509_NAME_get_index_by_NID(name, NID_pkcs9_emailAddress, i)) >= 0) { ne = X509_NAME_get_entry(name, i); email = X509_NAME_ENTRY_get_data(ne); if (!append_ia5(&ret, email)) return NULL; } for (i = 0; i < sk_GENERAL_NAME_num(gens); i++) { gen = sk_GENERAL_NAME_value(gens, i); if (gen->type != GEN_EMAIL) continue; if (!append_ia5(&ret, gen->d.ia5)) return NULL; } return ret; } static void str_free(OPENSSL_STRING str) { free(str); } static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, ASN1_IA5STRING *email) { char *emtmp; /* First some sanity checks */ if (email->type != V_ASN1_IA5STRING) return 1; if (!email->data || !email->length) return 1; if (!*sk) *sk = sk_OPENSSL_STRING_new(sk_strcmp); if (!*sk) return 0; /* Don't add duplicates */ if (sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1) return 1; emtmp = BUF_strdup((char *)email->data); if (!emtmp || !sk_OPENSSL_STRING_push(*sk, emtmp)) { X509_email_free(*sk); *sk = NULL; return 0; } return 1; } void X509_email_free(STACK_OF(OPENSSL_STRING) *sk) { sk_OPENSSL_STRING_pop_free(sk, str_free); } /* Convert IP addresses both IPv4 and IPv6 into an * OCTET STRING compatible with RFC3280. */ ASN1_OCTET_STRING * a2i_IPADDRESS(const char *ipasc) { unsigned char ipout[16]; ASN1_OCTET_STRING *ret; int iplen; /* If string contains a ':' assume IPv6 */ iplen = a2i_ipadd(ipout, ipasc); if (!iplen) return NULL; ret = ASN1_OCTET_STRING_new(); if (!ret) return NULL; if (!ASN1_OCTET_STRING_set(ret, ipout, iplen)) { ASN1_OCTET_STRING_free(ret); return NULL; } return ret; } ASN1_OCTET_STRING * a2i_IPADDRESS_NC(const char *ipasc) { ASN1_OCTET_STRING *ret = NULL; unsigned char ipout[32]; char *iptmp = NULL, *p; int iplen1, iplen2; p = strchr(ipasc, '/'); if (!p) return NULL; iptmp = BUF_strdup(ipasc); if (!iptmp) return NULL; p = iptmp + (p - ipasc); *p++ = 0; iplen1 = a2i_ipadd(ipout, iptmp); if (!iplen1) goto err; iplen2 = a2i_ipadd(ipout + iplen1, p); free(iptmp); iptmp = NULL; if (!iplen2 || (iplen1 != iplen2)) goto err; ret = ASN1_OCTET_STRING_new(); if (!ret) goto err; if (!ASN1_OCTET_STRING_set(ret, ipout, iplen1 + iplen2)) goto err; return ret; err: free(iptmp); if (ret) ASN1_OCTET_STRING_free(ret); return NULL; } int a2i_ipadd(unsigned char *ipout, const char *ipasc) { /* If string contains a ':' assume IPv6 */ if (strchr(ipasc, ':')) { if (!ipv6_from_asc(ipout, ipasc)) return 0; return 16; } else { if (!ipv4_from_asc(ipout, ipasc)) return 0; return 4; } } static int ipv4_from_asc(unsigned char *v4, const char *in) { int a0, a1, a2, a3; if (sscanf(in, "%d.%d.%d.%d", &a0, &a1, &a2, &a3) != 4) return 0; if ((a0 < 0) || (a0 > 255) || (a1 < 0) || (a1 > 255) || (a2 < 0) || (a2 > 255) || (a3 < 0) || (a3 > 255)) return 0; v4[0] = a0; v4[1] = a1; v4[2] = a2; v4[3] = a3; return 1; } typedef struct { /* Temporary store for IPV6 output */ unsigned char tmp[16]; /* Total number of bytes in tmp */ int total; /* The position of a zero (corresponding to '::') */ int zero_pos; /* Number of zeroes */ int zero_cnt; } IPV6_STAT; static int ipv6_from_asc(unsigned char *v6, const char *in) { IPV6_STAT v6stat; v6stat.total = 0; v6stat.zero_pos = -1; v6stat.zero_cnt = 0; /* Treat the IPv6 representation as a list of values * separated by ':'. The presence of a '::' will parse * as one, two or three zero length elements. */ if (!CONF_parse_list(in, ':', 0, ipv6_cb, &v6stat)) return 0; /* Now for some sanity checks */ if (v6stat.zero_pos == -1) { /* If no '::' must have exactly 16 bytes */ if (v6stat.total != 16) return 0; } else { /* If '::' must have less than 16 bytes */ if (v6stat.total == 16) return 0; /* More than three zeroes is an error */ if (v6stat.zero_cnt > 3) return 0; /* Can only have three zeroes if nothing else present */ else if (v6stat.zero_cnt == 3) { if (v6stat.total > 0) return 0; } /* Can only have two zeroes if at start or end */ else if (v6stat.zero_cnt == 2) { if ((v6stat.zero_pos != 0) && (v6stat.zero_pos != v6stat.total)) return 0; } else /* Can only have one zero if *not* start or end */ { if ((v6stat.zero_pos == 0) || (v6stat.zero_pos == v6stat.total)) return 0; } } /* Format result */ if (v6stat.zero_pos >= 0) { /* Copy initial part */ memcpy(v6, v6stat.tmp, v6stat.zero_pos); /* Zero middle */ memset(v6 + v6stat.zero_pos, 0, 16 - v6stat.total); /* Copy final part */ if (v6stat.total != v6stat.zero_pos) memcpy(v6 + v6stat.zero_pos + 16 - v6stat.total, v6stat.tmp + v6stat.zero_pos, v6stat.total - v6stat.zero_pos); } else memcpy(v6, v6stat.tmp, 16); return 1; } static int ipv6_cb(const char *elem, int len, void *usr) { IPV6_STAT *s = usr; /* Error if 16 bytes written */ if (s->total == 16) return 0; if (len == 0) { /* Zero length element, corresponds to '::' */ if (s->zero_pos == -1) s->zero_pos = s->total; /* If we've already got a :: its an error */ else if (s->zero_pos != s->total) return 0; s->zero_cnt++; } else { /* If more than 4 characters could be final a.b.c.d form */ if (len > 4) { /* Need at least 4 bytes left */ if (s->total > 12) return 0; /* Must be end of string */ if (elem[len]) return 0; if (!ipv4_from_asc(s->tmp + s->total, elem)) return 0; s->total += 4; } else { if (!ipv6_hex(s->tmp + s->total, elem, len)) return 0; s->total += 2; } } return 1; } /* Convert a string of up to 4 hex digits into the corresponding * IPv6 form. */ static int ipv6_hex(unsigned char *out, const char *in, int inlen) { unsigned char c; unsigned int num = 0; if (inlen > 4) return 0; while (inlen--) { c = *in++; num <<= 4; if ((c >= '0') && (c <= '9')) num |= c - '0'; else if ((c >= 'A') && (c <= 'F')) num |= c - 'A' + 10; else if ((c >= 'a') && (c <= 'f')) num |= c - 'a' + 10; else return 0; } out[0] = num >> 8; out[1] = num & 0xff; return 1; } int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE)*dn_sk, unsigned long chtype) { CONF_VALUE *v; int i, mval; char *p, *type; if (!nm) return 0; for (i = 0; i < sk_CONF_VALUE_num(dn_sk); i++) { v = sk_CONF_VALUE_value(dn_sk, i); type = v->name; /* Skip past any leading X. X: X, etc to allow for * multiple instances */ for (p = type; *p; p++) if ((*p == ':') || (*p == ',') || (*p == '.')) { p++; if (*p) type = p; break; } if (*type == '+') { mval = -1; type++; } else mval = 0; if (!X509_NAME_add_entry_by_txt(nm, type, chtype, (unsigned char *) v->value, -1, -1, mval)) return 0; } return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_genn.c0000644000175000017500000001546012360020706020743 0ustar /* $OpenBSD: v3_genn.c,v 1.8 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include ASN1_SEQUENCE(OTHERNAME) = { ASN1_SIMPLE(OTHERNAME, type_id, ASN1_OBJECT), /* Maybe have a true ANY DEFINED BY later */ ASN1_EXP(OTHERNAME, value, ASN1_ANY, 0) } ASN1_SEQUENCE_END(OTHERNAME) IMPLEMENT_ASN1_FUNCTIONS(OTHERNAME) ASN1_SEQUENCE(EDIPARTYNAME) = { ASN1_IMP_OPT(EDIPARTYNAME, nameAssigner, DIRECTORYSTRING, 0), ASN1_IMP_OPT(EDIPARTYNAME, partyName, DIRECTORYSTRING, 1) } ASN1_SEQUENCE_END(EDIPARTYNAME) IMPLEMENT_ASN1_FUNCTIONS(EDIPARTYNAME) ASN1_CHOICE(GENERAL_NAME) = { ASN1_IMP(GENERAL_NAME, d.otherName, OTHERNAME, GEN_OTHERNAME), ASN1_IMP(GENERAL_NAME, d.rfc822Name, ASN1_IA5STRING, GEN_EMAIL), ASN1_IMP(GENERAL_NAME, d.dNSName, ASN1_IA5STRING, GEN_DNS), /* Don't decode this */ ASN1_IMP(GENERAL_NAME, d.x400Address, ASN1_SEQUENCE, GEN_X400), /* X509_NAME is a CHOICE type so use EXPLICIT */ ASN1_EXP(GENERAL_NAME, d.directoryName, X509_NAME, GEN_DIRNAME), ASN1_IMP(GENERAL_NAME, d.ediPartyName, EDIPARTYNAME, GEN_EDIPARTY), ASN1_IMP(GENERAL_NAME, d.uniformResourceIdentifier, ASN1_IA5STRING, GEN_URI), ASN1_IMP(GENERAL_NAME, d.iPAddress, ASN1_OCTET_STRING, GEN_IPADD), ASN1_IMP(GENERAL_NAME, d.registeredID, ASN1_OBJECT, GEN_RID) } ASN1_CHOICE_END(GENERAL_NAME) IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAME) ASN1_ITEM_TEMPLATE(GENERAL_NAMES) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, GeneralNames, GENERAL_NAME) ASN1_ITEM_TEMPLATE_END(GENERAL_NAMES) IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAMES) GENERAL_NAME * GENERAL_NAME_dup(GENERAL_NAME *a) { return (GENERAL_NAME *)ASN1_dup((i2d_of_void *)i2d_GENERAL_NAME, (d2i_of_void *)d2i_GENERAL_NAME, (char *)a); } /* Returns 0 if they are equal, != 0 otherwise. */ int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b) { int result = -1; if (!a || !b || a->type != b->type) return -1; switch (a->type) { case GEN_X400: case GEN_EDIPARTY: result = ASN1_TYPE_cmp(a->d.other, b->d.other); break; case GEN_OTHERNAME: result = OTHERNAME_cmp(a->d.otherName, b->d.otherName); break; case GEN_EMAIL: case GEN_DNS: case GEN_URI: result = ASN1_STRING_cmp(a->d.ia5, b->d.ia5); break; case GEN_DIRNAME: result = X509_NAME_cmp(a->d.dirn, b->d.dirn); break; case GEN_IPADD: result = ASN1_OCTET_STRING_cmp(a->d.ip, b->d.ip); break; case GEN_RID: result = OBJ_cmp(a->d.rid, b->d.rid); break; } return result; } /* Returns 0 if they are equal, != 0 otherwise. */ int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b) { int result = -1; if (!a || !b) return -1; /* Check their type first. */ if ((result = OBJ_cmp(a->type_id, b->type_id)) != 0) return result; /* Check the value. */ result = ASN1_TYPE_cmp(a->value, b->value); return result; } void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value) { switch (type) { case GEN_X400: case GEN_EDIPARTY: a->d.other = value; break; case GEN_OTHERNAME: a->d.otherName = value; break; case GEN_EMAIL: case GEN_DNS: case GEN_URI: a->d.ia5 = value; break; case GEN_DIRNAME: a->d.dirn = value; break; case GEN_IPADD: a->d.ip = value; break; case GEN_RID: a->d.rid = value; break; } a->type = type; } void * GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype) { if (ptype) *ptype = a->type; switch (a->type) { case GEN_X400: case GEN_EDIPARTY: return a->d.other; case GEN_OTHERNAME: return a->d.otherName; case GEN_EMAIL: case GEN_DNS: case GEN_URI: return a->d.ia5; case GEN_DIRNAME: return a->d.dirn; case GEN_IPADD: return a->d.ip; case GEN_RID: return a->d.rid; default: return NULL; } } int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, ASN1_OBJECT *oid, ASN1_TYPE *value) { OTHERNAME *oth; oth = OTHERNAME_new(); if (!oth) return 0; oth->type_id = oid; oth->value = value; GENERAL_NAME_set0_value(gen, GEN_OTHERNAME, oth); return 1; } int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, ASN1_OBJECT **poid, ASN1_TYPE **pvalue) { if (gen->type != GEN_OTHERNAME) return 0; if (poid) *poid = gen->d.otherName->type_id; if (pvalue) *pvalue = gen->d.otherName->value; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_akey.c0000644000175000017500000001473412360020706020750 0ustar /* $OpenBSD: v3_akey.c,v 1.11 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, AUTHORITY_KEYID *akeyid, STACK_OF(CONF_VALUE) *extlist); static AUTHORITY_KEYID *v2i_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values); const X509V3_EXT_METHOD v3_akey_id = { NID_authority_key_identifier, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(AUTHORITY_KEYID), 0, 0,0, 0, 0, 0, (X509V3_EXT_I2V)i2v_AUTHORITY_KEYID, (X509V3_EXT_V2I)v2i_AUTHORITY_KEYID, 0, 0, NULL }; static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, AUTHORITY_KEYID *akeyid, STACK_OF(CONF_VALUE) *extlist) { char *tmp; if (akeyid->keyid) { tmp = hex_to_string(akeyid->keyid->data, akeyid->keyid->length); X509V3_add_value("keyid", tmp, &extlist); free(tmp); } if (akeyid->issuer) extlist = i2v_GENERAL_NAMES(NULL, akeyid->issuer, extlist); if (akeyid->serial) { tmp = hex_to_string(akeyid->serial->data, akeyid->serial->length); X509V3_add_value("serial", tmp, &extlist); free(tmp); } return extlist; } /* Currently two options: * keyid: use the issuers subject keyid, the value 'always' means its is * an error if the issuer certificate doesn't have a key id. * issuer: use the issuers cert issuer and serial number. The default is * to only use this if keyid is not present. With the option 'always' * this is always included. */ static AUTHORITY_KEYID * v2i_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values) { char keyid = 0, issuer = 0; int i; CONF_VALUE *cnf; ASN1_OCTET_STRING *ikeyid = NULL; X509_NAME *isname = NULL; GENERAL_NAMES * gens = NULL; GENERAL_NAME *gen = NULL; ASN1_INTEGER *serial = NULL; X509_EXTENSION *ext; X509 *cert; AUTHORITY_KEYID *akeyid; for (i = 0; i < sk_CONF_VALUE_num(values); i++) { cnf = sk_CONF_VALUE_value(values, i); if (!strcmp(cnf->name, "keyid")) { keyid = 1; if (cnf->value && !strcmp(cnf->value, "always")) keyid = 2; } else if (!strcmp(cnf->name, "issuer")) { issuer = 1; if (cnf->value && !strcmp(cnf->value, "always")) issuer = 2; } else { X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, X509V3_R_UNKNOWN_OPTION); ERR_asprintf_error_data("name=%s", cnf->name); return NULL; } } if (!ctx || !ctx->issuer_cert) { if (ctx && (ctx->flags == CTX_TEST)) return AUTHORITY_KEYID_new(); X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, X509V3_R_NO_ISSUER_CERTIFICATE); return NULL; } cert = ctx->issuer_cert; if (keyid) { i = X509_get_ext_by_NID(cert, NID_subject_key_identifier, -1); if ((i >= 0) && (ext = X509_get_ext(cert, i))) ikeyid = X509V3_EXT_d2i(ext); if (keyid == 2 && !ikeyid) { X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, X509V3_R_UNABLE_TO_GET_ISSUER_KEYID); return NULL; } } if ((issuer && !ikeyid) || (issuer == 2)) { isname = X509_NAME_dup(X509_get_issuer_name(cert)); serial = M_ASN1_INTEGER_dup(X509_get_serialNumber(cert)); if (!isname || !serial) { X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS); goto err; } } if (!(akeyid = AUTHORITY_KEYID_new())) goto err; if (isname) { if (!(gens = sk_GENERAL_NAME_new_null()) || !(gen = GENERAL_NAME_new()) || !sk_GENERAL_NAME_push(gens, gen)) { X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_MALLOC_FAILURE); goto err; } gen->type = GEN_DIRNAME; gen->d.dirn = isname; } akeyid->issuer = gens; akeyid->serial = serial; akeyid->keyid = ikeyid; return akeyid; err: X509_NAME_free(isname); M_ASN1_INTEGER_free(serial); M_ASN1_OCTET_STRING_free(ikeyid); return NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/x509v3/v3_cpols.c0000644000175000017500000003353412360020706021136 0ustar /* $OpenBSD: v3_cpols.c,v 1.14 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include "pcy_int.h" /* Certificate policies extension support: this one is a bit complex... */ static int i2r_certpol(X509V3_EXT_METHOD *method, STACK_OF(POLICYINFO) *pol, BIO *out, int indent); static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *value); static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, int indent); static void print_notice(BIO *out, USERNOTICE *notice, int indent); static POLICYINFO *policy_section(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *polstrs, int ia5org); static POLICYQUALINFO *notice_section(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *unot, int ia5org); static int nref_nos(STACK_OF(ASN1_INTEGER) *nnums, STACK_OF(CONF_VALUE) *nos); const X509V3_EXT_METHOD v3_cpols = { NID_certificate_policies, 0, ASN1_ITEM_ref(CERTIFICATEPOLICIES), 0, 0, 0, 0, 0, 0, 0, 0, (X509V3_EXT_I2R)i2r_certpol, (X509V3_EXT_R2I)r2i_certpol, NULL }; ASN1_ITEM_TEMPLATE(CERTIFICATEPOLICIES) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, CERTIFICATEPOLICIES, POLICYINFO) ASN1_ITEM_TEMPLATE_END(CERTIFICATEPOLICIES) IMPLEMENT_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) ASN1_SEQUENCE(POLICYINFO) = { ASN1_SIMPLE(POLICYINFO, policyid, ASN1_OBJECT), ASN1_SEQUENCE_OF_OPT(POLICYINFO, qualifiers, POLICYQUALINFO) } ASN1_SEQUENCE_END(POLICYINFO) IMPLEMENT_ASN1_FUNCTIONS(POLICYINFO) ASN1_ADB_TEMPLATE(policydefault) = ASN1_SIMPLE(POLICYQUALINFO, d.other, ASN1_ANY); ASN1_ADB(POLICYQUALINFO) = { ADB_ENTRY(NID_id_qt_cps, ASN1_SIMPLE(POLICYQUALINFO, d.cpsuri, ASN1_IA5STRING)), ADB_ENTRY(NID_id_qt_unotice, ASN1_SIMPLE(POLICYQUALINFO, d.usernotice, USERNOTICE)) } ASN1_ADB_END(POLICYQUALINFO, 0, pqualid, 0, &policydefault_tt, NULL); ASN1_SEQUENCE(POLICYQUALINFO) = { ASN1_SIMPLE(POLICYQUALINFO, pqualid, ASN1_OBJECT), ASN1_ADB_OBJECT(POLICYQUALINFO) } ASN1_SEQUENCE_END(POLICYQUALINFO) IMPLEMENT_ASN1_FUNCTIONS(POLICYQUALINFO) ASN1_SEQUENCE(USERNOTICE) = { ASN1_OPT(USERNOTICE, noticeref, NOTICEREF), ASN1_OPT(USERNOTICE, exptext, DISPLAYTEXT) } ASN1_SEQUENCE_END(USERNOTICE) IMPLEMENT_ASN1_FUNCTIONS(USERNOTICE) ASN1_SEQUENCE(NOTICEREF) = { ASN1_SIMPLE(NOTICEREF, organization, DISPLAYTEXT), ASN1_SEQUENCE_OF(NOTICEREF, noticenos, ASN1_INTEGER) } ASN1_SEQUENCE_END(NOTICEREF) IMPLEMENT_ASN1_FUNCTIONS(NOTICEREF) static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *value) { STACK_OF(POLICYINFO) *pols = NULL; char *pstr; POLICYINFO *pol; ASN1_OBJECT *pobj; STACK_OF(CONF_VALUE) *vals; CONF_VALUE *cnf; int i, ia5org; pols = sk_POLICYINFO_new_null(); if (pols == NULL) { X509V3err(X509V3_F_R2I_CERTPOL, ERR_R_MALLOC_FAILURE); return NULL; } vals = X509V3_parse_list(value); if (vals == NULL) { X509V3err(X509V3_F_R2I_CERTPOL, ERR_R_X509V3_LIB); goto err; } ia5org = 0; for (i = 0; i < sk_CONF_VALUE_num(vals); i++) { cnf = sk_CONF_VALUE_value(vals, i); if (cnf->value || !cnf->name ) { X509V3err(X509V3_F_R2I_CERTPOL, X509V3_R_INVALID_POLICY_IDENTIFIER); X509V3_conf_err(cnf); goto err; } pstr = cnf->name; if (!strcmp(pstr, "ia5org")) { ia5org = 1; continue; } else if (*pstr == '@') { STACK_OF(CONF_VALUE) *polsect; polsect = X509V3_get_section(ctx, pstr + 1); if (!polsect) { X509V3err(X509V3_F_R2I_CERTPOL, X509V3_R_INVALID_SECTION); X509V3_conf_err(cnf); goto err; } pol = policy_section(ctx, polsect, ia5org); X509V3_section_free(ctx, polsect); if (!pol) goto err; } else { if (!(pobj = OBJ_txt2obj(cnf->name, 0))) { X509V3err(X509V3_F_R2I_CERTPOL, X509V3_R_INVALID_OBJECT_IDENTIFIER); X509V3_conf_err(cnf); goto err; } pol = POLICYINFO_new(); pol->policyid = pobj; } if (!sk_POLICYINFO_push(pols, pol)){ POLICYINFO_free(pol); X509V3err(X509V3_F_R2I_CERTPOL, ERR_R_MALLOC_FAILURE); goto err; } } sk_CONF_VALUE_pop_free(vals, X509V3_conf_free); return pols; err: sk_CONF_VALUE_pop_free(vals, X509V3_conf_free); sk_POLICYINFO_pop_free(pols, POLICYINFO_free); return NULL; } static POLICYINFO * policy_section(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *polstrs, int ia5org) { int i; CONF_VALUE *cnf; POLICYINFO *pol; POLICYQUALINFO *qual; if (!(pol = POLICYINFO_new())) goto merr; for (i = 0; i < sk_CONF_VALUE_num(polstrs); i++) { cnf = sk_CONF_VALUE_value(polstrs, i); if (!strcmp(cnf->name, "policyIdentifier")) { ASN1_OBJECT *pobj; if (!(pobj = OBJ_txt2obj(cnf->value, 0))) { X509V3err(X509V3_F_POLICY_SECTION, X509V3_R_INVALID_OBJECT_IDENTIFIER); X509V3_conf_err(cnf); goto err; } pol->policyid = pobj; } else if (!name_cmp(cnf->name, "CPS")) { if (!pol->qualifiers) pol->qualifiers = sk_POLICYQUALINFO_new_null(); if (!(qual = POLICYQUALINFO_new())) goto merr; if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) goto merr; qual->pqualid = OBJ_nid2obj(NID_id_qt_cps); qual->d.cpsuri = M_ASN1_IA5STRING_new(); if (!ASN1_STRING_set(qual->d.cpsuri, cnf->value, strlen(cnf->value))) goto merr; } else if (!name_cmp(cnf->name, "userNotice")) { STACK_OF(CONF_VALUE) *unot; if (*cnf->value != '@') { X509V3err(X509V3_F_POLICY_SECTION, X509V3_R_EXPECTED_A_SECTION_NAME); X509V3_conf_err(cnf); goto err; } unot = X509V3_get_section(ctx, cnf->value + 1); if (!unot) { X509V3err(X509V3_F_POLICY_SECTION, X509V3_R_INVALID_SECTION); X509V3_conf_err(cnf); goto err; } qual = notice_section(ctx, unot, ia5org); X509V3_section_free(ctx, unot); if (!qual) goto err; if (!pol->qualifiers) pol->qualifiers = sk_POLICYQUALINFO_new_null(); if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) goto merr; } else { X509V3err(X509V3_F_POLICY_SECTION, X509V3_R_INVALID_OPTION); X509V3_conf_err(cnf); goto err; } } if (!pol->policyid) { X509V3err(X509V3_F_POLICY_SECTION, X509V3_R_NO_POLICY_IDENTIFIER); goto err; } return pol; merr: X509V3err(X509V3_F_POLICY_SECTION, ERR_R_MALLOC_FAILURE); err: POLICYINFO_free(pol); return NULL; } static POLICYQUALINFO * notice_section(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *unot, int ia5org) { int i, ret; CONF_VALUE *cnf; USERNOTICE *not; POLICYQUALINFO *qual; if (!(qual = POLICYQUALINFO_new())) goto merr; qual->pqualid = OBJ_nid2obj(NID_id_qt_unotice); if (!(not = USERNOTICE_new())) goto merr; qual->d.usernotice = not; for (i = 0; i < sk_CONF_VALUE_num(unot); i++) { cnf = sk_CONF_VALUE_value(unot, i); if (!strcmp(cnf->name, "explicitText")) { not->exptext = M_ASN1_VISIBLESTRING_new(); if (!ASN1_STRING_set(not->exptext, cnf->value, strlen(cnf->value))) goto merr; } else if (!strcmp(cnf->name, "organization")) { NOTICEREF *nref; if (!not->noticeref) { if (!(nref = NOTICEREF_new())) goto merr; not->noticeref = nref; } else nref = not->noticeref; if (ia5org) nref->organization->type = V_ASN1_IA5STRING; else nref->organization->type = V_ASN1_VISIBLESTRING; if (!ASN1_STRING_set(nref->organization, cnf->value, strlen(cnf->value))) goto merr; } else if (!strcmp(cnf->name, "noticeNumbers")) { NOTICEREF *nref; STACK_OF(CONF_VALUE) *nos; if (!not->noticeref) { if (!(nref = NOTICEREF_new())) goto merr; not->noticeref = nref; } else nref = not->noticeref; nos = X509V3_parse_list(cnf->value); if (!nos || !sk_CONF_VALUE_num(nos)) { X509V3err(X509V3_F_NOTICE_SECTION, X509V3_R_INVALID_NUMBERS); X509V3_conf_err(cnf); goto err; } ret = nref_nos(nref->noticenos, nos); sk_CONF_VALUE_pop_free(nos, X509V3_conf_free); if (!ret) goto err; } else { X509V3err(X509V3_F_NOTICE_SECTION, X509V3_R_INVALID_OPTION); X509V3_conf_err(cnf); goto err; } } if (not->noticeref && (!not->noticeref->noticenos || !not->noticeref->organization)) { X509V3err(X509V3_F_NOTICE_SECTION, X509V3_R_NEED_ORGANIZATION_AND_NUMBERS); goto err; } return qual; merr: X509V3err(X509V3_F_NOTICE_SECTION, ERR_R_MALLOC_FAILURE); err: POLICYQUALINFO_free(qual); return NULL; } static int nref_nos(STACK_OF(ASN1_INTEGER) *nnums, STACK_OF(CONF_VALUE) *nos) { CONF_VALUE *cnf; ASN1_INTEGER *aint; int i; for (i = 0; i < sk_CONF_VALUE_num(nos); i++) { cnf = sk_CONF_VALUE_value(nos, i); if (!(aint = s2i_ASN1_INTEGER(NULL, cnf->name))) { X509V3err(X509V3_F_NREF_NOS, X509V3_R_INVALID_NUMBER); goto err; } if (!sk_ASN1_INTEGER_push(nnums, aint)) goto merr; } return 1; merr: X509V3err(X509V3_F_NREF_NOS, ERR_R_MALLOC_FAILURE); err: sk_ASN1_INTEGER_pop_free(nnums, ASN1_STRING_free); return 0; } static int i2r_certpol(X509V3_EXT_METHOD *method, STACK_OF(POLICYINFO) *pol, BIO *out, int indent) { int i; POLICYINFO *pinfo; /* First print out the policy OIDs */ for (i = 0; i < sk_POLICYINFO_num(pol); i++) { pinfo = sk_POLICYINFO_value(pol, i); BIO_printf(out, "%*sPolicy: ", indent, ""); i2a_ASN1_OBJECT(out, pinfo->policyid); BIO_puts(out, "\n"); if (pinfo->qualifiers) print_qualifiers(out, pinfo->qualifiers, indent + 2); } return 1; } static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, int indent) { POLICYQUALINFO *qualinfo; int i; for (i = 0; i < sk_POLICYQUALINFO_num(quals); i++) { qualinfo = sk_POLICYQUALINFO_value(quals, i); switch (OBJ_obj2nid(qualinfo->pqualid)) { case NID_id_qt_cps: BIO_printf(out, "%*sCPS: %s\n", indent, "", qualinfo->d.cpsuri->data); break; case NID_id_qt_unotice: BIO_printf(out, "%*sUser Notice:\n", indent, ""); print_notice(out, qualinfo->d.usernotice, indent + 2); break; default: BIO_printf(out, "%*sUnknown Qualifier: ", indent + 2, ""); i2a_ASN1_OBJECT(out, qualinfo->pqualid); BIO_puts(out, "\n"); break; } } } static void print_notice(BIO *out, USERNOTICE *notice, int indent) { int i; if (notice->noticeref) { NOTICEREF *ref; ref = notice->noticeref; BIO_printf(out, "%*sOrganization: %s\n", indent, "", ref->organization->data); BIO_printf(out, "%*sNumber%s: ", indent, "", sk_ASN1_INTEGER_num(ref->noticenos) > 1 ? "s" : ""); for (i = 0; i < sk_ASN1_INTEGER_num(ref->noticenos); i++) { ASN1_INTEGER *num; char *tmp; num = sk_ASN1_INTEGER_value(ref->noticenos, i); if (i) BIO_puts(out, ", "); tmp = i2s_ASN1_INTEGER(NULL, num); BIO_puts(out, tmp); free(tmp); } BIO_puts(out, "\n"); } if (notice->exptext) BIO_printf(out, "%*sExplicit Text: %s\n", indent, "", notice->exptext->data); } void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent) { const X509_POLICY_DATA *dat = node->data; BIO_printf(out, "%*sPolicy: ", indent, ""); i2a_ASN1_OBJECT(out, dat->valid_policy); BIO_puts(out, "\n"); BIO_printf(out, "%*s%s\n", indent + 2, "", node_data_critical(dat) ? "Critical" : "Non Critical"); if (dat->qualifier_set) print_qualifiers(out, dat->qualifier_set, indent + 2); else BIO_printf(out, "%*sNo Qualifiers\n", indent + 2, ""); } IMPLEMENT_STACK_OF(X509_POLICY_NODE) IMPLEMENT_STACK_OF(X509_POLICY_DATA) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/cast/0000755000000000000000000000000012666635521021004 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/cast/c_cfb64.c0000644000175000017500000001041612360020705020561 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "cast_lcl.h" /* The input and output encrypted as though 64bit cfb mode is being * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, const CAST_KEY *schedule, unsigned char *ivec, int *num, int enc) { register CAST_LONG v0,v1,t; register int n= *num; register long l=length; CAST_LONG ti[2]; unsigned char *iv,c,cc; iv=ivec; if (enc) { while (l--) { if (n == 0) { n2l(iv,v0); ti[0]=v0; n2l(iv,v1); ti[1]=v1; CAST_encrypt((CAST_LONG *)ti,schedule); iv=ivec; t=ti[0]; l2n(t,iv); t=ti[1]; l2n(t,iv); iv=ivec; } c= *(in++)^iv[n]; *(out++)=c; iv[n]=c; n=(n+1)&0x07; } } else { while (l--) { if (n == 0) { n2l(iv,v0); ti[0]=v0; n2l(iv,v1); ti[1]=v1; CAST_encrypt((CAST_LONG *)ti,schedule); iv=ivec; t=ti[0]; l2n(t,iv); t=ti[1]; l2n(t,iv); iv=ivec; } cc= *(in++); c=iv[n]; iv[n]=cc; *(out++)=c^cc; n=(n+1)&0x07; } } v0=v1=ti[0]=ti[1]=t=c=cc=0; *num=n; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/cast/c_ecb.c0000644000175000017500000000702112360020705020404 0ustar /* $OpenBSD: c_ecb.c,v 1.6 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "cast_lcl.h" #include void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, const CAST_KEY *ks, int enc) { CAST_LONG l,d[2]; n2l(in,l); d[0]=l; n2l(in,l); d[1]=l; if (enc) CAST_encrypt(d,ks); else CAST_decrypt(d,ks); l=d[0]; l2n(l,out); l=d[1]; l2n(l,out); l=d[0]=d[1]=0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/cast/c_enc.c0000644000175000017500000001355112360020705020425 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "cast_lcl.h" #ifndef OPENBSD_CAST_ASM void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key) { register CAST_LONG l,r,t; register const CAST_LONG *k; k= &(key->data[0]); l=data[0]; r=data[1]; E_CAST( 0,k,l,r,+,^,-); E_CAST( 1,k,r,l,^,-,+); E_CAST( 2,k,l,r,-,+,^); E_CAST( 3,k,r,l,+,^,-); E_CAST( 4,k,l,r,^,-,+); E_CAST( 5,k,r,l,-,+,^); E_CAST( 6,k,l,r,+,^,-); E_CAST( 7,k,r,l,^,-,+); E_CAST( 8,k,l,r,-,+,^); E_CAST( 9,k,r,l,+,^,-); E_CAST(10,k,l,r,^,-,+); E_CAST(11,k,r,l,-,+,^); if(!key->short_key) { E_CAST(12,k,l,r,+,^,-); E_CAST(13,k,r,l,^,-,+); E_CAST(14,k,l,r,-,+,^); E_CAST(15,k,r,l,+,^,-); } data[1]=l&0xffffffffL; data[0]=r&0xffffffffL; } void CAST_decrypt(CAST_LONG *data, const CAST_KEY *key) { register CAST_LONG l,r,t; register const CAST_LONG *k; k= &(key->data[0]); l=data[0]; r=data[1]; if(!key->short_key) { E_CAST(15,k,l,r,+,^,-); E_CAST(14,k,r,l,-,+,^); E_CAST(13,k,l,r,^,-,+); E_CAST(12,k,r,l,+,^,-); } E_CAST(11,k,l,r,-,+,^); E_CAST(10,k,r,l,^,-,+); E_CAST( 9,k,l,r,+,^,-); E_CAST( 8,k,r,l,-,+,^); E_CAST( 7,k,l,r,^,-,+); E_CAST( 6,k,r,l,+,^,-); E_CAST( 5,k,l,r,-,+,^); E_CAST( 4,k,r,l,^,-,+); E_CAST( 3,k,l,r,+,^,-); E_CAST( 2,k,r,l,-,+,^); E_CAST( 1,k,l,r,^,-,+); E_CAST( 0,k,r,l,+,^,-); data[1]=l&0xffffffffL; data[0]=r&0xffffffffL; } #endif void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, const CAST_KEY *ks, unsigned char *iv, int enc) { register CAST_LONG tin0,tin1; register CAST_LONG tout0,tout1,xor0,xor1; register long l=length; CAST_LONG tin[2]; if (enc) { n2l(iv,tout0); n2l(iv,tout1); iv-=8; for (l-=8; l>=0; l-=8) { n2l(in,tin0); n2l(in,tin1); tin0^=tout0; tin1^=tout1; tin[0]=tin0; tin[1]=tin1; CAST_encrypt(tin,ks); tout0=tin[0]; tout1=tin[1]; l2n(tout0,out); l2n(tout1,out); } if (l != -8) { n2ln(in,tin0,tin1,l+8); tin0^=tout0; tin1^=tout1; tin[0]=tin0; tin[1]=tin1; CAST_encrypt(tin,ks); tout0=tin[0]; tout1=tin[1]; l2n(tout0,out); l2n(tout1,out); } l2n(tout0,iv); l2n(tout1,iv); } else { n2l(iv,xor0); n2l(iv,xor1); iv-=8; for (l-=8; l>=0; l-=8) { n2l(in,tin0); n2l(in,tin1); tin[0]=tin0; tin[1]=tin1; CAST_decrypt(tin,ks); tout0=tin[0]^xor0; tout1=tin[1]^xor1; l2n(tout0,out); l2n(tout1,out); xor0=tin0; xor1=tin1; } if (l != -8) { n2l(in,tin0); n2l(in,tin1); tin[0]=tin0; tin[1]=tin1; CAST_decrypt(tin,ks); tout0=tin[0]^xor0; tout1=tin[1]^xor1; l2nn(tout0,tout1,out,l+8); xor0=tin0; xor1=tin1; } l2n(xor0,iv); l2n(xor1,iv); } tin0=tin1=tout0=tout1=xor0=xor1=0; tin[0]=tin[1]=0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/cast/cast_s.h0000644000175000017500000006467112360020705020650 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ const CAST_LONG CAST_S_table0[256]={ 0x30fb40d4,0x9fa0ff0b,0x6beccd2f,0x3f258c7a, 0x1e213f2f,0x9c004dd3,0x6003e540,0xcf9fc949, 0xbfd4af27,0x88bbbdb5,0xe2034090,0x98d09675, 0x6e63a0e0,0x15c361d2,0xc2e7661d,0x22d4ff8e, 0x28683b6f,0xc07fd059,0xff2379c8,0x775f50e2, 0x43c340d3,0xdf2f8656,0x887ca41a,0xa2d2bd2d, 0xa1c9e0d6,0x346c4819,0x61b76d87,0x22540f2f, 0x2abe32e1,0xaa54166b,0x22568e3a,0xa2d341d0, 0x66db40c8,0xa784392f,0x004dff2f,0x2db9d2de, 0x97943fac,0x4a97c1d8,0x527644b7,0xb5f437a7, 0xb82cbaef,0xd751d159,0x6ff7f0ed,0x5a097a1f, 0x827b68d0,0x90ecf52e,0x22b0c054,0xbc8e5935, 0x4b6d2f7f,0x50bb64a2,0xd2664910,0xbee5812d, 0xb7332290,0xe93b159f,0xb48ee411,0x4bff345d, 0xfd45c240,0xad31973f,0xc4f6d02e,0x55fc8165, 0xd5b1caad,0xa1ac2dae,0xa2d4b76d,0xc19b0c50, 0x882240f2,0x0c6e4f38,0xa4e4bfd7,0x4f5ba272, 0x564c1d2f,0xc59c5319,0xb949e354,0xb04669fe, 0xb1b6ab8a,0xc71358dd,0x6385c545,0x110f935d, 0x57538ad5,0x6a390493,0xe63d37e0,0x2a54f6b3, 0x3a787d5f,0x6276a0b5,0x19a6fcdf,0x7a42206a, 0x29f9d4d5,0xf61b1891,0xbb72275e,0xaa508167, 0x38901091,0xc6b505eb,0x84c7cb8c,0x2ad75a0f, 0x874a1427,0xa2d1936b,0x2ad286af,0xaa56d291, 0xd7894360,0x425c750d,0x93b39e26,0x187184c9, 0x6c00b32d,0x73e2bb14,0xa0bebc3c,0x54623779, 0x64459eab,0x3f328b82,0x7718cf82,0x59a2cea6, 0x04ee002e,0x89fe78e6,0x3fab0950,0x325ff6c2, 0x81383f05,0x6963c5c8,0x76cb5ad6,0xd49974c9, 0xca180dcf,0x380782d5,0xc7fa5cf6,0x8ac31511, 0x35e79e13,0x47da91d0,0xf40f9086,0xa7e2419e, 0x31366241,0x051ef495,0xaa573b04,0x4a805d8d, 0x548300d0,0x00322a3c,0xbf64cddf,0xba57a68e, 0x75c6372b,0x50afd341,0xa7c13275,0x915a0bf5, 0x6b54bfab,0x2b0b1426,0xab4cc9d7,0x449ccd82, 0xf7fbf265,0xab85c5f3,0x1b55db94,0xaad4e324, 0xcfa4bd3f,0x2deaa3e2,0x9e204d02,0xc8bd25ac, 0xeadf55b3,0xd5bd9e98,0xe31231b2,0x2ad5ad6c, 0x954329de,0xadbe4528,0xd8710f69,0xaa51c90f, 0xaa786bf6,0x22513f1e,0xaa51a79b,0x2ad344cc, 0x7b5a41f0,0xd37cfbad,0x1b069505,0x41ece491, 0xb4c332e6,0x032268d4,0xc9600acc,0xce387e6d, 0xbf6bb16c,0x6a70fb78,0x0d03d9c9,0xd4df39de, 0xe01063da,0x4736f464,0x5ad328d8,0xb347cc96, 0x75bb0fc3,0x98511bfb,0x4ffbcc35,0xb58bcf6a, 0xe11f0abc,0xbfc5fe4a,0xa70aec10,0xac39570a, 0x3f04442f,0x6188b153,0xe0397a2e,0x5727cb79, 0x9ceb418f,0x1cacd68d,0x2ad37c96,0x0175cb9d, 0xc69dff09,0xc75b65f0,0xd9db40d8,0xec0e7779, 0x4744ead4,0xb11c3274,0xdd24cb9e,0x7e1c54bd, 0xf01144f9,0xd2240eb1,0x9675b3fd,0xa3ac3755, 0xd47c27af,0x51c85f4d,0x56907596,0xa5bb15e6, 0x580304f0,0xca042cf1,0x011a37ea,0x8dbfaadb, 0x35ba3e4a,0x3526ffa0,0xc37b4d09,0xbc306ed9, 0x98a52666,0x5648f725,0xff5e569d,0x0ced63d0, 0x7c63b2cf,0x700b45e1,0xd5ea50f1,0x85a92872, 0xaf1fbda7,0xd4234870,0xa7870bf3,0x2d3b4d79, 0x42e04198,0x0cd0ede7,0x26470db8,0xf881814c, 0x474d6ad7,0x7c0c5e5c,0xd1231959,0x381b7298, 0xf5d2f4db,0xab838653,0x6e2f1e23,0x83719c9e, 0xbd91e046,0x9a56456e,0xdc39200c,0x20c8c571, 0x962bda1c,0xe1e696ff,0xb141ab08,0x7cca89b9, 0x1a69e783,0x02cc4843,0xa2f7c579,0x429ef47d, 0x427b169c,0x5ac9f049,0xdd8f0f00,0x5c8165bf, }; const CAST_LONG CAST_S_table1[256]={ 0x1f201094,0xef0ba75b,0x69e3cf7e,0x393f4380, 0xfe61cf7a,0xeec5207a,0x55889c94,0x72fc0651, 0xada7ef79,0x4e1d7235,0xd55a63ce,0xde0436ba, 0x99c430ef,0x5f0c0794,0x18dcdb7d,0xa1d6eff3, 0xa0b52f7b,0x59e83605,0xee15b094,0xe9ffd909, 0xdc440086,0xef944459,0xba83ccb3,0xe0c3cdfb, 0xd1da4181,0x3b092ab1,0xf997f1c1,0xa5e6cf7b, 0x01420ddb,0xe4e7ef5b,0x25a1ff41,0xe180f806, 0x1fc41080,0x179bee7a,0xd37ac6a9,0xfe5830a4, 0x98de8b7f,0x77e83f4e,0x79929269,0x24fa9f7b, 0xe113c85b,0xacc40083,0xd7503525,0xf7ea615f, 0x62143154,0x0d554b63,0x5d681121,0xc866c359, 0x3d63cf73,0xcee234c0,0xd4d87e87,0x5c672b21, 0x071f6181,0x39f7627f,0x361e3084,0xe4eb573b, 0x602f64a4,0xd63acd9c,0x1bbc4635,0x9e81032d, 0x2701f50c,0x99847ab4,0xa0e3df79,0xba6cf38c, 0x10843094,0x2537a95e,0xf46f6ffe,0xa1ff3b1f, 0x208cfb6a,0x8f458c74,0xd9e0a227,0x4ec73a34, 0xfc884f69,0x3e4de8df,0xef0e0088,0x3559648d, 0x8a45388c,0x1d804366,0x721d9bfd,0xa58684bb, 0xe8256333,0x844e8212,0x128d8098,0xfed33fb4, 0xce280ae1,0x27e19ba5,0xd5a6c252,0xe49754bd, 0xc5d655dd,0xeb667064,0x77840b4d,0xa1b6a801, 0x84db26a9,0xe0b56714,0x21f043b7,0xe5d05860, 0x54f03084,0x066ff472,0xa31aa153,0xdadc4755, 0xb5625dbf,0x68561be6,0x83ca6b94,0x2d6ed23b, 0xeccf01db,0xa6d3d0ba,0xb6803d5c,0xaf77a709, 0x33b4a34c,0x397bc8d6,0x5ee22b95,0x5f0e5304, 0x81ed6f61,0x20e74364,0xb45e1378,0xde18639b, 0x881ca122,0xb96726d1,0x8049a7e8,0x22b7da7b, 0x5e552d25,0x5272d237,0x79d2951c,0xc60d894c, 0x488cb402,0x1ba4fe5b,0xa4b09f6b,0x1ca815cf, 0xa20c3005,0x8871df63,0xb9de2fcb,0x0cc6c9e9, 0x0beeff53,0xe3214517,0xb4542835,0x9f63293c, 0xee41e729,0x6e1d2d7c,0x50045286,0x1e6685f3, 0xf33401c6,0x30a22c95,0x31a70850,0x60930f13, 0x73f98417,0xa1269859,0xec645c44,0x52c877a9, 0xcdff33a6,0xa02b1741,0x7cbad9a2,0x2180036f, 0x50d99c08,0xcb3f4861,0xc26bd765,0x64a3f6ab, 0x80342676,0x25a75e7b,0xe4e6d1fc,0x20c710e6, 0xcdf0b680,0x17844d3b,0x31eef84d,0x7e0824e4, 0x2ccb49eb,0x846a3bae,0x8ff77888,0xee5d60f6, 0x7af75673,0x2fdd5cdb,0xa11631c1,0x30f66f43, 0xb3faec54,0x157fd7fa,0xef8579cc,0xd152de58, 0xdb2ffd5e,0x8f32ce19,0x306af97a,0x02f03ef8, 0x99319ad5,0xc242fa0f,0xa7e3ebb0,0xc68e4906, 0xb8da230c,0x80823028,0xdcdef3c8,0xd35fb171, 0x088a1bc8,0xbec0c560,0x61a3c9e8,0xbca8f54d, 0xc72feffa,0x22822e99,0x82c570b4,0xd8d94e89, 0x8b1c34bc,0x301e16e6,0x273be979,0xb0ffeaa6, 0x61d9b8c6,0x00b24869,0xb7ffce3f,0x08dc283b, 0x43daf65a,0xf7e19798,0x7619b72f,0x8f1c9ba4, 0xdc8637a0,0x16a7d3b1,0x9fc393b7,0xa7136eeb, 0xc6bcc63e,0x1a513742,0xef6828bc,0x520365d6, 0x2d6a77ab,0x3527ed4b,0x821fd216,0x095c6e2e, 0xdb92f2fb,0x5eea29cb,0x145892f5,0x91584f7f, 0x5483697b,0x2667a8cc,0x85196048,0x8c4bacea, 0x833860d4,0x0d23e0f9,0x6c387e8a,0x0ae6d249, 0xb284600c,0xd835731d,0xdcb1c647,0xac4c56ea, 0x3ebd81b3,0x230eabb0,0x6438bc87,0xf0b5b1fa, 0x8f5ea2b3,0xfc184642,0x0a036b7a,0x4fb089bd, 0x649da589,0xa345415e,0x5c038323,0x3e5d3bb9, 0x43d79572,0x7e6dd07c,0x06dfdf1e,0x6c6cc4ef, 0x7160a539,0x73bfbe70,0x83877605,0x4523ecf1, }; const CAST_LONG CAST_S_table2[256]={ 0x8defc240,0x25fa5d9f,0xeb903dbf,0xe810c907, 0x47607fff,0x369fe44b,0x8c1fc644,0xaececa90, 0xbeb1f9bf,0xeefbcaea,0xe8cf1950,0x51df07ae, 0x920e8806,0xf0ad0548,0xe13c8d83,0x927010d5, 0x11107d9f,0x07647db9,0xb2e3e4d4,0x3d4f285e, 0xb9afa820,0xfade82e0,0xa067268b,0x8272792e, 0x553fb2c0,0x489ae22b,0xd4ef9794,0x125e3fbc, 0x21fffcee,0x825b1bfd,0x9255c5ed,0x1257a240, 0x4e1a8302,0xbae07fff,0x528246e7,0x8e57140e, 0x3373f7bf,0x8c9f8188,0xa6fc4ee8,0xc982b5a5, 0xa8c01db7,0x579fc264,0x67094f31,0xf2bd3f5f, 0x40fff7c1,0x1fb78dfc,0x8e6bd2c1,0x437be59b, 0x99b03dbf,0xb5dbc64b,0x638dc0e6,0x55819d99, 0xa197c81c,0x4a012d6e,0xc5884a28,0xccc36f71, 0xb843c213,0x6c0743f1,0x8309893c,0x0feddd5f, 0x2f7fe850,0xd7c07f7e,0x02507fbf,0x5afb9a04, 0xa747d2d0,0x1651192e,0xaf70bf3e,0x58c31380, 0x5f98302e,0x727cc3c4,0x0a0fb402,0x0f7fef82, 0x8c96fdad,0x5d2c2aae,0x8ee99a49,0x50da88b8, 0x8427f4a0,0x1eac5790,0x796fb449,0x8252dc15, 0xefbd7d9b,0xa672597d,0xada840d8,0x45f54504, 0xfa5d7403,0xe83ec305,0x4f91751a,0x925669c2, 0x23efe941,0xa903f12e,0x60270df2,0x0276e4b6, 0x94fd6574,0x927985b2,0x8276dbcb,0x02778176, 0xf8af918d,0x4e48f79e,0x8f616ddf,0xe29d840e, 0x842f7d83,0x340ce5c8,0x96bbb682,0x93b4b148, 0xef303cab,0x984faf28,0x779faf9b,0x92dc560d, 0x224d1e20,0x8437aa88,0x7d29dc96,0x2756d3dc, 0x8b907cee,0xb51fd240,0xe7c07ce3,0xe566b4a1, 0xc3e9615e,0x3cf8209d,0x6094d1e3,0xcd9ca341, 0x5c76460e,0x00ea983b,0xd4d67881,0xfd47572c, 0xf76cedd9,0xbda8229c,0x127dadaa,0x438a074e, 0x1f97c090,0x081bdb8a,0x93a07ebe,0xb938ca15, 0x97b03cff,0x3dc2c0f8,0x8d1ab2ec,0x64380e51, 0x68cc7bfb,0xd90f2788,0x12490181,0x5de5ffd4, 0xdd7ef86a,0x76a2e214,0xb9a40368,0x925d958f, 0x4b39fffa,0xba39aee9,0xa4ffd30b,0xfaf7933b, 0x6d498623,0x193cbcfa,0x27627545,0x825cf47a, 0x61bd8ba0,0xd11e42d1,0xcead04f4,0x127ea392, 0x10428db7,0x8272a972,0x9270c4a8,0x127de50b, 0x285ba1c8,0x3c62f44f,0x35c0eaa5,0xe805d231, 0x428929fb,0xb4fcdf82,0x4fb66a53,0x0e7dc15b, 0x1f081fab,0x108618ae,0xfcfd086d,0xf9ff2889, 0x694bcc11,0x236a5cae,0x12deca4d,0x2c3f8cc5, 0xd2d02dfe,0xf8ef5896,0xe4cf52da,0x95155b67, 0x494a488c,0xb9b6a80c,0x5c8f82bc,0x89d36b45, 0x3a609437,0xec00c9a9,0x44715253,0x0a874b49, 0xd773bc40,0x7c34671c,0x02717ef6,0x4feb5536, 0xa2d02fff,0xd2bf60c4,0xd43f03c0,0x50b4ef6d, 0x07478cd1,0x006e1888,0xa2e53f55,0xb9e6d4bc, 0xa2048016,0x97573833,0xd7207d67,0xde0f8f3d, 0x72f87b33,0xabcc4f33,0x7688c55d,0x7b00a6b0, 0x947b0001,0x570075d2,0xf9bb88f8,0x8942019e, 0x4264a5ff,0x856302e0,0x72dbd92b,0xee971b69, 0x6ea22fde,0x5f08ae2b,0xaf7a616d,0xe5c98767, 0xcf1febd2,0x61efc8c2,0xf1ac2571,0xcc8239c2, 0x67214cb8,0xb1e583d1,0xb7dc3e62,0x7f10bdce, 0xf90a5c38,0x0ff0443d,0x606e6dc6,0x60543a49, 0x5727c148,0x2be98a1d,0x8ab41738,0x20e1be24, 0xaf96da0f,0x68458425,0x99833be5,0x600d457d, 0x282f9350,0x8334b362,0xd91d1120,0x2b6d8da0, 0x642b1e31,0x9c305a00,0x52bce688,0x1b03588a, 0xf7baefd5,0x4142ed9c,0xa4315c11,0x83323ec5, 0xdfef4636,0xa133c501,0xe9d3531c,0xee353783, }; const CAST_LONG CAST_S_table3[256]={ 0x9db30420,0x1fb6e9de,0xa7be7bef,0xd273a298, 0x4a4f7bdb,0x64ad8c57,0x85510443,0xfa020ed1, 0x7e287aff,0xe60fb663,0x095f35a1,0x79ebf120, 0xfd059d43,0x6497b7b1,0xf3641f63,0x241e4adf, 0x28147f5f,0x4fa2b8cd,0xc9430040,0x0cc32220, 0xfdd30b30,0xc0a5374f,0x1d2d00d9,0x24147b15, 0xee4d111a,0x0fca5167,0x71ff904c,0x2d195ffe, 0x1a05645f,0x0c13fefe,0x081b08ca,0x05170121, 0x80530100,0xe83e5efe,0xac9af4f8,0x7fe72701, 0xd2b8ee5f,0x06df4261,0xbb9e9b8a,0x7293ea25, 0xce84ffdf,0xf5718801,0x3dd64b04,0xa26f263b, 0x7ed48400,0x547eebe6,0x446d4ca0,0x6cf3d6f5, 0x2649abdf,0xaea0c7f5,0x36338cc1,0x503f7e93, 0xd3772061,0x11b638e1,0x72500e03,0xf80eb2bb, 0xabe0502e,0xec8d77de,0x57971e81,0xe14f6746, 0xc9335400,0x6920318f,0x081dbb99,0xffc304a5, 0x4d351805,0x7f3d5ce3,0xa6c866c6,0x5d5bcca9, 0xdaec6fea,0x9f926f91,0x9f46222f,0x3991467d, 0xa5bf6d8e,0x1143c44f,0x43958302,0xd0214eeb, 0x022083b8,0x3fb6180c,0x18f8931e,0x281658e6, 0x26486e3e,0x8bd78a70,0x7477e4c1,0xb506e07c, 0xf32d0a25,0x79098b02,0xe4eabb81,0x28123b23, 0x69dead38,0x1574ca16,0xdf871b62,0x211c40b7, 0xa51a9ef9,0x0014377b,0x041e8ac8,0x09114003, 0xbd59e4d2,0xe3d156d5,0x4fe876d5,0x2f91a340, 0x557be8de,0x00eae4a7,0x0ce5c2ec,0x4db4bba6, 0xe756bdff,0xdd3369ac,0xec17b035,0x06572327, 0x99afc8b0,0x56c8c391,0x6b65811c,0x5e146119, 0x6e85cb75,0xbe07c002,0xc2325577,0x893ff4ec, 0x5bbfc92d,0xd0ec3b25,0xb7801ab7,0x8d6d3b24, 0x20c763ef,0xc366a5fc,0x9c382880,0x0ace3205, 0xaac9548a,0xeca1d7c7,0x041afa32,0x1d16625a, 0x6701902c,0x9b757a54,0x31d477f7,0x9126b031, 0x36cc6fdb,0xc70b8b46,0xd9e66a48,0x56e55a79, 0x026a4ceb,0x52437eff,0x2f8f76b4,0x0df980a5, 0x8674cde3,0xedda04eb,0x17a9be04,0x2c18f4df, 0xb7747f9d,0xab2af7b4,0xefc34d20,0x2e096b7c, 0x1741a254,0xe5b6a035,0x213d42f6,0x2c1c7c26, 0x61c2f50f,0x6552daf9,0xd2c231f8,0x25130f69, 0xd8167fa2,0x0418f2c8,0x001a96a6,0x0d1526ab, 0x63315c21,0x5e0a72ec,0x49bafefd,0x187908d9, 0x8d0dbd86,0x311170a7,0x3e9b640c,0xcc3e10d7, 0xd5cad3b6,0x0caec388,0xf73001e1,0x6c728aff, 0x71eae2a1,0x1f9af36e,0xcfcbd12f,0xc1de8417, 0xac07be6b,0xcb44a1d8,0x8b9b0f56,0x013988c3, 0xb1c52fca,0xb4be31cd,0xd8782806,0x12a3a4e2, 0x6f7de532,0x58fd7eb6,0xd01ee900,0x24adffc2, 0xf4990fc5,0x9711aac5,0x001d7b95,0x82e5e7d2, 0x109873f6,0x00613096,0xc32d9521,0xada121ff, 0x29908415,0x7fbb977f,0xaf9eb3db,0x29c9ed2a, 0x5ce2a465,0xa730f32c,0xd0aa3fe8,0x8a5cc091, 0xd49e2ce7,0x0ce454a9,0xd60acd86,0x015f1919, 0x77079103,0xdea03af6,0x78a8565e,0xdee356df, 0x21f05cbe,0x8b75e387,0xb3c50651,0xb8a5c3ef, 0xd8eeb6d2,0xe523be77,0xc2154529,0x2f69efdf, 0xafe67afb,0xf470c4b2,0xf3e0eb5b,0xd6cc9876, 0x39e4460c,0x1fda8538,0x1987832f,0xca007367, 0xa99144f8,0x296b299e,0x492fc295,0x9266beab, 0xb5676e69,0x9bd3ddda,0xdf7e052f,0xdb25701c, 0x1b5e51ee,0xf65324e6,0x6afce36c,0x0316cc04, 0x8644213e,0xb7dc59d0,0x7965291f,0xccd6fd43, 0x41823979,0x932bcdf6,0xb657c34d,0x4edfd282, 0x7ae5290c,0x3cb9536b,0x851e20fe,0x9833557e, 0x13ecf0b0,0xd3ffb372,0x3f85c5c1,0x0aef7ed2, }; const CAST_LONG CAST_S_table4[256]={ 0x7ec90c04,0x2c6e74b9,0x9b0e66df,0xa6337911, 0xb86a7fff,0x1dd358f5,0x44dd9d44,0x1731167f, 0x08fbf1fa,0xe7f511cc,0xd2051b00,0x735aba00, 0x2ab722d8,0x386381cb,0xacf6243a,0x69befd7a, 0xe6a2e77f,0xf0c720cd,0xc4494816,0xccf5c180, 0x38851640,0x15b0a848,0xe68b18cb,0x4caadeff, 0x5f480a01,0x0412b2aa,0x259814fc,0x41d0efe2, 0x4e40b48d,0x248eb6fb,0x8dba1cfe,0x41a99b02, 0x1a550a04,0xba8f65cb,0x7251f4e7,0x95a51725, 0xc106ecd7,0x97a5980a,0xc539b9aa,0x4d79fe6a, 0xf2f3f763,0x68af8040,0xed0c9e56,0x11b4958b, 0xe1eb5a88,0x8709e6b0,0xd7e07156,0x4e29fea7, 0x6366e52d,0x02d1c000,0xc4ac8e05,0x9377f571, 0x0c05372a,0x578535f2,0x2261be02,0xd642a0c9, 0xdf13a280,0x74b55bd2,0x682199c0,0xd421e5ec, 0x53fb3ce8,0xc8adedb3,0x28a87fc9,0x3d959981, 0x5c1ff900,0xfe38d399,0x0c4eff0b,0x062407ea, 0xaa2f4fb1,0x4fb96976,0x90c79505,0xb0a8a774, 0xef55a1ff,0xe59ca2c2,0xa6b62d27,0xe66a4263, 0xdf65001f,0x0ec50966,0xdfdd55bc,0x29de0655, 0x911e739a,0x17af8975,0x32c7911c,0x89f89468, 0x0d01e980,0x524755f4,0x03b63cc9,0x0cc844b2, 0xbcf3f0aa,0x87ac36e9,0xe53a7426,0x01b3d82b, 0x1a9e7449,0x64ee2d7e,0xcddbb1da,0x01c94910, 0xb868bf80,0x0d26f3fd,0x9342ede7,0x04a5c284, 0x636737b6,0x50f5b616,0xf24766e3,0x8eca36c1, 0x136e05db,0xfef18391,0xfb887a37,0xd6e7f7d4, 0xc7fb7dc9,0x3063fcdf,0xb6f589de,0xec2941da, 0x26e46695,0xb7566419,0xf654efc5,0xd08d58b7, 0x48925401,0xc1bacb7f,0xe5ff550f,0xb6083049, 0x5bb5d0e8,0x87d72e5a,0xab6a6ee1,0x223a66ce, 0xc62bf3cd,0x9e0885f9,0x68cb3e47,0x086c010f, 0xa21de820,0xd18b69de,0xf3f65777,0xfa02c3f6, 0x407edac3,0xcbb3d550,0x1793084d,0xb0d70eba, 0x0ab378d5,0xd951fb0c,0xded7da56,0x4124bbe4, 0x94ca0b56,0x0f5755d1,0xe0e1e56e,0x6184b5be, 0x580a249f,0x94f74bc0,0xe327888e,0x9f7b5561, 0xc3dc0280,0x05687715,0x646c6bd7,0x44904db3, 0x66b4f0a3,0xc0f1648a,0x697ed5af,0x49e92ff6, 0x309e374f,0x2cb6356a,0x85808573,0x4991f840, 0x76f0ae02,0x083be84d,0x28421c9a,0x44489406, 0x736e4cb8,0xc1092910,0x8bc95fc6,0x7d869cf4, 0x134f616f,0x2e77118d,0xb31b2be1,0xaa90b472, 0x3ca5d717,0x7d161bba,0x9cad9010,0xaf462ba2, 0x9fe459d2,0x45d34559,0xd9f2da13,0xdbc65487, 0xf3e4f94e,0x176d486f,0x097c13ea,0x631da5c7, 0x445f7382,0x175683f4,0xcdc66a97,0x70be0288, 0xb3cdcf72,0x6e5dd2f3,0x20936079,0x459b80a5, 0xbe60e2db,0xa9c23101,0xeba5315c,0x224e42f2, 0x1c5c1572,0xf6721b2c,0x1ad2fff3,0x8c25404e, 0x324ed72f,0x4067b7fd,0x0523138e,0x5ca3bc78, 0xdc0fd66e,0x75922283,0x784d6b17,0x58ebb16e, 0x44094f85,0x3f481d87,0xfcfeae7b,0x77b5ff76, 0x8c2302bf,0xaaf47556,0x5f46b02a,0x2b092801, 0x3d38f5f7,0x0ca81f36,0x52af4a8a,0x66d5e7c0, 0xdf3b0874,0x95055110,0x1b5ad7a8,0xf61ed5ad, 0x6cf6e479,0x20758184,0xd0cefa65,0x88f7be58, 0x4a046826,0x0ff6f8f3,0xa09c7f70,0x5346aba0, 0x5ce96c28,0xe176eda3,0x6bac307f,0x376829d2, 0x85360fa9,0x17e3fe2a,0x24b79767,0xf5a96b20, 0xd6cd2595,0x68ff1ebf,0x7555442c,0xf19f06be, 0xf9e0659a,0xeeb9491d,0x34010718,0xbb30cab8, 0xe822fe15,0x88570983,0x750e6249,0xda627e55, 0x5e76ffa8,0xb1534546,0x6d47de08,0xefe9e7d4, }; const CAST_LONG CAST_S_table5[256]={ 0xf6fa8f9d,0x2cac6ce1,0x4ca34867,0xe2337f7c, 0x95db08e7,0x016843b4,0xeced5cbc,0x325553ac, 0xbf9f0960,0xdfa1e2ed,0x83f0579d,0x63ed86b9, 0x1ab6a6b8,0xde5ebe39,0xf38ff732,0x8989b138, 0x33f14961,0xc01937bd,0xf506c6da,0xe4625e7e, 0xa308ea99,0x4e23e33c,0x79cbd7cc,0x48a14367, 0xa3149619,0xfec94bd5,0xa114174a,0xeaa01866, 0xa084db2d,0x09a8486f,0xa888614a,0x2900af98, 0x01665991,0xe1992863,0xc8f30c60,0x2e78ef3c, 0xd0d51932,0xcf0fec14,0xf7ca07d2,0xd0a82072, 0xfd41197e,0x9305a6b0,0xe86be3da,0x74bed3cd, 0x372da53c,0x4c7f4448,0xdab5d440,0x6dba0ec3, 0x083919a7,0x9fbaeed9,0x49dbcfb0,0x4e670c53, 0x5c3d9c01,0x64bdb941,0x2c0e636a,0xba7dd9cd, 0xea6f7388,0xe70bc762,0x35f29adb,0x5c4cdd8d, 0xf0d48d8c,0xb88153e2,0x08a19866,0x1ae2eac8, 0x284caf89,0xaa928223,0x9334be53,0x3b3a21bf, 0x16434be3,0x9aea3906,0xefe8c36e,0xf890cdd9, 0x80226dae,0xc340a4a3,0xdf7e9c09,0xa694a807, 0x5b7c5ecc,0x221db3a6,0x9a69a02f,0x68818a54, 0xceb2296f,0x53c0843a,0xfe893655,0x25bfe68a, 0xb4628abc,0xcf222ebf,0x25ac6f48,0xa9a99387, 0x53bddb65,0xe76ffbe7,0xe967fd78,0x0ba93563, 0x8e342bc1,0xe8a11be9,0x4980740d,0xc8087dfc, 0x8de4bf99,0xa11101a0,0x7fd37975,0xda5a26c0, 0xe81f994f,0x9528cd89,0xfd339fed,0xb87834bf, 0x5f04456d,0x22258698,0xc9c4c83b,0x2dc156be, 0x4f628daa,0x57f55ec5,0xe2220abe,0xd2916ebf, 0x4ec75b95,0x24f2c3c0,0x42d15d99,0xcd0d7fa0, 0x7b6e27ff,0xa8dc8af0,0x7345c106,0xf41e232f, 0x35162386,0xe6ea8926,0x3333b094,0x157ec6f2, 0x372b74af,0x692573e4,0xe9a9d848,0xf3160289, 0x3a62ef1d,0xa787e238,0xf3a5f676,0x74364853, 0x20951063,0x4576698d,0xb6fad407,0x592af950, 0x36f73523,0x4cfb6e87,0x7da4cec0,0x6c152daa, 0xcb0396a8,0xc50dfe5d,0xfcd707ab,0x0921c42f, 0x89dff0bb,0x5fe2be78,0x448f4f33,0x754613c9, 0x2b05d08d,0x48b9d585,0xdc049441,0xc8098f9b, 0x7dede786,0xc39a3373,0x42410005,0x6a091751, 0x0ef3c8a6,0x890072d6,0x28207682,0xa9a9f7be, 0xbf32679d,0xd45b5b75,0xb353fd00,0xcbb0e358, 0x830f220a,0x1f8fb214,0xd372cf08,0xcc3c4a13, 0x8cf63166,0x061c87be,0x88c98f88,0x6062e397, 0x47cf8e7a,0xb6c85283,0x3cc2acfb,0x3fc06976, 0x4e8f0252,0x64d8314d,0xda3870e3,0x1e665459, 0xc10908f0,0x513021a5,0x6c5b68b7,0x822f8aa0, 0x3007cd3e,0x74719eef,0xdc872681,0x073340d4, 0x7e432fd9,0x0c5ec241,0x8809286c,0xf592d891, 0x08a930f6,0x957ef305,0xb7fbffbd,0xc266e96f, 0x6fe4ac98,0xb173ecc0,0xbc60b42a,0x953498da, 0xfba1ae12,0x2d4bd736,0x0f25faab,0xa4f3fceb, 0xe2969123,0x257f0c3d,0x9348af49,0x361400bc, 0xe8816f4a,0x3814f200,0xa3f94043,0x9c7a54c2, 0xbc704f57,0xda41e7f9,0xc25ad33a,0x54f4a084, 0xb17f5505,0x59357cbe,0xedbd15c8,0x7f97c5ab, 0xba5ac7b5,0xb6f6deaf,0x3a479c3a,0x5302da25, 0x653d7e6a,0x54268d49,0x51a477ea,0x5017d55b, 0xd7d25d88,0x44136c76,0x0404a8c8,0xb8e5a121, 0xb81a928a,0x60ed5869,0x97c55b96,0xeaec991b, 0x29935913,0x01fdb7f1,0x088e8dfa,0x9ab6f6f5, 0x3b4cbf9f,0x4a5de3ab,0xe6051d35,0xa0e1d855, 0xd36b4cf1,0xf544edeb,0xb0e93524,0xbebb8fbd, 0xa2d762cf,0x49c92f54,0x38b5f331,0x7128a454, 0x48392905,0xa65b1db8,0x851c97bd,0xd675cf2f, }; const CAST_LONG CAST_S_table6[256]={ 0x85e04019,0x332bf567,0x662dbfff,0xcfc65693, 0x2a8d7f6f,0xab9bc912,0xde6008a1,0x2028da1f, 0x0227bce7,0x4d642916,0x18fac300,0x50f18b82, 0x2cb2cb11,0xb232e75c,0x4b3695f2,0xb28707de, 0xa05fbcf6,0xcd4181e9,0xe150210c,0xe24ef1bd, 0xb168c381,0xfde4e789,0x5c79b0d8,0x1e8bfd43, 0x4d495001,0x38be4341,0x913cee1d,0x92a79c3f, 0x089766be,0xbaeeadf4,0x1286becf,0xb6eacb19, 0x2660c200,0x7565bde4,0x64241f7a,0x8248dca9, 0xc3b3ad66,0x28136086,0x0bd8dfa8,0x356d1cf2, 0x107789be,0xb3b2e9ce,0x0502aa8f,0x0bc0351e, 0x166bf52a,0xeb12ff82,0xe3486911,0xd34d7516, 0x4e7b3aff,0x5f43671b,0x9cf6e037,0x4981ac83, 0x334266ce,0x8c9341b7,0xd0d854c0,0xcb3a6c88, 0x47bc2829,0x4725ba37,0xa66ad22b,0x7ad61f1e, 0x0c5cbafa,0x4437f107,0xb6e79962,0x42d2d816, 0x0a961288,0xe1a5c06e,0x13749e67,0x72fc081a, 0xb1d139f7,0xf9583745,0xcf19df58,0xbec3f756, 0xc06eba30,0x07211b24,0x45c28829,0xc95e317f, 0xbc8ec511,0x38bc46e9,0xc6e6fa14,0xbae8584a, 0xad4ebc46,0x468f508b,0x7829435f,0xf124183b, 0x821dba9f,0xaff60ff4,0xea2c4e6d,0x16e39264, 0x92544a8b,0x009b4fc3,0xaba68ced,0x9ac96f78, 0x06a5b79a,0xb2856e6e,0x1aec3ca9,0xbe838688, 0x0e0804e9,0x55f1be56,0xe7e5363b,0xb3a1f25d, 0xf7debb85,0x61fe033c,0x16746233,0x3c034c28, 0xda6d0c74,0x79aac56c,0x3ce4e1ad,0x51f0c802, 0x98f8f35a,0x1626a49f,0xeed82b29,0x1d382fe3, 0x0c4fb99a,0xbb325778,0x3ec6d97b,0x6e77a6a9, 0xcb658b5c,0xd45230c7,0x2bd1408b,0x60c03eb7, 0xb9068d78,0xa33754f4,0xf430c87d,0xc8a71302, 0xb96d8c32,0xebd4e7be,0xbe8b9d2d,0x7979fb06, 0xe7225308,0x8b75cf77,0x11ef8da4,0xe083c858, 0x8d6b786f,0x5a6317a6,0xfa5cf7a0,0x5dda0033, 0xf28ebfb0,0xf5b9c310,0xa0eac280,0x08b9767a, 0xa3d9d2b0,0x79d34217,0x021a718d,0x9ac6336a, 0x2711fd60,0x438050e3,0x069908a8,0x3d7fedc4, 0x826d2bef,0x4eeb8476,0x488dcf25,0x36c9d566, 0x28e74e41,0xc2610aca,0x3d49a9cf,0xbae3b9df, 0xb65f8de6,0x92aeaf64,0x3ac7d5e6,0x9ea80509, 0xf22b017d,0xa4173f70,0xdd1e16c3,0x15e0d7f9, 0x50b1b887,0x2b9f4fd5,0x625aba82,0x6a017962, 0x2ec01b9c,0x15488aa9,0xd716e740,0x40055a2c, 0x93d29a22,0xe32dbf9a,0x058745b9,0x3453dc1e, 0xd699296e,0x496cff6f,0x1c9f4986,0xdfe2ed07, 0xb87242d1,0x19de7eae,0x053e561a,0x15ad6f8c, 0x66626c1c,0x7154c24c,0xea082b2a,0x93eb2939, 0x17dcb0f0,0x58d4f2ae,0x9ea294fb,0x52cf564c, 0x9883fe66,0x2ec40581,0x763953c3,0x01d6692e, 0xd3a0c108,0xa1e7160e,0xe4f2dfa6,0x693ed285, 0x74904698,0x4c2b0edd,0x4f757656,0x5d393378, 0xa132234f,0x3d321c5d,0xc3f5e194,0x4b269301, 0xc79f022f,0x3c997e7e,0x5e4f9504,0x3ffafbbd, 0x76f7ad0e,0x296693f4,0x3d1fce6f,0xc61e45be, 0xd3b5ab34,0xf72bf9b7,0x1b0434c0,0x4e72b567, 0x5592a33d,0xb5229301,0xcfd2a87f,0x60aeb767, 0x1814386b,0x30bcc33d,0x38a0c07d,0xfd1606f2, 0xc363519b,0x589dd390,0x5479f8e6,0x1cb8d647, 0x97fd61a9,0xea7759f4,0x2d57539d,0x569a58cf, 0xe84e63ad,0x462e1b78,0x6580f87e,0xf3817914, 0x91da55f4,0x40a230f3,0xd1988f35,0xb6e318d2, 0x3ffa50bc,0x3d40f021,0xc3c0bdae,0x4958c24c, 0x518f36b2,0x84b1d370,0x0fedce83,0x878ddada, 0xf2a279c7,0x94e01be8,0x90716f4b,0x954b8aa3, }; const CAST_LONG CAST_S_table7[256]={ 0xe216300d,0xbbddfffc,0xa7ebdabd,0x35648095, 0x7789f8b7,0xe6c1121b,0x0e241600,0x052ce8b5, 0x11a9cfb0,0xe5952f11,0xece7990a,0x9386d174, 0x2a42931c,0x76e38111,0xb12def3a,0x37ddddfc, 0xde9adeb1,0x0a0cc32c,0xbe197029,0x84a00940, 0xbb243a0f,0xb4d137cf,0xb44e79f0,0x049eedfd, 0x0b15a15d,0x480d3168,0x8bbbde5a,0x669ded42, 0xc7ece831,0x3f8f95e7,0x72df191b,0x7580330d, 0x94074251,0x5c7dcdfa,0xabbe6d63,0xaa402164, 0xb301d40a,0x02e7d1ca,0x53571dae,0x7a3182a2, 0x12a8ddec,0xfdaa335d,0x176f43e8,0x71fb46d4, 0x38129022,0xce949ad4,0xb84769ad,0x965bd862, 0x82f3d055,0x66fb9767,0x15b80b4e,0x1d5b47a0, 0x4cfde06f,0xc28ec4b8,0x57e8726e,0x647a78fc, 0x99865d44,0x608bd593,0x6c200e03,0x39dc5ff6, 0x5d0b00a3,0xae63aff2,0x7e8bd632,0x70108c0c, 0xbbd35049,0x2998df04,0x980cf42a,0x9b6df491, 0x9e7edd53,0x06918548,0x58cb7e07,0x3b74ef2e, 0x522fffb1,0xd24708cc,0x1c7e27cd,0xa4eb215b, 0x3cf1d2e2,0x19b47a38,0x424f7618,0x35856039, 0x9d17dee7,0x27eb35e6,0xc9aff67b,0x36baf5b8, 0x09c467cd,0xc18910b1,0xe11dbf7b,0x06cd1af8, 0x7170c608,0x2d5e3354,0xd4de495a,0x64c6d006, 0xbcc0c62c,0x3dd00db3,0x708f8f34,0x77d51b42, 0x264f620f,0x24b8d2bf,0x15c1b79e,0x46a52564, 0xf8d7e54e,0x3e378160,0x7895cda5,0x859c15a5, 0xe6459788,0xc37bc75f,0xdb07ba0c,0x0676a3ab, 0x7f229b1e,0x31842e7b,0x24259fd7,0xf8bef472, 0x835ffcb8,0x6df4c1f2,0x96f5b195,0xfd0af0fc, 0xb0fe134c,0xe2506d3d,0x4f9b12ea,0xf215f225, 0xa223736f,0x9fb4c428,0x25d04979,0x34c713f8, 0xc4618187,0xea7a6e98,0x7cd16efc,0x1436876c, 0xf1544107,0xbedeee14,0x56e9af27,0xa04aa441, 0x3cf7c899,0x92ecbae6,0xdd67016d,0x151682eb, 0xa842eedf,0xfdba60b4,0xf1907b75,0x20e3030f, 0x24d8c29e,0xe139673b,0xefa63fb8,0x71873054, 0xb6f2cf3b,0x9f326442,0xcb15a4cc,0xb01a4504, 0xf1e47d8d,0x844a1be5,0xbae7dfdc,0x42cbda70, 0xcd7dae0a,0x57e85b7a,0xd53f5af6,0x20cf4d8c, 0xcea4d428,0x79d130a4,0x3486ebfb,0x33d3cddc, 0x77853b53,0x37effcb5,0xc5068778,0xe580b3e6, 0x4e68b8f4,0xc5c8b37e,0x0d809ea2,0x398feb7c, 0x132a4f94,0x43b7950e,0x2fee7d1c,0x223613bd, 0xdd06caa2,0x37df932b,0xc4248289,0xacf3ebc3, 0x5715f6b7,0xef3478dd,0xf267616f,0xc148cbe4, 0x9052815e,0x5e410fab,0xb48a2465,0x2eda7fa4, 0xe87b40e4,0xe98ea084,0x5889e9e1,0xefd390fc, 0xdd07d35b,0xdb485694,0x38d7e5b2,0x57720101, 0x730edebc,0x5b643113,0x94917e4f,0x503c2fba, 0x646f1282,0x7523d24a,0xe0779695,0xf9c17a8f, 0x7a5b2121,0xd187b896,0x29263a4d,0xba510cdf, 0x81f47c9f,0xad1163ed,0xea7b5965,0x1a00726e, 0x11403092,0x00da6d77,0x4a0cdd61,0xad1f4603, 0x605bdfb0,0x9eedc364,0x22ebe6a8,0xcee7d28a, 0xa0e736a0,0x5564a6b9,0x10853209,0xc7eb8f37, 0x2de705ca,0x8951570f,0xdf09822b,0xbd691a6c, 0xaa12e4f2,0x87451c0f,0xe0f6a27a,0x3ada4819, 0x4cf1764f,0x0d771c2b,0x67cdb156,0x350d8384, 0x5938fa0f,0x42399ef3,0x36997b07,0x0e84093d, 0x4aa93e61,0x8360d87b,0x1fa98b0c,0x1149382c, 0xe97625a5,0x0614d1b7,0x0e25244b,0x0c768347, 0x589e8d82,0x0d2059d1,0xa466bb1e,0xf8da0a82, 0x04f19130,0xba6e4ec0,0x99265164,0x1ee7230d, 0x50b2ad80,0xeaee6801,0x8db2a283,0xea8bf59e, }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/cast/c_skey.c0000644000175000017500000001453112360020705020632 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include "cast_lcl.h" #include "cast_s.h" #define CAST_exp(l,A,a,n) \ A[n/4]=l; \ a[n+3]=(l )&0xff; \ a[n+2]=(l>> 8)&0xff; \ a[n+1]=(l>>16)&0xff; \ a[n+0]=(l>>24)&0xff; #define S4 CAST_S_table4 #define S5 CAST_S_table5 #define S6 CAST_S_table6 #define S7 CAST_S_table7 void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data) { CAST_LONG x[16]; CAST_LONG z[16]; CAST_LONG k[32]; CAST_LONG X[4],Z[4]; CAST_LONG l,*K; int i; for (i=0; i<16; i++) x[i]=0; if (len > 16) len=16; for (i=0; ishort_key=1; else key->short_key=0; K= &k[0]; X[0]=((x[ 0]<<24)|(x[ 1]<<16)|(x[ 2]<<8)|x[ 3])&0xffffffffL; X[1]=((x[ 4]<<24)|(x[ 5]<<16)|(x[ 6]<<8)|x[ 7])&0xffffffffL; X[2]=((x[ 8]<<24)|(x[ 9]<<16)|(x[10]<<8)|x[11])&0xffffffffL; X[3]=((x[12]<<24)|(x[13]<<16)|(x[14]<<8)|x[15])&0xffffffffL; for (;;) { l=X[0]^S4[x[13]]^S5[x[15]]^S6[x[12]]^S7[x[14]]^S6[x[ 8]]; CAST_exp(l,Z,z, 0); l=X[2]^S4[z[ 0]]^S5[z[ 2]]^S6[z[ 1]]^S7[z[ 3]]^S7[x[10]]; CAST_exp(l,Z,z, 4); l=X[3]^S4[z[ 7]]^S5[z[ 6]]^S6[z[ 5]]^S7[z[ 4]]^S4[x[ 9]]; CAST_exp(l,Z,z, 8); l=X[1]^S4[z[10]]^S5[z[ 9]]^S6[z[11]]^S7[z[ 8]]^S5[x[11]]; CAST_exp(l,Z,z,12); K[ 0]= S4[z[ 8]]^S5[z[ 9]]^S6[z[ 7]]^S7[z[ 6]]^S4[z[ 2]]; K[ 1]= S4[z[10]]^S5[z[11]]^S6[z[ 5]]^S7[z[ 4]]^S5[z[ 6]]; K[ 2]= S4[z[12]]^S5[z[13]]^S6[z[ 3]]^S7[z[ 2]]^S6[z[ 9]]; K[ 3]= S4[z[14]]^S5[z[15]]^S6[z[ 1]]^S7[z[ 0]]^S7[z[12]]; l=Z[2]^S4[z[ 5]]^S5[z[ 7]]^S6[z[ 4]]^S7[z[ 6]]^S6[z[ 0]]; CAST_exp(l,X,x, 0); l=Z[0]^S4[x[ 0]]^S5[x[ 2]]^S6[x[ 1]]^S7[x[ 3]]^S7[z[ 2]]; CAST_exp(l,X,x, 4); l=Z[1]^S4[x[ 7]]^S5[x[ 6]]^S6[x[ 5]]^S7[x[ 4]]^S4[z[ 1]]; CAST_exp(l,X,x, 8); l=Z[3]^S4[x[10]]^S5[x[ 9]]^S6[x[11]]^S7[x[ 8]]^S5[z[ 3]]; CAST_exp(l,X,x,12); K[ 4]= S4[x[ 3]]^S5[x[ 2]]^S6[x[12]]^S7[x[13]]^S4[x[ 8]]; K[ 5]= S4[x[ 1]]^S5[x[ 0]]^S6[x[14]]^S7[x[15]]^S5[x[13]]; K[ 6]= S4[x[ 7]]^S5[x[ 6]]^S6[x[ 8]]^S7[x[ 9]]^S6[x[ 3]]; K[ 7]= S4[x[ 5]]^S5[x[ 4]]^S6[x[10]]^S7[x[11]]^S7[x[ 7]]; l=X[0]^S4[x[13]]^S5[x[15]]^S6[x[12]]^S7[x[14]]^S6[x[ 8]]; CAST_exp(l,Z,z, 0); l=X[2]^S4[z[ 0]]^S5[z[ 2]]^S6[z[ 1]]^S7[z[ 3]]^S7[x[10]]; CAST_exp(l,Z,z, 4); l=X[3]^S4[z[ 7]]^S5[z[ 6]]^S6[z[ 5]]^S7[z[ 4]]^S4[x[ 9]]; CAST_exp(l,Z,z, 8); l=X[1]^S4[z[10]]^S5[z[ 9]]^S6[z[11]]^S7[z[ 8]]^S5[x[11]]; CAST_exp(l,Z,z,12); K[ 8]= S4[z[ 3]]^S5[z[ 2]]^S6[z[12]]^S7[z[13]]^S4[z[ 9]]; K[ 9]= S4[z[ 1]]^S5[z[ 0]]^S6[z[14]]^S7[z[15]]^S5[z[12]]; K[10]= S4[z[ 7]]^S5[z[ 6]]^S6[z[ 8]]^S7[z[ 9]]^S6[z[ 2]]; K[11]= S4[z[ 5]]^S5[z[ 4]]^S6[z[10]]^S7[z[11]]^S7[z[ 6]]; l=Z[2]^S4[z[ 5]]^S5[z[ 7]]^S6[z[ 4]]^S7[z[ 6]]^S6[z[ 0]]; CAST_exp(l,X,x, 0); l=Z[0]^S4[x[ 0]]^S5[x[ 2]]^S6[x[ 1]]^S7[x[ 3]]^S7[z[ 2]]; CAST_exp(l,X,x, 4); l=Z[1]^S4[x[ 7]]^S5[x[ 6]]^S6[x[ 5]]^S7[x[ 4]]^S4[z[ 1]]; CAST_exp(l,X,x, 8); l=Z[3]^S4[x[10]]^S5[x[ 9]]^S6[x[11]]^S7[x[ 8]]^S5[z[ 3]]; CAST_exp(l,X,x,12); K[12]= S4[x[ 8]]^S5[x[ 9]]^S6[x[ 7]]^S7[x[ 6]]^S4[x[ 3]]; K[13]= S4[x[10]]^S5[x[11]]^S6[x[ 5]]^S7[x[ 4]]^S5[x[ 7]]; K[14]= S4[x[12]]^S5[x[13]]^S6[x[ 3]]^S7[x[ 2]]^S6[x[ 8]]; K[15]= S4[x[14]]^S5[x[15]]^S6[x[ 1]]^S7[x[ 0]]^S7[x[13]]; if (K != k) break; K+=16; } for (i=0; i<16; i++) { key->data[i*2]=k[i]; key->data[i*2+1]=((k[i+16])+16)&0x1f; } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/cast/c_ofb64.c0000644000175000017500000001010012360020705020563 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "cast_lcl.h" /* The input and output encrypted as though 64bit ofb mode is being * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, const CAST_KEY *schedule, unsigned char *ivec, int *num) { register CAST_LONG v0,v1,t; register int n= *num; register long l=length; unsigned char d[8]; register char *dp; CAST_LONG ti[2]; unsigned char *iv; int save=0; iv=ivec; n2l(iv,v0); n2l(iv,v1); ti[0]=v0; ti[1]=v1; dp=(char *)d; l2n(v0,dp); l2n(v1,dp); while (l--) { if (n == 0) { CAST_encrypt((CAST_LONG *)ti,schedule); dp=(char *)d; t=ti[0]; l2n(t,dp); t=ti[1]; l2n(t,dp); save++; } *(out++)= *(in++)^d[n]; n=(n+1)&0x07; } if (save) { v0=ti[0]; v1=ti[1]; iv=ivec; l2n(v0,iv); l2n(v1,iv); } t=v0=v1=ti[0]=ti[1]=0; *num=n; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/cast/cast_lcl.h0000644000175000017500000002030312360020705021140 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #undef c2l #define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ l|=((unsigned long)(*((c)++)))<< 8L, \ l|=((unsigned long)(*((c)++)))<<16L, \ l|=((unsigned long)(*((c)++)))<<24L) /* NOTE - c is not incremented as per c2l */ #undef c2ln #define c2ln(c,l1,l2,n) { \ c+=n; \ l1=l2=0; \ switch (n) { \ case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ case 5: l2|=((unsigned long)(*(--(c)))); \ case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ case 1: l1|=((unsigned long)(*(--(c)))); \ } \ } #undef l2c #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>>24L)&0xff)) /* NOTE - c is not incremented as per l2c */ #undef l2cn #define l2cn(l1,l2,c,n) { \ c+=n; \ switch (n) { \ case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ } \ } /* NOTE - c is not incremented as per n2l */ #define n2ln(c,l1,l2,n) { \ c+=n; \ l1=l2=0; \ switch (n) { \ case 8: l2 =((unsigned long)(*(--(c)))) ; \ case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ case 6: l2|=((unsigned long)(*(--(c))))<<16; \ case 5: l2|=((unsigned long)(*(--(c))))<<24; \ case 4: l1 =((unsigned long)(*(--(c)))) ; \ case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ case 2: l1|=((unsigned long)(*(--(c))))<<16; \ case 1: l1|=((unsigned long)(*(--(c))))<<24; \ } \ } /* NOTE - c is not incremented as per l2n */ #define l2nn(l1,l2,c,n) { \ c+=n; \ switch (n) { \ case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ } \ } #undef n2l #define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ l|=((unsigned long)(*((c)++)))<<16L, \ l|=((unsigned long)(*((c)++)))<< 8L, \ l|=((unsigned long)(*((c)++)))) #undef l2n #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l) )&0xff)) #define ROTL(a,n) ((((a)<<(n))&0xffffffffL)|((a)>>(32-(n)))) #define C_M 0x3fc #define C_0 22L #define C_1 14L #define C_2 6L #define C_3 2L /* left shift */ /* The rotate has an extra 16 added to it to help the x86 asm */ #if defined(CAST_PTR) #define E_CAST(n,key,L,R,OP1,OP2,OP3) \ { \ int i; \ t=(key[n*2] OP1 R)&0xffffffffL; \ i=key[n*2+1]; \ t=ROTL(t,i); \ L^= (((((*(CAST_LONG *)((unsigned char *) \ CAST_S_table0+((t>>C_2)&C_M)) OP2 \ *(CAST_LONG *)((unsigned char *) \ CAST_S_table1+((t<>C_0)&C_M)))&0xffffffffL) OP1 \ *(CAST_LONG *)((unsigned char *) \ CAST_S_table3+((t>>C_1)&C_M)))&0xffffffffL; \ } #elif defined(CAST_PTR2) #define E_CAST(n,key,L,R,OP1,OP2,OP3) \ { \ int i; \ CAST_LONG u,v,w; \ w=(key[n*2] OP1 R)&0xffffffffL; \ i=key[n*2+1]; \ w=ROTL(w,i); \ u=w>>C_2; \ v=w<>C_0; \ t=(t OP2 *(CAST_LONG *)((unsigned char *)CAST_S_table1+v))&0xffffffffL;\ v=w>>C_1; \ u&=C_M; \ v&=C_M; \ t=(t OP3 *(CAST_LONG *)((unsigned char *)CAST_S_table2+u)&0xffffffffL);\ t=(t OP1 *(CAST_LONG *)((unsigned char *)CAST_S_table3+v)&0xffffffffL);\ L^=(t&0xffffffff); \ } #else #define E_CAST(n,key,L,R,OP1,OP2,OP3) \ { \ CAST_LONG a,b,c,d; \ t=(key[n*2] OP1 R)&0xffffffff; \ t=ROTL(t,(key[n*2+1])); \ a=CAST_S_table0[(t>> 8)&0xff]; \ b=CAST_S_table1[(t )&0xff]; \ c=CAST_S_table2[(t>>24)&0xff]; \ d=CAST_S_table3[(t>>16)&0xff]; \ L^=(((((a OP2 b)&0xffffffffL) OP3 c)&0xffffffffL) OP1 d)&0xffffffffL; \ } #endif extern const CAST_LONG CAST_S_table0[256]; extern const CAST_LONG CAST_S_table1[256]; extern const CAST_LONG CAST_S_table2[256]; extern const CAST_LONG CAST_S_table3[256]; extern const CAST_LONG CAST_S_table4[256]; extern const CAST_LONG CAST_S_table5[256]; extern const CAST_LONG CAST_S_table6[256]; extern const CAST_LONG CAST_S_table7[256]; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ex_data.c0000644000175000017500000005153612360020705020036 0ustar /* $OpenBSD: ex_data.c,v 1.16 2014/06/12 15:49:27 deraadt Exp $ */ /* * Overhaul notes; * * This code is now *mostly* thread-safe. It is now easier to understand in what * ways it is safe and in what ways it is not, which is an improvement. Firstly, * all per-class stacks and index-counters for ex_data are stored in the same * global LHASH table (keyed by class). This hash table uses locking for all * access with the exception of CRYPTO_cleanup_all_ex_data(), which must only be * called when no other threads can possibly race against it (even if it was * locked, the race would mean it's possible the hash table might have been * recreated after the cleanup). As classes can only be added to the hash table, * and within each class, the stack of methods can only be incremented, the * locking mechanics are simpler than they would otherwise be. For example, the * new/dup/free ex_data functions will lock the hash table, copy the method * pointers it needs from the relevant class, then unlock the hash table before * actually applying those method pointers to the task of the new/dup/free * operations. As they can't be removed from the method-stack, only * supplemented, there's no race conditions associated with using them outside * the lock. The get/set_ex_data functions are not locked because they do not * involve this global state at all - they operate directly with a previously * obtained per-class method index and a particular "ex_data" variable. These * variables are usually instantiated per-context (eg. each RSA structure has * one) so locking on read/write access to that variable can be locked locally * if required (eg. using the "RSA" lock to synchronise access to a * per-RSA-structure ex_data variable if required). * [Geoff] */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include /* What an "implementation of ex_data functionality" looks like */ struct st_CRYPTO_EX_DATA_IMPL { /*********************/ /* GLOBAL OPERATIONS */ /* Return a new class index */ int (*cb_new_class)(void); /* Cleanup all state used by the implementation */ void (*cb_cleanup)(void); /************************/ /* PER-CLASS OPERATIONS */ /* Get a new method index within a class */ int (*cb_get_new_index)(int class_index, long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); /* Initialise a new CRYPTO_EX_DATA of a given class */ int (*cb_new_ex_data)(int class_index, void *obj, CRYPTO_EX_DATA *ad); /* Duplicate a CRYPTO_EX_DATA of a given class onto a copy */ int (*cb_dup_ex_data)(int class_index, CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from); /* Cleanup a CRYPTO_EX_DATA of a given class */ void (*cb_free_ex_data)(int class_index, void *obj, CRYPTO_EX_DATA *ad); }; /* The implementation we use at run-time */ static const CRYPTO_EX_DATA_IMPL *impl = NULL; /* To call "impl" functions, use this macro rather than referring to 'impl' directly, eg. * EX_IMPL(get_new_index)(...); */ #define EX_IMPL(a) impl->cb_##a /* Predeclare the "default" ex_data implementation */ static int int_new_class(void); static void int_cleanup(void); static int int_get_new_index(int class_index, long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); static int int_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from); static void int_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); static CRYPTO_EX_DATA_IMPL impl_default = { int_new_class, int_cleanup, int_get_new_index, int_new_ex_data, int_dup_ex_data, int_free_ex_data }; /* Internal function that checks whether "impl" is set and if not, sets it to * the default. */ static void impl_check(void) { CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA); if (!impl) impl = &impl_default; CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA); } /* A macro wrapper for impl_check that first uses a non-locked test before * invoking the function (which checks again inside a lock). */ #define IMPL_CHECK if(!impl) impl_check(); /* API functions to get/set the "ex_data" implementation */ const CRYPTO_EX_DATA_IMPL * CRYPTO_get_ex_data_implementation(void) { IMPL_CHECK return impl; } int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i) { int toret = 0; CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA); if (!impl) { impl = i; toret = 1; } CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA); return toret; } /****************************************************************************/ /* Interal (default) implementation of "ex_data" support. API functions are * further down. */ /* The type that represents what each "class" used to implement locally. A STACK * of CRYPTO_EX_DATA_FUNCS plus a index-counter. The 'class_index' is the global * value representing the class that is used to distinguish these items. */ typedef struct st_ex_class_item { int class_index; STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth; int meth_num; } EX_CLASS_ITEM; /* When assigning new class indexes, this is our counter */ static int ex_class = CRYPTO_EX_INDEX_USER; /* The global hash table of EX_CLASS_ITEM items */ DECLARE_LHASH_OF(EX_CLASS_ITEM); static LHASH_OF(EX_CLASS_ITEM) *ex_data = NULL; /* The callbacks required in the "ex_data" hash table */ static unsigned long ex_class_item_hash(const EX_CLASS_ITEM *a) { return a->class_index; } static IMPLEMENT_LHASH_HASH_FN(ex_class_item, EX_CLASS_ITEM) static int ex_class_item_cmp(const EX_CLASS_ITEM *a, const EX_CLASS_ITEM *b) { return a->class_index - b->class_index; } static IMPLEMENT_LHASH_COMP_FN(ex_class_item, EX_CLASS_ITEM) /* Internal functions used by the "impl_default" implementation to access the * state */ static int ex_data_check(void) { int toret = 1; CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA); if (!ex_data && (ex_data = lh_EX_CLASS_ITEM_new()) == NULL) toret = 0; CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA); return toret; } /* This macros helps reduce the locking from repeated checks because the * ex_data_check() function checks ex_data again inside a lock. */ #define EX_DATA_CHECK(iffail) if(!ex_data && !ex_data_check()) {iffail} /* This "inner" callback is used by the callback function that follows it */ static void def_cleanup_util_cb(CRYPTO_EX_DATA_FUNCS *funcs) { free(funcs); } /* This callback is used in lh_doall to destroy all EX_CLASS_ITEM values from * "ex_data" prior to the ex_data hash table being itself destroyed. Doesn't do * any locking. */ static void def_cleanup_cb(void *a_void) { EX_CLASS_ITEM *item = (EX_CLASS_ITEM *)a_void; sk_CRYPTO_EX_DATA_FUNCS_pop_free(item->meth, def_cleanup_util_cb); free(item); } /* Return the EX_CLASS_ITEM from the "ex_data" hash table that corresponds to a * given class. Handles locking. */ static EX_CLASS_ITEM * def_get_class(int class_index) { EX_CLASS_ITEM d, *p, *gen; EX_DATA_CHECK(return NULL;) d.class_index = class_index; CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA); p = lh_EX_CLASS_ITEM_retrieve(ex_data, &d); if (!p) { gen = malloc(sizeof(EX_CLASS_ITEM)); if (gen) { gen->class_index = class_index; gen->meth_num = 0; gen->meth = sk_CRYPTO_EX_DATA_FUNCS_new_null(); if (!gen->meth) free(gen); else { /* Because we're inside the ex_data lock, the * return value from the insert will be NULL */ (void)lh_EX_CLASS_ITEM_insert(ex_data, gen); p = gen; } } } CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA); if (!p) CRYPTOerr(CRYPTO_F_DEF_GET_CLASS, ERR_R_MALLOC_FAILURE); return p; } /* Add a new method to the given EX_CLASS_ITEM and return the corresponding * index (or -1 for error). Handles locking. */ static int def_add_index(EX_CLASS_ITEM *item, long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { int toret = -1; CRYPTO_EX_DATA_FUNCS *a = malloc(sizeof(CRYPTO_EX_DATA_FUNCS)); if (!a) { CRYPTOerr(CRYPTO_F_DEF_ADD_INDEX, ERR_R_MALLOC_FAILURE); return -1; } a->argl = argl; a->argp = argp; a->new_func = new_func; a->dup_func = dup_func; a->free_func = free_func; CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA); while (sk_CRYPTO_EX_DATA_FUNCS_num(item->meth) <= item->meth_num) { if (!sk_CRYPTO_EX_DATA_FUNCS_push(item->meth, NULL)) { CRYPTOerr(CRYPTO_F_DEF_ADD_INDEX, ERR_R_MALLOC_FAILURE); free(a); goto err; } } toret = item->meth_num++; (void)sk_CRYPTO_EX_DATA_FUNCS_set(item->meth, toret, a); err: CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA); return toret; } /**************************************************************/ /* The functions in the default CRYPTO_EX_DATA_IMPL structure */ static int int_new_class(void) { int toret; CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA); toret = ex_class++; CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA); return toret; } static void int_cleanup(void) { EX_DATA_CHECK(return;) lh_EX_CLASS_ITEM_doall(ex_data, def_cleanup_cb); lh_EX_CLASS_ITEM_free(ex_data); ex_data = NULL; impl = NULL; } static int int_get_new_index(int class_index, long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { EX_CLASS_ITEM *item = def_get_class(class_index); if (!item) return -1; return def_add_index(item, argl, argp, new_func, dup_func, free_func); } /* Thread-safe by copying a class's array of "CRYPTO_EX_DATA_FUNCS" entries in * the lock, then using them outside the lock. NB: Thread-safety only applies to * the global "ex_data" state (ie. class definitions), not thread-safe on 'ad' * itself. */ static int int_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad) { int mx, i; void *ptr; CRYPTO_EX_DATA_FUNCS **storage = NULL; EX_CLASS_ITEM *item = def_get_class(class_index); if (!item) /* error is already set */ return 0; ad->sk = NULL; CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA); mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth); if (mx > 0) { storage = reallocarray(NULL, mx, sizeof(CRYPTO_EX_DATA_FUNCS*)); if (!storage) goto skip; for (i = 0; i < mx; i++) storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value( item->meth, i); } skip: CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA); if ((mx > 0) && !storage) { CRYPTOerr(CRYPTO_F_INT_NEW_EX_DATA, ERR_R_MALLOC_FAILURE); return 0; } for (i = 0; i < mx; i++) { if (storage[i] && storage[i]->new_func) { ptr = CRYPTO_get_ex_data(ad, i); storage[i]->new_func(obj, ptr, ad, i, storage[i]->argl, storage[i]->argp); } } free(storage); return 1; } /* Same thread-safety notes as for "int_new_ex_data" */ static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from) { int mx, j, i; char *ptr; CRYPTO_EX_DATA_FUNCS **storage = NULL; EX_CLASS_ITEM *item; if (!from->sk) /* 'to' should be "blank" which *is* just like 'from' */ return 1; if ((item = def_get_class(class_index)) == NULL) return 0; CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA); mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth); j = sk_void_num(from->sk); if (j < mx) mx = j; if (mx > 0) { storage = reallocarray(NULL, mx, sizeof(CRYPTO_EX_DATA_FUNCS*)); if (!storage) goto skip; for (i = 0; i < mx; i++) storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value( item->meth, i); } skip: CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA); if ((mx > 0) && !storage) { CRYPTOerr(CRYPTO_F_INT_DUP_EX_DATA, ERR_R_MALLOC_FAILURE); return 0; } for (i = 0; i < mx; i++) { ptr = CRYPTO_get_ex_data(from, i); if (storage[i] && storage[i]->dup_func) storage[i]->dup_func(to, from, &ptr, i, storage[i]->argl, storage[i]->argp); CRYPTO_set_ex_data(to, i, ptr); } free(storage); return 1; } /* Same thread-safety notes as for "int_new_ex_data" */ static void int_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad) { int mx, i; EX_CLASS_ITEM *item; void *ptr; CRYPTO_EX_DATA_FUNCS **storage = NULL; if ((item = def_get_class(class_index)) == NULL) return; CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA); mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth); if (mx > 0) { storage = reallocarray(NULL, mx, sizeof(CRYPTO_EX_DATA_FUNCS*)); if (!storage) goto skip; for (i = 0; i < mx; i++) storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value( item->meth, i); } skip: CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA); if ((mx > 0) && !storage) { CRYPTOerr(CRYPTO_F_INT_FREE_EX_DATA, ERR_R_MALLOC_FAILURE); return; } for (i = 0; i < mx; i++) { if (storage[i] && storage[i]->free_func) { ptr = CRYPTO_get_ex_data(ad, i); storage[i]->free_func(obj, ptr, ad, i, storage[i]->argl, storage[i]->argp); } } free(storage); if (ad->sk) { sk_void_free(ad->sk); ad->sk = NULL; } } /********************************************************************/ /* API functions that defer all "state" operations to the "ex_data" * implementation we have set. */ /* Obtain an index for a new class (not the same as getting a new index within * an existing class - this is actually getting a new *class*) */ int CRYPTO_ex_data_new_class(void) { IMPL_CHECK return EX_IMPL(new_class)(); } /* Release all "ex_data" state to prevent memory leaks. This can't be made * thread-safe without overhauling a lot of stuff, and shouldn't really be * called under potential race-conditions anyway (it's for program shutdown * after all). */ void CRYPTO_cleanup_all_ex_data(void) { IMPL_CHECK EX_IMPL(cleanup)(); } /* Inside an existing class, get/register a new index. */ int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { int ret = -1; IMPL_CHECK ret = EX_IMPL(get_new_index)(class_index, argl, argp, new_func, dup_func, free_func); return ret; } /* Initialise a new CRYPTO_EX_DATA for use in a particular class - including * calling new() callbacks for each index in the class used by this variable */ int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad) { IMPL_CHECK return EX_IMPL(new_ex_data)(class_index, obj, ad); } /* Duplicate a CRYPTO_EX_DATA variable - including calling dup() callbacks for * each index in the class used by this variable */ int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from) { IMPL_CHECK return EX_IMPL(dup_ex_data)(class_index, to, from); } /* Cleanup a CRYPTO_EX_DATA variable - including calling free() callbacks for * each index in the class used by this variable */ void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad) { IMPL_CHECK EX_IMPL(free_ex_data)(class_index, obj, ad); } /* For a given CRYPTO_EX_DATA variable, set the value corresponding to a * particular index in the class used by this variable */ int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val) { int i; if (ad->sk == NULL) { if ((ad->sk = sk_void_new_null()) == NULL) { CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA, ERR_R_MALLOC_FAILURE); return (0); } } i = sk_void_num(ad->sk); while (i <= idx) { if (!sk_void_push(ad->sk, NULL)) { CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA, ERR_R_MALLOC_FAILURE); return (0); } i++; } sk_void_set(ad->sk, idx, val); return (1); } /* For a given CRYPTO_EX_DATA_ variable, get the value corresponding to a * particular index in the class used by this variable */ void * CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx) { if (ad->sk == NULL) return (0); else if (idx >= sk_void_num(ad->sk)) return (0); else return (sk_void_value(ad->sk, idx)); } IMPLEMENT_STACK_OF(CRYPTO_EX_DATA_FUNCS) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/cmac/0000755000000000000000000000000012666635521020755 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/cmac/cm_pmeth.c0000644000175000017500000001275412360020705021127 0ustar /* $OpenBSD: cm_pmeth.c,v 1.7 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2010. */ /* ==================================================================== * Copyright (c) 2010 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== */ #include #include #include #include #include #include #include "evp_locl.h" /* The context structure and "key" is simply a CMAC_CTX */ static int pkey_cmac_init(EVP_PKEY_CTX *ctx) { ctx->data = CMAC_CTX_new(); if (!ctx->data) return 0; ctx->keygen_info_count = 0; return 1; } static int pkey_cmac_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src) { if (!pkey_cmac_init(dst)) return 0; if (!CMAC_CTX_copy(dst->data, src->data)) return 0; return 1; } static void pkey_cmac_cleanup(EVP_PKEY_CTX *ctx) { CMAC_CTX_free(ctx->data); } static int pkey_cmac_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) { CMAC_CTX *cmkey = CMAC_CTX_new(); CMAC_CTX *cmctx = ctx->data; if (!cmkey) return 0; if (!CMAC_CTX_copy(cmkey, cmctx)) { CMAC_CTX_free(cmkey); return 0; } EVP_PKEY_assign(pkey, EVP_PKEY_CMAC, cmkey); return 1; } static int int_update(EVP_MD_CTX *ctx, const void *data, size_t count) { if (!CMAC_Update(ctx->pctx->data, data, count)) return 0; return 1; } static int cmac_signctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx) { EVP_MD_CTX_set_flags(mctx, EVP_MD_CTX_FLAG_NO_INIT); mctx->update = int_update; return 1; } static int cmac_signctx(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, EVP_MD_CTX *mctx) { return CMAC_Final(ctx->data, sig, siglen); } static int pkey_cmac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) { CMAC_CTX *cmctx = ctx->data; switch (type) { case EVP_PKEY_CTRL_SET_MAC_KEY: if (!p2 || p1 < 0) return 0; if (!CMAC_Init(cmctx, p2, p1, NULL, NULL)) return 0; break; case EVP_PKEY_CTRL_CIPHER: if (!CMAC_Init(cmctx, NULL, 0, p2, ctx->engine)) return 0; break; case EVP_PKEY_CTRL_MD: if (ctx->pkey && !CMAC_CTX_copy(ctx->data, (CMAC_CTX *)ctx->pkey->pkey.ptr)) return 0; if (!CMAC_Init(cmctx, NULL, 0, NULL, NULL)) return 0; break; default: return -2; } return 1; } static int pkey_cmac_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) { if (!value) return 0; if (!strcmp(type, "key")) { void *p = (void *)value; return pkey_cmac_ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY, strlen(p), p); } if (!strcmp(type, "cipher")) { const EVP_CIPHER *c; c = EVP_get_cipherbyname(value); if (!c) return 0; return pkey_cmac_ctrl(ctx, EVP_PKEY_CTRL_CIPHER, -1, (void *)c); } if (!strcmp(type, "hexkey")) { unsigned char *key; int r; long keylen; key = string_to_hex(value, &keylen); if (!key) return 0; r = pkey_cmac_ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY, keylen, key); free(key); return r; } return -2; } const EVP_PKEY_METHOD cmac_pkey_meth = { .pkey_id = EVP_PKEY_CMAC, .flags = EVP_PKEY_FLAG_SIGCTX_CUSTOM, .init = pkey_cmac_init, .copy = pkey_cmac_copy, .cleanup = pkey_cmac_cleanup, .keygen = pkey_cmac_keygen, .signctx_init = cmac_signctx_init, .signctx = cmac_signctx, .ctrl = pkey_cmac_ctrl, .ctrl_str = pkey_cmac_ctrl_str }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/cmac/cm_ameth.c0000644000175000017500000000625612360020705021110 0ustar /* $OpenBSD: cm_ameth.c,v 1.5 2014/06/21 13:42:14 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2010. */ /* ==================================================================== * Copyright (c) 2010 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== */ #include #include #include #include "asn1_locl.h" /* CMAC "ASN1" method. This is just here to indicate the * maximum CMAC output length and to free up a CMAC * key. */ static int cmac_size(const EVP_PKEY *pkey) { return EVP_MAX_BLOCK_LENGTH; } static void cmac_key_free(EVP_PKEY *pkey) { CMAC_CTX *cmctx = (CMAC_CTX *)pkey->pkey.ptr; if (cmctx) CMAC_CTX_free(cmctx); } const EVP_PKEY_ASN1_METHOD cmac_asn1_meth = { .pkey_id = EVP_PKEY_CMAC, .pkey_base_id = EVP_PKEY_CMAC, .pem_str = "CMAC", .info = "OpenSSL CMAC method", .pkey_size = cmac_size, .pkey_free = cmac_key_free }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/cmac/cmac.c0000644000175000017500000001736412360020705020240 0ustar /* $OpenBSD: cmac.c,v 1.7 2014/06/21 13:42:14 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ /* ==================================================================== * Copyright (c) 2010 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== */ #include #include #include #include struct CMAC_CTX_st { /* Cipher context to use */ EVP_CIPHER_CTX cctx; /* Keys k1 and k2 */ unsigned char k1[EVP_MAX_BLOCK_LENGTH]; unsigned char k2[EVP_MAX_BLOCK_LENGTH]; /* Temporary block */ unsigned char tbl[EVP_MAX_BLOCK_LENGTH]; /* Last (possibly partial) block */ unsigned char last_block[EVP_MAX_BLOCK_LENGTH]; /* Number of bytes in last block: -1 means context not initialised */ int nlast_block; }; /* Make temporary keys K1 and K2 */ static void make_kn(unsigned char *k1, unsigned char *l, int bl) { int i; /* Shift block to left, including carry */ for (i = 0; i < bl; i++) { k1[i] = l[i] << 1; if (i < bl - 1 && l[i + 1] & 0x80) k1[i] |= 1; } /* If MSB set fixup with R */ if (l[0] & 0x80) k1[bl - 1] ^= bl == 16 ? 0x87 : 0x1b; } CMAC_CTX * CMAC_CTX_new(void) { CMAC_CTX *ctx; ctx = malloc(sizeof(CMAC_CTX)); if (!ctx) return NULL; EVP_CIPHER_CTX_init(&ctx->cctx); ctx->nlast_block = -1; return ctx; } void CMAC_CTX_cleanup(CMAC_CTX *ctx) { EVP_CIPHER_CTX_cleanup(&ctx->cctx); OPENSSL_cleanse(ctx->tbl, EVP_MAX_BLOCK_LENGTH); OPENSSL_cleanse(ctx->k1, EVP_MAX_BLOCK_LENGTH); OPENSSL_cleanse(ctx->k2, EVP_MAX_BLOCK_LENGTH); OPENSSL_cleanse(ctx->last_block, EVP_MAX_BLOCK_LENGTH); ctx->nlast_block = -1; } EVP_CIPHER_CTX * CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx) { return &ctx->cctx; } void CMAC_CTX_free(CMAC_CTX *ctx) { CMAC_CTX_cleanup(ctx); free(ctx); } int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in) { int bl; if (in->nlast_block == -1) return 0; if (!EVP_CIPHER_CTX_copy(&out->cctx, &in->cctx)) return 0; bl = EVP_CIPHER_CTX_block_size(&in->cctx); memcpy(out->k1, in->k1, bl); memcpy(out->k2, in->k2, bl); memcpy(out->tbl, in->tbl, bl); memcpy(out->last_block, in->last_block, bl); out->nlast_block = in->nlast_block; return 1; } int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen, const EVP_CIPHER *cipher, ENGINE *impl) { static unsigned char zero_iv[EVP_MAX_BLOCK_LENGTH]; /* All zeros means restart */ if (!key && !cipher && !impl && keylen == 0) { /* Not initialised */ if (ctx->nlast_block == -1) return 0; if (!EVP_EncryptInit_ex(&ctx->cctx, NULL, NULL, NULL, zero_iv)) return 0; memset(ctx->tbl, 0, EVP_CIPHER_CTX_block_size(&ctx->cctx)); ctx->nlast_block = 0; return 1; } /* Initialiase context */ if (cipher && !EVP_EncryptInit_ex(&ctx->cctx, cipher, impl, NULL, NULL)) return 0; /* Non-NULL key means initialisation complete */ if (key) { int bl; if (!EVP_CIPHER_CTX_cipher(&ctx->cctx)) return 0; if (!EVP_CIPHER_CTX_set_key_length(&ctx->cctx, keylen)) return 0; if (!EVP_EncryptInit_ex(&ctx->cctx, NULL, NULL, key, zero_iv)) return 0; bl = EVP_CIPHER_CTX_block_size(&ctx->cctx); if (!EVP_Cipher(&ctx->cctx, ctx->tbl, zero_iv, bl)) return 0; make_kn(ctx->k1, ctx->tbl, bl); make_kn(ctx->k2, ctx->k1, bl); OPENSSL_cleanse(ctx->tbl, bl); /* Reset context again ready for first data block */ if (!EVP_EncryptInit_ex(&ctx->cctx, NULL, NULL, NULL, zero_iv)) return 0; /* Zero tbl so resume works */ memset(ctx->tbl, 0, bl); ctx->nlast_block = 0; } return 1; } int CMAC_Update(CMAC_CTX *ctx, const void *in, size_t dlen) { const unsigned char *data = in; size_t bl; if (ctx->nlast_block == -1) return 0; if (dlen == 0) return 1; bl = EVP_CIPHER_CTX_block_size(&ctx->cctx); /* Copy into partial block if we need to */ if (ctx->nlast_block > 0) { size_t nleft; nleft = bl - ctx->nlast_block; if (dlen < nleft) nleft = dlen; memcpy(ctx->last_block + ctx->nlast_block, data, nleft); dlen -= nleft; ctx->nlast_block += nleft; /* If no more to process return */ if (dlen == 0) return 1; data += nleft; /* Else not final block so encrypt it */ if (!EVP_Cipher(&ctx->cctx, ctx->tbl, ctx->last_block, bl)) return 0; } /* Encrypt all but one of the complete blocks left */ while (dlen > bl) { if (!EVP_Cipher(&ctx->cctx, ctx->tbl, data, bl)) return 0; dlen -= bl; data += bl; } /* Copy any data left to last block buffer */ memcpy(ctx->last_block, data, dlen); ctx->nlast_block = dlen; return 1; } int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen) { int i, bl, lb; if (ctx->nlast_block == -1) return 0; bl = EVP_CIPHER_CTX_block_size(&ctx->cctx); *poutlen = (size_t)bl; if (!out) return 1; lb = ctx->nlast_block; /* Is last block complete? */ if (lb == bl) { for (i = 0; i < bl; i++) out[i] = ctx->last_block[i] ^ ctx->k1[i]; } else { ctx->last_block[lb] = 0x80; if (bl - lb > 1) memset(ctx->last_block + lb + 1, 0, bl - lb - 1); for (i = 0; i < bl; i++) out[i] = ctx->last_block[i] ^ ctx->k2[i]; } if (!EVP_Cipher(&ctx->cctx, out, out, bl)) { OPENSSL_cleanse(out, bl); return 0; } return 1; } int CMAC_resume(CMAC_CTX *ctx) { if (ctx->nlast_block == -1) return 0; /* The buffer "tbl" containes the last fully encrypted block * which is the last IV (or all zeroes if no last encrypted block). * The last block has not been modified since CMAC_final(). * So reinitialising using the last decrypted block will allow * CMAC to continue after calling CMAC_Final(). */ return EVP_EncryptInit_ex(&ctx->cctx, NULL, NULL, NULL, ctx->tbl); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/objects/0000755000000000000000000000000012666635521021503 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/objects/o_names.c0000644000175000017500000001676412360020706021510 0ustar /* $OpenBSD$ */ #include #include #include #include #include #include #include #include /* I use the ex_data stuff to manage the identifiers for the obj_name_types * that applications may define. I only really use the free function field. */ DECLARE_LHASH_OF(OBJ_NAME); static LHASH_OF(OBJ_NAME) *names_lh = NULL; static int names_type_num = OBJ_NAME_TYPE_NUM; typedef struct name_funcs_st { unsigned long (*hash_func)(const char *name); int (*cmp_func)(const char *a, const char *b); void (*free_func)(const char *, int, const char *); } NAME_FUNCS; DECLARE_STACK_OF(NAME_FUNCS) IMPLEMENT_STACK_OF(NAME_FUNCS) static STACK_OF(NAME_FUNCS) *name_funcs_stack; /* The LHASH callbacks now use the raw "void *" prototypes and do per-variable * casting in the functions. This prevents function pointer casting without the * need for macro-generated wrapper functions. */ /* static unsigned long obj_name_hash(OBJ_NAME *a); */ static unsigned long obj_name_hash(const void *a_void); /* static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b); */ static int obj_name_cmp(const void *a_void, const void *b_void); static IMPLEMENT_LHASH_HASH_FN(obj_name, OBJ_NAME) static IMPLEMENT_LHASH_COMP_FN(obj_name, OBJ_NAME) int OBJ_NAME_init(void) { if (names_lh != NULL) return (1); names_lh = lh_OBJ_NAME_new(); return (names_lh != NULL); } int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *), int (*cmp_func)(const char *, const char *), void (*free_func)(const char *, int, const char *)) { int ret; int i; NAME_FUNCS *name_funcs; if (name_funcs_stack == NULL) name_funcs_stack = sk_NAME_FUNCS_new_null(); if (name_funcs_stack == NULL) return (0); ret = names_type_num; names_type_num++; for (i = sk_NAME_FUNCS_num(name_funcs_stack); i < names_type_num; i++) { name_funcs = malloc(sizeof(NAME_FUNCS)); if (!name_funcs) { OBJerr(OBJ_F_OBJ_NAME_NEW_INDEX, ERR_R_MALLOC_FAILURE); return (0); } name_funcs->hash_func = lh_strhash; name_funcs->cmp_func = strcmp; name_funcs->free_func = NULL; sk_NAME_FUNCS_push(name_funcs_stack, name_funcs); } name_funcs = sk_NAME_FUNCS_value(name_funcs_stack, ret); if (hash_func != NULL) name_funcs->hash_func = hash_func; if (cmp_func != NULL) name_funcs->cmp_func = cmp_func; if (free_func != NULL) name_funcs->free_func = free_func; return (ret); } /* static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b) */ static int obj_name_cmp(const void *a_void, const void *b_void) { int ret; const OBJ_NAME *a = (const OBJ_NAME *)a_void; const OBJ_NAME *b = (const OBJ_NAME *)b_void; ret = a->type - b->type; if (ret == 0) { if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > a->type)) { ret = sk_NAME_FUNCS_value(name_funcs_stack, a->type)->cmp_func(a->name, b->name); } else ret = strcmp(a->name, b->name); } return (ret); } /* static unsigned long obj_name_hash(OBJ_NAME *a) */ static unsigned long obj_name_hash(const void *a_void) { unsigned long ret; const OBJ_NAME *a = (const OBJ_NAME *)a_void; if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > a->type)) { ret = sk_NAME_FUNCS_value(name_funcs_stack, a->type)->hash_func(a->name); } else { ret = lh_strhash(a->name); } ret ^= a->type; return (ret); } const char * OBJ_NAME_get(const char *name, int type) { OBJ_NAME on, *ret; int num = 0, alias; if (name == NULL) return (NULL); if ((names_lh == NULL) && !OBJ_NAME_init()) return (NULL); alias = type&OBJ_NAME_ALIAS; type&= ~OBJ_NAME_ALIAS; on.name = name; on.type = type; for (;;) { ret = lh_OBJ_NAME_retrieve(names_lh, &on); if (ret == NULL) return (NULL); if ((ret->alias) && !alias) { if (++num > 10) return (NULL); on.name = ret->data; } else { return (ret->data); } } } int OBJ_NAME_add(const char *name, int type, const char *data) { OBJ_NAME *onp, *ret; int alias; if ((names_lh == NULL) && !OBJ_NAME_init()) return (0); alias = type & OBJ_NAME_ALIAS; type &= ~OBJ_NAME_ALIAS; onp = malloc(sizeof(OBJ_NAME)); if (onp == NULL) { /* ERROR */ return (0); } onp->name = name; onp->alias = alias; onp->type = type; onp->data = data; ret = lh_OBJ_NAME_insert(names_lh, onp); if (ret != NULL) { /* free things */ if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > ret->type)) { /* XXX: I'm not sure I understand why the free * function should get three arguments... * -- Richard Levitte */ sk_NAME_FUNCS_value( name_funcs_stack, ret->type)->free_func( ret->name, ret->type, ret->data); } free(ret); } else { if (lh_OBJ_NAME_error(names_lh)) { /* ERROR */ return (0); } } return (1); } int OBJ_NAME_remove(const char *name, int type) { OBJ_NAME on, *ret; if (names_lh == NULL) return (0); type &= ~OBJ_NAME_ALIAS; on.name = name; on.type = type; ret = lh_OBJ_NAME_delete(names_lh, &on); if (ret != NULL) { /* free things */ if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > ret->type)) { /* XXX: I'm not sure I understand why the free * function should get three arguments... * -- Richard Levitte */ sk_NAME_FUNCS_value( name_funcs_stack, ret->type)->free_func( ret->name, ret->type, ret->data); } free(ret); return (1); } else return (0); } struct doall { int type; void (*fn)(const OBJ_NAME *, void *arg); void *arg; }; static void do_all_fn_doall_arg(const OBJ_NAME *name, struct doall *d) { if (name->type == d->type) d->fn(name, d->arg); } static IMPLEMENT_LHASH_DOALL_ARG_FN(do_all_fn, const OBJ_NAME, struct doall) void OBJ_NAME_do_all(int type, void (*fn)(const OBJ_NAME *, void *arg), void *arg) { struct doall d; d.type = type; d.fn = fn; d.arg = arg; lh_OBJ_NAME_doall_arg(names_lh, LHASH_DOALL_ARG_FN(do_all_fn), struct doall, &d); } struct doall_sorted { int type; int n; const OBJ_NAME **names; }; static void do_all_sorted_fn(const OBJ_NAME *name, void *d_) { struct doall_sorted *d = d_; if (name->type != d->type) return; d->names[d->n++] = name; } static int do_all_sorted_cmp(const void *n1_, const void *n2_) { const OBJ_NAME * const *n1 = n1_; const OBJ_NAME * const *n2 = n2_; return strcmp((*n1)->name, (*n2)->name); } void OBJ_NAME_do_all_sorted(int type, void (*fn)(const OBJ_NAME *, void *arg), void *arg) { struct doall_sorted d; int n; d.type = type; d.names = reallocarray(NULL, lh_OBJ_NAME_num_items(names_lh), sizeof *d.names); d.n = 0; OBJ_NAME_do_all(type, do_all_sorted_fn, &d); qsort((void *)d.names, d.n, sizeof *d.names, do_all_sorted_cmp); for (n = 0; n < d.n; ++n) fn(d.names[n], arg); free((void *)d.names); } static int free_type; static void names_lh_free_doall(OBJ_NAME *onp) { if (onp == NULL) return; if (free_type < 0 || free_type == onp->type) OBJ_NAME_remove(onp->name, onp->type); } static IMPLEMENT_LHASH_DOALL_FN(names_lh_free, OBJ_NAME) static void name_funcs_free(NAME_FUNCS *ptr) { free(ptr); } void OBJ_NAME_cleanup(int type) { unsigned long down_load; if (names_lh == NULL) return; free_type = type; down_load = lh_OBJ_NAME_down_load(names_lh); lh_OBJ_NAME_down_load(names_lh) = 0; lh_OBJ_NAME_doall(names_lh, LHASH_DOALL_FN(names_lh_free)); if (type < 0) { lh_OBJ_NAME_free(names_lh); sk_NAME_FUNCS_pop_free(name_funcs_stack, name_funcs_free); names_lh = NULL; name_funcs_stack = NULL; } else lh_OBJ_NAME_down_load(names_lh) = down_load; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/objects/obj_xref.c0000644000175000017500000001255612360020706021660 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include "obj_xref.h" DECLARE_STACK_OF(nid_triple) STACK_OF(nid_triple) *sig_app, *sigx_app; static int sig_cmp(const nid_triple *a, const nid_triple *b) { return a->sign_id - b->sign_id; } DECLARE_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, sig); IMPLEMENT_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, sig); static int sig_sk_cmp(const nid_triple * const *a, const nid_triple * const *b) { return (*a)->sign_id - (*b)->sign_id; } DECLARE_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, sigx); static int sigx_cmp(const nid_triple * const *a, const nid_triple * const *b) { int ret; ret = (*a)->hash_id - (*b)->hash_id; if (ret) return ret; return (*a)->pkey_id - (*b)->pkey_id; } IMPLEMENT_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, sigx); int OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid) { nid_triple tmp; const nid_triple *rv = NULL; tmp.sign_id = signid; if (sig_app) { int idx = sk_nid_triple_find(sig_app, &tmp); if (idx >= 0) rv = sk_nid_triple_value(sig_app, idx); } #ifndef OBJ_XREF_TEST2 if (rv == NULL) { rv = OBJ_bsearch_sig(&tmp, sigoid_srt, sizeof(sigoid_srt) / sizeof(nid_triple)); } #endif if (rv == NULL) return 0; if (pdig_nid) *pdig_nid = rv->hash_id; if (ppkey_nid) *ppkey_nid = rv->pkey_id; return 1; } int OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid) { nid_triple tmp; const nid_triple *t = &tmp; const nid_triple **rv = NULL; tmp.hash_id = dig_nid; tmp.pkey_id = pkey_nid; if (sigx_app) { int idx = sk_nid_triple_find(sigx_app, &tmp); if (idx >= 0) { t = sk_nid_triple_value(sigx_app, idx); rv = &t; } } #ifndef OBJ_XREF_TEST2 if (rv == NULL) { rv = OBJ_bsearch_sigx(&t, sigoid_srt_xref, sizeof(sigoid_srt_xref) / sizeof(nid_triple *)); } #endif if (rv == NULL) return 0; if (psignid) *psignid = (*rv)->sign_id; return 1; } int OBJ_add_sigid(int signid, int dig_id, int pkey_id) { nid_triple *ntr; if (!sig_app) sig_app = sk_nid_triple_new(sig_sk_cmp); if (!sig_app) return 0; if (!sigx_app) sigx_app = sk_nid_triple_new(sigx_cmp); if (!sigx_app) return 0; ntr = reallocarray(NULL, 3, sizeof(int)); if (!ntr) return 0; ntr->sign_id = signid; ntr->hash_id = dig_id; ntr->pkey_id = pkey_id; if (!sk_nid_triple_push(sig_app, ntr)) { free(ntr); return 0; } if (!sk_nid_triple_push(sigx_app, ntr)) return 0; sk_nid_triple_sort(sig_app); sk_nid_triple_sort(sigx_app); return 1; } static void sid_free(nid_triple *tt) { free(tt); } void OBJ_sigid_free(void) { if (sig_app) { sk_nid_triple_pop_free(sig_app, sid_free); sig_app = NULL; } if (sigx_app) { sk_nid_triple_free(sigx_app); sigx_app = NULL; } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/objects/obj_dat.c0000644000175000017500000004167212360020706021465 0ustar /* $OpenBSD: obj_dat.c,v 1.29 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #include #include /* obj_dat.h is generated from objects.h by obj_dat.pl */ #ifndef OPENSSL_NO_OBJECT #include "obj_dat.h" #else /* You will have to load all the objects needed manually in the application */ #define NUM_NID 0 #define NUM_SN 0 #define NUM_LN 0 #define NUM_OBJ 0 static const unsigned char lvalues[1]; static const ASN1_OBJECT nid_objs[1]; static const unsigned int sn_objs[1]; static const unsigned int ln_objs[1]; static const unsigned int obj_objs[1]; #endif DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn); DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln); DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj); #define ADDED_DATA 0 #define ADDED_SNAME 1 #define ADDED_LNAME 2 #define ADDED_NID 3 typedef struct added_obj_st { int type; ASN1_OBJECT *obj; } ADDED_OBJ; DECLARE_LHASH_OF(ADDED_OBJ); static int new_nid = NUM_NID; static LHASH_OF(ADDED_OBJ) *added = NULL; static int sn_cmp(const ASN1_OBJECT * const *a, const unsigned int *b) { return (strcmp((*a)->sn, nid_objs[*b].sn)); } IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn); static int ln_cmp(const ASN1_OBJECT * const *a, const unsigned int *b) { return (strcmp((*a)->ln, nid_objs[*b].ln)); } IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln); static unsigned long added_obj_hash(const ADDED_OBJ *ca) { const ASN1_OBJECT *a; int i; unsigned long ret = 0; unsigned char *p; a = ca->obj; switch (ca->type) { case ADDED_DATA: ret = a->length << 20L; p = (unsigned char *)a->data; for (i = 0; i < a->length; i++) ret ^= p[i] << ((i * 3) % 24); break; case ADDED_SNAME: ret = lh_strhash(a->sn); break; case ADDED_LNAME: ret = lh_strhash(a->ln); break; case ADDED_NID: ret = a->nid; break; default: /* abort(); */ return 0; } ret &= 0x3fffffffL; ret |= ca->type << 30L; return (ret); } static IMPLEMENT_LHASH_HASH_FN(added_obj, ADDED_OBJ) static int added_obj_cmp(const ADDED_OBJ *ca, const ADDED_OBJ *cb) { ASN1_OBJECT *a, *b; int i; i = ca->type - cb->type; if (i) return (i); a = ca->obj; b = cb->obj; switch (ca->type) { case ADDED_DATA: i = (a->length - b->length); if (i) return (i); return (memcmp(a->data, b->data, (size_t)a->length)); case ADDED_SNAME: if (a->sn == NULL) return (-1); else if (b->sn == NULL) return (1); else return (strcmp(a->sn, b->sn)); case ADDED_LNAME: if (a->ln == NULL) return (-1); else if (b->ln == NULL) return (1); else return (strcmp(a->ln, b->ln)); case ADDED_NID: return (a->nid - b->nid); default: /* abort(); */ return 0; } } static IMPLEMENT_LHASH_COMP_FN(added_obj, ADDED_OBJ) static int init_added(void) { if (added != NULL) return (1); added = lh_ADDED_OBJ_new(); return (added != NULL); } static void cleanup1_doall(ADDED_OBJ *a) { a->obj->nid = 0; a->obj->flags |= ASN1_OBJECT_FLAG_DYNAMIC | ASN1_OBJECT_FLAG_DYNAMIC_STRINGS | ASN1_OBJECT_FLAG_DYNAMIC_DATA; } static void cleanup2_doall(ADDED_OBJ *a) { a->obj->nid++; } static void cleanup3_doall(ADDED_OBJ *a) { if (--a->obj->nid == 0) ASN1_OBJECT_free(a->obj); free(a); } static IMPLEMENT_LHASH_DOALL_FN(cleanup1, ADDED_OBJ) static IMPLEMENT_LHASH_DOALL_FN(cleanup2, ADDED_OBJ) static IMPLEMENT_LHASH_DOALL_FN(cleanup3, ADDED_OBJ) /* The purpose of obj_cleanup_defer is to avoid EVP_cleanup() attempting * to use freed up OIDs. If neccessary the actual freeing up of OIDs is * delayed. */ int obj_cleanup_defer = 0; void check_defer(int nid) { if (!obj_cleanup_defer && nid >= NUM_NID) obj_cleanup_defer = 1; } void OBJ_cleanup(void) { if (obj_cleanup_defer) { obj_cleanup_defer = 2; return; } if (added == NULL) return; lh_ADDED_OBJ_down_load(added) = 0; lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup1)); /* zero counters */ lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup2)); /* set counters */ lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup3)); /* free objects */ lh_ADDED_OBJ_free(added); added = NULL; } int OBJ_new_nid(int num) { int i; i = new_nid; new_nid += num; return (i); } int OBJ_add_object(const ASN1_OBJECT *obj) { ASN1_OBJECT *o; ADDED_OBJ *ao[4] = {NULL, NULL, NULL, NULL}, *aop; int i; if (added == NULL) if (!init_added()) return (0); if ((o = OBJ_dup(obj)) == NULL) goto err; if (!(ao[ADDED_NID] = malloc(sizeof(ADDED_OBJ)))) goto err2; if ((o->length != 0) && (obj->data != NULL)) if (!(ao[ADDED_DATA] = malloc(sizeof(ADDED_OBJ)))) goto err2; if (o->sn != NULL) if (!(ao[ADDED_SNAME] = malloc(sizeof(ADDED_OBJ)))) goto err2; if (o->ln != NULL) if (!(ao[ADDED_LNAME] = malloc(sizeof(ADDED_OBJ)))) goto err2; for (i = ADDED_DATA; i <= ADDED_NID; i++) { if (ao[i] != NULL) { ao[i]->type = i; ao[i]->obj = o; aop = lh_ADDED_OBJ_insert(added, ao[i]); /* memory leak, buit should not normally matter */ free(aop); } } o->flags &= ~(ASN1_OBJECT_FLAG_DYNAMIC | ASN1_OBJECT_FLAG_DYNAMIC_STRINGS | ASN1_OBJECT_FLAG_DYNAMIC_DATA); return (o->nid); err2: OBJerr(OBJ_F_OBJ_ADD_OBJECT, ERR_R_MALLOC_FAILURE); err: for (i = ADDED_DATA; i <= ADDED_NID; i++) free(ao[i]); free(o); return (NID_undef); } ASN1_OBJECT * OBJ_nid2obj(int n) { ADDED_OBJ ad, *adp; ASN1_OBJECT ob; if ((n >= 0) && (n < NUM_NID)) { if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) { OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID); return (NULL); } return ((ASN1_OBJECT *)&(nid_objs[n])); } else if (added == NULL) return (NULL); else { ad.type = ADDED_NID; ad.obj = &ob; ob.nid = n; adp = lh_ADDED_OBJ_retrieve(added, &ad); if (adp != NULL) return (adp->obj); else { OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID); return (NULL); } } } const char * OBJ_nid2sn(int n) { ADDED_OBJ ad, *adp; ASN1_OBJECT ob; if ((n >= 0) && (n < NUM_NID)) { if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) { OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID); return (NULL); } return (nid_objs[n].sn); } else if (added == NULL) return (NULL); else { ad.type = ADDED_NID; ad.obj = &ob; ob.nid = n; adp = lh_ADDED_OBJ_retrieve(added, &ad); if (adp != NULL) return (adp->obj->sn); else { OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID); return (NULL); } } } const char * OBJ_nid2ln(int n) { ADDED_OBJ ad, *adp; ASN1_OBJECT ob; if ((n >= 0) && (n < NUM_NID)) { if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) { OBJerr(OBJ_F_OBJ_NID2LN, OBJ_R_UNKNOWN_NID); return (NULL); } return (nid_objs[n].ln); } else if (added == NULL) return (NULL); else { ad.type = ADDED_NID; ad.obj = &ob; ob.nid = n; adp = lh_ADDED_OBJ_retrieve(added, &ad); if (adp != NULL) return (adp->obj->ln); else { OBJerr(OBJ_F_OBJ_NID2LN, OBJ_R_UNKNOWN_NID); return (NULL); } } } static int obj_cmp(const ASN1_OBJECT * const *ap, const unsigned int *bp) { int j; const ASN1_OBJECT *a= *ap; const ASN1_OBJECT *b = &nid_objs[*bp]; j = (a->length - b->length); if (j) return (j); return (memcmp(a->data, b->data, a->length)); } IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj); int OBJ_obj2nid(const ASN1_OBJECT *a) { const unsigned int *op; ADDED_OBJ ad, *adp; if (a == NULL) return (NID_undef); if (a->nid != 0) return (a->nid); if (added != NULL) { ad.type = ADDED_DATA; ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */ adp = lh_ADDED_OBJ_retrieve(added, &ad); if (adp != NULL) return (adp->obj->nid); } op = OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ); if (op == NULL) return (NID_undef); return (nid_objs[*op].nid); } /* Convert an object name into an ASN1_OBJECT * if "noname" is not set then search for short and long names first. * This will convert the "dotted" form into an object: unlike OBJ_txt2nid * it can be used with any objects, not just registered ones. */ ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name) { int nid = NID_undef; ASN1_OBJECT *op = NULL; unsigned char *buf; unsigned char *p; const unsigned char *cp; int i, j; if (!no_name) { if (((nid = OBJ_sn2nid(s)) != NID_undef) || ((nid = OBJ_ln2nid(s)) != NID_undef) ) return OBJ_nid2obj(nid); } /* Work out size of content octets */ i = a2d_ASN1_OBJECT(NULL, 0, s, -1); if (i <= 0) { /* Don't clear the error */ /*ERR_clear_error();*/ return NULL; } /* Work out total size */ j = ASN1_object_size(0, i, V_ASN1_OBJECT); if ((buf = malloc(j)) == NULL) return NULL; p = buf; /* Write out tag+length */ ASN1_put_object(&p, 0, i, V_ASN1_OBJECT, V_ASN1_UNIVERSAL); /* Write out contents */ a2d_ASN1_OBJECT(p, i, s, -1); cp = buf; op = d2i_ASN1_OBJECT(NULL, &cp, j); free(buf); return op; } int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name) { int i, ret = 0, len, nid, first = 1, use_bn; BIGNUM *bl = NULL; char *bndec = NULL; unsigned long l; const unsigned char *p; if ((a == NULL) || (a->data == NULL)) goto err; if (!no_name && (nid = OBJ_obj2nid(a)) != NID_undef) { const char *s; s = OBJ_nid2ln(nid); if (s == NULL) s = OBJ_nid2sn(nid); if (s) { ret = strlcpy(buf, s, buf_len); goto out; } } len = a->length; p = a->data; while (len > 0) { l = 0; use_bn = 0; for (;;) { unsigned char c = *p++; len--; if ((len == 0) && (c & 0x80)) goto err; if (use_bn) { if (!BN_add_word(bl, c & 0x7f)) goto err; } else l |= c & 0x7f; if (!(c & 0x80)) break; if (!use_bn && (l > (ULONG_MAX >> 7L))) { if (!bl && !(bl = BN_new())) goto err; if (!BN_set_word(bl, l)) goto err; use_bn = 1; } if (use_bn) { if (!BN_lshift(bl, bl, 7)) goto err; } else l <<= 7L; } if (first) { first = 0; if (l >= 80) { i = 2; if (use_bn) { if (!BN_sub_word(bl, 80)) goto err; } else l -= 80; } else { i = (int)(l / 40); l -= (long)(i * 40); } if (buf_len > 0) { *buf++ = i + '0'; buf_len--; } ret++; } if (use_bn) { bndec = BN_bn2dec(bl); if (!bndec) goto err; i = snprintf(buf, buf_len, ".%s", bndec); if (i == -1) goto err; if (i >= buf_len) { buf += buf_len; buf_len = 0; } else { buf += i; buf_len -= i; } ret += i; } else { i = snprintf(buf, buf_len, ".%lu", l); if (i == -1) goto err; if (i >= buf_len) { buf += buf_len; buf_len = 0; } else { buf += i; buf_len -= i; } ret += i; l = 0; } } out: free(bndec); BN_free(bl); return ret; err: ret = 0; buf[0] = '\0'; goto out; } int OBJ_txt2nid(const char *s) { ASN1_OBJECT *obj; int nid; obj = OBJ_txt2obj(s, 0); nid = OBJ_obj2nid(obj); ASN1_OBJECT_free(obj); return nid; } int OBJ_ln2nid(const char *s) { ASN1_OBJECT o; const ASN1_OBJECT *oo = &o; ADDED_OBJ ad, *adp; const unsigned int *op; o.ln = s; if (added != NULL) { ad.type = ADDED_LNAME; ad.obj = &o; adp = lh_ADDED_OBJ_retrieve(added, &ad); if (adp != NULL) return (adp->obj->nid); } op = OBJ_bsearch_ln(&oo, ln_objs, NUM_LN); if (op == NULL) return (NID_undef); return (nid_objs[*op].nid); } int OBJ_sn2nid(const char *s) { ASN1_OBJECT o; const ASN1_OBJECT *oo = &o; ADDED_OBJ ad, *adp; const unsigned int *op; o.sn = s; if (added != NULL) { ad.type = ADDED_SNAME; ad.obj = &o; adp = lh_ADDED_OBJ_retrieve(added, &ad); if (adp != NULL) return (adp->obj->nid); } op = OBJ_bsearch_sn(&oo, sn_objs, NUM_SN); if (op == NULL) return (NID_undef); return (nid_objs[*op].nid); } const void * OBJ_bsearch_(const void *key, const void *base, int num, int size, int (*cmp)(const void *, const void *)) { return OBJ_bsearch_ex_(key, base, num, size, cmp, 0); } const void * OBJ_bsearch_ex_(const void *key, const void *base_, int num, int size, int (*cmp)(const void *, const void *), int flags) { const char *base = base_; int l, h, i = 0, c = 0; const char *p = NULL; if (num == 0) return (NULL); l = 0; h = num; while (l < h) { i = (l + h) / 2; p = &(base[i * size]); c = (*cmp)(key, p); if (c < 0) h = i; else if (c > 0) l = i + 1; else break; } if (c != 0 && !(flags & OBJ_BSEARCH_VALUE_ON_NOMATCH)) p = NULL; else if (c == 0 && (flags & OBJ_BSEARCH_FIRST_VALUE_ON_MATCH)) { while (i > 0 && (*cmp)(key, &(base[(i - 1) * size])) == 0) i--; p = &(base[i * size]); } return (p); } int OBJ_create_objects(BIO *in) { char buf[512]; int i, num = 0; char *o, *s, *l = NULL; for (;;) { s = o = NULL; i = BIO_gets(in, buf, 512); if (i <= 0) return (num); buf[i - 1] = '\0'; if (!isalnum((unsigned char)buf[0])) return (num); o = s=buf; while (isdigit((unsigned char)*s) || (*s == '.')) s++; if (*s != '\0') { *(s++) = '\0'; while (isspace((unsigned char)*s)) s++; if (*s == '\0') s = NULL; else { l = s; while ((*l != '\0') && !isspace((unsigned char)*l)) l++; if (*l != '\0') { *(l++) = '\0'; while (isspace((unsigned char)*l)) l++; if (*l == '\0') l = NULL; } else l = NULL; } } else s = NULL; if ((o == NULL) || (*o == '\0')) return (num); if (!OBJ_create(o, s, l)) return (num); num++; } /* return(num); */ } int OBJ_create(const char *oid, const char *sn, const char *ln) { int ok = 0; ASN1_OBJECT *op = NULL; unsigned char *buf; int i; i = a2d_ASN1_OBJECT(NULL, 0, oid, -1); if (i <= 0) return (0); if ((buf = malloc(i)) == NULL) { OBJerr(OBJ_F_OBJ_CREATE, ERR_R_MALLOC_FAILURE); return (0); } i = a2d_ASN1_OBJECT(buf, i, oid, -1); if (i == 0) goto err; op = (ASN1_OBJECT *)ASN1_OBJECT_create(OBJ_new_nid(1), buf, i, sn, ln); if (op == NULL) goto err; ok = OBJ_add_object(op); err: ASN1_OBJECT_free(op); free(buf); return (ok); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/objects/obj_err.c0000644000175000017500000000757012360020706021504 0ustar /* $OpenBSD: obj_err.c,v 1.10 2014/06/12 15:49:30 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_OBJ,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_OBJ,0,reason) static ERR_STRING_DATA OBJ_str_functs[] = { {ERR_FUNC(OBJ_F_OBJ_ADD_OBJECT), "OBJ_add_object"}, {ERR_FUNC(OBJ_F_OBJ_CREATE), "OBJ_create"}, {ERR_FUNC(OBJ_F_OBJ_DUP), "OBJ_dup"}, {ERR_FUNC(OBJ_F_OBJ_NAME_NEW_INDEX), "OBJ_NAME_new_index"}, {ERR_FUNC(OBJ_F_OBJ_NID2LN), "OBJ_nid2ln"}, {ERR_FUNC(OBJ_F_OBJ_NID2OBJ), "OBJ_nid2obj"}, {ERR_FUNC(OBJ_F_OBJ_NID2SN), "OBJ_nid2sn"}, {0, NULL} }; static ERR_STRING_DATA OBJ_str_reasons[] = { {ERR_REASON(OBJ_R_MALLOC_FAILURE) , "malloc failure"}, {ERR_REASON(OBJ_R_UNKNOWN_NID) , "unknown nid"}, {0, NULL} }; #endif void ERR_load_OBJ_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(OBJ_str_functs[0].error) == NULL) { ERR_load_strings(0, OBJ_str_functs); ERR_load_strings(0, OBJ_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/objects/obj_xref.h0000644000175000017500000000500312360020706021652 0ustar /* $OpenBSD$ */ /* AUTOGENERATED BY objxref.pl, DO NOT EDIT */ typedef struct { int sign_id; int hash_id; int pkey_id; } nid_triple; static const nid_triple sigoid_srt[] = { {NID_md2WithRSAEncryption, NID_md2, NID_rsaEncryption}, {NID_md5WithRSAEncryption, NID_md5, NID_rsaEncryption}, {NID_shaWithRSAEncryption, NID_sha, NID_rsaEncryption}, {NID_sha1WithRSAEncryption, NID_sha1, NID_rsaEncryption}, {NID_dsaWithSHA, NID_sha, NID_dsa}, {NID_dsaWithSHA1_2, NID_sha1, NID_dsa_2}, {NID_mdc2WithRSA, NID_mdc2, NID_rsaEncryption}, {NID_md5WithRSA, NID_md5, NID_rsa}, {NID_dsaWithSHA1, NID_sha1, NID_dsa}, {NID_sha1WithRSA, NID_sha1, NID_rsa}, {NID_ripemd160WithRSA, NID_ripemd160, NID_rsaEncryption}, {NID_md4WithRSAEncryption, NID_md4, NID_rsaEncryption}, {NID_ecdsa_with_SHA1, NID_sha1, NID_X9_62_id_ecPublicKey}, {NID_sha256WithRSAEncryption, NID_sha256, NID_rsaEncryption}, {NID_sha384WithRSAEncryption, NID_sha384, NID_rsaEncryption}, {NID_sha512WithRSAEncryption, NID_sha512, NID_rsaEncryption}, {NID_sha224WithRSAEncryption, NID_sha224, NID_rsaEncryption}, {NID_ecdsa_with_Recommended, NID_undef, NID_X9_62_id_ecPublicKey}, {NID_ecdsa_with_Specified, NID_undef, NID_X9_62_id_ecPublicKey}, {NID_ecdsa_with_SHA224, NID_sha224, NID_X9_62_id_ecPublicKey}, {NID_ecdsa_with_SHA256, NID_sha256, NID_X9_62_id_ecPublicKey}, {NID_ecdsa_with_SHA384, NID_sha384, NID_X9_62_id_ecPublicKey}, {NID_ecdsa_with_SHA512, NID_sha512, NID_X9_62_id_ecPublicKey}, {NID_dsa_with_SHA224, NID_sha224, NID_dsa}, {NID_dsa_with_SHA256, NID_sha256, NID_dsa}, {NID_id_GostR3411_94_with_GostR3410_2001, NID_id_GostR3411_94, NID_id_GostR3410_2001}, {NID_id_GostR3411_94_with_GostR3410_94, NID_id_GostR3411_94, NID_id_GostR3410_94}, {NID_id_GostR3411_94_with_GostR3410_94_cc, NID_id_GostR3411_94, NID_id_GostR3410_94_cc}, {NID_id_GostR3411_94_with_GostR3410_2001_cc, NID_id_GostR3411_94, NID_id_GostR3410_2001_cc}, {NID_rsassaPss, NID_undef, NID_rsaEncryption}, }; static const nid_triple * const sigoid_srt_xref[] = { &sigoid_srt[29], &sigoid_srt[17], &sigoid_srt[18], &sigoid_srt[0], &sigoid_srt[1], &sigoid_srt[7], &sigoid_srt[2], &sigoid_srt[4], &sigoid_srt[3], &sigoid_srt[9], &sigoid_srt[5], &sigoid_srt[8], &sigoid_srt[12], &sigoid_srt[6], &sigoid_srt[10], &sigoid_srt[11], &sigoid_srt[13], &sigoid_srt[24], &sigoid_srt[20], &sigoid_srt[14], &sigoid_srt[21], &sigoid_srt[15], &sigoid_srt[22], &sigoid_srt[16], &sigoid_srt[23], &sigoid_srt[19], &sigoid_srt[25], &sigoid_srt[26], &sigoid_srt[27], &sigoid_srt[28], }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/objects/obj_dat.h0000644000175000017500000077434512360020705021503 0ustar /* crypto/objects/obj_dat.h */ /* THIS FILE IS GENERATED FROM objects.h by obj_dat.pl via the * following command: * perl obj_dat.pl obj_mac.h obj_dat.h */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #define NUM_NID 938 #define NUM_SN 931 #define NUM_LN 931 #define NUM_OBJ 874 static const unsigned char lvalues[6119]={ 0x2A,0x86,0x48,0x86,0xF7,0x0D, /* [ 0] OBJ_rsadsi */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01, /* [ 6] OBJ_pkcs */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x02, /* [ 13] OBJ_md2 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x05, /* [ 21] OBJ_md5 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x04, /* [ 29] OBJ_rc4 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,/* [ 37] OBJ_rsaEncryption */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x02,/* [ 46] OBJ_md2WithRSAEncryption */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,/* [ 55] OBJ_md5WithRSAEncryption */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x01,/* [ 64] OBJ_pbeWithMD2AndDES_CBC */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x03,/* [ 73] OBJ_pbeWithMD5AndDES_CBC */ 0x55, /* [ 82] OBJ_X500 */ 0x55,0x04, /* [ 83] OBJ_X509 */ 0x55,0x04,0x03, /* [ 85] OBJ_commonName */ 0x55,0x04,0x06, /* [ 88] OBJ_countryName */ 0x55,0x04,0x07, /* [ 91] OBJ_localityName */ 0x55,0x04,0x08, /* [ 94] OBJ_stateOrProvinceName */ 0x55,0x04,0x0A, /* [ 97] OBJ_organizationName */ 0x55,0x04,0x0B, /* [100] OBJ_organizationalUnitName */ 0x55,0x08,0x01,0x01, /* [103] OBJ_rsa */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07, /* [107] OBJ_pkcs7 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x01,/* [115] OBJ_pkcs7_data */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x02,/* [124] OBJ_pkcs7_signed */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x03,/* [133] OBJ_pkcs7_enveloped */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x04,/* [142] OBJ_pkcs7_signedAndEnveloped */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x05,/* [151] OBJ_pkcs7_digest */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x06,/* [160] OBJ_pkcs7_encrypted */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x03, /* [169] OBJ_pkcs3 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x03,0x01,/* [177] OBJ_dhKeyAgreement */ 0x2B,0x0E,0x03,0x02,0x06, /* [186] OBJ_des_ecb */ 0x2B,0x0E,0x03,0x02,0x09, /* [191] OBJ_des_cfb64 */ 0x2B,0x0E,0x03,0x02,0x07, /* [196] OBJ_des_cbc */ 0x2B,0x0E,0x03,0x02,0x11, /* [201] OBJ_des_ede_ecb */ 0x2B,0x06,0x01,0x04,0x01,0x81,0x3C,0x07,0x01,0x01,0x02,/* [206] OBJ_idea_cbc */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x02, /* [217] OBJ_rc2_cbc */ 0x2B,0x0E,0x03,0x02,0x12, /* [225] OBJ_sha */ 0x2B,0x0E,0x03,0x02,0x0F, /* [230] OBJ_shaWithRSAEncryption */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x07, /* [235] OBJ_des_ede3_cbc */ 0x2B,0x0E,0x03,0x02,0x08, /* [243] OBJ_des_ofb64 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09, /* [248] OBJ_pkcs9 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,/* [256] OBJ_pkcs9_emailAddress */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x02,/* [265] OBJ_pkcs9_unstructuredName */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x03,/* [274] OBJ_pkcs9_contentType */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x04,/* [283] OBJ_pkcs9_messageDigest */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x05,/* [292] OBJ_pkcs9_signingTime */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x06,/* [301] OBJ_pkcs9_countersignature */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x07,/* [310] OBJ_pkcs9_challengePassword */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x08,/* [319] OBJ_pkcs9_unstructuredAddress */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x09,/* [328] OBJ_pkcs9_extCertAttributes */ 0x60,0x86,0x48,0x01,0x86,0xF8,0x42, /* [337] OBJ_netscape */ 0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01, /* [344] OBJ_netscape_cert_extension */ 0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x02, /* [352] OBJ_netscape_data_type */ 0x2B,0x0E,0x03,0x02,0x1A, /* [360] OBJ_sha1 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,/* [365] OBJ_sha1WithRSAEncryption */ 0x2B,0x0E,0x03,0x02,0x0D, /* [374] OBJ_dsaWithSHA */ 0x2B,0x0E,0x03,0x02,0x0C, /* [379] OBJ_dsa_2 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0B,/* [384] OBJ_pbeWithSHA1AndRC2_CBC */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0C,/* [393] OBJ_id_pbkdf2 */ 0x2B,0x0E,0x03,0x02,0x1B, /* [402] OBJ_dsaWithSHA1_2 */ 0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x01,/* [407] OBJ_netscape_cert_type */ 0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x02,/* [416] OBJ_netscape_base_url */ 0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x03,/* [425] OBJ_netscape_revocation_url */ 0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x04,/* [434] OBJ_netscape_ca_revocation_url */ 0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x07,/* [443] OBJ_netscape_renewal_url */ 0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x08,/* [452] OBJ_netscape_ca_policy_url */ 0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x0C,/* [461] OBJ_netscape_ssl_server_name */ 0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x0D,/* [470] OBJ_netscape_comment */ 0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x02,0x05,/* [479] OBJ_netscape_cert_sequence */ 0x55,0x1D, /* [488] OBJ_id_ce */ 0x55,0x1D,0x0E, /* [490] OBJ_subject_key_identifier */ 0x55,0x1D,0x0F, /* [493] OBJ_key_usage */ 0x55,0x1D,0x10, /* [496] OBJ_private_key_usage_period */ 0x55,0x1D,0x11, /* [499] OBJ_subject_alt_name */ 0x55,0x1D,0x12, /* [502] OBJ_issuer_alt_name */ 0x55,0x1D,0x13, /* [505] OBJ_basic_constraints */ 0x55,0x1D,0x14, /* [508] OBJ_crl_number */ 0x55,0x1D,0x20, /* [511] OBJ_certificate_policies */ 0x55,0x1D,0x23, /* [514] OBJ_authority_key_identifier */ 0x2B,0x06,0x01,0x04,0x01,0x97,0x55,0x01,0x02,/* [517] OBJ_bf_cbc */ 0x55,0x08,0x03,0x65, /* [526] OBJ_mdc2 */ 0x55,0x08,0x03,0x64, /* [530] OBJ_mdc2WithRSA */ 0x55,0x04,0x2A, /* [534] OBJ_givenName */ 0x55,0x04,0x04, /* [537] OBJ_surname */ 0x55,0x04,0x2B, /* [540] OBJ_initials */ 0x55,0x1D,0x1F, /* [543] OBJ_crl_distribution_points */ 0x2B,0x0E,0x03,0x02,0x03, /* [546] OBJ_md5WithRSA */ 0x55,0x04,0x05, /* [551] OBJ_serialNumber */ 0x55,0x04,0x0C, /* [554] OBJ_title */ 0x55,0x04,0x0D, /* [557] OBJ_description */ 0x2A,0x86,0x48,0x86,0xF6,0x7D,0x07,0x42,0x0A,/* [560] OBJ_cast5_cbc */ 0x2A,0x86,0x48,0x86,0xF6,0x7D,0x07,0x42,0x0C,/* [569] OBJ_pbeWithMD5AndCast5_CBC */ 0x2A,0x86,0x48,0xCE,0x38,0x04,0x03, /* [578] OBJ_dsaWithSHA1 */ 0x2B,0x0E,0x03,0x02,0x1D, /* [585] OBJ_sha1WithRSA */ 0x2A,0x86,0x48,0xCE,0x38,0x04,0x01, /* [590] OBJ_dsa */ 0x2B,0x24,0x03,0x02,0x01, /* [597] OBJ_ripemd160 */ 0x2B,0x24,0x03,0x03,0x01,0x02, /* [602] OBJ_ripemd160WithRSA */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x08, /* [608] OBJ_rc5_cbc */ 0x29,0x01,0x01,0x85,0x1A,0x01, /* [616] OBJ_rle_compression */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x08,/* [622] OBJ_zlib_compression */ 0x55,0x1D,0x25, /* [633] OBJ_ext_key_usage */ 0x2B,0x06,0x01,0x05,0x05,0x07, /* [636] OBJ_id_pkix */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x03, /* [642] OBJ_id_kp */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x01, /* [649] OBJ_server_auth */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x02, /* [657] OBJ_client_auth */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x03, /* [665] OBJ_code_sign */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x04, /* [673] OBJ_email_protect */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x08, /* [681] OBJ_time_stamp */ 0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x15,/* [689] OBJ_ms_code_ind */ 0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x16,/* [699] OBJ_ms_code_com */ 0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x0A,0x03,0x01,/* [709] OBJ_ms_ctl_sign */ 0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x0A,0x03,0x03,/* [719] OBJ_ms_sgc */ 0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x0A,0x03,0x04,/* [729] OBJ_ms_efs */ 0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x04,0x01,/* [739] OBJ_ns_sgc */ 0x55,0x1D,0x1B, /* [748] OBJ_delta_crl */ 0x55,0x1D,0x15, /* [751] OBJ_crl_reason */ 0x55,0x1D,0x18, /* [754] OBJ_invalidity_date */ 0x2B,0x65,0x01,0x04,0x01, /* [757] OBJ_sxnet */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x01,/* [762] OBJ_pbe_WithSHA1And128BitRC4 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x02,/* [772] OBJ_pbe_WithSHA1And40BitRC4 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x03,/* [782] OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x04,/* [792] OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x05,/* [802] OBJ_pbe_WithSHA1And128BitRC2_CBC */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x06,/* [812] OBJ_pbe_WithSHA1And40BitRC2_CBC */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x01,/* [822] OBJ_keyBag */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x02,/* [833] OBJ_pkcs8ShroudedKeyBag */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x03,/* [844] OBJ_certBag */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x04,/* [855] OBJ_crlBag */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x05,/* [866] OBJ_secretBag */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x06,/* [877] OBJ_safeContentsBag */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x14,/* [888] OBJ_friendlyName */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x15,/* [897] OBJ_localKeyID */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x16,0x01,/* [906] OBJ_x509Certificate */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x16,0x02,/* [916] OBJ_sdsiCertificate */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x17,0x01,/* [926] OBJ_x509Crl */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0D,/* [936] OBJ_pbes2 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0E,/* [945] OBJ_pbmac1 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x07, /* [954] OBJ_hmacWithSHA1 */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x02,0x01, /* [962] OBJ_id_qt_cps */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x02,0x02, /* [970] OBJ_id_qt_unotice */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x0F,/* [978] OBJ_SMIMECapabilities */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x04,/* [987] OBJ_pbeWithMD2AndRC2_CBC */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x06,/* [996] OBJ_pbeWithMD5AndRC2_CBC */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0A,/* [1005] OBJ_pbeWithSHA1AndDES_CBC */ 0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0E,/* [1014] OBJ_ms_ext_req */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x0E,/* [1024] OBJ_ext_req */ 0x55,0x04,0x29, /* [1033] OBJ_name */ 0x55,0x04,0x2E, /* [1036] OBJ_dnQualifier */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x01, /* [1039] OBJ_id_pe */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30, /* [1046] OBJ_id_ad */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x01, /* [1053] OBJ_info_access */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01, /* [1061] OBJ_ad_OCSP */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x02, /* [1069] OBJ_ad_ca_issuers */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x09, /* [1077] OBJ_OCSP_sign */ 0x2A, /* [1085] OBJ_member_body */ 0x2A,0x86,0x48, /* [1086] OBJ_ISO_US */ 0x2A,0x86,0x48,0xCE,0x38, /* [1089] OBJ_X9_57 */ 0x2A,0x86,0x48,0xCE,0x38,0x04, /* [1094] OBJ_X9cm */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01, /* [1100] OBJ_pkcs1 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05, /* [1108] OBJ_pkcs5 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,/* [1116] OBJ_SMIME */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,/* [1125] OBJ_id_smime_mod */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,/* [1135] OBJ_id_smime_ct */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,/* [1145] OBJ_id_smime_aa */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,/* [1155] OBJ_id_smime_alg */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x04,/* [1165] OBJ_id_smime_cd */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x05,/* [1175] OBJ_id_smime_spq */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,/* [1185] OBJ_id_smime_cti */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x01,/* [1195] OBJ_id_smime_mod_cms */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x02,/* [1206] OBJ_id_smime_mod_ess */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x03,/* [1217] OBJ_id_smime_mod_oid */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x04,/* [1228] OBJ_id_smime_mod_msg_v3 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x05,/* [1239] OBJ_id_smime_mod_ets_eSignature_88 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x06,/* [1250] OBJ_id_smime_mod_ets_eSignature_97 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x07,/* [1261] OBJ_id_smime_mod_ets_eSigPolicy_88 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x08,/* [1272] OBJ_id_smime_mod_ets_eSigPolicy_97 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x01,/* [1283] OBJ_id_smime_ct_receipt */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x02,/* [1294] OBJ_id_smime_ct_authData */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x03,/* [1305] OBJ_id_smime_ct_publishCert */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x04,/* [1316] OBJ_id_smime_ct_TSTInfo */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x05,/* [1327] OBJ_id_smime_ct_TDTInfo */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x06,/* [1338] OBJ_id_smime_ct_contentInfo */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x07,/* [1349] OBJ_id_smime_ct_DVCSRequestData */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x08,/* [1360] OBJ_id_smime_ct_DVCSResponseData */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x01,/* [1371] OBJ_id_smime_aa_receiptRequest */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x02,/* [1382] OBJ_id_smime_aa_securityLabel */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x03,/* [1393] OBJ_id_smime_aa_mlExpandHistory */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x04,/* [1404] OBJ_id_smime_aa_contentHint */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x05,/* [1415] OBJ_id_smime_aa_msgSigDigest */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x06,/* [1426] OBJ_id_smime_aa_encapContentType */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x07,/* [1437] OBJ_id_smime_aa_contentIdentifier */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x08,/* [1448] OBJ_id_smime_aa_macValue */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x09,/* [1459] OBJ_id_smime_aa_equivalentLabels */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0A,/* [1470] OBJ_id_smime_aa_contentReference */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0B,/* [1481] OBJ_id_smime_aa_encrypKeyPref */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0C,/* [1492] OBJ_id_smime_aa_signingCertificate */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0D,/* [1503] OBJ_id_smime_aa_smimeEncryptCerts */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0E,/* [1514] OBJ_id_smime_aa_timeStampToken */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0F,/* [1525] OBJ_id_smime_aa_ets_sigPolicyId */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x10,/* [1536] OBJ_id_smime_aa_ets_commitmentType */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x11,/* [1547] OBJ_id_smime_aa_ets_signerLocation */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x12,/* [1558] OBJ_id_smime_aa_ets_signerAttr */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x13,/* [1569] OBJ_id_smime_aa_ets_otherSigCert */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x14,/* [1580] OBJ_id_smime_aa_ets_contentTimestamp */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x15,/* [1591] OBJ_id_smime_aa_ets_CertificateRefs */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x16,/* [1602] OBJ_id_smime_aa_ets_RevocationRefs */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x17,/* [1613] OBJ_id_smime_aa_ets_certValues */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x18,/* [1624] OBJ_id_smime_aa_ets_revocationValues */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x19,/* [1635] OBJ_id_smime_aa_ets_escTimeStamp */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x1A,/* [1646] OBJ_id_smime_aa_ets_certCRLTimestamp */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x1B,/* [1657] OBJ_id_smime_aa_ets_archiveTimeStamp */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x1C,/* [1668] OBJ_id_smime_aa_signatureType */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x1D,/* [1679] OBJ_id_smime_aa_dvcs_dvc */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x01,/* [1690] OBJ_id_smime_alg_ESDHwith3DES */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x02,/* [1701] OBJ_id_smime_alg_ESDHwithRC2 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x03,/* [1712] OBJ_id_smime_alg_3DESwrap */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x04,/* [1723] OBJ_id_smime_alg_RC2wrap */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x05,/* [1734] OBJ_id_smime_alg_ESDH */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x06,/* [1745] OBJ_id_smime_alg_CMS3DESwrap */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x07,/* [1756] OBJ_id_smime_alg_CMSRC2wrap */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x04,0x01,/* [1767] OBJ_id_smime_cd_ldap */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x05,0x01,/* [1778] OBJ_id_smime_spq_ets_sqt_uri */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x05,0x02,/* [1789] OBJ_id_smime_spq_ets_sqt_unotice */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x01,/* [1800] OBJ_id_smime_cti_ets_proofOfOrigin */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x02,/* [1811] OBJ_id_smime_cti_ets_proofOfReceipt */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x03,/* [1822] OBJ_id_smime_cti_ets_proofOfDelivery */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x04,/* [1833] OBJ_id_smime_cti_ets_proofOfSender */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x05,/* [1844] OBJ_id_smime_cti_ets_proofOfApproval */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x06,/* [1855] OBJ_id_smime_cti_ets_proofOfCreation */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x04, /* [1866] OBJ_md4 */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00, /* [1874] OBJ_id_pkix_mod */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x02, /* [1881] OBJ_id_qt */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04, /* [1888] OBJ_id_it */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x05, /* [1895] OBJ_id_pkip */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x06, /* [1902] OBJ_id_alg */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07, /* [1909] OBJ_id_cmc */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x08, /* [1916] OBJ_id_on */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x09, /* [1923] OBJ_id_pda */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x0A, /* [1930] OBJ_id_aca */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x0B, /* [1937] OBJ_id_qcs */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x0C, /* [1944] OBJ_id_cct */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x01, /* [1951] OBJ_id_pkix1_explicit_88 */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x02, /* [1959] OBJ_id_pkix1_implicit_88 */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x03, /* [1967] OBJ_id_pkix1_explicit_93 */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x04, /* [1975] OBJ_id_pkix1_implicit_93 */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x05, /* [1983] OBJ_id_mod_crmf */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x06, /* [1991] OBJ_id_mod_cmc */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x07, /* [1999] OBJ_id_mod_kea_profile_88 */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x08, /* [2007] OBJ_id_mod_kea_profile_93 */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x09, /* [2015] OBJ_id_mod_cmp */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0A, /* [2023] OBJ_id_mod_qualified_cert_88 */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0B, /* [2031] OBJ_id_mod_qualified_cert_93 */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0C, /* [2039] OBJ_id_mod_attribute_cert */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0D, /* [2047] OBJ_id_mod_timestamp_protocol */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0E, /* [2055] OBJ_id_mod_ocsp */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0F, /* [2063] OBJ_id_mod_dvcs */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x10, /* [2071] OBJ_id_mod_cmp2000 */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x02, /* [2079] OBJ_biometricInfo */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x03, /* [2087] OBJ_qcStatements */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x04, /* [2095] OBJ_ac_auditEntity */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x05, /* [2103] OBJ_ac_targeting */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x06, /* [2111] OBJ_aaControls */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x07, /* [2119] OBJ_sbgp_ipAddrBlock */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x08, /* [2127] OBJ_sbgp_autonomousSysNum */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x09, /* [2135] OBJ_sbgp_routerIdentifier */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x02,0x03, /* [2143] OBJ_textNotice */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x05, /* [2151] OBJ_ipsecEndSystem */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x06, /* [2159] OBJ_ipsecTunnel */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x07, /* [2167] OBJ_ipsecUser */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x0A, /* [2175] OBJ_dvcs */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x01, /* [2183] OBJ_id_it_caProtEncCert */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x02, /* [2191] OBJ_id_it_signKeyPairTypes */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x03, /* [2199] OBJ_id_it_encKeyPairTypes */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x04, /* [2207] OBJ_id_it_preferredSymmAlg */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x05, /* [2215] OBJ_id_it_caKeyUpdateInfo */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x06, /* [2223] OBJ_id_it_currentCRL */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x07, /* [2231] OBJ_id_it_unsupportedOIDs */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x08, /* [2239] OBJ_id_it_subscriptionRequest */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x09, /* [2247] OBJ_id_it_subscriptionResponse */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0A, /* [2255] OBJ_id_it_keyPairParamReq */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0B, /* [2263] OBJ_id_it_keyPairParamRep */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0C, /* [2271] OBJ_id_it_revPassphrase */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0D, /* [2279] OBJ_id_it_implicitConfirm */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0E, /* [2287] OBJ_id_it_confirmWaitTime */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0F, /* [2295] OBJ_id_it_origPKIMessage */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01, /* [2303] OBJ_id_regCtrl */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x02, /* [2311] OBJ_id_regInfo */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x01,/* [2319] OBJ_id_regCtrl_regToken */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x02,/* [2328] OBJ_id_regCtrl_authenticator */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x03,/* [2337] OBJ_id_regCtrl_pkiPublicationInfo */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x04,/* [2346] OBJ_id_regCtrl_pkiArchiveOptions */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x05,/* [2355] OBJ_id_regCtrl_oldCertID */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x06,/* [2364] OBJ_id_regCtrl_protocolEncrKey */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x02,0x01,/* [2373] OBJ_id_regInfo_utf8Pairs */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x02,0x02,/* [2382] OBJ_id_regInfo_certReq */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x06,0x01, /* [2391] OBJ_id_alg_des40 */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x06,0x02, /* [2399] OBJ_id_alg_noSignature */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x06,0x03, /* [2407] OBJ_id_alg_dh_sig_hmac_sha1 */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x06,0x04, /* [2415] OBJ_id_alg_dh_pop */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x01, /* [2423] OBJ_id_cmc_statusInfo */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x02, /* [2431] OBJ_id_cmc_identification */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x03, /* [2439] OBJ_id_cmc_identityProof */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x04, /* [2447] OBJ_id_cmc_dataReturn */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x05, /* [2455] OBJ_id_cmc_transactionId */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x06, /* [2463] OBJ_id_cmc_senderNonce */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x07, /* [2471] OBJ_id_cmc_recipientNonce */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x08, /* [2479] OBJ_id_cmc_addExtensions */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x09, /* [2487] OBJ_id_cmc_encryptedPOP */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x0A, /* [2495] OBJ_id_cmc_decryptedPOP */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x0B, /* [2503] OBJ_id_cmc_lraPOPWitness */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x0F, /* [2511] OBJ_id_cmc_getCert */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x10, /* [2519] OBJ_id_cmc_getCRL */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x11, /* [2527] OBJ_id_cmc_revokeRequest */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x12, /* [2535] OBJ_id_cmc_regInfo */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x13, /* [2543] OBJ_id_cmc_responseInfo */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x15, /* [2551] OBJ_id_cmc_queryPending */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x16, /* [2559] OBJ_id_cmc_popLinkRandom */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x17, /* [2567] OBJ_id_cmc_popLinkWitness */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x18, /* [2575] OBJ_id_cmc_confirmCertAcceptance */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x08,0x01, /* [2583] OBJ_id_on_personalData */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x09,0x01, /* [2591] OBJ_id_pda_dateOfBirth */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x09,0x02, /* [2599] OBJ_id_pda_placeOfBirth */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x09,0x03, /* [2607] OBJ_id_pda_gender */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x09,0x04, /* [2615] OBJ_id_pda_countryOfCitizenship */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x09,0x05, /* [2623] OBJ_id_pda_countryOfResidence */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x01, /* [2631] OBJ_id_aca_authenticationInfo */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x02, /* [2639] OBJ_id_aca_accessIdentity */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x03, /* [2647] OBJ_id_aca_chargingIdentity */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x04, /* [2655] OBJ_id_aca_group */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x05, /* [2663] OBJ_id_aca_role */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x0B,0x01, /* [2671] OBJ_id_qcs_pkixQCSyntax_v1 */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x0C,0x01, /* [2679] OBJ_id_cct_crs */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x0C,0x02, /* [2687] OBJ_id_cct_PKIData */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x0C,0x03, /* [2695] OBJ_id_cct_PKIResponse */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x03, /* [2703] OBJ_ad_timeStamping */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x04, /* [2711] OBJ_ad_dvcs */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x01,/* [2719] OBJ_id_pkix_OCSP_basic */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x02,/* [2728] OBJ_id_pkix_OCSP_Nonce */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x03,/* [2737] OBJ_id_pkix_OCSP_CrlID */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x04,/* [2746] OBJ_id_pkix_OCSP_acceptableResponses */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x05,/* [2755] OBJ_id_pkix_OCSP_noCheck */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x06,/* [2764] OBJ_id_pkix_OCSP_archiveCutoff */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x07,/* [2773] OBJ_id_pkix_OCSP_serviceLocator */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x08,/* [2782] OBJ_id_pkix_OCSP_extendedStatus */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x09,/* [2791] OBJ_id_pkix_OCSP_valid */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x0A,/* [2800] OBJ_id_pkix_OCSP_path */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x0B,/* [2809] OBJ_id_pkix_OCSP_trustRoot */ 0x2B,0x0E,0x03,0x02, /* [2818] OBJ_algorithm */ 0x2B,0x0E,0x03,0x02,0x0B, /* [2822] OBJ_rsaSignature */ 0x55,0x08, /* [2827] OBJ_X500algorithms */ 0x2B, /* [2829] OBJ_org */ 0x2B,0x06, /* [2830] OBJ_dod */ 0x2B,0x06,0x01, /* [2832] OBJ_iana */ 0x2B,0x06,0x01,0x01, /* [2835] OBJ_Directory */ 0x2B,0x06,0x01,0x02, /* [2839] OBJ_Management */ 0x2B,0x06,0x01,0x03, /* [2843] OBJ_Experimental */ 0x2B,0x06,0x01,0x04, /* [2847] OBJ_Private */ 0x2B,0x06,0x01,0x05, /* [2851] OBJ_Security */ 0x2B,0x06,0x01,0x06, /* [2855] OBJ_SNMPv2 */ 0x2B,0x06,0x01,0x07, /* [2859] OBJ_Mail */ 0x2B,0x06,0x01,0x04,0x01, /* [2863] OBJ_Enterprises */ 0x2B,0x06,0x01,0x04,0x01,0x8B,0x3A,0x82,0x58,/* [2868] OBJ_dcObject */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x19,/* [2877] OBJ_domainComponent */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x0D,/* [2887] OBJ_Domain */ 0x55,0x01,0x05, /* [2897] OBJ_selected_attribute_types */ 0x55,0x01,0x05,0x37, /* [2900] OBJ_clearance */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x03,/* [2904] OBJ_md4WithRSAEncryption */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x0A, /* [2913] OBJ_ac_proxying */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x0B, /* [2921] OBJ_sinfo_access */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x06, /* [2929] OBJ_id_aca_encAttrs */ 0x55,0x04,0x48, /* [2937] OBJ_role */ 0x55,0x1D,0x24, /* [2940] OBJ_policy_constraints */ 0x55,0x1D,0x37, /* [2943] OBJ_target_information */ 0x55,0x1D,0x38, /* [2946] OBJ_no_rev_avail */ 0x2A,0x86,0x48,0xCE,0x3D, /* [2949] OBJ_ansi_X9_62 */ 0x2A,0x86,0x48,0xCE,0x3D,0x01,0x01, /* [2954] OBJ_X9_62_prime_field */ 0x2A,0x86,0x48,0xCE,0x3D,0x01,0x02, /* [2961] OBJ_X9_62_characteristic_two_field */ 0x2A,0x86,0x48,0xCE,0x3D,0x02,0x01, /* [2968] OBJ_X9_62_id_ecPublicKey */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x01, /* [2975] OBJ_X9_62_prime192v1 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x02, /* [2983] OBJ_X9_62_prime192v2 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x03, /* [2991] OBJ_X9_62_prime192v3 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x04, /* [2999] OBJ_X9_62_prime239v1 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x05, /* [3007] OBJ_X9_62_prime239v2 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x06, /* [3015] OBJ_X9_62_prime239v3 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x07, /* [3023] OBJ_X9_62_prime256v1 */ 0x2A,0x86,0x48,0xCE,0x3D,0x04,0x01, /* [3031] OBJ_ecdsa_with_SHA1 */ 0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x11,0x01,/* [3038] OBJ_ms_csp_name */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x01,/* [3047] OBJ_aes_128_ecb */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x02,/* [3056] OBJ_aes_128_cbc */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x03,/* [3065] OBJ_aes_128_ofb128 */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x04,/* [3074] OBJ_aes_128_cfb128 */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x15,/* [3083] OBJ_aes_192_ecb */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x16,/* [3092] OBJ_aes_192_cbc */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x17,/* [3101] OBJ_aes_192_ofb128 */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x18,/* [3110] OBJ_aes_192_cfb128 */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x29,/* [3119] OBJ_aes_256_ecb */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x2A,/* [3128] OBJ_aes_256_cbc */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x2B,/* [3137] OBJ_aes_256_ofb128 */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x2C,/* [3146] OBJ_aes_256_cfb128 */ 0x55,0x1D,0x17, /* [3155] OBJ_hold_instruction_code */ 0x2A,0x86,0x48,0xCE,0x38,0x02,0x01, /* [3158] OBJ_hold_instruction_none */ 0x2A,0x86,0x48,0xCE,0x38,0x02,0x02, /* [3165] OBJ_hold_instruction_call_issuer */ 0x2A,0x86,0x48,0xCE,0x38,0x02,0x03, /* [3172] OBJ_hold_instruction_reject */ 0x09, /* [3179] OBJ_data */ 0x09,0x92,0x26, /* [3180] OBJ_pss */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C, /* [3183] OBJ_ucl */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64, /* [3190] OBJ_pilot */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,/* [3198] OBJ_pilotAttributeType */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x03,/* [3207] OBJ_pilotAttributeSyntax */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,/* [3216] OBJ_pilotObjectClass */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x0A,/* [3225] OBJ_pilotGroups */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x03,0x04,/* [3234] OBJ_iA5StringSyntax */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x03,0x05,/* [3244] OBJ_caseIgnoreIA5StringSyntax */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x03,/* [3254] OBJ_pilotObject */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x04,/* [3264] OBJ_pilotPerson */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x05,/* [3274] OBJ_account */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x06,/* [3284] OBJ_document */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x07,/* [3294] OBJ_room */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x09,/* [3304] OBJ_documentSeries */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x0E,/* [3314] OBJ_rFC822localPart */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x0F,/* [3324] OBJ_dNSDomain */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x11,/* [3334] OBJ_domainRelatedObject */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x12,/* [3344] OBJ_friendlyCountry */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x13,/* [3354] OBJ_simpleSecurityObject */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x14,/* [3364] OBJ_pilotOrganization */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x15,/* [3374] OBJ_pilotDSA */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x16,/* [3384] OBJ_qualityLabelledData */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x01,/* [3394] OBJ_userId */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x02,/* [3404] OBJ_textEncodedORAddress */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x03,/* [3414] OBJ_rfc822Mailbox */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x04,/* [3424] OBJ_info */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x05,/* [3434] OBJ_favouriteDrink */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x06,/* [3444] OBJ_roomNumber */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x07,/* [3454] OBJ_photo */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x08,/* [3464] OBJ_userClass */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x09,/* [3474] OBJ_host */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0A,/* [3484] OBJ_manager */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0B,/* [3494] OBJ_documentIdentifier */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0C,/* [3504] OBJ_documentTitle */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0D,/* [3514] OBJ_documentVersion */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0E,/* [3524] OBJ_documentAuthor */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0F,/* [3534] OBJ_documentLocation */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x14,/* [3544] OBJ_homeTelephoneNumber */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x15,/* [3554] OBJ_secretary */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x16,/* [3564] OBJ_otherMailbox */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x17,/* [3574] OBJ_lastModifiedTime */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x18,/* [3584] OBJ_lastModifiedBy */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1A,/* [3594] OBJ_aRecord */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1B,/* [3604] OBJ_pilotAttributeType27 */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1C,/* [3614] OBJ_mXRecord */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1D,/* [3624] OBJ_nSRecord */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1E,/* [3634] OBJ_sOARecord */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1F,/* [3644] OBJ_cNAMERecord */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x25,/* [3654] OBJ_associatedDomain */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x26,/* [3664] OBJ_associatedName */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x27,/* [3674] OBJ_homePostalAddress */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x28,/* [3684] OBJ_personalTitle */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x29,/* [3694] OBJ_mobileTelephoneNumber */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x2A,/* [3704] OBJ_pagerTelephoneNumber */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x2B,/* [3714] OBJ_friendlyCountryName */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x2D,/* [3724] OBJ_organizationalStatus */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x2E,/* [3734] OBJ_janetMailbox */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x2F,/* [3744] OBJ_mailPreferenceOption */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x30,/* [3754] OBJ_buildingName */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x31,/* [3764] OBJ_dSAQuality */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x32,/* [3774] OBJ_singleLevelQuality */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x33,/* [3784] OBJ_subtreeMinimumQuality */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x34,/* [3794] OBJ_subtreeMaximumQuality */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x35,/* [3804] OBJ_personalSignature */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x36,/* [3814] OBJ_dITRedirect */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x37,/* [3824] OBJ_audio */ 0x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x38,/* [3834] OBJ_documentPublisher */ 0x55,0x04,0x2D, /* [3844] OBJ_x500UniqueIdentifier */ 0x2B,0x06,0x01,0x07,0x01, /* [3847] OBJ_mime_mhs */ 0x2B,0x06,0x01,0x07,0x01,0x01, /* [3852] OBJ_mime_mhs_headings */ 0x2B,0x06,0x01,0x07,0x01,0x02, /* [3858] OBJ_mime_mhs_bodies */ 0x2B,0x06,0x01,0x07,0x01,0x01,0x01, /* [3864] OBJ_id_hex_partial_message */ 0x2B,0x06,0x01,0x07,0x01,0x01,0x02, /* [3871] OBJ_id_hex_multipart_message */ 0x55,0x04,0x2C, /* [3878] OBJ_generationQualifier */ 0x55,0x04,0x41, /* [3881] OBJ_pseudonym */ 0x67,0x2A, /* [3884] OBJ_id_set */ 0x67,0x2A,0x00, /* [3886] OBJ_set_ctype */ 0x67,0x2A,0x01, /* [3889] OBJ_set_msgExt */ 0x67,0x2A,0x03, /* [3892] OBJ_set_attr */ 0x67,0x2A,0x05, /* [3895] OBJ_set_policy */ 0x67,0x2A,0x07, /* [3898] OBJ_set_certExt */ 0x67,0x2A,0x08, /* [3901] OBJ_set_brand */ 0x67,0x2A,0x00,0x00, /* [3904] OBJ_setct_PANData */ 0x67,0x2A,0x00,0x01, /* [3908] OBJ_setct_PANToken */ 0x67,0x2A,0x00,0x02, /* [3912] OBJ_setct_PANOnly */ 0x67,0x2A,0x00,0x03, /* [3916] OBJ_setct_OIData */ 0x67,0x2A,0x00,0x04, /* [3920] OBJ_setct_PI */ 0x67,0x2A,0x00,0x05, /* [3924] OBJ_setct_PIData */ 0x67,0x2A,0x00,0x06, /* [3928] OBJ_setct_PIDataUnsigned */ 0x67,0x2A,0x00,0x07, /* [3932] OBJ_setct_HODInput */ 0x67,0x2A,0x00,0x08, /* [3936] OBJ_setct_AuthResBaggage */ 0x67,0x2A,0x00,0x09, /* [3940] OBJ_setct_AuthRevReqBaggage */ 0x67,0x2A,0x00,0x0A, /* [3944] OBJ_setct_AuthRevResBaggage */ 0x67,0x2A,0x00,0x0B, /* [3948] OBJ_setct_CapTokenSeq */ 0x67,0x2A,0x00,0x0C, /* [3952] OBJ_setct_PInitResData */ 0x67,0x2A,0x00,0x0D, /* [3956] OBJ_setct_PI_TBS */ 0x67,0x2A,0x00,0x0E, /* [3960] OBJ_setct_PResData */ 0x67,0x2A,0x00,0x10, /* [3964] OBJ_setct_AuthReqTBS */ 0x67,0x2A,0x00,0x11, /* [3968] OBJ_setct_AuthResTBS */ 0x67,0x2A,0x00,0x12, /* [3972] OBJ_setct_AuthResTBSX */ 0x67,0x2A,0x00,0x13, /* [3976] OBJ_setct_AuthTokenTBS */ 0x67,0x2A,0x00,0x14, /* [3980] OBJ_setct_CapTokenData */ 0x67,0x2A,0x00,0x15, /* [3984] OBJ_setct_CapTokenTBS */ 0x67,0x2A,0x00,0x16, /* [3988] OBJ_setct_AcqCardCodeMsg */ 0x67,0x2A,0x00,0x17, /* [3992] OBJ_setct_AuthRevReqTBS */ 0x67,0x2A,0x00,0x18, /* [3996] OBJ_setct_AuthRevResData */ 0x67,0x2A,0x00,0x19, /* [4000] OBJ_setct_AuthRevResTBS */ 0x67,0x2A,0x00,0x1A, /* [4004] OBJ_setct_CapReqTBS */ 0x67,0x2A,0x00,0x1B, /* [4008] OBJ_setct_CapReqTBSX */ 0x67,0x2A,0x00,0x1C, /* [4012] OBJ_setct_CapResData */ 0x67,0x2A,0x00,0x1D, /* [4016] OBJ_setct_CapRevReqTBS */ 0x67,0x2A,0x00,0x1E, /* [4020] OBJ_setct_CapRevReqTBSX */ 0x67,0x2A,0x00,0x1F, /* [4024] OBJ_setct_CapRevResData */ 0x67,0x2A,0x00,0x20, /* [4028] OBJ_setct_CredReqTBS */ 0x67,0x2A,0x00,0x21, /* [4032] OBJ_setct_CredReqTBSX */ 0x67,0x2A,0x00,0x22, /* [4036] OBJ_setct_CredResData */ 0x67,0x2A,0x00,0x23, /* [4040] OBJ_setct_CredRevReqTBS */ 0x67,0x2A,0x00,0x24, /* [4044] OBJ_setct_CredRevReqTBSX */ 0x67,0x2A,0x00,0x25, /* [4048] OBJ_setct_CredRevResData */ 0x67,0x2A,0x00,0x26, /* [4052] OBJ_setct_PCertReqData */ 0x67,0x2A,0x00,0x27, /* [4056] OBJ_setct_PCertResTBS */ 0x67,0x2A,0x00,0x28, /* [4060] OBJ_setct_BatchAdminReqData */ 0x67,0x2A,0x00,0x29, /* [4064] OBJ_setct_BatchAdminResData */ 0x67,0x2A,0x00,0x2A, /* [4068] OBJ_setct_CardCInitResTBS */ 0x67,0x2A,0x00,0x2B, /* [4072] OBJ_setct_MeAqCInitResTBS */ 0x67,0x2A,0x00,0x2C, /* [4076] OBJ_setct_RegFormResTBS */ 0x67,0x2A,0x00,0x2D, /* [4080] OBJ_setct_CertReqData */ 0x67,0x2A,0x00,0x2E, /* [4084] OBJ_setct_CertReqTBS */ 0x67,0x2A,0x00,0x2F, /* [4088] OBJ_setct_CertResData */ 0x67,0x2A,0x00,0x30, /* [4092] OBJ_setct_CertInqReqTBS */ 0x67,0x2A,0x00,0x31, /* [4096] OBJ_setct_ErrorTBS */ 0x67,0x2A,0x00,0x32, /* [4100] OBJ_setct_PIDualSignedTBE */ 0x67,0x2A,0x00,0x33, /* [4104] OBJ_setct_PIUnsignedTBE */ 0x67,0x2A,0x00,0x34, /* [4108] OBJ_setct_AuthReqTBE */ 0x67,0x2A,0x00,0x35, /* [4112] OBJ_setct_AuthResTBE */ 0x67,0x2A,0x00,0x36, /* [4116] OBJ_setct_AuthResTBEX */ 0x67,0x2A,0x00,0x37, /* [4120] OBJ_setct_AuthTokenTBE */ 0x67,0x2A,0x00,0x38, /* [4124] OBJ_setct_CapTokenTBE */ 0x67,0x2A,0x00,0x39, /* [4128] OBJ_setct_CapTokenTBEX */ 0x67,0x2A,0x00,0x3A, /* [4132] OBJ_setct_AcqCardCodeMsgTBE */ 0x67,0x2A,0x00,0x3B, /* [4136] OBJ_setct_AuthRevReqTBE */ 0x67,0x2A,0x00,0x3C, /* [4140] OBJ_setct_AuthRevResTBE */ 0x67,0x2A,0x00,0x3D, /* [4144] OBJ_setct_AuthRevResTBEB */ 0x67,0x2A,0x00,0x3E, /* [4148] OBJ_setct_CapReqTBE */ 0x67,0x2A,0x00,0x3F, /* [4152] OBJ_setct_CapReqTBEX */ 0x67,0x2A,0x00,0x40, /* [4156] OBJ_setct_CapResTBE */ 0x67,0x2A,0x00,0x41, /* [4160] OBJ_setct_CapRevReqTBE */ 0x67,0x2A,0x00,0x42, /* [4164] OBJ_setct_CapRevReqTBEX */ 0x67,0x2A,0x00,0x43, /* [4168] OBJ_setct_CapRevResTBE */ 0x67,0x2A,0x00,0x44, /* [4172] OBJ_setct_CredReqTBE */ 0x67,0x2A,0x00,0x45, /* [4176] OBJ_setct_CredReqTBEX */ 0x67,0x2A,0x00,0x46, /* [4180] OBJ_setct_CredResTBE */ 0x67,0x2A,0x00,0x47, /* [4184] OBJ_setct_CredRevReqTBE */ 0x67,0x2A,0x00,0x48, /* [4188] OBJ_setct_CredRevReqTBEX */ 0x67,0x2A,0x00,0x49, /* [4192] OBJ_setct_CredRevResTBE */ 0x67,0x2A,0x00,0x4A, /* [4196] OBJ_setct_BatchAdminReqTBE */ 0x67,0x2A,0x00,0x4B, /* [4200] OBJ_setct_BatchAdminResTBE */ 0x67,0x2A,0x00,0x4C, /* [4204] OBJ_setct_RegFormReqTBE */ 0x67,0x2A,0x00,0x4D, /* [4208] OBJ_setct_CertReqTBE */ 0x67,0x2A,0x00,0x4E, /* [4212] OBJ_setct_CertReqTBEX */ 0x67,0x2A,0x00,0x4F, /* [4216] OBJ_setct_CertResTBE */ 0x67,0x2A,0x00,0x50, /* [4220] OBJ_setct_CRLNotificationTBS */ 0x67,0x2A,0x00,0x51, /* [4224] OBJ_setct_CRLNotificationResTBS */ 0x67,0x2A,0x00,0x52, /* [4228] OBJ_setct_BCIDistributionTBS */ 0x67,0x2A,0x01,0x01, /* [4232] OBJ_setext_genCrypt */ 0x67,0x2A,0x01,0x03, /* [4236] OBJ_setext_miAuth */ 0x67,0x2A,0x01,0x04, /* [4240] OBJ_setext_pinSecure */ 0x67,0x2A,0x01,0x05, /* [4244] OBJ_setext_pinAny */ 0x67,0x2A,0x01,0x07, /* [4248] OBJ_setext_track2 */ 0x67,0x2A,0x01,0x08, /* [4252] OBJ_setext_cv */ 0x67,0x2A,0x05,0x00, /* [4256] OBJ_set_policy_root */ 0x67,0x2A,0x07,0x00, /* [4260] OBJ_setCext_hashedRoot */ 0x67,0x2A,0x07,0x01, /* [4264] OBJ_setCext_certType */ 0x67,0x2A,0x07,0x02, /* [4268] OBJ_setCext_merchData */ 0x67,0x2A,0x07,0x03, /* [4272] OBJ_setCext_cCertRequired */ 0x67,0x2A,0x07,0x04, /* [4276] OBJ_setCext_tunneling */ 0x67,0x2A,0x07,0x05, /* [4280] OBJ_setCext_setExt */ 0x67,0x2A,0x07,0x06, /* [4284] OBJ_setCext_setQualf */ 0x67,0x2A,0x07,0x07, /* [4288] OBJ_setCext_PGWYcapabilities */ 0x67,0x2A,0x07,0x08, /* [4292] OBJ_setCext_TokenIdentifier */ 0x67,0x2A,0x07,0x09, /* [4296] OBJ_setCext_Track2Data */ 0x67,0x2A,0x07,0x0A, /* [4300] OBJ_setCext_TokenType */ 0x67,0x2A,0x07,0x0B, /* [4304] OBJ_setCext_IssuerCapabilities */ 0x67,0x2A,0x03,0x00, /* [4308] OBJ_setAttr_Cert */ 0x67,0x2A,0x03,0x01, /* [4312] OBJ_setAttr_PGWYcap */ 0x67,0x2A,0x03,0x02, /* [4316] OBJ_setAttr_TokenType */ 0x67,0x2A,0x03,0x03, /* [4320] OBJ_setAttr_IssCap */ 0x67,0x2A,0x03,0x00,0x00, /* [4324] OBJ_set_rootKeyThumb */ 0x67,0x2A,0x03,0x00,0x01, /* [4329] OBJ_set_addPolicy */ 0x67,0x2A,0x03,0x02,0x01, /* [4334] OBJ_setAttr_Token_EMV */ 0x67,0x2A,0x03,0x02,0x02, /* [4339] OBJ_setAttr_Token_B0Prime */ 0x67,0x2A,0x03,0x03,0x03, /* [4344] OBJ_setAttr_IssCap_CVM */ 0x67,0x2A,0x03,0x03,0x04, /* [4349] OBJ_setAttr_IssCap_T2 */ 0x67,0x2A,0x03,0x03,0x05, /* [4354] OBJ_setAttr_IssCap_Sig */ 0x67,0x2A,0x03,0x03,0x03,0x01, /* [4359] OBJ_setAttr_GenCryptgrm */ 0x67,0x2A,0x03,0x03,0x04,0x01, /* [4365] OBJ_setAttr_T2Enc */ 0x67,0x2A,0x03,0x03,0x04,0x02, /* [4371] OBJ_setAttr_T2cleartxt */ 0x67,0x2A,0x03,0x03,0x05,0x01, /* [4377] OBJ_setAttr_TokICCsig */ 0x67,0x2A,0x03,0x03,0x05,0x02, /* [4383] OBJ_setAttr_SecDevSig */ 0x67,0x2A,0x08,0x01, /* [4389] OBJ_set_brand_IATA_ATA */ 0x67,0x2A,0x08,0x1E, /* [4393] OBJ_set_brand_Diners */ 0x67,0x2A,0x08,0x22, /* [4397] OBJ_set_brand_AmericanExpress */ 0x67,0x2A,0x08,0x23, /* [4401] OBJ_set_brand_JCB */ 0x67,0x2A,0x08,0x04, /* [4405] OBJ_set_brand_Visa */ 0x67,0x2A,0x08,0x05, /* [4409] OBJ_set_brand_MasterCard */ 0x67,0x2A,0x08,0xAE,0x7B, /* [4413] OBJ_set_brand_Novus */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x0A, /* [4418] OBJ_des_cdmf */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x06,/* [4426] OBJ_rsaOAEPEncryptionSET */ 0x67, /* [4435] OBJ_international_organizations */ 0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x14,0x02,0x02,/* [4436] OBJ_ms_smartcard_login */ 0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x14,0x02,0x03,/* [4446] OBJ_ms_upn */ 0x55,0x04,0x09, /* [4456] OBJ_streetAddress */ 0x55,0x04,0x11, /* [4459] OBJ_postalCode */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x15, /* [4462] OBJ_id_ppl */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x0E, /* [4469] OBJ_proxyCertInfo */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x15,0x00, /* [4477] OBJ_id_ppl_anyLanguage */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x15,0x01, /* [4485] OBJ_id_ppl_inheritAll */ 0x55,0x1D,0x1E, /* [4493] OBJ_name_constraints */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x15,0x02, /* [4496] OBJ_Independent */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,/* [4504] OBJ_sha256WithRSAEncryption */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0C,/* [4513] OBJ_sha384WithRSAEncryption */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0D,/* [4522] OBJ_sha512WithRSAEncryption */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0E,/* [4531] OBJ_sha224WithRSAEncryption */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,/* [4540] OBJ_sha256 */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x02,/* [4549] OBJ_sha384 */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,/* [4558] OBJ_sha512 */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x04,/* [4567] OBJ_sha224 */ 0x2B, /* [4576] OBJ_identified_organization */ 0x2B,0x81,0x04, /* [4577] OBJ_certicom_arc */ 0x67,0x2B, /* [4580] OBJ_wap */ 0x67,0x2B,0x01, /* [4582] OBJ_wap_wsg */ 0x2A,0x86,0x48,0xCE,0x3D,0x01,0x02,0x03, /* [4585] OBJ_X9_62_id_characteristic_two_basis */ 0x2A,0x86,0x48,0xCE,0x3D,0x01,0x02,0x03,0x01,/* [4593] OBJ_X9_62_onBasis */ 0x2A,0x86,0x48,0xCE,0x3D,0x01,0x02,0x03,0x02,/* [4602] OBJ_X9_62_tpBasis */ 0x2A,0x86,0x48,0xCE,0x3D,0x01,0x02,0x03,0x03,/* [4611] OBJ_X9_62_ppBasis */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x01, /* [4620] OBJ_X9_62_c2pnb163v1 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x02, /* [4628] OBJ_X9_62_c2pnb163v2 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x03, /* [4636] OBJ_X9_62_c2pnb163v3 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x04, /* [4644] OBJ_X9_62_c2pnb176v1 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x05, /* [4652] OBJ_X9_62_c2tnb191v1 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x06, /* [4660] OBJ_X9_62_c2tnb191v2 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x07, /* [4668] OBJ_X9_62_c2tnb191v3 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x08, /* [4676] OBJ_X9_62_c2onb191v4 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x09, /* [4684] OBJ_X9_62_c2onb191v5 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x0A, /* [4692] OBJ_X9_62_c2pnb208w1 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x0B, /* [4700] OBJ_X9_62_c2tnb239v1 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x0C, /* [4708] OBJ_X9_62_c2tnb239v2 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x0D, /* [4716] OBJ_X9_62_c2tnb239v3 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x0E, /* [4724] OBJ_X9_62_c2onb239v4 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x0F, /* [4732] OBJ_X9_62_c2onb239v5 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x10, /* [4740] OBJ_X9_62_c2pnb272w1 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x11, /* [4748] OBJ_X9_62_c2pnb304w1 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x12, /* [4756] OBJ_X9_62_c2tnb359v1 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x13, /* [4764] OBJ_X9_62_c2pnb368w1 */ 0x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x14, /* [4772] OBJ_X9_62_c2tnb431r1 */ 0x2B,0x81,0x04,0x00,0x06, /* [4780] OBJ_secp112r1 */ 0x2B,0x81,0x04,0x00,0x07, /* [4785] OBJ_secp112r2 */ 0x2B,0x81,0x04,0x00,0x1C, /* [4790] OBJ_secp128r1 */ 0x2B,0x81,0x04,0x00,0x1D, /* [4795] OBJ_secp128r2 */ 0x2B,0x81,0x04,0x00,0x09, /* [4800] OBJ_secp160k1 */ 0x2B,0x81,0x04,0x00,0x08, /* [4805] OBJ_secp160r1 */ 0x2B,0x81,0x04,0x00,0x1E, /* [4810] OBJ_secp160r2 */ 0x2B,0x81,0x04,0x00,0x1F, /* [4815] OBJ_secp192k1 */ 0x2B,0x81,0x04,0x00,0x20, /* [4820] OBJ_secp224k1 */ 0x2B,0x81,0x04,0x00,0x21, /* [4825] OBJ_secp224r1 */ 0x2B,0x81,0x04,0x00,0x0A, /* [4830] OBJ_secp256k1 */ 0x2B,0x81,0x04,0x00,0x22, /* [4835] OBJ_secp384r1 */ 0x2B,0x81,0x04,0x00,0x23, /* [4840] OBJ_secp521r1 */ 0x2B,0x81,0x04,0x00,0x04, /* [4845] OBJ_sect113r1 */ 0x2B,0x81,0x04,0x00,0x05, /* [4850] OBJ_sect113r2 */ 0x2B,0x81,0x04,0x00,0x16, /* [4855] OBJ_sect131r1 */ 0x2B,0x81,0x04,0x00,0x17, /* [4860] OBJ_sect131r2 */ 0x2B,0x81,0x04,0x00,0x01, /* [4865] OBJ_sect163k1 */ 0x2B,0x81,0x04,0x00,0x02, /* [4870] OBJ_sect163r1 */ 0x2B,0x81,0x04,0x00,0x0F, /* [4875] OBJ_sect163r2 */ 0x2B,0x81,0x04,0x00,0x18, /* [4880] OBJ_sect193r1 */ 0x2B,0x81,0x04,0x00,0x19, /* [4885] OBJ_sect193r2 */ 0x2B,0x81,0x04,0x00,0x1A, /* [4890] OBJ_sect233k1 */ 0x2B,0x81,0x04,0x00,0x1B, /* [4895] OBJ_sect233r1 */ 0x2B,0x81,0x04,0x00,0x03, /* [4900] OBJ_sect239k1 */ 0x2B,0x81,0x04,0x00,0x10, /* [4905] OBJ_sect283k1 */ 0x2B,0x81,0x04,0x00,0x11, /* [4910] OBJ_sect283r1 */ 0x2B,0x81,0x04,0x00,0x24, /* [4915] OBJ_sect409k1 */ 0x2B,0x81,0x04,0x00,0x25, /* [4920] OBJ_sect409r1 */ 0x2B,0x81,0x04,0x00,0x26, /* [4925] OBJ_sect571k1 */ 0x2B,0x81,0x04,0x00,0x27, /* [4930] OBJ_sect571r1 */ 0x67,0x2B,0x01,0x04,0x01, /* [4935] OBJ_wap_wsg_idm_ecid_wtls1 */ 0x67,0x2B,0x01,0x04,0x03, /* [4940] OBJ_wap_wsg_idm_ecid_wtls3 */ 0x67,0x2B,0x01,0x04,0x04, /* [4945] OBJ_wap_wsg_idm_ecid_wtls4 */ 0x67,0x2B,0x01,0x04,0x05, /* [4950] OBJ_wap_wsg_idm_ecid_wtls5 */ 0x67,0x2B,0x01,0x04,0x06, /* [4955] OBJ_wap_wsg_idm_ecid_wtls6 */ 0x67,0x2B,0x01,0x04,0x07, /* [4960] OBJ_wap_wsg_idm_ecid_wtls7 */ 0x67,0x2B,0x01,0x04,0x08, /* [4965] OBJ_wap_wsg_idm_ecid_wtls8 */ 0x67,0x2B,0x01,0x04,0x09, /* [4970] OBJ_wap_wsg_idm_ecid_wtls9 */ 0x67,0x2B,0x01,0x04,0x0A, /* [4975] OBJ_wap_wsg_idm_ecid_wtls10 */ 0x67,0x2B,0x01,0x04,0x0B, /* [4980] OBJ_wap_wsg_idm_ecid_wtls11 */ 0x67,0x2B,0x01,0x04,0x0C, /* [4985] OBJ_wap_wsg_idm_ecid_wtls12 */ 0x55,0x1D,0x20,0x00, /* [4990] OBJ_any_policy */ 0x55,0x1D,0x21, /* [4994] OBJ_policy_mappings */ 0x55,0x1D,0x36, /* [4997] OBJ_inhibit_any_policy */ 0x2A,0x83,0x08,0x8C,0x9A,0x4B,0x3D,0x01,0x01,0x01,0x02,/* [5000] OBJ_camellia_128_cbc */ 0x2A,0x83,0x08,0x8C,0x9A,0x4B,0x3D,0x01,0x01,0x01,0x03,/* [5011] OBJ_camellia_192_cbc */ 0x2A,0x83,0x08,0x8C,0x9A,0x4B,0x3D,0x01,0x01,0x01,0x04,/* [5022] OBJ_camellia_256_cbc */ 0x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x01, /* [5033] OBJ_camellia_128_ecb */ 0x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x15, /* [5041] OBJ_camellia_192_ecb */ 0x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x29, /* [5049] OBJ_camellia_256_ecb */ 0x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x04, /* [5057] OBJ_camellia_128_cfb128 */ 0x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x18, /* [5065] OBJ_camellia_192_cfb128 */ 0x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x2C, /* [5073] OBJ_camellia_256_cfb128 */ 0x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x03, /* [5081] OBJ_camellia_128_ofb128 */ 0x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x17, /* [5089] OBJ_camellia_192_ofb128 */ 0x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x2B, /* [5097] OBJ_camellia_256_ofb128 */ 0x55,0x1D,0x09, /* [5105] OBJ_subject_directory_attributes */ 0x55,0x1D,0x1C, /* [5108] OBJ_issuing_distribution_point */ 0x55,0x1D,0x1D, /* [5111] OBJ_certificate_issuer */ 0x2A,0x83,0x1A,0x8C,0x9A,0x44, /* [5114] OBJ_kisa */ 0x2A,0x83,0x1A,0x8C,0x9A,0x44,0x01,0x03, /* [5120] OBJ_seed_ecb */ 0x2A,0x83,0x1A,0x8C,0x9A,0x44,0x01,0x04, /* [5128] OBJ_seed_cbc */ 0x2A,0x83,0x1A,0x8C,0x9A,0x44,0x01,0x06, /* [5136] OBJ_seed_ofb128 */ 0x2A,0x83,0x1A,0x8C,0x9A,0x44,0x01,0x05, /* [5144] OBJ_seed_cfb128 */ 0x2B,0x06,0x01,0x05,0x05,0x08,0x01,0x01, /* [5152] OBJ_hmac_md5 */ 0x2B,0x06,0x01,0x05,0x05,0x08,0x01,0x02, /* [5160] OBJ_hmac_sha1 */ 0x2A,0x86,0x48,0x86,0xF6,0x7D,0x07,0x42,0x0D,/* [5168] OBJ_id_PasswordBasedMAC */ 0x2A,0x86,0x48,0x86,0xF6,0x7D,0x07,0x42,0x1E,/* [5177] OBJ_id_DHBasedMac */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x10, /* [5186] OBJ_id_it_suppLangTags */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x05, /* [5194] OBJ_caRepository */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x09,/* [5202] OBJ_id_smime_ct_compressedData */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x1B,/* [5213] OBJ_id_ct_asciiTextWithCRLF */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x05,/* [5224] OBJ_id_aes128_wrap */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x19,/* [5233] OBJ_id_aes192_wrap */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x2D,/* [5242] OBJ_id_aes256_wrap */ 0x2A,0x86,0x48,0xCE,0x3D,0x04,0x02, /* [5251] OBJ_ecdsa_with_Recommended */ 0x2A,0x86,0x48,0xCE,0x3D,0x04,0x03, /* [5258] OBJ_ecdsa_with_Specified */ 0x2A,0x86,0x48,0xCE,0x3D,0x04,0x03,0x01, /* [5265] OBJ_ecdsa_with_SHA224 */ 0x2A,0x86,0x48,0xCE,0x3D,0x04,0x03,0x02, /* [5273] OBJ_ecdsa_with_SHA256 */ 0x2A,0x86,0x48,0xCE,0x3D,0x04,0x03,0x03, /* [5281] OBJ_ecdsa_with_SHA384 */ 0x2A,0x86,0x48,0xCE,0x3D,0x04,0x03,0x04, /* [5289] OBJ_ecdsa_with_SHA512 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x06, /* [5297] OBJ_hmacWithMD5 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x08, /* [5305] OBJ_hmacWithSHA224 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x09, /* [5313] OBJ_hmacWithSHA256 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x0A, /* [5321] OBJ_hmacWithSHA384 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x0B, /* [5329] OBJ_hmacWithSHA512 */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x03,0x01,/* [5337] OBJ_dsa_with_SHA224 */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x03,0x02,/* [5346] OBJ_dsa_with_SHA256 */ 0x28,0xCF,0x06,0x03,0x00,0x37, /* [5355] OBJ_whirlpool */ 0x2A,0x85,0x03,0x02,0x02, /* [5361] OBJ_cryptopro */ 0x2A,0x85,0x03,0x02,0x09, /* [5366] OBJ_cryptocom */ 0x2A,0x85,0x03,0x02,0x02,0x03, /* [5371] OBJ_id_GostR3411_94_with_GostR3410_2001 */ 0x2A,0x85,0x03,0x02,0x02,0x04, /* [5377] OBJ_id_GostR3411_94_with_GostR3410_94 */ 0x2A,0x85,0x03,0x02,0x02,0x09, /* [5383] OBJ_id_GostR3411_94 */ 0x2A,0x85,0x03,0x02,0x02,0x0A, /* [5389] OBJ_id_HMACGostR3411_94 */ 0x2A,0x85,0x03,0x02,0x02,0x13, /* [5395] OBJ_id_GostR3410_2001 */ 0x2A,0x85,0x03,0x02,0x02,0x14, /* [5401] OBJ_id_GostR3410_94 */ 0x2A,0x85,0x03,0x02,0x02,0x15, /* [5407] OBJ_id_Gost28147_89 */ 0x2A,0x85,0x03,0x02,0x02,0x16, /* [5413] OBJ_id_Gost28147_89_MAC */ 0x2A,0x85,0x03,0x02,0x02,0x17, /* [5419] OBJ_id_GostR3411_94_prf */ 0x2A,0x85,0x03,0x02,0x02,0x62, /* [5425] OBJ_id_GostR3410_2001DH */ 0x2A,0x85,0x03,0x02,0x02,0x63, /* [5431] OBJ_id_GostR3410_94DH */ 0x2A,0x85,0x03,0x02,0x02,0x0E,0x01, /* [5437] OBJ_id_Gost28147_89_CryptoPro_KeyMeshing */ 0x2A,0x85,0x03,0x02,0x02,0x0E,0x00, /* [5444] OBJ_id_Gost28147_89_None_KeyMeshing */ 0x2A,0x85,0x03,0x02,0x02,0x1E,0x00, /* [5451] OBJ_id_GostR3411_94_TestParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x1E,0x01, /* [5458] OBJ_id_GostR3411_94_CryptoProParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x1F,0x00, /* [5465] OBJ_id_Gost28147_89_TestParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x1F,0x01, /* [5472] OBJ_id_Gost28147_89_CryptoPro_A_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x1F,0x02, /* [5479] OBJ_id_Gost28147_89_CryptoPro_B_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x1F,0x03, /* [5486] OBJ_id_Gost28147_89_CryptoPro_C_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x1F,0x04, /* [5493] OBJ_id_Gost28147_89_CryptoPro_D_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x1F,0x05, /* [5500] OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x1F,0x06, /* [5507] OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x1F,0x07, /* [5514] OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x20,0x00, /* [5521] OBJ_id_GostR3410_94_TestParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x20,0x02, /* [5528] OBJ_id_GostR3410_94_CryptoPro_A_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x20,0x03, /* [5535] OBJ_id_GostR3410_94_CryptoPro_B_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x20,0x04, /* [5542] OBJ_id_GostR3410_94_CryptoPro_C_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x20,0x05, /* [5549] OBJ_id_GostR3410_94_CryptoPro_D_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x21,0x01, /* [5556] OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x21,0x02, /* [5563] OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x21,0x03, /* [5570] OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x23,0x00, /* [5577] OBJ_id_GostR3410_2001_TestParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x23,0x01, /* [5584] OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x23,0x02, /* [5591] OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x23,0x03, /* [5598] OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x24,0x00, /* [5605] OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x24,0x01, /* [5612] OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet */ 0x2A,0x85,0x03,0x02,0x02,0x14,0x01, /* [5619] OBJ_id_GostR3410_94_a */ 0x2A,0x85,0x03,0x02,0x02,0x14,0x02, /* [5626] OBJ_id_GostR3410_94_aBis */ 0x2A,0x85,0x03,0x02,0x02,0x14,0x03, /* [5633] OBJ_id_GostR3410_94_b */ 0x2A,0x85,0x03,0x02,0x02,0x14,0x04, /* [5640] OBJ_id_GostR3410_94_bBis */ 0x2A,0x85,0x03,0x02,0x09,0x01,0x06,0x01, /* [5647] OBJ_id_Gost28147_89_cc */ 0x2A,0x85,0x03,0x02,0x09,0x01,0x05,0x03, /* [5655] OBJ_id_GostR3410_94_cc */ 0x2A,0x85,0x03,0x02,0x09,0x01,0x05,0x04, /* [5663] OBJ_id_GostR3410_2001_cc */ 0x2A,0x85,0x03,0x02,0x09,0x01,0x03,0x03, /* [5671] OBJ_id_GostR3411_94_with_GostR3410_94_cc */ 0x2A,0x85,0x03,0x02,0x09,0x01,0x03,0x04, /* [5679] OBJ_id_GostR3411_94_with_GostR3410_2001_cc */ 0x2A,0x85,0x03,0x02,0x09,0x01,0x08,0x01, /* [5687] OBJ_id_GostR3410_2001_ParamSet_cc */ 0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x11,0x02,/* [5695] OBJ_LocalKeySet */ 0x55,0x1D,0x2E, /* [5704] OBJ_freshest_crl */ 0x2B,0x06,0x01,0x05,0x05,0x07,0x08,0x03, /* [5707] OBJ_id_on_permanentIdentifier */ 0x55,0x04,0x0E, /* [5715] OBJ_searchGuide */ 0x55,0x04,0x0F, /* [5718] OBJ_businessCategory */ 0x55,0x04,0x10, /* [5721] OBJ_postalAddress */ 0x55,0x04,0x12, /* [5724] OBJ_postOfficeBox */ 0x55,0x04,0x13, /* [5727] OBJ_physicalDeliveryOfficeName */ 0x55,0x04,0x14, /* [5730] OBJ_telephoneNumber */ 0x55,0x04,0x15, /* [5733] OBJ_telexNumber */ 0x55,0x04,0x16, /* [5736] OBJ_teletexTerminalIdentifier */ 0x55,0x04,0x17, /* [5739] OBJ_facsimileTelephoneNumber */ 0x55,0x04,0x18, /* [5742] OBJ_x121Address */ 0x55,0x04,0x19, /* [5745] OBJ_internationaliSDNNumber */ 0x55,0x04,0x1A, /* [5748] OBJ_registeredAddress */ 0x55,0x04,0x1B, /* [5751] OBJ_destinationIndicator */ 0x55,0x04,0x1C, /* [5754] OBJ_preferredDeliveryMethod */ 0x55,0x04,0x1D, /* [5757] OBJ_presentationAddress */ 0x55,0x04,0x1E, /* [5760] OBJ_supportedApplicationContext */ 0x55,0x04,0x1F, /* [5763] OBJ_member */ 0x55,0x04,0x20, /* [5766] OBJ_owner */ 0x55,0x04,0x21, /* [5769] OBJ_roleOccupant */ 0x55,0x04,0x22, /* [5772] OBJ_seeAlso */ 0x55,0x04,0x23, /* [5775] OBJ_userPassword */ 0x55,0x04,0x24, /* [5778] OBJ_userCertificate */ 0x55,0x04,0x25, /* [5781] OBJ_cACertificate */ 0x55,0x04,0x26, /* [5784] OBJ_authorityRevocationList */ 0x55,0x04,0x27, /* [5787] OBJ_certificateRevocationList */ 0x55,0x04,0x28, /* [5790] OBJ_crossCertificatePair */ 0x55,0x04,0x2F, /* [5793] OBJ_enhancedSearchGuide */ 0x55,0x04,0x30, /* [5796] OBJ_protocolInformation */ 0x55,0x04,0x31, /* [5799] OBJ_distinguishedName */ 0x55,0x04,0x32, /* [5802] OBJ_uniqueMember */ 0x55,0x04,0x33, /* [5805] OBJ_houseIdentifier */ 0x55,0x04,0x34, /* [5808] OBJ_supportedAlgorithms */ 0x55,0x04,0x35, /* [5811] OBJ_deltaRevocationList */ 0x55,0x04,0x36, /* [5814] OBJ_dmdName */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x09,/* [5817] OBJ_id_alg_PWRI_KEK */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x06,/* [5828] OBJ_aes_128_gcm */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x07,/* [5837] OBJ_aes_128_ccm */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x08,/* [5846] OBJ_id_aes128_wrap_pad */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x1A,/* [5855] OBJ_aes_192_gcm */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x1B,/* [5864] OBJ_aes_192_ccm */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x1C,/* [5873] OBJ_id_aes192_wrap_pad */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x2E,/* [5882] OBJ_aes_256_gcm */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x2F,/* [5891] OBJ_aes_256_ccm */ 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x30,/* [5900] OBJ_id_aes256_wrap_pad */ 0x2A,0x83,0x08,0x8C,0x9A,0x4B,0x3D,0x01,0x01,0x03,0x02,/* [5909] OBJ_id_camellia128_wrap */ 0x2A,0x83,0x08,0x8C,0x9A,0x4B,0x3D,0x01,0x01,0x03,0x03,/* [5920] OBJ_id_camellia192_wrap */ 0x2A,0x83,0x08,0x8C,0x9A,0x4B,0x3D,0x01,0x01,0x03,0x04,/* [5931] OBJ_id_camellia256_wrap */ 0x55,0x1D,0x25,0x00, /* [5942] OBJ_anyExtendedKeyUsage */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x08,/* [5946] OBJ_mgf1 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0A,/* [5955] OBJ_rsassaPss */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x07,/* [5964] OBJ_rsaesOaep */ 0x2B,0x24, /* [5973] OBJ_teletrust */ 0x2B,0x24,0x03,0x03,0x02,0x08,0x01, /* [5975] OBJ_brainpool */ 0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x01,/* [5982] OBJ_brainpoolP160r1 */ 0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x02,/* [5991] OBJ_brainpoolP160t1 */ 0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x03,/* [6000] OBJ_brainpoolP192r1 */ 0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x04,/* [6009] OBJ_brainpoolP192t1 */ 0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x05,/* [6018] OBJ_brainpoolP224r1 */ 0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x06,/* [6027] OBJ_brainpoolP224t1 */ 0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x07,/* [6036] OBJ_brainpoolP256r1 */ 0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x08,/* [6045] OBJ_brainpoolP256t1 */ 0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x09,/* [6054] OBJ_brainpoolP320r1 */ 0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x0A,/* [6063] OBJ_brainpoolP320t1 */ 0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x0B,/* [6072] OBJ_brainpoolP384r1 */ 0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x0C,/* [6081] OBJ_brainpoolP384t1 */ 0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x0D,/* [6090] OBJ_brainpoolP512r1 */ 0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x0E,/* [6099] OBJ_brainpoolP512t1 */ 0x2A,0x81,0x7A,0x01,0x81,0x5F,0x65,0x82,0x00,0x01,/* [6108] OBJ_FRP256v1 */ }; static const ASN1_OBJECT nid_objs[NUM_NID]={ {"UNDEF","undefined",NID_undef,0,NULL,0}, {"rsadsi","RSA Data Security, Inc.",NID_rsadsi,6,&(lvalues[0]),0}, {"pkcs","RSA Data Security, Inc. PKCS",NID_pkcs,7,&(lvalues[6]),0}, {"MD2","md2",NID_md2,8,&(lvalues[13]),0}, {"MD5","md5",NID_md5,8,&(lvalues[21]),0}, {"RC4","rc4",NID_rc4,8,&(lvalues[29]),0}, {"rsaEncryption","rsaEncryption",NID_rsaEncryption,9,&(lvalues[37]),0}, {"RSA-MD2","md2WithRSAEncryption",NID_md2WithRSAEncryption,9, &(lvalues[46]),0}, {"RSA-MD5","md5WithRSAEncryption",NID_md5WithRSAEncryption,9, &(lvalues[55]),0}, {"PBE-MD2-DES","pbeWithMD2AndDES-CBC",NID_pbeWithMD2AndDES_CBC,9, &(lvalues[64]),0}, {"PBE-MD5-DES","pbeWithMD5AndDES-CBC",NID_pbeWithMD5AndDES_CBC,9, &(lvalues[73]),0}, {"X500","directory services (X.500)",NID_X500,1,&(lvalues[82]),0}, {"X509","X509",NID_X509,2,&(lvalues[83]),0}, {"CN","commonName",NID_commonName,3,&(lvalues[85]),0}, {"C","countryName",NID_countryName,3,&(lvalues[88]),0}, {"L","localityName",NID_localityName,3,&(lvalues[91]),0}, {"ST","stateOrProvinceName",NID_stateOrProvinceName,3,&(lvalues[94]),0}, {"O","organizationName",NID_organizationName,3,&(lvalues[97]),0}, {"OU","organizationalUnitName",NID_organizationalUnitName,3, &(lvalues[100]),0}, {"RSA","rsa",NID_rsa,4,&(lvalues[103]),0}, {"pkcs7","pkcs7",NID_pkcs7,8,&(lvalues[107]),0}, {"pkcs7-data","pkcs7-data",NID_pkcs7_data,9,&(lvalues[115]),0}, {"pkcs7-signedData","pkcs7-signedData",NID_pkcs7_signed,9, &(lvalues[124]),0}, {"pkcs7-envelopedData","pkcs7-envelopedData",NID_pkcs7_enveloped,9, &(lvalues[133]),0}, {"pkcs7-signedAndEnvelopedData","pkcs7-signedAndEnvelopedData", NID_pkcs7_signedAndEnveloped,9,&(lvalues[142]),0}, {"pkcs7-digestData","pkcs7-digestData",NID_pkcs7_digest,9, &(lvalues[151]),0}, {"pkcs7-encryptedData","pkcs7-encryptedData",NID_pkcs7_encrypted,9, &(lvalues[160]),0}, {"pkcs3","pkcs3",NID_pkcs3,8,&(lvalues[169]),0}, {"dhKeyAgreement","dhKeyAgreement",NID_dhKeyAgreement,9, &(lvalues[177]),0}, {"DES-ECB","des-ecb",NID_des_ecb,5,&(lvalues[186]),0}, {"DES-CFB","des-cfb",NID_des_cfb64,5,&(lvalues[191]),0}, {"DES-CBC","des-cbc",NID_des_cbc,5,&(lvalues[196]),0}, {"DES-EDE","des-ede",NID_des_ede_ecb,5,&(lvalues[201]),0}, {"DES-EDE3","des-ede3",NID_des_ede3_ecb,0,NULL,0}, {"IDEA-CBC","idea-cbc",NID_idea_cbc,11,&(lvalues[206]),0}, {"IDEA-CFB","idea-cfb",NID_idea_cfb64,0,NULL,0}, {"IDEA-ECB","idea-ecb",NID_idea_ecb,0,NULL,0}, {"RC2-CBC","rc2-cbc",NID_rc2_cbc,8,&(lvalues[217]),0}, {"RC2-ECB","rc2-ecb",NID_rc2_ecb,0,NULL,0}, {"RC2-CFB","rc2-cfb",NID_rc2_cfb64,0,NULL,0}, {"RC2-OFB","rc2-ofb",NID_rc2_ofb64,0,NULL,0}, {"SHA","sha",NID_sha,5,&(lvalues[225]),0}, {"RSA-SHA","shaWithRSAEncryption",NID_shaWithRSAEncryption,5, &(lvalues[230]),0}, {"DES-EDE-CBC","des-ede-cbc",NID_des_ede_cbc,0,NULL,0}, {"DES-EDE3-CBC","des-ede3-cbc",NID_des_ede3_cbc,8,&(lvalues[235]),0}, {"DES-OFB","des-ofb",NID_des_ofb64,5,&(lvalues[243]),0}, {"IDEA-OFB","idea-ofb",NID_idea_ofb64,0,NULL,0}, {"pkcs9","pkcs9",NID_pkcs9,8,&(lvalues[248]),0}, {"emailAddress","emailAddress",NID_pkcs9_emailAddress,9, &(lvalues[256]),0}, {"unstructuredName","unstructuredName",NID_pkcs9_unstructuredName,9, &(lvalues[265]),0}, {"contentType","contentType",NID_pkcs9_contentType,9,&(lvalues[274]),0}, {"messageDigest","messageDigest",NID_pkcs9_messageDigest,9, &(lvalues[283]),0}, {"signingTime","signingTime",NID_pkcs9_signingTime,9,&(lvalues[292]),0}, {"countersignature","countersignature",NID_pkcs9_countersignature,9, &(lvalues[301]),0}, {"challengePassword","challengePassword",NID_pkcs9_challengePassword, 9,&(lvalues[310]),0}, {"unstructuredAddress","unstructuredAddress", NID_pkcs9_unstructuredAddress,9,&(lvalues[319]),0}, {"extendedCertificateAttributes","extendedCertificateAttributes", NID_pkcs9_extCertAttributes,9,&(lvalues[328]),0}, {"Netscape","Netscape Communications Corp.",NID_netscape,7, &(lvalues[337]),0}, {"nsCertExt","Netscape Certificate Extension", NID_netscape_cert_extension,8,&(lvalues[344]),0}, {"nsDataType","Netscape Data Type",NID_netscape_data_type,8, &(lvalues[352]),0}, {"DES-EDE-CFB","des-ede-cfb",NID_des_ede_cfb64,0,NULL,0}, {"DES-EDE3-CFB","des-ede3-cfb",NID_des_ede3_cfb64,0,NULL,0}, {"DES-EDE-OFB","des-ede-ofb",NID_des_ede_ofb64,0,NULL,0}, {"DES-EDE3-OFB","des-ede3-ofb",NID_des_ede3_ofb64,0,NULL,0}, {"SHA1","sha1",NID_sha1,5,&(lvalues[360]),0}, {"RSA-SHA1","sha1WithRSAEncryption",NID_sha1WithRSAEncryption,9, &(lvalues[365]),0}, {"DSA-SHA","dsaWithSHA",NID_dsaWithSHA,5,&(lvalues[374]),0}, {"DSA-old","dsaEncryption-old",NID_dsa_2,5,&(lvalues[379]),0}, {"PBE-SHA1-RC2-64","pbeWithSHA1AndRC2-CBC",NID_pbeWithSHA1AndRC2_CBC, 9,&(lvalues[384]),0}, {"PBKDF2","PBKDF2",NID_id_pbkdf2,9,&(lvalues[393]),0}, {"DSA-SHA1-old","dsaWithSHA1-old",NID_dsaWithSHA1_2,5,&(lvalues[402]),0}, {"nsCertType","Netscape Cert Type",NID_netscape_cert_type,9, &(lvalues[407]),0}, {"nsBaseUrl","Netscape Base Url",NID_netscape_base_url,9, &(lvalues[416]),0}, {"nsRevocationUrl","Netscape Revocation Url", NID_netscape_revocation_url,9,&(lvalues[425]),0}, {"nsCaRevocationUrl","Netscape CA Revocation Url", NID_netscape_ca_revocation_url,9,&(lvalues[434]),0}, {"nsRenewalUrl","Netscape Renewal Url",NID_netscape_renewal_url,9, &(lvalues[443]),0}, {"nsCaPolicyUrl","Netscape CA Policy Url",NID_netscape_ca_policy_url, 9,&(lvalues[452]),0}, {"nsSslServerName","Netscape SSL Server Name", NID_netscape_ssl_server_name,9,&(lvalues[461]),0}, {"nsComment","Netscape Comment",NID_netscape_comment,9,&(lvalues[470]),0}, {"nsCertSequence","Netscape Certificate Sequence", NID_netscape_cert_sequence,9,&(lvalues[479]),0}, {"DESX-CBC","desx-cbc",NID_desx_cbc,0,NULL,0}, {"id-ce","id-ce",NID_id_ce,2,&(lvalues[488]),0}, {"subjectKeyIdentifier","X509v3 Subject Key Identifier", NID_subject_key_identifier,3,&(lvalues[490]),0}, {"keyUsage","X509v3 Key Usage",NID_key_usage,3,&(lvalues[493]),0}, {"privateKeyUsagePeriod","X509v3 Private Key Usage Period", NID_private_key_usage_period,3,&(lvalues[496]),0}, {"subjectAltName","X509v3 Subject Alternative Name", NID_subject_alt_name,3,&(lvalues[499]),0}, {"issuerAltName","X509v3 Issuer Alternative Name",NID_issuer_alt_name, 3,&(lvalues[502]),0}, {"basicConstraints","X509v3 Basic Constraints",NID_basic_constraints, 3,&(lvalues[505]),0}, {"crlNumber","X509v3 CRL Number",NID_crl_number,3,&(lvalues[508]),0}, {"certificatePolicies","X509v3 Certificate Policies", NID_certificate_policies,3,&(lvalues[511]),0}, {"authorityKeyIdentifier","X509v3 Authority Key Identifier", NID_authority_key_identifier,3,&(lvalues[514]),0}, {"BF-CBC","bf-cbc",NID_bf_cbc,9,&(lvalues[517]),0}, {"BF-ECB","bf-ecb",NID_bf_ecb,0,NULL,0}, {"BF-CFB","bf-cfb",NID_bf_cfb64,0,NULL,0}, {"BF-OFB","bf-ofb",NID_bf_ofb64,0,NULL,0}, {"MDC2","mdc2",NID_mdc2,4,&(lvalues[526]),0}, {"RSA-MDC2","mdc2WithRSA",NID_mdc2WithRSA,4,&(lvalues[530]),0}, {"RC4-40","rc4-40",NID_rc4_40,0,NULL,0}, {"RC2-40-CBC","rc2-40-cbc",NID_rc2_40_cbc,0,NULL,0}, {"GN","givenName",NID_givenName,3,&(lvalues[534]),0}, {"SN","surname",NID_surname,3,&(lvalues[537]),0}, {"initials","initials",NID_initials,3,&(lvalues[540]),0}, {NULL,NULL,NID_undef,0,NULL,0}, {"crlDistributionPoints","X509v3 CRL Distribution Points", NID_crl_distribution_points,3,&(lvalues[543]),0}, {"RSA-NP-MD5","md5WithRSA",NID_md5WithRSA,5,&(lvalues[546]),0}, {"serialNumber","serialNumber",NID_serialNumber,3,&(lvalues[551]),0}, {"title","title",NID_title,3,&(lvalues[554]),0}, {"description","description",NID_description,3,&(lvalues[557]),0}, {"CAST5-CBC","cast5-cbc",NID_cast5_cbc,9,&(lvalues[560]),0}, {"CAST5-ECB","cast5-ecb",NID_cast5_ecb,0,NULL,0}, {"CAST5-CFB","cast5-cfb",NID_cast5_cfb64,0,NULL,0}, {"CAST5-OFB","cast5-ofb",NID_cast5_ofb64,0,NULL,0}, {"pbeWithMD5AndCast5CBC","pbeWithMD5AndCast5CBC", NID_pbeWithMD5AndCast5_CBC,9,&(lvalues[569]),0}, {"DSA-SHA1","dsaWithSHA1",NID_dsaWithSHA1,7,&(lvalues[578]),0}, {"MD5-SHA1","md5-sha1",NID_md5_sha1,0,NULL,0}, {"RSA-SHA1-2","sha1WithRSA",NID_sha1WithRSA,5,&(lvalues[585]),0}, {"DSA","dsaEncryption",NID_dsa,7,&(lvalues[590]),0}, {"RIPEMD160","ripemd160",NID_ripemd160,5,&(lvalues[597]),0}, {NULL,NULL,NID_undef,0,NULL,0}, {"RSA-RIPEMD160","ripemd160WithRSA",NID_ripemd160WithRSA,6, &(lvalues[602]),0}, {"RC5-CBC","rc5-cbc",NID_rc5_cbc,8,&(lvalues[608]),0}, {"RC5-ECB","rc5-ecb",NID_rc5_ecb,0,NULL,0}, {"RC5-CFB","rc5-cfb",NID_rc5_cfb64,0,NULL,0}, {"RC5-OFB","rc5-ofb",NID_rc5_ofb64,0,NULL,0}, {"RLE","run length compression",NID_rle_compression,6,&(lvalues[616]),0}, {"ZLIB","zlib compression",NID_zlib_compression,11,&(lvalues[622]),0}, {"extendedKeyUsage","X509v3 Extended Key Usage",NID_ext_key_usage,3, &(lvalues[633]),0}, {"PKIX","PKIX",NID_id_pkix,6,&(lvalues[636]),0}, {"id-kp","id-kp",NID_id_kp,7,&(lvalues[642]),0}, {"serverAuth","TLS Web Server Authentication",NID_server_auth,8, &(lvalues[649]),0}, {"clientAuth","TLS Web Client Authentication",NID_client_auth,8, &(lvalues[657]),0}, {"codeSigning","Code Signing",NID_code_sign,8,&(lvalues[665]),0}, {"emailProtection","E-mail Protection",NID_email_protect,8, &(lvalues[673]),0}, {"timeStamping","Time Stamping",NID_time_stamp,8,&(lvalues[681]),0}, {"msCodeInd","Microsoft Individual Code Signing",NID_ms_code_ind,10, &(lvalues[689]),0}, {"msCodeCom","Microsoft Commercial Code Signing",NID_ms_code_com,10, &(lvalues[699]),0}, {"msCTLSign","Microsoft Trust List Signing",NID_ms_ctl_sign,10, &(lvalues[709]),0}, {"msSGC","Microsoft Server Gated Crypto",NID_ms_sgc,10,&(lvalues[719]),0}, {"msEFS","Microsoft Encrypted File System",NID_ms_efs,10, &(lvalues[729]),0}, {"nsSGC","Netscape Server Gated Crypto",NID_ns_sgc,9,&(lvalues[739]),0}, {"deltaCRL","X509v3 Delta CRL Indicator",NID_delta_crl,3, &(lvalues[748]),0}, {"CRLReason","X509v3 CRL Reason Code",NID_crl_reason,3,&(lvalues[751]),0}, {"invalidityDate","Invalidity Date",NID_invalidity_date,3, &(lvalues[754]),0}, {"SXNetID","Strong Extranet ID",NID_sxnet,5,&(lvalues[757]),0}, {"PBE-SHA1-RC4-128","pbeWithSHA1And128BitRC4", NID_pbe_WithSHA1And128BitRC4,10,&(lvalues[762]),0}, {"PBE-SHA1-RC4-40","pbeWithSHA1And40BitRC4", NID_pbe_WithSHA1And40BitRC4,10,&(lvalues[772]),0}, {"PBE-SHA1-3DES","pbeWithSHA1And3-KeyTripleDES-CBC", NID_pbe_WithSHA1And3_Key_TripleDES_CBC,10,&(lvalues[782]),0}, {"PBE-SHA1-2DES","pbeWithSHA1And2-KeyTripleDES-CBC", NID_pbe_WithSHA1And2_Key_TripleDES_CBC,10,&(lvalues[792]),0}, {"PBE-SHA1-RC2-128","pbeWithSHA1And128BitRC2-CBC", NID_pbe_WithSHA1And128BitRC2_CBC,10,&(lvalues[802]),0}, {"PBE-SHA1-RC2-40","pbeWithSHA1And40BitRC2-CBC", NID_pbe_WithSHA1And40BitRC2_CBC,10,&(lvalues[812]),0}, {"keyBag","keyBag",NID_keyBag,11,&(lvalues[822]),0}, {"pkcs8ShroudedKeyBag","pkcs8ShroudedKeyBag",NID_pkcs8ShroudedKeyBag, 11,&(lvalues[833]),0}, {"certBag","certBag",NID_certBag,11,&(lvalues[844]),0}, {"crlBag","crlBag",NID_crlBag,11,&(lvalues[855]),0}, {"secretBag","secretBag",NID_secretBag,11,&(lvalues[866]),0}, {"safeContentsBag","safeContentsBag",NID_safeContentsBag,11, &(lvalues[877]),0}, {"friendlyName","friendlyName",NID_friendlyName,9,&(lvalues[888]),0}, {"localKeyID","localKeyID",NID_localKeyID,9,&(lvalues[897]),0}, {"x509Certificate","x509Certificate",NID_x509Certificate,10, &(lvalues[906]),0}, {"sdsiCertificate","sdsiCertificate",NID_sdsiCertificate,10, &(lvalues[916]),0}, {"x509Crl","x509Crl",NID_x509Crl,10,&(lvalues[926]),0}, {"PBES2","PBES2",NID_pbes2,9,&(lvalues[936]),0}, {"PBMAC1","PBMAC1",NID_pbmac1,9,&(lvalues[945]),0}, {"hmacWithSHA1","hmacWithSHA1",NID_hmacWithSHA1,8,&(lvalues[954]),0}, {"id-qt-cps","Policy Qualifier CPS",NID_id_qt_cps,8,&(lvalues[962]),0}, {"id-qt-unotice","Policy Qualifier User Notice",NID_id_qt_unotice,8, &(lvalues[970]),0}, {"RC2-64-CBC","rc2-64-cbc",NID_rc2_64_cbc,0,NULL,0}, {"SMIME-CAPS","S/MIME Capabilities",NID_SMIMECapabilities,9, &(lvalues[978]),0}, {"PBE-MD2-RC2-64","pbeWithMD2AndRC2-CBC",NID_pbeWithMD2AndRC2_CBC,9, &(lvalues[987]),0}, {"PBE-MD5-RC2-64","pbeWithMD5AndRC2-CBC",NID_pbeWithMD5AndRC2_CBC,9, &(lvalues[996]),0}, {"PBE-SHA1-DES","pbeWithSHA1AndDES-CBC",NID_pbeWithSHA1AndDES_CBC,9, &(lvalues[1005]),0}, {"msExtReq","Microsoft Extension Request",NID_ms_ext_req,10, &(lvalues[1014]),0}, {"extReq","Extension Request",NID_ext_req,9,&(lvalues[1024]),0}, {"name","name",NID_name,3,&(lvalues[1033]),0}, {"dnQualifier","dnQualifier",NID_dnQualifier,3,&(lvalues[1036]),0}, {"id-pe","id-pe",NID_id_pe,7,&(lvalues[1039]),0}, {"id-ad","id-ad",NID_id_ad,7,&(lvalues[1046]),0}, {"authorityInfoAccess","Authority Information Access",NID_info_access, 8,&(lvalues[1053]),0}, {"OCSP","OCSP",NID_ad_OCSP,8,&(lvalues[1061]),0}, {"caIssuers","CA Issuers",NID_ad_ca_issuers,8,&(lvalues[1069]),0}, {"OCSPSigning","OCSP Signing",NID_OCSP_sign,8,&(lvalues[1077]),0}, {"ISO","iso",NID_iso,0,NULL,0}, {"member-body","ISO Member Body",NID_member_body,1,&(lvalues[1085]),0}, {"ISO-US","ISO US Member Body",NID_ISO_US,3,&(lvalues[1086]),0}, {"X9-57","X9.57",NID_X9_57,5,&(lvalues[1089]),0}, {"X9cm","X9.57 CM ?",NID_X9cm,6,&(lvalues[1094]),0}, {"pkcs1","pkcs1",NID_pkcs1,8,&(lvalues[1100]),0}, {"pkcs5","pkcs5",NID_pkcs5,8,&(lvalues[1108]),0}, {"SMIME","S/MIME",NID_SMIME,9,&(lvalues[1116]),0}, {"id-smime-mod","id-smime-mod",NID_id_smime_mod,10,&(lvalues[1125]),0}, {"id-smime-ct","id-smime-ct",NID_id_smime_ct,10,&(lvalues[1135]),0}, {"id-smime-aa","id-smime-aa",NID_id_smime_aa,10,&(lvalues[1145]),0}, {"id-smime-alg","id-smime-alg",NID_id_smime_alg,10,&(lvalues[1155]),0}, {"id-smime-cd","id-smime-cd",NID_id_smime_cd,10,&(lvalues[1165]),0}, {"id-smime-spq","id-smime-spq",NID_id_smime_spq,10,&(lvalues[1175]),0}, {"id-smime-cti","id-smime-cti",NID_id_smime_cti,10,&(lvalues[1185]),0}, {"id-smime-mod-cms","id-smime-mod-cms",NID_id_smime_mod_cms,11, &(lvalues[1195]),0}, {"id-smime-mod-ess","id-smime-mod-ess",NID_id_smime_mod_ess,11, &(lvalues[1206]),0}, {"id-smime-mod-oid","id-smime-mod-oid",NID_id_smime_mod_oid,11, &(lvalues[1217]),0}, {"id-smime-mod-msg-v3","id-smime-mod-msg-v3",NID_id_smime_mod_msg_v3, 11,&(lvalues[1228]),0}, {"id-smime-mod-ets-eSignature-88","id-smime-mod-ets-eSignature-88", NID_id_smime_mod_ets_eSignature_88,11,&(lvalues[1239]),0}, {"id-smime-mod-ets-eSignature-97","id-smime-mod-ets-eSignature-97", NID_id_smime_mod_ets_eSignature_97,11,&(lvalues[1250]),0}, {"id-smime-mod-ets-eSigPolicy-88","id-smime-mod-ets-eSigPolicy-88", NID_id_smime_mod_ets_eSigPolicy_88,11,&(lvalues[1261]),0}, {"id-smime-mod-ets-eSigPolicy-97","id-smime-mod-ets-eSigPolicy-97", NID_id_smime_mod_ets_eSigPolicy_97,11,&(lvalues[1272]),0}, {"id-smime-ct-receipt","id-smime-ct-receipt",NID_id_smime_ct_receipt, 11,&(lvalues[1283]),0}, {"id-smime-ct-authData","id-smime-ct-authData", NID_id_smime_ct_authData,11,&(lvalues[1294]),0}, {"id-smime-ct-publishCert","id-smime-ct-publishCert", NID_id_smime_ct_publishCert,11,&(lvalues[1305]),0}, {"id-smime-ct-TSTInfo","id-smime-ct-TSTInfo",NID_id_smime_ct_TSTInfo, 11,&(lvalues[1316]),0}, {"id-smime-ct-TDTInfo","id-smime-ct-TDTInfo",NID_id_smime_ct_TDTInfo, 11,&(lvalues[1327]),0}, {"id-smime-ct-contentInfo","id-smime-ct-contentInfo", NID_id_smime_ct_contentInfo,11,&(lvalues[1338]),0}, {"id-smime-ct-DVCSRequestData","id-smime-ct-DVCSRequestData", NID_id_smime_ct_DVCSRequestData,11,&(lvalues[1349]),0}, {"id-smime-ct-DVCSResponseData","id-smime-ct-DVCSResponseData", NID_id_smime_ct_DVCSResponseData,11,&(lvalues[1360]),0}, {"id-smime-aa-receiptRequest","id-smime-aa-receiptRequest", NID_id_smime_aa_receiptRequest,11,&(lvalues[1371]),0}, {"id-smime-aa-securityLabel","id-smime-aa-securityLabel", NID_id_smime_aa_securityLabel,11,&(lvalues[1382]),0}, {"id-smime-aa-mlExpandHistory","id-smime-aa-mlExpandHistory", NID_id_smime_aa_mlExpandHistory,11,&(lvalues[1393]),0}, {"id-smime-aa-contentHint","id-smime-aa-contentHint", NID_id_smime_aa_contentHint,11,&(lvalues[1404]),0}, {"id-smime-aa-msgSigDigest","id-smime-aa-msgSigDigest", NID_id_smime_aa_msgSigDigest,11,&(lvalues[1415]),0}, {"id-smime-aa-encapContentType","id-smime-aa-encapContentType", NID_id_smime_aa_encapContentType,11,&(lvalues[1426]),0}, {"id-smime-aa-contentIdentifier","id-smime-aa-contentIdentifier", NID_id_smime_aa_contentIdentifier,11,&(lvalues[1437]),0}, {"id-smime-aa-macValue","id-smime-aa-macValue", NID_id_smime_aa_macValue,11,&(lvalues[1448]),0}, {"id-smime-aa-equivalentLabels","id-smime-aa-equivalentLabels", NID_id_smime_aa_equivalentLabels,11,&(lvalues[1459]),0}, {"id-smime-aa-contentReference","id-smime-aa-contentReference", NID_id_smime_aa_contentReference,11,&(lvalues[1470]),0}, {"id-smime-aa-encrypKeyPref","id-smime-aa-encrypKeyPref", NID_id_smime_aa_encrypKeyPref,11,&(lvalues[1481]),0}, {"id-smime-aa-signingCertificate","id-smime-aa-signingCertificate", NID_id_smime_aa_signingCertificate,11,&(lvalues[1492]),0}, {"id-smime-aa-smimeEncryptCerts","id-smime-aa-smimeEncryptCerts", NID_id_smime_aa_smimeEncryptCerts,11,&(lvalues[1503]),0}, {"id-smime-aa-timeStampToken","id-smime-aa-timeStampToken", NID_id_smime_aa_timeStampToken,11,&(lvalues[1514]),0}, {"id-smime-aa-ets-sigPolicyId","id-smime-aa-ets-sigPolicyId", NID_id_smime_aa_ets_sigPolicyId,11,&(lvalues[1525]),0}, {"id-smime-aa-ets-commitmentType","id-smime-aa-ets-commitmentType", NID_id_smime_aa_ets_commitmentType,11,&(lvalues[1536]),0}, {"id-smime-aa-ets-signerLocation","id-smime-aa-ets-signerLocation", NID_id_smime_aa_ets_signerLocation,11,&(lvalues[1547]),0}, {"id-smime-aa-ets-signerAttr","id-smime-aa-ets-signerAttr", NID_id_smime_aa_ets_signerAttr,11,&(lvalues[1558]),0}, {"id-smime-aa-ets-otherSigCert","id-smime-aa-ets-otherSigCert", NID_id_smime_aa_ets_otherSigCert,11,&(lvalues[1569]),0}, {"id-smime-aa-ets-contentTimestamp", "id-smime-aa-ets-contentTimestamp", NID_id_smime_aa_ets_contentTimestamp,11,&(lvalues[1580]),0}, {"id-smime-aa-ets-CertificateRefs","id-smime-aa-ets-CertificateRefs", NID_id_smime_aa_ets_CertificateRefs,11,&(lvalues[1591]),0}, {"id-smime-aa-ets-RevocationRefs","id-smime-aa-ets-RevocationRefs", NID_id_smime_aa_ets_RevocationRefs,11,&(lvalues[1602]),0}, {"id-smime-aa-ets-certValues","id-smime-aa-ets-certValues", NID_id_smime_aa_ets_certValues,11,&(lvalues[1613]),0}, {"id-smime-aa-ets-revocationValues", "id-smime-aa-ets-revocationValues", NID_id_smime_aa_ets_revocationValues,11,&(lvalues[1624]),0}, {"id-smime-aa-ets-escTimeStamp","id-smime-aa-ets-escTimeStamp", NID_id_smime_aa_ets_escTimeStamp,11,&(lvalues[1635]),0}, {"id-smime-aa-ets-certCRLTimestamp", "id-smime-aa-ets-certCRLTimestamp", NID_id_smime_aa_ets_certCRLTimestamp,11,&(lvalues[1646]),0}, {"id-smime-aa-ets-archiveTimeStamp", "id-smime-aa-ets-archiveTimeStamp", NID_id_smime_aa_ets_archiveTimeStamp,11,&(lvalues[1657]),0}, {"id-smime-aa-signatureType","id-smime-aa-signatureType", NID_id_smime_aa_signatureType,11,&(lvalues[1668]),0}, {"id-smime-aa-dvcs-dvc","id-smime-aa-dvcs-dvc", NID_id_smime_aa_dvcs_dvc,11,&(lvalues[1679]),0}, {"id-smime-alg-ESDHwith3DES","id-smime-alg-ESDHwith3DES", NID_id_smime_alg_ESDHwith3DES,11,&(lvalues[1690]),0}, {"id-smime-alg-ESDHwithRC2","id-smime-alg-ESDHwithRC2", NID_id_smime_alg_ESDHwithRC2,11,&(lvalues[1701]),0}, {"id-smime-alg-3DESwrap","id-smime-alg-3DESwrap", NID_id_smime_alg_3DESwrap,11,&(lvalues[1712]),0}, {"id-smime-alg-RC2wrap","id-smime-alg-RC2wrap", NID_id_smime_alg_RC2wrap,11,&(lvalues[1723]),0}, {"id-smime-alg-ESDH","id-smime-alg-ESDH",NID_id_smime_alg_ESDH,11, &(lvalues[1734]),0}, {"id-smime-alg-CMS3DESwrap","id-smime-alg-CMS3DESwrap", NID_id_smime_alg_CMS3DESwrap,11,&(lvalues[1745]),0}, {"id-smime-alg-CMSRC2wrap","id-smime-alg-CMSRC2wrap", NID_id_smime_alg_CMSRC2wrap,11,&(lvalues[1756]),0}, {"id-smime-cd-ldap","id-smime-cd-ldap",NID_id_smime_cd_ldap,11, &(lvalues[1767]),0}, {"id-smime-spq-ets-sqt-uri","id-smime-spq-ets-sqt-uri", NID_id_smime_spq_ets_sqt_uri,11,&(lvalues[1778]),0}, {"id-smime-spq-ets-sqt-unotice","id-smime-spq-ets-sqt-unotice", NID_id_smime_spq_ets_sqt_unotice,11,&(lvalues[1789]),0}, {"id-smime-cti-ets-proofOfOrigin","id-smime-cti-ets-proofOfOrigin", NID_id_smime_cti_ets_proofOfOrigin,11,&(lvalues[1800]),0}, {"id-smime-cti-ets-proofOfReceipt","id-smime-cti-ets-proofOfReceipt", NID_id_smime_cti_ets_proofOfReceipt,11,&(lvalues[1811]),0}, {"id-smime-cti-ets-proofOfDelivery", "id-smime-cti-ets-proofOfDelivery", NID_id_smime_cti_ets_proofOfDelivery,11,&(lvalues[1822]),0}, {"id-smime-cti-ets-proofOfSender","id-smime-cti-ets-proofOfSender", NID_id_smime_cti_ets_proofOfSender,11,&(lvalues[1833]),0}, {"id-smime-cti-ets-proofOfApproval", "id-smime-cti-ets-proofOfApproval", NID_id_smime_cti_ets_proofOfApproval,11,&(lvalues[1844]),0}, {"id-smime-cti-ets-proofOfCreation", "id-smime-cti-ets-proofOfCreation", NID_id_smime_cti_ets_proofOfCreation,11,&(lvalues[1855]),0}, {"MD4","md4",NID_md4,8,&(lvalues[1866]),0}, {"id-pkix-mod","id-pkix-mod",NID_id_pkix_mod,7,&(lvalues[1874]),0}, {"id-qt","id-qt",NID_id_qt,7,&(lvalues[1881]),0}, {"id-it","id-it",NID_id_it,7,&(lvalues[1888]),0}, {"id-pkip","id-pkip",NID_id_pkip,7,&(lvalues[1895]),0}, {"id-alg","id-alg",NID_id_alg,7,&(lvalues[1902]),0}, {"id-cmc","id-cmc",NID_id_cmc,7,&(lvalues[1909]),0}, {"id-on","id-on",NID_id_on,7,&(lvalues[1916]),0}, {"id-pda","id-pda",NID_id_pda,7,&(lvalues[1923]),0}, {"id-aca","id-aca",NID_id_aca,7,&(lvalues[1930]),0}, {"id-qcs","id-qcs",NID_id_qcs,7,&(lvalues[1937]),0}, {"id-cct","id-cct",NID_id_cct,7,&(lvalues[1944]),0}, {"id-pkix1-explicit-88","id-pkix1-explicit-88", NID_id_pkix1_explicit_88,8,&(lvalues[1951]),0}, {"id-pkix1-implicit-88","id-pkix1-implicit-88", NID_id_pkix1_implicit_88,8,&(lvalues[1959]),0}, {"id-pkix1-explicit-93","id-pkix1-explicit-93", NID_id_pkix1_explicit_93,8,&(lvalues[1967]),0}, {"id-pkix1-implicit-93","id-pkix1-implicit-93", NID_id_pkix1_implicit_93,8,&(lvalues[1975]),0}, {"id-mod-crmf","id-mod-crmf",NID_id_mod_crmf,8,&(lvalues[1983]),0}, {"id-mod-cmc","id-mod-cmc",NID_id_mod_cmc,8,&(lvalues[1991]),0}, {"id-mod-kea-profile-88","id-mod-kea-profile-88", NID_id_mod_kea_profile_88,8,&(lvalues[1999]),0}, {"id-mod-kea-profile-93","id-mod-kea-profile-93", NID_id_mod_kea_profile_93,8,&(lvalues[2007]),0}, {"id-mod-cmp","id-mod-cmp",NID_id_mod_cmp,8,&(lvalues[2015]),0}, {"id-mod-qualified-cert-88","id-mod-qualified-cert-88", NID_id_mod_qualified_cert_88,8,&(lvalues[2023]),0}, {"id-mod-qualified-cert-93","id-mod-qualified-cert-93", NID_id_mod_qualified_cert_93,8,&(lvalues[2031]),0}, {"id-mod-attribute-cert","id-mod-attribute-cert", NID_id_mod_attribute_cert,8,&(lvalues[2039]),0}, {"id-mod-timestamp-protocol","id-mod-timestamp-protocol", NID_id_mod_timestamp_protocol,8,&(lvalues[2047]),0}, {"id-mod-ocsp","id-mod-ocsp",NID_id_mod_ocsp,8,&(lvalues[2055]),0}, {"id-mod-dvcs","id-mod-dvcs",NID_id_mod_dvcs,8,&(lvalues[2063]),0}, {"id-mod-cmp2000","id-mod-cmp2000",NID_id_mod_cmp2000,8, &(lvalues[2071]),0}, {"biometricInfo","Biometric Info",NID_biometricInfo,8,&(lvalues[2079]),0}, {"qcStatements","qcStatements",NID_qcStatements,8,&(lvalues[2087]),0}, {"ac-auditEntity","ac-auditEntity",NID_ac_auditEntity,8, &(lvalues[2095]),0}, {"ac-targeting","ac-targeting",NID_ac_targeting,8,&(lvalues[2103]),0}, {"aaControls","aaControls",NID_aaControls,8,&(lvalues[2111]),0}, {"sbgp-ipAddrBlock","sbgp-ipAddrBlock",NID_sbgp_ipAddrBlock,8, &(lvalues[2119]),0}, {"sbgp-autonomousSysNum","sbgp-autonomousSysNum", NID_sbgp_autonomousSysNum,8,&(lvalues[2127]),0}, {"sbgp-routerIdentifier","sbgp-routerIdentifier", NID_sbgp_routerIdentifier,8,&(lvalues[2135]),0}, {"textNotice","textNotice",NID_textNotice,8,&(lvalues[2143]),0}, {"ipsecEndSystem","IPSec End System",NID_ipsecEndSystem,8, &(lvalues[2151]),0}, {"ipsecTunnel","IPSec Tunnel",NID_ipsecTunnel,8,&(lvalues[2159]),0}, {"ipsecUser","IPSec User",NID_ipsecUser,8,&(lvalues[2167]),0}, {"DVCS","dvcs",NID_dvcs,8,&(lvalues[2175]),0}, {"id-it-caProtEncCert","id-it-caProtEncCert",NID_id_it_caProtEncCert, 8,&(lvalues[2183]),0}, {"id-it-signKeyPairTypes","id-it-signKeyPairTypes", NID_id_it_signKeyPairTypes,8,&(lvalues[2191]),0}, {"id-it-encKeyPairTypes","id-it-encKeyPairTypes", NID_id_it_encKeyPairTypes,8,&(lvalues[2199]),0}, {"id-it-preferredSymmAlg","id-it-preferredSymmAlg", NID_id_it_preferredSymmAlg,8,&(lvalues[2207]),0}, {"id-it-caKeyUpdateInfo","id-it-caKeyUpdateInfo", NID_id_it_caKeyUpdateInfo,8,&(lvalues[2215]),0}, {"id-it-currentCRL","id-it-currentCRL",NID_id_it_currentCRL,8, &(lvalues[2223]),0}, {"id-it-unsupportedOIDs","id-it-unsupportedOIDs", NID_id_it_unsupportedOIDs,8,&(lvalues[2231]),0}, {"id-it-subscriptionRequest","id-it-subscriptionRequest", NID_id_it_subscriptionRequest,8,&(lvalues[2239]),0}, {"id-it-subscriptionResponse","id-it-subscriptionResponse", NID_id_it_subscriptionResponse,8,&(lvalues[2247]),0}, {"id-it-keyPairParamReq","id-it-keyPairParamReq", NID_id_it_keyPairParamReq,8,&(lvalues[2255]),0}, {"id-it-keyPairParamRep","id-it-keyPairParamRep", NID_id_it_keyPairParamRep,8,&(lvalues[2263]),0}, {"id-it-revPassphrase","id-it-revPassphrase",NID_id_it_revPassphrase, 8,&(lvalues[2271]),0}, {"id-it-implicitConfirm","id-it-implicitConfirm", NID_id_it_implicitConfirm,8,&(lvalues[2279]),0}, {"id-it-confirmWaitTime","id-it-confirmWaitTime", NID_id_it_confirmWaitTime,8,&(lvalues[2287]),0}, {"id-it-origPKIMessage","id-it-origPKIMessage", NID_id_it_origPKIMessage,8,&(lvalues[2295]),0}, {"id-regCtrl","id-regCtrl",NID_id_regCtrl,8,&(lvalues[2303]),0}, {"id-regInfo","id-regInfo",NID_id_regInfo,8,&(lvalues[2311]),0}, {"id-regCtrl-regToken","id-regCtrl-regToken",NID_id_regCtrl_regToken, 9,&(lvalues[2319]),0}, {"id-regCtrl-authenticator","id-regCtrl-authenticator", NID_id_regCtrl_authenticator,9,&(lvalues[2328]),0}, {"id-regCtrl-pkiPublicationInfo","id-regCtrl-pkiPublicationInfo", NID_id_regCtrl_pkiPublicationInfo,9,&(lvalues[2337]),0}, {"id-regCtrl-pkiArchiveOptions","id-regCtrl-pkiArchiveOptions", NID_id_regCtrl_pkiArchiveOptions,9,&(lvalues[2346]),0}, {"id-regCtrl-oldCertID","id-regCtrl-oldCertID", NID_id_regCtrl_oldCertID,9,&(lvalues[2355]),0}, {"id-regCtrl-protocolEncrKey","id-regCtrl-protocolEncrKey", NID_id_regCtrl_protocolEncrKey,9,&(lvalues[2364]),0}, {"id-regInfo-utf8Pairs","id-regInfo-utf8Pairs", NID_id_regInfo_utf8Pairs,9,&(lvalues[2373]),0}, {"id-regInfo-certReq","id-regInfo-certReq",NID_id_regInfo_certReq,9, &(lvalues[2382]),0}, {"id-alg-des40","id-alg-des40",NID_id_alg_des40,8,&(lvalues[2391]),0}, {"id-alg-noSignature","id-alg-noSignature",NID_id_alg_noSignature,8, &(lvalues[2399]),0}, {"id-alg-dh-sig-hmac-sha1","id-alg-dh-sig-hmac-sha1", NID_id_alg_dh_sig_hmac_sha1,8,&(lvalues[2407]),0}, {"id-alg-dh-pop","id-alg-dh-pop",NID_id_alg_dh_pop,8,&(lvalues[2415]),0}, {"id-cmc-statusInfo","id-cmc-statusInfo",NID_id_cmc_statusInfo,8, &(lvalues[2423]),0}, {"id-cmc-identification","id-cmc-identification", NID_id_cmc_identification,8,&(lvalues[2431]),0}, {"id-cmc-identityProof","id-cmc-identityProof", NID_id_cmc_identityProof,8,&(lvalues[2439]),0}, {"id-cmc-dataReturn","id-cmc-dataReturn",NID_id_cmc_dataReturn,8, &(lvalues[2447]),0}, {"id-cmc-transactionId","id-cmc-transactionId", NID_id_cmc_transactionId,8,&(lvalues[2455]),0}, {"id-cmc-senderNonce","id-cmc-senderNonce",NID_id_cmc_senderNonce,8, &(lvalues[2463]),0}, {"id-cmc-recipientNonce","id-cmc-recipientNonce", NID_id_cmc_recipientNonce,8,&(lvalues[2471]),0}, {"id-cmc-addExtensions","id-cmc-addExtensions", NID_id_cmc_addExtensions,8,&(lvalues[2479]),0}, {"id-cmc-encryptedPOP","id-cmc-encryptedPOP",NID_id_cmc_encryptedPOP, 8,&(lvalues[2487]),0}, {"id-cmc-decryptedPOP","id-cmc-decryptedPOP",NID_id_cmc_decryptedPOP, 8,&(lvalues[2495]),0}, {"id-cmc-lraPOPWitness","id-cmc-lraPOPWitness", NID_id_cmc_lraPOPWitness,8,&(lvalues[2503]),0}, {"id-cmc-getCert","id-cmc-getCert",NID_id_cmc_getCert,8, &(lvalues[2511]),0}, {"id-cmc-getCRL","id-cmc-getCRL",NID_id_cmc_getCRL,8,&(lvalues[2519]),0}, {"id-cmc-revokeRequest","id-cmc-revokeRequest", NID_id_cmc_revokeRequest,8,&(lvalues[2527]),0}, {"id-cmc-regInfo","id-cmc-regInfo",NID_id_cmc_regInfo,8, &(lvalues[2535]),0}, {"id-cmc-responseInfo","id-cmc-responseInfo",NID_id_cmc_responseInfo, 8,&(lvalues[2543]),0}, {"id-cmc-queryPending","id-cmc-queryPending",NID_id_cmc_queryPending, 8,&(lvalues[2551]),0}, {"id-cmc-popLinkRandom","id-cmc-popLinkRandom", NID_id_cmc_popLinkRandom,8,&(lvalues[2559]),0}, {"id-cmc-popLinkWitness","id-cmc-popLinkWitness", NID_id_cmc_popLinkWitness,8,&(lvalues[2567]),0}, {"id-cmc-confirmCertAcceptance","id-cmc-confirmCertAcceptance", NID_id_cmc_confirmCertAcceptance,8,&(lvalues[2575]),0}, {"id-on-personalData","id-on-personalData",NID_id_on_personalData,8, &(lvalues[2583]),0}, {"id-pda-dateOfBirth","id-pda-dateOfBirth",NID_id_pda_dateOfBirth,8, &(lvalues[2591]),0}, {"id-pda-placeOfBirth","id-pda-placeOfBirth",NID_id_pda_placeOfBirth, 8,&(lvalues[2599]),0}, {NULL,NULL,NID_undef,0,NULL,0}, {"id-pda-gender","id-pda-gender",NID_id_pda_gender,8,&(lvalues[2607]),0}, {"id-pda-countryOfCitizenship","id-pda-countryOfCitizenship", NID_id_pda_countryOfCitizenship,8,&(lvalues[2615]),0}, {"id-pda-countryOfResidence","id-pda-countryOfResidence", NID_id_pda_countryOfResidence,8,&(lvalues[2623]),0}, {"id-aca-authenticationInfo","id-aca-authenticationInfo", NID_id_aca_authenticationInfo,8,&(lvalues[2631]),0}, {"id-aca-accessIdentity","id-aca-accessIdentity", NID_id_aca_accessIdentity,8,&(lvalues[2639]),0}, {"id-aca-chargingIdentity","id-aca-chargingIdentity", NID_id_aca_chargingIdentity,8,&(lvalues[2647]),0}, {"id-aca-group","id-aca-group",NID_id_aca_group,8,&(lvalues[2655]),0}, {"id-aca-role","id-aca-role",NID_id_aca_role,8,&(lvalues[2663]),0}, {"id-qcs-pkixQCSyntax-v1","id-qcs-pkixQCSyntax-v1", NID_id_qcs_pkixQCSyntax_v1,8,&(lvalues[2671]),0}, {"id-cct-crs","id-cct-crs",NID_id_cct_crs,8,&(lvalues[2679]),0}, {"id-cct-PKIData","id-cct-PKIData",NID_id_cct_PKIData,8, &(lvalues[2687]),0}, {"id-cct-PKIResponse","id-cct-PKIResponse",NID_id_cct_PKIResponse,8, &(lvalues[2695]),0}, {"ad_timestamping","AD Time Stamping",NID_ad_timeStamping,8, &(lvalues[2703]),0}, {"AD_DVCS","ad dvcs",NID_ad_dvcs,8,&(lvalues[2711]),0}, {"basicOCSPResponse","Basic OCSP Response",NID_id_pkix_OCSP_basic,9, &(lvalues[2719]),0}, {"Nonce","OCSP Nonce",NID_id_pkix_OCSP_Nonce,9,&(lvalues[2728]),0}, {"CrlID","OCSP CRL ID",NID_id_pkix_OCSP_CrlID,9,&(lvalues[2737]),0}, {"acceptableResponses","Acceptable OCSP Responses", NID_id_pkix_OCSP_acceptableResponses,9,&(lvalues[2746]),0}, {"noCheck","OCSP No Check",NID_id_pkix_OCSP_noCheck,9,&(lvalues[2755]),0}, {"archiveCutoff","OCSP Archive Cutoff",NID_id_pkix_OCSP_archiveCutoff, 9,&(lvalues[2764]),0}, {"serviceLocator","OCSP Service Locator", NID_id_pkix_OCSP_serviceLocator,9,&(lvalues[2773]),0}, {"extendedStatus","Extended OCSP Status", NID_id_pkix_OCSP_extendedStatus,9,&(lvalues[2782]),0}, {"valid","valid",NID_id_pkix_OCSP_valid,9,&(lvalues[2791]),0}, {"path","path",NID_id_pkix_OCSP_path,9,&(lvalues[2800]),0}, {"trustRoot","Trust Root",NID_id_pkix_OCSP_trustRoot,9, &(lvalues[2809]),0}, {"algorithm","algorithm",NID_algorithm,4,&(lvalues[2818]),0}, {"rsaSignature","rsaSignature",NID_rsaSignature,5,&(lvalues[2822]),0}, {"X500algorithms","directory services - algorithms", NID_X500algorithms,2,&(lvalues[2827]),0}, {"ORG","org",NID_org,1,&(lvalues[2829]),0}, {"DOD","dod",NID_dod,2,&(lvalues[2830]),0}, {"IANA","iana",NID_iana,3,&(lvalues[2832]),0}, {"directory","Directory",NID_Directory,4,&(lvalues[2835]),0}, {"mgmt","Management",NID_Management,4,&(lvalues[2839]),0}, {"experimental","Experimental",NID_Experimental,4,&(lvalues[2843]),0}, {"private","Private",NID_Private,4,&(lvalues[2847]),0}, {"security","Security",NID_Security,4,&(lvalues[2851]),0}, {"snmpv2","SNMPv2",NID_SNMPv2,4,&(lvalues[2855]),0}, {"Mail","Mail",NID_Mail,4,&(lvalues[2859]),0}, {"enterprises","Enterprises",NID_Enterprises,5,&(lvalues[2863]),0}, {"dcobject","dcObject",NID_dcObject,9,&(lvalues[2868]),0}, {"DC","domainComponent",NID_domainComponent,10,&(lvalues[2877]),0}, {"domain","Domain",NID_Domain,10,&(lvalues[2887]),0}, {"NULL","NULL",NID_joint_iso_ccitt,0,NULL,0}, {"selected-attribute-types","Selected Attribute Types", NID_selected_attribute_types,3,&(lvalues[2897]),0}, {"clearance","clearance",NID_clearance,4,&(lvalues[2900]),0}, {"RSA-MD4","md4WithRSAEncryption",NID_md4WithRSAEncryption,9, &(lvalues[2904]),0}, {"ac-proxying","ac-proxying",NID_ac_proxying,8,&(lvalues[2913]),0}, {"subjectInfoAccess","Subject Information Access",NID_sinfo_access,8, &(lvalues[2921]),0}, {"id-aca-encAttrs","id-aca-encAttrs",NID_id_aca_encAttrs,8, &(lvalues[2929]),0}, {"role","role",NID_role,3,&(lvalues[2937]),0}, {"policyConstraints","X509v3 Policy Constraints", NID_policy_constraints,3,&(lvalues[2940]),0}, {"targetInformation","X509v3 AC Targeting",NID_target_information,3, &(lvalues[2943]),0}, {"noRevAvail","X509v3 No Revocation Available",NID_no_rev_avail,3, &(lvalues[2946]),0}, {"NULL","NULL",NID_ccitt,0,NULL,0}, {"ansi-X9-62","ANSI X9.62",NID_ansi_X9_62,5,&(lvalues[2949]),0}, {"prime-field","prime-field",NID_X9_62_prime_field,7,&(lvalues[2954]),0}, {"characteristic-two-field","characteristic-two-field", NID_X9_62_characteristic_two_field,7,&(lvalues[2961]),0}, {"id-ecPublicKey","id-ecPublicKey",NID_X9_62_id_ecPublicKey,7, &(lvalues[2968]),0}, {"prime192v1","prime192v1",NID_X9_62_prime192v1,8,&(lvalues[2975]),0}, {"prime192v2","prime192v2",NID_X9_62_prime192v2,8,&(lvalues[2983]),0}, {"prime192v3","prime192v3",NID_X9_62_prime192v3,8,&(lvalues[2991]),0}, {"prime239v1","prime239v1",NID_X9_62_prime239v1,8,&(lvalues[2999]),0}, {"prime239v2","prime239v2",NID_X9_62_prime239v2,8,&(lvalues[3007]),0}, {"prime239v3","prime239v3",NID_X9_62_prime239v3,8,&(lvalues[3015]),0}, {"prime256v1","prime256v1",NID_X9_62_prime256v1,8,&(lvalues[3023]),0}, {"ecdsa-with-SHA1","ecdsa-with-SHA1",NID_ecdsa_with_SHA1,7, &(lvalues[3031]),0}, {"CSPName","Microsoft CSP Name",NID_ms_csp_name,9,&(lvalues[3038]),0}, {"AES-128-ECB","aes-128-ecb",NID_aes_128_ecb,9,&(lvalues[3047]),0}, {"AES-128-CBC","aes-128-cbc",NID_aes_128_cbc,9,&(lvalues[3056]),0}, {"AES-128-OFB","aes-128-ofb",NID_aes_128_ofb128,9,&(lvalues[3065]),0}, {"AES-128-CFB","aes-128-cfb",NID_aes_128_cfb128,9,&(lvalues[3074]),0}, {"AES-192-ECB","aes-192-ecb",NID_aes_192_ecb,9,&(lvalues[3083]),0}, {"AES-192-CBC","aes-192-cbc",NID_aes_192_cbc,9,&(lvalues[3092]),0}, {"AES-192-OFB","aes-192-ofb",NID_aes_192_ofb128,9,&(lvalues[3101]),0}, {"AES-192-CFB","aes-192-cfb",NID_aes_192_cfb128,9,&(lvalues[3110]),0}, {"AES-256-ECB","aes-256-ecb",NID_aes_256_ecb,9,&(lvalues[3119]),0}, {"AES-256-CBC","aes-256-cbc",NID_aes_256_cbc,9,&(lvalues[3128]),0}, {"AES-256-OFB","aes-256-ofb",NID_aes_256_ofb128,9,&(lvalues[3137]),0}, {"AES-256-CFB","aes-256-cfb",NID_aes_256_cfb128,9,&(lvalues[3146]),0}, {"holdInstructionCode","Hold Instruction Code", NID_hold_instruction_code,3,&(lvalues[3155]),0}, {"holdInstructionNone","Hold Instruction None", NID_hold_instruction_none,7,&(lvalues[3158]),0}, {"holdInstructionCallIssuer","Hold Instruction Call Issuer", NID_hold_instruction_call_issuer,7,&(lvalues[3165]),0}, {"holdInstructionReject","Hold Instruction Reject", NID_hold_instruction_reject,7,&(lvalues[3172]),0}, {"data","data",NID_data,1,&(lvalues[3179]),0}, {"pss","pss",NID_pss,3,&(lvalues[3180]),0}, {"ucl","ucl",NID_ucl,7,&(lvalues[3183]),0}, {"pilot","pilot",NID_pilot,8,&(lvalues[3190]),0}, {"pilotAttributeType","pilotAttributeType",NID_pilotAttributeType,9, &(lvalues[3198]),0}, {"pilotAttributeSyntax","pilotAttributeSyntax", NID_pilotAttributeSyntax,9,&(lvalues[3207]),0}, {"pilotObjectClass","pilotObjectClass",NID_pilotObjectClass,9, &(lvalues[3216]),0}, {"pilotGroups","pilotGroups",NID_pilotGroups,9,&(lvalues[3225]),0}, {"iA5StringSyntax","iA5StringSyntax",NID_iA5StringSyntax,10, &(lvalues[3234]),0}, {"caseIgnoreIA5StringSyntax","caseIgnoreIA5StringSyntax", NID_caseIgnoreIA5StringSyntax,10,&(lvalues[3244]),0}, {"pilotObject","pilotObject",NID_pilotObject,10,&(lvalues[3254]),0}, {"pilotPerson","pilotPerson",NID_pilotPerson,10,&(lvalues[3264]),0}, {"account","account",NID_account,10,&(lvalues[3274]),0}, {"document","document",NID_document,10,&(lvalues[3284]),0}, {"room","room",NID_room,10,&(lvalues[3294]),0}, {"documentSeries","documentSeries",NID_documentSeries,10, &(lvalues[3304]),0}, {"rFC822localPart","rFC822localPart",NID_rFC822localPart,10, &(lvalues[3314]),0}, {"dNSDomain","dNSDomain",NID_dNSDomain,10,&(lvalues[3324]),0}, {"domainRelatedObject","domainRelatedObject",NID_domainRelatedObject, 10,&(lvalues[3334]),0}, {"friendlyCountry","friendlyCountry",NID_friendlyCountry,10, &(lvalues[3344]),0}, {"simpleSecurityObject","simpleSecurityObject", NID_simpleSecurityObject,10,&(lvalues[3354]),0}, {"pilotOrganization","pilotOrganization",NID_pilotOrganization,10, &(lvalues[3364]),0}, {"pilotDSA","pilotDSA",NID_pilotDSA,10,&(lvalues[3374]),0}, {"qualityLabelledData","qualityLabelledData",NID_qualityLabelledData, 10,&(lvalues[3384]),0}, {"UID","userId",NID_userId,10,&(lvalues[3394]),0}, {"textEncodedORAddress","textEncodedORAddress", NID_textEncodedORAddress,10,&(lvalues[3404]),0}, {"mail","rfc822Mailbox",NID_rfc822Mailbox,10,&(lvalues[3414]),0}, {"info","info",NID_info,10,&(lvalues[3424]),0}, {"favouriteDrink","favouriteDrink",NID_favouriteDrink,10, &(lvalues[3434]),0}, {"roomNumber","roomNumber",NID_roomNumber,10,&(lvalues[3444]),0}, {"photo","photo",NID_photo,10,&(lvalues[3454]),0}, {"userClass","userClass",NID_userClass,10,&(lvalues[3464]),0}, {"host","host",NID_host,10,&(lvalues[3474]),0}, {"manager","manager",NID_manager,10,&(lvalues[3484]),0}, {"documentIdentifier","documentIdentifier",NID_documentIdentifier,10, &(lvalues[3494]),0}, {"documentTitle","documentTitle",NID_documentTitle,10,&(lvalues[3504]),0}, {"documentVersion","documentVersion",NID_documentVersion,10, &(lvalues[3514]),0}, {"documentAuthor","documentAuthor",NID_documentAuthor,10, &(lvalues[3524]),0}, {"documentLocation","documentLocation",NID_documentLocation,10, &(lvalues[3534]),0}, {"homeTelephoneNumber","homeTelephoneNumber",NID_homeTelephoneNumber, 10,&(lvalues[3544]),0}, {"secretary","secretary",NID_secretary,10,&(lvalues[3554]),0}, {"otherMailbox","otherMailbox",NID_otherMailbox,10,&(lvalues[3564]),0}, {"lastModifiedTime","lastModifiedTime",NID_lastModifiedTime,10, &(lvalues[3574]),0}, {"lastModifiedBy","lastModifiedBy",NID_lastModifiedBy,10, &(lvalues[3584]),0}, {"aRecord","aRecord",NID_aRecord,10,&(lvalues[3594]),0}, {"pilotAttributeType27","pilotAttributeType27", NID_pilotAttributeType27,10,&(lvalues[3604]),0}, {"mXRecord","mXRecord",NID_mXRecord,10,&(lvalues[3614]),0}, {"nSRecord","nSRecord",NID_nSRecord,10,&(lvalues[3624]),0}, {"sOARecord","sOARecord",NID_sOARecord,10,&(lvalues[3634]),0}, {"cNAMERecord","cNAMERecord",NID_cNAMERecord,10,&(lvalues[3644]),0}, {"associatedDomain","associatedDomain",NID_associatedDomain,10, &(lvalues[3654]),0}, {"associatedName","associatedName",NID_associatedName,10, &(lvalues[3664]),0}, {"homePostalAddress","homePostalAddress",NID_homePostalAddress,10, &(lvalues[3674]),0}, {"personalTitle","personalTitle",NID_personalTitle,10,&(lvalues[3684]),0}, {"mobileTelephoneNumber","mobileTelephoneNumber", NID_mobileTelephoneNumber,10,&(lvalues[3694]),0}, {"pagerTelephoneNumber","pagerTelephoneNumber", NID_pagerTelephoneNumber,10,&(lvalues[3704]),0}, {"friendlyCountryName","friendlyCountryName",NID_friendlyCountryName, 10,&(lvalues[3714]),0}, {"organizationalStatus","organizationalStatus", NID_organizationalStatus,10,&(lvalues[3724]),0}, {"janetMailbox","janetMailbox",NID_janetMailbox,10,&(lvalues[3734]),0}, {"mailPreferenceOption","mailPreferenceOption", NID_mailPreferenceOption,10,&(lvalues[3744]),0}, {"buildingName","buildingName",NID_buildingName,10,&(lvalues[3754]),0}, {"dSAQuality","dSAQuality",NID_dSAQuality,10,&(lvalues[3764]),0}, {"singleLevelQuality","singleLevelQuality",NID_singleLevelQuality,10, &(lvalues[3774]),0}, {"subtreeMinimumQuality","subtreeMinimumQuality", NID_subtreeMinimumQuality,10,&(lvalues[3784]),0}, {"subtreeMaximumQuality","subtreeMaximumQuality", NID_subtreeMaximumQuality,10,&(lvalues[3794]),0}, {"personalSignature","personalSignature",NID_personalSignature,10, &(lvalues[3804]),0}, {"dITRedirect","dITRedirect",NID_dITRedirect,10,&(lvalues[3814]),0}, {"audio","audio",NID_audio,10,&(lvalues[3824]),0}, {"documentPublisher","documentPublisher",NID_documentPublisher,10, &(lvalues[3834]),0}, {"x500UniqueIdentifier","x500UniqueIdentifier", NID_x500UniqueIdentifier,3,&(lvalues[3844]),0}, {"mime-mhs","MIME MHS",NID_mime_mhs,5,&(lvalues[3847]),0}, {"mime-mhs-headings","mime-mhs-headings",NID_mime_mhs_headings,6, &(lvalues[3852]),0}, {"mime-mhs-bodies","mime-mhs-bodies",NID_mime_mhs_bodies,6, &(lvalues[3858]),0}, {"id-hex-partial-message","id-hex-partial-message", NID_id_hex_partial_message,7,&(lvalues[3864]),0}, {"id-hex-multipart-message","id-hex-multipart-message", NID_id_hex_multipart_message,7,&(lvalues[3871]),0}, {"generationQualifier","generationQualifier",NID_generationQualifier, 3,&(lvalues[3878]),0}, {"pseudonym","pseudonym",NID_pseudonym,3,&(lvalues[3881]),0}, {NULL,NULL,NID_undef,0,NULL,0}, {"id-set","Secure Electronic Transactions",NID_id_set,2, &(lvalues[3884]),0}, {"set-ctype","content types",NID_set_ctype,3,&(lvalues[3886]),0}, {"set-msgExt","message extensions",NID_set_msgExt,3,&(lvalues[3889]),0}, {"set-attr","set-attr",NID_set_attr,3,&(lvalues[3892]),0}, {"set-policy","set-policy",NID_set_policy,3,&(lvalues[3895]),0}, {"set-certExt","certificate extensions",NID_set_certExt,3, &(lvalues[3898]),0}, {"set-brand","set-brand",NID_set_brand,3,&(lvalues[3901]),0}, {"setct-PANData","setct-PANData",NID_setct_PANData,4,&(lvalues[3904]),0}, {"setct-PANToken","setct-PANToken",NID_setct_PANToken,4, &(lvalues[3908]),0}, {"setct-PANOnly","setct-PANOnly",NID_setct_PANOnly,4,&(lvalues[3912]),0}, {"setct-OIData","setct-OIData",NID_setct_OIData,4,&(lvalues[3916]),0}, {"setct-PI","setct-PI",NID_setct_PI,4,&(lvalues[3920]),0}, {"setct-PIData","setct-PIData",NID_setct_PIData,4,&(lvalues[3924]),0}, {"setct-PIDataUnsigned","setct-PIDataUnsigned", NID_setct_PIDataUnsigned,4,&(lvalues[3928]),0}, {"setct-HODInput","setct-HODInput",NID_setct_HODInput,4, &(lvalues[3932]),0}, {"setct-AuthResBaggage","setct-AuthResBaggage", NID_setct_AuthResBaggage,4,&(lvalues[3936]),0}, {"setct-AuthRevReqBaggage","setct-AuthRevReqBaggage", NID_setct_AuthRevReqBaggage,4,&(lvalues[3940]),0}, {"setct-AuthRevResBaggage","setct-AuthRevResBaggage", NID_setct_AuthRevResBaggage,4,&(lvalues[3944]),0}, {"setct-CapTokenSeq","setct-CapTokenSeq",NID_setct_CapTokenSeq,4, &(lvalues[3948]),0}, {"setct-PInitResData","setct-PInitResData",NID_setct_PInitResData,4, &(lvalues[3952]),0}, {"setct-PI-TBS","setct-PI-TBS",NID_setct_PI_TBS,4,&(lvalues[3956]),0}, {"setct-PResData","setct-PResData",NID_setct_PResData,4, &(lvalues[3960]),0}, {"setct-AuthReqTBS","setct-AuthReqTBS",NID_setct_AuthReqTBS,4, &(lvalues[3964]),0}, {"setct-AuthResTBS","setct-AuthResTBS",NID_setct_AuthResTBS,4, &(lvalues[3968]),0}, {"setct-AuthResTBSX","setct-AuthResTBSX",NID_setct_AuthResTBSX,4, &(lvalues[3972]),0}, {"setct-AuthTokenTBS","setct-AuthTokenTBS",NID_setct_AuthTokenTBS,4, &(lvalues[3976]),0}, {"setct-CapTokenData","setct-CapTokenData",NID_setct_CapTokenData,4, &(lvalues[3980]),0}, {"setct-CapTokenTBS","setct-CapTokenTBS",NID_setct_CapTokenTBS,4, &(lvalues[3984]),0}, {"setct-AcqCardCodeMsg","setct-AcqCardCodeMsg", NID_setct_AcqCardCodeMsg,4,&(lvalues[3988]),0}, {"setct-AuthRevReqTBS","setct-AuthRevReqTBS",NID_setct_AuthRevReqTBS, 4,&(lvalues[3992]),0}, {"setct-AuthRevResData","setct-AuthRevResData", NID_setct_AuthRevResData,4,&(lvalues[3996]),0}, {"setct-AuthRevResTBS","setct-AuthRevResTBS",NID_setct_AuthRevResTBS, 4,&(lvalues[4000]),0}, {"setct-CapReqTBS","setct-CapReqTBS",NID_setct_CapReqTBS,4, &(lvalues[4004]),0}, {"setct-CapReqTBSX","setct-CapReqTBSX",NID_setct_CapReqTBSX,4, &(lvalues[4008]),0}, {"setct-CapResData","setct-CapResData",NID_setct_CapResData,4, &(lvalues[4012]),0}, {"setct-CapRevReqTBS","setct-CapRevReqTBS",NID_setct_CapRevReqTBS,4, &(lvalues[4016]),0}, {"setct-CapRevReqTBSX","setct-CapRevReqTBSX",NID_setct_CapRevReqTBSX, 4,&(lvalues[4020]),0}, {"setct-CapRevResData","setct-CapRevResData",NID_setct_CapRevResData, 4,&(lvalues[4024]),0}, {"setct-CredReqTBS","setct-CredReqTBS",NID_setct_CredReqTBS,4, &(lvalues[4028]),0}, {"setct-CredReqTBSX","setct-CredReqTBSX",NID_setct_CredReqTBSX,4, &(lvalues[4032]),0}, {"setct-CredResData","setct-CredResData",NID_setct_CredResData,4, &(lvalues[4036]),0}, {"setct-CredRevReqTBS","setct-CredRevReqTBS",NID_setct_CredRevReqTBS, 4,&(lvalues[4040]),0}, {"setct-CredRevReqTBSX","setct-CredRevReqTBSX", NID_setct_CredRevReqTBSX,4,&(lvalues[4044]),0}, {"setct-CredRevResData","setct-CredRevResData", NID_setct_CredRevResData,4,&(lvalues[4048]),0}, {"setct-PCertReqData","setct-PCertReqData",NID_setct_PCertReqData,4, &(lvalues[4052]),0}, {"setct-PCertResTBS","setct-PCertResTBS",NID_setct_PCertResTBS,4, &(lvalues[4056]),0}, {"setct-BatchAdminReqData","setct-BatchAdminReqData", NID_setct_BatchAdminReqData,4,&(lvalues[4060]),0}, {"setct-BatchAdminResData","setct-BatchAdminResData", NID_setct_BatchAdminResData,4,&(lvalues[4064]),0}, {"setct-CardCInitResTBS","setct-CardCInitResTBS", NID_setct_CardCInitResTBS,4,&(lvalues[4068]),0}, {"setct-MeAqCInitResTBS","setct-MeAqCInitResTBS", NID_setct_MeAqCInitResTBS,4,&(lvalues[4072]),0}, {"setct-RegFormResTBS","setct-RegFormResTBS",NID_setct_RegFormResTBS, 4,&(lvalues[4076]),0}, {"setct-CertReqData","setct-CertReqData",NID_setct_CertReqData,4, &(lvalues[4080]),0}, {"setct-CertReqTBS","setct-CertReqTBS",NID_setct_CertReqTBS,4, &(lvalues[4084]),0}, {"setct-CertResData","setct-CertResData",NID_setct_CertResData,4, &(lvalues[4088]),0}, {"setct-CertInqReqTBS","setct-CertInqReqTBS",NID_setct_CertInqReqTBS, 4,&(lvalues[4092]),0}, {"setct-ErrorTBS","setct-ErrorTBS",NID_setct_ErrorTBS,4, &(lvalues[4096]),0}, {"setct-PIDualSignedTBE","setct-PIDualSignedTBE", NID_setct_PIDualSignedTBE,4,&(lvalues[4100]),0}, {"setct-PIUnsignedTBE","setct-PIUnsignedTBE",NID_setct_PIUnsignedTBE, 4,&(lvalues[4104]),0}, {"setct-AuthReqTBE","setct-AuthReqTBE",NID_setct_AuthReqTBE,4, &(lvalues[4108]),0}, {"setct-AuthResTBE","setct-AuthResTBE",NID_setct_AuthResTBE,4, &(lvalues[4112]),0}, {"setct-AuthResTBEX","setct-AuthResTBEX",NID_setct_AuthResTBEX,4, &(lvalues[4116]),0}, {"setct-AuthTokenTBE","setct-AuthTokenTBE",NID_setct_AuthTokenTBE,4, &(lvalues[4120]),0}, {"setct-CapTokenTBE","setct-CapTokenTBE",NID_setct_CapTokenTBE,4, &(lvalues[4124]),0}, {"setct-CapTokenTBEX","setct-CapTokenTBEX",NID_setct_CapTokenTBEX,4, &(lvalues[4128]),0}, {"setct-AcqCardCodeMsgTBE","setct-AcqCardCodeMsgTBE", NID_setct_AcqCardCodeMsgTBE,4,&(lvalues[4132]),0}, {"setct-AuthRevReqTBE","setct-AuthRevReqTBE",NID_setct_AuthRevReqTBE, 4,&(lvalues[4136]),0}, {"setct-AuthRevResTBE","setct-AuthRevResTBE",NID_setct_AuthRevResTBE, 4,&(lvalues[4140]),0}, {"setct-AuthRevResTBEB","setct-AuthRevResTBEB", NID_setct_AuthRevResTBEB,4,&(lvalues[4144]),0}, {"setct-CapReqTBE","setct-CapReqTBE",NID_setct_CapReqTBE,4, &(lvalues[4148]),0}, {"setct-CapReqTBEX","setct-CapReqTBEX",NID_setct_CapReqTBEX,4, &(lvalues[4152]),0}, {"setct-CapResTBE","setct-CapResTBE",NID_setct_CapResTBE,4, &(lvalues[4156]),0}, {"setct-CapRevReqTBE","setct-CapRevReqTBE",NID_setct_CapRevReqTBE,4, &(lvalues[4160]),0}, {"setct-CapRevReqTBEX","setct-CapRevReqTBEX",NID_setct_CapRevReqTBEX, 4,&(lvalues[4164]),0}, {"setct-CapRevResTBE","setct-CapRevResTBE",NID_setct_CapRevResTBE,4, &(lvalues[4168]),0}, {"setct-CredReqTBE","setct-CredReqTBE",NID_setct_CredReqTBE,4, &(lvalues[4172]),0}, {"setct-CredReqTBEX","setct-CredReqTBEX",NID_setct_CredReqTBEX,4, &(lvalues[4176]),0}, {"setct-CredResTBE","setct-CredResTBE",NID_setct_CredResTBE,4, &(lvalues[4180]),0}, {"setct-CredRevReqTBE","setct-CredRevReqTBE",NID_setct_CredRevReqTBE, 4,&(lvalues[4184]),0}, {"setct-CredRevReqTBEX","setct-CredRevReqTBEX", NID_setct_CredRevReqTBEX,4,&(lvalues[4188]),0}, {"setct-CredRevResTBE","setct-CredRevResTBE",NID_setct_CredRevResTBE, 4,&(lvalues[4192]),0}, {"setct-BatchAdminReqTBE","setct-BatchAdminReqTBE", NID_setct_BatchAdminReqTBE,4,&(lvalues[4196]),0}, {"setct-BatchAdminResTBE","setct-BatchAdminResTBE", NID_setct_BatchAdminResTBE,4,&(lvalues[4200]),0}, {"setct-RegFormReqTBE","setct-RegFormReqTBE",NID_setct_RegFormReqTBE, 4,&(lvalues[4204]),0}, {"setct-CertReqTBE","setct-CertReqTBE",NID_setct_CertReqTBE,4, &(lvalues[4208]),0}, {"setct-CertReqTBEX","setct-CertReqTBEX",NID_setct_CertReqTBEX,4, &(lvalues[4212]),0}, {"setct-CertResTBE","setct-CertResTBE",NID_setct_CertResTBE,4, &(lvalues[4216]),0}, {"setct-CRLNotificationTBS","setct-CRLNotificationTBS", NID_setct_CRLNotificationTBS,4,&(lvalues[4220]),0}, {"setct-CRLNotificationResTBS","setct-CRLNotificationResTBS", NID_setct_CRLNotificationResTBS,4,&(lvalues[4224]),0}, {"setct-BCIDistributionTBS","setct-BCIDistributionTBS", NID_setct_BCIDistributionTBS,4,&(lvalues[4228]),0}, {"setext-genCrypt","generic cryptogram",NID_setext_genCrypt,4, &(lvalues[4232]),0}, {"setext-miAuth","merchant initiated auth",NID_setext_miAuth,4, &(lvalues[4236]),0}, {"setext-pinSecure","setext-pinSecure",NID_setext_pinSecure,4, &(lvalues[4240]),0}, {"setext-pinAny","setext-pinAny",NID_setext_pinAny,4,&(lvalues[4244]),0}, {"setext-track2","setext-track2",NID_setext_track2,4,&(lvalues[4248]),0}, {"setext-cv","additional verification",NID_setext_cv,4, &(lvalues[4252]),0}, {"set-policy-root","set-policy-root",NID_set_policy_root,4, &(lvalues[4256]),0}, {"setCext-hashedRoot","setCext-hashedRoot",NID_setCext_hashedRoot,4, &(lvalues[4260]),0}, {"setCext-certType","setCext-certType",NID_setCext_certType,4, &(lvalues[4264]),0}, {"setCext-merchData","setCext-merchData",NID_setCext_merchData,4, &(lvalues[4268]),0}, {"setCext-cCertRequired","setCext-cCertRequired", NID_setCext_cCertRequired,4,&(lvalues[4272]),0}, {"setCext-tunneling","setCext-tunneling",NID_setCext_tunneling,4, &(lvalues[4276]),0}, {"setCext-setExt","setCext-setExt",NID_setCext_setExt,4, &(lvalues[4280]),0}, {"setCext-setQualf","setCext-setQualf",NID_setCext_setQualf,4, &(lvalues[4284]),0}, {"setCext-PGWYcapabilities","setCext-PGWYcapabilities", NID_setCext_PGWYcapabilities,4,&(lvalues[4288]),0}, {"setCext-TokenIdentifier","setCext-TokenIdentifier", NID_setCext_TokenIdentifier,4,&(lvalues[4292]),0}, {"setCext-Track2Data","setCext-Track2Data",NID_setCext_Track2Data,4, &(lvalues[4296]),0}, {"setCext-TokenType","setCext-TokenType",NID_setCext_TokenType,4, &(lvalues[4300]),0}, {"setCext-IssuerCapabilities","setCext-IssuerCapabilities", NID_setCext_IssuerCapabilities,4,&(lvalues[4304]),0}, {"setAttr-Cert","setAttr-Cert",NID_setAttr_Cert,4,&(lvalues[4308]),0}, {"setAttr-PGWYcap","payment gateway capabilities",NID_setAttr_PGWYcap, 4,&(lvalues[4312]),0}, {"setAttr-TokenType","setAttr-TokenType",NID_setAttr_TokenType,4, &(lvalues[4316]),0}, {"setAttr-IssCap","issuer capabilities",NID_setAttr_IssCap,4, &(lvalues[4320]),0}, {"set-rootKeyThumb","set-rootKeyThumb",NID_set_rootKeyThumb,5, &(lvalues[4324]),0}, {"set-addPolicy","set-addPolicy",NID_set_addPolicy,5,&(lvalues[4329]),0}, {"setAttr-Token-EMV","setAttr-Token-EMV",NID_setAttr_Token_EMV,5, &(lvalues[4334]),0}, {"setAttr-Token-B0Prime","setAttr-Token-B0Prime", NID_setAttr_Token_B0Prime,5,&(lvalues[4339]),0}, {"setAttr-IssCap-CVM","setAttr-IssCap-CVM",NID_setAttr_IssCap_CVM,5, &(lvalues[4344]),0}, {"setAttr-IssCap-T2","setAttr-IssCap-T2",NID_setAttr_IssCap_T2,5, &(lvalues[4349]),0}, {"setAttr-IssCap-Sig","setAttr-IssCap-Sig",NID_setAttr_IssCap_Sig,5, &(lvalues[4354]),0}, {"setAttr-GenCryptgrm","generate cryptogram",NID_setAttr_GenCryptgrm, 6,&(lvalues[4359]),0}, {"setAttr-T2Enc","encrypted track 2",NID_setAttr_T2Enc,6, &(lvalues[4365]),0}, {"setAttr-T2cleartxt","cleartext track 2",NID_setAttr_T2cleartxt,6, &(lvalues[4371]),0}, {"setAttr-TokICCsig","ICC or token signature",NID_setAttr_TokICCsig,6, &(lvalues[4377]),0}, {"setAttr-SecDevSig","secure device signature",NID_setAttr_SecDevSig, 6,&(lvalues[4383]),0}, {"set-brand-IATA-ATA","set-brand-IATA-ATA",NID_set_brand_IATA_ATA,4, &(lvalues[4389]),0}, {"set-brand-Diners","set-brand-Diners",NID_set_brand_Diners,4, &(lvalues[4393]),0}, {"set-brand-AmericanExpress","set-brand-AmericanExpress", NID_set_brand_AmericanExpress,4,&(lvalues[4397]),0}, {"set-brand-JCB","set-brand-JCB",NID_set_brand_JCB,4,&(lvalues[4401]),0}, {"set-brand-Visa","set-brand-Visa",NID_set_brand_Visa,4, &(lvalues[4405]),0}, {"set-brand-MasterCard","set-brand-MasterCard", NID_set_brand_MasterCard,4,&(lvalues[4409]),0}, {"set-brand-Novus","set-brand-Novus",NID_set_brand_Novus,5, &(lvalues[4413]),0}, {"DES-CDMF","des-cdmf",NID_des_cdmf,8,&(lvalues[4418]),0}, {"rsaOAEPEncryptionSET","rsaOAEPEncryptionSET", NID_rsaOAEPEncryptionSET,9,&(lvalues[4426]),0}, {"ITU-T","itu-t",NID_itu_t,0,NULL,0}, {"JOINT-ISO-ITU-T","joint-iso-itu-t",NID_joint_iso_itu_t,0,NULL,0}, {"international-organizations","International Organizations", NID_international_organizations,1,&(lvalues[4435]),0}, {"msSmartcardLogin","Microsoft Smartcardlogin",NID_ms_smartcard_login, 10,&(lvalues[4436]),0}, {"msUPN","Microsoft Universal Principal Name",NID_ms_upn,10, &(lvalues[4446]),0}, {"AES-128-CFB1","aes-128-cfb1",NID_aes_128_cfb1,0,NULL,0}, {"AES-192-CFB1","aes-192-cfb1",NID_aes_192_cfb1,0,NULL,0}, {"AES-256-CFB1","aes-256-cfb1",NID_aes_256_cfb1,0,NULL,0}, {"AES-128-CFB8","aes-128-cfb8",NID_aes_128_cfb8,0,NULL,0}, {"AES-192-CFB8","aes-192-cfb8",NID_aes_192_cfb8,0,NULL,0}, {"AES-256-CFB8","aes-256-cfb8",NID_aes_256_cfb8,0,NULL,0}, {"DES-CFB1","des-cfb1",NID_des_cfb1,0,NULL,0}, {"DES-CFB8","des-cfb8",NID_des_cfb8,0,NULL,0}, {"DES-EDE3-CFB1","des-ede3-cfb1",NID_des_ede3_cfb1,0,NULL,0}, {"DES-EDE3-CFB8","des-ede3-cfb8",NID_des_ede3_cfb8,0,NULL,0}, {"street","streetAddress",NID_streetAddress,3,&(lvalues[4456]),0}, {"postalCode","postalCode",NID_postalCode,3,&(lvalues[4459]),0}, {"id-ppl","id-ppl",NID_id_ppl,7,&(lvalues[4462]),0}, {"proxyCertInfo","Proxy Certificate Information",NID_proxyCertInfo,8, &(lvalues[4469]),0}, {"id-ppl-anyLanguage","Any language",NID_id_ppl_anyLanguage,8, &(lvalues[4477]),0}, {"id-ppl-inheritAll","Inherit all",NID_id_ppl_inheritAll,8, &(lvalues[4485]),0}, {"nameConstraints","X509v3 Name Constraints",NID_name_constraints,3, &(lvalues[4493]),0}, {"id-ppl-independent","Independent",NID_Independent,8,&(lvalues[4496]),0}, {"RSA-SHA256","sha256WithRSAEncryption",NID_sha256WithRSAEncryption,9, &(lvalues[4504]),0}, {"RSA-SHA384","sha384WithRSAEncryption",NID_sha384WithRSAEncryption,9, &(lvalues[4513]),0}, {"RSA-SHA512","sha512WithRSAEncryption",NID_sha512WithRSAEncryption,9, &(lvalues[4522]),0}, {"RSA-SHA224","sha224WithRSAEncryption",NID_sha224WithRSAEncryption,9, &(lvalues[4531]),0}, {"SHA256","sha256",NID_sha256,9,&(lvalues[4540]),0}, {"SHA384","sha384",NID_sha384,9,&(lvalues[4549]),0}, {"SHA512","sha512",NID_sha512,9,&(lvalues[4558]),0}, {"SHA224","sha224",NID_sha224,9,&(lvalues[4567]),0}, {"identified-organization","identified-organization", NID_identified_organization,1,&(lvalues[4576]),0}, {"certicom-arc","certicom-arc",NID_certicom_arc,3,&(lvalues[4577]),0}, {"wap","wap",NID_wap,2,&(lvalues[4580]),0}, {"wap-wsg","wap-wsg",NID_wap_wsg,3,&(lvalues[4582]),0}, {"id-characteristic-two-basis","id-characteristic-two-basis", NID_X9_62_id_characteristic_two_basis,8,&(lvalues[4585]),0}, {"onBasis","onBasis",NID_X9_62_onBasis,9,&(lvalues[4593]),0}, {"tpBasis","tpBasis",NID_X9_62_tpBasis,9,&(lvalues[4602]),0}, {"ppBasis","ppBasis",NID_X9_62_ppBasis,9,&(lvalues[4611]),0}, {"c2pnb163v1","c2pnb163v1",NID_X9_62_c2pnb163v1,8,&(lvalues[4620]),0}, {"c2pnb163v2","c2pnb163v2",NID_X9_62_c2pnb163v2,8,&(lvalues[4628]),0}, {"c2pnb163v3","c2pnb163v3",NID_X9_62_c2pnb163v3,8,&(lvalues[4636]),0}, {"c2pnb176v1","c2pnb176v1",NID_X9_62_c2pnb176v1,8,&(lvalues[4644]),0}, {"c2tnb191v1","c2tnb191v1",NID_X9_62_c2tnb191v1,8,&(lvalues[4652]),0}, {"c2tnb191v2","c2tnb191v2",NID_X9_62_c2tnb191v2,8,&(lvalues[4660]),0}, {"c2tnb191v3","c2tnb191v3",NID_X9_62_c2tnb191v3,8,&(lvalues[4668]),0}, {"c2onb191v4","c2onb191v4",NID_X9_62_c2onb191v4,8,&(lvalues[4676]),0}, {"c2onb191v5","c2onb191v5",NID_X9_62_c2onb191v5,8,&(lvalues[4684]),0}, {"c2pnb208w1","c2pnb208w1",NID_X9_62_c2pnb208w1,8,&(lvalues[4692]),0}, {"c2tnb239v1","c2tnb239v1",NID_X9_62_c2tnb239v1,8,&(lvalues[4700]),0}, {"c2tnb239v2","c2tnb239v2",NID_X9_62_c2tnb239v2,8,&(lvalues[4708]),0}, {"c2tnb239v3","c2tnb239v3",NID_X9_62_c2tnb239v3,8,&(lvalues[4716]),0}, {"c2onb239v4","c2onb239v4",NID_X9_62_c2onb239v4,8,&(lvalues[4724]),0}, {"c2onb239v5","c2onb239v5",NID_X9_62_c2onb239v5,8,&(lvalues[4732]),0}, {"c2pnb272w1","c2pnb272w1",NID_X9_62_c2pnb272w1,8,&(lvalues[4740]),0}, {"c2pnb304w1","c2pnb304w1",NID_X9_62_c2pnb304w1,8,&(lvalues[4748]),0}, {"c2tnb359v1","c2tnb359v1",NID_X9_62_c2tnb359v1,8,&(lvalues[4756]),0}, {"c2pnb368w1","c2pnb368w1",NID_X9_62_c2pnb368w1,8,&(lvalues[4764]),0}, {"c2tnb431r1","c2tnb431r1",NID_X9_62_c2tnb431r1,8,&(lvalues[4772]),0}, {"secp112r1","secp112r1",NID_secp112r1,5,&(lvalues[4780]),0}, {"secp112r2","secp112r2",NID_secp112r2,5,&(lvalues[4785]),0}, {"secp128r1","secp128r1",NID_secp128r1,5,&(lvalues[4790]),0}, {"secp128r2","secp128r2",NID_secp128r2,5,&(lvalues[4795]),0}, {"secp160k1","secp160k1",NID_secp160k1,5,&(lvalues[4800]),0}, {"secp160r1","secp160r1",NID_secp160r1,5,&(lvalues[4805]),0}, {"secp160r2","secp160r2",NID_secp160r2,5,&(lvalues[4810]),0}, {"secp192k1","secp192k1",NID_secp192k1,5,&(lvalues[4815]),0}, {"secp224k1","secp224k1",NID_secp224k1,5,&(lvalues[4820]),0}, {"secp224r1","secp224r1",NID_secp224r1,5,&(lvalues[4825]),0}, {"secp256k1","secp256k1",NID_secp256k1,5,&(lvalues[4830]),0}, {"secp384r1","secp384r1",NID_secp384r1,5,&(lvalues[4835]),0}, {"secp521r1","secp521r1",NID_secp521r1,5,&(lvalues[4840]),0}, {"sect113r1","sect113r1",NID_sect113r1,5,&(lvalues[4845]),0}, {"sect113r2","sect113r2",NID_sect113r2,5,&(lvalues[4850]),0}, {"sect131r1","sect131r1",NID_sect131r1,5,&(lvalues[4855]),0}, {"sect131r2","sect131r2",NID_sect131r2,5,&(lvalues[4860]),0}, {"sect163k1","sect163k1",NID_sect163k1,5,&(lvalues[4865]),0}, {"sect163r1","sect163r1",NID_sect163r1,5,&(lvalues[4870]),0}, {"sect163r2","sect163r2",NID_sect163r2,5,&(lvalues[4875]),0}, {"sect193r1","sect193r1",NID_sect193r1,5,&(lvalues[4880]),0}, {"sect193r2","sect193r2",NID_sect193r2,5,&(lvalues[4885]),0}, {"sect233k1","sect233k1",NID_sect233k1,5,&(lvalues[4890]),0}, {"sect233r1","sect233r1",NID_sect233r1,5,&(lvalues[4895]),0}, {"sect239k1","sect239k1",NID_sect239k1,5,&(lvalues[4900]),0}, {"sect283k1","sect283k1",NID_sect283k1,5,&(lvalues[4905]),0}, {"sect283r1","sect283r1",NID_sect283r1,5,&(lvalues[4910]),0}, {"sect409k1","sect409k1",NID_sect409k1,5,&(lvalues[4915]),0}, {"sect409r1","sect409r1",NID_sect409r1,5,&(lvalues[4920]),0}, {"sect571k1","sect571k1",NID_sect571k1,5,&(lvalues[4925]),0}, {"sect571r1","sect571r1",NID_sect571r1,5,&(lvalues[4930]),0}, {"wap-wsg-idm-ecid-wtls1","wap-wsg-idm-ecid-wtls1", NID_wap_wsg_idm_ecid_wtls1,5,&(lvalues[4935]),0}, {"wap-wsg-idm-ecid-wtls3","wap-wsg-idm-ecid-wtls3", NID_wap_wsg_idm_ecid_wtls3,5,&(lvalues[4940]),0}, {"wap-wsg-idm-ecid-wtls4","wap-wsg-idm-ecid-wtls4", NID_wap_wsg_idm_ecid_wtls4,5,&(lvalues[4945]),0}, {"wap-wsg-idm-ecid-wtls5","wap-wsg-idm-ecid-wtls5", NID_wap_wsg_idm_ecid_wtls5,5,&(lvalues[4950]),0}, {"wap-wsg-idm-ecid-wtls6","wap-wsg-idm-ecid-wtls6", NID_wap_wsg_idm_ecid_wtls6,5,&(lvalues[4955]),0}, {"wap-wsg-idm-ecid-wtls7","wap-wsg-idm-ecid-wtls7", NID_wap_wsg_idm_ecid_wtls7,5,&(lvalues[4960]),0}, {"wap-wsg-idm-ecid-wtls8","wap-wsg-idm-ecid-wtls8", NID_wap_wsg_idm_ecid_wtls8,5,&(lvalues[4965]),0}, {"wap-wsg-idm-ecid-wtls9","wap-wsg-idm-ecid-wtls9", NID_wap_wsg_idm_ecid_wtls9,5,&(lvalues[4970]),0}, {"wap-wsg-idm-ecid-wtls10","wap-wsg-idm-ecid-wtls10", NID_wap_wsg_idm_ecid_wtls10,5,&(lvalues[4975]),0}, {"wap-wsg-idm-ecid-wtls11","wap-wsg-idm-ecid-wtls11", NID_wap_wsg_idm_ecid_wtls11,5,&(lvalues[4980]),0}, {"wap-wsg-idm-ecid-wtls12","wap-wsg-idm-ecid-wtls12", NID_wap_wsg_idm_ecid_wtls12,5,&(lvalues[4985]),0}, {"anyPolicy","X509v3 Any Policy",NID_any_policy,4,&(lvalues[4990]),0}, {"policyMappings","X509v3 Policy Mappings",NID_policy_mappings,3, &(lvalues[4994]),0}, {"inhibitAnyPolicy","X509v3 Inhibit Any Policy", NID_inhibit_any_policy,3,&(lvalues[4997]),0}, {"Oakley-EC2N-3","ipsec3",NID_ipsec3,0,NULL,0}, {"Oakley-EC2N-4","ipsec4",NID_ipsec4,0,NULL,0}, {"CAMELLIA-128-CBC","camellia-128-cbc",NID_camellia_128_cbc,11, &(lvalues[5000]),0}, {"CAMELLIA-192-CBC","camellia-192-cbc",NID_camellia_192_cbc,11, &(lvalues[5011]),0}, {"CAMELLIA-256-CBC","camellia-256-cbc",NID_camellia_256_cbc,11, &(lvalues[5022]),0}, {"CAMELLIA-128-ECB","camellia-128-ecb",NID_camellia_128_ecb,8, &(lvalues[5033]),0}, {"CAMELLIA-192-ECB","camellia-192-ecb",NID_camellia_192_ecb,8, &(lvalues[5041]),0}, {"CAMELLIA-256-ECB","camellia-256-ecb",NID_camellia_256_ecb,8, &(lvalues[5049]),0}, {"CAMELLIA-128-CFB","camellia-128-cfb",NID_camellia_128_cfb128,8, &(lvalues[5057]),0}, {"CAMELLIA-192-CFB","camellia-192-cfb",NID_camellia_192_cfb128,8, &(lvalues[5065]),0}, {"CAMELLIA-256-CFB","camellia-256-cfb",NID_camellia_256_cfb128,8, &(lvalues[5073]),0}, {"CAMELLIA-128-CFB1","camellia-128-cfb1",NID_camellia_128_cfb1,0,NULL,0}, {"CAMELLIA-192-CFB1","camellia-192-cfb1",NID_camellia_192_cfb1,0,NULL,0}, {"CAMELLIA-256-CFB1","camellia-256-cfb1",NID_camellia_256_cfb1,0,NULL,0}, {"CAMELLIA-128-CFB8","camellia-128-cfb8",NID_camellia_128_cfb8,0,NULL,0}, {"CAMELLIA-192-CFB8","camellia-192-cfb8",NID_camellia_192_cfb8,0,NULL,0}, {"CAMELLIA-256-CFB8","camellia-256-cfb8",NID_camellia_256_cfb8,0,NULL,0}, {"CAMELLIA-128-OFB","camellia-128-ofb",NID_camellia_128_ofb128,8, &(lvalues[5081]),0}, {"CAMELLIA-192-OFB","camellia-192-ofb",NID_camellia_192_ofb128,8, &(lvalues[5089]),0}, {"CAMELLIA-256-OFB","camellia-256-ofb",NID_camellia_256_ofb128,8, &(lvalues[5097]),0}, {"subjectDirectoryAttributes","X509v3 Subject Directory Attributes", NID_subject_directory_attributes,3,&(lvalues[5105]),0}, {"issuingDistributionPoint","X509v3 Issuing Distrubution Point", NID_issuing_distribution_point,3,&(lvalues[5108]),0}, {"certificateIssuer","X509v3 Certificate Issuer", NID_certificate_issuer,3,&(lvalues[5111]),0}, {NULL,NULL,NID_undef,0,NULL,0}, {"KISA","kisa",NID_kisa,6,&(lvalues[5114]),0}, {NULL,NULL,NID_undef,0,NULL,0}, {NULL,NULL,NID_undef,0,NULL,0}, {"SEED-ECB","seed-ecb",NID_seed_ecb,8,&(lvalues[5120]),0}, {"SEED-CBC","seed-cbc",NID_seed_cbc,8,&(lvalues[5128]),0}, {"SEED-OFB","seed-ofb",NID_seed_ofb128,8,&(lvalues[5136]),0}, {"SEED-CFB","seed-cfb",NID_seed_cfb128,8,&(lvalues[5144]),0}, {"HMAC-MD5","hmac-md5",NID_hmac_md5,8,&(lvalues[5152]),0}, {"HMAC-SHA1","hmac-sha1",NID_hmac_sha1,8,&(lvalues[5160]),0}, {"id-PasswordBasedMAC","password based MAC",NID_id_PasswordBasedMAC,9, &(lvalues[5168]),0}, {"id-DHBasedMac","Diffie-Hellman based MAC",NID_id_DHBasedMac,9, &(lvalues[5177]),0}, {"id-it-suppLangTags","id-it-suppLangTags",NID_id_it_suppLangTags,8, &(lvalues[5186]),0}, {"caRepository","CA Repository",NID_caRepository,8,&(lvalues[5194]),0}, {"id-smime-ct-compressedData","id-smime-ct-compressedData", NID_id_smime_ct_compressedData,11,&(lvalues[5202]),0}, {"id-ct-asciiTextWithCRLF","id-ct-asciiTextWithCRLF", NID_id_ct_asciiTextWithCRLF,11,&(lvalues[5213]),0}, {"id-aes128-wrap","id-aes128-wrap",NID_id_aes128_wrap,9, &(lvalues[5224]),0}, {"id-aes192-wrap","id-aes192-wrap",NID_id_aes192_wrap,9, &(lvalues[5233]),0}, {"id-aes256-wrap","id-aes256-wrap",NID_id_aes256_wrap,9, &(lvalues[5242]),0}, {"ecdsa-with-Recommended","ecdsa-with-Recommended", NID_ecdsa_with_Recommended,7,&(lvalues[5251]),0}, {"ecdsa-with-Specified","ecdsa-with-Specified", NID_ecdsa_with_Specified,7,&(lvalues[5258]),0}, {"ecdsa-with-SHA224","ecdsa-with-SHA224",NID_ecdsa_with_SHA224,8, &(lvalues[5265]),0}, {"ecdsa-with-SHA256","ecdsa-with-SHA256",NID_ecdsa_with_SHA256,8, &(lvalues[5273]),0}, {"ecdsa-with-SHA384","ecdsa-with-SHA384",NID_ecdsa_with_SHA384,8, &(lvalues[5281]),0}, {"ecdsa-with-SHA512","ecdsa-with-SHA512",NID_ecdsa_with_SHA512,8, &(lvalues[5289]),0}, {"hmacWithMD5","hmacWithMD5",NID_hmacWithMD5,8,&(lvalues[5297]),0}, {"hmacWithSHA224","hmacWithSHA224",NID_hmacWithSHA224,8, &(lvalues[5305]),0}, {"hmacWithSHA256","hmacWithSHA256",NID_hmacWithSHA256,8, &(lvalues[5313]),0}, {"hmacWithSHA384","hmacWithSHA384",NID_hmacWithSHA384,8, &(lvalues[5321]),0}, {"hmacWithSHA512","hmacWithSHA512",NID_hmacWithSHA512,8, &(lvalues[5329]),0}, {"dsa_with_SHA224","dsa_with_SHA224",NID_dsa_with_SHA224,9, &(lvalues[5337]),0}, {"dsa_with_SHA256","dsa_with_SHA256",NID_dsa_with_SHA256,9, &(lvalues[5346]),0}, {"whirlpool","whirlpool",NID_whirlpool,6,&(lvalues[5355]),0}, {"cryptopro","cryptopro",NID_cryptopro,5,&(lvalues[5361]),0}, {"cryptocom","cryptocom",NID_cryptocom,5,&(lvalues[5366]),0}, {"id-GostR3411-94-with-GostR3410-2001", "GOST R 34.11-94 with GOST R 34.10-2001", NID_id_GostR3411_94_with_GostR3410_2001,6,&(lvalues[5371]),0}, {"id-GostR3411-94-with-GostR3410-94", "GOST R 34.11-94 with GOST R 34.10-94", NID_id_GostR3411_94_with_GostR3410_94,6,&(lvalues[5377]),0}, {"md_gost94","GOST R 34.11-94",NID_id_GostR3411_94,6,&(lvalues[5383]),0}, {"id-HMACGostR3411-94","HMAC GOST 34.11-94",NID_id_HMACGostR3411_94,6, &(lvalues[5389]),0}, {"gost2001","GOST R 34.10-2001",NID_id_GostR3410_2001,6, &(lvalues[5395]),0}, {"gost94","GOST R 34.10-94",NID_id_GostR3410_94,6,&(lvalues[5401]),0}, {"gost89","GOST 28147-89",NID_id_Gost28147_89,6,&(lvalues[5407]),0}, {"gost89-cnt","gost89-cnt",NID_gost89_cnt,0,NULL,0}, {"gost-mac","GOST 28147-89 MAC",NID_id_Gost28147_89_MAC,6, &(lvalues[5413]),0}, {"prf-gostr3411-94","GOST R 34.11-94 PRF",NID_id_GostR3411_94_prf,6, &(lvalues[5419]),0}, {"id-GostR3410-2001DH","GOST R 34.10-2001 DH",NID_id_GostR3410_2001DH, 6,&(lvalues[5425]),0}, {"id-GostR3410-94DH","GOST R 34.10-94 DH",NID_id_GostR3410_94DH,6, &(lvalues[5431]),0}, {"id-Gost28147-89-CryptoPro-KeyMeshing", "id-Gost28147-89-CryptoPro-KeyMeshing", NID_id_Gost28147_89_CryptoPro_KeyMeshing,7,&(lvalues[5437]),0}, {"id-Gost28147-89-None-KeyMeshing","id-Gost28147-89-None-KeyMeshing", NID_id_Gost28147_89_None_KeyMeshing,7,&(lvalues[5444]),0}, {"id-GostR3411-94-TestParamSet","id-GostR3411-94-TestParamSet", NID_id_GostR3411_94_TestParamSet,7,&(lvalues[5451]),0}, {"id-GostR3411-94-CryptoProParamSet", "id-GostR3411-94-CryptoProParamSet", NID_id_GostR3411_94_CryptoProParamSet,7,&(lvalues[5458]),0}, {"id-Gost28147-89-TestParamSet","id-Gost28147-89-TestParamSet", NID_id_Gost28147_89_TestParamSet,7,&(lvalues[5465]),0}, {"id-Gost28147-89-CryptoPro-A-ParamSet", "id-Gost28147-89-CryptoPro-A-ParamSet", NID_id_Gost28147_89_CryptoPro_A_ParamSet,7,&(lvalues[5472]),0}, {"id-Gost28147-89-CryptoPro-B-ParamSet", "id-Gost28147-89-CryptoPro-B-ParamSet", NID_id_Gost28147_89_CryptoPro_B_ParamSet,7,&(lvalues[5479]),0}, {"id-Gost28147-89-CryptoPro-C-ParamSet", "id-Gost28147-89-CryptoPro-C-ParamSet", NID_id_Gost28147_89_CryptoPro_C_ParamSet,7,&(lvalues[5486]),0}, {"id-Gost28147-89-CryptoPro-D-ParamSet", "id-Gost28147-89-CryptoPro-D-ParamSet", NID_id_Gost28147_89_CryptoPro_D_ParamSet,7,&(lvalues[5493]),0}, {"id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet", "id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet", NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet,7,&(lvalues[5500]), 0}, {"id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet", "id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet", NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet,7,&(lvalues[5507]), 0}, {"id-Gost28147-89-CryptoPro-RIC-1-ParamSet", "id-Gost28147-89-CryptoPro-RIC-1-ParamSet", NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet,7,&(lvalues[5514]),0}, {"id-GostR3410-94-TestParamSet","id-GostR3410-94-TestParamSet", NID_id_GostR3410_94_TestParamSet,7,&(lvalues[5521]),0}, {"id-GostR3410-94-CryptoPro-A-ParamSet", "id-GostR3410-94-CryptoPro-A-ParamSet", NID_id_GostR3410_94_CryptoPro_A_ParamSet,7,&(lvalues[5528]),0}, {"id-GostR3410-94-CryptoPro-B-ParamSet", "id-GostR3410-94-CryptoPro-B-ParamSet", NID_id_GostR3410_94_CryptoPro_B_ParamSet,7,&(lvalues[5535]),0}, {"id-GostR3410-94-CryptoPro-C-ParamSet", "id-GostR3410-94-CryptoPro-C-ParamSet", NID_id_GostR3410_94_CryptoPro_C_ParamSet,7,&(lvalues[5542]),0}, {"id-GostR3410-94-CryptoPro-D-ParamSet", "id-GostR3410-94-CryptoPro-D-ParamSet", NID_id_GostR3410_94_CryptoPro_D_ParamSet,7,&(lvalues[5549]),0}, {"id-GostR3410-94-CryptoPro-XchA-ParamSet", "id-GostR3410-94-CryptoPro-XchA-ParamSet", NID_id_GostR3410_94_CryptoPro_XchA_ParamSet,7,&(lvalues[5556]),0}, {"id-GostR3410-94-CryptoPro-XchB-ParamSet", "id-GostR3410-94-CryptoPro-XchB-ParamSet", NID_id_GostR3410_94_CryptoPro_XchB_ParamSet,7,&(lvalues[5563]),0}, {"id-GostR3410-94-CryptoPro-XchC-ParamSet", "id-GostR3410-94-CryptoPro-XchC-ParamSet", NID_id_GostR3410_94_CryptoPro_XchC_ParamSet,7,&(lvalues[5570]),0}, {"id-GostR3410-2001-TestParamSet","id-GostR3410-2001-TestParamSet", NID_id_GostR3410_2001_TestParamSet,7,&(lvalues[5577]),0}, {"id-GostR3410-2001-CryptoPro-A-ParamSet", "id-GostR3410-2001-CryptoPro-A-ParamSet", NID_id_GostR3410_2001_CryptoPro_A_ParamSet,7,&(lvalues[5584]),0}, {"id-GostR3410-2001-CryptoPro-B-ParamSet", "id-GostR3410-2001-CryptoPro-B-ParamSet", NID_id_GostR3410_2001_CryptoPro_B_ParamSet,7,&(lvalues[5591]),0}, {"id-GostR3410-2001-CryptoPro-C-ParamSet", "id-GostR3410-2001-CryptoPro-C-ParamSet", NID_id_GostR3410_2001_CryptoPro_C_ParamSet,7,&(lvalues[5598]),0}, {"id-GostR3410-2001-CryptoPro-XchA-ParamSet", "id-GostR3410-2001-CryptoPro-XchA-ParamSet", NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet,7,&(lvalues[5605]),0}, {"id-GostR3410-2001-CryptoPro-XchB-ParamSet", "id-GostR3410-2001-CryptoPro-XchB-ParamSet", NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet,7,&(lvalues[5612]),0}, {"id-GostR3410-94-a","id-GostR3410-94-a",NID_id_GostR3410_94_a,7, &(lvalues[5619]),0}, {"id-GostR3410-94-aBis","id-GostR3410-94-aBis", NID_id_GostR3410_94_aBis,7,&(lvalues[5626]),0}, {"id-GostR3410-94-b","id-GostR3410-94-b",NID_id_GostR3410_94_b,7, &(lvalues[5633]),0}, {"id-GostR3410-94-bBis","id-GostR3410-94-bBis", NID_id_GostR3410_94_bBis,7,&(lvalues[5640]),0}, {"id-Gost28147-89-cc","GOST 28147-89 Cryptocom ParamSet", NID_id_Gost28147_89_cc,8,&(lvalues[5647]),0}, {"gost94cc","GOST 34.10-94 Cryptocom",NID_id_GostR3410_94_cc,8, &(lvalues[5655]),0}, {"gost2001cc","GOST 34.10-2001 Cryptocom",NID_id_GostR3410_2001_cc,8, &(lvalues[5663]),0}, {"id-GostR3411-94-with-GostR3410-94-cc", "GOST R 34.11-94 with GOST R 34.10-94 Cryptocom", NID_id_GostR3411_94_with_GostR3410_94_cc,8,&(lvalues[5671]),0}, {"id-GostR3411-94-with-GostR3410-2001-cc", "GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom", NID_id_GostR3411_94_with_GostR3410_2001_cc,8,&(lvalues[5679]),0}, {"id-GostR3410-2001-ParamSet-cc", "GOST R 3410-2001 Parameter Set Cryptocom", NID_id_GostR3410_2001_ParamSet_cc,8,&(lvalues[5687]),0}, {"HMAC","hmac",NID_hmac,0,NULL,0}, {"LocalKeySet","Microsoft Local Key set",NID_LocalKeySet,9, &(lvalues[5695]),0}, {"freshestCRL","X509v3 Freshest CRL",NID_freshest_crl,3, &(lvalues[5704]),0}, {"id-on-permanentIdentifier","Permanent Identifier", NID_id_on_permanentIdentifier,8,&(lvalues[5707]),0}, {"searchGuide","searchGuide",NID_searchGuide,3,&(lvalues[5715]),0}, {"businessCategory","businessCategory",NID_businessCategory,3, &(lvalues[5718]),0}, {"postalAddress","postalAddress",NID_postalAddress,3,&(lvalues[5721]),0}, {"postOfficeBox","postOfficeBox",NID_postOfficeBox,3,&(lvalues[5724]),0}, {"physicalDeliveryOfficeName","physicalDeliveryOfficeName", NID_physicalDeliveryOfficeName,3,&(lvalues[5727]),0}, {"telephoneNumber","telephoneNumber",NID_telephoneNumber,3, &(lvalues[5730]),0}, {"telexNumber","telexNumber",NID_telexNumber,3,&(lvalues[5733]),0}, {"teletexTerminalIdentifier","teletexTerminalIdentifier", NID_teletexTerminalIdentifier,3,&(lvalues[5736]),0}, {"facsimileTelephoneNumber","facsimileTelephoneNumber", NID_facsimileTelephoneNumber,3,&(lvalues[5739]),0}, {"x121Address","x121Address",NID_x121Address,3,&(lvalues[5742]),0}, {"internationaliSDNNumber","internationaliSDNNumber", NID_internationaliSDNNumber,3,&(lvalues[5745]),0}, {"registeredAddress","registeredAddress",NID_registeredAddress,3, &(lvalues[5748]),0}, {"destinationIndicator","destinationIndicator", NID_destinationIndicator,3,&(lvalues[5751]),0}, {"preferredDeliveryMethod","preferredDeliveryMethod", NID_preferredDeliveryMethod,3,&(lvalues[5754]),0}, {"presentationAddress","presentationAddress",NID_presentationAddress, 3,&(lvalues[5757]),0}, {"supportedApplicationContext","supportedApplicationContext", NID_supportedApplicationContext,3,&(lvalues[5760]),0}, {"member","member",NID_member,3,&(lvalues[5763]),0}, {"owner","owner",NID_owner,3,&(lvalues[5766]),0}, {"roleOccupant","roleOccupant",NID_roleOccupant,3,&(lvalues[5769]),0}, {"seeAlso","seeAlso",NID_seeAlso,3,&(lvalues[5772]),0}, {"userPassword","userPassword",NID_userPassword,3,&(lvalues[5775]),0}, {"userCertificate","userCertificate",NID_userCertificate,3, &(lvalues[5778]),0}, {"cACertificate","cACertificate",NID_cACertificate,3,&(lvalues[5781]),0}, {"authorityRevocationList","authorityRevocationList", NID_authorityRevocationList,3,&(lvalues[5784]),0}, {"certificateRevocationList","certificateRevocationList", NID_certificateRevocationList,3,&(lvalues[5787]),0}, {"crossCertificatePair","crossCertificatePair", NID_crossCertificatePair,3,&(lvalues[5790]),0}, {"enhancedSearchGuide","enhancedSearchGuide",NID_enhancedSearchGuide, 3,&(lvalues[5793]),0}, {"protocolInformation","protocolInformation",NID_protocolInformation, 3,&(lvalues[5796]),0}, {"distinguishedName","distinguishedName",NID_distinguishedName,3, &(lvalues[5799]),0}, {"uniqueMember","uniqueMember",NID_uniqueMember,3,&(lvalues[5802]),0}, {"houseIdentifier","houseIdentifier",NID_houseIdentifier,3, &(lvalues[5805]),0}, {"supportedAlgorithms","supportedAlgorithms",NID_supportedAlgorithms, 3,&(lvalues[5808]),0}, {"deltaRevocationList","deltaRevocationList",NID_deltaRevocationList, 3,&(lvalues[5811]),0}, {"dmdName","dmdName",NID_dmdName,3,&(lvalues[5814]),0}, {"id-alg-PWRI-KEK","id-alg-PWRI-KEK",NID_id_alg_PWRI_KEK,11, &(lvalues[5817]),0}, {"CMAC","cmac",NID_cmac,0,NULL,0}, {"id-aes128-GCM","aes-128-gcm",NID_aes_128_gcm,9,&(lvalues[5828]),0}, {"id-aes128-CCM","aes-128-ccm",NID_aes_128_ccm,9,&(lvalues[5837]),0}, {"id-aes128-wrap-pad","id-aes128-wrap-pad",NID_id_aes128_wrap_pad,9, &(lvalues[5846]),0}, {"id-aes192-GCM","aes-192-gcm",NID_aes_192_gcm,9,&(lvalues[5855]),0}, {"id-aes192-CCM","aes-192-ccm",NID_aes_192_ccm,9,&(lvalues[5864]),0}, {"id-aes192-wrap-pad","id-aes192-wrap-pad",NID_id_aes192_wrap_pad,9, &(lvalues[5873]),0}, {"id-aes256-GCM","aes-256-gcm",NID_aes_256_gcm,9,&(lvalues[5882]),0}, {"id-aes256-CCM","aes-256-ccm",NID_aes_256_ccm,9,&(lvalues[5891]),0}, {"id-aes256-wrap-pad","id-aes256-wrap-pad",NID_id_aes256_wrap_pad,9, &(lvalues[5900]),0}, {"AES-128-CTR","aes-128-ctr",NID_aes_128_ctr,0,NULL,0}, {"AES-192-CTR","aes-192-ctr",NID_aes_192_ctr,0,NULL,0}, {"AES-256-CTR","aes-256-ctr",NID_aes_256_ctr,0,NULL,0}, {"id-camellia128-wrap","id-camellia128-wrap",NID_id_camellia128_wrap, 11,&(lvalues[5909]),0}, {"id-camellia192-wrap","id-camellia192-wrap",NID_id_camellia192_wrap, 11,&(lvalues[5920]),0}, {"id-camellia256-wrap","id-camellia256-wrap",NID_id_camellia256_wrap, 11,&(lvalues[5931]),0}, {"anyExtendedKeyUsage","Any Extended Key Usage", NID_anyExtendedKeyUsage,4,&(lvalues[5942]),0}, {"MGF1","mgf1",NID_mgf1,9,&(lvalues[5946]),0}, {"RSASSA-PSS","rsassaPss",NID_rsassaPss,9,&(lvalues[5955]),0}, {"AES-128-XTS","aes-128-xts",NID_aes_128_xts,0,NULL,0}, {"AES-256-XTS","aes-256-xts",NID_aes_256_xts,0,NULL,0}, {"RC4-HMAC-MD5","rc4-hmac-md5",NID_rc4_hmac_md5,0,NULL,0}, {"AES-128-CBC-HMAC-SHA1","aes-128-cbc-hmac-sha1", NID_aes_128_cbc_hmac_sha1,0,NULL,0}, {"AES-192-CBC-HMAC-SHA1","aes-192-cbc-hmac-sha1", NID_aes_192_cbc_hmac_sha1,0,NULL,0}, {"AES-256-CBC-HMAC-SHA1","aes-256-cbc-hmac-sha1", NID_aes_256_cbc_hmac_sha1,0,NULL,0}, {"RSAES-OAEP","rsaesOaep",NID_rsaesOaep,9,&(lvalues[5964]),0}, {"teletrust","teletrust",NID_teletrust,2,&(lvalues[5973]),0}, {"brainpool","brainpool",NID_brainpool,7,&(lvalues[5975]),0}, {"brainpoolP160r1","brainpoolP160r1",NID_brainpoolP160r1,9, &(lvalues[5982]),0}, {"brainpoolP160t1","brainpoolP160t1",NID_brainpoolP160t1,9, &(lvalues[5991]),0}, {"brainpoolP192r1","brainpoolP192r1",NID_brainpoolP192r1,9, &(lvalues[6000]),0}, {"brainpoolP192t1","brainpoolP192t1",NID_brainpoolP192t1,9, &(lvalues[6009]),0}, {"brainpoolP224r1","brainpoolP224r1",NID_brainpoolP224r1,9, &(lvalues[6018]),0}, {"brainpoolP224t1","brainpoolP224t1",NID_brainpoolP224t1,9, &(lvalues[6027]),0}, {"brainpoolP256r1","brainpoolP256r1",NID_brainpoolP256r1,9, &(lvalues[6036]),0}, {"brainpoolP256t1","brainpoolP256t1",NID_brainpoolP256t1,9, &(lvalues[6045]),0}, {"brainpoolP320r1","brainpoolP320r1",NID_brainpoolP320r1,9, &(lvalues[6054]),0}, {"brainpoolP320t1","brainpoolP320t1",NID_brainpoolP320t1,9, &(lvalues[6063]),0}, {"brainpoolP384r1","brainpoolP384r1",NID_brainpoolP384r1,9, &(lvalues[6072]),0}, {"brainpoolP384t1","brainpoolP384t1",NID_brainpoolP384t1,9, &(lvalues[6081]),0}, {"brainpoolP512r1","brainpoolP512r1",NID_brainpoolP512r1,9, &(lvalues[6090]),0}, {"brainpoolP512t1","brainpoolP512t1",NID_brainpoolP512t1,9, &(lvalues[6099]),0}, {"FRP256v1","FRP256v1",NID_FRP256v1,10,&(lvalues[6108]),0}, {"ChaCha","chacha",NID_chacha20,0,NULL,0}, }; static const unsigned int sn_objs[NUM_SN]={ 364, /* "AD_DVCS" */ 419, /* "AES-128-CBC" */ 916, /* "AES-128-CBC-HMAC-SHA1" */ 421, /* "AES-128-CFB" */ 650, /* "AES-128-CFB1" */ 653, /* "AES-128-CFB8" */ 904, /* "AES-128-CTR" */ 418, /* "AES-128-ECB" */ 420, /* "AES-128-OFB" */ 913, /* "AES-128-XTS" */ 423, /* "AES-192-CBC" */ 917, /* "AES-192-CBC-HMAC-SHA1" */ 425, /* "AES-192-CFB" */ 651, /* "AES-192-CFB1" */ 654, /* "AES-192-CFB8" */ 905, /* "AES-192-CTR" */ 422, /* "AES-192-ECB" */ 424, /* "AES-192-OFB" */ 427, /* "AES-256-CBC" */ 918, /* "AES-256-CBC-HMAC-SHA1" */ 429, /* "AES-256-CFB" */ 652, /* "AES-256-CFB1" */ 655, /* "AES-256-CFB8" */ 906, /* "AES-256-CTR" */ 426, /* "AES-256-ECB" */ 428, /* "AES-256-OFB" */ 914, /* "AES-256-XTS" */ 91, /* "BF-CBC" */ 93, /* "BF-CFB" */ 92, /* "BF-ECB" */ 94, /* "BF-OFB" */ 14, /* "C" */ 751, /* "CAMELLIA-128-CBC" */ 757, /* "CAMELLIA-128-CFB" */ 760, /* "CAMELLIA-128-CFB1" */ 763, /* "CAMELLIA-128-CFB8" */ 754, /* "CAMELLIA-128-ECB" */ 766, /* "CAMELLIA-128-OFB" */ 752, /* "CAMELLIA-192-CBC" */ 758, /* "CAMELLIA-192-CFB" */ 761, /* "CAMELLIA-192-CFB1" */ 764, /* "CAMELLIA-192-CFB8" */ 755, /* "CAMELLIA-192-ECB" */ 767, /* "CAMELLIA-192-OFB" */ 753, /* "CAMELLIA-256-CBC" */ 759, /* "CAMELLIA-256-CFB" */ 762, /* "CAMELLIA-256-CFB1" */ 765, /* "CAMELLIA-256-CFB8" */ 756, /* "CAMELLIA-256-ECB" */ 768, /* "CAMELLIA-256-OFB" */ 108, /* "CAST5-CBC" */ 110, /* "CAST5-CFB" */ 109, /* "CAST5-ECB" */ 111, /* "CAST5-OFB" */ 894, /* "CMAC" */ 13, /* "CN" */ 141, /* "CRLReason" */ 417, /* "CSPName" */ 937, /* "ChaCha" */ 367, /* "CrlID" */ 391, /* "DC" */ 31, /* "DES-CBC" */ 643, /* "DES-CDMF" */ 30, /* "DES-CFB" */ 656, /* "DES-CFB1" */ 657, /* "DES-CFB8" */ 29, /* "DES-ECB" */ 32, /* "DES-EDE" */ 43, /* "DES-EDE-CBC" */ 60, /* "DES-EDE-CFB" */ 62, /* "DES-EDE-OFB" */ 33, /* "DES-EDE3" */ 44, /* "DES-EDE3-CBC" */ 61, /* "DES-EDE3-CFB" */ 658, /* "DES-EDE3-CFB1" */ 659, /* "DES-EDE3-CFB8" */ 63, /* "DES-EDE3-OFB" */ 45, /* "DES-OFB" */ 80, /* "DESX-CBC" */ 380, /* "DOD" */ 116, /* "DSA" */ 66, /* "DSA-SHA" */ 113, /* "DSA-SHA1" */ 70, /* "DSA-SHA1-old" */ 67, /* "DSA-old" */ 297, /* "DVCS" */ 936, /* "FRP256v1" */ 99, /* "GN" */ 855, /* "HMAC" */ 780, /* "HMAC-MD5" */ 781, /* "HMAC-SHA1" */ 381, /* "IANA" */ 34, /* "IDEA-CBC" */ 35, /* "IDEA-CFB" */ 36, /* "IDEA-ECB" */ 46, /* "IDEA-OFB" */ 181, /* "ISO" */ 183, /* "ISO-US" */ 645, /* "ITU-T" */ 646, /* "JOINT-ISO-ITU-T" */ 773, /* "KISA" */ 15, /* "L" */ 856, /* "LocalKeySet" */ 3, /* "MD2" */ 257, /* "MD4" */ 4, /* "MD5" */ 114, /* "MD5-SHA1" */ 95, /* "MDC2" */ 911, /* "MGF1" */ 388, /* "Mail" */ 393, /* "NULL" */ 404, /* "NULL" */ 57, /* "Netscape" */ 366, /* "Nonce" */ 17, /* "O" */ 178, /* "OCSP" */ 180, /* "OCSPSigning" */ 379, /* "ORG" */ 18, /* "OU" */ 749, /* "Oakley-EC2N-3" */ 750, /* "Oakley-EC2N-4" */ 9, /* "PBE-MD2-DES" */ 168, /* "PBE-MD2-RC2-64" */ 10, /* "PBE-MD5-DES" */ 169, /* "PBE-MD5-RC2-64" */ 147, /* "PBE-SHA1-2DES" */ 146, /* "PBE-SHA1-3DES" */ 170, /* "PBE-SHA1-DES" */ 148, /* "PBE-SHA1-RC2-128" */ 149, /* "PBE-SHA1-RC2-40" */ 68, /* "PBE-SHA1-RC2-64" */ 144, /* "PBE-SHA1-RC4-128" */ 145, /* "PBE-SHA1-RC4-40" */ 161, /* "PBES2" */ 69, /* "PBKDF2" */ 162, /* "PBMAC1" */ 127, /* "PKIX" */ 98, /* "RC2-40-CBC" */ 166, /* "RC2-64-CBC" */ 37, /* "RC2-CBC" */ 39, /* "RC2-CFB" */ 38, /* "RC2-ECB" */ 40, /* "RC2-OFB" */ 5, /* "RC4" */ 97, /* "RC4-40" */ 915, /* "RC4-HMAC-MD5" */ 120, /* "RC5-CBC" */ 122, /* "RC5-CFB" */ 121, /* "RC5-ECB" */ 123, /* "RC5-OFB" */ 117, /* "RIPEMD160" */ 124, /* "RLE" */ 19, /* "RSA" */ 7, /* "RSA-MD2" */ 396, /* "RSA-MD4" */ 8, /* "RSA-MD5" */ 96, /* "RSA-MDC2" */ 104, /* "RSA-NP-MD5" */ 119, /* "RSA-RIPEMD160" */ 42, /* "RSA-SHA" */ 65, /* "RSA-SHA1" */ 115, /* "RSA-SHA1-2" */ 671, /* "RSA-SHA224" */ 668, /* "RSA-SHA256" */ 669, /* "RSA-SHA384" */ 670, /* "RSA-SHA512" */ 919, /* "RSAES-OAEP" */ 912, /* "RSASSA-PSS" */ 777, /* "SEED-CBC" */ 779, /* "SEED-CFB" */ 776, /* "SEED-ECB" */ 778, /* "SEED-OFB" */ 41, /* "SHA" */ 64, /* "SHA1" */ 675, /* "SHA224" */ 672, /* "SHA256" */ 673, /* "SHA384" */ 674, /* "SHA512" */ 188, /* "SMIME" */ 167, /* "SMIME-CAPS" */ 100, /* "SN" */ 16, /* "ST" */ 143, /* "SXNetID" */ 458, /* "UID" */ 0, /* "UNDEF" */ 11, /* "X500" */ 378, /* "X500algorithms" */ 12, /* "X509" */ 184, /* "X9-57" */ 185, /* "X9cm" */ 125, /* "ZLIB" */ 478, /* "aRecord" */ 289, /* "aaControls" */ 287, /* "ac-auditEntity" */ 397, /* "ac-proxying" */ 288, /* "ac-targeting" */ 368, /* "acceptableResponses" */ 446, /* "account" */ 363, /* "ad_timestamping" */ 376, /* "algorithm" */ 405, /* "ansi-X9-62" */ 910, /* "anyExtendedKeyUsage" */ 746, /* "anyPolicy" */ 370, /* "archiveCutoff" */ 484, /* "associatedDomain" */ 485, /* "associatedName" */ 501, /* "audio" */ 177, /* "authorityInfoAccess" */ 90, /* "authorityKeyIdentifier" */ 882, /* "authorityRevocationList" */ 87, /* "basicConstraints" */ 365, /* "basicOCSPResponse" */ 285, /* "biometricInfo" */ 921, /* "brainpool" */ 922, /* "brainpoolP160r1" */ 923, /* "brainpoolP160t1" */ 924, /* "brainpoolP192r1" */ 925, /* "brainpoolP192t1" */ 926, /* "brainpoolP224r1" */ 927, /* "brainpoolP224t1" */ 928, /* "brainpoolP256r1" */ 929, /* "brainpoolP256t1" */ 930, /* "brainpoolP320r1" */ 931, /* "brainpoolP320t1" */ 932, /* "brainpoolP384r1" */ 933, /* "brainpoolP384t1" */ 934, /* "brainpoolP512r1" */ 935, /* "brainpoolP512t1" */ 494, /* "buildingName" */ 860, /* "businessCategory" */ 691, /* "c2onb191v4" */ 692, /* "c2onb191v5" */ 697, /* "c2onb239v4" */ 698, /* "c2onb239v5" */ 684, /* "c2pnb163v1" */ 685, /* "c2pnb163v2" */ 686, /* "c2pnb163v3" */ 687, /* "c2pnb176v1" */ 693, /* "c2pnb208w1" */ 699, /* "c2pnb272w1" */ 700, /* "c2pnb304w1" */ 702, /* "c2pnb368w1" */ 688, /* "c2tnb191v1" */ 689, /* "c2tnb191v2" */ 690, /* "c2tnb191v3" */ 694, /* "c2tnb239v1" */ 695, /* "c2tnb239v2" */ 696, /* "c2tnb239v3" */ 701, /* "c2tnb359v1" */ 703, /* "c2tnb431r1" */ 881, /* "cACertificate" */ 483, /* "cNAMERecord" */ 179, /* "caIssuers" */ 785, /* "caRepository" */ 443, /* "caseIgnoreIA5StringSyntax" */ 152, /* "certBag" */ 677, /* "certicom-arc" */ 771, /* "certificateIssuer" */ 89, /* "certificatePolicies" */ 883, /* "certificateRevocationList" */ 54, /* "challengePassword" */ 407, /* "characteristic-two-field" */ 395, /* "clearance" */ 130, /* "clientAuth" */ 131, /* "codeSigning" */ 50, /* "contentType" */ 53, /* "countersignature" */ 153, /* "crlBag" */ 103, /* "crlDistributionPoints" */ 88, /* "crlNumber" */ 884, /* "crossCertificatePair" */ 806, /* "cryptocom" */ 805, /* "cryptopro" */ 500, /* "dITRedirect" */ 451, /* "dNSDomain" */ 495, /* "dSAQuality" */ 434, /* "data" */ 390, /* "dcobject" */ 140, /* "deltaCRL" */ 891, /* "deltaRevocationList" */ 107, /* "description" */ 871, /* "destinationIndicator" */ 28, /* "dhKeyAgreement" */ 382, /* "directory" */ 887, /* "distinguishedName" */ 892, /* "dmdName" */ 174, /* "dnQualifier" */ 447, /* "document" */ 471, /* "documentAuthor" */ 468, /* "documentIdentifier" */ 472, /* "documentLocation" */ 502, /* "documentPublisher" */ 449, /* "documentSeries" */ 469, /* "documentTitle" */ 470, /* "documentVersion" */ 392, /* "domain" */ 452, /* "domainRelatedObject" */ 802, /* "dsa_with_SHA224" */ 803, /* "dsa_with_SHA256" */ 791, /* "ecdsa-with-Recommended" */ 416, /* "ecdsa-with-SHA1" */ 793, /* "ecdsa-with-SHA224" */ 794, /* "ecdsa-with-SHA256" */ 795, /* "ecdsa-with-SHA384" */ 796, /* "ecdsa-with-SHA512" */ 792, /* "ecdsa-with-Specified" */ 48, /* "emailAddress" */ 132, /* "emailProtection" */ 885, /* "enhancedSearchGuide" */ 389, /* "enterprises" */ 384, /* "experimental" */ 172, /* "extReq" */ 56, /* "extendedCertificateAttributes" */ 126, /* "extendedKeyUsage" */ 372, /* "extendedStatus" */ 867, /* "facsimileTelephoneNumber" */ 462, /* "favouriteDrink" */ 857, /* "freshestCRL" */ 453, /* "friendlyCountry" */ 490, /* "friendlyCountryName" */ 156, /* "friendlyName" */ 509, /* "generationQualifier" */ 815, /* "gost-mac" */ 811, /* "gost2001" */ 851, /* "gost2001cc" */ 813, /* "gost89" */ 814, /* "gost89-cnt" */ 812, /* "gost94" */ 850, /* "gost94cc" */ 797, /* "hmacWithMD5" */ 163, /* "hmacWithSHA1" */ 798, /* "hmacWithSHA224" */ 799, /* "hmacWithSHA256" */ 800, /* "hmacWithSHA384" */ 801, /* "hmacWithSHA512" */ 432, /* "holdInstructionCallIssuer" */ 430, /* "holdInstructionCode" */ 431, /* "holdInstructionNone" */ 433, /* "holdInstructionReject" */ 486, /* "homePostalAddress" */ 473, /* "homeTelephoneNumber" */ 466, /* "host" */ 889, /* "houseIdentifier" */ 442, /* "iA5StringSyntax" */ 783, /* "id-DHBasedMac" */ 824, /* "id-Gost28147-89-CryptoPro-A-ParamSet" */ 825, /* "id-Gost28147-89-CryptoPro-B-ParamSet" */ 826, /* "id-Gost28147-89-CryptoPro-C-ParamSet" */ 827, /* "id-Gost28147-89-CryptoPro-D-ParamSet" */ 819, /* "id-Gost28147-89-CryptoPro-KeyMeshing" */ 829, /* "id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet" */ 828, /* "id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet" */ 830, /* "id-Gost28147-89-CryptoPro-RIC-1-ParamSet" */ 820, /* "id-Gost28147-89-None-KeyMeshing" */ 823, /* "id-Gost28147-89-TestParamSet" */ 849, /* "id-Gost28147-89-cc" */ 840, /* "id-GostR3410-2001-CryptoPro-A-ParamSet" */ 841, /* "id-GostR3410-2001-CryptoPro-B-ParamSet" */ 842, /* "id-GostR3410-2001-CryptoPro-C-ParamSet" */ 843, /* "id-GostR3410-2001-CryptoPro-XchA-ParamSet" */ 844, /* "id-GostR3410-2001-CryptoPro-XchB-ParamSet" */ 854, /* "id-GostR3410-2001-ParamSet-cc" */ 839, /* "id-GostR3410-2001-TestParamSet" */ 817, /* "id-GostR3410-2001DH" */ 832, /* "id-GostR3410-94-CryptoPro-A-ParamSet" */ 833, /* "id-GostR3410-94-CryptoPro-B-ParamSet" */ 834, /* "id-GostR3410-94-CryptoPro-C-ParamSet" */ 835, /* "id-GostR3410-94-CryptoPro-D-ParamSet" */ 836, /* "id-GostR3410-94-CryptoPro-XchA-ParamSet" */ 837, /* "id-GostR3410-94-CryptoPro-XchB-ParamSet" */ 838, /* "id-GostR3410-94-CryptoPro-XchC-ParamSet" */ 831, /* "id-GostR3410-94-TestParamSet" */ 845, /* "id-GostR3410-94-a" */ 846, /* "id-GostR3410-94-aBis" */ 847, /* "id-GostR3410-94-b" */ 848, /* "id-GostR3410-94-bBis" */ 818, /* "id-GostR3410-94DH" */ 822, /* "id-GostR3411-94-CryptoProParamSet" */ 821, /* "id-GostR3411-94-TestParamSet" */ 807, /* "id-GostR3411-94-with-GostR3410-2001" */ 853, /* "id-GostR3411-94-with-GostR3410-2001-cc" */ 808, /* "id-GostR3411-94-with-GostR3410-94" */ 852, /* "id-GostR3411-94-with-GostR3410-94-cc" */ 810, /* "id-HMACGostR3411-94" */ 782, /* "id-PasswordBasedMAC" */ 266, /* "id-aca" */ 355, /* "id-aca-accessIdentity" */ 354, /* "id-aca-authenticationInfo" */ 356, /* "id-aca-chargingIdentity" */ 399, /* "id-aca-encAttrs" */ 357, /* "id-aca-group" */ 358, /* "id-aca-role" */ 176, /* "id-ad" */ 896, /* "id-aes128-CCM" */ 895, /* "id-aes128-GCM" */ 788, /* "id-aes128-wrap" */ 897, /* "id-aes128-wrap-pad" */ 899, /* "id-aes192-CCM" */ 898, /* "id-aes192-GCM" */ 789, /* "id-aes192-wrap" */ 900, /* "id-aes192-wrap-pad" */ 902, /* "id-aes256-CCM" */ 901, /* "id-aes256-GCM" */ 790, /* "id-aes256-wrap" */ 903, /* "id-aes256-wrap-pad" */ 262, /* "id-alg" */ 893, /* "id-alg-PWRI-KEK" */ 323, /* "id-alg-des40" */ 326, /* "id-alg-dh-pop" */ 325, /* "id-alg-dh-sig-hmac-sha1" */ 324, /* "id-alg-noSignature" */ 907, /* "id-camellia128-wrap" */ 908, /* "id-camellia192-wrap" */ 909, /* "id-camellia256-wrap" */ 268, /* "id-cct" */ 361, /* "id-cct-PKIData" */ 362, /* "id-cct-PKIResponse" */ 360, /* "id-cct-crs" */ 81, /* "id-ce" */ 680, /* "id-characteristic-two-basis" */ 263, /* "id-cmc" */ 334, /* "id-cmc-addExtensions" */ 346, /* "id-cmc-confirmCertAcceptance" */ 330, /* "id-cmc-dataReturn" */ 336, /* "id-cmc-decryptedPOP" */ 335, /* "id-cmc-encryptedPOP" */ 339, /* "id-cmc-getCRL" */ 338, /* "id-cmc-getCert" */ 328, /* "id-cmc-identification" */ 329, /* "id-cmc-identityProof" */ 337, /* "id-cmc-lraPOPWitness" */ 344, /* "id-cmc-popLinkRandom" */ 345, /* "id-cmc-popLinkWitness" */ 343, /* "id-cmc-queryPending" */ 333, /* "id-cmc-recipientNonce" */ 341, /* "id-cmc-regInfo" */ 342, /* "id-cmc-responseInfo" */ 340, /* "id-cmc-revokeRequest" */ 332, /* "id-cmc-senderNonce" */ 327, /* "id-cmc-statusInfo" */ 331, /* "id-cmc-transactionId" */ 787, /* "id-ct-asciiTextWithCRLF" */ 408, /* "id-ecPublicKey" */ 508, /* "id-hex-multipart-message" */ 507, /* "id-hex-partial-message" */ 260, /* "id-it" */ 302, /* "id-it-caKeyUpdateInfo" */ 298, /* "id-it-caProtEncCert" */ 311, /* "id-it-confirmWaitTime" */ 303, /* "id-it-currentCRL" */ 300, /* "id-it-encKeyPairTypes" */ 310, /* "id-it-implicitConfirm" */ 308, /* "id-it-keyPairParamRep" */ 307, /* "id-it-keyPairParamReq" */ 312, /* "id-it-origPKIMessage" */ 301, /* "id-it-preferredSymmAlg" */ 309, /* "id-it-revPassphrase" */ 299, /* "id-it-signKeyPairTypes" */ 305, /* "id-it-subscriptionRequest" */ 306, /* "id-it-subscriptionResponse" */ 784, /* "id-it-suppLangTags" */ 304, /* "id-it-unsupportedOIDs" */ 128, /* "id-kp" */ 280, /* "id-mod-attribute-cert" */ 274, /* "id-mod-cmc" */ 277, /* "id-mod-cmp" */ 284, /* "id-mod-cmp2000" */ 273, /* "id-mod-crmf" */ 283, /* "id-mod-dvcs" */ 275, /* "id-mod-kea-profile-88" */ 276, /* "id-mod-kea-profile-93" */ 282, /* "id-mod-ocsp" */ 278, /* "id-mod-qualified-cert-88" */ 279, /* "id-mod-qualified-cert-93" */ 281, /* "id-mod-timestamp-protocol" */ 264, /* "id-on" */ 858, /* "id-on-permanentIdentifier" */ 347, /* "id-on-personalData" */ 265, /* "id-pda" */ 352, /* "id-pda-countryOfCitizenship" */ 353, /* "id-pda-countryOfResidence" */ 348, /* "id-pda-dateOfBirth" */ 351, /* "id-pda-gender" */ 349, /* "id-pda-placeOfBirth" */ 175, /* "id-pe" */ 261, /* "id-pkip" */ 258, /* "id-pkix-mod" */ 269, /* "id-pkix1-explicit-88" */ 271, /* "id-pkix1-explicit-93" */ 270, /* "id-pkix1-implicit-88" */ 272, /* "id-pkix1-implicit-93" */ 662, /* "id-ppl" */ 664, /* "id-ppl-anyLanguage" */ 667, /* "id-ppl-independent" */ 665, /* "id-ppl-inheritAll" */ 267, /* "id-qcs" */ 359, /* "id-qcs-pkixQCSyntax-v1" */ 259, /* "id-qt" */ 164, /* "id-qt-cps" */ 165, /* "id-qt-unotice" */ 313, /* "id-regCtrl" */ 316, /* "id-regCtrl-authenticator" */ 319, /* "id-regCtrl-oldCertID" */ 318, /* "id-regCtrl-pkiArchiveOptions" */ 317, /* "id-regCtrl-pkiPublicationInfo" */ 320, /* "id-regCtrl-protocolEncrKey" */ 315, /* "id-regCtrl-regToken" */ 314, /* "id-regInfo" */ 322, /* "id-regInfo-certReq" */ 321, /* "id-regInfo-utf8Pairs" */ 512, /* "id-set" */ 191, /* "id-smime-aa" */ 215, /* "id-smime-aa-contentHint" */ 218, /* "id-smime-aa-contentIdentifier" */ 221, /* "id-smime-aa-contentReference" */ 240, /* "id-smime-aa-dvcs-dvc" */ 217, /* "id-smime-aa-encapContentType" */ 222, /* "id-smime-aa-encrypKeyPref" */ 220, /* "id-smime-aa-equivalentLabels" */ 232, /* "id-smime-aa-ets-CertificateRefs" */ 233, /* "id-smime-aa-ets-RevocationRefs" */ 238, /* "id-smime-aa-ets-archiveTimeStamp" */ 237, /* "id-smime-aa-ets-certCRLTimestamp" */ 234, /* "id-smime-aa-ets-certValues" */ 227, /* "id-smime-aa-ets-commitmentType" */ 231, /* "id-smime-aa-ets-contentTimestamp" */ 236, /* "id-smime-aa-ets-escTimeStamp" */ 230, /* "id-smime-aa-ets-otherSigCert" */ 235, /* "id-smime-aa-ets-revocationValues" */ 226, /* "id-smime-aa-ets-sigPolicyId" */ 229, /* "id-smime-aa-ets-signerAttr" */ 228, /* "id-smime-aa-ets-signerLocation" */ 219, /* "id-smime-aa-macValue" */ 214, /* "id-smime-aa-mlExpandHistory" */ 216, /* "id-smime-aa-msgSigDigest" */ 212, /* "id-smime-aa-receiptRequest" */ 213, /* "id-smime-aa-securityLabel" */ 239, /* "id-smime-aa-signatureType" */ 223, /* "id-smime-aa-signingCertificate" */ 224, /* "id-smime-aa-smimeEncryptCerts" */ 225, /* "id-smime-aa-timeStampToken" */ 192, /* "id-smime-alg" */ 243, /* "id-smime-alg-3DESwrap" */ 246, /* "id-smime-alg-CMS3DESwrap" */ 247, /* "id-smime-alg-CMSRC2wrap" */ 245, /* "id-smime-alg-ESDH" */ 241, /* "id-smime-alg-ESDHwith3DES" */ 242, /* "id-smime-alg-ESDHwithRC2" */ 244, /* "id-smime-alg-RC2wrap" */ 193, /* "id-smime-cd" */ 248, /* "id-smime-cd-ldap" */ 190, /* "id-smime-ct" */ 210, /* "id-smime-ct-DVCSRequestData" */ 211, /* "id-smime-ct-DVCSResponseData" */ 208, /* "id-smime-ct-TDTInfo" */ 207, /* "id-smime-ct-TSTInfo" */ 205, /* "id-smime-ct-authData" */ 786, /* "id-smime-ct-compressedData" */ 209, /* "id-smime-ct-contentInfo" */ 206, /* "id-smime-ct-publishCert" */ 204, /* "id-smime-ct-receipt" */ 195, /* "id-smime-cti" */ 255, /* "id-smime-cti-ets-proofOfApproval" */ 256, /* "id-smime-cti-ets-proofOfCreation" */ 253, /* "id-smime-cti-ets-proofOfDelivery" */ 251, /* "id-smime-cti-ets-proofOfOrigin" */ 252, /* "id-smime-cti-ets-proofOfReceipt" */ 254, /* "id-smime-cti-ets-proofOfSender" */ 189, /* "id-smime-mod" */ 196, /* "id-smime-mod-cms" */ 197, /* "id-smime-mod-ess" */ 202, /* "id-smime-mod-ets-eSigPolicy-88" */ 203, /* "id-smime-mod-ets-eSigPolicy-97" */ 200, /* "id-smime-mod-ets-eSignature-88" */ 201, /* "id-smime-mod-ets-eSignature-97" */ 199, /* "id-smime-mod-msg-v3" */ 198, /* "id-smime-mod-oid" */ 194, /* "id-smime-spq" */ 250, /* "id-smime-spq-ets-sqt-unotice" */ 249, /* "id-smime-spq-ets-sqt-uri" */ 676, /* "identified-organization" */ 461, /* "info" */ 748, /* "inhibitAnyPolicy" */ 101, /* "initials" */ 647, /* "international-organizations" */ 869, /* "internationaliSDNNumber" */ 142, /* "invalidityDate" */ 294, /* "ipsecEndSystem" */ 295, /* "ipsecTunnel" */ 296, /* "ipsecUser" */ 86, /* "issuerAltName" */ 770, /* "issuingDistributionPoint" */ 492, /* "janetMailbox" */ 150, /* "keyBag" */ 83, /* "keyUsage" */ 477, /* "lastModifiedBy" */ 476, /* "lastModifiedTime" */ 157, /* "localKeyID" */ 480, /* "mXRecord" */ 460, /* "mail" */ 493, /* "mailPreferenceOption" */ 467, /* "manager" */ 809, /* "md_gost94" */ 875, /* "member" */ 182, /* "member-body" */ 51, /* "messageDigest" */ 383, /* "mgmt" */ 504, /* "mime-mhs" */ 506, /* "mime-mhs-bodies" */ 505, /* "mime-mhs-headings" */ 488, /* "mobileTelephoneNumber" */ 136, /* "msCTLSign" */ 135, /* "msCodeCom" */ 134, /* "msCodeInd" */ 138, /* "msEFS" */ 171, /* "msExtReq" */ 137, /* "msSGC" */ 648, /* "msSmartcardLogin" */ 649, /* "msUPN" */ 481, /* "nSRecord" */ 173, /* "name" */ 666, /* "nameConstraints" */ 369, /* "noCheck" */ 403, /* "noRevAvail" */ 72, /* "nsBaseUrl" */ 76, /* "nsCaPolicyUrl" */ 74, /* "nsCaRevocationUrl" */ 58, /* "nsCertExt" */ 79, /* "nsCertSequence" */ 71, /* "nsCertType" */ 78, /* "nsComment" */ 59, /* "nsDataType" */ 75, /* "nsRenewalUrl" */ 73, /* "nsRevocationUrl" */ 139, /* "nsSGC" */ 77, /* "nsSslServerName" */ 681, /* "onBasis" */ 491, /* "organizationalStatus" */ 475, /* "otherMailbox" */ 876, /* "owner" */ 489, /* "pagerTelephoneNumber" */ 374, /* "path" */ 112, /* "pbeWithMD5AndCast5CBC" */ 499, /* "personalSignature" */ 487, /* "personalTitle" */ 464, /* "photo" */ 863, /* "physicalDeliveryOfficeName" */ 437, /* "pilot" */ 439, /* "pilotAttributeSyntax" */ 438, /* "pilotAttributeType" */ 479, /* "pilotAttributeType27" */ 456, /* "pilotDSA" */ 441, /* "pilotGroups" */ 444, /* "pilotObject" */ 440, /* "pilotObjectClass" */ 455, /* "pilotOrganization" */ 445, /* "pilotPerson" */ 2, /* "pkcs" */ 186, /* "pkcs1" */ 27, /* "pkcs3" */ 187, /* "pkcs5" */ 20, /* "pkcs7" */ 21, /* "pkcs7-data" */ 25, /* "pkcs7-digestData" */ 26, /* "pkcs7-encryptedData" */ 23, /* "pkcs7-envelopedData" */ 24, /* "pkcs7-signedAndEnvelopedData" */ 22, /* "pkcs7-signedData" */ 151, /* "pkcs8ShroudedKeyBag" */ 47, /* "pkcs9" */ 401, /* "policyConstraints" */ 747, /* "policyMappings" */ 862, /* "postOfficeBox" */ 861, /* "postalAddress" */ 661, /* "postalCode" */ 683, /* "ppBasis" */ 872, /* "preferredDeliveryMethod" */ 873, /* "presentationAddress" */ 816, /* "prf-gostr3411-94" */ 406, /* "prime-field" */ 409, /* "prime192v1" */ 410, /* "prime192v2" */ 411, /* "prime192v3" */ 412, /* "prime239v1" */ 413, /* "prime239v2" */ 414, /* "prime239v3" */ 415, /* "prime256v1" */ 385, /* "private" */ 84, /* "privateKeyUsagePeriod" */ 886, /* "protocolInformation" */ 663, /* "proxyCertInfo" */ 510, /* "pseudonym" */ 435, /* "pss" */ 286, /* "qcStatements" */ 457, /* "qualityLabelledData" */ 450, /* "rFC822localPart" */ 870, /* "registeredAddress" */ 400, /* "role" */ 877, /* "roleOccupant" */ 448, /* "room" */ 463, /* "roomNumber" */ 6, /* "rsaEncryption" */ 644, /* "rsaOAEPEncryptionSET" */ 377, /* "rsaSignature" */ 1, /* "rsadsi" */ 482, /* "sOARecord" */ 155, /* "safeContentsBag" */ 291, /* "sbgp-autonomousSysNum" */ 290, /* "sbgp-ipAddrBlock" */ 292, /* "sbgp-routerIdentifier" */ 159, /* "sdsiCertificate" */ 859, /* "searchGuide" */ 704, /* "secp112r1" */ 705, /* "secp112r2" */ 706, /* "secp128r1" */ 707, /* "secp128r2" */ 708, /* "secp160k1" */ 709, /* "secp160r1" */ 710, /* "secp160r2" */ 711, /* "secp192k1" */ 712, /* "secp224k1" */ 713, /* "secp224r1" */ 714, /* "secp256k1" */ 715, /* "secp384r1" */ 716, /* "secp521r1" */ 154, /* "secretBag" */ 474, /* "secretary" */ 717, /* "sect113r1" */ 718, /* "sect113r2" */ 719, /* "sect131r1" */ 720, /* "sect131r2" */ 721, /* "sect163k1" */ 722, /* "sect163r1" */ 723, /* "sect163r2" */ 724, /* "sect193r1" */ 725, /* "sect193r2" */ 726, /* "sect233k1" */ 727, /* "sect233r1" */ 728, /* "sect239k1" */ 729, /* "sect283k1" */ 730, /* "sect283r1" */ 731, /* "sect409k1" */ 732, /* "sect409r1" */ 733, /* "sect571k1" */ 734, /* "sect571r1" */ 386, /* "security" */ 878, /* "seeAlso" */ 394, /* "selected-attribute-types" */ 105, /* "serialNumber" */ 129, /* "serverAuth" */ 371, /* "serviceLocator" */ 625, /* "set-addPolicy" */ 515, /* "set-attr" */ 518, /* "set-brand" */ 638, /* "set-brand-AmericanExpress" */ 637, /* "set-brand-Diners" */ 636, /* "set-brand-IATA-ATA" */ 639, /* "set-brand-JCB" */ 641, /* "set-brand-MasterCard" */ 642, /* "set-brand-Novus" */ 640, /* "set-brand-Visa" */ 517, /* "set-certExt" */ 513, /* "set-ctype" */ 514, /* "set-msgExt" */ 516, /* "set-policy" */ 607, /* "set-policy-root" */ 624, /* "set-rootKeyThumb" */ 620, /* "setAttr-Cert" */ 631, /* "setAttr-GenCryptgrm" */ 623, /* "setAttr-IssCap" */ 628, /* "setAttr-IssCap-CVM" */ 630, /* "setAttr-IssCap-Sig" */ 629, /* "setAttr-IssCap-T2" */ 621, /* "setAttr-PGWYcap" */ 635, /* "setAttr-SecDevSig" */ 632, /* "setAttr-T2Enc" */ 633, /* "setAttr-T2cleartxt" */ 634, /* "setAttr-TokICCsig" */ 627, /* "setAttr-Token-B0Prime" */ 626, /* "setAttr-Token-EMV" */ 622, /* "setAttr-TokenType" */ 619, /* "setCext-IssuerCapabilities" */ 615, /* "setCext-PGWYcapabilities" */ 616, /* "setCext-TokenIdentifier" */ 618, /* "setCext-TokenType" */ 617, /* "setCext-Track2Data" */ 611, /* "setCext-cCertRequired" */ 609, /* "setCext-certType" */ 608, /* "setCext-hashedRoot" */ 610, /* "setCext-merchData" */ 613, /* "setCext-setExt" */ 614, /* "setCext-setQualf" */ 612, /* "setCext-tunneling" */ 540, /* "setct-AcqCardCodeMsg" */ 576, /* "setct-AcqCardCodeMsgTBE" */ 570, /* "setct-AuthReqTBE" */ 534, /* "setct-AuthReqTBS" */ 527, /* "setct-AuthResBaggage" */ 571, /* "setct-AuthResTBE" */ 572, /* "setct-AuthResTBEX" */ 535, /* "setct-AuthResTBS" */ 536, /* "setct-AuthResTBSX" */ 528, /* "setct-AuthRevReqBaggage" */ 577, /* "setct-AuthRevReqTBE" */ 541, /* "setct-AuthRevReqTBS" */ 529, /* "setct-AuthRevResBaggage" */ 542, /* "setct-AuthRevResData" */ 578, /* "setct-AuthRevResTBE" */ 579, /* "setct-AuthRevResTBEB" */ 543, /* "setct-AuthRevResTBS" */ 573, /* "setct-AuthTokenTBE" */ 537, /* "setct-AuthTokenTBS" */ 600, /* "setct-BCIDistributionTBS" */ 558, /* "setct-BatchAdminReqData" */ 592, /* "setct-BatchAdminReqTBE" */ 559, /* "setct-BatchAdminResData" */ 593, /* "setct-BatchAdminResTBE" */ 599, /* "setct-CRLNotificationResTBS" */ 598, /* "setct-CRLNotificationTBS" */ 580, /* "setct-CapReqTBE" */ 581, /* "setct-CapReqTBEX" */ 544, /* "setct-CapReqTBS" */ 545, /* "setct-CapReqTBSX" */ 546, /* "setct-CapResData" */ 582, /* "setct-CapResTBE" */ 583, /* "setct-CapRevReqTBE" */ 584, /* "setct-CapRevReqTBEX" */ 547, /* "setct-CapRevReqTBS" */ 548, /* "setct-CapRevReqTBSX" */ 549, /* "setct-CapRevResData" */ 585, /* "setct-CapRevResTBE" */ 538, /* "setct-CapTokenData" */ 530, /* "setct-CapTokenSeq" */ 574, /* "setct-CapTokenTBE" */ 575, /* "setct-CapTokenTBEX" */ 539, /* "setct-CapTokenTBS" */ 560, /* "setct-CardCInitResTBS" */ 566, /* "setct-CertInqReqTBS" */ 563, /* "setct-CertReqData" */ 595, /* "setct-CertReqTBE" */ 596, /* "setct-CertReqTBEX" */ 564, /* "setct-CertReqTBS" */ 565, /* "setct-CertResData" */ 597, /* "setct-CertResTBE" */ 586, /* "setct-CredReqTBE" */ 587, /* "setct-CredReqTBEX" */ 550, /* "setct-CredReqTBS" */ 551, /* "setct-CredReqTBSX" */ 552, /* "setct-CredResData" */ 588, /* "setct-CredResTBE" */ 589, /* "setct-CredRevReqTBE" */ 590, /* "setct-CredRevReqTBEX" */ 553, /* "setct-CredRevReqTBS" */ 554, /* "setct-CredRevReqTBSX" */ 555, /* "setct-CredRevResData" */ 591, /* "setct-CredRevResTBE" */ 567, /* "setct-ErrorTBS" */ 526, /* "setct-HODInput" */ 561, /* "setct-MeAqCInitResTBS" */ 522, /* "setct-OIData" */ 519, /* "setct-PANData" */ 521, /* "setct-PANOnly" */ 520, /* "setct-PANToken" */ 556, /* "setct-PCertReqData" */ 557, /* "setct-PCertResTBS" */ 523, /* "setct-PI" */ 532, /* "setct-PI-TBS" */ 524, /* "setct-PIData" */ 525, /* "setct-PIDataUnsigned" */ 568, /* "setct-PIDualSignedTBE" */ 569, /* "setct-PIUnsignedTBE" */ 531, /* "setct-PInitResData" */ 533, /* "setct-PResData" */ 594, /* "setct-RegFormReqTBE" */ 562, /* "setct-RegFormResTBS" */ 606, /* "setext-cv" */ 601, /* "setext-genCrypt" */ 602, /* "setext-miAuth" */ 604, /* "setext-pinAny" */ 603, /* "setext-pinSecure" */ 605, /* "setext-track2" */ 52, /* "signingTime" */ 454, /* "simpleSecurityObject" */ 496, /* "singleLevelQuality" */ 387, /* "snmpv2" */ 660, /* "street" */ 85, /* "subjectAltName" */ 769, /* "subjectDirectoryAttributes" */ 398, /* "subjectInfoAccess" */ 82, /* "subjectKeyIdentifier" */ 498, /* "subtreeMaximumQuality" */ 497, /* "subtreeMinimumQuality" */ 890, /* "supportedAlgorithms" */ 874, /* "supportedApplicationContext" */ 402, /* "targetInformation" */ 864, /* "telephoneNumber" */ 866, /* "teletexTerminalIdentifier" */ 920, /* "teletrust" */ 865, /* "telexNumber" */ 459, /* "textEncodedORAddress" */ 293, /* "textNotice" */ 133, /* "timeStamping" */ 106, /* "title" */ 682, /* "tpBasis" */ 375, /* "trustRoot" */ 436, /* "ucl" */ 888, /* "uniqueMember" */ 55, /* "unstructuredAddress" */ 49, /* "unstructuredName" */ 880, /* "userCertificate" */ 465, /* "userClass" */ 879, /* "userPassword" */ 373, /* "valid" */ 678, /* "wap" */ 679, /* "wap-wsg" */ 735, /* "wap-wsg-idm-ecid-wtls1" */ 743, /* "wap-wsg-idm-ecid-wtls10" */ 744, /* "wap-wsg-idm-ecid-wtls11" */ 745, /* "wap-wsg-idm-ecid-wtls12" */ 736, /* "wap-wsg-idm-ecid-wtls3" */ 737, /* "wap-wsg-idm-ecid-wtls4" */ 738, /* "wap-wsg-idm-ecid-wtls5" */ 739, /* "wap-wsg-idm-ecid-wtls6" */ 740, /* "wap-wsg-idm-ecid-wtls7" */ 741, /* "wap-wsg-idm-ecid-wtls8" */ 742, /* "wap-wsg-idm-ecid-wtls9" */ 804, /* "whirlpool" */ 868, /* "x121Address" */ 503, /* "x500UniqueIdentifier" */ 158, /* "x509Certificate" */ 160, /* "x509Crl" */ }; static const unsigned int ln_objs[NUM_LN]={ 363, /* "AD Time Stamping" */ 405, /* "ANSI X9.62" */ 368, /* "Acceptable OCSP Responses" */ 910, /* "Any Extended Key Usage" */ 664, /* "Any language" */ 177, /* "Authority Information Access" */ 365, /* "Basic OCSP Response" */ 285, /* "Biometric Info" */ 179, /* "CA Issuers" */ 785, /* "CA Repository" */ 131, /* "Code Signing" */ 783, /* "Diffie-Hellman based MAC" */ 382, /* "Directory" */ 392, /* "Domain" */ 132, /* "E-mail Protection" */ 389, /* "Enterprises" */ 384, /* "Experimental" */ 372, /* "Extended OCSP Status" */ 172, /* "Extension Request" */ 936, /* "FRP256v1" */ 813, /* "GOST 28147-89" */ 849, /* "GOST 28147-89 Cryptocom ParamSet" */ 815, /* "GOST 28147-89 MAC" */ 851, /* "GOST 34.10-2001 Cryptocom" */ 850, /* "GOST 34.10-94 Cryptocom" */ 811, /* "GOST R 34.10-2001" */ 817, /* "GOST R 34.10-2001 DH" */ 812, /* "GOST R 34.10-94" */ 818, /* "GOST R 34.10-94 DH" */ 809, /* "GOST R 34.11-94" */ 816, /* "GOST R 34.11-94 PRF" */ 807, /* "GOST R 34.11-94 with GOST R 34.10-2001" */ 853, /* "GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom" */ 808, /* "GOST R 34.11-94 with GOST R 34.10-94" */ 852, /* "GOST R 34.11-94 with GOST R 34.10-94 Cryptocom" */ 854, /* "GOST R 3410-2001 Parameter Set Cryptocom" */ 810, /* "HMAC GOST 34.11-94" */ 432, /* "Hold Instruction Call Issuer" */ 430, /* "Hold Instruction Code" */ 431, /* "Hold Instruction None" */ 433, /* "Hold Instruction Reject" */ 634, /* "ICC or token signature" */ 294, /* "IPSec End System" */ 295, /* "IPSec Tunnel" */ 296, /* "IPSec User" */ 182, /* "ISO Member Body" */ 183, /* "ISO US Member Body" */ 667, /* "Independent" */ 665, /* "Inherit all" */ 647, /* "International Organizations" */ 142, /* "Invalidity Date" */ 504, /* "MIME MHS" */ 388, /* "Mail" */ 383, /* "Management" */ 417, /* "Microsoft CSP Name" */ 135, /* "Microsoft Commercial Code Signing" */ 138, /* "Microsoft Encrypted File System" */ 171, /* "Microsoft Extension Request" */ 134, /* "Microsoft Individual Code Signing" */ 856, /* "Microsoft Local Key set" */ 137, /* "Microsoft Server Gated Crypto" */ 648, /* "Microsoft Smartcardlogin" */ 136, /* "Microsoft Trust List Signing" */ 649, /* "Microsoft Universal Principal Name" */ 393, /* "NULL" */ 404, /* "NULL" */ 72, /* "Netscape Base Url" */ 76, /* "Netscape CA Policy Url" */ 74, /* "Netscape CA Revocation Url" */ 71, /* "Netscape Cert Type" */ 58, /* "Netscape Certificate Extension" */ 79, /* "Netscape Certificate Sequence" */ 78, /* "Netscape Comment" */ 57, /* "Netscape Communications Corp." */ 59, /* "Netscape Data Type" */ 75, /* "Netscape Renewal Url" */ 73, /* "Netscape Revocation Url" */ 77, /* "Netscape SSL Server Name" */ 139, /* "Netscape Server Gated Crypto" */ 178, /* "OCSP" */ 370, /* "OCSP Archive Cutoff" */ 367, /* "OCSP CRL ID" */ 369, /* "OCSP No Check" */ 366, /* "OCSP Nonce" */ 371, /* "OCSP Service Locator" */ 180, /* "OCSP Signing" */ 161, /* "PBES2" */ 69, /* "PBKDF2" */ 162, /* "PBMAC1" */ 127, /* "PKIX" */ 858, /* "Permanent Identifier" */ 164, /* "Policy Qualifier CPS" */ 165, /* "Policy Qualifier User Notice" */ 385, /* "Private" */ 663, /* "Proxy Certificate Information" */ 1, /* "RSA Data Security, Inc." */ 2, /* "RSA Data Security, Inc. PKCS" */ 188, /* "S/MIME" */ 167, /* "S/MIME Capabilities" */ 387, /* "SNMPv2" */ 512, /* "Secure Electronic Transactions" */ 386, /* "Security" */ 394, /* "Selected Attribute Types" */ 143, /* "Strong Extranet ID" */ 398, /* "Subject Information Access" */ 130, /* "TLS Web Client Authentication" */ 129, /* "TLS Web Server Authentication" */ 133, /* "Time Stamping" */ 375, /* "Trust Root" */ 12, /* "X509" */ 402, /* "X509v3 AC Targeting" */ 746, /* "X509v3 Any Policy" */ 90, /* "X509v3 Authority Key Identifier" */ 87, /* "X509v3 Basic Constraints" */ 103, /* "X509v3 CRL Distribution Points" */ 88, /* "X509v3 CRL Number" */ 141, /* "X509v3 CRL Reason Code" */ 771, /* "X509v3 Certificate Issuer" */ 89, /* "X509v3 Certificate Policies" */ 140, /* "X509v3 Delta CRL Indicator" */ 126, /* "X509v3 Extended Key Usage" */ 857, /* "X509v3 Freshest CRL" */ 748, /* "X509v3 Inhibit Any Policy" */ 86, /* "X509v3 Issuer Alternative Name" */ 770, /* "X509v3 Issuing Distrubution Point" */ 83, /* "X509v3 Key Usage" */ 666, /* "X509v3 Name Constraints" */ 403, /* "X509v3 No Revocation Available" */ 401, /* "X509v3 Policy Constraints" */ 747, /* "X509v3 Policy Mappings" */ 84, /* "X509v3 Private Key Usage Period" */ 85, /* "X509v3 Subject Alternative Name" */ 769, /* "X509v3 Subject Directory Attributes" */ 82, /* "X509v3 Subject Key Identifier" */ 184, /* "X9.57" */ 185, /* "X9.57 CM ?" */ 478, /* "aRecord" */ 289, /* "aaControls" */ 287, /* "ac-auditEntity" */ 397, /* "ac-proxying" */ 288, /* "ac-targeting" */ 446, /* "account" */ 364, /* "ad dvcs" */ 606, /* "additional verification" */ 419, /* "aes-128-cbc" */ 916, /* "aes-128-cbc-hmac-sha1" */ 896, /* "aes-128-ccm" */ 421, /* "aes-128-cfb" */ 650, /* "aes-128-cfb1" */ 653, /* "aes-128-cfb8" */ 904, /* "aes-128-ctr" */ 418, /* "aes-128-ecb" */ 895, /* "aes-128-gcm" */ 420, /* "aes-128-ofb" */ 913, /* "aes-128-xts" */ 423, /* "aes-192-cbc" */ 917, /* "aes-192-cbc-hmac-sha1" */ 899, /* "aes-192-ccm" */ 425, /* "aes-192-cfb" */ 651, /* "aes-192-cfb1" */ 654, /* "aes-192-cfb8" */ 905, /* "aes-192-ctr" */ 422, /* "aes-192-ecb" */ 898, /* "aes-192-gcm" */ 424, /* "aes-192-ofb" */ 427, /* "aes-256-cbc" */ 918, /* "aes-256-cbc-hmac-sha1" */ 902, /* "aes-256-ccm" */ 429, /* "aes-256-cfb" */ 652, /* "aes-256-cfb1" */ 655, /* "aes-256-cfb8" */ 906, /* "aes-256-ctr" */ 426, /* "aes-256-ecb" */ 901, /* "aes-256-gcm" */ 428, /* "aes-256-ofb" */ 914, /* "aes-256-xts" */ 376, /* "algorithm" */ 484, /* "associatedDomain" */ 485, /* "associatedName" */ 501, /* "audio" */ 882, /* "authorityRevocationList" */ 91, /* "bf-cbc" */ 93, /* "bf-cfb" */ 92, /* "bf-ecb" */ 94, /* "bf-ofb" */ 921, /* "brainpool" */ 922, /* "brainpoolP160r1" */ 923, /* "brainpoolP160t1" */ 924, /* "brainpoolP192r1" */ 925, /* "brainpoolP192t1" */ 926, /* "brainpoolP224r1" */ 927, /* "brainpoolP224t1" */ 928, /* "brainpoolP256r1" */ 929, /* "brainpoolP256t1" */ 930, /* "brainpoolP320r1" */ 931, /* "brainpoolP320t1" */ 932, /* "brainpoolP384r1" */ 933, /* "brainpoolP384t1" */ 934, /* "brainpoolP512r1" */ 935, /* "brainpoolP512t1" */ 494, /* "buildingName" */ 860, /* "businessCategory" */ 691, /* "c2onb191v4" */ 692, /* "c2onb191v5" */ 697, /* "c2onb239v4" */ 698, /* "c2onb239v5" */ 684, /* "c2pnb163v1" */ 685, /* "c2pnb163v2" */ 686, /* "c2pnb163v3" */ 687, /* "c2pnb176v1" */ 693, /* "c2pnb208w1" */ 699, /* "c2pnb272w1" */ 700, /* "c2pnb304w1" */ 702, /* "c2pnb368w1" */ 688, /* "c2tnb191v1" */ 689, /* "c2tnb191v2" */ 690, /* "c2tnb191v3" */ 694, /* "c2tnb239v1" */ 695, /* "c2tnb239v2" */ 696, /* "c2tnb239v3" */ 701, /* "c2tnb359v1" */ 703, /* "c2tnb431r1" */ 881, /* "cACertificate" */ 483, /* "cNAMERecord" */ 751, /* "camellia-128-cbc" */ 757, /* "camellia-128-cfb" */ 760, /* "camellia-128-cfb1" */ 763, /* "camellia-128-cfb8" */ 754, /* "camellia-128-ecb" */ 766, /* "camellia-128-ofb" */ 752, /* "camellia-192-cbc" */ 758, /* "camellia-192-cfb" */ 761, /* "camellia-192-cfb1" */ 764, /* "camellia-192-cfb8" */ 755, /* "camellia-192-ecb" */ 767, /* "camellia-192-ofb" */ 753, /* "camellia-256-cbc" */ 759, /* "camellia-256-cfb" */ 762, /* "camellia-256-cfb1" */ 765, /* "camellia-256-cfb8" */ 756, /* "camellia-256-ecb" */ 768, /* "camellia-256-ofb" */ 443, /* "caseIgnoreIA5StringSyntax" */ 108, /* "cast5-cbc" */ 110, /* "cast5-cfb" */ 109, /* "cast5-ecb" */ 111, /* "cast5-ofb" */ 152, /* "certBag" */ 677, /* "certicom-arc" */ 517, /* "certificate extensions" */ 883, /* "certificateRevocationList" */ 937, /* "chacha" */ 54, /* "challengePassword" */ 407, /* "characteristic-two-field" */ 395, /* "clearance" */ 633, /* "cleartext track 2" */ 894, /* "cmac" */ 13, /* "commonName" */ 513, /* "content types" */ 50, /* "contentType" */ 53, /* "countersignature" */ 14, /* "countryName" */ 153, /* "crlBag" */ 884, /* "crossCertificatePair" */ 806, /* "cryptocom" */ 805, /* "cryptopro" */ 500, /* "dITRedirect" */ 451, /* "dNSDomain" */ 495, /* "dSAQuality" */ 434, /* "data" */ 390, /* "dcObject" */ 891, /* "deltaRevocationList" */ 31, /* "des-cbc" */ 643, /* "des-cdmf" */ 30, /* "des-cfb" */ 656, /* "des-cfb1" */ 657, /* "des-cfb8" */ 29, /* "des-ecb" */ 32, /* "des-ede" */ 43, /* "des-ede-cbc" */ 60, /* "des-ede-cfb" */ 62, /* "des-ede-ofb" */ 33, /* "des-ede3" */ 44, /* "des-ede3-cbc" */ 61, /* "des-ede3-cfb" */ 658, /* "des-ede3-cfb1" */ 659, /* "des-ede3-cfb8" */ 63, /* "des-ede3-ofb" */ 45, /* "des-ofb" */ 107, /* "description" */ 871, /* "destinationIndicator" */ 80, /* "desx-cbc" */ 28, /* "dhKeyAgreement" */ 11, /* "directory services (X.500)" */ 378, /* "directory services - algorithms" */ 887, /* "distinguishedName" */ 892, /* "dmdName" */ 174, /* "dnQualifier" */ 447, /* "document" */ 471, /* "documentAuthor" */ 468, /* "documentIdentifier" */ 472, /* "documentLocation" */ 502, /* "documentPublisher" */ 449, /* "documentSeries" */ 469, /* "documentTitle" */ 470, /* "documentVersion" */ 380, /* "dod" */ 391, /* "domainComponent" */ 452, /* "domainRelatedObject" */ 116, /* "dsaEncryption" */ 67, /* "dsaEncryption-old" */ 66, /* "dsaWithSHA" */ 113, /* "dsaWithSHA1" */ 70, /* "dsaWithSHA1-old" */ 802, /* "dsa_with_SHA224" */ 803, /* "dsa_with_SHA256" */ 297, /* "dvcs" */ 791, /* "ecdsa-with-Recommended" */ 416, /* "ecdsa-with-SHA1" */ 793, /* "ecdsa-with-SHA224" */ 794, /* "ecdsa-with-SHA256" */ 795, /* "ecdsa-with-SHA384" */ 796, /* "ecdsa-with-SHA512" */ 792, /* "ecdsa-with-Specified" */ 48, /* "emailAddress" */ 632, /* "encrypted track 2" */ 885, /* "enhancedSearchGuide" */ 56, /* "extendedCertificateAttributes" */ 867, /* "facsimileTelephoneNumber" */ 462, /* "favouriteDrink" */ 453, /* "friendlyCountry" */ 490, /* "friendlyCountryName" */ 156, /* "friendlyName" */ 631, /* "generate cryptogram" */ 509, /* "generationQualifier" */ 601, /* "generic cryptogram" */ 99, /* "givenName" */ 814, /* "gost89-cnt" */ 855, /* "hmac" */ 780, /* "hmac-md5" */ 781, /* "hmac-sha1" */ 797, /* "hmacWithMD5" */ 163, /* "hmacWithSHA1" */ 798, /* "hmacWithSHA224" */ 799, /* "hmacWithSHA256" */ 800, /* "hmacWithSHA384" */ 801, /* "hmacWithSHA512" */ 486, /* "homePostalAddress" */ 473, /* "homeTelephoneNumber" */ 466, /* "host" */ 889, /* "houseIdentifier" */ 442, /* "iA5StringSyntax" */ 381, /* "iana" */ 824, /* "id-Gost28147-89-CryptoPro-A-ParamSet" */ 825, /* "id-Gost28147-89-CryptoPro-B-ParamSet" */ 826, /* "id-Gost28147-89-CryptoPro-C-ParamSet" */ 827, /* "id-Gost28147-89-CryptoPro-D-ParamSet" */ 819, /* "id-Gost28147-89-CryptoPro-KeyMeshing" */ 829, /* "id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet" */ 828, /* "id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet" */ 830, /* "id-Gost28147-89-CryptoPro-RIC-1-ParamSet" */ 820, /* "id-Gost28147-89-None-KeyMeshing" */ 823, /* "id-Gost28147-89-TestParamSet" */ 840, /* "id-GostR3410-2001-CryptoPro-A-ParamSet" */ 841, /* "id-GostR3410-2001-CryptoPro-B-ParamSet" */ 842, /* "id-GostR3410-2001-CryptoPro-C-ParamSet" */ 843, /* "id-GostR3410-2001-CryptoPro-XchA-ParamSet" */ 844, /* "id-GostR3410-2001-CryptoPro-XchB-ParamSet" */ 839, /* "id-GostR3410-2001-TestParamSet" */ 832, /* "id-GostR3410-94-CryptoPro-A-ParamSet" */ 833, /* "id-GostR3410-94-CryptoPro-B-ParamSet" */ 834, /* "id-GostR3410-94-CryptoPro-C-ParamSet" */ 835, /* "id-GostR3410-94-CryptoPro-D-ParamSet" */ 836, /* "id-GostR3410-94-CryptoPro-XchA-ParamSet" */ 837, /* "id-GostR3410-94-CryptoPro-XchB-ParamSet" */ 838, /* "id-GostR3410-94-CryptoPro-XchC-ParamSet" */ 831, /* "id-GostR3410-94-TestParamSet" */ 845, /* "id-GostR3410-94-a" */ 846, /* "id-GostR3410-94-aBis" */ 847, /* "id-GostR3410-94-b" */ 848, /* "id-GostR3410-94-bBis" */ 822, /* "id-GostR3411-94-CryptoProParamSet" */ 821, /* "id-GostR3411-94-TestParamSet" */ 266, /* "id-aca" */ 355, /* "id-aca-accessIdentity" */ 354, /* "id-aca-authenticationInfo" */ 356, /* "id-aca-chargingIdentity" */ 399, /* "id-aca-encAttrs" */ 357, /* "id-aca-group" */ 358, /* "id-aca-role" */ 176, /* "id-ad" */ 788, /* "id-aes128-wrap" */ 897, /* "id-aes128-wrap-pad" */ 789, /* "id-aes192-wrap" */ 900, /* "id-aes192-wrap-pad" */ 790, /* "id-aes256-wrap" */ 903, /* "id-aes256-wrap-pad" */ 262, /* "id-alg" */ 893, /* "id-alg-PWRI-KEK" */ 323, /* "id-alg-des40" */ 326, /* "id-alg-dh-pop" */ 325, /* "id-alg-dh-sig-hmac-sha1" */ 324, /* "id-alg-noSignature" */ 907, /* "id-camellia128-wrap" */ 908, /* "id-camellia192-wrap" */ 909, /* "id-camellia256-wrap" */ 268, /* "id-cct" */ 361, /* "id-cct-PKIData" */ 362, /* "id-cct-PKIResponse" */ 360, /* "id-cct-crs" */ 81, /* "id-ce" */ 680, /* "id-characteristic-two-basis" */ 263, /* "id-cmc" */ 334, /* "id-cmc-addExtensions" */ 346, /* "id-cmc-confirmCertAcceptance" */ 330, /* "id-cmc-dataReturn" */ 336, /* "id-cmc-decryptedPOP" */ 335, /* "id-cmc-encryptedPOP" */ 339, /* "id-cmc-getCRL" */ 338, /* "id-cmc-getCert" */ 328, /* "id-cmc-identification" */ 329, /* "id-cmc-identityProof" */ 337, /* "id-cmc-lraPOPWitness" */ 344, /* "id-cmc-popLinkRandom" */ 345, /* "id-cmc-popLinkWitness" */ 343, /* "id-cmc-queryPending" */ 333, /* "id-cmc-recipientNonce" */ 341, /* "id-cmc-regInfo" */ 342, /* "id-cmc-responseInfo" */ 340, /* "id-cmc-revokeRequest" */ 332, /* "id-cmc-senderNonce" */ 327, /* "id-cmc-statusInfo" */ 331, /* "id-cmc-transactionId" */ 787, /* "id-ct-asciiTextWithCRLF" */ 408, /* "id-ecPublicKey" */ 508, /* "id-hex-multipart-message" */ 507, /* "id-hex-partial-message" */ 260, /* "id-it" */ 302, /* "id-it-caKeyUpdateInfo" */ 298, /* "id-it-caProtEncCert" */ 311, /* "id-it-confirmWaitTime" */ 303, /* "id-it-currentCRL" */ 300, /* "id-it-encKeyPairTypes" */ 310, /* "id-it-implicitConfirm" */ 308, /* "id-it-keyPairParamRep" */ 307, /* "id-it-keyPairParamReq" */ 312, /* "id-it-origPKIMessage" */ 301, /* "id-it-preferredSymmAlg" */ 309, /* "id-it-revPassphrase" */ 299, /* "id-it-signKeyPairTypes" */ 305, /* "id-it-subscriptionRequest" */ 306, /* "id-it-subscriptionResponse" */ 784, /* "id-it-suppLangTags" */ 304, /* "id-it-unsupportedOIDs" */ 128, /* "id-kp" */ 280, /* "id-mod-attribute-cert" */ 274, /* "id-mod-cmc" */ 277, /* "id-mod-cmp" */ 284, /* "id-mod-cmp2000" */ 273, /* "id-mod-crmf" */ 283, /* "id-mod-dvcs" */ 275, /* "id-mod-kea-profile-88" */ 276, /* "id-mod-kea-profile-93" */ 282, /* "id-mod-ocsp" */ 278, /* "id-mod-qualified-cert-88" */ 279, /* "id-mod-qualified-cert-93" */ 281, /* "id-mod-timestamp-protocol" */ 264, /* "id-on" */ 347, /* "id-on-personalData" */ 265, /* "id-pda" */ 352, /* "id-pda-countryOfCitizenship" */ 353, /* "id-pda-countryOfResidence" */ 348, /* "id-pda-dateOfBirth" */ 351, /* "id-pda-gender" */ 349, /* "id-pda-placeOfBirth" */ 175, /* "id-pe" */ 261, /* "id-pkip" */ 258, /* "id-pkix-mod" */ 269, /* "id-pkix1-explicit-88" */ 271, /* "id-pkix1-explicit-93" */ 270, /* "id-pkix1-implicit-88" */ 272, /* "id-pkix1-implicit-93" */ 662, /* "id-ppl" */ 267, /* "id-qcs" */ 359, /* "id-qcs-pkixQCSyntax-v1" */ 259, /* "id-qt" */ 313, /* "id-regCtrl" */ 316, /* "id-regCtrl-authenticator" */ 319, /* "id-regCtrl-oldCertID" */ 318, /* "id-regCtrl-pkiArchiveOptions" */ 317, /* "id-regCtrl-pkiPublicationInfo" */ 320, /* "id-regCtrl-protocolEncrKey" */ 315, /* "id-regCtrl-regToken" */ 314, /* "id-regInfo" */ 322, /* "id-regInfo-certReq" */ 321, /* "id-regInfo-utf8Pairs" */ 191, /* "id-smime-aa" */ 215, /* "id-smime-aa-contentHint" */ 218, /* "id-smime-aa-contentIdentifier" */ 221, /* "id-smime-aa-contentReference" */ 240, /* "id-smime-aa-dvcs-dvc" */ 217, /* "id-smime-aa-encapContentType" */ 222, /* "id-smime-aa-encrypKeyPref" */ 220, /* "id-smime-aa-equivalentLabels" */ 232, /* "id-smime-aa-ets-CertificateRefs" */ 233, /* "id-smime-aa-ets-RevocationRefs" */ 238, /* "id-smime-aa-ets-archiveTimeStamp" */ 237, /* "id-smime-aa-ets-certCRLTimestamp" */ 234, /* "id-smime-aa-ets-certValues" */ 227, /* "id-smime-aa-ets-commitmentType" */ 231, /* "id-smime-aa-ets-contentTimestamp" */ 236, /* "id-smime-aa-ets-escTimeStamp" */ 230, /* "id-smime-aa-ets-otherSigCert" */ 235, /* "id-smime-aa-ets-revocationValues" */ 226, /* "id-smime-aa-ets-sigPolicyId" */ 229, /* "id-smime-aa-ets-signerAttr" */ 228, /* "id-smime-aa-ets-signerLocation" */ 219, /* "id-smime-aa-macValue" */ 214, /* "id-smime-aa-mlExpandHistory" */ 216, /* "id-smime-aa-msgSigDigest" */ 212, /* "id-smime-aa-receiptRequest" */ 213, /* "id-smime-aa-securityLabel" */ 239, /* "id-smime-aa-signatureType" */ 223, /* "id-smime-aa-signingCertificate" */ 224, /* "id-smime-aa-smimeEncryptCerts" */ 225, /* "id-smime-aa-timeStampToken" */ 192, /* "id-smime-alg" */ 243, /* "id-smime-alg-3DESwrap" */ 246, /* "id-smime-alg-CMS3DESwrap" */ 247, /* "id-smime-alg-CMSRC2wrap" */ 245, /* "id-smime-alg-ESDH" */ 241, /* "id-smime-alg-ESDHwith3DES" */ 242, /* "id-smime-alg-ESDHwithRC2" */ 244, /* "id-smime-alg-RC2wrap" */ 193, /* "id-smime-cd" */ 248, /* "id-smime-cd-ldap" */ 190, /* "id-smime-ct" */ 210, /* "id-smime-ct-DVCSRequestData" */ 211, /* "id-smime-ct-DVCSResponseData" */ 208, /* "id-smime-ct-TDTInfo" */ 207, /* "id-smime-ct-TSTInfo" */ 205, /* "id-smime-ct-authData" */ 786, /* "id-smime-ct-compressedData" */ 209, /* "id-smime-ct-contentInfo" */ 206, /* "id-smime-ct-publishCert" */ 204, /* "id-smime-ct-receipt" */ 195, /* "id-smime-cti" */ 255, /* "id-smime-cti-ets-proofOfApproval" */ 256, /* "id-smime-cti-ets-proofOfCreation" */ 253, /* "id-smime-cti-ets-proofOfDelivery" */ 251, /* "id-smime-cti-ets-proofOfOrigin" */ 252, /* "id-smime-cti-ets-proofOfReceipt" */ 254, /* "id-smime-cti-ets-proofOfSender" */ 189, /* "id-smime-mod" */ 196, /* "id-smime-mod-cms" */ 197, /* "id-smime-mod-ess" */ 202, /* "id-smime-mod-ets-eSigPolicy-88" */ 203, /* "id-smime-mod-ets-eSigPolicy-97" */ 200, /* "id-smime-mod-ets-eSignature-88" */ 201, /* "id-smime-mod-ets-eSignature-97" */ 199, /* "id-smime-mod-msg-v3" */ 198, /* "id-smime-mod-oid" */ 194, /* "id-smime-spq" */ 250, /* "id-smime-spq-ets-sqt-unotice" */ 249, /* "id-smime-spq-ets-sqt-uri" */ 34, /* "idea-cbc" */ 35, /* "idea-cfb" */ 36, /* "idea-ecb" */ 46, /* "idea-ofb" */ 676, /* "identified-organization" */ 461, /* "info" */ 101, /* "initials" */ 869, /* "internationaliSDNNumber" */ 749, /* "ipsec3" */ 750, /* "ipsec4" */ 181, /* "iso" */ 623, /* "issuer capabilities" */ 645, /* "itu-t" */ 492, /* "janetMailbox" */ 646, /* "joint-iso-itu-t" */ 150, /* "keyBag" */ 773, /* "kisa" */ 477, /* "lastModifiedBy" */ 476, /* "lastModifiedTime" */ 157, /* "localKeyID" */ 15, /* "localityName" */ 480, /* "mXRecord" */ 493, /* "mailPreferenceOption" */ 467, /* "manager" */ 3, /* "md2" */ 7, /* "md2WithRSAEncryption" */ 257, /* "md4" */ 396, /* "md4WithRSAEncryption" */ 4, /* "md5" */ 114, /* "md5-sha1" */ 104, /* "md5WithRSA" */ 8, /* "md5WithRSAEncryption" */ 95, /* "mdc2" */ 96, /* "mdc2WithRSA" */ 875, /* "member" */ 602, /* "merchant initiated auth" */ 514, /* "message extensions" */ 51, /* "messageDigest" */ 911, /* "mgf1" */ 506, /* "mime-mhs-bodies" */ 505, /* "mime-mhs-headings" */ 488, /* "mobileTelephoneNumber" */ 481, /* "nSRecord" */ 173, /* "name" */ 681, /* "onBasis" */ 379, /* "org" */ 17, /* "organizationName" */ 491, /* "organizationalStatus" */ 18, /* "organizationalUnitName" */ 475, /* "otherMailbox" */ 876, /* "owner" */ 489, /* "pagerTelephoneNumber" */ 782, /* "password based MAC" */ 374, /* "path" */ 621, /* "payment gateway capabilities" */ 9, /* "pbeWithMD2AndDES-CBC" */ 168, /* "pbeWithMD2AndRC2-CBC" */ 112, /* "pbeWithMD5AndCast5CBC" */ 10, /* "pbeWithMD5AndDES-CBC" */ 169, /* "pbeWithMD5AndRC2-CBC" */ 148, /* "pbeWithSHA1And128BitRC2-CBC" */ 144, /* "pbeWithSHA1And128BitRC4" */ 147, /* "pbeWithSHA1And2-KeyTripleDES-CBC" */ 146, /* "pbeWithSHA1And3-KeyTripleDES-CBC" */ 149, /* "pbeWithSHA1And40BitRC2-CBC" */ 145, /* "pbeWithSHA1And40BitRC4" */ 170, /* "pbeWithSHA1AndDES-CBC" */ 68, /* "pbeWithSHA1AndRC2-CBC" */ 499, /* "personalSignature" */ 487, /* "personalTitle" */ 464, /* "photo" */ 863, /* "physicalDeliveryOfficeName" */ 437, /* "pilot" */ 439, /* "pilotAttributeSyntax" */ 438, /* "pilotAttributeType" */ 479, /* "pilotAttributeType27" */ 456, /* "pilotDSA" */ 441, /* "pilotGroups" */ 444, /* "pilotObject" */ 440, /* "pilotObjectClass" */ 455, /* "pilotOrganization" */ 445, /* "pilotPerson" */ 186, /* "pkcs1" */ 27, /* "pkcs3" */ 187, /* "pkcs5" */ 20, /* "pkcs7" */ 21, /* "pkcs7-data" */ 25, /* "pkcs7-digestData" */ 26, /* "pkcs7-encryptedData" */ 23, /* "pkcs7-envelopedData" */ 24, /* "pkcs7-signedAndEnvelopedData" */ 22, /* "pkcs7-signedData" */ 151, /* "pkcs8ShroudedKeyBag" */ 47, /* "pkcs9" */ 862, /* "postOfficeBox" */ 861, /* "postalAddress" */ 661, /* "postalCode" */ 683, /* "ppBasis" */ 872, /* "preferredDeliveryMethod" */ 873, /* "presentationAddress" */ 406, /* "prime-field" */ 409, /* "prime192v1" */ 410, /* "prime192v2" */ 411, /* "prime192v3" */ 412, /* "prime239v1" */ 413, /* "prime239v2" */ 414, /* "prime239v3" */ 415, /* "prime256v1" */ 886, /* "protocolInformation" */ 510, /* "pseudonym" */ 435, /* "pss" */ 286, /* "qcStatements" */ 457, /* "qualityLabelledData" */ 450, /* "rFC822localPart" */ 98, /* "rc2-40-cbc" */ 166, /* "rc2-64-cbc" */ 37, /* "rc2-cbc" */ 39, /* "rc2-cfb" */ 38, /* "rc2-ecb" */ 40, /* "rc2-ofb" */ 5, /* "rc4" */ 97, /* "rc4-40" */ 915, /* "rc4-hmac-md5" */ 120, /* "rc5-cbc" */ 122, /* "rc5-cfb" */ 121, /* "rc5-ecb" */ 123, /* "rc5-ofb" */ 870, /* "registeredAddress" */ 460, /* "rfc822Mailbox" */ 117, /* "ripemd160" */ 119, /* "ripemd160WithRSA" */ 400, /* "role" */ 877, /* "roleOccupant" */ 448, /* "room" */ 463, /* "roomNumber" */ 19, /* "rsa" */ 6, /* "rsaEncryption" */ 644, /* "rsaOAEPEncryptionSET" */ 377, /* "rsaSignature" */ 919, /* "rsaesOaep" */ 912, /* "rsassaPss" */ 124, /* "run length compression" */ 482, /* "sOARecord" */ 155, /* "safeContentsBag" */ 291, /* "sbgp-autonomousSysNum" */ 290, /* "sbgp-ipAddrBlock" */ 292, /* "sbgp-routerIdentifier" */ 159, /* "sdsiCertificate" */ 859, /* "searchGuide" */ 704, /* "secp112r1" */ 705, /* "secp112r2" */ 706, /* "secp128r1" */ 707, /* "secp128r2" */ 708, /* "secp160k1" */ 709, /* "secp160r1" */ 710, /* "secp160r2" */ 711, /* "secp192k1" */ 712, /* "secp224k1" */ 713, /* "secp224r1" */ 714, /* "secp256k1" */ 715, /* "secp384r1" */ 716, /* "secp521r1" */ 154, /* "secretBag" */ 474, /* "secretary" */ 717, /* "sect113r1" */ 718, /* "sect113r2" */ 719, /* "sect131r1" */ 720, /* "sect131r2" */ 721, /* "sect163k1" */ 722, /* "sect163r1" */ 723, /* "sect163r2" */ 724, /* "sect193r1" */ 725, /* "sect193r2" */ 726, /* "sect233k1" */ 727, /* "sect233r1" */ 728, /* "sect239k1" */ 729, /* "sect283k1" */ 730, /* "sect283r1" */ 731, /* "sect409k1" */ 732, /* "sect409r1" */ 733, /* "sect571k1" */ 734, /* "sect571r1" */ 635, /* "secure device signature" */ 878, /* "seeAlso" */ 777, /* "seed-cbc" */ 779, /* "seed-cfb" */ 776, /* "seed-ecb" */ 778, /* "seed-ofb" */ 105, /* "serialNumber" */ 625, /* "set-addPolicy" */ 515, /* "set-attr" */ 518, /* "set-brand" */ 638, /* "set-brand-AmericanExpress" */ 637, /* "set-brand-Diners" */ 636, /* "set-brand-IATA-ATA" */ 639, /* "set-brand-JCB" */ 641, /* "set-brand-MasterCard" */ 642, /* "set-brand-Novus" */ 640, /* "set-brand-Visa" */ 516, /* "set-policy" */ 607, /* "set-policy-root" */ 624, /* "set-rootKeyThumb" */ 620, /* "setAttr-Cert" */ 628, /* "setAttr-IssCap-CVM" */ 630, /* "setAttr-IssCap-Sig" */ 629, /* "setAttr-IssCap-T2" */ 627, /* "setAttr-Token-B0Prime" */ 626, /* "setAttr-Token-EMV" */ 622, /* "setAttr-TokenType" */ 619, /* "setCext-IssuerCapabilities" */ 615, /* "setCext-PGWYcapabilities" */ 616, /* "setCext-TokenIdentifier" */ 618, /* "setCext-TokenType" */ 617, /* "setCext-Track2Data" */ 611, /* "setCext-cCertRequired" */ 609, /* "setCext-certType" */ 608, /* "setCext-hashedRoot" */ 610, /* "setCext-merchData" */ 613, /* "setCext-setExt" */ 614, /* "setCext-setQualf" */ 612, /* "setCext-tunneling" */ 540, /* "setct-AcqCardCodeMsg" */ 576, /* "setct-AcqCardCodeMsgTBE" */ 570, /* "setct-AuthReqTBE" */ 534, /* "setct-AuthReqTBS" */ 527, /* "setct-AuthResBaggage" */ 571, /* "setct-AuthResTBE" */ 572, /* "setct-AuthResTBEX" */ 535, /* "setct-AuthResTBS" */ 536, /* "setct-AuthResTBSX" */ 528, /* "setct-AuthRevReqBaggage" */ 577, /* "setct-AuthRevReqTBE" */ 541, /* "setct-AuthRevReqTBS" */ 529, /* "setct-AuthRevResBaggage" */ 542, /* "setct-AuthRevResData" */ 578, /* "setct-AuthRevResTBE" */ 579, /* "setct-AuthRevResTBEB" */ 543, /* "setct-AuthRevResTBS" */ 573, /* "setct-AuthTokenTBE" */ 537, /* "setct-AuthTokenTBS" */ 600, /* "setct-BCIDistributionTBS" */ 558, /* "setct-BatchAdminReqData" */ 592, /* "setct-BatchAdminReqTBE" */ 559, /* "setct-BatchAdminResData" */ 593, /* "setct-BatchAdminResTBE" */ 599, /* "setct-CRLNotificationResTBS" */ 598, /* "setct-CRLNotificationTBS" */ 580, /* "setct-CapReqTBE" */ 581, /* "setct-CapReqTBEX" */ 544, /* "setct-CapReqTBS" */ 545, /* "setct-CapReqTBSX" */ 546, /* "setct-CapResData" */ 582, /* "setct-CapResTBE" */ 583, /* "setct-CapRevReqTBE" */ 584, /* "setct-CapRevReqTBEX" */ 547, /* "setct-CapRevReqTBS" */ 548, /* "setct-CapRevReqTBSX" */ 549, /* "setct-CapRevResData" */ 585, /* "setct-CapRevResTBE" */ 538, /* "setct-CapTokenData" */ 530, /* "setct-CapTokenSeq" */ 574, /* "setct-CapTokenTBE" */ 575, /* "setct-CapTokenTBEX" */ 539, /* "setct-CapTokenTBS" */ 560, /* "setct-CardCInitResTBS" */ 566, /* "setct-CertInqReqTBS" */ 563, /* "setct-CertReqData" */ 595, /* "setct-CertReqTBE" */ 596, /* "setct-CertReqTBEX" */ 564, /* "setct-CertReqTBS" */ 565, /* "setct-CertResData" */ 597, /* "setct-CertResTBE" */ 586, /* "setct-CredReqTBE" */ 587, /* "setct-CredReqTBEX" */ 550, /* "setct-CredReqTBS" */ 551, /* "setct-CredReqTBSX" */ 552, /* "setct-CredResData" */ 588, /* "setct-CredResTBE" */ 589, /* "setct-CredRevReqTBE" */ 590, /* "setct-CredRevReqTBEX" */ 553, /* "setct-CredRevReqTBS" */ 554, /* "setct-CredRevReqTBSX" */ 555, /* "setct-CredRevResData" */ 591, /* "setct-CredRevResTBE" */ 567, /* "setct-ErrorTBS" */ 526, /* "setct-HODInput" */ 561, /* "setct-MeAqCInitResTBS" */ 522, /* "setct-OIData" */ 519, /* "setct-PANData" */ 521, /* "setct-PANOnly" */ 520, /* "setct-PANToken" */ 556, /* "setct-PCertReqData" */ 557, /* "setct-PCertResTBS" */ 523, /* "setct-PI" */ 532, /* "setct-PI-TBS" */ 524, /* "setct-PIData" */ 525, /* "setct-PIDataUnsigned" */ 568, /* "setct-PIDualSignedTBE" */ 569, /* "setct-PIUnsignedTBE" */ 531, /* "setct-PInitResData" */ 533, /* "setct-PResData" */ 594, /* "setct-RegFormReqTBE" */ 562, /* "setct-RegFormResTBS" */ 604, /* "setext-pinAny" */ 603, /* "setext-pinSecure" */ 605, /* "setext-track2" */ 41, /* "sha" */ 64, /* "sha1" */ 115, /* "sha1WithRSA" */ 65, /* "sha1WithRSAEncryption" */ 675, /* "sha224" */ 671, /* "sha224WithRSAEncryption" */ 672, /* "sha256" */ 668, /* "sha256WithRSAEncryption" */ 673, /* "sha384" */ 669, /* "sha384WithRSAEncryption" */ 674, /* "sha512" */ 670, /* "sha512WithRSAEncryption" */ 42, /* "shaWithRSAEncryption" */ 52, /* "signingTime" */ 454, /* "simpleSecurityObject" */ 496, /* "singleLevelQuality" */ 16, /* "stateOrProvinceName" */ 660, /* "streetAddress" */ 498, /* "subtreeMaximumQuality" */ 497, /* "subtreeMinimumQuality" */ 890, /* "supportedAlgorithms" */ 874, /* "supportedApplicationContext" */ 100, /* "surname" */ 864, /* "telephoneNumber" */ 866, /* "teletexTerminalIdentifier" */ 920, /* "teletrust" */ 865, /* "telexNumber" */ 459, /* "textEncodedORAddress" */ 293, /* "textNotice" */ 106, /* "title" */ 682, /* "tpBasis" */ 436, /* "ucl" */ 0, /* "undefined" */ 888, /* "uniqueMember" */ 55, /* "unstructuredAddress" */ 49, /* "unstructuredName" */ 880, /* "userCertificate" */ 465, /* "userClass" */ 458, /* "userId" */ 879, /* "userPassword" */ 373, /* "valid" */ 678, /* "wap" */ 679, /* "wap-wsg" */ 735, /* "wap-wsg-idm-ecid-wtls1" */ 743, /* "wap-wsg-idm-ecid-wtls10" */ 744, /* "wap-wsg-idm-ecid-wtls11" */ 745, /* "wap-wsg-idm-ecid-wtls12" */ 736, /* "wap-wsg-idm-ecid-wtls3" */ 737, /* "wap-wsg-idm-ecid-wtls4" */ 738, /* "wap-wsg-idm-ecid-wtls5" */ 739, /* "wap-wsg-idm-ecid-wtls6" */ 740, /* "wap-wsg-idm-ecid-wtls7" */ 741, /* "wap-wsg-idm-ecid-wtls8" */ 742, /* "wap-wsg-idm-ecid-wtls9" */ 804, /* "whirlpool" */ 868, /* "x121Address" */ 503, /* "x500UniqueIdentifier" */ 158, /* "x509Certificate" */ 160, /* "x509Crl" */ 125, /* "zlib compression" */ }; static const unsigned int obj_objs[NUM_OBJ]={ 0, /* OBJ_undef 0 */ 181, /* OBJ_iso 1 */ 393, /* OBJ_joint_iso_ccitt OBJ_joint_iso_itu_t */ 404, /* OBJ_ccitt OBJ_itu_t */ 645, /* OBJ_itu_t 0 */ 646, /* OBJ_joint_iso_itu_t 2 */ 434, /* OBJ_data 0 9 */ 182, /* OBJ_member_body 1 2 */ 379, /* OBJ_org 1 3 */ 676, /* OBJ_identified_organization 1 3 */ 11, /* OBJ_X500 2 5 */ 647, /* OBJ_international_organizations 2 23 */ 380, /* OBJ_dod 1 3 6 */ 920, /* OBJ_teletrust 1 3 36 */ 12, /* OBJ_X509 2 5 4 */ 378, /* OBJ_X500algorithms 2 5 8 */ 81, /* OBJ_id_ce 2 5 29 */ 512, /* OBJ_id_set 2 23 42 */ 678, /* OBJ_wap 2 23 43 */ 435, /* OBJ_pss 0 9 2342 */ 183, /* OBJ_ISO_US 1 2 840 */ 381, /* OBJ_iana 1 3 6 1 */ 677, /* OBJ_certicom_arc 1 3 132 */ 394, /* OBJ_selected_attribute_types 2 5 1 5 */ 13, /* OBJ_commonName 2 5 4 3 */ 100, /* OBJ_surname 2 5 4 4 */ 105, /* OBJ_serialNumber 2 5 4 5 */ 14, /* OBJ_countryName 2 5 4 6 */ 15, /* OBJ_localityName 2 5 4 7 */ 16, /* OBJ_stateOrProvinceName 2 5 4 8 */ 660, /* OBJ_streetAddress 2 5 4 9 */ 17, /* OBJ_organizationName 2 5 4 10 */ 18, /* OBJ_organizationalUnitName 2 5 4 11 */ 106, /* OBJ_title 2 5 4 12 */ 107, /* OBJ_description 2 5 4 13 */ 859, /* OBJ_searchGuide 2 5 4 14 */ 860, /* OBJ_businessCategory 2 5 4 15 */ 861, /* OBJ_postalAddress 2 5 4 16 */ 661, /* OBJ_postalCode 2 5 4 17 */ 862, /* OBJ_postOfficeBox 2 5 4 18 */ 863, /* OBJ_physicalDeliveryOfficeName 2 5 4 19 */ 864, /* OBJ_telephoneNumber 2 5 4 20 */ 865, /* OBJ_telexNumber 2 5 4 21 */ 866, /* OBJ_teletexTerminalIdentifier 2 5 4 22 */ 867, /* OBJ_facsimileTelephoneNumber 2 5 4 23 */ 868, /* OBJ_x121Address 2 5 4 24 */ 869, /* OBJ_internationaliSDNNumber 2 5 4 25 */ 870, /* OBJ_registeredAddress 2 5 4 26 */ 871, /* OBJ_destinationIndicator 2 5 4 27 */ 872, /* OBJ_preferredDeliveryMethod 2 5 4 28 */ 873, /* OBJ_presentationAddress 2 5 4 29 */ 874, /* OBJ_supportedApplicationContext 2 5 4 30 */ 875, /* OBJ_member 2 5 4 31 */ 876, /* OBJ_owner 2 5 4 32 */ 877, /* OBJ_roleOccupant 2 5 4 33 */ 878, /* OBJ_seeAlso 2 5 4 34 */ 879, /* OBJ_userPassword 2 5 4 35 */ 880, /* OBJ_userCertificate 2 5 4 36 */ 881, /* OBJ_cACertificate 2 5 4 37 */ 882, /* OBJ_authorityRevocationList 2 5 4 38 */ 883, /* OBJ_certificateRevocationList 2 5 4 39 */ 884, /* OBJ_crossCertificatePair 2 5 4 40 */ 173, /* OBJ_name 2 5 4 41 */ 99, /* OBJ_givenName 2 5 4 42 */ 101, /* OBJ_initials 2 5 4 43 */ 509, /* OBJ_generationQualifier 2 5 4 44 */ 503, /* OBJ_x500UniqueIdentifier 2 5 4 45 */ 174, /* OBJ_dnQualifier 2 5 4 46 */ 885, /* OBJ_enhancedSearchGuide 2 5 4 47 */ 886, /* OBJ_protocolInformation 2 5 4 48 */ 887, /* OBJ_distinguishedName 2 5 4 49 */ 888, /* OBJ_uniqueMember 2 5 4 50 */ 889, /* OBJ_houseIdentifier 2 5 4 51 */ 890, /* OBJ_supportedAlgorithms 2 5 4 52 */ 891, /* OBJ_deltaRevocationList 2 5 4 53 */ 892, /* OBJ_dmdName 2 5 4 54 */ 510, /* OBJ_pseudonym 2 5 4 65 */ 400, /* OBJ_role 2 5 4 72 */ 769, /* OBJ_subject_directory_attributes 2 5 29 9 */ 82, /* OBJ_subject_key_identifier 2 5 29 14 */ 83, /* OBJ_key_usage 2 5 29 15 */ 84, /* OBJ_private_key_usage_period 2 5 29 16 */ 85, /* OBJ_subject_alt_name 2 5 29 17 */ 86, /* OBJ_issuer_alt_name 2 5 29 18 */ 87, /* OBJ_basic_constraints 2 5 29 19 */ 88, /* OBJ_crl_number 2 5 29 20 */ 141, /* OBJ_crl_reason 2 5 29 21 */ 430, /* OBJ_hold_instruction_code 2 5 29 23 */ 142, /* OBJ_invalidity_date 2 5 29 24 */ 140, /* OBJ_delta_crl 2 5 29 27 */ 770, /* OBJ_issuing_distribution_point 2 5 29 28 */ 771, /* OBJ_certificate_issuer 2 5 29 29 */ 666, /* OBJ_name_constraints 2 5 29 30 */ 103, /* OBJ_crl_distribution_points 2 5 29 31 */ 89, /* OBJ_certificate_policies 2 5 29 32 */ 747, /* OBJ_policy_mappings 2 5 29 33 */ 90, /* OBJ_authority_key_identifier 2 5 29 35 */ 401, /* OBJ_policy_constraints 2 5 29 36 */ 126, /* OBJ_ext_key_usage 2 5 29 37 */ 857, /* OBJ_freshest_crl 2 5 29 46 */ 748, /* OBJ_inhibit_any_policy 2 5 29 54 */ 402, /* OBJ_target_information 2 5 29 55 */ 403, /* OBJ_no_rev_avail 2 5 29 56 */ 513, /* OBJ_set_ctype 2 23 42 0 */ 514, /* OBJ_set_msgExt 2 23 42 1 */ 515, /* OBJ_set_attr 2 23 42 3 */ 516, /* OBJ_set_policy 2 23 42 5 */ 517, /* OBJ_set_certExt 2 23 42 7 */ 518, /* OBJ_set_brand 2 23 42 8 */ 679, /* OBJ_wap_wsg 2 23 43 1 */ 382, /* OBJ_Directory 1 3 6 1 1 */ 383, /* OBJ_Management 1 3 6 1 2 */ 384, /* OBJ_Experimental 1 3 6 1 3 */ 385, /* OBJ_Private 1 3 6 1 4 */ 386, /* OBJ_Security 1 3 6 1 5 */ 387, /* OBJ_SNMPv2 1 3 6 1 6 */ 388, /* OBJ_Mail 1 3 6 1 7 */ 376, /* OBJ_algorithm 1 3 14 3 2 */ 395, /* OBJ_clearance 2 5 1 5 55 */ 19, /* OBJ_rsa 2 5 8 1 1 */ 96, /* OBJ_mdc2WithRSA 2 5 8 3 100 */ 95, /* OBJ_mdc2 2 5 8 3 101 */ 746, /* OBJ_any_policy 2 5 29 32 0 */ 910, /* OBJ_anyExtendedKeyUsage 2 5 29 37 0 */ 519, /* OBJ_setct_PANData 2 23 42 0 0 */ 520, /* OBJ_setct_PANToken 2 23 42 0 1 */ 521, /* OBJ_setct_PANOnly 2 23 42 0 2 */ 522, /* OBJ_setct_OIData 2 23 42 0 3 */ 523, /* OBJ_setct_PI 2 23 42 0 4 */ 524, /* OBJ_setct_PIData 2 23 42 0 5 */ 525, /* OBJ_setct_PIDataUnsigned 2 23 42 0 6 */ 526, /* OBJ_setct_HODInput 2 23 42 0 7 */ 527, /* OBJ_setct_AuthResBaggage 2 23 42 0 8 */ 528, /* OBJ_setct_AuthRevReqBaggage 2 23 42 0 9 */ 529, /* OBJ_setct_AuthRevResBaggage 2 23 42 0 10 */ 530, /* OBJ_setct_CapTokenSeq 2 23 42 0 11 */ 531, /* OBJ_setct_PInitResData 2 23 42 0 12 */ 532, /* OBJ_setct_PI_TBS 2 23 42 0 13 */ 533, /* OBJ_setct_PResData 2 23 42 0 14 */ 534, /* OBJ_setct_AuthReqTBS 2 23 42 0 16 */ 535, /* OBJ_setct_AuthResTBS 2 23 42 0 17 */ 536, /* OBJ_setct_AuthResTBSX 2 23 42 0 18 */ 537, /* OBJ_setct_AuthTokenTBS 2 23 42 0 19 */ 538, /* OBJ_setct_CapTokenData 2 23 42 0 20 */ 539, /* OBJ_setct_CapTokenTBS 2 23 42 0 21 */ 540, /* OBJ_setct_AcqCardCodeMsg 2 23 42 0 22 */ 541, /* OBJ_setct_AuthRevReqTBS 2 23 42 0 23 */ 542, /* OBJ_setct_AuthRevResData 2 23 42 0 24 */ 543, /* OBJ_setct_AuthRevResTBS 2 23 42 0 25 */ 544, /* OBJ_setct_CapReqTBS 2 23 42 0 26 */ 545, /* OBJ_setct_CapReqTBSX 2 23 42 0 27 */ 546, /* OBJ_setct_CapResData 2 23 42 0 28 */ 547, /* OBJ_setct_CapRevReqTBS 2 23 42 0 29 */ 548, /* OBJ_setct_CapRevReqTBSX 2 23 42 0 30 */ 549, /* OBJ_setct_CapRevResData 2 23 42 0 31 */ 550, /* OBJ_setct_CredReqTBS 2 23 42 0 32 */ 551, /* OBJ_setct_CredReqTBSX 2 23 42 0 33 */ 552, /* OBJ_setct_CredResData 2 23 42 0 34 */ 553, /* OBJ_setct_CredRevReqTBS 2 23 42 0 35 */ 554, /* OBJ_setct_CredRevReqTBSX 2 23 42 0 36 */ 555, /* OBJ_setct_CredRevResData 2 23 42 0 37 */ 556, /* OBJ_setct_PCertReqData 2 23 42 0 38 */ 557, /* OBJ_setct_PCertResTBS 2 23 42 0 39 */ 558, /* OBJ_setct_BatchAdminReqData 2 23 42 0 40 */ 559, /* OBJ_setct_BatchAdminResData 2 23 42 0 41 */ 560, /* OBJ_setct_CardCInitResTBS 2 23 42 0 42 */ 561, /* OBJ_setct_MeAqCInitResTBS 2 23 42 0 43 */ 562, /* OBJ_setct_RegFormResTBS 2 23 42 0 44 */ 563, /* OBJ_setct_CertReqData 2 23 42 0 45 */ 564, /* OBJ_setct_CertReqTBS 2 23 42 0 46 */ 565, /* OBJ_setct_CertResData 2 23 42 0 47 */ 566, /* OBJ_setct_CertInqReqTBS 2 23 42 0 48 */ 567, /* OBJ_setct_ErrorTBS 2 23 42 0 49 */ 568, /* OBJ_setct_PIDualSignedTBE 2 23 42 0 50 */ 569, /* OBJ_setct_PIUnsignedTBE 2 23 42 0 51 */ 570, /* OBJ_setct_AuthReqTBE 2 23 42 0 52 */ 571, /* OBJ_setct_AuthResTBE 2 23 42 0 53 */ 572, /* OBJ_setct_AuthResTBEX 2 23 42 0 54 */ 573, /* OBJ_setct_AuthTokenTBE 2 23 42 0 55 */ 574, /* OBJ_setct_CapTokenTBE 2 23 42 0 56 */ 575, /* OBJ_setct_CapTokenTBEX 2 23 42 0 57 */ 576, /* OBJ_setct_AcqCardCodeMsgTBE 2 23 42 0 58 */ 577, /* OBJ_setct_AuthRevReqTBE 2 23 42 0 59 */ 578, /* OBJ_setct_AuthRevResTBE 2 23 42 0 60 */ 579, /* OBJ_setct_AuthRevResTBEB 2 23 42 0 61 */ 580, /* OBJ_setct_CapReqTBE 2 23 42 0 62 */ 581, /* OBJ_setct_CapReqTBEX 2 23 42 0 63 */ 582, /* OBJ_setct_CapResTBE 2 23 42 0 64 */ 583, /* OBJ_setct_CapRevReqTBE 2 23 42 0 65 */ 584, /* OBJ_setct_CapRevReqTBEX 2 23 42 0 66 */ 585, /* OBJ_setct_CapRevResTBE 2 23 42 0 67 */ 586, /* OBJ_setct_CredReqTBE 2 23 42 0 68 */ 587, /* OBJ_setct_CredReqTBEX 2 23 42 0 69 */ 588, /* OBJ_setct_CredResTBE 2 23 42 0 70 */ 589, /* OBJ_setct_CredRevReqTBE 2 23 42 0 71 */ 590, /* OBJ_setct_CredRevReqTBEX 2 23 42 0 72 */ 591, /* OBJ_setct_CredRevResTBE 2 23 42 0 73 */ 592, /* OBJ_setct_BatchAdminReqTBE 2 23 42 0 74 */ 593, /* OBJ_setct_BatchAdminResTBE 2 23 42 0 75 */ 594, /* OBJ_setct_RegFormReqTBE 2 23 42 0 76 */ 595, /* OBJ_setct_CertReqTBE 2 23 42 0 77 */ 596, /* OBJ_setct_CertReqTBEX 2 23 42 0 78 */ 597, /* OBJ_setct_CertResTBE 2 23 42 0 79 */ 598, /* OBJ_setct_CRLNotificationTBS 2 23 42 0 80 */ 599, /* OBJ_setct_CRLNotificationResTBS 2 23 42 0 81 */ 600, /* OBJ_setct_BCIDistributionTBS 2 23 42 0 82 */ 601, /* OBJ_setext_genCrypt 2 23 42 1 1 */ 602, /* OBJ_setext_miAuth 2 23 42 1 3 */ 603, /* OBJ_setext_pinSecure 2 23 42 1 4 */ 604, /* OBJ_setext_pinAny 2 23 42 1 5 */ 605, /* OBJ_setext_track2 2 23 42 1 7 */ 606, /* OBJ_setext_cv 2 23 42 1 8 */ 620, /* OBJ_setAttr_Cert 2 23 42 3 0 */ 621, /* OBJ_setAttr_PGWYcap 2 23 42 3 1 */ 622, /* OBJ_setAttr_TokenType 2 23 42 3 2 */ 623, /* OBJ_setAttr_IssCap 2 23 42 3 3 */ 607, /* OBJ_set_policy_root 2 23 42 5 0 */ 608, /* OBJ_setCext_hashedRoot 2 23 42 7 0 */ 609, /* OBJ_setCext_certType 2 23 42 7 1 */ 610, /* OBJ_setCext_merchData 2 23 42 7 2 */ 611, /* OBJ_setCext_cCertRequired 2 23 42 7 3 */ 612, /* OBJ_setCext_tunneling 2 23 42 7 4 */ 613, /* OBJ_setCext_setExt 2 23 42 7 5 */ 614, /* OBJ_setCext_setQualf 2 23 42 7 6 */ 615, /* OBJ_setCext_PGWYcapabilities 2 23 42 7 7 */ 616, /* OBJ_setCext_TokenIdentifier 2 23 42 7 8 */ 617, /* OBJ_setCext_Track2Data 2 23 42 7 9 */ 618, /* OBJ_setCext_TokenType 2 23 42 7 10 */ 619, /* OBJ_setCext_IssuerCapabilities 2 23 42 7 11 */ 636, /* OBJ_set_brand_IATA_ATA 2 23 42 8 1 */ 640, /* OBJ_set_brand_Visa 2 23 42 8 4 */ 641, /* OBJ_set_brand_MasterCard 2 23 42 8 5 */ 637, /* OBJ_set_brand_Diners 2 23 42 8 30 */ 638, /* OBJ_set_brand_AmericanExpress 2 23 42 8 34 */ 639, /* OBJ_set_brand_JCB 2 23 42 8 35 */ 805, /* OBJ_cryptopro 1 2 643 2 2 */ 806, /* OBJ_cryptocom 1 2 643 2 9 */ 184, /* OBJ_X9_57 1 2 840 10040 */ 405, /* OBJ_ansi_X9_62 1 2 840 10045 */ 389, /* OBJ_Enterprises 1 3 6 1 4 1 */ 504, /* OBJ_mime_mhs 1 3 6 1 7 1 */ 104, /* OBJ_md5WithRSA 1 3 14 3 2 3 */ 29, /* OBJ_des_ecb 1 3 14 3 2 6 */ 31, /* OBJ_des_cbc 1 3 14 3 2 7 */ 45, /* OBJ_des_ofb64 1 3 14 3 2 8 */ 30, /* OBJ_des_cfb64 1 3 14 3 2 9 */ 377, /* OBJ_rsaSignature 1 3 14 3 2 11 */ 67, /* OBJ_dsa_2 1 3 14 3 2 12 */ 66, /* OBJ_dsaWithSHA 1 3 14 3 2 13 */ 42, /* OBJ_shaWithRSAEncryption 1 3 14 3 2 15 */ 32, /* OBJ_des_ede_ecb 1 3 14 3 2 17 */ 41, /* OBJ_sha 1 3 14 3 2 18 */ 64, /* OBJ_sha1 1 3 14 3 2 26 */ 70, /* OBJ_dsaWithSHA1_2 1 3 14 3 2 27 */ 115, /* OBJ_sha1WithRSA 1 3 14 3 2 29 */ 117, /* OBJ_ripemd160 1 3 36 3 2 1 */ 143, /* OBJ_sxnet 1 3 101 1 4 1 */ 721, /* OBJ_sect163k1 1 3 132 0 1 */ 722, /* OBJ_sect163r1 1 3 132 0 2 */ 728, /* OBJ_sect239k1 1 3 132 0 3 */ 717, /* OBJ_sect113r1 1 3 132 0 4 */ 718, /* OBJ_sect113r2 1 3 132 0 5 */ 704, /* OBJ_secp112r1 1 3 132 0 6 */ 705, /* OBJ_secp112r2 1 3 132 0 7 */ 709, /* OBJ_secp160r1 1 3 132 0 8 */ 708, /* OBJ_secp160k1 1 3 132 0 9 */ 714, /* OBJ_secp256k1 1 3 132 0 10 */ 723, /* OBJ_sect163r2 1 3 132 0 15 */ 729, /* OBJ_sect283k1 1 3 132 0 16 */ 730, /* OBJ_sect283r1 1 3 132 0 17 */ 719, /* OBJ_sect131r1 1 3 132 0 22 */ 720, /* OBJ_sect131r2 1 3 132 0 23 */ 724, /* OBJ_sect193r1 1 3 132 0 24 */ 725, /* OBJ_sect193r2 1 3 132 0 25 */ 726, /* OBJ_sect233k1 1 3 132 0 26 */ 727, /* OBJ_sect233r1 1 3 132 0 27 */ 706, /* OBJ_secp128r1 1 3 132 0 28 */ 707, /* OBJ_secp128r2 1 3 132 0 29 */ 710, /* OBJ_secp160r2 1 3 132 0 30 */ 711, /* OBJ_secp192k1 1 3 132 0 31 */ 712, /* OBJ_secp224k1 1 3 132 0 32 */ 713, /* OBJ_secp224r1 1 3 132 0 33 */ 715, /* OBJ_secp384r1 1 3 132 0 34 */ 716, /* OBJ_secp521r1 1 3 132 0 35 */ 731, /* OBJ_sect409k1 1 3 132 0 36 */ 732, /* OBJ_sect409r1 1 3 132 0 37 */ 733, /* OBJ_sect571k1 1 3 132 0 38 */ 734, /* OBJ_sect571r1 1 3 132 0 39 */ 624, /* OBJ_set_rootKeyThumb 2 23 42 3 0 0 */ 625, /* OBJ_set_addPolicy 2 23 42 3 0 1 */ 626, /* OBJ_setAttr_Token_EMV 2 23 42 3 2 1 */ 627, /* OBJ_setAttr_Token_B0Prime 2 23 42 3 2 2 */ 628, /* OBJ_setAttr_IssCap_CVM 2 23 42 3 3 3 */ 629, /* OBJ_setAttr_IssCap_T2 2 23 42 3 3 4 */ 630, /* OBJ_setAttr_IssCap_Sig 2 23 42 3 3 5 */ 642, /* OBJ_set_brand_Novus 2 23 42 8 6011 */ 735, /* OBJ_wap_wsg_idm_ecid_wtls1 2 23 43 1 4 1 */ 736, /* OBJ_wap_wsg_idm_ecid_wtls3 2 23 43 1 4 3 */ 737, /* OBJ_wap_wsg_idm_ecid_wtls4 2 23 43 1 4 4 */ 738, /* OBJ_wap_wsg_idm_ecid_wtls5 2 23 43 1 4 5 */ 739, /* OBJ_wap_wsg_idm_ecid_wtls6 2 23 43 1 4 6 */ 740, /* OBJ_wap_wsg_idm_ecid_wtls7 2 23 43 1 4 7 */ 741, /* OBJ_wap_wsg_idm_ecid_wtls8 2 23 43 1 4 8 */ 742, /* OBJ_wap_wsg_idm_ecid_wtls9 2 23 43 1 4 9 */ 743, /* OBJ_wap_wsg_idm_ecid_wtls10 2 23 43 1 4 10 */ 744, /* OBJ_wap_wsg_idm_ecid_wtls11 2 23 43 1 4 11 */ 745, /* OBJ_wap_wsg_idm_ecid_wtls12 2 23 43 1 4 12 */ 804, /* OBJ_whirlpool 1 0 10118 3 0 55 */ 124, /* OBJ_rle_compression 1 1 1 1 666 1 */ 773, /* OBJ_kisa 1 2 410 200004 */ 807, /* OBJ_id_GostR3411_94_with_GostR3410_2001 1 2 643 2 2 3 */ 808, /* OBJ_id_GostR3411_94_with_GostR3410_94 1 2 643 2 2 4 */ 809, /* OBJ_id_GostR3411_94 1 2 643 2 2 9 */ 810, /* OBJ_id_HMACGostR3411_94 1 2 643 2 2 10 */ 811, /* OBJ_id_GostR3410_2001 1 2 643 2 2 19 */ 812, /* OBJ_id_GostR3410_94 1 2 643 2 2 20 */ 813, /* OBJ_id_Gost28147_89 1 2 643 2 2 21 */ 815, /* OBJ_id_Gost28147_89_MAC 1 2 643 2 2 22 */ 816, /* OBJ_id_GostR3411_94_prf 1 2 643 2 2 23 */ 817, /* OBJ_id_GostR3410_2001DH 1 2 643 2 2 98 */ 818, /* OBJ_id_GostR3410_94DH 1 2 643 2 2 99 */ 1, /* OBJ_rsadsi 1 2 840 113549 */ 185, /* OBJ_X9cm 1 2 840 10040 4 */ 127, /* OBJ_id_pkix 1 3 6 1 5 5 7 */ 505, /* OBJ_mime_mhs_headings 1 3 6 1 7 1 1 */ 506, /* OBJ_mime_mhs_bodies 1 3 6 1 7 1 2 */ 119, /* OBJ_ripemd160WithRSA 1 3 36 3 3 1 2 */ 631, /* OBJ_setAttr_GenCryptgrm 2 23 42 3 3 3 1 */ 632, /* OBJ_setAttr_T2Enc 2 23 42 3 3 4 1 */ 633, /* OBJ_setAttr_T2cleartxt 2 23 42 3 3 4 2 */ 634, /* OBJ_setAttr_TokICCsig 2 23 42 3 3 5 1 */ 635, /* OBJ_setAttr_SecDevSig 2 23 42 3 3 5 2 */ 436, /* OBJ_ucl 0 9 2342 19200300 */ 820, /* OBJ_id_Gost28147_89_None_KeyMeshing 1 2 643 2 2 14 0 */ 819, /* OBJ_id_Gost28147_89_CryptoPro_KeyMeshing 1 2 643 2 2 14 1 */ 845, /* OBJ_id_GostR3410_94_a 1 2 643 2 2 20 1 */ 846, /* OBJ_id_GostR3410_94_aBis 1 2 643 2 2 20 2 */ 847, /* OBJ_id_GostR3410_94_b 1 2 643 2 2 20 3 */ 848, /* OBJ_id_GostR3410_94_bBis 1 2 643 2 2 20 4 */ 821, /* OBJ_id_GostR3411_94_TestParamSet 1 2 643 2 2 30 0 */ 822, /* OBJ_id_GostR3411_94_CryptoProParamSet 1 2 643 2 2 30 1 */ 823, /* OBJ_id_Gost28147_89_TestParamSet 1 2 643 2 2 31 0 */ 824, /* OBJ_id_Gost28147_89_CryptoPro_A_ParamSet 1 2 643 2 2 31 1 */ 825, /* OBJ_id_Gost28147_89_CryptoPro_B_ParamSet 1 2 643 2 2 31 2 */ 826, /* OBJ_id_Gost28147_89_CryptoPro_C_ParamSet 1 2 643 2 2 31 3 */ 827, /* OBJ_id_Gost28147_89_CryptoPro_D_ParamSet 1 2 643 2 2 31 4 */ 828, /* OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet 1 2 643 2 2 31 5 */ 829, /* OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet 1 2 643 2 2 31 6 */ 830, /* OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet 1 2 643 2 2 31 7 */ 831, /* OBJ_id_GostR3410_94_TestParamSet 1 2 643 2 2 32 0 */ 832, /* OBJ_id_GostR3410_94_CryptoPro_A_ParamSet 1 2 643 2 2 32 2 */ 833, /* OBJ_id_GostR3410_94_CryptoPro_B_ParamSet 1 2 643 2 2 32 3 */ 834, /* OBJ_id_GostR3410_94_CryptoPro_C_ParamSet 1 2 643 2 2 32 4 */ 835, /* OBJ_id_GostR3410_94_CryptoPro_D_ParamSet 1 2 643 2 2 32 5 */ 836, /* OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet 1 2 643 2 2 33 1 */ 837, /* OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet 1 2 643 2 2 33 2 */ 838, /* OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet 1 2 643 2 2 33 3 */ 839, /* OBJ_id_GostR3410_2001_TestParamSet 1 2 643 2 2 35 0 */ 840, /* OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet 1 2 643 2 2 35 1 */ 841, /* OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet 1 2 643 2 2 35 2 */ 842, /* OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet 1 2 643 2 2 35 3 */ 843, /* OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet 1 2 643 2 2 36 0 */ 844, /* OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet 1 2 643 2 2 36 1 */ 2, /* OBJ_pkcs 1 2 840 113549 1 */ 431, /* OBJ_hold_instruction_none 1 2 840 10040 2 1 */ 432, /* OBJ_hold_instruction_call_issuer 1 2 840 10040 2 2 */ 433, /* OBJ_hold_instruction_reject 1 2 840 10040 2 3 */ 116, /* OBJ_dsa 1 2 840 10040 4 1 */ 113, /* OBJ_dsaWithSHA1 1 2 840 10040 4 3 */ 406, /* OBJ_X9_62_prime_field 1 2 840 10045 1 1 */ 407, /* OBJ_X9_62_characteristic_two_field 1 2 840 10045 1 2 */ 408, /* OBJ_X9_62_id_ecPublicKey 1 2 840 10045 2 1 */ 416, /* OBJ_ecdsa_with_SHA1 1 2 840 10045 4 1 */ 791, /* OBJ_ecdsa_with_Recommended 1 2 840 10045 4 2 */ 792, /* OBJ_ecdsa_with_Specified 1 2 840 10045 4 3 */ 258, /* OBJ_id_pkix_mod 1 3 6 1 5 5 7 0 */ 175, /* OBJ_id_pe 1 3 6 1 5 5 7 1 */ 259, /* OBJ_id_qt 1 3 6 1 5 5 7 2 */ 128, /* OBJ_id_kp 1 3 6 1 5 5 7 3 */ 260, /* OBJ_id_it 1 3 6 1 5 5 7 4 */ 261, /* OBJ_id_pkip 1 3 6 1 5 5 7 5 */ 262, /* OBJ_id_alg 1 3 6 1 5 5 7 6 */ 263, /* OBJ_id_cmc 1 3 6 1 5 5 7 7 */ 264, /* OBJ_id_on 1 3 6 1 5 5 7 8 */ 265, /* OBJ_id_pda 1 3 6 1 5 5 7 9 */ 266, /* OBJ_id_aca 1 3 6 1 5 5 7 10 */ 267, /* OBJ_id_qcs 1 3 6 1 5 5 7 11 */ 268, /* OBJ_id_cct 1 3 6 1 5 5 7 12 */ 662, /* OBJ_id_ppl 1 3 6 1 5 5 7 21 */ 176, /* OBJ_id_ad 1 3 6 1 5 5 7 48 */ 507, /* OBJ_id_hex_partial_message 1 3 6 1 7 1 1 1 */ 508, /* OBJ_id_hex_multipart_message 1 3 6 1 7 1 1 2 */ 921, /* OBJ_brainpool 1 3 36 3 3 2 8 1 */ 57, /* OBJ_netscape 2 16 840 1 113730 */ 754, /* OBJ_camellia_128_ecb 0 3 4401 5 3 1 9 1 */ 766, /* OBJ_camellia_128_ofb128 0 3 4401 5 3 1 9 3 */ 757, /* OBJ_camellia_128_cfb128 0 3 4401 5 3 1 9 4 */ 755, /* OBJ_camellia_192_ecb 0 3 4401 5 3 1 9 21 */ 767, /* OBJ_camellia_192_ofb128 0 3 4401 5 3 1 9 23 */ 758, /* OBJ_camellia_192_cfb128 0 3 4401 5 3 1 9 24 */ 756, /* OBJ_camellia_256_ecb 0 3 4401 5 3 1 9 41 */ 768, /* OBJ_camellia_256_ofb128 0 3 4401 5 3 1 9 43 */ 759, /* OBJ_camellia_256_cfb128 0 3 4401 5 3 1 9 44 */ 437, /* OBJ_pilot 0 9 2342 19200300 100 */ 776, /* OBJ_seed_ecb 1 2 410 200004 1 3 */ 777, /* OBJ_seed_cbc 1 2 410 200004 1 4 */ 779, /* OBJ_seed_cfb128 1 2 410 200004 1 5 */ 778, /* OBJ_seed_ofb128 1 2 410 200004 1 6 */ 852, /* OBJ_id_GostR3411_94_with_GostR3410_94_cc 1 2 643 2 9 1 3 3 */ 853, /* OBJ_id_GostR3411_94_with_GostR3410_2001_cc 1 2 643 2 9 1 3 4 */ 850, /* OBJ_id_GostR3410_94_cc 1 2 643 2 9 1 5 3 */ 851, /* OBJ_id_GostR3410_2001_cc 1 2 643 2 9 1 5 4 */ 849, /* OBJ_id_Gost28147_89_cc 1 2 643 2 9 1 6 1 */ 854, /* OBJ_id_GostR3410_2001_ParamSet_cc 1 2 643 2 9 1 8 1 */ 186, /* OBJ_pkcs1 1 2 840 113549 1 1 */ 27, /* OBJ_pkcs3 1 2 840 113549 1 3 */ 187, /* OBJ_pkcs5 1 2 840 113549 1 5 */ 20, /* OBJ_pkcs7 1 2 840 113549 1 7 */ 47, /* OBJ_pkcs9 1 2 840 113549 1 9 */ 3, /* OBJ_md2 1 2 840 113549 2 2 */ 257, /* OBJ_md4 1 2 840 113549 2 4 */ 4, /* OBJ_md5 1 2 840 113549 2 5 */ 797, /* OBJ_hmacWithMD5 1 2 840 113549 2 6 */ 163, /* OBJ_hmacWithSHA1 1 2 840 113549 2 7 */ 798, /* OBJ_hmacWithSHA224 1 2 840 113549 2 8 */ 799, /* OBJ_hmacWithSHA256 1 2 840 113549 2 9 */ 800, /* OBJ_hmacWithSHA384 1 2 840 113549 2 10 */ 801, /* OBJ_hmacWithSHA512 1 2 840 113549 2 11 */ 37, /* OBJ_rc2_cbc 1 2 840 113549 3 2 */ 5, /* OBJ_rc4 1 2 840 113549 3 4 */ 44, /* OBJ_des_ede3_cbc 1 2 840 113549 3 7 */ 120, /* OBJ_rc5_cbc 1 2 840 113549 3 8 */ 643, /* OBJ_des_cdmf 1 2 840 113549 3 10 */ 680, /* OBJ_X9_62_id_characteristic_two_basis 1 2 840 10045 1 2 3 */ 684, /* OBJ_X9_62_c2pnb163v1 1 2 840 10045 3 0 1 */ 685, /* OBJ_X9_62_c2pnb163v2 1 2 840 10045 3 0 2 */ 686, /* OBJ_X9_62_c2pnb163v3 1 2 840 10045 3 0 3 */ 687, /* OBJ_X9_62_c2pnb176v1 1 2 840 10045 3 0 4 */ 688, /* OBJ_X9_62_c2tnb191v1 1 2 840 10045 3 0 5 */ 689, /* OBJ_X9_62_c2tnb191v2 1 2 840 10045 3 0 6 */ 690, /* OBJ_X9_62_c2tnb191v3 1 2 840 10045 3 0 7 */ 691, /* OBJ_X9_62_c2onb191v4 1 2 840 10045 3 0 8 */ 692, /* OBJ_X9_62_c2onb191v5 1 2 840 10045 3 0 9 */ 693, /* OBJ_X9_62_c2pnb208w1 1 2 840 10045 3 0 10 */ 694, /* OBJ_X9_62_c2tnb239v1 1 2 840 10045 3 0 11 */ 695, /* OBJ_X9_62_c2tnb239v2 1 2 840 10045 3 0 12 */ 696, /* OBJ_X9_62_c2tnb239v3 1 2 840 10045 3 0 13 */ 697, /* OBJ_X9_62_c2onb239v4 1 2 840 10045 3 0 14 */ 698, /* OBJ_X9_62_c2onb239v5 1 2 840 10045 3 0 15 */ 699, /* OBJ_X9_62_c2pnb272w1 1 2 840 10045 3 0 16 */ 700, /* OBJ_X9_62_c2pnb304w1 1 2 840 10045 3 0 17 */ 701, /* OBJ_X9_62_c2tnb359v1 1 2 840 10045 3 0 18 */ 702, /* OBJ_X9_62_c2pnb368w1 1 2 840 10045 3 0 19 */ 703, /* OBJ_X9_62_c2tnb431r1 1 2 840 10045 3 0 20 */ 409, /* OBJ_X9_62_prime192v1 1 2 840 10045 3 1 1 */ 410, /* OBJ_X9_62_prime192v2 1 2 840 10045 3 1 2 */ 411, /* OBJ_X9_62_prime192v3 1 2 840 10045 3 1 3 */ 412, /* OBJ_X9_62_prime239v1 1 2 840 10045 3 1 4 */ 413, /* OBJ_X9_62_prime239v2 1 2 840 10045 3 1 5 */ 414, /* OBJ_X9_62_prime239v3 1 2 840 10045 3 1 6 */ 415, /* OBJ_X9_62_prime256v1 1 2 840 10045 3 1 7 */ 793, /* OBJ_ecdsa_with_SHA224 1 2 840 10045 4 3 1 */ 794, /* OBJ_ecdsa_with_SHA256 1 2 840 10045 4 3 2 */ 795, /* OBJ_ecdsa_with_SHA384 1 2 840 10045 4 3 3 */ 796, /* OBJ_ecdsa_with_SHA512 1 2 840 10045 4 3 4 */ 269, /* OBJ_id_pkix1_explicit_88 1 3 6 1 5 5 7 0 1 */ 270, /* OBJ_id_pkix1_implicit_88 1 3 6 1 5 5 7 0 2 */ 271, /* OBJ_id_pkix1_explicit_93 1 3 6 1 5 5 7 0 3 */ 272, /* OBJ_id_pkix1_implicit_93 1 3 6 1 5 5 7 0 4 */ 273, /* OBJ_id_mod_crmf 1 3 6 1 5 5 7 0 5 */ 274, /* OBJ_id_mod_cmc 1 3 6 1 5 5 7 0 6 */ 275, /* OBJ_id_mod_kea_profile_88 1 3 6 1 5 5 7 0 7 */ 276, /* OBJ_id_mod_kea_profile_93 1 3 6 1 5 5 7 0 8 */ 277, /* OBJ_id_mod_cmp 1 3 6 1 5 5 7 0 9 */ 278, /* OBJ_id_mod_qualified_cert_88 1 3 6 1 5 5 7 0 10 */ 279, /* OBJ_id_mod_qualified_cert_93 1 3 6 1 5 5 7 0 11 */ 280, /* OBJ_id_mod_attribute_cert 1 3 6 1 5 5 7 0 12 */ 281, /* OBJ_id_mod_timestamp_protocol 1 3 6 1 5 5 7 0 13 */ 282, /* OBJ_id_mod_ocsp 1 3 6 1 5 5 7 0 14 */ 283, /* OBJ_id_mod_dvcs 1 3 6 1 5 5 7 0 15 */ 284, /* OBJ_id_mod_cmp2000 1 3 6 1 5 5 7 0 16 */ 177, /* OBJ_info_access 1 3 6 1 5 5 7 1 1 */ 285, /* OBJ_biometricInfo 1 3 6 1 5 5 7 1 2 */ 286, /* OBJ_qcStatements 1 3 6 1 5 5 7 1 3 */ 287, /* OBJ_ac_auditEntity 1 3 6 1 5 5 7 1 4 */ 288, /* OBJ_ac_targeting 1 3 6 1 5 5 7 1 5 */ 289, /* OBJ_aaControls 1 3 6 1 5 5 7 1 6 */ 290, /* OBJ_sbgp_ipAddrBlock 1 3 6 1 5 5 7 1 7 */ 291, /* OBJ_sbgp_autonomousSysNum 1 3 6 1 5 5 7 1 8 */ 292, /* OBJ_sbgp_routerIdentifier 1 3 6 1 5 5 7 1 9 */ 397, /* OBJ_ac_proxying 1 3 6 1 5 5 7 1 10 */ 398, /* OBJ_sinfo_access 1 3 6 1 5 5 7 1 11 */ 663, /* OBJ_proxyCertInfo 1 3 6 1 5 5 7 1 14 */ 164, /* OBJ_id_qt_cps 1 3 6 1 5 5 7 2 1 */ 165, /* OBJ_id_qt_unotice 1 3 6 1 5 5 7 2 2 */ 293, /* OBJ_textNotice 1 3 6 1 5 5 7 2 3 */ 129, /* OBJ_server_auth 1 3 6 1 5 5 7 3 1 */ 130, /* OBJ_client_auth 1 3 6 1 5 5 7 3 2 */ 131, /* OBJ_code_sign 1 3 6 1 5 5 7 3 3 */ 132, /* OBJ_email_protect 1 3 6 1 5 5 7 3 4 */ 294, /* OBJ_ipsecEndSystem 1 3 6 1 5 5 7 3 5 */ 295, /* OBJ_ipsecTunnel 1 3 6 1 5 5 7 3 6 */ 296, /* OBJ_ipsecUser 1 3 6 1 5 5 7 3 7 */ 133, /* OBJ_time_stamp 1 3 6 1 5 5 7 3 8 */ 180, /* OBJ_OCSP_sign 1 3 6 1 5 5 7 3 9 */ 297, /* OBJ_dvcs 1 3 6 1 5 5 7 3 10 */ 298, /* OBJ_id_it_caProtEncCert 1 3 6 1 5 5 7 4 1 */ 299, /* OBJ_id_it_signKeyPairTypes 1 3 6 1 5 5 7 4 2 */ 300, /* OBJ_id_it_encKeyPairTypes 1 3 6 1 5 5 7 4 3 */ 301, /* OBJ_id_it_preferredSymmAlg 1 3 6 1 5 5 7 4 4 */ 302, /* OBJ_id_it_caKeyUpdateInfo 1 3 6 1 5 5 7 4 5 */ 303, /* OBJ_id_it_currentCRL 1 3 6 1 5 5 7 4 6 */ 304, /* OBJ_id_it_unsupportedOIDs 1 3 6 1 5 5 7 4 7 */ 305, /* OBJ_id_it_subscriptionRequest 1 3 6 1 5 5 7 4 8 */ 306, /* OBJ_id_it_subscriptionResponse 1 3 6 1 5 5 7 4 9 */ 307, /* OBJ_id_it_keyPairParamReq 1 3 6 1 5 5 7 4 10 */ 308, /* OBJ_id_it_keyPairParamRep 1 3 6 1 5 5 7 4 11 */ 309, /* OBJ_id_it_revPassphrase 1 3 6 1 5 5 7 4 12 */ 310, /* OBJ_id_it_implicitConfirm 1 3 6 1 5 5 7 4 13 */ 311, /* OBJ_id_it_confirmWaitTime 1 3 6 1 5 5 7 4 14 */ 312, /* OBJ_id_it_origPKIMessage 1 3 6 1 5 5 7 4 15 */ 784, /* OBJ_id_it_suppLangTags 1 3 6 1 5 5 7 4 16 */ 313, /* OBJ_id_regCtrl 1 3 6 1 5 5 7 5 1 */ 314, /* OBJ_id_regInfo 1 3 6 1 5 5 7 5 2 */ 323, /* OBJ_id_alg_des40 1 3 6 1 5 5 7 6 1 */ 324, /* OBJ_id_alg_noSignature 1 3 6 1 5 5 7 6 2 */ 325, /* OBJ_id_alg_dh_sig_hmac_sha1 1 3 6 1 5 5 7 6 3 */ 326, /* OBJ_id_alg_dh_pop 1 3 6 1 5 5 7 6 4 */ 327, /* OBJ_id_cmc_statusInfo 1 3 6 1 5 5 7 7 1 */ 328, /* OBJ_id_cmc_identification 1 3 6 1 5 5 7 7 2 */ 329, /* OBJ_id_cmc_identityProof 1 3 6 1 5 5 7 7 3 */ 330, /* OBJ_id_cmc_dataReturn 1 3 6 1 5 5 7 7 4 */ 331, /* OBJ_id_cmc_transactionId 1 3 6 1 5 5 7 7 5 */ 332, /* OBJ_id_cmc_senderNonce 1 3 6 1 5 5 7 7 6 */ 333, /* OBJ_id_cmc_recipientNonce 1 3 6 1 5 5 7 7 7 */ 334, /* OBJ_id_cmc_addExtensions 1 3 6 1 5 5 7 7 8 */ 335, /* OBJ_id_cmc_encryptedPOP 1 3 6 1 5 5 7 7 9 */ 336, /* OBJ_id_cmc_decryptedPOP 1 3 6 1 5 5 7 7 10 */ 337, /* OBJ_id_cmc_lraPOPWitness 1 3 6 1 5 5 7 7 11 */ 338, /* OBJ_id_cmc_getCert 1 3 6 1 5 5 7 7 15 */ 339, /* OBJ_id_cmc_getCRL 1 3 6 1 5 5 7 7 16 */ 340, /* OBJ_id_cmc_revokeRequest 1 3 6 1 5 5 7 7 17 */ 341, /* OBJ_id_cmc_regInfo 1 3 6 1 5 5 7 7 18 */ 342, /* OBJ_id_cmc_responseInfo 1 3 6 1 5 5 7 7 19 */ 343, /* OBJ_id_cmc_queryPending 1 3 6 1 5 5 7 7 21 */ 344, /* OBJ_id_cmc_popLinkRandom 1 3 6 1 5 5 7 7 22 */ 345, /* OBJ_id_cmc_popLinkWitness 1 3 6 1 5 5 7 7 23 */ 346, /* OBJ_id_cmc_confirmCertAcceptance 1 3 6 1 5 5 7 7 24 */ 347, /* OBJ_id_on_personalData 1 3 6 1 5 5 7 8 1 */ 858, /* OBJ_id_on_permanentIdentifier 1 3 6 1 5 5 7 8 3 */ 348, /* OBJ_id_pda_dateOfBirth 1 3 6 1 5 5 7 9 1 */ 349, /* OBJ_id_pda_placeOfBirth 1 3 6 1 5 5 7 9 2 */ 351, /* OBJ_id_pda_gender 1 3 6 1 5 5 7 9 3 */ 352, /* OBJ_id_pda_countryOfCitizenship 1 3 6 1 5 5 7 9 4 */ 353, /* OBJ_id_pda_countryOfResidence 1 3 6 1 5 5 7 9 5 */ 354, /* OBJ_id_aca_authenticationInfo 1 3 6 1 5 5 7 10 1 */ 355, /* OBJ_id_aca_accessIdentity 1 3 6 1 5 5 7 10 2 */ 356, /* OBJ_id_aca_chargingIdentity 1 3 6 1 5 5 7 10 3 */ 357, /* OBJ_id_aca_group 1 3 6 1 5 5 7 10 4 */ 358, /* OBJ_id_aca_role 1 3 6 1 5 5 7 10 5 */ 399, /* OBJ_id_aca_encAttrs 1 3 6 1 5 5 7 10 6 */ 359, /* OBJ_id_qcs_pkixQCSyntax_v1 1 3 6 1 5 5 7 11 1 */ 360, /* OBJ_id_cct_crs 1 3 6 1 5 5 7 12 1 */ 361, /* OBJ_id_cct_PKIData 1 3 6 1 5 5 7 12 2 */ 362, /* OBJ_id_cct_PKIResponse 1 3 6 1 5 5 7 12 3 */ 664, /* OBJ_id_ppl_anyLanguage 1 3 6 1 5 5 7 21 0 */ 665, /* OBJ_id_ppl_inheritAll 1 3 6 1 5 5 7 21 1 */ 667, /* OBJ_Independent 1 3 6 1 5 5 7 21 2 */ 178, /* OBJ_ad_OCSP 1 3 6 1 5 5 7 48 1 */ 179, /* OBJ_ad_ca_issuers 1 3 6 1 5 5 7 48 2 */ 363, /* OBJ_ad_timeStamping 1 3 6 1 5 5 7 48 3 */ 364, /* OBJ_ad_dvcs 1 3 6 1 5 5 7 48 4 */ 785, /* OBJ_caRepository 1 3 6 1 5 5 7 48 5 */ 780, /* OBJ_hmac_md5 1 3 6 1 5 5 8 1 1 */ 781, /* OBJ_hmac_sha1 1 3 6 1 5 5 8 1 2 */ 58, /* OBJ_netscape_cert_extension 2 16 840 1 113730 1 */ 59, /* OBJ_netscape_data_type 2 16 840 1 113730 2 */ 438, /* OBJ_pilotAttributeType 0 9 2342 19200300 100 1 */ 439, /* OBJ_pilotAttributeSyntax 0 9 2342 19200300 100 3 */ 440, /* OBJ_pilotObjectClass 0 9 2342 19200300 100 4 */ 441, /* OBJ_pilotGroups 0 9 2342 19200300 100 10 */ 108, /* OBJ_cast5_cbc 1 2 840 113533 7 66 10 */ 112, /* OBJ_pbeWithMD5AndCast5_CBC 1 2 840 113533 7 66 12 */ 782, /* OBJ_id_PasswordBasedMAC 1 2 840 113533 7 66 13 */ 783, /* OBJ_id_DHBasedMac 1 2 840 113533 7 66 30 */ 6, /* OBJ_rsaEncryption 1 2 840 113549 1 1 1 */ 7, /* OBJ_md2WithRSAEncryption 1 2 840 113549 1 1 2 */ 396, /* OBJ_md4WithRSAEncryption 1 2 840 113549 1 1 3 */ 8, /* OBJ_md5WithRSAEncryption 1 2 840 113549 1 1 4 */ 65, /* OBJ_sha1WithRSAEncryption 1 2 840 113549 1 1 5 */ 644, /* OBJ_rsaOAEPEncryptionSET 1 2 840 113549 1 1 6 */ 919, /* OBJ_rsaesOaep 1 2 840 113549 1 1 7 */ 911, /* OBJ_mgf1 1 2 840 113549 1 1 8 */ 912, /* OBJ_rsassaPss 1 2 840 113549 1 1 10 */ 668, /* OBJ_sha256WithRSAEncryption 1 2 840 113549 1 1 11 */ 669, /* OBJ_sha384WithRSAEncryption 1 2 840 113549 1 1 12 */ 670, /* OBJ_sha512WithRSAEncryption 1 2 840 113549 1 1 13 */ 671, /* OBJ_sha224WithRSAEncryption 1 2 840 113549 1 1 14 */ 28, /* OBJ_dhKeyAgreement 1 2 840 113549 1 3 1 */ 9, /* OBJ_pbeWithMD2AndDES_CBC 1 2 840 113549 1 5 1 */ 10, /* OBJ_pbeWithMD5AndDES_CBC 1 2 840 113549 1 5 3 */ 168, /* OBJ_pbeWithMD2AndRC2_CBC 1 2 840 113549 1 5 4 */ 169, /* OBJ_pbeWithMD5AndRC2_CBC 1 2 840 113549 1 5 6 */ 170, /* OBJ_pbeWithSHA1AndDES_CBC 1 2 840 113549 1 5 10 */ 68, /* OBJ_pbeWithSHA1AndRC2_CBC 1 2 840 113549 1 5 11 */ 69, /* OBJ_id_pbkdf2 1 2 840 113549 1 5 12 */ 161, /* OBJ_pbes2 1 2 840 113549 1 5 13 */ 162, /* OBJ_pbmac1 1 2 840 113549 1 5 14 */ 21, /* OBJ_pkcs7_data 1 2 840 113549 1 7 1 */ 22, /* OBJ_pkcs7_signed 1 2 840 113549 1 7 2 */ 23, /* OBJ_pkcs7_enveloped 1 2 840 113549 1 7 3 */ 24, /* OBJ_pkcs7_signedAndEnveloped 1 2 840 113549 1 7 4 */ 25, /* OBJ_pkcs7_digest 1 2 840 113549 1 7 5 */ 26, /* OBJ_pkcs7_encrypted 1 2 840 113549 1 7 6 */ 48, /* OBJ_pkcs9_emailAddress 1 2 840 113549 1 9 1 */ 49, /* OBJ_pkcs9_unstructuredName 1 2 840 113549 1 9 2 */ 50, /* OBJ_pkcs9_contentType 1 2 840 113549 1 9 3 */ 51, /* OBJ_pkcs9_messageDigest 1 2 840 113549 1 9 4 */ 52, /* OBJ_pkcs9_signingTime 1 2 840 113549 1 9 5 */ 53, /* OBJ_pkcs9_countersignature 1 2 840 113549 1 9 6 */ 54, /* OBJ_pkcs9_challengePassword 1 2 840 113549 1 9 7 */ 55, /* OBJ_pkcs9_unstructuredAddress 1 2 840 113549 1 9 8 */ 56, /* OBJ_pkcs9_extCertAttributes 1 2 840 113549 1 9 9 */ 172, /* OBJ_ext_req 1 2 840 113549 1 9 14 */ 167, /* OBJ_SMIMECapabilities 1 2 840 113549 1 9 15 */ 188, /* OBJ_SMIME 1 2 840 113549 1 9 16 */ 156, /* OBJ_friendlyName 1 2 840 113549 1 9 20 */ 157, /* OBJ_localKeyID 1 2 840 113549 1 9 21 */ 681, /* OBJ_X9_62_onBasis 1 2 840 10045 1 2 3 1 */ 682, /* OBJ_X9_62_tpBasis 1 2 840 10045 1 2 3 2 */ 683, /* OBJ_X9_62_ppBasis 1 2 840 10045 1 2 3 3 */ 417, /* OBJ_ms_csp_name 1 3 6 1 4 1 311 17 1 */ 856, /* OBJ_LocalKeySet 1 3 6 1 4 1 311 17 2 */ 390, /* OBJ_dcObject 1 3 6 1 4 1 1466 344 */ 91, /* OBJ_bf_cbc 1 3 6 1 4 1 3029 1 2 */ 315, /* OBJ_id_regCtrl_regToken 1 3 6 1 5 5 7 5 1 1 */ 316, /* OBJ_id_regCtrl_authenticator 1 3 6 1 5 5 7 5 1 2 */ 317, /* OBJ_id_regCtrl_pkiPublicationInfo 1 3 6 1 5 5 7 5 1 3 */ 318, /* OBJ_id_regCtrl_pkiArchiveOptions 1 3 6 1 5 5 7 5 1 4 */ 319, /* OBJ_id_regCtrl_oldCertID 1 3 6 1 5 5 7 5 1 5 */ 320, /* OBJ_id_regCtrl_protocolEncrKey 1 3 6 1 5 5 7 5 1 6 */ 321, /* OBJ_id_regInfo_utf8Pairs 1 3 6 1 5 5 7 5 2 1 */ 322, /* OBJ_id_regInfo_certReq 1 3 6 1 5 5 7 5 2 2 */ 365, /* OBJ_id_pkix_OCSP_basic 1 3 6 1 5 5 7 48 1 1 */ 366, /* OBJ_id_pkix_OCSP_Nonce 1 3 6 1 5 5 7 48 1 2 */ 367, /* OBJ_id_pkix_OCSP_CrlID 1 3 6 1 5 5 7 48 1 3 */ 368, /* OBJ_id_pkix_OCSP_acceptableResponses 1 3 6 1 5 5 7 48 1 4 */ 369, /* OBJ_id_pkix_OCSP_noCheck 1 3 6 1 5 5 7 48 1 5 */ 370, /* OBJ_id_pkix_OCSP_archiveCutoff 1 3 6 1 5 5 7 48 1 6 */ 371, /* OBJ_id_pkix_OCSP_serviceLocator 1 3 6 1 5 5 7 48 1 7 */ 372, /* OBJ_id_pkix_OCSP_extendedStatus 1 3 6 1 5 5 7 48 1 8 */ 373, /* OBJ_id_pkix_OCSP_valid 1 3 6 1 5 5 7 48 1 9 */ 374, /* OBJ_id_pkix_OCSP_path 1 3 6 1 5 5 7 48 1 10 */ 375, /* OBJ_id_pkix_OCSP_trustRoot 1 3 6 1 5 5 7 48 1 11 */ 922, /* OBJ_brainpoolP160r1 1 3 36 3 3 2 8 1 1 1 */ 923, /* OBJ_brainpoolP160t1 1 3 36 3 3 2 8 1 1 2 */ 924, /* OBJ_brainpoolP192r1 1 3 36 3 3 2 8 1 1 3 */ 925, /* OBJ_brainpoolP192t1 1 3 36 3 3 2 8 1 1 4 */ 926, /* OBJ_brainpoolP224r1 1 3 36 3 3 2 8 1 1 5 */ 927, /* OBJ_brainpoolP224t1 1 3 36 3 3 2 8 1 1 6 */ 928, /* OBJ_brainpoolP256r1 1 3 36 3 3 2 8 1 1 7 */ 929, /* OBJ_brainpoolP256t1 1 3 36 3 3 2 8 1 1 8 */ 930, /* OBJ_brainpoolP320r1 1 3 36 3 3 2 8 1 1 9 */ 931, /* OBJ_brainpoolP320t1 1 3 36 3 3 2 8 1 1 10 */ 932, /* OBJ_brainpoolP384r1 1 3 36 3 3 2 8 1 1 11 */ 933, /* OBJ_brainpoolP384t1 1 3 36 3 3 2 8 1 1 12 */ 934, /* OBJ_brainpoolP512r1 1 3 36 3 3 2 8 1 1 13 */ 935, /* OBJ_brainpoolP512t1 1 3 36 3 3 2 8 1 1 14 */ 418, /* OBJ_aes_128_ecb 2 16 840 1 101 3 4 1 1 */ 419, /* OBJ_aes_128_cbc 2 16 840 1 101 3 4 1 2 */ 420, /* OBJ_aes_128_ofb128 2 16 840 1 101 3 4 1 3 */ 421, /* OBJ_aes_128_cfb128 2 16 840 1 101 3 4 1 4 */ 788, /* OBJ_id_aes128_wrap 2 16 840 1 101 3 4 1 5 */ 895, /* OBJ_aes_128_gcm 2 16 840 1 101 3 4 1 6 */ 896, /* OBJ_aes_128_ccm 2 16 840 1 101 3 4 1 7 */ 897, /* OBJ_id_aes128_wrap_pad 2 16 840 1 101 3 4 1 8 */ 422, /* OBJ_aes_192_ecb 2 16 840 1 101 3 4 1 21 */ 423, /* OBJ_aes_192_cbc 2 16 840 1 101 3 4 1 22 */ 424, /* OBJ_aes_192_ofb128 2 16 840 1 101 3 4 1 23 */ 425, /* OBJ_aes_192_cfb128 2 16 840 1 101 3 4 1 24 */ 789, /* OBJ_id_aes192_wrap 2 16 840 1 101 3 4 1 25 */ 898, /* OBJ_aes_192_gcm 2 16 840 1 101 3 4 1 26 */ 899, /* OBJ_aes_192_ccm 2 16 840 1 101 3 4 1 27 */ 900, /* OBJ_id_aes192_wrap_pad 2 16 840 1 101 3 4 1 28 */ 426, /* OBJ_aes_256_ecb 2 16 840 1 101 3 4 1 41 */ 427, /* OBJ_aes_256_cbc 2 16 840 1 101 3 4 1 42 */ 428, /* OBJ_aes_256_ofb128 2 16 840 1 101 3 4 1 43 */ 429, /* OBJ_aes_256_cfb128 2 16 840 1 101 3 4 1 44 */ 790, /* OBJ_id_aes256_wrap 2 16 840 1 101 3 4 1 45 */ 901, /* OBJ_aes_256_gcm 2 16 840 1 101 3 4 1 46 */ 902, /* OBJ_aes_256_ccm 2 16 840 1 101 3 4 1 47 */ 903, /* OBJ_id_aes256_wrap_pad 2 16 840 1 101 3 4 1 48 */ 672, /* OBJ_sha256 2 16 840 1 101 3 4 2 1 */ 673, /* OBJ_sha384 2 16 840 1 101 3 4 2 2 */ 674, /* OBJ_sha512 2 16 840 1 101 3 4 2 3 */ 675, /* OBJ_sha224 2 16 840 1 101 3 4 2 4 */ 802, /* OBJ_dsa_with_SHA224 2 16 840 1 101 3 4 3 1 */ 803, /* OBJ_dsa_with_SHA256 2 16 840 1 101 3 4 3 2 */ 71, /* OBJ_netscape_cert_type 2 16 840 1 113730 1 1 */ 72, /* OBJ_netscape_base_url 2 16 840 1 113730 1 2 */ 73, /* OBJ_netscape_revocation_url 2 16 840 1 113730 1 3 */ 74, /* OBJ_netscape_ca_revocation_url 2 16 840 1 113730 1 4 */ 75, /* OBJ_netscape_renewal_url 2 16 840 1 113730 1 7 */ 76, /* OBJ_netscape_ca_policy_url 2 16 840 1 113730 1 8 */ 77, /* OBJ_netscape_ssl_server_name 2 16 840 1 113730 1 12 */ 78, /* OBJ_netscape_comment 2 16 840 1 113730 1 13 */ 79, /* OBJ_netscape_cert_sequence 2 16 840 1 113730 2 5 */ 139, /* OBJ_ns_sgc 2 16 840 1 113730 4 1 */ 458, /* OBJ_userId 0 9 2342 19200300 100 1 1 */ 459, /* OBJ_textEncodedORAddress 0 9 2342 19200300 100 1 2 */ 460, /* OBJ_rfc822Mailbox 0 9 2342 19200300 100 1 3 */ 461, /* OBJ_info 0 9 2342 19200300 100 1 4 */ 462, /* OBJ_favouriteDrink 0 9 2342 19200300 100 1 5 */ 463, /* OBJ_roomNumber 0 9 2342 19200300 100 1 6 */ 464, /* OBJ_photo 0 9 2342 19200300 100 1 7 */ 465, /* OBJ_userClass 0 9 2342 19200300 100 1 8 */ 466, /* OBJ_host 0 9 2342 19200300 100 1 9 */ 467, /* OBJ_manager 0 9 2342 19200300 100 1 10 */ 468, /* OBJ_documentIdentifier 0 9 2342 19200300 100 1 11 */ 469, /* OBJ_documentTitle 0 9 2342 19200300 100 1 12 */ 470, /* OBJ_documentVersion 0 9 2342 19200300 100 1 13 */ 471, /* OBJ_documentAuthor 0 9 2342 19200300 100 1 14 */ 472, /* OBJ_documentLocation 0 9 2342 19200300 100 1 15 */ 473, /* OBJ_homeTelephoneNumber 0 9 2342 19200300 100 1 20 */ 474, /* OBJ_secretary 0 9 2342 19200300 100 1 21 */ 475, /* OBJ_otherMailbox 0 9 2342 19200300 100 1 22 */ 476, /* OBJ_lastModifiedTime 0 9 2342 19200300 100 1 23 */ 477, /* OBJ_lastModifiedBy 0 9 2342 19200300 100 1 24 */ 391, /* OBJ_domainComponent 0 9 2342 19200300 100 1 25 */ 478, /* OBJ_aRecord 0 9 2342 19200300 100 1 26 */ 479, /* OBJ_pilotAttributeType27 0 9 2342 19200300 100 1 27 */ 480, /* OBJ_mXRecord 0 9 2342 19200300 100 1 28 */ 481, /* OBJ_nSRecord 0 9 2342 19200300 100 1 29 */ 482, /* OBJ_sOARecord 0 9 2342 19200300 100 1 30 */ 483, /* OBJ_cNAMERecord 0 9 2342 19200300 100 1 31 */ 484, /* OBJ_associatedDomain 0 9 2342 19200300 100 1 37 */ 485, /* OBJ_associatedName 0 9 2342 19200300 100 1 38 */ 486, /* OBJ_homePostalAddress 0 9 2342 19200300 100 1 39 */ 487, /* OBJ_personalTitle 0 9 2342 19200300 100 1 40 */ 488, /* OBJ_mobileTelephoneNumber 0 9 2342 19200300 100 1 41 */ 489, /* OBJ_pagerTelephoneNumber 0 9 2342 19200300 100 1 42 */ 490, /* OBJ_friendlyCountryName 0 9 2342 19200300 100 1 43 */ 491, /* OBJ_organizationalStatus 0 9 2342 19200300 100 1 45 */ 492, /* OBJ_janetMailbox 0 9 2342 19200300 100 1 46 */ 493, /* OBJ_mailPreferenceOption 0 9 2342 19200300 100 1 47 */ 494, /* OBJ_buildingName 0 9 2342 19200300 100 1 48 */ 495, /* OBJ_dSAQuality 0 9 2342 19200300 100 1 49 */ 496, /* OBJ_singleLevelQuality 0 9 2342 19200300 100 1 50 */ 497, /* OBJ_subtreeMinimumQuality 0 9 2342 19200300 100 1 51 */ 498, /* OBJ_subtreeMaximumQuality 0 9 2342 19200300 100 1 52 */ 499, /* OBJ_personalSignature 0 9 2342 19200300 100 1 53 */ 500, /* OBJ_dITRedirect 0 9 2342 19200300 100 1 54 */ 501, /* OBJ_audio 0 9 2342 19200300 100 1 55 */ 502, /* OBJ_documentPublisher 0 9 2342 19200300 100 1 56 */ 442, /* OBJ_iA5StringSyntax 0 9 2342 19200300 100 3 4 */ 443, /* OBJ_caseIgnoreIA5StringSyntax 0 9 2342 19200300 100 3 5 */ 444, /* OBJ_pilotObject 0 9 2342 19200300 100 4 3 */ 445, /* OBJ_pilotPerson 0 9 2342 19200300 100 4 4 */ 446, /* OBJ_account 0 9 2342 19200300 100 4 5 */ 447, /* OBJ_document 0 9 2342 19200300 100 4 6 */ 448, /* OBJ_room 0 9 2342 19200300 100 4 7 */ 449, /* OBJ_documentSeries 0 9 2342 19200300 100 4 9 */ 392, /* OBJ_Domain 0 9 2342 19200300 100 4 13 */ 450, /* OBJ_rFC822localPart 0 9 2342 19200300 100 4 14 */ 451, /* OBJ_dNSDomain 0 9 2342 19200300 100 4 15 */ 452, /* OBJ_domainRelatedObject 0 9 2342 19200300 100 4 17 */ 453, /* OBJ_friendlyCountry 0 9 2342 19200300 100 4 18 */ 454, /* OBJ_simpleSecurityObject 0 9 2342 19200300 100 4 19 */ 455, /* OBJ_pilotOrganization 0 9 2342 19200300 100 4 20 */ 456, /* OBJ_pilotDSA 0 9 2342 19200300 100 4 21 */ 457, /* OBJ_qualityLabelledData 0 9 2342 19200300 100 4 22 */ 936, /* OBJ_FRP256v1 1 2 250 1 223 101 256 1 */ 189, /* OBJ_id_smime_mod 1 2 840 113549 1 9 16 0 */ 190, /* OBJ_id_smime_ct 1 2 840 113549 1 9 16 1 */ 191, /* OBJ_id_smime_aa 1 2 840 113549 1 9 16 2 */ 192, /* OBJ_id_smime_alg 1 2 840 113549 1 9 16 3 */ 193, /* OBJ_id_smime_cd 1 2 840 113549 1 9 16 4 */ 194, /* OBJ_id_smime_spq 1 2 840 113549 1 9 16 5 */ 195, /* OBJ_id_smime_cti 1 2 840 113549 1 9 16 6 */ 158, /* OBJ_x509Certificate 1 2 840 113549 1 9 22 1 */ 159, /* OBJ_sdsiCertificate 1 2 840 113549 1 9 22 2 */ 160, /* OBJ_x509Crl 1 2 840 113549 1 9 23 1 */ 144, /* OBJ_pbe_WithSHA1And128BitRC4 1 2 840 113549 1 12 1 1 */ 145, /* OBJ_pbe_WithSHA1And40BitRC4 1 2 840 113549 1 12 1 2 */ 146, /* OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC 1 2 840 113549 1 12 1 3 */ 147, /* OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC 1 2 840 113549 1 12 1 4 */ 148, /* OBJ_pbe_WithSHA1And128BitRC2_CBC 1 2 840 113549 1 12 1 5 */ 149, /* OBJ_pbe_WithSHA1And40BitRC2_CBC 1 2 840 113549 1 12 1 6 */ 171, /* OBJ_ms_ext_req 1 3 6 1 4 1 311 2 1 14 */ 134, /* OBJ_ms_code_ind 1 3 6 1 4 1 311 2 1 21 */ 135, /* OBJ_ms_code_com 1 3 6 1 4 1 311 2 1 22 */ 136, /* OBJ_ms_ctl_sign 1 3 6 1 4 1 311 10 3 1 */ 137, /* OBJ_ms_sgc 1 3 6 1 4 1 311 10 3 3 */ 138, /* OBJ_ms_efs 1 3 6 1 4 1 311 10 3 4 */ 648, /* OBJ_ms_smartcard_login 1 3 6 1 4 1 311 20 2 2 */ 649, /* OBJ_ms_upn 1 3 6 1 4 1 311 20 2 3 */ 751, /* OBJ_camellia_128_cbc 1 2 392 200011 61 1 1 1 2 */ 752, /* OBJ_camellia_192_cbc 1 2 392 200011 61 1 1 1 3 */ 753, /* OBJ_camellia_256_cbc 1 2 392 200011 61 1 1 1 4 */ 907, /* OBJ_id_camellia128_wrap 1 2 392 200011 61 1 1 3 2 */ 908, /* OBJ_id_camellia192_wrap 1 2 392 200011 61 1 1 3 3 */ 909, /* OBJ_id_camellia256_wrap 1 2 392 200011 61 1 1 3 4 */ 196, /* OBJ_id_smime_mod_cms 1 2 840 113549 1 9 16 0 1 */ 197, /* OBJ_id_smime_mod_ess 1 2 840 113549 1 9 16 0 2 */ 198, /* OBJ_id_smime_mod_oid 1 2 840 113549 1 9 16 0 3 */ 199, /* OBJ_id_smime_mod_msg_v3 1 2 840 113549 1 9 16 0 4 */ 200, /* OBJ_id_smime_mod_ets_eSignature_88 1 2 840 113549 1 9 16 0 5 */ 201, /* OBJ_id_smime_mod_ets_eSignature_97 1 2 840 113549 1 9 16 0 6 */ 202, /* OBJ_id_smime_mod_ets_eSigPolicy_88 1 2 840 113549 1 9 16 0 7 */ 203, /* OBJ_id_smime_mod_ets_eSigPolicy_97 1 2 840 113549 1 9 16 0 8 */ 204, /* OBJ_id_smime_ct_receipt 1 2 840 113549 1 9 16 1 1 */ 205, /* OBJ_id_smime_ct_authData 1 2 840 113549 1 9 16 1 2 */ 206, /* OBJ_id_smime_ct_publishCert 1 2 840 113549 1 9 16 1 3 */ 207, /* OBJ_id_smime_ct_TSTInfo 1 2 840 113549 1 9 16 1 4 */ 208, /* OBJ_id_smime_ct_TDTInfo 1 2 840 113549 1 9 16 1 5 */ 209, /* OBJ_id_smime_ct_contentInfo 1 2 840 113549 1 9 16 1 6 */ 210, /* OBJ_id_smime_ct_DVCSRequestData 1 2 840 113549 1 9 16 1 7 */ 211, /* OBJ_id_smime_ct_DVCSResponseData 1 2 840 113549 1 9 16 1 8 */ 786, /* OBJ_id_smime_ct_compressedData 1 2 840 113549 1 9 16 1 9 */ 787, /* OBJ_id_ct_asciiTextWithCRLF 1 2 840 113549 1 9 16 1 27 */ 212, /* OBJ_id_smime_aa_receiptRequest 1 2 840 113549 1 9 16 2 1 */ 213, /* OBJ_id_smime_aa_securityLabel 1 2 840 113549 1 9 16 2 2 */ 214, /* OBJ_id_smime_aa_mlExpandHistory 1 2 840 113549 1 9 16 2 3 */ 215, /* OBJ_id_smime_aa_contentHint 1 2 840 113549 1 9 16 2 4 */ 216, /* OBJ_id_smime_aa_msgSigDigest 1 2 840 113549 1 9 16 2 5 */ 217, /* OBJ_id_smime_aa_encapContentType 1 2 840 113549 1 9 16 2 6 */ 218, /* OBJ_id_smime_aa_contentIdentifier 1 2 840 113549 1 9 16 2 7 */ 219, /* OBJ_id_smime_aa_macValue 1 2 840 113549 1 9 16 2 8 */ 220, /* OBJ_id_smime_aa_equivalentLabels 1 2 840 113549 1 9 16 2 9 */ 221, /* OBJ_id_smime_aa_contentReference 1 2 840 113549 1 9 16 2 10 */ 222, /* OBJ_id_smime_aa_encrypKeyPref 1 2 840 113549 1 9 16 2 11 */ 223, /* OBJ_id_smime_aa_signingCertificate 1 2 840 113549 1 9 16 2 12 */ 224, /* OBJ_id_smime_aa_smimeEncryptCerts 1 2 840 113549 1 9 16 2 13 */ 225, /* OBJ_id_smime_aa_timeStampToken 1 2 840 113549 1 9 16 2 14 */ 226, /* OBJ_id_smime_aa_ets_sigPolicyId 1 2 840 113549 1 9 16 2 15 */ 227, /* OBJ_id_smime_aa_ets_commitmentType 1 2 840 113549 1 9 16 2 16 */ 228, /* OBJ_id_smime_aa_ets_signerLocation 1 2 840 113549 1 9 16 2 17 */ 229, /* OBJ_id_smime_aa_ets_signerAttr 1 2 840 113549 1 9 16 2 18 */ 230, /* OBJ_id_smime_aa_ets_otherSigCert 1 2 840 113549 1 9 16 2 19 */ 231, /* OBJ_id_smime_aa_ets_contentTimestamp 1 2 840 113549 1 9 16 2 20 */ 232, /* OBJ_id_smime_aa_ets_CertificateRefs 1 2 840 113549 1 9 16 2 21 */ 233, /* OBJ_id_smime_aa_ets_RevocationRefs 1 2 840 113549 1 9 16 2 22 */ 234, /* OBJ_id_smime_aa_ets_certValues 1 2 840 113549 1 9 16 2 23 */ 235, /* OBJ_id_smime_aa_ets_revocationValues 1 2 840 113549 1 9 16 2 24 */ 236, /* OBJ_id_smime_aa_ets_escTimeStamp 1 2 840 113549 1 9 16 2 25 */ 237, /* OBJ_id_smime_aa_ets_certCRLTimestamp 1 2 840 113549 1 9 16 2 26 */ 238, /* OBJ_id_smime_aa_ets_archiveTimeStamp 1 2 840 113549 1 9 16 2 27 */ 239, /* OBJ_id_smime_aa_signatureType 1 2 840 113549 1 9 16 2 28 */ 240, /* OBJ_id_smime_aa_dvcs_dvc 1 2 840 113549 1 9 16 2 29 */ 241, /* OBJ_id_smime_alg_ESDHwith3DES 1 2 840 113549 1 9 16 3 1 */ 242, /* OBJ_id_smime_alg_ESDHwithRC2 1 2 840 113549 1 9 16 3 2 */ 243, /* OBJ_id_smime_alg_3DESwrap 1 2 840 113549 1 9 16 3 3 */ 244, /* OBJ_id_smime_alg_RC2wrap 1 2 840 113549 1 9 16 3 4 */ 245, /* OBJ_id_smime_alg_ESDH 1 2 840 113549 1 9 16 3 5 */ 246, /* OBJ_id_smime_alg_CMS3DESwrap 1 2 840 113549 1 9 16 3 6 */ 247, /* OBJ_id_smime_alg_CMSRC2wrap 1 2 840 113549 1 9 16 3 7 */ 125, /* OBJ_zlib_compression 1 2 840 113549 1 9 16 3 8 */ 893, /* OBJ_id_alg_PWRI_KEK 1 2 840 113549 1 9 16 3 9 */ 248, /* OBJ_id_smime_cd_ldap 1 2 840 113549 1 9 16 4 1 */ 249, /* OBJ_id_smime_spq_ets_sqt_uri 1 2 840 113549 1 9 16 5 1 */ 250, /* OBJ_id_smime_spq_ets_sqt_unotice 1 2 840 113549 1 9 16 5 2 */ 251, /* OBJ_id_smime_cti_ets_proofOfOrigin 1 2 840 113549 1 9 16 6 1 */ 252, /* OBJ_id_smime_cti_ets_proofOfReceipt 1 2 840 113549 1 9 16 6 2 */ 253, /* OBJ_id_smime_cti_ets_proofOfDelivery 1 2 840 113549 1 9 16 6 3 */ 254, /* OBJ_id_smime_cti_ets_proofOfSender 1 2 840 113549 1 9 16 6 4 */ 255, /* OBJ_id_smime_cti_ets_proofOfApproval 1 2 840 113549 1 9 16 6 5 */ 256, /* OBJ_id_smime_cti_ets_proofOfCreation 1 2 840 113549 1 9 16 6 6 */ 150, /* OBJ_keyBag 1 2 840 113549 1 12 10 1 1 */ 151, /* OBJ_pkcs8ShroudedKeyBag 1 2 840 113549 1 12 10 1 2 */ 152, /* OBJ_certBag 1 2 840 113549 1 12 10 1 3 */ 153, /* OBJ_crlBag 1 2 840 113549 1 12 10 1 4 */ 154, /* OBJ_secretBag 1 2 840 113549 1 12 10 1 5 */ 155, /* OBJ_safeContentsBag 1 2 840 113549 1 12 10 1 6 */ 34, /* OBJ_idea_cbc 1 3 6 1 4 1 188 7 1 1 2 */ }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/objects/obj_lib.c0000644000175000017500000001120512360020706021450 0ustar /* $OpenBSD: obj_lib.c,v 1.11 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o) { ASN1_OBJECT *r; int i; char *ln = NULL, *sn = NULL; unsigned char *data = NULL; if (o == NULL) return (NULL); if (!(o->flags & ASN1_OBJECT_FLAG_DYNAMIC)) return((ASN1_OBJECT *)o); /* XXX: ugh! Why? What kind of duplication is this??? */ r = ASN1_OBJECT_new(); if (r == NULL) { OBJerr(OBJ_F_OBJ_DUP, ERR_R_ASN1_LIB); return (NULL); } data = malloc(o->length); if (data == NULL) goto err; if (o->data != NULL) memcpy(data, o->data, o->length); /* once data attached to object it remains const */ r->data = data; r->length = o->length; r->nid = o->nid; r->ln = r->sn = NULL; if (o->ln != NULL) { i = strlen(o->ln) + 1; ln = malloc(i); if (ln == NULL) goto err; memcpy(ln, o->ln, i); r->ln = ln; } if (o->sn != NULL) { i = strlen(o->sn) + 1; sn = malloc(i); if (sn == NULL) goto err; memcpy(sn, o->sn, i); r->sn = sn; } r->flags = o->flags | (ASN1_OBJECT_FLAG_DYNAMIC | ASN1_OBJECT_FLAG_DYNAMIC_STRINGS | ASN1_OBJECT_FLAG_DYNAMIC_DATA); return (r); err: OBJerr(OBJ_F_OBJ_DUP, ERR_R_MALLOC_FAILURE); free(ln); free(sn); free(data); free(r); return (NULL); } int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b) { int ret; ret = (a->length - b->length); if (ret) return (ret); return (memcmp(a->data, b->data, a->length)); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/malloc-wrapper.c0000644000175000017500000000742712360020705021356 0ustar /* $OpenBSD: malloc-wrapper.c,v 1.2 2014/04/17 20:44:45 tedu Exp $ */ /* * Copyright (c) 2014 Bob Beck * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include int CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t), void (*f)(void *)) { return 0; } int CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int), void *(*r)(void *, size_t, const char *, int), void (*f)(void *)) { return 0; } int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*f)(void *)) { return 0; } int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int), void (*f)(void *)) { return 0; } int CRYPTO_set_mem_debug_functions(void (*m)(void *, int, const char *, int, int), void (*r)(void *, void *, int, const char *, int, int), void (*f)(void *, int), void (*so)(long), long (*go)(void)) { return 0; } void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t), void (**f)(void *)) { if (m != NULL) *m = malloc; if (r != NULL) *r = realloc; if (f != NULL) *f = free; } void CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int), void *(**r)(void *, size_t, const char *, int), void (**f)(void *)) { if (m != NULL) *m = NULL; if (r != NULL) *r = NULL; if (f != NULL) *f = free; } void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)) { if (m != NULL) *m = malloc; if (f != NULL) *f = free; } void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int), void (**f)(void *)) { if (m != NULL) *m = NULL; if (f != NULL) *f = free; } void CRYPTO_get_mem_debug_functions(void (**m)(void *, int, const char *, int, int), void (**r)(void *, void *, int, const char *, int, int), void (**f)(void *, int), void (**so)(long), long (**go)(void)) { if (m != NULL) *m = NULL; if (r != NULL) *r = NULL; if (f != NULL) *f = NULL; if (so != NULL) *so = NULL; if (go != NULL) *go = NULL; } void * CRYPTO_malloc_locked(int num, const char *file, int line) { if (num <= 0) return NULL; return malloc(num); } void CRYPTO_free_locked(void *ptr) { free(ptr); } void * CRYPTO_malloc(int num, const char *file, int line) { if (num <= 0) return NULL; return malloc(num); } char * CRYPTO_strdup(const char *str, const char *file, int line) { return strdup(str); } void * CRYPTO_realloc(void *ptr, int num, const char *file, int line) { if (num <= 0) return NULL; return realloc(ptr, num); } void * CRYPTO_realloc_clean(void *ptr, int old_len, int num, const char *file, int line) { void *ret = NULL; if (num <= 0) return NULL; if (num < old_len) return NULL; /* original does not support shrinking */ ret = malloc(num); if (ret && ptr && old_len > 0) { memcpy(ret, ptr, old_len); explicit_bzero(ptr, old_len); free(ptr); } return ret; } void CRYPTO_free(void *ptr) { free(ptr); } void * CRYPTO_remalloc(void *a, int num, const char *file, int line) { free(a); return malloc(num); } void CRYPTO_set_mem_debug_options(long bits) { return; } long CRYPTO_get_mem_debug_options(void) { return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/0000755000000000000000000000000012666635521020623 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/bss_acpt.c0000644000175000017500000002454212360020705020775 0ustar /* $OpenBSD: bss_acpt.c,v 1.22 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #define SOCKET_PROTOCOL IPPROTO_TCP typedef struct bio_accept_st { int state; char *param_addr; int accept_sock; int accept_nbio; char *addr; int nbio; /* If 0, it means normal, if 1, do a connect on bind failure, * and if there is no-one listening, bind with SO_REUSEADDR. * If 2, always use SO_REUSEADDR. */ int bind_mode; BIO *bio_chain; } BIO_ACCEPT; static int acpt_write(BIO *h, const char *buf, int num); static int acpt_read(BIO *h, char *buf, int size); static int acpt_puts(BIO *h, const char *str); static long acpt_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int acpt_new(BIO *h); static int acpt_free(BIO *data); static int acpt_state(BIO *b, BIO_ACCEPT *c); static void acpt_close_socket(BIO *data); static BIO_ACCEPT *BIO_ACCEPT_new(void ); static void BIO_ACCEPT_free(BIO_ACCEPT *a); #define ACPT_S_BEFORE 1 #define ACPT_S_GET_ACCEPT_SOCKET 2 #define ACPT_S_OK 3 static BIO_METHOD methods_acceptp = { .type = BIO_TYPE_ACCEPT, .name = "socket accept", .bwrite = acpt_write, .bread = acpt_read, .bputs = acpt_puts, .ctrl = acpt_ctrl, .create = acpt_new, .destroy = acpt_free }; BIO_METHOD * BIO_s_accept(void) { return (&methods_acceptp); } static int acpt_new(BIO *bi) { BIO_ACCEPT *ba; bi->init = 0; bi->num = -1; bi->flags = 0; if ((ba = BIO_ACCEPT_new()) == NULL) return (0); bi->ptr = (char *)ba; ba->state = ACPT_S_BEFORE; bi->shutdown = 1; return (1); } static BIO_ACCEPT * BIO_ACCEPT_new(void) { BIO_ACCEPT *ret; if ((ret = calloc(1, sizeof(BIO_ACCEPT))) == NULL) return (NULL); ret->accept_sock = -1; ret->bind_mode = BIO_BIND_NORMAL; return (ret); } static void BIO_ACCEPT_free(BIO_ACCEPT *a) { if (a == NULL) return; free(a->param_addr); free(a->addr); if (a->bio_chain != NULL) BIO_free(a->bio_chain); free(a); } static void acpt_close_socket(BIO *bio) { BIO_ACCEPT *c; c = (BIO_ACCEPT *)bio->ptr; if (c->accept_sock != -1) { shutdown(c->accept_sock, SHUT_RDWR); close(c->accept_sock); c->accept_sock = -1; bio->num = -1; } } static int acpt_free(BIO *a) { BIO_ACCEPT *data; if (a == NULL) return (0); data = (BIO_ACCEPT *)a->ptr; if (a->shutdown) { acpt_close_socket(a); BIO_ACCEPT_free(data); a->ptr = NULL; a->flags = 0; a->init = 0; } return (1); } static int acpt_state(BIO *b, BIO_ACCEPT *c) { BIO *bio = NULL, *dbio; int s = -1; int i; again: switch (c->state) { case ACPT_S_BEFORE: if (c->param_addr == NULL) { BIOerr(BIO_F_ACPT_STATE, BIO_R_NO_ACCEPT_PORT_SPECIFIED); return (-1); } s = BIO_get_accept_socket(c->param_addr, c->bind_mode); if (s == -1) return (-1); if (c->accept_nbio) { if (!BIO_socket_nbio(s, 1)) { close(s); BIOerr(BIO_F_ACPT_STATE, BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET); return (-1); } } c->accept_sock = s; b->num = s; c->state = ACPT_S_GET_ACCEPT_SOCKET; return (1); /* break; */ case ACPT_S_GET_ACCEPT_SOCKET: if (b->next_bio != NULL) { c->state = ACPT_S_OK; goto again; } BIO_clear_retry_flags(b); b->retry_reason = 0; i = BIO_accept(c->accept_sock, &(c->addr)); /* -2 return means we should retry */ if (i == -2) { BIO_set_retry_special(b); b->retry_reason = BIO_RR_ACCEPT; return -1; } if (i < 0) return (i); bio = BIO_new_socket(i, BIO_CLOSE); if (bio == NULL) goto err; BIO_set_callback(bio, BIO_get_callback(b)); BIO_set_callback_arg(bio, BIO_get_callback_arg(b)); if (c->nbio) { if (!BIO_socket_nbio(i, 1)) { BIOerr(BIO_F_ACPT_STATE, BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET); goto err; } } /* If the accept BIO has an bio_chain, we dup it and * put the new socket at the end. */ if (c->bio_chain != NULL) { if ((dbio = BIO_dup_chain(c->bio_chain)) == NULL) goto err; if (!BIO_push(dbio, bio)) goto err; bio = dbio; } if (BIO_push(b, bio) == NULL) goto err; c->state = ACPT_S_OK; return (1); err: if (bio != NULL) BIO_free(bio); else if (s >= 0) close(s); return (0); /* break; */ case ACPT_S_OK: if (b->next_bio == NULL) { c->state = ACPT_S_GET_ACCEPT_SOCKET; goto again; } return (1); /* break; */ default: return (0); /* break; */ } } static int acpt_read(BIO *b, char *out, int outl) { int ret = 0; BIO_ACCEPT *data; BIO_clear_retry_flags(b); data = (BIO_ACCEPT *)b->ptr; while (b->next_bio == NULL) { ret = acpt_state(b, data); if (ret <= 0) return (ret); } ret = BIO_read(b->next_bio, out, outl); BIO_copy_next_retry(b); return (ret); } static int acpt_write(BIO *b, const char *in, int inl) { int ret; BIO_ACCEPT *data; BIO_clear_retry_flags(b); data = (BIO_ACCEPT *)b->ptr; while (b->next_bio == NULL) { ret = acpt_state(b, data); if (ret <= 0) return (ret); } ret = BIO_write(b->next_bio, in, inl); BIO_copy_next_retry(b); return (ret); } static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr) { int *ip; long ret = 1; BIO_ACCEPT *data; char **pp; data = (BIO_ACCEPT *)b->ptr; switch (cmd) { case BIO_CTRL_RESET: ret = 0; data->state = ACPT_S_BEFORE; acpt_close_socket(b); b->flags = 0; break; case BIO_C_DO_STATE_MACHINE: /* use this one to start the connection */ ret = (long)acpt_state(b, data); break; case BIO_C_SET_ACCEPT: if (ptr != NULL) { if (num == 0) { b->init = 1; free(data->param_addr); data->param_addr = BUF_strdup(ptr); } else if (num == 1) { data->accept_nbio = (ptr != NULL); } else if (num == 2) { if (data->bio_chain != NULL) BIO_free(data->bio_chain); data->bio_chain = (BIO *)ptr; } } break; case BIO_C_SET_NBIO: data->nbio = (int)num; break; case BIO_C_SET_FD: b->init = 1; b->num= *((int *)ptr); data->accept_sock = b->num; data->state = ACPT_S_GET_ACCEPT_SOCKET; b->shutdown = (int)num; b->init = 1; break; case BIO_C_GET_FD: if (b->init) { ip = (int *)ptr; if (ip != NULL) *ip = data->accept_sock; ret = data->accept_sock; } else ret = -1; break; case BIO_C_GET_ACCEPT: if (b->init) { if (ptr != NULL) { pp = (char **)ptr; *pp = data->param_addr; } else ret = -1; } else ret = -1; break; case BIO_CTRL_GET_CLOSE: ret = b->shutdown; break; case BIO_CTRL_SET_CLOSE: b->shutdown = (int)num; break; case BIO_CTRL_PENDING: case BIO_CTRL_WPENDING: ret = 0; break; case BIO_CTRL_FLUSH: break; case BIO_C_SET_BIND_MODE: data->bind_mode = (int)num; break; case BIO_C_GET_BIND_MODE: ret = (long)data->bind_mode; break; case BIO_CTRL_DUP: /* dbio=(BIO *)ptr; if (data->param_port) EAY EAY BIO_set_port(dbio,data->param_port); if (data->param_hostname) BIO_set_hostname(dbio,data->param_hostname); BIO_set_nbio(dbio,data->nbio); */ break; default: ret = 0; break; } return (ret); } static int acpt_puts(BIO *bp, const char *str) { int n, ret; n = strlen(str); ret = acpt_write(bp, str, n); return (ret); } BIO * BIO_new_accept(char *str) { BIO *ret; ret = BIO_new(BIO_s_accept()); if (ret == NULL) return (NULL); if (BIO_set_accept_port(ret, str)) return (ret); else { BIO_free(ret); return (NULL); } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/bss_file.c0000644000175000017500000002126512360020705020764 0ustar /* $OpenBSD: bss_file.c,v 1.29 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* * 03-Dec-1997 rdenny@dc3.com Fix bug preventing use of stdin/stdout * with binary data (e.g. asn1parse -inform DER < xxx) under * Windows */ #ifndef HEADER_BSS_FILE_C #define HEADER_BSS_FILE_C #if defined(__linux) || defined(__sun) || defined(__hpux) /* Following definition aliases fopen to fopen64 on above mentioned * platforms. This makes it possible to open and sequentially access * files larger than 2GB from 32-bit application. It does not allow to * traverse them beyond 2GB with fseek/ftell, but on the other hand *no* * 32-bit platform permits that, not with fseek/ftell. Not to mention * that breaking 2GB limit for seeking would require surgery to *our* * API. But sequential access suffices for practical cases when you * can run into large files, such as fingerprinting, so we can let API * alone. For reference, the list of 32-bit platforms which allow for * sequential access of large files without extra "magic" comprise *BSD, * Darwin, IRIX... */ #ifndef _FILE_OFFSET_BITS #define _FILE_OFFSET_BITS 64 #endif #endif #include #include #include #include #include static int file_write(BIO *h, const char *buf, int num); static int file_read(BIO *h, char *buf, int size); static int file_puts(BIO *h, const char *str); static int file_gets(BIO *h, char *str, int size); static long file_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int file_new(BIO *h); static int file_free(BIO *data); static BIO_METHOD methods_filep = { .type = BIO_TYPE_FILE, .name = "FILE pointer", .bwrite = file_write, .bread = file_read, .bputs = file_puts, .bgets = file_gets, .ctrl = file_ctrl, .create = file_new, .destroy = file_free }; BIO * BIO_new_file(const char *filename, const char *mode) { BIO *ret; FILE *file = NULL; file = fopen(filename, mode); if (file == NULL) { SYSerr(SYS_F_FOPEN, errno); ERR_asprintf_error_data("fopen('%s', '%s')", filename, mode); if (errno == ENOENT) BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE); else BIOerr(BIO_F_BIO_NEW_FILE, ERR_R_SYS_LIB); return (NULL); } if ((ret = BIO_new(BIO_s_file())) == NULL) { fclose(file); return (NULL); } BIO_set_fp(ret, file, BIO_CLOSE); return (ret); } BIO * BIO_new_fp(FILE *stream, int close_flag) { BIO *ret; if ((ret = BIO_new(BIO_s_file())) == NULL) return (NULL); BIO_set_fp(ret, stream, close_flag); return (ret); } BIO_METHOD * BIO_s_file(void) { return (&methods_filep); } static int file_new(BIO *bi) { bi->init = 0; bi->num = 0; bi->ptr = NULL; bi->flags=0; return (1); } static int file_free(BIO *a) { if (a == NULL) return (0); if (a->shutdown) { if ((a->init) && (a->ptr != NULL)) { fclose (a->ptr); a->ptr = NULL; a->flags = 0; } a->init = 0; } return (1); } static int file_read(BIO *b, char *out, int outl) { int ret = 0; if (b->init && (out != NULL)) { ret = fread(out, 1,(int)outl,(FILE *)b->ptr); if (ret == 0 && ferror((FILE *)b->ptr)) { SYSerr(SYS_F_FREAD, errno); BIOerr(BIO_F_FILE_READ, ERR_R_SYS_LIB); ret = -1; } } return (ret); } static int file_write(BIO *b, const char *in, int inl) { int ret = 0; if (b->init && (in != NULL)) { ret = fwrite(in,(int)inl, 1,(FILE *)b->ptr); if (ret) ret = inl; /* ret=fwrite(in,1,(int)inl,(FILE *)b->ptr); */ /* according to Tim Hudson , the commented * out version above can cause 'inl' write calls under * some stupid stdio implementations (VMS) */ } return (ret); } static long file_ctrl(BIO *b, int cmd, long num, void *ptr) { long ret = 1; FILE *fp = (FILE *)b->ptr; FILE **fpp; char p[4]; switch (cmd) { case BIO_C_FILE_SEEK: case BIO_CTRL_RESET: ret = (long)fseek(fp, num, 0); break; case BIO_CTRL_EOF: ret = (long)feof(fp); break; case BIO_C_FILE_TELL: case BIO_CTRL_INFO: ret = ftell(fp); break; case BIO_C_SET_FILE_PTR: file_free(b); b->shutdown = (int)num&BIO_CLOSE; b->ptr = ptr; b->init = 1; break; case BIO_C_SET_FILENAME: file_free(b); b->shutdown = (int)num&BIO_CLOSE; if (num & BIO_FP_APPEND) { if (num & BIO_FP_READ) strlcpy(p, "a+", sizeof p); else strlcpy(p, "a", sizeof p); } else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE)) strlcpy(p, "r+", sizeof p); else if (num & BIO_FP_WRITE) strlcpy(p, "w", sizeof p); else if (num & BIO_FP_READ) strlcpy(p, "r", sizeof p); else { BIOerr(BIO_F_FILE_CTRL, BIO_R_BAD_FOPEN_MODE); ret = 0; break; } fp = fopen(ptr, p); if (fp == NULL) { SYSerr(SYS_F_FOPEN, errno); ERR_asprintf_error_data("fopen('%s', '%s')", ptr, p); BIOerr(BIO_F_FILE_CTRL, ERR_R_SYS_LIB); ret = 0; break; } b->ptr = fp; b->init = 1; break; case BIO_C_GET_FILE_PTR: /* the ptr parameter is actually a FILE ** in this case. */ if (ptr != NULL) { fpp = (FILE **)ptr; *fpp = (FILE *)b->ptr; } break; case BIO_CTRL_GET_CLOSE: ret = (long)b->shutdown; break; case BIO_CTRL_SET_CLOSE: b->shutdown = (int)num; break; case BIO_CTRL_FLUSH: fflush((FILE *)b->ptr); break; case BIO_CTRL_DUP: ret = 1; break; case BIO_CTRL_WPENDING: case BIO_CTRL_PENDING: case BIO_CTRL_PUSH: case BIO_CTRL_POP: default: ret = 0; break; } return (ret); } static int file_gets(BIO *bp, char *buf, int size) { int ret = 0; buf[0] = '\0'; if (!fgets(buf, size,(FILE *)bp->ptr)) goto err; if (buf[0] != '\0') ret = strlen(buf); err: return (ret); } static int file_puts(BIO *bp, const char *str) { int n, ret; n = strlen(str); ret = file_write(bp, str, n); return (ret); } #endif /* HEADER_BSS_FILE_C */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/bss_bio.c0000644000175000017500000004372612430034550020625 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Special method for a BIO where the other endpoint is also a BIO * of this kind, handled by the same thread (i.e. the "peer" is actually * ourselves, wearing a different hat). * Such "BIO pairs" are mainly for using the SSL library with I/O interfaces * for which no specific BIO method is available. * See ssl/ssltest.c for some hints on how this can be used. */ /* BIO_DEBUG implies BIO_PAIR_DEBUG */ #ifdef BIO_DEBUG # ifndef BIO_PAIR_DEBUG # define BIO_PAIR_DEBUG # endif #endif /* disable assert() unless BIO_PAIR_DEBUG has been defined */ #ifndef BIO_PAIR_DEBUG # ifndef NDEBUG # define NDEBUG # endif #endif #include #include #include #include #include #include #include static int bio_new(BIO *bio); static int bio_free(BIO *bio); static int bio_read(BIO *bio, char *buf, int size); static int bio_write(BIO *bio, const char *buf, int num); static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr); static int bio_puts(BIO *bio, const char *str); static int bio_make_pair(BIO *bio1, BIO *bio2); static void bio_destroy_pair(BIO *bio); static BIO_METHOD methods_biop = { .type = BIO_TYPE_BIO, .name = "BIO pair", .bwrite = bio_write, .bread = bio_read, .bputs = bio_puts, .ctrl = bio_ctrl, .create = bio_new, .destroy = bio_free }; BIO_METHOD * BIO_s_bio(void) { return &methods_biop; } struct bio_bio_st { BIO *peer; /* NULL if buf == NULL. * If peer != NULL, then peer->ptr is also a bio_bio_st, * and its "peer" member points back to us. * peer != NULL iff init != 0 in the BIO. */ /* This is for what we write (i.e. reading uses peer's struct): */ int closed; /* valid iff peer != NULL */ size_t len; /* valid iff buf != NULL; 0 if peer == NULL */ size_t offset; /* valid iff buf != NULL; 0 if len == 0 */ size_t size; char *buf; /* "size" elements (if != NULL) */ size_t request; /* valid iff peer != NULL; 0 if len != 0, * otherwise set by peer to number of bytes * it (unsuccessfully) tried to read, * never more than buffer space (size-len) warrants. */ }; static int bio_new(BIO *bio) { struct bio_bio_st *b; b = malloc(sizeof *b); if (b == NULL) return 0; b->peer = NULL; b->size = 17 * 1024; /* enough for one TLS record (just a default) */ b->buf = NULL; bio->ptr = b; return 1; } static int bio_free(BIO *bio) { struct bio_bio_st *b; if (bio == NULL) return 0; b = bio->ptr; assert(b != NULL); if (b->peer) bio_destroy_pair(bio); free(b->buf); free(b); return 1; } static int bio_read(BIO *bio, char *buf, int size_) { size_t size = size_; size_t rest; struct bio_bio_st *b, *peer_b; BIO_clear_retry_flags(bio); if (!bio->init) return 0; b = bio->ptr; assert(b != NULL); assert(b->peer != NULL); peer_b = b->peer->ptr; assert(peer_b != NULL); assert(peer_b->buf != NULL); peer_b->request = 0; /* will be set in "retry_read" situation */ if (buf == NULL || size == 0) return 0; if (peer_b->len == 0) { if (peer_b->closed) return 0; /* writer has closed, and no data is left */ else { BIO_set_retry_read(bio); /* buffer is empty */ if (size <= peer_b->size) peer_b->request = size; else /* don't ask for more than the peer can * deliver in one write */ peer_b->request = peer_b->size; return -1; } } /* we can read */ if (peer_b->len < size) size = peer_b->len; /* now read "size" bytes */ rest = size; assert(rest > 0); do /* one or two iterations */ { size_t chunk; assert(rest <= peer_b->len); if (peer_b->offset + rest <= peer_b->size) chunk = rest; else /* wrap around ring buffer */ chunk = peer_b->size - peer_b->offset; assert(peer_b->offset + chunk <= peer_b->size); memcpy(buf, peer_b->buf + peer_b->offset, chunk); peer_b->len -= chunk; if (peer_b->len) { peer_b->offset += chunk; assert(peer_b->offset <= peer_b->size); if (peer_b->offset == peer_b->size) peer_b->offset = 0; buf += chunk; } else { /* buffer now empty, no need to advance "buf" */ assert(chunk == rest); peer_b->offset = 0; } rest -= chunk; } while (rest); return size; } /* non-copying interface: provide pointer to available data in buffer * bio_nread0: return number of available bytes * bio_nread: also advance index * (example usage: bio_nread0(), read from buffer, bio_nread() * or just bio_nread(), read from buffer) */ /* WARNING: The non-copying interface is largely untested as of yet * and may contain bugs. */ static ssize_t bio_nread0(BIO *bio, char **buf) { struct bio_bio_st *b, *peer_b; ssize_t num; BIO_clear_retry_flags(bio); if (!bio->init) return 0; b = bio->ptr; assert(b != NULL); assert(b->peer != NULL); peer_b = b->peer->ptr; assert(peer_b != NULL); assert(peer_b->buf != NULL); peer_b->request = 0; if (peer_b->len == 0) { char dummy; /* avoid code duplication -- nothing available for reading */ return bio_read(bio, &dummy, 1); /* returns 0 or -1 */ } num = peer_b->len; if (peer_b->size < peer_b->offset + num) /* no ring buffer wrap-around for non-copying interface */ num = peer_b->size - peer_b->offset; assert(num > 0); if (buf != NULL) *buf = peer_b->buf + peer_b->offset; return num; } #ifdef __pnacl__ #define SSIZE_MAX LONG_MAX #endif static ssize_t bio_nread(BIO *bio, char **buf, size_t num_) { struct bio_bio_st *b, *peer_b; ssize_t num, available; if (num_ > SSIZE_MAX) num = SSIZE_MAX; else num = (ssize_t)num_; available = bio_nread0(bio, buf); if (num > available) num = available; if (num <= 0) return num; b = bio->ptr; peer_b = b->peer->ptr; peer_b->len -= num; if (peer_b->len) { peer_b->offset += num; assert(peer_b->offset <= peer_b->size); if (peer_b->offset == peer_b->size) peer_b->offset = 0; } else peer_b->offset = 0; return num; } static int bio_write(BIO *bio, const char *buf, int num_) { size_t num = num_; size_t rest; struct bio_bio_st *b; BIO_clear_retry_flags(bio); if (!bio->init || buf == NULL || num == 0) return 0; b = bio->ptr; assert(b != NULL); assert(b->peer != NULL); assert(b->buf != NULL); b->request = 0; if (b->closed) { /* we already closed */ BIOerr(BIO_F_BIO_WRITE, BIO_R_BROKEN_PIPE); return -1; } assert(b->len <= b->size); if (b->len == b->size) { BIO_set_retry_write(bio); /* buffer is full */ return -1; } /* we can write */ if (num > b->size - b->len) num = b->size - b->len; /* now write "num" bytes */ rest = num; assert(rest > 0); do /* one or two iterations */ { size_t write_offset; size_t chunk; assert(b->len + rest <= b->size); write_offset = b->offset + b->len; if (write_offset >= b->size) write_offset -= b->size; /* b->buf[write_offset] is the first byte we can write to. */ if (write_offset + rest <= b->size) chunk = rest; else /* wrap around ring buffer */ chunk = b->size - write_offset; memcpy(b->buf + write_offset, buf, chunk); b->len += chunk; assert(b->len <= b->size); rest -= chunk; buf += chunk; } while (rest); return num; } /* non-copying interface: provide pointer to region to write to * bio_nwrite0: check how much space is available * bio_nwrite: also increase length * (example usage: bio_nwrite0(), write to buffer, bio_nwrite() * or just bio_nwrite(), write to buffer) */ static ssize_t bio_nwrite0(BIO *bio, char **buf) { struct bio_bio_st *b; size_t num; size_t write_offset; BIO_clear_retry_flags(bio); if (!bio->init) return 0; b = bio->ptr; assert(b != NULL); assert(b->peer != NULL); assert(b->buf != NULL); b->request = 0; if (b->closed) { BIOerr(BIO_F_BIO_NWRITE0, BIO_R_BROKEN_PIPE); return -1; } assert(b->len <= b->size); if (b->len == b->size) { BIO_set_retry_write(bio); return -1; } num = b->size - b->len; write_offset = b->offset + b->len; if (write_offset >= b->size) write_offset -= b->size; if (write_offset + num > b->size) /* no ring buffer wrap-around for non-copying interface * (to fulfil the promise by BIO_ctrl_get_write_guarantee, * BIO_nwrite may have to be called twice) */ num = b->size - write_offset; if (buf != NULL) *buf = b->buf + write_offset; assert(write_offset + num <= b->size); return num; } static ssize_t bio_nwrite(BIO *bio, char **buf, size_t num_) { struct bio_bio_st *b; ssize_t num, space; if (num_ > SSIZE_MAX) num = SSIZE_MAX; else num = (ssize_t)num_; space = bio_nwrite0(bio, buf); if (num > space) num = space; if (num <= 0) return num; b = bio->ptr; assert(b != NULL); b->len += num; assert(b->len <= b->size); return num; } static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr) { long ret; struct bio_bio_st *b = bio->ptr; assert(b != NULL); switch (cmd) { /* specific CTRL codes */ case BIO_C_SET_WRITE_BUF_SIZE: if (b->peer) { BIOerr(BIO_F_BIO_CTRL, BIO_R_IN_USE); ret = 0; } else if (num == 0) { BIOerr(BIO_F_BIO_CTRL, BIO_R_INVALID_ARGUMENT); ret = 0; } else { size_t new_size = num; if (b->size != new_size) { if (b->buf) { free(b->buf); b->buf = NULL; } b->size = new_size; } ret = 1; } break; case BIO_C_GET_WRITE_BUF_SIZE: ret = (long) b->size; break; case BIO_C_MAKE_BIO_PAIR: { BIO *other_bio = ptr; if (bio_make_pair(bio, other_bio)) ret = 1; else ret = 0; } break; case BIO_C_DESTROY_BIO_PAIR: /* Affects both BIOs in the pair -- call just once! * Or let BIO_free(bio1); BIO_free(bio2); do the job. */ bio_destroy_pair(bio); ret = 1; break; case BIO_C_GET_WRITE_GUARANTEE: /* How many bytes can the caller feed to the next write * without having to keep any? */ if (b->peer == NULL || b->closed) ret = 0; else ret = (long) b->size - b->len; break; case BIO_C_GET_READ_REQUEST: /* If the peer unsuccessfully tried to read, how many bytes * were requested? (As with BIO_CTRL_PENDING, that number * can usually be treated as boolean.) */ ret = (long) b->request; break; case BIO_C_RESET_READ_REQUEST: /* Reset request. (Can be useful after read attempts * at the other side that are meant to be non-blocking, * e.g. when probing SSL_read to see if any data is * available.) */ b->request = 0; ret = 1; break; case BIO_C_SHUTDOWN_WR: /* similar to shutdown(..., SHUT_WR) */ b->closed = 1; ret = 1; break; case BIO_C_NREAD0: /* prepare for non-copying read */ ret = (long) bio_nread0(bio, ptr); break; case BIO_C_NREAD: /* non-copying read */ ret = (long) bio_nread(bio, ptr, (size_t) num); break; case BIO_C_NWRITE0: /* prepare for non-copying write */ ret = (long) bio_nwrite0(bio, ptr); break; case BIO_C_NWRITE: /* non-copying write */ ret = (long) bio_nwrite(bio, ptr, (size_t) num); break; /* standard CTRL codes follow */ case BIO_CTRL_RESET: if (b->buf != NULL) { b->len = 0; b->offset = 0; } ret = 0; break; case BIO_CTRL_GET_CLOSE: ret = bio->shutdown; break; case BIO_CTRL_SET_CLOSE: bio->shutdown = (int) num; ret = 1; break; case BIO_CTRL_PENDING: if (b->peer != NULL) { struct bio_bio_st *peer_b = b->peer->ptr; ret = (long) peer_b->len; } else ret = 0; break; case BIO_CTRL_WPENDING: if (b->buf != NULL) ret = (long) b->len; else ret = 0; break; case BIO_CTRL_DUP: /* See BIO_dup_chain for circumstances we have to expect. */ { BIO *other_bio = ptr; struct bio_bio_st *other_b; assert(other_bio != NULL); other_b = other_bio->ptr; assert(other_b != NULL); assert(other_b->buf == NULL); /* other_bio is always fresh */ other_b->size = b->size; } ret = 1; break; case BIO_CTRL_FLUSH: ret = 1; break; case BIO_CTRL_EOF: { BIO *other_bio = ptr; if (other_bio) { struct bio_bio_st *other_b = other_bio->ptr; assert(other_b != NULL); ret = other_b->len == 0 && other_b->closed; } else ret = 1; } break; default: ret = 0; } return ret; } static int bio_puts(BIO *bio, const char *str) { return bio_write(bio, str, strlen(str)); } static int bio_make_pair(BIO *bio1, BIO *bio2) { struct bio_bio_st *b1, *b2; assert(bio1 != NULL); assert(bio2 != NULL); b1 = bio1->ptr; b2 = bio2->ptr; if (b1->peer != NULL || b2->peer != NULL) { BIOerr(BIO_F_BIO_MAKE_PAIR, BIO_R_IN_USE); return 0; } if (b1->buf == NULL) { b1->buf = malloc(b1->size); if (b1->buf == NULL) { BIOerr(BIO_F_BIO_MAKE_PAIR, ERR_R_MALLOC_FAILURE); return 0; } b1->len = 0; b1->offset = 0; } if (b2->buf == NULL) { b2->buf = malloc(b2->size); if (b2->buf == NULL) { BIOerr(BIO_F_BIO_MAKE_PAIR, ERR_R_MALLOC_FAILURE); return 0; } b2->len = 0; b2->offset = 0; } b1->peer = bio2; b1->closed = 0; b1->request = 0; b2->peer = bio1; b2->closed = 0; b2->request = 0; bio1->init = 1; bio2->init = 1; return 1; } static void bio_destroy_pair(BIO *bio) { struct bio_bio_st *b = bio->ptr; if (b != NULL) { BIO *peer_bio = b->peer; if (peer_bio != NULL) { struct bio_bio_st *peer_b = peer_bio->ptr; assert(peer_b != NULL); assert(peer_b->peer == bio); peer_b->peer = NULL; peer_bio->init = 0; assert(peer_b->buf != NULL); peer_b->len = 0; peer_b->offset = 0; b->peer = NULL; bio->init = 0; assert(b->buf != NULL); b->len = 0; b->offset = 0; } } } /* Exported convenience functions */ int BIO_new_bio_pair(BIO **bio1_p, size_t writebuf1, BIO **bio2_p, size_t writebuf2) { BIO *bio1 = NULL, *bio2 = NULL; long r; int ret = 0; bio1 = BIO_new(BIO_s_bio()); if (bio1 == NULL) goto err; bio2 = BIO_new(BIO_s_bio()); if (bio2 == NULL) goto err; if (writebuf1) { r = BIO_set_write_buf_size(bio1, writebuf1); if (!r) goto err; } if (writebuf2) { r = BIO_set_write_buf_size(bio2, writebuf2); if (!r) goto err; } r = BIO_make_bio_pair(bio1, bio2); if (!r) goto err; ret = 1; err: if (ret == 0) { if (bio1) { BIO_free(bio1); bio1 = NULL; } if (bio2) { BIO_free(bio2); bio2 = NULL; } } *bio1_p = bio1; *bio2_p = bio2; return ret; } size_t BIO_ctrl_get_write_guarantee(BIO *bio) { return BIO_ctrl(bio, BIO_C_GET_WRITE_GUARANTEE, 0, NULL); } size_t BIO_ctrl_get_read_request(BIO *bio) { return BIO_ctrl(bio, BIO_C_GET_READ_REQUEST, 0, NULL); } int BIO_ctrl_reset_read_request(BIO *bio) { return (BIO_ctrl(bio, BIO_C_RESET_READ_REQUEST, 0, NULL) != 0); } /* BIO_nread0/nread/nwrite0/nwrite are available only for BIO pairs for now * (conceivably some other BIOs could allow non-copying reads and writes too.) */ int BIO_nread0(BIO *bio, char **buf) { long ret; if (!bio->init) { BIOerr(BIO_F_BIO_NREAD0, BIO_R_UNINITIALIZED); return -2; } ret = BIO_ctrl(bio, BIO_C_NREAD0, 0, buf); if (ret > INT_MAX) return INT_MAX; else return (int) ret; } int BIO_nread(BIO *bio, char **buf, int num) { int ret; if (!bio->init) { BIOerr(BIO_F_BIO_NREAD, BIO_R_UNINITIALIZED); return -2; } ret = (int) BIO_ctrl(bio, BIO_C_NREAD, num, buf); if (ret > 0) bio->num_read += ret; return ret; } int BIO_nwrite0(BIO *bio, char **buf) { long ret; if (!bio->init) { BIOerr(BIO_F_BIO_NWRITE0, BIO_R_UNINITIALIZED); return -2; } ret = BIO_ctrl(bio, BIO_C_NWRITE0, 0, buf); if (ret > INT_MAX) return INT_MAX; else return (int) ret; } int BIO_nwrite(BIO *bio, char **buf, int num) { int ret; if (!bio->init) { BIOerr(BIO_F_BIO_NWRITE, BIO_R_UNINITIALIZED); return -2; } ret = BIO_ctrl(bio, BIO_C_NWRITE, num, buf); if (ret > 0) bio->num_write += ret; return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/bf_nbio.c0000644000175000017500000001472512360020705020577 0ustar /* $OpenBSD: bf_nbio.c,v 1.16 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include /* BIO_put and BIO_get both add to the digest, * BIO_gets returns the digest */ static int nbiof_write(BIO *h, const char *buf, int num); static int nbiof_read(BIO *h, char *buf, int size); static int nbiof_puts(BIO *h, const char *str); static int nbiof_gets(BIO *h, char *str, int size); static long nbiof_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int nbiof_new(BIO *h); static int nbiof_free(BIO *data); static long nbiof_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); typedef struct nbio_test_st { /* only set if we sent a 'should retry' error */ int lrn; int lwn; } NBIO_TEST; static BIO_METHOD methods_nbiof = { .type = BIO_TYPE_NBIO_TEST, .name = "non-blocking IO test filter", .bwrite = nbiof_write, .bread = nbiof_read, .bputs = nbiof_puts, .bgets = nbiof_gets, .ctrl = nbiof_ctrl, .create = nbiof_new, .destroy = nbiof_free, .callback_ctrl = nbiof_callback_ctrl }; BIO_METHOD * BIO_f_nbio_test(void) { return (&methods_nbiof); } static int nbiof_new(BIO *bi) { NBIO_TEST *nt; if (!(nt = malloc(sizeof(NBIO_TEST)))) return (0); nt->lrn = -1; nt->lwn = -1; bi->ptr = (char *)nt; bi->init = 1; bi->flags = 0; return (1); } static int nbiof_free(BIO *a) { if (a == NULL) return (0); free(a->ptr); a->ptr = NULL; a->init = 0; a->flags = 0; return (1); } static int nbiof_read(BIO *b, char *out, int outl) { int ret = 0; #if 1 int num; unsigned char n; #endif if (out == NULL) return (0); if (b->next_bio == NULL) return (0); BIO_clear_retry_flags(b); #if 1 RAND_pseudo_bytes(&n, 1); num = (n & 0x07); if (outl > num) outl = num; if (num == 0) { ret = -1; BIO_set_retry_read(b); } else #endif { ret = BIO_read(b->next_bio, out, outl); if (ret < 0) BIO_copy_next_retry(b); } return (ret); } static int nbiof_write(BIO *b, const char *in, int inl) { NBIO_TEST *nt; int ret = 0; int num; unsigned char n; if ((in == NULL) || (inl <= 0)) return (0); if (b->next_bio == NULL) return (0); nt = (NBIO_TEST *)b->ptr; BIO_clear_retry_flags(b); #if 1 if (nt->lwn > 0) { num = nt->lwn; nt->lwn = 0; } else { RAND_pseudo_bytes(&n, 1); num = (n&7); } if (inl > num) inl = num; if (num == 0) { ret = -1; BIO_set_retry_write(b); } else #endif { ret = BIO_write(b->next_bio, in, inl); if (ret < 0) { BIO_copy_next_retry(b); nt->lwn = inl; } } return (ret); } static long nbiof_ctrl(BIO *b, int cmd, long num, void *ptr) { long ret; if (b->next_bio == NULL) return (0); switch (cmd) { case BIO_C_DO_STATE_MACHINE: BIO_clear_retry_flags(b); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); BIO_copy_next_retry(b); break; case BIO_CTRL_DUP: ret = 0L; break; default: ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; } return (ret); } static long nbiof_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) { long ret = 1; if (b->next_bio == NULL) return (0); switch (cmd) { default: ret = BIO_callback_ctrl(b->next_bio, cmd, fp); break; } return (ret); } static int nbiof_gets(BIO *bp, char *buf, int size) { if (bp->next_bio == NULL) return (0); return (BIO_gets(bp->next_bio, buf, size)); } static int nbiof_puts(BIO *bp, const char *str) { if (bp->next_bio == NULL) return (0); return (BIO_puts(bp->next_bio, str)); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/bss_null.c0000644000175000017500000001135012360020705021011 0ustar /* $OpenBSD: bss_null.c,v 1.9 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include static int null_write(BIO *h, const char *buf, int num); static int null_read(BIO *h, char *buf, int size); static int null_puts(BIO *h, const char *str); static int null_gets(BIO *h, char *str, int size); static long null_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int null_new(BIO *h); static int null_free(BIO *data); static BIO_METHOD null_method = { .type = BIO_TYPE_NULL, .name = "NULL", .bwrite = null_write, .bread = null_read, .bputs = null_puts, .bgets = null_gets, .ctrl = null_ctrl, .create = null_new, .destroy = null_free }; BIO_METHOD * BIO_s_null(void) { return (&null_method); } static int null_new(BIO *bi) { bi->init = 1; bi->num = 0; bi->ptr = (NULL); return (1); } static int null_free(BIO *a) { if (a == NULL) return (0); return (1); } static int null_read(BIO *b, char *out, int outl) { return (0); } static int null_write(BIO *b, const char *in, int inl) { return (inl); } static long null_ctrl(BIO *b, int cmd, long num, void *ptr) { long ret = 1; switch (cmd) { case BIO_CTRL_RESET: case BIO_CTRL_EOF: case BIO_CTRL_SET: case BIO_CTRL_SET_CLOSE: case BIO_CTRL_FLUSH: case BIO_CTRL_DUP: ret = 1; break; case BIO_CTRL_GET_CLOSE: case BIO_CTRL_INFO: case BIO_CTRL_GET: case BIO_CTRL_PENDING: case BIO_CTRL_WPENDING: default: ret = 0; break; } return (ret); } static int null_gets(BIO *bp, char *buf, int size) { return (0); } static int null_puts(BIO *bp, const char *str) { if (str == NULL) return (0); return (strlen(str)); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/bss_mem.c0000644000175000017500000001754712360020705020633 0ustar /* $OpenBSD: bss_mem.c,v 1.12 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include static int mem_write(BIO *h, const char *buf, int num); static int mem_read(BIO *h, char *buf, int size); static int mem_puts(BIO *h, const char *str); static int mem_gets(BIO *h, char *str, int size); static long mem_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int mem_new(BIO *h); static int mem_free(BIO *data); static BIO_METHOD mem_method = { .type = BIO_TYPE_MEM, .name = "memory buffer", .bwrite = mem_write, .bread = mem_read, .bputs = mem_puts, .bgets = mem_gets, .ctrl = mem_ctrl, .create = mem_new, .destroy = mem_free }; /* bio->num is used to hold the value to return on 'empty', if it is * 0, should_retry is not set */ BIO_METHOD * BIO_s_mem(void) { return (&mem_method); } BIO * BIO_new_mem_buf(void *buf, int len) { BIO *ret; BUF_MEM *b; size_t sz; if (!buf) { BIOerr(BIO_F_BIO_NEW_MEM_BUF, BIO_R_NULL_PARAMETER); return NULL; } sz = (len < 0) ? strlen(buf) : (size_t)len; if (!(ret = BIO_new(BIO_s_mem()))) return NULL; b = (BUF_MEM *)ret->ptr; b->data = buf; b->length = sz; b->max = sz; ret->flags |= BIO_FLAGS_MEM_RDONLY; /* Since this is static data retrying wont help */ ret->num = 0; return ret; } static int mem_new(BIO *bi) { BUF_MEM *b; if ((b = BUF_MEM_new()) == NULL) return (0); bi->shutdown = 1; bi->init = 1; bi->num = -1; bi->ptr = (char *)b; return (1); } static int mem_free(BIO *a) { if (a == NULL) return (0); if (a->shutdown) { if ((a->init) && (a->ptr != NULL)) { BUF_MEM *b; b = (BUF_MEM *)a->ptr; if (a->flags & BIO_FLAGS_MEM_RDONLY) b->data = NULL; BUF_MEM_free(b); a->ptr = NULL; } } return (1); } static int mem_read(BIO *b, char *out, int outl) { int ret = -1; BUF_MEM *bm; bm = (BUF_MEM *)b->ptr; BIO_clear_retry_flags(b); ret = (outl >=0 && (size_t)outl > bm->length) ? (int)bm->length : outl; if ((out != NULL) && (ret > 0)) { memcpy(out, bm->data, ret); bm->length -= ret; if (b->flags & BIO_FLAGS_MEM_RDONLY) bm->data += ret; else { memmove(&(bm->data[0]), &(bm->data[ret]), bm->length); } } else if (bm->length == 0) { ret = b->num; if (ret != 0) BIO_set_retry_read(b); } return (ret); } static int mem_write(BIO *b, const char *in, int inl) { int ret = -1; int blen; BUF_MEM *bm; bm = (BUF_MEM *)b->ptr; if (in == NULL) { BIOerr(BIO_F_MEM_WRITE, BIO_R_NULL_PARAMETER); goto end; } if (b->flags & BIO_FLAGS_MEM_RDONLY) { BIOerr(BIO_F_MEM_WRITE, BIO_R_WRITE_TO_READ_ONLY_BIO); goto end; } BIO_clear_retry_flags(b); blen = bm->length; if (BUF_MEM_grow_clean(bm, blen + inl) != (blen + inl)) goto end; memcpy(&(bm->data[blen]), in, inl); ret = inl; end: return (ret); } static long mem_ctrl(BIO *b, int cmd, long num, void *ptr) { long ret = 1; char **pptr; BUF_MEM *bm = (BUF_MEM *)b->ptr; switch (cmd) { case BIO_CTRL_RESET: if (bm->data != NULL) { /* For read only case reset to the start again */ if (b->flags & BIO_FLAGS_MEM_RDONLY) { bm->data -= bm->max - bm->length; bm->length = bm->max; } else { memset(bm->data, 0, bm->max); bm->length = 0; } } break; case BIO_CTRL_EOF: ret = (long)(bm->length == 0); break; case BIO_C_SET_BUF_MEM_EOF_RETURN: b->num = (int)num; break; case BIO_CTRL_INFO: ret = (long)bm->length; if (ptr != NULL) { pptr = (char **)ptr; *pptr = (char *)&(bm->data[0]); } break; case BIO_C_SET_BUF_MEM: mem_free(b); b->shutdown = (int)num; b->ptr = ptr; break; case BIO_C_GET_BUF_MEM_PTR: if (ptr != NULL) { pptr = (char **)ptr; *pptr = (char *)bm; } break; case BIO_CTRL_GET_CLOSE: ret = (long)b->shutdown; break; case BIO_CTRL_SET_CLOSE: b->shutdown = (int)num; break; case BIO_CTRL_WPENDING: ret = 0L; break; case BIO_CTRL_PENDING: ret = (long)bm->length; break; case BIO_CTRL_DUP: case BIO_CTRL_FLUSH: ret = 1; break; case BIO_CTRL_PUSH: case BIO_CTRL_POP: default: ret = 0; break; } return (ret); } static int mem_gets(BIO *bp, char *buf, int size) { int i, j; int ret = -1; char *p; BUF_MEM *bm = (BUF_MEM *)bp->ptr; BIO_clear_retry_flags(bp); j = bm->length; if ((size - 1) < j) j = size - 1; if (j <= 0) { *buf = '\0'; return 0; } p = bm->data; for (i = 0; i < j; i++) { if (p[i] == '\n') { i++; break; } } /* * i is now the max num of bytes to copy, either j or up to * and including the first newline */ i = mem_read(bp, buf, i); if (i > 0) buf[i] = '\0'; ret = i; return (ret); } static int mem_puts(BIO *bp, const char *str) { int n, ret; n = strlen(str); ret = mem_write(bp, str, n); /* memory semantics is that it will always work */ return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/b_sock.c0000644000175000017500000002656312430034550020445 0ustar /* $OpenBSD: b_sock.c,v 1.53 2014/07/10 21:57:40 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int BIO_get_host_ip(const char *str, unsigned char *ip) { int i; int err = 1; int locked = 0; struct hostent *he; if (inet_pton(AF_INET, str, ip) == 1) return (1); /* do a gethostbyname */ CRYPTO_w_lock(CRYPTO_LOCK_GETHOSTBYNAME); locked = 1; he = BIO_gethostbyname(str); if (he == NULL) { BIOerr(BIO_F_BIO_GET_HOST_IP, BIO_R_BAD_HOSTNAME_LOOKUP); goto err; } /* cast to short because of win16 winsock definition */ if ((short)he->h_addrtype != AF_INET) { BIOerr(BIO_F_BIO_GET_HOST_IP, BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET); goto err; } for (i = 0; i < 4; i++) ip[i] = he->h_addr_list[0][i]; err = 0; err: if (locked) CRYPTO_w_unlock(CRYPTO_LOCK_GETHOSTBYNAME); if (err) { ERR_asprintf_error_data("host=%s", str); return 0; } else return 1; } int BIO_get_port(const char *str, unsigned short *port_ptr) { struct addrinfo *res = NULL; struct addrinfo hints = { .ai_family = AF_UNSPEC, .ai_socktype = SOCK_STREAM, .ai_flags = AI_PASSIVE, }; long port; char *ep; if (str == NULL) { BIOerr(BIO_F_BIO_GET_PORT, BIO_R_NO_PORT_SPECIFIED); return (0); } errno = 0; port = strtol(str, &ep, 10); if (str[0] != '\0' && *ep == '\0') { if (errno == ERANGE && (port == LONG_MAX || port == LONG_MIN)) { BIOerr(BIO_F_BIO_GET_PORT, BIO_R_INVALID_PORT_NUMBER); return (0); } if (port < 0 || port > 65535) { BIOerr(BIO_F_BIO_GET_PORT, BIO_R_INVALID_PORT_NUMBER); return (0); } goto done; } if (getaddrinfo(NULL, str, &hints, &res) == 0) { port = ntohs(((struct sockaddr_in *)(res->ai_addr))->sin_port); goto done; } if (strcmp(str, "http") == 0) port = 80; else if (strcmp(str, "telnet") == 0) port = 23; else if (strcmp(str, "socks") == 0) port = 1080; else if (strcmp(str, "https") == 0) port = 443; else if (strcmp(str, "ssl") == 0) port = 443; else if (strcmp(str, "ftp") == 0) port = 21; else if (strcmp(str, "gopher") == 0) port = 70; else { SYSerr(SYS_F_GETSERVBYNAME, errno); ERR_asprintf_error_data("service='%s'", str); return (0); } done: if (res) freeaddrinfo(res); *port_ptr = (unsigned short)port; return (1); } int BIO_sock_error(int sock) { socklen_t len; int err; len = sizeof(err); if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &err, &len) != 0) return (1); return (err); } struct hostent * BIO_gethostbyname(const char *name) { return gethostbyname(name); } int BIO_sock_init(void) { return (1); } void BIO_sock_cleanup(void) { } int BIO_socket_ioctl(int fd, long type, void *arg) { int ret; ret = ioctl(fd, type, arg); if (ret < 0) SYSerr(SYS_F_IOCTLSOCKET, errno); return (ret); } int BIO_get_accept_socket(char *host, int bind_mode) { int ret = 0; union { struct sockaddr sa; struct sockaddr_in sa_in; struct sockaddr_in6 sa_in6; } server, client; int s = -1, cs, addrlen; unsigned char ip[4]; unsigned short port; char *str = NULL, *e; char *h, *p; unsigned long l; int err_num; if ((str = BUF_strdup(host)) == NULL) return (-1); h = p = NULL; h = str; for (e = str; *e; e++) { if (*e == ':') { p = e; } else if (*e == '/') { *e = '\0'; break; } } /* points at last ':', '::port' is special [see below] */ if (p) *p++ = '\0'; else p = h, h = NULL; do { struct addrinfo *res, hint; /* * '::port' enforces IPv6 wildcard listener. Some OSes, * e.g. Solaris, default to IPv6 without any hint. Also * note that commonly IPv6 wildchard socket can service * IPv4 connections just as well... */ memset(&hint, 0, sizeof(hint)); hint.ai_flags = AI_PASSIVE; if (h) { if (strchr(h, ':')) { if (h[1] == '\0') h = NULL; hint.ai_family = AF_INET6; } else if (h[0] == '*' && h[1] == '\0') { hint.ai_family = AF_INET; h = NULL; } } if (getaddrinfo(h, p, &hint, &res)) break; addrlen = res->ai_addrlen <= sizeof(server) ? res->ai_addrlen : sizeof(server); memcpy(&server, res->ai_addr, addrlen); freeaddrinfo(res); goto again; } while (0); if (!BIO_get_port(p, &port)) goto err; memset((char *)&server, 0, sizeof(server)); server.sa_in.sin_family = AF_INET; server.sa_in.sin_port = htons(port); addrlen = sizeof(server.sa_in); if (h == NULL || strcmp(h, "*") == 0) server.sa_in.sin_addr.s_addr = INADDR_ANY; else { if (!BIO_get_host_ip(h, &(ip[0]))) goto err; l = (unsigned long)((unsigned long)ip[0]<<24L)| ((unsigned long)ip[1]<<16L)| ((unsigned long)ip[2]<< 8L)| ((unsigned long)ip[3]); server.sa_in.sin_addr.s_addr = htonl(l); } again: s = socket(server.sa.sa_family, SOCK_STREAM, IPPROTO_TCP); if (s == -1) { SYSerr(SYS_F_SOCKET, errno); ERR_asprintf_error_data("port='%s'", host); BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_CREATE_SOCKET); goto err; } if (bind_mode == BIO_BIND_REUSEADDR) { int i = 1; ret = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&i, sizeof(i)); bind_mode = BIO_BIND_NORMAL; } if (bind(s, &server.sa, addrlen) == -1) { err_num = errno; if ((bind_mode == BIO_BIND_REUSEADDR_IF_UNUSED) && (err_num == EADDRINUSE)) { client = server; if (h == NULL || strcmp(h, "*") == 0) { if (client.sa.sa_family == AF_INET6) { memset(&client.sa_in6.sin6_addr, 0, sizeof(client.sa_in6.sin6_addr)); client.sa_in6.sin6_addr.s6_addr[15] = 1; } else if (client.sa.sa_family == AF_INET) { client.sa_in.sin_addr.s_addr = htonl(0x7F000001); } else goto err; } cs = socket(client.sa.sa_family, SOCK_STREAM, IPPROTO_TCP); if (cs != -1) { int ii; ii = connect(cs, &client.sa, addrlen); close(cs); if (ii == -1) { bind_mode = BIO_BIND_REUSEADDR; close(s); goto again; } /* else error */ } /* else error */ } SYSerr(SYS_F_BIND, err_num); ERR_asprintf_error_data("port='%s'", host); BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_BIND_SOCKET); goto err; } if (listen(s, SOMAXCONN) == -1) { SYSerr(SYS_F_BIND, errno); ERR_asprintf_error_data("port='%s'", host); BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_LISTEN_SOCKET); goto err; } ret = 1; err: free(str); if ((ret == 0) && (s != -1)) { close(s); s = -1; } return (s); } int BIO_accept(int sock, char **addr) { int ret = -1; unsigned long l; unsigned short port; char *p, *tmp; struct { socklen_t len; union { struct sockaddr sa; struct sockaddr_in sa_in; struct sockaddr_in6 sa_in6; } from; } sa; sa.len = sizeof(sa.from); memset(&sa.from, 0, sizeof(sa.from)); ret = accept(sock, &sa.from.sa, &sa.len); if (ret == -1) { if (BIO_sock_should_retry(ret)) return -2; SYSerr(SYS_F_ACCEPT, errno); BIOerr(BIO_F_BIO_ACCEPT, BIO_R_ACCEPT_ERROR); goto end; } if (addr == NULL) goto end; do { char h[NI_MAXHOST], s[NI_MAXSERV]; size_t nl; if (getnameinfo(&sa.from.sa, sa.len, h, sizeof(h), s, sizeof(s), NI_NUMERICHOST|NI_NUMERICSERV)) break; nl = strlen(h) + strlen(s) + 2; p = *addr; if (p) *p = '\0'; if (!(tmp = realloc(p, nl))) { close(ret); ret = -1; free(p); *addr = NULL; BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE); goto end; } p = tmp; *addr = p; snprintf(*addr, nl, "%s:%s", h, s); goto end; } while (0); if (sa.from.sa.sa_family != AF_INET) goto end; l = ntohl(sa.from.sa_in.sin_addr.s_addr); port = ntohs(sa.from.sa_in.sin_port); if (*addr == NULL) { if ((p = malloc(24)) == NULL) { close(ret); ret = -1; BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE); goto end; } *addr = p; } snprintf(*addr, 24, "%d.%d.%d.%d:%d", (unsigned char)(l >> 24L) & 0xff, (unsigned char)(l >> 16L) & 0xff, (unsigned char)(l >> 8L) & 0xff, (unsigned char)(l) & 0xff, port); end: return (ret); } int BIO_set_tcp_ndelay(int s, int on) { return (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)) == 0); } int BIO_socket_nbio(int s, int mode) { #ifdef __pnacl__ #define FIONBIO 0x5421 #endif return (BIO_socket_ioctl(s, FIONBIO, &mode) == 0); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/bf_null.c0000644000175000017500000001320512360020705020612 0ustar /* $OpenBSD: bf_null.c,v 1.10 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include /* BIO_put and BIO_get both add to the digest, * BIO_gets returns the digest */ static int nullf_write(BIO *h, const char *buf, int num); static int nullf_read(BIO *h, char *buf, int size); static int nullf_puts(BIO *h, const char *str); static int nullf_gets(BIO *h, char *str, int size); static long nullf_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int nullf_new(BIO *h); static int nullf_free(BIO *data); static long nullf_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); static BIO_METHOD methods_nullf = { .type = BIO_TYPE_NULL_FILTER, .name = "NULL filter", .bwrite = nullf_write, .bread = nullf_read, .bputs = nullf_puts, .bgets = nullf_gets, .ctrl = nullf_ctrl, .create = nullf_new, .destroy = nullf_free, .callback_ctrl = nullf_callback_ctrl }; BIO_METHOD * BIO_f_null(void) { return (&methods_nullf); } static int nullf_new(BIO *bi) { bi->init = 1; bi->ptr = NULL; bi->flags = 0; return (1); } static int nullf_free(BIO *a) { if (a == NULL) return (0); /* a->ptr=NULL; a->init=0; a->flags=0;*/ return (1); } static int nullf_read(BIO *b, char *out, int outl) { int ret = 0; if (out == NULL) return (0); if (b->next_bio == NULL) return (0); ret = BIO_read(b->next_bio, out, outl); BIO_clear_retry_flags(b); BIO_copy_next_retry(b); return (ret); } static int nullf_write(BIO *b, const char *in, int inl) { int ret = 0; if ((in == NULL) || (inl <= 0)) return (0); if (b->next_bio == NULL) return (0); ret = BIO_write(b->next_bio, in, inl); BIO_clear_retry_flags(b); BIO_copy_next_retry(b); return (ret); } static long nullf_ctrl(BIO *b, int cmd, long num, void *ptr) { long ret; if (b->next_bio == NULL) return (0); switch (cmd) { case BIO_C_DO_STATE_MACHINE: BIO_clear_retry_flags(b); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); BIO_copy_next_retry(b); break; case BIO_CTRL_DUP: ret = 0L; break; default: ret = BIO_ctrl(b->next_bio, cmd, num, ptr); } return (ret); } static long nullf_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) { long ret = 1; if (b->next_bio == NULL) return (0); switch (cmd) { default: ret = BIO_callback_ctrl(b->next_bio, cmd, fp); break; } return (ret); } static int nullf_gets(BIO *bp, char *buf, int size) { if (bp->next_bio == NULL) return (0); return (BIO_gets(bp->next_bio, buf, size)); } static int nullf_puts(BIO *bp, const char *str) { if (bp->next_bio == NULL) return (0); return (BIO_puts(bp->next_bio, str)); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/bss_dgram.c0000644000175000017500000012207212360020705021135 0ustar /* $OpenBSD: bss_dgram.c,v 1.31 2014/07/11 08:44:47 jsing Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. */ /* ==================================================================== * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_DGRAM #ifndef OPENSSL_NO_SCTP #include #include #define OPENSSL_SCTP_DATA_CHUNK_TYPE 0x00 #define OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE 0xc0 #endif #if defined(OPENSSL_SYS_LINUX) && !defined(IP_MTU) #define IP_MTU 14 /* linux is lame */ #endif static int dgram_write(BIO *h, const char *buf, int num); static int dgram_read(BIO *h, char *buf, int size); static int dgram_puts(BIO *h, const char *str); static long dgram_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int dgram_new(BIO *h); static int dgram_free(BIO *data); static int dgram_clear(BIO *bio); #ifndef OPENSSL_NO_SCTP static int dgram_sctp_write(BIO *h, const char *buf, int num); static int dgram_sctp_read(BIO *h, char *buf, int size); static int dgram_sctp_puts(BIO *h, const char *str); static long dgram_sctp_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int dgram_sctp_new(BIO *h); static int dgram_sctp_free(BIO *data); #ifdef SCTP_AUTHENTICATION_EVENT static void dgram_sctp_handle_auth_free_key_event(BIO *b, union sctp_notification *snp); #endif #endif static int BIO_dgram_should_retry(int s); static void get_current_time(struct timeval *t); static BIO_METHOD methods_dgramp = { .type = BIO_TYPE_DGRAM, .name = "datagram socket", .bwrite = dgram_write, .bread = dgram_read, .bputs = dgram_puts, .ctrl = dgram_ctrl, .create = dgram_new, .destroy = dgram_free }; #ifndef OPENSSL_NO_SCTP static BIO_METHOD methods_dgramp_sctp = { .type = BIO_TYPE_DGRAM_SCTP, .name = "datagram sctp socket", .bwrite = dgram_sctp_write, .bread = dgram_sctp_read, .bputs = dgram_sctp_puts, .ctrl = dgram_sctp_ctrl, .create = dgram_sctp_new, .destroy = dgram_sctp_free }; #endif typedef struct bio_dgram_data_st { union { struct sockaddr sa; struct sockaddr_in sa_in; struct sockaddr_in6 sa_in6; } peer; unsigned int connected; unsigned int _errno; unsigned int mtu; struct timeval next_timeout; struct timeval socket_timeout; } bio_dgram_data; #ifndef OPENSSL_NO_SCTP typedef struct bio_dgram_sctp_save_message_st { BIO *bio; char *data; int length; } bio_dgram_sctp_save_message; typedef struct bio_dgram_sctp_data_st { union { struct sockaddr sa; struct sockaddr_in sa_in; struct sockaddr_in6 sa_in6; } peer; unsigned int connected; unsigned int _errno; unsigned int mtu; struct bio_dgram_sctp_sndinfo sndinfo; struct bio_dgram_sctp_rcvinfo rcvinfo; struct bio_dgram_sctp_prinfo prinfo; void (*handle_notifications)(BIO *bio, void *context, void *buf); void* notification_context; int in_handshake; int ccs_rcvd; int ccs_sent; int save_shutdown; int peer_auth_tested; bio_dgram_sctp_save_message saved_message; } bio_dgram_sctp_data; #endif BIO_METHOD * BIO_s_datagram(void) { return (&methods_dgramp); } BIO * BIO_new_dgram(int fd, int close_flag) { BIO *ret; ret = BIO_new(BIO_s_datagram()); if (ret == NULL) return (NULL); BIO_set_fd(ret, fd, close_flag); return (ret); } static int dgram_new(BIO *bi) { bio_dgram_data *data = NULL; bi->init = 0; bi->num = 0; data = calloc(1, sizeof(bio_dgram_data)); if (data == NULL) return 0; bi->ptr = data; bi->flags = 0; return (1); } static int dgram_free(BIO *a) { bio_dgram_data *data; if (a == NULL) return (0); if (!dgram_clear(a)) return 0; data = (bio_dgram_data *)a->ptr; free(data); return (1); } static int dgram_clear(BIO *a) { if (a == NULL) return (0); if (a->shutdown) { if (a->init) { shutdown(a->num, SHUT_RDWR); close(a->num); } a->init = 0; a->flags = 0; } return (1); } static void dgram_adjust_rcv_timeout(BIO *b) { #if defined(SO_RCVTIMEO) bio_dgram_data *data = (bio_dgram_data *)b->ptr; union { size_t s; int i; } sz = {0}; /* Is a timer active? */ if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0) { struct timeval timenow, timeleft; /* Read current socket timeout */ sz.i = sizeof(data->socket_timeout); if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, &(data->socket_timeout), (void *)&sz) < 0) { perror("getsockopt"); } else if (sizeof(sz.s) != sizeof(sz.i) && sz.i == 0) OPENSSL_assert(sz.s <= sizeof(data->socket_timeout)); /* Get current time */ get_current_time(&timenow); /* Calculate time left until timer expires */ memcpy(&timeleft, &(data->next_timeout), sizeof(struct timeval)); timeleft.tv_sec -= timenow.tv_sec; timeleft.tv_usec -= timenow.tv_usec; if (timeleft.tv_usec < 0) { timeleft.tv_sec--; timeleft.tv_usec += 1000000; } if (timeleft.tv_sec < 0) { timeleft.tv_sec = 0; timeleft.tv_usec = 1; } /* Adjust socket timeout if next handhake message timer * will expire earlier. */ if ((data->socket_timeout.tv_sec == 0 && data->socket_timeout.tv_usec == 0) || (data->socket_timeout.tv_sec > timeleft.tv_sec) || (data->socket_timeout.tv_sec == timeleft.tv_sec && data->socket_timeout.tv_usec >= timeleft.tv_usec)) { if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, &timeleft, sizeof(struct timeval)) < 0) { perror("setsockopt"); } } } #endif } static void dgram_reset_rcv_timeout(BIO *b) { #if defined(SO_RCVTIMEO) bio_dgram_data *data = (bio_dgram_data *)b->ptr; /* Is a timer active? */ if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0) { if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, &(data->socket_timeout), sizeof(struct timeval)) < 0) { perror("setsockopt"); } } #endif } static int dgram_read(BIO *b, char *out, int outl) { int ret = 0; bio_dgram_data *data = (bio_dgram_data *)b->ptr; struct { socklen_t len; union { struct sockaddr sa; struct sockaddr_in sa_in; struct sockaddr_in6 sa_in6; } peer; } sa; sa.len = sizeof(sa.peer); if (out != NULL) { errno = 0; memset(&sa.peer, 0x00, sizeof(sa.peer)); dgram_adjust_rcv_timeout(b); ret = recvfrom(b->num, out, outl, 0, &sa.peer.sa, &sa.len); if (! data->connected && ret >= 0) BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, &sa.peer); BIO_clear_retry_flags(b); if (ret < 0) { if (BIO_dgram_should_retry(ret)) { BIO_set_retry_read(b); data->_errno = errno; } } dgram_reset_rcv_timeout(b); } return (ret); } static int dgram_write(BIO *b, const char *in, int inl) { int ret; bio_dgram_data *data = (bio_dgram_data *)b->ptr; errno = 0; if (data->connected) ret = write(b->num, in, inl); else { int peerlen = sizeof(data->peer); if (data->peer.sa.sa_family == AF_INET) peerlen = sizeof(data->peer.sa_in); else if (data->peer.sa.sa_family == AF_INET6) peerlen = sizeof(data->peer.sa_in6); ret = sendto(b->num, in, inl, 0, &data->peer.sa, peerlen); } BIO_clear_retry_flags(b); if (ret <= 0) { if (BIO_dgram_should_retry(ret)) { BIO_set_retry_write(b); data->_errno = errno; /* * higher layers are responsible for querying MTU, * if necessary */ } } return (ret); } static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr) { long ret = 1; int *ip; struct sockaddr *to = NULL; bio_dgram_data *data = NULL; #if defined(OPENSSL_SYS_LINUX) && (defined(IP_MTU_DISCOVER) || defined(IP_MTU)) int sockopt_val = 0; socklen_t sockopt_len; /* assume that system supporting IP_MTU is * modern enough to define socklen_t */ socklen_t addr_len; union { struct sockaddr sa; struct sockaddr_in s4; struct sockaddr_in6 s6; } addr; #endif data = (bio_dgram_data *)b->ptr; switch (cmd) { case BIO_CTRL_RESET: num = 0; case BIO_C_FILE_SEEK: ret = 0; break; case BIO_C_FILE_TELL: case BIO_CTRL_INFO: ret = 0; break; case BIO_C_SET_FD: dgram_clear(b); b->num= *((int *)ptr); b->shutdown = (int)num; b->init = 1; break; case BIO_C_GET_FD: if (b->init) { ip = (int *)ptr; if (ip != NULL) *ip = b->num; ret = b->num; } else ret = -1; break; case BIO_CTRL_GET_CLOSE: ret = b->shutdown; break; case BIO_CTRL_SET_CLOSE: b->shutdown = (int)num; break; case BIO_CTRL_PENDING: case BIO_CTRL_WPENDING: ret = 0; break; case BIO_CTRL_DUP: case BIO_CTRL_FLUSH: ret = 1; break; case BIO_CTRL_DGRAM_CONNECT: to = (struct sockaddr *)ptr; switch (to->sa_family) { case AF_INET: memcpy(&data->peer, to, sizeof(data->peer.sa_in)); break; case AF_INET6: memcpy(&data->peer, to, sizeof(data->peer.sa_in6)); break; default: memcpy(&data->peer, to, sizeof(data->peer.sa)); break; } break; /* (Linux)kernel sets DF bit on outgoing IP packets */ case BIO_CTRL_DGRAM_MTU_DISCOVER: #if defined(OPENSSL_SYS_LINUX) && defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO) addr_len = (socklen_t)sizeof(addr); memset((void *)&addr, 0, sizeof(addr)); if (getsockname(b->num, &addr.sa, &addr_len) < 0) { ret = 0; break; } switch (addr.sa.sa_family) { case AF_INET: sockopt_val = IP_PMTUDISC_DO; if ((ret = setsockopt(b->num, IPPROTO_IP, IP_MTU_DISCOVER, &sockopt_val, sizeof(sockopt_val))) < 0) perror("setsockopt"); break; #if defined(IPV6_MTU_DISCOVER) && defined(IPV6_PMTUDISC_DO) case AF_INET6: sockopt_val = IPV6_PMTUDISC_DO; if ((ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_MTU_DISCOVER, &sockopt_val, sizeof(sockopt_val))) < 0) perror("setsockopt"); break; #endif default: ret = -1; break; } ret = -1; #else break; #endif case BIO_CTRL_DGRAM_QUERY_MTU: #if defined(OPENSSL_SYS_LINUX) && defined(IP_MTU) addr_len = (socklen_t)sizeof(addr); memset((void *)&addr, 0, sizeof(addr)); if (getsockname(b->num, &addr.sa, &addr_len) < 0) { ret = 0; break; } sockopt_len = sizeof(sockopt_val); switch (addr.sa.sa_family) { case AF_INET: if ((ret = getsockopt(b->num, IPPROTO_IP, IP_MTU, (void *)&sockopt_val, &sockopt_len)) < 0 || sockopt_val < 0) { ret = 0; } else { /* we assume that the transport protocol is UDP and no * IP options are used. */ data->mtu = sockopt_val - 8 - 20; ret = data->mtu; } break; #if defined(IPV6_MTU) case AF_INET6: if ((ret = getsockopt(b->num, IPPROTO_IPV6, IPV6_MTU, (void *)&sockopt_val, &sockopt_len)) < 0 || sockopt_val < 0) { ret = 0; } else { /* we assume that the transport protocol is UDP and no * IPV6 options are used. */ data->mtu = sockopt_val - 8 - 40; ret = data->mtu; } break; #endif default: ret = 0; break; } #else ret = 0; #endif break; case BIO_CTRL_DGRAM_GET_FALLBACK_MTU: switch (data->peer.sa.sa_family) { case AF_INET: ret = 576 - 20 - 8; break; case AF_INET6: #ifdef IN6_IS_ADDR_V4MAPPED if (IN6_IS_ADDR_V4MAPPED(&data->peer.sa_in6.sin6_addr)) ret = 576 - 20 - 8; else #endif ret = 1280 - 40 - 8; break; default: ret = 576 - 20 - 8; break; } break; case BIO_CTRL_DGRAM_GET_MTU: return data->mtu; break; case BIO_CTRL_DGRAM_SET_MTU: data->mtu = num; ret = num; break; case BIO_CTRL_DGRAM_SET_CONNECTED: to = (struct sockaddr *)ptr; if (to != NULL) { data->connected = 1; switch (to->sa_family) { case AF_INET: memcpy(&data->peer, to, sizeof(data->peer.sa_in)); break; case AF_INET6: memcpy(&data->peer, to, sizeof(data->peer.sa_in6)); break; default: memcpy(&data->peer, to, sizeof(data->peer.sa)); break; } } else { data->connected = 0; memset(&(data->peer), 0x00, sizeof(data->peer)); } break; case BIO_CTRL_DGRAM_GET_PEER: switch (data->peer.sa.sa_family) { case AF_INET: ret = sizeof(data->peer.sa_in); break; case AF_INET6: ret = sizeof(data->peer.sa_in6); break; default: ret = sizeof(data->peer.sa); break; } if (num == 0 || num > ret) num = ret; memcpy(ptr, &data->peer, (ret = num)); break; case BIO_CTRL_DGRAM_SET_PEER: to = (struct sockaddr *) ptr; switch (to->sa_family) { case AF_INET: memcpy(&data->peer, to, sizeof(data->peer.sa_in)); break; case AF_INET6: memcpy(&data->peer, to, sizeof(data->peer.sa_in6)); break; default: memcpy(&data->peer, to, sizeof(data->peer.sa)); break; } break; case BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT: memcpy(&(data->next_timeout), ptr, sizeof(struct timeval)); break; #if defined(SO_RCVTIMEO) case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT: if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr, sizeof(struct timeval)) < 0) { perror("setsockopt"); ret = -1; } break; case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT: { union { size_t s; int i; } sz = {0}; sz.i = sizeof(struct timeval); if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr, (void *)&sz) < 0) { perror("getsockopt"); ret = -1; } else if (sizeof(sz.s)!=sizeof(sz.i) && sz.i==0) { OPENSSL_assert(sz.s <= sizeof(struct timeval)); ret = (int)sz.s; } else ret = sz.i; } break; #endif #if defined(SO_SNDTIMEO) case BIO_CTRL_DGRAM_SET_SEND_TIMEOUT: if (setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr, sizeof(struct timeval)) < 0) { perror("setsockopt"); ret = -1; } break; case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT: { union { size_t s; int i; } sz = {0}; sz.i = sizeof(struct timeval); if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr, (void *)&sz) < 0) { perror("getsockopt"); ret = -1; } else if (sizeof(sz.s) != sizeof(sz.i) && sz.i == 0) { OPENSSL_assert(sz.s <= sizeof(struct timeval)); ret = (int)sz.s; } else ret = sz.i; } break; #endif case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP: /* fall-through */ case BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP: if (data->_errno == EAGAIN) { ret = 1; data->_errno = 0; } else ret = 0; break; #ifdef EMSGSIZE case BIO_CTRL_DGRAM_MTU_EXCEEDED: if (data->_errno == EMSGSIZE) { ret = 1; data->_errno = 0; } else ret = 0; break; #endif default: ret = 0; break; } return (ret); } static int dgram_puts(BIO *bp, const char *str) { int n, ret; n = strlen(str); ret = dgram_write(bp, str, n); return (ret); } #ifndef OPENSSL_NO_SCTP BIO_METHOD * BIO_s_datagram_sctp(void) { return (&methods_dgramp_sctp); } BIO * BIO_new_dgram_sctp(int fd, int close_flag) { BIO *bio; int ret, optval = 20000; int auth_data = 0, auth_forward = 0; unsigned char *p; struct sctp_authchunk auth; struct sctp_authchunks *authchunks; socklen_t sockopt_len; #ifdef SCTP_AUTHENTICATION_EVENT #ifdef SCTP_EVENT struct sctp_event event; #else struct sctp_event_subscribe event; #endif #endif bio = BIO_new(BIO_s_datagram_sctp()); if (bio == NULL) return (NULL); BIO_set_fd(bio, fd, close_flag); /* Activate SCTP-AUTH for DATA and FORWARD-TSN chunks */ auth.sauth_chunk = OPENSSL_SCTP_DATA_CHUNK_TYPE; ret = setsockopt(fd, IPPROTO_SCTP, SCTP_AUTH_CHUNK, &auth, sizeof(struct sctp_authchunk)); OPENSSL_assert(ret >= 0); auth.sauth_chunk = OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE; ret = setsockopt(fd, IPPROTO_SCTP, SCTP_AUTH_CHUNK, &auth, sizeof(struct sctp_authchunk)); OPENSSL_assert(ret >= 0); /* Test if activation was successful. When using accept(), * SCTP-AUTH has to be activated for the listening socket * already, otherwise the connected socket won't use it. */ sockopt_len = (socklen_t)(sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t)); authchunks = calloc(1, sockopt_len); ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks, &sockopt_len); OPENSSL_assert(ret >= 0); for (p = (unsigned char*) authchunks->gauth_chunks; p < (unsigned char*) authchunks + sockopt_len; p += sizeof(uint8_t)) { if (*p == OPENSSL_SCTP_DATA_CHUNK_TYPE) auth_data = 1; if (*p == OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE) auth_forward = 1; } free(authchunks); OPENSSL_assert(auth_data); OPENSSL_assert(auth_forward); #ifdef SCTP_AUTHENTICATION_EVENT #ifdef SCTP_EVENT memset(&event, 0, sizeof(struct sctp_event)); event.se_assoc_id = 0; event.se_type = SCTP_AUTHENTICATION_EVENT; event.se_on = 1; ret = setsockopt(fd, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(struct sctp_event)); OPENSSL_assert(ret >= 0); #else sockopt_len = (socklen_t) sizeof(struct sctp_event_subscribe); ret = getsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event, &sockopt_len); OPENSSL_assert(ret >= 0); event.sctp_authentication_event = 1; ret = setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(struct sctp_event_subscribe)); OPENSSL_assert(ret >= 0); #endif #endif /* Disable partial delivery by setting the min size * larger than the max record size of 2^14 + 2048 + 13 */ ret = setsockopt(fd, IPPROTO_SCTP, SCTP_PARTIAL_DELIVERY_POINT, &optval, sizeof(optval)); OPENSSL_assert(ret >= 0); return (bio); } int BIO_dgram_is_sctp(BIO *bio) { return (BIO_method_type(bio) == BIO_TYPE_DGRAM_SCTP); } static int dgram_sctp_new(BIO *bi) { bio_dgram_sctp_data *data = NULL; bi->init = 0; bi->num = 0; data = calloc(1, sizeof(bio_dgram_sctp_data)); if (data == NULL) return 0; #ifdef SCTP_PR_SCTP_NONE data->prinfo.pr_policy = SCTP_PR_SCTP_NONE; #endif bi->ptr = data; bi->flags = 0; return (1); } static int dgram_sctp_free(BIO *a) { bio_dgram_sctp_data *data; if (a == NULL) return (0); if (! dgram_clear(a)) return 0; data = (bio_dgram_sctp_data *)a->ptr; free(data); return (1); } #ifdef SCTP_AUTHENTICATION_EVENT void dgram_sctp_handle_auth_free_key_event(BIO *b, union sctp_notification *snp) { int ret; struct sctp_authkey_event* authkeyevent = &snp->sn_auth_event; if (authkeyevent->auth_indication == SCTP_AUTH_FREE_KEY) { struct sctp_authkeyid authkeyid; /* delete key */ authkeyid.scact_keynumber = authkeyevent->auth_keynumber; ret = setsockopt(b->num, IPPROTO_SCTP, SCTP_AUTH_DELETE_KEY, &authkeyid, sizeof(struct sctp_authkeyid)); } } #endif static int dgram_sctp_read(BIO *b, char *out, int outl) { int ret = 0, n = 0, i, optval; socklen_t optlen; bio_dgram_sctp_data *data = (bio_dgram_sctp_data *)b->ptr; union sctp_notification *snp; struct msghdr msg; struct iovec iov; struct cmsghdr *cmsg; char cmsgbuf[512]; if (out != NULL) { errno = 0; do { memset(&data->rcvinfo, 0x00, sizeof(struct bio_dgram_sctp_rcvinfo)); iov.iov_base = out; iov.iov_len = outl; msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_control = cmsgbuf; msg.msg_controllen = 512; msg.msg_flags = 0; n = recvmsg(b->num, &msg, 0); if (msg.msg_controllen > 0) { for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) { if (cmsg->cmsg_level != IPPROTO_SCTP) continue; #ifdef SCTP_RCVINFO if (cmsg->cmsg_type == SCTP_RCVINFO) { struct sctp_rcvinfo *rcvinfo; rcvinfo = (struct sctp_rcvinfo *)CMSG_DATA(cmsg); data->rcvinfo.rcv_sid = rcvinfo->rcv_sid; data->rcvinfo.rcv_ssn = rcvinfo->rcv_ssn; data->rcvinfo.rcv_flags = rcvinfo->rcv_flags; data->rcvinfo.rcv_ppid = rcvinfo->rcv_ppid; data->rcvinfo.rcv_tsn = rcvinfo->rcv_tsn; data->rcvinfo.rcv_cumtsn = rcvinfo->rcv_cumtsn; data->rcvinfo.rcv_context = rcvinfo->rcv_context; } #endif #ifdef SCTP_SNDRCV if (cmsg->cmsg_type == SCTP_SNDRCV) { struct sctp_sndrcvinfo *sndrcvinfo; sndrcvinfo = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg); data->rcvinfo.rcv_sid = sndrcvinfo->sinfo_stream; data->rcvinfo.rcv_ssn = sndrcvinfo->sinfo_ssn; data->rcvinfo.rcv_flags = sndrcvinfo->sinfo_flags; data->rcvinfo.rcv_ppid = sndrcvinfo->sinfo_ppid; data->rcvinfo.rcv_tsn = sndrcvinfo->sinfo_tsn; data->rcvinfo.rcv_cumtsn = sndrcvinfo->sinfo_cumtsn; data->rcvinfo.rcv_context = sndrcvinfo->sinfo_context; } #endif } } if (n <= 0) { if (n < 0) ret = n; break; } if (msg.msg_flags & MSG_NOTIFICATION) { snp = (union sctp_notification*) out; if (snp->sn_header.sn_type == SCTP_SENDER_DRY_EVENT) { #ifdef SCTP_EVENT struct sctp_event event; #else struct sctp_event_subscribe event; socklen_t eventsize; #endif /* If a message has been delayed until the socket * is dry, it can be sent now. */ if (data->saved_message.length > 0) { dgram_sctp_write(data->saved_message.bio, data->saved_message.data, data->saved_message.length); free(data->saved_message.data); data->saved_message.length = 0; } /* disable sender dry event */ #ifdef SCTP_EVENT memset(&event, 0, sizeof(struct sctp_event)); event.se_assoc_id = 0; event.se_type = SCTP_SENDER_DRY_EVENT; event.se_on = 0; i = setsockopt(b->num, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(struct sctp_event)); OPENSSL_assert(i >= 0); #else eventsize = sizeof(struct sctp_event_subscribe); i = getsockopt(b->num, IPPROTO_SCTP, SCTP_EVENTS, &event, &eventsize); OPENSSL_assert(i >= 0); event.sctp_sender_dry_event = 0; i = setsockopt(b->num, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(struct sctp_event_subscribe)); OPENSSL_assert(i >= 0); #endif } #ifdef SCTP_AUTHENTICATION_EVENT if (snp->sn_header.sn_type == SCTP_AUTHENTICATION_EVENT) dgram_sctp_handle_auth_free_key_event(b, snp); #endif if (data->handle_notifications != NULL) data->handle_notifications(b, data->notification_context, (void*) out); memset(out, 0, outl); } else ret += n; } while ((msg.msg_flags & MSG_NOTIFICATION) && (msg.msg_flags & MSG_EOR) && (ret < outl)); if (ret > 0 && !(msg.msg_flags & MSG_EOR)) { /* Partial message read, this should never happen! */ /* The buffer was too small, this means the peer sent * a message that was larger than allowed. */ if (ret == outl) return -1; /* Test if socket buffer can handle max record * size (2^14 + 2048 + 13) */ optlen = (socklen_t) sizeof(int); ret = getsockopt(b->num, SOL_SOCKET, SO_RCVBUF, &optval, &optlen); OPENSSL_assert(ret >= 0); OPENSSL_assert(optval >= 18445); /* Test if SCTP doesn't partially deliver below * max record size (2^14 + 2048 + 13) */ optlen = (socklen_t) sizeof(int); ret = getsockopt(b->num, IPPROTO_SCTP, SCTP_PARTIAL_DELIVERY_POINT, &optval, &optlen); OPENSSL_assert(ret >= 0); OPENSSL_assert(optval >= 18445); /* Partially delivered notification??? Probably a bug.... */ OPENSSL_assert(!(msg.msg_flags & MSG_NOTIFICATION)); /* Everything seems ok till now, so it's most likely * a message dropped by PR-SCTP. */ memset(out, 0, outl); BIO_set_retry_read(b); return -1; } BIO_clear_retry_flags(b); if (ret < 0) { if (BIO_dgram_should_retry(ret)) { BIO_set_retry_read(b); data->_errno = errno; } } /* Test if peer uses SCTP-AUTH before continuing */ if (!data->peer_auth_tested) { int ii, auth_data = 0, auth_forward = 0; unsigned char *p; struct sctp_authchunks *authchunks; optlen = (socklen_t)(sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t)); authchunks = calloc(1, optlen); ii = getsockopt(b->num, IPPROTO_SCTP, SCTP_PEER_AUTH_CHUNKS, authchunks, &optlen); OPENSSL_assert(ii >= 0); for (p = (unsigned char*) authchunks->gauth_chunks; p < (unsigned char*) authchunks + optlen; p += sizeof(uint8_t)) { if (*p == OPENSSL_SCTP_DATA_CHUNK_TYPE) auth_data = 1; if (*p == OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE) auth_forward = 1; } free(authchunks); if (!auth_data || !auth_forward) { BIOerr(BIO_F_DGRAM_SCTP_READ, BIO_R_CONNECT_ERROR); return -1; } data->peer_auth_tested = 1; } } return (ret); } static int dgram_sctp_write(BIO *b, const char *in, int inl) { int ret; bio_dgram_sctp_data *data = (bio_dgram_sctp_data *)b->ptr; struct bio_dgram_sctp_sndinfo *sinfo = &(data->sndinfo); struct bio_dgram_sctp_prinfo *pinfo = &(data->prinfo); struct bio_dgram_sctp_sndinfo handshake_sinfo; struct iovec iov[1]; struct msghdr msg; struct cmsghdr *cmsg; #if defined(SCTP_SNDINFO) && defined(SCTP_PRINFO) char cmsgbuf[CMSG_SPACE(sizeof(struct sctp_sndinfo)) + CMSG_SPACE(sizeof(struct sctp_prinfo))]; struct sctp_sndinfo *sndinfo; struct sctp_prinfo *prinfo; #else char cmsgbuf[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))]; struct sctp_sndrcvinfo *sndrcvinfo; #endif errno = 0; /* If we're send anything else than application data, * disable all user parameters and flags. */ if (in[0] != 23) { memset(&handshake_sinfo, 0x00, sizeof(struct bio_dgram_sctp_sndinfo)); #ifdef SCTP_SACK_IMMEDIATELY handshake_sinfo.snd_flags = SCTP_SACK_IMMEDIATELY; #endif sinfo = &handshake_sinfo; } /* If we have to send a shutdown alert message and the * socket is not dry yet, we have to save it and send it * as soon as the socket gets dry. */ if (data->save_shutdown && !BIO_dgram_sctp_wait_for_dry(b)) { data->saved_message.bio = b; data->saved_message.length = inl; data->saved_message.data = malloc(inl); memcpy(data->saved_message.data, in, inl); return inl; } iov[0].iov_base = (char *)in; iov[0].iov_len = inl; msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_iov = iov; msg.msg_iovlen = 1; msg.msg_control = (caddr_t)cmsgbuf; msg.msg_controllen = 0; msg.msg_flags = 0; #if defined(SCTP_SNDINFO) && defined(SCTP_PRINFO) cmsg = (struct cmsghdr *)cmsgbuf; cmsg->cmsg_level = IPPROTO_SCTP; cmsg->cmsg_type = SCTP_SNDINFO; cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndinfo)); sndinfo = (struct sctp_sndinfo *)CMSG_DATA(cmsg); memset(sndinfo, 0, sizeof(struct sctp_sndinfo)); sndinfo->snd_sid = sinfo->snd_sid; sndinfo->snd_flags = sinfo->snd_flags; sndinfo->snd_ppid = sinfo->snd_ppid; sndinfo->snd_context = sinfo->snd_context; msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_sndinfo)); cmsg = (struct cmsghdr *)&cmsgbuf[CMSG_SPACE(sizeof(struct sctp_sndinfo))]; cmsg->cmsg_level = IPPROTO_SCTP; cmsg->cmsg_type = SCTP_PRINFO; cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_prinfo)); prinfo = (struct sctp_prinfo *)CMSG_DATA(cmsg); memset(prinfo, 0, sizeof(struct sctp_prinfo)); prinfo->pr_policy = pinfo->pr_policy; prinfo->pr_value = pinfo->pr_value; msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_prinfo)); #else cmsg = (struct cmsghdr *)cmsgbuf; cmsg->cmsg_level = IPPROTO_SCTP; cmsg->cmsg_type = SCTP_SNDRCV; cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo)); sndrcvinfo = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg); memset(sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo)); sndrcvinfo->sinfo_stream = sinfo->snd_sid; sndrcvinfo->sinfo_flags = sinfo->snd_flags; sndrcvinfo->sinfo_ppid = sinfo->snd_ppid; sndrcvinfo->sinfo_context = sinfo->snd_context; sndrcvinfo->sinfo_timetolive = pinfo->pr_value; msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_sndrcvinfo)); #endif ret = sendmsg(b->num, &msg, 0); BIO_clear_retry_flags(b); if (ret <= 0) { if (BIO_dgram_should_retry(ret)) { BIO_set_retry_write(b); data->_errno = errno; } } return (ret); } static long dgram_sctp_ctrl(BIO *b, int cmd, long num, void *ptr) { long ret = 1; bio_dgram_sctp_data *data = NULL; socklen_t sockopt_len = 0; struct sctp_authkeyid authkeyid; data = (bio_dgram_sctp_data *)b->ptr; switch (cmd) { case BIO_CTRL_DGRAM_QUERY_MTU: /* Set to maximum (2^14) * and ignore user input to enable transport * protocol fragmentation. * Returns always 2^14. */ data->mtu = 16384; ret = data->mtu; break; case BIO_CTRL_DGRAM_SET_MTU: /* Set to maximum (2^14) * and ignore input to enable transport * protocol fragmentation. * Returns always 2^14. */ data->mtu = 16384; ret = data->mtu; break; case BIO_CTRL_DGRAM_SET_CONNECTED: case BIO_CTRL_DGRAM_CONNECT: /* Returns always -1. */ ret = -1; break; case BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT: /* SCTP doesn't need the DTLS timer * Returns always 1. */ break; case BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE: if (num > 0) data->in_handshake = 1; else data->in_handshake = 0; ret = setsockopt(b->num, IPPROTO_SCTP, SCTP_NODELAY, &data->in_handshake, sizeof(int)); break; case BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY: { struct sctp_authkey *authkey; /* New shared key for SCTP AUTH. * Returns 0 on success, -1 otherwise. */ /* Get active key */ sockopt_len = sizeof(struct sctp_authkeyid); ret = getsockopt(b->num, IPPROTO_SCTP, SCTP_AUTH_ACTIVE_KEY, &authkeyid, &sockopt_len); if (ret < 0) break; /* Add new key */ sockopt_len = sizeof(struct sctp_authkey) + 64 * sizeof(uint8_t); authkey = calloc(1, sockopt_len); if (authkey == NULL) { ret = -1; break; } authkey->sca_keynumber = authkeyid.scact_keynumber + 1; authkey->sca_keylength = 64; memcpy(&authkey->sca_key[0], ptr, 64 * sizeof(uint8_t)); ret = setsockopt(b->num, IPPROTO_SCTP, SCTP_AUTH_KEY, authkey, sockopt_len); free(authkey); if (ret < 0) break; /* Reset active key */ ret = setsockopt(b->num, IPPROTO_SCTP, SCTP_AUTH_ACTIVE_KEY, &authkeyid, sizeof(struct sctp_authkeyid)); if (ret < 0) break; } break; case BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY: /* Returns 0 on success, -1 otherwise. */ /* Get active key */ sockopt_len = sizeof(struct sctp_authkeyid); ret = getsockopt(b->num, IPPROTO_SCTP, SCTP_AUTH_ACTIVE_KEY, &authkeyid, &sockopt_len); if (ret < 0) break; /* Set active key */ authkeyid.scact_keynumber = authkeyid.scact_keynumber + 1; ret = setsockopt(b->num, IPPROTO_SCTP, SCTP_AUTH_ACTIVE_KEY, &authkeyid, sizeof(struct sctp_authkeyid)); if (ret < 0) break; /* CCS has been sent, so remember that and fall through * to check if we need to deactivate an old key */ data->ccs_sent = 1; case BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD: /* Returns 0 on success, -1 otherwise. */ /* Has this command really been called or is this just a fall-through? */ if (cmd == BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD) data->ccs_rcvd = 1; /* CSS has been both, received and sent, so deactivate an old key */ if (data->ccs_rcvd == 1 && data->ccs_sent == 1) { /* Get active key */ sockopt_len = sizeof(struct sctp_authkeyid); ret = getsockopt(b->num, IPPROTO_SCTP, SCTP_AUTH_ACTIVE_KEY, &authkeyid, &sockopt_len); if (ret < 0) break; /* Deactivate key or delete second last key if * SCTP_AUTHENTICATION_EVENT is not available. */ authkeyid.scact_keynumber = authkeyid.scact_keynumber - 1; #ifdef SCTP_AUTH_DEACTIVATE_KEY sockopt_len = sizeof(struct sctp_authkeyid); ret = setsockopt(b->num, IPPROTO_SCTP, SCTP_AUTH_DEACTIVATE_KEY, &authkeyid, sockopt_len); if (ret < 0) break; #endif #ifndef SCTP_AUTHENTICATION_EVENT if (authkeyid.scact_keynumber > 0) { authkeyid.scact_keynumber = authkeyid.scact_keynumber - 1; ret = setsockopt(b->num, IPPROTO_SCTP, SCTP_AUTH_DELETE_KEY, &authkeyid, sizeof(struct sctp_authkeyid)); if (ret < 0) break; } #endif data->ccs_rcvd = 0; data->ccs_sent = 0; } break; case BIO_CTRL_DGRAM_SCTP_GET_SNDINFO: /* Returns the size of the copied struct. */ if (num > (long) sizeof(struct bio_dgram_sctp_sndinfo)) num = sizeof(struct bio_dgram_sctp_sndinfo); memcpy(ptr, &(data->sndinfo), num); ret = num; break; case BIO_CTRL_DGRAM_SCTP_SET_SNDINFO: /* Returns the size of the copied struct. */ if (num > (long) sizeof(struct bio_dgram_sctp_sndinfo)) num = sizeof(struct bio_dgram_sctp_sndinfo); memcpy(&(data->sndinfo), ptr, num); break; case BIO_CTRL_DGRAM_SCTP_GET_RCVINFO: /* Returns the size of the copied struct. */ if (num > (long) sizeof(struct bio_dgram_sctp_rcvinfo)) num = sizeof(struct bio_dgram_sctp_rcvinfo); memcpy(ptr, &data->rcvinfo, num); ret = num; break; case BIO_CTRL_DGRAM_SCTP_SET_RCVINFO: /* Returns the size of the copied struct. */ if (num > (long) sizeof(struct bio_dgram_sctp_rcvinfo)) num = sizeof(struct bio_dgram_sctp_rcvinfo); memcpy(&(data->rcvinfo), ptr, num); break; case BIO_CTRL_DGRAM_SCTP_GET_PRINFO: /* Returns the size of the copied struct. */ if (num > (long) sizeof(struct bio_dgram_sctp_prinfo)) num = sizeof(struct bio_dgram_sctp_prinfo); memcpy(ptr, &(data->prinfo), num); ret = num; break; case BIO_CTRL_DGRAM_SCTP_SET_PRINFO: /* Returns the size of the copied struct. */ if (num > (long) sizeof(struct bio_dgram_sctp_prinfo)) num = sizeof(struct bio_dgram_sctp_prinfo); memcpy(&(data->prinfo), ptr, num); break; case BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN: /* Returns always 1. */ if (num > 0) data->save_shutdown = 1; else data->save_shutdown = 0; break; default: /* Pass to default ctrl function to * process SCTP unspecific commands */ ret = dgram_ctrl(b, cmd, num, ptr); break; } return (ret); } int BIO_dgram_sctp_notification_cb(BIO *b, void (*handle_notifications)(BIO *bio, void *context, void *buf), void *context) { bio_dgram_sctp_data *data = (bio_dgram_sctp_data *) b->ptr; if (handle_notifications != NULL) { data->handle_notifications = handle_notifications; data->notification_context = context; } else return -1; return 0; } int BIO_dgram_sctp_wait_for_dry(BIO *b) { int is_dry = 0; int n, sockflags, ret; union sctp_notification snp; struct msghdr msg; struct iovec iov; #ifdef SCTP_EVENT struct sctp_event event; #else struct sctp_event_subscribe event; socklen_t eventsize; #endif bio_dgram_sctp_data *data = (bio_dgram_sctp_data *)b->ptr; /* set sender dry event */ #ifdef SCTP_EVENT memset(&event, 0, sizeof(struct sctp_event)); event.se_assoc_id = 0; event.se_type = SCTP_SENDER_DRY_EVENT; event.se_on = 1; ret = setsockopt(b->num, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(struct sctp_event)); #else eventsize = sizeof(struct sctp_event_subscribe); ret = getsockopt(b->num, IPPROTO_SCTP, SCTP_EVENTS, &event, &eventsize); if (ret < 0) return -1; event.sctp_sender_dry_event = 1; ret = setsockopt(b->num, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(struct sctp_event_subscribe)); #endif if (ret < 0) return -1; /* peek for notification */ memset(&snp, 0x00, sizeof(union sctp_notification)); iov.iov_base = (char *)&snp; iov.iov_len = sizeof(union sctp_notification); msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_control = NULL; msg.msg_controllen = 0; msg.msg_flags = 0; n = recvmsg(b->num, &msg, MSG_PEEK); if (n <= 0) { if ((n < 0) && (errno != EAGAIN) && (errno != EWOULDBLOCK)) return -1; else return 0; } /* if we find a notification, process it and try again if necessary */ while (msg.msg_flags & MSG_NOTIFICATION) { memset(&snp, 0x00, sizeof(union sctp_notification)); iov.iov_base = (char *)&snp; iov.iov_len = sizeof(union sctp_notification); msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_control = NULL; msg.msg_controllen = 0; msg.msg_flags = 0; n = recvmsg(b->num, &msg, 0); if (n <= 0) { if ((n < 0) && (errno != EAGAIN) && (errno != EWOULDBLOCK)) return -1; else return is_dry; } if (snp.sn_header.sn_type == SCTP_SENDER_DRY_EVENT) { is_dry = 1; /* disable sender dry event */ #ifdef SCTP_EVENT memset(&event, 0, sizeof(struct sctp_event)); event.se_assoc_id = 0; event.se_type = SCTP_SENDER_DRY_EVENT; event.se_on = 0; ret = setsockopt(b->num, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(struct sctp_event)); #else eventsize = (socklen_t) sizeof(struct sctp_event_subscribe); ret = getsockopt(b->num, IPPROTO_SCTP, SCTP_EVENTS, &event, &eventsize); if (ret < 0) return -1; event.sctp_sender_dry_event = 0; ret = setsockopt(b->num, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(struct sctp_event_subscribe)); #endif if (ret < 0) return -1; } #ifdef SCTP_AUTHENTICATION_EVENT if (snp.sn_header.sn_type == SCTP_AUTHENTICATION_EVENT) dgram_sctp_handle_auth_free_key_event(b, &snp); #endif if (data->handle_notifications != NULL) data->handle_notifications(b, data->notification_context, (void*) &snp); /* found notification, peek again */ memset(&snp, 0x00, sizeof(union sctp_notification)); iov.iov_base = (char *)&snp; iov.iov_len = sizeof(union sctp_notification); msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_control = NULL; msg.msg_controllen = 0; msg.msg_flags = 0; /* if we have seen the dry already, don't wait */ if (is_dry) { sockflags = fcntl(b->num, F_GETFL, 0); fcntl(b->num, F_SETFL, O_NONBLOCK); } n = recvmsg(b->num, &msg, MSG_PEEK); if (is_dry) { fcntl(b->num, F_SETFL, sockflags); } if (n <= 0) { if ((n < 0) && (errno != EAGAIN) && (errno != EWOULDBLOCK)) return -1; else return is_dry; } } /* read anything else */ return is_dry; } int BIO_dgram_sctp_msg_waiting(BIO *b) { int n, sockflags; union sctp_notification snp; struct msghdr msg; struct iovec iov; bio_dgram_sctp_data *data = (bio_dgram_sctp_data *)b->ptr; /* Check if there are any messages waiting to be read */ do { memset(&snp, 0x00, sizeof(union sctp_notification)); iov.iov_base = (char *)&snp; iov.iov_len = sizeof(union sctp_notification); msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_control = NULL; msg.msg_controllen = 0; msg.msg_flags = 0; sockflags = fcntl(b->num, F_GETFL, 0); fcntl(b->num, F_SETFL, O_NONBLOCK); n = recvmsg(b->num, &msg, MSG_PEEK); fcntl(b->num, F_SETFL, sockflags); /* if notification, process and try again */ if (n > 0 && (msg.msg_flags & MSG_NOTIFICATION)) { #ifdef SCTP_AUTHENTICATION_EVENT if (snp.sn_header.sn_type == SCTP_AUTHENTICATION_EVENT) dgram_sctp_handle_auth_free_key_event(b, &snp); #endif memset(&snp, 0x00, sizeof(union sctp_notification)); iov.iov_base = (char *)&snp; iov.iov_len = sizeof(union sctp_notification); msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_control = NULL; msg.msg_controllen = 0; msg.msg_flags = 0; n = recvmsg(b->num, &msg, 0); if (data->handle_notifications != NULL) data->handle_notifications(b, data->notification_context, (void*) &snp); } } while (n > 0 && (msg.msg_flags & MSG_NOTIFICATION)); /* Return 1 if there is a message to be read, return 0 otherwise. */ if (n > 0) return 1; else return 0; } static int dgram_sctp_puts(BIO *bp, const char *str) { int n, ret; n = strlen(str); ret = dgram_sctp_write(bp, str, n); return (ret); } #endif static int BIO_dgram_should_retry(int i) { int err; if ((i == 0) || (i == -1)) { err = errno; return (BIO_dgram_non_fatal_error(err)); } return (0); } int BIO_dgram_non_fatal_error(int err) { switch (err) { case EINTR: case EAGAIN: case EINPROGRESS: case EALREADY: return (1); default: break; } return (0); } static void get_current_time(struct timeval *t) { gettimeofday(t, NULL); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/bss_conn.c0000644000175000017500000003424612360020705021005 0ustar /* $OpenBSD: bss_conn.c,v 1.28 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #include #include #define SOCKET_PROTOCOL IPPROTO_TCP typedef struct bio_connect_st { int state; char *param_hostname; char *param_port; int nbio; unsigned char ip[4]; unsigned short port; struct sockaddr_in them; /* int socket; this will be kept in bio->num so that it is * compatible with the bss_sock bio */ /* called when the connection is initially made * callback(BIO,state,ret); The callback should return * 'ret'. state is for compatibility with the ssl info_callback */ int (*info_callback)(const BIO *bio, int state, int ret); } BIO_CONNECT; static int conn_write(BIO *h, const char *buf, int num); static int conn_read(BIO *h, char *buf, int size); static int conn_puts(BIO *h, const char *str); static long conn_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int conn_new(BIO *h); static int conn_free(BIO *data); static long conn_callback_ctrl(BIO *h, int cmd, bio_info_cb *); static int conn_state(BIO *b, BIO_CONNECT *c); static void conn_close_socket(BIO *data); BIO_CONNECT *BIO_CONNECT_new(void); void BIO_CONNECT_free(BIO_CONNECT *a); static BIO_METHOD methods_connectp = { .type = BIO_TYPE_CONNECT, .name = "socket connect", .bwrite = conn_write, .bread = conn_read, .bputs = conn_puts, .ctrl = conn_ctrl, .create = conn_new, .destroy = conn_free, .callback_ctrl = conn_callback_ctrl }; static int conn_state(BIO *b, BIO_CONNECT *c) { int ret = -1, i; unsigned long l; char *p, *q; int (*cb)(const BIO *, int, int) = NULL; if (c->info_callback != NULL) cb = c->info_callback; for (;;) { switch (c->state) { case BIO_CONN_S_BEFORE: p = c->param_hostname; if (p == NULL) { BIOerr(BIO_F_CONN_STATE, BIO_R_NO_HOSTNAME_SPECIFIED); goto exit_loop; } for (; *p != '\0'; p++) { if ((*p == ':') || (*p == '/')) break; } i= *p; if ((i == ':') || (i == '/')) { *(p++) = '\0'; if (i == ':') { for (q = p; *q; q++) if (*q == '/') { *q = '\0'; break; } free(c->param_port); c->param_port = BUF_strdup(p); } } if (c->param_port == NULL) { BIOerr(BIO_F_CONN_STATE, BIO_R_NO_PORT_SPECIFIED); ERR_asprintf_error_data("host=%s", c->param_hostname); goto exit_loop; } c->state = BIO_CONN_S_GET_IP; break; case BIO_CONN_S_GET_IP: if (BIO_get_host_ip(c->param_hostname, &(c->ip[0])) <= 0) goto exit_loop; c->state = BIO_CONN_S_GET_PORT; break; case BIO_CONN_S_GET_PORT: if (c->param_port == NULL) { /* abort(); */ goto exit_loop; } else if (BIO_get_port(c->param_port, &c->port) <= 0) goto exit_loop; c->state = BIO_CONN_S_CREATE_SOCKET; break; case BIO_CONN_S_CREATE_SOCKET: /* now setup address */ memset((char *)&c->them, 0, sizeof(c->them)); c->them.sin_family = AF_INET; c->them.sin_port = htons((unsigned short)c->port); l = (unsigned long) ((unsigned long)c->ip[0] << 24L)| ((unsigned long)c->ip[1] << 16L)| ((unsigned long)c->ip[2] << 8L)| ((unsigned long)c->ip[3]); c->them.sin_addr.s_addr = htonl(l); c->state = BIO_CONN_S_CREATE_SOCKET; ret = socket(AF_INET, SOCK_STREAM, SOCKET_PROTOCOL); if (ret == -1) { SYSerr(SYS_F_SOCKET, errno); ERR_asprintf_error_data("host=%s:%s", c->param_hostname, c->param_port); BIOerr(BIO_F_CONN_STATE, BIO_R_UNABLE_TO_CREATE_SOCKET); goto exit_loop; } b->num = ret; c->state = BIO_CONN_S_NBIO; break; case BIO_CONN_S_NBIO: if (c->nbio) { if (!BIO_socket_nbio(b->num, 1)) { BIOerr(BIO_F_CONN_STATE, BIO_R_ERROR_SETTING_NBIO); ERR_asprintf_error_data("host=%s:%s", c->param_hostname, c->param_port); goto exit_loop; } } c->state = BIO_CONN_S_CONNECT; #if defined(SO_KEEPALIVE) && !defined(OPENSSL_SYS_MPE) i = 1; i = setsockopt(b->num, SOL_SOCKET, SO_KEEPALIVE,(char *)&i, sizeof(i)); if (i < 0) { SYSerr(SYS_F_SOCKET, errno); ERR_asprintf_error_data("host=%s:%s", c->param_hostname, c->param_port); BIOerr(BIO_F_CONN_STATE, BIO_R_KEEPALIVE); goto exit_loop; } #endif break; case BIO_CONN_S_CONNECT: BIO_clear_retry_flags(b); ret = connect(b->num, (struct sockaddr *)&c->them, sizeof(c->them)); b->retry_reason = 0; if (ret < 0) { if (BIO_sock_should_retry(ret)) { BIO_set_retry_special(b); c->state = BIO_CONN_S_BLOCKED_CONNECT; b->retry_reason = BIO_RR_CONNECT; } else { SYSerr(SYS_F_CONNECT, errno); ERR_asprintf_error_data("host=%s:%s", c->param_hostname, c->param_port); BIOerr(BIO_F_CONN_STATE, BIO_R_CONNECT_ERROR); } goto exit_loop; } else c->state = BIO_CONN_S_OK; break; case BIO_CONN_S_BLOCKED_CONNECT: i = BIO_sock_error(b->num); if (i) { BIO_clear_retry_flags(b); SYSerr(SYS_F_CONNECT, i); ERR_asprintf_error_data("host=%s:%s", c->param_hostname, c->param_port); BIOerr(BIO_F_CONN_STATE, BIO_R_NBIO_CONNECT_ERROR); ret = 0; goto exit_loop; } else c->state = BIO_CONN_S_OK; break; case BIO_CONN_S_OK: ret = 1; goto exit_loop; default: /* abort(); */ goto exit_loop; } if (cb != NULL) { if (!(ret = cb((BIO *)b, c->state, ret))) goto end; } } /* Loop does not exit */ exit_loop: if (cb != NULL) ret = cb((BIO *)b, c->state, ret); end: return (ret); } BIO_CONNECT * BIO_CONNECT_new(void) { BIO_CONNECT *ret; if ((ret = malloc(sizeof(BIO_CONNECT))) == NULL) return (NULL); ret->state = BIO_CONN_S_BEFORE; ret->param_hostname = NULL; ret->param_port = NULL; ret->info_callback = NULL; ret->nbio = 0; ret->ip[0] = 0; ret->ip[1] = 0; ret->ip[2] = 0; ret->ip[3] = 0; ret->port = 0; memset((char *)&ret->them, 0, sizeof(ret->them)); return (ret); } void BIO_CONNECT_free(BIO_CONNECT *a) { if (a == NULL) return; free(a->param_hostname); free(a->param_port); free(a); } BIO_METHOD * BIO_s_connect(void) { return (&methods_connectp); } static int conn_new(BIO *bi) { bi->init = 0; bi->num = -1; bi->flags = 0; if ((bi->ptr = (char *)BIO_CONNECT_new()) == NULL) return (0); else return (1); } static void conn_close_socket(BIO *bio) { BIO_CONNECT *c; c = (BIO_CONNECT *)bio->ptr; if (bio->num != -1) { /* Only do a shutdown if things were established */ if (c->state == BIO_CONN_S_OK) shutdown(bio->num, SHUT_RDWR); close(bio->num); bio->num = -1; } } static int conn_free(BIO *a) { BIO_CONNECT *data; if (a == NULL) return (0); data = (BIO_CONNECT *)a->ptr; if (a->shutdown) { conn_close_socket(a); BIO_CONNECT_free(data); a->ptr = NULL; a->flags = 0; a->init = 0; } return (1); } static int conn_read(BIO *b, char *out, int outl) { int ret = 0; BIO_CONNECT *data; data = (BIO_CONNECT *)b->ptr; if (data->state != BIO_CONN_S_OK) { ret = conn_state(b, data); if (ret <= 0) return (ret); } if (out != NULL) { errno = 0; ret = read(b->num, out, outl); BIO_clear_retry_flags(b); if (ret <= 0) { if (BIO_sock_should_retry(ret)) BIO_set_retry_read(b); } } return (ret); } static int conn_write(BIO *b, const char *in, int inl) { int ret; BIO_CONNECT *data; data = (BIO_CONNECT *)b->ptr; if (data->state != BIO_CONN_S_OK) { ret = conn_state(b, data); if (ret <= 0) return (ret); } errno = 0; ret = write(b->num, in, inl); BIO_clear_retry_flags(b); if (ret <= 0) { if (BIO_sock_should_retry(ret)) BIO_set_retry_write(b); } return (ret); } static long conn_ctrl(BIO *b, int cmd, long num, void *ptr) { BIO *dbio; int *ip; const char **pptr; long ret = 1; BIO_CONNECT *data; data = (BIO_CONNECT *)b->ptr; switch (cmd) { case BIO_CTRL_RESET: ret = 0; data->state = BIO_CONN_S_BEFORE; conn_close_socket(b); b->flags = 0; break; case BIO_C_DO_STATE_MACHINE: /* use this one to start the connection */ if (data->state != BIO_CONN_S_OK) ret = (long)conn_state(b, data); else ret = 1; break; case BIO_C_GET_CONNECT: if (ptr != NULL) { pptr = (const char **)ptr; if (num == 0) { *pptr = data->param_hostname; } else if (num == 1) { *pptr = data->param_port; } else if (num == 2) { *pptr = (char *)&(data->ip[0]); } else if (num == 3) { *((int *)ptr) = data->port; } if ((!b->init) || (ptr == NULL)) *pptr = "not initialized"; ret = 1; } break; case BIO_C_SET_CONNECT: if (ptr != NULL) { b->init = 1; if (num == 0) { free(data->param_hostname); data->param_hostname = BUF_strdup(ptr); } else if (num == 1) { free(data->param_port); data->param_port = BUF_strdup(ptr); } else if (num == 2) { unsigned char *p = ptr; free(data->param_hostname); if (asprintf(&data->param_hostname, "%u.%u.%u.%u", p[0], p[1], p[2], p[3]) == -1) data->param_hostname = NULL; memcpy(&(data->ip[0]), ptr, 4); } else if (num == 3) { free(data->param_port); data->port= *(int *)ptr; if (asprintf(&data->param_port, "%d", data->port) == -1) data->param_port = NULL; } } break; case BIO_C_SET_NBIO: data->nbio = (int)num; break; case BIO_C_GET_FD: if (b->init) { ip = (int *)ptr; if (ip != NULL) *ip = b->num; ret = b->num; } else ret = -1; break; case BIO_CTRL_GET_CLOSE: ret = b->shutdown; break; case BIO_CTRL_SET_CLOSE: b->shutdown = (int)num; break; case BIO_CTRL_PENDING: case BIO_CTRL_WPENDING: ret = 0; break; case BIO_CTRL_FLUSH: break; case BIO_CTRL_DUP: { dbio = (BIO *)ptr; if (data->param_port) BIO_set_conn_port(dbio, data->param_port); if (data->param_hostname) BIO_set_conn_hostname(dbio, data->param_hostname); BIO_set_nbio(dbio, data->nbio); /* FIXME: the cast of the function seems unlikely to be a good idea */ (void)BIO_set_info_callback(dbio, (bio_info_cb *)data->info_callback); } break; case BIO_CTRL_SET_CALLBACK: { #if 0 /* FIXME: Should this be used? -- Richard Levitte */ BIOerr(BIO_F_CONN_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); ret = -1; #else ret = 0; #endif } break; case BIO_CTRL_GET_CALLBACK: { int (**fptr)(const BIO *bio, int state, int xret); fptr = (int (**)(const BIO *bio, int state, int xret))ptr; *fptr = data->info_callback; } break; default: ret = 0; break; } return (ret); } static long conn_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) { long ret = 1; BIO_CONNECT *data; data = (BIO_CONNECT *)b->ptr; switch (cmd) { case BIO_CTRL_SET_CALLBACK: { data->info_callback = (int (*)(const struct bio_st *, int, int))fp; } break; default: ret = 0; break; } return (ret); } static int conn_puts(BIO *bp, const char *str) { int n, ret; n = strlen(str); ret = conn_write(bp, str, n); return (ret); } BIO * BIO_new_connect(char *str) { BIO *ret; ret = BIO_new(BIO_s_connect()); if (ret == NULL) return (NULL); if (BIO_set_conn_hostname(ret, str)) return (ret); else { BIO_free(ret); return (NULL); } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/b_print.c0000644000175000017500000000434312360020705020631 0ustar /* $OpenBSD: b_print.c,v 1.24 2014/06/11 15:40:52 jsing Exp $ */ /* Theo de Raadt places this file in the public domain. */ #include int BIO_printf(BIO *bio, const char *format, ...) { va_list args; int ret; va_start(args, format); ret = BIO_vprintf(bio, format, args); va_end(args); return (ret); } #ifdef HAVE_FUNOPEN static int _BIO_write(void *cookie, const char *buf, int nbytes) { return BIO_write(cookie, buf, nbytes); } int BIO_vprintf(BIO *bio, const char *format, va_list args) { int ret; FILE *fp; fp = funopen(bio, NULL, &_BIO_write, NULL, NULL); if (fp == NULL) { ret = -1; goto fail; } ret = vfprintf(fp, format, args); fclose(fp); fail: return (ret); } #else /* !HAVE_FUNOPEN */ int BIO_vprintf(BIO *bio, const char *format, va_list args) { int ret; char *buf = NULL; ret = vasprintf(&buf, format, args); if (buf == NULL) { ret = -1; goto fail; } BIO_write(bio, buf, ret); free(buf); fail: return (ret); } #endif /* HAVE_FUNOPEN */ /* * BIO_snprintf and BIO_vsnprintf return -1 for overflow, * due to the history of this API. Justification: * * Traditional snprintf surfaced in 4.4BSD, and returned * "number of bytes wanted". Solaris and Windows opted to * return -1. A draft standard was written which returned -1. * Due to the large volume of code already using the first * semantics, the draft was repaired before standardization to * specify "number of bytes wanted" plus "-1 for character conversion * style errors". Solaris adapted to this rule, but Windows stuck * with -1. * * Original OpenSSL comment which is full of lies: * * "In case of truncation, return -1 like traditional snprintf. * (Current drafts for ISO/IEC 9899 say snprintf should return * the number of characters that would have been written, * had the buffer been large enough.)" */ int BIO_snprintf(char *buf, size_t n, const char *format, ...) { va_list args; int ret; va_start(args, format); ret = vsnprintf(buf, n, format, args); va_end(args); if (ret >= n || ret == -1) return (-1); return (ret); } int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) { int ret; ret = vsnprintf(buf, n, format, args); if (ret >= n || ret == -1) return (-1); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/bss_fd.c0000644000175000017500000001476712360020705020447 0ustar /* $OpenBSD: bss_fd.c,v 1.16 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #if defined(OPENSSL_NO_POSIX_IO) /* * One can argue that one should implement dummy placeholder for * BIO_s_fd here... */ #else #include static int fd_write(BIO *h, const char *buf, int num); static int fd_read(BIO *h, char *buf, int size); static int fd_puts(BIO *h, const char *str); static int fd_gets(BIO *h, char *buf, int size); static long fd_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int fd_new(BIO *h); static int fd_free(BIO *data); int BIO_fd_should_retry(int s); static BIO_METHOD methods_fdp = { .type = BIO_TYPE_FD, .name = "file descriptor", .bwrite = fd_write, .bread = fd_read, .bputs = fd_puts, .bgets = fd_gets, .ctrl = fd_ctrl, .create = fd_new, .destroy = fd_free }; BIO_METHOD * BIO_s_fd(void) { return (&methods_fdp); } BIO * BIO_new_fd(int fd, int close_flag) { BIO *ret; ret = BIO_new(BIO_s_fd()); if (ret == NULL) return (NULL); BIO_set_fd(ret, fd, close_flag); return (ret); } static int fd_new(BIO *bi) { bi->init = 0; bi->num = -1; bi->ptr = NULL; bi->flags=0; return (1); } static int fd_free(BIO *a) { if (a == NULL) return (0); if (a->shutdown) { if (a->init) { close(a->num); } a->init = 0; a->flags = 0; } return (1); } static int fd_read(BIO *b, char *out, int outl) { int ret = 0; if (out != NULL) { errno = 0; ret = read(b->num, out, outl); BIO_clear_retry_flags(b); if (ret <= 0) { if (BIO_fd_should_retry(ret)) BIO_set_retry_read(b); } } return (ret); } static int fd_write(BIO *b, const char *in, int inl) { int ret; errno = 0; ret = write(b->num, in, inl); BIO_clear_retry_flags(b); if (ret <= 0) { if (BIO_fd_should_retry(ret)) BIO_set_retry_write(b); } return (ret); } static long fd_ctrl(BIO *b, int cmd, long num, void *ptr) { long ret = 1; int *ip; switch (cmd) { case BIO_CTRL_RESET: num = 0; case BIO_C_FILE_SEEK: ret = (long)lseek(b->num, num, 0); break; case BIO_C_FILE_TELL: case BIO_CTRL_INFO: ret = (long)lseek(b->num, 0, 1); break; case BIO_C_SET_FD: fd_free(b); b->num= *((int *)ptr); b->shutdown = (int)num; b->init = 1; break; case BIO_C_GET_FD: if (b->init) { ip = (int *)ptr; if (ip != NULL) *ip = b->num; ret = b->num; } else ret = -1; break; case BIO_CTRL_GET_CLOSE: ret = b->shutdown; break; case BIO_CTRL_SET_CLOSE: b->shutdown = (int)num; break; case BIO_CTRL_PENDING: case BIO_CTRL_WPENDING: ret = 0; break; case BIO_CTRL_DUP: case BIO_CTRL_FLUSH: ret = 1; break; default: ret = 0; break; } return (ret); } static int fd_puts(BIO *bp, const char *str) { int n, ret; n = strlen(str); ret = fd_write(bp, str, n); return (ret); } static int fd_gets(BIO *bp, char *buf, int size) { int ret = 0; char *ptr = buf; char *end = buf + size - 1; while ((ptr < end) && (fd_read(bp, ptr, 1) > 0) && (ptr[0] != '\n')) ptr++; ptr[0] = '\0'; if (buf[0] != '\0') ret = strlen(buf); return (ret); } int BIO_fd_should_retry(int i) { int err; if ((i == 0) || (i == -1)) { err = errno; return (BIO_fd_non_fatal_error(err)); } return (0); } int BIO_fd_non_fatal_error(int err) { switch (err) { case ENOTCONN: case EINTR: case EAGAIN: case EINPROGRESS: case EALREADY: return (1); default: break; } return (0); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/bss_log.c0000644000175000017500000001273312430034550020627 0ustar /* $OpenBSD: bss_log.c,v 1.20 2014/07/10 13:58:22 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Why BIO_s_log? BIO_s_log is useful for system daemons (or services under NT). It is one-way BIO, it sends all stuff to syslogd (on system that commonly use that), or event log (on NT), or OPCOM (on OpenVMS). */ #include #include #include #ifndef __pnacl__ #include #endif #include #include #ifndef NO_SYSLOG static int slg_write(BIO *h, const char *buf, int num); static int slg_puts(BIO *h, const char *str); static long slg_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int slg_new(BIO *h); static int slg_free(BIO *data); static void xopenlog(BIO* bp, char* name, int level); static void xsyslog(BIO* bp, int priority, const char* string); static void xcloselog(BIO* bp); static BIO_METHOD methods_slg = { .type = BIO_TYPE_MEM, .name = "syslog", .bwrite = slg_write, .bputs = slg_puts, .ctrl = slg_ctrl, .create = slg_new, .destroy = slg_free }; BIO_METHOD * BIO_s_log(void) { return (&methods_slg); } static int slg_new(BIO *bi) { bi->init = 1; bi->num = 0; bi->ptr = NULL; xopenlog(bi, "application", LOG_DAEMON); return (1); } static int slg_free(BIO *a) { if (a == NULL) return (0); xcloselog(a); return (1); } static int slg_write(BIO *b, const char *in, int inl) { int ret = inl; char* buf; char* pp; int priority, i; static const struct { int strl; char str[10]; int log_level; } mapping[] = { { 6, "PANIC ", LOG_EMERG }, { 6, "EMERG ", LOG_EMERG }, { 4, "EMR ", LOG_EMERG }, { 6, "ALERT ", LOG_ALERT }, { 4, "ALR ", LOG_ALERT }, { 5, "CRIT ", LOG_CRIT }, { 4, "CRI ", LOG_CRIT }, { 6, "ERROR ", LOG_ERR }, { 4, "ERR ", LOG_ERR }, { 8, "WARNING ", LOG_WARNING }, { 5, "WARN ", LOG_WARNING }, { 4, "WAR ", LOG_WARNING }, { 7, "NOTICE ", LOG_NOTICE }, { 5, "NOTE ", LOG_NOTICE }, { 4, "NOT ", LOG_NOTICE }, { 5, "INFO ", LOG_INFO }, { 4, "INF ", LOG_INFO }, { 6, "DEBUG ", LOG_DEBUG }, { 4, "DBG ", LOG_DEBUG }, { 0, "", LOG_ERR } /* The default */ }; if ((buf = malloc(inl + 1)) == NULL) { return (0); } strlcpy(buf, in, inl + 1); i = 0; while (strncmp(buf, mapping[i].str, mapping[i].strl) != 0) i++; priority = mapping[i].log_level; pp = buf + mapping[i].strl; xsyslog(b, priority, pp); free(buf); return (ret); } static long slg_ctrl(BIO *b, int cmd, long num, void *ptr) { switch (cmd) { case BIO_CTRL_SET: xcloselog(b); xopenlog(b, ptr, num); break; default: break; } return (0); } static int slg_puts(BIO *bp, const char *str) { int n, ret; n = strlen(str); ret = slg_write(bp, str, n); return (ret); } static void xopenlog(BIO* bp, char* name, int level) { openlog(name, LOG_PID|LOG_CONS, level); } static void xsyslog(BIO *bp, int priority, const char *string) { syslog(priority, "%s", string); } static void xcloselog(BIO* bp) { closelog(); } #endif /* NO_SYSLOG */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/bss_sock.c0000644000175000017500000001356412360020705021007 0ustar /* $OpenBSD: bss_sock.c,v 1.22 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include static int sock_write(BIO *h, const char *buf, int num); static int sock_read(BIO *h, char *buf, int size); static int sock_puts(BIO *h, const char *str); static long sock_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int sock_new(BIO *h); static int sock_free(BIO *data); int BIO_sock_should_retry(int s); static BIO_METHOD methods_sockp = { .type = BIO_TYPE_SOCKET, .name = "socket", .bwrite = sock_write, .bread = sock_read, .bputs = sock_puts, .ctrl = sock_ctrl, .create = sock_new, .destroy = sock_free }; BIO_METHOD * BIO_s_socket(void) { return (&methods_sockp); } BIO * BIO_new_socket(int fd, int close_flag) { BIO *ret; ret = BIO_new(BIO_s_socket()); if (ret == NULL) return (NULL); BIO_set_fd(ret, fd, close_flag); return (ret); } static int sock_new(BIO *bi) { bi->init = 0; bi->num = 0; bi->ptr = NULL; bi->flags = 0; return (1); } static int sock_free(BIO *a) { if (a == NULL) return (0); if (a->shutdown) { if (a->init) { shutdown(a->num, SHUT_RDWR); close(a->num); } a->init = 0; a->flags = 0; } return (1); } static int sock_read(BIO *b, char *out, int outl) { int ret = 0; if (out != NULL) { errno = 0; ret = read(b->num, out, outl); BIO_clear_retry_flags(b); if (ret <= 0) { if (BIO_sock_should_retry(ret)) BIO_set_retry_read(b); } } return (ret); } static int sock_write(BIO *b, const char *in, int inl) { int ret; errno = 0; ret = write(b->num, in, inl); BIO_clear_retry_flags(b); if (ret <= 0) { if (BIO_sock_should_retry(ret)) BIO_set_retry_write(b); } return (ret); } static long sock_ctrl(BIO *b, int cmd, long num, void *ptr) { long ret = 1; int *ip; switch (cmd) { case BIO_C_SET_FD: sock_free(b); b->num= *((int *)ptr); b->shutdown = (int)num; b->init = 1; break; case BIO_C_GET_FD: if (b->init) { ip = (int *)ptr; if (ip != NULL) *ip = b->num; ret = b->num; } else ret = -1; break; case BIO_CTRL_GET_CLOSE: ret = b->shutdown; break; case BIO_CTRL_SET_CLOSE: b->shutdown = (int)num; break; case BIO_CTRL_DUP: case BIO_CTRL_FLUSH: ret = 1; break; default: ret = 0; break; } return (ret); } static int sock_puts(BIO *bp, const char *str) { int n, ret; n = strlen(str); ret = sock_write(bp, str, n); return (ret); } int BIO_sock_should_retry(int i) { int err; if ((i == 0) || (i == -1)) { err = errno; return (BIO_sock_non_fatal_error(err)); } return (0); } int BIO_sock_non_fatal_error(int err) { switch (err) { case ENOTCONN: case EINTR: case EAGAIN: case EINPROGRESS: case EALREADY: return (1); default: break; } return (0); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/bf_buff.c0000644000175000017500000003042512360020705020565 0ustar /* $OpenBSD: bf_buff.c,v 1.20 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include static int buffer_write(BIO *h, const char *buf, int num); static int buffer_read(BIO *h, char *buf, int size); static int buffer_puts(BIO *h, const char *str); static int buffer_gets(BIO *h, char *str, int size); static long buffer_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int buffer_new(BIO *h); static int buffer_free(BIO *data); static long buffer_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); #define DEFAULT_BUFFER_SIZE 4096 static BIO_METHOD methods_buffer = { .type = BIO_TYPE_BUFFER, .name = "buffer", .bwrite = buffer_write, .bread = buffer_read, .bputs = buffer_puts, .bgets = buffer_gets, .ctrl = buffer_ctrl, .create = buffer_new, .destroy = buffer_free, .callback_ctrl = buffer_callback_ctrl }; BIO_METHOD * BIO_f_buffer(void) { return (&methods_buffer); } static int buffer_new(BIO *bi) { BIO_F_BUFFER_CTX *ctx; ctx = malloc(sizeof(BIO_F_BUFFER_CTX)); if (ctx == NULL) return (0); ctx->ibuf = malloc(DEFAULT_BUFFER_SIZE); if (ctx->ibuf == NULL) { free(ctx); return (0); } ctx->obuf = malloc(DEFAULT_BUFFER_SIZE); if (ctx->obuf == NULL) { free(ctx->ibuf); free(ctx); return (0); } ctx->ibuf_size = DEFAULT_BUFFER_SIZE; ctx->obuf_size = DEFAULT_BUFFER_SIZE; ctx->ibuf_len = 0; ctx->ibuf_off = 0; ctx->obuf_len = 0; ctx->obuf_off = 0; bi->init = 1; bi->ptr = (char *)ctx; bi->flags = 0; return (1); } static int buffer_free(BIO *a) { BIO_F_BUFFER_CTX *b; if (a == NULL) return (0); b = (BIO_F_BUFFER_CTX *)a->ptr; free(b->ibuf); free(b->obuf); free(a->ptr); a->ptr = NULL; a->init = 0; a->flags = 0; return (1); } static int buffer_read(BIO *b, char *out, int outl) { int i, num = 0; BIO_F_BUFFER_CTX *ctx; if (out == NULL) return (0); ctx = (BIO_F_BUFFER_CTX *)b->ptr; if ((ctx == NULL) || (b->next_bio == NULL)) return (0); num = 0; BIO_clear_retry_flags(b); start: i = ctx->ibuf_len; /* If there is stuff left over, grab it */ if (i != 0) { if (i > outl) i = outl; memcpy(out, &(ctx->ibuf[ctx->ibuf_off]), i); ctx->ibuf_off += i; ctx->ibuf_len -= i; num += i; if (outl == i) return (num); outl -= i; out += i; } /* We may have done a partial read. try to do more. * We have nothing in the buffer. * If we get an error and have read some data, just return it * and let them retry to get the error again. * copy direct to parent address space */ if (outl > ctx->ibuf_size) { for (;;) { i = BIO_read(b->next_bio, out, outl); if (i <= 0) { BIO_copy_next_retry(b); if (i < 0) return ((num > 0) ? num : i); if (i == 0) return (num); } num += i; if (outl == i) return (num); out += i; outl -= i; } } /* else */ /* we are going to be doing some buffering */ i = BIO_read(b->next_bio, ctx->ibuf, ctx->ibuf_size); if (i <= 0) { BIO_copy_next_retry(b); if (i < 0) return ((num > 0) ? num : i); if (i == 0) return (num); } ctx->ibuf_off = 0; ctx->ibuf_len = i; /* Lets re-read using ourselves :-) */ goto start; } static int buffer_write(BIO *b, const char *in, int inl) { int i, num = 0; BIO_F_BUFFER_CTX *ctx; if ((in == NULL) || (inl <= 0)) return (0); ctx = (BIO_F_BUFFER_CTX *)b->ptr; if ((ctx == NULL) || (b->next_bio == NULL)) return (0); BIO_clear_retry_flags(b); start: i = ctx->obuf_size - (ctx->obuf_len + ctx->obuf_off); /* add to buffer and return */ if (i >= inl) { memcpy(&(ctx->obuf[ctx->obuf_off + ctx->obuf_len]), in, inl); ctx->obuf_len += inl; return (num + inl); } /* else */ /* stuff already in buffer, so add to it first, then flush */ if (ctx->obuf_len != 0) { if (i > 0) /* lets fill it up if we can */ { memcpy(&(ctx->obuf[ctx->obuf_off + ctx->obuf_len]), in, i); in += i; inl -= i; num += i; ctx->obuf_len += i; } /* we now have a full buffer needing flushing */ for (;;) { i = BIO_write(b->next_bio, &(ctx->obuf[ctx->obuf_off]), ctx->obuf_len); if (i <= 0) { BIO_copy_next_retry(b); if (i < 0) return ((num > 0) ? num : i); if (i == 0) return (num); } ctx->obuf_off += i; ctx->obuf_len -= i; if (ctx->obuf_len == 0) break; } } /* we only get here if the buffer has been flushed and we * still have stuff to write */ ctx->obuf_off = 0; /* we now have inl bytes to write */ while (inl >= ctx->obuf_size) { i = BIO_write(b->next_bio, in, inl); if (i <= 0) { BIO_copy_next_retry(b); if (i < 0) return ((num > 0) ? num : i); if (i == 0) return (num); } num += i; in += i; inl -= i; if (inl == 0) return (num); } /* copy the rest into the buffer since we have only a small * amount left */ goto start; } static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr) { BIO *dbio; BIO_F_BUFFER_CTX *ctx; long ret = 1; char *p1, *p2; int r, i, *ip; int ibs, obs; ctx = (BIO_F_BUFFER_CTX *)b->ptr; switch (cmd) { case BIO_CTRL_RESET: ctx->ibuf_off = 0; ctx->ibuf_len = 0; ctx->obuf_off = 0; ctx->obuf_len = 0; if (b->next_bio == NULL) return (0); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; case BIO_CTRL_INFO: ret = (long)ctx->obuf_len; break; case BIO_C_GET_BUFF_NUM_LINES: ret = 0; p1 = ctx->ibuf; for (i = 0; i < ctx->ibuf_len; i++) { if (p1[ctx->ibuf_off + i] == '\n') ret++; } break; case BIO_CTRL_WPENDING: ret = (long)ctx->obuf_len; if (ret == 0) { if (b->next_bio == NULL) return (0); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); } break; case BIO_CTRL_PENDING: ret = (long)ctx->ibuf_len; if (ret == 0) { if (b->next_bio == NULL) return (0); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); } break; case BIO_C_SET_BUFF_READ_DATA: if (num > ctx->ibuf_size) { p1 = malloc((int)num); if (p1 == NULL) goto malloc_error; free(ctx->ibuf); ctx->ibuf = p1; } ctx->ibuf_off = 0; ctx->ibuf_len = (int)num; memcpy(ctx->ibuf, ptr, num); ret = 1; break; case BIO_C_SET_BUFF_SIZE: if (ptr != NULL) { ip = (int *)ptr; if (*ip == 0) { ibs = (int)num; obs = ctx->obuf_size; } else /* if (*ip == 1) */ { ibs = ctx->ibuf_size; obs = (int)num; } } else { ibs = (int)num; obs = (int)num; } p1 = ctx->ibuf; p2 = ctx->obuf; if ((ibs > DEFAULT_BUFFER_SIZE) && (ibs != ctx->ibuf_size)) { p1 = malloc((int)num); if (p1 == NULL) goto malloc_error; } if ((obs > DEFAULT_BUFFER_SIZE) && (obs != ctx->obuf_size)) { p2 = malloc((int)num); if (p2 == NULL) { if (p1 != ctx->ibuf) free(p1); goto malloc_error; } } if (ctx->ibuf != p1) { free(ctx->ibuf); ctx->ibuf = p1; ctx->ibuf_off = 0; ctx->ibuf_len = 0; ctx->ibuf_size = ibs; } if (ctx->obuf != p2) { free(ctx->obuf); ctx->obuf = p2; ctx->obuf_off = 0; ctx->obuf_len = 0; ctx->obuf_size = obs; } break; case BIO_C_DO_STATE_MACHINE: if (b->next_bio == NULL) return (0); BIO_clear_retry_flags(b); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); BIO_copy_next_retry(b); break; case BIO_CTRL_FLUSH: if (b->next_bio == NULL) return (0); if (ctx->obuf_len <= 0) { ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; } for (;;) { BIO_clear_retry_flags(b); if (ctx->obuf_len > 0) { r = BIO_write(b->next_bio, &(ctx->obuf[ctx->obuf_off]), ctx->obuf_len); BIO_copy_next_retry(b); if (r <= 0) return ((long)r); ctx->obuf_off += r; ctx->obuf_len -= r; } else { ctx->obuf_len = 0; ctx->obuf_off = 0; ret = 1; break; } } ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; case BIO_CTRL_DUP: dbio = (BIO *)ptr; if (!BIO_set_read_buffer_size(dbio, ctx->ibuf_size) || !BIO_set_write_buffer_size(dbio, ctx->obuf_size)) ret = 0; break; default: if (b->next_bio == NULL) return (0); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; } return (ret); malloc_error: BIOerr(BIO_F_BUFFER_CTRL, ERR_R_MALLOC_FAILURE); return (0); } static long buffer_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) { long ret = 1; if (b->next_bio == NULL) return (0); switch (cmd) { default: ret = BIO_callback_ctrl(b->next_bio, cmd, fp); break; } return (ret); } static int buffer_gets(BIO *b, char *buf, int size) { BIO_F_BUFFER_CTX *ctx; int num = 0, i, flag; char *p; ctx = (BIO_F_BUFFER_CTX *)b->ptr; size--; /* reserve space for a '\0' */ BIO_clear_retry_flags(b); for (;;) { if (ctx->ibuf_len > 0) { p = &(ctx->ibuf[ctx->ibuf_off]); flag = 0; for (i = 0; (i < ctx->ibuf_len) && (i < size); i++) { *(buf++) = p[i]; if (p[i] == '\n') { flag = 1; i++; break; } } num += i; size -= i; ctx->ibuf_len -= i; ctx->ibuf_off += i; if (flag || size == 0) { *buf = '\0'; return (num); } } else /* read another chunk */ { i = BIO_read(b->next_bio, ctx->ibuf, ctx->ibuf_size); if (i <= 0) { BIO_copy_next_retry(b); *buf = '\0'; if (i < 0) return ((num > 0) ? num : i); if (i == 0) return (num); } ctx->ibuf_len = i; ctx->ibuf_off = 0; } } } static int buffer_puts(BIO *b, const char *str) { return (buffer_write(b, str, strlen(str))); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/bio_cb.c0000644000175000017500000001245612360020705020415 0ustar /* $OpenBSD: bio_cb.c,v 1.14 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi, long argl, long ret) { BIO *b; char buf[256]; char *p; long r = 1; size_t p_maxlen; if (BIO_CB_RETURN & cmd) r = ret; snprintf(buf, sizeof buf, "BIO[%08lX]:", (unsigned long)bio); p = &(buf[14]); p_maxlen = sizeof buf - 14; switch (cmd) { case BIO_CB_FREE: snprintf(p, p_maxlen, "Free - %s\n", bio->method->name); break; case BIO_CB_READ: if (bio->method->type & BIO_TYPE_DESCRIPTOR) snprintf(p, p_maxlen, "read(%d,%lu) - %s fd=%d\n", bio->num, (unsigned long)argi, bio->method->name, bio->num); else snprintf(p, p_maxlen, "read(%d,%lu) - %s\n", bio->num, (unsigned long)argi, bio->method->name); break; case BIO_CB_WRITE: if (bio->method->type & BIO_TYPE_DESCRIPTOR) snprintf(p, p_maxlen, "write(%d,%lu) - %s fd=%d\n", bio->num, (unsigned long)argi, bio->method->name, bio->num); else snprintf(p, p_maxlen, "write(%d,%lu) - %s\n", bio->num, (unsigned long)argi, bio->method->name); break; case BIO_CB_PUTS: snprintf(p, p_maxlen, "puts() - %s\n", bio->method->name); break; case BIO_CB_GETS: snprintf(p, p_maxlen, "gets(%lu) - %s\n", (unsigned long)argi, bio->method->name); break; case BIO_CB_CTRL: snprintf(p, p_maxlen, "ctrl(%lu) - %s\n", (unsigned long)argi, bio->method->name); break; case BIO_CB_RETURN|BIO_CB_READ: snprintf(p, p_maxlen, "read return %ld\n", ret); break; case BIO_CB_RETURN|BIO_CB_WRITE: snprintf(p, p_maxlen, "write return %ld\n", ret); break; case BIO_CB_RETURN|BIO_CB_GETS: snprintf(p, p_maxlen, "gets return %ld\n", ret); break; case BIO_CB_RETURN|BIO_CB_PUTS: snprintf(p, p_maxlen, "puts return %ld\n", ret); break; case BIO_CB_RETURN|BIO_CB_CTRL: snprintf(p, p_maxlen, "ctrl return %ld\n", ret); break; default: snprintf(p, p_maxlen, "bio callback - unknown type (%d)\n", cmd); break; } b = (BIO *)bio->cb_arg; if (b != NULL) BIO_write(b, buf, strlen(buf)); else fputs(buf, stderr); return (r); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/b_dump.c0000644000175000017500000001371312360020705020443 0ustar /* $OpenBSD: b_dump.c,v 1.18 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* * Stolen from tjh's ssl/ssl_trc.c stuff. */ #include #include #include #define TRUNCATE #define DUMP_WIDTH 16 #define DUMP_WIDTH_LESS_INDENT(i) (DUMP_WIDTH - ((i - (i > 6 ? 6 : i) + 3) / 4)) int BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u), void *u, const char *s, int len) { return BIO_dump_indent_cb(cb, u, s, len, 0); } int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), void *u, const char *s, int len, int indent) { int ret = 0; char buf[288 + 1], tmp[20], str[128 + 1]; int i, j, rows, trc; unsigned char ch; int dump_width; trc = 0; #ifdef TRUNCATE for (; (len > 0) && ((s[len - 1] == ' ') || (s[len - 1] == '\0')); len--) trc++; #endif if (indent < 0) indent = 0; if (indent) { if (indent > 128) indent = 128; memset(str, ' ', indent); } str[indent] = '\0'; dump_width = DUMP_WIDTH_LESS_INDENT(indent); rows = (len / dump_width); if ((rows * dump_width) < len) rows++; for (i = 0; i < rows; i++) { buf[0] = '\0'; /* start with empty string */ strlcpy(buf, str, sizeof buf); snprintf(tmp, sizeof tmp, "%04x - ", i*dump_width); strlcat(buf, tmp, sizeof buf); for (j = 0; j < dump_width; j++) { if (((i*dump_width) + j) >= len) { strlcat(buf, " ", sizeof buf); } else { ch = ((unsigned char)*(s + i*dump_width + j)) & 0xff; snprintf(tmp, sizeof tmp, "%02x%c", ch, j == 7 ? '-' : ' '); strlcat(buf, tmp, sizeof buf); } } strlcat(buf, " ", sizeof buf); for (j = 0; j < dump_width; j++) { if (((i*dump_width) + j) >= len) break; ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff; snprintf(tmp, sizeof tmp, "%c", ((ch >= ' ') && (ch <= '~')) ? ch : '.'); strlcat(buf, tmp, sizeof buf); } strlcat(buf, "\n", sizeof buf); /* if this is the last call then update the ddt_dump thing so * that we will move the selection point in the debug window */ ret += cb((void *)buf, strlen(buf), u); } #ifdef TRUNCATE if (trc > 0) { snprintf(buf, sizeof buf, "%s%04x - \n", str, len + trc); ret += cb((void *)buf, strlen(buf), u); } #endif return (ret); } static int write_fp(const void *data, size_t len, void *fp) { return fwrite(data, len, 1, fp); } int BIO_dump_fp(FILE *fp, const char *s, int len) { return BIO_dump_cb(write_fp, fp, s, len); } int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent) { return BIO_dump_indent_cb(write_fp, fp, s, len, indent); } static int write_bio(const void *data, size_t len, void *bp) { return BIO_write((BIO *)bp, (const char *)data, len); } int BIO_dump(BIO *bp, const char *s, int len) { return BIO_dump_cb(write_bio, bp, s, len); } int BIO_dump_indent(BIO *bp, const char *s, int len, int indent) { return BIO_dump_indent_cb(write_bio, bp, s, len, indent); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/bio_err.c0000644000175000017500000001572012360020705020616 0ustar /* $OpenBSD: bio_err.c,v 1.15 2014/06/22 14:41:10 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_BIO,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_BIO,0,reason) static ERR_STRING_DATA BIO_str_functs[] = { {ERR_FUNC(BIO_F_ACPT_STATE), "ACPT_STATE"}, {ERR_FUNC(BIO_F_BIO_ACCEPT), "BIO_accept"}, {ERR_FUNC(BIO_F_BIO_BER_GET_HEADER), "BIO_BER_GET_HEADER"}, {ERR_FUNC(BIO_F_BIO_CALLBACK_CTRL), "BIO_callback_ctrl"}, {ERR_FUNC(BIO_F_BIO_CTRL), "BIO_ctrl"}, {ERR_FUNC(BIO_F_BIO_GETHOSTBYNAME), "BIO_gethostbyname"}, {ERR_FUNC(BIO_F_BIO_GETS), "BIO_gets"}, {ERR_FUNC(BIO_F_BIO_GET_ACCEPT_SOCKET), "BIO_get_accept_socket"}, {ERR_FUNC(BIO_F_BIO_GET_HOST_IP), "BIO_get_host_ip"}, {ERR_FUNC(BIO_F_BIO_GET_PORT), "BIO_get_port"}, {ERR_FUNC(BIO_F_BIO_MAKE_PAIR), "BIO_MAKE_PAIR"}, {ERR_FUNC(BIO_F_BIO_NEW), "BIO_new"}, {ERR_FUNC(BIO_F_BIO_NEW_FILE), "BIO_new_file"}, {ERR_FUNC(BIO_F_BIO_NEW_MEM_BUF), "BIO_new_mem_buf"}, {ERR_FUNC(BIO_F_BIO_NREAD), "BIO_nread"}, {ERR_FUNC(BIO_F_BIO_NREAD0), "BIO_nread0"}, {ERR_FUNC(BIO_F_BIO_NWRITE), "BIO_nwrite"}, {ERR_FUNC(BIO_F_BIO_NWRITE0), "BIO_nwrite0"}, {ERR_FUNC(BIO_F_BIO_PUTS), "BIO_puts"}, {ERR_FUNC(BIO_F_BIO_READ), "BIO_read"}, {ERR_FUNC(BIO_F_BIO_SOCK_INIT), "BIO_sock_init"}, {ERR_FUNC(BIO_F_BIO_WRITE), "BIO_write"}, {ERR_FUNC(BIO_F_BUFFER_CTRL), "BUFFER_CTRL"}, {ERR_FUNC(BIO_F_CONN_CTRL), "CONN_CTRL"}, {ERR_FUNC(BIO_F_CONN_STATE), "CONN_STATE"}, {ERR_FUNC(BIO_F_DGRAM_SCTP_READ), "DGRAM_SCTP_READ"}, {ERR_FUNC(BIO_F_FILE_CTRL), "FILE_CTRL"}, {ERR_FUNC(BIO_F_FILE_READ), "FILE_READ"}, {ERR_FUNC(BIO_F_LINEBUFFER_CTRL), "LINEBUFFER_CTRL"}, {ERR_FUNC(BIO_F_MEM_READ), "MEM_READ"}, {ERR_FUNC(BIO_F_MEM_WRITE), "MEM_WRITE"}, {ERR_FUNC(BIO_F_SSL_NEW), "SSL_new"}, {ERR_FUNC(BIO_F_WSASTARTUP), "WSASTARTUP"}, {0, NULL} }; static ERR_STRING_DATA BIO_str_reasons[] = { {ERR_REASON(BIO_R_ACCEPT_ERROR) , "accept error"}, {ERR_REASON(BIO_R_BAD_FOPEN_MODE) , "bad fopen mode"}, {ERR_REASON(BIO_R_BAD_HOSTNAME_LOOKUP) , "bad hostname lookup"}, {ERR_REASON(BIO_R_BROKEN_PIPE) , "broken pipe"}, {ERR_REASON(BIO_R_CONNECT_ERROR) , "connect error"}, {ERR_REASON(BIO_R_EOF_ON_MEMORY_BIO) , "EOF on memory BIO"}, {ERR_REASON(BIO_R_ERROR_SETTING_NBIO) , "error setting nbio"}, {ERR_REASON(BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET), "error setting nbio on accepted socket"}, {ERR_REASON(BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET), "error setting nbio on accept socket"}, {ERR_REASON(BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET), "gethostbyname addr is not af inet"}, {ERR_REASON(BIO_R_INVALID_ARGUMENT) , "invalid argument"}, {ERR_REASON(BIO_R_INVALID_IP_ADDRESS) , "invalid ip address"}, {ERR_REASON(BIO_R_INVALID_PORT_NUMBER) , "invalid port number"}, {ERR_REASON(BIO_R_IN_USE) , "in use"}, {ERR_REASON(BIO_R_KEEPALIVE) , "keepalive"}, {ERR_REASON(BIO_R_NBIO_CONNECT_ERROR) , "nbio connect error"}, {ERR_REASON(BIO_R_NO_ACCEPT_PORT_SPECIFIED), "no accept port specified"}, {ERR_REASON(BIO_R_NO_HOSTNAME_SPECIFIED) , "no hostname specified"}, {ERR_REASON(BIO_R_NO_PORT_DEFINED) , "no port defined"}, {ERR_REASON(BIO_R_NO_PORT_SPECIFIED) , "no port specified"}, {ERR_REASON(BIO_R_NO_SUCH_FILE) , "no such file"}, {ERR_REASON(BIO_R_NULL_PARAMETER) , "null parameter"}, {ERR_REASON(BIO_R_TAG_MISMATCH) , "tag mismatch"}, {ERR_REASON(BIO_R_UNABLE_TO_BIND_SOCKET) , "unable to bind socket"}, {ERR_REASON(BIO_R_UNABLE_TO_CREATE_SOCKET), "unable to create socket"}, {ERR_REASON(BIO_R_UNABLE_TO_LISTEN_SOCKET), "unable to listen socket"}, {ERR_REASON(BIO_R_UNINITIALIZED) , "uninitialized"}, {ERR_REASON(BIO_R_UNSUPPORTED_METHOD) , "unsupported method"}, {ERR_REASON(BIO_R_WRITE_TO_READ_ONLY_BIO), "write to read only BIO"}, {ERR_REASON(BIO_R_WSASTARTUP) , "WSAStartup"}, {0, NULL} }; #endif void ERR_load_BIO_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(BIO_str_functs[0].error) == NULL) { ERR_load_strings(0, BIO_str_functs); ERR_load_strings(0, BIO_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bio/bio_lib.c0000644000175000017500000003172312360020705020575 0ustar /* $OpenBSD: bio_lib.c,v 1.19 2014/07/11 08:44:47 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include BIO * BIO_new(BIO_METHOD *method) { BIO *ret = NULL; ret = malloc(sizeof(BIO)); if (ret == NULL) { BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } if (!BIO_set(ret, method)) { free(ret); ret = NULL; } return (ret); } int BIO_set(BIO *bio, BIO_METHOD *method) { bio->method = method; bio->callback = NULL; bio->cb_arg = NULL; bio->init = 0; bio->shutdown = 1; bio->flags = 0; bio->retry_reason = 0; bio->num = 0; bio->ptr = NULL; bio->prev_bio = NULL; bio->next_bio = NULL; bio->references = 1; bio->num_read = 0L; bio->num_write = 0L; CRYPTO_new_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data); if (method->create != NULL) if (!method->create(bio)) { CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data); return (0); } return (1); } int BIO_free(BIO *a) { int i; if (a == NULL) return (0); i = CRYPTO_add(&a->references, -1, CRYPTO_LOCK_BIO); if (i > 0) return (1); if ((a->callback != NULL) && ((i = (int)a->callback(a, BIO_CB_FREE, NULL, 0, 0L, 1L)) <= 0)) return (i); CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data); if (a->method != NULL && a->method->destroy != NULL) a->method->destroy(a); free(a); return (1); } void BIO_vfree(BIO *a) { BIO_free(a); } void BIO_clear_flags(BIO *b, int flags) { b->flags &= ~flags; } int BIO_test_flags(const BIO *b, int flags) { return (b->flags & flags); } void BIO_set_flags(BIO *b, int flags) { b->flags |= flags; } long (*BIO_get_callback(const BIO *b))(struct bio_st *, int, const char *, int, long, long) { return b->callback; } void BIO_set_callback(BIO *b, long (*cb)(struct bio_st *, int, const char *, int, long, long)) { b->callback = cb; } void BIO_set_callback_arg(BIO *b, char *arg) { b->cb_arg = arg; } char * BIO_get_callback_arg(const BIO *b) { return b->cb_arg; } const char * BIO_method_name(const BIO *b) { return b->method->name; } int BIO_method_type(const BIO *b) { return b->method->type; } int BIO_read(BIO *b, void *out, int outl) { int i; long (*cb)(BIO *, int, const char *, int, long, long); if ((b == NULL) || (b->method == NULL) || (b->method->bread == NULL)) { BIOerr(BIO_F_BIO_READ, BIO_R_UNSUPPORTED_METHOD); return (-2); } cb = b->callback; if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_READ, out, outl, 0L, 1L)) <= 0)) return (i); if (!b->init) { BIOerr(BIO_F_BIO_READ, BIO_R_UNINITIALIZED); return (-2); } i = b->method->bread(b, out, outl); if (i > 0) b->num_read += (unsigned long)i; if (cb != NULL) i = (int)cb(b, BIO_CB_READ|BIO_CB_RETURN, out, outl, 0L, (long)i); return (i); } int BIO_write(BIO *b, const void *in, int inl) { int i; long (*cb)(BIO *, int, const char *, int, long, long); if (b == NULL) return (0); cb = b->callback; if ((b->method == NULL) || (b->method->bwrite == NULL)) { BIOerr(BIO_F_BIO_WRITE, BIO_R_UNSUPPORTED_METHOD); return (-2); } if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_WRITE, in, inl, 0L, 1L)) <= 0)) return (i); if (!b->init) { BIOerr(BIO_F_BIO_WRITE, BIO_R_UNINITIALIZED); return (-2); } i = b->method->bwrite(b, in, inl); if (i > 0) b->num_write += (unsigned long)i; if (cb != NULL) i = (int)cb(b, BIO_CB_WRITE|BIO_CB_RETURN, in, inl, 0L, (long)i); return (i); } int BIO_puts(BIO *b, const char *in) { int i; long (*cb)(BIO *, int, const char *, int, long, long); if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) { BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD); return (-2); } cb = b->callback; if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_PUTS, in, 0, 0L, 1L)) <= 0)) return (i); if (!b->init) { BIOerr(BIO_F_BIO_PUTS, BIO_R_UNINITIALIZED); return (-2); } i = b->method->bputs(b, in); if (i > 0) b->num_write += (unsigned long)i; if (cb != NULL) i = (int)cb(b, BIO_CB_PUTS|BIO_CB_RETURN, in, 0, 0L, (long)i); return (i); } int BIO_gets(BIO *b, char *in, int inl) { int i; long (*cb)(BIO *, int, const char *, int, long, long); if ((b == NULL) || (b->method == NULL) || (b->method->bgets == NULL)) { BIOerr(BIO_F_BIO_GETS, BIO_R_UNSUPPORTED_METHOD); return (-2); } cb = b->callback; if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_GETS, in, inl, 0L, 1L)) <= 0)) return (i); if (!b->init) { BIOerr(BIO_F_BIO_GETS, BIO_R_UNINITIALIZED); return (-2); } i = b->method->bgets(b, in, inl); if (cb != NULL) i = (int)cb(b, BIO_CB_GETS|BIO_CB_RETURN, in, inl, 0L, (long)i); return (i); } int BIO_indent(BIO *b, int indent, int max) { if (indent < 0) indent = 0; if (indent > max) indent = max; while (indent--) if (BIO_puts(b, " ") != 1) return 0; return 1; } long BIO_int_ctrl(BIO *b, int cmd, long larg, int iarg) { int i; i = iarg; return (BIO_ctrl(b, cmd, larg, (char *)&i)); } char * BIO_ptr_ctrl(BIO *b, int cmd, long larg) { char *p = NULL; if (BIO_ctrl(b, cmd, larg, (char *)&p) <= 0) return (NULL); else return (p); } long BIO_ctrl(BIO *b, int cmd, long larg, void *parg) { long ret; long (*cb)(BIO *, int, const char *, int, long, long); if (b == NULL) return (0); if ((b->method == NULL) || (b->method->ctrl == NULL)) { BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD); return (-2); } cb = b->callback; if ((cb != NULL) && ((ret = cb(b, BIO_CB_CTRL, parg, cmd, larg, 1L)) <= 0)) return (ret); ret = b->method->ctrl(b, cmd, larg, parg); if (cb != NULL) ret = cb(b, BIO_CB_CTRL|BIO_CB_RETURN, parg, cmd, larg, ret); return (ret); } long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long)) { long ret; long (*cb)(BIO *, int, const char *, int, long, long); if (b == NULL) return (0); if ((b->method == NULL) || (b->method->callback_ctrl == NULL)) { BIOerr(BIO_F_BIO_CALLBACK_CTRL, BIO_R_UNSUPPORTED_METHOD); return (-2); } cb = b->callback; if ((cb != NULL) && ((ret = cb(b, BIO_CB_CTRL, (void *)&fp, cmd, 0, 1L)) <= 0)) return (ret); ret = b->method->callback_ctrl(b, cmd, fp); if (cb != NULL) ret = cb(b, BIO_CB_CTRL|BIO_CB_RETURN, (void *)&fp, cmd, 0, ret); return (ret); } /* It is unfortunate to duplicate in functions what the BIO_(w)pending macros * do; but those macros have inappropriate return type, and for interfacing * from other programming languages, C macros aren't much of a help anyway. */ size_t BIO_ctrl_pending(BIO *bio) { return BIO_ctrl(bio, BIO_CTRL_PENDING, 0, NULL); } size_t BIO_ctrl_wpending(BIO *bio) { return BIO_ctrl(bio, BIO_CTRL_WPENDING, 0, NULL); } /* put the 'bio' on the end of b's list of operators */ BIO * BIO_push(BIO *b, BIO *bio) { BIO *lb; if (b == NULL) return (bio); lb = b; while (lb->next_bio != NULL) lb = lb->next_bio; lb->next_bio = bio; if (bio != NULL) bio->prev_bio = lb; /* called to do internal processing */ BIO_ctrl(b, BIO_CTRL_PUSH, 0, lb); return (b); } /* Remove the first and return the rest */ BIO * BIO_pop(BIO *b) { BIO *ret; if (b == NULL) return (NULL); ret = b->next_bio; BIO_ctrl(b, BIO_CTRL_POP, 0, b); if (b->prev_bio != NULL) b->prev_bio->next_bio = b->next_bio; if (b->next_bio != NULL) b->next_bio->prev_bio = b->prev_bio; b->next_bio = NULL; b->prev_bio = NULL; return (ret); } BIO * BIO_get_retry_BIO(BIO *bio, int *reason) { BIO *b, *last; b = last = bio; for (;;) { if (!BIO_should_retry(b)) break; last = b; b = b->next_bio; if (b == NULL) break; } if (reason != NULL) *reason = last->retry_reason; return (last); } int BIO_get_retry_reason(BIO *bio) { return (bio->retry_reason); } BIO * BIO_find_type(BIO *bio, int type) { int mt, mask; if (!bio) return NULL; mask = type & 0xff; do { if (bio->method != NULL) { mt = bio->method->type; if (!mask) { if (mt & type) return (bio); } else if (mt == type) return (bio); } bio = bio->next_bio; } while (bio != NULL); return (NULL); } BIO * BIO_next(BIO *b) { if (!b) return NULL; return b->next_bio; } void BIO_free_all(BIO *bio) { BIO *b; int ref; while (bio != NULL) { b = bio; ref = b->references; bio = bio->next_bio; BIO_free(b); /* Since ref count > 1, don't free anyone else. */ if (ref > 1) break; } } BIO * BIO_dup_chain(BIO *in) { BIO *ret = NULL, *eoc = NULL, *bio, *new_bio; for (bio = in; bio != NULL; bio = bio->next_bio) { if ((new_bio = BIO_new(bio->method)) == NULL) goto err; new_bio->callback = bio->callback; new_bio->cb_arg = bio->cb_arg; new_bio->init = bio->init; new_bio->shutdown = bio->shutdown; new_bio->flags = bio->flags; /* This will let SSL_s_sock() work with stdin/stdout */ new_bio->num = bio->num; if (!BIO_dup_state(bio, (char *)new_bio)) { BIO_free(new_bio); goto err; } /* copy app data */ if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_BIO, &new_bio->ex_data, &bio->ex_data)) goto err; if (ret == NULL) { eoc = new_bio; ret = eoc; } else { BIO_push(eoc, new_bio); eoc = new_bio; } } return (ret); err: if (ret != NULL) BIO_free(ret); return (NULL); } void BIO_copy_next_retry(BIO *b) { BIO_set_flags(b, BIO_get_retry_flags(b->next_bio)); b->retry_reason = b->next_bio->retry_reason; } int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, argl, argp, new_func, dup_func, free_func); } int BIO_set_ex_data(BIO *bio, int idx, void *data) { return (CRYPTO_set_ex_data(&(bio->ex_data), idx, data)); } void * BIO_get_ex_data(BIO *bio, int idx) { return (CRYPTO_get_ex_data(&(bio->ex_data), idx)); } unsigned long BIO_number_read(BIO *bio) { if (bio) return bio->num_read; return 0; } unsigned long BIO_number_written(BIO *bio) { if (bio) return bio->num_write; return 0; } IMPLEMENT_STACK_OF(BIO) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/Makefile.am0000644000175000017500000005554012430034550020321 0ustar include $(top_srcdir)/Makefile.am.common AM_CPPFLAGS += -I$(top_srcdir)/crypto/asn1 AM_CPPFLAGS += -I$(top_srcdir)/crypto/evp AM_CPPFLAGS += -I$(top_srcdir)/crypto/modes lib_LTLIBRARIES = libcrypto.la libcrypto_la_LIBADD = libcompat.la libcompatnoopt.la libcrypto_la_LDFLAGS = -version-info 29:0:0 libcrypto_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS) -DOPENSSL_NO_HW_PADLOCK noinst_LTLIBRARIES = libcompat.la libcompatnoopt.la # compatibility functions that need to be built without optimizations libcompatnoopt_la_CFLAGS = -O0 libcompatnoopt_la_SOURCES = compat/explicit_bzero.c # other compatibility functions libcompat_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS) libcompat_la_SOURCES = if NO_STRLCAT libcompat_la_SOURCES += compat/strlcat.c endif if NO_STRLCPY libcompat_la_SOURCES += compat/strlcpy.c endif if NO_REALLOCARRAY libcompat_la_SOURCES += compat/reallocarray.c endif if NO_TIMINGSAFE_MEMCMP libcompat_la_SOURCES += compat/timingsafe_memcmp.c endif if NO_TIMINGSAFE_BCMP libcompat_la_SOURCES += compat/timingsafe_bcmp.c endif if NO_ARC4RANDOM_BUF libcompat_la_SOURCES += compat/arc4random.c if NO_GETENTROPY if TARGET_LINUX libcompat_la_SOURCES += compat/getentropy_linux.c endif if TARGET_DARWIN libcompat_la_SOURCES += compat/getentropy_osx.c endif if TARGET_SOLARIS libcompat_la_SOURCES += compat/getentropy_solaris.c endif if TARGET_NACL libcompat_la_SOURCES += compat/getentropy_nacl.c endif endif endif if NO_ISSETUGID libcompat_la_SOURCES += compat/issetugid_linux.c endif noinst_HEADERS = des/ncbc_enc.c noinst_HEADERS += compat/thread_private.h noinst_HEADERS += compat/chacha_private.h libcrypto_la_SOURCES = EXTRA_libcrypto_la_SOURCES = libcrypto_la_SOURCES += cpt_err.c libcrypto_la_SOURCES += cryptlib.c libcrypto_la_SOURCES += cversion.c libcrypto_la_SOURCES += ex_data.c libcrypto_la_SOURCES += malloc-wrapper.c libcrypto_la_SOURCES += mem_clr.c libcrypto_la_SOURCES += mem_dbg.c libcrypto_la_SOURCES += o_init.c libcrypto_la_SOURCES += o_str.c libcrypto_la_SOURCES += o_time.c noinst_HEADERS += cryptlib.h noinst_HEADERS += md32_common.h noinst_HEADERS += o_time.h libcrypto_la_SOURCES += aes/aes_cbc.c libcrypto_la_SOURCES += aes/aes_cfb.c libcrypto_la_SOURCES += aes/aes_core.c libcrypto_la_SOURCES += aes/aes_ctr.c libcrypto_la_SOURCES += aes/aes_ecb.c libcrypto_la_SOURCES += aes/aes_ige.c libcrypto_la_SOURCES += aes/aes_misc.c libcrypto_la_SOURCES += aes/aes_ofb.c libcrypto_la_SOURCES += aes/aes_wrap.c noinst_HEADERS += aes/aes_locl.h libcrypto_la_SOURCES += asn1/a_bitstr.c libcrypto_la_SOURCES += asn1/a_bool.c libcrypto_la_SOURCES += asn1/a_bytes.c libcrypto_la_SOURCES += asn1/a_d2i_fp.c libcrypto_la_SOURCES += asn1/a_digest.c libcrypto_la_SOURCES += asn1/a_dup.c libcrypto_la_SOURCES += asn1/a_enum.c libcrypto_la_SOURCES += asn1/a_gentm.c libcrypto_la_SOURCES += asn1/a_i2d_fp.c libcrypto_la_SOURCES += asn1/a_int.c libcrypto_la_SOURCES += asn1/a_mbstr.c libcrypto_la_SOURCES += asn1/a_object.c libcrypto_la_SOURCES += asn1/a_octet.c libcrypto_la_SOURCES += asn1/a_print.c libcrypto_la_SOURCES += asn1/a_set.c libcrypto_la_SOURCES += asn1/a_sign.c libcrypto_la_SOURCES += asn1/a_strex.c libcrypto_la_SOURCES += asn1/a_strnid.c libcrypto_la_SOURCES += asn1/a_time.c libcrypto_la_SOURCES += asn1/a_type.c libcrypto_la_SOURCES += asn1/a_utctm.c libcrypto_la_SOURCES += asn1/a_utf8.c libcrypto_la_SOURCES += asn1/a_verify.c libcrypto_la_SOURCES += asn1/ameth_lib.c libcrypto_la_SOURCES += asn1/asn1_err.c libcrypto_la_SOURCES += asn1/asn1_gen.c libcrypto_la_SOURCES += asn1/asn1_lib.c libcrypto_la_SOURCES += asn1/asn1_par.c libcrypto_la_SOURCES += asn1/asn_mime.c libcrypto_la_SOURCES += asn1/asn_moid.c libcrypto_la_SOURCES += asn1/asn_pack.c libcrypto_la_SOURCES += asn1/bio_asn1.c libcrypto_la_SOURCES += asn1/bio_ndef.c libcrypto_la_SOURCES += asn1/d2i_pr.c libcrypto_la_SOURCES += asn1/d2i_pu.c libcrypto_la_SOURCES += asn1/evp_asn1.c libcrypto_la_SOURCES += asn1/f_enum.c libcrypto_la_SOURCES += asn1/f_int.c libcrypto_la_SOURCES += asn1/f_string.c libcrypto_la_SOURCES += asn1/i2d_pr.c libcrypto_la_SOURCES += asn1/i2d_pu.c libcrypto_la_SOURCES += asn1/n_pkey.c libcrypto_la_SOURCES += asn1/nsseq.c libcrypto_la_SOURCES += asn1/p5_pbe.c libcrypto_la_SOURCES += asn1/p5_pbev2.c libcrypto_la_SOURCES += asn1/p8_pkey.c libcrypto_la_SOURCES += asn1/t_bitst.c libcrypto_la_SOURCES += asn1/t_crl.c libcrypto_la_SOURCES += asn1/t_pkey.c libcrypto_la_SOURCES += asn1/t_req.c libcrypto_la_SOURCES += asn1/t_spki.c libcrypto_la_SOURCES += asn1/t_x509.c libcrypto_la_SOURCES += asn1/t_x509a.c libcrypto_la_SOURCES += asn1/tasn_dec.c libcrypto_la_SOURCES += asn1/tasn_enc.c libcrypto_la_SOURCES += asn1/tasn_fre.c libcrypto_la_SOURCES += asn1/tasn_new.c libcrypto_la_SOURCES += asn1/tasn_prn.c libcrypto_la_SOURCES += asn1/tasn_typ.c libcrypto_la_SOURCES += asn1/tasn_utl.c libcrypto_la_SOURCES += asn1/x_algor.c libcrypto_la_SOURCES += asn1/x_attrib.c libcrypto_la_SOURCES += asn1/x_bignum.c libcrypto_la_SOURCES += asn1/x_crl.c libcrypto_la_SOURCES += asn1/x_exten.c libcrypto_la_SOURCES += asn1/x_info.c libcrypto_la_SOURCES += asn1/x_long.c libcrypto_la_SOURCES += asn1/x_name.c libcrypto_la_SOURCES += asn1/x_nx509.c libcrypto_la_SOURCES += asn1/x_pkey.c libcrypto_la_SOURCES += asn1/x_pubkey.c libcrypto_la_SOURCES += asn1/x_req.c libcrypto_la_SOURCES += asn1/x_sig.c libcrypto_la_SOURCES += asn1/x_spki.c libcrypto_la_SOURCES += asn1/x_val.c libcrypto_la_SOURCES += asn1/x_x509.c libcrypto_la_SOURCES += asn1/x_x509a.c noinst_HEADERS += asn1/asn1_locl.h noinst_HEADERS += asn1/charmap.h libcrypto_la_SOURCES += bf/bf_cfb64.c libcrypto_la_SOURCES += bf/bf_ecb.c libcrypto_la_SOURCES += bf/bf_enc.c libcrypto_la_SOURCES += bf/bf_ofb64.c libcrypto_la_SOURCES += bf/bf_skey.c noinst_HEADERS += bf/bf_locl.h noinst_HEADERS += bf/bf_pi.h libcrypto_la_SOURCES += bio/b_dump.c libcrypto_la_SOURCES += bio/b_print.c libcrypto_la_SOURCES += bio/b_sock.c libcrypto_la_SOURCES += bio/bf_buff.c libcrypto_la_SOURCES += bio/bf_nbio.c libcrypto_la_SOURCES += bio/bf_null.c libcrypto_la_SOURCES += bio/bio_cb.c libcrypto_la_SOURCES += bio/bio_err.c libcrypto_la_SOURCES += bio/bio_lib.c libcrypto_la_SOURCES += bio/bss_acpt.c libcrypto_la_SOURCES += bio/bss_bio.c libcrypto_la_SOURCES += bio/bss_conn.c libcrypto_la_SOURCES += bio/bss_dgram.c libcrypto_la_SOURCES += bio/bss_fd.c libcrypto_la_SOURCES += bio/bss_file.c libcrypto_la_SOURCES += bio/bss_log.c libcrypto_la_SOURCES += bio/bss_mem.c libcrypto_la_SOURCES += bio/bss_null.c libcrypto_la_SOURCES += bio/bss_sock.c libcrypto_la_SOURCES += bn/bn_add.c libcrypto_la_SOURCES += bn/bn_asm.c libcrypto_la_SOURCES += bn/bn_blind.c libcrypto_la_SOURCES += bn/bn_const.c libcrypto_la_SOURCES += bn/bn_ctx.c libcrypto_la_SOURCES += bn/bn_depr.c libcrypto_la_SOURCES += bn/bn_div.c libcrypto_la_SOURCES += bn/bn_err.c libcrypto_la_SOURCES += bn/bn_exp.c libcrypto_la_SOURCES += bn/bn_exp2.c libcrypto_la_SOURCES += bn/bn_gcd.c libcrypto_la_SOURCES += bn/bn_gf2m.c libcrypto_la_SOURCES += bn/bn_kron.c libcrypto_la_SOURCES += bn/bn_lib.c libcrypto_la_SOURCES += bn/bn_mod.c libcrypto_la_SOURCES += bn/bn_mont.c libcrypto_la_SOURCES += bn/bn_mpi.c libcrypto_la_SOURCES += bn/bn_mul.c libcrypto_la_SOURCES += bn/bn_nist.c libcrypto_la_SOURCES += bn/bn_prime.c libcrypto_la_SOURCES += bn/bn_print.c libcrypto_la_SOURCES += bn/bn_rand.c libcrypto_la_SOURCES += bn/bn_recp.c libcrypto_la_SOURCES += bn/bn_shift.c libcrypto_la_SOURCES += bn/bn_sqr.c libcrypto_la_SOURCES += bn/bn_sqrt.c libcrypto_la_SOURCES += bn/bn_word.c libcrypto_la_SOURCES += bn/bn_x931p.c noinst_HEADERS += bn/bn_lcl.h noinst_HEADERS += bn/bn_prime.h libcrypto_la_SOURCES += buffer/buf_err.c libcrypto_la_SOURCES += buffer/buf_str.c libcrypto_la_SOURCES += buffer/buffer.c libcrypto_la_SOURCES += cast/c_cfb64.c libcrypto_la_SOURCES += cast/c_ecb.c libcrypto_la_SOURCES += cast/c_enc.c libcrypto_la_SOURCES += cast/c_ofb64.c libcrypto_la_SOURCES += cast/c_skey.c noinst_HEADERS += cast/cast_lcl.h noinst_HEADERS += cast/cast_s.h libcrypto_la_SOURCES += chacha/chacha.c libcrypto_la_SOURCES += cmac/cm_ameth.c libcrypto_la_SOURCES += cmac/cm_pmeth.c libcrypto_la_SOURCES += cmac/cmac.c libcrypto_la_SOURCES += comp/c_rle.c libcrypto_la_SOURCES += comp/c_zlib.c libcrypto_la_SOURCES += comp/comp_err.c libcrypto_la_SOURCES += comp/comp_lib.c libcrypto_la_SOURCES += conf/conf_api.c libcrypto_la_SOURCES += conf/conf_def.c libcrypto_la_SOURCES += conf/conf_err.c libcrypto_la_SOURCES += conf/conf_lib.c libcrypto_la_SOURCES += conf/conf_mall.c libcrypto_la_SOURCES += conf/conf_mod.c libcrypto_la_SOURCES += conf/conf_sap.c noinst_HEADERS += conf/conf_def.h libcrypto_la_SOURCES += des/cbc_cksm.c libcrypto_la_SOURCES += des/cbc_enc.c libcrypto_la_SOURCES += des/cfb64ede.c libcrypto_la_SOURCES += des/cfb64enc.c libcrypto_la_SOURCES += des/cfb_enc.c libcrypto_la_SOURCES += des/des_enc.c libcrypto_la_SOURCES += des/ecb3_enc.c libcrypto_la_SOURCES += des/ecb_enc.c libcrypto_la_SOURCES += des/ede_cbcm_enc.c libcrypto_la_SOURCES += des/enc_read.c libcrypto_la_SOURCES += des/enc_writ.c libcrypto_la_SOURCES += des/fcrypt.c libcrypto_la_SOURCES += des/fcrypt_b.c libcrypto_la_SOURCES += des/ofb64ede.c libcrypto_la_SOURCES += des/ofb64enc.c libcrypto_la_SOURCES += des/ofb_enc.c libcrypto_la_SOURCES += des/pcbc_enc.c libcrypto_la_SOURCES += des/qud_cksm.c libcrypto_la_SOURCES += des/rand_key.c libcrypto_la_SOURCES += des/set_key.c libcrypto_la_SOURCES += des/str2key.c libcrypto_la_SOURCES += des/xcbc_enc.c noinst_HEADERS += des/des_locl.h noinst_HEADERS += des/spr.h libcrypto_la_SOURCES += dh/dh_ameth.c libcrypto_la_SOURCES += dh/dh_asn1.c libcrypto_la_SOURCES += dh/dh_check.c libcrypto_la_SOURCES += dh/dh_depr.c libcrypto_la_SOURCES += dh/dh_err.c libcrypto_la_SOURCES += dh/dh_gen.c libcrypto_la_SOURCES += dh/dh_key.c libcrypto_la_SOURCES += dh/dh_lib.c libcrypto_la_SOURCES += dh/dh_pmeth.c libcrypto_la_SOURCES += dh/dh_prn.c libcrypto_la_SOURCES += dsa/dsa_ameth.c libcrypto_la_SOURCES += dsa/dsa_asn1.c libcrypto_la_SOURCES += dsa/dsa_depr.c libcrypto_la_SOURCES += dsa/dsa_err.c libcrypto_la_SOURCES += dsa/dsa_gen.c libcrypto_la_SOURCES += dsa/dsa_key.c libcrypto_la_SOURCES += dsa/dsa_lib.c libcrypto_la_SOURCES += dsa/dsa_ossl.c libcrypto_la_SOURCES += dsa/dsa_pmeth.c libcrypto_la_SOURCES += dsa/dsa_prn.c libcrypto_la_SOURCES += dsa/dsa_sign.c libcrypto_la_SOURCES += dsa/dsa_vrf.c noinst_HEADERS += dsa/dsa_locl.h libcrypto_la_SOURCES += dso/dso_dlfcn.c libcrypto_la_SOURCES += dso/dso_err.c libcrypto_la_SOURCES += dso/dso_lib.c libcrypto_la_SOURCES += dso/dso_null.c libcrypto_la_SOURCES += dso/dso_openssl.c libcrypto_la_SOURCES += ec/ec2_mult.c libcrypto_la_SOURCES += ec/ec2_oct.c libcrypto_la_SOURCES += ec/ec2_smpl.c libcrypto_la_SOURCES += ec/ec_ameth.c libcrypto_la_SOURCES += ec/ec_asn1.c libcrypto_la_SOURCES += ec/ec_check.c libcrypto_la_SOURCES += ec/ec_curve.c libcrypto_la_SOURCES += ec/ec_cvt.c libcrypto_la_SOURCES += ec/ec_err.c libcrypto_la_SOURCES += ec/ec_key.c libcrypto_la_SOURCES += ec/ec_lib.c libcrypto_la_SOURCES += ec/ec_mult.c libcrypto_la_SOURCES += ec/ec_oct.c libcrypto_la_SOURCES += ec/ec_pmeth.c libcrypto_la_SOURCES += ec/ec_print.c libcrypto_la_SOURCES += ec/eck_prn.c libcrypto_la_SOURCES += ec/ecp_mont.c libcrypto_la_SOURCES += ec/ecp_nist.c libcrypto_la_SOURCES += ec/ecp_oct.c libcrypto_la_SOURCES += ec/ecp_smpl.c noinst_HEADERS += ec/ec_lcl.h libcrypto_la_SOURCES += ecdh/ech_err.c libcrypto_la_SOURCES += ecdh/ech_key.c libcrypto_la_SOURCES += ecdh/ech_lib.c libcrypto_la_SOURCES += ecdh/ech_ossl.c noinst_HEADERS += ecdh/ech_locl.h libcrypto_la_SOURCES += ecdsa/ecs_asn1.c libcrypto_la_SOURCES += ecdsa/ecs_err.c libcrypto_la_SOURCES += ecdsa/ecs_lib.c libcrypto_la_SOURCES += ecdsa/ecs_ossl.c libcrypto_la_SOURCES += ecdsa/ecs_sign.c libcrypto_la_SOURCES += ecdsa/ecs_vrf.c noinst_HEADERS += ecdsa/ecs_locl.h libcrypto_la_SOURCES += engine/eng_all.c libcrypto_la_SOURCES += engine/eng_cnf.c libcrypto_la_SOURCES += engine/eng_ctrl.c libcrypto_la_SOURCES += engine/eng_dyn.c libcrypto_la_SOURCES += engine/eng_err.c libcrypto_la_SOURCES += engine/eng_fat.c libcrypto_la_SOURCES += engine/eng_init.c libcrypto_la_SOURCES += engine/eng_lib.c libcrypto_la_SOURCES += engine/eng_list.c libcrypto_la_SOURCES += engine/eng_openssl.c libcrypto_la_SOURCES += engine/eng_pkey.c libcrypto_la_SOURCES += engine/eng_rsax.c libcrypto_la_SOURCES += engine/eng_table.c libcrypto_la_SOURCES += engine/tb_asnmth.c libcrypto_la_SOURCES += engine/tb_cipher.c libcrypto_la_SOURCES += engine/tb_dh.c libcrypto_la_SOURCES += engine/tb_digest.c libcrypto_la_SOURCES += engine/tb_dsa.c libcrypto_la_SOURCES += engine/tb_ecdh.c libcrypto_la_SOURCES += engine/tb_ecdsa.c libcrypto_la_SOURCES += engine/tb_pkmeth.c libcrypto_la_SOURCES += engine/tb_rand.c libcrypto_la_SOURCES += engine/tb_rsa.c libcrypto_la_SOURCES += engine/tb_store.c noinst_HEADERS += engine/eng_int.h libcrypto_la_SOURCES += err/err.c libcrypto_la_SOURCES += err/err_all.c libcrypto_la_SOURCES += err/err_prn.c libcrypto_la_SOURCES += evp/bio_b64.c libcrypto_la_SOURCES += evp/bio_enc.c libcrypto_la_SOURCES += evp/bio_md.c libcrypto_la_SOURCES += evp/c_all.c libcrypto_la_SOURCES += evp/c_allc.c libcrypto_la_SOURCES += evp/c_alld.c libcrypto_la_SOURCES += evp/digest.c libcrypto_la_SOURCES += evp/e_aes.c libcrypto_la_SOURCES += evp/e_aes_cbc_hmac_sha1.c libcrypto_la_SOURCES += evp/e_bf.c libcrypto_la_SOURCES += evp/e_cast.c libcrypto_la_SOURCES += evp/e_chacha.c libcrypto_la_SOURCES += evp/e_chacha20poly1305.c libcrypto_la_SOURCES += evp/e_des.c libcrypto_la_SOURCES += evp/e_des3.c libcrypto_la_SOURCES += evp/e_idea.c libcrypto_la_SOURCES += evp/e_null.c libcrypto_la_SOURCES += evp/e_old.c libcrypto_la_SOURCES += evp/e_rc2.c libcrypto_la_SOURCES += evp/e_rc4.c libcrypto_la_SOURCES += evp/e_rc4_hmac_md5.c libcrypto_la_SOURCES += evp/e_xcbc_d.c libcrypto_la_SOURCES += evp/encode.c libcrypto_la_SOURCES += evp/evp_aead.c libcrypto_la_SOURCES += evp/evp_enc.c libcrypto_la_SOURCES += evp/evp_err.c libcrypto_la_SOURCES += evp/evp_key.c libcrypto_la_SOURCES += evp/evp_lib.c libcrypto_la_SOURCES += evp/evp_pbe.c libcrypto_la_SOURCES += evp/evp_pkey.c libcrypto_la_SOURCES += evp/m_dss.c libcrypto_la_SOURCES += evp/m_dss1.c libcrypto_la_SOURCES += evp/m_ecdsa.c libcrypto_la_SOURCES += evp/m_md4.c libcrypto_la_SOURCES += evp/m_md5.c libcrypto_la_SOURCES += evp/m_mdc2.c libcrypto_la_SOURCES += evp/m_null.c libcrypto_la_SOURCES += evp/m_ripemd.c libcrypto_la_SOURCES += evp/m_sha.c libcrypto_la_SOURCES += evp/m_sha1.c libcrypto_la_SOURCES += evp/m_sigver.c libcrypto_la_SOURCES += evp/m_wp.c libcrypto_la_SOURCES += evp/names.c libcrypto_la_SOURCES += evp/p5_crpt.c libcrypto_la_SOURCES += evp/p5_crpt2.c libcrypto_la_SOURCES += evp/p_dec.c libcrypto_la_SOURCES += evp/p_enc.c libcrypto_la_SOURCES += evp/p_lib.c libcrypto_la_SOURCES += evp/p_open.c libcrypto_la_SOURCES += evp/p_seal.c libcrypto_la_SOURCES += evp/p_sign.c libcrypto_la_SOURCES += evp/p_verify.c libcrypto_la_SOURCES += evp/pmeth_fn.c libcrypto_la_SOURCES += evp/pmeth_gn.c libcrypto_la_SOURCES += evp/pmeth_lib.c noinst_HEADERS += evp/evp_locl.h libcrypto_la_SOURCES += hmac/hm_ameth.c libcrypto_la_SOURCES += hmac/hm_pmeth.c libcrypto_la_SOURCES += hmac/hmac.c libcrypto_la_SOURCES += idea/i_cbc.c libcrypto_la_SOURCES += idea/i_cfb64.c libcrypto_la_SOURCES += idea/i_ecb.c libcrypto_la_SOURCES += idea/i_ofb64.c libcrypto_la_SOURCES += idea/i_skey.c noinst_HEADERS += idea/idea_lcl.h libcrypto_la_SOURCES += krb5/krb5_asn.c libcrypto_la_SOURCES += lhash/lh_stats.c libcrypto_la_SOURCES += lhash/lhash.c libcrypto_la_SOURCES += md4/md4_dgst.c libcrypto_la_SOURCES += md4/md4_one.c noinst_HEADERS += md4/md4_locl.h libcrypto_la_SOURCES += md5/md5_dgst.c libcrypto_la_SOURCES += md5/md5_one.c noinst_HEADERS += md5/md5_locl.h libcrypto_la_SOURCES += mdc2/mdc2_one.c libcrypto_la_SOURCES += mdc2/mdc2dgst.c libcrypto_la_SOURCES += modes/cbc128.c libcrypto_la_SOURCES += modes/ccm128.c libcrypto_la_SOURCES += modes/cfb128.c libcrypto_la_SOURCES += modes/ctr128.c libcrypto_la_SOURCES += modes/cts128.c libcrypto_la_SOURCES += modes/gcm128.c libcrypto_la_SOURCES += modes/ofb128.c libcrypto_la_SOURCES += modes/xts128.c noinst_HEADERS += modes/modes_lcl.h libcrypto_la_SOURCES += objects/o_names.c libcrypto_la_SOURCES += objects/obj_dat.c libcrypto_la_SOURCES += objects/obj_err.c libcrypto_la_SOURCES += objects/obj_lib.c libcrypto_la_SOURCES += objects/obj_xref.c noinst_HEADERS += objects/obj_dat.h noinst_HEADERS += objects/obj_xref.h libcrypto_la_SOURCES += ocsp/ocsp_asn.c libcrypto_la_SOURCES += ocsp/ocsp_cl.c libcrypto_la_SOURCES += ocsp/ocsp_err.c libcrypto_la_SOURCES += ocsp/ocsp_ext.c libcrypto_la_SOURCES += ocsp/ocsp_ht.c libcrypto_la_SOURCES += ocsp/ocsp_lib.c libcrypto_la_SOURCES += ocsp/ocsp_prn.c libcrypto_la_SOURCES += ocsp/ocsp_srv.c libcrypto_la_SOURCES += ocsp/ocsp_vfy.c libcrypto_la_SOURCES += pem/pem_all.c libcrypto_la_SOURCES += pem/pem_err.c libcrypto_la_SOURCES += pem/pem_info.c libcrypto_la_SOURCES += pem/pem_lib.c libcrypto_la_SOURCES += pem/pem_oth.c libcrypto_la_SOURCES += pem/pem_pk8.c libcrypto_la_SOURCES += pem/pem_pkey.c libcrypto_la_SOURCES += pem/pem_seal.c libcrypto_la_SOURCES += pem/pem_sign.c libcrypto_la_SOURCES += pem/pem_x509.c libcrypto_la_SOURCES += pem/pem_xaux.c libcrypto_la_SOURCES += pem/pvkfmt.c libcrypto_la_SOURCES += pkcs12/p12_add.c libcrypto_la_SOURCES += pkcs12/p12_asn.c libcrypto_la_SOURCES += pkcs12/p12_attr.c libcrypto_la_SOURCES += pkcs12/p12_crpt.c libcrypto_la_SOURCES += pkcs12/p12_crt.c libcrypto_la_SOURCES += pkcs12/p12_decr.c libcrypto_la_SOURCES += pkcs12/p12_init.c libcrypto_la_SOURCES += pkcs12/p12_key.c libcrypto_la_SOURCES += pkcs12/p12_kiss.c libcrypto_la_SOURCES += pkcs12/p12_mutl.c libcrypto_la_SOURCES += pkcs12/p12_npas.c libcrypto_la_SOURCES += pkcs12/p12_p8d.c libcrypto_la_SOURCES += pkcs12/p12_p8e.c libcrypto_la_SOURCES += pkcs12/p12_utl.c libcrypto_la_SOURCES += pkcs12/pk12err.c libcrypto_la_SOURCES += pkcs7/bio_pk7.c libcrypto_la_SOURCES += pkcs7/pk7_asn1.c libcrypto_la_SOURCES += pkcs7/pk7_attr.c libcrypto_la_SOURCES += pkcs7/pk7_doit.c libcrypto_la_SOURCES += pkcs7/pk7_lib.c libcrypto_la_SOURCES += pkcs7/pk7_mime.c libcrypto_la_SOURCES += pkcs7/pk7_smime.c libcrypto_la_SOURCES += pkcs7/pkcs7err.c libcrypto_la_SOURCES += poly1305/poly1305.c libcrypto_la_SOURCES += rand/rand_err.c libcrypto_la_SOURCES += rand/rand_lib.c libcrypto_la_SOURCES += rand/randfile.c libcrypto_la_SOURCES += rc2/rc2_cbc.c libcrypto_la_SOURCES += rc2/rc2_ecb.c libcrypto_la_SOURCES += rc2/rc2_skey.c libcrypto_la_SOURCES += rc2/rc2cfb64.c libcrypto_la_SOURCES += rc2/rc2ofb64.c noinst_HEADERS += rc2/rc2_locl.h libcrypto_la_SOURCES += rc4/rc4_enc.c libcrypto_la_SOURCES += rc4/rc4_skey.c libcrypto_la_SOURCES += rc4/rc4_utl.c noinst_HEADERS += rc4/rc4_locl.h libcrypto_la_SOURCES += ripemd/rmd_dgst.c libcrypto_la_SOURCES += ripemd/rmd_one.c noinst_HEADERS += ripemd/rmd_locl.h noinst_HEADERS += ripemd/rmdconst.h libcrypto_la_SOURCES += rsa/rsa_ameth.c libcrypto_la_SOURCES += rsa/rsa_asn1.c libcrypto_la_SOURCES += rsa/rsa_chk.c libcrypto_la_SOURCES += rsa/rsa_crpt.c libcrypto_la_SOURCES += rsa/rsa_depr.c libcrypto_la_SOURCES += rsa/rsa_eay.c libcrypto_la_SOURCES += rsa/rsa_err.c libcrypto_la_SOURCES += rsa/rsa_gen.c libcrypto_la_SOURCES += rsa/rsa_lib.c libcrypto_la_SOURCES += rsa/rsa_none.c libcrypto_la_SOURCES += rsa/rsa_oaep.c libcrypto_la_SOURCES += rsa/rsa_pk1.c libcrypto_la_SOURCES += rsa/rsa_pmeth.c libcrypto_la_SOURCES += rsa/rsa_prn.c libcrypto_la_SOURCES += rsa/rsa_pss.c libcrypto_la_SOURCES += rsa/rsa_saos.c libcrypto_la_SOURCES += rsa/rsa_sign.c libcrypto_la_SOURCES += rsa/rsa_ssl.c libcrypto_la_SOURCES += rsa/rsa_x931.c noinst_HEADERS += rsa/rsa_locl.h libcrypto_la_SOURCES += sha/sha1_one.c libcrypto_la_SOURCES += sha/sha1dgst.c libcrypto_la_SOURCES += sha/sha256.c libcrypto_la_SOURCES += sha/sha512.c libcrypto_la_SOURCES += sha/sha_dgst.c libcrypto_la_SOURCES += sha/sha_one.c noinst_HEADERS += sha/sha_locl.h libcrypto_la_SOURCES += stack/stack.c libcrypto_la_SOURCES += ts/ts_asn1.c libcrypto_la_SOURCES += ts/ts_conf.c libcrypto_la_SOURCES += ts/ts_err.c libcrypto_la_SOURCES += ts/ts_lib.c libcrypto_la_SOURCES += ts/ts_req_print.c libcrypto_la_SOURCES += ts/ts_req_utils.c libcrypto_la_SOURCES += ts/ts_rsp_print.c libcrypto_la_SOURCES += ts/ts_rsp_sign.c libcrypto_la_SOURCES += ts/ts_rsp_utils.c libcrypto_la_SOURCES += ts/ts_rsp_verify.c libcrypto_la_SOURCES += ts/ts_verify_ctx.c libcrypto_la_SOURCES += txt_db/txt_db.c libcrypto_la_SOURCES += ui/ui_err.c libcrypto_la_SOURCES += ui/ui_lib.c libcrypto_la_SOURCES += ui/ui_openssl.c libcrypto_la_SOURCES += ui/ui_util.c noinst_HEADERS += ui/ui_locl.h libcrypto_la_SOURCES += whrlpool/wp_block.c libcrypto_la_SOURCES += whrlpool/wp_dgst.c noinst_HEADERS += whrlpool/wp_locl.h libcrypto_la_SOURCES += x509/by_dir.c libcrypto_la_SOURCES += x509/by_file.c libcrypto_la_SOURCES += x509/x509_att.c libcrypto_la_SOURCES += x509/x509_cmp.c libcrypto_la_SOURCES += x509/x509_d2.c libcrypto_la_SOURCES += x509/x509_def.c libcrypto_la_SOURCES += x509/x509_err.c libcrypto_la_SOURCES += x509/x509_ext.c libcrypto_la_SOURCES += x509/x509_lu.c libcrypto_la_SOURCES += x509/x509_obj.c libcrypto_la_SOURCES += x509/x509_r2x.c libcrypto_la_SOURCES += x509/x509_req.c libcrypto_la_SOURCES += x509/x509_set.c libcrypto_la_SOURCES += x509/x509_trs.c libcrypto_la_SOURCES += x509/x509_txt.c libcrypto_la_SOURCES += x509/x509_v3.c libcrypto_la_SOURCES += x509/x509_vfy.c libcrypto_la_SOURCES += x509/x509_vpm.c libcrypto_la_SOURCES += x509/x509cset.c libcrypto_la_SOURCES += x509/x509name.c libcrypto_la_SOURCES += x509/x509rset.c libcrypto_la_SOURCES += x509/x509spki.c libcrypto_la_SOURCES += x509/x509type.c libcrypto_la_SOURCES += x509/x_all.c noinst_HEADERS += x509/x509_lcl.h libcrypto_la_SOURCES += x509v3/pcy_cache.c libcrypto_la_SOURCES += x509v3/pcy_data.c libcrypto_la_SOURCES += x509v3/pcy_lib.c libcrypto_la_SOURCES += x509v3/pcy_map.c libcrypto_la_SOURCES += x509v3/pcy_node.c libcrypto_la_SOURCES += x509v3/pcy_tree.c libcrypto_la_SOURCES += x509v3/v3_akey.c libcrypto_la_SOURCES += x509v3/v3_akeya.c libcrypto_la_SOURCES += x509v3/v3_alt.c libcrypto_la_SOURCES += x509v3/v3_bcons.c libcrypto_la_SOURCES += x509v3/v3_bitst.c libcrypto_la_SOURCES += x509v3/v3_conf.c libcrypto_la_SOURCES += x509v3/v3_cpols.c libcrypto_la_SOURCES += x509v3/v3_crld.c libcrypto_la_SOURCES += x509v3/v3_enum.c libcrypto_la_SOURCES += x509v3/v3_extku.c libcrypto_la_SOURCES += x509v3/v3_genn.c libcrypto_la_SOURCES += x509v3/v3_ia5.c libcrypto_la_SOURCES += x509v3/v3_info.c libcrypto_la_SOURCES += x509v3/v3_int.c libcrypto_la_SOURCES += x509v3/v3_lib.c libcrypto_la_SOURCES += x509v3/v3_ncons.c libcrypto_la_SOURCES += x509v3/v3_ocsp.c libcrypto_la_SOURCES += x509v3/v3_pci.c libcrypto_la_SOURCES += x509v3/v3_pcia.c libcrypto_la_SOURCES += x509v3/v3_pcons.c libcrypto_la_SOURCES += x509v3/v3_pku.c libcrypto_la_SOURCES += x509v3/v3_pmaps.c libcrypto_la_SOURCES += x509v3/v3_prn.c libcrypto_la_SOURCES += x509v3/v3_purp.c libcrypto_la_SOURCES += x509v3/v3_skey.c libcrypto_la_SOURCES += x509v3/v3_sxnet.c libcrypto_la_SOURCES += x509v3/v3_utl.c libcrypto_la_SOURCES += x509v3/v3err.c noinst_HEADERS += x509v3/ext_dat.h noinst_HEADERS += x509v3/pcy_int.h EXTRA_libcrypto_la_SOURCES += des/ncbc_enc.c EXTRA_libcrypto_la_SOURCES += chacha/chacha-merged.c EXTRA_libcrypto_la_SOURCES += poly1305/poly1305-donna.c deps/libressl-pnacl-sys-2.1.6/libressl/crypto/o_str.c0000644000175000017500000000157112430034550017552 0ustar /* $OpenBSD: o_str.c,v 1.8 2014/06/12 15:49:27 deraadt Exp $ */ /* * Written by Theo de Raadt. Public domain. */ #include int OPENSSL_strcasecmp(const char *str1, const char *str2); int OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n); int OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n) { #if !defined(__pnacl__) return strncasecmp(str1, str2, n); #else size_t i = 0; for(; str1[i] == str2[i] && str1[i] != '\0' && str2[i] != '\0' && i < n; ++i) { } return (int)(str1[i] - str2[i]); #endif } int OPENSSL_strcasecmp(const char *str1, const char *str2) { #if !defined(__pnacl__) return strcasecmp(str1, str2); #else size_t i = 0; for(; str1[i] == str2[i] && str1[i] != '\0' && str2[i] != '\0'; ++i) { } return (int)(str1[i] - str2[i]); #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rand/0000755000000000000000000000000012666635521020776 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/rand/randfile.c0000644000175000017500000001147112430034550021134 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #include #include #include #undef BUFSIZE #define BUFSIZE 1024 #define RAND_DATA 1024 /* Note that these functions should not be used. */ int RAND_load_file(const char *file, long bytes) { /* the "whole" file */ if (bytes == -1) return 123456; else return bytes; } int RAND_write_file(const char *file) { unsigned char buf[BUFSIZE]; int i, ret = 0, rand_err = 0; FILE *out = NULL; int n; struct stat sb; i = stat(file, &sb); if (i != -1) { if (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode)) { /* this file is a device. we don't write back to it. * we "succeed" on the assumption this is some sort * of random device. Otherwise attempting to write to * and chmod the device causes problems. */ return (1); } } { /* chmod(..., 0600) is too late to protect the file, * permissions should be restrictive from the start */ int fd = open(file, O_WRONLY|O_CREAT, 0600); if (fd != -1) out = fdopen(fd, "wb"); } if (out == NULL) out = fopen(file, "wb"); if (out == NULL) goto err; chmod(file, 0600); n = RAND_DATA; for (;;) { i = (n > BUFSIZE) ? BUFSIZE : n; n -= BUFSIZE; if (RAND_bytes(buf, i) <= 0) rand_err = 1; i = fwrite(buf, 1, i, out); if (i <= 0) { ret = 0; break; } ret += i; if (n <= 0) break; } fclose(out); OPENSSL_cleanse(buf, BUFSIZE); err: return (rand_err ? -1 : ret); } const char * RAND_file_name(char *buf, size_t size) { if (strlcpy(buf, "/dev/urandom", size) >= size) return (NULL); return buf; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rand/rand_lib.c0000644000175000017500000000332512360020706021121 0ustar /* $OpenBSD: rand_lib.c,v 1.18 2014/07/10 22:45:57 jsing Exp $ */ /* * Copyright (c) 2014 Ted Unangst * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include /* * The useful functions in this file are at the bottom. */ int RAND_set_rand_method(const RAND_METHOD *meth) { return 1; } const RAND_METHOD * RAND_get_rand_method(void) { return NULL; } RAND_METHOD * RAND_SSLeay(void) { return NULL; } #ifndef OPENSSL_NO_ENGINE int RAND_set_rand_engine(ENGINE *engine) { return 1; } #endif void RAND_cleanup(void) { } void RAND_seed(const void *buf, int num) { } void RAND_add(const void *buf, int num, double entropy) { } int RAND_status(void) { return 1; } int RAND_poll(void) { return 1; } /* * Hurray. You've made it to the good parts. */ int RAND_bytes(unsigned char *buf, int num) { if (num > 0) arc4random_buf(buf, num); return 1; } int RAND_pseudo_bytes(unsigned char *buf, int num) { if (num > 0) arc4random_buf(buf, num); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rand/rand_err.c0000644000175000017500000000772212360020706021150 0ustar /* $OpenBSD: rand_err.c,v 1.13 2014/06/12 15:49:30 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_RAND,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_RAND,0,reason) static ERR_STRING_DATA RAND_str_functs[] = { {ERR_FUNC(RAND_F_RAND_GET_RAND_METHOD), "RAND_get_rand_method"}, {ERR_FUNC(RAND_F_RAND_INIT_FIPS), "RAND_init_fips"}, {ERR_FUNC(RAND_F_SSLEAY_RAND_BYTES), "SSLEAY_RAND_BYTES"}, {0, NULL} }; static ERR_STRING_DATA RAND_str_reasons[] = { {ERR_REASON(RAND_R_DUAL_EC_DRBG_DISABLED), "dual ec drbg disabled"}, {ERR_REASON(RAND_R_ERROR_INITIALISING_DRBG), "error initialising drbg"}, {ERR_REASON(RAND_R_ERROR_INSTANTIATING_DRBG), "error instantiating drbg"}, {ERR_REASON(RAND_R_NO_FIPS_RANDOM_METHOD_SET), "no fips random method set"}, {ERR_REASON(RAND_R_PRNG_NOT_SEEDED) , "PRNG not seeded"}, {0, NULL} }; #endif void ERR_load_RAND_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(RAND_str_functs[0].error) == NULL) { ERR_load_strings(0, RAND_str_functs); ERR_load_strings(0, RAND_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ts/0000755000000000000000000000000012666635521020500 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/ts/ts_rsp_utils.c0000644000175000017500000002343312360020706021605 0ustar /* $OpenBSD: ts_rsp_utils.c,v 1.3 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include /* Function definitions. */ int TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *status_info) { TS_STATUS_INFO *new_status_info; if (a->status_info == status_info) return 1; new_status_info = TS_STATUS_INFO_dup(status_info); if (new_status_info == NULL) { TSerr(TS_F_TS_RESP_SET_STATUS_INFO, ERR_R_MALLOC_FAILURE); return 0; } TS_STATUS_INFO_free(a->status_info); a->status_info = new_status_info; return 1; } TS_STATUS_INFO * TS_RESP_get_status_info(TS_RESP *a) { return a->status_info; } /* Caller loses ownership of PKCS7 and TS_TST_INFO objects. */ void TS_RESP_set_tst_info(TS_RESP *a, PKCS7 *p7, TS_TST_INFO *tst_info) { /* Set new PKCS7 and TST_INFO objects. */ PKCS7_free(a->token); a->token = p7; TS_TST_INFO_free(a->tst_info); a->tst_info = tst_info; } PKCS7 * TS_RESP_get_token(TS_RESP *a) { return a->token; } TS_TST_INFO * TS_RESP_get_tst_info(TS_RESP *a) { return a->tst_info; } int TS_TST_INFO_set_version(TS_TST_INFO *a, long version) { return ASN1_INTEGER_set(a->version, version); } long TS_TST_INFO_get_version(const TS_TST_INFO *a) { return ASN1_INTEGER_get(a->version); } int TS_TST_INFO_set_policy_id(TS_TST_INFO *a, ASN1_OBJECT *policy) { ASN1_OBJECT *new_policy; if (a->policy_id == policy) return 1; new_policy = OBJ_dup(policy); if (new_policy == NULL) { TSerr(TS_F_TS_TST_INFO_SET_POLICY_ID, ERR_R_MALLOC_FAILURE); return 0; } ASN1_OBJECT_free(a->policy_id); a->policy_id = new_policy; return 1; } ASN1_OBJECT * TS_TST_INFO_get_policy_id(TS_TST_INFO *a) { return a->policy_id; } int TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint) { TS_MSG_IMPRINT *new_msg_imprint; if (a->msg_imprint == msg_imprint) return 1; new_msg_imprint = TS_MSG_IMPRINT_dup(msg_imprint); if (new_msg_imprint == NULL) { TSerr(TS_F_TS_TST_INFO_SET_MSG_IMPRINT, ERR_R_MALLOC_FAILURE); return 0; } TS_MSG_IMPRINT_free(a->msg_imprint); a->msg_imprint = new_msg_imprint; return 1; } TS_MSG_IMPRINT * TS_TST_INFO_get_msg_imprint(TS_TST_INFO *a) { return a->msg_imprint; } int TS_TST_INFO_set_serial(TS_TST_INFO *a, const ASN1_INTEGER *serial) { ASN1_INTEGER *new_serial; if (a->serial == serial) return 1; new_serial = ASN1_INTEGER_dup(serial); if (new_serial == NULL) { TSerr(TS_F_TS_TST_INFO_SET_SERIAL, ERR_R_MALLOC_FAILURE); return 0; } ASN1_INTEGER_free(a->serial); a->serial = new_serial; return 1; } const ASN1_INTEGER * TS_TST_INFO_get_serial(const TS_TST_INFO *a) { return a->serial; } int TS_TST_INFO_set_time(TS_TST_INFO *a, const ASN1_GENERALIZEDTIME *gtime) { ASN1_GENERALIZEDTIME *new_time; if (a->time == gtime) return 1; new_time = M_ASN1_GENERALIZEDTIME_dup(gtime); if (new_time == NULL) { TSerr(TS_F_TS_TST_INFO_SET_TIME, ERR_R_MALLOC_FAILURE); return 0; } ASN1_GENERALIZEDTIME_free(a->time); a->time = new_time; return 1; } const ASN1_GENERALIZEDTIME * TS_TST_INFO_get_time(const TS_TST_INFO *a) { return a->time; } int TS_TST_INFO_set_accuracy(TS_TST_INFO *a, TS_ACCURACY *accuracy) { TS_ACCURACY *new_accuracy; if (a->accuracy == accuracy) return 1; new_accuracy = TS_ACCURACY_dup(accuracy); if (new_accuracy == NULL) { TSerr(TS_F_TS_TST_INFO_SET_ACCURACY, ERR_R_MALLOC_FAILURE); return 0; } TS_ACCURACY_free(a->accuracy); a->accuracy = new_accuracy; return 1; } TS_ACCURACY * TS_TST_INFO_get_accuracy(TS_TST_INFO *a) { return a->accuracy; } int TS_ACCURACY_set_seconds(TS_ACCURACY *a, const ASN1_INTEGER *seconds) { ASN1_INTEGER *new_seconds; if (a->seconds == seconds) return 1; new_seconds = ASN1_INTEGER_dup(seconds); if (new_seconds == NULL) { TSerr(TS_F_TS_ACCURACY_SET_SECONDS, ERR_R_MALLOC_FAILURE); return 0; } ASN1_INTEGER_free(a->seconds); a->seconds = new_seconds; return 1; } const ASN1_INTEGER * TS_ACCURACY_get_seconds(const TS_ACCURACY *a) { return a->seconds; } int TS_ACCURACY_set_millis(TS_ACCURACY *a, const ASN1_INTEGER *millis) { ASN1_INTEGER *new_millis = NULL; if (a->millis == millis) return 1; if (millis != NULL) { new_millis = ASN1_INTEGER_dup(millis); if (new_millis == NULL) { TSerr(TS_F_TS_ACCURACY_SET_MILLIS, ERR_R_MALLOC_FAILURE); return 0; } } ASN1_INTEGER_free(a->millis); a->millis = new_millis; return 1; } const ASN1_INTEGER * TS_ACCURACY_get_millis(const TS_ACCURACY *a) { return a->millis; } int TS_ACCURACY_set_micros(TS_ACCURACY *a, const ASN1_INTEGER *micros) { ASN1_INTEGER *new_micros = NULL; if (a->micros == micros) return 1; if (micros != NULL) { new_micros = ASN1_INTEGER_dup(micros); if (new_micros == NULL) { TSerr(TS_F_TS_ACCURACY_SET_MICROS, ERR_R_MALLOC_FAILURE); return 0; } } ASN1_INTEGER_free(a->micros); a->micros = new_micros; return 1; } const ASN1_INTEGER * TS_ACCURACY_get_micros(const TS_ACCURACY *a) { return a->micros; } int TS_TST_INFO_set_ordering(TS_TST_INFO *a, int ordering) { a->ordering = ordering ? 0xFF : 0x00; return 1; } int TS_TST_INFO_get_ordering(const TS_TST_INFO *a) { return a->ordering ? 1 : 0; } int TS_TST_INFO_set_nonce(TS_TST_INFO *a, const ASN1_INTEGER *nonce) { ASN1_INTEGER *new_nonce; if (a->nonce == nonce) return 1; new_nonce = ASN1_INTEGER_dup(nonce); if (new_nonce == NULL) { TSerr(TS_F_TS_TST_INFO_SET_NONCE, ERR_R_MALLOC_FAILURE); return 0; } ASN1_INTEGER_free(a->nonce); a->nonce = new_nonce; return 1; } const ASN1_INTEGER * TS_TST_INFO_get_nonce(const TS_TST_INFO *a) { return a->nonce; } int TS_TST_INFO_set_tsa(TS_TST_INFO *a, GENERAL_NAME *tsa) { GENERAL_NAME *new_tsa; if (a->tsa == tsa) return 1; new_tsa = GENERAL_NAME_dup(tsa); if (new_tsa == NULL) { TSerr(TS_F_TS_TST_INFO_SET_TSA, ERR_R_MALLOC_FAILURE); return 0; } GENERAL_NAME_free(a->tsa); a->tsa = new_tsa; return 1; } GENERAL_NAME * TS_TST_INFO_get_tsa(TS_TST_INFO *a) { return a->tsa; } STACK_OF(X509_EXTENSION) *TS_TST_INFO_get_exts(TS_TST_INFO *a) { return a->extensions; } void TS_TST_INFO_ext_free(TS_TST_INFO *a) { if (!a) return; sk_X509_EXTENSION_pop_free(a->extensions, X509_EXTENSION_free); a->extensions = NULL; } int TS_TST_INFO_get_ext_count(TS_TST_INFO *a) { return X509v3_get_ext_count(a->extensions); } int TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos) { return X509v3_get_ext_by_NID(a->extensions, nid, lastpos); } int TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, ASN1_OBJECT *obj, int lastpos) { return X509v3_get_ext_by_OBJ(a->extensions, obj, lastpos); } int TS_TST_INFO_get_ext_by_critical(TS_TST_INFO *a, int crit, int lastpos) { return X509v3_get_ext_by_critical(a->extensions, crit, lastpos); } X509_EXTENSION * TS_TST_INFO_get_ext(TS_TST_INFO *a, int loc) { return X509v3_get_ext(a->extensions, loc); } X509_EXTENSION * TS_TST_INFO_delete_ext(TS_TST_INFO *a, int loc) { return X509v3_delete_ext(a->extensions, loc); } int TS_TST_INFO_add_ext(TS_TST_INFO *a, X509_EXTENSION *ex, int loc) { return X509v3_add_ext(&a->extensions, ex, loc) != NULL; } void * TS_TST_INFO_get_ext_d2i(TS_TST_INFO *a, int nid, int *crit, int *idx) { return X509V3_get_d2i(a->extensions, nid, crit, idx); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ts/ts_rsp_print.c0000644000175000017500000002036612360020706021603 0ustar /* $OpenBSD: ts_rsp_print.c,v 1.4 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include struct status_map_st { int bit; const char *text; }; /* Local function declarations. */ static int TS_status_map_print(BIO *bio, struct status_map_st *a, ASN1_BIT_STRING *v); static int TS_ACCURACY_print_bio(BIO *bio, const TS_ACCURACY *accuracy); /* Function definitions. */ int TS_RESP_print_bio(BIO *bio, TS_RESP *a) { TS_TST_INFO *tst_info; BIO_printf(bio, "Status info:\n"); TS_STATUS_INFO_print_bio(bio, TS_RESP_get_status_info(a)); BIO_printf(bio, "\nTST info:\n"); tst_info = TS_RESP_get_tst_info(a); if (tst_info != NULL) TS_TST_INFO_print_bio(bio, TS_RESP_get_tst_info(a)); else BIO_printf(bio, "Not included.\n"); return 1; } int TS_STATUS_INFO_print_bio(BIO *bio, TS_STATUS_INFO *a) { static const char *status_map[] = { "Granted.", "Granted with modifications.", "Rejected.", "Waiting.", "Revocation warning.", "Revoked." }; static struct status_map_st failure_map[] = { { TS_INFO_BAD_ALG, "unrecognized or unsupported algorithm identifier" }, { TS_INFO_BAD_REQUEST, "transaction not permitted or supported" }, { TS_INFO_BAD_DATA_FORMAT, "the data submitted has the wrong format" }, { TS_INFO_TIME_NOT_AVAILABLE, "the TSA's time source is not available" }, { TS_INFO_UNACCEPTED_POLICY, "the requested TSA policy is not supported by the TSA" }, { TS_INFO_UNACCEPTED_EXTENSION, "the requested extension is not supported by the TSA" }, { TS_INFO_ADD_INFO_NOT_AVAILABLE, "the additional information requested could not be understood " "or is not available" }, { TS_INFO_SYSTEM_FAILURE, "the request cannot be handled due to system failure" }, { -1, NULL } }; long status; int i, lines = 0; /* Printing status code. */ BIO_printf(bio, "Status: "); status = ASN1_INTEGER_get(a->status); if (0 <= status && status < (long)(sizeof(status_map) / sizeof(status_map[0]))) BIO_printf(bio, "%s\n", status_map[status]); else BIO_printf(bio, "out of bounds\n"); /* Printing status description. */ BIO_printf(bio, "Status description: "); for (i = 0; i < sk_ASN1_UTF8STRING_num(a->text); ++i) { if (i > 0) BIO_puts(bio, "\t"); ASN1_STRING_print_ex(bio, sk_ASN1_UTF8STRING_value(a->text, i), 0); BIO_puts(bio, "\n"); } if (i == 0) BIO_printf(bio, "unspecified\n"); /* Printing failure information. */ BIO_printf(bio, "Failure info: "); if (a->failure_info != NULL) lines = TS_status_map_print(bio, failure_map, a->failure_info); if (lines == 0) BIO_printf(bio, "unspecified"); BIO_printf(bio, "\n"); return 1; } static int TS_status_map_print(BIO *bio, struct status_map_st *a, ASN1_BIT_STRING *v) { int lines = 0; for (; a->bit >= 0; ++a) { if (ASN1_BIT_STRING_get_bit(v, a->bit)) { if (++lines > 1) BIO_printf(bio, ", "); BIO_printf(bio, "%s", a->text); } } return lines; } int TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a) { int v; ASN1_OBJECT *policy_id; const ASN1_INTEGER *serial; const ASN1_GENERALIZEDTIME *gtime; TS_ACCURACY *accuracy; const ASN1_INTEGER *nonce; GENERAL_NAME *tsa_name; if (a == NULL) return 0; /* Print version. */ v = TS_TST_INFO_get_version(a); BIO_printf(bio, "Version: %d\n", v); /* Print policy id. */ BIO_printf(bio, "Policy OID: "); policy_id = TS_TST_INFO_get_policy_id(a); TS_OBJ_print_bio(bio, policy_id); /* Print message imprint. */ TS_MSG_IMPRINT_print_bio(bio, TS_TST_INFO_get_msg_imprint(a)); /* Print serial number. */ BIO_printf(bio, "Serial number: "); serial = TS_TST_INFO_get_serial(a); if (serial == NULL) BIO_printf(bio, "unspecified"); else TS_ASN1_INTEGER_print_bio(bio, serial); BIO_write(bio, "\n", 1); /* Print time stamp. */ BIO_printf(bio, "Time stamp: "); gtime = TS_TST_INFO_get_time(a); ASN1_GENERALIZEDTIME_print(bio, gtime); BIO_write(bio, "\n", 1); /* Print accuracy. */ BIO_printf(bio, "Accuracy: "); accuracy = TS_TST_INFO_get_accuracy(a); if (accuracy == NULL) BIO_printf(bio, "unspecified"); else TS_ACCURACY_print_bio(bio, accuracy); BIO_write(bio, "\n", 1); /* Print ordering. */ BIO_printf(bio, "Ordering: %s\n", TS_TST_INFO_get_ordering(a) ? "yes" : "no"); /* Print nonce. */ BIO_printf(bio, "Nonce: "); nonce = TS_TST_INFO_get_nonce(a); if (nonce == NULL) BIO_printf(bio, "unspecified"); else TS_ASN1_INTEGER_print_bio(bio, nonce); BIO_write(bio, "\n", 1); /* Print TSA name. */ BIO_printf(bio, "TSA: "); tsa_name = TS_TST_INFO_get_tsa(a); if (tsa_name == NULL) BIO_printf(bio, "unspecified"); else { STACK_OF(CONF_VALUE) *nval; if ((nval = i2v_GENERAL_NAME(NULL, tsa_name, NULL))) X509V3_EXT_val_prn(bio, nval, 0, 0); sk_CONF_VALUE_pop_free(nval, X509V3_conf_free); } BIO_write(bio, "\n", 1); /* Print extensions. */ TS_ext_print_bio(bio, TS_TST_INFO_get_exts(a)); return 1; } static int TS_ACCURACY_print_bio(BIO *bio, const TS_ACCURACY *accuracy) { const ASN1_INTEGER *seconds = TS_ACCURACY_get_seconds(accuracy); const ASN1_INTEGER *millis = TS_ACCURACY_get_millis(accuracy); const ASN1_INTEGER *micros = TS_ACCURACY_get_micros(accuracy); if (seconds != NULL) TS_ASN1_INTEGER_print_bio(bio, seconds); else BIO_printf(bio, "unspecified"); BIO_printf(bio, " seconds, "); if (millis != NULL) TS_ASN1_INTEGER_print_bio(bio, millis); else BIO_printf(bio, "unspecified"); BIO_printf(bio, " millis, "); if (micros != NULL) TS_ASN1_INTEGER_print_bio(bio, micros); else BIO_printf(bio, "unspecified"); BIO_printf(bio, " micros"); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ts/ts_rsp_sign.c0000644000175000017500000006670612360020706021417 0ustar /* $OpenBSD: ts_rsp_sign.c,v 1.16 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include /* Private function declarations. */ static ASN1_INTEGER *def_serial_cb(struct TS_resp_ctx *, void *); static int def_time_cb(struct TS_resp_ctx *, void *, time_t *sec, long *usec); static int def_extension_cb(struct TS_resp_ctx *, X509_EXTENSION *, void *); static void TS_RESP_CTX_init(TS_RESP_CTX *ctx); static void TS_RESP_CTX_cleanup(TS_RESP_CTX *ctx); static int TS_RESP_check_request(TS_RESP_CTX *ctx); static ASN1_OBJECT *TS_RESP_get_policy(TS_RESP_CTX *ctx); static TS_TST_INFO *TS_RESP_create_tst_info(TS_RESP_CTX *ctx, ASN1_OBJECT *policy); static int TS_RESP_process_extensions(TS_RESP_CTX *ctx); static int TS_RESP_sign(TS_RESP_CTX *ctx); static ESS_SIGNING_CERT *ESS_SIGNING_CERT_new_init(X509 *signcert, STACK_OF(X509) *certs); static ESS_CERT_ID *ESS_CERT_ID_new_init(X509 *cert, int issuer_needed); static int TS_TST_INFO_content_new(PKCS7 *p7); static int ESS_add_signing_cert(PKCS7_SIGNER_INFO *si, ESS_SIGNING_CERT *sc); static ASN1_GENERALIZEDTIME *TS_RESP_set_genTime_with_precision( ASN1_GENERALIZEDTIME *, time_t, long, unsigned); /* Default callbacks for response generation. */ static ASN1_INTEGER * def_serial_cb(struct TS_resp_ctx *ctx, void *data) { ASN1_INTEGER *serial = ASN1_INTEGER_new(); if (!serial) goto err; if (!ASN1_INTEGER_set(serial, 1)) goto err; return serial; err: TSerr(TS_F_DEF_SERIAL_CB, ERR_R_MALLOC_FAILURE); TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION, "Error during serial number generation."); return NULL; } /* Use the gettimeofday function call. */ static int def_time_cb(struct TS_resp_ctx *ctx, void *data, time_t *sec, long *usec) { struct timeval tv; if (gettimeofday(&tv, NULL) != 0) { TSerr(TS_F_DEF_TIME_CB, TS_R_TIME_SYSCALL_ERROR); TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION, "Time is not available."); TS_RESP_CTX_add_failure_info(ctx, TS_INFO_TIME_NOT_AVAILABLE); return 0; } /* Return time to caller. */ *sec = tv.tv_sec; *usec = tv.tv_usec; return 1; } static int def_extension_cb(struct TS_resp_ctx *ctx, X509_EXTENSION *ext, void *data) { /* No extensions are processed here. */ TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION, "Unsupported extension."); TS_RESP_CTX_add_failure_info(ctx, TS_INFO_UNACCEPTED_EXTENSION); return 0; } /* TS_RESP_CTX management functions. */ TS_RESP_CTX * TS_RESP_CTX_new(void) { TS_RESP_CTX *ctx; if (!(ctx = calloc(1, sizeof(TS_RESP_CTX)))) { TSerr(TS_F_TS_RESP_CTX_NEW, ERR_R_MALLOC_FAILURE); return NULL; } /* Setting default callbacks. */ ctx->serial_cb = def_serial_cb; ctx->time_cb = def_time_cb; ctx->extension_cb = def_extension_cb; return ctx; } void TS_RESP_CTX_free(TS_RESP_CTX *ctx) { if (!ctx) return; X509_free(ctx->signer_cert); EVP_PKEY_free(ctx->signer_key); sk_X509_pop_free(ctx->certs, X509_free); sk_ASN1_OBJECT_pop_free(ctx->policies, ASN1_OBJECT_free); ASN1_OBJECT_free(ctx->default_policy); sk_EVP_MD_free(ctx->mds); /* No EVP_MD_free method exists. */ ASN1_INTEGER_free(ctx->seconds); ASN1_INTEGER_free(ctx->millis); ASN1_INTEGER_free(ctx->micros); free(ctx); } int TS_RESP_CTX_set_signer_cert(TS_RESP_CTX *ctx, X509 *signer) { if (X509_check_purpose(signer, X509_PURPOSE_TIMESTAMP_SIGN, 0) != 1) { TSerr(TS_F_TS_RESP_CTX_SET_SIGNER_CERT, TS_R_INVALID_SIGNER_CERTIFICATE_PURPOSE); return 0; } if (ctx->signer_cert) X509_free(ctx->signer_cert); ctx->signer_cert = signer; CRYPTO_add(&ctx->signer_cert->references, +1, CRYPTO_LOCK_X509); return 1; } int TS_RESP_CTX_set_signer_key(TS_RESP_CTX *ctx, EVP_PKEY *key) { if (ctx->signer_key) EVP_PKEY_free(ctx->signer_key); ctx->signer_key = key; CRYPTO_add(&ctx->signer_key->references, +1, CRYPTO_LOCK_EVP_PKEY); return 1; } int TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *def_policy) { if (ctx->default_policy) ASN1_OBJECT_free(ctx->default_policy); if (!(ctx->default_policy = OBJ_dup(def_policy))) goto err; return 1; err: TSerr(TS_F_TS_RESP_CTX_SET_DEF_POLICY, ERR_R_MALLOC_FAILURE); return 0; } int TS_RESP_CTX_set_certs(TS_RESP_CTX *ctx, STACK_OF(X509) *certs) { int i; if (ctx->certs) { sk_X509_pop_free(ctx->certs, X509_free); ctx->certs = NULL; } if (!certs) return 1; if (!(ctx->certs = sk_X509_dup(certs))) { TSerr(TS_F_TS_RESP_CTX_SET_CERTS, ERR_R_MALLOC_FAILURE); return 0; } for (i = 0; i < sk_X509_num(ctx->certs); ++i) { X509 *cert = sk_X509_value(ctx->certs, i); CRYPTO_add(&cert->references, +1, CRYPTO_LOCK_X509); } return 1; } int TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *policy) { ASN1_OBJECT *copy = NULL; /* Create new policy stack if necessary. */ if (!ctx->policies && !(ctx->policies = sk_ASN1_OBJECT_new_null())) goto err; if (!(copy = OBJ_dup(policy))) goto err; if (!sk_ASN1_OBJECT_push(ctx->policies, copy)) goto err; return 1; err: TSerr(TS_F_TS_RESP_CTX_ADD_POLICY, ERR_R_MALLOC_FAILURE); ASN1_OBJECT_free(copy); return 0; } int TS_RESP_CTX_add_md(TS_RESP_CTX *ctx, const EVP_MD *md) { /* Create new md stack if necessary. */ if (!ctx->mds && !(ctx->mds = sk_EVP_MD_new_null())) goto err; /* Add the shared md, no copy needed. */ if (!sk_EVP_MD_push(ctx->mds, (EVP_MD *)md)) goto err; return 1; err: TSerr(TS_F_TS_RESP_CTX_ADD_MD, ERR_R_MALLOC_FAILURE); return 0; } #define TS_RESP_CTX_accuracy_free(ctx) \ ASN1_INTEGER_free(ctx->seconds); \ ctx->seconds = NULL; \ ASN1_INTEGER_free(ctx->millis); \ ctx->millis = NULL; \ ASN1_INTEGER_free(ctx->micros); \ ctx->micros = NULL; int TS_RESP_CTX_set_accuracy(TS_RESP_CTX *ctx, int secs, int millis, int micros) { TS_RESP_CTX_accuracy_free(ctx); if (secs && (!(ctx->seconds = ASN1_INTEGER_new()) || !ASN1_INTEGER_set(ctx->seconds, secs))) goto err; if (millis && (!(ctx->millis = ASN1_INTEGER_new()) || !ASN1_INTEGER_set(ctx->millis, millis))) goto err; if (micros && (!(ctx->micros = ASN1_INTEGER_new()) || !ASN1_INTEGER_set(ctx->micros, micros))) goto err; return 1; err: TS_RESP_CTX_accuracy_free(ctx); TSerr(TS_F_TS_RESP_CTX_SET_ACCURACY, ERR_R_MALLOC_FAILURE); return 0; } void TS_RESP_CTX_add_flags(TS_RESP_CTX *ctx, int flags) { ctx->flags |= flags; } void TS_RESP_CTX_set_serial_cb(TS_RESP_CTX *ctx, TS_serial_cb cb, void *data) { ctx->serial_cb = cb; ctx->serial_cb_data = data; } void TS_RESP_CTX_set_extension_cb(TS_RESP_CTX *ctx, TS_extension_cb cb, void *data) { ctx->extension_cb = cb; ctx->extension_cb_data = data; } int TS_RESP_CTX_set_status_info(TS_RESP_CTX *ctx, int status, const char *text) { TS_STATUS_INFO *si = NULL; ASN1_UTF8STRING *utf8_text = NULL; int ret = 0; if (!(si = TS_STATUS_INFO_new())) goto err; if (!ASN1_INTEGER_set(si->status, status)) goto err; if (text) { if (!(utf8_text = ASN1_UTF8STRING_new()) || !ASN1_STRING_set(utf8_text, text, strlen(text))) goto err; if (!si->text && !(si->text = sk_ASN1_UTF8STRING_new_null())) goto err; if (!sk_ASN1_UTF8STRING_push(si->text, utf8_text)) goto err; utf8_text = NULL; /* Ownership is lost. */ } if (!TS_RESP_set_status_info(ctx->response, si)) goto err; ret = 1; err: if (!ret) TSerr(TS_F_TS_RESP_CTX_SET_STATUS_INFO, ERR_R_MALLOC_FAILURE); TS_STATUS_INFO_free(si); ASN1_UTF8STRING_free(utf8_text); return ret; } int TS_RESP_CTX_set_status_info_cond(TS_RESP_CTX *ctx, int status, const char *text) { int ret = 1; TS_STATUS_INFO *si = TS_RESP_get_status_info(ctx->response); if (ASN1_INTEGER_get(si->status) == TS_STATUS_GRANTED) { /* Status has not been set, set it now. */ ret = TS_RESP_CTX_set_status_info(ctx, status, text); } return ret; } int TS_RESP_CTX_add_failure_info(TS_RESP_CTX *ctx, int failure) { TS_STATUS_INFO *si = TS_RESP_get_status_info(ctx->response); if (!si->failure_info && !(si->failure_info = ASN1_BIT_STRING_new())) goto err; if (!ASN1_BIT_STRING_set_bit(si->failure_info, failure, 1)) goto err; return 1; err: TSerr(TS_F_TS_RESP_CTX_ADD_FAILURE_INFO, ERR_R_MALLOC_FAILURE); return 0; } TS_REQ * TS_RESP_CTX_get_request(TS_RESP_CTX *ctx) { return ctx->request; } TS_TST_INFO * TS_RESP_CTX_get_tst_info(TS_RESP_CTX *ctx) { return ctx->tst_info; } int TS_RESP_CTX_set_clock_precision_digits(TS_RESP_CTX *ctx, unsigned precision) { if (precision > TS_MAX_CLOCK_PRECISION_DIGITS) return 0; ctx->clock_precision_digits = precision; return 1; } /* Main entry method of the response generation. */ TS_RESP * TS_RESP_create_response(TS_RESP_CTX *ctx, BIO *req_bio) { ASN1_OBJECT *policy; TS_RESP *response; int result = 0; TS_RESP_CTX_init(ctx); /* Creating the response object. */ if (!(ctx->response = TS_RESP_new())) { TSerr(TS_F_TS_RESP_CREATE_RESPONSE, ERR_R_MALLOC_FAILURE); goto end; } /* Parsing DER request. */ if (!(ctx->request = d2i_TS_REQ_bio(req_bio, NULL))) { TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION, "Bad request format or " "system error."); TS_RESP_CTX_add_failure_info(ctx, TS_INFO_BAD_DATA_FORMAT); goto end; } /* Setting default status info. */ if (!TS_RESP_CTX_set_status_info(ctx, TS_STATUS_GRANTED, NULL)) goto end; /* Checking the request format. */ if (!TS_RESP_check_request(ctx)) goto end; /* Checking acceptable policies. */ if (!(policy = TS_RESP_get_policy(ctx))) goto end; /* Creating the TS_TST_INFO object. */ if (!(ctx->tst_info = TS_RESP_create_tst_info(ctx, policy))) goto end; /* Processing extensions. */ if (!TS_RESP_process_extensions(ctx)) goto end; /* Generating the signature. */ if (!TS_RESP_sign(ctx)) goto end; /* Everything was successful. */ result = 1; end: if (!result) { TSerr(TS_F_TS_RESP_CREATE_RESPONSE, TS_R_RESPONSE_SETUP_ERROR); if (ctx->response != NULL) { if (TS_RESP_CTX_set_status_info_cond(ctx, TS_STATUS_REJECTION, "Error during response " "generation.") == 0) { TS_RESP_free(ctx->response); ctx->response = NULL; } } } response = ctx->response; ctx->response = NULL; /* Ownership will be returned to caller. */ TS_RESP_CTX_cleanup(ctx); return response; } /* Initializes the variable part of the context. */ static void TS_RESP_CTX_init(TS_RESP_CTX *ctx) { ctx->request = NULL; ctx->response = NULL; ctx->tst_info = NULL; } /* Cleans up the variable part of the context. */ static void TS_RESP_CTX_cleanup(TS_RESP_CTX *ctx) { TS_REQ_free(ctx->request); ctx->request = NULL; TS_RESP_free(ctx->response); ctx->response = NULL; TS_TST_INFO_free(ctx->tst_info); ctx->tst_info = NULL; } /* Checks the format and content of the request. */ static int TS_RESP_check_request(TS_RESP_CTX *ctx) { TS_REQ *request = ctx->request; TS_MSG_IMPRINT *msg_imprint; X509_ALGOR *md_alg; int md_alg_id; const ASN1_OCTET_STRING *digest; EVP_MD *md = NULL; int i; /* Checking request version. */ if (TS_REQ_get_version(request) != 1) { TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION, "Bad request version."); TS_RESP_CTX_add_failure_info(ctx, TS_INFO_BAD_REQUEST); return 0; } /* Checking message digest algorithm. */ msg_imprint = TS_REQ_get_msg_imprint(request); md_alg = TS_MSG_IMPRINT_get_algo(msg_imprint); md_alg_id = OBJ_obj2nid(md_alg->algorithm); for (i = 0; !md && i < sk_EVP_MD_num(ctx->mds); ++i) { EVP_MD *current_md = sk_EVP_MD_value(ctx->mds, i); if (md_alg_id == EVP_MD_type(current_md)) md = current_md; } if (!md) { TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION, "Message digest algorithm is " "not supported."); TS_RESP_CTX_add_failure_info(ctx, TS_INFO_BAD_ALG); return 0; } /* No message digest takes parameter. */ if (md_alg->parameter && ASN1_TYPE_get(md_alg->parameter) != V_ASN1_NULL) { TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION, "Superfluous message digest " "parameter."); TS_RESP_CTX_add_failure_info(ctx, TS_INFO_BAD_ALG); return 0; } /* Checking message digest size. */ digest = TS_MSG_IMPRINT_get_msg(msg_imprint); if (digest->length != EVP_MD_size(md)) { TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION, "Bad message digest."); TS_RESP_CTX_add_failure_info(ctx, TS_INFO_BAD_DATA_FORMAT); return 0; } return 1; } /* Returns the TSA policy based on the requested and acceptable policies. */ static ASN1_OBJECT * TS_RESP_get_policy(TS_RESP_CTX *ctx) { ASN1_OBJECT *requested = TS_REQ_get_policy_id(ctx->request); ASN1_OBJECT *policy = NULL; int i; if (ctx->default_policy == NULL) { TSerr(TS_F_TS_RESP_GET_POLICY, TS_R_INVALID_NULL_POINTER); return NULL; } /* Return the default policy if none is requested or the default is requested. */ if (!requested || !OBJ_cmp(requested, ctx->default_policy)) policy = ctx->default_policy; /* Check if the policy is acceptable. */ for (i = 0; !policy && i < sk_ASN1_OBJECT_num(ctx->policies); ++i) { ASN1_OBJECT *current = sk_ASN1_OBJECT_value(ctx->policies, i); if (!OBJ_cmp(requested, current)) policy = current; } if (!policy) { TSerr(TS_F_TS_RESP_GET_POLICY, TS_R_UNACCEPTABLE_POLICY); TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION, "Requested policy is not " "supported."); TS_RESP_CTX_add_failure_info(ctx, TS_INFO_UNACCEPTED_POLICY); } return policy; } /* Creates the TS_TST_INFO object based on the settings of the context. */ static TS_TST_INFO * TS_RESP_create_tst_info(TS_RESP_CTX *ctx, ASN1_OBJECT *policy) { int result = 0; TS_TST_INFO *tst_info = NULL; ASN1_INTEGER *serial = NULL; ASN1_GENERALIZEDTIME *asn1_time = NULL; time_t sec; long usec; TS_ACCURACY *accuracy = NULL; const ASN1_INTEGER *nonce; GENERAL_NAME *tsa_name = NULL; if (!(tst_info = TS_TST_INFO_new())) goto end; if (!TS_TST_INFO_set_version(tst_info, 1)) goto end; if (!TS_TST_INFO_set_policy_id(tst_info, policy)) goto end; if (!TS_TST_INFO_set_msg_imprint(tst_info, ctx->request->msg_imprint)) goto end; if (!(serial = (*ctx->serial_cb)(ctx, ctx->serial_cb_data)) || !TS_TST_INFO_set_serial(tst_info, serial)) goto end; if (!(*ctx->time_cb)(ctx, ctx->time_cb_data, &sec, &usec) || !(asn1_time = TS_RESP_set_genTime_with_precision(NULL, sec, usec, ctx->clock_precision_digits)) || !TS_TST_INFO_set_time(tst_info, asn1_time)) goto end; /* Setting accuracy if needed. */ if ((ctx->seconds || ctx->millis || ctx->micros) && !(accuracy = TS_ACCURACY_new())) goto end; if (ctx->seconds && !TS_ACCURACY_set_seconds(accuracy, ctx->seconds)) goto end; if (ctx->millis && !TS_ACCURACY_set_millis(accuracy, ctx->millis)) goto end; if (ctx->micros && !TS_ACCURACY_set_micros(accuracy, ctx->micros)) goto end; if (accuracy && !TS_TST_INFO_set_accuracy(tst_info, accuracy)) goto end; /* Setting ordering. */ if ((ctx->flags & TS_ORDERING) && !TS_TST_INFO_set_ordering(tst_info, 1)) goto end; /* Setting nonce if needed. */ if ((nonce = TS_REQ_get_nonce(ctx->request)) != NULL && !TS_TST_INFO_set_nonce(tst_info, nonce)) goto end; /* Setting TSA name to subject of signer certificate. */ if (ctx->flags & TS_TSA_NAME) { if (!(tsa_name = GENERAL_NAME_new())) goto end; tsa_name->type = GEN_DIRNAME; tsa_name->d.dirn = X509_NAME_dup(ctx->signer_cert->cert_info->subject); if (!tsa_name->d.dirn) goto end; if (!TS_TST_INFO_set_tsa(tst_info, tsa_name)) goto end; } result = 1; end: if (!result) { TS_TST_INFO_free(tst_info); tst_info = NULL; TSerr(TS_F_TS_RESP_CREATE_TST_INFO, TS_R_TST_INFO_SETUP_ERROR); TS_RESP_CTX_set_status_info_cond(ctx, TS_STATUS_REJECTION, "Error during TSTInfo " "generation."); } GENERAL_NAME_free(tsa_name); TS_ACCURACY_free(accuracy); ASN1_GENERALIZEDTIME_free(asn1_time); ASN1_INTEGER_free(serial); return tst_info; } /* Processing the extensions of the request. */ static int TS_RESP_process_extensions(TS_RESP_CTX *ctx) { STACK_OF(X509_EXTENSION) *exts = TS_REQ_get_exts(ctx->request); int i; int ok = 1; for (i = 0; ok && i < sk_X509_EXTENSION_num(exts); ++i) { X509_EXTENSION *ext = sk_X509_EXTENSION_value(exts, i); /* XXXXX The last argument was previously (void *)ctx->extension_cb, but ISO C doesn't permit converting a function pointer to void *. For lack of better information, I'm placing a NULL there instead. The callback can pick its own address out from the ctx anyway... */ ok = (*ctx->extension_cb)(ctx, ext, NULL); } return ok; } /* Functions for signing the TS_TST_INFO structure of the context. */ static int TS_RESP_sign(TS_RESP_CTX *ctx) { int ret = 0; PKCS7 *p7 = NULL; PKCS7_SIGNER_INFO *si; STACK_OF(X509) *certs; /* Certificates to include in sc. */ ESS_SIGNING_CERT *sc = NULL; ASN1_OBJECT *oid; BIO *p7bio = NULL; int i; /* Check if signcert and pkey match. */ if (!X509_check_private_key(ctx->signer_cert, ctx->signer_key)) { TSerr(TS_F_TS_RESP_SIGN, TS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE); goto err; } /* Create a new PKCS7 signed object. */ if (!(p7 = PKCS7_new())) { TSerr(TS_F_TS_RESP_SIGN, ERR_R_MALLOC_FAILURE); goto err; } if (!PKCS7_set_type(p7, NID_pkcs7_signed)) goto err; /* Force SignedData version to be 3 instead of the default 1. */ if (!ASN1_INTEGER_set(p7->d.sign->version, 3)) goto err; /* Add signer certificate and optional certificate chain. */ if (TS_REQ_get_cert_req(ctx->request)) { PKCS7_add_certificate(p7, ctx->signer_cert); if (ctx->certs) { for (i = 0; i < sk_X509_num(ctx->certs); ++i) { X509 *cert = sk_X509_value(ctx->certs, i); PKCS7_add_certificate(p7, cert); } } } /* Add a new signer info. */ if (!(si = PKCS7_add_signature(p7, ctx->signer_cert, ctx->signer_key, EVP_sha1()))) { TSerr(TS_F_TS_RESP_SIGN, TS_R_PKCS7_ADD_SIGNATURE_ERROR); goto err; } /* Add content type signed attribute to the signer info. */ oid = OBJ_nid2obj(NID_id_smime_ct_TSTInfo); if (!PKCS7_add_signed_attribute(si, NID_pkcs9_contentType, V_ASN1_OBJECT, oid)) { TSerr(TS_F_TS_RESP_SIGN, TS_R_PKCS7_ADD_SIGNED_ATTR_ERROR); goto err; } /* Create the ESS SigningCertificate attribute which contains the signer certificate id and optionally the certificate chain. */ certs = ctx->flags & TS_ESS_CERT_ID_CHAIN ? ctx->certs : NULL; if (!(sc = ESS_SIGNING_CERT_new_init(ctx->signer_cert, certs))) goto err; /* Add SigningCertificate signed attribute to the signer info. */ if (!ESS_add_signing_cert(si, sc)) { TSerr(TS_F_TS_RESP_SIGN, TS_R_ESS_ADD_SIGNING_CERT_ERROR); goto err; } /* Add a new empty NID_id_smime_ct_TSTInfo encapsulated content. */ if (!TS_TST_INFO_content_new(p7)) goto err; /* Add the DER encoded tst_info to the PKCS7 structure. */ if (!(p7bio = PKCS7_dataInit(p7, NULL))) { TSerr(TS_F_TS_RESP_SIGN, ERR_R_MALLOC_FAILURE); goto err; } /* Convert tst_info to DER. */ if (!i2d_TS_TST_INFO_bio(p7bio, ctx->tst_info)) { TSerr(TS_F_TS_RESP_SIGN, TS_R_TS_DATASIGN); goto err; } /* Create the signature and add it to the signer info. */ if (!PKCS7_dataFinal(p7, p7bio)) { TSerr(TS_F_TS_RESP_SIGN, TS_R_TS_DATASIGN); goto err; } /* Set new PKCS7 and TST_INFO objects. */ TS_RESP_set_tst_info(ctx->response, p7, ctx->tst_info); p7 = NULL; /* Ownership is lost. */ ctx->tst_info = NULL; /* Ownership is lost. */ ret = 1; err: if (!ret) TS_RESP_CTX_set_status_info_cond(ctx, TS_STATUS_REJECTION, "Error during signature " "generation."); BIO_free_all(p7bio); ESS_SIGNING_CERT_free(sc); PKCS7_free(p7); return ret; } static ESS_SIGNING_CERT * ESS_SIGNING_CERT_new_init(X509 *signcert, STACK_OF(X509) *certs) { ESS_CERT_ID *cid; ESS_SIGNING_CERT *sc = NULL; int i; /* Creating the ESS_CERT_ID stack. */ if (!(sc = ESS_SIGNING_CERT_new())) goto err; if (!sc->cert_ids && !(sc->cert_ids = sk_ESS_CERT_ID_new_null())) goto err; /* Adding the signing certificate id. */ if (!(cid = ESS_CERT_ID_new_init(signcert, 0)) || !sk_ESS_CERT_ID_push(sc->cert_ids, cid)) goto err; /* Adding the certificate chain ids. */ for (i = 0; i < sk_X509_num(certs); ++i) { X509 *cert = sk_X509_value(certs, i); if (!(cid = ESS_CERT_ID_new_init(cert, 1)) || !sk_ESS_CERT_ID_push(sc->cert_ids, cid)) goto err; } return sc; err: ESS_SIGNING_CERT_free(sc); TSerr(TS_F_ESS_SIGNING_CERT_NEW_INIT, ERR_R_MALLOC_FAILURE); return NULL; } static ESS_CERT_ID * ESS_CERT_ID_new_init(X509 *cert, int issuer_needed) { ESS_CERT_ID *cid = NULL; GENERAL_NAME *name = NULL; /* Recompute SHA1 hash of certificate if necessary (side effect). */ X509_check_purpose(cert, -1, 0); if (!(cid = ESS_CERT_ID_new())) goto err; if (!ASN1_OCTET_STRING_set(cid->hash, cert->sha1_hash, sizeof(cert->sha1_hash))) goto err; /* Setting the issuer/serial if requested. */ if (issuer_needed) { /* Creating issuer/serial structure. */ if (!cid->issuer_serial && !(cid->issuer_serial = ESS_ISSUER_SERIAL_new())) goto err; /* Creating general name from the certificate issuer. */ if (!(name = GENERAL_NAME_new())) goto err; name->type = GEN_DIRNAME; if (!(name->d.dirn = X509_NAME_dup(cert->cert_info->issuer))) goto err; if (!sk_GENERAL_NAME_push(cid->issuer_serial->issuer, name)) goto err; name = NULL; /* Ownership is lost. */ /* Setting the serial number. */ ASN1_INTEGER_free(cid->issuer_serial->serial); if (!(cid->issuer_serial->serial = ASN1_INTEGER_dup(cert->cert_info->serialNumber))) goto err; } return cid; err: GENERAL_NAME_free(name); ESS_CERT_ID_free(cid); TSerr(TS_F_ESS_CERT_ID_NEW_INIT, ERR_R_MALLOC_FAILURE); return NULL; } static int TS_TST_INFO_content_new(PKCS7 *p7) { PKCS7 *ret = NULL; ASN1_OCTET_STRING *octet_string = NULL; /* Create new encapsulated NID_id_smime_ct_TSTInfo content. */ if (!(ret = PKCS7_new())) goto err; if (!(ret->d.other = ASN1_TYPE_new())) goto err; ret->type = OBJ_nid2obj(NID_id_smime_ct_TSTInfo); if (!(octet_string = ASN1_OCTET_STRING_new())) goto err; ASN1_TYPE_set(ret->d.other, V_ASN1_OCTET_STRING, octet_string); octet_string = NULL; /* Add encapsulated content to signed PKCS7 structure. */ if (!PKCS7_set_content(p7, ret)) goto err; return 1; err: ASN1_OCTET_STRING_free(octet_string); PKCS7_free(ret); return 0; } static int ESS_add_signing_cert(PKCS7_SIGNER_INFO *si, ESS_SIGNING_CERT *sc) { ASN1_STRING *seq = NULL; unsigned char *p, *pp = NULL; int len; len = i2d_ESS_SIGNING_CERT(sc, NULL); if (!(pp = malloc(len))) { TSerr(TS_F_ESS_ADD_SIGNING_CERT, ERR_R_MALLOC_FAILURE); goto err; } p = pp; i2d_ESS_SIGNING_CERT(sc, &p); if (!(seq = ASN1_STRING_new()) || !ASN1_STRING_set(seq, pp, len)) { TSerr(TS_F_ESS_ADD_SIGNING_CERT, ERR_R_MALLOC_FAILURE); goto err; } free(pp); pp = NULL; return PKCS7_add_signed_attribute(si, NID_id_smime_aa_signingCertificate, V_ASN1_SEQUENCE, seq); err: ASN1_STRING_free(seq); free(pp); return 0; } static ASN1_GENERALIZEDTIME * TS_RESP_set_genTime_with_precision(ASN1_GENERALIZEDTIME *asn1_time, time_t sec, long usec, unsigned precision) { struct tm *tm = NULL; char genTime_str[17 + TS_MAX_CLOCK_PRECISION_DIGITS]; char usecstr[TS_MAX_CLOCK_PRECISION_DIGITS + 2]; char *p; int rv; if (precision > TS_MAX_CLOCK_PRECISION_DIGITS) goto err; if (!(tm = gmtime(&sec))) goto err; /* * Put "genTime_str" in GeneralizedTime format. We work around the * restrictions imposed by rfc3280 (i.e. "GeneralizedTime values MUST * NOT include fractional seconds") and OpenSSL related functions to * meet the rfc3161 requirement: "GeneralizedTime syntax can include * fraction-of-second details". */ if (precision > 0) { /* To make things a bit harder, X.690 | ISO/IEC 8825-1 provides the following restrictions for a DER-encoding, which OpenSSL (specifically ASN1_GENERALIZEDTIME_check() function) doesn't support: "The encoding MUST terminate with a "Z" (which means "Zulu" time). The decimal point element, if present, MUST be the point option ".". The fractional-seconds elements, if present, MUST omit all trailing 0's; if the elements correspond to 0, they MUST be wholly omitted, and the decimal point element also MUST be omitted." */ (void) snprintf(usecstr, sizeof(usecstr), ".%06ld", usec); /* truncate and trim trailing 0 */ usecstr[precision + 1] = '\0'; p = usecstr + strlen(usecstr) - 1; while (p > usecstr && *p == '0') *p-- = '\0'; /* if we've reached the beginning, delete the . too */ if (p == usecstr) *p = '\0'; } else { /* empty */ usecstr[0] = '\0'; } rv = snprintf(genTime_str, sizeof(genTime_str), "%04d%02d%02d%02d%02d%02d%sZ", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, usecstr); if (rv == -1 || rv >= sizeof(genTime_str)) goto err; /* Now call OpenSSL to check and set our genTime value */ if (!asn1_time && !(asn1_time = M_ASN1_GENERALIZEDTIME_new())) goto err; if (!ASN1_GENERALIZEDTIME_set_string(asn1_time, genTime_str)) { ASN1_GENERALIZEDTIME_free(asn1_time); goto err; } return asn1_time; err: TSerr(TS_F_TS_RESP_SET_GENTIME_WITH_PRECISION, TS_R_COULD_NOT_SET_TIME); return NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ts/ts_req_utils.c0000644000175000017500000001432112360020706021564 0ustar /* $OpenBSD: ts_req_utils.c,v 1.3 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include int TS_REQ_set_version(TS_REQ *a, long version) { return ASN1_INTEGER_set(a->version, version); } long TS_REQ_get_version(const TS_REQ *a) { return ASN1_INTEGER_get(a->version); } int TS_REQ_set_msg_imprint(TS_REQ *a, TS_MSG_IMPRINT *msg_imprint) { TS_MSG_IMPRINT *new_msg_imprint; if (a->msg_imprint == msg_imprint) return 1; new_msg_imprint = TS_MSG_IMPRINT_dup(msg_imprint); if (new_msg_imprint == NULL) { TSerr(TS_F_TS_REQ_SET_MSG_IMPRINT, ERR_R_MALLOC_FAILURE); return 0; } TS_MSG_IMPRINT_free(a->msg_imprint); a->msg_imprint = new_msg_imprint; return 1; } TS_MSG_IMPRINT * TS_REQ_get_msg_imprint(TS_REQ *a) { return a->msg_imprint; } int TS_MSG_IMPRINT_set_algo(TS_MSG_IMPRINT *a, X509_ALGOR *alg) { X509_ALGOR *new_alg; if (a->hash_algo == alg) return 1; new_alg = X509_ALGOR_dup(alg); if (new_alg == NULL) { TSerr(TS_F_TS_MSG_IMPRINT_SET_ALGO, ERR_R_MALLOC_FAILURE); return 0; } X509_ALGOR_free(a->hash_algo); a->hash_algo = new_alg; return 1; } X509_ALGOR * TS_MSG_IMPRINT_get_algo(TS_MSG_IMPRINT *a) { return a->hash_algo; } int TS_MSG_IMPRINT_set_msg(TS_MSG_IMPRINT *a, unsigned char *d, int len) { return ASN1_OCTET_STRING_set(a->hashed_msg, d, len); } ASN1_OCTET_STRING * TS_MSG_IMPRINT_get_msg(TS_MSG_IMPRINT *a) { return a->hashed_msg; } int TS_REQ_set_policy_id(TS_REQ *a, ASN1_OBJECT *policy) { ASN1_OBJECT *new_policy; if (a->policy_id == policy) return 1; new_policy = OBJ_dup(policy); if (new_policy == NULL) { TSerr(TS_F_TS_REQ_SET_POLICY_ID, ERR_R_MALLOC_FAILURE); return 0; } ASN1_OBJECT_free(a->policy_id); a->policy_id = new_policy; return 1; } ASN1_OBJECT * TS_REQ_get_policy_id(TS_REQ *a) { return a->policy_id; } int TS_REQ_set_nonce(TS_REQ *a, const ASN1_INTEGER *nonce) { ASN1_INTEGER *new_nonce; if (a->nonce == nonce) return 1; new_nonce = ASN1_INTEGER_dup(nonce); if (new_nonce == NULL) { TSerr(TS_F_TS_REQ_SET_NONCE, ERR_R_MALLOC_FAILURE); return 0; } ASN1_INTEGER_free(a->nonce); a->nonce = new_nonce; return 1; } const ASN1_INTEGER * TS_REQ_get_nonce(const TS_REQ *a) { return a->nonce; } int TS_REQ_set_cert_req(TS_REQ *a, int cert_req) { a->cert_req = cert_req ? 0xFF : 0x00; return 1; } int TS_REQ_get_cert_req(const TS_REQ *a) { return a->cert_req ? 1 : 0; } STACK_OF(X509_EXTENSION) *TS_REQ_get_exts(TS_REQ *a) { return a->extensions; } void TS_REQ_ext_free(TS_REQ *a) { if (!a) return; sk_X509_EXTENSION_pop_free(a->extensions, X509_EXTENSION_free); a->extensions = NULL; } int TS_REQ_get_ext_count(TS_REQ *a) { return X509v3_get_ext_count(a->extensions); } int TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos) { return X509v3_get_ext_by_NID(a->extensions, nid, lastpos); } int TS_REQ_get_ext_by_OBJ(TS_REQ *a, ASN1_OBJECT *obj, int lastpos) { return X509v3_get_ext_by_OBJ(a->extensions, obj, lastpos); } int TS_REQ_get_ext_by_critical(TS_REQ *a, int crit, int lastpos) { return X509v3_get_ext_by_critical(a->extensions, crit, lastpos); } X509_EXTENSION * TS_REQ_get_ext(TS_REQ *a, int loc) { return X509v3_get_ext(a->extensions, loc); } X509_EXTENSION * TS_REQ_delete_ext(TS_REQ *a, int loc) { return X509v3_delete_ext(a->extensions, loc); } int TS_REQ_add_ext(TS_REQ *a, X509_EXTENSION *ex, int loc) { return X509v3_add_ext(&a->extensions, ex, loc) != NULL; } void * TS_REQ_get_ext_d2i(TS_REQ *a, int nid, int *crit, int *idx) { return X509V3_get_d2i(a->extensions, nid, crit, idx); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ts/ts_lib.c0000644000175000017500000001123312360020706020322 0ustar /* $OpenBSD: ts_lib.c,v 1.7 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include /* Local function declarations. */ /* Function definitions. */ int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num) { BIGNUM num_bn; int result = 0; char *hex; BN_init(&num_bn); ASN1_INTEGER_to_BN(num, &num_bn); if ((hex = BN_bn2hex(&num_bn))) { result = BIO_write(bio, "0x", 2) > 0; result = result && BIO_write(bio, hex, strlen(hex)) > 0; free(hex); } BN_free(&num_bn); return result; } int TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj) { char obj_txt[128]; int len = OBJ_obj2txt(obj_txt, sizeof(obj_txt), obj, 0); if (len >= sizeof(obj_txt)) len = sizeof(obj_txt) - 1; BIO_write(bio, obj_txt, len); BIO_write(bio, "\n", 1); return 1; } int TS_ext_print_bio(BIO *bio, const STACK_OF(X509_EXTENSION) *extensions) { int i, critical, n; X509_EXTENSION *ex; ASN1_OBJECT *obj; BIO_printf(bio, "Extensions:\n"); n = X509v3_get_ext_count(extensions); for (i = 0; i < n; i++) { ex = X509v3_get_ext(extensions, i); obj = X509_EXTENSION_get_object(ex); i2a_ASN1_OBJECT(bio, obj); critical = X509_EXTENSION_get_critical(ex); BIO_printf(bio, ": %s\n", critical ? "critical" : ""); if (!X509V3_EXT_print(bio, ex, 0, 4)) { BIO_printf(bio, "%4s", ""); M_ASN1_OCTET_STRING_print(bio, ex->value); } BIO_write(bio, "\n", 1); } return 1; } int TS_X509_ALGOR_print_bio(BIO *bio, const X509_ALGOR *alg) { int i = OBJ_obj2nid(alg->algorithm); return BIO_printf(bio, "Hash Algorithm: %s\n", (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i)); } int TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *a) { const ASN1_OCTET_STRING *msg; TS_X509_ALGOR_print_bio(bio, TS_MSG_IMPRINT_get_algo(a)); BIO_printf(bio, "Message data:\n"); msg = TS_MSG_IMPRINT_get_msg(a); BIO_dump_indent(bio, (const char *)M_ASN1_STRING_data(msg), M_ASN1_STRING_length(msg), 4); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ts/ts_verify_ctx.c0000644000175000017500000001152312360020706021740 0ustar /* $OpenBSD: ts_verify_ctx.c,v 1.6 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2003. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include TS_VERIFY_CTX * TS_VERIFY_CTX_new(void) { TS_VERIFY_CTX *ctx = calloc(1, sizeof(TS_VERIFY_CTX)); if (!ctx) TSerr(TS_F_TS_VERIFY_CTX_NEW, ERR_R_MALLOC_FAILURE); return ctx; } void TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx) { OPENSSL_assert(ctx != NULL); memset(ctx, 0, sizeof(TS_VERIFY_CTX)); } void TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx) { if (!ctx) return; TS_VERIFY_CTX_cleanup(ctx); free(ctx); } void TS_VERIFY_CTX_cleanup(TS_VERIFY_CTX *ctx) { if (!ctx) return; X509_STORE_free(ctx->store); sk_X509_pop_free(ctx->certs, X509_free); ASN1_OBJECT_free(ctx->policy); X509_ALGOR_free(ctx->md_alg); free(ctx->imprint); BIO_free_all(ctx->data); ASN1_INTEGER_free(ctx->nonce); GENERAL_NAME_free(ctx->tsa_name); TS_VERIFY_CTX_init(ctx); } TS_VERIFY_CTX * TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx) { TS_VERIFY_CTX *ret = ctx; ASN1_OBJECT *policy; TS_MSG_IMPRINT *imprint; X509_ALGOR *md_alg; ASN1_OCTET_STRING *msg; const ASN1_INTEGER *nonce; OPENSSL_assert(req != NULL); if (ret) TS_VERIFY_CTX_cleanup(ret); else if (!(ret = TS_VERIFY_CTX_new())) return NULL; /* Setting flags. */ ret->flags = TS_VFY_ALL_IMPRINT & ~(TS_VFY_TSA_NAME | TS_VFY_SIGNATURE); /* Setting policy. */ if ((policy = TS_REQ_get_policy_id(req)) != NULL) { if (!(ret->policy = OBJ_dup(policy))) goto err; } else ret->flags &= ~TS_VFY_POLICY; /* Setting md_alg, imprint and imprint_len. */ imprint = TS_REQ_get_msg_imprint(req); md_alg = TS_MSG_IMPRINT_get_algo(imprint); if (!(ret->md_alg = X509_ALGOR_dup(md_alg))) goto err; msg = TS_MSG_IMPRINT_get_msg(imprint); ret->imprint_len = ASN1_STRING_length(msg); if (!(ret->imprint = malloc(ret->imprint_len))) goto err; memcpy(ret->imprint, ASN1_STRING_data(msg), ret->imprint_len); /* Setting nonce. */ if ((nonce = TS_REQ_get_nonce(req)) != NULL) { if (!(ret->nonce = ASN1_INTEGER_dup(nonce))) goto err; } else ret->flags &= ~TS_VFY_NONCE; return ret; err: if (ctx) TS_VERIFY_CTX_cleanup(ctx); else TS_VERIFY_CTX_free(ret); return NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ts/ts_asn1.c0000644000175000017500000002410712360020706020422 0ustar /* $OpenBSD: ts_asn1.c,v 1.4 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Nils Larsch for the OpenSSL project 2004. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include ASN1_SEQUENCE(TS_MSG_IMPRINT) = { ASN1_SIMPLE(TS_MSG_IMPRINT, hash_algo, X509_ALGOR), ASN1_SIMPLE(TS_MSG_IMPRINT, hashed_msg, ASN1_OCTET_STRING) } ASN1_SEQUENCE_END(TS_MSG_IMPRINT) IMPLEMENT_ASN1_FUNCTIONS_const(TS_MSG_IMPRINT) IMPLEMENT_ASN1_DUP_FUNCTION(TS_MSG_IMPRINT) #ifndef OPENSSL_NO_BIO TS_MSG_IMPRINT * d2i_TS_MSG_IMPRINT_bio(BIO *bp, TS_MSG_IMPRINT **a) { return ASN1_d2i_bio_of(TS_MSG_IMPRINT, TS_MSG_IMPRINT_new, d2i_TS_MSG_IMPRINT, bp, a); } int i2d_TS_MSG_IMPRINT_bio(BIO *bp, TS_MSG_IMPRINT *a) { return ASN1_i2d_bio_of_const(TS_MSG_IMPRINT, i2d_TS_MSG_IMPRINT, bp, a); } #endif TS_MSG_IMPRINT * d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a) { return ASN1_d2i_fp_of(TS_MSG_IMPRINT, TS_MSG_IMPRINT_new, d2i_TS_MSG_IMPRINT, fp, a); } int i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a) { return ASN1_i2d_fp_of_const(TS_MSG_IMPRINT, i2d_TS_MSG_IMPRINT, fp, a); } ASN1_SEQUENCE(TS_REQ) = { ASN1_SIMPLE(TS_REQ, version, ASN1_INTEGER), ASN1_SIMPLE(TS_REQ, msg_imprint, TS_MSG_IMPRINT), ASN1_OPT(TS_REQ, policy_id, ASN1_OBJECT), ASN1_OPT(TS_REQ, nonce, ASN1_INTEGER), ASN1_OPT(TS_REQ, cert_req, ASN1_FBOOLEAN), ASN1_IMP_SEQUENCE_OF_OPT(TS_REQ, extensions, X509_EXTENSION, 0) } ASN1_SEQUENCE_END(TS_REQ) IMPLEMENT_ASN1_FUNCTIONS_const(TS_REQ) IMPLEMENT_ASN1_DUP_FUNCTION(TS_REQ) #ifndef OPENSSL_NO_BIO TS_REQ * d2i_TS_REQ_bio(BIO *bp, TS_REQ **a) { return ASN1_d2i_bio_of(TS_REQ, TS_REQ_new, d2i_TS_REQ, bp, a); } int i2d_TS_REQ_bio(BIO *bp, TS_REQ *a) { return ASN1_i2d_bio_of_const(TS_REQ, i2d_TS_REQ, bp, a); } #endif TS_REQ * d2i_TS_REQ_fp(FILE *fp, TS_REQ **a) { return ASN1_d2i_fp_of(TS_REQ, TS_REQ_new, d2i_TS_REQ, fp, a); } int i2d_TS_REQ_fp(FILE *fp, TS_REQ *a) { return ASN1_i2d_fp_of_const(TS_REQ, i2d_TS_REQ, fp, a); } ASN1_SEQUENCE(TS_ACCURACY) = { ASN1_OPT(TS_ACCURACY, seconds, ASN1_INTEGER), ASN1_IMP_OPT(TS_ACCURACY, millis, ASN1_INTEGER, 0), ASN1_IMP_OPT(TS_ACCURACY, micros, ASN1_INTEGER, 1) } ASN1_SEQUENCE_END(TS_ACCURACY) IMPLEMENT_ASN1_FUNCTIONS_const(TS_ACCURACY) IMPLEMENT_ASN1_DUP_FUNCTION(TS_ACCURACY) ASN1_SEQUENCE(TS_TST_INFO) = { ASN1_SIMPLE(TS_TST_INFO, version, ASN1_INTEGER), ASN1_SIMPLE(TS_TST_INFO, policy_id, ASN1_OBJECT), ASN1_SIMPLE(TS_TST_INFO, msg_imprint, TS_MSG_IMPRINT), ASN1_SIMPLE(TS_TST_INFO, serial, ASN1_INTEGER), ASN1_SIMPLE(TS_TST_INFO, time, ASN1_GENERALIZEDTIME), ASN1_OPT(TS_TST_INFO, accuracy, TS_ACCURACY), ASN1_OPT(TS_TST_INFO, ordering, ASN1_FBOOLEAN), ASN1_OPT(TS_TST_INFO, nonce, ASN1_INTEGER), ASN1_EXP_OPT(TS_TST_INFO, tsa, GENERAL_NAME, 0), ASN1_IMP_SEQUENCE_OF_OPT(TS_TST_INFO, extensions, X509_EXTENSION, 1) } ASN1_SEQUENCE_END(TS_TST_INFO) IMPLEMENT_ASN1_FUNCTIONS_const(TS_TST_INFO) IMPLEMENT_ASN1_DUP_FUNCTION(TS_TST_INFO) #ifndef OPENSSL_NO_BIO TS_TST_INFO * d2i_TS_TST_INFO_bio(BIO *bp, TS_TST_INFO **a) { return ASN1_d2i_bio_of(TS_TST_INFO, TS_TST_INFO_new, d2i_TS_TST_INFO, bp, a); } int i2d_TS_TST_INFO_bio(BIO *bp, TS_TST_INFO *a) { return ASN1_i2d_bio_of_const(TS_TST_INFO, i2d_TS_TST_INFO, bp, a); } #endif TS_TST_INFO * d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a) { return ASN1_d2i_fp_of(TS_TST_INFO, TS_TST_INFO_new, d2i_TS_TST_INFO, fp, a); } int i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a) { return ASN1_i2d_fp_of_const(TS_TST_INFO, i2d_TS_TST_INFO, fp, a); } ASN1_SEQUENCE(TS_STATUS_INFO) = { ASN1_SIMPLE(TS_STATUS_INFO, status, ASN1_INTEGER), ASN1_SEQUENCE_OF_OPT(TS_STATUS_INFO, text, ASN1_UTF8STRING), ASN1_OPT(TS_STATUS_INFO, failure_info, ASN1_BIT_STRING) } ASN1_SEQUENCE_END(TS_STATUS_INFO) IMPLEMENT_ASN1_FUNCTIONS_const(TS_STATUS_INFO) IMPLEMENT_ASN1_DUP_FUNCTION(TS_STATUS_INFO) static int ts_resp_set_tst_info(TS_RESP *a) { long status; status = ASN1_INTEGER_get(a->status_info->status); if (a->token) { if (status != 0 && status != 1) { TSerr(TS_F_TS_RESP_SET_TST_INFO, TS_R_TOKEN_PRESENT); return 0; } if (a->tst_info != NULL) TS_TST_INFO_free(a->tst_info); a->tst_info = PKCS7_to_TS_TST_INFO(a->token); if (!a->tst_info) { TSerr(TS_F_TS_RESP_SET_TST_INFO, TS_R_PKCS7_TO_TS_TST_INFO_FAILED); return 0; } } else if (status == 0 || status == 1) { TSerr(TS_F_TS_RESP_SET_TST_INFO, TS_R_TOKEN_NOT_PRESENT); return 0; } return 1; } static int ts_resp_cb(int op, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { TS_RESP *ts_resp = (TS_RESP *)*pval; if (op == ASN1_OP_NEW_POST) { ts_resp->tst_info = NULL; } else if (op == ASN1_OP_FREE_POST) { if (ts_resp->tst_info != NULL) TS_TST_INFO_free(ts_resp->tst_info); } else if (op == ASN1_OP_D2I_POST) { if (ts_resp_set_tst_info(ts_resp) == 0) return 0; } return 1; } ASN1_SEQUENCE_cb(TS_RESP, ts_resp_cb) = { ASN1_SIMPLE(TS_RESP, status_info, TS_STATUS_INFO), ASN1_OPT(TS_RESP, token, PKCS7), } ASN1_SEQUENCE_END_cb(TS_RESP, TS_RESP) IMPLEMENT_ASN1_FUNCTIONS_const(TS_RESP) IMPLEMENT_ASN1_DUP_FUNCTION(TS_RESP) #ifndef OPENSSL_NO_BIO TS_RESP * d2i_TS_RESP_bio(BIO *bp, TS_RESP **a) { return ASN1_d2i_bio_of(TS_RESP, TS_RESP_new, d2i_TS_RESP, bp, a); } int i2d_TS_RESP_bio(BIO *bp, TS_RESP *a) { return ASN1_i2d_bio_of_const(TS_RESP, i2d_TS_RESP, bp, a); } #endif TS_RESP * d2i_TS_RESP_fp(FILE *fp, TS_RESP **a) { return ASN1_d2i_fp_of(TS_RESP, TS_RESP_new, d2i_TS_RESP, fp, a); } int i2d_TS_RESP_fp(FILE *fp, TS_RESP *a) { return ASN1_i2d_fp_of_const(TS_RESP, i2d_TS_RESP, fp, a); } ASN1_SEQUENCE(ESS_ISSUER_SERIAL) = { ASN1_SEQUENCE_OF(ESS_ISSUER_SERIAL, issuer, GENERAL_NAME), ASN1_SIMPLE(ESS_ISSUER_SERIAL, serial, ASN1_INTEGER) } ASN1_SEQUENCE_END(ESS_ISSUER_SERIAL) IMPLEMENT_ASN1_FUNCTIONS_const(ESS_ISSUER_SERIAL) IMPLEMENT_ASN1_DUP_FUNCTION(ESS_ISSUER_SERIAL) ASN1_SEQUENCE(ESS_CERT_ID) = { ASN1_SIMPLE(ESS_CERT_ID, hash, ASN1_OCTET_STRING), ASN1_OPT(ESS_CERT_ID, issuer_serial, ESS_ISSUER_SERIAL) } ASN1_SEQUENCE_END(ESS_CERT_ID) IMPLEMENT_ASN1_FUNCTIONS_const(ESS_CERT_ID) IMPLEMENT_ASN1_DUP_FUNCTION(ESS_CERT_ID) ASN1_SEQUENCE(ESS_SIGNING_CERT) = { ASN1_SEQUENCE_OF(ESS_SIGNING_CERT, cert_ids, ESS_CERT_ID), ASN1_SEQUENCE_OF_OPT(ESS_SIGNING_CERT, policy_info, POLICYINFO) } ASN1_SEQUENCE_END(ESS_SIGNING_CERT) IMPLEMENT_ASN1_FUNCTIONS_const(ESS_SIGNING_CERT) IMPLEMENT_ASN1_DUP_FUNCTION(ESS_SIGNING_CERT) /* Getting encapsulated TS_TST_INFO object from PKCS7. */ TS_TST_INFO * PKCS7_to_TS_TST_INFO(PKCS7 *token) { PKCS7_SIGNED *pkcs7_signed; PKCS7 *enveloped; ASN1_TYPE *tst_info_wrapper; ASN1_OCTET_STRING *tst_info_der; const unsigned char *p; if (!PKCS7_type_is_signed(token)) { TSerr(TS_F_PKCS7_TO_TS_TST_INFO, TS_R_BAD_PKCS7_TYPE); return NULL; } /* Content must be present. */ if (PKCS7_get_detached(token)) { TSerr(TS_F_PKCS7_TO_TS_TST_INFO, TS_R_DETACHED_CONTENT); return NULL; } /* We have a signed data with content. */ pkcs7_signed = token->d.sign; enveloped = pkcs7_signed->contents; if (OBJ_obj2nid(enveloped->type) != NID_id_smime_ct_TSTInfo) { TSerr(TS_F_PKCS7_TO_TS_TST_INFO, TS_R_BAD_PKCS7_TYPE); return NULL; } /* We have a DER encoded TST_INFO as the signed data. */ tst_info_wrapper = enveloped->d.other; if (tst_info_wrapper->type != V_ASN1_OCTET_STRING) { TSerr(TS_F_PKCS7_TO_TS_TST_INFO, TS_R_BAD_TYPE); return NULL; } /* We have the correct ASN1_OCTET_STRING type. */ tst_info_der = tst_info_wrapper->value.octet_string; /* At last, decode the TST_INFO. */ p = tst_info_der->data; return d2i_TS_TST_INFO(NULL, &p, tst_info_der->length); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ts/ts_conf.c0000644000175000017500000003154612360020706020512 0ustar /* $OpenBSD: ts_conf.c,v 1.6 2014/07/10 22:45:58 jsing Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif /* Macro definitions for the configuration file. */ #define BASE_SECTION "tsa" #define ENV_DEFAULT_TSA "default_tsa" #define ENV_SERIAL "serial" #define ENV_CRYPTO_DEVICE "crypto_device" #define ENV_SIGNER_CERT "signer_cert" #define ENV_CERTS "certs" #define ENV_SIGNER_KEY "signer_key" #define ENV_DEFAULT_POLICY "default_policy" #define ENV_OTHER_POLICIES "other_policies" #define ENV_DIGESTS "digests" #define ENV_ACCURACY "accuracy" #define ENV_ORDERING "ordering" #define ENV_TSA_NAME "tsa_name" #define ENV_ESS_CERT_ID_CHAIN "ess_cert_id_chain" #define ENV_VALUE_SECS "secs" #define ENV_VALUE_MILLISECS "millisecs" #define ENV_VALUE_MICROSECS "microsecs" #define ENV_CLOCK_PRECISION_DIGITS "clock_precision_digits" #define ENV_VALUE_YES "yes" #define ENV_VALUE_NO "no" /* Function definitions for certificate and key loading. */ X509 * TS_CONF_load_cert(const char *file) { BIO *cert = NULL; X509 *x = NULL; if ((cert = BIO_new_file(file, "r")) == NULL) goto end; x = PEM_read_bio_X509_AUX(cert, NULL, NULL, NULL); end: if (x == NULL) fprintf(stderr, "unable to load certificate: %s\n", file); BIO_free(cert); return x; } STACK_OF(X509) *TS_CONF_load_certs(const char *file) { BIO *certs = NULL; STACK_OF(X509) *othercerts = NULL; STACK_OF(X509_INFO) *allcerts = NULL; int i; if (!(certs = BIO_new_file(file, "r"))) goto end; if (!(othercerts = sk_X509_new_null())) goto end; allcerts = PEM_X509_INFO_read_bio(certs, NULL, NULL, NULL); for (i = 0; i < sk_X509_INFO_num(allcerts); i++) { X509_INFO *xi = sk_X509_INFO_value(allcerts, i); if (xi->x509) { sk_X509_push(othercerts, xi->x509); xi->x509 = NULL; } } end: if (othercerts == NULL) fprintf(stderr, "unable to load certificates: %s\n", file); sk_X509_INFO_pop_free(allcerts, X509_INFO_free); BIO_free(certs); return othercerts; } EVP_PKEY * TS_CONF_load_key(const char *file, const char *pass) { BIO *key = NULL; EVP_PKEY *pkey = NULL; if (!(key = BIO_new_file(file, "r"))) goto end; pkey = PEM_read_bio_PrivateKey(key, NULL, NULL, (char *) pass); end: if (pkey == NULL) fprintf(stderr, "unable to load private key: %s\n", file); BIO_free(key); return pkey; } /* Function definitions for handling configuration options. */ static void TS_CONF_lookup_fail(const char *name, const char *tag) { fprintf(stderr, "variable lookup failed for %s::%s\n", name, tag); } static void TS_CONF_invalid(const char *name, const char *tag) { fprintf(stderr, "invalid variable value for %s::%s\n", name, tag); } const char * TS_CONF_get_tsa_section(CONF *conf, const char *section) { if (!section) { section = NCONF_get_string(conf, BASE_SECTION, ENV_DEFAULT_TSA); if (!section) TS_CONF_lookup_fail(BASE_SECTION, ENV_DEFAULT_TSA); } return section; } int TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb, TS_RESP_CTX *ctx) { int ret = 0; char *serial = NCONF_get_string(conf, section, ENV_SERIAL); if (!serial) { TS_CONF_lookup_fail(section, ENV_SERIAL); goto err; } TS_RESP_CTX_set_serial_cb(ctx, cb, serial); ret = 1; err: return ret; } #ifndef OPENSSL_NO_ENGINE int TS_CONF_set_crypto_device(CONF *conf, const char *section, const char *device) { int ret = 0; if (!device) device = NCONF_get_string(conf, section, ENV_CRYPTO_DEVICE); if (device && !TS_CONF_set_default_engine(device)) { TS_CONF_invalid(section, ENV_CRYPTO_DEVICE); goto err; } ret = 1; err: return ret; } int TS_CONF_set_default_engine(const char *name) { ENGINE *e = NULL; int ret = 0; /* Leave the default if builtin specified. */ if (strcmp(name, "builtin") == 0) return 1; if (!(e = ENGINE_by_id(name))) goto err; /* All the operations are going to be carried out by the engine. */ if (!ENGINE_set_default(e, ENGINE_METHOD_ALL)) goto err; ret = 1; err: if (!ret) { TSerr(TS_F_TS_CONF_SET_DEFAULT_ENGINE, TS_R_COULD_NOT_SET_ENGINE); ERR_asprintf_error_data("engine:%s", name); } if (e) ENGINE_free(e); return ret; } #endif int TS_CONF_set_signer_cert(CONF *conf, const char *section, const char *cert, TS_RESP_CTX *ctx) { int ret = 0; X509 *cert_obj = NULL; if (!cert) cert = NCONF_get_string(conf, section, ENV_SIGNER_CERT); if (!cert) { TS_CONF_lookup_fail(section, ENV_SIGNER_CERT); goto err; } if (!(cert_obj = TS_CONF_load_cert(cert))) goto err; if (!TS_RESP_CTX_set_signer_cert(ctx, cert_obj)) goto err; ret = 1; err: X509_free(cert_obj); return ret; } int TS_CONF_set_certs(CONF *conf, const char *section, const char *certs, TS_RESP_CTX *ctx) { int ret = 0; STACK_OF(X509) *certs_obj = NULL; if (!certs) certs = NCONF_get_string(conf, section, ENV_CERTS); /* Certificate chain is optional. */ if (!certs) goto end; if (!(certs_obj = TS_CONF_load_certs(certs))) goto err; if (!TS_RESP_CTX_set_certs(ctx, certs_obj)) goto err; end: ret = 1; err: sk_X509_pop_free(certs_obj, X509_free); return ret; } int TS_CONF_set_signer_key(CONF *conf, const char *section, const char *key, const char *pass, TS_RESP_CTX *ctx) { int ret = 0; EVP_PKEY *key_obj = NULL; if (!key) key = NCONF_get_string(conf, section, ENV_SIGNER_KEY); if (!key) { TS_CONF_lookup_fail(section, ENV_SIGNER_KEY); goto err; } if (!(key_obj = TS_CONF_load_key(key, pass))) goto err; if (!TS_RESP_CTX_set_signer_key(ctx, key_obj)) goto err; ret = 1; err: EVP_PKEY_free(key_obj); return ret; } int TS_CONF_set_def_policy(CONF *conf, const char *section, const char *policy, TS_RESP_CTX *ctx) { int ret = 0; ASN1_OBJECT *policy_obj = NULL; if (!policy) policy = NCONF_get_string(conf, section, ENV_DEFAULT_POLICY); if (!policy) { TS_CONF_lookup_fail(section, ENV_DEFAULT_POLICY); goto err; } if (!(policy_obj = OBJ_txt2obj(policy, 0))) { TS_CONF_invalid(section, ENV_DEFAULT_POLICY); goto err; } if (!TS_RESP_CTX_set_def_policy(ctx, policy_obj)) goto err; ret = 1; err: ASN1_OBJECT_free(policy_obj); return ret; } int TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx) { int ret = 0; int i; STACK_OF(CONF_VALUE) *list = NULL; char *policies = NCONF_get_string(conf, section, ENV_OTHER_POLICIES); /* If no other policy is specified, that's fine. */ if (policies && !(list = X509V3_parse_list(policies))) { TS_CONF_invalid(section, ENV_OTHER_POLICIES); goto err; } for (i = 0; i < sk_CONF_VALUE_num(list); ++i) { CONF_VALUE *val = sk_CONF_VALUE_value(list, i); const char *extval = val->value ? val->value : val->name; ASN1_OBJECT *objtmp; if (!(objtmp = OBJ_txt2obj(extval, 0))) { TS_CONF_invalid(section, ENV_OTHER_POLICIES); goto err; } if (!TS_RESP_CTX_add_policy(ctx, objtmp)) goto err; ASN1_OBJECT_free(objtmp); } ret = 1; err: sk_CONF_VALUE_pop_free(list, X509V3_conf_free); return ret; } int TS_CONF_set_digests(CONF *conf, const char *section, TS_RESP_CTX *ctx) { int ret = 0; int i; STACK_OF(CONF_VALUE) *list = NULL; char *digests = NCONF_get_string(conf, section, ENV_DIGESTS); if (!digests) { TS_CONF_lookup_fail(section, ENV_DIGESTS); goto err; } if (!(list = X509V3_parse_list(digests))) { TS_CONF_invalid(section, ENV_DIGESTS); goto err; } if (sk_CONF_VALUE_num(list) == 0) { TS_CONF_invalid(section, ENV_DIGESTS); goto err; } for (i = 0; i < sk_CONF_VALUE_num(list); ++i) { CONF_VALUE *val = sk_CONF_VALUE_value(list, i); const char *extval = val->value ? val->value : val->name; const EVP_MD *md; if (!(md = EVP_get_digestbyname(extval))) { TS_CONF_invalid(section, ENV_DIGESTS); goto err; } if (!TS_RESP_CTX_add_md(ctx, md)) goto err; } ret = 1; err: sk_CONF_VALUE_pop_free(list, X509V3_conf_free); return ret; } int TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx) { int ret = 0; int i; int secs = 0, millis = 0, micros = 0; STACK_OF(CONF_VALUE) *list = NULL; char *accuracy = NCONF_get_string(conf, section, ENV_ACCURACY); if (accuracy && !(list = X509V3_parse_list(accuracy))) { TS_CONF_invalid(section, ENV_ACCURACY); goto err; } for (i = 0; i < sk_CONF_VALUE_num(list); ++i) { CONF_VALUE *val = sk_CONF_VALUE_value(list, i); if (strcmp(val->name, ENV_VALUE_SECS) == 0) { if (val->value) secs = atoi(val->value); } else if (strcmp(val->name, ENV_VALUE_MILLISECS) == 0) { if (val->value) millis = atoi(val->value); } else if (strcmp(val->name, ENV_VALUE_MICROSECS) == 0) { if (val->value) micros = atoi(val->value); } else { TS_CONF_invalid(section, ENV_ACCURACY); goto err; } } if (!TS_RESP_CTX_set_accuracy(ctx, secs, millis, micros)) goto err; ret = 1; err: sk_CONF_VALUE_pop_free(list, X509V3_conf_free); return ret; } int TS_CONF_set_clock_precision_digits(CONF *conf, const char *section, TS_RESP_CTX *ctx) { int ret = 0; long digits = 0; /* If not specified, set the default value to 0, i.e. sec precision */ if (!NCONF_get_number_e(conf, section, ENV_CLOCK_PRECISION_DIGITS, &digits)) digits = 0; if (digits < 0 || digits > TS_MAX_CLOCK_PRECISION_DIGITS) { TS_CONF_invalid(section, ENV_CLOCK_PRECISION_DIGITS); goto err; } if (!TS_RESP_CTX_set_clock_precision_digits(ctx, digits)) goto err; return 1; err: return ret; } static int TS_CONF_add_flag(CONF *conf, const char *section, const char *field, int flag, TS_RESP_CTX *ctx) { /* Default is false. */ const char *value = NCONF_get_string(conf, section, field); if (value) { if (strcmp(value, ENV_VALUE_YES) == 0) TS_RESP_CTX_add_flags(ctx, flag); else if (strcmp(value, ENV_VALUE_NO) != 0) { TS_CONF_invalid(section, field); return 0; } } return 1; } int TS_CONF_set_ordering(CONF *conf, const char *section, TS_RESP_CTX *ctx) { return TS_CONF_add_flag(conf, section, ENV_ORDERING, TS_ORDERING, ctx); } int TS_CONF_set_tsa_name(CONF *conf, const char *section, TS_RESP_CTX *ctx) { return TS_CONF_add_flag(conf, section, ENV_TSA_NAME, TS_TSA_NAME, ctx); } int TS_CONF_set_ess_cert_id_chain(CONF *conf, const char *section, TS_RESP_CTX *ctx) { return TS_CONF_add_flag(conf, section, ENV_ESS_CERT_ID_CHAIN, TS_ESS_CERT_ID_CHAIN, ctx); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ts/ts_rsp_verify.c0000644000175000017500000005176612360020706021763 0ustar /* $OpenBSD: ts_rsp_verify.c,v 1.11 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include /* Private function declarations. */ static int TS_verify_cert(X509_STORE *store, STACK_OF(X509) *untrusted, X509 *signer, STACK_OF(X509) **chain); static int TS_check_signing_certs(PKCS7_SIGNER_INFO *si, STACK_OF(X509) *chain); static ESS_SIGNING_CERT *ESS_get_signing_cert(PKCS7_SIGNER_INFO *si); static int TS_find_cert(STACK_OF(ESS_CERT_ID) *cert_ids, X509 *cert); static int TS_issuer_serial_cmp(ESS_ISSUER_SERIAL *is, X509_CINF *cinfo); static int int_TS_RESP_verify_token(TS_VERIFY_CTX *ctx, PKCS7 *token, TS_TST_INFO *tst_info); static int TS_check_status_info(TS_RESP *response); static char *TS_get_status_text(STACK_OF(ASN1_UTF8STRING) *text); static int TS_check_policy(ASN1_OBJECT *req_oid, TS_TST_INFO *tst_info); static int TS_compute_imprint(BIO *data, TS_TST_INFO *tst_info, X509_ALGOR **md_alg, unsigned char **imprint, unsigned *imprint_len); static int TS_check_imprints(X509_ALGOR *algor_a, unsigned char *imprint_a, unsigned len_a, TS_TST_INFO *tst_info); static int TS_check_nonces(const ASN1_INTEGER *a, TS_TST_INFO *tst_info); static int TS_check_signer_name(GENERAL_NAME *tsa_name, X509 *signer); static int TS_find_name(STACK_OF(GENERAL_NAME) *gen_names, GENERAL_NAME *name); /* * Local mapping between response codes and descriptions. * Don't forget to change TS_STATUS_BUF_SIZE when modifying * the elements of this array. */ static const char *TS_status_text[] = { "granted", "grantedWithMods", "rejection", "waiting", "revocationWarning", "revocationNotification" }; #define TS_STATUS_TEXT_SIZE (sizeof(TS_status_text)/sizeof(*TS_status_text)) /* * This must be greater or equal to the sum of the strings in TS_status_text * plus the number of its elements. */ #define TS_STATUS_BUF_SIZE 256 static struct { int code; const char *text; } TS_failure_info[] = { { TS_INFO_BAD_ALG, "badAlg" }, { TS_INFO_BAD_REQUEST, "badRequest" }, { TS_INFO_BAD_DATA_FORMAT, "badDataFormat" }, { TS_INFO_TIME_NOT_AVAILABLE, "timeNotAvailable" }, { TS_INFO_UNACCEPTED_POLICY, "unacceptedPolicy" }, { TS_INFO_UNACCEPTED_EXTENSION, "unacceptedExtension" }, { TS_INFO_ADD_INFO_NOT_AVAILABLE, "addInfoNotAvailable" }, { TS_INFO_SYSTEM_FAILURE, "systemFailure" } }; #define TS_FAILURE_INFO_SIZE (sizeof(TS_failure_info) / \ sizeof(*TS_failure_info)) /* Functions for verifying a signed TS_TST_INFO structure. */ /* * This function carries out the following tasks: * - Checks if there is one and only one signer. * - Search for the signing certificate in 'certs' and in the response. * - Check the extended key usage and key usage fields of the signer * certificate (done by the path validation). * - Build and validate the certificate path. * - Check if the certificate path meets the requirements of the * SigningCertificate ESS signed attribute. * - Verify the signature value. * - Returns the signer certificate in 'signer', if 'signer' is not NULL. */ int TS_RESP_verify_signature(PKCS7 *token, STACK_OF(X509) *certs, X509_STORE *store, X509 **signer_out) { STACK_OF(PKCS7_SIGNER_INFO) *sinfos = NULL; PKCS7_SIGNER_INFO *si; STACK_OF(X509) *signers = NULL; X509 *signer; STACK_OF(X509) *chain = NULL; char buf[4096]; int i, j = 0, ret = 0; BIO *p7bio = NULL; /* Some sanity checks first. */ if (!token) { TSerr(TS_F_TS_RESP_VERIFY_SIGNATURE, TS_R_INVALID_NULL_POINTER); goto err; } /* Check for the correct content type */ if (!PKCS7_type_is_signed(token)) { TSerr(TS_F_TS_RESP_VERIFY_SIGNATURE, TS_R_WRONG_CONTENT_TYPE); goto err; } /* Check if there is one and only one signer. */ sinfos = PKCS7_get_signer_info(token); if (!sinfos || sk_PKCS7_SIGNER_INFO_num(sinfos) != 1) { TSerr(TS_F_TS_RESP_VERIFY_SIGNATURE, TS_R_THERE_MUST_BE_ONE_SIGNER); goto err; } si = sk_PKCS7_SIGNER_INFO_value(sinfos, 0); /* Check for no content: no data to verify signature. */ if (PKCS7_get_detached(token)) { TSerr(TS_F_TS_RESP_VERIFY_SIGNATURE, TS_R_NO_CONTENT); goto err; } /* Get hold of the signer certificate, search only internal certificates if it was requested. */ signers = PKCS7_get0_signers(token, certs, 0); if (!signers || sk_X509_num(signers) != 1) goto err; signer = sk_X509_value(signers, 0); /* Now verify the certificate. */ if (!TS_verify_cert(store, certs, signer, &chain)) goto err; /* Check if the signer certificate is consistent with the ESS extension. */ if (!TS_check_signing_certs(si, chain)) goto err; /* Creating the message digest. */ p7bio = PKCS7_dataInit(token, NULL); /* We now have to 'read' from p7bio to calculate digests etc. */ while ((i = BIO_read(p7bio, buf, sizeof(buf))) > 0) ; /* Verifying the signature. */ j = PKCS7_signatureVerify(p7bio, token, si, signer); if (j <= 0) { TSerr(TS_F_TS_RESP_VERIFY_SIGNATURE, TS_R_SIGNATURE_FAILURE); goto err; } /* Return the signer certificate if needed. */ if (signer_out) { *signer_out = signer; CRYPTO_add(&signer->references, 1, CRYPTO_LOCK_X509); } ret = 1; err: BIO_free_all(p7bio); sk_X509_pop_free(chain, X509_free); sk_X509_free(signers); return ret; } /* * The certificate chain is returned in chain. Caller is responsible for * freeing the vector. */ static int TS_verify_cert(X509_STORE *store, STACK_OF(X509) *untrusted, X509 *signer, STACK_OF(X509) **chain) { X509_STORE_CTX cert_ctx; int i; int ret = 1; /* chain is an out argument. */ *chain = NULL; X509_STORE_CTX_init(&cert_ctx, store, signer, untrusted); X509_STORE_CTX_set_purpose(&cert_ctx, X509_PURPOSE_TIMESTAMP_SIGN); i = X509_verify_cert(&cert_ctx); if (i <= 0) { int j = X509_STORE_CTX_get_error(&cert_ctx); TSerr(TS_F_TS_VERIFY_CERT, TS_R_CERTIFICATE_VERIFY_ERROR); ERR_asprintf_error_data("Verify error:%s", X509_verify_cert_error_string(j)); ret = 0; } else { /* Get a copy of the certificate chain. */ *chain = X509_STORE_CTX_get1_chain(&cert_ctx); } X509_STORE_CTX_cleanup(&cert_ctx); return ret; } static int TS_check_signing_certs(PKCS7_SIGNER_INFO *si, STACK_OF(X509) *chain) { ESS_SIGNING_CERT *ss = ESS_get_signing_cert(si); STACK_OF(ESS_CERT_ID) *cert_ids = NULL; X509 *cert; int i = 0; int ret = 0; if (!ss) goto err; cert_ids = ss->cert_ids; /* The signer certificate must be the first in cert_ids. */ cert = sk_X509_value(chain, 0); if (TS_find_cert(cert_ids, cert) != 0) goto err; /* Check the other certificates of the chain if there are more than one certificate ids in cert_ids. */ if (sk_ESS_CERT_ID_num(cert_ids) > 1) { /* All the certificates of the chain must be in cert_ids. */ for (i = 1; i < sk_X509_num(chain); ++i) { cert = sk_X509_value(chain, i); if (TS_find_cert(cert_ids, cert) < 0) goto err; } } ret = 1; err: if (!ret) TSerr(TS_F_TS_CHECK_SIGNING_CERTS, TS_R_ESS_SIGNING_CERTIFICATE_ERROR); ESS_SIGNING_CERT_free(ss); return ret; } static ESS_SIGNING_CERT * ESS_get_signing_cert(PKCS7_SIGNER_INFO *si) { ASN1_TYPE *attr; const unsigned char *p; attr = PKCS7_get_signed_attribute(si, NID_id_smime_aa_signingCertificate); if (!attr) return NULL; p = attr->value.sequence->data; return d2i_ESS_SIGNING_CERT(NULL, &p, attr->value.sequence->length); } /* Returns < 0 if certificate is not found, certificate index otherwise. */ static int TS_find_cert(STACK_OF(ESS_CERT_ID) *cert_ids, X509 *cert) { int i; if (!cert_ids || !cert) return -1; /* Recompute SHA1 hash of certificate if necessary (side effect). */ X509_check_purpose(cert, -1, 0); /* Look for cert in the cert_ids vector. */ for (i = 0; i < sk_ESS_CERT_ID_num(cert_ids); ++i) { ESS_CERT_ID *cid = sk_ESS_CERT_ID_value(cert_ids, i); /* Check the SHA-1 hash first. */ if (cid->hash->length == sizeof(cert->sha1_hash) && !memcmp(cid->hash->data, cert->sha1_hash, sizeof(cert->sha1_hash))) { /* Check the issuer/serial as well if specified. */ ESS_ISSUER_SERIAL *is = cid->issuer_serial; if (!is || !TS_issuer_serial_cmp(is, cert->cert_info)) return i; } } return -1; } static int TS_issuer_serial_cmp(ESS_ISSUER_SERIAL *is, X509_CINF *cinfo) { GENERAL_NAME *issuer; if (!is || !cinfo || sk_GENERAL_NAME_num(is->issuer) != 1) return -1; /* Check the issuer first. It must be a directory name. */ issuer = sk_GENERAL_NAME_value(is->issuer, 0); if (issuer->type != GEN_DIRNAME || X509_NAME_cmp(issuer->d.dirn, cinfo->issuer)) return -1; /* Check the serial number, too. */ if (ASN1_INTEGER_cmp(is->serial, cinfo->serialNumber)) return -1; return 0; } /* * Verifies whether 'response' contains a valid response with regards * to the settings of the context: * - Gives an error message if the TS_TST_INFO is not present. * - Calls _TS_RESP_verify_token to verify the token content. */ int TS_RESP_verify_response(TS_VERIFY_CTX *ctx, TS_RESP *response) { PKCS7 *token = TS_RESP_get_token(response); TS_TST_INFO *tst_info = TS_RESP_get_tst_info(response); int ret = 0; /* Check if we have a successful TS_TST_INFO object in place. */ if (!TS_check_status_info(response)) goto err; /* Check the contents of the time stamp token. */ if (!int_TS_RESP_verify_token(ctx, token, tst_info)) goto err; ret = 1; err: return ret; } /* * Tries to extract a TS_TST_INFO structure from the PKCS7 token and * calls the internal int_TS_RESP_verify_token function for verifying it. */ int TS_RESP_verify_token(TS_VERIFY_CTX *ctx, PKCS7 *token) { TS_TST_INFO *tst_info = PKCS7_to_TS_TST_INFO(token); int ret = 0; if (tst_info) { ret = int_TS_RESP_verify_token(ctx, token, tst_info); TS_TST_INFO_free(tst_info); } return ret; } /* * Verifies whether the 'token' contains a valid time stamp token * with regards to the settings of the context. Only those checks are * carried out that are specified in the context: * - Verifies the signature of the TS_TST_INFO. * - Checks the version number of the response. * - Check if the requested and returned policies math. * - Check if the message imprints are the same. * - Check if the nonces are the same. * - Check if the TSA name matches the signer. * - Check if the TSA name is the expected TSA. */ static int int_TS_RESP_verify_token(TS_VERIFY_CTX *ctx, PKCS7 *token, TS_TST_INFO *tst_info) { X509 *signer = NULL; GENERAL_NAME *tsa_name = TS_TST_INFO_get_tsa(tst_info); X509_ALGOR *md_alg = NULL; unsigned char *imprint = NULL; unsigned imprint_len = 0; int ret = 0; /* Verify the signature. */ if ((ctx->flags & TS_VFY_SIGNATURE) && !TS_RESP_verify_signature(token, ctx->certs, ctx->store, &signer)) goto err; /* Check version number of response. */ if ((ctx->flags & TS_VFY_VERSION) && TS_TST_INFO_get_version(tst_info) != 1) { TSerr(TS_F_INT_TS_RESP_VERIFY_TOKEN, TS_R_UNSUPPORTED_VERSION); goto err; } /* Check policies. */ if ((ctx->flags & TS_VFY_POLICY) && !TS_check_policy(ctx->policy, tst_info)) goto err; /* Check message imprints. */ if ((ctx->flags & TS_VFY_IMPRINT) && !TS_check_imprints(ctx->md_alg, ctx->imprint, ctx->imprint_len, tst_info)) goto err; /* Compute and check message imprints. */ if ((ctx->flags & TS_VFY_DATA) && (!TS_compute_imprint(ctx->data, tst_info, &md_alg, &imprint, &imprint_len) || !TS_check_imprints(md_alg, imprint, imprint_len, tst_info))) goto err; /* Check nonces. */ if ((ctx->flags & TS_VFY_NONCE) && !TS_check_nonces(ctx->nonce, tst_info)) goto err; /* Check whether TSA name and signer certificate match. */ if ((ctx->flags & TS_VFY_SIGNER) && tsa_name && !TS_check_signer_name(tsa_name, signer)) { TSerr(TS_F_INT_TS_RESP_VERIFY_TOKEN, TS_R_TSA_NAME_MISMATCH); goto err; } /* Check whether the TSA is the expected one. */ if ((ctx->flags & TS_VFY_TSA_NAME) && !TS_check_signer_name(ctx->tsa_name, signer)) { TSerr(TS_F_INT_TS_RESP_VERIFY_TOKEN, TS_R_TSA_UNTRUSTED); goto err; } ret = 1; err: X509_free(signer); X509_ALGOR_free(md_alg); free(imprint); return ret; } static int TS_check_status_info(TS_RESP *response) { TS_STATUS_INFO *info = TS_RESP_get_status_info(response); long status = ASN1_INTEGER_get(info->status); const char *status_text = NULL; char *embedded_status_text = NULL; char failure_text[TS_STATUS_BUF_SIZE] = ""; /* Check if everything went fine. */ if (status == 0 || status == 1) return 1; /* There was an error, get the description in status_text. */ if (0 <= status && status < (long)TS_STATUS_TEXT_SIZE) status_text = TS_status_text[status]; else status_text = "unknown code"; /* Set the embedded_status_text to the returned description. */ if (sk_ASN1_UTF8STRING_num(info->text) > 0 && !(embedded_status_text = TS_get_status_text(info->text))) return 0; /* Filling in failure_text with the failure information. */ if (info->failure_info) { int i; int first = 1; for (i = 0; i < (int)TS_FAILURE_INFO_SIZE; ++i) { if (ASN1_BIT_STRING_get_bit(info->failure_info, TS_failure_info[i].code)) { if (!first) strlcat(failure_text, ",", TS_STATUS_BUF_SIZE); else first = 0; strlcat(failure_text, TS_failure_info[i].text, TS_STATUS_BUF_SIZE); } } } if (failure_text[0] == '\0') strlcpy(failure_text, "unspecified", TS_STATUS_BUF_SIZE); /* Making up the error string. */ TSerr(TS_F_TS_CHECK_STATUS_INFO, TS_R_NO_TIME_STAMP_TOKEN); ERR_asprintf_error_data ("status code: %s, status text: %s, failure codes: %s", status_text, embedded_status_text ? embedded_status_text : "unspecified", failure_text); free(embedded_status_text); return 0; } static char * TS_get_status_text(STACK_OF(ASN1_UTF8STRING) *text) { int i; unsigned int length = 0; char *result = NULL; /* Determine length first. */ for (i = 0; i < sk_ASN1_UTF8STRING_num(text); ++i) { ASN1_UTF8STRING *current = sk_ASN1_UTF8STRING_value(text, i); length += ASN1_STRING_length(current); length += 1; /* separator character */ } /* Allocate memory (closing '\0' included). */ if (!(result = malloc(length))) { TSerr(TS_F_TS_GET_STATUS_TEXT, ERR_R_MALLOC_FAILURE); return NULL; } /* Concatenate the descriptions. */ result[0] = '\0'; for (i = 0; i < sk_ASN1_UTF8STRING_num(text); ++i) { ASN1_UTF8STRING *current = sk_ASN1_UTF8STRING_value(text, i); if (i > 0) strlcat(result, "/", length); strlcat(result, (const char *)ASN1_STRING_data(current), length); } return result; } static int TS_check_policy(ASN1_OBJECT *req_oid, TS_TST_INFO *tst_info) { ASN1_OBJECT *resp_oid = TS_TST_INFO_get_policy_id(tst_info); if (OBJ_cmp(req_oid, resp_oid) != 0) { TSerr(TS_F_TS_CHECK_POLICY, TS_R_POLICY_MISMATCH); return 0; } return 1; } static int TS_compute_imprint(BIO *data, TS_TST_INFO *tst_info, X509_ALGOR **md_alg, unsigned char **imprint, unsigned *imprint_len) { TS_MSG_IMPRINT *msg_imprint = TS_TST_INFO_get_msg_imprint(tst_info); X509_ALGOR *md_alg_resp = TS_MSG_IMPRINT_get_algo(msg_imprint); const EVP_MD *md; EVP_MD_CTX md_ctx; unsigned char buffer[4096]; int length; *md_alg = NULL; *imprint = NULL; /* Return the MD algorithm of the response. */ if (!(*md_alg = X509_ALGOR_dup(md_alg_resp))) goto err; /* Getting the MD object. */ if (!(md = EVP_get_digestbyobj((*md_alg)->algorithm))) { TSerr(TS_F_TS_COMPUTE_IMPRINT, TS_R_UNSUPPORTED_MD_ALGORITHM); goto err; } /* Compute message digest. */ length = EVP_MD_size(md); if (length < 0) goto err; *imprint_len = length; if (!(*imprint = malloc(*imprint_len))) { TSerr(TS_F_TS_COMPUTE_IMPRINT, ERR_R_MALLOC_FAILURE); goto err; } if (!EVP_DigestInit(&md_ctx, md)) goto err; while ((length = BIO_read(data, buffer, sizeof(buffer))) > 0) { if (!EVP_DigestUpdate(&md_ctx, buffer, length)) goto err; } if (!EVP_DigestFinal(&md_ctx, *imprint, NULL)) goto err; return 1; err: X509_ALGOR_free(*md_alg); free(*imprint); *imprint = NULL; *imprint_len = 0; return 0; } static int TS_check_imprints(X509_ALGOR *algor_a, unsigned char *imprint_a, unsigned len_a, TS_TST_INFO *tst_info) { TS_MSG_IMPRINT *b = TS_TST_INFO_get_msg_imprint(tst_info); X509_ALGOR *algor_b = TS_MSG_IMPRINT_get_algo(b); int ret = 0; /* algor_a is optional. */ if (algor_a) { /* Compare algorithm OIDs. */ if (OBJ_cmp(algor_a->algorithm, algor_b->algorithm)) goto err; /* The parameter must be NULL in both. */ if ((algor_a->parameter && ASN1_TYPE_get(algor_a->parameter) != V_ASN1_NULL) || (algor_b->parameter && ASN1_TYPE_get(algor_b->parameter) != V_ASN1_NULL)) goto err; } /* Compare octet strings. */ ret = len_a == (unsigned) ASN1_STRING_length(b->hashed_msg) && memcmp(imprint_a, ASN1_STRING_data(b->hashed_msg), len_a) == 0; err: if (!ret) TSerr(TS_F_TS_CHECK_IMPRINTS, TS_R_MESSAGE_IMPRINT_MISMATCH); return ret; } static int TS_check_nonces(const ASN1_INTEGER *a, TS_TST_INFO *tst_info) { const ASN1_INTEGER *b = TS_TST_INFO_get_nonce(tst_info); /* Error if nonce is missing. */ if (!b) { TSerr(TS_F_TS_CHECK_NONCES, TS_R_NONCE_NOT_RETURNED); return 0; } /* No error if a nonce is returned without being requested. */ if (ASN1_INTEGER_cmp(a, b) != 0) { TSerr(TS_F_TS_CHECK_NONCES, TS_R_NONCE_MISMATCH); return 0; } return 1; } /* Check if the specified TSA name matches either the subject or one of the subject alternative names of the TSA certificate. */ static int TS_check_signer_name(GENERAL_NAME *tsa_name, X509 *signer) { STACK_OF(GENERAL_NAME) *gen_names = NULL; int idx = -1; int found = 0; /* Check the subject name first. */ if (tsa_name->type == GEN_DIRNAME && X509_name_cmp(tsa_name->d.dirn, signer->cert_info->subject) == 0) return 1; /* Check all the alternative names. */ gen_names = X509_get_ext_d2i(signer, NID_subject_alt_name, NULL, &idx); while (gen_names != NULL && !(found = TS_find_name(gen_names, tsa_name) >= 0)) { /* Get the next subject alternative name, although there should be no more than one. */ GENERAL_NAMES_free(gen_names); gen_names = X509_get_ext_d2i(signer, NID_subject_alt_name, NULL, &idx); } if (gen_names) GENERAL_NAMES_free(gen_names); return found; } /* Returns 1 if name is in gen_names, 0 otherwise. */ static int TS_find_name(STACK_OF(GENERAL_NAME) *gen_names, GENERAL_NAME *name) { int i, found; for (i = 0, found = 0; !found && i < sk_GENERAL_NAME_num(gen_names); ++i) { GENERAL_NAME *current = sk_GENERAL_NAME_value(gen_names, i); found = GENERAL_NAME_cmp(current, name) == 0; } return found ? i - 1 : -1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ts/ts_err.c0000644000175000017500000002206012360020706020344 0ustar /* $OpenBSD: ts_err.c,v 1.3 2014/06/12 15:49:31 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_TS,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_TS,0,reason) static ERR_STRING_DATA TS_str_functs[] = { {ERR_FUNC(TS_F_D2I_TS_RESP), "d2i_TS_RESP"}, {ERR_FUNC(TS_F_DEF_SERIAL_CB), "DEF_SERIAL_CB"}, {ERR_FUNC(TS_F_DEF_TIME_CB), "DEF_TIME_CB"}, {ERR_FUNC(TS_F_ESS_ADD_SIGNING_CERT), "ESS_ADD_SIGNING_CERT"}, {ERR_FUNC(TS_F_ESS_CERT_ID_NEW_INIT), "ESS_CERT_ID_NEW_INIT"}, {ERR_FUNC(TS_F_ESS_SIGNING_CERT_NEW_INIT), "ESS_SIGNING_CERT_NEW_INIT"}, {ERR_FUNC(TS_F_INT_TS_RESP_VERIFY_TOKEN), "INT_TS_RESP_VERIFY_TOKEN"}, {ERR_FUNC(TS_F_PKCS7_TO_TS_TST_INFO), "PKCS7_to_TS_TST_INFO"}, {ERR_FUNC(TS_F_TS_ACCURACY_SET_MICROS), "TS_ACCURACY_set_micros"}, {ERR_FUNC(TS_F_TS_ACCURACY_SET_MILLIS), "TS_ACCURACY_set_millis"}, {ERR_FUNC(TS_F_TS_ACCURACY_SET_SECONDS), "TS_ACCURACY_set_seconds"}, {ERR_FUNC(TS_F_TS_CHECK_IMPRINTS), "TS_CHECK_IMPRINTS"}, {ERR_FUNC(TS_F_TS_CHECK_NONCES), "TS_CHECK_NONCES"}, {ERR_FUNC(TS_F_TS_CHECK_POLICY), "TS_CHECK_POLICY"}, {ERR_FUNC(TS_F_TS_CHECK_SIGNING_CERTS), "TS_CHECK_SIGNING_CERTS"}, {ERR_FUNC(TS_F_TS_CHECK_STATUS_INFO), "TS_CHECK_STATUS_INFO"}, {ERR_FUNC(TS_F_TS_COMPUTE_IMPRINT), "TS_COMPUTE_IMPRINT"}, {ERR_FUNC(TS_F_TS_CONF_SET_DEFAULT_ENGINE), "TS_CONF_set_default_engine"}, {ERR_FUNC(TS_F_TS_GET_STATUS_TEXT), "TS_GET_STATUS_TEXT"}, {ERR_FUNC(TS_F_TS_MSG_IMPRINT_SET_ALGO), "TS_MSG_IMPRINT_set_algo"}, {ERR_FUNC(TS_F_TS_REQ_SET_MSG_IMPRINT), "TS_REQ_set_msg_imprint"}, {ERR_FUNC(TS_F_TS_REQ_SET_NONCE), "TS_REQ_set_nonce"}, {ERR_FUNC(TS_F_TS_REQ_SET_POLICY_ID), "TS_REQ_set_policy_id"}, {ERR_FUNC(TS_F_TS_RESP_CREATE_RESPONSE), "TS_RESP_create_response"}, {ERR_FUNC(TS_F_TS_RESP_CREATE_TST_INFO), "TS_RESP_CREATE_TST_INFO"}, {ERR_FUNC(TS_F_TS_RESP_CTX_ADD_FAILURE_INFO), "TS_RESP_CTX_add_failure_info"}, {ERR_FUNC(TS_F_TS_RESP_CTX_ADD_MD), "TS_RESP_CTX_add_md"}, {ERR_FUNC(TS_F_TS_RESP_CTX_ADD_POLICY), "TS_RESP_CTX_add_policy"}, {ERR_FUNC(TS_F_TS_RESP_CTX_NEW), "TS_RESP_CTX_new"}, {ERR_FUNC(TS_F_TS_RESP_CTX_SET_ACCURACY), "TS_RESP_CTX_set_accuracy"}, {ERR_FUNC(TS_F_TS_RESP_CTX_SET_CERTS), "TS_RESP_CTX_set_certs"}, {ERR_FUNC(TS_F_TS_RESP_CTX_SET_DEF_POLICY), "TS_RESP_CTX_set_def_policy"}, {ERR_FUNC(TS_F_TS_RESP_CTX_SET_SIGNER_CERT), "TS_RESP_CTX_set_signer_cert"}, {ERR_FUNC(TS_F_TS_RESP_CTX_SET_STATUS_INFO), "TS_RESP_CTX_set_status_info"}, {ERR_FUNC(TS_F_TS_RESP_GET_POLICY), "TS_RESP_GET_POLICY"}, {ERR_FUNC(TS_F_TS_RESP_SET_GENTIME_WITH_PRECISION), "TS_RESP_SET_GENTIME_WITH_PRECISION"}, {ERR_FUNC(TS_F_TS_RESP_SET_STATUS_INFO), "TS_RESP_set_status_info"}, {ERR_FUNC(TS_F_TS_RESP_SET_TST_INFO), "TS_RESP_set_tst_info"}, {ERR_FUNC(TS_F_TS_RESP_SIGN), "TS_RESP_SIGN"}, {ERR_FUNC(TS_F_TS_RESP_VERIFY_SIGNATURE), "TS_RESP_verify_signature"}, {ERR_FUNC(TS_F_TS_RESP_VERIFY_TOKEN), "TS_RESP_verify_token"}, {ERR_FUNC(TS_F_TS_TST_INFO_SET_ACCURACY), "TS_TST_INFO_set_accuracy"}, {ERR_FUNC(TS_F_TS_TST_INFO_SET_MSG_IMPRINT), "TS_TST_INFO_set_msg_imprint"}, {ERR_FUNC(TS_F_TS_TST_INFO_SET_NONCE), "TS_TST_INFO_set_nonce"}, {ERR_FUNC(TS_F_TS_TST_INFO_SET_POLICY_ID), "TS_TST_INFO_set_policy_id"}, {ERR_FUNC(TS_F_TS_TST_INFO_SET_SERIAL), "TS_TST_INFO_set_serial"}, {ERR_FUNC(TS_F_TS_TST_INFO_SET_TIME), "TS_TST_INFO_set_time"}, {ERR_FUNC(TS_F_TS_TST_INFO_SET_TSA), "TS_TST_INFO_set_tsa"}, {ERR_FUNC(TS_F_TS_VERIFY), "TS_VERIFY"}, {ERR_FUNC(TS_F_TS_VERIFY_CERT), "TS_VERIFY_CERT"}, {ERR_FUNC(TS_F_TS_VERIFY_CTX_NEW), "TS_VERIFY_CTX_new"}, {0, NULL} }; static ERR_STRING_DATA TS_str_reasons[]= { {ERR_REASON(TS_R_BAD_PKCS7_TYPE) , "bad pkcs7 type"}, {ERR_REASON(TS_R_BAD_TYPE) , "bad type"}, {ERR_REASON(TS_R_CERTIFICATE_VERIFY_ERROR), "certificate verify error"}, {ERR_REASON(TS_R_COULD_NOT_SET_ENGINE) , "could not set engine"}, {ERR_REASON(TS_R_COULD_NOT_SET_TIME) , "could not set time"}, {ERR_REASON(TS_R_D2I_TS_RESP_INT_FAILED) , "d2i ts resp int failed"}, {ERR_REASON(TS_R_DETACHED_CONTENT) , "detached content"}, {ERR_REASON(TS_R_ESS_ADD_SIGNING_CERT_ERROR), "ess add signing cert error"}, {ERR_REASON(TS_R_ESS_SIGNING_CERTIFICATE_ERROR), "ess signing certificate error"}, {ERR_REASON(TS_R_INVALID_NULL_POINTER) , "invalid null pointer"}, {ERR_REASON(TS_R_INVALID_SIGNER_CERTIFICATE_PURPOSE), "invalid signer certificate purpose"}, {ERR_REASON(TS_R_MESSAGE_IMPRINT_MISMATCH), "message imprint mismatch"}, {ERR_REASON(TS_R_NONCE_MISMATCH) , "nonce mismatch"}, {ERR_REASON(TS_R_NONCE_NOT_RETURNED) , "nonce not returned"}, {ERR_REASON(TS_R_NO_CONTENT) , "no content"}, {ERR_REASON(TS_R_NO_TIME_STAMP_TOKEN) , "no time stamp token"}, {ERR_REASON(TS_R_PKCS7_ADD_SIGNATURE_ERROR), "pkcs7 add signature error"}, {ERR_REASON(TS_R_PKCS7_ADD_SIGNED_ATTR_ERROR), "pkcs7 add signed attr error"}, {ERR_REASON(TS_R_PKCS7_TO_TS_TST_INFO_FAILED), "pkcs7 to ts tst info failed"}, {ERR_REASON(TS_R_POLICY_MISMATCH) , "policy mismatch"}, {ERR_REASON(TS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE), "private key does not match certificate"}, {ERR_REASON(TS_R_RESPONSE_SETUP_ERROR) , "response setup error"}, {ERR_REASON(TS_R_SIGNATURE_FAILURE) , "signature failure"}, {ERR_REASON(TS_R_THERE_MUST_BE_ONE_SIGNER), "there must be one signer"}, {ERR_REASON(TS_R_TIME_SYSCALL_ERROR) , "time syscall error"}, {ERR_REASON(TS_R_TOKEN_NOT_PRESENT) , "token not present"}, {ERR_REASON(TS_R_TOKEN_PRESENT) , "token present"}, {ERR_REASON(TS_R_TSA_NAME_MISMATCH) , "tsa name mismatch"}, {ERR_REASON(TS_R_TSA_UNTRUSTED) , "tsa untrusted"}, {ERR_REASON(TS_R_TST_INFO_SETUP_ERROR) , "tst info setup error"}, {ERR_REASON(TS_R_TS_DATASIGN) , "ts datasign"}, {ERR_REASON(TS_R_UNACCEPTABLE_POLICY) , "unacceptable policy"}, {ERR_REASON(TS_R_UNSUPPORTED_MD_ALGORITHM), "unsupported md algorithm"}, {ERR_REASON(TS_R_UNSUPPORTED_VERSION) , "unsupported version"}, {ERR_REASON(TS_R_WRONG_CONTENT_TYPE) , "wrong content type"}, {0, NULL} }; #endif void ERR_load_TS_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(TS_str_functs[0].error) == NULL) { ERR_load_strings(0, TS_str_functs); ERR_load_strings(0, TS_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ts/ts_req_print.c0000644000175000017500000000720112360020706021557 0ustar /* $OpenBSD: ts_req_print.c,v 1.3 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include /* Function definitions. */ int TS_REQ_print_bio(BIO *bio, TS_REQ *a) { int v; ASN1_OBJECT *policy_id; const ASN1_INTEGER *nonce; if (a == NULL) return 0; v = TS_REQ_get_version(a); BIO_printf(bio, "Version: %d\n", v); TS_MSG_IMPRINT_print_bio(bio, TS_REQ_get_msg_imprint(a)); BIO_printf(bio, "Policy OID: "); policy_id = TS_REQ_get_policy_id(a); if (policy_id == NULL) BIO_printf(bio, "unspecified\n"); else TS_OBJ_print_bio(bio, policy_id); BIO_printf(bio, "Nonce: "); nonce = TS_REQ_get_nonce(a); if (nonce == NULL) BIO_printf(bio, "unspecified"); else TS_ASN1_INTEGER_print_bio(bio, nonce); BIO_write(bio, "\n", 1); BIO_printf(bio, "Certificate required: %s\n", TS_REQ_get_cert_req(a) ? "yes" : "no"); TS_ext_print_bio(bio, TS_REQ_get_exts(a)); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dsa/0000755000000000000000000000000012666635521020621 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/dsa/dsa_asn1.c0000644000175000017500000001367412360020705020672 0ustar /* $OpenBSD: dsa_asn1.c,v 1.11 2014/07/09 10:16:24 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include /* Override the default new methods */ static int sig_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { if (operation == ASN1_OP_NEW_PRE) { DSA_SIG *sig; sig = malloc(sizeof(DSA_SIG)); if (!sig) { DSAerr(DSA_F_SIG_CB, ERR_R_MALLOC_FAILURE); return 0; } sig->r = NULL; sig->s = NULL; *pval = (ASN1_VALUE *)sig; return 2; } return 1; } ASN1_SEQUENCE_cb(DSA_SIG, sig_cb) = { ASN1_SIMPLE(DSA_SIG, r, CBIGNUM), ASN1_SIMPLE(DSA_SIG, s, CBIGNUM) } ASN1_SEQUENCE_END_cb(DSA_SIG, DSA_SIG) IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA_SIG, DSA_SIG, DSA_SIG) /* Override the default free and new methods */ static int dsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { if (operation == ASN1_OP_NEW_PRE) { *pval = (ASN1_VALUE *)DSA_new(); if (*pval) return 2; return 0; } else if (operation == ASN1_OP_FREE_PRE) { DSA_free((DSA *)*pval); *pval = NULL; return 2; } return 1; } ASN1_SEQUENCE_cb(DSAPrivateKey, dsa_cb) = { ASN1_SIMPLE(DSA, version, LONG), ASN1_SIMPLE(DSA, p, BIGNUM), ASN1_SIMPLE(DSA, q, BIGNUM), ASN1_SIMPLE(DSA, g, BIGNUM), ASN1_SIMPLE(DSA, pub_key, BIGNUM), ASN1_SIMPLE(DSA, priv_key, BIGNUM) } ASN1_SEQUENCE_END_cb(DSA, DSAPrivateKey) IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAPrivateKey, DSAPrivateKey) ASN1_SEQUENCE_cb(DSAparams, dsa_cb) = { ASN1_SIMPLE(DSA, p, BIGNUM), ASN1_SIMPLE(DSA, q, BIGNUM), ASN1_SIMPLE(DSA, g, BIGNUM), } ASN1_SEQUENCE_END_cb(DSA, DSAparams) IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAparams, DSAparams) /* * DSA public key is a bit trickier... its effectively a CHOICE type * decided by a field called write_params which can either write out * just the public key as an INTEGER or the parameters and public key * in a SEQUENCE */ ASN1_SEQUENCE(dsa_pub_internal) = { ASN1_SIMPLE(DSA, pub_key, BIGNUM), ASN1_SIMPLE(DSA, p, BIGNUM), ASN1_SIMPLE(DSA, q, BIGNUM), ASN1_SIMPLE(DSA, g, BIGNUM) } ASN1_SEQUENCE_END_name(DSA, dsa_pub_internal) ASN1_CHOICE_cb(DSAPublicKey, dsa_cb) = { ASN1_SIMPLE(DSA, pub_key, BIGNUM), ASN1_EX_COMBINE(0, 0, dsa_pub_internal) } ASN1_CHOICE_END_cb(DSA, DSAPublicKey, write_params) IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAPublicKey, DSAPublicKey) DSA * DSAparams_dup(DSA *dsa) { return ASN1_item_dup(ASN1_ITEM_rptr(DSAparams), dsa); } int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, unsigned int *siglen, DSA *dsa) { DSA_SIG *s; s = DSA_do_sign(dgst, dlen, dsa); if (s == NULL) { *siglen = 0; return 0; } *siglen = i2d_DSA_SIG(s,&sig); DSA_SIG_free(s); return 1; } /* * data has already been hashed (probably with SHA or SHA-1). * returns * 1: correct signature * 0: incorrect signature * -1: error */ int DSA_verify(int type, const unsigned char *dgst, int dgst_len, const unsigned char *sigbuf, int siglen, DSA *dsa) { DSA_SIG *s; int ret = -1; s = DSA_SIG_new(); if (s == NULL) return ret; if (d2i_DSA_SIG(&s, &sigbuf, siglen) == NULL) goto err; ret = DSA_do_verify(dgst, dgst_len, s, dsa); err: DSA_SIG_free(s); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dsa/dsa_sign.c0000644000175000017500000000752712360020705020770 0ustar /* $OpenBSD: dsa_sign.c,v 1.16 2014/07/09 10:16:24 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* Original version from Steven Schoch */ #include #include #include DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) { return dsa->meth->dsa_do_sign(dgst, dlen, dsa); } int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) { return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp); } DSA_SIG * DSA_SIG_new(void) { DSA_SIG *sig; sig = malloc(sizeof(DSA_SIG)); if (!sig) return NULL; sig->r = NULL; sig->s = NULL; return sig; } void DSA_SIG_free(DSA_SIG *sig) { if (sig) { if (sig->r) BN_free(sig->r); if (sig->s) BN_free(sig->s); free(sig); } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dsa/dsa_ameth.c0000644000175000017500000003716412360020705021126 0ustar /* $OpenBSD: dsa_ameth.c,v 1.11 2014/07/10 22:45:56 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #ifndef OPENSSL_NO_CMS #include #endif #include "asn1_locl.h" static int dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) { const unsigned char *p, *pm; int pklen, pmlen; int ptype; void *pval; ASN1_STRING *pstr; X509_ALGOR *palg; ASN1_INTEGER *public_key = NULL; DSA *dsa = NULL; if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, &palg, pubkey)) return 0; X509_ALGOR_get0(NULL, &ptype, &pval, palg); if (ptype == V_ASN1_SEQUENCE) { pstr = pval; pm = pstr->data; pmlen = pstr->length; if (!(dsa = d2i_DSAparams(NULL, &pm, pmlen))) { DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_DECODE_ERROR); goto err; } } else if (ptype == V_ASN1_NULL || ptype == V_ASN1_UNDEF) { if (!(dsa = DSA_new())) { DSAerr(DSA_F_DSA_PUB_DECODE, ERR_R_MALLOC_FAILURE); goto err; } } else { DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_PARAMETER_ENCODING_ERROR); goto err; } if (!(public_key=d2i_ASN1_INTEGER(NULL, &p, pklen))) { DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_DECODE_ERROR); goto err; } if (!(dsa->pub_key = ASN1_INTEGER_to_BN(public_key, NULL))) { DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_BN_DECODE_ERROR); goto err; } ASN1_INTEGER_free(public_key); EVP_PKEY_assign_DSA(pkey, dsa); return 1; err: if (public_key) ASN1_INTEGER_free(public_key); if (dsa) DSA_free(dsa); return 0; } static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) { DSA *dsa; void *pval = NULL; int ptype; unsigned char *penc = NULL; int penclen; dsa = pkey->pkey.dsa; if (pkey->save_parameters && dsa->p && dsa->q && dsa->g) { ASN1_STRING *str; str = ASN1_STRING_new(); str->length = i2d_DSAparams(dsa, &str->data); if (str->length <= 0) { DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE); goto err; } pval = str; ptype = V_ASN1_SEQUENCE; } else ptype = V_ASN1_UNDEF; dsa->write_params = 0; penclen = i2d_DSAPublicKey(dsa, &penc); if (penclen <= 0) { DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE); goto err; } if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_DSA), ptype, pval, penc, penclen)) return 1; err: free(penc); ASN1_STRING_free(pval); return 0; } /* In PKCS#8 DSA: you just get a private key integer and parameters in the * AlgorithmIdentifier the pubkey must be recalculated. */ static int dsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8) { const unsigned char *p, *pm; int pklen, pmlen; int ptype; void *pval; ASN1_STRING *pstr; X509_ALGOR *palg; ASN1_INTEGER *privkey = NULL; BN_CTX *ctx = NULL; STACK_OF(ASN1_TYPE) *ndsa = NULL; DSA *dsa = NULL; if (!PKCS8_pkey_get0(NULL, &p, &pklen, &palg, p8)) return 0; X509_ALGOR_get0(NULL, &ptype, &pval, palg); /* Check for broken DSA PKCS#8, UGH! */ if (*p == (V_ASN1_SEQUENCE|V_ASN1_CONSTRUCTED)) { ASN1_TYPE *t1, *t2; if (!(ndsa = d2i_ASN1_SEQUENCE_ANY(NULL, &p, pklen))) goto decerr; if (sk_ASN1_TYPE_num(ndsa) != 2) goto decerr; /* * Handle Two broken types: * SEQUENCE {parameters, priv_key} * SEQUENCE {pub_key, priv_key} */ t1 = sk_ASN1_TYPE_value(ndsa, 0); t2 = sk_ASN1_TYPE_value(ndsa, 1); if (t1->type == V_ASN1_SEQUENCE) { p8->broken = PKCS8_EMBEDDED_PARAM; pval = t1->value.ptr; } else if (ptype == V_ASN1_SEQUENCE) p8->broken = PKCS8_NS_DB; else goto decerr; if (t2->type != V_ASN1_INTEGER) goto decerr; privkey = t2->value.integer; } else { const unsigned char *q = p; if (!(privkey=d2i_ASN1_INTEGER(NULL, &p, pklen))) goto decerr; if (privkey->type == V_ASN1_NEG_INTEGER) { p8->broken = PKCS8_NEG_PRIVKEY; ASN1_INTEGER_free(privkey); if (!(privkey = d2i_ASN1_UINTEGER(NULL, &q, pklen))) goto decerr; } if (ptype != V_ASN1_SEQUENCE) goto decerr; } pstr = pval; pm = pstr->data; pmlen = pstr->length; if (!(dsa = d2i_DSAparams(NULL, &pm, pmlen))) goto decerr; /* We have parameters now set private key */ if (!(dsa->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) { DSAerr(DSA_F_DSA_PRIV_DECODE,DSA_R_BN_ERROR); goto dsaerr; } /* Calculate public key */ if (!(dsa->pub_key = BN_new())) { DSAerr(DSA_F_DSA_PRIV_DECODE, ERR_R_MALLOC_FAILURE); goto dsaerr; } if (!(ctx = BN_CTX_new())) { DSAerr(DSA_F_DSA_PRIV_DECODE, ERR_R_MALLOC_FAILURE); goto dsaerr; } if (!BN_mod_exp(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, ctx)) { DSAerr(DSA_F_DSA_PRIV_DECODE,DSA_R_BN_ERROR); goto dsaerr; } EVP_PKEY_assign_DSA(pkey, dsa); BN_CTX_free (ctx); if (ndsa) sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); else ASN1_INTEGER_free(privkey); return 1; decerr: DSAerr(DSA_F_DSA_PRIV_DECODE, EVP_R_DECODE_ERROR); dsaerr: BN_CTX_free (ctx); if (privkey) ASN1_INTEGER_free(privkey); sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); DSA_free(dsa); return 0; } static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) { ASN1_STRING *params = NULL; ASN1_INTEGER *prkey = NULL; unsigned char *dp = NULL; int dplen; params = ASN1_STRING_new(); if (!params) { DSAerr(DSA_F_DSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); goto err; } params->length = i2d_DSAparams(pkey->pkey.dsa, ¶ms->data); if (params->length <= 0) { DSAerr(DSA_F_DSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); goto err; } params->type = V_ASN1_SEQUENCE; /* Get private key into integer */ prkey = BN_to_ASN1_INTEGER(pkey->pkey.dsa->priv_key, NULL); if (!prkey) { DSAerr(DSA_F_DSA_PRIV_ENCODE, DSA_R_BN_ERROR); goto err; } dplen = i2d_ASN1_INTEGER(prkey, &dp); ASN1_INTEGER_free(prkey); if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(NID_dsa), 0, V_ASN1_SEQUENCE, params, dp, dplen)) goto err; return 1; err: free(dp); ASN1_STRING_free(params); ASN1_INTEGER_free(prkey); return 0; } static int int_dsa_size(const EVP_PKEY *pkey) { return DSA_size(pkey->pkey.dsa); } static int dsa_bits(const EVP_PKEY *pkey) { return BN_num_bits(pkey->pkey.dsa->p); } static int dsa_missing_parameters(const EVP_PKEY *pkey) { DSA *dsa; dsa = pkey->pkey.dsa; if (dsa->p == NULL || dsa->q == NULL || dsa->g == NULL) return 1; return 0; } static int dsa_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from) { BIGNUM *a; if ((a = BN_dup(from->pkey.dsa->p)) == NULL) return 0; if (to->pkey.dsa->p != NULL) BN_free(to->pkey.dsa->p); to->pkey.dsa->p = a; if ((a = BN_dup(from->pkey.dsa->q)) == NULL) return 0; if (to->pkey.dsa->q != NULL) BN_free(to->pkey.dsa->q); to->pkey.dsa->q = a; if ((a = BN_dup(from->pkey.dsa->g)) == NULL) return 0; if (to->pkey.dsa->g != NULL) BN_free(to->pkey.dsa->g); to->pkey.dsa->g = a; return 1; } static int dsa_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b) { if (BN_cmp(a->pkey.dsa->p, b->pkey.dsa->p) || BN_cmp(a->pkey.dsa->q, b->pkey.dsa->q) || BN_cmp(a->pkey.dsa->g, b->pkey.dsa->g)) return 0; else return 1; } static int dsa_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b) { if (BN_cmp(b->pkey.dsa->pub_key, a->pkey.dsa->pub_key) != 0) return 0; else return 1; } static void int_dsa_free(EVP_PKEY *pkey) { DSA_free(pkey->pkey.dsa); } static void update_buflen(const BIGNUM *b, size_t *pbuflen) { size_t i; if (!b) return; if (*pbuflen < (i = (size_t)BN_num_bytes(b))) *pbuflen = i; } static int do_dsa_print(BIO *bp, const DSA *x, int off, int ptype) { unsigned char *m = NULL; int ret = 0; size_t buf_len = 0; const char *ktype = NULL; const BIGNUM *priv_key, *pub_key; if (ptype == 2) priv_key = x->priv_key; else priv_key = NULL; if (ptype > 0) pub_key = x->pub_key; else pub_key = NULL; if (ptype == 2) ktype = "Private-Key"; else if (ptype == 1) ktype = "Public-Key"; else ktype = "DSA-Parameters"; update_buflen(x->p, &buf_len); update_buflen(x->q, &buf_len); update_buflen(x->g, &buf_len); update_buflen(priv_key, &buf_len); update_buflen(pub_key, &buf_len); m = malloc(buf_len + 10); if (m == NULL) { DSAerr(DSA_F_DO_DSA_PRINT, ERR_R_MALLOC_FAILURE); goto err; } if (priv_key) { if (!BIO_indent(bp, off, 128)) goto err; if (BIO_printf(bp, "%s: (%d bit)\n", ktype, BN_num_bits(x->p)) <= 0) goto err; } if (!ASN1_bn_print(bp, "priv:", priv_key, m, off)) goto err; if (!ASN1_bn_print(bp, "pub: ", pub_key, m, off)) goto err; if (!ASN1_bn_print(bp, "P: ", x->p, m, off)) goto err; if (!ASN1_bn_print(bp, "Q: ", x->q, m, off)) goto err; if (!ASN1_bn_print(bp, "G: ", x->g, m, off)) goto err; ret = 1; err: free(m); return(ret); } static int dsa_param_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) { DSA *dsa; if (!(dsa = d2i_DSAparams(NULL, pder, derlen))) { DSAerr(DSA_F_DSA_PARAM_DECODE, ERR_R_DSA_LIB); return 0; } EVP_PKEY_assign_DSA(pkey, dsa); return 1; } static int dsa_param_encode(const EVP_PKEY *pkey, unsigned char **pder) { return i2d_DSAparams(pkey->pkey.dsa, pder); } static int dsa_param_print(BIO *bp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx) { return do_dsa_print(bp, pkey->pkey.dsa, indent, 0); } static int dsa_pub_print(BIO *bp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx) { return do_dsa_print(bp, pkey->pkey.dsa, indent, 1); } static int dsa_priv_print(BIO *bp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx) { return do_dsa_print(bp, pkey->pkey.dsa, indent, 2); } static int old_dsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) { DSA *dsa; if (!(dsa = d2i_DSAPrivateKey (NULL, pder, derlen))) { DSAerr(DSA_F_OLD_DSA_PRIV_DECODE, ERR_R_DSA_LIB); return 0; } EVP_PKEY_assign_DSA(pkey, dsa); return 1; } static int old_dsa_priv_encode(const EVP_PKEY *pkey, unsigned char **pder) { return i2d_DSAPrivateKey(pkey->pkey.dsa, pder); } static int dsa_sig_print(BIO *bp, const X509_ALGOR *sigalg, const ASN1_STRING *sig, int indent, ASN1_PCTX *pctx) { DSA_SIG *dsa_sig; const unsigned char *p; if (!sig) { if (BIO_puts(bp, "\n") <= 0) return 0; else return 1; } p = sig->data; dsa_sig = d2i_DSA_SIG(NULL, &p, sig->length); if (dsa_sig) { int rv = 0; size_t buf_len = 0; unsigned char *m = NULL; update_buflen(dsa_sig->r, &buf_len); update_buflen(dsa_sig->s, &buf_len); m = malloc(buf_len + 10); if (m == NULL) { DSAerr(DSA_F_DSA_SIG_PRINT, ERR_R_MALLOC_FAILURE); goto err; } if (BIO_write(bp, "\n", 1) != 1) goto err; if (!ASN1_bn_print(bp, "r: ", dsa_sig->r, m, indent)) goto err; if (!ASN1_bn_print(bp, "s: ", dsa_sig->s, m, indent)) goto err; rv = 1; err: free(m); DSA_SIG_free(dsa_sig); return rv; } return X509_signature_dump(bp, sig, indent); } static int dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) { switch (op) { case ASN1_PKEY_CTRL_PKCS7_SIGN: if (arg1 == 0) { int snid, hnid; X509_ALGOR *alg1, *alg2; PKCS7_SIGNER_INFO_get0_algs(arg2, NULL, &alg1, &alg2); if (alg1 == NULL || alg1->algorithm == NULL) return -1; hnid = OBJ_obj2nid(alg1->algorithm); if (hnid == NID_undef) return -1; if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) return -1; X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); } return 1; #ifndef OPENSSL_NO_CMS case ASN1_PKEY_CTRL_CMS_SIGN: if (arg1 == 0) { int snid, hnid; X509_ALGOR *alg1, *alg2; CMS_SignerInfo_get0_algs(arg2, NULL, NULL, &alg1, &alg2); if (alg1 == NULL || alg1->algorithm == NULL) return -1; hnid = OBJ_obj2nid(alg1->algorithm); if (hnid == NID_undef) return -1; if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) return -1; X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); } return 1; #endif case ASN1_PKEY_CTRL_DEFAULT_MD_NID: *(int *)arg2 = NID_sha1; return 2; default: return -2; } } /* NB these are sorted in pkey_id order, lowest first */ const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[] = { { .pkey_id = EVP_PKEY_DSA2, .pkey_base_id = EVP_PKEY_DSA, .pkey_flags = ASN1_PKEY_ALIAS }, { .pkey_id = EVP_PKEY_DSA1, .pkey_base_id = EVP_PKEY_DSA, .pkey_flags = ASN1_PKEY_ALIAS }, { .pkey_id = EVP_PKEY_DSA4, .pkey_base_id = EVP_PKEY_DSA, .pkey_flags = ASN1_PKEY_ALIAS }, { .pkey_id = EVP_PKEY_DSA3, .pkey_base_id = EVP_PKEY_DSA, .pkey_flags = ASN1_PKEY_ALIAS }, { .pkey_id = EVP_PKEY_DSA, .pkey_base_id = EVP_PKEY_DSA, .pem_str = "DSA", .info = "OpenSSL DSA method", .pub_decode = dsa_pub_decode, .pub_encode = dsa_pub_encode, .pub_cmp = dsa_pub_cmp, .pub_print = dsa_pub_print, .priv_decode = dsa_priv_decode, .priv_encode = dsa_priv_encode, .priv_print = dsa_priv_print, .pkey_size = int_dsa_size, .pkey_bits = dsa_bits, .param_decode = dsa_param_decode, .param_encode = dsa_param_encode, .param_missing = dsa_missing_parameters, .param_copy = dsa_copy_parameters, .param_cmp = dsa_cmp_parameters, .param_print = dsa_param_print, .sig_print = dsa_sig_print, .pkey_free = int_dsa_free, .pkey_ctrl = dsa_pkey_ctrl, .old_priv_decode = old_dsa_priv_decode, .old_priv_encode = old_dsa_priv_encode } }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dsa/dsa_locl.h0000644000175000017500000000550512360020705020760 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, const EVP_MD *evpmd, const unsigned char *seed_in, size_t seed_len, unsigned char *seed_out, int *counter_ret, unsigned long *h_ret, BN_GENCB *cb); deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dsa/dsa_lib.c0000644000175000017500000001777012360020705020577 0ustar /* $OpenBSD: dsa_lib.c,v 1.19 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* Original version from Steven Schoch */ #include #include #include #include #include #ifndef OPENSSL_NO_DH #include #endif #ifndef OPENSSL_NO_ENGINE #include #endif static const DSA_METHOD *default_DSA_method = NULL; void DSA_set_default_method(const DSA_METHOD *meth) { default_DSA_method = meth; } const DSA_METHOD * DSA_get_default_method(void) { if (!default_DSA_method) default_DSA_method = DSA_OpenSSL(); return default_DSA_method; } DSA * DSA_new(void) { return DSA_new_method(NULL); } int DSA_set_method(DSA *dsa, const DSA_METHOD *meth) { /* * NB: The caller is specifically setting a method, so it's not up to us * to deal with which ENGINE it comes from. */ const DSA_METHOD *mtmp; mtmp = dsa->meth; if (mtmp->finish) mtmp->finish(dsa); #ifndef OPENSSL_NO_ENGINE if (dsa->engine) { ENGINE_finish(dsa->engine); dsa->engine = NULL; } #endif dsa->meth = meth; if (meth->init) meth->init(dsa); return 1; } DSA * DSA_new_method(ENGINE *engine) { DSA *ret; ret = malloc(sizeof(DSA)); if (ret == NULL) { DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_MALLOC_FAILURE); return NULL; } ret->meth = DSA_get_default_method(); #ifndef OPENSSL_NO_ENGINE if (engine) { if (!ENGINE_init(engine)) { DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_ENGINE_LIB); free(ret); return NULL; } ret->engine = engine; } else ret->engine = ENGINE_get_default_DSA(); if (ret->engine) { ret->meth = ENGINE_get_DSA(ret->engine); if (!ret->meth) { DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_ENGINE_LIB); ENGINE_finish(ret->engine); free(ret); return NULL; } } #endif ret->pad = 0; ret->version = 0; ret->write_params = 1; ret->p = NULL; ret->q = NULL; ret->g = NULL; ret->pub_key = NULL; ret->priv_key = NULL; ret->kinv = NULL; ret->r = NULL; ret->method_mont_p = NULL; ret->references = 1; ret->flags = ret->meth->flags & ~DSA_FLAG_NON_FIPS_ALLOW; CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); if (ret->meth->init != NULL && !ret->meth->init(ret)) { #ifndef OPENSSL_NO_ENGINE if (ret->engine) ENGINE_finish(ret->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); free(ret); ret = NULL; } return ret; } void DSA_free(DSA *r) { int i; if (r == NULL) return; i = CRYPTO_add(&r->references, -1, CRYPTO_LOCK_DSA); if (i > 0) return; if (r->meth->finish) r->meth->finish(r); #ifndef OPENSSL_NO_ENGINE if (r->engine) ENGINE_finish(r->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data); if (r->p != NULL) BN_clear_free(r->p); if (r->q != NULL) BN_clear_free(r->q); if (r->g != NULL) BN_clear_free(r->g); if (r->pub_key != NULL) BN_clear_free(r->pub_key); if (r->priv_key != NULL) BN_clear_free(r->priv_key); if (r->kinv != NULL) BN_clear_free(r->kinv); if (r->r != NULL) BN_clear_free(r->r); free(r); } int DSA_up_ref(DSA *r) { int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_DSA); return i > 1 ? 1 : 0; } int DSA_size(const DSA *r) { int ret, i; ASN1_INTEGER bs; unsigned char buf[4]; /* 4 bytes looks really small. However, i2d_ASN1_INTEGER() will not look beyond the first byte, as long as the second parameter is NULL. */ i = BN_num_bits(r->q); bs.length = (i + 7) / 8; bs.data = buf; bs.type = V_ASN1_INTEGER; /* If the top bit is set the asn1 encoding is 1 larger. */ buf[0] = 0xff; i = i2d_ASN1_INTEGER(&bs, NULL); i += i; /* r and s */ ret = ASN1_object_size(1, i, V_ASN1_SEQUENCE); return ret; } int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DSA, argl, argp, new_func, dup_func, free_func); } int DSA_set_ex_data(DSA *d, int idx, void *arg) { return CRYPTO_set_ex_data(&d->ex_data, idx, arg); } void * DSA_get_ex_data(DSA *d, int idx) { return CRYPTO_get_ex_data(&d->ex_data, idx); } #ifndef OPENSSL_NO_DH DH * DSA_dup_DH(const DSA *r) { /* * DSA has p, q, g, optional pub_key, optional priv_key. * DH has p, optional length, g, optional pub_key, optional priv_key, * optional q. */ DH *ret = NULL; if (r == NULL) goto err; ret = DH_new(); if (ret == NULL) goto err; if (r->p != NULL) if ((ret->p = BN_dup(r->p)) == NULL) goto err; if (r->q != NULL) { ret->length = BN_num_bits(r->q); if ((ret->q = BN_dup(r->q)) == NULL) goto err; } if (r->g != NULL) if ((ret->g = BN_dup(r->g)) == NULL) goto err; if (r->pub_key != NULL) if ((ret->pub_key = BN_dup(r->pub_key)) == NULL) goto err; if (r->priv_key != NULL) if ((ret->priv_key = BN_dup(r->priv_key)) == NULL) goto err; return ret; err: if (ret != NULL) DH_free(ret); return NULL; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dsa/dsa_prn.c0000644000175000017500000000746212360020705020625 0ustar /* $OpenBSD: dsa_prn.c,v 1.4 2014/07/09 10:16:24 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include int DSA_print_fp(FILE *fp, const DSA *x, int off) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { DSAerr(DSA_F_DSA_PRINT_FP, ERR_R_BUF_LIB); return 0; } BIO_set_fp(b, fp, BIO_NOCLOSE); ret = DSA_print(b, x, off); BIO_free(b); return ret; } int DSAparams_print_fp(FILE *fp, const DSA *x) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { DSAerr(DSA_F_DSAPARAMS_PRINT_FP, ERR_R_BUF_LIB); return 0; } BIO_set_fp(b, fp, BIO_NOCLOSE); ret = DSAparams_print(b, x); BIO_free(b); return ret; } int DSA_print(BIO *bp, const DSA *x, int off) { EVP_PKEY *pk; int ret; pk = EVP_PKEY_new(); if (!pk || !EVP_PKEY_set1_DSA(pk, (DSA *)x)) return 0; ret = EVP_PKEY_print_private(bp, pk, off, NULL); EVP_PKEY_free(pk); return ret; } int DSAparams_print(BIO *bp, const DSA *x) { EVP_PKEY *pk; int ret; pk = EVP_PKEY_new(); if (!pk || !EVP_PKEY_set1_DSA(pk, (DSA *)x)) return 0; ret = EVP_PKEY_print_params(bp, pk, 4, NULL); EVP_PKEY_free(pk); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dsa/dsa_vrf.c0000644000175000017500000000662612360020705020624 0ustar /* $OpenBSD: dsa_vrf.c,v 1.15 2014/07/09 10:16:24 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* Original version from Steven Schoch */ #include int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) { return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dsa/dsa_key.c0000644000175000017500000001101612360020705020604 0ustar /* $OpenBSD: dsa_key.c,v 1.17 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #ifndef OPENSSL_NO_SHA #include #include #include static int dsa_builtin_keygen(DSA *dsa); int DSA_generate_key(DSA *dsa) { if (dsa->meth->dsa_keygen) return dsa->meth->dsa_keygen(dsa); return dsa_builtin_keygen(dsa); } static int dsa_builtin_keygen(DSA *dsa) { int ok = 0; BN_CTX *ctx = NULL; BIGNUM *pub_key = NULL, *priv_key = NULL; if ((ctx = BN_CTX_new()) == NULL) goto err; if (dsa->priv_key == NULL) { if ((priv_key = BN_new()) == NULL) goto err; } else priv_key=dsa->priv_key; do { if (!BN_rand_range(priv_key, dsa->q)) goto err; } while (BN_is_zero(priv_key)); if (dsa->pub_key == NULL) { if ((pub_key = BN_new()) == NULL) goto err; } else pub_key=dsa->pub_key; { BIGNUM local_prk; BIGNUM *prk; if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0) { BN_init(&local_prk); prk = &local_prk; BN_with_flags(prk, priv_key, BN_FLG_CONSTTIME); } else prk = priv_key; if (!BN_mod_exp(pub_key, dsa->g, prk, dsa->p, ctx)) goto err; } dsa->priv_key = priv_key; dsa->pub_key = pub_key; ok = 1; err: if (pub_key != NULL && dsa->pub_key == NULL) BN_free(pub_key); if (priv_key != NULL && dsa->priv_key == NULL) BN_free(priv_key); if (ctx != NULL) BN_CTX_free(ctx); return ok; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dsa/dsa_depr.c0000644000175000017500000000665112360020705020757 0ustar /* $OpenBSD: dsa_depr.c,v 1.5 2014/07/10 22:45:56 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* This file contains deprecated function(s) that are now wrappers to the new * version(s). */ #include #include #include #ifndef OPENSSL_NO_SHA #include #include #include #include #include #ifndef OPENSSL_NO_DEPRECATED DSA * DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len, int *counter_ret, unsigned long *h_ret, void (*callback)(int, int, void *), void *cb_arg) { BN_GENCB cb; DSA *ret; if ((ret = DSA_new()) == NULL) return NULL; BN_GENCB_set_old(&cb, callback, cb_arg); if (DSA_generate_parameters_ex(ret, bits, seed_in, seed_len, counter_ret, h_ret, &cb)) return ret; DSA_free(ret); return NULL; } #endif #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dsa/dsa_ossl.c0000644000175000017500000002636712360020705021013 0ustar /* $OpenBSD: dsa_ossl.c,v 1.19 2014/07/09 10:16:24 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* Original version from Steven Schoch */ #include #include #include #include #include #include #include static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa); static int dsa_init(DSA *dsa); static int dsa_finish(DSA *dsa); static DSA_METHOD openssl_dsa_meth = { .name = "OpenSSL DSA method", .dsa_do_sign = dsa_do_sign, .dsa_sign_setup = dsa_sign_setup, .dsa_do_verify = dsa_do_verify, .init = dsa_init, .finish = dsa_finish }; /* * These macro wrappers replace attempts to use the dsa_mod_exp() and * bn_mod_exp() handlers in the DSA_METHOD structure. We avoid the problem of * having a the macro work as an expression by bundling an "err_instr". So; * * if (!dsa->meth->bn_mod_exp(dsa, r,dsa->g,&k,dsa->p,ctx, * dsa->method_mont_p)) goto err; * * can be replaced by; * * DSA_BN_MOD_EXP(goto err, dsa, r, dsa->g, &k, dsa->p, ctx, * dsa->method_mont_p); */ #define DSA_MOD_EXP(err_instr,dsa,rr,a1,p1,a2,p2,m,ctx,in_mont) \ do { \ int _tmp_res53; \ if ((dsa)->meth->dsa_mod_exp) \ _tmp_res53 = (dsa)->meth->dsa_mod_exp((dsa), (rr), \ (a1), (p1), (a2), (p2), (m), (ctx), (in_mont)); \ else \ _tmp_res53 = BN_mod_exp2_mont((rr), (a1), \ (p1), (a2), (p2), (m), (ctx), (in_mont)); \ if (!_tmp_res53) \ err_instr; \ } while(0) #define DSA_BN_MOD_EXP(err_instr,dsa,r,a,p,m,ctx,m_ctx) \ do { \ int _tmp_res53; \ if ((dsa)->meth->bn_mod_exp) \ _tmp_res53 = (dsa)->meth->bn_mod_exp((dsa), (r), \ (a), (p), (m), (ctx), (m_ctx)); \ else \ _tmp_res53 = BN_mod_exp_mont((r), (a), (p), (m), \ (ctx), (m_ctx)); \ if (!_tmp_res53) \ err_instr; \ } while(0) const DSA_METHOD * DSA_OpenSSL(void) { return &openssl_dsa_meth; } static DSA_SIG * dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) { BIGNUM *kinv = NULL, *r = NULL, *s = NULL; BIGNUM m; BIGNUM xr; BN_CTX *ctx = NULL; int reason = ERR_R_BN_LIB; DSA_SIG *ret = NULL; int noredo = 0; BN_init(&m); BN_init(&xr); if (!dsa->p || !dsa->q || !dsa->g) { reason = DSA_R_MISSING_PARAMETERS; goto err; } s = BN_new(); if (s == NULL) goto err; ctx = BN_CTX_new(); if (ctx == NULL) goto err; redo: if (dsa->kinv == NULL || dsa->r == NULL) { if (!DSA_sign_setup(dsa, ctx, &kinv, &r)) goto err; } else { kinv = dsa->kinv; dsa->kinv = NULL; r = dsa->r; dsa->r = NULL; noredo = 1; } /* * If the digest length is greater than the size of q use the * BN_num_bits(dsa->q) leftmost bits of the digest, see * fips 186-3, 4.2 */ if (dlen > BN_num_bytes(dsa->q)) dlen = BN_num_bytes(dsa->q); if (BN_bin2bn(dgst,dlen,&m) == NULL) goto err; /* Compute s = inv(k) (m + xr) mod q */ if (!BN_mod_mul(&xr, dsa->priv_key, r, dsa->q, ctx)) /* s = xr */ goto err; if (!BN_add(s, &xr, &m)) /* s = m + xr */ goto err; if (BN_cmp(s, dsa->q) > 0) if (!BN_sub(s, s, dsa->q)) goto err; if (!BN_mod_mul(s, s, kinv, dsa->q, ctx)) goto err; ret = DSA_SIG_new(); if (ret == NULL) goto err; /* * Redo if r or s is zero as required by FIPS 186-3: this is * very unlikely. */ if (BN_is_zero(r) || BN_is_zero(s)) { if (noredo) { reason = DSA_R_NEED_NEW_SETUP_VALUES; goto err; } goto redo; } ret->r = r; ret->s = s; err: if (!ret) { DSAerr(DSA_F_DSA_DO_SIGN, reason); BN_free(r); BN_free(s); } if (ctx != NULL) BN_CTX_free(ctx); BN_clear_free(&m); BN_clear_free(&xr); if (kinv != NULL) /* dsa->kinv is NULL now if we used it */ BN_clear_free(kinv); return ret; } static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) { BN_CTX *ctx; BIGNUM k, kq, *K, *kinv = NULL, *r = NULL; int ret = 0; if (!dsa->p || !dsa->q || !dsa->g) { DSAerr(DSA_F_DSA_SIGN_SETUP, DSA_R_MISSING_PARAMETERS); return 0; } BN_init(&k); BN_init(&kq); if (ctx_in == NULL) { if ((ctx = BN_CTX_new()) == NULL) goto err; } else ctx = ctx_in; if ((r = BN_new()) == NULL) goto err; /* Get random k */ do { if (!BN_rand_range(&k, dsa->q)) goto err; } while (BN_is_zero(&k)); if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0) { BN_set_flags(&k, BN_FLG_CONSTTIME); } if (dsa->flags & DSA_FLAG_CACHE_MONT_P) { if (!BN_MONT_CTX_set_locked(&dsa->method_mont_p, CRYPTO_LOCK_DSA, dsa->p, ctx)) goto err; } /* Compute r = (g^k mod p) mod q */ if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0) { if (!BN_copy(&kq, &k)) goto err; /* * We do not want timing information to leak the length of k, * so we compute g^k using an equivalent exponent of fixed * length. * * (This is a kludge that we need because the BN_mod_exp_mont() * does not let us specify the desired timing behaviour.) */ if (!BN_add(&kq, &kq, dsa->q)) goto err; if (BN_num_bits(&kq) <= BN_num_bits(dsa->q)) { if (!BN_add(&kq, &kq, dsa->q)) goto err; } K = &kq; } else { K = &k; } DSA_BN_MOD_EXP(goto err, dsa, r, dsa->g, K, dsa->p, ctx, dsa->method_mont_p); if (!BN_mod(r,r,dsa->q,ctx)) goto err; /* Compute part of 's = inv(k) (m + xr) mod q' */ if ((kinv = BN_mod_inverse(NULL, &k, dsa->q, ctx)) == NULL) goto err; if (*kinvp != NULL) BN_clear_free(*kinvp); *kinvp = kinv; kinv = NULL; if (*rp != NULL) BN_clear_free(*rp); *rp = r; ret = 1; err: if (!ret) { DSAerr(DSA_F_DSA_SIGN_SETUP, ERR_R_BN_LIB); if (r != NULL) BN_clear_free(r); } if (ctx_in == NULL) BN_CTX_free(ctx); BN_clear_free(&k); BN_clear_free(&kq); return ret; } static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) { BN_CTX *ctx; BIGNUM u1, u2, t1; BN_MONT_CTX *mont = NULL; int ret = -1, i; if (!dsa->p || !dsa->q || !dsa->g) { DSAerr(DSA_F_DSA_DO_VERIFY, DSA_R_MISSING_PARAMETERS); return -1; } i = BN_num_bits(dsa->q); /* fips 186-3 allows only different sizes for q */ if (i != 160 && i != 224 && i != 256) { DSAerr(DSA_F_DSA_DO_VERIFY, DSA_R_BAD_Q_VALUE); return -1; } if (BN_num_bits(dsa->p) > OPENSSL_DSA_MAX_MODULUS_BITS) { DSAerr(DSA_F_DSA_DO_VERIFY, DSA_R_MODULUS_TOO_LARGE); return -1; } BN_init(&u1); BN_init(&u2); BN_init(&t1); if ((ctx = BN_CTX_new()) == NULL) goto err; if (BN_is_zero(sig->r) || BN_is_negative(sig->r) || BN_ucmp(sig->r, dsa->q) >= 0) { ret = 0; goto err; } if (BN_is_zero(sig->s) || BN_is_negative(sig->s) || BN_ucmp(sig->s, dsa->q) >= 0) { ret = 0; goto err; } /* Calculate W = inv(S) mod Q * save W in u2 */ if ((BN_mod_inverse(&u2, sig->s, dsa->q, ctx)) == NULL) goto err; /* save M in u1 */ /* * If the digest length is greater than the size of q use the * BN_num_bits(dsa->q) leftmost bits of the digest, see * fips 186-3, 4.2 */ if (dgst_len > (i >> 3)) dgst_len = (i >> 3); if (BN_bin2bn(dgst, dgst_len, &u1) == NULL) goto err; /* u1 = M * w mod q */ if (!BN_mod_mul(&u1, &u1, &u2, dsa->q, ctx)) goto err; /* u2 = r * w mod q */ if (!BN_mod_mul(&u2, sig->r, &u2, dsa->q, ctx)) goto err; if (dsa->flags & DSA_FLAG_CACHE_MONT_P) { mont = BN_MONT_CTX_set_locked(&dsa->method_mont_p, CRYPTO_LOCK_DSA, dsa->p, ctx); if (!mont) goto err; } DSA_MOD_EXP(goto err, dsa, &t1, dsa->g, &u1, dsa->pub_key, &u2, dsa->p, ctx, mont); /* BN_copy(&u1,&t1); */ /* let u1 = u1 mod q */ if (!BN_mod(&u1, &t1, dsa->q, ctx)) goto err; /* V is now in u1. If the signature is correct, it will be * equal to R. */ ret = BN_ucmp(&u1, sig->r) == 0; err: /* XXX: surely this is wrong - if ret is 0, it just didn't verify; there is no error in BN. Test should be ret == -1 (Ben) */ if (ret != 1) DSAerr(DSA_F_DSA_DO_VERIFY, ERR_R_BN_LIB); if (ctx != NULL) BN_CTX_free(ctx); BN_free(&u1); BN_free(&u2); BN_free(&t1); return ret; } static int dsa_init(DSA *dsa) { dsa->flags |= DSA_FLAG_CACHE_MONT_P; return 1; } static int dsa_finish(DSA *dsa) { if (dsa->method_mont_p) BN_MONT_CTX_free(dsa->method_mont_p); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dsa/dsa_gen.c0000644000175000017500000002215312360020705020571 0ustar /* $OpenBSD: dsa_gen.c,v 1.14 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include /* To see if OPENSSL_NO_SHA is defined */ #ifndef OPENSSL_NO_SHA #include #include #include #include #include #include #include "dsa_locl.h" int DSA_generate_parameters_ex(DSA *ret, int bits, const unsigned char *seed_in, int seed_len, int *counter_ret, unsigned long *h_ret, BN_GENCB *cb) { if (ret->meth->dsa_paramgen) return ret->meth->dsa_paramgen(ret, bits, seed_in, seed_len, counter_ret, h_ret, cb); else { const EVP_MD *evpmd; size_t qbits; if (bits >= 2048) { qbits = 256; evpmd = EVP_sha256(); } else { qbits = 160; evpmd = EVP_sha1(); } return dsa_builtin_paramgen(ret, bits, qbits, evpmd, seed_in, seed_len, NULL, counter_ret, h_ret, cb); } } int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, const EVP_MD *evpmd, const unsigned char *seed_in, size_t seed_len, unsigned char *seed_out, int *counter_ret, unsigned long *h_ret, BN_GENCB *cb) { int ok = 0; unsigned char seed[SHA256_DIGEST_LENGTH]; unsigned char md[SHA256_DIGEST_LENGTH]; unsigned char buf[SHA256_DIGEST_LENGTH], buf2[SHA256_DIGEST_LENGTH]; BIGNUM *r0, *W, *X, *c, *test; BIGNUM *g = NULL, *q = NULL, *p = NULL; BN_MONT_CTX *mont = NULL; int i, k, n = 0, m = 0, qsize = qbits >> 3; int counter = 0; int r = 0; BN_CTX *ctx = NULL; unsigned int h = 2; if (qsize != SHA_DIGEST_LENGTH && qsize != SHA224_DIGEST_LENGTH && qsize != SHA256_DIGEST_LENGTH) /* invalid q size */ return 0; if (evpmd == NULL) /* use SHA1 as default */ evpmd = EVP_sha1(); if (bits < 512) bits = 512; bits = (bits + 63) / 64 * 64; /* * NB: seed_len == 0 is special case: copy generated seed to * seed_in if it is not NULL. */ if (seed_len && seed_len < (size_t)qsize) seed_in = NULL; /* seed buffer too small -- ignore */ /* * App. 2.2 of FIPS PUB 186 allows larger SEED, * but our internal buffers are restricted to 160 bits */ if (seed_len > (size_t)qsize) seed_len = qsize; if (seed_in != NULL) memcpy(seed, seed_in, seed_len); if ((ctx=BN_CTX_new()) == NULL) goto err; if ((mont=BN_MONT_CTX_new()) == NULL) goto err; BN_CTX_start(ctx); r0 = BN_CTX_get(ctx); g = BN_CTX_get(ctx); W = BN_CTX_get(ctx); q = BN_CTX_get(ctx); X = BN_CTX_get(ctx); c = BN_CTX_get(ctx); p = BN_CTX_get(ctx); test = BN_CTX_get(ctx); if (!BN_lshift(test, BN_value_one(), bits - 1)) goto err; for (;;) { for (;;) { /* find q */ int seed_is_random; /* step 1 */ if (!BN_GENCB_call(cb, 0, m++)) goto err; if (!seed_len) { RAND_pseudo_bytes(seed, qsize); seed_is_random = 1; } else { seed_is_random = 0; /* use random seed if 'seed_in' turns out to be bad */ seed_len = 0; } memcpy(buf, seed, qsize); memcpy(buf2, seed, qsize); /* precompute "SEED + 1" for step 7: */ for (i = qsize - 1; i >= 0; i--) { buf[i]++; if (buf[i] != 0) break; } /* step 2 */ if (!EVP_Digest(seed, qsize, md, NULL, evpmd, NULL)) goto err; if (!EVP_Digest(buf, qsize, buf2, NULL, evpmd, NULL)) goto err; for (i = 0; i < qsize; i++) md[i] ^= buf2[i]; /* step 3 */ md[0] |= 0x80; md[qsize - 1] |= 0x01; if (!BN_bin2bn(md, qsize, q)) goto err; /* step 4 */ r = BN_is_prime_fasttest_ex(q, DSS_prime_checks, ctx, seed_is_random, cb); if (r > 0) break; if (r != 0) goto err; /* do a callback call */ /* step 5 */ } if (!BN_GENCB_call(cb, 2, 0)) goto err; if (!BN_GENCB_call(cb, 3, 0)) goto err; /* step 6 */ counter = 0; /* "offset = 2" */ n = (bits - 1) / 160; for (;;) { if (counter != 0 && !BN_GENCB_call(cb, 0, counter)) goto err; /* step 7 */ BN_zero(W); /* now 'buf' contains "SEED + offset - 1" */ for (k = 0; k <= n; k++) { /* obtain "SEED + offset + k" by incrementing: */ for (i = qsize - 1; i >= 0; i--) { buf[i]++; if (buf[i] != 0) break; } if (!EVP_Digest(buf, qsize, md ,NULL, evpmd, NULL)) goto err; /* step 8 */ if (!BN_bin2bn(md, qsize, r0)) goto err; if (!BN_lshift(r0, r0, (qsize << 3) * k)) goto err; if (!BN_add(W, W, r0)) goto err; } /* more of step 8 */ if (!BN_mask_bits(W, bits - 1)) goto err; if (!BN_copy(X, W)) goto err; if (!BN_add(X, X, test)) goto err; /* step 9 */ if (!BN_lshift1(r0, q)) goto err; if (!BN_mod(c, X, r0, ctx)) goto err; if (!BN_sub(r0, c, BN_value_one())) goto err; if (!BN_sub(p, X, r0)) goto err; /* step 10 */ if (BN_cmp(p, test) >= 0) { /* step 11 */ r = BN_is_prime_fasttest_ex(p, DSS_prime_checks, ctx, 1, cb); if (r > 0) goto end; /* found it */ if (r != 0) goto err; } /* step 13 */ counter++; /* "offset = offset + n + 1" */ /* step 14 */ if (counter >= 4096) break; } } end: if (!BN_GENCB_call(cb, 2, 1)) goto err; /* We now need to generate g */ /* Set r0=(p-1)/q */ if (!BN_sub(test, p, BN_value_one())) goto err; if (!BN_div(r0, NULL, test, q, ctx)) goto err; if (!BN_set_word(test, h)) goto err; if (!BN_MONT_CTX_set(mont, p, ctx)) goto err; for (;;) { /* g=test^r0%p */ if (!BN_mod_exp_mont(g, test, r0, p, ctx, mont)) goto err; if (!BN_is_one(g)) break; if (!BN_add(test, test, BN_value_one())) goto err; h++; } if (!BN_GENCB_call(cb, 3, 1)) goto err; ok = 1; err: if (ok) { if (ret->p) BN_free(ret->p); if (ret->q) BN_free(ret->q); if (ret->g) BN_free(ret->g); ret->p = BN_dup(p); ret->q = BN_dup(q); ret->g = BN_dup(g); if (ret->p == NULL || ret->q == NULL || ret->g == NULL) { ok = 0; goto err; } if (counter_ret != NULL) *counter_ret = counter; if (h_ret != NULL) *h_ret = h; if (seed_out) memcpy(seed_out, seed, qsize); } if (ctx) { BN_CTX_end(ctx); BN_CTX_free(ctx); } if (mont != NULL) BN_MONT_CTX_free(mont); return ok; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dsa/dsa_pmeth.c0000644000175000017500000002054512360020705021140 0ustar /* $OpenBSD: dsa_pmeth.c,v 1.9 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include #include "dsa_locl.h" #include "evp_locl.h" /* DSA pkey context structure */ typedef struct { /* Parameter gen parameters */ int nbits; /* size of p in bits (default: 1024) */ int qbits; /* size of q in bits (default: 160) */ const EVP_MD *pmd; /* MD for parameter generation */ /* Keygen callback info */ int gentmp[2]; /* message digest */ const EVP_MD *md; /* MD for the signature */ } DSA_PKEY_CTX; static int pkey_dsa_init(EVP_PKEY_CTX *ctx) { DSA_PKEY_CTX *dctx; dctx = malloc(sizeof(DSA_PKEY_CTX)); if (!dctx) return 0; dctx->nbits = 1024; dctx->qbits = 160; dctx->pmd = NULL; dctx->md = NULL; ctx->data = dctx; ctx->keygen_info = dctx->gentmp; ctx->keygen_info_count = 2; return 1; } static int pkey_dsa_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src) { DSA_PKEY_CTX *dctx, *sctx; if (!pkey_dsa_init(dst)) return 0; sctx = src->data; dctx = dst->data; dctx->nbits = sctx->nbits; dctx->qbits = sctx->qbits; dctx->pmd = sctx->pmd; dctx->md = sctx->md; return 1; } static void pkey_dsa_cleanup(EVP_PKEY_CTX *ctx) { DSA_PKEY_CTX *dctx = ctx->data; free(dctx); } static int pkey_dsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, const unsigned char *tbs, size_t tbslen) { int ret, type; unsigned int sltmp; DSA_PKEY_CTX *dctx = ctx->data; DSA *dsa = ctx->pkey->pkey.dsa; if (dctx->md) type = EVP_MD_type(dctx->md); else type = NID_sha1; ret = DSA_sign(type, tbs, tbslen, sig, &sltmp, dsa); if (ret <= 0) return ret; *siglen = sltmp; return 1; } static int pkey_dsa_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, const unsigned char *tbs, size_t tbslen) { int ret, type; DSA_PKEY_CTX *dctx = ctx->data; DSA *dsa = ctx->pkey->pkey.dsa; if (dctx->md) type = EVP_MD_type(dctx->md); else type = NID_sha1; ret = DSA_verify(type, tbs, tbslen, sig, siglen, dsa); return ret; } static int pkey_dsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) { DSA_PKEY_CTX *dctx = ctx->data; switch (type) { case EVP_PKEY_CTRL_DSA_PARAMGEN_BITS: if (p1 < 256) return -2; dctx->nbits = p1; return 1; case EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS: if (p1 != 160 && p1 != 224 && p1 && p1 != 256) return -2; dctx->qbits = p1; return 1; case EVP_PKEY_CTRL_DSA_PARAMGEN_MD: switch (EVP_MD_type((const EVP_MD *)p2)) { case NID_sha1: case NID_sha224: case NID_sha256: break; default: DSAerr(DSA_F_PKEY_DSA_CTRL, DSA_R_INVALID_DIGEST_TYPE); return 0; } dctx->md = p2; return 1; case EVP_PKEY_CTRL_MD: switch (EVP_MD_type((const EVP_MD *)p2)) { case NID_sha1: case NID_dsa: case NID_dsaWithSHA: case NID_sha224: case NID_sha256: case NID_sha384: case NID_sha512: break; default: DSAerr(DSA_F_PKEY_DSA_CTRL, DSA_R_INVALID_DIGEST_TYPE); return 0; } dctx->md = p2; return 1; case EVP_PKEY_CTRL_DIGESTINIT: case EVP_PKEY_CTRL_PKCS7_SIGN: case EVP_PKEY_CTRL_CMS_SIGN: return 1; case EVP_PKEY_CTRL_PEER_KEY: DSAerr(DSA_F_PKEY_DSA_CTRL, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; default: return -2; } } static int pkey_dsa_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) { long lval; char *ep; if (!strcmp(type, "dsa_paramgen_bits")) { int nbits; errno = 0; lval = strtol(value, &ep, 10); if (value[0] == '\0' || *ep != '\0') goto not_a_number; if ((errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN)) || (lval > INT_MAX || lval < INT_MIN)) goto out_of_range; nbits = lval; return EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits); } else if (!strcmp(type, "dsa_paramgen_q_bits")) { int qbits; errno = 0; lval = strtol(value, &ep, 10); if (value[0] == '\0' || *ep != '\0') goto not_a_number; if ((errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN)) || (lval > INT_MAX || lval < INT_MIN)) goto out_of_range; qbits = lval; return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS, qbits, NULL); } else if (!strcmp(type, "dsa_paramgen_md")) { return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, EVP_PKEY_CTRL_DSA_PARAMGEN_MD, 0, (void *)EVP_get_digestbyname(value)); } not_a_number: out_of_range: return -2; } static int pkey_dsa_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) { DSA *dsa = NULL; DSA_PKEY_CTX *dctx = ctx->data; BN_GENCB *pcb, cb; int ret; if (ctx->pkey_gencb) { pcb = &cb; evp_pkey_set_cb_translate(pcb, ctx); } else pcb = NULL; dsa = DSA_new(); if (!dsa) return 0; ret = dsa_builtin_paramgen(dsa, dctx->nbits, dctx->qbits, dctx->pmd, NULL, 0, NULL, NULL, NULL, pcb); if (ret) EVP_PKEY_assign_DSA(pkey, dsa); else DSA_free(dsa); return ret; } static int pkey_dsa_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) { DSA *dsa = NULL; if (ctx->pkey == NULL) { DSAerr(DSA_F_PKEY_DSA_KEYGEN, DSA_R_NO_PARAMETERS_SET); return 0; } dsa = DSA_new(); if (!dsa) return 0; EVP_PKEY_assign_DSA(pkey, dsa); /* Note: if error return, pkey is freed by parent routine */ if (!EVP_PKEY_copy_parameters(pkey, ctx->pkey)) return 0; return DSA_generate_key(pkey->pkey.dsa); } const EVP_PKEY_METHOD dsa_pkey_meth = { .pkey_id = EVP_PKEY_DSA, .flags = EVP_PKEY_FLAG_AUTOARGLEN, .init = pkey_dsa_init, .copy = pkey_dsa_copy, .cleanup = pkey_dsa_cleanup, .paramgen = pkey_dsa_paramgen, .keygen = pkey_dsa_keygen, .sign = pkey_dsa_sign, .verify = pkey_dsa_verify, .ctrl = pkey_dsa_ctrl, .ctrl_str = pkey_dsa_ctrl_str }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dsa/dsa_err.c0000644000175000017500000001267412360020705020617 0ustar /* $OpenBSD: dsa_err.c,v 1.13 2014/06/12 15:49:28 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_DSA,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_DSA,0,reason) static ERR_STRING_DATA DSA_str_functs[]= { {ERR_FUNC(DSA_F_D2I_DSA_SIG), "d2i_DSA_SIG"}, {ERR_FUNC(DSA_F_DO_DSA_PRINT), "DO_DSA_PRINT"}, {ERR_FUNC(DSA_F_DSAPARAMS_PRINT), "DSAparams_print"}, {ERR_FUNC(DSA_F_DSAPARAMS_PRINT_FP), "DSAparams_print_fp"}, {ERR_FUNC(DSA_F_DSA_DO_SIGN), "DSA_do_sign"}, {ERR_FUNC(DSA_F_DSA_DO_VERIFY), "DSA_do_verify"}, {ERR_FUNC(DSA_F_DSA_GENERATE_KEY), "DSA_generate_key"}, {ERR_FUNC(DSA_F_DSA_GENERATE_PARAMETERS_EX), "DSA_generate_parameters_ex"}, {ERR_FUNC(DSA_F_DSA_NEW_METHOD), "DSA_new_method"}, {ERR_FUNC(DSA_F_DSA_PARAM_DECODE), "DSA_PARAM_DECODE"}, {ERR_FUNC(DSA_F_DSA_PRINT_FP), "DSA_print_fp"}, {ERR_FUNC(DSA_F_DSA_PRIV_DECODE), "DSA_PRIV_DECODE"}, {ERR_FUNC(DSA_F_DSA_PRIV_ENCODE), "DSA_PRIV_ENCODE"}, {ERR_FUNC(DSA_F_DSA_PUB_DECODE), "DSA_PUB_DECODE"}, {ERR_FUNC(DSA_F_DSA_PUB_ENCODE), "DSA_PUB_ENCODE"}, {ERR_FUNC(DSA_F_DSA_SIGN), "DSA_sign"}, {ERR_FUNC(DSA_F_DSA_SIGN_SETUP), "DSA_sign_setup"}, {ERR_FUNC(DSA_F_DSA_SIG_NEW), "DSA_SIG_new"}, {ERR_FUNC(DSA_F_DSA_SIG_PRINT), "DSA_SIG_PRINT"}, {ERR_FUNC(DSA_F_DSA_VERIFY), "DSA_verify"}, {ERR_FUNC(DSA_F_I2D_DSA_SIG), "i2d_DSA_SIG"}, {ERR_FUNC(DSA_F_OLD_DSA_PRIV_DECODE), "OLD_DSA_PRIV_DECODE"}, {ERR_FUNC(DSA_F_PKEY_DSA_CTRL), "PKEY_DSA_CTRL"}, {ERR_FUNC(DSA_F_PKEY_DSA_KEYGEN), "PKEY_DSA_KEYGEN"}, {ERR_FUNC(DSA_F_SIG_CB), "SIG_CB"}, {0,NULL} }; static ERR_STRING_DATA DSA_str_reasons[]= { {ERR_REASON(DSA_R_BAD_Q_VALUE) ,"bad q value"}, {ERR_REASON(DSA_R_BN_DECODE_ERROR) ,"bn decode error"}, {ERR_REASON(DSA_R_BN_ERROR) ,"bn error"}, {ERR_REASON(DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),"data too large for key size"}, {ERR_REASON(DSA_R_DECODE_ERROR) ,"decode error"}, {ERR_REASON(DSA_R_INVALID_DIGEST_TYPE) ,"invalid digest type"}, {ERR_REASON(DSA_R_MISSING_PARAMETERS) ,"missing parameters"}, {ERR_REASON(DSA_R_MODULUS_TOO_LARGE) ,"modulus too large"}, {ERR_REASON(DSA_R_NEED_NEW_SETUP_VALUES) ,"need new setup values"}, {ERR_REASON(DSA_R_NON_FIPS_DSA_METHOD) ,"non fips dsa method"}, {ERR_REASON(DSA_R_NO_PARAMETERS_SET) ,"no parameters set"}, {ERR_REASON(DSA_R_PARAMETER_ENCODING_ERROR),"parameter encoding error"}, {0,NULL} }; #endif void ERR_load_DSA_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(DSA_str_functs[0].error) == NULL) { ERR_load_strings(0,DSA_str_functs); ERR_load_strings(0,DSA_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/cryptlib.h0000644000175000017500000000723312360020705020261 0ustar /* $OpenBSD: cryptlib.h,v 1.23 2014/07/10 22:13:39 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #ifndef HEADER_CRYPTLIB_H #define HEADER_CRYPTLIB_H #include #ifdef __cplusplus extern "C" { #endif #define X509_CERT_AREA OPENSSLDIR #define X509_CERT_DIR OPENSSLDIR "/certs" #define X509_CERT_FILE OPENSSLDIR "/cert.pem" #define X509_PRIVATE_DIR OPENSSLDIR "/private" #define X509_CERT_DIR_EVP "SSL_CERT_DIR" #define X509_CERT_FILE_EVP "SSL_CERT_FILE" void OPENSSL_cpuid_setup(void); extern unsigned int OPENSSL_ia32cap_P[]; #ifdef __cplusplus } #endif #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/Makefile.in0000664000175000017500000272034512437255271020354 0ustar # Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ DIST_COMMON = $(top_srcdir)/Makefile.am.common $(srcdir)/Makefile.in \ $(srcdir)/Makefile.am $(top_srcdir)/depcomp $(noinst_HEADERS) @NO_STRLCAT_TRUE@am__append_1 = compat/strlcat.c @NO_STRLCPY_TRUE@am__append_2 = compat/strlcpy.c @NO_REALLOCARRAY_TRUE@am__append_3 = compat/reallocarray.c @NO_TIMINGSAFE_MEMCMP_TRUE@am__append_4 = compat/timingsafe_memcmp.c @NO_TIMINGSAFE_BCMP_TRUE@am__append_5 = compat/timingsafe_bcmp.c @NO_ARC4RANDOM_BUF_TRUE@am__append_6 = compat/arc4random.c @NO_ARC4RANDOM_BUF_TRUE@@NO_GETENTROPY_TRUE@@TARGET_LINUX_TRUE@am__append_7 = compat/getentropy_linux.c @NO_ARC4RANDOM_BUF_TRUE@@NO_GETENTROPY_TRUE@@TARGET_DARWIN_TRUE@am__append_8 = compat/getentropy_osx.c @NO_ARC4RANDOM_BUF_TRUE@@NO_GETENTROPY_TRUE@@TARGET_SOLARIS_TRUE@am__append_9 = compat/getentropy_solaris.c @NO_ARC4RANDOM_BUF_TRUE@@NO_GETENTROPY_TRUE@@TARGET_NACL_TRUE@am__append_10 = compat/getentropy_nacl.c @NO_ISSETUGID_TRUE@am__append_11 = compat/issetugid_linux.c subdir = crypto ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) libcompat_la_LIBADD = am__libcompat_la_SOURCES_DIST = compat/strlcat.c compat/strlcpy.c \ compat/reallocarray.c compat/timingsafe_memcmp.c \ compat/timingsafe_bcmp.c compat/arc4random.c \ compat/getentropy_linux.c compat/getentropy_osx.c \ compat/getentropy_solaris.c compat/getentropy_nacl.c \ compat/issetugid_linux.c am__dirstamp = $(am__leading_dot)dirstamp @NO_STRLCAT_TRUE@am__objects_1 = compat/libcompat_la-strlcat.lo @NO_STRLCPY_TRUE@am__objects_2 = compat/libcompat_la-strlcpy.lo @NO_REALLOCARRAY_TRUE@am__objects_3 = \ @NO_REALLOCARRAY_TRUE@ compat/libcompat_la-reallocarray.lo @NO_TIMINGSAFE_MEMCMP_TRUE@am__objects_4 = compat/libcompat_la-timingsafe_memcmp.lo @NO_TIMINGSAFE_BCMP_TRUE@am__objects_5 = compat/libcompat_la-timingsafe_bcmp.lo @NO_ARC4RANDOM_BUF_TRUE@am__objects_6 = \ @NO_ARC4RANDOM_BUF_TRUE@ compat/libcompat_la-arc4random.lo @NO_ARC4RANDOM_BUF_TRUE@@NO_GETENTROPY_TRUE@@TARGET_LINUX_TRUE@am__objects_7 = compat/libcompat_la-getentropy_linux.lo @NO_ARC4RANDOM_BUF_TRUE@@NO_GETENTROPY_TRUE@@TARGET_DARWIN_TRUE@am__objects_8 = compat/libcompat_la-getentropy_osx.lo @NO_ARC4RANDOM_BUF_TRUE@@NO_GETENTROPY_TRUE@@TARGET_SOLARIS_TRUE@am__objects_9 = compat/libcompat_la-getentropy_solaris.lo @NO_ARC4RANDOM_BUF_TRUE@@NO_GETENTROPY_TRUE@@TARGET_NACL_TRUE@am__objects_10 = compat/libcompat_la-getentropy_nacl.lo @NO_ISSETUGID_TRUE@am__objects_11 = \ @NO_ISSETUGID_TRUE@ compat/libcompat_la-issetugid_linux.lo am_libcompat_la_OBJECTS = $(am__objects_1) $(am__objects_2) \ $(am__objects_3) $(am__objects_4) $(am__objects_5) \ $(am__objects_6) $(am__objects_7) $(am__objects_8) \ $(am__objects_9) $(am__objects_10) $(am__objects_11) libcompat_la_OBJECTS = $(am_libcompat_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libcompat_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libcompat_la_CFLAGS) \ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ libcompatnoopt_la_LIBADD = am_libcompatnoopt_la_OBJECTS = \ compat/libcompatnoopt_la-explicit_bzero.lo libcompatnoopt_la_OBJECTS = $(am_libcompatnoopt_la_OBJECTS) libcompatnoopt_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(libcompatnoopt_la_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ libcrypto_la_DEPENDENCIES = libcompat.la libcompatnoopt.la am_libcrypto_la_OBJECTS = libcrypto_la-cpt_err.lo \ libcrypto_la-cryptlib.lo libcrypto_la-cversion.lo \ libcrypto_la-ex_data.lo libcrypto_la-malloc-wrapper.lo \ libcrypto_la-mem_clr.lo libcrypto_la-mem_dbg.lo \ libcrypto_la-o_init.lo libcrypto_la-o_str.lo \ libcrypto_la-o_time.lo aes/libcrypto_la-aes_cbc.lo \ aes/libcrypto_la-aes_cfb.lo aes/libcrypto_la-aes_core.lo \ aes/libcrypto_la-aes_ctr.lo aes/libcrypto_la-aes_ecb.lo \ aes/libcrypto_la-aes_ige.lo aes/libcrypto_la-aes_misc.lo \ aes/libcrypto_la-aes_ofb.lo aes/libcrypto_la-aes_wrap.lo \ asn1/libcrypto_la-a_bitstr.lo asn1/libcrypto_la-a_bool.lo \ asn1/libcrypto_la-a_bytes.lo asn1/libcrypto_la-a_d2i_fp.lo \ asn1/libcrypto_la-a_digest.lo asn1/libcrypto_la-a_dup.lo \ asn1/libcrypto_la-a_enum.lo asn1/libcrypto_la-a_gentm.lo \ asn1/libcrypto_la-a_i2d_fp.lo asn1/libcrypto_la-a_int.lo \ asn1/libcrypto_la-a_mbstr.lo asn1/libcrypto_la-a_object.lo \ asn1/libcrypto_la-a_octet.lo asn1/libcrypto_la-a_print.lo \ asn1/libcrypto_la-a_set.lo asn1/libcrypto_la-a_sign.lo \ asn1/libcrypto_la-a_strex.lo asn1/libcrypto_la-a_strnid.lo \ asn1/libcrypto_la-a_time.lo asn1/libcrypto_la-a_type.lo \ asn1/libcrypto_la-a_utctm.lo asn1/libcrypto_la-a_utf8.lo \ asn1/libcrypto_la-a_verify.lo asn1/libcrypto_la-ameth_lib.lo \ asn1/libcrypto_la-asn1_err.lo asn1/libcrypto_la-asn1_gen.lo \ asn1/libcrypto_la-asn1_lib.lo asn1/libcrypto_la-asn1_par.lo \ asn1/libcrypto_la-asn_mime.lo asn1/libcrypto_la-asn_moid.lo \ asn1/libcrypto_la-asn_pack.lo asn1/libcrypto_la-bio_asn1.lo \ asn1/libcrypto_la-bio_ndef.lo asn1/libcrypto_la-d2i_pr.lo \ asn1/libcrypto_la-d2i_pu.lo asn1/libcrypto_la-evp_asn1.lo \ asn1/libcrypto_la-f_enum.lo asn1/libcrypto_la-f_int.lo \ asn1/libcrypto_la-f_string.lo asn1/libcrypto_la-i2d_pr.lo \ asn1/libcrypto_la-i2d_pu.lo asn1/libcrypto_la-n_pkey.lo \ asn1/libcrypto_la-nsseq.lo asn1/libcrypto_la-p5_pbe.lo \ asn1/libcrypto_la-p5_pbev2.lo asn1/libcrypto_la-p8_pkey.lo \ asn1/libcrypto_la-t_bitst.lo asn1/libcrypto_la-t_crl.lo \ asn1/libcrypto_la-t_pkey.lo asn1/libcrypto_la-t_req.lo \ asn1/libcrypto_la-t_spki.lo asn1/libcrypto_la-t_x509.lo \ asn1/libcrypto_la-t_x509a.lo asn1/libcrypto_la-tasn_dec.lo \ asn1/libcrypto_la-tasn_enc.lo asn1/libcrypto_la-tasn_fre.lo \ asn1/libcrypto_la-tasn_new.lo asn1/libcrypto_la-tasn_prn.lo \ asn1/libcrypto_la-tasn_typ.lo asn1/libcrypto_la-tasn_utl.lo \ asn1/libcrypto_la-x_algor.lo asn1/libcrypto_la-x_attrib.lo \ asn1/libcrypto_la-x_bignum.lo asn1/libcrypto_la-x_crl.lo \ asn1/libcrypto_la-x_exten.lo asn1/libcrypto_la-x_info.lo \ asn1/libcrypto_la-x_long.lo asn1/libcrypto_la-x_name.lo \ asn1/libcrypto_la-x_nx509.lo asn1/libcrypto_la-x_pkey.lo \ asn1/libcrypto_la-x_pubkey.lo asn1/libcrypto_la-x_req.lo \ asn1/libcrypto_la-x_sig.lo asn1/libcrypto_la-x_spki.lo \ asn1/libcrypto_la-x_val.lo asn1/libcrypto_la-x_x509.lo \ asn1/libcrypto_la-x_x509a.lo bf/libcrypto_la-bf_cfb64.lo \ bf/libcrypto_la-bf_ecb.lo bf/libcrypto_la-bf_enc.lo \ bf/libcrypto_la-bf_ofb64.lo bf/libcrypto_la-bf_skey.lo \ bio/libcrypto_la-b_dump.lo bio/libcrypto_la-b_print.lo \ bio/libcrypto_la-b_sock.lo bio/libcrypto_la-bf_buff.lo \ bio/libcrypto_la-bf_nbio.lo bio/libcrypto_la-bf_null.lo \ bio/libcrypto_la-bio_cb.lo bio/libcrypto_la-bio_err.lo \ bio/libcrypto_la-bio_lib.lo bio/libcrypto_la-bss_acpt.lo \ bio/libcrypto_la-bss_bio.lo bio/libcrypto_la-bss_conn.lo \ bio/libcrypto_la-bss_dgram.lo bio/libcrypto_la-bss_fd.lo \ bio/libcrypto_la-bss_file.lo bio/libcrypto_la-bss_log.lo \ bio/libcrypto_la-bss_mem.lo bio/libcrypto_la-bss_null.lo \ bio/libcrypto_la-bss_sock.lo bn/libcrypto_la-bn_add.lo \ bn/libcrypto_la-bn_asm.lo bn/libcrypto_la-bn_blind.lo \ bn/libcrypto_la-bn_const.lo bn/libcrypto_la-bn_ctx.lo \ bn/libcrypto_la-bn_depr.lo bn/libcrypto_la-bn_div.lo \ bn/libcrypto_la-bn_err.lo bn/libcrypto_la-bn_exp.lo \ bn/libcrypto_la-bn_exp2.lo bn/libcrypto_la-bn_gcd.lo \ bn/libcrypto_la-bn_gf2m.lo bn/libcrypto_la-bn_kron.lo \ bn/libcrypto_la-bn_lib.lo bn/libcrypto_la-bn_mod.lo \ bn/libcrypto_la-bn_mont.lo bn/libcrypto_la-bn_mpi.lo \ bn/libcrypto_la-bn_mul.lo bn/libcrypto_la-bn_nist.lo \ bn/libcrypto_la-bn_prime.lo bn/libcrypto_la-bn_print.lo \ bn/libcrypto_la-bn_rand.lo bn/libcrypto_la-bn_recp.lo \ bn/libcrypto_la-bn_shift.lo bn/libcrypto_la-bn_sqr.lo \ bn/libcrypto_la-bn_sqrt.lo bn/libcrypto_la-bn_word.lo \ bn/libcrypto_la-bn_x931p.lo buffer/libcrypto_la-buf_err.lo \ buffer/libcrypto_la-buf_str.lo buffer/libcrypto_la-buffer.lo \ cast/libcrypto_la-c_cfb64.lo cast/libcrypto_la-c_ecb.lo \ cast/libcrypto_la-c_enc.lo cast/libcrypto_la-c_ofb64.lo \ cast/libcrypto_la-c_skey.lo chacha/libcrypto_la-chacha.lo \ cmac/libcrypto_la-cm_ameth.lo cmac/libcrypto_la-cm_pmeth.lo \ cmac/libcrypto_la-cmac.lo comp/libcrypto_la-c_rle.lo \ comp/libcrypto_la-c_zlib.lo comp/libcrypto_la-comp_err.lo \ comp/libcrypto_la-comp_lib.lo conf/libcrypto_la-conf_api.lo \ conf/libcrypto_la-conf_def.lo conf/libcrypto_la-conf_err.lo \ conf/libcrypto_la-conf_lib.lo conf/libcrypto_la-conf_mall.lo \ conf/libcrypto_la-conf_mod.lo conf/libcrypto_la-conf_sap.lo \ des/libcrypto_la-cbc_cksm.lo des/libcrypto_la-cbc_enc.lo \ des/libcrypto_la-cfb64ede.lo des/libcrypto_la-cfb64enc.lo \ des/libcrypto_la-cfb_enc.lo des/libcrypto_la-des_enc.lo \ des/libcrypto_la-ecb3_enc.lo des/libcrypto_la-ecb_enc.lo \ des/libcrypto_la-ede_cbcm_enc.lo des/libcrypto_la-enc_read.lo \ des/libcrypto_la-enc_writ.lo des/libcrypto_la-fcrypt.lo \ des/libcrypto_la-fcrypt_b.lo des/libcrypto_la-ofb64ede.lo \ des/libcrypto_la-ofb64enc.lo des/libcrypto_la-ofb_enc.lo \ des/libcrypto_la-pcbc_enc.lo des/libcrypto_la-qud_cksm.lo \ des/libcrypto_la-rand_key.lo des/libcrypto_la-set_key.lo \ des/libcrypto_la-str2key.lo des/libcrypto_la-xcbc_enc.lo \ dh/libcrypto_la-dh_ameth.lo dh/libcrypto_la-dh_asn1.lo \ dh/libcrypto_la-dh_check.lo dh/libcrypto_la-dh_depr.lo \ dh/libcrypto_la-dh_err.lo dh/libcrypto_la-dh_gen.lo \ dh/libcrypto_la-dh_key.lo dh/libcrypto_la-dh_lib.lo \ dh/libcrypto_la-dh_pmeth.lo dh/libcrypto_la-dh_prn.lo \ dsa/libcrypto_la-dsa_ameth.lo dsa/libcrypto_la-dsa_asn1.lo \ dsa/libcrypto_la-dsa_depr.lo dsa/libcrypto_la-dsa_err.lo \ dsa/libcrypto_la-dsa_gen.lo dsa/libcrypto_la-dsa_key.lo \ dsa/libcrypto_la-dsa_lib.lo dsa/libcrypto_la-dsa_ossl.lo \ dsa/libcrypto_la-dsa_pmeth.lo dsa/libcrypto_la-dsa_prn.lo \ dsa/libcrypto_la-dsa_sign.lo dsa/libcrypto_la-dsa_vrf.lo \ dso/libcrypto_la-dso_dlfcn.lo dso/libcrypto_la-dso_err.lo \ dso/libcrypto_la-dso_lib.lo dso/libcrypto_la-dso_null.lo \ dso/libcrypto_la-dso_openssl.lo ec/libcrypto_la-ec2_mult.lo \ ec/libcrypto_la-ec2_oct.lo ec/libcrypto_la-ec2_smpl.lo \ ec/libcrypto_la-ec_ameth.lo ec/libcrypto_la-ec_asn1.lo \ ec/libcrypto_la-ec_check.lo ec/libcrypto_la-ec_curve.lo \ ec/libcrypto_la-ec_cvt.lo ec/libcrypto_la-ec_err.lo \ ec/libcrypto_la-ec_key.lo ec/libcrypto_la-ec_lib.lo \ ec/libcrypto_la-ec_mult.lo ec/libcrypto_la-ec_oct.lo \ ec/libcrypto_la-ec_pmeth.lo ec/libcrypto_la-ec_print.lo \ ec/libcrypto_la-eck_prn.lo ec/libcrypto_la-ecp_mont.lo \ ec/libcrypto_la-ecp_nist.lo ec/libcrypto_la-ecp_oct.lo \ ec/libcrypto_la-ecp_smpl.lo ecdh/libcrypto_la-ech_err.lo \ ecdh/libcrypto_la-ech_key.lo ecdh/libcrypto_la-ech_lib.lo \ ecdh/libcrypto_la-ech_ossl.lo ecdsa/libcrypto_la-ecs_asn1.lo \ ecdsa/libcrypto_la-ecs_err.lo ecdsa/libcrypto_la-ecs_lib.lo \ ecdsa/libcrypto_la-ecs_ossl.lo ecdsa/libcrypto_la-ecs_sign.lo \ ecdsa/libcrypto_la-ecs_vrf.lo engine/libcrypto_la-eng_all.lo \ engine/libcrypto_la-eng_cnf.lo engine/libcrypto_la-eng_ctrl.lo \ engine/libcrypto_la-eng_dyn.lo engine/libcrypto_la-eng_err.lo \ engine/libcrypto_la-eng_fat.lo engine/libcrypto_la-eng_init.lo \ engine/libcrypto_la-eng_lib.lo engine/libcrypto_la-eng_list.lo \ engine/libcrypto_la-eng_openssl.lo \ engine/libcrypto_la-eng_pkey.lo \ engine/libcrypto_la-eng_rsax.lo \ engine/libcrypto_la-eng_table.lo \ engine/libcrypto_la-tb_asnmth.lo \ engine/libcrypto_la-tb_cipher.lo engine/libcrypto_la-tb_dh.lo \ engine/libcrypto_la-tb_digest.lo engine/libcrypto_la-tb_dsa.lo \ engine/libcrypto_la-tb_ecdh.lo engine/libcrypto_la-tb_ecdsa.lo \ engine/libcrypto_la-tb_pkmeth.lo \ engine/libcrypto_la-tb_rand.lo engine/libcrypto_la-tb_rsa.lo \ engine/libcrypto_la-tb_store.lo err/libcrypto_la-err.lo \ err/libcrypto_la-err_all.lo err/libcrypto_la-err_prn.lo \ evp/libcrypto_la-bio_b64.lo evp/libcrypto_la-bio_enc.lo \ evp/libcrypto_la-bio_md.lo evp/libcrypto_la-c_all.lo \ evp/libcrypto_la-c_allc.lo evp/libcrypto_la-c_alld.lo \ evp/libcrypto_la-digest.lo evp/libcrypto_la-e_aes.lo \ evp/libcrypto_la-e_aes_cbc_hmac_sha1.lo \ evp/libcrypto_la-e_bf.lo evp/libcrypto_la-e_cast.lo \ evp/libcrypto_la-e_chacha.lo \ evp/libcrypto_la-e_chacha20poly1305.lo \ evp/libcrypto_la-e_des.lo evp/libcrypto_la-e_des3.lo \ evp/libcrypto_la-e_idea.lo evp/libcrypto_la-e_null.lo \ evp/libcrypto_la-e_old.lo evp/libcrypto_la-e_rc2.lo \ evp/libcrypto_la-e_rc4.lo evp/libcrypto_la-e_rc4_hmac_md5.lo \ evp/libcrypto_la-e_xcbc_d.lo evp/libcrypto_la-encode.lo \ evp/libcrypto_la-evp_aead.lo evp/libcrypto_la-evp_enc.lo \ evp/libcrypto_la-evp_err.lo evp/libcrypto_la-evp_key.lo \ evp/libcrypto_la-evp_lib.lo evp/libcrypto_la-evp_pbe.lo \ evp/libcrypto_la-evp_pkey.lo evp/libcrypto_la-m_dss.lo \ evp/libcrypto_la-m_dss1.lo evp/libcrypto_la-m_ecdsa.lo \ evp/libcrypto_la-m_md4.lo evp/libcrypto_la-m_md5.lo \ evp/libcrypto_la-m_mdc2.lo evp/libcrypto_la-m_null.lo \ evp/libcrypto_la-m_ripemd.lo evp/libcrypto_la-m_sha.lo \ evp/libcrypto_la-m_sha1.lo evp/libcrypto_la-m_sigver.lo \ evp/libcrypto_la-m_wp.lo evp/libcrypto_la-names.lo \ evp/libcrypto_la-p5_crpt.lo evp/libcrypto_la-p5_crpt2.lo \ evp/libcrypto_la-p_dec.lo evp/libcrypto_la-p_enc.lo \ evp/libcrypto_la-p_lib.lo evp/libcrypto_la-p_open.lo \ evp/libcrypto_la-p_seal.lo evp/libcrypto_la-p_sign.lo \ evp/libcrypto_la-p_verify.lo evp/libcrypto_la-pmeth_fn.lo \ evp/libcrypto_la-pmeth_gn.lo evp/libcrypto_la-pmeth_lib.lo \ hmac/libcrypto_la-hm_ameth.lo hmac/libcrypto_la-hm_pmeth.lo \ hmac/libcrypto_la-hmac.lo idea/libcrypto_la-i_cbc.lo \ idea/libcrypto_la-i_cfb64.lo idea/libcrypto_la-i_ecb.lo \ idea/libcrypto_la-i_ofb64.lo idea/libcrypto_la-i_skey.lo \ krb5/libcrypto_la-krb5_asn.lo lhash/libcrypto_la-lh_stats.lo \ lhash/libcrypto_la-lhash.lo md4/libcrypto_la-md4_dgst.lo \ md4/libcrypto_la-md4_one.lo md5/libcrypto_la-md5_dgst.lo \ md5/libcrypto_la-md5_one.lo mdc2/libcrypto_la-mdc2_one.lo \ mdc2/libcrypto_la-mdc2dgst.lo modes/libcrypto_la-cbc128.lo \ modes/libcrypto_la-ccm128.lo modes/libcrypto_la-cfb128.lo \ modes/libcrypto_la-ctr128.lo modes/libcrypto_la-cts128.lo \ modes/libcrypto_la-gcm128.lo modes/libcrypto_la-ofb128.lo \ modes/libcrypto_la-xts128.lo objects/libcrypto_la-o_names.lo \ objects/libcrypto_la-obj_dat.lo \ objects/libcrypto_la-obj_err.lo \ objects/libcrypto_la-obj_lib.lo \ objects/libcrypto_la-obj_xref.lo ocsp/libcrypto_la-ocsp_asn.lo \ ocsp/libcrypto_la-ocsp_cl.lo ocsp/libcrypto_la-ocsp_err.lo \ ocsp/libcrypto_la-ocsp_ext.lo ocsp/libcrypto_la-ocsp_ht.lo \ ocsp/libcrypto_la-ocsp_lib.lo ocsp/libcrypto_la-ocsp_prn.lo \ ocsp/libcrypto_la-ocsp_srv.lo ocsp/libcrypto_la-ocsp_vfy.lo \ pem/libcrypto_la-pem_all.lo pem/libcrypto_la-pem_err.lo \ pem/libcrypto_la-pem_info.lo pem/libcrypto_la-pem_lib.lo \ pem/libcrypto_la-pem_oth.lo pem/libcrypto_la-pem_pk8.lo \ pem/libcrypto_la-pem_pkey.lo pem/libcrypto_la-pem_seal.lo \ pem/libcrypto_la-pem_sign.lo pem/libcrypto_la-pem_x509.lo \ pem/libcrypto_la-pem_xaux.lo pem/libcrypto_la-pvkfmt.lo \ pkcs12/libcrypto_la-p12_add.lo pkcs12/libcrypto_la-p12_asn.lo \ pkcs12/libcrypto_la-p12_attr.lo \ pkcs12/libcrypto_la-p12_crpt.lo pkcs12/libcrypto_la-p12_crt.lo \ pkcs12/libcrypto_la-p12_decr.lo \ pkcs12/libcrypto_la-p12_init.lo pkcs12/libcrypto_la-p12_key.lo \ pkcs12/libcrypto_la-p12_kiss.lo \ pkcs12/libcrypto_la-p12_mutl.lo \ pkcs12/libcrypto_la-p12_npas.lo pkcs12/libcrypto_la-p12_p8d.lo \ pkcs12/libcrypto_la-p12_p8e.lo pkcs12/libcrypto_la-p12_utl.lo \ pkcs12/libcrypto_la-pk12err.lo pkcs7/libcrypto_la-bio_pk7.lo \ pkcs7/libcrypto_la-pk7_asn1.lo pkcs7/libcrypto_la-pk7_attr.lo \ pkcs7/libcrypto_la-pk7_doit.lo pkcs7/libcrypto_la-pk7_lib.lo \ pkcs7/libcrypto_la-pk7_mime.lo pkcs7/libcrypto_la-pk7_smime.lo \ pkcs7/libcrypto_la-pkcs7err.lo \ poly1305/libcrypto_la-poly1305.lo \ rand/libcrypto_la-rand_err.lo rand/libcrypto_la-rand_lib.lo \ rand/libcrypto_la-randfile.lo rc2/libcrypto_la-rc2_cbc.lo \ rc2/libcrypto_la-rc2_ecb.lo rc2/libcrypto_la-rc2_skey.lo \ rc2/libcrypto_la-rc2cfb64.lo rc2/libcrypto_la-rc2ofb64.lo \ rc4/libcrypto_la-rc4_enc.lo rc4/libcrypto_la-rc4_skey.lo \ rc4/libcrypto_la-rc4_utl.lo ripemd/libcrypto_la-rmd_dgst.lo \ ripemd/libcrypto_la-rmd_one.lo rsa/libcrypto_la-rsa_ameth.lo \ rsa/libcrypto_la-rsa_asn1.lo rsa/libcrypto_la-rsa_chk.lo \ rsa/libcrypto_la-rsa_crpt.lo rsa/libcrypto_la-rsa_depr.lo \ rsa/libcrypto_la-rsa_eay.lo rsa/libcrypto_la-rsa_err.lo \ rsa/libcrypto_la-rsa_gen.lo rsa/libcrypto_la-rsa_lib.lo \ rsa/libcrypto_la-rsa_none.lo rsa/libcrypto_la-rsa_oaep.lo \ rsa/libcrypto_la-rsa_pk1.lo rsa/libcrypto_la-rsa_pmeth.lo \ rsa/libcrypto_la-rsa_prn.lo rsa/libcrypto_la-rsa_pss.lo \ rsa/libcrypto_la-rsa_saos.lo rsa/libcrypto_la-rsa_sign.lo \ rsa/libcrypto_la-rsa_ssl.lo rsa/libcrypto_la-rsa_x931.lo \ sha/libcrypto_la-sha1_one.lo sha/libcrypto_la-sha1dgst.lo \ sha/libcrypto_la-sha256.lo sha/libcrypto_la-sha512.lo \ sha/libcrypto_la-sha_dgst.lo sha/libcrypto_la-sha_one.lo \ stack/libcrypto_la-stack.lo ts/libcrypto_la-ts_asn1.lo \ ts/libcrypto_la-ts_conf.lo ts/libcrypto_la-ts_err.lo \ ts/libcrypto_la-ts_lib.lo ts/libcrypto_la-ts_req_print.lo \ ts/libcrypto_la-ts_req_utils.lo \ ts/libcrypto_la-ts_rsp_print.lo ts/libcrypto_la-ts_rsp_sign.lo \ ts/libcrypto_la-ts_rsp_utils.lo \ ts/libcrypto_la-ts_rsp_verify.lo \ ts/libcrypto_la-ts_verify_ctx.lo txt_db/libcrypto_la-txt_db.lo \ ui/libcrypto_la-ui_err.lo ui/libcrypto_la-ui_lib.lo \ ui/libcrypto_la-ui_openssl.lo ui/libcrypto_la-ui_util.lo \ whrlpool/libcrypto_la-wp_block.lo \ whrlpool/libcrypto_la-wp_dgst.lo x509/libcrypto_la-by_dir.lo \ x509/libcrypto_la-by_file.lo x509/libcrypto_la-x509_att.lo \ x509/libcrypto_la-x509_cmp.lo x509/libcrypto_la-x509_d2.lo \ x509/libcrypto_la-x509_def.lo x509/libcrypto_la-x509_err.lo \ x509/libcrypto_la-x509_ext.lo x509/libcrypto_la-x509_lu.lo \ x509/libcrypto_la-x509_obj.lo x509/libcrypto_la-x509_r2x.lo \ x509/libcrypto_la-x509_req.lo x509/libcrypto_la-x509_set.lo \ x509/libcrypto_la-x509_trs.lo x509/libcrypto_la-x509_txt.lo \ x509/libcrypto_la-x509_v3.lo x509/libcrypto_la-x509_vfy.lo \ x509/libcrypto_la-x509_vpm.lo x509/libcrypto_la-x509cset.lo \ x509/libcrypto_la-x509name.lo x509/libcrypto_la-x509rset.lo \ x509/libcrypto_la-x509spki.lo x509/libcrypto_la-x509type.lo \ x509/libcrypto_la-x_all.lo x509v3/libcrypto_la-pcy_cache.lo \ x509v3/libcrypto_la-pcy_data.lo x509v3/libcrypto_la-pcy_lib.lo \ x509v3/libcrypto_la-pcy_map.lo x509v3/libcrypto_la-pcy_node.lo \ x509v3/libcrypto_la-pcy_tree.lo x509v3/libcrypto_la-v3_akey.lo \ x509v3/libcrypto_la-v3_akeya.lo x509v3/libcrypto_la-v3_alt.lo \ x509v3/libcrypto_la-v3_bcons.lo \ x509v3/libcrypto_la-v3_bitst.lo x509v3/libcrypto_la-v3_conf.lo \ x509v3/libcrypto_la-v3_cpols.lo x509v3/libcrypto_la-v3_crld.lo \ x509v3/libcrypto_la-v3_enum.lo x509v3/libcrypto_la-v3_extku.lo \ x509v3/libcrypto_la-v3_genn.lo x509v3/libcrypto_la-v3_ia5.lo \ x509v3/libcrypto_la-v3_info.lo x509v3/libcrypto_la-v3_int.lo \ x509v3/libcrypto_la-v3_lib.lo x509v3/libcrypto_la-v3_ncons.lo \ x509v3/libcrypto_la-v3_ocsp.lo x509v3/libcrypto_la-v3_pci.lo \ x509v3/libcrypto_la-v3_pcia.lo x509v3/libcrypto_la-v3_pcons.lo \ x509v3/libcrypto_la-v3_pku.lo x509v3/libcrypto_la-v3_pmaps.lo \ x509v3/libcrypto_la-v3_prn.lo x509v3/libcrypto_la-v3_purp.lo \ x509v3/libcrypto_la-v3_skey.lo x509v3/libcrypto_la-v3_sxnet.lo \ x509v3/libcrypto_la-v3_utl.lo x509v3/libcrypto_la-v3err.lo libcrypto_la_OBJECTS = $(am_libcrypto_la_OBJECTS) libcrypto_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libcrypto_la_CFLAGS) \ $(CFLAGS) $(libcrypto_la_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libcompat_la_SOURCES) $(libcompatnoopt_la_SOURCES) \ $(libcrypto_la_SOURCES) $(EXTRA_libcrypto_la_SOURCES) DIST_SOURCES = $(am__libcompat_la_SOURCES_DIST) \ $(libcompatnoopt_la_SOURCES) $(libcrypto_la_SOURCES) \ $(EXTRA_libcrypto_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac HEADERS = $(noinst_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ NO_ARC4RANDOM_BUF = @NO_ARC4RANDOM_BUF@ NO_GETENTROPY = @NO_GETENTROPY@ NO_ISSETUGID = @NO_ISSETUGID@ NO_REALLOCARRAY = @NO_REALLOCARRAY@ NO_STRLCAT = @NO_STRLCAT@ NO_STRLCPY = @NO_STRLCPY@ NO_STRTONUM = @NO_STRTONUM@ NO_TIMINGSAFE_BCMP = @NO_TIMINGSAFE_BCMP@ NO_TIMINGSAFE_MEMCMP = @NO_TIMINGSAFE_MEMCMP@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PLATFORM_LDADD = @PLATFORM_LDADD@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ USER_CFLAGS = @USER_CFLAGS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = -I$(top_srcdir)/include -DOPENSSL_NO_ASM \ -DHAVE_CRYPTODEV -DLIBRESSL_INTERNAL \ -I$(top_srcdir)/crypto/asn1 -I$(top_srcdir)/crypto/evp \ -I$(top_srcdir)/crypto/modes lib_LTLIBRARIES = libcrypto.la libcrypto_la_LIBADD = libcompat.la libcompatnoopt.la libcrypto_la_LDFLAGS = -version-info 29:0:0 libcrypto_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS) -DOPENSSL_NO_HW_PADLOCK noinst_LTLIBRARIES = libcompat.la libcompatnoopt.la # compatibility functions that need to be built without optimizations libcompatnoopt_la_CFLAGS = -O0 libcompatnoopt_la_SOURCES = compat/explicit_bzero.c # other compatibility functions libcompat_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS) libcompat_la_SOURCES = $(am__append_1) $(am__append_2) $(am__append_3) \ $(am__append_4) $(am__append_5) $(am__append_6) \ $(am__append_7) $(am__append_8) $(am__append_9) \ $(am__append_10) $(am__append_11) noinst_HEADERS = des/ncbc_enc.c compat/thread_private.h \ compat/chacha_private.h cryptlib.h md32_common.h o_time.h \ aes/aes_locl.h asn1/asn1_locl.h asn1/charmap.h bf/bf_locl.h \ bf/bf_pi.h bn/bn_lcl.h bn/bn_prime.h cast/cast_lcl.h \ cast/cast_s.h conf/conf_def.h des/des_locl.h des/spr.h \ dsa/dsa_locl.h ec/ec_lcl.h ecdh/ech_locl.h ecdsa/ecs_locl.h \ engine/eng_int.h evp/evp_locl.h idea/idea_lcl.h md4/md4_locl.h \ md5/md5_locl.h modes/modes_lcl.h objects/obj_dat.h \ objects/obj_xref.h rc2/rc2_locl.h rc4/rc4_locl.h \ ripemd/rmd_locl.h ripemd/rmdconst.h rsa/rsa_locl.h \ sha/sha_locl.h ui/ui_locl.h whrlpool/wp_locl.h x509/x509_lcl.h \ x509v3/ext_dat.h x509v3/pcy_int.h libcrypto_la_SOURCES = cpt_err.c cryptlib.c cversion.c ex_data.c \ malloc-wrapper.c mem_clr.c mem_dbg.c o_init.c o_str.c o_time.c \ aes/aes_cbc.c aes/aes_cfb.c aes/aes_core.c aes/aes_ctr.c \ aes/aes_ecb.c aes/aes_ige.c aes/aes_misc.c aes/aes_ofb.c \ aes/aes_wrap.c asn1/a_bitstr.c asn1/a_bool.c asn1/a_bytes.c \ asn1/a_d2i_fp.c asn1/a_digest.c asn1/a_dup.c asn1/a_enum.c \ asn1/a_gentm.c asn1/a_i2d_fp.c asn1/a_int.c asn1/a_mbstr.c \ asn1/a_object.c asn1/a_octet.c asn1/a_print.c asn1/a_set.c \ asn1/a_sign.c asn1/a_strex.c asn1/a_strnid.c asn1/a_time.c \ asn1/a_type.c asn1/a_utctm.c asn1/a_utf8.c asn1/a_verify.c \ asn1/ameth_lib.c asn1/asn1_err.c asn1/asn1_gen.c \ asn1/asn1_lib.c asn1/asn1_par.c asn1/asn_mime.c \ asn1/asn_moid.c asn1/asn_pack.c asn1/bio_asn1.c \ asn1/bio_ndef.c asn1/d2i_pr.c asn1/d2i_pu.c asn1/evp_asn1.c \ asn1/f_enum.c asn1/f_int.c asn1/f_string.c asn1/i2d_pr.c \ asn1/i2d_pu.c asn1/n_pkey.c asn1/nsseq.c asn1/p5_pbe.c \ asn1/p5_pbev2.c asn1/p8_pkey.c asn1/t_bitst.c asn1/t_crl.c \ asn1/t_pkey.c asn1/t_req.c asn1/t_spki.c asn1/t_x509.c \ asn1/t_x509a.c asn1/tasn_dec.c asn1/tasn_enc.c asn1/tasn_fre.c \ asn1/tasn_new.c asn1/tasn_prn.c asn1/tasn_typ.c \ asn1/tasn_utl.c asn1/x_algor.c asn1/x_attrib.c asn1/x_bignum.c \ asn1/x_crl.c asn1/x_exten.c asn1/x_info.c asn1/x_long.c \ asn1/x_name.c asn1/x_nx509.c asn1/x_pkey.c asn1/x_pubkey.c \ asn1/x_req.c asn1/x_sig.c asn1/x_spki.c asn1/x_val.c \ asn1/x_x509.c asn1/x_x509a.c bf/bf_cfb64.c bf/bf_ecb.c \ bf/bf_enc.c bf/bf_ofb64.c bf/bf_skey.c bio/b_dump.c \ bio/b_print.c bio/b_sock.c bio/bf_buff.c bio/bf_nbio.c \ bio/bf_null.c bio/bio_cb.c bio/bio_err.c bio/bio_lib.c \ bio/bss_acpt.c bio/bss_bio.c bio/bss_conn.c bio/bss_dgram.c \ bio/bss_fd.c bio/bss_file.c bio/bss_log.c bio/bss_mem.c \ bio/bss_null.c bio/bss_sock.c bn/bn_add.c bn/bn_asm.c \ bn/bn_blind.c bn/bn_const.c bn/bn_ctx.c bn/bn_depr.c \ bn/bn_div.c bn/bn_err.c bn/bn_exp.c bn/bn_exp2.c bn/bn_gcd.c \ bn/bn_gf2m.c bn/bn_kron.c bn/bn_lib.c bn/bn_mod.c bn/bn_mont.c \ bn/bn_mpi.c bn/bn_mul.c bn/bn_nist.c bn/bn_prime.c \ bn/bn_print.c bn/bn_rand.c bn/bn_recp.c bn/bn_shift.c \ bn/bn_sqr.c bn/bn_sqrt.c bn/bn_word.c bn/bn_x931p.c \ buffer/buf_err.c buffer/buf_str.c buffer/buffer.c \ cast/c_cfb64.c cast/c_ecb.c cast/c_enc.c cast/c_ofb64.c \ cast/c_skey.c chacha/chacha.c cmac/cm_ameth.c cmac/cm_pmeth.c \ cmac/cmac.c comp/c_rle.c comp/c_zlib.c comp/comp_err.c \ comp/comp_lib.c conf/conf_api.c conf/conf_def.c \ conf/conf_err.c conf/conf_lib.c conf/conf_mall.c \ conf/conf_mod.c conf/conf_sap.c des/cbc_cksm.c des/cbc_enc.c \ des/cfb64ede.c des/cfb64enc.c des/cfb_enc.c des/des_enc.c \ des/ecb3_enc.c des/ecb_enc.c des/ede_cbcm_enc.c des/enc_read.c \ des/enc_writ.c des/fcrypt.c des/fcrypt_b.c des/ofb64ede.c \ des/ofb64enc.c des/ofb_enc.c des/pcbc_enc.c des/qud_cksm.c \ des/rand_key.c des/set_key.c des/str2key.c des/xcbc_enc.c \ dh/dh_ameth.c dh/dh_asn1.c dh/dh_check.c dh/dh_depr.c \ dh/dh_err.c dh/dh_gen.c dh/dh_key.c dh/dh_lib.c dh/dh_pmeth.c \ dh/dh_prn.c dsa/dsa_ameth.c dsa/dsa_asn1.c dsa/dsa_depr.c \ dsa/dsa_err.c dsa/dsa_gen.c dsa/dsa_key.c dsa/dsa_lib.c \ dsa/dsa_ossl.c dsa/dsa_pmeth.c dsa/dsa_prn.c dsa/dsa_sign.c \ dsa/dsa_vrf.c dso/dso_dlfcn.c dso/dso_err.c dso/dso_lib.c \ dso/dso_null.c dso/dso_openssl.c ec/ec2_mult.c ec/ec2_oct.c \ ec/ec2_smpl.c ec/ec_ameth.c ec/ec_asn1.c ec/ec_check.c \ ec/ec_curve.c ec/ec_cvt.c ec/ec_err.c ec/ec_key.c ec/ec_lib.c \ ec/ec_mult.c ec/ec_oct.c ec/ec_pmeth.c ec/ec_print.c \ ec/eck_prn.c ec/ecp_mont.c ec/ecp_nist.c ec/ecp_oct.c \ ec/ecp_smpl.c ecdh/ech_err.c ecdh/ech_key.c ecdh/ech_lib.c \ ecdh/ech_ossl.c ecdsa/ecs_asn1.c ecdsa/ecs_err.c \ ecdsa/ecs_lib.c ecdsa/ecs_ossl.c ecdsa/ecs_sign.c \ ecdsa/ecs_vrf.c engine/eng_all.c engine/eng_cnf.c \ engine/eng_ctrl.c engine/eng_dyn.c engine/eng_err.c \ engine/eng_fat.c engine/eng_init.c engine/eng_lib.c \ engine/eng_list.c engine/eng_openssl.c engine/eng_pkey.c \ engine/eng_rsax.c engine/eng_table.c engine/tb_asnmth.c \ engine/tb_cipher.c engine/tb_dh.c engine/tb_digest.c \ engine/tb_dsa.c engine/tb_ecdh.c engine/tb_ecdsa.c \ engine/tb_pkmeth.c engine/tb_rand.c engine/tb_rsa.c \ engine/tb_store.c err/err.c err/err_all.c err/err_prn.c \ evp/bio_b64.c evp/bio_enc.c evp/bio_md.c evp/c_all.c \ evp/c_allc.c evp/c_alld.c evp/digest.c evp/e_aes.c \ evp/e_aes_cbc_hmac_sha1.c evp/e_bf.c evp/e_cast.c \ evp/e_chacha.c evp/e_chacha20poly1305.c evp/e_des.c \ evp/e_des3.c evp/e_idea.c evp/e_null.c evp/e_old.c evp/e_rc2.c \ evp/e_rc4.c evp/e_rc4_hmac_md5.c evp/e_xcbc_d.c evp/encode.c \ evp/evp_aead.c evp/evp_enc.c evp/evp_err.c evp/evp_key.c \ evp/evp_lib.c evp/evp_pbe.c evp/evp_pkey.c evp/m_dss.c \ evp/m_dss1.c evp/m_ecdsa.c evp/m_md4.c evp/m_md5.c \ evp/m_mdc2.c evp/m_null.c evp/m_ripemd.c evp/m_sha.c \ evp/m_sha1.c evp/m_sigver.c evp/m_wp.c evp/names.c \ evp/p5_crpt.c evp/p5_crpt2.c evp/p_dec.c evp/p_enc.c \ evp/p_lib.c evp/p_open.c evp/p_seal.c evp/p_sign.c \ evp/p_verify.c evp/pmeth_fn.c evp/pmeth_gn.c evp/pmeth_lib.c \ hmac/hm_ameth.c hmac/hm_pmeth.c hmac/hmac.c idea/i_cbc.c \ idea/i_cfb64.c idea/i_ecb.c idea/i_ofb64.c idea/i_skey.c \ krb5/krb5_asn.c lhash/lh_stats.c lhash/lhash.c md4/md4_dgst.c \ md4/md4_one.c md5/md5_dgst.c md5/md5_one.c mdc2/mdc2_one.c \ mdc2/mdc2dgst.c modes/cbc128.c modes/ccm128.c modes/cfb128.c \ modes/ctr128.c modes/cts128.c modes/gcm128.c modes/ofb128.c \ modes/xts128.c objects/o_names.c objects/obj_dat.c \ objects/obj_err.c objects/obj_lib.c objects/obj_xref.c \ ocsp/ocsp_asn.c ocsp/ocsp_cl.c ocsp/ocsp_err.c ocsp/ocsp_ext.c \ ocsp/ocsp_ht.c ocsp/ocsp_lib.c ocsp/ocsp_prn.c ocsp/ocsp_srv.c \ ocsp/ocsp_vfy.c pem/pem_all.c pem/pem_err.c pem/pem_info.c \ pem/pem_lib.c pem/pem_oth.c pem/pem_pk8.c pem/pem_pkey.c \ pem/pem_seal.c pem/pem_sign.c pem/pem_x509.c pem/pem_xaux.c \ pem/pvkfmt.c pkcs12/p12_add.c pkcs12/p12_asn.c \ pkcs12/p12_attr.c pkcs12/p12_crpt.c pkcs12/p12_crt.c \ pkcs12/p12_decr.c pkcs12/p12_init.c pkcs12/p12_key.c \ pkcs12/p12_kiss.c pkcs12/p12_mutl.c pkcs12/p12_npas.c \ pkcs12/p12_p8d.c pkcs12/p12_p8e.c pkcs12/p12_utl.c \ pkcs12/pk12err.c pkcs7/bio_pk7.c pkcs7/pk7_asn1.c \ pkcs7/pk7_attr.c pkcs7/pk7_doit.c pkcs7/pk7_lib.c \ pkcs7/pk7_mime.c pkcs7/pk7_smime.c pkcs7/pkcs7err.c \ poly1305/poly1305.c rand/rand_err.c rand/rand_lib.c \ rand/randfile.c rc2/rc2_cbc.c rc2/rc2_ecb.c rc2/rc2_skey.c \ rc2/rc2cfb64.c rc2/rc2ofb64.c rc4/rc4_enc.c rc4/rc4_skey.c \ rc4/rc4_utl.c ripemd/rmd_dgst.c ripemd/rmd_one.c \ rsa/rsa_ameth.c rsa/rsa_asn1.c rsa/rsa_chk.c rsa/rsa_crpt.c \ rsa/rsa_depr.c rsa/rsa_eay.c rsa/rsa_err.c rsa/rsa_gen.c \ rsa/rsa_lib.c rsa/rsa_none.c rsa/rsa_oaep.c rsa/rsa_pk1.c \ rsa/rsa_pmeth.c rsa/rsa_prn.c rsa/rsa_pss.c rsa/rsa_saos.c \ rsa/rsa_sign.c rsa/rsa_ssl.c rsa/rsa_x931.c sha/sha1_one.c \ sha/sha1dgst.c sha/sha256.c sha/sha512.c sha/sha_dgst.c \ sha/sha_one.c stack/stack.c ts/ts_asn1.c ts/ts_conf.c \ ts/ts_err.c ts/ts_lib.c ts/ts_req_print.c ts/ts_req_utils.c \ ts/ts_rsp_print.c ts/ts_rsp_sign.c ts/ts_rsp_utils.c \ ts/ts_rsp_verify.c ts/ts_verify_ctx.c txt_db/txt_db.c \ ui/ui_err.c ui/ui_lib.c ui/ui_openssl.c ui/ui_util.c \ whrlpool/wp_block.c whrlpool/wp_dgst.c x509/by_dir.c \ x509/by_file.c x509/x509_att.c x509/x509_cmp.c x509/x509_d2.c \ x509/x509_def.c x509/x509_err.c x509/x509_ext.c x509/x509_lu.c \ x509/x509_obj.c x509/x509_r2x.c x509/x509_req.c \ x509/x509_set.c x509/x509_trs.c x509/x509_txt.c x509/x509_v3.c \ x509/x509_vfy.c x509/x509_vpm.c x509/x509cset.c \ x509/x509name.c x509/x509rset.c x509/x509spki.c \ x509/x509type.c x509/x_all.c x509v3/pcy_cache.c \ x509v3/pcy_data.c x509v3/pcy_lib.c x509v3/pcy_map.c \ x509v3/pcy_node.c x509v3/pcy_tree.c x509v3/v3_akey.c \ x509v3/v3_akeya.c x509v3/v3_alt.c x509v3/v3_bcons.c \ x509v3/v3_bitst.c x509v3/v3_conf.c x509v3/v3_cpols.c \ x509v3/v3_crld.c x509v3/v3_enum.c x509v3/v3_extku.c \ x509v3/v3_genn.c x509v3/v3_ia5.c x509v3/v3_info.c \ x509v3/v3_int.c x509v3/v3_lib.c x509v3/v3_ncons.c \ x509v3/v3_ocsp.c x509v3/v3_pci.c x509v3/v3_pcia.c \ x509v3/v3_pcons.c x509v3/v3_pku.c x509v3/v3_pmaps.c \ x509v3/v3_prn.c x509v3/v3_purp.c x509v3/v3_skey.c \ x509v3/v3_sxnet.c x509v3/v3_utl.c x509v3/v3err.c EXTRA_libcrypto_la_SOURCES = des/ncbc_enc.c chacha/chacha-merged.c \ poly1305/poly1305-donna.c all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.am.common $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu crypto/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu crypto/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_srcdir)/Makefile.am.common: $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } compat/$(am__dirstamp): @$(MKDIR_P) compat @: > compat/$(am__dirstamp) compat/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) compat/$(DEPDIR) @: > compat/$(DEPDIR)/$(am__dirstamp) compat/libcompat_la-strlcat.lo: compat/$(am__dirstamp) \ compat/$(DEPDIR)/$(am__dirstamp) compat/libcompat_la-strlcpy.lo: compat/$(am__dirstamp) \ compat/$(DEPDIR)/$(am__dirstamp) compat/libcompat_la-reallocarray.lo: compat/$(am__dirstamp) \ compat/$(DEPDIR)/$(am__dirstamp) compat/libcompat_la-timingsafe_memcmp.lo: compat/$(am__dirstamp) \ compat/$(DEPDIR)/$(am__dirstamp) compat/libcompat_la-timingsafe_bcmp.lo: compat/$(am__dirstamp) \ compat/$(DEPDIR)/$(am__dirstamp) compat/libcompat_la-arc4random.lo: compat/$(am__dirstamp) \ compat/$(DEPDIR)/$(am__dirstamp) compat/libcompat_la-getentropy_linux.lo: compat/$(am__dirstamp) \ compat/$(DEPDIR)/$(am__dirstamp) compat/libcompat_la-getentropy_osx.lo: compat/$(am__dirstamp) \ compat/$(DEPDIR)/$(am__dirstamp) compat/libcompat_la-getentropy_solaris.lo: compat/$(am__dirstamp) \ compat/$(DEPDIR)/$(am__dirstamp) compat/libcompat_la-getentropy_nacl.lo: compat/$(am__dirstamp) \ compat/$(DEPDIR)/$(am__dirstamp) compat/libcompat_la-issetugid_linux.lo: compat/$(am__dirstamp) \ compat/$(DEPDIR)/$(am__dirstamp) libcompat.la: $(libcompat_la_OBJECTS) $(libcompat_la_DEPENDENCIES) $(EXTRA_libcompat_la_DEPENDENCIES) $(AM_V_CCLD)$(libcompat_la_LINK) $(libcompat_la_OBJECTS) $(libcompat_la_LIBADD) $(LIBS) compat/libcompatnoopt_la-explicit_bzero.lo: compat/$(am__dirstamp) \ compat/$(DEPDIR)/$(am__dirstamp) libcompatnoopt.la: $(libcompatnoopt_la_OBJECTS) $(libcompatnoopt_la_DEPENDENCIES) $(EXTRA_libcompatnoopt_la_DEPENDENCIES) $(AM_V_CCLD)$(libcompatnoopt_la_LINK) $(libcompatnoopt_la_OBJECTS) $(libcompatnoopt_la_LIBADD) $(LIBS) aes/$(am__dirstamp): @$(MKDIR_P) aes @: > aes/$(am__dirstamp) aes/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) aes/$(DEPDIR) @: > aes/$(DEPDIR)/$(am__dirstamp) aes/libcrypto_la-aes_cbc.lo: aes/$(am__dirstamp) \ aes/$(DEPDIR)/$(am__dirstamp) aes/libcrypto_la-aes_cfb.lo: aes/$(am__dirstamp) \ aes/$(DEPDIR)/$(am__dirstamp) aes/libcrypto_la-aes_core.lo: aes/$(am__dirstamp) \ aes/$(DEPDIR)/$(am__dirstamp) aes/libcrypto_la-aes_ctr.lo: aes/$(am__dirstamp) \ aes/$(DEPDIR)/$(am__dirstamp) aes/libcrypto_la-aes_ecb.lo: aes/$(am__dirstamp) \ aes/$(DEPDIR)/$(am__dirstamp) aes/libcrypto_la-aes_ige.lo: aes/$(am__dirstamp) \ aes/$(DEPDIR)/$(am__dirstamp) aes/libcrypto_la-aes_misc.lo: aes/$(am__dirstamp) \ aes/$(DEPDIR)/$(am__dirstamp) aes/libcrypto_la-aes_ofb.lo: aes/$(am__dirstamp) \ aes/$(DEPDIR)/$(am__dirstamp) aes/libcrypto_la-aes_wrap.lo: aes/$(am__dirstamp) \ aes/$(DEPDIR)/$(am__dirstamp) asn1/$(am__dirstamp): @$(MKDIR_P) asn1 @: > asn1/$(am__dirstamp) asn1/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) asn1/$(DEPDIR) @: > asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_bitstr.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_bool.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_bytes.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_d2i_fp.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_digest.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_dup.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_enum.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_gentm.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_i2d_fp.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_int.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_mbstr.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_object.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_octet.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_print.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_set.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_sign.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_strex.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_strnid.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_time.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_type.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_utctm.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_utf8.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_verify.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-ameth_lib.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-asn1_err.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-asn1_gen.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-asn1_lib.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-asn1_par.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-asn_mime.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-asn_moid.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-asn_pack.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-bio_asn1.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-bio_ndef.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-d2i_pr.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-d2i_pu.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-evp_asn1.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-f_enum.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-f_int.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-f_string.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-i2d_pr.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-i2d_pu.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-n_pkey.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-nsseq.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-p5_pbe.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-p5_pbev2.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-p8_pkey.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-t_bitst.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-t_crl.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-t_pkey.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-t_req.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-t_spki.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-t_x509.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-t_x509a.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-tasn_dec.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-tasn_enc.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-tasn_fre.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-tasn_new.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-tasn_prn.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-tasn_typ.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-tasn_utl.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_algor.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_attrib.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_bignum.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_crl.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_exten.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_info.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_long.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_name.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_nx509.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_pkey.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_pubkey.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_req.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_sig.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_spki.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_val.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_x509.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-x_x509a.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) bf/$(am__dirstamp): @$(MKDIR_P) bf @: > bf/$(am__dirstamp) bf/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) bf/$(DEPDIR) @: > bf/$(DEPDIR)/$(am__dirstamp) bf/libcrypto_la-bf_cfb64.lo: bf/$(am__dirstamp) \ bf/$(DEPDIR)/$(am__dirstamp) bf/libcrypto_la-bf_ecb.lo: bf/$(am__dirstamp) \ bf/$(DEPDIR)/$(am__dirstamp) bf/libcrypto_la-bf_enc.lo: bf/$(am__dirstamp) \ bf/$(DEPDIR)/$(am__dirstamp) bf/libcrypto_la-bf_ofb64.lo: bf/$(am__dirstamp) \ bf/$(DEPDIR)/$(am__dirstamp) bf/libcrypto_la-bf_skey.lo: bf/$(am__dirstamp) \ bf/$(DEPDIR)/$(am__dirstamp) bio/$(am__dirstamp): @$(MKDIR_P) bio @: > bio/$(am__dirstamp) bio/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) bio/$(DEPDIR) @: > bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-b_dump.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-b_print.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-b_sock.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-bf_buff.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-bf_nbio.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-bf_null.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-bio_cb.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-bio_err.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-bio_lib.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-bss_acpt.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-bss_bio.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-bss_conn.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-bss_dgram.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-bss_fd.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-bss_file.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-bss_log.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-bss_mem.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-bss_null.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bio/libcrypto_la-bss_sock.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bn/$(am__dirstamp): @$(MKDIR_P) bn @: > bn/$(am__dirstamp) bn/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) bn/$(DEPDIR) @: > bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_add.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_asm.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_blind.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_const.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_ctx.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_depr.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_div.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_err.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_exp.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_exp2.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_gcd.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_gf2m.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_kron.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_lib.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_mod.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_mont.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_mpi.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_mul.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_nist.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_prime.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_print.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_rand.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_recp.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_shift.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_sqr.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_sqrt.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_word.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_x931p.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) buffer/$(am__dirstamp): @$(MKDIR_P) buffer @: > buffer/$(am__dirstamp) buffer/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) buffer/$(DEPDIR) @: > buffer/$(DEPDIR)/$(am__dirstamp) buffer/libcrypto_la-buf_err.lo: buffer/$(am__dirstamp) \ buffer/$(DEPDIR)/$(am__dirstamp) buffer/libcrypto_la-buf_str.lo: buffer/$(am__dirstamp) \ buffer/$(DEPDIR)/$(am__dirstamp) buffer/libcrypto_la-buffer.lo: buffer/$(am__dirstamp) \ buffer/$(DEPDIR)/$(am__dirstamp) cast/$(am__dirstamp): @$(MKDIR_P) cast @: > cast/$(am__dirstamp) cast/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) cast/$(DEPDIR) @: > cast/$(DEPDIR)/$(am__dirstamp) cast/libcrypto_la-c_cfb64.lo: cast/$(am__dirstamp) \ cast/$(DEPDIR)/$(am__dirstamp) cast/libcrypto_la-c_ecb.lo: cast/$(am__dirstamp) \ cast/$(DEPDIR)/$(am__dirstamp) cast/libcrypto_la-c_enc.lo: cast/$(am__dirstamp) \ cast/$(DEPDIR)/$(am__dirstamp) cast/libcrypto_la-c_ofb64.lo: cast/$(am__dirstamp) \ cast/$(DEPDIR)/$(am__dirstamp) cast/libcrypto_la-c_skey.lo: cast/$(am__dirstamp) \ cast/$(DEPDIR)/$(am__dirstamp) chacha/$(am__dirstamp): @$(MKDIR_P) chacha @: > chacha/$(am__dirstamp) chacha/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) chacha/$(DEPDIR) @: > chacha/$(DEPDIR)/$(am__dirstamp) chacha/libcrypto_la-chacha.lo: chacha/$(am__dirstamp) \ chacha/$(DEPDIR)/$(am__dirstamp) cmac/$(am__dirstamp): @$(MKDIR_P) cmac @: > cmac/$(am__dirstamp) cmac/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) cmac/$(DEPDIR) @: > cmac/$(DEPDIR)/$(am__dirstamp) cmac/libcrypto_la-cm_ameth.lo: cmac/$(am__dirstamp) \ cmac/$(DEPDIR)/$(am__dirstamp) cmac/libcrypto_la-cm_pmeth.lo: cmac/$(am__dirstamp) \ cmac/$(DEPDIR)/$(am__dirstamp) cmac/libcrypto_la-cmac.lo: cmac/$(am__dirstamp) \ cmac/$(DEPDIR)/$(am__dirstamp) comp/$(am__dirstamp): @$(MKDIR_P) comp @: > comp/$(am__dirstamp) comp/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) comp/$(DEPDIR) @: > comp/$(DEPDIR)/$(am__dirstamp) comp/libcrypto_la-c_rle.lo: comp/$(am__dirstamp) \ comp/$(DEPDIR)/$(am__dirstamp) comp/libcrypto_la-c_zlib.lo: comp/$(am__dirstamp) \ comp/$(DEPDIR)/$(am__dirstamp) comp/libcrypto_la-comp_err.lo: comp/$(am__dirstamp) \ comp/$(DEPDIR)/$(am__dirstamp) comp/libcrypto_la-comp_lib.lo: comp/$(am__dirstamp) \ comp/$(DEPDIR)/$(am__dirstamp) conf/$(am__dirstamp): @$(MKDIR_P) conf @: > conf/$(am__dirstamp) conf/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) conf/$(DEPDIR) @: > conf/$(DEPDIR)/$(am__dirstamp) conf/libcrypto_la-conf_api.lo: conf/$(am__dirstamp) \ conf/$(DEPDIR)/$(am__dirstamp) conf/libcrypto_la-conf_def.lo: conf/$(am__dirstamp) \ conf/$(DEPDIR)/$(am__dirstamp) conf/libcrypto_la-conf_err.lo: conf/$(am__dirstamp) \ conf/$(DEPDIR)/$(am__dirstamp) conf/libcrypto_la-conf_lib.lo: conf/$(am__dirstamp) \ conf/$(DEPDIR)/$(am__dirstamp) conf/libcrypto_la-conf_mall.lo: conf/$(am__dirstamp) \ conf/$(DEPDIR)/$(am__dirstamp) conf/libcrypto_la-conf_mod.lo: conf/$(am__dirstamp) \ conf/$(DEPDIR)/$(am__dirstamp) conf/libcrypto_la-conf_sap.lo: conf/$(am__dirstamp) \ conf/$(DEPDIR)/$(am__dirstamp) des/$(am__dirstamp): @$(MKDIR_P) des @: > des/$(am__dirstamp) des/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) des/$(DEPDIR) @: > des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-cbc_cksm.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-cbc_enc.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-cfb64ede.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-cfb64enc.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-cfb_enc.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-des_enc.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-ecb3_enc.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-ecb_enc.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-ede_cbcm_enc.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-enc_read.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-enc_writ.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-fcrypt.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-fcrypt_b.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-ofb64ede.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-ofb64enc.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-ofb_enc.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-pcbc_enc.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-qud_cksm.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-rand_key.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-set_key.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-str2key.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-xcbc_enc.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) dh/$(am__dirstamp): @$(MKDIR_P) dh @: > dh/$(am__dirstamp) dh/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) dh/$(DEPDIR) @: > dh/$(DEPDIR)/$(am__dirstamp) dh/libcrypto_la-dh_ameth.lo: dh/$(am__dirstamp) \ dh/$(DEPDIR)/$(am__dirstamp) dh/libcrypto_la-dh_asn1.lo: dh/$(am__dirstamp) \ dh/$(DEPDIR)/$(am__dirstamp) dh/libcrypto_la-dh_check.lo: dh/$(am__dirstamp) \ dh/$(DEPDIR)/$(am__dirstamp) dh/libcrypto_la-dh_depr.lo: dh/$(am__dirstamp) \ dh/$(DEPDIR)/$(am__dirstamp) dh/libcrypto_la-dh_err.lo: dh/$(am__dirstamp) \ dh/$(DEPDIR)/$(am__dirstamp) dh/libcrypto_la-dh_gen.lo: dh/$(am__dirstamp) \ dh/$(DEPDIR)/$(am__dirstamp) dh/libcrypto_la-dh_key.lo: dh/$(am__dirstamp) \ dh/$(DEPDIR)/$(am__dirstamp) dh/libcrypto_la-dh_lib.lo: dh/$(am__dirstamp) \ dh/$(DEPDIR)/$(am__dirstamp) dh/libcrypto_la-dh_pmeth.lo: dh/$(am__dirstamp) \ dh/$(DEPDIR)/$(am__dirstamp) dh/libcrypto_la-dh_prn.lo: dh/$(am__dirstamp) \ dh/$(DEPDIR)/$(am__dirstamp) dsa/$(am__dirstamp): @$(MKDIR_P) dsa @: > dsa/$(am__dirstamp) dsa/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) dsa/$(DEPDIR) @: > dsa/$(DEPDIR)/$(am__dirstamp) dsa/libcrypto_la-dsa_ameth.lo: dsa/$(am__dirstamp) \ dsa/$(DEPDIR)/$(am__dirstamp) dsa/libcrypto_la-dsa_asn1.lo: dsa/$(am__dirstamp) \ dsa/$(DEPDIR)/$(am__dirstamp) dsa/libcrypto_la-dsa_depr.lo: dsa/$(am__dirstamp) \ dsa/$(DEPDIR)/$(am__dirstamp) dsa/libcrypto_la-dsa_err.lo: dsa/$(am__dirstamp) \ dsa/$(DEPDIR)/$(am__dirstamp) dsa/libcrypto_la-dsa_gen.lo: dsa/$(am__dirstamp) \ dsa/$(DEPDIR)/$(am__dirstamp) dsa/libcrypto_la-dsa_key.lo: dsa/$(am__dirstamp) \ dsa/$(DEPDIR)/$(am__dirstamp) dsa/libcrypto_la-dsa_lib.lo: dsa/$(am__dirstamp) \ dsa/$(DEPDIR)/$(am__dirstamp) dsa/libcrypto_la-dsa_ossl.lo: dsa/$(am__dirstamp) \ dsa/$(DEPDIR)/$(am__dirstamp) dsa/libcrypto_la-dsa_pmeth.lo: dsa/$(am__dirstamp) \ dsa/$(DEPDIR)/$(am__dirstamp) dsa/libcrypto_la-dsa_prn.lo: dsa/$(am__dirstamp) \ dsa/$(DEPDIR)/$(am__dirstamp) dsa/libcrypto_la-dsa_sign.lo: dsa/$(am__dirstamp) \ dsa/$(DEPDIR)/$(am__dirstamp) dsa/libcrypto_la-dsa_vrf.lo: dsa/$(am__dirstamp) \ dsa/$(DEPDIR)/$(am__dirstamp) dso/$(am__dirstamp): @$(MKDIR_P) dso @: > dso/$(am__dirstamp) dso/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) dso/$(DEPDIR) @: > dso/$(DEPDIR)/$(am__dirstamp) dso/libcrypto_la-dso_dlfcn.lo: dso/$(am__dirstamp) \ dso/$(DEPDIR)/$(am__dirstamp) dso/libcrypto_la-dso_err.lo: dso/$(am__dirstamp) \ dso/$(DEPDIR)/$(am__dirstamp) dso/libcrypto_la-dso_lib.lo: dso/$(am__dirstamp) \ dso/$(DEPDIR)/$(am__dirstamp) dso/libcrypto_la-dso_null.lo: dso/$(am__dirstamp) \ dso/$(DEPDIR)/$(am__dirstamp) dso/libcrypto_la-dso_openssl.lo: dso/$(am__dirstamp) \ dso/$(DEPDIR)/$(am__dirstamp) ec/$(am__dirstamp): @$(MKDIR_P) ec @: > ec/$(am__dirstamp) ec/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) ec/$(DEPDIR) @: > ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ec2_mult.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ec2_oct.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ec2_smpl.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ec_ameth.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ec_asn1.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ec_check.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ec_curve.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ec_cvt.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ec_err.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ec_key.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ec_lib.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ec_mult.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ec_oct.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ec_pmeth.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ec_print.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-eck_prn.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ecp_mont.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ecp_nist.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ecp_oct.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ecp_smpl.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ecdh/$(am__dirstamp): @$(MKDIR_P) ecdh @: > ecdh/$(am__dirstamp) ecdh/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) ecdh/$(DEPDIR) @: > ecdh/$(DEPDIR)/$(am__dirstamp) ecdh/libcrypto_la-ech_err.lo: ecdh/$(am__dirstamp) \ ecdh/$(DEPDIR)/$(am__dirstamp) ecdh/libcrypto_la-ech_key.lo: ecdh/$(am__dirstamp) \ ecdh/$(DEPDIR)/$(am__dirstamp) ecdh/libcrypto_la-ech_lib.lo: ecdh/$(am__dirstamp) \ ecdh/$(DEPDIR)/$(am__dirstamp) ecdh/libcrypto_la-ech_ossl.lo: ecdh/$(am__dirstamp) \ ecdh/$(DEPDIR)/$(am__dirstamp) ecdsa/$(am__dirstamp): @$(MKDIR_P) ecdsa @: > ecdsa/$(am__dirstamp) ecdsa/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) ecdsa/$(DEPDIR) @: > ecdsa/$(DEPDIR)/$(am__dirstamp) ecdsa/libcrypto_la-ecs_asn1.lo: ecdsa/$(am__dirstamp) \ ecdsa/$(DEPDIR)/$(am__dirstamp) ecdsa/libcrypto_la-ecs_err.lo: ecdsa/$(am__dirstamp) \ ecdsa/$(DEPDIR)/$(am__dirstamp) ecdsa/libcrypto_la-ecs_lib.lo: ecdsa/$(am__dirstamp) \ ecdsa/$(DEPDIR)/$(am__dirstamp) ecdsa/libcrypto_la-ecs_ossl.lo: ecdsa/$(am__dirstamp) \ ecdsa/$(DEPDIR)/$(am__dirstamp) ecdsa/libcrypto_la-ecs_sign.lo: ecdsa/$(am__dirstamp) \ ecdsa/$(DEPDIR)/$(am__dirstamp) ecdsa/libcrypto_la-ecs_vrf.lo: ecdsa/$(am__dirstamp) \ ecdsa/$(DEPDIR)/$(am__dirstamp) engine/$(am__dirstamp): @$(MKDIR_P) engine @: > engine/$(am__dirstamp) engine/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) engine/$(DEPDIR) @: > engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-eng_all.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-eng_cnf.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-eng_ctrl.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-eng_dyn.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-eng_err.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-eng_fat.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-eng_init.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-eng_lib.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-eng_list.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-eng_openssl.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-eng_pkey.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-eng_rsax.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-eng_table.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-tb_asnmth.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-tb_cipher.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-tb_dh.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-tb_digest.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-tb_dsa.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-tb_ecdh.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-tb_ecdsa.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-tb_pkmeth.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-tb_rand.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-tb_rsa.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) engine/libcrypto_la-tb_store.lo: engine/$(am__dirstamp) \ engine/$(DEPDIR)/$(am__dirstamp) err/$(am__dirstamp): @$(MKDIR_P) err @: > err/$(am__dirstamp) err/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) err/$(DEPDIR) @: > err/$(DEPDIR)/$(am__dirstamp) err/libcrypto_la-err.lo: err/$(am__dirstamp) \ err/$(DEPDIR)/$(am__dirstamp) err/libcrypto_la-err_all.lo: err/$(am__dirstamp) \ err/$(DEPDIR)/$(am__dirstamp) err/libcrypto_la-err_prn.lo: err/$(am__dirstamp) \ err/$(DEPDIR)/$(am__dirstamp) evp/$(am__dirstamp): @$(MKDIR_P) evp @: > evp/$(am__dirstamp) evp/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) evp/$(DEPDIR) @: > evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-bio_b64.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-bio_enc.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-bio_md.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-c_all.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-c_allc.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-c_alld.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-digest.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-e_aes.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-e_aes_cbc_hmac_sha1.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-e_bf.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-e_cast.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-e_chacha.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-e_chacha20poly1305.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-e_des.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-e_des3.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-e_idea.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-e_null.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-e_old.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-e_rc2.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-e_rc4.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-e_rc4_hmac_md5.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-e_xcbc_d.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-encode.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-evp_aead.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-evp_enc.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-evp_err.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-evp_key.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-evp_lib.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-evp_pbe.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-evp_pkey.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-m_dss.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-m_dss1.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-m_ecdsa.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-m_md4.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-m_md5.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-m_mdc2.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-m_null.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-m_ripemd.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-m_sha.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-m_sha1.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-m_sigver.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-m_wp.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-names.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-p5_crpt.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-p5_crpt2.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-p_dec.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-p_enc.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-p_lib.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-p_open.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-p_seal.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-p_sign.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-p_verify.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-pmeth_fn.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-pmeth_gn.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-pmeth_lib.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) hmac/$(am__dirstamp): @$(MKDIR_P) hmac @: > hmac/$(am__dirstamp) hmac/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) hmac/$(DEPDIR) @: > hmac/$(DEPDIR)/$(am__dirstamp) hmac/libcrypto_la-hm_ameth.lo: hmac/$(am__dirstamp) \ hmac/$(DEPDIR)/$(am__dirstamp) hmac/libcrypto_la-hm_pmeth.lo: hmac/$(am__dirstamp) \ hmac/$(DEPDIR)/$(am__dirstamp) hmac/libcrypto_la-hmac.lo: hmac/$(am__dirstamp) \ hmac/$(DEPDIR)/$(am__dirstamp) idea/$(am__dirstamp): @$(MKDIR_P) idea @: > idea/$(am__dirstamp) idea/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) idea/$(DEPDIR) @: > idea/$(DEPDIR)/$(am__dirstamp) idea/libcrypto_la-i_cbc.lo: idea/$(am__dirstamp) \ idea/$(DEPDIR)/$(am__dirstamp) idea/libcrypto_la-i_cfb64.lo: idea/$(am__dirstamp) \ idea/$(DEPDIR)/$(am__dirstamp) idea/libcrypto_la-i_ecb.lo: idea/$(am__dirstamp) \ idea/$(DEPDIR)/$(am__dirstamp) idea/libcrypto_la-i_ofb64.lo: idea/$(am__dirstamp) \ idea/$(DEPDIR)/$(am__dirstamp) idea/libcrypto_la-i_skey.lo: idea/$(am__dirstamp) \ idea/$(DEPDIR)/$(am__dirstamp) krb5/$(am__dirstamp): @$(MKDIR_P) krb5 @: > krb5/$(am__dirstamp) krb5/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) krb5/$(DEPDIR) @: > krb5/$(DEPDIR)/$(am__dirstamp) krb5/libcrypto_la-krb5_asn.lo: krb5/$(am__dirstamp) \ krb5/$(DEPDIR)/$(am__dirstamp) lhash/$(am__dirstamp): @$(MKDIR_P) lhash @: > lhash/$(am__dirstamp) lhash/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) lhash/$(DEPDIR) @: > lhash/$(DEPDIR)/$(am__dirstamp) lhash/libcrypto_la-lh_stats.lo: lhash/$(am__dirstamp) \ lhash/$(DEPDIR)/$(am__dirstamp) lhash/libcrypto_la-lhash.lo: lhash/$(am__dirstamp) \ lhash/$(DEPDIR)/$(am__dirstamp) md4/$(am__dirstamp): @$(MKDIR_P) md4 @: > md4/$(am__dirstamp) md4/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) md4/$(DEPDIR) @: > md4/$(DEPDIR)/$(am__dirstamp) md4/libcrypto_la-md4_dgst.lo: md4/$(am__dirstamp) \ md4/$(DEPDIR)/$(am__dirstamp) md4/libcrypto_la-md4_one.lo: md4/$(am__dirstamp) \ md4/$(DEPDIR)/$(am__dirstamp) md5/$(am__dirstamp): @$(MKDIR_P) md5 @: > md5/$(am__dirstamp) md5/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) md5/$(DEPDIR) @: > md5/$(DEPDIR)/$(am__dirstamp) md5/libcrypto_la-md5_dgst.lo: md5/$(am__dirstamp) \ md5/$(DEPDIR)/$(am__dirstamp) md5/libcrypto_la-md5_one.lo: md5/$(am__dirstamp) \ md5/$(DEPDIR)/$(am__dirstamp) mdc2/$(am__dirstamp): @$(MKDIR_P) mdc2 @: > mdc2/$(am__dirstamp) mdc2/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) mdc2/$(DEPDIR) @: > mdc2/$(DEPDIR)/$(am__dirstamp) mdc2/libcrypto_la-mdc2_one.lo: mdc2/$(am__dirstamp) \ mdc2/$(DEPDIR)/$(am__dirstamp) mdc2/libcrypto_la-mdc2dgst.lo: mdc2/$(am__dirstamp) \ mdc2/$(DEPDIR)/$(am__dirstamp) modes/$(am__dirstamp): @$(MKDIR_P) modes @: > modes/$(am__dirstamp) modes/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) modes/$(DEPDIR) @: > modes/$(DEPDIR)/$(am__dirstamp) modes/libcrypto_la-cbc128.lo: modes/$(am__dirstamp) \ modes/$(DEPDIR)/$(am__dirstamp) modes/libcrypto_la-ccm128.lo: modes/$(am__dirstamp) \ modes/$(DEPDIR)/$(am__dirstamp) modes/libcrypto_la-cfb128.lo: modes/$(am__dirstamp) \ modes/$(DEPDIR)/$(am__dirstamp) modes/libcrypto_la-ctr128.lo: modes/$(am__dirstamp) \ modes/$(DEPDIR)/$(am__dirstamp) modes/libcrypto_la-cts128.lo: modes/$(am__dirstamp) \ modes/$(DEPDIR)/$(am__dirstamp) modes/libcrypto_la-gcm128.lo: modes/$(am__dirstamp) \ modes/$(DEPDIR)/$(am__dirstamp) modes/libcrypto_la-ofb128.lo: modes/$(am__dirstamp) \ modes/$(DEPDIR)/$(am__dirstamp) modes/libcrypto_la-xts128.lo: modes/$(am__dirstamp) \ modes/$(DEPDIR)/$(am__dirstamp) objects/$(am__dirstamp): @$(MKDIR_P) objects @: > objects/$(am__dirstamp) objects/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) objects/$(DEPDIR) @: > objects/$(DEPDIR)/$(am__dirstamp) objects/libcrypto_la-o_names.lo: objects/$(am__dirstamp) \ objects/$(DEPDIR)/$(am__dirstamp) objects/libcrypto_la-obj_dat.lo: objects/$(am__dirstamp) \ objects/$(DEPDIR)/$(am__dirstamp) objects/libcrypto_la-obj_err.lo: objects/$(am__dirstamp) \ objects/$(DEPDIR)/$(am__dirstamp) objects/libcrypto_la-obj_lib.lo: objects/$(am__dirstamp) \ objects/$(DEPDIR)/$(am__dirstamp) objects/libcrypto_la-obj_xref.lo: objects/$(am__dirstamp) \ objects/$(DEPDIR)/$(am__dirstamp) ocsp/$(am__dirstamp): @$(MKDIR_P) ocsp @: > ocsp/$(am__dirstamp) ocsp/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) ocsp/$(DEPDIR) @: > ocsp/$(DEPDIR)/$(am__dirstamp) ocsp/libcrypto_la-ocsp_asn.lo: ocsp/$(am__dirstamp) \ ocsp/$(DEPDIR)/$(am__dirstamp) ocsp/libcrypto_la-ocsp_cl.lo: ocsp/$(am__dirstamp) \ ocsp/$(DEPDIR)/$(am__dirstamp) ocsp/libcrypto_la-ocsp_err.lo: ocsp/$(am__dirstamp) \ ocsp/$(DEPDIR)/$(am__dirstamp) ocsp/libcrypto_la-ocsp_ext.lo: ocsp/$(am__dirstamp) \ ocsp/$(DEPDIR)/$(am__dirstamp) ocsp/libcrypto_la-ocsp_ht.lo: ocsp/$(am__dirstamp) \ ocsp/$(DEPDIR)/$(am__dirstamp) ocsp/libcrypto_la-ocsp_lib.lo: ocsp/$(am__dirstamp) \ ocsp/$(DEPDIR)/$(am__dirstamp) ocsp/libcrypto_la-ocsp_prn.lo: ocsp/$(am__dirstamp) \ ocsp/$(DEPDIR)/$(am__dirstamp) ocsp/libcrypto_la-ocsp_srv.lo: ocsp/$(am__dirstamp) \ ocsp/$(DEPDIR)/$(am__dirstamp) ocsp/libcrypto_la-ocsp_vfy.lo: ocsp/$(am__dirstamp) \ ocsp/$(DEPDIR)/$(am__dirstamp) pem/$(am__dirstamp): @$(MKDIR_P) pem @: > pem/$(am__dirstamp) pem/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) pem/$(DEPDIR) @: > pem/$(DEPDIR)/$(am__dirstamp) pem/libcrypto_la-pem_all.lo: pem/$(am__dirstamp) \ pem/$(DEPDIR)/$(am__dirstamp) pem/libcrypto_la-pem_err.lo: pem/$(am__dirstamp) \ pem/$(DEPDIR)/$(am__dirstamp) pem/libcrypto_la-pem_info.lo: pem/$(am__dirstamp) \ pem/$(DEPDIR)/$(am__dirstamp) pem/libcrypto_la-pem_lib.lo: pem/$(am__dirstamp) \ pem/$(DEPDIR)/$(am__dirstamp) pem/libcrypto_la-pem_oth.lo: pem/$(am__dirstamp) \ pem/$(DEPDIR)/$(am__dirstamp) pem/libcrypto_la-pem_pk8.lo: pem/$(am__dirstamp) \ pem/$(DEPDIR)/$(am__dirstamp) pem/libcrypto_la-pem_pkey.lo: pem/$(am__dirstamp) \ pem/$(DEPDIR)/$(am__dirstamp) pem/libcrypto_la-pem_seal.lo: pem/$(am__dirstamp) \ pem/$(DEPDIR)/$(am__dirstamp) pem/libcrypto_la-pem_sign.lo: pem/$(am__dirstamp) \ pem/$(DEPDIR)/$(am__dirstamp) pem/libcrypto_la-pem_x509.lo: pem/$(am__dirstamp) \ pem/$(DEPDIR)/$(am__dirstamp) pem/libcrypto_la-pem_xaux.lo: pem/$(am__dirstamp) \ pem/$(DEPDIR)/$(am__dirstamp) pem/libcrypto_la-pvkfmt.lo: pem/$(am__dirstamp) \ pem/$(DEPDIR)/$(am__dirstamp) pkcs12/$(am__dirstamp): @$(MKDIR_P) pkcs12 @: > pkcs12/$(am__dirstamp) pkcs12/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) pkcs12/$(DEPDIR) @: > pkcs12/$(DEPDIR)/$(am__dirstamp) pkcs12/libcrypto_la-p12_add.lo: pkcs12/$(am__dirstamp) \ pkcs12/$(DEPDIR)/$(am__dirstamp) pkcs12/libcrypto_la-p12_asn.lo: pkcs12/$(am__dirstamp) \ pkcs12/$(DEPDIR)/$(am__dirstamp) pkcs12/libcrypto_la-p12_attr.lo: pkcs12/$(am__dirstamp) \ pkcs12/$(DEPDIR)/$(am__dirstamp) pkcs12/libcrypto_la-p12_crpt.lo: pkcs12/$(am__dirstamp) \ pkcs12/$(DEPDIR)/$(am__dirstamp) pkcs12/libcrypto_la-p12_crt.lo: pkcs12/$(am__dirstamp) \ pkcs12/$(DEPDIR)/$(am__dirstamp) pkcs12/libcrypto_la-p12_decr.lo: pkcs12/$(am__dirstamp) \ pkcs12/$(DEPDIR)/$(am__dirstamp) pkcs12/libcrypto_la-p12_init.lo: pkcs12/$(am__dirstamp) \ pkcs12/$(DEPDIR)/$(am__dirstamp) pkcs12/libcrypto_la-p12_key.lo: pkcs12/$(am__dirstamp) \ pkcs12/$(DEPDIR)/$(am__dirstamp) pkcs12/libcrypto_la-p12_kiss.lo: pkcs12/$(am__dirstamp) \ pkcs12/$(DEPDIR)/$(am__dirstamp) pkcs12/libcrypto_la-p12_mutl.lo: pkcs12/$(am__dirstamp) \ pkcs12/$(DEPDIR)/$(am__dirstamp) pkcs12/libcrypto_la-p12_npas.lo: pkcs12/$(am__dirstamp) \ pkcs12/$(DEPDIR)/$(am__dirstamp) pkcs12/libcrypto_la-p12_p8d.lo: pkcs12/$(am__dirstamp) \ pkcs12/$(DEPDIR)/$(am__dirstamp) pkcs12/libcrypto_la-p12_p8e.lo: pkcs12/$(am__dirstamp) \ pkcs12/$(DEPDIR)/$(am__dirstamp) pkcs12/libcrypto_la-p12_utl.lo: pkcs12/$(am__dirstamp) \ pkcs12/$(DEPDIR)/$(am__dirstamp) pkcs12/libcrypto_la-pk12err.lo: pkcs12/$(am__dirstamp) \ pkcs12/$(DEPDIR)/$(am__dirstamp) pkcs7/$(am__dirstamp): @$(MKDIR_P) pkcs7 @: > pkcs7/$(am__dirstamp) pkcs7/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) pkcs7/$(DEPDIR) @: > pkcs7/$(DEPDIR)/$(am__dirstamp) pkcs7/libcrypto_la-bio_pk7.lo: pkcs7/$(am__dirstamp) \ pkcs7/$(DEPDIR)/$(am__dirstamp) pkcs7/libcrypto_la-pk7_asn1.lo: pkcs7/$(am__dirstamp) \ pkcs7/$(DEPDIR)/$(am__dirstamp) pkcs7/libcrypto_la-pk7_attr.lo: pkcs7/$(am__dirstamp) \ pkcs7/$(DEPDIR)/$(am__dirstamp) pkcs7/libcrypto_la-pk7_doit.lo: pkcs7/$(am__dirstamp) \ pkcs7/$(DEPDIR)/$(am__dirstamp) pkcs7/libcrypto_la-pk7_lib.lo: pkcs7/$(am__dirstamp) \ pkcs7/$(DEPDIR)/$(am__dirstamp) pkcs7/libcrypto_la-pk7_mime.lo: pkcs7/$(am__dirstamp) \ pkcs7/$(DEPDIR)/$(am__dirstamp) pkcs7/libcrypto_la-pk7_smime.lo: pkcs7/$(am__dirstamp) \ pkcs7/$(DEPDIR)/$(am__dirstamp) pkcs7/libcrypto_la-pkcs7err.lo: pkcs7/$(am__dirstamp) \ pkcs7/$(DEPDIR)/$(am__dirstamp) poly1305/$(am__dirstamp): @$(MKDIR_P) poly1305 @: > poly1305/$(am__dirstamp) poly1305/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) poly1305/$(DEPDIR) @: > poly1305/$(DEPDIR)/$(am__dirstamp) poly1305/libcrypto_la-poly1305.lo: poly1305/$(am__dirstamp) \ poly1305/$(DEPDIR)/$(am__dirstamp) rand/$(am__dirstamp): @$(MKDIR_P) rand @: > rand/$(am__dirstamp) rand/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) rand/$(DEPDIR) @: > rand/$(DEPDIR)/$(am__dirstamp) rand/libcrypto_la-rand_err.lo: rand/$(am__dirstamp) \ rand/$(DEPDIR)/$(am__dirstamp) rand/libcrypto_la-rand_lib.lo: rand/$(am__dirstamp) \ rand/$(DEPDIR)/$(am__dirstamp) rand/libcrypto_la-randfile.lo: rand/$(am__dirstamp) \ rand/$(DEPDIR)/$(am__dirstamp) rc2/$(am__dirstamp): @$(MKDIR_P) rc2 @: > rc2/$(am__dirstamp) rc2/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) rc2/$(DEPDIR) @: > rc2/$(DEPDIR)/$(am__dirstamp) rc2/libcrypto_la-rc2_cbc.lo: rc2/$(am__dirstamp) \ rc2/$(DEPDIR)/$(am__dirstamp) rc2/libcrypto_la-rc2_ecb.lo: rc2/$(am__dirstamp) \ rc2/$(DEPDIR)/$(am__dirstamp) rc2/libcrypto_la-rc2_skey.lo: rc2/$(am__dirstamp) \ rc2/$(DEPDIR)/$(am__dirstamp) rc2/libcrypto_la-rc2cfb64.lo: rc2/$(am__dirstamp) \ rc2/$(DEPDIR)/$(am__dirstamp) rc2/libcrypto_la-rc2ofb64.lo: rc2/$(am__dirstamp) \ rc2/$(DEPDIR)/$(am__dirstamp) rc4/$(am__dirstamp): @$(MKDIR_P) rc4 @: > rc4/$(am__dirstamp) rc4/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) rc4/$(DEPDIR) @: > rc4/$(DEPDIR)/$(am__dirstamp) rc4/libcrypto_la-rc4_enc.lo: rc4/$(am__dirstamp) \ rc4/$(DEPDIR)/$(am__dirstamp) rc4/libcrypto_la-rc4_skey.lo: rc4/$(am__dirstamp) \ rc4/$(DEPDIR)/$(am__dirstamp) rc4/libcrypto_la-rc4_utl.lo: rc4/$(am__dirstamp) \ rc4/$(DEPDIR)/$(am__dirstamp) ripemd/$(am__dirstamp): @$(MKDIR_P) ripemd @: > ripemd/$(am__dirstamp) ripemd/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) ripemd/$(DEPDIR) @: > ripemd/$(DEPDIR)/$(am__dirstamp) ripemd/libcrypto_la-rmd_dgst.lo: ripemd/$(am__dirstamp) \ ripemd/$(DEPDIR)/$(am__dirstamp) ripemd/libcrypto_la-rmd_one.lo: ripemd/$(am__dirstamp) \ ripemd/$(DEPDIR)/$(am__dirstamp) rsa/$(am__dirstamp): @$(MKDIR_P) rsa @: > rsa/$(am__dirstamp) rsa/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) rsa/$(DEPDIR) @: > rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_ameth.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_asn1.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_chk.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_crpt.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_depr.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_eay.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_err.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_gen.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_lib.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_none.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_oaep.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_pk1.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_pmeth.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_prn.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_pss.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_saos.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_sign.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_ssl.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) rsa/libcrypto_la-rsa_x931.lo: rsa/$(am__dirstamp) \ rsa/$(DEPDIR)/$(am__dirstamp) sha/$(am__dirstamp): @$(MKDIR_P) sha @: > sha/$(am__dirstamp) sha/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) sha/$(DEPDIR) @: > sha/$(DEPDIR)/$(am__dirstamp) sha/libcrypto_la-sha1_one.lo: sha/$(am__dirstamp) \ sha/$(DEPDIR)/$(am__dirstamp) sha/libcrypto_la-sha1dgst.lo: sha/$(am__dirstamp) \ sha/$(DEPDIR)/$(am__dirstamp) sha/libcrypto_la-sha256.lo: sha/$(am__dirstamp) \ sha/$(DEPDIR)/$(am__dirstamp) sha/libcrypto_la-sha512.lo: sha/$(am__dirstamp) \ sha/$(DEPDIR)/$(am__dirstamp) sha/libcrypto_la-sha_dgst.lo: sha/$(am__dirstamp) \ sha/$(DEPDIR)/$(am__dirstamp) sha/libcrypto_la-sha_one.lo: sha/$(am__dirstamp) \ sha/$(DEPDIR)/$(am__dirstamp) stack/$(am__dirstamp): @$(MKDIR_P) stack @: > stack/$(am__dirstamp) stack/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) stack/$(DEPDIR) @: > stack/$(DEPDIR)/$(am__dirstamp) stack/libcrypto_la-stack.lo: stack/$(am__dirstamp) \ stack/$(DEPDIR)/$(am__dirstamp) ts/$(am__dirstamp): @$(MKDIR_P) ts @: > ts/$(am__dirstamp) ts/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) ts/$(DEPDIR) @: > ts/$(DEPDIR)/$(am__dirstamp) ts/libcrypto_la-ts_asn1.lo: ts/$(am__dirstamp) \ ts/$(DEPDIR)/$(am__dirstamp) ts/libcrypto_la-ts_conf.lo: ts/$(am__dirstamp) \ ts/$(DEPDIR)/$(am__dirstamp) ts/libcrypto_la-ts_err.lo: ts/$(am__dirstamp) \ ts/$(DEPDIR)/$(am__dirstamp) ts/libcrypto_la-ts_lib.lo: ts/$(am__dirstamp) \ ts/$(DEPDIR)/$(am__dirstamp) ts/libcrypto_la-ts_req_print.lo: ts/$(am__dirstamp) \ ts/$(DEPDIR)/$(am__dirstamp) ts/libcrypto_la-ts_req_utils.lo: ts/$(am__dirstamp) \ ts/$(DEPDIR)/$(am__dirstamp) ts/libcrypto_la-ts_rsp_print.lo: ts/$(am__dirstamp) \ ts/$(DEPDIR)/$(am__dirstamp) ts/libcrypto_la-ts_rsp_sign.lo: ts/$(am__dirstamp) \ ts/$(DEPDIR)/$(am__dirstamp) ts/libcrypto_la-ts_rsp_utils.lo: ts/$(am__dirstamp) \ ts/$(DEPDIR)/$(am__dirstamp) ts/libcrypto_la-ts_rsp_verify.lo: ts/$(am__dirstamp) \ ts/$(DEPDIR)/$(am__dirstamp) ts/libcrypto_la-ts_verify_ctx.lo: ts/$(am__dirstamp) \ ts/$(DEPDIR)/$(am__dirstamp) txt_db/$(am__dirstamp): @$(MKDIR_P) txt_db @: > txt_db/$(am__dirstamp) txt_db/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) txt_db/$(DEPDIR) @: > txt_db/$(DEPDIR)/$(am__dirstamp) txt_db/libcrypto_la-txt_db.lo: txt_db/$(am__dirstamp) \ txt_db/$(DEPDIR)/$(am__dirstamp) ui/$(am__dirstamp): @$(MKDIR_P) ui @: > ui/$(am__dirstamp) ui/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) ui/$(DEPDIR) @: > ui/$(DEPDIR)/$(am__dirstamp) ui/libcrypto_la-ui_err.lo: ui/$(am__dirstamp) \ ui/$(DEPDIR)/$(am__dirstamp) ui/libcrypto_la-ui_lib.lo: ui/$(am__dirstamp) \ ui/$(DEPDIR)/$(am__dirstamp) ui/libcrypto_la-ui_openssl.lo: ui/$(am__dirstamp) \ ui/$(DEPDIR)/$(am__dirstamp) ui/libcrypto_la-ui_util.lo: ui/$(am__dirstamp) \ ui/$(DEPDIR)/$(am__dirstamp) whrlpool/$(am__dirstamp): @$(MKDIR_P) whrlpool @: > whrlpool/$(am__dirstamp) whrlpool/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) whrlpool/$(DEPDIR) @: > whrlpool/$(DEPDIR)/$(am__dirstamp) whrlpool/libcrypto_la-wp_block.lo: whrlpool/$(am__dirstamp) \ whrlpool/$(DEPDIR)/$(am__dirstamp) whrlpool/libcrypto_la-wp_dgst.lo: whrlpool/$(am__dirstamp) \ whrlpool/$(DEPDIR)/$(am__dirstamp) x509/$(am__dirstamp): @$(MKDIR_P) x509 @: > x509/$(am__dirstamp) x509/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) x509/$(DEPDIR) @: > x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-by_dir.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-by_file.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509_att.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509_cmp.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509_d2.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509_def.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509_err.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509_ext.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509_lu.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509_obj.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509_r2x.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509_req.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509_set.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509_trs.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509_txt.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509_v3.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509_vfy.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509_vpm.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509cset.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509name.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509rset.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509spki.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x509type.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509/libcrypto_la-x_all.lo: x509/$(am__dirstamp) \ x509/$(DEPDIR)/$(am__dirstamp) x509v3/$(am__dirstamp): @$(MKDIR_P) x509v3 @: > x509v3/$(am__dirstamp) x509v3/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) x509v3/$(DEPDIR) @: > x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-pcy_cache.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-pcy_data.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-pcy_lib.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-pcy_map.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-pcy_node.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-pcy_tree.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_akey.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_akeya.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_alt.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_bcons.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_bitst.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_conf.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_cpols.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_crld.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_enum.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_extku.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_genn.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_ia5.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_info.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_int.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_lib.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_ncons.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_ocsp.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_pci.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_pcia.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_pcons.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_pku.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_pmaps.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_prn.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_purp.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_skey.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_sxnet.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3_utl.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) x509v3/libcrypto_la-v3err.lo: x509v3/$(am__dirstamp) \ x509v3/$(DEPDIR)/$(am__dirstamp) des/libcrypto_la-ncbc_enc.lo: des/$(am__dirstamp) \ des/$(DEPDIR)/$(am__dirstamp) chacha/libcrypto_la-chacha-merged.lo: chacha/$(am__dirstamp) \ chacha/$(DEPDIR)/$(am__dirstamp) poly1305/libcrypto_la-poly1305-donna.lo: poly1305/$(am__dirstamp) \ poly1305/$(DEPDIR)/$(am__dirstamp) libcrypto.la: $(libcrypto_la_OBJECTS) $(libcrypto_la_DEPENDENCIES) $(EXTRA_libcrypto_la_DEPENDENCIES) $(AM_V_CCLD)$(libcrypto_la_LINK) -rpath $(libdir) $(libcrypto_la_OBJECTS) $(libcrypto_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f aes/*.$(OBJEXT) -rm -f aes/*.lo -rm -f asn1/*.$(OBJEXT) -rm -f asn1/*.lo -rm -f bf/*.$(OBJEXT) -rm -f bf/*.lo -rm -f bio/*.$(OBJEXT) -rm -f bio/*.lo -rm -f bn/*.$(OBJEXT) -rm -f bn/*.lo -rm -f buffer/*.$(OBJEXT) -rm -f buffer/*.lo -rm -f cast/*.$(OBJEXT) -rm -f cast/*.lo -rm -f chacha/*.$(OBJEXT) -rm -f chacha/*.lo -rm -f cmac/*.$(OBJEXT) -rm -f cmac/*.lo -rm -f comp/*.$(OBJEXT) -rm -f comp/*.lo -rm -f compat/*.$(OBJEXT) -rm -f compat/*.lo -rm -f conf/*.$(OBJEXT) -rm -f conf/*.lo -rm -f des/*.$(OBJEXT) -rm -f des/*.lo -rm -f dh/*.$(OBJEXT) -rm -f dh/*.lo -rm -f dsa/*.$(OBJEXT) -rm -f dsa/*.lo -rm -f dso/*.$(OBJEXT) -rm -f dso/*.lo -rm -f ec/*.$(OBJEXT) -rm -f ec/*.lo -rm -f ecdh/*.$(OBJEXT) -rm -f ecdh/*.lo -rm -f ecdsa/*.$(OBJEXT) -rm -f ecdsa/*.lo -rm -f engine/*.$(OBJEXT) -rm -f engine/*.lo -rm -f err/*.$(OBJEXT) -rm -f err/*.lo -rm -f evp/*.$(OBJEXT) -rm -f evp/*.lo -rm -f hmac/*.$(OBJEXT) -rm -f hmac/*.lo -rm -f idea/*.$(OBJEXT) -rm -f idea/*.lo -rm -f krb5/*.$(OBJEXT) -rm -f krb5/*.lo -rm -f lhash/*.$(OBJEXT) -rm -f lhash/*.lo -rm -f md4/*.$(OBJEXT) -rm -f md4/*.lo -rm -f md5/*.$(OBJEXT) -rm -f md5/*.lo -rm -f mdc2/*.$(OBJEXT) -rm -f mdc2/*.lo -rm -f modes/*.$(OBJEXT) -rm -f modes/*.lo -rm -f objects/*.$(OBJEXT) -rm -f objects/*.lo -rm -f ocsp/*.$(OBJEXT) -rm -f ocsp/*.lo -rm -f pem/*.$(OBJEXT) -rm -f pem/*.lo -rm -f pkcs12/*.$(OBJEXT) -rm -f pkcs12/*.lo -rm -f pkcs7/*.$(OBJEXT) -rm -f pkcs7/*.lo -rm -f poly1305/*.$(OBJEXT) -rm -f poly1305/*.lo -rm -f rand/*.$(OBJEXT) -rm -f rand/*.lo -rm -f rc2/*.$(OBJEXT) -rm -f rc2/*.lo -rm -f rc4/*.$(OBJEXT) -rm -f rc4/*.lo -rm -f ripemd/*.$(OBJEXT) -rm -f ripemd/*.lo -rm -f rsa/*.$(OBJEXT) -rm -f rsa/*.lo -rm -f sha/*.$(OBJEXT) -rm -f sha/*.lo -rm -f stack/*.$(OBJEXT) -rm -f stack/*.lo -rm -f ts/*.$(OBJEXT) -rm -f ts/*.lo -rm -f txt_db/*.$(OBJEXT) -rm -f txt_db/*.lo -rm -f ui/*.$(OBJEXT) -rm -f ui/*.lo -rm -f whrlpool/*.$(OBJEXT) -rm -f whrlpool/*.lo -rm -f x509/*.$(OBJEXT) -rm -f x509/*.lo -rm -f x509v3/*.$(OBJEXT) -rm -f x509v3/*.lo distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcrypto_la-cpt_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcrypto_la-cryptlib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcrypto_la-cversion.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcrypto_la-ex_data.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcrypto_la-malloc-wrapper.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcrypto_la-mem_clr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcrypto_la-mem_dbg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcrypto_la-o_init.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcrypto_la-o_str.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcrypto_la-o_time.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes_cbc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes_cfb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes_core.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes_ctr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes_ecb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes_ige.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes_misc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes_ofb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes_wrap.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_bitstr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_bool.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_bytes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_d2i_fp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_digest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_dup.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_enum.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_gentm.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_i2d_fp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_int.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_mbstr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_object.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_octet.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_print.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_set.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_sign.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_strex.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_strnid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_time.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_type.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_utctm.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_utf8.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_verify.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-ameth_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-asn1_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-asn1_gen.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-asn1_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-asn1_par.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-asn_mime.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-asn_moid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-asn_pack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-bio_asn1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-bio_ndef.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-d2i_pr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-d2i_pu.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-evp_asn1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-f_enum.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-f_int.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-f_string.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-i2d_pr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-i2d_pu.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-n_pkey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-nsseq.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-p5_pbe.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-p5_pbev2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-p8_pkey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-t_bitst.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-t_crl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-t_pkey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-t_req.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-t_spki.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-t_x509.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-t_x509a.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-tasn_dec.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-tasn_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-tasn_fre.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-tasn_new.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-tasn_prn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-tasn_typ.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-tasn_utl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_algor.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_attrib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_bignum.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_crl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_exten.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_info.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_long.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_name.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_nx509.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_pkey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_pubkey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_req.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_sig.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_spki.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_val.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_x509.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-x_x509a.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bf/$(DEPDIR)/libcrypto_la-bf_cfb64.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bf/$(DEPDIR)/libcrypto_la-bf_ecb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bf/$(DEPDIR)/libcrypto_la-bf_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bf/$(DEPDIR)/libcrypto_la-bf_ofb64.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bf/$(DEPDIR)/libcrypto_la-bf_skey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-b_dump.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-b_print.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-b_sock.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bf_buff.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bf_nbio.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bf_null.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bio_cb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bio_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bio_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bss_acpt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bss_bio.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bss_conn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bss_dgram.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bss_fd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bss_file.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bss_log.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bss_mem.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bss_null.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bss_sock.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_add.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_asm.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_blind.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_const.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_ctx.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_depr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_div.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_exp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_exp2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_gcd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_gf2m.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_kron.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_mod.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_mont.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_mpi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_mul.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_nist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_prime.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_print.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_rand.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_recp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_shift.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_sqr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_sqrt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_word.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_x931p.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@buffer/$(DEPDIR)/libcrypto_la-buf_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@buffer/$(DEPDIR)/libcrypto_la-buf_str.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@buffer/$(DEPDIR)/libcrypto_la-buffer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cast/$(DEPDIR)/libcrypto_la-c_cfb64.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cast/$(DEPDIR)/libcrypto_la-c_ecb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cast/$(DEPDIR)/libcrypto_la-c_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cast/$(DEPDIR)/libcrypto_la-c_ofb64.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cast/$(DEPDIR)/libcrypto_la-c_skey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@chacha/$(DEPDIR)/libcrypto_la-chacha-merged.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@chacha/$(DEPDIR)/libcrypto_la-chacha.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cmac/$(DEPDIR)/libcrypto_la-cm_ameth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cmac/$(DEPDIR)/libcrypto_la-cm_pmeth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@cmac/$(DEPDIR)/libcrypto_la-cmac.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@comp/$(DEPDIR)/libcrypto_la-c_rle.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@comp/$(DEPDIR)/libcrypto_la-c_zlib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@comp/$(DEPDIR)/libcrypto_la-comp_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@comp/$(DEPDIR)/libcrypto_la-comp_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-arc4random.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-getentropy_linux.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-getentropy_nacl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-getentropy_osx.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-getentropy_solaris.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-issetugid_linux.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-reallocarray.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-strlcat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-strlcpy.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-timingsafe_bcmp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-timingsafe_memcmp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompatnoopt_la-explicit_bzero.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@conf/$(DEPDIR)/libcrypto_la-conf_api.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@conf/$(DEPDIR)/libcrypto_la-conf_def.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@conf/$(DEPDIR)/libcrypto_la-conf_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@conf/$(DEPDIR)/libcrypto_la-conf_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@conf/$(DEPDIR)/libcrypto_la-conf_mall.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@conf/$(DEPDIR)/libcrypto_la-conf_mod.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@conf/$(DEPDIR)/libcrypto_la-conf_sap.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-cbc_cksm.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-cbc_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-cfb64ede.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-cfb64enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-cfb_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-des_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-ecb3_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-ecb_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-ede_cbcm_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-enc_read.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-enc_writ.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-fcrypt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-fcrypt_b.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-ncbc_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-ofb64ede.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-ofb64enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-ofb_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-pcbc_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-qud_cksm.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-rand_key.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-set_key.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-str2key.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@des/$(DEPDIR)/libcrypto_la-xcbc_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dh/$(DEPDIR)/libcrypto_la-dh_ameth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dh/$(DEPDIR)/libcrypto_la-dh_asn1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dh/$(DEPDIR)/libcrypto_la-dh_check.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dh/$(DEPDIR)/libcrypto_la-dh_depr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dh/$(DEPDIR)/libcrypto_la-dh_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dh/$(DEPDIR)/libcrypto_la-dh_gen.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dh/$(DEPDIR)/libcrypto_la-dh_key.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dh/$(DEPDIR)/libcrypto_la-dh_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dh/$(DEPDIR)/libcrypto_la-dh_pmeth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dh/$(DEPDIR)/libcrypto_la-dh_prn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_ameth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_asn1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_depr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_gen.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_key.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_ossl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_pmeth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_prn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_sign.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_vrf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dso/$(DEPDIR)/libcrypto_la-dso_dlfcn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dso/$(DEPDIR)/libcrypto_la-dso_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dso/$(DEPDIR)/libcrypto_la-dso_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dso/$(DEPDIR)/libcrypto_la-dso_null.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@dso/$(DEPDIR)/libcrypto_la-dso_openssl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ec2_mult.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ec2_oct.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ec2_smpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ec_ameth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ec_asn1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ec_check.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ec_curve.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ec_cvt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ec_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ec_key.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ec_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ec_mult.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ec_oct.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ec_pmeth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ec_print.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-eck_prn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ecp_mont.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ecp_nist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ecp_oct.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ecp_smpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ecdh/$(DEPDIR)/libcrypto_la-ech_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ecdh/$(DEPDIR)/libcrypto_la-ech_key.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ecdh/$(DEPDIR)/libcrypto_la-ech_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ecdh/$(DEPDIR)/libcrypto_la-ech_ossl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ecdsa/$(DEPDIR)/libcrypto_la-ecs_asn1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ecdsa/$(DEPDIR)/libcrypto_la-ecs_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ecdsa/$(DEPDIR)/libcrypto_la-ecs_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ecdsa/$(DEPDIR)/libcrypto_la-ecs_ossl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ecdsa/$(DEPDIR)/libcrypto_la-ecs_sign.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ecdsa/$(DEPDIR)/libcrypto_la-ecs_vrf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-eng_all.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-eng_cnf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-eng_ctrl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-eng_dyn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-eng_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-eng_fat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-eng_init.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-eng_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-eng_list.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-eng_openssl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-eng_pkey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-eng_rsax.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-eng_table.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-tb_asnmth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-tb_cipher.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-tb_dh.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-tb_digest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-tb_dsa.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-tb_ecdh.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-tb_ecdsa.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-tb_pkmeth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-tb_rand.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-tb_rsa.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@engine/$(DEPDIR)/libcrypto_la-tb_store.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@err/$(DEPDIR)/libcrypto_la-err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@err/$(DEPDIR)/libcrypto_la-err_all.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@err/$(DEPDIR)/libcrypto_la-err_prn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-bio_b64.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-bio_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-bio_md.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-c_all.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-c_allc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-c_alld.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-digest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_aes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_aes_cbc_hmac_sha1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_bf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_cast.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_chacha.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_chacha20poly1305.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_des.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_des3.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_idea.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_null.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_old.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_rc2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_rc4.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_rc4_hmac_md5.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_xcbc_d.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-encode.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-evp_aead.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-evp_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-evp_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-evp_key.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-evp_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-evp_pbe.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-evp_pkey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-m_dss.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-m_dss1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-m_ecdsa.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-m_md4.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-m_md5.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-m_mdc2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-m_null.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-m_ripemd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-m_sha.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-m_sha1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-m_sigver.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-m_wp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-names.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-p5_crpt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-p5_crpt2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-p_dec.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-p_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-p_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-p_open.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-p_seal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-p_sign.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-p_verify.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-pmeth_fn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-pmeth_gn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-pmeth_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@hmac/$(DEPDIR)/libcrypto_la-hm_ameth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@hmac/$(DEPDIR)/libcrypto_la-hm_pmeth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@hmac/$(DEPDIR)/libcrypto_la-hmac.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@idea/$(DEPDIR)/libcrypto_la-i_cbc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@idea/$(DEPDIR)/libcrypto_la-i_cfb64.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@idea/$(DEPDIR)/libcrypto_la-i_ecb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@idea/$(DEPDIR)/libcrypto_la-i_ofb64.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@idea/$(DEPDIR)/libcrypto_la-i_skey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@krb5/$(DEPDIR)/libcrypto_la-krb5_asn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@lhash/$(DEPDIR)/libcrypto_la-lh_stats.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@lhash/$(DEPDIR)/libcrypto_la-lhash.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@md4/$(DEPDIR)/libcrypto_la-md4_dgst.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@md4/$(DEPDIR)/libcrypto_la-md4_one.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@md5/$(DEPDIR)/libcrypto_la-md5_dgst.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@md5/$(DEPDIR)/libcrypto_la-md5_one.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@mdc2/$(DEPDIR)/libcrypto_la-mdc2_one.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@mdc2/$(DEPDIR)/libcrypto_la-mdc2dgst.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@modes/$(DEPDIR)/libcrypto_la-cbc128.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@modes/$(DEPDIR)/libcrypto_la-ccm128.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@modes/$(DEPDIR)/libcrypto_la-cfb128.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@modes/$(DEPDIR)/libcrypto_la-ctr128.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@modes/$(DEPDIR)/libcrypto_la-cts128.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@modes/$(DEPDIR)/libcrypto_la-gcm128.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@modes/$(DEPDIR)/libcrypto_la-ofb128.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@modes/$(DEPDIR)/libcrypto_la-xts128.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@objects/$(DEPDIR)/libcrypto_la-o_names.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@objects/$(DEPDIR)/libcrypto_la-obj_dat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@objects/$(DEPDIR)/libcrypto_la-obj_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@objects/$(DEPDIR)/libcrypto_la-obj_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@objects/$(DEPDIR)/libcrypto_la-obj_xref.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ocsp/$(DEPDIR)/libcrypto_la-ocsp_asn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ocsp/$(DEPDIR)/libcrypto_la-ocsp_cl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ocsp/$(DEPDIR)/libcrypto_la-ocsp_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ocsp/$(DEPDIR)/libcrypto_la-ocsp_ext.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ocsp/$(DEPDIR)/libcrypto_la-ocsp_ht.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ocsp/$(DEPDIR)/libcrypto_la-ocsp_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ocsp/$(DEPDIR)/libcrypto_la-ocsp_prn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ocsp/$(DEPDIR)/libcrypto_la-ocsp_srv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ocsp/$(DEPDIR)/libcrypto_la-ocsp_vfy.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pem/$(DEPDIR)/libcrypto_la-pem_all.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pem/$(DEPDIR)/libcrypto_la-pem_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pem/$(DEPDIR)/libcrypto_la-pem_info.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pem/$(DEPDIR)/libcrypto_la-pem_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pem/$(DEPDIR)/libcrypto_la-pem_oth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pem/$(DEPDIR)/libcrypto_la-pem_pk8.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pem/$(DEPDIR)/libcrypto_la-pem_pkey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pem/$(DEPDIR)/libcrypto_la-pem_seal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pem/$(DEPDIR)/libcrypto_la-pem_sign.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pem/$(DEPDIR)/libcrypto_la-pem_x509.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pem/$(DEPDIR)/libcrypto_la-pem_xaux.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pem/$(DEPDIR)/libcrypto_la-pvkfmt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs12/$(DEPDIR)/libcrypto_la-p12_add.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs12/$(DEPDIR)/libcrypto_la-p12_asn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs12/$(DEPDIR)/libcrypto_la-p12_attr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs12/$(DEPDIR)/libcrypto_la-p12_crpt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs12/$(DEPDIR)/libcrypto_la-p12_crt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs12/$(DEPDIR)/libcrypto_la-p12_decr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs12/$(DEPDIR)/libcrypto_la-p12_init.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs12/$(DEPDIR)/libcrypto_la-p12_key.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs12/$(DEPDIR)/libcrypto_la-p12_kiss.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs12/$(DEPDIR)/libcrypto_la-p12_mutl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs12/$(DEPDIR)/libcrypto_la-p12_npas.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs12/$(DEPDIR)/libcrypto_la-p12_p8d.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs12/$(DEPDIR)/libcrypto_la-p12_p8e.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs12/$(DEPDIR)/libcrypto_la-p12_utl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs12/$(DEPDIR)/libcrypto_la-pk12err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs7/$(DEPDIR)/libcrypto_la-bio_pk7.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs7/$(DEPDIR)/libcrypto_la-pk7_asn1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs7/$(DEPDIR)/libcrypto_la-pk7_attr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs7/$(DEPDIR)/libcrypto_la-pk7_doit.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs7/$(DEPDIR)/libcrypto_la-pk7_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs7/$(DEPDIR)/libcrypto_la-pk7_mime.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs7/$(DEPDIR)/libcrypto_la-pk7_smime.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pkcs7/$(DEPDIR)/libcrypto_la-pkcs7err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@poly1305/$(DEPDIR)/libcrypto_la-poly1305-donna.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@poly1305/$(DEPDIR)/libcrypto_la-poly1305.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rand/$(DEPDIR)/libcrypto_la-rand_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rand/$(DEPDIR)/libcrypto_la-rand_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rand/$(DEPDIR)/libcrypto_la-randfile.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rc2/$(DEPDIR)/libcrypto_la-rc2_cbc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rc2/$(DEPDIR)/libcrypto_la-rc2_ecb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rc2/$(DEPDIR)/libcrypto_la-rc2_skey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rc2/$(DEPDIR)/libcrypto_la-rc2cfb64.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rc2/$(DEPDIR)/libcrypto_la-rc2ofb64.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rc4/$(DEPDIR)/libcrypto_la-rc4_enc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rc4/$(DEPDIR)/libcrypto_la-rc4_skey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rc4/$(DEPDIR)/libcrypto_la-rc4_utl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ripemd/$(DEPDIR)/libcrypto_la-rmd_dgst.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ripemd/$(DEPDIR)/libcrypto_la-rmd_one.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_ameth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_asn1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_chk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_crpt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_depr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_eay.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_gen.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_none.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_oaep.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_pk1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_pmeth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_prn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_pss.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_saos.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_sign.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_ssl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@rsa/$(DEPDIR)/libcrypto_la-rsa_x931.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha1_one.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha1dgst.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha256.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha512.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha_dgst.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha_one.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@stack/$(DEPDIR)/libcrypto_la-stack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ts/$(DEPDIR)/libcrypto_la-ts_asn1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ts/$(DEPDIR)/libcrypto_la-ts_conf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ts/$(DEPDIR)/libcrypto_la-ts_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ts/$(DEPDIR)/libcrypto_la-ts_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ts/$(DEPDIR)/libcrypto_la-ts_req_print.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ts/$(DEPDIR)/libcrypto_la-ts_req_utils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ts/$(DEPDIR)/libcrypto_la-ts_rsp_print.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ts/$(DEPDIR)/libcrypto_la-ts_rsp_sign.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ts/$(DEPDIR)/libcrypto_la-ts_rsp_utils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ts/$(DEPDIR)/libcrypto_la-ts_rsp_verify.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ts/$(DEPDIR)/libcrypto_la-ts_verify_ctx.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@txt_db/$(DEPDIR)/libcrypto_la-txt_db.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/libcrypto_la-ui_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/libcrypto_la-ui_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/libcrypto_la-ui_openssl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/libcrypto_la-ui_util.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@whrlpool/$(DEPDIR)/libcrypto_la-wp_block.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@whrlpool/$(DEPDIR)/libcrypto_la-wp_dgst.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-by_dir.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-by_file.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509_att.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509_cmp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509_d2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509_def.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509_err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509_ext.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509_lu.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509_obj.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509_r2x.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509_req.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509_set.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509_trs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509_txt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509_v3.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509_vfy.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509_vpm.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509cset.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509name.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509rset.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509spki.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x509type.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509/$(DEPDIR)/libcrypto_la-x_all.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-pcy_cache.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-pcy_data.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-pcy_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-pcy_map.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-pcy_node.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-pcy_tree.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_akey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_akeya.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_alt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_bcons.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_bitst.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_conf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_cpols.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_crld.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_enum.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_extku.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_genn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_ia5.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_info.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_int.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_ncons.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_ocsp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_pci.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_pcia.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_pcons.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_pku.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_pmaps.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_prn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_purp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_skey.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_sxnet.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3_utl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@x509v3/$(DEPDIR)/libcrypto_la-v3err.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< compat/libcompat_la-strlcat.lo: compat/strlcat.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -MT compat/libcompat_la-strlcat.lo -MD -MP -MF compat/$(DEPDIR)/libcompat_la-strlcat.Tpo -c -o compat/libcompat_la-strlcat.lo `test -f 'compat/strlcat.c' || echo '$(srcdir)/'`compat/strlcat.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) compat/$(DEPDIR)/libcompat_la-strlcat.Tpo compat/$(DEPDIR)/libcompat_la-strlcat.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='compat/strlcat.c' object='compat/libcompat_la-strlcat.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -c -o compat/libcompat_la-strlcat.lo `test -f 'compat/strlcat.c' || echo '$(srcdir)/'`compat/strlcat.c compat/libcompat_la-strlcpy.lo: compat/strlcpy.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -MT compat/libcompat_la-strlcpy.lo -MD -MP -MF compat/$(DEPDIR)/libcompat_la-strlcpy.Tpo -c -o compat/libcompat_la-strlcpy.lo `test -f 'compat/strlcpy.c' || echo '$(srcdir)/'`compat/strlcpy.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) compat/$(DEPDIR)/libcompat_la-strlcpy.Tpo compat/$(DEPDIR)/libcompat_la-strlcpy.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='compat/strlcpy.c' object='compat/libcompat_la-strlcpy.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -c -o compat/libcompat_la-strlcpy.lo `test -f 'compat/strlcpy.c' || echo '$(srcdir)/'`compat/strlcpy.c compat/libcompat_la-reallocarray.lo: compat/reallocarray.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -MT compat/libcompat_la-reallocarray.lo -MD -MP -MF compat/$(DEPDIR)/libcompat_la-reallocarray.Tpo -c -o compat/libcompat_la-reallocarray.lo `test -f 'compat/reallocarray.c' || echo '$(srcdir)/'`compat/reallocarray.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) compat/$(DEPDIR)/libcompat_la-reallocarray.Tpo compat/$(DEPDIR)/libcompat_la-reallocarray.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='compat/reallocarray.c' object='compat/libcompat_la-reallocarray.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -c -o compat/libcompat_la-reallocarray.lo `test -f 'compat/reallocarray.c' || echo '$(srcdir)/'`compat/reallocarray.c compat/libcompat_la-timingsafe_memcmp.lo: compat/timingsafe_memcmp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -MT compat/libcompat_la-timingsafe_memcmp.lo -MD -MP -MF compat/$(DEPDIR)/libcompat_la-timingsafe_memcmp.Tpo -c -o compat/libcompat_la-timingsafe_memcmp.lo `test -f 'compat/timingsafe_memcmp.c' || echo '$(srcdir)/'`compat/timingsafe_memcmp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) compat/$(DEPDIR)/libcompat_la-timingsafe_memcmp.Tpo compat/$(DEPDIR)/libcompat_la-timingsafe_memcmp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='compat/timingsafe_memcmp.c' object='compat/libcompat_la-timingsafe_memcmp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -c -o compat/libcompat_la-timingsafe_memcmp.lo `test -f 'compat/timingsafe_memcmp.c' || echo '$(srcdir)/'`compat/timingsafe_memcmp.c compat/libcompat_la-timingsafe_bcmp.lo: compat/timingsafe_bcmp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -MT compat/libcompat_la-timingsafe_bcmp.lo -MD -MP -MF compat/$(DEPDIR)/libcompat_la-timingsafe_bcmp.Tpo -c -o compat/libcompat_la-timingsafe_bcmp.lo `test -f 'compat/timingsafe_bcmp.c' || echo '$(srcdir)/'`compat/timingsafe_bcmp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) compat/$(DEPDIR)/libcompat_la-timingsafe_bcmp.Tpo compat/$(DEPDIR)/libcompat_la-timingsafe_bcmp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='compat/timingsafe_bcmp.c' object='compat/libcompat_la-timingsafe_bcmp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -c -o compat/libcompat_la-timingsafe_bcmp.lo `test -f 'compat/timingsafe_bcmp.c' || echo '$(srcdir)/'`compat/timingsafe_bcmp.c compat/libcompat_la-arc4random.lo: compat/arc4random.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -MT compat/libcompat_la-arc4random.lo -MD -MP -MF compat/$(DEPDIR)/libcompat_la-arc4random.Tpo -c -o compat/libcompat_la-arc4random.lo `test -f 'compat/arc4random.c' || echo '$(srcdir)/'`compat/arc4random.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) compat/$(DEPDIR)/libcompat_la-arc4random.Tpo compat/$(DEPDIR)/libcompat_la-arc4random.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='compat/arc4random.c' object='compat/libcompat_la-arc4random.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -c -o compat/libcompat_la-arc4random.lo `test -f 'compat/arc4random.c' || echo '$(srcdir)/'`compat/arc4random.c compat/libcompat_la-getentropy_linux.lo: compat/getentropy_linux.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -MT compat/libcompat_la-getentropy_linux.lo -MD -MP -MF compat/$(DEPDIR)/libcompat_la-getentropy_linux.Tpo -c -o compat/libcompat_la-getentropy_linux.lo `test -f 'compat/getentropy_linux.c' || echo '$(srcdir)/'`compat/getentropy_linux.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) compat/$(DEPDIR)/libcompat_la-getentropy_linux.Tpo compat/$(DEPDIR)/libcompat_la-getentropy_linux.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='compat/getentropy_linux.c' object='compat/libcompat_la-getentropy_linux.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -c -o compat/libcompat_la-getentropy_linux.lo `test -f 'compat/getentropy_linux.c' || echo '$(srcdir)/'`compat/getentropy_linux.c compat/libcompat_la-getentropy_osx.lo: compat/getentropy_osx.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -MT compat/libcompat_la-getentropy_osx.lo -MD -MP -MF compat/$(DEPDIR)/libcompat_la-getentropy_osx.Tpo -c -o compat/libcompat_la-getentropy_osx.lo `test -f 'compat/getentropy_osx.c' || echo '$(srcdir)/'`compat/getentropy_osx.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) compat/$(DEPDIR)/libcompat_la-getentropy_osx.Tpo compat/$(DEPDIR)/libcompat_la-getentropy_osx.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='compat/getentropy_osx.c' object='compat/libcompat_la-getentropy_osx.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -c -o compat/libcompat_la-getentropy_osx.lo `test -f 'compat/getentropy_osx.c' || echo '$(srcdir)/'`compat/getentropy_osx.c compat/libcompat_la-getentropy_solaris.lo: compat/getentropy_solaris.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -MT compat/libcompat_la-getentropy_solaris.lo -MD -MP -MF compat/$(DEPDIR)/libcompat_la-getentropy_solaris.Tpo -c -o compat/libcompat_la-getentropy_solaris.lo `test -f 'compat/getentropy_solaris.c' || echo '$(srcdir)/'`compat/getentropy_solaris.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) compat/$(DEPDIR)/libcompat_la-getentropy_solaris.Tpo compat/$(DEPDIR)/libcompat_la-getentropy_solaris.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='compat/getentropy_solaris.c' object='compat/libcompat_la-getentropy_solaris.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -c -o compat/libcompat_la-getentropy_solaris.lo `test -f 'compat/getentropy_solaris.c' || echo '$(srcdir)/'`compat/getentropy_solaris.c compat/libcompat_la-getentropy_nacl.lo: compat/getentropy_nacl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -MT compat/libcompat_la-getentropy_nacl.lo -MD -MP -MF compat/$(DEPDIR)/libcompat_la-getentropy_nacl.Tpo -c -o compat/libcompat_la-getentropy_nacl.lo `test -f 'compat/getentropy_nacl.c' || echo '$(srcdir)/'`compat/getentropy_nacl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) compat/$(DEPDIR)/libcompat_la-getentropy_nacl.Tpo compat/$(DEPDIR)/libcompat_la-getentropy_nacl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='compat/getentropy_nacl.c' object='compat/libcompat_la-getentropy_nacl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -c -o compat/libcompat_la-getentropy_nacl.lo `test -f 'compat/getentropy_nacl.c' || echo '$(srcdir)/'`compat/getentropy_nacl.c compat/libcompat_la-issetugid_linux.lo: compat/issetugid_linux.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -MT compat/libcompat_la-issetugid_linux.lo -MD -MP -MF compat/$(DEPDIR)/libcompat_la-issetugid_linux.Tpo -c -o compat/libcompat_la-issetugid_linux.lo `test -f 'compat/issetugid_linux.c' || echo '$(srcdir)/'`compat/issetugid_linux.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) compat/$(DEPDIR)/libcompat_la-issetugid_linux.Tpo compat/$(DEPDIR)/libcompat_la-issetugid_linux.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='compat/issetugid_linux.c' object='compat/libcompat_la-issetugid_linux.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -c -o compat/libcompat_la-issetugid_linux.lo `test -f 'compat/issetugid_linux.c' || echo '$(srcdir)/'`compat/issetugid_linux.c compat/libcompatnoopt_la-explicit_bzero.lo: compat/explicit_bzero.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompatnoopt_la_CFLAGS) $(CFLAGS) -MT compat/libcompatnoopt_la-explicit_bzero.lo -MD -MP -MF compat/$(DEPDIR)/libcompatnoopt_la-explicit_bzero.Tpo -c -o compat/libcompatnoopt_la-explicit_bzero.lo `test -f 'compat/explicit_bzero.c' || echo '$(srcdir)/'`compat/explicit_bzero.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) compat/$(DEPDIR)/libcompatnoopt_la-explicit_bzero.Tpo compat/$(DEPDIR)/libcompatnoopt_la-explicit_bzero.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='compat/explicit_bzero.c' object='compat/libcompatnoopt_la-explicit_bzero.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompatnoopt_la_CFLAGS) $(CFLAGS) -c -o compat/libcompatnoopt_la-explicit_bzero.lo `test -f 'compat/explicit_bzero.c' || echo '$(srcdir)/'`compat/explicit_bzero.c libcrypto_la-cpt_err.lo: cpt_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT libcrypto_la-cpt_err.lo -MD -MP -MF $(DEPDIR)/libcrypto_la-cpt_err.Tpo -c -o libcrypto_la-cpt_err.lo `test -f 'cpt_err.c' || echo '$(srcdir)/'`cpt_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcrypto_la-cpt_err.Tpo $(DEPDIR)/libcrypto_la-cpt_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cpt_err.c' object='libcrypto_la-cpt_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o libcrypto_la-cpt_err.lo `test -f 'cpt_err.c' || echo '$(srcdir)/'`cpt_err.c libcrypto_la-cryptlib.lo: cryptlib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT libcrypto_la-cryptlib.lo -MD -MP -MF $(DEPDIR)/libcrypto_la-cryptlib.Tpo -c -o libcrypto_la-cryptlib.lo `test -f 'cryptlib.c' || echo '$(srcdir)/'`cryptlib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcrypto_la-cryptlib.Tpo $(DEPDIR)/libcrypto_la-cryptlib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cryptlib.c' object='libcrypto_la-cryptlib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o libcrypto_la-cryptlib.lo `test -f 'cryptlib.c' || echo '$(srcdir)/'`cryptlib.c libcrypto_la-cversion.lo: cversion.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT libcrypto_la-cversion.lo -MD -MP -MF $(DEPDIR)/libcrypto_la-cversion.Tpo -c -o libcrypto_la-cversion.lo `test -f 'cversion.c' || echo '$(srcdir)/'`cversion.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcrypto_la-cversion.Tpo $(DEPDIR)/libcrypto_la-cversion.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cversion.c' object='libcrypto_la-cversion.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o libcrypto_la-cversion.lo `test -f 'cversion.c' || echo '$(srcdir)/'`cversion.c libcrypto_la-ex_data.lo: ex_data.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT libcrypto_la-ex_data.lo -MD -MP -MF $(DEPDIR)/libcrypto_la-ex_data.Tpo -c -o libcrypto_la-ex_data.lo `test -f 'ex_data.c' || echo '$(srcdir)/'`ex_data.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcrypto_la-ex_data.Tpo $(DEPDIR)/libcrypto_la-ex_data.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ex_data.c' object='libcrypto_la-ex_data.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o libcrypto_la-ex_data.lo `test -f 'ex_data.c' || echo '$(srcdir)/'`ex_data.c libcrypto_la-malloc-wrapper.lo: malloc-wrapper.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT libcrypto_la-malloc-wrapper.lo -MD -MP -MF $(DEPDIR)/libcrypto_la-malloc-wrapper.Tpo -c -o libcrypto_la-malloc-wrapper.lo `test -f 'malloc-wrapper.c' || echo '$(srcdir)/'`malloc-wrapper.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcrypto_la-malloc-wrapper.Tpo $(DEPDIR)/libcrypto_la-malloc-wrapper.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='malloc-wrapper.c' object='libcrypto_la-malloc-wrapper.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o libcrypto_la-malloc-wrapper.lo `test -f 'malloc-wrapper.c' || echo '$(srcdir)/'`malloc-wrapper.c libcrypto_la-mem_clr.lo: mem_clr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT libcrypto_la-mem_clr.lo -MD -MP -MF $(DEPDIR)/libcrypto_la-mem_clr.Tpo -c -o libcrypto_la-mem_clr.lo `test -f 'mem_clr.c' || echo '$(srcdir)/'`mem_clr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcrypto_la-mem_clr.Tpo $(DEPDIR)/libcrypto_la-mem_clr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mem_clr.c' object='libcrypto_la-mem_clr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o libcrypto_la-mem_clr.lo `test -f 'mem_clr.c' || echo '$(srcdir)/'`mem_clr.c libcrypto_la-mem_dbg.lo: mem_dbg.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT libcrypto_la-mem_dbg.lo -MD -MP -MF $(DEPDIR)/libcrypto_la-mem_dbg.Tpo -c -o libcrypto_la-mem_dbg.lo `test -f 'mem_dbg.c' || echo '$(srcdir)/'`mem_dbg.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcrypto_la-mem_dbg.Tpo $(DEPDIR)/libcrypto_la-mem_dbg.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mem_dbg.c' object='libcrypto_la-mem_dbg.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o libcrypto_la-mem_dbg.lo `test -f 'mem_dbg.c' || echo '$(srcdir)/'`mem_dbg.c libcrypto_la-o_init.lo: o_init.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT libcrypto_la-o_init.lo -MD -MP -MF $(DEPDIR)/libcrypto_la-o_init.Tpo -c -o libcrypto_la-o_init.lo `test -f 'o_init.c' || echo '$(srcdir)/'`o_init.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcrypto_la-o_init.Tpo $(DEPDIR)/libcrypto_la-o_init.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='o_init.c' object='libcrypto_la-o_init.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o libcrypto_la-o_init.lo `test -f 'o_init.c' || echo '$(srcdir)/'`o_init.c libcrypto_la-o_str.lo: o_str.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT libcrypto_la-o_str.lo -MD -MP -MF $(DEPDIR)/libcrypto_la-o_str.Tpo -c -o libcrypto_la-o_str.lo `test -f 'o_str.c' || echo '$(srcdir)/'`o_str.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcrypto_la-o_str.Tpo $(DEPDIR)/libcrypto_la-o_str.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='o_str.c' object='libcrypto_la-o_str.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o libcrypto_la-o_str.lo `test -f 'o_str.c' || echo '$(srcdir)/'`o_str.c libcrypto_la-o_time.lo: o_time.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT libcrypto_la-o_time.lo -MD -MP -MF $(DEPDIR)/libcrypto_la-o_time.Tpo -c -o libcrypto_la-o_time.lo `test -f 'o_time.c' || echo '$(srcdir)/'`o_time.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcrypto_la-o_time.Tpo $(DEPDIR)/libcrypto_la-o_time.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='o_time.c' object='libcrypto_la-o_time.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o libcrypto_la-o_time.lo `test -f 'o_time.c' || echo '$(srcdir)/'`o_time.c aes/libcrypto_la-aes_cbc.lo: aes/aes_cbc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT aes/libcrypto_la-aes_cbc.lo -MD -MP -MF aes/$(DEPDIR)/libcrypto_la-aes_cbc.Tpo -c -o aes/libcrypto_la-aes_cbc.lo `test -f 'aes/aes_cbc.c' || echo '$(srcdir)/'`aes/aes_cbc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) aes/$(DEPDIR)/libcrypto_la-aes_cbc.Tpo aes/$(DEPDIR)/libcrypto_la-aes_cbc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='aes/aes_cbc.c' object='aes/libcrypto_la-aes_cbc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o aes/libcrypto_la-aes_cbc.lo `test -f 'aes/aes_cbc.c' || echo '$(srcdir)/'`aes/aes_cbc.c aes/libcrypto_la-aes_cfb.lo: aes/aes_cfb.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT aes/libcrypto_la-aes_cfb.lo -MD -MP -MF aes/$(DEPDIR)/libcrypto_la-aes_cfb.Tpo -c -o aes/libcrypto_la-aes_cfb.lo `test -f 'aes/aes_cfb.c' || echo '$(srcdir)/'`aes/aes_cfb.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) aes/$(DEPDIR)/libcrypto_la-aes_cfb.Tpo aes/$(DEPDIR)/libcrypto_la-aes_cfb.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='aes/aes_cfb.c' object='aes/libcrypto_la-aes_cfb.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o aes/libcrypto_la-aes_cfb.lo `test -f 'aes/aes_cfb.c' || echo '$(srcdir)/'`aes/aes_cfb.c aes/libcrypto_la-aes_core.lo: aes/aes_core.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT aes/libcrypto_la-aes_core.lo -MD -MP -MF aes/$(DEPDIR)/libcrypto_la-aes_core.Tpo -c -o aes/libcrypto_la-aes_core.lo `test -f 'aes/aes_core.c' || echo '$(srcdir)/'`aes/aes_core.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) aes/$(DEPDIR)/libcrypto_la-aes_core.Tpo aes/$(DEPDIR)/libcrypto_la-aes_core.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='aes/aes_core.c' object='aes/libcrypto_la-aes_core.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o aes/libcrypto_la-aes_core.lo `test -f 'aes/aes_core.c' || echo '$(srcdir)/'`aes/aes_core.c aes/libcrypto_la-aes_ctr.lo: aes/aes_ctr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT aes/libcrypto_la-aes_ctr.lo -MD -MP -MF aes/$(DEPDIR)/libcrypto_la-aes_ctr.Tpo -c -o aes/libcrypto_la-aes_ctr.lo `test -f 'aes/aes_ctr.c' || echo '$(srcdir)/'`aes/aes_ctr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) aes/$(DEPDIR)/libcrypto_la-aes_ctr.Tpo aes/$(DEPDIR)/libcrypto_la-aes_ctr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='aes/aes_ctr.c' object='aes/libcrypto_la-aes_ctr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o aes/libcrypto_la-aes_ctr.lo `test -f 'aes/aes_ctr.c' || echo '$(srcdir)/'`aes/aes_ctr.c aes/libcrypto_la-aes_ecb.lo: aes/aes_ecb.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT aes/libcrypto_la-aes_ecb.lo -MD -MP -MF aes/$(DEPDIR)/libcrypto_la-aes_ecb.Tpo -c -o aes/libcrypto_la-aes_ecb.lo `test -f 'aes/aes_ecb.c' || echo '$(srcdir)/'`aes/aes_ecb.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) aes/$(DEPDIR)/libcrypto_la-aes_ecb.Tpo aes/$(DEPDIR)/libcrypto_la-aes_ecb.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='aes/aes_ecb.c' object='aes/libcrypto_la-aes_ecb.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o aes/libcrypto_la-aes_ecb.lo `test -f 'aes/aes_ecb.c' || echo '$(srcdir)/'`aes/aes_ecb.c aes/libcrypto_la-aes_ige.lo: aes/aes_ige.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT aes/libcrypto_la-aes_ige.lo -MD -MP -MF aes/$(DEPDIR)/libcrypto_la-aes_ige.Tpo -c -o aes/libcrypto_la-aes_ige.lo `test -f 'aes/aes_ige.c' || echo '$(srcdir)/'`aes/aes_ige.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) aes/$(DEPDIR)/libcrypto_la-aes_ige.Tpo aes/$(DEPDIR)/libcrypto_la-aes_ige.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='aes/aes_ige.c' object='aes/libcrypto_la-aes_ige.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o aes/libcrypto_la-aes_ige.lo `test -f 'aes/aes_ige.c' || echo '$(srcdir)/'`aes/aes_ige.c aes/libcrypto_la-aes_misc.lo: aes/aes_misc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT aes/libcrypto_la-aes_misc.lo -MD -MP -MF aes/$(DEPDIR)/libcrypto_la-aes_misc.Tpo -c -o aes/libcrypto_la-aes_misc.lo `test -f 'aes/aes_misc.c' || echo '$(srcdir)/'`aes/aes_misc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) aes/$(DEPDIR)/libcrypto_la-aes_misc.Tpo aes/$(DEPDIR)/libcrypto_la-aes_misc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='aes/aes_misc.c' object='aes/libcrypto_la-aes_misc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o aes/libcrypto_la-aes_misc.lo `test -f 'aes/aes_misc.c' || echo '$(srcdir)/'`aes/aes_misc.c aes/libcrypto_la-aes_ofb.lo: aes/aes_ofb.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT aes/libcrypto_la-aes_ofb.lo -MD -MP -MF aes/$(DEPDIR)/libcrypto_la-aes_ofb.Tpo -c -o aes/libcrypto_la-aes_ofb.lo `test -f 'aes/aes_ofb.c' || echo '$(srcdir)/'`aes/aes_ofb.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) aes/$(DEPDIR)/libcrypto_la-aes_ofb.Tpo aes/$(DEPDIR)/libcrypto_la-aes_ofb.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='aes/aes_ofb.c' object='aes/libcrypto_la-aes_ofb.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o aes/libcrypto_la-aes_ofb.lo `test -f 'aes/aes_ofb.c' || echo '$(srcdir)/'`aes/aes_ofb.c aes/libcrypto_la-aes_wrap.lo: aes/aes_wrap.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT aes/libcrypto_la-aes_wrap.lo -MD -MP -MF aes/$(DEPDIR)/libcrypto_la-aes_wrap.Tpo -c -o aes/libcrypto_la-aes_wrap.lo `test -f 'aes/aes_wrap.c' || echo '$(srcdir)/'`aes/aes_wrap.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) aes/$(DEPDIR)/libcrypto_la-aes_wrap.Tpo aes/$(DEPDIR)/libcrypto_la-aes_wrap.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='aes/aes_wrap.c' object='aes/libcrypto_la-aes_wrap.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o aes/libcrypto_la-aes_wrap.lo `test -f 'aes/aes_wrap.c' || echo '$(srcdir)/'`aes/aes_wrap.c asn1/libcrypto_la-a_bitstr.lo: asn1/a_bitstr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_bitstr.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_bitstr.Tpo -c -o asn1/libcrypto_la-a_bitstr.lo `test -f 'asn1/a_bitstr.c' || echo '$(srcdir)/'`asn1/a_bitstr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_bitstr.Tpo asn1/$(DEPDIR)/libcrypto_la-a_bitstr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_bitstr.c' object='asn1/libcrypto_la-a_bitstr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_bitstr.lo `test -f 'asn1/a_bitstr.c' || echo '$(srcdir)/'`asn1/a_bitstr.c asn1/libcrypto_la-a_bool.lo: asn1/a_bool.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_bool.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_bool.Tpo -c -o asn1/libcrypto_la-a_bool.lo `test -f 'asn1/a_bool.c' || echo '$(srcdir)/'`asn1/a_bool.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_bool.Tpo asn1/$(DEPDIR)/libcrypto_la-a_bool.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_bool.c' object='asn1/libcrypto_la-a_bool.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_bool.lo `test -f 'asn1/a_bool.c' || echo '$(srcdir)/'`asn1/a_bool.c asn1/libcrypto_la-a_bytes.lo: asn1/a_bytes.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_bytes.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_bytes.Tpo -c -o asn1/libcrypto_la-a_bytes.lo `test -f 'asn1/a_bytes.c' || echo '$(srcdir)/'`asn1/a_bytes.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_bytes.Tpo asn1/$(DEPDIR)/libcrypto_la-a_bytes.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_bytes.c' object='asn1/libcrypto_la-a_bytes.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_bytes.lo `test -f 'asn1/a_bytes.c' || echo '$(srcdir)/'`asn1/a_bytes.c asn1/libcrypto_la-a_d2i_fp.lo: asn1/a_d2i_fp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_d2i_fp.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_d2i_fp.Tpo -c -o asn1/libcrypto_la-a_d2i_fp.lo `test -f 'asn1/a_d2i_fp.c' || echo '$(srcdir)/'`asn1/a_d2i_fp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_d2i_fp.Tpo asn1/$(DEPDIR)/libcrypto_la-a_d2i_fp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_d2i_fp.c' object='asn1/libcrypto_la-a_d2i_fp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_d2i_fp.lo `test -f 'asn1/a_d2i_fp.c' || echo '$(srcdir)/'`asn1/a_d2i_fp.c asn1/libcrypto_la-a_digest.lo: asn1/a_digest.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_digest.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_digest.Tpo -c -o asn1/libcrypto_la-a_digest.lo `test -f 'asn1/a_digest.c' || echo '$(srcdir)/'`asn1/a_digest.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_digest.Tpo asn1/$(DEPDIR)/libcrypto_la-a_digest.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_digest.c' object='asn1/libcrypto_la-a_digest.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_digest.lo `test -f 'asn1/a_digest.c' || echo '$(srcdir)/'`asn1/a_digest.c asn1/libcrypto_la-a_dup.lo: asn1/a_dup.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_dup.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_dup.Tpo -c -o asn1/libcrypto_la-a_dup.lo `test -f 'asn1/a_dup.c' || echo '$(srcdir)/'`asn1/a_dup.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_dup.Tpo asn1/$(DEPDIR)/libcrypto_la-a_dup.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_dup.c' object='asn1/libcrypto_la-a_dup.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_dup.lo `test -f 'asn1/a_dup.c' || echo '$(srcdir)/'`asn1/a_dup.c asn1/libcrypto_la-a_enum.lo: asn1/a_enum.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_enum.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_enum.Tpo -c -o asn1/libcrypto_la-a_enum.lo `test -f 'asn1/a_enum.c' || echo '$(srcdir)/'`asn1/a_enum.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_enum.Tpo asn1/$(DEPDIR)/libcrypto_la-a_enum.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_enum.c' object='asn1/libcrypto_la-a_enum.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_enum.lo `test -f 'asn1/a_enum.c' || echo '$(srcdir)/'`asn1/a_enum.c asn1/libcrypto_la-a_gentm.lo: asn1/a_gentm.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_gentm.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_gentm.Tpo -c -o asn1/libcrypto_la-a_gentm.lo `test -f 'asn1/a_gentm.c' || echo '$(srcdir)/'`asn1/a_gentm.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_gentm.Tpo asn1/$(DEPDIR)/libcrypto_la-a_gentm.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_gentm.c' object='asn1/libcrypto_la-a_gentm.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_gentm.lo `test -f 'asn1/a_gentm.c' || echo '$(srcdir)/'`asn1/a_gentm.c asn1/libcrypto_la-a_i2d_fp.lo: asn1/a_i2d_fp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_i2d_fp.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_i2d_fp.Tpo -c -o asn1/libcrypto_la-a_i2d_fp.lo `test -f 'asn1/a_i2d_fp.c' || echo '$(srcdir)/'`asn1/a_i2d_fp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_i2d_fp.Tpo asn1/$(DEPDIR)/libcrypto_la-a_i2d_fp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_i2d_fp.c' object='asn1/libcrypto_la-a_i2d_fp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_i2d_fp.lo `test -f 'asn1/a_i2d_fp.c' || echo '$(srcdir)/'`asn1/a_i2d_fp.c asn1/libcrypto_la-a_int.lo: asn1/a_int.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_int.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_int.Tpo -c -o asn1/libcrypto_la-a_int.lo `test -f 'asn1/a_int.c' || echo '$(srcdir)/'`asn1/a_int.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_int.Tpo asn1/$(DEPDIR)/libcrypto_la-a_int.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_int.c' object='asn1/libcrypto_la-a_int.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_int.lo `test -f 'asn1/a_int.c' || echo '$(srcdir)/'`asn1/a_int.c asn1/libcrypto_la-a_mbstr.lo: asn1/a_mbstr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_mbstr.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_mbstr.Tpo -c -o asn1/libcrypto_la-a_mbstr.lo `test -f 'asn1/a_mbstr.c' || echo '$(srcdir)/'`asn1/a_mbstr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_mbstr.Tpo asn1/$(DEPDIR)/libcrypto_la-a_mbstr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_mbstr.c' object='asn1/libcrypto_la-a_mbstr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_mbstr.lo `test -f 'asn1/a_mbstr.c' || echo '$(srcdir)/'`asn1/a_mbstr.c asn1/libcrypto_la-a_object.lo: asn1/a_object.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_object.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_object.Tpo -c -o asn1/libcrypto_la-a_object.lo `test -f 'asn1/a_object.c' || echo '$(srcdir)/'`asn1/a_object.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_object.Tpo asn1/$(DEPDIR)/libcrypto_la-a_object.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_object.c' object='asn1/libcrypto_la-a_object.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_object.lo `test -f 'asn1/a_object.c' || echo '$(srcdir)/'`asn1/a_object.c asn1/libcrypto_la-a_octet.lo: asn1/a_octet.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_octet.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_octet.Tpo -c -o asn1/libcrypto_la-a_octet.lo `test -f 'asn1/a_octet.c' || echo '$(srcdir)/'`asn1/a_octet.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_octet.Tpo asn1/$(DEPDIR)/libcrypto_la-a_octet.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_octet.c' object='asn1/libcrypto_la-a_octet.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_octet.lo `test -f 'asn1/a_octet.c' || echo '$(srcdir)/'`asn1/a_octet.c asn1/libcrypto_la-a_print.lo: asn1/a_print.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_print.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_print.Tpo -c -o asn1/libcrypto_la-a_print.lo `test -f 'asn1/a_print.c' || echo '$(srcdir)/'`asn1/a_print.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_print.Tpo asn1/$(DEPDIR)/libcrypto_la-a_print.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_print.c' object='asn1/libcrypto_la-a_print.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_print.lo `test -f 'asn1/a_print.c' || echo '$(srcdir)/'`asn1/a_print.c asn1/libcrypto_la-a_set.lo: asn1/a_set.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_set.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_set.Tpo -c -o asn1/libcrypto_la-a_set.lo `test -f 'asn1/a_set.c' || echo '$(srcdir)/'`asn1/a_set.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_set.Tpo asn1/$(DEPDIR)/libcrypto_la-a_set.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_set.c' object='asn1/libcrypto_la-a_set.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_set.lo `test -f 'asn1/a_set.c' || echo '$(srcdir)/'`asn1/a_set.c asn1/libcrypto_la-a_sign.lo: asn1/a_sign.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_sign.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_sign.Tpo -c -o asn1/libcrypto_la-a_sign.lo `test -f 'asn1/a_sign.c' || echo '$(srcdir)/'`asn1/a_sign.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_sign.Tpo asn1/$(DEPDIR)/libcrypto_la-a_sign.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_sign.c' object='asn1/libcrypto_la-a_sign.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_sign.lo `test -f 'asn1/a_sign.c' || echo '$(srcdir)/'`asn1/a_sign.c asn1/libcrypto_la-a_strex.lo: asn1/a_strex.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_strex.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_strex.Tpo -c -o asn1/libcrypto_la-a_strex.lo `test -f 'asn1/a_strex.c' || echo '$(srcdir)/'`asn1/a_strex.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_strex.Tpo asn1/$(DEPDIR)/libcrypto_la-a_strex.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_strex.c' object='asn1/libcrypto_la-a_strex.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_strex.lo `test -f 'asn1/a_strex.c' || echo '$(srcdir)/'`asn1/a_strex.c asn1/libcrypto_la-a_strnid.lo: asn1/a_strnid.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_strnid.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_strnid.Tpo -c -o asn1/libcrypto_la-a_strnid.lo `test -f 'asn1/a_strnid.c' || echo '$(srcdir)/'`asn1/a_strnid.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_strnid.Tpo asn1/$(DEPDIR)/libcrypto_la-a_strnid.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_strnid.c' object='asn1/libcrypto_la-a_strnid.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_strnid.lo `test -f 'asn1/a_strnid.c' || echo '$(srcdir)/'`asn1/a_strnid.c asn1/libcrypto_la-a_time.lo: asn1/a_time.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_time.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_time.Tpo -c -o asn1/libcrypto_la-a_time.lo `test -f 'asn1/a_time.c' || echo '$(srcdir)/'`asn1/a_time.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_time.Tpo asn1/$(DEPDIR)/libcrypto_la-a_time.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_time.c' object='asn1/libcrypto_la-a_time.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_time.lo `test -f 'asn1/a_time.c' || echo '$(srcdir)/'`asn1/a_time.c asn1/libcrypto_la-a_type.lo: asn1/a_type.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_type.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_type.Tpo -c -o asn1/libcrypto_la-a_type.lo `test -f 'asn1/a_type.c' || echo '$(srcdir)/'`asn1/a_type.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_type.Tpo asn1/$(DEPDIR)/libcrypto_la-a_type.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_type.c' object='asn1/libcrypto_la-a_type.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_type.lo `test -f 'asn1/a_type.c' || echo '$(srcdir)/'`asn1/a_type.c asn1/libcrypto_la-a_utctm.lo: asn1/a_utctm.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_utctm.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_utctm.Tpo -c -o asn1/libcrypto_la-a_utctm.lo `test -f 'asn1/a_utctm.c' || echo '$(srcdir)/'`asn1/a_utctm.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_utctm.Tpo asn1/$(DEPDIR)/libcrypto_la-a_utctm.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_utctm.c' object='asn1/libcrypto_la-a_utctm.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_utctm.lo `test -f 'asn1/a_utctm.c' || echo '$(srcdir)/'`asn1/a_utctm.c asn1/libcrypto_la-a_utf8.lo: asn1/a_utf8.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_utf8.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_utf8.Tpo -c -o asn1/libcrypto_la-a_utf8.lo `test -f 'asn1/a_utf8.c' || echo '$(srcdir)/'`asn1/a_utf8.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_utf8.Tpo asn1/$(DEPDIR)/libcrypto_la-a_utf8.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_utf8.c' object='asn1/libcrypto_la-a_utf8.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_utf8.lo `test -f 'asn1/a_utf8.c' || echo '$(srcdir)/'`asn1/a_utf8.c asn1/libcrypto_la-a_verify.lo: asn1/a_verify.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_verify.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_verify.Tpo -c -o asn1/libcrypto_la-a_verify.lo `test -f 'asn1/a_verify.c' || echo '$(srcdir)/'`asn1/a_verify.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_verify.Tpo asn1/$(DEPDIR)/libcrypto_la-a_verify.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_verify.c' object='asn1/libcrypto_la-a_verify.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_verify.lo `test -f 'asn1/a_verify.c' || echo '$(srcdir)/'`asn1/a_verify.c asn1/libcrypto_la-ameth_lib.lo: asn1/ameth_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-ameth_lib.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-ameth_lib.Tpo -c -o asn1/libcrypto_la-ameth_lib.lo `test -f 'asn1/ameth_lib.c' || echo '$(srcdir)/'`asn1/ameth_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-ameth_lib.Tpo asn1/$(DEPDIR)/libcrypto_la-ameth_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/ameth_lib.c' object='asn1/libcrypto_la-ameth_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-ameth_lib.lo `test -f 'asn1/ameth_lib.c' || echo '$(srcdir)/'`asn1/ameth_lib.c asn1/libcrypto_la-asn1_err.lo: asn1/asn1_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-asn1_err.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-asn1_err.Tpo -c -o asn1/libcrypto_la-asn1_err.lo `test -f 'asn1/asn1_err.c' || echo '$(srcdir)/'`asn1/asn1_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-asn1_err.Tpo asn1/$(DEPDIR)/libcrypto_la-asn1_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/asn1_err.c' object='asn1/libcrypto_la-asn1_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-asn1_err.lo `test -f 'asn1/asn1_err.c' || echo '$(srcdir)/'`asn1/asn1_err.c asn1/libcrypto_la-asn1_gen.lo: asn1/asn1_gen.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-asn1_gen.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-asn1_gen.Tpo -c -o asn1/libcrypto_la-asn1_gen.lo `test -f 'asn1/asn1_gen.c' || echo '$(srcdir)/'`asn1/asn1_gen.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-asn1_gen.Tpo asn1/$(DEPDIR)/libcrypto_la-asn1_gen.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/asn1_gen.c' object='asn1/libcrypto_la-asn1_gen.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-asn1_gen.lo `test -f 'asn1/asn1_gen.c' || echo '$(srcdir)/'`asn1/asn1_gen.c asn1/libcrypto_la-asn1_lib.lo: asn1/asn1_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-asn1_lib.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-asn1_lib.Tpo -c -o asn1/libcrypto_la-asn1_lib.lo `test -f 'asn1/asn1_lib.c' || echo '$(srcdir)/'`asn1/asn1_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-asn1_lib.Tpo asn1/$(DEPDIR)/libcrypto_la-asn1_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/asn1_lib.c' object='asn1/libcrypto_la-asn1_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-asn1_lib.lo `test -f 'asn1/asn1_lib.c' || echo '$(srcdir)/'`asn1/asn1_lib.c asn1/libcrypto_la-asn1_par.lo: asn1/asn1_par.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-asn1_par.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-asn1_par.Tpo -c -o asn1/libcrypto_la-asn1_par.lo `test -f 'asn1/asn1_par.c' || echo '$(srcdir)/'`asn1/asn1_par.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-asn1_par.Tpo asn1/$(DEPDIR)/libcrypto_la-asn1_par.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/asn1_par.c' object='asn1/libcrypto_la-asn1_par.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-asn1_par.lo `test -f 'asn1/asn1_par.c' || echo '$(srcdir)/'`asn1/asn1_par.c asn1/libcrypto_la-asn_mime.lo: asn1/asn_mime.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-asn_mime.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-asn_mime.Tpo -c -o asn1/libcrypto_la-asn_mime.lo `test -f 'asn1/asn_mime.c' || echo '$(srcdir)/'`asn1/asn_mime.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-asn_mime.Tpo asn1/$(DEPDIR)/libcrypto_la-asn_mime.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/asn_mime.c' object='asn1/libcrypto_la-asn_mime.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-asn_mime.lo `test -f 'asn1/asn_mime.c' || echo '$(srcdir)/'`asn1/asn_mime.c asn1/libcrypto_la-asn_moid.lo: asn1/asn_moid.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-asn_moid.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-asn_moid.Tpo -c -o asn1/libcrypto_la-asn_moid.lo `test -f 'asn1/asn_moid.c' || echo '$(srcdir)/'`asn1/asn_moid.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-asn_moid.Tpo asn1/$(DEPDIR)/libcrypto_la-asn_moid.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/asn_moid.c' object='asn1/libcrypto_la-asn_moid.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-asn_moid.lo `test -f 'asn1/asn_moid.c' || echo '$(srcdir)/'`asn1/asn_moid.c asn1/libcrypto_la-asn_pack.lo: asn1/asn_pack.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-asn_pack.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-asn_pack.Tpo -c -o asn1/libcrypto_la-asn_pack.lo `test -f 'asn1/asn_pack.c' || echo '$(srcdir)/'`asn1/asn_pack.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-asn_pack.Tpo asn1/$(DEPDIR)/libcrypto_la-asn_pack.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/asn_pack.c' object='asn1/libcrypto_la-asn_pack.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-asn_pack.lo `test -f 'asn1/asn_pack.c' || echo '$(srcdir)/'`asn1/asn_pack.c asn1/libcrypto_la-bio_asn1.lo: asn1/bio_asn1.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-bio_asn1.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-bio_asn1.Tpo -c -o asn1/libcrypto_la-bio_asn1.lo `test -f 'asn1/bio_asn1.c' || echo '$(srcdir)/'`asn1/bio_asn1.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-bio_asn1.Tpo asn1/$(DEPDIR)/libcrypto_la-bio_asn1.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/bio_asn1.c' object='asn1/libcrypto_la-bio_asn1.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-bio_asn1.lo `test -f 'asn1/bio_asn1.c' || echo '$(srcdir)/'`asn1/bio_asn1.c asn1/libcrypto_la-bio_ndef.lo: asn1/bio_ndef.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-bio_ndef.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-bio_ndef.Tpo -c -o asn1/libcrypto_la-bio_ndef.lo `test -f 'asn1/bio_ndef.c' || echo '$(srcdir)/'`asn1/bio_ndef.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-bio_ndef.Tpo asn1/$(DEPDIR)/libcrypto_la-bio_ndef.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/bio_ndef.c' object='asn1/libcrypto_la-bio_ndef.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-bio_ndef.lo `test -f 'asn1/bio_ndef.c' || echo '$(srcdir)/'`asn1/bio_ndef.c asn1/libcrypto_la-d2i_pr.lo: asn1/d2i_pr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-d2i_pr.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-d2i_pr.Tpo -c -o asn1/libcrypto_la-d2i_pr.lo `test -f 'asn1/d2i_pr.c' || echo '$(srcdir)/'`asn1/d2i_pr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-d2i_pr.Tpo asn1/$(DEPDIR)/libcrypto_la-d2i_pr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/d2i_pr.c' object='asn1/libcrypto_la-d2i_pr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-d2i_pr.lo `test -f 'asn1/d2i_pr.c' || echo '$(srcdir)/'`asn1/d2i_pr.c asn1/libcrypto_la-d2i_pu.lo: asn1/d2i_pu.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-d2i_pu.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-d2i_pu.Tpo -c -o asn1/libcrypto_la-d2i_pu.lo `test -f 'asn1/d2i_pu.c' || echo '$(srcdir)/'`asn1/d2i_pu.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-d2i_pu.Tpo asn1/$(DEPDIR)/libcrypto_la-d2i_pu.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/d2i_pu.c' object='asn1/libcrypto_la-d2i_pu.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-d2i_pu.lo `test -f 'asn1/d2i_pu.c' || echo '$(srcdir)/'`asn1/d2i_pu.c asn1/libcrypto_la-evp_asn1.lo: asn1/evp_asn1.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-evp_asn1.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-evp_asn1.Tpo -c -o asn1/libcrypto_la-evp_asn1.lo `test -f 'asn1/evp_asn1.c' || echo '$(srcdir)/'`asn1/evp_asn1.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-evp_asn1.Tpo asn1/$(DEPDIR)/libcrypto_la-evp_asn1.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/evp_asn1.c' object='asn1/libcrypto_la-evp_asn1.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-evp_asn1.lo `test -f 'asn1/evp_asn1.c' || echo '$(srcdir)/'`asn1/evp_asn1.c asn1/libcrypto_la-f_enum.lo: asn1/f_enum.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-f_enum.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-f_enum.Tpo -c -o asn1/libcrypto_la-f_enum.lo `test -f 'asn1/f_enum.c' || echo '$(srcdir)/'`asn1/f_enum.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-f_enum.Tpo asn1/$(DEPDIR)/libcrypto_la-f_enum.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/f_enum.c' object='asn1/libcrypto_la-f_enum.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-f_enum.lo `test -f 'asn1/f_enum.c' || echo '$(srcdir)/'`asn1/f_enum.c asn1/libcrypto_la-f_int.lo: asn1/f_int.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-f_int.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-f_int.Tpo -c -o asn1/libcrypto_la-f_int.lo `test -f 'asn1/f_int.c' || echo '$(srcdir)/'`asn1/f_int.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-f_int.Tpo asn1/$(DEPDIR)/libcrypto_la-f_int.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/f_int.c' object='asn1/libcrypto_la-f_int.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-f_int.lo `test -f 'asn1/f_int.c' || echo '$(srcdir)/'`asn1/f_int.c asn1/libcrypto_la-f_string.lo: asn1/f_string.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-f_string.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-f_string.Tpo -c -o asn1/libcrypto_la-f_string.lo `test -f 'asn1/f_string.c' || echo '$(srcdir)/'`asn1/f_string.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-f_string.Tpo asn1/$(DEPDIR)/libcrypto_la-f_string.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/f_string.c' object='asn1/libcrypto_la-f_string.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-f_string.lo `test -f 'asn1/f_string.c' || echo '$(srcdir)/'`asn1/f_string.c asn1/libcrypto_la-i2d_pr.lo: asn1/i2d_pr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-i2d_pr.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-i2d_pr.Tpo -c -o asn1/libcrypto_la-i2d_pr.lo `test -f 'asn1/i2d_pr.c' || echo '$(srcdir)/'`asn1/i2d_pr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-i2d_pr.Tpo asn1/$(DEPDIR)/libcrypto_la-i2d_pr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/i2d_pr.c' object='asn1/libcrypto_la-i2d_pr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-i2d_pr.lo `test -f 'asn1/i2d_pr.c' || echo '$(srcdir)/'`asn1/i2d_pr.c asn1/libcrypto_la-i2d_pu.lo: asn1/i2d_pu.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-i2d_pu.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-i2d_pu.Tpo -c -o asn1/libcrypto_la-i2d_pu.lo `test -f 'asn1/i2d_pu.c' || echo '$(srcdir)/'`asn1/i2d_pu.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-i2d_pu.Tpo asn1/$(DEPDIR)/libcrypto_la-i2d_pu.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/i2d_pu.c' object='asn1/libcrypto_la-i2d_pu.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-i2d_pu.lo `test -f 'asn1/i2d_pu.c' || echo '$(srcdir)/'`asn1/i2d_pu.c asn1/libcrypto_la-n_pkey.lo: asn1/n_pkey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-n_pkey.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-n_pkey.Tpo -c -o asn1/libcrypto_la-n_pkey.lo `test -f 'asn1/n_pkey.c' || echo '$(srcdir)/'`asn1/n_pkey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-n_pkey.Tpo asn1/$(DEPDIR)/libcrypto_la-n_pkey.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/n_pkey.c' object='asn1/libcrypto_la-n_pkey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-n_pkey.lo `test -f 'asn1/n_pkey.c' || echo '$(srcdir)/'`asn1/n_pkey.c asn1/libcrypto_la-nsseq.lo: asn1/nsseq.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-nsseq.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-nsseq.Tpo -c -o asn1/libcrypto_la-nsseq.lo `test -f 'asn1/nsseq.c' || echo '$(srcdir)/'`asn1/nsseq.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-nsseq.Tpo asn1/$(DEPDIR)/libcrypto_la-nsseq.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/nsseq.c' object='asn1/libcrypto_la-nsseq.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-nsseq.lo `test -f 'asn1/nsseq.c' || echo '$(srcdir)/'`asn1/nsseq.c asn1/libcrypto_la-p5_pbe.lo: asn1/p5_pbe.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-p5_pbe.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-p5_pbe.Tpo -c -o asn1/libcrypto_la-p5_pbe.lo `test -f 'asn1/p5_pbe.c' || echo '$(srcdir)/'`asn1/p5_pbe.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-p5_pbe.Tpo asn1/$(DEPDIR)/libcrypto_la-p5_pbe.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/p5_pbe.c' object='asn1/libcrypto_la-p5_pbe.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-p5_pbe.lo `test -f 'asn1/p5_pbe.c' || echo '$(srcdir)/'`asn1/p5_pbe.c asn1/libcrypto_la-p5_pbev2.lo: asn1/p5_pbev2.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-p5_pbev2.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-p5_pbev2.Tpo -c -o asn1/libcrypto_la-p5_pbev2.lo `test -f 'asn1/p5_pbev2.c' || echo '$(srcdir)/'`asn1/p5_pbev2.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-p5_pbev2.Tpo asn1/$(DEPDIR)/libcrypto_la-p5_pbev2.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/p5_pbev2.c' object='asn1/libcrypto_la-p5_pbev2.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-p5_pbev2.lo `test -f 'asn1/p5_pbev2.c' || echo '$(srcdir)/'`asn1/p5_pbev2.c asn1/libcrypto_la-p8_pkey.lo: asn1/p8_pkey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-p8_pkey.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-p8_pkey.Tpo -c -o asn1/libcrypto_la-p8_pkey.lo `test -f 'asn1/p8_pkey.c' || echo '$(srcdir)/'`asn1/p8_pkey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-p8_pkey.Tpo asn1/$(DEPDIR)/libcrypto_la-p8_pkey.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/p8_pkey.c' object='asn1/libcrypto_la-p8_pkey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-p8_pkey.lo `test -f 'asn1/p8_pkey.c' || echo '$(srcdir)/'`asn1/p8_pkey.c asn1/libcrypto_la-t_bitst.lo: asn1/t_bitst.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-t_bitst.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-t_bitst.Tpo -c -o asn1/libcrypto_la-t_bitst.lo `test -f 'asn1/t_bitst.c' || echo '$(srcdir)/'`asn1/t_bitst.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-t_bitst.Tpo asn1/$(DEPDIR)/libcrypto_la-t_bitst.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/t_bitst.c' object='asn1/libcrypto_la-t_bitst.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-t_bitst.lo `test -f 'asn1/t_bitst.c' || echo '$(srcdir)/'`asn1/t_bitst.c asn1/libcrypto_la-t_crl.lo: asn1/t_crl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-t_crl.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-t_crl.Tpo -c -o asn1/libcrypto_la-t_crl.lo `test -f 'asn1/t_crl.c' || echo '$(srcdir)/'`asn1/t_crl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-t_crl.Tpo asn1/$(DEPDIR)/libcrypto_la-t_crl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/t_crl.c' object='asn1/libcrypto_la-t_crl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-t_crl.lo `test -f 'asn1/t_crl.c' || echo '$(srcdir)/'`asn1/t_crl.c asn1/libcrypto_la-t_pkey.lo: asn1/t_pkey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-t_pkey.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-t_pkey.Tpo -c -o asn1/libcrypto_la-t_pkey.lo `test -f 'asn1/t_pkey.c' || echo '$(srcdir)/'`asn1/t_pkey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-t_pkey.Tpo asn1/$(DEPDIR)/libcrypto_la-t_pkey.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/t_pkey.c' object='asn1/libcrypto_la-t_pkey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-t_pkey.lo `test -f 'asn1/t_pkey.c' || echo '$(srcdir)/'`asn1/t_pkey.c asn1/libcrypto_la-t_req.lo: asn1/t_req.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-t_req.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-t_req.Tpo -c -o asn1/libcrypto_la-t_req.lo `test -f 'asn1/t_req.c' || echo '$(srcdir)/'`asn1/t_req.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-t_req.Tpo asn1/$(DEPDIR)/libcrypto_la-t_req.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/t_req.c' object='asn1/libcrypto_la-t_req.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-t_req.lo `test -f 'asn1/t_req.c' || echo '$(srcdir)/'`asn1/t_req.c asn1/libcrypto_la-t_spki.lo: asn1/t_spki.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-t_spki.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-t_spki.Tpo -c -o asn1/libcrypto_la-t_spki.lo `test -f 'asn1/t_spki.c' || echo '$(srcdir)/'`asn1/t_spki.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-t_spki.Tpo asn1/$(DEPDIR)/libcrypto_la-t_spki.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/t_spki.c' object='asn1/libcrypto_la-t_spki.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-t_spki.lo `test -f 'asn1/t_spki.c' || echo '$(srcdir)/'`asn1/t_spki.c asn1/libcrypto_la-t_x509.lo: asn1/t_x509.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-t_x509.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-t_x509.Tpo -c -o asn1/libcrypto_la-t_x509.lo `test -f 'asn1/t_x509.c' || echo '$(srcdir)/'`asn1/t_x509.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-t_x509.Tpo asn1/$(DEPDIR)/libcrypto_la-t_x509.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/t_x509.c' object='asn1/libcrypto_la-t_x509.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-t_x509.lo `test -f 'asn1/t_x509.c' || echo '$(srcdir)/'`asn1/t_x509.c asn1/libcrypto_la-t_x509a.lo: asn1/t_x509a.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-t_x509a.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-t_x509a.Tpo -c -o asn1/libcrypto_la-t_x509a.lo `test -f 'asn1/t_x509a.c' || echo '$(srcdir)/'`asn1/t_x509a.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-t_x509a.Tpo asn1/$(DEPDIR)/libcrypto_la-t_x509a.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/t_x509a.c' object='asn1/libcrypto_la-t_x509a.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-t_x509a.lo `test -f 'asn1/t_x509a.c' || echo '$(srcdir)/'`asn1/t_x509a.c asn1/libcrypto_la-tasn_dec.lo: asn1/tasn_dec.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-tasn_dec.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-tasn_dec.Tpo -c -o asn1/libcrypto_la-tasn_dec.lo `test -f 'asn1/tasn_dec.c' || echo '$(srcdir)/'`asn1/tasn_dec.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-tasn_dec.Tpo asn1/$(DEPDIR)/libcrypto_la-tasn_dec.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/tasn_dec.c' object='asn1/libcrypto_la-tasn_dec.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-tasn_dec.lo `test -f 'asn1/tasn_dec.c' || echo '$(srcdir)/'`asn1/tasn_dec.c asn1/libcrypto_la-tasn_enc.lo: asn1/tasn_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-tasn_enc.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-tasn_enc.Tpo -c -o asn1/libcrypto_la-tasn_enc.lo `test -f 'asn1/tasn_enc.c' || echo '$(srcdir)/'`asn1/tasn_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-tasn_enc.Tpo asn1/$(DEPDIR)/libcrypto_la-tasn_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/tasn_enc.c' object='asn1/libcrypto_la-tasn_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-tasn_enc.lo `test -f 'asn1/tasn_enc.c' || echo '$(srcdir)/'`asn1/tasn_enc.c asn1/libcrypto_la-tasn_fre.lo: asn1/tasn_fre.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-tasn_fre.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-tasn_fre.Tpo -c -o asn1/libcrypto_la-tasn_fre.lo `test -f 'asn1/tasn_fre.c' || echo '$(srcdir)/'`asn1/tasn_fre.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-tasn_fre.Tpo asn1/$(DEPDIR)/libcrypto_la-tasn_fre.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/tasn_fre.c' object='asn1/libcrypto_la-tasn_fre.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-tasn_fre.lo `test -f 'asn1/tasn_fre.c' || echo '$(srcdir)/'`asn1/tasn_fre.c asn1/libcrypto_la-tasn_new.lo: asn1/tasn_new.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-tasn_new.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-tasn_new.Tpo -c -o asn1/libcrypto_la-tasn_new.lo `test -f 'asn1/tasn_new.c' || echo '$(srcdir)/'`asn1/tasn_new.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-tasn_new.Tpo asn1/$(DEPDIR)/libcrypto_la-tasn_new.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/tasn_new.c' object='asn1/libcrypto_la-tasn_new.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-tasn_new.lo `test -f 'asn1/tasn_new.c' || echo '$(srcdir)/'`asn1/tasn_new.c asn1/libcrypto_la-tasn_prn.lo: asn1/tasn_prn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-tasn_prn.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-tasn_prn.Tpo -c -o asn1/libcrypto_la-tasn_prn.lo `test -f 'asn1/tasn_prn.c' || echo '$(srcdir)/'`asn1/tasn_prn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-tasn_prn.Tpo asn1/$(DEPDIR)/libcrypto_la-tasn_prn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/tasn_prn.c' object='asn1/libcrypto_la-tasn_prn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-tasn_prn.lo `test -f 'asn1/tasn_prn.c' || echo '$(srcdir)/'`asn1/tasn_prn.c asn1/libcrypto_la-tasn_typ.lo: asn1/tasn_typ.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-tasn_typ.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-tasn_typ.Tpo -c -o asn1/libcrypto_la-tasn_typ.lo `test -f 'asn1/tasn_typ.c' || echo '$(srcdir)/'`asn1/tasn_typ.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-tasn_typ.Tpo asn1/$(DEPDIR)/libcrypto_la-tasn_typ.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/tasn_typ.c' object='asn1/libcrypto_la-tasn_typ.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-tasn_typ.lo `test -f 'asn1/tasn_typ.c' || echo '$(srcdir)/'`asn1/tasn_typ.c asn1/libcrypto_la-tasn_utl.lo: asn1/tasn_utl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-tasn_utl.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-tasn_utl.Tpo -c -o asn1/libcrypto_la-tasn_utl.lo `test -f 'asn1/tasn_utl.c' || echo '$(srcdir)/'`asn1/tasn_utl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-tasn_utl.Tpo asn1/$(DEPDIR)/libcrypto_la-tasn_utl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/tasn_utl.c' object='asn1/libcrypto_la-tasn_utl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-tasn_utl.lo `test -f 'asn1/tasn_utl.c' || echo '$(srcdir)/'`asn1/tasn_utl.c asn1/libcrypto_la-x_algor.lo: asn1/x_algor.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_algor.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_algor.Tpo -c -o asn1/libcrypto_la-x_algor.lo `test -f 'asn1/x_algor.c' || echo '$(srcdir)/'`asn1/x_algor.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_algor.Tpo asn1/$(DEPDIR)/libcrypto_la-x_algor.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_algor.c' object='asn1/libcrypto_la-x_algor.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_algor.lo `test -f 'asn1/x_algor.c' || echo '$(srcdir)/'`asn1/x_algor.c asn1/libcrypto_la-x_attrib.lo: asn1/x_attrib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_attrib.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_attrib.Tpo -c -o asn1/libcrypto_la-x_attrib.lo `test -f 'asn1/x_attrib.c' || echo '$(srcdir)/'`asn1/x_attrib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_attrib.Tpo asn1/$(DEPDIR)/libcrypto_la-x_attrib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_attrib.c' object='asn1/libcrypto_la-x_attrib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_attrib.lo `test -f 'asn1/x_attrib.c' || echo '$(srcdir)/'`asn1/x_attrib.c asn1/libcrypto_la-x_bignum.lo: asn1/x_bignum.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_bignum.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_bignum.Tpo -c -o asn1/libcrypto_la-x_bignum.lo `test -f 'asn1/x_bignum.c' || echo '$(srcdir)/'`asn1/x_bignum.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_bignum.Tpo asn1/$(DEPDIR)/libcrypto_la-x_bignum.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_bignum.c' object='asn1/libcrypto_la-x_bignum.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_bignum.lo `test -f 'asn1/x_bignum.c' || echo '$(srcdir)/'`asn1/x_bignum.c asn1/libcrypto_la-x_crl.lo: asn1/x_crl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_crl.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_crl.Tpo -c -o asn1/libcrypto_la-x_crl.lo `test -f 'asn1/x_crl.c' || echo '$(srcdir)/'`asn1/x_crl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_crl.Tpo asn1/$(DEPDIR)/libcrypto_la-x_crl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_crl.c' object='asn1/libcrypto_la-x_crl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_crl.lo `test -f 'asn1/x_crl.c' || echo '$(srcdir)/'`asn1/x_crl.c asn1/libcrypto_la-x_exten.lo: asn1/x_exten.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_exten.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_exten.Tpo -c -o asn1/libcrypto_la-x_exten.lo `test -f 'asn1/x_exten.c' || echo '$(srcdir)/'`asn1/x_exten.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_exten.Tpo asn1/$(DEPDIR)/libcrypto_la-x_exten.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_exten.c' object='asn1/libcrypto_la-x_exten.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_exten.lo `test -f 'asn1/x_exten.c' || echo '$(srcdir)/'`asn1/x_exten.c asn1/libcrypto_la-x_info.lo: asn1/x_info.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_info.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_info.Tpo -c -o asn1/libcrypto_la-x_info.lo `test -f 'asn1/x_info.c' || echo '$(srcdir)/'`asn1/x_info.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_info.Tpo asn1/$(DEPDIR)/libcrypto_la-x_info.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_info.c' object='asn1/libcrypto_la-x_info.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_info.lo `test -f 'asn1/x_info.c' || echo '$(srcdir)/'`asn1/x_info.c asn1/libcrypto_la-x_long.lo: asn1/x_long.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_long.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_long.Tpo -c -o asn1/libcrypto_la-x_long.lo `test -f 'asn1/x_long.c' || echo '$(srcdir)/'`asn1/x_long.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_long.Tpo asn1/$(DEPDIR)/libcrypto_la-x_long.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_long.c' object='asn1/libcrypto_la-x_long.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_long.lo `test -f 'asn1/x_long.c' || echo '$(srcdir)/'`asn1/x_long.c asn1/libcrypto_la-x_name.lo: asn1/x_name.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_name.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_name.Tpo -c -o asn1/libcrypto_la-x_name.lo `test -f 'asn1/x_name.c' || echo '$(srcdir)/'`asn1/x_name.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_name.Tpo asn1/$(DEPDIR)/libcrypto_la-x_name.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_name.c' object='asn1/libcrypto_la-x_name.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_name.lo `test -f 'asn1/x_name.c' || echo '$(srcdir)/'`asn1/x_name.c asn1/libcrypto_la-x_nx509.lo: asn1/x_nx509.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_nx509.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_nx509.Tpo -c -o asn1/libcrypto_la-x_nx509.lo `test -f 'asn1/x_nx509.c' || echo '$(srcdir)/'`asn1/x_nx509.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_nx509.Tpo asn1/$(DEPDIR)/libcrypto_la-x_nx509.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_nx509.c' object='asn1/libcrypto_la-x_nx509.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_nx509.lo `test -f 'asn1/x_nx509.c' || echo '$(srcdir)/'`asn1/x_nx509.c asn1/libcrypto_la-x_pkey.lo: asn1/x_pkey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_pkey.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_pkey.Tpo -c -o asn1/libcrypto_la-x_pkey.lo `test -f 'asn1/x_pkey.c' || echo '$(srcdir)/'`asn1/x_pkey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_pkey.Tpo asn1/$(DEPDIR)/libcrypto_la-x_pkey.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_pkey.c' object='asn1/libcrypto_la-x_pkey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_pkey.lo `test -f 'asn1/x_pkey.c' || echo '$(srcdir)/'`asn1/x_pkey.c asn1/libcrypto_la-x_pubkey.lo: asn1/x_pubkey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_pubkey.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_pubkey.Tpo -c -o asn1/libcrypto_la-x_pubkey.lo `test -f 'asn1/x_pubkey.c' || echo '$(srcdir)/'`asn1/x_pubkey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_pubkey.Tpo asn1/$(DEPDIR)/libcrypto_la-x_pubkey.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_pubkey.c' object='asn1/libcrypto_la-x_pubkey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_pubkey.lo `test -f 'asn1/x_pubkey.c' || echo '$(srcdir)/'`asn1/x_pubkey.c asn1/libcrypto_la-x_req.lo: asn1/x_req.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_req.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_req.Tpo -c -o asn1/libcrypto_la-x_req.lo `test -f 'asn1/x_req.c' || echo '$(srcdir)/'`asn1/x_req.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_req.Tpo asn1/$(DEPDIR)/libcrypto_la-x_req.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_req.c' object='asn1/libcrypto_la-x_req.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_req.lo `test -f 'asn1/x_req.c' || echo '$(srcdir)/'`asn1/x_req.c asn1/libcrypto_la-x_sig.lo: asn1/x_sig.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_sig.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_sig.Tpo -c -o asn1/libcrypto_la-x_sig.lo `test -f 'asn1/x_sig.c' || echo '$(srcdir)/'`asn1/x_sig.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_sig.Tpo asn1/$(DEPDIR)/libcrypto_la-x_sig.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_sig.c' object='asn1/libcrypto_la-x_sig.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_sig.lo `test -f 'asn1/x_sig.c' || echo '$(srcdir)/'`asn1/x_sig.c asn1/libcrypto_la-x_spki.lo: asn1/x_spki.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_spki.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_spki.Tpo -c -o asn1/libcrypto_la-x_spki.lo `test -f 'asn1/x_spki.c' || echo '$(srcdir)/'`asn1/x_spki.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_spki.Tpo asn1/$(DEPDIR)/libcrypto_la-x_spki.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_spki.c' object='asn1/libcrypto_la-x_spki.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_spki.lo `test -f 'asn1/x_spki.c' || echo '$(srcdir)/'`asn1/x_spki.c asn1/libcrypto_la-x_val.lo: asn1/x_val.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_val.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_val.Tpo -c -o asn1/libcrypto_la-x_val.lo `test -f 'asn1/x_val.c' || echo '$(srcdir)/'`asn1/x_val.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_val.Tpo asn1/$(DEPDIR)/libcrypto_la-x_val.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_val.c' object='asn1/libcrypto_la-x_val.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_val.lo `test -f 'asn1/x_val.c' || echo '$(srcdir)/'`asn1/x_val.c asn1/libcrypto_la-x_x509.lo: asn1/x_x509.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_x509.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_x509.Tpo -c -o asn1/libcrypto_la-x_x509.lo `test -f 'asn1/x_x509.c' || echo '$(srcdir)/'`asn1/x_x509.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_x509.Tpo asn1/$(DEPDIR)/libcrypto_la-x_x509.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_x509.c' object='asn1/libcrypto_la-x_x509.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_x509.lo `test -f 'asn1/x_x509.c' || echo '$(srcdir)/'`asn1/x_x509.c asn1/libcrypto_la-x_x509a.lo: asn1/x_x509a.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-x_x509a.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-x_x509a.Tpo -c -o asn1/libcrypto_la-x_x509a.lo `test -f 'asn1/x_x509a.c' || echo '$(srcdir)/'`asn1/x_x509a.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-x_x509a.Tpo asn1/$(DEPDIR)/libcrypto_la-x_x509a.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/x_x509a.c' object='asn1/libcrypto_la-x_x509a.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-x_x509a.lo `test -f 'asn1/x_x509a.c' || echo '$(srcdir)/'`asn1/x_x509a.c bf/libcrypto_la-bf_cfb64.lo: bf/bf_cfb64.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bf/libcrypto_la-bf_cfb64.lo -MD -MP -MF bf/$(DEPDIR)/libcrypto_la-bf_cfb64.Tpo -c -o bf/libcrypto_la-bf_cfb64.lo `test -f 'bf/bf_cfb64.c' || echo '$(srcdir)/'`bf/bf_cfb64.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bf/$(DEPDIR)/libcrypto_la-bf_cfb64.Tpo bf/$(DEPDIR)/libcrypto_la-bf_cfb64.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bf/bf_cfb64.c' object='bf/libcrypto_la-bf_cfb64.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bf/libcrypto_la-bf_cfb64.lo `test -f 'bf/bf_cfb64.c' || echo '$(srcdir)/'`bf/bf_cfb64.c bf/libcrypto_la-bf_ecb.lo: bf/bf_ecb.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bf/libcrypto_la-bf_ecb.lo -MD -MP -MF bf/$(DEPDIR)/libcrypto_la-bf_ecb.Tpo -c -o bf/libcrypto_la-bf_ecb.lo `test -f 'bf/bf_ecb.c' || echo '$(srcdir)/'`bf/bf_ecb.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bf/$(DEPDIR)/libcrypto_la-bf_ecb.Tpo bf/$(DEPDIR)/libcrypto_la-bf_ecb.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bf/bf_ecb.c' object='bf/libcrypto_la-bf_ecb.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bf/libcrypto_la-bf_ecb.lo `test -f 'bf/bf_ecb.c' || echo '$(srcdir)/'`bf/bf_ecb.c bf/libcrypto_la-bf_enc.lo: bf/bf_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bf/libcrypto_la-bf_enc.lo -MD -MP -MF bf/$(DEPDIR)/libcrypto_la-bf_enc.Tpo -c -o bf/libcrypto_la-bf_enc.lo `test -f 'bf/bf_enc.c' || echo '$(srcdir)/'`bf/bf_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bf/$(DEPDIR)/libcrypto_la-bf_enc.Tpo bf/$(DEPDIR)/libcrypto_la-bf_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bf/bf_enc.c' object='bf/libcrypto_la-bf_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bf/libcrypto_la-bf_enc.lo `test -f 'bf/bf_enc.c' || echo '$(srcdir)/'`bf/bf_enc.c bf/libcrypto_la-bf_ofb64.lo: bf/bf_ofb64.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bf/libcrypto_la-bf_ofb64.lo -MD -MP -MF bf/$(DEPDIR)/libcrypto_la-bf_ofb64.Tpo -c -o bf/libcrypto_la-bf_ofb64.lo `test -f 'bf/bf_ofb64.c' || echo '$(srcdir)/'`bf/bf_ofb64.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bf/$(DEPDIR)/libcrypto_la-bf_ofb64.Tpo bf/$(DEPDIR)/libcrypto_la-bf_ofb64.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bf/bf_ofb64.c' object='bf/libcrypto_la-bf_ofb64.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bf/libcrypto_la-bf_ofb64.lo `test -f 'bf/bf_ofb64.c' || echo '$(srcdir)/'`bf/bf_ofb64.c bf/libcrypto_la-bf_skey.lo: bf/bf_skey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bf/libcrypto_la-bf_skey.lo -MD -MP -MF bf/$(DEPDIR)/libcrypto_la-bf_skey.Tpo -c -o bf/libcrypto_la-bf_skey.lo `test -f 'bf/bf_skey.c' || echo '$(srcdir)/'`bf/bf_skey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bf/$(DEPDIR)/libcrypto_la-bf_skey.Tpo bf/$(DEPDIR)/libcrypto_la-bf_skey.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bf/bf_skey.c' object='bf/libcrypto_la-bf_skey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bf/libcrypto_la-bf_skey.lo `test -f 'bf/bf_skey.c' || echo '$(srcdir)/'`bf/bf_skey.c bio/libcrypto_la-b_dump.lo: bio/b_dump.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-b_dump.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-b_dump.Tpo -c -o bio/libcrypto_la-b_dump.lo `test -f 'bio/b_dump.c' || echo '$(srcdir)/'`bio/b_dump.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-b_dump.Tpo bio/$(DEPDIR)/libcrypto_la-b_dump.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/b_dump.c' object='bio/libcrypto_la-b_dump.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-b_dump.lo `test -f 'bio/b_dump.c' || echo '$(srcdir)/'`bio/b_dump.c bio/libcrypto_la-b_print.lo: bio/b_print.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-b_print.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-b_print.Tpo -c -o bio/libcrypto_la-b_print.lo `test -f 'bio/b_print.c' || echo '$(srcdir)/'`bio/b_print.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-b_print.Tpo bio/$(DEPDIR)/libcrypto_la-b_print.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/b_print.c' object='bio/libcrypto_la-b_print.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-b_print.lo `test -f 'bio/b_print.c' || echo '$(srcdir)/'`bio/b_print.c bio/libcrypto_la-b_sock.lo: bio/b_sock.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-b_sock.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-b_sock.Tpo -c -o bio/libcrypto_la-b_sock.lo `test -f 'bio/b_sock.c' || echo '$(srcdir)/'`bio/b_sock.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-b_sock.Tpo bio/$(DEPDIR)/libcrypto_la-b_sock.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/b_sock.c' object='bio/libcrypto_la-b_sock.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-b_sock.lo `test -f 'bio/b_sock.c' || echo '$(srcdir)/'`bio/b_sock.c bio/libcrypto_la-bf_buff.lo: bio/bf_buff.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-bf_buff.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-bf_buff.Tpo -c -o bio/libcrypto_la-bf_buff.lo `test -f 'bio/bf_buff.c' || echo '$(srcdir)/'`bio/bf_buff.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-bf_buff.Tpo bio/$(DEPDIR)/libcrypto_la-bf_buff.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/bf_buff.c' object='bio/libcrypto_la-bf_buff.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-bf_buff.lo `test -f 'bio/bf_buff.c' || echo '$(srcdir)/'`bio/bf_buff.c bio/libcrypto_la-bf_nbio.lo: bio/bf_nbio.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-bf_nbio.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-bf_nbio.Tpo -c -o bio/libcrypto_la-bf_nbio.lo `test -f 'bio/bf_nbio.c' || echo '$(srcdir)/'`bio/bf_nbio.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-bf_nbio.Tpo bio/$(DEPDIR)/libcrypto_la-bf_nbio.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/bf_nbio.c' object='bio/libcrypto_la-bf_nbio.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-bf_nbio.lo `test -f 'bio/bf_nbio.c' || echo '$(srcdir)/'`bio/bf_nbio.c bio/libcrypto_la-bf_null.lo: bio/bf_null.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-bf_null.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-bf_null.Tpo -c -o bio/libcrypto_la-bf_null.lo `test -f 'bio/bf_null.c' || echo '$(srcdir)/'`bio/bf_null.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-bf_null.Tpo bio/$(DEPDIR)/libcrypto_la-bf_null.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/bf_null.c' object='bio/libcrypto_la-bf_null.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-bf_null.lo `test -f 'bio/bf_null.c' || echo '$(srcdir)/'`bio/bf_null.c bio/libcrypto_la-bio_cb.lo: bio/bio_cb.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-bio_cb.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-bio_cb.Tpo -c -o bio/libcrypto_la-bio_cb.lo `test -f 'bio/bio_cb.c' || echo '$(srcdir)/'`bio/bio_cb.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-bio_cb.Tpo bio/$(DEPDIR)/libcrypto_la-bio_cb.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/bio_cb.c' object='bio/libcrypto_la-bio_cb.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-bio_cb.lo `test -f 'bio/bio_cb.c' || echo '$(srcdir)/'`bio/bio_cb.c bio/libcrypto_la-bio_err.lo: bio/bio_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-bio_err.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-bio_err.Tpo -c -o bio/libcrypto_la-bio_err.lo `test -f 'bio/bio_err.c' || echo '$(srcdir)/'`bio/bio_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-bio_err.Tpo bio/$(DEPDIR)/libcrypto_la-bio_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/bio_err.c' object='bio/libcrypto_la-bio_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-bio_err.lo `test -f 'bio/bio_err.c' || echo '$(srcdir)/'`bio/bio_err.c bio/libcrypto_la-bio_lib.lo: bio/bio_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-bio_lib.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-bio_lib.Tpo -c -o bio/libcrypto_la-bio_lib.lo `test -f 'bio/bio_lib.c' || echo '$(srcdir)/'`bio/bio_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-bio_lib.Tpo bio/$(DEPDIR)/libcrypto_la-bio_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/bio_lib.c' object='bio/libcrypto_la-bio_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-bio_lib.lo `test -f 'bio/bio_lib.c' || echo '$(srcdir)/'`bio/bio_lib.c bio/libcrypto_la-bss_acpt.lo: bio/bss_acpt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-bss_acpt.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-bss_acpt.Tpo -c -o bio/libcrypto_la-bss_acpt.lo `test -f 'bio/bss_acpt.c' || echo '$(srcdir)/'`bio/bss_acpt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-bss_acpt.Tpo bio/$(DEPDIR)/libcrypto_la-bss_acpt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/bss_acpt.c' object='bio/libcrypto_la-bss_acpt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-bss_acpt.lo `test -f 'bio/bss_acpt.c' || echo '$(srcdir)/'`bio/bss_acpt.c bio/libcrypto_la-bss_bio.lo: bio/bss_bio.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-bss_bio.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-bss_bio.Tpo -c -o bio/libcrypto_la-bss_bio.lo `test -f 'bio/bss_bio.c' || echo '$(srcdir)/'`bio/bss_bio.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-bss_bio.Tpo bio/$(DEPDIR)/libcrypto_la-bss_bio.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/bss_bio.c' object='bio/libcrypto_la-bss_bio.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-bss_bio.lo `test -f 'bio/bss_bio.c' || echo '$(srcdir)/'`bio/bss_bio.c bio/libcrypto_la-bss_conn.lo: bio/bss_conn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-bss_conn.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-bss_conn.Tpo -c -o bio/libcrypto_la-bss_conn.lo `test -f 'bio/bss_conn.c' || echo '$(srcdir)/'`bio/bss_conn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-bss_conn.Tpo bio/$(DEPDIR)/libcrypto_la-bss_conn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/bss_conn.c' object='bio/libcrypto_la-bss_conn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-bss_conn.lo `test -f 'bio/bss_conn.c' || echo '$(srcdir)/'`bio/bss_conn.c bio/libcrypto_la-bss_dgram.lo: bio/bss_dgram.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-bss_dgram.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-bss_dgram.Tpo -c -o bio/libcrypto_la-bss_dgram.lo `test -f 'bio/bss_dgram.c' || echo '$(srcdir)/'`bio/bss_dgram.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-bss_dgram.Tpo bio/$(DEPDIR)/libcrypto_la-bss_dgram.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/bss_dgram.c' object='bio/libcrypto_la-bss_dgram.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-bss_dgram.lo `test -f 'bio/bss_dgram.c' || echo '$(srcdir)/'`bio/bss_dgram.c bio/libcrypto_la-bss_fd.lo: bio/bss_fd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-bss_fd.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-bss_fd.Tpo -c -o bio/libcrypto_la-bss_fd.lo `test -f 'bio/bss_fd.c' || echo '$(srcdir)/'`bio/bss_fd.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-bss_fd.Tpo bio/$(DEPDIR)/libcrypto_la-bss_fd.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/bss_fd.c' object='bio/libcrypto_la-bss_fd.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-bss_fd.lo `test -f 'bio/bss_fd.c' || echo '$(srcdir)/'`bio/bss_fd.c bio/libcrypto_la-bss_file.lo: bio/bss_file.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-bss_file.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-bss_file.Tpo -c -o bio/libcrypto_la-bss_file.lo `test -f 'bio/bss_file.c' || echo '$(srcdir)/'`bio/bss_file.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-bss_file.Tpo bio/$(DEPDIR)/libcrypto_la-bss_file.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/bss_file.c' object='bio/libcrypto_la-bss_file.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-bss_file.lo `test -f 'bio/bss_file.c' || echo '$(srcdir)/'`bio/bss_file.c bio/libcrypto_la-bss_log.lo: bio/bss_log.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-bss_log.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-bss_log.Tpo -c -o bio/libcrypto_la-bss_log.lo `test -f 'bio/bss_log.c' || echo '$(srcdir)/'`bio/bss_log.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-bss_log.Tpo bio/$(DEPDIR)/libcrypto_la-bss_log.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/bss_log.c' object='bio/libcrypto_la-bss_log.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-bss_log.lo `test -f 'bio/bss_log.c' || echo '$(srcdir)/'`bio/bss_log.c bio/libcrypto_la-bss_mem.lo: bio/bss_mem.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-bss_mem.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-bss_mem.Tpo -c -o bio/libcrypto_la-bss_mem.lo `test -f 'bio/bss_mem.c' || echo '$(srcdir)/'`bio/bss_mem.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-bss_mem.Tpo bio/$(DEPDIR)/libcrypto_la-bss_mem.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/bss_mem.c' object='bio/libcrypto_la-bss_mem.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-bss_mem.lo `test -f 'bio/bss_mem.c' || echo '$(srcdir)/'`bio/bss_mem.c bio/libcrypto_la-bss_null.lo: bio/bss_null.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-bss_null.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-bss_null.Tpo -c -o bio/libcrypto_la-bss_null.lo `test -f 'bio/bss_null.c' || echo '$(srcdir)/'`bio/bss_null.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-bss_null.Tpo bio/$(DEPDIR)/libcrypto_la-bss_null.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/bss_null.c' object='bio/libcrypto_la-bss_null.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-bss_null.lo `test -f 'bio/bss_null.c' || echo '$(srcdir)/'`bio/bss_null.c bio/libcrypto_la-bss_sock.lo: bio/bss_sock.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bio/libcrypto_la-bss_sock.lo -MD -MP -MF bio/$(DEPDIR)/libcrypto_la-bss_sock.Tpo -c -o bio/libcrypto_la-bss_sock.lo `test -f 'bio/bss_sock.c' || echo '$(srcdir)/'`bio/bss_sock.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bio/$(DEPDIR)/libcrypto_la-bss_sock.Tpo bio/$(DEPDIR)/libcrypto_la-bss_sock.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio/bss_sock.c' object='bio/libcrypto_la-bss_sock.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bio/libcrypto_la-bss_sock.lo `test -f 'bio/bss_sock.c' || echo '$(srcdir)/'`bio/bss_sock.c bn/libcrypto_la-bn_add.lo: bn/bn_add.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_add.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_add.Tpo -c -o bn/libcrypto_la-bn_add.lo `test -f 'bn/bn_add.c' || echo '$(srcdir)/'`bn/bn_add.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_add.Tpo bn/$(DEPDIR)/libcrypto_la-bn_add.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_add.c' object='bn/libcrypto_la-bn_add.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_add.lo `test -f 'bn/bn_add.c' || echo '$(srcdir)/'`bn/bn_add.c bn/libcrypto_la-bn_asm.lo: bn/bn_asm.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_asm.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_asm.Tpo -c -o bn/libcrypto_la-bn_asm.lo `test -f 'bn/bn_asm.c' || echo '$(srcdir)/'`bn/bn_asm.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_asm.Tpo bn/$(DEPDIR)/libcrypto_la-bn_asm.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_asm.c' object='bn/libcrypto_la-bn_asm.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_asm.lo `test -f 'bn/bn_asm.c' || echo '$(srcdir)/'`bn/bn_asm.c bn/libcrypto_la-bn_blind.lo: bn/bn_blind.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_blind.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_blind.Tpo -c -o bn/libcrypto_la-bn_blind.lo `test -f 'bn/bn_blind.c' || echo '$(srcdir)/'`bn/bn_blind.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_blind.Tpo bn/$(DEPDIR)/libcrypto_la-bn_blind.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_blind.c' object='bn/libcrypto_la-bn_blind.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_blind.lo `test -f 'bn/bn_blind.c' || echo '$(srcdir)/'`bn/bn_blind.c bn/libcrypto_la-bn_const.lo: bn/bn_const.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_const.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_const.Tpo -c -o bn/libcrypto_la-bn_const.lo `test -f 'bn/bn_const.c' || echo '$(srcdir)/'`bn/bn_const.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_const.Tpo bn/$(DEPDIR)/libcrypto_la-bn_const.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_const.c' object='bn/libcrypto_la-bn_const.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_const.lo `test -f 'bn/bn_const.c' || echo '$(srcdir)/'`bn/bn_const.c bn/libcrypto_la-bn_ctx.lo: bn/bn_ctx.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_ctx.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_ctx.Tpo -c -o bn/libcrypto_la-bn_ctx.lo `test -f 'bn/bn_ctx.c' || echo '$(srcdir)/'`bn/bn_ctx.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_ctx.Tpo bn/$(DEPDIR)/libcrypto_la-bn_ctx.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_ctx.c' object='bn/libcrypto_la-bn_ctx.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_ctx.lo `test -f 'bn/bn_ctx.c' || echo '$(srcdir)/'`bn/bn_ctx.c bn/libcrypto_la-bn_depr.lo: bn/bn_depr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_depr.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_depr.Tpo -c -o bn/libcrypto_la-bn_depr.lo `test -f 'bn/bn_depr.c' || echo '$(srcdir)/'`bn/bn_depr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_depr.Tpo bn/$(DEPDIR)/libcrypto_la-bn_depr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_depr.c' object='bn/libcrypto_la-bn_depr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_depr.lo `test -f 'bn/bn_depr.c' || echo '$(srcdir)/'`bn/bn_depr.c bn/libcrypto_la-bn_div.lo: bn/bn_div.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_div.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_div.Tpo -c -o bn/libcrypto_la-bn_div.lo `test -f 'bn/bn_div.c' || echo '$(srcdir)/'`bn/bn_div.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_div.Tpo bn/$(DEPDIR)/libcrypto_la-bn_div.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_div.c' object='bn/libcrypto_la-bn_div.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_div.lo `test -f 'bn/bn_div.c' || echo '$(srcdir)/'`bn/bn_div.c bn/libcrypto_la-bn_err.lo: bn/bn_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_err.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_err.Tpo -c -o bn/libcrypto_la-bn_err.lo `test -f 'bn/bn_err.c' || echo '$(srcdir)/'`bn/bn_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_err.Tpo bn/$(DEPDIR)/libcrypto_la-bn_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_err.c' object='bn/libcrypto_la-bn_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_err.lo `test -f 'bn/bn_err.c' || echo '$(srcdir)/'`bn/bn_err.c bn/libcrypto_la-bn_exp.lo: bn/bn_exp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_exp.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_exp.Tpo -c -o bn/libcrypto_la-bn_exp.lo `test -f 'bn/bn_exp.c' || echo '$(srcdir)/'`bn/bn_exp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_exp.Tpo bn/$(DEPDIR)/libcrypto_la-bn_exp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_exp.c' object='bn/libcrypto_la-bn_exp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_exp.lo `test -f 'bn/bn_exp.c' || echo '$(srcdir)/'`bn/bn_exp.c bn/libcrypto_la-bn_exp2.lo: bn/bn_exp2.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_exp2.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_exp2.Tpo -c -o bn/libcrypto_la-bn_exp2.lo `test -f 'bn/bn_exp2.c' || echo '$(srcdir)/'`bn/bn_exp2.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_exp2.Tpo bn/$(DEPDIR)/libcrypto_la-bn_exp2.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_exp2.c' object='bn/libcrypto_la-bn_exp2.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_exp2.lo `test -f 'bn/bn_exp2.c' || echo '$(srcdir)/'`bn/bn_exp2.c bn/libcrypto_la-bn_gcd.lo: bn/bn_gcd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_gcd.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_gcd.Tpo -c -o bn/libcrypto_la-bn_gcd.lo `test -f 'bn/bn_gcd.c' || echo '$(srcdir)/'`bn/bn_gcd.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_gcd.Tpo bn/$(DEPDIR)/libcrypto_la-bn_gcd.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_gcd.c' object='bn/libcrypto_la-bn_gcd.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_gcd.lo `test -f 'bn/bn_gcd.c' || echo '$(srcdir)/'`bn/bn_gcd.c bn/libcrypto_la-bn_gf2m.lo: bn/bn_gf2m.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_gf2m.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_gf2m.Tpo -c -o bn/libcrypto_la-bn_gf2m.lo `test -f 'bn/bn_gf2m.c' || echo '$(srcdir)/'`bn/bn_gf2m.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_gf2m.Tpo bn/$(DEPDIR)/libcrypto_la-bn_gf2m.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_gf2m.c' object='bn/libcrypto_la-bn_gf2m.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_gf2m.lo `test -f 'bn/bn_gf2m.c' || echo '$(srcdir)/'`bn/bn_gf2m.c bn/libcrypto_la-bn_kron.lo: bn/bn_kron.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_kron.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_kron.Tpo -c -o bn/libcrypto_la-bn_kron.lo `test -f 'bn/bn_kron.c' || echo '$(srcdir)/'`bn/bn_kron.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_kron.Tpo bn/$(DEPDIR)/libcrypto_la-bn_kron.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_kron.c' object='bn/libcrypto_la-bn_kron.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_kron.lo `test -f 'bn/bn_kron.c' || echo '$(srcdir)/'`bn/bn_kron.c bn/libcrypto_la-bn_lib.lo: bn/bn_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_lib.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_lib.Tpo -c -o bn/libcrypto_la-bn_lib.lo `test -f 'bn/bn_lib.c' || echo '$(srcdir)/'`bn/bn_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_lib.Tpo bn/$(DEPDIR)/libcrypto_la-bn_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_lib.c' object='bn/libcrypto_la-bn_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_lib.lo `test -f 'bn/bn_lib.c' || echo '$(srcdir)/'`bn/bn_lib.c bn/libcrypto_la-bn_mod.lo: bn/bn_mod.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_mod.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_mod.Tpo -c -o bn/libcrypto_la-bn_mod.lo `test -f 'bn/bn_mod.c' || echo '$(srcdir)/'`bn/bn_mod.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_mod.Tpo bn/$(DEPDIR)/libcrypto_la-bn_mod.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_mod.c' object='bn/libcrypto_la-bn_mod.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_mod.lo `test -f 'bn/bn_mod.c' || echo '$(srcdir)/'`bn/bn_mod.c bn/libcrypto_la-bn_mont.lo: bn/bn_mont.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_mont.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_mont.Tpo -c -o bn/libcrypto_la-bn_mont.lo `test -f 'bn/bn_mont.c' || echo '$(srcdir)/'`bn/bn_mont.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_mont.Tpo bn/$(DEPDIR)/libcrypto_la-bn_mont.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_mont.c' object='bn/libcrypto_la-bn_mont.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_mont.lo `test -f 'bn/bn_mont.c' || echo '$(srcdir)/'`bn/bn_mont.c bn/libcrypto_la-bn_mpi.lo: bn/bn_mpi.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_mpi.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_mpi.Tpo -c -o bn/libcrypto_la-bn_mpi.lo `test -f 'bn/bn_mpi.c' || echo '$(srcdir)/'`bn/bn_mpi.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_mpi.Tpo bn/$(DEPDIR)/libcrypto_la-bn_mpi.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_mpi.c' object='bn/libcrypto_la-bn_mpi.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_mpi.lo `test -f 'bn/bn_mpi.c' || echo '$(srcdir)/'`bn/bn_mpi.c bn/libcrypto_la-bn_mul.lo: bn/bn_mul.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_mul.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_mul.Tpo -c -o bn/libcrypto_la-bn_mul.lo `test -f 'bn/bn_mul.c' || echo '$(srcdir)/'`bn/bn_mul.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_mul.Tpo bn/$(DEPDIR)/libcrypto_la-bn_mul.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_mul.c' object='bn/libcrypto_la-bn_mul.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_mul.lo `test -f 'bn/bn_mul.c' || echo '$(srcdir)/'`bn/bn_mul.c bn/libcrypto_la-bn_nist.lo: bn/bn_nist.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_nist.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_nist.Tpo -c -o bn/libcrypto_la-bn_nist.lo `test -f 'bn/bn_nist.c' || echo '$(srcdir)/'`bn/bn_nist.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_nist.Tpo bn/$(DEPDIR)/libcrypto_la-bn_nist.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_nist.c' object='bn/libcrypto_la-bn_nist.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_nist.lo `test -f 'bn/bn_nist.c' || echo '$(srcdir)/'`bn/bn_nist.c bn/libcrypto_la-bn_prime.lo: bn/bn_prime.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_prime.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_prime.Tpo -c -o bn/libcrypto_la-bn_prime.lo `test -f 'bn/bn_prime.c' || echo '$(srcdir)/'`bn/bn_prime.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_prime.Tpo bn/$(DEPDIR)/libcrypto_la-bn_prime.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_prime.c' object='bn/libcrypto_la-bn_prime.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_prime.lo `test -f 'bn/bn_prime.c' || echo '$(srcdir)/'`bn/bn_prime.c bn/libcrypto_la-bn_print.lo: bn/bn_print.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_print.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_print.Tpo -c -o bn/libcrypto_la-bn_print.lo `test -f 'bn/bn_print.c' || echo '$(srcdir)/'`bn/bn_print.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_print.Tpo bn/$(DEPDIR)/libcrypto_la-bn_print.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_print.c' object='bn/libcrypto_la-bn_print.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_print.lo `test -f 'bn/bn_print.c' || echo '$(srcdir)/'`bn/bn_print.c bn/libcrypto_la-bn_rand.lo: bn/bn_rand.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_rand.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_rand.Tpo -c -o bn/libcrypto_la-bn_rand.lo `test -f 'bn/bn_rand.c' || echo '$(srcdir)/'`bn/bn_rand.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_rand.Tpo bn/$(DEPDIR)/libcrypto_la-bn_rand.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_rand.c' object='bn/libcrypto_la-bn_rand.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_rand.lo `test -f 'bn/bn_rand.c' || echo '$(srcdir)/'`bn/bn_rand.c bn/libcrypto_la-bn_recp.lo: bn/bn_recp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_recp.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_recp.Tpo -c -o bn/libcrypto_la-bn_recp.lo `test -f 'bn/bn_recp.c' || echo '$(srcdir)/'`bn/bn_recp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_recp.Tpo bn/$(DEPDIR)/libcrypto_la-bn_recp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_recp.c' object='bn/libcrypto_la-bn_recp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_recp.lo `test -f 'bn/bn_recp.c' || echo '$(srcdir)/'`bn/bn_recp.c bn/libcrypto_la-bn_shift.lo: bn/bn_shift.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_shift.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_shift.Tpo -c -o bn/libcrypto_la-bn_shift.lo `test -f 'bn/bn_shift.c' || echo '$(srcdir)/'`bn/bn_shift.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_shift.Tpo bn/$(DEPDIR)/libcrypto_la-bn_shift.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_shift.c' object='bn/libcrypto_la-bn_shift.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_shift.lo `test -f 'bn/bn_shift.c' || echo '$(srcdir)/'`bn/bn_shift.c bn/libcrypto_la-bn_sqr.lo: bn/bn_sqr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_sqr.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_sqr.Tpo -c -o bn/libcrypto_la-bn_sqr.lo `test -f 'bn/bn_sqr.c' || echo '$(srcdir)/'`bn/bn_sqr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_sqr.Tpo bn/$(DEPDIR)/libcrypto_la-bn_sqr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_sqr.c' object='bn/libcrypto_la-bn_sqr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_sqr.lo `test -f 'bn/bn_sqr.c' || echo '$(srcdir)/'`bn/bn_sqr.c bn/libcrypto_la-bn_sqrt.lo: bn/bn_sqrt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_sqrt.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_sqrt.Tpo -c -o bn/libcrypto_la-bn_sqrt.lo `test -f 'bn/bn_sqrt.c' || echo '$(srcdir)/'`bn/bn_sqrt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_sqrt.Tpo bn/$(DEPDIR)/libcrypto_la-bn_sqrt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_sqrt.c' object='bn/libcrypto_la-bn_sqrt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_sqrt.lo `test -f 'bn/bn_sqrt.c' || echo '$(srcdir)/'`bn/bn_sqrt.c bn/libcrypto_la-bn_word.lo: bn/bn_word.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_word.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_word.Tpo -c -o bn/libcrypto_la-bn_word.lo `test -f 'bn/bn_word.c' || echo '$(srcdir)/'`bn/bn_word.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_word.Tpo bn/$(DEPDIR)/libcrypto_la-bn_word.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_word.c' object='bn/libcrypto_la-bn_word.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_word.lo `test -f 'bn/bn_word.c' || echo '$(srcdir)/'`bn/bn_word.c bn/libcrypto_la-bn_x931p.lo: bn/bn_x931p.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_x931p.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_x931p.Tpo -c -o bn/libcrypto_la-bn_x931p.lo `test -f 'bn/bn_x931p.c' || echo '$(srcdir)/'`bn/bn_x931p.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_x931p.Tpo bn/$(DEPDIR)/libcrypto_la-bn_x931p.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_x931p.c' object='bn/libcrypto_la-bn_x931p.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_x931p.lo `test -f 'bn/bn_x931p.c' || echo '$(srcdir)/'`bn/bn_x931p.c buffer/libcrypto_la-buf_err.lo: buffer/buf_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT buffer/libcrypto_la-buf_err.lo -MD -MP -MF buffer/$(DEPDIR)/libcrypto_la-buf_err.Tpo -c -o buffer/libcrypto_la-buf_err.lo `test -f 'buffer/buf_err.c' || echo '$(srcdir)/'`buffer/buf_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) buffer/$(DEPDIR)/libcrypto_la-buf_err.Tpo buffer/$(DEPDIR)/libcrypto_la-buf_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='buffer/buf_err.c' object='buffer/libcrypto_la-buf_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o buffer/libcrypto_la-buf_err.lo `test -f 'buffer/buf_err.c' || echo '$(srcdir)/'`buffer/buf_err.c buffer/libcrypto_la-buf_str.lo: buffer/buf_str.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT buffer/libcrypto_la-buf_str.lo -MD -MP -MF buffer/$(DEPDIR)/libcrypto_la-buf_str.Tpo -c -o buffer/libcrypto_la-buf_str.lo `test -f 'buffer/buf_str.c' || echo '$(srcdir)/'`buffer/buf_str.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) buffer/$(DEPDIR)/libcrypto_la-buf_str.Tpo buffer/$(DEPDIR)/libcrypto_la-buf_str.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='buffer/buf_str.c' object='buffer/libcrypto_la-buf_str.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o buffer/libcrypto_la-buf_str.lo `test -f 'buffer/buf_str.c' || echo '$(srcdir)/'`buffer/buf_str.c buffer/libcrypto_la-buffer.lo: buffer/buffer.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT buffer/libcrypto_la-buffer.lo -MD -MP -MF buffer/$(DEPDIR)/libcrypto_la-buffer.Tpo -c -o buffer/libcrypto_la-buffer.lo `test -f 'buffer/buffer.c' || echo '$(srcdir)/'`buffer/buffer.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) buffer/$(DEPDIR)/libcrypto_la-buffer.Tpo buffer/$(DEPDIR)/libcrypto_la-buffer.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='buffer/buffer.c' object='buffer/libcrypto_la-buffer.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o buffer/libcrypto_la-buffer.lo `test -f 'buffer/buffer.c' || echo '$(srcdir)/'`buffer/buffer.c cast/libcrypto_la-c_cfb64.lo: cast/c_cfb64.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT cast/libcrypto_la-c_cfb64.lo -MD -MP -MF cast/$(DEPDIR)/libcrypto_la-c_cfb64.Tpo -c -o cast/libcrypto_la-c_cfb64.lo `test -f 'cast/c_cfb64.c' || echo '$(srcdir)/'`cast/c_cfb64.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) cast/$(DEPDIR)/libcrypto_la-c_cfb64.Tpo cast/$(DEPDIR)/libcrypto_la-c_cfb64.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cast/c_cfb64.c' object='cast/libcrypto_la-c_cfb64.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o cast/libcrypto_la-c_cfb64.lo `test -f 'cast/c_cfb64.c' || echo '$(srcdir)/'`cast/c_cfb64.c cast/libcrypto_la-c_ecb.lo: cast/c_ecb.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT cast/libcrypto_la-c_ecb.lo -MD -MP -MF cast/$(DEPDIR)/libcrypto_la-c_ecb.Tpo -c -o cast/libcrypto_la-c_ecb.lo `test -f 'cast/c_ecb.c' || echo '$(srcdir)/'`cast/c_ecb.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) cast/$(DEPDIR)/libcrypto_la-c_ecb.Tpo cast/$(DEPDIR)/libcrypto_la-c_ecb.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cast/c_ecb.c' object='cast/libcrypto_la-c_ecb.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o cast/libcrypto_la-c_ecb.lo `test -f 'cast/c_ecb.c' || echo '$(srcdir)/'`cast/c_ecb.c cast/libcrypto_la-c_enc.lo: cast/c_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT cast/libcrypto_la-c_enc.lo -MD -MP -MF cast/$(DEPDIR)/libcrypto_la-c_enc.Tpo -c -o cast/libcrypto_la-c_enc.lo `test -f 'cast/c_enc.c' || echo '$(srcdir)/'`cast/c_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) cast/$(DEPDIR)/libcrypto_la-c_enc.Tpo cast/$(DEPDIR)/libcrypto_la-c_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cast/c_enc.c' object='cast/libcrypto_la-c_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o cast/libcrypto_la-c_enc.lo `test -f 'cast/c_enc.c' || echo '$(srcdir)/'`cast/c_enc.c cast/libcrypto_la-c_ofb64.lo: cast/c_ofb64.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT cast/libcrypto_la-c_ofb64.lo -MD -MP -MF cast/$(DEPDIR)/libcrypto_la-c_ofb64.Tpo -c -o cast/libcrypto_la-c_ofb64.lo `test -f 'cast/c_ofb64.c' || echo '$(srcdir)/'`cast/c_ofb64.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) cast/$(DEPDIR)/libcrypto_la-c_ofb64.Tpo cast/$(DEPDIR)/libcrypto_la-c_ofb64.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cast/c_ofb64.c' object='cast/libcrypto_la-c_ofb64.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o cast/libcrypto_la-c_ofb64.lo `test -f 'cast/c_ofb64.c' || echo '$(srcdir)/'`cast/c_ofb64.c cast/libcrypto_la-c_skey.lo: cast/c_skey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT cast/libcrypto_la-c_skey.lo -MD -MP -MF cast/$(DEPDIR)/libcrypto_la-c_skey.Tpo -c -o cast/libcrypto_la-c_skey.lo `test -f 'cast/c_skey.c' || echo '$(srcdir)/'`cast/c_skey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) cast/$(DEPDIR)/libcrypto_la-c_skey.Tpo cast/$(DEPDIR)/libcrypto_la-c_skey.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cast/c_skey.c' object='cast/libcrypto_la-c_skey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o cast/libcrypto_la-c_skey.lo `test -f 'cast/c_skey.c' || echo '$(srcdir)/'`cast/c_skey.c chacha/libcrypto_la-chacha.lo: chacha/chacha.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT chacha/libcrypto_la-chacha.lo -MD -MP -MF chacha/$(DEPDIR)/libcrypto_la-chacha.Tpo -c -o chacha/libcrypto_la-chacha.lo `test -f 'chacha/chacha.c' || echo '$(srcdir)/'`chacha/chacha.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) chacha/$(DEPDIR)/libcrypto_la-chacha.Tpo chacha/$(DEPDIR)/libcrypto_la-chacha.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='chacha/chacha.c' object='chacha/libcrypto_la-chacha.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o chacha/libcrypto_la-chacha.lo `test -f 'chacha/chacha.c' || echo '$(srcdir)/'`chacha/chacha.c cmac/libcrypto_la-cm_ameth.lo: cmac/cm_ameth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT cmac/libcrypto_la-cm_ameth.lo -MD -MP -MF cmac/$(DEPDIR)/libcrypto_la-cm_ameth.Tpo -c -o cmac/libcrypto_la-cm_ameth.lo `test -f 'cmac/cm_ameth.c' || echo '$(srcdir)/'`cmac/cm_ameth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) cmac/$(DEPDIR)/libcrypto_la-cm_ameth.Tpo cmac/$(DEPDIR)/libcrypto_la-cm_ameth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cmac/cm_ameth.c' object='cmac/libcrypto_la-cm_ameth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o cmac/libcrypto_la-cm_ameth.lo `test -f 'cmac/cm_ameth.c' || echo '$(srcdir)/'`cmac/cm_ameth.c cmac/libcrypto_la-cm_pmeth.lo: cmac/cm_pmeth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT cmac/libcrypto_la-cm_pmeth.lo -MD -MP -MF cmac/$(DEPDIR)/libcrypto_la-cm_pmeth.Tpo -c -o cmac/libcrypto_la-cm_pmeth.lo `test -f 'cmac/cm_pmeth.c' || echo '$(srcdir)/'`cmac/cm_pmeth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) cmac/$(DEPDIR)/libcrypto_la-cm_pmeth.Tpo cmac/$(DEPDIR)/libcrypto_la-cm_pmeth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cmac/cm_pmeth.c' object='cmac/libcrypto_la-cm_pmeth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o cmac/libcrypto_la-cm_pmeth.lo `test -f 'cmac/cm_pmeth.c' || echo '$(srcdir)/'`cmac/cm_pmeth.c cmac/libcrypto_la-cmac.lo: cmac/cmac.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT cmac/libcrypto_la-cmac.lo -MD -MP -MF cmac/$(DEPDIR)/libcrypto_la-cmac.Tpo -c -o cmac/libcrypto_la-cmac.lo `test -f 'cmac/cmac.c' || echo '$(srcdir)/'`cmac/cmac.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) cmac/$(DEPDIR)/libcrypto_la-cmac.Tpo cmac/$(DEPDIR)/libcrypto_la-cmac.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cmac/cmac.c' object='cmac/libcrypto_la-cmac.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o cmac/libcrypto_la-cmac.lo `test -f 'cmac/cmac.c' || echo '$(srcdir)/'`cmac/cmac.c comp/libcrypto_la-c_rle.lo: comp/c_rle.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT comp/libcrypto_la-c_rle.lo -MD -MP -MF comp/$(DEPDIR)/libcrypto_la-c_rle.Tpo -c -o comp/libcrypto_la-c_rle.lo `test -f 'comp/c_rle.c' || echo '$(srcdir)/'`comp/c_rle.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) comp/$(DEPDIR)/libcrypto_la-c_rle.Tpo comp/$(DEPDIR)/libcrypto_la-c_rle.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='comp/c_rle.c' object='comp/libcrypto_la-c_rle.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o comp/libcrypto_la-c_rle.lo `test -f 'comp/c_rle.c' || echo '$(srcdir)/'`comp/c_rle.c comp/libcrypto_la-c_zlib.lo: comp/c_zlib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT comp/libcrypto_la-c_zlib.lo -MD -MP -MF comp/$(DEPDIR)/libcrypto_la-c_zlib.Tpo -c -o comp/libcrypto_la-c_zlib.lo `test -f 'comp/c_zlib.c' || echo '$(srcdir)/'`comp/c_zlib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) comp/$(DEPDIR)/libcrypto_la-c_zlib.Tpo comp/$(DEPDIR)/libcrypto_la-c_zlib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='comp/c_zlib.c' object='comp/libcrypto_la-c_zlib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o comp/libcrypto_la-c_zlib.lo `test -f 'comp/c_zlib.c' || echo '$(srcdir)/'`comp/c_zlib.c comp/libcrypto_la-comp_err.lo: comp/comp_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT comp/libcrypto_la-comp_err.lo -MD -MP -MF comp/$(DEPDIR)/libcrypto_la-comp_err.Tpo -c -o comp/libcrypto_la-comp_err.lo `test -f 'comp/comp_err.c' || echo '$(srcdir)/'`comp/comp_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) comp/$(DEPDIR)/libcrypto_la-comp_err.Tpo comp/$(DEPDIR)/libcrypto_la-comp_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='comp/comp_err.c' object='comp/libcrypto_la-comp_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o comp/libcrypto_la-comp_err.lo `test -f 'comp/comp_err.c' || echo '$(srcdir)/'`comp/comp_err.c comp/libcrypto_la-comp_lib.lo: comp/comp_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT comp/libcrypto_la-comp_lib.lo -MD -MP -MF comp/$(DEPDIR)/libcrypto_la-comp_lib.Tpo -c -o comp/libcrypto_la-comp_lib.lo `test -f 'comp/comp_lib.c' || echo '$(srcdir)/'`comp/comp_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) comp/$(DEPDIR)/libcrypto_la-comp_lib.Tpo comp/$(DEPDIR)/libcrypto_la-comp_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='comp/comp_lib.c' object='comp/libcrypto_la-comp_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o comp/libcrypto_la-comp_lib.lo `test -f 'comp/comp_lib.c' || echo '$(srcdir)/'`comp/comp_lib.c conf/libcrypto_la-conf_api.lo: conf/conf_api.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT conf/libcrypto_la-conf_api.lo -MD -MP -MF conf/$(DEPDIR)/libcrypto_la-conf_api.Tpo -c -o conf/libcrypto_la-conf_api.lo `test -f 'conf/conf_api.c' || echo '$(srcdir)/'`conf/conf_api.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) conf/$(DEPDIR)/libcrypto_la-conf_api.Tpo conf/$(DEPDIR)/libcrypto_la-conf_api.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='conf/conf_api.c' object='conf/libcrypto_la-conf_api.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o conf/libcrypto_la-conf_api.lo `test -f 'conf/conf_api.c' || echo '$(srcdir)/'`conf/conf_api.c conf/libcrypto_la-conf_def.lo: conf/conf_def.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT conf/libcrypto_la-conf_def.lo -MD -MP -MF conf/$(DEPDIR)/libcrypto_la-conf_def.Tpo -c -o conf/libcrypto_la-conf_def.lo `test -f 'conf/conf_def.c' || echo '$(srcdir)/'`conf/conf_def.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) conf/$(DEPDIR)/libcrypto_la-conf_def.Tpo conf/$(DEPDIR)/libcrypto_la-conf_def.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='conf/conf_def.c' object='conf/libcrypto_la-conf_def.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o conf/libcrypto_la-conf_def.lo `test -f 'conf/conf_def.c' || echo '$(srcdir)/'`conf/conf_def.c conf/libcrypto_la-conf_err.lo: conf/conf_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT conf/libcrypto_la-conf_err.lo -MD -MP -MF conf/$(DEPDIR)/libcrypto_la-conf_err.Tpo -c -o conf/libcrypto_la-conf_err.lo `test -f 'conf/conf_err.c' || echo '$(srcdir)/'`conf/conf_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) conf/$(DEPDIR)/libcrypto_la-conf_err.Tpo conf/$(DEPDIR)/libcrypto_la-conf_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='conf/conf_err.c' object='conf/libcrypto_la-conf_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o conf/libcrypto_la-conf_err.lo `test -f 'conf/conf_err.c' || echo '$(srcdir)/'`conf/conf_err.c conf/libcrypto_la-conf_lib.lo: conf/conf_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT conf/libcrypto_la-conf_lib.lo -MD -MP -MF conf/$(DEPDIR)/libcrypto_la-conf_lib.Tpo -c -o conf/libcrypto_la-conf_lib.lo `test -f 'conf/conf_lib.c' || echo '$(srcdir)/'`conf/conf_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) conf/$(DEPDIR)/libcrypto_la-conf_lib.Tpo conf/$(DEPDIR)/libcrypto_la-conf_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='conf/conf_lib.c' object='conf/libcrypto_la-conf_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o conf/libcrypto_la-conf_lib.lo `test -f 'conf/conf_lib.c' || echo '$(srcdir)/'`conf/conf_lib.c conf/libcrypto_la-conf_mall.lo: conf/conf_mall.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT conf/libcrypto_la-conf_mall.lo -MD -MP -MF conf/$(DEPDIR)/libcrypto_la-conf_mall.Tpo -c -o conf/libcrypto_la-conf_mall.lo `test -f 'conf/conf_mall.c' || echo '$(srcdir)/'`conf/conf_mall.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) conf/$(DEPDIR)/libcrypto_la-conf_mall.Tpo conf/$(DEPDIR)/libcrypto_la-conf_mall.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='conf/conf_mall.c' object='conf/libcrypto_la-conf_mall.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o conf/libcrypto_la-conf_mall.lo `test -f 'conf/conf_mall.c' || echo '$(srcdir)/'`conf/conf_mall.c conf/libcrypto_la-conf_mod.lo: conf/conf_mod.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT conf/libcrypto_la-conf_mod.lo -MD -MP -MF conf/$(DEPDIR)/libcrypto_la-conf_mod.Tpo -c -o conf/libcrypto_la-conf_mod.lo `test -f 'conf/conf_mod.c' || echo '$(srcdir)/'`conf/conf_mod.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) conf/$(DEPDIR)/libcrypto_la-conf_mod.Tpo conf/$(DEPDIR)/libcrypto_la-conf_mod.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='conf/conf_mod.c' object='conf/libcrypto_la-conf_mod.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o conf/libcrypto_la-conf_mod.lo `test -f 'conf/conf_mod.c' || echo '$(srcdir)/'`conf/conf_mod.c conf/libcrypto_la-conf_sap.lo: conf/conf_sap.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT conf/libcrypto_la-conf_sap.lo -MD -MP -MF conf/$(DEPDIR)/libcrypto_la-conf_sap.Tpo -c -o conf/libcrypto_la-conf_sap.lo `test -f 'conf/conf_sap.c' || echo '$(srcdir)/'`conf/conf_sap.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) conf/$(DEPDIR)/libcrypto_la-conf_sap.Tpo conf/$(DEPDIR)/libcrypto_la-conf_sap.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='conf/conf_sap.c' object='conf/libcrypto_la-conf_sap.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o conf/libcrypto_la-conf_sap.lo `test -f 'conf/conf_sap.c' || echo '$(srcdir)/'`conf/conf_sap.c des/libcrypto_la-cbc_cksm.lo: des/cbc_cksm.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-cbc_cksm.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-cbc_cksm.Tpo -c -o des/libcrypto_la-cbc_cksm.lo `test -f 'des/cbc_cksm.c' || echo '$(srcdir)/'`des/cbc_cksm.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-cbc_cksm.Tpo des/$(DEPDIR)/libcrypto_la-cbc_cksm.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/cbc_cksm.c' object='des/libcrypto_la-cbc_cksm.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-cbc_cksm.lo `test -f 'des/cbc_cksm.c' || echo '$(srcdir)/'`des/cbc_cksm.c des/libcrypto_la-cbc_enc.lo: des/cbc_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-cbc_enc.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-cbc_enc.Tpo -c -o des/libcrypto_la-cbc_enc.lo `test -f 'des/cbc_enc.c' || echo '$(srcdir)/'`des/cbc_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-cbc_enc.Tpo des/$(DEPDIR)/libcrypto_la-cbc_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/cbc_enc.c' object='des/libcrypto_la-cbc_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-cbc_enc.lo `test -f 'des/cbc_enc.c' || echo '$(srcdir)/'`des/cbc_enc.c des/libcrypto_la-cfb64ede.lo: des/cfb64ede.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-cfb64ede.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-cfb64ede.Tpo -c -o des/libcrypto_la-cfb64ede.lo `test -f 'des/cfb64ede.c' || echo '$(srcdir)/'`des/cfb64ede.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-cfb64ede.Tpo des/$(DEPDIR)/libcrypto_la-cfb64ede.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/cfb64ede.c' object='des/libcrypto_la-cfb64ede.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-cfb64ede.lo `test -f 'des/cfb64ede.c' || echo '$(srcdir)/'`des/cfb64ede.c des/libcrypto_la-cfb64enc.lo: des/cfb64enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-cfb64enc.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-cfb64enc.Tpo -c -o des/libcrypto_la-cfb64enc.lo `test -f 'des/cfb64enc.c' || echo '$(srcdir)/'`des/cfb64enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-cfb64enc.Tpo des/$(DEPDIR)/libcrypto_la-cfb64enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/cfb64enc.c' object='des/libcrypto_la-cfb64enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-cfb64enc.lo `test -f 'des/cfb64enc.c' || echo '$(srcdir)/'`des/cfb64enc.c des/libcrypto_la-cfb_enc.lo: des/cfb_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-cfb_enc.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-cfb_enc.Tpo -c -o des/libcrypto_la-cfb_enc.lo `test -f 'des/cfb_enc.c' || echo '$(srcdir)/'`des/cfb_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-cfb_enc.Tpo des/$(DEPDIR)/libcrypto_la-cfb_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/cfb_enc.c' object='des/libcrypto_la-cfb_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-cfb_enc.lo `test -f 'des/cfb_enc.c' || echo '$(srcdir)/'`des/cfb_enc.c des/libcrypto_la-des_enc.lo: des/des_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-des_enc.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-des_enc.Tpo -c -o des/libcrypto_la-des_enc.lo `test -f 'des/des_enc.c' || echo '$(srcdir)/'`des/des_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-des_enc.Tpo des/$(DEPDIR)/libcrypto_la-des_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/des_enc.c' object='des/libcrypto_la-des_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-des_enc.lo `test -f 'des/des_enc.c' || echo '$(srcdir)/'`des/des_enc.c des/libcrypto_la-ecb3_enc.lo: des/ecb3_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-ecb3_enc.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-ecb3_enc.Tpo -c -o des/libcrypto_la-ecb3_enc.lo `test -f 'des/ecb3_enc.c' || echo '$(srcdir)/'`des/ecb3_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-ecb3_enc.Tpo des/$(DEPDIR)/libcrypto_la-ecb3_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/ecb3_enc.c' object='des/libcrypto_la-ecb3_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-ecb3_enc.lo `test -f 'des/ecb3_enc.c' || echo '$(srcdir)/'`des/ecb3_enc.c des/libcrypto_la-ecb_enc.lo: des/ecb_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-ecb_enc.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-ecb_enc.Tpo -c -o des/libcrypto_la-ecb_enc.lo `test -f 'des/ecb_enc.c' || echo '$(srcdir)/'`des/ecb_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-ecb_enc.Tpo des/$(DEPDIR)/libcrypto_la-ecb_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/ecb_enc.c' object='des/libcrypto_la-ecb_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-ecb_enc.lo `test -f 'des/ecb_enc.c' || echo '$(srcdir)/'`des/ecb_enc.c des/libcrypto_la-ede_cbcm_enc.lo: des/ede_cbcm_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-ede_cbcm_enc.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-ede_cbcm_enc.Tpo -c -o des/libcrypto_la-ede_cbcm_enc.lo `test -f 'des/ede_cbcm_enc.c' || echo '$(srcdir)/'`des/ede_cbcm_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-ede_cbcm_enc.Tpo des/$(DEPDIR)/libcrypto_la-ede_cbcm_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/ede_cbcm_enc.c' object='des/libcrypto_la-ede_cbcm_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-ede_cbcm_enc.lo `test -f 'des/ede_cbcm_enc.c' || echo '$(srcdir)/'`des/ede_cbcm_enc.c des/libcrypto_la-enc_read.lo: des/enc_read.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-enc_read.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-enc_read.Tpo -c -o des/libcrypto_la-enc_read.lo `test -f 'des/enc_read.c' || echo '$(srcdir)/'`des/enc_read.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-enc_read.Tpo des/$(DEPDIR)/libcrypto_la-enc_read.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/enc_read.c' object='des/libcrypto_la-enc_read.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-enc_read.lo `test -f 'des/enc_read.c' || echo '$(srcdir)/'`des/enc_read.c des/libcrypto_la-enc_writ.lo: des/enc_writ.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-enc_writ.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-enc_writ.Tpo -c -o des/libcrypto_la-enc_writ.lo `test -f 'des/enc_writ.c' || echo '$(srcdir)/'`des/enc_writ.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-enc_writ.Tpo des/$(DEPDIR)/libcrypto_la-enc_writ.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/enc_writ.c' object='des/libcrypto_la-enc_writ.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-enc_writ.lo `test -f 'des/enc_writ.c' || echo '$(srcdir)/'`des/enc_writ.c des/libcrypto_la-fcrypt.lo: des/fcrypt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-fcrypt.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-fcrypt.Tpo -c -o des/libcrypto_la-fcrypt.lo `test -f 'des/fcrypt.c' || echo '$(srcdir)/'`des/fcrypt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-fcrypt.Tpo des/$(DEPDIR)/libcrypto_la-fcrypt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/fcrypt.c' object='des/libcrypto_la-fcrypt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-fcrypt.lo `test -f 'des/fcrypt.c' || echo '$(srcdir)/'`des/fcrypt.c des/libcrypto_la-fcrypt_b.lo: des/fcrypt_b.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-fcrypt_b.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-fcrypt_b.Tpo -c -o des/libcrypto_la-fcrypt_b.lo `test -f 'des/fcrypt_b.c' || echo '$(srcdir)/'`des/fcrypt_b.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-fcrypt_b.Tpo des/$(DEPDIR)/libcrypto_la-fcrypt_b.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/fcrypt_b.c' object='des/libcrypto_la-fcrypt_b.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-fcrypt_b.lo `test -f 'des/fcrypt_b.c' || echo '$(srcdir)/'`des/fcrypt_b.c des/libcrypto_la-ofb64ede.lo: des/ofb64ede.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-ofb64ede.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-ofb64ede.Tpo -c -o des/libcrypto_la-ofb64ede.lo `test -f 'des/ofb64ede.c' || echo '$(srcdir)/'`des/ofb64ede.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-ofb64ede.Tpo des/$(DEPDIR)/libcrypto_la-ofb64ede.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/ofb64ede.c' object='des/libcrypto_la-ofb64ede.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-ofb64ede.lo `test -f 'des/ofb64ede.c' || echo '$(srcdir)/'`des/ofb64ede.c des/libcrypto_la-ofb64enc.lo: des/ofb64enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-ofb64enc.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-ofb64enc.Tpo -c -o des/libcrypto_la-ofb64enc.lo `test -f 'des/ofb64enc.c' || echo '$(srcdir)/'`des/ofb64enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-ofb64enc.Tpo des/$(DEPDIR)/libcrypto_la-ofb64enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/ofb64enc.c' object='des/libcrypto_la-ofb64enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-ofb64enc.lo `test -f 'des/ofb64enc.c' || echo '$(srcdir)/'`des/ofb64enc.c des/libcrypto_la-ofb_enc.lo: des/ofb_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-ofb_enc.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-ofb_enc.Tpo -c -o des/libcrypto_la-ofb_enc.lo `test -f 'des/ofb_enc.c' || echo '$(srcdir)/'`des/ofb_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-ofb_enc.Tpo des/$(DEPDIR)/libcrypto_la-ofb_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/ofb_enc.c' object='des/libcrypto_la-ofb_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-ofb_enc.lo `test -f 'des/ofb_enc.c' || echo '$(srcdir)/'`des/ofb_enc.c des/libcrypto_la-pcbc_enc.lo: des/pcbc_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-pcbc_enc.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-pcbc_enc.Tpo -c -o des/libcrypto_la-pcbc_enc.lo `test -f 'des/pcbc_enc.c' || echo '$(srcdir)/'`des/pcbc_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-pcbc_enc.Tpo des/$(DEPDIR)/libcrypto_la-pcbc_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/pcbc_enc.c' object='des/libcrypto_la-pcbc_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-pcbc_enc.lo `test -f 'des/pcbc_enc.c' || echo '$(srcdir)/'`des/pcbc_enc.c des/libcrypto_la-qud_cksm.lo: des/qud_cksm.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-qud_cksm.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-qud_cksm.Tpo -c -o des/libcrypto_la-qud_cksm.lo `test -f 'des/qud_cksm.c' || echo '$(srcdir)/'`des/qud_cksm.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-qud_cksm.Tpo des/$(DEPDIR)/libcrypto_la-qud_cksm.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/qud_cksm.c' object='des/libcrypto_la-qud_cksm.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-qud_cksm.lo `test -f 'des/qud_cksm.c' || echo '$(srcdir)/'`des/qud_cksm.c des/libcrypto_la-rand_key.lo: des/rand_key.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-rand_key.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-rand_key.Tpo -c -o des/libcrypto_la-rand_key.lo `test -f 'des/rand_key.c' || echo '$(srcdir)/'`des/rand_key.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-rand_key.Tpo des/$(DEPDIR)/libcrypto_la-rand_key.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/rand_key.c' object='des/libcrypto_la-rand_key.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-rand_key.lo `test -f 'des/rand_key.c' || echo '$(srcdir)/'`des/rand_key.c des/libcrypto_la-set_key.lo: des/set_key.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-set_key.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-set_key.Tpo -c -o des/libcrypto_la-set_key.lo `test -f 'des/set_key.c' || echo '$(srcdir)/'`des/set_key.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-set_key.Tpo des/$(DEPDIR)/libcrypto_la-set_key.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/set_key.c' object='des/libcrypto_la-set_key.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-set_key.lo `test -f 'des/set_key.c' || echo '$(srcdir)/'`des/set_key.c des/libcrypto_la-str2key.lo: des/str2key.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-str2key.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-str2key.Tpo -c -o des/libcrypto_la-str2key.lo `test -f 'des/str2key.c' || echo '$(srcdir)/'`des/str2key.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-str2key.Tpo des/$(DEPDIR)/libcrypto_la-str2key.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/str2key.c' object='des/libcrypto_la-str2key.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-str2key.lo `test -f 'des/str2key.c' || echo '$(srcdir)/'`des/str2key.c des/libcrypto_la-xcbc_enc.lo: des/xcbc_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-xcbc_enc.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-xcbc_enc.Tpo -c -o des/libcrypto_la-xcbc_enc.lo `test -f 'des/xcbc_enc.c' || echo '$(srcdir)/'`des/xcbc_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-xcbc_enc.Tpo des/$(DEPDIR)/libcrypto_la-xcbc_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/xcbc_enc.c' object='des/libcrypto_la-xcbc_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-xcbc_enc.lo `test -f 'des/xcbc_enc.c' || echo '$(srcdir)/'`des/xcbc_enc.c dh/libcrypto_la-dh_ameth.lo: dh/dh_ameth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dh/libcrypto_la-dh_ameth.lo -MD -MP -MF dh/$(DEPDIR)/libcrypto_la-dh_ameth.Tpo -c -o dh/libcrypto_la-dh_ameth.lo `test -f 'dh/dh_ameth.c' || echo '$(srcdir)/'`dh/dh_ameth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dh/$(DEPDIR)/libcrypto_la-dh_ameth.Tpo dh/$(DEPDIR)/libcrypto_la-dh_ameth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dh/dh_ameth.c' object='dh/libcrypto_la-dh_ameth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dh/libcrypto_la-dh_ameth.lo `test -f 'dh/dh_ameth.c' || echo '$(srcdir)/'`dh/dh_ameth.c dh/libcrypto_la-dh_asn1.lo: dh/dh_asn1.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dh/libcrypto_la-dh_asn1.lo -MD -MP -MF dh/$(DEPDIR)/libcrypto_la-dh_asn1.Tpo -c -o dh/libcrypto_la-dh_asn1.lo `test -f 'dh/dh_asn1.c' || echo '$(srcdir)/'`dh/dh_asn1.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dh/$(DEPDIR)/libcrypto_la-dh_asn1.Tpo dh/$(DEPDIR)/libcrypto_la-dh_asn1.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dh/dh_asn1.c' object='dh/libcrypto_la-dh_asn1.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dh/libcrypto_la-dh_asn1.lo `test -f 'dh/dh_asn1.c' || echo '$(srcdir)/'`dh/dh_asn1.c dh/libcrypto_la-dh_check.lo: dh/dh_check.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dh/libcrypto_la-dh_check.lo -MD -MP -MF dh/$(DEPDIR)/libcrypto_la-dh_check.Tpo -c -o dh/libcrypto_la-dh_check.lo `test -f 'dh/dh_check.c' || echo '$(srcdir)/'`dh/dh_check.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dh/$(DEPDIR)/libcrypto_la-dh_check.Tpo dh/$(DEPDIR)/libcrypto_la-dh_check.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dh/dh_check.c' object='dh/libcrypto_la-dh_check.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dh/libcrypto_la-dh_check.lo `test -f 'dh/dh_check.c' || echo '$(srcdir)/'`dh/dh_check.c dh/libcrypto_la-dh_depr.lo: dh/dh_depr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dh/libcrypto_la-dh_depr.lo -MD -MP -MF dh/$(DEPDIR)/libcrypto_la-dh_depr.Tpo -c -o dh/libcrypto_la-dh_depr.lo `test -f 'dh/dh_depr.c' || echo '$(srcdir)/'`dh/dh_depr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dh/$(DEPDIR)/libcrypto_la-dh_depr.Tpo dh/$(DEPDIR)/libcrypto_la-dh_depr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dh/dh_depr.c' object='dh/libcrypto_la-dh_depr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dh/libcrypto_la-dh_depr.lo `test -f 'dh/dh_depr.c' || echo '$(srcdir)/'`dh/dh_depr.c dh/libcrypto_la-dh_err.lo: dh/dh_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dh/libcrypto_la-dh_err.lo -MD -MP -MF dh/$(DEPDIR)/libcrypto_la-dh_err.Tpo -c -o dh/libcrypto_la-dh_err.lo `test -f 'dh/dh_err.c' || echo '$(srcdir)/'`dh/dh_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dh/$(DEPDIR)/libcrypto_la-dh_err.Tpo dh/$(DEPDIR)/libcrypto_la-dh_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dh/dh_err.c' object='dh/libcrypto_la-dh_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dh/libcrypto_la-dh_err.lo `test -f 'dh/dh_err.c' || echo '$(srcdir)/'`dh/dh_err.c dh/libcrypto_la-dh_gen.lo: dh/dh_gen.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dh/libcrypto_la-dh_gen.lo -MD -MP -MF dh/$(DEPDIR)/libcrypto_la-dh_gen.Tpo -c -o dh/libcrypto_la-dh_gen.lo `test -f 'dh/dh_gen.c' || echo '$(srcdir)/'`dh/dh_gen.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dh/$(DEPDIR)/libcrypto_la-dh_gen.Tpo dh/$(DEPDIR)/libcrypto_la-dh_gen.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dh/dh_gen.c' object='dh/libcrypto_la-dh_gen.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dh/libcrypto_la-dh_gen.lo `test -f 'dh/dh_gen.c' || echo '$(srcdir)/'`dh/dh_gen.c dh/libcrypto_la-dh_key.lo: dh/dh_key.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dh/libcrypto_la-dh_key.lo -MD -MP -MF dh/$(DEPDIR)/libcrypto_la-dh_key.Tpo -c -o dh/libcrypto_la-dh_key.lo `test -f 'dh/dh_key.c' || echo '$(srcdir)/'`dh/dh_key.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dh/$(DEPDIR)/libcrypto_la-dh_key.Tpo dh/$(DEPDIR)/libcrypto_la-dh_key.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dh/dh_key.c' object='dh/libcrypto_la-dh_key.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dh/libcrypto_la-dh_key.lo `test -f 'dh/dh_key.c' || echo '$(srcdir)/'`dh/dh_key.c dh/libcrypto_la-dh_lib.lo: dh/dh_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dh/libcrypto_la-dh_lib.lo -MD -MP -MF dh/$(DEPDIR)/libcrypto_la-dh_lib.Tpo -c -o dh/libcrypto_la-dh_lib.lo `test -f 'dh/dh_lib.c' || echo '$(srcdir)/'`dh/dh_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dh/$(DEPDIR)/libcrypto_la-dh_lib.Tpo dh/$(DEPDIR)/libcrypto_la-dh_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dh/dh_lib.c' object='dh/libcrypto_la-dh_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dh/libcrypto_la-dh_lib.lo `test -f 'dh/dh_lib.c' || echo '$(srcdir)/'`dh/dh_lib.c dh/libcrypto_la-dh_pmeth.lo: dh/dh_pmeth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dh/libcrypto_la-dh_pmeth.lo -MD -MP -MF dh/$(DEPDIR)/libcrypto_la-dh_pmeth.Tpo -c -o dh/libcrypto_la-dh_pmeth.lo `test -f 'dh/dh_pmeth.c' || echo '$(srcdir)/'`dh/dh_pmeth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dh/$(DEPDIR)/libcrypto_la-dh_pmeth.Tpo dh/$(DEPDIR)/libcrypto_la-dh_pmeth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dh/dh_pmeth.c' object='dh/libcrypto_la-dh_pmeth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dh/libcrypto_la-dh_pmeth.lo `test -f 'dh/dh_pmeth.c' || echo '$(srcdir)/'`dh/dh_pmeth.c dh/libcrypto_la-dh_prn.lo: dh/dh_prn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dh/libcrypto_la-dh_prn.lo -MD -MP -MF dh/$(DEPDIR)/libcrypto_la-dh_prn.Tpo -c -o dh/libcrypto_la-dh_prn.lo `test -f 'dh/dh_prn.c' || echo '$(srcdir)/'`dh/dh_prn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dh/$(DEPDIR)/libcrypto_la-dh_prn.Tpo dh/$(DEPDIR)/libcrypto_la-dh_prn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dh/dh_prn.c' object='dh/libcrypto_la-dh_prn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dh/libcrypto_la-dh_prn.lo `test -f 'dh/dh_prn.c' || echo '$(srcdir)/'`dh/dh_prn.c dsa/libcrypto_la-dsa_ameth.lo: dsa/dsa_ameth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dsa/libcrypto_la-dsa_ameth.lo -MD -MP -MF dsa/$(DEPDIR)/libcrypto_la-dsa_ameth.Tpo -c -o dsa/libcrypto_la-dsa_ameth.lo `test -f 'dsa/dsa_ameth.c' || echo '$(srcdir)/'`dsa/dsa_ameth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcrypto_la-dsa_ameth.Tpo dsa/$(DEPDIR)/libcrypto_la-dsa_ameth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/dsa_ameth.c' object='dsa/libcrypto_la-dsa_ameth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dsa/libcrypto_la-dsa_ameth.lo `test -f 'dsa/dsa_ameth.c' || echo '$(srcdir)/'`dsa/dsa_ameth.c dsa/libcrypto_la-dsa_asn1.lo: dsa/dsa_asn1.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dsa/libcrypto_la-dsa_asn1.lo -MD -MP -MF dsa/$(DEPDIR)/libcrypto_la-dsa_asn1.Tpo -c -o dsa/libcrypto_la-dsa_asn1.lo `test -f 'dsa/dsa_asn1.c' || echo '$(srcdir)/'`dsa/dsa_asn1.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcrypto_la-dsa_asn1.Tpo dsa/$(DEPDIR)/libcrypto_la-dsa_asn1.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/dsa_asn1.c' object='dsa/libcrypto_la-dsa_asn1.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dsa/libcrypto_la-dsa_asn1.lo `test -f 'dsa/dsa_asn1.c' || echo '$(srcdir)/'`dsa/dsa_asn1.c dsa/libcrypto_la-dsa_depr.lo: dsa/dsa_depr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dsa/libcrypto_la-dsa_depr.lo -MD -MP -MF dsa/$(DEPDIR)/libcrypto_la-dsa_depr.Tpo -c -o dsa/libcrypto_la-dsa_depr.lo `test -f 'dsa/dsa_depr.c' || echo '$(srcdir)/'`dsa/dsa_depr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcrypto_la-dsa_depr.Tpo dsa/$(DEPDIR)/libcrypto_la-dsa_depr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/dsa_depr.c' object='dsa/libcrypto_la-dsa_depr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dsa/libcrypto_la-dsa_depr.lo `test -f 'dsa/dsa_depr.c' || echo '$(srcdir)/'`dsa/dsa_depr.c dsa/libcrypto_la-dsa_err.lo: dsa/dsa_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dsa/libcrypto_la-dsa_err.lo -MD -MP -MF dsa/$(DEPDIR)/libcrypto_la-dsa_err.Tpo -c -o dsa/libcrypto_la-dsa_err.lo `test -f 'dsa/dsa_err.c' || echo '$(srcdir)/'`dsa/dsa_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcrypto_la-dsa_err.Tpo dsa/$(DEPDIR)/libcrypto_la-dsa_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/dsa_err.c' object='dsa/libcrypto_la-dsa_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dsa/libcrypto_la-dsa_err.lo `test -f 'dsa/dsa_err.c' || echo '$(srcdir)/'`dsa/dsa_err.c dsa/libcrypto_la-dsa_gen.lo: dsa/dsa_gen.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dsa/libcrypto_la-dsa_gen.lo -MD -MP -MF dsa/$(DEPDIR)/libcrypto_la-dsa_gen.Tpo -c -o dsa/libcrypto_la-dsa_gen.lo `test -f 'dsa/dsa_gen.c' || echo '$(srcdir)/'`dsa/dsa_gen.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcrypto_la-dsa_gen.Tpo dsa/$(DEPDIR)/libcrypto_la-dsa_gen.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/dsa_gen.c' object='dsa/libcrypto_la-dsa_gen.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dsa/libcrypto_la-dsa_gen.lo `test -f 'dsa/dsa_gen.c' || echo '$(srcdir)/'`dsa/dsa_gen.c dsa/libcrypto_la-dsa_key.lo: dsa/dsa_key.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dsa/libcrypto_la-dsa_key.lo -MD -MP -MF dsa/$(DEPDIR)/libcrypto_la-dsa_key.Tpo -c -o dsa/libcrypto_la-dsa_key.lo `test -f 'dsa/dsa_key.c' || echo '$(srcdir)/'`dsa/dsa_key.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcrypto_la-dsa_key.Tpo dsa/$(DEPDIR)/libcrypto_la-dsa_key.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/dsa_key.c' object='dsa/libcrypto_la-dsa_key.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dsa/libcrypto_la-dsa_key.lo `test -f 'dsa/dsa_key.c' || echo '$(srcdir)/'`dsa/dsa_key.c dsa/libcrypto_la-dsa_lib.lo: dsa/dsa_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dsa/libcrypto_la-dsa_lib.lo -MD -MP -MF dsa/$(DEPDIR)/libcrypto_la-dsa_lib.Tpo -c -o dsa/libcrypto_la-dsa_lib.lo `test -f 'dsa/dsa_lib.c' || echo '$(srcdir)/'`dsa/dsa_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcrypto_la-dsa_lib.Tpo dsa/$(DEPDIR)/libcrypto_la-dsa_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/dsa_lib.c' object='dsa/libcrypto_la-dsa_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dsa/libcrypto_la-dsa_lib.lo `test -f 'dsa/dsa_lib.c' || echo '$(srcdir)/'`dsa/dsa_lib.c dsa/libcrypto_la-dsa_ossl.lo: dsa/dsa_ossl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dsa/libcrypto_la-dsa_ossl.lo -MD -MP -MF dsa/$(DEPDIR)/libcrypto_la-dsa_ossl.Tpo -c -o dsa/libcrypto_la-dsa_ossl.lo `test -f 'dsa/dsa_ossl.c' || echo '$(srcdir)/'`dsa/dsa_ossl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcrypto_la-dsa_ossl.Tpo dsa/$(DEPDIR)/libcrypto_la-dsa_ossl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/dsa_ossl.c' object='dsa/libcrypto_la-dsa_ossl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dsa/libcrypto_la-dsa_ossl.lo `test -f 'dsa/dsa_ossl.c' || echo '$(srcdir)/'`dsa/dsa_ossl.c dsa/libcrypto_la-dsa_pmeth.lo: dsa/dsa_pmeth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dsa/libcrypto_la-dsa_pmeth.lo -MD -MP -MF dsa/$(DEPDIR)/libcrypto_la-dsa_pmeth.Tpo -c -o dsa/libcrypto_la-dsa_pmeth.lo `test -f 'dsa/dsa_pmeth.c' || echo '$(srcdir)/'`dsa/dsa_pmeth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcrypto_la-dsa_pmeth.Tpo dsa/$(DEPDIR)/libcrypto_la-dsa_pmeth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/dsa_pmeth.c' object='dsa/libcrypto_la-dsa_pmeth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dsa/libcrypto_la-dsa_pmeth.lo `test -f 'dsa/dsa_pmeth.c' || echo '$(srcdir)/'`dsa/dsa_pmeth.c dsa/libcrypto_la-dsa_prn.lo: dsa/dsa_prn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dsa/libcrypto_la-dsa_prn.lo -MD -MP -MF dsa/$(DEPDIR)/libcrypto_la-dsa_prn.Tpo -c -o dsa/libcrypto_la-dsa_prn.lo `test -f 'dsa/dsa_prn.c' || echo '$(srcdir)/'`dsa/dsa_prn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcrypto_la-dsa_prn.Tpo dsa/$(DEPDIR)/libcrypto_la-dsa_prn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/dsa_prn.c' object='dsa/libcrypto_la-dsa_prn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dsa/libcrypto_la-dsa_prn.lo `test -f 'dsa/dsa_prn.c' || echo '$(srcdir)/'`dsa/dsa_prn.c dsa/libcrypto_la-dsa_sign.lo: dsa/dsa_sign.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dsa/libcrypto_la-dsa_sign.lo -MD -MP -MF dsa/$(DEPDIR)/libcrypto_la-dsa_sign.Tpo -c -o dsa/libcrypto_la-dsa_sign.lo `test -f 'dsa/dsa_sign.c' || echo '$(srcdir)/'`dsa/dsa_sign.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcrypto_la-dsa_sign.Tpo dsa/$(DEPDIR)/libcrypto_la-dsa_sign.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/dsa_sign.c' object='dsa/libcrypto_la-dsa_sign.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dsa/libcrypto_la-dsa_sign.lo `test -f 'dsa/dsa_sign.c' || echo '$(srcdir)/'`dsa/dsa_sign.c dsa/libcrypto_la-dsa_vrf.lo: dsa/dsa_vrf.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dsa/libcrypto_la-dsa_vrf.lo -MD -MP -MF dsa/$(DEPDIR)/libcrypto_la-dsa_vrf.Tpo -c -o dsa/libcrypto_la-dsa_vrf.lo `test -f 'dsa/dsa_vrf.c' || echo '$(srcdir)/'`dsa/dsa_vrf.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcrypto_la-dsa_vrf.Tpo dsa/$(DEPDIR)/libcrypto_la-dsa_vrf.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/dsa_vrf.c' object='dsa/libcrypto_la-dsa_vrf.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dsa/libcrypto_la-dsa_vrf.lo `test -f 'dsa/dsa_vrf.c' || echo '$(srcdir)/'`dsa/dsa_vrf.c dso/libcrypto_la-dso_dlfcn.lo: dso/dso_dlfcn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dso/libcrypto_la-dso_dlfcn.lo -MD -MP -MF dso/$(DEPDIR)/libcrypto_la-dso_dlfcn.Tpo -c -o dso/libcrypto_la-dso_dlfcn.lo `test -f 'dso/dso_dlfcn.c' || echo '$(srcdir)/'`dso/dso_dlfcn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dso/$(DEPDIR)/libcrypto_la-dso_dlfcn.Tpo dso/$(DEPDIR)/libcrypto_la-dso_dlfcn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dso/dso_dlfcn.c' object='dso/libcrypto_la-dso_dlfcn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dso/libcrypto_la-dso_dlfcn.lo `test -f 'dso/dso_dlfcn.c' || echo '$(srcdir)/'`dso/dso_dlfcn.c dso/libcrypto_la-dso_err.lo: dso/dso_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dso/libcrypto_la-dso_err.lo -MD -MP -MF dso/$(DEPDIR)/libcrypto_la-dso_err.Tpo -c -o dso/libcrypto_la-dso_err.lo `test -f 'dso/dso_err.c' || echo '$(srcdir)/'`dso/dso_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dso/$(DEPDIR)/libcrypto_la-dso_err.Tpo dso/$(DEPDIR)/libcrypto_la-dso_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dso/dso_err.c' object='dso/libcrypto_la-dso_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dso/libcrypto_la-dso_err.lo `test -f 'dso/dso_err.c' || echo '$(srcdir)/'`dso/dso_err.c dso/libcrypto_la-dso_lib.lo: dso/dso_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dso/libcrypto_la-dso_lib.lo -MD -MP -MF dso/$(DEPDIR)/libcrypto_la-dso_lib.Tpo -c -o dso/libcrypto_la-dso_lib.lo `test -f 'dso/dso_lib.c' || echo '$(srcdir)/'`dso/dso_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dso/$(DEPDIR)/libcrypto_la-dso_lib.Tpo dso/$(DEPDIR)/libcrypto_la-dso_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dso/dso_lib.c' object='dso/libcrypto_la-dso_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dso/libcrypto_la-dso_lib.lo `test -f 'dso/dso_lib.c' || echo '$(srcdir)/'`dso/dso_lib.c dso/libcrypto_la-dso_null.lo: dso/dso_null.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dso/libcrypto_la-dso_null.lo -MD -MP -MF dso/$(DEPDIR)/libcrypto_la-dso_null.Tpo -c -o dso/libcrypto_la-dso_null.lo `test -f 'dso/dso_null.c' || echo '$(srcdir)/'`dso/dso_null.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dso/$(DEPDIR)/libcrypto_la-dso_null.Tpo dso/$(DEPDIR)/libcrypto_la-dso_null.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dso/dso_null.c' object='dso/libcrypto_la-dso_null.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dso/libcrypto_la-dso_null.lo `test -f 'dso/dso_null.c' || echo '$(srcdir)/'`dso/dso_null.c dso/libcrypto_la-dso_openssl.lo: dso/dso_openssl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT dso/libcrypto_la-dso_openssl.lo -MD -MP -MF dso/$(DEPDIR)/libcrypto_la-dso_openssl.Tpo -c -o dso/libcrypto_la-dso_openssl.lo `test -f 'dso/dso_openssl.c' || echo '$(srcdir)/'`dso/dso_openssl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dso/$(DEPDIR)/libcrypto_la-dso_openssl.Tpo dso/$(DEPDIR)/libcrypto_la-dso_openssl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dso/dso_openssl.c' object='dso/libcrypto_la-dso_openssl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o dso/libcrypto_la-dso_openssl.lo `test -f 'dso/dso_openssl.c' || echo '$(srcdir)/'`dso/dso_openssl.c ec/libcrypto_la-ec2_mult.lo: ec/ec2_mult.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ec2_mult.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ec2_mult.Tpo -c -o ec/libcrypto_la-ec2_mult.lo `test -f 'ec/ec2_mult.c' || echo '$(srcdir)/'`ec/ec2_mult.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ec2_mult.Tpo ec/$(DEPDIR)/libcrypto_la-ec2_mult.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ec2_mult.c' object='ec/libcrypto_la-ec2_mult.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ec2_mult.lo `test -f 'ec/ec2_mult.c' || echo '$(srcdir)/'`ec/ec2_mult.c ec/libcrypto_la-ec2_oct.lo: ec/ec2_oct.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ec2_oct.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ec2_oct.Tpo -c -o ec/libcrypto_la-ec2_oct.lo `test -f 'ec/ec2_oct.c' || echo '$(srcdir)/'`ec/ec2_oct.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ec2_oct.Tpo ec/$(DEPDIR)/libcrypto_la-ec2_oct.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ec2_oct.c' object='ec/libcrypto_la-ec2_oct.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ec2_oct.lo `test -f 'ec/ec2_oct.c' || echo '$(srcdir)/'`ec/ec2_oct.c ec/libcrypto_la-ec2_smpl.lo: ec/ec2_smpl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ec2_smpl.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ec2_smpl.Tpo -c -o ec/libcrypto_la-ec2_smpl.lo `test -f 'ec/ec2_smpl.c' || echo '$(srcdir)/'`ec/ec2_smpl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ec2_smpl.Tpo ec/$(DEPDIR)/libcrypto_la-ec2_smpl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ec2_smpl.c' object='ec/libcrypto_la-ec2_smpl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ec2_smpl.lo `test -f 'ec/ec2_smpl.c' || echo '$(srcdir)/'`ec/ec2_smpl.c ec/libcrypto_la-ec_ameth.lo: ec/ec_ameth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ec_ameth.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ec_ameth.Tpo -c -o ec/libcrypto_la-ec_ameth.lo `test -f 'ec/ec_ameth.c' || echo '$(srcdir)/'`ec/ec_ameth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ec_ameth.Tpo ec/$(DEPDIR)/libcrypto_la-ec_ameth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ec_ameth.c' object='ec/libcrypto_la-ec_ameth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ec_ameth.lo `test -f 'ec/ec_ameth.c' || echo '$(srcdir)/'`ec/ec_ameth.c ec/libcrypto_la-ec_asn1.lo: ec/ec_asn1.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ec_asn1.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ec_asn1.Tpo -c -o ec/libcrypto_la-ec_asn1.lo `test -f 'ec/ec_asn1.c' || echo '$(srcdir)/'`ec/ec_asn1.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ec_asn1.Tpo ec/$(DEPDIR)/libcrypto_la-ec_asn1.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ec_asn1.c' object='ec/libcrypto_la-ec_asn1.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ec_asn1.lo `test -f 'ec/ec_asn1.c' || echo '$(srcdir)/'`ec/ec_asn1.c ec/libcrypto_la-ec_check.lo: ec/ec_check.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ec_check.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ec_check.Tpo -c -o ec/libcrypto_la-ec_check.lo `test -f 'ec/ec_check.c' || echo '$(srcdir)/'`ec/ec_check.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ec_check.Tpo ec/$(DEPDIR)/libcrypto_la-ec_check.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ec_check.c' object='ec/libcrypto_la-ec_check.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ec_check.lo `test -f 'ec/ec_check.c' || echo '$(srcdir)/'`ec/ec_check.c ec/libcrypto_la-ec_curve.lo: ec/ec_curve.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ec_curve.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ec_curve.Tpo -c -o ec/libcrypto_la-ec_curve.lo `test -f 'ec/ec_curve.c' || echo '$(srcdir)/'`ec/ec_curve.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ec_curve.Tpo ec/$(DEPDIR)/libcrypto_la-ec_curve.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ec_curve.c' object='ec/libcrypto_la-ec_curve.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ec_curve.lo `test -f 'ec/ec_curve.c' || echo '$(srcdir)/'`ec/ec_curve.c ec/libcrypto_la-ec_cvt.lo: ec/ec_cvt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ec_cvt.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ec_cvt.Tpo -c -o ec/libcrypto_la-ec_cvt.lo `test -f 'ec/ec_cvt.c' || echo '$(srcdir)/'`ec/ec_cvt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ec_cvt.Tpo ec/$(DEPDIR)/libcrypto_la-ec_cvt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ec_cvt.c' object='ec/libcrypto_la-ec_cvt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ec_cvt.lo `test -f 'ec/ec_cvt.c' || echo '$(srcdir)/'`ec/ec_cvt.c ec/libcrypto_la-ec_err.lo: ec/ec_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ec_err.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ec_err.Tpo -c -o ec/libcrypto_la-ec_err.lo `test -f 'ec/ec_err.c' || echo '$(srcdir)/'`ec/ec_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ec_err.Tpo ec/$(DEPDIR)/libcrypto_la-ec_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ec_err.c' object='ec/libcrypto_la-ec_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ec_err.lo `test -f 'ec/ec_err.c' || echo '$(srcdir)/'`ec/ec_err.c ec/libcrypto_la-ec_key.lo: ec/ec_key.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ec_key.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ec_key.Tpo -c -o ec/libcrypto_la-ec_key.lo `test -f 'ec/ec_key.c' || echo '$(srcdir)/'`ec/ec_key.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ec_key.Tpo ec/$(DEPDIR)/libcrypto_la-ec_key.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ec_key.c' object='ec/libcrypto_la-ec_key.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ec_key.lo `test -f 'ec/ec_key.c' || echo '$(srcdir)/'`ec/ec_key.c ec/libcrypto_la-ec_lib.lo: ec/ec_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ec_lib.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ec_lib.Tpo -c -o ec/libcrypto_la-ec_lib.lo `test -f 'ec/ec_lib.c' || echo '$(srcdir)/'`ec/ec_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ec_lib.Tpo ec/$(DEPDIR)/libcrypto_la-ec_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ec_lib.c' object='ec/libcrypto_la-ec_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ec_lib.lo `test -f 'ec/ec_lib.c' || echo '$(srcdir)/'`ec/ec_lib.c ec/libcrypto_la-ec_mult.lo: ec/ec_mult.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ec_mult.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ec_mult.Tpo -c -o ec/libcrypto_la-ec_mult.lo `test -f 'ec/ec_mult.c' || echo '$(srcdir)/'`ec/ec_mult.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ec_mult.Tpo ec/$(DEPDIR)/libcrypto_la-ec_mult.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ec_mult.c' object='ec/libcrypto_la-ec_mult.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ec_mult.lo `test -f 'ec/ec_mult.c' || echo '$(srcdir)/'`ec/ec_mult.c ec/libcrypto_la-ec_oct.lo: ec/ec_oct.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ec_oct.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ec_oct.Tpo -c -o ec/libcrypto_la-ec_oct.lo `test -f 'ec/ec_oct.c' || echo '$(srcdir)/'`ec/ec_oct.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ec_oct.Tpo ec/$(DEPDIR)/libcrypto_la-ec_oct.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ec_oct.c' object='ec/libcrypto_la-ec_oct.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ec_oct.lo `test -f 'ec/ec_oct.c' || echo '$(srcdir)/'`ec/ec_oct.c ec/libcrypto_la-ec_pmeth.lo: ec/ec_pmeth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ec_pmeth.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ec_pmeth.Tpo -c -o ec/libcrypto_la-ec_pmeth.lo `test -f 'ec/ec_pmeth.c' || echo '$(srcdir)/'`ec/ec_pmeth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ec_pmeth.Tpo ec/$(DEPDIR)/libcrypto_la-ec_pmeth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ec_pmeth.c' object='ec/libcrypto_la-ec_pmeth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ec_pmeth.lo `test -f 'ec/ec_pmeth.c' || echo '$(srcdir)/'`ec/ec_pmeth.c ec/libcrypto_la-ec_print.lo: ec/ec_print.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ec_print.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ec_print.Tpo -c -o ec/libcrypto_la-ec_print.lo `test -f 'ec/ec_print.c' || echo '$(srcdir)/'`ec/ec_print.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ec_print.Tpo ec/$(DEPDIR)/libcrypto_la-ec_print.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ec_print.c' object='ec/libcrypto_la-ec_print.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ec_print.lo `test -f 'ec/ec_print.c' || echo '$(srcdir)/'`ec/ec_print.c ec/libcrypto_la-eck_prn.lo: ec/eck_prn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-eck_prn.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-eck_prn.Tpo -c -o ec/libcrypto_la-eck_prn.lo `test -f 'ec/eck_prn.c' || echo '$(srcdir)/'`ec/eck_prn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-eck_prn.Tpo ec/$(DEPDIR)/libcrypto_la-eck_prn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/eck_prn.c' object='ec/libcrypto_la-eck_prn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-eck_prn.lo `test -f 'ec/eck_prn.c' || echo '$(srcdir)/'`ec/eck_prn.c ec/libcrypto_la-ecp_mont.lo: ec/ecp_mont.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ecp_mont.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ecp_mont.Tpo -c -o ec/libcrypto_la-ecp_mont.lo `test -f 'ec/ecp_mont.c' || echo '$(srcdir)/'`ec/ecp_mont.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ecp_mont.Tpo ec/$(DEPDIR)/libcrypto_la-ecp_mont.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ecp_mont.c' object='ec/libcrypto_la-ecp_mont.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ecp_mont.lo `test -f 'ec/ecp_mont.c' || echo '$(srcdir)/'`ec/ecp_mont.c ec/libcrypto_la-ecp_nist.lo: ec/ecp_nist.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ecp_nist.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ecp_nist.Tpo -c -o ec/libcrypto_la-ecp_nist.lo `test -f 'ec/ecp_nist.c' || echo '$(srcdir)/'`ec/ecp_nist.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ecp_nist.Tpo ec/$(DEPDIR)/libcrypto_la-ecp_nist.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ecp_nist.c' object='ec/libcrypto_la-ecp_nist.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ecp_nist.lo `test -f 'ec/ecp_nist.c' || echo '$(srcdir)/'`ec/ecp_nist.c ec/libcrypto_la-ecp_oct.lo: ec/ecp_oct.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ecp_oct.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ecp_oct.Tpo -c -o ec/libcrypto_la-ecp_oct.lo `test -f 'ec/ecp_oct.c' || echo '$(srcdir)/'`ec/ecp_oct.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ecp_oct.Tpo ec/$(DEPDIR)/libcrypto_la-ecp_oct.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ecp_oct.c' object='ec/libcrypto_la-ecp_oct.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ecp_oct.lo `test -f 'ec/ecp_oct.c' || echo '$(srcdir)/'`ec/ecp_oct.c ec/libcrypto_la-ecp_smpl.lo: ec/ecp_smpl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ecp_smpl.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ecp_smpl.Tpo -c -o ec/libcrypto_la-ecp_smpl.lo `test -f 'ec/ecp_smpl.c' || echo '$(srcdir)/'`ec/ecp_smpl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ecp_smpl.Tpo ec/$(DEPDIR)/libcrypto_la-ecp_smpl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ecp_smpl.c' object='ec/libcrypto_la-ecp_smpl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ecp_smpl.lo `test -f 'ec/ecp_smpl.c' || echo '$(srcdir)/'`ec/ecp_smpl.c ecdh/libcrypto_la-ech_err.lo: ecdh/ech_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ecdh/libcrypto_la-ech_err.lo -MD -MP -MF ecdh/$(DEPDIR)/libcrypto_la-ech_err.Tpo -c -o ecdh/libcrypto_la-ech_err.lo `test -f 'ecdh/ech_err.c' || echo '$(srcdir)/'`ecdh/ech_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ecdh/$(DEPDIR)/libcrypto_la-ech_err.Tpo ecdh/$(DEPDIR)/libcrypto_la-ech_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ecdh/ech_err.c' object='ecdh/libcrypto_la-ech_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ecdh/libcrypto_la-ech_err.lo `test -f 'ecdh/ech_err.c' || echo '$(srcdir)/'`ecdh/ech_err.c ecdh/libcrypto_la-ech_key.lo: ecdh/ech_key.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ecdh/libcrypto_la-ech_key.lo -MD -MP -MF ecdh/$(DEPDIR)/libcrypto_la-ech_key.Tpo -c -o ecdh/libcrypto_la-ech_key.lo `test -f 'ecdh/ech_key.c' || echo '$(srcdir)/'`ecdh/ech_key.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ecdh/$(DEPDIR)/libcrypto_la-ech_key.Tpo ecdh/$(DEPDIR)/libcrypto_la-ech_key.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ecdh/ech_key.c' object='ecdh/libcrypto_la-ech_key.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ecdh/libcrypto_la-ech_key.lo `test -f 'ecdh/ech_key.c' || echo '$(srcdir)/'`ecdh/ech_key.c ecdh/libcrypto_la-ech_lib.lo: ecdh/ech_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ecdh/libcrypto_la-ech_lib.lo -MD -MP -MF ecdh/$(DEPDIR)/libcrypto_la-ech_lib.Tpo -c -o ecdh/libcrypto_la-ech_lib.lo `test -f 'ecdh/ech_lib.c' || echo '$(srcdir)/'`ecdh/ech_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ecdh/$(DEPDIR)/libcrypto_la-ech_lib.Tpo ecdh/$(DEPDIR)/libcrypto_la-ech_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ecdh/ech_lib.c' object='ecdh/libcrypto_la-ech_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ecdh/libcrypto_la-ech_lib.lo `test -f 'ecdh/ech_lib.c' || echo '$(srcdir)/'`ecdh/ech_lib.c ecdh/libcrypto_la-ech_ossl.lo: ecdh/ech_ossl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ecdh/libcrypto_la-ech_ossl.lo -MD -MP -MF ecdh/$(DEPDIR)/libcrypto_la-ech_ossl.Tpo -c -o ecdh/libcrypto_la-ech_ossl.lo `test -f 'ecdh/ech_ossl.c' || echo '$(srcdir)/'`ecdh/ech_ossl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ecdh/$(DEPDIR)/libcrypto_la-ech_ossl.Tpo ecdh/$(DEPDIR)/libcrypto_la-ech_ossl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ecdh/ech_ossl.c' object='ecdh/libcrypto_la-ech_ossl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ecdh/libcrypto_la-ech_ossl.lo `test -f 'ecdh/ech_ossl.c' || echo '$(srcdir)/'`ecdh/ech_ossl.c ecdsa/libcrypto_la-ecs_asn1.lo: ecdsa/ecs_asn1.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ecdsa/libcrypto_la-ecs_asn1.lo -MD -MP -MF ecdsa/$(DEPDIR)/libcrypto_la-ecs_asn1.Tpo -c -o ecdsa/libcrypto_la-ecs_asn1.lo `test -f 'ecdsa/ecs_asn1.c' || echo '$(srcdir)/'`ecdsa/ecs_asn1.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ecdsa/$(DEPDIR)/libcrypto_la-ecs_asn1.Tpo ecdsa/$(DEPDIR)/libcrypto_la-ecs_asn1.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ecdsa/ecs_asn1.c' object='ecdsa/libcrypto_la-ecs_asn1.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ecdsa/libcrypto_la-ecs_asn1.lo `test -f 'ecdsa/ecs_asn1.c' || echo '$(srcdir)/'`ecdsa/ecs_asn1.c ecdsa/libcrypto_la-ecs_err.lo: ecdsa/ecs_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ecdsa/libcrypto_la-ecs_err.lo -MD -MP -MF ecdsa/$(DEPDIR)/libcrypto_la-ecs_err.Tpo -c -o ecdsa/libcrypto_la-ecs_err.lo `test -f 'ecdsa/ecs_err.c' || echo '$(srcdir)/'`ecdsa/ecs_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ecdsa/$(DEPDIR)/libcrypto_la-ecs_err.Tpo ecdsa/$(DEPDIR)/libcrypto_la-ecs_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ecdsa/ecs_err.c' object='ecdsa/libcrypto_la-ecs_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ecdsa/libcrypto_la-ecs_err.lo `test -f 'ecdsa/ecs_err.c' || echo '$(srcdir)/'`ecdsa/ecs_err.c ecdsa/libcrypto_la-ecs_lib.lo: ecdsa/ecs_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ecdsa/libcrypto_la-ecs_lib.lo -MD -MP -MF ecdsa/$(DEPDIR)/libcrypto_la-ecs_lib.Tpo -c -o ecdsa/libcrypto_la-ecs_lib.lo `test -f 'ecdsa/ecs_lib.c' || echo '$(srcdir)/'`ecdsa/ecs_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ecdsa/$(DEPDIR)/libcrypto_la-ecs_lib.Tpo ecdsa/$(DEPDIR)/libcrypto_la-ecs_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ecdsa/ecs_lib.c' object='ecdsa/libcrypto_la-ecs_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ecdsa/libcrypto_la-ecs_lib.lo `test -f 'ecdsa/ecs_lib.c' || echo '$(srcdir)/'`ecdsa/ecs_lib.c ecdsa/libcrypto_la-ecs_ossl.lo: ecdsa/ecs_ossl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ecdsa/libcrypto_la-ecs_ossl.lo -MD -MP -MF ecdsa/$(DEPDIR)/libcrypto_la-ecs_ossl.Tpo -c -o ecdsa/libcrypto_la-ecs_ossl.lo `test -f 'ecdsa/ecs_ossl.c' || echo '$(srcdir)/'`ecdsa/ecs_ossl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ecdsa/$(DEPDIR)/libcrypto_la-ecs_ossl.Tpo ecdsa/$(DEPDIR)/libcrypto_la-ecs_ossl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ecdsa/ecs_ossl.c' object='ecdsa/libcrypto_la-ecs_ossl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ecdsa/libcrypto_la-ecs_ossl.lo `test -f 'ecdsa/ecs_ossl.c' || echo '$(srcdir)/'`ecdsa/ecs_ossl.c ecdsa/libcrypto_la-ecs_sign.lo: ecdsa/ecs_sign.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ecdsa/libcrypto_la-ecs_sign.lo -MD -MP -MF ecdsa/$(DEPDIR)/libcrypto_la-ecs_sign.Tpo -c -o ecdsa/libcrypto_la-ecs_sign.lo `test -f 'ecdsa/ecs_sign.c' || echo '$(srcdir)/'`ecdsa/ecs_sign.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ecdsa/$(DEPDIR)/libcrypto_la-ecs_sign.Tpo ecdsa/$(DEPDIR)/libcrypto_la-ecs_sign.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ecdsa/ecs_sign.c' object='ecdsa/libcrypto_la-ecs_sign.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ecdsa/libcrypto_la-ecs_sign.lo `test -f 'ecdsa/ecs_sign.c' || echo '$(srcdir)/'`ecdsa/ecs_sign.c ecdsa/libcrypto_la-ecs_vrf.lo: ecdsa/ecs_vrf.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ecdsa/libcrypto_la-ecs_vrf.lo -MD -MP -MF ecdsa/$(DEPDIR)/libcrypto_la-ecs_vrf.Tpo -c -o ecdsa/libcrypto_la-ecs_vrf.lo `test -f 'ecdsa/ecs_vrf.c' || echo '$(srcdir)/'`ecdsa/ecs_vrf.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ecdsa/$(DEPDIR)/libcrypto_la-ecs_vrf.Tpo ecdsa/$(DEPDIR)/libcrypto_la-ecs_vrf.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ecdsa/ecs_vrf.c' object='ecdsa/libcrypto_la-ecs_vrf.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ecdsa/libcrypto_la-ecs_vrf.lo `test -f 'ecdsa/ecs_vrf.c' || echo '$(srcdir)/'`ecdsa/ecs_vrf.c engine/libcrypto_la-eng_all.lo: engine/eng_all.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-eng_all.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-eng_all.Tpo -c -o engine/libcrypto_la-eng_all.lo `test -f 'engine/eng_all.c' || echo '$(srcdir)/'`engine/eng_all.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-eng_all.Tpo engine/$(DEPDIR)/libcrypto_la-eng_all.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/eng_all.c' object='engine/libcrypto_la-eng_all.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-eng_all.lo `test -f 'engine/eng_all.c' || echo '$(srcdir)/'`engine/eng_all.c engine/libcrypto_la-eng_cnf.lo: engine/eng_cnf.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-eng_cnf.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-eng_cnf.Tpo -c -o engine/libcrypto_la-eng_cnf.lo `test -f 'engine/eng_cnf.c' || echo '$(srcdir)/'`engine/eng_cnf.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-eng_cnf.Tpo engine/$(DEPDIR)/libcrypto_la-eng_cnf.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/eng_cnf.c' object='engine/libcrypto_la-eng_cnf.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-eng_cnf.lo `test -f 'engine/eng_cnf.c' || echo '$(srcdir)/'`engine/eng_cnf.c engine/libcrypto_la-eng_ctrl.lo: engine/eng_ctrl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-eng_ctrl.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-eng_ctrl.Tpo -c -o engine/libcrypto_la-eng_ctrl.lo `test -f 'engine/eng_ctrl.c' || echo '$(srcdir)/'`engine/eng_ctrl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-eng_ctrl.Tpo engine/$(DEPDIR)/libcrypto_la-eng_ctrl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/eng_ctrl.c' object='engine/libcrypto_la-eng_ctrl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-eng_ctrl.lo `test -f 'engine/eng_ctrl.c' || echo '$(srcdir)/'`engine/eng_ctrl.c engine/libcrypto_la-eng_dyn.lo: engine/eng_dyn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-eng_dyn.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-eng_dyn.Tpo -c -o engine/libcrypto_la-eng_dyn.lo `test -f 'engine/eng_dyn.c' || echo '$(srcdir)/'`engine/eng_dyn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-eng_dyn.Tpo engine/$(DEPDIR)/libcrypto_la-eng_dyn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/eng_dyn.c' object='engine/libcrypto_la-eng_dyn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-eng_dyn.lo `test -f 'engine/eng_dyn.c' || echo '$(srcdir)/'`engine/eng_dyn.c engine/libcrypto_la-eng_err.lo: engine/eng_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-eng_err.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-eng_err.Tpo -c -o engine/libcrypto_la-eng_err.lo `test -f 'engine/eng_err.c' || echo '$(srcdir)/'`engine/eng_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-eng_err.Tpo engine/$(DEPDIR)/libcrypto_la-eng_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/eng_err.c' object='engine/libcrypto_la-eng_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-eng_err.lo `test -f 'engine/eng_err.c' || echo '$(srcdir)/'`engine/eng_err.c engine/libcrypto_la-eng_fat.lo: engine/eng_fat.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-eng_fat.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-eng_fat.Tpo -c -o engine/libcrypto_la-eng_fat.lo `test -f 'engine/eng_fat.c' || echo '$(srcdir)/'`engine/eng_fat.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-eng_fat.Tpo engine/$(DEPDIR)/libcrypto_la-eng_fat.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/eng_fat.c' object='engine/libcrypto_la-eng_fat.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-eng_fat.lo `test -f 'engine/eng_fat.c' || echo '$(srcdir)/'`engine/eng_fat.c engine/libcrypto_la-eng_init.lo: engine/eng_init.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-eng_init.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-eng_init.Tpo -c -o engine/libcrypto_la-eng_init.lo `test -f 'engine/eng_init.c' || echo '$(srcdir)/'`engine/eng_init.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-eng_init.Tpo engine/$(DEPDIR)/libcrypto_la-eng_init.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/eng_init.c' object='engine/libcrypto_la-eng_init.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-eng_init.lo `test -f 'engine/eng_init.c' || echo '$(srcdir)/'`engine/eng_init.c engine/libcrypto_la-eng_lib.lo: engine/eng_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-eng_lib.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-eng_lib.Tpo -c -o engine/libcrypto_la-eng_lib.lo `test -f 'engine/eng_lib.c' || echo '$(srcdir)/'`engine/eng_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-eng_lib.Tpo engine/$(DEPDIR)/libcrypto_la-eng_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/eng_lib.c' object='engine/libcrypto_la-eng_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-eng_lib.lo `test -f 'engine/eng_lib.c' || echo '$(srcdir)/'`engine/eng_lib.c engine/libcrypto_la-eng_list.lo: engine/eng_list.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-eng_list.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-eng_list.Tpo -c -o engine/libcrypto_la-eng_list.lo `test -f 'engine/eng_list.c' || echo '$(srcdir)/'`engine/eng_list.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-eng_list.Tpo engine/$(DEPDIR)/libcrypto_la-eng_list.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/eng_list.c' object='engine/libcrypto_la-eng_list.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-eng_list.lo `test -f 'engine/eng_list.c' || echo '$(srcdir)/'`engine/eng_list.c engine/libcrypto_la-eng_openssl.lo: engine/eng_openssl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-eng_openssl.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-eng_openssl.Tpo -c -o engine/libcrypto_la-eng_openssl.lo `test -f 'engine/eng_openssl.c' || echo '$(srcdir)/'`engine/eng_openssl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-eng_openssl.Tpo engine/$(DEPDIR)/libcrypto_la-eng_openssl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/eng_openssl.c' object='engine/libcrypto_la-eng_openssl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-eng_openssl.lo `test -f 'engine/eng_openssl.c' || echo '$(srcdir)/'`engine/eng_openssl.c engine/libcrypto_la-eng_pkey.lo: engine/eng_pkey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-eng_pkey.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-eng_pkey.Tpo -c -o engine/libcrypto_la-eng_pkey.lo `test -f 'engine/eng_pkey.c' || echo '$(srcdir)/'`engine/eng_pkey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-eng_pkey.Tpo engine/$(DEPDIR)/libcrypto_la-eng_pkey.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/eng_pkey.c' object='engine/libcrypto_la-eng_pkey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-eng_pkey.lo `test -f 'engine/eng_pkey.c' || echo '$(srcdir)/'`engine/eng_pkey.c engine/libcrypto_la-eng_rsax.lo: engine/eng_rsax.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-eng_rsax.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-eng_rsax.Tpo -c -o engine/libcrypto_la-eng_rsax.lo `test -f 'engine/eng_rsax.c' || echo '$(srcdir)/'`engine/eng_rsax.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-eng_rsax.Tpo engine/$(DEPDIR)/libcrypto_la-eng_rsax.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/eng_rsax.c' object='engine/libcrypto_la-eng_rsax.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-eng_rsax.lo `test -f 'engine/eng_rsax.c' || echo '$(srcdir)/'`engine/eng_rsax.c engine/libcrypto_la-eng_table.lo: engine/eng_table.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-eng_table.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-eng_table.Tpo -c -o engine/libcrypto_la-eng_table.lo `test -f 'engine/eng_table.c' || echo '$(srcdir)/'`engine/eng_table.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-eng_table.Tpo engine/$(DEPDIR)/libcrypto_la-eng_table.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/eng_table.c' object='engine/libcrypto_la-eng_table.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-eng_table.lo `test -f 'engine/eng_table.c' || echo '$(srcdir)/'`engine/eng_table.c engine/libcrypto_la-tb_asnmth.lo: engine/tb_asnmth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-tb_asnmth.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-tb_asnmth.Tpo -c -o engine/libcrypto_la-tb_asnmth.lo `test -f 'engine/tb_asnmth.c' || echo '$(srcdir)/'`engine/tb_asnmth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-tb_asnmth.Tpo engine/$(DEPDIR)/libcrypto_la-tb_asnmth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/tb_asnmth.c' object='engine/libcrypto_la-tb_asnmth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-tb_asnmth.lo `test -f 'engine/tb_asnmth.c' || echo '$(srcdir)/'`engine/tb_asnmth.c engine/libcrypto_la-tb_cipher.lo: engine/tb_cipher.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-tb_cipher.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-tb_cipher.Tpo -c -o engine/libcrypto_la-tb_cipher.lo `test -f 'engine/tb_cipher.c' || echo '$(srcdir)/'`engine/tb_cipher.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-tb_cipher.Tpo engine/$(DEPDIR)/libcrypto_la-tb_cipher.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/tb_cipher.c' object='engine/libcrypto_la-tb_cipher.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-tb_cipher.lo `test -f 'engine/tb_cipher.c' || echo '$(srcdir)/'`engine/tb_cipher.c engine/libcrypto_la-tb_dh.lo: engine/tb_dh.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-tb_dh.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-tb_dh.Tpo -c -o engine/libcrypto_la-tb_dh.lo `test -f 'engine/tb_dh.c' || echo '$(srcdir)/'`engine/tb_dh.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-tb_dh.Tpo engine/$(DEPDIR)/libcrypto_la-tb_dh.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/tb_dh.c' object='engine/libcrypto_la-tb_dh.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-tb_dh.lo `test -f 'engine/tb_dh.c' || echo '$(srcdir)/'`engine/tb_dh.c engine/libcrypto_la-tb_digest.lo: engine/tb_digest.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-tb_digest.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-tb_digest.Tpo -c -o engine/libcrypto_la-tb_digest.lo `test -f 'engine/tb_digest.c' || echo '$(srcdir)/'`engine/tb_digest.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-tb_digest.Tpo engine/$(DEPDIR)/libcrypto_la-tb_digest.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/tb_digest.c' object='engine/libcrypto_la-tb_digest.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-tb_digest.lo `test -f 'engine/tb_digest.c' || echo '$(srcdir)/'`engine/tb_digest.c engine/libcrypto_la-tb_dsa.lo: engine/tb_dsa.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-tb_dsa.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-tb_dsa.Tpo -c -o engine/libcrypto_la-tb_dsa.lo `test -f 'engine/tb_dsa.c' || echo '$(srcdir)/'`engine/tb_dsa.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-tb_dsa.Tpo engine/$(DEPDIR)/libcrypto_la-tb_dsa.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/tb_dsa.c' object='engine/libcrypto_la-tb_dsa.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-tb_dsa.lo `test -f 'engine/tb_dsa.c' || echo '$(srcdir)/'`engine/tb_dsa.c engine/libcrypto_la-tb_ecdh.lo: engine/tb_ecdh.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-tb_ecdh.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-tb_ecdh.Tpo -c -o engine/libcrypto_la-tb_ecdh.lo `test -f 'engine/tb_ecdh.c' || echo '$(srcdir)/'`engine/tb_ecdh.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-tb_ecdh.Tpo engine/$(DEPDIR)/libcrypto_la-tb_ecdh.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/tb_ecdh.c' object='engine/libcrypto_la-tb_ecdh.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-tb_ecdh.lo `test -f 'engine/tb_ecdh.c' || echo '$(srcdir)/'`engine/tb_ecdh.c engine/libcrypto_la-tb_ecdsa.lo: engine/tb_ecdsa.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-tb_ecdsa.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-tb_ecdsa.Tpo -c -o engine/libcrypto_la-tb_ecdsa.lo `test -f 'engine/tb_ecdsa.c' || echo '$(srcdir)/'`engine/tb_ecdsa.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-tb_ecdsa.Tpo engine/$(DEPDIR)/libcrypto_la-tb_ecdsa.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/tb_ecdsa.c' object='engine/libcrypto_la-tb_ecdsa.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-tb_ecdsa.lo `test -f 'engine/tb_ecdsa.c' || echo '$(srcdir)/'`engine/tb_ecdsa.c engine/libcrypto_la-tb_pkmeth.lo: engine/tb_pkmeth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-tb_pkmeth.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-tb_pkmeth.Tpo -c -o engine/libcrypto_la-tb_pkmeth.lo `test -f 'engine/tb_pkmeth.c' || echo '$(srcdir)/'`engine/tb_pkmeth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-tb_pkmeth.Tpo engine/$(DEPDIR)/libcrypto_la-tb_pkmeth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/tb_pkmeth.c' object='engine/libcrypto_la-tb_pkmeth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-tb_pkmeth.lo `test -f 'engine/tb_pkmeth.c' || echo '$(srcdir)/'`engine/tb_pkmeth.c engine/libcrypto_la-tb_rand.lo: engine/tb_rand.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-tb_rand.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-tb_rand.Tpo -c -o engine/libcrypto_la-tb_rand.lo `test -f 'engine/tb_rand.c' || echo '$(srcdir)/'`engine/tb_rand.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-tb_rand.Tpo engine/$(DEPDIR)/libcrypto_la-tb_rand.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/tb_rand.c' object='engine/libcrypto_la-tb_rand.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-tb_rand.lo `test -f 'engine/tb_rand.c' || echo '$(srcdir)/'`engine/tb_rand.c engine/libcrypto_la-tb_rsa.lo: engine/tb_rsa.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-tb_rsa.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-tb_rsa.Tpo -c -o engine/libcrypto_la-tb_rsa.lo `test -f 'engine/tb_rsa.c' || echo '$(srcdir)/'`engine/tb_rsa.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-tb_rsa.Tpo engine/$(DEPDIR)/libcrypto_la-tb_rsa.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/tb_rsa.c' object='engine/libcrypto_la-tb_rsa.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-tb_rsa.lo `test -f 'engine/tb_rsa.c' || echo '$(srcdir)/'`engine/tb_rsa.c engine/libcrypto_la-tb_store.lo: engine/tb_store.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT engine/libcrypto_la-tb_store.lo -MD -MP -MF engine/$(DEPDIR)/libcrypto_la-tb_store.Tpo -c -o engine/libcrypto_la-tb_store.lo `test -f 'engine/tb_store.c' || echo '$(srcdir)/'`engine/tb_store.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) engine/$(DEPDIR)/libcrypto_la-tb_store.Tpo engine/$(DEPDIR)/libcrypto_la-tb_store.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine/tb_store.c' object='engine/libcrypto_la-tb_store.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o engine/libcrypto_la-tb_store.lo `test -f 'engine/tb_store.c' || echo '$(srcdir)/'`engine/tb_store.c err/libcrypto_la-err.lo: err/err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT err/libcrypto_la-err.lo -MD -MP -MF err/$(DEPDIR)/libcrypto_la-err.Tpo -c -o err/libcrypto_la-err.lo `test -f 'err/err.c' || echo '$(srcdir)/'`err/err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) err/$(DEPDIR)/libcrypto_la-err.Tpo err/$(DEPDIR)/libcrypto_la-err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='err/err.c' object='err/libcrypto_la-err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o err/libcrypto_la-err.lo `test -f 'err/err.c' || echo '$(srcdir)/'`err/err.c err/libcrypto_la-err_all.lo: err/err_all.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT err/libcrypto_la-err_all.lo -MD -MP -MF err/$(DEPDIR)/libcrypto_la-err_all.Tpo -c -o err/libcrypto_la-err_all.lo `test -f 'err/err_all.c' || echo '$(srcdir)/'`err/err_all.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) err/$(DEPDIR)/libcrypto_la-err_all.Tpo err/$(DEPDIR)/libcrypto_la-err_all.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='err/err_all.c' object='err/libcrypto_la-err_all.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o err/libcrypto_la-err_all.lo `test -f 'err/err_all.c' || echo '$(srcdir)/'`err/err_all.c err/libcrypto_la-err_prn.lo: err/err_prn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT err/libcrypto_la-err_prn.lo -MD -MP -MF err/$(DEPDIR)/libcrypto_la-err_prn.Tpo -c -o err/libcrypto_la-err_prn.lo `test -f 'err/err_prn.c' || echo '$(srcdir)/'`err/err_prn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) err/$(DEPDIR)/libcrypto_la-err_prn.Tpo err/$(DEPDIR)/libcrypto_la-err_prn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='err/err_prn.c' object='err/libcrypto_la-err_prn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o err/libcrypto_la-err_prn.lo `test -f 'err/err_prn.c' || echo '$(srcdir)/'`err/err_prn.c evp/libcrypto_la-bio_b64.lo: evp/bio_b64.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-bio_b64.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-bio_b64.Tpo -c -o evp/libcrypto_la-bio_b64.lo `test -f 'evp/bio_b64.c' || echo '$(srcdir)/'`evp/bio_b64.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-bio_b64.Tpo evp/$(DEPDIR)/libcrypto_la-bio_b64.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/bio_b64.c' object='evp/libcrypto_la-bio_b64.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-bio_b64.lo `test -f 'evp/bio_b64.c' || echo '$(srcdir)/'`evp/bio_b64.c evp/libcrypto_la-bio_enc.lo: evp/bio_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-bio_enc.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-bio_enc.Tpo -c -o evp/libcrypto_la-bio_enc.lo `test -f 'evp/bio_enc.c' || echo '$(srcdir)/'`evp/bio_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-bio_enc.Tpo evp/$(DEPDIR)/libcrypto_la-bio_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/bio_enc.c' object='evp/libcrypto_la-bio_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-bio_enc.lo `test -f 'evp/bio_enc.c' || echo '$(srcdir)/'`evp/bio_enc.c evp/libcrypto_la-bio_md.lo: evp/bio_md.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-bio_md.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-bio_md.Tpo -c -o evp/libcrypto_la-bio_md.lo `test -f 'evp/bio_md.c' || echo '$(srcdir)/'`evp/bio_md.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-bio_md.Tpo evp/$(DEPDIR)/libcrypto_la-bio_md.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/bio_md.c' object='evp/libcrypto_la-bio_md.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-bio_md.lo `test -f 'evp/bio_md.c' || echo '$(srcdir)/'`evp/bio_md.c evp/libcrypto_la-c_all.lo: evp/c_all.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-c_all.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-c_all.Tpo -c -o evp/libcrypto_la-c_all.lo `test -f 'evp/c_all.c' || echo '$(srcdir)/'`evp/c_all.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-c_all.Tpo evp/$(DEPDIR)/libcrypto_la-c_all.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/c_all.c' object='evp/libcrypto_la-c_all.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-c_all.lo `test -f 'evp/c_all.c' || echo '$(srcdir)/'`evp/c_all.c evp/libcrypto_la-c_allc.lo: evp/c_allc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-c_allc.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-c_allc.Tpo -c -o evp/libcrypto_la-c_allc.lo `test -f 'evp/c_allc.c' || echo '$(srcdir)/'`evp/c_allc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-c_allc.Tpo evp/$(DEPDIR)/libcrypto_la-c_allc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/c_allc.c' object='evp/libcrypto_la-c_allc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-c_allc.lo `test -f 'evp/c_allc.c' || echo '$(srcdir)/'`evp/c_allc.c evp/libcrypto_la-c_alld.lo: evp/c_alld.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-c_alld.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-c_alld.Tpo -c -o evp/libcrypto_la-c_alld.lo `test -f 'evp/c_alld.c' || echo '$(srcdir)/'`evp/c_alld.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-c_alld.Tpo evp/$(DEPDIR)/libcrypto_la-c_alld.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/c_alld.c' object='evp/libcrypto_la-c_alld.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-c_alld.lo `test -f 'evp/c_alld.c' || echo '$(srcdir)/'`evp/c_alld.c evp/libcrypto_la-digest.lo: evp/digest.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-digest.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-digest.Tpo -c -o evp/libcrypto_la-digest.lo `test -f 'evp/digest.c' || echo '$(srcdir)/'`evp/digest.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-digest.Tpo evp/$(DEPDIR)/libcrypto_la-digest.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/digest.c' object='evp/libcrypto_la-digest.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-digest.lo `test -f 'evp/digest.c' || echo '$(srcdir)/'`evp/digest.c evp/libcrypto_la-e_aes.lo: evp/e_aes.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-e_aes.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-e_aes.Tpo -c -o evp/libcrypto_la-e_aes.lo `test -f 'evp/e_aes.c' || echo '$(srcdir)/'`evp/e_aes.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-e_aes.Tpo evp/$(DEPDIR)/libcrypto_la-e_aes.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/e_aes.c' object='evp/libcrypto_la-e_aes.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-e_aes.lo `test -f 'evp/e_aes.c' || echo '$(srcdir)/'`evp/e_aes.c evp/libcrypto_la-e_aes_cbc_hmac_sha1.lo: evp/e_aes_cbc_hmac_sha1.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-e_aes_cbc_hmac_sha1.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-e_aes_cbc_hmac_sha1.Tpo -c -o evp/libcrypto_la-e_aes_cbc_hmac_sha1.lo `test -f 'evp/e_aes_cbc_hmac_sha1.c' || echo '$(srcdir)/'`evp/e_aes_cbc_hmac_sha1.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-e_aes_cbc_hmac_sha1.Tpo evp/$(DEPDIR)/libcrypto_la-e_aes_cbc_hmac_sha1.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/e_aes_cbc_hmac_sha1.c' object='evp/libcrypto_la-e_aes_cbc_hmac_sha1.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-e_aes_cbc_hmac_sha1.lo `test -f 'evp/e_aes_cbc_hmac_sha1.c' || echo '$(srcdir)/'`evp/e_aes_cbc_hmac_sha1.c evp/libcrypto_la-e_bf.lo: evp/e_bf.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-e_bf.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-e_bf.Tpo -c -o evp/libcrypto_la-e_bf.lo `test -f 'evp/e_bf.c' || echo '$(srcdir)/'`evp/e_bf.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-e_bf.Tpo evp/$(DEPDIR)/libcrypto_la-e_bf.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/e_bf.c' object='evp/libcrypto_la-e_bf.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-e_bf.lo `test -f 'evp/e_bf.c' || echo '$(srcdir)/'`evp/e_bf.c evp/libcrypto_la-e_cast.lo: evp/e_cast.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-e_cast.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-e_cast.Tpo -c -o evp/libcrypto_la-e_cast.lo `test -f 'evp/e_cast.c' || echo '$(srcdir)/'`evp/e_cast.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-e_cast.Tpo evp/$(DEPDIR)/libcrypto_la-e_cast.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/e_cast.c' object='evp/libcrypto_la-e_cast.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-e_cast.lo `test -f 'evp/e_cast.c' || echo '$(srcdir)/'`evp/e_cast.c evp/libcrypto_la-e_chacha.lo: evp/e_chacha.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-e_chacha.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-e_chacha.Tpo -c -o evp/libcrypto_la-e_chacha.lo `test -f 'evp/e_chacha.c' || echo '$(srcdir)/'`evp/e_chacha.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-e_chacha.Tpo evp/$(DEPDIR)/libcrypto_la-e_chacha.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/e_chacha.c' object='evp/libcrypto_la-e_chacha.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-e_chacha.lo `test -f 'evp/e_chacha.c' || echo '$(srcdir)/'`evp/e_chacha.c evp/libcrypto_la-e_chacha20poly1305.lo: evp/e_chacha20poly1305.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-e_chacha20poly1305.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-e_chacha20poly1305.Tpo -c -o evp/libcrypto_la-e_chacha20poly1305.lo `test -f 'evp/e_chacha20poly1305.c' || echo '$(srcdir)/'`evp/e_chacha20poly1305.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-e_chacha20poly1305.Tpo evp/$(DEPDIR)/libcrypto_la-e_chacha20poly1305.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/e_chacha20poly1305.c' object='evp/libcrypto_la-e_chacha20poly1305.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-e_chacha20poly1305.lo `test -f 'evp/e_chacha20poly1305.c' || echo '$(srcdir)/'`evp/e_chacha20poly1305.c evp/libcrypto_la-e_des.lo: evp/e_des.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-e_des.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-e_des.Tpo -c -o evp/libcrypto_la-e_des.lo `test -f 'evp/e_des.c' || echo '$(srcdir)/'`evp/e_des.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-e_des.Tpo evp/$(DEPDIR)/libcrypto_la-e_des.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/e_des.c' object='evp/libcrypto_la-e_des.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-e_des.lo `test -f 'evp/e_des.c' || echo '$(srcdir)/'`evp/e_des.c evp/libcrypto_la-e_des3.lo: evp/e_des3.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-e_des3.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-e_des3.Tpo -c -o evp/libcrypto_la-e_des3.lo `test -f 'evp/e_des3.c' || echo '$(srcdir)/'`evp/e_des3.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-e_des3.Tpo evp/$(DEPDIR)/libcrypto_la-e_des3.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/e_des3.c' object='evp/libcrypto_la-e_des3.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-e_des3.lo `test -f 'evp/e_des3.c' || echo '$(srcdir)/'`evp/e_des3.c evp/libcrypto_la-e_idea.lo: evp/e_idea.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-e_idea.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-e_idea.Tpo -c -o evp/libcrypto_la-e_idea.lo `test -f 'evp/e_idea.c' || echo '$(srcdir)/'`evp/e_idea.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-e_idea.Tpo evp/$(DEPDIR)/libcrypto_la-e_idea.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/e_idea.c' object='evp/libcrypto_la-e_idea.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-e_idea.lo `test -f 'evp/e_idea.c' || echo '$(srcdir)/'`evp/e_idea.c evp/libcrypto_la-e_null.lo: evp/e_null.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-e_null.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-e_null.Tpo -c -o evp/libcrypto_la-e_null.lo `test -f 'evp/e_null.c' || echo '$(srcdir)/'`evp/e_null.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-e_null.Tpo evp/$(DEPDIR)/libcrypto_la-e_null.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/e_null.c' object='evp/libcrypto_la-e_null.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-e_null.lo `test -f 'evp/e_null.c' || echo '$(srcdir)/'`evp/e_null.c evp/libcrypto_la-e_old.lo: evp/e_old.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-e_old.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-e_old.Tpo -c -o evp/libcrypto_la-e_old.lo `test -f 'evp/e_old.c' || echo '$(srcdir)/'`evp/e_old.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-e_old.Tpo evp/$(DEPDIR)/libcrypto_la-e_old.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/e_old.c' object='evp/libcrypto_la-e_old.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-e_old.lo `test -f 'evp/e_old.c' || echo '$(srcdir)/'`evp/e_old.c evp/libcrypto_la-e_rc2.lo: evp/e_rc2.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-e_rc2.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-e_rc2.Tpo -c -o evp/libcrypto_la-e_rc2.lo `test -f 'evp/e_rc2.c' || echo '$(srcdir)/'`evp/e_rc2.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-e_rc2.Tpo evp/$(DEPDIR)/libcrypto_la-e_rc2.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/e_rc2.c' object='evp/libcrypto_la-e_rc2.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-e_rc2.lo `test -f 'evp/e_rc2.c' || echo '$(srcdir)/'`evp/e_rc2.c evp/libcrypto_la-e_rc4.lo: evp/e_rc4.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-e_rc4.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-e_rc4.Tpo -c -o evp/libcrypto_la-e_rc4.lo `test -f 'evp/e_rc4.c' || echo '$(srcdir)/'`evp/e_rc4.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-e_rc4.Tpo evp/$(DEPDIR)/libcrypto_la-e_rc4.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/e_rc4.c' object='evp/libcrypto_la-e_rc4.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-e_rc4.lo `test -f 'evp/e_rc4.c' || echo '$(srcdir)/'`evp/e_rc4.c evp/libcrypto_la-e_rc4_hmac_md5.lo: evp/e_rc4_hmac_md5.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-e_rc4_hmac_md5.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-e_rc4_hmac_md5.Tpo -c -o evp/libcrypto_la-e_rc4_hmac_md5.lo `test -f 'evp/e_rc4_hmac_md5.c' || echo '$(srcdir)/'`evp/e_rc4_hmac_md5.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-e_rc4_hmac_md5.Tpo evp/$(DEPDIR)/libcrypto_la-e_rc4_hmac_md5.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/e_rc4_hmac_md5.c' object='evp/libcrypto_la-e_rc4_hmac_md5.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-e_rc4_hmac_md5.lo `test -f 'evp/e_rc4_hmac_md5.c' || echo '$(srcdir)/'`evp/e_rc4_hmac_md5.c evp/libcrypto_la-e_xcbc_d.lo: evp/e_xcbc_d.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-e_xcbc_d.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-e_xcbc_d.Tpo -c -o evp/libcrypto_la-e_xcbc_d.lo `test -f 'evp/e_xcbc_d.c' || echo '$(srcdir)/'`evp/e_xcbc_d.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-e_xcbc_d.Tpo evp/$(DEPDIR)/libcrypto_la-e_xcbc_d.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/e_xcbc_d.c' object='evp/libcrypto_la-e_xcbc_d.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-e_xcbc_d.lo `test -f 'evp/e_xcbc_d.c' || echo '$(srcdir)/'`evp/e_xcbc_d.c evp/libcrypto_la-encode.lo: evp/encode.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-encode.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-encode.Tpo -c -o evp/libcrypto_la-encode.lo `test -f 'evp/encode.c' || echo '$(srcdir)/'`evp/encode.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-encode.Tpo evp/$(DEPDIR)/libcrypto_la-encode.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/encode.c' object='evp/libcrypto_la-encode.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-encode.lo `test -f 'evp/encode.c' || echo '$(srcdir)/'`evp/encode.c evp/libcrypto_la-evp_aead.lo: evp/evp_aead.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-evp_aead.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-evp_aead.Tpo -c -o evp/libcrypto_la-evp_aead.lo `test -f 'evp/evp_aead.c' || echo '$(srcdir)/'`evp/evp_aead.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-evp_aead.Tpo evp/$(DEPDIR)/libcrypto_la-evp_aead.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/evp_aead.c' object='evp/libcrypto_la-evp_aead.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-evp_aead.lo `test -f 'evp/evp_aead.c' || echo '$(srcdir)/'`evp/evp_aead.c evp/libcrypto_la-evp_enc.lo: evp/evp_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-evp_enc.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-evp_enc.Tpo -c -o evp/libcrypto_la-evp_enc.lo `test -f 'evp/evp_enc.c' || echo '$(srcdir)/'`evp/evp_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-evp_enc.Tpo evp/$(DEPDIR)/libcrypto_la-evp_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/evp_enc.c' object='evp/libcrypto_la-evp_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-evp_enc.lo `test -f 'evp/evp_enc.c' || echo '$(srcdir)/'`evp/evp_enc.c evp/libcrypto_la-evp_err.lo: evp/evp_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-evp_err.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-evp_err.Tpo -c -o evp/libcrypto_la-evp_err.lo `test -f 'evp/evp_err.c' || echo '$(srcdir)/'`evp/evp_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-evp_err.Tpo evp/$(DEPDIR)/libcrypto_la-evp_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/evp_err.c' object='evp/libcrypto_la-evp_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-evp_err.lo `test -f 'evp/evp_err.c' || echo '$(srcdir)/'`evp/evp_err.c evp/libcrypto_la-evp_key.lo: evp/evp_key.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-evp_key.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-evp_key.Tpo -c -o evp/libcrypto_la-evp_key.lo `test -f 'evp/evp_key.c' || echo '$(srcdir)/'`evp/evp_key.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-evp_key.Tpo evp/$(DEPDIR)/libcrypto_la-evp_key.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/evp_key.c' object='evp/libcrypto_la-evp_key.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-evp_key.lo `test -f 'evp/evp_key.c' || echo '$(srcdir)/'`evp/evp_key.c evp/libcrypto_la-evp_lib.lo: evp/evp_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-evp_lib.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-evp_lib.Tpo -c -o evp/libcrypto_la-evp_lib.lo `test -f 'evp/evp_lib.c' || echo '$(srcdir)/'`evp/evp_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-evp_lib.Tpo evp/$(DEPDIR)/libcrypto_la-evp_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/evp_lib.c' object='evp/libcrypto_la-evp_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-evp_lib.lo `test -f 'evp/evp_lib.c' || echo '$(srcdir)/'`evp/evp_lib.c evp/libcrypto_la-evp_pbe.lo: evp/evp_pbe.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-evp_pbe.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-evp_pbe.Tpo -c -o evp/libcrypto_la-evp_pbe.lo `test -f 'evp/evp_pbe.c' || echo '$(srcdir)/'`evp/evp_pbe.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-evp_pbe.Tpo evp/$(DEPDIR)/libcrypto_la-evp_pbe.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/evp_pbe.c' object='evp/libcrypto_la-evp_pbe.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-evp_pbe.lo `test -f 'evp/evp_pbe.c' || echo '$(srcdir)/'`evp/evp_pbe.c evp/libcrypto_la-evp_pkey.lo: evp/evp_pkey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-evp_pkey.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-evp_pkey.Tpo -c -o evp/libcrypto_la-evp_pkey.lo `test -f 'evp/evp_pkey.c' || echo '$(srcdir)/'`evp/evp_pkey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-evp_pkey.Tpo evp/$(DEPDIR)/libcrypto_la-evp_pkey.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/evp_pkey.c' object='evp/libcrypto_la-evp_pkey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-evp_pkey.lo `test -f 'evp/evp_pkey.c' || echo '$(srcdir)/'`evp/evp_pkey.c evp/libcrypto_la-m_dss.lo: evp/m_dss.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-m_dss.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-m_dss.Tpo -c -o evp/libcrypto_la-m_dss.lo `test -f 'evp/m_dss.c' || echo '$(srcdir)/'`evp/m_dss.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-m_dss.Tpo evp/$(DEPDIR)/libcrypto_la-m_dss.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/m_dss.c' object='evp/libcrypto_la-m_dss.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-m_dss.lo `test -f 'evp/m_dss.c' || echo '$(srcdir)/'`evp/m_dss.c evp/libcrypto_la-m_dss1.lo: evp/m_dss1.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-m_dss1.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-m_dss1.Tpo -c -o evp/libcrypto_la-m_dss1.lo `test -f 'evp/m_dss1.c' || echo '$(srcdir)/'`evp/m_dss1.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-m_dss1.Tpo evp/$(DEPDIR)/libcrypto_la-m_dss1.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/m_dss1.c' object='evp/libcrypto_la-m_dss1.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-m_dss1.lo `test -f 'evp/m_dss1.c' || echo '$(srcdir)/'`evp/m_dss1.c evp/libcrypto_la-m_ecdsa.lo: evp/m_ecdsa.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-m_ecdsa.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-m_ecdsa.Tpo -c -o evp/libcrypto_la-m_ecdsa.lo `test -f 'evp/m_ecdsa.c' || echo '$(srcdir)/'`evp/m_ecdsa.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-m_ecdsa.Tpo evp/$(DEPDIR)/libcrypto_la-m_ecdsa.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/m_ecdsa.c' object='evp/libcrypto_la-m_ecdsa.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-m_ecdsa.lo `test -f 'evp/m_ecdsa.c' || echo '$(srcdir)/'`evp/m_ecdsa.c evp/libcrypto_la-m_md4.lo: evp/m_md4.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-m_md4.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-m_md4.Tpo -c -o evp/libcrypto_la-m_md4.lo `test -f 'evp/m_md4.c' || echo '$(srcdir)/'`evp/m_md4.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-m_md4.Tpo evp/$(DEPDIR)/libcrypto_la-m_md4.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/m_md4.c' object='evp/libcrypto_la-m_md4.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-m_md4.lo `test -f 'evp/m_md4.c' || echo '$(srcdir)/'`evp/m_md4.c evp/libcrypto_la-m_md5.lo: evp/m_md5.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-m_md5.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-m_md5.Tpo -c -o evp/libcrypto_la-m_md5.lo `test -f 'evp/m_md5.c' || echo '$(srcdir)/'`evp/m_md5.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-m_md5.Tpo evp/$(DEPDIR)/libcrypto_la-m_md5.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/m_md5.c' object='evp/libcrypto_la-m_md5.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-m_md5.lo `test -f 'evp/m_md5.c' || echo '$(srcdir)/'`evp/m_md5.c evp/libcrypto_la-m_mdc2.lo: evp/m_mdc2.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-m_mdc2.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-m_mdc2.Tpo -c -o evp/libcrypto_la-m_mdc2.lo `test -f 'evp/m_mdc2.c' || echo '$(srcdir)/'`evp/m_mdc2.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-m_mdc2.Tpo evp/$(DEPDIR)/libcrypto_la-m_mdc2.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/m_mdc2.c' object='evp/libcrypto_la-m_mdc2.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-m_mdc2.lo `test -f 'evp/m_mdc2.c' || echo '$(srcdir)/'`evp/m_mdc2.c evp/libcrypto_la-m_null.lo: evp/m_null.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-m_null.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-m_null.Tpo -c -o evp/libcrypto_la-m_null.lo `test -f 'evp/m_null.c' || echo '$(srcdir)/'`evp/m_null.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-m_null.Tpo evp/$(DEPDIR)/libcrypto_la-m_null.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/m_null.c' object='evp/libcrypto_la-m_null.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-m_null.lo `test -f 'evp/m_null.c' || echo '$(srcdir)/'`evp/m_null.c evp/libcrypto_la-m_ripemd.lo: evp/m_ripemd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-m_ripemd.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-m_ripemd.Tpo -c -o evp/libcrypto_la-m_ripemd.lo `test -f 'evp/m_ripemd.c' || echo '$(srcdir)/'`evp/m_ripemd.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-m_ripemd.Tpo evp/$(DEPDIR)/libcrypto_la-m_ripemd.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/m_ripemd.c' object='evp/libcrypto_la-m_ripemd.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-m_ripemd.lo `test -f 'evp/m_ripemd.c' || echo '$(srcdir)/'`evp/m_ripemd.c evp/libcrypto_la-m_sha.lo: evp/m_sha.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-m_sha.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-m_sha.Tpo -c -o evp/libcrypto_la-m_sha.lo `test -f 'evp/m_sha.c' || echo '$(srcdir)/'`evp/m_sha.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-m_sha.Tpo evp/$(DEPDIR)/libcrypto_la-m_sha.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/m_sha.c' object='evp/libcrypto_la-m_sha.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-m_sha.lo `test -f 'evp/m_sha.c' || echo '$(srcdir)/'`evp/m_sha.c evp/libcrypto_la-m_sha1.lo: evp/m_sha1.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-m_sha1.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-m_sha1.Tpo -c -o evp/libcrypto_la-m_sha1.lo `test -f 'evp/m_sha1.c' || echo '$(srcdir)/'`evp/m_sha1.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-m_sha1.Tpo evp/$(DEPDIR)/libcrypto_la-m_sha1.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/m_sha1.c' object='evp/libcrypto_la-m_sha1.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-m_sha1.lo `test -f 'evp/m_sha1.c' || echo '$(srcdir)/'`evp/m_sha1.c evp/libcrypto_la-m_sigver.lo: evp/m_sigver.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-m_sigver.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-m_sigver.Tpo -c -o evp/libcrypto_la-m_sigver.lo `test -f 'evp/m_sigver.c' || echo '$(srcdir)/'`evp/m_sigver.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-m_sigver.Tpo evp/$(DEPDIR)/libcrypto_la-m_sigver.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/m_sigver.c' object='evp/libcrypto_la-m_sigver.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-m_sigver.lo `test -f 'evp/m_sigver.c' || echo '$(srcdir)/'`evp/m_sigver.c evp/libcrypto_la-m_wp.lo: evp/m_wp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-m_wp.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-m_wp.Tpo -c -o evp/libcrypto_la-m_wp.lo `test -f 'evp/m_wp.c' || echo '$(srcdir)/'`evp/m_wp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-m_wp.Tpo evp/$(DEPDIR)/libcrypto_la-m_wp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/m_wp.c' object='evp/libcrypto_la-m_wp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-m_wp.lo `test -f 'evp/m_wp.c' || echo '$(srcdir)/'`evp/m_wp.c evp/libcrypto_la-names.lo: evp/names.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-names.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-names.Tpo -c -o evp/libcrypto_la-names.lo `test -f 'evp/names.c' || echo '$(srcdir)/'`evp/names.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-names.Tpo evp/$(DEPDIR)/libcrypto_la-names.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/names.c' object='evp/libcrypto_la-names.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-names.lo `test -f 'evp/names.c' || echo '$(srcdir)/'`evp/names.c evp/libcrypto_la-p5_crpt.lo: evp/p5_crpt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-p5_crpt.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-p5_crpt.Tpo -c -o evp/libcrypto_la-p5_crpt.lo `test -f 'evp/p5_crpt.c' || echo '$(srcdir)/'`evp/p5_crpt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-p5_crpt.Tpo evp/$(DEPDIR)/libcrypto_la-p5_crpt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/p5_crpt.c' object='evp/libcrypto_la-p5_crpt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-p5_crpt.lo `test -f 'evp/p5_crpt.c' || echo '$(srcdir)/'`evp/p5_crpt.c evp/libcrypto_la-p5_crpt2.lo: evp/p5_crpt2.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-p5_crpt2.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-p5_crpt2.Tpo -c -o evp/libcrypto_la-p5_crpt2.lo `test -f 'evp/p5_crpt2.c' || echo '$(srcdir)/'`evp/p5_crpt2.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-p5_crpt2.Tpo evp/$(DEPDIR)/libcrypto_la-p5_crpt2.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/p5_crpt2.c' object='evp/libcrypto_la-p5_crpt2.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-p5_crpt2.lo `test -f 'evp/p5_crpt2.c' || echo '$(srcdir)/'`evp/p5_crpt2.c evp/libcrypto_la-p_dec.lo: evp/p_dec.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-p_dec.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-p_dec.Tpo -c -o evp/libcrypto_la-p_dec.lo `test -f 'evp/p_dec.c' || echo '$(srcdir)/'`evp/p_dec.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-p_dec.Tpo evp/$(DEPDIR)/libcrypto_la-p_dec.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/p_dec.c' object='evp/libcrypto_la-p_dec.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-p_dec.lo `test -f 'evp/p_dec.c' || echo '$(srcdir)/'`evp/p_dec.c evp/libcrypto_la-p_enc.lo: evp/p_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-p_enc.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-p_enc.Tpo -c -o evp/libcrypto_la-p_enc.lo `test -f 'evp/p_enc.c' || echo '$(srcdir)/'`evp/p_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-p_enc.Tpo evp/$(DEPDIR)/libcrypto_la-p_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/p_enc.c' object='evp/libcrypto_la-p_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-p_enc.lo `test -f 'evp/p_enc.c' || echo '$(srcdir)/'`evp/p_enc.c evp/libcrypto_la-p_lib.lo: evp/p_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-p_lib.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-p_lib.Tpo -c -o evp/libcrypto_la-p_lib.lo `test -f 'evp/p_lib.c' || echo '$(srcdir)/'`evp/p_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-p_lib.Tpo evp/$(DEPDIR)/libcrypto_la-p_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/p_lib.c' object='evp/libcrypto_la-p_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-p_lib.lo `test -f 'evp/p_lib.c' || echo '$(srcdir)/'`evp/p_lib.c evp/libcrypto_la-p_open.lo: evp/p_open.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-p_open.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-p_open.Tpo -c -o evp/libcrypto_la-p_open.lo `test -f 'evp/p_open.c' || echo '$(srcdir)/'`evp/p_open.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-p_open.Tpo evp/$(DEPDIR)/libcrypto_la-p_open.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/p_open.c' object='evp/libcrypto_la-p_open.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-p_open.lo `test -f 'evp/p_open.c' || echo '$(srcdir)/'`evp/p_open.c evp/libcrypto_la-p_seal.lo: evp/p_seal.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-p_seal.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-p_seal.Tpo -c -o evp/libcrypto_la-p_seal.lo `test -f 'evp/p_seal.c' || echo '$(srcdir)/'`evp/p_seal.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-p_seal.Tpo evp/$(DEPDIR)/libcrypto_la-p_seal.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/p_seal.c' object='evp/libcrypto_la-p_seal.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-p_seal.lo `test -f 'evp/p_seal.c' || echo '$(srcdir)/'`evp/p_seal.c evp/libcrypto_la-p_sign.lo: evp/p_sign.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-p_sign.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-p_sign.Tpo -c -o evp/libcrypto_la-p_sign.lo `test -f 'evp/p_sign.c' || echo '$(srcdir)/'`evp/p_sign.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-p_sign.Tpo evp/$(DEPDIR)/libcrypto_la-p_sign.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/p_sign.c' object='evp/libcrypto_la-p_sign.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-p_sign.lo `test -f 'evp/p_sign.c' || echo '$(srcdir)/'`evp/p_sign.c evp/libcrypto_la-p_verify.lo: evp/p_verify.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-p_verify.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-p_verify.Tpo -c -o evp/libcrypto_la-p_verify.lo `test -f 'evp/p_verify.c' || echo '$(srcdir)/'`evp/p_verify.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-p_verify.Tpo evp/$(DEPDIR)/libcrypto_la-p_verify.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/p_verify.c' object='evp/libcrypto_la-p_verify.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-p_verify.lo `test -f 'evp/p_verify.c' || echo '$(srcdir)/'`evp/p_verify.c evp/libcrypto_la-pmeth_fn.lo: evp/pmeth_fn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-pmeth_fn.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-pmeth_fn.Tpo -c -o evp/libcrypto_la-pmeth_fn.lo `test -f 'evp/pmeth_fn.c' || echo '$(srcdir)/'`evp/pmeth_fn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-pmeth_fn.Tpo evp/$(DEPDIR)/libcrypto_la-pmeth_fn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/pmeth_fn.c' object='evp/libcrypto_la-pmeth_fn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-pmeth_fn.lo `test -f 'evp/pmeth_fn.c' || echo '$(srcdir)/'`evp/pmeth_fn.c evp/libcrypto_la-pmeth_gn.lo: evp/pmeth_gn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-pmeth_gn.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-pmeth_gn.Tpo -c -o evp/libcrypto_la-pmeth_gn.lo `test -f 'evp/pmeth_gn.c' || echo '$(srcdir)/'`evp/pmeth_gn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-pmeth_gn.Tpo evp/$(DEPDIR)/libcrypto_la-pmeth_gn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/pmeth_gn.c' object='evp/libcrypto_la-pmeth_gn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-pmeth_gn.lo `test -f 'evp/pmeth_gn.c' || echo '$(srcdir)/'`evp/pmeth_gn.c evp/libcrypto_la-pmeth_lib.lo: evp/pmeth_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-pmeth_lib.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-pmeth_lib.Tpo -c -o evp/libcrypto_la-pmeth_lib.lo `test -f 'evp/pmeth_lib.c' || echo '$(srcdir)/'`evp/pmeth_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-pmeth_lib.Tpo evp/$(DEPDIR)/libcrypto_la-pmeth_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/pmeth_lib.c' object='evp/libcrypto_la-pmeth_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-pmeth_lib.lo `test -f 'evp/pmeth_lib.c' || echo '$(srcdir)/'`evp/pmeth_lib.c hmac/libcrypto_la-hm_ameth.lo: hmac/hm_ameth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT hmac/libcrypto_la-hm_ameth.lo -MD -MP -MF hmac/$(DEPDIR)/libcrypto_la-hm_ameth.Tpo -c -o hmac/libcrypto_la-hm_ameth.lo `test -f 'hmac/hm_ameth.c' || echo '$(srcdir)/'`hmac/hm_ameth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) hmac/$(DEPDIR)/libcrypto_la-hm_ameth.Tpo hmac/$(DEPDIR)/libcrypto_la-hm_ameth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hmac/hm_ameth.c' object='hmac/libcrypto_la-hm_ameth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o hmac/libcrypto_la-hm_ameth.lo `test -f 'hmac/hm_ameth.c' || echo '$(srcdir)/'`hmac/hm_ameth.c hmac/libcrypto_la-hm_pmeth.lo: hmac/hm_pmeth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT hmac/libcrypto_la-hm_pmeth.lo -MD -MP -MF hmac/$(DEPDIR)/libcrypto_la-hm_pmeth.Tpo -c -o hmac/libcrypto_la-hm_pmeth.lo `test -f 'hmac/hm_pmeth.c' || echo '$(srcdir)/'`hmac/hm_pmeth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) hmac/$(DEPDIR)/libcrypto_la-hm_pmeth.Tpo hmac/$(DEPDIR)/libcrypto_la-hm_pmeth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hmac/hm_pmeth.c' object='hmac/libcrypto_la-hm_pmeth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o hmac/libcrypto_la-hm_pmeth.lo `test -f 'hmac/hm_pmeth.c' || echo '$(srcdir)/'`hmac/hm_pmeth.c hmac/libcrypto_la-hmac.lo: hmac/hmac.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT hmac/libcrypto_la-hmac.lo -MD -MP -MF hmac/$(DEPDIR)/libcrypto_la-hmac.Tpo -c -o hmac/libcrypto_la-hmac.lo `test -f 'hmac/hmac.c' || echo '$(srcdir)/'`hmac/hmac.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) hmac/$(DEPDIR)/libcrypto_la-hmac.Tpo hmac/$(DEPDIR)/libcrypto_la-hmac.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hmac/hmac.c' object='hmac/libcrypto_la-hmac.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o hmac/libcrypto_la-hmac.lo `test -f 'hmac/hmac.c' || echo '$(srcdir)/'`hmac/hmac.c idea/libcrypto_la-i_cbc.lo: idea/i_cbc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT idea/libcrypto_la-i_cbc.lo -MD -MP -MF idea/$(DEPDIR)/libcrypto_la-i_cbc.Tpo -c -o idea/libcrypto_la-i_cbc.lo `test -f 'idea/i_cbc.c' || echo '$(srcdir)/'`idea/i_cbc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) idea/$(DEPDIR)/libcrypto_la-i_cbc.Tpo idea/$(DEPDIR)/libcrypto_la-i_cbc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='idea/i_cbc.c' object='idea/libcrypto_la-i_cbc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o idea/libcrypto_la-i_cbc.lo `test -f 'idea/i_cbc.c' || echo '$(srcdir)/'`idea/i_cbc.c idea/libcrypto_la-i_cfb64.lo: idea/i_cfb64.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT idea/libcrypto_la-i_cfb64.lo -MD -MP -MF idea/$(DEPDIR)/libcrypto_la-i_cfb64.Tpo -c -o idea/libcrypto_la-i_cfb64.lo `test -f 'idea/i_cfb64.c' || echo '$(srcdir)/'`idea/i_cfb64.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) idea/$(DEPDIR)/libcrypto_la-i_cfb64.Tpo idea/$(DEPDIR)/libcrypto_la-i_cfb64.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='idea/i_cfb64.c' object='idea/libcrypto_la-i_cfb64.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o idea/libcrypto_la-i_cfb64.lo `test -f 'idea/i_cfb64.c' || echo '$(srcdir)/'`idea/i_cfb64.c idea/libcrypto_la-i_ecb.lo: idea/i_ecb.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT idea/libcrypto_la-i_ecb.lo -MD -MP -MF idea/$(DEPDIR)/libcrypto_la-i_ecb.Tpo -c -o idea/libcrypto_la-i_ecb.lo `test -f 'idea/i_ecb.c' || echo '$(srcdir)/'`idea/i_ecb.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) idea/$(DEPDIR)/libcrypto_la-i_ecb.Tpo idea/$(DEPDIR)/libcrypto_la-i_ecb.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='idea/i_ecb.c' object='idea/libcrypto_la-i_ecb.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o idea/libcrypto_la-i_ecb.lo `test -f 'idea/i_ecb.c' || echo '$(srcdir)/'`idea/i_ecb.c idea/libcrypto_la-i_ofb64.lo: idea/i_ofb64.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT idea/libcrypto_la-i_ofb64.lo -MD -MP -MF idea/$(DEPDIR)/libcrypto_la-i_ofb64.Tpo -c -o idea/libcrypto_la-i_ofb64.lo `test -f 'idea/i_ofb64.c' || echo '$(srcdir)/'`idea/i_ofb64.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) idea/$(DEPDIR)/libcrypto_la-i_ofb64.Tpo idea/$(DEPDIR)/libcrypto_la-i_ofb64.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='idea/i_ofb64.c' object='idea/libcrypto_la-i_ofb64.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o idea/libcrypto_la-i_ofb64.lo `test -f 'idea/i_ofb64.c' || echo '$(srcdir)/'`idea/i_ofb64.c idea/libcrypto_la-i_skey.lo: idea/i_skey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT idea/libcrypto_la-i_skey.lo -MD -MP -MF idea/$(DEPDIR)/libcrypto_la-i_skey.Tpo -c -o idea/libcrypto_la-i_skey.lo `test -f 'idea/i_skey.c' || echo '$(srcdir)/'`idea/i_skey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) idea/$(DEPDIR)/libcrypto_la-i_skey.Tpo idea/$(DEPDIR)/libcrypto_la-i_skey.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='idea/i_skey.c' object='idea/libcrypto_la-i_skey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o idea/libcrypto_la-i_skey.lo `test -f 'idea/i_skey.c' || echo '$(srcdir)/'`idea/i_skey.c krb5/libcrypto_la-krb5_asn.lo: krb5/krb5_asn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT krb5/libcrypto_la-krb5_asn.lo -MD -MP -MF krb5/$(DEPDIR)/libcrypto_la-krb5_asn.Tpo -c -o krb5/libcrypto_la-krb5_asn.lo `test -f 'krb5/krb5_asn.c' || echo '$(srcdir)/'`krb5/krb5_asn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) krb5/$(DEPDIR)/libcrypto_la-krb5_asn.Tpo krb5/$(DEPDIR)/libcrypto_la-krb5_asn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='krb5/krb5_asn.c' object='krb5/libcrypto_la-krb5_asn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o krb5/libcrypto_la-krb5_asn.lo `test -f 'krb5/krb5_asn.c' || echo '$(srcdir)/'`krb5/krb5_asn.c lhash/libcrypto_la-lh_stats.lo: lhash/lh_stats.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT lhash/libcrypto_la-lh_stats.lo -MD -MP -MF lhash/$(DEPDIR)/libcrypto_la-lh_stats.Tpo -c -o lhash/libcrypto_la-lh_stats.lo `test -f 'lhash/lh_stats.c' || echo '$(srcdir)/'`lhash/lh_stats.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lhash/$(DEPDIR)/libcrypto_la-lh_stats.Tpo lhash/$(DEPDIR)/libcrypto_la-lh_stats.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lhash/lh_stats.c' object='lhash/libcrypto_la-lh_stats.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o lhash/libcrypto_la-lh_stats.lo `test -f 'lhash/lh_stats.c' || echo '$(srcdir)/'`lhash/lh_stats.c lhash/libcrypto_la-lhash.lo: lhash/lhash.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT lhash/libcrypto_la-lhash.lo -MD -MP -MF lhash/$(DEPDIR)/libcrypto_la-lhash.Tpo -c -o lhash/libcrypto_la-lhash.lo `test -f 'lhash/lhash.c' || echo '$(srcdir)/'`lhash/lhash.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) lhash/$(DEPDIR)/libcrypto_la-lhash.Tpo lhash/$(DEPDIR)/libcrypto_la-lhash.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lhash/lhash.c' object='lhash/libcrypto_la-lhash.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o lhash/libcrypto_la-lhash.lo `test -f 'lhash/lhash.c' || echo '$(srcdir)/'`lhash/lhash.c md4/libcrypto_la-md4_dgst.lo: md4/md4_dgst.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT md4/libcrypto_la-md4_dgst.lo -MD -MP -MF md4/$(DEPDIR)/libcrypto_la-md4_dgst.Tpo -c -o md4/libcrypto_la-md4_dgst.lo `test -f 'md4/md4_dgst.c' || echo '$(srcdir)/'`md4/md4_dgst.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) md4/$(DEPDIR)/libcrypto_la-md4_dgst.Tpo md4/$(DEPDIR)/libcrypto_la-md4_dgst.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='md4/md4_dgst.c' object='md4/libcrypto_la-md4_dgst.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o md4/libcrypto_la-md4_dgst.lo `test -f 'md4/md4_dgst.c' || echo '$(srcdir)/'`md4/md4_dgst.c md4/libcrypto_la-md4_one.lo: md4/md4_one.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT md4/libcrypto_la-md4_one.lo -MD -MP -MF md4/$(DEPDIR)/libcrypto_la-md4_one.Tpo -c -o md4/libcrypto_la-md4_one.lo `test -f 'md4/md4_one.c' || echo '$(srcdir)/'`md4/md4_one.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) md4/$(DEPDIR)/libcrypto_la-md4_one.Tpo md4/$(DEPDIR)/libcrypto_la-md4_one.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='md4/md4_one.c' object='md4/libcrypto_la-md4_one.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o md4/libcrypto_la-md4_one.lo `test -f 'md4/md4_one.c' || echo '$(srcdir)/'`md4/md4_one.c md5/libcrypto_la-md5_dgst.lo: md5/md5_dgst.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT md5/libcrypto_la-md5_dgst.lo -MD -MP -MF md5/$(DEPDIR)/libcrypto_la-md5_dgst.Tpo -c -o md5/libcrypto_la-md5_dgst.lo `test -f 'md5/md5_dgst.c' || echo '$(srcdir)/'`md5/md5_dgst.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) md5/$(DEPDIR)/libcrypto_la-md5_dgst.Tpo md5/$(DEPDIR)/libcrypto_la-md5_dgst.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='md5/md5_dgst.c' object='md5/libcrypto_la-md5_dgst.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o md5/libcrypto_la-md5_dgst.lo `test -f 'md5/md5_dgst.c' || echo '$(srcdir)/'`md5/md5_dgst.c md5/libcrypto_la-md5_one.lo: md5/md5_one.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT md5/libcrypto_la-md5_one.lo -MD -MP -MF md5/$(DEPDIR)/libcrypto_la-md5_one.Tpo -c -o md5/libcrypto_la-md5_one.lo `test -f 'md5/md5_one.c' || echo '$(srcdir)/'`md5/md5_one.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) md5/$(DEPDIR)/libcrypto_la-md5_one.Tpo md5/$(DEPDIR)/libcrypto_la-md5_one.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='md5/md5_one.c' object='md5/libcrypto_la-md5_one.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o md5/libcrypto_la-md5_one.lo `test -f 'md5/md5_one.c' || echo '$(srcdir)/'`md5/md5_one.c mdc2/libcrypto_la-mdc2_one.lo: mdc2/mdc2_one.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT mdc2/libcrypto_la-mdc2_one.lo -MD -MP -MF mdc2/$(DEPDIR)/libcrypto_la-mdc2_one.Tpo -c -o mdc2/libcrypto_la-mdc2_one.lo `test -f 'mdc2/mdc2_one.c' || echo '$(srcdir)/'`mdc2/mdc2_one.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mdc2/$(DEPDIR)/libcrypto_la-mdc2_one.Tpo mdc2/$(DEPDIR)/libcrypto_la-mdc2_one.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mdc2/mdc2_one.c' object='mdc2/libcrypto_la-mdc2_one.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o mdc2/libcrypto_la-mdc2_one.lo `test -f 'mdc2/mdc2_one.c' || echo '$(srcdir)/'`mdc2/mdc2_one.c mdc2/libcrypto_la-mdc2dgst.lo: mdc2/mdc2dgst.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT mdc2/libcrypto_la-mdc2dgst.lo -MD -MP -MF mdc2/$(DEPDIR)/libcrypto_la-mdc2dgst.Tpo -c -o mdc2/libcrypto_la-mdc2dgst.lo `test -f 'mdc2/mdc2dgst.c' || echo '$(srcdir)/'`mdc2/mdc2dgst.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mdc2/$(DEPDIR)/libcrypto_la-mdc2dgst.Tpo mdc2/$(DEPDIR)/libcrypto_la-mdc2dgst.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mdc2/mdc2dgst.c' object='mdc2/libcrypto_la-mdc2dgst.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o mdc2/libcrypto_la-mdc2dgst.lo `test -f 'mdc2/mdc2dgst.c' || echo '$(srcdir)/'`mdc2/mdc2dgst.c modes/libcrypto_la-cbc128.lo: modes/cbc128.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT modes/libcrypto_la-cbc128.lo -MD -MP -MF modes/$(DEPDIR)/libcrypto_la-cbc128.Tpo -c -o modes/libcrypto_la-cbc128.lo `test -f 'modes/cbc128.c' || echo '$(srcdir)/'`modes/cbc128.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) modes/$(DEPDIR)/libcrypto_la-cbc128.Tpo modes/$(DEPDIR)/libcrypto_la-cbc128.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='modes/cbc128.c' object='modes/libcrypto_la-cbc128.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o modes/libcrypto_la-cbc128.lo `test -f 'modes/cbc128.c' || echo '$(srcdir)/'`modes/cbc128.c modes/libcrypto_la-ccm128.lo: modes/ccm128.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT modes/libcrypto_la-ccm128.lo -MD -MP -MF modes/$(DEPDIR)/libcrypto_la-ccm128.Tpo -c -o modes/libcrypto_la-ccm128.lo `test -f 'modes/ccm128.c' || echo '$(srcdir)/'`modes/ccm128.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) modes/$(DEPDIR)/libcrypto_la-ccm128.Tpo modes/$(DEPDIR)/libcrypto_la-ccm128.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='modes/ccm128.c' object='modes/libcrypto_la-ccm128.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o modes/libcrypto_la-ccm128.lo `test -f 'modes/ccm128.c' || echo '$(srcdir)/'`modes/ccm128.c modes/libcrypto_la-cfb128.lo: modes/cfb128.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT modes/libcrypto_la-cfb128.lo -MD -MP -MF modes/$(DEPDIR)/libcrypto_la-cfb128.Tpo -c -o modes/libcrypto_la-cfb128.lo `test -f 'modes/cfb128.c' || echo '$(srcdir)/'`modes/cfb128.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) modes/$(DEPDIR)/libcrypto_la-cfb128.Tpo modes/$(DEPDIR)/libcrypto_la-cfb128.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='modes/cfb128.c' object='modes/libcrypto_la-cfb128.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o modes/libcrypto_la-cfb128.lo `test -f 'modes/cfb128.c' || echo '$(srcdir)/'`modes/cfb128.c modes/libcrypto_la-ctr128.lo: modes/ctr128.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT modes/libcrypto_la-ctr128.lo -MD -MP -MF modes/$(DEPDIR)/libcrypto_la-ctr128.Tpo -c -o modes/libcrypto_la-ctr128.lo `test -f 'modes/ctr128.c' || echo '$(srcdir)/'`modes/ctr128.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) modes/$(DEPDIR)/libcrypto_la-ctr128.Tpo modes/$(DEPDIR)/libcrypto_la-ctr128.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='modes/ctr128.c' object='modes/libcrypto_la-ctr128.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o modes/libcrypto_la-ctr128.lo `test -f 'modes/ctr128.c' || echo '$(srcdir)/'`modes/ctr128.c modes/libcrypto_la-cts128.lo: modes/cts128.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT modes/libcrypto_la-cts128.lo -MD -MP -MF modes/$(DEPDIR)/libcrypto_la-cts128.Tpo -c -o modes/libcrypto_la-cts128.lo `test -f 'modes/cts128.c' || echo '$(srcdir)/'`modes/cts128.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) modes/$(DEPDIR)/libcrypto_la-cts128.Tpo modes/$(DEPDIR)/libcrypto_la-cts128.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='modes/cts128.c' object='modes/libcrypto_la-cts128.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o modes/libcrypto_la-cts128.lo `test -f 'modes/cts128.c' || echo '$(srcdir)/'`modes/cts128.c modes/libcrypto_la-gcm128.lo: modes/gcm128.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT modes/libcrypto_la-gcm128.lo -MD -MP -MF modes/$(DEPDIR)/libcrypto_la-gcm128.Tpo -c -o modes/libcrypto_la-gcm128.lo `test -f 'modes/gcm128.c' || echo '$(srcdir)/'`modes/gcm128.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) modes/$(DEPDIR)/libcrypto_la-gcm128.Tpo modes/$(DEPDIR)/libcrypto_la-gcm128.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='modes/gcm128.c' object='modes/libcrypto_la-gcm128.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o modes/libcrypto_la-gcm128.lo `test -f 'modes/gcm128.c' || echo '$(srcdir)/'`modes/gcm128.c modes/libcrypto_la-ofb128.lo: modes/ofb128.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT modes/libcrypto_la-ofb128.lo -MD -MP -MF modes/$(DEPDIR)/libcrypto_la-ofb128.Tpo -c -o modes/libcrypto_la-ofb128.lo `test -f 'modes/ofb128.c' || echo '$(srcdir)/'`modes/ofb128.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) modes/$(DEPDIR)/libcrypto_la-ofb128.Tpo modes/$(DEPDIR)/libcrypto_la-ofb128.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='modes/ofb128.c' object='modes/libcrypto_la-ofb128.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o modes/libcrypto_la-ofb128.lo `test -f 'modes/ofb128.c' || echo '$(srcdir)/'`modes/ofb128.c modes/libcrypto_la-xts128.lo: modes/xts128.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT modes/libcrypto_la-xts128.lo -MD -MP -MF modes/$(DEPDIR)/libcrypto_la-xts128.Tpo -c -o modes/libcrypto_la-xts128.lo `test -f 'modes/xts128.c' || echo '$(srcdir)/'`modes/xts128.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) modes/$(DEPDIR)/libcrypto_la-xts128.Tpo modes/$(DEPDIR)/libcrypto_la-xts128.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='modes/xts128.c' object='modes/libcrypto_la-xts128.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o modes/libcrypto_la-xts128.lo `test -f 'modes/xts128.c' || echo '$(srcdir)/'`modes/xts128.c objects/libcrypto_la-o_names.lo: objects/o_names.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT objects/libcrypto_la-o_names.lo -MD -MP -MF objects/$(DEPDIR)/libcrypto_la-o_names.Tpo -c -o objects/libcrypto_la-o_names.lo `test -f 'objects/o_names.c' || echo '$(srcdir)/'`objects/o_names.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) objects/$(DEPDIR)/libcrypto_la-o_names.Tpo objects/$(DEPDIR)/libcrypto_la-o_names.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='objects/o_names.c' object='objects/libcrypto_la-o_names.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o objects/libcrypto_la-o_names.lo `test -f 'objects/o_names.c' || echo '$(srcdir)/'`objects/o_names.c objects/libcrypto_la-obj_dat.lo: objects/obj_dat.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT objects/libcrypto_la-obj_dat.lo -MD -MP -MF objects/$(DEPDIR)/libcrypto_la-obj_dat.Tpo -c -o objects/libcrypto_la-obj_dat.lo `test -f 'objects/obj_dat.c' || echo '$(srcdir)/'`objects/obj_dat.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) objects/$(DEPDIR)/libcrypto_la-obj_dat.Tpo objects/$(DEPDIR)/libcrypto_la-obj_dat.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='objects/obj_dat.c' object='objects/libcrypto_la-obj_dat.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o objects/libcrypto_la-obj_dat.lo `test -f 'objects/obj_dat.c' || echo '$(srcdir)/'`objects/obj_dat.c objects/libcrypto_la-obj_err.lo: objects/obj_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT objects/libcrypto_la-obj_err.lo -MD -MP -MF objects/$(DEPDIR)/libcrypto_la-obj_err.Tpo -c -o objects/libcrypto_la-obj_err.lo `test -f 'objects/obj_err.c' || echo '$(srcdir)/'`objects/obj_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) objects/$(DEPDIR)/libcrypto_la-obj_err.Tpo objects/$(DEPDIR)/libcrypto_la-obj_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='objects/obj_err.c' object='objects/libcrypto_la-obj_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o objects/libcrypto_la-obj_err.lo `test -f 'objects/obj_err.c' || echo '$(srcdir)/'`objects/obj_err.c objects/libcrypto_la-obj_lib.lo: objects/obj_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT objects/libcrypto_la-obj_lib.lo -MD -MP -MF objects/$(DEPDIR)/libcrypto_la-obj_lib.Tpo -c -o objects/libcrypto_la-obj_lib.lo `test -f 'objects/obj_lib.c' || echo '$(srcdir)/'`objects/obj_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) objects/$(DEPDIR)/libcrypto_la-obj_lib.Tpo objects/$(DEPDIR)/libcrypto_la-obj_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='objects/obj_lib.c' object='objects/libcrypto_la-obj_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o objects/libcrypto_la-obj_lib.lo `test -f 'objects/obj_lib.c' || echo '$(srcdir)/'`objects/obj_lib.c objects/libcrypto_la-obj_xref.lo: objects/obj_xref.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT objects/libcrypto_la-obj_xref.lo -MD -MP -MF objects/$(DEPDIR)/libcrypto_la-obj_xref.Tpo -c -o objects/libcrypto_la-obj_xref.lo `test -f 'objects/obj_xref.c' || echo '$(srcdir)/'`objects/obj_xref.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) objects/$(DEPDIR)/libcrypto_la-obj_xref.Tpo objects/$(DEPDIR)/libcrypto_la-obj_xref.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='objects/obj_xref.c' object='objects/libcrypto_la-obj_xref.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o objects/libcrypto_la-obj_xref.lo `test -f 'objects/obj_xref.c' || echo '$(srcdir)/'`objects/obj_xref.c ocsp/libcrypto_la-ocsp_asn.lo: ocsp/ocsp_asn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ocsp/libcrypto_la-ocsp_asn.lo -MD -MP -MF ocsp/$(DEPDIR)/libcrypto_la-ocsp_asn.Tpo -c -o ocsp/libcrypto_la-ocsp_asn.lo `test -f 'ocsp/ocsp_asn.c' || echo '$(srcdir)/'`ocsp/ocsp_asn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ocsp/$(DEPDIR)/libcrypto_la-ocsp_asn.Tpo ocsp/$(DEPDIR)/libcrypto_la-ocsp_asn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ocsp/ocsp_asn.c' object='ocsp/libcrypto_la-ocsp_asn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ocsp/libcrypto_la-ocsp_asn.lo `test -f 'ocsp/ocsp_asn.c' || echo '$(srcdir)/'`ocsp/ocsp_asn.c ocsp/libcrypto_la-ocsp_cl.lo: ocsp/ocsp_cl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ocsp/libcrypto_la-ocsp_cl.lo -MD -MP -MF ocsp/$(DEPDIR)/libcrypto_la-ocsp_cl.Tpo -c -o ocsp/libcrypto_la-ocsp_cl.lo `test -f 'ocsp/ocsp_cl.c' || echo '$(srcdir)/'`ocsp/ocsp_cl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ocsp/$(DEPDIR)/libcrypto_la-ocsp_cl.Tpo ocsp/$(DEPDIR)/libcrypto_la-ocsp_cl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ocsp/ocsp_cl.c' object='ocsp/libcrypto_la-ocsp_cl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ocsp/libcrypto_la-ocsp_cl.lo `test -f 'ocsp/ocsp_cl.c' || echo '$(srcdir)/'`ocsp/ocsp_cl.c ocsp/libcrypto_la-ocsp_err.lo: ocsp/ocsp_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ocsp/libcrypto_la-ocsp_err.lo -MD -MP -MF ocsp/$(DEPDIR)/libcrypto_la-ocsp_err.Tpo -c -o ocsp/libcrypto_la-ocsp_err.lo `test -f 'ocsp/ocsp_err.c' || echo '$(srcdir)/'`ocsp/ocsp_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ocsp/$(DEPDIR)/libcrypto_la-ocsp_err.Tpo ocsp/$(DEPDIR)/libcrypto_la-ocsp_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ocsp/ocsp_err.c' object='ocsp/libcrypto_la-ocsp_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ocsp/libcrypto_la-ocsp_err.lo `test -f 'ocsp/ocsp_err.c' || echo '$(srcdir)/'`ocsp/ocsp_err.c ocsp/libcrypto_la-ocsp_ext.lo: ocsp/ocsp_ext.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ocsp/libcrypto_la-ocsp_ext.lo -MD -MP -MF ocsp/$(DEPDIR)/libcrypto_la-ocsp_ext.Tpo -c -o ocsp/libcrypto_la-ocsp_ext.lo `test -f 'ocsp/ocsp_ext.c' || echo '$(srcdir)/'`ocsp/ocsp_ext.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ocsp/$(DEPDIR)/libcrypto_la-ocsp_ext.Tpo ocsp/$(DEPDIR)/libcrypto_la-ocsp_ext.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ocsp/ocsp_ext.c' object='ocsp/libcrypto_la-ocsp_ext.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ocsp/libcrypto_la-ocsp_ext.lo `test -f 'ocsp/ocsp_ext.c' || echo '$(srcdir)/'`ocsp/ocsp_ext.c ocsp/libcrypto_la-ocsp_ht.lo: ocsp/ocsp_ht.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ocsp/libcrypto_la-ocsp_ht.lo -MD -MP -MF ocsp/$(DEPDIR)/libcrypto_la-ocsp_ht.Tpo -c -o ocsp/libcrypto_la-ocsp_ht.lo `test -f 'ocsp/ocsp_ht.c' || echo '$(srcdir)/'`ocsp/ocsp_ht.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ocsp/$(DEPDIR)/libcrypto_la-ocsp_ht.Tpo ocsp/$(DEPDIR)/libcrypto_la-ocsp_ht.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ocsp/ocsp_ht.c' object='ocsp/libcrypto_la-ocsp_ht.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ocsp/libcrypto_la-ocsp_ht.lo `test -f 'ocsp/ocsp_ht.c' || echo '$(srcdir)/'`ocsp/ocsp_ht.c ocsp/libcrypto_la-ocsp_lib.lo: ocsp/ocsp_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ocsp/libcrypto_la-ocsp_lib.lo -MD -MP -MF ocsp/$(DEPDIR)/libcrypto_la-ocsp_lib.Tpo -c -o ocsp/libcrypto_la-ocsp_lib.lo `test -f 'ocsp/ocsp_lib.c' || echo '$(srcdir)/'`ocsp/ocsp_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ocsp/$(DEPDIR)/libcrypto_la-ocsp_lib.Tpo ocsp/$(DEPDIR)/libcrypto_la-ocsp_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ocsp/ocsp_lib.c' object='ocsp/libcrypto_la-ocsp_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ocsp/libcrypto_la-ocsp_lib.lo `test -f 'ocsp/ocsp_lib.c' || echo '$(srcdir)/'`ocsp/ocsp_lib.c ocsp/libcrypto_la-ocsp_prn.lo: ocsp/ocsp_prn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ocsp/libcrypto_la-ocsp_prn.lo -MD -MP -MF ocsp/$(DEPDIR)/libcrypto_la-ocsp_prn.Tpo -c -o ocsp/libcrypto_la-ocsp_prn.lo `test -f 'ocsp/ocsp_prn.c' || echo '$(srcdir)/'`ocsp/ocsp_prn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ocsp/$(DEPDIR)/libcrypto_la-ocsp_prn.Tpo ocsp/$(DEPDIR)/libcrypto_la-ocsp_prn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ocsp/ocsp_prn.c' object='ocsp/libcrypto_la-ocsp_prn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ocsp/libcrypto_la-ocsp_prn.lo `test -f 'ocsp/ocsp_prn.c' || echo '$(srcdir)/'`ocsp/ocsp_prn.c ocsp/libcrypto_la-ocsp_srv.lo: ocsp/ocsp_srv.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ocsp/libcrypto_la-ocsp_srv.lo -MD -MP -MF ocsp/$(DEPDIR)/libcrypto_la-ocsp_srv.Tpo -c -o ocsp/libcrypto_la-ocsp_srv.lo `test -f 'ocsp/ocsp_srv.c' || echo '$(srcdir)/'`ocsp/ocsp_srv.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ocsp/$(DEPDIR)/libcrypto_la-ocsp_srv.Tpo ocsp/$(DEPDIR)/libcrypto_la-ocsp_srv.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ocsp/ocsp_srv.c' object='ocsp/libcrypto_la-ocsp_srv.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ocsp/libcrypto_la-ocsp_srv.lo `test -f 'ocsp/ocsp_srv.c' || echo '$(srcdir)/'`ocsp/ocsp_srv.c ocsp/libcrypto_la-ocsp_vfy.lo: ocsp/ocsp_vfy.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ocsp/libcrypto_la-ocsp_vfy.lo -MD -MP -MF ocsp/$(DEPDIR)/libcrypto_la-ocsp_vfy.Tpo -c -o ocsp/libcrypto_la-ocsp_vfy.lo `test -f 'ocsp/ocsp_vfy.c' || echo '$(srcdir)/'`ocsp/ocsp_vfy.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ocsp/$(DEPDIR)/libcrypto_la-ocsp_vfy.Tpo ocsp/$(DEPDIR)/libcrypto_la-ocsp_vfy.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ocsp/ocsp_vfy.c' object='ocsp/libcrypto_la-ocsp_vfy.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ocsp/libcrypto_la-ocsp_vfy.lo `test -f 'ocsp/ocsp_vfy.c' || echo '$(srcdir)/'`ocsp/ocsp_vfy.c pem/libcrypto_la-pem_all.lo: pem/pem_all.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pem/libcrypto_la-pem_all.lo -MD -MP -MF pem/$(DEPDIR)/libcrypto_la-pem_all.Tpo -c -o pem/libcrypto_la-pem_all.lo `test -f 'pem/pem_all.c' || echo '$(srcdir)/'`pem/pem_all.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pem/$(DEPDIR)/libcrypto_la-pem_all.Tpo pem/$(DEPDIR)/libcrypto_la-pem_all.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pem/pem_all.c' object='pem/libcrypto_la-pem_all.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pem/libcrypto_la-pem_all.lo `test -f 'pem/pem_all.c' || echo '$(srcdir)/'`pem/pem_all.c pem/libcrypto_la-pem_err.lo: pem/pem_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pem/libcrypto_la-pem_err.lo -MD -MP -MF pem/$(DEPDIR)/libcrypto_la-pem_err.Tpo -c -o pem/libcrypto_la-pem_err.lo `test -f 'pem/pem_err.c' || echo '$(srcdir)/'`pem/pem_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pem/$(DEPDIR)/libcrypto_la-pem_err.Tpo pem/$(DEPDIR)/libcrypto_la-pem_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pem/pem_err.c' object='pem/libcrypto_la-pem_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pem/libcrypto_la-pem_err.lo `test -f 'pem/pem_err.c' || echo '$(srcdir)/'`pem/pem_err.c pem/libcrypto_la-pem_info.lo: pem/pem_info.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pem/libcrypto_la-pem_info.lo -MD -MP -MF pem/$(DEPDIR)/libcrypto_la-pem_info.Tpo -c -o pem/libcrypto_la-pem_info.lo `test -f 'pem/pem_info.c' || echo '$(srcdir)/'`pem/pem_info.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pem/$(DEPDIR)/libcrypto_la-pem_info.Tpo pem/$(DEPDIR)/libcrypto_la-pem_info.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pem/pem_info.c' object='pem/libcrypto_la-pem_info.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pem/libcrypto_la-pem_info.lo `test -f 'pem/pem_info.c' || echo '$(srcdir)/'`pem/pem_info.c pem/libcrypto_la-pem_lib.lo: pem/pem_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pem/libcrypto_la-pem_lib.lo -MD -MP -MF pem/$(DEPDIR)/libcrypto_la-pem_lib.Tpo -c -o pem/libcrypto_la-pem_lib.lo `test -f 'pem/pem_lib.c' || echo '$(srcdir)/'`pem/pem_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pem/$(DEPDIR)/libcrypto_la-pem_lib.Tpo pem/$(DEPDIR)/libcrypto_la-pem_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pem/pem_lib.c' object='pem/libcrypto_la-pem_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pem/libcrypto_la-pem_lib.lo `test -f 'pem/pem_lib.c' || echo '$(srcdir)/'`pem/pem_lib.c pem/libcrypto_la-pem_oth.lo: pem/pem_oth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pem/libcrypto_la-pem_oth.lo -MD -MP -MF pem/$(DEPDIR)/libcrypto_la-pem_oth.Tpo -c -o pem/libcrypto_la-pem_oth.lo `test -f 'pem/pem_oth.c' || echo '$(srcdir)/'`pem/pem_oth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pem/$(DEPDIR)/libcrypto_la-pem_oth.Tpo pem/$(DEPDIR)/libcrypto_la-pem_oth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pem/pem_oth.c' object='pem/libcrypto_la-pem_oth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pem/libcrypto_la-pem_oth.lo `test -f 'pem/pem_oth.c' || echo '$(srcdir)/'`pem/pem_oth.c pem/libcrypto_la-pem_pk8.lo: pem/pem_pk8.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pem/libcrypto_la-pem_pk8.lo -MD -MP -MF pem/$(DEPDIR)/libcrypto_la-pem_pk8.Tpo -c -o pem/libcrypto_la-pem_pk8.lo `test -f 'pem/pem_pk8.c' || echo '$(srcdir)/'`pem/pem_pk8.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pem/$(DEPDIR)/libcrypto_la-pem_pk8.Tpo pem/$(DEPDIR)/libcrypto_la-pem_pk8.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pem/pem_pk8.c' object='pem/libcrypto_la-pem_pk8.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pem/libcrypto_la-pem_pk8.lo `test -f 'pem/pem_pk8.c' || echo '$(srcdir)/'`pem/pem_pk8.c pem/libcrypto_la-pem_pkey.lo: pem/pem_pkey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pem/libcrypto_la-pem_pkey.lo -MD -MP -MF pem/$(DEPDIR)/libcrypto_la-pem_pkey.Tpo -c -o pem/libcrypto_la-pem_pkey.lo `test -f 'pem/pem_pkey.c' || echo '$(srcdir)/'`pem/pem_pkey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pem/$(DEPDIR)/libcrypto_la-pem_pkey.Tpo pem/$(DEPDIR)/libcrypto_la-pem_pkey.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pem/pem_pkey.c' object='pem/libcrypto_la-pem_pkey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pem/libcrypto_la-pem_pkey.lo `test -f 'pem/pem_pkey.c' || echo '$(srcdir)/'`pem/pem_pkey.c pem/libcrypto_la-pem_seal.lo: pem/pem_seal.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pem/libcrypto_la-pem_seal.lo -MD -MP -MF pem/$(DEPDIR)/libcrypto_la-pem_seal.Tpo -c -o pem/libcrypto_la-pem_seal.lo `test -f 'pem/pem_seal.c' || echo '$(srcdir)/'`pem/pem_seal.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pem/$(DEPDIR)/libcrypto_la-pem_seal.Tpo pem/$(DEPDIR)/libcrypto_la-pem_seal.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pem/pem_seal.c' object='pem/libcrypto_la-pem_seal.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pem/libcrypto_la-pem_seal.lo `test -f 'pem/pem_seal.c' || echo '$(srcdir)/'`pem/pem_seal.c pem/libcrypto_la-pem_sign.lo: pem/pem_sign.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pem/libcrypto_la-pem_sign.lo -MD -MP -MF pem/$(DEPDIR)/libcrypto_la-pem_sign.Tpo -c -o pem/libcrypto_la-pem_sign.lo `test -f 'pem/pem_sign.c' || echo '$(srcdir)/'`pem/pem_sign.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pem/$(DEPDIR)/libcrypto_la-pem_sign.Tpo pem/$(DEPDIR)/libcrypto_la-pem_sign.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pem/pem_sign.c' object='pem/libcrypto_la-pem_sign.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pem/libcrypto_la-pem_sign.lo `test -f 'pem/pem_sign.c' || echo '$(srcdir)/'`pem/pem_sign.c pem/libcrypto_la-pem_x509.lo: pem/pem_x509.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pem/libcrypto_la-pem_x509.lo -MD -MP -MF pem/$(DEPDIR)/libcrypto_la-pem_x509.Tpo -c -o pem/libcrypto_la-pem_x509.lo `test -f 'pem/pem_x509.c' || echo '$(srcdir)/'`pem/pem_x509.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pem/$(DEPDIR)/libcrypto_la-pem_x509.Tpo pem/$(DEPDIR)/libcrypto_la-pem_x509.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pem/pem_x509.c' object='pem/libcrypto_la-pem_x509.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pem/libcrypto_la-pem_x509.lo `test -f 'pem/pem_x509.c' || echo '$(srcdir)/'`pem/pem_x509.c pem/libcrypto_la-pem_xaux.lo: pem/pem_xaux.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pem/libcrypto_la-pem_xaux.lo -MD -MP -MF pem/$(DEPDIR)/libcrypto_la-pem_xaux.Tpo -c -o pem/libcrypto_la-pem_xaux.lo `test -f 'pem/pem_xaux.c' || echo '$(srcdir)/'`pem/pem_xaux.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pem/$(DEPDIR)/libcrypto_la-pem_xaux.Tpo pem/$(DEPDIR)/libcrypto_la-pem_xaux.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pem/pem_xaux.c' object='pem/libcrypto_la-pem_xaux.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pem/libcrypto_la-pem_xaux.lo `test -f 'pem/pem_xaux.c' || echo '$(srcdir)/'`pem/pem_xaux.c pem/libcrypto_la-pvkfmt.lo: pem/pvkfmt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pem/libcrypto_la-pvkfmt.lo -MD -MP -MF pem/$(DEPDIR)/libcrypto_la-pvkfmt.Tpo -c -o pem/libcrypto_la-pvkfmt.lo `test -f 'pem/pvkfmt.c' || echo '$(srcdir)/'`pem/pvkfmt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pem/$(DEPDIR)/libcrypto_la-pvkfmt.Tpo pem/$(DEPDIR)/libcrypto_la-pvkfmt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pem/pvkfmt.c' object='pem/libcrypto_la-pvkfmt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pem/libcrypto_la-pvkfmt.lo `test -f 'pem/pvkfmt.c' || echo '$(srcdir)/'`pem/pvkfmt.c pkcs12/libcrypto_la-p12_add.lo: pkcs12/p12_add.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs12/libcrypto_la-p12_add.lo -MD -MP -MF pkcs12/$(DEPDIR)/libcrypto_la-p12_add.Tpo -c -o pkcs12/libcrypto_la-p12_add.lo `test -f 'pkcs12/p12_add.c' || echo '$(srcdir)/'`pkcs12/p12_add.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs12/$(DEPDIR)/libcrypto_la-p12_add.Tpo pkcs12/$(DEPDIR)/libcrypto_la-p12_add.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12/p12_add.c' object='pkcs12/libcrypto_la-p12_add.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs12/libcrypto_la-p12_add.lo `test -f 'pkcs12/p12_add.c' || echo '$(srcdir)/'`pkcs12/p12_add.c pkcs12/libcrypto_la-p12_asn.lo: pkcs12/p12_asn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs12/libcrypto_la-p12_asn.lo -MD -MP -MF pkcs12/$(DEPDIR)/libcrypto_la-p12_asn.Tpo -c -o pkcs12/libcrypto_la-p12_asn.lo `test -f 'pkcs12/p12_asn.c' || echo '$(srcdir)/'`pkcs12/p12_asn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs12/$(DEPDIR)/libcrypto_la-p12_asn.Tpo pkcs12/$(DEPDIR)/libcrypto_la-p12_asn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12/p12_asn.c' object='pkcs12/libcrypto_la-p12_asn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs12/libcrypto_la-p12_asn.lo `test -f 'pkcs12/p12_asn.c' || echo '$(srcdir)/'`pkcs12/p12_asn.c pkcs12/libcrypto_la-p12_attr.lo: pkcs12/p12_attr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs12/libcrypto_la-p12_attr.lo -MD -MP -MF pkcs12/$(DEPDIR)/libcrypto_la-p12_attr.Tpo -c -o pkcs12/libcrypto_la-p12_attr.lo `test -f 'pkcs12/p12_attr.c' || echo '$(srcdir)/'`pkcs12/p12_attr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs12/$(DEPDIR)/libcrypto_la-p12_attr.Tpo pkcs12/$(DEPDIR)/libcrypto_la-p12_attr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12/p12_attr.c' object='pkcs12/libcrypto_la-p12_attr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs12/libcrypto_la-p12_attr.lo `test -f 'pkcs12/p12_attr.c' || echo '$(srcdir)/'`pkcs12/p12_attr.c pkcs12/libcrypto_la-p12_crpt.lo: pkcs12/p12_crpt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs12/libcrypto_la-p12_crpt.lo -MD -MP -MF pkcs12/$(DEPDIR)/libcrypto_la-p12_crpt.Tpo -c -o pkcs12/libcrypto_la-p12_crpt.lo `test -f 'pkcs12/p12_crpt.c' || echo '$(srcdir)/'`pkcs12/p12_crpt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs12/$(DEPDIR)/libcrypto_la-p12_crpt.Tpo pkcs12/$(DEPDIR)/libcrypto_la-p12_crpt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12/p12_crpt.c' object='pkcs12/libcrypto_la-p12_crpt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs12/libcrypto_la-p12_crpt.lo `test -f 'pkcs12/p12_crpt.c' || echo '$(srcdir)/'`pkcs12/p12_crpt.c pkcs12/libcrypto_la-p12_crt.lo: pkcs12/p12_crt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs12/libcrypto_la-p12_crt.lo -MD -MP -MF pkcs12/$(DEPDIR)/libcrypto_la-p12_crt.Tpo -c -o pkcs12/libcrypto_la-p12_crt.lo `test -f 'pkcs12/p12_crt.c' || echo '$(srcdir)/'`pkcs12/p12_crt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs12/$(DEPDIR)/libcrypto_la-p12_crt.Tpo pkcs12/$(DEPDIR)/libcrypto_la-p12_crt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12/p12_crt.c' object='pkcs12/libcrypto_la-p12_crt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs12/libcrypto_la-p12_crt.lo `test -f 'pkcs12/p12_crt.c' || echo '$(srcdir)/'`pkcs12/p12_crt.c pkcs12/libcrypto_la-p12_decr.lo: pkcs12/p12_decr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs12/libcrypto_la-p12_decr.lo -MD -MP -MF pkcs12/$(DEPDIR)/libcrypto_la-p12_decr.Tpo -c -o pkcs12/libcrypto_la-p12_decr.lo `test -f 'pkcs12/p12_decr.c' || echo '$(srcdir)/'`pkcs12/p12_decr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs12/$(DEPDIR)/libcrypto_la-p12_decr.Tpo pkcs12/$(DEPDIR)/libcrypto_la-p12_decr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12/p12_decr.c' object='pkcs12/libcrypto_la-p12_decr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs12/libcrypto_la-p12_decr.lo `test -f 'pkcs12/p12_decr.c' || echo '$(srcdir)/'`pkcs12/p12_decr.c pkcs12/libcrypto_la-p12_init.lo: pkcs12/p12_init.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs12/libcrypto_la-p12_init.lo -MD -MP -MF pkcs12/$(DEPDIR)/libcrypto_la-p12_init.Tpo -c -o pkcs12/libcrypto_la-p12_init.lo `test -f 'pkcs12/p12_init.c' || echo '$(srcdir)/'`pkcs12/p12_init.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs12/$(DEPDIR)/libcrypto_la-p12_init.Tpo pkcs12/$(DEPDIR)/libcrypto_la-p12_init.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12/p12_init.c' object='pkcs12/libcrypto_la-p12_init.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs12/libcrypto_la-p12_init.lo `test -f 'pkcs12/p12_init.c' || echo '$(srcdir)/'`pkcs12/p12_init.c pkcs12/libcrypto_la-p12_key.lo: pkcs12/p12_key.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs12/libcrypto_la-p12_key.lo -MD -MP -MF pkcs12/$(DEPDIR)/libcrypto_la-p12_key.Tpo -c -o pkcs12/libcrypto_la-p12_key.lo `test -f 'pkcs12/p12_key.c' || echo '$(srcdir)/'`pkcs12/p12_key.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs12/$(DEPDIR)/libcrypto_la-p12_key.Tpo pkcs12/$(DEPDIR)/libcrypto_la-p12_key.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12/p12_key.c' object='pkcs12/libcrypto_la-p12_key.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs12/libcrypto_la-p12_key.lo `test -f 'pkcs12/p12_key.c' || echo '$(srcdir)/'`pkcs12/p12_key.c pkcs12/libcrypto_la-p12_kiss.lo: pkcs12/p12_kiss.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs12/libcrypto_la-p12_kiss.lo -MD -MP -MF pkcs12/$(DEPDIR)/libcrypto_la-p12_kiss.Tpo -c -o pkcs12/libcrypto_la-p12_kiss.lo `test -f 'pkcs12/p12_kiss.c' || echo '$(srcdir)/'`pkcs12/p12_kiss.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs12/$(DEPDIR)/libcrypto_la-p12_kiss.Tpo pkcs12/$(DEPDIR)/libcrypto_la-p12_kiss.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12/p12_kiss.c' object='pkcs12/libcrypto_la-p12_kiss.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs12/libcrypto_la-p12_kiss.lo `test -f 'pkcs12/p12_kiss.c' || echo '$(srcdir)/'`pkcs12/p12_kiss.c pkcs12/libcrypto_la-p12_mutl.lo: pkcs12/p12_mutl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs12/libcrypto_la-p12_mutl.lo -MD -MP -MF pkcs12/$(DEPDIR)/libcrypto_la-p12_mutl.Tpo -c -o pkcs12/libcrypto_la-p12_mutl.lo `test -f 'pkcs12/p12_mutl.c' || echo '$(srcdir)/'`pkcs12/p12_mutl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs12/$(DEPDIR)/libcrypto_la-p12_mutl.Tpo pkcs12/$(DEPDIR)/libcrypto_la-p12_mutl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12/p12_mutl.c' object='pkcs12/libcrypto_la-p12_mutl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs12/libcrypto_la-p12_mutl.lo `test -f 'pkcs12/p12_mutl.c' || echo '$(srcdir)/'`pkcs12/p12_mutl.c pkcs12/libcrypto_la-p12_npas.lo: pkcs12/p12_npas.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs12/libcrypto_la-p12_npas.lo -MD -MP -MF pkcs12/$(DEPDIR)/libcrypto_la-p12_npas.Tpo -c -o pkcs12/libcrypto_la-p12_npas.lo `test -f 'pkcs12/p12_npas.c' || echo '$(srcdir)/'`pkcs12/p12_npas.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs12/$(DEPDIR)/libcrypto_la-p12_npas.Tpo pkcs12/$(DEPDIR)/libcrypto_la-p12_npas.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12/p12_npas.c' object='pkcs12/libcrypto_la-p12_npas.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs12/libcrypto_la-p12_npas.lo `test -f 'pkcs12/p12_npas.c' || echo '$(srcdir)/'`pkcs12/p12_npas.c pkcs12/libcrypto_la-p12_p8d.lo: pkcs12/p12_p8d.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs12/libcrypto_la-p12_p8d.lo -MD -MP -MF pkcs12/$(DEPDIR)/libcrypto_la-p12_p8d.Tpo -c -o pkcs12/libcrypto_la-p12_p8d.lo `test -f 'pkcs12/p12_p8d.c' || echo '$(srcdir)/'`pkcs12/p12_p8d.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs12/$(DEPDIR)/libcrypto_la-p12_p8d.Tpo pkcs12/$(DEPDIR)/libcrypto_la-p12_p8d.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12/p12_p8d.c' object='pkcs12/libcrypto_la-p12_p8d.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs12/libcrypto_la-p12_p8d.lo `test -f 'pkcs12/p12_p8d.c' || echo '$(srcdir)/'`pkcs12/p12_p8d.c pkcs12/libcrypto_la-p12_p8e.lo: pkcs12/p12_p8e.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs12/libcrypto_la-p12_p8e.lo -MD -MP -MF pkcs12/$(DEPDIR)/libcrypto_la-p12_p8e.Tpo -c -o pkcs12/libcrypto_la-p12_p8e.lo `test -f 'pkcs12/p12_p8e.c' || echo '$(srcdir)/'`pkcs12/p12_p8e.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs12/$(DEPDIR)/libcrypto_la-p12_p8e.Tpo pkcs12/$(DEPDIR)/libcrypto_la-p12_p8e.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12/p12_p8e.c' object='pkcs12/libcrypto_la-p12_p8e.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs12/libcrypto_la-p12_p8e.lo `test -f 'pkcs12/p12_p8e.c' || echo '$(srcdir)/'`pkcs12/p12_p8e.c pkcs12/libcrypto_la-p12_utl.lo: pkcs12/p12_utl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs12/libcrypto_la-p12_utl.lo -MD -MP -MF pkcs12/$(DEPDIR)/libcrypto_la-p12_utl.Tpo -c -o pkcs12/libcrypto_la-p12_utl.lo `test -f 'pkcs12/p12_utl.c' || echo '$(srcdir)/'`pkcs12/p12_utl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs12/$(DEPDIR)/libcrypto_la-p12_utl.Tpo pkcs12/$(DEPDIR)/libcrypto_la-p12_utl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12/p12_utl.c' object='pkcs12/libcrypto_la-p12_utl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs12/libcrypto_la-p12_utl.lo `test -f 'pkcs12/p12_utl.c' || echo '$(srcdir)/'`pkcs12/p12_utl.c pkcs12/libcrypto_la-pk12err.lo: pkcs12/pk12err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs12/libcrypto_la-pk12err.lo -MD -MP -MF pkcs12/$(DEPDIR)/libcrypto_la-pk12err.Tpo -c -o pkcs12/libcrypto_la-pk12err.lo `test -f 'pkcs12/pk12err.c' || echo '$(srcdir)/'`pkcs12/pk12err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs12/$(DEPDIR)/libcrypto_la-pk12err.Tpo pkcs12/$(DEPDIR)/libcrypto_la-pk12err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12/pk12err.c' object='pkcs12/libcrypto_la-pk12err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs12/libcrypto_la-pk12err.lo `test -f 'pkcs12/pk12err.c' || echo '$(srcdir)/'`pkcs12/pk12err.c pkcs7/libcrypto_la-bio_pk7.lo: pkcs7/bio_pk7.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs7/libcrypto_la-bio_pk7.lo -MD -MP -MF pkcs7/$(DEPDIR)/libcrypto_la-bio_pk7.Tpo -c -o pkcs7/libcrypto_la-bio_pk7.lo `test -f 'pkcs7/bio_pk7.c' || echo '$(srcdir)/'`pkcs7/bio_pk7.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs7/$(DEPDIR)/libcrypto_la-bio_pk7.Tpo pkcs7/$(DEPDIR)/libcrypto_la-bio_pk7.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs7/bio_pk7.c' object='pkcs7/libcrypto_la-bio_pk7.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs7/libcrypto_la-bio_pk7.lo `test -f 'pkcs7/bio_pk7.c' || echo '$(srcdir)/'`pkcs7/bio_pk7.c pkcs7/libcrypto_la-pk7_asn1.lo: pkcs7/pk7_asn1.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs7/libcrypto_la-pk7_asn1.lo -MD -MP -MF pkcs7/$(DEPDIR)/libcrypto_la-pk7_asn1.Tpo -c -o pkcs7/libcrypto_la-pk7_asn1.lo `test -f 'pkcs7/pk7_asn1.c' || echo '$(srcdir)/'`pkcs7/pk7_asn1.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs7/$(DEPDIR)/libcrypto_la-pk7_asn1.Tpo pkcs7/$(DEPDIR)/libcrypto_la-pk7_asn1.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs7/pk7_asn1.c' object='pkcs7/libcrypto_la-pk7_asn1.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs7/libcrypto_la-pk7_asn1.lo `test -f 'pkcs7/pk7_asn1.c' || echo '$(srcdir)/'`pkcs7/pk7_asn1.c pkcs7/libcrypto_la-pk7_attr.lo: pkcs7/pk7_attr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs7/libcrypto_la-pk7_attr.lo -MD -MP -MF pkcs7/$(DEPDIR)/libcrypto_la-pk7_attr.Tpo -c -o pkcs7/libcrypto_la-pk7_attr.lo `test -f 'pkcs7/pk7_attr.c' || echo '$(srcdir)/'`pkcs7/pk7_attr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs7/$(DEPDIR)/libcrypto_la-pk7_attr.Tpo pkcs7/$(DEPDIR)/libcrypto_la-pk7_attr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs7/pk7_attr.c' object='pkcs7/libcrypto_la-pk7_attr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs7/libcrypto_la-pk7_attr.lo `test -f 'pkcs7/pk7_attr.c' || echo '$(srcdir)/'`pkcs7/pk7_attr.c pkcs7/libcrypto_la-pk7_doit.lo: pkcs7/pk7_doit.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs7/libcrypto_la-pk7_doit.lo -MD -MP -MF pkcs7/$(DEPDIR)/libcrypto_la-pk7_doit.Tpo -c -o pkcs7/libcrypto_la-pk7_doit.lo `test -f 'pkcs7/pk7_doit.c' || echo '$(srcdir)/'`pkcs7/pk7_doit.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs7/$(DEPDIR)/libcrypto_la-pk7_doit.Tpo pkcs7/$(DEPDIR)/libcrypto_la-pk7_doit.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs7/pk7_doit.c' object='pkcs7/libcrypto_la-pk7_doit.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs7/libcrypto_la-pk7_doit.lo `test -f 'pkcs7/pk7_doit.c' || echo '$(srcdir)/'`pkcs7/pk7_doit.c pkcs7/libcrypto_la-pk7_lib.lo: pkcs7/pk7_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs7/libcrypto_la-pk7_lib.lo -MD -MP -MF pkcs7/$(DEPDIR)/libcrypto_la-pk7_lib.Tpo -c -o pkcs7/libcrypto_la-pk7_lib.lo `test -f 'pkcs7/pk7_lib.c' || echo '$(srcdir)/'`pkcs7/pk7_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs7/$(DEPDIR)/libcrypto_la-pk7_lib.Tpo pkcs7/$(DEPDIR)/libcrypto_la-pk7_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs7/pk7_lib.c' object='pkcs7/libcrypto_la-pk7_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs7/libcrypto_la-pk7_lib.lo `test -f 'pkcs7/pk7_lib.c' || echo '$(srcdir)/'`pkcs7/pk7_lib.c pkcs7/libcrypto_la-pk7_mime.lo: pkcs7/pk7_mime.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs7/libcrypto_la-pk7_mime.lo -MD -MP -MF pkcs7/$(DEPDIR)/libcrypto_la-pk7_mime.Tpo -c -o pkcs7/libcrypto_la-pk7_mime.lo `test -f 'pkcs7/pk7_mime.c' || echo '$(srcdir)/'`pkcs7/pk7_mime.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs7/$(DEPDIR)/libcrypto_la-pk7_mime.Tpo pkcs7/$(DEPDIR)/libcrypto_la-pk7_mime.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs7/pk7_mime.c' object='pkcs7/libcrypto_la-pk7_mime.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs7/libcrypto_la-pk7_mime.lo `test -f 'pkcs7/pk7_mime.c' || echo '$(srcdir)/'`pkcs7/pk7_mime.c pkcs7/libcrypto_la-pk7_smime.lo: pkcs7/pk7_smime.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs7/libcrypto_la-pk7_smime.lo -MD -MP -MF pkcs7/$(DEPDIR)/libcrypto_la-pk7_smime.Tpo -c -o pkcs7/libcrypto_la-pk7_smime.lo `test -f 'pkcs7/pk7_smime.c' || echo '$(srcdir)/'`pkcs7/pk7_smime.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs7/$(DEPDIR)/libcrypto_la-pk7_smime.Tpo pkcs7/$(DEPDIR)/libcrypto_la-pk7_smime.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs7/pk7_smime.c' object='pkcs7/libcrypto_la-pk7_smime.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs7/libcrypto_la-pk7_smime.lo `test -f 'pkcs7/pk7_smime.c' || echo '$(srcdir)/'`pkcs7/pk7_smime.c pkcs7/libcrypto_la-pkcs7err.lo: pkcs7/pkcs7err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT pkcs7/libcrypto_la-pkcs7err.lo -MD -MP -MF pkcs7/$(DEPDIR)/libcrypto_la-pkcs7err.Tpo -c -o pkcs7/libcrypto_la-pkcs7err.lo `test -f 'pkcs7/pkcs7err.c' || echo '$(srcdir)/'`pkcs7/pkcs7err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) pkcs7/$(DEPDIR)/libcrypto_la-pkcs7err.Tpo pkcs7/$(DEPDIR)/libcrypto_la-pkcs7err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs7/pkcs7err.c' object='pkcs7/libcrypto_la-pkcs7err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o pkcs7/libcrypto_la-pkcs7err.lo `test -f 'pkcs7/pkcs7err.c' || echo '$(srcdir)/'`pkcs7/pkcs7err.c poly1305/libcrypto_la-poly1305.lo: poly1305/poly1305.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT poly1305/libcrypto_la-poly1305.lo -MD -MP -MF poly1305/$(DEPDIR)/libcrypto_la-poly1305.Tpo -c -o poly1305/libcrypto_la-poly1305.lo `test -f 'poly1305/poly1305.c' || echo '$(srcdir)/'`poly1305/poly1305.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) poly1305/$(DEPDIR)/libcrypto_la-poly1305.Tpo poly1305/$(DEPDIR)/libcrypto_la-poly1305.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='poly1305/poly1305.c' object='poly1305/libcrypto_la-poly1305.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o poly1305/libcrypto_la-poly1305.lo `test -f 'poly1305/poly1305.c' || echo '$(srcdir)/'`poly1305/poly1305.c rand/libcrypto_la-rand_err.lo: rand/rand_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rand/libcrypto_la-rand_err.lo -MD -MP -MF rand/$(DEPDIR)/libcrypto_la-rand_err.Tpo -c -o rand/libcrypto_la-rand_err.lo `test -f 'rand/rand_err.c' || echo '$(srcdir)/'`rand/rand_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rand/$(DEPDIR)/libcrypto_la-rand_err.Tpo rand/$(DEPDIR)/libcrypto_la-rand_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rand/rand_err.c' object='rand/libcrypto_la-rand_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rand/libcrypto_la-rand_err.lo `test -f 'rand/rand_err.c' || echo '$(srcdir)/'`rand/rand_err.c rand/libcrypto_la-rand_lib.lo: rand/rand_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rand/libcrypto_la-rand_lib.lo -MD -MP -MF rand/$(DEPDIR)/libcrypto_la-rand_lib.Tpo -c -o rand/libcrypto_la-rand_lib.lo `test -f 'rand/rand_lib.c' || echo '$(srcdir)/'`rand/rand_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rand/$(DEPDIR)/libcrypto_la-rand_lib.Tpo rand/$(DEPDIR)/libcrypto_la-rand_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rand/rand_lib.c' object='rand/libcrypto_la-rand_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rand/libcrypto_la-rand_lib.lo `test -f 'rand/rand_lib.c' || echo '$(srcdir)/'`rand/rand_lib.c rand/libcrypto_la-randfile.lo: rand/randfile.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rand/libcrypto_la-randfile.lo -MD -MP -MF rand/$(DEPDIR)/libcrypto_la-randfile.Tpo -c -o rand/libcrypto_la-randfile.lo `test -f 'rand/randfile.c' || echo '$(srcdir)/'`rand/randfile.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rand/$(DEPDIR)/libcrypto_la-randfile.Tpo rand/$(DEPDIR)/libcrypto_la-randfile.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rand/randfile.c' object='rand/libcrypto_la-randfile.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rand/libcrypto_la-randfile.lo `test -f 'rand/randfile.c' || echo '$(srcdir)/'`rand/randfile.c rc2/libcrypto_la-rc2_cbc.lo: rc2/rc2_cbc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rc2/libcrypto_la-rc2_cbc.lo -MD -MP -MF rc2/$(DEPDIR)/libcrypto_la-rc2_cbc.Tpo -c -o rc2/libcrypto_la-rc2_cbc.lo `test -f 'rc2/rc2_cbc.c' || echo '$(srcdir)/'`rc2/rc2_cbc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rc2/$(DEPDIR)/libcrypto_la-rc2_cbc.Tpo rc2/$(DEPDIR)/libcrypto_la-rc2_cbc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rc2/rc2_cbc.c' object='rc2/libcrypto_la-rc2_cbc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rc2/libcrypto_la-rc2_cbc.lo `test -f 'rc2/rc2_cbc.c' || echo '$(srcdir)/'`rc2/rc2_cbc.c rc2/libcrypto_la-rc2_ecb.lo: rc2/rc2_ecb.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rc2/libcrypto_la-rc2_ecb.lo -MD -MP -MF rc2/$(DEPDIR)/libcrypto_la-rc2_ecb.Tpo -c -o rc2/libcrypto_la-rc2_ecb.lo `test -f 'rc2/rc2_ecb.c' || echo '$(srcdir)/'`rc2/rc2_ecb.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rc2/$(DEPDIR)/libcrypto_la-rc2_ecb.Tpo rc2/$(DEPDIR)/libcrypto_la-rc2_ecb.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rc2/rc2_ecb.c' object='rc2/libcrypto_la-rc2_ecb.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rc2/libcrypto_la-rc2_ecb.lo `test -f 'rc2/rc2_ecb.c' || echo '$(srcdir)/'`rc2/rc2_ecb.c rc2/libcrypto_la-rc2_skey.lo: rc2/rc2_skey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rc2/libcrypto_la-rc2_skey.lo -MD -MP -MF rc2/$(DEPDIR)/libcrypto_la-rc2_skey.Tpo -c -o rc2/libcrypto_la-rc2_skey.lo `test -f 'rc2/rc2_skey.c' || echo '$(srcdir)/'`rc2/rc2_skey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rc2/$(DEPDIR)/libcrypto_la-rc2_skey.Tpo rc2/$(DEPDIR)/libcrypto_la-rc2_skey.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rc2/rc2_skey.c' object='rc2/libcrypto_la-rc2_skey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rc2/libcrypto_la-rc2_skey.lo `test -f 'rc2/rc2_skey.c' || echo '$(srcdir)/'`rc2/rc2_skey.c rc2/libcrypto_la-rc2cfb64.lo: rc2/rc2cfb64.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rc2/libcrypto_la-rc2cfb64.lo -MD -MP -MF rc2/$(DEPDIR)/libcrypto_la-rc2cfb64.Tpo -c -o rc2/libcrypto_la-rc2cfb64.lo `test -f 'rc2/rc2cfb64.c' || echo '$(srcdir)/'`rc2/rc2cfb64.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rc2/$(DEPDIR)/libcrypto_la-rc2cfb64.Tpo rc2/$(DEPDIR)/libcrypto_la-rc2cfb64.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rc2/rc2cfb64.c' object='rc2/libcrypto_la-rc2cfb64.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rc2/libcrypto_la-rc2cfb64.lo `test -f 'rc2/rc2cfb64.c' || echo '$(srcdir)/'`rc2/rc2cfb64.c rc2/libcrypto_la-rc2ofb64.lo: rc2/rc2ofb64.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rc2/libcrypto_la-rc2ofb64.lo -MD -MP -MF rc2/$(DEPDIR)/libcrypto_la-rc2ofb64.Tpo -c -o rc2/libcrypto_la-rc2ofb64.lo `test -f 'rc2/rc2ofb64.c' || echo '$(srcdir)/'`rc2/rc2ofb64.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rc2/$(DEPDIR)/libcrypto_la-rc2ofb64.Tpo rc2/$(DEPDIR)/libcrypto_la-rc2ofb64.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rc2/rc2ofb64.c' object='rc2/libcrypto_la-rc2ofb64.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rc2/libcrypto_la-rc2ofb64.lo `test -f 'rc2/rc2ofb64.c' || echo '$(srcdir)/'`rc2/rc2ofb64.c rc4/libcrypto_la-rc4_enc.lo: rc4/rc4_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rc4/libcrypto_la-rc4_enc.lo -MD -MP -MF rc4/$(DEPDIR)/libcrypto_la-rc4_enc.Tpo -c -o rc4/libcrypto_la-rc4_enc.lo `test -f 'rc4/rc4_enc.c' || echo '$(srcdir)/'`rc4/rc4_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rc4/$(DEPDIR)/libcrypto_la-rc4_enc.Tpo rc4/$(DEPDIR)/libcrypto_la-rc4_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rc4/rc4_enc.c' object='rc4/libcrypto_la-rc4_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rc4/libcrypto_la-rc4_enc.lo `test -f 'rc4/rc4_enc.c' || echo '$(srcdir)/'`rc4/rc4_enc.c rc4/libcrypto_la-rc4_skey.lo: rc4/rc4_skey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rc4/libcrypto_la-rc4_skey.lo -MD -MP -MF rc4/$(DEPDIR)/libcrypto_la-rc4_skey.Tpo -c -o rc4/libcrypto_la-rc4_skey.lo `test -f 'rc4/rc4_skey.c' || echo '$(srcdir)/'`rc4/rc4_skey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rc4/$(DEPDIR)/libcrypto_la-rc4_skey.Tpo rc4/$(DEPDIR)/libcrypto_la-rc4_skey.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rc4/rc4_skey.c' object='rc4/libcrypto_la-rc4_skey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rc4/libcrypto_la-rc4_skey.lo `test -f 'rc4/rc4_skey.c' || echo '$(srcdir)/'`rc4/rc4_skey.c rc4/libcrypto_la-rc4_utl.lo: rc4/rc4_utl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rc4/libcrypto_la-rc4_utl.lo -MD -MP -MF rc4/$(DEPDIR)/libcrypto_la-rc4_utl.Tpo -c -o rc4/libcrypto_la-rc4_utl.lo `test -f 'rc4/rc4_utl.c' || echo '$(srcdir)/'`rc4/rc4_utl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rc4/$(DEPDIR)/libcrypto_la-rc4_utl.Tpo rc4/$(DEPDIR)/libcrypto_la-rc4_utl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rc4/rc4_utl.c' object='rc4/libcrypto_la-rc4_utl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rc4/libcrypto_la-rc4_utl.lo `test -f 'rc4/rc4_utl.c' || echo '$(srcdir)/'`rc4/rc4_utl.c ripemd/libcrypto_la-rmd_dgst.lo: ripemd/rmd_dgst.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ripemd/libcrypto_la-rmd_dgst.lo -MD -MP -MF ripemd/$(DEPDIR)/libcrypto_la-rmd_dgst.Tpo -c -o ripemd/libcrypto_la-rmd_dgst.lo `test -f 'ripemd/rmd_dgst.c' || echo '$(srcdir)/'`ripemd/rmd_dgst.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ripemd/$(DEPDIR)/libcrypto_la-rmd_dgst.Tpo ripemd/$(DEPDIR)/libcrypto_la-rmd_dgst.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ripemd/rmd_dgst.c' object='ripemd/libcrypto_la-rmd_dgst.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ripemd/libcrypto_la-rmd_dgst.lo `test -f 'ripemd/rmd_dgst.c' || echo '$(srcdir)/'`ripemd/rmd_dgst.c ripemd/libcrypto_la-rmd_one.lo: ripemd/rmd_one.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ripemd/libcrypto_la-rmd_one.lo -MD -MP -MF ripemd/$(DEPDIR)/libcrypto_la-rmd_one.Tpo -c -o ripemd/libcrypto_la-rmd_one.lo `test -f 'ripemd/rmd_one.c' || echo '$(srcdir)/'`ripemd/rmd_one.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ripemd/$(DEPDIR)/libcrypto_la-rmd_one.Tpo ripemd/$(DEPDIR)/libcrypto_la-rmd_one.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ripemd/rmd_one.c' object='ripemd/libcrypto_la-rmd_one.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ripemd/libcrypto_la-rmd_one.lo `test -f 'ripemd/rmd_one.c' || echo '$(srcdir)/'`ripemd/rmd_one.c rsa/libcrypto_la-rsa_ameth.lo: rsa/rsa_ameth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_ameth.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_ameth.Tpo -c -o rsa/libcrypto_la-rsa_ameth.lo `test -f 'rsa/rsa_ameth.c' || echo '$(srcdir)/'`rsa/rsa_ameth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_ameth.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_ameth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_ameth.c' object='rsa/libcrypto_la-rsa_ameth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_ameth.lo `test -f 'rsa/rsa_ameth.c' || echo '$(srcdir)/'`rsa/rsa_ameth.c rsa/libcrypto_la-rsa_asn1.lo: rsa/rsa_asn1.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_asn1.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_asn1.Tpo -c -o rsa/libcrypto_la-rsa_asn1.lo `test -f 'rsa/rsa_asn1.c' || echo '$(srcdir)/'`rsa/rsa_asn1.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_asn1.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_asn1.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_asn1.c' object='rsa/libcrypto_la-rsa_asn1.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_asn1.lo `test -f 'rsa/rsa_asn1.c' || echo '$(srcdir)/'`rsa/rsa_asn1.c rsa/libcrypto_la-rsa_chk.lo: rsa/rsa_chk.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_chk.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_chk.Tpo -c -o rsa/libcrypto_la-rsa_chk.lo `test -f 'rsa/rsa_chk.c' || echo '$(srcdir)/'`rsa/rsa_chk.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_chk.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_chk.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_chk.c' object='rsa/libcrypto_la-rsa_chk.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_chk.lo `test -f 'rsa/rsa_chk.c' || echo '$(srcdir)/'`rsa/rsa_chk.c rsa/libcrypto_la-rsa_crpt.lo: rsa/rsa_crpt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_crpt.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_crpt.Tpo -c -o rsa/libcrypto_la-rsa_crpt.lo `test -f 'rsa/rsa_crpt.c' || echo '$(srcdir)/'`rsa/rsa_crpt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_crpt.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_crpt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_crpt.c' object='rsa/libcrypto_la-rsa_crpt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_crpt.lo `test -f 'rsa/rsa_crpt.c' || echo '$(srcdir)/'`rsa/rsa_crpt.c rsa/libcrypto_la-rsa_depr.lo: rsa/rsa_depr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_depr.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_depr.Tpo -c -o rsa/libcrypto_la-rsa_depr.lo `test -f 'rsa/rsa_depr.c' || echo '$(srcdir)/'`rsa/rsa_depr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_depr.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_depr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_depr.c' object='rsa/libcrypto_la-rsa_depr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_depr.lo `test -f 'rsa/rsa_depr.c' || echo '$(srcdir)/'`rsa/rsa_depr.c rsa/libcrypto_la-rsa_eay.lo: rsa/rsa_eay.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_eay.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_eay.Tpo -c -o rsa/libcrypto_la-rsa_eay.lo `test -f 'rsa/rsa_eay.c' || echo '$(srcdir)/'`rsa/rsa_eay.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_eay.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_eay.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_eay.c' object='rsa/libcrypto_la-rsa_eay.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_eay.lo `test -f 'rsa/rsa_eay.c' || echo '$(srcdir)/'`rsa/rsa_eay.c rsa/libcrypto_la-rsa_err.lo: rsa/rsa_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_err.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_err.Tpo -c -o rsa/libcrypto_la-rsa_err.lo `test -f 'rsa/rsa_err.c' || echo '$(srcdir)/'`rsa/rsa_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_err.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_err.c' object='rsa/libcrypto_la-rsa_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_err.lo `test -f 'rsa/rsa_err.c' || echo '$(srcdir)/'`rsa/rsa_err.c rsa/libcrypto_la-rsa_gen.lo: rsa/rsa_gen.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_gen.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_gen.Tpo -c -o rsa/libcrypto_la-rsa_gen.lo `test -f 'rsa/rsa_gen.c' || echo '$(srcdir)/'`rsa/rsa_gen.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_gen.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_gen.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_gen.c' object='rsa/libcrypto_la-rsa_gen.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_gen.lo `test -f 'rsa/rsa_gen.c' || echo '$(srcdir)/'`rsa/rsa_gen.c rsa/libcrypto_la-rsa_lib.lo: rsa/rsa_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_lib.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_lib.Tpo -c -o rsa/libcrypto_la-rsa_lib.lo `test -f 'rsa/rsa_lib.c' || echo '$(srcdir)/'`rsa/rsa_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_lib.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_lib.c' object='rsa/libcrypto_la-rsa_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_lib.lo `test -f 'rsa/rsa_lib.c' || echo '$(srcdir)/'`rsa/rsa_lib.c rsa/libcrypto_la-rsa_none.lo: rsa/rsa_none.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_none.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_none.Tpo -c -o rsa/libcrypto_la-rsa_none.lo `test -f 'rsa/rsa_none.c' || echo '$(srcdir)/'`rsa/rsa_none.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_none.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_none.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_none.c' object='rsa/libcrypto_la-rsa_none.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_none.lo `test -f 'rsa/rsa_none.c' || echo '$(srcdir)/'`rsa/rsa_none.c rsa/libcrypto_la-rsa_oaep.lo: rsa/rsa_oaep.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_oaep.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_oaep.Tpo -c -o rsa/libcrypto_la-rsa_oaep.lo `test -f 'rsa/rsa_oaep.c' || echo '$(srcdir)/'`rsa/rsa_oaep.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_oaep.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_oaep.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_oaep.c' object='rsa/libcrypto_la-rsa_oaep.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_oaep.lo `test -f 'rsa/rsa_oaep.c' || echo '$(srcdir)/'`rsa/rsa_oaep.c rsa/libcrypto_la-rsa_pk1.lo: rsa/rsa_pk1.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_pk1.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_pk1.Tpo -c -o rsa/libcrypto_la-rsa_pk1.lo `test -f 'rsa/rsa_pk1.c' || echo '$(srcdir)/'`rsa/rsa_pk1.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_pk1.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_pk1.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_pk1.c' object='rsa/libcrypto_la-rsa_pk1.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_pk1.lo `test -f 'rsa/rsa_pk1.c' || echo '$(srcdir)/'`rsa/rsa_pk1.c rsa/libcrypto_la-rsa_pmeth.lo: rsa/rsa_pmeth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_pmeth.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_pmeth.Tpo -c -o rsa/libcrypto_la-rsa_pmeth.lo `test -f 'rsa/rsa_pmeth.c' || echo '$(srcdir)/'`rsa/rsa_pmeth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_pmeth.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_pmeth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_pmeth.c' object='rsa/libcrypto_la-rsa_pmeth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_pmeth.lo `test -f 'rsa/rsa_pmeth.c' || echo '$(srcdir)/'`rsa/rsa_pmeth.c rsa/libcrypto_la-rsa_prn.lo: rsa/rsa_prn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_prn.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_prn.Tpo -c -o rsa/libcrypto_la-rsa_prn.lo `test -f 'rsa/rsa_prn.c' || echo '$(srcdir)/'`rsa/rsa_prn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_prn.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_prn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_prn.c' object='rsa/libcrypto_la-rsa_prn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_prn.lo `test -f 'rsa/rsa_prn.c' || echo '$(srcdir)/'`rsa/rsa_prn.c rsa/libcrypto_la-rsa_pss.lo: rsa/rsa_pss.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_pss.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_pss.Tpo -c -o rsa/libcrypto_la-rsa_pss.lo `test -f 'rsa/rsa_pss.c' || echo '$(srcdir)/'`rsa/rsa_pss.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_pss.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_pss.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_pss.c' object='rsa/libcrypto_la-rsa_pss.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_pss.lo `test -f 'rsa/rsa_pss.c' || echo '$(srcdir)/'`rsa/rsa_pss.c rsa/libcrypto_la-rsa_saos.lo: rsa/rsa_saos.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_saos.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_saos.Tpo -c -o rsa/libcrypto_la-rsa_saos.lo `test -f 'rsa/rsa_saos.c' || echo '$(srcdir)/'`rsa/rsa_saos.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_saos.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_saos.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_saos.c' object='rsa/libcrypto_la-rsa_saos.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_saos.lo `test -f 'rsa/rsa_saos.c' || echo '$(srcdir)/'`rsa/rsa_saos.c rsa/libcrypto_la-rsa_sign.lo: rsa/rsa_sign.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_sign.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_sign.Tpo -c -o rsa/libcrypto_la-rsa_sign.lo `test -f 'rsa/rsa_sign.c' || echo '$(srcdir)/'`rsa/rsa_sign.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_sign.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_sign.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_sign.c' object='rsa/libcrypto_la-rsa_sign.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_sign.lo `test -f 'rsa/rsa_sign.c' || echo '$(srcdir)/'`rsa/rsa_sign.c rsa/libcrypto_la-rsa_ssl.lo: rsa/rsa_ssl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_ssl.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_ssl.Tpo -c -o rsa/libcrypto_la-rsa_ssl.lo `test -f 'rsa/rsa_ssl.c' || echo '$(srcdir)/'`rsa/rsa_ssl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_ssl.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_ssl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_ssl.c' object='rsa/libcrypto_la-rsa_ssl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_ssl.lo `test -f 'rsa/rsa_ssl.c' || echo '$(srcdir)/'`rsa/rsa_ssl.c rsa/libcrypto_la-rsa_x931.lo: rsa/rsa_x931.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT rsa/libcrypto_la-rsa_x931.lo -MD -MP -MF rsa/$(DEPDIR)/libcrypto_la-rsa_x931.Tpo -c -o rsa/libcrypto_la-rsa_x931.lo `test -f 'rsa/rsa_x931.c' || echo '$(srcdir)/'`rsa/rsa_x931.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) rsa/$(DEPDIR)/libcrypto_la-rsa_x931.Tpo rsa/$(DEPDIR)/libcrypto_la-rsa_x931.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa/rsa_x931.c' object='rsa/libcrypto_la-rsa_x931.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o rsa/libcrypto_la-rsa_x931.lo `test -f 'rsa/rsa_x931.c' || echo '$(srcdir)/'`rsa/rsa_x931.c sha/libcrypto_la-sha1_one.lo: sha/sha1_one.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT sha/libcrypto_la-sha1_one.lo -MD -MP -MF sha/$(DEPDIR)/libcrypto_la-sha1_one.Tpo -c -o sha/libcrypto_la-sha1_one.lo `test -f 'sha/sha1_one.c' || echo '$(srcdir)/'`sha/sha1_one.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) sha/$(DEPDIR)/libcrypto_la-sha1_one.Tpo sha/$(DEPDIR)/libcrypto_la-sha1_one.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha/sha1_one.c' object='sha/libcrypto_la-sha1_one.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o sha/libcrypto_la-sha1_one.lo `test -f 'sha/sha1_one.c' || echo '$(srcdir)/'`sha/sha1_one.c sha/libcrypto_la-sha1dgst.lo: sha/sha1dgst.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT sha/libcrypto_la-sha1dgst.lo -MD -MP -MF sha/$(DEPDIR)/libcrypto_la-sha1dgst.Tpo -c -o sha/libcrypto_la-sha1dgst.lo `test -f 'sha/sha1dgst.c' || echo '$(srcdir)/'`sha/sha1dgst.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) sha/$(DEPDIR)/libcrypto_la-sha1dgst.Tpo sha/$(DEPDIR)/libcrypto_la-sha1dgst.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha/sha1dgst.c' object='sha/libcrypto_la-sha1dgst.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o sha/libcrypto_la-sha1dgst.lo `test -f 'sha/sha1dgst.c' || echo '$(srcdir)/'`sha/sha1dgst.c sha/libcrypto_la-sha256.lo: sha/sha256.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT sha/libcrypto_la-sha256.lo -MD -MP -MF sha/$(DEPDIR)/libcrypto_la-sha256.Tpo -c -o sha/libcrypto_la-sha256.lo `test -f 'sha/sha256.c' || echo '$(srcdir)/'`sha/sha256.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) sha/$(DEPDIR)/libcrypto_la-sha256.Tpo sha/$(DEPDIR)/libcrypto_la-sha256.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha/sha256.c' object='sha/libcrypto_la-sha256.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o sha/libcrypto_la-sha256.lo `test -f 'sha/sha256.c' || echo '$(srcdir)/'`sha/sha256.c sha/libcrypto_la-sha512.lo: sha/sha512.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT sha/libcrypto_la-sha512.lo -MD -MP -MF sha/$(DEPDIR)/libcrypto_la-sha512.Tpo -c -o sha/libcrypto_la-sha512.lo `test -f 'sha/sha512.c' || echo '$(srcdir)/'`sha/sha512.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) sha/$(DEPDIR)/libcrypto_la-sha512.Tpo sha/$(DEPDIR)/libcrypto_la-sha512.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha/sha512.c' object='sha/libcrypto_la-sha512.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o sha/libcrypto_la-sha512.lo `test -f 'sha/sha512.c' || echo '$(srcdir)/'`sha/sha512.c sha/libcrypto_la-sha_dgst.lo: sha/sha_dgst.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT sha/libcrypto_la-sha_dgst.lo -MD -MP -MF sha/$(DEPDIR)/libcrypto_la-sha_dgst.Tpo -c -o sha/libcrypto_la-sha_dgst.lo `test -f 'sha/sha_dgst.c' || echo '$(srcdir)/'`sha/sha_dgst.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) sha/$(DEPDIR)/libcrypto_la-sha_dgst.Tpo sha/$(DEPDIR)/libcrypto_la-sha_dgst.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha/sha_dgst.c' object='sha/libcrypto_la-sha_dgst.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o sha/libcrypto_la-sha_dgst.lo `test -f 'sha/sha_dgst.c' || echo '$(srcdir)/'`sha/sha_dgst.c sha/libcrypto_la-sha_one.lo: sha/sha_one.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT sha/libcrypto_la-sha_one.lo -MD -MP -MF sha/$(DEPDIR)/libcrypto_la-sha_one.Tpo -c -o sha/libcrypto_la-sha_one.lo `test -f 'sha/sha_one.c' || echo '$(srcdir)/'`sha/sha_one.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) sha/$(DEPDIR)/libcrypto_la-sha_one.Tpo sha/$(DEPDIR)/libcrypto_la-sha_one.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha/sha_one.c' object='sha/libcrypto_la-sha_one.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o sha/libcrypto_la-sha_one.lo `test -f 'sha/sha_one.c' || echo '$(srcdir)/'`sha/sha_one.c stack/libcrypto_la-stack.lo: stack/stack.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT stack/libcrypto_la-stack.lo -MD -MP -MF stack/$(DEPDIR)/libcrypto_la-stack.Tpo -c -o stack/libcrypto_la-stack.lo `test -f 'stack/stack.c' || echo '$(srcdir)/'`stack/stack.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) stack/$(DEPDIR)/libcrypto_la-stack.Tpo stack/$(DEPDIR)/libcrypto_la-stack.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='stack/stack.c' object='stack/libcrypto_la-stack.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o stack/libcrypto_la-stack.lo `test -f 'stack/stack.c' || echo '$(srcdir)/'`stack/stack.c ts/libcrypto_la-ts_asn1.lo: ts/ts_asn1.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ts/libcrypto_la-ts_asn1.lo -MD -MP -MF ts/$(DEPDIR)/libcrypto_la-ts_asn1.Tpo -c -o ts/libcrypto_la-ts_asn1.lo `test -f 'ts/ts_asn1.c' || echo '$(srcdir)/'`ts/ts_asn1.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ts/$(DEPDIR)/libcrypto_la-ts_asn1.Tpo ts/$(DEPDIR)/libcrypto_la-ts_asn1.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ts/ts_asn1.c' object='ts/libcrypto_la-ts_asn1.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ts/libcrypto_la-ts_asn1.lo `test -f 'ts/ts_asn1.c' || echo '$(srcdir)/'`ts/ts_asn1.c ts/libcrypto_la-ts_conf.lo: ts/ts_conf.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ts/libcrypto_la-ts_conf.lo -MD -MP -MF ts/$(DEPDIR)/libcrypto_la-ts_conf.Tpo -c -o ts/libcrypto_la-ts_conf.lo `test -f 'ts/ts_conf.c' || echo '$(srcdir)/'`ts/ts_conf.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ts/$(DEPDIR)/libcrypto_la-ts_conf.Tpo ts/$(DEPDIR)/libcrypto_la-ts_conf.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ts/ts_conf.c' object='ts/libcrypto_la-ts_conf.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ts/libcrypto_la-ts_conf.lo `test -f 'ts/ts_conf.c' || echo '$(srcdir)/'`ts/ts_conf.c ts/libcrypto_la-ts_err.lo: ts/ts_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ts/libcrypto_la-ts_err.lo -MD -MP -MF ts/$(DEPDIR)/libcrypto_la-ts_err.Tpo -c -o ts/libcrypto_la-ts_err.lo `test -f 'ts/ts_err.c' || echo '$(srcdir)/'`ts/ts_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ts/$(DEPDIR)/libcrypto_la-ts_err.Tpo ts/$(DEPDIR)/libcrypto_la-ts_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ts/ts_err.c' object='ts/libcrypto_la-ts_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ts/libcrypto_la-ts_err.lo `test -f 'ts/ts_err.c' || echo '$(srcdir)/'`ts/ts_err.c ts/libcrypto_la-ts_lib.lo: ts/ts_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ts/libcrypto_la-ts_lib.lo -MD -MP -MF ts/$(DEPDIR)/libcrypto_la-ts_lib.Tpo -c -o ts/libcrypto_la-ts_lib.lo `test -f 'ts/ts_lib.c' || echo '$(srcdir)/'`ts/ts_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ts/$(DEPDIR)/libcrypto_la-ts_lib.Tpo ts/$(DEPDIR)/libcrypto_la-ts_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ts/ts_lib.c' object='ts/libcrypto_la-ts_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ts/libcrypto_la-ts_lib.lo `test -f 'ts/ts_lib.c' || echo '$(srcdir)/'`ts/ts_lib.c ts/libcrypto_la-ts_req_print.lo: ts/ts_req_print.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ts/libcrypto_la-ts_req_print.lo -MD -MP -MF ts/$(DEPDIR)/libcrypto_la-ts_req_print.Tpo -c -o ts/libcrypto_la-ts_req_print.lo `test -f 'ts/ts_req_print.c' || echo '$(srcdir)/'`ts/ts_req_print.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ts/$(DEPDIR)/libcrypto_la-ts_req_print.Tpo ts/$(DEPDIR)/libcrypto_la-ts_req_print.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ts/ts_req_print.c' object='ts/libcrypto_la-ts_req_print.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ts/libcrypto_la-ts_req_print.lo `test -f 'ts/ts_req_print.c' || echo '$(srcdir)/'`ts/ts_req_print.c ts/libcrypto_la-ts_req_utils.lo: ts/ts_req_utils.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ts/libcrypto_la-ts_req_utils.lo -MD -MP -MF ts/$(DEPDIR)/libcrypto_la-ts_req_utils.Tpo -c -o ts/libcrypto_la-ts_req_utils.lo `test -f 'ts/ts_req_utils.c' || echo '$(srcdir)/'`ts/ts_req_utils.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ts/$(DEPDIR)/libcrypto_la-ts_req_utils.Tpo ts/$(DEPDIR)/libcrypto_la-ts_req_utils.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ts/ts_req_utils.c' object='ts/libcrypto_la-ts_req_utils.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ts/libcrypto_la-ts_req_utils.lo `test -f 'ts/ts_req_utils.c' || echo '$(srcdir)/'`ts/ts_req_utils.c ts/libcrypto_la-ts_rsp_print.lo: ts/ts_rsp_print.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ts/libcrypto_la-ts_rsp_print.lo -MD -MP -MF ts/$(DEPDIR)/libcrypto_la-ts_rsp_print.Tpo -c -o ts/libcrypto_la-ts_rsp_print.lo `test -f 'ts/ts_rsp_print.c' || echo '$(srcdir)/'`ts/ts_rsp_print.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ts/$(DEPDIR)/libcrypto_la-ts_rsp_print.Tpo ts/$(DEPDIR)/libcrypto_la-ts_rsp_print.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ts/ts_rsp_print.c' object='ts/libcrypto_la-ts_rsp_print.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ts/libcrypto_la-ts_rsp_print.lo `test -f 'ts/ts_rsp_print.c' || echo '$(srcdir)/'`ts/ts_rsp_print.c ts/libcrypto_la-ts_rsp_sign.lo: ts/ts_rsp_sign.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ts/libcrypto_la-ts_rsp_sign.lo -MD -MP -MF ts/$(DEPDIR)/libcrypto_la-ts_rsp_sign.Tpo -c -o ts/libcrypto_la-ts_rsp_sign.lo `test -f 'ts/ts_rsp_sign.c' || echo '$(srcdir)/'`ts/ts_rsp_sign.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ts/$(DEPDIR)/libcrypto_la-ts_rsp_sign.Tpo ts/$(DEPDIR)/libcrypto_la-ts_rsp_sign.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ts/ts_rsp_sign.c' object='ts/libcrypto_la-ts_rsp_sign.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ts/libcrypto_la-ts_rsp_sign.lo `test -f 'ts/ts_rsp_sign.c' || echo '$(srcdir)/'`ts/ts_rsp_sign.c ts/libcrypto_la-ts_rsp_utils.lo: ts/ts_rsp_utils.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ts/libcrypto_la-ts_rsp_utils.lo -MD -MP -MF ts/$(DEPDIR)/libcrypto_la-ts_rsp_utils.Tpo -c -o ts/libcrypto_la-ts_rsp_utils.lo `test -f 'ts/ts_rsp_utils.c' || echo '$(srcdir)/'`ts/ts_rsp_utils.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ts/$(DEPDIR)/libcrypto_la-ts_rsp_utils.Tpo ts/$(DEPDIR)/libcrypto_la-ts_rsp_utils.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ts/ts_rsp_utils.c' object='ts/libcrypto_la-ts_rsp_utils.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ts/libcrypto_la-ts_rsp_utils.lo `test -f 'ts/ts_rsp_utils.c' || echo '$(srcdir)/'`ts/ts_rsp_utils.c ts/libcrypto_la-ts_rsp_verify.lo: ts/ts_rsp_verify.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ts/libcrypto_la-ts_rsp_verify.lo -MD -MP -MF ts/$(DEPDIR)/libcrypto_la-ts_rsp_verify.Tpo -c -o ts/libcrypto_la-ts_rsp_verify.lo `test -f 'ts/ts_rsp_verify.c' || echo '$(srcdir)/'`ts/ts_rsp_verify.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ts/$(DEPDIR)/libcrypto_la-ts_rsp_verify.Tpo ts/$(DEPDIR)/libcrypto_la-ts_rsp_verify.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ts/ts_rsp_verify.c' object='ts/libcrypto_la-ts_rsp_verify.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ts/libcrypto_la-ts_rsp_verify.lo `test -f 'ts/ts_rsp_verify.c' || echo '$(srcdir)/'`ts/ts_rsp_verify.c ts/libcrypto_la-ts_verify_ctx.lo: ts/ts_verify_ctx.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ts/libcrypto_la-ts_verify_ctx.lo -MD -MP -MF ts/$(DEPDIR)/libcrypto_la-ts_verify_ctx.Tpo -c -o ts/libcrypto_la-ts_verify_ctx.lo `test -f 'ts/ts_verify_ctx.c' || echo '$(srcdir)/'`ts/ts_verify_ctx.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ts/$(DEPDIR)/libcrypto_la-ts_verify_ctx.Tpo ts/$(DEPDIR)/libcrypto_la-ts_verify_ctx.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ts/ts_verify_ctx.c' object='ts/libcrypto_la-ts_verify_ctx.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ts/libcrypto_la-ts_verify_ctx.lo `test -f 'ts/ts_verify_ctx.c' || echo '$(srcdir)/'`ts/ts_verify_ctx.c txt_db/libcrypto_la-txt_db.lo: txt_db/txt_db.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT txt_db/libcrypto_la-txt_db.lo -MD -MP -MF txt_db/$(DEPDIR)/libcrypto_la-txt_db.Tpo -c -o txt_db/libcrypto_la-txt_db.lo `test -f 'txt_db/txt_db.c' || echo '$(srcdir)/'`txt_db/txt_db.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) txt_db/$(DEPDIR)/libcrypto_la-txt_db.Tpo txt_db/$(DEPDIR)/libcrypto_la-txt_db.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='txt_db/txt_db.c' object='txt_db/libcrypto_la-txt_db.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o txt_db/libcrypto_la-txt_db.lo `test -f 'txt_db/txt_db.c' || echo '$(srcdir)/'`txt_db/txt_db.c ui/libcrypto_la-ui_err.lo: ui/ui_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ui/libcrypto_la-ui_err.lo -MD -MP -MF ui/$(DEPDIR)/libcrypto_la-ui_err.Tpo -c -o ui/libcrypto_la-ui_err.lo `test -f 'ui/ui_err.c' || echo '$(srcdir)/'`ui/ui_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ui/$(DEPDIR)/libcrypto_la-ui_err.Tpo ui/$(DEPDIR)/libcrypto_la-ui_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ui/ui_err.c' object='ui/libcrypto_la-ui_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ui/libcrypto_la-ui_err.lo `test -f 'ui/ui_err.c' || echo '$(srcdir)/'`ui/ui_err.c ui/libcrypto_la-ui_lib.lo: ui/ui_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ui/libcrypto_la-ui_lib.lo -MD -MP -MF ui/$(DEPDIR)/libcrypto_la-ui_lib.Tpo -c -o ui/libcrypto_la-ui_lib.lo `test -f 'ui/ui_lib.c' || echo '$(srcdir)/'`ui/ui_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ui/$(DEPDIR)/libcrypto_la-ui_lib.Tpo ui/$(DEPDIR)/libcrypto_la-ui_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ui/ui_lib.c' object='ui/libcrypto_la-ui_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ui/libcrypto_la-ui_lib.lo `test -f 'ui/ui_lib.c' || echo '$(srcdir)/'`ui/ui_lib.c ui/libcrypto_la-ui_openssl.lo: ui/ui_openssl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ui/libcrypto_la-ui_openssl.lo -MD -MP -MF ui/$(DEPDIR)/libcrypto_la-ui_openssl.Tpo -c -o ui/libcrypto_la-ui_openssl.lo `test -f 'ui/ui_openssl.c' || echo '$(srcdir)/'`ui/ui_openssl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ui/$(DEPDIR)/libcrypto_la-ui_openssl.Tpo ui/$(DEPDIR)/libcrypto_la-ui_openssl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ui/ui_openssl.c' object='ui/libcrypto_la-ui_openssl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ui/libcrypto_la-ui_openssl.lo `test -f 'ui/ui_openssl.c' || echo '$(srcdir)/'`ui/ui_openssl.c ui/libcrypto_la-ui_util.lo: ui/ui_util.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT ui/libcrypto_la-ui_util.lo -MD -MP -MF ui/$(DEPDIR)/libcrypto_la-ui_util.Tpo -c -o ui/libcrypto_la-ui_util.lo `test -f 'ui/ui_util.c' || echo '$(srcdir)/'`ui/ui_util.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ui/$(DEPDIR)/libcrypto_la-ui_util.Tpo ui/$(DEPDIR)/libcrypto_la-ui_util.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ui/ui_util.c' object='ui/libcrypto_la-ui_util.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o ui/libcrypto_la-ui_util.lo `test -f 'ui/ui_util.c' || echo '$(srcdir)/'`ui/ui_util.c whrlpool/libcrypto_la-wp_block.lo: whrlpool/wp_block.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT whrlpool/libcrypto_la-wp_block.lo -MD -MP -MF whrlpool/$(DEPDIR)/libcrypto_la-wp_block.Tpo -c -o whrlpool/libcrypto_la-wp_block.lo `test -f 'whrlpool/wp_block.c' || echo '$(srcdir)/'`whrlpool/wp_block.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) whrlpool/$(DEPDIR)/libcrypto_la-wp_block.Tpo whrlpool/$(DEPDIR)/libcrypto_la-wp_block.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='whrlpool/wp_block.c' object='whrlpool/libcrypto_la-wp_block.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o whrlpool/libcrypto_la-wp_block.lo `test -f 'whrlpool/wp_block.c' || echo '$(srcdir)/'`whrlpool/wp_block.c whrlpool/libcrypto_la-wp_dgst.lo: whrlpool/wp_dgst.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT whrlpool/libcrypto_la-wp_dgst.lo -MD -MP -MF whrlpool/$(DEPDIR)/libcrypto_la-wp_dgst.Tpo -c -o whrlpool/libcrypto_la-wp_dgst.lo `test -f 'whrlpool/wp_dgst.c' || echo '$(srcdir)/'`whrlpool/wp_dgst.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) whrlpool/$(DEPDIR)/libcrypto_la-wp_dgst.Tpo whrlpool/$(DEPDIR)/libcrypto_la-wp_dgst.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='whrlpool/wp_dgst.c' object='whrlpool/libcrypto_la-wp_dgst.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o whrlpool/libcrypto_la-wp_dgst.lo `test -f 'whrlpool/wp_dgst.c' || echo '$(srcdir)/'`whrlpool/wp_dgst.c x509/libcrypto_la-by_dir.lo: x509/by_dir.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-by_dir.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-by_dir.Tpo -c -o x509/libcrypto_la-by_dir.lo `test -f 'x509/by_dir.c' || echo '$(srcdir)/'`x509/by_dir.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-by_dir.Tpo x509/$(DEPDIR)/libcrypto_la-by_dir.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/by_dir.c' object='x509/libcrypto_la-by_dir.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-by_dir.lo `test -f 'x509/by_dir.c' || echo '$(srcdir)/'`x509/by_dir.c x509/libcrypto_la-by_file.lo: x509/by_file.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-by_file.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-by_file.Tpo -c -o x509/libcrypto_la-by_file.lo `test -f 'x509/by_file.c' || echo '$(srcdir)/'`x509/by_file.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-by_file.Tpo x509/$(DEPDIR)/libcrypto_la-by_file.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/by_file.c' object='x509/libcrypto_la-by_file.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-by_file.lo `test -f 'x509/by_file.c' || echo '$(srcdir)/'`x509/by_file.c x509/libcrypto_la-x509_att.lo: x509/x509_att.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509_att.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509_att.Tpo -c -o x509/libcrypto_la-x509_att.lo `test -f 'x509/x509_att.c' || echo '$(srcdir)/'`x509/x509_att.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509_att.Tpo x509/$(DEPDIR)/libcrypto_la-x509_att.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509_att.c' object='x509/libcrypto_la-x509_att.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509_att.lo `test -f 'x509/x509_att.c' || echo '$(srcdir)/'`x509/x509_att.c x509/libcrypto_la-x509_cmp.lo: x509/x509_cmp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509_cmp.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509_cmp.Tpo -c -o x509/libcrypto_la-x509_cmp.lo `test -f 'x509/x509_cmp.c' || echo '$(srcdir)/'`x509/x509_cmp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509_cmp.Tpo x509/$(DEPDIR)/libcrypto_la-x509_cmp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509_cmp.c' object='x509/libcrypto_la-x509_cmp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509_cmp.lo `test -f 'x509/x509_cmp.c' || echo '$(srcdir)/'`x509/x509_cmp.c x509/libcrypto_la-x509_d2.lo: x509/x509_d2.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509_d2.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509_d2.Tpo -c -o x509/libcrypto_la-x509_d2.lo `test -f 'x509/x509_d2.c' || echo '$(srcdir)/'`x509/x509_d2.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509_d2.Tpo x509/$(DEPDIR)/libcrypto_la-x509_d2.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509_d2.c' object='x509/libcrypto_la-x509_d2.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509_d2.lo `test -f 'x509/x509_d2.c' || echo '$(srcdir)/'`x509/x509_d2.c x509/libcrypto_la-x509_def.lo: x509/x509_def.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509_def.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509_def.Tpo -c -o x509/libcrypto_la-x509_def.lo `test -f 'x509/x509_def.c' || echo '$(srcdir)/'`x509/x509_def.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509_def.Tpo x509/$(DEPDIR)/libcrypto_la-x509_def.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509_def.c' object='x509/libcrypto_la-x509_def.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509_def.lo `test -f 'x509/x509_def.c' || echo '$(srcdir)/'`x509/x509_def.c x509/libcrypto_la-x509_err.lo: x509/x509_err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509_err.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509_err.Tpo -c -o x509/libcrypto_la-x509_err.lo `test -f 'x509/x509_err.c' || echo '$(srcdir)/'`x509/x509_err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509_err.Tpo x509/$(DEPDIR)/libcrypto_la-x509_err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509_err.c' object='x509/libcrypto_la-x509_err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509_err.lo `test -f 'x509/x509_err.c' || echo '$(srcdir)/'`x509/x509_err.c x509/libcrypto_la-x509_ext.lo: x509/x509_ext.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509_ext.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509_ext.Tpo -c -o x509/libcrypto_la-x509_ext.lo `test -f 'x509/x509_ext.c' || echo '$(srcdir)/'`x509/x509_ext.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509_ext.Tpo x509/$(DEPDIR)/libcrypto_la-x509_ext.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509_ext.c' object='x509/libcrypto_la-x509_ext.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509_ext.lo `test -f 'x509/x509_ext.c' || echo '$(srcdir)/'`x509/x509_ext.c x509/libcrypto_la-x509_lu.lo: x509/x509_lu.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509_lu.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509_lu.Tpo -c -o x509/libcrypto_la-x509_lu.lo `test -f 'x509/x509_lu.c' || echo '$(srcdir)/'`x509/x509_lu.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509_lu.Tpo x509/$(DEPDIR)/libcrypto_la-x509_lu.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509_lu.c' object='x509/libcrypto_la-x509_lu.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509_lu.lo `test -f 'x509/x509_lu.c' || echo '$(srcdir)/'`x509/x509_lu.c x509/libcrypto_la-x509_obj.lo: x509/x509_obj.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509_obj.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509_obj.Tpo -c -o x509/libcrypto_la-x509_obj.lo `test -f 'x509/x509_obj.c' || echo '$(srcdir)/'`x509/x509_obj.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509_obj.Tpo x509/$(DEPDIR)/libcrypto_la-x509_obj.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509_obj.c' object='x509/libcrypto_la-x509_obj.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509_obj.lo `test -f 'x509/x509_obj.c' || echo '$(srcdir)/'`x509/x509_obj.c x509/libcrypto_la-x509_r2x.lo: x509/x509_r2x.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509_r2x.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509_r2x.Tpo -c -o x509/libcrypto_la-x509_r2x.lo `test -f 'x509/x509_r2x.c' || echo '$(srcdir)/'`x509/x509_r2x.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509_r2x.Tpo x509/$(DEPDIR)/libcrypto_la-x509_r2x.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509_r2x.c' object='x509/libcrypto_la-x509_r2x.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509_r2x.lo `test -f 'x509/x509_r2x.c' || echo '$(srcdir)/'`x509/x509_r2x.c x509/libcrypto_la-x509_req.lo: x509/x509_req.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509_req.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509_req.Tpo -c -o x509/libcrypto_la-x509_req.lo `test -f 'x509/x509_req.c' || echo '$(srcdir)/'`x509/x509_req.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509_req.Tpo x509/$(DEPDIR)/libcrypto_la-x509_req.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509_req.c' object='x509/libcrypto_la-x509_req.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509_req.lo `test -f 'x509/x509_req.c' || echo '$(srcdir)/'`x509/x509_req.c x509/libcrypto_la-x509_set.lo: x509/x509_set.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509_set.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509_set.Tpo -c -o x509/libcrypto_la-x509_set.lo `test -f 'x509/x509_set.c' || echo '$(srcdir)/'`x509/x509_set.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509_set.Tpo x509/$(DEPDIR)/libcrypto_la-x509_set.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509_set.c' object='x509/libcrypto_la-x509_set.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509_set.lo `test -f 'x509/x509_set.c' || echo '$(srcdir)/'`x509/x509_set.c x509/libcrypto_la-x509_trs.lo: x509/x509_trs.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509_trs.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509_trs.Tpo -c -o x509/libcrypto_la-x509_trs.lo `test -f 'x509/x509_trs.c' || echo '$(srcdir)/'`x509/x509_trs.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509_trs.Tpo x509/$(DEPDIR)/libcrypto_la-x509_trs.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509_trs.c' object='x509/libcrypto_la-x509_trs.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509_trs.lo `test -f 'x509/x509_trs.c' || echo '$(srcdir)/'`x509/x509_trs.c x509/libcrypto_la-x509_txt.lo: x509/x509_txt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509_txt.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509_txt.Tpo -c -o x509/libcrypto_la-x509_txt.lo `test -f 'x509/x509_txt.c' || echo '$(srcdir)/'`x509/x509_txt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509_txt.Tpo x509/$(DEPDIR)/libcrypto_la-x509_txt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509_txt.c' object='x509/libcrypto_la-x509_txt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509_txt.lo `test -f 'x509/x509_txt.c' || echo '$(srcdir)/'`x509/x509_txt.c x509/libcrypto_la-x509_v3.lo: x509/x509_v3.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509_v3.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509_v3.Tpo -c -o x509/libcrypto_la-x509_v3.lo `test -f 'x509/x509_v3.c' || echo '$(srcdir)/'`x509/x509_v3.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509_v3.Tpo x509/$(DEPDIR)/libcrypto_la-x509_v3.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509_v3.c' object='x509/libcrypto_la-x509_v3.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509_v3.lo `test -f 'x509/x509_v3.c' || echo '$(srcdir)/'`x509/x509_v3.c x509/libcrypto_la-x509_vfy.lo: x509/x509_vfy.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509_vfy.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509_vfy.Tpo -c -o x509/libcrypto_la-x509_vfy.lo `test -f 'x509/x509_vfy.c' || echo '$(srcdir)/'`x509/x509_vfy.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509_vfy.Tpo x509/$(DEPDIR)/libcrypto_la-x509_vfy.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509_vfy.c' object='x509/libcrypto_la-x509_vfy.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509_vfy.lo `test -f 'x509/x509_vfy.c' || echo '$(srcdir)/'`x509/x509_vfy.c x509/libcrypto_la-x509_vpm.lo: x509/x509_vpm.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509_vpm.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509_vpm.Tpo -c -o x509/libcrypto_la-x509_vpm.lo `test -f 'x509/x509_vpm.c' || echo '$(srcdir)/'`x509/x509_vpm.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509_vpm.Tpo x509/$(DEPDIR)/libcrypto_la-x509_vpm.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509_vpm.c' object='x509/libcrypto_la-x509_vpm.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509_vpm.lo `test -f 'x509/x509_vpm.c' || echo '$(srcdir)/'`x509/x509_vpm.c x509/libcrypto_la-x509cset.lo: x509/x509cset.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509cset.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509cset.Tpo -c -o x509/libcrypto_la-x509cset.lo `test -f 'x509/x509cset.c' || echo '$(srcdir)/'`x509/x509cset.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509cset.Tpo x509/$(DEPDIR)/libcrypto_la-x509cset.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509cset.c' object='x509/libcrypto_la-x509cset.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509cset.lo `test -f 'x509/x509cset.c' || echo '$(srcdir)/'`x509/x509cset.c x509/libcrypto_la-x509name.lo: x509/x509name.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509name.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509name.Tpo -c -o x509/libcrypto_la-x509name.lo `test -f 'x509/x509name.c' || echo '$(srcdir)/'`x509/x509name.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509name.Tpo x509/$(DEPDIR)/libcrypto_la-x509name.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509name.c' object='x509/libcrypto_la-x509name.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509name.lo `test -f 'x509/x509name.c' || echo '$(srcdir)/'`x509/x509name.c x509/libcrypto_la-x509rset.lo: x509/x509rset.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509rset.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509rset.Tpo -c -o x509/libcrypto_la-x509rset.lo `test -f 'x509/x509rset.c' || echo '$(srcdir)/'`x509/x509rset.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509rset.Tpo x509/$(DEPDIR)/libcrypto_la-x509rset.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509rset.c' object='x509/libcrypto_la-x509rset.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509rset.lo `test -f 'x509/x509rset.c' || echo '$(srcdir)/'`x509/x509rset.c x509/libcrypto_la-x509spki.lo: x509/x509spki.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509spki.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509spki.Tpo -c -o x509/libcrypto_la-x509spki.lo `test -f 'x509/x509spki.c' || echo '$(srcdir)/'`x509/x509spki.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509spki.Tpo x509/$(DEPDIR)/libcrypto_la-x509spki.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509spki.c' object='x509/libcrypto_la-x509spki.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509spki.lo `test -f 'x509/x509spki.c' || echo '$(srcdir)/'`x509/x509spki.c x509/libcrypto_la-x509type.lo: x509/x509type.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x509type.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x509type.Tpo -c -o x509/libcrypto_la-x509type.lo `test -f 'x509/x509type.c' || echo '$(srcdir)/'`x509/x509type.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x509type.Tpo x509/$(DEPDIR)/libcrypto_la-x509type.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x509type.c' object='x509/libcrypto_la-x509type.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x509type.lo `test -f 'x509/x509type.c' || echo '$(srcdir)/'`x509/x509type.c x509/libcrypto_la-x_all.lo: x509/x_all.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509/libcrypto_la-x_all.lo -MD -MP -MF x509/$(DEPDIR)/libcrypto_la-x_all.Tpo -c -o x509/libcrypto_la-x_all.lo `test -f 'x509/x_all.c' || echo '$(srcdir)/'`x509/x_all.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509/$(DEPDIR)/libcrypto_la-x_all.Tpo x509/$(DEPDIR)/libcrypto_la-x_all.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509/x_all.c' object='x509/libcrypto_la-x_all.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509/libcrypto_la-x_all.lo `test -f 'x509/x_all.c' || echo '$(srcdir)/'`x509/x_all.c x509v3/libcrypto_la-pcy_cache.lo: x509v3/pcy_cache.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-pcy_cache.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-pcy_cache.Tpo -c -o x509v3/libcrypto_la-pcy_cache.lo `test -f 'x509v3/pcy_cache.c' || echo '$(srcdir)/'`x509v3/pcy_cache.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-pcy_cache.Tpo x509v3/$(DEPDIR)/libcrypto_la-pcy_cache.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/pcy_cache.c' object='x509v3/libcrypto_la-pcy_cache.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-pcy_cache.lo `test -f 'x509v3/pcy_cache.c' || echo '$(srcdir)/'`x509v3/pcy_cache.c x509v3/libcrypto_la-pcy_data.lo: x509v3/pcy_data.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-pcy_data.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-pcy_data.Tpo -c -o x509v3/libcrypto_la-pcy_data.lo `test -f 'x509v3/pcy_data.c' || echo '$(srcdir)/'`x509v3/pcy_data.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-pcy_data.Tpo x509v3/$(DEPDIR)/libcrypto_la-pcy_data.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/pcy_data.c' object='x509v3/libcrypto_la-pcy_data.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-pcy_data.lo `test -f 'x509v3/pcy_data.c' || echo '$(srcdir)/'`x509v3/pcy_data.c x509v3/libcrypto_la-pcy_lib.lo: x509v3/pcy_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-pcy_lib.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-pcy_lib.Tpo -c -o x509v3/libcrypto_la-pcy_lib.lo `test -f 'x509v3/pcy_lib.c' || echo '$(srcdir)/'`x509v3/pcy_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-pcy_lib.Tpo x509v3/$(DEPDIR)/libcrypto_la-pcy_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/pcy_lib.c' object='x509v3/libcrypto_la-pcy_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-pcy_lib.lo `test -f 'x509v3/pcy_lib.c' || echo '$(srcdir)/'`x509v3/pcy_lib.c x509v3/libcrypto_la-pcy_map.lo: x509v3/pcy_map.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-pcy_map.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-pcy_map.Tpo -c -o x509v3/libcrypto_la-pcy_map.lo `test -f 'x509v3/pcy_map.c' || echo '$(srcdir)/'`x509v3/pcy_map.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-pcy_map.Tpo x509v3/$(DEPDIR)/libcrypto_la-pcy_map.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/pcy_map.c' object='x509v3/libcrypto_la-pcy_map.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-pcy_map.lo `test -f 'x509v3/pcy_map.c' || echo '$(srcdir)/'`x509v3/pcy_map.c x509v3/libcrypto_la-pcy_node.lo: x509v3/pcy_node.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-pcy_node.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-pcy_node.Tpo -c -o x509v3/libcrypto_la-pcy_node.lo `test -f 'x509v3/pcy_node.c' || echo '$(srcdir)/'`x509v3/pcy_node.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-pcy_node.Tpo x509v3/$(DEPDIR)/libcrypto_la-pcy_node.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/pcy_node.c' object='x509v3/libcrypto_la-pcy_node.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-pcy_node.lo `test -f 'x509v3/pcy_node.c' || echo '$(srcdir)/'`x509v3/pcy_node.c x509v3/libcrypto_la-pcy_tree.lo: x509v3/pcy_tree.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-pcy_tree.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-pcy_tree.Tpo -c -o x509v3/libcrypto_la-pcy_tree.lo `test -f 'x509v3/pcy_tree.c' || echo '$(srcdir)/'`x509v3/pcy_tree.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-pcy_tree.Tpo x509v3/$(DEPDIR)/libcrypto_la-pcy_tree.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/pcy_tree.c' object='x509v3/libcrypto_la-pcy_tree.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-pcy_tree.lo `test -f 'x509v3/pcy_tree.c' || echo '$(srcdir)/'`x509v3/pcy_tree.c x509v3/libcrypto_la-v3_akey.lo: x509v3/v3_akey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_akey.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_akey.Tpo -c -o x509v3/libcrypto_la-v3_akey.lo `test -f 'x509v3/v3_akey.c' || echo '$(srcdir)/'`x509v3/v3_akey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_akey.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_akey.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_akey.c' object='x509v3/libcrypto_la-v3_akey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_akey.lo `test -f 'x509v3/v3_akey.c' || echo '$(srcdir)/'`x509v3/v3_akey.c x509v3/libcrypto_la-v3_akeya.lo: x509v3/v3_akeya.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_akeya.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_akeya.Tpo -c -o x509v3/libcrypto_la-v3_akeya.lo `test -f 'x509v3/v3_akeya.c' || echo '$(srcdir)/'`x509v3/v3_akeya.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_akeya.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_akeya.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_akeya.c' object='x509v3/libcrypto_la-v3_akeya.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_akeya.lo `test -f 'x509v3/v3_akeya.c' || echo '$(srcdir)/'`x509v3/v3_akeya.c x509v3/libcrypto_la-v3_alt.lo: x509v3/v3_alt.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_alt.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_alt.Tpo -c -o x509v3/libcrypto_la-v3_alt.lo `test -f 'x509v3/v3_alt.c' || echo '$(srcdir)/'`x509v3/v3_alt.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_alt.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_alt.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_alt.c' object='x509v3/libcrypto_la-v3_alt.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_alt.lo `test -f 'x509v3/v3_alt.c' || echo '$(srcdir)/'`x509v3/v3_alt.c x509v3/libcrypto_la-v3_bcons.lo: x509v3/v3_bcons.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_bcons.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_bcons.Tpo -c -o x509v3/libcrypto_la-v3_bcons.lo `test -f 'x509v3/v3_bcons.c' || echo '$(srcdir)/'`x509v3/v3_bcons.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_bcons.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_bcons.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_bcons.c' object='x509v3/libcrypto_la-v3_bcons.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_bcons.lo `test -f 'x509v3/v3_bcons.c' || echo '$(srcdir)/'`x509v3/v3_bcons.c x509v3/libcrypto_la-v3_bitst.lo: x509v3/v3_bitst.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_bitst.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_bitst.Tpo -c -o x509v3/libcrypto_la-v3_bitst.lo `test -f 'x509v3/v3_bitst.c' || echo '$(srcdir)/'`x509v3/v3_bitst.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_bitst.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_bitst.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_bitst.c' object='x509v3/libcrypto_la-v3_bitst.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_bitst.lo `test -f 'x509v3/v3_bitst.c' || echo '$(srcdir)/'`x509v3/v3_bitst.c x509v3/libcrypto_la-v3_conf.lo: x509v3/v3_conf.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_conf.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_conf.Tpo -c -o x509v3/libcrypto_la-v3_conf.lo `test -f 'x509v3/v3_conf.c' || echo '$(srcdir)/'`x509v3/v3_conf.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_conf.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_conf.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_conf.c' object='x509v3/libcrypto_la-v3_conf.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_conf.lo `test -f 'x509v3/v3_conf.c' || echo '$(srcdir)/'`x509v3/v3_conf.c x509v3/libcrypto_la-v3_cpols.lo: x509v3/v3_cpols.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_cpols.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_cpols.Tpo -c -o x509v3/libcrypto_la-v3_cpols.lo `test -f 'x509v3/v3_cpols.c' || echo '$(srcdir)/'`x509v3/v3_cpols.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_cpols.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_cpols.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_cpols.c' object='x509v3/libcrypto_la-v3_cpols.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_cpols.lo `test -f 'x509v3/v3_cpols.c' || echo '$(srcdir)/'`x509v3/v3_cpols.c x509v3/libcrypto_la-v3_crld.lo: x509v3/v3_crld.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_crld.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_crld.Tpo -c -o x509v3/libcrypto_la-v3_crld.lo `test -f 'x509v3/v3_crld.c' || echo '$(srcdir)/'`x509v3/v3_crld.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_crld.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_crld.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_crld.c' object='x509v3/libcrypto_la-v3_crld.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_crld.lo `test -f 'x509v3/v3_crld.c' || echo '$(srcdir)/'`x509v3/v3_crld.c x509v3/libcrypto_la-v3_enum.lo: x509v3/v3_enum.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_enum.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_enum.Tpo -c -o x509v3/libcrypto_la-v3_enum.lo `test -f 'x509v3/v3_enum.c' || echo '$(srcdir)/'`x509v3/v3_enum.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_enum.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_enum.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_enum.c' object='x509v3/libcrypto_la-v3_enum.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_enum.lo `test -f 'x509v3/v3_enum.c' || echo '$(srcdir)/'`x509v3/v3_enum.c x509v3/libcrypto_la-v3_extku.lo: x509v3/v3_extku.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_extku.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_extku.Tpo -c -o x509v3/libcrypto_la-v3_extku.lo `test -f 'x509v3/v3_extku.c' || echo '$(srcdir)/'`x509v3/v3_extku.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_extku.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_extku.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_extku.c' object='x509v3/libcrypto_la-v3_extku.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_extku.lo `test -f 'x509v3/v3_extku.c' || echo '$(srcdir)/'`x509v3/v3_extku.c x509v3/libcrypto_la-v3_genn.lo: x509v3/v3_genn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_genn.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_genn.Tpo -c -o x509v3/libcrypto_la-v3_genn.lo `test -f 'x509v3/v3_genn.c' || echo '$(srcdir)/'`x509v3/v3_genn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_genn.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_genn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_genn.c' object='x509v3/libcrypto_la-v3_genn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_genn.lo `test -f 'x509v3/v3_genn.c' || echo '$(srcdir)/'`x509v3/v3_genn.c x509v3/libcrypto_la-v3_ia5.lo: x509v3/v3_ia5.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_ia5.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_ia5.Tpo -c -o x509v3/libcrypto_la-v3_ia5.lo `test -f 'x509v3/v3_ia5.c' || echo '$(srcdir)/'`x509v3/v3_ia5.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_ia5.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_ia5.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_ia5.c' object='x509v3/libcrypto_la-v3_ia5.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_ia5.lo `test -f 'x509v3/v3_ia5.c' || echo '$(srcdir)/'`x509v3/v3_ia5.c x509v3/libcrypto_la-v3_info.lo: x509v3/v3_info.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_info.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_info.Tpo -c -o x509v3/libcrypto_la-v3_info.lo `test -f 'x509v3/v3_info.c' || echo '$(srcdir)/'`x509v3/v3_info.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_info.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_info.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_info.c' object='x509v3/libcrypto_la-v3_info.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_info.lo `test -f 'x509v3/v3_info.c' || echo '$(srcdir)/'`x509v3/v3_info.c x509v3/libcrypto_la-v3_int.lo: x509v3/v3_int.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_int.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_int.Tpo -c -o x509v3/libcrypto_la-v3_int.lo `test -f 'x509v3/v3_int.c' || echo '$(srcdir)/'`x509v3/v3_int.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_int.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_int.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_int.c' object='x509v3/libcrypto_la-v3_int.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_int.lo `test -f 'x509v3/v3_int.c' || echo '$(srcdir)/'`x509v3/v3_int.c x509v3/libcrypto_la-v3_lib.lo: x509v3/v3_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_lib.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_lib.Tpo -c -o x509v3/libcrypto_la-v3_lib.lo `test -f 'x509v3/v3_lib.c' || echo '$(srcdir)/'`x509v3/v3_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_lib.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_lib.c' object='x509v3/libcrypto_la-v3_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_lib.lo `test -f 'x509v3/v3_lib.c' || echo '$(srcdir)/'`x509v3/v3_lib.c x509v3/libcrypto_la-v3_ncons.lo: x509v3/v3_ncons.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_ncons.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_ncons.Tpo -c -o x509v3/libcrypto_la-v3_ncons.lo `test -f 'x509v3/v3_ncons.c' || echo '$(srcdir)/'`x509v3/v3_ncons.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_ncons.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_ncons.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_ncons.c' object='x509v3/libcrypto_la-v3_ncons.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_ncons.lo `test -f 'x509v3/v3_ncons.c' || echo '$(srcdir)/'`x509v3/v3_ncons.c x509v3/libcrypto_la-v3_ocsp.lo: x509v3/v3_ocsp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_ocsp.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_ocsp.Tpo -c -o x509v3/libcrypto_la-v3_ocsp.lo `test -f 'x509v3/v3_ocsp.c' || echo '$(srcdir)/'`x509v3/v3_ocsp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_ocsp.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_ocsp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_ocsp.c' object='x509v3/libcrypto_la-v3_ocsp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_ocsp.lo `test -f 'x509v3/v3_ocsp.c' || echo '$(srcdir)/'`x509v3/v3_ocsp.c x509v3/libcrypto_la-v3_pci.lo: x509v3/v3_pci.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_pci.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_pci.Tpo -c -o x509v3/libcrypto_la-v3_pci.lo `test -f 'x509v3/v3_pci.c' || echo '$(srcdir)/'`x509v3/v3_pci.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_pci.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_pci.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_pci.c' object='x509v3/libcrypto_la-v3_pci.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_pci.lo `test -f 'x509v3/v3_pci.c' || echo '$(srcdir)/'`x509v3/v3_pci.c x509v3/libcrypto_la-v3_pcia.lo: x509v3/v3_pcia.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_pcia.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_pcia.Tpo -c -o x509v3/libcrypto_la-v3_pcia.lo `test -f 'x509v3/v3_pcia.c' || echo '$(srcdir)/'`x509v3/v3_pcia.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_pcia.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_pcia.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_pcia.c' object='x509v3/libcrypto_la-v3_pcia.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_pcia.lo `test -f 'x509v3/v3_pcia.c' || echo '$(srcdir)/'`x509v3/v3_pcia.c x509v3/libcrypto_la-v3_pcons.lo: x509v3/v3_pcons.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_pcons.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_pcons.Tpo -c -o x509v3/libcrypto_la-v3_pcons.lo `test -f 'x509v3/v3_pcons.c' || echo '$(srcdir)/'`x509v3/v3_pcons.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_pcons.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_pcons.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_pcons.c' object='x509v3/libcrypto_la-v3_pcons.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_pcons.lo `test -f 'x509v3/v3_pcons.c' || echo '$(srcdir)/'`x509v3/v3_pcons.c x509v3/libcrypto_la-v3_pku.lo: x509v3/v3_pku.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_pku.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_pku.Tpo -c -o x509v3/libcrypto_la-v3_pku.lo `test -f 'x509v3/v3_pku.c' || echo '$(srcdir)/'`x509v3/v3_pku.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_pku.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_pku.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_pku.c' object='x509v3/libcrypto_la-v3_pku.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_pku.lo `test -f 'x509v3/v3_pku.c' || echo '$(srcdir)/'`x509v3/v3_pku.c x509v3/libcrypto_la-v3_pmaps.lo: x509v3/v3_pmaps.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_pmaps.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_pmaps.Tpo -c -o x509v3/libcrypto_la-v3_pmaps.lo `test -f 'x509v3/v3_pmaps.c' || echo '$(srcdir)/'`x509v3/v3_pmaps.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_pmaps.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_pmaps.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_pmaps.c' object='x509v3/libcrypto_la-v3_pmaps.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_pmaps.lo `test -f 'x509v3/v3_pmaps.c' || echo '$(srcdir)/'`x509v3/v3_pmaps.c x509v3/libcrypto_la-v3_prn.lo: x509v3/v3_prn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_prn.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_prn.Tpo -c -o x509v3/libcrypto_la-v3_prn.lo `test -f 'x509v3/v3_prn.c' || echo '$(srcdir)/'`x509v3/v3_prn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_prn.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_prn.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_prn.c' object='x509v3/libcrypto_la-v3_prn.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_prn.lo `test -f 'x509v3/v3_prn.c' || echo '$(srcdir)/'`x509v3/v3_prn.c x509v3/libcrypto_la-v3_purp.lo: x509v3/v3_purp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_purp.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_purp.Tpo -c -o x509v3/libcrypto_la-v3_purp.lo `test -f 'x509v3/v3_purp.c' || echo '$(srcdir)/'`x509v3/v3_purp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_purp.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_purp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_purp.c' object='x509v3/libcrypto_la-v3_purp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_purp.lo `test -f 'x509v3/v3_purp.c' || echo '$(srcdir)/'`x509v3/v3_purp.c x509v3/libcrypto_la-v3_skey.lo: x509v3/v3_skey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_skey.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_skey.Tpo -c -o x509v3/libcrypto_la-v3_skey.lo `test -f 'x509v3/v3_skey.c' || echo '$(srcdir)/'`x509v3/v3_skey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_skey.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_skey.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_skey.c' object='x509v3/libcrypto_la-v3_skey.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_skey.lo `test -f 'x509v3/v3_skey.c' || echo '$(srcdir)/'`x509v3/v3_skey.c x509v3/libcrypto_la-v3_sxnet.lo: x509v3/v3_sxnet.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_sxnet.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_sxnet.Tpo -c -o x509v3/libcrypto_la-v3_sxnet.lo `test -f 'x509v3/v3_sxnet.c' || echo '$(srcdir)/'`x509v3/v3_sxnet.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_sxnet.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_sxnet.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_sxnet.c' object='x509v3/libcrypto_la-v3_sxnet.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_sxnet.lo `test -f 'x509v3/v3_sxnet.c' || echo '$(srcdir)/'`x509v3/v3_sxnet.c x509v3/libcrypto_la-v3_utl.lo: x509v3/v3_utl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3_utl.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3_utl.Tpo -c -o x509v3/libcrypto_la-v3_utl.lo `test -f 'x509v3/v3_utl.c' || echo '$(srcdir)/'`x509v3/v3_utl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3_utl.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3_utl.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3_utl.c' object='x509v3/libcrypto_la-v3_utl.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3_utl.lo `test -f 'x509v3/v3_utl.c' || echo '$(srcdir)/'`x509v3/v3_utl.c x509v3/libcrypto_la-v3err.lo: x509v3/v3err.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT x509v3/libcrypto_la-v3err.lo -MD -MP -MF x509v3/$(DEPDIR)/libcrypto_la-v3err.Tpo -c -o x509v3/libcrypto_la-v3err.lo `test -f 'x509v3/v3err.c' || echo '$(srcdir)/'`x509v3/v3err.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) x509v3/$(DEPDIR)/libcrypto_la-v3err.Tpo x509v3/$(DEPDIR)/libcrypto_la-v3err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509v3/v3err.c' object='x509v3/libcrypto_la-v3err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o x509v3/libcrypto_la-v3err.lo `test -f 'x509v3/v3err.c' || echo '$(srcdir)/'`x509v3/v3err.c des/libcrypto_la-ncbc_enc.lo: des/ncbc_enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT des/libcrypto_la-ncbc_enc.lo -MD -MP -MF des/$(DEPDIR)/libcrypto_la-ncbc_enc.Tpo -c -o des/libcrypto_la-ncbc_enc.lo `test -f 'des/ncbc_enc.c' || echo '$(srcdir)/'`des/ncbc_enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) des/$(DEPDIR)/libcrypto_la-ncbc_enc.Tpo des/$(DEPDIR)/libcrypto_la-ncbc_enc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='des/ncbc_enc.c' object='des/libcrypto_la-ncbc_enc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o des/libcrypto_la-ncbc_enc.lo `test -f 'des/ncbc_enc.c' || echo '$(srcdir)/'`des/ncbc_enc.c chacha/libcrypto_la-chacha-merged.lo: chacha/chacha-merged.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT chacha/libcrypto_la-chacha-merged.lo -MD -MP -MF chacha/$(DEPDIR)/libcrypto_la-chacha-merged.Tpo -c -o chacha/libcrypto_la-chacha-merged.lo `test -f 'chacha/chacha-merged.c' || echo '$(srcdir)/'`chacha/chacha-merged.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) chacha/$(DEPDIR)/libcrypto_la-chacha-merged.Tpo chacha/$(DEPDIR)/libcrypto_la-chacha-merged.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='chacha/chacha-merged.c' object='chacha/libcrypto_la-chacha-merged.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o chacha/libcrypto_la-chacha-merged.lo `test -f 'chacha/chacha-merged.c' || echo '$(srcdir)/'`chacha/chacha-merged.c poly1305/libcrypto_la-poly1305-donna.lo: poly1305/poly1305-donna.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -MT poly1305/libcrypto_la-poly1305-donna.lo -MD -MP -MF poly1305/$(DEPDIR)/libcrypto_la-poly1305-donna.Tpo -c -o poly1305/libcrypto_la-poly1305-donna.lo `test -f 'poly1305/poly1305-donna.c' || echo '$(srcdir)/'`poly1305/poly1305-donna.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) poly1305/$(DEPDIR)/libcrypto_la-poly1305-donna.Tpo poly1305/$(DEPDIR)/libcrypto_la-poly1305-donna.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='poly1305/poly1305-donna.c' object='poly1305/libcrypto_la-poly1305-donna.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcrypto_la_CFLAGS) $(CFLAGS) -c -o poly1305/libcrypto_la-poly1305-donna.lo `test -f 'poly1305/poly1305-donna.c' || echo '$(srcdir)/'`poly1305/poly1305-donna.c mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs -rm -rf aes/.libs aes/_libs -rm -rf asn1/.libs asn1/_libs -rm -rf bf/.libs bf/_libs -rm -rf bio/.libs bio/_libs -rm -rf bn/.libs bn/_libs -rm -rf buffer/.libs buffer/_libs -rm -rf cast/.libs cast/_libs -rm -rf chacha/.libs chacha/_libs -rm -rf cmac/.libs cmac/_libs -rm -rf comp/.libs comp/_libs -rm -rf compat/.libs compat/_libs -rm -rf conf/.libs conf/_libs -rm -rf des/.libs des/_libs -rm -rf dh/.libs dh/_libs -rm -rf dsa/.libs dsa/_libs -rm -rf dso/.libs dso/_libs -rm -rf ec/.libs ec/_libs -rm -rf ecdh/.libs ecdh/_libs -rm -rf ecdsa/.libs ecdsa/_libs -rm -rf engine/.libs engine/_libs -rm -rf err/.libs err/_libs -rm -rf evp/.libs evp/_libs -rm -rf hmac/.libs hmac/_libs -rm -rf idea/.libs idea/_libs -rm -rf krb5/.libs krb5/_libs -rm -rf lhash/.libs lhash/_libs -rm -rf md4/.libs md4/_libs -rm -rf md5/.libs md5/_libs -rm -rf mdc2/.libs mdc2/_libs -rm -rf modes/.libs modes/_libs -rm -rf objects/.libs objects/_libs -rm -rf ocsp/.libs ocsp/_libs -rm -rf pem/.libs pem/_libs -rm -rf pkcs12/.libs pkcs12/_libs -rm -rf pkcs7/.libs pkcs7/_libs -rm -rf poly1305/.libs poly1305/_libs -rm -rf rand/.libs rand/_libs -rm -rf rc2/.libs rc2/_libs -rm -rf rc4/.libs rc4/_libs -rm -rf ripemd/.libs ripemd/_libs -rm -rf rsa/.libs rsa/_libs -rm -rf sha/.libs sha/_libs -rm -rf stack/.libs stack/_libs -rm -rf ts/.libs ts/_libs -rm -rf txt_db/.libs txt_db/_libs -rm -rf ui/.libs ui/_libs -rm -rf whrlpool/.libs whrlpool/_libs -rm -rf x509/.libs x509/_libs -rm -rf x509v3/.libs x509v3/_libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -rm -f aes/$(DEPDIR)/$(am__dirstamp) -rm -f aes/$(am__dirstamp) -rm -f asn1/$(DEPDIR)/$(am__dirstamp) -rm -f asn1/$(am__dirstamp) -rm -f bf/$(DEPDIR)/$(am__dirstamp) -rm -f bf/$(am__dirstamp) -rm -f bio/$(DEPDIR)/$(am__dirstamp) -rm -f bio/$(am__dirstamp) -rm -f bn/$(DEPDIR)/$(am__dirstamp) -rm -f bn/$(am__dirstamp) -rm -f buffer/$(DEPDIR)/$(am__dirstamp) -rm -f buffer/$(am__dirstamp) -rm -f cast/$(DEPDIR)/$(am__dirstamp) -rm -f cast/$(am__dirstamp) -rm -f chacha/$(DEPDIR)/$(am__dirstamp) -rm -f chacha/$(am__dirstamp) -rm -f cmac/$(DEPDIR)/$(am__dirstamp) -rm -f cmac/$(am__dirstamp) -rm -f comp/$(DEPDIR)/$(am__dirstamp) -rm -f comp/$(am__dirstamp) -rm -f compat/$(DEPDIR)/$(am__dirstamp) -rm -f compat/$(am__dirstamp) -rm -f conf/$(DEPDIR)/$(am__dirstamp) -rm -f conf/$(am__dirstamp) -rm -f des/$(DEPDIR)/$(am__dirstamp) -rm -f des/$(am__dirstamp) -rm -f dh/$(DEPDIR)/$(am__dirstamp) -rm -f dh/$(am__dirstamp) -rm -f dsa/$(DEPDIR)/$(am__dirstamp) -rm -f dsa/$(am__dirstamp) -rm -f dso/$(DEPDIR)/$(am__dirstamp) -rm -f dso/$(am__dirstamp) -rm -f ec/$(DEPDIR)/$(am__dirstamp) -rm -f ec/$(am__dirstamp) -rm -f ecdh/$(DEPDIR)/$(am__dirstamp) -rm -f ecdh/$(am__dirstamp) -rm -f ecdsa/$(DEPDIR)/$(am__dirstamp) -rm -f ecdsa/$(am__dirstamp) -rm -f engine/$(DEPDIR)/$(am__dirstamp) -rm -f engine/$(am__dirstamp) -rm -f err/$(DEPDIR)/$(am__dirstamp) -rm -f err/$(am__dirstamp) -rm -f evp/$(DEPDIR)/$(am__dirstamp) -rm -f evp/$(am__dirstamp) -rm -f hmac/$(DEPDIR)/$(am__dirstamp) -rm -f hmac/$(am__dirstamp) -rm -f idea/$(DEPDIR)/$(am__dirstamp) -rm -f idea/$(am__dirstamp) -rm -f krb5/$(DEPDIR)/$(am__dirstamp) -rm -f krb5/$(am__dirstamp) -rm -f lhash/$(DEPDIR)/$(am__dirstamp) -rm -f lhash/$(am__dirstamp) -rm -f md4/$(DEPDIR)/$(am__dirstamp) -rm -f md4/$(am__dirstamp) -rm -f md5/$(DEPDIR)/$(am__dirstamp) -rm -f md5/$(am__dirstamp) -rm -f mdc2/$(DEPDIR)/$(am__dirstamp) -rm -f mdc2/$(am__dirstamp) -rm -f modes/$(DEPDIR)/$(am__dirstamp) -rm -f modes/$(am__dirstamp) -rm -f objects/$(DEPDIR)/$(am__dirstamp) -rm -f objects/$(am__dirstamp) -rm -f ocsp/$(DEPDIR)/$(am__dirstamp) -rm -f ocsp/$(am__dirstamp) -rm -f pem/$(DEPDIR)/$(am__dirstamp) -rm -f pem/$(am__dirstamp) -rm -f pkcs12/$(DEPDIR)/$(am__dirstamp) -rm -f pkcs12/$(am__dirstamp) -rm -f pkcs7/$(DEPDIR)/$(am__dirstamp) -rm -f pkcs7/$(am__dirstamp) -rm -f poly1305/$(DEPDIR)/$(am__dirstamp) -rm -f poly1305/$(am__dirstamp) -rm -f rand/$(DEPDIR)/$(am__dirstamp) -rm -f rand/$(am__dirstamp) -rm -f rc2/$(DEPDIR)/$(am__dirstamp) -rm -f rc2/$(am__dirstamp) -rm -f rc4/$(DEPDIR)/$(am__dirstamp) -rm -f rc4/$(am__dirstamp) -rm -f ripemd/$(DEPDIR)/$(am__dirstamp) -rm -f ripemd/$(am__dirstamp) -rm -f rsa/$(DEPDIR)/$(am__dirstamp) -rm -f rsa/$(am__dirstamp) -rm -f sha/$(DEPDIR)/$(am__dirstamp) -rm -f sha/$(am__dirstamp) -rm -f stack/$(DEPDIR)/$(am__dirstamp) -rm -f stack/$(am__dirstamp) -rm -f ts/$(DEPDIR)/$(am__dirstamp) -rm -f ts/$(am__dirstamp) -rm -f txt_db/$(DEPDIR)/$(am__dirstamp) -rm -f txt_db/$(am__dirstamp) -rm -f ui/$(DEPDIR)/$(am__dirstamp) -rm -f ui/$(am__dirstamp) -rm -f whrlpool/$(DEPDIR)/$(am__dirstamp) -rm -f whrlpool/$(am__dirstamp) -rm -f x509/$(DEPDIR)/$(am__dirstamp) -rm -f x509/$(am__dirstamp) -rm -f x509v3/$(DEPDIR)/$(am__dirstamp) -rm -f x509v3/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ clean-noinstLTLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) aes/$(DEPDIR) asn1/$(DEPDIR) bf/$(DEPDIR) bio/$(DEPDIR) bn/$(DEPDIR) buffer/$(DEPDIR) cast/$(DEPDIR) chacha/$(DEPDIR) cmac/$(DEPDIR) comp/$(DEPDIR) compat/$(DEPDIR) conf/$(DEPDIR) des/$(DEPDIR) dh/$(DEPDIR) dsa/$(DEPDIR) dso/$(DEPDIR) ec/$(DEPDIR) ecdh/$(DEPDIR) ecdsa/$(DEPDIR) engine/$(DEPDIR) err/$(DEPDIR) evp/$(DEPDIR) hmac/$(DEPDIR) idea/$(DEPDIR) krb5/$(DEPDIR) lhash/$(DEPDIR) md4/$(DEPDIR) md5/$(DEPDIR) mdc2/$(DEPDIR) modes/$(DEPDIR) objects/$(DEPDIR) ocsp/$(DEPDIR) pem/$(DEPDIR) pkcs12/$(DEPDIR) pkcs7/$(DEPDIR) poly1305/$(DEPDIR) rand/$(DEPDIR) rc2/$(DEPDIR) rc4/$(DEPDIR) ripemd/$(DEPDIR) rsa/$(DEPDIR) sha/$(DEPDIR) stack/$(DEPDIR) ts/$(DEPDIR) txt_db/$(DEPDIR) ui/$(DEPDIR) whrlpool/$(DEPDIR) x509/$(DEPDIR) x509v3/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) aes/$(DEPDIR) asn1/$(DEPDIR) bf/$(DEPDIR) bio/$(DEPDIR) bn/$(DEPDIR) buffer/$(DEPDIR) cast/$(DEPDIR) chacha/$(DEPDIR) cmac/$(DEPDIR) comp/$(DEPDIR) compat/$(DEPDIR) conf/$(DEPDIR) des/$(DEPDIR) dh/$(DEPDIR) dsa/$(DEPDIR) dso/$(DEPDIR) ec/$(DEPDIR) ecdh/$(DEPDIR) ecdsa/$(DEPDIR) engine/$(DEPDIR) err/$(DEPDIR) evp/$(DEPDIR) hmac/$(DEPDIR) idea/$(DEPDIR) krb5/$(DEPDIR) lhash/$(DEPDIR) md4/$(DEPDIR) md5/$(DEPDIR) mdc2/$(DEPDIR) modes/$(DEPDIR) objects/$(DEPDIR) ocsp/$(DEPDIR) pem/$(DEPDIR) pkcs12/$(DEPDIR) pkcs7/$(DEPDIR) poly1305/$(DEPDIR) rand/$(DEPDIR) rc2/$(DEPDIR) rc4/$(DEPDIR) ripemd/$(DEPDIR) rsa/$(DEPDIR) sha/$(DEPDIR) stack/$(DEPDIR) ts/$(DEPDIR) txt_db/$(DEPDIR) ui/$(DEPDIR) whrlpool/$(DEPDIR) x509/$(DEPDIR) x509v3/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool clean-noinstLTLIBRARIES \ cscopelist-am ctags ctags-am distclean distclean-compile \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-libLTLIBRARIES \ install-man install-pdf install-pdf-am install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: deps/libressl-pnacl-sys-2.1.6/libressl/crypto/lhash/0000755000000000000000000000000012666635521021151 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/lhash/lhash.c0000644000175000017500000002652612360020706020631 0ustar /* $OpenBSD: lhash.c,v 1.16 2014/07/09 11:10:51 bcook Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* Code for dynamic hash table routines * Author - Eric Young v 2.0 * * 2.2 eay - added #include "crypto.h" so the memory leak checking code is * present. eay 18-Jun-98 * * 2.1 eay - Added an 'error in last operation' flag. eay 6-May-98 * * 2.0 eay - Fixed a bug that occurred when using lh_delete * from inside lh_doall(). As entries were deleted, * the 'table' was 'contract()ed', making some entries * jump from the end of the table to the start, there by * skipping the lh_doall() processing. eay - 4/12/95 * * 1.9 eay - Fixed a memory leak in lh_free, the LHASH_NODEs * were not being free()ed. 21/11/95 * * 1.8 eay - Put the stats routines into a separate file, lh_stats.c * 19/09/95 * * 1.7 eay - Removed the fputs() for realloc failures - the code * should silently tolerate them. I have also fixed things * lint complained about 04/05/95 * * 1.6 eay - Fixed an invalid pointers in contract/expand 27/07/92 * * 1.5 eay - Fixed a misuse of realloc in expand 02/03/1992 * * 1.4 eay - Fixed lh_doall so the function can call lh_delete 28/05/91 * * 1.3 eay - Fixed a few lint problems 19/3/1991 * * 1.2 eay - Fixed lh_doall problem 13/3/1991 * * 1.1 eay - Added lh_doall * * 1.0 eay - First version */ #include #include #include #include #include #include #undef MIN_NODES #define MIN_NODES 16 #define UP_LOAD (2*LH_LOAD_MULT) /* load times 256 (default 2) */ #define DOWN_LOAD (LH_LOAD_MULT) /* load times 256 (default 1) */ static void expand(_LHASH *lh); static void contract(_LHASH *lh); static LHASH_NODE **getrn(_LHASH *lh, const void *data, unsigned long *rhash); _LHASH * lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c) { _LHASH *ret; int i; if ((ret = malloc(sizeof(_LHASH))) == NULL) goto err0; if ((ret->b = reallocarray(NULL, MIN_NODES, sizeof(LHASH_NODE *))) == NULL) goto err1; for (i = 0; i < MIN_NODES; i++) ret->b[i] = NULL; ret->comp = ((c == NULL) ? (LHASH_COMP_FN_TYPE)strcmp : c); ret->hash = ((h == NULL) ? (LHASH_HASH_FN_TYPE)lh_strhash : h); ret->num_nodes = MIN_NODES / 2; ret->num_alloc_nodes = MIN_NODES; ret->p = 0; ret->pmax = MIN_NODES / 2; ret->up_load = UP_LOAD; ret->down_load = DOWN_LOAD; ret->num_items = 0; ret->num_expands = 0; ret->num_expand_reallocs = 0; ret->num_contracts = 0; ret->num_contract_reallocs = 0; ret->num_hash_calls = 0; ret->num_comp_calls = 0; ret->num_insert = 0; ret->num_replace = 0; ret->num_delete = 0; ret->num_no_delete = 0; ret->num_retrieve = 0; ret->num_retrieve_miss = 0; ret->num_hash_comps = 0; ret->error = 0; return (ret); err1: free(ret); err0: return (NULL); } void lh_free(_LHASH *lh) { unsigned int i; LHASH_NODE *n, *nn; if (lh == NULL) return; for (i = 0; i < lh->num_nodes; i++) { n = lh->b[i]; while (n != NULL) { nn = n->next; free(n); n = nn; } } free(lh->b); free(lh); } void * lh_insert(_LHASH *lh, void *data) { unsigned long hash; LHASH_NODE *nn, **rn; void *ret; lh->error = 0; if (lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) expand(lh); rn = getrn(lh, data, &hash); if (*rn == NULL) { if ((nn = malloc(sizeof(LHASH_NODE))) == NULL) { lh->error++; return (NULL); } nn->data = data; nn->next = NULL; #ifndef OPENSSL_NO_HASH_COMP nn->hash = hash; #endif *rn = nn; ret = NULL; lh->num_insert++; lh->num_items++; } else /* replace same key */ { ret = (*rn)->data; (*rn)->data = data; lh->num_replace++; } return (ret); } void * lh_delete(_LHASH *lh, const void *data) { unsigned long hash; LHASH_NODE *nn, **rn; void *ret; lh->error = 0; rn = getrn(lh, data, &hash); if (*rn == NULL) { lh->num_no_delete++; return (NULL); } else { nn= *rn; *rn = nn->next; ret = nn->data; free(nn); lh->num_delete++; } lh->num_items--; if ((lh->num_nodes > MIN_NODES) && (lh->down_load >= (lh->num_items * LH_LOAD_MULT / lh->num_nodes))) contract(lh); return (ret); } void * lh_retrieve(_LHASH *lh, const void *data) { unsigned long hash; LHASH_NODE **rn; void *ret; lh->error = 0; rn = getrn(lh, data, &hash); if (*rn == NULL) { lh->num_retrieve_miss++; return (NULL); } else { ret = (*rn)->data; lh->num_retrieve++; } return (ret); } static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func, LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg) { int i; LHASH_NODE *a, *n; if (lh == NULL) return; /* reverse the order so we search from 'top to bottom' * We were having memory leaks otherwise */ for (i = lh->num_nodes - 1; i >= 0; i--) { a = lh->b[i]; while (a != NULL) { /* 28/05/91 - eay - n added so items can be deleted * via lh_doall */ /* 22/05/08 - ben - eh? since a is not passed, * this should not be needed */ n = a->next; if (use_arg) func_arg(a->data, arg); else func(a->data); a = n; } } } void lh_doall(_LHASH *lh, LHASH_DOALL_FN_TYPE func) { doall_util_fn(lh, 0, func, (LHASH_DOALL_ARG_FN_TYPE)0, NULL); } void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg) { doall_util_fn(lh, 1, (LHASH_DOALL_FN_TYPE)0, func, arg); } static void expand(_LHASH *lh) { LHASH_NODE **n, **n1, **n2, *np; unsigned int p, i, j; unsigned long hash, nni; lh->num_nodes++; lh->num_expands++; p = (int)lh->p++; n1 = &(lh->b[p]); n2 = &(lh->b[p + (int)lh->pmax]); *n2 = NULL; /* 27/07/92 - eay - undefined pointer bug */ nni = lh->num_alloc_nodes; for (np = *n1; np != NULL; ) { #ifndef OPENSSL_NO_HASH_COMP hash = np->hash; #else hash = lh->hash(np->data); lh->num_hash_calls++; #endif if ((hash % nni) != p) { /* move it */ *n1 = (*n1)->next; np->next= *n2; *n2 = np; } else n1 = &((*n1)->next); np= *n1; } if ((lh->p) >= lh->pmax) { j = (int)lh->num_alloc_nodes * 2; n = reallocarray(lh->b, j, sizeof(LHASH_NODE *)); if (n == NULL) { /* fputs("realloc error in lhash", stderr); */ lh->error++; lh->p = 0; return; } /* else */ for (i = (int)lh->num_alloc_nodes; i < j; i++)/* 26/02/92 eay */ n[i] = NULL; /* 02/03/92 eay */ lh->pmax = lh->num_alloc_nodes; lh->num_alloc_nodes = j; lh->num_expand_reallocs++; lh->p = 0; lh->b = n; } } static void contract(_LHASH *lh) { LHASH_NODE **n, *n1, *np; np = lh->b[lh->p + lh->pmax - 1]; lh->b[lh->p+lh->pmax - 1] = NULL; /* 24/07-92 - eay - weird but :-( */ if (lh->p == 0) { n = reallocarray(lh->b, lh->pmax, sizeof(LHASH_NODE *)); if (n == NULL) { /* fputs("realloc error in lhash", stderr); */ lh->error++; return; } lh->num_contract_reallocs++; lh->num_alloc_nodes /= 2; lh->pmax /= 2; lh->p = lh->pmax - 1; lh->b = n; } else lh->p--; lh->num_nodes--; lh->num_contracts++; n1 = lh->b[(int)lh->p]; if (n1 == NULL) lh->b[(int)lh->p] = np; else { while (n1->next != NULL) n1 = n1->next; n1->next = np; } } static LHASH_NODE **getrn(_LHASH *lh, const void *data, unsigned long *rhash) { LHASH_NODE **ret, *n1; unsigned long hash, nn; LHASH_COMP_FN_TYPE cf; hash = (*(lh->hash))(data); lh->num_hash_calls++; *rhash = hash; nn = hash % lh->pmax; if (nn < lh->p) nn = hash % lh->num_alloc_nodes; cf = lh->comp; ret = &(lh->b[(int)nn]); for (n1 = *ret; n1 != NULL; n1 = n1->next) { #ifndef OPENSSL_NO_HASH_COMP lh->num_hash_comps++; if (n1->hash != hash) { ret = &(n1->next); continue; } #endif lh->num_comp_calls++; if (cf(n1->data, data) == 0) break; ret = &(n1->next); } return (ret); } /* The following hash seems to work very well on normal text strings * no collisions on /usr/dict/words and it distributes on %2^n quite * well, not as good as MD5, but still good. */ unsigned long lh_strhash(const char *c) { unsigned long ret = 0; long n; unsigned long v; int r; if ((c == NULL) || (*c == '\0')) return (ret); /* unsigned char b[16]; MD5(c,strlen(c),b); return(b[0]|(b[1]<<8)|(b[2]<<16)|(b[3]<<24)); */ n = 0x100; while (*c) { v = n | (*c); n += 0x100; r = (int)((v >> 2) ^ v) & 0x0f; ret = (ret << r)|(ret >> (32 - r)); ret &= 0xFFFFFFFFL; ret ^= v * v; c++; } return ((ret >> 16) ^ ret); } unsigned long lh_num_items(const _LHASH *lh) { return lh ? lh->num_items : 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/lhash/lh_stats.c0000644000175000017500000002075612360020706021352 0ustar /* $OpenBSD: lh_stats.c,v 1.11 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #ifndef OPENSSL_NO_BIO #include #endif #include #ifdef OPENSSL_NO_BIO void lh_stats(LHASH *lh, FILE *out) { fprintf(out, "num_items = %lu\n", lh->num_items); fprintf(out, "num_nodes = %u\n", lh->num_nodes); fprintf(out, "num_alloc_nodes = %u\n", lh->num_alloc_nodes); fprintf(out, "num_expands = %lu\n", lh->num_expands); fprintf(out, "num_expand_reallocs = %lu\n", lh->num_expand_reallocs); fprintf(out, "num_contracts = %lu\n", lh->num_contracts); fprintf(out, "num_contract_reallocs = %lu\n", lh->num_contract_reallocs); fprintf(out, "num_hash_calls = %lu\n", lh->num_hash_calls); fprintf(out, "num_comp_calls = %lu\n", lh->num_comp_calls); fprintf(out, "num_insert = %lu\n", lh->num_insert); fprintf(out, "num_replace = %lu\n", lh->num_replace); fprintf(out, "num_delete = %lu\n", lh->num_delete); fprintf(out, "num_no_delete = %lu\n", lh->num_no_delete); fprintf(out, "num_retrieve = %lu\n", lh->num_retrieve); fprintf(out, "num_retrieve_miss = %lu\n", lh->num_retrieve_miss); fprintf(out, "num_hash_comps = %lu\n", lh->num_hash_comps); #if 0 fprintf(out, "p = %u\n", lh->p); fprintf(out, "pmax = %u\n", lh->pmax); fprintf(out, "up_load = %lu\n", lh->up_load); fprintf(out, "down_load = %lu\n", lh->down_load); #endif } void lh_node_stats(LHASH *lh, FILE *out) { LHASH_NODE *n; unsigned int i, num; for (i = 0; i < lh->num_nodes; i++) { for (n = lh->b[i], num = 0; n != NULL; n = n->next) num++; fprintf(out, "node %6u -> %3u\n", i, num); } } void lh_node_usage_stats(LHASH *lh, FILE *out) { LHASH_NODE *n; unsigned long num; unsigned int i; unsigned long total = 0, n_used = 0; for (i = 0; i < lh->num_nodes; i++) { for (n = lh->b[i], num = 0; n != NULL; n = n->next) num++; if (num != 0) { n_used++; total += num; } } fprintf(out, "%lu nodes used out of %u\n", n_used, lh->num_nodes); fprintf(out, "%lu items\n", total); if (n_used == 0) return; fprintf(out, "load %d.%02d actual load %d.%02d\n", (int)(total / lh->num_nodes), (int)((total % lh->num_nodes) * 100 / lh->num_nodes), (int)(total / n_used), (int)((total % n_used) * 100 / n_used)); } #else void lh_stats(const _LHASH *lh, FILE *fp) { BIO *bp; bp = BIO_new(BIO_s_file()); if (bp == NULL) goto end; BIO_set_fp(bp, fp, BIO_NOCLOSE); lh_stats_bio(lh, bp); BIO_free(bp); end:; } void lh_node_stats(const _LHASH *lh, FILE *fp) { BIO *bp; bp = BIO_new(BIO_s_file()); if (bp == NULL) goto end; BIO_set_fp(bp, fp, BIO_NOCLOSE); lh_node_stats_bio(lh, bp); BIO_free(bp); end:; } void lh_node_usage_stats(const _LHASH *lh, FILE *fp) { BIO *bp; bp = BIO_new(BIO_s_file()); if (bp == NULL) goto end; BIO_set_fp(bp, fp, BIO_NOCLOSE); lh_node_usage_stats_bio(lh, bp); BIO_free(bp); end:; } void lh_stats_bio(const _LHASH *lh, BIO *out) { BIO_printf(out, "num_items = %lu\n", lh->num_items); BIO_printf(out, "num_nodes = %u\n", lh->num_nodes); BIO_printf(out, "num_alloc_nodes = %u\n", lh->num_alloc_nodes); BIO_printf(out, "num_expands = %lu\n", lh->num_expands); BIO_printf(out, "num_expand_reallocs = %lu\n", lh->num_expand_reallocs); BIO_printf(out, "num_contracts = %lu\n", lh->num_contracts); BIO_printf(out, "num_contract_reallocs = %lu\n", lh->num_contract_reallocs); BIO_printf(out, "num_hash_calls = %lu\n", lh->num_hash_calls); BIO_printf(out, "num_comp_calls = %lu\n", lh->num_comp_calls); BIO_printf(out, "num_insert = %lu\n", lh->num_insert); BIO_printf(out, "num_replace = %lu\n", lh->num_replace); BIO_printf(out, "num_delete = %lu\n", lh->num_delete); BIO_printf(out, "num_no_delete = %lu\n", lh->num_no_delete); BIO_printf(out, "num_retrieve = %lu\n", lh->num_retrieve); BIO_printf(out, "num_retrieve_miss = %lu\n", lh->num_retrieve_miss); BIO_printf(out, "num_hash_comps = %lu\n", lh->num_hash_comps); #if 0 BIO_printf(out, "p = %u\n", lh->p); BIO_printf(out, "pmax = %u\n", lh->pmax); BIO_printf(out, "up_load = %lu\n", lh->up_load); BIO_printf(out, "down_load = %lu\n", lh->down_load); #endif } void lh_node_stats_bio(const _LHASH *lh, BIO *out) { LHASH_NODE *n; unsigned int i, num; for (i = 0; i < lh->num_nodes; i++) { for (n = lh->b[i], num = 0; n != NULL; n = n->next) num++; BIO_printf(out, "node %6u -> %3u\n", i, num); } } void lh_node_usage_stats_bio(const _LHASH *lh, BIO *out) { LHASH_NODE *n; unsigned long num; unsigned int i; unsigned long total = 0, n_used = 0; for (i = 0; i < lh->num_nodes; i++) { for (n = lh->b[i], num = 0; n != NULL; n = n->next) num++; if (num != 0) { n_used++; total += num; } } BIO_printf(out, "%lu nodes used out of %u\n", n_used, lh->num_nodes); BIO_printf(out, "%lu items\n", total); if (n_used == 0) return; BIO_printf(out, "load %d.%02d actual load %d.%02d\n", (int)(total / lh->num_nodes), (int)((total % lh->num_nodes) * 100 / lh->num_nodes), (int)(total / n_used), (int)((total % n_used) * 100 / n_used)); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/mem_dbg.c0000644000175000017500000001541412360020705020016 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include int CRYPTO_mem_ctrl(int mode) { return (CRYPTO_MEM_CHECK_OFF); } int CRYPTO_is_mem_check_on(void) { return (0); } void CRYPTO_dbg_set_options(long bits) { return; } long CRYPTO_dbg_get_options(void) { return (0); } int CRYPTO_push_info_(const char *info, const char *file, int line) { return (0); } int CRYPTO_pop_info(void) { return (0); } int CRYPTO_remove_all_info(void) { return (0); } void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line, int before_p) { /* CRYPTO_dbg_malloc is no longer permitted */ abort(); } void CRYPTO_dbg_free(void *addr, int before_p) { /* CRYPTO_dbg_free is no longer permitted */ abort(); } void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, const char *file, int line, int before_p) { /* CRYPTO_dbg_realloc is no longer permitted */ abort(); } void CRYPTO_mem_leaks(BIO *b) { return; } void CRYPTO_mem_leaks_fp(FILE *fp) { return; } void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb) { return; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/cryptlib.c0000644000175000017500000004735512360020705020265 0ustar /* $OpenBSD: cryptlib.c,v 1.31 2014/07/10 22:45:56 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * ECDH support in OpenSSL originally developed by * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. */ #include #include #include #include #include #include #include #include DECLARE_STACK_OF(CRYPTO_dynlock) /* real #defines in crypto.h, keep these upto date */ static const char* const lock_names[CRYPTO_NUM_LOCKS] = { "<>", "err", "ex_data", "x509", "x509_info", "x509_pkey", "x509_crl", "x509_req", "dsa", "rsa", "evp_pkey", "x509_store", "ssl_ctx", "ssl_cert", "ssl_session", "ssl_sess_cert", "ssl", "ssl_method", "rand", "rand2", "debug_malloc", "BIO", "gethostbyname", "getservbyname", "readdir", "RSA_blinding", "dh", "debug_malloc2", "dso", "dynlock", "engine", "ui", "ecdsa", "ec", "ecdh", "bn", "ec_pre_comp", "store", "comp", "fips", "fips2", #if CRYPTO_NUM_LOCKS != 41 # error "Inconsistency between crypto.h and cryptlib.c" #endif }; /* This is for applications to allocate new type names in the non-dynamic array of lock names. These are numbered with positive numbers. */ static STACK_OF(OPENSSL_STRING) *app_locks = NULL; /* For applications that want a more dynamic way of handling threads, the following stack is used. These are externally numbered with negative numbers. */ static STACK_OF(CRYPTO_dynlock) *dyn_locks = NULL; static void (*locking_callback)(int mode, int type, const char *file, int line) = 0; static int (*add_lock_callback)(int *pointer, int amount, int type, const char *file, int line) = 0; #ifndef OPENSSL_NO_DEPRECATED static unsigned long (*id_callback)(void) = 0; #endif static void (*threadid_callback)(CRYPTO_THREADID *) = 0; static struct CRYPTO_dynlock_value *(*dynlock_create_callback)( const char *file, int line) = 0; static void (*dynlock_lock_callback)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line) = 0; static void (*dynlock_destroy_callback)(struct CRYPTO_dynlock_value *l, const char *file, int line) = 0; int CRYPTO_get_new_lockid(char *name) { char *str; int i; if ((app_locks == NULL) && ((app_locks = sk_OPENSSL_STRING_new_null()) == NULL)) { CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE); return (0); } if ((str = BUF_strdup(name)) == NULL) { CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE); return (0); } i = sk_OPENSSL_STRING_push(app_locks, str); if (!i) free(str); else i += CRYPTO_NUM_LOCKS; /* gap of one :-) */ return (i); } int CRYPTO_num_locks(void) { return CRYPTO_NUM_LOCKS; } int CRYPTO_get_new_dynlockid(void) { int i = 0; CRYPTO_dynlock *pointer = NULL; if (dynlock_create_callback == NULL) { CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK); return (0); } CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK); if ((dyn_locks == NULL) && ((dyn_locks = sk_CRYPTO_dynlock_new_null()) == NULL)) { CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE); return (0); } CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); pointer = malloc(sizeof(CRYPTO_dynlock)); if (pointer == NULL) { CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE); return (0); } pointer->references = 1; pointer->data = dynlock_create_callback(__FILE__, __LINE__); if (pointer->data == NULL) { free(pointer); CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE); return (0); } CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK); /* First, try to find an existing empty slot */ i = sk_CRYPTO_dynlock_find(dyn_locks, NULL); /* If there was none, push, thereby creating a new one */ if (i == -1) /* Since sk_push() returns the number of items on the stack, not the location of the pushed item, we need to transform the returned number into a position, by decreasing it. */ i = sk_CRYPTO_dynlock_push(dyn_locks, pointer) - 1; else /* If we found a place with a NULL pointer, put our pointer in it. */ (void)sk_CRYPTO_dynlock_set(dyn_locks, i, pointer); CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); if (i == -1) { dynlock_destroy_callback(pointer->data, __FILE__, __LINE__); free(pointer); } else i += 1; /* to avoid 0 */ return -i; } void CRYPTO_destroy_dynlockid(int i) { CRYPTO_dynlock *pointer = NULL; if (i) i = -i - 1; if (dynlock_destroy_callback == NULL) return; CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK); if (dyn_locks == NULL || i >= sk_CRYPTO_dynlock_num(dyn_locks)) { CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); return; } pointer = sk_CRYPTO_dynlock_value(dyn_locks, i); if (pointer != NULL) { --pointer->references; if (pointer->references <= 0) { (void)sk_CRYPTO_dynlock_set(dyn_locks, i, NULL); } else pointer = NULL; } CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); if (pointer) { dynlock_destroy_callback(pointer->data, __FILE__, __LINE__); free(pointer); } } struct CRYPTO_dynlock_value * CRYPTO_get_dynlock_value(int i) { CRYPTO_dynlock *pointer = NULL; if (i) i = -i - 1; CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK); if (dyn_locks != NULL && i < sk_CRYPTO_dynlock_num(dyn_locks)) pointer = sk_CRYPTO_dynlock_value(dyn_locks, i); if (pointer) pointer->references++; CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); if (pointer) return pointer->data; return NULL; } struct CRYPTO_dynlock_value * (*CRYPTO_get_dynlock_create_callback(void))(const char *file, int line) { return (dynlock_create_callback); } void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line) { return (dynlock_lock_callback); } void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file, int line) { return (dynlock_destroy_callback); } void CRYPTO_set_dynlock_create_callback( struct CRYPTO_dynlock_value *(*func)(const char *file, int line)) { dynlock_create_callback = func; } void CRYPTO_set_dynlock_lock_callback(void (*func)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)) { dynlock_lock_callback = func; } void CRYPTO_set_dynlock_destroy_callback( void (*func)(struct CRYPTO_dynlock_value *l, const char *file, int line)) { dynlock_destroy_callback = func; } void (*CRYPTO_get_locking_callback(void))(int mode, int type, const char *file, int line) { return (locking_callback); } int (*CRYPTO_get_add_lock_callback(void))(int *num, int mount, int type, const char *file, int line) { return (add_lock_callback); } void CRYPTO_set_locking_callback(void (*func)(int mode, int type, const char *file, int line)) { /* Calling this here ensures initialisation before any threads * are started. */ OPENSSL_init(); locking_callback = func; } void CRYPTO_set_add_lock_callback(int (*func)(int *num, int mount, int type, const char *file, int line)) { add_lock_callback = func; } /* the memset() here and in set_pointer() seem overkill, but for the sake of * CRYPTO_THREADID_cmp() this avoids any platform silliness that might cause two * "equal" THREADID structs to not be memcmp()-identical. */ void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val) { memset(id, 0, sizeof(*id)); id->val = val; } static const unsigned char hash_coeffs[] = { 3, 5, 7, 11, 13, 17, 19, 23 }; void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr) { unsigned char *dest = (void *)&id->val; unsigned int accum = 0; unsigned char dnum = sizeof(id->val); memset(id, 0, sizeof(*id)); id->ptr = ptr; if (sizeof(id->val) >= sizeof(id->ptr)) { /* 'ptr' can be embedded in 'val' without loss of uniqueness */ id->val = (unsigned long)id->ptr; return; } /* hash ptr ==> val. Each byte of 'val' gets the mod-256 total of a * linear function over the bytes in 'ptr', the co-efficients of which * are a sequence of low-primes (hash_coeffs is an 8-element cycle) - * the starting prime for the sequence varies for each byte of 'val' * (unique polynomials unless pointers are >64-bit). For added spice, * the totals accumulate rather than restarting from zero, and the index * of the 'val' byte is added each time (position dependence). If I was * a black-belt, I'd scan big-endian pointers in reverse to give * low-order bits more play, but this isn't crypto and I'd prefer nobody * mistake it as such. Plus I'm lazy. */ while (dnum--) { const unsigned char *src = (void *)&id->ptr; unsigned char snum = sizeof(id->ptr); while (snum--) accum += *(src++) * hash_coeffs[(snum + dnum) & 7]; accum += dnum; *(dest++) = accum & 255; } } int CRYPTO_THREADID_set_callback(void (*func)(CRYPTO_THREADID *)) { if (threadid_callback) return 0; threadid_callback = func; return 1; } void (*CRYPTO_THREADID_get_callback(void))(CRYPTO_THREADID *) { return threadid_callback; } void CRYPTO_THREADID_current(CRYPTO_THREADID *id) { if (threadid_callback) { threadid_callback(id); return; } #ifndef OPENSSL_NO_DEPRECATED /* If the deprecated callback was set, fall back to that */ if (id_callback) { CRYPTO_THREADID_set_numeric(id, id_callback()); return; } #endif /* Else pick a backup */ /* For everything else, default to using the address of 'errno' */ CRYPTO_THREADID_set_pointer(id, (void*)&errno); } int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b) { return memcmp(a, b, sizeof(*a)); } void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src) { memcpy(dest, src, sizeof(*src)); } unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id) { return id->val; } #ifndef OPENSSL_NO_DEPRECATED unsigned long (*CRYPTO_get_id_callback(void))(void) { return (id_callback); } void CRYPTO_set_id_callback(unsigned long (*func)(void)) { id_callback = func; } unsigned long CRYPTO_thread_id(void) { unsigned long ret = 0; if (id_callback == NULL) { ret = (unsigned long)getpid(); } else ret = id_callback(); return (ret); } #endif void CRYPTO_lock(int mode, int type, const char *file, int line) { #ifdef LOCK_DEBUG { CRYPTO_THREADID id; char *rw_text, *operation_text; if (mode & CRYPTO_LOCK) operation_text = "lock "; else if (mode & CRYPTO_UNLOCK) operation_text = "unlock"; else operation_text = "ERROR "; if (mode & CRYPTO_READ) rw_text = "r"; else if (mode & CRYPTO_WRITE) rw_text = "w"; else rw_text = "ERROR"; CRYPTO_THREADID_current(&id); fprintf(stderr, "lock:%08lx:(%s)%s %-18s %s:%d\n", CRYPTO_THREADID_hash(&id), rw_text, operation_text, CRYPTO_get_lock_name(type), file, line); } #endif if (type < 0) { if (dynlock_lock_callback != NULL) { struct CRYPTO_dynlock_value *pointer = CRYPTO_get_dynlock_value(type); OPENSSL_assert(pointer != NULL); dynlock_lock_callback(mode, pointer, file, line); CRYPTO_destroy_dynlockid(type); } } else if (locking_callback != NULL) locking_callback(mode, type, file, line); } int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file, int line) { int ret = 0; if (add_lock_callback != NULL) { #ifdef LOCK_DEBUG int before= *pointer; #endif ret = add_lock_callback(pointer, amount, type, file, line); #ifdef LOCK_DEBUG { CRYPTO_THREADID id; CRYPTO_THREADID_current(&id); fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n", CRYPTO_THREADID_hash(&id), before, amount, ret, CRYPTO_get_lock_name(type), file, line); } #endif } else { CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE, type, file, line); ret= *pointer + amount; #ifdef LOCK_DEBUG { CRYPTO_THREADID id; CRYPTO_THREADID_current(&id); fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n", CRYPTO_THREADID_hash(&id), *pointer, amount, ret, CRYPTO_get_lock_name(type), file, line); } #endif *pointer = ret; CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE, type, file, line); } return (ret); } const char * CRYPTO_get_lock_name(int type) { if (type < 0) return("dynamic"); else if (type < CRYPTO_NUM_LOCKS) return (lock_names[type]); else if (type - CRYPTO_NUM_LOCKS > sk_OPENSSL_STRING_num(app_locks)) return("ERROR"); else return (sk_OPENSSL_STRING_value(app_locks, type - CRYPTO_NUM_LOCKS)); } #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ defined(__INTEL__) || \ defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64) unsigned int OPENSSL_ia32cap_P[2]; unsigned long * OPENSSL_ia32cap_loc(void) { if (sizeof(long) == 4) /* * If 32-bit application pulls address of OPENSSL_ia32cap_P[0] * clear second element to maintain the illusion that vector * is 32-bit. */ OPENSSL_ia32cap_P[1] = 0; return (unsigned long *)OPENSSL_ia32cap_P; } #if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY) #define OPENSSL_CPUID_SETUP typedef unsigned long long IA32CAP; void OPENSSL_cpuid_setup(void) { static int trigger = 0; IA32CAP OPENSSL_ia32_cpuid(void); IA32CAP vec; if (trigger) return; trigger = 1; vec = OPENSSL_ia32_cpuid(); /* * |(1<<10) sets a reserved bit to signal that variable * was initialized already... This is to avoid interference * with cpuid snippets in ELF .init segment. */ OPENSSL_ia32cap_P[0] = (unsigned int)vec | (1 << 10); OPENSSL_ia32cap_P[1] = (unsigned int)(vec >> 32); } #endif #else unsigned long * OPENSSL_ia32cap_loc(void) { return NULL; } #endif #if !defined(OPENSSL_CPUID_SETUP) && !defined(OPENSSL_CPUID_OBJ) void OPENSSL_cpuid_setup(void) { } #endif static void OPENSSL_showfatal(const char *fmta, ...) { va_list ap; va_start(ap, fmta); vfprintf(stderr, fmta, ap); va_end(ap); } void OpenSSLDie(const char *file, int line, const char *assertion) { OPENSSL_showfatal( "%s(%d): OpenSSL internal error, assertion failed: %s\n", file, line, assertion); abort(); } int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len) { size_t i; const unsigned char *a = in_a; const unsigned char *b = in_b; unsigned char x = 0; for (i = 0; i < len; i++) x |= a[i] ^ b[i]; return x; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/aes/0000755000000000000000000000000012666635521020622 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/aes/aes_locl.h0000644000175000017500000000613512360020705020762 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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 HEADER_AES_LOCL_H #define HEADER_AES_LOCL_H #include #ifdef OPENSSL_NO_AES #error AES is disabled. #endif #include #include #include #define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3])) #define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); } typedef unsigned int u32; typedef unsigned short u16; typedef unsigned char u8; #define MAXKC (256/32) #define MAXKB (256/8) #define MAXNR 14 /* This controls loop-unrolling in aes_core.c */ #undef FULL_UNROLL #endif /* !HEADER_AES_LOCL_H */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/aes/aes_misc.c0000644000175000017500000000527112360020705020757 0ustar /* $OpenBSD: aes_misc.c,v 1.9 2014/07/09 09:10:07 miod Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * */ #include #include #include #include "aes_locl.h" const char * AES_options(void) { #ifdef FULL_UNROLL return "aes(full)"; #else return "aes(partial)"; #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/aes/aes_ecb.c0000644000175000017500000000551412360020705020555 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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 AES_DEBUG # ifndef NDEBUG # define NDEBUG # endif #endif #include #include #include "aes_locl.h" void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key, const int enc) { assert(in && out && key); assert((AES_ENCRYPT == enc) || (AES_DECRYPT == enc)); if (AES_ENCRYPT == enc) AES_encrypt(in, out, key); else AES_decrypt(in, out, key); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/aes/aes_ofb.c0000644000175000017500000000530712360020705020572 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * */ #include #include void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key, unsigned char *ivec, int *num) { CRYPTO_ofb128_encrypt(in, out, length, key, ivec, num, (block128_f)AES_encrypt); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/aes/aes_wrap.c0000644000175000017500000001036512360020705020775 0ustar /* $OpenBSD: aes_wrap.c,v 1.8 2014/07/10 13:58:21 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ /* ==================================================================== * Copyright (c) 2008 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== */ #include #include #include static const unsigned char default_iv[] = { 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, }; int AES_wrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out, const unsigned char *in, unsigned int inlen) { unsigned char *A, B[16], *R; unsigned int i, j, t; if ((inlen & 0x7) || (inlen < 8)) return -1; A = B; t = 1; memcpy(out + 8, in, inlen); if (!iv) iv = default_iv; memcpy(A, iv, 8); for (j = 0; j < 6; j++) { R = out + 8; for (i = 0; i < inlen; i += 8, t++, R += 8) { memcpy(B + 8, R, 8); AES_encrypt(B, B, key); A[7] ^= (unsigned char)(t & 0xff); if (t > 0xff) { A[6] ^= (unsigned char)((t >> 8) & 0xff); A[5] ^= (unsigned char)((t >> 16) & 0xff); A[4] ^= (unsigned char)((t >> 24) & 0xff); } memcpy(R, B + 8, 8); } } memcpy(out, A, 8); return inlen + 8; } int AES_unwrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out, const unsigned char *in, unsigned int inlen) { unsigned char *A, B[16], *R; unsigned int i, j, t; inlen -= 8; if (inlen & 0x7) return -1; if (inlen < 8) return -1; A = B; t = 6 * (inlen >> 3); memcpy(A, in, 8); memcpy(out, in + 8, inlen); for (j = 0; j < 6; j++) { R = out + inlen - 8; for (i = 0; i < inlen; i += 8, t--, R -= 8) { A[7] ^= (unsigned char)(t & 0xff); if (t > 0xff) { A[6] ^= (unsigned char)((t >> 8) & 0xff); A[5] ^= (unsigned char)((t >> 16) & 0xff); A[4] ^= (unsigned char)((t >> 24) & 0xff); } memcpy(B + 8, R, 8); AES_decrypt(B, B, key); memcpy(R, B + 8, 8); } } if (!iv) iv = default_iv; if (memcmp(A, iv, 8)) { OPENSSL_cleanse(out, inlen); return 0; } return inlen; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/aes/aes_ctr.c0000644000175000017500000000543112360020705020612 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * */ #include #include void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key, unsigned char ivec[AES_BLOCK_SIZE], unsigned char ecount_buf[AES_BLOCK_SIZE], unsigned int *num) { CRYPTO_ctr128_encrypt(in, out, length, key, ivec, ecount_buf, num, (block128_f)AES_encrypt); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/aes/aes_core.c0000644000175000017500000015662412360020705020765 0ustar /* $OpenBSD: aes_core.c,v 1.10 2014/06/12 15:49:27 deraadt Exp $ */ /** * rijndael-alg-fst.c * * @version 3.0 (December 2000) * * Optimised ANSI C code for the Rijndael cipher (now AES) * * @author Vincent Rijmen * @author Antoon Bosselaers * @author Paulo Barreto * * This code is hereby placed in the public domain. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''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 THE AUTHORS OR CONTRIBUTORS 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. */ /* Note: rewritten a little bit to provide error control and an OpenSSL- compatible API */ #ifndef AES_DEBUG # ifndef NDEBUG # define NDEBUG # endif #endif #include #include #include #include "aes_locl.h" #ifndef AES_ASM /* Te0[x] = S [x].[02, 01, 01, 03]; Te1[x] = S [x].[03, 02, 01, 01]; Te2[x] = S [x].[01, 03, 02, 01]; Te3[x] = S [x].[01, 01, 03, 02]; Td0[x] = Si[x].[0e, 09, 0d, 0b]; Td1[x] = Si[x].[0b, 0e, 09, 0d]; Td2[x] = Si[x].[0d, 0b, 0e, 09]; Td3[x] = Si[x].[09, 0d, 0b, 0e]; Td4[x] = Si[x].[01]; */ static const u32 Te0[256] = { 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU, 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU, 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U, 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU, 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU, 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU, 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU, 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU, 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U, 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU, 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU, 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U, 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU, 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU, 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU, 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU, 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU, 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U, 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU, 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU, 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU, 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU, 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U, 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U, 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U, 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U, 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU, 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U, 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U, 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU, 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU, 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U, 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U, 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U, 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU, 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U, 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU, 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U, 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU, 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U, 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U, 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU, 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U, 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U, 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U, 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U, 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U, 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U, 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U, 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U, 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU, 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U, 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U, 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U, 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U, 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U, 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U, 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU, 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U, 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U, 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U, 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, }; static const u32 Te1[256] = { 0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU, 0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U, 0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU, 0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U, 0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU, 0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U, 0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU, 0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U, 0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U, 0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU, 0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U, 0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U, 0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U, 0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU, 0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U, 0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U, 0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU, 0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U, 0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U, 0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U, 0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU, 0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU, 0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U, 0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU, 0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU, 0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U, 0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU, 0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U, 0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU, 0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U, 0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U, 0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U, 0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU, 0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U, 0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU, 0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U, 0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU, 0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U, 0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U, 0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU, 0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU, 0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU, 0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U, 0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U, 0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU, 0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U, 0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU, 0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U, 0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU, 0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U, 0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU, 0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU, 0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U, 0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU, 0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U, 0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU, 0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U, 0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U, 0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U, 0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU, 0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU, 0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U, 0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU, 0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U, }; static const u32 Te2[256] = { 0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU, 0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U, 0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU, 0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U, 0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU, 0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U, 0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU, 0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U, 0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U, 0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU, 0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U, 0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U, 0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U, 0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU, 0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U, 0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U, 0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU, 0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U, 0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U, 0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U, 0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU, 0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU, 0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U, 0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU, 0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU, 0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U, 0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU, 0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U, 0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU, 0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U, 0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U, 0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U, 0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU, 0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U, 0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU, 0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U, 0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU, 0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U, 0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U, 0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU, 0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU, 0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU, 0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U, 0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U, 0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU, 0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U, 0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU, 0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U, 0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU, 0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U, 0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU, 0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU, 0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U, 0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU, 0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U, 0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU, 0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U, 0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U, 0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U, 0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU, 0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU, 0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U, 0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU, 0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U, }; static const u32 Te3[256] = { 0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U, 0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U, 0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U, 0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU, 0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU, 0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU, 0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U, 0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU, 0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU, 0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U, 0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U, 0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU, 0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU, 0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU, 0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU, 0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU, 0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U, 0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU, 0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU, 0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U, 0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U, 0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U, 0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U, 0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U, 0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU, 0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U, 0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU, 0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU, 0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U, 0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U, 0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U, 0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU, 0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U, 0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU, 0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU, 0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U, 0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U, 0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU, 0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U, 0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU, 0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U, 0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U, 0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U, 0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U, 0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU, 0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U, 0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU, 0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U, 0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU, 0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U, 0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU, 0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU, 0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU, 0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU, 0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U, 0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U, 0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U, 0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U, 0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U, 0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U, 0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU, 0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U, 0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU, 0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU, }; static const u32 Td0[256] = { 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U, 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU, 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U, 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U, 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU, 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U, 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU, 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U, 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U, 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U, 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U, 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU, 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U, 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU, 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U, 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU, 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U, 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U, 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U, 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU, 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U, 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU, 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U, 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU, 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U, 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU, 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU, 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U, 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU, 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U, 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU, 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U, 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U, 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U, 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU, 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U, 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U, 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU, 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U, 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U, 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U, 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U, 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U, 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU, 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U, 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U, 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U, 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U, 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U, 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU, 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU, 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU, 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU, 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U, 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U, 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU, 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU, 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U, 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU, 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U, 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U, 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, }; static const u32 Td1[256] = { 0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU, 0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U, 0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU, 0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U, 0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U, 0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U, 0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U, 0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U, 0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U, 0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU, 0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU, 0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU, 0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U, 0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU, 0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U, 0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U, 0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U, 0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU, 0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU, 0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U, 0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU, 0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U, 0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU, 0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU, 0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U, 0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U, 0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U, 0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU, 0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U, 0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU, 0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U, 0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U, 0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U, 0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU, 0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U, 0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U, 0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U, 0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U, 0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U, 0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U, 0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU, 0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU, 0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U, 0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU, 0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U, 0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU, 0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU, 0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U, 0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU, 0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U, 0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U, 0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U, 0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U, 0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U, 0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U, 0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U, 0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU, 0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U, 0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U, 0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU, 0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U, 0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U, 0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U, 0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U, }; static const u32 Td2[256] = { 0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U, 0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U, 0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U, 0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U, 0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU, 0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U, 0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U, 0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U, 0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U, 0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU, 0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U, 0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U, 0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU, 0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U, 0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U, 0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U, 0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U, 0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U, 0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U, 0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU, 0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U, 0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U, 0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U, 0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U, 0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U, 0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU, 0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU, 0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U, 0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU, 0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U, 0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU, 0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU, 0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU, 0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU, 0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U, 0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U, 0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U, 0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U, 0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U, 0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U, 0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U, 0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU, 0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU, 0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U, 0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U, 0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU, 0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU, 0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U, 0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U, 0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U, 0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U, 0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U, 0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U, 0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U, 0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU, 0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U, 0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U, 0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U, 0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U, 0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U, 0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U, 0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU, 0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U, 0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U, }; static const u32 Td3[256] = { 0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU, 0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU, 0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U, 0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U, 0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU, 0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU, 0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U, 0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU, 0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U, 0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU, 0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U, 0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U, 0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U, 0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U, 0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U, 0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU, 0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU, 0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U, 0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U, 0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU, 0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU, 0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U, 0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U, 0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U, 0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U, 0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU, 0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U, 0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U, 0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU, 0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU, 0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U, 0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U, 0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U, 0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU, 0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U, 0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U, 0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U, 0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U, 0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U, 0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U, 0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U, 0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU, 0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U, 0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U, 0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU, 0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU, 0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U, 0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU, 0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U, 0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U, 0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U, 0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U, 0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U, 0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U, 0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU, 0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU, 0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU, 0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU, 0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U, 0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U, 0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U, 0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU, 0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U, 0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U, }; static const u8 Td4[256] = { 0x52U, 0x09U, 0x6aU, 0xd5U, 0x30U, 0x36U, 0xa5U, 0x38U, 0xbfU, 0x40U, 0xa3U, 0x9eU, 0x81U, 0xf3U, 0xd7U, 0xfbU, 0x7cU, 0xe3U, 0x39U, 0x82U, 0x9bU, 0x2fU, 0xffU, 0x87U, 0x34U, 0x8eU, 0x43U, 0x44U, 0xc4U, 0xdeU, 0xe9U, 0xcbU, 0x54U, 0x7bU, 0x94U, 0x32U, 0xa6U, 0xc2U, 0x23U, 0x3dU, 0xeeU, 0x4cU, 0x95U, 0x0bU, 0x42U, 0xfaU, 0xc3U, 0x4eU, 0x08U, 0x2eU, 0xa1U, 0x66U, 0x28U, 0xd9U, 0x24U, 0xb2U, 0x76U, 0x5bU, 0xa2U, 0x49U, 0x6dU, 0x8bU, 0xd1U, 0x25U, 0x72U, 0xf8U, 0xf6U, 0x64U, 0x86U, 0x68U, 0x98U, 0x16U, 0xd4U, 0xa4U, 0x5cU, 0xccU, 0x5dU, 0x65U, 0xb6U, 0x92U, 0x6cU, 0x70U, 0x48U, 0x50U, 0xfdU, 0xedU, 0xb9U, 0xdaU, 0x5eU, 0x15U, 0x46U, 0x57U, 0xa7U, 0x8dU, 0x9dU, 0x84U, 0x90U, 0xd8U, 0xabU, 0x00U, 0x8cU, 0xbcU, 0xd3U, 0x0aU, 0xf7U, 0xe4U, 0x58U, 0x05U, 0xb8U, 0xb3U, 0x45U, 0x06U, 0xd0U, 0x2cU, 0x1eU, 0x8fU, 0xcaU, 0x3fU, 0x0fU, 0x02U, 0xc1U, 0xafU, 0xbdU, 0x03U, 0x01U, 0x13U, 0x8aU, 0x6bU, 0x3aU, 0x91U, 0x11U, 0x41U, 0x4fU, 0x67U, 0xdcU, 0xeaU, 0x97U, 0xf2U, 0xcfU, 0xceU, 0xf0U, 0xb4U, 0xe6U, 0x73U, 0x96U, 0xacU, 0x74U, 0x22U, 0xe7U, 0xadU, 0x35U, 0x85U, 0xe2U, 0xf9U, 0x37U, 0xe8U, 0x1cU, 0x75U, 0xdfU, 0x6eU, 0x47U, 0xf1U, 0x1aU, 0x71U, 0x1dU, 0x29U, 0xc5U, 0x89U, 0x6fU, 0xb7U, 0x62U, 0x0eU, 0xaaU, 0x18U, 0xbeU, 0x1bU, 0xfcU, 0x56U, 0x3eU, 0x4bU, 0xc6U, 0xd2U, 0x79U, 0x20U, 0x9aU, 0xdbU, 0xc0U, 0xfeU, 0x78U, 0xcdU, 0x5aU, 0xf4U, 0x1fU, 0xddU, 0xa8U, 0x33U, 0x88U, 0x07U, 0xc7U, 0x31U, 0xb1U, 0x12U, 0x10U, 0x59U, 0x27U, 0x80U, 0xecU, 0x5fU, 0x60U, 0x51U, 0x7fU, 0xa9U, 0x19U, 0xb5U, 0x4aU, 0x0dU, 0x2dU, 0xe5U, 0x7aU, 0x9fU, 0x93U, 0xc9U, 0x9cU, 0xefU, 0xa0U, 0xe0U, 0x3bU, 0x4dU, 0xaeU, 0x2aU, 0xf5U, 0xb0U, 0xc8U, 0xebU, 0xbbU, 0x3cU, 0x83U, 0x53U, 0x99U, 0x61U, 0x17U, 0x2bU, 0x04U, 0x7eU, 0xbaU, 0x77U, 0xd6U, 0x26U, 0xe1U, 0x69U, 0x14U, 0x63U, 0x55U, 0x21U, 0x0cU, 0x7dU, }; static const u32 rcon[] = { 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, 0x20000000, 0x40000000, 0x80000000, 0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ }; /** * Expand the cipher key into the encryption key schedule. */ int AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) { u32 *rk; int i = 0; u32 temp; if (!userKey || !key) return -1; if (bits != 128 && bits != 192 && bits != 256) return -2; rk = key->rd_key; if (bits == 128) key->rounds = 10; else if (bits == 192) key->rounds = 12; else key->rounds = 14; rk[0] = GETU32(userKey); rk[1] = GETU32(userKey + 4); rk[2] = GETU32(userKey + 8); rk[3] = GETU32(userKey + 12); if (bits == 128) { while (1) { temp = rk[3]; rk[4] = rk[0] ^ (Te2[(temp >> 16) & 0xff] & 0xff000000) ^ (Te3[(temp >> 8) & 0xff] & 0x00ff0000) ^ (Te0[(temp) & 0xff] & 0x0000ff00) ^ (Te1[(temp >> 24)] & 0x000000ff) ^ rcon[i]; rk[5] = rk[1] ^ rk[4]; rk[6] = rk[2] ^ rk[5]; rk[7] = rk[3] ^ rk[6]; if (++i == 10) { return 0; } rk += 4; } } rk[4] = GETU32(userKey + 16); rk[5] = GETU32(userKey + 20); if (bits == 192) { while (1) { temp = rk[5]; rk[6] = rk[ 0] ^ (Te2[(temp >> 16) & 0xff] & 0xff000000) ^ (Te3[(temp >> 8) & 0xff] & 0x00ff0000) ^ (Te0[(temp) & 0xff] & 0x0000ff00) ^ (Te1[(temp >> 24)] & 0x000000ff) ^ rcon[i]; rk[7] = rk[1] ^ rk[6]; rk[8] = rk[2] ^ rk[7]; rk[9] = rk[3] ^ rk[8]; if (++i == 8) { return 0; } rk[10] = rk[4] ^ rk[9]; rk[11] = rk[5] ^ rk[10]; rk += 6; } } rk[6] = GETU32(userKey + 24); rk[7] = GETU32(userKey + 28); if (bits == 256) { while (1) { temp = rk[7]; rk[8] = rk[0] ^ (Te2[(temp >> 16) & 0xff] & 0xff000000) ^ (Te3[(temp >> 8) & 0xff] & 0x00ff0000) ^ (Te0[(temp) & 0xff] & 0x0000ff00) ^ (Te1[(temp >> 24)] & 0x000000ff) ^ rcon[i]; rk[9] = rk[1] ^ rk[8]; rk[10] = rk[2] ^ rk[9]; rk[11] = rk[3] ^ rk[10]; if (++i == 7) { return 0; } temp = rk[11]; rk[12] = rk[4] ^ (Te2[(temp >> 24)] & 0xff000000) ^ (Te3[(temp >> 16) & 0xff] & 0x00ff0000) ^ (Te0[(temp >> 8) & 0xff] & 0x0000ff00) ^ (Te1[(temp) & 0xff] & 0x000000ff); rk[13] = rk[5] ^ rk[12]; rk[14] = rk[6] ^ rk[13]; rk[15] = rk[7] ^ rk[14]; rk += 8; } } return 0; } /** * Expand the cipher key into the decryption key schedule. */ int AES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) { u32 *rk; int i, j, status; u32 temp; /* first, start with an encryption schedule */ status = AES_set_encrypt_key(userKey, bits, key); if (status < 0) return status; rk = key->rd_key; /* invert the order of the round keys: */ for (i = 0, j = 4 * (key->rounds); i < j; i += 4, j -= 4) { temp = rk[i]; rk[i] = rk[j]; rk[j] = temp; temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp; temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp; temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp; } /* apply the inverse MixColumn transform to all round keys but the first and the last: */ for (i = 1; i < (key->rounds); i++) { rk += 4; rk[0] = Td0[Te1[(rk[0] >> 24)] & 0xff] ^ Td1[Te1[(rk[0] >> 16) & 0xff] & 0xff] ^ Td2[Te1[(rk[0] >> 8) & 0xff] & 0xff] ^ Td3[Te1[(rk[0]) & 0xff] & 0xff]; rk[1] = Td0[Te1[(rk[1] >> 24)] & 0xff] ^ Td1[Te1[(rk[1] >> 16) & 0xff] & 0xff] ^ Td2[Te1[(rk[1] >> 8) & 0xff] & 0xff] ^ Td3[Te1[(rk[1]) & 0xff] & 0xff]; rk[2] = Td0[Te1[(rk[2] >> 24)] & 0xff] ^ Td1[Te1[(rk[2] >> 16) & 0xff] & 0xff] ^ Td2[Te1[(rk[2] >> 8) & 0xff] & 0xff] ^ Td3[Te1[(rk[2]) & 0xff] & 0xff]; rk[3] = Td0[Te1[(rk[3] >> 24)] & 0xff] ^ Td1[Te1[(rk[3] >> 16) & 0xff] & 0xff] ^ Td2[Te1[(rk[3] >> 8) & 0xff] & 0xff] ^ Td3[Te1[(rk[3]) & 0xff] & 0xff]; } return 0; } /* * Encrypt a single block * in and out can overlap */ void AES_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key) { const u32 *rk; u32 s0, s1, s2, s3, t0, t1, t2, t3; #ifndef FULL_UNROLL int r; #endif /* ?FULL_UNROLL */ assert(in && out && key); rk = key->rd_key; /* * map byte array block to cipher state * and add initial round key: */ s0 = GETU32(in ) ^ rk[0]; s1 = GETU32(in + 4) ^ rk[1]; s2 = GETU32(in + 8) ^ rk[2]; s3 = GETU32(in + 12) ^ rk[3]; #ifdef FULL_UNROLL /* round 1: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7]; /* round 2: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[ 8]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[ 9]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11]; /* round 3: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[13]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[14]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[15]; /* round 4: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[16]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[17]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[18]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[19]; /* round 5: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[20]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[21]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[22]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[23]; /* round 6: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[24]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[25]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[26]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[27]; /* round 7: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[28]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[29]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[30]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[31]; /* round 8: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[32]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[33]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[34]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[35]; /* round 9: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[36]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[37]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[38]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[39]; if (key->rounds > 10) { /* round 10: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[40]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[41]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[42]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[43]; /* round 11: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[44]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[45]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[46]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[47]; if (key->rounds > 12) { /* round 12: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[48]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[49]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[50]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[51]; /* round 13: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[52]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[53]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[54]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[55]; } } rk += key->rounds << 2; #else /* !FULL_UNROLL */ /* * Nr - 1 full rounds: */ r = key->rounds >> 1; for (;;) { t0 = Te0[(s0 >> 24)] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[(s3) & 0xff] ^ rk[4]; t1 = Te0[(s1 >> 24)] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[(s0) & 0xff] ^ rk[5]; t2 = Te0[(s2 >> 24)] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[(s1) & 0xff] ^ rk[6]; t3 = Te0[(s3 >> 24)] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[(s2) & 0xff] ^ rk[7]; rk += 8; if (--r == 0) { break; } s0 = Te0[(t0 >> 24)] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[(t3) & 0xff] ^ rk[0]; s1 = Te0[(t1 >> 24)] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[(t0) & 0xff] ^ rk[1]; s2 = Te0[(t2 >> 24)] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[(t1) & 0xff] ^ rk[2]; s3 = Te0[(t3 >> 24)] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[(t2) & 0xff] ^ rk[3]; } #endif /* ?FULL_UNROLL */ /* * apply last round and * map cipher state to byte array block: */ s0 = (Te2[(t0 >> 24)] & 0xff000000) ^ (Te3[(t1 >> 16) & 0xff] & 0x00ff0000) ^ (Te0[(t2 >> 8) & 0xff] & 0x0000ff00) ^ (Te1[(t3) & 0xff] & 0x000000ff) ^ rk[0]; PUTU32(out, s0); s1 = (Te2[(t1 >> 24)] & 0xff000000) ^ (Te3[(t2 >> 16) & 0xff] & 0x00ff0000) ^ (Te0[(t3 >> 8) & 0xff] & 0x0000ff00) ^ (Te1[(t0) & 0xff] & 0x000000ff) ^ rk[1]; PUTU32(out + 4, s1); s2 = (Te2[(t2 >> 24)] & 0xff000000) ^ (Te3[(t3 >> 16) & 0xff] & 0x00ff0000) ^ (Te0[(t0 >> 8) & 0xff] & 0x0000ff00) ^ (Te1[(t1) & 0xff] & 0x000000ff) ^ rk[2]; PUTU32(out + 8, s2); s3 = (Te2[(t3 >> 24)] & 0xff000000) ^ (Te3[(t0 >> 16) & 0xff] & 0x00ff0000) ^ (Te0[(t1 >> 8) & 0xff] & 0x0000ff00) ^ (Te1[(t2) & 0xff] & 0x000000ff) ^ rk[3]; PUTU32(out + 12, s3); } /* * Decrypt a single block * in and out can overlap */ void AES_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key) { const u32 *rk; u32 s0, s1, s2, s3, t0, t1, t2, t3; #ifndef FULL_UNROLL int r; #endif /* ?FULL_UNROLL */ assert(in && out && key); rk = key->rd_key; /* * map byte array block to cipher state * and add initial round key: */ s0 = GETU32(in) ^ rk[0]; s1 = GETU32(in + 4) ^ rk[1]; s2 = GETU32(in + 8) ^ rk[2]; s3 = GETU32(in + 12) ^ rk[3]; #ifdef FULL_UNROLL /* round 1: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[ 4]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[ 5]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[ 6]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[ 7]; /* round 2: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[ 8]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[ 9]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[10]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[11]; /* round 3: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[12]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[13]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[14]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[15]; /* round 4: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[16]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[17]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[18]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[19]; /* round 5: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[20]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[21]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[22]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[23]; /* round 6: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[24]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[25]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[26]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[27]; /* round 7: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[28]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[29]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[30]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[31]; /* round 8: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[32]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[33]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[34]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[35]; /* round 9: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[36]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[37]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[38]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[39]; if (key->rounds > 10) { /* round 10: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[40]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[41]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[42]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[43]; /* round 11: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[44]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[45]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[46]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[47]; if (key->rounds > 12) { /* round 12: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[48]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[49]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[50]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[51]; /* round 13: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[52]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[53]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[54]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[55]; } } rk += key->rounds << 2; #else /* !FULL_UNROLL */ /* * Nr - 1 full rounds: */ r = key->rounds >> 1; for (;;) { t0 = Td0[(s0 >> 24)] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[(s1) & 0xff] ^ rk[4]; t1 = Td0[(s1 >> 24)] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[(s2) & 0xff] ^ rk[5]; t2 = Td0[(s2 >> 24)] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[(s3) & 0xff] ^ rk[6]; t3 = Td0[(s3 >> 24)] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[(s0) & 0xff] ^ rk[7]; rk += 8; if (--r == 0) { break; } s0 = Td0[(t0 >> 24)] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[(t1) & 0xff] ^ rk[0]; s1 = Td0[(t1 >> 24)] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[(t2) & 0xff] ^ rk[1]; s2 = Td0[(t2 >> 24)] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[(t3) & 0xff] ^ rk[2]; s3 = Td0[(t3 >> 24)] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[(t0) & 0xff] ^ rk[3]; } #endif /* ?FULL_UNROLL */ /* * apply last round and * map cipher state to byte array block: */ s0 = (Td4[(t0 >> 24)] << 24) ^ (Td4[(t3 >> 16) & 0xff] << 16) ^ (Td4[(t2 >> 8) & 0xff] << 8) ^ (Td4[(t1) & 0xff]) ^ rk[0]; PUTU32(out, s0); s1 = (Td4[(t1 >> 24)] << 24) ^ (Td4[(t0 >> 16) & 0xff] << 16) ^ (Td4[(t3 >> 8) & 0xff] << 8) ^ (Td4[(t2) & 0xff]) ^ rk[1]; PUTU32(out + 4, s1); s2 = (Td4[(t2 >> 24)] << 24) ^ (Td4[(t1 >> 16) & 0xff] << 16) ^ (Td4[(t0 >> 8) & 0xff] << 8) ^ (Td4[(t3) & 0xff]) ^ rk[2]; PUTU32(out + 8, s2); s3 = (Td4[(t3 >> 24)] << 24) ^ (Td4[(t2 >> 16) & 0xff] << 16) ^ (Td4[(t1 >> 8) & 0xff] << 8) ^ (Td4[(t0) & 0xff]) ^ rk[3]; PUTU32(out + 12, s3); } #else /* AES_ASM */ static const u8 Te4[256] = { 0x63U, 0x7cU, 0x77U, 0x7bU, 0xf2U, 0x6bU, 0x6fU, 0xc5U, 0x30U, 0x01U, 0x67U, 0x2bU, 0xfeU, 0xd7U, 0xabU, 0x76U, 0xcaU, 0x82U, 0xc9U, 0x7dU, 0xfaU, 0x59U, 0x47U, 0xf0U, 0xadU, 0xd4U, 0xa2U, 0xafU, 0x9cU, 0xa4U, 0x72U, 0xc0U, 0xb7U, 0xfdU, 0x93U, 0x26U, 0x36U, 0x3fU, 0xf7U, 0xccU, 0x34U, 0xa5U, 0xe5U, 0xf1U, 0x71U, 0xd8U, 0x31U, 0x15U, 0x04U, 0xc7U, 0x23U, 0xc3U, 0x18U, 0x96U, 0x05U, 0x9aU, 0x07U, 0x12U, 0x80U, 0xe2U, 0xebU, 0x27U, 0xb2U, 0x75U, 0x09U, 0x83U, 0x2cU, 0x1aU, 0x1bU, 0x6eU, 0x5aU, 0xa0U, 0x52U, 0x3bU, 0xd6U, 0xb3U, 0x29U, 0xe3U, 0x2fU, 0x84U, 0x53U, 0xd1U, 0x00U, 0xedU, 0x20U, 0xfcU, 0xb1U, 0x5bU, 0x6aU, 0xcbU, 0xbeU, 0x39U, 0x4aU, 0x4cU, 0x58U, 0xcfU, 0xd0U, 0xefU, 0xaaU, 0xfbU, 0x43U, 0x4dU, 0x33U, 0x85U, 0x45U, 0xf9U, 0x02U, 0x7fU, 0x50U, 0x3cU, 0x9fU, 0xa8U, 0x51U, 0xa3U, 0x40U, 0x8fU, 0x92U, 0x9dU, 0x38U, 0xf5U, 0xbcU, 0xb6U, 0xdaU, 0x21U, 0x10U, 0xffU, 0xf3U, 0xd2U, 0xcdU, 0x0cU, 0x13U, 0xecU, 0x5fU, 0x97U, 0x44U, 0x17U, 0xc4U, 0xa7U, 0x7eU, 0x3dU, 0x64U, 0x5dU, 0x19U, 0x73U, 0x60U, 0x81U, 0x4fU, 0xdcU, 0x22U, 0x2aU, 0x90U, 0x88U, 0x46U, 0xeeU, 0xb8U, 0x14U, 0xdeU, 0x5eU, 0x0bU, 0xdbU, 0xe0U, 0x32U, 0x3aU, 0x0aU, 0x49U, 0x06U, 0x24U, 0x5cU, 0xc2U, 0xd3U, 0xacU, 0x62U, 0x91U, 0x95U, 0xe4U, 0x79U, 0xe7U, 0xc8U, 0x37U, 0x6dU, 0x8dU, 0xd5U, 0x4eU, 0xa9U, 0x6cU, 0x56U, 0xf4U, 0xeaU, 0x65U, 0x7aU, 0xaeU, 0x08U, 0xbaU, 0x78U, 0x25U, 0x2eU, 0x1cU, 0xa6U, 0xb4U, 0xc6U, 0xe8U, 0xddU, 0x74U, 0x1fU, 0x4bU, 0xbdU, 0x8bU, 0x8aU, 0x70U, 0x3eU, 0xb5U, 0x66U, 0x48U, 0x03U, 0xf6U, 0x0eU, 0x61U, 0x35U, 0x57U, 0xb9U, 0x86U, 0xc1U, 0x1dU, 0x9eU, 0xe1U, 0xf8U, 0x98U, 0x11U, 0x69U, 0xd9U, 0x8eU, 0x94U, 0x9bU, 0x1eU, 0x87U, 0xe9U, 0xceU, 0x55U, 0x28U, 0xdfU, 0x8cU, 0xa1U, 0x89U, 0x0dU, 0xbfU, 0xe6U, 0x42U, 0x68U, 0x41U, 0x99U, 0x2dU, 0x0fU, 0xb0U, 0x54U, 0xbbU, 0x16U }; static const u32 rcon[] = { 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, 0x20000000, 0x40000000, 0x80000000, 0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ }; /** * Expand the cipher key into the encryption key schedule. */ int AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) { u32 *rk; int i = 0; u32 temp; if (!userKey || !key) return -1; if (bits != 128 && bits != 192 && bits != 256) return -2; rk = key->rd_key; if (bits == 128) key->rounds = 10; else if (bits == 192) key->rounds = 12; else key->rounds = 14; rk[0] = GETU32(userKey); rk[1] = GETU32(userKey + 4); rk[2] = GETU32(userKey + 8); rk[3] = GETU32(userKey + 12); if (bits == 128) { while (1) { temp = rk[3]; rk[4] = rk[0] ^ (Te4[(temp >> 16) & 0xff] << 24) ^ (Te4[(temp >> 8) & 0xff] << 16) ^ (Te4[(temp) & 0xff] << 8) ^ (Te4[(temp >> 24)]) ^ rcon[i]; rk[5] = rk[1] ^ rk[4]; rk[6] = rk[2] ^ rk[5]; rk[7] = rk[3] ^ rk[6]; if (++i == 10) { return 0; } rk += 4; } } rk[4] = GETU32(userKey + 16); rk[5] = GETU32(userKey + 20); if (bits == 192) { while (1) { temp = rk[5]; rk[6] = rk[0] ^ (Te4[(temp >> 16) & 0xff] << 24) ^ (Te4[(temp >> 8) & 0xff] << 16) ^ (Te4[(temp) & 0xff] << 8) ^ (Te4[(temp >> 24)]) ^ rcon[i]; rk[7] = rk[1] ^ rk[6]; rk[8] = rk[2] ^ rk[7]; rk[9] = rk[3] ^ rk[8]; if (++i == 8) { return 0; } rk[10] = rk[4] ^ rk[9]; rk[11] = rk[5] ^ rk[10]; rk += 6; } } rk[6] = GETU32(userKey + 24); rk[7] = GETU32(userKey + 28); if (bits == 256) { while (1) { temp = rk[7]; rk[8] = rk[0] ^ (Te4[(temp >> 16) & 0xff] << 24) ^ (Te4[(temp >> 8) & 0xff] << 16) ^ (Te4[(temp) & 0xff] << 8) ^ (Te4[(temp >> 24)]) ^ rcon[i]; rk[9] = rk[1] ^ rk[8]; rk[10] = rk[2] ^ rk[9]; rk[11] = rk[3] ^ rk[10]; if (++i == 7) { return 0; } temp = rk[11]; rk[12] = rk[4] ^ (Te4[(temp >> 24)] << 24) ^ (Te4[(temp >> 16) & 0xff] << 16) ^ (Te4[(temp >> 8) & 0xff] << 8) ^ (Te4[(temp) & 0xff]); rk[13] = rk[5] ^ rk[12]; rk[14] = rk[6] ^ rk[13]; rk[15] = rk[7] ^ rk[14]; rk += 8; } } return 0; } /** * Expand the cipher key into the decryption key schedule. */ int AES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) { u32 *rk; int i, j, status; u32 temp; /* first, start with an encryption schedule */ status = AES_set_encrypt_key(userKey, bits, key); if (status < 0) return status; rk = key->rd_key; /* invert the order of the round keys: */ for (i = 0, j = 4*(key->rounds); i < j; i += 4, j -= 4) { temp = rk[i]; rk[i] = rk[j]; rk[j] = temp; temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp; temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp; temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp; } /* apply the inverse MixColumn transform to all round keys but the first and the last: */ for (i = 1; i < (key->rounds); i++) { rk += 4; for (j = 0; j < 4; j++) { u32 tp1, tp2, tp4, tp8, tp9, tpb, tpd, tpe, m; tp1 = rk[j]; m = tp1 & 0x80808080; tp2 = ((tp1 & 0x7f7f7f7f) << 1) ^ ((m - (m >> 7)) & 0x1b1b1b1b); m = tp2 & 0x80808080; tp4 = ((tp2 & 0x7f7f7f7f) << 1) ^ ((m - (m >> 7)) & 0x1b1b1b1b); m = tp4 & 0x80808080; tp8 = ((tp4 & 0x7f7f7f7f) << 1) ^ ((m - (m >> 7)) & 0x1b1b1b1b); tp9 = tp8 ^ tp1; tpb = tp9 ^ tp2; tpd = tp9 ^ tp4; tpe = tp8 ^ tp4 ^ tp2; #if defined(ROTATE) rk[j] = tpe ^ ROTATE(tpd, 16) ^ ROTATE(tp9, 24) ^ ROTATE(tpb, 8); #else rk[j] = tpe ^ (tpd >> 16) ^ (tpd << 16) ^ (tp9 >> 8) ^ (tp9 << 24) ^ (tpb >> 24) ^ (tpb << 8); #endif } } return 0; } #endif /* AES_ASM */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/aes/aes_ige.c0000644000175000017500000001463212360020705020571 0ustar /* $OpenBSD: aes_ige.c,v 1.5 2014/06/12 15:49:27 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * */ #include #include #include "aes_locl.h" #define N_WORDS (AES_BLOCK_SIZE / sizeof(unsigned long)) typedef struct { unsigned long data[N_WORDS]; } aes_block_t; /* XXX: probably some better way to do this */ #if defined(__i386__) || defined(__x86_64__) #define UNALIGNED_MEMOPS_ARE_FAST 1 #else #define UNALIGNED_MEMOPS_ARE_FAST 0 #endif #if UNALIGNED_MEMOPS_ARE_FAST #define load_block(d, s) (d) = *(const aes_block_t *)(s) #define store_block(d, s) *(aes_block_t *)(d) = (s) #else #define load_block(d, s) memcpy((d).data, (s), AES_BLOCK_SIZE) #define store_block(d, s) memcpy((d), (s).data, AES_BLOCK_SIZE) #endif /* N.B. The IV for this mode is _twice_ the block size */ void AES_ige_encrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key, unsigned char *ivec, const int enc) { size_t n; size_t len = length; OPENSSL_assert(in && out && key && ivec); OPENSSL_assert((AES_ENCRYPT == enc) || (AES_DECRYPT == enc)); OPENSSL_assert((length % AES_BLOCK_SIZE) == 0); len = length / AES_BLOCK_SIZE; if (AES_ENCRYPT == enc) { if (in != out && (UNALIGNED_MEMOPS_ARE_FAST || ((size_t)in|(size_t)out|(size_t)ivec) % sizeof(long) == 0)) { aes_block_t *ivp = (aes_block_t *)ivec; aes_block_t *iv2p = (aes_block_t *)(ivec + AES_BLOCK_SIZE); while (len) { aes_block_t *inp = (aes_block_t *)in; aes_block_t *outp = (aes_block_t *)out; for (n = 0; n < N_WORDS; ++n) outp->data[n] = inp->data[n] ^ ivp->data[n]; AES_encrypt((unsigned char *)outp->data, (unsigned char *)outp->data, key); for (n = 0; n < N_WORDS; ++n) outp->data[n] ^= iv2p->data[n]; ivp = outp; iv2p = inp; --len; in += AES_BLOCK_SIZE; out += AES_BLOCK_SIZE; } memcpy(ivec, ivp->data, AES_BLOCK_SIZE); memcpy(ivec + AES_BLOCK_SIZE, iv2p->data, AES_BLOCK_SIZE); } else { aes_block_t tmp, tmp2; aes_block_t iv; aes_block_t iv2; load_block(iv, ivec); load_block(iv2, ivec + AES_BLOCK_SIZE); while (len) { load_block(tmp, in); for (n = 0; n < N_WORDS; ++n) tmp2.data[n] = tmp.data[n] ^ iv.data[n]; AES_encrypt((unsigned char *)tmp2.data, (unsigned char *)tmp2.data, key); for (n = 0; n < N_WORDS; ++n) tmp2.data[n] ^= iv2.data[n]; store_block(out, tmp2); iv = tmp2; iv2 = tmp; --len; in += AES_BLOCK_SIZE; out += AES_BLOCK_SIZE; } memcpy(ivec, iv.data, AES_BLOCK_SIZE); memcpy(ivec + AES_BLOCK_SIZE, iv2.data, AES_BLOCK_SIZE); } } else { if (in != out && (UNALIGNED_MEMOPS_ARE_FAST || ((size_t)in|(size_t)out|(size_t)ivec) % sizeof(long) == 0)) { aes_block_t *ivp = (aes_block_t *)ivec; aes_block_t *iv2p = (aes_block_t *)(ivec + AES_BLOCK_SIZE); while (len) { aes_block_t tmp; aes_block_t *inp = (aes_block_t *)in; aes_block_t *outp = (aes_block_t *)out; for (n = 0; n < N_WORDS; ++n) tmp.data[n] = inp->data[n] ^ iv2p->data[n]; AES_decrypt((unsigned char *)tmp.data, (unsigned char *)outp->data, key); for (n = 0; n < N_WORDS; ++n) outp->data[n] ^= ivp->data[n]; ivp = inp; iv2p = outp; --len; in += AES_BLOCK_SIZE; out += AES_BLOCK_SIZE; } memcpy(ivec, ivp->data, AES_BLOCK_SIZE); memcpy(ivec + AES_BLOCK_SIZE, iv2p->data, AES_BLOCK_SIZE); } else { aes_block_t tmp, tmp2; aes_block_t iv; aes_block_t iv2; load_block(iv, ivec); load_block(iv2, ivec + AES_BLOCK_SIZE); while (len) { load_block(tmp, in); tmp2 = tmp; for (n = 0; n < N_WORDS; ++n) tmp.data[n] ^= iv2.data[n]; AES_decrypt((unsigned char *)tmp.data, (unsigned char *)tmp.data, key); for (n = 0; n < N_WORDS; ++n) tmp.data[n] ^= iv.data[n]; store_block(out, tmp); iv = tmp2; iv2 = tmp; --len; in += AES_BLOCK_SIZE; out += AES_BLOCK_SIZE; } memcpy(ivec, iv.data, AES_BLOCK_SIZE); memcpy(ivec + AES_BLOCK_SIZE, iv2.data, AES_BLOCK_SIZE); } } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/aes/aes_cbc.c0000644000175000017500000000544112360020705020552 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * */ #include #include void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, const AES_KEY *key, unsigned char *ivec, const int enc) { if (enc) CRYPTO_cbc128_encrypt(in, out, len, key, ivec, (block128_f)AES_encrypt); else CRYPTO_cbc128_decrypt(in, out, len, key, ivec, (block128_f)AES_decrypt); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/aes/aes_cfb.c0000644000175000017500000000671412360020705020561 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * */ #include #include /* The input and output encrypted as though 128bit cfb mode is being * used. The extra state information to record how much of the * 128bit block we have used is contained in *num; */ void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key, unsigned char *ivec, int *num, const int enc) { CRYPTO_cfb128_encrypt(in, out, length, key, ivec, num, enc, (block128_f)AES_encrypt); } /* N.B. This expects the input to be packed, MS bit first */ void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key, unsigned char *ivec, int *num, const int enc) { CRYPTO_cfb128_1_encrypt(in, out, length, key, ivec, num, enc, (block128_f)AES_encrypt); } void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key, unsigned char *ivec, int *num, const int enc) { CRYPTO_cfb128_8_encrypt(in, out, length, key, ivec, num, enc, (block128_f)AES_encrypt); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/0000755000000000000000000000000012666635521020637 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_depr.c0000644000175000017500000000676112360020706021016 0ustar /* $OpenBSD: rsa_depr.c,v 1.7 2014/07/10 22:45:57 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NB: This file contains deprecated functions (compatibility wrappers to the * "new" versions). */ #include #include #include #include #include #ifndef OPENSSL_NO_DEPRECATED RSA * RSA_generate_key(int bits, unsigned long e_value, void (*callback)(int, int, void *), void *cb_arg) { BN_GENCB cb; int i; RSA *rsa = RSA_new(); BIGNUM *e = BN_new(); if (!rsa || !e) goto err; /* The problem is when building with 8, 16, or 32 BN_ULONG, * unsigned long can be larger */ for (i = 0; i < (int)sizeof(unsigned long) * 8; i++) { if (e_value & (1UL << i)) if (BN_set_bit(e, i) == 0) goto err; } BN_GENCB_set_old(&cb, callback, cb_arg); if (RSA_generate_key_ex(rsa, bits, e, &cb)) { BN_free(e); return rsa; } err: BN_free(e); RSA_free(rsa); return 0; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_locl.h0000644000175000017500000000036712360020706021016 0ustar /* $OpenBSD: rsa_locl.h,v 1.2 2014/06/12 15:49:30 deraadt Exp $ */ extern int int_rsa_verify(int dtype, const unsigned char *m, unsigned int m_len, unsigned char *rm, size_t *prm_len, const unsigned char *sigbuf, size_t siglen, RSA *rsa); deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_lib.c0000644000175000017500000001544412360020706020630 0ustar /* $OpenBSD: rsa_lib.c,v 1.27 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif static const RSA_METHOD *default_RSA_meth = NULL; RSA * RSA_new(void) { RSA *r = RSA_new_method(NULL); return r; } void RSA_set_default_method(const RSA_METHOD *meth) { default_RSA_meth = meth; } const RSA_METHOD * RSA_get_default_method(void) { if (default_RSA_meth == NULL) default_RSA_meth = RSA_PKCS1_SSLeay(); return default_RSA_meth; } const RSA_METHOD * RSA_get_method(const RSA *rsa) { return rsa->meth; } int RSA_set_method(RSA *rsa, const RSA_METHOD *meth) { /* * NB: The caller is specifically setting a method, so it's not up to us * to deal with which ENGINE it comes from. */ const RSA_METHOD *mtmp; mtmp = rsa->meth; if (mtmp->finish) mtmp->finish(rsa); #ifndef OPENSSL_NO_ENGINE if (rsa->engine) { ENGINE_finish(rsa->engine); rsa->engine = NULL; } #endif rsa->meth = meth; if (meth->init) meth->init(rsa); return 1; } RSA * RSA_new_method(ENGINE *engine) { RSA *ret; ret = malloc(sizeof(RSA)); if (ret == NULL) { RSAerr(RSA_F_RSA_NEW_METHOD, ERR_R_MALLOC_FAILURE); return NULL; } ret->meth = RSA_get_default_method(); #ifndef OPENSSL_NO_ENGINE if (engine) { if (!ENGINE_init(engine)) { RSAerr(RSA_F_RSA_NEW_METHOD, ERR_R_ENGINE_LIB); free(ret); return NULL; } ret->engine = engine; } else ret->engine = ENGINE_get_default_RSA(); if (ret->engine) { ret->meth = ENGINE_get_RSA(ret->engine); if (!ret->meth) { RSAerr(RSA_F_RSA_NEW_METHOD, ERR_R_ENGINE_LIB); ENGINE_finish(ret->engine); free(ret); return NULL; } } #endif ret->pad = 0; ret->version = 0; ret->n = NULL; ret->e = NULL; ret->d = NULL; ret->p = NULL; ret->q = NULL; ret->dmp1 = NULL; ret->dmq1 = NULL; ret->iqmp = NULL; ret->references = 1; ret->_method_mod_n = NULL; ret->_method_mod_p = NULL; ret->_method_mod_q = NULL; ret->blinding = NULL; ret->mt_blinding = NULL; ret->flags = ret->meth->flags & ~RSA_FLAG_NON_FIPS_ALLOW; if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data)) { #ifndef OPENSSL_NO_ENGINE if (ret->engine) ENGINE_finish(ret->engine); #endif free(ret); return NULL; } if (ret->meth->init != NULL && !ret->meth->init(ret)) { #ifndef OPENSSL_NO_ENGINE if (ret->engine) ENGINE_finish(ret->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data); free(ret); ret = NULL; } return ret; } void RSA_free(RSA *r) { int i; if (r == NULL) return; i = CRYPTO_add(&r->references, -1, CRYPTO_LOCK_RSA); if (i > 0) return; if (r->meth->finish) r->meth->finish(r); #ifndef OPENSSL_NO_ENGINE if (r->engine) ENGINE_finish(r->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data); BN_clear_free(r->n); BN_clear_free(r->e); BN_clear_free(r->d); BN_clear_free(r->p); BN_clear_free(r->q); BN_clear_free(r->dmp1); BN_clear_free(r->dmq1); BN_clear_free(r->iqmp); BN_BLINDING_free(r->blinding); BN_BLINDING_free(r->mt_blinding); free(r); } int RSA_up_ref(RSA *r) { int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_RSA); return i > 1 ? 1 : 0; } int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, argl, argp, new_func, dup_func, free_func); } int RSA_set_ex_data(RSA *r, int idx, void *arg) { return CRYPTO_set_ex_data(&r->ex_data, idx, arg); } void * RSA_get_ex_data(const RSA *r, int idx) { return CRYPTO_get_ex_data(&r->ex_data, idx); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_pss.c0000644000175000017500000001743412360020706020670 0ustar /* $OpenBSD: rsa_pss.c,v 1.8 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2005. */ /* ==================================================================== * Copyright (c) 2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include static const unsigned char zeroes[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash, const EVP_MD *Hash, const unsigned char *EM, int sLen) { return RSA_verify_PKCS1_PSS_mgf1(rsa, mHash, Hash, NULL, EM, sLen); } int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash, const EVP_MD *Hash, const EVP_MD *mgf1Hash, const unsigned char *EM, int sLen) { int i; int ret = 0; int hLen, maskedDBLen, MSBits, emLen; const unsigned char *H; unsigned char *DB = NULL; EVP_MD_CTX ctx; unsigned char H_[EVP_MAX_MD_SIZE]; EVP_MD_CTX_init(&ctx); if (mgf1Hash == NULL) mgf1Hash = Hash; hLen = EVP_MD_size(Hash); if (hLen < 0) goto err; /* * Negative sLen has special meanings: * -1 sLen == hLen * -2 salt length is autorecovered from signature * -N reserved */ if (sLen == -1) sLen = hLen; else if (sLen == -2) sLen = -2; else if (sLen < -2) { RSAerr(RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1, RSA_R_SLEN_CHECK_FAILED); goto err; } MSBits = (BN_num_bits(rsa->n) - 1) & 0x7; emLen = RSA_size(rsa); if (EM[0] & (0xFF << MSBits)) { RSAerr(RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1, RSA_R_FIRST_OCTET_INVALID); goto err; } if (MSBits == 0) { EM++; emLen--; } if (emLen < (hLen + sLen + 2)) { /* sLen can be small negative */ RSAerr(RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1, RSA_R_DATA_TOO_LARGE); goto err; } if (EM[emLen - 1] != 0xbc) { RSAerr(RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1, RSA_R_LAST_OCTET_INVALID); goto err; } maskedDBLen = emLen - hLen - 1; H = EM + maskedDBLen; DB = malloc(maskedDBLen); if (!DB) { RSAerr(RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1, ERR_R_MALLOC_FAILURE); goto err; } if (PKCS1_MGF1(DB, maskedDBLen, H, hLen, mgf1Hash) < 0) goto err; for (i = 0; i < maskedDBLen; i++) DB[i] ^= EM[i]; if (MSBits) DB[0] &= 0xFF >> (8 - MSBits); for (i = 0; DB[i] == 0 && i < (maskedDBLen - 1); i++) ; if (DB[i++] != 0x1) { RSAerr(RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1, RSA_R_SLEN_RECOVERY_FAILED); goto err; } if (sLen >= 0 && (maskedDBLen - i) != sLen) { RSAerr(RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1, RSA_R_SLEN_CHECK_FAILED); goto err; } if (!EVP_DigestInit_ex(&ctx, Hash, NULL) || !EVP_DigestUpdate(&ctx, zeroes, sizeof zeroes) || !EVP_DigestUpdate(&ctx, mHash, hLen)) goto err; if (maskedDBLen - i) { if (!EVP_DigestUpdate(&ctx, DB + i, maskedDBLen - i)) goto err; } if (!EVP_DigestFinal_ex(&ctx, H_, NULL)) goto err; if (memcmp(H_, H, hLen)) { RSAerr(RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1, RSA_R_BAD_SIGNATURE); ret = 0; } else ret = 1; err: free(DB); EVP_MD_CTX_cleanup(&ctx); return ret; } int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM, const unsigned char *mHash, const EVP_MD *Hash, int sLen) { return RSA_padding_add_PKCS1_PSS_mgf1(rsa, EM, mHash, Hash, NULL, sLen); } int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM, const unsigned char *mHash, const EVP_MD *Hash, const EVP_MD *mgf1Hash, int sLen) { int i; int ret = 0; int hLen, maskedDBLen, MSBits, emLen; unsigned char *H, *salt = NULL, *p; EVP_MD_CTX ctx; if (mgf1Hash == NULL) mgf1Hash = Hash; hLen = EVP_MD_size(Hash); if (hLen < 0) goto err; /* * Negative sLen has special meanings: * -1 sLen == hLen * -2 salt length is maximized * -N reserved */ if (sLen == -1) sLen = hLen; else if (sLen == -2) sLen = -2; else if (sLen < -2) { RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1, RSA_R_SLEN_CHECK_FAILED); goto err; } MSBits = (BN_num_bits(rsa->n) - 1) & 0x7; emLen = RSA_size(rsa); if (MSBits == 0) { *EM++ = 0; emLen--; } if (sLen == -2) sLen = emLen - hLen - 2; else if (emLen < (hLen + sLen + 2)) { RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); goto err; } if (sLen > 0) { salt = malloc(sLen); if (!salt) { RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1, ERR_R_MALLOC_FAILURE); goto err; } if (RAND_bytes(salt, sLen) <= 0) goto err; } maskedDBLen = emLen - hLen - 1; H = EM + maskedDBLen; EVP_MD_CTX_init(&ctx); if (!EVP_DigestInit_ex(&ctx, Hash, NULL) || !EVP_DigestUpdate(&ctx, zeroes, sizeof zeroes) || !EVP_DigestUpdate(&ctx, mHash, hLen)) goto err; if (sLen && !EVP_DigestUpdate(&ctx, salt, sLen)) goto err; if (!EVP_DigestFinal_ex(&ctx, H, NULL)) goto err; EVP_MD_CTX_cleanup(&ctx); /* Generate dbMask in place then perform XOR on it */ if (PKCS1_MGF1(EM, maskedDBLen, H, hLen, mgf1Hash)) goto err; p = EM; /* * Initial PS XORs with all zeroes which is a NOP so just update * pointer. Note from a test above this value is guaranteed to * be non-negative. */ p += emLen - sLen - hLen - 2; *p++ ^= 0x1; if (sLen > 0) { for (i = 0; i < sLen; i++) *p++ ^= salt[i]; } if (MSBits) EM[0] &= 0xFF >> (8 - MSBits); /* H is already in place so just set final 0xbc */ EM[emLen - 1] = 0xbc; ret = 1; err: free(salt); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_oaep.c0000644000175000017500000001410612360020706021000 0ustar /* $OpenBSD: rsa_oaep.c,v 1.22 2014/07/10 22:45:57 jsing Exp $ */ /* Written by Ulf Moeller. This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. */ /* EME-OAEP as defined in RFC 2437 (PKCS #1 v2.0) */ /* See Victor Shoup, "OAEP reconsidered," Nov. 2000, * * for problems with the security proof for the * original OAEP scheme, which EME-OAEP is based on. * * A new proof can be found in E. Fujisaki, T. Okamoto, * D. Pointcheval, J. Stern, "RSA-OEAP is Still Alive!", * Dec. 2000, . * The new proof has stronger requirements for the * underlying permutation: "partial-one-wayness" instead * of one-wayness. For the RSA function, this is * an equivalent notion. */ #include #include #include #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1) #include #include #include #include #include #include static int MGF1(unsigned char *mask, long len, const unsigned char *seed, long seedlen); int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, const unsigned char *from, int flen, const unsigned char *param, int plen) { int i, emlen = tlen - 1; unsigned char *db, *seed; unsigned char *dbmask, seedmask[SHA_DIGEST_LENGTH]; if (flen > emlen - 2 * SHA_DIGEST_LENGTH - 1) { RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); return 0; } if (emlen < 2 * SHA_DIGEST_LENGTH + 1) { RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, RSA_R_KEY_SIZE_TOO_SMALL); return 0; } to[0] = 0; seed = to + 1; db = to + SHA_DIGEST_LENGTH + 1; if (!EVP_Digest((void *)param, plen, db, NULL, EVP_sha1(), NULL)) return 0; memset(db + SHA_DIGEST_LENGTH, 0, emlen - flen - 2 * SHA_DIGEST_LENGTH - 1); db[emlen - flen - SHA_DIGEST_LENGTH - 1] = 0x01; memcpy(db + emlen - flen - SHA_DIGEST_LENGTH, from, flen); if (RAND_bytes(seed, SHA_DIGEST_LENGTH) <= 0) return 0; dbmask = malloc(emlen - SHA_DIGEST_LENGTH); if (dbmask == NULL) { RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, ERR_R_MALLOC_FAILURE); return 0; } if (MGF1(dbmask, emlen - SHA_DIGEST_LENGTH, seed, SHA_DIGEST_LENGTH) < 0) return 0; for (i = 0; i < emlen - SHA_DIGEST_LENGTH; i++) db[i] ^= dbmask[i]; if (MGF1(seedmask, SHA_DIGEST_LENGTH, db, emlen - SHA_DIGEST_LENGTH) < 0) return 0; for (i = 0; i < SHA_DIGEST_LENGTH; i++) seed[i] ^= seedmask[i]; free(dbmask); return 1; } int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, const unsigned char *from, int flen, int num, const unsigned char *param, int plen) { int i, dblen, mlen = -1; const unsigned char *maskeddb; int lzero; unsigned char *db = NULL; unsigned char seed[SHA_DIGEST_LENGTH], phash[SHA_DIGEST_LENGTH]; unsigned char *padded_from; int bad = 0; if (--num < 2 * SHA_DIGEST_LENGTH + 1) /* * 'num' is the length of the modulus, i.e. does not depend * on the particular ciphertext. */ goto decoding_err; lzero = num - flen; if (lzero < 0) { /* * signalling this error immediately after detection might allow * for side-channel attacks (e.g. timing if 'plen' is huge * -- cf. James H. Manger, "A Chosen Ciphertext Attack on RSA * Optimal Asymmetric Encryption Padding (OAEP) [...]", * CRYPTO 2001), so we use a 'bad' flag */ bad = 1; lzero = 0; flen = num; /* don't overflow the memcpy to padded_from */ } dblen = num - SHA_DIGEST_LENGTH; db = malloc(dblen + num); if (db == NULL) { RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, ERR_R_MALLOC_FAILURE); return -1; } /* * Always do this zero-padding copy (even when lzero == 0) * to avoid leaking timing info about the value of lzero. */ padded_from = db + dblen; memset(padded_from, 0, lzero); memcpy(padded_from + lzero, from, flen); maskeddb = padded_from + SHA_DIGEST_LENGTH; if (MGF1(seed, SHA_DIGEST_LENGTH, maskeddb, dblen)) return -1; for (i = 0; i < SHA_DIGEST_LENGTH; i++) seed[i] ^= padded_from[i]; if (MGF1(db, dblen, seed, SHA_DIGEST_LENGTH)) return -1; for (i = 0; i < dblen; i++) db[i] ^= maskeddb[i]; if (!EVP_Digest((void *)param, plen, phash, NULL, EVP_sha1(), NULL)) return -1; if (CRYPTO_memcmp(db, phash, SHA_DIGEST_LENGTH) != 0 || bad) goto decoding_err; else { for (i = SHA_DIGEST_LENGTH; i < dblen; i++) if (db[i] != 0x00) break; if (i == dblen || db[i] != 0x01) goto decoding_err; else { /* everything looks OK */ mlen = dblen - ++i; if (tlen < mlen) { RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_DATA_TOO_LARGE); mlen = -1; } else memcpy(to, db + i, mlen); } } free(db); return mlen; decoding_err: /* * To avoid chosen ciphertext attacks, the error message should not * reveal which kind of decoding error happened */ RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_OAEP_DECODING_ERROR); free(db); return -1; } int PKCS1_MGF1(unsigned char *mask, long len, const unsigned char *seed, long seedlen, const EVP_MD *dgst) { long i, outlen = 0; unsigned char cnt[4]; EVP_MD_CTX c; unsigned char md[EVP_MAX_MD_SIZE]; int mdlen; int rv = -1; EVP_MD_CTX_init(&c); mdlen = EVP_MD_size(dgst); if (mdlen < 0) goto err; for (i = 0; outlen < len; i++) { cnt[0] = (unsigned char)((i >> 24) & 255); cnt[1] = (unsigned char)((i >> 16) & 255); cnt[2] = (unsigned char)((i >> 8)) & 255; cnt[3] = (unsigned char)(i & 255); if (!EVP_DigestInit_ex(&c, dgst, NULL) || !EVP_DigestUpdate(&c, seed, seedlen) || !EVP_DigestUpdate(&c, cnt, 4)) goto err; if (outlen + mdlen <= len) { if (!EVP_DigestFinal_ex(&c, mask + outlen, NULL)) goto err; outlen += mdlen; } else { if (!EVP_DigestFinal_ex(&c, md, NULL)) goto err; memcpy(mask + outlen, md, len - outlen); outlen = len; } } rv = 0; err: EVP_MD_CTX_cleanup(&c); return rv; } static int MGF1(unsigned char *mask, long len, const unsigned char *seed, long seedlen) { return PKCS1_MGF1(mask, len, seed, seedlen, EVP_sha1()); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_gen.c0000644000175000017500000001674412360020706020637 0ustar /* $OpenBSD: rsa_gen.c,v 1.15 2014/07/09 19:51:38 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* NB: these functions have been "upgraded", the deprecated versions (which are * compatibility wrappers using these functions) are in rsa_depr.c. * - Geoff */ #include #include #include #include #include static int rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb); /* * NB: this wrapper would normally be placed in rsa_lib.c and the static * implementation would probably be in rsa_eay.c. Nonetheless, is kept here so * that we don't introduce a new linker dependency. Eg. any application that * wasn't previously linking object code related to key-generation won't have to * now just because key-generation is part of RSA_METHOD. */ int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb) { if (rsa->meth->rsa_keygen) return rsa->meth->rsa_keygen(rsa, bits, e_value, cb); return rsa_builtin_keygen(rsa, bits, e_value, cb); } static int rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb) { BIGNUM *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *tmp; BIGNUM local_r0, local_d, local_p; BIGNUM *pr0, *d, *p; int bitsp, bitsq, ok = -1, n = 0; BN_CTX *ctx = NULL; ctx = BN_CTX_new(); if (ctx == NULL) goto err; BN_CTX_start(ctx); r0 = BN_CTX_get(ctx); r1 = BN_CTX_get(ctx); r2 = BN_CTX_get(ctx); r3 = BN_CTX_get(ctx); if (r3 == NULL) goto err; bitsp = (bits + 1) / 2; bitsq = bits - bitsp; /* We need the RSA components non-NULL */ if (!rsa->n && ((rsa->n = BN_new()) == NULL)) goto err; if (!rsa->d && ((rsa->d = BN_new()) == NULL)) goto err; if (!rsa->e && ((rsa->e = BN_new()) == NULL)) goto err; if (!rsa->p && ((rsa->p = BN_new()) == NULL)) goto err; if (!rsa->q && ((rsa->q = BN_new()) == NULL)) goto err; if (!rsa->dmp1 && ((rsa->dmp1 = BN_new()) == NULL)) goto err; if (!rsa->dmq1 && ((rsa->dmq1 = BN_new()) == NULL)) goto err; if (!rsa->iqmp && ((rsa->iqmp = BN_new()) == NULL)) goto err; BN_copy(rsa->e, e_value); /* generate p and q */ for (;;) { if (!BN_generate_prime_ex(rsa->p, bitsp, 0, NULL, NULL, cb)) goto err; if (!BN_sub(r2, rsa->p, BN_value_one())) goto err; if (!BN_gcd(r1, r2, rsa->e, ctx)) goto err; if (BN_is_one(r1)) break; if (!BN_GENCB_call(cb, 2, n++)) goto err; } if (!BN_GENCB_call(cb, 3, 0)) goto err; for (;;) { /* * When generating ridiculously small keys, we can get stuck * continually regenerating the same prime values. Check for * this and bail if it happens 3 times. */ unsigned int degenerate = 0; do { if (!BN_generate_prime_ex(rsa->q, bitsq, 0, NULL, NULL, cb)) goto err; } while (BN_cmp(rsa->p, rsa->q) == 0 && ++degenerate < 3); if (degenerate == 3) { ok = 0; /* we set our own err */ RSAerr(RSA_F_RSA_BUILTIN_KEYGEN, RSA_R_KEY_SIZE_TOO_SMALL); goto err; } if (!BN_sub(r2, rsa->q, BN_value_one())) goto err; if (!BN_gcd(r1, r2, rsa->e, ctx)) goto err; if (BN_is_one(r1)) break; if (!BN_GENCB_call(cb, 2, n++)) goto err; } if (!BN_GENCB_call(cb, 3, 1)) goto err; if (BN_cmp(rsa->p, rsa->q) < 0) { tmp = rsa->p; rsa->p = rsa->q; rsa->q = tmp; } /* calculate n */ if (!BN_mul(rsa->n, rsa->p, rsa->q, ctx)) goto err; /* calculate d */ if (!BN_sub(r1, rsa->p, BN_value_one())) /* p-1 */ goto err; if (!BN_sub(r2, rsa->q, BN_value_one())) /* q-1 */ goto err; if (!BN_mul(r0, r1, r2, ctx)) /* (p-1)(q-1) */ goto err; if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { pr0 = &local_r0; BN_with_flags(pr0, r0, BN_FLG_CONSTTIME); } else pr0 = r0; if (!BN_mod_inverse(rsa->d, rsa->e, pr0, ctx)) /* d */ goto err; /* set up d for correct BN_FLG_CONSTTIME flag */ if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { d = &local_d; BN_with_flags(d, rsa->d, BN_FLG_CONSTTIME); } else d = rsa->d; /* calculate d mod (p-1) */ if (!BN_mod(rsa->dmp1, d, r1, ctx)) goto err; /* calculate d mod (q-1) */ if (!BN_mod(rsa->dmq1, d, r2, ctx)) goto err; /* calculate inverse of q mod p */ if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { p = &local_p; BN_with_flags(p, rsa->p, BN_FLG_CONSTTIME); } else p = rsa->p; if (!BN_mod_inverse(rsa->iqmp, rsa->q, p, ctx)) goto err; ok = 1; err: if (ok == -1) { RSAerr(RSA_F_RSA_BUILTIN_KEYGEN, ERR_LIB_BN); ok = 0; } if (ctx != NULL) { BN_CTX_end(ctx); BN_CTX_free(ctx); } return ok; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_none.c0000644000175000017500000000767312360020706021026 0ustar /* $OpenBSD: rsa_none.c,v 1.8 2014/07/10 13:58:23 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include int RSA_padding_add_none(unsigned char *to, int tlen, const unsigned char *from, int flen) { if (flen > tlen) { RSAerr(RSA_F_RSA_PADDING_ADD_NONE, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); return 0; } if (flen < tlen) { RSAerr(RSA_F_RSA_PADDING_ADD_NONE, RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE); return 0; } memcpy(to, from, flen); return 1; } int RSA_padding_check_none(unsigned char *to, int tlen, const unsigned char *from, int flen, int num) { if (flen > tlen) { RSAerr(RSA_F_RSA_PADDING_CHECK_NONE, RSA_R_DATA_TOO_LARGE); return -1; } memset(to, 0, tlen - flen); memcpy(to + tlen - flen, from, flen); return tlen; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_ameth.c0000644000175000017500000004055212360020706021156 0ustar /* $OpenBSD: rsa_ameth.c,v 1.11 2014/07/11 08:44:49 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #ifndef OPENSSL_NO_CMS #include #endif #include "asn1_locl.h" static int rsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) { unsigned char *penc = NULL; int penclen; penclen = i2d_RSAPublicKey(pkey->pkey.rsa, &penc); if (penclen <= 0) return 0; if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_RSA), V_ASN1_NULL, NULL, penc, penclen)) return 1; free(penc); return 0; } static int rsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) { const unsigned char *p; int pklen; RSA *rsa = NULL; if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, NULL, pubkey)) return 0; if (!(rsa = d2i_RSAPublicKey(NULL, &p, pklen))) { RSAerr(RSA_F_RSA_PUB_DECODE, ERR_R_RSA_LIB); return 0; } EVP_PKEY_assign_RSA (pkey, rsa); return 1; } static int rsa_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b) { if (BN_cmp(b->pkey.rsa->n, a->pkey.rsa->n) != 0 || BN_cmp(b->pkey.rsa->e, a->pkey.rsa->e) != 0) return 0; return 1; } static int old_rsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) { RSA *rsa; if (!(rsa = d2i_RSAPrivateKey (NULL, pder, derlen))) { RSAerr(RSA_F_OLD_RSA_PRIV_DECODE, ERR_R_RSA_LIB); return 0; } EVP_PKEY_assign_RSA(pkey, rsa); return 1; } static int old_rsa_priv_encode(const EVP_PKEY *pkey, unsigned char **pder) { return i2d_RSAPrivateKey(pkey->pkey.rsa, pder); } static int rsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) { unsigned char *rk = NULL; int rklen; rklen = i2d_RSAPrivateKey(pkey->pkey.rsa, &rk); if (rklen <= 0) { RSAerr(RSA_F_RSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); return 0; } if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(NID_rsaEncryption), 0, V_ASN1_NULL, NULL, rk, rklen)) { RSAerr(RSA_F_RSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); return 0; } return 1; } static int rsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8) { const unsigned char *p; int pklen; if (!PKCS8_pkey_get0(NULL, &p, &pklen, NULL, p8)) return 0; return old_rsa_priv_decode(pkey, &p, pklen); } static int int_rsa_size(const EVP_PKEY *pkey) { return RSA_size(pkey->pkey.rsa); } static int rsa_bits(const EVP_PKEY *pkey) { return BN_num_bits(pkey->pkey.rsa->n); } static void int_rsa_free(EVP_PKEY *pkey) { RSA_free(pkey->pkey.rsa); } static void update_buflen(const BIGNUM *b, size_t *pbuflen) { size_t i; if (!b) return; if (*pbuflen < (i = (size_t)BN_num_bytes(b))) *pbuflen = i; } static int do_rsa_print(BIO *bp, const RSA *x, int off, int priv) { char *str; const char *s; unsigned char *m = NULL; int ret = 0, mod_len = 0; size_t buf_len = 0; update_buflen(x->n, &buf_len); update_buflen(x->e, &buf_len); if (priv) { update_buflen(x->d, &buf_len); update_buflen(x->p, &buf_len); update_buflen(x->q, &buf_len); update_buflen(x->dmp1, &buf_len); update_buflen(x->dmq1, &buf_len); update_buflen(x->iqmp, &buf_len); } m = malloc(buf_len + 10); if (m == NULL) { RSAerr(RSA_F_DO_RSA_PRINT, ERR_R_MALLOC_FAILURE); goto err; } if (x->n != NULL) mod_len = BN_num_bits(x->n); if (!BIO_indent(bp, off, 128)) goto err; if (priv && x->d) { if (BIO_printf(bp, "Private-Key: (%d bit)\n", mod_len) <= 0) goto err; str = "modulus:"; s = "publicExponent:"; } else { if (BIO_printf(bp, "Public-Key: (%d bit)\n", mod_len) <= 0) goto err; str = "Modulus:"; s= "Exponent:"; } if (!ASN1_bn_print(bp, str, x->n, m, off)) goto err; if (!ASN1_bn_print(bp, s, x->e, m, off)) goto err; if (priv) { if (!ASN1_bn_print(bp, "privateExponent:", x->d,m, off)) goto err; if (!ASN1_bn_print(bp, "prime1:", x->p, m, off)) goto err; if (!ASN1_bn_print(bp, "prime2:", x->q, m, off)) goto err; if (!ASN1_bn_print(bp, "exponent1:", x->dmp1, m, off)) goto err; if (!ASN1_bn_print(bp, "exponent2:", x->dmq1, m, off)) goto err; if (!ASN1_bn_print(bp, "coefficient:", x->iqmp, m, off)) goto err; } ret = 1; err: free(m); return (ret); } static int rsa_pub_print(BIO *bp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx) { return do_rsa_print(bp, pkey->pkey.rsa, indent, 0); } static int rsa_priv_print(BIO *bp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx) { return do_rsa_print(bp, pkey->pkey.rsa, indent, 1); } static RSA_PSS_PARAMS * rsa_pss_decode(const X509_ALGOR *alg, X509_ALGOR **pmaskHash) { const unsigned char *p; int plen; RSA_PSS_PARAMS *pss; *pmaskHash = NULL; if (!alg->parameter || alg->parameter->type != V_ASN1_SEQUENCE) return NULL; p = alg->parameter->value.sequence->data; plen = alg->parameter->value.sequence->length; pss = d2i_RSA_PSS_PARAMS(NULL, &p, plen); if (!pss) return NULL; if (pss->maskGenAlgorithm) { ASN1_TYPE *param = pss->maskGenAlgorithm->parameter; if (OBJ_obj2nid(pss->maskGenAlgorithm->algorithm) == NID_mgf1 && param->type == V_ASN1_SEQUENCE) { p = param->value.sequence->data; plen = param->value.sequence->length; *pmaskHash = d2i_X509_ALGOR(NULL, &p, plen); } } return pss; } static int rsa_pss_param_print(BIO *bp, RSA_PSS_PARAMS *pss, X509_ALGOR *maskHash, int indent) { int rv = 0; if (!pss) { if (BIO_puts(bp, " (INVALID PSS PARAMETERS)\n") <= 0) return 0; return 1; } if (BIO_puts(bp, "\n") <= 0) goto err; if (!BIO_indent(bp, indent, 128)) goto err; if (BIO_puts(bp, "Hash Algorithm: ") <= 0) goto err; if (pss->hashAlgorithm) { if (i2a_ASN1_OBJECT(bp, pss->hashAlgorithm->algorithm) <= 0) goto err; } else if (BIO_puts(bp, "sha1 (default)") <= 0) goto err; if (BIO_puts(bp, "\n") <= 0) goto err; if (!BIO_indent(bp, indent, 128)) goto err; if (BIO_puts(bp, "Mask Algorithm: ") <= 0) goto err; if (pss->maskGenAlgorithm) { if (i2a_ASN1_OBJECT(bp, pss->maskGenAlgorithm->algorithm) <= 0) goto err; if (BIO_puts(bp, " with ") <= 0) goto err; if (maskHash) { if (i2a_ASN1_OBJECT(bp, maskHash->algorithm) <= 0) goto err; } else if (BIO_puts(bp, "INVALID") <= 0) goto err; } else if (BIO_puts(bp, "mgf1 with sha1 (default)") <= 0) goto err; BIO_puts(bp, "\n"); if (!BIO_indent(bp, indent, 128)) goto err; if (BIO_puts(bp, "Salt Length: 0x") <= 0) goto err; if (pss->saltLength) { if (i2a_ASN1_INTEGER(bp, pss->saltLength) <= 0) goto err; } else if (BIO_puts(bp, "14 (default)") <= 0) goto err; BIO_puts(bp, "\n"); if (!BIO_indent(bp, indent, 128)) goto err; if (BIO_puts(bp, "Trailer Field: 0x") <= 0) goto err; if (pss->trailerField) { if (i2a_ASN1_INTEGER(bp, pss->trailerField) <= 0) goto err; } else if (BIO_puts(bp, "BC (default)") <= 0) goto err; BIO_puts(bp, "\n"); rv = 1; err: return rv; } static int rsa_sig_print(BIO *bp, const X509_ALGOR *sigalg, const ASN1_STRING *sig, int indent, ASN1_PCTX *pctx) { if (OBJ_obj2nid(sigalg->algorithm) == NID_rsassaPss) { int rv; RSA_PSS_PARAMS *pss; X509_ALGOR *maskHash; pss = rsa_pss_decode(sigalg, &maskHash); rv = rsa_pss_param_print(bp, pss, maskHash, indent); if (pss) RSA_PSS_PARAMS_free(pss); if (maskHash) X509_ALGOR_free(maskHash); if (!rv) return 0; } else if (!sig && BIO_puts(bp, "\n") <= 0) return 0; if (sig) return X509_signature_dump(bp, sig, indent); return 1; } static int rsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) { X509_ALGOR *alg = NULL; switch (op) { case ASN1_PKEY_CTRL_PKCS7_SIGN: if (arg1 == 0) PKCS7_SIGNER_INFO_get0_algs(arg2, NULL, NULL, &alg); break; case ASN1_PKEY_CTRL_PKCS7_ENCRYPT: if (arg1 == 0) PKCS7_RECIP_INFO_get0_alg(arg2, &alg); break; #ifndef OPENSSL_NO_CMS case ASN1_PKEY_CTRL_CMS_SIGN: if (arg1 == 0) CMS_SignerInfo_get0_algs(arg2, NULL, NULL, NULL, &alg); break; case ASN1_PKEY_CTRL_CMS_ENVELOPE: if (arg1 == 0) CMS_RecipientInfo_ktri_get0_algs(arg2, NULL, NULL, &alg); break; #endif case ASN1_PKEY_CTRL_DEFAULT_MD_NID: *(int *)arg2 = NID_sha1; return 1; default: return -2; } if (alg) X509_ALGOR_set0(alg, OBJ_nid2obj(NID_rsaEncryption), V_ASN1_NULL, 0); return 1; } /* Customised RSA item verification routine. This is called * when a signature is encountered requiring special handling. We * currently only handle PSS. */ static int rsa_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, X509_ALGOR *sigalg, ASN1_BIT_STRING *sig, EVP_PKEY *pkey) { int rv = -1; int saltlen; const EVP_MD *mgf1md = NULL, *md = NULL; RSA_PSS_PARAMS *pss; X509_ALGOR *maskHash; EVP_PKEY_CTX *pkctx; /* Sanity check: make sure it is PSS */ if (OBJ_obj2nid(sigalg->algorithm) != NID_rsassaPss) { RSAerr(RSA_F_RSA_ITEM_VERIFY, RSA_R_UNSUPPORTED_SIGNATURE_TYPE); return -1; } /* Decode PSS parameters */ pss = rsa_pss_decode(sigalg, &maskHash); if (pss == NULL) { RSAerr(RSA_F_RSA_ITEM_VERIFY, RSA_R_INVALID_PSS_PARAMETERS); goto err; } /* Check mask and lookup mask hash algorithm */ if (pss->maskGenAlgorithm) { if (OBJ_obj2nid(pss->maskGenAlgorithm->algorithm) != NID_mgf1) { RSAerr(RSA_F_RSA_ITEM_VERIFY, RSA_R_UNSUPPORTED_MASK_ALGORITHM); goto err; } if (!maskHash) { RSAerr(RSA_F_RSA_ITEM_VERIFY, RSA_R_UNSUPPORTED_MASK_PARAMETER); goto err; } mgf1md = EVP_get_digestbyobj(maskHash->algorithm); if (mgf1md == NULL) { RSAerr(RSA_F_RSA_ITEM_VERIFY, RSA_R_UNKNOWN_MASK_DIGEST); goto err; } } else mgf1md = EVP_sha1(); if (pss->hashAlgorithm) { md = EVP_get_digestbyobj(pss->hashAlgorithm->algorithm); if (md == NULL) { RSAerr(RSA_F_RSA_ITEM_VERIFY, RSA_R_UNKNOWN_PSS_DIGEST); goto err; } } else md = EVP_sha1(); if (pss->saltLength) { saltlen = ASN1_INTEGER_get(pss->saltLength); /* Could perform more salt length sanity checks but the main * RSA routines will trap other invalid values anyway. */ if (saltlen < 0) { RSAerr(RSA_F_RSA_ITEM_VERIFY, RSA_R_INVALID_SALT_LENGTH); goto err; } } else saltlen = 20; /* low-level routines support only trailer field 0xbc (value 1) * and PKCS#1 says we should reject any other value anyway. */ if (pss->trailerField && ASN1_INTEGER_get(pss->trailerField) != 1) { RSAerr(RSA_F_RSA_ITEM_VERIFY, RSA_R_INVALID_TRAILER); goto err; } /* We have all parameters now set up context */ if (!EVP_DigestVerifyInit(ctx, &pkctx, md, NULL, pkey)) goto err; if (EVP_PKEY_CTX_set_rsa_padding(pkctx, RSA_PKCS1_PSS_PADDING) <= 0) goto err; if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkctx, saltlen) <= 0) goto err; if (EVP_PKEY_CTX_set_rsa_mgf1_md(pkctx, mgf1md) <= 0) goto err; /* Carry on */ rv = 2; err: RSA_PSS_PARAMS_free(pss); if (maskHash) X509_ALGOR_free(maskHash); return rv; } static int rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, X509_ALGOR *alg1, X509_ALGOR *alg2, ASN1_BIT_STRING *sig) { int pad_mode; EVP_PKEY_CTX *pkctx = ctx->pctx; if (EVP_PKEY_CTX_get_rsa_padding(pkctx, &pad_mode) <= 0) return 0; if (pad_mode == RSA_PKCS1_PADDING) return 2; if (pad_mode == RSA_PKCS1_PSS_PADDING) { const EVP_MD *sigmd, *mgf1md; RSA_PSS_PARAMS *pss = NULL; X509_ALGOR *mgf1alg = NULL; ASN1_STRING *os1 = NULL, *os2 = NULL; EVP_PKEY *pk = EVP_PKEY_CTX_get0_pkey(pkctx); int saltlen, rv = 0; sigmd = EVP_MD_CTX_md(ctx); if (EVP_PKEY_CTX_get_rsa_mgf1_md(pkctx, &mgf1md) <= 0) goto err; if (!EVP_PKEY_CTX_get_rsa_pss_saltlen(pkctx, &saltlen)) goto err; if (saltlen == -1) saltlen = EVP_MD_size(sigmd); else if (saltlen == -2) { saltlen = EVP_PKEY_size(pk) - EVP_MD_size(sigmd) - 2; if (((EVP_PKEY_bits(pk) - 1) & 0x7) == 0) saltlen--; } pss = RSA_PSS_PARAMS_new(); if (!pss) goto err; if (saltlen != 20) { pss->saltLength = ASN1_INTEGER_new(); if (!pss->saltLength) goto err; if (!ASN1_INTEGER_set(pss->saltLength, saltlen)) goto err; } if (EVP_MD_type(sigmd) != NID_sha1) { pss->hashAlgorithm = X509_ALGOR_new(); if (!pss->hashAlgorithm) goto err; X509_ALGOR_set_md(pss->hashAlgorithm, sigmd); } if (EVP_MD_type(mgf1md) != NID_sha1) { ASN1_STRING *stmp = NULL; /* need to embed algorithm ID inside another */ mgf1alg = X509_ALGOR_new(); X509_ALGOR_set_md(mgf1alg, mgf1md); if (!ASN1_item_pack(mgf1alg, ASN1_ITEM_rptr(X509_ALGOR), &stmp)) goto err; pss->maskGenAlgorithm = X509_ALGOR_new(); if (!pss->maskGenAlgorithm) goto err; X509_ALGOR_set0(pss->maskGenAlgorithm, OBJ_nid2obj(NID_mgf1), V_ASN1_SEQUENCE, stmp); } /* Finally create string with pss parameter encoding. */ if (!ASN1_item_pack(pss, ASN1_ITEM_rptr(RSA_PSS_PARAMS), &os1)) goto err; if (alg2) { os2 = ASN1_STRING_dup(os1); if (!os2) goto err; X509_ALGOR_set0(alg2, OBJ_nid2obj(NID_rsassaPss), V_ASN1_SEQUENCE, os2); } X509_ALGOR_set0(alg1, OBJ_nid2obj(NID_rsassaPss), V_ASN1_SEQUENCE, os1); os1 = os2 = NULL; rv = 3; err: if (mgf1alg) X509_ALGOR_free(mgf1alg); if (pss) RSA_PSS_PARAMS_free(pss); ASN1_STRING_free(os1); return rv; } return 2; } const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[] = { { .pkey_id = EVP_PKEY_RSA, .pkey_base_id = EVP_PKEY_RSA, .pkey_flags = ASN1_PKEY_SIGPARAM_NULL, .pem_str = "RSA", .info = "OpenSSL RSA method", .pub_decode = rsa_pub_decode, .pub_encode = rsa_pub_encode, .pub_cmp = rsa_pub_cmp, .pub_print = rsa_pub_print, .priv_decode = rsa_priv_decode, .priv_encode = rsa_priv_encode, .priv_print = rsa_priv_print, .pkey_size = int_rsa_size, .pkey_bits = rsa_bits, .sig_print = rsa_sig_print, .pkey_free = int_rsa_free, .pkey_ctrl = rsa_pkey_ctrl, .old_priv_decode = old_rsa_priv_decode, .old_priv_encode = old_rsa_priv_encode, .item_verify = rsa_item_verify, .item_sign = rsa_item_sign }, { .pkey_id = EVP_PKEY_RSA2, .pkey_base_id = EVP_PKEY_RSA, .pkey_flags = ASN1_PKEY_ALIAS } }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_eay.c0000644000175000017500000006134512360020706020641 0ustar /* $OpenBSD: rsa_eay.c,v 1.34 2014/07/11 08:44:49 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include static int RSA_eay_public_encrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding); static int RSA_eay_private_encrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding); static int RSA_eay_public_decrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding); static int RSA_eay_private_decrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding); static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *i, RSA *rsa, BN_CTX *ctx); static int RSA_eay_init(RSA *rsa); static int RSA_eay_finish(RSA *rsa); static RSA_METHOD rsa_pkcs1_eay_meth = { .name = "Eric Young's PKCS#1 RSA", .rsa_pub_enc = RSA_eay_public_encrypt, .rsa_pub_dec = RSA_eay_public_decrypt, /* signature verification */ .rsa_priv_enc = RSA_eay_private_encrypt, /* signing */ .rsa_priv_dec = RSA_eay_private_decrypt, .rsa_mod_exp = RSA_eay_mod_exp, .bn_mod_exp = BN_mod_exp_mont, /* XXX probably we should not use Montgomery if e == 3 */ .init = RSA_eay_init, .finish = RSA_eay_finish, }; const RSA_METHOD * RSA_PKCS1_SSLeay(void) { return &rsa_pkcs1_eay_meth; } static int RSA_eay_public_encrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding) { BIGNUM *f, *ret; int i, j, k, num = 0, r = -1; unsigned char *buf = NULL; BN_CTX *ctx = NULL; if (BN_num_bits(rsa->n) > OPENSSL_RSA_MAX_MODULUS_BITS) { RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_MODULUS_TOO_LARGE); return -1; } if (BN_ucmp(rsa->n, rsa->e) <= 0) { RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_BAD_E_VALUE); return -1; } /* for large moduli, enforce exponent limit */ if (BN_num_bits(rsa->n) > OPENSSL_RSA_SMALL_MODULUS_BITS) { if (BN_num_bits(rsa->e) > OPENSSL_RSA_MAX_PUBEXP_BITS) { RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_BAD_E_VALUE); return -1; } } if ((ctx = BN_CTX_new()) == NULL) goto err; BN_CTX_start(ctx); f = BN_CTX_get(ctx); ret = BN_CTX_get(ctx); num = BN_num_bytes(rsa->n); buf = malloc(num); if (!f || !ret || !buf) { RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, ERR_R_MALLOC_FAILURE); goto err; } switch (padding) { case RSA_PKCS1_PADDING: i = RSA_padding_add_PKCS1_type_2(buf, num, from, flen); break; #ifndef OPENSSL_NO_SHA case RSA_PKCS1_OAEP_PADDING: i = RSA_padding_add_PKCS1_OAEP(buf, num, from, flen, NULL, 0); break; #endif case RSA_SSLV23_PADDING: i = RSA_padding_add_SSLv23(buf, num, from, flen); break; case RSA_NO_PADDING: i = RSA_padding_add_none(buf, num, from, flen); break; default: RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_UNKNOWN_PADDING_TYPE); goto err; } if (i <= 0) goto err; if (BN_bin2bn(buf, num, f) == NULL) goto err; if (BN_ucmp(f, rsa->n) >= 0) { /* usually the padding functions would catch this */ RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_DATA_TOO_LARGE_FOR_MODULUS); goto err; } if (rsa->flags & RSA_FLAG_CACHE_PUBLIC) if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_n, CRYPTO_LOCK_RSA, rsa->n, ctx)) goto err; if (!rsa->meth->bn_mod_exp(ret, f,rsa->e, rsa->n, ctx, rsa->_method_mod_n)) goto err; /* put in leading 0 bytes if the number is less than the * length of the modulus */ j = BN_num_bytes(ret); i = BN_bn2bin(ret, &(to[num - j])); for (k = 0; k < num - i; k++) to[k] = 0; r = num; err: if (ctx != NULL) { BN_CTX_end(ctx); BN_CTX_free(ctx); } if (buf != NULL) { OPENSSL_cleanse(buf, num); free(buf); } return r; } static BN_BLINDING * rsa_get_blinding(RSA *rsa, int *local, BN_CTX *ctx) { BN_BLINDING *ret; int got_write_lock = 0; CRYPTO_THREADID cur; CRYPTO_r_lock(CRYPTO_LOCK_RSA); if (rsa->blinding == NULL) { CRYPTO_r_unlock(CRYPTO_LOCK_RSA); CRYPTO_w_lock(CRYPTO_LOCK_RSA); got_write_lock = 1; if (rsa->blinding == NULL) rsa->blinding = RSA_setup_blinding(rsa, ctx); } ret = rsa->blinding; if (ret == NULL) goto err; CRYPTO_THREADID_current(&cur); if (!CRYPTO_THREADID_cmp(&cur, BN_BLINDING_thread_id(ret))) { /* rsa->blinding is ours! */ *local = 1; } else { /* resort to rsa->mt_blinding instead */ /* * Instruct rsa_blinding_convert(), rsa_blinding_invert() * that the BN_BLINDING is shared, meaning that accesses * require locks, and that the blinding factor must be * stored outside the BN_BLINDING */ *local = 0; if (rsa->mt_blinding == NULL) { if (!got_write_lock) { CRYPTO_r_unlock(CRYPTO_LOCK_RSA); CRYPTO_w_lock(CRYPTO_LOCK_RSA); got_write_lock = 1; } if (rsa->mt_blinding == NULL) rsa->mt_blinding = RSA_setup_blinding(rsa, ctx); } ret = rsa->mt_blinding; } err: if (got_write_lock) CRYPTO_w_unlock(CRYPTO_LOCK_RSA); else CRYPTO_r_unlock(CRYPTO_LOCK_RSA); return ret; } static int rsa_blinding_convert(BN_BLINDING *b, BIGNUM *f, BIGNUM *unblind, BN_CTX *ctx) { if (unblind == NULL) /* * Local blinding: store the unblinding factor * in BN_BLINDING. */ return BN_BLINDING_convert_ex(f, NULL, b, ctx); else { /* * Shared blinding: store the unblinding factor * outside BN_BLINDING. */ int ret; CRYPTO_w_lock(CRYPTO_LOCK_RSA_BLINDING); ret = BN_BLINDING_convert_ex(f, unblind, b, ctx); CRYPTO_w_unlock(CRYPTO_LOCK_RSA_BLINDING); return ret; } } static int rsa_blinding_invert(BN_BLINDING *b, BIGNUM *f, BIGNUM *unblind, BN_CTX *ctx) { /* * For local blinding, unblind is set to NULL, and BN_BLINDING_invert_ex * will use the unblinding factor stored in BN_BLINDING. * If BN_BLINDING is shared between threads, unblind must be non-null: * BN_BLINDING_invert_ex will then use the local unblinding factor, * and will only read the modulus from BN_BLINDING. * In both cases it's safe to access the blinding without a lock. */ return BN_BLINDING_invert_ex(f, unblind, b, ctx); } /* signing */ static int RSA_eay_private_encrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding) { BIGNUM *f, *ret, *res; int i, j, k, num = 0, r = -1; unsigned char *buf = NULL; BN_CTX *ctx = NULL; int local_blinding = 0; /* * Used only if the blinding structure is shared. A non-NULL unblind * instructs rsa_blinding_convert() and rsa_blinding_invert() to store * the unblinding factor outside the blinding structure. */ BIGNUM *unblind = NULL; BN_BLINDING *blinding = NULL; if ((ctx = BN_CTX_new()) == NULL) goto err; BN_CTX_start(ctx); f = BN_CTX_get(ctx); ret = BN_CTX_get(ctx); num = BN_num_bytes(rsa->n); buf = malloc(num); if (!f || !ret || !buf) { RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT, ERR_R_MALLOC_FAILURE); goto err; } switch (padding) { case RSA_PKCS1_PADDING: i = RSA_padding_add_PKCS1_type_1(buf, num, from, flen); break; case RSA_X931_PADDING: i = RSA_padding_add_X931(buf, num, from, flen); break; case RSA_NO_PADDING: i = RSA_padding_add_none(buf, num, from, flen); break; case RSA_SSLV23_PADDING: default: RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT, RSA_R_UNKNOWN_PADDING_TYPE); goto err; } if (i <= 0) goto err; if (BN_bin2bn(buf, num, f) == NULL) goto err; if (BN_ucmp(f, rsa->n) >= 0) { /* usually the padding functions would catch this */ RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT, RSA_R_DATA_TOO_LARGE_FOR_MODULUS); goto err; } if (!(rsa->flags & RSA_FLAG_NO_BLINDING)) { blinding = rsa_get_blinding(rsa, &local_blinding, ctx); if (blinding == NULL) { RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT, ERR_R_INTERNAL_ERROR); goto err; } } if (blinding != NULL) { if (!local_blinding && ((unblind = BN_CTX_get(ctx)) == NULL)) { RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT, ERR_R_MALLOC_FAILURE); goto err; } if (!rsa_blinding_convert(blinding, f, unblind, ctx)) goto err; } if ((rsa->flags & RSA_FLAG_EXT_PKEY) || (rsa->p != NULL && rsa->q != NULL && rsa->dmp1 != NULL && rsa->dmq1 != NULL && rsa->iqmp != NULL)) { if (!rsa->meth->rsa_mod_exp(ret, f, rsa, ctx)) goto err; } else { BIGNUM local_d; BIGNUM *d = NULL; if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { BN_init(&local_d); d = &local_d; BN_with_flags(d, rsa->d, BN_FLG_CONSTTIME); } else d = rsa->d; if (rsa->flags & RSA_FLAG_CACHE_PUBLIC) if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_n, CRYPTO_LOCK_RSA, rsa->n, ctx)) goto err; if (!rsa->meth->bn_mod_exp(ret, f, d, rsa->n, ctx, rsa->_method_mod_n)) goto err; } if (blinding) if (!rsa_blinding_invert(blinding, ret, unblind, ctx)) goto err; if (padding == RSA_X931_PADDING) { BN_sub(f, rsa->n, ret); if (BN_cmp(ret, f) > 0) res = f; else res = ret; } else res = ret; /* put in leading 0 bytes if the number is less than the * length of the modulus */ j = BN_num_bytes(res); i = BN_bn2bin(res, &(to[num - j])); for (k = 0; k < num - i; k++) to[k] = 0; r = num; err: if (ctx != NULL) { BN_CTX_end(ctx); BN_CTX_free(ctx); } if (buf != NULL) { OPENSSL_cleanse(buf, num); free(buf); } return r; } static int RSA_eay_private_decrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding) { BIGNUM *f, *ret; int j, num = 0, r = -1; unsigned char *p; unsigned char *buf = NULL; BN_CTX *ctx = NULL; int local_blinding = 0; /* * Used only if the blinding structure is shared. A non-NULL unblind * instructs rsa_blinding_convert() and rsa_blinding_invert() to store * the unblinding factor outside the blinding structure. */ BIGNUM *unblind = NULL; BN_BLINDING *blinding = NULL; if ((ctx = BN_CTX_new()) == NULL) goto err; BN_CTX_start(ctx); f = BN_CTX_get(ctx); ret = BN_CTX_get(ctx); num = BN_num_bytes(rsa->n); buf = malloc(num); if (!f || !ret || !buf) { RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, ERR_R_MALLOC_FAILURE); goto err; } /* This check was for equality but PGP does evil things * and chops off the top '0' bytes */ if (flen > num) { RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, RSA_R_DATA_GREATER_THAN_MOD_LEN); goto err; } /* make data into a big number */ if (BN_bin2bn(from, (int)flen, f) == NULL) goto err; if (BN_ucmp(f, rsa->n) >= 0) { RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, RSA_R_DATA_TOO_LARGE_FOR_MODULUS); goto err; } if (!(rsa->flags & RSA_FLAG_NO_BLINDING)) { blinding = rsa_get_blinding(rsa, &local_blinding, ctx); if (blinding == NULL) { RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, ERR_R_INTERNAL_ERROR); goto err; } } if (blinding != NULL) { if (!local_blinding && ((unblind = BN_CTX_get(ctx)) == NULL)) { RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, ERR_R_MALLOC_FAILURE); goto err; } if (!rsa_blinding_convert(blinding, f, unblind, ctx)) goto err; } /* do the decrypt */ if ((rsa->flags & RSA_FLAG_EXT_PKEY) || (rsa->p != NULL && rsa->q != NULL && rsa->dmp1 != NULL && rsa->dmq1 != NULL && rsa->iqmp != NULL)) { if (!rsa->meth->rsa_mod_exp(ret, f, rsa, ctx)) goto err; } else { BIGNUM local_d; BIGNUM *d = NULL; if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { d = &local_d; BN_with_flags(d, rsa->d, BN_FLG_CONSTTIME); } else d = rsa->d; if (rsa->flags & RSA_FLAG_CACHE_PUBLIC) if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_n, CRYPTO_LOCK_RSA, rsa->n, ctx)) goto err; if (!rsa->meth->bn_mod_exp(ret, f, d, rsa->n, ctx, rsa->_method_mod_n)) goto err; } if (blinding) if (!rsa_blinding_invert(blinding, ret, unblind, ctx)) goto err; p = buf; j = BN_bn2bin(ret, p); /* j is only used with no-padding mode */ switch (padding) { case RSA_PKCS1_PADDING: r = RSA_padding_check_PKCS1_type_2(to, num, buf, j, num); break; #ifndef OPENSSL_NO_SHA case RSA_PKCS1_OAEP_PADDING: r = RSA_padding_check_PKCS1_OAEP(to, num, buf, j, num, NULL, 0); break; #endif case RSA_SSLV23_PADDING: r = RSA_padding_check_SSLv23(to, num, buf, j, num); break; case RSA_NO_PADDING: r = RSA_padding_check_none(to, num, buf, j, num); break; default: RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, RSA_R_UNKNOWN_PADDING_TYPE); goto err; } if (r < 0) RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, RSA_R_PADDING_CHECK_FAILED); err: if (ctx != NULL) { BN_CTX_end(ctx); BN_CTX_free(ctx); } if (buf != NULL) { OPENSSL_cleanse(buf, num); free(buf); } return r; } /* signature verification */ static int RSA_eay_public_decrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding) { BIGNUM *f, *ret; int i, num = 0, r = -1; unsigned char *p; unsigned char *buf = NULL; BN_CTX *ctx = NULL; if (BN_num_bits(rsa->n) > OPENSSL_RSA_MAX_MODULUS_BITS) { RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_MODULUS_TOO_LARGE); return -1; } if (BN_ucmp(rsa->n, rsa->e) <= 0) { RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_BAD_E_VALUE); return -1; } /* for large moduli, enforce exponent limit */ if (BN_num_bits(rsa->n) > OPENSSL_RSA_SMALL_MODULUS_BITS) { if (BN_num_bits(rsa->e) > OPENSSL_RSA_MAX_PUBEXP_BITS) { RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_BAD_E_VALUE); return -1; } } if ((ctx = BN_CTX_new()) == NULL) goto err; BN_CTX_start(ctx); f = BN_CTX_get(ctx); ret = BN_CTX_get(ctx); num = BN_num_bytes(rsa->n); buf = malloc(num); if (!f || !ret || !buf) { RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, ERR_R_MALLOC_FAILURE); goto err; } /* This check was for equality but PGP does evil things * and chops off the top '0' bytes */ if (flen > num) { RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_DATA_GREATER_THAN_MOD_LEN); goto err; } if (BN_bin2bn(from, flen, f) == NULL) goto err; if (BN_ucmp(f, rsa->n) >= 0) { RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_DATA_TOO_LARGE_FOR_MODULUS); goto err; } if (rsa->flags & RSA_FLAG_CACHE_PUBLIC) if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_n, CRYPTO_LOCK_RSA, rsa->n, ctx)) goto err; if (!rsa->meth->bn_mod_exp(ret, f, rsa->e, rsa->n, ctx, rsa->_method_mod_n)) goto err; if (padding == RSA_X931_PADDING && (ret->d[0] & 0xf) != 12) if (!BN_sub(ret, rsa->n, ret)) goto err; p = buf; i = BN_bn2bin(ret, p); switch (padding) { case RSA_PKCS1_PADDING: r = RSA_padding_check_PKCS1_type_1(to, num, buf, i, num); break; case RSA_X931_PADDING: r = RSA_padding_check_X931(to, num, buf, i, num); break; case RSA_NO_PADDING: r = RSA_padding_check_none(to, num, buf, i, num); break; default: RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_UNKNOWN_PADDING_TYPE); goto err; } if (r < 0) RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_PADDING_CHECK_FAILED); err: if (ctx != NULL) { BN_CTX_end(ctx); BN_CTX_free(ctx); } if (buf != NULL) { OPENSSL_cleanse(buf, num); free(buf); } return r; } static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) { BIGNUM *r1, *m1, *vrfy; BIGNUM local_dmp1, local_dmq1, local_c, local_r1; BIGNUM *dmp1, *dmq1, *c, *pr1; int ret = 0; BN_CTX_start(ctx); r1 = BN_CTX_get(ctx); m1 = BN_CTX_get(ctx); vrfy = BN_CTX_get(ctx); { BIGNUM local_p, local_q; BIGNUM *p = NULL, *q = NULL; /* * Make sure BN_mod_inverse in Montgomery intialization uses the * BN_FLG_CONSTTIME flag (unless RSA_FLAG_NO_CONSTTIME is set) */ if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { BN_init(&local_p); p = &local_p; BN_with_flags(p, rsa->p, BN_FLG_CONSTTIME); BN_init(&local_q); q = &local_q; BN_with_flags(q, rsa->q, BN_FLG_CONSTTIME); } else { p = rsa->p; q = rsa->q; } if (rsa->flags & RSA_FLAG_CACHE_PRIVATE) { if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_p, CRYPTO_LOCK_RSA, p, ctx)) goto err; if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_q, CRYPTO_LOCK_RSA, q, ctx)) goto err; } } if (rsa->flags & RSA_FLAG_CACHE_PUBLIC) if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_n, CRYPTO_LOCK_RSA, rsa->n, ctx)) goto err; /* compute I mod q */ if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { c = &local_c; BN_with_flags(c, I, BN_FLG_CONSTTIME); if (!BN_mod(r1, c, rsa->q, ctx)) goto err; } else { if (!BN_mod(r1, I, rsa->q, ctx)) goto err; } /* compute r1^dmq1 mod q */ if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { dmq1 = &local_dmq1; BN_with_flags(dmq1, rsa->dmq1, BN_FLG_CONSTTIME); } else dmq1 = rsa->dmq1; if (!rsa->meth->bn_mod_exp(m1, r1, dmq1, rsa->q, ctx, rsa->_method_mod_q)) goto err; /* compute I mod p */ if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { c = &local_c; BN_with_flags(c, I, BN_FLG_CONSTTIME); if (!BN_mod(r1, c, rsa->p, ctx)) goto err; } else { if (!BN_mod(r1, I, rsa->p, ctx)) goto err; } /* compute r1^dmp1 mod p */ if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { dmp1 = &local_dmp1; BN_with_flags(dmp1, rsa->dmp1, BN_FLG_CONSTTIME); } else dmp1 = rsa->dmp1; if (!rsa->meth->bn_mod_exp(r0, r1, dmp1, rsa->p, ctx, rsa->_method_mod_p)) goto err; if (!BN_sub(r0, r0, m1)) goto err; /* * This will help stop the size of r0 increasing, which does * affect the multiply if it optimised for a power of 2 size */ if (BN_is_negative(r0)) if (!BN_add(r0, r0, rsa->p)) goto err; if (!BN_mul(r1, r0, rsa->iqmp, ctx)) goto err; /* Turn BN_FLG_CONSTTIME flag on before division operation */ if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { pr1 = &local_r1; BN_with_flags(pr1, r1, BN_FLG_CONSTTIME); } else pr1 = r1; if (!BN_mod(r0, pr1, rsa->p, ctx)) goto err; /* * If p < q it is occasionally possible for the correction of * adding 'p' if r0 is negative above to leave the result still * negative. This can break the private key operations: the following * second correction should *always* correct this rare occurrence. * This will *never* happen with OpenSSL generated keys because * they ensure p > q [steve] */ if (BN_is_negative(r0)) if (!BN_add(r0, r0, rsa->p)) goto err; if (!BN_mul(r1, r0, rsa->q, ctx)) goto err; if (!BN_add(r0, r1, m1)) goto err; if (rsa->e && rsa->n) { if (!rsa->meth->bn_mod_exp(vrfy, r0, rsa->e, rsa->n, ctx, rsa->_method_mod_n)) goto err; /* * If 'I' was greater than (or equal to) rsa->n, the operation * will be equivalent to using 'I mod n'. However, the result of * the verify will *always* be less than 'n' so we don't check * for absolute equality, just congruency. */ if (!BN_sub(vrfy, vrfy, I)) goto err; if (!BN_mod(vrfy, vrfy, rsa->n, ctx)) goto err; if (BN_is_negative(vrfy)) if (!BN_add(vrfy, vrfy, rsa->n)) goto err; if (!BN_is_zero(vrfy)) { /* * 'I' and 'vrfy' aren't congruent mod n. Don't leak * miscalculated CRT output, just do a raw (slower) * mod_exp and return that instead. */ BIGNUM local_d; BIGNUM *d = NULL; if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { d = &local_d; BN_with_flags(d, rsa->d, BN_FLG_CONSTTIME); } else d = rsa->d; if (!rsa->meth->bn_mod_exp(r0, I, d, rsa->n, ctx, rsa->_method_mod_n)) goto err; } } ret = 1; err: BN_CTX_end(ctx); return ret; } static int RSA_eay_init(RSA *rsa) { rsa->flags |= RSA_FLAG_CACHE_PUBLIC | RSA_FLAG_CACHE_PRIVATE; return 1; } static int RSA_eay_finish(RSA *rsa) { BN_MONT_CTX_free(rsa->_method_mod_n); BN_MONT_CTX_free(rsa->_method_mod_p); BN_MONT_CTX_free(rsa->_method_mod_q); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_ssl.c0000644000175000017500000001156712360020706020665 0ustar /* $OpenBSD: rsa_ssl.c,v 1.12 2014/07/10 13:58:23 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include int RSA_padding_add_SSLv23(unsigned char *to, int tlen, const unsigned char *from, int flen) { int i, j; unsigned char *p; if (flen > tlen - 11) { RSAerr(RSA_F_RSA_PADDING_ADD_SSLV23, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); return 0; } p = (unsigned char *)to; *(p++) = 0; *(p++) = 2; /* Public Key BT (Block Type) */ /* pad out with non-zero random data */ j = tlen - 3 - 8 - flen; if (RAND_bytes(p, j) <= 0) return 0; for (i = 0; i < j; i++) { while (*p == '\0') { if (RAND_bytes(p, 1) <= 0) return 0; } p++; } memset(p, 3, 8); p += 8; *(p++) = '\0'; memcpy(p, from, flen); return 1; } int RSA_padding_check_SSLv23(unsigned char *to, int tlen, const unsigned char *from, int flen, int num) { int i, j, k; const unsigned char *p; p = from; if (flen < 10) { RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23, RSA_R_DATA_TOO_SMALL); return -1; } if (num != flen + 1 || *(p++) != 02) { RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23, RSA_R_BLOCK_TYPE_IS_NOT_02); return -1; } /* scan over padding data */ j = flen - 1; /* one for type */ for (i = 0; i < j; i++) if (*(p++) == 0) break; if (i == j || i < 8) { RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23, RSA_R_NULL_BEFORE_BLOCK_MISSING); return -1; } for (k = -9; k < -1; k++) { if (p[k] != 0x03) break; } if (k == -1) { RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23, RSA_R_SSLV3_ROLLBACK_ATTACK); return -1; } i++; /* Skip over the '\0' */ j -= i; if (j > tlen) { RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23, RSA_R_DATA_TOO_LARGE); return -1; } memcpy(to, p, j); return j; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_pmeth.c0000644000175000017500000003555312360020706021202 0ustar /* $OpenBSD: rsa_pmeth.c,v 1.13 2014/07/10 22:45:57 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_CMS #include #endif #include "evp_locl.h" #include "rsa_locl.h" /* RSA pkey context structure */ typedef struct { /* Key gen parameters */ int nbits; BIGNUM *pub_exp; /* Keygen callback info */ int gentmp[2]; /* RSA padding mode */ int pad_mode; /* message digest */ const EVP_MD *md; /* message digest for MGF1 */ const EVP_MD *mgf1md; /* PSS/OAEP salt length */ int saltlen; /* Temp buffer */ unsigned char *tbuf; } RSA_PKEY_CTX; static int pkey_rsa_init(EVP_PKEY_CTX *ctx) { RSA_PKEY_CTX *rctx; rctx = malloc(sizeof(RSA_PKEY_CTX)); if (!rctx) return 0; rctx->nbits = 2048; rctx->pub_exp = NULL; rctx->pad_mode = RSA_PKCS1_PADDING; rctx->md = NULL; rctx->mgf1md = NULL; rctx->tbuf = NULL; rctx->saltlen = -2; ctx->data = rctx; ctx->keygen_info = rctx->gentmp; ctx->keygen_info_count = 2; return 1; } static int pkey_rsa_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src) { RSA_PKEY_CTX *dctx, *sctx; if (!pkey_rsa_init(dst)) return 0; sctx = src->data; dctx = dst->data; dctx->nbits = sctx->nbits; if (sctx->pub_exp) { dctx->pub_exp = BN_dup(sctx->pub_exp); if (!dctx->pub_exp) return 0; } dctx->pad_mode = sctx->pad_mode; dctx->md = sctx->md; return 1; } static int setup_tbuf(RSA_PKEY_CTX *ctx, EVP_PKEY_CTX *pk) { if (ctx->tbuf) return 1; ctx->tbuf = malloc(EVP_PKEY_size(pk->pkey)); if (!ctx->tbuf) return 0; return 1; } static void pkey_rsa_cleanup(EVP_PKEY_CTX *ctx) { RSA_PKEY_CTX *rctx = ctx->data; if (rctx) { BN_free(rctx->pub_exp); free(rctx->tbuf); free(rctx); } } static int pkey_rsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, const unsigned char *tbs, size_t tbslen) { int ret; RSA_PKEY_CTX *rctx = ctx->data; RSA *rsa = ctx->pkey->pkey.rsa; if (rctx->md) { if (tbslen != (size_t)EVP_MD_size(rctx->md)) { RSAerr(RSA_F_PKEY_RSA_SIGN, RSA_R_INVALID_DIGEST_LENGTH); return -1; } if (EVP_MD_type(rctx->md) == NID_mdc2) { unsigned int sltmp; if (rctx->pad_mode != RSA_PKCS1_PADDING) return -1; ret = RSA_sign_ASN1_OCTET_STRING(NID_mdc2, tbs, tbslen, sig, &sltmp, rsa); if (ret <= 0) return ret; ret = sltmp; } else if (rctx->pad_mode == RSA_X931_PADDING) { if (!setup_tbuf(rctx, ctx)) return -1; memcpy(rctx->tbuf, tbs, tbslen); rctx->tbuf[tbslen] = RSA_X931_hash_id(EVP_MD_type(rctx->md)); ret = RSA_private_encrypt(tbslen + 1, rctx->tbuf, sig, rsa, RSA_X931_PADDING); } else if (rctx->pad_mode == RSA_PKCS1_PADDING) { unsigned int sltmp; ret = RSA_sign(EVP_MD_type(rctx->md), tbs, tbslen, sig, &sltmp, rsa); if (ret <= 0) return ret; ret = sltmp; } else if (rctx->pad_mode == RSA_PKCS1_PSS_PADDING) { if (!setup_tbuf(rctx, ctx)) return -1; if (!RSA_padding_add_PKCS1_PSS_mgf1(rsa, rctx->tbuf, tbs, rctx->md, rctx->mgf1md, rctx->saltlen)) return -1; ret = RSA_private_encrypt(RSA_size(rsa), rctx->tbuf, sig, rsa, RSA_NO_PADDING); } else return -1; } else ret = RSA_private_encrypt(tbslen, tbs, sig, ctx->pkey->pkey.rsa, rctx->pad_mode); if (ret < 0) return ret; *siglen = ret; return 1; } static int pkey_rsa_verifyrecover(EVP_PKEY_CTX *ctx, unsigned char *rout, size_t *routlen, const unsigned char *sig, size_t siglen) { int ret; RSA_PKEY_CTX *rctx = ctx->data; if (rctx->md) { if (rctx->pad_mode == RSA_X931_PADDING) { if (!setup_tbuf(rctx, ctx)) return -1; ret = RSA_public_decrypt(siglen, sig, rctx->tbuf, ctx->pkey->pkey.rsa, RSA_X931_PADDING); if (ret < 1) return 0; ret--; if (rctx->tbuf[ret] != RSA_X931_hash_id(EVP_MD_type(rctx->md))) { RSAerr(RSA_F_PKEY_RSA_VERIFYRECOVER, RSA_R_ALGORITHM_MISMATCH); return 0; } if (ret != EVP_MD_size(rctx->md)) { RSAerr(RSA_F_PKEY_RSA_VERIFYRECOVER, RSA_R_INVALID_DIGEST_LENGTH); return 0; } if (rout) memcpy(rout, rctx->tbuf, ret); } else if (rctx->pad_mode == RSA_PKCS1_PADDING) { size_t sltmp; ret = int_rsa_verify(EVP_MD_type(rctx->md), NULL, 0, rout, &sltmp, sig, siglen, ctx->pkey->pkey.rsa); if (ret <= 0) return 0; ret = sltmp; } else return -1; } else ret = RSA_public_decrypt(siglen, sig, rout, ctx->pkey->pkey.rsa, rctx->pad_mode); if (ret < 0) return ret; *routlen = ret; return 1; } static int pkey_rsa_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, const unsigned char *tbs, size_t tbslen) { RSA_PKEY_CTX *rctx = ctx->data; RSA *rsa = ctx->pkey->pkey.rsa; size_t rslen; if (rctx->md) { if (rctx->pad_mode == RSA_PKCS1_PADDING) return RSA_verify(EVP_MD_type(rctx->md), tbs, tbslen, sig, siglen, rsa); if (rctx->pad_mode == RSA_X931_PADDING) { if (pkey_rsa_verifyrecover(ctx, NULL, &rslen, sig, siglen) <= 0) return 0; } else if (rctx->pad_mode == RSA_PKCS1_PSS_PADDING) { int ret; if (!setup_tbuf(rctx, ctx)) return -1; ret = RSA_public_decrypt(siglen, sig, rctx->tbuf, rsa, RSA_NO_PADDING); if (ret <= 0) return 0; ret = RSA_verify_PKCS1_PSS_mgf1(rsa, tbs, rctx->md, rctx->mgf1md, rctx->tbuf, rctx->saltlen); if (ret <= 0) return 0; return 1; } else return -1; } else { if (!setup_tbuf(rctx, ctx)) return -1; rslen = RSA_public_decrypt(siglen, sig, rctx->tbuf, rsa, rctx->pad_mode); if (rslen == 0) return 0; } if (rslen != tbslen || memcmp(tbs, rctx->tbuf, rslen)) return 0; return 1; } static int pkey_rsa_encrypt(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, const unsigned char *in, size_t inlen) { int ret; RSA_PKEY_CTX *rctx = ctx->data; ret = RSA_public_encrypt(inlen, in, out, ctx->pkey->pkey.rsa, rctx->pad_mode); if (ret < 0) return ret; *outlen = ret; return 1; } static int pkey_rsa_decrypt(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, const unsigned char *in, size_t inlen) { int ret; RSA_PKEY_CTX *rctx = ctx->data; ret = RSA_private_decrypt(inlen, in, out, ctx->pkey->pkey.rsa, rctx->pad_mode); if (ret < 0) return ret; *outlen = ret; return 1; } static int check_padding_md(const EVP_MD *md, int padding) { if (!md) return 1; if (padding == RSA_NO_PADDING) { RSAerr(RSA_F_CHECK_PADDING_MD, RSA_R_INVALID_PADDING_MODE); return 0; } if (padding == RSA_X931_PADDING) { if (RSA_X931_hash_id(EVP_MD_type(md)) == -1) { RSAerr(RSA_F_CHECK_PADDING_MD, RSA_R_INVALID_X931_DIGEST); return 0; } return 1; } return 1; } static int pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) { RSA_PKEY_CTX *rctx = ctx->data; switch (type) { case EVP_PKEY_CTRL_RSA_PADDING: if (p1 >= RSA_PKCS1_PADDING && p1 <= RSA_PKCS1_PSS_PADDING) { if (!check_padding_md(rctx->md, p1)) return 0; if (p1 == RSA_PKCS1_PSS_PADDING) { if (!(ctx->operation & (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY))) goto bad_pad; if (!rctx->md) rctx->md = EVP_sha1(); } if (p1 == RSA_PKCS1_OAEP_PADDING) { if (!(ctx->operation & EVP_PKEY_OP_TYPE_CRYPT)) goto bad_pad; if (!rctx->md) rctx->md = EVP_sha1(); } rctx->pad_mode = p1; return 1; } bad_pad: RSAerr(RSA_F_PKEY_RSA_CTRL, RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE); return -2; case EVP_PKEY_CTRL_GET_RSA_PADDING: *(int *)p2 = rctx->pad_mode; return 1; case EVP_PKEY_CTRL_RSA_PSS_SALTLEN: case EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN: if (rctx->pad_mode != RSA_PKCS1_PSS_PADDING) { RSAerr(RSA_F_PKEY_RSA_CTRL, RSA_R_INVALID_PSS_SALTLEN); return -2; } if (type == EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN) *(int *)p2 = rctx->saltlen; else { if (p1 < -2) return -2; rctx->saltlen = p1; } return 1; case EVP_PKEY_CTRL_RSA_KEYGEN_BITS: if (p1 < 256) { RSAerr(RSA_F_PKEY_RSA_CTRL, RSA_R_INVALID_KEYBITS); return -2; } rctx->nbits = p1; return 1; case EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP: if (!p2) return -2; rctx->pub_exp = p2; return 1; case EVP_PKEY_CTRL_MD: if (!check_padding_md(p2, rctx->pad_mode)) return 0; rctx->md = p2; return 1; case EVP_PKEY_CTRL_RSA_MGF1_MD: case EVP_PKEY_CTRL_GET_RSA_MGF1_MD: if (rctx->pad_mode != RSA_PKCS1_PSS_PADDING) { RSAerr(RSA_F_PKEY_RSA_CTRL, RSA_R_INVALID_MGF1_MD); return -2; } if (type == EVP_PKEY_CTRL_GET_RSA_MGF1_MD) { if (rctx->mgf1md) *(const EVP_MD **)p2 = rctx->mgf1md; else *(const EVP_MD **)p2 = rctx->md; } else rctx->mgf1md = p2; return 1; case EVP_PKEY_CTRL_DIGESTINIT: case EVP_PKEY_CTRL_PKCS7_ENCRYPT: case EVP_PKEY_CTRL_PKCS7_DECRYPT: case EVP_PKEY_CTRL_PKCS7_SIGN: return 1; #ifndef OPENSSL_NO_CMS case EVP_PKEY_CTRL_CMS_DECRYPT: { X509_ALGOR *alg = NULL; ASN1_OBJECT *encalg = NULL; if (p2) CMS_RecipientInfo_ktri_get0_algs(p2, NULL, NULL, &alg); if (alg) X509_ALGOR_get0(&encalg, NULL, NULL, alg); if (encalg && OBJ_obj2nid(encalg) == NID_rsaesOaep) rctx->pad_mode = RSA_PKCS1_OAEP_PADDING; } /* FALLTHROUGH */ case EVP_PKEY_CTRL_CMS_ENCRYPT: case EVP_PKEY_CTRL_CMS_SIGN: return 1; #endif case EVP_PKEY_CTRL_PEER_KEY: RSAerr(RSA_F_PKEY_RSA_CTRL, RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; default: return -2; } } static int pkey_rsa_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) { long lval; char *ep; if (!value) { RSAerr(RSA_F_PKEY_RSA_CTRL_STR, RSA_R_VALUE_MISSING); return 0; } if (!strcmp(type, "rsa_padding_mode")) { int pm; if (!strcmp(value, "pkcs1")) pm = RSA_PKCS1_PADDING; else if (!strcmp(value, "sslv23")) pm = RSA_SSLV23_PADDING; else if (!strcmp(value, "none")) pm = RSA_NO_PADDING; else if (!strcmp(value, "oeap")) pm = RSA_PKCS1_OAEP_PADDING; else if (!strcmp(value, "oaep")) pm = RSA_PKCS1_OAEP_PADDING; else if (!strcmp(value, "x931")) pm = RSA_X931_PADDING; else if (!strcmp(value, "pss")) pm = RSA_PKCS1_PSS_PADDING; else { RSAerr(RSA_F_PKEY_RSA_CTRL_STR, RSA_R_UNKNOWN_PADDING_TYPE); return -2; } return EVP_PKEY_CTX_set_rsa_padding(ctx, pm); } if (!strcmp(type, "rsa_pss_saltlen")) { int saltlen; errno = 0; lval = strtol(value, &ep, 10); if (value[0] == '\0' || *ep != '\0') goto not_a_number; if ((errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN)) || (lval > INT_MAX || lval < INT_MIN)) goto out_of_range; saltlen = lval; return EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, saltlen); } if (!strcmp(type, "rsa_keygen_bits")) { int nbits; errno = 0; lval = strtol(value, &ep, 10); if (value[0] == '\0' || *ep != '\0') goto not_a_number; if ((errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN)) || (lval > INT_MAX || lval < INT_MIN)) goto out_of_range; nbits = lval; return EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, nbits); } if (!strcmp(type, "rsa_keygen_pubexp")) { int ret; BIGNUM *pubexp = NULL; if (!BN_asc2bn(&pubexp, value)) return 0; ret = EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp); if (ret <= 0) BN_free(pubexp); return ret; } not_a_number: out_of_range: return -2; } static int pkey_rsa_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) { RSA *rsa = NULL; RSA_PKEY_CTX *rctx = ctx->data; BN_GENCB *pcb, cb; int ret; if (!rctx->pub_exp) { rctx->pub_exp = BN_new(); if (!rctx->pub_exp || !BN_set_word(rctx->pub_exp, RSA_F4)) return 0; } rsa = RSA_new(); if (!rsa) return 0; if (ctx->pkey_gencb) { pcb = &cb; evp_pkey_set_cb_translate(pcb, ctx); } else pcb = NULL; ret = RSA_generate_key_ex(rsa, rctx->nbits, rctx->pub_exp, pcb); if (ret > 0) EVP_PKEY_assign_RSA(pkey, rsa); else RSA_free(rsa); return ret; } const EVP_PKEY_METHOD rsa_pkey_meth = { .pkey_id = EVP_PKEY_RSA, .flags = EVP_PKEY_FLAG_AUTOARGLEN, .init = pkey_rsa_init, .copy = pkey_rsa_copy, .cleanup = pkey_rsa_cleanup, .keygen = pkey_rsa_keygen, .sign = pkey_rsa_sign, .verify = pkey_rsa_verify, .verify_recover = pkey_rsa_verifyrecover, .encrypt = pkey_rsa_encrypt, .decrypt = pkey_rsa_decrypt, .ctrl = pkey_rsa_ctrl, .ctrl_str = pkey_rsa_ctrl_str }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_err.c0000644000175000017500000002536512360020706020655 0ustar /* $OpenBSD: rsa_err.c,v 1.14 2014/07/09 19:51:38 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_RSA,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_RSA,0,reason) static ERR_STRING_DATA RSA_str_functs[] = { {ERR_FUNC(RSA_F_CHECK_PADDING_MD), "CHECK_PADDING_MD"}, {ERR_FUNC(RSA_F_DO_RSA_PRINT), "DO_RSA_PRINT"}, {ERR_FUNC(RSA_F_INT_RSA_VERIFY), "INT_RSA_VERIFY"}, {ERR_FUNC(RSA_F_MEMORY_LOCK), "MEMORY_LOCK"}, {ERR_FUNC(RSA_F_OLD_RSA_PRIV_DECODE), "OLD_RSA_PRIV_DECODE"}, {ERR_FUNC(RSA_F_PKEY_RSA_CTRL), "PKEY_RSA_CTRL"}, {ERR_FUNC(RSA_F_PKEY_RSA_CTRL_STR), "PKEY_RSA_CTRL_STR"}, {ERR_FUNC(RSA_F_PKEY_RSA_SIGN), "PKEY_RSA_SIGN"}, {ERR_FUNC(RSA_F_PKEY_RSA_VERIFY), "PKEY_RSA_VERIFY"}, {ERR_FUNC(RSA_F_PKEY_RSA_VERIFYRECOVER), "PKEY_RSA_VERIFYRECOVER"}, {ERR_FUNC(RSA_F_RSA_BUILTIN_KEYGEN), "RSA_BUILTIN_KEYGEN"}, {ERR_FUNC(RSA_F_RSA_CHECK_KEY), "RSA_check_key"}, {ERR_FUNC(RSA_F_RSA_EAY_PRIVATE_DECRYPT), "RSA_EAY_PRIVATE_DECRYPT"}, {ERR_FUNC(RSA_F_RSA_EAY_PRIVATE_ENCRYPT), "RSA_EAY_PRIVATE_ENCRYPT"}, {ERR_FUNC(RSA_F_RSA_EAY_PUBLIC_DECRYPT), "RSA_EAY_PUBLIC_DECRYPT"}, {ERR_FUNC(RSA_F_RSA_EAY_PUBLIC_ENCRYPT), "RSA_EAY_PUBLIC_ENCRYPT"}, {ERR_FUNC(RSA_F_RSA_GENERATE_KEY), "RSA_generate_key"}, {ERR_FUNC(RSA_F_RSA_GENERATE_KEY_EX), "RSA_generate_key_ex"}, {ERR_FUNC(RSA_F_RSA_ITEM_VERIFY), "RSA_ITEM_VERIFY"}, {ERR_FUNC(RSA_F_RSA_MEMORY_LOCK), "RSA_memory_lock"}, {ERR_FUNC(RSA_F_RSA_NEW_METHOD), "RSA_new_method"}, {ERR_FUNC(RSA_F_RSA_PADDING_ADD_NONE), "RSA_padding_add_none"}, {ERR_FUNC(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP), "RSA_padding_add_PKCS1_OAEP"}, {ERR_FUNC(RSA_F_RSA_PADDING_ADD_PKCS1_PSS), "RSA_padding_add_PKCS1_PSS"}, {ERR_FUNC(RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1), "RSA_padding_add_PKCS1_PSS_mgf1"}, {ERR_FUNC(RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1), "RSA_padding_add_PKCS1_type_1"}, {ERR_FUNC(RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2), "RSA_padding_add_PKCS1_type_2"}, {ERR_FUNC(RSA_F_RSA_PADDING_ADD_SSLV23), "RSA_padding_add_SSLv23"}, {ERR_FUNC(RSA_F_RSA_PADDING_ADD_X931), "RSA_padding_add_X931"}, {ERR_FUNC(RSA_F_RSA_PADDING_CHECK_NONE), "RSA_padding_check_none"}, {ERR_FUNC(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP), "RSA_padding_check_PKCS1_OAEP"}, {ERR_FUNC(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1), "RSA_padding_check_PKCS1_type_1"}, {ERR_FUNC(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2), "RSA_padding_check_PKCS1_type_2"}, {ERR_FUNC(RSA_F_RSA_PADDING_CHECK_SSLV23), "RSA_padding_check_SSLv23"}, {ERR_FUNC(RSA_F_RSA_PADDING_CHECK_X931), "RSA_padding_check_X931"}, {ERR_FUNC(RSA_F_RSA_PRINT), "RSA_print"}, {ERR_FUNC(RSA_F_RSA_PRINT_FP), "RSA_print_fp"}, {ERR_FUNC(RSA_F_RSA_PRIVATE_DECRYPT), "RSA_private_decrypt"}, {ERR_FUNC(RSA_F_RSA_PRIVATE_ENCRYPT), "RSA_private_encrypt"}, {ERR_FUNC(RSA_F_RSA_PRIV_DECODE), "RSA_PRIV_DECODE"}, {ERR_FUNC(RSA_F_RSA_PRIV_ENCODE), "RSA_PRIV_ENCODE"}, {ERR_FUNC(RSA_F_RSA_PUBLIC_DECRYPT), "RSA_public_decrypt"}, {ERR_FUNC(RSA_F_RSA_PUBLIC_ENCRYPT), "RSA_public_encrypt"}, {ERR_FUNC(RSA_F_RSA_PUB_DECODE), "RSA_PUB_DECODE"}, {ERR_FUNC(RSA_F_RSA_SETUP_BLINDING), "RSA_setup_blinding"}, {ERR_FUNC(RSA_F_RSA_SIGN), "RSA_sign"}, {ERR_FUNC(RSA_F_RSA_SIGN_ASN1_OCTET_STRING), "RSA_sign_ASN1_OCTET_STRING"}, {ERR_FUNC(RSA_F_RSA_VERIFY), "RSA_verify"}, {ERR_FUNC(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING), "RSA_verify_ASN1_OCTET_STRING"}, {ERR_FUNC(RSA_F_RSA_VERIFY_PKCS1_PSS), "RSA_verify_PKCS1_PSS"}, {ERR_FUNC(RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1), "RSA_verify_PKCS1_PSS_mgf1"}, {0, NULL} }; static ERR_STRING_DATA RSA_str_reasons[] = { {ERR_REASON(RSA_R_ALGORITHM_MISMATCH) , "algorithm mismatch"}, {ERR_REASON(RSA_R_BAD_E_VALUE) , "bad e value"}, {ERR_REASON(RSA_R_BAD_FIXED_HEADER_DECRYPT), "bad fixed header decrypt"}, {ERR_REASON(RSA_R_BAD_PAD_BYTE_COUNT) , "bad pad byte count"}, {ERR_REASON(RSA_R_BAD_SIGNATURE) , "bad signature"}, {ERR_REASON(RSA_R_BLOCK_TYPE_IS_NOT_01) , "block type is not 01"}, {ERR_REASON(RSA_R_BLOCK_TYPE_IS_NOT_02) , "block type is not 02"}, {ERR_REASON(RSA_R_DATA_GREATER_THAN_MOD_LEN), "data greater than mod len"}, {ERR_REASON(RSA_R_DATA_TOO_LARGE) , "data too large"}, {ERR_REASON(RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE), "data too large for key size"}, {ERR_REASON(RSA_R_DATA_TOO_LARGE_FOR_MODULUS), "data too large for modulus"}, {ERR_REASON(RSA_R_DATA_TOO_SMALL) , "data too small"}, {ERR_REASON(RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE), "data too small for key size"}, {ERR_REASON(RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY), "digest too big for rsa key"}, {ERR_REASON(RSA_R_DMP1_NOT_CONGRUENT_TO_D), "dmp1 not congruent to d"}, {ERR_REASON(RSA_R_DMQ1_NOT_CONGRUENT_TO_D), "dmq1 not congruent to d"}, {ERR_REASON(RSA_R_D_E_NOT_CONGRUENT_TO_1), "d e not congruent to 1"}, {ERR_REASON(RSA_R_FIRST_OCTET_INVALID) , "first octet invalid"}, {ERR_REASON(RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE), "illegal or unsupported padding mode"}, {ERR_REASON(RSA_R_INVALID_DIGEST_LENGTH) , "invalid digest length"}, {ERR_REASON(RSA_R_INVALID_HEADER) , "invalid header"}, {ERR_REASON(RSA_R_INVALID_KEYBITS) , "invalid keybits"}, {ERR_REASON(RSA_R_INVALID_MESSAGE_LENGTH), "invalid message length"}, {ERR_REASON(RSA_R_INVALID_MGF1_MD) , "invalid mgf1 md"}, {ERR_REASON(RSA_R_INVALID_PADDING) , "invalid padding"}, {ERR_REASON(RSA_R_INVALID_PADDING_MODE) , "invalid padding mode"}, {ERR_REASON(RSA_R_INVALID_PSS_PARAMETERS), "invalid pss parameters"}, {ERR_REASON(RSA_R_INVALID_PSS_SALTLEN) , "invalid pss saltlen"}, {ERR_REASON(RSA_R_INVALID_SALT_LENGTH) , "invalid salt length"}, {ERR_REASON(RSA_R_INVALID_TRAILER) , "invalid trailer"}, {ERR_REASON(RSA_R_INVALID_X931_DIGEST) , "invalid x931 digest"}, {ERR_REASON(RSA_R_IQMP_NOT_INVERSE_OF_Q) , "iqmp not inverse of q"}, {ERR_REASON(RSA_R_KEY_SIZE_TOO_SMALL) , "key size too small"}, {ERR_REASON(RSA_R_LAST_OCTET_INVALID) , "last octet invalid"}, {ERR_REASON(RSA_R_MODULUS_TOO_LARGE) , "modulus too large"}, {ERR_REASON(RSA_R_NON_FIPS_RSA_METHOD) , "non fips rsa method"}, {ERR_REASON(RSA_R_NO_PUBLIC_EXPONENT) , "no public exponent"}, {ERR_REASON(RSA_R_NULL_BEFORE_BLOCK_MISSING), "null before block missing"}, {ERR_REASON(RSA_R_N_DOES_NOT_EQUAL_P_Q) , "n does not equal p q"}, {ERR_REASON(RSA_R_OAEP_DECODING_ERROR) , "oaep decoding error"}, {ERR_REASON(RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE), "operation not allowed in fips mode"}, {ERR_REASON(RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE), "operation not supported for this keytype"}, {ERR_REASON(RSA_R_PADDING_CHECK_FAILED) , "padding check failed"}, {ERR_REASON(RSA_R_P_NOT_PRIME) , "p not prime"}, {ERR_REASON(RSA_R_Q_NOT_PRIME) , "q not prime"}, {ERR_REASON(RSA_R_RSA_OPERATIONS_NOT_SUPPORTED), "rsa operations not supported"}, {ERR_REASON(RSA_R_SLEN_CHECK_FAILED) , "salt length check failed"}, {ERR_REASON(RSA_R_SLEN_RECOVERY_FAILED) , "salt length recovery failed"}, {ERR_REASON(RSA_R_SSLV3_ROLLBACK_ATTACK) , "sslv3 rollback attack"}, {ERR_REASON(RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD), "the asn1 object identifier is not known for this md"}, {ERR_REASON(RSA_R_UNKNOWN_ALGORITHM_TYPE), "unknown algorithm type"}, {ERR_REASON(RSA_R_UNKNOWN_MASK_DIGEST) , "unknown mask digest"}, {ERR_REASON(RSA_R_UNKNOWN_PADDING_TYPE) , "unknown padding type"}, {ERR_REASON(RSA_R_UNKNOWN_PSS_DIGEST) , "unknown pss digest"}, {ERR_REASON(RSA_R_UNSUPPORTED_MASK_ALGORITHM), "unsupported mask algorithm"}, {ERR_REASON(RSA_R_UNSUPPORTED_MASK_PARAMETER), "unsupported mask parameter"}, {ERR_REASON(RSA_R_UNSUPPORTED_SIGNATURE_TYPE), "unsupported signature type"}, {ERR_REASON(RSA_R_VALUE_MISSING) , "value missing"}, {ERR_REASON(RSA_R_WRONG_SIGNATURE_LENGTH), "wrong signature length"}, {0, NULL} }; #endif void ERR_load_RSA_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(RSA_str_functs[0].error) == NULL) { ERR_load_strings(0, RSA_str_functs); ERR_load_strings(0, RSA_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_chk.c0000644000175000017500000001226212360020706020622 0ustar /* $OpenBSD: rsa_chk.c,v 1.8 2014/07/09 19:51:38 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== */ #include #include #include int RSA_check_key(const RSA *key) { BIGNUM *i, *j, *k, *l, *m; BN_CTX *ctx; int r; int ret = 1; if (!key->p || !key->q || !key->n || !key->e || !key->d) { RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_VALUE_MISSING); return 0; } i = BN_new(); j = BN_new(); k = BN_new(); l = BN_new(); m = BN_new(); ctx = BN_CTX_new(); if (i == NULL || j == NULL || k == NULL || l == NULL || m == NULL || ctx == NULL) { ret = -1; RSAerr(RSA_F_RSA_CHECK_KEY, ERR_R_MALLOC_FAILURE); goto err; } /* p prime? */ r = BN_is_prime_ex(key->p, BN_prime_checks, NULL, NULL); if (r != 1) { ret = r; if (r != 0) goto err; RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_P_NOT_PRIME); } /* q prime? */ r = BN_is_prime_ex(key->q, BN_prime_checks, NULL, NULL); if (r != 1) { ret = r; if (r != 0) goto err; RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_Q_NOT_PRIME); } /* n = p*q? */ r = BN_mul(i, key->p, key->q, ctx); if (!r) { ret = -1; goto err; } if (BN_cmp(i, key->n) != 0) { ret = 0; RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_N_DOES_NOT_EQUAL_P_Q); } /* d*e = 1 mod lcm(p-1,q-1)? */ r = BN_sub(i, key->p, BN_value_one()); if (!r) { ret = -1; goto err; } r = BN_sub(j, key->q, BN_value_one()); if (!r) { ret = -1; goto err; } /* now compute k = lcm(i,j) */ r = BN_mul(l, i, j, ctx); if (!r) { ret = -1; goto err; } r = BN_gcd(m, i, j, ctx); if (!r) { ret = -1; goto err; } r = BN_div(k, NULL, l, m, ctx); /* remainder is 0 */ if (!r) { ret = -1; goto err; } r = BN_mod_mul(i, key->d, key->e, k, ctx); if (!r) { ret = -1; goto err; } if (!BN_is_one(i)) { ret = 0; RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_D_E_NOT_CONGRUENT_TO_1); } if (key->dmp1 != NULL && key->dmq1 != NULL && key->iqmp != NULL) { /* dmp1 = d mod (p-1)? */ r = BN_sub(i, key->p, BN_value_one()); if (!r) { ret = -1; goto err; } r = BN_mod(j, key->d, i, ctx); if (!r) { ret = -1; goto err; } if (BN_cmp(j, key->dmp1) != 0) { ret = 0; RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_DMP1_NOT_CONGRUENT_TO_D); } /* dmq1 = d mod (q-1)? */ r = BN_sub(i, key->q, BN_value_one()); if (!r) { ret = -1; goto err; } r = BN_mod(j, key->d, i, ctx); if (!r) { ret = -1; goto err; } if (BN_cmp(j, key->dmq1) != 0) { ret = 0; RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_DMQ1_NOT_CONGRUENT_TO_D); } /* iqmp = q^-1 mod p? */ if (!BN_mod_inverse(i, key->q, key->p, ctx)) { ret = -1; goto err; } if (BN_cmp(i, key->iqmp) != 0) { ret = 0; RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_IQMP_NOT_INVERSE_OF_Q); } } err: BN_free(i); BN_free(j); BN_free(k); BN_free(l); BN_free(m); BN_CTX_free(ctx); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_x931.c0000644000175000017500000001111712360020706020557 0ustar /* $OpenBSD: rsa_x931.c,v 1.7 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2005. */ /* ==================================================================== * Copyright (c) 2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include int RSA_padding_add_X931(unsigned char *to, int tlen, const unsigned char *from, int flen) { int j; unsigned char *p; /* * Absolute minimum amount of padding is 1 header nibble, 1 padding * nibble and 2 trailer bytes: but 1 hash if is already in 'from'. */ j = tlen - flen - 2; if (j < 0) { RSAerr(RSA_F_RSA_PADDING_ADD_X931, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); return -1; } p = (unsigned char *)to; /* If no padding start and end nibbles are in one byte */ if (j == 0) *p++ = 0x6A; else { *p++ = 0x6B; if (j > 1) { memset(p, 0xBB, j - 1); p += j - 1; } *p++ = 0xBA; } memcpy(p, from, flen); p += flen; *p = 0xCC; return 1; } int RSA_padding_check_X931(unsigned char *to, int tlen, const unsigned char *from, int flen, int num) { int i = 0, j; const unsigned char *p = from; if (num != flen || (*p != 0x6A && *p != 0x6B)) { RSAerr(RSA_F_RSA_PADDING_CHECK_X931, RSA_R_INVALID_HEADER); return -1; } if (*p++ == 0x6B) { j = flen - 3; for (i = 0; i < j; i++) { unsigned char c = *p++; if (c == 0xBA) break; if (c != 0xBB) { RSAerr(RSA_F_RSA_PADDING_CHECK_X931, RSA_R_INVALID_PADDING); return -1; } } if (i == 0) { RSAerr(RSA_F_RSA_PADDING_CHECK_X931, RSA_R_INVALID_PADDING); return -1; } j -= i; } else j = flen - 2; if (j < 0 || p[j] != 0xCC) { RSAerr(RSA_F_RSA_PADDING_CHECK_X931, RSA_R_INVALID_TRAILER); return -1; } memcpy(to, p, j); return j; } /* Translate between X931 hash ids and NIDs */ int RSA_X931_hash_id(int nid) { switch (nid) { case NID_sha1: return 0x33; case NID_sha256: return 0x34; case NID_sha384: return 0x36; case NID_sha512: return 0x35; } return -1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_sign.c0000644000175000017500000002034012360020706021011 0ustar /* $OpenBSD: rsa_sign.c,v 1.21 2014/07/10 13:58:23 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include "rsa_locl.h" /* Size of an SSL signature: MD5+SHA1 */ #define SSL_SIG_LENGTH 36 int RSA_sign(int type, const unsigned char *m, unsigned int m_len, unsigned char *sigret, unsigned int *siglen, RSA *rsa) { X509_SIG sig; ASN1_TYPE parameter; int i, j, ret = 1; unsigned char *p, *tmps = NULL; const unsigned char *s = NULL; X509_ALGOR algor; ASN1_OCTET_STRING digest; if ((rsa->flags & RSA_FLAG_SIGN_VER) && rsa->meth->rsa_sign) return rsa->meth->rsa_sign(type, m, m_len, sigret, siglen, rsa); /* Special case: SSL signature, just check the length */ if (type == NID_md5_sha1) { if (m_len != SSL_SIG_LENGTH) { RSAerr(RSA_F_RSA_SIGN, RSA_R_INVALID_MESSAGE_LENGTH); return 0; } i = SSL_SIG_LENGTH; s = m; } else { sig.algor = &algor; sig.algor->algorithm = OBJ_nid2obj(type); if (sig.algor->algorithm == NULL) { RSAerr(RSA_F_RSA_SIGN, RSA_R_UNKNOWN_ALGORITHM_TYPE); return 0; } if (sig.algor->algorithm->length == 0) { RSAerr(RSA_F_RSA_SIGN, RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD); return 0; } parameter.type = V_ASN1_NULL; parameter.value.ptr = NULL; sig.algor->parameter = ¶meter; sig.digest = &digest; sig.digest->data = (unsigned char *)m; /* TMP UGLY CAST */ sig.digest->length = m_len; i = i2d_X509_SIG(&sig, NULL); } j = RSA_size(rsa); if (i > j - RSA_PKCS1_PADDING_SIZE) { RSAerr(RSA_F_RSA_SIGN, RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY); return 0; } if (type != NID_md5_sha1) { tmps = malloc((unsigned int)j + 1); if (tmps == NULL) { RSAerr(RSA_F_RSA_SIGN, ERR_R_MALLOC_FAILURE); return 0; } p = tmps; i2d_X509_SIG(&sig, &p); s = tmps; } i = RSA_private_encrypt(i, s, sigret, rsa, RSA_PKCS1_PADDING); if (i <= 0) ret = 0; else *siglen = i; if (type != NID_md5_sha1) { OPENSSL_cleanse(tmps, (unsigned int)j + 1); free(tmps); } return (ret); } int int_rsa_verify(int dtype, const unsigned char *m, unsigned int m_len, unsigned char *rm, size_t *prm_len, const unsigned char *sigbuf, size_t siglen, RSA *rsa) { int i, ret = 0, sigtype; unsigned char *s; X509_SIG *sig = NULL; if (siglen != (unsigned int)RSA_size(rsa)) { RSAerr(RSA_F_INT_RSA_VERIFY, RSA_R_WRONG_SIGNATURE_LENGTH); return 0; } if ((dtype == NID_md5_sha1) && rm) { i = RSA_public_decrypt((int)siglen, sigbuf, rm, rsa, RSA_PKCS1_PADDING); if (i <= 0) return 0; *prm_len = i; return 1; } s = malloc((unsigned int)siglen); if (s == NULL) { RSAerr(RSA_F_INT_RSA_VERIFY, ERR_R_MALLOC_FAILURE); goto err; } if (dtype == NID_md5_sha1 && m_len != SSL_SIG_LENGTH) { RSAerr(RSA_F_INT_RSA_VERIFY, RSA_R_INVALID_MESSAGE_LENGTH); goto err; } i = RSA_public_decrypt((int)siglen, sigbuf, s, rsa, RSA_PKCS1_PADDING); if (i <= 0) goto err; /* * Oddball MDC2 case: signature can be OCTET STRING. * check for correct tag and length octets. */ if (dtype == NID_mdc2 && i == 18 && s[0] == 0x04 && s[1] == 0x10) { if (rm) { memcpy(rm, s + 2, 16); *prm_len = 16; ret = 1; } else if (memcmp(m, s + 2, 16)) RSAerr(RSA_F_INT_RSA_VERIFY, RSA_R_BAD_SIGNATURE); else ret = 1; } /* Special case: SSL signature */ if (dtype == NID_md5_sha1) { if (i != SSL_SIG_LENGTH || memcmp(s, m, SSL_SIG_LENGTH)) RSAerr(RSA_F_INT_RSA_VERIFY, RSA_R_BAD_SIGNATURE); else ret = 1; } else { const unsigned char *p = s; sig = d2i_X509_SIG(NULL, &p, (long)i); if (sig == NULL) goto err; /* Excess data can be used to create forgeries */ if (p != s + i) { RSAerr(RSA_F_INT_RSA_VERIFY, RSA_R_BAD_SIGNATURE); goto err; } /* Parameters to the signature algorithm can also be used to create forgeries */ if (sig->algor->parameter && ASN1_TYPE_get(sig->algor->parameter) != V_ASN1_NULL) { RSAerr(RSA_F_INT_RSA_VERIFY, RSA_R_BAD_SIGNATURE); goto err; } sigtype = OBJ_obj2nid(sig->algor->algorithm); if (sigtype != dtype) { RSAerr(RSA_F_INT_RSA_VERIFY, RSA_R_ALGORITHM_MISMATCH); goto err; } if (rm) { const EVP_MD *md; md = EVP_get_digestbynid(dtype); if (md && (EVP_MD_size(md) != sig->digest->length)) RSAerr(RSA_F_INT_RSA_VERIFY, RSA_R_INVALID_DIGEST_LENGTH); else { memcpy(rm, sig->digest->data, sig->digest->length); *prm_len = sig->digest->length; ret = 1; } } else if ((unsigned int)sig->digest->length != m_len || memcmp(m, sig->digest->data, m_len) != 0) { RSAerr(RSA_F_INT_RSA_VERIFY, RSA_R_BAD_SIGNATURE); } else ret = 1; } err: if (sig != NULL) X509_SIG_free(sig); if (s != NULL) { OPENSSL_cleanse(s, (unsigned int)siglen); free(s); } return ret; } int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len, const unsigned char *sigbuf, unsigned int siglen, RSA *rsa) { if ((rsa->flags & RSA_FLAG_SIGN_VER) && rsa->meth->rsa_verify) return rsa->meth->rsa_verify(dtype, m, m_len, sigbuf, siglen, rsa); return int_rsa_verify(dtype, m, m_len, NULL, NULL, sigbuf, siglen, rsa); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_crpt.c0000644000175000017500000001412412360020706021024 0ustar /* $OpenBSD: rsa_crpt.c,v 1.10 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif int RSA_size(const RSA *r) { return BN_num_bytes(r->n); } int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding) { return rsa->meth->rsa_pub_enc(flen, from, to, rsa, padding); } int RSA_private_encrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding) { return rsa->meth->rsa_priv_enc(flen, from, to, rsa, padding); } int RSA_private_decrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding) { return rsa->meth->rsa_priv_dec(flen, from, to, rsa, padding); } int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding) { return rsa->meth->rsa_pub_dec(flen, from, to, rsa, padding); } int RSA_flags(const RSA *r) { return r == NULL ? 0 : r->meth->flags; } void RSA_blinding_off(RSA *rsa) { BN_BLINDING_free(rsa->blinding); rsa->blinding = NULL; rsa->flags |= RSA_FLAG_NO_BLINDING; } int RSA_blinding_on(RSA *rsa, BN_CTX *ctx) { int ret = 0; if (rsa->blinding != NULL) RSA_blinding_off(rsa); rsa->blinding = RSA_setup_blinding(rsa, ctx); if (rsa->blinding == NULL) goto err; rsa->flags &= ~RSA_FLAG_NO_BLINDING; ret = 1; err: return (ret); } static BIGNUM * rsa_get_public_exp(const BIGNUM *d, const BIGNUM *p, const BIGNUM *q, BN_CTX *ctx) { BIGNUM *ret = NULL, *r0, *r1, *r2; if (d == NULL || p == NULL || q == NULL) return NULL; BN_CTX_start(ctx); r0 = BN_CTX_get(ctx); r1 = BN_CTX_get(ctx); r2 = BN_CTX_get(ctx); if (r2 == NULL) goto err; if (!BN_sub(r1, p, BN_value_one())) goto err; if (!BN_sub(r2, q, BN_value_one())) goto err; if (!BN_mul(r0, r1, r2, ctx)) goto err; ret = BN_mod_inverse(NULL, d, r0, ctx); err: BN_CTX_end(ctx); return ret; } BN_BLINDING * RSA_setup_blinding(RSA *rsa, BN_CTX *in_ctx) { BIGNUM local_n; BIGNUM *e, *n; BN_CTX *ctx; BN_BLINDING *ret = NULL; if (in_ctx == NULL) { if ((ctx = BN_CTX_new()) == NULL) return 0; } else ctx = in_ctx; BN_CTX_start(ctx); if (rsa->e == NULL) { e = rsa_get_public_exp(rsa->d, rsa->p, rsa->q, ctx); if (e == NULL) { RSAerr(RSA_F_RSA_SETUP_BLINDING, RSA_R_NO_PUBLIC_EXPONENT); goto err; } } else e = rsa->e; if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { /* Set BN_FLG_CONSTTIME flag */ n = &local_n; BN_with_flags(n, rsa->n, BN_FLG_CONSTTIME); } else n = rsa->n; ret = BN_BLINDING_create_param(NULL, e, n, ctx, rsa->meth->bn_mod_exp, rsa->_method_mod_n); if (ret == NULL) { RSAerr(RSA_F_RSA_SETUP_BLINDING, ERR_R_BN_LIB); goto err; } CRYPTO_THREADID_current(BN_BLINDING_thread_id(ret)); err: BN_CTX_end(ctx); if (in_ctx == NULL) BN_CTX_free(ctx); if (rsa->e == NULL) BN_free(e); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_saos.c0000644000175000017500000001225512360020706021024 0ustar /* $OpenBSD: rsa_saos.c,v 1.14 2014/07/10 13:58:23 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include int RSA_sign_ASN1_OCTET_STRING(int type, const unsigned char *m, unsigned int m_len, unsigned char *sigret, unsigned int *siglen, RSA *rsa) { ASN1_OCTET_STRING sig; int i, j, ret = 1; unsigned char *p, *s; sig.type = V_ASN1_OCTET_STRING; sig.length = m_len; sig.data = (unsigned char *)m; i = i2d_ASN1_OCTET_STRING(&sig, NULL); j = RSA_size(rsa); if (i > (j - RSA_PKCS1_PADDING_SIZE)) { RSAerr(RSA_F_RSA_SIGN_ASN1_OCTET_STRING, RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY); return 0; } s = malloc((unsigned int)j + 1); if (s == NULL) { RSAerr(RSA_F_RSA_SIGN_ASN1_OCTET_STRING, ERR_R_MALLOC_FAILURE); return 0; } p = s; i2d_ASN1_OCTET_STRING(&sig, &p); i = RSA_private_encrypt(i, s, sigret, rsa, RSA_PKCS1_PADDING); if (i <= 0) ret = 0; else *siglen = i; OPENSSL_cleanse(s, (unsigned int)j + 1); free(s); return ret; } int RSA_verify_ASN1_OCTET_STRING(int dtype, const unsigned char *m, unsigned int m_len, unsigned char *sigbuf, unsigned int siglen, RSA *rsa) { int i, ret = 0; unsigned char *s; const unsigned char *p; ASN1_OCTET_STRING *sig = NULL; if (siglen != (unsigned int)RSA_size(rsa)) { RSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING, RSA_R_WRONG_SIGNATURE_LENGTH); return 0; } s = malloc((unsigned int)siglen); if (s == NULL) { RSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING, ERR_R_MALLOC_FAILURE); goto err; } i = RSA_public_decrypt((int)siglen, sigbuf, s, rsa, RSA_PKCS1_PADDING); if (i <= 0) goto err; p = s; sig = d2i_ASN1_OCTET_STRING(NULL, &p, (long)i); if (sig == NULL) goto err; if ((unsigned int)sig->length != m_len || memcmp(m, sig->data, m_len) != 0) { RSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING, RSA_R_BAD_SIGNATURE); } else ret = 1; err: if (sig != NULL) M_ASN1_OCTET_STRING_free(sig); if (s != NULL) { OPENSSL_cleanse(s, (unsigned int)siglen); free(s); } return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_pk1.c0000644000175000017500000001433512360020706020553 0ustar /* $OpenBSD: rsa_pk1.c,v 1.12 2014/07/10 13:58:23 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen, const unsigned char *from, int flen) { int j; unsigned char *p; if (flen > (tlen - RSA_PKCS1_PADDING_SIZE)) { RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); return 0; } p = (unsigned char *)to; *(p++) = 0; *(p++) = 1; /* Private Key BT (Block Type) */ /* pad out with 0xff data */ j = tlen - 3 - flen; memset(p, 0xff, j); p += j; *(p++) = '\0'; memcpy(p, from, flen); return 1; } int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen, const unsigned char *from, int flen, int num) { int i, j; const unsigned char *p; p = from; if (num != flen + 1 || *(p++) != 01) { RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1, RSA_R_BLOCK_TYPE_IS_NOT_01); return -1; } /* scan over padding data */ j = flen - 1; /* one for type. */ for (i = 0; i < j; i++) { if (*p != 0xff) { /* should decrypt to 0xff */ if (*p == 0) { p++; break; } else { RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1, RSA_R_BAD_FIXED_HEADER_DECRYPT); return -1; } } p++; } if (i == j) { RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1, RSA_R_NULL_BEFORE_BLOCK_MISSING); return -1; } if (i < 8) { RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1, RSA_R_BAD_PAD_BYTE_COUNT); return -1; } i++; /* Skip over the '\0' */ j -= i; if (j > tlen) { RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1, RSA_R_DATA_TOO_LARGE); return -1; } memcpy(to, p, j); return j; } int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen, const unsigned char *from, int flen) { int i, j; unsigned char *p; if (flen > tlen - 11) { RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); return 0; } p = (unsigned char *)to; *(p++) = 0; *(p++) = 2; /* Public Key BT (Block Type) */ /* pad out with non-zero random data */ j = tlen - 3 - flen; if (RAND_bytes(p, j) <= 0) return 0; for (i = 0; i < j; i++) { while (*p == '\0') { if (RAND_bytes(p, 1) <= 0) return 0; } p++; } *(p++) = '\0'; memcpy(p, from, flen); return 1; } int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, const unsigned char *from, int flen, int num) { int i, j; const unsigned char *p; p = from; if (num != flen + 1 || *(p++) != 02) { RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2, RSA_R_BLOCK_TYPE_IS_NOT_02); return -1; } /* scan over padding data */ j = flen - 1; /* one for type. */ for (i = 0; i < j; i++) if (*(p++) == 0) break; if (i == j) { RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2, RSA_R_NULL_BEFORE_BLOCK_MISSING); return -1; } if (i < 8) { RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2, RSA_R_BAD_PAD_BYTE_COUNT); return -1; } i++; /* Skip over the '\0' */ j -= i; if (j > tlen) { RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2, RSA_R_DATA_TOO_LARGE); return -1; } memcpy(to, p, j); return j; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_prn.c0000644000175000017500000000647012360020706020660 0ustar /* $OpenBSD: rsa_prn.c,v 1.5 2014/07/09 19:51:38 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include int RSA_print_fp(FILE *fp, const RSA *x, int off) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { RSAerr(RSA_F_RSA_PRINT_FP, ERR_R_BUF_LIB); return 0; } BIO_set_fp(b, fp, BIO_NOCLOSE); ret = RSA_print(b, x, off); BIO_free(b); return ret; } int RSA_print(BIO *bp, const RSA *x, int off) { EVP_PKEY *pk; int ret; pk = EVP_PKEY_new(); if (!pk || !EVP_PKEY_set1_RSA(pk, (RSA *)x)) return 0; ret = EVP_PKEY_print_private(bp, pk, off, NULL); EVP_PKEY_free(pk); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rsa/rsa_asn1.c0000644000175000017500000001062312360020706020716 0ustar /* $OpenBSD: rsa_asn1.c,v 1.8 2014/07/09 19:51:38 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include /* Override the default free and new methods */ static int rsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { if (operation == ASN1_OP_NEW_PRE) { *pval = (ASN1_VALUE *)RSA_new(); if (*pval) return 2; return 0; } else if (operation == ASN1_OP_FREE_PRE) { RSA_free((RSA *)*pval); *pval = NULL; return 2; } return 1; } ASN1_SEQUENCE_cb(RSAPrivateKey, rsa_cb) = { ASN1_SIMPLE(RSA, version, LONG), ASN1_SIMPLE(RSA, n, BIGNUM), ASN1_SIMPLE(RSA, e, BIGNUM), ASN1_SIMPLE(RSA, d, BIGNUM), ASN1_SIMPLE(RSA, p, BIGNUM), ASN1_SIMPLE(RSA, q, BIGNUM), ASN1_SIMPLE(RSA, dmp1, BIGNUM), ASN1_SIMPLE(RSA, dmq1, BIGNUM), ASN1_SIMPLE(RSA, iqmp, BIGNUM) } ASN1_SEQUENCE_END_cb(RSA, RSAPrivateKey) ASN1_SEQUENCE_cb(RSAPublicKey, rsa_cb) = { ASN1_SIMPLE(RSA, n, BIGNUM), ASN1_SIMPLE(RSA, e, BIGNUM), } ASN1_SEQUENCE_END_cb(RSA, RSAPublicKey) ASN1_SEQUENCE(RSA_PSS_PARAMS) = { ASN1_EXP_OPT(RSA_PSS_PARAMS, hashAlgorithm, X509_ALGOR, 0), ASN1_EXP_OPT(RSA_PSS_PARAMS, maskGenAlgorithm, X509_ALGOR, 1), ASN1_EXP_OPT(RSA_PSS_PARAMS, saltLength, ASN1_INTEGER, 2), ASN1_EXP_OPT(RSA_PSS_PARAMS, trailerField, ASN1_INTEGER, 3) } ASN1_SEQUENCE_END(RSA_PSS_PARAMS) IMPLEMENT_ASN1_FUNCTIONS(RSA_PSS_PARAMS) IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(RSA, RSAPrivateKey, RSAPrivateKey) IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(RSA, RSAPublicKey, RSAPublicKey) RSA * RSAPublicKey_dup(RSA *rsa) { return ASN1_item_dup(ASN1_ITEM_rptr(RSAPublicKey), rsa); } RSA * RSAPrivateKey_dup(RSA *rsa) { return ASN1_item_dup(ASN1_ITEM_rptr(RSAPrivateKey), rsa); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/cpt_err.c0000644000175000017500000001032112360020705020052 0ustar /* $OpenBSD: cpt_err.c,v 1.12 2014/06/12 15:49:27 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_CRYPTO,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_CRYPTO,0,reason) static ERR_STRING_DATA CRYPTO_str_functs[] = { {ERR_FUNC(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX), "CRYPTO_get_ex_new_index"}, {ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID), "CRYPTO_get_new_dynlockid"}, {ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_LOCKID), "CRYPTO_get_new_lockid"}, {ERR_FUNC(CRYPTO_F_CRYPTO_SET_EX_DATA), "CRYPTO_set_ex_data"}, {ERR_FUNC(CRYPTO_F_DEF_ADD_INDEX), "DEF_ADD_INDEX"}, {ERR_FUNC(CRYPTO_F_DEF_GET_CLASS), "DEF_GET_CLASS"}, {ERR_FUNC(CRYPTO_F_FIPS_MODE_SET), "FIPS_mode_set"}, {ERR_FUNC(CRYPTO_F_INT_DUP_EX_DATA), "INT_DUP_EX_DATA"}, {ERR_FUNC(CRYPTO_F_INT_FREE_EX_DATA), "INT_FREE_EX_DATA"}, {ERR_FUNC(CRYPTO_F_INT_NEW_EX_DATA), "INT_NEW_EX_DATA"}, {0, NULL} }; static ERR_STRING_DATA CRYPTO_str_reasons[] = { {ERR_REASON(CRYPTO_R_FIPS_MODE_NOT_SUPPORTED), "fips mode not supported"}, {ERR_REASON(CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK), "no dynlock create callback"}, {0, NULL} }; #endif void ERR_load_CRYPTO_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(CRYPTO_str_functs[0].error) == NULL) { ERR_load_strings(0, CRYPTO_str_functs); ERR_load_strings(0, CRYPTO_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/modes/0000755000000000000000000000000012666635521021161 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/modes/ccm128.c0000644000175000017500000002656412360020706020541 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== */ #include #include "modes_lcl.h" #include #ifndef MODES_DEBUG # ifndef NDEBUG # define NDEBUG # endif #endif #include /* First you setup M and L parameters and pass the key schedule. * This is called once per session setup... */ void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx, unsigned int M,unsigned int L,void *key,block128_f block) { memset(ctx->nonce.c,0,sizeof(ctx->nonce.c)); ctx->nonce.c[0] = ((u8)(L-1)&7) | (u8)(((M-2)/2)&7)<<3; ctx->blocks = 0; ctx->block = block; ctx->key = key; } /* !!! Following interfaces are to be called *once* per packet !!! */ /* Then you setup per-message nonce and pass the length of the message */ int CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, const unsigned char *nonce,size_t nlen,size_t mlen) { unsigned int L = ctx->nonce.c[0]&7; /* the L parameter */ if (nlen<(14-L)) return -1; /* nonce is too short */ if (sizeof(mlen)==8 && L>=3) { ctx->nonce.c[8] = (u8)(mlen>>(56%(sizeof(mlen)*8))); ctx->nonce.c[9] = (u8)(mlen>>(48%(sizeof(mlen)*8))); ctx->nonce.c[10] = (u8)(mlen>>(40%(sizeof(mlen)*8))); ctx->nonce.c[11] = (u8)(mlen>>(32%(sizeof(mlen)*8))); } else ctx->nonce.u[1] = 0; ctx->nonce.c[12] = (u8)(mlen>>24); ctx->nonce.c[13] = (u8)(mlen>>16); ctx->nonce.c[14] = (u8)(mlen>>8); ctx->nonce.c[15] = (u8)mlen; ctx->nonce.c[0] &= ~0x40; /* clear Adata flag */ memcpy(&ctx->nonce.c[1],nonce,14-L); return 0; } /* Then you pass additional authentication data, this is optional */ void CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, const unsigned char *aad,size_t alen) { unsigned int i; block128_f block = ctx->block; if (alen==0) return; ctx->nonce.c[0] |= 0x40; /* set Adata flag */ (*block)(ctx->nonce.c,ctx->cmac.c,ctx->key), ctx->blocks++; if (alen<(0x10000-0x100)) { ctx->cmac.c[0] ^= (u8)(alen>>8); ctx->cmac.c[1] ^= (u8)alen; i=2; } else if (sizeof(alen)==8 && alen>=(size_t)1<<(32%(sizeof(alen)*8))) { ctx->cmac.c[0] ^= 0xFF; ctx->cmac.c[1] ^= 0xFF; ctx->cmac.c[2] ^= (u8)(alen>>(56%(sizeof(alen)*8))); ctx->cmac.c[3] ^= (u8)(alen>>(48%(sizeof(alen)*8))); ctx->cmac.c[4] ^= (u8)(alen>>(40%(sizeof(alen)*8))); ctx->cmac.c[5] ^= (u8)(alen>>(32%(sizeof(alen)*8))); ctx->cmac.c[6] ^= (u8)(alen>>24); ctx->cmac.c[7] ^= (u8)(alen>>16); ctx->cmac.c[8] ^= (u8)(alen>>8); ctx->cmac.c[9] ^= (u8)alen; i=10; } else { ctx->cmac.c[0] ^= 0xFF; ctx->cmac.c[1] ^= 0xFE; ctx->cmac.c[2] ^= (u8)(alen>>24); ctx->cmac.c[3] ^= (u8)(alen>>16); ctx->cmac.c[4] ^= (u8)(alen>>8); ctx->cmac.c[5] ^= (u8)alen; i=6; } do { for(;i<16 && alen;++i,++aad,--alen) ctx->cmac.c[i] ^= *aad; (*block)(ctx->cmac.c,ctx->cmac.c,ctx->key), ctx->blocks++; i=0; } while (alen); } /* Finally you encrypt or decrypt the message */ /* counter part of nonce may not be larger than L*8 bits, * L is not larger than 8, therefore 64-bit counter... */ static void ctr64_inc(unsigned char *counter) { unsigned int n=8; u8 c; counter += 8; do { --n; c = counter[n]; ++c; counter[n] = c; if (c) return; } while (n); } int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, const unsigned char *inp, unsigned char *out, size_t len) { size_t n; unsigned int i,L; unsigned char flags0 = ctx->nonce.c[0]; block128_f block = ctx->block; void * key = ctx->key; union { u64 u[2]; u8 c[16]; } scratch; if (!(flags0&0x40)) (*block)(ctx->nonce.c,ctx->cmac.c,key), ctx->blocks++; ctx->nonce.c[0] = L = flags0&7; for (n=0,i=15-L;i<15;++i) { n |= ctx->nonce.c[i]; ctx->nonce.c[i]=0; n <<= 8; } n |= ctx->nonce.c[15]; /* reconstructed length */ ctx->nonce.c[15]=1; if (n!=len) return -1; /* length mismatch */ ctx->blocks += ((len+15)>>3)|1; if (ctx->blocks > (U64(1)<<61)) return -2; /* too much data */ while (len>=16) { #ifdef __STRICT_ALIGNMENT union { u64 u[2]; u8 c[16]; } temp; memcpy (temp.c,inp,16); ctx->cmac.u[0] ^= temp.u[0]; ctx->cmac.u[1] ^= temp.u[1]; #else ctx->cmac.u[0] ^= ((u64*)inp)[0]; ctx->cmac.u[1] ^= ((u64*)inp)[1]; #endif (*block)(ctx->cmac.c,ctx->cmac.c,key); (*block)(ctx->nonce.c,scratch.c,key); ctr64_inc(ctx->nonce.c); #ifdef __STRICT_ALIGNMENT temp.u[0] ^= scratch.u[0]; temp.u[1] ^= scratch.u[1]; memcpy(out,temp.c,16); #else ((u64*)out)[0] = scratch.u[0]^((u64*)inp)[0]; ((u64*)out)[1] = scratch.u[1]^((u64*)inp)[1]; #endif inp += 16; out += 16; len -= 16; } if (len) { for (i=0; icmac.c[i] ^= inp[i]; (*block)(ctx->cmac.c,ctx->cmac.c,key); (*block)(ctx->nonce.c,scratch.c,key); for (i=0; inonce.c[i]=0; (*block)(ctx->nonce.c,scratch.c,key); ctx->cmac.u[0] ^= scratch.u[0]; ctx->cmac.u[1] ^= scratch.u[1]; ctx->nonce.c[0] = flags0; return 0; } int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, const unsigned char *inp, unsigned char *out, size_t len) { size_t n; unsigned int i,L; unsigned char flags0 = ctx->nonce.c[0]; block128_f block = ctx->block; void * key = ctx->key; union { u64 u[2]; u8 c[16]; } scratch; if (!(flags0&0x40)) (*block)(ctx->nonce.c,ctx->cmac.c,key); ctx->nonce.c[0] = L = flags0&7; for (n=0,i=15-L;i<15;++i) { n |= ctx->nonce.c[i]; ctx->nonce.c[i]=0; n <<= 8; } n |= ctx->nonce.c[15]; /* reconstructed length */ ctx->nonce.c[15]=1; if (n!=len) return -1; while (len>=16) { #ifdef __STRICT_ALIGNMENT union { u64 u[2]; u8 c[16]; } temp; #endif (*block)(ctx->nonce.c,scratch.c,key); ctr64_inc(ctx->nonce.c); #ifdef __STRICT_ALIGNMENT memcpy (temp.c,inp,16); ctx->cmac.u[0] ^= (scratch.u[0] ^= temp.u[0]); ctx->cmac.u[1] ^= (scratch.u[1] ^= temp.u[1]); memcpy (out,scratch.c,16); #else ctx->cmac.u[0] ^= (((u64*)out)[0] = scratch.u[0]^((u64*)inp)[0]); ctx->cmac.u[1] ^= (((u64*)out)[1] = scratch.u[1]^((u64*)inp)[1]); #endif (*block)(ctx->cmac.c,ctx->cmac.c,key); inp += 16; out += 16; len -= 16; } if (len) { (*block)(ctx->nonce.c,scratch.c,key); for (i=0; icmac.c[i] ^= (out[i] = scratch.c[i]^inp[i]); (*block)(ctx->cmac.c,ctx->cmac.c,key); } for (i=15-L;i<16;++i) ctx->nonce.c[i]=0; (*block)(ctx->nonce.c,scratch.c,key); ctx->cmac.u[0] ^= scratch.u[0]; ctx->cmac.u[1] ^= scratch.u[1]; ctx->nonce.c[0] = flags0; return 0; } static void ctr64_add (unsigned char *counter,size_t inc) { size_t n=8, val=0; counter += 8; do { --n; val += counter[n] + (inc&0xff); counter[n] = (unsigned char)val; val >>= 8; /* carry bit */ inc >>= 8; } while(n && (inc || val)); } int CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp, unsigned char *out, size_t len,ccm128_f stream) { size_t n; unsigned int i,L; unsigned char flags0 = ctx->nonce.c[0]; block128_f block = ctx->block; void * key = ctx->key; union { u64 u[2]; u8 c[16]; } scratch; if (!(flags0&0x40)) (*block)(ctx->nonce.c,ctx->cmac.c,key), ctx->blocks++; ctx->nonce.c[0] = L = flags0&7; for (n=0,i=15-L;i<15;++i) { n |= ctx->nonce.c[i]; ctx->nonce.c[i]=0; n <<= 8; } n |= ctx->nonce.c[15]; /* reconstructed length */ ctx->nonce.c[15]=1; if (n!=len) return -1; /* length mismatch */ ctx->blocks += ((len+15)>>3)|1; if (ctx->blocks > (U64(1)<<61)) return -2; /* too much data */ if ((n=len/16)) { (*stream)(inp,out,n,key,ctx->nonce.c,ctx->cmac.c); n *= 16; inp += n; out += n; len -= n; if (len) ctr64_add(ctx->nonce.c,n/16); } if (len) { for (i=0; icmac.c[i] ^= inp[i]; (*block)(ctx->cmac.c,ctx->cmac.c,key); (*block)(ctx->nonce.c,scratch.c,key); for (i=0; inonce.c[i]=0; (*block)(ctx->nonce.c,scratch.c,key); ctx->cmac.u[0] ^= scratch.u[0]; ctx->cmac.u[1] ^= scratch.u[1]; ctx->nonce.c[0] = flags0; return 0; } int CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp, unsigned char *out, size_t len,ccm128_f stream) { size_t n; unsigned int i,L; unsigned char flags0 = ctx->nonce.c[0]; block128_f block = ctx->block; void * key = ctx->key; union { u64 u[2]; u8 c[16]; } scratch; if (!(flags0&0x40)) (*block)(ctx->nonce.c,ctx->cmac.c,key); ctx->nonce.c[0] = L = flags0&7; for (n=0,i=15-L;i<15;++i) { n |= ctx->nonce.c[i]; ctx->nonce.c[i]=0; n <<= 8; } n |= ctx->nonce.c[15]; /* reconstructed length */ ctx->nonce.c[15]=1; if (n!=len) return -1; if ((n=len/16)) { (*stream)(inp,out,n,key,ctx->nonce.c,ctx->cmac.c); n *= 16; inp += n; out += n; len -= n; if (len) ctr64_add(ctx->nonce.c,n/16); } if (len) { (*block)(ctx->nonce.c,scratch.c,key); for (i=0; icmac.c[i] ^= (out[i] = scratch.c[i]^inp[i]); (*block)(ctx->cmac.c,ctx->cmac.c,key); } for (i=15-L;i<16;++i) ctx->nonce.c[i]=0; (*block)(ctx->nonce.c,scratch.c,key); ctx->cmac.u[0] ^= scratch.u[0]; ctx->cmac.u[1] ^= scratch.u[1]; ctx->nonce.c[0] = flags0; return 0; } size_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx,unsigned char *tag,size_t len) { unsigned int M = (ctx->nonce.c[0]>>3)&7; /* the M parameter */ M *= 2; M += 2; if (lencmac.c,M); return M; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/modes/xts128.c0000644000175000017500000001302712360020706020603 0ustar /* $OpenBSD: xts128.c,v 1.4 2014/06/12 15:49:30 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== */ #include #include #include "modes_lcl.h" #include #ifndef MODES_DEBUG # ifndef NDEBUG # define NDEBUG # endif #endif #include int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16], const unsigned char *inp, unsigned char *out, size_t len, int enc) { union { u64 u[2]; u32 d[4]; u8 c[16]; } tweak, scratch; unsigned int i; if (len<16) return -1; memcpy(tweak.c, iv, 16); (*ctx->block2)(tweak.c,tweak.c,ctx->key2); if (!enc && (len%16)) len-=16; while (len>=16) { #ifdef __STRICT_ALIGNMENT memcpy(scratch.c,inp,16); scratch.u[0] ^= tweak.u[0]; scratch.u[1] ^= tweak.u[1]; #else scratch.u[0] = ((u64*)inp)[0]^tweak.u[0]; scratch.u[1] = ((u64*)inp)[1]^tweak.u[1]; #endif (*ctx->block1)(scratch.c,scratch.c,ctx->key1); #ifdef __STRICT_ALIGNMENT scratch.u[0] ^= tweak.u[0]; scratch.u[1] ^= tweak.u[1]; memcpy(out,scratch.c,16); #else ((u64*)out)[0] = scratch.u[0]^=tweak.u[0]; ((u64*)out)[1] = scratch.u[1]^=tweak.u[1]; #endif inp += 16; out += 16; len -= 16; if (len==0) return 0; if (BYTE_ORDER == LITTLE_ENDIAN) { unsigned int carry,res; res = 0x87&(((int)tweak.d[3])>>31); carry = (unsigned int)(tweak.u[0]>>63); tweak.u[0] = (tweak.u[0]<<1)^res; tweak.u[1] = (tweak.u[1]<<1)|carry; } else { size_t c; for (c=0,i=0;i<16;++i) { /*+ substitutes for |, because c is 1 bit */ c += ((size_t)tweak.c[i])<<1; tweak.c[i] = (u8)c; c = c>>8; } tweak.c[0] ^= (u8)(0x87&(0-c)); } } if (enc) { for (i=0;iblock1)(scratch.c,scratch.c,ctx->key1); scratch.u[0] ^= tweak.u[0]; scratch.u[1] ^= tweak.u[1]; memcpy(out-16,scratch.c,16); } else { union { u64 u[2]; u8 c[16]; } tweak1; if (BYTE_ORDER == LITTLE_ENDIAN) { unsigned int carry,res; res = 0x87&(((int)tweak.d[3])>>31); carry = (unsigned int)(tweak.u[0]>>63); tweak1.u[0] = (tweak.u[0]<<1)^res; tweak1.u[1] = (tweak.u[1]<<1)|carry; } else { size_t c; for (c=0,i=0;i<16;++i) { /*+ substitutes for |, because c is 1 bit */ c += ((size_t)tweak.c[i])<<1; tweak1.c[i] = (u8)c; c = c>>8; } tweak1.c[0] ^= (u8)(0x87&(0-c)); } #ifdef __STRICT_ALIGNMENT memcpy(scratch.c,inp,16); scratch.u[0] ^= tweak1.u[0]; scratch.u[1] ^= tweak1.u[1]; #else scratch.u[0] = ((u64*)inp)[0]^tweak1.u[0]; scratch.u[1] = ((u64*)inp)[1]^tweak1.u[1]; #endif (*ctx->block1)(scratch.c,scratch.c,ctx->key1); scratch.u[0] ^= tweak1.u[0]; scratch.u[1] ^= tweak1.u[1]; for (i=0;iblock1)(scratch.c,scratch.c,ctx->key1); #ifdef __STRICT_ALIGNMENT scratch.u[0] ^= tweak.u[0]; scratch.u[1] ^= tweak.u[1]; memcpy (out,scratch.c,16); #else ((u64*)out)[0] = scratch.u[0]^tweak.u[0]; ((u64*)out)[1] = scratch.u[1]^tweak.u[1]; #endif } return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/modes/gcm128.c0000644000175000017500000011441612360020706020537 0ustar /* $OpenBSD: gcm128.c,v 1.9 2014/06/27 06:07:35 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 2010 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== */ #define OPENSSL_FIPSAPI #include #include "modes_lcl.h" #include #ifndef MODES_DEBUG # ifndef NDEBUG # define NDEBUG # endif #endif #include #if defined(BSWAP4) && defined(__STRICT_ALIGNMENT) /* redefine, because alignment is ensured */ #undef GETU32 #define GETU32(p) BSWAP4(*(const u32 *)(p)) #undef PUTU32 #define PUTU32(p,v) *(u32 *)(p) = BSWAP4(v) #endif #define PACK(s) ((size_t)(s)<<(sizeof(size_t)*8-16)) #define REDUCE1BIT(V) \ do { \ if (sizeof(size_t)==8) { \ u64 T = U64(0xe100000000000000) & (0-(V.lo&1)); \ V.lo = (V.hi<<63)|(V.lo>>1); \ V.hi = (V.hi>>1 )^T; \ } else { \ u32 T = 0xe1000000U & (0-(u32)(V.lo&1)); \ V.lo = (V.hi<<63)|(V.lo>>1); \ V.hi = (V.hi>>1 )^((u64)T<<32); \ } \ } while(0) /* * Even though permitted values for TABLE_BITS are 8, 4 and 1, it should * never be set to 8. 8 is effectively reserved for testing purposes. * TABLE_BITS>1 are lookup-table-driven implementations referred to as * "Shoup's" in GCM specification. In other words OpenSSL does not cover * whole spectrum of possible table driven implementations. Why? In * non-"Shoup's" case memory access pattern is segmented in such manner, * that it's trivial to see that cache timing information can reveal * fair portion of intermediate hash value. Given that ciphertext is * always available to attacker, it's possible for him to attempt to * deduce secret parameter H and if successful, tamper with messages * [which is nothing but trivial in CTR mode]. In "Shoup's" case it's * not as trivial, but there is no reason to believe that it's resistant * to cache-timing attack. And the thing about "8-bit" implementation is * that it consumes 16 (sixteen) times more memory, 4KB per individual * key + 1KB shared. Well, on pros side it should be twice as fast as * "4-bit" version. And for gcc-generated x86[_64] code, "8-bit" version * was observed to run ~75% faster, closer to 100% for commercial * compilers... Yet "4-bit" procedure is preferred, because it's * believed to provide better security-performance balance and adequate * all-round performance. "All-round" refers to things like: * * - shorter setup time effectively improves overall timing for * handling short messages; * - larger table allocation can become unbearable because of VM * subsystem penalties (for example on Windows large enough free * results in VM working set trimming, meaning that consequent * malloc would immediately incur working set expansion); * - larger table has larger cache footprint, which can affect * performance of other code paths (not necessarily even from same * thread in Hyper-Threading world); * * Value of 1 is not appropriate for performance reasons. */ #if TABLE_BITS==8 static void gcm_init_8bit(u128 Htable[256], u64 H[2]) { int i, j; u128 V; Htable[0].hi = 0; Htable[0].lo = 0; V.hi = H[0]; V.lo = H[1]; for (Htable[128]=V, i=64; i>0; i>>=1) { REDUCE1BIT(V); Htable[i] = V; } for (i=2; i<256; i<<=1) { u128 *Hi = Htable+i, H0 = *Hi; for (j=1; j>8); Z.hi = (Z.hi>>8); if (sizeof(size_t)==8) Z.hi ^= rem_8bit[rem]; else Z.hi ^= (u64)rem_8bit[rem]<<32; } if (BYTE_ORDER == LITTLE_ENDIAN) { #ifdef BSWAP8 Xi[0] = BSWAP8(Z.hi); Xi[1] = BSWAP8(Z.lo); #else u8 *p = (u8 *)Xi; u32 v; v = (u32)(Z.hi>>32); PUTU32(p,v); v = (u32)(Z.hi); PUTU32(p+4,v); v = (u32)(Z.lo>>32); PUTU32(p+8,v); v = (u32)(Z.lo); PUTU32(p+12,v); #endif } else { Xi[0] = Z.hi; Xi[1] = Z.lo; } } #define GCM_MUL(ctx,Xi) gcm_gmult_8bit(ctx->Xi.u,ctx->Htable) #elif TABLE_BITS==4 static void gcm_init_4bit(u128 Htable[16], u64 H[2]) { u128 V; #if defined(OPENSSL_SMALL_FOOTPRINT) int i; #endif Htable[0].hi = 0; Htable[0].lo = 0; V.hi = H[0]; V.lo = H[1]; #if defined(OPENSSL_SMALL_FOOTPRINT) for (Htable[8]=V, i=4; i>0; i>>=1) { REDUCE1BIT(V); Htable[i] = V; } for (i=2; i<16; i<<=1) { u128 *Hi = Htable+i; int j; for (V=*Hi, j=1; j>32; Htable[j].lo = V.hi<<32|V.hi>>32; } } #endif } #ifndef GHASH_ASM static const size_t rem_4bit[16] = { PACK(0x0000), PACK(0x1C20), PACK(0x3840), PACK(0x2460), PACK(0x7080), PACK(0x6CA0), PACK(0x48C0), PACK(0x54E0), PACK(0xE100), PACK(0xFD20), PACK(0xD940), PACK(0xC560), PACK(0x9180), PACK(0x8DA0), PACK(0xA9C0), PACK(0xB5E0) }; static void gcm_gmult_4bit(u64 Xi[2], const u128 Htable[16]) { u128 Z; int cnt = 15; size_t rem, nlo, nhi; nlo = ((const u8 *)Xi)[15]; nhi = nlo>>4; nlo &= 0xf; Z.hi = Htable[nlo].hi; Z.lo = Htable[nlo].lo; while (1) { rem = (size_t)Z.lo&0xf; Z.lo = (Z.hi<<60)|(Z.lo>>4); Z.hi = (Z.hi>>4); if (sizeof(size_t)==8) Z.hi ^= rem_4bit[rem]; else Z.hi ^= (u64)rem_4bit[rem]<<32; Z.hi ^= Htable[nhi].hi; Z.lo ^= Htable[nhi].lo; if (--cnt<0) break; nlo = ((const u8 *)Xi)[cnt]; nhi = nlo>>4; nlo &= 0xf; rem = (size_t)Z.lo&0xf; Z.lo = (Z.hi<<60)|(Z.lo>>4); Z.hi = (Z.hi>>4); if (sizeof(size_t)==8) Z.hi ^= rem_4bit[rem]; else Z.hi ^= (u64)rem_4bit[rem]<<32; Z.hi ^= Htable[nlo].hi; Z.lo ^= Htable[nlo].lo; } if (BYTE_ORDER == LITTLE_ENDIAN) { #ifdef BSWAP8 Xi[0] = BSWAP8(Z.hi); Xi[1] = BSWAP8(Z.lo); #else u8 *p = (u8 *)Xi; u32 v; v = (u32)(Z.hi>>32); PUTU32(p,v); v = (u32)(Z.hi); PUTU32(p+4,v); v = (u32)(Z.lo>>32); PUTU32(p+8,v); v = (u32)(Z.lo); PUTU32(p+12,v); #endif } else { Xi[0] = Z.hi; Xi[1] = Z.lo; } } #if !defined(OPENSSL_SMALL_FOOTPRINT) /* * Streamed gcm_mult_4bit, see CRYPTO_gcm128_[en|de]crypt for * details... Compiler-generated code doesn't seem to give any * performance improvement, at least not on x86[_64]. It's here * mostly as reference and a placeholder for possible future * non-trivial optimization[s]... */ static void gcm_ghash_4bit(u64 Xi[2],const u128 Htable[16], const u8 *inp,size_t len) { u128 Z; int cnt; size_t rem, nlo, nhi; #if 1 do { cnt = 15; nlo = ((const u8 *)Xi)[15]; nlo ^= inp[15]; nhi = nlo>>4; nlo &= 0xf; Z.hi = Htable[nlo].hi; Z.lo = Htable[nlo].lo; while (1) { rem = (size_t)Z.lo&0xf; Z.lo = (Z.hi<<60)|(Z.lo>>4); Z.hi = (Z.hi>>4); if (sizeof(size_t)==8) Z.hi ^= rem_4bit[rem]; else Z.hi ^= (u64)rem_4bit[rem]<<32; Z.hi ^= Htable[nhi].hi; Z.lo ^= Htable[nhi].lo; if (--cnt<0) break; nlo = ((const u8 *)Xi)[cnt]; nlo ^= inp[cnt]; nhi = nlo>>4; nlo &= 0xf; rem = (size_t)Z.lo&0xf; Z.lo = (Z.hi<<60)|(Z.lo>>4); Z.hi = (Z.hi>>4); if (sizeof(size_t)==8) Z.hi ^= rem_4bit[rem]; else Z.hi ^= (u64)rem_4bit[rem]<<32; Z.hi ^= Htable[nlo].hi; Z.lo ^= Htable[nlo].lo; } #else /* * Extra 256+16 bytes per-key plus 512 bytes shared tables * [should] give ~50% improvement... One could have PACK()-ed * the rem_8bit even here, but the priority is to minimize * cache footprint... */ u128 Hshr4[16]; /* Htable shifted right by 4 bits */ u8 Hshl4[16]; /* Htable shifted left by 4 bits */ static const unsigned short rem_8bit[256] = { 0x0000, 0x01C2, 0x0384, 0x0246, 0x0708, 0x06CA, 0x048C, 0x054E, 0x0E10, 0x0FD2, 0x0D94, 0x0C56, 0x0918, 0x08DA, 0x0A9C, 0x0B5E, 0x1C20, 0x1DE2, 0x1FA4, 0x1E66, 0x1B28, 0x1AEA, 0x18AC, 0x196E, 0x1230, 0x13F2, 0x11B4, 0x1076, 0x1538, 0x14FA, 0x16BC, 0x177E, 0x3840, 0x3982, 0x3BC4, 0x3A06, 0x3F48, 0x3E8A, 0x3CCC, 0x3D0E, 0x3650, 0x3792, 0x35D4, 0x3416, 0x3158, 0x309A, 0x32DC, 0x331E, 0x2460, 0x25A2, 0x27E4, 0x2626, 0x2368, 0x22AA, 0x20EC, 0x212E, 0x2A70, 0x2BB2, 0x29F4, 0x2836, 0x2D78, 0x2CBA, 0x2EFC, 0x2F3E, 0x7080, 0x7142, 0x7304, 0x72C6, 0x7788, 0x764A, 0x740C, 0x75CE, 0x7E90, 0x7F52, 0x7D14, 0x7CD6, 0x7998, 0x785A, 0x7A1C, 0x7BDE, 0x6CA0, 0x6D62, 0x6F24, 0x6EE6, 0x6BA8, 0x6A6A, 0x682C, 0x69EE, 0x62B0, 0x6372, 0x6134, 0x60F6, 0x65B8, 0x647A, 0x663C, 0x67FE, 0x48C0, 0x4902, 0x4B44, 0x4A86, 0x4FC8, 0x4E0A, 0x4C4C, 0x4D8E, 0x46D0, 0x4712, 0x4554, 0x4496, 0x41D8, 0x401A, 0x425C, 0x439E, 0x54E0, 0x5522, 0x5764, 0x56A6, 0x53E8, 0x522A, 0x506C, 0x51AE, 0x5AF0, 0x5B32, 0x5974, 0x58B6, 0x5DF8, 0x5C3A, 0x5E7C, 0x5FBE, 0xE100, 0xE0C2, 0xE284, 0xE346, 0xE608, 0xE7CA, 0xE58C, 0xE44E, 0xEF10, 0xEED2, 0xEC94, 0xED56, 0xE818, 0xE9DA, 0xEB9C, 0xEA5E, 0xFD20, 0xFCE2, 0xFEA4, 0xFF66, 0xFA28, 0xFBEA, 0xF9AC, 0xF86E, 0xF330, 0xF2F2, 0xF0B4, 0xF176, 0xF438, 0xF5FA, 0xF7BC, 0xF67E, 0xD940, 0xD882, 0xDAC4, 0xDB06, 0xDE48, 0xDF8A, 0xDDCC, 0xDC0E, 0xD750, 0xD692, 0xD4D4, 0xD516, 0xD058, 0xD19A, 0xD3DC, 0xD21E, 0xC560, 0xC4A2, 0xC6E4, 0xC726, 0xC268, 0xC3AA, 0xC1EC, 0xC02E, 0xCB70, 0xCAB2, 0xC8F4, 0xC936, 0xCC78, 0xCDBA, 0xCFFC, 0xCE3E, 0x9180, 0x9042, 0x9204, 0x93C6, 0x9688, 0x974A, 0x950C, 0x94CE, 0x9F90, 0x9E52, 0x9C14, 0x9DD6, 0x9898, 0x995A, 0x9B1C, 0x9ADE, 0x8DA0, 0x8C62, 0x8E24, 0x8FE6, 0x8AA8, 0x8B6A, 0x892C, 0x88EE, 0x83B0, 0x8272, 0x8034, 0x81F6, 0x84B8, 0x857A, 0x873C, 0x86FE, 0xA9C0, 0xA802, 0xAA44, 0xAB86, 0xAEC8, 0xAF0A, 0xAD4C, 0xAC8E, 0xA7D0, 0xA612, 0xA454, 0xA596, 0xA0D8, 0xA11A, 0xA35C, 0xA29E, 0xB5E0, 0xB422, 0xB664, 0xB7A6, 0xB2E8, 0xB32A, 0xB16C, 0xB0AE, 0xBBF0, 0xBA32, 0xB874, 0xB9B6, 0xBCF8, 0xBD3A, 0xBF7C, 0xBEBE }; /* * This pre-processing phase slows down procedure by approximately * same time as it makes each loop spin faster. In other words * single block performance is approximately same as straightforward * "4-bit" implementation, and then it goes only faster... */ for (cnt=0; cnt<16; ++cnt) { Z.hi = Htable[cnt].hi; Z.lo = Htable[cnt].lo; Hshr4[cnt].lo = (Z.hi<<60)|(Z.lo>>4); Hshr4[cnt].hi = (Z.hi>>4); Hshl4[cnt] = (u8)(Z.lo<<4); } do { for (Z.lo=0, Z.hi=0, cnt=15; cnt; --cnt) { nlo = ((const u8 *)Xi)[cnt]; nlo ^= inp[cnt]; nhi = nlo>>4; nlo &= 0xf; Z.hi ^= Htable[nlo].hi; Z.lo ^= Htable[nlo].lo; rem = (size_t)Z.lo&0xff; Z.lo = (Z.hi<<56)|(Z.lo>>8); Z.hi = (Z.hi>>8); Z.hi ^= Hshr4[nhi].hi; Z.lo ^= Hshr4[nhi].lo; Z.hi ^= (u64)rem_8bit[rem^Hshl4[nhi]]<<48; } nlo = ((const u8 *)Xi)[0]; nlo ^= inp[0]; nhi = nlo>>4; nlo &= 0xf; Z.hi ^= Htable[nlo].hi; Z.lo ^= Htable[nlo].lo; rem = (size_t)Z.lo&0xf; Z.lo = (Z.hi<<60)|(Z.lo>>4); Z.hi = (Z.hi>>4); Z.hi ^= Htable[nhi].hi; Z.lo ^= Htable[nhi].lo; Z.hi ^= ((u64)rem_8bit[rem<<4])<<48; #endif if (BYTE_ORDER == LITTLE_ENDIAN) { #ifdef BSWAP8 Xi[0] = BSWAP8(Z.hi); Xi[1] = BSWAP8(Z.lo); #else u8 *p = (u8 *)Xi; u32 v; v = (u32)(Z.hi>>32); PUTU32(p,v); v = (u32)(Z.hi); PUTU32(p+4,v); v = (u32)(Z.lo>>32); PUTU32(p+8,v); v = (u32)(Z.lo); PUTU32(p+12,v); #endif } else { Xi[0] = Z.hi; Xi[1] = Z.lo; } } while (inp+=16, len-=16); } #endif #else void gcm_gmult_4bit(u64 Xi[2],const u128 Htable[16]); void gcm_ghash_4bit(u64 Xi[2],const u128 Htable[16],const u8 *inp,size_t len); #endif #define GCM_MUL(ctx,Xi) gcm_gmult_4bit(ctx->Xi.u,ctx->Htable) #if defined(GHASH_ASM) || !defined(OPENSSL_SMALL_FOOTPRINT) #define GHASH(ctx,in,len) gcm_ghash_4bit((ctx)->Xi.u,(ctx)->Htable,in,len) /* GHASH_CHUNK is "stride parameter" missioned to mitigate cache * trashing effect. In other words idea is to hash data while it's * still in L1 cache after encryption pass... */ #define GHASH_CHUNK (3*1024) #endif #else /* TABLE_BITS */ static void gcm_gmult_1bit(u64 Xi[2],const u64 H[2]) { u128 V,Z = { 0,0 }; long X; int i,j; const long *xi = (const long *)Xi; V.hi = H[0]; /* H is in host byte order, no byte swapping */ V.lo = H[1]; for (j=0; j<16/sizeof(long); ++j) { if (BYTE_ORDER == LITTLE_ENDIAN) { if (sizeof(long)==8) { #ifdef BSWAP8 X = (long)(BSWAP8(xi[j])); #else const u8 *p = (const u8 *)(xi+j); X = (long)((u64)GETU32(p)<<32|GETU32(p+4)); #endif } else { const u8 *p = (const u8 *)(xi+j); X = (long)GETU32(p); } } else X = xi[j]; for (i=0; i<8*sizeof(long); ++i, X<<=1) { u64 M = (u64)(X>>(8*sizeof(long)-1)); Z.hi ^= V.hi&M; Z.lo ^= V.lo&M; REDUCE1BIT(V); } } if (BYTE_ORDER == LITTLE_ENDIAN) { #ifdef BSWAP8 Xi[0] = BSWAP8(Z.hi); Xi[1] = BSWAP8(Z.lo); #else u8 *p = (u8 *)Xi; u32 v; v = (u32)(Z.hi>>32); PUTU32(p,v); v = (u32)(Z.hi); PUTU32(p+4,v); v = (u32)(Z.lo>>32); PUTU32(p+8,v); v = (u32)(Z.lo); PUTU32(p+12,v); #endif } else { Xi[0] = Z.hi; Xi[1] = Z.lo; } } #define GCM_MUL(ctx,Xi) gcm_gmult_1bit(ctx->Xi.u,ctx->H.u) #endif #if TABLE_BITS==4 && defined(GHASH_ASM) # if !defined(I386_ONLY) && \ (defined(__i386) || defined(__i386__) || \ defined(__x86_64) || defined(__x86_64__) || \ defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64)) # define GHASH_ASM_X86_OR_64 # define GCM_FUNCREF_4BIT extern unsigned int OPENSSL_ia32cap_P[2]; void gcm_init_clmul(u128 Htable[16],const u64 Xi[2]); void gcm_gmult_clmul(u64 Xi[2],const u128 Htable[16]); void gcm_ghash_clmul(u64 Xi[2],const u128 Htable[16],const u8 *inp,size_t len); # if defined(__i386) || defined(__i386__) || defined(_M_IX86) # define GHASH_ASM_X86 void gcm_gmult_4bit_mmx(u64 Xi[2],const u128 Htable[16]); void gcm_ghash_4bit_mmx(u64 Xi[2],const u128 Htable[16],const u8 *inp,size_t len); void gcm_gmult_4bit_x86(u64 Xi[2],const u128 Htable[16]); void gcm_ghash_4bit_x86(u64 Xi[2],const u128 Htable[16],const u8 *inp,size_t len); # endif # elif defined(__arm__) || defined(__arm) # include "arm_arch.h" # if __ARM_ARCH__>=7 # define GHASH_ASM_ARM # define GCM_FUNCREF_4BIT void gcm_gmult_neon(u64 Xi[2],const u128 Htable[16]); void gcm_ghash_neon(u64 Xi[2],const u128 Htable[16],const u8 *inp,size_t len); # endif # endif #endif #ifdef GCM_FUNCREF_4BIT # undef GCM_MUL # define GCM_MUL(ctx,Xi) (*gcm_gmult_p)(ctx->Xi.u,ctx->Htable) # ifdef GHASH # undef GHASH # define GHASH(ctx,in,len) (*gcm_ghash_p)(ctx->Xi.u,ctx->Htable,in,len) # endif #endif void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx,void *key,block128_f block) { memset(ctx,0,sizeof(*ctx)); ctx->block = block; ctx->key = key; (*block)(ctx->H.c,ctx->H.c,key); if (BYTE_ORDER == LITTLE_ENDIAN) { /* H is stored in host byte order */ #ifdef BSWAP8 ctx->H.u[0] = BSWAP8(ctx->H.u[0]); ctx->H.u[1] = BSWAP8(ctx->H.u[1]); #else u8 *p = ctx->H.c; u64 hi,lo; hi = (u64)GETU32(p) <<32|GETU32(p+4); lo = (u64)GETU32(p+8)<<32|GETU32(p+12); ctx->H.u[0] = hi; ctx->H.u[1] = lo; #endif } #if TABLE_BITS==8 gcm_init_8bit(ctx->Htable,ctx->H.u); #elif TABLE_BITS==4 # if defined(GHASH_ASM_X86_OR_64) # if !defined(GHASH_ASM_X86) || defined(OPENSSL_IA32_SSE2) if (OPENSSL_ia32cap_P[0]&(1<<24) && /* check FXSR bit */ OPENSSL_ia32cap_P[1]&(1<<1) ) { /* check PCLMULQDQ bit */ gcm_init_clmul(ctx->Htable,ctx->H.u); ctx->gmult = gcm_gmult_clmul; ctx->ghash = gcm_ghash_clmul; return; } # endif gcm_init_4bit(ctx->Htable,ctx->H.u); # if defined(GHASH_ASM_X86) /* x86 only */ # if defined(OPENSSL_IA32_SSE2) if (OPENSSL_ia32cap_P[0]&(1<<25)) { /* check SSE bit */ # else if (OPENSSL_ia32cap_P[0]&(1<<23)) { /* check MMX bit */ # endif ctx->gmult = gcm_gmult_4bit_mmx; ctx->ghash = gcm_ghash_4bit_mmx; } else { ctx->gmult = gcm_gmult_4bit_x86; ctx->ghash = gcm_ghash_4bit_x86; } # else ctx->gmult = gcm_gmult_4bit; ctx->ghash = gcm_ghash_4bit; # endif # elif defined(GHASH_ASM_ARM) if (OPENSSL_armcap_P & ARMV7_NEON) { ctx->gmult = gcm_gmult_neon; ctx->ghash = gcm_ghash_neon; } else { gcm_init_4bit(ctx->Htable,ctx->H.u); ctx->gmult = gcm_gmult_4bit; ctx->ghash = gcm_ghash_4bit; } # else gcm_init_4bit(ctx->Htable,ctx->H.u); # endif #endif } void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx,const unsigned char *iv,size_t len) { unsigned int ctr; #ifdef GCM_FUNCREF_4BIT void (*gcm_gmult_p)(u64 Xi[2],const u128 Htable[16]) = ctx->gmult; #endif ctx->Yi.u[0] = 0; ctx->Yi.u[1] = 0; ctx->Xi.u[0] = 0; ctx->Xi.u[1] = 0; ctx->len.u[0] = 0; /* AAD length */ ctx->len.u[1] = 0; /* message length */ ctx->ares = 0; ctx->mres = 0; if (len==12) { memcpy(ctx->Yi.c,iv,12); ctx->Yi.c[15]=1; ctr=1; } else { size_t i; u64 len0 = len; while (len>=16) { for (i=0; i<16; ++i) ctx->Yi.c[i] ^= iv[i]; GCM_MUL(ctx,Yi); iv += 16; len -= 16; } if (len) { for (i=0; iYi.c[i] ^= iv[i]; GCM_MUL(ctx,Yi); } len0 <<= 3; if (BYTE_ORDER == LITTLE_ENDIAN) { #ifdef BSWAP8 ctx->Yi.u[1] ^= BSWAP8(len0); #else ctx->Yi.c[8] ^= (u8)(len0>>56); ctx->Yi.c[9] ^= (u8)(len0>>48); ctx->Yi.c[10] ^= (u8)(len0>>40); ctx->Yi.c[11] ^= (u8)(len0>>32); ctx->Yi.c[12] ^= (u8)(len0>>24); ctx->Yi.c[13] ^= (u8)(len0>>16); ctx->Yi.c[14] ^= (u8)(len0>>8); ctx->Yi.c[15] ^= (u8)(len0); #endif } else ctx->Yi.u[1] ^= len0; GCM_MUL(ctx,Yi); if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctr = BSWAP4(ctx->Yi.d[3]); #else ctr = GETU32(ctx->Yi.c+12); #endif else ctr = ctx->Yi.d[3]; } (*ctx->block)(ctx->Yi.c,ctx->EK0.c,ctx->key); ++ctr; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; } int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx,const unsigned char *aad,size_t len) { size_t i; unsigned int n; u64 alen = ctx->len.u[0]; #ifdef GCM_FUNCREF_4BIT void (*gcm_gmult_p)(u64 Xi[2],const u128 Htable[16]) = ctx->gmult; # ifdef GHASH void (*gcm_ghash_p)(u64 Xi[2],const u128 Htable[16], const u8 *inp,size_t len) = ctx->ghash; # endif #endif if (ctx->len.u[1]) return -2; alen += len; if (alen>(U64(1)<<61) || (sizeof(len)==8 && alenlen.u[0] = alen; n = ctx->ares; if (n) { while (n && len) { ctx->Xi.c[n] ^= *(aad++); --len; n = (n+1)%16; } if (n==0) GCM_MUL(ctx,Xi); else { ctx->ares = n; return 0; } } #ifdef GHASH if ((i = (len&(size_t)-16))) { GHASH(ctx,aad,i); aad += i; len -= i; } #else while (len>=16) { for (i=0; i<16; ++i) ctx->Xi.c[i] ^= aad[i]; GCM_MUL(ctx,Xi); aad += 16; len -= 16; } #endif if (len) { n = (unsigned int)len; for (i=0; iXi.c[i] ^= aad[i]; } ctx->ares = n; return 0; } int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, const unsigned char *in, unsigned char *out, size_t len) { unsigned int n, ctr; size_t i; u64 mlen = ctx->len.u[1]; block128_f block = ctx->block; void *key = ctx->key; #ifdef GCM_FUNCREF_4BIT void (*gcm_gmult_p)(u64 Xi[2],const u128 Htable[16]) = ctx->gmult; # ifdef GHASH void (*gcm_ghash_p)(u64 Xi[2],const u128 Htable[16], const u8 *inp,size_t len) = ctx->ghash; # endif #endif #if 0 n = (unsigned int)mlen%16; /* alternative to ctx->mres */ #endif mlen += len; if (mlen>((U64(1)<<36)-32) || (sizeof(len)==8 && mlenlen.u[1] = mlen; if (ctx->ares) { /* First call to encrypt finalizes GHASH(AAD) */ GCM_MUL(ctx,Xi); ctx->ares = 0; } if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctr = BSWAP4(ctx->Yi.d[3]); #else ctr = GETU32(ctx->Yi.c+12); #endif else ctr = ctx->Yi.d[3]; n = ctx->mres; #if !defined(OPENSSL_SMALL_FOOTPRINT) if (16%sizeof(size_t) == 0) do { /* always true actually */ if (n) { while (n && len) { ctx->Xi.c[n] ^= *(out++) = *(in++)^ctx->EKi.c[n]; --len; n = (n+1)%16; } if (n==0) GCM_MUL(ctx,Xi); else { ctx->mres = n; return 0; } } #ifdef __STRICT_ALIGNMENT if (((size_t)in|(size_t)out)%sizeof(size_t) != 0) break; #endif #if defined(GHASH) && defined(GHASH_CHUNK) while (len>=GHASH_CHUNK) { size_t j=GHASH_CHUNK; while (j) { size_t *out_t=(size_t *)out; const size_t *in_t=(const size_t *)in; (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) out_t[i] = in_t[i] ^ ctx->EKi.t[i]; out += 16; in += 16; j -= 16; } GHASH(ctx,out-GHASH_CHUNK,GHASH_CHUNK); len -= GHASH_CHUNK; } if ((i = (len&(size_t)-16))) { size_t j=i; while (len>=16) { size_t *out_t=(size_t *)out; const size_t *in_t=(const size_t *)in; (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) out_t[i] = in_t[i] ^ ctx->EKi.t[i]; out += 16; in += 16; len -= 16; } GHASH(ctx,out-j,j); } #else while (len>=16) { size_t *out_t=(size_t *)out; const size_t *in_t=(const size_t *)in; (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) ctx->Xi.t[i] ^= out_t[i] = in_t[i]^ctx->EKi.t[i]; GCM_MUL(ctx,Xi); out += 16; in += 16; len -= 16; } #endif if (len) { (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; while (len--) { ctx->Xi.c[n] ^= out[n] = in[n]^ctx->EKi.c[n]; ++n; } } ctx->mres = n; return 0; } while(0); #endif for (i=0;iYi.c,ctx->EKi.c,key); ++ctr; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; } ctx->Xi.c[n] ^= out[i] = in[i]^ctx->EKi.c[n]; n = (n+1)%16; if (n==0) GCM_MUL(ctx,Xi); } ctx->mres = n; return 0; } int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, const unsigned char *in, unsigned char *out, size_t len) { unsigned int n, ctr; size_t i; u64 mlen = ctx->len.u[1]; block128_f block = ctx->block; void *key = ctx->key; #ifdef GCM_FUNCREF_4BIT void (*gcm_gmult_p)(u64 Xi[2],const u128 Htable[16]) = ctx->gmult; # ifdef GHASH void (*gcm_ghash_p)(u64 Xi[2],const u128 Htable[16], const u8 *inp,size_t len) = ctx->ghash; # endif #endif mlen += len; if (mlen>((U64(1)<<36)-32) || (sizeof(len)==8 && mlenlen.u[1] = mlen; if (ctx->ares) { /* First call to decrypt finalizes GHASH(AAD) */ GCM_MUL(ctx,Xi); ctx->ares = 0; } if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctr = BSWAP4(ctx->Yi.d[3]); #else ctr = GETU32(ctx->Yi.c+12); #endif else ctr = ctx->Yi.d[3]; n = ctx->mres; #if !defined(OPENSSL_SMALL_FOOTPRINT) if (16%sizeof(size_t) == 0) do { /* always true actually */ if (n) { while (n && len) { u8 c = *(in++); *(out++) = c^ctx->EKi.c[n]; ctx->Xi.c[n] ^= c; --len; n = (n+1)%16; } if (n==0) GCM_MUL (ctx,Xi); else { ctx->mres = n; return 0; } } #ifdef __STRICT_ALIGNMENT if (((size_t)in|(size_t)out)%sizeof(size_t) != 0) break; #endif #if defined(GHASH) && defined(GHASH_CHUNK) while (len>=GHASH_CHUNK) { size_t j=GHASH_CHUNK; GHASH(ctx,in,GHASH_CHUNK); while (j) { size_t *out_t=(size_t *)out; const size_t *in_t=(const size_t *)in; (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) out_t[i] = in_t[i]^ctx->EKi.t[i]; out += 16; in += 16; j -= 16; } len -= GHASH_CHUNK; } if ((i = (len&(size_t)-16))) { GHASH(ctx,in,i); while (len>=16) { size_t *out_t=(size_t *)out; const size_t *in_t=(const size_t *)in; (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) out_t[i] = in_t[i]^ctx->EKi.t[i]; out += 16; in += 16; len -= 16; } } #else while (len>=16) { size_t *out_t=(size_t *)out; const size_t *in_t=(const size_t *)in; (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; for (i=0; i<16/sizeof(size_t); ++i) { size_t c = in[i]; out[i] = c^ctx->EKi.t[i]; ctx->Xi.t[i] ^= c; } GCM_MUL(ctx,Xi); out += 16; in += 16; len -= 16; } #endif if (len) { (*block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; while (len--) { u8 c = in[n]; ctx->Xi.c[n] ^= c; out[n] = c^ctx->EKi.c[n]; ++n; } } ctx->mres = n; return 0; } while(0); #endif for (i=0;iYi.c,ctx->EKi.c,key); ++ctr; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; } c = in[i]; out[i] = c^ctx->EKi.c[n]; ctx->Xi.c[n] ^= c; n = (n+1)%16; if (n==0) GCM_MUL(ctx,Xi); } ctx->mres = n; return 0; } int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, const unsigned char *in, unsigned char *out, size_t len, ctr128_f stream) { unsigned int n, ctr; size_t i; u64 mlen = ctx->len.u[1]; void *key = ctx->key; #ifdef GCM_FUNCREF_4BIT void (*gcm_gmult_p)(u64 Xi[2],const u128 Htable[16]) = ctx->gmult; # ifdef GHASH void (*gcm_ghash_p)(u64 Xi[2],const u128 Htable[16], const u8 *inp,size_t len) = ctx->ghash; # endif #endif mlen += len; if (mlen>((U64(1)<<36)-32) || (sizeof(len)==8 && mlenlen.u[1] = mlen; if (ctx->ares) { /* First call to encrypt finalizes GHASH(AAD) */ GCM_MUL(ctx,Xi); ctx->ares = 0; } if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctr = BSWAP4(ctx->Yi.d[3]); #else ctr = GETU32(ctx->Yi.c+12); #endif else ctr = ctx->Yi.d[3]; n = ctx->mres; if (n) { while (n && len) { ctx->Xi.c[n] ^= *(out++) = *(in++)^ctx->EKi.c[n]; --len; n = (n+1)%16; } if (n==0) GCM_MUL(ctx,Xi); else { ctx->mres = n; return 0; } } #if defined(GHASH) && !defined(OPENSSL_SMALL_FOOTPRINT) while (len>=GHASH_CHUNK) { (*stream)(in,out,GHASH_CHUNK/16,key,ctx->Yi.c); ctr += GHASH_CHUNK/16; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; GHASH(ctx,out,GHASH_CHUNK); out += GHASH_CHUNK; in += GHASH_CHUNK; len -= GHASH_CHUNK; } #endif if ((i = (len&(size_t)-16))) { size_t j=i/16; (*stream)(in,out,j,key,ctx->Yi.c); ctr += (unsigned int)j; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; in += i; len -= i; #if defined(GHASH) GHASH(ctx,out,i); out += i; #else while (j--) { for (i=0;i<16;++i) ctx->Xi.c[i] ^= out[i]; GCM_MUL(ctx,Xi); out += 16; } #endif } if (len) { (*ctx->block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; while (len--) { ctx->Xi.c[n] ^= out[n] = in[n]^ctx->EKi.c[n]; ++n; } } ctx->mres = n; return 0; } int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, const unsigned char *in, unsigned char *out, size_t len,ctr128_f stream) { unsigned int n, ctr; size_t i; u64 mlen = ctx->len.u[1]; void *key = ctx->key; #ifdef GCM_FUNCREF_4BIT void (*gcm_gmult_p)(u64 Xi[2],const u128 Htable[16]) = ctx->gmult; # ifdef GHASH void (*gcm_ghash_p)(u64 Xi[2],const u128 Htable[16], const u8 *inp,size_t len) = ctx->ghash; # endif #endif mlen += len; if (mlen>((U64(1)<<36)-32) || (sizeof(len)==8 && mlenlen.u[1] = mlen; if (ctx->ares) { /* First call to decrypt finalizes GHASH(AAD) */ GCM_MUL(ctx,Xi); ctx->ares = 0; } if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctr = BSWAP4(ctx->Yi.d[3]); #else ctr = GETU32(ctx->Yi.c+12); #endif else ctr = ctx->Yi.d[3]; n = ctx->mres; if (n) { while (n && len) { u8 c = *(in++); *(out++) = c^ctx->EKi.c[n]; ctx->Xi.c[n] ^= c; --len; n = (n+1)%16; } if (n==0) GCM_MUL (ctx,Xi); else { ctx->mres = n; return 0; } } #if defined(GHASH) && !defined(OPENSSL_SMALL_FOOTPRINT) while (len>=GHASH_CHUNK) { GHASH(ctx,in,GHASH_CHUNK); (*stream)(in,out,GHASH_CHUNK/16,key,ctx->Yi.c); ctr += GHASH_CHUNK/16; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; out += GHASH_CHUNK; in += GHASH_CHUNK; len -= GHASH_CHUNK; } #endif if ((i = (len&(size_t)-16))) { size_t j=i/16; #if defined(GHASH) GHASH(ctx,in,i); #else while (j--) { size_t k; for (k=0;k<16;++k) ctx->Xi.c[k] ^= in[k]; GCM_MUL(ctx,Xi); in += 16; } j = i/16; in -= i; #endif (*stream)(in,out,j,key,ctx->Yi.c); ctr += (unsigned int)j; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; out += i; in += i; len -= i; } if (len) { (*ctx->block)(ctx->Yi.c,ctx->EKi.c,key); ++ctr; if (BYTE_ORDER == LITTLE_ENDIAN) #ifdef BSWAP4 ctx->Yi.d[3] = BSWAP4(ctr); #else PUTU32(ctx->Yi.c+12,ctr); #endif else ctx->Yi.d[3] = ctr; while (len--) { u8 c = in[n]; ctx->Xi.c[n] ^= c; out[n] = c^ctx->EKi.c[n]; ++n; } } ctx->mres = n; return 0; } int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx,const unsigned char *tag, size_t len) { u64 alen = ctx->len.u[0]<<3; u64 clen = ctx->len.u[1]<<3; #ifdef GCM_FUNCREF_4BIT void (*gcm_gmult_p)(u64 Xi[2],const u128 Htable[16]) = ctx->gmult; #endif if (ctx->mres || ctx->ares) GCM_MUL(ctx,Xi); if (BYTE_ORDER == LITTLE_ENDIAN) { #ifdef BSWAP8 alen = BSWAP8(alen); clen = BSWAP8(clen); #else u8 *p = ctx->len.c; ctx->len.u[0] = alen; ctx->len.u[1] = clen; alen = (u64)GETU32(p) <<32|GETU32(p+4); clen = (u64)GETU32(p+8)<<32|GETU32(p+12); #endif } ctx->Xi.u[0] ^= alen; ctx->Xi.u[1] ^= clen; GCM_MUL(ctx,Xi); ctx->Xi.u[0] ^= ctx->EK0.u[0]; ctx->Xi.u[1] ^= ctx->EK0.u[1]; if (tag && len<=sizeof(ctx->Xi)) return memcmp(ctx->Xi.c,tag,len); else return -1; } void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len) { CRYPTO_gcm128_finish(ctx, NULL, 0); memcpy(tag, ctx->Xi.c, len<=sizeof(ctx->Xi.c)?len:sizeof(ctx->Xi.c)); } GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block) { GCM128_CONTEXT *ret; if ((ret = malloc(sizeof(GCM128_CONTEXT)))) CRYPTO_gcm128_init(ret,key,block); return ret; } void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx) { if (ctx) { OPENSSL_cleanse(ctx,sizeof(*ctx)); free(ctx); } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/modes/ctr128.c0000644000175000017500000001553312360020706020561 0ustar /* $OpenBSD: ctr128.c,v 1.4 2014/06/12 15:49:30 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 2008 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * */ #include #include "modes_lcl.h" #include #ifndef MODES_DEBUG # ifndef NDEBUG # define NDEBUG # endif #endif #include /* NOTE: the IV/counter CTR mode is big-endian. The code itself * is endian-neutral. */ /* increment counter (128-bit int) by 1 */ static void ctr128_inc(unsigned char *counter) { u32 n=16; u8 c; do { --n; c = counter[n]; ++c; counter[n] = c; if (c) return; } while (n); } #if !defined(OPENSSL_SMALL_FOOTPRINT) static void ctr128_inc_aligned(unsigned char *counter) { size_t *data,c,n; if (BYTE_ORDER == LITTLE_ENDIAN) { ctr128_inc(counter); return; } data = (size_t *)counter; n = 16/sizeof(size_t); do { --n; c = data[n]; ++c; data[n] = c; if (c) return; } while (n); } #endif /* The input encrypted as though 128bit counter mode is being * used. The extra state information to record how much of the * 128bit block we have used is contained in *num, and the * encrypted counter is kept in ecount_buf. Both *num and * ecount_buf must be initialised with zeros before the first * call to CRYPTO_ctr128_encrypt(). * * This algorithm assumes that the counter is in the x lower bits * of the IV (ivec), and that the application has full control over * overflow and the rest of the IV. This implementation takes NO * responsability for checking that the counter doesn't overflow * into the rest of the IV when incremented. */ void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key, unsigned char ivec[16], unsigned char ecount_buf[16], unsigned int *num, block128_f block) { unsigned int n; size_t l=0; assert(in && out && key && ecount_buf && num); assert(*num < 16); n = *num; #if !defined(OPENSSL_SMALL_FOOTPRINT) if (16%sizeof(size_t) == 0) do { /* always true actually */ while (n && len) { *(out++) = *(in++) ^ ecount_buf[n]; --len; n = (n+1) % 16; } #ifdef __STRICT_ALIGNMENT if (((size_t)in|(size_t)out|(size_t)ivec)%sizeof(size_t) != 0) break; #endif while (len>=16) { (*block)(ivec, ecount_buf, key); ctr128_inc_aligned(ivec); for (; n<16; n+=sizeof(size_t)) *(size_t *)(out+n) = *(size_t *)(in+n) ^ *(size_t *)(ecount_buf+n); len -= 16; out += 16; in += 16; n = 0; } if (len) { (*block)(ivec, ecount_buf, key); ctr128_inc_aligned(ivec); while (len--) { out[n] = in[n] ^ ecount_buf[n]; ++n; } } *num = n; return; } while(0); /* the rest would be commonly eliminated by x86* compiler */ #endif while (l=16) { size_t blocks = len/16; /* * 1<<28 is just a not-so-small yet not-so-large number... * Below condition is practically never met, but it has to * be checked for code correctness. */ if (sizeof(size_t)>sizeof(unsigned int) && blocks>(1U<<28)) blocks = (1U<<28); /* * As (*func) operates on 32-bit counter, caller * has to handle overflow. 'if' below detects the * overflow, which is then handled by limiting the * amount of blocks to the exact overflow point... */ ctr32 += (u32)blocks; if (ctr32 < blocks) { blocks -= ctr32; ctr32 = 0; } (*func)(in,out,blocks,key,ivec); /* (*ctr) does not update ivec, caller does: */ PUTU32(ivec+12,ctr32); /* ... overflow was detected, propogate carry. */ if (ctr32 == 0) ctr96_inc(ivec); blocks *= 16; len -= blocks; out += blocks; in += blocks; } if (len) { memset(ecount_buf,0,16); (*func)(ecount_buf,ecount_buf,1,key,ivec); ++ctr32; PUTU32(ivec+12,ctr32); if (ctr32 == 0) ctr96_inc(ivec); while (len--) { out[n] = in[n] ^ ecount_buf[n]; ++n; } } *num=n; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/modes/cts128.c0000644000175000017500000001510112360020706020551 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2008 The OpenSSL Project. All rights reserved. * * Rights for redistribution and usage in source and binary * forms are granted according to the OpenSSL license. */ #include #include "modes_lcl.h" #include #ifndef MODES_DEBUG # ifndef NDEBUG # define NDEBUG # endif #endif #include /* * Trouble with Ciphertext Stealing, CTS, mode is that there is no * common official specification, but couple of cipher/application * specific ones: RFC2040 and RFC3962. Then there is 'Proposal to * Extend CBC Mode By "Ciphertext Stealing"' at NIST site, which * deviates from mentioned RFCs. Most notably it allows input to be * of block length and it doesn't flip the order of the last two * blocks. CTS is being discussed even in ECB context, but it's not * adopted for any known application. This implementation provides * two interfaces: one compliant with above mentioned RFCs and one * compliant with the NIST proposal, both extending CBC mode. */ size_t CRYPTO_cts128_encrypt_block(const unsigned char *in, unsigned char *out, size_t len, const void *key, unsigned char ivec[16], block128_f block) { size_t residue, n; assert (in && out && key && ivec); if (len <= 16) return 0; if ((residue=len%16) == 0) residue = 16; len -= residue; CRYPTO_cbc128_encrypt(in,out,len,key,ivec,block); in += len; out += len; for (n=0; n #include "modes_lcl.h" #include #ifndef MODES_DEBUG # ifndef NDEBUG # define NDEBUG # endif #endif #include #undef STRICT_ALIGNMENT #ifdef __STRICT_ALIGNMENT #define STRICT_ALIGNMENT 1 #else #define STRICT_ALIGNMENT 0 #endif void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key, unsigned char ivec[16], block128_f block) { size_t n; const unsigned char *iv = ivec; assert(in && out && key && ivec); #if !defined(OPENSSL_SMALL_FOOTPRINT) if (STRICT_ALIGNMENT && ((size_t)in|(size_t)out|(size_t)ivec)%sizeof(size_t) != 0) { while (len>=16) { for(n=0; n<16; ++n) out[n] = in[n] ^ iv[n]; (*block)(out, out, key); iv = out; len -= 16; in += 16; out += 16; } } else { while (len>=16) { for(n=0; n<16; n+=sizeof(size_t)) *(size_t*)(out+n) = *(size_t*)(in+n) ^ *(size_t*)(iv+n); (*block)(out, out, key); iv = out; len -= 16; in += 16; out += 16; } } #endif while (len) { for(n=0; n<16 && n=16) { (*block)(in, out, key); for(n=0; n<16; ++n) out[n] ^= iv[n]; iv = in; len -= 16; in += 16; out += 16; } } else if (16%sizeof(size_t) == 0) { /* always true */ while (len>=16) { size_t *out_t=(size_t *)out, *iv_t=(size_t *)iv; (*block)(in, out, key); for(n=0; n<16/sizeof(size_t); n++) out_t[n] ^= iv_t[n]; iv = in; len -= 16; in += 16; out += 16; } } memcpy(ivec,iv,16); } else { if (STRICT_ALIGNMENT && ((size_t)in|(size_t)out|(size_t)ivec)%sizeof(size_t) != 0) { unsigned char c; while (len>=16) { (*block)(in, tmp.c, key); for(n=0; n<16; ++n) { c = in[n]; out[n] = tmp.c[n] ^ ivec[n]; ivec[n] = c; } len -= 16; in += 16; out += 16; } } else if (16%sizeof(size_t) == 0) { /* always true */ while (len>=16) { size_t c, *out_t=(size_t *)out, *ivec_t=(size_t *)ivec; const size_t *in_t=(const size_t *)in; (*block)(in, tmp.c, key); for(n=0; n<16/sizeof(size_t); n++) { c = in_t[n]; out_t[n] = tmp.t[n] ^ ivec_t[n]; ivec_t[n] = c; } len -= 16; in += 16; out += 16; } } } #endif while (len) { unsigned char c; (*block)(in, tmp.c, key); for(n=0; n<16 && n #include #include #if defined(_LP64) typedef long i64; typedef unsigned long u64; #define U64(C) C##UL #else typedef long long i64; typedef unsigned long long u64; #define U64(C) C##ULL #endif typedef unsigned int u32; typedef unsigned char u8; #if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) #if defined(__GNUC__) && __GNUC__>=2 # if defined(__x86_64) || defined(__x86_64__) # define BSWAP8(x) ({ u64 ret=(x); \ asm ("bswapq %0" \ : "+r"(ret)); ret; }) # define BSWAP4(x) ({ u32 ret=(x); \ asm ("bswapl %0" \ : "+r"(ret)); ret; }) # elif (defined(__i386) || defined(__i386__)) && !defined(I386_ONLY) # define BSWAP8(x) ({ u32 lo=(u64)(x)>>32,hi=(x); \ asm ("bswapl %0; bswapl %1" \ : "+r"(hi),"+r"(lo)); \ (u64)hi<<32|lo; }) # define BSWAP4(x) ({ u32 ret=(x); \ asm ("bswapl %0" \ : "+r"(ret)); ret; }) # elif (defined(__arm__) || defined(__arm)) && !defined(__STRICT_ALIGNMENT) # define BSWAP8(x) ({ u32 lo=(u64)(x)>>32,hi=(x); \ asm ("rev %0,%0; rev %1,%1" \ : "+r"(hi),"+r"(lo)); \ (u64)hi<<32|lo; }) # define BSWAP4(x) ({ u32 ret; \ asm ("rev %0,%1" \ : "=r"(ret) : "r"((u32)(x))); \ ret; }) # endif #endif #endif #if defined(BSWAP4) && !defined(__STRICT_ALIGNMENT) #define GETU32(p) BSWAP4(*(const u32 *)(p)) #define PUTU32(p,v) *(u32 *)(p) = BSWAP4(v) #else #define GETU32(p) ((u32)(p)[0]<<24|(u32)(p)[1]<<16|(u32)(p)[2]<<8|(u32)(p)[3]) #define PUTU32(p,v) ((p)[0]=(u8)((v)>>24),(p)[1]=(u8)((v)>>16),(p)[2]=(u8)((v)>>8),(p)[3]=(u8)(v)) #endif /* GCM definitions */ typedef struct { u64 hi,lo; } u128; #ifdef TABLE_BITS #undef TABLE_BITS #endif /* * Even though permitted values for TABLE_BITS are 8, 4 and 1, it should * never be set to 8 [or 1]. For further information see gcm128.c. */ #define TABLE_BITS 4 struct gcm128_context { /* Following 6 names follow names in GCM specification */ union { u64 u[2]; u32 d[4]; u8 c[16]; size_t t[16/sizeof(size_t)]; } Yi,EKi,EK0,len,Xi,H; /* Relative position of Xi, H and pre-computed Htable is used * in some assembler modules, i.e. don't change the order! */ #if TABLE_BITS==8 u128 Htable[256]; #else u128 Htable[16]; void (*gmult)(u64 Xi[2],const u128 Htable[16]); void (*ghash)(u64 Xi[2],const u128 Htable[16],const u8 *inp,size_t len); #endif unsigned int mres, ares; block128_f block; void *key; }; struct xts128_context { void *key1, *key2; block128_f block1,block2; }; struct ccm128_context { union { u64 u[2]; u8 c[16]; } nonce, cmac; u64 blocks; block128_f block; void *key; }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/modes/cfb128.c0000644000175000017500000001560712360020706020525 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2008 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * */ #include #include "modes_lcl.h" #include #ifndef MODES_DEBUG # ifndef NDEBUG # define NDEBUG # endif #endif #include /* The input and output encrypted as though 128bit cfb mode is being * used. The extra state information to record how much of the * 128bit block we have used is contained in *num; */ void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key, unsigned char ivec[16], int *num, int enc, block128_f block) { unsigned int n; size_t l = 0; assert(in && out && key && ivec && num); n = *num; if (enc) { #if !defined(OPENSSL_SMALL_FOOTPRINT) if (16%sizeof(size_t) == 0) do { /* always true actually */ while (n && len) { *(out++) = ivec[n] ^= *(in++); --len; n = (n+1) % 16; } #ifdef __STRICT_ALIGNMENT if (((size_t)in|(size_t)out|(size_t)ivec)%sizeof(size_t) != 0) break; #endif while (len>=16) { (*block)(ivec, ivec, key); for (; n<16; n+=sizeof(size_t)) { *(size_t*)(out+n) = *(size_t*)(ivec+n) ^= *(size_t*)(in+n); } len -= 16; out += 16; in += 16; n = 0; } if (len) { (*block)(ivec, ivec, key); while (len--) { out[n] = ivec[n] ^= in[n]; ++n; } } *num = n; return; } while (0); /* the rest would be commonly eliminated by x86* compiler */ #endif while (l=16) { (*block)(ivec, ivec, key); for (; n<16; n+=sizeof(size_t)) { size_t t = *(size_t*)(in+n); *(size_t*)(out+n) = *(size_t*)(ivec+n) ^ t; *(size_t*)(ivec+n) = t; } len -= 16; out += 16; in += 16; n = 0; } if (len) { (*block)(ivec, ivec, key); while (len--) { unsigned char c; out[n] = ivec[n] ^ (c = in[n]); ivec[n] = c; ++n; } } *num = n; return; } while (0); /* the rest would be commonly eliminated by x86* compiler */ #endif while (l128) return; /* fill in the first half of the new IV with the current IV */ memcpy(ovec,ivec,16); /* construct the new IV */ (*block)(ivec,ivec,key); num = (nbits+7)/8; if (enc) /* encrypt the input */ for(n=0 ; n < num ; ++n) out[n] = (ovec[16+n] = in[n] ^ ivec[n]); else /* decrypt the input */ for(n=0 ; n < num ; ++n) out[n] = (ovec[16+n] = in[n]) ^ ivec[n]; /* shift ovec left... */ rem = nbits%8; num = nbits/8; if(rem==0) memcpy(ivec,ovec+num,16); else for(n=0 ; n < 16 ; ++n) ivec[n] = ovec[n+num]<>(8-rem); /* it is not necessary to cleanse ovec, since the IV is not secret */ } /* N.B. This expects the input to be packed, MS bit first */ void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out, size_t bits, const void *key, unsigned char ivec[16], int *num, int enc, block128_f block) { size_t n; unsigned char c[1],d[1]; assert(in && out && key && ivec && num); assert(*num == 0); for(n=0 ; n> (unsigned int)(n%8)); } } void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out, size_t length, const void *key, unsigned char ivec[16], int *num, int enc, block128_f block) { size_t n; assert(in && out && key && ivec && num); assert(*num == 0); for(n=0 ; n #include "modes_lcl.h" #include #ifndef MODES_DEBUG # ifndef NDEBUG # define NDEBUG # endif #endif #include /* The input and output encrypted as though 128bit ofb mode is being * used. The extra state information to record how much of the * 128bit block we have used is contained in *num; */ void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key, unsigned char ivec[16], int *num, block128_f block) { unsigned int n; size_t l=0; assert(in && out && key && ivec && num); n = *num; #if !defined(OPENSSL_SMALL_FOOTPRINT) if (16%sizeof(size_t) == 0) do { /* always true actually */ while (n && len) { *(out++) = *(in++) ^ ivec[n]; --len; n = (n+1) % 16; } #ifdef __STRICT_ALIGNMENT if (((size_t)in|(size_t)out|(size_t)ivec)%sizeof(size_t) != 0) break; #endif while (len>=16) { (*block)(ivec, ivec, key); for (; n<16; n+=sizeof(size_t)) *(size_t*)(out+n) = *(size_t*)(in+n) ^ *(size_t*)(ivec+n); len -= 16; out += 16; in += 16; n = 0; } if (len) { (*block)(ivec, ivec, key); while (len--) { out[n] = in[n] ^ ivec[n]; ++n; } } *num = n; return; } while(0); /* the rest would be commonly eliminated by x86* compiler */ #endif while (l #include #include "cryptlib.h" const char * SSLeay_version(int t) { switch (t) { case SSLEAY_VERSION: return OPENSSL_VERSION_TEXT; case SSLEAY_BUILT_ON: return("built on: date not available"); case SSLEAY_CFLAGS: return("compiler: information not available"); case SSLEAY_PLATFORM: return("platform: information not available"); case SSLEAY_DIR: return "OPENSSLDIR: \"" OPENSSLDIR "\""; } return("not available"); } unsigned long SSLeay(void) { return (SSLEAY_VERSION_NUMBER); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pem/0000755000000000000000000000000012666635521020633 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/pem/pem_lib.c0000644000175000017500000005022012360020706020607 0ustar /* $OpenBSD: pem_lib.c,v 1.32 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_DES #include #endif #ifndef OPENSSL_NO_ENGINE #include #endif #include "asn1_locl.h" #define MIN_LENGTH 4 static int load_iv(char **fromp, unsigned char *to, int num); static int check_pem(const char *nm, const char *name); int pem_check_suffix(const char *pem_str, const char *suffix); int PEM_def_callback(char *buf, int num, int w, void *key) { int i, j; const char *prompt; if (key) { i = strlen(key); i = (i > num) ? num : i; memcpy(buf, key, i); return (i); } prompt = EVP_get_pw_prompt(); if (prompt == NULL) prompt = "Enter PEM pass phrase:"; for (;;) { i = EVP_read_pw_string_min(buf, MIN_LENGTH, num, prompt, w); if (i != 0) { PEMerr(PEM_F_PEM_DEF_CALLBACK, PEM_R_PROBLEMS_GETTING_PASSWORD); memset(buf, 0, num); return (-1); } j = strlen(buf); if (j < MIN_LENGTH) { fprintf(stderr, "phrase is too short, needs to be at least %d chars\n", MIN_LENGTH); } else break; } return (j); } void PEM_proc_type(char *buf, int type) { const char *str; if (type == PEM_TYPE_ENCRYPTED) str = "ENCRYPTED"; else if (type == PEM_TYPE_MIC_CLEAR) str = "MIC-CLEAR"; else if (type == PEM_TYPE_MIC_ONLY) str = "MIC-ONLY"; else str = "BAD-TYPE"; strlcat(buf, "Proc-Type: 4,", PEM_BUFSIZE); strlcat(buf, str, PEM_BUFSIZE); strlcat(buf, "\n", PEM_BUFSIZE); } void PEM_dek_info(char *buf, const char *type, int len, char *str) { static const unsigned char map[17] = "0123456789ABCDEF"; long i; int j; strlcat(buf, "DEK-Info: ", PEM_BUFSIZE); strlcat(buf, type, PEM_BUFSIZE); strlcat(buf, ",", PEM_BUFSIZE); j = strlen(buf); if (j + (len * 2) + 1 > PEM_BUFSIZE) return; for (i = 0; i < len; i++) { buf[j + i * 2] = map[(str[i] >> 4) & 0x0f]; buf[j + i * 2 + 1] = map[(str[i]) & 0x0f]; } buf[j + i * 2] = '\n'; buf[j + i * 2 + 1] = '\0'; } void * PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, pem_password_cb *cb, void *u) { BIO *b; void *ret; if ((b = BIO_new(BIO_s_file())) == NULL) { PEMerr(PEM_F_PEM_ASN1_READ, ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, fp, BIO_NOCLOSE); ret = PEM_ASN1_read_bio(d2i, name, b, x, cb, u); BIO_free(b); return (ret); } static int check_pem(const char *nm, const char *name) { /* Normal matching nm and name */ if (!strcmp(nm, name)) return 1; /* Make PEM_STRING_EVP_PKEY match any private key */ if (!strcmp(name, PEM_STRING_EVP_PKEY)) { int slen; const EVP_PKEY_ASN1_METHOD *ameth; if (!strcmp(nm, PEM_STRING_PKCS8)) return 1; if (!strcmp(nm, PEM_STRING_PKCS8INF)) return 1; slen = pem_check_suffix(nm, "PRIVATE KEY"); if (slen > 0) { /* NB: ENGINE implementations wont contain * a deprecated old private key decode function * so don't look for them. */ ameth = EVP_PKEY_asn1_find_str(NULL, nm, slen); if (ameth && ameth->old_priv_decode) return 1; } return 0; } if (!strcmp(name, PEM_STRING_PARAMETERS)) { int slen; const EVP_PKEY_ASN1_METHOD *ameth; slen = pem_check_suffix(nm, "PARAMETERS"); if (slen > 0) { ENGINE *e; ameth = EVP_PKEY_asn1_find_str(&e, nm, slen); if (ameth) { int r; if (ameth->param_decode) r = 1; else r = 0; #ifndef OPENSSL_NO_ENGINE if (e) ENGINE_finish(e); #endif return r; } } return 0; } /* Permit older strings */ if (!strcmp(nm, PEM_STRING_X509_OLD) && !strcmp(name, PEM_STRING_X509)) return 1; if (!strcmp(nm, PEM_STRING_X509_REQ_OLD) && !strcmp(name, PEM_STRING_X509_REQ)) return 1; /* Allow normal certs to be read as trusted certs */ if (!strcmp(nm, PEM_STRING_X509) && !strcmp(name, PEM_STRING_X509_TRUSTED)) return 1; if (!strcmp(nm, PEM_STRING_X509_OLD) && !strcmp(name, PEM_STRING_X509_TRUSTED)) return 1; /* Some CAs use PKCS#7 with CERTIFICATE headers */ if (!strcmp(nm, PEM_STRING_X509) && !strcmp(name, PEM_STRING_PKCS7)) return 1; if (!strcmp(nm, PEM_STRING_PKCS7_SIGNED) && !strcmp(name, PEM_STRING_PKCS7)) return 1; #ifndef OPENSSL_NO_CMS if (!strcmp(nm, PEM_STRING_X509) && !strcmp(name, PEM_STRING_CMS)) return 1; /* Allow CMS to be read from PKCS#7 headers */ if (!strcmp(nm, PEM_STRING_PKCS7) && !strcmp(name, PEM_STRING_CMS)) return 1; #endif return 0; } int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp, pem_password_cb *cb, void *u) { EVP_CIPHER_INFO cipher; char *nm = NULL, *header = NULL; unsigned char *data = NULL; long len; int ret = 0; for (;;) { if (!PEM_read_bio(bp, &nm, &header, &data, &len)) { if (ERR_GET_REASON(ERR_peek_error()) == PEM_R_NO_START_LINE) ERR_asprintf_error_data("Expecting: %s", name); return 0; } if (check_pem(nm, name)) break; free(nm); free(header); free(data); } if (!PEM_get_EVP_CIPHER_INFO(header, &cipher)) goto err; if (!PEM_do_header(&cipher, data, &len, cb, u)) goto err; *pdata = data; *plen = len; if (pnm) *pnm = nm; ret = 1; err: if (!ret || !pnm) free(nm); free(header); if (!ret) free(data); return ret; } int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp, void *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *callback, void *u) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { PEMerr(PEM_F_PEM_ASN1_WRITE, ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, fp, BIO_NOCLOSE); ret = PEM_ASN1_write_bio(i2d, name, b, x, enc, kstr, klen, callback, u); BIO_free(b); return (ret); } int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *callback, void *u) { EVP_CIPHER_CTX ctx; int dsize = 0, i, j, ret = 0; unsigned char *p, *data = NULL; const char *objstr = NULL; char buf[PEM_BUFSIZE]; unsigned char key[EVP_MAX_KEY_LENGTH]; unsigned char iv[EVP_MAX_IV_LENGTH]; if (enc != NULL) { objstr = OBJ_nid2sn(EVP_CIPHER_nid(enc)); if (objstr == NULL) { PEMerr(PEM_F_PEM_ASN1_WRITE_BIO, PEM_R_UNSUPPORTED_CIPHER); goto err; } } if ((dsize = i2d(x, NULL)) < 0) { PEMerr(PEM_F_PEM_ASN1_WRITE_BIO, ERR_R_ASN1_LIB); dsize = 0; goto err; } /* dzise + 8 bytes are needed */ /* actually it needs the cipher block size extra... */ data = malloc((unsigned int)dsize + 20); if (data == NULL) { PEMerr(PEM_F_PEM_ASN1_WRITE_BIO, ERR_R_MALLOC_FAILURE); goto err; } p = data; i = i2d(x, &p); if (enc != NULL) { if (kstr == NULL) { if (callback == NULL) klen = PEM_def_callback(buf, PEM_BUFSIZE, 1, u); else klen = (*callback)(buf, PEM_BUFSIZE, 1, u); if (klen <= 0) { PEMerr(PEM_F_PEM_ASN1_WRITE_BIO, PEM_R_READ_KEY); goto err; } kstr = (unsigned char *)buf; } OPENSSL_assert(enc->iv_len <= (int)sizeof(iv)); if (RAND_pseudo_bytes(iv, enc->iv_len) < 0) /* Generate a salt */ goto err; /* The 'iv' is used as the iv and as a salt. It is * NOT taken from the BytesToKey function */ if (!EVP_BytesToKey(enc, EVP_md5(), iv, kstr, klen, 1, key, NULL)) goto err; if (kstr == (unsigned char *)buf) OPENSSL_cleanse(buf, PEM_BUFSIZE); OPENSSL_assert(strlen(objstr) + 23 + 2 * enc->iv_len + 13 <= sizeof buf); buf[0] = '\0'; PEM_proc_type(buf, PEM_TYPE_ENCRYPTED); PEM_dek_info(buf, objstr, enc->iv_len, (char *)iv); /* k=strlen(buf); */ EVP_CIPHER_CTX_init(&ctx); ret = 1; if (!EVP_EncryptInit_ex(&ctx, enc, NULL, key, iv) || !EVP_EncryptUpdate(&ctx, data, &j, data, i) || !EVP_EncryptFinal_ex(&ctx, &(data[j]), &i)) ret = 0; EVP_CIPHER_CTX_cleanup(&ctx); if (ret == 0) goto err; i += j; } else { ret = 1; buf[0] = '\0'; } i = PEM_write_bio(bp, name, buf, data, i); if (i <= 0) ret = 0; err: OPENSSL_cleanse(key, sizeof(key)); OPENSSL_cleanse(iv, sizeof(iv)); OPENSSL_cleanse((char *)&ctx, sizeof(ctx)); OPENSSL_cleanse(buf, PEM_BUFSIZE); if (data != NULL) { OPENSSL_cleanse(data, (unsigned int)dsize); free(data); } return (ret); } int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *plen, pem_password_cb *callback, void *u) { int i, j, o, klen; long len; EVP_CIPHER_CTX ctx; unsigned char key[EVP_MAX_KEY_LENGTH]; char buf[PEM_BUFSIZE]; len = *plen; if (cipher->cipher == NULL) return (1); if (callback == NULL) klen = PEM_def_callback(buf, PEM_BUFSIZE, 0, u); else klen = callback(buf, PEM_BUFSIZE, 0, u); if (klen <= 0) { PEMerr(PEM_F_PEM_DO_HEADER, PEM_R_BAD_PASSWORD_READ); return (0); } if (!EVP_BytesToKey(cipher->cipher, EVP_md5(), &(cipher->iv[0]), (unsigned char *)buf, klen, 1, key, NULL)) return 0; j = (int)len; EVP_CIPHER_CTX_init(&ctx); o = EVP_DecryptInit_ex(&ctx, cipher->cipher, NULL, key, &(cipher->iv[0])); if (o) o = EVP_DecryptUpdate(&ctx, data, &i, data, j); if (o) o = EVP_DecryptFinal_ex(&ctx, &(data[i]), &j); EVP_CIPHER_CTX_cleanup(&ctx); OPENSSL_cleanse((char *)buf, sizeof(buf)); OPENSSL_cleanse((char *)key, sizeof(key)); if (!o) { PEMerr(PEM_F_PEM_DO_HEADER, PEM_R_BAD_DECRYPT); return (0); } *plen = j + i; return (1); } int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher) { const EVP_CIPHER *enc = NULL; char *p, c; char **header_pp = &header; cipher->cipher = NULL; if ((header == NULL) || (*header == '\0') || (*header == '\n')) return (1); if (strncmp(header, "Proc-Type: ", 11) != 0) { PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_NOT_PROC_TYPE); return (0); } header += 11; if (*header != '4') return (0); header++; if (*header != ',') return (0); header++; if (strncmp(header, "ENCRYPTED", 9) != 0) { PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_NOT_ENCRYPTED); return (0); } for (; (*header != '\n') && (*header != '\0'); header++) ; if (*header == '\0') { PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_SHORT_HEADER); return (0); } header++; if (strncmp(header, "DEK-Info: ", 10) != 0) { PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_NOT_DEK_INFO); return (0); } header += 10; p = header; for (;;) { c= *header; if (!( ((c >= 'A') && (c <= 'Z')) || (c == '-') || ((c >= '0') && (c <= '9')))) break; header++; } *header = '\0'; cipher->cipher = enc = EVP_get_cipherbyname(p); *header = c; header++; if (enc == NULL) { PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_UNSUPPORTED_ENCRYPTION); return (0); } if (!load_iv(header_pp, &(cipher->iv[0]), enc->iv_len)) return (0); return (1); } static int load_iv(char **fromp, unsigned char *to, int num) { int v, i; char *from; from= *fromp; for (i = 0; i < num; i++) to[i] = 0; num *= 2; for (i = 0; i < num; i++) { if ((*from >= '0') && (*from <= '9')) v = *from - '0'; else if ((*from >= 'A') && (*from <= 'F')) v = *from - 'A' + 10; else if ((*from >= 'a') && (*from <= 'f')) v = *from - 'a' + 10; else { PEMerr(PEM_F_LOAD_IV, PEM_R_BAD_IV_CHARS); return (0); } from++; to[i / 2] |= v << (long)((!(i & 1)) * 4); } *fromp = from; return (1); } int PEM_write(FILE *fp, char *name, char *header, unsigned char *data, long len) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { PEMerr(PEM_F_PEM_WRITE, ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, fp, BIO_NOCLOSE); ret = PEM_write_bio(b, name, header, data, len); BIO_free(b); return (ret); } int PEM_write_bio(BIO *bp, const char *name, char *header, unsigned char *data, long len) { int nlen, n, i, j, outl; unsigned char *buf = NULL; EVP_ENCODE_CTX ctx; int reason = ERR_R_BUF_LIB; EVP_EncodeInit(&ctx); nlen = strlen(name); if ((BIO_write(bp, "-----BEGIN ", 11) != 11) || (BIO_write(bp, name, nlen) != nlen) || (BIO_write(bp, "-----\n", 6) != 6)) goto err; i = strlen(header); if (i > 0) { if ((BIO_write(bp, header, i) != i) || (BIO_write(bp, "\n", 1) != 1)) goto err; } buf = reallocarray(NULL, PEM_BUFSIZE, 8); if (buf == NULL) { reason = ERR_R_MALLOC_FAILURE; goto err; } i = j = 0; while (len > 0) { n = (int)((len > (PEM_BUFSIZE * 5)) ? (PEM_BUFSIZE * 5) : len); EVP_EncodeUpdate(&ctx, buf, &outl, &(data[j]), n); if ((outl) && (BIO_write(bp, (char *)buf, outl) != outl)) goto err; i += outl; len -= n; j += n; } EVP_EncodeFinal(&ctx, buf, &outl); if ((outl > 0) && (BIO_write(bp, (char *)buf, outl) != outl)) goto err; OPENSSL_cleanse(buf, PEM_BUFSIZE * 8); free(buf); buf = NULL; if ((BIO_write(bp, "-----END ", 9) != 9) || (BIO_write(bp, name, nlen) != nlen) || (BIO_write(bp, "-----\n", 6) != 6)) goto err; return (i + outl); err: if (buf) { OPENSSL_cleanse(buf, PEM_BUFSIZE * 8); free(buf); } PEMerr(PEM_F_PEM_WRITE_BIO, reason); return (0); } int PEM_read(FILE *fp, char **name, char **header, unsigned char **data, long *len) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { PEMerr(PEM_F_PEM_READ, ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, fp, BIO_NOCLOSE); ret = PEM_read_bio(b, name, header, data, len); BIO_free(b); return (ret); } int PEM_read_bio(BIO *bp, char **name, char **header, unsigned char **data, long *len) { EVP_ENCODE_CTX ctx; int end = 0, i, k, bl = 0, hl = 0, nohead = 0; char buf[256]; BUF_MEM *nameB; BUF_MEM *headerB; BUF_MEM *dataB, *tmpB; nameB = BUF_MEM_new(); headerB = BUF_MEM_new(); dataB = BUF_MEM_new(); if ((nameB == NULL) || (headerB == NULL) || (dataB == NULL)) { BUF_MEM_free(nameB); BUF_MEM_free(headerB); BUF_MEM_free(dataB); PEMerr(PEM_F_PEM_READ_BIO, ERR_R_MALLOC_FAILURE); return (0); } buf[254] = '\0'; for (;;) { i = BIO_gets(bp, buf, 254); if (i <= 0) { PEMerr(PEM_F_PEM_READ_BIO, PEM_R_NO_START_LINE); goto err; } while ((i >= 0) && (buf[i] <= ' ')) i--; buf[++i] = '\n'; buf[++i] = '\0'; if (strncmp(buf, "-----BEGIN ", 11) == 0) { i = strlen(&(buf[11])); if (strncmp(&(buf[11 + i - 6]), "-----\n", 6) != 0) continue; if (!BUF_MEM_grow(nameB, i + 9)) { PEMerr(PEM_F_PEM_READ_BIO, ERR_R_MALLOC_FAILURE); goto err; } memcpy(nameB->data, &(buf[11]), i - 6); nameB->data[i - 6] = '\0'; break; } } hl = 0; if (!BUF_MEM_grow(headerB, 256)) { PEMerr(PEM_F_PEM_READ_BIO, ERR_R_MALLOC_FAILURE); goto err; } headerB->data[0] = '\0'; for (;;) { i = BIO_gets(bp, buf, 254); if (i <= 0) break; while ((i >= 0) && (buf[i] <= ' ')) i--; buf[++i] = '\n'; buf[++i] = '\0'; if (buf[0] == '\n') break; if (!BUF_MEM_grow(headerB, hl + i + 9)) { PEMerr(PEM_F_PEM_READ_BIO, ERR_R_MALLOC_FAILURE); goto err; } if (strncmp(buf, "-----END ", 9) == 0) { nohead = 1; break; } memcpy(&(headerB->data[hl]), buf, i); headerB->data[hl + i] = '\0'; hl += i; } bl = 0; if (!BUF_MEM_grow(dataB, 1024)) { PEMerr(PEM_F_PEM_READ_BIO, ERR_R_MALLOC_FAILURE); goto err; } dataB->data[0] = '\0'; if (!nohead) { for (;;) { i = BIO_gets(bp, buf, 254); if (i <= 0) break; while ((i >= 0) && (buf[i] <= ' ')) i--; buf[++i] = '\n'; buf[++i] = '\0'; if (i != 65) end = 1; if (strncmp(buf, "-----END ", 9) == 0) break; if (i > 65) break; if (!BUF_MEM_grow_clean(dataB, i + bl + 9)) { PEMerr(PEM_F_PEM_READ_BIO, ERR_R_MALLOC_FAILURE); goto err; } memcpy(&(dataB->data[bl]), buf, i); dataB->data[bl + i] = '\0'; bl += i; if (end) { buf[0] = '\0'; i = BIO_gets(bp, buf, 254); if (i <= 0) break; while ((i >= 0) && (buf[i] <= ' ')) i--; buf[++i] = '\n'; buf[++i] = '\0'; break; } } } else { tmpB = headerB; headerB = dataB; dataB = tmpB; bl = hl; } i = strlen(nameB->data); if ((strncmp(buf, "-----END ", 9) != 0) || (strncmp(nameB->data, &(buf[9]), i) != 0) || (strncmp(&(buf[9 + i]), "-----\n", 6) != 0)) { PEMerr(PEM_F_PEM_READ_BIO, PEM_R_BAD_END_LINE); goto err; } EVP_DecodeInit(&ctx); i = EVP_DecodeUpdate(&ctx, (unsigned char *)dataB->data, &bl, (unsigned char *)dataB->data, bl); if (i < 0) { PEMerr(PEM_F_PEM_READ_BIO, PEM_R_BAD_BASE64_DECODE); goto err; } i = EVP_DecodeFinal(&ctx, (unsigned char *)&(dataB->data[bl]), &k); if (i < 0) { PEMerr(PEM_F_PEM_READ_BIO, PEM_R_BAD_BASE64_DECODE); goto err; } bl += k; if (bl == 0) goto err; *name = nameB->data; *header = headerB->data; *data = (unsigned char *)dataB->data; *len = bl; free(nameB); free(headerB); free(dataB); return (1); err: BUF_MEM_free(nameB); BUF_MEM_free(headerB); BUF_MEM_free(dataB); return (0); } /* Check pem string and return prefix length. * If for example the pem_str == "RSA PRIVATE KEY" and suffix = "PRIVATE KEY" * the return value is 3 for the string "RSA". */ int pem_check_suffix(const char *pem_str, const char *suffix) { int pem_len = strlen(pem_str); int suffix_len = strlen(suffix); const char *p; if (suffix_len + 1 >= pem_len) return 0; p = pem_str + pem_len - suffix_len; if (strcmp(p, suffix)) return 0; p--; if (*p != ' ') return 0; return p - pem_str; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pem/pem_pk8.c0000644000175000017500000002014112360020706020542 0ustar /* $OpenBSD: pem_pk8.c,v 1.6 2014/06/12 15:49:30 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #include static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u); static int do_pk8pkey_fp(FILE *bp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u); /* These functions write a private key in PKCS#8 format: it is a "drop in" * replacement for PEM_write_bio_PrivateKey() and friends. As usual if 'enc' * is NULL then it uses the unencrypted private key form. The 'nid' versions * uses PKCS#5 v1.5 PBE algorithms whereas the others use PKCS#5 v2.0. */ int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u) { return do_pk8pkey(bp, x, 0, nid, NULL, kstr, klen, cb, u); } int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u) { return do_pk8pkey(bp, x, 0, -1, enc, kstr, klen, cb, u); } int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u) { return do_pk8pkey(bp, x, 1, -1, enc, kstr, klen, cb, u); } int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u) { return do_pk8pkey(bp, x, 1, nid, NULL, kstr, klen, cb, u); } static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u) { X509_SIG *p8; PKCS8_PRIV_KEY_INFO *p8inf; char buf[PEM_BUFSIZE]; int ret; if (!(p8inf = EVP_PKEY2PKCS8(x))) { PEMerr(PEM_F_DO_PK8PKEY, PEM_R_ERROR_CONVERTING_PRIVATE_KEY); return 0; } if (enc || (nid != -1)) { if (!kstr) { if (!cb) klen = PEM_def_callback(buf, PEM_BUFSIZE, 1, u); else klen = cb(buf, PEM_BUFSIZE, 1, u); if (klen <= 0) { PEMerr(PEM_F_DO_PK8PKEY, PEM_R_READ_KEY); PKCS8_PRIV_KEY_INFO_free(p8inf); return 0; } kstr = buf; } p8 = PKCS8_encrypt(nid, enc, kstr, klen, NULL, 0, 0, p8inf); if (kstr == buf) OPENSSL_cleanse(buf, klen); PKCS8_PRIV_KEY_INFO_free(p8inf); if (isder) ret = i2d_PKCS8_bio(bp, p8); else ret = PEM_write_bio_PKCS8(bp, p8); X509_SIG_free(p8); return ret; } else { if (isder) ret = i2d_PKCS8_PRIV_KEY_INFO_bio(bp, p8inf); else ret = PEM_write_bio_PKCS8_PRIV_KEY_INFO(bp, p8inf); PKCS8_PRIV_KEY_INFO_free(p8inf); return ret; } } EVP_PKEY * d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u) { PKCS8_PRIV_KEY_INFO *p8inf = NULL; X509_SIG *p8 = NULL; int klen; EVP_PKEY *ret; char psbuf[PEM_BUFSIZE]; p8 = d2i_PKCS8_bio(bp, NULL); if (!p8) return NULL; if (cb) klen = cb(psbuf, PEM_BUFSIZE, 0, u); else klen = PEM_def_callback(psbuf, PEM_BUFSIZE, 0, u); if (klen <= 0) { PEMerr(PEM_F_D2I_PKCS8PRIVATEKEY_BIO, PEM_R_BAD_PASSWORD_READ); X509_SIG_free(p8); return NULL; } p8inf = PKCS8_decrypt(p8, psbuf, klen); X509_SIG_free(p8); if (!p8inf) return NULL; ret = EVP_PKCS82PKEY(p8inf); PKCS8_PRIV_KEY_INFO_free(p8inf); if (!ret) return NULL; if (x) { if (*x) EVP_PKEY_free(*x); *x = ret; } return ret; } int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u) { return do_pk8pkey_fp(fp, x, 1, -1, enc, kstr, klen, cb, u); } int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u) { return do_pk8pkey_fp(fp, x, 1, nid, NULL, kstr, klen, cb, u); } int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u) { return do_pk8pkey_fp(fp, x, 0, nid, NULL, kstr, klen, cb, u); } int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u) { return do_pk8pkey_fp(fp, x, 0, -1, enc, kstr, klen, cb, u); } static int do_pk8pkey_fp(FILE *fp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u) { BIO *bp; int ret; if (!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) { PEMerr(PEM_F_DO_PK8PKEY_FP, ERR_R_BUF_LIB); return (0); } ret = do_pk8pkey(bp, x, isder, nid, enc, kstr, klen, cb, u); BIO_free(bp); return ret; } EVP_PKEY * d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u) { BIO *bp; EVP_PKEY *ret; if (!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) { PEMerr(PEM_F_D2I_PKCS8PRIVATEKEY_FP, ERR_R_BUF_LIB); return NULL; } ret = d2i_PKCS8PrivateKey_bio(bp, x, cb, u); BIO_free(bp); return ret; } IMPLEMENT_PEM_rw(PKCS8, X509_SIG, PEM_STRING_PKCS8, X509_SIG) IMPLEMENT_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO, PEM_STRING_PKCS8INF, PKCS8_PRIV_KEY_INFO) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pem/pem_xaux.c0000644000175000017500000000602412360020706021031 0ustar /* $OpenBSD: pem_xaux.c,v 1.6 2014/06/12 15:49:30 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include IMPLEMENT_PEM_rw(X509_AUX, X509, PEM_STRING_X509_TRUSTED, X509_AUX) IMPLEMENT_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR, PEM_STRING_X509_PAIR, X509_CERT_PAIR) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pem/pem_all.c0000644000175000017500000002350412360020706020616 0ustar /* $OpenBSD: pem_all.c,v 1.14 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #ifndef OPENSSL_NO_DH #include #endif #ifndef OPENSSL_NO_DSA #include #endif #ifndef OPENSSL_NO_RSA #include #endif #ifndef OPENSSL_NO_RSA static RSA *pkey_get_rsa(EVP_PKEY *key, RSA **rsa); #endif #ifndef OPENSSL_NO_DSA static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa); #endif #ifndef OPENSSL_NO_EC static EC_KEY *pkey_get_eckey(EVP_PKEY *key, EC_KEY **eckey); #endif IMPLEMENT_PEM_rw(X509_REQ, X509_REQ, PEM_STRING_X509_REQ, X509_REQ) IMPLEMENT_PEM_write(X509_REQ_NEW, X509_REQ, PEM_STRING_X509_REQ_OLD, X509_REQ) IMPLEMENT_PEM_rw(X509_CRL, X509_CRL, PEM_STRING_X509_CRL, X509_CRL) IMPLEMENT_PEM_rw(PKCS7, PKCS7, PEM_STRING_PKCS7, PKCS7) IMPLEMENT_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE, PEM_STRING_X509, NETSCAPE_CERT_SEQUENCE) #ifndef OPENSSL_NO_RSA /* We treat RSA or DSA private keys as a special case. * * For private keys we read in an EVP_PKEY structure with * PEM_read_bio_PrivateKey() and extract the relevant private * key: this means can handle "traditional" and PKCS#8 formats * transparently. */ static RSA * pkey_get_rsa(EVP_PKEY *key, RSA **rsa) { RSA *rtmp; if (!key) return NULL; rtmp = EVP_PKEY_get1_RSA(key); EVP_PKEY_free(key); if (!rtmp) return NULL; if (rsa) { RSA_free(*rsa); *rsa = rtmp; } return rtmp; } RSA * PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **rsa, pem_password_cb *cb, void *u) { EVP_PKEY *pktmp; pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u); return pkey_get_rsa(pktmp, rsa); } RSA * PEM_read_RSAPrivateKey(FILE *fp, RSA **rsa, pem_password_cb *cb, void *u) { EVP_PKEY *pktmp; pktmp = PEM_read_PrivateKey(fp, NULL, cb, u); return pkey_get_rsa(pktmp, rsa); } IMPLEMENT_PEM_write_cb_const(RSAPrivateKey, RSA, PEM_STRING_RSA, RSAPrivateKey) IMPLEMENT_PEM_rw_const(RSAPublicKey, RSA, PEM_STRING_RSA_PUBLIC, RSAPublicKey) IMPLEMENT_PEM_rw(RSA_PUBKEY, RSA, PEM_STRING_PUBLIC, RSA_PUBKEY) #endif #ifndef OPENSSL_NO_DSA static DSA * pkey_get_dsa(EVP_PKEY *key, DSA **dsa) { DSA *dtmp; if (!key) return NULL; dtmp = EVP_PKEY_get1_DSA(key); EVP_PKEY_free(key); if (!dtmp) return NULL; if (dsa) { DSA_free(*dsa); *dsa = dtmp; } return dtmp; } DSA * PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **dsa, pem_password_cb *cb, void *u) { EVP_PKEY *pktmp; pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u); return pkey_get_dsa(pktmp, dsa); /* will free pktmp */ } IMPLEMENT_PEM_write_cb_const(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey) IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY) DSA * PEM_read_DSAPrivateKey(FILE *fp, DSA **dsa, pem_password_cb *cb, void *u) { EVP_PKEY *pktmp; pktmp = PEM_read_PrivateKey(fp, NULL, cb, u); return pkey_get_dsa(pktmp, dsa); /* will free pktmp */ } IMPLEMENT_PEM_rw_const(DSAparams, DSA, PEM_STRING_DSAPARAMS, DSAparams) #endif #ifndef OPENSSL_NO_EC static EC_KEY * pkey_get_eckey(EVP_PKEY *key, EC_KEY **eckey) { EC_KEY *dtmp; if (!key) return NULL; dtmp = EVP_PKEY_get1_EC_KEY(key); EVP_PKEY_free(key); if (!dtmp) return NULL; if (eckey) { EC_KEY_free(*eckey); *eckey = dtmp; } return dtmp; } EC_KEY * PEM_read_bio_ECPrivateKey(BIO *bp, EC_KEY **key, pem_password_cb *cb, void *u) { EVP_PKEY *pktmp; pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u); return pkey_get_eckey(pktmp, key); /* will free pktmp */ } IMPLEMENT_PEM_rw_const(ECPKParameters, EC_GROUP, PEM_STRING_ECPARAMETERS, ECPKParameters) IMPLEMENT_PEM_write_cb(ECPrivateKey, EC_KEY, PEM_STRING_ECPRIVATEKEY, ECPrivateKey) IMPLEMENT_PEM_rw(EC_PUBKEY, EC_KEY, PEM_STRING_PUBLIC, EC_PUBKEY) EC_KEY * PEM_read_ECPrivateKey(FILE *fp, EC_KEY **eckey, pem_password_cb *cb, void *u) { EVP_PKEY *pktmp; pktmp = PEM_read_PrivateKey(fp, NULL, cb, u); return pkey_get_eckey(pktmp, eckey); /* will free pktmp */ } #endif #ifndef OPENSSL_NO_DH IMPLEMENT_PEM_rw_const(DHparams, DH, PEM_STRING_DHPARAMS, DHparams) #endif IMPLEMENT_PEM_rw(PUBKEY, EVP_PKEY, PEM_STRING_PUBLIC, PUBKEY) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pem/pem_pkey.c0000644000175000017500000001674612360020706021030 0ustar /* $OpenBSD: pem_pkey.c,v 1.16 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif #include "asn1_locl.h" int pem_check_suffix(const char *pem_str, const char *suffix); EVP_PKEY * PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u) { char *nm = NULL; const unsigned char *p = NULL; unsigned char *data = NULL; long len; int slen; EVP_PKEY *ret = NULL; if (!PEM_bytes_read_bio(&data, &len, &nm, PEM_STRING_EVP_PKEY, bp, cb, u)) return NULL; p = data; if (strcmp(nm, PEM_STRING_PKCS8INF) == 0) { PKCS8_PRIV_KEY_INFO *p8inf; p8inf = d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, len); if (!p8inf) goto p8err; ret = EVP_PKCS82PKEY(p8inf); if (x) { if (*x) EVP_PKEY_free((EVP_PKEY *)*x); *x = ret; } PKCS8_PRIV_KEY_INFO_free(p8inf); } else if (strcmp(nm, PEM_STRING_PKCS8) == 0) { PKCS8_PRIV_KEY_INFO *p8inf; X509_SIG *p8; int klen; char psbuf[PEM_BUFSIZE]; p8 = d2i_X509_SIG(NULL, &p, len); if (!p8) goto p8err; if (cb) klen = cb(psbuf, PEM_BUFSIZE, 0, u); else klen = PEM_def_callback(psbuf, PEM_BUFSIZE, 0, u); if (klen <= 0) { PEMerr(PEM_F_PEM_READ_BIO_PRIVATEKEY, PEM_R_BAD_PASSWORD_READ); X509_SIG_free(p8); goto err; } p8inf = PKCS8_decrypt(p8, psbuf, klen); X509_SIG_free(p8); if (!p8inf) goto p8err; ret = EVP_PKCS82PKEY(p8inf); if (x) { if (*x) EVP_PKEY_free((EVP_PKEY *)*x); *x = ret; } PKCS8_PRIV_KEY_INFO_free(p8inf); } else if ((slen = pem_check_suffix(nm, "PRIVATE KEY")) > 0) { const EVP_PKEY_ASN1_METHOD *ameth; ameth = EVP_PKEY_asn1_find_str(NULL, nm, slen); if (!ameth || !ameth->old_priv_decode) goto p8err; ret = d2i_PrivateKey(ameth->pkey_id, x, &p, len); } p8err: if (ret == NULL) PEMerr(PEM_F_PEM_READ_BIO_PRIVATEKEY, ERR_R_ASN1_LIB); err: free(nm); OPENSSL_cleanse(data, len); free(data); return (ret); } int PEM_write_bio_PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u) { char pem_str[80]; if (!x->ameth || x->ameth->priv_encode) return PEM_write_bio_PKCS8PrivateKey(bp, x, enc, (char *)kstr, klen, cb, u); (void) snprintf(pem_str, sizeof(pem_str), "%s PRIVATE KEY", x->ameth->pem_str); return PEM_ASN1_write_bio((i2d_of_void *)i2d_PrivateKey, pem_str, bp, x, enc, kstr, klen, cb, u); } EVP_PKEY * PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x) { char *nm = NULL; const unsigned char *p = NULL; unsigned char *data = NULL; long len; int slen; EVP_PKEY *ret = NULL; if (!PEM_bytes_read_bio(&data, &len, &nm, PEM_STRING_PARAMETERS, bp, 0, NULL)) return NULL; p = data; if ((slen = pem_check_suffix(nm, "PARAMETERS")) > 0) { ret = EVP_PKEY_new(); if (!ret) goto err; if (!EVP_PKEY_set_type_str(ret, nm, slen) || !ret->ameth->param_decode || !ret->ameth->param_decode(ret, &p, len)) { EVP_PKEY_free(ret); ret = NULL; goto err; } if (x) { if (*x) EVP_PKEY_free((EVP_PKEY *)*x); *x = ret; } } err: if (ret == NULL) PEMerr(PEM_F_PEM_READ_BIO_PARAMETERS, ERR_R_ASN1_LIB); free(nm); free(data); return (ret); } int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x) { char pem_str[80]; if (!x->ameth || !x->ameth->param_encode) return 0; (void) snprintf(pem_str, sizeof(pem_str), "%s PARAMETERS", x->ameth->pem_str); return PEM_ASN1_write_bio((i2d_of_void *)x->ameth->param_encode, pem_str, bp, x, NULL, NULL, 0, 0, NULL); } EVP_PKEY * PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u) { BIO *b; EVP_PKEY *ret; if ((b = BIO_new(BIO_s_file())) == NULL) { PEMerr(PEM_F_PEM_READ_PRIVATEKEY, ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, fp, BIO_NOCLOSE); ret = PEM_read_bio_PrivateKey(b, x, cb, u); BIO_free(b); return (ret); } int PEM_write_PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u) { BIO *b; int ret; if ((b = BIO_new_fp(fp, BIO_NOCLOSE)) == NULL) { PEMerr(PEM_F_PEM_WRITE_PRIVATEKEY, ERR_R_BUF_LIB); return 0; } ret = PEM_write_bio_PrivateKey(b, x, enc, kstr, klen, cb, u); BIO_free(b); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pem/pvkfmt.c0000644000175000017500000005212012360020706020510 0ustar /* $OpenBSD: pvkfmt.c,v 1.9 2014/07/11 08:44:49 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2005. */ /* ==================================================================== * Copyright (c) 2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Support for PVK format keys and related structures (such a PUBLICKEYBLOB * and PRIVATEKEYBLOB). */ #include #include #include #include #include #include #if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DSA) #include #include /* Utility function: read a DWORD (4 byte unsigned integer) in little endian * format */ static unsigned int read_ledword(const unsigned char **in) { const unsigned char *p = *in; unsigned int ret; ret = *p++; ret |= (*p++ << 8); ret |= (*p++ << 16); ret |= (*p++ << 24); *in = p; return ret; } /* Read a BIGNUM in little endian format. The docs say that this should take up * bitlen/8 bytes. */ static int read_lebn(const unsigned char **in, unsigned int nbyte, BIGNUM **r) { const unsigned char *p; unsigned char *tmpbuf, *q; unsigned int i; p = *in + nbyte - 1; tmpbuf = malloc(nbyte); if (!tmpbuf) return 0; q = tmpbuf; for (i = 0; i < nbyte; i++) *q++ = *p--; *r = BN_bin2bn(tmpbuf, nbyte, NULL); free(tmpbuf); if (*r) { *in += nbyte; return 1; } else return 0; } /* Convert private key blob to EVP_PKEY: RSA and DSA keys supported */ #define MS_PUBLICKEYBLOB 0x6 #define MS_PRIVATEKEYBLOB 0x7 #define MS_RSA1MAGIC 0x31415352L #define MS_RSA2MAGIC 0x32415352L #define MS_DSS1MAGIC 0x31535344L #define MS_DSS2MAGIC 0x32535344L #define MS_KEYALG_RSA_KEYX 0xa400 #define MS_KEYALG_DSS_SIGN 0x2200 #define MS_KEYTYPE_KEYX 0x1 #define MS_KEYTYPE_SIGN 0x2 /* The PVK file magic number: seems to spell out "bobsfile", who is Bob? */ #define MS_PVKMAGIC 0xb0b5f11eL /* Salt length for PVK files */ #define PVK_SALTLEN 0x10 static EVP_PKEY *b2i_rsa(const unsigned char **in, unsigned int length, unsigned int bitlen, int ispub); static EVP_PKEY *b2i_dss(const unsigned char **in, unsigned int length, unsigned int bitlen, int ispub); static int do_blob_header(const unsigned char **in, unsigned int length, unsigned int *pmagic, unsigned int *pbitlen, int *pisdss, int *pispub) { const unsigned char *p = *in; if (length < 16) return 0; /* bType */ if (*p == MS_PUBLICKEYBLOB) { if (*pispub == 0) { PEMerr(PEM_F_DO_BLOB_HEADER, PEM_R_EXPECTING_PRIVATE_KEY_BLOB); return 0; } *pispub = 1; } else if (*p == MS_PRIVATEKEYBLOB) { if (*pispub == 1) { PEMerr(PEM_F_DO_BLOB_HEADER, PEM_R_EXPECTING_PUBLIC_KEY_BLOB); return 0; } *pispub = 0; } else return 0; p++; /* Version */ if (*p++ != 0x2) { PEMerr(PEM_F_DO_BLOB_HEADER, PEM_R_BAD_VERSION_NUMBER); return 0; } /* Ignore reserved, aiKeyAlg */ p += 6; *pmagic = read_ledword(&p); *pbitlen = read_ledword(&p); *pisdss = 0; switch (*pmagic) { case MS_DSS1MAGIC: *pisdss = 1; case MS_RSA1MAGIC: if (*pispub == 0) { PEMerr(PEM_F_DO_BLOB_HEADER, PEM_R_EXPECTING_PRIVATE_KEY_BLOB); return 0; } break; case MS_DSS2MAGIC: *pisdss = 1; case MS_RSA2MAGIC: if (*pispub == 1) { PEMerr(PEM_F_DO_BLOB_HEADER, PEM_R_EXPECTING_PUBLIC_KEY_BLOB); return 0; } break; default: PEMerr(PEM_F_DO_BLOB_HEADER, PEM_R_BAD_MAGIC_NUMBER); return -1; } *in = p; return 1; } static unsigned int blob_length(unsigned bitlen, int isdss, int ispub) { unsigned int nbyte, hnbyte; nbyte = (bitlen + 7) >> 3; hnbyte = (bitlen + 15) >> 4; if (isdss) { /* Expected length: 20 for q + 3 components bitlen each + 24 * for seed structure. */ if (ispub) return 44 + 3 * nbyte; /* Expected length: 20 for q, priv, 2 bitlen components + 24 * for seed structure. */ else return 64 + 2 * nbyte; } else { /* Expected length: 4 for 'e' + 'n' */ if (ispub) return 4 + nbyte; else /* Expected length: 4 for 'e' and 7 other components. * 2 components are bitlen size, 5 are bitlen/2 */ return 4 + 2*nbyte + 5*hnbyte; } } static EVP_PKEY * do_b2i(const unsigned char **in, unsigned int length, int ispub) { const unsigned char *p = *in; unsigned int bitlen, magic; int isdss; if (do_blob_header(&p, length, &magic, &bitlen, &isdss, &ispub) <= 0) { PEMerr(PEM_F_DO_B2I, PEM_R_KEYBLOB_HEADER_PARSE_ERROR); return NULL; } length -= 16; if (length < blob_length(bitlen, isdss, ispub)) { PEMerr(PEM_F_DO_B2I, PEM_R_KEYBLOB_TOO_SHORT); return NULL; } if (isdss) return b2i_dss(&p, length, bitlen, ispub); else return b2i_rsa(&p, length, bitlen, ispub); } static EVP_PKEY * do_b2i_bio(BIO *in, int ispub) { const unsigned char *p; unsigned char hdr_buf[16], *buf = NULL; unsigned int bitlen, magic, length; int isdss; EVP_PKEY *ret = NULL; if (BIO_read(in, hdr_buf, 16) != 16) { PEMerr(PEM_F_DO_B2I_BIO, PEM_R_KEYBLOB_TOO_SHORT); return NULL; } p = hdr_buf; if (do_blob_header(&p, 16, &magic, &bitlen, &isdss, &ispub) <= 0) return NULL; length = blob_length(bitlen, isdss, ispub); buf = malloc(length); if (!buf) { PEMerr(PEM_F_DO_B2I_BIO, ERR_R_MALLOC_FAILURE); goto err; } p = buf; if (BIO_read(in, buf, length) != (int)length) { PEMerr(PEM_F_DO_B2I_BIO, PEM_R_KEYBLOB_TOO_SHORT); goto err; } if (isdss) ret = b2i_dss(&p, length, bitlen, ispub); else ret = b2i_rsa(&p, length, bitlen, ispub); err: free(buf); return ret; } static EVP_PKEY * b2i_dss(const unsigned char **in, unsigned int length, unsigned int bitlen, int ispub) { const unsigned char *p = *in; EVP_PKEY *ret = NULL; DSA *dsa = NULL; BN_CTX *ctx = NULL; unsigned int nbyte; nbyte = (bitlen + 7) >> 3; dsa = DSA_new(); ret = EVP_PKEY_new(); if (!dsa || !ret) goto memerr; if (!read_lebn(&p, nbyte, &dsa->p)) goto memerr; if (!read_lebn(&p, 20, &dsa->q)) goto memerr; if (!read_lebn(&p, nbyte, &dsa->g)) goto memerr; if (ispub) { if (!read_lebn(&p, nbyte, &dsa->pub_key)) goto memerr; } else { if (!read_lebn(&p, 20, &dsa->priv_key)) goto memerr; /* Calculate public key */ if (!(dsa->pub_key = BN_new())) goto memerr; if (!(ctx = BN_CTX_new())) goto memerr; if (!BN_mod_exp(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, ctx)) goto memerr; BN_CTX_free(ctx); } EVP_PKEY_set1_DSA(ret, dsa); DSA_free(dsa); *in = p; return ret; memerr: PEMerr(PEM_F_B2I_DSS, ERR_R_MALLOC_FAILURE); if (dsa) DSA_free(dsa); if (ret) EVP_PKEY_free(ret); if (ctx) BN_CTX_free(ctx); return NULL; } static EVP_PKEY * b2i_rsa(const unsigned char **in, unsigned int length, unsigned int bitlen, int ispub) { const unsigned char *p = *in; EVP_PKEY *ret = NULL; RSA *rsa = NULL; unsigned int nbyte, hnbyte; nbyte = (bitlen + 7) >> 3; hnbyte = (bitlen + 15) >> 4; rsa = RSA_new(); ret = EVP_PKEY_new(); if (!rsa || !ret) goto memerr; rsa->e = BN_new(); if (!rsa->e) goto memerr; if (!BN_set_word(rsa->e, read_ledword(&p))) goto memerr; if (!read_lebn(&p, nbyte, &rsa->n)) goto memerr; if (!ispub) { if (!read_lebn(&p, hnbyte, &rsa->p)) goto memerr; if (!read_lebn(&p, hnbyte, &rsa->q)) goto memerr; if (!read_lebn(&p, hnbyte, &rsa->dmp1)) goto memerr; if (!read_lebn(&p, hnbyte, &rsa->dmq1)) goto memerr; if (!read_lebn(&p, hnbyte, &rsa->iqmp)) goto memerr; if (!read_lebn(&p, nbyte, &rsa->d)) goto memerr; } EVP_PKEY_set1_RSA(ret, rsa); RSA_free(rsa); *in = p; return ret; memerr: PEMerr(PEM_F_B2I_RSA, ERR_R_MALLOC_FAILURE); if (rsa) RSA_free(rsa); if (ret) EVP_PKEY_free(ret); return NULL; } EVP_PKEY * b2i_PrivateKey(const unsigned char **in, long length) { return do_b2i(in, length, 0); } EVP_PKEY * b2i_PublicKey(const unsigned char **in, long length) { return do_b2i(in, length, 1); } EVP_PKEY * b2i_PrivateKey_bio(BIO *in) { return do_b2i_bio(in, 0); } EVP_PKEY * b2i_PublicKey_bio(BIO *in) { return do_b2i_bio(in, 1); } static void write_ledword(unsigned char **out, unsigned int dw) { unsigned char *p = *out; *p++ = dw & 0xff; *p++ = (dw >> 8) & 0xff; *p++ = (dw >> 16) & 0xff; *p++ = (dw >> 24) & 0xff; *out = p; } static void write_lebn(unsigned char **out, const BIGNUM *bn, int len) { int nb, i; unsigned char *p = *out, *q, c; nb = BN_num_bytes(bn); BN_bn2bin(bn, p); q = p + nb - 1; /* In place byte order reversal */ for (i = 0; i < nb / 2; i++) { c = *p; *p++ = *q; *q-- = c; } *out += nb; /* Pad with zeroes if we have to */ if (len > 0) { len -= nb; if (len > 0) { memset(*out, 0, len); *out += len; } } } static int check_bitlen_rsa(RSA *rsa, int ispub, unsigned int *magic); static int check_bitlen_dsa(DSA *dsa, int ispub, unsigned int *magic); static void write_rsa(unsigned char **out, RSA *rsa, int ispub); static void write_dsa(unsigned char **out, DSA *dsa, int ispub); static int do_i2b(unsigned char **out, EVP_PKEY *pk, int ispub) { unsigned char *p; unsigned int bitlen, magic = 0, keyalg; int outlen, noinc = 0; if (pk->type == EVP_PKEY_DSA) { bitlen = check_bitlen_dsa(pk->pkey.dsa, ispub, &magic); keyalg = MS_KEYALG_DSS_SIGN; } else if (pk->type == EVP_PKEY_RSA) { bitlen = check_bitlen_rsa(pk->pkey.rsa, ispub, &magic); keyalg = MS_KEYALG_RSA_KEYX; } else return -1; if (bitlen == 0) return -1; outlen = 16 + blob_length(bitlen, keyalg == MS_KEYALG_DSS_SIGN ? 1 : 0, ispub); if (out == NULL) return outlen; if (*out) p = *out; else { p = malloc(outlen); if (!p) return -1; *out = p; noinc = 1; } if (ispub) *p++ = MS_PUBLICKEYBLOB; else *p++ = MS_PRIVATEKEYBLOB; *p++ = 0x2; *p++ = 0; *p++ = 0; write_ledword(&p, keyalg); write_ledword(&p, magic); write_ledword(&p, bitlen); if (keyalg == MS_KEYALG_DSS_SIGN) write_dsa(&p, pk->pkey.dsa, ispub); else write_rsa(&p, pk->pkey.rsa, ispub); if (!noinc) *out += outlen; return outlen; } static int do_i2b_bio(BIO *out, EVP_PKEY *pk, int ispub) { unsigned char *tmp = NULL; int outlen, wrlen; outlen = do_i2b(&tmp, pk, ispub); if (outlen < 0) return -1; wrlen = BIO_write(out, tmp, outlen); free(tmp); if (wrlen == outlen) return outlen; return -1; } static int check_bitlen_dsa(DSA *dsa, int ispub, unsigned int *pmagic) { int bitlen; bitlen = BN_num_bits(dsa->p); if ((bitlen & 7) || (BN_num_bits(dsa->q) != 160) || (BN_num_bits(dsa->g) > bitlen)) goto badkey; if (ispub) { if (BN_num_bits(dsa->pub_key) > bitlen) goto badkey; *pmagic = MS_DSS1MAGIC; } else { if (BN_num_bits(dsa->priv_key) > 160) goto badkey; *pmagic = MS_DSS2MAGIC; } return bitlen; badkey: PEMerr(PEM_F_CHECK_BITLEN_DSA, PEM_R_UNSUPPORTED_KEY_COMPONENTS); return 0; } static int check_bitlen_rsa(RSA *rsa, int ispub, unsigned int *pmagic) { int nbyte, hnbyte, bitlen; if (BN_num_bits(rsa->e) > 32) goto badkey; bitlen = BN_num_bits(rsa->n); nbyte = BN_num_bytes(rsa->n); hnbyte = (BN_num_bits(rsa->n) + 15) >> 4; if (ispub) { *pmagic = MS_RSA1MAGIC; return bitlen; } else { *pmagic = MS_RSA2MAGIC; /* For private key each component must fit within nbyte or * hnbyte. */ if (BN_num_bytes(rsa->d) > nbyte) goto badkey; if ((BN_num_bytes(rsa->iqmp) > hnbyte) || (BN_num_bytes(rsa->p) > hnbyte) || (BN_num_bytes(rsa->q) > hnbyte) || (BN_num_bytes(rsa->dmp1) > hnbyte) || (BN_num_bytes(rsa->dmq1) > hnbyte)) goto badkey; } return bitlen; badkey: PEMerr(PEM_F_CHECK_BITLEN_RSA, PEM_R_UNSUPPORTED_KEY_COMPONENTS); return 0; } static void write_rsa(unsigned char **out, RSA *rsa, int ispub) { int nbyte, hnbyte; nbyte = BN_num_bytes(rsa->n); hnbyte = (BN_num_bits(rsa->n) + 15) >> 4; write_lebn(out, rsa->e, 4); write_lebn(out, rsa->n, -1); if (ispub) return; write_lebn(out, rsa->p, hnbyte); write_lebn(out, rsa->q, hnbyte); write_lebn(out, rsa->dmp1, hnbyte); write_lebn(out, rsa->dmq1, hnbyte); write_lebn(out, rsa->iqmp, hnbyte); write_lebn(out, rsa->d, nbyte); } static void write_dsa(unsigned char **out, DSA *dsa, int ispub) { int nbyte; nbyte = BN_num_bytes(dsa->p); write_lebn(out, dsa->p, nbyte); write_lebn(out, dsa->q, 20); write_lebn(out, dsa->g, nbyte); if (ispub) write_lebn(out, dsa->pub_key, nbyte); else write_lebn(out, dsa->priv_key, 20); /* Set "invalid" for seed structure values */ memset(*out, 0xff, 24); *out += 24; return; } int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk) { return do_i2b_bio(out, pk, 0); } int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk) { return do_i2b_bio(out, pk, 1); } #ifndef OPENSSL_NO_RC4 static int do_PVK_header(const unsigned char **in, unsigned int length, int skip_magic, unsigned int *psaltlen, unsigned int *pkeylen) { const unsigned char *p = *in; unsigned int pvk_magic, is_encrypted; if (skip_magic) { if (length < 20) { PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_PVK_TOO_SHORT); return 0; } length -= 20; } else { if (length < 24) { PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_PVK_TOO_SHORT); return 0; } length -= 24; pvk_magic = read_ledword(&p); if (pvk_magic != MS_PVKMAGIC) { PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_BAD_MAGIC_NUMBER); return 0; } } /* Skip reserved */ p += 4; /*keytype = */read_ledword(&p); is_encrypted = read_ledword(&p); *psaltlen = read_ledword(&p); *pkeylen = read_ledword(&p); if (is_encrypted && !*psaltlen) { PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_INCONSISTENT_HEADER); return 0; } *in = p; return 1; } static int derive_pvk_key(unsigned char *key, const unsigned char *salt, unsigned int saltlen, const unsigned char *pass, int passlen) { EVP_MD_CTX mctx; int rv = 1; EVP_MD_CTX_init(&mctx); if (!EVP_DigestInit_ex(&mctx, EVP_sha1(), NULL) || !EVP_DigestUpdate(&mctx, salt, saltlen) || !EVP_DigestUpdate(&mctx, pass, passlen) || !EVP_DigestFinal_ex(&mctx, key, NULL)) rv = 0; EVP_MD_CTX_cleanup(&mctx); return rv; } static EVP_PKEY * do_PVK_body(const unsigned char **in, unsigned int saltlen, unsigned int keylen, pem_password_cb *cb, void *u) { EVP_PKEY *ret = NULL; const unsigned char *p = *in; unsigned int magic; unsigned char *enctmp = NULL, *q; EVP_CIPHER_CTX cctx; EVP_CIPHER_CTX_init(&cctx); if (saltlen) { char psbuf[PEM_BUFSIZE]; unsigned char keybuf[20]; int enctmplen, inlen; if (cb) inlen = cb(psbuf, PEM_BUFSIZE, 0, u); else inlen = PEM_def_callback(psbuf, PEM_BUFSIZE, 0, u); if (inlen <= 0) { PEMerr(PEM_F_DO_PVK_BODY, PEM_R_BAD_PASSWORD_READ); return NULL; } enctmp = malloc(keylen + 8); if (!enctmp) { PEMerr(PEM_F_DO_PVK_BODY, ERR_R_MALLOC_FAILURE); return NULL; } if (!derive_pvk_key(keybuf, p, saltlen, (unsigned char *)psbuf, inlen)) { free(enctmp); return NULL; } p += saltlen; /* Copy BLOBHEADER across, decrypt rest */ memcpy(enctmp, p, 8); p += 8; if (keylen < 8) { PEMerr(PEM_F_DO_PVK_BODY, PEM_R_PVK_TOO_SHORT); free(enctmp); return NULL; } inlen = keylen - 8; q = enctmp + 8; if (!EVP_DecryptInit_ex(&cctx, EVP_rc4(), NULL, keybuf, NULL)) goto err; if (!EVP_DecryptUpdate(&cctx, q, &enctmplen, p, inlen)) goto err; if (!EVP_DecryptFinal_ex(&cctx, q + enctmplen, &enctmplen)) goto err; magic = read_ledword((const unsigned char **)&q); if (magic != MS_RSA2MAGIC && magic != MS_DSS2MAGIC) { q = enctmp + 8; memset(keybuf + 5, 0, 11); if (!EVP_DecryptInit_ex(&cctx, EVP_rc4(), NULL, keybuf, NULL)) goto err; OPENSSL_cleanse(keybuf, 20); if (!EVP_DecryptUpdate(&cctx, q, &enctmplen, p, inlen)) goto err; if (!EVP_DecryptFinal_ex(&cctx, q + enctmplen, &enctmplen)) goto err; magic = read_ledword((const unsigned char **)&q); if (magic != MS_RSA2MAGIC && magic != MS_DSS2MAGIC) { PEMerr(PEM_F_DO_PVK_BODY, PEM_R_BAD_DECRYPT); goto err; } } else OPENSSL_cleanse(keybuf, 20); p = enctmp; } ret = b2i_PrivateKey(&p, keylen); err: EVP_CIPHER_CTX_cleanup(&cctx); if (enctmp && saltlen) free(enctmp); return ret; } EVP_PKEY * b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u) { unsigned char pvk_hdr[24], *buf = NULL; const unsigned char *p; int buflen; EVP_PKEY *ret = NULL; unsigned int saltlen, keylen; if (BIO_read(in, pvk_hdr, 24) != 24) { PEMerr(PEM_F_B2I_PVK_BIO, PEM_R_PVK_DATA_TOO_SHORT); return NULL; } p = pvk_hdr; if (!do_PVK_header(&p, 24, 0, &saltlen, &keylen)) return 0; buflen = (int) keylen + saltlen; buf = malloc(buflen); if (!buf) { PEMerr(PEM_F_B2I_PVK_BIO, ERR_R_MALLOC_FAILURE); return 0; } p = buf; if (BIO_read(in, buf, buflen) != buflen) { PEMerr(PEM_F_B2I_PVK_BIO, PEM_R_PVK_DATA_TOO_SHORT); goto err; } ret = do_PVK_body(&p, saltlen, keylen, cb, u); err: if (buf) { OPENSSL_cleanse(buf, buflen); free(buf); } return ret; } static int i2b_PVK(unsigned char **out, EVP_PKEY*pk, int enclevel, pem_password_cb *cb, void *u) { int outlen = 24, pklen; unsigned char *p, *salt = NULL; EVP_CIPHER_CTX cctx; EVP_CIPHER_CTX_init(&cctx); if (enclevel) outlen += PVK_SALTLEN; pklen = do_i2b(NULL, pk, 0); if (pklen < 0) return -1; outlen += pklen; if (!out) return outlen; if (*out) p = *out; else { p = malloc(outlen); if (!p) { PEMerr(PEM_F_I2B_PVK, ERR_R_MALLOC_FAILURE); return -1; } *out = p; } write_ledword(&p, MS_PVKMAGIC); write_ledword(&p, 0); if (pk->type == EVP_PKEY_DSA) write_ledword(&p, MS_KEYTYPE_SIGN); else write_ledword(&p, MS_KEYTYPE_KEYX); write_ledword(&p, enclevel ? 1 : 0); write_ledword(&p, enclevel ? PVK_SALTLEN : 0); write_ledword(&p, pklen); if (enclevel) { if (RAND_bytes(p, PVK_SALTLEN) <= 0) goto error; salt = p; p += PVK_SALTLEN; } do_i2b(&p, pk, 0); if (enclevel == 0) return outlen; else { char psbuf[PEM_BUFSIZE]; unsigned char keybuf[20]; int enctmplen, inlen; if (cb) inlen = cb(psbuf, PEM_BUFSIZE, 1, u); else inlen = PEM_def_callback(psbuf, PEM_BUFSIZE, 1, u); if (inlen <= 0) { PEMerr(PEM_F_I2B_PVK, PEM_R_BAD_PASSWORD_READ); goto error; } if (!derive_pvk_key(keybuf, salt, PVK_SALTLEN, (unsigned char *)psbuf, inlen)) goto error; if (enclevel == 1) memset(keybuf + 5, 0, 11); p = salt + PVK_SALTLEN + 8; if (!EVP_EncryptInit_ex(&cctx, EVP_rc4(), NULL, keybuf, NULL)) goto error; OPENSSL_cleanse(keybuf, 20); if (!EVP_DecryptUpdate(&cctx, p, &enctmplen, p, pklen - 8)) goto error; if (!EVP_DecryptFinal_ex(&cctx, p + enctmplen, &enctmplen)) goto error; } EVP_CIPHER_CTX_cleanup(&cctx); return outlen; error: EVP_CIPHER_CTX_cleanup(&cctx); return -1; } int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel, pem_password_cb *cb, void *u) { unsigned char *tmp = NULL; int outlen, wrlen; outlen = i2b_PVK(&tmp, pk, enclevel, cb, u); if (outlen < 0) return -1; wrlen = BIO_write(out, tmp, outlen); free(tmp); if (wrlen == outlen) { PEMerr(PEM_F_I2B_PVK_BIO, PEM_R_BIO_WRITE_FAILURE); return outlen; } return -1; } #endif #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pem/pem_oth.c0000644000175000017500000000747312360020706020647 0ustar /* $OpenBSD: pem_oth.c,v 1.5 2014/06/12 15:49:30 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include /* Handle 'other' PEMs: not private keys */ void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x, pem_password_cb *cb, void *u) { const unsigned char *p = NULL; unsigned char *data = NULL; long len; char *ret = NULL; if (!PEM_bytes_read_bio(&data, &len, NULL, name, bp, cb, u)) return NULL; p = data; ret = d2i(x, &p, len); if (ret == NULL) PEMerr(PEM_F_PEM_ASN1_READ_BIO, ERR_R_ASN1_LIB); free(data); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pem/pem_x509.c0000644000175000017500000000565112360020706020556 0ustar /* $OpenBSD: pem_x509.c,v 1.5 2014/06/12 15:49:30 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include IMPLEMENT_PEM_rw(X509, X509, PEM_STRING_X509, X509) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pem/pem_sign.c0000644000175000017500000001002012360020706020773 0ustar /* $OpenBSD: pem_sign.c,v 1.10 2014/06/12 15:49:30 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type) { EVP_DigestInit_ex(ctx, type, NULL); } void PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *data, unsigned int count) { EVP_DigestUpdate(ctx, data, count); } int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, EVP_PKEY *pkey) { unsigned char *m; int i, ret = 0; unsigned int m_len; m = malloc(EVP_PKEY_size(pkey) + 2); if (m == NULL) { PEMerr(PEM_F_PEM_SIGNFINAL, ERR_R_MALLOC_FAILURE); goto err; } if (EVP_SignFinal(ctx, m, &m_len, pkey) <= 0) goto err; i = EVP_EncodeBlock(sigret, m, m_len); *siglen = i; ret = 1; err: /* ctx has been zeroed by EVP_SignFinal() */ free(m); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pem/pem_seal.c0000644000175000017500000001352012360020706020767 0ustar /* $OpenBSD: pem_seal.c,v 1.19 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include /* for OPENSSL_NO_RSA */ #ifndef OPENSSL_NO_RSA #include #include #include #include #include #include #include int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type, unsigned char **ek, int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk) { unsigned char key[EVP_MAX_KEY_LENGTH]; int ret = -1; int i, j, max = 0; char *s = NULL; for (i = 0; i < npubk; i++) { if (pubk[i]->type != EVP_PKEY_RSA) { PEMerr(PEM_F_PEM_SEALINIT, PEM_R_PUBLIC_KEY_NO_RSA); goto err; } j = RSA_size(pubk[i]->pkey.rsa); if (j > max) max = j; } s = reallocarray(NULL, max, 2); if (s == NULL) { PEMerr(PEM_F_PEM_SEALINIT, ERR_R_MALLOC_FAILURE); goto err; } EVP_EncodeInit(&ctx->encode); EVP_MD_CTX_init(&ctx->md); if (!EVP_SignInit(&ctx->md, md_type)) goto err; EVP_CIPHER_CTX_init(&ctx->cipher); ret = EVP_SealInit(&ctx->cipher, type, ek, ekl, iv, pubk, npubk); if (ret <= 0) goto err; /* base64 encode the keys */ for (i = 0; i < npubk; i++) { j = EVP_EncodeBlock((unsigned char *)s, ek[i], RSA_size(pubk[i]->pkey.rsa)); ekl[i] = j; memcpy(ek[i], s, j + 1); } ret = npubk; err: free(s); OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH); return (ret); } void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl, unsigned char *in, int inl) { unsigned char buffer[1600]; int i, j; *outl = 0; EVP_SignUpdate(&ctx->md, in, inl); for (;;) { if (inl <= 0) break; if (inl > 1200) i = 1200; else i = inl; EVP_EncryptUpdate(&ctx->cipher, buffer, &j, in, i); EVP_EncodeUpdate(&ctx->encode, out, &j, buffer, j); *outl += j; out += j; in += i; inl -= i; } } int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl, unsigned char *out, int *outl, EVP_PKEY *priv) { unsigned char *s = NULL; int ret = 0, j; unsigned int i; if (priv->type != EVP_PKEY_RSA) { PEMerr(PEM_F_PEM_SEALFINAL, PEM_R_PUBLIC_KEY_NO_RSA); goto err; } i = RSA_size(priv->pkey.rsa); if (i < 100) i = 100; s = reallocarray(NULL, i, 2); if (s == NULL) { PEMerr(PEM_F_PEM_SEALFINAL, ERR_R_MALLOC_FAILURE); goto err; } if (!EVP_EncryptFinal_ex(&ctx->cipher, s, (int *)&i)) goto err; EVP_EncodeUpdate(&ctx->encode, out, &j, s, i); *outl = j; out += j; EVP_EncodeFinal(&ctx->encode, out, &j); *outl += j; if (!EVP_SignFinal(&ctx->md, s, &i, priv)) goto err; *sigl = EVP_EncodeBlock(sig, s, i); ret = 1; err: EVP_MD_CTX_cleanup(&ctx->md); EVP_CIPHER_CTX_cleanup(&ctx->cipher); free(s); return (ret); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pem/pem_info.c0000644000175000017500000002567512360020706021014 0ustar /* $OpenBSD: pem_info.c,v 1.18 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_DSA #include #endif #ifndef OPENSSL_NO_RSA #include #endif STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u) { BIO *b; STACK_OF(X509_INFO) *ret; if ((b = BIO_new(BIO_s_file())) == NULL) { PEMerr(PEM_F_PEM_X509_INFO_READ, ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, fp, BIO_NOCLOSE); ret = PEM_X509_INFO_read_bio(b, sk, cb, u); BIO_free(b); return (ret); } STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u) { X509_INFO *xi = NULL; char *name = NULL, *header = NULL; void *pp; unsigned char *data = NULL; const unsigned char *p; long len, error = 0; int ok = 0; STACK_OF(X509_INFO) *ret = NULL; unsigned int i, raw, ptype; d2i_of_void *d2i = 0; if (sk == NULL) { if ((ret = sk_X509_INFO_new_null()) == NULL) { PEMerr(PEM_F_PEM_X509_INFO_READ_BIO, ERR_R_MALLOC_FAILURE); return 0; } } else ret = sk; if ((xi = X509_INFO_new()) == NULL) goto err; for (;;) { raw = 0; ptype = 0; i = PEM_read_bio(bp, &name, &header, &data, &len); if (i == 0) { error = ERR_GET_REASON(ERR_peek_last_error()); if (error == PEM_R_NO_START_LINE) { ERR_clear_error(); break; } goto err; } start: if ((strcmp(name, PEM_STRING_X509) == 0) || (strcmp(name, PEM_STRING_X509_OLD) == 0)) { d2i = (D2I_OF(void))d2i_X509; if (xi->x509 != NULL) { if (!sk_X509_INFO_push(ret, xi)) goto err; if ((xi = X509_INFO_new()) == NULL) goto err; goto start; } pp = &(xi->x509); } else if ((strcmp(name, PEM_STRING_X509_TRUSTED) == 0)) { d2i = (D2I_OF(void))d2i_X509_AUX; if (xi->x509 != NULL) { if (!sk_X509_INFO_push(ret, xi)) goto err; if ((xi = X509_INFO_new()) == NULL) goto err; goto start; } pp = &(xi->x509); } else if (strcmp(name, PEM_STRING_X509_CRL) == 0) { d2i = (D2I_OF(void))d2i_X509_CRL; if (xi->crl != NULL) { if (!sk_X509_INFO_push(ret, xi)) goto err; if ((xi = X509_INFO_new()) == NULL) goto err; goto start; } pp = &(xi->crl); } else #ifndef OPENSSL_NO_RSA if (strcmp(name, PEM_STRING_RSA) == 0) { d2i = (D2I_OF(void))d2i_RSAPrivateKey; if (xi->x_pkey != NULL) { if (!sk_X509_INFO_push(ret, xi)) goto err; if ((xi = X509_INFO_new()) == NULL) goto err; goto start; } xi->enc_data = NULL; xi->enc_len = 0; xi->x_pkey = X509_PKEY_new(); if (xi->x_pkey == NULL) goto err; ptype = EVP_PKEY_RSA; pp = &xi->x_pkey->dec_pkey; if (strlen(header) > 10) /* assume encrypted */ raw = 1; } else #endif #ifndef OPENSSL_NO_DSA if (strcmp(name, PEM_STRING_DSA) == 0) { d2i = (D2I_OF(void))d2i_DSAPrivateKey; if (xi->x_pkey != NULL) { if (!sk_X509_INFO_push(ret, xi)) goto err; if ((xi = X509_INFO_new()) == NULL) goto err; goto start; } xi->enc_data = NULL; xi->enc_len = 0; xi->x_pkey = X509_PKEY_new(); if (xi->x_pkey == NULL) goto err; ptype = EVP_PKEY_DSA; pp = &xi->x_pkey->dec_pkey; if (strlen(header) > 10) /* assume encrypted */ raw = 1; } else #endif #ifndef OPENSSL_NO_EC if (strcmp(name, PEM_STRING_ECPRIVATEKEY) == 0) { d2i = (D2I_OF(void))d2i_ECPrivateKey; if (xi->x_pkey != NULL) { if (!sk_X509_INFO_push(ret, xi)) goto err; if ((xi = X509_INFO_new()) == NULL) goto err; goto start; } xi->enc_data = NULL; xi->enc_len = 0; xi->x_pkey = X509_PKEY_new(); if (xi->x_pkey == NULL) goto err; ptype = EVP_PKEY_EC; pp = &xi->x_pkey->dec_pkey; if (strlen(header) > 10) /* assume encrypted */ raw = 1; } else #endif { d2i = NULL; pp = NULL; } if (d2i != NULL) { if (!raw) { EVP_CIPHER_INFO cipher; if (!PEM_get_EVP_CIPHER_INFO(header, &cipher)) goto err; if (!PEM_do_header(&cipher, data, &len, cb, u)) goto err; p = data; if (ptype) { if (!d2i_PrivateKey(ptype, pp, &p, len)) { PEMerr(PEM_F_PEM_X509_INFO_READ_BIO, ERR_R_ASN1_LIB); goto err; } } else if (d2i(pp, &p, len) == NULL) { PEMerr(PEM_F_PEM_X509_INFO_READ_BIO, ERR_R_ASN1_LIB); goto err; } } else { /* encrypted RSA data */ if (!PEM_get_EVP_CIPHER_INFO(header, &xi->enc_cipher)) goto err; xi->enc_data = (char *)data; xi->enc_len = (int)len; data = NULL; } } else { /* unknown */ } free(name); free(header); free(data); name = NULL; header = NULL; data = NULL; } /* if the last one hasn't been pushed yet and there is anything * in it then add it to the stack ... */ if ((xi->x509 != NULL) || (xi->crl != NULL) || (xi->x_pkey != NULL) || (xi->enc_data != NULL)) { if (!sk_X509_INFO_push(ret, xi)) goto err; xi = NULL; } ok = 1; err: if (xi != NULL) X509_INFO_free(xi); if (!ok) { for (i = 0; ((int)i) < sk_X509_INFO_num(ret); i++) { xi = sk_X509_INFO_value(ret, i); X509_INFO_free(xi); } if (ret != sk) sk_X509_INFO_free(ret); ret = NULL; } free(name); free(header); free(data); return (ret); } /* A TJH addition */ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u) { EVP_CIPHER_CTX ctx; int i, ret = 0; unsigned char *data = NULL; const char *objstr = NULL; char buf[PEM_BUFSIZE]; unsigned char *iv = NULL; if (enc != NULL) { objstr = OBJ_nid2sn(EVP_CIPHER_nid(enc)); if (objstr == NULL) { PEMerr(PEM_F_PEM_X509_INFO_WRITE_BIO, PEM_R_UNSUPPORTED_CIPHER); goto err; } } /* now for the fun part ... if we have a private key then * we have to be able to handle a not-yet-decrypted key * being written out correctly ... if it is decrypted or * it is non-encrypted then we use the base code */ if (xi->x_pkey != NULL) { if ((xi->enc_data != NULL) && (xi->enc_len > 0) ) { if (enc == NULL) { PEMerr(PEM_F_PEM_X509_INFO_WRITE_BIO, PEM_R_CIPHER_IS_NULL); goto err; } /* copy from weirdo names into more normal things */ iv = xi->enc_cipher.iv; data = (unsigned char *)xi->enc_data; i = xi->enc_len; /* we take the encryption data from the * internal stuff rather than what the * user has passed us ... as we have to * match exactly for some strange reason */ objstr = OBJ_nid2sn( EVP_CIPHER_nid(xi->enc_cipher.cipher)); if (objstr == NULL) { PEMerr(PEM_F_PEM_X509_INFO_WRITE_BIO, PEM_R_UNSUPPORTED_CIPHER); goto err; } /* create the right magic header stuff */ OPENSSL_assert(strlen(objstr) + 23 + 2 * enc->iv_len + 13 <= sizeof buf); buf[0] = '\0'; PEM_proc_type(buf, PEM_TYPE_ENCRYPTED); PEM_dek_info(buf, objstr, enc->iv_len, (char *)iv); /* use the normal code to write things out */ i = PEM_write_bio(bp, PEM_STRING_RSA, buf, data, i); if (i <= 0) goto err; } else { /* Add DSA/DH */ #ifndef OPENSSL_NO_RSA /* normal optionally encrypted stuff */ if (PEM_write_bio_RSAPrivateKey(bp, xi->x_pkey->dec_pkey->pkey.rsa, enc, kstr, klen, cb, u) <= 0) goto err; #endif } } /* if we have a certificate then write it out now */ if ((xi->x509 != NULL) && (PEM_write_bio_X509(bp, xi->x509) <= 0)) goto err; /* we are ignoring anything else that is loaded into the X509_INFO * structure for the moment ... as I don't need it so I'm not * coding it here and Eric can do it when this makes it into the * base library --tjh */ ret = 1; err: OPENSSL_cleanse((char *)&ctx, sizeof(ctx)); OPENSSL_cleanse(buf, PEM_BUFSIZE); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pem/pem_err.c0000644000175000017500000001660312360020706020640 0ustar /* $OpenBSD: pem_err.c,v 1.10 2014/06/12 15:49:30 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_PEM,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_PEM,0,reason) static ERR_STRING_DATA PEM_str_functs[] = { {ERR_FUNC(PEM_F_B2I_DSS), "B2I_DSS"}, {ERR_FUNC(PEM_F_B2I_PVK_BIO), "b2i_PVK_bio"}, {ERR_FUNC(PEM_F_B2I_RSA), "B2I_RSA"}, {ERR_FUNC(PEM_F_CHECK_BITLEN_DSA), "CHECK_BITLEN_DSA"}, {ERR_FUNC(PEM_F_CHECK_BITLEN_RSA), "CHECK_BITLEN_RSA"}, {ERR_FUNC(PEM_F_D2I_PKCS8PRIVATEKEY_BIO), "d2i_PKCS8PrivateKey_bio"}, {ERR_FUNC(PEM_F_D2I_PKCS8PRIVATEKEY_FP), "d2i_PKCS8PrivateKey_fp"}, {ERR_FUNC(PEM_F_DO_B2I), "DO_B2I"}, {ERR_FUNC(PEM_F_DO_B2I_BIO), "DO_B2I_BIO"}, {ERR_FUNC(PEM_F_DO_BLOB_HEADER), "DO_BLOB_HEADER"}, {ERR_FUNC(PEM_F_DO_PK8PKEY), "DO_PK8PKEY"}, {ERR_FUNC(PEM_F_DO_PK8PKEY_FP), "DO_PK8PKEY_FP"}, {ERR_FUNC(PEM_F_DO_PVK_BODY), "DO_PVK_BODY"}, {ERR_FUNC(PEM_F_DO_PVK_HEADER), "DO_PVK_HEADER"}, {ERR_FUNC(PEM_F_I2B_PVK), "I2B_PVK"}, {ERR_FUNC(PEM_F_I2B_PVK_BIO), "i2b_PVK_bio"}, {ERR_FUNC(PEM_F_LOAD_IV), "LOAD_IV"}, {ERR_FUNC(PEM_F_PEM_ASN1_READ), "PEM_ASN1_read"}, {ERR_FUNC(PEM_F_PEM_ASN1_READ_BIO), "PEM_ASN1_read_bio"}, {ERR_FUNC(PEM_F_PEM_ASN1_WRITE), "PEM_ASN1_write"}, {ERR_FUNC(PEM_F_PEM_ASN1_WRITE_BIO), "PEM_ASN1_write_bio"}, {ERR_FUNC(PEM_F_PEM_DEF_CALLBACK), "PEM_def_callback"}, {ERR_FUNC(PEM_F_PEM_DO_HEADER), "PEM_do_header"}, {ERR_FUNC(PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY), "PEM_F_PEM_WRITE_PKCS8PRIVATEKEY"}, {ERR_FUNC(PEM_F_PEM_GET_EVP_CIPHER_INFO), "PEM_get_EVP_CIPHER_INFO"}, {ERR_FUNC(PEM_F_PEM_PK8PKEY), "PEM_PK8PKEY"}, {ERR_FUNC(PEM_F_PEM_READ), "PEM_read"}, {ERR_FUNC(PEM_F_PEM_READ_BIO), "PEM_read_bio"}, {ERR_FUNC(PEM_F_PEM_READ_BIO_PARAMETERS), "PEM_read_bio_Parameters"}, {ERR_FUNC(PEM_F_PEM_READ_BIO_PRIVATEKEY), "PEM_READ_BIO_PRIVATEKEY"}, {ERR_FUNC(PEM_F_PEM_READ_PRIVATEKEY), "PEM_READ_PRIVATEKEY"}, {ERR_FUNC(PEM_F_PEM_SEALFINAL), "PEM_SealFinal"}, {ERR_FUNC(PEM_F_PEM_SEALINIT), "PEM_SealInit"}, {ERR_FUNC(PEM_F_PEM_SIGNFINAL), "PEM_SignFinal"}, {ERR_FUNC(PEM_F_PEM_WRITE), "PEM_write"}, {ERR_FUNC(PEM_F_PEM_WRITE_BIO), "PEM_write_bio"}, {ERR_FUNC(PEM_F_PEM_WRITE_PRIVATEKEY), "PEM_WRITE_PRIVATEKEY"}, {ERR_FUNC(PEM_F_PEM_X509_INFO_READ), "PEM_X509_INFO_read"}, {ERR_FUNC(PEM_F_PEM_X509_INFO_READ_BIO), "PEM_X509_INFO_read_bio"}, {ERR_FUNC(PEM_F_PEM_X509_INFO_WRITE_BIO), "PEM_X509_INFO_write_bio"}, {0, NULL} }; static ERR_STRING_DATA PEM_str_reasons[] = { {ERR_REASON(PEM_R_BAD_BASE64_DECODE) , "bad base64 decode"}, {ERR_REASON(PEM_R_BAD_DECRYPT) , "bad decrypt"}, {ERR_REASON(PEM_R_BAD_END_LINE) , "bad end line"}, {ERR_REASON(PEM_R_BAD_IV_CHARS) , "bad iv chars"}, {ERR_REASON(PEM_R_BAD_MAGIC_NUMBER) , "bad magic number"}, {ERR_REASON(PEM_R_BAD_PASSWORD_READ) , "bad password read"}, {ERR_REASON(PEM_R_BAD_VERSION_NUMBER) , "bad version number"}, {ERR_REASON(PEM_R_BIO_WRITE_FAILURE) , "bio write failure"}, {ERR_REASON(PEM_R_CIPHER_IS_NULL) , "cipher is null"}, {ERR_REASON(PEM_R_ERROR_CONVERTING_PRIVATE_KEY), "error converting private key"}, {ERR_REASON(PEM_R_EXPECTING_PRIVATE_KEY_BLOB), "expecting private key blob"}, {ERR_REASON(PEM_R_EXPECTING_PUBLIC_KEY_BLOB), "expecting public key blob"}, {ERR_REASON(PEM_R_INCONSISTENT_HEADER) , "inconsistent header"}, {ERR_REASON(PEM_R_KEYBLOB_HEADER_PARSE_ERROR), "keyblob header parse error"}, {ERR_REASON(PEM_R_KEYBLOB_TOO_SHORT) , "keyblob too short"}, {ERR_REASON(PEM_R_NOT_DEK_INFO) , "not dek info"}, {ERR_REASON(PEM_R_NOT_ENCRYPTED) , "not encrypted"}, {ERR_REASON(PEM_R_NOT_PROC_TYPE) , "not proc type"}, {ERR_REASON(PEM_R_NO_START_LINE) , "no start line"}, {ERR_REASON(PEM_R_PROBLEMS_GETTING_PASSWORD), "problems getting password"}, {ERR_REASON(PEM_R_PUBLIC_KEY_NO_RSA) , "public key no rsa"}, {ERR_REASON(PEM_R_PVK_DATA_TOO_SHORT) , "pvk data too short"}, {ERR_REASON(PEM_R_PVK_TOO_SHORT) , "pvk too short"}, {ERR_REASON(PEM_R_READ_KEY) , "read key"}, {ERR_REASON(PEM_R_SHORT_HEADER) , "short header"}, {ERR_REASON(PEM_R_UNSUPPORTED_CIPHER) , "unsupported cipher"}, {ERR_REASON(PEM_R_UNSUPPORTED_ENCRYPTION), "unsupported encryption"}, {ERR_REASON(PEM_R_UNSUPPORTED_KEY_COMPONENTS), "unsupported key components"}, {0, NULL} }; #endif void ERR_load_PEM_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(PEM_str_functs[0].error) == NULL) { ERR_load_strings(0, PEM_str_functs); ERR_load_strings(0, PEM_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/sha/0000755000000000000000000000000012666635521020625 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/sha/sha_one.c0000644000175000017500000000713112360020706020611 0ustar /* $OpenBSD: sha_one.c,v 1.7 2014/06/12 15:49:30 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #ifndef OPENSSL_NO_SHA0 unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md) { SHA_CTX c; static unsigned char m[SHA_DIGEST_LENGTH]; if (md == NULL) md=m; if (!SHA_Init(&c)) return NULL; SHA_Update(&c,d,n); SHA_Final(md,&c); OPENSSL_cleanse(&c,sizeof(c)); return(md); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/sha/sha_dgst.c0000644000175000017500000000665112360020706020777 0ustar /* $OpenBSD: sha_dgst.c,v 1.11 2014/07/09 11:10:51 bcook Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #if !defined(OPENSSL_NO_SHA0) && !defined(OPENSSL_NO_SHA) #undef SHA_1 #define SHA_0 #include /* The implementation is in ../md32_common.h */ #include "sha_locl.h" #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/sha/sha512.c0000644000175000017500000004221012360020706020175 0ustar /* $OpenBSD: sha512.c,v 1.12 2014/07/10 22:45:58 jsing Exp $ */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved * according to the OpenSSL license [found in ../../LICENSE]. * ==================================================================== */ #include #include #include #include #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA512) /* * IMPLEMENTATION NOTES. * * As you might have noticed 32-bit hash algorithms: * * - permit SHA_LONG to be wider than 32-bit (case on CRAY); * - optimized versions implement two transform functions: one operating * on [aligned] data in host byte order and one - on data in input * stream byte order; * - share common byte-order neutral collector and padding function * implementations, ../md32_common.h; * * Neither of the above applies to this SHA-512 implementations. Reasons * [in reverse order] are: * * - it's the only 64-bit hash algorithm for the moment of this writing, * there is no need for common collector/padding implementation [yet]; * - by supporting only one transform function [which operates on * *aligned* data in input stream byte order, big-endian in this case] * we minimize burden of maintenance in two ways: a) collector/padding * function is simpler; b) only one transform function to stare at; * - SHA_LONG64 is required to be exactly 64-bit in order to be able to * apply a number of optimizations to mitigate potential performance * penalties caused by previous design decision; * * Caveat lector. * * Implementation relies on the fact that "long long" is 64-bit on * both 32- and 64-bit platforms. If some compiler vendor comes up * with 128-bit long long, adjustment to sha.h would be required. * As this implementation relies on 64-bit integer type, it's totally * inappropriate for platforms which don't support it, most notably * 16-bit platforms. * */ #include #include #include #if !defined(__STRICT_ALIGNMENT) || defined(SHA512_ASM) #define SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA #endif int SHA384_Init(SHA512_CTX *c) { c->h[0]=U64(0xcbbb9d5dc1059ed8); c->h[1]=U64(0x629a292a367cd507); c->h[2]=U64(0x9159015a3070dd17); c->h[3]=U64(0x152fecd8f70e5939); c->h[4]=U64(0x67332667ffc00b31); c->h[5]=U64(0x8eb44a8768581511); c->h[6]=U64(0xdb0c2e0d64f98fa7); c->h[7]=U64(0x47b5481dbefa4fa4); c->Nl=0; c->Nh=0; c->num=0; c->md_len=SHA384_DIGEST_LENGTH; return 1; } int SHA512_Init(SHA512_CTX *c) { c->h[0]=U64(0x6a09e667f3bcc908); c->h[1]=U64(0xbb67ae8584caa73b); c->h[2]=U64(0x3c6ef372fe94f82b); c->h[3]=U64(0xa54ff53a5f1d36f1); c->h[4]=U64(0x510e527fade682d1); c->h[5]=U64(0x9b05688c2b3e6c1f); c->h[6]=U64(0x1f83d9abfb41bd6b); c->h[7]=U64(0x5be0cd19137e2179); c->Nl=0; c->Nh=0; c->num=0; c->md_len=SHA512_DIGEST_LENGTH; return 1; } #ifndef SHA512_ASM static #endif void sha512_block_data_order (SHA512_CTX *ctx, const void *in, size_t num); int SHA512_Final (unsigned char *md, SHA512_CTX *c) { unsigned char *p=(unsigned char *)c->u.p; size_t n=c->num; p[n]=0x80; /* There always is a room for one */ n++; if (n > (sizeof(c->u)-16)) memset (p+n,0,sizeof(c->u)-n), n=0, sha512_block_data_order (c,p,1); memset (p+n,0,sizeof(c->u)-16-n); #if BYTE_ORDER == BIG_ENDIAN c->u.d[SHA_LBLOCK-2] = c->Nh; c->u.d[SHA_LBLOCK-1] = c->Nl; #else p[sizeof(c->u)-1] = (unsigned char)(c->Nl); p[sizeof(c->u)-2] = (unsigned char)(c->Nl>>8); p[sizeof(c->u)-3] = (unsigned char)(c->Nl>>16); p[sizeof(c->u)-4] = (unsigned char)(c->Nl>>24); p[sizeof(c->u)-5] = (unsigned char)(c->Nl>>32); p[sizeof(c->u)-6] = (unsigned char)(c->Nl>>40); p[sizeof(c->u)-7] = (unsigned char)(c->Nl>>48); p[sizeof(c->u)-8] = (unsigned char)(c->Nl>>56); p[sizeof(c->u)-9] = (unsigned char)(c->Nh); p[sizeof(c->u)-10] = (unsigned char)(c->Nh>>8); p[sizeof(c->u)-11] = (unsigned char)(c->Nh>>16); p[sizeof(c->u)-12] = (unsigned char)(c->Nh>>24); p[sizeof(c->u)-13] = (unsigned char)(c->Nh>>32); p[sizeof(c->u)-14] = (unsigned char)(c->Nh>>40); p[sizeof(c->u)-15] = (unsigned char)(c->Nh>>48); p[sizeof(c->u)-16] = (unsigned char)(c->Nh>>56); #endif sha512_block_data_order (c,p,1); if (md==0) return 0; switch (c->md_len) { /* Let compiler decide if it's appropriate to unroll... */ case SHA384_DIGEST_LENGTH: for (n=0;nh[n]; *(md++) = (unsigned char)(t>>56); *(md++) = (unsigned char)(t>>48); *(md++) = (unsigned char)(t>>40); *(md++) = (unsigned char)(t>>32); *(md++) = (unsigned char)(t>>24); *(md++) = (unsigned char)(t>>16); *(md++) = (unsigned char)(t>>8); *(md++) = (unsigned char)(t); } break; case SHA512_DIGEST_LENGTH: for (n=0;nh[n]; *(md++) = (unsigned char)(t>>56); *(md++) = (unsigned char)(t>>48); *(md++) = (unsigned char)(t>>40); *(md++) = (unsigned char)(t>>32); *(md++) = (unsigned char)(t>>24); *(md++) = (unsigned char)(t>>16); *(md++) = (unsigned char)(t>>8); *(md++) = (unsigned char)(t); } break; /* ... as well as make sure md_len is not abused. */ default: return 0; } return 1; } int SHA384_Final (unsigned char *md,SHA512_CTX *c) { return SHA512_Final (md,c); } int SHA512_Update (SHA512_CTX *c, const void *_data, size_t len) { SHA_LONG64 l; unsigned char *p=c->u.p; const unsigned char *data=(const unsigned char *)_data; if (len==0) return 1; l = (c->Nl+(((SHA_LONG64)len)<<3))&U64(0xffffffffffffffff); if (l < c->Nl) c->Nh++; if (sizeof(len)>=8) c->Nh+=(((SHA_LONG64)len)>>61); c->Nl=l; if (c->num != 0) { size_t n = sizeof(c->u) - c->num; if (len < n) { memcpy (p+c->num,data,len), c->num += (unsigned int)len; return 1; } else { memcpy (p+c->num,data,n), c->num = 0; len-=n, data+=n; sha512_block_data_order (c,p,1); } } if (len >= sizeof(c->u)) { #ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA if ((size_t)data%sizeof(c->u.d[0]) != 0) while (len >= sizeof(c->u)) memcpy (p,data,sizeof(c->u)), sha512_block_data_order (c,p,1), len -= sizeof(c->u), data += sizeof(c->u); else #endif sha512_block_data_order (c,data,len/sizeof(c->u)), data += len, len %= sizeof(c->u), data -= len; } if (len != 0) memcpy (p,data,len), c->num = (int)len; return 1; } int SHA384_Update (SHA512_CTX *c, const void *data, size_t len) { return SHA512_Update (c,data,len); } void SHA512_Transform (SHA512_CTX *c, const unsigned char *data) { #ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA if ((size_t)data%sizeof(c->u.d[0]) != 0) memcpy(c->u.p,data,sizeof(c->u.p)), data = c->u.p; #endif sha512_block_data_order (c,data,1); } unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md) { SHA512_CTX c; static unsigned char m[SHA384_DIGEST_LENGTH]; if (md == NULL) md=m; SHA384_Init(&c); SHA512_Update(&c,d,n); SHA512_Final(md,&c); OPENSSL_cleanse(&c,sizeof(c)); return(md); } unsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md) { SHA512_CTX c; static unsigned char m[SHA512_DIGEST_LENGTH]; if (md == NULL) md=m; SHA512_Init(&c); SHA512_Update(&c,d,n); SHA512_Final(md,&c); OPENSSL_cleanse(&c,sizeof(c)); return(md); } #ifndef SHA512_ASM static const SHA_LONG64 K512[80] = { U64(0x428a2f98d728ae22),U64(0x7137449123ef65cd), U64(0xb5c0fbcfec4d3b2f),U64(0xe9b5dba58189dbbc), U64(0x3956c25bf348b538),U64(0x59f111f1b605d019), U64(0x923f82a4af194f9b),U64(0xab1c5ed5da6d8118), U64(0xd807aa98a3030242),U64(0x12835b0145706fbe), U64(0x243185be4ee4b28c),U64(0x550c7dc3d5ffb4e2), U64(0x72be5d74f27b896f),U64(0x80deb1fe3b1696b1), U64(0x9bdc06a725c71235),U64(0xc19bf174cf692694), U64(0xe49b69c19ef14ad2),U64(0xefbe4786384f25e3), U64(0x0fc19dc68b8cd5b5),U64(0x240ca1cc77ac9c65), U64(0x2de92c6f592b0275),U64(0x4a7484aa6ea6e483), U64(0x5cb0a9dcbd41fbd4),U64(0x76f988da831153b5), U64(0x983e5152ee66dfab),U64(0xa831c66d2db43210), U64(0xb00327c898fb213f),U64(0xbf597fc7beef0ee4), U64(0xc6e00bf33da88fc2),U64(0xd5a79147930aa725), U64(0x06ca6351e003826f),U64(0x142929670a0e6e70), U64(0x27b70a8546d22ffc),U64(0x2e1b21385c26c926), U64(0x4d2c6dfc5ac42aed),U64(0x53380d139d95b3df), U64(0x650a73548baf63de),U64(0x766a0abb3c77b2a8), U64(0x81c2c92e47edaee6),U64(0x92722c851482353b), U64(0xa2bfe8a14cf10364),U64(0xa81a664bbc423001), U64(0xc24b8b70d0f89791),U64(0xc76c51a30654be30), U64(0xd192e819d6ef5218),U64(0xd69906245565a910), U64(0xf40e35855771202a),U64(0x106aa07032bbd1b8), U64(0x19a4c116b8d2d0c8),U64(0x1e376c085141ab53), U64(0x2748774cdf8eeb99),U64(0x34b0bcb5e19b48a8), U64(0x391c0cb3c5c95a63),U64(0x4ed8aa4ae3418acb), U64(0x5b9cca4f7763e373),U64(0x682e6ff3d6b2b8a3), U64(0x748f82ee5defb2fc),U64(0x78a5636f43172f60), U64(0x84c87814a1f0ab72),U64(0x8cc702081a6439ec), U64(0x90befffa23631e28),U64(0xa4506cebde82bde9), U64(0xbef9a3f7b2c67915),U64(0xc67178f2e372532b), U64(0xca273eceea26619c),U64(0xd186b8c721c0c207), U64(0xeada7dd6cde0eb1e),U64(0xf57d4f7fee6ed178), U64(0x06f067aa72176fba),U64(0x0a637dc5a2c898a6), U64(0x113f9804bef90dae),U64(0x1b710b35131c471b), U64(0x28db77f523047d84),U64(0x32caab7b40c72493), U64(0x3c9ebe0a15c9bebc),U64(0x431d67c49c100d4c), U64(0x4cc5d4becb3e42b6),U64(0x597f299cfc657e2a), U64(0x5fcb6fab3ad6faec),U64(0x6c44198c4a475817) }; #if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) # if defined(__x86_64) || defined(__x86_64__) # define ROTR(a,n) ({ SHA_LONG64 ret; \ asm ("rorq %1,%0" \ : "=r"(ret) \ : "J"(n),"0"(a) \ : "cc"); ret; }) # define PULL64(x) ({ SHA_LONG64 ret=*((const SHA_LONG64 *)(&(x))); \ asm ("bswapq %0" \ : "=r"(ret) \ : "0"(ret)); ret; }) # elif (defined(__i386) || defined(__i386__)) # if defined(I386_ONLY) # define PULL64(x) ({ const unsigned int *p=(const unsigned int *)(&(x));\ unsigned int hi=p[0],lo=p[1]; \ asm("xchgb %%ah,%%al;xchgb %%dh,%%dl;"\ "roll $16,%%eax; roll $16,%%edx; "\ "xchgb %%ah,%%al;xchgb %%dh,%%dl;" \ : "=a"(lo),"=d"(hi) \ : "0"(lo),"1"(hi) : "cc"); \ ((SHA_LONG64)hi)<<32|lo; }) # else # define PULL64(x) ({ const unsigned int *p=(const unsigned int *)(&(x));\ unsigned int hi=p[0],lo=p[1]; \ asm ("bswapl %0; bswapl %1;" \ : "=r"(lo),"=r"(hi) \ : "0"(lo),"1"(hi)); \ ((SHA_LONG64)hi)<<32|lo; }) # endif # elif (defined(_ARCH_PPC) && defined(__64BIT__)) || defined(_ARCH_PPC64) # define ROTR(a,n) ({ SHA_LONG64 ret; \ asm ("rotrdi %0,%1,%2" \ : "=r"(ret) \ : "r"(a),"K"(n)); ret; }) # endif #endif #ifndef PULL64 #define B(x,j) (((SHA_LONG64)(*(((const unsigned char *)(&x))+j)))<<((7-j)*8)) #define PULL64(x) (B(x,0)|B(x,1)|B(x,2)|B(x,3)|B(x,4)|B(x,5)|B(x,6)|B(x,7)) #endif #ifndef ROTR #define ROTR(x,s) (((x)>>s) | (x)<<(64-s)) #endif #define Sigma0(x) (ROTR((x),28) ^ ROTR((x),34) ^ ROTR((x),39)) #define Sigma1(x) (ROTR((x),14) ^ ROTR((x),18) ^ ROTR((x),41)) #define sigma0(x) (ROTR((x),1) ^ ROTR((x),8) ^ ((x)>>7)) #define sigma1(x) (ROTR((x),19) ^ ROTR((x),61) ^ ((x)>>6)) #define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) #define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) #if defined(__i386) || defined(__i386__) || defined(_M_IX86) /* * This code should give better results on 32-bit CPU with less than * ~24 registers, both size and performance wise... */ static void sha512_block_data_order (SHA512_CTX *ctx, const void *in, size_t num) { const SHA_LONG64 *W=in; SHA_LONG64 A,E,T; SHA_LONG64 X[9+80],*F; int i; while (num--) { F = X+80; A = ctx->h[0]; F[1] = ctx->h[1]; F[2] = ctx->h[2]; F[3] = ctx->h[3]; E = ctx->h[4]; F[5] = ctx->h[5]; F[6] = ctx->h[6]; F[7] = ctx->h[7]; for (i=0;i<16;i++,F--) { T = PULL64(W[i]); F[0] = A; F[4] = E; F[8] = T; T += F[7] + Sigma1(E) + Ch(E,F[5],F[6]) + K512[i]; E = F[3] + T; A = T + Sigma0(A) + Maj(A,F[1],F[2]); } for (;i<80;i++,F--) { T = sigma0(F[8+16-1]); T += sigma1(F[8+16-14]); T += F[8+16] + F[8+16-9]; F[0] = A; F[4] = E; F[8] = T; T += F[7] + Sigma1(E) + Ch(E,F[5],F[6]) + K512[i]; E = F[3] + T; A = T + Sigma0(A) + Maj(A,F[1],F[2]); } ctx->h[0] += A; ctx->h[1] += F[1]; ctx->h[2] += F[2]; ctx->h[3] += F[3]; ctx->h[4] += E; ctx->h[5] += F[5]; ctx->h[6] += F[6]; ctx->h[7] += F[7]; W+=SHA_LBLOCK; } } #elif defined(OPENSSL_SMALL_FOOTPRINT) static void sha512_block_data_order (SHA512_CTX *ctx, const void *in, size_t num) { const SHA_LONG64 *W=in; SHA_LONG64 a,b,c,d,e,f,g,h,s0,s1,T1,T2; SHA_LONG64 X[16]; int i; while (num--) { a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3]; e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7]; for (i=0;i<16;i++) { #if BYTE_ORDER == BIG_ENDIAN T1 = X[i] = W[i]; #else T1 = X[i] = PULL64(W[i]); #endif T1 += h + Sigma1(e) + Ch(e,f,g) + K512[i]; T2 = Sigma0(a) + Maj(a,b,c); h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2; } for (;i<80;i++) { s0 = X[(i+1)&0x0f]; s0 = sigma0(s0); s1 = X[(i+14)&0x0f]; s1 = sigma1(s1); T1 = X[i&0xf] += s0 + s1 + X[(i+9)&0xf]; T1 += h + Sigma1(e) + Ch(e,f,g) + K512[i]; T2 = Sigma0(a) + Maj(a,b,c); h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2; } ctx->h[0] += a; ctx->h[1] += b; ctx->h[2] += c; ctx->h[3] += d; ctx->h[4] += e; ctx->h[5] += f; ctx->h[6] += g; ctx->h[7] += h; W+=SHA_LBLOCK; } } #else #define ROUND_00_15(i,a,b,c,d,e,f,g,h) do { \ T1 += h + Sigma1(e) + Ch(e,f,g) + K512[i]; \ h = Sigma0(a) + Maj(a,b,c); \ d += T1; h += T1; } while (0) #define ROUND_16_80(i,j,a,b,c,d,e,f,g,h,X) do { \ s0 = X[(j+1)&0x0f]; s0 = sigma0(s0); \ s1 = X[(j+14)&0x0f]; s1 = sigma1(s1); \ T1 = X[(j)&0x0f] += s0 + s1 + X[(j+9)&0x0f]; \ ROUND_00_15(i+j,a,b,c,d,e,f,g,h); } while (0) static void sha512_block_data_order (SHA512_CTX *ctx, const void *in, size_t num) { const SHA_LONG64 *W=in; SHA_LONG64 a,b,c,d,e,f,g,h,s0,s1,T1; SHA_LONG64 X[16]; int i; while (num--) { a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3]; e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7]; #if BYTE_ORDER == BIG_ENDIAN T1 = X[0] = W[0]; ROUND_00_15(0,a,b,c,d,e,f,g,h); T1 = X[1] = W[1]; ROUND_00_15(1,h,a,b,c,d,e,f,g); T1 = X[2] = W[2]; ROUND_00_15(2,g,h,a,b,c,d,e,f); T1 = X[3] = W[3]; ROUND_00_15(3,f,g,h,a,b,c,d,e); T1 = X[4] = W[4]; ROUND_00_15(4,e,f,g,h,a,b,c,d); T1 = X[5] = W[5]; ROUND_00_15(5,d,e,f,g,h,a,b,c); T1 = X[6] = W[6]; ROUND_00_15(6,c,d,e,f,g,h,a,b); T1 = X[7] = W[7]; ROUND_00_15(7,b,c,d,e,f,g,h,a); T1 = X[8] = W[8]; ROUND_00_15(8,a,b,c,d,e,f,g,h); T1 = X[9] = W[9]; ROUND_00_15(9,h,a,b,c,d,e,f,g); T1 = X[10] = W[10]; ROUND_00_15(10,g,h,a,b,c,d,e,f); T1 = X[11] = W[11]; ROUND_00_15(11,f,g,h,a,b,c,d,e); T1 = X[12] = W[12]; ROUND_00_15(12,e,f,g,h,a,b,c,d); T1 = X[13] = W[13]; ROUND_00_15(13,d,e,f,g,h,a,b,c); T1 = X[14] = W[14]; ROUND_00_15(14,c,d,e,f,g,h,a,b); T1 = X[15] = W[15]; ROUND_00_15(15,b,c,d,e,f,g,h,a); #else T1 = X[0] = PULL64(W[0]); ROUND_00_15(0,a,b,c,d,e,f,g,h); T1 = X[1] = PULL64(W[1]); ROUND_00_15(1,h,a,b,c,d,e,f,g); T1 = X[2] = PULL64(W[2]); ROUND_00_15(2,g,h,a,b,c,d,e,f); T1 = X[3] = PULL64(W[3]); ROUND_00_15(3,f,g,h,a,b,c,d,e); T1 = X[4] = PULL64(W[4]); ROUND_00_15(4,e,f,g,h,a,b,c,d); T1 = X[5] = PULL64(W[5]); ROUND_00_15(5,d,e,f,g,h,a,b,c); T1 = X[6] = PULL64(W[6]); ROUND_00_15(6,c,d,e,f,g,h,a,b); T1 = X[7] = PULL64(W[7]); ROUND_00_15(7,b,c,d,e,f,g,h,a); T1 = X[8] = PULL64(W[8]); ROUND_00_15(8,a,b,c,d,e,f,g,h); T1 = X[9] = PULL64(W[9]); ROUND_00_15(9,h,a,b,c,d,e,f,g); T1 = X[10] = PULL64(W[10]); ROUND_00_15(10,g,h,a,b,c,d,e,f); T1 = X[11] = PULL64(W[11]); ROUND_00_15(11,f,g,h,a,b,c,d,e); T1 = X[12] = PULL64(W[12]); ROUND_00_15(12,e,f,g,h,a,b,c,d); T1 = X[13] = PULL64(W[13]); ROUND_00_15(13,d,e,f,g,h,a,b,c); T1 = X[14] = PULL64(W[14]); ROUND_00_15(14,c,d,e,f,g,h,a,b); T1 = X[15] = PULL64(W[15]); ROUND_00_15(15,b,c,d,e,f,g,h,a); #endif for (i=16;i<80;i+=16) { ROUND_16_80(i, 0,a,b,c,d,e,f,g,h,X); ROUND_16_80(i, 1,h,a,b,c,d,e,f,g,X); ROUND_16_80(i, 2,g,h,a,b,c,d,e,f,X); ROUND_16_80(i, 3,f,g,h,a,b,c,d,e,X); ROUND_16_80(i, 4,e,f,g,h,a,b,c,d,X); ROUND_16_80(i, 5,d,e,f,g,h,a,b,c,X); ROUND_16_80(i, 6,c,d,e,f,g,h,a,b,X); ROUND_16_80(i, 7,b,c,d,e,f,g,h,a,X); ROUND_16_80(i, 8,a,b,c,d,e,f,g,h,X); ROUND_16_80(i, 9,h,a,b,c,d,e,f,g,X); ROUND_16_80(i,10,g,h,a,b,c,d,e,f,X); ROUND_16_80(i,11,f,g,h,a,b,c,d,e,X); ROUND_16_80(i,12,e,f,g,h,a,b,c,d,X); ROUND_16_80(i,13,d,e,f,g,h,a,b,c,X); ROUND_16_80(i,14,c,d,e,f,g,h,a,b,X); ROUND_16_80(i,15,b,c,d,e,f,g,h,a,X); } ctx->h[0] += a; ctx->h[1] += b; ctx->h[2] += c; ctx->h[3] += d; ctx->h[4] += e; ctx->h[5] += f; ctx->h[6] += g; ctx->h[7] += h; W+=SHA_LBLOCK; } } #endif #endif /* SHA512_ASM */ #endif /* !OPENSSL_NO_SHA512 */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/sha/sha1_one.c0000644000175000017500000000713712360020706020700 0ustar /* $OpenBSD: sha1_one.c,v 1.10 2014/06/12 15:49:30 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #ifndef OPENSSL_NO_SHA1 unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md) { SHA_CTX c; static unsigned char m[SHA_DIGEST_LENGTH]; if (md == NULL) md=m; if (!SHA1_Init(&c)) return NULL; SHA1_Update(&c,d,n); SHA1_Final(md,&c); OPENSSL_cleanse(&c,sizeof(c)); return(md); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/sha/sha_locl.h0000644000175000017500000003620712360020706020774 0ustar /* $OpenBSD: sha_locl.h,v 1.16 2014/06/12 15:49:30 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #define DATA_ORDER_IS_BIG_ENDIAN #define HASH_LONG SHA_LONG #define HASH_CTX SHA_CTX #define HASH_CBLOCK SHA_CBLOCK #define HASH_MAKE_STRING(c,s) do { \ unsigned long ll; \ ll=(c)->h0; (void)HOST_l2c(ll,(s)); \ ll=(c)->h1; (void)HOST_l2c(ll,(s)); \ ll=(c)->h2; (void)HOST_l2c(ll,(s)); \ ll=(c)->h3; (void)HOST_l2c(ll,(s)); \ ll=(c)->h4; (void)HOST_l2c(ll,(s)); \ } while (0) #if defined(SHA_0) # define HASH_UPDATE SHA_Update # define HASH_TRANSFORM SHA_Transform # define HASH_FINAL SHA_Final # define HASH_INIT SHA_Init # define HASH_BLOCK_DATA_ORDER sha_block_data_order # define Xupdate(a,ix,ia,ib,ic,id) (ix=(a)=(ia^ib^ic^id)) static void sha_block_data_order (SHA_CTX *c, const void *p,size_t num); #elif defined(SHA_1) # define HASH_UPDATE SHA1_Update # define HASH_TRANSFORM SHA1_Transform # define HASH_FINAL SHA1_Final # define HASH_INIT SHA1_Init # define HASH_BLOCK_DATA_ORDER sha1_block_data_order # define Xupdate(a,ix,ia,ib,ic,id) ( (a)=(ia^ib^ic^id), \ ix=(a)=ROTATE((a),1) \ ) #ifndef SHA1_ASM static #endif void sha1_block_data_order (SHA_CTX *c, const void *p,size_t num); #else # error "Either SHA_0 or SHA_1 must be defined." #endif #include "md32_common.h" #define INIT_DATA_h0 0x67452301UL #define INIT_DATA_h1 0xefcdab89UL #define INIT_DATA_h2 0x98badcfeUL #define INIT_DATA_h3 0x10325476UL #define INIT_DATA_h4 0xc3d2e1f0UL #ifdef SHA_0 int SHA_Init(SHA_CTX *c) #else int SHA1_Init(SHA_CTX *c) #endif { memset (c,0,sizeof(*c)); c->h0=INIT_DATA_h0; c->h1=INIT_DATA_h1; c->h2=INIT_DATA_h2; c->h3=INIT_DATA_h3; c->h4=INIT_DATA_h4; return 1; } #define K_00_19 0x5a827999UL #define K_20_39 0x6ed9eba1UL #define K_40_59 0x8f1bbcdcUL #define K_60_79 0xca62c1d6UL /* As pointed out by Wei Dai , F() below can be * simplified to the code in F_00_19. Wei attributes these optimisations * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel. * #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z))) * I've just become aware of another tweak to be made, again from Wei Dai, * in F_40_59, (x&a)|(y&a) -> (x|y)&a */ #define F_00_19(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) #define F_20_39(b,c,d) ((b) ^ (c) ^ (d)) #define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d))) #define F_60_79(b,c,d) F_20_39(b,c,d) #ifndef OPENSSL_SMALL_FOOTPRINT #define BODY_00_15(i,a,b,c,d,e,f,xi) \ (f)=xi+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ (b)=ROTATE((b),30); #define BODY_16_19(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \ Xupdate(f,xi,xa,xb,xc,xd); \ (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ (b)=ROTATE((b),30); #define BODY_20_31(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \ Xupdate(f,xi,xa,xb,xc,xd); \ (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ (b)=ROTATE((b),30); #define BODY_32_39(i,a,b,c,d,e,f,xa,xb,xc,xd) \ Xupdate(f,xa,xa,xb,xc,xd); \ (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ (b)=ROTATE((b),30); #define BODY_40_59(i,a,b,c,d,e,f,xa,xb,xc,xd) \ Xupdate(f,xa,xa,xb,xc,xd); \ (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \ (b)=ROTATE((b),30); #define BODY_60_79(i,a,b,c,d,e,f,xa,xb,xc,xd) \ Xupdate(f,xa,xa,xb,xc,xd); \ (f)=xa+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \ (b)=ROTATE((b),30); #ifdef X #undef X #endif #ifndef MD32_XARRAY /* * Originally X was an array. As it's automatic it's natural * to expect RISC compiler to accomodate at least part of it in * the register bank, isn't it? Unfortunately not all compilers * "find" this expectation reasonable:-( On order to make such * compilers generate better code I replace X[] with a bunch of * X0, X1, etc. See the function body below... * */ # define X(i) XX##i #else /* * However! Some compilers (most notably HP C) get overwhelmed by * that many local variables so that we have to have the way to * fall down to the original behavior. */ # define X(i) XX[i] #endif #if !defined(SHA_1) || !defined(SHA1_ASM) #include static void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, size_t num) { const unsigned char *data=p; register unsigned MD32_REG_T A,B,C,D,E,T,l; #ifndef MD32_XARRAY unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; #else SHA_LONG XX[16]; #endif A=c->h0; B=c->h1; C=c->h2; D=c->h3; E=c->h4; for (;;) { if (BYTE_ORDER != LITTLE_ENDIAN && sizeof(SHA_LONG)==4 && ((size_t)p%4)==0) { const SHA_LONG *W=(const SHA_LONG *)data; X( 0) = W[0]; X( 1) = W[ 1]; BODY_00_15( 0,A,B,C,D,E,T,X( 0)); X( 2) = W[ 2]; BODY_00_15( 1,T,A,B,C,D,E,X( 1)); X( 3) = W[ 3]; BODY_00_15( 2,E,T,A,B,C,D,X( 2)); X( 4) = W[ 4]; BODY_00_15( 3,D,E,T,A,B,C,X( 3)); X( 5) = W[ 5]; BODY_00_15( 4,C,D,E,T,A,B,X( 4)); X( 6) = W[ 6]; BODY_00_15( 5,B,C,D,E,T,A,X( 5)); X( 7) = W[ 7]; BODY_00_15( 6,A,B,C,D,E,T,X( 6)); X( 8) = W[ 8]; BODY_00_15( 7,T,A,B,C,D,E,X( 7)); X( 9) = W[ 9]; BODY_00_15( 8,E,T,A,B,C,D,X( 8)); X(10) = W[10]; BODY_00_15( 9,D,E,T,A,B,C,X( 9)); X(11) = W[11]; BODY_00_15(10,C,D,E,T,A,B,X(10)); X(12) = W[12]; BODY_00_15(11,B,C,D,E,T,A,X(11)); X(13) = W[13]; BODY_00_15(12,A,B,C,D,E,T,X(12)); X(14) = W[14]; BODY_00_15(13,T,A,B,C,D,E,X(13)); X(15) = W[15]; BODY_00_15(14,E,T,A,B,C,D,X(14)); BODY_00_15(15,D,E,T,A,B,C,X(15)); data += SHA_CBLOCK; } else { (void)HOST_c2l(data,l); X( 0)=l; (void)HOST_c2l(data,l); X( 1)=l; BODY_00_15( 0,A,B,C,D,E,T,X( 0)); (void)HOST_c2l(data,l); X( 2)=l; BODY_00_15( 1,T,A,B,C,D,E,X( 1)); (void)HOST_c2l(data,l); X( 3)=l; BODY_00_15( 2,E,T,A,B,C,D,X( 2)); (void)HOST_c2l(data,l); X( 4)=l; BODY_00_15( 3,D,E,T,A,B,C,X( 3)); (void)HOST_c2l(data,l); X( 5)=l; BODY_00_15( 4,C,D,E,T,A,B,X( 4)); (void)HOST_c2l(data,l); X( 6)=l; BODY_00_15( 5,B,C,D,E,T,A,X( 5)); (void)HOST_c2l(data,l); X( 7)=l; BODY_00_15( 6,A,B,C,D,E,T,X( 6)); (void)HOST_c2l(data,l); X( 8)=l; BODY_00_15( 7,T,A,B,C,D,E,X( 7)); (void)HOST_c2l(data,l); X( 9)=l; BODY_00_15( 8,E,T,A,B,C,D,X( 8)); (void)HOST_c2l(data,l); X(10)=l; BODY_00_15( 9,D,E,T,A,B,C,X( 9)); (void)HOST_c2l(data,l); X(11)=l; BODY_00_15(10,C,D,E,T,A,B,X(10)); (void)HOST_c2l(data,l); X(12)=l; BODY_00_15(11,B,C,D,E,T,A,X(11)); (void)HOST_c2l(data,l); X(13)=l; BODY_00_15(12,A,B,C,D,E,T,X(12)); (void)HOST_c2l(data,l); X(14)=l; BODY_00_15(13,T,A,B,C,D,E,X(13)); (void)HOST_c2l(data,l); X(15)=l; BODY_00_15(14,E,T,A,B,C,D,X(14)); BODY_00_15(15,D,E,T,A,B,C,X(15)); } BODY_16_19(16,C,D,E,T,A,B,X( 0),X( 0),X( 2),X( 8),X(13)); BODY_16_19(17,B,C,D,E,T,A,X( 1),X( 1),X( 3),X( 9),X(14)); BODY_16_19(18,A,B,C,D,E,T,X( 2),X( 2),X( 4),X(10),X(15)); BODY_16_19(19,T,A,B,C,D,E,X( 3),X( 3),X( 5),X(11),X( 0)); BODY_20_31(20,E,T,A,B,C,D,X( 4),X( 4),X( 6),X(12),X( 1)); BODY_20_31(21,D,E,T,A,B,C,X( 5),X( 5),X( 7),X(13),X( 2)); BODY_20_31(22,C,D,E,T,A,B,X( 6),X( 6),X( 8),X(14),X( 3)); BODY_20_31(23,B,C,D,E,T,A,X( 7),X( 7),X( 9),X(15),X( 4)); BODY_20_31(24,A,B,C,D,E,T,X( 8),X( 8),X(10),X( 0),X( 5)); BODY_20_31(25,T,A,B,C,D,E,X( 9),X( 9),X(11),X( 1),X( 6)); BODY_20_31(26,E,T,A,B,C,D,X(10),X(10),X(12),X( 2),X( 7)); BODY_20_31(27,D,E,T,A,B,C,X(11),X(11),X(13),X( 3),X( 8)); BODY_20_31(28,C,D,E,T,A,B,X(12),X(12),X(14),X( 4),X( 9)); BODY_20_31(29,B,C,D,E,T,A,X(13),X(13),X(15),X( 5),X(10)); BODY_20_31(30,A,B,C,D,E,T,X(14),X(14),X( 0),X( 6),X(11)); BODY_20_31(31,T,A,B,C,D,E,X(15),X(15),X( 1),X( 7),X(12)); BODY_32_39(32,E,T,A,B,C,D,X( 0),X( 2),X( 8),X(13)); BODY_32_39(33,D,E,T,A,B,C,X( 1),X( 3),X( 9),X(14)); BODY_32_39(34,C,D,E,T,A,B,X( 2),X( 4),X(10),X(15)); BODY_32_39(35,B,C,D,E,T,A,X( 3),X( 5),X(11),X( 0)); BODY_32_39(36,A,B,C,D,E,T,X( 4),X( 6),X(12),X( 1)); BODY_32_39(37,T,A,B,C,D,E,X( 5),X( 7),X(13),X( 2)); BODY_32_39(38,E,T,A,B,C,D,X( 6),X( 8),X(14),X( 3)); BODY_32_39(39,D,E,T,A,B,C,X( 7),X( 9),X(15),X( 4)); BODY_40_59(40,C,D,E,T,A,B,X( 8),X(10),X( 0),X( 5)); BODY_40_59(41,B,C,D,E,T,A,X( 9),X(11),X( 1),X( 6)); BODY_40_59(42,A,B,C,D,E,T,X(10),X(12),X( 2),X( 7)); BODY_40_59(43,T,A,B,C,D,E,X(11),X(13),X( 3),X( 8)); BODY_40_59(44,E,T,A,B,C,D,X(12),X(14),X( 4),X( 9)); BODY_40_59(45,D,E,T,A,B,C,X(13),X(15),X( 5),X(10)); BODY_40_59(46,C,D,E,T,A,B,X(14),X( 0),X( 6),X(11)); BODY_40_59(47,B,C,D,E,T,A,X(15),X( 1),X( 7),X(12)); BODY_40_59(48,A,B,C,D,E,T,X( 0),X( 2),X( 8),X(13)); BODY_40_59(49,T,A,B,C,D,E,X( 1),X( 3),X( 9),X(14)); BODY_40_59(50,E,T,A,B,C,D,X( 2),X( 4),X(10),X(15)); BODY_40_59(51,D,E,T,A,B,C,X( 3),X( 5),X(11),X( 0)); BODY_40_59(52,C,D,E,T,A,B,X( 4),X( 6),X(12),X( 1)); BODY_40_59(53,B,C,D,E,T,A,X( 5),X( 7),X(13),X( 2)); BODY_40_59(54,A,B,C,D,E,T,X( 6),X( 8),X(14),X( 3)); BODY_40_59(55,T,A,B,C,D,E,X( 7),X( 9),X(15),X( 4)); BODY_40_59(56,E,T,A,B,C,D,X( 8),X(10),X( 0),X( 5)); BODY_40_59(57,D,E,T,A,B,C,X( 9),X(11),X( 1),X( 6)); BODY_40_59(58,C,D,E,T,A,B,X(10),X(12),X( 2),X( 7)); BODY_40_59(59,B,C,D,E,T,A,X(11),X(13),X( 3),X( 8)); BODY_60_79(60,A,B,C,D,E,T,X(12),X(14),X( 4),X( 9)); BODY_60_79(61,T,A,B,C,D,E,X(13),X(15),X( 5),X(10)); BODY_60_79(62,E,T,A,B,C,D,X(14),X( 0),X( 6),X(11)); BODY_60_79(63,D,E,T,A,B,C,X(15),X( 1),X( 7),X(12)); BODY_60_79(64,C,D,E,T,A,B,X( 0),X( 2),X( 8),X(13)); BODY_60_79(65,B,C,D,E,T,A,X( 1),X( 3),X( 9),X(14)); BODY_60_79(66,A,B,C,D,E,T,X( 2),X( 4),X(10),X(15)); BODY_60_79(67,T,A,B,C,D,E,X( 3),X( 5),X(11),X( 0)); BODY_60_79(68,E,T,A,B,C,D,X( 4),X( 6),X(12),X( 1)); BODY_60_79(69,D,E,T,A,B,C,X( 5),X( 7),X(13),X( 2)); BODY_60_79(70,C,D,E,T,A,B,X( 6),X( 8),X(14),X( 3)); BODY_60_79(71,B,C,D,E,T,A,X( 7),X( 9),X(15),X( 4)); BODY_60_79(72,A,B,C,D,E,T,X( 8),X(10),X( 0),X( 5)); BODY_60_79(73,T,A,B,C,D,E,X( 9),X(11),X( 1),X( 6)); BODY_60_79(74,E,T,A,B,C,D,X(10),X(12),X( 2),X( 7)); BODY_60_79(75,D,E,T,A,B,C,X(11),X(13),X( 3),X( 8)); BODY_60_79(76,C,D,E,T,A,B,X(12),X(14),X( 4),X( 9)); BODY_60_79(77,B,C,D,E,T,A,X(13),X(15),X( 5),X(10)); BODY_60_79(78,A,B,C,D,E,T,X(14),X( 0),X( 6),X(11)); BODY_60_79(79,T,A,B,C,D,E,X(15),X( 1),X( 7),X(12)); c->h0=(c->h0+E)&0xffffffffL; c->h1=(c->h1+T)&0xffffffffL; c->h2=(c->h2+A)&0xffffffffL; c->h3=(c->h3+B)&0xffffffffL; c->h4=(c->h4+C)&0xffffffffL; if (--num == 0) break; A=c->h0; B=c->h1; C=c->h2; D=c->h3; E=c->h4; } } #endif #else /* OPENSSL_SMALL_FOOTPRINT */ #define BODY_00_15(xi) do { \ T=E+K_00_19+F_00_19(B,C,D); \ E=D, D=C, C=ROTATE(B,30), B=A; \ A=ROTATE(A,5)+T+xi; } while(0) #define BODY_16_19(xa,xb,xc,xd) do { \ Xupdate(T,xa,xa,xb,xc,xd); \ T+=E+K_00_19+F_00_19(B,C,D); \ E=D, D=C, C=ROTATE(B,30), B=A; \ A=ROTATE(A,5)+T; } while(0) #define BODY_20_39(xa,xb,xc,xd) do { \ Xupdate(T,xa,xa,xb,xc,xd); \ T+=E+K_20_39+F_20_39(B,C,D); \ E=D, D=C, C=ROTATE(B,30), B=A; \ A=ROTATE(A,5)+T; } while(0) #define BODY_40_59(xa,xb,xc,xd) do { \ Xupdate(T,xa,xa,xb,xc,xd); \ T+=E+K_40_59+F_40_59(B,C,D); \ E=D, D=C, C=ROTATE(B,30), B=A; \ A=ROTATE(A,5)+T; } while(0) #define BODY_60_79(xa,xb,xc,xd) do { \ Xupdate(T,xa,xa,xb,xc,xd); \ T=E+K_60_79+F_60_79(B,C,D); \ E=D, D=C, C=ROTATE(B,30), B=A; \ A=ROTATE(A,5)+T+xa; } while(0) #if !defined(SHA_1) || !defined(SHA1_ASM) static void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, size_t num) { const unsigned char *data=p; register unsigned MD32_REG_T A,B,C,D,E,T,l; int i; SHA_LONG X[16]; A=c->h0; B=c->h1; C=c->h2; D=c->h3; E=c->h4; for (;;) { for (i=0;i<16;i++) { HOST_c2l(data,l); X[i]=l; BODY_00_15(X[i]); } for (i=0;i<4;i++) { BODY_16_19(X[i], X[i+2], X[i+8], X[(i+13)&15]); } for (;i<24;i++) { BODY_20_39(X[i&15], X[(i+2)&15], X[(i+8)&15],X[(i+13)&15]); } for (i=0;i<20;i++) { BODY_40_59(X[(i+8)&15],X[(i+10)&15],X[i&15], X[(i+5)&15]); } for (i=4;i<24;i++) { BODY_60_79(X[(i+8)&15],X[(i+10)&15],X[i&15], X[(i+5)&15]); } c->h0=(c->h0+A)&0xffffffffL; c->h1=(c->h1+B)&0xffffffffL; c->h2=(c->h2+C)&0xffffffffL; c->h3=(c->h3+D)&0xffffffffL; c->h4=(c->h4+E)&0xffffffffL; if (--num == 0) break; A=c->h0; B=c->h1; C=c->h2; D=c->h3; E=c->h4; } } #endif #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/sha/sha1dgst.c0000644000175000017500000000665212360020706020722 0ustar /* $OpenBSD: sha1dgst.c,v 1.12 2014/07/09 11:10:51 bcook Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #if !defined(OPENSSL_NO_SHA1) && !defined(OPENSSL_NO_SHA) #undef SHA_0 #define SHA_1 #include /* The implementation is in ../md32_common.h */ #include "sha_locl.h" #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/sha/sha256.c0000644000175000017500000002207512360020706020211 0ustar /* $OpenBSD: sha256.c,v 1.6 2014/07/09 16:06:13 miod Exp $ */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved * according to the OpenSSL license [found in ../../LICENSE]. * ==================================================================== */ #include #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA256) #include #include #include #include #include #include int SHA224_Init(SHA256_CTX *c) { memset (c,0,sizeof(*c)); c->h[0]=0xc1059ed8UL; c->h[1]=0x367cd507UL; c->h[2]=0x3070dd17UL; c->h[3]=0xf70e5939UL; c->h[4]=0xffc00b31UL; c->h[5]=0x68581511UL; c->h[6]=0x64f98fa7UL; c->h[7]=0xbefa4fa4UL; c->md_len=SHA224_DIGEST_LENGTH; return 1; } int SHA256_Init(SHA256_CTX *c) { memset (c,0,sizeof(*c)); c->h[0]=0x6a09e667UL; c->h[1]=0xbb67ae85UL; c->h[2]=0x3c6ef372UL; c->h[3]=0xa54ff53aUL; c->h[4]=0x510e527fUL; c->h[5]=0x9b05688cUL; c->h[6]=0x1f83d9abUL; c->h[7]=0x5be0cd19UL; c->md_len=SHA256_DIGEST_LENGTH; return 1; } unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md) { SHA256_CTX c; static unsigned char m[SHA224_DIGEST_LENGTH]; if (md == NULL) md=m; SHA224_Init(&c); SHA256_Update(&c,d,n); SHA256_Final(md,&c); OPENSSL_cleanse(&c,sizeof(c)); return(md); } unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md) { SHA256_CTX c; static unsigned char m[SHA256_DIGEST_LENGTH]; if (md == NULL) md=m; SHA256_Init(&c); SHA256_Update(&c,d,n); SHA256_Final(md,&c); OPENSSL_cleanse(&c,sizeof(c)); return(md); } int SHA224_Update(SHA256_CTX *c, const void *data, size_t len) { return SHA256_Update (c,data,len); } int SHA224_Final (unsigned char *md, SHA256_CTX *c) { return SHA256_Final (md,c); } #define DATA_ORDER_IS_BIG_ENDIAN #define HASH_LONG SHA_LONG #define HASH_CTX SHA256_CTX #define HASH_CBLOCK SHA_CBLOCK /* * Note that FIPS180-2 discusses "Truncation of the Hash Function Output." * default: case below covers for it. It's not clear however if it's * permitted to truncate to amount of bytes not divisible by 4. I bet not, * but if it is, then default: case shall be extended. For reference. * Idea behind separate cases for pre-defined lenghts is to let the * compiler decide if it's appropriate to unroll small loops. */ #define HASH_MAKE_STRING(c,s) do { \ unsigned long ll; \ unsigned int nn; \ switch ((c)->md_len) \ { case SHA224_DIGEST_LENGTH: \ for (nn=0;nnh[nn]; (void)HOST_l2c(ll,(s)); } \ break; \ case SHA256_DIGEST_LENGTH: \ for (nn=0;nnh[nn]; (void)HOST_l2c(ll,(s)); } \ break; \ default: \ if ((c)->md_len > SHA256_DIGEST_LENGTH) \ return 0; \ for (nn=0;nn<(c)->md_len/4;nn++) \ { ll=(c)->h[nn]; (void)HOST_l2c(ll,(s)); } \ break; \ } \ } while (0) #define HASH_UPDATE SHA256_Update #define HASH_TRANSFORM SHA256_Transform #define HASH_FINAL SHA256_Final #define HASH_BLOCK_DATA_ORDER sha256_block_data_order #ifndef SHA256_ASM static #endif void sha256_block_data_order (SHA256_CTX *ctx, const void *in, size_t num); #include "md32_common.h" #ifndef SHA256_ASM static const SHA_LONG K256[64] = { 0x428a2f98UL,0x71374491UL,0xb5c0fbcfUL,0xe9b5dba5UL, 0x3956c25bUL,0x59f111f1UL,0x923f82a4UL,0xab1c5ed5UL, 0xd807aa98UL,0x12835b01UL,0x243185beUL,0x550c7dc3UL, 0x72be5d74UL,0x80deb1feUL,0x9bdc06a7UL,0xc19bf174UL, 0xe49b69c1UL,0xefbe4786UL,0x0fc19dc6UL,0x240ca1ccUL, 0x2de92c6fUL,0x4a7484aaUL,0x5cb0a9dcUL,0x76f988daUL, 0x983e5152UL,0xa831c66dUL,0xb00327c8UL,0xbf597fc7UL, 0xc6e00bf3UL,0xd5a79147UL,0x06ca6351UL,0x14292967UL, 0x27b70a85UL,0x2e1b2138UL,0x4d2c6dfcUL,0x53380d13UL, 0x650a7354UL,0x766a0abbUL,0x81c2c92eUL,0x92722c85UL, 0xa2bfe8a1UL,0xa81a664bUL,0xc24b8b70UL,0xc76c51a3UL, 0xd192e819UL,0xd6990624UL,0xf40e3585UL,0x106aa070UL, 0x19a4c116UL,0x1e376c08UL,0x2748774cUL,0x34b0bcb5UL, 0x391c0cb3UL,0x4ed8aa4aUL,0x5b9cca4fUL,0x682e6ff3UL, 0x748f82eeUL,0x78a5636fUL,0x84c87814UL,0x8cc70208UL, 0x90befffaUL,0xa4506cebUL,0xbef9a3f7UL,0xc67178f2UL }; /* * FIPS specification refers to right rotations, while our ROTATE macro * is left one. This is why you might notice that rotation coefficients * differ from those observed in FIPS document by 32-N... */ #define Sigma0(x) (ROTATE((x),30) ^ ROTATE((x),19) ^ ROTATE((x),10)) #define Sigma1(x) (ROTATE((x),26) ^ ROTATE((x),21) ^ ROTATE((x),7)) #define sigma0(x) (ROTATE((x),25) ^ ROTATE((x),14) ^ ((x)>>3)) #define sigma1(x) (ROTATE((x),15) ^ ROTATE((x),13) ^ ((x)>>10)) #define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) #define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) #ifdef OPENSSL_SMALL_FOOTPRINT static void sha256_block_data_order (SHA256_CTX *ctx, const void *in, size_t num) { unsigned MD32_REG_T a,b,c,d,e,f,g,h,s0,s1,T1,T2; SHA_LONG X[16],l; int i; const unsigned char *data=in; while (num--) { a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3]; e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7]; for (i=0;i<16;i++) { HOST_c2l(data,l); T1 = X[i] = l; T1 += h + Sigma1(e) + Ch(e,f,g) + K256[i]; T2 = Sigma0(a) + Maj(a,b,c); h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2; } for (;i<64;i++) { s0 = X[(i+1)&0x0f]; s0 = sigma0(s0); s1 = X[(i+14)&0x0f]; s1 = sigma1(s1); T1 = X[i&0xf] += s0 + s1 + X[(i+9)&0xf]; T1 += h + Sigma1(e) + Ch(e,f,g) + K256[i]; T2 = Sigma0(a) + Maj(a,b,c); h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2; } ctx->h[0] += a; ctx->h[1] += b; ctx->h[2] += c; ctx->h[3] += d; ctx->h[4] += e; ctx->h[5] += f; ctx->h[6] += g; ctx->h[7] += h; } } #else #define ROUND_00_15(i,a,b,c,d,e,f,g,h) do { \ T1 += h + Sigma1(e) + Ch(e,f,g) + K256[i]; \ h = Sigma0(a) + Maj(a,b,c); \ d += T1; h += T1; } while (0) #define ROUND_16_63(i,a,b,c,d,e,f,g,h,X) do { \ s0 = X[(i+1)&0x0f]; s0 = sigma0(s0); \ s1 = X[(i+14)&0x0f]; s1 = sigma1(s1); \ T1 = X[(i)&0x0f] += s0 + s1 + X[(i+9)&0x0f]; \ ROUND_00_15(i,a,b,c,d,e,f,g,h); } while (0) static void sha256_block_data_order (SHA256_CTX *ctx, const void *in, size_t num) { unsigned MD32_REG_T a,b,c,d,e,f,g,h,s0,s1,T1; SHA_LONG X[16]; int i; const unsigned char *data=in; while (num--) { a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3]; e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7]; if (BYTE_ORDER != LITTLE_ENDIAN && sizeof(SHA_LONG)==4 && ((size_t)in%4)==0) { const SHA_LONG *W=(const SHA_LONG *)data; T1 = X[0] = W[0]; ROUND_00_15(0,a,b,c,d,e,f,g,h); T1 = X[1] = W[1]; ROUND_00_15(1,h,a,b,c,d,e,f,g); T1 = X[2] = W[2]; ROUND_00_15(2,g,h,a,b,c,d,e,f); T1 = X[3] = W[3]; ROUND_00_15(3,f,g,h,a,b,c,d,e); T1 = X[4] = W[4]; ROUND_00_15(4,e,f,g,h,a,b,c,d); T1 = X[5] = W[5]; ROUND_00_15(5,d,e,f,g,h,a,b,c); T1 = X[6] = W[6]; ROUND_00_15(6,c,d,e,f,g,h,a,b); T1 = X[7] = W[7]; ROUND_00_15(7,b,c,d,e,f,g,h,a); T1 = X[8] = W[8]; ROUND_00_15(8,a,b,c,d,e,f,g,h); T1 = X[9] = W[9]; ROUND_00_15(9,h,a,b,c,d,e,f,g); T1 = X[10] = W[10]; ROUND_00_15(10,g,h,a,b,c,d,e,f); T1 = X[11] = W[11]; ROUND_00_15(11,f,g,h,a,b,c,d,e); T1 = X[12] = W[12]; ROUND_00_15(12,e,f,g,h,a,b,c,d); T1 = X[13] = W[13]; ROUND_00_15(13,d,e,f,g,h,a,b,c); T1 = X[14] = W[14]; ROUND_00_15(14,c,d,e,f,g,h,a,b); T1 = X[15] = W[15]; ROUND_00_15(15,b,c,d,e,f,g,h,a); data += SHA256_CBLOCK; } else { SHA_LONG l; HOST_c2l(data,l); T1 = X[0] = l; ROUND_00_15(0,a,b,c,d,e,f,g,h); HOST_c2l(data,l); T1 = X[1] = l; ROUND_00_15(1,h,a,b,c,d,e,f,g); HOST_c2l(data,l); T1 = X[2] = l; ROUND_00_15(2,g,h,a,b,c,d,e,f); HOST_c2l(data,l); T1 = X[3] = l; ROUND_00_15(3,f,g,h,a,b,c,d,e); HOST_c2l(data,l); T1 = X[4] = l; ROUND_00_15(4,e,f,g,h,a,b,c,d); HOST_c2l(data,l); T1 = X[5] = l; ROUND_00_15(5,d,e,f,g,h,a,b,c); HOST_c2l(data,l); T1 = X[6] = l; ROUND_00_15(6,c,d,e,f,g,h,a,b); HOST_c2l(data,l); T1 = X[7] = l; ROUND_00_15(7,b,c,d,e,f,g,h,a); HOST_c2l(data,l); T1 = X[8] = l; ROUND_00_15(8,a,b,c,d,e,f,g,h); HOST_c2l(data,l); T1 = X[9] = l; ROUND_00_15(9,h,a,b,c,d,e,f,g); HOST_c2l(data,l); T1 = X[10] = l; ROUND_00_15(10,g,h,a,b,c,d,e,f); HOST_c2l(data,l); T1 = X[11] = l; ROUND_00_15(11,f,g,h,a,b,c,d,e); HOST_c2l(data,l); T1 = X[12] = l; ROUND_00_15(12,e,f,g,h,a,b,c,d); HOST_c2l(data,l); T1 = X[13] = l; ROUND_00_15(13,d,e,f,g,h,a,b,c); HOST_c2l(data,l); T1 = X[14] = l; ROUND_00_15(14,c,d,e,f,g,h,a,b); HOST_c2l(data,l); T1 = X[15] = l; ROUND_00_15(15,b,c,d,e,f,g,h,a); } for (i=16;i<64;i+=8) { ROUND_16_63(i+0,a,b,c,d,e,f,g,h,X); ROUND_16_63(i+1,h,a,b,c,d,e,f,g,X); ROUND_16_63(i+2,g,h,a,b,c,d,e,f,X); ROUND_16_63(i+3,f,g,h,a,b,c,d,e,X); ROUND_16_63(i+4,e,f,g,h,a,b,c,d,X); ROUND_16_63(i+5,d,e,f,g,h,a,b,c,X); ROUND_16_63(i+6,c,d,e,f,g,h,a,b,X); ROUND_16_63(i+7,b,c,d,e,f,g,h,a,X); } ctx->h[0] += a; ctx->h[1] += b; ctx->h[2] += c; ctx->h[3] += d; ctx->h[4] += e; ctx->h[5] += f; ctx->h[6] += g; ctx->h[7] += h; } } #endif #endif /* SHA256_ASM */ #endif /* OPENSSL_NO_SHA256 */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/0000755000000000000000000000000012666635521020625 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/cbc_enc.c0000644000175000017500000000630112360020705020546 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #define CBC_ENC_C__DONT_UPDATE_IV #include "ncbc_enc.c" /* des_cbc_encrypt */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/ncbc_enc.c0000644000175000017500000001205412360020705020726 0ustar /* $OpenBSD$ */ /* * #included by: * cbc_enc.c (DES_cbc_encrypt) * des_enc.c (DES_ncbc_encrypt) */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include "des_locl.h" #ifdef CBC_ENC_C__DONT_UPDATE_IV void DES_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, DES_key_schedule *_schedule, DES_cblock *ivec, int enc) #else void DES_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, DES_key_schedule *_schedule, DES_cblock *ivec, int enc) #endif { register DES_LONG tin0,tin1; register DES_LONG tout0,tout1,xor0,xor1; register long l=length; DES_LONG tin[2]; unsigned char *iv; iv = &(*ivec)[0]; if (enc) { c2l(iv,tout0); c2l(iv,tout1); for (l-=8; l>=0; l-=8) { c2l(in,tin0); c2l(in,tin1); tin0^=tout0; tin[0]=tin0; tin1^=tout1; tin[1]=tin1; DES_encrypt1((DES_LONG *)tin,_schedule,DES_ENCRYPT); tout0=tin[0]; l2c(tout0,out); tout1=tin[1]; l2c(tout1,out); } if (l != -8) { c2ln(in,tin0,tin1,l+8); tin0^=tout0; tin[0]=tin0; tin1^=tout1; tin[1]=tin1; DES_encrypt1((DES_LONG *)tin,_schedule,DES_ENCRYPT); tout0=tin[0]; l2c(tout0,out); tout1=tin[1]; l2c(tout1,out); } #ifndef CBC_ENC_C__DONT_UPDATE_IV iv = &(*ivec)[0]; l2c(tout0,iv); l2c(tout1,iv); #endif } else { c2l(iv,xor0); c2l(iv,xor1); for (l-=8; l>=0; l-=8) { c2l(in,tin0); tin[0]=tin0; c2l(in,tin1); tin[1]=tin1; DES_encrypt1((DES_LONG *)tin,_schedule,DES_DECRYPT); tout0=tin[0]^xor0; tout1=tin[1]^xor1; l2c(tout0,out); l2c(tout1,out); xor0=tin0; xor1=tin1; } if (l != -8) { c2l(in,tin0); tin[0]=tin0; c2l(in,tin1); tin[1]=tin1; DES_encrypt1((DES_LONG *)tin,_schedule,DES_DECRYPT); tout0=tin[0]^xor0; tout1=tin[1]^xor1; l2cn(tout0,tout1,out,l+8); #ifndef CBC_ENC_C__DONT_UPDATE_IV xor0=tin0; xor1=tin1; #endif } #ifndef CBC_ENC_C__DONT_UPDATE_IV iv = &(*ivec)[0]; l2c(xor0,iv); l2c(xor1,iv); #endif } tin0=tin1=tout0=tout1=xor0=xor1=0; tin[0]=tin[1]=0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/des_enc.c0000644000175000017500000002451412360020705020600 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include "des_locl.h" #include "spr.h" #ifndef OPENBSD_DES_ASM void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) { register DES_LONG l,r,t,u; #ifdef DES_PTR register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans; #endif #ifndef DES_UNROLL register int i; #endif register DES_LONG *s; r=data[0]; l=data[1]; IP(r,l); /* Things have been modified so that the initial rotate is * done outside the loop. This required the * DES_SPtrans values in sp.h to be rotated 1 bit to the right. * One perl script later and things have a 5% speed up on a sparc2. * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> * for pointing this out. */ /* clear the top bits on machines with 8byte longs */ /* shift left by 2 */ r=ROTATE(r,29)&0xffffffffL; l=ROTATE(l,29)&0xffffffffL; s=ks->ks->deslong; /* I don't know if it is worth the effort of loop unrolling the * inner loop */ if (enc) { #ifdef DES_UNROLL D_ENCRYPT(l,r, 0); /* 1 */ D_ENCRYPT(r,l, 2); /* 2 */ D_ENCRYPT(l,r, 4); /* 3 */ D_ENCRYPT(r,l, 6); /* 4 */ D_ENCRYPT(l,r, 8); /* 5 */ D_ENCRYPT(r,l,10); /* 6 */ D_ENCRYPT(l,r,12); /* 7 */ D_ENCRYPT(r,l,14); /* 8 */ D_ENCRYPT(l,r,16); /* 9 */ D_ENCRYPT(r,l,18); /* 10 */ D_ENCRYPT(l,r,20); /* 11 */ D_ENCRYPT(r,l,22); /* 12 */ D_ENCRYPT(l,r,24); /* 13 */ D_ENCRYPT(r,l,26); /* 14 */ D_ENCRYPT(l,r,28); /* 15 */ D_ENCRYPT(r,l,30); /* 16 */ #else for (i=0; i<32; i+=4) { D_ENCRYPT(l,r,i+0); /* 1 */ D_ENCRYPT(r,l,i+2); /* 2 */ } #endif } else { #ifdef DES_UNROLL D_ENCRYPT(l,r,30); /* 16 */ D_ENCRYPT(r,l,28); /* 15 */ D_ENCRYPT(l,r,26); /* 14 */ D_ENCRYPT(r,l,24); /* 13 */ D_ENCRYPT(l,r,22); /* 12 */ D_ENCRYPT(r,l,20); /* 11 */ D_ENCRYPT(l,r,18); /* 10 */ D_ENCRYPT(r,l,16); /* 9 */ D_ENCRYPT(l,r,14); /* 8 */ D_ENCRYPT(r,l,12); /* 7 */ D_ENCRYPT(l,r,10); /* 6 */ D_ENCRYPT(r,l, 8); /* 5 */ D_ENCRYPT(l,r, 6); /* 4 */ D_ENCRYPT(r,l, 4); /* 3 */ D_ENCRYPT(l,r, 2); /* 2 */ D_ENCRYPT(r,l, 0); /* 1 */ #else for (i=30; i>0; i-=4) { D_ENCRYPT(l,r,i-0); /* 16 */ D_ENCRYPT(r,l,i-2); /* 15 */ } #endif } /* rotate and clear the top bits on machines with 8byte longs */ l=ROTATE(l,3)&0xffffffffL; r=ROTATE(r,3)&0xffffffffL; FP(r,l); data[0]=l; data[1]=r; l=r=t=u=0; } void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) { register DES_LONG l,r,t,u; #ifdef DES_PTR register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans; #endif #ifndef DES_UNROLL register int i; #endif register DES_LONG *s; r=data[0]; l=data[1]; /* Things have been modified so that the initial rotate is * done outside the loop. This required the * DES_SPtrans values in sp.h to be rotated 1 bit to the right. * One perl script later and things have a 5% speed up on a sparc2. * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> * for pointing this out. */ /* clear the top bits on machines with 8byte longs */ r=ROTATE(r,29)&0xffffffffL; l=ROTATE(l,29)&0xffffffffL; s=ks->ks->deslong; /* I don't know if it is worth the effort of loop unrolling the * inner loop */ if (enc) { #ifdef DES_UNROLL D_ENCRYPT(l,r, 0); /* 1 */ D_ENCRYPT(r,l, 2); /* 2 */ D_ENCRYPT(l,r, 4); /* 3 */ D_ENCRYPT(r,l, 6); /* 4 */ D_ENCRYPT(l,r, 8); /* 5 */ D_ENCRYPT(r,l,10); /* 6 */ D_ENCRYPT(l,r,12); /* 7 */ D_ENCRYPT(r,l,14); /* 8 */ D_ENCRYPT(l,r,16); /* 9 */ D_ENCRYPT(r,l,18); /* 10 */ D_ENCRYPT(l,r,20); /* 11 */ D_ENCRYPT(r,l,22); /* 12 */ D_ENCRYPT(l,r,24); /* 13 */ D_ENCRYPT(r,l,26); /* 14 */ D_ENCRYPT(l,r,28); /* 15 */ D_ENCRYPT(r,l,30); /* 16 */ #else for (i=0; i<32; i+=4) { D_ENCRYPT(l,r,i+0); /* 1 */ D_ENCRYPT(r,l,i+2); /* 2 */ } #endif } else { #ifdef DES_UNROLL D_ENCRYPT(l,r,30); /* 16 */ D_ENCRYPT(r,l,28); /* 15 */ D_ENCRYPT(l,r,26); /* 14 */ D_ENCRYPT(r,l,24); /* 13 */ D_ENCRYPT(l,r,22); /* 12 */ D_ENCRYPT(r,l,20); /* 11 */ D_ENCRYPT(l,r,18); /* 10 */ D_ENCRYPT(r,l,16); /* 9 */ D_ENCRYPT(l,r,14); /* 8 */ D_ENCRYPT(r,l,12); /* 7 */ D_ENCRYPT(l,r,10); /* 6 */ D_ENCRYPT(r,l, 8); /* 5 */ D_ENCRYPT(l,r, 6); /* 4 */ D_ENCRYPT(r,l, 4); /* 3 */ D_ENCRYPT(l,r, 2); /* 2 */ D_ENCRYPT(r,l, 0); /* 1 */ #else for (i=30; i>0; i-=4) { D_ENCRYPT(l,r,i-0); /* 16 */ D_ENCRYPT(r,l,i-2); /* 15 */ } #endif } /* rotate and clear the top bits on machines with 8byte longs */ data[0]=ROTATE(l,3)&0xffffffffL; data[1]=ROTATE(r,3)&0xffffffffL; l=r=t=u=0; } #endif /* OPENBSD_DES_ASM */ void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, DES_key_schedule *ks2, DES_key_schedule *ks3) { register DES_LONG l,r; l=data[0]; r=data[1]; IP(l,r); data[0]=l; data[1]=r; DES_encrypt2((DES_LONG *)data,ks1,DES_ENCRYPT); DES_encrypt2((DES_LONG *)data,ks2,DES_DECRYPT); DES_encrypt2((DES_LONG *)data,ks3,DES_ENCRYPT); l=data[0]; r=data[1]; FP(r,l); data[0]=l; data[1]=r; } void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, DES_key_schedule *ks2, DES_key_schedule *ks3) { register DES_LONG l,r; l=data[0]; r=data[1]; IP(l,r); data[0]=l; data[1]=r; DES_encrypt2((DES_LONG *)data,ks3,DES_DECRYPT); DES_encrypt2((DES_LONG *)data,ks2,DES_ENCRYPT); DES_encrypt2((DES_LONG *)data,ks1,DES_DECRYPT); l=data[0]; r=data[1]; FP(r,l); data[0]=l; data[1]=r; } #ifndef DES_DEFAULT_OPTIONS #undef CBC_ENC_C__DONT_UPDATE_IV #include "ncbc_enc.c" /* DES_ncbc_encrypt */ void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, long length, DES_key_schedule *ks1, DES_key_schedule *ks2, DES_key_schedule *ks3, DES_cblock *ivec, int enc) { register DES_LONG tin0,tin1; register DES_LONG tout0,tout1,xor0,xor1; register const unsigned char *in; unsigned char *out; register long l=length; DES_LONG tin[2]; unsigned char *iv; in=input; out=output; iv = &(*ivec)[0]; if (enc) { c2l(iv,tout0); c2l(iv,tout1); for (l-=8; l>=0; l-=8) { c2l(in,tin0); c2l(in,tin1); tin0^=tout0; tin1^=tout1; tin[0]=tin0; tin[1]=tin1; DES_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); tout0=tin[0]; tout1=tin[1]; l2c(tout0,out); l2c(tout1,out); } if (l != -8) { c2ln(in,tin0,tin1,l+8); tin0^=tout0; tin1^=tout1; tin[0]=tin0; tin[1]=tin1; DES_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); tout0=tin[0]; tout1=tin[1]; l2c(tout0,out); l2c(tout1,out); } iv = &(*ivec)[0]; l2c(tout0,iv); l2c(tout1,iv); } else { register DES_LONG t0,t1; c2l(iv,xor0); c2l(iv,xor1); for (l-=8; l>=0; l-=8) { c2l(in,tin0); c2l(in,tin1); t0=tin0; t1=tin1; tin[0]=tin0; tin[1]=tin1; DES_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); tout0=tin[0]; tout1=tin[1]; tout0^=xor0; tout1^=xor1; l2c(tout0,out); l2c(tout1,out); xor0=t0; xor1=t1; } if (l != -8) { c2l(in,tin0); c2l(in,tin1); t0=tin0; t1=tin1; tin[0]=tin0; tin[1]=tin1; DES_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); tout0=tin[0]; tout1=tin[1]; tout0^=xor0; tout1^=xor1; l2cn(tout0,tout1,out,l+8); xor0=t0; xor1=t1; } iv = &(*ivec)[0]; l2c(xor0,iv); l2c(xor1,iv); } tin0=tin1=tout0=tout1=xor0=xor1=0; tin[0]=tin[1]=0; } #endif /* DES_DEFAULT_OPTIONS */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/ecb3_enc.c0000644000175000017500000000714212360020705020637 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include "des_locl.h" void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, DES_key_schedule *ks1, DES_key_schedule *ks2, DES_key_schedule *ks3, int enc) { register DES_LONG l0,l1; DES_LONG ll[2]; const unsigned char *in = &(*input)[0]; unsigned char *out = &(*output)[0]; c2l(in,l0); c2l(in,l1); ll[0]=l0; ll[1]=l1; if (enc) DES_encrypt3(ll,ks1,ks2,ks3); else DES_decrypt3(ll,ks1,ks2,ks3); l0=ll[0]; l1=ll[1]; l2c(l0,out); l2c(l1,out); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/cfb_enc.c0000644000175000017500000001421112360020705020550 0ustar /* $OpenBSD: cfb_enc.c,v 1.10 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include "des_locl.h" #include #include /* The input and output are loaded in multiples of 8 bits. * What this means is that if you hame numbits=12 and length=2 * the first 12 bits will be retrieved from the first byte and half * the second. The second 12 bits will come from the 3rd and half the 4th * byte. */ /* Until Aug 1 2003 this function did not correctly implement CFB-r, so it * will not be compatible with any encryption prior to that date. Ben. */ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, long length, DES_key_schedule *schedule, DES_cblock *ivec, int enc) { register DES_LONG d0,d1,v0,v1; register unsigned long l=length; register int num=numbits/8,n=(numbits+7)/8,i,rem=numbits%8; DES_LONG ti[2]; unsigned char *iv; #if BYTE_ORDER != LITTLE_ENDIAN unsigned char ovec[16]; #else unsigned int sh[4]; unsigned char *ovec=(unsigned char *)sh; /* I kind of count that compiler optimizes away this assertioni,*/ assert (sizeof(sh[0])==4); /* as this holds true for all, */ /* but 16-bit platforms... */ #endif if (numbits<=0 || numbits > 64) return; iv = &(*ivec)[0]; c2l(iv,v0); c2l(iv,v1); if (enc) { while (l >= (unsigned long)n) { l-=n; ti[0]=v0; ti[1]=v1; DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); c2ln(in,d0,d1,n); in+=n; d0^=ti[0]; d1^=ti[1]; l2cn(d0,d1,out,n); out+=n; /* 30-08-94 - eay - changed because l>>32 and * l<<32 are bad under gcc :-( */ if (numbits == 32) { v0=v1; v1=d0; } else if (numbits == 64) { v0=d0; v1=d1; } else { #if BYTE_ORDER != LITTLE_ENDIAN iv=&ovec[0]; l2c(v0,iv); l2c(v1,iv); l2c(d0,iv); l2c(d1,iv); #else sh[0]=v0, sh[1]=v1, sh[2]=d0, sh[3]=d1; #endif if (rem==0) memmove(ovec,ovec+num,8); else for(i=0 ; i < 8 ; ++i) ovec[i]=ovec[i+num]<>(8-rem); #if BYTE_ORDER == LITTLE_ENDIAN v0=sh[0], v1=sh[1]; #else iv=&ovec[0]; c2l(iv,v0); c2l(iv,v1); #endif } } } else { while (l >= (unsigned long)n) { l-=n; ti[0]=v0; ti[1]=v1; DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); c2ln(in,d0,d1,n); in+=n; /* 30-08-94 - eay - changed because l>>32 and * l<<32 are bad under gcc :-( */ if (numbits == 32) { v0=v1; v1=d0; } else if (numbits == 64) { v0=d0; v1=d1; } else { #if BYTE_ORDER != LITTLE_ENDIAN iv=&ovec[0]; l2c(v0,iv); l2c(v1,iv); l2c(d0,iv); l2c(d1,iv); #else sh[0]=v0, sh[1]=v1, sh[2]=d0, sh[3]=d1; #endif if (rem==0) memmove(ovec,ovec+num,8); else for(i=0 ; i < 8 ; ++i) ovec[i]=ovec[i+num]<>(8-rem); #if BYTE_ORDER == LITTLE_ENDIAN v0=sh[0], v1=sh[1]; #else iv=&ovec[0]; c2l(iv,v0); c2l(iv,v1); #endif } d0^=ti[0]; d1^=ti[1]; l2cn(d0,d1,out,n); out+=n; } } iv = &(*ivec)[0]; l2c(v0,iv); l2c(v1,iv); v0=v1=d0=d1=ti[0]=ti[1]=0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/enc_writ.c0000644000175000017500000001314012360020705021003 0ustar /* $OpenBSD: enc_writ.c,v 1.11 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include "des_locl.h" /* * WARNINGS: * * - The data format used by DES_enc_write() and DES_enc_read() * has a cryptographic weakness: When asked to write more * than MAXWRITE bytes, DES_enc_write will split the data * into several chunks that are all encrypted * using the same IV. So don't use these functions unless you * are sure you know what you do (in which case you might * not want to use them anyway). * * - This code cannot handle non-blocking sockets. */ int DES_enc_write(int fd, const void *_buf, int len, DES_key_schedule *sched, DES_cblock *iv) { #if defined(OPENSSL_NO_POSIX_IO) return (-1); #else #ifdef _LIBC extern unsigned long time(); extern int write(); #endif const unsigned char *buf=_buf; long rnum; int i,j,k,outnum; static unsigned char *outbuf=NULL; unsigned char shortbuf[8]; unsigned char *p; const unsigned char *cp; static int start=1; if (outbuf == NULL) { outbuf=malloc(BSIZE+HDRSIZE); if (outbuf == NULL) return(-1); } /* If we are sending less than 8 bytes, the same char will look * the same if we don't pad it out with random bytes */ if (start) { start=0; } /* lets recurse if we want to send the data in small chunks */ if (len > MAXWRITE) { j=0; for (i=0; i MAXWRITE)?MAXWRITE:(len-i),sched,iv); if (k < 0) return(k); else j+=k; } return(j); } /* write length first */ p=outbuf; l2n(len,p); /* pad short strings */ if (len < 8) { cp=shortbuf; memcpy(shortbuf,buf,len); RAND_pseudo_bytes(shortbuf+len, 8-len); rnum=8; } else { cp=buf; rnum=((len+7)/8*8); /* round up to nearest eight */ } if (DES_rw_mode & DES_PCBC_MODE) DES_pcbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv, DES_ENCRYPT); else DES_cbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv, DES_ENCRYPT); /* output */ outnum=rnum+HDRSIZE; for (j=0; j 0) { if (l > 1) { t0= (DES_LONG)(*(cp++)); t0|=(DES_LONG)Q_B1(*(cp++)); l--; } else t0= (DES_LONG)(*(cp++)); l--; /* add */ t0+=z0; t0&=0xffffffffL; t1=z1; /* square, well sort of square */ z0=((((t0*t0)&0xffffffffL)+((t1*t1)&0xffffffffL)) &0xffffffffL)%0x7fffffffL; z1=((t0*((t1+NOISE)&0xffffffffL))&0xffffffffL)%0x7fffffffL; } if (lp != NULL) { /* The MIT library assumes that the checksum is * composed of 2*out_count 32 bit ints */ *lp++ = z0; *lp++ = z1; } } return(z0); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/fcrypt_b.c0000644000175000017500000001160012360020705021000 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include /* This version of crypt has been developed from my MIT compatible * DES library. * The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au * Eric Young (eay@cryptsoft.com) */ #define DES_FCRYPT #include "des_locl.h" #undef DES_FCRYPT #ifndef OPENBSD_DES_ASM #undef PERM_OP #define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\ (b)^=(t),\ (a)^=((t)<<(n))) #undef HPERM_OP #define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ (a)=(a)^(t)^(t>>(16-(n))))\ void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0, DES_LONG Eswap1) { register DES_LONG l,r,t,u; #ifdef DES_PTR register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans; #endif register DES_LONG *s; register int j; register DES_LONG E0,E1; l=0; r=0; s=(DES_LONG *)ks; E0=Eswap0; E1=Eswap1; for (j=0; j<25; j++) { #ifndef DES_UNROLL register int i; for (i=0; i<32; i+=4) { D_ENCRYPT(l,r,i+0); /* 1 */ D_ENCRYPT(r,l,i+2); /* 2 */ } #else D_ENCRYPT(l,r, 0); /* 1 */ D_ENCRYPT(r,l, 2); /* 2 */ D_ENCRYPT(l,r, 4); /* 3 */ D_ENCRYPT(r,l, 6); /* 4 */ D_ENCRYPT(l,r, 8); /* 5 */ D_ENCRYPT(r,l,10); /* 6 */ D_ENCRYPT(l,r,12); /* 7 */ D_ENCRYPT(r,l,14); /* 8 */ D_ENCRYPT(l,r,16); /* 9 */ D_ENCRYPT(r,l,18); /* 10 */ D_ENCRYPT(l,r,20); /* 11 */ D_ENCRYPT(r,l,22); /* 12 */ D_ENCRYPT(l,r,24); /* 13 */ D_ENCRYPT(r,l,26); /* 14 */ D_ENCRYPT(l,r,28); /* 15 */ D_ENCRYPT(r,l,30); /* 16 */ #endif t=l; l=r; r=t; } l=ROTATE(l,3)&0xffffffffL; r=ROTATE(r,3)&0xffffffffL; PERM_OP(l,r,t, 1,0x55555555L); PERM_OP(r,l,t, 8,0x00ff00ffL); PERM_OP(l,r,t, 2,0x33333333L); PERM_OP(r,l,t,16,0x0000ffffL); PERM_OP(l,r,t, 4,0x0f0f0f0fL); out[0]=r; out[1]=l; } #endif /* OPENBSD_DES_ASM */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/ede_cbcm_enc.c0000644000175000017500000001216412360020705021544 0ustar /* $OpenBSD$ */ /* Written by Ben Laurie for the OpenSSL * project 13 Feb 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* This is an implementation of Triple DES Cipher Block Chaining with Output Feedback Masking, by Coppersmith, Johnson and Matyas, (IBM and Certicom). Note that there is a known attack on this by Biham and Knudsen but it takes a lot of work: http://www.cs.technion.ac.il/users/wwwb/cgi-bin/tr-get.cgi/1998/CS/CS0928.ps.gz */ #include /* To see if OPENSSL_NO_DESCBCM is defined */ #ifndef OPENSSL_NO_DESCBCM #include "des_locl.h" void DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, long length, DES_key_schedule *ks1, DES_key_schedule *ks2, DES_key_schedule *ks3, DES_cblock *ivec1, DES_cblock *ivec2, int enc) { register DES_LONG tin0,tin1; register DES_LONG tout0,tout1,xor0,xor1,m0,m1; register long l=length; DES_LONG tin[2]; unsigned char *iv1,*iv2; iv1 = &(*ivec1)[0]; iv2 = &(*ivec2)[0]; if (enc) { c2l(iv1,m0); c2l(iv1,m1); c2l(iv2,tout0); c2l(iv2,tout1); for (l-=8; l>=-7; l-=8) { tin[0]=m0; tin[1]=m1; DES_encrypt1(tin,ks3,1); m0=tin[0]; m1=tin[1]; if(l < 0) { c2ln(in,tin0,tin1,l+8); } else { c2l(in,tin0); c2l(in,tin1); } tin0^=tout0; tin1^=tout1; tin[0]=tin0; tin[1]=tin1; DES_encrypt1(tin,ks1,1); tin[0]^=m0; tin[1]^=m1; DES_encrypt1(tin,ks2,0); tin[0]^=m0; tin[1]^=m1; DES_encrypt1(tin,ks1,1); tout0=tin[0]; tout1=tin[1]; l2c(tout0,out); l2c(tout1,out); } iv1=&(*ivec1)[0]; l2c(m0,iv1); l2c(m1,iv1); iv2=&(*ivec2)[0]; l2c(tout0,iv2); l2c(tout1,iv2); } else { register DES_LONG t0,t1; c2l(iv1,m0); c2l(iv1,m1); c2l(iv2,xor0); c2l(iv2,xor1); for (l-=8; l>=-7; l-=8) { tin[0]=m0; tin[1]=m1; DES_encrypt1(tin,ks3,1); m0=tin[0]; m1=tin[1]; c2l(in,tin0); c2l(in,tin1); t0=tin0; t1=tin1; tin[0]=tin0; tin[1]=tin1; DES_encrypt1(tin,ks1,0); tin[0]^=m0; tin[1]^=m1; DES_encrypt1(tin,ks2,1); tin[0]^=m0; tin[1]^=m1; DES_encrypt1(tin,ks1,0); tout0=tin[0]; tout1=tin[1]; tout0^=xor0; tout1^=xor1; if(l < 0) { l2cn(tout0,tout1,out,l+8); } else { l2c(tout0,out); l2c(tout1,out); } xor0=t0; xor1=t1; } iv1=&(*ivec1)[0]; l2c(m0,iv1); l2c(m1,iv1); iv2=&(*ivec2)[0]; l2c(xor0,iv2); l2c(xor1,iv2); } tin0=tin1=tout0=tout1=xor0=xor1=0; tin[0]=tin[1]=0; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/ofb64enc.c0000644000175000017500000001010512360020705020575 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include "des_locl.h" /* The input and output encrypted as though 64bit ofb mode is being * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ void DES_ofb64_encrypt(register const unsigned char *in, register unsigned char *out, long length, DES_key_schedule *schedule, DES_cblock *ivec, int *num) { register DES_LONG v0,v1,t; register int n= *num; register long l=length; DES_cblock d; register unsigned char *dp; DES_LONG ti[2]; unsigned char *iv; int save=0; iv = &(*ivec)[0]; c2l(iv,v0); c2l(iv,v1); ti[0]=v0; ti[1]=v1; dp=d; l2c(v0,dp); l2c(v1,dp); while (l--) { if (n == 0) { DES_encrypt1(ti,schedule,DES_ENCRYPT); dp=d; t=ti[0]; l2c(t,dp); t=ti[1]; l2c(t,dp); save++; } *(out++)= *(in++)^d[n]; n=(n+1)&0x07; } if (save) { v0=ti[0]; v1=ti[1]; iv = &(*ivec)[0]; l2c(v0,iv); l2c(v1,iv); } t=v0=v1=ti[0]=ti[1]=0; *num=n; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/ecb_enc.c0000644000175000017500000001024512360020705020552 0ustar /* $OpenBSD: ecb_enc.c,v 1.14 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include "des_locl.h" #include #include const char *DES_options(void) { static int init=1; static char buf[32]; if (init) { const char *ptr,*unroll,*risc,*size; #ifdef DES_PTR ptr="ptr"; #else ptr="idx"; #endif #if defined(DES_RISC1) || defined(DES_RISC2) #ifdef DES_RISC1 risc="risc1"; #endif #ifdef DES_RISC2 risc="risc2"; #endif #else risc="cisc"; #endif #ifdef DES_UNROLL unroll="16"; #else unroll="2"; #endif if (sizeof(DES_LONG) != sizeof(long)) size="int"; else size="long"; snprintf(buf,sizeof buf,"des(%s,%s,%s,%s)",ptr,risc,unroll, size); init=0; } return(buf); } void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, DES_key_schedule *ks, int enc) { register DES_LONG l; DES_LONG ll[2]; const unsigned char *in = &(*input)[0]; unsigned char *out = &(*output)[0]; c2l(in,l); ll[0]=l; c2l(in,l); ll[1]=l; DES_encrypt1(ll,ks,enc); l=ll[0]; l2c(l,out); l=ll[1]; l2c(l,out); l=ll[0]=ll[1]=0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/des_locl.h0000644000175000017500000003132712360020705020771 0ustar /* $OpenBSD: des_locl.h,v 1.15 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #ifndef HEADER_DES_LOCL_H #define HEADER_DES_LOCL_H #include #include #include #include #include #include #include #define ITERATIONS 16 #define HALF_ITERATIONS 8 /* used in des_read and des_write */ #define MAXWRITE (1024*16) #define BSIZE (MAXWRITE+4) #define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \ l|=((DES_LONG)(*((c)++)))<< 8L, \ l|=((DES_LONG)(*((c)++)))<<16L, \ l|=((DES_LONG)(*((c)++)))<<24L) /* NOTE - c is not incremented as per c2l */ #define c2ln(c,l1,l2,n) { \ c+=n; \ l1=l2=0; \ switch (n) { \ case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \ case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \ case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \ case 5: l2|=((DES_LONG)(*(--(c)))); \ case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \ case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \ case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \ case 1: l1|=((DES_LONG)(*(--(c)))); \ } \ } #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>>24L)&0xff)) /* replacements for htonl and ntohl since I have no idea what to do * when faced with machines with 8 byte longs. */ #define HDRSIZE 4 #define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \ l|=((DES_LONG)(*((c)++)))<<16L, \ l|=((DES_LONG)(*((c)++)))<< 8L, \ l|=((DES_LONG)(*((c)++)))) #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l) )&0xff)) /* NOTE - c is not incremented as per l2c */ #define l2cn(l1,l2,c,n) { \ c+=n; \ switch (n) { \ case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ } \ } #if defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) # if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) # define ROTATE(a,n) ({ register unsigned int ret; \ asm ("rorl %1,%0" \ : "=r"(ret) \ : "I"(n),"0"(a) \ : "cc"); \ ret; \ }) # endif #endif #ifndef ROTATE #define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n)))) #endif /* Don't worry about the LOAD_DATA() stuff, that is used by * fcrypt() to add it's little bit to the front */ #ifdef DES_FCRYPT #define LOAD_DATA_tmp(R,S,u,t,E0,E1) \ { DES_LONG tmp; LOAD_DATA(R,S,u,t,E0,E1,tmp); } #define LOAD_DATA(R,S,u,t,E0,E1,tmp) \ t=R^(R>>16L); \ u=t&E0; t&=E1; \ tmp=(u<<16); u^=R^s[S ]; u^=tmp; \ tmp=(t<<16); t^=R^s[S+1]; t^=tmp #else #define LOAD_DATA_tmp(a,b,c,d,e,f) LOAD_DATA(a,b,c,d,e,f,g) #define LOAD_DATA(R,S,u,t,E0,E1,tmp) \ u=R^s[S ]; \ t=R^s[S+1] #endif /* The changes to this macro may help or hinder, depending on the * compiler and the architecture. gcc2 always seems to do well :-). * Inspired by Dana How * DO NOT use the alternative version on machines with 8 byte longs. * It does not seem to work on the Alpha, even when DES_LONG is 4 * bytes, probably an issue of accessing non-word aligned objects :-( */ #ifdef DES_PTR /* It recently occurred to me that 0^0^0^0^0^0^0 == 0, so there * is no reason to not xor all the sub items together. This potentially * saves a register since things can be xored directly into L */ #if defined(DES_RISC1) || defined(DES_RISC2) #ifdef DES_RISC1 #define D_ENCRYPT(LL,R,S) { \ unsigned int u1,u2,u3; \ LOAD_DATA(R,S,u,t,E0,E1,u1); \ u2=(int)u>>8L; \ u1=(int)u&0xfc; \ u2&=0xfc; \ t=ROTATE(t,4); \ u>>=16L; \ LL^= *(const DES_LONG *)(des_SP +u1); \ LL^= *(const DES_LONG *)(des_SP+0x200+u2); \ u3=(int)(u>>8L); \ u1=(int)u&0xfc; \ u3&=0xfc; \ LL^= *(const DES_LONG *)(des_SP+0x400+u1); \ LL^= *(const DES_LONG *)(des_SP+0x600+u3); \ u2=(int)t>>8L; \ u1=(int)t&0xfc; \ u2&=0xfc; \ t>>=16L; \ LL^= *(const DES_LONG *)(des_SP+0x100+u1); \ LL^= *(const DES_LONG *)(des_SP+0x300+u2); \ u3=(int)t>>8L; \ u1=(int)t&0xfc; \ u3&=0xfc; \ LL^= *(const DES_LONG *)(des_SP+0x500+u1); \ LL^= *(const DES_LONG *)(des_SP+0x700+u3); } #endif #ifdef DES_RISC2 #define D_ENCRYPT(LL,R,S) { \ unsigned int u1,u2,s1,s2; \ LOAD_DATA(R,S,u,t,E0,E1,u1); \ u2=(int)u>>8L; \ u1=(int)u&0xfc; \ u2&=0xfc; \ t=ROTATE(t,4); \ LL^= *(const DES_LONG *)(des_SP +u1); \ LL^= *(const DES_LONG *)(des_SP+0x200+u2); \ s1=(int)(u>>16L); \ s2=(int)(u>>24L); \ s1&=0xfc; \ s2&=0xfc; \ LL^= *(const DES_LONG *)(des_SP+0x400+s1); \ LL^= *(const DES_LONG *)(des_SP+0x600+s2); \ u2=(int)t>>8L; \ u1=(int)t&0xfc; \ u2&=0xfc; \ LL^= *(const DES_LONG *)(des_SP+0x100+u1); \ LL^= *(const DES_LONG *)(des_SP+0x300+u2); \ s1=(int)(t>>16L); \ s2=(int)(t>>24L); \ s1&=0xfc; \ s2&=0xfc; \ LL^= *(const DES_LONG *)(des_SP+0x500+s1); \ LL^= *(const DES_LONG *)(des_SP+0x700+s2); } #endif #else #define D_ENCRYPT(LL,R,S) { \ LOAD_DATA_tmp(R,S,u,t,E0,E1); \ t=ROTATE(t,4); \ LL^= \ *(const DES_LONG *)(des_SP +((u )&0xfc))^ \ *(const DES_LONG *)(des_SP+0x200+((u>> 8L)&0xfc))^ \ *(const DES_LONG *)(des_SP+0x400+((u>>16L)&0xfc))^ \ *(const DES_LONG *)(des_SP+0x600+((u>>24L)&0xfc))^ \ *(const DES_LONG *)(des_SP+0x100+((t )&0xfc))^ \ *(const DES_LONG *)(des_SP+0x300+((t>> 8L)&0xfc))^ \ *(const DES_LONG *)(des_SP+0x500+((t>>16L)&0xfc))^ \ *(const DES_LONG *)(des_SP+0x700+((t>>24L)&0xfc)); } #endif #else /* original version */ #if defined(DES_RISC1) || defined(DES_RISC2) #ifdef DES_RISC1 #define D_ENCRYPT(LL,R,S) {\ unsigned int u1,u2,u3; \ LOAD_DATA(R,S,u,t,E0,E1,u1); \ u>>=2L; \ t=ROTATE(t,6); \ u2=(int)u>>8L; \ u1=(int)u&0x3f; \ u2&=0x3f; \ u>>=16L; \ LL^=DES_SPtrans[0][u1]; \ LL^=DES_SPtrans[2][u2]; \ u3=(int)u>>8L; \ u1=(int)u&0x3f; \ u3&=0x3f; \ LL^=DES_SPtrans[4][u1]; \ LL^=DES_SPtrans[6][u3]; \ u2=(int)t>>8L; \ u1=(int)t&0x3f; \ u2&=0x3f; \ t>>=16L; \ LL^=DES_SPtrans[1][u1]; \ LL^=DES_SPtrans[3][u2]; \ u3=(int)t>>8L; \ u1=(int)t&0x3f; \ u3&=0x3f; \ LL^=DES_SPtrans[5][u1]; \ LL^=DES_SPtrans[7][u3]; } #endif #ifdef DES_RISC2 #define D_ENCRYPT(LL,R,S) {\ unsigned int u1,u2,s1,s2; \ LOAD_DATA(R,S,u,t,E0,E1,u1); \ u>>=2L; \ t=ROTATE(t,6); \ u2=(int)u>>8L; \ u1=(int)u&0x3f; \ u2&=0x3f; \ LL^=DES_SPtrans[0][u1]; \ LL^=DES_SPtrans[2][u2]; \ s1=(int)u>>16L; \ s2=(int)u>>24L; \ s1&=0x3f; \ s2&=0x3f; \ LL^=DES_SPtrans[4][s1]; \ LL^=DES_SPtrans[6][s2]; \ u2=(int)t>>8L; \ u1=(int)t&0x3f; \ u2&=0x3f; \ LL^=DES_SPtrans[1][u1]; \ LL^=DES_SPtrans[3][u2]; \ s1=(int)t>>16; \ s2=(int)t>>24L; \ s1&=0x3f; \ s2&=0x3f; \ LL^=DES_SPtrans[5][s1]; \ LL^=DES_SPtrans[7][s2]; } #endif #else #define D_ENCRYPT(LL,R,S) {\ LOAD_DATA_tmp(R,S,u,t,E0,E1); \ t=ROTATE(t,4); \ LL^=\ DES_SPtrans[0][(u>> 2L)&0x3f]^ \ DES_SPtrans[2][(u>>10L)&0x3f]^ \ DES_SPtrans[4][(u>>18L)&0x3f]^ \ DES_SPtrans[6][(u>>26L)&0x3f]^ \ DES_SPtrans[1][(t>> 2L)&0x3f]^ \ DES_SPtrans[3][(t>>10L)&0x3f]^ \ DES_SPtrans[5][(t>>18L)&0x3f]^ \ DES_SPtrans[7][(t>>26L)&0x3f]; } #endif #endif /* IP and FP * The problem is more of a geometric problem that random bit fiddling. 0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6 8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4 16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2 24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0 32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7 40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5 48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3 56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1 The output has been subject to swaps of the form 0 1 -> 3 1 but the odd and even bits have been put into 2 3 2 0 different words. The main trick is to remember that t=((l>>size)^r)&(mask); r^=t; l^=(t<>(n))^(b))&(m)),\ (b)^=(t),\ (a)^=((t)<<(n))) #define IP(l,r) \ { \ register DES_LONG tt; \ PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \ PERM_OP(l,r,tt,16,0x0000ffffL); \ PERM_OP(r,l,tt, 2,0x33333333L); \ PERM_OP(l,r,tt, 8,0x00ff00ffL); \ PERM_OP(r,l,tt, 1,0x55555555L); \ } #define FP(l,r) \ { \ register DES_LONG tt; \ PERM_OP(l,r,tt, 1,0x55555555L); \ PERM_OP(r,l,tt, 8,0x00ff00ffL); \ PERM_OP(l,r,tt, 2,0x33333333L); \ PERM_OP(r,l,tt,16,0x0000ffffL); \ PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \ } extern const DES_LONG DES_SPtrans[8][64]; void fcrypt_body(DES_LONG *out,DES_key_schedule *ks, DES_LONG Eswap0, DES_LONG Eswap1); #ifdef OPENSSL_SMALL_FOOTPRINT #undef DES_UNROLL #endif #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/pcbc_enc.c0000644000175000017500000001046112360020705020730 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include "des_locl.h" void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, long length, DES_key_schedule *schedule, DES_cblock *ivec, int enc) { register DES_LONG sin0,sin1,xor0,xor1,tout0,tout1; DES_LONG tin[2]; const unsigned char *in; unsigned char *out,*iv; in=input; out=output; iv = &(*ivec)[0]; if (enc) { c2l(iv,xor0); c2l(iv,xor1); for (; length>0; length-=8) { if (length >= 8) { c2l(in,sin0); c2l(in,sin1); } else c2ln(in,sin0,sin1,length); tin[0]=sin0^xor0; tin[1]=sin1^xor1; DES_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT); tout0=tin[0]; tout1=tin[1]; xor0=sin0^tout0; xor1=sin1^tout1; l2c(tout0,out); l2c(tout1,out); } } else { c2l(iv,xor0); c2l(iv,xor1); for (; length>0; length-=8) { c2l(in,sin0); c2l(in,sin1); tin[0]=sin0; tin[1]=sin1; DES_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT); tout0=tin[0]^xor0; tout1=tin[1]^xor1; if (length >= 8) { l2c(tout0,out); l2c(tout1,out); } else l2cn(tout0,tout1,out,length); xor0=tout0^sin0; xor1=tout1^sin1; } } tin[0]=tin[1]=0; sin0=sin1=xor0=xor1=tout0=tout1=0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/fcrypt.c0000644000175000017500000000611312360020705020502 0ustar /* $OpenBSD$ */ #include /* This version of crypt has been developed from my MIT compatible * DES library. * Eric Young (eay@cryptsoft.com) */ /* Modification by Jens Kupferschmidt (Cu) * I have included directive PARA for shared memory computers. * I have included a directive LONGCRYPT to using this routine to cipher * passwords with more then 8 bytes like HP-UX 10.x it used. The MAXPLEN * definition is the maximum of length of password and can changed. I have * defined 24. */ #include "des_locl.h" /* Added more values to handle illegal salt values the way normal * crypt() implementations do. The patch was sent by * Bjorn Gronvall */ static unsigned const char con_salt[128]={ 0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9, 0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,0xE0,0xE1, 0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9, 0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1, 0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9, 0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,0x00,0x01, 0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09, 0x0A,0x0B,0x05,0x06,0x07,0x08,0x09,0x0A, 0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12, 0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A, 0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22, 0x23,0x24,0x25,0x20,0x21,0x22,0x23,0x24, 0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C, 0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34, 0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C, 0x3D,0x3E,0x3F,0x40,0x41,0x42,0x43,0x44, }; static unsigned const char cov_2char[64]={ 0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35, 0x36,0x37,0x38,0x39,0x41,0x42,0x43,0x44, 0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C, 0x4D,0x4E,0x4F,0x50,0x51,0x52,0x53,0x54, 0x55,0x56,0x57,0x58,0x59,0x5A,0x61,0x62, 0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A, 0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72, 0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A }; char *DES_crypt(const char *buf, const char *salt) { static char buff[14]; return(DES_fcrypt(buf,salt,buff)); } char *DES_fcrypt(const char *buf, const char *salt, char *ret) { unsigned int i,j,x,y; DES_LONG Eswap0,Eswap1; DES_LONG out[2],ll; DES_cblock key; DES_key_schedule ks; unsigned char bb[9]; unsigned char *b=bb; unsigned char c,u; /* eay 25/08/92 * If you call crypt("pwd","*") as often happens when you * have * as the pwd field in /etc/passwd, the function * returns *\0xxxxxxxxx * The \0 makes the string look like * so the pwd "*" would * crypt to "*". This was found when replacing the crypt in * our shared libraries. People found that the disabled * accounts effectively had no passwd :-(. */ x=ret[0]=((salt[0] == '\0')?'A':salt[0]); Eswap0=con_salt[x]<<2; x=ret[1]=((salt[1] == '\0')?'A':salt[1]); Eswap1=con_salt[x]<<6; /* EAY r=strlen(buf); r=(r+7)/8; */ for (i=0; i<8; i++) { c= *(buf++); if (!c) break; key[i]=(c<<1); } for (; i<8; i++) key[i]=0; DES_set_key_unchecked(&key,&ks); fcrypt_body(&(out[0]),&ks,Eswap0,Eswap1); ll=out[0]; l2c(ll,b); ll=out[1]; l2c(ll,b); y=0; u=0x80; bb[8]=0; for (i=2; i<13; i++) { c=0; for (j=0; j<6; j++) { c<<=1; if (bb[y] & u) c|=1; u>>=1; if (!u) { y++; u=0x80; } } ret[i]=cov_2char[c]; } ret[13]='\0'; return(ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/str2key.c0000644000175000017500000001271112360020705020577 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "des_locl.h" void DES_string_to_key(const char *str, DES_cblock *key) { DES_key_schedule ks; int i,length; register unsigned char j; memset(key,0,8); length=strlen(str); #ifdef OLD_STR_TO_KEY for (i=0; i>4)&0x0f); j=((j<<2)&0xcc)|((j>>2)&0x33); j=((j<<1)&0xaa)|((j>>1)&0x55); (*key)[7-(i%8)]^=j; } } #endif DES_set_odd_parity(key); #ifdef EXPERIMENTAL_STR_TO_STRONG_KEY if(DES_is_weak_key(key)) (*key)[7] ^= 0xF0; DES_set_key(key,&ks); #else DES_set_key_unchecked(key,&ks); #endif DES_cbc_cksum((const unsigned char*)str,key,length,&ks,key); OPENSSL_cleanse(&ks,sizeof(ks)); DES_set_odd_parity(key); } void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2) { DES_key_schedule ks; int i,length; register unsigned char j; memset(key1,0,8); memset(key2,0,8); length=strlen(str); #ifdef OLD_STR_TO_KEY if (length <= 8) { for (i=0; i>4)&0x0f); j=((j<<2)&0xcc)|((j>>2)&0x33); j=((j<<1)&0xaa)|((j>>1)&0x55); if ((i%16) < 8) (*key1)[7-(i%8)]^=j; else (*key2)[7-(i%8)]^=j; } } if (length <= 8) memcpy(key2,key1,8); #endif DES_set_odd_parity(key1); DES_set_odd_parity(key2); #ifdef EXPERIMENTAL_STR_TO_STRONG_KEY if(DES_is_weak_key(key1)) (*key1)[7] ^= 0xF0; DES_set_key(key1,&ks); #else DES_set_key_unchecked(key1,&ks); #endif DES_cbc_cksum((const unsigned char*)str,key1,length,&ks,key1); #ifdef EXPERIMENTAL_STR_TO_STRONG_KEY if(DES_is_weak_key(key2)) (*key2)[7] ^= 0xF0; DES_set_key(key2,&ks); #else DES_set_key_unchecked(key2,&ks); #endif DES_cbc_cksum((const unsigned char*)str,key2,length,&ks,key2); OPENSSL_cleanse(&ks,sizeof(ks)); DES_set_odd_parity(key1); DES_set_odd_parity(key2); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/xcbc_enc.c0000644000175000017500000001576112360020705020750 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include "des_locl.h" /* RSA's DESX */ #if 0 /* broken code, preserved just in case anyone specifically looks for this */ static const unsigned char desx_white_in2out[256]={ 0xBD,0x56,0xEA,0xF2,0xA2,0xF1,0xAC,0x2A,0xB0,0x93,0xD1,0x9C,0x1B,0x33,0xFD,0xD0, 0x30,0x04,0xB6,0xDC,0x7D,0xDF,0x32,0x4B,0xF7,0xCB,0x45,0x9B,0x31,0xBB,0x21,0x5A, 0x41,0x9F,0xE1,0xD9,0x4A,0x4D,0x9E,0xDA,0xA0,0x68,0x2C,0xC3,0x27,0x5F,0x80,0x36, 0x3E,0xEE,0xFB,0x95,0x1A,0xFE,0xCE,0xA8,0x34,0xA9,0x13,0xF0,0xA6,0x3F,0xD8,0x0C, 0x78,0x24,0xAF,0x23,0x52,0xC1,0x67,0x17,0xF5,0x66,0x90,0xE7,0xE8,0x07,0xB8,0x60, 0x48,0xE6,0x1E,0x53,0xF3,0x92,0xA4,0x72,0x8C,0x08,0x15,0x6E,0x86,0x00,0x84,0xFA, 0xF4,0x7F,0x8A,0x42,0x19,0xF6,0xDB,0xCD,0x14,0x8D,0x50,0x12,0xBA,0x3C,0x06,0x4E, 0xEC,0xB3,0x35,0x11,0xA1,0x88,0x8E,0x2B,0x94,0x99,0xB7,0x71,0x74,0xD3,0xE4,0xBF, 0x3A,0xDE,0x96,0x0E,0xBC,0x0A,0xED,0x77,0xFC,0x37,0x6B,0x03,0x79,0x89,0x62,0xC6, 0xD7,0xC0,0xD2,0x7C,0x6A,0x8B,0x22,0xA3,0x5B,0x05,0x5D,0x02,0x75,0xD5,0x61,0xE3, 0x18,0x8F,0x55,0x51,0xAD,0x1F,0x0B,0x5E,0x85,0xE5,0xC2,0x57,0x63,0xCA,0x3D,0x6C, 0xB4,0xC5,0xCC,0x70,0xB2,0x91,0x59,0x0D,0x47,0x20,0xC8,0x4F,0x58,0xE0,0x01,0xE2, 0x16,0x38,0xC4,0x6F,0x3B,0x0F,0x65,0x46,0xBE,0x7E,0x2D,0x7B,0x82,0xF9,0x40,0xB5, 0x1D,0x73,0xF8,0xEB,0x26,0xC7,0x87,0x97,0x25,0x54,0xB1,0x28,0xAA,0x98,0x9D,0xA5, 0x64,0x6D,0x7A,0xD4,0x10,0x81,0x44,0xEF,0x49,0xD6,0xAE,0x2E,0xDD,0x76,0x5C,0x2F, 0xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB, }; void DES_xwhite_in2out(const_DES_cblock *des_key, const_DES_cblock *in_white, DES_cblock *out_white) { int out0,out1; int i; const unsigned char *key = &(*des_key)[0]; const unsigned char *in = &(*in_white)[0]; unsigned char *out = &(*out_white)[0]; out[0]=out[1]=out[2]=out[3]=out[4]=out[5]=out[6]=out[7]=0; out0=out1=0; for (i=0; i<8; i++) { out[i]=key[i]^desx_white_in2out[out0^out1]; out0=out1; out1=(int)out[i&0x07]; } out0=out[0]; out1=out[i]; /* BUG: out-of-bounds read */ for (i=0; i<8; i++) { out[i]=in[i]^desx_white_in2out[out0^out1]; out0=out1; out1=(int)out[i&0x07]; } } #endif void DES_xcbc_encrypt(const unsigned char *in, unsigned char *out, long length, DES_key_schedule *schedule, DES_cblock *ivec, const_DES_cblock *inw, const_DES_cblock *outw, int enc) { register DES_LONG tin0,tin1; register DES_LONG tout0,tout1,xor0,xor1; register DES_LONG inW0,inW1,outW0,outW1; register const unsigned char *in2; register long l=length; DES_LONG tin[2]; unsigned char *iv; in2 = &(*inw)[0]; c2l(in2,inW0); c2l(in2,inW1); in2 = &(*outw)[0]; c2l(in2,outW0); c2l(in2,outW1); iv = &(*ivec)[0]; if (enc) { c2l(iv,tout0); c2l(iv,tout1); for (l-=8; l>=0; l-=8) { c2l(in,tin0); c2l(in,tin1); tin0^=tout0^inW0; tin[0]=tin0; tin1^=tout1^inW1; tin[1]=tin1; DES_encrypt1(tin,schedule,DES_ENCRYPT); tout0=tin[0]^outW0; l2c(tout0,out); tout1=tin[1]^outW1; l2c(tout1,out); } if (l != -8) { c2ln(in,tin0,tin1,l+8); tin0^=tout0^inW0; tin[0]=tin0; tin1^=tout1^inW1; tin[1]=tin1; DES_encrypt1(tin,schedule,DES_ENCRYPT); tout0=tin[0]^outW0; l2c(tout0,out); tout1=tin[1]^outW1; l2c(tout1,out); } iv = &(*ivec)[0]; l2c(tout0,iv); l2c(tout1,iv); } else { c2l(iv,xor0); c2l(iv,xor1); for (l-=8; l>0; l-=8) { c2l(in,tin0); tin[0]=tin0^outW0; c2l(in,tin1); tin[1]=tin1^outW1; DES_encrypt1(tin,schedule,DES_DECRYPT); tout0=tin[0]^xor0^inW0; tout1=tin[1]^xor1^inW1; l2c(tout0,out); l2c(tout1,out); xor0=tin0; xor1=tin1; } if (l != -8) { c2l(in,tin0); tin[0]=tin0^outW0; c2l(in,tin1); tin[1]=tin1^outW1; DES_encrypt1(tin,schedule,DES_DECRYPT); tout0=tin[0]^xor0^inW0; tout1=tin[1]^xor1^inW1; l2cn(tout0,tout1,out,l+8); xor0=tin0; xor1=tin1; } iv = &(*ivec)[0]; l2c(xor0,iv); l2c(xor1,iv); } tin0=tin1=tout0=tout1=xor0=xor1=0; inW0=inW1=outW0=outW1=0; tin[0]=tin[1]=0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/ofb64ede.c0000644000175000017500000001070112360020705020567 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include "des_locl.h" /* The input and output encrypted as though 64bit ofb mode is being * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ void DES_ede3_ofb64_encrypt(register const unsigned char *in, register unsigned char *out, long length, DES_key_schedule *k1, DES_key_schedule *k2, DES_key_schedule *k3, DES_cblock *ivec, int *num) { register DES_LONG v0,v1; register int n= *num; register long l=length; DES_cblock d; register char *dp; DES_LONG ti[2]; unsigned char *iv; int save=0; iv = &(*ivec)[0]; c2l(iv,v0); c2l(iv,v1); ti[0]=v0; ti[1]=v1; dp=(char *)d; l2c(v0,dp); l2c(v1,dp); while (l--) { if (n == 0) { /* ti[0]=v0; */ /* ti[1]=v1; */ DES_encrypt3(ti,k1,k2,k3); v0=ti[0]; v1=ti[1]; dp=(char *)d; l2c(v0,dp); l2c(v1,dp); save++; } *(out++)= *(in++)^d[n]; n=(n+1)&0x07; } if (save) { /* v0=ti[0]; v1=ti[1];*/ iv = &(*ivec)[0]; l2c(v0,iv); l2c(v1,iv); } v0=v1=ti[0]=ti[1]=0; *num=n; } #ifdef undef /* MACRO */ void DES_ede2_ofb64_encrypt(register unsigned char *in, register unsigned char *out, long length, DES_key_schedule k1, DES_key_schedule k2, DES_cblock (*ivec), int *num) { DES_ede3_ofb64_encrypt(in, out, length, k1,k2,k1, ivec, num); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/set_key.c0000644000175000017500000003727012360020705020646 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* set_key.c v 1.4 eay 24/9/91 * 1.4 Speed up by 400% :-) * 1.3 added register declarations. * 1.2 unrolled make_key_sched a bit more * 1.1 added norm_expand_bits * 1.0 First working version */ #include #include "des_locl.h" int DES_check_key = 0; /* defaults to false */ static const unsigned char odd_parity[256]={ 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14, 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31, 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47, 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62, 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79, 81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94, 97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110, 112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127, 128,128,131,131,133,133,134,134,137,137,138,138,140,140,143,143, 145,145,146,146,148,148,151,151,152,152,155,155,157,157,158,158, 161,161,162,162,164,164,167,167,168,168,171,171,173,173,174,174, 176,176,179,179,181,181,182,182,185,185,186,186,188,188,191,191, 193,193,194,194,196,196,199,199,200,200,203,203,205,205,206,206, 208,208,211,211,213,213,214,214,217,217,218,218,220,220,223,223, 224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239, 241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254}; void DES_set_odd_parity(DES_cblock *key) { unsigned int i; for (i=0; i>(n))^(b))&(m)),\ * (b)^=(t),\ * (a)=((a)^((t)<<(n)))) */ #define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ (a)=(a)^(t)^(t>>(16-(n)))) static const DES_LONG des_skb[8][64]={ { /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ 0x00000000L,0x00000010L,0x20000000L,0x20000010L, 0x00010000L,0x00010010L,0x20010000L,0x20010010L, 0x00000800L,0x00000810L,0x20000800L,0x20000810L, 0x00010800L,0x00010810L,0x20010800L,0x20010810L, 0x00000020L,0x00000030L,0x20000020L,0x20000030L, 0x00010020L,0x00010030L,0x20010020L,0x20010030L, 0x00000820L,0x00000830L,0x20000820L,0x20000830L, 0x00010820L,0x00010830L,0x20010820L,0x20010830L, 0x00080000L,0x00080010L,0x20080000L,0x20080010L, 0x00090000L,0x00090010L,0x20090000L,0x20090010L, 0x00080800L,0x00080810L,0x20080800L,0x20080810L, 0x00090800L,0x00090810L,0x20090800L,0x20090810L, 0x00080020L,0x00080030L,0x20080020L,0x20080030L, 0x00090020L,0x00090030L,0x20090020L,0x20090030L, 0x00080820L,0x00080830L,0x20080820L,0x20080830L, 0x00090820L,0x00090830L,0x20090820L,0x20090830L, },{ /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ 0x00000000L,0x02000000L,0x00002000L,0x02002000L, 0x00200000L,0x02200000L,0x00202000L,0x02202000L, 0x00000004L,0x02000004L,0x00002004L,0x02002004L, 0x00200004L,0x02200004L,0x00202004L,0x02202004L, 0x00000400L,0x02000400L,0x00002400L,0x02002400L, 0x00200400L,0x02200400L,0x00202400L,0x02202400L, 0x00000404L,0x02000404L,0x00002404L,0x02002404L, 0x00200404L,0x02200404L,0x00202404L,0x02202404L, 0x10000000L,0x12000000L,0x10002000L,0x12002000L, 0x10200000L,0x12200000L,0x10202000L,0x12202000L, 0x10000004L,0x12000004L,0x10002004L,0x12002004L, 0x10200004L,0x12200004L,0x10202004L,0x12202004L, 0x10000400L,0x12000400L,0x10002400L,0x12002400L, 0x10200400L,0x12200400L,0x10202400L,0x12202400L, 0x10000404L,0x12000404L,0x10002404L,0x12002404L, 0x10200404L,0x12200404L,0x10202404L,0x12202404L, },{ /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ 0x00000000L,0x00000001L,0x00040000L,0x00040001L, 0x01000000L,0x01000001L,0x01040000L,0x01040001L, 0x00000002L,0x00000003L,0x00040002L,0x00040003L, 0x01000002L,0x01000003L,0x01040002L,0x01040003L, 0x00000200L,0x00000201L,0x00040200L,0x00040201L, 0x01000200L,0x01000201L,0x01040200L,0x01040201L, 0x00000202L,0x00000203L,0x00040202L,0x00040203L, 0x01000202L,0x01000203L,0x01040202L,0x01040203L, 0x08000000L,0x08000001L,0x08040000L,0x08040001L, 0x09000000L,0x09000001L,0x09040000L,0x09040001L, 0x08000002L,0x08000003L,0x08040002L,0x08040003L, 0x09000002L,0x09000003L,0x09040002L,0x09040003L, 0x08000200L,0x08000201L,0x08040200L,0x08040201L, 0x09000200L,0x09000201L,0x09040200L,0x09040201L, 0x08000202L,0x08000203L,0x08040202L,0x08040203L, 0x09000202L,0x09000203L,0x09040202L,0x09040203L, },{ /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ 0x00000000L,0x00100000L,0x00000100L,0x00100100L, 0x00000008L,0x00100008L,0x00000108L,0x00100108L, 0x00001000L,0x00101000L,0x00001100L,0x00101100L, 0x00001008L,0x00101008L,0x00001108L,0x00101108L, 0x04000000L,0x04100000L,0x04000100L,0x04100100L, 0x04000008L,0x04100008L,0x04000108L,0x04100108L, 0x04001000L,0x04101000L,0x04001100L,0x04101100L, 0x04001008L,0x04101008L,0x04001108L,0x04101108L, 0x00020000L,0x00120000L,0x00020100L,0x00120100L, 0x00020008L,0x00120008L,0x00020108L,0x00120108L, 0x00021000L,0x00121000L,0x00021100L,0x00121100L, 0x00021008L,0x00121008L,0x00021108L,0x00121108L, 0x04020000L,0x04120000L,0x04020100L,0x04120100L, 0x04020008L,0x04120008L,0x04020108L,0x04120108L, 0x04021000L,0x04121000L,0x04021100L,0x04121100L, 0x04021008L,0x04121008L,0x04021108L,0x04121108L, },{ /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ 0x00000000L,0x10000000L,0x00010000L,0x10010000L, 0x00000004L,0x10000004L,0x00010004L,0x10010004L, 0x20000000L,0x30000000L,0x20010000L,0x30010000L, 0x20000004L,0x30000004L,0x20010004L,0x30010004L, 0x00100000L,0x10100000L,0x00110000L,0x10110000L, 0x00100004L,0x10100004L,0x00110004L,0x10110004L, 0x20100000L,0x30100000L,0x20110000L,0x30110000L, 0x20100004L,0x30100004L,0x20110004L,0x30110004L, 0x00001000L,0x10001000L,0x00011000L,0x10011000L, 0x00001004L,0x10001004L,0x00011004L,0x10011004L, 0x20001000L,0x30001000L,0x20011000L,0x30011000L, 0x20001004L,0x30001004L,0x20011004L,0x30011004L, 0x00101000L,0x10101000L,0x00111000L,0x10111000L, 0x00101004L,0x10101004L,0x00111004L,0x10111004L, 0x20101000L,0x30101000L,0x20111000L,0x30111000L, 0x20101004L,0x30101004L,0x20111004L,0x30111004L, },{ /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ 0x00000000L,0x08000000L,0x00000008L,0x08000008L, 0x00000400L,0x08000400L,0x00000408L,0x08000408L, 0x00020000L,0x08020000L,0x00020008L,0x08020008L, 0x00020400L,0x08020400L,0x00020408L,0x08020408L, 0x00000001L,0x08000001L,0x00000009L,0x08000009L, 0x00000401L,0x08000401L,0x00000409L,0x08000409L, 0x00020001L,0x08020001L,0x00020009L,0x08020009L, 0x00020401L,0x08020401L,0x00020409L,0x08020409L, 0x02000000L,0x0A000000L,0x02000008L,0x0A000008L, 0x02000400L,0x0A000400L,0x02000408L,0x0A000408L, 0x02020000L,0x0A020000L,0x02020008L,0x0A020008L, 0x02020400L,0x0A020400L,0x02020408L,0x0A020408L, 0x02000001L,0x0A000001L,0x02000009L,0x0A000009L, 0x02000401L,0x0A000401L,0x02000409L,0x0A000409L, 0x02020001L,0x0A020001L,0x02020009L,0x0A020009L, 0x02020401L,0x0A020401L,0x02020409L,0x0A020409L, },{ /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ 0x00000000L,0x00000100L,0x00080000L,0x00080100L, 0x01000000L,0x01000100L,0x01080000L,0x01080100L, 0x00000010L,0x00000110L,0x00080010L,0x00080110L, 0x01000010L,0x01000110L,0x01080010L,0x01080110L, 0x00200000L,0x00200100L,0x00280000L,0x00280100L, 0x01200000L,0x01200100L,0x01280000L,0x01280100L, 0x00200010L,0x00200110L,0x00280010L,0x00280110L, 0x01200010L,0x01200110L,0x01280010L,0x01280110L, 0x00000200L,0x00000300L,0x00080200L,0x00080300L, 0x01000200L,0x01000300L,0x01080200L,0x01080300L, 0x00000210L,0x00000310L,0x00080210L,0x00080310L, 0x01000210L,0x01000310L,0x01080210L,0x01080310L, 0x00200200L,0x00200300L,0x00280200L,0x00280300L, 0x01200200L,0x01200300L,0x01280200L,0x01280300L, 0x00200210L,0x00200310L,0x00280210L,0x00280310L, 0x01200210L,0x01200310L,0x01280210L,0x01280310L, },{ /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ 0x00000000L,0x04000000L,0x00040000L,0x04040000L, 0x00000002L,0x04000002L,0x00040002L,0x04040002L, 0x00002000L,0x04002000L,0x00042000L,0x04042000L, 0x00002002L,0x04002002L,0x00042002L,0x04042002L, 0x00000020L,0x04000020L,0x00040020L,0x04040020L, 0x00000022L,0x04000022L,0x00040022L,0x04040022L, 0x00002020L,0x04002020L,0x00042020L,0x04042020L, 0x00002022L,0x04002022L,0x00042022L,0x04042022L, 0x00000800L,0x04000800L,0x00040800L,0x04040800L, 0x00000802L,0x04000802L,0x00040802L,0x04040802L, 0x00002800L,0x04002800L,0x00042800L,0x04042800L, 0x00002802L,0x04002802L,0x00042802L,0x04042802L, 0x00000820L,0x04000820L,0x00040820L,0x04040820L, 0x00000822L,0x04000822L,0x00040822L,0x04040822L, 0x00002820L,0x04002820L,0x00042820L,0x04042820L, 0x00002822L,0x04002822L,0x00042822L,0x04042822L, }}; int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule) { if (DES_check_key) { return DES_set_key_checked(key, schedule); } else { DES_set_key_unchecked(key, schedule); return 0; } } /* return 0 if key parity is odd (correct), * return -1 if key parity error, * return -2 if illegal weak key. */ int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule) { if (!DES_check_key_parity(key)) return(-1); if (DES_is_weak_key(key)) return(-2); DES_set_key_unchecked(key, schedule); return 0; } void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule) { static const int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; register DES_LONG c,d,t,s,t2; register const unsigned char *in; register DES_LONG *k; register int i; k = &schedule->ks->deslong[0]; in = &(*key)[0]; c2l(in,c); c2l(in,d); /* do PC1 in 47 simple operations :-) * Thanks to John Fletcher (john_fletcher@lccmail.ocf.llnl.gov) * for the inspiration. :-) */ PERM_OP (d,c,t,4,0x0f0f0f0fL); HPERM_OP(c,t,-2,0xcccc0000L); HPERM_OP(d,t,-2,0xcccc0000L); PERM_OP (d,c,t,1,0x55555555L); PERM_OP (c,d,t,8,0x00ff00ffL); PERM_OP (d,c,t,1,0x55555555L); d= (((d&0x000000ffL)<<16L)| (d&0x0000ff00L) | ((d&0x00ff0000L)>>16L)|((c&0xf0000000L)>>4L)); c&=0x0fffffffL; for (i=0; i>2L)|(c<<26L)); d=((d>>2L)|(d<<26L)); } else { c=((c>>1L)|(c<<27L)); d=((d>>1L)|(d<<27L)); } c&=0x0fffffffL; d&=0x0fffffffL; /* could be a few less shifts but I am to lazy at this * point in time to investigate */ s= des_skb[0][ (c )&0x3f ]| des_skb[1][((c>> 6L)&0x03)|((c>> 7L)&0x3c)]| des_skb[2][((c>>13L)&0x0f)|((c>>14L)&0x30)]| des_skb[3][((c>>20L)&0x01)|((c>>21L)&0x06) | ((c>>22L)&0x38)]; t= des_skb[4][ (d )&0x3f ]| des_skb[5][((d>> 7L)&0x03)|((d>> 8L)&0x3c)]| des_skb[6][ (d>>15L)&0x3f ]| des_skb[7][((d>>21L)&0x0f)|((d>>22L)&0x30)]; /* table contained 0213 4657 */ t2=((t<<16L)|(s&0x0000ffffL))&0xffffffffL; *(k++)=ROTATE(t2,30)&0xffffffffL; t2=((s>>16L)|(t&0xffff0000L)); *(k++)=ROTATE(t2,26)&0xffffffffL; } } int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule) { return(DES_set_key(key,schedule)); } /* #undef des_fixup_key_parity void des_fixup_key_parity(des_cblock *key) { des_set_odd_parity(key); } */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/cfb64ede.c0000644000175000017500000001542412360020705020562 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include "des_locl.h" /* The input and output encrypted as though 64bit cfb mode is being * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, DES_key_schedule *ks1, DES_key_schedule *ks2, DES_key_schedule *ks3, DES_cblock *ivec, int *num, int enc) { register DES_LONG v0,v1; register long l=length; register int n= *num; DES_LONG ti[2]; unsigned char *iv,c,cc; iv=&(*ivec)[0]; if (enc) { while (l--) { if (n == 0) { c2l(iv,v0); c2l(iv,v1); ti[0]=v0; ti[1]=v1; DES_encrypt3(ti,ks1,ks2,ks3); v0=ti[0]; v1=ti[1]; iv = &(*ivec)[0]; l2c(v0,iv); l2c(v1,iv); iv = &(*ivec)[0]; } c= *(in++)^iv[n]; *(out++)=c; iv[n]=c; n=(n+1)&0x07; } } else { while (l--) { if (n == 0) { c2l(iv,v0); c2l(iv,v1); ti[0]=v0; ti[1]=v1; DES_encrypt3(ti,ks1,ks2,ks3); v0=ti[0]; v1=ti[1]; iv = &(*ivec)[0]; l2c(v0,iv); l2c(v1,iv); iv = &(*ivec)[0]; } cc= *(in++); c=iv[n]; iv[n]=cc; *(out++)=c^cc; n=(n+1)&0x07; } } v0=v1=ti[0]=ti[1]=c=cc=0; *num=n; } #ifdef undef /* MACRO */ void DES_ede2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, DES_key_schedule ks1, DES_key_schedule ks2, DES_cblock (*ivec), int *num, int enc) { DES_ede3_cfb64_encrypt(in,out,length,ks1,ks2,ks1,ivec,num,enc); } #endif /* This is compatible with the single key CFB-r for DES, even thought that's * not what EVP needs. */ void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out, int numbits,long length,DES_key_schedule *ks1, DES_key_schedule *ks2,DES_key_schedule *ks3, DES_cblock *ivec,int enc) { register DES_LONG d0,d1,v0,v1; register unsigned long l=length,n=((unsigned int)numbits+7)/8; register int num=numbits,i; DES_LONG ti[2]; unsigned char *iv; unsigned char ovec[16]; if (num > 64) return; iv = &(*ivec)[0]; c2l(iv,v0); c2l(iv,v1); if (enc) { while (l >= n) { l-=n; ti[0]=v0; ti[1]=v1; DES_encrypt3(ti,ks1,ks2,ks3); c2ln(in,d0,d1,n); in+=n; d0^=ti[0]; d1^=ti[1]; l2cn(d0,d1,out,n); out+=n; /* 30-08-94 - eay - changed because l>>32 and * l<<32 are bad under gcc :-( */ if (num == 32) { v0=v1; v1=d0; } else if (num == 64) { v0=d0; v1=d1; } else { iv=&ovec[0]; l2c(v0,iv); l2c(v1,iv); l2c(d0,iv); l2c(d1,iv); /* shift ovec left most of the bits... */ memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0)); /* now the remaining bits */ if(num%8 != 0) for(i=0 ; i < 8 ; ++i) { ovec[i]<<=num%8; ovec[i]|=ovec[i+1]>>(8-num%8); } iv=&ovec[0]; c2l(iv,v0); c2l(iv,v1); } } } else { while (l >= n) { l-=n; ti[0]=v0; ti[1]=v1; DES_encrypt3(ti,ks1,ks2,ks3); c2ln(in,d0,d1,n); in+=n; /* 30-08-94 - eay - changed because l>>32 and * l<<32 are bad under gcc :-( */ if (num == 32) { v0=v1; v1=d0; } else if (num == 64) { v0=d0; v1=d1; } else { iv=&ovec[0]; l2c(v0,iv); l2c(v1,iv); l2c(d0,iv); l2c(d1,iv); /* shift ovec left most of the bits... */ memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0)); /* now the remaining bits */ if(num%8 != 0) for(i=0 ; i < 8 ; ++i) { ovec[i]<<=num%8; ovec[i]|=ovec[i+1]>>(8-num%8); } iv=&ovec[0]; c2l(iv,v0); c2l(iv,v1); } d0^=ti[0]; d1^=ti[1]; l2cn(d0,d1,out,n); out+=n; } } iv = &(*ivec)[0]; l2c(v0,iv); l2c(v1,iv); v0=v1=d0=d1=ti[0]=ti[1]=0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/enc_read.c0000644000175000017500000001632012360020705020734 0ustar /* $OpenBSD: enc_read.c,v 1.13 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include "des_locl.h" /* This has some uglies in it but it works - even over sockets. */ /*extern int errno;*/ int DES_rw_mode = DES_PCBC_MODE; /* * WARNINGS: * * - The data format used by DES_enc_write() and DES_enc_read() * has a cryptographic weakness: When asked to write more * than MAXWRITE bytes, DES_enc_write will split the data * into several chunks that are all encrypted * using the same IV. So don't use these functions unless you * are sure you know what you do (in which case you might * not want to use them anyway). * * - This code cannot handle non-blocking sockets. * * - This function uses an internal state and thus cannot be * used on multiple files. */ int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched, DES_cblock *iv) { #if defined(OPENSSL_NO_POSIX_IO) return(0); #else /* data to be unencrypted */ int net_num=0; static unsigned char *net=NULL; /* extra unencrypted data * for when a block of 100 comes in but is des_read one byte at * a time. */ static unsigned char *unnet=NULL; static int unnet_start=0; static int unnet_left=0; static unsigned char *tmpbuf=NULL; int i; long num=0,rnum; unsigned char *p; if (tmpbuf == NULL) { tmpbuf=malloc(BSIZE); if (tmpbuf == NULL) return(-1); } if (net == NULL) { net=malloc(BSIZE); if (net == NULL) return(-1); } if (unnet == NULL) { unnet=malloc(BSIZE); if (unnet == NULL) return(-1); } /* left over data from last decrypt */ if (unnet_left != 0) { if (unnet_left < len) { /* we still still need more data but will return * with the number of bytes we have - should always * check the return value */ memcpy(buf,&(unnet[unnet_start]), unnet_left); /* eay 26/08/92 I had the next 2 lines * reversed :-( */ i=unnet_left; unnet_start=unnet_left=0; } else { memcpy(buf,&(unnet[unnet_start]),len); unnet_start+=len; unnet_left-=len; i=len; } return(i); } /* We need to get more data. */ if (len > MAXWRITE) len=MAXWRITE; /* first - get the length */ while (net_num < HDRSIZE) { i=read(fd,(void *)&(net[net_num]),HDRSIZE-net_num); #ifdef EINTR if ((i == -1) && (errno == EINTR)) continue; #endif if (i <= 0) return(0); net_num+=i; } /* we now have at net_num bytes in net */ p=net; /* num=0; */ n2l(p,num); /* num should be rounded up to the next group of eight * we make sure that we have read a multiple of 8 bytes from the net. */ if ((num > MAXWRITE) || (num < 0)) /* error */ return(-1); rnum=(num < 8)?8:((num+7)/8*8); net_num=0; while (net_num < rnum) { i=read(fd,(void *)&(net[net_num]),rnum-net_num); #ifdef EINTR if ((i == -1) && (errno == EINTR)) continue; #endif if (i <= 0) return(0); net_num+=i; } /* Check if there will be data left over. */ if (len < num) { if (DES_rw_mode & DES_PCBC_MODE) DES_pcbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT); else DES_cbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT); memcpy(buf,unnet,len); unnet_start=len; unnet_left=num-len; /* The following line is done because we return num * as the number of bytes read. */ num=len; } else { /* >output is a multiple of 8 byes, if len < rnum * >we must be careful. The user must be aware that this * >routine will write more bytes than he asked for. * >The length of the buffer must be correct. * FIXED - Should be ok now 18-9-90 - eay */ if (len < rnum) { if (DES_rw_mode & DES_PCBC_MODE) DES_pcbc_encrypt(net,tmpbuf,num,sched,iv, DES_DECRYPT); else DES_cbc_encrypt(net,tmpbuf,num,sched,iv, DES_DECRYPT); /* eay 26/08/92 fix a bug that returned more * bytes than you asked for (returned len bytes :-( */ memcpy(buf,tmpbuf,num); } else { if (DES_rw_mode & DES_PCBC_MODE) DES_pcbc_encrypt(net,buf,num,sched,iv, DES_DECRYPT); else DES_cbc_encrypt(net,buf,num,sched,iv, DES_DECRYPT); } } return num; #endif /* OPENSSL_NO_POSIX_IO */ } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/cfb64enc.c0000644000175000017500000001045412360020705020570 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include "des_locl.h" /* The input and output encrypted as though 64bit cfb mode is being * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, DES_key_schedule *schedule, DES_cblock *ivec, int *num, int enc) { register DES_LONG v0,v1; register long l=length; register int n= *num; DES_LONG ti[2]; unsigned char *iv,c,cc; iv = &(*ivec)[0]; if (enc) { while (l--) { if (n == 0) { c2l(iv,v0); ti[0]=v0; c2l(iv,v1); ti[1]=v1; DES_encrypt1(ti,schedule,DES_ENCRYPT); iv = &(*ivec)[0]; v0=ti[0]; l2c(v0,iv); v0=ti[1]; l2c(v0,iv); iv = &(*ivec)[0]; } c= *(in++)^iv[n]; *(out++)=c; iv[n]=c; n=(n+1)&0x07; } } else { while (l--) { if (n == 0) { c2l(iv,v0); ti[0]=v0; c2l(iv,v1); ti[1]=v1; DES_encrypt1(ti,schedule,DES_ENCRYPT); iv = &(*ivec)[0]; v0=ti[0]; l2c(v0,iv); v0=ti[1]; l2c(v0,iv); iv = &(*ivec)[0]; } cc= *(in++); c=iv[n]; iv[n]=cc; *(out++)=c^cc; n=(n+1)&0x07; } } v0=v1=ti[0]=ti[1]=c=cc=0; *num=n; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/spr.h0000644000175000017500000002346012360020705020010 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ const DES_LONG DES_SPtrans[8][64]={ { /* nibble 0 */ 0x02080800L, 0x00080000L, 0x02000002L, 0x02080802L, 0x02000000L, 0x00080802L, 0x00080002L, 0x02000002L, 0x00080802L, 0x02080800L, 0x02080000L, 0x00000802L, 0x02000802L, 0x02000000L, 0x00000000L, 0x00080002L, 0x00080000L, 0x00000002L, 0x02000800L, 0x00080800L, 0x02080802L, 0x02080000L, 0x00000802L, 0x02000800L, 0x00000002L, 0x00000800L, 0x00080800L, 0x02080002L, 0x00000800L, 0x02000802L, 0x02080002L, 0x00000000L, 0x00000000L, 0x02080802L, 0x02000800L, 0x00080002L, 0x02080800L, 0x00080000L, 0x00000802L, 0x02000800L, 0x02080002L, 0x00000800L, 0x00080800L, 0x02000002L, 0x00080802L, 0x00000002L, 0x02000002L, 0x02080000L, 0x02080802L, 0x00080800L, 0x02080000L, 0x02000802L, 0x02000000L, 0x00000802L, 0x00080002L, 0x00000000L, 0x00080000L, 0x02000000L, 0x02000802L, 0x02080800L, 0x00000002L, 0x02080002L, 0x00000800L, 0x00080802L, },{ /* nibble 1 */ 0x40108010L, 0x00000000L, 0x00108000L, 0x40100000L, 0x40000010L, 0x00008010L, 0x40008000L, 0x00108000L, 0x00008000L, 0x40100010L, 0x00000010L, 0x40008000L, 0x00100010L, 0x40108000L, 0x40100000L, 0x00000010L, 0x00100000L, 0x40008010L, 0x40100010L, 0x00008000L, 0x00108010L, 0x40000000L, 0x00000000L, 0x00100010L, 0x40008010L, 0x00108010L, 0x40108000L, 0x40000010L, 0x40000000L, 0x00100000L, 0x00008010L, 0x40108010L, 0x00100010L, 0x40108000L, 0x40008000L, 0x00108010L, 0x40108010L, 0x00100010L, 0x40000010L, 0x00000000L, 0x40000000L, 0x00008010L, 0x00100000L, 0x40100010L, 0x00008000L, 0x40000000L, 0x00108010L, 0x40008010L, 0x40108000L, 0x00008000L, 0x00000000L, 0x40000010L, 0x00000010L, 0x40108010L, 0x00108000L, 0x40100000L, 0x40100010L, 0x00100000L, 0x00008010L, 0x40008000L, 0x40008010L, 0x00000010L, 0x40100000L, 0x00108000L, },{ /* nibble 2 */ 0x04000001L, 0x04040100L, 0x00000100L, 0x04000101L, 0x00040001L, 0x04000000L, 0x04000101L, 0x00040100L, 0x04000100L, 0x00040000L, 0x04040000L, 0x00000001L, 0x04040101L, 0x00000101L, 0x00000001L, 0x04040001L, 0x00000000L, 0x00040001L, 0x04040100L, 0x00000100L, 0x00000101L, 0x04040101L, 0x00040000L, 0x04000001L, 0x04040001L, 0x04000100L, 0x00040101L, 0x04040000L, 0x00040100L, 0x00000000L, 0x04000000L, 0x00040101L, 0x04040100L, 0x00000100L, 0x00000001L, 0x00040000L, 0x00000101L, 0x00040001L, 0x04040000L, 0x04000101L, 0x00000000L, 0x04040100L, 0x00040100L, 0x04040001L, 0x00040001L, 0x04000000L, 0x04040101L, 0x00000001L, 0x00040101L, 0x04000001L, 0x04000000L, 0x04040101L, 0x00040000L, 0x04000100L, 0x04000101L, 0x00040100L, 0x04000100L, 0x00000000L, 0x04040001L, 0x00000101L, 0x04000001L, 0x00040101L, 0x00000100L, 0x04040000L, },{ /* nibble 3 */ 0x00401008L, 0x10001000L, 0x00000008L, 0x10401008L, 0x00000000L, 0x10400000L, 0x10001008L, 0x00400008L, 0x10401000L, 0x10000008L, 0x10000000L, 0x00001008L, 0x10000008L, 0x00401008L, 0x00400000L, 0x10000000L, 0x10400008L, 0x00401000L, 0x00001000L, 0x00000008L, 0x00401000L, 0x10001008L, 0x10400000L, 0x00001000L, 0x00001008L, 0x00000000L, 0x00400008L, 0x10401000L, 0x10001000L, 0x10400008L, 0x10401008L, 0x00400000L, 0x10400008L, 0x00001008L, 0x00400000L, 0x10000008L, 0x00401000L, 0x10001000L, 0x00000008L, 0x10400000L, 0x10001008L, 0x00000000L, 0x00001000L, 0x00400008L, 0x00000000L, 0x10400008L, 0x10401000L, 0x00001000L, 0x10000000L, 0x10401008L, 0x00401008L, 0x00400000L, 0x10401008L, 0x00000008L, 0x10001000L, 0x00401008L, 0x00400008L, 0x00401000L, 0x10400000L, 0x10001008L, 0x00001008L, 0x10000000L, 0x10000008L, 0x10401000L, },{ /* nibble 4 */ 0x08000000L, 0x00010000L, 0x00000400L, 0x08010420L, 0x08010020L, 0x08000400L, 0x00010420L, 0x08010000L, 0x00010000L, 0x00000020L, 0x08000020L, 0x00010400L, 0x08000420L, 0x08010020L, 0x08010400L, 0x00000000L, 0x00010400L, 0x08000000L, 0x00010020L, 0x00000420L, 0x08000400L, 0x00010420L, 0x00000000L, 0x08000020L, 0x00000020L, 0x08000420L, 0x08010420L, 0x00010020L, 0x08010000L, 0x00000400L, 0x00000420L, 0x08010400L, 0x08010400L, 0x08000420L, 0x00010020L, 0x08010000L, 0x00010000L, 0x00000020L, 0x08000020L, 0x08000400L, 0x08000000L, 0x00010400L, 0x08010420L, 0x00000000L, 0x00010420L, 0x08000000L, 0x00000400L, 0x00010020L, 0x08000420L, 0x00000400L, 0x00000000L, 0x08010420L, 0x08010020L, 0x08010400L, 0x00000420L, 0x00010000L, 0x00010400L, 0x08010020L, 0x08000400L, 0x00000420L, 0x00000020L, 0x00010420L, 0x08010000L, 0x08000020L, },{ /* nibble 5 */ 0x80000040L, 0x00200040L, 0x00000000L, 0x80202000L, 0x00200040L, 0x00002000L, 0x80002040L, 0x00200000L, 0x00002040L, 0x80202040L, 0x00202000L, 0x80000000L, 0x80002000L, 0x80000040L, 0x80200000L, 0x00202040L, 0x00200000L, 0x80002040L, 0x80200040L, 0x00000000L, 0x00002000L, 0x00000040L, 0x80202000L, 0x80200040L, 0x80202040L, 0x80200000L, 0x80000000L, 0x00002040L, 0x00000040L, 0x00202000L, 0x00202040L, 0x80002000L, 0x00002040L, 0x80000000L, 0x80002000L, 0x00202040L, 0x80202000L, 0x00200040L, 0x00000000L, 0x80002000L, 0x80000000L, 0x00002000L, 0x80200040L, 0x00200000L, 0x00200040L, 0x80202040L, 0x00202000L, 0x00000040L, 0x80202040L, 0x00202000L, 0x00200000L, 0x80002040L, 0x80000040L, 0x80200000L, 0x00202040L, 0x00000000L, 0x00002000L, 0x80000040L, 0x80002040L, 0x80202000L, 0x80200000L, 0x00002040L, 0x00000040L, 0x80200040L, },{ /* nibble 6 */ 0x00004000L, 0x00000200L, 0x01000200L, 0x01000004L, 0x01004204L, 0x00004004L, 0x00004200L, 0x00000000L, 0x01000000L, 0x01000204L, 0x00000204L, 0x01004000L, 0x00000004L, 0x01004200L, 0x01004000L, 0x00000204L, 0x01000204L, 0x00004000L, 0x00004004L, 0x01004204L, 0x00000000L, 0x01000200L, 0x01000004L, 0x00004200L, 0x01004004L, 0x00004204L, 0x01004200L, 0x00000004L, 0x00004204L, 0x01004004L, 0x00000200L, 0x01000000L, 0x00004204L, 0x01004000L, 0x01004004L, 0x00000204L, 0x00004000L, 0x00000200L, 0x01000000L, 0x01004004L, 0x01000204L, 0x00004204L, 0x00004200L, 0x00000000L, 0x00000200L, 0x01000004L, 0x00000004L, 0x01000200L, 0x00000000L, 0x01000204L, 0x01000200L, 0x00004200L, 0x00000204L, 0x00004000L, 0x01004204L, 0x01000000L, 0x01004200L, 0x00000004L, 0x00004004L, 0x01004204L, 0x01000004L, 0x01004200L, 0x01004000L, 0x00004004L, },{ /* nibble 7 */ 0x20800080L, 0x20820000L, 0x00020080L, 0x00000000L, 0x20020000L, 0x00800080L, 0x20800000L, 0x20820080L, 0x00000080L, 0x20000000L, 0x00820000L, 0x00020080L, 0x00820080L, 0x20020080L, 0x20000080L, 0x20800000L, 0x00020000L, 0x00820080L, 0x00800080L, 0x20020000L, 0x20820080L, 0x20000080L, 0x00000000L, 0x00820000L, 0x20000000L, 0x00800000L, 0x20020080L, 0x20800080L, 0x00800000L, 0x00020000L, 0x20820000L, 0x00000080L, 0x00800000L, 0x00020000L, 0x20000080L, 0x20820080L, 0x00020080L, 0x20000000L, 0x00000000L, 0x00820000L, 0x20800080L, 0x20020080L, 0x20020000L, 0x00800080L, 0x20820000L, 0x00000080L, 0x00800080L, 0x20020000L, 0x20820080L, 0x00800000L, 0x20800000L, 0x20000080L, 0x00820000L, 0x00020080L, 0x20020080L, 0x20800000L, 0x00000080L, 0x20820000L, 0x00820080L, 0x00000000L, 0x20000000L, 0x20800080L, 0x00020000L, 0x00820080L, }}; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/rand_key.c0000644000175000017500000000553212360020705020773 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include int DES_random_key(DES_cblock *ret) { do { if (RAND_bytes((unsigned char *)ret, sizeof(DES_cblock)) != 1) return (0); } while (DES_is_weak_key(ret)); DES_set_odd_parity(ret); return (1); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/ofb_enc.c0000644000175000017500000001130612360020705020566 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include "des_locl.h" /* The input and output are loaded in multiples of 8 bits. * What this means is that if you hame numbits=12 and length=2 * the first 12 bits will be retrieved from the first byte and half * the second. The second 12 bits will come from the 3rd and half the 4th * byte. */ void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, long length, DES_key_schedule *schedule, DES_cblock *ivec) { register DES_LONG d0,d1,vv0,vv1,v0,v1,n=(numbits+7)/8; register DES_LONG mask0,mask1; register long l=length; register int num=numbits; DES_LONG ti[2]; unsigned char *iv; if (num > 64) return; if (num > 32) { mask0=0xffffffffL; if (num >= 64) mask1=mask0; else mask1=(1L<<(num-32))-1; } else { if (num == 32) mask0=0xffffffffL; else mask0=(1L< 0) { ti[0]=v0; ti[1]=v1; DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); vv0=ti[0]; vv1=ti[1]; c2ln(in,d0,d1,n); in+=n; d0=(d0^vv0)&mask0; d1=(d1^vv1)&mask1; l2cn(d0,d1,out,n); out+=n; if (num == 32) { v0=v1; v1=vv0; } else if (num == 64) { v0=vv0; v1=vv1; } else if (num > 32) /* && num != 64 */ { v0=((v1>>(num-32))|(vv0<<(64-num)))&0xffffffffL; v1=((vv0>>(num-32))|(vv1<<(64-num)))&0xffffffffL; } else /* num < 32 */ { v0=((v0>>num)|(v1<<(32-num)))&0xffffffffL; v1=((v1>>num)|(vv0<<(32-num)))&0xffffffffL; } } iv = &(*ivec)[0]; l2c(v0,iv); l2c(v1,iv); v0=v1=d0=d1=ti[0]=ti[1]=vv0=vv1=0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/des/cbc_cksm.c0000644000175000017500000001027212360020705020740 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include "des_locl.h" DES_LONG DES_cbc_cksum(const unsigned char *in, DES_cblock *output, long length, DES_key_schedule *schedule, const_DES_cblock *ivec) { register DES_LONG tout0,tout1,tin0,tin1; register long l=length; DES_LONG tin[2]; unsigned char *out = &(*output)[0]; const unsigned char *iv = &(*ivec)[0]; c2l(iv,tout0); c2l(iv,tout1); for (; l>0; l-=8) { if (l >= 8) { c2l(in,tin0); c2l(in,tin1); } else c2ln(in,tin0,tin1,l); tin0^=tout0; tin[0]=tin0; tin1^=tout1; tin[1]=tin1; DES_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT); /* fix 15/10/91 eay - thanks to keithr@sco.COM */ tout0=tin[0]; tout1=tin[1]; } if (out != NULL) { l2c(tout0,out); l2c(tout1,out); } tout0=tin0=tin1=tin[0]=tin[1]=0; /* Transform the data in tout1 so that it will match the return value that the MIT Kerberos mit_des_cbc_cksum API returns. */ tout1 = ((tout1 >> 24L) & 0x000000FF) | ((tout1 >> 8L) & 0x0000FF00) | ((tout1 << 8L) & 0x00FF0000) | ((tout1 << 24L) & 0xFF000000); return(tout1); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/0000755000000000000000000000000012666635521020714 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_long.c0000644000175000017500000001350212360020705020550 0ustar /* $OpenBSD: x_long.c,v 1.8 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include /* Custom primitive type for long handling. This converts between an ASN1_INTEGER * and a long directly. */ static int long_new(ASN1_VALUE **pval, const ASN1_ITEM *it); static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it); static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx); static ASN1_PRIMITIVE_FUNCS long_pf = { NULL, 0, long_new, long_free, long_free, /* Clear should set to initial value */ long_c2i, long_i2c, long_print }; ASN1_ITEM_start(LONG) ASN1_ITYPE_PRIMITIVE, V_ASN1_INTEGER, NULL, 0, &long_pf, ASN1_LONG_UNDEF, "LONG" ASN1_ITEM_end(LONG) ASN1_ITEM_start(ZLONG) ASN1_ITYPE_PRIMITIVE, V_ASN1_INTEGER, NULL, 0, &long_pf, 0, "ZLONG" ASN1_ITEM_end(ZLONG) static int long_new(ASN1_VALUE **pval, const ASN1_ITEM *it) { *(long *)pval = it->size; return 1; } static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it) { *(long *)pval = it->size; } static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it) { long ltmp; unsigned long utmp; int clen, pad, i; /* this exists to bypass broken gcc optimization */ char *cp = (char *)pval; /* use memcpy, because we may not be long aligned */ memcpy(<mp, cp, sizeof(long)); if (ltmp == it->size) return -1; /* Convert the long to positive: we subtract one if negative so * we can cleanly handle the padding if only the MSB of the leading * octet is set. */ if (ltmp < 0) utmp = -ltmp - 1; else utmp = ltmp; clen = BN_num_bits_word(utmp); /* If MSB of leading octet set we need to pad */ if (!(clen & 0x7)) pad = 1; else pad = 0; /* Convert number of bits to number of octets */ clen = (clen + 7) >> 3; if (cont) { if (pad) *cont++ = (ltmp < 0) ? 0xff : 0; for (i = clen - 1; i >= 0; i--) { cont[i] = (unsigned char)(utmp & 0xff); if (ltmp < 0) cont[i] ^= 0xff; utmp >>= 8; } } return clen + pad; } static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it) { int neg, i; long ltmp; unsigned long utmp = 0; char *cp = (char *)pval; if (len > (int)sizeof(long)) { ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG); return 0; } /* Is it negative? */ if (len && (cont[0] & 0x80)) neg = 1; else neg = 0; utmp = 0; for (i = 0; i < len; i++) { utmp <<= 8; if (neg) utmp |= cont[i] ^ 0xff; else utmp |= cont[i]; } ltmp = (long)utmp; if (neg) { ltmp++; ltmp = -ltmp; } if (ltmp == it->size) { ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG); return 0; } memcpy(cp, <mp, sizeof(long)); return 1; } static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx) { return BIO_printf(out, "%ld\n", *(long *)pval); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_x509a.c0000644000175000017500000001360112360020705020457 0ustar /* $OpenBSD: x_x509a.c,v 1.9 2014/06/12 15:49:27 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include /* X509_CERT_AUX routines. These are used to encode additional * user modifiable data about a certificate. This data is * appended to the X509 encoding when the *_X509_AUX routines * are used. This means that the "traditional" X509 routines * will simply ignore the extra data. */ static X509_CERT_AUX *aux_get(X509 *x); ASN1_SEQUENCE(X509_CERT_AUX) = { ASN1_SEQUENCE_OF_OPT(X509_CERT_AUX, trust, ASN1_OBJECT), ASN1_IMP_SEQUENCE_OF_OPT(X509_CERT_AUX, reject, ASN1_OBJECT, 0), ASN1_OPT(X509_CERT_AUX, alias, ASN1_UTF8STRING), ASN1_OPT(X509_CERT_AUX, keyid, ASN1_OCTET_STRING), ASN1_IMP_SEQUENCE_OF_OPT(X509_CERT_AUX, other, X509_ALGOR, 1) } ASN1_SEQUENCE_END(X509_CERT_AUX) IMPLEMENT_ASN1_FUNCTIONS(X509_CERT_AUX) static X509_CERT_AUX * aux_get(X509 *x) { if (!x) return NULL; if (!x->aux && !(x->aux = X509_CERT_AUX_new())) return NULL; return x->aux; } int X509_alias_set1(X509 *x, unsigned char *name, int len) { X509_CERT_AUX *aux; if (!name) { if (!x || !x->aux || !x->aux->alias) return 1; ASN1_UTF8STRING_free(x->aux->alias); x->aux->alias = NULL; return 1; } if (!(aux = aux_get(x))) return 0; if (!aux->alias && !(aux->alias = ASN1_UTF8STRING_new())) return 0; return ASN1_STRING_set(aux->alias, name, len); } int X509_keyid_set1(X509 *x, unsigned char *id, int len) { X509_CERT_AUX *aux; if (!id) { if (!x || !x->aux || !x->aux->keyid) return 1; ASN1_OCTET_STRING_free(x->aux->keyid); x->aux->keyid = NULL; return 1; } if (!(aux = aux_get(x))) return 0; if (!aux->keyid && !(aux->keyid = ASN1_OCTET_STRING_new())) return 0; return ASN1_STRING_set(aux->keyid, id, len); } unsigned char * X509_alias_get0(X509 *x, int *len) { if (!x->aux || !x->aux->alias) return NULL; if (len) *len = x->aux->alias->length; return x->aux->alias->data; } unsigned char * X509_keyid_get0(X509 *x, int *len) { if (!x->aux || !x->aux->keyid) return NULL; if (len) *len = x->aux->keyid->length; return x->aux->keyid->data; } int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj) { X509_CERT_AUX *aux; ASN1_OBJECT *objtmp; if (!(objtmp = OBJ_dup(obj))) return 0; if (!(aux = aux_get(x))) return 0; if (!aux->trust && !(aux->trust = sk_ASN1_OBJECT_new_null())) return 0; return sk_ASN1_OBJECT_push(aux->trust, objtmp); } int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj) { X509_CERT_AUX *aux; ASN1_OBJECT *objtmp; if (!(objtmp = OBJ_dup(obj))) return 0; if (!(aux = aux_get(x))) return 0; if (!aux->reject && !(aux->reject = sk_ASN1_OBJECT_new_null())) return 0; return sk_ASN1_OBJECT_push(aux->reject, objtmp); } void X509_trust_clear(X509 *x) { if (x->aux && x->aux->trust) { sk_ASN1_OBJECT_pop_free(x->aux->trust, ASN1_OBJECT_free); x->aux->trust = NULL; } } void X509_reject_clear(X509 *x) { if (x->aux && x->aux->reject) { sk_ASN1_OBJECT_pop_free(x->aux->reject, ASN1_OBJECT_free); x->aux->reject = NULL; } } ASN1_SEQUENCE(X509_CERT_PAIR) = { ASN1_EXP_OPT(X509_CERT_PAIR, forward, X509, 0), ASN1_EXP_OPT(X509_CERT_PAIR, reverse, X509, 1) } ASN1_SEQUENCE_END(X509_CERT_PAIR) IMPLEMENT_ASN1_FUNCTIONS(X509_CERT_PAIR) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/i2d_pu.c0000644000175000017500000000764512360020705020457 0ustar /* $OpenBSD: i2d_pu.c,v 1.9 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #ifndef OPENSSL_NO_DSA #include #endif #ifndef OPENSSL_NO_EC #include #endif #ifndef OPENSSL_NO_RSA #include #endif int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp) { switch (a->type) { #ifndef OPENSSL_NO_RSA case EVP_PKEY_RSA: return (i2d_RSAPublicKey(a->pkey.rsa, pp)); #endif #ifndef OPENSSL_NO_DSA case EVP_PKEY_DSA: return (i2d_DSAPublicKey(a->pkey.dsa, pp)); #endif #ifndef OPENSSL_NO_EC case EVP_PKEY_EC: return (i2o_ECPublicKey(a->pkey.ec, pp)); #endif default: ASN1err(ASN1_F_I2D_PUBLICKEY, ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE); return (-1); } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_pkey.c0000644000175000017500000001263512360020705020567 0ustar /* $OpenBSD: x_pkey.c,v 1.13 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include /* need to implement */ int i2d_X509_PKEY(X509_PKEY *a, unsigned char **pp) { return (0); } X509_PKEY * d2i_X509_PKEY(X509_PKEY **a, const unsigned char **pp, long length) { int i; M_ASN1_D2I_vars(a, X509_PKEY *, X509_PKEY_new); M_ASN1_D2I_Init(); M_ASN1_D2I_start_sequence(); M_ASN1_D2I_get_x(X509_ALGOR, ret->enc_algor, d2i_X509_ALGOR); M_ASN1_D2I_get_x(ASN1_OCTET_STRING, ret->enc_pkey, d2i_ASN1_OCTET_STRING); ret->cipher.cipher = EVP_get_cipherbyname( OBJ_nid2ln(OBJ_obj2nid(ret->enc_algor->algorithm))); if (ret->cipher.cipher == NULL) { c.error = ASN1_R_UNSUPPORTED_CIPHER; c.line = __LINE__; goto err; } if (ret->enc_algor->parameter->type == V_ASN1_OCTET_STRING) { i = ret->enc_algor->parameter->value.octet_string->length; if (i > EVP_MAX_IV_LENGTH) { c.error = ASN1_R_IV_TOO_LARGE; c.line = __LINE__; goto err; } memcpy(ret->cipher.iv, ret->enc_algor->parameter->value.octet_string->data, i); } else memset(ret->cipher.iv, 0, EVP_MAX_IV_LENGTH); M_ASN1_D2I_Finish(a, X509_PKEY_free, ASN1_F_D2I_X509_PKEY); } X509_PKEY * X509_PKEY_new(void) { X509_PKEY *ret = NULL; if ((ret = malloc(sizeof(X509_PKEY))) == NULL) { ASN1_MAC_H_err(ASN1_F_X509_PKEY_NEW, ERR_R_MALLOC_FAILURE, __LINE__); return NULL; } ret->version = 0; if ((ret->enc_algor = X509_ALGOR_new()) == NULL) { free(ret); return NULL; } if ((ret->enc_pkey = M_ASN1_OCTET_STRING_new()) == NULL) { X509_ALGOR_free(ret->enc_algor); free(ret); return NULL; } ret->dec_pkey = NULL; ret->key_length = 0; ret->key_data = NULL; ret->key_free = 0; ret->cipher.cipher = NULL; memset(ret->cipher.iv, 0, EVP_MAX_IV_LENGTH); ret->references = 1; return (ret); } void X509_PKEY_free(X509_PKEY *x) { int i; if (x == NULL) return; i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_X509_PKEY); if (i > 0) return; if (x->enc_algor != NULL) X509_ALGOR_free(x->enc_algor); if (x->enc_pkey != NULL) M_ASN1_OCTET_STRING_free(x->enc_pkey); if (x->dec_pkey != NULL) EVP_PKEY_free(x->dec_pkey); if ((x->key_data != NULL) && (x->key_free)) free(x->key_data); free(x); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_enum.c0000644000175000017500000001276012360020705020533 0ustar /* $OpenBSD: a_enum.c,v 1.14 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include /* * Code for ENUMERATED type: identical to INTEGER apart from a different tag. * for comments on encoding see a_int.c */ int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v) { int j, k; unsigned int i; unsigned char buf[sizeof(long) + 1]; long d; a->type = V_ASN1_ENUMERATED; if (a->length < (int)(sizeof(long) + 1)) { free(a->data); a->data = calloc(1, sizeof(long) + 1); } if (a->data == NULL) { ASN1err(ASN1_F_ASN1_ENUMERATED_SET, ERR_R_MALLOC_FAILURE); return (0); } d = v; if (d < 0) { d = -d; a->type = V_ASN1_NEG_ENUMERATED; } for (i = 0; i < sizeof(long); i++) { if (d == 0) break; buf[i] = (int)d & 0xff; d >>= 8; } j = 0; for (k = i - 1; k >=0; k--) a->data[j++] = buf[k]; a->length = j; return (1); } long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a) { int neg = 0, i; long r = 0; if (a == NULL) return (0L); i = a->type; if (i == V_ASN1_NEG_ENUMERATED) neg = 1; else if (i != V_ASN1_ENUMERATED) return -1; if (a->length > (int)sizeof(long)) { /* hmm... a bit ugly */ return (0xffffffffL); } if (a->data == NULL) return 0; for (i = 0; i < a->length; i++) { r <<= 8; r |= (unsigned char)a->data[i]; } if (neg) r = -r; return (r); } ASN1_ENUMERATED * BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai) { ASN1_ENUMERATED *ret; int len, j; if (ai == NULL) ret = M_ASN1_ENUMERATED_new(); else ret = ai; if (ret == NULL) { ASN1err(ASN1_F_BN_TO_ASN1_ENUMERATED, ERR_R_NESTED_ASN1_ERROR); goto err; } if (BN_is_negative(bn)) ret->type = V_ASN1_NEG_ENUMERATED; else ret->type = V_ASN1_ENUMERATED; j = BN_num_bits(bn); len = ((j == 0) ? 0 : ((j / 8) + 1)); if (ret->length < len + 4) { unsigned char *new_data = realloc(ret->data, len + 4); if (!new_data) { ASN1err(ASN1_F_BN_TO_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE); goto err; } ret->data = new_data; } ret->length = BN_bn2bin(bn, ret->data); return (ret); err: if (ret != ai) M_ASN1_ENUMERATED_free(ret); return (NULL); } BIGNUM * ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn) { BIGNUM *ret; if ((ret = BN_bin2bn(ai->data, ai->length, bn)) == NULL) ASN1err(ASN1_F_ASN1_ENUMERATED_TO_BN, ASN1_R_BN_LIB); else if (ai->type == V_ASN1_NEG_ENUMERATED) BN_set_negative(ret, 1); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/f_enum.c0000644000175000017500000001352712360020705020542 0ustar /* $OpenBSD: f_enum.c,v 1.13 2014/07/10 21:58:08 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include /* Based on a_int.c: equivalent ENUMERATED functions */ int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a) { int i, n = 0; static const char h[] = "0123456789ABCDEF"; char buf[2]; if (a == NULL) return (0); if (a->length == 0) { if (BIO_write(bp, "00", 2) != 2) goto err; n = 2; } else { for (i = 0; i < a->length; i++) { if ((i != 0) && (i % 35 == 0)) { if (BIO_write(bp, "\\\n", 2) != 2) goto err; n += 2; } buf[0] = h[((unsigned char)a->data[i] >> 4) & 0x0f]; buf[1] = h[((unsigned char)a->data[i]) & 0x0f]; if (BIO_write(bp, buf, 2) != 2) goto err; n += 2; } } return (n); err: return (-1); } int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size) { int ret = 0; int i, j,k, m,n, again, bufsize; unsigned char *s = NULL, *sp; unsigned char *bufp; int first = 1; size_t num = 0, slen = 0; bs->type = V_ASN1_ENUMERATED; bufsize = BIO_gets(bp, buf, size); for (;;) { if (bufsize < 1) goto err_sl; i = bufsize; if (buf[i-1] == '\n') buf[--i] = '\0'; if (i == 0) goto err_sl; if (buf[i-1] == '\r') buf[--i] = '\0'; if (i == 0) goto err_sl; again = (buf[i - 1] == '\\'); for (j = 0; j < i; j++) { if (!(((buf[j] >= '0') && (buf[j] <= '9')) || ((buf[j] >= 'a') && (buf[j] <= 'f')) || ((buf[j] >= 'A') && (buf[j] <= 'F')))) { i = j; break; } } buf[i] = '\0'; /* We have now cleared all the crap off the end of the * line */ if (i < 2) goto err_sl; bufp = (unsigned char *)buf; if (first) { first = 0; if ((bufp[0] == '0') && (buf[1] == '0')) { bufp += 2; i -= 2; } } k = 0; i -= again; if (i % 2 != 0) { ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ASN1_R_ODD_NUMBER_OF_CHARS); goto err; } i /= 2; if (num + i > slen) { sp = realloc(s, num + i); if (sp == NULL) { ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE); goto err; } s = sp; slen = num + i; } for (j = 0; j < i; j++, k += 2) { for (n = 0; n < 2; n++) { m = bufp[k + n]; if ((m >= '0') && (m <= '9')) m -= '0'; else if ((m >= 'a') && (m <= 'f')) m = m - 'a' + 10; else if ((m >= 'A') && (m <= 'F')) m = m - 'A' + 10; else { ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ASN1_R_NON_HEX_CHARACTERS); goto err; } s[num + j] <<= 4; s[num + j] |= m; } } num += i; if (again) bufsize = BIO_gets(bp, buf, size); else break; } bs->length = num; bs->data = s; return (1); err_sl: ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ASN1_R_SHORT_LINE); err: free(s); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/nsseq.c0000644000175000017500000000663412360020705020423 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include static int nsseq_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { if (operation == ASN1_OP_NEW_POST) { NETSCAPE_CERT_SEQUENCE *nsseq; nsseq = (NETSCAPE_CERT_SEQUENCE *)*pval; nsseq->type = OBJ_nid2obj(NID_netscape_cert_sequence); } return 1; } /* Netscape certificate sequence structure */ ASN1_SEQUENCE_cb(NETSCAPE_CERT_SEQUENCE, nsseq_cb) = { ASN1_SIMPLE(NETSCAPE_CERT_SEQUENCE, type, ASN1_OBJECT), ASN1_EXP_SEQUENCE_OF_OPT(NETSCAPE_CERT_SEQUENCE, certs, X509, 0) } ASN1_SEQUENCE_END_cb(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE) IMPLEMENT_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_time.c0000644000175000017500000001342112360020705020520 0ustar /* $OpenBSD: a_time.c,v 1.20 2014/07/10 13:58:22 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* This is an implementation of the ASN1 Time structure which is: * Time ::= CHOICE { * utcTime UTCTime, * generalTime GeneralizedTime } * written by Steve Henson. */ #include #include #include #include #include #include "o_time.h" IMPLEMENT_ASN1_MSTRING(ASN1_TIME, B_ASN1_TIME) IMPLEMENT_ASN1_FUNCTIONS(ASN1_TIME) #if 0 int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **pp) { if (a->type == V_ASN1_UTCTIME || a->type == V_ASN1_GENERALIZEDTIME) return(i2d_ASN1_bytes((ASN1_STRING *)a, pp, a->type, V_ASN1_UNIVERSAL)); ASN1err(ASN1_F_I2D_ASN1_TIME, ASN1_R_EXPECTING_A_TIME); return -1; } #endif ASN1_TIME * ASN1_TIME_set(ASN1_TIME *s, time_t t) { return ASN1_TIME_adj(s, t, 0, 0); } ASN1_TIME * ASN1_TIME_adj(ASN1_TIME *s, time_t t, int offset_day, long offset_sec) { struct tm *ts; struct tm data; ts = gmtime_r(&t, &data); if (ts == NULL) { ASN1err(ASN1_F_ASN1_TIME_ADJ, ASN1_R_ERROR_GETTING_TIME); return NULL; } if (offset_day || offset_sec) { if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec)) return NULL; } if ((ts->tm_year >= 50) && (ts->tm_year < 150)) return ASN1_UTCTIME_adj(s, t, offset_day, offset_sec); return ASN1_GENERALIZEDTIME_adj(s, t, offset_day, offset_sec); } int ASN1_TIME_check(ASN1_TIME *t) { if (t->type == V_ASN1_GENERALIZEDTIME) return ASN1_GENERALIZEDTIME_check(t); else if (t->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_check(t); return 0; } /* Convert an ASN1_TIME structure to GeneralizedTime */ static ASN1_GENERALIZEDTIME * ASN1_TIME_to_generalizedtime_internal(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out) { ASN1_GENERALIZEDTIME *ret; char *str; int newlen; int i; if (!ASN1_TIME_check(t)) return NULL; ret = *out; /* If already GeneralizedTime just copy across */ if (t->type == V_ASN1_GENERALIZEDTIME) { if (!ASN1_STRING_set(ret, t->data, t->length)) return NULL; return ret; } /* grow the string */ if (!ASN1_STRING_set(ret, NULL, t->length + 2)) return NULL; /* ASN1_STRING_set() allocated 'len + 1' bytes. */ newlen = t->length + 2 + 1; str = (char *)ret->data; /* XXX ASN1_TIME is not Y2050 compatible */ i = snprintf(str, newlen, "%s%s", (t->data[0] >= '5') ? "19" : "20", (char *) t->data); if (i == -1 || i >= newlen) { M_ASN1_GENERALIZEDTIME_free(ret); *out = NULL; return NULL; } return ret; } ASN1_GENERALIZEDTIME * ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out) { ASN1_GENERALIZEDTIME *tmp = NULL, *ret; if (!out || !*out) { if (!(tmp = ASN1_GENERALIZEDTIME_new())) return NULL; if (out != NULL) *out = tmp; else out = &tmp; } ret = ASN1_TIME_to_generalizedtime_internal(t, out); if (ret == NULL && tmp != NULL) ASN1_GENERALIZEDTIME_free(tmp); return ret; } int ASN1_TIME_set_string(ASN1_TIME *s, const char *str) { ASN1_TIME t; t.length = strlen(str); t.data = (unsigned char *)str; t.flags = 0; t.type = V_ASN1_UTCTIME; if (!ASN1_TIME_check(&t)) { t.type = V_ASN1_GENERALIZEDTIME; if (!ASN1_TIME_check(&t)) return 0; } if (s && !ASN1_STRING_copy((ASN1_STRING *)s, (ASN1_STRING *)&t)) return 0; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/t_pkey.c0000644000175000017500000001043712360020705020561 0ustar /* $OpenBSD: t_pkey.c,v 1.15 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, unsigned char *buf, int off) { int n, i; const char *neg; if (num == NULL) return (1); neg = (BN_is_negative(num)) ? "-" : ""; if (!BIO_indent(bp, off, 128)) return 0; if (BN_is_zero(num)) { if (BIO_printf(bp, "%s 0\n", number) <= 0) return 0; return 1; } if (BN_num_bytes(num) <= BN_BYTES) { if (BIO_printf(bp, "%s %s%lu (%s0x%lx)\n", number, neg, (unsigned long)num->d[0], neg, (unsigned long)num->d[0]) <= 0) return (0); } else { buf[0] = 0; if (BIO_printf(bp, "%s%s", number, (neg[0] == '-') ? " (Negative)" : "") <= 0) return (0); n = BN_bn2bin(num, &buf[1]); if (buf[1] & 0x80) n++; else buf++; for (i = 0; i < n; i++) { if ((i % 15) == 0) { if (BIO_puts(bp, "\n") <= 0 || !BIO_indent(bp, off + 4, 128)) return 0; } if (BIO_printf(bp, "%02x%s", buf[i], ((i + 1) == n) ? "" : ":") <= 0) return (0); } if (BIO_write(bp, "\n", 1) <= 0) return (0); } return (1); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/n_pkey.c0000644000175000017500000002463412360020705020557 0ustar /* $OpenBSD: n_pkey.c,v 1.20 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #ifndef OPENSSL_NO_RSA #include #include #include #include #include #include #include #ifndef OPENSSL_NO_RC4 typedef struct netscape_pkey_st { long version; X509_ALGOR *algor; ASN1_OCTET_STRING *private_key; } NETSCAPE_PKEY; typedef struct netscape_encrypted_pkey_st { ASN1_OCTET_STRING *os; /* This is the same structure as DigestInfo so use it: * although this isn't really anything to do with * digests. */ X509_SIG *enckey; } NETSCAPE_ENCRYPTED_PKEY; ASN1_BROKEN_SEQUENCE(NETSCAPE_ENCRYPTED_PKEY) = { ASN1_SIMPLE(NETSCAPE_ENCRYPTED_PKEY, os, ASN1_OCTET_STRING), ASN1_SIMPLE(NETSCAPE_ENCRYPTED_PKEY, enckey, X509_SIG) } ASN1_BROKEN_SEQUENCE_END(NETSCAPE_ENCRYPTED_PKEY) DECLARE_ASN1_FUNCTIONS_const(NETSCAPE_ENCRYPTED_PKEY) DECLARE_ASN1_ENCODE_FUNCTIONS_const(NETSCAPE_ENCRYPTED_PKEY, NETSCAPE_ENCRYPTED_PKEY) IMPLEMENT_ASN1_FUNCTIONS_const(NETSCAPE_ENCRYPTED_PKEY) ASN1_SEQUENCE(NETSCAPE_PKEY) = { ASN1_SIMPLE(NETSCAPE_PKEY, version, LONG), ASN1_SIMPLE(NETSCAPE_PKEY, algor, X509_ALGOR), ASN1_SIMPLE(NETSCAPE_PKEY, private_key, ASN1_OCTET_STRING) } ASN1_SEQUENCE_END(NETSCAPE_PKEY) DECLARE_ASN1_FUNCTIONS_const(NETSCAPE_PKEY) DECLARE_ASN1_ENCODE_FUNCTIONS_const(NETSCAPE_PKEY, NETSCAPE_PKEY) IMPLEMENT_ASN1_FUNCTIONS_const(NETSCAPE_PKEY) static RSA *d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os, int (*cb)(char *buf, int len, const char *prompt, int verify), int sgckey); int i2d_Netscape_RSA(const RSA *a, unsigned char **pp, int (*cb)(char *buf, int len, const char *prompt, int verify)) { return i2d_RSA_NET(a, pp, cb, 0); } int i2d_RSA_NET(const RSA *a, unsigned char **pp, int (*cb)(char *buf, int len, const char *prompt, int verify), int sgckey) { int i, j, ret = 0; int rsalen, pkeylen, olen; NETSCAPE_PKEY *pkey = NULL; NETSCAPE_ENCRYPTED_PKEY *enckey = NULL; unsigned char buf[256], *zz; unsigned char key[EVP_MAX_KEY_LENGTH]; EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX_init(&ctx); if (a == NULL) return (0); if ((pkey = NETSCAPE_PKEY_new()) == NULL) goto err; if ((enckey = NETSCAPE_ENCRYPTED_PKEY_new()) == NULL) goto err; pkey->version = 0; pkey->algor->algorithm = OBJ_nid2obj(NID_rsaEncryption); if ((pkey->algor->parameter = ASN1_TYPE_new()) == NULL) goto err; pkey->algor->parameter->type = V_ASN1_NULL; rsalen = i2d_RSAPrivateKey(a, NULL); /* Fake some octet strings just for the initial length * calculation. */ pkey->private_key->length = rsalen; pkeylen = i2d_NETSCAPE_PKEY(pkey, NULL); enckey->enckey->digest->length = pkeylen; enckey->os->length = 11; /* "private-key" */ enckey->enckey->algor->algorithm = OBJ_nid2obj(NID_rc4); if ((enckey->enckey->algor->parameter = ASN1_TYPE_new()) == NULL) goto err; enckey->enckey->algor->parameter->type = V_ASN1_NULL; if (pp == NULL) { olen = i2d_NETSCAPE_ENCRYPTED_PKEY(enckey, NULL); NETSCAPE_PKEY_free(pkey); NETSCAPE_ENCRYPTED_PKEY_free(enckey); return olen; } /* Since its RC4 encrypted length is actual length */ if ((zz = malloc(rsalen)) == NULL) { ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE); goto err; } pkey->private_key->data = zz; /* Write out private key encoding */ i2d_RSAPrivateKey(a, &zz); if ((zz = malloc(pkeylen)) == NULL) { ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE); goto err; } if (!ASN1_STRING_set(enckey->os, "private-key", -1)) { ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE); goto err; } enckey->enckey->digest->data = zz; i2d_NETSCAPE_PKEY(pkey, &zz); /* Wipe the private key encoding */ OPENSSL_cleanse(pkey->private_key->data, rsalen); if (cb == NULL) cb = EVP_read_pw_string; i = cb((char *)buf, sizeof(buf), "Enter Private Key password:", 1); if (i != 0) { ASN1err(ASN1_F_I2D_RSA_NET, ASN1_R_BAD_PASSWORD_READ); goto err; } i = strlen((char *)buf); /* If the key is used for SGC the algorithm is modified a little. */ if (sgckey) { if (!EVP_Digest(buf, i, buf, NULL, EVP_md5(), NULL)) goto err; memcpy(buf + 16, "SGCKEYSALT", 10); i = 26; } if (!EVP_BytesToKey(EVP_rc4(), EVP_md5(), NULL, buf, i,1, key, NULL)) goto err; OPENSSL_cleanse(buf, sizeof(buf)); /* Encrypt private key in place */ zz = enckey->enckey->digest->data; if (!EVP_EncryptInit_ex(&ctx, EVP_rc4(), NULL, key, NULL)) goto err; if (!EVP_EncryptUpdate(&ctx, zz, &i, zz, pkeylen)) goto err; if (!EVP_EncryptFinal_ex(&ctx, zz + i, &j)) goto err; ret = i2d_NETSCAPE_ENCRYPTED_PKEY(enckey, pp); err: EVP_CIPHER_CTX_cleanup(&ctx); NETSCAPE_ENCRYPTED_PKEY_free(enckey); NETSCAPE_PKEY_free(pkey); return (ret); } RSA * d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length, int (*cb)(char *buf, int len, const char *prompt, int verify)) { return d2i_RSA_NET(a, pp, length, cb, 0); } RSA * d2i_RSA_NET(RSA **a, const unsigned char **pp, long length, int (*cb)(char *buf, int len, const char *prompt, int verify), int sgckey) { RSA *ret = NULL; const unsigned char *p; NETSCAPE_ENCRYPTED_PKEY *enckey = NULL; p = *pp; enckey = d2i_NETSCAPE_ENCRYPTED_PKEY(NULL, &p, length); if (!enckey) { ASN1err(ASN1_F_D2I_RSA_NET, ASN1_R_DECODING_ERROR); return NULL; } if ((enckey->os->length != 11) || (strncmp("private-key", (char *)enckey->os->data, 11) != 0)) { ASN1err(ASN1_F_D2I_RSA_NET, ASN1_R_PRIVATE_KEY_HEADER_MISSING); NETSCAPE_ENCRYPTED_PKEY_free(enckey); return NULL; } if (OBJ_obj2nid(enckey->enckey->algor->algorithm) != NID_rc4) { ASN1err(ASN1_F_D2I_RSA_NET, ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM); goto err; } if (cb == NULL) cb = EVP_read_pw_string; if ((ret = d2i_RSA_NET_2(a, enckey->enckey->digest, cb, sgckey)) == NULL) goto err; *pp = p; err: NETSCAPE_ENCRYPTED_PKEY_free(enckey); return ret; } static RSA * d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os, int (*cb)(char *buf, int len, const char *prompt, int verify), int sgckey) { NETSCAPE_PKEY *pkey = NULL; RSA *ret = NULL; int i, j; unsigned char buf[256]; const unsigned char *zz; unsigned char key[EVP_MAX_KEY_LENGTH]; EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX_init(&ctx); i=cb((char *)buf, sizeof(buf), "Enter Private Key password:",0); if (i != 0) { ASN1err(ASN1_F_D2I_RSA_NET_2, ASN1_R_BAD_PASSWORD_READ); goto err; } i = strlen((char *)buf); if (sgckey){ if (!EVP_Digest(buf, i, buf, NULL, EVP_md5(), NULL)) goto err; memcpy(buf + 16, "SGCKEYSALT", 10); i = 26; } if (!EVP_BytesToKey(EVP_rc4(), EVP_md5(), NULL, buf, i,1, key, NULL)) goto err; OPENSSL_cleanse(buf, sizeof(buf)); if (!EVP_DecryptInit_ex(&ctx, EVP_rc4(), NULL, key, NULL)) goto err; if (!EVP_DecryptUpdate(&ctx, os->data, &i, os->data, os->length)) goto err; if (!EVP_DecryptFinal_ex(&ctx, &(os->data[i]), &j)) goto err; os->length = i + j; zz = os->data; if ((pkey = d2i_NETSCAPE_PKEY(NULL, &zz, os->length)) == NULL) { ASN1err(ASN1_F_D2I_RSA_NET_2, ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY); goto err; } zz = pkey->private_key->data; if ((ret = d2i_RSAPrivateKey(a, &zz, pkey->private_key->length)) == NULL) { ASN1err(ASN1_F_D2I_RSA_NET_2, ASN1_R_UNABLE_TO_DECODE_RSA_KEY); goto err; } err: EVP_CIPHER_CTX_cleanup(&ctx); NETSCAPE_PKEY_free(pkey); return (ret); } #endif /* OPENSSL_NO_RC4 */ #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/asn_pack.c0000644000175000017500000001376712360020705021056 0ustar /* $OpenBSD: asn_pack.c,v 1.13 2014/07/11 08:44:47 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #ifndef NO_ASN1_OLD /* ASN1 packing and unpacking functions */ /* Turn an ASN1 encoded SEQUENCE OF into a STACK of structures */ STACK_OF(OPENSSL_BLOCK) * ASN1_seq_unpack(const unsigned char *buf, int len, d2i_of_void *d2i, void (*free_func)(OPENSSL_BLOCK)) { STACK_OF(OPENSSL_BLOCK) *sk; const unsigned char *pbuf; pbuf = buf; if (!(sk = d2i_ASN1_SET(NULL, &pbuf, len, d2i, free_func, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL))) ASN1err(ASN1_F_ASN1_SEQ_UNPACK,ASN1_R_DECODE_ERROR); return sk; } /* Turn a STACK structures into an ASN1 encoded SEQUENCE OF structure in a * OPENSSL_malloc'ed buffer */ unsigned char * ASN1_seq_pack(STACK_OF(OPENSSL_BLOCK) *safes, i2d_of_void *i2d, unsigned char **buf, int *len) { int safelen; unsigned char *safe, *p; if (!(safelen = i2d_ASN1_SET(safes, NULL, i2d, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, IS_SEQUENCE))) { ASN1err(ASN1_F_ASN1_SEQ_PACK,ASN1_R_ENCODE_ERROR); return NULL; } if (!(safe = malloc(safelen))) { ASN1err(ASN1_F_ASN1_SEQ_PACK,ERR_R_MALLOC_FAILURE); return NULL; } p = safe; i2d_ASN1_SET(safes, &p, i2d, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, IS_SEQUENCE); if (len) *len = safelen; if (buf) *buf = safe; return safe; } /* Extract an ASN1 object from an ASN1_STRING */ void * ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i) { const unsigned char *p; char *ret; p = oct->data; if (!(ret = d2i(NULL, &p, oct->length))) ASN1err(ASN1_F_ASN1_UNPACK_STRING,ASN1_R_DECODE_ERROR); return ret; } /* Pack an ASN1 object into an ASN1_STRING */ ASN1_STRING * ASN1_pack_string(void *obj, i2d_of_void *i2d, ASN1_STRING **oct) { unsigned char *p; ASN1_STRING *octmp; if (!oct || !*oct) { if (!(octmp = ASN1_STRING_new())) { ASN1err(ASN1_F_ASN1_PACK_STRING,ERR_R_MALLOC_FAILURE); return NULL; } } else octmp = *oct; if (!(octmp->length = i2d(obj, NULL))) { ASN1err(ASN1_F_ASN1_PACK_STRING,ASN1_R_ENCODE_ERROR); goto err; } if (!(p = malloc (octmp->length))) { ASN1err(ASN1_F_ASN1_PACK_STRING,ERR_R_MALLOC_FAILURE); goto err; } octmp->data = p; i2d (obj, &p); if (oct) *oct = octmp; return octmp; err: if (!oct || octmp != *oct) { ASN1_STRING_free(octmp); if (oct) *oct = NULL; } return NULL; } #endif /* ASN1_ITEM versions of the above */ ASN1_STRING * ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct) { ASN1_STRING *octmp; if (!oct || !*oct) { if (!(octmp = ASN1_STRING_new ())) { ASN1err(ASN1_F_ASN1_ITEM_PACK, ERR_R_MALLOC_FAILURE); return NULL; } } else octmp = *oct; if (octmp->data) { free(octmp->data); octmp->data = NULL; } if (!(octmp->length = ASN1_item_i2d(obj, &octmp->data, it))) { ASN1err(ASN1_F_ASN1_ITEM_PACK, ASN1_R_ENCODE_ERROR); goto err; } if (!octmp->data) { ASN1err(ASN1_F_ASN1_ITEM_PACK, ERR_R_MALLOC_FAILURE); goto err; } if (oct) *oct = octmp; return octmp; err: if (!oct || octmp != *oct) ASN1_STRING_free(octmp); return NULL; } /* Extract an ASN1 object from an ASN1_STRING */ void * ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it) { const unsigned char *p; void *ret; p = oct->data; if (!(ret = ASN1_item_d2i(NULL, &p, oct->length, it))) ASN1err(ASN1_F_ASN1_ITEM_UNPACK, ASN1_R_DECODE_ERROR); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_type.c0000644000175000017500000001224012360020705020541 0ustar /* $OpenBSD: a_type.c,v 1.13 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include int ASN1_TYPE_get(ASN1_TYPE *a) { if ((a->value.ptr != NULL) || (a->type == V_ASN1_NULL)) return (a->type); else return (0); } void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value) { if (a->value.ptr != NULL) { ASN1_TYPE **tmp_a = &a; ASN1_primitive_free((ASN1_VALUE **)tmp_a, NULL); } a->type = type; if (type == V_ASN1_BOOLEAN) a->value.boolean = value ? 0xff : 0; else a->value.ptr = value; } int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value) { if (!value || (type == V_ASN1_BOOLEAN)) { void *p = (void *)value; ASN1_TYPE_set(a, type, p); } else if (type == V_ASN1_OBJECT) { ASN1_OBJECT *odup; odup = OBJ_dup(value); if (!odup) return 0; ASN1_TYPE_set(a, type, odup); } else { ASN1_STRING *sdup; sdup = ASN1_STRING_dup(value); if (!sdup) return 0; ASN1_TYPE_set(a, type, sdup); } return 1; } IMPLEMENT_STACK_OF(ASN1_TYPE) IMPLEMENT_ASN1_SET_OF(ASN1_TYPE) /* Returns 0 if they are equal, != 0 otherwise. */ int ASN1_TYPE_cmp(ASN1_TYPE *a, ASN1_TYPE *b) { int result = -1; if (!a || !b || a->type != b->type) return -1; switch (a->type) { case V_ASN1_OBJECT: result = OBJ_cmp(a->value.object, b->value.object); break; case V_ASN1_NULL: result = 0; /* They do not have content. */ break; case V_ASN1_INTEGER: case V_ASN1_NEG_INTEGER: case V_ASN1_ENUMERATED: case V_ASN1_NEG_ENUMERATED: case V_ASN1_BIT_STRING: case V_ASN1_OCTET_STRING: case V_ASN1_SEQUENCE: case V_ASN1_SET: case V_ASN1_NUMERICSTRING: case V_ASN1_PRINTABLESTRING: case V_ASN1_T61STRING: case V_ASN1_VIDEOTEXSTRING: case V_ASN1_IA5STRING: case V_ASN1_UTCTIME: case V_ASN1_GENERALIZEDTIME: case V_ASN1_GRAPHICSTRING: case V_ASN1_VISIBLESTRING: case V_ASN1_GENERALSTRING: case V_ASN1_UNIVERSALSTRING: case V_ASN1_BMPSTRING: case V_ASN1_UTF8STRING: case V_ASN1_OTHER: default: result = ASN1_STRING_cmp((ASN1_STRING *)a->value.ptr, (ASN1_STRING *)b->value.ptr); break; } return result; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/tasn_utl.c0000644000175000017500000001652712360020705021125 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000-2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include /* Utility functions for manipulating fields and offsets */ /* Add 'offset' to 'addr' */ #define offset2ptr(addr, offset) (void *)(((char *) addr) + offset) /* Given an ASN1_ITEM CHOICE type return * the selector value */ int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it) { int *sel = offset2ptr(*pval, it->utype); return *sel; } /* Given an ASN1_ITEM CHOICE type set * the selector value, return old value. */ int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it) { int *sel, ret; sel = offset2ptr(*pval, it->utype); ret = *sel; *sel = value; return ret; } /* Do reference counting. The value 'op' decides what to do. * if it is +1 then the count is incremented. If op is 0 count is * set to 1. If op is -1 count is decremented and the return value * is the current refrence count or 0 if no reference count exists. */ int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it) { const ASN1_AUX *aux; int *lck, ret; if ((it->itype != ASN1_ITYPE_SEQUENCE) && (it->itype != ASN1_ITYPE_NDEF_SEQUENCE)) return 0; aux = it->funcs; if (!aux || !(aux->flags & ASN1_AFLG_REFCOUNT)) return 0; lck = offset2ptr(*pval, aux->ref_offset); if (op == 0) { *lck = 1; return 1; } ret = CRYPTO_add(lck, op, aux->ref_lock); return ret; } static ASN1_ENCODING * asn1_get_enc_ptr(ASN1_VALUE **pval, const ASN1_ITEM *it) { const ASN1_AUX *aux; if (!pval || !*pval) return NULL; aux = it->funcs; if (!aux || !(aux->flags & ASN1_AFLG_ENCODING)) return NULL; return offset2ptr(*pval, aux->enc_offset); } void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it) { ASN1_ENCODING *enc; enc = asn1_get_enc_ptr(pval, it); if (enc) { enc->enc = NULL; enc->len = 0; enc->modified = 1; } } void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it) { ASN1_ENCODING *enc; enc = asn1_get_enc_ptr(pval, it); if (enc) { free(enc->enc); enc->enc = NULL; enc->len = 0; enc->modified = 1; } } int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, const ASN1_ITEM *it) { ASN1_ENCODING *enc; enc = asn1_get_enc_ptr(pval, it); if (!enc) return 1; free(enc->enc); enc->enc = malloc(inlen); if (!enc->enc) return 0; memcpy(enc->enc, in, inlen); enc->len = inlen; enc->modified = 0; return 1; } int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, const ASN1_ITEM *it) { ASN1_ENCODING *enc; enc = asn1_get_enc_ptr(pval, it); if (!enc || enc->modified) return 0; if (out) { memcpy(*out, enc->enc, enc->len); *out += enc->len; } if (len) *len = enc->len; return 1; } /* Given an ASN1_TEMPLATE get a pointer to a field */ ASN1_VALUE ** asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) { ASN1_VALUE **pvaltmp; if (tt->flags & ASN1_TFLG_COMBINE) return pval; pvaltmp = offset2ptr(*pval, tt->offset); /* NOTE for BOOLEAN types the field is just a plain * int so we can't return int **, so settle for * (int *). */ return pvaltmp; } /* Handle ANY DEFINED BY template, find the selector, look up * the relevant ASN1_TEMPLATE in the table and return it. */ const ASN1_TEMPLATE * asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, int nullerr) { const ASN1_ADB *adb; const ASN1_ADB_TABLE *atbl; long selector; ASN1_VALUE **sfld; int i; if (!(tt->flags & ASN1_TFLG_ADB_MASK)) return tt; /* Else ANY DEFINED BY ... get the table */ adb = ASN1_ADB_ptr(tt->item); /* Get the selector field */ sfld = offset2ptr(*pval, adb->offset); /* Check if NULL */ if (!sfld) { if (!adb->null_tt) goto err; return adb->null_tt; } /* Convert type to a long: * NB: don't check for NID_undef here because it * might be a legitimate value in the table */ if (tt->flags & ASN1_TFLG_ADB_OID) selector = OBJ_obj2nid((ASN1_OBJECT *)*sfld); else selector = ASN1_INTEGER_get((ASN1_INTEGER *)*sfld); /* Try to find matching entry in table * Maybe should check application types first to * allow application override? Might also be useful * to have a flag which indicates table is sorted and * we can do a binary search. For now stick to a * linear search. */ for (atbl = adb->tbl, i = 0; i < adb->tblcount; i++, atbl++) if (atbl->value == selector) return &atbl->tt; /* FIXME: need to search application table too */ /* No match, return default type */ if (!adb->default_tt) goto err; return adb->default_tt; err: /* FIXME: should log the value or OID of unsupported type */ if (nullerr) ASN1err(ASN1_F_ASN1_DO_ADB, ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE); return NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/asn1_par.c0000644000175000017500000002705412360020705020775 0ustar /* $OpenBSD: asn1_par.c,v 1.18 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed, int indent); static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, int offset, int depth, int indent, int dump); static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed, int indent) { static const char fmt[] = "%-18s"; char str[128]; const char *p; if (constructed & V_ASN1_CONSTRUCTED) p="cons: "; else p="prim: "; if (BIO_write(bp, p, 6) < 6) goto err; BIO_indent(bp, indent, 128); p = str; if ((xclass & V_ASN1_PRIVATE) == V_ASN1_PRIVATE) snprintf(str, sizeof str, "priv [ %d ] ", tag); else if ((xclass & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC) snprintf(str, sizeof str, "cont [ %d ]", tag); else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION) snprintf(str, sizeof str, "appl [ %d ]", tag); else if (tag > 30) snprintf(str, sizeof str, "", tag); else p = ASN1_tag2str(tag); if (BIO_printf(bp, fmt, p) <= 0) goto err; return (1); err: return (0); } int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent) { return (asn1_parse2(bp, &pp, len, 0, 0, indent, 0)); } int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent, int dump) { return (asn1_parse2(bp, &pp, len, 0, 0, indent, dump)); } static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, int offset, int depth, int indent, int dump) { const unsigned char *p, *ep, *tot, *op, *opp; long len; int tag, xclass, ret = 0; int nl, hl, j, r; ASN1_OBJECT *o = NULL; ASN1_OCTET_STRING *os = NULL; /* ASN1_BMPSTRING *bmp=NULL;*/ int dump_indent; #if 0 dump_indent = indent; #else dump_indent = 6; /* Because we know BIO_dump_indent() */ #endif p = *pp; tot = p + length; op = p - 1; while ((p < tot) && (op < p)) { op = p; j = ASN1_get_object(&p, &len, &tag, &xclass, length); if (j & 0x80) { if (BIO_write(bp, "Error in encoding\n", 18) <= 0) goto end; ret = 0; goto end; } hl = (p - op); length -= hl; /* if j == 0x21 it is a constructed indefinite length object */ if (BIO_printf(bp, "%5ld:", (long)offset + (long)(op - *pp)) <= 0) goto end; if (j != (V_ASN1_CONSTRUCTED | 1)) { if (BIO_printf(bp, "d=%-2d hl=%ld l=%4ld ", depth, (long)hl, len) <= 0) goto end; } else { if (BIO_printf(bp, "d=%-2d hl=%ld l=inf ", depth, (long)hl) <= 0) goto end; } if (!asn1_print_info(bp, tag, xclass, j, (indent) ? depth : 0)) goto end; if (j & V_ASN1_CONSTRUCTED) { ep = p + len; if (BIO_write(bp, "\n", 1) <= 0) goto end; if (len > length) { BIO_printf(bp, "length is greater than %ld\n", length); ret = 0; goto end; } if ((j == 0x21) && (len == 0)) { for (;;) { r = asn1_parse2(bp, &p, (long)(tot - p), offset + (p - *pp), depth + 1, indent, dump); if (r == 0) { ret = 0; goto end; } if ((r == 2) || (p >= tot)) break; } } else while (p < ep) { r = asn1_parse2(bp, &p, (long)len, offset + (p - *pp), depth + 1, indent, dump); if (r == 0) { ret = 0; goto end; } } } else if (xclass != 0) { p += len; if (BIO_write(bp, "\n", 1) <= 0) goto end; } else { nl = 0; if ((tag == V_ASN1_PRINTABLESTRING) || (tag == V_ASN1_T61STRING) || (tag == V_ASN1_IA5STRING) || (tag == V_ASN1_VISIBLESTRING) || (tag == V_ASN1_NUMERICSTRING) || (tag == V_ASN1_UTF8STRING) || (tag == V_ASN1_UTCTIME) || (tag == V_ASN1_GENERALIZEDTIME)) { if (BIO_write(bp, ":", 1) <= 0) goto end; if ((len > 0) && BIO_write(bp, (const char *)p, (int)len) != (int)len) goto end; } else if (tag == V_ASN1_OBJECT) { opp = op; if (d2i_ASN1_OBJECT(&o, &opp, len + hl) != NULL) { if (BIO_write(bp, ":", 1) <= 0) goto end; i2a_ASN1_OBJECT(bp, o); } else { if (BIO_write(bp, ":BAD OBJECT", 11) <= 0) goto end; } } else if (tag == V_ASN1_BOOLEAN) { int ii; opp = op; ii = d2i_ASN1_BOOLEAN(NULL, &opp, len + hl); if (ii < 0) { if (BIO_write(bp, "Bad boolean\n", 12) <= 0) goto end; } BIO_printf(bp, ":%d", ii); } else if (tag == V_ASN1_BMPSTRING) { /* do the BMP thang */ } else if (tag == V_ASN1_OCTET_STRING) { int i, printable = 1; opp = op; os = d2i_ASN1_OCTET_STRING(NULL, &opp, len + hl); if (os != NULL && os->length > 0) { opp = os->data; /* testing whether the octet string is * printable */ for (i = 0; i < os->length; i++) { if (((opp[i] < ' ') && (opp[i] != '\n') && (opp[i] != '\r') && (opp[i] != '\t')) || (opp[i] > '~')) { printable = 0; break; } } if (printable) { /* printable string */ if (BIO_write(bp, ":", 1) <= 0) goto end; if (BIO_write(bp, (const char *)opp, os->length) <= 0) goto end; } else if (!dump) { /* not printable => print octet string * as hex dump */ if (BIO_write(bp, "[HEX DUMP]:", 11) <= 0) goto end; for (i = 0; i < os->length; i++) { if (BIO_printf(bp, "%02X", opp[i]) <= 0) goto end; } } else { /* print the normal dump */ if (!nl) { if (BIO_write(bp, "\n", 1) <= 0) goto end; } if (BIO_dump_indent(bp, (const char *)opp, ((dump == -1 || dump > os->length) ? os->length : dump), dump_indent) <= 0) goto end; nl = 1; } } if (os != NULL) { M_ASN1_OCTET_STRING_free(os); os = NULL; } } else if (tag == V_ASN1_INTEGER) { ASN1_INTEGER *bs; int i; opp = op; bs = d2i_ASN1_INTEGER(NULL, &opp, len + hl); if (bs != NULL) { if (BIO_write(bp, ":", 1) <= 0) goto end; if (bs->type == V_ASN1_NEG_INTEGER) if (BIO_write(bp, "-", 1) <= 0) goto end; for (i = 0; i < bs->length; i++) { if (BIO_printf(bp, "%02X", bs->data[i]) <= 0) goto end; } if (bs->length == 0) { if (BIO_write(bp, "00", 2) <= 0) goto end; } } else { if (BIO_write(bp, "BAD INTEGER", 11) <= 0) goto end; } M_ASN1_INTEGER_free(bs); } else if (tag == V_ASN1_ENUMERATED) { ASN1_ENUMERATED *bs; int i; opp = op; bs = d2i_ASN1_ENUMERATED(NULL, &opp, len + hl); if (bs != NULL) { if (BIO_write(bp, ":", 1) <= 0) goto end; if (bs->type == V_ASN1_NEG_ENUMERATED) if (BIO_write(bp, "-", 1) <= 0) goto end; for (i = 0; i < bs->length; i++) { if (BIO_printf(bp, "%02X", bs->data[i]) <= 0) goto end; } if (bs->length == 0) { if (BIO_write(bp, "00", 2) <= 0) goto end; } } else { if (BIO_write(bp, "BAD ENUMERATED", 14) <= 0) goto end; } M_ASN1_ENUMERATED_free(bs); } else if (len > 0 && dump) { if (!nl) { if (BIO_write(bp, "\n", 1) <= 0) goto end; } if (BIO_dump_indent(bp, (const char *)p, ((dump == -1 || dump > len) ? len : dump), dump_indent) <= 0) goto end; nl = 1; } if (!nl) { if (BIO_write(bp, "\n", 1) <= 0) goto end; } p += len; if ((tag == V_ASN1_EOC) && (xclass == 0)) { ret = 2; /* End of sequence */ goto end; } } length -= len; } ret = 1; end: if (o != NULL) ASN1_OBJECT_free(o); if (os != NULL) M_ASN1_OCTET_STRING_free(os); *pp = p; return (ret); } const char * ASN1_tag2str(int tag) { static const char * const tag2str[] = { "EOC", "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING", /* 0-4 */ "NULL", "OBJECT", "OBJECT DESCRIPTOR", "EXTERNAL", "REAL", /* 5-9 */ "ENUMERATED", "", "UTF8STRING", "", /* 10-13 */ "", "", "SEQUENCE", "SET", /* 15-17 */ "NUMERICSTRING", "PRINTABLESTRING", "T61STRING", /* 18-20 */ "VIDEOTEXSTRING", "IA5STRING", "UTCTIME", "GENERALIZEDTIME", /* 21-24 */ "GRAPHICSTRING", "VISIBLESTRING", "GENERALSTRING", /* 25-27 */ "UNIVERSALSTRING", "", "BMPSTRING" /* 28-30 */ }; if ((tag == V_ASN1_NEG_INTEGER) || (tag == V_ASN1_NEG_ENUMERATED)) tag &= ~0x100; if (tag < 0 || tag > 30) return "(unknown)"; return tag2str[tag]; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_sig.c0000644000175000017500000000664112360020705020401 0ustar /* $OpenBSD: x_sig.c,v 1.7 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include ASN1_SEQUENCE(X509_SIG) = { ASN1_SIMPLE(X509_SIG, algor, X509_ALGOR), ASN1_SIMPLE(X509_SIG, digest, ASN1_OCTET_STRING) } ASN1_SEQUENCE_END(X509_SIG) IMPLEMENT_ASN1_FUNCTIONS(X509_SIG) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/p5_pbev2.c0000644000175000017500000001762212360020705020713 0ustar /* $OpenBSD: p5_pbev2.c,v 1.16 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999-2004. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include /* PKCS#5 v2.0 password based encryption structures */ ASN1_SEQUENCE(PBE2PARAM) = { ASN1_SIMPLE(PBE2PARAM, keyfunc, X509_ALGOR), ASN1_SIMPLE(PBE2PARAM, encryption, X509_ALGOR) } ASN1_SEQUENCE_END(PBE2PARAM) IMPLEMENT_ASN1_FUNCTIONS(PBE2PARAM) ASN1_SEQUENCE(PBKDF2PARAM) = { ASN1_SIMPLE(PBKDF2PARAM, salt, ASN1_ANY), ASN1_SIMPLE(PBKDF2PARAM, iter, ASN1_INTEGER), ASN1_OPT(PBKDF2PARAM, keylength, ASN1_INTEGER), ASN1_OPT(PBKDF2PARAM, prf, X509_ALGOR) } ASN1_SEQUENCE_END(PBKDF2PARAM) IMPLEMENT_ASN1_FUNCTIONS(PBKDF2PARAM) /* Return an algorithm identifier for a PKCS#5 v2.0 PBE algorithm: * yes I know this is horrible! * * Extended version to allow application supplied PRF NID and IV. */ X509_ALGOR * PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter, unsigned char *salt, int saltlen, unsigned char *aiv, int prf_nid) { X509_ALGOR *scheme = NULL, *kalg = NULL, *ret = NULL; int alg_nid, keylen; EVP_CIPHER_CTX ctx; unsigned char iv[EVP_MAX_IV_LENGTH]; PBE2PARAM *pbe2 = NULL; ASN1_OBJECT *obj; alg_nid = EVP_CIPHER_type(cipher); if (alg_nid == NID_undef) { ASN1err(ASN1_F_PKCS5_PBE2_SET_IV, ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER); goto err; } obj = OBJ_nid2obj(alg_nid); if (!(pbe2 = PBE2PARAM_new())) goto merr; /* Setup the AlgorithmIdentifier for the encryption scheme */ scheme = pbe2->encryption; scheme->algorithm = obj; if (!(scheme->parameter = ASN1_TYPE_new())) goto merr; /* Create random IV */ if (EVP_CIPHER_iv_length(cipher)) { if (aiv) memcpy(iv, aiv, EVP_CIPHER_iv_length(cipher)); else if (RAND_pseudo_bytes(iv, EVP_CIPHER_iv_length(cipher)) < 0) goto err; } EVP_CIPHER_CTX_init(&ctx); /* Dummy cipherinit to just setup the IV, and PRF */ if (!EVP_CipherInit_ex(&ctx, cipher, NULL, NULL, iv, 0)) goto err; if (EVP_CIPHER_param_to_asn1(&ctx, scheme->parameter) < 0) { ASN1err(ASN1_F_PKCS5_PBE2_SET_IV, ASN1_R_ERROR_SETTING_CIPHER_PARAMS); EVP_CIPHER_CTX_cleanup(&ctx); goto err; } /* If prf NID unspecified see if cipher has a preference. * An error is OK here: just means use default PRF. */ if ((prf_nid == -1) && EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_PBE_PRF_NID, 0, &prf_nid) <= 0) { ERR_clear_error(); prf_nid = NID_hmacWithSHA1; } EVP_CIPHER_CTX_cleanup(&ctx); /* If its RC2 then we'd better setup the key length */ if (alg_nid == NID_rc2_cbc) keylen = EVP_CIPHER_key_length(cipher); else keylen = -1; /* Setup keyfunc */ X509_ALGOR_free(pbe2->keyfunc); pbe2->keyfunc = PKCS5_pbkdf2_set(iter, salt, saltlen, prf_nid, keylen); if (!pbe2->keyfunc) goto merr; /* Now set up top level AlgorithmIdentifier */ if (!(ret = X509_ALGOR_new())) goto merr; if (!(ret->parameter = ASN1_TYPE_new())) goto merr; ret->algorithm = OBJ_nid2obj(NID_pbes2); /* Encode PBE2PARAM into parameter */ if (!ASN1_item_pack(pbe2, ASN1_ITEM_rptr(PBE2PARAM), &ret->parameter->value.sequence)) goto merr; ret->parameter->type = V_ASN1_SEQUENCE; PBE2PARAM_free(pbe2); pbe2 = NULL; return ret; merr: ASN1err(ASN1_F_PKCS5_PBE2_SET_IV, ERR_R_MALLOC_FAILURE); err: PBE2PARAM_free(pbe2); /* Note 'scheme' is freed as part of pbe2 */ X509_ALGOR_free(kalg); X509_ALGOR_free(ret); return NULL; } X509_ALGOR * PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, unsigned char *salt, int saltlen) { return PKCS5_pbe2_set_iv(cipher, iter, salt, saltlen, NULL, -1); } X509_ALGOR * PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen, int prf_nid, int keylen) { X509_ALGOR *keyfunc = NULL; PBKDF2PARAM *kdf = NULL; ASN1_OCTET_STRING *osalt = NULL; if (!(kdf = PBKDF2PARAM_new())) goto merr; if (!(osalt = M_ASN1_OCTET_STRING_new())) goto merr; kdf->salt->value.octet_string = osalt; kdf->salt->type = V_ASN1_OCTET_STRING; if (!saltlen) saltlen = PKCS5_SALT_LEN; if (!(osalt->data = malloc (saltlen))) goto merr; osalt->length = saltlen; if (salt) memcpy (osalt->data, salt, saltlen); else if (RAND_pseudo_bytes (osalt->data, saltlen) < 0) goto merr; if (iter <= 0) iter = PKCS5_DEFAULT_ITER; if (!ASN1_INTEGER_set(kdf->iter, iter)) goto merr; /* If have a key len set it up */ if (keylen > 0) { if (!(kdf->keylength = M_ASN1_INTEGER_new())) goto merr; if (!ASN1_INTEGER_set (kdf->keylength, keylen)) goto merr; } /* prf can stay NULL if we are using hmacWithSHA1 */ if (prf_nid > 0 && prf_nid != NID_hmacWithSHA1) { kdf->prf = X509_ALGOR_new(); if (!kdf->prf) goto merr; X509_ALGOR_set0(kdf->prf, OBJ_nid2obj(prf_nid), V_ASN1_NULL, NULL); } /* Finally setup the keyfunc structure */ keyfunc = X509_ALGOR_new(); if (!keyfunc) goto merr; keyfunc->algorithm = OBJ_nid2obj(NID_id_pbkdf2); /* Encode PBKDF2PARAM into parameter of pbe2 */ if (!(keyfunc->parameter = ASN1_TYPE_new())) goto merr; if (!ASN1_item_pack(kdf, ASN1_ITEM_rptr(PBKDF2PARAM), &keyfunc->parameter->value.sequence)) goto merr; keyfunc->parameter->type = V_ASN1_SEQUENCE; PBKDF2PARAM_free(kdf); return keyfunc; merr: ASN1err(ASN1_F_PKCS5_PBKDF2_SET, ERR_R_MALLOC_FAILURE); PBKDF2PARAM_free(kdf); X509_ALGOR_free(keyfunc); return NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/bio_asn1.c0000644000175000017500000002703212360020705020760 0ustar /* $OpenBSD: bio_asn1.c,v 1.9 2014/06/12 15:49:27 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Experimental ASN1 BIO. When written through the data is converted * to an ASN1 string type: default is OCTET STRING. Additional functions * can be provided to add prefix and suffix data. */ #include #include #include #include /* Must be large enough for biggest tag+length */ #define DEFAULT_ASN1_BUF_SIZE 20 typedef enum { ASN1_STATE_START, ASN1_STATE_PRE_COPY, ASN1_STATE_HEADER, ASN1_STATE_HEADER_COPY, ASN1_STATE_DATA_COPY, ASN1_STATE_POST_COPY, ASN1_STATE_DONE } asn1_bio_state_t; typedef struct BIO_ASN1_EX_FUNCS_st { asn1_ps_func *ex_func; asn1_ps_func *ex_free_func; } BIO_ASN1_EX_FUNCS; typedef struct BIO_ASN1_BUF_CTX_t { /* Internal state */ asn1_bio_state_t state; /* Internal buffer */ unsigned char *buf; /* Size of buffer */ int bufsize; /* Current position in buffer */ int bufpos; /* Current buffer length */ int buflen; /* Amount of data to copy */ int copylen; /* Class and tag to use */ int asn1_class, asn1_tag; asn1_ps_func *prefix, *prefix_free, *suffix, *suffix_free; /* Extra buffer for prefix and suffix data */ unsigned char *ex_buf; int ex_len; int ex_pos; void *ex_arg; } BIO_ASN1_BUF_CTX; static int asn1_bio_write(BIO *h, const char *buf, int num); static int asn1_bio_read(BIO *h, char *buf, int size); static int asn1_bio_puts(BIO *h, const char *str); static int asn1_bio_gets(BIO *h, char *str, int size); static long asn1_bio_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int asn1_bio_new(BIO *h); static int asn1_bio_free(BIO *data); static long asn1_bio_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); static int asn1_bio_init(BIO_ASN1_BUF_CTX *ctx, int size); static int asn1_bio_flush_ex(BIO *b, BIO_ASN1_BUF_CTX *ctx, asn1_ps_func *cleanup, asn1_bio_state_t next); static int asn1_bio_setup_ex(BIO *b, BIO_ASN1_BUF_CTX *ctx, asn1_ps_func *setup, asn1_bio_state_t ex_state, asn1_bio_state_t other_state); static BIO_METHOD methods_asn1 = { .type = BIO_TYPE_ASN1, .name = "asn1", .bwrite = asn1_bio_write, .bread = asn1_bio_read, .bputs = asn1_bio_puts, .bgets = asn1_bio_gets, .ctrl = asn1_bio_ctrl, .create = asn1_bio_new, .destroy = asn1_bio_free, .callback_ctrl = asn1_bio_callback_ctrl }; BIO_METHOD * BIO_f_asn1(void) { return (&methods_asn1); } static int asn1_bio_new(BIO *b) { BIO_ASN1_BUF_CTX *ctx; ctx = malloc(sizeof(BIO_ASN1_BUF_CTX)); if (!ctx) return 0; if (!asn1_bio_init(ctx, DEFAULT_ASN1_BUF_SIZE)) { free(ctx); return 0; } b->init = 1; b->ptr = (char *)ctx; b->flags = 0; return 1; } static int asn1_bio_init(BIO_ASN1_BUF_CTX *ctx, int size) { ctx->buf = malloc(size); if (!ctx->buf) return 0; ctx->bufsize = size; ctx->bufpos = 0; ctx->buflen = 0; ctx->copylen = 0; ctx->asn1_class = V_ASN1_UNIVERSAL; ctx->asn1_tag = V_ASN1_OCTET_STRING; ctx->ex_buf = 0; ctx->ex_pos = 0; ctx->ex_len = 0; ctx->state = ASN1_STATE_START; return 1; } static int asn1_bio_free(BIO *b) { BIO_ASN1_BUF_CTX *ctx; ctx = (BIO_ASN1_BUF_CTX *) b->ptr; if (ctx == NULL) return 0; free(ctx->buf); free(ctx); b->init = 0; b->ptr = NULL; b->flags = 0; return 1; } static int asn1_bio_write(BIO *b, const char *in , int inl) { BIO_ASN1_BUF_CTX *ctx; int wrmax, wrlen, ret; unsigned char *p; if (!in || (inl < 0) || (b->next_bio == NULL)) return 0; ctx = (BIO_ASN1_BUF_CTX *) b->ptr; if (ctx == NULL) return 0; wrlen = 0; ret = -1; for (;;) { switch (ctx->state) { /* Setup prefix data, call it */ case ASN1_STATE_START: if (!asn1_bio_setup_ex(b, ctx, ctx->prefix, ASN1_STATE_PRE_COPY, ASN1_STATE_HEADER)) return 0; break; /* Copy any pre data first */ case ASN1_STATE_PRE_COPY: ret = asn1_bio_flush_ex(b, ctx, ctx->prefix_free, ASN1_STATE_HEADER); if (ret <= 0) goto done; break; case ASN1_STATE_HEADER: ctx->buflen = ASN1_object_size(0, inl, ctx->asn1_tag) - inl; OPENSSL_assert(ctx->buflen <= ctx->bufsize); p = ctx->buf; ASN1_put_object(&p, 0, inl, ctx->asn1_tag, ctx->asn1_class); ctx->copylen = inl; ctx->state = ASN1_STATE_HEADER_COPY; break; case ASN1_STATE_HEADER_COPY: ret = BIO_write(b->next_bio, ctx->buf + ctx->bufpos, ctx->buflen); if (ret <= 0) goto done; ctx->buflen -= ret; if (ctx->buflen) ctx->bufpos += ret; else { ctx->bufpos = 0; ctx->state = ASN1_STATE_DATA_COPY; } break; case ASN1_STATE_DATA_COPY: if (inl > ctx->copylen) wrmax = ctx->copylen; else wrmax = inl; ret = BIO_write(b->next_bio, in, wrmax); if (ret <= 0) break; wrlen += ret; ctx->copylen -= ret; in += ret; inl -= ret; if (ctx->copylen == 0) ctx->state = ASN1_STATE_HEADER; if (inl == 0) goto done; break; default: BIO_clear_retry_flags(b); return 0; } } done: BIO_clear_retry_flags(b); BIO_copy_next_retry(b); return (wrlen > 0) ? wrlen : ret; } static int asn1_bio_flush_ex(BIO *b, BIO_ASN1_BUF_CTX *ctx, asn1_ps_func *cleanup, asn1_bio_state_t next) { int ret; if (ctx->ex_len <= 0) return 1; for (;;) { ret = BIO_write(b->next_bio, ctx->ex_buf + ctx->ex_pos, ctx->ex_len); if (ret <= 0) break; ctx->ex_len -= ret; if (ctx->ex_len > 0) ctx->ex_pos += ret; else { if (cleanup) cleanup(b, &ctx->ex_buf, &ctx->ex_len, &ctx->ex_arg); ctx->state = next; ctx->ex_pos = 0; break; } } return ret; } static int asn1_bio_setup_ex(BIO *b, BIO_ASN1_BUF_CTX *ctx, asn1_ps_func *setup, asn1_bio_state_t ex_state, asn1_bio_state_t other_state) { if (setup && !setup(b, &ctx->ex_buf, &ctx->ex_len, &ctx->ex_arg)) { BIO_clear_retry_flags(b); return 0; } if (ctx->ex_len > 0) ctx->state = ex_state; else ctx->state = other_state; return 1; } static int asn1_bio_read(BIO *b, char *in , int inl) { if (!b->next_bio) return 0; return BIO_read(b->next_bio, in , inl); } static int asn1_bio_puts(BIO *b, const char *str) { return asn1_bio_write(b, str, strlen(str)); } static int asn1_bio_gets(BIO *b, char *str, int size) { if (!b->next_bio) return 0; return BIO_gets(b->next_bio, str , size); } static long asn1_bio_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) { if (b->next_bio == NULL) return (0); return BIO_callback_ctrl(b->next_bio, cmd, fp); } static long asn1_bio_ctrl(BIO *b, int cmd, long arg1, void *arg2) { BIO_ASN1_BUF_CTX *ctx; BIO_ASN1_EX_FUNCS *ex_func; long ret = 1; ctx = (BIO_ASN1_BUF_CTX *) b->ptr; if (ctx == NULL) return 0; switch (cmd) { case BIO_C_SET_PREFIX: ex_func = arg2; ctx->prefix = ex_func->ex_func; ctx->prefix_free = ex_func->ex_free_func; break; case BIO_C_GET_PREFIX: ex_func = arg2; ex_func->ex_func = ctx->prefix; ex_func->ex_free_func = ctx->prefix_free; break; case BIO_C_SET_SUFFIX: ex_func = arg2; ctx->suffix = ex_func->ex_func; ctx->suffix_free = ex_func->ex_free_func; break; case BIO_C_GET_SUFFIX: ex_func = arg2; ex_func->ex_func = ctx->suffix; ex_func->ex_free_func = ctx->suffix_free; break; case BIO_C_SET_EX_ARG: ctx->ex_arg = arg2; break; case BIO_C_GET_EX_ARG: *(void **)arg2 = ctx->ex_arg; break; case BIO_CTRL_FLUSH: if (!b->next_bio) return 0; /* Call post function if possible */ if (ctx->state == ASN1_STATE_HEADER) { if (!asn1_bio_setup_ex(b, ctx, ctx->suffix, ASN1_STATE_POST_COPY, ASN1_STATE_DONE)) return 0; } if (ctx->state == ASN1_STATE_POST_COPY) { ret = asn1_bio_flush_ex(b, ctx, ctx->suffix_free, ASN1_STATE_DONE); if (ret <= 0) return ret; } if (ctx->state == ASN1_STATE_DONE) return BIO_ctrl(b->next_bio, cmd, arg1, arg2); else { BIO_clear_retry_flags(b); return 0; } break; default: if (!b->next_bio) return 0; return BIO_ctrl(b->next_bio, cmd, arg1, arg2); } return ret; } static int asn1_bio_set_ex(BIO *b, int cmd, asn1_ps_func *ex_func, asn1_ps_func *ex_free_func) { BIO_ASN1_EX_FUNCS extmp; extmp.ex_func = ex_func; extmp.ex_free_func = ex_free_func; return BIO_ctrl(b, cmd, 0, &extmp); } static int asn1_bio_get_ex(BIO *b, int cmd, asn1_ps_func **ex_func, asn1_ps_func **ex_free_func) { BIO_ASN1_EX_FUNCS extmp; int ret; ret = BIO_ctrl(b, cmd, 0, &extmp); if (ret > 0) { *ex_func = extmp.ex_func; *ex_free_func = extmp.ex_free_func; } return ret; } int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix, asn1_ps_func *prefix_free) { return asn1_bio_set_ex(b, BIO_C_SET_PREFIX, prefix, prefix_free); } int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix, asn1_ps_func **pprefix_free) { return asn1_bio_get_ex(b, BIO_C_GET_PREFIX, pprefix, pprefix_free); } int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix, asn1_ps_func *suffix_free) { return asn1_bio_set_ex(b, BIO_C_SET_SUFFIX, suffix, suffix_free); } int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix, asn1_ps_func **psuffix_free) { return asn1_bio_get_ex(b, BIO_C_GET_SUFFIX, psuffix, psuffix_free); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/charmap.h0000644000175000017500000000115112360020705020677 0ustar /* $OpenBSD$ */ /* Auto generated with chartype.pl script. * Mask of various character properties */ static const unsigned char char_type[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 120, 0, 1, 40, 0, 0, 0, 16, 16, 16, 0, 25, 25, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 9, 9, 16, 9, 16, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 1, 0, 0, 0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 2 }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_utctm.c0000644000175000017500000001547512360020705020731 0ustar /* $OpenBSD: a_utctm.c,v 1.26 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include "o_time.h" int ASN1_UTCTIME_check(ASN1_UTCTIME *d) { static const int min[8] = {0, 1, 1, 0, 0, 0, 0, 0}; static const int max[8] = {99, 12, 31, 23, 59, 59, 12, 59}; char *a; int n, i, l, o; if (d->type != V_ASN1_UTCTIME) return (0); l = d->length; a = (char *)d->data; o = 0; if (l < 11) goto err; for (i = 0; i < 6; i++) { if ((i == 5) && ((a[o] == 'Z') || (a[o] == '+') || (a[o] == '-'))) { i++; break; } if ((a[o] < '0') || (a[o] > '9')) goto err; n = a[o]-'0'; if (++o > l) goto err; if ((a[o] < '0') || (a[o] > '9')) goto err; n = (n * 10) + a[o] - '0'; if (++o > l) goto err; if ((n < min[i]) || (n > max[i])) goto err; } if (a[o] == 'Z') o++; else if ((a[o] == '+') || (a[o] == '-')) { o++; if (o + 4 > l) goto err; for (i = 6; i < 8; i++) { if ((a[o] < '0') || (a[o] > '9')) goto err; n = a[o] -'0'; o++; if ((a[o] < '0') || (a[o] > '9')) goto err; n = (n * 10) + a[o] - '0'; if ((n < min[i]) || (n > max[i])) goto err; o++; } } return (o == l); err: return (0); } int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str) { ASN1_UTCTIME t; t.type = V_ASN1_UTCTIME; t.length = strlen(str); t.data = (unsigned char *)str; if (ASN1_UTCTIME_check(&t)) { if (s != NULL) { if (!ASN1_STRING_set((ASN1_STRING *)s, (unsigned char *)str, t.length)) return 0; s->type = V_ASN1_UTCTIME; } return (1); } else return (0); } ASN1_UTCTIME * ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t) { return ASN1_UTCTIME_adj(s, t, 0, 0); } static ASN1_UTCTIME * ASN1_UTCTIME_adj_internal(ASN1_UTCTIME *s, time_t t, int offset_day, long offset_sec) { char *p; struct tm *ts; struct tm data; size_t len = 20; ts = gmtime_r(&t, &data); if (ts == NULL) return (NULL); if (offset_day || offset_sec) { if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec)) return NULL; } if ((ts->tm_year < 50) || (ts->tm_year >= 150)) return NULL; p = (char *)s->data; if ((p == NULL) || ((size_t)s->length < len)) { p = malloc(len); if (p == NULL) { ASN1err(ASN1_F_ASN1_UTCTIME_ADJ, ERR_R_MALLOC_FAILURE); return (NULL); } free(s->data); s->data = (unsigned char *)p; } snprintf(p, len, "%02d%02d%02d%02d%02d%02dZ", ts->tm_year % 100, ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min, ts->tm_sec); s->length = strlen(p); s->type = V_ASN1_UTCTIME; return (s); } ASN1_UTCTIME * ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, int offset_day, long offset_sec) { ASN1_UTCTIME *tmp = NULL, *ret; if (s == NULL) { tmp = M_ASN1_UTCTIME_new(); if (tmp == NULL) return NULL; s = tmp; } ret = ASN1_UTCTIME_adj_internal(s, t, offset_day, offset_sec); if (ret == NULL && tmp != NULL) M_ASN1_UTCTIME_free(tmp); return ret; } int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t) { struct tm *tm; struct tm data; int offset; int year; #define g2(p) (((p)[0]-'0')*10+(p)[1]-'0') if (s->data[12] == 'Z') offset = 0; else { offset = g2(s->data + 13)*60 + g2(s->data + 15); if (s->data[12] == '-') offset = -offset; } t -= offset * 60; /* FIXME: may overflow in extreme cases */ tm = gmtime_r(&t, &data); #define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1 year = g2(s->data); if (year < 50) year += 100; return_cmp(year, tm->tm_year); return_cmp(g2(s->data + 2) - 1, tm->tm_mon); return_cmp(g2(s->data + 4), tm->tm_mday); return_cmp(g2(s->data + 6), tm->tm_hour); return_cmp(g2(s->data + 8), tm->tm_min); return_cmp(g2(s->data + 10), tm->tm_sec); #undef g2 #undef return_cmp return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/d2i_pr.c0000644000175000017500000001337612360020705020452 0ustar /* $OpenBSD: d2i_pr.c,v 1.11 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif #include "asn1_locl.h" EVP_PKEY * d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, long length) { EVP_PKEY *ret; if ((a == NULL) || (*a == NULL)) { if ((ret = EVP_PKEY_new()) == NULL) { ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_EVP_LIB); return (NULL); } } else { ret = *a; #ifndef OPENSSL_NO_ENGINE if (ret->engine) { ENGINE_finish(ret->engine); ret->engine = NULL; } #endif } if (!EVP_PKEY_set_type(ret, type)) { ASN1err(ASN1_F_D2I_PRIVATEKEY, ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE); goto err; } if (!ret->ameth->old_priv_decode || !ret->ameth->old_priv_decode(ret, pp, length)) { if (ret->ameth->priv_decode) { PKCS8_PRIV_KEY_INFO *p8 = NULL; p8 = d2i_PKCS8_PRIV_KEY_INFO(NULL, pp, length); if (!p8) goto err; EVP_PKEY_free(ret); ret = EVP_PKCS82PKEY(p8); PKCS8_PRIV_KEY_INFO_free(p8); } else { ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_ASN1_LIB); goto err; } } if (a != NULL) (*a) = ret; return (ret); err: if ((ret != NULL) && ((a == NULL) || (*a != ret))) EVP_PKEY_free(ret); return (NULL); } /* This works like d2i_PrivateKey() except it automatically works out the type */ EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, long length) { STACK_OF(ASN1_TYPE) *inkey; const unsigned char *p; int keytype; p = *pp; /* Dirty trick: read in the ASN1 data into a STACK_OF(ASN1_TYPE): * by analyzing it we can determine the passed structure: this * assumes the input is surrounded by an ASN1 SEQUENCE. */ inkey = d2i_ASN1_SEQUENCE_ANY(NULL, &p, length); /* Since we only need to discern "traditional format" RSA and DSA * keys we can just count the elements. */ if (sk_ASN1_TYPE_num(inkey) == 6) keytype = EVP_PKEY_DSA; else if (sk_ASN1_TYPE_num(inkey) == 4) keytype = EVP_PKEY_EC; else if (sk_ASN1_TYPE_num(inkey) == 3) { /* This seems to be PKCS8, not traditional format */ PKCS8_PRIV_KEY_INFO *p8 = d2i_PKCS8_PRIV_KEY_INFO( NULL, pp, length); EVP_PKEY *ret; sk_ASN1_TYPE_pop_free(inkey, ASN1_TYPE_free); if (!p8) { ASN1err(ASN1_F_D2I_AUTOPRIVATEKEY, ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE); return NULL; } ret = EVP_PKCS82PKEY(p8); PKCS8_PRIV_KEY_INFO_free(p8); if (a) { *a = ret; } return ret; } else keytype = EVP_PKEY_RSA; sk_ASN1_TYPE_pop_free(inkey, ASN1_TYPE_free); return d2i_PrivateKey(keytype, a, pp, length); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_val.c0000644000175000017500000000663612360020705020405 0ustar /* $OpenBSD: x_val.c,v 1.7 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include ASN1_SEQUENCE(X509_VAL) = { ASN1_SIMPLE(X509_VAL, notBefore, ASN1_TIME), ASN1_SIMPLE(X509_VAL, notAfter, ASN1_TIME) } ASN1_SEQUENCE_END(X509_VAL) IMPLEMENT_ASN1_FUNCTIONS(X509_VAL) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/f_int.c0000644000175000017500000001355712360020705020373 0ustar /* $OpenBSD: f_int.c,v 1.16 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a) { int i, n = 0; static const char h[] = "0123456789ABCDEF"; char buf[2]; if (a == NULL) return (0); if (a->type & V_ASN1_NEG) { if (BIO_write(bp, "-", 1) != 1) goto err; n = 1; } if (a->length == 0) { if (BIO_write(bp, "00", 2) != 2) goto err; n += 2; } else { for (i = 0; i < a->length; i++) { if ((i != 0) && (i % 35 == 0)) { if (BIO_write(bp, "\\\n", 2) != 2) goto err; n += 2; } buf[0] = h[((unsigned char)a->data[i] >> 4) & 0x0f]; buf[1] = h[((unsigned char)a->data[i]) & 0x0f]; if (BIO_write(bp, buf, 2) != 2) goto err; n += 2; } } return (n); err: return (-1); } int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size) { int ret = 0; int i, j,k, m,n, again, bufsize; unsigned char *s = NULL, *sp; unsigned char *bufp; int num = 0, slen = 0, first = 1; bs->type = V_ASN1_INTEGER; bufsize = BIO_gets(bp, buf, size); for (;;) { if (bufsize < 1) goto err_sl; i = bufsize; if (buf[i - 1] == '\n') buf[--i] = '\0'; if (i == 0) goto err_sl; if (buf[i - 1] == '\r') buf[--i] = '\0'; if (i == 0) goto err_sl; again = (buf[i - 1] == '\\'); for (j = 0; j < i; j++) { if (!(((buf[j] >= '0') && (buf[j] <= '9')) || ((buf[j] >= 'a') && (buf[j] <= 'f')) || ((buf[j] >= 'A') && (buf[j] <= 'F')))) { i = j; break; } } buf[i] = '\0'; /* We have now cleared all the crap off the end of the * line */ if (i < 2) goto err_sl; bufp = (unsigned char *)buf; if (first) { first = 0; if ((bufp[0] == '0') && (buf[1] == '0')) { bufp += 2; i -= 2; } } k = 0; i -= again; if (i % 2 != 0) { ASN1err(ASN1_F_A2I_ASN1_INTEGER, ASN1_R_ODD_NUMBER_OF_CHARS); goto err; } i /= 2; if (num + i > slen) { sp = OPENSSL_realloc_clean(s, slen, num + i); if (sp == NULL) { ASN1err(ASN1_F_A2I_ASN1_INTEGER, ERR_R_MALLOC_FAILURE); goto err; } s = sp; slen = num + i; } for (j = 0; j < i; j++, k += 2) { for (n = 0; n < 2; n++) { m = bufp[k + n]; if ((m >= '0') && (m <= '9')) m -= '0'; else if ((m >= 'a') && (m <= 'f')) m = m - 'a' + 10; else if ((m >= 'A') && (m <= 'F')) m = m - 'A' + 10; else { ASN1err(ASN1_F_A2I_ASN1_INTEGER, ASN1_R_NON_HEX_CHARACTERS); goto err; } s[num + j] <<= 4; s[num + j] |= m; } } num += i; if (again) bufsize = BIO_gets(bp, buf, size); else break; } bs->length = num; bs->data = s; return (1); err_sl: ASN1err(ASN1_F_A2I_ASN1_INTEGER, ASN1_R_SHORT_LINE); err: free(s); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/t_bitst.c0000644000175000017500000000734612360020705020743 0ustar /* $OpenBSD: t_bitst.c,v 1.6 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, BIT_STRING_BITNAME *tbl, int indent) { BIT_STRING_BITNAME *bnam; char first = 1; BIO_printf(out, "%*s", indent, ""); for (bnam = tbl; bnam->lname; bnam++) { if (ASN1_BIT_STRING_get_bit(bs, bnam->bitnum)) { if (!first) BIO_puts(out, ", "); BIO_puts(out, bnam->lname); first = 0; } } BIO_puts(out, "\n"); return 1; } int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, BIT_STRING_BITNAME *tbl) { int bitnum; bitnum = ASN1_BIT_STRING_num_asc(name, tbl); if (bitnum < 0) return 0; if (bs) { if (!ASN1_BIT_STRING_set_bit(bs, bitnum, value)) return 0; } return 1; } int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl) { BIT_STRING_BITNAME *bnam; for (bnam = tbl; bnam->lname; bnam++) { if (!strcmp(bnam->sname, name) || !strcmp(bnam->lname, name)) return bnam->bitnum; } return -1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_bytes.c0000644000175000017500000001725112360020705020715 0ustar /* $OpenBSD: a_bytes.c,v 1.17 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include static int asn1_collate_primitive(ASN1_STRING *a, ASN1_const_CTX *c); /* type is a 'bitmap' of acceptable string types. */ ASN1_STRING * d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp, long length, int type) { ASN1_STRING *ret = NULL; const unsigned char *p; unsigned char *s; long len; int inf, tag, xclass; int i = 0; p = *pp; inf = ASN1_get_object(&p, &len, &tag, &xclass, length); if (inf & 0x80) goto err; if (tag >= 32) { i = ASN1_R_TAG_VALUE_TOO_HIGH; goto err; } if (!(ASN1_tag2bit(tag) & type)) { i = ASN1_R_WRONG_TYPE; goto err; } /* If a bit-string, exit early */ if (tag == V_ASN1_BIT_STRING) return (d2i_ASN1_BIT_STRING(a, pp, length)); if ((a == NULL) || ((*a) == NULL)) { if ((ret = ASN1_STRING_new()) == NULL) return (NULL); } else ret = (*a); if (len != 0) { s = malloc(len + 1); if (s == NULL) { i = ERR_R_MALLOC_FAILURE; goto err; } memcpy(s, p, len); s[len]='\0'; p += len; } else s = NULL; free(ret->data); ret->length = (int)len; ret->data = s; ret->type = tag; if (a != NULL) (*a) = ret; *pp = p; return (ret); err: ASN1err(ASN1_F_D2I_ASN1_TYPE_BYTES, i); if (a == NULL || *a != ret) ASN1_STRING_free(ret); return (NULL); } int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass) { int ret, r, constructed; unsigned char *p; if (a == NULL) return (0); if (tag == V_ASN1_BIT_STRING) return (i2d_ASN1_BIT_STRING(a, pp)); ret = a->length; r = ASN1_object_size(0, ret, tag); if (pp == NULL) return (r); p = *pp; if ((tag == V_ASN1_SEQUENCE) || (tag == V_ASN1_SET)) constructed = 1; else constructed = 0; ASN1_put_object(&p, constructed, ret, tag, xclass); memcpy(p, a->data, a->length); p += a->length; *pp = p; return (r); } ASN1_STRING * d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp, long length, int Ptag, int Pclass) { ASN1_STRING *ret = NULL; const unsigned char *p; unsigned char *s; long len; int inf, tag, xclass; int i = 0; if ((a == NULL) || ((*a) == NULL)) { if ((ret = ASN1_STRING_new()) == NULL) return (NULL); } else ret = (*a); p= *pp; inf = ASN1_get_object(&p, &len, &tag, &xclass, length); if (inf & 0x80) { i = ASN1_R_BAD_OBJECT_HEADER; goto err; } if (tag != Ptag) { i = ASN1_R_WRONG_TAG; goto err; } if (inf & V_ASN1_CONSTRUCTED) { ASN1_const_CTX c; c.pp = pp; c.p = p; c.inf = inf; c.slen = len; c.tag = Ptag; c.xclass = Pclass; c.max = (length == 0) ? 0 : (p + length); if (!asn1_collate_primitive(ret, &c)) goto err; else { p = c.p; } } else { if (len != 0) { if ((ret->length < len) || (ret->data == NULL)) { free(ret->data); ret->data = NULL; s = malloc(len + 1); if (s == NULL) { i = ERR_R_MALLOC_FAILURE; goto err; } } else s = ret->data; memcpy(s, p, len); s[len] = '\0'; p += len; } else { s = NULL; free(ret->data); } ret->length = (int)len; ret->data = s; ret->type = Ptag; } if (a != NULL) (*a) = ret; *pp = p; return (ret); err: if (a == NULL || *a != ret) ASN1_STRING_free(ret); ASN1err(ASN1_F_D2I_ASN1_BYTES, i); return (NULL); } /* We are about to parse 0..n d2i_ASN1_bytes objects, we are to collapse * them into the one structure that is then returned */ /* There have been a few bug fixes for this function from * Paul Keogh , many thanks to him */ static int asn1_collate_primitive(ASN1_STRING *a, ASN1_const_CTX *c) { ASN1_STRING *os = NULL; BUF_MEM b; int num; b.length = 0; b.max = 0; b.data = NULL; if (a == NULL) { c->error = ERR_R_PASSED_NULL_PARAMETER; goto err; } num = 0; for (;;) { if (c->inf & 1) { c->eos = ASN1_const_check_infinite_end(&c->p, (long)(c->max - c->p)); if (c->eos) break; } else { if (c->slen <= 0) break; } c->q = c->p; if (d2i_ASN1_bytes(&os, &c->p, c->max - c->p, c->tag, c->xclass) == NULL) { c->error = ERR_R_ASN1_LIB; goto err; } if (!BUF_MEM_grow_clean(&b, num + os->length)) { c->error = ERR_R_BUF_LIB; goto err; } memcpy(&(b.data[num]), os->data, os->length); if (!(c->inf & 1)) c->slen -= (c->p - c->q); num += os->length; } if (!asn1_const_Finish(c)) goto err; a->length = num; free(a->data); a->data = (unsigned char *)b.data; ASN1_STRING_free(os); return (1); err: ASN1err(ASN1_F_ASN1_COLLATE_PRIMITIVE, c->error); ASN1_STRING_free(os); free(b.data); return (0); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_pubkey.c0000644000175000017500000002241612360020705021114 0ustar /* $OpenBSD: x_pubkey.c,v 1.20 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #ifndef OPENSSL_NO_DSA #include #endif #ifndef OPENSSL_NO_RSA #include #endif #include "asn1_locl.h" /* Minor tweak to operation: free up EVP_PKEY */ static int pubkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { if (operation == ASN1_OP_FREE_POST) { X509_PUBKEY *pubkey = (X509_PUBKEY *)*pval; EVP_PKEY_free(pubkey->pkey); } return 1; } ASN1_SEQUENCE_cb(X509_PUBKEY, pubkey_cb) = { ASN1_SIMPLE(X509_PUBKEY, algor, X509_ALGOR), ASN1_SIMPLE(X509_PUBKEY, public_key, ASN1_BIT_STRING) } ASN1_SEQUENCE_END_cb(X509_PUBKEY, X509_PUBKEY) IMPLEMENT_ASN1_FUNCTIONS(X509_PUBKEY) int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) { X509_PUBKEY *pk = NULL; if (x == NULL) return (0); if ((pk = X509_PUBKEY_new()) == NULL) goto error; if (pkey->ameth) { if (pkey->ameth->pub_encode) { if (!pkey->ameth->pub_encode(pk, pkey)) { X509err(X509_F_X509_PUBKEY_SET, X509_R_PUBLIC_KEY_ENCODE_ERROR); goto error; } } else { X509err(X509_F_X509_PUBKEY_SET, X509_R_METHOD_NOT_SUPPORTED); goto error; } } else { X509err(X509_F_X509_PUBKEY_SET, X509_R_UNSUPPORTED_ALGORITHM); goto error; } if (*x != NULL) X509_PUBKEY_free(*x); *x = pk; return 1; error: if (pk != NULL) X509_PUBKEY_free(pk); return 0; } EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key) { EVP_PKEY *ret = NULL; if (key == NULL) goto error; if (key->pkey != NULL) { CRYPTO_add(&key->pkey->references, 1, CRYPTO_LOCK_EVP_PKEY); return key->pkey; } if (key->public_key == NULL) goto error; if ((ret = EVP_PKEY_new()) == NULL) { X509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE); goto error; } if (!EVP_PKEY_set_type(ret, OBJ_obj2nid(key->algor->algorithm))) { X509err(X509_F_X509_PUBKEY_GET, X509_R_UNSUPPORTED_ALGORITHM); goto error; } if (ret->ameth->pub_decode) { if (!ret->ameth->pub_decode(ret, key)) { X509err(X509_F_X509_PUBKEY_GET, X509_R_PUBLIC_KEY_DECODE_ERROR); goto error; } } else { X509err(X509_F_X509_PUBKEY_GET, X509_R_METHOD_NOT_SUPPORTED); goto error; } /* Check to see if another thread set key->pkey first */ CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY); if (key->pkey) { CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY); EVP_PKEY_free(ret); ret = key->pkey; } else { key->pkey = ret; CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY); } CRYPTO_add(&ret->references, 1, CRYPTO_LOCK_EVP_PKEY); return ret; error: if (ret != NULL) EVP_PKEY_free(ret); return (NULL); } /* Now two pseudo ASN1 routines that take an EVP_PKEY structure * and encode or decode as X509_PUBKEY */ EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a, const unsigned char **pp, long length) { X509_PUBKEY *xpk; EVP_PKEY *pktmp; xpk = d2i_X509_PUBKEY(NULL, pp, length); if (!xpk) return NULL; pktmp = X509_PUBKEY_get(xpk); X509_PUBKEY_free(xpk); if (!pktmp) return NULL; if (a) { EVP_PKEY_free(*a); *a = pktmp; } return pktmp; } int i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp) { X509_PUBKEY *xpk = NULL; int ret; if (!a) return 0; if (!X509_PUBKEY_set(&xpk, a)) return 0; ret = i2d_X509_PUBKEY(xpk, pp); X509_PUBKEY_free(xpk); return ret; } /* The following are equivalents but which return RSA and DSA * keys */ #ifndef OPENSSL_NO_RSA RSA * d2i_RSA_PUBKEY(RSA **a, const unsigned char **pp, long length) { EVP_PKEY *pkey; RSA *key; const unsigned char *q; q = *pp; pkey = d2i_PUBKEY(NULL, &q, length); if (!pkey) return NULL; key = EVP_PKEY_get1_RSA(pkey); EVP_PKEY_free(pkey); if (!key) return NULL; *pp = q; if (a) { RSA_free(*a); *a = key; } return key; } int i2d_RSA_PUBKEY(RSA *a, unsigned char **pp) { EVP_PKEY *pktmp; int ret; if (!a) return 0; pktmp = EVP_PKEY_new(); if (!pktmp) { ASN1err(ASN1_F_I2D_RSA_PUBKEY, ERR_R_MALLOC_FAILURE); return 0; } EVP_PKEY_set1_RSA(pktmp, a); ret = i2d_PUBKEY(pktmp, pp); EVP_PKEY_free(pktmp); return ret; } #endif #ifndef OPENSSL_NO_DSA DSA * d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length) { EVP_PKEY *pkey; DSA *key; const unsigned char *q; q = *pp; pkey = d2i_PUBKEY(NULL, &q, length); if (!pkey) return NULL; key = EVP_PKEY_get1_DSA(pkey); EVP_PKEY_free(pkey); if (!key) return NULL; *pp = q; if (a) { DSA_free(*a); *a = key; } return key; } int i2d_DSA_PUBKEY(DSA *a, unsigned char **pp) { EVP_PKEY *pktmp; int ret; if (!a) return 0; pktmp = EVP_PKEY_new(); if (!pktmp) { ASN1err(ASN1_F_I2D_DSA_PUBKEY, ERR_R_MALLOC_FAILURE); return 0; } EVP_PKEY_set1_DSA(pktmp, a); ret = i2d_PUBKEY(pktmp, pp); EVP_PKEY_free(pktmp); return ret; } #endif #ifndef OPENSSL_NO_EC EC_KEY * d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, long length) { EVP_PKEY *pkey; EC_KEY *key; const unsigned char *q; q = *pp; pkey = d2i_PUBKEY(NULL, &q, length); if (!pkey) return (NULL); key = EVP_PKEY_get1_EC_KEY(pkey); EVP_PKEY_free(pkey); if (!key) return (NULL); *pp = q; if (a) { EC_KEY_free(*a); *a = key; } return (key); } int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp) { EVP_PKEY *pktmp; int ret; if (!a) return (0); if ((pktmp = EVP_PKEY_new()) == NULL) { ASN1err(ASN1_F_I2D_EC_PUBKEY, ERR_R_MALLOC_FAILURE); return (0); } EVP_PKEY_set1_EC_KEY(pktmp, a); ret = i2d_PUBKEY(pktmp, pp); EVP_PKEY_free(pktmp); return (ret); } #endif int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj, int ptype, void *pval, unsigned char *penc, int penclen) { if (!X509_ALGOR_set0(pub->algor, aobj, ptype, pval)) return 0; if (penc) { free(pub->public_key->data); pub->public_key->data = penc; pub->public_key->length = penclen; /* Set number of unused bits to zero */ pub->public_key->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); pub->public_key->flags |= ASN1_STRING_FLAG_BITS_LEFT; } return 1; } int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg, const unsigned char **pk, int *ppklen, X509_ALGOR **pa, X509_PUBKEY *pub) { if (ppkalg) *ppkalg = pub->algor->algorithm; if (pk) { *pk = pub->public_key->data; *ppklen = pub->public_key->length; } if (pa) *pa = pub->algor; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/p5_pbe.c0000644000175000017500000001121212360020705020430 0ustar /* $OpenBSD: p5_pbe.c,v 1.15 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include /* PKCS#5 password based encryption structure */ ASN1_SEQUENCE(PBEPARAM) = { ASN1_SIMPLE(PBEPARAM, salt, ASN1_OCTET_STRING), ASN1_SIMPLE(PBEPARAM, iter, ASN1_INTEGER) } ASN1_SEQUENCE_END(PBEPARAM) IMPLEMENT_ASN1_FUNCTIONS(PBEPARAM) /* Set an algorithm identifier for a PKCS#5 PBE algorithm */ int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, const unsigned char *salt, int saltlen) { PBEPARAM *pbe = NULL; ASN1_STRING *pbe_str = NULL; unsigned char *sstr; pbe = PBEPARAM_new(); if (!pbe) { ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR, ERR_R_MALLOC_FAILURE); goto err; } if (iter <= 0) iter = PKCS5_DEFAULT_ITER; if (!ASN1_INTEGER_set(pbe->iter, iter)) { ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR, ERR_R_MALLOC_FAILURE); goto err; } if (!saltlen) saltlen = PKCS5_SALT_LEN; if (!ASN1_STRING_set(pbe->salt, NULL, saltlen)) { ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR, ERR_R_MALLOC_FAILURE); goto err; } sstr = ASN1_STRING_data(pbe->salt); if (salt) memcpy(sstr, salt, saltlen); else if (RAND_pseudo_bytes(sstr, saltlen) < 0) goto err; if (!ASN1_item_pack(pbe, ASN1_ITEM_rptr(PBEPARAM), &pbe_str)) { ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR, ERR_R_MALLOC_FAILURE); goto err; } PBEPARAM_free(pbe); pbe = NULL; if (X509_ALGOR_set0(algor, OBJ_nid2obj(alg), V_ASN1_SEQUENCE, pbe_str)) return 1; err: if (pbe != NULL) PBEPARAM_free(pbe); ASN1_STRING_free(pbe_str); return 0; } /* Return an algorithm identifier for a PKCS#5 PBE algorithm */ X509_ALGOR * PKCS5_pbe_set(int alg, int iter, const unsigned char *salt, int saltlen) { X509_ALGOR *ret; ret = X509_ALGOR_new(); if (!ret) { ASN1err(ASN1_F_PKCS5_PBE_SET, ERR_R_MALLOC_FAILURE); return NULL; } if (PKCS5_pbe_set0_algor(ret, alg, iter, salt, saltlen)) return ret; X509_ALGOR_free(ret); return NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_name.c0000644000175000017500000003443212360020705020536 0ustar /* $OpenBSD: x_name.c,v 1.18 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include "asn1_locl.h" typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY; DECLARE_STACK_OF(STACK_OF_X509_NAME_ENTRY) static int x509_name_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx); static int x509_name_ex_i2d(ASN1_VALUE **val, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); static int x509_name_ex_new(ASN1_VALUE **val, const ASN1_ITEM *it); static void x509_name_ex_free(ASN1_VALUE **val, const ASN1_ITEM *it); static int x509_name_encode(X509_NAME *a); static int x509_name_canon(X509_NAME *a); static int asn1_string_canon(ASN1_STRING *out, ASN1_STRING *in); static int i2d_name_canon(STACK_OF(STACK_OF_X509_NAME_ENTRY) *intname, unsigned char **in); static int x509_name_ex_print(BIO *out, ASN1_VALUE **pval, int indent, const char *fname, const ASN1_PCTX *pctx); ASN1_SEQUENCE(X509_NAME_ENTRY) = { ASN1_SIMPLE(X509_NAME_ENTRY, object, ASN1_OBJECT), ASN1_SIMPLE(X509_NAME_ENTRY, value, ASN1_PRINTABLE) } ASN1_SEQUENCE_END(X509_NAME_ENTRY) IMPLEMENT_ASN1_FUNCTIONS(X509_NAME_ENTRY) IMPLEMENT_ASN1_DUP_FUNCTION(X509_NAME_ENTRY) /* For the "Name" type we need a SEQUENCE OF { SET OF X509_NAME_ENTRY } * so declare two template wrappers for this */ ASN1_ITEM_TEMPLATE(X509_NAME_ENTRIES) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SET_OF, 0, RDNS, X509_NAME_ENTRY) ASN1_ITEM_TEMPLATE_END(X509_NAME_ENTRIES) ASN1_ITEM_TEMPLATE(X509_NAME_INTERNAL) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, Name, X509_NAME_ENTRIES) ASN1_ITEM_TEMPLATE_END(X509_NAME_INTERNAL) /* Normally that's where it would end: we'd have two nested STACK structures * representing the ASN1. Unfortunately X509_NAME uses a completely different * form and caches encodings so we have to process the internal form and convert * to the external form. */ const ASN1_EXTERN_FUNCS x509_name_ff = { NULL, x509_name_ex_new, x509_name_ex_free, 0, /* Default clear behaviour is OK */ x509_name_ex_d2i, x509_name_ex_i2d, x509_name_ex_print }; IMPLEMENT_EXTERN_ASN1(X509_NAME, V_ASN1_SEQUENCE, x509_name_ff) IMPLEMENT_ASN1_FUNCTIONS(X509_NAME) IMPLEMENT_ASN1_DUP_FUNCTION(X509_NAME) static int x509_name_ex_new(ASN1_VALUE **val, const ASN1_ITEM *it) { X509_NAME *ret = NULL; ret = malloc(sizeof(X509_NAME)); if (!ret) goto memerr; if ((ret->entries = sk_X509_NAME_ENTRY_new_null()) == NULL) goto memerr; if ((ret->bytes = BUF_MEM_new()) == NULL) goto memerr; ret->canon_enc = NULL; ret->canon_enclen = 0; ret->modified = 1; *val = (ASN1_VALUE *)ret; return 1; memerr: ASN1err(ASN1_F_X509_NAME_EX_NEW, ERR_R_MALLOC_FAILURE); if (ret) { if (ret->entries) sk_X509_NAME_ENTRY_free(ret->entries); free(ret); } return 0; } static void x509_name_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) { X509_NAME *a; if (!pval || !*pval) return; a = (X509_NAME *)*pval; BUF_MEM_free(a->bytes); sk_X509_NAME_ENTRY_pop_free(a->entries, X509_NAME_ENTRY_free); free(a->canon_enc); free(a); *pval = NULL; } static int x509_name_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx) { const unsigned char *p = *in, *q; union { STACK_OF(STACK_OF_X509_NAME_ENTRY) *s; ASN1_VALUE *a; } intname = {NULL}; union { X509_NAME *x; ASN1_VALUE *a; } nm = {NULL}; int i, j, ret; STACK_OF(X509_NAME_ENTRY) *entries; X509_NAME_ENTRY *entry; q = p; /* Get internal representation of Name */ ret = ASN1_item_ex_d2i(&intname.a, &p, len, ASN1_ITEM_rptr(X509_NAME_INTERNAL), tag, aclass, opt, ctx); if (ret <= 0) return ret; if (*val) x509_name_ex_free(val, NULL); if (!x509_name_ex_new(&nm.a, NULL)) goto err; /* We've decoded it: now cache encoding */ if (!BUF_MEM_grow(nm.x->bytes, p - q)) goto err; memcpy(nm.x->bytes->data, q, p - q); /* Convert internal representation to X509_NAME structure */ for (i = 0; i < sk_STACK_OF_X509_NAME_ENTRY_num(intname.s); i++) { entries = sk_STACK_OF_X509_NAME_ENTRY_value(intname.s, i); for (j = 0; j < sk_X509_NAME_ENTRY_num(entries); j++) { entry = sk_X509_NAME_ENTRY_value(entries, j); entry->set = i; if (!sk_X509_NAME_ENTRY_push(nm.x->entries, entry)) goto err; } sk_X509_NAME_ENTRY_free(entries); } sk_STACK_OF_X509_NAME_ENTRY_free(intname.s); ret = x509_name_canon(nm.x); if (!ret) goto err; nm.x->modified = 0; *val = nm.a; *in = p; return ret; err: if (nm.x != NULL) X509_NAME_free(nm.x); ASN1err(ASN1_F_X509_NAME_EX_D2I, ERR_R_NESTED_ASN1_ERROR); return 0; } static int x509_name_ex_i2d(ASN1_VALUE **val, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass) { int ret; X509_NAME *a = (X509_NAME *)*val; if (a->modified) { ret = x509_name_encode(a); if (ret < 0) return ret; ret = x509_name_canon(a); if (ret < 0) return ret; } ret = a->bytes->length; if (out != NULL) { memcpy(*out, a->bytes->data, ret); *out += ret; } return ret; } static void local_sk_X509_NAME_ENTRY_free(STACK_OF(X509_NAME_ENTRY) *ne) { sk_X509_NAME_ENTRY_free(ne); } static void local_sk_X509_NAME_ENTRY_pop_free(STACK_OF(X509_NAME_ENTRY) *ne) { sk_X509_NAME_ENTRY_pop_free(ne, X509_NAME_ENTRY_free); } static int x509_name_encode(X509_NAME *a) { union { STACK_OF(STACK_OF_X509_NAME_ENTRY) *s; ASN1_VALUE *a; } intname = {NULL}; int len; unsigned char *p; STACK_OF(X509_NAME_ENTRY) *entries = NULL; X509_NAME_ENTRY *entry; int i, set = -1; intname.s = sk_STACK_OF_X509_NAME_ENTRY_new_null(); if (!intname.s) goto memerr; for (i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) { entry = sk_X509_NAME_ENTRY_value(a->entries, i); if (entry->set != set) { entries = sk_X509_NAME_ENTRY_new_null(); if (!entries) goto memerr; if (!sk_STACK_OF_X509_NAME_ENTRY_push(intname.s, entries)) goto memerr; set = entry->set; } if (!sk_X509_NAME_ENTRY_push(entries, entry)) goto memerr; } len = ASN1_item_ex_i2d(&intname.a, NULL, ASN1_ITEM_rptr(X509_NAME_INTERNAL), -1, -1); if (!BUF_MEM_grow(a->bytes, len)) goto memerr; p = (unsigned char *)a->bytes->data; ASN1_item_ex_i2d(&intname.a, &p, ASN1_ITEM_rptr(X509_NAME_INTERNAL), -1, -1); sk_STACK_OF_X509_NAME_ENTRY_pop_free(intname.s, local_sk_X509_NAME_ENTRY_free); a->modified = 0; return len; memerr: sk_STACK_OF_X509_NAME_ENTRY_pop_free(intname.s, local_sk_X509_NAME_ENTRY_free); ASN1err(ASN1_F_X509_NAME_ENCODE, ERR_R_MALLOC_FAILURE); return -1; } static int x509_name_ex_print(BIO *out, ASN1_VALUE **pval, int indent, const char *fname, const ASN1_PCTX *pctx) { if (X509_NAME_print_ex(out, (X509_NAME *)*pval, indent, pctx->nm_flags) <= 0) return 0; return 2; } /* This function generates the canonical encoding of the Name structure. * In it all strings are converted to UTF8, leading, trailing and * multiple spaces collapsed, converted to lower case and the leading * SEQUENCE header removed. * * In future we could also normalize the UTF8 too. * * By doing this comparison of Name structures can be rapidly * perfomed by just using memcmp() of the canonical encoding. * By omitting the leading SEQUENCE name constraints of type * dirName can also be checked with a simple memcmp(). */ static int x509_name_canon(X509_NAME *a) { unsigned char *p; STACK_OF(STACK_OF_X509_NAME_ENTRY) *intname = NULL; STACK_OF(X509_NAME_ENTRY) *entries = NULL; X509_NAME_ENTRY *entry, *tmpentry = NULL; int i, set = -1, ret = 0; if (a->canon_enc) { free(a->canon_enc); a->canon_enc = NULL; } /* Special case: empty X509_NAME => null encoding */ if (sk_X509_NAME_ENTRY_num(a->entries) == 0) { a->canon_enclen = 0; return 1; } intname = sk_STACK_OF_X509_NAME_ENTRY_new_null(); if (!intname) goto err; for (i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) { entry = sk_X509_NAME_ENTRY_value(a->entries, i); if (entry->set != set) { entries = sk_X509_NAME_ENTRY_new_null(); if (!entries) goto err; if (!sk_STACK_OF_X509_NAME_ENTRY_push(intname, entries)) goto err; set = entry->set; } tmpentry = X509_NAME_ENTRY_new(); tmpentry->object = OBJ_dup(entry->object); if (!asn1_string_canon(tmpentry->value, entry->value)) goto err; if (!sk_X509_NAME_ENTRY_push(entries, tmpentry)) goto err; tmpentry = NULL; } /* Finally generate encoding */ a->canon_enclen = i2d_name_canon(intname, NULL); p = malloc(a->canon_enclen); if (!p) goto err; a->canon_enc = p; i2d_name_canon(intname, &p); ret = 1; err: if (tmpentry) X509_NAME_ENTRY_free(tmpentry); if (intname) sk_STACK_OF_X509_NAME_ENTRY_pop_free(intname, local_sk_X509_NAME_ENTRY_pop_free); return ret; } /* Bitmap of all the types of string that will be canonicalized. */ #define ASN1_MASK_CANON \ (B_ASN1_UTF8STRING | B_ASN1_BMPSTRING | B_ASN1_UNIVERSALSTRING \ | B_ASN1_PRINTABLESTRING | B_ASN1_T61STRING | B_ASN1_IA5STRING \ | B_ASN1_VISIBLESTRING) static int asn1_string_canon(ASN1_STRING *out, ASN1_STRING *in) { unsigned char *to, *from; int len, i; /* If type not in bitmask just copy string across */ if (!(ASN1_tag2bit(in->type) & ASN1_MASK_CANON)) { if (!ASN1_STRING_copy(out, in)) return 0; return 1; } out->type = V_ASN1_UTF8STRING; out->length = ASN1_STRING_to_UTF8(&out->data, in); if (out->length == -1) return 0; to = out->data; from = to; len = out->length; /* Convert string in place to canonical form. * Ultimately we may need to handle a wider range of characters * but for now ignore anything with MSB set and rely on the * isspace() and tolower() functions. */ /* Ignore leading spaces */ while ((len > 0) && !(*from & 0x80) && isspace(*from)) { from++; len--; } to = from + len - 1; /* Ignore trailing spaces */ while ((len > 0) && !(*to & 0x80) && isspace(*to)) { to--; len--; } to = out->data; i = 0; while (i < len) { /* If MSB set just copy across */ if (*from & 0x80) { *to++ = *from++; i++; } /* Collapse multiple spaces */ else if (isspace(*from)) { /* Copy one space across */ *to++ = ' '; /* Ignore subsequent spaces. Note: don't need to * check len here because we know the last * character is a non-space so we can't overflow. */ do { from++; i++; } while (!(*from & 0x80) && isspace(*from)); } else { *to++ = tolower(*from); from++; i++; } } out->length = to - out->data; return 1; } static int i2d_name_canon(STACK_OF(STACK_OF_X509_NAME_ENTRY) *_intname, unsigned char **in) { int i, len, ltmp; ASN1_VALUE *v; STACK_OF(ASN1_VALUE) *intname = (STACK_OF(ASN1_VALUE) *)_intname; len = 0; for (i = 0; i < sk_ASN1_VALUE_num(intname); i++) { v = sk_ASN1_VALUE_value(intname, i); ltmp = ASN1_item_ex_i2d(&v, in, ASN1_ITEM_rptr(X509_NAME_ENTRIES), -1, -1); if (ltmp < 0) return ltmp; len += ltmp; } return len; } int X509_NAME_set(X509_NAME **xn, X509_NAME *name) { X509_NAME *in; if (!xn || !name) return (0); if (*xn != name) { in = X509_NAME_dup(name); if (in != NULL) { X509_NAME_free(*xn); *xn = in; } } return (*xn != NULL); } IMPLEMENT_STACK_OF(X509_NAME_ENTRY) IMPLEMENT_ASN1_SET_OF(X509_NAME_ENTRY) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/asn1_err.c0000644000175000017500000004432712360020705021005 0ustar /* $OpenBSD: asn1_err.c,v 1.17 2014/06/12 15:49:27 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_ASN1,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_ASN1,0,reason) static ERR_STRING_DATA ASN1_str_functs[] = { {ERR_FUNC(ASN1_F_A2D_ASN1_OBJECT), "a2d_ASN1_OBJECT"}, {ERR_FUNC(ASN1_F_A2I_ASN1_ENUMERATED), "a2i_ASN1_ENUMERATED"}, {ERR_FUNC(ASN1_F_A2I_ASN1_INTEGER), "a2i_ASN1_INTEGER"}, {ERR_FUNC(ASN1_F_A2I_ASN1_STRING), "a2i_ASN1_STRING"}, {ERR_FUNC(ASN1_F_APPEND_EXP), "APPEND_EXP"}, {ERR_FUNC(ASN1_F_ASN1_BIT_STRING_SET_BIT), "ASN1_BIT_STRING_set_bit"}, {ERR_FUNC(ASN1_F_ASN1_CB), "ASN1_CB"}, {ERR_FUNC(ASN1_F_ASN1_CHECK_TLEN), "ASN1_CHECK_TLEN"}, {ERR_FUNC(ASN1_F_ASN1_COLLATE_PRIMITIVE), "ASN1_COLLATE_PRIMITIVE"}, {ERR_FUNC(ASN1_F_ASN1_COLLECT), "ASN1_COLLECT"}, {ERR_FUNC(ASN1_F_ASN1_D2I_EX_PRIMITIVE), "ASN1_D2I_EX_PRIMITIVE"}, {ERR_FUNC(ASN1_F_ASN1_D2I_FP), "ASN1_d2i_fp"}, {ERR_FUNC(ASN1_F_ASN1_D2I_READ_BIO), "ASN1_D2I_READ_BIO"}, {ERR_FUNC(ASN1_F_ASN1_DIGEST), "ASN1_digest"}, {ERR_FUNC(ASN1_F_ASN1_DO_ADB), "ASN1_DO_ADB"}, {ERR_FUNC(ASN1_F_ASN1_DUP), "ASN1_dup"}, {ERR_FUNC(ASN1_F_ASN1_ENUMERATED_SET), "ASN1_ENUMERATED_set"}, {ERR_FUNC(ASN1_F_ASN1_ENUMERATED_TO_BN), "ASN1_ENUMERATED_to_BN"}, {ERR_FUNC(ASN1_F_ASN1_EX_C2I), "ASN1_EX_C2I"}, {ERR_FUNC(ASN1_F_ASN1_FIND_END), "ASN1_FIND_END"}, {ERR_FUNC(ASN1_F_ASN1_GENERALIZEDTIME_ADJ), "ASN1_GENERALIZEDTIME_adj"}, {ERR_FUNC(ASN1_F_ASN1_GENERALIZEDTIME_SET), "ASN1_GENERALIZEDTIME_set"}, {ERR_FUNC(ASN1_F_ASN1_GENERATE_V3), "ASN1_generate_v3"}, {ERR_FUNC(ASN1_F_ASN1_GET_OBJECT), "ASN1_get_object"}, {ERR_FUNC(ASN1_F_ASN1_HEADER_NEW), "ASN1_HEADER_NEW"}, {ERR_FUNC(ASN1_F_ASN1_I2D_BIO), "ASN1_i2d_bio"}, {ERR_FUNC(ASN1_F_ASN1_I2D_FP), "ASN1_i2d_fp"}, {ERR_FUNC(ASN1_F_ASN1_INTEGER_SET), "ASN1_INTEGER_set"}, {ERR_FUNC(ASN1_F_ASN1_INTEGER_TO_BN), "ASN1_INTEGER_to_BN"}, {ERR_FUNC(ASN1_F_ASN1_ITEM_D2I_FP), "ASN1_item_d2i_fp"}, {ERR_FUNC(ASN1_F_ASN1_ITEM_DUP), "ASN1_item_dup"}, {ERR_FUNC(ASN1_F_ASN1_ITEM_EX_COMBINE_NEW), "ASN1_ITEM_EX_COMBINE_NEW"}, {ERR_FUNC(ASN1_F_ASN1_ITEM_EX_D2I), "ASN1_ITEM_EX_D2I"}, {ERR_FUNC(ASN1_F_ASN1_ITEM_I2D_BIO), "ASN1_item_i2d_bio"}, {ERR_FUNC(ASN1_F_ASN1_ITEM_I2D_FP), "ASN1_item_i2d_fp"}, {ERR_FUNC(ASN1_F_ASN1_ITEM_PACK), "ASN1_item_pack"}, {ERR_FUNC(ASN1_F_ASN1_ITEM_SIGN), "ASN1_item_sign"}, {ERR_FUNC(ASN1_F_ASN1_ITEM_SIGN_CTX), "ASN1_item_sign_ctx"}, {ERR_FUNC(ASN1_F_ASN1_ITEM_UNPACK), "ASN1_item_unpack"}, {ERR_FUNC(ASN1_F_ASN1_ITEM_VERIFY), "ASN1_item_verify"}, {ERR_FUNC(ASN1_F_ASN1_MBSTRING_NCOPY), "ASN1_mbstring_ncopy"}, {ERR_FUNC(ASN1_F_ASN1_OBJECT_NEW), "ASN1_OBJECT_new"}, {ERR_FUNC(ASN1_F_ASN1_OUTPUT_DATA), "ASN1_OUTPUT_DATA"}, {ERR_FUNC(ASN1_F_ASN1_PACK_STRING), "ASN1_pack_string"}, {ERR_FUNC(ASN1_F_ASN1_PCTX_NEW), "ASN1_PCTX_new"}, {ERR_FUNC(ASN1_F_ASN1_PKCS5_PBE_SET), "ASN1_PKCS5_PBE_SET"}, {ERR_FUNC(ASN1_F_ASN1_SEQ_PACK), "ASN1_seq_pack"}, {ERR_FUNC(ASN1_F_ASN1_SEQ_UNPACK), "ASN1_seq_unpack"}, {ERR_FUNC(ASN1_F_ASN1_SIGN), "ASN1_sign"}, {ERR_FUNC(ASN1_F_ASN1_STR2TYPE), "ASN1_STR2TYPE"}, {ERR_FUNC(ASN1_F_ASN1_STRING_SET), "ASN1_STRING_set"}, {ERR_FUNC(ASN1_F_ASN1_STRING_TABLE_ADD), "ASN1_STRING_TABLE_add"}, {ERR_FUNC(ASN1_F_ASN1_STRING_TYPE_NEW), "ASN1_STRING_type_new"}, {ERR_FUNC(ASN1_F_ASN1_TEMPLATE_EX_D2I), "ASN1_TEMPLATE_EX_D2I"}, {ERR_FUNC(ASN1_F_ASN1_TEMPLATE_NEW), "ASN1_TEMPLATE_NEW"}, {ERR_FUNC(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I), "ASN1_TEMPLATE_NOEXP_D2I"}, {ERR_FUNC(ASN1_F_ASN1_TIME_ADJ), "ASN1_TIME_adj"}, {ERR_FUNC(ASN1_F_ASN1_TIME_SET), "ASN1_TIME_set"}, {ERR_FUNC(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING), "ASN1_TYPE_get_int_octetstring"}, {ERR_FUNC(ASN1_F_ASN1_TYPE_GET_OCTETSTRING), "ASN1_TYPE_get_octetstring"}, {ERR_FUNC(ASN1_F_ASN1_UNPACK_STRING), "ASN1_unpack_string"}, {ERR_FUNC(ASN1_F_ASN1_UTCTIME_ADJ), "ASN1_UTCTIME_adj"}, {ERR_FUNC(ASN1_F_ASN1_UTCTIME_SET), "ASN1_UTCTIME_set"}, {ERR_FUNC(ASN1_F_ASN1_VERIFY), "ASN1_verify"}, {ERR_FUNC(ASN1_F_B64_READ_ASN1), "B64_READ_ASN1"}, {ERR_FUNC(ASN1_F_B64_WRITE_ASN1), "B64_WRITE_ASN1"}, {ERR_FUNC(ASN1_F_BIO_NEW_NDEF), "BIO_new_NDEF"}, {ERR_FUNC(ASN1_F_BITSTR_CB), "BITSTR_CB"}, {ERR_FUNC(ASN1_F_BN_TO_ASN1_ENUMERATED), "BN_to_ASN1_ENUMERATED"}, {ERR_FUNC(ASN1_F_BN_TO_ASN1_INTEGER), "BN_to_ASN1_INTEGER"}, {ERR_FUNC(ASN1_F_C2I_ASN1_BIT_STRING), "c2i_ASN1_BIT_STRING"}, {ERR_FUNC(ASN1_F_C2I_ASN1_INTEGER), "c2i_ASN1_INTEGER"}, {ERR_FUNC(ASN1_F_C2I_ASN1_OBJECT), "c2i_ASN1_OBJECT"}, {ERR_FUNC(ASN1_F_COLLECT_DATA), "COLLECT_DATA"}, {ERR_FUNC(ASN1_F_D2I_ASN1_BIT_STRING), "D2I_ASN1_BIT_STRING"}, {ERR_FUNC(ASN1_F_D2I_ASN1_BOOLEAN), "d2i_ASN1_BOOLEAN"}, {ERR_FUNC(ASN1_F_D2I_ASN1_BYTES), "d2i_ASN1_bytes"}, {ERR_FUNC(ASN1_F_D2I_ASN1_GENERALIZEDTIME), "D2I_ASN1_GENERALIZEDTIME"}, {ERR_FUNC(ASN1_F_D2I_ASN1_HEADER), "D2I_ASN1_HEADER"}, {ERR_FUNC(ASN1_F_D2I_ASN1_INTEGER), "D2I_ASN1_INTEGER"}, {ERR_FUNC(ASN1_F_D2I_ASN1_OBJECT), "d2i_ASN1_OBJECT"}, {ERR_FUNC(ASN1_F_D2I_ASN1_SET), "d2i_ASN1_SET"}, {ERR_FUNC(ASN1_F_D2I_ASN1_TYPE_BYTES), "d2i_ASN1_type_bytes"}, {ERR_FUNC(ASN1_F_D2I_ASN1_UINTEGER), "d2i_ASN1_UINTEGER"}, {ERR_FUNC(ASN1_F_D2I_ASN1_UTCTIME), "D2I_ASN1_UTCTIME"}, {ERR_FUNC(ASN1_F_D2I_AUTOPRIVATEKEY), "d2i_AutoPrivateKey"}, {ERR_FUNC(ASN1_F_D2I_NETSCAPE_RSA), "d2i_Netscape_RSA"}, {ERR_FUNC(ASN1_F_D2I_NETSCAPE_RSA_2), "D2I_NETSCAPE_RSA_2"}, {ERR_FUNC(ASN1_F_D2I_PRIVATEKEY), "d2i_PrivateKey"}, {ERR_FUNC(ASN1_F_D2I_PUBLICKEY), "d2i_PublicKey"}, {ERR_FUNC(ASN1_F_D2I_RSA_NET), "d2i_RSA_NET"}, {ERR_FUNC(ASN1_F_D2I_RSA_NET_2), "D2I_RSA_NET_2"}, {ERR_FUNC(ASN1_F_D2I_X509), "D2I_X509"}, {ERR_FUNC(ASN1_F_D2I_X509_CINF), "D2I_X509_CINF"}, {ERR_FUNC(ASN1_F_D2I_X509_PKEY), "d2i_X509_PKEY"}, {ERR_FUNC(ASN1_F_I2D_ASN1_BIO_STREAM), "i2d_ASN1_bio_stream"}, {ERR_FUNC(ASN1_F_I2D_ASN1_SET), "i2d_ASN1_SET"}, {ERR_FUNC(ASN1_F_I2D_ASN1_TIME), "I2D_ASN1_TIME"}, {ERR_FUNC(ASN1_F_I2D_DSA_PUBKEY), "i2d_DSA_PUBKEY"}, {ERR_FUNC(ASN1_F_I2D_EC_PUBKEY), "i2d_EC_PUBKEY"}, {ERR_FUNC(ASN1_F_I2D_PRIVATEKEY), "i2d_PrivateKey"}, {ERR_FUNC(ASN1_F_I2D_PUBLICKEY), "i2d_PublicKey"}, {ERR_FUNC(ASN1_F_I2D_RSA_NET), "i2d_RSA_NET"}, {ERR_FUNC(ASN1_F_I2D_RSA_PUBKEY), "i2d_RSA_PUBKEY"}, {ERR_FUNC(ASN1_F_LONG_C2I), "LONG_C2I"}, {ERR_FUNC(ASN1_F_OID_MODULE_INIT), "OID_MODULE_INIT"}, {ERR_FUNC(ASN1_F_PARSE_TAGGING), "PARSE_TAGGING"}, {ERR_FUNC(ASN1_F_PKCS5_PBE2_SET_IV), "PKCS5_pbe2_set_iv"}, {ERR_FUNC(ASN1_F_PKCS5_PBE_SET), "PKCS5_pbe_set"}, {ERR_FUNC(ASN1_F_PKCS5_PBE_SET0_ALGOR), "PKCS5_pbe_set0_algor"}, {ERR_FUNC(ASN1_F_PKCS5_PBKDF2_SET), "PKCS5_pbkdf2_set"}, {ERR_FUNC(ASN1_F_SMIME_READ_ASN1), "SMIME_read_ASN1"}, {ERR_FUNC(ASN1_F_SMIME_TEXT), "SMIME_text"}, {ERR_FUNC(ASN1_F_X509_CINF_NEW), "X509_CINF_NEW"}, {ERR_FUNC(ASN1_F_X509_CRL_ADD0_REVOKED), "X509_CRL_add0_revoked"}, {ERR_FUNC(ASN1_F_X509_INFO_NEW), "X509_INFO_new"}, {ERR_FUNC(ASN1_F_X509_NAME_ENCODE), "X509_NAME_ENCODE"}, {ERR_FUNC(ASN1_F_X509_NAME_EX_D2I), "X509_NAME_EX_D2I"}, {ERR_FUNC(ASN1_F_X509_NAME_EX_NEW), "X509_NAME_EX_NEW"}, {ERR_FUNC(ASN1_F_X509_NEW), "X509_NEW"}, {ERR_FUNC(ASN1_F_X509_PKEY_NEW), "X509_PKEY_new"}, {0, NULL} }; static ERR_STRING_DATA ASN1_str_reasons[]= { {ERR_REASON(ASN1_R_ADDING_OBJECT) , "adding object"}, {ERR_REASON(ASN1_R_ASN1_PARSE_ERROR) , "asn1 parse error"}, {ERR_REASON(ASN1_R_ASN1_SIG_PARSE_ERROR) , "asn1 sig parse error"}, {ERR_REASON(ASN1_R_AUX_ERROR) , "aux error"}, {ERR_REASON(ASN1_R_BAD_CLASS) , "bad class"}, {ERR_REASON(ASN1_R_BAD_OBJECT_HEADER) , "bad object header"}, {ERR_REASON(ASN1_R_BAD_PASSWORD_READ) , "bad password read"}, {ERR_REASON(ASN1_R_BAD_TAG) , "bad tag"}, {ERR_REASON(ASN1_R_BMPSTRING_IS_WRONG_LENGTH), "bmpstring is wrong length"}, {ERR_REASON(ASN1_R_BN_LIB) , "bn lib"}, {ERR_REASON(ASN1_R_BOOLEAN_IS_WRONG_LENGTH), "boolean is wrong length"}, {ERR_REASON(ASN1_R_BUFFER_TOO_SMALL) , "buffer too small"}, {ERR_REASON(ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER), "cipher has no object identifier"}, {ERR_REASON(ASN1_R_CONTEXT_NOT_INITIALISED), "context not initialised"}, {ERR_REASON(ASN1_R_DATA_IS_WRONG) , "data is wrong"}, {ERR_REASON(ASN1_R_DECODE_ERROR) , "decode error"}, {ERR_REASON(ASN1_R_DECODING_ERROR) , "decoding error"}, {ERR_REASON(ASN1_R_DEPTH_EXCEEDED) , "depth exceeded"}, {ERR_REASON(ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED), "digest and key type not supported"}, {ERR_REASON(ASN1_R_ENCODE_ERROR) , "encode error"}, {ERR_REASON(ASN1_R_ERROR_GETTING_TIME) , "error getting time"}, {ERR_REASON(ASN1_R_ERROR_LOADING_SECTION), "error loading section"}, {ERR_REASON(ASN1_R_ERROR_PARSING_SET_ELEMENT), "error parsing set element"}, {ERR_REASON(ASN1_R_ERROR_SETTING_CIPHER_PARAMS), "error setting cipher params"}, {ERR_REASON(ASN1_R_EXPECTING_AN_INTEGER) , "expecting an integer"}, {ERR_REASON(ASN1_R_EXPECTING_AN_OBJECT) , "expecting an object"}, {ERR_REASON(ASN1_R_EXPECTING_A_BOOLEAN) , "expecting a boolean"}, {ERR_REASON(ASN1_R_EXPECTING_A_TIME) , "expecting a time"}, {ERR_REASON(ASN1_R_EXPLICIT_LENGTH_MISMATCH), "explicit length mismatch"}, {ERR_REASON(ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED), "explicit tag not constructed"}, {ERR_REASON(ASN1_R_FIELD_MISSING) , "field missing"}, {ERR_REASON(ASN1_R_FIRST_NUM_TOO_LARGE) , "first num too large"}, {ERR_REASON(ASN1_R_HEADER_TOO_LONG) , "header too long"}, {ERR_REASON(ASN1_R_ILLEGAL_BITSTRING_FORMAT), "illegal bitstring format"}, {ERR_REASON(ASN1_R_ILLEGAL_BOOLEAN) , "illegal boolean"}, {ERR_REASON(ASN1_R_ILLEGAL_CHARACTERS) , "illegal characters"}, {ERR_REASON(ASN1_R_ILLEGAL_FORMAT) , "illegal format"}, {ERR_REASON(ASN1_R_ILLEGAL_HEX) , "illegal hex"}, {ERR_REASON(ASN1_R_ILLEGAL_IMPLICIT_TAG) , "illegal implicit tag"}, {ERR_REASON(ASN1_R_ILLEGAL_INTEGER) , "illegal integer"}, {ERR_REASON(ASN1_R_ILLEGAL_NESTED_TAGGING), "illegal nested tagging"}, {ERR_REASON(ASN1_R_ILLEGAL_NULL) , "illegal null"}, {ERR_REASON(ASN1_R_ILLEGAL_NULL_VALUE) , "illegal null value"}, {ERR_REASON(ASN1_R_ILLEGAL_OBJECT) , "illegal object"}, {ERR_REASON(ASN1_R_ILLEGAL_OPTIONAL_ANY) , "illegal optional any"}, {ERR_REASON(ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE), "illegal options on item template"}, {ERR_REASON(ASN1_R_ILLEGAL_TAGGED_ANY) , "illegal tagged any"}, {ERR_REASON(ASN1_R_ILLEGAL_TIME_VALUE) , "illegal time value"}, {ERR_REASON(ASN1_R_INTEGER_NOT_ASCII_FORMAT), "integer not ascii format"}, {ERR_REASON(ASN1_R_INTEGER_TOO_LARGE_FOR_LONG), "integer too large for long"}, {ERR_REASON(ASN1_R_INVALID_BMPSTRING_LENGTH), "invalid bmpstring length"}, {ERR_REASON(ASN1_R_INVALID_DIGIT) , "invalid digit"}, {ERR_REASON(ASN1_R_INVALID_MIME_TYPE) , "invalid mime type"}, {ERR_REASON(ASN1_R_INVALID_MODIFIER) , "invalid modifier"}, {ERR_REASON(ASN1_R_INVALID_NUMBER) , "invalid number"}, {ERR_REASON(ASN1_R_INVALID_OBJECT_ENCODING), "invalid object encoding"}, {ERR_REASON(ASN1_R_INVALID_SEPARATOR) , "invalid separator"}, {ERR_REASON(ASN1_R_INVALID_TIME_FORMAT) , "invalid time format"}, {ERR_REASON(ASN1_R_INVALID_UNIVERSALSTRING_LENGTH), "invalid universalstring length"}, {ERR_REASON(ASN1_R_INVALID_UTF8STRING) , "invalid utf8string"}, {ERR_REASON(ASN1_R_IV_TOO_LARGE) , "iv too large"}, {ERR_REASON(ASN1_R_LENGTH_ERROR) , "length error"}, {ERR_REASON(ASN1_R_LIST_ERROR) , "list error"}, {ERR_REASON(ASN1_R_MIME_NO_CONTENT_TYPE) , "mime no content type"}, {ERR_REASON(ASN1_R_MIME_PARSE_ERROR) , "mime parse error"}, {ERR_REASON(ASN1_R_MIME_SIG_PARSE_ERROR) , "mime sig parse error"}, {ERR_REASON(ASN1_R_MISSING_EOC) , "missing eoc"}, {ERR_REASON(ASN1_R_MISSING_SECOND_NUMBER), "missing second number"}, {ERR_REASON(ASN1_R_MISSING_VALUE) , "missing value"}, {ERR_REASON(ASN1_R_MSTRING_NOT_UNIVERSAL), "mstring not universal"}, {ERR_REASON(ASN1_R_MSTRING_WRONG_TAG) , "mstring wrong tag"}, {ERR_REASON(ASN1_R_NESTED_ASN1_STRING) , "nested asn1 string"}, {ERR_REASON(ASN1_R_NON_HEX_CHARACTERS) , "non hex characters"}, {ERR_REASON(ASN1_R_NOT_ASCII_FORMAT) , "not ascii format"}, {ERR_REASON(ASN1_R_NOT_ENOUGH_DATA) , "not enough data"}, {ERR_REASON(ASN1_R_NO_CONTENT_TYPE) , "no content type"}, {ERR_REASON(ASN1_R_NO_DEFAULT_DIGEST) , "no default digest"}, {ERR_REASON(ASN1_R_NO_MATCHING_CHOICE_TYPE), "no matching choice type"}, {ERR_REASON(ASN1_R_NO_MULTIPART_BODY_FAILURE), "no multipart body failure"}, {ERR_REASON(ASN1_R_NO_MULTIPART_BOUNDARY), "no multipart boundary"}, {ERR_REASON(ASN1_R_NO_SIG_CONTENT_TYPE) , "no sig content type"}, {ERR_REASON(ASN1_R_NULL_IS_WRONG_LENGTH) , "null is wrong length"}, {ERR_REASON(ASN1_R_OBJECT_NOT_ASCII_FORMAT), "object not ascii format"}, {ERR_REASON(ASN1_R_ODD_NUMBER_OF_CHARS) , "odd number of chars"}, {ERR_REASON(ASN1_R_PRIVATE_KEY_HEADER_MISSING), "private key header missing"}, {ERR_REASON(ASN1_R_SECOND_NUMBER_TOO_LARGE), "second number too large"}, {ERR_REASON(ASN1_R_SEQUENCE_LENGTH_MISMATCH), "sequence length mismatch"}, {ERR_REASON(ASN1_R_SEQUENCE_NOT_CONSTRUCTED), "sequence not constructed"}, {ERR_REASON(ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG), "sequence or set needs config"}, {ERR_REASON(ASN1_R_SHORT_LINE) , "short line"}, {ERR_REASON(ASN1_R_SIG_INVALID_MIME_TYPE), "sig invalid mime type"}, {ERR_REASON(ASN1_R_STREAMING_NOT_SUPPORTED), "streaming not supported"}, {ERR_REASON(ASN1_R_STRING_TOO_LONG) , "string too long"}, {ERR_REASON(ASN1_R_STRING_TOO_SHORT) , "string too short"}, {ERR_REASON(ASN1_R_TAG_VALUE_TOO_HIGH) , "tag value too high"}, {ERR_REASON(ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD), "the asn1 object identifier is not known for this md"}, {ERR_REASON(ASN1_R_TIME_NOT_ASCII_FORMAT), "time not ascii format"}, {ERR_REASON(ASN1_R_TOO_LONG) , "too long"}, {ERR_REASON(ASN1_R_TYPE_NOT_CONSTRUCTED) , "type not constructed"}, {ERR_REASON(ASN1_R_UNABLE_TO_DECODE_RSA_KEY), "unable to decode rsa key"}, {ERR_REASON(ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY), "unable to decode rsa private key"}, {ERR_REASON(ASN1_R_UNEXPECTED_EOC) , "unexpected eoc"}, {ERR_REASON(ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH), "universalstring is wrong length"}, {ERR_REASON(ASN1_R_UNKNOWN_FORMAT) , "unknown format"}, {ERR_REASON(ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM), "unknown message digest algorithm"}, {ERR_REASON(ASN1_R_UNKNOWN_OBJECT_TYPE) , "unknown object type"}, {ERR_REASON(ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE), "unknown public key type"}, {ERR_REASON(ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM), "unknown signature algorithm"}, {ERR_REASON(ASN1_R_UNKNOWN_TAG) , "unknown tag"}, {ERR_REASON(ASN1_R_UNKOWN_FORMAT) , "unknown format"}, {ERR_REASON(ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE), "unsupported any defined by type"}, {ERR_REASON(ASN1_R_UNSUPPORTED_CIPHER) , "unsupported cipher"}, {ERR_REASON(ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM), "unsupported encryption algorithm"}, {ERR_REASON(ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE), "unsupported public key type"}, {ERR_REASON(ASN1_R_UNSUPPORTED_TYPE) , "unsupported type"}, {ERR_REASON(ASN1_R_WRONG_PUBLIC_KEY_TYPE), "wrong public key type"}, {ERR_REASON(ASN1_R_WRONG_TAG) , "wrong tag"}, {ERR_REASON(ASN1_R_WRONG_TYPE) , "wrong type"}, {0, NULL} }; #endif void ERR_load_ASN1_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(ASN1_str_functs[0].error) == NULL) { ERR_load_strings(0, ASN1_str_functs); ERR_load_strings(0, ASN1_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_mbstr.c0000644000175000017500000002625712360020705020724 0ustar /* $OpenBSD: a_mbstr.c,v 1.18 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include "asn1_locl.h" static int traverse_string(const unsigned char *p, int len, int inform, int (*rfunc)(unsigned long value, void *in), void *arg); static int in_utf8(unsigned long value, void *arg); static int out_utf8(unsigned long value, void *arg); static int type_str(unsigned long value, void *arg); static int cpy_asc(unsigned long value, void *arg); static int cpy_bmp(unsigned long value, void *arg); static int cpy_univ(unsigned long value, void *arg); static int cpy_utf8(unsigned long value, void *arg); static int is_printable(unsigned long value); /* These functions take a string in UTF8, ASCII or multibyte form and * a mask of permissible ASN1 string types. It then works out the minimal * type (using the order Printable < IA5 < T61 < BMP < Universal < UTF8) * and creates a string of the correct type with the supplied data. * Yes this is horrible: it has to be :-( * The 'ncopy' form checks minimum and maximum size limits too. */ int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, int inform, unsigned long mask) { return ASN1_mbstring_ncopy(out, in, len, inform, mask, 0, 0); } int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, int inform, unsigned long mask, long minsize, long maxsize) { int str_type; int ret; char free_out; int outform, outlen = 0; ASN1_STRING *dest; unsigned char *p; int nchar; int (*cpyfunc)(unsigned long, void *) = NULL; if (len == -1) len = strlen((const char *)in); if (!mask) mask = DIRSTRING_TYPE; /* First do a string check and work out the number of characters */ switch (inform) { case MBSTRING_BMP: if (len & 1) { ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_INVALID_BMPSTRING_LENGTH); return -1; } nchar = len >> 1; break; case MBSTRING_UNIV: if (len & 3) { ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_INVALID_UNIVERSALSTRING_LENGTH); return -1; } nchar = len >> 2; break; case MBSTRING_UTF8: nchar = 0; /* This counts the characters and does utf8 syntax checking */ ret = traverse_string(in, len, MBSTRING_UTF8, in_utf8, &nchar); if (ret < 0) { ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_INVALID_UTF8STRING); return -1; } break; case MBSTRING_ASC: nchar = len; break; default: ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_UNKNOWN_FORMAT); return -1; } if ((minsize > 0) && (nchar < minsize)) { ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_STRING_TOO_SHORT); ERR_asprintf_error_data("minsize=%ld", minsize); return -1; } if ((maxsize > 0) && (nchar > maxsize)) { ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_STRING_TOO_LONG); ERR_asprintf_error_data("maxsize=%ld", maxsize); return -1; } /* Now work out minimal type (if any) */ if (traverse_string(in, len, inform, type_str, &mask) < 0) { ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_ILLEGAL_CHARACTERS); return -1; } /* Now work out output format and string type */ outform = MBSTRING_ASC; if (mask & B_ASN1_PRINTABLESTRING) str_type = V_ASN1_PRINTABLESTRING; else if (mask & B_ASN1_IA5STRING) str_type = V_ASN1_IA5STRING; else if (mask & B_ASN1_T61STRING) str_type = V_ASN1_T61STRING; else if (mask & B_ASN1_BMPSTRING) { str_type = V_ASN1_BMPSTRING; outform = MBSTRING_BMP; } else if (mask & B_ASN1_UNIVERSALSTRING) { str_type = V_ASN1_UNIVERSALSTRING; outform = MBSTRING_UNIV; } else { str_type = V_ASN1_UTF8STRING; outform = MBSTRING_UTF8; } if (!out) return str_type; if (*out) { free_out = 0; dest = *out; if (dest->data) { dest->length = 0; free(dest->data); dest->data = NULL; } dest->type = str_type; } else { free_out = 1; dest = ASN1_STRING_type_new(str_type); if (!dest) { ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ERR_R_MALLOC_FAILURE); return -1; } *out = dest; } /* If both the same type just copy across */ if (inform == outform) { if (!ASN1_STRING_set(dest, in, len)) { ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ERR_R_MALLOC_FAILURE); return -1; } return str_type; } /* Work out how much space the destination will need */ switch (outform) { case MBSTRING_ASC: outlen = nchar; cpyfunc = cpy_asc; break; case MBSTRING_BMP: outlen = nchar << 1; cpyfunc = cpy_bmp; break; case MBSTRING_UNIV: outlen = nchar << 2; cpyfunc = cpy_univ; break; case MBSTRING_UTF8: outlen = 0; if (traverse_string(in, len, inform, out_utf8, &outlen) < 0) { ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_ILLEGAL_CHARACTERS); return -1; } cpyfunc = cpy_utf8; break; } if (!(p = malloc(outlen + 1))) { if (free_out) ASN1_STRING_free(dest); ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ERR_R_MALLOC_FAILURE); return -1; } dest->length = outlen; dest->data = p; p[outlen] = 0; traverse_string(in, len, inform, cpyfunc, &p); return str_type; } /* This function traverses a string and passes the value of each character * to an optional function along with a void * argument. */ static int traverse_string(const unsigned char *p, int len, int inform, int (*rfunc)(unsigned long value, void *in), void *arg) { unsigned long value; int ret; while (len) { if (inform == MBSTRING_ASC) { value = *p++; len--; } else if (inform == MBSTRING_BMP) { value = *p++ << 8; value |= *p++; /* BMP is explictly defined to not support surrogates */ if (UNICODE_IS_SURROGATE(value)) return -1; len -= 2; } else if (inform == MBSTRING_UNIV) { value = ((unsigned long)*p++) << 24; value |= ((unsigned long)*p++) << 16; value |= *p++ << 8; value |= *p++; if (value > UNICODE_MAX || UNICODE_IS_SURROGATE(value)) return -1; len -= 4; } else { ret = UTF8_getc(p, len, &value); if (ret < 0) return -1; len -= ret; p += ret; } if (rfunc) { ret = rfunc(value, arg); if (ret <= 0) return ret; } } return 1; } /* Various utility functions for traverse_string */ /* Just count number of characters */ static int in_utf8(unsigned long value, void *arg) { int *nchar; nchar = arg; (*nchar)++; return 1; } /* Determine size of output as a UTF8 String */ static int out_utf8(unsigned long value, void *arg) { int *outlen; int ret; outlen = arg; ret = UTF8_putc(NULL, -1, value); if (ret < 0) return ret; *outlen += ret; return 1; } /* Determine the "type" of a string: check each character against a * supplied "mask". */ static int type_str(unsigned long value, void *arg) { unsigned long types; types = *((unsigned long *)arg); if ((types & B_ASN1_PRINTABLESTRING) && !is_printable(value)) types &= ~B_ASN1_PRINTABLESTRING; if ((types & B_ASN1_IA5STRING) && (value > 127)) types &= ~B_ASN1_IA5STRING; if ((types & B_ASN1_T61STRING) && (value > 0xff)) types &= ~B_ASN1_T61STRING; if ((types & B_ASN1_BMPSTRING) && (value > 0xffff)) types &= ~B_ASN1_BMPSTRING; if (!types) return -1; *((unsigned long *)arg) = types; return 1; } /* Copy one byte per character ASCII like strings */ static int cpy_asc(unsigned long value, void *arg) { unsigned char **p, *q; p = arg; q = *p; *q = (unsigned char) value; (*p)++; return 1; } /* Copy two byte per character BMPStrings */ static int cpy_bmp(unsigned long value, void *arg) { unsigned char **p, *q; p = arg; q = *p; *q++ = (unsigned char) ((value >> 8) & 0xff); *q = (unsigned char) (value & 0xff); *p += 2; return 1; } /* Copy four byte per character UniversalStrings */ static int cpy_univ(unsigned long value, void *arg) { unsigned char **p, *q; p = arg; q = *p; *q++ = (unsigned char) ((value >> 24) & 0xff); *q++ = (unsigned char) ((value >> 16) & 0xff); *q++ = (unsigned char) ((value >> 8) & 0xff); *q = (unsigned char) (value & 0xff); *p += 4; return 1; } /* Copy to a UTF8String */ static int cpy_utf8(unsigned long value, void *arg) { unsigned char **p; int ret; p = arg; /* We already know there is enough room so pass 0xff as the length */ ret = UTF8_putc(*p, 0xff, value); *p += ret; return 1; } /* Return 1 if the character is permitted in a PrintableString */ static int is_printable(unsigned long value) { int ch; if (value > 0x7f) return 0; ch = (int)value; /* Note: we can't use 'isalnum' because certain accented * characters may count as alphanumeric in some environments. */ if ((ch >= 'a') && (ch <= 'z')) return 1; if ((ch >= 'A') && (ch <= 'Z')) return 1; if ((ch >= '0') && (ch <= '9')) return 1; if ((ch == ' ') || strchr("'()+,-./:=?", ch)) return 1; return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/tasn_new.c0000644000175000017500000002214312360020705021101 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000-2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine); static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it); static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); static void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it); ASN1_VALUE * ASN1_item_new(const ASN1_ITEM *it) { ASN1_VALUE *ret = NULL; if (ASN1_item_ex_new(&ret, it) > 0) return ret; return NULL; } /* Allocate an ASN1 structure */ int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it) { return asn1_item_ex_combine_new(pval, it, 0); } static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine) { const ASN1_TEMPLATE *tt = NULL; const ASN1_COMPAT_FUNCS *cf; const ASN1_EXTERN_FUNCS *ef; const ASN1_AUX *aux = it->funcs; ASN1_aux_cb *asn1_cb; ASN1_VALUE **pseqval; int i; if (aux && aux->asn1_cb) asn1_cb = aux->asn1_cb; else asn1_cb = 0; if (!combine) *pval = NULL; #ifdef CRYPTO_MDEBUG if (it->sname) CRYPTO_push_info(it->sname); #endif switch (it->itype) { case ASN1_ITYPE_EXTERN: ef = it->funcs; if (ef && ef->asn1_ex_new) { if (!ef->asn1_ex_new(pval, it)) goto memerr; } break; case ASN1_ITYPE_COMPAT: cf = it->funcs; if (cf && cf->asn1_new) { *pval = cf->asn1_new(); if (!*pval) goto memerr; } break; case ASN1_ITYPE_PRIMITIVE: if (it->templates) { if (!ASN1_template_new(pval, it->templates)) goto memerr; } else if (!ASN1_primitive_new(pval, it)) goto memerr; break; case ASN1_ITYPE_MSTRING: if (!ASN1_primitive_new(pval, it)) goto memerr; break; case ASN1_ITYPE_CHOICE: if (asn1_cb) { i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL); if (!i) goto auxerr; if (i == 2) { #ifdef CRYPTO_MDEBUG if (it->sname) CRYPTO_pop_info(); #endif return 1; } } if (!combine) { *pval = calloc(1, it->size); if (!*pval) goto memerr; } asn1_set_choice_selector(pval, -1, it); if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL)) goto auxerr; break; case ASN1_ITYPE_NDEF_SEQUENCE: case ASN1_ITYPE_SEQUENCE: if (asn1_cb) { i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL); if (!i) goto auxerr; if (i == 2) { #ifdef CRYPTO_MDEBUG if (it->sname) CRYPTO_pop_info(); #endif return 1; } } if (!combine) { *pval = calloc(1, it->size); if (!*pval) goto memerr; asn1_do_lock(pval, 0, it); asn1_enc_init(pval, it); } for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) { pseqval = asn1_get_field_ptr(pval, tt); if (!ASN1_template_new(pseqval, tt)) goto memerr; } if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL)) goto auxerr; break; } #ifdef CRYPTO_MDEBUG if (it->sname) CRYPTO_pop_info(); #endif return 1; memerr: ASN1err(ASN1_F_ASN1_ITEM_EX_COMBINE_NEW, ERR_R_MALLOC_FAILURE); #ifdef CRYPTO_MDEBUG if (it->sname) CRYPTO_pop_info(); #endif return 0; auxerr: ASN1err(ASN1_F_ASN1_ITEM_EX_COMBINE_NEW, ASN1_R_AUX_ERROR); ASN1_item_ex_free(pval, it); #ifdef CRYPTO_MDEBUG if (it->sname) CRYPTO_pop_info(); #endif return 0; } static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it) { const ASN1_EXTERN_FUNCS *ef; switch (it->itype) { case ASN1_ITYPE_EXTERN: ef = it->funcs; if (ef && ef->asn1_ex_clear) ef->asn1_ex_clear(pval, it); else *pval = NULL; break; case ASN1_ITYPE_PRIMITIVE: if (it->templates) asn1_template_clear(pval, it->templates); else asn1_primitive_clear(pval, it); break; case ASN1_ITYPE_MSTRING: asn1_primitive_clear(pval, it); break; case ASN1_ITYPE_COMPAT: case ASN1_ITYPE_CHOICE: case ASN1_ITYPE_SEQUENCE: case ASN1_ITYPE_NDEF_SEQUENCE: *pval = NULL; break; } } int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) { const ASN1_ITEM *it = ASN1_ITEM_ptr(tt->item); int ret; if (tt->flags & ASN1_TFLG_OPTIONAL) { asn1_template_clear(pval, tt); return 1; } /* If ANY DEFINED BY nothing to do */ if (tt->flags & ASN1_TFLG_ADB_MASK) { *pval = NULL; return 1; } #ifdef CRYPTO_MDEBUG if (tt->field_name) CRYPTO_push_info(tt->field_name); #endif /* If SET OF or SEQUENCE OF, its a STACK */ if (tt->flags & ASN1_TFLG_SK_MASK) { STACK_OF(ASN1_VALUE) *skval; skval = sk_ASN1_VALUE_new_null(); if (!skval) { ASN1err(ASN1_F_ASN1_TEMPLATE_NEW, ERR_R_MALLOC_FAILURE); ret = 0; goto done; } *pval = (ASN1_VALUE *)skval; ret = 1; goto done; } /* Otherwise pass it back to the item routine */ ret = asn1_item_ex_combine_new(pval, it, tt->flags & ASN1_TFLG_COMBINE); done: #ifdef CRYPTO_MDEBUG if (it->sname) CRYPTO_pop_info(); #endif return ret; } static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) { /* If ADB or STACK just NULL the field */ if (tt->flags & (ASN1_TFLG_ADB_MASK|ASN1_TFLG_SK_MASK)) *pval = NULL; else asn1_item_clear(pval, ASN1_ITEM_ptr(tt->item)); } /* NB: could probably combine most of the real XXX_new() behaviour and junk * all the old functions. */ int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it) { ASN1_TYPE *typ; ASN1_STRING *str; int utype; if (it && it->funcs) { const ASN1_PRIMITIVE_FUNCS *pf = it->funcs; if (pf->prim_new) return pf->prim_new(pval, it); } if (!it || (it->itype == ASN1_ITYPE_MSTRING)) utype = -1; else utype = it->utype; switch (utype) { case V_ASN1_OBJECT: *pval = (ASN1_VALUE *)OBJ_nid2obj(NID_undef); return 1; case V_ASN1_BOOLEAN: *(ASN1_BOOLEAN *)pval = it->size; return 1; case V_ASN1_NULL: *pval = (ASN1_VALUE *)1; return 1; case V_ASN1_ANY: typ = malloc(sizeof(ASN1_TYPE)); if (!typ) return 0; typ->value.ptr = NULL; typ->type = -1; *pval = (ASN1_VALUE *)typ; break; default: str = ASN1_STRING_type_new(utype); if (it->itype == ASN1_ITYPE_MSTRING && str) str->flags |= ASN1_STRING_FLAG_MSTRING; *pval = (ASN1_VALUE *)str; break; } if (*pval) return 1; return 0; } static void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it) { int utype; if (it && it->funcs) { const ASN1_PRIMITIVE_FUNCS *pf = it->funcs; if (pf->prim_clear) pf->prim_clear(pval, it); else *pval = NULL; return; } if (!it || (it->itype == ASN1_ITYPE_MSTRING)) utype = -1; else utype = it->utype; if (utype == V_ASN1_BOOLEAN) *(ASN1_BOOLEAN *)pval = it->size; else *pval = NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_d2i_fp.c0000644000175000017500000001645612360020705020740 0ustar /* $OpenBSD: a_d2i_fp.c,v 1.9 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb); #ifndef NO_OLD_ASN1 void * ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x) { BIO *b; void *ret; if ((b = BIO_new(BIO_s_file())) == NULL) { ASN1err(ASN1_F_ASN1_D2I_FP, ERR_R_BUF_LIB); return (NULL); } BIO_set_fp(b, in, BIO_NOCLOSE); ret = ASN1_d2i_bio(xnew, d2i, b, x); BIO_free(b); return (ret); } void * ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x) { BUF_MEM *b = NULL; const unsigned char *p; void *ret = NULL; int len; len = asn1_d2i_read_bio(in, &b); if (len < 0) goto err; p = (unsigned char *)b->data; ret = d2i(x, &p, len); err: if (b != NULL) BUF_MEM_free(b); return (ret); } #endif void * ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x) { BUF_MEM *b = NULL; const unsigned char *p; void *ret = NULL; int len; len = asn1_d2i_read_bio(in, &b); if (len < 0) goto err; p = (const unsigned char *)b->data; ret = ASN1_item_d2i(x, &p, len, it); err: if (b != NULL) BUF_MEM_free(b); return (ret); } void * ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x) { BIO *b; char *ret; if ((b = BIO_new(BIO_s_file())) == NULL) { ASN1err(ASN1_F_ASN1_ITEM_D2I_FP, ERR_R_BUF_LIB); return (NULL); } BIO_set_fp(b, in, BIO_NOCLOSE); ret = ASN1_item_d2i_bio(it, b, x); BIO_free(b); return (ret); } #define HEADER_SIZE 8 static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb) { BUF_MEM *b; unsigned char *p; int i; ASN1_const_CTX c; size_t want = HEADER_SIZE; int eos = 0; size_t off = 0; size_t len = 0; b = BUF_MEM_new(); if (b == NULL) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ERR_R_MALLOC_FAILURE); return -1; } ERR_clear_error(); for (;;) { if (want >= (len - off)) { want -= (len - off); if (len + want < len || !BUF_MEM_grow_clean(b, len + want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ERR_R_MALLOC_FAILURE); goto err; } i = BIO_read(in, &(b->data[len]), want); if ((i < 0) && ((len - off) == 0)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_NOT_ENOUGH_DATA); goto err; } if (i > 0) { if (len + i < len) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_TOO_LONG); goto err; } len += i; } } /* else data already loaded */ p = (unsigned char *) & (b->data[off]); c.p = p; c.inf = ASN1_get_object(&(c.p), &(c.slen), &(c.tag), &(c.xclass), len - off); if (c.inf & 0x80) { unsigned long e; e = ERR_GET_REASON(ERR_peek_error()); if (e != ASN1_R_TOO_LONG) goto err; else ERR_clear_error(); /* clear error */ } i = c.p - p; /* header length */ off += i; /* end of data */ if (c.inf & 1) { /* no data body so go round again */ eos++; if (eos < 0) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_HEADER_TOO_LONG); goto err; } want = HEADER_SIZE; } else if (eos && (c.slen == 0) && (c.tag == V_ASN1_EOC)) { /* eos value, so go back and read another header */ eos--; if (eos <= 0) break; else want = HEADER_SIZE; } else { /* suck in c.slen bytes of data */ want = c.slen; if (want > (len - off)) { want -= (len - off); if (want > INT_MAX /* BIO_read takes an int length */ || len+want < len) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_TOO_LONG); goto err; } if (!BUF_MEM_grow_clean(b, len + want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ERR_R_MALLOC_FAILURE); goto err; } while (want > 0) { i = BIO_read(in, &(b->data[len]), want); if (i <= 0) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_NOT_ENOUGH_DATA); goto err; } /* This can't overflow because * |len+want| didn't overflow. */ len += i; want -= i; } } if (off + c.slen < off) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_TOO_LONG); goto err; } off += c.slen; if (eos <= 0) { break; } else want = HEADER_SIZE; } } if (off > INT_MAX) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_TOO_LONG); goto err; } *pb = b; return off; err: if (b != NULL) BUF_MEM_free(b); return -1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_x509.c0000644000175000017500000001537612360020705020331 0ustar /* $OpenBSD: x_x509.c,v 1.16 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include ASN1_SEQUENCE_enc(X509_CINF, enc, 0) = { ASN1_EXP_OPT(X509_CINF, version, ASN1_INTEGER, 0), ASN1_SIMPLE(X509_CINF, serialNumber, ASN1_INTEGER), ASN1_SIMPLE(X509_CINF, signature, X509_ALGOR), ASN1_SIMPLE(X509_CINF, issuer, X509_NAME), ASN1_SIMPLE(X509_CINF, validity, X509_VAL), ASN1_SIMPLE(X509_CINF, subject, X509_NAME), ASN1_SIMPLE(X509_CINF, key, X509_PUBKEY), ASN1_IMP_OPT(X509_CINF, issuerUID, ASN1_BIT_STRING, 1), ASN1_IMP_OPT(X509_CINF, subjectUID, ASN1_BIT_STRING, 2), ASN1_EXP_SEQUENCE_OF_OPT(X509_CINF, extensions, X509_EXTENSION, 3) } ASN1_SEQUENCE_END_enc(X509_CINF, X509_CINF) IMPLEMENT_ASN1_FUNCTIONS(X509_CINF) /* X509 top level structure needs a bit of customisation */ extern void policy_cache_free(X509_POLICY_CACHE *cache); static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { X509 *ret = (X509 *)*pval; switch (operation) { case ASN1_OP_NEW_POST: ret->valid = 0; ret->name = NULL; ret->ex_flags = 0; ret->ex_pathlen = -1; ret->skid = NULL; ret->akid = NULL; #ifndef OPENSSL_NO_RFC3779 ret->rfc3779_addr = NULL; ret->rfc3779_asid = NULL; #endif ret->aux = NULL; ret->crldp = NULL; CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509, ret, &ret->ex_data); break; case ASN1_OP_D2I_POST: free(ret->name); ret->name = X509_NAME_oneline(ret->cert_info->subject, NULL, 0); break; case ASN1_OP_FREE_POST: CRYPTO_free_ex_data(CRYPTO_EX_INDEX_X509, ret, &ret->ex_data); X509_CERT_AUX_free(ret->aux); ASN1_OCTET_STRING_free(ret->skid); AUTHORITY_KEYID_free(ret->akid); CRL_DIST_POINTS_free(ret->crldp); policy_cache_free(ret->policy_cache); GENERAL_NAMES_free(ret->altname); NAME_CONSTRAINTS_free(ret->nc); #ifndef OPENSSL_NO_RFC3779 sk_IPAddressFamily_pop_free(ret->rfc3779_addr, IPAddressFamily_free); ASIdentifiers_free(ret->rfc3779_asid); #endif free(ret->name); ret->name = NULL; break; } return 1; } ASN1_SEQUENCE_ref(X509, x509_cb, CRYPTO_LOCK_X509) = { ASN1_SIMPLE(X509, cert_info, X509_CINF), ASN1_SIMPLE(X509, sig_alg, X509_ALGOR), ASN1_SIMPLE(X509, signature, ASN1_BIT_STRING) } ASN1_SEQUENCE_END_ref(X509, X509) IMPLEMENT_ASN1_FUNCTIONS(X509) IMPLEMENT_ASN1_DUP_FUNCTION(X509) int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509, argl, argp, new_func, dup_func, free_func); } int X509_set_ex_data(X509 *r, int idx, void *arg) { return (CRYPTO_set_ex_data(&r->ex_data, idx, arg)); } void * X509_get_ex_data(X509 *r, int idx) { return (CRYPTO_get_ex_data(&r->ex_data, idx)); } /* X509_AUX ASN1 routines. X509_AUX is the name given to * a certificate with extra info tagged on the end. Since these * functions set how a certificate is trusted they should only * be used when the certificate comes from a reliable source * such as local storage. * */ X509 * d2i_X509_AUX(X509 **a, const unsigned char **pp, long length) { const unsigned char *q; X509 *ret; /* Save start position */ q = *pp; ret = d2i_X509(a, pp, length); /* If certificate unreadable then forget it */ if (!ret) return NULL; /* update length */ length -= *pp - q; if (!length) return ret; if (!d2i_X509_CERT_AUX(&ret->aux, pp, length)) goto err; return ret; err: X509_free(ret); return NULL; } int i2d_X509_AUX(X509 *a, unsigned char **pp) { int length; length = i2d_X509(a, pp); if (a) length += i2d_X509_CERT_AUX(a->aux, pp); return length; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_spki.c0000644000175000017500000000752512360020705020567 0ustar /* $OpenBSD: x_spki.c,v 1.7 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* This module was send to me my Pat Richards who * wrote it. It is under my Copyright with his permission */ #include #include #include ASN1_SEQUENCE(NETSCAPE_SPKAC) = { ASN1_SIMPLE(NETSCAPE_SPKAC, pubkey, X509_PUBKEY), ASN1_SIMPLE(NETSCAPE_SPKAC, challenge, ASN1_IA5STRING) } ASN1_SEQUENCE_END(NETSCAPE_SPKAC) IMPLEMENT_ASN1_FUNCTIONS(NETSCAPE_SPKAC) ASN1_SEQUENCE(NETSCAPE_SPKI) = { ASN1_SIMPLE(NETSCAPE_SPKI, spkac, NETSCAPE_SPKAC), ASN1_SIMPLE(NETSCAPE_SPKI, sig_algor, X509_ALGOR), ASN1_SIMPLE(NETSCAPE_SPKI, signature, ASN1_BIT_STRING) } ASN1_SEQUENCE_END(NETSCAPE_SPKI) IMPLEMENT_ASN1_FUNCTIONS(NETSCAPE_SPKI) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/t_spki.c0000644000175000017500000000776012360020705020564 0ustar /* $OpenBSD: t_spki.c,v 1.10 2014/07/10 22:45:56 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #ifndef OPENSSL_NO_DSA #include #endif #ifndef OPENSSL_NO_RSA #include #endif /* Print out an SPKI */ int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki) { EVP_PKEY *pkey; ASN1_IA5STRING *chal; int i, n; char *s; BIO_printf(out, "Netscape SPKI:\n"); i = OBJ_obj2nid(spki->spkac->pubkey->algor->algorithm); BIO_printf(out, " Public Key Algorithm: %s\n", (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i)); pkey = X509_PUBKEY_get(spki->spkac->pubkey); if (!pkey) BIO_printf(out, " Unable to load public key\n"); else { EVP_PKEY_print_public(out, pkey, 4, NULL); EVP_PKEY_free(pkey); } chal = spki->spkac->challenge; if (chal->length) BIO_printf(out, " Challenge String: %s\n", chal->data); i = OBJ_obj2nid(spki->sig_algor->algorithm); BIO_printf(out, " Signature Algorithm: %s", (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i)); n = spki->signature->length; s = (char *)spki->signature->data; for (i = 0; i < n; i++) { if ((i % 18) == 0) BIO_write(out, "\n ", 7); BIO_printf(out, "%02x%s", (unsigned char)s[i], ((i + 1) == n) ? "" : ":"); } BIO_write(out, "\n", 1); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/ameth_lib.c0000644000175000017500000002723512360020705021216 0ustar /* $OpenBSD: ameth_lib.c,v 1.12 2014/07/11 08:44:47 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif #include "asn1_locl.h" extern const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[]; extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[]; extern const EVP_PKEY_ASN1_METHOD dh_asn1_meth; extern const EVP_PKEY_ASN1_METHOD eckey_asn1_meth; extern const EVP_PKEY_ASN1_METHOD hmac_asn1_meth; extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth; /* Keep this sorted in type order !! */ static const EVP_PKEY_ASN1_METHOD *standard_methods[] = { #ifndef OPENSSL_NO_RSA &rsa_asn1_meths[0], &rsa_asn1_meths[1], #endif #ifndef OPENSSL_NO_DH &dh_asn1_meth, #endif #ifndef OPENSSL_NO_DSA &dsa_asn1_meths[0], &dsa_asn1_meths[1], &dsa_asn1_meths[2], &dsa_asn1_meths[3], &dsa_asn1_meths[4], #endif #ifndef OPENSSL_NO_EC &eckey_asn1_meth, #endif &hmac_asn1_meth, &cmac_asn1_meth }; typedef int sk_cmp_fn_type(const char * const *a, const char * const *b); DECLARE_STACK_OF(EVP_PKEY_ASN1_METHOD) static STACK_OF(EVP_PKEY_ASN1_METHOD) *app_methods = NULL; DECLARE_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_ASN1_METHOD *, const EVP_PKEY_ASN1_METHOD *, ameth); static int ameth_cmp(const EVP_PKEY_ASN1_METHOD * const *a, const EVP_PKEY_ASN1_METHOD * const *b) { return ((*a)->pkey_id - (*b)->pkey_id); } IMPLEMENT_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_ASN1_METHOD *, const EVP_PKEY_ASN1_METHOD *, ameth); int EVP_PKEY_asn1_get_count(void) { int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *); if (app_methods) num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods); return num; } const EVP_PKEY_ASN1_METHOD * EVP_PKEY_asn1_get0(int idx) { int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *); if (idx < 0) return NULL; if (idx < num) return standard_methods[idx]; idx -= num; return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx); } static const EVP_PKEY_ASN1_METHOD * pkey_asn1_find(int type) { EVP_PKEY_ASN1_METHOD tmp; const EVP_PKEY_ASN1_METHOD *t = &tmp, **ret; tmp.pkey_id = type; if (app_methods) { int idx; idx = sk_EVP_PKEY_ASN1_METHOD_find(app_methods, &tmp); if (idx >= 0) return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx); } ret = OBJ_bsearch_ameth(&t, standard_methods, sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *)); if (!ret || !*ret) return NULL; return *ret; } /* Find an implementation of an ASN1 algorithm. If 'pe' is not NULL * also search through engines and set *pe to a functional reference * to the engine implementing 'type' or NULL if no engine implements * it. */ const EVP_PKEY_ASN1_METHOD * EVP_PKEY_asn1_find(ENGINE **pe, int type) { const EVP_PKEY_ASN1_METHOD *t; for (;;) { t = pkey_asn1_find(type); if (!t || !(t->pkey_flags & ASN1_PKEY_ALIAS)) break; type = t->pkey_base_id; } if (pe) { #ifndef OPENSSL_NO_ENGINE ENGINE *e; /* type will contain the final unaliased type */ e = ENGINE_get_pkey_asn1_meth_engine(type); if (e) { *pe = e; return ENGINE_get_pkey_asn1_meth(e, type); } #endif *pe = NULL; } return t; } const EVP_PKEY_ASN1_METHOD * EVP_PKEY_asn1_find_str(ENGINE **pe, const char *str, int len) { int i; const EVP_PKEY_ASN1_METHOD *ameth; if (len == -1) len = strlen(str); if (pe) { #ifndef OPENSSL_NO_ENGINE ENGINE *e; ameth = ENGINE_pkey_asn1_find_str(&e, str, len); if (ameth) { /* Convert structural into * functional reference */ if (!ENGINE_init(e)) ameth = NULL; ENGINE_free(e); *pe = e; return ameth; } #endif *pe = NULL; } for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) { ameth = EVP_PKEY_asn1_get0(i); if (ameth->pkey_flags & ASN1_PKEY_ALIAS) continue; if (((int)strlen(ameth->pem_str) == len) && !strncasecmp(ameth->pem_str, str, len)) return ameth; } return NULL; } int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth) { if (app_methods == NULL) { app_methods = sk_EVP_PKEY_ASN1_METHOD_new(ameth_cmp); if (!app_methods) return 0; } if (!sk_EVP_PKEY_ASN1_METHOD_push(app_methods, ameth)) return 0; sk_EVP_PKEY_ASN1_METHOD_sort(app_methods); return 1; } int EVP_PKEY_asn1_add_alias(int to, int from) { EVP_PKEY_ASN1_METHOD *ameth; ameth = EVP_PKEY_asn1_new(from, ASN1_PKEY_ALIAS, NULL, NULL); if (!ameth) return 0; ameth->pkey_base_id = to; if (!EVP_PKEY_asn1_add0(ameth)) { EVP_PKEY_asn1_free(ameth); return 0; } return 1; } int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *ppkey_base_id, int *ppkey_flags, const char **pinfo, const char **ppem_str, const EVP_PKEY_ASN1_METHOD *ameth) { if (!ameth) return 0; if (ppkey_id) *ppkey_id = ameth->pkey_id; if (ppkey_base_id) *ppkey_base_id = ameth->pkey_base_id; if (ppkey_flags) *ppkey_flags = ameth->pkey_flags; if (pinfo) *pinfo = ameth->info; if (ppem_str) *ppem_str = ameth->pem_str; return 1; } const EVP_PKEY_ASN1_METHOD* EVP_PKEY_get0_asn1(EVP_PKEY *pkey) { return pkey->ameth; } EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info) { EVP_PKEY_ASN1_METHOD *ameth; ameth = calloc(1, sizeof(EVP_PKEY_ASN1_METHOD)); if (!ameth) return NULL; ameth->pkey_id = id; ameth->pkey_base_id = id; ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; if (info) { ameth->info = BUF_strdup(info); if (!ameth->info) goto err; } else ameth->info = NULL; if (pem_str) { ameth->pem_str = BUF_strdup(pem_str); if (!ameth->pem_str) goto err; } else ameth->pem_str = NULL; ameth->pub_decode = 0; ameth->pub_encode = 0; ameth->pub_cmp = 0; ameth->pub_print = 0; ameth->priv_decode = 0; ameth->priv_encode = 0; ameth->priv_print = 0; ameth->old_priv_encode = 0; ameth->old_priv_decode = 0; ameth->item_verify = 0; ameth->item_sign = 0; ameth->pkey_size = 0; ameth->pkey_bits = 0; ameth->param_decode = 0; ameth->param_encode = 0; ameth->param_missing = 0; ameth->param_copy = 0; ameth->param_cmp = 0; ameth->param_print = 0; ameth->pkey_free = 0; ameth->pkey_ctrl = 0; return ameth; err: EVP_PKEY_asn1_free(ameth); return NULL; } void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst, const EVP_PKEY_ASN1_METHOD *src) { dst->pub_decode = src->pub_decode; dst->pub_encode = src->pub_encode; dst->pub_cmp = src->pub_cmp; dst->pub_print = src->pub_print; dst->priv_decode = src->priv_decode; dst->priv_encode = src->priv_encode; dst->priv_print = src->priv_print; dst->old_priv_encode = src->old_priv_encode; dst->old_priv_decode = src->old_priv_decode; dst->pkey_size = src->pkey_size; dst->pkey_bits = src->pkey_bits; dst->param_decode = src->param_decode; dst->param_encode = src->param_encode; dst->param_missing = src->param_missing; dst->param_copy = src->param_copy; dst->param_cmp = src->param_cmp; dst->param_print = src->param_print; dst->pkey_free = src->pkey_free; dst->pkey_ctrl = src->pkey_ctrl; dst->item_sign = src->item_sign; dst->item_verify = src->item_verify; } void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth) { if (ameth && (ameth->pkey_flags & ASN1_PKEY_DYNAMIC)) { free(ameth->pem_str); free(ameth->info); free(ameth); } } void EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth, int (*pub_decode)(EVP_PKEY *pk, X509_PUBKEY *pub), int (*pub_encode)(X509_PUBKEY *pub, const EVP_PKEY *pk), int (*pub_cmp)(const EVP_PKEY *a, const EVP_PKEY *b), int (*pub_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx), int (*pkey_size)(const EVP_PKEY *pk), int (*pkey_bits)(const EVP_PKEY *pk)) { ameth->pub_decode = pub_decode; ameth->pub_encode = pub_encode; ameth->pub_cmp = pub_cmp; ameth->pub_print = pub_print; ameth->pkey_size = pkey_size; ameth->pkey_bits = pkey_bits; } void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth, int (*priv_decode)(EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO *p8inf), int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk), int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx)) { ameth->priv_decode = priv_decode; ameth->priv_encode = priv_encode; ameth->priv_print = priv_print; } void EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth, int (*param_decode)(EVP_PKEY *pkey, const unsigned char **pder, int derlen), int (*param_encode)(const EVP_PKEY *pkey, unsigned char **pder), int (*param_missing)(const EVP_PKEY *pk), int (*param_copy)(EVP_PKEY *to, const EVP_PKEY *from), int (*param_cmp)(const EVP_PKEY *a, const EVP_PKEY *b), int (*param_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx)) { ameth->param_decode = param_decode; ameth->param_encode = param_encode; ameth->param_missing = param_missing; ameth->param_copy = param_copy; ameth->param_cmp = param_cmp; ameth->param_print = param_print; } void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth, void (*pkey_free)(EVP_PKEY *pkey)) { ameth->pkey_free = pkey_free; } void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth, int (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1, void *arg2)) { ameth->pkey_ctrl = pkey_ctrl; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_object.c0000644000175000017500000002321412360020705021031 0ustar /* $OpenBSD: a_object.c,v 1.20 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp) { unsigned char *p; int objsize; if ((a == NULL) || (a->data == NULL)) return (0); objsize = ASN1_object_size(0, a->length, V_ASN1_OBJECT); if (pp == NULL) return objsize; p = *pp; ASN1_put_object(&p, 0, a->length, V_ASN1_OBJECT, V_ASN1_UNIVERSAL); memcpy(p, a->data, a->length); p += a->length; *pp = p; return (objsize); } int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num) { int i, first, len = 0, c, use_bn; char ftmp[24], *tmp = ftmp; int tmpsize = sizeof ftmp; const char *p; unsigned long l; BIGNUM *bl = NULL; if (num == 0) return (0); else if (num == -1) num = strlen(buf); p = buf; c = *(p++); num--; if ((c >= '0') && (c <= '2')) { first= c-'0'; } else { ASN1err(ASN1_F_A2D_ASN1_OBJECT, ASN1_R_FIRST_NUM_TOO_LARGE); goto err; } if (num <= 0) { ASN1err(ASN1_F_A2D_ASN1_OBJECT, ASN1_R_MISSING_SECOND_NUMBER); goto err; } c = *(p++); num--; for (;;) { if (num <= 0) break; if ((c != '.') && (c != ' ')) { ASN1err(ASN1_F_A2D_ASN1_OBJECT, ASN1_R_INVALID_SEPARATOR); goto err; } l = 0; use_bn = 0; for (;;) { if (num <= 0) break; num--; c = *(p++); if ((c == ' ') || (c == '.')) break; if ((c < '0') || (c > '9')) { ASN1err(ASN1_F_A2D_ASN1_OBJECT, ASN1_R_INVALID_DIGIT); goto err; } if (!use_bn && l >= ((ULONG_MAX - 80) / 10L)) { use_bn = 1; if (!bl) bl = BN_new(); if (!bl || !BN_set_word(bl, l)) goto err; } if (use_bn) { if (!BN_mul_word(bl, 10L) || !BN_add_word(bl, c-'0')) goto err; } else l = l * 10L + (long)(c - '0'); } if (len == 0) { if ((first < 2) && (l >= 40)) { ASN1err(ASN1_F_A2D_ASN1_OBJECT, ASN1_R_SECOND_NUMBER_TOO_LARGE); goto err; } if (use_bn) { if (!BN_add_word(bl, first * 40)) goto err; } else l += (long)first * 40; } i = 0; if (use_bn) { int blsize; blsize = BN_num_bits(bl); blsize = (blsize + 6) / 7; if (blsize > tmpsize) { if (tmp != ftmp) free(tmp); tmpsize = blsize + 32; tmp = malloc(tmpsize); if (!tmp) goto err; } while (blsize--) tmp[i++] = (unsigned char)BN_div_word(bl, 0x80L); } else { for (;;) { tmp[i++] = (unsigned char)l & 0x7f; l >>= 7L; if (l == 0L) break; } } if (out != NULL) { if (len + i > olen) { ASN1err(ASN1_F_A2D_ASN1_OBJECT, ASN1_R_BUFFER_TOO_SMALL); goto err; } while (--i > 0) out[len++] = tmp[i]|0x80; out[len++] = tmp[0]; } else len += i; } if (tmp != ftmp) free(tmp); if (bl) BN_free(bl); return (len); err: if (tmp != ftmp) free(tmp); if (bl) BN_free(bl); return (0); } int i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a) { return OBJ_obj2txt(buf, buf_len, a, 0); } int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a) { char buf[80], *p = buf; int i; if ((a == NULL) || (a->data == NULL)) return(BIO_write(bp, "NULL",4)); i = i2t_ASN1_OBJECT(buf, sizeof buf, a); if (i > (int)(sizeof(buf) - 1)) { p = malloc(i + 1); if (!p) return -1; i2t_ASN1_OBJECT(p, i + 1, a); } if (i <= 0) return BIO_write(bp, "", 9); BIO_write(bp, p, i); if (p != buf) free(p); return (i); } ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, long length) { const unsigned char *p; long len; int tag, xclass; int inf, i; ASN1_OBJECT *ret = NULL; p = *pp; inf = ASN1_get_object(&p, &len, &tag, &xclass, length); if (inf & 0x80) { i = ASN1_R_BAD_OBJECT_HEADER; goto err; } if (tag != V_ASN1_OBJECT) { i = ASN1_R_EXPECTING_AN_OBJECT; goto err; } ret = c2i_ASN1_OBJECT(a, &p, len); if (ret) *pp = p; return ret; err: ASN1err(ASN1_F_D2I_ASN1_OBJECT, i); return (NULL); } ASN1_OBJECT * c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, long len) { ASN1_OBJECT *ret = NULL; const unsigned char *p; unsigned char *data; int i; /* Sanity check OID encoding: can't have leading 0x80 in * subidentifiers, see: X.690 8.19.2 */ for (i = 0, p = *pp; i < len; i++, p++) { if (*p == 0x80 && (!i || !(p[-1] & 0x80))) { ASN1err(ASN1_F_C2I_ASN1_OBJECT, ASN1_R_INVALID_OBJECT_ENCODING); return NULL; } } /* only the ASN1_OBJECTs from the 'table' will have values * for ->sn or ->ln */ if ((a == NULL) || ((*a) == NULL) || !((*a)->flags & ASN1_OBJECT_FLAG_DYNAMIC)) { if ((ret = ASN1_OBJECT_new()) == NULL) return (NULL); } else ret = (*a); p = *pp; /* detach data from object */ data = (unsigned char *)ret->data; ret->data = NULL; /* once detached we can change it */ if ((data == NULL) || (ret->length < len)) { ret->length = 0; free(data); data = malloc(len ? len : 1); if (data == NULL) { i = ERR_R_MALLOC_FAILURE; goto err; } ret->flags |= ASN1_OBJECT_FLAG_DYNAMIC_DATA; } memcpy(data, p, len); /* reattach data to object, after which it remains const */ ret->data = data; ret->length = (int)len; ret->sn = NULL; ret->ln = NULL; /* ret->flags=ASN1_OBJECT_FLAG_DYNAMIC; we know it is dynamic */ p += len; if (a != NULL) (*a) = ret; *pp = p; return (ret); err: ASN1err(ASN1_F_C2I_ASN1_OBJECT, i); if ((ret != NULL) && ((a == NULL) || (*a != ret))) ASN1_OBJECT_free(ret); return (NULL); } ASN1_OBJECT * ASN1_OBJECT_new(void) { ASN1_OBJECT *ret; ret = malloc(sizeof(ASN1_OBJECT)); if (ret == NULL) { ASN1err(ASN1_F_ASN1_OBJECT_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } ret->length = 0; ret->data = NULL; ret->nid = 0; ret->sn = NULL; ret->ln = NULL; ret->flags = ASN1_OBJECT_FLAG_DYNAMIC; return (ret); } void ASN1_OBJECT_free(ASN1_OBJECT *a) { if (a == NULL) return; if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS) { free((void *)a->sn); free((void *)a->ln); a->sn = a->ln = NULL; } if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_DATA) { free((void *)a->data); a->data = NULL; a->length = 0; } if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC) free(a); } ASN1_OBJECT * ASN1_OBJECT_create(int nid, unsigned char *data, int len, const char *sn, const char *ln) { ASN1_OBJECT o; o.sn = sn; o.ln = ln; o.data = data; o.nid = nid; o.length = len; o.flags = ASN1_OBJECT_FLAG_DYNAMIC | ASN1_OBJECT_FLAG_DYNAMIC_STRINGS | ASN1_OBJECT_FLAG_DYNAMIC_DATA; return (OBJ_dup(&o)); } IMPLEMENT_STACK_OF(ASN1_OBJECT) IMPLEMENT_ASN1_SET_OF(ASN1_OBJECT) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_print.c0000644000175000017500000001065612360020705020725 0ustar /* $OpenBSD: a_print.c,v 1.10 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include int ASN1_PRINTABLE_type(const unsigned char *s, int len) { int c; int ia5 = 0; int t61 = 0; if (len <= 0) len = -1; if (s == NULL) return (V_ASN1_PRINTABLESTRING); while ((*s) && (len-- != 0)) { c= *(s++); if (!(((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || (c == ' ') || ((c >= '0') && (c <= '9')) || (c == ' ') || (c == '\'') || (c == '(') || (c == ')') || (c == '+') || (c == ',') || (c == '-') || (c == '.') || (c == '/') || (c == ':') || (c == '=') || (c == '?'))) ia5 = 1; if (c & 0x80) t61 = 1; } if (t61) return (V_ASN1_T61STRING); if (ia5) return (V_ASN1_IA5STRING); return (V_ASN1_PRINTABLESTRING); } int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s) { int i; unsigned char *p; if (s->type != V_ASN1_UNIVERSALSTRING) return (0); if ((s->length % 4) != 0) return (0); p = s->data; for (i = 0; i < s->length; i += 4) { if ((p[0] != '\0') || (p[1] != '\0') || (p[2] != '\0')) break; else p += 4; } if (i < s->length) return (0); p = s->data; for (i = 3; i < s->length; i += 4) { *(p++) = s->data[i]; } *(p) = '\0'; s->length /= 4; s->type = ASN1_PRINTABLE_type(s->data, s->length); return (1); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_exten.c0000644000175000017500000000650112360020705020735 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include ASN1_SEQUENCE(X509_EXTENSION) = { ASN1_SIMPLE(X509_EXTENSION, object, ASN1_OBJECT), ASN1_OPT(X509_EXTENSION, critical, ASN1_BOOLEAN), ASN1_SIMPLE(X509_EXTENSION, value, ASN1_OCTET_STRING) } ASN1_SEQUENCE_END(X509_EXTENSION) ASN1_ITEM_TEMPLATE(X509_EXTENSIONS) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, Extension, X509_EXTENSION) ASN1_ITEM_TEMPLATE_END(X509_EXTENSIONS) IMPLEMENT_ASN1_FUNCTIONS(X509_EXTENSION) IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS) IMPLEMENT_ASN1_DUP_FUNCTION(X509_EXTENSION) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_algor.c0000644000175000017500000001074112360020705020717 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include ASN1_SEQUENCE(X509_ALGOR) = { ASN1_SIMPLE(X509_ALGOR, algorithm, ASN1_OBJECT), ASN1_OPT(X509_ALGOR, parameter, ASN1_ANY) } ASN1_SEQUENCE_END(X509_ALGOR) ASN1_ITEM_TEMPLATE(X509_ALGORS) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, algorithms, X509_ALGOR) ASN1_ITEM_TEMPLATE_END(X509_ALGORS) IMPLEMENT_ASN1_FUNCTIONS(X509_ALGOR) IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(X509_ALGORS, X509_ALGORS, X509_ALGORS) IMPLEMENT_ASN1_DUP_FUNCTION(X509_ALGOR) IMPLEMENT_STACK_OF(X509_ALGOR) IMPLEMENT_ASN1_SET_OF(X509_ALGOR) int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval) { if (!alg) return 0; if (ptype != V_ASN1_UNDEF) { if (alg->parameter == NULL) alg->parameter = ASN1_TYPE_new(); if (alg->parameter == NULL) return 0; } if (alg) { if (alg->algorithm) ASN1_OBJECT_free(alg->algorithm); alg->algorithm = aobj; } if (ptype == 0) return 1; if (ptype == V_ASN1_UNDEF) { if (alg->parameter) { ASN1_TYPE_free(alg->parameter); alg->parameter = NULL; } } else ASN1_TYPE_set(alg->parameter, ptype, pval); return 1; } void X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval, X509_ALGOR *algor) { if (paobj) *paobj = algor->algorithm; if (pptype) { if (algor->parameter == NULL) { *pptype = V_ASN1_UNDEF; return; } else *pptype = algor->parameter->type; if (ppval) *ppval = algor->parameter->value.ptr; } } /* Set up an X509_ALGOR DigestAlgorithmIdentifier from an EVP_MD */ void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md) { int param_type; if (md->flags & EVP_MD_FLAG_DIGALGID_ABSENT) param_type = V_ASN1_UNDEF; else param_type = V_ASN1_NULL; X509_ALGOR_set0(alg, OBJ_nid2obj(EVP_MD_type(md)), param_type, NULL); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/asn_mime.c0000644000175000017500000006010612360020705021054 0ustar /* $OpenBSD: asn_mime.c,v 1.20 2014/07/11 08:44:47 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ /* ==================================================================== * Copyright (c) 1999-2008 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * */ #include #include #include #include #include #include #include #include #include "asn1_locl.h" /* Generalised MIME like utilities for streaming ASN1. Although many * have a PKCS7/CMS like flavour others are more general purpose. */ /* MIME format structures * Note that all are translated to lower case apart from * parameter values. Quotes are stripped off */ typedef struct { char *param_name; /* Param name e.g. "micalg" */ char *param_value; /* Param value e.g. "sha1" */ } MIME_PARAM; DECLARE_STACK_OF(MIME_PARAM) IMPLEMENT_STACK_OF(MIME_PARAM) typedef struct { char *name; /* Name of line e.g. "content-type" */ char *value; /* Value of line e.g. "text/plain" */ STACK_OF(MIME_PARAM) *params; /* Zero or more parameters */ } MIME_HEADER; DECLARE_STACK_OF(MIME_HEADER) IMPLEMENT_STACK_OF(MIME_HEADER) static int asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags, const ASN1_ITEM *it); static char * strip_ends(char *name); static char * strip_start(char *name); static char * strip_end(char *name); static MIME_HEADER *mime_hdr_new(char *name, char *value); static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value); static STACK_OF(MIME_HEADER) *mime_parse_hdr(BIO *bio); static int mime_hdr_cmp(const MIME_HEADER * const *a, const MIME_HEADER * const *b); static int mime_param_cmp(const MIME_PARAM * const *a, const MIME_PARAM * const *b); static void mime_param_free(MIME_PARAM *param); static int mime_bound_check(char *line, int linelen, char *bound, int blen); static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret); static int strip_eol(char *linebuf, int *plen); static MIME_HEADER *mime_hdr_find(STACK_OF(MIME_HEADER) *hdrs, char *name); static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name); static void mime_hdr_free(MIME_HEADER *hdr); #define MAX_SMLEN 1024 #define mime_debug(x) /* x */ /* Output an ASN1 structure in BER format streaming if necessary */ int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, const ASN1_ITEM *it) { /* If streaming create stream BIO and copy all content through it */ if (flags & SMIME_STREAM) { BIO *bio, *tbio; bio = BIO_new_NDEF(out, val, it); if (!bio) { ASN1err(ASN1_F_I2D_ASN1_BIO_STREAM, ERR_R_MALLOC_FAILURE); return 0; } SMIME_crlf_copy(in, bio, flags); (void)BIO_flush(bio); /* Free up successive BIOs until we hit the old output BIO */ do { tbio = BIO_pop(bio); BIO_free(bio); bio = tbio; } while (bio != out); } /* else just write out ASN1 structure which will have all content * stored internally */ else ASN1_item_i2d_bio(it, out, val); return 1; } /* Base 64 read and write of ASN1 structure */ static int B64_write_ASN1(BIO *out, ASN1_VALUE *val, BIO *in, int flags, const ASN1_ITEM *it) { BIO *b64; int r; b64 = BIO_new(BIO_f_base64()); if (!b64) { ASN1err(ASN1_F_B64_WRITE_ASN1, ERR_R_MALLOC_FAILURE); return 0; } /* prepend the b64 BIO so all data is base64 encoded. */ out = BIO_push(b64, out); r = i2d_ASN1_bio_stream(out, val, in, flags, it); (void)BIO_flush(out); BIO_pop(out); BIO_free(b64); return r; } /* Streaming ASN1 PEM write */ int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, const char *hdr, const ASN1_ITEM *it) { int r; BIO_printf(out, "-----BEGIN %s-----\n", hdr); r = B64_write_ASN1(out, val, in, flags, it); BIO_printf(out, "-----END %s-----\n", hdr); return r; } static ASN1_VALUE * b64_read_asn1(BIO *bio, const ASN1_ITEM *it) { BIO *b64; ASN1_VALUE *val; if (!(b64 = BIO_new(BIO_f_base64()))) { ASN1err(ASN1_F_B64_READ_ASN1, ERR_R_MALLOC_FAILURE); return 0; } bio = BIO_push(b64, bio); val = ASN1_item_d2i_bio(it, bio, NULL); if (!val) ASN1err(ASN1_F_B64_READ_ASN1, ASN1_R_DECODE_ERROR); (void)BIO_flush(bio); bio = BIO_pop(bio); BIO_free(b64); return val; } /* Generate the MIME "micalg" parameter from RFC3851, RFC4490 */ static int asn1_write_micalg(BIO *out, STACK_OF(X509_ALGOR) *mdalgs) { const EVP_MD *md; int i, have_unknown = 0, write_comma, ret = 0, md_nid; have_unknown = 0; write_comma = 0; for (i = 0; i < sk_X509_ALGOR_num(mdalgs); i++) { if (write_comma) BIO_write(out, ",", 1); write_comma = 1; md_nid = OBJ_obj2nid(sk_X509_ALGOR_value(mdalgs, i)->algorithm); md = EVP_get_digestbynid(md_nid); if (md && md->md_ctrl) { int rv; char *micstr; rv = md->md_ctrl(NULL, EVP_MD_CTRL_MICALG, 0, &micstr); if (rv > 0) { BIO_puts(out, micstr); free(micstr); continue; } if (rv != -2) goto err; } switch (md_nid) { case NID_sha1: BIO_puts(out, "sha1"); break; case NID_md5: BIO_puts(out, "md5"); break; case NID_sha256: BIO_puts(out, "sha-256"); break; case NID_sha384: BIO_puts(out, "sha-384"); break; case NID_sha512: BIO_puts(out, "sha-512"); break; case NID_id_GostR3411_94: BIO_puts(out, "gostr3411-94"); goto err; break; default: if (have_unknown) write_comma = 0; else { BIO_puts(out, "unknown"); have_unknown = 1; } break; } } ret = 1; err: return ret; } /* SMIME sender */ int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, int ctype_nid, int econt_nid, STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it) { char bound[33], c; int i; const char *mime_prefix, *mime_eol, *cname = "smime.p7m"; const char *msg_type = NULL; if (flags & SMIME_OLDMIME) mime_prefix = "application/x-pkcs7-"; else mime_prefix = "application/pkcs7-"; if (flags & SMIME_CRLFEOL) mime_eol = "\r\n"; else mime_eol = "\n"; if ((flags & SMIME_DETACHED) && data) { /* We want multipart/signed */ /* Generate a random boundary */ RAND_pseudo_bytes((unsigned char *)bound, 32); for (i = 0; i < 32; i++) { c = bound[i] & 0xf; if (c < 10) c += '0'; else c += 'A' - 10; bound[i] = c; } bound[32] = 0; BIO_printf(bio, "MIME-Version: 1.0%s", mime_eol); BIO_printf(bio, "Content-Type: multipart/signed;"); BIO_printf(bio, " protocol=\"%ssignature\";", mime_prefix); BIO_puts(bio, " micalg=\""); asn1_write_micalg(bio, mdalgs); BIO_printf(bio, "\"; boundary=\"----%s\"%s%s", bound, mime_eol, mime_eol); BIO_printf(bio, "This is an S/MIME signed message%s%s", mime_eol, mime_eol); /* Now write out the first part */ BIO_printf(bio, "------%s%s", bound, mime_eol); if (!asn1_output_data(bio, data, val, flags, it)) return 0; BIO_printf(bio, "%s------%s%s", mime_eol, bound, mime_eol); /* Headers for signature */ BIO_printf(bio, "Content-Type: %ssignature;", mime_prefix); BIO_printf(bio, " name=\"smime.p7s\"%s", mime_eol); BIO_printf(bio, "Content-Transfer-Encoding: base64%s", mime_eol); BIO_printf(bio, "Content-Disposition: attachment;"); BIO_printf(bio, " filename=\"smime.p7s\"%s%s", mime_eol, mime_eol); B64_write_ASN1(bio, val, NULL, 0, it); BIO_printf(bio, "%s------%s--%s%s", mime_eol, bound, mime_eol, mime_eol); return 1; } /* Determine smime-type header */ if (ctype_nid == NID_pkcs7_enveloped) msg_type = "enveloped-data"; else if (ctype_nid == NID_pkcs7_signed) { if (econt_nid == NID_id_smime_ct_receipt) msg_type = "signed-receipt"; else if (sk_X509_ALGOR_num(mdalgs) >= 0) msg_type = "signed-data"; else msg_type = "certs-only"; } else if (ctype_nid == NID_id_smime_ct_compressedData) { msg_type = "compressed-data"; cname = "smime.p7z"; } /* MIME headers */ BIO_printf(bio, "MIME-Version: 1.0%s", mime_eol); BIO_printf(bio, "Content-Disposition: attachment;"); BIO_printf(bio, " filename=\"%s\"%s", cname, mime_eol); BIO_printf(bio, "Content-Type: %smime;", mime_prefix); if (msg_type) BIO_printf(bio, " smime-type=%s;", msg_type); BIO_printf(bio, " name=\"%s\"%s", cname, mime_eol); BIO_printf(bio, "Content-Transfer-Encoding: base64%s%s", mime_eol, mime_eol); if (!B64_write_ASN1(bio, val, data, flags, it)) return 0; BIO_printf(bio, "%s", mime_eol); return 1; } /* Handle output of ASN1 data */ static int asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags, const ASN1_ITEM *it) { BIO *tmpbio; const ASN1_AUX *aux = it->funcs; ASN1_STREAM_ARG sarg; int rv = 1; /* If data is not deteched or resigning then the output BIO is * already set up to finalise when it is written through. */ if (!(flags & SMIME_DETACHED) || (flags & PKCS7_REUSE_DIGEST)) { SMIME_crlf_copy(data, out, flags); return 1; } if (!aux || !aux->asn1_cb) { ASN1err(ASN1_F_ASN1_OUTPUT_DATA, ASN1_R_STREAMING_NOT_SUPPORTED); return 0; } sarg.out = out; sarg.ndef_bio = NULL; sarg.boundary = NULL; /* Let ASN1 code prepend any needed BIOs */ if (aux->asn1_cb(ASN1_OP_DETACHED_PRE, &val, it, &sarg) <= 0) return 0; /* Copy data across, passing through filter BIOs for processing */ SMIME_crlf_copy(data, sarg.ndef_bio, flags); /* Finalize structure */ if (aux->asn1_cb(ASN1_OP_DETACHED_POST, &val, it, &sarg) <= 0) rv = 0; /* Now remove any digests prepended to the BIO */ while (sarg.ndef_bio != out) { tmpbio = BIO_pop(sarg.ndef_bio); BIO_free(sarg.ndef_bio); sarg.ndef_bio = tmpbio; } return rv; } /* SMIME reader: handle multipart/signed and opaque signing. * in multipart case the content is placed in a memory BIO * pointed to by "bcont". In opaque this is set to NULL */ ASN1_VALUE * SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it) { BIO *asnin; STACK_OF(MIME_HEADER) *headers = NULL; STACK_OF(BIO) *parts = NULL; MIME_HEADER *hdr; MIME_PARAM *prm; ASN1_VALUE *val; int ret; if (bcont) *bcont = NULL; if (!(headers = mime_parse_hdr(bio))) { ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_MIME_PARSE_ERROR); return NULL; } if (!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) { sk_MIME_HEADER_pop_free(headers, mime_hdr_free); ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_CONTENT_TYPE); return NULL; } /* Handle multipart/signed */ if (!strcmp(hdr->value, "multipart/signed")) { /* Split into two parts */ prm = mime_param_find(hdr, "boundary"); if (!prm || !prm->param_value) { sk_MIME_HEADER_pop_free(headers, mime_hdr_free); ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_MULTIPART_BOUNDARY); return NULL; } ret = multi_split(bio, prm->param_value, &parts); sk_MIME_HEADER_pop_free(headers, mime_hdr_free); if (!ret || (sk_BIO_num(parts) != 2) ) { ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_MULTIPART_BODY_FAILURE); sk_BIO_pop_free(parts, BIO_vfree); return NULL; } /* Parse the signature piece */ asnin = sk_BIO_value(parts, 1); if (!(headers = mime_parse_hdr(asnin))) { ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_MIME_SIG_PARSE_ERROR); sk_BIO_pop_free(parts, BIO_vfree); return NULL; } /* Get content type */ if (!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) { sk_MIME_HEADER_pop_free(headers, mime_hdr_free); ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_SIG_CONTENT_TYPE); return NULL; } if (strcmp(hdr->value, "application/x-pkcs7-signature") && strcmp(hdr->value, "application/pkcs7-signature")) { ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_SIG_INVALID_MIME_TYPE); ERR_asprintf_error_data("type: %s", hdr->value); sk_MIME_HEADER_pop_free(headers, mime_hdr_free); sk_BIO_pop_free(parts, BIO_vfree); return NULL; } sk_MIME_HEADER_pop_free(headers, mime_hdr_free); /* Read in ASN1 */ if (!(val = b64_read_asn1(asnin, it))) { ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_ASN1_SIG_PARSE_ERROR); sk_BIO_pop_free(parts, BIO_vfree); return NULL; } if (bcont) { *bcont = sk_BIO_value(parts, 0); BIO_free(asnin); sk_BIO_free(parts); } else sk_BIO_pop_free(parts, BIO_vfree); return val; } /* OK, if not multipart/signed try opaque signature */ if (strcmp (hdr->value, "application/x-pkcs7-mime") && strcmp (hdr->value, "application/pkcs7-mime")) { ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_INVALID_MIME_TYPE); ERR_asprintf_error_data("type: %s", hdr->value); sk_MIME_HEADER_pop_free(headers, mime_hdr_free); return NULL; } sk_MIME_HEADER_pop_free(headers, mime_hdr_free); if (!(val = b64_read_asn1(bio, it))) { ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_ASN1_PARSE_ERROR); return NULL; } return val; } /* Copy text from one BIO to another making the output CRLF at EOL */ int SMIME_crlf_copy(BIO *in, BIO *out, int flags) { BIO *bf; char eol; int len; char linebuf[MAX_SMLEN]; /* Buffer output so we don't write one line at a time. This is * useful when streaming as we don't end up with one OCTET STRING * per line. */ bf = BIO_new(BIO_f_buffer()); if (!bf) return 0; out = BIO_push(bf, out); if (flags & SMIME_BINARY) { while ((len = BIO_read(in, linebuf, MAX_SMLEN)) > 0) BIO_write(out, linebuf, len); } else { if (flags & SMIME_TEXT) BIO_printf(out, "Content-Type: text/plain\r\n\r\n"); while ((len = BIO_gets(in, linebuf, MAX_SMLEN)) > 0) { eol = strip_eol(linebuf, &len); if (len) BIO_write(out, linebuf, len); if (eol) BIO_write(out, "\r\n", 2); } } (void)BIO_flush(out); BIO_pop(out); BIO_free(bf); return 1; } /* Strip off headers if they are text/plain */ int SMIME_text(BIO *in, BIO *out) { char iobuf[4096]; int len; STACK_OF(MIME_HEADER) *headers; MIME_HEADER *hdr; if (!(headers = mime_parse_hdr(in))) { ASN1err(ASN1_F_SMIME_TEXT, ASN1_R_MIME_PARSE_ERROR); return 0; } if (!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) { ASN1err(ASN1_F_SMIME_TEXT, ASN1_R_MIME_NO_CONTENT_TYPE); sk_MIME_HEADER_pop_free(headers, mime_hdr_free); return 0; } if (strcmp (hdr->value, "text/plain")) { ASN1err(ASN1_F_SMIME_TEXT, ASN1_R_INVALID_MIME_TYPE); ERR_asprintf_error_data("type: %s", hdr->value); sk_MIME_HEADER_pop_free(headers, mime_hdr_free); return 0; } sk_MIME_HEADER_pop_free(headers, mime_hdr_free); while ((len = BIO_read(in, iobuf, sizeof(iobuf))) > 0) BIO_write(out, iobuf, len); if (len < 0) return 0; return 1; } /* Split a multipart/XXX message body into component parts: result is * canonical parts in a STACK of bios */ static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret) { char linebuf[MAX_SMLEN]; int len, blen; int eol = 0, next_eol = 0; BIO *bpart = NULL; STACK_OF(BIO) *parts; char state, part, first; blen = strlen(bound); part = 0; state = 0; first = 1; parts = sk_BIO_new_null(); *ret = parts; while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) { state = mime_bound_check(linebuf, len, bound, blen); if (state == 1) { first = 1; part++; } else if (state == 2) { sk_BIO_push(parts, bpart); return 1; } else if (part) { /* Strip CR+LF from linebuf */ next_eol = strip_eol(linebuf, &len); if (first) { first = 0; if (bpart) sk_BIO_push(parts, bpart); bpart = BIO_new(BIO_s_mem()); BIO_set_mem_eof_return(bpart, 0); } else if (eol) BIO_write(bpart, "\r\n", 2); eol = next_eol; if (len) BIO_write(bpart, linebuf, len); } } return 0; } /* This is the big one: parse MIME header lines up to message body */ #define MIME_INVALID 0 #define MIME_START 1 #define MIME_TYPE 2 #define MIME_NAME 3 #define MIME_VALUE 4 #define MIME_QUOTE 5 #define MIME_COMMENT 6 static STACK_OF(MIME_HEADER) *mime_parse_hdr(BIO *bio) { char *p, *q, c; char *ntmp; char linebuf[MAX_SMLEN]; MIME_HEADER *mhdr = NULL; STACK_OF(MIME_HEADER) *headers; int len, state, save_state = 0; headers = sk_MIME_HEADER_new(mime_hdr_cmp); if (!headers) return NULL; while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) { /* If whitespace at line start then continuation line */ if (mhdr && isspace((unsigned char)linebuf[0])) state = MIME_NAME; else state = MIME_START; ntmp = NULL; /* Go through all characters */ for (p = linebuf, q = linebuf; (c = *p) && (c != '\r') && (c != '\n'); p++) { /* State machine to handle MIME headers * if this looks horrible that's because it *is* */ switch (state) { case MIME_START: if (c == ':') { state = MIME_TYPE; *p = 0; ntmp = strip_ends(q); q = p + 1; } break; case MIME_TYPE: if (c == ';') { mime_debug("Found End Value\n"); *p = 0; mhdr = mime_hdr_new(ntmp, strip_ends(q)); sk_MIME_HEADER_push(headers, mhdr); ntmp = NULL; q = p + 1; state = MIME_NAME; } else if (c == '(') { save_state = state; state = MIME_COMMENT; } break; case MIME_COMMENT: if (c == ')') { state = save_state; } break; case MIME_NAME: if (c == '=') { state = MIME_VALUE; *p = 0; ntmp = strip_ends(q); q = p + 1; } break; case MIME_VALUE: if (c == ';') { state = MIME_NAME; *p = 0; mime_hdr_addparam(mhdr, ntmp, strip_ends(q)); ntmp = NULL; q = p + 1; } else if (c == '"') { mime_debug("Found Quote\n"); state = MIME_QUOTE; } else if (c == '(') { save_state = state; state = MIME_COMMENT; } break; case MIME_QUOTE: if (c == '"') { mime_debug("Found Match Quote\n"); state = MIME_VALUE; } break; } } if (state == MIME_TYPE) { mhdr = mime_hdr_new(ntmp, strip_ends(q)); sk_MIME_HEADER_push(headers, mhdr); } else if (state == MIME_VALUE) mime_hdr_addparam(mhdr, ntmp, strip_ends(q)); if (p == linebuf) break; /* Blank line means end of headers */ } return headers; } static char * strip_ends(char *name) { return strip_end(strip_start(name)); } /* Strip a parameter of whitespace from start of param */ static char * strip_start(char *name) { char *p, c; /* Look for first non white space or quote */ for (p = name; (c = *p); p++) { if (c == '"') { /* Next char is start of string if non null */ if (p[1]) return p + 1; /* Else null string */ return NULL; } if (!isspace((unsigned char)c)) return p; } return NULL; } /* As above but strip from end of string : maybe should handle brackets? */ static char * strip_end(char *name) { char *p, c; if (!name) return NULL; /* Look for first non white space or quote */ for (p = name + strlen(name) - 1; p >= name; p--) { c = *p; if (c == '"') { if (p - 1 == name) return NULL; *p = 0; return name; } if (isspace((unsigned char)c)) *p = 0; else return name; } return NULL; } static MIME_HEADER * mime_hdr_new(char *name, char *value) { MIME_HEADER *mhdr; char *tmpname = NULL, *tmpval = NULL, *p; if (name) { if (!(tmpname = BUF_strdup(name))) goto err; for (p = tmpname; *p; p++) *p = tolower((unsigned char)*p); } if (value) { if (!(tmpval = BUF_strdup(value))) goto err; for (p = tmpval; *p; p++) *p = tolower((unsigned char)*p); } mhdr = malloc(sizeof(MIME_HEADER)); if (!mhdr) goto err; mhdr->name = tmpname; mhdr->value = tmpval; if (!(mhdr->params = sk_MIME_PARAM_new(mime_param_cmp))) { free(mhdr); goto err; } return mhdr; err: free(tmpname); free(tmpval); return NULL; } static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value) { char *tmpname = NULL, *tmpval = NULL, *p; MIME_PARAM *mparam; if (name) { tmpname = BUF_strdup(name); if (!tmpname) goto err; for (p = tmpname; *p; p++) *p = tolower((unsigned char)*p); } if (value) { tmpval = BUF_strdup(value); if (!tmpval) goto err; } /* Parameter values are case sensitive so leave as is */ mparam = malloc(sizeof(MIME_PARAM)); if (!mparam) goto err; mparam->param_name = tmpname; mparam->param_value = tmpval; sk_MIME_PARAM_push(mhdr->params, mparam); return 1; err: free(tmpname); free(tmpval); return 0; } static int mime_hdr_cmp(const MIME_HEADER * const *a, const MIME_HEADER * const *b) { if (!(*a)->name || !(*b)->name) return !!(*a)->name - !!(*b)->name; return (strcmp((*a)->name, (*b)->name)); } static int mime_param_cmp(const MIME_PARAM * const *a, const MIME_PARAM * const *b) { if (!(*a)->param_name || !(*b)->param_name) return !!(*a)->param_name - !!(*b)->param_name; return (strcmp((*a)->param_name, (*b)->param_name)); } /* Find a header with a given name (if possible) */ static MIME_HEADER * mime_hdr_find(STACK_OF(MIME_HEADER) *hdrs, char *name) { MIME_HEADER htmp; int idx; htmp.name = name; idx = sk_MIME_HEADER_find(hdrs, &htmp); if (idx < 0) return NULL; return sk_MIME_HEADER_value(hdrs, idx); } static MIME_PARAM * mime_param_find(MIME_HEADER *hdr, char *name) { MIME_PARAM param; int idx; param.param_name = name; idx = sk_MIME_PARAM_find(hdr->params, ¶m); if (idx < 0) return NULL; return sk_MIME_PARAM_value(hdr->params, idx); } static void mime_hdr_free(MIME_HEADER *hdr) { free(hdr->name); free(hdr->value); if (hdr->params) sk_MIME_PARAM_pop_free(hdr->params, mime_param_free); free(hdr); } static void mime_param_free(MIME_PARAM *param) { free(param->param_name); free(param->param_value); free(param); } /* Check for a multipart boundary. Returns: * 0 : no boundary * 1 : part boundary * 2 : final boundary */ static int mime_bound_check(char *line, int linelen, char *bound, int blen) { if (linelen == -1) linelen = strlen(line); if (blen == -1) blen = strlen(bound); /* Quickly eliminate if line length too short */ if (blen + 2 > linelen) return 0; /* Check for part boundary */ if (!strncmp(line, "--", 2) && !strncmp(line + 2, bound, blen)) { if (!strncmp(line + blen + 2, "--", 2)) return 2; else return 1; } return 0; } static int strip_eol(char *linebuf, int *plen) { int len = *plen; char *p, c; int is_eol = 0; for (p = linebuf + len - 1; len > 0; len--, p--) { c = *p; if (c == '\n') is_eol = 1; else if (c != '\r') break; } *plen = len; return is_eol; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_set.c0000644000175000017500000001643512360020705020365 0ustar /* $OpenBSD: a_set.c,v 1.15 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #ifndef NO_ASN1_OLD typedef struct { unsigned char *pbData; int cbData; } MYBLOB; /* SetBlobCmp * This function compares two elements of SET_OF block */ static int SetBlobCmp(const void *elem1, const void *elem2) { const MYBLOB *b1 = (const MYBLOB *)elem1; const MYBLOB *b2 = (const MYBLOB *)elem2; int r; r = memcmp(b1->pbData, b2->pbData, b1->cbData < b2->cbData ? b1->cbData : b2->cbData); if (r != 0) return r; return b1->cbData - b2->cbData; } /* int is_set: if TRUE, then sort the contents (i.e. it isn't a SEQUENCE) */ int i2d_ASN1_SET(STACK_OF(OPENSSL_BLOCK) *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag, int ex_class, int is_set) { int ret = 0, r; int i; unsigned char *p; unsigned char *pStart, *pTempMem; MYBLOB *rgSetBlob; int totSize; if (a == NULL) return 0; for (i = sk_OPENSSL_BLOCK_num(a) - 1; i >= 0; i--) ret += i2d(sk_OPENSSL_BLOCK_value(a, i), NULL); r = ASN1_object_size(1, ret, ex_tag); if (pp == NULL) return r; p = *pp; ASN1_put_object(&p, 1, ret, ex_tag, ex_class); /* Modified by gp@nsj.co.jp */ /* And then again by Ben */ /* And again by Steve */ if (!is_set || (sk_OPENSSL_BLOCK_num(a) < 2)) { for (i = 0; i < sk_OPENSSL_BLOCK_num(a); i++) i2d(sk_OPENSSL_BLOCK_value(a, i), &p); *pp = p; return r; } pStart = p; /* Catch the beg of Setblobs*/ /* In this array we will store the SET blobs */ rgSetBlob = reallocarray(NULL, sk_OPENSSL_BLOCK_num(a), sizeof(MYBLOB)); if (rgSetBlob == NULL) { ASN1err(ASN1_F_I2D_ASN1_SET, ERR_R_MALLOC_FAILURE); return 0; } for (i = 0; i < sk_OPENSSL_BLOCK_num(a); i++) { rgSetBlob[i].pbData = p; /* catch each set encode blob */ i2d(sk_OPENSSL_BLOCK_value(a, i), &p); /* Length of this SetBlob */ rgSetBlob[i].cbData = p - rgSetBlob[i].pbData; } *pp = p; totSize = p - pStart; /* This is the total size of all set blobs */ /* Now we have to sort the blobs. I am using a simple algo. * Sort ptrs * Copy to temp-mem * Copy from temp-mem to user-mem */ qsort(rgSetBlob, sk_OPENSSL_BLOCK_num(a), sizeof(MYBLOB), SetBlobCmp); if ((pTempMem = malloc(totSize)) == NULL) { free(rgSetBlob); ASN1err(ASN1_F_I2D_ASN1_SET, ERR_R_MALLOC_FAILURE); return 0; } /* Copy to temp mem */ p = pTempMem; for (i = 0; i < sk_OPENSSL_BLOCK_num(a); ++i) { memcpy(p, rgSetBlob[i].pbData, rgSetBlob[i].cbData); p += rgSetBlob[i].cbData; } /* Copy back to user mem*/ memcpy(pStart, pTempMem, totSize); free(pTempMem); free(rgSetBlob); return r; } STACK_OF(OPENSSL_BLOCK) * d2i_ASN1_SET(STACK_OF(OPENSSL_BLOCK) **a, const unsigned char **pp, long length, d2i_of_void *d2i, void (*free_func)(OPENSSL_BLOCK), int ex_tag, int ex_class) { ASN1_const_CTX c; STACK_OF(OPENSSL_BLOCK) *ret = NULL; if (a == NULL || (*a) == NULL) { if ((ret = sk_OPENSSL_BLOCK_new_null()) == NULL) { ASN1err(ASN1_F_D2I_ASN1_SET, ERR_R_MALLOC_FAILURE); goto err; } } else ret = *a; c.p = *pp; c.max = (length == 0) ? 0 : (c.p + length); c.inf = ASN1_get_object(&c.p, &c.slen, &c.tag, &c.xclass, c.max - c.p); if (c.inf & 0x80) goto err; if (ex_class != c.xclass) { ASN1err(ASN1_F_D2I_ASN1_SET, ASN1_R_BAD_CLASS); goto err; } if (ex_tag != c.tag) { ASN1err(ASN1_F_D2I_ASN1_SET, ASN1_R_BAD_TAG); goto err; } if (c.slen + c.p > c.max) { ASN1err(ASN1_F_D2I_ASN1_SET, ASN1_R_LENGTH_ERROR); goto err; } /* check for infinite constructed - it can be as long * as the amount of data passed to us */ if (c.inf == (V_ASN1_CONSTRUCTED + 1)) c.slen = length + *pp - c.p; c.max = c.p + c.slen; while (c.p < c.max) { char *s; if (M_ASN1_D2I_end_sequence()) break; if ((s = d2i(NULL, &c.p, c.slen)) == NULL) { ASN1err(ASN1_F_D2I_ASN1_SET, ASN1_R_ERROR_PARSING_SET_ELEMENT); asn1_add_error(*pp, (int)(c.p - *pp)); goto err; } if (!sk_OPENSSL_BLOCK_push(ret, s)) goto err; } if (a != NULL) *a = ret; *pp = c.p; return ret; err: if (ret != NULL && (a == NULL || *a != ret)) { if (free_func != NULL) sk_OPENSSL_BLOCK_pop_free(ret, free_func); else sk_OPENSSL_BLOCK_free(ret); } return NULL; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_digest.c0000644000175000017500000000716112360020705021045 0ustar /* $OpenBSD: a_digest.c,v 1.14 2014/06/24 19:37:58 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *asn, unsigned char *md, unsigned int *len) { int i; unsigned char *str = NULL; i = ASN1_item_i2d(asn, &str, it); if (!str) return (0); if (!EVP_Digest(str, i, md, len, type, NULL)) return 0; free(str); return (1); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_strnid.c0000644000175000017500000002143112360020705021065 0ustar /* $OpenBSD: a_strnid.c,v 1.16 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include static STACK_OF(ASN1_STRING_TABLE) *stable = NULL; static void st_free(ASN1_STRING_TABLE *tbl); static int sk_table_cmp(const ASN1_STRING_TABLE * const *a, const ASN1_STRING_TABLE * const *b); /* This is the global mask for the mbstring functions: this is use to * mask out certain types (such as BMPString and UTF8String) because * certain software (e.g. Netscape) has problems with them. */ static unsigned long global_mask = B_ASN1_UTF8STRING; void ASN1_STRING_set_default_mask(unsigned long mask) { global_mask = mask; } unsigned long ASN1_STRING_get_default_mask(void) { return global_mask; } /* This function sets the default to various "flavours" of configuration. * based on an ASCII string. Currently this is: * MASK:XXXX : a numerical mask value. * nobmp : Don't use BMPStrings (just Printable, T61). * pkix : PKIX recommendation in RFC2459. * utf8only : only use UTF8Strings (RFC2459 recommendation for 2004). * default: the default value, Printable, T61, BMP. */ int ASN1_STRING_set_default_mask_asc(const char *p) { unsigned long mask; char *end; if (!strncmp(p, "MASK:", 5)) { if (!p[5]) return 0; mask = strtoul(p + 5, &end, 0); if (*end) return 0; } else if (!strcmp(p, "nombstr")) mask = ~((unsigned long)(B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)); else if (!strcmp(p, "pkix")) mask = ~((unsigned long)B_ASN1_T61STRING); else if (!strcmp(p, "utf8only")) mask = B_ASN1_UTF8STRING; else if (!strcmp(p, "default")) mask = 0xFFFFFFFFL; else return 0; ASN1_STRING_set_default_mask(mask); return 1; } /* The following function generates an ASN1_STRING based on limits in a table. * Frequently the types and length of an ASN1_STRING are restricted by a * corresponding OID. For example certificates and certificate requests. */ ASN1_STRING * ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in, int inlen, int inform, int nid) { ASN1_STRING_TABLE *tbl; ASN1_STRING *str = NULL; unsigned long mask; int ret; if (!out) out = &str; tbl = ASN1_STRING_TABLE_get(nid); if (tbl) { mask = tbl->mask; if (!(tbl->flags & STABLE_NO_MASK)) mask &= global_mask; ret = ASN1_mbstring_ncopy(out, in, inlen, inform, mask, tbl->minsize, tbl->maxsize); } else ret = ASN1_mbstring_copy(out, in, inlen, inform, DIRSTRING_TYPE & global_mask); if (ret <= 0) return NULL; return *out; } /* Now the tables and helper functions for the string table: */ /* size limits: this stuff is taken straight from RFC3280 */ #define ub_name 32768 #define ub_common_name 64 #define ub_locality_name 128 #define ub_state_name 128 #define ub_organization_name 64 #define ub_organization_unit_name 64 #define ub_title 64 #define ub_email_address 128 #define ub_serial_number 64 /* This table must be kept in NID order */ static const ASN1_STRING_TABLE tbl_standard[] = { {NID_commonName, 1, ub_common_name, DIRSTRING_TYPE, 0}, {NID_countryName, 2, 2, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK}, {NID_localityName, 1, ub_locality_name, DIRSTRING_TYPE, 0}, {NID_stateOrProvinceName, 1, ub_state_name, DIRSTRING_TYPE, 0}, {NID_organizationName, 1, ub_organization_name, DIRSTRING_TYPE, 0}, {NID_organizationalUnitName, 1, ub_organization_unit_name, DIRSTRING_TYPE, 0}, {NID_pkcs9_emailAddress, 1, ub_email_address, B_ASN1_IA5STRING, STABLE_NO_MASK}, {NID_pkcs9_unstructuredName, 1, -1, PKCS9STRING_TYPE, 0}, {NID_pkcs9_challengePassword, 1, -1, PKCS9STRING_TYPE, 0}, {NID_pkcs9_unstructuredAddress, 1, -1, DIRSTRING_TYPE, 0}, {NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0}, {NID_surname, 1, ub_name, DIRSTRING_TYPE, 0}, {NID_initials, 1, ub_name, DIRSTRING_TYPE, 0}, {NID_serialNumber, 1, ub_serial_number, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK}, {NID_friendlyName, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK}, {NID_name, 1, ub_name, DIRSTRING_TYPE, 0}, {NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK}, {NID_domainComponent, 1, -1, B_ASN1_IA5STRING, STABLE_NO_MASK}, {NID_ms_csp_name, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK} }; static int sk_table_cmp(const ASN1_STRING_TABLE * const *a, const ASN1_STRING_TABLE * const *b) { return (*a)->nid - (*b)->nid; } DECLARE_OBJ_BSEARCH_CMP_FN(ASN1_STRING_TABLE, ASN1_STRING_TABLE, table); static int table_cmp(const ASN1_STRING_TABLE *a, const ASN1_STRING_TABLE *b) { return a->nid - b->nid; } IMPLEMENT_OBJ_BSEARCH_CMP_FN(ASN1_STRING_TABLE, ASN1_STRING_TABLE, table); ASN1_STRING_TABLE * ASN1_STRING_TABLE_get(int nid) { int idx; ASN1_STRING_TABLE *ttmp; ASN1_STRING_TABLE fnd; fnd.nid = nid; ttmp = OBJ_bsearch_table(&fnd, tbl_standard, sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE)); if (ttmp) return ttmp; if (!stable) return NULL; idx = sk_ASN1_STRING_TABLE_find(stable, &fnd); if (idx < 0) return NULL; return sk_ASN1_STRING_TABLE_value(stable, idx); } int ASN1_STRING_TABLE_add(int nid, long minsize, long maxsize, unsigned long mask, unsigned long flags) { ASN1_STRING_TABLE *tmp; char new_nid = 0; flags &= ~STABLE_FLAGS_MALLOC; if (!stable) stable = sk_ASN1_STRING_TABLE_new(sk_table_cmp); if (!stable) { ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD, ERR_R_MALLOC_FAILURE); return 0; } if (!(tmp = ASN1_STRING_TABLE_get(nid))) { tmp = malloc(sizeof(ASN1_STRING_TABLE)); if (!tmp) { ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD, ERR_R_MALLOC_FAILURE); return 0; } tmp->flags = flags | STABLE_FLAGS_MALLOC; tmp->nid = nid; new_nid = 1; } else tmp->flags = (tmp->flags & STABLE_FLAGS_MALLOC) | flags; if (minsize != -1) tmp->minsize = minsize; if (maxsize != -1) tmp->maxsize = maxsize; tmp->mask = mask; if (new_nid) sk_ASN1_STRING_TABLE_push(stable, tmp); return 1; } void ASN1_STRING_TABLE_cleanup(void) { STACK_OF(ASN1_STRING_TABLE) *tmp; tmp = stable; if (!tmp) return; stable = NULL; sk_ASN1_STRING_TABLE_pop_free(tmp, st_free); } static void st_free(ASN1_STRING_TABLE *tbl) { if (tbl->flags & STABLE_FLAGS_MALLOC) free(tbl); } IMPLEMENT_STACK_OF(ASN1_STRING_TABLE) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_int.c0000644000175000017500000002724712360020705020367 0ustar /* $OpenBSD: a_int.c,v 1.23 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include ASN1_INTEGER * ASN1_INTEGER_dup(const ASN1_INTEGER *x) { return M_ASN1_INTEGER_dup(x); } int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y) { int neg, ret; /* Compare signs */ neg = x->type & V_ASN1_NEG; if (neg != (y->type & V_ASN1_NEG)) { if (neg) return -1; else return 1; } ret = ASN1_STRING_cmp(x, y); if (neg) return -ret; else return ret; } /* * This converts an ASN1 INTEGER into its content encoding. * The internal representation is an ASN1_STRING whose data is a big endian * representation of the value, ignoring the sign. The sign is determined by * the type: V_ASN1_INTEGER for positive and V_ASN1_NEG_INTEGER for negative. * * Positive integers are no problem: they are almost the same as the DER * encoding, except if the first byte is >= 0x80 we need to add a zero pad. * * Negative integers are a bit trickier... * The DER representation of negative integers is in 2s complement form. * The internal form is converted by complementing each octet and finally * adding one to the result. This can be done less messily with a little trick. * If the internal form has trailing zeroes then they will become FF by the * complement and 0 by the add one (due to carry) so just copy as many trailing * zeros to the destination as there are in the source. The carry will add one * to the last none zero octet: so complement this octet and add one and finally * complement any left over until you get to the start of the string. * * Padding is a little trickier too. If the first bytes is > 0x80 then we pad * with 0xff. However if the first byte is 0x80 and one of the following bytes * is non-zero we pad with 0xff. The reason for this distinction is that 0x80 * followed by optional zeros isn't padded. */ int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp) { int pad = 0, ret, i, neg; unsigned char *p, *n, pb = 0; if (a == NULL) return (0); neg = a->type & V_ASN1_NEG; if (a->length == 0) ret = 1; else { ret = a->length; i = a->data[0]; if (!neg && (i > 127)) { pad = 1; pb = 0; } else if (neg) { if (i > 128) { pad = 1; pb = 0xFF; } else if (i == 128) { /* * Special case: if any other bytes non zero we pad: * otherwise we don't. */ for (i = 1; i < a->length; i++) if (a->data[i]) { pad = 1; pb = 0xFF; break; } } } ret += pad; } if (pp == NULL) return (ret); p= *pp; if (pad) *(p++) = pb; if (a->length == 0) *(p++) = 0; else if (!neg) memcpy(p, a->data, a->length); else { /* Begin at the end of the encoding */ n = a->data + a->length - 1; p += a->length - 1; i = a->length; /* Copy zeros to destination as long as source is zero */ while (!*n) { *(p--) = 0; n--; i--; } /* Complement and increment next octet */ *(p--) = ((*(n--)) ^ 0xff) + 1; i--; /* Complement any octets left */ for (; i > 0; i--) *(p--) = *(n--) ^ 0xff; } *pp += ret; return (ret); } /* Convert just ASN1 INTEGER content octets to ASN1_INTEGER structure */ ASN1_INTEGER * c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, long len) { ASN1_INTEGER *ret = NULL; const unsigned char *p, *pend; unsigned char *to, *s; int i; if ((a == NULL) || ((*a) == NULL)) { if ((ret = M_ASN1_INTEGER_new()) == NULL) return (NULL); ret->type = V_ASN1_INTEGER; } else ret = (*a); p = *pp; pend = p + len; /* We must malloc stuff, even for 0 bytes otherwise it * signifies a missing NULL parameter. */ s = malloc(len + 1); if (s == NULL) { i = ERR_R_MALLOC_FAILURE; goto err; } to = s; if (!len) { /* Strictly speaking this is an illegal INTEGER but we * tolerate it. */ ret->type = V_ASN1_INTEGER; } else if (*p & 0x80) /* a negative number */ { ret->type = V_ASN1_NEG_INTEGER; if ((*p == 0xff) && (len != 1)) { p++; len--; } i = len; p += i - 1; to += i - 1; while((!*p) && i) { *(to--) = 0; i--; p--; } /* Special case: if all zeros then the number will be of * the form FF followed by n zero bytes: this corresponds to * 1 followed by n zero bytes. We've already written n zeros * so we just append an extra one and set the first byte to * a 1. This is treated separately because it is the only case * where the number of bytes is larger than len. */ if (!i) { *s = 1; s[len] = 0; len++; } else { *(to--) = (*(p--) ^ 0xff) + 1; i--; for (; i > 0; i--) *(to--) = *(p--) ^ 0xff; } } else { ret->type = V_ASN1_INTEGER; if ((*p == 0) && (len != 1)) { p++; len--; } memcpy(s, p, len); } free(ret->data); ret->data = s; ret->length = (int)len; if (a != NULL) (*a) = ret; *pp = pend; return (ret); err: ASN1err(ASN1_F_C2I_ASN1_INTEGER, i); if ((ret != NULL) && ((a == NULL) || (*a != ret))) M_ASN1_INTEGER_free(ret); return (NULL); } /* This is a version of d2i_ASN1_INTEGER that ignores the sign bit of * ASN1 integers: some broken software can encode a positive INTEGER * with its MSB set as negative (it doesn't add a padding zero). */ ASN1_INTEGER * d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, long length) { ASN1_INTEGER *ret = NULL; const unsigned char *p; unsigned char *s; long len; int inf, tag, xclass; int i; if ((a == NULL) || ((*a) == NULL)) { if ((ret = M_ASN1_INTEGER_new()) == NULL) return (NULL); ret->type = V_ASN1_INTEGER; } else ret = (*a); p = *pp; inf = ASN1_get_object(&p, &len, &tag, &xclass, length); if (inf & 0x80) { i = ASN1_R_BAD_OBJECT_HEADER; goto err; } if (tag != V_ASN1_INTEGER) { i = ASN1_R_EXPECTING_AN_INTEGER; goto err; } /* We must malloc stuff, even for 0 bytes otherwise it * signifies a missing NULL parameter. */ s = malloc((int)len + 1); if (s == NULL) { i = ERR_R_MALLOC_FAILURE; goto err; } ret->type = V_ASN1_INTEGER; if (len) { if ((*p == 0) && (len != 1)) { p++; len--; } memcpy(s, p, len); p += len; } free(ret->data); ret->data = s; ret->length = (int)len; if (a != NULL) (*a) = ret; *pp = p; return (ret); err: ASN1err(ASN1_F_D2I_ASN1_UINTEGER, i); if ((ret != NULL) && ((a == NULL) || (*a != ret))) M_ASN1_INTEGER_free(ret); return (NULL); } int ASN1_INTEGER_set(ASN1_INTEGER *a, long v) { int j, k; unsigned int i; unsigned char buf[sizeof(long) + 1]; long d; a->type = V_ASN1_INTEGER; /* XXX ssl/ssl_asn1.c:i2d_SSL_SESSION() depends upon this bound vae */ if (a->length < (int)(sizeof(long) + 1)) { free(a->data); a->data = calloc(1, sizeof(long) + 1); } if (a->data == NULL) { ASN1err(ASN1_F_ASN1_INTEGER_SET, ERR_R_MALLOC_FAILURE); return (0); } d = v; if (d < 0) { d = -d; a->type = V_ASN1_NEG_INTEGER; } for (i = 0; i < sizeof(long); i++) { if (d == 0) break; buf[i] = (int)d & 0xff; d >>= 8; } j = 0; for (k = i - 1; k >= 0; k--) a->data[j++] = buf[k]; a->length = j; return (1); } long ASN1_INTEGER_get(const ASN1_INTEGER *a) { int neg = 0, i; long r = 0; if (a == NULL) return (0L); i = a->type; if (i == V_ASN1_NEG_INTEGER) neg = 1; else if (i != V_ASN1_INTEGER) return -1; if (a->length > (int)sizeof(long)) { /* hmm... a bit ugly, return all ones */ return -1; } if (a->data == NULL) return 0; for (i = 0; i < a->length; i++) { r <<= 8; r |= (unsigned char)a->data[i]; } if (neg) r = -r; return (r); } ASN1_INTEGER * BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai) { ASN1_INTEGER *ret; int len, j; if (ai == NULL) ret = M_ASN1_INTEGER_new(); else ret = ai; if (ret == NULL) { ASN1err(ASN1_F_BN_TO_ASN1_INTEGER, ERR_R_NESTED_ASN1_ERROR); goto err; } if (BN_is_negative(bn)) ret->type = V_ASN1_NEG_INTEGER; else ret->type = V_ASN1_INTEGER; j = BN_num_bits(bn); len = ((j == 0) ? 0 : ((j / 8) + 1)); if (ret->length < len + 4) { unsigned char *new_data = realloc(ret->data, len + 4); if (!new_data) { ASN1err(ASN1_F_BN_TO_ASN1_INTEGER, ERR_R_MALLOC_FAILURE); goto err; } ret->data = new_data; } ret->length = BN_bn2bin(bn, ret->data); /* Correct zero case */ if (!ret->length) { ret->data[0] = 0; ret->length = 1; } return (ret); err: if (ret != ai) M_ASN1_INTEGER_free(ret); return (NULL); } BIGNUM * ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn) { BIGNUM *ret; if ((ret = BN_bin2bn(ai->data, ai->length, bn)) == NULL) ASN1err(ASN1_F_ASN1_INTEGER_TO_BN, ASN1_R_BN_LIB); else if (ai->type == V_ASN1_NEG_INTEGER) BN_set_negative(ret, 1); return (ret); } IMPLEMENT_STACK_OF(ASN1_INTEGER) IMPLEMENT_ASN1_SET_OF(ASN1_INTEGER) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/asn1_gen.c0000644000175000017500000005070512360020705020763 0ustar /* $OpenBSD: asn1_gen.c,v 1.11 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2002. */ /* ==================================================================== * Copyright (c) 2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #define ASN1_GEN_FLAG 0x10000 #define ASN1_GEN_FLAG_IMP (ASN1_GEN_FLAG|1) #define ASN1_GEN_FLAG_EXP (ASN1_GEN_FLAG|2) #define ASN1_GEN_FLAG_TAG (ASN1_GEN_FLAG|3) #define ASN1_GEN_FLAG_BITWRAP (ASN1_GEN_FLAG|4) #define ASN1_GEN_FLAG_OCTWRAP (ASN1_GEN_FLAG|5) #define ASN1_GEN_FLAG_SEQWRAP (ASN1_GEN_FLAG|6) #define ASN1_GEN_FLAG_SETWRAP (ASN1_GEN_FLAG|7) #define ASN1_GEN_FLAG_FORMAT (ASN1_GEN_FLAG|8) #define ASN1_GEN_STR(str,val){str, sizeof(str) - 1, val} #define ASN1_FLAG_EXP_MAX 20 /* Input formats */ /* ASCII: default */ #define ASN1_GEN_FORMAT_ASCII 1 /* UTF8 */ #define ASN1_GEN_FORMAT_UTF8 2 /* Hex */ #define ASN1_GEN_FORMAT_HEX 3 /* List of bits */ #define ASN1_GEN_FORMAT_BITLIST 4 struct tag_name_st { const char *strnam; int len; int tag; }; typedef struct { int exp_tag; int exp_class; int exp_constructed; int exp_pad; long exp_len; } tag_exp_type; typedef struct { int imp_tag; int imp_class; int utype; int format; const char *str; tag_exp_type exp_list[ASN1_FLAG_EXP_MAX]; int exp_count; } tag_exp_arg; static int bitstr_cb(const char *elem, int len, void *bitstr); static int asn1_cb(const char *elem, int len, void *bitstr); static int append_exp(tag_exp_arg *arg, int exp_tag, int exp_class, int exp_constructed, int exp_pad, int imp_ok); static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass); static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf); static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype); static int asn1_str2tag(const char *tagstr, int len); ASN1_TYPE * ASN1_generate_nconf(char *str, CONF *nconf) { X509V3_CTX cnf; if (!nconf) return ASN1_generate_v3(str, NULL); X509V3_set_nconf(&cnf, nconf); return ASN1_generate_v3(str, &cnf); } ASN1_TYPE * ASN1_generate_v3(char *str, X509V3_CTX *cnf) { ASN1_TYPE *ret; tag_exp_arg asn1_tags; tag_exp_type *etmp; int i, len; unsigned char *orig_der = NULL, *new_der = NULL; const unsigned char *cpy_start; unsigned char *p; const unsigned char *cp; int cpy_len; long hdr_len; int hdr_constructed = 0, hdr_tag, hdr_class; int r; asn1_tags.imp_tag = -1; asn1_tags.imp_class = -1; asn1_tags.format = ASN1_GEN_FORMAT_ASCII; asn1_tags.exp_count = 0; if (CONF_parse_list(str, ',', 1, asn1_cb, &asn1_tags) != 0) return NULL; if ((asn1_tags.utype == V_ASN1_SEQUENCE) || (asn1_tags.utype == V_ASN1_SET)) { if (!cnf) { ASN1err(ASN1_F_ASN1_GENERATE_V3, ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG); return NULL; } ret = asn1_multi(asn1_tags.utype, asn1_tags.str, cnf); } else ret = asn1_str2type(asn1_tags.str, asn1_tags.format, asn1_tags.utype); if (!ret) return NULL; /* If no tagging return base type */ if ((asn1_tags.imp_tag == -1) && (asn1_tags.exp_count == 0)) return ret; /* Generate the encoding */ cpy_len = i2d_ASN1_TYPE(ret, &orig_der); ASN1_TYPE_free(ret); ret = NULL; /* Set point to start copying for modified encoding */ cpy_start = orig_der; /* Do we need IMPLICIT tagging? */ if (asn1_tags.imp_tag != -1) { /* If IMPLICIT we will replace the underlying tag */ /* Skip existing tag+len */ r = ASN1_get_object(&cpy_start, &hdr_len, &hdr_tag, &hdr_class, cpy_len); if (r & 0x80) goto err; /* Update copy length */ cpy_len -= cpy_start - orig_der; /* For IMPLICIT tagging the length should match the * original length and constructed flag should be * consistent. */ if (r & 0x1) { /* Indefinite length constructed */ hdr_constructed = 2; hdr_len = 0; } else /* Just retain constructed flag */ hdr_constructed = r & V_ASN1_CONSTRUCTED; /* Work out new length with IMPLICIT tag: ignore constructed * because it will mess up if indefinite length */ len = ASN1_object_size(0, hdr_len, asn1_tags.imp_tag); } else len = cpy_len; /* Work out length in any EXPLICIT, starting from end */ for (i = 0, etmp = asn1_tags.exp_list + asn1_tags.exp_count - 1; i < asn1_tags.exp_count; i++, etmp--) { /* Content length: number of content octets + any padding */ len += etmp->exp_pad; etmp->exp_len = len; /* Total object length: length including new header */ len = ASN1_object_size(0, len, etmp->exp_tag); } /* Allocate buffer for new encoding */ new_der = malloc(len); if (!new_der) goto err; /* Generate tagged encoding */ p = new_der; /* Output explicit tags first */ for (i = 0, etmp = asn1_tags.exp_list; i < asn1_tags.exp_count; i++, etmp++) { ASN1_put_object(&p, etmp->exp_constructed, etmp->exp_len, etmp->exp_tag, etmp->exp_class); if (etmp->exp_pad) *p++ = 0; } /* If IMPLICIT, output tag */ if (asn1_tags.imp_tag != -1) { if (asn1_tags.imp_class == V_ASN1_UNIVERSAL && (asn1_tags.imp_tag == V_ASN1_SEQUENCE || asn1_tags.imp_tag == V_ASN1_SET)) hdr_constructed = V_ASN1_CONSTRUCTED; ASN1_put_object(&p, hdr_constructed, hdr_len, asn1_tags.imp_tag, asn1_tags.imp_class); } /* Copy across original encoding */ memcpy(p, cpy_start, cpy_len); cp = new_der; /* Obtain new ASN1_TYPE structure */ ret = d2i_ASN1_TYPE(NULL, &cp, len); err: free(orig_der); free(new_der); return ret; } static int asn1_cb(const char *elem, int len, void *bitstr) { tag_exp_arg *arg = bitstr; int i; int utype; int vlen = 0; const char *p, *vstart = NULL; int tmp_tag, tmp_class; for (i = 0, p = elem; i < len; p++, i++) { /* Look for the ':' in name value pairs */ if (*p == ':') { vstart = p + 1; vlen = len - (vstart - elem); len = p - elem; break; } } utype = asn1_str2tag(elem, len); if (utype == -1) { ASN1err(ASN1_F_ASN1_CB, ASN1_R_UNKNOWN_TAG); ERR_asprintf_error_data("tag=%s", elem); return -1; } /* If this is not a modifier mark end of string and exit */ if (!(utype & ASN1_GEN_FLAG)) { arg->utype = utype; arg->str = vstart; /* If no value and not end of string, error */ if (!vstart && elem[len]) { ASN1err(ASN1_F_ASN1_CB, ASN1_R_MISSING_VALUE); return -1; } return 0; } switch (utype) { case ASN1_GEN_FLAG_IMP: /* Check for illegal multiple IMPLICIT tagging */ if (arg->imp_tag != -1) { ASN1err(ASN1_F_ASN1_CB, ASN1_R_ILLEGAL_NESTED_TAGGING); return -1; } if (!parse_tagging(vstart, vlen, &arg->imp_tag, &arg->imp_class)) return -1; break; case ASN1_GEN_FLAG_EXP: if (!parse_tagging(vstart, vlen, &tmp_tag, &tmp_class)) return -1; if (!append_exp(arg, tmp_tag, tmp_class, 1, 0, 0)) return -1; break; case ASN1_GEN_FLAG_SEQWRAP: if (!append_exp(arg, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, 1, 0, 1)) return -1; break; case ASN1_GEN_FLAG_SETWRAP: if (!append_exp(arg, V_ASN1_SET, V_ASN1_UNIVERSAL, 1, 0, 1)) return -1; break; case ASN1_GEN_FLAG_BITWRAP: if (!append_exp(arg, V_ASN1_BIT_STRING, V_ASN1_UNIVERSAL, 0, 1, 1)) return -1; break; case ASN1_GEN_FLAG_OCTWRAP: if (!append_exp(arg, V_ASN1_OCTET_STRING, V_ASN1_UNIVERSAL, 0, 0, 1)) return -1; break; case ASN1_GEN_FLAG_FORMAT: if (!strncmp(vstart, "ASCII", 5)) arg->format = ASN1_GEN_FORMAT_ASCII; else if (!strncmp(vstart, "UTF8", 4)) arg->format = ASN1_GEN_FORMAT_UTF8; else if (!strncmp(vstart, "HEX", 3)) arg->format = ASN1_GEN_FORMAT_HEX; else if (!strncmp(vstart, "BITLIST", 7)) arg->format = ASN1_GEN_FORMAT_BITLIST; else { ASN1err(ASN1_F_ASN1_CB, ASN1_R_UNKOWN_FORMAT); return -1; } break; } return 1; } static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass) { long tag_num; char *eptr; if (!vstart) return 0; tag_num = strtoul(vstart, &eptr, 10); /* Check we haven't gone past max length: should be impossible */ if (eptr && *eptr && (eptr > vstart + vlen)) return 0; if (tag_num < 0) { ASN1err(ASN1_F_PARSE_TAGGING, ASN1_R_INVALID_NUMBER); return 0; } *ptag = tag_num; /* If we have non numeric characters, parse them */ if (eptr) vlen -= eptr - vstart; else vlen = 0; if (vlen) { switch (*eptr) { case 'U': *pclass = V_ASN1_UNIVERSAL; break; case 'A': *pclass = V_ASN1_APPLICATION; break; case 'P': *pclass = V_ASN1_PRIVATE; break; case 'C': *pclass = V_ASN1_CONTEXT_SPECIFIC; break; default: ASN1err(ASN1_F_PARSE_TAGGING, ASN1_R_INVALID_MODIFIER); ERR_asprintf_error_data("Char=%c", *eptr); return 0; break; } } else *pclass = V_ASN1_CONTEXT_SPECIFIC; return 1; } /* Handle multiple types: SET and SEQUENCE */ static ASN1_TYPE * asn1_multi(int utype, const char *section, X509V3_CTX *cnf) { ASN1_TYPE *ret = NULL; STACK_OF(ASN1_TYPE) *sk = NULL; STACK_OF(CONF_VALUE) *sect = NULL; unsigned char *der = NULL; int derlen; int i; sk = sk_ASN1_TYPE_new_null(); if (!sk) goto bad; if (section) { if (!cnf) goto bad; sect = X509V3_get_section(cnf, (char *)section); if (!sect) goto bad; for (i = 0; i < sk_CONF_VALUE_num(sect); i++) { ASN1_TYPE *typ = ASN1_generate_v3( sk_CONF_VALUE_value(sect, i)->value, cnf); if (!typ) goto bad; if (!sk_ASN1_TYPE_push(sk, typ)) goto bad; } } /* Now we has a STACK of the components, convert to the correct form */ if (utype == V_ASN1_SET) derlen = i2d_ASN1_SET_ANY(sk, &der); else derlen = i2d_ASN1_SEQUENCE_ANY(sk, &der); if (derlen < 0) goto bad; if (!(ret = ASN1_TYPE_new())) goto bad; if (!(ret->value.asn1_string = ASN1_STRING_type_new(utype))) goto bad; ret->type = utype; ret->value.asn1_string->data = der; ret->value.asn1_string->length = derlen; der = NULL; bad: free(der); if (sk) sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free); if (sect) X509V3_section_free(cnf, sect); return ret; } static int append_exp(tag_exp_arg *arg, int exp_tag, int exp_class, int exp_constructed, int exp_pad, int imp_ok) { tag_exp_type *exp_tmp; /* Can only have IMPLICIT if permitted */ if ((arg->imp_tag != -1) && !imp_ok) { ASN1err(ASN1_F_APPEND_EXP, ASN1_R_ILLEGAL_IMPLICIT_TAG); return 0; } if (arg->exp_count == ASN1_FLAG_EXP_MAX) { ASN1err(ASN1_F_APPEND_EXP, ASN1_R_DEPTH_EXCEEDED); return 0; } exp_tmp = &arg->exp_list[arg->exp_count++]; /* If IMPLICIT set tag to implicit value then * reset implicit tag since it has been used. */ if (arg->imp_tag != -1) { exp_tmp->exp_tag = arg->imp_tag; exp_tmp->exp_class = arg->imp_class; arg->imp_tag = -1; arg->imp_class = -1; } else { exp_tmp->exp_tag = exp_tag; exp_tmp->exp_class = exp_class; } exp_tmp->exp_constructed = exp_constructed; exp_tmp->exp_pad = exp_pad; return 1; } static int asn1_str2tag(const char *tagstr, int len) { unsigned int i; static const struct tag_name_st *tntmp, tnst [] = { ASN1_GEN_STR("BOOL", V_ASN1_BOOLEAN), ASN1_GEN_STR("BOOLEAN", V_ASN1_BOOLEAN), ASN1_GEN_STR("NULL", V_ASN1_NULL), ASN1_GEN_STR("INT", V_ASN1_INTEGER), ASN1_GEN_STR("INTEGER", V_ASN1_INTEGER), ASN1_GEN_STR("ENUM", V_ASN1_ENUMERATED), ASN1_GEN_STR("ENUMERATED", V_ASN1_ENUMERATED), ASN1_GEN_STR("OID", V_ASN1_OBJECT), ASN1_GEN_STR("OBJECT", V_ASN1_OBJECT), ASN1_GEN_STR("UTCTIME", V_ASN1_UTCTIME), ASN1_GEN_STR("UTC", V_ASN1_UTCTIME), ASN1_GEN_STR("GENERALIZEDTIME", V_ASN1_GENERALIZEDTIME), ASN1_GEN_STR("GENTIME", V_ASN1_GENERALIZEDTIME), ASN1_GEN_STR("OCT", V_ASN1_OCTET_STRING), ASN1_GEN_STR("OCTETSTRING", V_ASN1_OCTET_STRING), ASN1_GEN_STR("BITSTR", V_ASN1_BIT_STRING), ASN1_GEN_STR("BITSTRING", V_ASN1_BIT_STRING), ASN1_GEN_STR("UNIVERSALSTRING", V_ASN1_UNIVERSALSTRING), ASN1_GEN_STR("UNIV", V_ASN1_UNIVERSALSTRING), ASN1_GEN_STR("IA5", V_ASN1_IA5STRING), ASN1_GEN_STR("IA5STRING", V_ASN1_IA5STRING), ASN1_GEN_STR("UTF8", V_ASN1_UTF8STRING), ASN1_GEN_STR("UTF8String", V_ASN1_UTF8STRING), ASN1_GEN_STR("BMP", V_ASN1_BMPSTRING), ASN1_GEN_STR("BMPSTRING", V_ASN1_BMPSTRING), ASN1_GEN_STR("VISIBLESTRING", V_ASN1_VISIBLESTRING), ASN1_GEN_STR("VISIBLE", V_ASN1_VISIBLESTRING), ASN1_GEN_STR("PRINTABLESTRING", V_ASN1_PRINTABLESTRING), ASN1_GEN_STR("PRINTABLE", V_ASN1_PRINTABLESTRING), ASN1_GEN_STR("T61", V_ASN1_T61STRING), ASN1_GEN_STR("T61STRING", V_ASN1_T61STRING), ASN1_GEN_STR("TELETEXSTRING", V_ASN1_T61STRING), ASN1_GEN_STR("GeneralString", V_ASN1_GENERALSTRING), ASN1_GEN_STR("GENSTR", V_ASN1_GENERALSTRING), ASN1_GEN_STR("NUMERIC", V_ASN1_NUMERICSTRING), ASN1_GEN_STR("NUMERICSTRING", V_ASN1_NUMERICSTRING), /* Special cases */ ASN1_GEN_STR("SEQUENCE", V_ASN1_SEQUENCE), ASN1_GEN_STR("SEQ", V_ASN1_SEQUENCE), ASN1_GEN_STR("SET", V_ASN1_SET), /* type modifiers */ /* Explicit tag */ ASN1_GEN_STR("EXP", ASN1_GEN_FLAG_EXP), ASN1_GEN_STR("EXPLICIT", ASN1_GEN_FLAG_EXP), /* Implicit tag */ ASN1_GEN_STR("IMP", ASN1_GEN_FLAG_IMP), ASN1_GEN_STR("IMPLICIT", ASN1_GEN_FLAG_IMP), /* OCTET STRING wrapper */ ASN1_GEN_STR("OCTWRAP", ASN1_GEN_FLAG_OCTWRAP), /* SEQUENCE wrapper */ ASN1_GEN_STR("SEQWRAP", ASN1_GEN_FLAG_SEQWRAP), /* SET wrapper */ ASN1_GEN_STR("SETWRAP", ASN1_GEN_FLAG_SETWRAP), /* BIT STRING wrapper */ ASN1_GEN_STR("BITWRAP", ASN1_GEN_FLAG_BITWRAP), ASN1_GEN_STR("FORM", ASN1_GEN_FLAG_FORMAT), ASN1_GEN_STR("FORMAT", ASN1_GEN_FLAG_FORMAT), }; if (len == -1) len = strlen(tagstr); tntmp = tnst; for (i = 0; i < sizeof(tnst) / sizeof(struct tag_name_st); i++, tntmp++) { if ((len == tntmp->len) && !strncmp(tntmp->strnam, tagstr, len)) return tntmp->tag; } return -1; } static ASN1_TYPE * asn1_str2type(const char *str, int format, int utype) { ASN1_TYPE *atmp = NULL; CONF_VALUE vtmp; unsigned char *rdata; long rdlen; int no_unused = 1; if (!(atmp = ASN1_TYPE_new())) { ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE); return NULL; } if (!str) str = ""; switch (utype) { case V_ASN1_NULL: if (str && *str) { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_NULL_VALUE); goto bad_form; } break; case V_ASN1_BOOLEAN: if (format != ASN1_GEN_FORMAT_ASCII) { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_NOT_ASCII_FORMAT); goto bad_form; } vtmp.name = NULL; vtmp.section = NULL; vtmp.value = (char *)str; if (!X509V3_get_value_bool(&vtmp, &atmp->value.boolean)) { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_BOOLEAN); goto bad_str; } break; case V_ASN1_INTEGER: case V_ASN1_ENUMERATED: if (format != ASN1_GEN_FORMAT_ASCII) { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_INTEGER_NOT_ASCII_FORMAT); goto bad_form; } if (!(atmp->value.integer = s2i_ASN1_INTEGER(NULL, (char *)str))) { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_INTEGER); goto bad_str; } break; case V_ASN1_OBJECT: if (format != ASN1_GEN_FORMAT_ASCII) { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_OBJECT_NOT_ASCII_FORMAT); goto bad_form; } if (!(atmp->value.object = OBJ_txt2obj(str, 0))) { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_OBJECT); goto bad_str; } break; case V_ASN1_UTCTIME: case V_ASN1_GENERALIZEDTIME: if (format != ASN1_GEN_FORMAT_ASCII) { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_TIME_NOT_ASCII_FORMAT); goto bad_form; } if (!(atmp->value.asn1_string = ASN1_STRING_new())) { ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE); goto bad_str; } if (!ASN1_STRING_set(atmp->value.asn1_string, str, -1)) { ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE); goto bad_str; } atmp->value.asn1_string->type = utype; if (!ASN1_TIME_check(atmp->value.asn1_string)) { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_TIME_VALUE); goto bad_str; } break; case V_ASN1_BMPSTRING: case V_ASN1_PRINTABLESTRING: case V_ASN1_IA5STRING: case V_ASN1_T61STRING: case V_ASN1_UTF8STRING: case V_ASN1_VISIBLESTRING: case V_ASN1_UNIVERSALSTRING: case V_ASN1_GENERALSTRING: case V_ASN1_NUMERICSTRING: if (format == ASN1_GEN_FORMAT_ASCII) format = MBSTRING_ASC; else if (format == ASN1_GEN_FORMAT_UTF8) format = MBSTRING_UTF8; else { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_FORMAT); goto bad_form; } if (ASN1_mbstring_copy(&atmp->value.asn1_string, (unsigned char *)str, -1, format, ASN1_tag2bit(utype)) <= 0) { ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE); goto bad_str; } break; case V_ASN1_BIT_STRING: case V_ASN1_OCTET_STRING: if (!(atmp->value.asn1_string = ASN1_STRING_new())) { ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE); goto bad_form; } if (format == ASN1_GEN_FORMAT_HEX) { if (!(rdata = string_to_hex((char *)str, &rdlen))) { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_HEX); goto bad_str; } atmp->value.asn1_string->data = rdata; atmp->value.asn1_string->length = rdlen; atmp->value.asn1_string->type = utype; } else if (format == ASN1_GEN_FORMAT_ASCII) ASN1_STRING_set(atmp->value.asn1_string, str, -1); else if ((format == ASN1_GEN_FORMAT_BITLIST) && (utype == V_ASN1_BIT_STRING)) { if (!CONF_parse_list(str, ',', 1, bitstr_cb, atmp->value.bit_string)) { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_LIST_ERROR); goto bad_str; } no_unused = 0; } else { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_BITSTRING_FORMAT); goto bad_form; } if ((utype == V_ASN1_BIT_STRING) && no_unused) { atmp->value.asn1_string->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); atmp->value.asn1_string->flags |= ASN1_STRING_FLAG_BITS_LEFT; } break; default: ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_UNSUPPORTED_TYPE); goto bad_str; break; } atmp->type = utype; return atmp; bad_str: ERR_asprintf_error_data("string=%s", str); bad_form: ASN1_TYPE_free(atmp); return NULL; } static int bitstr_cb(const char *elem, int len, void *bitstr) { long bitnum; char *eptr; if (!elem) return 0; bitnum = strtoul(elem, &eptr, 10); if (eptr && *eptr && (eptr != elem + len)) return 0; if (bitnum < 0) { ASN1err(ASN1_F_BITSTR_CB, ASN1_R_INVALID_NUMBER); return 0; } if (!ASN1_BIT_STRING_set_bit(bitstr, bitnum, 1)) { ASN1err(ASN1_F_BITSTR_CB, ERR_R_MALLOC_FAILURE); return 0; } return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_strex.c0000644000175000017500000003755012360020705020740 0ustar /* $OpenBSD: a_strex.c,v 1.23 2014/07/10 20:42:45 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include "asn1_locl.h" #include "charmap.h" /* ASN1_STRING_print_ex() and X509_NAME_print_ex(). * Enhanced string and name printing routines handling * multibyte characters, RFC2253 and a host of other * options. */ #define CHARTYPE_BS_ESC (ASN1_STRFLGS_ESC_2253 | CHARTYPE_FIRST_ESC_2253 | CHARTYPE_LAST_ESC_2253) #define ESC_FLAGS (ASN1_STRFLGS_ESC_2253 | \ ASN1_STRFLGS_ESC_QUOTE | \ ASN1_STRFLGS_ESC_CTRL | \ ASN1_STRFLGS_ESC_MSB) /* Three IO functions for sending data to memory, a BIO and * and a FILE pointer. */ #if 0 /* never used */ static int send_mem_chars(void *arg, const void *buf, int len) { unsigned char **out = arg; if (!out) return 1; memcpy(*out, buf, len); *out += len; return 1; } #endif static int send_bio_chars(void *arg, const void *buf, int len) { if (!arg) return 1; if (BIO_write(arg, buf, len) != len) return 0; return 1; } static int send_fp_chars(void *arg, const void *buf, int len) { if (!arg) return 1; if (fwrite(buf, 1, (size_t)len, arg) != (size_t)len) return 0; return 1; } typedef int char_io(void *arg, const void *buf, int len); /* This function handles display of * strings, one character at a time. * It is passed an unsigned long for each * character because it could come from 2 or even * 4 byte forms. */ static int do_esc_char(unsigned long c, unsigned char flags, char *do_quotes, char_io *io_ch, void *arg) { unsigned char chflgs, chtmp; char tmphex[sizeof(long) * 2 + 3]; if (c > 0xffffffffL) return -1; if (c > 0xffff) { snprintf(tmphex, sizeof tmphex, "\\W%08lX", c); if (!io_ch(arg, tmphex, 10)) return -1; return 10; } if (c > 0xff) { snprintf(tmphex, sizeof tmphex, "\\U%04lX", c); if (!io_ch(arg, tmphex, 6)) return -1; return 6; } chtmp = (unsigned char)c; if (chtmp > 0x7f) chflgs = flags & ASN1_STRFLGS_ESC_MSB; else chflgs = char_type[chtmp] & flags; if (chflgs & CHARTYPE_BS_ESC) { /* If we don't escape with quotes, signal we need quotes */ if (chflgs & ASN1_STRFLGS_ESC_QUOTE) { if (do_quotes) *do_quotes = 1; if (!io_ch(arg, &chtmp, 1)) return -1; return 1; } if (!io_ch(arg, "\\", 1)) return -1; if (!io_ch(arg, &chtmp, 1)) return -1; return 2; } if (chflgs & (ASN1_STRFLGS_ESC_CTRL|ASN1_STRFLGS_ESC_MSB)) { snprintf(tmphex, sizeof tmphex, "\\%02X", chtmp); if (!io_ch(arg, tmphex, 3)) return -1; return 3; } /* If we get this far and do any escaping at all must escape * the escape character itself: backslash. */ if (chtmp == '\\' && flags & ESC_FLAGS) { if (!io_ch(arg, "\\\\", 2)) return -1; return 2; } if (!io_ch(arg, &chtmp, 1)) return -1; return 1; } #define BUF_TYPE_WIDTH_MASK 0x7 #define BUF_TYPE_CONVUTF8 0x8 /* This function sends each character in a buffer to * do_esc_char(). It interprets the content formats * and converts to or from UTF8 as appropriate. */ static int do_buf(unsigned char *buf, int buflen, int type, unsigned char flags, char *quotes, char_io *io_ch, void *arg) { int i, outlen, len; unsigned char orflags, *p, *q; unsigned long c; p = buf; q = buf + buflen; outlen = 0; while (p != q) { if (p == buf && flags & ASN1_STRFLGS_ESC_2253) orflags = CHARTYPE_FIRST_ESC_2253; else orflags = 0; switch (type & BUF_TYPE_WIDTH_MASK) { case 4: c = ((unsigned long)*p++) << 24; c |= ((unsigned long)*p++) << 16; c |= ((unsigned long)*p++) << 8; c |= *p++; if (c > UNICODE_MAX || UNICODE_IS_SURROGATE(c)) return -1; break; case 2: c = ((unsigned long)*p++) << 8; c |= *p++; if (UNICODE_IS_SURROGATE(c)) return -1; break; case 1: c = *p++; break; case 0: i = UTF8_getc(p, q - p, &c); if (i < 0) return -1; /* Invalid UTF8String */ p += i; break; default: return -1; /* invalid width */ } if (p == q && flags & ASN1_STRFLGS_ESC_2253) orflags = CHARTYPE_LAST_ESC_2253; if (type & BUF_TYPE_CONVUTF8) { unsigned char utfbuf[6]; int utflen; utflen = UTF8_putc(utfbuf, sizeof utfbuf, c); if (utflen < 0) return -1; for (i = 0; i < utflen; i++) { /* We don't need to worry about setting orflags correctly * because if utflen==1 its value will be correct anyway * otherwise each character will be > 0x7f and so the * character will never be escaped on first and last. */ len = do_esc_char(utfbuf[i], (unsigned char)(flags | orflags), quotes, io_ch, arg); if (len < 0) return -1; outlen += len; } } else { len = do_esc_char(c, (unsigned char)(flags | orflags), quotes, io_ch, arg); if (len < 0) return -1; outlen += len; } } return outlen; } /* This function hex dumps a buffer of characters */ static int do_hex_dump(char_io *io_ch, void *arg, unsigned char *buf, int buflen) { static const char hexdig[] = "0123456789ABCDEF"; unsigned char *p, *q; char hextmp[2]; if (arg) { p = buf; q = buf + buflen; while (p != q) { hextmp[0] = hexdig[*p >> 4]; hextmp[1] = hexdig[*p & 0xf]; if (!io_ch(arg, hextmp, 2)) return -1; p++; } } return buflen << 1; } /* "dump" a string. This is done when the type is unknown, * or the flags request it. We can either dump the content * octets or the entire DER encoding. This uses the RFC2253 * #01234 format. */ static int do_dump(unsigned long lflags, char_io *io_ch, void *arg, ASN1_STRING *str) { /* Placing the ASN1_STRING in a temp ASN1_TYPE allows * the DER encoding to readily obtained */ ASN1_TYPE t; unsigned char *der_buf, *p; int outlen, der_len; if (!io_ch(arg, "#", 1)) return -1; /* If we don't dump DER encoding just dump content octets */ if (!(lflags & ASN1_STRFLGS_DUMP_DER)) { outlen = do_hex_dump(io_ch, arg, str->data, str->length); if (outlen < 0) return -1; return outlen + 1; } t.type = str->type; t.value.ptr = (char *)str; der_len = i2d_ASN1_TYPE(&t, NULL); der_buf = malloc(der_len); if (!der_buf) return -1; p = der_buf; i2d_ASN1_TYPE(&t, &p); outlen = do_hex_dump(io_ch, arg, der_buf, der_len); free(der_buf); if (outlen < 0) return -1; return outlen + 1; } /* Lookup table to convert tags to character widths, * 0 = UTF8 encoded, -1 is used for non string types * otherwise it is the number of bytes per character */ static const signed char tag2nbyte[] = { -1, -1, -1, -1, -1, /* 0-4 */ -1, -1, -1, -1, -1, /* 5-9 */ -1, -1, 0, -1, /* 10-13 */ -1, -1, -1, -1, /* 15-17 */ -1, 1, 1, /* 18-20 */ -1, 1, 1, 1, /* 21-24 */ -1, 1, -1, /* 25-27 */ 4, -1, 2 /* 28-30 */ }; /* This is the main function, print out an * ASN1_STRING taking note of various escape * and display options. Returns number of * characters written or -1 if an error * occurred. */ static int do_print_ex(char_io *io_ch, void *arg, unsigned long lflags, ASN1_STRING *str) { int outlen, len; int type; char quotes; unsigned char flags; quotes = 0; /* Keep a copy of escape flags */ flags = (unsigned char)(lflags & ESC_FLAGS); type = str->type; outlen = 0; if (lflags & ASN1_STRFLGS_SHOW_TYPE) { const char *tagname; tagname = ASN1_tag2str(type); outlen += strlen(tagname); if (!io_ch(arg, tagname, outlen) || !io_ch(arg, ":", 1)) return -1; outlen++; } /* Decide what to do with type, either dump content or display it */ /* Dump everything */ if (lflags & ASN1_STRFLGS_DUMP_ALL) type = -1; /* Ignore the string type */ else if (lflags & ASN1_STRFLGS_IGNORE_TYPE) type = 1; else { /* Else determine width based on type */ if ((type > 0) && (type < 31)) type = tag2nbyte[type]; else type = -1; if ((type == -1) && !(lflags & ASN1_STRFLGS_DUMP_UNKNOWN)) type = 1; } if (type == -1) { len = do_dump(lflags, io_ch, arg, str); if (len < 0) return -1; outlen += len; return outlen; } if (lflags & ASN1_STRFLGS_UTF8_CONVERT) { /* Note: if string is UTF8 and we want * to convert to UTF8 then we just interpret * it as 1 byte per character to avoid converting * twice. */ if (!type) type = 1; else type |= BUF_TYPE_CONVUTF8; } len = do_buf(str->data, str->length, type, flags, "es, io_ch, NULL); if (len < 0) return -1; outlen += len; if (quotes) outlen += 2; if (!arg) return outlen; if (quotes && !io_ch(arg, "\"", 1)) return -1; if (do_buf(str->data, str->length, type, flags, NULL, io_ch, arg) < 0) return -1; if (quotes && !io_ch(arg, "\"", 1)) return -1; return outlen; } /* Used for line indenting: print 'indent' spaces */ static int do_indent(char_io *io_ch, void *arg, int indent) { int i; for (i = 0; i < indent; i++) if (!io_ch(arg, " ", 1)) return 0; return 1; } #define FN_WIDTH_LN 25 #define FN_WIDTH_SN 10 static int do_name_ex(char_io *io_ch, void *arg, X509_NAME *n, int indent, unsigned long flags) { int i, prev = -1, orflags, cnt; int fn_opt, fn_nid; ASN1_OBJECT *fn; ASN1_STRING *val; X509_NAME_ENTRY *ent; char objtmp[80]; const char *objbuf; int outlen, len; char *sep_dn, *sep_mv, *sep_eq; int sep_dn_len, sep_mv_len, sep_eq_len; if (indent < 0) indent = 0; outlen = indent; if (!do_indent(io_ch, arg, indent)) return -1; switch (flags & XN_FLAG_SEP_MASK) { case XN_FLAG_SEP_MULTILINE: sep_dn = "\n"; sep_dn_len = 1; sep_mv = " + "; sep_mv_len = 3; break; case XN_FLAG_SEP_COMMA_PLUS: sep_dn = ","; sep_dn_len = 1; sep_mv = "+"; sep_mv_len = 1; indent = 0; break; case XN_FLAG_SEP_CPLUS_SPC: sep_dn = ", "; sep_dn_len = 2; sep_mv = " + "; sep_mv_len = 3; indent = 0; break; case XN_FLAG_SEP_SPLUS_SPC: sep_dn = "; "; sep_dn_len = 2; sep_mv = " + "; sep_mv_len = 3; indent = 0; break; default: return -1; } if (flags & XN_FLAG_SPC_EQ) { sep_eq = " = "; sep_eq_len = 3; } else { sep_eq = "="; sep_eq_len = 1; } fn_opt = flags & XN_FLAG_FN_MASK; cnt = X509_NAME_entry_count(n); for (i = 0; i < cnt; i++) { if (flags & XN_FLAG_DN_REV) ent = X509_NAME_get_entry(n, cnt - i - 1); else ent = X509_NAME_get_entry(n, i); if (prev != -1) { if (prev == ent->set) { if (!io_ch(arg, sep_mv, sep_mv_len)) return -1; outlen += sep_mv_len; } else { if (!io_ch(arg, sep_dn, sep_dn_len)) return -1; outlen += sep_dn_len; if (!do_indent(io_ch, arg, indent)) return -1; outlen += indent; } } prev = ent->set; fn = X509_NAME_ENTRY_get_object(ent); val = X509_NAME_ENTRY_get_data(ent); fn_nid = OBJ_obj2nid(fn); if (fn_opt != XN_FLAG_FN_NONE) { int objlen, fld_len; if ((fn_opt == XN_FLAG_FN_OID) || (fn_nid == NID_undef)) { OBJ_obj2txt(objtmp, sizeof objtmp, fn, 1); fld_len = 0; /* XXX: what should this be? */ objbuf = objtmp; } else { if (fn_opt == XN_FLAG_FN_SN) { fld_len = FN_WIDTH_SN; objbuf = OBJ_nid2sn(fn_nid); } else if (fn_opt == XN_FLAG_FN_LN) { fld_len = FN_WIDTH_LN; objbuf = OBJ_nid2ln(fn_nid); } else { fld_len = 0; /* XXX: what should this be? */ objbuf = ""; } } objlen = strlen(objbuf); if (!io_ch(arg, objbuf, objlen)) return -1; if ((objlen < fld_len) && (flags & XN_FLAG_FN_ALIGN)) { if (!do_indent(io_ch, arg, fld_len - objlen)) return -1; outlen += fld_len - objlen; } if (!io_ch(arg, sep_eq, sep_eq_len)) return -1; outlen += objlen + sep_eq_len; } /* If the field name is unknown then fix up the DER dump * flag. We might want to limit this further so it will * DER dump on anything other than a few 'standard' fields. */ if ((fn_nid == NID_undef) && (flags & XN_FLAG_DUMP_UNKNOWN_FIELDS)) orflags = ASN1_STRFLGS_DUMP_ALL; else orflags = 0; len = do_print_ex(io_ch, arg, flags | orflags, val); if (len < 0) return -1; outlen += len; } return outlen; } /* Wrappers round the main functions */ int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags) { if (flags == XN_FLAG_COMPAT) return X509_NAME_print(out, nm, indent); return do_name_ex(send_bio_chars, out, nm, indent, flags); } int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags) { if (flags == XN_FLAG_COMPAT) { BIO *btmp; int ret; btmp = BIO_new_fp(fp, BIO_NOCLOSE); if (!btmp) return -1; ret = X509_NAME_print(btmp, nm, indent); BIO_free(btmp); return ret; } return do_name_ex(send_fp_chars, fp, nm, indent, flags); } int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags) { return do_print_ex(send_bio_chars, out, flags, str); } int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags) { return do_print_ex(send_fp_chars, fp, flags, str); } /* Utility function: convert any string type to UTF8, returns number of bytes * in output string or a negative error code */ int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in) { ASN1_STRING stmp, *str = &stmp; int mbflag, type, ret; if (!in) return -1; type = in->type; if ((type < 0) || (type > 30)) return -1; mbflag = tag2nbyte[type]; if (mbflag == -1) return -1; mbflag |= MBSTRING_FLAG; stmp.data = NULL; stmp.length = 0; ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8STRING); if (ret < 0) return ret; *out = stmp.data; return stmp.length; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_octet.c0000644000175000017500000000707312360020705020706 0ustar /* $OpenBSD: a_octet.c,v 1.8 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *x) { return M_ASN1_OCTET_STRING_dup(x); } int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, const ASN1_OCTET_STRING *b) { return M_ASN1_OCTET_STRING_cmp(a, b); } int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, const unsigned char *d, int len) { return M_ASN1_OCTET_STRING_set(x, d, len); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/asn1_locl.h0000644000175000017500000001331112360020705021140 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Internal ASN1 structures and functions: not for application use */ /* ASN1 print context structure */ struct asn1_pctx_st { unsigned long flags; unsigned long nm_flags; unsigned long cert_flags; unsigned long oid_flags; unsigned long str_flags; } /* ASN1_PCTX */; /* ASN1 public key method structure */ struct evp_pkey_asn1_method_st { int pkey_id; int pkey_base_id; unsigned long pkey_flags; char *pem_str; char *info; int (*pub_decode)(EVP_PKEY *pk, X509_PUBKEY *pub); int (*pub_encode)(X509_PUBKEY *pub, const EVP_PKEY *pk); int (*pub_cmp)(const EVP_PKEY *a, const EVP_PKEY *b); int (*pub_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx); int (*priv_decode)(EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO *p8inf); int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk); int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx); int (*pkey_size)(const EVP_PKEY *pk); int (*pkey_bits)(const EVP_PKEY *pk); int (*param_decode)(EVP_PKEY *pkey, const unsigned char **pder, int derlen); int (*param_encode)(const EVP_PKEY *pkey, unsigned char **pder); int (*param_missing)(const EVP_PKEY *pk); int (*param_copy)(EVP_PKEY *to, const EVP_PKEY *from); int (*param_cmp)(const EVP_PKEY *a, const EVP_PKEY *b); int (*param_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx); int (*sig_print)(BIO *out, const X509_ALGOR *sigalg, const ASN1_STRING *sig, int indent, ASN1_PCTX *pctx); void (*pkey_free)(EVP_PKEY *pkey); int (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1, void *arg2); /* Legacy functions for old PEM */ int (*old_priv_decode)(EVP_PKEY *pkey, const unsigned char **pder, int derlen); int (*old_priv_encode)(const EVP_PKEY *pkey, unsigned char **pder); /* Custom ASN1 signature verification */ int (*item_verify)(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, X509_ALGOR *a, ASN1_BIT_STRING *sig, EVP_PKEY *pkey); int (*item_sign)(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, X509_ALGOR *alg1, X509_ALGOR *alg2, ASN1_BIT_STRING *sig); } /* EVP_PKEY_ASN1_METHOD */; /* Method to handle CRL access. * In general a CRL could be very large (several Mb) and can consume large * amounts of resources if stored in memory by multiple processes. * This method allows general CRL operations to be redirected to more * efficient callbacks: for example a CRL entry database. */ #define X509_CRL_METHOD_DYNAMIC 1 struct x509_crl_method_st { int flags; int (*crl_init)(X509_CRL *crl); int (*crl_free)(X509_CRL *crl); int (*crl_lookup)(X509_CRL *crl, X509_REVOKED **ret, ASN1_INTEGER *ser, X509_NAME *issuer); int (*crl_verify)(X509_CRL *crl, EVP_PKEY *pk); }; /* * Unicode codepoint constants */ #define UNICODE_MAX 0x10FFFF #define UNICODE_SURROGATE_MIN 0x00D800 #define UNICODE_SURROGATE_MAX 0x00DFFF #define UNICODE_IS_SURROGATE(x) \ ((x) >= UNICODE_SURROGATE_MIN && (x) <= UNICODE_SURROGATE_MAX) int UTF8_getc(const unsigned char *str, int len, unsigned long *val); int UTF8_putc(unsigned char *str, int len, unsigned long value); deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_i2d_fp.c0000644000175000017500000001127312360020705020730 0ustar /* $OpenBSD: a_i2d_fp.c,v 1.13 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #ifndef NO_OLD_ASN1 int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { ASN1err(ASN1_F_ASN1_I2D_FP, ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, out, BIO_NOCLOSE); ret = ASN1_i2d_bio(i2d, b, x); BIO_free(b); return (ret); } int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x) { char *b; unsigned char *p; int i, j = 0, n, ret = 1; n = i2d(x, NULL); b = malloc(n); if (b == NULL) { ASN1err(ASN1_F_ASN1_I2D_BIO, ERR_R_MALLOC_FAILURE); return (0); } p = (unsigned char *)b; i2d(x, &p); for (;;) { i = BIO_write(out, &(b[j]), n); if (i == n) break; if (i <= 0) { ret = 0; break; } j += i; n -= i; } free(b); return (ret); } #endif int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { ASN1err(ASN1_F_ASN1_ITEM_I2D_FP, ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, out, BIO_NOCLOSE); ret = ASN1_item_i2d_bio(it, b, x); BIO_free(b); return (ret); } int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x) { unsigned char *b = NULL; int i, j = 0, n, ret = 1; n = ASN1_item_i2d(x, &b, it); if (b == NULL) { ASN1err(ASN1_F_ASN1_ITEM_I2D_BIO, ERR_R_MALLOC_FAILURE); return (0); } for (;;) { i = BIO_write(out, &(b[j]), n); if (i == n) break; if (i <= 0) { ret = 0; break; } j += i; n -= i; } free(b); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_sign.c0000644000175000017500000002150412360020705020523 0ustar /* $OpenBSD: a_sign.c,v 1.18 2014/06/24 19:37:58 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include #include #include "asn1_locl.h" int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, ASN1_BIT_STRING *signature, void *asn, EVP_PKEY *pkey, const EVP_MD *type) { EVP_MD_CTX ctx; EVP_MD_CTX_init(&ctx); if (!EVP_DigestSignInit(&ctx, NULL, type, NULL, pkey)) { EVP_MD_CTX_cleanup(&ctx); return 0; } return ASN1_item_sign_ctx(it, algor1, algor2, signature, asn, &ctx); } int ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, ASN1_BIT_STRING *signature, void *asn, EVP_MD_CTX *ctx) { const EVP_MD *type; EVP_PKEY *pkey; unsigned char *buf_in = NULL, *buf_out = NULL; size_t inl = 0, outl = 0, outll = 0; int signid, paramtype; int rv; type = EVP_MD_CTX_md(ctx); pkey = EVP_PKEY_CTX_get0_pkey(ctx->pctx); if (!type || !pkey) { ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ASN1_R_CONTEXT_NOT_INITIALISED); return 0; } if (pkey->ameth->item_sign) { rv = pkey->ameth->item_sign(ctx, it, asn, algor1, algor2, signature); if (rv == 1) outl = signature->length; /* Return value meanings: * <=0: error. * 1: method does everything. * 2: carry on as normal. * 3: ASN1 method sets algorithm identifiers: just sign. */ if (rv <= 0) ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ERR_R_EVP_LIB); if (rv <= 1) goto err; } else rv = 2; if (rv == 2) { if (type->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) { if (!pkey->ameth || !OBJ_find_sigid_by_algs(&signid, EVP_MD_nid(type), pkey->ameth->pkey_id)) { ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED); return 0; } } else signid = type->pkey_type; if (pkey->ameth->pkey_flags & ASN1_PKEY_SIGPARAM_NULL) paramtype = V_ASN1_NULL; else paramtype = V_ASN1_UNDEF; if (algor1) X509_ALGOR_set0(algor1, OBJ_nid2obj(signid), paramtype, NULL); if (algor2) X509_ALGOR_set0(algor2, OBJ_nid2obj(signid), paramtype, NULL); } inl = ASN1_item_i2d(asn, &buf_in, it); outll = outl = EVP_PKEY_size(pkey); buf_out = malloc((unsigned int)outl); if ((buf_in == NULL) || (buf_out == NULL)) { outl = 0; ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ERR_R_MALLOC_FAILURE); goto err; } if (!EVP_DigestSignUpdate(ctx, buf_in, inl) || !EVP_DigestSignFinal(ctx, buf_out, &outl)) { outl = 0; ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ERR_R_EVP_LIB); goto err; } free(signature->data); signature->data = buf_out; buf_out = NULL; signature->length = outl; /* In the interests of compatibility, I'll make sure that * the bit string has a 'not-used bits' value of 0 */ signature->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); signature->flags |= ASN1_STRING_FLAG_BITS_LEFT; err: EVP_MD_CTX_cleanup(ctx); if (buf_in != NULL) { OPENSSL_cleanse((char *)buf_in, (unsigned int)inl); free(buf_in); } if (buf_out != NULL) { OPENSSL_cleanse((char *)buf_out, outll); free(buf_out); } return (outl); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_bignum.c0000644000175000017500000001135412360020705021075 0ustar /* $OpenBSD: x_bignum.c,v 1.5 2014/06/12 15:49:27 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include /* Custom primitive type for BIGNUM handling. This reads in an ASN1_INTEGER as a * BIGNUM directly. Currently it ignores the sign which isn't a problem since all * BIGNUMs used are non negative and anything that looks negative is normally due * to an encoding error. */ #define BN_SENSITIVE 1 static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it); static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it); static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); static int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); static ASN1_PRIMITIVE_FUNCS bignum_pf = { NULL, 0, bn_new, bn_free, 0, bn_c2i, bn_i2c }; ASN1_ITEM_start(BIGNUM) ASN1_ITYPE_PRIMITIVE, V_ASN1_INTEGER, NULL, 0, &bignum_pf, 0, "BIGNUM" ASN1_ITEM_end(BIGNUM) ASN1_ITEM_start(CBIGNUM) ASN1_ITYPE_PRIMITIVE, V_ASN1_INTEGER, NULL, 0, &bignum_pf, BN_SENSITIVE, "BIGNUM" ASN1_ITEM_end(CBIGNUM) static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it) { *pval = (ASN1_VALUE *)BN_new(); if (*pval) return 1; else return 0; } static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it) { if (!*pval) return; if (it->size & BN_SENSITIVE) BN_clear_free((BIGNUM *)*pval); else BN_free((BIGNUM *)*pval); *pval = NULL; } static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it) { BIGNUM *bn; int pad; if (!*pval) return -1; bn = (BIGNUM *)*pval; /* If MSB set in an octet we need a padding byte */ if (BN_num_bits(bn) & 0x7) pad = 0; else pad = 1; if (cont) { if (pad) *cont++ = 0; BN_bn2bin(bn, cont); } return pad + BN_num_bytes(bn); } static int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it) { BIGNUM *bn; if (!*pval) bn_new(pval, it); bn = (BIGNUM *)*pval; if (!BN_bin2bn(cont, len, bn)) { bn_free(pval, it); return 0; } return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_bitstr.c0000644000175000017500000001624212360020705021075 0ustar /* $OpenBSD: a_bitstr.c,v 1.19 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len) { return M_ASN1_BIT_STRING_set(x, d, len); } int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) { int ret, j, bits, len; unsigned char *p, *d; if (a == NULL) return (0); len = a->length; if (len > 0) { if (a->flags & ASN1_STRING_FLAG_BITS_LEFT) { bits = (int)a->flags & 0x07; } else { for (; len > 0; len--) { if (a->data[len - 1]) break; } j = a->data[len - 1]; if (j & 0x01) bits = 0; else if (j & 0x02) bits = 1; else if (j & 0x04) bits = 2; else if (j & 0x08) bits = 3; else if (j & 0x10) bits = 4; else if (j & 0x20) bits = 5; else if (j & 0x40) bits = 6; else if (j & 0x80) bits = 7; else bits = 0; /* should not happen */ } } else bits = 0; ret = 1 + len; if (pp == NULL) return (ret); p= *pp; *(p++) = (unsigned char)bits; d = a->data; memcpy(p, d, len); p += len; if (len > 0) p[-1]&=(0xff << bits); *pp = p; return (ret); } ASN1_BIT_STRING * c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, const unsigned char **pp, long len) { ASN1_BIT_STRING *ret = NULL; const unsigned char *p; unsigned char *s; int i; if (len < 1) { i = ASN1_R_STRING_TOO_SHORT; goto err; } if ((a == NULL) || ((*a) == NULL)) { if ((ret = M_ASN1_BIT_STRING_new()) == NULL) return (NULL); } else ret = (*a); p = *pp; i = *(p++); /* We do this to preserve the settings. If we modify * the settings, via the _set_bit function, we will recalculate * on output */ ret->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear */ ret->flags|=(ASN1_STRING_FLAG_BITS_LEFT|(i&0x07)); /* set */ if (len-- > 1) /* using one because of the bits left byte */ { s = malloc((int)len); if (s == NULL) { i = ERR_R_MALLOC_FAILURE; goto err; } memcpy(s, p, len); s[len - 1] &= (0xff << i); p += len; } else s = NULL; ret->length = (int)len; free(ret->data); ret->data = s; ret->type = V_ASN1_BIT_STRING; if (a != NULL) (*a) = ret; *pp = p; return (ret); err: ASN1err(ASN1_F_C2I_ASN1_BIT_STRING, i); if ((ret != NULL) && ((a == NULL) || (*a != ret))) M_ASN1_BIT_STRING_free(ret); return (NULL); } /* These next 2 functions from Goetz Babin-Ebell */ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) { int w, v, iv; unsigned char *c; w = n/8; v = 1 << (7 - (n & 0x07)); iv = ~v; if (!value) v = 0; if (a == NULL) return 0; a->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); /* clear, set on write */ if ((a->length < (w + 1)) || (a->data == NULL)) { if (!value) return(1); /* Don't need to set */ c = OPENSSL_realloc_clean(a->data, a->length, w + 1); if (c == NULL) { ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT, ERR_R_MALLOC_FAILURE); return 0; } if (w + 1 - a->length > 0) memset(c + a->length, 0, w + 1 - a->length); a->data = c; a->length = w + 1; } a->data[w] = ((a->data[w]) & iv) | v; while ((a->length > 0) && (a->data[a->length - 1] == 0)) a->length--; return (1); } int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n) { int w, v; w = n / 8; v = 1 << (7 - (n & 0x07)); if ((a == NULL) || (a->length < (w + 1)) || (a->data == NULL)) return (0); return ((a->data[w] & v) != 0); } /* * Checks if the given bit string contains only bits specified by * the flags vector. Returns 0 if there is at least one bit set in 'a' * which is not specified in 'flags', 1 otherwise. * 'len' is the length of 'flags'. */ int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a, unsigned char *flags, int flags_len) { int i, ok; /* Check if there is one bit set at all. */ if (!a || !a->data) return 1; /* Check each byte of the internal representation of the bit string. */ ok = 1; for (i = 0; i < a->length && ok; ++i) { unsigned char mask = i < flags_len ? ~flags[i] : 0xff; /* We are done if there is an unneeded bit set. */ ok = (a->data[i] & mask) == 0; } return ok; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/tasn_fre.c0000644000175000017500000001524412360020705021070 0ustar /* $OpenBSD: tasn_fre.c,v 1.11 2014/06/12 15:49:27 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine); /* Free up an ASN1 structure */ void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it) { asn1_item_combine_free(&val, it, 0); } void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) { asn1_item_combine_free(pval, it, 0); } static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine) { const ASN1_TEMPLATE *tt = NULL, *seqtt; const ASN1_EXTERN_FUNCS *ef; const ASN1_COMPAT_FUNCS *cf; const ASN1_AUX *aux = it->funcs; ASN1_aux_cb *asn1_cb; int i; if (pval == NULL || *pval == NULL) return; if (aux && aux->asn1_cb) asn1_cb = aux->asn1_cb; else asn1_cb = 0; switch (it->itype) { case ASN1_ITYPE_PRIMITIVE: if (it->templates) ASN1_template_free(pval, it->templates); else ASN1_primitive_free(pval, it); break; case ASN1_ITYPE_MSTRING: ASN1_primitive_free(pval, it); break; case ASN1_ITYPE_CHOICE: if (asn1_cb) { i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL); if (i == 2) return; } i = asn1_get_choice_selector(pval, it); if ((i >= 0) && (i < it->tcount)) { ASN1_VALUE **pchval; tt = it->templates + i; pchval = asn1_get_field_ptr(pval, tt); ASN1_template_free(pchval, tt); } if (asn1_cb) asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL); if (!combine) { free(*pval); *pval = NULL; } break; case ASN1_ITYPE_COMPAT: cf = it->funcs; if (cf && cf->asn1_free) cf->asn1_free(*pval); break; case ASN1_ITYPE_EXTERN: ef = it->funcs; if (ef && ef->asn1_ex_free) ef->asn1_ex_free(pval, it); break; case ASN1_ITYPE_NDEF_SEQUENCE: case ASN1_ITYPE_SEQUENCE: if (asn1_do_lock(pval, -1, it) > 0) return; if (asn1_cb) { i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL); if (i == 2) return; } asn1_enc_free(pval, it); /* If we free up as normal we will invalidate any * ANY DEFINED BY field and we wont be able to * determine the type of the field it defines. So * free up in reverse order. */ tt = it->templates + it->tcount - 1; for (i = 0; i < it->tcount; tt--, i++) { ASN1_VALUE **pseqval; seqtt = asn1_do_adb(pval, tt, 0); if (!seqtt) continue; pseqval = asn1_get_field_ptr(pval, seqtt); ASN1_template_free(pseqval, seqtt); } if (asn1_cb) asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL); if (!combine) { free(*pval); *pval = NULL; } break; } } void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) { int i; if (tt->flags & ASN1_TFLG_SK_MASK) { STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval; for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) { ASN1_VALUE *vtmp; vtmp = sk_ASN1_VALUE_value(sk, i); asn1_item_combine_free(&vtmp, ASN1_ITEM_ptr(tt->item), 0); } sk_ASN1_VALUE_free(sk); *pval = NULL; } else asn1_item_combine_free(pval, ASN1_ITEM_ptr(tt->item), tt->flags & ASN1_TFLG_COMBINE); } void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it) { int utype; if (it) { const ASN1_PRIMITIVE_FUNCS *pf; pf = it->funcs; if (pf && pf->prim_free) { pf->prim_free(pval, it); return; } } /* Special case: if 'it' is NULL free contents of ASN1_TYPE */ if (!it) { ASN1_TYPE *typ = (ASN1_TYPE *)*pval; utype = typ->type; pval = &typ->value.asn1_value; if (!*pval) return; } else if (it->itype == ASN1_ITYPE_MSTRING) { utype = -1; if (!*pval) return; } else { utype = it->utype; if ((utype != V_ASN1_BOOLEAN) && !*pval) return; } switch (utype) { case V_ASN1_OBJECT: ASN1_OBJECT_free((ASN1_OBJECT *)*pval); break; case V_ASN1_BOOLEAN: if (it) *(ASN1_BOOLEAN *)pval = it->size; else *(ASN1_BOOLEAN *)pval = -1; return; case V_ASN1_NULL: break; case V_ASN1_ANY: ASN1_primitive_free(pval, NULL); free(*pval); break; default: ASN1_STRING_free((ASN1_STRING *)*pval); break; } *pval = NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/bio_ndef.c0000644000175000017500000001532412360020705021033 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ /* ==================================================================== * Copyright (c) 2008 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * */ #include #include #include #include #include /* Experimental NDEF ASN1 BIO support routines */ /* The usage is quite simple, initialize an ASN1 structure, * get a BIO from it then any data written through the BIO * will end up translated to approptiate format on the fly. * The data is streamed out and does *not* need to be * all held in memory at once. * * When the BIO is flushed the output is finalized and any * signatures etc written out. * * The BIO is a 'proper' BIO and can handle non blocking I/O * correctly. * * The usage is simple. The implementation is *not*... */ /* BIO support data stored in the ASN1 BIO ex_arg */ typedef struct ndef_aux_st { /* ASN1 structure this BIO refers to */ ASN1_VALUE *val; const ASN1_ITEM *it; /* Top of the BIO chain */ BIO *ndef_bio; /* Output BIO */ BIO *out; /* Boundary where content is inserted */ unsigned char **boundary; /* DER buffer start */ unsigned char *derbuf; } NDEF_SUPPORT; static int ndef_prefix(BIO *b, unsigned char **pbuf, int *plen, void *parg); static int ndef_prefix_free(BIO *b, unsigned char **pbuf, int *plen, void *parg); static int ndef_suffix(BIO *b, unsigned char **pbuf, int *plen, void *parg); static int ndef_suffix_free(BIO *b, unsigned char **pbuf, int *plen, void *parg); BIO * BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it) { NDEF_SUPPORT *ndef_aux = NULL; BIO *asn_bio = NULL; const ASN1_AUX *aux = it->funcs; ASN1_STREAM_ARG sarg; if (!aux || !aux->asn1_cb) { ASN1err(ASN1_F_BIO_NEW_NDEF, ASN1_R_STREAMING_NOT_SUPPORTED); return NULL; } ndef_aux = malloc(sizeof(NDEF_SUPPORT)); asn_bio = BIO_new(BIO_f_asn1()); /* ASN1 bio needs to be next to output BIO */ out = BIO_push(asn_bio, out); if (!ndef_aux || !asn_bio || !out) goto err; BIO_asn1_set_prefix(asn_bio, ndef_prefix, ndef_prefix_free); BIO_asn1_set_suffix(asn_bio, ndef_suffix, ndef_suffix_free); /* Now let callback prepend any digest, cipher etc BIOs * ASN1 structure needs. */ sarg.out = out; sarg.ndef_bio = NULL; sarg.boundary = NULL; if (aux->asn1_cb(ASN1_OP_STREAM_PRE, &val, it, &sarg) <= 0) goto err; ndef_aux->val = val; ndef_aux->it = it; ndef_aux->ndef_bio = sarg.ndef_bio; ndef_aux->boundary = sarg.boundary; ndef_aux->out = out; BIO_ctrl(asn_bio, BIO_C_SET_EX_ARG, 0, ndef_aux); return sarg.ndef_bio; err: if (asn_bio) BIO_free(asn_bio); free(ndef_aux); return NULL; } static int ndef_prefix(BIO *b, unsigned char **pbuf, int *plen, void *parg) { NDEF_SUPPORT *ndef_aux; unsigned char *p; int derlen; if (!parg) return 0; ndef_aux = *(NDEF_SUPPORT **)parg; derlen = ASN1_item_ndef_i2d(ndef_aux->val, NULL, ndef_aux->it); p = malloc(derlen); ndef_aux->derbuf = p; *pbuf = p; derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it); if (!*ndef_aux->boundary) return 0; *plen = *ndef_aux->boundary - *pbuf; return 1; } static int ndef_prefix_free(BIO *b, unsigned char **pbuf, int *plen, void *parg) { NDEF_SUPPORT *ndef_aux; if (!parg) return 0; ndef_aux = *(NDEF_SUPPORT **)parg; free(ndef_aux->derbuf); ndef_aux->derbuf = NULL; *pbuf = NULL; *plen = 0; return 1; } static int ndef_suffix_free(BIO *b, unsigned char **pbuf, int *plen, void *parg) { NDEF_SUPPORT **pndef_aux = (NDEF_SUPPORT **)parg; if (!ndef_prefix_free(b, pbuf, plen, parg)) return 0; free(*pndef_aux); *pndef_aux = NULL; return 1; } static int ndef_suffix(BIO *b, unsigned char **pbuf, int *plen, void *parg) { NDEF_SUPPORT *ndef_aux; unsigned char *p; int derlen; const ASN1_AUX *aux; ASN1_STREAM_ARG sarg; if (!parg) return 0; ndef_aux = *(NDEF_SUPPORT **)parg; aux = ndef_aux->it->funcs; /* Finalize structures */ sarg.ndef_bio = ndef_aux->ndef_bio; sarg.out = ndef_aux->out; sarg.boundary = ndef_aux->boundary; if (aux->asn1_cb(ASN1_OP_STREAM_POST, &ndef_aux->val, ndef_aux->it, &sarg) <= 0) return 0; derlen = ASN1_item_ndef_i2d(ndef_aux->val, NULL, ndef_aux->it); p = malloc(derlen); ndef_aux->derbuf = p; *pbuf = p; derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it); if (!*ndef_aux->boundary) return 0; *pbuf = *ndef_aux->boundary; *plen = derlen - (*ndef_aux->boundary - ndef_aux->derbuf); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_req.c0000644000175000017500000001172412360020705020404 0ustar /* $OpenBSD: x_req.c,v 1.9 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include /* X509_REQ_INFO is handled in an unusual way to get round * invalid encodings. Some broken certificate requests don't * encode the attributes field if it is empty. This is in * violation of PKCS#10 but we need to tolerate it. We do * this by making the attributes field OPTIONAL then using * the callback to initialise it to an empty STACK. * * This means that the field will be correctly encoded unless * we NULL out the field. * * As a result we no longer need the req_kludge field because * the information is now contained in the attributes field: * 1. If it is NULL then it's the invalid omission. * 2. If it is empty it is the correct encoding. * 3. If it is not empty then some attributes are present. * */ static int rinf_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { X509_REQ_INFO *rinf = (X509_REQ_INFO *)*pval; if (operation == ASN1_OP_NEW_POST) { rinf->attributes = sk_X509_ATTRIBUTE_new_null(); if (!rinf->attributes) return 0; } return 1; } ASN1_SEQUENCE_enc(X509_REQ_INFO, enc, rinf_cb) = { ASN1_SIMPLE(X509_REQ_INFO, version, ASN1_INTEGER), ASN1_SIMPLE(X509_REQ_INFO, subject, X509_NAME), ASN1_SIMPLE(X509_REQ_INFO, pubkey, X509_PUBKEY), /* This isn't really OPTIONAL but it gets round invalid * encodings */ ASN1_IMP_SET_OF_OPT(X509_REQ_INFO, attributes, X509_ATTRIBUTE, 0) } ASN1_SEQUENCE_END_enc(X509_REQ_INFO, X509_REQ_INFO) IMPLEMENT_ASN1_FUNCTIONS(X509_REQ_INFO) ASN1_SEQUENCE_ref(X509_REQ, 0, CRYPTO_LOCK_X509_REQ) = { ASN1_SIMPLE(X509_REQ, req_info, X509_REQ_INFO), ASN1_SIMPLE(X509_REQ, sig_alg, X509_ALGOR), ASN1_SIMPLE(X509_REQ, signature, ASN1_BIT_STRING) } ASN1_SEQUENCE_END_ref(X509_REQ, X509_REQ) IMPLEMENT_ASN1_FUNCTIONS(X509_REQ) IMPLEMENT_ASN1_DUP_FUNCTION(X509_REQ) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_bool.c0000644000175000017500000001010012360020705020504 0ustar /* $OpenBSD: a_bool.c,v 1.6 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include int i2d_ASN1_BOOLEAN(int a, unsigned char **pp) { int r; unsigned char *p; r = ASN1_object_size(0, 1, V_ASN1_BOOLEAN); if (pp == NULL) return (r); p = *pp; ASN1_put_object(&p, 0, 1, V_ASN1_BOOLEAN, V_ASN1_UNIVERSAL); *(p++) = (unsigned char)a; *pp = p; return (r); } int d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, long length) { int ret = -1; const unsigned char *p; long len; int inf, tag, xclass; int i = 0; p = *pp; inf = ASN1_get_object(&p, &len, &tag, &xclass, length); if (inf & 0x80) { i = ASN1_R_BAD_OBJECT_HEADER; goto err; } if (tag != V_ASN1_BOOLEAN) { i = ASN1_R_EXPECTING_A_BOOLEAN; goto err; } if (len != 1) { i = ASN1_R_BOOLEAN_IS_WRONG_LENGTH; goto err; } ret = (int)*(p++); if (a != NULL) (*a) = ret; *pp = p; return (ret); err: ASN1err(ASN1_F_D2I_ASN1_BOOLEAN, i); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/i2d_pr.c0000644000175000017500000000726412360020705020451 0ustar /* $OpenBSD: i2d_pr.c,v 1.9 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include "asn1_locl.h" int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp) { if (a->ameth && a->ameth->old_priv_encode) { return a->ameth->old_priv_encode(a, pp); } if (a->ameth && a->ameth->priv_encode) { PKCS8_PRIV_KEY_INFO *p8 = EVP_PKEY2PKCS8(a); int ret = i2d_PKCS8_PRIV_KEY_INFO(p8, pp); PKCS8_PRIV_KEY_INFO_free(p8); return ret; } ASN1err(ASN1_F_I2D_PRIVATEKEY, ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE); return (-1); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_verify.c0000644000175000017500000001312612360020705021070 0ustar /* $OpenBSD: a_verify.c,v 1.19 2014/06/24 19:37:58 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #include #include "asn1_locl.h" int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, ASN1_BIT_STRING *signature, void *asn, EVP_PKEY *pkey) { EVP_MD_CTX ctx; unsigned char *buf_in = NULL; int ret = -1, inl; int mdnid, pknid; if (!pkey) { ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_PASSED_NULL_PARAMETER); return -1; } EVP_MD_CTX_init(&ctx); /* Convert signature OID into digest and public key OIDs */ if (!OBJ_find_sigid_algs(OBJ_obj2nid(a->algorithm), &mdnid, &pknid)) { ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM); goto err; } if (mdnid == NID_undef) { if (!pkey->ameth || !pkey->ameth->item_verify) { ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM); goto err; } ret = pkey->ameth->item_verify(&ctx, it, asn, a, signature, pkey); /* Return value of 2 means carry on, anything else means we * exit straight away: either a fatal error of the underlying * verification routine handles all verification. */ if (ret != 2) goto err; ret = -1; } else { const EVP_MD *type; type = EVP_get_digestbynid(mdnid); if (type == NULL) { ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM); goto err; } /* Check public key OID matches public key type */ if (EVP_PKEY_type(pknid) != pkey->ameth->pkey_id) { ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ASN1_R_WRONG_PUBLIC_KEY_TYPE); goto err; } if (!EVP_DigestVerifyInit(&ctx, NULL, type, NULL, pkey)) { ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_EVP_LIB); ret = 0; goto err; } } inl = ASN1_item_i2d(asn, &buf_in, it); if (buf_in == NULL) { ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_MALLOC_FAILURE); goto err; } if (!EVP_DigestVerifyUpdate(&ctx, buf_in, inl)) { ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_EVP_LIB); ret = 0; goto err; } OPENSSL_cleanse(buf_in, (unsigned int)inl); free(buf_in); if (EVP_DigestVerifyFinal(&ctx, signature->data, (size_t)signature->length) <= 0) { ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_EVP_LIB); ret = 0; goto err; } /* we don't need to zero the 'ctx' because we just checked * public information */ /* memset(&ctx,0,sizeof(ctx)); */ ret = 1; err: EVP_MD_CTX_cleanup(&ctx); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_info.c0000644000175000017500000000775412360020705020560 0ustar /* $OpenBSD: x_info.c,v 1.13 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include X509_INFO * X509_INFO_new(void) { X509_INFO *ret = NULL; ret = malloc(sizeof(X509_INFO)); if (ret == NULL) { ASN1err(ASN1_F_X509_INFO_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } ret->enc_cipher.cipher = NULL; ret->enc_len = 0; ret->enc_data = NULL; ret->references = 1; ret->x509 = NULL; ret->crl = NULL; ret->x_pkey = NULL; return (ret); } void X509_INFO_free(X509_INFO *x) { int i; if (x == NULL) return; i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_X509_INFO); if (i > 0) return; if (x->x509 != NULL) X509_free(x->x509); if (x->crl != NULL) X509_CRL_free(x->crl); if (x->x_pkey != NULL) X509_PKEY_free(x->x_pkey); free(x->enc_data); free(x); } IMPLEMENT_STACK_OF(X509_INFO) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/asn1_lib.c0000644000175000017500000002525512360020705020762 0ustar /* $OpenBSD: asn1_lib.c,v 1.31 2014/07/11 14:22:55 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include static int asn1_get_length(const unsigned char **pp, int *inf, long *rl, int max); static void asn1_put_length(unsigned char **pp, int length); static int _asn1_check_infinite_end(const unsigned char **p, long len) { /* If there is 0 or 1 byte left, the length check should pick * things up */ if (len <= 0) return (1); else if ((len >= 2) && ((*p)[0] == 0) && ((*p)[1] == 0)) { (*p) += 2; return (1); } return (0); } int ASN1_check_infinite_end(unsigned char **p, long len) { return _asn1_check_infinite_end((const unsigned char **)p, len); } int ASN1_const_check_infinite_end(const unsigned char **p, long len) { return _asn1_check_infinite_end(p, len); } int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, int *pclass, long omax) { int i, ret; long l; const unsigned char *p= *pp; int tag, xclass, inf; long max = omax; if (!max) goto err; ret = (*p & V_ASN1_CONSTRUCTED); xclass = (*p & V_ASN1_PRIVATE); i= *p & V_ASN1_PRIMITIVE_TAG; if (i == V_ASN1_PRIMITIVE_TAG) { /* high-tag */ p++; if (--max == 0) goto err; l = 0; while (*p & 0x80) { l <<= 7L; l |= *(p++) & 0x7f; if (--max == 0) goto err; if (l > (INT_MAX >> 7L)) goto err; } l <<= 7L; l |= *(p++) & 0x7f; tag = (int)l; if (--max == 0) goto err; } else { tag = i; p++; if (--max == 0) goto err; } *ptag = tag; *pclass = xclass; if (!asn1_get_length(&p, &inf, plength, (int)max)) goto err; if (inf && !(ret & V_ASN1_CONSTRUCTED)) goto err; #if 0 fprintf(stderr, "p=%d + *plength=%ld > omax=%ld + *pp=%d (%d > %d)\n", (int)p, *plength, omax, (int)*pp, (int)(p+ *plength), (int)(omax+ *pp)); #endif if (*plength > (omax - (p - *pp))) { ASN1err(ASN1_F_ASN1_GET_OBJECT, ASN1_R_TOO_LONG); /* Set this so that even if things are not long enough * the values are set correctly */ ret |= 0x80; } *pp = p; return (ret | inf); err: ASN1err(ASN1_F_ASN1_GET_OBJECT, ASN1_R_HEADER_TOO_LONG); return (0x80); } static int asn1_get_length(const unsigned char **pp, int *inf, long *rl, int max) { const unsigned char *p= *pp; unsigned long ret = 0; unsigned int i; if (max-- < 1) return (0); if (*p == 0x80) { *inf = 1; ret = 0; p++; } else { *inf = 0; i= *p & 0x7f; if (*(p++) & 0x80) { if (max < (int)i) return (0); /* skip leading zeroes */ while (i && *p == 0) { p++; i--; } if (i > sizeof(long)) return 0; while (i-- > 0) { ret <<= 8L; ret |= *(p++); } } else ret = i; } if (ret > LONG_MAX) return 0; *pp = p; *rl = (long)ret; return (1); } /* class 0 is constructed * constructed == 2 for indefinite length constructed */ void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag, int xclass) { unsigned char *p= *pp; int i, ttag; i = (constructed) ? V_ASN1_CONSTRUCTED : 0; i |= (xclass & V_ASN1_PRIVATE); if (tag < 31) *(p++) = i | (tag & V_ASN1_PRIMITIVE_TAG); else { *(p++) = i | V_ASN1_PRIMITIVE_TAG; for(i = 0, ttag = tag; ttag > 0; i++) ttag >>= 7; ttag = i; while (i-- > 0) { p[i] = tag & 0x7f; if (i != (ttag - 1)) p[i] |= 0x80; tag >>= 7; } p += ttag; } if (constructed == 2) *(p++) = 0x80; else asn1_put_length(&p, length); *pp = p; } int ASN1_put_eoc(unsigned char **pp) { unsigned char *p = *pp; *p++ = 0; *p++ = 0; *pp = p; return 2; } static void asn1_put_length(unsigned char **pp, int length) { unsigned char *p= *pp; int i, l; if (length <= 127) *(p++) = (unsigned char)length; else { l = length; for (i = 0; l > 0; i++) l >>= 8; *(p++) = i | 0x80; l = i; while (i-- > 0) { p[i] = length & 0xff; length >>= 8; } p += l; } *pp = p; } int ASN1_object_size(int constructed, int length, int tag) { int ret; ret = length; ret++; if (tag >= 31) { while (tag > 0) { tag >>= 7; ret++; } } if (constructed == 2) return ret + 3; ret++; if (length > 127) { while (length > 0) { length >>= 8; ret++; } } return (ret); } static int _asn1_Finish(ASN1_const_CTX *c) { if ((c->inf == (1|V_ASN1_CONSTRUCTED)) && (!c->eos)) { if (!ASN1_const_check_infinite_end(&c->p, c->slen)) { c->error = ERR_R_MISSING_ASN1_EOS; return (0); } } if (((c->slen != 0) && !(c->inf & 1)) || ((c->slen < 0) && (c->inf & 1))) { c->error = ERR_R_ASN1_LENGTH_MISMATCH; return (0); } return (1); } int asn1_Finish(ASN1_CTX *c) { return _asn1_Finish((ASN1_const_CTX *)c); } int asn1_const_Finish(ASN1_const_CTX *c) { return _asn1_Finish(c); } int asn1_GetSequence(ASN1_const_CTX *c, long *length) { const unsigned char *q; q = c->p; c->inf = ASN1_get_object(&(c->p), &(c->slen), &(c->tag), &(c->xclass), *length); if (c->inf & 0x80) { c->error = ERR_R_BAD_GET_ASN1_OBJECT_CALL; return (0); } if (c->tag != V_ASN1_SEQUENCE) { c->error = ERR_R_EXPECTING_AN_ASN1_SEQUENCE; return (0); } (*length) -= (c->p - q); if (c->max && (*length < 0)) { c->error = ERR_R_ASN1_LENGTH_MISMATCH; return (0); } if (c->inf == (1|V_ASN1_CONSTRUCTED)) c->slen= *length+ *(c->pp) - c->p; c->eos = 0; return (1); } int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str) { if (str == NULL) return 0; dst->type = str->type; if (!ASN1_STRING_set(dst, str->data, str->length)) return 0; dst->flags = str->flags; return 1; } ASN1_STRING * ASN1_STRING_dup(const ASN1_STRING *str) { ASN1_STRING *ret; if (!str) return NULL; ret = ASN1_STRING_new(); if (!ret) return NULL; if (!ASN1_STRING_copy(ret, str)) { ASN1_STRING_free(ret); return NULL; } return ret; } int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len) { const char *data = _data; if (len < 0) { if (data == NULL) return (0); else len = strlen(data); } if ((str->length < len) || (str->data == NULL)) { unsigned char *tmp; tmp = realloc(str->data, len + 1); if (tmp == NULL) { ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE); return (0); } str->data = tmp; } str->length = len; if (data != NULL) { memmove(str->data, data, len); } str->data[str->length]='\0'; return (1); } void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len) { free(str->data); str->data = data; str->length = len; } ASN1_STRING * ASN1_STRING_new(void) { return (ASN1_STRING_type_new(V_ASN1_OCTET_STRING)); } ASN1_STRING * ASN1_STRING_type_new(int type) { ASN1_STRING *ret; ret = malloc(sizeof(ASN1_STRING)); if (ret == NULL) { ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } ret->length = 0; ret->type = type; ret->data = NULL; ret->flags = 0; return (ret); } void ASN1_STRING_free(ASN1_STRING *a) { if (a == NULL) return; if (a->data && !(a->flags & ASN1_STRING_FLAG_NDEF)) free(a->data); free(a); } int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b) { int i; i = (a->length - b->length); if (i == 0) { i = memcmp(a->data, b->data, a->length); if (i == 0) return (a->type - b->type); else return (i); } else return (i); } void asn1_add_error(const unsigned char *address, int offset) { ERR_asprintf_error_data("address=%p offset=%d", address, offset); } int ASN1_STRING_length(const ASN1_STRING *x) { return M_ASN1_STRING_length(x); } void ASN1_STRING_length_set(ASN1_STRING *x, int len) { M_ASN1_STRING_length_set(x, len); return; } int ASN1_STRING_type(ASN1_STRING *x) { return M_ASN1_STRING_type(x); } unsigned char * ASN1_STRING_data(ASN1_STRING *x) { return M_ASN1_STRING_data(x); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_nx509.c0000644000175000017500000000601212360020705020472 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2005. */ /* ==================================================================== * Copyright (c) 2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include /* Old netscape certificate wrapper format */ ASN1_SEQUENCE(NETSCAPE_X509) = { ASN1_SIMPLE(NETSCAPE_X509, header, ASN1_OCTET_STRING), ASN1_OPT(NETSCAPE_X509, cert, X509) } ASN1_SEQUENCE_END(NETSCAPE_X509) IMPLEMENT_ASN1_FUNCTIONS(NETSCAPE_X509) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/tasn_prn.c0000644000175000017500000003375412360020705021121 0ustar /* $OpenBSD: tasn_prn.c,v 1.10 2014/06/12 15:49:27 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000,2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include "asn1_locl.h" /* Print routines. */ /* ASN1_PCTX routines */ ASN1_PCTX default_pctx = { ASN1_PCTX_FLAGS_SHOW_ABSENT, /* flags */ 0, /* nm_flags */ 0, /* cert_flags */ 0, /* oid_flags */ 0 /* str_flags */ }; ASN1_PCTX * ASN1_PCTX_new(void) { ASN1_PCTX *ret; ret = malloc(sizeof(ASN1_PCTX)); if (ret == NULL) { ASN1err(ASN1_F_ASN1_PCTX_NEW, ERR_R_MALLOC_FAILURE); return NULL; } ret->flags = 0; ret->nm_flags = 0; ret->cert_flags = 0; ret->oid_flags = 0; ret->str_flags = 0; return ret; } void ASN1_PCTX_free(ASN1_PCTX *p) { free(p); } unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p) { return p->flags; } void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags) { p->flags = flags; } unsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p) { return p->nm_flags; } void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags) { p->nm_flags = flags; } unsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p) { return p->cert_flags; } void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags) { p->cert_flags = flags; } unsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p) { return p->oid_flags; } void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags) { p->oid_flags = flags; } unsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p) { return p->str_flags; } void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags) { p->str_flags = flags; } /* Main print routines */ static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, const ASN1_ITEM *it, const char *fname, const char *sname, int nohdr, const ASN1_PCTX *pctx); int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx); static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld, const ASN1_ITEM *it, int indent, const char *fname, const char *sname, const ASN1_PCTX *pctx); static int asn1_print_fsname(BIO *out, int indent, const char *fname, const char *sname, const ASN1_PCTX *pctx); int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent, const ASN1_ITEM *it, const ASN1_PCTX *pctx) { const char *sname; if (pctx == NULL) pctx = &default_pctx; if (pctx->flags & ASN1_PCTX_FLAGS_NO_STRUCT_NAME) sname = NULL; else sname = it->sname; return asn1_item_print_ctx(out, &ifld, indent, it, NULL, sname, 0, pctx); } static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, const ASN1_ITEM *it, const char *fname, const char *sname, int nohdr, const ASN1_PCTX *pctx) { const ASN1_TEMPLATE *tt; const ASN1_EXTERN_FUNCS *ef; ASN1_VALUE **tmpfld; const ASN1_AUX *aux = it->funcs; ASN1_aux_cb *asn1_cb; ASN1_PRINT_ARG parg; int i; if (aux && aux->asn1_cb) { parg.out = out; parg.indent = indent; parg.pctx = pctx; asn1_cb = aux->asn1_cb; } else asn1_cb = 0; if (*fld == NULL) { if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_ABSENT) { if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx)) return 0; if (BIO_puts(out, "\n") <= 0) return 0; } return 1; } switch (it->itype) { case ASN1_ITYPE_PRIMITIVE: if (it->templates) { if (!asn1_template_print_ctx(out, fld, indent, it->templates, pctx)) return 0; } /* fall thru */ case ASN1_ITYPE_MSTRING: if (!asn1_primitive_print(out, fld, it, indent, fname, sname, pctx)) return 0; break; case ASN1_ITYPE_EXTERN: if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx)) return 0; /* Use new style print routine if possible */ ef = it->funcs; if (ef && ef->asn1_ex_print) { i = ef->asn1_ex_print(out, fld, indent, "", pctx); if (!i) return 0; if ((i == 2) && (BIO_puts(out, "\n") <= 0)) return 0; return 1; } else if (sname && BIO_printf(out, ":EXTERNAL TYPE %s\n", sname) <= 0) return 0; break; case ASN1_ITYPE_CHOICE: #if 0 if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx)) return 0; #endif /* CHOICE type, get selector */ i = asn1_get_choice_selector(fld, it); /* This should never happen... */ if ((i < 0) || (i >= it->tcount)) { if (BIO_printf(out, "ERROR: selector [%d] invalid\n", i) <= 0) return 0; return 1; } tt = it->templates + i; tmpfld = asn1_get_field_ptr(fld, tt); if (!asn1_template_print_ctx(out, tmpfld, indent, tt, pctx)) return 0; break; case ASN1_ITYPE_SEQUENCE: case ASN1_ITYPE_NDEF_SEQUENCE: if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx)) return 0; if (fname || sname) { if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE) { if (BIO_puts(out, " {\n") <= 0) return 0; } else { if (BIO_puts(out, "\n") <= 0) return 0; } } if (asn1_cb) { i = asn1_cb(ASN1_OP_PRINT_PRE, fld, it, &parg); if (i == 0) return 0; if (i == 2) return 1; } /* Print each field entry */ for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) { const ASN1_TEMPLATE *seqtt; seqtt = asn1_do_adb(fld, tt, 1); tmpfld = asn1_get_field_ptr(fld, seqtt); if (!asn1_template_print_ctx(out, tmpfld, indent + 2, seqtt, pctx)) return 0; } if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE) { if (BIO_printf(out, "%*s}\n", indent, "") < 0) return 0; } if (asn1_cb) { i = asn1_cb(ASN1_OP_PRINT_POST, fld, it, &parg); if (i == 0) return 0; } break; default: BIO_printf(out, "Unprocessed type %d\n", it->itype); return 0; } return 1; } int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx) { int i, flags; const char *sname, *fname; flags = tt->flags; if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME) sname = ASN1_ITEM_ptr(tt->item)->sname; else sname = NULL; if (pctx->flags & ASN1_PCTX_FLAGS_NO_FIELD_NAME) fname = NULL; else fname = tt->field_name; if (flags & ASN1_TFLG_SK_MASK) { char *tname; ASN1_VALUE *skitem; STACK_OF(ASN1_VALUE) *stack; /* SET OF, SEQUENCE OF */ if (fname) { if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SSOF) { if (flags & ASN1_TFLG_SET_OF) tname = "SET"; else tname = "SEQUENCE"; if (BIO_printf(out, "%*s%s OF %s {\n", indent, "", tname, tt->field_name) <= 0) return 0; } else if (BIO_printf(out, "%*s%s:\n", indent, "", fname) <= 0) return 0; } stack = (STACK_OF(ASN1_VALUE) *)*fld; for (i = 0; i < sk_ASN1_VALUE_num(stack); i++) { if ((i > 0) && (BIO_puts(out, "\n") <= 0)) return 0; skitem = sk_ASN1_VALUE_value(stack, i); if (!asn1_item_print_ctx(out, &skitem, indent + 2, ASN1_ITEM_ptr(tt->item), NULL, NULL, 1, pctx)) return 0; } if (!i && BIO_printf(out, "%*s\n", indent + 2, "") <= 0) return 0; if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE) { if (BIO_printf(out, "%*s}\n", indent, "") <= 0) return 0; } return 1; } return asn1_item_print_ctx(out, fld, indent, ASN1_ITEM_ptr(tt->item), fname, sname, 0, pctx); } static int asn1_print_fsname(BIO *out, int indent, const char *fname, const char *sname, const ASN1_PCTX *pctx) { static char spaces[] = " "; const int nspaces = sizeof(spaces) - 1; #if 0 if (!sname && !fname) return 1; #endif while (indent > nspaces) { if (BIO_write(out, spaces, nspaces) != nspaces) return 0; indent -= nspaces; } if (BIO_write(out, spaces, indent) != indent) return 0; if (pctx->flags & ASN1_PCTX_FLAGS_NO_STRUCT_NAME) sname = NULL; if (pctx->flags & ASN1_PCTX_FLAGS_NO_FIELD_NAME) fname = NULL; if (!sname && !fname) return 1; if (fname) { if (BIO_puts(out, fname) <= 0) return 0; } if (sname) { if (fname) { if (BIO_printf(out, " (%s)", sname) <= 0) return 0; } else { if (BIO_puts(out, sname) <= 0) return 0; } } if (BIO_write(out, ": ", 2) != 2) return 0; return 1; } static int asn1_print_boolean_ctx(BIO *out, int boolval, const ASN1_PCTX *pctx) { const char *str; switch (boolval) { case -1: str = "BOOL ABSENT"; break; case 0: str = "FALSE"; break; default: str = "TRUE"; break; } if (BIO_puts(out, str) <= 0) return 0; return 1; } static int asn1_print_integer_ctx(BIO *out, ASN1_INTEGER *str, const ASN1_PCTX *pctx) { char *s; int ret = 1; s = i2s_ASN1_INTEGER(NULL, str); if (BIO_puts(out, s) <= 0) ret = 0; free(s); return ret; } static int asn1_print_oid_ctx(BIO *out, const ASN1_OBJECT *oid, const ASN1_PCTX *pctx) { char objbuf[80]; const char *ln; ln = OBJ_nid2ln(OBJ_obj2nid(oid)); if (!ln) ln = ""; OBJ_obj2txt(objbuf, sizeof objbuf, oid, 1); if (BIO_printf(out, "%s (%s)", ln, objbuf) <= 0) return 0; return 1; } static int asn1_print_obstring_ctx(BIO *out, ASN1_STRING *str, int indent, const ASN1_PCTX *pctx) { if (str->type == V_ASN1_BIT_STRING) { if (BIO_printf(out, " (%ld unused bits)\n", str->flags & 0x7) <= 0) return 0; } else if (BIO_puts(out, "\n") <= 0) return 0; if ((str->length > 0) && BIO_dump_indent(out, (char *)str->data, str->length, indent + 2) <= 0) return 0; return 1; } static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld, const ASN1_ITEM *it, int indent, const char *fname, const char *sname, const ASN1_PCTX *pctx) { long utype; ASN1_STRING *str; int ret = 1, needlf = 1; const char *pname; const ASN1_PRIMITIVE_FUNCS *pf; pf = it->funcs; if (!asn1_print_fsname(out, indent, fname, sname, pctx)) return 0; if (pf && pf->prim_print) return pf->prim_print(out, fld, it, indent, pctx); str = (ASN1_STRING *)*fld; if (it->itype == ASN1_ITYPE_MSTRING) utype = str->type & ~V_ASN1_NEG; else utype = it->utype; if (utype == V_ASN1_ANY) { ASN1_TYPE *atype = (ASN1_TYPE *)*fld; utype = atype->type; fld = &atype->value.asn1_value; str = (ASN1_STRING *)*fld; if (pctx->flags & ASN1_PCTX_FLAGS_NO_ANY_TYPE) pname = NULL; else pname = ASN1_tag2str(utype); } else { if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_TYPE) pname = ASN1_tag2str(utype); else pname = NULL; } if (utype == V_ASN1_NULL) { if (BIO_puts(out, "NULL\n") <= 0) return 0; return 1; } if (pname) { if (BIO_puts(out, pname) <= 0) return 0; if (BIO_puts(out, ":") <= 0) return 0; } switch (utype) { case V_ASN1_BOOLEAN: { int boolval = *(int *)fld; if (boolval == -1) boolval = it->size; ret = asn1_print_boolean_ctx(out, boolval, pctx); } break; case V_ASN1_INTEGER: case V_ASN1_ENUMERATED: ret = asn1_print_integer_ctx(out, str, pctx); break; case V_ASN1_UTCTIME: ret = ASN1_UTCTIME_print(out, str); break; case V_ASN1_GENERALIZEDTIME: ret = ASN1_GENERALIZEDTIME_print(out, str); break; case V_ASN1_OBJECT: ret = asn1_print_oid_ctx(out, (const ASN1_OBJECT *)*fld, pctx); break; case V_ASN1_OCTET_STRING: case V_ASN1_BIT_STRING: ret = asn1_print_obstring_ctx(out, str, indent, pctx); needlf = 0; break; case V_ASN1_SEQUENCE: case V_ASN1_SET: case V_ASN1_OTHER: if (BIO_puts(out, "\n") <= 0) return 0; if (ASN1_parse_dump(out, str->data, str->length, indent, 0) <= 0) ret = 0; needlf = 0; break; default: ret = ASN1_STRING_print_ex(out, str, pctx->str_flags); } if (!ret) return 0; if (needlf && BIO_puts(out, "\n") <= 0) return 0; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/t_crl.c0000644000175000017500000001110612360020705020363 0ustar /* $OpenBSD: t_crl.c,v 1.14 2014/06/12 15:49:27 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include int X509_CRL_print_fp(FILE *fp, X509_CRL *x) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { X509err(X509_F_X509_CRL_PRINT_FP, ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, fp, BIO_NOCLOSE); ret = X509_CRL_print(b, x); BIO_free(b); return (ret); } int X509_CRL_print(BIO *out, X509_CRL *x) { STACK_OF(X509_REVOKED) *rev; X509_REVOKED *r; long l; int i; char *p; BIO_printf(out, "Certificate Revocation List (CRL):\n"); l = X509_CRL_get_version(x); BIO_printf(out, "%8sVersion %lu (0x%lx)\n", "", l + 1, l); i = OBJ_obj2nid(x->sig_alg->algorithm); X509_signature_print(out, x->sig_alg, NULL); p = X509_NAME_oneline(X509_CRL_get_issuer(x), NULL, 0); BIO_printf(out, "%8sIssuer: %s\n", "", p); free(p); BIO_printf(out, "%8sLast Update: ", ""); ASN1_TIME_print(out, X509_CRL_get_lastUpdate(x)); BIO_printf(out, "\n%8sNext Update: ", ""); if (X509_CRL_get_nextUpdate(x)) ASN1_TIME_print(out, X509_CRL_get_nextUpdate(x)); else BIO_printf(out, "NONE"); BIO_printf(out, "\n"); X509V3_extensions_print(out, "CRL extensions", x->crl->extensions, 0, 8); rev = X509_CRL_get_REVOKED(x); if (sk_X509_REVOKED_num(rev) > 0) BIO_printf(out, "Revoked Certificates:\n"); else BIO_printf(out, "No Revoked Certificates.\n"); for (i = 0; i < sk_X509_REVOKED_num(rev); i++) { r = sk_X509_REVOKED_value(rev, i); BIO_printf(out, " Serial Number: "); i2a_ASN1_INTEGER(out, r->serialNumber); BIO_printf(out, "\n Revocation Date: "); ASN1_TIME_print(out, r->revocationDate); BIO_printf(out, "\n"); X509V3_extensions_print(out, "CRL entry extensions", r->extensions, 0, 8); } X509_signature_print(out, x->sig_alg, x->signature); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_dup.c0000644000175000017500000001032012360020705020345 0ustar /* $OpenBSD: a_dup.c,v 1.12 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #ifndef NO_OLD_ASN1 void * ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x) { unsigned char *b, *p; const unsigned char *p2; int i; char *ret; if (x == NULL) return (NULL); i = i2d(x, NULL); b = malloc(i + 10); if (b == NULL) { ASN1err(ASN1_F_ASN1_DUP, ERR_R_MALLOC_FAILURE); return (NULL); } p = b; i = i2d(x, &p); p2 = b; ret = d2i(NULL, &p2, i); free(b); return (ret); } #endif /* ASN1_ITEM version of dup: this follows the model above except we don't need * to allocate the buffer. At some point this could be rewritten to directly dup * the underlying structure instead of doing and encode and decode. */ void * ASN1_item_dup(const ASN1_ITEM *it, void *x) { unsigned char *b = NULL; const unsigned char *p; long i; void *ret; if (x == NULL) return (NULL); i = ASN1_item_i2d(x, &b, it); if (b == NULL) { ASN1err(ASN1_F_ASN1_ITEM_DUP, ERR_R_MALLOC_FAILURE); return (NULL); } p = b; ret = ASN1_item_d2i(NULL, &p, i, it); free(b); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_utf8.c0000644000175000017500000001512112360020705020447 0ustar /* $OpenBSD: a_utf8.c,v 1.7 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include "asn1_locl.h" /* UTF8 utilities */ /* * This parses a UTF8 string one character at a time. It is passed a pointer * to the string and the length of the string. It sets 'value' to the value of * the current character. It returns the number of characters read or a * negative error code: * -1 = string too short * -2 = illegal character * -3 = subsequent characters not of the form 10xxxxxx * -4 = character encoded incorrectly (not minimal length). */ int UTF8_getc(const unsigned char *str, int len, unsigned long *val) { const unsigned char *p; unsigned long value; int ret; if (len <= 0) return 0; p = str; /* Check syntax and work out the encoded value (if correct) */ if ((*p & 0x80) == 0) { value = *p++ & 0x7f; ret = 1; } else if ((*p & 0xe0) == 0xc0) { if (*p < 0xc2) return -2; if (len < 2) return -1; if ((p[1] & 0xc0) != 0x80) return -3; value = (*p++ & 0x1f) << 6; value |= *p++ & 0x3f; if (value < 0x80) return -4; ret = 2; } else if ((*p & 0xf0) == 0xe0) { if (len < 3) return -1; if (((p[1] & 0xc0) != 0x80) || ((p[2] & 0xc0) != 0x80)) return -3; value = (*p++ & 0xf) << 12; value |= (*p++ & 0x3f) << 6; value |= *p++ & 0x3f; if (value < 0x800) return -4; /* surrogate pair code points are not valid */ if (value >= 0xd800 && value < 0xe000) return -2; ret = 3; } else if ((*p & 0xf8) == 0xf0 && (*p < 0xf5)) { if (len < 4) return -1; if (((p[1] & 0xc0) != 0x80) || ((p[2] & 0xc0) != 0x80) || ((p[3] & 0xc0) != 0x80)) return -3; value = ((unsigned long)(*p++ & 0x7)) << 18; value |= (*p++ & 0x3f) << 12; value |= (*p++ & 0x3f) << 6; value |= *p++ & 0x3f; if (value < 0x10000) return -4; if (value > UNICODE_MAX) return -2; ret = 4; } else return -2; *val = value; return ret; } /* This takes a Unicode code point 'value' and writes its UTF-8 encoded form * in 'str' where 'str' is a buffer of at least length 'len'. If 'str' * is NULL, then nothing is written and just the return code is determined. * Returns less than zero on error: * -1 if 'str' is not NULL and 'len' is too small * -2 if 'value' is an invalid character (surrogate or out-of-range) * * Otherwise, returns the number of bytes in 'value's encoded form * (i.e., the number of bytes written to 'str' when it's not NULL). * * It will need at most 4 characters. */ int UTF8_putc(unsigned char *str, int len, unsigned long value) { if (value < 0x80) { if (str != NULL) { if (len < 1) return -1; str[0] = (unsigned char)value; } return 1; } if (value < 0x800) { if (str != NULL) { if (len < 2) return -1; str[0] = (unsigned char)(((value >> 6) & 0x1f) | 0xc0); str[1] = (unsigned char)((value & 0x3f) | 0x80); } return 2; } if (value < 0x10000) { if (UNICODE_IS_SURROGATE(value)) return -2; if (str != NULL) { if (len < 3) return -1; str[0] = (unsigned char)(((value >> 12) & 0xf) | 0xe0); str[1] = (unsigned char)(((value >> 6) & 0x3f) | 0x80); str[2] = (unsigned char)((value & 0x3f) | 0x80); } return 3; } if (value <= UNICODE_MAX) { if (str != NULL) { if (len < 4) return -1; str[0] = (unsigned char)(((value >> 18) & 0x7) | 0xf0); str[1] = (unsigned char)(((value >> 12) & 0x3f) | 0x80); str[2] = (unsigned char)(((value >> 6) & 0x3f) | 0x80); str[3] = (unsigned char)((value & 0x3f) | 0x80); } return 4; } return -2; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/tasn_dec.c0000644000175000017500000007553612360020705021061 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include static int asn1_check_eoc(const unsigned char **in, long len); static int asn1_find_end(const unsigned char **in, long len, char inf); static int asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, char inf, int tag, int aclass, int depth); static int collect_data(BUF_MEM *buf, const unsigned char **p, long plen); static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, char *inf, char *cst, const unsigned char **in, long len, int exptag, int expclass, char opt, ASN1_TLC *ctx); static int asn1_template_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx); static int asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx); static int asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx); /* Table to convert tags to bit values, used for MSTRING type */ static const unsigned long tag2bit[32] = { 0, 0, 0, B_ASN1_BIT_STRING, /* tags 0 - 3 */ B_ASN1_OCTET_STRING, 0, 0, B_ASN1_UNKNOWN,/* tags 4- 7 */ B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN,/* tags 8-11 */ B_ASN1_UTF8STRING,B_ASN1_UNKNOWN,B_ASN1_UNKNOWN,B_ASN1_UNKNOWN,/* tags 12-15 */ B_ASN1_SEQUENCE,0,B_ASN1_NUMERICSTRING,B_ASN1_PRINTABLESTRING, /* tags 16-19 */ B_ASN1_T61STRING,B_ASN1_VIDEOTEXSTRING,B_ASN1_IA5STRING, /* tags 20-22 */ B_ASN1_UTCTIME, B_ASN1_GENERALIZEDTIME, /* tags 23-24 */ B_ASN1_GRAPHICSTRING,B_ASN1_ISO64STRING,B_ASN1_GENERALSTRING, /* tags 25-27 */ B_ASN1_UNIVERSALSTRING,B_ASN1_UNKNOWN,B_ASN1_BMPSTRING,B_ASN1_UNKNOWN, /* tags 28-31 */ }; unsigned long ASN1_tag2bit(int tag) { if ((tag < 0) || (tag > 30)) return 0; return tag2bit[tag]; } /* Macro to initialize and invalidate the cache */ #define asn1_tlc_clear(c) if (c) (c)->valid = 0 /* Version to avoid compiler warning about 'c' always non-NULL */ #define asn1_tlc_clear_nc(c) (c)->valid = 0 /* Decode an ASN1 item, this currently behaves just * like a standard 'd2i' function. 'in' points to * a buffer to read the data from, in future we will * have more advanced versions that can input data * a piece at a time and this will simply be a special * case. */ ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it) { ASN1_TLC c; ASN1_VALUE *ptmpval = NULL; if (!pval) pval = &ptmpval; asn1_tlc_clear_nc(&c); if (ASN1_item_ex_d2i(pval, in, len, it, -1, 0, 0, &c) > 0) return *pval; return NULL; } int ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_TEMPLATE *tt) { ASN1_TLC c; asn1_tlc_clear_nc(&c); return asn1_template_ex_d2i(pval, in, len, tt, 0, &c); } /* Decode an item, taking care of IMPLICIT tagging, if any. * If 'opt' set and tag mismatch return -1 to handle OPTIONAL */ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx) { const ASN1_TEMPLATE *tt, *errtt = NULL; const ASN1_COMPAT_FUNCS *cf; const ASN1_EXTERN_FUNCS *ef; const ASN1_AUX *aux = it->funcs; ASN1_aux_cb *asn1_cb; const unsigned char *p = NULL, *q; unsigned char *wp = NULL; /* BIG FAT WARNING! BREAKS CONST WHERE USED */ unsigned char imphack = 0, oclass; char seq_eoc, seq_nolen, cst, isopt; long tmplen; int i; int otag; int ret = 0; ASN1_VALUE **pchptr, *ptmpval; if (!pval) return 0; if (aux && aux->asn1_cb) asn1_cb = aux->asn1_cb; else asn1_cb = 0; switch (it->itype) { case ASN1_ITYPE_PRIMITIVE: if (it->templates) { /* tagging or OPTIONAL is currently illegal on an item * template because the flags can't get passed down. * In practice this isn't a problem: we include the * relevant flags from the item template in the * template itself. */ if ((tag != -1) || opt) { ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE); goto err; } return asn1_template_ex_d2i(pval, in, len, it->templates, opt, ctx); } return asn1_d2i_ex_primitive(pval, in, len, it, tag, aclass, opt, ctx); break; case ASN1_ITYPE_MSTRING: p = *in; /* Just read in tag and class */ ret = asn1_check_tlen(NULL, &otag, &oclass, NULL, NULL, &p, len, -1, 0, 1, ctx); if (!ret) { ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; } /* Must be UNIVERSAL class */ if (oclass != V_ASN1_UNIVERSAL) { /* If OPTIONAL, assume this is OK */ if (opt) return -1; ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_MSTRING_NOT_UNIVERSAL); goto err; } /* Check tag matches bit map */ if (!(ASN1_tag2bit(otag) & it->utype)) { /* If OPTIONAL, assume this is OK */ if (opt) return -1; ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_MSTRING_WRONG_TAG); goto err; } return asn1_d2i_ex_primitive(pval, in, len, it, otag, 0, 0, ctx); case ASN1_ITYPE_EXTERN: /* Use new style d2i */ ef = it->funcs; return ef->asn1_ex_d2i(pval, in, len, it, tag, aclass, opt, ctx); case ASN1_ITYPE_COMPAT: /* we must resort to old style evil hackery */ cf = it->funcs; /* If OPTIONAL see if it is there */ if (opt) { int exptag; p = *in; if (tag == -1) exptag = it->utype; else exptag = tag; /* Don't care about anything other than presence * of expected tag */ ret = asn1_check_tlen(NULL, NULL, NULL, NULL, NULL, &p, len, exptag, aclass, 1, ctx); if (!ret) { ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; } if (ret == -1) return -1; } /* This is the old style evil hack IMPLICIT handling: * since the underlying code is expecting a tag and * class other than the one present we change the * buffer temporarily then change it back afterwards. * This doesn't and never did work for tags > 30. * * Yes this is *horrible* but it is only needed for * old style d2i which will hopefully not be around * for much longer. * FIXME: should copy the buffer then modify it so * the input buffer can be const: we should *always* * copy because the old style d2i might modify the * buffer. */ if (tag != -1) { wp = *(unsigned char **)in; imphack = *wp; if (p == NULL) { ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; } *wp = (unsigned char)((*p & V_ASN1_CONSTRUCTED) | it->utype); } ptmpval = cf->asn1_d2i(pval, in, len); if (tag != -1) *wp = imphack; if (ptmpval) return 1; ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; case ASN1_ITYPE_CHOICE: if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL)) goto auxerr; /* Allocate structure */ if (!*pval && !ASN1_item_ex_new(pval, it)) { ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; } /* CHOICE type, try each possibility in turn */ p = *in; for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) { pchptr = asn1_get_field_ptr(pval, tt); /* We mark field as OPTIONAL so its absence * can be recognised. */ ret = asn1_template_ex_d2i(pchptr, &p, len, tt, 1, ctx); /* If field not present, try the next one */ if (ret == -1) continue; /* If positive return, read OK, break loop */ if (ret > 0) break; /* Otherwise must be an ASN1 parsing error */ errtt = tt; ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; } /* Did we fall off the end without reading anything? */ if (i == it->tcount) { /* If OPTIONAL, this is OK */ if (opt) { /* Free and zero it */ ASN1_item_ex_free(pval, it); return -1; } ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_NO_MATCHING_CHOICE_TYPE); goto err; } asn1_set_choice_selector(pval, i, it); *in = p; if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it, NULL)) goto auxerr; return 1; case ASN1_ITYPE_NDEF_SEQUENCE: case ASN1_ITYPE_SEQUENCE: p = *in; tmplen = len; /* If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL */ if (tag == -1) { tag = V_ASN1_SEQUENCE; aclass = V_ASN1_UNIVERSAL; } /* Get SEQUENCE length and update len, p */ ret = asn1_check_tlen(&len, NULL, NULL, &seq_eoc, &cst, &p, len, tag, aclass, opt, ctx); if (!ret) { ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; } else if (ret == -1) return -1; if (aux && (aux->flags & ASN1_AFLG_BROKEN)) { len = tmplen - (p - *in); seq_nolen = 1; } /* If indefinite we don't do a length check */ else seq_nolen = seq_eoc; if (!cst) { ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_SEQUENCE_NOT_CONSTRUCTED); goto err; } if (!*pval && !ASN1_item_ex_new(pval, it)) { ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; } if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL)) goto auxerr; /* Get each field entry */ for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) { const ASN1_TEMPLATE *seqtt; ASN1_VALUE **pseqval; seqtt = asn1_do_adb(pval, tt, 1); if (!seqtt) goto err; pseqval = asn1_get_field_ptr(pval, seqtt); /* Have we ran out of data? */ if (!len) break; q = p; if (asn1_check_eoc(&p, len)) { if (!seq_eoc) { ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_UNEXPECTED_EOC); goto err; } len -= p - q; seq_eoc = 0; q = p; break; } /* This determines the OPTIONAL flag value. The field * cannot be omitted if it is the last of a SEQUENCE * and there is still data to be read. This isn't * strictly necessary but it increases efficiency in * some cases. */ if (i == (it->tcount - 1)) isopt = 0; else isopt = (char)(seqtt->flags & ASN1_TFLG_OPTIONAL); /* attempt to read in field, allowing each to be * OPTIONAL */ ret = asn1_template_ex_d2i(pseqval, &p, len, seqtt, isopt, ctx); if (!ret) { errtt = seqtt; goto err; } else if (ret == -1) { /* OPTIONAL component absent. * Free and zero the field. */ ASN1_template_free(pseqval, seqtt); continue; } /* Update length */ len -= p - q; } /* Check for EOC if expecting one */ if (seq_eoc && !asn1_check_eoc(&p, len)) { ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_MISSING_EOC); goto err; } /* Check all data read */ if (!seq_nolen && len) { ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_SEQUENCE_LENGTH_MISMATCH); goto err; } /* If we get here we've got no more data in the SEQUENCE, * however we may not have read all fields so check all * remaining are OPTIONAL and clear any that are. */ for (; i < it->tcount; tt++, i++) { const ASN1_TEMPLATE *seqtt; seqtt = asn1_do_adb(pval, tt, 1); if (!seqtt) goto err; if (seqtt->flags & ASN1_TFLG_OPTIONAL) { ASN1_VALUE **pseqval; pseqval = asn1_get_field_ptr(pval, seqtt); ASN1_template_free(pseqval, seqtt); } else { errtt = seqtt; ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_FIELD_MISSING); goto err; } } /* Save encoding */ if (!asn1_enc_save(pval, *in, p - *in, it)) goto auxerr; *in = p; if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it, NULL)) goto auxerr; return 1; default: return 0; } auxerr: ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_AUX_ERROR); err: ASN1_item_ex_free(pval, it); if (errtt) ERR_asprintf_error_data("Field=%s, Type=%s", errtt->field_name, it->sname); else ERR_asprintf_error_data("Type=%s", it->sname); return 0; } /* Templates are handled with two separate functions. * One handles any EXPLICIT tag and the other handles the rest. */ static int asn1_template_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long inlen, const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx) { int flags, aclass; int ret; long len; const unsigned char *p, *q; char exp_eoc; if (!val) return 0; flags = tt->flags; aclass = flags & ASN1_TFLG_TAG_CLASS; p = *in; /* Check if EXPLICIT tag expected */ if (flags & ASN1_TFLG_EXPTAG) { char cst; /* Need to work out amount of data available to the inner * content and where it starts: so read in EXPLICIT header to * get the info. */ ret = asn1_check_tlen(&len, NULL, NULL, &exp_eoc, &cst, &p, inlen, tt->tag, aclass, opt, ctx); q = p; if (!ret) { ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ERR_R_NESTED_ASN1_ERROR); return 0; } else if (ret == -1) return -1; if (!cst) { ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED); return 0; } /* We've found the field so it can't be OPTIONAL now */ ret = asn1_template_noexp_d2i(val, &p, len, tt, 0, ctx); if (!ret) { ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ERR_R_NESTED_ASN1_ERROR); return 0; } /* We read the field in OK so update length */ len -= p - q; if (exp_eoc) { /* If NDEF we must have an EOC here */ if (!asn1_check_eoc(&p, len)) { ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ASN1_R_MISSING_EOC); goto err; } } else { /* Otherwise we must hit the EXPLICIT tag end or its * an error */ if (len) { ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ASN1_R_EXPLICIT_LENGTH_MISMATCH); goto err; } } } else return asn1_template_noexp_d2i(val, in, inlen, tt, opt, ctx); *in = p; return 1; err: ASN1_template_free(val, tt); return 0; } static int asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx) { int flags, aclass; int ret; const unsigned char *p, *q; if (!val) return 0; flags = tt->flags; aclass = flags & ASN1_TFLG_TAG_CLASS; p = *in; q = p; if (flags & ASN1_TFLG_SK_MASK) { /* SET OF, SEQUENCE OF */ int sktag, skaclass; char sk_eoc; /* First work out expected inner tag value */ if (flags & ASN1_TFLG_IMPTAG) { sktag = tt->tag; skaclass = aclass; } else { skaclass = V_ASN1_UNIVERSAL; if (flags & ASN1_TFLG_SET_OF) sktag = V_ASN1_SET; else sktag = V_ASN1_SEQUENCE; } /* Get the tag */ ret = asn1_check_tlen(&len, NULL, NULL, &sk_eoc, NULL, &p, len, sktag, skaclass, opt, ctx); if (!ret) { ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, ERR_R_NESTED_ASN1_ERROR); return 0; } else if (ret == -1) return -1; if (!*val) *val = (ASN1_VALUE *)sk_new_null(); else { /* We've got a valid STACK: free up any items present */ STACK_OF(ASN1_VALUE) *sktmp = (STACK_OF(ASN1_VALUE) *)*val; ASN1_VALUE *vtmp; while (sk_ASN1_VALUE_num(sktmp) > 0) { vtmp = sk_ASN1_VALUE_pop(sktmp); ASN1_item_ex_free(&vtmp, ASN1_ITEM_ptr(tt->item)); } } if (!*val) { ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, ERR_R_MALLOC_FAILURE); goto err; } /* Read as many items as we can */ while (len > 0) { ASN1_VALUE *skfield; q = p; /* See if EOC found */ if (asn1_check_eoc(&p, len)) { if (!sk_eoc) { ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, ASN1_R_UNEXPECTED_EOC); goto err; } len -= p - q; sk_eoc = 0; break; } skfield = NULL; if (!ASN1_item_ex_d2i(&skfield, &p, len, ASN1_ITEM_ptr(tt->item), -1, 0, 0, ctx)) { ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; } len -= p - q; if (!sk_ASN1_VALUE_push((STACK_OF(ASN1_VALUE) *)*val, skfield)) { ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, ERR_R_MALLOC_FAILURE); goto err; } } if (sk_eoc) { ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, ASN1_R_MISSING_EOC); goto err; } } else if (flags & ASN1_TFLG_IMPTAG) { /* IMPLICIT tagging */ ret = ASN1_item_ex_d2i(val, &p, len, ASN1_ITEM_ptr(tt->item), tt->tag, aclass, opt, ctx); if (!ret) { ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; } else if (ret == -1) return -1; } else { /* Nothing special */ ret = ASN1_item_ex_d2i(val, &p, len, ASN1_ITEM_ptr(tt->item), -1, 0, opt, ctx); if (!ret) { ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; } else if (ret == -1) return -1; } *in = p; return 1; err: ASN1_template_free(val, tt); return 0; } static int asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, long inlen, const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx) { int ret = 0, utype; long plen; char cst, inf, free_cont = 0; const unsigned char *p; BUF_MEM buf; const unsigned char *cont = NULL; long len; if (!pval) { ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_NULL); return 0; /* Should never happen */ } if (it->itype == ASN1_ITYPE_MSTRING) { utype = tag; tag = -1; } else utype = it->utype; if (utype == V_ASN1_ANY) { /* If type is ANY need to figure out type from tag */ unsigned char oclass; if (tag >= 0) { ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_TAGGED_ANY); return 0; } if (opt) { ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_OPTIONAL_ANY); return 0; } p = *in; ret = asn1_check_tlen(NULL, &utype, &oclass, NULL, NULL, &p, inlen, -1, 0, 0, ctx); if (!ret) { ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_NESTED_ASN1_ERROR); return 0; } if (oclass != V_ASN1_UNIVERSAL) utype = V_ASN1_OTHER; } if (tag == -1) { tag = utype; aclass = V_ASN1_UNIVERSAL; } p = *in; /* Check header */ ret = asn1_check_tlen(&plen, NULL, NULL, &inf, &cst, &p, inlen, tag, aclass, opt, ctx); if (!ret) { ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_NESTED_ASN1_ERROR); return 0; } else if (ret == -1) return -1; ret = 0; /* SEQUENCE, SET and "OTHER" are left in encoded form */ if ((utype == V_ASN1_SEQUENCE) || (utype == V_ASN1_SET) || (utype == V_ASN1_OTHER)) { /* Clear context cache for type OTHER because the auto clear * when we have a exact match wont work */ if (utype == V_ASN1_OTHER) { asn1_tlc_clear(ctx); } /* SEQUENCE and SET must be constructed */ else if (!cst) { ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_TYPE_NOT_CONSTRUCTED); return 0; } cont = *in; /* If indefinite length constructed find the real end */ if (inf) { if (!asn1_find_end(&p, plen, inf)) goto err; len = p - cont; } else { len = p - cont + plen; p += plen; buf.data = NULL; } } else if (cst) { buf.length = 0; buf.max = 0; buf.data = NULL; /* Should really check the internal tags are correct but * some things may get this wrong. The relevant specs * say that constructed string types should be OCTET STRINGs * internally irrespective of the type. So instead just check * for UNIVERSAL class and ignore the tag. */ if (!asn1_collect(&buf, &p, plen, inf, -1, V_ASN1_UNIVERSAL, 0)) { free_cont = 1; goto err; } len = buf.length; /* Append a final null to string */ if (!BUF_MEM_grow_clean(&buf, len + 1)) { ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_MALLOC_FAILURE); return 0; } buf.data[len] = 0; cont = (const unsigned char *)buf.data; free_cont = 1; } else { cont = p; len = plen; p += plen; } /* We now have content length and type: translate into a structure */ if (!asn1_ex_c2i(pval, cont, len, utype, &free_cont, it)) goto err; *in = p; ret = 1; err: if (free_cont && buf.data) free(buf.data); return ret; } /* Translate ASN1 content octets into a structure */ int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it) { ASN1_VALUE **opval = NULL; ASN1_STRING *stmp; ASN1_TYPE *typ = NULL; int ret = 0; const ASN1_PRIMITIVE_FUNCS *pf; ASN1_INTEGER **tint; pf = it->funcs; if (pf && pf->prim_c2i) return pf->prim_c2i(pval, cont, len, utype, free_cont, it); /* If ANY type clear type and set pointer to internal value */ if (it->utype == V_ASN1_ANY) { if (!*pval) { typ = ASN1_TYPE_new(); if (typ == NULL) goto err; *pval = (ASN1_VALUE *)typ; } else typ = (ASN1_TYPE *)*pval; if (utype != typ->type) ASN1_TYPE_set(typ, utype, NULL); opval = pval; pval = &typ->value.asn1_value; } switch (utype) { case V_ASN1_OBJECT: if (!c2i_ASN1_OBJECT((ASN1_OBJECT **)pval, &cont, len)) goto err; break; case V_ASN1_NULL: if (len) { ASN1err(ASN1_F_ASN1_EX_C2I, ASN1_R_NULL_IS_WRONG_LENGTH); goto err; } *pval = (ASN1_VALUE *)1; break; case V_ASN1_BOOLEAN: if (len != 1) { ASN1err(ASN1_F_ASN1_EX_C2I, ASN1_R_BOOLEAN_IS_WRONG_LENGTH); goto err; } else { ASN1_BOOLEAN *tbool; tbool = (ASN1_BOOLEAN *)pval; *tbool = *cont; } break; case V_ASN1_BIT_STRING: if (!c2i_ASN1_BIT_STRING((ASN1_BIT_STRING **)pval, &cont, len)) goto err; break; case V_ASN1_INTEGER: case V_ASN1_NEG_INTEGER: case V_ASN1_ENUMERATED: case V_ASN1_NEG_ENUMERATED: tint = (ASN1_INTEGER **)pval; if (!c2i_ASN1_INTEGER(tint, &cont, len)) goto err; /* Fixup type to match the expected form */ (*tint)->type = utype | ((*tint)->type & V_ASN1_NEG); break; case V_ASN1_OCTET_STRING: case V_ASN1_NUMERICSTRING: case V_ASN1_PRINTABLESTRING: case V_ASN1_T61STRING: case V_ASN1_VIDEOTEXSTRING: case V_ASN1_IA5STRING: case V_ASN1_UTCTIME: case V_ASN1_GENERALIZEDTIME: case V_ASN1_GRAPHICSTRING: case V_ASN1_VISIBLESTRING: case V_ASN1_GENERALSTRING: case V_ASN1_UNIVERSALSTRING: case V_ASN1_BMPSTRING: case V_ASN1_UTF8STRING: case V_ASN1_OTHER: case V_ASN1_SET: case V_ASN1_SEQUENCE: default: if (utype == V_ASN1_BMPSTRING && (len & 1)) { ASN1err(ASN1_F_ASN1_EX_C2I, ASN1_R_BMPSTRING_IS_WRONG_LENGTH); goto err; } if (utype == V_ASN1_UNIVERSALSTRING && (len & 3)) { ASN1err(ASN1_F_ASN1_EX_C2I, ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH); goto err; } /* All based on ASN1_STRING and handled the same */ if (!*pval) { stmp = ASN1_STRING_type_new(utype); if (!stmp) { ASN1err(ASN1_F_ASN1_EX_C2I, ERR_R_MALLOC_FAILURE); goto err; } *pval = (ASN1_VALUE *)stmp; } else { stmp = (ASN1_STRING *)*pval; stmp->type = utype; } /* If we've already allocated a buffer use it */ if (*free_cont) { free(stmp->data); stmp->data = (unsigned char *)cont; /* UGLY CAST! RL */ stmp->length = len; *free_cont = 0; } else { if (!ASN1_STRING_set(stmp, cont, len)) { ASN1err(ASN1_F_ASN1_EX_C2I, ERR_R_MALLOC_FAILURE); ASN1_STRING_free(stmp); *pval = NULL; goto err; } } break; } /* If ASN1_ANY and NULL type fix up value */ if (typ && (utype == V_ASN1_NULL)) typ->value.ptr = NULL; ret = 1; err: if (!ret) { ASN1_TYPE_free(typ); if (opval) *opval = NULL; } return ret; } /* This function finds the end of an ASN1 structure when passed its maximum * length, whether it is indefinite length and a pointer to the content. * This is more efficient than calling asn1_collect because it does not * recurse on each indefinite length header. */ static int asn1_find_end(const unsigned char **in, long len, char inf) { int expected_eoc; long plen; const unsigned char *p = *in, *q; /* If not indefinite length constructed just add length */ if (inf == 0) { *in += len; return 1; } expected_eoc = 1; /* Indefinite length constructed form. Find the end when enough EOCs * are found. If more indefinite length constructed headers * are encountered increment the expected eoc count otherwise just * skip to the end of the data. */ while (len > 0) { if (asn1_check_eoc(&p, len)) { expected_eoc--; if (expected_eoc == 0) break; len -= 2; continue; } q = p; /* Just read in a header: only care about the length */ if (!asn1_check_tlen(&plen, NULL, NULL, &inf, NULL, &p, len, -1, 0, 0, NULL)) { ASN1err(ASN1_F_ASN1_FIND_END, ERR_R_NESTED_ASN1_ERROR); return 0; } if (inf) expected_eoc++; else p += plen; len -= p - q; } if (expected_eoc) { ASN1err(ASN1_F_ASN1_FIND_END, ASN1_R_MISSING_EOC); return 0; } *in = p; return 1; } /* This function collects the asn1 data from a constructred string * type into a buffer. The values of 'in' and 'len' should refer * to the contents of the constructed type and 'inf' should be set * if it is indefinite length. */ #ifndef ASN1_MAX_STRING_NEST /* This determines how many levels of recursion are permitted in ASN1 * string types. If it is not limited stack overflows can occur. If set * to zero no recursion is allowed at all. Although zero should be adequate * examples exist that require a value of 1. So 5 should be more than enough. */ #define ASN1_MAX_STRING_NEST 5 #endif static int asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, char inf, int tag, int aclass, int depth) { const unsigned char *p, *q; long plen; char cst, ininf; p = *in; inf &= 1; /* If no buffer and not indefinite length constructed just pass over * the encoded data */ if (!buf && !inf) { *in += len; return 1; } while (len > 0) { q = p; /* Check for EOC */ if (asn1_check_eoc(&p, len)) { /* EOC is illegal outside indefinite length * constructed form */ if (!inf) { ASN1err(ASN1_F_ASN1_COLLECT, ASN1_R_UNEXPECTED_EOC); return 0; } inf = 0; break; } if (!asn1_check_tlen(&plen, NULL, NULL, &ininf, &cst, &p, len, tag, aclass, 0, NULL)) { ASN1err(ASN1_F_ASN1_COLLECT, ERR_R_NESTED_ASN1_ERROR); return 0; } /* If indefinite length constructed update max length */ if (cst) { if (depth >= ASN1_MAX_STRING_NEST) { ASN1err(ASN1_F_ASN1_COLLECT, ASN1_R_NESTED_ASN1_STRING); return 0; } if (!asn1_collect(buf, &p, plen, ininf, tag, aclass, depth + 1)) return 0; } else if (plen && !collect_data(buf, &p, plen)) return 0; len -= p - q; } if (inf) { ASN1err(ASN1_F_ASN1_COLLECT, ASN1_R_MISSING_EOC); return 0; } *in = p; return 1; } static int collect_data(BUF_MEM *buf, const unsigned char **p, long plen) { int len; if (buf) { len = buf->length; if (!BUF_MEM_grow_clean(buf, len + plen)) { ASN1err(ASN1_F_COLLECT_DATA, ERR_R_MALLOC_FAILURE); return 0; } memcpy(buf->data + len, *p, plen); } *p += plen; return 1; } /* Check for ASN1 EOC and swallow it if found */ static int asn1_check_eoc(const unsigned char **in, long len) { const unsigned char *p; if (len < 2) return 0; p = *in; if (!p[0] && !p[1]) { *in += 2; return 1; } return 0; } /* Check an ASN1 tag and length: a bit like ASN1_get_object * but it sets the length for indefinite length constructed * form, we don't know the exact length but we can set an * upper bound to the amount of data available minus the * header length just read. */ static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, char *inf, char *cst, const unsigned char **in, long len, int exptag, int expclass, char opt, ASN1_TLC *ctx) { int i; int ptag, pclass; long plen; const unsigned char *p, *q; p = *in; q = p; if (ctx && ctx->valid) { i = ctx->ret; plen = ctx->plen; pclass = ctx->pclass; ptag = ctx->ptag; p += ctx->hdrlen; } else { i = ASN1_get_object(&p, &plen, &ptag, &pclass, len); if (ctx) { ctx->ret = i; ctx->plen = plen; ctx->pclass = pclass; ctx->ptag = ptag; ctx->hdrlen = p - q; ctx->valid = 1; /* If definite length, and no error, length + * header can't exceed total amount of data available. */ if (!(i & 0x81) && ((plen + ctx->hdrlen) > len)) { ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_TOO_LONG); asn1_tlc_clear(ctx); return 0; } } } if (i & 0x80) { ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_BAD_OBJECT_HEADER); asn1_tlc_clear(ctx); return 0; } if (exptag >= 0) { if ((exptag != ptag) || (expclass != pclass)) { /* If type is OPTIONAL, not an error: * indicate missing type. */ if (opt) return -1; asn1_tlc_clear(ctx); ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_WRONG_TAG); return 0; } /* We have a tag and class match: * assume we are going to do something with it */ asn1_tlc_clear(ctx); } if (i & 1) plen = len - (p - q); if (inf) *inf = i & 1; if (cst) *cst = i & V_ASN1_CONSTRUCTED; if (olen) *olen = plen; if (oclass) *oclass = pclass; if (otag) *otag = ptag; *in = p; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/evp_asn1.c0000644000175000017500000001444112360020705021001 0ustar /* $OpenBSD: evp_asn1.c,v 1.11 2014/07/11 08:44:47 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len) { ASN1_STRING *os; if ((os = M_ASN1_OCTET_STRING_new()) == NULL) return (0); if (!M_ASN1_OCTET_STRING_set(os, data, len)) { M_ASN1_OCTET_STRING_free(os); return (0); } ASN1_TYPE_set(a, V_ASN1_OCTET_STRING, os); return (1); } /* int max_len: for returned value */ int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data, int max_len) { int ret, num; unsigned char *p; if ((a->type != V_ASN1_OCTET_STRING) || (a->value.octet_string == NULL)) { ASN1err(ASN1_F_ASN1_TYPE_GET_OCTETSTRING, ASN1_R_DATA_IS_WRONG); return (-1); } p = M_ASN1_STRING_data(a->value.octet_string); ret = M_ASN1_STRING_length(a->value.octet_string); if (ret < max_len) num = ret; else num = max_len; memcpy(data, p, num); return (ret); } int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data, int len) { int n, size; ASN1_OCTET_STRING os, *osp; ASN1_INTEGER in; unsigned char *p; unsigned char buf[32]; /* when they have 256bit longs, * I'll be in trouble */ in.data = buf; in.length = 32; os.data = data; os.type = V_ASN1_OCTET_STRING; os.length = len; ASN1_INTEGER_set(&in, num); n = i2d_ASN1_INTEGER(&in, NULL); n += M_i2d_ASN1_OCTET_STRING(&os, NULL); size = ASN1_object_size(1, n, V_ASN1_SEQUENCE); if ((osp = ASN1_STRING_new()) == NULL) return (0); /* Grow the 'string' */ if (!ASN1_STRING_set(osp, NULL, size)) { ASN1_STRING_free(osp); return (0); } M_ASN1_STRING_length_set(osp, size); p = M_ASN1_STRING_data(osp); ASN1_put_object(&p, 1,n, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL); i2d_ASN1_INTEGER(&in, &p); M_i2d_ASN1_OCTET_STRING(&os, &p); ASN1_TYPE_set(a, V_ASN1_SEQUENCE, osp); return (1); } /* we return the actual length..., num may be missing, in which * case, set it to zero */ /* int max_len: for returned value */ int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, unsigned char *data, int max_len) { int ret = -1, n; ASN1_INTEGER *ai = NULL; ASN1_OCTET_STRING *os = NULL; const unsigned char *p; long length; ASN1_const_CTX c; if ((a->type != V_ASN1_SEQUENCE) || (a->value.sequence == NULL)) { goto err; } p = M_ASN1_STRING_data(a->value.sequence); length = M_ASN1_STRING_length(a->value.sequence); c.pp = &p; c.p = p; c.max = p + length; c.error = ASN1_R_DATA_IS_WRONG; M_ASN1_D2I_start_sequence(); c.q = c.p; if ((ai = d2i_ASN1_INTEGER(NULL, &c.p, c.slen)) == NULL) goto err; c.slen -= (c.p - c.q); c.q = c.p; if ((os = d2i_ASN1_OCTET_STRING(NULL, &c.p, c.slen)) == NULL) goto err; c.slen -= (c.p - c.q); if (!M_ASN1_D2I_end_sequence()) goto err; if (num != NULL) *num = ASN1_INTEGER_get(ai); ret = M_ASN1_STRING_length(os); if (max_len > ret) n = ret; else n = max_len; if (data != NULL) memcpy(data, M_ASN1_STRING_data(os), n); if (0) { err: ASN1err(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING, ASN1_R_DATA_IS_WRONG); } if (os != NULL) M_ASN1_OCTET_STRING_free(os); if (ai != NULL) M_ASN1_INTEGER_free(ai); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/a_gentm.c0000644000175000017500000001713012360020705020675 0ustar /* $OpenBSD: a_gentm.c,v 1.21 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* GENERALIZEDTIME implementation, written by Steve Henson. Based on UTCTIME */ #include #include #include #include #include #include "o_time.h" #if 0 int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a, unsigned char **pp) { return(i2d_ASN1_bytes((ASN1_STRING *)a, pp, V_ASN1_GENERALIZEDTIME, V_ASN1_UNIVERSAL)); } ASN1_GENERALIZEDTIME * d2i_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME **a, unsigned char **pp, long length) { ASN1_GENERALIZEDTIME *ret = NULL; ret = (ASN1_GENERALIZEDTIME *)d2i_ASN1_bytes((ASN1_STRING **)a, pp, length, V_ASN1_GENERALIZEDTIME, V_ASN1_UNIVERSAL); if (ret == NULL) { ASN1err(ASN1_F_D2I_ASN1_GENERALIZEDTIME, ERR_R_NESTED_ASN1_ERROR); return (NULL); } if (!ASN1_GENERALIZEDTIME_check(ret)) { ASN1err(ASN1_F_D2I_ASN1_GENERALIZEDTIME, ASN1_R_INVALID_TIME_FORMAT); goto err; } return (ret); err: if ((ret != NULL) && ((a == NULL) || (*a != ret))) M_ASN1_GENERALIZEDTIME_free(ret); return (NULL); } #endif int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d) { static const int min[9] = {0, 0, 1, 1, 0, 0, 0, 0, 0}; static const int max[9] = {99, 99, 12, 31, 23, 59, 59, 12, 59}; char *a; int n, i, l, o; if (d->type != V_ASN1_GENERALIZEDTIME) return (0); l = d->length; a = (char *)d->data; o = 0; /* GENERALIZEDTIME is similar to UTCTIME except the year is * represented as YYYY. This stuff treats everything as a two digit * field so make first two fields 00 to 99 */ if (l < 13) goto err; for (i = 0; i < 7; i++) { if ((i == 6) && ((a[o] == 'Z') || (a[o] == '+') || (a[o] == '-'))) { i++; break; } if ((a[o] < '0') || (a[o] > '9')) goto err; n= a[o]-'0'; if (++o > l) goto err; if ((a[o] < '0') || (a[o] > '9')) goto err; n = (n * 10)+ a[o] - '0'; if (++o > l) goto err; if ((n < min[i]) || (n > max[i])) goto err; } /* Optional fractional seconds: decimal point followed by one * or more digits. */ if (a[o] == '.') { if (++o > l) goto err; i = o; while ((a[o] >= '0') && (a[o] <= '9') && (o <= l)) o++; /* Must have at least one digit after decimal point */ if (i == o) goto err; } if (a[o] == 'Z') o++; else if ((a[o] == '+') || (a[o] == '-')) { o++; if (o + 4 > l) goto err; for (i = 7; i < 9; i++) { if ((a[o] < '0') || (a[o] > '9')) goto err; n = a[o] - '0'; o++; if ((a[o] < '0') || (a[o] > '9')) goto err; n = (n * 10) + a[o] - '0'; if ((n < min[i]) || (n > max[i])) goto err; o++; } } else { /* Missing time zone information. */ goto err; } return (o == l); err: return (0); } int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str) { ASN1_GENERALIZEDTIME t; t.type = V_ASN1_GENERALIZEDTIME; t.length = strlen(str); t.data = (unsigned char *)str; if (ASN1_GENERALIZEDTIME_check(&t)) { if (s != NULL) { if (!ASN1_STRING_set((ASN1_STRING *)s, (unsigned char *)str, t.length)) return 0; s->type = V_ASN1_GENERALIZEDTIME; } return (1); } else return (0); } ASN1_GENERALIZEDTIME * ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, time_t t) { return ASN1_GENERALIZEDTIME_adj(s, t, 0, 0); } static ASN1_GENERALIZEDTIME * ASN1_GENERALIZEDTIME_adj_internal(ASN1_GENERALIZEDTIME *s, time_t t, int offset_day, long offset_sec) { char *p; struct tm *ts; struct tm data; size_t len = 20; ts = gmtime_r(&t, &data); if (ts == NULL) return (NULL); if (offset_day || offset_sec) { if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec)) return NULL; } p = (char *)s->data; if ((p == NULL) || ((size_t)s->length < len)) { p = malloc(len); if (p == NULL) { ASN1err(ASN1_F_ASN1_GENERALIZEDTIME_ADJ, ERR_R_MALLOC_FAILURE); return (NULL); } free(s->data); s->data = (unsigned char *)p; } snprintf(p, len, "%04d%02d%02d%02d%02d%02dZ", ts->tm_year + 1900, ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min, ts->tm_sec); s->length = strlen(p); s->type = V_ASN1_GENERALIZEDTIME; return (s); } ASN1_GENERALIZEDTIME * ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, time_t t, int offset_day, long offset_sec) { ASN1_GENERALIZEDTIME *tmp = NULL, *ret; if (s == NULL) { tmp = M_ASN1_GENERALIZEDTIME_new(); if (tmp == NULL) return NULL; s = tmp; } ret = ASN1_GENERALIZEDTIME_adj_internal(s, t, offset_day, offset_sec); if (ret == NULL && tmp != NULL) M_ASN1_GENERALIZEDTIME_free(tmp); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/tasn_enc.c0000644000175000017500000004300612360020705021056 0ustar /* $OpenBSD: tasn_enc.c,v 1.13 2014/06/12 15:49:27 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000-2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out, int skcontlen, const ASN1_ITEM *item, int do_sort, int iclass); static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt, int tag, int aclass); static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it, int flags); /* Top level i2d equivalents: the 'ndef' variant instructs the encoder * to use indefinite length constructed encoding, where appropriate */ int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it) { return asn1_item_flags_i2d(val, out, it, ASN1_TFLG_NDEF); } int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it) { return asn1_item_flags_i2d(val, out, it, 0); } /* Encode an ASN1 item, this is use by the * standard 'i2d' function. 'out' points to * a buffer to output the data to. * * The new i2d has one additional feature. If the output * buffer is NULL (i.e. *out == NULL) then a buffer is * allocated and populated with the encoding. */ static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it, int flags) { if (out && !*out) { unsigned char *p, *buf; int len; len = ASN1_item_ex_i2d(&val, NULL, it, -1, flags); if (len <= 0) return len; buf = malloc(len); if (!buf) return -1; p = buf; ASN1_item_ex_i2d(&val, &p, it, -1, flags); *out = buf; return len; } return ASN1_item_ex_i2d(&val, out, it, -1, flags); } /* Encode an item, taking care of IMPLICIT tagging (if any). * This function performs the normal item handling: it can be * used in external types. */ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass) { const ASN1_TEMPLATE *tt = NULL; unsigned char *p = NULL; int i, seqcontlen, seqlen, ndef = 1; const ASN1_COMPAT_FUNCS *cf; const ASN1_EXTERN_FUNCS *ef; const ASN1_AUX *aux = it->funcs; ASN1_aux_cb *asn1_cb = 0; if ((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval) return 0; if (aux && aux->asn1_cb) asn1_cb = aux->asn1_cb; switch (it->itype) { case ASN1_ITYPE_PRIMITIVE: if (it->templates) return asn1_template_ex_i2d(pval, out, it->templates, tag, aclass); return asn1_i2d_ex_primitive(pval, out, it, tag, aclass); break; case ASN1_ITYPE_MSTRING: return asn1_i2d_ex_primitive(pval, out, it, -1, aclass); case ASN1_ITYPE_CHOICE: if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL)) return 0; i = asn1_get_choice_selector(pval, it); if ((i >= 0) && (i < it->tcount)) { ASN1_VALUE **pchval; const ASN1_TEMPLATE *chtt; chtt = it->templates + i; pchval = asn1_get_field_ptr(pval, chtt); return asn1_template_ex_i2d(pchval, out, chtt, -1, aclass); } /* Fixme: error condition if selector out of range */ if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL)) return 0; break; case ASN1_ITYPE_EXTERN: /* If new style i2d it does all the work */ ef = it->funcs; return ef->asn1_ex_i2d(pval, out, it, tag, aclass); case ASN1_ITYPE_COMPAT: /* old style hackery... */ cf = it->funcs; if (out) p = *out; i = cf->asn1_i2d(*pval, out); /* Fixup for IMPLICIT tag: note this messes up for tags > 30, * but so did the old code. Tags > 30 are very rare anyway. */ if (out && (tag != -1)) *p = aclass | tag | (*p & V_ASN1_CONSTRUCTED); return i; case ASN1_ITYPE_NDEF_SEQUENCE: /* Use indefinite length constructed if requested */ if (aclass & ASN1_TFLG_NDEF) ndef = 2; /* fall through */ case ASN1_ITYPE_SEQUENCE: i = asn1_enc_restore(&seqcontlen, out, pval, it); /* An error occurred */ if (i < 0) return 0; /* We have a valid cached encoding... */ if (i > 0) return seqcontlen; /* Otherwise carry on */ seqcontlen = 0; /* If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL */ if (tag == -1) { tag = V_ASN1_SEQUENCE; /* Retain any other flags in aclass */ aclass = (aclass & ~ASN1_TFLG_TAG_CLASS) | V_ASN1_UNIVERSAL; } if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL)) return 0; /* First work out sequence content length */ for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) { const ASN1_TEMPLATE *seqtt; ASN1_VALUE **pseqval; seqtt = asn1_do_adb(pval, tt, 1); if (!seqtt) return 0; pseqval = asn1_get_field_ptr(pval, seqtt); /* FIXME: check for errors in enhanced version */ seqcontlen += asn1_template_ex_i2d(pseqval, NULL, seqtt, -1, aclass); } seqlen = ASN1_object_size(ndef, seqcontlen, tag); if (!out) return seqlen; /* Output SEQUENCE header */ ASN1_put_object(out, ndef, seqcontlen, tag, aclass); for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) { const ASN1_TEMPLATE *seqtt; ASN1_VALUE **pseqval; seqtt = asn1_do_adb(pval, tt, 1); if (!seqtt) return 0; pseqval = asn1_get_field_ptr(pval, seqtt); /* FIXME: check for errors in enhanced version */ asn1_template_ex_i2d(pseqval, out, seqtt, -1, aclass); } if (ndef == 2) ASN1_put_eoc(out); if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL)) return 0; return seqlen; default: return 0; } return 0; } int ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt) { return asn1_template_ex_i2d(pval, out, tt, -1, 0); } static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt, int tag, int iclass) { int i, ret, flags, ttag, tclass, ndef; flags = tt->flags; /* Work out tag and class to use: tagging may come * either from the template or the arguments, not both * because this would create ambiguity. Additionally * the iclass argument may contain some additional flags * which should be noted and passed down to other levels. */ if (flags & ASN1_TFLG_TAG_MASK) { /* Error if argument and template tagging */ if (tag != -1) /* FIXME: error code here */ return -1; /* Get tagging from template */ ttag = tt->tag; tclass = flags & ASN1_TFLG_TAG_CLASS; } else if (tag != -1) { /* No template tagging, get from arguments */ ttag = tag; tclass = iclass & ASN1_TFLG_TAG_CLASS; } else { ttag = -1; tclass = 0; } /* * Remove any class mask from iflag. */ iclass &= ~ASN1_TFLG_TAG_CLASS; /* At this point 'ttag' contains the outer tag to use, * 'tclass' is the class and iclass is any flags passed * to this function. */ /* if template and arguments require ndef, use it */ if ((flags & ASN1_TFLG_NDEF) && (iclass & ASN1_TFLG_NDEF)) ndef = 2; else ndef = 1; if (flags & ASN1_TFLG_SK_MASK) { /* SET OF, SEQUENCE OF */ STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval; int isset, sktag, skaclass; int skcontlen, sklen; ASN1_VALUE *skitem; if (!*pval) return 0; if (flags & ASN1_TFLG_SET_OF) { isset = 1; /* 2 means we reorder */ if (flags & ASN1_TFLG_SEQUENCE_OF) isset = 2; } else isset = 0; /* Work out inner tag value: if EXPLICIT * or no tagging use underlying type. */ if ((ttag != -1) && !(flags & ASN1_TFLG_EXPTAG)) { sktag = ttag; skaclass = tclass; } else { skaclass = V_ASN1_UNIVERSAL; if (isset) sktag = V_ASN1_SET; else sktag = V_ASN1_SEQUENCE; } /* Determine total length of items */ skcontlen = 0; for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) { skitem = sk_ASN1_VALUE_value(sk, i); skcontlen += ASN1_item_ex_i2d(&skitem, NULL, ASN1_ITEM_ptr(tt->item), -1, iclass); } sklen = ASN1_object_size(ndef, skcontlen, sktag); /* If EXPLICIT need length of surrounding tag */ if (flags & ASN1_TFLG_EXPTAG) ret = ASN1_object_size(ndef, sklen, ttag); else ret = sklen; if (!out) return ret; /* Now encode this lot... */ /* EXPLICIT tag */ if (flags & ASN1_TFLG_EXPTAG) ASN1_put_object(out, ndef, sklen, ttag, tclass); /* SET or SEQUENCE and IMPLICIT tag */ ASN1_put_object(out, ndef, skcontlen, sktag, skaclass); /* And the stuff itself */ asn1_set_seq_out(sk, out, skcontlen, ASN1_ITEM_ptr(tt->item), isset, iclass); if (ndef == 2) { ASN1_put_eoc(out); if (flags & ASN1_TFLG_EXPTAG) ASN1_put_eoc(out); } return ret; } if (flags & ASN1_TFLG_EXPTAG) { /* EXPLICIT tagging */ /* Find length of tagged item */ i = ASN1_item_ex_i2d(pval, NULL, ASN1_ITEM_ptr(tt->item), -1, iclass); if (!i) return 0; /* Find length of EXPLICIT tag */ ret = ASN1_object_size(ndef, i, ttag); if (out) { /* Output tag and item */ ASN1_put_object(out, ndef, i, ttag, tclass); ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item), -1, iclass); if (ndef == 2) ASN1_put_eoc(out); } return ret; } /* Either normal or IMPLICIT tagging: combine class and flags */ return ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item), ttag, tclass | iclass); } /* Temporary structure used to hold DER encoding of items for SET OF */ typedef struct { unsigned char *data; int length; ASN1_VALUE *field; } DER_ENC; static int der_cmp(const void *a, const void *b) { const DER_ENC *d1 = a, *d2 = b; int cmplen, i; cmplen = (d1->length < d2->length) ? d1->length : d2->length; i = memcmp(d1->data, d2->data, cmplen); if (i) return i; return d1->length - d2->length; } /* Output the content octets of SET OF or SEQUENCE OF */ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out, int skcontlen, const ASN1_ITEM *item, int do_sort, int iclass) { int i; ASN1_VALUE *skitem; unsigned char *tmpdat = NULL, *p = NULL; DER_ENC *derlst = NULL, *tder; if (do_sort) { /* Don't need to sort less than 2 items */ if (sk_ASN1_VALUE_num(sk) < 2) do_sort = 0; else { derlst = reallocarray(NULL, sk_ASN1_VALUE_num(sk), sizeof(*derlst)); tmpdat = malloc(skcontlen); if (!derlst || !tmpdat) { free(derlst); free(tmpdat); return 0; } } } /* If not sorting just output each item */ if (!do_sort) { for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) { skitem = sk_ASN1_VALUE_value(sk, i); ASN1_item_ex_i2d(&skitem, out, item, -1, iclass); } return 1; } p = tmpdat; /* Doing sort: build up a list of each member's DER encoding */ for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) { skitem = sk_ASN1_VALUE_value(sk, i); tder->data = p; tder->length = ASN1_item_ex_i2d(&skitem, &p, item, -1, iclass); tder->field = skitem; } /* Now sort them */ qsort(derlst, sk_ASN1_VALUE_num(sk), sizeof(*derlst), der_cmp); /* Output sorted DER encoding */ p = *out; for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) { memcpy(p, tder->data, tder->length); p += tder->length; } *out = p; /* If do_sort is 2 then reorder the STACK */ if (do_sort == 2) { for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) (void)sk_ASN1_VALUE_set(sk, i, tder->field); } free(derlst); free(tmpdat); return 1; } static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass) { int len; int utype; int usetag; int ndef = 0; utype = it->utype; /* Get length of content octets and maybe find * out the underlying type. */ len = asn1_ex_i2c(pval, NULL, &utype, it); /* If SEQUENCE, SET or OTHER then header is * included in pseudo content octets so don't * include tag+length. We need to check here * because the call to asn1_ex_i2c() could change * utype. */ if ((utype == V_ASN1_SEQUENCE) || (utype == V_ASN1_SET) || (utype == V_ASN1_OTHER)) usetag = 0; else usetag = 1; /* -1 means omit type */ if (len == -1) return 0; /* -2 return is special meaning use ndef */ if (len == -2) { ndef = 2; len = 0; } /* If not implicitly tagged get tag from underlying type */ if (tag == -1) tag = utype; /* Output tag+length followed by content octets */ if (out) { if (usetag) ASN1_put_object(out, ndef, len, tag, aclass); asn1_ex_i2c(pval, *out, &utype, it); if (ndef) ASN1_put_eoc(out); else *out += len; } if (usetag) return ASN1_object_size(ndef, len, tag); return len; } /* Produce content octets from a structure */ int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype, const ASN1_ITEM *it) { ASN1_BOOLEAN *tbool = NULL; ASN1_STRING *strtmp; ASN1_OBJECT *otmp; int utype; const unsigned char *cont; unsigned char c; int len; const ASN1_PRIMITIVE_FUNCS *pf; pf = it->funcs; if (pf && pf->prim_i2c) return pf->prim_i2c(pval, cout, putype, it); /* Should type be omitted? */ if ((it->itype != ASN1_ITYPE_PRIMITIVE) || (it->utype != V_ASN1_BOOLEAN)) { if (!*pval) return -1; } if (it->itype == ASN1_ITYPE_MSTRING) { /* If MSTRING type set the underlying type */ strtmp = (ASN1_STRING *)*pval; utype = strtmp->type; *putype = utype; } else if (it->utype == V_ASN1_ANY) { /* If ANY set type and pointer to value */ ASN1_TYPE *typ; typ = (ASN1_TYPE *)*pval; utype = typ->type; *putype = utype; pval = &typ->value.asn1_value; } else utype = *putype; switch (utype) { case V_ASN1_OBJECT: otmp = (ASN1_OBJECT *)*pval; cont = otmp->data; len = otmp->length; break; case V_ASN1_NULL: cont = NULL; len = 0; break; case V_ASN1_BOOLEAN: tbool = (ASN1_BOOLEAN *)pval; if (*tbool == -1) return -1; if (it->utype != V_ASN1_ANY) { /* Default handling if value == size field then omit */ if (*tbool && (it->size > 0)) return -1; if (!*tbool && !it->size) return -1; } c = (unsigned char)*tbool; cont = &c; len = 1; break; case V_ASN1_BIT_STRING: return i2c_ASN1_BIT_STRING((ASN1_BIT_STRING *)*pval, cout ? &cout : NULL); break; case V_ASN1_INTEGER: case V_ASN1_NEG_INTEGER: case V_ASN1_ENUMERATED: case V_ASN1_NEG_ENUMERATED: /* These are all have the same content format * as ASN1_INTEGER */ return i2c_ASN1_INTEGER((ASN1_INTEGER *)*pval, cout ? &cout : NULL); break; case V_ASN1_OCTET_STRING: case V_ASN1_NUMERICSTRING: case V_ASN1_PRINTABLESTRING: case V_ASN1_T61STRING: case V_ASN1_VIDEOTEXSTRING: case V_ASN1_IA5STRING: case V_ASN1_UTCTIME: case V_ASN1_GENERALIZEDTIME: case V_ASN1_GRAPHICSTRING: case V_ASN1_VISIBLESTRING: case V_ASN1_GENERALSTRING: case V_ASN1_UNIVERSALSTRING: case V_ASN1_BMPSTRING: case V_ASN1_UTF8STRING: case V_ASN1_SEQUENCE: case V_ASN1_SET: default: /* All based on ASN1_STRING and handled the same */ strtmp = (ASN1_STRING *)*pval; /* Special handling for NDEF */ if ((it->size == ASN1_TFLG_NDEF) && (strtmp->flags & ASN1_STRING_FLAG_NDEF)) { if (cout) { strtmp->data = cout; strtmp->length = 0; } /* Special return code */ return -2; } cont = strtmp->data; len = strtmp->length; break; } if (cout && len) memcpy(cout, cont, len); return len; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/tasn_typ.c0000644000175000017500000001266112360020705021130 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include /* Declarations for string types */ IMPLEMENT_ASN1_TYPE(ASN1_INTEGER) IMPLEMENT_ASN1_FUNCTIONS(ASN1_INTEGER) IMPLEMENT_ASN1_TYPE(ASN1_ENUMERATED) IMPLEMENT_ASN1_FUNCTIONS(ASN1_ENUMERATED) IMPLEMENT_ASN1_TYPE(ASN1_BIT_STRING) IMPLEMENT_ASN1_FUNCTIONS(ASN1_BIT_STRING) IMPLEMENT_ASN1_TYPE(ASN1_OCTET_STRING) IMPLEMENT_ASN1_FUNCTIONS(ASN1_OCTET_STRING) IMPLEMENT_ASN1_TYPE(ASN1_NULL) IMPLEMENT_ASN1_FUNCTIONS(ASN1_NULL) IMPLEMENT_ASN1_TYPE(ASN1_OBJECT) IMPLEMENT_ASN1_TYPE(ASN1_UTF8STRING) IMPLEMENT_ASN1_FUNCTIONS(ASN1_UTF8STRING) IMPLEMENT_ASN1_TYPE(ASN1_PRINTABLESTRING) IMPLEMENT_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING) IMPLEMENT_ASN1_TYPE(ASN1_T61STRING) IMPLEMENT_ASN1_FUNCTIONS(ASN1_T61STRING) IMPLEMENT_ASN1_TYPE(ASN1_IA5STRING) IMPLEMENT_ASN1_FUNCTIONS(ASN1_IA5STRING) IMPLEMENT_ASN1_TYPE(ASN1_GENERALSTRING) IMPLEMENT_ASN1_FUNCTIONS(ASN1_GENERALSTRING) IMPLEMENT_ASN1_TYPE(ASN1_UTCTIME) IMPLEMENT_ASN1_FUNCTIONS(ASN1_UTCTIME) IMPLEMENT_ASN1_TYPE(ASN1_GENERALIZEDTIME) IMPLEMENT_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME) IMPLEMENT_ASN1_TYPE(ASN1_VISIBLESTRING) IMPLEMENT_ASN1_FUNCTIONS(ASN1_VISIBLESTRING) IMPLEMENT_ASN1_TYPE(ASN1_UNIVERSALSTRING) IMPLEMENT_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING) IMPLEMENT_ASN1_TYPE(ASN1_BMPSTRING) IMPLEMENT_ASN1_FUNCTIONS(ASN1_BMPSTRING) IMPLEMENT_ASN1_TYPE(ASN1_ANY) /* Just swallow an ASN1_SEQUENCE in an ASN1_STRING */ IMPLEMENT_ASN1_TYPE(ASN1_SEQUENCE) IMPLEMENT_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE) /* Multistring types */ IMPLEMENT_ASN1_MSTRING(ASN1_PRINTABLE, B_ASN1_PRINTABLE) IMPLEMENT_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE) IMPLEMENT_ASN1_MSTRING(DISPLAYTEXT, B_ASN1_DISPLAYTEXT) IMPLEMENT_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT) IMPLEMENT_ASN1_MSTRING(DIRECTORYSTRING, B_ASN1_DIRECTORYSTRING) IMPLEMENT_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING) /* Three separate BOOLEAN type: normal, DEFAULT TRUE and DEFAULT FALSE */ IMPLEMENT_ASN1_TYPE_ex(ASN1_BOOLEAN, ASN1_BOOLEAN, -1) IMPLEMENT_ASN1_TYPE_ex(ASN1_TBOOLEAN, ASN1_BOOLEAN, 1) IMPLEMENT_ASN1_TYPE_ex(ASN1_FBOOLEAN, ASN1_BOOLEAN, 0) /* Special, OCTET STRING with indefinite length constructed support */ IMPLEMENT_ASN1_TYPE_ex(ASN1_OCTET_STRING_NDEF, ASN1_OCTET_STRING, ASN1_TFLG_NDEF) ASN1_ITEM_TEMPLATE(ASN1_SEQUENCE_ANY) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, ASN1_SEQUENCE_ANY, ASN1_ANY) ASN1_ITEM_TEMPLATE_END(ASN1_SEQUENCE_ANY) ASN1_ITEM_TEMPLATE(ASN1_SET_ANY) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SET_OF, 0, ASN1_SET_ANY, ASN1_ANY) ASN1_ITEM_TEMPLATE_END(ASN1_SET_ANY) IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY) IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(ASN1_SEQUENCE_ANY, ASN1_SET_ANY, ASN1_SET_ANY) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_crl.c0000644000175000017500000003420312360020705020372 0ustar /* $OpenBSD: x_crl.c,v 1.17 2014/07/11 08:44:47 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include "asn1_locl.h" static int X509_REVOKED_cmp(const X509_REVOKED * const *a, const X509_REVOKED * const *b); static void setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp); ASN1_SEQUENCE(X509_REVOKED) = { ASN1_SIMPLE(X509_REVOKED, serialNumber, ASN1_INTEGER), ASN1_SIMPLE(X509_REVOKED, revocationDate, ASN1_TIME), ASN1_SEQUENCE_OF_OPT(X509_REVOKED, extensions, X509_EXTENSION) } ASN1_SEQUENCE_END(X509_REVOKED) static int def_crl_verify(X509_CRL *crl, EVP_PKEY *r); static int def_crl_lookup(X509_CRL *crl, X509_REVOKED **ret, ASN1_INTEGER *serial, X509_NAME *issuer); static X509_CRL_METHOD int_crl_meth = { .crl_lookup = def_crl_lookup, .crl_verify = def_crl_verify }; static const X509_CRL_METHOD *default_crl_method = &int_crl_meth; /* The X509_CRL_INFO structure needs a bit of customisation. * Since we cache the original encoding the signature wont be affected by * reordering of the revoked field. */ static int crl_inf_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { X509_CRL_INFO *a = (X509_CRL_INFO *)*pval; if (!a || !a->revoked) return 1; switch (operation) { /* Just set cmp function here. We don't sort because that * would affect the output of X509_CRL_print(). */ case ASN1_OP_D2I_POST: (void)sk_X509_REVOKED_set_cmp_func(a->revoked, X509_REVOKED_cmp); break; } return 1; } ASN1_SEQUENCE_enc(X509_CRL_INFO, enc, crl_inf_cb) = { ASN1_OPT(X509_CRL_INFO, version, ASN1_INTEGER), ASN1_SIMPLE(X509_CRL_INFO, sig_alg, X509_ALGOR), ASN1_SIMPLE(X509_CRL_INFO, issuer, X509_NAME), ASN1_SIMPLE(X509_CRL_INFO, lastUpdate, ASN1_TIME), ASN1_OPT(X509_CRL_INFO, nextUpdate, ASN1_TIME), ASN1_SEQUENCE_OF_OPT(X509_CRL_INFO, revoked, X509_REVOKED), ASN1_EXP_SEQUENCE_OF_OPT(X509_CRL_INFO, extensions, X509_EXTENSION, 0) } ASN1_SEQUENCE_END_enc(X509_CRL_INFO, X509_CRL_INFO) /* Set CRL entry issuer according to CRL certificate issuer extension. * Check for unhandled critical CRL entry extensions. */ static int crl_set_issuers(X509_CRL *crl) { int i, j; GENERAL_NAMES *gens, *gtmp; STACK_OF(X509_REVOKED) *revoked; revoked = X509_CRL_get_REVOKED(crl); gens = NULL; for (i = 0; i < sk_X509_REVOKED_num(revoked); i++) { X509_REVOKED *rev = sk_X509_REVOKED_value(revoked, i); STACK_OF(X509_EXTENSION) *exts; ASN1_ENUMERATED *reason; X509_EXTENSION *ext; gtmp = X509_REVOKED_get_ext_d2i(rev, NID_certificate_issuer, &j, NULL); if (!gtmp && (j != -1)) { crl->flags |= EXFLAG_INVALID; return 1; } if (gtmp) { gens = gtmp; if (!crl->issuers) { crl->issuers = sk_GENERAL_NAMES_new_null(); if (!crl->issuers) return 0; } if (!sk_GENERAL_NAMES_push(crl->issuers, gtmp)) return 0; } rev->issuer = gens; reason = X509_REVOKED_get_ext_d2i(rev, NID_crl_reason, &j, NULL); if (!reason && (j != -1)) { crl->flags |= EXFLAG_INVALID; return 1; } if (reason) { rev->reason = ASN1_ENUMERATED_get(reason); ASN1_ENUMERATED_free(reason); } else rev->reason = CRL_REASON_NONE; /* Check for critical CRL entry extensions */ exts = rev->extensions; for (j = 0; j < sk_X509_EXTENSION_num(exts); j++) { ext = sk_X509_EXTENSION_value(exts, j); if (ext->critical > 0) { if (OBJ_obj2nid(ext->object) == NID_certificate_issuer) continue; crl->flags |= EXFLAG_CRITICAL; break; } } } return 1; } /* The X509_CRL structure needs a bit of customisation. Cache some extensions * and hash of the whole CRL. */ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { X509_CRL *crl = (X509_CRL *)*pval; STACK_OF(X509_EXTENSION) *exts; X509_EXTENSION *ext; int idx; switch (operation) { case ASN1_OP_NEW_POST: crl->idp = NULL; crl->akid = NULL; crl->flags = 0; crl->idp_flags = 0; crl->idp_reasons = CRLDP_ALL_REASONS; crl->meth = default_crl_method; crl->meth_data = NULL; crl->issuers = NULL; crl->crl_number = NULL; crl->base_crl_number = NULL; break; case ASN1_OP_D2I_POST: #ifndef OPENSSL_NO_SHA X509_CRL_digest(crl, EVP_sha1(), crl->sha1_hash, NULL); #endif crl->idp = X509_CRL_get_ext_d2i(crl, NID_issuing_distribution_point, NULL, NULL); if (crl->idp) setup_idp(crl, crl->idp); crl->akid = X509_CRL_get_ext_d2i(crl, NID_authority_key_identifier, NULL, NULL); crl->crl_number = X509_CRL_get_ext_d2i(crl, NID_crl_number, NULL, NULL); crl->base_crl_number = X509_CRL_get_ext_d2i(crl, NID_delta_crl, NULL, NULL); /* Delta CRLs must have CRL number */ if (crl->base_crl_number && !crl->crl_number) crl->flags |= EXFLAG_INVALID; /* See if we have any unhandled critical CRL extensions and * indicate this in a flag. We only currently handle IDP, * AKID and deltas, so anything else critical sets the flag. * * This code accesses the X509_CRL structure directly: * applications shouldn't do this. */ exts = crl->crl->extensions; for (idx = 0; idx < sk_X509_EXTENSION_num(exts); idx++) { int nid; ext = sk_X509_EXTENSION_value(exts, idx); nid = OBJ_obj2nid(ext->object); if (nid == NID_freshest_crl) crl->flags |= EXFLAG_FRESHEST; if (ext->critical > 0) { /* We handle IDP, AKID and deltas */ if (nid == NID_issuing_distribution_point || nid == NID_authority_key_identifier || nid == NID_delta_crl) break; crl->flags |= EXFLAG_CRITICAL; break; } } if (!crl_set_issuers(crl)) return 0; if (crl->meth->crl_init) { if (crl->meth->crl_init(crl) == 0) return 0; } break; case ASN1_OP_FREE_POST: if (crl->meth->crl_free) { if (!crl->meth->crl_free(crl)) return 0; } if (crl->akid) AUTHORITY_KEYID_free(crl->akid); if (crl->idp) ISSUING_DIST_POINT_free(crl->idp); ASN1_INTEGER_free(crl->crl_number); ASN1_INTEGER_free(crl->base_crl_number); sk_GENERAL_NAMES_pop_free(crl->issuers, GENERAL_NAMES_free); break; } return 1; } /* Convert IDP into a more convenient form */ static void setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp) { int idp_only = 0; /* Set various flags according to IDP */ crl->idp_flags |= IDP_PRESENT; if (idp->onlyuser > 0) { idp_only++; crl->idp_flags |= IDP_ONLYUSER; } if (idp->onlyCA > 0) { idp_only++; crl->idp_flags |= IDP_ONLYCA; } if (idp->onlyattr > 0) { idp_only++; crl->idp_flags |= IDP_ONLYATTR; } if (idp_only > 1) crl->idp_flags |= IDP_INVALID; if (idp->indirectCRL > 0) crl->idp_flags |= IDP_INDIRECT; if (idp->onlysomereasons) { crl->idp_flags |= IDP_REASONS; if (idp->onlysomereasons->length > 0) crl->idp_reasons = idp->onlysomereasons->data[0]; if (idp->onlysomereasons->length > 1) crl->idp_reasons |= (idp->onlysomereasons->data[1] << 8); crl->idp_reasons &= CRLDP_ALL_REASONS; } DIST_POINT_set_dpname(idp->distpoint, X509_CRL_get_issuer(crl)); } ASN1_SEQUENCE_ref(X509_CRL, crl_cb, CRYPTO_LOCK_X509_CRL) = { ASN1_SIMPLE(X509_CRL, crl, X509_CRL_INFO), ASN1_SIMPLE(X509_CRL, sig_alg, X509_ALGOR), ASN1_SIMPLE(X509_CRL, signature, ASN1_BIT_STRING) } ASN1_SEQUENCE_END_ref(X509_CRL, X509_CRL) IMPLEMENT_ASN1_FUNCTIONS(X509_REVOKED) IMPLEMENT_ASN1_FUNCTIONS(X509_CRL_INFO) IMPLEMENT_ASN1_FUNCTIONS(X509_CRL) IMPLEMENT_ASN1_DUP_FUNCTION(X509_CRL) static int X509_REVOKED_cmp(const X509_REVOKED * const *a, const X509_REVOKED * const *b) { return(ASN1_STRING_cmp( (ASN1_STRING *)(*a)->serialNumber, (ASN1_STRING *)(*b)->serialNumber)); } int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev) { X509_CRL_INFO *inf; inf = crl->crl; if (!inf->revoked) inf->revoked = sk_X509_REVOKED_new(X509_REVOKED_cmp); if (!inf->revoked || !sk_X509_REVOKED_push(inf->revoked, rev)) { ASN1err(ASN1_F_X509_CRL_ADD0_REVOKED, ERR_R_MALLOC_FAILURE); return 0; } inf->enc.modified = 1; return 1; } int X509_CRL_verify(X509_CRL *crl, EVP_PKEY *r) { if (crl->meth->crl_verify) return crl->meth->crl_verify(crl, r); return 0; } int X509_CRL_get0_by_serial(X509_CRL *crl, X509_REVOKED **ret, ASN1_INTEGER *serial) { if (crl->meth->crl_lookup) return crl->meth->crl_lookup(crl, ret, serial, NULL); return 0; } int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x) { if (crl->meth->crl_lookup) return crl->meth->crl_lookup(crl, ret, X509_get_serialNumber(x), X509_get_issuer_name(x)); return 0; } static int def_crl_verify(X509_CRL *crl, EVP_PKEY *r) { return(ASN1_item_verify(ASN1_ITEM_rptr(X509_CRL_INFO), crl->sig_alg, crl->signature, crl->crl, r)); } static int crl_revoked_issuer_match(X509_CRL *crl, X509_NAME *nm, X509_REVOKED *rev) { int i; if (!rev->issuer) { if (!nm) return 1; if (!X509_NAME_cmp(nm, X509_CRL_get_issuer(crl))) return 1; return 0; } if (!nm) nm = X509_CRL_get_issuer(crl); for (i = 0; i < sk_GENERAL_NAME_num(rev->issuer); i++) { GENERAL_NAME *gen = sk_GENERAL_NAME_value(rev->issuer, i); if (gen->type != GEN_DIRNAME) continue; if (!X509_NAME_cmp(nm, gen->d.directoryName)) return 1; } return 0; } static int def_crl_lookup(X509_CRL *crl, X509_REVOKED **ret, ASN1_INTEGER *serial, X509_NAME *issuer) { X509_REVOKED rtmp, *rev; int idx; rtmp.serialNumber = serial; /* Sort revoked into serial number order if not already sorted. * Do this under a lock to avoid race condition. */ if (!sk_X509_REVOKED_is_sorted(crl->crl->revoked)) { CRYPTO_w_lock(CRYPTO_LOCK_X509_CRL); sk_X509_REVOKED_sort(crl->crl->revoked); CRYPTO_w_unlock(CRYPTO_LOCK_X509_CRL); } idx = sk_X509_REVOKED_find(crl->crl->revoked, &rtmp); if (idx < 0) return 0; /* Need to look for matching name */ for (; idx < sk_X509_REVOKED_num(crl->crl->revoked); idx++) { rev = sk_X509_REVOKED_value(crl->crl->revoked, idx); if (ASN1_INTEGER_cmp(rev->serialNumber, serial)) return 0; if (crl_revoked_issuer_match(crl, issuer, rev)) { if (ret) *ret = rev; if (rev->reason == CRL_REASON_REMOVE_FROM_CRL) return 2; return 1; } } return 0; } void X509_CRL_set_default_method(const X509_CRL_METHOD *meth) { if (meth == NULL) default_crl_method = &int_crl_meth; else default_crl_method = meth; } X509_CRL_METHOD * X509_CRL_METHOD_new(int (*crl_init)(X509_CRL *crl), int (*crl_free)(X509_CRL *crl), int (*crl_lookup)(X509_CRL *crl, X509_REVOKED **ret, ASN1_INTEGER *ser, X509_NAME *issuer), int (*crl_verify)(X509_CRL *crl, EVP_PKEY *pk)) { X509_CRL_METHOD *m; m = malloc(sizeof(X509_CRL_METHOD)); if (!m) return NULL; m->crl_init = crl_init; m->crl_free = crl_free; m->crl_lookup = crl_lookup; m->crl_verify = crl_verify; m->flags = X509_CRL_METHOD_DYNAMIC; return m; } void X509_CRL_METHOD_free(X509_CRL_METHOD *m) { if (!(m->flags & X509_CRL_METHOD_DYNAMIC)) return; free(m); } void X509_CRL_set_meth_data(X509_CRL *crl, void *dat) { crl->meth_data = dat; } void * X509_CRL_get_meth_data(X509_CRL *crl) { return crl->meth_data; } IMPLEMENT_STACK_OF(X509_REVOKED) IMPLEMENT_ASN1_SET_OF(X509_REVOKED) IMPLEMENT_STACK_OF(X509_CRL) IMPLEMENT_ASN1_SET_OF(X509_CRL) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/f_string.c0000644000175000017500000001326712360020705021105 0ustar /* $OpenBSD: f_string.c,v 1.15 2014/07/10 21:58:08 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type) { int i, n = 0; static const char h[] = "0123456789ABCDEF"; char buf[2]; if (a == NULL) return (0); if (a->length == 0) { if (BIO_write(bp, "0", 1) != 1) goto err; n = 1; } else { for (i = 0; i < a->length; i++) { if ((i != 0) && (i % 35 == 0)) { if (BIO_write(bp, "\\\n", 2) != 2) goto err; n += 2; } buf[0] = h[((unsigned char)a->data[i] >> 4) & 0x0f]; buf[1] = h[((unsigned char)a->data[i]) & 0x0f]; if (BIO_write(bp, buf, 2) != 2) goto err; n += 2; } } return (n); err: return (-1); } int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size) { int ret = 0; int i, j, k, m, n, again, bufsize; unsigned char *s = NULL, *sp; unsigned char *bufp; int first = 1; size_t num = 0, slen = 0; bufsize = BIO_gets(bp, buf, size); for (;;) { if (bufsize < 1) { if (first) break; else goto err_sl; } first = 0; i = bufsize; if (buf[i-1] == '\n') buf[--i] = '\0'; if (i == 0) goto err_sl; if (buf[i-1] == '\r') buf[--i] = '\0'; if (i == 0) goto err_sl; again = (buf[i - 1] == '\\'); for (j = i - 1; j > 0; j--) { if (!(((buf[j] >= '0') && (buf[j] <= '9')) || ((buf[j] >= 'a') && (buf[j] <= 'f')) || ((buf[j] >= 'A') && (buf[j] <= 'F')))) { i = j; break; } } buf[i] = '\0'; /* We have now cleared all the crap off the end of the * line */ if (i < 2) goto err_sl; bufp = (unsigned char *)buf; k = 0; i -= again; if (i % 2 != 0) { ASN1err(ASN1_F_A2I_ASN1_STRING, ASN1_R_ODD_NUMBER_OF_CHARS); goto err; } i /= 2; if (num + i > slen) { sp = realloc(s, num + i); if (sp == NULL) { ASN1err(ASN1_F_A2I_ASN1_STRING, ERR_R_MALLOC_FAILURE); goto err; } s = sp; slen = num + i; } for (j = 0; j < i; j++, k += 2) { for (n = 0; n < 2; n++) { m = bufp[k + n]; if ((m >= '0') && (m <= '9')) m -= '0'; else if ((m >= 'a') && (m <= 'f')) m = m - 'a' + 10; else if ((m >= 'A') && (m <= 'F')) m = m - 'A' + 10; else { ASN1err(ASN1_F_A2I_ASN1_STRING, ASN1_R_NON_HEX_CHARACTERS); goto err; } s[num + j] <<= 4; s[num + j] |= m; } } num += i; if (again) bufsize = BIO_gets(bp, buf, size); else break; } bs->length = num; bs->data = s; return (1); err_sl: ASN1err(ASN1_F_A2I_ASN1_STRING, ASN1_R_SHORT_LINE); err: free(s); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/asn_moid.c0000644000175000017500000001103012360020705021045 0ustar /* $OpenBSD: asn_moid.c,v 1.11 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 2001-2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include /* Simple ASN1 OID module: add all objects in a given section */ static int do_create(char *value, char *name); static int oid_module_init(CONF_IMODULE *md, const CONF *cnf) { int i; const char *oid_section; STACK_OF(CONF_VALUE) *sktmp; CONF_VALUE *oval; oid_section = CONF_imodule_get_value(md); if (!(sktmp = NCONF_get_section(cnf, oid_section))) { ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ERROR_LOADING_SECTION); return 0; } for (i = 0; i < sk_CONF_VALUE_num(sktmp); i++) { oval = sk_CONF_VALUE_value(sktmp, i); if (!do_create(oval->value, oval->name)) { ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ADDING_OBJECT); return 0; } } return 1; } static void oid_module_finish(CONF_IMODULE *md) { OBJ_cleanup(); } void ASN1_add_oid_module(void) { CONF_module_add("oid_section", oid_module_init, oid_module_finish); } /* Create an OID based on a name value pair. Accept two formats. * shortname = 1.2.3.4 * shortname = some long name, 1.2.3.4 */ static int do_create(char *value, char *name) { int nid; ASN1_OBJECT *oid; char *ln, *ostr, *p, *lntmp; p = strrchr(value, ','); if (!p) { ln = name; ostr = value; } else { ln = NULL; ostr = p + 1; if (!*ostr) return 0; while (isspace((unsigned char)*ostr)) ostr++; } nid = OBJ_create(ostr, name, ln); if (nid == NID_undef) return 0; if (p) { ln = value; while (isspace((unsigned char)*ln)) ln++; p--; while (isspace((unsigned char)*p)) { if (p == ln) return 0; p--; } p++; lntmp = malloc((p - ln) + 1); if (lntmp == NULL) return 0; memcpy(lntmp, ln, p - ln); lntmp[p - ln] = 0; oid = OBJ_nid2obj(nid); oid->ln = lntmp; } return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/x_attrib.c0000644000175000017500000001151212360020705021075 0ustar /* $OpenBSD: x_attrib.c,v 1.8 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include /* X509_ATTRIBUTE: this has the following form: * * typedef struct x509_attributes_st * { * ASN1_OBJECT *object; * int single; * union { * char *ptr; * STACK_OF(ASN1_TYPE) *set; * ASN1_TYPE *single; * } value; * } X509_ATTRIBUTE; * * this needs some extra thought because the CHOICE type is * merged with the main structure and because the value can * be anything at all we *must* try the SET OF first because * the ASN1_ANY type will swallow anything including the whole * SET OF structure. */ ASN1_CHOICE(X509_ATTRIBUTE_SET) = { ASN1_SET_OF(X509_ATTRIBUTE, value.set, ASN1_ANY), ASN1_SIMPLE(X509_ATTRIBUTE, value.single, ASN1_ANY) } ASN1_CHOICE_END_selector(X509_ATTRIBUTE, X509_ATTRIBUTE_SET, single) ASN1_SEQUENCE(X509_ATTRIBUTE) = { ASN1_SIMPLE(X509_ATTRIBUTE, object, ASN1_OBJECT), /* CHOICE type merged with parent */ ASN1_EX_COMBINE(0, 0, X509_ATTRIBUTE_SET) } ASN1_SEQUENCE_END(X509_ATTRIBUTE) IMPLEMENT_ASN1_FUNCTIONS(X509_ATTRIBUTE) IMPLEMENT_ASN1_DUP_FUNCTION(X509_ATTRIBUTE) X509_ATTRIBUTE * X509_ATTRIBUTE_create(int nid, int atrtype, void *value) { X509_ATTRIBUTE *ret = NULL; ASN1_TYPE *val = NULL; if ((ret = X509_ATTRIBUTE_new()) == NULL) return (NULL); ret->object = OBJ_nid2obj(nid); ret->single = 0; if ((ret->value.set = sk_ASN1_TYPE_new_null()) == NULL) goto err; if ((val = ASN1_TYPE_new()) == NULL) goto err; if (!sk_ASN1_TYPE_push(ret->value.set, val)) goto err; ASN1_TYPE_set(val, atrtype, value); return (ret); err: if (ret != NULL) X509_ATTRIBUTE_free(ret); if (val != NULL) ASN1_TYPE_free(val); return (NULL); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/t_x509a.c0000644000175000017500000001021312360020705020447 0ustar /* $OpenBSD: t_x509a.c,v 1.7 2014/06/12 15:49:27 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include /* X509_CERT_AUX and string set routines */ int X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent) { char oidstr[80], first; int i; if (!aux) return 1; if (aux->trust) { first = 1; BIO_printf(out, "%*sTrusted Uses:\n%*s", indent, "", indent + 2, ""); for (i = 0; i < sk_ASN1_OBJECT_num(aux->trust); i++) { if (!first) BIO_puts(out, ", "); else first = 0; OBJ_obj2txt(oidstr, sizeof oidstr, sk_ASN1_OBJECT_value(aux->trust, i), 0); BIO_puts(out, oidstr); } BIO_puts(out, "\n"); } else BIO_printf(out, "%*sNo Trusted Uses.\n", indent, ""); if (aux->reject) { first = 1; BIO_printf(out, "%*sRejected Uses:\n%*s", indent, "", indent + 2, ""); for (i = 0; i < sk_ASN1_OBJECT_num(aux->reject); i++) { if (!first) BIO_puts(out, ", "); else first = 0; OBJ_obj2txt(oidstr, sizeof oidstr, sk_ASN1_OBJECT_value(aux->reject, i), 0); BIO_puts(out, oidstr); } BIO_puts(out, "\n"); } else BIO_printf(out, "%*sNo Rejected Uses.\n", indent, ""); if (aux->alias) BIO_printf(out, "%*sAlias: %s\n", indent, "", aux->alias->data); if (aux->keyid) { BIO_printf(out, "%*sKey Id: ", indent, ""); for (i = 0; i < aux->keyid->length; i++) BIO_printf(out, "%s%02X", i ? ":" : "", aux->keyid->data[i]); BIO_write(out, "\n", 1); } return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/t_req.c0000644000175000017500000001775612360020705020413 0ustar /* $OpenBSD: t_req.c,v 1.16 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_DSA #include #endif #ifndef OPENSSL_NO_RSA #include #endif int X509_REQ_print_fp(FILE *fp, X509_REQ *x) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { X509err(X509_F_X509_REQ_PRINT_FP, ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, fp, BIO_NOCLOSE); ret = X509_REQ_print(b, x); BIO_free(b); return (ret); } int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long cflag) { unsigned long l; int i; const char *neg; X509_REQ_INFO *ri; EVP_PKEY *pkey; STACK_OF(X509_ATTRIBUTE) *sk; STACK_OF(X509_EXTENSION) *exts; char mlch = ' '; int nmindent = 0; if ((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { mlch = '\n'; nmindent = 12; } if (nmflags == X509_FLAG_COMPAT) nmindent = 16; ri = x->req_info; if (!(cflag & X509_FLAG_NO_HEADER)) { if (BIO_write(bp, "Certificate Request:\n", 21) <= 0) goto err; if (BIO_write(bp, " Data:\n", 10) <= 0) goto err; } if (!(cflag & X509_FLAG_NO_VERSION)) { neg = (ri->version->type == V_ASN1_NEG_INTEGER) ? "-" : ""; l = 0; for (i = 0; i < ri->version->length; i++) { l <<= 8; l += ri->version->data[i]; } if (BIO_printf(bp, "%8sVersion: %s%lu (%s0x%lx)\n", "", neg, l, neg, l) <= 0) goto err; } if (!(cflag & X509_FLAG_NO_SUBJECT)) { if (BIO_printf(bp, " Subject:%c", mlch) <= 0) goto err; if (X509_NAME_print_ex(bp, ri->subject, nmindent, nmflags) < 0) goto err; if (BIO_write(bp, "\n", 1) <= 0) goto err; } if (!(cflag & X509_FLAG_NO_PUBKEY)) { if (BIO_write(bp, " Subject Public Key Info:\n", 33) <= 0) goto err; if (BIO_printf(bp, "%12sPublic Key Algorithm: ", "") <= 0) goto err; if (i2a_ASN1_OBJECT(bp, ri->pubkey->algor->algorithm) <= 0) goto err; if (BIO_puts(bp, "\n") <= 0) goto err; pkey = X509_REQ_get_pubkey(x); if (pkey == NULL) { BIO_printf(bp, "%12sUnable to load Public Key\n", ""); ERR_print_errors(bp); } else { EVP_PKEY_print_public(bp, pkey, 16, NULL); EVP_PKEY_free(pkey); } } if (!(cflag & X509_FLAG_NO_ATTRIBUTES)) { /* may not be */ if (BIO_printf(bp, "%8sAttributes:\n", "") <= 0) goto err; sk = x->req_info->attributes; if (sk_X509_ATTRIBUTE_num(sk) == 0) { if (BIO_printf(bp, "%12sa0:00\n", "") <= 0) goto err; } else { for (i = 0; i < sk_X509_ATTRIBUTE_num(sk); i++) { ASN1_TYPE *at; X509_ATTRIBUTE *a; ASN1_BIT_STRING *bs = NULL; ASN1_TYPE *t; int j, type = 0, count = 1, ii = 0; a = sk_X509_ATTRIBUTE_value(sk, i); if (X509_REQ_extension_nid( OBJ_obj2nid(a->object))) continue; if (BIO_printf(bp, "%12s", "") <= 0) goto err; if ((j = i2a_ASN1_OBJECT(bp, a->object)) > 0) { if (a->single) { t = a->value.single; type = t->type; bs = t->value.bit_string; } else { ii = 0; count = sk_ASN1_TYPE_num( a->value.set); get_next: at = sk_ASN1_TYPE_value( a->value.set, ii); type = at->type; bs = at->value.asn1_string; } } for (j = 25 - j; j > 0; j--) if (BIO_write(bp, " ", 1) != 1) goto err; if (BIO_puts(bp, ":") <= 0) goto err; if ((type == V_ASN1_PRINTABLESTRING) || (type == V_ASN1_T61STRING) || (type == V_ASN1_IA5STRING)) { if (BIO_write(bp, (char *)bs->data, bs->length) != bs->length) goto err; BIO_puts(bp, "\n"); } else { BIO_puts(bp, "unable to print attribute\n"); } if (++ii < count) goto get_next; } } } if (!(cflag & X509_FLAG_NO_EXTENSIONS)) { exts = X509_REQ_get_extensions(x); if (exts) { BIO_printf(bp, "%8sRequested Extensions:\n", ""); for (i = 0; i < sk_X509_EXTENSION_num(exts); i++) { ASN1_OBJECT *obj; X509_EXTENSION *ex; int j; ex = sk_X509_EXTENSION_value(exts, i); if (BIO_printf(bp, "%12s", "") <= 0) goto err; obj = X509_EXTENSION_get_object(ex); i2a_ASN1_OBJECT(bp, obj); j = X509_EXTENSION_get_critical(ex); if (BIO_printf(bp, ": %s\n", j ? "critical" : "") <= 0) goto err; if (!X509V3_EXT_print(bp, ex, cflag, 16)) { BIO_printf(bp, "%16s", ""); M_ASN1_OCTET_STRING_print(bp, ex->value); } if (BIO_write(bp, "\n", 1) <= 0) goto err; } sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free); } } if (!(cflag & X509_FLAG_NO_SIGDUMP)) { if (!X509_signature_print(bp, x->sig_alg, x->signature)) goto err; } return (1); err: X509err(X509_F_X509_REQ_PRINT_EX, ERR_R_BUF_LIB); return (0); } int X509_REQ_print(BIO *bp, X509_REQ *x) { return X509_REQ_print_ex(bp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/d2i_pu.c0000644000175000017500000001127212360020705020446 0ustar /* $OpenBSD: d2i_pu.c,v 1.11 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #ifndef OPENSSL_NO_DSA #include #endif #ifndef OPENSSL_NO_EC #include #endif #ifndef OPENSSL_NO_RSA #include #endif EVP_PKEY * d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp, long length) { EVP_PKEY *ret; if ((a == NULL) || (*a == NULL)) { if ((ret = EVP_PKEY_new()) == NULL) { ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_EVP_LIB); return (NULL); } } else ret = *a; if (!EVP_PKEY_set_type(ret, type)) { ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_EVP_LIB); goto err; } switch (EVP_PKEY_id(ret)) { #ifndef OPENSSL_NO_RSA case EVP_PKEY_RSA: if ((ret->pkey.rsa = d2i_RSAPublicKey(NULL, pp, length)) == NULL) { ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_ASN1_LIB); goto err; } break; #endif #ifndef OPENSSL_NO_DSA case EVP_PKEY_DSA: if (!d2i_DSAPublicKey(&(ret->pkey.dsa), pp, length)) { ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_ASN1_LIB); goto err; } break; #endif #ifndef OPENSSL_NO_EC case EVP_PKEY_EC: if (!o2i_ECPublicKey(&(ret->pkey.ec), pp, length)) { ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_ASN1_LIB); goto err; } break; #endif default: ASN1err(ASN1_F_D2I_PUBLICKEY, ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE); goto err; /* break; */ } if (a != NULL) (*a) = ret; return (ret); err: if ((ret != NULL) && ((a == NULL) || (*a != ret))) EVP_PKEY_free(ret); return (NULL); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/p8_pkey.c0000644000175000017500000001174212360020705020645 0ustar /* $OpenBSD: p8_pkey.c,v 1.11 2014/06/12 15:49:27 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include /* Minor tweak to operation: zero private key data */ static int pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { /* Since the structure must still be valid use ASN1_OP_FREE_PRE */ if (operation == ASN1_OP_FREE_PRE) { PKCS8_PRIV_KEY_INFO *key = (PKCS8_PRIV_KEY_INFO *)*pval; if (key->pkey->value.octet_string) OPENSSL_cleanse(key->pkey->value.octet_string->data, key->pkey->value.octet_string->length); } return 1; } ASN1_SEQUENCE_cb(PKCS8_PRIV_KEY_INFO, pkey_cb) = { ASN1_SIMPLE(PKCS8_PRIV_KEY_INFO, version, ASN1_INTEGER), ASN1_SIMPLE(PKCS8_PRIV_KEY_INFO, pkeyalg, X509_ALGOR), ASN1_SIMPLE(PKCS8_PRIV_KEY_INFO, pkey, ASN1_ANY), ASN1_IMP_SET_OF_OPT(PKCS8_PRIV_KEY_INFO, attributes, X509_ATTRIBUTE, 0) } ASN1_SEQUENCE_END_cb(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) IMPLEMENT_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO) int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj, int version, int ptype, void *pval, unsigned char *penc, int penclen) { unsigned char **ppenc = NULL; if (version >= 0) { if (!ASN1_INTEGER_set(priv->version, version)) return 0; } if (penc) { int pmtype; ASN1_OCTET_STRING *oct; oct = ASN1_OCTET_STRING_new(); if (!oct) return 0; oct->data = penc; ppenc = &oct->data; oct->length = penclen; if (priv->broken == PKCS8_NO_OCTET) pmtype = V_ASN1_SEQUENCE; else pmtype = V_ASN1_OCTET_STRING; ASN1_TYPE_set(priv->pkey, pmtype, oct); } if (!X509_ALGOR_set0(priv->pkeyalg, aobj, ptype, pval)) { /* If call fails do not swallow 'enc' */ if (ppenc) *ppenc = NULL; return 0; } return 1; } int PKCS8_pkey_get0(ASN1_OBJECT **ppkalg, const unsigned char **pk, int *ppklen, X509_ALGOR **pa, PKCS8_PRIV_KEY_INFO *p8) { if (ppkalg) *ppkalg = p8->pkeyalg->algorithm; if (p8->pkey->type == V_ASN1_OCTET_STRING) { p8->broken = PKCS8_OK; if (pk) { *pk = p8->pkey->value.octet_string->data; *ppklen = p8->pkey->value.octet_string->length; } } else if (p8->pkey->type == V_ASN1_SEQUENCE) { p8->broken = PKCS8_NO_OCTET; if (pk) { *pk = p8->pkey->value.sequence->data; *ppklen = p8->pkey->value.sequence->length; } } else return 0; if (pa) *pa = p8->pkeyalg; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/asn1/t_x509.c0000644000175000017500000003306512360020705020320 0ustar /* $OpenBSD: t_x509.c,v 1.23 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_DSA #include #endif #ifndef OPENSSL_NO_EC #include #endif #ifndef OPENSSL_NO_RSA #include #endif #include "asn1_locl.h" int X509_print_fp(FILE *fp, X509 *x) { return X509_print_ex_fp(fp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); } int X509_print_ex_fp(FILE *fp, X509 *x, unsigned long nmflag, unsigned long cflag) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { X509err(X509_F_X509_PRINT_EX_FP, ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, fp, BIO_NOCLOSE); ret = X509_print_ex(b, x, nmflag, cflag); BIO_free(b); return (ret); } int X509_print(BIO *bp, X509 *x) { return X509_print_ex(bp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); } int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) { long l; int ret = 0, i; char *m = NULL, mlch = ' '; int nmindent = 0; X509_CINF *ci; ASN1_INTEGER *bs; EVP_PKEY *pkey = NULL; const char *neg; if ((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { mlch = '\n'; nmindent = 12; } if (nmflags == X509_FLAG_COMPAT) nmindent = 16; ci = x->cert_info; if (!(cflag & X509_FLAG_NO_HEADER)) { if (BIO_write(bp, "Certificate:\n", 13) <= 0) goto err; if (BIO_write(bp, " Data:\n", 10) <= 0) goto err; } if (!(cflag & X509_FLAG_NO_VERSION)) { l = X509_get_version(x); if (BIO_printf(bp, "%8sVersion: %lu (0x%lx)\n", "", l + 1, l) <= 0) goto err; } if (!(cflag & X509_FLAG_NO_SERIAL)) { if (BIO_write(bp, " Serial Number:", 22) <= 0) goto err; bs = X509_get_serialNumber(x); if (bs->length <= (int)sizeof(long)) { l = ASN1_INTEGER_get(bs); if (bs->type == V_ASN1_NEG_INTEGER) { l = -l; neg = "-"; } else neg = ""; if (BIO_printf(bp, " %s%lu (%s0x%lx)\n", neg, l, neg, l) <= 0) goto err; } else { neg = (bs->type == V_ASN1_NEG_INTEGER) ? " (Negative)" : ""; if (BIO_printf(bp, "\n%12s%s", "", neg) <= 0) goto err; for (i = 0; i < bs->length; i++) { if (BIO_printf(bp, "%02x%c", bs->data[i], ((i + 1 == bs->length) ? '\n' : ':')) <= 0) goto err; } } } if (!(cflag & X509_FLAG_NO_SIGNAME)) { if (X509_signature_print(bp, x->sig_alg, NULL) <= 0) goto err; #if 0 if (BIO_printf(bp, "%8sSignature Algorithm: ", "") <= 0) goto err; if (i2a_ASN1_OBJECT(bp, ci->signature->algorithm) <= 0) goto err; if (BIO_puts(bp, "\n") <= 0) goto err; #endif } if (!(cflag & X509_FLAG_NO_ISSUER)) { if (BIO_printf(bp, " Issuer:%c", mlch) <= 0) goto err; if (X509_NAME_print_ex(bp, X509_get_issuer_name(x), nmindent, nmflags) < 0) goto err; if (BIO_write(bp, "\n", 1) <= 0) goto err; } if (!(cflag & X509_FLAG_NO_VALIDITY)) { if (BIO_write(bp, " Validity\n", 17) <= 0) goto err; if (BIO_write(bp, " Not Before: ", 24) <= 0) goto err; if (!ASN1_TIME_print(bp, X509_get_notBefore(x))) goto err; if (BIO_write(bp, "\n Not After : ", 25) <= 0) goto err; if (!ASN1_TIME_print(bp, X509_get_notAfter(x))) goto err; if (BIO_write(bp, "\n", 1) <= 0) goto err; } if (!(cflag & X509_FLAG_NO_SUBJECT)) { if (BIO_printf(bp, " Subject:%c", mlch) <= 0) goto err; if (X509_NAME_print_ex(bp, X509_get_subject_name(x), nmindent, nmflags) < 0) goto err; if (BIO_write(bp, "\n", 1) <= 0) goto err; } if (!(cflag & X509_FLAG_NO_PUBKEY)) { if (BIO_write(bp, " Subject Public Key Info:\n", 33) <= 0) goto err; if (BIO_printf(bp, "%12sPublic Key Algorithm: ", "") <= 0) goto err; if (i2a_ASN1_OBJECT(bp, ci->key->algor->algorithm) <= 0) goto err; if (BIO_puts(bp, "\n") <= 0) goto err; pkey = X509_get_pubkey(x); if (pkey == NULL) { BIO_printf(bp, "%12sUnable to load Public Key\n", ""); ERR_print_errors(bp); } else { EVP_PKEY_print_public(bp, pkey, 16, NULL); EVP_PKEY_free(pkey); } } if (!(cflag & X509_FLAG_NO_EXTENSIONS)) X509V3_extensions_print(bp, "X509v3 extensions", ci->extensions, cflag, 8); if (!(cflag & X509_FLAG_NO_SIGDUMP)) { if (X509_signature_print(bp, x->sig_alg, x->signature) <= 0) goto err; } if (!(cflag & X509_FLAG_NO_AUX)) { if (!X509_CERT_AUX_print(bp, x->aux, 0)) goto err; } ret = 1; err: free(m); return (ret); } int X509_ocspid_print (BIO *bp, X509 *x) { unsigned char *der = NULL; unsigned char *dertmp; int derlen; int i; unsigned char SHA1md[SHA_DIGEST_LENGTH]; /* display the hash of the subject as it would appear in OCSP requests */ if (BIO_printf(bp, " Subject OCSP hash: ") <= 0) goto err; derlen = i2d_X509_NAME(x->cert_info->subject, NULL); if ((der = dertmp = malloc(derlen)) == NULL) goto err; i2d_X509_NAME(x->cert_info->subject, &dertmp); if (!EVP_Digest(der, derlen, SHA1md, NULL, EVP_sha1(), NULL)) goto err; for (i = 0; i < SHA_DIGEST_LENGTH; i++) { if (BIO_printf(bp, "%02X", SHA1md[i]) <= 0) goto err; } free (der); der = NULL; /* display the hash of the public key as it would appear in OCSP requests */ if (BIO_printf(bp, "\n Public key OCSP hash: ") <= 0) goto err; if (!EVP_Digest(x->cert_info->key->public_key->data, x->cert_info->key->public_key->length, SHA1md, NULL, EVP_sha1(), NULL)) goto err; for (i = 0; i < SHA_DIGEST_LENGTH; i++) { if (BIO_printf(bp, "%02X", SHA1md[i]) <= 0) goto err; } BIO_printf(bp, "\n"); return (1); err: free(der); return (0); } int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent) { const unsigned char *s; int i, n; n = sig->length; s = sig->data; for (i = 0; i < n; i++) { if ((i % 18) == 0) { if (BIO_write(bp, "\n", 1) <= 0) return 0; if (BIO_indent(bp, indent, indent) <= 0) return 0; } if (BIO_printf(bp, "%02x%s", s[i], ((i + 1) == n) ? "" : ":") <= 0) return 0; } if (BIO_write(bp, "\n", 1) != 1) return 0; return 1; } int X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig) { int sig_nid; if (BIO_puts(bp, " Signature Algorithm: ") <= 0) return 0; if (i2a_ASN1_OBJECT(bp, sigalg->algorithm) <= 0) return 0; sig_nid = OBJ_obj2nid(sigalg->algorithm); if (sig_nid != NID_undef) { int pkey_nid, dig_nid; const EVP_PKEY_ASN1_METHOD *ameth; if (OBJ_find_sigid_algs(sig_nid, &dig_nid, &pkey_nid)) { ameth = EVP_PKEY_asn1_find(NULL, pkey_nid); if (ameth && ameth->sig_print) return ameth->sig_print(bp, sigalg, sig, 9, 0); } } if (sig) return X509_signature_dump(bp, sig, 9); else if (BIO_puts(bp, "\n") <= 0) return 0; return 1; } int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v) { int i, n; char buf[80]; const char *p; if (v == NULL) return (0); n = 0; p = (const char *)v->data; for (i = 0; i < v->length; i++) { if ((p[i] > '~') || ((p[i] < ' ') && (p[i] != '\n') && (p[i] != '\r'))) buf[n] = '.'; else buf[n] = p[i]; n++; if (n >= 80) { if (BIO_write(bp, buf, n) <= 0) return (0); n = 0; } } if (n > 0) if (BIO_write(bp, buf, n) <= 0) return (0); return (1); } int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm) { if (tm->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_print(bp, tm); if (tm->type == V_ASN1_GENERALIZEDTIME) return ASN1_GENERALIZEDTIME_print(bp, tm); BIO_write(bp, "Bad time value", 14); return (0); } static const char *mon[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm) { char *v; int gmt = 0; int i; int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0; char *f = NULL; int f_len = 0; i = tm->length; v = (char *)tm->data; if (i < 12) goto err; if (v[i-1] == 'Z') gmt = 1; for (i = 0; i < 12; i++) if ((v[i] > '9') || (v[i] < '0')) goto err; y = (v[0] - '0') * 1000 + (v[1] - '0') * 100 + (v[2] - '0') * 10 + (v[3] - '0'); M = (v[4] - '0') * 10 + (v[5] - '0'); if ((M > 12) || (M < 1)) goto err; d = (v[6] - '0') * 10 + (v[7] - '0'); h = (v[8] - '0') * 10 + (v[9] - '0'); m = (v[10] - '0') * 10 + (v[11] - '0'); if (tm->length >= 14 && (v[12] >= '0') && (v[12] <= '9') && (v[13] >= '0') && (v[13] <= '9')) { s = (v[12] - '0') * 10 + (v[13] - '0'); /* Check for fractions of seconds. */ if (tm->length >= 15 && v[14] == '.') { int l = tm->length; f = &v[14]; /* The decimal point. */ f_len = 1; while (14 + f_len < l && f[f_len] >= '0' && f[f_len] <= '9') ++f_len; } } if (BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s", mon[M - 1], d, h, m, s, f_len, f, y, (gmt) ? " GMT" : "") <= 0) return (0); else return (1); err: BIO_write(bp, "Bad time value", 14); return (0); } int ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm) { const char *v; int gmt = 0; int i; int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0; i = tm->length; v = (const char *)tm->data; if (i < 10) goto err; if (v[i-1] == 'Z') gmt = 1; for (i = 0; i < 10; i++) if ((v[i] > '9') || (v[i] < '0')) goto err; y = (v[0] - '0') * 10 + (v[1] - '0'); if (y < 50) y += 100; M = (v[2] - '0') * 10 + (v[3] - '0'); if ((M > 12) || (M < 1)) goto err; d = (v[4] - '0') * 10 + (v[5] - '0'); h = (v[6] - '0') * 10 + (v[7] - '0'); m = (v[8] - '0') * 10 + (v[9] - '0'); if (tm->length >=12 && (v[10] >= '0') && (v[10] <= '9') && (v[11] >= '0') && (v[11] <= '9')) s = (v[10] - '0') * 10 + (v[11] - '0'); if (BIO_printf(bp, "%s %2d %02d:%02d:%02d %d%s", mon[M - 1], d, h, m, s, y + 1900, (gmt) ? " GMT" : "") <= 0) return (0); else return (1); err: BIO_write(bp, "Bad time value", 14); return (0); } int X509_NAME_print(BIO *bp, X509_NAME *name, int obase) { char *s, *c, *b; int ret = 0, l, i; l = 80 - 2 - obase; b = X509_NAME_oneline(name, NULL, 0); if (!*b) { free(b); return 1; } s = b + 1; /* skip the first slash */ c = s; for (;;) { if (((*s == '/') && ((s[1] >= 'A') && (s[1] <= 'Z') && ((s[2] == '=') || ((s[2] >= 'A') && (s[2] <= 'Z') && (s[3] == '='))))) || (*s == '\0')) { i = s - c; if (BIO_write(bp, c, i) != i) goto err; c = s + 1; /* skip following slash */ if (*s != '\0') { if (BIO_write(bp, ", ", 2) != 2) goto err; } l--; } if (*s == '\0') break; s++; l--; } ret = 1; if (0) { err: X509err(X509_F_X509_NAME_PRINT, ERR_R_BUF_LIB); } free(b); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/comp/0000755000000000000000000000000012666635521021010 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/comp/c_rle.c0000644000175000017500000000224212360020705020441 0ustar /* $OpenBSD$ */ #include #include #include #include #include static int rle_compress_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, unsigned char *in, unsigned int ilen); static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, unsigned char *in, unsigned int ilen); static COMP_METHOD rle_method = { .type = NID_rle_compression, .name = LN_rle_compression, .compress = rle_compress_block, .expand = rle_expand_block }; COMP_METHOD * COMP_rle(void) { return (&rle_method); } static int rle_compress_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, unsigned char *in, unsigned int ilen) { /* int i; */ if (ilen == 0 || olen < (ilen - 1)) { /* ZZZZZZZZZZZZZZZZZZZZZZ */ return (-1); } *(out++) = 0; memcpy(out, in, ilen); return (ilen + 1); } static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, unsigned char *in, unsigned int ilen) { int i; if (olen < (ilen - 1)) { /* ZZZZZZZZZZZZZZZZZZZZZZ */ return (-1); } i= *(in++); if (i == 0) { memcpy(out, in, ilen - 1); } return (ilen - 1); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/comp/comp_lib.c0000644000175000017500000000231412360020705021141 0ustar /* $OpenBSD$ */ #include #include #include #include #include COMP_CTX * COMP_CTX_new(COMP_METHOD *meth) { COMP_CTX *ret; if ((ret = calloc(1, sizeof(COMP_CTX))) == NULL) { /* ZZZZZZZZZZZZZZZZ */ return (NULL); } ret->meth = meth; if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { free(ret); ret = NULL; } return (ret); } void COMP_CTX_free(COMP_CTX *ctx) { if (ctx == NULL) return; if (ctx->meth->finish != NULL) ctx->meth->finish(ctx); free(ctx); } int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, unsigned char *in, int ilen) { int ret; if (ctx->meth->compress == NULL) { /* ZZZZZZZZZZZZZZZZZ */ return (-1); } ret = ctx->meth->compress(ctx, out, olen, in, ilen); if (ret > 0) { ctx->compress_in += ilen; ctx->compress_out += ret; } return (ret); } int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, unsigned char *in, int ilen) { int ret; if (ctx->meth->expand == NULL) { /* ZZZZZZZZZZZZZZZZZ */ return (-1); } ret = ctx->meth->expand(ctx, out, olen, in, ilen); if (ret > 0) { ctx->expand_in += ilen; ctx->expand_out += ret; } return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/comp/c_zlib.c0000644000175000017500000004174412360020705020631 0ustar /* $OpenBSD$ */ #include #include #include #include #include #include COMP_METHOD *COMP_zlib(void ); static COMP_METHOD zlib_method_nozlib = { .type = NID_undef, .name = "(undef)" }; #ifndef ZLIB #undef ZLIB_SHARED #else #include static int zlib_stateful_init(COMP_CTX *ctx); static void zlib_stateful_finish(COMP_CTX *ctx); static int zlib_stateful_compress_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, unsigned char *in, unsigned int ilen); static int zlib_stateful_expand_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, unsigned char *in, unsigned int ilen); /* memory allocations functions for zlib intialization */ static void* zlib_zalloc(void* opaque, unsigned int no, unsigned int size) { return calloc(no, size); } static void zlib_zfree(void* opaque, void* address) { free(address); } #if 0 static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, unsigned char *in, unsigned int ilen); static int zlib_expand_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, unsigned char *in, unsigned int ilen); static int zz_uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); static COMP_METHOD zlib_stateless_method = { .type = NID_zlib_compression, .name = LN_zlib_compression, .compress = zlib_compress_block, .expand = zlib_expand_block }; #endif static COMP_METHOD zlib_stateful_method = { .type = NID_zlib_compression, .name = LN_zlib_compression, .init = zlib_stateful_init, .finish = zlib_stateful_finish, .compress = zlib_stateful_compress_block, .expand = zlib_stateful_expand_block }; #ifdef ZLIB_SHARED #include /* Function pointers */ typedef int (*compress_ft)(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); typedef int (*inflateEnd_ft)(z_streamp strm); typedef int (*inflate_ft)(z_streamp strm, int flush); typedef int (*inflateInit__ft)(z_streamp strm, const char * version, int stream_size); typedef int (*deflateEnd_ft)(z_streamp strm); typedef int (*deflate_ft)(z_streamp strm, int flush); typedef int (*deflateInit__ft)(z_streamp strm, int level, const char * version, int stream_size); typedef const char * (*zError__ft)(int err); static compress_ft p_compress = NULL; static inflateEnd_ft p_inflateEnd = NULL; static inflate_ft p_inflate = NULL; static inflateInit__ft p_inflateInit_ = NULL; static deflateEnd_ft p_deflateEnd = NULL; static deflate_ft p_deflate = NULL; static deflateInit__ft p_deflateInit_ = NULL; static zError__ft p_zError = NULL; static int zlib_loaded = 0; /* only attempt to init func pts once */ static DSO *zlib_dso = NULL; #define compress p_compress #define inflateEnd p_inflateEnd #define inflate p_inflate #define inflateInit_ p_inflateInit_ #define deflateEnd p_deflateEnd #define deflate p_deflate #define deflateInit_ p_deflateInit_ #define zError p_zError #endif /* ZLIB_SHARED */ struct zlib_state { z_stream istream; z_stream ostream; }; static int zlib_stateful_ex_idx = -1; static int zlib_stateful_init(COMP_CTX *ctx) { int err; struct zlib_state *state = malloc(sizeof(struct zlib_state)); if (state == NULL) goto err; state->istream.zalloc = zlib_zalloc; state->istream.zfree = zlib_zfree; state->istream.opaque = Z_NULL; state->istream.next_in = Z_NULL; state->istream.next_out = Z_NULL; state->istream.avail_in = 0; state->istream.avail_out = 0; err = inflateInit_(&state->istream, ZLIB_VERSION, sizeof(z_stream)); if (err != Z_OK) goto err; state->ostream.zalloc = zlib_zalloc; state->ostream.zfree = zlib_zfree; state->ostream.opaque = Z_NULL; state->ostream.next_in = Z_NULL; state->ostream.next_out = Z_NULL; state->ostream.avail_in = 0; state->ostream.avail_out = 0; err = deflateInit_(&state->ostream, Z_DEFAULT_COMPRESSION, ZLIB_VERSION, sizeof(z_stream)); if (err != Z_OK) goto err; CRYPTO_new_ex_data(CRYPTO_EX_INDEX_COMP, ctx, &ctx->ex_data); CRYPTO_set_ex_data(&ctx->ex_data, zlib_stateful_ex_idx, state); return 1; err: free(state); return 0; } static void zlib_stateful_finish(COMP_CTX *ctx) { struct zlib_state *state = (struct zlib_state *)CRYPTO_get_ex_data(&ctx->ex_data, zlib_stateful_ex_idx); inflateEnd(&state->istream); deflateEnd(&state->ostream); free(state); CRYPTO_free_ex_data(CRYPTO_EX_INDEX_COMP, ctx, &ctx->ex_data); } static int zlib_stateful_compress_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, unsigned char *in, unsigned int ilen) { int err = Z_OK; struct zlib_state *state = (struct zlib_state *)CRYPTO_get_ex_data(&ctx->ex_data, zlib_stateful_ex_idx); if (state == NULL) return -1; state->ostream.next_in = in; state->ostream.avail_in = ilen; state->ostream.next_out = out; state->ostream.avail_out = olen; if (ilen > 0) err = deflate(&state->ostream, Z_SYNC_FLUSH); if (err != Z_OK) return -1; #ifdef DEBUG_ZLIB fprintf(stderr, "compress(%4d)->%4d %s\n", ilen, olen - state->ostream.avail_out, (ilen != olen - state->ostream.avail_out)?"zlib":"clear"); #endif return olen - state->ostream.avail_out; } static int zlib_stateful_expand_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, unsigned char *in, unsigned int ilen) { int err = Z_OK; struct zlib_state *state = (struct zlib_state *)CRYPTO_get_ex_data(&ctx->ex_data, zlib_stateful_ex_idx); if (state == NULL) return 0; state->istream.next_in = in; state->istream.avail_in = ilen; state->istream.next_out = out; state->istream.avail_out = olen; if (ilen > 0) err = inflate(&state->istream, Z_SYNC_FLUSH); if (err != Z_OK) return -1; #ifdef DEBUG_ZLIB fprintf(stderr, "expand(%4d)->%4d %s\n", ilen, olen - state->istream.avail_out, (ilen != olen - state->istream.avail_out)?"zlib":"clear"); #endif return olen - state->istream.avail_out; } #if 0 static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, unsigned char *in, unsigned int ilen) { unsigned long l; int i; int clear = 1; if (ilen > 128) { out[0] = 1; l = olen - 1; i = compress(&(out[1]), &l, in, (unsigned long)ilen); if (i != Z_OK) return (-1); if (ilen > l) { clear = 0; l++; } } if (clear) { out[0] = 0; memcpy(&(out[1]), in, ilen); l = ilen + 1; } #ifdef DEBUG_ZLIB fprintf(stderr, "compress(%4d)->%4d %s\n", ilen,(int)l, (clear)?"clear":"zlib"); #endif return ((int)l); } static int zlib_expand_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, unsigned char *in, unsigned int ilen) { unsigned long l; int i; if (in[0]) { l = olen; i = zz_uncompress(out, &l, &(in[1]), (unsigned long)ilen - 1); if (i != Z_OK) return (-1); } else { memcpy(out, &(in[1]), ilen - 1); l = ilen - 1; } #ifdef DEBUG_ZLIB fprintf(stderr, "expand (%4d)->%4d %s\n", ilen,(int)l, in[0]?"zlib":"clear"); #endif return ((int)l); } static int zz_uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) { z_stream stream; int err; stream.next_in = (Bytef*)source; stream.avail_in = (uInt)sourceLen; /* Check for source > 64K on 16-bit machine: */ if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; stream.next_out = dest; stream.avail_out = (uInt)*destLen; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; stream.zalloc = (alloc_func)0; stream.zfree = (free_func)0; err = inflateInit_(&stream, ZLIB_VERSION, sizeof(z_stream)); if (err != Z_OK) return err; err = inflate(&stream, Z_FINISH); if (err != Z_STREAM_END) { inflateEnd(&stream); return err; } *destLen = stream.total_out; err = inflateEnd(&stream); return err; } #endif #endif COMP_METHOD * COMP_zlib(void) { COMP_METHOD *meth = &zlib_method_nozlib; #ifdef ZLIB_SHARED if (!zlib_loaded) { zlib_dso = DSO_load(NULL, "z", NULL, 0); if (zlib_dso != NULL) { p_compress = (compress_ft)DSO_bind_func( zlib_dso, "compress"); p_inflateEnd = (inflateEnd_ft)DSO_bind_func( zlib_dso, "inflateEnd"); p_inflate = (inflate_ft)DSO_bind_func( zlib_dso, "inflate"); p_inflateInit_ = (inflateInit__ft)DSO_bind_func( zlib_dso, "inflateInit_"); p_deflateEnd = (deflateEnd_ft)DSO_bind_func( zlib_dso, "deflateEnd"); p_deflate = (deflate_ft)DSO_bind_func( zlib_dso, "deflate"); p_deflateInit_ = (deflateInit__ft)DSO_bind_func( zlib_dso, "deflateInit_"); p_zError = (zError__ft)DSO_bind_func( zlib_dso, "zError"); if (p_compress && p_inflateEnd && p_inflate && p_inflateInit_ && p_deflateEnd && p_deflate && p_deflateInit_ && p_zError) zlib_loaded++; } } #endif #ifdef ZLIB_SHARED if (zlib_loaded) #endif #if defined(ZLIB) || defined(ZLIB_SHARED) { /* init zlib_stateful_ex_idx here so that in a multi-process * application it's enough to intialize openssl before forking * (idx will be inherited in all the children) */ if (zlib_stateful_ex_idx == -1) { CRYPTO_w_lock(CRYPTO_LOCK_COMP); if (zlib_stateful_ex_idx == -1) zlib_stateful_ex_idx = CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_COMP, 0, NULL, NULL, NULL, NULL); CRYPTO_w_unlock(CRYPTO_LOCK_COMP); if (zlib_stateful_ex_idx == -1) goto err; } meth = &zlib_stateful_method; } err: #endif return (meth); } void COMP_zlib_cleanup(void) { #ifdef ZLIB_SHARED if (zlib_dso) DSO_free(zlib_dso); #endif } #ifdef ZLIB /* Zlib based compression/decompression filter BIO */ typedef struct { unsigned char *ibuf; /* Input buffer */ int ibufsize; /* Buffer size */ z_stream zin; /* Input decompress context */ unsigned char *obuf; /* Output buffer */ int obufsize; /* Output buffer size */ unsigned char *optr; /* Position in output buffer */ int ocount; /* Amount of data in output buffer */ int odone; /* deflate EOF */ int comp_level; /* Compression level to use */ z_stream zout; /* Output compression context */ } BIO_ZLIB_CTX; #define ZLIB_DEFAULT_BUFSIZE 1024 static int bio_zlib_new(BIO *bi); static int bio_zlib_free(BIO *bi); static int bio_zlib_read(BIO *b, char *out, int outl); static int bio_zlib_write(BIO *b, const char *in, int inl); static long bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr); static long bio_zlib_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp); static BIO_METHOD bio_meth_zlib = { .type = BIO_TYPE_COMP, .name = "zlib", .bwrite = bio_zlib_write, .bread = bio_zlib_read, .ctrl = bio_zlib_ctrl, .create = bio_zlib_new, .destroy = bio_zlib_free, .callback_ctrl = bio_zlib_callback_ctrl }; BIO_METHOD * BIO_f_zlib(void) { return &bio_meth_zlib; } static int bio_zlib_new(BIO *bi) { BIO_ZLIB_CTX *ctx; #ifdef ZLIB_SHARED (void)COMP_zlib(); if (!zlib_loaded) { COMPerr(COMP_F_BIO_ZLIB_NEW, COMP_R_ZLIB_NOT_SUPPORTED); return 0; } #endif ctx = malloc(sizeof(BIO_ZLIB_CTX)); if (!ctx) { COMPerr(COMP_F_BIO_ZLIB_NEW, ERR_R_MALLOC_FAILURE); return 0; } ctx->ibuf = NULL; ctx->obuf = NULL; ctx->ibufsize = ZLIB_DEFAULT_BUFSIZE; ctx->obufsize = ZLIB_DEFAULT_BUFSIZE; ctx->zin.zalloc = Z_NULL; ctx->zin.zfree = Z_NULL; ctx->zin.next_in = NULL; ctx->zin.avail_in = 0; ctx->zin.next_out = NULL; ctx->zin.avail_out = 0; ctx->zout.zalloc = Z_NULL; ctx->zout.zfree = Z_NULL; ctx->zout.next_in = NULL; ctx->zout.avail_in = 0; ctx->zout.next_out = NULL; ctx->zout.avail_out = 0; ctx->odone = 0; ctx->comp_level = Z_DEFAULT_COMPRESSION; bi->init = 1; bi->ptr = (char *)ctx; bi->flags = 0; return 1; } static int bio_zlib_free(BIO *bi) { BIO_ZLIB_CTX *ctx; if (!bi) return 0; ctx = (BIO_ZLIB_CTX *)bi->ptr; if (ctx->ibuf) { /* Destroy decompress context */ inflateEnd(&ctx->zin); free(ctx->ibuf); } if (ctx->obuf) { /* Destroy compress context */ deflateEnd(&ctx->zout); free(ctx->obuf); } free(ctx); bi->ptr = NULL; bi->init = 0; bi->flags = 0; return 1; } static int bio_zlib_read(BIO *b, char *out, int outl) { BIO_ZLIB_CTX *ctx; int ret; z_stream *zin; if (!out || !outl) return 0; ctx = (BIO_ZLIB_CTX *)b->ptr; zin = &ctx->zin; BIO_clear_retry_flags(b); if (!ctx->ibuf) { ctx->ibuf = malloc(ctx->ibufsize); if (!ctx->ibuf) { COMPerr(COMP_F_BIO_ZLIB_READ, ERR_R_MALLOC_FAILURE); return 0; } inflateInit(zin); zin->next_in = ctx->ibuf; zin->avail_in = 0; } /* Copy output data directly to supplied buffer */ zin->next_out = (unsigned char *)out; zin->avail_out = (unsigned int)outl; for (;;) { /* Decompress while data available */ while (zin->avail_in) { ret = inflate(zin, 0); if ((ret != Z_OK) && (ret != Z_STREAM_END)) { COMPerr(COMP_F_BIO_ZLIB_READ, COMP_R_ZLIB_INFLATE_ERROR); ERR_asprintf_error_data("zlib error:%s", zError(ret)); return 0; } /* If EOF or we've read everything then return */ if ((ret == Z_STREAM_END) || !zin->avail_out) return outl - zin->avail_out; } /* No data in input buffer try to read some in, * if an error then return the total data read. */ ret = BIO_read(b->next_bio, ctx->ibuf, ctx->ibufsize); if (ret <= 0) { /* Total data read */ int tot = outl - zin->avail_out; BIO_copy_next_retry(b); if (ret < 0) return (tot > 0) ? tot : ret; return tot; } zin->avail_in = ret; zin->next_in = ctx->ibuf; } } static int bio_zlib_write(BIO *b, const char *in, int inl) { BIO_ZLIB_CTX *ctx; int ret; z_stream *zout; if (!in || !inl) return 0; ctx = (BIO_ZLIB_CTX *)b->ptr; if (ctx->odone) return 0; zout = &ctx->zout; BIO_clear_retry_flags(b); if (!ctx->obuf) { ctx->obuf = malloc(ctx->obufsize); /* Need error here */ if (!ctx->obuf) { COMPerr(COMP_F_BIO_ZLIB_WRITE, ERR_R_MALLOC_FAILURE); return 0; } ctx->optr = ctx->obuf; ctx->ocount = 0; deflateInit(zout, ctx->comp_level); zout->next_out = ctx->obuf; zout->avail_out = ctx->obufsize; } /* Obtain input data directly from supplied buffer */ zout->next_in = (void *)in; zout->avail_in = inl; for (;;) { /* If data in output buffer write it first */ while (ctx->ocount) { ret = BIO_write(b->next_bio, ctx->optr, ctx->ocount); if (ret <= 0) { /* Total data written */ int tot = inl - zout->avail_in; BIO_copy_next_retry(b); if (ret < 0) return (tot > 0) ? tot : ret; return tot; } ctx->optr += ret; ctx->ocount -= ret; } /* Have we consumed all supplied data? */ if (!zout->avail_in) return inl; /* Compress some more */ /* Reset buffer */ ctx->optr = ctx->obuf; zout->next_out = ctx->obuf; zout->avail_out = ctx->obufsize; /* Compress some more */ ret = deflate(zout, 0); if (ret != Z_OK) { COMPerr(COMP_F_BIO_ZLIB_WRITE, COMP_R_ZLIB_DEFLATE_ERROR); ERR_asprintf_error_data("zlib error:%s", zError(ret)); return 0; } ctx->ocount = ctx->obufsize - zout->avail_out; } } static int bio_zlib_flush(BIO *b) { BIO_ZLIB_CTX *ctx; int ret; z_stream *zout; ctx = (BIO_ZLIB_CTX *)b->ptr; /* If no data written or already flush show success */ if (!ctx->obuf || (ctx->odone && !ctx->ocount)) return 1; zout = &ctx->zout; BIO_clear_retry_flags(b); /* No more input data */ zout->next_in = NULL; zout->avail_in = 0; for (;;) { /* If data in output buffer write it first */ while (ctx->ocount) { ret = BIO_write(b->next_bio, ctx->optr, ctx->ocount); if (ret <= 0) { BIO_copy_next_retry(b); return ret; } ctx->optr += ret; ctx->ocount -= ret; } if (ctx->odone) return 1; /* Compress some more */ /* Reset buffer */ ctx->optr = ctx->obuf; zout->next_out = ctx->obuf; zout->avail_out = ctx->obufsize; /* Compress some more */ ret = deflate(zout, Z_FINISH); if (ret == Z_STREAM_END) ctx->odone = 1; else if (ret != Z_OK) { COMPerr(COMP_F_BIO_ZLIB_FLUSH, COMP_R_ZLIB_DEFLATE_ERROR); ERR_asprintf_error_data("zlib error:%s", zError(ret)); return 0; } ctx->ocount = ctx->obufsize - zout->avail_out; } } static long bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr) { BIO_ZLIB_CTX *ctx; int ret, *ip; int ibs, obs; if (!b->next_bio) return 0; ctx = (BIO_ZLIB_CTX *)b->ptr; switch (cmd) { case BIO_CTRL_RESET: ctx->ocount = 0; ctx->odone = 0; ret = 1; break; case BIO_CTRL_FLUSH: ret = bio_zlib_flush(b); if (ret > 0) ret = BIO_flush(b->next_bio); break; case BIO_C_SET_BUFF_SIZE: ibs = -1; obs = -1; if (ptr != NULL) { ip = ptr; if (*ip == 0) ibs = (int) num; else obs = (int) num; } else { ibs = (int)num; obs = ibs; } if (ibs != -1) { if (ctx->ibuf) { free(ctx->ibuf); ctx->ibuf = NULL; } ctx->ibufsize = ibs; } if (obs != -1) { if (ctx->obuf) { free(ctx->obuf); ctx->obuf = NULL; } ctx->obufsize = obs; } ret = 1; break; case BIO_C_DO_STATE_MACHINE: BIO_clear_retry_flags(b); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); BIO_copy_next_retry(b); break; default: ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; } return ret; } static long bio_zlib_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) { if (!b->next_bio) return 0; return BIO_callback_ctrl(b->next_bio, cmd, fp); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/comp/comp_err.c0000644000175000017500000000751612360020705021174 0ustar /* $OpenBSD: comp_err.c,v 1.7 2014/06/12 15:49:28 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_COMP,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_COMP,0,reason) static ERR_STRING_DATA COMP_str_functs[] = { {ERR_FUNC(COMP_F_BIO_ZLIB_FLUSH), "BIO_ZLIB_FLUSH"}, {ERR_FUNC(COMP_F_BIO_ZLIB_NEW), "BIO_ZLIB_NEW"}, {ERR_FUNC(COMP_F_BIO_ZLIB_READ), "BIO_ZLIB_READ"}, {ERR_FUNC(COMP_F_BIO_ZLIB_WRITE), "BIO_ZLIB_WRITE"}, {0, NULL} }; static ERR_STRING_DATA COMP_str_reasons[] = { {ERR_REASON(COMP_R_ZLIB_DEFLATE_ERROR) , "zlib deflate error"}, {ERR_REASON(COMP_R_ZLIB_INFLATE_ERROR) , "zlib inflate error"}, {ERR_REASON(COMP_R_ZLIB_NOT_SUPPORTED) , "zlib not supported"}, {0, NULL} }; #endif void ERR_load_COMP_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(COMP_str_functs[0].error) == NULL) { ERR_load_strings(0, COMP_str_functs); ERR_load_strings(0, COMP_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs7/0000755000000000000000000000000012666635521021101 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs7/pk7_smime.c0000644000175000017500000003577212360020706021360 0ustar /* $OpenBSD: pk7_smime.c,v 1.17 2014/07/10 21:42:43 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ /* ==================================================================== * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Simple PKCS#7 processing functions */ #include #include #include #include static int pkcs7_copy_existing_digest(PKCS7 *p7, PKCS7_SIGNER_INFO *si); PKCS7 * PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, BIO *data, int flags) { PKCS7 *p7; int i; if (!(p7 = PKCS7_new())) { PKCS7err(PKCS7_F_PKCS7_SIGN, ERR_R_MALLOC_FAILURE); return NULL; } if (!PKCS7_set_type(p7, NID_pkcs7_signed)) goto err; if (!PKCS7_content_new(p7, NID_pkcs7_data)) goto err; if (pkey && !PKCS7_sign_add_signer(p7, signcert, pkey, NULL, flags)) { PKCS7err(PKCS7_F_PKCS7_SIGN, PKCS7_R_PKCS7_ADD_SIGNER_ERROR); goto err; } if (!(flags & PKCS7_NOCERTS)) { for (i = 0; i < sk_X509_num(certs); i++) { if (!PKCS7_add_certificate(p7, sk_X509_value(certs, i))) goto err; } } if (flags & PKCS7_DETACHED) PKCS7_set_detached(p7, 1); if (flags & (PKCS7_STREAM|PKCS7_PARTIAL)) return p7; if (PKCS7_final(p7, data, flags)) return p7; err: PKCS7_free(p7); return NULL; } int PKCS7_final(PKCS7 *p7, BIO *data, int flags) { BIO *p7bio; int ret = 0; if (!(p7bio = PKCS7_dataInit(p7, NULL))) { PKCS7err(PKCS7_F_PKCS7_FINAL, ERR_R_MALLOC_FAILURE); return 0; } SMIME_crlf_copy(data, p7bio, flags); (void)BIO_flush(p7bio); if (!PKCS7_dataFinal(p7, p7bio)) { PKCS7err(PKCS7_F_PKCS7_FINAL, PKCS7_R_PKCS7_DATASIGN); goto err; } ret = 1; err: BIO_free_all(p7bio); return ret; } /* Check to see if a cipher exists and if so add S/MIME capabilities */ static int add_cipher_smcap(STACK_OF(X509_ALGOR) *sk, int nid, int arg) { if (EVP_get_cipherbynid(nid)) return PKCS7_simple_smimecap(sk, nid, arg); return 1; } static int add_digest_smcap(STACK_OF(X509_ALGOR) *sk, int nid, int arg) { if (EVP_get_digestbynid(nid)) return PKCS7_simple_smimecap(sk, nid, arg); return 1; } PKCS7_SIGNER_INFO * PKCS7_sign_add_signer(PKCS7 *p7, X509 *signcert, EVP_PKEY *pkey, const EVP_MD *md, int flags) { PKCS7_SIGNER_INFO *si = NULL; STACK_OF(X509_ALGOR) *smcap = NULL; if (!X509_check_private_key(signcert, pkey)) { PKCS7err(PKCS7_F_PKCS7_SIGN_ADD_SIGNER, PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE); return NULL; } if (!(si = PKCS7_add_signature(p7, signcert, pkey, md))) { PKCS7err(PKCS7_F_PKCS7_SIGN_ADD_SIGNER, PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR); return NULL; } if (!(flags & PKCS7_NOCERTS)) { if (!PKCS7_add_certificate(p7, signcert)) goto err; } if (!(flags & PKCS7_NOATTR)) { if (!PKCS7_add_attrib_content_type(si, NULL)) goto err; /* Add SMIMECapabilities */ if (!(flags & PKCS7_NOSMIMECAP)) { if (!(smcap = sk_X509_ALGOR_new_null())) { PKCS7err(PKCS7_F_PKCS7_SIGN_ADD_SIGNER, ERR_R_MALLOC_FAILURE); goto err; } if (!add_cipher_smcap(smcap, NID_aes_256_cbc, -1) || !add_digest_smcap(smcap, NID_id_GostR3411_94, -1) || !add_cipher_smcap(smcap, NID_id_Gost28147_89, -1) || !add_cipher_smcap(smcap, NID_aes_192_cbc, -1) || !add_cipher_smcap(smcap, NID_aes_128_cbc, -1) || !add_cipher_smcap(smcap, NID_des_ede3_cbc, -1) || !add_cipher_smcap(smcap, NID_rc2_cbc, 128) || !add_cipher_smcap(smcap, NID_rc2_cbc, 64) || !add_cipher_smcap(smcap, NID_des_cbc, -1) || !add_cipher_smcap(smcap, NID_rc2_cbc, 40) || !PKCS7_add_attrib_smimecap(si, smcap)) goto err; sk_X509_ALGOR_pop_free(smcap, X509_ALGOR_free); smcap = NULL; } if (flags & PKCS7_REUSE_DIGEST) { if (!pkcs7_copy_existing_digest(p7, si)) goto err; if (!(flags & PKCS7_PARTIAL) && !PKCS7_SIGNER_INFO_sign(si)) goto err; } } return si; err: if (smcap) sk_X509_ALGOR_pop_free(smcap, X509_ALGOR_free); return NULL; } /* Search for a digest matching SignerInfo digest type and if found * copy across. */ static int pkcs7_copy_existing_digest(PKCS7 *p7, PKCS7_SIGNER_INFO *si) { int i; STACK_OF(PKCS7_SIGNER_INFO) *sinfos; PKCS7_SIGNER_INFO *sitmp; ASN1_OCTET_STRING *osdig = NULL; sinfos = PKCS7_get_signer_info(p7); for (i = 0; i < sk_PKCS7_SIGNER_INFO_num(sinfos); i++) { sitmp = sk_PKCS7_SIGNER_INFO_value(sinfos, i); if (si == sitmp) break; if (sk_X509_ATTRIBUTE_num(sitmp->auth_attr) <= 0) continue; if (!OBJ_cmp(si->digest_alg->algorithm, sitmp->digest_alg->algorithm)) { osdig = PKCS7_digest_from_attributes(sitmp->auth_attr); break; } } if (osdig) return PKCS7_add1_attrib_digest(si, osdig->data, osdig->length); PKCS7err(PKCS7_F_PKCS7_COPY_EXISTING_DIGEST, PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND); return 0; } int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, BIO *indata, BIO *out, int flags) { STACK_OF(X509) *signers; X509 *signer; STACK_OF(PKCS7_SIGNER_INFO) *sinfos; PKCS7_SIGNER_INFO *si; X509_STORE_CTX cert_ctx; char buf[4096]; int i, j = 0, k, ret = 0; BIO *p7bio; BIO *tmpin, *tmpout; if (!p7) { PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_INVALID_NULL_POINTER); return 0; } if (!PKCS7_type_is_signed(p7)) { PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_WRONG_CONTENT_TYPE); return 0; } /* Check for no data and no content: no data to verify signature */ if (PKCS7_get_detached(p7) && !indata) { PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_NO_CONTENT); return 0; } #if 0 /* NB: this test commented out because some versions of Netscape * illegally include zero length content when signing data. */ /* Check for data and content: two sets of data */ if (!PKCS7_get_detached(p7) && indata) { PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_CONTENT_AND_DATA_PRESENT); return 0; } #endif sinfos = PKCS7_get_signer_info(p7); if (!sinfos || !sk_PKCS7_SIGNER_INFO_num(sinfos)) { PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_NO_SIGNATURES_ON_DATA); return 0; } signers = PKCS7_get0_signers(p7, certs, flags); if (!signers) return 0; /* Now verify the certificates */ if (!(flags & PKCS7_NOVERIFY)) for (k = 0; k < sk_X509_num(signers); k++) { signer = sk_X509_value (signers, k); if (!(flags & PKCS7_NOCHAIN)) { if (!X509_STORE_CTX_init(&cert_ctx, store, signer, p7->d.sign->cert)) { PKCS7err(PKCS7_F_PKCS7_VERIFY, ERR_R_X509_LIB); sk_X509_free(signers); return 0; } X509_STORE_CTX_set_default(&cert_ctx, "smime_sign"); } else if (!X509_STORE_CTX_init(&cert_ctx, store, signer, NULL)) { PKCS7err(PKCS7_F_PKCS7_VERIFY, ERR_R_X509_LIB); sk_X509_free(signers); return 0; } if (!(flags & PKCS7_NOCRL)) X509_STORE_CTX_set0_crls(&cert_ctx, p7->d.sign->crl); i = X509_verify_cert(&cert_ctx); if (i <= 0) j = X509_STORE_CTX_get_error(&cert_ctx); X509_STORE_CTX_cleanup(&cert_ctx); if (i <= 0) { PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_CERTIFICATE_VERIFY_ERROR); ERR_asprintf_error_data("Verify error:%s", X509_verify_cert_error_string(j)); sk_X509_free(signers); return 0; } /* Check for revocation status here */ } /* * Performance optimization: if the content is a memory BIO then * store its contents in a temporary read only memory BIO. This * avoids potentially large numbers of slow copies of data which will * occur when reading from a read write memory BIO when signatures * are calculated. */ if (indata && (BIO_method_type(indata) == BIO_TYPE_MEM)) { char *ptr; long len; len = BIO_get_mem_data(indata, &ptr); tmpin = BIO_new_mem_buf(ptr, len); if (tmpin == NULL) { PKCS7err(PKCS7_F_PKCS7_VERIFY, ERR_R_MALLOC_FAILURE); return 0; } } else tmpin = indata; if (!(p7bio = PKCS7_dataInit(p7, tmpin))) goto err; if (flags & PKCS7_TEXT) { if (!(tmpout = BIO_new(BIO_s_mem()))) { PKCS7err(PKCS7_F_PKCS7_VERIFY, ERR_R_MALLOC_FAILURE); goto err; } BIO_set_mem_eof_return(tmpout, 0); } else tmpout = out; /* We now have to 'read' from p7bio to calculate digests etc. */ for (;;) { i = BIO_read(p7bio, buf, sizeof(buf)); if (i <= 0) break; if (tmpout) BIO_write(tmpout, buf, i); } if (flags & PKCS7_TEXT) { if (!SMIME_text(tmpout, out)) { PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_SMIME_TEXT_ERROR); BIO_free(tmpout); goto err; } BIO_free(tmpout); } /* Now Verify All Signatures */ if (!(flags & PKCS7_NOSIGS)) for (i = 0; i < sk_PKCS7_SIGNER_INFO_num(sinfos); i++) { si = sk_PKCS7_SIGNER_INFO_value(sinfos, i); signer = sk_X509_value (signers, i); j = PKCS7_signatureVerify(p7bio, p7, si, signer); if (j <= 0) { PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_SIGNATURE_FAILURE); goto err; } } ret = 1; err: if (tmpin == indata) { if (indata) BIO_pop(p7bio); } BIO_free_all(p7bio); sk_X509_free(signers); return ret; } STACK_OF(X509) * PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags) { STACK_OF(X509) *signers; STACK_OF(PKCS7_SIGNER_INFO) *sinfos; PKCS7_SIGNER_INFO *si; PKCS7_ISSUER_AND_SERIAL *ias; X509 *signer; int i; if (!p7) { PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS, PKCS7_R_INVALID_NULL_POINTER); return NULL; } if (!PKCS7_type_is_signed(p7)) { PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS, PKCS7_R_WRONG_CONTENT_TYPE); return NULL; } /* Collect all the signers together */ sinfos = PKCS7_get_signer_info(p7); if (sk_PKCS7_SIGNER_INFO_num(sinfos) <= 0) { PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS, PKCS7_R_NO_SIGNERS); return 0; } if (!(signers = sk_X509_new_null())) { PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS, ERR_R_MALLOC_FAILURE); return NULL; } for (i = 0; i < sk_PKCS7_SIGNER_INFO_num(sinfos); i++) { si = sk_PKCS7_SIGNER_INFO_value(sinfos, i); ias = si->issuer_and_serial; signer = NULL; /* If any certificates passed they take priority */ if (certs) signer = X509_find_by_issuer_and_serial (certs, ias->issuer, ias->serial); if (!signer && !(flags & PKCS7_NOINTERN) && p7->d.sign->cert) signer = X509_find_by_issuer_and_serial(p7->d.sign->cert, ias->issuer, ias->serial); if (!signer) { PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS, PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND); sk_X509_free(signers); return 0; } if (!sk_X509_push(signers, signer)) { sk_X509_free(signers); return NULL; } } return signers; } /* Build a complete PKCS#7 enveloped data */ PKCS7 * PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, int flags) { PKCS7 *p7; BIO *p7bio = NULL; int i; X509 *x509; if (!(p7 = PKCS7_new())) { PKCS7err(PKCS7_F_PKCS7_ENCRYPT, ERR_R_MALLOC_FAILURE); return NULL; } if (!PKCS7_set_type(p7, NID_pkcs7_enveloped)) goto err; if (!PKCS7_set_cipher(p7, cipher)) { PKCS7err(PKCS7_F_PKCS7_ENCRYPT, PKCS7_R_ERROR_SETTING_CIPHER); goto err; } for (i = 0; i < sk_X509_num(certs); i++) { x509 = sk_X509_value(certs, i); if (!PKCS7_add_recipient(p7, x509)) { PKCS7err(PKCS7_F_PKCS7_ENCRYPT, PKCS7_R_ERROR_ADDING_RECIPIENT); goto err; } } if (flags & PKCS7_STREAM) return p7; if (PKCS7_final(p7, in, flags)) return p7; err: BIO_free_all(p7bio); PKCS7_free(p7); return NULL; } int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags) { BIO *tmpmem; int ret, i; char buf[4096]; if (!p7) { PKCS7err(PKCS7_F_PKCS7_DECRYPT, PKCS7_R_INVALID_NULL_POINTER); return 0; } if (!PKCS7_type_is_enveloped(p7)) { PKCS7err(PKCS7_F_PKCS7_DECRYPT, PKCS7_R_WRONG_CONTENT_TYPE); return 0; } if (cert && !X509_check_private_key(cert, pkey)) { PKCS7err(PKCS7_F_PKCS7_DECRYPT, PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE); return 0; } if (!(tmpmem = PKCS7_dataDecode(p7, pkey, NULL, cert))) { PKCS7err(PKCS7_F_PKCS7_DECRYPT, PKCS7_R_DECRYPT_ERROR); return 0; } if (flags & PKCS7_TEXT) { BIO *tmpbuf; /* Encrypt BIOs can't do BIO_gets() so add a buffer BIO */ if (!(tmpbuf = BIO_new(BIO_f_buffer()))) { PKCS7err(PKCS7_F_PKCS7_DECRYPT, ERR_R_MALLOC_FAILURE); BIO_free_all(tmpmem); return 0; } BIO_push(tmpbuf, tmpmem); ret = SMIME_text(tmpbuf, data); if (ret > 0 && BIO_method_type(tmpmem) == BIO_TYPE_CIPHER) { if (!BIO_get_cipher_status(tmpmem)) ret = 0; } BIO_free_all(tmpbuf); return ret; } else { for (;;) { i = BIO_read(tmpmem, buf, sizeof(buf)); if (i <= 0) { ret = 1; if (BIO_method_type(tmpmem) == BIO_TYPE_CIPHER) { if (!BIO_get_cipher_status(tmpmem)) ret = 0; } break; } if (BIO_write(data, buf, i) != i) { ret = 0; break; } } BIO_free_all(tmpmem); return ret; } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs7/bio_pk7.c0000644000175000017500000000545112360020706021006 0ustar /* $OpenBSD: bio_pk7.c,v 1.3 2014/06/12 15:49:30 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ /* ==================================================================== * Copyright (c) 2008 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * */ #include #include #include #include /* Streaming encode support for PKCS#7 */ BIO * BIO_new_PKCS7(BIO *out, PKCS7 *p7) { return BIO_new_NDEF(out, (ASN1_VALUE *)p7, ASN1_ITEM_rptr(PKCS7)); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs7/pk7_lib.c0000644000175000017500000003752212360020706021007 0ustar /* $OpenBSD: pk7_lib.c,v 1.12 2014/07/08 09:08:27 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include "asn1_locl.h" long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg) { int nid; long ret; nid = OBJ_obj2nid(p7->type); switch (cmd) { case PKCS7_OP_SET_DETACHED_SIGNATURE: if (nid == NID_pkcs7_signed) { ret = p7->detached = (int)larg; if (ret && PKCS7_type_is_data(p7->d.sign->contents)) { ASN1_OCTET_STRING *os; os = p7->d.sign->contents->d.data; ASN1_OCTET_STRING_free(os); p7->d.sign->contents->d.data = NULL; } } else { PKCS7err(PKCS7_F_PKCS7_CTRL, PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE); ret = 0; } break; case PKCS7_OP_GET_DETACHED_SIGNATURE: if (nid == NID_pkcs7_signed) { if (!p7->d.sign || !p7->d.sign->contents->d.ptr) ret = 1; else ret = 0; p7->detached = ret; } else { PKCS7err(PKCS7_F_PKCS7_CTRL, PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE); ret = 0; } break; default: PKCS7err(PKCS7_F_PKCS7_CTRL, PKCS7_R_UNKNOWN_OPERATION); ret = 0; } return (ret); } int PKCS7_content_new(PKCS7 *p7, int type) { PKCS7 *ret = NULL; if ((ret = PKCS7_new()) == NULL) goto err; if (!PKCS7_set_type(ret, type)) goto err; if (!PKCS7_set_content(p7, ret)) goto err; return (1); err: if (ret != NULL) PKCS7_free(ret); return (0); } int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data) { int i; i = OBJ_obj2nid(p7->type); switch (i) { case NID_pkcs7_signed: if (p7->d.sign->contents != NULL) PKCS7_free(p7->d.sign->contents); p7->d.sign->contents = p7_data; break; case NID_pkcs7_digest: if (p7->d.digest->contents != NULL) PKCS7_free(p7->d.digest->contents); p7->d.digest->contents = p7_data; break; case NID_pkcs7_data: case NID_pkcs7_enveloped: case NID_pkcs7_signedAndEnveloped: case NID_pkcs7_encrypted: default: PKCS7err(PKCS7_F_PKCS7_SET_CONTENT, PKCS7_R_UNSUPPORTED_CONTENT_TYPE); goto err; } return (1); err: return (0); } int PKCS7_set_type(PKCS7 *p7, int type) { ASN1_OBJECT *obj; /*PKCS7_content_free(p7);*/ obj=OBJ_nid2obj(type); /* will not fail */ switch (type) { case NID_pkcs7_signed: p7->type = obj; if ((p7->d.sign = PKCS7_SIGNED_new()) == NULL) goto err; if (!ASN1_INTEGER_set(p7->d.sign->version, 1)) { PKCS7_SIGNED_free(p7->d.sign); p7->d.sign = NULL; goto err; } break; case NID_pkcs7_data: p7->type = obj; if ((p7->d.data = M_ASN1_OCTET_STRING_new()) == NULL) goto err; break; case NID_pkcs7_signedAndEnveloped: p7->type = obj; if ((p7->d.signed_and_enveloped = PKCS7_SIGN_ENVELOPE_new()) == NULL) goto err; ASN1_INTEGER_set(p7->d.signed_and_enveloped->version, 1); if (!ASN1_INTEGER_set(p7->d.signed_and_enveloped->version, 1)) goto err; p7->d.signed_and_enveloped->enc_data->content_type = OBJ_nid2obj(NID_pkcs7_data); break; case NID_pkcs7_enveloped: p7->type = obj; if ((p7->d.enveloped = PKCS7_ENVELOPE_new()) == NULL) goto err; if (!ASN1_INTEGER_set(p7->d.enveloped->version, 0)) goto err; p7->d.enveloped->enc_data->content_type = OBJ_nid2obj(NID_pkcs7_data); break; case NID_pkcs7_encrypted: p7->type = obj; if ((p7->d.encrypted = PKCS7_ENCRYPT_new()) == NULL) goto err; if (!ASN1_INTEGER_set(p7->d.encrypted->version, 0)) goto err; p7->d.encrypted->enc_data->content_type = OBJ_nid2obj(NID_pkcs7_data); break; case NID_pkcs7_digest: p7->type = obj; if ((p7->d.digest = PKCS7_DIGEST_new()) == NULL) goto err; if (!ASN1_INTEGER_set(p7->d.digest->version, 0)) goto err; break; default: PKCS7err(PKCS7_F_PKCS7_SET_TYPE, PKCS7_R_UNSUPPORTED_CONTENT_TYPE); goto err; } return (1); err: return (0); } int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other) { p7->type = OBJ_nid2obj(type); p7->d.other = other; return 1; } int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *psi) { int i, j, nid; X509_ALGOR *alg; STACK_OF(PKCS7_SIGNER_INFO) *signer_sk; STACK_OF(X509_ALGOR) *md_sk; i = OBJ_obj2nid(p7->type); switch (i) { case NID_pkcs7_signed: signer_sk = p7->d.sign->signer_info; md_sk = p7->d.sign->md_algs; break; case NID_pkcs7_signedAndEnveloped: signer_sk = p7->d.signed_and_enveloped->signer_info; md_sk = p7->d.signed_and_enveloped->md_algs; break; default: PKCS7err(PKCS7_F_PKCS7_ADD_SIGNER, PKCS7_R_WRONG_CONTENT_TYPE); return (0); } nid = OBJ_obj2nid(psi->digest_alg->algorithm); /* If the digest is not currently listed, add it */ j = 0; for (i = 0; i < sk_X509_ALGOR_num(md_sk); i++) { alg = sk_X509_ALGOR_value(md_sk, i); if (OBJ_obj2nid(alg->algorithm) == nid) { j = 1; break; } } if (!j) /* we need to add another algorithm */ { if (!(alg = X509_ALGOR_new()) || !(alg->parameter = ASN1_TYPE_new())) { X509_ALGOR_free(alg); PKCS7err(PKCS7_F_PKCS7_ADD_SIGNER, ERR_R_MALLOC_FAILURE); return (0); } alg->algorithm = OBJ_nid2obj(nid); alg->parameter->type = V_ASN1_NULL; if (!sk_X509_ALGOR_push(md_sk, alg)) { X509_ALGOR_free(alg); return 0; } } if (!sk_PKCS7_SIGNER_INFO_push(signer_sk, psi)) return 0; return (1); } int PKCS7_add_certificate(PKCS7 *p7, X509 *x509) { int i; STACK_OF(X509) **sk; i = OBJ_obj2nid(p7->type); switch (i) { case NID_pkcs7_signed: sk = &(p7->d.sign->cert); break; case NID_pkcs7_signedAndEnveloped: sk = &(p7->d.signed_and_enveloped->cert); break; default: PKCS7err(PKCS7_F_PKCS7_ADD_CERTIFICATE, PKCS7_R_WRONG_CONTENT_TYPE); return (0); } if (*sk == NULL) *sk = sk_X509_new_null(); if (*sk == NULL) { PKCS7err(PKCS7_F_PKCS7_ADD_CERTIFICATE, ERR_R_MALLOC_FAILURE); return 0; } CRYPTO_add(&x509->references, 1, CRYPTO_LOCK_X509); if (!sk_X509_push(*sk, x509)) { X509_free(x509); return 0; } return (1); } int PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl) { int i; STACK_OF(X509_CRL) **sk; i = OBJ_obj2nid(p7->type); switch (i) { case NID_pkcs7_signed: sk = &(p7->d.sign->crl); break; case NID_pkcs7_signedAndEnveloped: sk = &(p7->d.signed_and_enveloped->crl); break; default: PKCS7err(PKCS7_F_PKCS7_ADD_CRL, PKCS7_R_WRONG_CONTENT_TYPE); return (0); } if (*sk == NULL) *sk = sk_X509_CRL_new_null(); if (*sk == NULL) { PKCS7err(PKCS7_F_PKCS7_ADD_CRL, ERR_R_MALLOC_FAILURE); return 0; } CRYPTO_add(&crl->references, 1, CRYPTO_LOCK_X509_CRL); if (!sk_X509_CRL_push(*sk, crl)) { X509_CRL_free(crl); return 0; } return (1); } int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, const EVP_MD *dgst) { int ret; /* We now need to add another PKCS7_SIGNER_INFO entry */ if (!ASN1_INTEGER_set(p7i->version, 1)) goto err; if (!X509_NAME_set(&p7i->issuer_and_serial->issuer, X509_get_issuer_name(x509))) goto err; /* because ASN1_INTEGER_set is used to set a 'long' we will do * things the ugly way. */ M_ASN1_INTEGER_free(p7i->issuer_and_serial->serial); if (!(p7i->issuer_and_serial->serial = M_ASN1_INTEGER_dup(X509_get_serialNumber(x509)))) goto err; /* lets keep the pkey around for a while */ CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY); p7i->pkey = pkey; /* Set the algorithms */ X509_ALGOR_set0(p7i->digest_alg, OBJ_nid2obj(EVP_MD_type(dgst)), V_ASN1_NULL, NULL); if (pkey->ameth && pkey->ameth->pkey_ctrl) { ret = pkey->ameth->pkey_ctrl(pkey, ASN1_PKEY_CTRL_PKCS7_SIGN, 0, p7i); if (ret > 0) return 1; if (ret != -2) { PKCS7err(PKCS7_F_PKCS7_SIGNER_INFO_SET, PKCS7_R_SIGNING_CTRL_FAILURE); return 0; } } PKCS7err(PKCS7_F_PKCS7_SIGNER_INFO_SET, PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE); err: return 0; } PKCS7_SIGNER_INFO * PKCS7_add_signature(PKCS7 *p7, X509 *x509, EVP_PKEY *pkey, const EVP_MD *dgst) { PKCS7_SIGNER_INFO *si = NULL; if (dgst == NULL) { int def_nid; if (EVP_PKEY_get_default_digest_nid(pkey, &def_nid) <= 0) goto err; dgst = EVP_get_digestbynid(def_nid); if (dgst == NULL) { PKCS7err(PKCS7_F_PKCS7_ADD_SIGNATURE, PKCS7_R_NO_DEFAULT_DIGEST); goto err; } } if ((si = PKCS7_SIGNER_INFO_new()) == NULL) goto err; if (!PKCS7_SIGNER_INFO_set(si, x509, pkey, dgst)) goto err; if (!PKCS7_add_signer(p7, si)) goto err; return (si); err: if (si) PKCS7_SIGNER_INFO_free(si); return (NULL); } int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md) { if (PKCS7_type_is_digest(p7)) { if (!(p7->d.digest->md->parameter = ASN1_TYPE_new())) { PKCS7err(PKCS7_F_PKCS7_SET_DIGEST, ERR_R_MALLOC_FAILURE); return 0; } p7->d.digest->md->parameter->type = V_ASN1_NULL; p7->d.digest->md->algorithm = OBJ_nid2obj(EVP_MD_nid(md)); return 1; } PKCS7err(PKCS7_F_PKCS7_SET_DIGEST, PKCS7_R_WRONG_CONTENT_TYPE); return 1; } STACK_OF(PKCS7_SIGNER_INFO) * PKCS7_get_signer_info(PKCS7 *p7) { if (PKCS7_type_is_signed(p7)) { return (p7->d.sign->signer_info); } else if (PKCS7_type_is_signedAndEnveloped(p7)) { return (p7->d.signed_and_enveloped->signer_info); } else return (NULL); } void PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk, X509_ALGOR **pdig, X509_ALGOR **psig) { if (pk) *pk = si->pkey; if (pdig) *pdig = si->digest_alg; if (psig) *psig = si->digest_enc_alg; } void PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc) { if (penc) *penc = ri->key_enc_algor; } PKCS7_RECIP_INFO * PKCS7_add_recipient(PKCS7 *p7, X509 *x509) { PKCS7_RECIP_INFO *ri; if ((ri = PKCS7_RECIP_INFO_new()) == NULL) goto err; if (!PKCS7_RECIP_INFO_set(ri, x509)) goto err; if (!PKCS7_add_recipient_info(p7, ri)) goto err; return ri; err: if (ri) PKCS7_RECIP_INFO_free(ri); return NULL; } int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri) { int i; STACK_OF(PKCS7_RECIP_INFO) *sk; i = OBJ_obj2nid(p7->type); switch (i) { case NID_pkcs7_signedAndEnveloped: sk = p7->d.signed_and_enveloped->recipientinfo; break; case NID_pkcs7_enveloped: sk = p7->d.enveloped->recipientinfo; break; default: PKCS7err(PKCS7_F_PKCS7_ADD_RECIPIENT_INFO, PKCS7_R_WRONG_CONTENT_TYPE); return (0); } if (!sk_PKCS7_RECIP_INFO_push(sk, ri)) return 0; return (1); } int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509) { int ret; EVP_PKEY *pkey = NULL; if (!ASN1_INTEGER_set(p7i->version, 0)) return 0; if (!X509_NAME_set(&p7i->issuer_and_serial->issuer, X509_get_issuer_name(x509))) return 0; M_ASN1_INTEGER_free(p7i->issuer_and_serial->serial); if (!(p7i->issuer_and_serial->serial = M_ASN1_INTEGER_dup(X509_get_serialNumber(x509)))) return 0; pkey = X509_get_pubkey(x509); if (!pkey || !pkey->ameth || !pkey->ameth->pkey_ctrl) { PKCS7err(PKCS7_F_PKCS7_RECIP_INFO_SET, PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE); goto err; } ret = pkey->ameth->pkey_ctrl(pkey, ASN1_PKEY_CTRL_PKCS7_ENCRYPT, 0, p7i); if (ret == -2) { PKCS7err(PKCS7_F_PKCS7_RECIP_INFO_SET, PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE); goto err; } if (ret <= 0) { PKCS7err(PKCS7_F_PKCS7_RECIP_INFO_SET, PKCS7_R_ENCRYPTION_CTRL_FAILURE); goto err; } EVP_PKEY_free(pkey); CRYPTO_add(&x509->references, 1, CRYPTO_LOCK_X509); p7i->cert = x509; return 1; err: if (pkey) EVP_PKEY_free(pkey); return 0; } X509 * PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si) { if (PKCS7_type_is_signed(p7)) return(X509_find_by_issuer_and_serial(p7->d.sign->cert, si->issuer_and_serial->issuer, si->issuer_and_serial->serial)); else return (NULL); } int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher) { int i; PKCS7_ENC_CONTENT *ec; i = OBJ_obj2nid(p7->type); switch (i) { case NID_pkcs7_signedAndEnveloped: ec = p7->d.signed_and_enveloped->enc_data; break; case NID_pkcs7_enveloped: ec = p7->d.enveloped->enc_data; break; default: PKCS7err(PKCS7_F_PKCS7_SET_CIPHER, PKCS7_R_WRONG_CONTENT_TYPE); return (0); } /* Check cipher OID exists and has data in it*/ i = EVP_CIPHER_type(cipher); if (i == NID_undef) { PKCS7err(PKCS7_F_PKCS7_SET_CIPHER, PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER); return (0); } ec->cipher = cipher; return 1; } int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7) { ASN1_OCTET_STRING *os = NULL; switch (OBJ_obj2nid(p7->type)) { case NID_pkcs7_data: os = p7->d.data; break; case NID_pkcs7_signedAndEnveloped: os = p7->d.signed_and_enveloped->enc_data->enc_data; if (os == NULL) { os = M_ASN1_OCTET_STRING_new(); p7->d.signed_and_enveloped->enc_data->enc_data = os; } break; case NID_pkcs7_enveloped: os = p7->d.enveloped->enc_data->enc_data; if (os == NULL) { os = M_ASN1_OCTET_STRING_new(); p7->d.enveloped->enc_data->enc_data = os; } break; case NID_pkcs7_signed: os = p7->d.sign->contents->d.data; break; default: os = NULL; break; } if (os == NULL) return 0; os->flags |= ASN1_STRING_FLAG_NDEF; *boundary = &os->data; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs7/pkcs7err.c0000644000175000017500000002337712360020706021223 0ustar /* $OpenBSD: pkcs7err.c,v 1.10 2014/06/29 17:05:36 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_PKCS7,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_PKCS7,0,reason) static ERR_STRING_DATA PKCS7_str_functs[]= { {ERR_FUNC(PKCS7_F_B64_READ_PKCS7), "B64_READ_PKCS7"}, {ERR_FUNC(PKCS7_F_B64_WRITE_PKCS7), "B64_WRITE_PKCS7"}, {ERR_FUNC(PKCS7_F_DO_PKCS7_SIGNED_ATTRIB), "DO_PKCS7_SIGNED_ATTRIB"}, {ERR_FUNC(PKCS7_F_I2D_PKCS7_BIO_STREAM), "i2d_PKCS7_bio_stream"}, {ERR_FUNC(PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME), "PKCS7_add0_attrib_signing_time"}, {ERR_FUNC(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP), "PKCS7_add_attrib_smimecap"}, {ERR_FUNC(PKCS7_F_PKCS7_ADD_CERTIFICATE), "PKCS7_add_certificate"}, {ERR_FUNC(PKCS7_F_PKCS7_ADD_CRL), "PKCS7_add_crl"}, {ERR_FUNC(PKCS7_F_PKCS7_ADD_RECIPIENT_INFO), "PKCS7_add_recipient_info"}, {ERR_FUNC(PKCS7_F_PKCS7_ADD_SIGNATURE), "PKCS7_add_signature"}, {ERR_FUNC(PKCS7_F_PKCS7_ADD_SIGNER), "PKCS7_add_signer"}, {ERR_FUNC(PKCS7_F_PKCS7_BIO_ADD_DIGEST), "PKCS7_BIO_ADD_DIGEST"}, {ERR_FUNC(PKCS7_F_PKCS7_COPY_EXISTING_DIGEST), "PKCS7_COPY_EXISTING_DIGEST"}, {ERR_FUNC(PKCS7_F_PKCS7_CTRL), "PKCS7_ctrl"}, {ERR_FUNC(PKCS7_F_PKCS7_DATADECODE), "PKCS7_dataDecode"}, {ERR_FUNC(PKCS7_F_PKCS7_DATAFINAL), "PKCS7_dataFinal"}, {ERR_FUNC(PKCS7_F_PKCS7_DATAINIT), "PKCS7_dataInit"}, {ERR_FUNC(PKCS7_F_PKCS7_DATASIGN), "PKCS7_DATASIGN"}, {ERR_FUNC(PKCS7_F_PKCS7_DATAVERIFY), "PKCS7_dataVerify"}, {ERR_FUNC(PKCS7_F_PKCS7_DECRYPT), "PKCS7_decrypt"}, {ERR_FUNC(PKCS7_F_PKCS7_DECRYPT_RINFO), "PKCS7_DECRYPT_RINFO"}, {ERR_FUNC(PKCS7_F_PKCS7_ENCODE_RINFO), "PKCS7_ENCODE_RINFO"}, {ERR_FUNC(PKCS7_F_PKCS7_ENCRYPT), "PKCS7_encrypt"}, {ERR_FUNC(PKCS7_F_PKCS7_FINAL), "PKCS7_final"}, {ERR_FUNC(PKCS7_F_PKCS7_FIND_DIGEST), "PKCS7_FIND_DIGEST"}, {ERR_FUNC(PKCS7_F_PKCS7_GET0_SIGNERS), "PKCS7_get0_signers"}, {ERR_FUNC(PKCS7_F_PKCS7_RECIP_INFO_SET), "PKCS7_RECIP_INFO_set"}, {ERR_FUNC(PKCS7_F_PKCS7_SET_CIPHER), "PKCS7_set_cipher"}, {ERR_FUNC(PKCS7_F_PKCS7_SET_CONTENT), "PKCS7_set_content"}, {ERR_FUNC(PKCS7_F_PKCS7_SET_DIGEST), "PKCS7_set_digest"}, {ERR_FUNC(PKCS7_F_PKCS7_SET_TYPE), "PKCS7_set_type"}, {ERR_FUNC(PKCS7_F_PKCS7_SIGN), "PKCS7_sign"}, {ERR_FUNC(PKCS7_F_PKCS7_SIGNATUREVERIFY), "PKCS7_signatureVerify"}, {ERR_FUNC(PKCS7_F_PKCS7_SIGNER_INFO_SET), "PKCS7_SIGNER_INFO_set"}, {ERR_FUNC(PKCS7_F_PKCS7_SIGNER_INFO_SIGN), "PKCS7_SIGNER_INFO_sign"}, {ERR_FUNC(PKCS7_F_PKCS7_SIGN_ADD_SIGNER), "PKCS7_sign_add_signer"}, {ERR_FUNC(PKCS7_F_PKCS7_SIMPLE_SMIMECAP), "PKCS7_simple_smimecap"}, {ERR_FUNC(PKCS7_F_PKCS7_VERIFY), "PKCS7_verify"}, {ERR_FUNC(PKCS7_F_SMIME_READ_PKCS7), "SMIME_read_PKCS7"}, {ERR_FUNC(PKCS7_F_SMIME_TEXT), "SMIME_text"}, {0, NULL} }; static ERR_STRING_DATA PKCS7_str_reasons[]= { {ERR_REASON(PKCS7_R_CERTIFICATE_VERIFY_ERROR), "certificate verify error"}, {ERR_REASON(PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER), "cipher has no object identifier"}, {ERR_REASON(PKCS7_R_CIPHER_NOT_INITIALIZED), "cipher not initialized"}, {ERR_REASON(PKCS7_R_CONTENT_AND_DATA_PRESENT), "content and data present"}, {ERR_REASON(PKCS7_R_CTRL_ERROR) , "ctrl error"}, {ERR_REASON(PKCS7_R_DECODE_ERROR) , "decode error"}, {ERR_REASON(PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH), "decrypted key is wrong length"}, {ERR_REASON(PKCS7_R_DECRYPT_ERROR) , "decrypt error"}, {ERR_REASON(PKCS7_R_DIGEST_FAILURE) , "digest failure"}, {ERR_REASON(PKCS7_R_ENCRYPTION_CTRL_FAILURE), "encryption ctrl failure"}, {ERR_REASON(PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE), "encryption not supported for this key type"}, {ERR_REASON(PKCS7_R_ERROR_ADDING_RECIPIENT), "error adding recipient"}, {ERR_REASON(PKCS7_R_ERROR_SETTING_CIPHER), "error setting cipher"}, {ERR_REASON(PKCS7_R_INVALID_MIME_TYPE) , "invalid mime type"}, {ERR_REASON(PKCS7_R_INVALID_NULL_POINTER), "invalid null pointer"}, {ERR_REASON(PKCS7_R_MIME_NO_CONTENT_TYPE), "mime no content type"}, {ERR_REASON(PKCS7_R_MIME_PARSE_ERROR) , "mime parse error"}, {ERR_REASON(PKCS7_R_MIME_SIG_PARSE_ERROR), "mime sig parse error"}, {ERR_REASON(PKCS7_R_MISSING_CERIPEND_INFO), "missing ceripend info"}, {ERR_REASON(PKCS7_R_NO_CONTENT) , "no content"}, {ERR_REASON(PKCS7_R_NO_CONTENT_TYPE) , "no content type"}, {ERR_REASON(PKCS7_R_NO_DEFAULT_DIGEST) , "no default digest"}, {ERR_REASON(PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND), "no matching digest type found"}, {ERR_REASON(PKCS7_R_NO_MULTIPART_BODY_FAILURE), "no multipart body failure"}, {ERR_REASON(PKCS7_R_NO_MULTIPART_BOUNDARY), "no multipart boundary"}, {ERR_REASON(PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE), "no recipient matches certificate"}, {ERR_REASON(PKCS7_R_NO_RECIPIENT_MATCHES_KEY), "no recipient matches key"}, {ERR_REASON(PKCS7_R_NO_SIGNATURES_ON_DATA), "no signatures on data"}, {ERR_REASON(PKCS7_R_NO_SIGNERS) , "no signers"}, {ERR_REASON(PKCS7_R_NO_SIG_CONTENT_TYPE) , "no sig content type"}, {ERR_REASON(PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE), "operation not supported on this type"}, {ERR_REASON(PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR), "pkcs7 add signature error"}, {ERR_REASON(PKCS7_R_PKCS7_ADD_SIGNER_ERROR), "pkcs7 add signer error"}, {ERR_REASON(PKCS7_R_PKCS7_DATAFINAL) , "pkcs7 datafinal"}, {ERR_REASON(PKCS7_R_PKCS7_DATAFINAL_ERROR), "pkcs7 datafinal error"}, {ERR_REASON(PKCS7_R_PKCS7_DATASIGN) , "pkcs7 datasign"}, {ERR_REASON(PKCS7_R_PKCS7_PARSE_ERROR) , "pkcs7 parse error"}, {ERR_REASON(PKCS7_R_PKCS7_SIG_PARSE_ERROR), "pkcs7 sig parse error"}, {ERR_REASON(PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE), "private key does not match certificate"}, {ERR_REASON(PKCS7_R_SIGNATURE_FAILURE) , "signature failure"}, {ERR_REASON(PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND), "signer certificate not found"}, {ERR_REASON(PKCS7_R_SIGNING_CTRL_FAILURE), "signing ctrl failure"}, {ERR_REASON(PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE), "signing not supported for this key type"}, {ERR_REASON(PKCS7_R_SIG_INVALID_MIME_TYPE), "sig invalid mime type"}, {ERR_REASON(PKCS7_R_SMIME_TEXT_ERROR) , "smime text error"}, {ERR_REASON(PKCS7_R_UNABLE_TO_FIND_CERTIFICATE), "unable to find certificate"}, {ERR_REASON(PKCS7_R_UNABLE_TO_FIND_MEM_BIO), "unable to find mem bio"}, {ERR_REASON(PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST), "unable to find message digest"}, {ERR_REASON(PKCS7_R_UNKNOWN_DIGEST_TYPE) , "unknown digest type"}, {ERR_REASON(PKCS7_R_UNKNOWN_OPERATION) , "unknown operation"}, {ERR_REASON(PKCS7_R_UNSUPPORTED_CIPHER_TYPE), "unsupported cipher type"}, {ERR_REASON(PKCS7_R_UNSUPPORTED_CONTENT_TYPE), "unsupported content type"}, {ERR_REASON(PKCS7_R_WRONG_CONTENT_TYPE) , "wrong content type"}, {ERR_REASON(PKCS7_R_WRONG_PKCS7_TYPE) , "wrong pkcs7 type"}, {0, NULL} }; #endif void ERR_load_PKCS7_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(PKCS7_str_functs[0].error) == NULL) { ERR_load_strings(0, PKCS7_str_functs); ERR_load_strings(0, PKCS7_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs7/pk7_doit.c0000644000175000017500000007345112360020706021201 0ustar /* $OpenBSD: pk7_doit.c,v 1.26 2014/07/10 13:58:23 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include static int add_attribute(STACK_OF(X509_ATTRIBUTE) **sk, int nid, int atrtype, void *value); static ASN1_TYPE *get_attribute(STACK_OF(X509_ATTRIBUTE) *sk, int nid); static int PKCS7_type_is_other(PKCS7* p7) { int isOther = 1; int nid = OBJ_obj2nid(p7->type); switch (nid ) { case NID_pkcs7_data: case NID_pkcs7_signed: case NID_pkcs7_enveloped: case NID_pkcs7_signedAndEnveloped: case NID_pkcs7_digest: case NID_pkcs7_encrypted: isOther = 0; break; default: isOther = 1; } return isOther; } static ASN1_OCTET_STRING * PKCS7_get_octet_string(PKCS7 *p7) { if (PKCS7_type_is_data(p7)) return p7->d.data; if (PKCS7_type_is_other(p7) && p7->d.other && (p7->d.other->type == V_ASN1_OCTET_STRING)) return p7->d.other->value.octet_string; return NULL; } static int PKCS7_bio_add_digest(BIO **pbio, X509_ALGOR *alg) { BIO *btmp; const EVP_MD *md; if ((btmp = BIO_new(BIO_f_md())) == NULL) { PKCS7err(PKCS7_F_PKCS7_BIO_ADD_DIGEST, ERR_R_BIO_LIB); goto err; } md = EVP_get_digestbyobj(alg->algorithm); if (md == NULL) { PKCS7err(PKCS7_F_PKCS7_BIO_ADD_DIGEST, PKCS7_R_UNKNOWN_DIGEST_TYPE); goto err; } BIO_set_md(btmp, md); if (*pbio == NULL) *pbio = btmp; else if (!BIO_push(*pbio, btmp)) { PKCS7err(PKCS7_F_PKCS7_BIO_ADD_DIGEST, ERR_R_BIO_LIB); goto err; } btmp = NULL; return 1; err: if (btmp) BIO_free(btmp); return 0; } static int pkcs7_encode_rinfo(PKCS7_RECIP_INFO *ri, unsigned char *key, int keylen) { EVP_PKEY_CTX *pctx = NULL; EVP_PKEY *pkey = NULL; unsigned char *ek = NULL; int ret = 0; size_t eklen; pkey = X509_get_pubkey(ri->cert); if (!pkey) return 0; pctx = EVP_PKEY_CTX_new(pkey, NULL); if (!pctx) return 0; if (EVP_PKEY_encrypt_init(pctx) <= 0) goto err; if (EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_ENCRYPT, EVP_PKEY_CTRL_PKCS7_ENCRYPT, 0, ri) <= 0) { PKCS7err(PKCS7_F_PKCS7_ENCODE_RINFO, PKCS7_R_CTRL_ERROR); goto err; } if (EVP_PKEY_encrypt(pctx, NULL, &eklen, key, keylen) <= 0) goto err; ek = malloc(eklen); if (ek == NULL) { PKCS7err(PKCS7_F_PKCS7_ENCODE_RINFO, ERR_R_MALLOC_FAILURE); goto err; } if (EVP_PKEY_encrypt(pctx, ek, &eklen, key, keylen) <= 0) goto err; ASN1_STRING_set0(ri->enc_key, ek, eklen); ek = NULL; ret = 1; err: if (pkey) EVP_PKEY_free(pkey); if (pctx) EVP_PKEY_CTX_free(pctx); free(ek); return ret; } static int pkcs7_decrypt_rinfo(unsigned char **pek, int *peklen, PKCS7_RECIP_INFO *ri, EVP_PKEY *pkey) { EVP_PKEY_CTX *pctx = NULL; unsigned char *ek = NULL; size_t eklen; int ret = -1; pctx = EVP_PKEY_CTX_new(pkey, NULL); if (!pctx) return -1; if (EVP_PKEY_decrypt_init(pctx) <= 0) goto err; if (EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DECRYPT, EVP_PKEY_CTRL_PKCS7_DECRYPT, 0, ri) <= 0) { PKCS7err(PKCS7_F_PKCS7_DECRYPT_RINFO, PKCS7_R_CTRL_ERROR); goto err; } if (EVP_PKEY_decrypt(pctx, NULL, &eklen, ri->enc_key->data, ri->enc_key->length) <= 0) goto err; ek = malloc(eklen); if (ek == NULL) { PKCS7err(PKCS7_F_PKCS7_DECRYPT_RINFO, ERR_R_MALLOC_FAILURE); goto err; } if (EVP_PKEY_decrypt(pctx, ek, &eklen, ri->enc_key->data, ri->enc_key->length) <= 0) { ret = 0; PKCS7err(PKCS7_F_PKCS7_DECRYPT_RINFO, ERR_R_EVP_LIB); goto err; } ret = 1; if (*pek) { OPENSSL_cleanse(*pek, *peklen); free(*pek); } *pek = ek; *peklen = eklen; err: if (pctx) EVP_PKEY_CTX_free(pctx); if (!ret && ek) free(ek); return ret; } BIO * PKCS7_dataInit(PKCS7 *p7, BIO *bio) { int i; BIO *out = NULL, *btmp = NULL; X509_ALGOR *xa = NULL; const EVP_CIPHER *evp_cipher = NULL; STACK_OF(X509_ALGOR) *md_sk = NULL; STACK_OF(PKCS7_RECIP_INFO) *rsk = NULL; X509_ALGOR *xalg = NULL; PKCS7_RECIP_INFO *ri = NULL; ASN1_OCTET_STRING *os = NULL; i = OBJ_obj2nid(p7->type); p7->state = PKCS7_S_HEADER; switch (i) { case NID_pkcs7_signed: md_sk = p7->d.sign->md_algs; os = PKCS7_get_octet_string(p7->d.sign->contents); break; case NID_pkcs7_signedAndEnveloped: rsk = p7->d.signed_and_enveloped->recipientinfo; md_sk = p7->d.signed_and_enveloped->md_algs; xalg = p7->d.signed_and_enveloped->enc_data->algorithm; evp_cipher = p7->d.signed_and_enveloped->enc_data->cipher; if (evp_cipher == NULL) { PKCS7err(PKCS7_F_PKCS7_DATAINIT, PKCS7_R_CIPHER_NOT_INITIALIZED); goto err; } break; case NID_pkcs7_enveloped: rsk = p7->d.enveloped->recipientinfo; xalg = p7->d.enveloped->enc_data->algorithm; evp_cipher = p7->d.enveloped->enc_data->cipher; if (evp_cipher == NULL) { PKCS7err(PKCS7_F_PKCS7_DATAINIT, PKCS7_R_CIPHER_NOT_INITIALIZED); goto err; } break; case NID_pkcs7_digest: xa = p7->d.digest->md; os = PKCS7_get_octet_string(p7->d.digest->contents); break; case NID_pkcs7_data: break; default: PKCS7err(PKCS7_F_PKCS7_DATAINIT, PKCS7_R_UNSUPPORTED_CONTENT_TYPE); goto err; } for (i = 0; i < sk_X509_ALGOR_num(md_sk); i++) if (!PKCS7_bio_add_digest(&out, sk_X509_ALGOR_value(md_sk, i))) goto err; if (xa && !PKCS7_bio_add_digest(&out, xa)) goto err; if (evp_cipher != NULL) { unsigned char key[EVP_MAX_KEY_LENGTH]; unsigned char iv[EVP_MAX_IV_LENGTH]; int keylen, ivlen; EVP_CIPHER_CTX *ctx; if ((btmp = BIO_new(BIO_f_cipher())) == NULL) { PKCS7err(PKCS7_F_PKCS7_DATAINIT, ERR_R_BIO_LIB); goto err; } BIO_get_cipher_ctx(btmp, &ctx); keylen = EVP_CIPHER_key_length(evp_cipher); ivlen = EVP_CIPHER_iv_length(evp_cipher); xalg->algorithm = OBJ_nid2obj(EVP_CIPHER_type(evp_cipher)); if (ivlen > 0) if (RAND_pseudo_bytes(iv, ivlen) <= 0) goto err; if (EVP_CipherInit_ex(ctx, evp_cipher, NULL, NULL, NULL, 1) <= 0) goto err; if (EVP_CIPHER_CTX_rand_key(ctx, key) <= 0) goto err; if (EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, 1) <= 0) goto err; if (ivlen > 0) { if (xalg->parameter == NULL) { xalg->parameter = ASN1_TYPE_new(); if (xalg->parameter == NULL) goto err; } if (EVP_CIPHER_param_to_asn1(ctx, xalg->parameter) < 0) goto err; } /* Lets do the pub key stuff :-) */ for (i = 0; i < sk_PKCS7_RECIP_INFO_num(rsk); i++) { ri = sk_PKCS7_RECIP_INFO_value(rsk, i); if (pkcs7_encode_rinfo(ri, key, keylen) <= 0) goto err; } OPENSSL_cleanse(key, keylen); if (out == NULL) out = btmp; else BIO_push(out, btmp); btmp = NULL; } if (bio == NULL) { if (PKCS7_is_detached(p7)) bio = BIO_new(BIO_s_null()); else if (os && os->length > 0) bio = BIO_new_mem_buf(os->data, os->length); if (bio == NULL) { bio = BIO_new(BIO_s_mem()); if (bio == NULL) goto err; BIO_set_mem_eof_return(bio, 0); } } if (out) BIO_push(out, bio); else out = bio; bio = NULL; if (0) { err: if (out != NULL) BIO_free_all(out); if (btmp != NULL) BIO_free_all(btmp); out = NULL; } return (out); } static int pkcs7_cmp_ri(PKCS7_RECIP_INFO *ri, X509 *pcert) { int ret; ret = X509_NAME_cmp(ri->issuer_and_serial->issuer, pcert->cert_info->issuer); if (ret) return ret; return M_ASN1_INTEGER_cmp(pcert->cert_info->serialNumber, ri->issuer_and_serial->serial); } /* int */ BIO * PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert) { int i, j; BIO *out = NULL, *btmp = NULL, *etmp = NULL, *bio = NULL; X509_ALGOR *xa; ASN1_OCTET_STRING *data_body = NULL; const EVP_MD *evp_md; const EVP_CIPHER *evp_cipher = NULL; EVP_CIPHER_CTX *evp_ctx = NULL; X509_ALGOR *enc_alg = NULL; STACK_OF(X509_ALGOR) *md_sk = NULL; STACK_OF(PKCS7_RECIP_INFO) *rsk = NULL; PKCS7_RECIP_INFO *ri = NULL; unsigned char *ek = NULL, *tkey = NULL; int eklen = 0, tkeylen = 0; i = OBJ_obj2nid(p7->type); p7->state = PKCS7_S_HEADER; switch (i) { case NID_pkcs7_signed: data_body = PKCS7_get_octet_string(p7->d.sign->contents); md_sk = p7->d.sign->md_algs; break; case NID_pkcs7_signedAndEnveloped: rsk = p7->d.signed_and_enveloped->recipientinfo; md_sk = p7->d.signed_and_enveloped->md_algs; data_body = p7->d.signed_and_enveloped->enc_data->enc_data; enc_alg = p7->d.signed_and_enveloped->enc_data->algorithm; evp_cipher = EVP_get_cipherbyobj(enc_alg->algorithm); if (evp_cipher == NULL) { PKCS7err(PKCS7_F_PKCS7_DATADECODE, PKCS7_R_UNSUPPORTED_CIPHER_TYPE); goto err; } break; case NID_pkcs7_enveloped: rsk = p7->d.enveloped->recipientinfo; enc_alg = p7->d.enveloped->enc_data->algorithm; data_body = p7->d.enveloped->enc_data->enc_data; evp_cipher = EVP_get_cipherbyobj(enc_alg->algorithm); if (evp_cipher == NULL) { PKCS7err(PKCS7_F_PKCS7_DATADECODE, PKCS7_R_UNSUPPORTED_CIPHER_TYPE); goto err; } break; default: PKCS7err(PKCS7_F_PKCS7_DATADECODE, PKCS7_R_UNSUPPORTED_CONTENT_TYPE); goto err; } /* We will be checking the signature */ if (md_sk != NULL) { for (i = 0; i < sk_X509_ALGOR_num(md_sk); i++) { xa = sk_X509_ALGOR_value(md_sk, i); if ((btmp = BIO_new(BIO_f_md())) == NULL) { PKCS7err(PKCS7_F_PKCS7_DATADECODE, ERR_R_BIO_LIB); goto err; } j = OBJ_obj2nid(xa->algorithm); evp_md = EVP_get_digestbynid(j); if (evp_md == NULL) { PKCS7err(PKCS7_F_PKCS7_DATADECODE, PKCS7_R_UNKNOWN_DIGEST_TYPE); goto err; } BIO_set_md(btmp, evp_md); if (out == NULL) out = btmp; else BIO_push(out, btmp); btmp = NULL; } } if (evp_cipher != NULL) { #if 0 unsigned char key[EVP_MAX_KEY_LENGTH]; unsigned char iv[EVP_MAX_IV_LENGTH]; unsigned char *p; int keylen, ivlen; int max; X509_OBJECT ret; #endif if ((etmp = BIO_new(BIO_f_cipher())) == NULL) { PKCS7err(PKCS7_F_PKCS7_DATADECODE, ERR_R_BIO_LIB); goto err; } /* It was encrypted, we need to decrypt the secret key * with the private key */ /* Find the recipientInfo which matches the passed certificate * (if any) */ if (pcert) { for (i = 0; i < sk_PKCS7_RECIP_INFO_num(rsk); i++) { ri = sk_PKCS7_RECIP_INFO_value(rsk, i); if (!pkcs7_cmp_ri(ri, pcert)) break; ri = NULL; } if (ri == NULL) { PKCS7err(PKCS7_F_PKCS7_DATADECODE, PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE); goto err; } } /* If we haven't got a certificate try each ri in turn */ if (pcert == NULL) { /* Always attempt to decrypt all rinfo even * after sucess as a defence against MMA timing * attacks. */ for (i = 0; i < sk_PKCS7_RECIP_INFO_num(rsk); i++) { ri = sk_PKCS7_RECIP_INFO_value(rsk, i); if (pkcs7_decrypt_rinfo(&ek, &eklen, ri, pkey) < 0) goto err; ERR_clear_error(); } } else { /* Only exit on fatal errors, not decrypt failure */ if (pkcs7_decrypt_rinfo(&ek, &eklen, ri, pkey) < 0) goto err; ERR_clear_error(); } evp_ctx = NULL; BIO_get_cipher_ctx(etmp, &evp_ctx); if (EVP_CipherInit_ex(evp_ctx, evp_cipher, NULL, NULL, NULL, 0) <= 0) goto err; if (EVP_CIPHER_asn1_to_param(evp_ctx, enc_alg->parameter) < 0) goto err; /* Generate random key as MMA defence */ tkeylen = EVP_CIPHER_CTX_key_length(evp_ctx); tkey = malloc(tkeylen); if (!tkey) goto err; if (EVP_CIPHER_CTX_rand_key(evp_ctx, tkey) <= 0) goto err; if (ek == NULL) { ek = tkey; eklen = tkeylen; tkey = NULL; } if (eklen != EVP_CIPHER_CTX_key_length(evp_ctx)) { /* Some S/MIME clients don't use the same key * and effective key length. The key length is * determined by the size of the decrypted RSA key. */ if (!EVP_CIPHER_CTX_set_key_length(evp_ctx, eklen)) { /* Use random key as MMA defence */ OPENSSL_cleanse(ek, eklen); free(ek); ek = tkey; eklen = tkeylen; tkey = NULL; } } /* Clear errors so we don't leak information useful in MMA */ ERR_clear_error(); if (EVP_CipherInit_ex(evp_ctx, NULL, NULL, ek, NULL, 0) <= 0) goto err; if (ek) { OPENSSL_cleanse(ek, eklen); free(ek); ek = NULL; } if (tkey) { OPENSSL_cleanse(tkey, tkeylen); free(tkey); tkey = NULL; } if (out == NULL) out = etmp; else BIO_push(out, etmp); etmp = NULL; } #if 1 if (PKCS7_is_detached(p7) || (in_bio != NULL)) { bio = in_bio; } else { #if 0 bio = BIO_new(BIO_s_mem()); /* We need to set this so that when we have read all * the data, the encrypt BIO, if present, will read * EOF and encode the last few bytes */ BIO_set_mem_eof_return(bio, 0); if (data_body != NULL && data_body->length > 0) BIO_write(bio, (char *)data_body->data, data_body->length); #else if (data_body != NULL && data_body->length > 0) bio = BIO_new_mem_buf(data_body->data, data_body->length); else { bio = BIO_new(BIO_s_mem()); BIO_set_mem_eof_return(bio, 0); } if (bio == NULL) goto err; #endif } BIO_push(out, bio); bio = NULL; #endif if (0) { err: if (ek) { OPENSSL_cleanse(ek, eklen); free(ek); } if (tkey) { OPENSSL_cleanse(tkey, tkeylen); free(tkey); } if (out != NULL) BIO_free_all(out); if (btmp != NULL) BIO_free_all(btmp); if (etmp != NULL) BIO_free_all(etmp); if (bio != NULL) BIO_free_all(bio); out = NULL; } return (out); } static BIO * PKCS7_find_digest(EVP_MD_CTX **pmd, BIO *bio, int nid) { for (;;) { bio = BIO_find_type(bio, BIO_TYPE_MD); if (bio == NULL) { PKCS7err(PKCS7_F_PKCS7_FIND_DIGEST, PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST); return NULL; } BIO_get_md_ctx(bio, pmd); if (*pmd == NULL) { PKCS7err(PKCS7_F_PKCS7_FIND_DIGEST, ERR_R_INTERNAL_ERROR); return NULL; } if (EVP_MD_CTX_type(*pmd) == nid) return bio; bio = BIO_next(bio); } return NULL; } static int do_pkcs7_signed_attrib(PKCS7_SIGNER_INFO *si, EVP_MD_CTX *mctx) { unsigned char md_data[EVP_MAX_MD_SIZE]; unsigned int md_len; /* Add signing time if not already present */ if (!PKCS7_get_signed_attribute(si, NID_pkcs9_signingTime)) { if (!PKCS7_add0_attrib_signing_time(si, NULL)) { PKCS7err(PKCS7_F_DO_PKCS7_SIGNED_ATTRIB, ERR_R_MALLOC_FAILURE); return 0; } } /* Add digest */ if (!EVP_DigestFinal_ex(mctx, md_data, &md_len)) { PKCS7err(PKCS7_F_DO_PKCS7_SIGNED_ATTRIB, ERR_R_EVP_LIB); return 0; } if (!PKCS7_add1_attrib_digest(si, md_data, md_len)) { PKCS7err(PKCS7_F_DO_PKCS7_SIGNED_ATTRIB, ERR_R_MALLOC_FAILURE); return 0; } /* Now sign the attributes */ if (!PKCS7_SIGNER_INFO_sign(si)) return 0; return 1; } int PKCS7_dataFinal(PKCS7 *p7, BIO *bio) { int ret = 0; int i, j; BIO *btmp; PKCS7_SIGNER_INFO *si; EVP_MD_CTX *mdc, ctx_tmp; STACK_OF(X509_ATTRIBUTE) *sk; STACK_OF(PKCS7_SIGNER_INFO) *si_sk = NULL; ASN1_OCTET_STRING *os = NULL; EVP_MD_CTX_init(&ctx_tmp); i = OBJ_obj2nid(p7->type); p7->state = PKCS7_S_HEADER; switch (i) { case NID_pkcs7_data: os = p7->d.data; break; case NID_pkcs7_signedAndEnveloped: /* XXX */ si_sk = p7->d.signed_and_enveloped->signer_info; os = p7->d.signed_and_enveloped->enc_data->enc_data; if (!os) { os = M_ASN1_OCTET_STRING_new(); if (!os) { PKCS7err(PKCS7_F_PKCS7_DATAFINAL, ERR_R_MALLOC_FAILURE); goto err; } p7->d.signed_and_enveloped->enc_data->enc_data = os; } break; case NID_pkcs7_enveloped: /* XXX */ os = p7->d.enveloped->enc_data->enc_data; if (!os) { os = M_ASN1_OCTET_STRING_new(); if (!os) { PKCS7err(PKCS7_F_PKCS7_DATAFINAL, ERR_R_MALLOC_FAILURE); goto err; } p7->d.enveloped->enc_data->enc_data = os; } break; case NID_pkcs7_signed: si_sk = p7->d.sign->signer_info; os = PKCS7_get_octet_string(p7->d.sign->contents); if (!PKCS7_is_detached(p7) && os == NULL) { PKCS7err(PKCS7_F_PKCS7_DATAFINAL, PKCS7_R_DECODE_ERROR); goto err; } /* If detached data then the content is excluded */ if (PKCS7_type_is_data(p7->d.sign->contents) && p7->detached) { M_ASN1_OCTET_STRING_free(os); p7->d.sign->contents->d.data = NULL; } break; case NID_pkcs7_digest: os = PKCS7_get_octet_string(p7->d.digest->contents); if (os == NULL) { PKCS7err(PKCS7_F_PKCS7_DATAFINAL, PKCS7_R_DECODE_ERROR); goto err; } /* If detached data then the content is excluded */ if (PKCS7_type_is_data(p7->d.digest->contents) && p7->detached) { M_ASN1_OCTET_STRING_free(os); p7->d.digest->contents->d.data = NULL; } break; default: PKCS7err(PKCS7_F_PKCS7_DATAFINAL, PKCS7_R_UNSUPPORTED_CONTENT_TYPE); goto err; } if (si_sk != NULL) { for (i = 0; i < sk_PKCS7_SIGNER_INFO_num(si_sk); i++) { si = sk_PKCS7_SIGNER_INFO_value(si_sk, i); if (si->pkey == NULL) continue; j = OBJ_obj2nid(si->digest_alg->algorithm); btmp = bio; btmp = PKCS7_find_digest(&mdc, btmp, j); if (btmp == NULL) goto err; /* We now have the EVP_MD_CTX, lets do the * signing. */ if (!EVP_MD_CTX_copy_ex(&ctx_tmp, mdc)) goto err; sk = si->auth_attr; /* If there are attributes, we add the digest * attribute and only sign the attributes */ if (sk_X509_ATTRIBUTE_num(sk) > 0) { if (!do_pkcs7_signed_attrib(si, &ctx_tmp)) goto err; } else { unsigned char *abuf = NULL; unsigned int abuflen; abuflen = EVP_PKEY_size(si->pkey); abuf = malloc(abuflen); if (!abuf) goto err; if (!EVP_SignFinal(&ctx_tmp, abuf, &abuflen, si->pkey)) { PKCS7err(PKCS7_F_PKCS7_DATAFINAL, ERR_R_EVP_LIB); goto err; } ASN1_STRING_set0(si->enc_digest, abuf, abuflen); } } } else if (i == NID_pkcs7_digest) { unsigned char md_data[EVP_MAX_MD_SIZE]; unsigned int md_len; if (!PKCS7_find_digest(&mdc, bio, OBJ_obj2nid(p7->d.digest->md->algorithm))) goto err; if (!EVP_DigestFinal_ex(mdc, md_data, &md_len)) goto err; M_ASN1_OCTET_STRING_set(p7->d.digest->digest, md_data, md_len); } if (!PKCS7_is_detached(p7) && !(os->flags & ASN1_STRING_FLAG_NDEF)) { char *cont; long contlen; btmp = BIO_find_type(bio, BIO_TYPE_MEM); if (btmp == NULL) { PKCS7err(PKCS7_F_PKCS7_DATAFINAL, PKCS7_R_UNABLE_TO_FIND_MEM_BIO); goto err; } contlen = BIO_get_mem_data(btmp, &cont); /* Mark the BIO read only then we can use its copy of the data * instead of making an extra copy. */ BIO_set_flags(btmp, BIO_FLAGS_MEM_RDONLY); BIO_set_mem_eof_return(btmp, 0); ASN1_STRING_set0(os, (unsigned char *)cont, contlen); } ret = 1; err: EVP_MD_CTX_cleanup(&ctx_tmp); return (ret); } int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si) { EVP_MD_CTX mctx; EVP_PKEY_CTX *pctx; unsigned char *abuf = NULL; int alen; size_t siglen; const EVP_MD *md = NULL; md = EVP_get_digestbyobj(si->digest_alg->algorithm); if (md == NULL) return 0; EVP_MD_CTX_init(&mctx); if (EVP_DigestSignInit(&mctx, &pctx, md, NULL, si->pkey) <= 0) goto err; if (EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_SIGN, EVP_PKEY_CTRL_PKCS7_SIGN, 0, si) <= 0) { PKCS7err(PKCS7_F_PKCS7_SIGNER_INFO_SIGN, PKCS7_R_CTRL_ERROR); goto err; } alen = ASN1_item_i2d((ASN1_VALUE *)si->auth_attr, &abuf, ASN1_ITEM_rptr(PKCS7_ATTR_SIGN)); if (!abuf) goto err; if (EVP_DigestSignUpdate(&mctx, abuf, alen) <= 0) goto err; free(abuf); abuf = NULL; if (EVP_DigestSignFinal(&mctx, NULL, &siglen) <= 0) goto err; abuf = malloc(siglen); if (!abuf) goto err; if (EVP_DigestSignFinal(&mctx, abuf, &siglen) <= 0) goto err; if (EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_SIGN, EVP_PKEY_CTRL_PKCS7_SIGN, 1, si) <= 0) { PKCS7err(PKCS7_F_PKCS7_SIGNER_INFO_SIGN, PKCS7_R_CTRL_ERROR); goto err; } EVP_MD_CTX_cleanup(&mctx); ASN1_STRING_set0(si->enc_digest, abuf, siglen); return 1; err: free(abuf); EVP_MD_CTX_cleanup(&mctx); return 0; } int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si) { PKCS7_ISSUER_AND_SERIAL *ias; int ret = 0, i; STACK_OF(X509) *cert; X509 *x509; if (PKCS7_type_is_signed(p7)) { cert = p7->d.sign->cert; } else if (PKCS7_type_is_signedAndEnveloped(p7)) { cert = p7->d.signed_and_enveloped->cert; } else { PKCS7err(PKCS7_F_PKCS7_DATAVERIFY, PKCS7_R_WRONG_PKCS7_TYPE); goto err; } /* XXXX */ ias = si->issuer_and_serial; x509 = X509_find_by_issuer_and_serial(cert, ias->issuer, ias->serial); /* were we able to find the cert in passed to us */ if (x509 == NULL) { PKCS7err(PKCS7_F_PKCS7_DATAVERIFY, PKCS7_R_UNABLE_TO_FIND_CERTIFICATE); goto err; } /* Lets verify */ if (!X509_STORE_CTX_init(ctx, cert_store, x509, cert)) { PKCS7err(PKCS7_F_PKCS7_DATAVERIFY, ERR_R_X509_LIB); goto err; } X509_STORE_CTX_set_purpose(ctx, X509_PURPOSE_SMIME_SIGN); i = X509_verify_cert(ctx); if (i <= 0) { PKCS7err(PKCS7_F_PKCS7_DATAVERIFY, ERR_R_X509_LIB); X509_STORE_CTX_cleanup(ctx); goto err; } X509_STORE_CTX_cleanup(ctx); return PKCS7_signatureVerify(bio, p7, si, x509); err: return ret; } int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, X509 *x509) { ASN1_OCTET_STRING *os; EVP_MD_CTX mdc_tmp, *mdc; int ret = 0, i; int md_type; STACK_OF(X509_ATTRIBUTE) *sk; BIO *btmp; EVP_PKEY *pkey; EVP_MD_CTX_init(&mdc_tmp); if (!PKCS7_type_is_signed(p7) && !PKCS7_type_is_signedAndEnveloped(p7)) { PKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY, PKCS7_R_WRONG_PKCS7_TYPE); goto err; } md_type = OBJ_obj2nid(si->digest_alg->algorithm); btmp = bio; for (;;) { if ((btmp == NULL) || ((btmp = BIO_find_type(btmp, BIO_TYPE_MD)) == NULL)) { PKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY, PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST); goto err; } BIO_get_md_ctx(btmp, &mdc); if (mdc == NULL) { PKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY, ERR_R_INTERNAL_ERROR); goto err; } if (EVP_MD_CTX_type(mdc) == md_type) break; /* Workaround for some broken clients that put the signature * OID instead of the digest OID in digest_alg->algorithm */ if (EVP_MD_pkey_type(EVP_MD_CTX_md(mdc)) == md_type) break; btmp = BIO_next(btmp); } /* mdc is the digest ctx that we want, unless there are attributes, * in which case the digest is the signed attributes */ if (!EVP_MD_CTX_copy_ex(&mdc_tmp, mdc)) goto err; sk = si->auth_attr; if ((sk != NULL) && (sk_X509_ATTRIBUTE_num(sk) != 0)) { unsigned char md_dat[EVP_MAX_MD_SIZE], *abuf = NULL; unsigned int md_len; int alen; ASN1_OCTET_STRING *message_digest; if (!EVP_DigestFinal_ex(&mdc_tmp, md_dat, &md_len)) goto err; message_digest = PKCS7_digest_from_attributes(sk); if (!message_digest) { PKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY, PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST); goto err; } if ((message_digest->length != (int)md_len) || (memcmp(message_digest->data, md_dat, md_len))) { PKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY, PKCS7_R_DIGEST_FAILURE); ret = -1; goto err; } if (!EVP_VerifyInit_ex(&mdc_tmp, EVP_get_digestbynid(md_type), NULL)) goto err; alen = ASN1_item_i2d((ASN1_VALUE *)sk, &abuf, ASN1_ITEM_rptr(PKCS7_ATTR_VERIFY)); if (alen <= 0) { PKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY, ERR_R_ASN1_LIB); ret = -1; goto err; } if (!EVP_VerifyUpdate(&mdc_tmp, abuf, alen)) goto err; free(abuf); } os = si->enc_digest; pkey = X509_get_pubkey(x509); if (!pkey) { ret = -1; goto err; } i = EVP_VerifyFinal(&mdc_tmp, os->data, os->length, pkey); EVP_PKEY_free(pkey); if (i <= 0) { PKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY, PKCS7_R_SIGNATURE_FAILURE); ret = -1; goto err; } else ret = 1; err: EVP_MD_CTX_cleanup(&mdc_tmp); return (ret); } PKCS7_ISSUER_AND_SERIAL * PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx) { STACK_OF(PKCS7_RECIP_INFO) *rsk; PKCS7_RECIP_INFO *ri; int i; i = OBJ_obj2nid(p7->type); if (i != NID_pkcs7_signedAndEnveloped) return NULL; if (p7->d.signed_and_enveloped == NULL) return NULL; rsk = p7->d.signed_and_enveloped->recipientinfo; if (rsk == NULL) return NULL; ri = sk_PKCS7_RECIP_INFO_value(rsk, 0); if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return (NULL); ri = sk_PKCS7_RECIP_INFO_value(rsk, idx); return (ri->issuer_and_serial); } ASN1_TYPE * PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid) { return (get_attribute(si->auth_attr, nid)); } ASN1_TYPE * PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid) { return (get_attribute(si->unauth_attr, nid)); } static ASN1_TYPE * get_attribute(STACK_OF(X509_ATTRIBUTE) *sk, int nid) { int i; X509_ATTRIBUTE *xa; ASN1_OBJECT *o; o = OBJ_nid2obj(nid); if (!o || !sk) return (NULL); for (i = 0; i < sk_X509_ATTRIBUTE_num(sk); i++) { xa = sk_X509_ATTRIBUTE_value(sk, i); if (OBJ_cmp(xa->object, o) == 0) { if (!xa->single && sk_ASN1_TYPE_num(xa->value.set)) return (sk_ASN1_TYPE_value(xa->value.set, 0)); else return (NULL); } } return (NULL); } ASN1_OCTET_STRING * PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk) { ASN1_TYPE *astype; if (!(astype = get_attribute(sk, NID_pkcs9_messageDigest))) return NULL; return astype->value.octet_string; } int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si, STACK_OF(X509_ATTRIBUTE) *sk) { int i; if (p7si->auth_attr != NULL) sk_X509_ATTRIBUTE_pop_free(p7si->auth_attr, X509_ATTRIBUTE_free); p7si->auth_attr = sk_X509_ATTRIBUTE_dup(sk); if (p7si->auth_attr == NULL) return 0; for (i = 0; i < sk_X509_ATTRIBUTE_num(sk); i++) { if ((sk_X509_ATTRIBUTE_set(p7si->auth_attr, i, X509_ATTRIBUTE_dup(sk_X509_ATTRIBUTE_value(sk, i)))) == NULL) return (0); } return (1); } int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si, STACK_OF(X509_ATTRIBUTE) *sk) { int i; if (p7si->unauth_attr != NULL) sk_X509_ATTRIBUTE_pop_free(p7si->unauth_attr, X509_ATTRIBUTE_free); p7si->unauth_attr = sk_X509_ATTRIBUTE_dup(sk); if (p7si->unauth_attr == NULL) return 0; for (i = 0; i < sk_X509_ATTRIBUTE_num(sk); i++) { if ((sk_X509_ATTRIBUTE_set(p7si->unauth_attr, i, X509_ATTRIBUTE_dup(sk_X509_ATTRIBUTE_value(sk, i)))) == NULL) return (0); } return (1); } int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, void *value) { return (add_attribute(&(p7si->auth_attr), nid, atrtype, value)); } int PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, void *value) { return (add_attribute(&(p7si->unauth_attr), nid, atrtype, value)); } static int add_attribute(STACK_OF(X509_ATTRIBUTE) **sk, int nid, int atrtype, void *value) { X509_ATTRIBUTE *attr = NULL; if (*sk == NULL) { *sk = sk_X509_ATTRIBUTE_new_null(); if (*sk == NULL) return 0; new_attrib: if (!(attr = X509_ATTRIBUTE_create(nid, atrtype, value))) return 0; if (!sk_X509_ATTRIBUTE_push(*sk, attr)) { X509_ATTRIBUTE_free(attr); return 0; } } else { int i; for (i = 0; i < sk_X509_ATTRIBUTE_num(*sk); i++) { attr = sk_X509_ATTRIBUTE_value(*sk, i); if (OBJ_obj2nid(attr->object) == nid) { X509_ATTRIBUTE_free(attr); attr = X509_ATTRIBUTE_create(nid, atrtype, value); if (attr == NULL) return 0; if (!sk_X509_ATTRIBUTE_set(*sk, i, attr)) { X509_ATTRIBUTE_free(attr); return 0; } goto end; } } goto new_attrib; } end: return (1); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs7/pk7_mime.c0000644000175000017500000000706712360020706021171 0ustar /* $OpenBSD: pk7_mime.c,v 1.10 2014/06/29 17:05:36 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ /* ==================================================================== * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * */ #include #include #include #include #include /* PKCS#7 wrappers round generalised stream and MIME routines */ int i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags) { return i2d_ASN1_bio_stream(out, (ASN1_VALUE *)p7, in, flags, ASN1_ITEM_rptr(PKCS7)); } int PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags) { return PEM_write_bio_ASN1_stream(out, (ASN1_VALUE *) p7, in, flags, "PKCS7", ASN1_ITEM_rptr(PKCS7)); } int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags) { STACK_OF(X509_ALGOR) *mdalgs; int ctype_nid = OBJ_obj2nid(p7->type); if (ctype_nid == NID_pkcs7_signed) mdalgs = p7->d.sign->md_algs; else mdalgs = NULL; flags ^= SMIME_OLDMIME; return SMIME_write_ASN1(bio, (ASN1_VALUE *)p7, data, flags, ctype_nid, NID_undef, mdalgs, ASN1_ITEM_rptr(PKCS7)); } PKCS7 * SMIME_read_PKCS7(BIO *bio, BIO **bcont) { return (PKCS7 *)SMIME_read_ASN1(bio, bcont, ASN1_ITEM_rptr(PKCS7)); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs7/pk7_attr.c0000644000175000017500000001304712360020706021207 0ustar /* $OpenBSD: pk7_attr.c,v 1.8 2014/06/12 15:49:30 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 2001-2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include #include int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, STACK_OF(X509_ALGOR) *cap) { ASN1_STRING *seq; if (!(seq = ASN1_STRING_new())) { PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP, ERR_R_MALLOC_FAILURE); return 0; } seq->length = ASN1_item_i2d((ASN1_VALUE *)cap, &seq->data, ASN1_ITEM_rptr(X509_ALGORS)); return PKCS7_add_signed_attribute(si, NID_SMIMECapabilities, V_ASN1_SEQUENCE, seq); } STACK_OF(X509_ALGOR) * PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si) { ASN1_TYPE *cap; const unsigned char *p; cap = PKCS7_get_signed_attribute(si, NID_SMIMECapabilities); if (!cap || (cap->type != V_ASN1_SEQUENCE)) return NULL; p = cap->value.sequence->data; return (STACK_OF(X509_ALGOR) *) ASN1_item_d2i(NULL, &p, cap->value.sequence->length, ASN1_ITEM_rptr(X509_ALGORS)); } /* Basic smime-capabilities OID and optional integer arg */ int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg) { X509_ALGOR *alg; if (!(alg = X509_ALGOR_new())) { PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP, ERR_R_MALLOC_FAILURE); return 0; } ASN1_OBJECT_free(alg->algorithm); alg->algorithm = OBJ_nid2obj (nid); if (arg > 0) { ASN1_INTEGER *nbit; if (!(alg->parameter = ASN1_TYPE_new())) { PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP, ERR_R_MALLOC_FAILURE); return 0; } if (!(nbit = ASN1_INTEGER_new())) { PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP, ERR_R_MALLOC_FAILURE); return 0; } if (!ASN1_INTEGER_set (nbit, arg)) { PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP, ERR_R_MALLOC_FAILURE); return 0; } alg->parameter->value.integer = nbit; alg->parameter->type = V_ASN1_INTEGER; } sk_X509_ALGOR_push (sk, alg); return 1; } int PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid) { if (PKCS7_get_signed_attribute(si, NID_pkcs9_contentType)) return 0; if (!coid) coid = OBJ_nid2obj(NID_pkcs7_data); return PKCS7_add_signed_attribute(si, NID_pkcs9_contentType, V_ASN1_OBJECT, coid); } int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t) { if (!t && !(t = X509_gmtime_adj(NULL, 0))) { PKCS7err(PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME, ERR_R_MALLOC_FAILURE); return 0; } return PKCS7_add_signed_attribute(si, NID_pkcs9_signingTime, V_ASN1_UTCTIME, t); } int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si, const unsigned char *md, int mdlen) { ASN1_OCTET_STRING *os; os = ASN1_OCTET_STRING_new(); if (!os) return 0; if (!ASN1_STRING_set(os, md, mdlen) || !PKCS7_add_signed_attribute(si, NID_pkcs9_messageDigest, V_ASN1_OCTET_STRING, os)) { ASN1_OCTET_STRING_free(os); return 0; } return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs7/pk7_asn1.c0000644000175000017500000002227212360020706021077 0ustar /* $OpenBSD: pk7_asn1.c,v 1.6 2014/06/29 17:05:36 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include /* PKCS#7 ASN1 module */ /* This is the ANY DEFINED BY table for the top level PKCS#7 structure */ ASN1_ADB_TEMPLATE(p7default) = ASN1_EXP_OPT(PKCS7, d.other, ASN1_ANY, 0); ASN1_ADB(PKCS7) = { ADB_ENTRY(NID_pkcs7_data, ASN1_NDEF_EXP_OPT(PKCS7, d.data, ASN1_OCTET_STRING_NDEF, 0)), ADB_ENTRY(NID_pkcs7_signed, ASN1_NDEF_EXP_OPT(PKCS7, d.sign, PKCS7_SIGNED, 0)), ADB_ENTRY(NID_pkcs7_enveloped, ASN1_NDEF_EXP_OPT(PKCS7, d.enveloped, PKCS7_ENVELOPE, 0)), ADB_ENTRY(NID_pkcs7_signedAndEnveloped, ASN1_NDEF_EXP_OPT(PKCS7, d.signed_and_enveloped, PKCS7_SIGN_ENVELOPE, 0)), ADB_ENTRY(NID_pkcs7_digest, ASN1_NDEF_EXP_OPT(PKCS7, d.digest, PKCS7_DIGEST, 0)), ADB_ENTRY(NID_pkcs7_encrypted, ASN1_NDEF_EXP_OPT(PKCS7, d.encrypted, PKCS7_ENCRYPT, 0)) } ASN1_ADB_END(PKCS7, 0, type, 0, &p7default_tt, NULL); /* PKCS#7 streaming support */ static int pk7_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { ASN1_STREAM_ARG *sarg = exarg; PKCS7 **pp7 = (PKCS7 **)pval; switch (operation) { case ASN1_OP_STREAM_PRE: if (PKCS7_stream(&sarg->boundary, *pp7) <= 0) return 0; case ASN1_OP_DETACHED_PRE: sarg->ndef_bio = PKCS7_dataInit(*pp7, sarg->out); if (!sarg->ndef_bio) return 0; break; case ASN1_OP_STREAM_POST: case ASN1_OP_DETACHED_POST: if (PKCS7_dataFinal(*pp7, sarg->ndef_bio) <= 0) return 0; break; } return 1; } ASN1_NDEF_SEQUENCE_cb(PKCS7, pk7_cb) = { ASN1_SIMPLE(PKCS7, type, ASN1_OBJECT), ASN1_ADB_OBJECT(PKCS7) }ASN1_NDEF_SEQUENCE_END_cb(PKCS7, PKCS7) IMPLEMENT_ASN1_FUNCTIONS(PKCS7) IMPLEMENT_ASN1_NDEF_FUNCTION(PKCS7) IMPLEMENT_ASN1_DUP_FUNCTION(PKCS7) ASN1_NDEF_SEQUENCE(PKCS7_SIGNED) = { ASN1_SIMPLE(PKCS7_SIGNED, version, ASN1_INTEGER), ASN1_SET_OF(PKCS7_SIGNED, md_algs, X509_ALGOR), ASN1_SIMPLE(PKCS7_SIGNED, contents, PKCS7), ASN1_IMP_SEQUENCE_OF_OPT(PKCS7_SIGNED, cert, X509, 0), ASN1_IMP_SET_OF_OPT(PKCS7_SIGNED, crl, X509_CRL, 1), ASN1_SET_OF(PKCS7_SIGNED, signer_info, PKCS7_SIGNER_INFO) } ASN1_NDEF_SEQUENCE_END(PKCS7_SIGNED) IMPLEMENT_ASN1_FUNCTIONS(PKCS7_SIGNED) /* Minor tweak to operation: free up EVP_PKEY */ static int si_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { if (operation == ASN1_OP_FREE_POST) { PKCS7_SIGNER_INFO *si = (PKCS7_SIGNER_INFO *)*pval; EVP_PKEY_free(si->pkey); } return 1; } ASN1_SEQUENCE_cb(PKCS7_SIGNER_INFO, si_cb) = { ASN1_SIMPLE(PKCS7_SIGNER_INFO, version, ASN1_INTEGER), ASN1_SIMPLE(PKCS7_SIGNER_INFO, issuer_and_serial, PKCS7_ISSUER_AND_SERIAL), ASN1_SIMPLE(PKCS7_SIGNER_INFO, digest_alg, X509_ALGOR), /* NB this should be a SET OF but we use a SEQUENCE OF so the * original order * is retained when the structure is reencoded. * Since the attributes are implicitly tagged this will not affect * the encoding. */ ASN1_IMP_SEQUENCE_OF_OPT(PKCS7_SIGNER_INFO, auth_attr, X509_ATTRIBUTE, 0), ASN1_SIMPLE(PKCS7_SIGNER_INFO, digest_enc_alg, X509_ALGOR), ASN1_SIMPLE(PKCS7_SIGNER_INFO, enc_digest, ASN1_OCTET_STRING), ASN1_IMP_SET_OF_OPT(PKCS7_SIGNER_INFO, unauth_attr, X509_ATTRIBUTE, 1) } ASN1_SEQUENCE_END_cb(PKCS7_SIGNER_INFO, PKCS7_SIGNER_INFO) IMPLEMENT_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO) ASN1_SEQUENCE(PKCS7_ISSUER_AND_SERIAL) = { ASN1_SIMPLE(PKCS7_ISSUER_AND_SERIAL, issuer, X509_NAME), ASN1_SIMPLE(PKCS7_ISSUER_AND_SERIAL, serial, ASN1_INTEGER) } ASN1_SEQUENCE_END(PKCS7_ISSUER_AND_SERIAL) IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL) ASN1_NDEF_SEQUENCE(PKCS7_ENVELOPE) = { ASN1_SIMPLE(PKCS7_ENVELOPE, version, ASN1_INTEGER), ASN1_SET_OF(PKCS7_ENVELOPE, recipientinfo, PKCS7_RECIP_INFO), ASN1_SIMPLE(PKCS7_ENVELOPE, enc_data, PKCS7_ENC_CONTENT) } ASN1_NDEF_SEQUENCE_END(PKCS7_ENVELOPE) IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ENVELOPE) /* Minor tweak to operation: free up X509 */ static int ri_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { if (operation == ASN1_OP_FREE_POST) { PKCS7_RECIP_INFO *ri = (PKCS7_RECIP_INFO *)*pval; X509_free(ri->cert); } return 1; } ASN1_SEQUENCE_cb(PKCS7_RECIP_INFO, ri_cb) = { ASN1_SIMPLE(PKCS7_RECIP_INFO, version, ASN1_INTEGER), ASN1_SIMPLE(PKCS7_RECIP_INFO, issuer_and_serial, PKCS7_ISSUER_AND_SERIAL), ASN1_SIMPLE(PKCS7_RECIP_INFO, key_enc_algor, X509_ALGOR), ASN1_SIMPLE(PKCS7_RECIP_INFO, enc_key, ASN1_OCTET_STRING) } ASN1_SEQUENCE_END_cb(PKCS7_RECIP_INFO, PKCS7_RECIP_INFO) IMPLEMENT_ASN1_FUNCTIONS(PKCS7_RECIP_INFO) ASN1_NDEF_SEQUENCE(PKCS7_ENC_CONTENT) = { ASN1_SIMPLE(PKCS7_ENC_CONTENT, content_type, ASN1_OBJECT), ASN1_SIMPLE(PKCS7_ENC_CONTENT, algorithm, X509_ALGOR), ASN1_IMP_OPT(PKCS7_ENC_CONTENT, enc_data, ASN1_OCTET_STRING_NDEF, 0) } ASN1_NDEF_SEQUENCE_END(PKCS7_ENC_CONTENT) IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT) ASN1_NDEF_SEQUENCE(PKCS7_SIGN_ENVELOPE) = { ASN1_SIMPLE(PKCS7_SIGN_ENVELOPE, version, ASN1_INTEGER), ASN1_SET_OF(PKCS7_SIGN_ENVELOPE, recipientinfo, PKCS7_RECIP_INFO), ASN1_SET_OF(PKCS7_SIGN_ENVELOPE, md_algs, X509_ALGOR), ASN1_SIMPLE(PKCS7_SIGN_ENVELOPE, enc_data, PKCS7_ENC_CONTENT), ASN1_IMP_SET_OF_OPT(PKCS7_SIGN_ENVELOPE, cert, X509, 0), ASN1_IMP_SET_OF_OPT(PKCS7_SIGN_ENVELOPE, crl, X509_CRL, 1), ASN1_SET_OF(PKCS7_SIGN_ENVELOPE, signer_info, PKCS7_SIGNER_INFO) } ASN1_NDEF_SEQUENCE_END(PKCS7_SIGN_ENVELOPE) IMPLEMENT_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE) ASN1_NDEF_SEQUENCE(PKCS7_ENCRYPT) = { ASN1_SIMPLE(PKCS7_ENCRYPT, version, ASN1_INTEGER), ASN1_SIMPLE(PKCS7_ENCRYPT, enc_data, PKCS7_ENC_CONTENT) } ASN1_NDEF_SEQUENCE_END(PKCS7_ENCRYPT) IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ENCRYPT) ASN1_NDEF_SEQUENCE(PKCS7_DIGEST) = { ASN1_SIMPLE(PKCS7_DIGEST, version, ASN1_INTEGER), ASN1_SIMPLE(PKCS7_DIGEST, md, X509_ALGOR), ASN1_SIMPLE(PKCS7_DIGEST, contents, PKCS7), ASN1_SIMPLE(PKCS7_DIGEST, digest, ASN1_OCTET_STRING) } ASN1_NDEF_SEQUENCE_END(PKCS7_DIGEST) IMPLEMENT_ASN1_FUNCTIONS(PKCS7_DIGEST) /* Specials for authenticated attributes */ /* When signing attributes we want to reorder them to match the sorted * encoding. */ ASN1_ITEM_TEMPLATE(PKCS7_ATTR_SIGN) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SET_ORDER, 0, PKCS7_ATTRIBUTES, X509_ATTRIBUTE) ASN1_ITEM_TEMPLATE_END(PKCS7_ATTR_SIGN) /* When verifying attributes we need to use the received order. So * we use SEQUENCE OF and tag it to SET OF */ ASN1_ITEM_TEMPLATE(PKCS7_ATTR_VERIFY) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_IMPTAG | ASN1_TFLG_UNIVERSAL, V_ASN1_SET, PKCS7_ATTRIBUTES, X509_ATTRIBUTE) ASN1_ITEM_TEMPLATE_END(PKCS7_ATTR_VERIFY) IMPLEMENT_ASN1_PRINT_FUNCTION(PKCS7) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dso/0000755000000000000000000000000012666635521020637 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/dso/dso_dlfcn.c0000644000175000017500000002332212360020705021141 0ustar /* $OpenBSD: dso_dlfcn.c,v 1.26 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #ifndef DSO_DLFCN DSO_METHOD * DSO_METHOD_dlfcn(void) { return NULL; } #else #ifdef HAVE_DLFCN_H # include # define HAVE_DLINFO 1 #endif /* Part of the hack in "dlfcn_load" ... */ #define DSO_MAX_TRANSLATED_SIZE 256 static int dlfcn_load(DSO *dso); static int dlfcn_unload(DSO *dso); static void *dlfcn_bind_var(DSO *dso, const char *symname); static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname); #if 0 static int dlfcn_unbind(DSO *dso, char *symname, void *symptr); static int dlfcn_init(DSO *dso); static int dlfcn_finish(DSO *dso); static long dlfcn_ctrl(DSO *dso, int cmd, long larg, void *parg); #endif static char *dlfcn_name_converter(DSO *dso, const char *filename); static char *dlfcn_merger(DSO *dso, const char *filespec1, const char *filespec2); static int dlfcn_pathbyaddr(void *addr, char *path, int sz); static void *dlfcn_globallookup(const char *name); static DSO_METHOD dso_meth_dlfcn = { .name = "OpenSSL 'dlfcn' shared library method", .dso_load = dlfcn_load, .dso_unload = dlfcn_unload, .dso_bind_var = dlfcn_bind_var, .dso_bind_func = dlfcn_bind_func, .dso_name_converter = dlfcn_name_converter, .dso_merger = dlfcn_merger, .pathbyaddr = dlfcn_pathbyaddr, .globallookup = dlfcn_globallookup }; DSO_METHOD * DSO_METHOD_dlfcn(void) { return (&dso_meth_dlfcn); } /* For this DSO_METHOD, our meth_data STACK will contain; * (i) the handle (void*) returned from dlopen(). */ static int dlfcn_load(DSO *dso) { void *ptr = NULL; /* See applicable comments in dso_dl.c */ char *filename = DSO_convert_filename(dso, NULL); int flags = RTLD_LAZY; if (filename == NULL) { DSOerr(DSO_F_DLFCN_LOAD, DSO_R_NO_FILENAME); goto err; } if (dso->flags & DSO_FLAG_GLOBAL_SYMBOLS) flags |= RTLD_GLOBAL; ptr = dlopen(filename, flags); if (ptr == NULL) { DSOerr(DSO_F_DLFCN_LOAD, DSO_R_LOAD_FAILED); ERR_asprintf_error_data("filename(%s): %s", filename, dlerror()); goto err; } if (!sk_void_push(dso->meth_data, (char *)ptr)) { DSOerr(DSO_F_DLFCN_LOAD, DSO_R_STACK_ERROR); goto err; } /* Success */ dso->loaded_filename = filename; return (1); err: /* Cleanup! */ free(filename); if (ptr != NULL) dlclose(ptr); return (0); } static int dlfcn_unload(DSO *dso) { void *ptr; if (dso == NULL) { DSOerr(DSO_F_DLFCN_UNLOAD, ERR_R_PASSED_NULL_PARAMETER); return (0); } if (sk_void_num(dso->meth_data) < 1) return (1); ptr = sk_void_pop(dso->meth_data); if (ptr == NULL) { DSOerr(DSO_F_DLFCN_UNLOAD, DSO_R_NULL_HANDLE); /* Should push the value back onto the stack in * case of a retry. */ sk_void_push(dso->meth_data, ptr); return (0); } /* For now I'm not aware of any errors associated with dlclose() */ dlclose(ptr); return (1); } static void * dlfcn_bind_var(DSO *dso, const char *symname) { void *ptr, *sym; if ((dso == NULL) || (symname == NULL)) { DSOerr(DSO_F_DLFCN_BIND_VAR, ERR_R_PASSED_NULL_PARAMETER); return (NULL); } if (sk_void_num(dso->meth_data) < 1) { DSOerr(DSO_F_DLFCN_BIND_VAR, DSO_R_STACK_ERROR); return (NULL); } ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1); if (ptr == NULL) { DSOerr(DSO_F_DLFCN_BIND_VAR, DSO_R_NULL_HANDLE); return (NULL); } sym = dlsym(ptr, symname); if (sym == NULL) { DSOerr(DSO_F_DLFCN_BIND_VAR, DSO_R_SYM_FAILURE); ERR_asprintf_error_data("symname(%s): %s", symname, dlerror()); return (NULL); } return (sym); } static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname) { void *ptr; union { DSO_FUNC_TYPE sym; void *dlret; } u; if ((dso == NULL) || (symname == NULL)) { DSOerr(DSO_F_DLFCN_BIND_FUNC, ERR_R_PASSED_NULL_PARAMETER); return (NULL); } if (sk_void_num(dso->meth_data) < 1) { DSOerr(DSO_F_DLFCN_BIND_FUNC, DSO_R_STACK_ERROR); return (NULL); } ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1); if (ptr == NULL) { DSOerr(DSO_F_DLFCN_BIND_FUNC, DSO_R_NULL_HANDLE); return (NULL); } u.dlret = dlsym(ptr, symname); if (u.dlret == NULL) { DSOerr(DSO_F_DLFCN_BIND_FUNC, DSO_R_SYM_FAILURE); ERR_asprintf_error_data("symname(%s): %s", symname, dlerror()); return (NULL); } return u.sym; } static char * dlfcn_merger(DSO *dso, const char *filespec1, const char *filespec2) { char *merged; if (!filespec1 && !filespec2) { DSOerr(DSO_F_DLFCN_MERGER, ERR_R_PASSED_NULL_PARAMETER); return (NULL); } /* If the first file specification is a rooted path, it rules. same goes if the second file specification is missing. */ if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/')) { merged = strdup(filespec1); if (!merged) { DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); return (NULL); } } /* If the first file specification is missing, the second one rules. */ else if (!filespec1) { merged = strdup(filespec2); if (!merged) { DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); return (NULL); } } else /* This part isn't as trivial as it looks. It assumes that the second file specification really is a directory, and makes no checks whatsoever. Therefore, the result becomes the concatenation of filespec2 followed by a slash followed by filespec1. */ { size_t spec2len, len; spec2len = strlen(filespec2); len = spec2len + (filespec1 ? strlen(filespec1) : 0); if (filespec2 && filespec2[spec2len - 1] == '/') { spec2len--; len--; } merged = malloc(len + 2); if (!merged) { DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); return (NULL); } strlcpy(merged, filespec2, len + 2); merged[spec2len] = '/'; strlcpy(&merged[spec2len + 1], filespec1, len + 1 - spec2len); } return (merged); } #define DSO_ext ".so" #define DSO_extlen 3 static char * dlfcn_name_converter(DSO *dso, const char *filename) { char *translated; int ret; if (strchr(filename, '/') == NULL) { /* Bare name, so convert to "%s.so" or "lib%s.so" */ if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0) ret = asprintf(&translated, "lib%s" DSO_ext, filename); else ret = asprintf(&translated, "%s" DSO_ext, filename); if (ret == -1) translated = NULL; } else { /* Full path, so just duplicate it */ translated = strdup(filename); } if (translated == NULL) DSOerr(DSO_F_DLFCN_NAME_CONVERTER, DSO_R_NAME_TRANSLATION_FAILED); return (translated); } static int dlfcn_pathbyaddr(void *addr, char *path, int sz) { Dl_info dli; int len; if (addr == NULL) { union{ int(*f)(void*, char*, int); void *p; } t = { dlfcn_pathbyaddr }; addr = t.p; } if (dladdr(addr, &dli)) { len = (int)strlen(dli.dli_fname); if (sz <= 0) return len + 1; if (len >= sz) len = sz - 1; memcpy(path, dli.dli_fname, len); path[len++] = 0; return len; } ERR_asprintf_error_data("dlfcn_pathbyaddr(): %s", dlerror()); return -1; } static void * dlfcn_globallookup(const char *name) { void *ret = NULL, *handle = dlopen(NULL, RTLD_LAZY); if (handle) { ret = dlsym(handle, name); dlclose(handle); } return ret; } #endif /* DSO_DLFCN */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dso/dso_err.c0000644000175000017500000001616312360020705020650 0ustar /* $OpenBSD: dso_err.c,v 1.7 2014/06/12 15:49:29 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_DSO,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_DSO,0,reason) static ERR_STRING_DATA DSO_str_functs[]= { {ERR_FUNC(DSO_F_BEOS_BIND_FUNC), "BEOS_BIND_FUNC"}, {ERR_FUNC(DSO_F_BEOS_BIND_VAR), "BEOS_BIND_VAR"}, {ERR_FUNC(DSO_F_BEOS_LOAD), "BEOS_LOAD"}, {ERR_FUNC(DSO_F_BEOS_NAME_CONVERTER), "BEOS_NAME_CONVERTER"}, {ERR_FUNC(DSO_F_BEOS_UNLOAD), "BEOS_UNLOAD"}, {ERR_FUNC(DSO_F_DLFCN_BIND_FUNC), "DLFCN_BIND_FUNC"}, {ERR_FUNC(DSO_F_DLFCN_BIND_VAR), "DLFCN_BIND_VAR"}, {ERR_FUNC(DSO_F_DLFCN_LOAD), "DLFCN_LOAD"}, {ERR_FUNC(DSO_F_DLFCN_MERGER), "DLFCN_MERGER"}, {ERR_FUNC(DSO_F_DLFCN_NAME_CONVERTER), "DLFCN_NAME_CONVERTER"}, {ERR_FUNC(DSO_F_DLFCN_UNLOAD), "DLFCN_UNLOAD"}, {ERR_FUNC(DSO_F_DL_BIND_FUNC), "DL_BIND_FUNC"}, {ERR_FUNC(DSO_F_DL_BIND_VAR), "DL_BIND_VAR"}, {ERR_FUNC(DSO_F_DL_LOAD), "DL_LOAD"}, {ERR_FUNC(DSO_F_DL_MERGER), "DL_MERGER"}, {ERR_FUNC(DSO_F_DL_NAME_CONVERTER), "DL_NAME_CONVERTER"}, {ERR_FUNC(DSO_F_DL_UNLOAD), "DL_UNLOAD"}, {ERR_FUNC(DSO_F_DSO_BIND_FUNC), "DSO_bind_func"}, {ERR_FUNC(DSO_F_DSO_BIND_VAR), "DSO_bind_var"}, {ERR_FUNC(DSO_F_DSO_CONVERT_FILENAME), "DSO_convert_filename"}, {ERR_FUNC(DSO_F_DSO_CTRL), "DSO_ctrl"}, {ERR_FUNC(DSO_F_DSO_FREE), "DSO_free"}, {ERR_FUNC(DSO_F_DSO_GET_FILENAME), "DSO_get_filename"}, {ERR_FUNC(DSO_F_DSO_GET_LOADED_FILENAME), "DSO_get_loaded_filename"}, {ERR_FUNC(DSO_F_DSO_GLOBAL_LOOKUP), "DSO_global_lookup"}, {ERR_FUNC(DSO_F_DSO_LOAD), "DSO_load"}, {ERR_FUNC(DSO_F_DSO_MERGE), "DSO_merge"}, {ERR_FUNC(DSO_F_DSO_NEW_METHOD), "DSO_new_method"}, {ERR_FUNC(DSO_F_DSO_PATHBYADDR), "DSO_pathbyaddr"}, {ERR_FUNC(DSO_F_DSO_SET_FILENAME), "DSO_set_filename"}, {ERR_FUNC(DSO_F_DSO_SET_NAME_CONVERTER), "DSO_set_name_converter"}, {ERR_FUNC(DSO_F_DSO_UP_REF), "DSO_up_ref"}, {ERR_FUNC(DSO_F_GLOBAL_LOOKUP_FUNC), "GLOBAL_LOOKUP_FUNC"}, {ERR_FUNC(DSO_F_PATHBYADDR), "PATHBYADDR"}, {ERR_FUNC(DSO_F_VMS_BIND_SYM), "VMS_BIND_SYM"}, {ERR_FUNC(DSO_F_VMS_LOAD), "VMS_LOAD"}, {ERR_FUNC(DSO_F_VMS_MERGER), "VMS_MERGER"}, {ERR_FUNC(DSO_F_VMS_UNLOAD), "VMS_UNLOAD"}, {ERR_FUNC(DSO_F_WIN32_BIND_FUNC), "WIN32_BIND_FUNC"}, {ERR_FUNC(DSO_F_WIN32_BIND_VAR), "WIN32_BIND_VAR"}, {ERR_FUNC(DSO_F_WIN32_GLOBALLOOKUP), "WIN32_GLOBALLOOKUP"}, {ERR_FUNC(DSO_F_WIN32_GLOBALLOOKUP_FUNC), "WIN32_GLOBALLOOKUP_FUNC"}, {ERR_FUNC(DSO_F_WIN32_JOINER), "WIN32_JOINER"}, {ERR_FUNC(DSO_F_WIN32_LOAD), "WIN32_LOAD"}, {ERR_FUNC(DSO_F_WIN32_MERGER), "WIN32_MERGER"}, {ERR_FUNC(DSO_F_WIN32_NAME_CONVERTER), "WIN32_NAME_CONVERTER"}, {ERR_FUNC(DSO_F_WIN32_PATHBYADDR), "WIN32_PATHBYADDR"}, {ERR_FUNC(DSO_F_WIN32_SPLITTER), "WIN32_SPLITTER"}, {ERR_FUNC(DSO_F_WIN32_UNLOAD), "WIN32_UNLOAD"}, {0, NULL} }; static ERR_STRING_DATA DSO_str_reasons[]= { {ERR_REASON(DSO_R_CTRL_FAILED) , "control command failed"}, {ERR_REASON(DSO_R_DSO_ALREADY_LOADED) , "dso already loaded"}, {ERR_REASON(DSO_R_EMPTY_FILE_STRUCTURE) , "empty file structure"}, {ERR_REASON(DSO_R_FAILURE) , "failure"}, {ERR_REASON(DSO_R_FILENAME_TOO_BIG) , "filename too big"}, {ERR_REASON(DSO_R_FINISH_FAILED) , "cleanup method function failed"}, {ERR_REASON(DSO_R_INCORRECT_FILE_SYNTAX) , "incorrect file syntax"}, {ERR_REASON(DSO_R_LOAD_FAILED) , "could not load the shared library"}, {ERR_REASON(DSO_R_NAME_TRANSLATION_FAILED), "name translation failed"}, {ERR_REASON(DSO_R_NO_FILENAME) , "no filename"}, {ERR_REASON(DSO_R_NO_FILE_SPECIFICATION) , "no file specification"}, {ERR_REASON(DSO_R_NULL_HANDLE) , "a null shared library handle was used"}, {ERR_REASON(DSO_R_SET_FILENAME_FAILED) , "set filename failed"}, {ERR_REASON(DSO_R_STACK_ERROR) , "the meth_data stack is corrupt"}, {ERR_REASON(DSO_R_SYM_FAILURE) , "could not bind to the requested symbol name"}, {ERR_REASON(DSO_R_UNLOAD_FAILED) , "could not unload the shared library"}, {ERR_REASON(DSO_R_UNSUPPORTED) , "functionality not supported"}, {0, NULL} }; #endif void ERR_load_DSO_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(DSO_str_functs[0].error) == NULL) { ERR_load_strings(0, DSO_str_functs); ERR_load_strings(0, DSO_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dso/dso_null.c0000644000175000017500000000603012360020705021022 0ustar /* $OpenBSD: dso_null.c,v 1.6 2014/06/12 15:49:29 deraadt Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* This "NULL" method is provided as the fallback for systems that have * no appropriate support for "shared-libraries". */ #include #include static DSO_METHOD dso_meth_null = { .name = "NULL shared library method" }; DSO_METHOD * DSO_METHOD_null(void) { return (&dso_meth_null); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dso/dso_openssl.c0000644000175000017500000000602112360020705021533 0ustar /* $OpenBSD: dso_openssl.c,v 1.5 2014/06/12 15:49:29 deraadt Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include /* We just pinch the method from an appropriate "default" method. */ DSO_METHOD * DSO_METHOD_openssl(void) { #ifdef DEF_DSO_METHOD return (DEF_DSO_METHOD()); #elif defined(DSO_DLFCN) return (DSO_METHOD_dlfcn()); #else return (DSO_METHOD_null()); #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/dso/dso_lib.c0000644000175000017500000002631612360020705020627 0ustar /* $OpenBSD: dso_lib.c,v 1.17 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include static DSO_METHOD *default_DSO_meth = NULL; DSO * DSO_new(void) { return (DSO_new_method(NULL)); } void DSO_set_default_method(DSO_METHOD *meth) { default_DSO_meth = meth; } DSO_METHOD * DSO_get_default_method(void) { return (default_DSO_meth); } DSO_METHOD * DSO_get_method(DSO *dso) { return (dso->meth); } DSO_METHOD * DSO_set_method(DSO *dso, DSO_METHOD *meth) { DSO_METHOD *mtmp; mtmp = dso->meth; dso->meth = meth; return (mtmp); } DSO * DSO_new_method(DSO_METHOD *meth) { DSO *ret; if (default_DSO_meth == NULL) /* We default to DSO_METH_openssl() which in turn defaults * to stealing the "best available" method. Will fallback * to DSO_METH_null() in the worst case. */ default_DSO_meth = DSO_METHOD_openssl(); ret = calloc(1, sizeof(DSO)); if (ret == NULL) { DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE); return (NULL); } ret->meth_data = sk_void_new_null(); if (ret->meth_data == NULL) { /* sk_new doesn't generate any errors so we do */ DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE); free(ret); return (NULL); } if (meth == NULL) ret->meth = default_DSO_meth; else ret->meth = meth; ret->references = 1; if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { free(ret); ret = NULL; } return (ret); } int DSO_free(DSO *dso) { int i; if (dso == NULL) { DSOerr(DSO_F_DSO_FREE, ERR_R_PASSED_NULL_PARAMETER); return (0); } i = CRYPTO_add(&dso->references, -1, CRYPTO_LOCK_DSO); if (i > 0) return (1); if ((dso->meth->dso_unload != NULL) && !dso->meth->dso_unload(dso)) { DSOerr(DSO_F_DSO_FREE, DSO_R_UNLOAD_FAILED); return (0); } if ((dso->meth->finish != NULL) && !dso->meth->finish(dso)) { DSOerr(DSO_F_DSO_FREE, DSO_R_FINISH_FAILED); return (0); } sk_void_free(dso->meth_data); free(dso->filename); free(dso->loaded_filename); free(dso); return (1); } int DSO_flags(DSO *dso) { return ((dso == NULL) ? 0 : dso->flags); } int DSO_up_ref(DSO *dso) { if (dso == NULL) { DSOerr(DSO_F_DSO_UP_REF, ERR_R_PASSED_NULL_PARAMETER); return (0); } CRYPTO_add(&dso->references, 1, CRYPTO_LOCK_DSO); return (1); } DSO * DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags) { DSO *ret; int allocated = 0; if (dso == NULL) { ret = DSO_new_method(meth); if (ret == NULL) { DSOerr(DSO_F_DSO_LOAD, ERR_R_MALLOC_FAILURE); goto err; } allocated = 1; /* Pass the provided flags to the new DSO object */ if (DSO_ctrl(ret, DSO_CTRL_SET_FLAGS, flags, NULL) < 0) { DSOerr(DSO_F_DSO_LOAD, DSO_R_CTRL_FAILED); goto err; } } else ret = dso; /* Don't load if we're currently already loaded */ if (ret->filename != NULL) { DSOerr(DSO_F_DSO_LOAD, DSO_R_DSO_ALREADY_LOADED); goto err; } /* filename can only be NULL if we were passed a dso that already has * one set. */ if (filename != NULL) if (!DSO_set_filename(ret, filename)) { DSOerr(DSO_F_DSO_LOAD, DSO_R_SET_FILENAME_FAILED); goto err; } filename = ret->filename; if (filename == NULL) { DSOerr(DSO_F_DSO_LOAD, DSO_R_NO_FILENAME); goto err; } if (ret->meth->dso_load == NULL) { DSOerr(DSO_F_DSO_LOAD, DSO_R_UNSUPPORTED); goto err; } if (!ret->meth->dso_load(ret)) { DSOerr(DSO_F_DSO_LOAD, DSO_R_LOAD_FAILED); goto err; } /* Load succeeded */ return (ret); err: if (allocated) DSO_free(ret); return (NULL); } void * DSO_bind_var(DSO *dso, const char *symname) { void *ret = NULL; if ((dso == NULL) || (symname == NULL)) { DSOerr(DSO_F_DSO_BIND_VAR, ERR_R_PASSED_NULL_PARAMETER); return (NULL); } if (dso->meth->dso_bind_var == NULL) { DSOerr(DSO_F_DSO_BIND_VAR, DSO_R_UNSUPPORTED); return (NULL); } if ((ret = dso->meth->dso_bind_var(dso, symname)) == NULL) { DSOerr(DSO_F_DSO_BIND_VAR, DSO_R_SYM_FAILURE); return (NULL); } /* Success */ return (ret); } DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname) { DSO_FUNC_TYPE ret = NULL; if ((dso == NULL) || (symname == NULL)) { DSOerr(DSO_F_DSO_BIND_FUNC, ERR_R_PASSED_NULL_PARAMETER); return (NULL); } if (dso->meth->dso_bind_func == NULL) { DSOerr(DSO_F_DSO_BIND_FUNC, DSO_R_UNSUPPORTED); return (NULL); } if ((ret = dso->meth->dso_bind_func(dso, symname)) == NULL) { DSOerr(DSO_F_DSO_BIND_FUNC, DSO_R_SYM_FAILURE); return (NULL); } /* Success */ return (ret); } /* I don't really like these *_ctrl functions very much to be perfectly * honest. For one thing, I think I have to return a negative value for * any error because possible DSO_ctrl() commands may return values * such as "size"s that can legitimately be zero (making the standard * "if(DSO_cmd(...))" form that works almost everywhere else fail at * odd times. I'd prefer "output" values to be passed by reference and * the return value as success/failure like usual ... but we conform * when we must... :-) */ long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg) { if (dso == NULL) { DSOerr(DSO_F_DSO_CTRL, ERR_R_PASSED_NULL_PARAMETER); return (-1); } /* We should intercept certain generic commands and only pass control * to the method-specific ctrl() function if it's something we don't * handle. */ switch (cmd) { case DSO_CTRL_GET_FLAGS: return dso->flags; case DSO_CTRL_SET_FLAGS: dso->flags = (int)larg; return (0); case DSO_CTRL_OR_FLAGS: dso->flags |= (int)larg; return (0); default: break; } if ((dso->meth == NULL) || (dso->meth->dso_ctrl == NULL)) { DSOerr(DSO_F_DSO_CTRL, DSO_R_UNSUPPORTED); return (-1); } return (dso->meth->dso_ctrl(dso, cmd, larg, parg)); } int DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb, DSO_NAME_CONVERTER_FUNC *oldcb) { if (dso == NULL) { DSOerr(DSO_F_DSO_SET_NAME_CONVERTER, ERR_R_PASSED_NULL_PARAMETER); return (0); } if (oldcb) *oldcb = dso->name_converter; dso->name_converter = cb; return (1); } const char * DSO_get_filename(DSO *dso) { if (dso == NULL) { DSOerr(DSO_F_DSO_GET_FILENAME, ERR_R_PASSED_NULL_PARAMETER); return (NULL); } return (dso->filename); } int DSO_set_filename(DSO *dso, const char *filename) { char *copied; if ((dso == NULL) || (filename == NULL)) { DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_PASSED_NULL_PARAMETER); return (0); } if (dso->loaded_filename) { DSOerr(DSO_F_DSO_SET_FILENAME, DSO_R_DSO_ALREADY_LOADED); return (0); } /* We'll duplicate filename */ copied = strdup(filename); if (copied == NULL) { DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_MALLOC_FAILURE); return (0); } free(dso->filename); dso->filename = copied; return (1); } char * DSO_merge(DSO *dso, const char *filespec1, const char *filespec2) { char *result = NULL; if (dso == NULL || filespec1 == NULL) { DSOerr(DSO_F_DSO_MERGE, ERR_R_PASSED_NULL_PARAMETER); return (NULL); } if ((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) { if (dso->merger != NULL) result = dso->merger(dso, filespec1, filespec2); else if (dso->meth->dso_merger != NULL) result = dso->meth->dso_merger(dso, filespec1, filespec2); } return (result); } char * DSO_convert_filename(DSO *dso, const char *filename) { char *result = NULL; if (dso == NULL) { DSOerr(DSO_F_DSO_CONVERT_FILENAME, ERR_R_PASSED_NULL_PARAMETER); return (NULL); } if (filename == NULL) filename = dso->filename; if (filename == NULL) { DSOerr(DSO_F_DSO_CONVERT_FILENAME, DSO_R_NO_FILENAME); return (NULL); } if ((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) { if (dso->name_converter != NULL) result = dso->name_converter(dso, filename); else if (dso->meth->dso_name_converter != NULL) result = dso->meth->dso_name_converter(dso, filename); } if (result == NULL) { result = strdup(filename); if (result == NULL) { DSOerr(DSO_F_DSO_CONVERT_FILENAME, ERR_R_MALLOC_FAILURE); return (NULL); } } return (result); } const char * DSO_get_loaded_filename(DSO *dso) { if (dso == NULL) { DSOerr(DSO_F_DSO_GET_LOADED_FILENAME, ERR_R_PASSED_NULL_PARAMETER); return (NULL); } return (dso->loaded_filename); } int DSO_pathbyaddr(void *addr, char *path, int sz) { DSO_METHOD *meth = default_DSO_meth; if (meth == NULL) meth = DSO_METHOD_openssl(); if (meth->pathbyaddr == NULL) { DSOerr(DSO_F_DSO_PATHBYADDR, DSO_R_UNSUPPORTED); return -1; } return (*meth->pathbyaddr)(addr, path, sz); } void * DSO_global_lookup(const char *name) { DSO_METHOD *meth = default_DSO_meth; if (meth == NULL) meth = DSO_METHOD_openssl(); if (meth->globallookup == NULL) { DSOerr(DSO_F_DSO_GLOBAL_LOOKUP, DSO_R_UNSUPPORTED); return NULL; } return (*meth->globallookup)(name); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/0000755000000000000000000000000012666635521020441 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ec_print.c0000644000175000017500000001154712360020705020621 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include "ec_lcl.h" BIGNUM * EC_POINT_point2bn(const EC_GROUP * group, const EC_POINT * point, point_conversion_form_t form, BIGNUM * ret, BN_CTX * ctx) { size_t buf_len = 0; unsigned char *buf; buf_len = EC_POINT_point2oct(group, point, form, NULL, 0, ctx); if (buf_len == 0) return NULL; if ((buf = malloc(buf_len)) == NULL) return NULL; if (!EC_POINT_point2oct(group, point, form, buf, buf_len, ctx)) { free(buf); return NULL; } ret = BN_bin2bn(buf, buf_len, ret); free(buf); return ret; } EC_POINT * EC_POINT_bn2point(const EC_GROUP * group, const BIGNUM * bn, EC_POINT * point, BN_CTX * ctx) { size_t buf_len = 0; unsigned char *buf; EC_POINT *ret; if ((buf_len = BN_num_bytes(bn)) == 0) return NULL; buf = malloc(buf_len); if (buf == NULL) return NULL; if (!BN_bn2bin(bn, buf)) { free(buf); return NULL; } if (point == NULL) { if ((ret = EC_POINT_new(group)) == NULL) { free(buf); return NULL; } } else ret = point; if (!EC_POINT_oct2point(group, ret, buf, buf_len, ctx)) { if (point == NULL) EC_POINT_clear_free(ret); free(buf); return NULL; } free(buf); return ret; } static const char *HEX_DIGITS = "0123456789ABCDEF"; /* the return value must be freed (using free()) */ char * EC_POINT_point2hex(const EC_GROUP * group, const EC_POINT * point, point_conversion_form_t form, BN_CTX * ctx) { char *ret, *p; size_t buf_len = 0, i; unsigned char *buf, *pbuf; buf_len = EC_POINT_point2oct(group, point, form, NULL, 0, ctx); if (buf_len == 0) return NULL; if ((buf = malloc(buf_len)) == NULL) return NULL; if (!EC_POINT_point2oct(group, point, form, buf, buf_len, ctx)) { free(buf); return NULL; } ret = malloc(buf_len * 2 + 2); if (ret == NULL) { free(buf); return NULL; } p = ret; pbuf = buf; for (i = buf_len; i > 0; i--) { int v = (int) *(pbuf++); *(p++) = HEX_DIGITS[v >> 4]; *(p++) = HEX_DIGITS[v & 0x0F]; } *p = '\0'; free(buf); return ret; } EC_POINT * EC_POINT_hex2point(const EC_GROUP * group, const char *buf, EC_POINT * point, BN_CTX * ctx) { EC_POINT *ret = NULL; BIGNUM *tmp_bn = NULL; if (!BN_hex2bn(&tmp_bn, buf)) return NULL; ret = EC_POINT_bn2point(group, tmp_bn, point, ctx); BN_clear_free(tmp_bn); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ec_pmeth.c0000644000175000017500000002002312360020705020567 0ustar /* $OpenBSD: ec_pmeth.c,v 1.6 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include #include "evp_locl.h" /* EC pkey context structure */ typedef struct { /* Key and paramgen group */ EC_GROUP *gen_group; /* message digest */ const EVP_MD *md; } EC_PKEY_CTX; static int pkey_ec_init(EVP_PKEY_CTX * ctx) { EC_PKEY_CTX *dctx; dctx = malloc(sizeof(EC_PKEY_CTX)); if (!dctx) return 0; dctx->gen_group = NULL; dctx->md = NULL; ctx->data = dctx; return 1; } static int pkey_ec_copy(EVP_PKEY_CTX * dst, EVP_PKEY_CTX * src) { EC_PKEY_CTX *dctx, *sctx; if (!pkey_ec_init(dst)) return 0; sctx = src->data; dctx = dst->data; if (sctx->gen_group) { dctx->gen_group = EC_GROUP_dup(sctx->gen_group); if (!dctx->gen_group) return 0; } dctx->md = sctx->md; return 1; } static void pkey_ec_cleanup(EVP_PKEY_CTX * ctx) { EC_PKEY_CTX *dctx = ctx->data; if (dctx) { if (dctx->gen_group) EC_GROUP_free(dctx->gen_group); free(dctx); } } static int pkey_ec_sign(EVP_PKEY_CTX * ctx, unsigned char *sig, size_t * siglen, const unsigned char *tbs, size_t tbslen) { int ret, type; unsigned int sltmp; EC_PKEY_CTX *dctx = ctx->data; EC_KEY *ec = ctx->pkey->pkey.ec; if (!sig) { *siglen = ECDSA_size(ec); return 1; } else if (*siglen < (size_t) ECDSA_size(ec)) { ECerr(EC_F_PKEY_EC_SIGN, EC_R_BUFFER_TOO_SMALL); return 0; } if (dctx->md) type = EVP_MD_type(dctx->md); else type = NID_sha1; ret = ECDSA_sign(type, tbs, tbslen, sig, &sltmp, ec); if (ret <= 0) return ret; *siglen = (size_t) sltmp; return 1; } static int pkey_ec_verify(EVP_PKEY_CTX * ctx, const unsigned char *sig, size_t siglen, const unsigned char *tbs, size_t tbslen) { int ret, type; EC_PKEY_CTX *dctx = ctx->data; EC_KEY *ec = ctx->pkey->pkey.ec; if (dctx->md) type = EVP_MD_type(dctx->md); else type = NID_sha1; ret = ECDSA_verify(type, tbs, tbslen, sig, siglen, ec); return ret; } static int pkey_ec_derive(EVP_PKEY_CTX * ctx, unsigned char *key, size_t * keylen) { int ret; size_t outlen; const EC_POINT *pubkey = NULL; if (!ctx->pkey || !ctx->peerkey) { ECerr(EC_F_PKEY_EC_DERIVE, EC_R_KEYS_NOT_SET); return 0; } if (!key) { const EC_GROUP *group; group = EC_KEY_get0_group(ctx->pkey->pkey.ec); *keylen = (EC_GROUP_get_degree(group) + 7) / 8; return 1; } pubkey = EC_KEY_get0_public_key(ctx->peerkey->pkey.ec); /* * NB: unlike PKCS#3 DH, if *outlen is less than maximum size this is * not an error, the result is truncated. */ outlen = *keylen; ret = ECDH_compute_key(key, outlen, pubkey, ctx->pkey->pkey.ec, 0); if (ret < 0) return ret; *keylen = ret; return 1; } static int pkey_ec_ctrl(EVP_PKEY_CTX * ctx, int type, int p1, void *p2) { EC_PKEY_CTX *dctx = ctx->data; EC_GROUP *group; switch (type) { case EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID: group = EC_GROUP_new_by_curve_name(p1); if (group == NULL) { ECerr(EC_F_PKEY_EC_CTRL, EC_R_INVALID_CURVE); return 0; } if (dctx->gen_group) EC_GROUP_free(dctx->gen_group); dctx->gen_group = group; return 1; case EVP_PKEY_CTRL_MD: if (EVP_MD_type((const EVP_MD *) p2) != NID_sha1 && EVP_MD_type((const EVP_MD *) p2) != NID_ecdsa_with_SHA1 && EVP_MD_type((const EVP_MD *) p2) != NID_sha224 && EVP_MD_type((const EVP_MD *) p2) != NID_sha256 && EVP_MD_type((const EVP_MD *) p2) != NID_sha384 && EVP_MD_type((const EVP_MD *) p2) != NID_sha512) { ECerr(EC_F_PKEY_EC_CTRL, EC_R_INVALID_DIGEST_TYPE); return 0; } dctx->md = p2; return 1; case EVP_PKEY_CTRL_PEER_KEY: /* Default behaviour is OK */ case EVP_PKEY_CTRL_DIGESTINIT: case EVP_PKEY_CTRL_PKCS7_SIGN: case EVP_PKEY_CTRL_CMS_SIGN: return 1; default: return -2; } } static int pkey_ec_ctrl_str(EVP_PKEY_CTX * ctx, const char *type, const char *value) { if (!strcmp(type, "ec_paramgen_curve")) { int nid; nid = OBJ_sn2nid(value); if (nid == NID_undef) nid = OBJ_ln2nid(value); if (nid == NID_undef) { ECerr(EC_F_PKEY_EC_CTRL_STR, EC_R_INVALID_CURVE); return 0; } return EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid); } return -2; } static int pkey_ec_paramgen(EVP_PKEY_CTX * ctx, EVP_PKEY * pkey) { EC_KEY *ec = NULL; EC_PKEY_CTX *dctx = ctx->data; int ret = 0; if (dctx->gen_group == NULL) { ECerr(EC_F_PKEY_EC_PARAMGEN, EC_R_NO_PARAMETERS_SET); return 0; } ec = EC_KEY_new(); if (!ec) return 0; ret = EC_KEY_set_group(ec, dctx->gen_group); if (ret) EVP_PKEY_assign_EC_KEY(pkey, ec); else EC_KEY_free(ec); return ret; } static int pkey_ec_keygen(EVP_PKEY_CTX * ctx, EVP_PKEY * pkey) { EC_KEY *ec = NULL; if (ctx->pkey == NULL) { ECerr(EC_F_PKEY_EC_KEYGEN, EC_R_NO_PARAMETERS_SET); return 0; } ec = EC_KEY_new(); if (!ec) return 0; EVP_PKEY_assign_EC_KEY(pkey, ec); /* Note: if error return, pkey is freed by parent routine */ if (!EVP_PKEY_copy_parameters(pkey, ctx->pkey)) return 0; return EC_KEY_generate_key(pkey->pkey.ec); } const EVP_PKEY_METHOD ec_pkey_meth = { .pkey_id = EVP_PKEY_EC, .init = pkey_ec_init, .copy = pkey_ec_copy, .cleanup = pkey_ec_cleanup, .paramgen = pkey_ec_paramgen, .keygen = pkey_ec_keygen, .sign = pkey_ec_sign, .verify = pkey_ec_verify, .derive = pkey_ec_derive, .ctrl = pkey_ec_ctrl, .ctrl_str = pkey_ec_ctrl_str }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ec2_smpl.c0000644000175000017500000004612512360020705020522 0ustar /* $OpenBSD: ec2_smpl.c,v 1.10 2014/06/12 15:49:29 deraadt Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * The Elliptic Curve Public-Key Crypto Library (ECC Code) included * herein is developed by SUN MICROSYSTEMS, INC., and is contributed * to the OpenSSL project. * * The ECC Code is licensed pursuant to the OpenSSL open source * license provided below. * * The software is originally written by Sheueling Chang Shantz and * Douglas Stebila of Sun Microsystems Laboratories. * */ /* ==================================================================== * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "ec_lcl.h" #ifndef OPENSSL_NO_EC2M const EC_METHOD * EC_GF2m_simple_method(void) { static const EC_METHOD ret = { .flags = EC_FLAGS_DEFAULT_OCT, .field_type = NID_X9_62_characteristic_two_field, .group_init = ec_GF2m_simple_group_init, .group_finish = ec_GF2m_simple_group_finish, .group_clear_finish = ec_GF2m_simple_group_clear_finish, .group_copy = ec_GF2m_simple_group_copy, .group_set_curve = ec_GF2m_simple_group_set_curve, .group_get_curve = ec_GF2m_simple_group_get_curve, .group_get_degree = ec_GF2m_simple_group_get_degree, .group_check_discriminant = ec_GF2m_simple_group_check_discriminant, .point_init = ec_GF2m_simple_point_init, .point_finish = ec_GF2m_simple_point_finish, .point_clear_finish = ec_GF2m_simple_point_clear_finish, .point_copy = ec_GF2m_simple_point_copy, .point_set_to_infinity = ec_GF2m_simple_point_set_to_infinity, .point_set_affine_coordinates = ec_GF2m_simple_point_set_affine_coordinates, .point_get_affine_coordinates = ec_GF2m_simple_point_get_affine_coordinates, .add = ec_GF2m_simple_add, .dbl = ec_GF2m_simple_dbl, .invert = ec_GF2m_simple_invert, .is_at_infinity = ec_GF2m_simple_is_at_infinity, .is_on_curve = ec_GF2m_simple_is_on_curve, .point_cmp = ec_GF2m_simple_cmp, .make_affine = ec_GF2m_simple_make_affine, .points_make_affine = ec_GF2m_simple_points_make_affine, /* * the following three method functions are defined in * ec2_mult.c */ .mul = ec_GF2m_simple_mul, .precompute_mult = ec_GF2m_precompute_mult, .have_precompute_mult = ec_GF2m_have_precompute_mult, .field_mul = ec_GF2m_simple_field_mul, .field_sqr = ec_GF2m_simple_field_sqr, .field_div = ec_GF2m_simple_field_div, }; return &ret; } /* Initialize a GF(2^m)-based EC_GROUP structure. * Note that all other members are handled by EC_GROUP_new. */ int ec_GF2m_simple_group_init(EC_GROUP * group) { BN_init(&group->field); BN_init(&group->a); BN_init(&group->b); return 1; } /* Free a GF(2^m)-based EC_GROUP structure. * Note that all other members are handled by EC_GROUP_free. */ void ec_GF2m_simple_group_finish(EC_GROUP * group) { BN_free(&group->field); BN_free(&group->a); BN_free(&group->b); } /* Clear and free a GF(2^m)-based EC_GROUP structure. * Note that all other members are handled by EC_GROUP_clear_free. */ void ec_GF2m_simple_group_clear_finish(EC_GROUP * group) { BN_clear_free(&group->field); BN_clear_free(&group->a); BN_clear_free(&group->b); group->poly[0] = 0; group->poly[1] = 0; group->poly[2] = 0; group->poly[3] = 0; group->poly[4] = 0; group->poly[5] = -1; } /* Copy a GF(2^m)-based EC_GROUP structure. * Note that all other members are handled by EC_GROUP_copy. */ int ec_GF2m_simple_group_copy(EC_GROUP * dest, const EC_GROUP * src) { int i; if (!BN_copy(&dest->field, &src->field)) return 0; if (!BN_copy(&dest->a, &src->a)) return 0; if (!BN_copy(&dest->b, &src->b)) return 0; dest->poly[0] = src->poly[0]; dest->poly[1] = src->poly[1]; dest->poly[2] = src->poly[2]; dest->poly[3] = src->poly[3]; dest->poly[4] = src->poly[4]; dest->poly[5] = src->poly[5]; if (bn_wexpand(&dest->a, (int) (dest->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) return 0; if (bn_wexpand(&dest->b, (int) (dest->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) return 0; for (i = dest->a.top; i < dest->a.dmax; i++) dest->a.d[i] = 0; for (i = dest->b.top; i < dest->b.dmax; i++) dest->b.d[i] = 0; return 1; } /* Set the curve parameters of an EC_GROUP structure. */ int ec_GF2m_simple_group_set_curve(EC_GROUP * group, const BIGNUM * p, const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) { int ret = 0, i; /* group->field */ if (!BN_copy(&group->field, p)) goto err; i = BN_GF2m_poly2arr(&group->field, group->poly, 6) - 1; if ((i != 5) && (i != 3)) { ECerr(EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE, EC_R_UNSUPPORTED_FIELD); goto err; } /* group->a */ if (!BN_GF2m_mod_arr(&group->a, a, group->poly)) goto err; if (bn_wexpand(&group->a, (int) (group->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) goto err; for (i = group->a.top; i < group->a.dmax; i++) group->a.d[i] = 0; /* group->b */ if (!BN_GF2m_mod_arr(&group->b, b, group->poly)) goto err; if (bn_wexpand(&group->b, (int) (group->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) goto err; for (i = group->b.top; i < group->b.dmax; i++) group->b.d[i] = 0; ret = 1; err: return ret; } /* Get the curve parameters of an EC_GROUP structure. * If p, a, or b are NULL then there values will not be set but the method will return with success. */ int ec_GF2m_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx) { int ret = 0; if (p != NULL) { if (!BN_copy(p, &group->field)) return 0; } if (a != NULL) { if (!BN_copy(a, &group->a)) goto err; } if (b != NULL) { if (!BN_copy(b, &group->b)) goto err; } ret = 1; err: return ret; } /* Gets the degree of the field. For a curve over GF(2^m) this is the value m. */ int ec_GF2m_simple_group_get_degree(const EC_GROUP * group) { return BN_num_bits(&group->field) - 1; } /* Checks the discriminant of the curve. * y^2 + x*y = x^3 + a*x^2 + b is an elliptic curve <=> b != 0 (mod p) */ int ec_GF2m_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) { int ret = 0; BIGNUM *b; BN_CTX *new_ctx = NULL; if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) { ECerr(EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT, ERR_R_MALLOC_FAILURE); goto err; } } BN_CTX_start(ctx); b = BN_CTX_get(ctx); if (b == NULL) goto err; if (!BN_GF2m_mod_arr(b, &group->b, group->poly)) goto err; /* * check the discriminant: y^2 + x*y = x^3 + a*x^2 + b is an elliptic * curve <=> b != 0 (mod p) */ if (BN_is_zero(b)) goto err; ret = 1; err: if (ctx != NULL) BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } /* Initializes an EC_POINT. */ int ec_GF2m_simple_point_init(EC_POINT * point) { BN_init(&point->X); BN_init(&point->Y); BN_init(&point->Z); return 1; } /* Frees an EC_POINT. */ void ec_GF2m_simple_point_finish(EC_POINT * point) { BN_free(&point->X); BN_free(&point->Y); BN_free(&point->Z); } /* Clears and frees an EC_POINT. */ void ec_GF2m_simple_point_clear_finish(EC_POINT * point) { BN_clear_free(&point->X); BN_clear_free(&point->Y); BN_clear_free(&point->Z); point->Z_is_one = 0; } /* Copy the contents of one EC_POINT into another. Assumes dest is initialized. */ int ec_GF2m_simple_point_copy(EC_POINT * dest, const EC_POINT * src) { if (!BN_copy(&dest->X, &src->X)) return 0; if (!BN_copy(&dest->Y, &src->Y)) return 0; if (!BN_copy(&dest->Z, &src->Z)) return 0; dest->Z_is_one = src->Z_is_one; return 1; } /* Set an EC_POINT to the point at infinity. * A point at infinity is represented by having Z=0. */ int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP * group, EC_POINT * point) { point->Z_is_one = 0; BN_zero(&point->Z); return 1; } /* Set the coordinates of an EC_POINT using affine coordinates. * Note that the simple implementation only uses affine coordinates. */ int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP * group, EC_POINT * point, const BIGNUM * x, const BIGNUM * y, BN_CTX * ctx) { int ret = 0; if (x == NULL || y == NULL) { ECerr(EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES, ERR_R_PASSED_NULL_PARAMETER); return 0; } if (!BN_copy(&point->X, x)) goto err; BN_set_negative(&point->X, 0); if (!BN_copy(&point->Y, y)) goto err; BN_set_negative(&point->Y, 0); if (!BN_copy(&point->Z, BN_value_one())) goto err; BN_set_negative(&point->Z, 0); point->Z_is_one = 1; ret = 1; err: return ret; } /* Gets the affine coordinates of an EC_POINT. * Note that the simple implementation only uses affine coordinates. */ int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx) { int ret = 0; if (EC_POINT_is_at_infinity(group, point)) { ECerr(EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES, EC_R_POINT_AT_INFINITY); return 0; } if (BN_cmp(&point->Z, BN_value_one())) { ECerr(EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (x != NULL) { if (!BN_copy(x, &point->X)) goto err; BN_set_negative(x, 0); } if (y != NULL) { if (!BN_copy(y, &point->Y)) goto err; BN_set_negative(y, 0); } ret = 1; err: return ret; } /* Computes a + b and stores the result in r. r could be a or b, a could be b. * Uses algorithm A.10.2 of IEEE P1363. */ int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx) { BN_CTX *new_ctx = NULL; BIGNUM *x0, *y0, *x1, *y1, *x2, *y2, *s, *t; int ret = 0; if (EC_POINT_is_at_infinity(group, a)) { if (!EC_POINT_copy(r, b)) return 0; return 1; } if (EC_POINT_is_at_infinity(group, b)) { if (!EC_POINT_copy(r, a)) return 0; return 1; } if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } BN_CTX_start(ctx); x0 = BN_CTX_get(ctx); y0 = BN_CTX_get(ctx); x1 = BN_CTX_get(ctx); y1 = BN_CTX_get(ctx); x2 = BN_CTX_get(ctx); y2 = BN_CTX_get(ctx); s = BN_CTX_get(ctx); t = BN_CTX_get(ctx); if (t == NULL) goto err; if (a->Z_is_one) { if (!BN_copy(x0, &a->X)) goto err; if (!BN_copy(y0, &a->Y)) goto err; } else { if (!EC_POINT_get_affine_coordinates_GF2m(group, a, x0, y0, ctx)) goto err; } if (b->Z_is_one) { if (!BN_copy(x1, &b->X)) goto err; if (!BN_copy(y1, &b->Y)) goto err; } else { if (!EC_POINT_get_affine_coordinates_GF2m(group, b, x1, y1, ctx)) goto err; } if (BN_GF2m_cmp(x0, x1)) { if (!BN_GF2m_add(t, x0, x1)) goto err; if (!BN_GF2m_add(s, y0, y1)) goto err; if (!group->meth->field_div(group, s, s, t, ctx)) goto err; if (!group->meth->field_sqr(group, x2, s, ctx)) goto err; if (!BN_GF2m_add(x2, x2, &group->a)) goto err; if (!BN_GF2m_add(x2, x2, s)) goto err; if (!BN_GF2m_add(x2, x2, t)) goto err; } else { if (BN_GF2m_cmp(y0, y1) || BN_is_zero(x1)) { if (!EC_POINT_set_to_infinity(group, r)) goto err; ret = 1; goto err; } if (!group->meth->field_div(group, s, y1, x1, ctx)) goto err; if (!BN_GF2m_add(s, s, x1)) goto err; if (!group->meth->field_sqr(group, x2, s, ctx)) goto err; if (!BN_GF2m_add(x2, x2, s)) goto err; if (!BN_GF2m_add(x2, x2, &group->a)) goto err; } if (!BN_GF2m_add(y2, x1, x2)) goto err; if (!group->meth->field_mul(group, y2, y2, s, ctx)) goto err; if (!BN_GF2m_add(y2, y2, x2)) goto err; if (!BN_GF2m_add(y2, y2, y1)) goto err; if (!EC_POINT_set_affine_coordinates_GF2m(group, r, x2, y2, ctx)) goto err; ret = 1; err: BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } /* Computes 2 * a and stores the result in r. r could be a. * Uses algorithm A.10.2 of IEEE P1363. */ int ec_GF2m_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx) { return ec_GF2m_simple_add(group, r, a, a, ctx); } int ec_GF2m_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) { if (EC_POINT_is_at_infinity(group, point) || BN_is_zero(&point->Y)) /* point is its own inverse */ return 1; if (!EC_POINT_make_affine(group, point, ctx)) return 0; return BN_GF2m_add(&point->Y, &point->X, &point->Y); } /* Indicates whether the given point is the point at infinity. */ int ec_GF2m_simple_is_at_infinity(const EC_GROUP *group, const EC_POINT *point) { return BN_is_zero(&point->Z); } /* Determines whether the given EC_POINT is an actual point on the curve defined * in the EC_GROUP. A point is valid if it satisfies the Weierstrass equation: * y^2 + x*y = x^3 + a*x^2 + b. */ int ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx) { int ret = -1; BN_CTX *new_ctx = NULL; BIGNUM *lh, *y2; int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); if (EC_POINT_is_at_infinity(group, point)) return 1; field_mul = group->meth->field_mul; field_sqr = group->meth->field_sqr; /* only support affine coordinates */ if (!point->Z_is_one) return -1; if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return -1; } BN_CTX_start(ctx); y2 = BN_CTX_get(ctx); lh = BN_CTX_get(ctx); if (lh == NULL) goto err; /* * We have a curve defined by a Weierstrass equation y^2 + x*y = x^3 * + a*x^2 + b. <=> x^3 + a*x^2 + x*y + b + y^2 = 0 <=> ((x + a) * x * + y ) * x + b + y^2 = 0 */ if (!BN_GF2m_add(lh, &point->X, &group->a)) goto err; if (!field_mul(group, lh, lh, &point->X, ctx)) goto err; if (!BN_GF2m_add(lh, lh, &point->Y)) goto err; if (!field_mul(group, lh, lh, &point->X, ctx)) goto err; if (!BN_GF2m_add(lh, lh, &group->b)) goto err; if (!field_sqr(group, y2, &point->Y, ctx)) goto err; if (!BN_GF2m_add(lh, lh, y2)) goto err; ret = BN_is_zero(lh); err: if (ctx) BN_CTX_end(ctx); if (new_ctx) BN_CTX_free(new_ctx); return ret; } /* Indicates whether two points are equal. * Return values: * -1 error * 0 equal (in affine coordinates) * 1 not equal */ int ec_GF2m_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b, BN_CTX * ctx) { BIGNUM *aX, *aY, *bX, *bY; BN_CTX *new_ctx = NULL; int ret = -1; if (EC_POINT_is_at_infinity(group, a)) { return EC_POINT_is_at_infinity(group, b) ? 0 : 1; } if (EC_POINT_is_at_infinity(group, b)) return 1; if (a->Z_is_one && b->Z_is_one) { return ((BN_cmp(&a->X, &b->X) == 0) && BN_cmp(&a->Y, &b->Y) == 0) ? 0 : 1; } if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return -1; } BN_CTX_start(ctx); aX = BN_CTX_get(ctx); aY = BN_CTX_get(ctx); bX = BN_CTX_get(ctx); bY = BN_CTX_get(ctx); if (bY == NULL) goto err; if (!EC_POINT_get_affine_coordinates_GF2m(group, a, aX, aY, ctx)) goto err; if (!EC_POINT_get_affine_coordinates_GF2m(group, b, bX, bY, ctx)) goto err; ret = ((BN_cmp(aX, bX) == 0) && BN_cmp(aY, bY) == 0) ? 0 : 1; err: if (ctx) BN_CTX_end(ctx); if (new_ctx) BN_CTX_free(new_ctx); return ret; } /* Forces the given EC_POINT to internally use affine coordinates. */ int ec_GF2m_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx) { BN_CTX *new_ctx = NULL; BIGNUM *x, *y; int ret = 0; if (point->Z_is_one || EC_POINT_is_at_infinity(group, point)) return 1; if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } BN_CTX_start(ctx); x = BN_CTX_get(ctx); y = BN_CTX_get(ctx); if (y == NULL) goto err; if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx)) goto err; if (!BN_copy(&point->X, x)) goto err; if (!BN_copy(&point->Y, y)) goto err; if (!BN_one(&point->Z)) goto err; ret = 1; err: if (ctx) BN_CTX_end(ctx); if (new_ctx) BN_CTX_free(new_ctx); return ret; } /* Forces each of the EC_POINTs in the given array to use affine coordinates. */ int ec_GF2m_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx) { size_t i; for (i = 0; i < num; i++) { if (!group->meth->make_affine(group, points[i], ctx)) return 0; } return 1; } /* Wrapper to simple binary polynomial field multiplication implementation. */ int ec_GF2m_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { return BN_GF2m_mod_mul_arr(r, a, b, group->poly, ctx); } /* Wrapper to simple binary polynomial field squaring implementation. */ int ec_GF2m_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) { return BN_GF2m_mod_sqr_arr(r, a, group->poly, ctx); } /* Wrapper to simple binary polynomial field division implementation. */ int ec_GF2m_simple_field_div(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { return BN_GF2m_mod_div(r, a, b, &group->field, ctx); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ec_check.c0000644000175000017500000000772712360020705020547 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "ec_lcl.h" #include int EC_GROUP_check(const EC_GROUP * group, BN_CTX * ctx) { int ret = 0; BIGNUM *order; BN_CTX *new_ctx = NULL; EC_POINT *point = NULL; if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) { ECerr(EC_F_EC_GROUP_CHECK, ERR_R_MALLOC_FAILURE); goto err; } } BN_CTX_start(ctx); if ((order = BN_CTX_get(ctx)) == NULL) goto err; /* check the discriminant */ if (!EC_GROUP_check_discriminant(group, ctx)) { ECerr(EC_F_EC_GROUP_CHECK, EC_R_DISCRIMINANT_IS_ZERO); goto err; } /* check the generator */ if (group->generator == NULL) { ECerr(EC_F_EC_GROUP_CHECK, EC_R_UNDEFINED_GENERATOR); goto err; } if (!EC_POINT_is_on_curve(group, group->generator, ctx)) { ECerr(EC_F_EC_GROUP_CHECK, EC_R_POINT_IS_NOT_ON_CURVE); goto err; } /* check the order of the generator */ if ((point = EC_POINT_new(group)) == NULL) goto err; if (!EC_GROUP_get_order(group, order, ctx)) goto err; if (BN_is_zero(order)) { ECerr(EC_F_EC_GROUP_CHECK, EC_R_UNDEFINED_ORDER); goto err; } if (!EC_POINT_mul(group, point, order, NULL, NULL, ctx)) goto err; if (!EC_POINT_is_at_infinity(group, point)) { ECerr(EC_F_EC_GROUP_CHECK, EC_R_INVALID_GROUP_ORDER); goto err; } ret = 1; err: if (ctx != NULL) BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); if (point) EC_POINT_free(point); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ec_asn1.c0000644000175000017500000010243312360020705020322 0ustar /* $OpenBSD: ec_asn1.c,v 1.8 2014/07/01 21:26:27 miod Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 2000-2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "ec_lcl.h" #include #include #include int EC_GROUP_get_basis_type(const EC_GROUP * group) { int i = 0; if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) != NID_X9_62_characteristic_two_field) /* everything else is currently not supported */ return 0; while (group->poly[i] != 0) i++; if (i == 4) return NID_X9_62_ppBasis; else if (i == 2) return NID_X9_62_tpBasis; else /* everything else is currently not supported */ return 0; } #ifndef OPENSSL_NO_EC2M int EC_GROUP_get_trinomial_basis(const EC_GROUP * group, unsigned int *k) { if (group == NULL) return 0; if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) != NID_X9_62_characteristic_two_field || !((group->poly[0] != 0) && (group->poly[1] != 0) && (group->poly[2] == 0))) { ECerr(EC_F_EC_GROUP_GET_TRINOMIAL_BASIS, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (k) *k = group->poly[1]; return 1; } int EC_GROUP_get_pentanomial_basis(const EC_GROUP * group, unsigned int *k1, unsigned int *k2, unsigned int *k3) { if (group == NULL) return 0; if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) != NID_X9_62_characteristic_two_field || !((group->poly[0] != 0) && (group->poly[1] != 0) && (group->poly[2] != 0) && (group->poly[3] != 0) && (group->poly[4] == 0))) { ECerr(EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (k1) *k1 = group->poly[3]; if (k2) *k2 = group->poly[2]; if (k3) *k3 = group->poly[1]; return 1; } #endif /* some structures needed for the asn1 encoding */ typedef struct x9_62_pentanomial_st { long k1; long k2; long k3; } X9_62_PENTANOMIAL; typedef struct x9_62_characteristic_two_st { long m; ASN1_OBJECT *type; union { char *ptr; /* NID_X9_62_onBasis */ ASN1_NULL *onBasis; /* NID_X9_62_tpBasis */ ASN1_INTEGER *tpBasis; /* NID_X9_62_ppBasis */ X9_62_PENTANOMIAL *ppBasis; /* anything else */ ASN1_TYPE *other; } p; } X9_62_CHARACTERISTIC_TWO; typedef struct x9_62_fieldid_st { ASN1_OBJECT *fieldType; union { char *ptr; /* NID_X9_62_prime_field */ ASN1_INTEGER *prime; /* NID_X9_62_characteristic_two_field */ X9_62_CHARACTERISTIC_TWO *char_two; /* anything else */ ASN1_TYPE *other; } p; } X9_62_FIELDID; typedef struct x9_62_curve_st { ASN1_OCTET_STRING *a; ASN1_OCTET_STRING *b; ASN1_BIT_STRING *seed; } X9_62_CURVE; typedef struct ec_parameters_st { long version; X9_62_FIELDID *fieldID; X9_62_CURVE *curve; ASN1_OCTET_STRING *base; ASN1_INTEGER *order; ASN1_INTEGER *cofactor; } ECPARAMETERS; struct ecpk_parameters_st { int type; union { ASN1_OBJECT *named_curve; ECPARAMETERS *parameters; ASN1_NULL *implicitlyCA; } value; } /* ECPKPARAMETERS */ ; /* SEC1 ECPrivateKey */ typedef struct ec_privatekey_st { long version; ASN1_OCTET_STRING *privateKey; ECPKPARAMETERS *parameters; ASN1_BIT_STRING *publicKey; } EC_PRIVATEKEY; /* the OpenSSL ASN.1 definitions */ ASN1_SEQUENCE(X9_62_PENTANOMIAL) = { ASN1_SIMPLE(X9_62_PENTANOMIAL, k1, LONG), ASN1_SIMPLE(X9_62_PENTANOMIAL, k2, LONG), ASN1_SIMPLE(X9_62_PENTANOMIAL, k3, LONG) } ASN1_SEQUENCE_END(X9_62_PENTANOMIAL) DECLARE_ASN1_ALLOC_FUNCTIONS(X9_62_PENTANOMIAL) IMPLEMENT_ASN1_ALLOC_FUNCTIONS(X9_62_PENTANOMIAL) ASN1_ADB_TEMPLATE(char_two_def) = ASN1_SIMPLE(X9_62_CHARACTERISTIC_TWO, p.other, ASN1_ANY); ASN1_ADB(X9_62_CHARACTERISTIC_TWO) = { ADB_ENTRY(NID_X9_62_onBasis, ASN1_SIMPLE(X9_62_CHARACTERISTIC_TWO, p.onBasis, ASN1_NULL)), ADB_ENTRY(NID_X9_62_tpBasis, ASN1_SIMPLE(X9_62_CHARACTERISTIC_TWO, p.tpBasis, ASN1_INTEGER)), ADB_ENTRY(NID_X9_62_ppBasis, ASN1_SIMPLE(X9_62_CHARACTERISTIC_TWO, p.ppBasis, X9_62_PENTANOMIAL)) } ASN1_ADB_END(X9_62_CHARACTERISTIC_TWO, 0, type, 0, &char_two_def_tt, NULL); ASN1_SEQUENCE(X9_62_CHARACTERISTIC_TWO) = { ASN1_SIMPLE(X9_62_CHARACTERISTIC_TWO, m, LONG), ASN1_SIMPLE(X9_62_CHARACTERISTIC_TWO, type, ASN1_OBJECT), ASN1_ADB_OBJECT(X9_62_CHARACTERISTIC_TWO) } ASN1_SEQUENCE_END(X9_62_CHARACTERISTIC_TWO) DECLARE_ASN1_ALLOC_FUNCTIONS(X9_62_CHARACTERISTIC_TWO) IMPLEMENT_ASN1_ALLOC_FUNCTIONS(X9_62_CHARACTERISTIC_TWO) ASN1_ADB_TEMPLATE(fieldID_def) = ASN1_SIMPLE(X9_62_FIELDID, p.other, ASN1_ANY); ASN1_ADB(X9_62_FIELDID) = { ADB_ENTRY(NID_X9_62_prime_field, ASN1_SIMPLE(X9_62_FIELDID, p.prime, ASN1_INTEGER)), ADB_ENTRY(NID_X9_62_characteristic_two_field, ASN1_SIMPLE(X9_62_FIELDID, p.char_two, X9_62_CHARACTERISTIC_TWO)) } ASN1_ADB_END(X9_62_FIELDID, 0, fieldType, 0, &fieldID_def_tt, NULL); ASN1_SEQUENCE(X9_62_FIELDID) = { ASN1_SIMPLE(X9_62_FIELDID, fieldType, ASN1_OBJECT), ASN1_ADB_OBJECT(X9_62_FIELDID) } ASN1_SEQUENCE_END(X9_62_FIELDID) ASN1_SEQUENCE(X9_62_CURVE) = { ASN1_SIMPLE(X9_62_CURVE, a, ASN1_OCTET_STRING), ASN1_SIMPLE(X9_62_CURVE, b, ASN1_OCTET_STRING), ASN1_OPT(X9_62_CURVE, seed, ASN1_BIT_STRING) } ASN1_SEQUENCE_END(X9_62_CURVE) ASN1_SEQUENCE(ECPARAMETERS) = { ASN1_SIMPLE(ECPARAMETERS, version, LONG), ASN1_SIMPLE(ECPARAMETERS, fieldID, X9_62_FIELDID), ASN1_SIMPLE(ECPARAMETERS, curve, X9_62_CURVE), ASN1_SIMPLE(ECPARAMETERS, base, ASN1_OCTET_STRING), ASN1_SIMPLE(ECPARAMETERS, order, ASN1_INTEGER), ASN1_OPT(ECPARAMETERS, cofactor, ASN1_INTEGER) } ASN1_SEQUENCE_END(ECPARAMETERS) DECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS) IMPLEMENT_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS) ASN1_CHOICE(ECPKPARAMETERS) = { ASN1_SIMPLE(ECPKPARAMETERS, value.named_curve, ASN1_OBJECT), ASN1_SIMPLE(ECPKPARAMETERS, value.parameters, ECPARAMETERS), ASN1_SIMPLE(ECPKPARAMETERS, value.implicitlyCA, ASN1_NULL) } ASN1_CHOICE_END(ECPKPARAMETERS) DECLARE_ASN1_FUNCTIONS_const(ECPKPARAMETERS) DECLARE_ASN1_ENCODE_FUNCTIONS_const(ECPKPARAMETERS, ECPKPARAMETERS) IMPLEMENT_ASN1_FUNCTIONS_const(ECPKPARAMETERS) ASN1_SEQUENCE(EC_PRIVATEKEY) = { ASN1_SIMPLE(EC_PRIVATEKEY, version, LONG), ASN1_SIMPLE(EC_PRIVATEKEY, privateKey, ASN1_OCTET_STRING), ASN1_EXP_OPT(EC_PRIVATEKEY, parameters, ECPKPARAMETERS, 0), ASN1_EXP_OPT(EC_PRIVATEKEY, publicKey, ASN1_BIT_STRING, 1) } ASN1_SEQUENCE_END(EC_PRIVATEKEY) DECLARE_ASN1_FUNCTIONS_const(EC_PRIVATEKEY) DECLARE_ASN1_ENCODE_FUNCTIONS_const(EC_PRIVATEKEY, EC_PRIVATEKEY) IMPLEMENT_ASN1_FUNCTIONS_const(EC_PRIVATEKEY) /* some declarations of internal function */ /* ec_asn1_group2field() sets the values in a X9_62_FIELDID object */ static int ec_asn1_group2fieldid(const EC_GROUP *, X9_62_FIELDID *); /* ec_asn1_group2curve() sets the values in a X9_62_CURVE object */ static int ec_asn1_group2curve(const EC_GROUP *, X9_62_CURVE *); /* ec_asn1_parameters2group() creates a EC_GROUP object from a * ECPARAMETERS object */ static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *); /* ec_asn1_group2parameters() creates a ECPARAMETERS object from a * EC_GROUP object */ static ECPARAMETERS *ec_asn1_group2parameters(const EC_GROUP *, ECPARAMETERS *); /* ec_asn1_pkparameters2group() creates a EC_GROUP object from a * ECPKPARAMETERS object */ static EC_GROUP *ec_asn1_pkparameters2group(const ECPKPARAMETERS *); /* ec_asn1_group2pkparameters() creates a ECPKPARAMETERS object from a * EC_GROUP object */ static ECPKPARAMETERS *ec_asn1_group2pkparameters(const EC_GROUP *, ECPKPARAMETERS *); /* the function definitions */ static int ec_asn1_group2fieldid(const EC_GROUP * group, X9_62_FIELDID * field) { int ok = 0, nid; BIGNUM *tmp = NULL; if (group == NULL || field == NULL) return 0; /* clear the old values (if necessary) */ if (field->fieldType != NULL) ASN1_OBJECT_free(field->fieldType); if (field->p.other != NULL) ASN1_TYPE_free(field->p.other); nid = EC_METHOD_get_field_type(EC_GROUP_method_of(group)); /* set OID for the field */ if ((field->fieldType = OBJ_nid2obj(nid)) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_OBJ_LIB); goto err; } if (nid == NID_X9_62_prime_field) { if ((tmp = BN_new()) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); goto err; } /* the parameters are specified by the prime number p */ if (!EC_GROUP_get_curve_GFp(group, tmp, NULL, NULL, NULL)) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_EC_LIB); goto err; } /* set the prime number */ field->p.prime = BN_to_ASN1_INTEGER(tmp, NULL); if (field->p.prime == NULL) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_ASN1_LIB); goto err; } } else /* nid == NID_X9_62_characteristic_two_field */ #ifdef OPENSSL_NO_EC2M { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, EC_R_GF2M_NOT_SUPPORTED); goto err; } #else { int field_type; X9_62_CHARACTERISTIC_TWO *char_two; field->p.char_two = X9_62_CHARACTERISTIC_TWO_new(); char_two = field->p.char_two; if (char_two == NULL) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); goto err; } char_two->m = (long) EC_GROUP_get_degree(group); field_type = EC_GROUP_get_basis_type(group); if (field_type == 0) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_EC_LIB); goto err; } /* set base type OID */ if ((char_two->type = OBJ_nid2obj(field_type)) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_OBJ_LIB); goto err; } if (field_type == NID_X9_62_tpBasis) { unsigned int k; if (!EC_GROUP_get_trinomial_basis(group, &k)) goto err; char_two->p.tpBasis = ASN1_INTEGER_new(); if (!char_two->p.tpBasis) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); goto err; } if (!ASN1_INTEGER_set(char_two->p.tpBasis, (long) k)) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_ASN1_LIB); goto err; } } else if (field_type == NID_X9_62_ppBasis) { unsigned int k1, k2, k3; if (!EC_GROUP_get_pentanomial_basis(group, &k1, &k2, &k3)) goto err; char_two->p.ppBasis = X9_62_PENTANOMIAL_new(); if (!char_two->p.ppBasis) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); goto err; } /* set k? values */ char_two->p.ppBasis->k1 = (long) k1; char_two->p.ppBasis->k2 = (long) k2; char_two->p.ppBasis->k3 = (long) k3; } else { /* field_type == NID_X9_62_onBasis */ /* for ONB the parameters are (asn1) NULL */ char_two->p.onBasis = ASN1_NULL_new(); if (!char_two->p.onBasis) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); goto err; } } } #endif ok = 1; err: if (tmp) BN_free(tmp); return (ok); } static int ec_asn1_group2curve(const EC_GROUP * group, X9_62_CURVE * curve) { int ok = 0, nid; BIGNUM *tmp_1 = NULL, *tmp_2 = NULL; unsigned char *buffer_1 = NULL, *buffer_2 = NULL, *a_buf = NULL, *b_buf = NULL; size_t len_1, len_2; unsigned char char_zero = 0; if (!group || !curve || !curve->a || !curve->b) return 0; if ((tmp_1 = BN_new()) == NULL || (tmp_2 = BN_new()) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_MALLOC_FAILURE); goto err; } nid = EC_METHOD_get_field_type(EC_GROUP_method_of(group)); /* get a and b */ if (nid == NID_X9_62_prime_field) { if (!EC_GROUP_get_curve_GFp(group, NULL, tmp_1, tmp_2, NULL)) { ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_EC_LIB); goto err; } } #ifndef OPENSSL_NO_EC2M else { /* nid == NID_X9_62_characteristic_two_field */ if (!EC_GROUP_get_curve_GF2m(group, NULL, tmp_1, tmp_2, NULL)) { ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_EC_LIB); goto err; } } #endif len_1 = (size_t) BN_num_bytes(tmp_1); len_2 = (size_t) BN_num_bytes(tmp_2); if (len_1 == 0) { /* len_1 == 0 => a == 0 */ a_buf = &char_zero; len_1 = 1; } else { if ((buffer_1 = malloc(len_1)) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_MALLOC_FAILURE); goto err; } if ((len_1 = BN_bn2bin(tmp_1, buffer_1)) == 0) { ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_BN_LIB); goto err; } a_buf = buffer_1; } if (len_2 == 0) { /* len_2 == 0 => b == 0 */ b_buf = &char_zero; len_2 = 1; } else { if ((buffer_2 = malloc(len_2)) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_MALLOC_FAILURE); goto err; } if ((len_2 = BN_bn2bin(tmp_2, buffer_2)) == 0) { ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_BN_LIB); goto err; } b_buf = buffer_2; } /* set a and b */ if (!M_ASN1_OCTET_STRING_set(curve->a, a_buf, len_1) || !M_ASN1_OCTET_STRING_set(curve->b, b_buf, len_2)) { ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_ASN1_LIB); goto err; } /* set the seed (optional) */ if (group->seed) { if (!curve->seed) if ((curve->seed = ASN1_BIT_STRING_new()) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_MALLOC_FAILURE); goto err; } curve->seed->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); curve->seed->flags |= ASN1_STRING_FLAG_BITS_LEFT; if (!ASN1_BIT_STRING_set(curve->seed, group->seed, (int) group->seed_len)) { ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_ASN1_LIB); goto err; } } else { if (curve->seed) { ASN1_BIT_STRING_free(curve->seed); curve->seed = NULL; } } ok = 1; err: free(buffer_1); free(buffer_2); if (tmp_1) BN_free(tmp_1); if (tmp_2) BN_free(tmp_2); return (ok); } static ECPARAMETERS * ec_asn1_group2parameters(const EC_GROUP * group, ECPARAMETERS * param) { int ok = 0; size_t len = 0; ECPARAMETERS *ret = NULL; BIGNUM *tmp = NULL; unsigned char *buffer = NULL; const EC_POINT *point = NULL; point_conversion_form_t form; if ((tmp = BN_new()) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_MALLOC_FAILURE); goto err; } if (param == NULL) { if ((ret = ECPARAMETERS_new()) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_MALLOC_FAILURE); goto err; } } else ret = param; /* set the version (always one) */ ret->version = (long) 0x1; /* set the fieldID */ if (!ec_asn1_group2fieldid(group, ret->fieldID)) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_EC_LIB); goto err; } /* set the curve */ if (!ec_asn1_group2curve(group, ret->curve)) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_EC_LIB); goto err; } /* set the base point */ if ((point = EC_GROUP_get0_generator(group)) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, EC_R_UNDEFINED_GENERATOR); goto err; } form = EC_GROUP_get_point_conversion_form(group); len = EC_POINT_point2oct(group, point, form, NULL, len, NULL); if (len == 0) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_EC_LIB); goto err; } if ((buffer = malloc(len)) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_MALLOC_FAILURE); goto err; } if (!EC_POINT_point2oct(group, point, form, buffer, len, NULL)) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_EC_LIB); goto err; } if (ret->base == NULL && (ret->base = ASN1_OCTET_STRING_new()) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_MALLOC_FAILURE); goto err; } if (!ASN1_OCTET_STRING_set(ret->base, buffer, len)) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_ASN1_LIB); goto err; } /* set the order */ if (!EC_GROUP_get_order(group, tmp, NULL)) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_EC_LIB); goto err; } ret->order = BN_to_ASN1_INTEGER(tmp, ret->order); if (ret->order == NULL) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_ASN1_LIB); goto err; } /* set the cofactor (optional) */ if (EC_GROUP_get_cofactor(group, tmp, NULL)) { ret->cofactor = BN_to_ASN1_INTEGER(tmp, ret->cofactor); if (ret->cofactor == NULL) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_ASN1_LIB); goto err; } } ok = 1; err: if (!ok) { if (ret && !param) ECPARAMETERS_free(ret); ret = NULL; } if (tmp) BN_free(tmp); free(buffer); return (ret); } ECPKPARAMETERS * ec_asn1_group2pkparameters(const EC_GROUP * group, ECPKPARAMETERS * params) { int ok = 1, tmp; ECPKPARAMETERS *ret = params; if (ret == NULL) { if ((ret = ECPKPARAMETERS_new()) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2PKPARAMETERS, ERR_R_MALLOC_FAILURE); return NULL; } } else { if (ret->type == 0 && ret->value.named_curve) ASN1_OBJECT_free(ret->value.named_curve); else if (ret->type == 1 && ret->value.parameters) ECPARAMETERS_free(ret->value.parameters); } if (EC_GROUP_get_asn1_flag(group)) { /* * use the asn1 OID to describe the the elliptic curve * parameters */ tmp = EC_GROUP_get_curve_name(group); if (tmp) { ret->type = 0; if ((ret->value.named_curve = OBJ_nid2obj(tmp)) == NULL) ok = 0; } else /* we don't kmow the nid => ERROR */ ok = 0; } else { /* use the ECPARAMETERS structure */ ret->type = 1; if ((ret->value.parameters = ec_asn1_group2parameters( group, NULL)) == NULL) ok = 0; } if (!ok) { ECPKPARAMETERS_free(ret); return NULL; } return ret; } static EC_GROUP * ec_asn1_parameters2group(const ECPARAMETERS * params) { int ok = 0, tmp; EC_GROUP *ret = NULL; BIGNUM *p = NULL, *a = NULL, *b = NULL; EC_POINT *point = NULL; long field_bits; if (!params->fieldID || !params->fieldID->fieldType || !params->fieldID->p.ptr) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR); goto err; } /* now extract the curve parameters a and b */ if (!params->curve || !params->curve->a || !params->curve->a->data || !params->curve->b || !params->curve->b->data) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR); goto err; } a = BN_bin2bn(params->curve->a->data, params->curve->a->length, NULL); if (a == NULL) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_BN_LIB); goto err; } b = BN_bin2bn(params->curve->b->data, params->curve->b->length, NULL); if (b == NULL) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_BN_LIB); goto err; } /* get the field parameters */ tmp = OBJ_obj2nid(params->fieldID->fieldType); if (tmp == NID_X9_62_characteristic_two_field) #ifdef OPENSSL_NO_EC2M { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_GF2M_NOT_SUPPORTED); goto err; } #else { X9_62_CHARACTERISTIC_TWO *char_two; char_two = params->fieldID->p.char_two; field_bits = char_two->m; if (field_bits > OPENSSL_ECC_MAX_FIELD_BITS) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_FIELD_TOO_LARGE); goto err; } if ((p = BN_new()) == NULL) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_MALLOC_FAILURE); goto err; } /* get the base type */ tmp = OBJ_obj2nid(char_two->type); if (tmp == NID_X9_62_tpBasis) { long tmp_long; if (!char_two->p.tpBasis) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR); goto err; } tmp_long = ASN1_INTEGER_get(char_two->p.tpBasis); if (!(char_two->m > tmp_long && tmp_long > 0)) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_TRINOMIAL_BASIS); goto err; } /* create the polynomial */ if (!BN_set_bit(p, (int) char_two->m)) goto err; if (!BN_set_bit(p, (int) tmp_long)) goto err; if (!BN_set_bit(p, 0)) goto err; } else if (tmp == NID_X9_62_ppBasis) { X9_62_PENTANOMIAL *penta; penta = char_two->p.ppBasis; if (!penta) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR); goto err; } if (!(char_two->m > penta->k3 && penta->k3 > penta->k2 && penta->k2 > penta->k1 && penta->k1 > 0)) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_PENTANOMIAL_BASIS); goto err; } /* create the polynomial */ if (!BN_set_bit(p, (int) char_two->m)) goto err; if (!BN_set_bit(p, (int) penta->k1)) goto err; if (!BN_set_bit(p, (int) penta->k2)) goto err; if (!BN_set_bit(p, (int) penta->k3)) goto err; if (!BN_set_bit(p, 0)) goto err; } else if (tmp == NID_X9_62_onBasis) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_NOT_IMPLEMENTED); goto err; } else { /* error */ ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR); goto err; } /* create the EC_GROUP structure */ ret = EC_GROUP_new_curve_GF2m(p, a, b, NULL); } #endif else if (tmp == NID_X9_62_prime_field) { /* we have a curve over a prime field */ /* extract the prime number */ if (!params->fieldID->p.prime) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR); goto err; } p = ASN1_INTEGER_to_BN(params->fieldID->p.prime, NULL); if (p == NULL) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_ASN1_LIB); goto err; } if (BN_is_negative(p) || BN_is_zero(p)) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_FIELD); goto err; } field_bits = BN_num_bits(p); if (field_bits > OPENSSL_ECC_MAX_FIELD_BITS) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_FIELD_TOO_LARGE); goto err; } /* create the EC_GROUP structure */ ret = EC_GROUP_new_curve_GFp(p, a, b, NULL); } else { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_FIELD); goto err; } if (ret == NULL) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_EC_LIB); goto err; } /* extract seed (optional) */ if (params->curve->seed != NULL) { free(ret->seed); if (!(ret->seed = malloc(params->curve->seed->length))) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_MALLOC_FAILURE); goto err; } memcpy(ret->seed, params->curve->seed->data, params->curve->seed->length); ret->seed_len = params->curve->seed->length; } if (!params->order || !params->base || !params->base->data) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR); goto err; } if ((point = EC_POINT_new(ret)) == NULL) goto err; /* set the point conversion form */ EC_GROUP_set_point_conversion_form(ret, (point_conversion_form_t) (params->base->data[0] & ~0x01)); /* extract the ec point */ if (!EC_POINT_oct2point(ret, point, params->base->data, params->base->length, NULL)) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_EC_LIB); goto err; } /* extract the order */ if ((a = ASN1_INTEGER_to_BN(params->order, a)) == NULL) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_ASN1_LIB); goto err; } if (BN_is_negative(a) || BN_is_zero(a)) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_GROUP_ORDER); goto err; } if (BN_num_bits(a) > (int) field_bits + 1) { /* Hasse bound */ ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_GROUP_ORDER); goto err; } /* extract the cofactor (optional) */ if (params->cofactor == NULL) { if (b) { BN_free(b); b = NULL; } } else if ((b = ASN1_INTEGER_to_BN(params->cofactor, b)) == NULL) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_ASN1_LIB); goto err; } /* set the generator, order and cofactor (if present) */ if (!EC_GROUP_set_generator(ret, point, a, b)) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_EC_LIB); goto err; } ok = 1; err: if (!ok) { if (ret) EC_GROUP_clear_free(ret); ret = NULL; } if (p) BN_free(p); if (a) BN_free(a); if (b) BN_free(b); if (point) EC_POINT_free(point); return (ret); } EC_GROUP * ec_asn1_pkparameters2group(const ECPKPARAMETERS * params) { EC_GROUP *ret = NULL; int tmp = 0; if (params == NULL) { ECerr(EC_F_EC_ASN1_PKPARAMETERS2GROUP, EC_R_MISSING_PARAMETERS); return NULL; } if (params->type == 0) {/* the curve is given by an OID */ tmp = OBJ_obj2nid(params->value.named_curve); if ((ret = EC_GROUP_new_by_curve_name(tmp)) == NULL) { ECerr(EC_F_EC_ASN1_PKPARAMETERS2GROUP, EC_R_EC_GROUP_NEW_BY_NAME_FAILURE); return NULL; } EC_GROUP_set_asn1_flag(ret, OPENSSL_EC_NAMED_CURVE); } else if (params->type == 1) { /* the parameters are given by a * ECPARAMETERS structure */ ret = ec_asn1_parameters2group(params->value.parameters); if (!ret) { ECerr(EC_F_EC_ASN1_PKPARAMETERS2GROUP, ERR_R_EC_LIB); return NULL; } EC_GROUP_set_asn1_flag(ret, 0x0); } else if (params->type == 2) { /* implicitlyCA */ return NULL; } else { ECerr(EC_F_EC_ASN1_PKPARAMETERS2GROUP, EC_R_ASN1_ERROR); return NULL; } return ret; } /* EC_GROUP <-> DER encoding of ECPKPARAMETERS */ EC_GROUP * d2i_ECPKParameters(EC_GROUP ** a, const unsigned char **in, long len) { EC_GROUP *group = NULL; ECPKPARAMETERS *params = NULL; if ((params = d2i_ECPKPARAMETERS(NULL, in, len)) == NULL) { ECerr(EC_F_D2I_ECPKPARAMETERS, EC_R_D2I_ECPKPARAMETERS_FAILURE); ECPKPARAMETERS_free(params); return NULL; } if ((group = ec_asn1_pkparameters2group(params)) == NULL) { ECerr(EC_F_D2I_ECPKPARAMETERS, EC_R_PKPARAMETERS2GROUP_FAILURE); ECPKPARAMETERS_free(params); return NULL; } if (a && *a) EC_GROUP_clear_free(*a); if (a) *a = group; ECPKPARAMETERS_free(params); return (group); } int i2d_ECPKParameters(const EC_GROUP * a, unsigned char **out) { int ret = 0; ECPKPARAMETERS *tmp = ec_asn1_group2pkparameters(a, NULL); if (tmp == NULL) { ECerr(EC_F_I2D_ECPKPARAMETERS, EC_R_GROUP2PKPARAMETERS_FAILURE); return 0; } if ((ret = i2d_ECPKPARAMETERS(tmp, out)) == 0) { ECerr(EC_F_I2D_ECPKPARAMETERS, EC_R_I2D_ECPKPARAMETERS_FAILURE); ECPKPARAMETERS_free(tmp); return 0; } ECPKPARAMETERS_free(tmp); return (ret); } /* some EC_KEY functions */ EC_KEY * d2i_ECPrivateKey(EC_KEY ** a, const unsigned char **in, long len) { int ok = 0; EC_KEY *ret = NULL; EC_PRIVATEKEY *priv_key = NULL; if ((priv_key = EC_PRIVATEKEY_new()) == NULL) { ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE); return NULL; } if ((priv_key = d2i_EC_PRIVATEKEY(&priv_key, in, len)) == NULL) { ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB); EC_PRIVATEKEY_free(priv_key); return NULL; } if (a == NULL || *a == NULL) { if ((ret = EC_KEY_new()) == NULL) { ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE); goto err; } if (a) *a = ret; } else ret = *a; if (priv_key->parameters) { if (ret->group) EC_GROUP_clear_free(ret->group); ret->group = ec_asn1_pkparameters2group(priv_key->parameters); } if (ret->group == NULL) { ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB); goto err; } ret->version = priv_key->version; if (priv_key->privateKey) { ret->priv_key = BN_bin2bn( M_ASN1_STRING_data(priv_key->privateKey), M_ASN1_STRING_length(priv_key->privateKey), ret->priv_key); if (ret->priv_key == NULL) { ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_BN_LIB); goto err; } } else { ECerr(EC_F_D2I_ECPRIVATEKEY, EC_R_MISSING_PRIVATE_KEY); goto err; } if (priv_key->publicKey) { const unsigned char *pub_oct; size_t pub_oct_len; if (ret->pub_key) EC_POINT_clear_free(ret->pub_key); ret->pub_key = EC_POINT_new(ret->group); if (ret->pub_key == NULL) { ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB); goto err; } pub_oct = M_ASN1_STRING_data(priv_key->publicKey); pub_oct_len = M_ASN1_STRING_length(priv_key->publicKey); /* save the point conversion form */ ret->conv_form = (point_conversion_form_t) (pub_oct[0] & ~0x01); if (!EC_POINT_oct2point(ret->group, ret->pub_key, pub_oct, pub_oct_len, NULL)) { ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB); goto err; } } ok = 1; err: if (!ok) { if (ret) EC_KEY_free(ret); ret = NULL; } if (priv_key) EC_PRIVATEKEY_free(priv_key); return (ret); } int i2d_ECPrivateKey(EC_KEY * a, unsigned char **out) { int ret = 0, ok = 0; unsigned char *buffer = NULL; size_t buf_len = 0, tmp_len; EC_PRIVATEKEY *priv_key = NULL; if (a == NULL || a->group == NULL || a->priv_key == NULL) { ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_PASSED_NULL_PARAMETER); goto err; } if ((priv_key = EC_PRIVATEKEY_new()) == NULL) { ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE); goto err; } priv_key->version = a->version; buf_len = (size_t) BN_num_bytes(a->priv_key); buffer = malloc(buf_len); if (buffer == NULL) { ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE); goto err; } if (!BN_bn2bin(a->priv_key, buffer)) { ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_BN_LIB); goto err; } if (!M_ASN1_OCTET_STRING_set(priv_key->privateKey, buffer, buf_len)) { ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_ASN1_LIB); goto err; } if (!(a->enc_flag & EC_PKEY_NO_PARAMETERS)) { if ((priv_key->parameters = ec_asn1_group2pkparameters( a->group, priv_key->parameters)) == NULL) { ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_EC_LIB); goto err; } } if (!(a->enc_flag & EC_PKEY_NO_PUBKEY) && a->pub_key != NULL) { priv_key->publicKey = M_ASN1_BIT_STRING_new(); if (priv_key->publicKey == NULL) { ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE); goto err; } tmp_len = EC_POINT_point2oct(a->group, a->pub_key, a->conv_form, NULL, 0, NULL); if (tmp_len > buf_len) { unsigned char *tmp_buffer = realloc(buffer, tmp_len); if (!tmp_buffer) { ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE); goto err; } buffer = tmp_buffer; buf_len = tmp_len; } if (!EC_POINT_point2oct(a->group, a->pub_key, a->conv_form, buffer, buf_len, NULL)) { ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_EC_LIB); goto err; } priv_key->publicKey->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); priv_key->publicKey->flags |= ASN1_STRING_FLAG_BITS_LEFT; if (!M_ASN1_BIT_STRING_set(priv_key->publicKey, buffer, buf_len)) { ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_ASN1_LIB); goto err; } } if ((ret = i2d_EC_PRIVATEKEY(priv_key, out)) == 0) { ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_EC_LIB); goto err; } ok = 1; err: free(buffer); if (priv_key) EC_PRIVATEKEY_free(priv_key); return (ok ? ret : 0); } int i2d_ECParameters(EC_KEY * a, unsigned char **out) { if (a == NULL) { ECerr(EC_F_I2D_ECPARAMETERS, ERR_R_PASSED_NULL_PARAMETER); return 0; } return i2d_ECPKParameters(a->group, out); } EC_KEY * d2i_ECParameters(EC_KEY ** a, const unsigned char **in, long len) { EC_KEY *ret; if (in == NULL || *in == NULL) { ECerr(EC_F_D2I_ECPARAMETERS, ERR_R_PASSED_NULL_PARAMETER); return NULL; } if (a == NULL || *a == NULL) { if ((ret = EC_KEY_new()) == NULL) { ECerr(EC_F_D2I_ECPARAMETERS, ERR_R_MALLOC_FAILURE); return NULL; } if (a) *a = ret; } else ret = *a; if (!d2i_ECPKParameters(&ret->group, in, len)) { ECerr(EC_F_D2I_ECPARAMETERS, ERR_R_EC_LIB); return NULL; } return ret; } EC_KEY * o2i_ECPublicKey(EC_KEY ** a, const unsigned char **in, long len) { EC_KEY *ret = NULL; if (a == NULL || (*a) == NULL || (*a)->group == NULL) { /* * sorry, but a EC_GROUP-structur is necessary to set the * public key */ ECerr(EC_F_O2I_ECPUBLICKEY, ERR_R_PASSED_NULL_PARAMETER); return 0; } ret = *a; if (ret->pub_key == NULL && (ret->pub_key = EC_POINT_new(ret->group)) == NULL) { ECerr(EC_F_O2I_ECPUBLICKEY, ERR_R_MALLOC_FAILURE); return 0; } if (!EC_POINT_oct2point(ret->group, ret->pub_key, *in, len, NULL)) { ECerr(EC_F_O2I_ECPUBLICKEY, ERR_R_EC_LIB); return 0; } /* save the point conversion form */ ret->conv_form = (point_conversion_form_t) (*in[0] & ~0x01); *in += len; return ret; } int i2o_ECPublicKey(EC_KEY * a, unsigned char **out) { size_t buf_len = 0; int new_buffer = 0; if (a == NULL) { ECerr(EC_F_I2O_ECPUBLICKEY, ERR_R_PASSED_NULL_PARAMETER); return 0; } buf_len = EC_POINT_point2oct(a->group, a->pub_key, a->conv_form, NULL, 0, NULL); if (out == NULL || buf_len == 0) /* out == NULL => just return the length of the octet string */ return buf_len; if (*out == NULL) { if ((*out = malloc(buf_len)) == NULL) { ECerr(EC_F_I2O_ECPUBLICKEY, ERR_R_MALLOC_FAILURE); return 0; } new_buffer = 1; } if (!EC_POINT_point2oct(a->group, a->pub_key, a->conv_form, *out, buf_len, NULL)) { ECerr(EC_F_I2O_ECPUBLICKEY, ERR_R_EC_LIB); if (new_buffer) { free(*out); *out = NULL; } return 0; } if (!new_buffer) *out += buf_len; return buf_len; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ec_key.c0000644000175000017500000003136612360020705020256 0ustar /* $OpenBSD: ec_key.c,v 1.7 2014/06/12 15:49:29 deraadt Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * Portions originally developed by SUN MICROSYSTEMS, INC., and * contributed to the OpenSSL project. */ #include #include #include "ec_lcl.h" #include EC_KEY * EC_KEY_new(void) { EC_KEY *ret; ret = malloc(sizeof(EC_KEY)); if (ret == NULL) { ECerr(EC_F_EC_KEY_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } ret->version = 1; ret->flags = 0; ret->group = NULL; ret->pub_key = NULL; ret->priv_key = NULL; ret->enc_flag = 0; ret->conv_form = POINT_CONVERSION_UNCOMPRESSED; ret->references = 1; ret->method_data = NULL; return (ret); } EC_KEY * EC_KEY_new_by_curve_name(int nid) { EC_KEY *ret = EC_KEY_new(); if (ret == NULL) return NULL; ret->group = EC_GROUP_new_by_curve_name(nid); if (ret->group == NULL) { EC_KEY_free(ret); return NULL; } return ret; } void EC_KEY_free(EC_KEY * r) { int i; if (r == NULL) return; i = CRYPTO_add(&r->references, -1, CRYPTO_LOCK_EC); if (i > 0) return; if (r->group != NULL) EC_GROUP_free(r->group); if (r->pub_key != NULL) EC_POINT_free(r->pub_key); if (r->priv_key != NULL) BN_clear_free(r->priv_key); EC_EX_DATA_free_all_data(&r->method_data); OPENSSL_cleanse((void *) r, sizeof(EC_KEY)); free(r); } EC_KEY * EC_KEY_copy(EC_KEY * dest, const EC_KEY * src) { EC_EXTRA_DATA *d; if (dest == NULL || src == NULL) { ECerr(EC_F_EC_KEY_COPY, ERR_R_PASSED_NULL_PARAMETER); return NULL; } /* copy the parameters */ if (src->group) { const EC_METHOD *meth = EC_GROUP_method_of(src->group); /* clear the old group */ if (dest->group) EC_GROUP_free(dest->group); dest->group = EC_GROUP_new(meth); if (dest->group == NULL) return NULL; if (!EC_GROUP_copy(dest->group, src->group)) return NULL; } /* copy the public key */ if (src->pub_key && src->group) { if (dest->pub_key) EC_POINT_free(dest->pub_key); dest->pub_key = EC_POINT_new(src->group); if (dest->pub_key == NULL) return NULL; if (!EC_POINT_copy(dest->pub_key, src->pub_key)) return NULL; } /* copy the private key */ if (src->priv_key) { if (dest->priv_key == NULL) { dest->priv_key = BN_new(); if (dest->priv_key == NULL) return NULL; } if (!BN_copy(dest->priv_key, src->priv_key)) return NULL; } /* copy method/extra data */ EC_EX_DATA_free_all_data(&dest->method_data); for (d = src->method_data; d != NULL; d = d->next) { void *t = d->dup_func(d->data); if (t == NULL) return 0; if (!EC_EX_DATA_set_data(&dest->method_data, t, d->dup_func, d->free_func, d->clear_free_func)) return 0; } /* copy the rest */ dest->enc_flag = src->enc_flag; dest->conv_form = src->conv_form; dest->version = src->version; dest->flags = src->flags; return dest; } EC_KEY * EC_KEY_dup(const EC_KEY * ec_key) { EC_KEY *ret = EC_KEY_new(); if (ret == NULL) return NULL; if (EC_KEY_copy(ret, ec_key) == NULL) { EC_KEY_free(ret); return NULL; } return ret; } int EC_KEY_up_ref(EC_KEY * r) { int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_EC); return ((i > 1) ? 1 : 0); } int EC_KEY_generate_key(EC_KEY * eckey) { int ok = 0; BN_CTX *ctx = NULL; BIGNUM *priv_key = NULL, *order = NULL; EC_POINT *pub_key = NULL; if (!eckey || !eckey->group) { ECerr(EC_F_EC_KEY_GENERATE_KEY, ERR_R_PASSED_NULL_PARAMETER); return 0; } if ((order = BN_new()) == NULL) goto err; if ((ctx = BN_CTX_new()) == NULL) goto err; if (eckey->priv_key == NULL) { priv_key = BN_new(); if (priv_key == NULL) goto err; } else priv_key = eckey->priv_key; if (!EC_GROUP_get_order(eckey->group, order, ctx)) goto err; do if (!BN_rand_range(priv_key, order)) goto err; while (BN_is_zero(priv_key)); if (eckey->pub_key == NULL) { pub_key = EC_POINT_new(eckey->group); if (pub_key == NULL) goto err; } else pub_key = eckey->pub_key; if (!EC_POINT_mul(eckey->group, pub_key, priv_key, NULL, NULL, ctx)) goto err; eckey->priv_key = priv_key; eckey->pub_key = pub_key; ok = 1; err: if (order) BN_free(order); if (pub_key != NULL && eckey->pub_key == NULL) EC_POINT_free(pub_key); if (priv_key != NULL && eckey->priv_key == NULL) BN_free(priv_key); if (ctx != NULL) BN_CTX_free(ctx); return (ok); } int EC_KEY_check_key(const EC_KEY * eckey) { int ok = 0; BN_CTX *ctx = NULL; const BIGNUM *order = NULL; EC_POINT *point = NULL; if (!eckey || !eckey->group || !eckey->pub_key) { ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_PASSED_NULL_PARAMETER); return 0; } if (EC_POINT_is_at_infinity(eckey->group, eckey->pub_key)) { ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_POINT_AT_INFINITY); goto err; } if ((ctx = BN_CTX_new()) == NULL) goto err; if ((point = EC_POINT_new(eckey->group)) == NULL) goto err; /* testing whether the pub_key is on the elliptic curve */ if (!EC_POINT_is_on_curve(eckey->group, eckey->pub_key, ctx)) { ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_POINT_IS_NOT_ON_CURVE); goto err; } /* testing whether pub_key * order is the point at infinity */ order = &eckey->group->order; if (BN_is_zero(order)) { ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_INVALID_GROUP_ORDER); goto err; } if (!EC_POINT_mul(eckey->group, point, NULL, eckey->pub_key, order, ctx)) { ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_EC_LIB); goto err; } if (!EC_POINT_is_at_infinity(eckey->group, point)) { ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_WRONG_ORDER); goto err; } /* * in case the priv_key is present : check if generator * priv_key == * pub_key */ if (eckey->priv_key) { if (BN_cmp(eckey->priv_key, order) >= 0) { ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_WRONG_ORDER); goto err; } if (!EC_POINT_mul(eckey->group, point, eckey->priv_key, NULL, NULL, ctx)) { ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_EC_LIB); goto err; } if (EC_POINT_cmp(eckey->group, point, eckey->pub_key, ctx) != 0) { ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_INVALID_PRIVATE_KEY); goto err; } } ok = 1; err: if (ctx != NULL) BN_CTX_free(ctx); if (point != NULL) EC_POINT_free(point); return (ok); } int EC_KEY_set_public_key_affine_coordinates(EC_KEY * key, BIGNUM * x, BIGNUM * y) { BN_CTX *ctx = NULL; BIGNUM *tx, *ty; EC_POINT *point = NULL; int ok = 0, tmp_nid, is_char_two = 0; if (!key || !key->group || !x || !y) { ECerr(EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES, ERR_R_PASSED_NULL_PARAMETER); return 0; } ctx = BN_CTX_new(); if (!ctx) goto err; point = EC_POINT_new(key->group); if (!point) goto err; tmp_nid = EC_METHOD_get_field_type(EC_GROUP_method_of(key->group)); if (tmp_nid == NID_X9_62_characteristic_two_field) is_char_two = 1; tx = BN_CTX_get(ctx); ty = BN_CTX_get(ctx); #ifndef OPENSSL_NO_EC2M if (is_char_two) { if (!EC_POINT_set_affine_coordinates_GF2m(key->group, point, x, y, ctx)) goto err; if (!EC_POINT_get_affine_coordinates_GF2m(key->group, point, tx, ty, ctx)) goto err; } else #endif { if (!EC_POINT_set_affine_coordinates_GFp(key->group, point, x, y, ctx)) goto err; if (!EC_POINT_get_affine_coordinates_GFp(key->group, point, tx, ty, ctx)) goto err; } /* * Check if retrieved coordinates match originals: if not values are * out of range. */ if (BN_cmp(x, tx) || BN_cmp(y, ty)) { ECerr(EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES, EC_R_COORDINATES_OUT_OF_RANGE); goto err; } if (!EC_KEY_set_public_key(key, point)) goto err; if (EC_KEY_check_key(key) == 0) goto err; ok = 1; err: if (ctx) BN_CTX_free(ctx); if (point) EC_POINT_free(point); return ok; } const EC_GROUP * EC_KEY_get0_group(const EC_KEY * key) { return key->group; } int EC_KEY_set_group(EC_KEY * key, const EC_GROUP * group) { if (key->group != NULL) EC_GROUP_free(key->group); key->group = EC_GROUP_dup(group); return (key->group == NULL) ? 0 : 1; } const BIGNUM * EC_KEY_get0_private_key(const EC_KEY * key) { return key->priv_key; } int EC_KEY_set_private_key(EC_KEY * key, const BIGNUM * priv_key) { if (key->priv_key) BN_clear_free(key->priv_key); key->priv_key = BN_dup(priv_key); return (key->priv_key == NULL) ? 0 : 1; } const EC_POINT * EC_KEY_get0_public_key(const EC_KEY * key) { return key->pub_key; } int EC_KEY_set_public_key(EC_KEY * key, const EC_POINT * pub_key) { if (key->pub_key != NULL) EC_POINT_free(key->pub_key); key->pub_key = EC_POINT_dup(pub_key, key->group); return (key->pub_key == NULL) ? 0 : 1; } unsigned int EC_KEY_get_enc_flags(const EC_KEY * key) { return key->enc_flag; } void EC_KEY_set_enc_flags(EC_KEY * key, unsigned int flags) { key->enc_flag = flags; } point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY * key) { return key->conv_form; } void EC_KEY_set_conv_form(EC_KEY * key, point_conversion_form_t cform) { key->conv_form = cform; if (key->group != NULL) EC_GROUP_set_point_conversion_form(key->group, cform); } void * EC_KEY_get_key_method_data(EC_KEY *key, void *(*dup_func) (void *), void (*free_func) (void *), void (*clear_free_func) (void *)) { void *ret; CRYPTO_r_lock(CRYPTO_LOCK_EC); ret = EC_EX_DATA_get_data(key->method_data, dup_func, free_func, clear_free_func); CRYPTO_r_unlock(CRYPTO_LOCK_EC); return ret; } void * EC_KEY_insert_key_method_data(EC_KEY * key, void *data, void *(*dup_func) (void *), void (*free_func) (void *), void (*clear_free_func) (void *)) { EC_EXTRA_DATA *ex_data; CRYPTO_w_lock(CRYPTO_LOCK_EC); ex_data = EC_EX_DATA_get_data(key->method_data, dup_func, free_func, clear_free_func); if (ex_data == NULL) EC_EX_DATA_set_data(&key->method_data, data, dup_func, free_func, clear_free_func); CRYPTO_w_unlock(CRYPTO_LOCK_EC); return ex_data; } void EC_KEY_set_asn1_flag(EC_KEY * key, int flag) { if (key->group != NULL) EC_GROUP_set_asn1_flag(key->group, flag); } int EC_KEY_precompute_mult(EC_KEY * key, BN_CTX * ctx) { if (key->group == NULL) return 0; return EC_GROUP_precompute_mult(key->group, ctx); } int EC_KEY_get_flags(const EC_KEY * key) { return key->flags; } void EC_KEY_set_flags(EC_KEY * key, int flags) { key->flags |= flags; } void EC_KEY_clear_flags(EC_KEY * key, int flags) { key->flags &= ~flags; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ecp_smpl.c0000644000175000017500000010127212360020705020613 0ustar /* $OpenBSD$ */ /* Includes code written by Lenka Fibikova * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * Portions of this software developed by SUN MICROSYSTEMS, INC., * and contributed to the OpenSSL project. */ #include #include "ec_lcl.h" const EC_METHOD * EC_GFp_simple_method(void) { static const EC_METHOD ret = { .flags = EC_FLAGS_DEFAULT_OCT, .field_type = NID_X9_62_prime_field, .group_init = ec_GFp_simple_group_init, .group_finish = ec_GFp_simple_group_finish, .group_clear_finish = ec_GFp_simple_group_clear_finish, .group_copy = ec_GFp_simple_group_copy, .group_set_curve = ec_GFp_simple_group_set_curve, .group_get_curve = ec_GFp_simple_group_get_curve, .group_get_degree = ec_GFp_simple_group_get_degree, .group_check_discriminant = ec_GFp_simple_group_check_discriminant, .point_init = ec_GFp_simple_point_init, .point_finish = ec_GFp_simple_point_finish, .point_clear_finish = ec_GFp_simple_point_clear_finish, .point_copy = ec_GFp_simple_point_copy, .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, .point_set_Jprojective_coordinates_GFp = ec_GFp_simple_set_Jprojective_coordinates_GFp, .point_get_Jprojective_coordinates_GFp = ec_GFp_simple_get_Jprojective_coordinates_GFp, .point_set_affine_coordinates = ec_GFp_simple_point_set_affine_coordinates, .point_get_affine_coordinates = ec_GFp_simple_point_get_affine_coordinates, .add = ec_GFp_simple_add, .dbl = ec_GFp_simple_dbl, .invert = ec_GFp_simple_invert, .is_at_infinity = ec_GFp_simple_is_at_infinity, .is_on_curve = ec_GFp_simple_is_on_curve, .point_cmp = ec_GFp_simple_cmp, .make_affine = ec_GFp_simple_make_affine, .points_make_affine = ec_GFp_simple_points_make_affine, .field_mul = ec_GFp_simple_field_mul, .field_sqr = ec_GFp_simple_field_sqr }; return &ret; } /* Most method functions in this file are designed to work with * non-trivial representations of field elements if necessary * (see ecp_mont.c): while standard modular addition and subtraction * are used, the field_mul and field_sqr methods will be used for * multiplication, and field_encode and field_decode (if defined) * will be used for converting between representations. * Functions ec_GFp_simple_points_make_affine() and * ec_GFp_simple_point_get_affine_coordinates() specifically assume * that if a non-trivial representation is used, it is a Montgomery * representation (i.e. 'encoding' means multiplying by some factor R). */ int ec_GFp_simple_group_init(EC_GROUP * group) { BN_init(&group->field); BN_init(&group->a); BN_init(&group->b); group->a_is_minus3 = 0; return 1; } void ec_GFp_simple_group_finish(EC_GROUP * group) { BN_free(&group->field); BN_free(&group->a); BN_free(&group->b); } void ec_GFp_simple_group_clear_finish(EC_GROUP * group) { BN_clear_free(&group->field); BN_clear_free(&group->a); BN_clear_free(&group->b); } int ec_GFp_simple_group_copy(EC_GROUP * dest, const EC_GROUP * src) { if (!BN_copy(&dest->field, &src->field)) return 0; if (!BN_copy(&dest->a, &src->a)) return 0; if (!BN_copy(&dest->b, &src->b)) return 0; dest->a_is_minus3 = src->a_is_minus3; return 1; } int ec_GFp_simple_group_set_curve(EC_GROUP * group, const BIGNUM * p, const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) { int ret = 0; BN_CTX *new_ctx = NULL; BIGNUM *tmp_a; /* p must be a prime > 3 */ if (BN_num_bits(p) <= 2 || !BN_is_odd(p)) { ECerr(EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE, EC_R_INVALID_FIELD); return 0; } if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } BN_CTX_start(ctx); tmp_a = BN_CTX_get(ctx); if (tmp_a == NULL) goto err; /* group->field */ if (!BN_copy(&group->field, p)) goto err; BN_set_negative(&group->field, 0); /* group->a */ if (!BN_nnmod(tmp_a, a, p, ctx)) goto err; if (group->meth->field_encode) { if (!group->meth->field_encode(group, &group->a, tmp_a, ctx)) goto err; } else if (!BN_copy(&group->a, tmp_a)) goto err; /* group->b */ if (!BN_nnmod(&group->b, b, p, ctx)) goto err; if (group->meth->field_encode) if (!group->meth->field_encode(group, &group->b, &group->b, ctx)) goto err; /* group->a_is_minus3 */ if (!BN_add_word(tmp_a, 3)) goto err; group->a_is_minus3 = (0 == BN_cmp(tmp_a, &group->field)); ret = 1; err: BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } int ec_GFp_simple_group_get_curve(const EC_GROUP * group, BIGNUM * p, BIGNUM * a, BIGNUM * b, BN_CTX * ctx) { int ret = 0; BN_CTX *new_ctx = NULL; if (p != NULL) { if (!BN_copy(p, &group->field)) return 0; } if (a != NULL || b != NULL) { if (group->meth->field_decode) { if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } if (a != NULL) { if (!group->meth->field_decode(group, a, &group->a, ctx)) goto err; } if (b != NULL) { if (!group->meth->field_decode(group, b, &group->b, ctx)) goto err; } } else { if (a != NULL) { if (!BN_copy(a, &group->a)) goto err; } if (b != NULL) { if (!BN_copy(b, &group->b)) goto err; } } } ret = 1; err: if (new_ctx) BN_CTX_free(new_ctx); return ret; } int ec_GFp_simple_group_get_degree(const EC_GROUP * group) { return BN_num_bits(&group->field); } int ec_GFp_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) { int ret = 0; BIGNUM *a, *b, *order, *tmp_1, *tmp_2; const BIGNUM *p = &group->field; BN_CTX *new_ctx = NULL; if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) { ECerr(EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT, ERR_R_MALLOC_FAILURE); goto err; } } BN_CTX_start(ctx); a = BN_CTX_get(ctx); b = BN_CTX_get(ctx); tmp_1 = BN_CTX_get(ctx); tmp_2 = BN_CTX_get(ctx); order = BN_CTX_get(ctx); if (order == NULL) goto err; if (group->meth->field_decode) { if (!group->meth->field_decode(group, a, &group->a, ctx)) goto err; if (!group->meth->field_decode(group, b, &group->b, ctx)) goto err; } else { if (!BN_copy(a, &group->a)) goto err; if (!BN_copy(b, &group->b)) goto err; } /* * check the discriminant: y^2 = x^3 + a*x + b is an elliptic curve * <=> 4*a^3 + 27*b^2 != 0 (mod p) 0 =< a, b < p */ if (BN_is_zero(a)) { if (BN_is_zero(b)) goto err; } else if (!BN_is_zero(b)) { if (!BN_mod_sqr(tmp_1, a, p, ctx)) goto err; if (!BN_mod_mul(tmp_2, tmp_1, a, p, ctx)) goto err; if (!BN_lshift(tmp_1, tmp_2, 2)) goto err; /* tmp_1 = 4*a^3 */ if (!BN_mod_sqr(tmp_2, b, p, ctx)) goto err; if (!BN_mul_word(tmp_2, 27)) goto err; /* tmp_2 = 27*b^2 */ if (!BN_mod_add(a, tmp_1, tmp_2, p, ctx)) goto err; if (BN_is_zero(a)) goto err; } ret = 1; err: if (ctx != NULL) BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } int ec_GFp_simple_point_init(EC_POINT * point) { BN_init(&point->X); BN_init(&point->Y); BN_init(&point->Z); point->Z_is_one = 0; return 1; } void ec_GFp_simple_point_finish(EC_POINT * point) { BN_free(&point->X); BN_free(&point->Y); BN_free(&point->Z); } void ec_GFp_simple_point_clear_finish(EC_POINT * point) { BN_clear_free(&point->X); BN_clear_free(&point->Y); BN_clear_free(&point->Z); point->Z_is_one = 0; } int ec_GFp_simple_point_copy(EC_POINT * dest, const EC_POINT * src) { if (!BN_copy(&dest->X, &src->X)) return 0; if (!BN_copy(&dest->Y, &src->Y)) return 0; if (!BN_copy(&dest->Z, &src->Z)) return 0; dest->Z_is_one = src->Z_is_one; return 1; } int ec_GFp_simple_point_set_to_infinity(const EC_GROUP * group, EC_POINT * point) { point->Z_is_one = 0; BN_zero(&point->Z); return 1; } int ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP * group, EC_POINT * point, const BIGNUM * x, const BIGNUM * y, const BIGNUM * z, BN_CTX * ctx) { BN_CTX *new_ctx = NULL; int ret = 0; if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } if (x != NULL) { if (!BN_nnmod(&point->X, x, &group->field, ctx)) goto err; if (group->meth->field_encode) { if (!group->meth->field_encode(group, &point->X, &point->X, ctx)) goto err; } } if (y != NULL) { if (!BN_nnmod(&point->Y, y, &group->field, ctx)) goto err; if (group->meth->field_encode) { if (!group->meth->field_encode(group, &point->Y, &point->Y, ctx)) goto err; } } if (z != NULL) { int Z_is_one; if (!BN_nnmod(&point->Z, z, &group->field, ctx)) goto err; Z_is_one = BN_is_one(&point->Z); if (group->meth->field_encode) { if (Z_is_one && (group->meth->field_set_to_one != 0)) { if (!group->meth->field_set_to_one(group, &point->Z, ctx)) goto err; } else { if (!group->meth->field_encode(group, &point->Z, &point->Z, ctx)) goto err; } } point->Z_is_one = Z_is_one; } ret = 1; err: if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } int ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP * group, const EC_POINT * point, BIGNUM * x, BIGNUM * y, BIGNUM * z, BN_CTX * ctx) { BN_CTX *new_ctx = NULL; int ret = 0; if (group->meth->field_decode != 0) { if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } if (x != NULL) { if (!group->meth->field_decode(group, x, &point->X, ctx)) goto err; } if (y != NULL) { if (!group->meth->field_decode(group, y, &point->Y, ctx)) goto err; } if (z != NULL) { if (!group->meth->field_decode(group, z, &point->Z, ctx)) goto err; } } else { if (x != NULL) { if (!BN_copy(x, &point->X)) goto err; } if (y != NULL) { if (!BN_copy(y, &point->Y)) goto err; } if (z != NULL) { if (!BN_copy(z, &point->Z)) goto err; } } ret = 1; err: if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } int ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP * group, EC_POINT * point, const BIGNUM * x, const BIGNUM * y, BN_CTX * ctx) { if (x == NULL || y == NULL) { /* unlike for projective coordinates, we do not tolerate this */ ECerr(EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES, ERR_R_PASSED_NULL_PARAMETER); return 0; } return EC_POINT_set_Jprojective_coordinates_GFp(group, point, x, y, BN_value_one(), ctx); } int ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP * group, const EC_POINT * point, BIGNUM * x, BIGNUM * y, BN_CTX * ctx) { BN_CTX *new_ctx = NULL; BIGNUM *Z, *Z_1, *Z_2, *Z_3; const BIGNUM *Z_; int ret = 0; if (EC_POINT_is_at_infinity(group, point)) { ECerr(EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES, EC_R_POINT_AT_INFINITY); return 0; } if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } BN_CTX_start(ctx); Z = BN_CTX_get(ctx); Z_1 = BN_CTX_get(ctx); Z_2 = BN_CTX_get(ctx); Z_3 = BN_CTX_get(ctx); if (Z_3 == NULL) goto err; /* transform (X, Y, Z) into (x, y) := (X/Z^2, Y/Z^3) */ if (group->meth->field_decode) { if (!group->meth->field_decode(group, Z, &point->Z, ctx)) goto err; Z_ = Z; } else { Z_ = &point->Z; } if (BN_is_one(Z_)) { if (group->meth->field_decode) { if (x != NULL) { if (!group->meth->field_decode(group, x, &point->X, ctx)) goto err; } if (y != NULL) { if (!group->meth->field_decode(group, y, &point->Y, ctx)) goto err; } } else { if (x != NULL) { if (!BN_copy(x, &point->X)) goto err; } if (y != NULL) { if (!BN_copy(y, &point->Y)) goto err; } } } else { if (!BN_mod_inverse(Z_1, Z_, &group->field, ctx)) { ECerr(EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES, ERR_R_BN_LIB); goto err; } if (group->meth->field_encode == 0) { /* field_sqr works on standard representation */ if (!group->meth->field_sqr(group, Z_2, Z_1, ctx)) goto err; } else { if (!BN_mod_sqr(Z_2, Z_1, &group->field, ctx)) goto err; } if (x != NULL) { /* * in the Montgomery case, field_mul will cancel out * Montgomery factor in X: */ if (!group->meth->field_mul(group, x, &point->X, Z_2, ctx)) goto err; } if (y != NULL) { if (group->meth->field_encode == 0) { /* field_mul works on standard representation */ if (!group->meth->field_mul(group, Z_3, Z_2, Z_1, ctx)) goto err; } else { if (!BN_mod_mul(Z_3, Z_2, Z_1, &group->field, ctx)) goto err; } /* * in the Montgomery case, field_mul will cancel out * Montgomery factor in Y: */ if (!group->meth->field_mul(group, y, &point->Y, Z_3, ctx)) goto err; } } ret = 1; err: BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } int ec_GFp_simple_add(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, const EC_POINT * b, BN_CTX * ctx) { int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); const BIGNUM *p; BN_CTX *new_ctx = NULL; BIGNUM *n0, *n1, *n2, *n3, *n4, *n5, *n6; int ret = 0; if (a == b) return EC_POINT_dbl(group, r, a, ctx); if (EC_POINT_is_at_infinity(group, a)) return EC_POINT_copy(r, b); if (EC_POINT_is_at_infinity(group, b)) return EC_POINT_copy(r, a); field_mul = group->meth->field_mul; field_sqr = group->meth->field_sqr; p = &group->field; if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } BN_CTX_start(ctx); n0 = BN_CTX_get(ctx); n1 = BN_CTX_get(ctx); n2 = BN_CTX_get(ctx); n3 = BN_CTX_get(ctx); n4 = BN_CTX_get(ctx); n5 = BN_CTX_get(ctx); n6 = BN_CTX_get(ctx); if (n6 == NULL) goto end; /* * Note that in this function we must not read components of 'a' or * 'b' once we have written the corresponding components of 'r'. ('r' * might be one of 'a' or 'b'.) */ /* n1, n2 */ if (b->Z_is_one) { if (!BN_copy(n1, &a->X)) goto end; if (!BN_copy(n2, &a->Y)) goto end; /* n1 = X_a */ /* n2 = Y_a */ } else { if (!field_sqr(group, n0, &b->Z, ctx)) goto end; if (!field_mul(group, n1, &a->X, n0, ctx)) goto end; /* n1 = X_a * Z_b^2 */ if (!field_mul(group, n0, n0, &b->Z, ctx)) goto end; if (!field_mul(group, n2, &a->Y, n0, ctx)) goto end; /* n2 = Y_a * Z_b^3 */ } /* n3, n4 */ if (a->Z_is_one) { if (!BN_copy(n3, &b->X)) goto end; if (!BN_copy(n4, &b->Y)) goto end; /* n3 = X_b */ /* n4 = Y_b */ } else { if (!field_sqr(group, n0, &a->Z, ctx)) goto end; if (!field_mul(group, n3, &b->X, n0, ctx)) goto end; /* n3 = X_b * Z_a^2 */ if (!field_mul(group, n0, n0, &a->Z, ctx)) goto end; if (!field_mul(group, n4, &b->Y, n0, ctx)) goto end; /* n4 = Y_b * Z_a^3 */ } /* n5, n6 */ if (!BN_mod_sub_quick(n5, n1, n3, p)) goto end; if (!BN_mod_sub_quick(n6, n2, n4, p)) goto end; /* n5 = n1 - n3 */ /* n6 = n2 - n4 */ if (BN_is_zero(n5)) { if (BN_is_zero(n6)) { /* a is the same point as b */ BN_CTX_end(ctx); ret = EC_POINT_dbl(group, r, a, ctx); ctx = NULL; goto end; } else { /* a is the inverse of b */ BN_zero(&r->Z); r->Z_is_one = 0; ret = 1; goto end; } } /* 'n7', 'n8' */ if (!BN_mod_add_quick(n1, n1, n3, p)) goto end; if (!BN_mod_add_quick(n2, n2, n4, p)) goto end; /* 'n7' = n1 + n3 */ /* 'n8' = n2 + n4 */ /* Z_r */ if (a->Z_is_one && b->Z_is_one) { if (!BN_copy(&r->Z, n5)) goto end; } else { if (a->Z_is_one) { if (!BN_copy(n0, &b->Z)) goto end; } else if (b->Z_is_one) { if (!BN_copy(n0, &a->Z)) goto end; } else { if (!field_mul(group, n0, &a->Z, &b->Z, ctx)) goto end; } if (!field_mul(group, &r->Z, n0, n5, ctx)) goto end; } r->Z_is_one = 0; /* Z_r = Z_a * Z_b * n5 */ /* X_r */ if (!field_sqr(group, n0, n6, ctx)) goto end; if (!field_sqr(group, n4, n5, ctx)) goto end; if (!field_mul(group, n3, n1, n4, ctx)) goto end; if (!BN_mod_sub_quick(&r->X, n0, n3, p)) goto end; /* X_r = n6^2 - n5^2 * 'n7' */ /* 'n9' */ if (!BN_mod_lshift1_quick(n0, &r->X, p)) goto end; if (!BN_mod_sub_quick(n0, n3, n0, p)) goto end; /* n9 = n5^2 * 'n7' - 2 * X_r */ /* Y_r */ if (!field_mul(group, n0, n0, n6, ctx)) goto end; if (!field_mul(group, n5, n4, n5, ctx)) goto end; /* now n5 is n5^3 */ if (!field_mul(group, n1, n2, n5, ctx)) goto end; if (!BN_mod_sub_quick(n0, n0, n1, p)) goto end; if (BN_is_odd(n0)) if (!BN_add(n0, n0, p)) goto end; /* now 0 <= n0 < 2*p, and n0 is even */ if (!BN_rshift1(&r->Y, n0)) goto end; /* Y_r = (n6 * 'n9' - 'n8' * 'n5^3') / 2 */ ret = 1; end: if (ctx) /* otherwise we already called BN_CTX_end */ BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } int ec_GFp_simple_dbl(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, BN_CTX * ctx) { int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); const BIGNUM *p; BN_CTX *new_ctx = NULL; BIGNUM *n0, *n1, *n2, *n3; int ret = 0; if (EC_POINT_is_at_infinity(group, a)) { BN_zero(&r->Z); r->Z_is_one = 0; return 1; } field_mul = group->meth->field_mul; field_sqr = group->meth->field_sqr; p = &group->field; if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } BN_CTX_start(ctx); n0 = BN_CTX_get(ctx); n1 = BN_CTX_get(ctx); n2 = BN_CTX_get(ctx); n3 = BN_CTX_get(ctx); if (n3 == NULL) goto err; /* * Note that in this function we must not read components of 'a' once * we have written the corresponding components of 'r'. ('r' might * the same as 'a'.) */ /* n1 */ if (a->Z_is_one) { if (!field_sqr(group, n0, &a->X, ctx)) goto err; if (!BN_mod_lshift1_quick(n1, n0, p)) goto err; if (!BN_mod_add_quick(n0, n0, n1, p)) goto err; if (!BN_mod_add_quick(n1, n0, &group->a, p)) goto err; /* n1 = 3 * X_a^2 + a_curve */ } else if (group->a_is_minus3) { if (!field_sqr(group, n1, &a->Z, ctx)) goto err; if (!BN_mod_add_quick(n0, &a->X, n1, p)) goto err; if (!BN_mod_sub_quick(n2, &a->X, n1, p)) goto err; if (!field_mul(group, n1, n0, n2, ctx)) goto err; if (!BN_mod_lshift1_quick(n0, n1, p)) goto err; if (!BN_mod_add_quick(n1, n0, n1, p)) goto err; /* * n1 = 3 * (X_a + Z_a^2) * (X_a - Z_a^2) = 3 * X_a^2 - 3 * * Z_a^4 */ } else { if (!field_sqr(group, n0, &a->X, ctx)) goto err; if (!BN_mod_lshift1_quick(n1, n0, p)) goto err; if (!BN_mod_add_quick(n0, n0, n1, p)) goto err; if (!field_sqr(group, n1, &a->Z, ctx)) goto err; if (!field_sqr(group, n1, n1, ctx)) goto err; if (!field_mul(group, n1, n1, &group->a, ctx)) goto err; if (!BN_mod_add_quick(n1, n1, n0, p)) goto err; /* n1 = 3 * X_a^2 + a_curve * Z_a^4 */ } /* Z_r */ if (a->Z_is_one) { if (!BN_copy(n0, &a->Y)) goto err; } else { if (!field_mul(group, n0, &a->Y, &a->Z, ctx)) goto err; } if (!BN_mod_lshift1_quick(&r->Z, n0, p)) goto err; r->Z_is_one = 0; /* Z_r = 2 * Y_a * Z_a */ /* n2 */ if (!field_sqr(group, n3, &a->Y, ctx)) goto err; if (!field_mul(group, n2, &a->X, n3, ctx)) goto err; if (!BN_mod_lshift_quick(n2, n2, 2, p)) goto err; /* n2 = 4 * X_a * Y_a^2 */ /* X_r */ if (!BN_mod_lshift1_quick(n0, n2, p)) goto err; if (!field_sqr(group, &r->X, n1, ctx)) goto err; if (!BN_mod_sub_quick(&r->X, &r->X, n0, p)) goto err; /* X_r = n1^2 - 2 * n2 */ /* n3 */ if (!field_sqr(group, n0, n3, ctx)) goto err; if (!BN_mod_lshift_quick(n3, n0, 3, p)) goto err; /* n3 = 8 * Y_a^4 */ /* Y_r */ if (!BN_mod_sub_quick(n0, n2, &r->X, p)) goto err; if (!field_mul(group, n0, n1, n0, ctx)) goto err; if (!BN_mod_sub_quick(&r->Y, n0, n3, p)) goto err; /* Y_r = n1 * (n2 - X_r) - n3 */ ret = 1; err: BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } int ec_GFp_simple_invert(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx) { if (EC_POINT_is_at_infinity(group, point) || BN_is_zero(&point->Y)) /* point is its own inverse */ return 1; return BN_usub(&point->Y, &group->field, &point->Y); } int ec_GFp_simple_is_at_infinity(const EC_GROUP * group, const EC_POINT * point) { return BN_is_zero(&point->Z); } int ec_GFp_simple_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX * ctx) { int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); const BIGNUM *p; BN_CTX *new_ctx = NULL; BIGNUM *rh, *tmp, *Z4, *Z6; int ret = -1; if (EC_POINT_is_at_infinity(group, point)) return 1; field_mul = group->meth->field_mul; field_sqr = group->meth->field_sqr; p = &group->field; if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return -1; } BN_CTX_start(ctx); rh = BN_CTX_get(ctx); tmp = BN_CTX_get(ctx); Z4 = BN_CTX_get(ctx); Z6 = BN_CTX_get(ctx); if (Z6 == NULL) goto err; /* * We have a curve defined by a Weierstrass equation y^2 = x^3 + a*x * + b. The point to consider is given in Jacobian projective * coordinates where (X, Y, Z) represents (x, y) = (X/Z^2, Y/Z^3). * Substituting this and multiplying by Z^6 transforms the above * equation into Y^2 = X^3 + a*X*Z^4 + b*Z^6. To test this, we add up * the right-hand side in 'rh'. */ /* rh := X^2 */ if (!field_sqr(group, rh, &point->X, ctx)) goto err; if (!point->Z_is_one) { if (!field_sqr(group, tmp, &point->Z, ctx)) goto err; if (!field_sqr(group, Z4, tmp, ctx)) goto err; if (!field_mul(group, Z6, Z4, tmp, ctx)) goto err; /* rh := (rh + a*Z^4)*X */ if (group->a_is_minus3) { if (!BN_mod_lshift1_quick(tmp, Z4, p)) goto err; if (!BN_mod_add_quick(tmp, tmp, Z4, p)) goto err; if (!BN_mod_sub_quick(rh, rh, tmp, p)) goto err; if (!field_mul(group, rh, rh, &point->X, ctx)) goto err; } else { if (!field_mul(group, tmp, Z4, &group->a, ctx)) goto err; if (!BN_mod_add_quick(rh, rh, tmp, p)) goto err; if (!field_mul(group, rh, rh, &point->X, ctx)) goto err; } /* rh := rh + b*Z^6 */ if (!field_mul(group, tmp, &group->b, Z6, ctx)) goto err; if (!BN_mod_add_quick(rh, rh, tmp, p)) goto err; } else { /* point->Z_is_one */ /* rh := (rh + a)*X */ if (!BN_mod_add_quick(rh, rh, &group->a, p)) goto err; if (!field_mul(group, rh, rh, &point->X, ctx)) goto err; /* rh := rh + b */ if (!BN_mod_add_quick(rh, rh, &group->b, p)) goto err; } /* 'lh' := Y^2 */ if (!field_sqr(group, tmp, &point->Y, ctx)) goto err; ret = (0 == BN_ucmp(tmp, rh)); err: BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } int ec_GFp_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b, BN_CTX * ctx) { /* * return values: -1 error 0 equal (in affine coordinates) 1 * not equal */ int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); BN_CTX *new_ctx = NULL; BIGNUM *tmp1, *tmp2, *Za23, *Zb23; const BIGNUM *tmp1_, *tmp2_; int ret = -1; if (EC_POINT_is_at_infinity(group, a)) { return EC_POINT_is_at_infinity(group, b) ? 0 : 1; } if (EC_POINT_is_at_infinity(group, b)) return 1; if (a->Z_is_one && b->Z_is_one) { return ((BN_cmp(&a->X, &b->X) == 0) && BN_cmp(&a->Y, &b->Y) == 0) ? 0 : 1; } field_mul = group->meth->field_mul; field_sqr = group->meth->field_sqr; if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return -1; } BN_CTX_start(ctx); tmp1 = BN_CTX_get(ctx); tmp2 = BN_CTX_get(ctx); Za23 = BN_CTX_get(ctx); Zb23 = BN_CTX_get(ctx); if (Zb23 == NULL) goto end; /* * We have to decide whether (X_a/Z_a^2, Y_a/Z_a^3) = (X_b/Z_b^2, * Y_b/Z_b^3), or equivalently, whether (X_a*Z_b^2, Y_a*Z_b^3) = * (X_b*Z_a^2, Y_b*Z_a^3). */ if (!b->Z_is_one) { if (!field_sqr(group, Zb23, &b->Z, ctx)) goto end; if (!field_mul(group, tmp1, &a->X, Zb23, ctx)) goto end; tmp1_ = tmp1; } else tmp1_ = &a->X; if (!a->Z_is_one) { if (!field_sqr(group, Za23, &a->Z, ctx)) goto end; if (!field_mul(group, tmp2, &b->X, Za23, ctx)) goto end; tmp2_ = tmp2; } else tmp2_ = &b->X; /* compare X_a*Z_b^2 with X_b*Z_a^2 */ if (BN_cmp(tmp1_, tmp2_) != 0) { ret = 1; /* points differ */ goto end; } if (!b->Z_is_one) { if (!field_mul(group, Zb23, Zb23, &b->Z, ctx)) goto end; if (!field_mul(group, tmp1, &a->Y, Zb23, ctx)) goto end; /* tmp1_ = tmp1 */ } else tmp1_ = &a->Y; if (!a->Z_is_one) { if (!field_mul(group, Za23, Za23, &a->Z, ctx)) goto end; if (!field_mul(group, tmp2, &b->Y, Za23, ctx)) goto end; /* tmp2_ = tmp2 */ } else tmp2_ = &b->Y; /* compare Y_a*Z_b^3 with Y_b*Z_a^3 */ if (BN_cmp(tmp1_, tmp2_) != 0) { ret = 1; /* points differ */ goto end; } /* points are equal */ ret = 0; end: BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } int ec_GFp_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx) { BN_CTX *new_ctx = NULL; BIGNUM *x, *y; int ret = 0; if (point->Z_is_one || EC_POINT_is_at_infinity(group, point)) return 1; if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } BN_CTX_start(ctx); x = BN_CTX_get(ctx); y = BN_CTX_get(ctx); if (y == NULL) goto err; if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx)) goto err; if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx)) goto err; if (!point->Z_is_one) { ECerr(EC_F_EC_GFP_SIMPLE_MAKE_AFFINE, ERR_R_INTERNAL_ERROR); goto err; } ret = 1; err: BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } int ec_GFp_simple_points_make_affine(const EC_GROUP * group, size_t num, EC_POINT * points[], BN_CTX * ctx) { BN_CTX *new_ctx = NULL; BIGNUM *tmp0, *tmp1; size_t pow2 = 0; BIGNUM **heap = NULL; size_t i; int ret = 0; if (num == 0) return 1; if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } BN_CTX_start(ctx); tmp0 = BN_CTX_get(ctx); tmp1 = BN_CTX_get(ctx); if (tmp0 == NULL || tmp1 == NULL) goto err; /* * Before converting the individual points, compute inverses of all Z * values. Modular inversion is rather slow, but luckily we can do * with a single explicit inversion, plus about 3 multiplications per * input value. */ pow2 = 1; while (num > pow2) pow2 <<= 1; /* * Now pow2 is the smallest power of 2 satifsying pow2 >= num. We * need twice that. */ pow2 <<= 1; heap = reallocarray(NULL, pow2, sizeof heap[0]); if (heap == NULL) goto err; /* * The array is used as a binary tree, exactly as in heapsort: * * heap[1] heap[2] heap[3] heap[4] heap[5] * heap[6] heap[7] heap[8]heap[9] heap[10]heap[11] * heap[12]heap[13] heap[14] heap[15] * * We put the Z's in the last line; then we set each other node to the * product of its two child-nodes (where empty or 0 entries are * treated as ones); then we invert heap[1]; then we invert each * other node by replacing it by the product of its parent (after * inversion) and its sibling (before inversion). */ heap[0] = NULL; for (i = pow2 / 2 - 1; i > 0; i--) heap[i] = NULL; for (i = 0; i < num; i++) heap[pow2 / 2 + i] = &points[i]->Z; for (i = pow2 / 2 + num; i < pow2; i++) heap[i] = NULL; /* set each node to the product of its children */ for (i = pow2 / 2 - 1; i > 0; i--) { heap[i] = BN_new(); if (heap[i] == NULL) goto err; if (heap[2 * i] != NULL) { if ((heap[2 * i + 1] == NULL) || BN_is_zero(heap[2 * i + 1])) { if (!BN_copy(heap[i], heap[2 * i])) goto err; } else { if (BN_is_zero(heap[2 * i])) { if (!BN_copy(heap[i], heap[2 * i + 1])) goto err; } else { if (!group->meth->field_mul(group, heap[i], heap[2 * i], heap[2 * i + 1], ctx)) goto err; } } } } /* invert heap[1] */ if (!BN_is_zero(heap[1])) { if (!BN_mod_inverse(heap[1], heap[1], &group->field, ctx)) { ECerr(EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE, ERR_R_BN_LIB); goto err; } } if (group->meth->field_encode != 0) { /* * in the Montgomery case, we just turned R*H (representing * H) into 1/(R*H), but we need R*(1/H) (representing * 1/H); i.e. we have need to multiply by the Montgomery * factor twice */ if (!group->meth->field_encode(group, heap[1], heap[1], ctx)) goto err; if (!group->meth->field_encode(group, heap[1], heap[1], ctx)) goto err; } /* set other heap[i]'s to their inverses */ for (i = 2; i < pow2 / 2 + num; i += 2) { /* i is even */ if ((heap[i + 1] != NULL) && !BN_is_zero(heap[i + 1])) { if (!group->meth->field_mul(group, tmp0, heap[i / 2], heap[i + 1], ctx)) goto err; if (!group->meth->field_mul(group, tmp1, heap[i / 2], heap[i], ctx)) goto err; if (!BN_copy(heap[i], tmp0)) goto err; if (!BN_copy(heap[i + 1], tmp1)) goto err; } else { if (!BN_copy(heap[i], heap[i / 2])) goto err; } } /* * we have replaced all non-zero Z's by their inverses, now fix up * all the points */ for (i = 0; i < num; i++) { EC_POINT *p = points[i]; if (!BN_is_zero(&p->Z)) { /* turn (X, Y, 1/Z) into (X/Z^2, Y/Z^3, 1) */ if (!group->meth->field_sqr(group, tmp1, &p->Z, ctx)) goto err; if (!group->meth->field_mul(group, &p->X, &p->X, tmp1, ctx)) goto err; if (!group->meth->field_mul(group, tmp1, tmp1, &p->Z, ctx)) goto err; if (!group->meth->field_mul(group, &p->Y, &p->Y, tmp1, ctx)) goto err; if (group->meth->field_set_to_one != 0) { if (!group->meth->field_set_to_one(group, &p->Z, ctx)) goto err; } else { if (!BN_one(&p->Z)) goto err; } p->Z_is_one = 1; } } ret = 1; err: BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); if (heap != NULL) { /* * heap[pow2/2] .. heap[pow2-1] have not been allocated * locally! */ for (i = pow2 / 2 - 1; i > 0; i--) { if (heap[i] != NULL) BN_clear_free(heap[i]); } free(heap); } return ret; } int ec_GFp_simple_field_mul(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) { return BN_mod_mul(r, a, b, &group->field, ctx); } int ec_GFp_simple_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, BN_CTX * ctx) { return BN_mod_sqr(r, a, &group->field, ctx); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/eck_prn.c0000644000175000017500000002325412360020705020435 0ustar /* $OpenBSD: eck_prn.c,v 1.8 2014/07/10 22:45:57 jsing Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * Portions originally developed by SUN MICROSYSTEMS, INC., and * contributed to the OpenSSL project. */ #include #include #include #include #include #include #include int ECPKParameters_print_fp(FILE * fp, const EC_GROUP * x, int off) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { ECerr(EC_F_ECPKPARAMETERS_PRINT_FP, ERR_R_BUF_LIB); return (0); } BIO_set_fp(b, fp, BIO_NOCLOSE); ret = ECPKParameters_print(b, x, off); BIO_free(b); return (ret); } int EC_KEY_print_fp(FILE * fp, const EC_KEY * x, int off) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { ECerr(EC_F_EC_KEY_PRINT_FP, ERR_R_BIO_LIB); return (0); } BIO_set_fp(b, fp, BIO_NOCLOSE); ret = EC_KEY_print(b, x, off); BIO_free(b); return (ret); } int ECParameters_print_fp(FILE * fp, const EC_KEY * x) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file())) == NULL) { ECerr(EC_F_ECPARAMETERS_PRINT_FP, ERR_R_BIO_LIB); return (0); } BIO_set_fp(b, fp, BIO_NOCLOSE); ret = ECParameters_print(b, x); BIO_free(b); return (ret); } int EC_KEY_print(BIO * bp, const EC_KEY * x, int off) { EVP_PKEY *pk; int ret; pk = EVP_PKEY_new(); if (!pk || !EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) return 0; ret = EVP_PKEY_print_private(bp, pk, off, NULL); EVP_PKEY_free(pk); return ret; } int ECParameters_print(BIO * bp, const EC_KEY * x) { EVP_PKEY *pk; int ret; pk = EVP_PKEY_new(); if (!pk || !EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) return 0; ret = EVP_PKEY_print_params(bp, pk, 4, NULL); EVP_PKEY_free(pk); return ret; } static int print_bin(BIO * fp, const char *str, const unsigned char *num, size_t len, int off); int ECPKParameters_print(BIO * bp, const EC_GROUP * x, int off) { unsigned char *buffer = NULL; size_t buf_len = 0, i; int ret = 0, reason = ERR_R_BIO_LIB; BN_CTX *ctx = NULL; const EC_POINT *point = NULL; BIGNUM *p = NULL, *a = NULL, *b = NULL, *gen = NULL, *order = NULL, *cofactor = NULL; const unsigned char *seed; size_t seed_len = 0; static const char *gen_compressed = "Generator (compressed):"; static const char *gen_uncompressed = "Generator (uncompressed):"; static const char *gen_hybrid = "Generator (hybrid):"; if (!x) { reason = ERR_R_PASSED_NULL_PARAMETER; goto err; } ctx = BN_CTX_new(); if (ctx == NULL) { reason = ERR_R_MALLOC_FAILURE; goto err; } if (EC_GROUP_get_asn1_flag(x)) { /* the curve parameter are given by an asn1 OID */ int nid; if (!BIO_indent(bp, off, 128)) goto err; nid = EC_GROUP_get_curve_name(x); if (nid == 0) goto err; if (BIO_printf(bp, "ASN1 OID: %s", OBJ_nid2sn(nid)) <= 0) goto err; if (BIO_printf(bp, "\n") <= 0) goto err; } else { /* explicit parameters */ int is_char_two = 0; point_conversion_form_t form; int tmp_nid = EC_METHOD_get_field_type(EC_GROUP_method_of(x)); if (tmp_nid == NID_X9_62_characteristic_two_field) is_char_two = 1; if ((p = BN_new()) == NULL || (a = BN_new()) == NULL || (b = BN_new()) == NULL || (order = BN_new()) == NULL || (cofactor = BN_new()) == NULL) { reason = ERR_R_MALLOC_FAILURE; goto err; } #ifndef OPENSSL_NO_EC2M if (is_char_two) { if (!EC_GROUP_get_curve_GF2m(x, p, a, b, ctx)) { reason = ERR_R_EC_LIB; goto err; } } else /* prime field */ #endif { if (!EC_GROUP_get_curve_GFp(x, p, a, b, ctx)) { reason = ERR_R_EC_LIB; goto err; } } if ((point = EC_GROUP_get0_generator(x)) == NULL) { reason = ERR_R_EC_LIB; goto err; } if (!EC_GROUP_get_order(x, order, NULL) || !EC_GROUP_get_cofactor(x, cofactor, NULL)) { reason = ERR_R_EC_LIB; goto err; } form = EC_GROUP_get_point_conversion_form(x); if ((gen = EC_POINT_point2bn(x, point, form, NULL, ctx)) == NULL) { reason = ERR_R_EC_LIB; goto err; } buf_len = (size_t) BN_num_bytes(p); if (buf_len < (i = (size_t) BN_num_bytes(a))) buf_len = i; if (buf_len < (i = (size_t) BN_num_bytes(b))) buf_len = i; if (buf_len < (i = (size_t) BN_num_bytes(gen))) buf_len = i; if (buf_len < (i = (size_t) BN_num_bytes(order))) buf_len = i; if (buf_len < (i = (size_t) BN_num_bytes(cofactor))) buf_len = i; if ((seed = EC_GROUP_get0_seed(x)) != NULL) seed_len = EC_GROUP_get_seed_len(x); buf_len += 10; if ((buffer = malloc(buf_len)) == NULL) { reason = ERR_R_MALLOC_FAILURE; goto err; } if (!BIO_indent(bp, off, 128)) goto err; /* print the 'short name' of the field type */ if (BIO_printf(bp, "Field Type: %s\n", OBJ_nid2sn(tmp_nid)) <= 0) goto err; if (is_char_two) { /* print the 'short name' of the base type OID */ int basis_type = EC_GROUP_get_basis_type(x); if (basis_type == 0) goto err; if (!BIO_indent(bp, off, 128)) goto err; if (BIO_printf(bp, "Basis Type: %s\n", OBJ_nid2sn(basis_type)) <= 0) goto err; /* print the polynomial */ if ((p != NULL) && !ASN1_bn_print(bp, "Polynomial:", p, buffer, off)) goto err; } else { if ((p != NULL) && !ASN1_bn_print(bp, "Prime:", p, buffer, off)) goto err; } if ((a != NULL) && !ASN1_bn_print(bp, "A: ", a, buffer, off)) goto err; if ((b != NULL) && !ASN1_bn_print(bp, "B: ", b, buffer, off)) goto err; if (form == POINT_CONVERSION_COMPRESSED) { if ((gen != NULL) && !ASN1_bn_print(bp, gen_compressed, gen, buffer, off)) goto err; } else if (form == POINT_CONVERSION_UNCOMPRESSED) { if ((gen != NULL) && !ASN1_bn_print(bp, gen_uncompressed, gen, buffer, off)) goto err; } else { /* form == POINT_CONVERSION_HYBRID */ if ((gen != NULL) && !ASN1_bn_print(bp, gen_hybrid, gen, buffer, off)) goto err; } if ((order != NULL) && !ASN1_bn_print(bp, "Order: ", order, buffer, off)) goto err; if ((cofactor != NULL) && !ASN1_bn_print(bp, "Cofactor: ", cofactor, buffer, off)) goto err; if (seed && !print_bin(bp, "Seed:", seed, seed_len, off)) goto err; } ret = 1; err: if (!ret) ECerr(EC_F_ECPKPARAMETERS_PRINT, reason); if (p) BN_free(p); if (a) BN_free(a); if (b) BN_free(b); if (gen) BN_free(gen); if (order) BN_free(order); if (cofactor) BN_free(cofactor); if (ctx) BN_CTX_free(ctx); free(buffer); return (ret); } static int print_bin(BIO * fp, const char *name, const unsigned char *buf, size_t len, int off) { size_t i; char str[128]; if (buf == NULL) return 1; if (off) { if (off > 128) off = 128; memset(str, ' ', off); if (BIO_write(fp, str, off) <= 0) return 0; } if (BIO_printf(fp, "%s", name) <= 0) return 0; for (i = 0; i < len; i++) { if ((i % 15) == 0) { str[0] = '\n'; memset(&(str[1]), ' ', off + 4); if (BIO_write(fp, str, off + 1 + 4) <= 0) return 0; } if (BIO_printf(fp, "%02x%s", buf[i], ((i + 1) == len) ? "" : ":") <= 0) return 0; } if (BIO_write(fp, "\n", 1) <= 0) return 0; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ec_lib.c0000644000175000017500000006135512360020705020235 0ustar /* $OpenBSD: ec_lib.c,v 1.13 2014/07/09 11:10:50 bcook Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * Binary polynomial ECC support in OpenSSL originally developed by * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. */ #include #include #include #include #include "ec_lcl.h" /* functions for EC_GROUP objects */ EC_GROUP * EC_GROUP_new(const EC_METHOD * meth) { EC_GROUP *ret; if (meth == NULL) { ECerr(EC_F_EC_GROUP_NEW, EC_R_SLOT_FULL); return NULL; } if (meth->group_init == 0) { ECerr(EC_F_EC_GROUP_NEW, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return NULL; } ret = malloc(sizeof *ret); if (ret == NULL) { ECerr(EC_F_EC_GROUP_NEW, ERR_R_MALLOC_FAILURE); return NULL; } ret->meth = meth; ret->extra_data = NULL; ret->generator = NULL; BN_init(&ret->order); BN_init(&ret->cofactor); ret->curve_name = 0; ret->asn1_flag = 0; ret->asn1_form = POINT_CONVERSION_UNCOMPRESSED; ret->seed = NULL; ret->seed_len = 0; if (!meth->group_init(ret)) { free(ret); return NULL; } return ret; } void EC_GROUP_free(EC_GROUP * group) { if (!group) return; if (group->meth->group_finish != 0) group->meth->group_finish(group); EC_EX_DATA_free_all_data(&group->extra_data); if (group->generator != NULL) EC_POINT_free(group->generator); BN_free(&group->order); BN_free(&group->cofactor); free(group->seed); free(group); } void EC_GROUP_clear_free(EC_GROUP * group) { if (!group) return; if (group->meth->group_clear_finish != 0) group->meth->group_clear_finish(group); else if (group->meth->group_finish != 0) group->meth->group_finish(group); EC_EX_DATA_clear_free_all_data(&group->extra_data); if (group->generator != NULL) EC_POINT_clear_free(group->generator); BN_clear_free(&group->order); BN_clear_free(&group->cofactor); if (group->seed) { OPENSSL_cleanse(group->seed, group->seed_len); free(group->seed); } OPENSSL_cleanse(group, sizeof *group); free(group); } int EC_GROUP_copy(EC_GROUP * dest, const EC_GROUP * src) { EC_EXTRA_DATA *d; if (dest->meth->group_copy == 0) { ECerr(EC_F_EC_GROUP_COPY, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (dest->meth != src->meth) { ECerr(EC_F_EC_GROUP_COPY, EC_R_INCOMPATIBLE_OBJECTS); return 0; } if (dest == src) return 1; EC_EX_DATA_free_all_data(&dest->extra_data); for (d = src->extra_data; d != NULL; d = d->next) { void *t = d->dup_func(d->data); if (t == NULL) return 0; if (!EC_EX_DATA_set_data(&dest->extra_data, t, d->dup_func, d->free_func, d->clear_free_func)) return 0; } if (src->generator != NULL) { if (dest->generator == NULL) { dest->generator = EC_POINT_new(dest); if (dest->generator == NULL) return 0; } if (!EC_POINT_copy(dest->generator, src->generator)) return 0; } else { /* src->generator == NULL */ if (dest->generator != NULL) { EC_POINT_clear_free(dest->generator); dest->generator = NULL; } } if (!BN_copy(&dest->order, &src->order)) return 0; if (!BN_copy(&dest->cofactor, &src->cofactor)) return 0; dest->curve_name = src->curve_name; dest->asn1_flag = src->asn1_flag; dest->asn1_form = src->asn1_form; if (src->seed) { free(dest->seed); dest->seed = malloc(src->seed_len); if (dest->seed == NULL) return 0; if (!memcpy(dest->seed, src->seed, src->seed_len)) return 0; dest->seed_len = src->seed_len; } else { free(dest->seed); dest->seed = NULL; dest->seed_len = 0; } return dest->meth->group_copy(dest, src); } EC_GROUP * EC_GROUP_dup(const EC_GROUP * a) { EC_GROUP *t = NULL; int ok = 0; if (a == NULL) return NULL; if ((t = EC_GROUP_new(a->meth)) == NULL) return (NULL); if (!EC_GROUP_copy(t, a)) goto err; ok = 1; err: if (!ok) { if (t) EC_GROUP_free(t); return NULL; } else return t; } const EC_METHOD * EC_GROUP_method_of(const EC_GROUP *group) { return group->meth; } int EC_METHOD_get_field_type(const EC_METHOD *meth) { return meth->field_type; } int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor) { if (generator == NULL) { ECerr(EC_F_EC_GROUP_SET_GENERATOR, ERR_R_PASSED_NULL_PARAMETER); return 0; } if (group->generator == NULL) { group->generator = EC_POINT_new(group); if (group->generator == NULL) return 0; } if (!EC_POINT_copy(group->generator, generator)) return 0; if (order != NULL) { if (!BN_copy(&group->order, order)) return 0; } else BN_zero(&group->order); if (cofactor != NULL) { if (!BN_copy(&group->cofactor, cofactor)) return 0; } else BN_zero(&group->cofactor); return 1; } const EC_POINT * EC_GROUP_get0_generator(const EC_GROUP *group) { return group->generator; } int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx) { if (!BN_copy(order, &group->order)) return 0; return !BN_is_zero(order); } int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx) { if (!BN_copy(cofactor, &group->cofactor)) return 0; return !BN_is_zero(&group->cofactor); } void EC_GROUP_set_curve_name(EC_GROUP * group, int nid) { group->curve_name = nid; } int EC_GROUP_get_curve_name(const EC_GROUP * group) { return group->curve_name; } void EC_GROUP_set_asn1_flag(EC_GROUP * group, int flag) { group->asn1_flag = flag; } int EC_GROUP_get_asn1_flag(const EC_GROUP * group) { return group->asn1_flag; } void EC_GROUP_set_point_conversion_form(EC_GROUP * group, point_conversion_form_t form) { group->asn1_form = form; } point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP * group) { return group->asn1_form; } size_t EC_GROUP_set_seed(EC_GROUP * group, const unsigned char *p, size_t len) { if (group->seed) { free(group->seed); group->seed = NULL; group->seed_len = 0; } if (!len || !p) return 1; if ((group->seed = malloc(len)) == NULL) return 0; memcpy(group->seed, p, len); group->seed_len = len; return len; } unsigned char * EC_GROUP_get0_seed(const EC_GROUP * group) { return group->seed; } size_t EC_GROUP_get_seed_len(const EC_GROUP * group) { return group->seed_len; } int EC_GROUP_set_curve_GFp(EC_GROUP * group, const BIGNUM * p, const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) { if (group->meth->group_set_curve == 0) { ECerr(EC_F_EC_GROUP_SET_CURVE_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } return group->meth->group_set_curve(group, p, a, b, ctx); } int EC_GROUP_get_curve_GFp(const EC_GROUP * group, BIGNUM * p, BIGNUM * a, BIGNUM * b, BN_CTX * ctx) { if (group->meth->group_get_curve == 0) { ECerr(EC_F_EC_GROUP_GET_CURVE_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } return group->meth->group_get_curve(group, p, a, b, ctx); } #ifndef OPENSSL_NO_EC2M int EC_GROUP_set_curve_GF2m(EC_GROUP * group, const BIGNUM * p, const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) { if (group->meth->group_set_curve == 0) { ECerr(EC_F_EC_GROUP_SET_CURVE_GF2M, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } return group->meth->group_set_curve(group, p, a, b, ctx); } int EC_GROUP_get_curve_GF2m(const EC_GROUP * group, BIGNUM * p, BIGNUM * a, BIGNUM * b, BN_CTX * ctx) { if (group->meth->group_get_curve == 0) { ECerr(EC_F_EC_GROUP_GET_CURVE_GF2M, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } return group->meth->group_get_curve(group, p, a, b, ctx); } #endif int EC_GROUP_get_degree(const EC_GROUP * group) { if (group->meth->group_get_degree == 0) { ECerr(EC_F_EC_GROUP_GET_DEGREE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } return group->meth->group_get_degree(group); } int EC_GROUP_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) { if (group->meth->group_check_discriminant == 0) { ECerr(EC_F_EC_GROUP_CHECK_DISCRIMINANT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } return group->meth->group_check_discriminant(group, ctx); } int EC_GROUP_cmp(const EC_GROUP * a, const EC_GROUP * b, BN_CTX * ctx) { int r = 0; BIGNUM *a1, *a2, *a3, *b1, *b2, *b3; BN_CTX *ctx_new = NULL; /* compare the field types */ if (EC_METHOD_get_field_type(EC_GROUP_method_of(a)) != EC_METHOD_get_field_type(EC_GROUP_method_of(b))) return 1; /* compare the curve name (if present in both) */ if (EC_GROUP_get_curve_name(a) && EC_GROUP_get_curve_name(b) && EC_GROUP_get_curve_name(a) != EC_GROUP_get_curve_name(b)) return 1; if (!ctx) ctx_new = ctx = BN_CTX_new(); if (!ctx) return -1; BN_CTX_start(ctx); a1 = BN_CTX_get(ctx); a2 = BN_CTX_get(ctx); a3 = BN_CTX_get(ctx); b1 = BN_CTX_get(ctx); b2 = BN_CTX_get(ctx); b3 = BN_CTX_get(ctx); if (!b3) { BN_CTX_end(ctx); if (ctx_new) BN_CTX_free(ctx); return -1; } /* * XXX This approach assumes that the external representation of * curves over the same field type is the same. */ if (!a->meth->group_get_curve(a, a1, a2, a3, ctx) || !b->meth->group_get_curve(b, b1, b2, b3, ctx)) r = 1; if (r || BN_cmp(a1, b1) || BN_cmp(a2, b2) || BN_cmp(a3, b3)) r = 1; /* XXX EC_POINT_cmp() assumes that the methods are equal */ if (r || EC_POINT_cmp(a, EC_GROUP_get0_generator(a), EC_GROUP_get0_generator(b), ctx)) r = 1; if (!r) { /* compare the order and cofactor */ if (!EC_GROUP_get_order(a, a1, ctx) || !EC_GROUP_get_order(b, b1, ctx) || !EC_GROUP_get_cofactor(a, a2, ctx) || !EC_GROUP_get_cofactor(b, b2, ctx)) { BN_CTX_end(ctx); if (ctx_new) BN_CTX_free(ctx); return -1; } if (BN_cmp(a1, b1) || BN_cmp(a2, b2)) r = 1; } BN_CTX_end(ctx); if (ctx_new) BN_CTX_free(ctx); return r; } /* this has 'package' visibility */ int EC_EX_DATA_set_data(EC_EXTRA_DATA ** ex_data, void *data, void *(*dup_func) (void *), void (*free_func) (void *), void (*clear_free_func) (void *)) { EC_EXTRA_DATA *d; if (ex_data == NULL) return 0; for (d = *ex_data; d != NULL; d = d->next) { if (d->dup_func == dup_func && d->free_func == free_func && d->clear_free_func == clear_free_func) { ECerr(EC_F_EC_EX_DATA_SET_DATA, EC_R_SLOT_FULL); return 0; } } if (data == NULL) /* no explicit entry needed */ return 1; d = malloc(sizeof *d); if (d == NULL) return 0; d->data = data; d->dup_func = dup_func; d->free_func = free_func; d->clear_free_func = clear_free_func; d->next = *ex_data; *ex_data = d; return 1; } /* this has 'package' visibility */ void * EC_EX_DATA_get_data(const EC_EXTRA_DATA * ex_data, void *(*dup_func) (void *), void (*free_func) (void *), void (*clear_free_func) (void *)) { const EC_EXTRA_DATA *d; for (d = ex_data; d != NULL; d = d->next) { if (d->dup_func == dup_func && d->free_func == free_func && d->clear_free_func == clear_free_func) return d->data; } return NULL; } /* this has 'package' visibility */ void EC_EX_DATA_free_data(EC_EXTRA_DATA ** ex_data, void *(*dup_func) (void *), void (*free_func) (void *), void (*clear_free_func) (void *)) { EC_EXTRA_DATA **p; if (ex_data == NULL) return; for (p = ex_data; *p != NULL; p = &((*p)->next)) { if ((*p)->dup_func == dup_func && (*p)->free_func == free_func && (*p)->clear_free_func == clear_free_func) { EC_EXTRA_DATA *next = (*p)->next; (*p)->free_func((*p)->data); free(*p); *p = next; return; } } } /* this has 'package' visibility */ void EC_EX_DATA_clear_free_data(EC_EXTRA_DATA ** ex_data, void *(*dup_func) (void *), void (*free_func) (void *), void (*clear_free_func) (void *)) { EC_EXTRA_DATA **p; if (ex_data == NULL) return; for (p = ex_data; *p != NULL; p = &((*p)->next)) { if ((*p)->dup_func == dup_func && (*p)->free_func == free_func && (*p)->clear_free_func == clear_free_func) { EC_EXTRA_DATA *next = (*p)->next; (*p)->clear_free_func((*p)->data); free(*p); *p = next; return; } } } /* this has 'package' visibility */ void EC_EX_DATA_free_all_data(EC_EXTRA_DATA ** ex_data) { EC_EXTRA_DATA *d; if (ex_data == NULL) return; d = *ex_data; while (d) { EC_EXTRA_DATA *next = d->next; d->free_func(d->data); free(d); d = next; } *ex_data = NULL; } /* this has 'package' visibility */ void EC_EX_DATA_clear_free_all_data(EC_EXTRA_DATA ** ex_data) { EC_EXTRA_DATA *d; if (ex_data == NULL) return; d = *ex_data; while (d) { EC_EXTRA_DATA *next = d->next; d->clear_free_func(d->data); free(d); d = next; } *ex_data = NULL; } /* functions for EC_POINT objects */ EC_POINT * EC_POINT_new(const EC_GROUP * group) { EC_POINT *ret; if (group == NULL) { ECerr(EC_F_EC_POINT_NEW, ERR_R_PASSED_NULL_PARAMETER); return NULL; } if (group->meth->point_init == 0) { ECerr(EC_F_EC_POINT_NEW, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return NULL; } ret = malloc(sizeof *ret); if (ret == NULL) { ECerr(EC_F_EC_POINT_NEW, ERR_R_MALLOC_FAILURE); return NULL; } ret->meth = group->meth; if (!ret->meth->point_init(ret)) { free(ret); return NULL; } return ret; } void EC_POINT_free(EC_POINT * point) { if (!point) return; if (point->meth->point_finish != 0) point->meth->point_finish(point); free(point); } void EC_POINT_clear_free(EC_POINT * point) { if (!point) return; if (point->meth->point_clear_finish != 0) point->meth->point_clear_finish(point); else if (point->meth->point_finish != 0) point->meth->point_finish(point); OPENSSL_cleanse(point, sizeof *point); free(point); } int EC_POINT_copy(EC_POINT * dest, const EC_POINT * src) { if (dest->meth->point_copy == 0) { ECerr(EC_F_EC_POINT_COPY, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (dest->meth != src->meth) { ECerr(EC_F_EC_POINT_COPY, EC_R_INCOMPATIBLE_OBJECTS); return 0; } if (dest == src) return 1; return dest->meth->point_copy(dest, src); } EC_POINT * EC_POINT_dup(const EC_POINT * a, const EC_GROUP * group) { EC_POINT *t; int r; if (a == NULL) return NULL; t = EC_POINT_new(group); if (t == NULL) return (NULL); r = EC_POINT_copy(t, a); if (!r) { EC_POINT_free(t); return NULL; } else return t; } const EC_METHOD * EC_POINT_method_of(const EC_POINT * point) { return point->meth; } int EC_POINT_set_to_infinity(const EC_GROUP * group, EC_POINT * point) { if (group->meth->point_set_to_infinity == 0) { ECerr(EC_F_EC_POINT_SET_TO_INFINITY, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (group->meth != point->meth) { ECerr(EC_F_EC_POINT_SET_TO_INFINITY, EC_R_INCOMPATIBLE_OBJECTS); return 0; } return group->meth->point_set_to_infinity(group, point); } int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *point, const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx) { if (group->meth->point_set_Jprojective_coordinates_GFp == 0) { ECerr(EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (group->meth != point->meth) { ECerr(EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP, EC_R_INCOMPATIBLE_OBJECTS); return 0; } return group->meth->point_set_Jprojective_coordinates_GFp(group, point, x, y, z, ctx); } int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx) { if (group->meth->point_get_Jprojective_coordinates_GFp == 0) { ECerr(EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (group->meth != point->meth) { ECerr(EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP, EC_R_INCOMPATIBLE_OBJECTS); return 0; } return group->meth->point_get_Jprojective_coordinates_GFp(group, point, x, y, z, ctx); } int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *point, const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx) { if (group->meth->point_set_affine_coordinates == 0) { ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (group->meth != point->meth) { ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP, EC_R_INCOMPATIBLE_OBJECTS); return 0; } return group->meth->point_set_affine_coordinates(group, point, x, y, ctx); } #ifndef OPENSSL_NO_EC2M int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *point, const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx) { if (group->meth->point_set_affine_coordinates == 0) { ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (group->meth != point->meth) { ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M, EC_R_INCOMPATIBLE_OBJECTS); return 0; } return group->meth->point_set_affine_coordinates(group, point, x, y, ctx); } #endif int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx) { if (group->meth->point_get_affine_coordinates == 0) { ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (group->meth != point->meth) { ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP, EC_R_INCOMPATIBLE_OBJECTS); return 0; } return group->meth->point_get_affine_coordinates(group, point, x, y, ctx); } #ifndef OPENSSL_NO_EC2M int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx) { if (group->meth->point_get_affine_coordinates == 0) { ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (group->meth != point->meth) { ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M, EC_R_INCOMPATIBLE_OBJECTS); return 0; } return group->meth->point_get_affine_coordinates(group, point, x, y, ctx); } #endif int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx) { if (group->meth->add == 0) { ECerr(EC_F_EC_POINT_ADD, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if ((group->meth != r->meth) || (r->meth != a->meth) || (a->meth != b->meth)) { ECerr(EC_F_EC_POINT_ADD, EC_R_INCOMPATIBLE_OBJECTS); return 0; } return group->meth->add(group, r, a, b, ctx); } int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx) { if (group->meth->dbl == 0) { ECerr(EC_F_EC_POINT_DBL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if ((group->meth != r->meth) || (r->meth != a->meth)) { ECerr(EC_F_EC_POINT_DBL, EC_R_INCOMPATIBLE_OBJECTS); return 0; } return group->meth->dbl(group, r, a, ctx); } int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx) { if (group->meth->invert == 0) { ECerr(EC_F_EC_POINT_INVERT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (group->meth != a->meth) { ECerr(EC_F_EC_POINT_INVERT, EC_R_INCOMPATIBLE_OBJECTS); return 0; } return group->meth->invert(group, a, ctx); } int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *point) { if (group->meth->is_at_infinity == 0) { ECerr(EC_F_EC_POINT_IS_AT_INFINITY, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (group->meth != point->meth) { ECerr(EC_F_EC_POINT_IS_AT_INFINITY, EC_R_INCOMPATIBLE_OBJECTS); return 0; } return group->meth->is_at_infinity(group, point); } int EC_POINT_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX * ctx) { if (group->meth->is_on_curve == 0) { ECerr(EC_F_EC_POINT_IS_ON_CURVE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (group->meth != point->meth) { ECerr(EC_F_EC_POINT_IS_ON_CURVE, EC_R_INCOMPATIBLE_OBJECTS); return 0; } return group->meth->is_on_curve(group, point, ctx); } int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX * ctx) { if (group->meth->point_cmp == 0) { ECerr(EC_F_EC_POINT_CMP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return -1; } if ((group->meth != a->meth) || (a->meth != b->meth)) { ECerr(EC_F_EC_POINT_CMP, EC_R_INCOMPATIBLE_OBJECTS); return -1; } return group->meth->point_cmp(group, a, b, ctx); } int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) { if (group->meth->make_affine == 0) { ECerr(EC_F_EC_POINT_MAKE_AFFINE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (group->meth != point->meth) { ECerr(EC_F_EC_POINT_MAKE_AFFINE, EC_R_INCOMPATIBLE_OBJECTS); return 0; } return group->meth->make_affine(group, point, ctx); } int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx) { size_t i; if (group->meth->points_make_affine == 0) { ECerr(EC_F_EC_POINTS_MAKE_AFFINE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } for (i = 0; i < num; i++) { if (group->meth != points[i]->meth) { ECerr(EC_F_EC_POINTS_MAKE_AFFINE, EC_R_INCOMPATIBLE_OBJECTS); return 0; } } return group->meth->points_make_affine(group, num, points, ctx); } /* Functions for point multiplication. * * If group->meth->mul is 0, we use the wNAF-based implementations in ec_mult.c; * otherwise we dispatch through methods. */ int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx) { if (group->meth->mul == 0) /* use default */ return ec_wNAF_mul(group, r, scalar, num, points, scalars, ctx); return group->meth->mul(group, r, scalar, num, points, scalars, ctx); } int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar, const EC_POINT *point, const BIGNUM *p_scalar, BN_CTX *ctx) { /* just a convenient interface to EC_POINTs_mul() */ const EC_POINT *points[1]; const BIGNUM *scalars[1]; points[0] = point; scalars[0] = p_scalar; return EC_POINTs_mul(group, r, g_scalar, (point != NULL && p_scalar != NULL), points, scalars, ctx); } int EC_GROUP_precompute_mult(EC_GROUP * group, BN_CTX * ctx) { if (group->meth->mul == 0) /* use default */ return ec_wNAF_precompute_mult(group, ctx); if (group->meth->precompute_mult != 0) return group->meth->precompute_mult(group, ctx); else return 1; /* nothing to do, so report success */ } int EC_GROUP_have_precompute_mult(const EC_GROUP * group) { if (group->meth->mul == 0) /* use default */ return ec_wNAF_have_precompute_mult(group); if (group->meth->have_precompute_mult != 0) return group->meth->have_precompute_mult(group); else return 0; /* cannot tell whether precomputation has * been performed */ } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ec_err.c0000644000175000017500000003734112360020705020255 0ustar /* $OpenBSD: ec_err.c,v 1.8 2014/06/12 15:49:29 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_EC,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_EC,0,reason) static ERR_STRING_DATA EC_str_functs[] = { {ERR_FUNC(EC_F_BN_TO_FELEM), "BN_TO_FELEM"}, {ERR_FUNC(EC_F_COMPUTE_WNAF), "COMPUTE_WNAF"}, {ERR_FUNC(EC_F_D2I_ECPARAMETERS), "d2i_ECParameters"}, {ERR_FUNC(EC_F_D2I_ECPKPARAMETERS), "d2i_ECPKParameters"}, {ERR_FUNC(EC_F_D2I_ECPRIVATEKEY), "d2i_ECPrivateKey"}, {ERR_FUNC(EC_F_DO_EC_KEY_PRINT), "DO_EC_KEY_PRINT"}, {ERR_FUNC(EC_F_ECKEY_PARAM2TYPE), "ECKEY_PARAM2TYPE"}, {ERR_FUNC(EC_F_ECKEY_PARAM_DECODE), "ECKEY_PARAM_DECODE"}, {ERR_FUNC(EC_F_ECKEY_PRIV_DECODE), "ECKEY_PRIV_DECODE"}, {ERR_FUNC(EC_F_ECKEY_PRIV_ENCODE), "ECKEY_PRIV_ENCODE"}, {ERR_FUNC(EC_F_ECKEY_PUB_DECODE), "ECKEY_PUB_DECODE"}, {ERR_FUNC(EC_F_ECKEY_PUB_ENCODE), "ECKEY_PUB_ENCODE"}, {ERR_FUNC(EC_F_ECKEY_TYPE2PARAM), "ECKEY_TYPE2PARAM"}, {ERR_FUNC(EC_F_ECPARAMETERS_PRINT), "ECParameters_print"}, {ERR_FUNC(EC_F_ECPARAMETERS_PRINT_FP), "ECParameters_print_fp"}, {ERR_FUNC(EC_F_ECPKPARAMETERS_PRINT), "ECPKParameters_print"}, {ERR_FUNC(EC_F_ECPKPARAMETERS_PRINT_FP), "ECPKParameters_print_fp"}, {ERR_FUNC(EC_F_ECP_NIST_MOD_192), "ECP_NIST_MOD_192"}, {ERR_FUNC(EC_F_ECP_NIST_MOD_224), "ECP_NIST_MOD_224"}, {ERR_FUNC(EC_F_ECP_NIST_MOD_256), "ECP_NIST_MOD_256"}, {ERR_FUNC(EC_F_ECP_NIST_MOD_521), "ECP_NIST_MOD_521"}, {ERR_FUNC(EC_F_EC_ASN1_GROUP2CURVE), "EC_ASN1_GROUP2CURVE"}, {ERR_FUNC(EC_F_EC_ASN1_GROUP2FIELDID), "EC_ASN1_GROUP2FIELDID"}, {ERR_FUNC(EC_F_EC_ASN1_GROUP2PARAMETERS), "EC_ASN1_GROUP2PARAMETERS"}, {ERR_FUNC(EC_F_EC_ASN1_GROUP2PKPARAMETERS), "EC_ASN1_GROUP2PKPARAMETERS"}, {ERR_FUNC(EC_F_EC_ASN1_PARAMETERS2GROUP), "EC_ASN1_PARAMETERS2GROUP"}, {ERR_FUNC(EC_F_EC_ASN1_PKPARAMETERS2GROUP), "EC_ASN1_PKPARAMETERS2GROUP"}, {ERR_FUNC(EC_F_EC_EX_DATA_SET_DATA), "EC_EX_DATA_set_data"}, {ERR_FUNC(EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY), "EC_GF2M_MONTGOMERY_POINT_MULTIPLY"}, {ERR_FUNC(EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT), "ec_GF2m_simple_group_check_discriminant"}, {ERR_FUNC(EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE), "ec_GF2m_simple_group_set_curve"}, {ERR_FUNC(EC_F_EC_GF2M_SIMPLE_OCT2POINT), "ec_GF2m_simple_oct2point"}, {ERR_FUNC(EC_F_EC_GF2M_SIMPLE_POINT2OCT), "ec_GF2m_simple_point2oct"}, {ERR_FUNC(EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES), "ec_GF2m_simple_point_get_affine_coordinates"}, {ERR_FUNC(EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES), "ec_GF2m_simple_point_set_affine_coordinates"}, {ERR_FUNC(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES), "ec_GF2m_simple_set_compressed_coordinates"}, {ERR_FUNC(EC_F_EC_GFP_MONT_FIELD_DECODE), "ec_GFp_mont_field_decode"}, {ERR_FUNC(EC_F_EC_GFP_MONT_FIELD_ENCODE), "ec_GFp_mont_field_encode"}, {ERR_FUNC(EC_F_EC_GFP_MONT_FIELD_MUL), "ec_GFp_mont_field_mul"}, {ERR_FUNC(EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE), "ec_GFp_mont_field_set_to_one"}, {ERR_FUNC(EC_F_EC_GFP_MONT_FIELD_SQR), "ec_GFp_mont_field_sqr"}, {ERR_FUNC(EC_F_EC_GFP_MONT_GROUP_SET_CURVE), "ec_GFp_mont_group_set_curve"}, {ERR_FUNC(EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP), "EC_GFP_MONT_GROUP_SET_CURVE_GFP"}, {ERR_FUNC(EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE), "ec_GFp_nistp224_group_set_curve"}, {ERR_FUNC(EC_F_EC_GFP_NISTP224_POINTS_MUL), "ec_GFp_nistp224_points_mul"}, {ERR_FUNC(EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES), "ec_GFp_nistp224_point_get_affine_coordinates"}, {ERR_FUNC(EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE), "ec_GFp_nistp256_group_set_curve"}, {ERR_FUNC(EC_F_EC_GFP_NISTP256_POINTS_MUL), "ec_GFp_nistp256_points_mul"}, {ERR_FUNC(EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES), "ec_GFp_nistp256_point_get_affine_coordinates"}, {ERR_FUNC(EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE), "ec_GFp_nistp521_group_set_curve"}, {ERR_FUNC(EC_F_EC_GFP_NISTP521_POINTS_MUL), "ec_GFp_nistp521_points_mul"}, {ERR_FUNC(EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES), "ec_GFp_nistp521_point_get_affine_coordinates"}, {ERR_FUNC(EC_F_EC_GFP_NIST_FIELD_MUL), "ec_GFp_nist_field_mul"}, {ERR_FUNC(EC_F_EC_GFP_NIST_FIELD_SQR), "ec_GFp_nist_field_sqr"}, {ERR_FUNC(EC_F_EC_GFP_NIST_GROUP_SET_CURVE), "ec_GFp_nist_group_set_curve"}, {ERR_FUNC(EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT), "ec_GFp_simple_group_check_discriminant"}, {ERR_FUNC(EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE), "ec_GFp_simple_group_set_curve"}, {ERR_FUNC(EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP), "EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP"}, {ERR_FUNC(EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR), "EC_GFP_SIMPLE_GROUP_SET_GENERATOR"}, {ERR_FUNC(EC_F_EC_GFP_SIMPLE_MAKE_AFFINE), "ec_GFp_simple_make_affine"}, {ERR_FUNC(EC_F_EC_GFP_SIMPLE_OCT2POINT), "ec_GFp_simple_oct2point"}, {ERR_FUNC(EC_F_EC_GFP_SIMPLE_POINT2OCT), "ec_GFp_simple_point2oct"}, {ERR_FUNC(EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE), "ec_GFp_simple_points_make_affine"}, {ERR_FUNC(EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES), "ec_GFp_simple_point_get_affine_coordinates"}, {ERR_FUNC(EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP), "EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP"}, {ERR_FUNC(EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES), "ec_GFp_simple_point_set_affine_coordinates"}, {ERR_FUNC(EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP), "EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP"}, {ERR_FUNC(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES), "ec_GFp_simple_set_compressed_coordinates"}, {ERR_FUNC(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP), "EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP"}, {ERR_FUNC(EC_F_EC_GROUP_CHECK), "EC_GROUP_check"}, {ERR_FUNC(EC_F_EC_GROUP_CHECK_DISCRIMINANT), "EC_GROUP_check_discriminant"}, {ERR_FUNC(EC_F_EC_GROUP_COPY), "EC_GROUP_copy"}, {ERR_FUNC(EC_F_EC_GROUP_GET0_GENERATOR), "EC_GROUP_get0_generator"}, {ERR_FUNC(EC_F_EC_GROUP_GET_COFACTOR), "EC_GROUP_get_cofactor"}, {ERR_FUNC(EC_F_EC_GROUP_GET_CURVE_GF2M), "EC_GROUP_get_curve_GF2m"}, {ERR_FUNC(EC_F_EC_GROUP_GET_CURVE_GFP), "EC_GROUP_get_curve_GFp"}, {ERR_FUNC(EC_F_EC_GROUP_GET_DEGREE), "EC_GROUP_get_degree"}, {ERR_FUNC(EC_F_EC_GROUP_GET_ORDER), "EC_GROUP_get_order"}, {ERR_FUNC(EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS), "EC_GROUP_get_pentanomial_basis"}, {ERR_FUNC(EC_F_EC_GROUP_GET_TRINOMIAL_BASIS), "EC_GROUP_get_trinomial_basis"}, {ERR_FUNC(EC_F_EC_GROUP_NEW), "EC_GROUP_new"}, {ERR_FUNC(EC_F_EC_GROUP_NEW_BY_CURVE_NAME), "EC_GROUP_new_by_curve_name"}, {ERR_FUNC(EC_F_EC_GROUP_NEW_FROM_DATA), "EC_GROUP_NEW_FROM_DATA"}, {ERR_FUNC(EC_F_EC_GROUP_PRECOMPUTE_MULT), "EC_GROUP_precompute_mult"}, {ERR_FUNC(EC_F_EC_GROUP_SET_CURVE_GF2M), "EC_GROUP_set_curve_GF2m"}, {ERR_FUNC(EC_F_EC_GROUP_SET_CURVE_GFP), "EC_GROUP_set_curve_GFp"}, {ERR_FUNC(EC_F_EC_GROUP_SET_EXTRA_DATA), "EC_GROUP_SET_EXTRA_DATA"}, {ERR_FUNC(EC_F_EC_GROUP_SET_GENERATOR), "EC_GROUP_set_generator"}, {ERR_FUNC(EC_F_EC_KEY_CHECK_KEY), "EC_KEY_check_key"}, {ERR_FUNC(EC_F_EC_KEY_COPY), "EC_KEY_copy"}, {ERR_FUNC(EC_F_EC_KEY_GENERATE_KEY), "EC_KEY_generate_key"}, {ERR_FUNC(EC_F_EC_KEY_NEW), "EC_KEY_new"}, {ERR_FUNC(EC_F_EC_KEY_PRINT), "EC_KEY_print"}, {ERR_FUNC(EC_F_EC_KEY_PRINT_FP), "EC_KEY_print_fp"}, {ERR_FUNC(EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES), "EC_KEY_set_public_key_affine_coordinates"}, {ERR_FUNC(EC_F_EC_POINTS_MAKE_AFFINE), "EC_POINTs_make_affine"}, {ERR_FUNC(EC_F_EC_POINT_ADD), "EC_POINT_add"}, {ERR_FUNC(EC_F_EC_POINT_CMP), "EC_POINT_cmp"}, {ERR_FUNC(EC_F_EC_POINT_COPY), "EC_POINT_copy"}, {ERR_FUNC(EC_F_EC_POINT_DBL), "EC_POINT_dbl"}, {ERR_FUNC(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M), "EC_POINT_get_affine_coordinates_GF2m"}, {ERR_FUNC(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP), "EC_POINT_get_affine_coordinates_GFp"}, {ERR_FUNC(EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP), "EC_POINT_get_Jprojective_coordinates_GFp"}, {ERR_FUNC(EC_F_EC_POINT_INVERT), "EC_POINT_invert"}, {ERR_FUNC(EC_F_EC_POINT_IS_AT_INFINITY), "EC_POINT_is_at_infinity"}, {ERR_FUNC(EC_F_EC_POINT_IS_ON_CURVE), "EC_POINT_is_on_curve"}, {ERR_FUNC(EC_F_EC_POINT_MAKE_AFFINE), "EC_POINT_make_affine"}, {ERR_FUNC(EC_F_EC_POINT_MUL), "EC_POINT_mul"}, {ERR_FUNC(EC_F_EC_POINT_NEW), "EC_POINT_new"}, {ERR_FUNC(EC_F_EC_POINT_OCT2POINT), "EC_POINT_oct2point"}, {ERR_FUNC(EC_F_EC_POINT_POINT2OCT), "EC_POINT_point2oct"}, {ERR_FUNC(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M), "EC_POINT_set_affine_coordinates_GF2m"}, {ERR_FUNC(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP), "EC_POINT_set_affine_coordinates_GFp"}, {ERR_FUNC(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M), "EC_POINT_set_compressed_coordinates_GF2m"}, {ERR_FUNC(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP), "EC_POINT_set_compressed_coordinates_GFp"}, {ERR_FUNC(EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP), "EC_POINT_set_Jprojective_coordinates_GFp"}, {ERR_FUNC(EC_F_EC_POINT_SET_TO_INFINITY), "EC_POINT_set_to_infinity"}, {ERR_FUNC(EC_F_EC_PRE_COMP_DUP), "EC_PRE_COMP_DUP"}, {ERR_FUNC(EC_F_EC_PRE_COMP_NEW), "EC_PRE_COMP_NEW"}, {ERR_FUNC(EC_F_EC_WNAF_MUL), "ec_wNAF_mul"}, {ERR_FUNC(EC_F_EC_WNAF_PRECOMPUTE_MULT), "ec_wNAF_precompute_mult"}, {ERR_FUNC(EC_F_I2D_ECPARAMETERS), "i2d_ECParameters"}, {ERR_FUNC(EC_F_I2D_ECPKPARAMETERS), "i2d_ECPKParameters"}, {ERR_FUNC(EC_F_I2D_ECPRIVATEKEY), "i2d_ECPrivateKey"}, {ERR_FUNC(EC_F_I2O_ECPUBLICKEY), "i2o_ECPublicKey"}, {ERR_FUNC(EC_F_NISTP224_PRE_COMP_NEW), "NISTP224_PRE_COMP_NEW"}, {ERR_FUNC(EC_F_NISTP256_PRE_COMP_NEW), "NISTP256_PRE_COMP_NEW"}, {ERR_FUNC(EC_F_NISTP521_PRE_COMP_NEW), "NISTP521_PRE_COMP_NEW"}, {ERR_FUNC(EC_F_O2I_ECPUBLICKEY), "o2i_ECPublicKey"}, {ERR_FUNC(EC_F_OLD_EC_PRIV_DECODE), "OLD_EC_PRIV_DECODE"}, {ERR_FUNC(EC_F_PKEY_EC_CTRL), "PKEY_EC_CTRL"}, {ERR_FUNC(EC_F_PKEY_EC_CTRL_STR), "PKEY_EC_CTRL_STR"}, {ERR_FUNC(EC_F_PKEY_EC_DERIVE), "PKEY_EC_DERIVE"}, {ERR_FUNC(EC_F_PKEY_EC_KEYGEN), "PKEY_EC_KEYGEN"}, {ERR_FUNC(EC_F_PKEY_EC_PARAMGEN), "PKEY_EC_PARAMGEN"}, {ERR_FUNC(EC_F_PKEY_EC_SIGN), "PKEY_EC_SIGN"}, {0, NULL} }; static ERR_STRING_DATA EC_str_reasons[] = { {ERR_REASON(EC_R_ASN1_ERROR), "asn1 error"}, {ERR_REASON(EC_R_ASN1_UNKNOWN_FIELD), "asn1 unknown field"}, {ERR_REASON(EC_R_BIGNUM_OUT_OF_RANGE), "bignum out of range"}, {ERR_REASON(EC_R_BUFFER_TOO_SMALL), "buffer too small"}, {ERR_REASON(EC_R_COORDINATES_OUT_OF_RANGE), "coordinates out of range"}, {ERR_REASON(EC_R_D2I_ECPKPARAMETERS_FAILURE), "d2i ecpkparameters failure"}, {ERR_REASON(EC_R_DECODE_ERROR), "decode error"}, {ERR_REASON(EC_R_DISCRIMINANT_IS_ZERO), "discriminant is zero"}, {ERR_REASON(EC_R_EC_GROUP_NEW_BY_NAME_FAILURE), "ec group new by name failure"}, {ERR_REASON(EC_R_FIELD_TOO_LARGE), "field too large"}, {ERR_REASON(EC_R_GF2M_NOT_SUPPORTED), "gf2m not supported"}, {ERR_REASON(EC_R_GROUP2PKPARAMETERS_FAILURE), "group2pkparameters failure"}, {ERR_REASON(EC_R_I2D_ECPKPARAMETERS_FAILURE), "i2d ecpkparameters failure"}, {ERR_REASON(EC_R_INCOMPATIBLE_OBJECTS), "incompatible objects"}, {ERR_REASON(EC_R_INVALID_ARGUMENT), "invalid argument"}, {ERR_REASON(EC_R_INVALID_COMPRESSED_POINT), "invalid compressed point"}, {ERR_REASON(EC_R_INVALID_COMPRESSION_BIT), "invalid compression bit"}, {ERR_REASON(EC_R_INVALID_CURVE), "invalid curve"}, {ERR_REASON(EC_R_INVALID_DIGEST_TYPE), "invalid digest type"}, {ERR_REASON(EC_R_INVALID_ENCODING), "invalid encoding"}, {ERR_REASON(EC_R_INVALID_FIELD), "invalid field"}, {ERR_REASON(EC_R_INVALID_FORM), "invalid form"}, {ERR_REASON(EC_R_INVALID_GROUP_ORDER), "invalid group order"}, {ERR_REASON(EC_R_INVALID_PENTANOMIAL_BASIS), "invalid pentanomial basis"}, {ERR_REASON(EC_R_INVALID_PRIVATE_KEY), "invalid private key"}, {ERR_REASON(EC_R_INVALID_TRINOMIAL_BASIS), "invalid trinomial basis"}, {ERR_REASON(EC_R_KEYS_NOT_SET), "keys not set"}, {ERR_REASON(EC_R_MISSING_PARAMETERS), "missing parameters"}, {ERR_REASON(EC_R_MISSING_PRIVATE_KEY), "missing private key"}, {ERR_REASON(EC_R_NOT_A_NIST_PRIME), "not a NIST prime"}, {ERR_REASON(EC_R_NOT_A_SUPPORTED_NIST_PRIME), "not a supported NIST prime"}, {ERR_REASON(EC_R_NOT_IMPLEMENTED), "not implemented"}, {ERR_REASON(EC_R_NOT_INITIALIZED), "not initialized"}, {ERR_REASON(EC_R_NO_FIELD_MOD), "no field mod"}, {ERR_REASON(EC_R_NO_PARAMETERS_SET), "no parameters set"}, {ERR_REASON(EC_R_PASSED_NULL_PARAMETER), "passed null parameter"}, {ERR_REASON(EC_R_PKPARAMETERS2GROUP_FAILURE), "pkparameters2group failure"}, {ERR_REASON(EC_R_POINT_AT_INFINITY), "point at infinity"}, {ERR_REASON(EC_R_POINT_IS_NOT_ON_CURVE), "point is not on curve"}, {ERR_REASON(EC_R_SLOT_FULL), "slot full"}, {ERR_REASON(EC_R_UNDEFINED_GENERATOR), "undefined generator"}, {ERR_REASON(EC_R_UNDEFINED_ORDER), "undefined order"}, {ERR_REASON(EC_R_UNKNOWN_GROUP), "unknown group"}, {ERR_REASON(EC_R_UNKNOWN_ORDER), "unknown order"}, {ERR_REASON(EC_R_UNSUPPORTED_FIELD), "unsupported field"}, {ERR_REASON(EC_R_WRONG_CURVE_PARAMETERS), "wrong curve parameters"}, {ERR_REASON(EC_R_WRONG_ORDER), "wrong order"}, {0, NULL} }; #endif void ERR_load_EC_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(EC_str_functs[0].error) == NULL) { ERR_load_strings(0, EC_str_functs); ERR_load_strings(0, EC_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ec_lcl.h0000644000175000017500000005261612360020705020246 0ustar /* $OpenBSD$ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2010 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * Portions of the attached software ("Contribution") are developed by * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. * * The Contribution is licensed pursuant to the OpenSSL open source * license provided above. * * The elliptic curve binary polynomial software is originally written by * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. * */ #include #include #include #include #if defined(__SUNPRO_C) # if __SUNPRO_C >= 0x520 # pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) # endif #endif /* Use default functions for poin2oct, oct2point and compressed coordinates */ #define EC_FLAGS_DEFAULT_OCT 0x1 /* Structure details are not part of the exported interface, * so all this may change in future versions. */ struct ec_method_st { /* Various method flags */ int flags; /* used by EC_METHOD_get_field_type: */ int field_type; /* a NID */ /* used by EC_GROUP_new, EC_GROUP_free, EC_GROUP_clear_free, EC_GROUP_copy: */ int (*group_init)(EC_GROUP *); void (*group_finish)(EC_GROUP *); void (*group_clear_finish)(EC_GROUP *); int (*group_copy)(EC_GROUP *, const EC_GROUP *); /* used by EC_GROUP_set_curve_GFp, EC_GROUP_get_curve_GFp, */ /* EC_GROUP_set_curve_GF2m, and EC_GROUP_get_curve_GF2m: */ int (*group_set_curve)(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); int (*group_get_curve)(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); /* used by EC_GROUP_get_degree: */ int (*group_get_degree)(const EC_GROUP *); /* used by EC_GROUP_check: */ int (*group_check_discriminant)(const EC_GROUP *, BN_CTX *); /* used by EC_POINT_new, EC_POINT_free, EC_POINT_clear_free, EC_POINT_copy: */ int (*point_init)(EC_POINT *); void (*point_finish)(EC_POINT *); void (*point_clear_finish)(EC_POINT *); int (*point_copy)(EC_POINT *, const EC_POINT *); /* used by EC_POINT_set_to_infinity, * EC_POINT_set_Jprojective_coordinates_GFp, * EC_POINT_get_Jprojective_coordinates_GFp, * EC_POINT_set_affine_coordinates_GFp, ..._GF2m, * EC_POINT_get_affine_coordinates_GFp, ..._GF2m, * EC_POINT_set_compressed_coordinates_GFp, ..._GF2m: */ int (*point_set_to_infinity)(const EC_GROUP *, EC_POINT *); int (*point_set_Jprojective_coordinates_GFp)(const EC_GROUP *, EC_POINT *, const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *); int (*point_get_Jprojective_coordinates_GFp)(const EC_GROUP *, const EC_POINT *, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *); int (*point_set_affine_coordinates)(const EC_GROUP *, EC_POINT *, const BIGNUM *x, const BIGNUM *y, BN_CTX *); int (*point_get_affine_coordinates)(const EC_GROUP *, const EC_POINT *, BIGNUM *x, BIGNUM *y, BN_CTX *); int (*point_set_compressed_coordinates)(const EC_GROUP *, EC_POINT *, const BIGNUM *x, int y_bit, BN_CTX *); /* used by EC_POINT_point2oct, EC_POINT_oct2point: */ size_t (*point2oct)(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, unsigned char *buf, size_t len, BN_CTX *); int (*oct2point)(const EC_GROUP *, EC_POINT *, const unsigned char *buf, size_t len, BN_CTX *); /* used by EC_POINT_add, EC_POINT_dbl, ECP_POINT_invert: */ int (*add)(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); int (*dbl)(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); int (*invert)(const EC_GROUP *, EC_POINT *, BN_CTX *); /* used by EC_POINT_is_at_infinity, EC_POINT_is_on_curve, EC_POINT_cmp: */ int (*is_at_infinity)(const EC_GROUP *, const EC_POINT *); int (*is_on_curve)(const EC_GROUP *, const EC_POINT *, BN_CTX *); int (*point_cmp)(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *); /* used by EC_POINT_make_affine, EC_POINTs_make_affine: */ int (*make_affine)(const EC_GROUP *, EC_POINT *, BN_CTX *); int (*points_make_affine)(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); /* used by EC_POINTs_mul, EC_POINT_mul, EC_POINT_precompute_mult, EC_POINT_have_precompute_mult * (default implementations are used if the 'mul' pointer is 0): */ int (*mul)(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); int (*precompute_mult)(EC_GROUP *group, BN_CTX *); int (*have_precompute_mult)(const EC_GROUP *group); /* internal functions */ /* 'field_mul', 'field_sqr', and 'field_div' can be used by 'add' and 'dbl' so that * the same implementations of point operations can be used with different * optimized implementations of expensive field operations: */ int (*field_mul)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); int (*field_sqr)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); int (*field_div)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); int (*field_encode)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); /* e.g. to Montgomery */ int (*field_decode)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); /* e.g. from Montgomery */ int (*field_set_to_one)(const EC_GROUP *, BIGNUM *r, BN_CTX *); } /* EC_METHOD */; typedef struct ec_extra_data_st { struct ec_extra_data_st *next; void *data; void *(*dup_func)(void *); void (*free_func)(void *); void (*clear_free_func)(void *); } EC_EXTRA_DATA; /* used in EC_GROUP */ struct ec_group_st { const EC_METHOD *meth; EC_POINT *generator; /* optional */ BIGNUM order, cofactor; int curve_name;/* optional NID for named curve */ int asn1_flag; /* flag to control the asn1 encoding */ point_conversion_form_t asn1_form; unsigned char *seed; /* optional seed for parameters (appears in ASN1) */ size_t seed_len; EC_EXTRA_DATA *extra_data; /* linked list */ /* The following members are handled by the method functions, * even if they appear generic */ BIGNUM field; /* Field specification. * For curves over GF(p), this is the modulus; * for curves over GF(2^m), this is the * irreducible polynomial defining the field. */ int poly[6]; /* Field specification for curves over GF(2^m). * The irreducible f(t) is then of the form: * t^poly[0] + t^poly[1] + ... + t^poly[k] * where m = poly[0] > poly[1] > ... > poly[k] = 0. * The array is terminated with poly[k+1]=-1. * All elliptic curve irreducibles have at most 5 * non-zero terms. */ BIGNUM a, b; /* Curve coefficients. * (Here the assumption is that BIGNUMs can be used * or abused for all kinds of fields, not just GF(p).) * For characteristic > 3, the curve is defined * by a Weierstrass equation of the form * y^2 = x^3 + a*x + b. * For characteristic 2, the curve is defined by * an equation of the form * y^2 + x*y = x^3 + a*x^2 + b. */ int a_is_minus3; /* enable optimized point arithmetics for special case */ void *field_data1; /* method-specific (e.g., Montgomery structure) */ void *field_data2; /* method-specific */ int (*field_mod_func)(BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); /* method-specific */ } /* EC_GROUP */; struct ec_key_st { int version; EC_GROUP *group; EC_POINT *pub_key; BIGNUM *priv_key; unsigned int enc_flag; point_conversion_form_t conv_form; int references; int flags; EC_EXTRA_DATA *method_data; } /* EC_KEY */; /* Basically a 'mixin' for extra data, but available for EC_GROUPs/EC_KEYs only * (with visibility limited to 'package' level for now). * We use the function pointers as index for retrieval; this obviates * global ex_data-style index tables. */ int EC_EX_DATA_set_data(EC_EXTRA_DATA **, void *data, void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); void *EC_EX_DATA_get_data(const EC_EXTRA_DATA *, void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); void EC_EX_DATA_free_data(EC_EXTRA_DATA **, void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); void EC_EX_DATA_clear_free_data(EC_EXTRA_DATA **, void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); void EC_EX_DATA_free_all_data(EC_EXTRA_DATA **); void EC_EX_DATA_clear_free_all_data(EC_EXTRA_DATA **); struct ec_point_st { const EC_METHOD *meth; /* All members except 'meth' are handled by the method functions, * even if they appear generic */ BIGNUM X; BIGNUM Y; BIGNUM Z; /* Jacobian projective coordinates: * (X, Y, Z) represents (X/Z^2, Y/Z^3) if Z != 0 */ int Z_is_one; /* enable optimized point arithmetics for special case */ } /* EC_POINT */; /* method functions in ec_mult.c * (ec_lib.c uses these as defaults if group->method->mul is 0) */ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *); int ec_wNAF_have_precompute_mult(const EC_GROUP *group); /* method functions in ecp_smpl.c */ int ec_GFp_simple_group_init(EC_GROUP *); void ec_GFp_simple_group_finish(EC_GROUP *); void ec_GFp_simple_group_clear_finish(EC_GROUP *); int ec_GFp_simple_group_copy(EC_GROUP *, const EC_GROUP *); int ec_GFp_simple_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); int ec_GFp_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); int ec_GFp_simple_group_get_degree(const EC_GROUP *); int ec_GFp_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *); int ec_GFp_simple_point_init(EC_POINT *); void ec_GFp_simple_point_finish(EC_POINT *); void ec_GFp_simple_point_clear_finish(EC_POINT *); int ec_GFp_simple_point_copy(EC_POINT *, const EC_POINT *); int ec_GFp_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *); int ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP *, EC_POINT *, const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *); int ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP *, const EC_POINT *, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *); int ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *, const BIGNUM *x, const BIGNUM *y, BN_CTX *); int ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *, const EC_POINT *, BIGNUM *x, BIGNUM *y, BN_CTX *); int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *, const BIGNUM *x, int y_bit, BN_CTX *); size_t ec_GFp_simple_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, unsigned char *buf, size_t len, BN_CTX *); int ec_GFp_simple_oct2point(const EC_GROUP *, EC_POINT *, const unsigned char *buf, size_t len, BN_CTX *); int ec_GFp_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); int ec_GFp_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); int ec_GFp_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); int ec_GFp_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *); int ec_GFp_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); int ec_GFp_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *); int ec_GFp_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); int ec_GFp_simple_points_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); int ec_GFp_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); int ec_GFp_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); /* method functions in ecp_mont.c */ int ec_GFp_mont_group_init(EC_GROUP *); int ec_GFp_mont_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); void ec_GFp_mont_group_finish(EC_GROUP *); void ec_GFp_mont_group_clear_finish(EC_GROUP *); int ec_GFp_mont_group_copy(EC_GROUP *, const EC_GROUP *); int ec_GFp_mont_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); int ec_GFp_mont_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); int ec_GFp_mont_field_encode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); int ec_GFp_mont_field_decode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); int ec_GFp_mont_field_set_to_one(const EC_GROUP *, BIGNUM *r, BN_CTX *); /* method functions in ecp_nist.c */ int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src); int ec_GFp_nist_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); int ec_GFp_nist_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); int ec_GFp_nist_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); /* method functions in ec2_smpl.c */ int ec_GF2m_simple_group_init(EC_GROUP *); void ec_GF2m_simple_group_finish(EC_GROUP *); void ec_GF2m_simple_group_clear_finish(EC_GROUP *); int ec_GF2m_simple_group_copy(EC_GROUP *, const EC_GROUP *); int ec_GF2m_simple_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); int ec_GF2m_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); int ec_GF2m_simple_group_get_degree(const EC_GROUP *); int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *); int ec_GF2m_simple_point_init(EC_POINT *); void ec_GF2m_simple_point_finish(EC_POINT *); void ec_GF2m_simple_point_clear_finish(EC_POINT *); int ec_GF2m_simple_point_copy(EC_POINT *, const EC_POINT *); int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *); int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *, const BIGNUM *x, const BIGNUM *y, BN_CTX *); int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *, const EC_POINT *, BIGNUM *x, BIGNUM *y, BN_CTX *); int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *, const BIGNUM *x, int y_bit, BN_CTX *); size_t ec_GF2m_simple_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, unsigned char *buf, size_t len, BN_CTX *); int ec_GF2m_simple_oct2point(const EC_GROUP *, EC_POINT *, const unsigned char *buf, size_t len, BN_CTX *); int ec_GF2m_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); int ec_GF2m_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); int ec_GF2m_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); int ec_GF2m_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *); int ec_GF2m_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); int ec_GF2m_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *); int ec_GF2m_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); int ec_GF2m_simple_points_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); int ec_GF2m_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); int ec_GF2m_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); int ec_GF2m_simple_field_div(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); /* method functions in ec2_mult.c */ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); int ec_GF2m_precompute_mult(EC_GROUP *group, BN_CTX *ctx); int ec_GF2m_have_precompute_mult(const EC_GROUP *group); /* method functions in ec2_mult.c */ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); int ec_GF2m_precompute_mult(EC_GROUP *group, BN_CTX *ctx); int ec_GF2m_have_precompute_mult(const EC_GROUP *group); #ifndef OPENSSL_EC_NISTP_64_GCC_128 /* method functions in ecp_nistp224.c */ int ec_GFp_nistp224_group_init(EC_GROUP *group); int ec_GFp_nistp224_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *n, BN_CTX *); int ec_GFp_nistp224_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); int ec_GFp_nistp224_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); int ec_GFp_nistp224_points_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx); int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx); int ec_GFp_nistp224_have_precompute_mult(const EC_GROUP *group); /* method functions in ecp_nistp256.c */ int ec_GFp_nistp256_group_init(EC_GROUP *group); int ec_GFp_nistp256_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *n, BN_CTX *); int ec_GFp_nistp256_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); int ec_GFp_nistp256_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); int ec_GFp_nistp256_points_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx); int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx); int ec_GFp_nistp256_have_precompute_mult(const EC_GROUP *group); /* method functions in ecp_nistp521.c */ int ec_GFp_nistp521_group_init(EC_GROUP *group); int ec_GFp_nistp521_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *n, BN_CTX *); int ec_GFp_nistp521_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); int ec_GFp_nistp521_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); int ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx); int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx); int ec_GFp_nistp521_have_precompute_mult(const EC_GROUP *group); /* utility functions in ecp_nistputil.c */ void ec_GFp_nistp_points_make_affine_internal(size_t num, void *point_array, size_t felem_size, void *tmp_felems, void (*felem_one)(void *out), int (*felem_is_zero)(const void *in), void (*felem_assign)(void *out, const void *in), void (*felem_square)(void *out, const void *in), void (*felem_mul)(void *out, const void *in1, const void *in2), void (*felem_inv)(void *out, const void *in), void (*felem_contract)(void *out, const void *in)); void ec_GFp_nistp_recode_scalar_bits(unsigned char *sign, unsigned char *digit, unsigned char in); #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ec_mult.c0000644000175000017500000005530612360020705020447 0ustar /* $OpenBSD$ */ /* * Originally written by Bodo Moeller and Nils Larsch for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * Portions of this software developed by SUN MICROSYSTEMS, INC., * and contributed to the OpenSSL project. */ #include #include #include "ec_lcl.h" /* * This file implements the wNAF-based interleaving multi-exponentation method * (); * for multiplication with precomputation, we use wNAF splitting * (). */ /* structure for precomputed multiples of the generator */ typedef struct ec_pre_comp_st { const EC_GROUP *group; /* parent EC_GROUP object */ size_t blocksize; /* block size for wNAF splitting */ size_t numblocks; /* max. number of blocks for which we have * precomputation */ size_t w; /* window size */ EC_POINT **points; /* array with pre-calculated multiples of * generator: 'num' pointers to EC_POINT * objects followed by a NULL */ size_t num; /* numblocks * 2^(w-1) */ int references; } EC_PRE_COMP; /* functions to manage EC_PRE_COMP within the EC_GROUP extra_data framework */ static void *ec_pre_comp_dup(void *); static void ec_pre_comp_free(void *); static void ec_pre_comp_clear_free(void *); static EC_PRE_COMP * ec_pre_comp_new(const EC_GROUP * group) { EC_PRE_COMP *ret = NULL; if (!group) return NULL; ret = malloc(sizeof(EC_PRE_COMP)); if (!ret) { ECerr(EC_F_EC_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE); return ret; } ret->group = group; ret->blocksize = 8; /* default */ ret->numblocks = 0; ret->w = 4; /* default */ ret->points = NULL; ret->num = 0; ret->references = 1; return ret; } static void * ec_pre_comp_dup(void *src_) { EC_PRE_COMP *src = src_; /* no need to actually copy, these objects never change! */ CRYPTO_add(&src->references, 1, CRYPTO_LOCK_EC_PRE_COMP); return src_; } static void ec_pre_comp_free(void *pre_) { int i; EC_PRE_COMP *pre = pre_; if (!pre) return; i = CRYPTO_add(&pre->references, -1, CRYPTO_LOCK_EC_PRE_COMP); if (i > 0) return; if (pre->points) { EC_POINT **p; for (p = pre->points; *p != NULL; p++) EC_POINT_free(*p); free(pre->points); } free(pre); } static void ec_pre_comp_clear_free(void *pre_) { int i; EC_PRE_COMP *pre = pre_; if (!pre) return; i = CRYPTO_add(&pre->references, -1, CRYPTO_LOCK_EC_PRE_COMP); if (i > 0) return; if (pre->points) { EC_POINT **p; for (p = pre->points; *p != NULL; p++) { EC_POINT_clear_free(*p); OPENSSL_cleanse(p, sizeof *p); } free(pre->points); } OPENSSL_cleanse(pre, sizeof *pre); free(pre); } /* Determine the modified width-(w+1) Non-Adjacent Form (wNAF) of 'scalar'. * This is an array r[] of values that are either zero or odd with an * absolute value less than 2^w satisfying * scalar = \sum_j r[j]*2^j * where at most one of any w+1 consecutive digits is non-zero * with the exception that the most significant digit may be only * w-1 zeros away from that next non-zero digit. */ static signed char * compute_wNAF(const BIGNUM * scalar, int w, size_t * ret_len) { int window_val; int ok = 0; signed char *r = NULL; int sign = 1; int bit, next_bit, mask; size_t len = 0, j; if (BN_is_zero(scalar)) { r = malloc(1); if (!r) { ECerr(EC_F_COMPUTE_WNAF, ERR_R_MALLOC_FAILURE); goto err; } r[0] = 0; *ret_len = 1; return r; } if (w <= 0 || w > 7) { /* 'signed char' can represent integers with * absolute values less than 2^7 */ ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR); goto err; } bit = 1 << w; /* at most 128 */ next_bit = bit << 1; /* at most 256 */ mask = next_bit - 1; /* at most 255 */ if (BN_is_negative(scalar)) { sign = -1; } if (scalar->d == NULL || scalar->top == 0) { ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR); goto err; } len = BN_num_bits(scalar); r = malloc(len + 1); /* modified wNAF may be one digit longer than * binary representation (*ret_len will be * set to the actual length, i.e. at most * BN_num_bits(scalar) + 1) */ if (r == NULL) { ECerr(EC_F_COMPUTE_WNAF, ERR_R_MALLOC_FAILURE); goto err; } window_val = scalar->d[0] & mask; j = 0; while ((window_val != 0) || (j + w + 1 < len)) { /* if j+w+1 >= len, window_val will not increase */ int digit = 0; /* 0 <= window_val <= 2^(w+1) */ if (window_val & 1) { /* 0 < window_val < 2^(w+1) */ if (window_val & bit) { digit = window_val - next_bit; /* -2^w < digit < 0 */ #if 1 /* modified wNAF */ if (j + w + 1 >= len) { /* * special case for generating * modified wNAFs: no new bits will * be added into window_val, so using * a positive digit here will * decrease the total length of the * representation */ digit = window_val & (mask >> 1); /* 0 < digit < 2^w */ } #endif } else { digit = window_val; /* 0 < digit < 2^w */ } if (digit <= -bit || digit >= bit || !(digit & 1)) { ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR); goto err; } window_val -= digit; /* * now window_val is 0 or 2^(w+1) in standard wNAF * generation; for modified window NAFs, it may also * be 2^w */ if (window_val != 0 && window_val != next_bit && window_val != bit) { ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR); goto err; } } r[j++] = sign * digit; window_val >>= 1; window_val += bit * BN_is_bit_set(scalar, j + w); if (window_val > next_bit) { ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR); goto err; } } if (j > len + 1) { ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR); goto err; } len = j; ok = 1; err: if (!ok) { free(r); r = NULL; } if (ok) *ret_len = len; return r; } /* TODO: table should be optimised for the wNAF-based implementation, * sometimes smaller windows will give better performance * (thus the boundaries should be increased) */ #define EC_window_bits_for_scalar_size(b) \ ((size_t) \ ((b) >= 2000 ? 6 : \ (b) >= 800 ? 5 : \ (b) >= 300 ? 4 : \ (b) >= 70 ? 3 : \ (b) >= 20 ? 2 : \ 1)) /* Compute * \sum scalars[i]*points[i], * also including * scalar*generator * in the addition if scalar != NULL */ int ec_wNAF_mul(const EC_GROUP * group, EC_POINT * r, const BIGNUM * scalar, size_t num, const EC_POINT * points[], const BIGNUM * scalars[], BN_CTX * ctx) { BN_CTX *new_ctx = NULL; const EC_POINT *generator = NULL; EC_POINT *tmp = NULL; size_t totalnum; size_t blocksize = 0, numblocks = 0; /* for wNAF splitting */ size_t pre_points_per_block = 0; size_t i, j; int k; int r_is_inverted = 0; int r_is_at_infinity = 1; size_t *wsize = NULL; /* individual window sizes */ signed char **wNAF = NULL; /* individual wNAFs */ size_t *wNAF_len = NULL; size_t max_len = 0; size_t num_val; EC_POINT **val = NULL; /* precomputation */ EC_POINT **v; EC_POINT ***val_sub = NULL; /* pointers to sub-arrays of 'val' or * 'pre_comp->points' */ const EC_PRE_COMP *pre_comp = NULL; int num_scalar = 0; /* flag: will be set to 1 if 'scalar' must be * treated like other scalars, i.e. * precomputation is not available */ int ret = 0; if (group->meth != r->meth) { ECerr(EC_F_EC_WNAF_MUL, EC_R_INCOMPATIBLE_OBJECTS); return 0; } if ((scalar == NULL) && (num == 0)) { return EC_POINT_set_to_infinity(group, r); } for (i = 0; i < num; i++) { if (group->meth != points[i]->meth) { ECerr(EC_F_EC_WNAF_MUL, EC_R_INCOMPATIBLE_OBJECTS); return 0; } } if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) goto err; } if (scalar != NULL) { generator = EC_GROUP_get0_generator(group); if (generator == NULL) { ECerr(EC_F_EC_WNAF_MUL, EC_R_UNDEFINED_GENERATOR); goto err; } /* look if we can use precomputed multiples of generator */ pre_comp = EC_EX_DATA_get_data(group->extra_data, ec_pre_comp_dup, ec_pre_comp_free, ec_pre_comp_clear_free); if (pre_comp && pre_comp->numblocks && (EC_POINT_cmp(group, generator, pre_comp->points[0], ctx) == 0)) { blocksize = pre_comp->blocksize; /* * determine maximum number of blocks that wNAF * splitting may yield (NB: maximum wNAF length is * bit length plus one) */ numblocks = (BN_num_bits(scalar) / blocksize) + 1; /* * we cannot use more blocks than we have * precomputation for */ if (numblocks > pre_comp->numblocks) numblocks = pre_comp->numblocks; pre_points_per_block = (size_t) 1 << (pre_comp->w - 1); /* check that pre_comp looks sane */ if (pre_comp->num != (pre_comp->numblocks * pre_points_per_block)) { ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); goto err; } } else { /* can't use precomputation */ pre_comp = NULL; numblocks = 1; num_scalar = 1; /* treat 'scalar' like 'num'-th * element of 'scalars' */ } } totalnum = num + numblocks; wsize = reallocarray(NULL, totalnum, sizeof wsize[0]); wNAF_len = reallocarray(NULL, totalnum, sizeof wNAF_len[0]); /* includes space for pivot */ wNAF = reallocarray(NULL, (totalnum + 1), sizeof wNAF[0]); val_sub = reallocarray(NULL, totalnum, sizeof val_sub[0]); if (!wsize || !wNAF_len || !wNAF || !val_sub) { ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE); goto err; } wNAF[0] = NULL; /* preliminary pivot */ /* num_val will be the total number of temporarily precomputed points */ num_val = 0; for (i = 0; i < num + num_scalar; i++) { size_t bits; bits = i < num ? BN_num_bits(scalars[i]) : BN_num_bits(scalar); wsize[i] = EC_window_bits_for_scalar_size(bits); num_val += (size_t) 1 << (wsize[i] - 1); wNAF[i + 1] = NULL; /* make sure we always have a pivot */ wNAF[i] = compute_wNAF((i < num ? scalars[i] : scalar), wsize[i], &wNAF_len[i]); if (wNAF[i] == NULL) goto err; if (wNAF_len[i] > max_len) max_len = wNAF_len[i]; } if (numblocks) { /* we go here iff scalar != NULL */ if (pre_comp == NULL) { if (num_scalar != 1) { ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); goto err; } /* we have already generated a wNAF for 'scalar' */ } else { signed char *tmp_wNAF = NULL; size_t tmp_len = 0; if (num_scalar != 0) { ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); goto err; } /* * use the window size for which we have * precomputation */ wsize[num] = pre_comp->w; tmp_wNAF = compute_wNAF(scalar, wsize[num], &tmp_len); if (!tmp_wNAF) goto err; if (tmp_len <= max_len) { /* * One of the other wNAFs is at least as long * as the wNAF belonging to the generator, so * wNAF splitting will not buy us anything. */ numblocks = 1; totalnum = num + 1; /* don't use wNAF * splitting */ wNAF[num] = tmp_wNAF; wNAF[num + 1] = NULL; wNAF_len[num] = tmp_len; if (tmp_len > max_len) max_len = tmp_len; /* * pre_comp->points starts with the points * that we need here: */ val_sub[num] = pre_comp->points; } else { /* * don't include tmp_wNAF directly into wNAF * array - use wNAF splitting and include the * blocks */ signed char *pp; EC_POINT **tmp_points; if (tmp_len < numblocks * blocksize) { /* * possibly we can do with fewer * blocks than estimated */ numblocks = (tmp_len + blocksize - 1) / blocksize; if (numblocks > pre_comp->numblocks) { ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); goto err; } totalnum = num + numblocks; } /* split wNAF in 'numblocks' parts */ pp = tmp_wNAF; tmp_points = pre_comp->points; for (i = num; i < totalnum; i++) { if (i < totalnum - 1) { wNAF_len[i] = blocksize; if (tmp_len < blocksize) { ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); goto err; } tmp_len -= blocksize; } else /* * last block gets whatever * is left (this could be * more or less than * 'blocksize'!) */ wNAF_len[i] = tmp_len; wNAF[i + 1] = NULL; wNAF[i] = malloc(wNAF_len[i]); if (wNAF[i] == NULL) { ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE); free(tmp_wNAF); goto err; } memcpy(wNAF[i], pp, wNAF_len[i]); if (wNAF_len[i] > max_len) max_len = wNAF_len[i]; if (*tmp_points == NULL) { ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); free(tmp_wNAF); goto err; } val_sub[i] = tmp_points; tmp_points += pre_points_per_block; pp += blocksize; } free(tmp_wNAF); } } } /* * All points we precompute now go into a single array 'val'. * 'val_sub[i]' is a pointer to the subarray for the i-th point, or * to a subarray of 'pre_comp->points' if we already have * precomputation. */ val = reallocarray(NULL, (num_val + 1), sizeof val[0]); if (val == NULL) { ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE); goto err; } val[num_val] = NULL; /* pivot element */ /* allocate points for precomputation */ v = val; for (i = 0; i < num + num_scalar; i++) { val_sub[i] = v; for (j = 0; j < ((size_t) 1 << (wsize[i] - 1)); j++) { *v = EC_POINT_new(group); if (*v == NULL) goto err; v++; } } if (!(v == val + num_val)) { ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); goto err; } if (!(tmp = EC_POINT_new(group))) goto err; /* * prepare precomputed values: val_sub[i][0] := points[i] * val_sub[i][1] := 3 * points[i] val_sub[i][2] := 5 * points[i] ... */ for (i = 0; i < num + num_scalar; i++) { if (i < num) { if (!EC_POINT_copy(val_sub[i][0], points[i])) goto err; } else { if (!EC_POINT_copy(val_sub[i][0], generator)) goto err; } if (wsize[i] > 1) { if (!EC_POINT_dbl(group, tmp, val_sub[i][0], ctx)) goto err; for (j = 1; j < ((size_t) 1 << (wsize[i] - 1)); j++) { if (!EC_POINT_add(group, val_sub[i][j], val_sub[i][j - 1], tmp, ctx)) goto err; } } } #if 1 /* optional; EC_window_bits_for_scalar_size * assumes we do this step */ if (!EC_POINTs_make_affine(group, num_val, val, ctx)) goto err; #endif r_is_at_infinity = 1; for (k = max_len - 1; k >= 0; k--) { if (!r_is_at_infinity) { if (!EC_POINT_dbl(group, r, r, ctx)) goto err; } for (i = 0; i < totalnum; i++) { if (wNAF_len[i] > (size_t) k) { int digit = wNAF[i][k]; int is_neg; if (digit) { is_neg = digit < 0; if (is_neg) digit = -digit; if (is_neg != r_is_inverted) { if (!r_is_at_infinity) { if (!EC_POINT_invert(group, r, ctx)) goto err; } r_is_inverted = !r_is_inverted; } /* digit > 0 */ if (r_is_at_infinity) { if (!EC_POINT_copy(r, val_sub[i][digit >> 1])) goto err; r_is_at_infinity = 0; } else { if (!EC_POINT_add(group, r, r, val_sub[i][digit >> 1], ctx)) goto err; } } } } } if (r_is_at_infinity) { if (!EC_POINT_set_to_infinity(group, r)) goto err; } else { if (r_is_inverted) if (!EC_POINT_invert(group, r, ctx)) goto err; } ret = 1; err: if (new_ctx != NULL) BN_CTX_free(new_ctx); if (tmp != NULL) EC_POINT_free(tmp); free(wsize); free(wNAF_len); if (wNAF != NULL) { signed char **w; for (w = wNAF; *w != NULL; w++) free(*w); free(wNAF); } if (val != NULL) { for (v = val; *v != NULL; v++) EC_POINT_clear_free(*v); free(val); } free(val_sub); return ret; } /* ec_wNAF_precompute_mult() * creates an EC_PRE_COMP object with preprecomputed multiples of the generator * for use with wNAF splitting as implemented in ec_wNAF_mul(). * * 'pre_comp->points' is an array of multiples of the generator * of the following form: * points[0] = generator; * points[1] = 3 * generator; * ... * points[2^(w-1)-1] = (2^(w-1)-1) * generator; * points[2^(w-1)] = 2^blocksize * generator; * points[2^(w-1)+1] = 3 * 2^blocksize * generator; * ... * points[2^(w-1)*(numblocks-1)-1] = (2^(w-1)) * 2^(blocksize*(numblocks-2)) * generator * points[2^(w-1)*(numblocks-1)] = 2^(blocksize*(numblocks-1)) * generator * ... * points[2^(w-1)*numblocks-1] = (2^(w-1)) * 2^(blocksize*(numblocks-1)) * generator * points[2^(w-1)*numblocks] = NULL */ int ec_wNAF_precompute_mult(EC_GROUP * group, BN_CTX * ctx) { const EC_POINT *generator; EC_POINT *tmp_point = NULL, *base = NULL, **var; BN_CTX *new_ctx = NULL; BIGNUM *order; size_t i, bits, w, pre_points_per_block, blocksize, numblocks, num; EC_POINT **points = NULL; EC_PRE_COMP *pre_comp; int ret = 0; /* if there is an old EC_PRE_COMP object, throw it away */ EC_EX_DATA_free_data(&group->extra_data, ec_pre_comp_dup, ec_pre_comp_free, ec_pre_comp_clear_free); if ((pre_comp = ec_pre_comp_new(group)) == NULL) return 0; generator = EC_GROUP_get0_generator(group); if (generator == NULL) { ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, EC_R_UNDEFINED_GENERATOR); goto err; } if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) goto err; } BN_CTX_start(ctx); order = BN_CTX_get(ctx); if (order == NULL) goto err; if (!EC_GROUP_get_order(group, order, ctx)) goto err; if (BN_is_zero(order)) { ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, EC_R_UNKNOWN_ORDER); goto err; } bits = BN_num_bits(order); /* * The following parameters mean we precompute (approximately) one * point per bit. * * TBD: The combination 8, 4 is perfect for 160 bits; for other bit * lengths, other parameter combinations might provide better * efficiency. */ blocksize = 8; w = 4; if (EC_window_bits_for_scalar_size(bits) > w) { /* let's not make the window too small ... */ w = EC_window_bits_for_scalar_size(bits); } numblocks = (bits + blocksize - 1) / blocksize; /* max. number of blocks * to use for wNAF * splitting */ pre_points_per_block = (size_t) 1 << (w - 1); num = pre_points_per_block * numblocks; /* number of points to * compute and store */ points = reallocarray(NULL, (num + 1), sizeof(EC_POINT *)); if (!points) { ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE); goto err; } var = points; var[num] = NULL; /* pivot */ for (i = 0; i < num; i++) { if ((var[i] = EC_POINT_new(group)) == NULL) { ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE); goto err; } } if (!(tmp_point = EC_POINT_new(group)) || !(base = EC_POINT_new(group))) { ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE); goto err; } if (!EC_POINT_copy(base, generator)) goto err; /* do the precomputation */ for (i = 0; i < numblocks; i++) { size_t j; if (!EC_POINT_dbl(group, tmp_point, base, ctx)) goto err; if (!EC_POINT_copy(*var++, base)) goto err; for (j = 1; j < pre_points_per_block; j++, var++) { /* calculate odd multiples of the current base point */ if (!EC_POINT_add(group, *var, tmp_point, *(var - 1), ctx)) goto err; } if (i < numblocks - 1) { /* * get the next base (multiply current one by * 2^blocksize) */ size_t k; if (blocksize <= 2) { ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_INTERNAL_ERROR); goto err; } if (!EC_POINT_dbl(group, base, tmp_point, ctx)) goto err; for (k = 2; k < blocksize; k++) { if (!EC_POINT_dbl(group, base, base, ctx)) goto err; } } } if (!EC_POINTs_make_affine(group, num, points, ctx)) goto err; pre_comp->group = group; pre_comp->blocksize = blocksize; pre_comp->numblocks = numblocks; pre_comp->w = w; pre_comp->points = points; points = NULL; pre_comp->num = num; if (!EC_EX_DATA_set_data(&group->extra_data, pre_comp, ec_pre_comp_dup, ec_pre_comp_free, ec_pre_comp_clear_free)) goto err; pre_comp = NULL; ret = 1; err: if (ctx != NULL) BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); if (pre_comp) ec_pre_comp_free(pre_comp); if (points) { EC_POINT **p; for (p = points; *p != NULL; p++) EC_POINT_free(*p); free(points); } if (tmp_point) EC_POINT_free(tmp_point); if (base) EC_POINT_free(base); return ret; } int ec_wNAF_have_precompute_mult(const EC_GROUP * group) { if (EC_EX_DATA_get_data(group->extra_data, ec_pre_comp_dup, ec_pre_comp_free, ec_pre_comp_clear_free) != NULL) return 1; else return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ecp_oct.c0000644000175000017500000002571412360020705020433 0ustar /* $OpenBSD$ */ /* Includes code written by Lenka Fibikova * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * Portions of this software developed by SUN MICROSYSTEMS, INC., * and contributed to the OpenSSL project. */ #include #include "ec_lcl.h" int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP * group, EC_POINT * point, const BIGNUM * x_, int y_bit, BN_CTX * ctx) { BN_CTX *new_ctx = NULL; BIGNUM *tmp1, *tmp2, *x, *y; int ret = 0; /* clear error queue */ ERR_clear_error(); if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } y_bit = (y_bit != 0); BN_CTX_start(ctx); tmp1 = BN_CTX_get(ctx); tmp2 = BN_CTX_get(ctx); x = BN_CTX_get(ctx); y = BN_CTX_get(ctx); if (y == NULL) goto err; /* * Recover y. We have a Weierstrass equation y^2 = x^3 + a*x + b, so * y is one of the square roots of x^3 + a*x + b. */ /* tmp1 := x^3 */ if (!BN_nnmod(x, x_, &group->field, ctx)) goto err; if (group->meth->field_decode == 0) { /* field_{sqr,mul} work on standard representation */ if (!group->meth->field_sqr(group, tmp2, x_, ctx)) goto err; if (!group->meth->field_mul(group, tmp1, tmp2, x_, ctx)) goto err; } else { if (!BN_mod_sqr(tmp2, x_, &group->field, ctx)) goto err; if (!BN_mod_mul(tmp1, tmp2, x_, &group->field, ctx)) goto err; } /* tmp1 := tmp1 + a*x */ if (group->a_is_minus3) { if (!BN_mod_lshift1_quick(tmp2, x, &group->field)) goto err; if (!BN_mod_add_quick(tmp2, tmp2, x, &group->field)) goto err; if (!BN_mod_sub_quick(tmp1, tmp1, tmp2, &group->field)) goto err; } else { if (group->meth->field_decode) { if (!group->meth->field_decode(group, tmp2, &group->a, ctx)) goto err; if (!BN_mod_mul(tmp2, tmp2, x, &group->field, ctx)) goto err; } else { /* field_mul works on standard representation */ if (!group->meth->field_mul(group, tmp2, &group->a, x, ctx)) goto err; } if (!BN_mod_add_quick(tmp1, tmp1, tmp2, &group->field)) goto err; } /* tmp1 := tmp1 + b */ if (group->meth->field_decode) { if (!group->meth->field_decode(group, tmp2, &group->b, ctx)) goto err; if (!BN_mod_add_quick(tmp1, tmp1, tmp2, &group->field)) goto err; } else { if (!BN_mod_add_quick(tmp1, tmp1, &group->b, &group->field)) goto err; } if (!BN_mod_sqrt(y, tmp1, &group->field, ctx)) { unsigned long err = ERR_peek_last_error(); if (ERR_GET_LIB(err) == ERR_LIB_BN && ERR_GET_REASON(err) == BN_R_NOT_A_SQUARE) { ERR_clear_error(); ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES, EC_R_INVALID_COMPRESSED_POINT); } else ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES, ERR_R_BN_LIB); goto err; } if (y_bit != BN_is_odd(y)) { if (BN_is_zero(y)) { int kron; kron = BN_kronecker(x, &group->field, ctx); if (kron == -2) goto err; if (kron == 1) ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES, EC_R_INVALID_COMPRESSION_BIT); else /* * BN_mod_sqrt() should have cought this * error (not a square) */ ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES, EC_R_INVALID_COMPRESSED_POINT); goto err; } if (!BN_usub(y, &group->field, y)) goto err; } if (y_bit != BN_is_odd(y)) { ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES, ERR_R_INTERNAL_ERROR); goto err; } if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx)) goto err; ret = 1; err: BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } size_t ec_GFp_simple_point2oct(const EC_GROUP * group, const EC_POINT * point, point_conversion_form_t form, unsigned char *buf, size_t len, BN_CTX * ctx) { size_t ret; BN_CTX *new_ctx = NULL; int used_ctx = 0; BIGNUM *x, *y; size_t field_len, i, skip; if ((form != POINT_CONVERSION_COMPRESSED) && (form != POINT_CONVERSION_UNCOMPRESSED) && (form != POINT_CONVERSION_HYBRID)) { ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, EC_R_INVALID_FORM); goto err; } if (EC_POINT_is_at_infinity(group, point)) { /* encodes to a single 0 octet */ if (buf != NULL) { if (len < 1) { ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL); return 0; } buf[0] = 0; } return 1; } /* ret := required output buffer length */ field_len = BN_num_bytes(&group->field); ret = (form == POINT_CONVERSION_COMPRESSED) ? 1 + field_len : 1 + 2 * field_len; /* if 'buf' is NULL, just return required length */ if (buf != NULL) { if (len < ret) { ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL); goto err; } if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } BN_CTX_start(ctx); used_ctx = 1; x = BN_CTX_get(ctx); y = BN_CTX_get(ctx); if (y == NULL) goto err; if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx)) goto err; if ((form == POINT_CONVERSION_COMPRESSED || form == POINT_CONVERSION_HYBRID) && BN_is_odd(y)) buf[0] = form + 1; else buf[0] = form; i = 1; skip = field_len - BN_num_bytes(x); if (skip > field_len) { ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); goto err; } while (skip > 0) { buf[i++] = 0; skip--; } skip = BN_bn2bin(x, buf + i); i += skip; if (i != 1 + field_len) { ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); goto err; } if (form == POINT_CONVERSION_UNCOMPRESSED || form == POINT_CONVERSION_HYBRID) { skip = field_len - BN_num_bytes(y); if (skip > field_len) { ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); goto err; } while (skip > 0) { buf[i++] = 0; skip--; } skip = BN_bn2bin(y, buf + i); i += skip; } if (i != ret) { ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); goto err; } } if (used_ctx) BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; err: if (used_ctx) BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return 0; } int ec_GFp_simple_oct2point(const EC_GROUP * group, EC_POINT * point, const unsigned char *buf, size_t len, BN_CTX * ctx) { point_conversion_form_t form; int y_bit; BN_CTX *new_ctx = NULL; BIGNUM *x, *y; size_t field_len, enc_len; int ret = 0; if (len == 0) { ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_BUFFER_TOO_SMALL); return 0; } form = buf[0]; y_bit = form & 1; form = form & ~1U; if ((form != 0) && (form != POINT_CONVERSION_COMPRESSED) && (form != POINT_CONVERSION_UNCOMPRESSED) && (form != POINT_CONVERSION_HYBRID)) { ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); return 0; } if ((form == 0 || form == POINT_CONVERSION_UNCOMPRESSED) && y_bit) { ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); return 0; } if (form == 0) { if (len != 1) { ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); return 0; } return EC_POINT_set_to_infinity(group, point); } field_len = BN_num_bytes(&group->field); enc_len = (form == POINT_CONVERSION_COMPRESSED) ? 1 + field_len : 1 + 2 * field_len; if (len != enc_len) { ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); return 0; } if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } BN_CTX_start(ctx); x = BN_CTX_get(ctx); y = BN_CTX_get(ctx); if (y == NULL) goto err; if (!BN_bin2bn(buf + 1, field_len, x)) goto err; if (BN_ucmp(x, &group->field) >= 0) { ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); goto err; } if (form == POINT_CONVERSION_COMPRESSED) { if (!EC_POINT_set_compressed_coordinates_GFp(group, point, x, y_bit, ctx)) goto err; } else { if (!BN_bin2bn(buf + 1 + field_len, field_len, y)) goto err; if (BN_ucmp(y, &group->field) >= 0) { ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); goto err; } if (form == POINT_CONVERSION_HYBRID) { if (y_bit != BN_is_odd(y)) { ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); goto err; } } if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx)) goto err; } if (!EC_POINT_is_on_curve(group, point, ctx)) { /* test required by * X9.62 */ ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_POINT_IS_NOT_ON_CURVE); goto err; } ret = 1; err: BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ec_ameth.c0000644000175000017500000003665012360020705020565 0ustar /* $OpenBSD: ec_ameth.c,v 1.10 2014/07/10 22:45:57 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #ifndef OPENSSL_NO_CMS #include #endif #include "asn1_locl.h" static int eckey_param2type(int *pptype, void **ppval, EC_KEY * ec_key) { const EC_GROUP *group; int nid; if (ec_key == NULL || (group = EC_KEY_get0_group(ec_key)) == NULL) { ECerr(EC_F_ECKEY_PARAM2TYPE, EC_R_MISSING_PARAMETERS); return 0; } if (EC_GROUP_get_asn1_flag(group) && (nid = EC_GROUP_get_curve_name(group))) { /* we have a 'named curve' => just set the OID */ *ppval = OBJ_nid2obj(nid); *pptype = V_ASN1_OBJECT; } else { /* explicit parameters */ ASN1_STRING *pstr = NULL; pstr = ASN1_STRING_new(); if (!pstr) return 0; pstr->length = i2d_ECParameters(ec_key, &pstr->data); if (pstr->length <= 0) { ASN1_STRING_free(pstr); ECerr(EC_F_ECKEY_PARAM2TYPE, ERR_R_EC_LIB); return 0; } *ppval = pstr; *pptype = V_ASN1_SEQUENCE; } return 1; } static int eckey_pub_encode(X509_PUBKEY * pk, const EVP_PKEY * pkey) { EC_KEY *ec_key = pkey->pkey.ec; void *pval = NULL; int ptype; unsigned char *penc = NULL, *p; int penclen; if (!eckey_param2type(&ptype, &pval, ec_key)) { ECerr(EC_F_ECKEY_PUB_ENCODE, ERR_R_EC_LIB); return 0; } penclen = i2o_ECPublicKey(ec_key, NULL); if (penclen <= 0) goto err; penc = malloc(penclen); if (!penc) goto err; p = penc; penclen = i2o_ECPublicKey(ec_key, &p); if (penclen <= 0) goto err; if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_EC), ptype, pval, penc, penclen)) return 1; err: if (ptype == V_ASN1_OBJECT) ASN1_OBJECT_free(pval); else ASN1_STRING_free(pval); free(penc); return 0; } static EC_KEY * eckey_type2param(int ptype, void *pval) { EC_KEY *eckey = NULL; if (ptype == V_ASN1_SEQUENCE) { ASN1_STRING *pstr = pval; const unsigned char *pm = NULL; int pmlen; pm = pstr->data; pmlen = pstr->length; if (!(eckey = d2i_ECParameters(NULL, &pm, pmlen))) { ECerr(EC_F_ECKEY_TYPE2PARAM, EC_R_DECODE_ERROR); goto ecerr; } } else if (ptype == V_ASN1_OBJECT) { ASN1_OBJECT *poid = pval; EC_GROUP *group; /* * type == V_ASN1_OBJECT => the parameters are given by an * asn1 OID */ if ((eckey = EC_KEY_new()) == NULL) { ECerr(EC_F_ECKEY_TYPE2PARAM, ERR_R_MALLOC_FAILURE); goto ecerr; } group = EC_GROUP_new_by_curve_name(OBJ_obj2nid(poid)); if (group == NULL) goto ecerr; EC_GROUP_set_asn1_flag(group, OPENSSL_EC_NAMED_CURVE); if (EC_KEY_set_group(eckey, group) == 0) goto ecerr; EC_GROUP_free(group); } else { ECerr(EC_F_ECKEY_TYPE2PARAM, EC_R_DECODE_ERROR); goto ecerr; } return eckey; ecerr: if (eckey) EC_KEY_free(eckey); return NULL; } static int eckey_pub_decode(EVP_PKEY * pkey, X509_PUBKEY * pubkey) { const unsigned char *p = NULL; void *pval; int ptype, pklen; EC_KEY *eckey = NULL; X509_ALGOR *palg; if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, &palg, pubkey)) return 0; X509_ALGOR_get0(NULL, &ptype, &pval, palg); eckey = eckey_type2param(ptype, pval); if (!eckey) { ECerr(EC_F_ECKEY_PUB_DECODE, ERR_R_EC_LIB); return 0; } /* We have parameters now set public key */ if (!o2i_ECPublicKey(&eckey, &p, pklen)) { ECerr(EC_F_ECKEY_PUB_DECODE, EC_R_DECODE_ERROR); goto ecerr; } EVP_PKEY_assign_EC_KEY(pkey, eckey); return 1; ecerr: if (eckey) EC_KEY_free(eckey); return 0; } static int eckey_pub_cmp(const EVP_PKEY * a, const EVP_PKEY * b) { int r; const EC_GROUP *group = EC_KEY_get0_group(b->pkey.ec); const EC_POINT *pa = EC_KEY_get0_public_key(a->pkey.ec), *pb = EC_KEY_get0_public_key(b->pkey.ec); r = EC_POINT_cmp(group, pa, pb, NULL); if (r == 0) return 1; if (r == 1) return 0; return -2; } static int eckey_priv_decode(EVP_PKEY * pkey, PKCS8_PRIV_KEY_INFO * p8) { const unsigned char *p = NULL; void *pval; int ptype, pklen; EC_KEY *eckey = NULL; X509_ALGOR *palg; if (!PKCS8_pkey_get0(NULL, &p, &pklen, &palg, p8)) return 0; X509_ALGOR_get0(NULL, &ptype, &pval, palg); eckey = eckey_type2param(ptype, pval); if (!eckey) goto ecliberr; /* We have parameters now set private key */ if (!d2i_ECPrivateKey(&eckey, &p, pklen)) { ECerr(EC_F_ECKEY_PRIV_DECODE, EC_R_DECODE_ERROR); goto ecerr; } /* calculate public key (if necessary) */ if (EC_KEY_get0_public_key(eckey) == NULL) { const BIGNUM *priv_key; const EC_GROUP *group; EC_POINT *pub_key; /* * the public key was not included in the SEC1 private key => * calculate the public key */ group = EC_KEY_get0_group(eckey); pub_key = EC_POINT_new(group); if (pub_key == NULL) { ECerr(EC_F_ECKEY_PRIV_DECODE, ERR_R_EC_LIB); goto ecliberr; } if (!EC_POINT_copy(pub_key, EC_GROUP_get0_generator(group))) { EC_POINT_free(pub_key); ECerr(EC_F_ECKEY_PRIV_DECODE, ERR_R_EC_LIB); goto ecliberr; } priv_key = EC_KEY_get0_private_key(eckey); if (!EC_POINT_mul(group, pub_key, priv_key, NULL, NULL, NULL)) { EC_POINT_free(pub_key); ECerr(EC_F_ECKEY_PRIV_DECODE, ERR_R_EC_LIB); goto ecliberr; } if (EC_KEY_set_public_key(eckey, pub_key) == 0) { EC_POINT_free(pub_key); ECerr(EC_F_ECKEY_PRIV_DECODE, ERR_R_EC_LIB); goto ecliberr; } EC_POINT_free(pub_key); } EVP_PKEY_assign_EC_KEY(pkey, eckey); return 1; ecliberr: ECerr(EC_F_ECKEY_PRIV_DECODE, ERR_R_EC_LIB); ecerr: if (eckey) EC_KEY_free(eckey); return 0; } static int eckey_priv_encode(PKCS8_PRIV_KEY_INFO * p8, const EVP_PKEY * pkey) { EC_KEY *ec_key; unsigned char *ep, *p; int eplen, ptype; void *pval; unsigned int tmp_flags, old_flags; ec_key = pkey->pkey.ec; if (!eckey_param2type(&ptype, &pval, ec_key)) { ECerr(EC_F_ECKEY_PRIV_ENCODE, EC_R_DECODE_ERROR); return 0; } /* set the private key */ /* * do not include the parameters in the SEC1 private key see PKCS#11 * 12.11 */ old_flags = EC_KEY_get_enc_flags(ec_key); tmp_flags = old_flags | EC_PKEY_NO_PARAMETERS; EC_KEY_set_enc_flags(ec_key, tmp_flags); eplen = i2d_ECPrivateKey(ec_key, NULL); if (!eplen) { EC_KEY_set_enc_flags(ec_key, old_flags); ECerr(EC_F_ECKEY_PRIV_ENCODE, ERR_R_EC_LIB); return 0; } ep = malloc(eplen); if (!ep) { EC_KEY_set_enc_flags(ec_key, old_flags); ECerr(EC_F_ECKEY_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); return 0; } p = ep; if (!i2d_ECPrivateKey(ec_key, &p)) { EC_KEY_set_enc_flags(ec_key, old_flags); free(ep); ECerr(EC_F_ECKEY_PRIV_ENCODE, ERR_R_EC_LIB); return 0; } /* restore old encoding flags */ EC_KEY_set_enc_flags(ec_key, old_flags); if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(NID_X9_62_id_ecPublicKey), 0, ptype, pval, ep, eplen)) return 0; return 1; } static int int_ec_size(const EVP_PKEY * pkey) { return ECDSA_size(pkey->pkey.ec); } static int ec_bits(const EVP_PKEY * pkey) { BIGNUM *order = BN_new(); const EC_GROUP *group; int ret; if (!order) { ERR_clear_error(); return 0; } group = EC_KEY_get0_group(pkey->pkey.ec); if (!EC_GROUP_get_order(group, order, NULL)) { ERR_clear_error(); return 0; } ret = BN_num_bits(order); BN_free(order); return ret; } static int ec_missing_parameters(const EVP_PKEY * pkey) { if (EC_KEY_get0_group(pkey->pkey.ec) == NULL) return 1; return 0; } static int ec_copy_parameters(EVP_PKEY * to, const EVP_PKEY * from) { EC_GROUP *group = EC_GROUP_dup(EC_KEY_get0_group(from->pkey.ec)); if (group == NULL) return 0; if (EC_KEY_set_group(to->pkey.ec, group) == 0) return 0; EC_GROUP_free(group); return 1; } static int ec_cmp_parameters(const EVP_PKEY * a, const EVP_PKEY * b) { const EC_GROUP *group_a = EC_KEY_get0_group(a->pkey.ec), *group_b = EC_KEY_get0_group(b->pkey.ec); if (EC_GROUP_cmp(group_a, group_b, NULL)) return 0; else return 1; } static void int_ec_free(EVP_PKEY * pkey) { EC_KEY_free(pkey->pkey.ec); } static int do_EC_KEY_print(BIO * bp, const EC_KEY * x, int off, int ktype) { unsigned char *buffer = NULL; const char *ecstr; size_t buf_len = 0, i; int ret = 0, reason = ERR_R_BIO_LIB; BIGNUM *pub_key = NULL, *order = NULL; BN_CTX *ctx = NULL; const EC_GROUP *group; const EC_POINT *public_key; const BIGNUM *priv_key; if (x == NULL || (group = EC_KEY_get0_group(x)) == NULL) { reason = ERR_R_PASSED_NULL_PARAMETER; goto err; } ctx = BN_CTX_new(); if (ctx == NULL) { reason = ERR_R_MALLOC_FAILURE; goto err; } if (ktype > 0) { public_key = EC_KEY_get0_public_key(x); if ((pub_key = EC_POINT_point2bn(group, public_key, EC_KEY_get_conv_form(x), NULL, ctx)) == NULL) { reason = ERR_R_EC_LIB; goto err; } if (pub_key) buf_len = (size_t) BN_num_bytes(pub_key); } if (ktype == 2) { priv_key = EC_KEY_get0_private_key(x); if (priv_key && (i = (size_t) BN_num_bytes(priv_key)) > buf_len) buf_len = i; } else priv_key = NULL; if (ktype > 0) { buf_len += 10; if ((buffer = malloc(buf_len)) == NULL) { reason = ERR_R_MALLOC_FAILURE; goto err; } } if (ktype == 2) ecstr = "Private-Key"; else if (ktype == 1) ecstr = "Public-Key"; else ecstr = "ECDSA-Parameters"; if (!BIO_indent(bp, off, 128)) goto err; if ((order = BN_new()) == NULL) goto err; if (!EC_GROUP_get_order(group, order, NULL)) goto err; if (BIO_printf(bp, "%s: (%d bit)\n", ecstr, BN_num_bits(order)) <= 0) goto err; if ((priv_key != NULL) && !ASN1_bn_print(bp, "priv:", priv_key, buffer, off)) goto err; if ((pub_key != NULL) && !ASN1_bn_print(bp, "pub: ", pub_key, buffer, off)) goto err; if (!ECPKParameters_print(bp, group, off)) goto err; ret = 1; err: if (!ret) ECerr(EC_F_DO_EC_KEY_PRINT, reason); if (pub_key) BN_free(pub_key); if (order) BN_free(order); if (ctx) BN_CTX_free(ctx); free(buffer); return (ret); } static int eckey_param_decode(EVP_PKEY * pkey, const unsigned char **pder, int derlen) { EC_KEY *eckey; if (!(eckey = d2i_ECParameters(NULL, pder, derlen))) { ECerr(EC_F_ECKEY_PARAM_DECODE, ERR_R_EC_LIB); return 0; } EVP_PKEY_assign_EC_KEY(pkey, eckey); return 1; } static int eckey_param_encode(const EVP_PKEY * pkey, unsigned char **pder) { return i2d_ECParameters(pkey->pkey.ec, pder); } static int eckey_param_print(BIO * bp, const EVP_PKEY * pkey, int indent, ASN1_PCTX * ctx) { return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 0); } static int eckey_pub_print(BIO * bp, const EVP_PKEY * pkey, int indent, ASN1_PCTX * ctx) { return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 1); } static int eckey_priv_print(BIO * bp, const EVP_PKEY * pkey, int indent, ASN1_PCTX * ctx) { return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 2); } static int old_ec_priv_decode(EVP_PKEY * pkey, const unsigned char **pder, int derlen) { EC_KEY *ec; if (!(ec = d2i_ECPrivateKey(NULL, pder, derlen))) { ECerr(EC_F_OLD_EC_PRIV_DECODE, EC_R_DECODE_ERROR); return 0; } EVP_PKEY_assign_EC_KEY(pkey, ec); return 1; } static int old_ec_priv_encode(const EVP_PKEY * pkey, unsigned char **pder) { return i2d_ECPrivateKey(pkey->pkey.ec, pder); } static int ec_pkey_ctrl(EVP_PKEY * pkey, int op, long arg1, void *arg2) { switch (op) { case ASN1_PKEY_CTRL_PKCS7_SIGN: if (arg1 == 0) { int snid, hnid; X509_ALGOR *alg1, *alg2; PKCS7_SIGNER_INFO_get0_algs(arg2, NULL, &alg1, &alg2); if (alg1 == NULL || alg1->algorithm == NULL) return -1; hnid = OBJ_obj2nid(alg1->algorithm); if (hnid == NID_undef) return -1; if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) return -1; X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); } return 1; #ifndef OPENSSL_NO_CMS case ASN1_PKEY_CTRL_CMS_SIGN: if (arg1 == 0) { int snid, hnid; X509_ALGOR *alg1, *alg2; CMS_SignerInfo_get0_algs(arg2, NULL, NULL, &alg1, &alg2); if (alg1 == NULL || alg1->algorithm == NULL) return -1; hnid = OBJ_obj2nid(alg1->algorithm); if (hnid == NID_undef) return -1; if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) return -1; X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); } return 1; #endif case ASN1_PKEY_CTRL_DEFAULT_MD_NID: *(int *) arg2 = NID_sha1; return 2; default: return -2; } } const EVP_PKEY_ASN1_METHOD eckey_asn1_meth = { .pkey_id = EVP_PKEY_EC, .pkey_base_id = EVP_PKEY_EC, .pem_str = "EC", .info = "OpenSSL EC algorithm", .pub_decode = eckey_pub_decode, .pub_encode = eckey_pub_encode, .pub_cmp = eckey_pub_cmp, .pub_print = eckey_pub_print, .priv_decode = eckey_priv_decode, .priv_encode = eckey_priv_encode, .priv_print = eckey_priv_print, .pkey_size = int_ec_size, .pkey_bits = ec_bits, .param_decode = eckey_param_decode, .param_encode = eckey_param_encode, .param_missing = ec_missing_parameters, .param_copy = ec_copy_parameters, .param_cmp = ec_cmp_parameters, .param_print = eckey_param_print, .pkey_free = int_ec_free, .pkey_ctrl = ec_pkey_ctrl, .old_priv_decode = old_ec_priv_decode, .old_priv_encode = old_ec_priv_encode }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ecp_nist.c0000644000175000017500000001526712360020705020625 0ustar /* $OpenBSD$ */ /* * Written by Nils Larsch for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * Portions of this software developed by SUN MICROSYSTEMS, INC., * and contributed to the OpenSSL project. */ #include #include #include #include "ec_lcl.h" const EC_METHOD * EC_GFp_nist_method(void) { static const EC_METHOD ret = { .flags = EC_FLAGS_DEFAULT_OCT, .field_type = NID_X9_62_prime_field, .group_init = ec_GFp_simple_group_init, .group_finish = ec_GFp_simple_group_finish, .group_clear_finish = ec_GFp_simple_group_clear_finish, .group_copy = ec_GFp_nist_group_copy, .group_set_curve = ec_GFp_nist_group_set_curve, .group_get_curve = ec_GFp_simple_group_get_curve, .group_get_degree = ec_GFp_simple_group_get_degree, .group_check_discriminant = ec_GFp_simple_group_check_discriminant, .point_init = ec_GFp_simple_point_init, .point_finish = ec_GFp_simple_point_finish, .point_clear_finish = ec_GFp_simple_point_clear_finish, .point_copy = ec_GFp_simple_point_copy, .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, .point_set_Jprojective_coordinates_GFp = ec_GFp_simple_set_Jprojective_coordinates_GFp, .point_get_Jprojective_coordinates_GFp = ec_GFp_simple_get_Jprojective_coordinates_GFp, .point_set_affine_coordinates = ec_GFp_simple_point_set_affine_coordinates, .point_get_affine_coordinates = ec_GFp_simple_point_get_affine_coordinates, .add = ec_GFp_simple_add, .dbl = ec_GFp_simple_dbl, .invert = ec_GFp_simple_invert, .is_at_infinity = ec_GFp_simple_is_at_infinity, .is_on_curve = ec_GFp_simple_is_on_curve, .point_cmp = ec_GFp_simple_cmp, .make_affine = ec_GFp_simple_make_affine, .points_make_affine = ec_GFp_simple_points_make_affine, .field_mul = ec_GFp_nist_field_mul, .field_sqr = ec_GFp_nist_field_sqr }; return &ret; } int ec_GFp_nist_group_copy(EC_GROUP * dest, const EC_GROUP * src) { dest->field_mod_func = src->field_mod_func; return ec_GFp_simple_group_copy(dest, src); } int ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { int ret = 0; BN_CTX *new_ctx = NULL; BIGNUM *tmp_bn; if (ctx == NULL) if ((ctx = new_ctx = BN_CTX_new()) == NULL) return 0; BN_CTX_start(ctx); if ((tmp_bn = BN_CTX_get(ctx)) == NULL) goto err; if (BN_ucmp(BN_get0_nist_prime_192(), p) == 0) group->field_mod_func = BN_nist_mod_192; else if (BN_ucmp(BN_get0_nist_prime_224(), p) == 0) group->field_mod_func = BN_nist_mod_224; else if (BN_ucmp(BN_get0_nist_prime_256(), p) == 0) group->field_mod_func = BN_nist_mod_256; else if (BN_ucmp(BN_get0_nist_prime_384(), p) == 0) group->field_mod_func = BN_nist_mod_384; else if (BN_ucmp(BN_get0_nist_prime_521(), p) == 0) group->field_mod_func = BN_nist_mod_521; else { ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE, EC_R_NOT_A_NIST_PRIME); goto err; } ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); err: BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } int ec_GFp_nist_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { int ret = 0; BN_CTX *ctx_new = NULL; if (!group || !r || !a || !b) { ECerr(EC_F_EC_GFP_NIST_FIELD_MUL, ERR_R_PASSED_NULL_PARAMETER); goto err; } if (!ctx) if ((ctx_new = ctx = BN_CTX_new()) == NULL) goto err; if (!BN_mul(r, a, b, ctx)) goto err; if (!group->field_mod_func(r, r, &group->field, ctx)) goto err; ret = 1; err: if (ctx_new) BN_CTX_free(ctx_new); return ret; } int ec_GFp_nist_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, BN_CTX * ctx) { int ret = 0; BN_CTX *ctx_new = NULL; if (!group || !r || !a) { ECerr(EC_F_EC_GFP_NIST_FIELD_SQR, EC_R_PASSED_NULL_PARAMETER); goto err; } if (!ctx) if ((ctx_new = ctx = BN_CTX_new()) == NULL) goto err; if (!BN_sqr(r, a, ctx)) goto err; if (!group->field_mod_func(r, r, &group->field, ctx)) goto err; ret = 1; err: if (ctx_new) BN_CTX_free(ctx_new); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ec_cvt.c0000644000175000017500000001337212360020705020257 0ustar /* $OpenBSD: ec_cvt.c,v 1.5 2014/06/12 15:49:29 deraadt Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * Portions of the attached software ("Contribution") are developed by * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. * * The Contribution is licensed pursuant to the OpenSSL open source * license provided above. * * The elliptic curve binary polynomial software is originally written by * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. * */ #include #include #include "ec_lcl.h" EC_GROUP * EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { const EC_METHOD *meth; EC_GROUP *ret; #if defined(OPENSSL_BN_ASM_MONT) /* * This might appear controversial, but the fact is that generic * prime method was observed to deliver better performance even * for NIST primes on a range of platforms, e.g.: 60%-15% * improvement on IA-64, ~25% on ARM, 30%-90% on P4, 20%-25% * in 32-bit build and 35%--12% in 64-bit build on Core2... * Coefficients are relative to optimized bn_nist.c for most * intensive ECDSA verify and ECDH operations for 192- and 521- * bit keys respectively. Choice of these boundary values is * arguable, because the dependency of improvement coefficient * from key length is not a "monotone" curve. For example while * 571-bit result is 23% on ARM, 384-bit one is -1%. But it's * generally faster, sometimes "respectfully" faster, sometimes * "tolerably" slower... What effectively happens is that loop * with bn_mul_add_words is put against bn_mul_mont, and the * latter "wins" on short vectors. Correct solution should be * implementing dedicated NxN multiplication subroutines for * small N. But till it materializes, let's stick to generic * prime method... * */ meth = EC_GFp_mont_method(); #else meth = EC_GFp_nist_method(); #endif ret = EC_GROUP_new(meth); if (ret == NULL) return NULL; if (!EC_GROUP_set_curve_GFp(ret, p, a, b, ctx)) { unsigned long err; err = ERR_peek_last_error(); if (!(ERR_GET_LIB(err) == ERR_LIB_EC && ((ERR_GET_REASON(err) == EC_R_NOT_A_NIST_PRIME) || (ERR_GET_REASON(err) == EC_R_NOT_A_SUPPORTED_NIST_PRIME)))) { /* real error */ EC_GROUP_clear_free(ret); return NULL; } /* not an actual error, we just cannot use EC_GFp_nist_method */ ERR_clear_error(); EC_GROUP_clear_free(ret); meth = EC_GFp_mont_method(); ret = EC_GROUP_new(meth); if (ret == NULL) return NULL; if (!EC_GROUP_set_curve_GFp(ret, p, a, b, ctx)) { EC_GROUP_clear_free(ret); return NULL; } } return ret; } #ifndef OPENSSL_NO_EC2M EC_GROUP * EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { const EC_METHOD *meth; EC_GROUP *ret; meth = EC_GF2m_simple_method(); ret = EC_GROUP_new(meth); if (ret == NULL) return NULL; if (!EC_GROUP_set_curve_GF2m(ret, p, a, b, ctx)) { EC_GROUP_clear_free(ret); return NULL; } return ret; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ec_oct.c0000644000175000017500000001525112360020705020246 0ustar /* $OpenBSD: ec_oct.c,v 1.3 2014/06/12 15:49:29 deraadt Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * Binary polynomial ECC support in OpenSSL originally developed by * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. */ #include #include #include #include #include "ec_lcl.h" int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP * group, EC_POINT * point, const BIGNUM * x, int y_bit, BN_CTX * ctx) { if (group->meth->point_set_compressed_coordinates == 0 && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) { ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (group->meth != point->meth) { ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP, EC_R_INCOMPATIBLE_OBJECTS); return 0; } if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) { if (group->meth->field_type == NID_X9_62_prime_field) return ec_GFp_simple_set_compressed_coordinates( group, point, x, y_bit, ctx); else #ifdef OPENSSL_NO_EC2M { ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP, EC_R_GF2M_NOT_SUPPORTED); return 0; } #else return ec_GF2m_simple_set_compressed_coordinates( group, point, x, y_bit, ctx); #endif } return group->meth->point_set_compressed_coordinates(group, point, x, y_bit, ctx); } #ifndef OPENSSL_NO_EC2M int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP * group, EC_POINT * point, const BIGNUM * x, int y_bit, BN_CTX * ctx) { if (group->meth->point_set_compressed_coordinates == 0 && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) { ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (group->meth != point->meth) { ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M, EC_R_INCOMPATIBLE_OBJECTS); return 0; } if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) { if (group->meth->field_type == NID_X9_62_prime_field) return ec_GFp_simple_set_compressed_coordinates( group, point, x, y_bit, ctx); else return ec_GF2m_simple_set_compressed_coordinates( group, point, x, y_bit, ctx); } return group->meth->point_set_compressed_coordinates(group, point, x, y_bit, ctx); } #endif size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form, unsigned char *buf, size_t len, BN_CTX *ctx) { if (group->meth->point2oct == 0 && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) { ECerr(EC_F_EC_POINT_POINT2OCT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (group->meth != point->meth) { ECerr(EC_F_EC_POINT_POINT2OCT, EC_R_INCOMPATIBLE_OBJECTS); return 0; } if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) { if (group->meth->field_type == NID_X9_62_prime_field) return ec_GFp_simple_point2oct(group, point, form, buf, len, ctx); else #ifdef OPENSSL_NO_EC2M { ECerr(EC_F_EC_POINT_POINT2OCT, EC_R_GF2M_NOT_SUPPORTED); return 0; } #else return ec_GF2m_simple_point2oct(group, point, form, buf, len, ctx); #endif } return group->meth->point2oct(group, point, form, buf, len, ctx); } int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point, const unsigned char *buf, size_t len, BN_CTX *ctx) { if (group->meth->oct2point == 0 && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) { ECerr(EC_F_EC_POINT_OCT2POINT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } if (group->meth != point->meth) { ECerr(EC_F_EC_POINT_OCT2POINT, EC_R_INCOMPATIBLE_OBJECTS); return 0; } if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) { if (group->meth->field_type == NID_X9_62_prime_field) return ec_GFp_simple_oct2point(group, point, buf, len, ctx); else #ifdef OPENSSL_NO_EC2M { ECerr(EC_F_EC_POINT_OCT2POINT, EC_R_GF2M_NOT_SUPPORTED); return 0; } #else return ec_GF2m_simple_oct2point(group, point, buf, len, ctx); #endif } return group->meth->oct2point(group, point, buf, len, ctx); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ec_curve.c0000644000175000017500000036367512360020705020625 0ustar /* $OpenBSD: ec_curve.c,v 1.5 2014/06/12 15:49:29 deraadt Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2010 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * Portions of the attached software ("Contribution") are developed by * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. * * The Contribution is licensed pursuant to the OpenSSL open source * license provided above. * * The elliptic curve binary polynomial software is originally written by * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. * */ #include #include "ec_lcl.h" #include #include typedef struct { int field_type, /* either NID_X9_62_prime_field or * NID_X9_62_characteristic_two_field */ seed_len, param_len; unsigned int cofactor; /* promoted to BN_ULONG */ } EC_CURVE_DATA; /* the nist prime curves */ static const struct { EC_CURVE_DATA h; unsigned char data[20 + 24 * 6]; } _EC_NIST_PRIME_192 = { { NID_X9_62_prime_field, 20, 24, 1 }, { 0x30, 0x45, 0xAE, 0x6F, 0xC8, 0x42, 0x2F, 0x64, 0xED, 0x57, /* seed */ 0x95, 0x28, 0xD3, 0x81, 0x20, 0xEA, 0xE1, 0x21, 0x96, 0xD5, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* a */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x64, 0x21, 0x05, 0x19, 0xE5, 0x9C, 0x80, 0xE7, 0x0F, 0xA7, /* b */ 0xE9, 0xAB, 0x72, 0x24, 0x30, 0x49, 0xFE, 0xB8, 0xDE, 0xEC, 0xC1, 0x46, 0xB9, 0xB1, 0x18, 0x8D, 0xA8, 0x0E, 0xB0, 0x30, 0x90, 0xF6, 0x7C, 0xBF, /* x */ 0x20, 0xEB, 0x43, 0xA1, 0x88, 0x00, 0xF4, 0xFF, 0x0A, 0xFD, 0x82, 0xFF, 0x10, 0x12, 0x07, 0x19, 0x2b, 0x95, 0xff, 0xc8, 0xda, 0x78, 0x63, 0x10, /* y */ 0x11, 0xed, 0x6b, 0x24, 0xcd, 0xd5, 0x73, 0xf9, 0x77, 0xa1, 0x1e, 0x79, 0x48, 0x11, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFF, 0x99, 0xDE, 0xF8, 0x36, 0x14, 0x6B, 0xC9, 0xB1, 0xB4, 0xD2, 0x28, 0x31 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 28 * 6]; } _EC_NIST_PRIME_224 = { { NID_X9_62_prime_field, 20, 28, 1 }, { 0xBD, 0x71, 0x34, 0x47, 0x99, 0xD5, 0xC7, 0xFC, 0xDC, 0x45, /* seed */ 0xB5, 0x9F, 0xA3, 0xB9, 0xAB, 0x8F, 0x6A, 0x94, 0x8B, 0xC5, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* a */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xB4, 0x05, 0x0A, 0x85, 0x0C, 0x04, 0xB3, 0xAB, 0xF5, 0x41, /* b */ 0x32, 0x56, 0x50, 0x44, 0xB0, 0xB7, 0xD7, 0xBF, 0xD8, 0xBA, 0x27, 0x0B, 0x39, 0x43, 0x23, 0x55, 0xFF, 0xB4, 0xB7, 0x0E, 0x0C, 0xBD, 0x6B, 0xB4, 0xBF, 0x7F, 0x32, 0x13, /* x */ 0x90, 0xB9, 0x4A, 0x03, 0xC1, 0xD3, 0x56, 0xC2, 0x11, 0x22, 0x34, 0x32, 0x80, 0xD6, 0x11, 0x5C, 0x1D, 0x21, 0xbd, 0x37, 0x63, 0x88, 0xb5, 0xf7, 0x23, 0xfb, 0x4c, 0x22, /* y */ 0xdf, 0xe6, 0xcd, 0x43, 0x75, 0xa0, 0x5a, 0x07, 0x47, 0x64, 0x44, 0xd5, 0x81, 0x99, 0x85, 0x00, 0x7e, 0x34, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFF, 0xFF, 0xFF, 0x16, 0xA2, 0xE0, 0xB8, 0xF0, 0x3E, 0x13, 0xDD, 0x29, 0x45, 0x5C, 0x5C, 0x2A, 0x3D } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 48 * 6]; } _EC_NIST_PRIME_384 = { { NID_X9_62_prime_field, 20, 48, 1 }, { 0xA3, 0x35, 0x92, 0x6A, 0xA3, 0x19, 0xA2, 0x7A, 0x1D, 0x00, /* seed */ 0x89, 0x6A, 0x67, 0x73, 0xA4, 0x82, 0x7A, 0xCD, 0xAC, 0x73, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* a */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFC, 0xB3, 0x31, 0x2F, 0xA7, 0xE2, 0x3E, 0xE7, 0xE4, 0x98, 0x8E, /* b */ 0x05, 0x6B, 0xE3, 0xF8, 0x2D, 0x19, 0x18, 0x1D, 0x9C, 0x6E, 0xFE, 0x81, 0x41, 0x12, 0x03, 0x14, 0x08, 0x8F, 0x50, 0x13, 0x87, 0x5A, 0xC6, 0x56, 0x39, 0x8D, 0x8A, 0x2E, 0xD1, 0x9D, 0x2A, 0x85, 0xC8, 0xED, 0xD3, 0xEC, 0x2A, 0xEF, 0xAA, 0x87, 0xCA, 0x22, 0xBE, 0x8B, 0x05, 0x37, 0x8E, 0xB1, /* x */ 0xC7, 0x1E, 0xF3, 0x20, 0xAD, 0x74, 0x6E, 0x1D, 0x3B, 0x62, 0x8B, 0xA7, 0x9B, 0x98, 0x59, 0xF7, 0x41, 0xE0, 0x82, 0x54, 0x2A, 0x38, 0x55, 0x02, 0xF2, 0x5D, 0xBF, 0x55, 0x29, 0x6C, 0x3A, 0x54, 0x5E, 0x38, 0x72, 0x76, 0x0A, 0xB7, 0x36, 0x17, 0xde, 0x4a, 0x96, 0x26, 0x2c, 0x6f, 0x5d, 0x9e, /* y */ 0x98, 0xbf, 0x92, 0x92, 0xdc, 0x29, 0xf8, 0xf4, 0x1d, 0xbd, 0x28, 0x9a, 0x14, 0x7c, 0xe9, 0xda, 0x31, 0x13, 0xb5, 0xf0, 0xb8, 0xc0, 0x0a, 0x60, 0xb1, 0xce, 0x1d, 0x7e, 0x81, 0x9d, 0x7a, 0x43, 0x1d, 0x7c, 0x90, 0xea, 0x0e, 0x5f, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC7, 0x63, 0x4D, 0x81, 0xF4, 0x37, 0x2D, 0xDF, 0x58, 0x1A, 0x0D, 0xB2, 0x48, 0xB0, 0xA7, 0x7A, 0xEC, 0xEC, 0x19, 0x6A, 0xCC, 0xC5, 0x29, 0x73 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 66 * 6]; } _EC_NIST_PRIME_521 = { { NID_X9_62_prime_field, 20, 66, 1 }, { 0xD0, 0x9E, 0x88, 0x00, 0x29, 0x1C, 0xB8, 0x53, 0x96, 0xCC, /* seed */ 0x67, 0x17, 0x39, 0x32, 0x84, 0xAA, 0xA0, 0xDA, 0x64, 0xBA, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* a */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0x51, 0x95, 0x3E, 0xB9, 0x61, 0x8E, 0x1C, 0x9A, 0x1F, /* b */ 0x92, 0x9A, 0x21, 0xA0, 0xB6, 0x85, 0x40, 0xEE, 0xA2, 0xDA, 0x72, 0x5B, 0x99, 0xB3, 0x15, 0xF3, 0xB8, 0xB4, 0x89, 0x91, 0x8E, 0xF1, 0x09, 0xE1, 0x56, 0x19, 0x39, 0x51, 0xEC, 0x7E, 0x93, 0x7B, 0x16, 0x52, 0xC0, 0xBD, 0x3B, 0xB1, 0xBF, 0x07, 0x35, 0x73, 0xDF, 0x88, 0x3D, 0x2C, 0x34, 0xF1, 0xEF, 0x45, 0x1F, 0xD4, 0x6B, 0x50, 0x3F, 0x00, 0x00, 0xC6, 0x85, 0x8E, 0x06, 0xB7, 0x04, 0x04, 0xE9, 0xCD, /* x */ 0x9E, 0x3E, 0xCB, 0x66, 0x23, 0x95, 0xB4, 0x42, 0x9C, 0x64, 0x81, 0x39, 0x05, 0x3F, 0xB5, 0x21, 0xF8, 0x28, 0xAF, 0x60, 0x6B, 0x4D, 0x3D, 0xBA, 0xA1, 0x4B, 0x5E, 0x77, 0xEF, 0xE7, 0x59, 0x28, 0xFE, 0x1D, 0xC1, 0x27, 0xA2, 0xFF, 0xA8, 0xDE, 0x33, 0x48, 0xB3, 0xC1, 0x85, 0x6A, 0x42, 0x9B, 0xF9, 0x7E, 0x7E, 0x31, 0xC2, 0xE5, 0xBD, 0x66, 0x01, 0x18, 0x39, 0x29, 0x6a, 0x78, 0x9a, 0x3b, 0xc0, 0x04, /* y */ 0x5c, 0x8a, 0x5f, 0xb4, 0x2c, 0x7d, 0x1b, 0xd9, 0x98, 0xf5, 0x44, 0x49, 0x57, 0x9b, 0x44, 0x68, 0x17, 0xaf, 0xbd, 0x17, 0x27, 0x3e, 0x66, 0x2c, 0x97, 0xee, 0x72, 0x99, 0x5e, 0xf4, 0x26, 0x40, 0xc5, 0x50, 0xb9, 0x01, 0x3f, 0xad, 0x07, 0x61, 0x35, 0x3c, 0x70, 0x86, 0xa2, 0x72, 0xc2, 0x40, 0x88, 0xbe, 0x94, 0x76, 0x9f, 0xd1, 0x66, 0x50, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0x51, 0x86, 0x87, 0x83, 0xBF, 0x2F, 0x96, 0x6B, 0x7F, 0xCC, 0x01, 0x48, 0xF7, 0x09, 0xA5, 0xD0, 0x3B, 0xB5, 0xC9, 0xB8, 0x89, 0x9C, 0x47, 0xAE, 0xBB, 0x6F, 0xB7, 0x1E, 0x91, 0x38, 0x64, 0x09 } }; /* the x9.62 prime curves (minus the nist prime curves) */ static const struct { EC_CURVE_DATA h; unsigned char data[20 + 24 * 6]; } _EC_X9_62_PRIME_192V2 = { { NID_X9_62_prime_field, 20, 24, 1 }, { 0x31, 0xA9, 0x2E, 0xE2, 0x02, 0x9F, 0xD1, 0x0D, 0x90, 0x1B, /* seed */ 0x11, 0x3E, 0x99, 0x07, 0x10, 0xF0, 0xD2, 0x1A, 0xC6, 0xB6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* a */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xCC, 0x22, 0xD6, 0xDF, 0xB9, 0x5C, 0x6B, 0x25, 0xE4, 0x9C, /* b */ 0x0D, 0x63, 0x64, 0xA4, 0xE5, 0x98, 0x0C, 0x39, 0x3A, 0xA2, 0x16, 0x68, 0xD9, 0x53, 0xEE, 0xA2, 0xBA, 0xE7, 0xE1, 0x49, 0x78, 0x42, 0xF2, 0xDE, /* x */ 0x77, 0x69, 0xCF, 0xE9, 0xC9, 0x89, 0xC0, 0x72, 0xAD, 0x69, 0x6F, 0x48, 0x03, 0x4A, 0x65, 0x74, 0xd1, 0x1d, 0x69, 0xb6, 0xec, 0x7a, 0x67, 0x2b, /* y */ 0xb8, 0x2a, 0x08, 0x3d, 0xf2, 0xf2, 0xb0, 0x84, 0x7d, 0xe9, 0x70, 0xb2, 0xde, 0x15, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFE, 0x5F, 0xB1, 0xA7, 0x24, 0xDC, 0x80, 0x41, 0x86, 0x48, 0xD8, 0xDD, 0x31 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 24 * 6]; } _EC_X9_62_PRIME_192V3 = { { NID_X9_62_prime_field, 20, 24, 1 }, { 0xC4, 0x69, 0x68, 0x44, 0x35, 0xDE, 0xB3, 0x78, 0xC4, 0xB6, /* seed */ 0x5C, 0xA9, 0x59, 0x1E, 0x2A, 0x57, 0x63, 0x05, 0x9A, 0x2E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* a */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x22, 0x12, 0x3D, 0xC2, 0x39, 0x5A, 0x05, 0xCA, 0xA7, 0x42, /* b */ 0x3D, 0xAE, 0xCC, 0xC9, 0x47, 0x60, 0xA7, 0xD4, 0x62, 0x25, 0x6B, 0xD5, 0x69, 0x16, 0x7D, 0x29, 0x77, 0x81, 0x00, 0xC6, 0x5A, 0x1D, 0xA1, 0x78, /* x */ 0x37, 0x16, 0x58, 0x8D, 0xCE, 0x2B, 0x8B, 0x4A, 0xEE, 0x8E, 0x22, 0x8F, 0x18, 0x96, 0x38, 0xa9, 0x0f, 0x22, 0x63, 0x73, 0x37, 0x33, 0x4b, 0x49, /* y */ 0xdc, 0xb6, 0x6a, 0x6d, 0xc8, 0xf9, 0x97, 0x8a, 0xca, 0x76, 0x48, 0xa9, 0x43, 0xb0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFF, 0x7A, 0x62, 0xD0, 0x31, 0xC8, 0x3F, 0x42, 0x94, 0xF6, 0x40, 0xEC, 0x13 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 30 * 6]; } _EC_X9_62_PRIME_239V1 = { { NID_X9_62_prime_field, 20, 30, 1 }, { 0xE4, 0x3B, 0xB4, 0x60, 0xF0, 0xB8, 0x0C, 0xC0, 0xC0, 0xB0, /* seed */ 0x75, 0x79, 0x8E, 0x94, 0x80, 0x60, 0xF8, 0x32, 0x1B, 0x7D, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* a */ 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x6B, 0x01, 0x6C, 0x3B, 0xDC, 0xF1, 0x89, 0x41, 0xD0, 0xD6, /* b */ 0x54, 0x92, 0x14, 0x75, 0xCA, 0x71, 0xA9, 0xDB, 0x2F, 0xB2, 0x7D, 0x1D, 0x37, 0x79, 0x61, 0x85, 0xC2, 0x94, 0x2C, 0x0A, 0x0F, 0xFA, 0x96, 0x3C, 0xDC, 0xA8, 0x81, 0x6C, 0xCC, 0x33, /* x */ 0xB8, 0x64, 0x2B, 0xED, 0xF9, 0x05, 0xC3, 0xD3, 0x58, 0x57, 0x3D, 0x3F, 0x27, 0xFB, 0xBD, 0x3B, 0x3C, 0xB9, 0xAA, 0xAF, 0x7d, 0xeb, 0xe8, 0xe4, 0xe9, 0x0a, 0x5d, 0xae, 0x6e, 0x40, /* y */ 0x54, 0xca, 0x53, 0x0b, 0xa0, 0x46, 0x54, 0xb3, 0x68, 0x18, 0xce, 0x22, 0x6b, 0x39, 0xfc, 0xcb, 0x7b, 0x02, 0xf1, 0xae, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0x9E, 0x5E, 0x9A, 0x9F, 0x5D, 0x90, 0x71, 0xFB, 0xD1, 0x52, 0x26, 0x88, 0x90, 0x9D, 0x0B } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 30 * 6]; } _EC_X9_62_PRIME_239V2 = { { NID_X9_62_prime_field, 20, 30, 1 }, { 0xE8, 0xB4, 0x01, 0x16, 0x04, 0x09, 0x53, 0x03, 0xCA, 0x3B, /* seed */ 0x80, 0x99, 0x98, 0x2B, 0xE0, 0x9F, 0xCB, 0x9A, 0xE6, 0x16, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* a */ 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x61, 0x7F, 0xAB, 0x68, 0x32, 0x57, 0x6C, 0xBB, 0xFE, 0xD5, /* b */ 0x0D, 0x99, 0xF0, 0x24, 0x9C, 0x3F, 0xEE, 0x58, 0xB9, 0x4B, 0xA0, 0x03, 0x8C, 0x7A, 0xE8, 0x4C, 0x8C, 0x83, 0x2F, 0x2C, 0x38, 0xAF, 0x09, 0xD9, 0x87, 0x27, 0x70, 0x51, 0x20, 0xC9, /* x */ 0x21, 0xBB, 0x5E, 0x9E, 0x26, 0x29, 0x6A, 0x3C, 0xDC, 0xF2, 0xF3, 0x57, 0x57, 0xA0, 0xEA, 0xFD, 0x87, 0xB8, 0x30, 0xE7, 0x5b, 0x01, 0x25, 0xe4, 0xdb, 0xea, 0x0e, 0xc7, 0x20, 0x6d, /* y */ 0xa0, 0xfc, 0x01, 0xd9, 0xb0, 0x81, 0x32, 0x9f, 0xb5, 0x55, 0xde, 0x6e, 0xf4, 0x60, 0x23, 0x7d, 0xff, 0x8b, 0xe4, 0xba, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFF, 0x80, 0x00, 0x00, 0xCF, 0xA7, 0xE8, 0x59, 0x43, 0x77, 0xD4, 0x14, 0xC0, 0x38, 0x21, 0xBC, 0x58, 0x20, 0x63 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 30 * 6]; } _EC_X9_62_PRIME_239V3 = { { NID_X9_62_prime_field, 20, 30, 1 }, { 0x7D, 0x73, 0x74, 0x16, 0x8F, 0xFE, 0x34, 0x71, 0xB6, 0x0A, /* seed */ 0x85, 0x76, 0x86, 0xA1, 0x94, 0x75, 0xD3, 0xBF, 0xA2, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* a */ 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x25, 0x57, 0x05, 0xFA, 0x2A, 0x30, 0x66, 0x54, 0xB1, 0xF4, /* b */ 0xCB, 0x03, 0xD6, 0xA7, 0x50, 0xA3, 0x0C, 0x25, 0x01, 0x02, 0xD4, 0x98, 0x87, 0x17, 0xD9, 0xBA, 0x15, 0xAB, 0x6D, 0x3E, 0x67, 0x68, 0xAE, 0x8E, 0x18, 0xBB, 0x92, 0xCF, 0xCF, 0x00, /* x */ 0x5C, 0x94, 0x9A, 0xA2, 0xC6, 0xD9, 0x48, 0x53, 0xD0, 0xE6, 0x60, 0xBB, 0xF8, 0x54, 0xB1, 0xC9, 0x50, 0x5F, 0xE9, 0x5A, 0x16, 0x07, 0xe6, 0x89, 0x8f, 0x39, 0x0c, 0x06, 0xbc, 0x1d, /* y */ 0x55, 0x2b, 0xad, 0x22, 0x6f, 0x3b, 0x6f, 0xcf, 0xe4, 0x8b, 0x6e, 0x81, 0x84, 0x99, 0xaf, 0x18, 0xe3, 0xed, 0x6c, 0xf3, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0x97, 0x5D, 0xEB, 0x41, 0xB3, 0xA6, 0x05, 0x7C, 0x3C, 0x43, 0x21, 0x46, 0x52, 0x65, 0x51 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 32 * 6]; } _EC_X9_62_PRIME_256V1 = { { NID_X9_62_prime_field, 20, 32, 1 }, { 0xC4, 0x9D, 0x36, 0x08, 0x86, 0xE7, 0x04, 0x93, 0x6A, 0x66, /* seed */ 0x78, 0xE1, 0x13, 0x9D, 0x26, 0xB7, 0x81, 0x9F, 0x7E, 0x90, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x5A, 0xC6, 0x35, 0xD8, 0xAA, 0x3A, 0x93, 0xE7, 0xB3, 0xEB, /* b */ 0xBD, 0x55, 0x76, 0x98, 0x86, 0xBC, 0x65, 0x1D, 0x06, 0xB0, 0xCC, 0x53, 0xB0, 0xF6, 0x3B, 0xCE, 0x3C, 0x3E, 0x27, 0xD2, 0x60, 0x4B, 0x6B, 0x17, 0xD1, 0xF2, 0xE1, 0x2C, 0x42, 0x47, 0xF8, 0xBC, /* x */ 0xE6, 0xE5, 0x63, 0xA4, 0x40, 0xF2, 0x77, 0x03, 0x7D, 0x81, 0x2D, 0xEB, 0x33, 0xA0, 0xF4, 0xA1, 0x39, 0x45, 0xD8, 0x98, 0xC2, 0x96, 0x4f, 0xe3, 0x42, 0xe2, 0xfe, 0x1a, 0x7f, 0x9b, 0x8e, 0xe7, /* y */ 0xeb, 0x4a, 0x7c, 0x0f, 0x9e, 0x16, 0x2b, 0xce, 0x33, 0x57, 0x6b, 0x31, 0x5e, 0xce, 0xcb, 0xb6, 0x40, 0x68, 0x37, 0xbf, 0x51, 0xf5, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, /* order */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17, 0x9E, 0x84, 0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51 } }; /* the secg prime curves (minus the nist and x9.62 prime curves) */ static const struct { EC_CURVE_DATA h; unsigned char data[20 + 14 * 6]; } _EC_SECG_PRIME_112R1 = { { NID_X9_62_prime_field, 20, 14, 1 }, { 0x00, 0xF5, 0x0B, 0x02, 0x8E, 0x4D, 0x69, 0x6E, 0x67, 0x68, /* seed */ 0x75, 0x61, 0x51, 0x75, 0x29, 0x04, 0x72, 0x78, 0x3F, 0xB1, 0xDB, 0x7C, 0x2A, 0xBF, 0x62, 0xE3, 0x5E, 0x66, 0x80, 0x76, /* p */ 0xBE, 0xAD, 0x20, 0x8B, 0xDB, 0x7C, 0x2A, 0xBF, 0x62, 0xE3, 0x5E, 0x66, 0x80, 0x76, /* a */ 0xBE, 0xAD, 0x20, 0x88, 0x65, 0x9E, 0xF8, 0xBA, 0x04, 0x39, 0x16, 0xEE, 0xDE, 0x89, /* b */ 0x11, 0x70, 0x2B, 0x22, 0x09, 0x48, 0x72, 0x39, 0x99, 0x5A, 0x5E, 0xE7, 0x6B, 0x55, /* x */ 0xF9, 0xC2, 0xF0, 0x98, 0xa8, 0x9c, 0xe5, 0xaf, 0x87, 0x24, 0xc0, 0xa2, 0x3e, 0x0e, /* y */ 0x0f, 0xf7, 0x75, 0x00, 0xDB, 0x7C, 0x2A, 0xBF, 0x62, 0xE3, 0x5E, 0x76, 0x28, 0xDF, /* order */ 0xAC, 0x65, 0x61, 0xC5 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 14 * 6]; } _EC_SECG_PRIME_112R2 = { { NID_X9_62_prime_field, 20, 14, 4 }, { 0x00, 0x27, 0x57, 0xA1, 0x11, 0x4D, 0x69, 0x6E, 0x67, 0x68, /* seed */ 0x75, 0x61, 0x51, 0x75, 0x53, 0x16, 0xC0, 0x5E, 0x0B, 0xD4, 0xDB, 0x7C, 0x2A, 0xBF, 0x62, 0xE3, 0x5E, 0x66, 0x80, 0x76, /* p */ 0xBE, 0xAD, 0x20, 0x8B, 0x61, 0x27, 0xC2, 0x4C, 0x05, 0xF3, 0x8A, 0x0A, 0xAA, 0xF6, /* a */ 0x5C, 0x0E, 0xF0, 0x2C, 0x51, 0xDE, 0xF1, 0x81, 0x5D, 0xB5, 0xED, 0x74, 0xFC, 0xC3, /* b */ 0x4C, 0x85, 0xD7, 0x09, 0x4B, 0xA3, 0x0A, 0xB5, 0xE8, 0x92, 0xB4, 0xE1, 0x64, 0x9D, /* x */ 0xD0, 0x92, 0x86, 0x43, 0xad, 0xcd, 0x46, 0xf5, 0x88, 0x2e, 0x37, 0x47, 0xde, 0xf3, /* y */ 0x6e, 0x95, 0x6e, 0x97, 0x36, 0xDF, 0x0A, 0xAF, 0xD8, 0xB8, 0xD7, 0x59, 0x7C, 0xA1, /* order */ 0x05, 0x20, 0xD0, 0x4B } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 16 * 6]; } _EC_SECG_PRIME_128R1 = { { NID_X9_62_prime_field, 20, 16, 1 }, { 0x00, 0x0E, 0x0D, 0x4D, 0x69, 0x6E, 0x67, 0x68, 0x75, 0x61, /* seed */ 0x51, 0x75, 0x0C, 0xC0, 0x3A, 0x44, 0x73, 0xD0, 0x36, 0x79, 0xFF, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* a */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xE8, 0x75, 0x79, 0xC1, 0x10, 0x79, 0xF4, 0x3D, 0xD8, 0x24, /* b */ 0x99, 0x3C, 0x2C, 0xEE, 0x5E, 0xD3, 0x16, 0x1F, 0xF7, 0x52, 0x8B, 0x89, 0x9B, 0x2D, 0x0C, 0x28, /* x */ 0x60, 0x7C, 0xA5, 0x2C, 0x5B, 0x86, 0xcf, 0x5a, 0xc8, 0x39, 0x5b, 0xaf, 0xeb, 0x13, 0xc0, 0x2d, /* y */ 0xa2, 0x92, 0xdd, 0xed, 0x7a, 0x83, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x75, 0xA3, /* order */ 0x0D, 0x1B, 0x90, 0x38, 0xA1, 0x15 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 16 * 6]; } _EC_SECG_PRIME_128R2 = { { NID_X9_62_prime_field, 20, 16, 4 }, { 0x00, 0x4D, 0x69, 0x6E, 0x67, 0x68, 0x75, 0x61, 0x51, 0x75, /* seed */ 0x12, 0xD8, 0xF0, 0x34, 0x31, 0xFC, 0xE6, 0x3B, 0x88, 0xF4, 0xFF, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD6, 0x03, 0x19, 0x98, 0xD1, 0xB3, 0xBB, 0xFE, 0xBF, 0x59, /* a */ 0xCC, 0x9B, 0xBF, 0xF9, 0xAE, 0xE1, 0x5E, 0xEE, 0xFC, 0xA3, 0x80, 0xD0, 0x29, 0x19, 0xDC, 0x2C, /* b */ 0x65, 0x58, 0xBB, 0x6D, 0x8A, 0x5D, 0x7B, 0x6A, 0xA5, 0xD8, 0x5E, 0x57, 0x29, 0x83, 0xE6, 0xFB, /* x */ 0x32, 0xA7, 0xCD, 0xEB, 0xC1, 0x40, 0x27, 0xb6, 0x91, 0x6a, 0x89, 0x4d, 0x3a, 0xee, 0x71, 0x06, /* y */ 0xfe, 0x80, 0x5f, 0xc3, 0x4b, 0x44, 0x3F, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xBE, 0x00, /* order */ 0x24, 0x72, 0x06, 0x13, 0xB5, 0xA3 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 21 * 6]; } _EC_SECG_PRIME_160K1 = { { NID_X9_62_prime_field, 0, 21, 1 }, { /* no seed */ 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xAC, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x3B, 0x4C, 0x38, 0x2C, 0xE3, 0x7A, 0xA1, 0x92, 0xA4, /* x */ 0x01, 0x9E, 0x76, 0x30, 0x36, 0xF4, 0xF5, 0xDD, 0x4D, 0x7E, 0xBB, 0x00, 0x93, 0x8c, 0xf9, 0x35, 0x31, 0x8f, 0xdc, 0xed, 0x6b, /* y */ 0xc2, 0x82, 0x86, 0x53, 0x17, 0x33, 0xc3, 0xf0, 0x3c, 0x4f, 0xee, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x01, 0xB8, 0xFA, 0x16, 0xDF, 0xAB, 0x9A, 0xCA, 0x16, 0xB6, 0xB3 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 21 * 6]; } _EC_SECG_PRIME_160R1 = { { NID_X9_62_prime_field, 20, 21, 1 }, { 0x10, 0x53, 0xCD, 0xE4, 0x2C, 0x14, 0xD6, 0x96, 0xE6, 0x76, /* seed */ 0x87, 0x56, 0x15, 0x17, 0x53, 0x3B, 0xF3, 0xF8, 0x33, 0x45, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* a */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFC, 0x00, 0x1C, 0x97, 0xBE, 0xFC, 0x54, 0xBD, 0x7A, 0x8B, 0x65, /* b */ 0xAC, 0xF8, 0x9F, 0x81, 0xD4, 0xD4, 0xAD, 0xC5, 0x65, 0xFA, 0x45, 0x00, 0x4A, 0x96, 0xB5, 0x68, 0x8E, 0xF5, 0x73, 0x28, 0x46, /* x */ 0x64, 0x69, 0x89, 0x68, 0xC3, 0x8B, 0xB9, 0x13, 0xCB, 0xFC, 0x82, 0x00, 0x23, 0xa6, 0x28, 0x55, 0x31, 0x68, 0x94, 0x7d, 0x59, /* y */ 0xdc, 0xc9, 0x12, 0x04, 0x23, 0x51, 0x37, 0x7a, 0xc5, 0xfb, 0x32, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x01, 0xF4, 0xC8, 0xF9, 0x27, 0xAE, 0xD3, 0xCA, 0x75, 0x22, 0x57 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 21 * 6]; } _EC_SECG_PRIME_160R2 = { { NID_X9_62_prime_field, 20, 21, 1 }, { 0xB9, 0x9B, 0x99, 0xB0, 0x99, 0xB3, 0x23, 0xE0, 0x27, 0x09, /* seed */ 0xA4, 0xD6, 0x96, 0xE6, 0x76, 0x87, 0x56, 0x15, 0x17, 0x51, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xAC, 0x73, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* a */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xAC, 0x70, 0x00, 0xB4, 0xE1, 0x34, 0xD3, 0xFB, 0x59, 0xEB, 0x8B, 0xAB, /* b */ 0x57, 0x27, 0x49, 0x04, 0x66, 0x4D, 0x5A, 0xF5, 0x03, 0x88, 0xBA, 0x00, 0x52, 0xDC, 0xB0, 0x34, 0x29, 0x3A, 0x11, 0x7E, 0x1F, /* x */ 0x4F, 0xF1, 0x1B, 0x30, 0xF7, 0x19, 0x9D, 0x31, 0x44, 0xCE, 0x6D, 0x00, 0xfe, 0xaf, 0xfe, 0xf2, 0xe3, 0x31, 0xf2, 0x96, 0xe0, /* y */ 0x71, 0xfa, 0x0d, 0xf9, 0x98, 0x2c, 0xfe, 0xa7, 0xd4, 0x3f, 0x2e, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x00, 0x35, 0x1E, 0xE7, 0x86, 0xA8, 0x18, 0xF3, 0xA1, 0xA1, 0x6B } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 24 * 6]; } _EC_SECG_PRIME_192K1 = { { NID_X9_62_prime_field, 0, 24, 1 }, { /* no seed */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xEE, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xDB, 0x4F, 0xF1, 0x0E, 0xC0, 0x57, 0xE9, 0xAE, 0x26, 0xB0, /* x */ 0x7D, 0x02, 0x80, 0xB7, 0xF4, 0x34, 0x1D, 0xA5, 0xD1, 0xB1, 0xEA, 0xE0, 0x6C, 0x7D, 0x9b, 0x2f, 0x2f, 0x6d, 0x9c, 0x56, 0x28, 0xa7, 0x84, 0x41, /* y */ 0x63, 0xd0, 0x15, 0xbe, 0x86, 0x34, 0x40, 0x82, 0xaa, 0x88, 0xd9, 0x5e, 0x2f, 0x9d, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFE, 0x26, 0xF2, 0xFC, 0x17, 0x0F, 0x69, 0x46, 0x6A, 0x74, 0xDE, 0xFD, 0x8D } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 29 * 6]; } _EC_SECG_PRIME_224K1 = { { NID_X9_62_prime_field, 0, 29, 1 }, { /* no seed */ 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xE5, 0x6D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0xA1, 0x45, 0x5B, 0x33, 0x4D, 0xF0, 0x99, 0xDF, 0x30, /* x */ 0xFC, 0x28, 0xA1, 0x69, 0xA4, 0x67, 0xE9, 0xE4, 0x70, 0x75, 0xA9, 0x0F, 0x7E, 0x65, 0x0E, 0xB6, 0xB7, 0xA4, 0x5C, 0x00, 0x7e, 0x08, 0x9f, 0xed, 0x7f, 0xba, 0x34, 0x42, 0x82, /* y */ 0xca, 0xfb, 0xd6, 0xf7, 0xe3, 0x19, 0xf7, 0xc0, 0xb0, 0xbd, 0x59, 0xe2, 0xca, 0x4b, 0xdb, 0x55, 0x6d, 0x61, 0xa5, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x00, 0x00, 0x00, 0x00, 0x01, 0xDC, 0xE8, 0xD2, 0xEC, 0x61, 0x84, 0xCA, 0xF0, 0xA9, 0x71, 0x76, 0x9F, 0xB1, 0xF7 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 32 * 6]; } _EC_SECG_PRIME_256K1 = { { NID_X9_62_prime_field, 0, 32, 1 }, { /* no seed */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFC, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x79, 0xBE, 0x66, 0x7E, 0xF9, 0xDC, 0xBB, 0xAC, 0x55, 0xA0, /* x */ 0x62, 0x95, 0xCE, 0x87, 0x0B, 0x07, 0x02, 0x9B, 0xFC, 0xDB, 0x2D, 0xCE, 0x28, 0xD9, 0x59, 0xF2, 0x81, 0x5B, 0x16, 0xF8, 0x17, 0x98, 0x48, 0x3a, 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65, 0x5d, 0xa4, /* y */ 0xfb, 0xfc, 0x0e, 0x11, 0x08, 0xa8, 0xfd, 0x17, 0xb4, 0x48, 0xa6, 0x85, 0x54, 0x19, 0x9c, 0x47, 0xd0, 0x8f, 0xfb, 0x10, 0xd4, 0xb8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xBA, 0xAE, 0xDC, 0xE6, 0xAF, 0x48, 0xA0, 0x3B, 0xBF, 0xD2, 0x5E, 0x8C, 0xD0, 0x36, 0x41, 0x41 } }; /* some wap/wtls curves */ static const struct { EC_CURVE_DATA h; unsigned char data[0 + 15 * 6]; } _EC_WTLS_8 = { { NID_X9_62_prime_field, 0, 15, 1 }, { /* no seed */ 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFD, 0xE7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* x */ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* y */ 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEC, 0xEA, /* order */ 0x55, 0x1A, 0xD8, 0x37, 0xE9 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 21 * 6]; } _EC_WTLS_9 = { { NID_X9_62_prime_field, 0, 21, 1 }, { /* no seed */ 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x80, 0x8F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* x */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* y */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x01, 0xCD, 0xC9, 0x8A, 0xE0, 0xE2, 0xDE, 0x57, 0x4A, 0xBF, 0x33 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 28 * 6]; } _EC_WTLS_12 = { { NID_X9_62_prime_field, 0, 28, 1 }, { /* no seed */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* p */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* a */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xB4, 0x05, 0x0A, 0x85, 0x0C, 0x04, 0xB3, 0xAB, 0xF5, 0x41, /* b */ 0x32, 0x56, 0x50, 0x44, 0xB0, 0xB7, 0xD7, 0xBF, 0xD8, 0xBA, 0x27, 0x0B, 0x39, 0x43, 0x23, 0x55, 0xFF, 0xB4, 0xB7, 0x0E, 0x0C, 0xBD, 0x6B, 0xB4, 0xBF, 0x7F, 0x32, 0x13, /* x */ 0x90, 0xB9, 0x4A, 0x03, 0xC1, 0xD3, 0x56, 0xC2, 0x11, 0x22, 0x34, 0x32, 0x80, 0xD6, 0x11, 0x5C, 0x1D, 0x21, 0xbd, 0x37, 0x63, 0x88, 0xb5, 0xf7, 0x23, 0xfb, 0x4c, 0x22, /* y */ 0xdf, 0xe6, 0xcd, 0x43, 0x75, 0xa0, 0x5a, 0x07, 0x47, 0x64, 0x44, 0xd5, 0x81, 0x99, 0x85, 0x00, 0x7e, 0x34, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFF, 0xFF, 0xFF, 0x16, 0xA2, 0xE0, 0xB8, 0xF0, 0x3E, 0x13, 0xDD, 0x29, 0x45, 0x5C, 0x5C, 0x2A, 0x3D } }; #ifndef OPENSSL_NO_EC2M /* characteristic two curves */ static const struct { EC_CURVE_DATA h; unsigned char data[20 + 15 * 6]; } _EC_SECG_CHAR2_113R1 = { { NID_X9_62_characteristic_two_field, 20, 15, 2 }, { 0x10, 0xE7, 0x23, 0xAB, 0x14, 0xD6, 0x96, 0xE6, 0x76, 0x87, /* seed */ 0x56, 0x15, 0x17, 0x56, 0xFE, 0xBF, 0x8F, 0xCB, 0x49, 0xA9, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x30, 0x88, 0x25, 0x0C, 0xA6, 0xE7, 0xC7, 0xFE, 0x64, /* a */ 0x9C, 0xE8, 0x58, 0x20, 0xF7, 0x00, 0xE8, 0xBE, 0xE4, 0xD3, 0xE2, 0x26, 0x07, 0x44, 0x18, /* b */ 0x8B, 0xE0, 0xE9, 0xC7, 0x23, 0x00, 0x9D, 0x73, 0x61, 0x6F, 0x35, 0xF4, 0xAB, 0x14, 0x07, /* x */ 0xD7, 0x35, 0x62, 0xC1, 0x0F, 0x00, 0xA5, 0x28, 0x30, 0x27, 0x79, 0x58, 0xEE, 0x84, 0xD1, /* y */ 0x31, 0x5E, 0xD3, 0x18, 0x86, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD9, 0xCC, /* order */ 0xEC, 0x8A, 0x39, 0xE5, 0x6F } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 15 * 6]; } _EC_SECG_CHAR2_113R2 = { { NID_X9_62_characteristic_two_field, 20, 15, 2 }, { 0x10, 0xC0, 0xFB, 0x15, 0x76, 0x08, 0x60, 0xDE, 0xF1, 0xEE, /* seed */ 0xF4, 0xD6, 0x96, 0xE6, 0x76, 0x87, 0x56, 0x15, 0x17, 0x5D, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x68, 0x99, 0x18, 0xDB, 0xEC, 0x7E, 0x5A, 0x0D, 0xD6, /* a */ 0xDF, 0xC0, 0xAA, 0x55, 0xC7, 0x00, 0x95, 0xE9, 0xA9, 0xEC, 0x9B, 0x29, 0x7B, 0xD4, 0xBF, /* b */ 0x36, 0xE0, 0x59, 0x18, 0x4F, 0x01, 0xA5, 0x7A, 0x6A, 0x7B, 0x26, 0xCA, 0x5E, 0xF5, 0x2F, /* x */ 0xCD, 0xB8, 0x16, 0x47, 0x97, 0x00, 0xB3, 0xAD, 0xC9, 0x4E, 0xD1, 0xFE, 0x67, 0x4C, 0x06, /* y */ 0xE6, 0x95, 0xBA, 0xBA, 0x1D, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x78, /* order */ 0x9B, 0x24, 0x96, 0xAF, 0x93 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 17 * 6]; } _EC_SECG_CHAR2_131R1 = { { NID_X9_62_characteristic_two_field, 20, 17, 2 }, { 0x4D, 0x69, 0x6E, 0x67, 0x68, 0x75, 0x61, 0x51, 0x75, 0x98, /* seed */ 0x5B, 0xD3, 0xAD, 0xBA, 0xDA, 0x21, 0xB4, 0x3A, 0x97, 0xE2, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0D, 0x07, 0xA1, 0x1B, 0x09, 0xA7, 0x6B, 0x56, 0x21, 0x44, 0x41, /* a */ 0x8F, 0xF3, 0xFF, 0x8C, 0x25, 0x70, 0xB8, 0x02, 0x17, 0xC0, 0x56, 0x10, 0x88, 0x4B, 0x63, 0xB9, 0xC6, /* b */ 0xC7, 0x29, 0x16, 0x78, 0xF9, 0xD3, 0x41, 0x00, 0x81, 0xBA, 0xF9, 0x1F, 0xDF, 0x98, 0x33, 0xC4, 0x0F, /* x */ 0x9C, 0x18, 0x13, 0x43, 0x63, 0x83, 0x99, 0x07, 0x8C, 0x6E, 0x7E, 0xA3, 0x8C, 0x00, 0x1F, 0x73, 0xC8, /* y */ 0x13, 0x4B, 0x1B, 0x4E, 0xF9, 0xE1, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x31, /* order */ 0x23, 0x95, 0x3A, 0x94, 0x64, 0xB5, 0x4D } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 17 * 6]; } _EC_SECG_CHAR2_131R2 = { { NID_X9_62_characteristic_two_field, 20, 17, 2 }, { 0x98, 0x5B, 0xD3, 0xAD, 0xBA, 0xD4, 0xD6, 0x96, 0xE6, 0x76, /* seed */ 0x87, 0x56, 0x15, 0x17, 0x5A, 0x21, 0xB4, 0x3A, 0x97, 0xE3, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0D, 0x03, 0xE5, 0xA8, 0x89, 0x19, 0xD7, 0xCA, 0xFC, 0xBF, 0x41, /* a */ 0x5F, 0x07, 0xC2, 0x17, 0x65, 0x73, 0xB2, 0x04, 0xB8, 0x26, 0x6A, 0x46, 0xC5, 0x56, 0x57, 0xAC, 0x73, /* b */ 0x4C, 0xE3, 0x8F, 0x01, 0x8F, 0x21, 0x92, 0x03, 0x56, 0xDC, 0xD8, 0xF2, 0xF9, 0x50, 0x31, 0xAD, 0x65, /* x */ 0x2D, 0x23, 0x95, 0x1B, 0xB3, 0x66, 0xA8, 0x06, 0x48, 0xF0, 0x6D, 0x86, 0x79, 0x40, 0xA5, 0x36, 0x6D, /* y */ 0x9E, 0x26, 0x5D, 0xE9, 0xEB, 0x24, 0x0F, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x69, /* order */ 0x54, 0xA2, 0x33, 0x04, 0x9B, 0xA9, 0x8F } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 21 * 6]; } _EC_NIST_CHAR2_163K = { { NID_X9_62_characteristic_two_field, 0, 21, 2 }, { /* no seed */ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0xFE, 0x13, 0xC0, 0x53, 0x7B, 0xBC, 0x11, 0xAC, 0xAA, /* x */ 0x07, 0xD7, 0x93, 0xDE, 0x4E, 0x6D, 0x5E, 0x5C, 0x94, 0xEE, 0xE8, 0x02, 0x89, 0x07, 0x0F, 0xB0, 0x5D, 0x38, 0xFF, 0x58, 0x32, /* y */ 0x1F, 0x2E, 0x80, 0x05, 0x36, 0xD5, 0x38, 0xCC, 0xDA, 0xA3, 0xD9, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x02, 0x01, 0x08, 0xA2, 0xE0, 0xCC, 0x0D, 0x99, 0xF8, 0xA5, 0xEF } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 21 * 6]; } _EC_SECG_CHAR2_163R1 = { { NID_X9_62_characteristic_two_field, 0, 21, 2 }, { /* no seed */ #if 0 /* The algorithm used to derive the curve parameters from * the seed used here is slightly different than the * algorithm described in X9.62 . */ 0x24, 0xB7, 0xB1, 0x37, 0xC8, 0xA1, 0x4D, 0x69, 0x6E, 0x67, 0x68, 0x75, 0x61, 0x51, 0x75, 0x6F, 0xD0, 0xDA, 0x2E, 0x5C, #endif 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC9, 0x07, 0xB6, 0x88, 0x2C, 0xAA, 0xEF, 0xA8, 0x4F, 0x95, 0x54, /* a */ 0xFF, 0x84, 0x28, 0xBD, 0x88, 0xE2, 0x46, 0xD2, 0x78, 0x2A, 0xE2, 0x07, 0x13, 0x61, 0x2D, 0xCD, 0xDC, 0xB4, 0x0A, 0xAB, 0x94, /* b */ 0x6B, 0xDA, 0x29, 0xCA, 0x91, 0xF7, 0x3A, 0xF9, 0x58, 0xAF, 0xD9, 0x03, 0x69, 0x97, 0x96, 0x97, 0xAB, 0x43, 0x89, 0x77, 0x89, /* x */ 0x56, 0x67, 0x89, 0x56, 0x7F, 0x78, 0x7A, 0x78, 0x76, 0xA6, 0x54, 0x00, 0x43, 0x5E, 0xDB, 0x42, 0xEF, 0xAF, 0xB2, 0x98, 0x9D, /* y */ 0x51, 0xFE, 0xFC, 0xE3, 0xC8, 0x09, 0x88, 0xF4, 0x1F, 0xF8, 0x83, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0x48, 0xAA, 0xB6, 0x89, 0xC2, 0x9C, 0xA7, 0x10, 0x27, 0x9B } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 21 * 6]; } _EC_NIST_CHAR2_163B = { { NID_X9_62_characteristic_two_field, 0, 21, 2 }, { /* no seed */ #if 0 /* The seed here was used to created the curve parameters in normal * basis representation (and not the polynomial representation used here) */ 0x85, 0xE2, 0x5B, 0xFE, 0x5C, 0x86, 0x22, 0x6C, 0xDB, 0x12, 0x01, 0x6F, 0x75, 0x53, 0xF9, 0xD0, 0xE6, 0x93, 0xA2, 0x68, #endif 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x0A, 0x60, 0x19, 0x07, 0xB8, 0xC9, 0x53, 0xCA, 0x14, /* b */ 0x81, 0xEB, 0x10, 0x51, 0x2F, 0x78, 0x74, 0x4A, 0x32, 0x05, 0xFD, 0x03, 0xF0, 0xEB, 0xA1, 0x62, 0x86, 0xA2, 0xD5, 0x7E, 0xA0, /* x */ 0x99, 0x11, 0x68, 0xD4, 0x99, 0x46, 0x37, 0xE8, 0x34, 0x3E, 0x36, 0x00, 0xD5, 0x1F, 0xBC, 0x6C, 0x71, 0xA0, 0x09, 0x4F, 0xA2, /* y */ 0xCD, 0xD5, 0x45, 0xB1, 0x1C, 0x5C, 0x0C, 0x79, 0x73, 0x24, 0xF1, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x02, 0x92, 0xFE, 0x77, 0xE7, 0x0C, 0x12, 0xA4, 0x23, 0x4C, 0x33 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 25 * 6]; } _EC_SECG_CHAR2_193R1 = { { NID_X9_62_characteristic_two_field, 20, 25, 2 }, { 0x10, 0x3F, 0xAE, 0xC7, 0x4D, 0x69, 0x6E, 0x67, 0x68, 0x75, /* seed */ 0x61, 0x51, 0x75, 0x77, 0x7F, 0xC5, 0xB1, 0x91, 0xEF, 0x30, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x17, 0x85, 0x8F, 0xEB, 0x7A, 0x98, 0x97, 0x51, 0x69, /* a */ 0xE1, 0x71, 0xF7, 0x7B, 0x40, 0x87, 0xDE, 0x09, 0x8A, 0xC8, 0xA9, 0x11, 0xDF, 0x7B, 0x01, 0x00, 0xFD, 0xFB, 0x49, 0xBF, 0xE6, 0xC3, 0xA8, 0x9F, 0xAC, /* b */ 0xAD, 0xAA, 0x7A, 0x1E, 0x5B, 0xBC, 0x7C, 0xC1, 0xC2, 0xE5, 0xD8, 0x31, 0x47, 0x88, 0x14, 0x01, 0xF4, 0x81, 0xBC, 0x5F, 0x0F, 0xF8, 0x4A, 0x74, 0xAD, /* x */ 0x6C, 0xDF, 0x6F, 0xDE, 0xF4, 0xBF, 0x61, 0x79, 0x62, 0x53, 0x72, 0xD8, 0xC0, 0xC5, 0xE1, 0x00, 0x25, 0xE3, 0x99, 0xF2, 0x90, 0x37, 0x12, 0xCC, 0xF3, /* y */ 0xEA, 0x9E, 0x3A, 0x1A, 0xD1, 0x7F, 0xB0, 0xB3, 0x20, 0x1B, 0x6A, 0xF7, 0xCE, 0x1B, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x00, 0x00, 0x00, 0xC7, 0xF3, 0x4A, 0x77, 0x8F, 0x44, 0x3A, 0xCC, 0x92, 0x0E, 0xBA, 0x49 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 25 * 6]; } _EC_SECG_CHAR2_193R2 = { { NID_X9_62_characteristic_two_field, 20, 25, 2 }, { 0x10, 0xB7, 0xB4, 0xD6, 0x96, 0xE6, 0x76, 0x87, 0x56, 0x15, /* seed */ 0x17, 0x51, 0x37, 0xC8, 0xA1, 0x6F, 0xD0, 0xDA, 0x22, 0x11, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x01, 0x63, 0xF3, 0x5A, 0x51, 0x37, 0xC2, 0xCE, 0x3E, 0xA6, /* a */ 0xED, 0x86, 0x67, 0x19, 0x0B, 0x0B, 0xC4, 0x3E, 0xCD, 0x69, 0x97, 0x77, 0x02, 0x70, 0x9B, 0x00, 0xC9, 0xBB, 0x9E, 0x89, 0x27, 0xD4, 0xD6, 0x4C, 0x37, /* b */ 0x7E, 0x2A, 0xB2, 0x85, 0x6A, 0x5B, 0x16, 0xE3, 0xEF, 0xB7, 0xF6, 0x1D, 0x43, 0x16, 0xAE, 0x00, 0xD9, 0xB6, 0x7D, 0x19, 0x2E, 0x03, 0x67, 0xC8, 0x03, /* x */ 0xF3, 0x9E, 0x1A, 0x7E, 0x82, 0xCA, 0x14, 0xA6, 0x51, 0x35, 0x0A, 0xAE, 0x61, 0x7E, 0x8F, 0x01, 0xCE, 0x94, 0x33, 0x56, 0x07, 0xC3, 0x04, 0xAC, 0x29, /* y */ 0xE7, 0xDE, 0xFB, 0xD9, 0xCA, 0x01, 0xF5, 0x96, 0xF9, 0x27, 0x22, 0x4C, 0xDE, 0xCF, 0x6C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x00, 0x00, 0x01, 0x5A, 0xAB, 0x56, 0x1B, 0x00, 0x54, 0x13, 0xCC, 0xD4, 0xEE, 0x99, 0xD5 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 30 * 6]; } _EC_NIST_CHAR2_233K = { { NID_X9_62_characteristic_two_field, 0, 30, 4 }, { /* no seed */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x72, 0x32, 0xBA, 0x85, 0x3A, 0x7E, 0x73, 0x1A, 0xF1, /* x */ 0x29, 0xF2, 0x2F, 0xF4, 0x14, 0x95, 0x63, 0xA4, 0x19, 0xC2, 0x6B, 0xF5, 0x0A, 0x4C, 0x9D, 0x6E, 0xEF, 0xAD, 0x61, 0x26, 0x01, 0xDB, 0x53, 0x7D, 0xEC, 0xE8, 0x19, 0xB7, 0xF7, 0x0F, /* y */ 0x55, 0x5A, 0x67, 0xC4, 0x27, 0xA8, 0xCD, 0x9B, 0xF1, 0x8A, 0xEB, 0x9B, 0x56, 0xE0, 0xC1, 0x10, 0x56, 0xFA, 0xE6, 0xA3, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x9D, 0x5B, 0xB9, 0x15, 0xBC, 0xD4, 0x6E, 0xFB, 0x1A, 0xD5, 0xF1, 0x73, 0xAB, 0xDF } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 30 * 6]; } _EC_NIST_CHAR2_233B = { { NID_X9_62_characteristic_two_field, 20, 30, 2 }, { 0x74, 0xD5, 0x9F, 0xF0, 0x7F, 0x6B, 0x41, 0x3D, 0x0E, 0xA1, /* seed */ 0x4B, 0x34, 0x4B, 0x20, 0xA2, 0xDB, 0x04, 0x9B, 0x50, 0xC3, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x66, 0x64, 0x7E, 0xDE, 0x6C, 0x33, 0x2C, 0x7F, 0x8C, /* b */ 0x09, 0x23, 0xBB, 0x58, 0x21, 0x3B, 0x33, 0x3B, 0x20, 0xE9, 0xCE, 0x42, 0x81, 0xFE, 0x11, 0x5F, 0x7D, 0x8F, 0x90, 0xAD, 0x00, 0xFA, 0xC9, 0xDF, 0xCB, 0xAC, 0x83, 0x13, 0xBB, 0x21, /* x */ 0x39, 0xF1, 0xBB, 0x75, 0x5F, 0xEF, 0x65, 0xBC, 0x39, 0x1F, 0x8B, 0x36, 0xF8, 0xF8, 0xEB, 0x73, 0x71, 0xFD, 0x55, 0x8B, 0x01, 0x00, 0x6A, 0x08, 0xA4, 0x19, 0x03, 0x35, 0x06, 0x78, /* y */ 0xE5, 0x85, 0x28, 0xBE, 0xBF, 0x8A, 0x0B, 0xEF, 0xF8, 0x67, 0xA7, 0xCA, 0x36, 0x71, 0x6F, 0x7E, 0x01, 0xF8, 0x10, 0x52, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0xE9, 0x74, 0xE7, 0x2F, 0x8A, 0x69, 0x22, 0x03, 0x1D, 0x26, 0x03, 0xCF, 0xE0, 0xD7 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 30 * 6]; } _EC_SECG_CHAR2_239K1 = { { NID_X9_62_characteristic_two_field, 0, 30, 4 }, { /* no seed */ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x29, 0xA0, 0xB6, 0xA8, 0x87, 0xA9, 0x83, 0xE9, 0x73, 0x09, /* x */ 0x88, 0xA6, 0x87, 0x27, 0xA8, 0xB2, 0xD1, 0x26, 0xC4, 0x4C, 0xC2, 0xCC, 0x7B, 0x2A, 0x65, 0x55, 0x19, 0x30, 0x35, 0xDC, 0x76, 0x31, 0x08, 0x04, 0xF1, 0x2E, 0x54, 0x9B, 0xDB, 0x01, /* y */ 0x1C, 0x10, 0x30, 0x89, 0xE7, 0x35, 0x10, 0xAC, 0xB2, 0x75, 0xFC, 0x31, 0x2A, 0x5D, 0xC6, 0xB7, 0x65, 0x53, 0xF0, 0xCA, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x5A, 0x79, 0xFE, 0xC6, 0x7C, 0xB6, 0xE9, 0x1F, 0x1C, 0x1D, 0xA8, 0x00, 0xE4, 0x78, 0xA5 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 36 * 6]; } _EC_NIST_CHAR2_283K = { { NID_X9_62_characteristic_two_field, 0, 36, 4 }, { /* no seed */ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xA1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x05, 0x03, 0x21, 0x3F, 0x78, 0xCA, 0x44, 0x88, 0x3F, 0x1A, /* x */ 0x3B, 0x81, 0x62, 0xF1, 0x88, 0xE5, 0x53, 0xCD, 0x26, 0x5F, 0x23, 0xC1, 0x56, 0x7A, 0x16, 0x87, 0x69, 0x13, 0xB0, 0xC2, 0xAC, 0x24, 0x58, 0x49, 0x28, 0x36, 0x01, 0xCC, 0xDA, 0x38, 0x0F, 0x1C, 0x9E, 0x31, 0x8D, 0x90, /* y */ 0xF9, 0x5D, 0x07, 0xE5, 0x42, 0x6F, 0xE8, 0x7E, 0x45, 0xC0, 0xE8, 0x18, 0x46, 0x98, 0xE4, 0x59, 0x62, 0x36, 0x4E, 0x34, 0x11, 0x61, 0x77, 0xDD, 0x22, 0x59, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE9, 0xAE, 0x2E, 0xD0, 0x75, 0x77, 0x26, 0x5D, 0xFF, 0x7F, 0x94, 0x45, 0x1E, 0x06, 0x1E, 0x16, 0x3C, 0x61 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 36 * 6]; } _EC_NIST_CHAR2_283B = { { NID_X9_62_characteristic_two_field, 20, 36, 2 }, { 0x77, 0xE2, 0xB0, 0x73, 0x70, 0xEB, 0x0F, 0x83, 0x2A, 0x6D, /* no seed */ 0xD5, 0xB6, 0x2D, 0xFC, 0x88, 0xCD, 0x06, 0xBB, 0x84, 0xBE, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xA1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x7B, 0x68, 0x0A, 0xC8, 0xB8, 0x59, 0x6D, 0xA5, 0xA4, /* b */ 0xAF, 0x8A, 0x19, 0xA0, 0x30, 0x3F, 0xCA, 0x97, 0xFD, 0x76, 0x45, 0x30, 0x9F, 0xA2, 0xA5, 0x81, 0x48, 0x5A, 0xF6, 0x26, 0x3E, 0x31, 0x3B, 0x79, 0xA2, 0xF5, 0x05, 0xF9, 0x39, 0x25, 0x8D, 0xB7, 0xDD, 0x90, 0xE1, 0x93, /* x */ 0x4F, 0x8C, 0x70, 0xB0, 0xDF, 0xEC, 0x2E, 0xED, 0x25, 0xB8, 0x55, 0x7E, 0xAC, 0x9C, 0x80, 0xE2, 0xE1, 0x98, 0xF8, 0xCD, 0xBE, 0xCD, 0x86, 0xB1, 0x20, 0x53, 0x03, 0x67, 0x68, 0x54, 0xFE, 0x24, 0x14, 0x1C, 0xB9, 0x8F, /* y */ 0xE6, 0xD4, 0xB2, 0x0D, 0x02, 0xB4, 0x51, 0x6F, 0xF7, 0x02, 0x35, 0x0E, 0xDD, 0xB0, 0x82, 0x67, 0x79, 0xC8, 0x13, 0xF0, 0xDF, 0x45, 0xBE, 0x81, 0x12, 0xF4, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEF, 0x90, 0x39, 0x96, 0x60, 0xFC, 0x93, 0x8A, 0x90, 0x16, 0x5B, 0x04, 0x2A, 0x7C, 0xEF, 0xAD, 0xB3, 0x07 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 52 * 6]; } _EC_NIST_CHAR2_409K = { { NID_X9_62_characteristic_two_field, 0, 52, 4 }, { /* no seed */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x60, 0xF0, 0x5F, 0x65, 0x8F, 0x49, 0xC1, 0xAD, 0x3A, /* x */ 0xB1, 0x89, 0x0F, 0x71, 0x84, 0x21, 0x0E, 0xFD, 0x09, 0x87, 0xE3, 0x07, 0xC8, 0x4C, 0x27, 0xAC, 0xCF, 0xB8, 0xF9, 0xF6, 0x7C, 0xC2, 0xC4, 0x60, 0x18, 0x9E, 0xB5, 0xAA, 0xAA, 0x62, 0xEE, 0x22, 0x2E, 0xB1, 0xB3, 0x55, 0x40, 0xCF, 0xE9, 0x02, 0x37, 0x46, 0x01, 0xE3, 0x69, 0x05, 0x0B, 0x7C, 0x4E, 0x42, 0xAC, 0xBA, /* y */ 0x1D, 0xAC, 0xBF, 0x04, 0x29, 0x9C, 0x34, 0x60, 0x78, 0x2F, 0x91, 0x8E, 0xA4, 0x27, 0xE6, 0x32, 0x51, 0x65, 0xE9, 0xEA, 0x10, 0xE3, 0xDA, 0x5F, 0x6C, 0x42, 0xE9, 0xC5, 0x52, 0x15, 0xAA, 0x9C, 0xA2, 0x7A, 0x58, 0x63, 0xEC, 0x48, 0xD8, 0xE0, 0x28, 0x6B, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x5F, 0x83, 0xB2, 0xD4, 0xEA, 0x20, 0x40, 0x0E, 0xC4, 0x55, 0x7D, 0x5E, 0xD3, 0xE3, 0xE7, 0xCA, 0x5B, 0x4B, 0x5C, 0x83, 0xB8, 0xE0, 0x1E, 0x5F, 0xCF } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 52 * 6]; } _EC_NIST_CHAR2_409B = { { NID_X9_62_characteristic_two_field, 20, 52, 2 }, { 0x40, 0x99, 0xB5, 0xA4, 0x57, 0xF9, 0xD6, 0x9F, 0x79, 0x21, /* seed */ 0x3D, 0x09, 0x4C, 0x4B, 0xCD, 0x4D, 0x42, 0x62, 0x21, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x21, 0xA5, 0xC2, 0xC8, 0xEE, 0x9F, 0xEB, 0x5C, 0x4B, /* b */ 0x9A, 0x75, 0x3B, 0x7B, 0x47, 0x6B, 0x7F, 0xD6, 0x42, 0x2E, 0xF1, 0xF3, 0xDD, 0x67, 0x47, 0x61, 0xFA, 0x99, 0xD6, 0xAC, 0x27, 0xC8, 0xA9, 0xA1, 0x97, 0xB2, 0x72, 0x82, 0x2F, 0x6C, 0xD5, 0x7A, 0x55, 0xAA, 0x4F, 0x50, 0xAE, 0x31, 0x7B, 0x13, 0x54, 0x5F, 0x01, 0x5D, 0x48, 0x60, 0xD0, 0x88, 0xDD, 0xB3, 0x49, 0x6B, /* x */ 0x0C, 0x60, 0x64, 0x75, 0x62, 0x60, 0x44, 0x1C, 0xDE, 0x4A, 0xF1, 0x77, 0x1D, 0x4D, 0xB0, 0x1F, 0xFE, 0x5B, 0x34, 0xE5, 0x97, 0x03, 0xDC, 0x25, 0x5A, 0x86, 0x8A, 0x11, 0x80, 0x51, 0x56, 0x03, 0xAE, 0xAB, 0x60, 0x79, 0x4E, 0x54, 0xBB, 0x79, 0x96, 0xA7, 0x00, 0x61, 0xB1, 0xCF, 0xAB, 0x6B, 0xE5, 0xF3, 0x2B, 0xBF, /* y */ 0xA7, 0x83, 0x24, 0xED, 0x10, 0x6A, 0x76, 0x36, 0xB9, 0xC5, 0xA7, 0xBD, 0x19, 0x8D, 0x01, 0x58, 0xAA, 0x4F, 0x54, 0x88, 0xD0, 0x8F, 0x38, 0x51, 0x4F, 0x1F, 0xDF, 0x4B, 0x4F, 0x40, 0xD2, 0x18, 0x1B, 0x36, 0x81, 0xC3, 0x64, 0xBA, 0x02, 0x73, 0xC7, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xE2, 0xAA, 0xD6, 0xA6, 0x12, 0xF3, 0x33, 0x07, 0xBE, 0x5F, 0xA4, 0x7C, 0x3C, 0x9E, 0x05, 0x2F, 0x83, 0x81, 0x64, 0xCD, 0x37, 0xD9, 0xA2, 0x11, 0x73 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 72 * 6]; } _EC_NIST_CHAR2_571K = { { NID_X9_62_characteristic_two_field, 0, 72, 4 }, { /* no seed */ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x6E, 0xB7, 0xA8, 0x59, 0x92, 0x3F, 0xBC, 0x82, 0x18, /* x */ 0x96, 0x31, 0xF8, 0x10, 0x3F, 0xE4, 0xAC, 0x9C, 0xA2, 0x97, 0x00, 0x12, 0xD5, 0xD4, 0x60, 0x24, 0x80, 0x48, 0x01, 0x84, 0x1C, 0xA4, 0x43, 0x70, 0x95, 0x84, 0x93, 0xB2, 0x05, 0xE6, 0x47, 0xDA, 0x30, 0x4D, 0xB4, 0xCE, 0xB0, 0x8C, 0xBB, 0xD1, 0xBA, 0x39, 0x49, 0x47, 0x76, 0xFB, 0x98, 0x8B, 0x47, 0x17, 0x4D, 0xCA, 0x88, 0xC7, 0xE2, 0x94, 0x52, 0x83, 0xA0, 0x1C, 0x89, 0x72, 0x03, 0x49, 0xDC, 0x80, 0x7F, 0x4F, 0xBF, 0x37, 0x4F, 0x4A, /* y */ 0xEA, 0xDE, 0x3B, 0xCA, 0x95, 0x31, 0x4D, 0xD5, 0x8C, 0xEC, 0x9F, 0x30, 0x7A, 0x54, 0xFF, 0xC6, 0x1E, 0xFC, 0x00, 0x6D, 0x8A, 0x2C, 0x9D, 0x49, 0x79, 0xC0, 0xAC, 0x44, 0xAE, 0xA7, 0x4F, 0xBE, 0xBB, 0xB9, 0xF7, 0x72, 0xAE, 0xDC, 0xB6, 0x20, 0xB0, 0x1A, 0x7B, 0xA7, 0xAF, 0x1B, 0x32, 0x04, 0x30, 0xC8, 0x59, 0x19, 0x84, 0xF6, 0x01, 0xCD, 0x4C, 0x14, 0x3E, 0xF1, 0xC7, 0xA3, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x18, 0x50, 0xE1, 0xF1, 0x9A, 0x63, 0xE4, 0xB3, 0x91, 0xA8, 0xDB, 0x91, 0x7F, 0x41, 0x38, 0xB6, 0x30, 0xD8, 0x4B, 0xE5, 0xD6, 0x39, 0x38, 0x1E, 0x91, 0xDE, 0xB4, 0x5C, 0xFE, 0x77, 0x8F, 0x63, 0x7C, 0x10, 0x01 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 72 * 6]; } _EC_NIST_CHAR2_571B = { { NID_X9_62_characteristic_two_field, 20, 72, 2 }, { 0x2A, 0xA0, 0x58, 0xF7, 0x3A, 0x0E, 0x33, 0xAB, 0x48, 0x6B, /* seed */ 0x0F, 0x61, 0x04, 0x10, 0xC5, 0x3A, 0x7F, 0x13, 0x23, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0xF4, 0x0E, 0x7E, 0x22, 0x21, 0xF2, 0x95, 0xDE, 0x29, /* b */ 0x71, 0x17, 0xB7, 0xF3, 0xD6, 0x2F, 0x5C, 0x6A, 0x97, 0xFF, 0xCB, 0x8C, 0xEF, 0xF1, 0xCD, 0x6B, 0xA8, 0xCE, 0x4A, 0x9A, 0x18, 0xAD, 0x84, 0xFF, 0xAB, 0xBD, 0x8E, 0xFA, 0x59, 0x33, 0x2B, 0xE7, 0xAD, 0x67, 0x56, 0xA6, 0x6E, 0x29, 0x4A, 0xFD, 0x18, 0x5A, 0x78, 0xFF, 0x12, 0xAA, 0x52, 0x0E, 0x4D, 0xE7, 0x39, 0xBA, 0xCA, 0x0C, 0x7F, 0xFE, 0xFF, 0x7F, 0x29, 0x55, 0x72, 0x7A, 0x03, 0x03, 0x00, 0x1D, 0x34, 0xB8, 0x56, 0x29, 0x6C, 0x16, /* x */ 0xC0, 0xD4, 0x0D, 0x3C, 0xD7, 0x75, 0x0A, 0x93, 0xD1, 0xD2, 0x95, 0x5F, 0xA8, 0x0A, 0xA5, 0xF4, 0x0F, 0xC8, 0xDB, 0x7B, 0x2A, 0xBD, 0xBD, 0xE5, 0x39, 0x50, 0xF4, 0xC0, 0xD2, 0x93, 0xCD, 0xD7, 0x11, 0xA3, 0x5B, 0x67, 0xFB, 0x14, 0x99, 0xAE, 0x60, 0x03, 0x86, 0x14, 0xF1, 0x39, 0x4A, 0xBF, 0xA3, 0xB4, 0xC8, 0x50, 0xD9, 0x27, 0xE1, 0xE7, 0x76, 0x9C, 0x8E, 0xEC, 0x2D, 0x19, 0x03, 0x7B, 0xF2, 0x73, 0x42, 0xDA, 0x63, 0x9B, 0x6D, 0xCC, /* y */ 0xFF, 0xFE, 0xB7, 0x3D, 0x69, 0xD7, 0x8C, 0x6C, 0x27, 0xA6, 0x00, 0x9C, 0xBB, 0xCA, 0x19, 0x80, 0xF8, 0x53, 0x39, 0x21, 0xE8, 0xA6, 0x84, 0x42, 0x3E, 0x43, 0xBA, 0xB0, 0x8A, 0x57, 0x62, 0x91, 0xAF, 0x8F, 0x46, 0x1B, 0xB2, 0xA8, 0xB3, 0x53, 0x1D, 0x2F, 0x04, 0x85, 0xC1, 0x9B, 0x16, 0xE2, 0xF1, 0x51, 0x6E, 0x23, 0xDD, 0x3C, 0x1A, 0x48, 0x27, 0xAF, 0x1B, 0x8A, 0xC1, 0x5B, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE6, 0x61, 0xCE, 0x18, 0xFF, 0x55, 0x98, 0x73, 0x08, 0x05, 0x9B, 0x18, 0x68, 0x23, 0x85, 0x1E, 0xC7, 0xDD, 0x9C, 0xA1, 0x16, 0x1D, 0xE9, 0x3D, 0x51, 0x74, 0xD6, 0x6E, 0x83, 0x82, 0xE9, 0xBB, 0x2F, 0xE8, 0x4E, 0x47 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 21 * 6]; } _EC_X9_62_CHAR2_163V1 = { { NID_X9_62_characteristic_two_field, 20, 21, 2 }, { 0xD2, 0xC0, 0xFB, 0x15, 0x76, 0x08, 0x60, 0xDE, 0xF1, 0xEE, 0xF4, 0xD6, 0x96, 0xE6, 0x76, 0x87, 0x56, 0x15, 0x17, 0x54, /* seed */ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x07, 0x25, 0x46, 0xB5, 0x43, 0x52, 0x34, 0xA4, 0x22, 0xE0, /* a */ 0x78, 0x96, 0x75, 0xF4, 0x32, 0xC8, 0x94, 0x35, 0xDE, 0x52, 0x42, 0x00, 0xC9, 0x51, 0x7D, 0x06, 0xD5, 0x24, 0x0D, 0x3C, 0xFF, /* b */ 0x38, 0xC7, 0x4B, 0x20, 0xB6, 0xCD, 0x4D, 0x6F, 0x9D, 0xD4, 0xD9, 0x07, 0xAF, 0x69, 0x98, 0x95, 0x46, 0x10, 0x3D, 0x79, 0x32, /* x */ 0x9F, 0xCC, 0x3D, 0x74, 0x88, 0x0F, 0x33, 0xBB, 0xE8, 0x03, 0xCB, 0x01, 0xEC, 0x23, 0x21, 0x1B, 0x59, 0x66, 0xAD, 0xEA, 0x1D, /* y */ 0x3F, 0x87, 0xF7, 0xEA, 0x58, 0x48, 0xAE, 0xF0, 0xB7, 0xCA, 0x9F, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x01, 0xE6, 0x0F, 0xC8, 0x82, 0x1C, 0xC7, 0x4D, 0xAE, 0xAF, 0xC1 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 21 * 6]; } _EC_X9_62_CHAR2_163V2 = { { NID_X9_62_characteristic_two_field, 20, 21, 2 }, { 0x53, 0x81, 0x4C, 0x05, 0x0D, 0x44, 0xD6, 0x96, 0xE6, 0x76, /* seed */ 0x87, 0x56, 0x15, 0x17, 0x58, 0x0C, 0xA4, 0xE2, 0x9F, 0xFD, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x01, 0x08, 0xB3, 0x9E, 0x77, 0xC4, 0xB1, 0x08, 0xBE, 0xD9, /* a */ 0x81, 0xED, 0x0E, 0x89, 0x0E, 0x11, 0x7C, 0x51, 0x1C, 0xF0, 0x72, 0x06, 0x67, 0xAC, 0xEB, 0x38, 0xAF, 0x4E, 0x48, 0x8C, 0x40, /* b */ 0x74, 0x33, 0xFF, 0xAE, 0x4F, 0x1C, 0x81, 0x16, 0x38, 0xDF, 0x20, 0x00, 0x24, 0x26, 0x6E, 0x4E, 0xB5, 0x10, 0x6D, 0x0A, 0x96, /* x */ 0x4D, 0x92, 0xC4, 0x86, 0x0E, 0x26, 0x71, 0xDB, 0x9B, 0x6C, 0xC5, 0x07, 0x9F, 0x68, 0x4D, 0xDF, 0x66, 0x84, 0xC5, 0xCD, 0x25, /* y */ 0x8B, 0x38, 0x90, 0x02, 0x1B, 0x23, 0x86, 0xDF, 0xD1, 0x9F, 0xC5, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFD, 0xF6, 0x4D, 0xE1, 0x15, 0x1A, 0xDB, 0xB7, 0x8F, 0x10, 0xA7 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 21 * 6]; } _EC_X9_62_CHAR2_163V3 = { { NID_X9_62_characteristic_two_field, 20, 21, 2 }, { 0x50, 0xCB, 0xF1, 0xD9, 0x5C, 0xA9, 0x4D, 0x69, 0x6E, 0x67, /* seed */ 0x68, 0x75, 0x61, 0x51, 0x75, 0xF1, 0x6A, 0x36, 0xA3, 0xB8, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x07, 0xA5, 0x26, 0xC6, 0x3D, 0x3E, 0x25, 0xA2, 0x56, 0xA0, /* a */ 0x07, 0x69, 0x9F, 0x54, 0x47, 0xE3, 0x2A, 0xE4, 0x56, 0xB5, 0x0E, 0x03, 0xF7, 0x06, 0x17, 0x98, 0xEB, 0x99, 0xE2, 0x38, 0xFD, /* b */ 0x6F, 0x1B, 0xF9, 0x5B, 0x48, 0xFE, 0xEB, 0x48, 0x54, 0x25, 0x2B, 0x02, 0xF9, 0xF8, 0x7B, 0x7C, 0x57, 0x4D, 0x0B, 0xDE, 0xCF, /* x */ 0x8A, 0x22, 0xE6, 0x52, 0x47, 0x75, 0xF9, 0x8C, 0xDE, 0xBD, 0xCB, 0x05, 0xB9, 0x35, 0x59, 0x0C, 0x15, 0x5E, 0x17, 0xEA, 0x48, /* y */ 0xEB, 0x3F, 0xF3, 0x71, 0x8B, 0x89, 0x3D, 0xF5, 0x9A, 0x05, 0xD0, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFE, 0x1A, 0xEE, 0x14, 0x0F, 0x11, 0x0A, 0xFF, 0x96, 0x13, 0x09 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 23 * 6]; } _EC_X9_62_CHAR2_176V1 = { { NID_X9_62_characteristic_two_field, 0, 23, 0xFF6E }, { /* no seed */ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xE4, 0xE6, 0xDB, 0x29, 0x95, 0x06, 0x5C, 0x40, 0x7D, /* a */ 0x9D, 0x39, 0xB8, 0xD0, 0x96, 0x7B, 0x96, 0x70, 0x4B, 0xA8, 0xE9, 0xC9, 0x0B, 0x00, 0x5D, 0xDA, 0x47, 0x0A, 0xBE, 0x64, 0x14, 0xDE, 0x8E, /* b */ 0xC1, 0x33, 0xAE, 0x28, 0xE9, 0xBB, 0xD7, 0xFC, 0xEC, 0x0A, 0xE0, 0xFF, 0xF2, 0x00, 0x8D, 0x16, 0xC2, 0x86, 0x67, 0x98, 0xB6, 0x00, 0xF9, /* x */ 0xF0, 0x8B, 0xB4, 0xA8, 0xE8, 0x60, 0xF3, 0x29, 0x8C, 0xE0, 0x4A, 0x57, 0x98, 0x00, 0x6F, 0xA4, 0x53, 0x9C, 0x2D, 0xAD, 0xDD, 0xD6, 0xBA, /* y */ 0xB5, 0x16, 0x7D, 0x61, 0xB4, 0x36, 0xE1, 0xD9, 0x2B, 0xB1, 0x6A, 0x56, 0x2C, 0x00, 0x00, 0x01, 0x00, 0x92, 0x53, 0x73, 0x97, 0xEC, 0xA4, /* order */ 0xF6, 0x14, 0x57, 0x99, 0xD6, 0x2B, 0x0A, 0x19, 0xCE, 0x06, 0xFE, 0x26, 0xAD } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 24 * 6]; } _EC_X9_62_CHAR2_191V1 = { { NID_X9_62_characteristic_two_field, 20, 24, 2 }, { 0x4E, 0x13, 0xCA, 0x54, 0x27, 0x44, 0xD6, 0x96, 0xE6, 0x76, /* seed */ 0x87, 0x56, 0x15, 0x17, 0x55, 0x2F, 0x27, 0x9A, 0x8C, 0x84, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x28, 0x66, 0x53, 0x7B, 0x67, 0x67, 0x52, 0x63, 0x6A, 0x68, /* a */ 0xF5, 0x65, 0x54, 0xE1, 0x26, 0x40, 0x27, 0x6B, 0x64, 0x9E, 0xF7, 0x52, 0x62, 0x67, 0x2E, 0x45, 0xEF, 0x57, 0x1F, 0x00, 0x78, 0x6F, 0x67, 0xB0, /* b */ 0x08, 0x1B, 0x94, 0x95, 0xA3, 0xD9, 0x54, 0x62, 0xF5, 0xDE, 0x0A, 0xA1, 0x85, 0xEC, 0x36, 0xB3, 0xDA, 0xF8, 0xA2, 0x32, 0x06, 0xF9, 0xC4, 0xF2, /* x */ 0x99, 0xD7, 0xB2, 0x1A, 0x9C, 0x36, 0x91, 0x37, 0xF2, 0xC8, 0x4A, 0xE1, 0xAA, 0x0D, 0x76, 0x5B, 0xE7, 0x34, 0x33, 0xB3, 0xF9, 0x5E, 0x33, 0x29, /* y */ 0x32, 0xE7, 0x0E, 0xA2, 0x45, 0xCA, 0x24, 0x18, 0xEA, 0x0E, 0xF9, 0x80, 0x18, 0xFB, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x00, 0x00, 0x04, 0xA2, 0x0E, 0x90, 0xC3, 0x90, 0x67, 0xC8, 0x93, 0xBB, 0xB9, 0xA5 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 24 * 6]; } _EC_X9_62_CHAR2_191V2 = { { NID_X9_62_characteristic_two_field, 20, 24, 4 }, { 0x08, 0x71, 0xEF, 0x2F, 0xEF, 0x24, 0xD6, 0x96, 0xE6, 0x76, /* seed */ 0x87, 0x56, 0x15, 0x17, 0x58, 0xBE, 0xE0, 0xD9, 0x5C, 0x15, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x40, 0x10, 0x28, 0x77, 0x4D, 0x77, 0x77, 0xC7, 0xB7, 0x66, /* a */ 0x6D, 0x13, 0x66, 0xEA, 0x43, 0x20, 0x71, 0x27, 0x4F, 0x89, 0xFF, 0x01, 0xE7, 0x18, 0x06, 0x20, 0x04, 0x8D, 0x28, 0xBC, 0xBD, 0x03, 0xB6, 0x24, /* b */ 0x9C, 0x99, 0x18, 0x2B, 0x7C, 0x8C, 0xD1, 0x97, 0x00, 0xC3, 0x62, 0xC4, 0x6A, 0x01, 0x38, 0x09, 0xB2, 0xB7, 0xCC, 0x1B, 0x28, 0xCC, 0x5A, 0x87, /* x */ 0x92, 0x6A, 0xAD, 0x83, 0xFD, 0x28, 0x78, 0x9E, 0x81, 0xE2, 0xC9, 0xE3, 0xBF, 0x10, 0x17, 0x43, 0x43, 0x86, 0x62, 0x6D, 0x14, 0xF3, 0xDB, 0xF0, /* y */ 0x17, 0x60, 0xD9, 0x21, 0x3A, 0x3E, 0x1C, 0xF3, 0x7A, 0xEC, 0x43, 0x7D, 0x66, 0x8A, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x00, 0x00, 0x50, 0x50, 0x8C, 0xB8, 0x9F, 0x65, 0x28, 0x24, 0xE0, 0x6B, 0x81, 0x73 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 24 * 6]; } _EC_X9_62_CHAR2_191V3 = { { NID_X9_62_characteristic_two_field, 20, 24, 6 }, { 0xE0, 0x53, 0x51, 0x2D, 0xC6, 0x84, 0xD6, 0x96, 0xE6, 0x76, /* seed */ 0x87, 0x56, 0x15, 0x17, 0x50, 0x67, 0xAE, 0x78, 0x6D, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x6C, 0x01, 0x07, 0x47, 0x56, 0x09, 0x91, 0x22, 0x22, 0x10, /* a */ 0x56, 0x91, 0x1C, 0x77, 0xD7, 0x7E, 0x77, 0xA7, 0x77, 0xE7, 0xE7, 0xE7, 0x7F, 0xCB, 0x71, 0xFE, 0x1A, 0xF9, 0x26, 0xCF, 0x84, 0x79, 0x89, 0xEF, /* b */ 0xEF, 0x8D, 0xB4, 0x59, 0xF6, 0x63, 0x94, 0xD9, 0x0F, 0x32, 0xAD, 0x3F, 0x15, 0xE8, 0x37, 0x5D, 0x4C, 0xE2, 0x4F, 0xDE, 0x43, 0x44, 0x89, 0xDE, /* x */ 0x87, 0x46, 0xE7, 0x17, 0x86, 0x01, 0x50, 0x09, 0xE6, 0x6E, 0x38, 0xA9, 0x26, 0xDD, 0x54, 0x5A, 0x39, 0x17, 0x61, 0x96, 0x57, 0x5D, 0x98, 0x59, /* y */ 0x99, 0x36, 0x6E, 0x6A, 0xD3, 0x4C, 0xE0, 0xA7, 0x7C, 0xD7, 0x12, 0x7B, 0x06, 0xBE, 0x15, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, /* order */ 0x55, 0x55, 0x61, 0x0C, 0x0B, 0x19, 0x68, 0x12, 0xBF, 0xB6, 0x28, 0x8A, 0x3E, 0xA3 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 27 * 6]; } _EC_X9_62_CHAR2_208W1 = { { NID_X9_62_characteristic_two_field, 0, 27, 0xFE48 }, { /* no seed */ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC8, 0x61, 0x9E, 0xD4, 0x5A, 0x62, 0xE6, 0x21, 0x2E, /* b */ 0x11, 0x60, 0x34, 0x9E, 0x2B, 0xFA, 0x84, 0x44, 0x39, 0xFA, 0xFC, 0x2A, 0x3F, 0xD1, 0x63, 0x8F, 0x9E, 0x00, 0x89, 0xFD, 0xFB, 0xE4, 0xAB, 0xE1, 0x93, 0xDF, 0x95, /* x */ 0x59, 0xEC, 0xF0, 0x7A, 0xC0, 0xCE, 0x78, 0x55, 0x4E, 0x27, 0x84, 0xEB, 0x8C, 0x1E, 0xD1, 0xA5, 0x7A, 0x00, 0x0F, 0x55, 0xB5, 0x1A, 0x06, 0xE7, 0x8E, 0x9A, 0xC3, /* y */ 0x8A, 0x03, 0x5F, 0xF5, 0x20, 0xD8, 0xB0, 0x17, 0x81, 0xBE, 0xB1, 0xA6, 0xBB, 0x08, 0x61, 0x7D, 0xE3, 0x00, 0x00, 0x01, 0x01, 0xBA, 0xF9, 0x5C, 0x97, 0x23, 0xC5, /* order */ 0x7B, 0x6C, 0x21, 0xDA, 0x2E, 0xFF, 0x2D, 0x5E, 0xD5, 0x88, 0xBD, 0xD5, 0x71, 0x7E, 0x21, 0x2F, 0x9D } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 30 * 6]; } _EC_X9_62_CHAR2_239V1 = { { NID_X9_62_characteristic_two_field, 20, 30, 4 }, { 0xD3, 0x4B, 0x9A, 0x4D, 0x69, 0x6E, 0x67, 0x68, 0x75, 0x61, /* seed */ 0x51, 0x75, 0xCA, 0x71, 0xB9, 0x20, 0xBF, 0xEF, 0xB0, 0x5D, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x32, 0x01, 0x08, 0x57, 0x07, 0x7C, 0x54, 0x31, 0x12, 0x3A, /* a */ 0x46, 0xB8, 0x08, 0x90, 0x67, 0x56, 0xF5, 0x43, 0x42, 0x3E, 0x8D, 0x27, 0x87, 0x75, 0x78, 0x12, 0x57, 0x78, 0xAC, 0x76, 0x79, 0x04, 0x08, 0xF2, 0xEE, 0xDA, 0xF3, 0x92, 0xB0, 0x12, /* b */ 0xED, 0xEF, 0xB3, 0x39, 0x2F, 0x30, 0xF4, 0x32, 0x7C, 0x0C, 0xA3, 0xF3, 0x1F, 0xC3, 0x83, 0xC4, 0x22, 0xAA, 0x8C, 0x16, 0x57, 0x92, 0x70, 0x98, 0xFA, 0x93, 0x2E, 0x7C, 0x0A, 0x96, /* x */ 0xD3, 0xFD, 0x5B, 0x70, 0x6E, 0xF7, 0xE5, 0xF5, 0xC1, 0x56, 0xE1, 0x6B, 0x7E, 0x7C, 0x86, 0x03, 0x85, 0x52, 0xE9, 0x1D, 0x61, 0xD8, 0xEE, 0x50, 0x77, 0xC3, 0x3F, 0xEC, 0xF6, 0xF1, /* y */ 0xA1, 0x6B, 0x26, 0x8D, 0xE4, 0x69, 0xC3, 0xC7, 0x74, 0x4E, 0xA9, 0xA9, 0x71, 0x64, 0x9F, 0xC7, 0xA9, 0x61, 0x63, 0x05, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* order */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x4D, 0x42, 0xFF, 0xE1, 0x49, 0x2A, 0x49, 0x93, 0xF1, 0xCA, 0xD6, 0x66, 0xE4, 0x47 } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 30 * 6]; } _EC_X9_62_CHAR2_239V2 = { { NID_X9_62_characteristic_two_field, 20, 30, 6 }, { 0x2A, 0xA6, 0x98, 0x2F, 0xDF, 0xA4, 0xD6, 0x96, 0xE6, 0x76, /* seed */ 0x87, 0x56, 0x15, 0x17, 0x5D, 0x26, 0x67, 0x27, 0x27, 0x7D, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x42, 0x30, 0x01, 0x77, 0x57, 0xA7, 0x67, 0xFA, 0xE4, 0x23, /* a */ 0x98, 0x56, 0x9B, 0x74, 0x63, 0x25, 0xD4, 0x53, 0x13, 0xAF, 0x07, 0x66, 0x26, 0x64, 0x79, 0xB7, 0x56, 0x54, 0xE6, 0x5F, 0x50, 0x37, 0xEA, 0x65, 0x41, 0x96, 0xCF, 0xF0, 0xCD, 0x82, /* b */ 0xB2, 0xC1, 0x4A, 0x2F, 0xCF, 0x2E, 0x3F, 0xF8, 0x77, 0x52, 0x85, 0xB5, 0x45, 0x72, 0x2F, 0x03, 0xEA, 0xCD, 0xB7, 0x4B, 0x28, 0xF9, 0xD0, 0x4E, 0x90, 0x00, 0x69, 0xC8, 0xDC, 0x47, /* x */ 0xA0, 0x85, 0x34, 0xFE, 0x76, 0xD2, 0xB9, 0x00, 0xB7, 0xD7, 0xEF, 0x31, 0xF5, 0x70, 0x9F, 0x20, 0x0C, 0x4C, 0xA2, 0x05, 0x56, 0x67, 0x33, 0x4C, 0x45, 0xAF, 0xF3, 0xB5, 0xA0, 0x3B, /* y */ 0xAD, 0x9D, 0xD7, 0x5E, 0x2C, 0x71, 0xA9, 0x93, 0x62, 0x56, 0x7D, 0x54, 0x53, 0xF7, 0xFA, 0x6E, 0x22, 0x7E, 0xC8, 0x33, 0x15, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, /* order */ 0x55, 0x55, 0x55, 0x55, 0x55, 0x3C, 0x6F, 0x28, 0x85, 0x25, 0x9C, 0x31, 0xE3, 0xFC, 0xDF, 0x15, 0x46, 0x24, 0x52, 0x2D } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 30 * 6]; } _EC_X9_62_CHAR2_239V3 = { { NID_X9_62_characteristic_two_field, 20, 30, 0xA }, { 0x9E, 0x07, 0x6F, 0x4D, 0x69, 0x6E, 0x67, 0x68, 0x75, 0x61, /* seed */ 0x51, 0x75, 0xE1, 0x1E, 0x9F, 0xDD, 0x77, 0xF9, 0x20, 0x41, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x01, 0x23, 0x87, 0x74, 0x66, 0x6A, 0x67, 0x76, 0x6D, 0x66, /* a */ 0x76, 0xF7, 0x78, 0xE6, 0x76, 0xB6, 0x69, 0x99, 0x17, 0x66, 0x66, 0xE6, 0x87, 0x66, 0x6D, 0x87, 0x66, 0xC6, 0x6A, 0x9F, 0x6A, 0x94, 0x19, 0x77, 0xBA, 0x9F, 0x6A, 0x43, 0x51, 0x99, /* b */ 0xAC, 0xFC, 0x51, 0x06, 0x7E, 0xD5, 0x87, 0xF5, 0x19, 0xC5, 0xEC, 0xB5, 0x41, 0xB8, 0xE4, 0x41, 0x11, 0xDE, 0x1D, 0x40, 0x70, 0xF6, 0xE9, 0xD0, 0x4D, 0x28, 0x9C, 0x4E, 0x89, 0x91, /* x */ 0x3C, 0xE3, 0x53, 0x0B, 0xFD, 0xE9, 0x03, 0x97, 0x7D, 0x42, 0xB1, 0x46, 0xD5, 0x39, 0xBF, 0x1B, 0xDE, 0x4E, 0x9C, 0x92, 0x2E, 0x5A, 0x0E, 0xAF, 0x6E, 0x5E, 0x13, 0x05, 0xB9, 0x00, /* y */ 0x4D, 0xCE, 0x5C, 0x0E, 0xD7, 0xFE, 0x59, 0xA3, 0x56, 0x08, 0xF3, 0x38, 0x37, 0xC8, 0x16, 0xD8, 0x0B, 0x79, 0xF4, 0x61, 0x0C, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, /* order */ 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xAC, 0x49, 0x12, 0xD2, 0xD9, 0xDF, 0x90, 0x3E, 0xF9, 0x88, 0x8B, 0x8A, 0x0E, 0x4C, 0xFF } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 35 * 6]; } _EC_X9_62_CHAR2_272W1 = { { NID_X9_62_characteristic_two_field, 0, 35, 0xFF06 }, { /* no seed */ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x91, 0xA0, 0x91, 0xF0, 0x3B, 0x5F, 0xBA, 0x4A, 0xB2, /* a */ 0xCC, 0xF4, 0x9C, 0x4E, 0xDD, 0x22, 0x0F, 0xB0, 0x28, 0x71, 0x2D, 0x42, 0xBE, 0x75, 0x2B, 0x2C, 0x40, 0x09, 0x4D, 0xBA, 0xCD, 0xB5, 0x86, 0xFB, 0x20, 0x00, 0x71, 0x67, 0xEF, 0xC9, 0x2B, 0xB2, 0xE3, 0xCE, 0x7C, /* b */ 0x8A, 0xAA, 0xFF, 0x34, 0xE1, 0x2A, 0x9C, 0x55, 0x70, 0x03, 0xD7, 0xC7, 0x3A, 0x6F, 0xAF, 0x00, 0x3F, 0x99, 0xF6, 0xCC, 0x84, 0x82, 0xE5, 0x40, 0xF7, 0x00, 0x61, 0x08, 0xBA, 0xBB, 0x2C, 0xEE, 0xBC, 0xF7, 0x87, /* x */ 0x05, 0x8A, 0x05, 0x6C, 0xBE, 0x0C, 0xFE, 0x62, 0x2D, 0x77, 0x23, 0xA2, 0x89, 0xE0, 0x8A, 0x07, 0xAE, 0x13, 0xEF, 0x0D, 0x10, 0xD1, 0x71, 0xDD, 0x8D, 0x00, 0x10, 0xC7, 0x69, 0x57, 0x16, 0x85, 0x1E, 0xEF, 0x6B, /* y */ 0xA7, 0xF6, 0x87, 0x2E, 0x61, 0x42, 0xFB, 0xD2, 0x41, 0xB8, 0x30, 0xFF, 0x5E, 0xFC, 0xAC, 0xEC, 0xCA, 0xB0, 0x5E, 0x02, 0x00, 0x5D, 0xDE, 0x9D, 0x23, 0x00, 0x00, 0x01, 0x00, 0xFA, 0xF5, 0x13, 0x54, 0xE0, 0xE3, /* order */ 0x9E, 0x48, 0x92, 0xDF, 0x6E, 0x31, 0x9C, 0x72, 0xC8, 0x16, 0x16, 0x03, 0xFA, 0x45, 0xAA, 0x7B, 0x99, 0x8A, 0x16, 0x7B, 0x8F, 0x1E, 0x62, 0x95, 0x21 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 39 * 6]; } _EC_X9_62_CHAR2_304W1 = { { NID_X9_62_characteristic_two_field, 0, 39, 0xFE2E }, { /* no seed */ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x07, 0x00, 0xFD, 0x0D, 0x69, 0x31, 0x49, 0xA1, 0x18, 0xF6, 0x51, /* a */ 0xE6, 0xDC, 0xE6, 0x80, 0x20, 0x85, 0x37, 0x7E, 0x5F, 0x88, 0x2D, 0x1B, 0x51, 0x0B, 0x44, 0x16, 0x00, 0x74, 0xC1, 0x28, 0x80, 0x78, 0x36, 0x5A, 0x03, 0x96, 0xC8, 0xE6, 0x81, 0x00, 0xBD, 0xDB, 0x97, 0xE5, 0x55, 0xA5, 0x0A, 0x90, 0x8E, /* b */ 0x43, 0xB0, 0x1C, 0x79, 0x8E, 0xA5, 0xDA, 0xA6, 0x78, 0x8F, 0x1E, 0xA2, 0x79, 0x4E, 0xFC, 0xF5, 0x71, 0x66, 0xB8, 0xC1, 0x40, 0x39, 0x60, 0x1E, 0x55, 0x82, 0x73, 0x40, 0xBE, 0x00, 0x19, 0x7B, 0x07, 0x84, 0x5E, 0x9B, 0xE2, 0xD9, 0x6A, /* x */ 0xDB, 0x0F, 0x5F, 0x3C, 0x7F, 0x2C, 0xFF, 0xBD, 0x7A, 0x3E, 0xB8, 0xB6, 0xFE, 0xC3, 0x5C, 0x7F, 0xD6, 0x7F, 0x26, 0xDD, 0xF6, 0x28, 0x5A, 0x64, 0x4F, 0x74, 0x0A, 0x26, 0x14, 0x00, 0xE1, 0x9F, 0xBE, 0xB7, 0x6E, 0x0D, 0xA1, 0x71, 0x51, /* y */ 0x7E, 0xCF, 0x40, 0x1B, 0x50, 0x28, 0x9B, 0xF0, 0x14, 0x10, 0x32, 0x88, 0x52, 0x7A, 0x9B, 0x41, 0x6A, 0x10, 0x5E, 0x80, 0x26, 0x0B, 0x54, 0x9F, 0xDC, 0x1B, 0x92, 0xC0, 0x3B, 0x00, 0x00, 0x01, 0x01, 0xD5, 0x56, 0x57, 0x2A, 0xAB, 0xAC, /* order */ 0x80, 0x01, 0x01, 0xD5, 0x56, 0x57, 0x2A, 0xAB, 0xAC, 0x80, 0x01, 0x02, 0x2D, 0x5C, 0x91, 0xDD, 0x17, 0x3F, 0x8F, 0xB5, 0x61, 0xDA, 0x68, 0x99, 0x16, 0x44, 0x43, 0x05, 0x1D } }; static const struct { EC_CURVE_DATA h; unsigned char data[20 + 45 * 6]; } _EC_X9_62_CHAR2_359V1 = { { NID_X9_62_characteristic_two_field, 20, 45, 0x4C }, { 0x2B, 0x35, 0x49, 0x20, 0xB7, 0x24, 0xD6, 0x96, 0xE6, 0x76, /* seed */ 0x87, 0x56, 0x15, 0x17, 0x58, 0x5B, 0xA1, 0x33, 0x2D, 0xC6, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x56, 0x67, 0x67, 0x6A, 0x65, 0x4B, 0x20, 0x75, 0x4F, 0x35, /* a */ 0x6E, 0xA9, 0x20, 0x17, 0xD9, 0x46, 0x56, 0x7C, 0x46, 0x67, 0x55, 0x56, 0xF1, 0x95, 0x56, 0xA0, 0x46, 0x16, 0xB5, 0x67, 0xD2, 0x23, 0xA5, 0xE0, 0x56, 0x56, 0xFB, 0x54, 0x90, 0x16, 0xA9, 0x66, 0x56, 0xA5, 0x57, 0x24, 0x72, 0xE2, 0xD0, 0x19, 0x7C, 0x49, 0x36, 0x3F, 0x1F, /* b */ 0xE7, 0xF5, 0xB6, 0xDB, 0x07, 0x5D, 0x52, 0xB6, 0x94, 0x7D, 0x13, 0x5D, 0x8C, 0xA4, 0x45, 0x80, 0x5D, 0x39, 0xBC, 0x34, 0x56, 0x26, 0x08, 0x96, 0x87, 0x74, 0x2B, 0x63, 0x29, 0xE7, 0x06, 0x80, 0x23, 0x19, 0x88, 0x3C, 0x25, 0x8E, 0xF3, 0x04, 0x77, 0x67, 0xE7, 0xED, 0xE0, /* x */ 0xF1, 0xFD, 0xAA, 0x79, 0xDA, 0xEE, 0x38, 0x41, 0x36, 0x6A, 0x13, 0x2E, 0x16, 0x3A, 0xCE, 0xD4, 0xED, 0x24, 0x01, 0xDF, 0x9C, 0x6B, 0xDC, 0xDE, 0x98, 0xE8, 0xE7, 0x07, 0xC0, 0x7A, 0x22, 0x39, 0xB1, 0xB0, 0x97, 0x53, 0xD7, 0xE0, 0x85, 0x29, 0x54, 0x70, 0x48, 0x12, 0x1E, /* y */ 0x9C, 0x95, 0xF3, 0x79, 0x1D, 0xD8, 0x04, 0x96, 0x39, 0x48, 0xF3, 0x4F, 0xAE, 0x7B, 0xF4, 0x4E, 0xA8, 0x23, 0x65, 0xDC, 0x78, 0x68, 0xFE, 0x57, 0xE4, 0xAE, 0x2D, 0xE2, 0x11, 0x30, 0x5A, 0x40, 0x71, 0x04, 0xBD, 0x01, 0xAF, 0x28, 0x6B, 0xCA, 0x1A, 0xF2, 0x86, 0xBC, 0xA1, /* order */ 0xAF, 0x28, 0x6B, 0xCA, 0x1A, 0xF2, 0x86, 0xBC, 0xA1, 0xAF, 0x28, 0x6B, 0xC9, 0xFB, 0x8F, 0x6B, 0x85, 0xC5, 0x56, 0x89, 0x2C, 0x20, 0xA7, 0xEB, 0x96, 0x4F, 0xE7, 0x71, 0x9E, 0x74, 0xF4, 0x90, 0x75, 0x8D, 0x3B } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 47 * 6]; } _EC_X9_62_CHAR2_368W1 = { { NID_X9_62_characteristic_two_field, 0, 47, 0xFF70 }, { /* no seed */ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xE0, 0xD2, 0xEE, 0x25, 0x09, 0x52, 0x06, 0xF5, 0xE2, /* a */ 0xA4, 0xF9, 0xED, 0x22, 0x9F, 0x1F, 0x25, 0x6E, 0x79, 0xA0, 0xE2, 0xB4, 0x55, 0x97, 0x0D, 0x8D, 0x0D, 0x86, 0x5B, 0xD9, 0x47, 0x78, 0xC5, 0x76, 0xD6, 0x2F, 0x0A, 0xB7, 0x51, 0x9C, 0xCD, 0x2A, 0x1A, 0x90, 0x6A, 0xE3, 0x0D, 0x00, 0xFC, 0x12, 0x17, 0xD4, 0x32, 0x0A, 0x90, 0x45, 0x2C, /* b */ 0x76, 0x0A, 0x58, 0xED, 0xCD, 0x30, 0xC8, 0xDD, 0x06, 0x9B, 0x3C, 0x34, 0x45, 0x38, 0x37, 0xA3, 0x4E, 0xD5, 0x0C, 0xB5, 0x49, 0x17, 0xE1, 0xC2, 0x11, 0x2D, 0x84, 0xD1, 0x64, 0xF4, 0x44, 0xF8, 0xF7, 0x47, 0x86, 0x04, 0x6A, 0x00, 0x10, 0x85, 0xE2, 0x75, 0x53, 0x81, 0xDC, 0xCC, 0xE3, /* x */ 0xC1, 0x55, 0x7A, 0xFA, 0x10, 0xC2, 0xF0, 0xC0, 0xC2, 0x82, 0x56, 0x46, 0xC5, 0xB3, 0x4A, 0x39, 0x4C, 0xBC, 0xFA, 0x8B, 0xC1, 0x6B, 0x22, 0xE7, 0xE7, 0x89, 0xE9, 0x27, 0xBE, 0x21, 0x6F, 0x02, 0xE1, 0xFB, 0x13, 0x6A, 0x5F, 0x00, 0x7B, 0x3E, 0xB1, 0xBD, 0xDC, 0xBA, 0x62, 0xD5, 0xD8, /* y */ 0xB2, 0x05, 0x9B, 0x52, 0x57, 0x97, 0xFC, 0x73, 0x82, 0x2C, 0x59, 0x05, 0x9C, 0x62, 0x3A, 0x45, 0xFF, 0x38, 0x43, 0xCE, 0xE8, 0xF8, 0x7C, 0xD1, 0x85, 0x5A, 0xDA, 0xA8, 0x1E, 0x2A, 0x07, 0x50, 0xB8, 0x0F, 0xDA, 0x23, 0x10, 0x00, 0x00, 0x01, 0x00, 0x90, 0x51, 0x2D, 0xA9, 0xAF, 0x72, /* order */ 0xB0, 0x83, 0x49, 0xD9, 0x8A, 0x5D, 0xD4, 0xC7, 0xB0, 0x53, 0x2E, 0xCA, 0x51, 0xCE, 0x03, 0xE2, 0xD1, 0x0F, 0x3B, 0x7A, 0xC5, 0x79, 0xBD, 0x87, 0xE9, 0x09, 0xAE, 0x40, 0xA6, 0xF1, 0x31, 0xE9, 0xCF, 0xCE, 0x5B, 0xD9, 0x67 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 54 * 6]; } _EC_X9_62_CHAR2_431R1 = { { NID_X9_62_characteristic_two_field, 0, 54, 0x2760 }, { /* no seed */ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1A, 0x82, 0x7E, 0xF0, 0x0D, 0xD6, 0xFC, 0x0E, 0x23, 0x4C, /* a */ 0xAF, 0x04, 0x6C, 0x6A, 0x5D, 0x8A, 0x85, 0x39, 0x5B, 0x23, 0x6C, 0xC4, 0xAD, 0x2C, 0xF3, 0x2A, 0x0C, 0xAD, 0xBD, 0xC9, 0xDD, 0xF6, 0x20, 0xB0, 0xEB, 0x99, 0x06, 0xD0, 0x95, 0x7F, 0x6C, 0x6F, 0xEA, 0xCD, 0x61, 0x54, 0x68, 0xDF, 0x10, 0x4D, 0xE2, 0x96, 0xCD, 0x8F, 0x10, 0xD9, 0xB4, 0xA3, 0xD9, 0x04, 0x7D, 0x8B, 0x15, 0x43, /* b */ 0x59, 0xAB, 0xFB, 0x1B, 0x7F, 0x54, 0x85, 0xB0, 0x4C, 0xEB, 0x86, 0x82, 0x37, 0xDD, 0xC9, 0xDE, 0xDA, 0x98, 0x2A, 0x67, 0x9A, 0x5A, 0x91, 0x9B, 0x62, 0x6D, 0x4E, 0x50, 0xA8, 0xDD, 0x73, 0x1B, 0x10, 0x7A, 0x99, 0x62, 0x38, 0x1F, 0xB5, 0xD8, 0x07, 0xBF, 0x26, 0x18, 0x12, 0x0F, 0xC0, 0x5D, 0x3C, 0x67, 0xA9, 0x9D, 0xE1, 0x61, /* x */ 0xD2, 0xF4, 0x09, 0x26, 0x22, 0xFE, 0xCA, 0x70, 0x1B, 0xE4, 0xF5, 0x0F, 0x47, 0x58, 0x71, 0x4E, 0x8A, 0x87, 0xBB, 0xF2, 0xA6, 0x58, 0xEF, 0x8C, 0x21, 0xE7, 0xC5, 0xEF, 0xE9, 0x65, 0x36, 0x1F, 0x6C, 0x29, 0x99, 0xC0, 0xC2, 0x47, 0xB0, 0xDB, 0xD7, 0x0C, 0xE6, 0xB7, 0x20, 0xD0, 0xAF, 0x89, 0x03, 0xA9, 0x6F, 0x8D, 0x5F, 0xA2, /* y */ 0xC2, 0x55, 0x74, 0x5D, 0x3C, 0x45, 0x1B, 0x30, 0x2C, 0x93, 0x46, 0xD9, 0xB7, 0xE4, 0x85, 0xE7, 0xBC, 0xE4, 0x1F, 0x6B, 0x59, 0x1F, 0x3E, 0x8F, 0x6A, 0xDD, 0xCB, 0xB0, 0xBC, 0x4C, 0x2F, 0x94, 0x7A, 0x7D, 0xE1, 0xA8, 0x9B, 0x62, 0x5D, 0x6A, 0x59, 0x8B, 0x37, 0x60, 0x00, 0x03, 0x40, 0x34, 0x03, 0x40, 0x34, 0x03, 0x40, 0x34, /* order */ 0x03, 0x40, 0x34, 0x03, 0x40, 0x34, 0x03, 0x40, 0x34, 0x03, 0x40, 0x34, 0x03, 0x40, 0x34, 0x03, 0x40, 0x34, 0x03, 0x23, 0xC3, 0x13, 0xFA, 0xB5, 0x05, 0x89, 0x70, 0x3B, 0x5E, 0xC6, 0x8D, 0x35, 0x87, 0xFE, 0xC6, 0x0D, 0x16, 0x1C, 0xC1, 0x49, 0xC1, 0xAD, 0x4A, 0x91 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 15 * 6]; } _EC_WTLS_1 = { { NID_X9_62_characteristic_two_field, 0, 15, 2 }, { /* no seed */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x66, 0x79, 0x79, 0xA4, 0x0B, 0xA4, 0x97, 0xE5, 0xD5, /* x */ 0xC2, 0x70, 0x78, 0x06, 0x17, 0x00, 0xF4, 0x4B, 0x4A, 0xF1, 0xEC, 0xC2, 0x63, 0x0E, 0x08, /* y */ 0x78, 0x5C, 0xEB, 0xCC, 0x15, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0xBF, /* order */ 0x91, 0xAF, 0x6D, 0xEA, 0x73 } }; /* IPSec curves */ /* NOTE: The of curves over a extension field of non prime degree * is not recommended (Weil-descent). * As the group order is not a prime this curve is not suitable * for ECDSA. */ static const struct { EC_CURVE_DATA h; unsigned char data[0 + 20 * 6]; } _EC_IPSEC_155_ID3 = { { NID_X9_62_characteristic_two_field, 0, 20, 3 }, { /* no seed */ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x33, 0x8f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* x */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* y */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc8, 0x02, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, /* order */ 0xC7, 0xF3, 0xC7, 0x88, 0x1B, 0xD0, 0x86, 0x8F, 0xA8, 0x6C } }; /* NOTE: The of curves over a extension field of non prime degree * is not recommended (Weil-descent). * As the group order is not a prime this curve is not suitable * for ECDSA. */ static const struct { EC_CURVE_DATA h; unsigned char data[0 + 24 * 6]; } _EC_IPSEC_185_ID4 = { { NID_X9_62_characteristic_two_field, 0, 24, 2 }, { /* no seed */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* p */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0xe9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* x */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* y */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* order */ 0xFF, 0xFF, 0xED, 0xF9, 0x7C, 0x44, 0xDB, 0x9F, 0x24, 0x20, 0xBA, 0xFC, 0xA7, 0x5E } }; #endif /* These curves were added by Annie Yousar * For the definition of RFC 5639 curves see * http://www.ietf.org/rfc/rfc5639.txt * These curves are generated verifiable at random, nevertheless the seed is * omitted as parameter because the generation mechanism is different from * those defined in ANSI X9.62. */ static const struct { EC_CURVE_DATA h; unsigned char data[0 + 20 * 6]; } _EC_brainpoolP160r1 = { { NID_X9_62_prime_field, 0, 20, 1 }, { /* no seed */ 0xE9, 0x5E, 0x4A, 0x5F, 0x73, 0x70, 0x59, 0xDC, 0x60, 0xDF, /* p */ 0xC7, 0xAD, 0x95, 0xB3, 0xD8, 0x13, 0x95, 0x15, 0x62, 0x0F, 0x34, 0x0E, 0x7B, 0xE2, 0xA2, 0x80, 0xEB, 0x74, 0xE2, 0xBE, /* a */ 0x61, 0xBA, 0xDA, 0x74, 0x5D, 0x97, 0xE8, 0xF7, 0xC3, 0x00, 0x1E, 0x58, 0x9A, 0x85, 0x95, 0x42, 0x34, 0x12, 0x13, 0x4F, /* b */ 0xAA, 0x2D, 0xBD, 0xEC, 0x95, 0xC8, 0xD8, 0x67, 0x5E, 0x58, 0xBE, 0xD5, 0xAF, 0x16, 0xEA, 0x3F, 0x6A, 0x4F, 0x62, 0x93, /* x */ 0x8C, 0x46, 0x31, 0xEB, 0x5A, 0xF7, 0xBD, 0xBC, 0xDB, 0xC3, 0x16, 0x67, 0xCB, 0x47, 0x7A, 0x1A, 0x8E, 0xC3, 0x38, 0xF9, /* y */ 0x47, 0x41, 0x66, 0x9C, 0x97, 0x63, 0x16, 0xDA, 0x63, 0x21, 0xE9, 0x5E, 0x4A, 0x5F, 0x73, 0x70, 0x59, 0xDC, 0x60, 0xDF, /* order */ 0x59, 0x91, 0xD4, 0x50, 0x29, 0x40, 0x9E, 0x60, 0xFC, 0x09 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 20 * 6]; } _EC_brainpoolP160t1 = { { NID_X9_62_prime_field, 0, 20, 1 }, { /* no seed */ 0xE9, 0x5E, 0x4A, 0x5F, 0x73, 0x70, 0x59, 0xDC, 0x60, 0xDF, /* p */ 0xC7, 0xAD, 0x95, 0xB3, 0xD8, 0x13, 0x95, 0x15, 0x62, 0x0F, 0xE9, 0x5E, 0x4A, 0x5F, 0x73, 0x70, 0x59, 0xDC, 0x60, 0xDF, /* a */ 0xC7, 0xAD, 0x95, 0xB3, 0xD8, 0x13, 0x95, 0x15, 0x62, 0x0C, 0x7A, 0x55, 0x6B, 0x6D, 0xAE, 0x53, 0x5B, 0x7B, 0x51, 0xED, /* b */ 0x2C, 0x4D, 0x7D, 0xAA, 0x7A, 0x0B, 0x5C, 0x55, 0xF3, 0x80, 0xB1, 0x99, 0xB1, 0x3B, 0x9B, 0x34, 0xEF, 0xC1, 0x39, 0x7E, /* x */ 0x64, 0xBA, 0xEB, 0x05, 0xAC, 0xC2, 0x65, 0xFF, 0x23, 0x78, 0xAD, 0xD6, 0x71, 0x8B, 0x7C, 0x7C, 0x19, 0x61, 0xF0, 0x99, /* y */ 0x1B, 0x84, 0x24, 0x43, 0x77, 0x21, 0x52, 0xC9, 0xE0, 0xAD, 0xE9, 0x5E, 0x4A, 0x5F, 0x73, 0x70, 0x59, 0xDC, 0x60, 0xDF, /* order */ 0x59, 0x91, 0xD4, 0x50, 0x29, 0x40, 0x9E, 0x60, 0xFC, 0x09 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 24 * 6]; } _EC_brainpoolP192r1 = { { NID_X9_62_prime_field, 0, 24, 1 }, { /* no seed */ 0xC3, 0x02, 0xF4, 0x1D, 0x93, 0x2A, 0x36, 0xCD, 0xA7, 0xA3, /* p */ 0x46, 0x30, 0x93, 0xD1, 0x8D, 0xB7, 0x8F, 0xCE, 0x47, 0x6D, 0xE1, 0xA8, 0x62, 0x97, 0x6A, 0x91, 0x17, 0x40, 0x76, 0xB1, 0xE0, 0xE1, 0x9C, 0x39, /* a */ 0xC0, 0x31, 0xFE, 0x86, 0x85, 0xC1, 0xCA, 0xE0, 0x40, 0xE5, 0xC6, 0x9A, 0x28, 0xEF, 0x46, 0x9A, 0x28, 0xEF, 0x7C, 0x28, 0xCC, 0xA3, 0xDC, 0x72, /* b */ 0x1D, 0x04, 0x4F, 0x44, 0x96, 0xBC, 0xCA, 0x7E, 0xF4, 0x14, 0x6F, 0xBF, 0x25, 0xC9, 0xC0, 0xA0, 0x64, 0x7E, 0xAA, 0xB6, 0xA4, 0x87, 0x53, 0xB0, /* x */ 0x33, 0xC5, 0x6C, 0xB0, 0xF0, 0x90, 0x0A, 0x2F, 0x5C, 0x48, 0x53, 0x37, 0x5F, 0xD6, 0x14, 0xB6, 0x90, 0x86, 0x6A, 0xBD, 0x5B, 0xB8, 0x8B, 0x5F, /* y */ 0x48, 0x28, 0xC1, 0x49, 0x00, 0x02, 0xE6, 0x77, 0x3F, 0xA2, 0xFA, 0x29, 0x9B, 0x8F, 0xC3, 0x02, 0xF4, 0x1D, 0x93, 0x2A, 0x36, 0xCD, 0xA7, 0xA3, /* order */ 0x46, 0x2F, 0x9E, 0x9E, 0x91, 0x6B, 0x5B, 0xE8, 0xF1, 0x02, 0x9A, 0xC4, 0xAC, 0xC1 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 24 * 6]; } _EC_brainpoolP192t1 = { { NID_X9_62_prime_field, 0, 24, 1 }, { /* no seed */ 0xC3, 0x02, 0xF4, 0x1D, 0x93, 0x2A, 0x36, 0xCD, 0xA7, 0xA3, /* p */ 0x46, 0x30, 0x93, 0xD1, 0x8D, 0xB7, 0x8F, 0xCE, 0x47, 0x6D, 0xE1, 0xA8, 0x62, 0x97, 0xC3, 0x02, 0xF4, 0x1D, 0x93, 0x2A, 0x36, 0xCD, 0xA7, 0xA3, /* a */ 0x46, 0x30, 0x93, 0xD1, 0x8D, 0xB7, 0x8F, 0xCE, 0x47, 0x6D, 0xE1, 0xA8, 0x62, 0x94, 0x13, 0xD5, 0x6F, 0xFA, 0xEC, 0x78, 0x68, 0x1E, 0x68, 0xF9, /* b */ 0xDE, 0xB4, 0x3B, 0x35, 0xBE, 0xC2, 0xFB, 0x68, 0x54, 0x2E, 0x27, 0x89, 0x7B, 0x79, 0x3A, 0xE9, 0xE5, 0x8C, 0x82, 0xF6, 0x3C, 0x30, 0x28, 0x2E, /* x */ 0x1F, 0xE7, 0xBB, 0xF4, 0x3F, 0xA7, 0x2C, 0x44, 0x6A, 0xF6, 0xF4, 0x61, 0x81, 0x29, 0x09, 0x7E, 0x2C, 0x56, 0x67, 0xC2, 0x22, 0x3A, 0x90, 0x2A, /* y */ 0xB5, 0xCA, 0x44, 0x9D, 0x00, 0x84, 0xB7, 0xE5, 0xB3, 0xDE, 0x7C, 0xCC, 0x01, 0xC9, 0xC3, 0x02, 0xF4, 0x1D, 0x93, 0x2A, 0x36, 0xCD, 0xA7, 0xA3, /* order */ 0x46, 0x2F, 0x9E, 0x9E, 0x91, 0x6B, 0x5B, 0xE8, 0xF1, 0x02, 0x9A, 0xC4, 0xAC, 0xC1 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 28 * 6]; } _EC_brainpoolP224r1 = { { NID_X9_62_prime_field, 0, 28, 1 }, { /* no seed */ 0xD7, 0xC1, 0x34, 0xAA, 0x26, 0x43, 0x66, 0x86, 0x2A, 0x18, /* p */ 0x30, 0x25, 0x75, 0xD1, 0xD7, 0x87, 0xB0, 0x9F, 0x07, 0x57, 0x97, 0xDA, 0x89, 0xF5, 0x7E, 0xC8, 0xC0, 0xFF, 0x68, 0xA5, 0xE6, 0x2C, 0xA9, 0xCE, 0x6C, 0x1C, 0x29, 0x98, /* a */ 0x03, 0xA6, 0xC1, 0x53, 0x0B, 0x51, 0x4E, 0x18, 0x2A, 0xD8, 0xB0, 0x04, 0x2A, 0x59, 0xCA, 0xD2, 0x9F, 0x43, 0x25, 0x80, 0xF6, 0x3C, 0xCF, 0xE4, 0x41, 0x38, 0x87, 0x07, /* b */ 0x13, 0xB1, 0xA9, 0x23, 0x69, 0xE3, 0x3E, 0x21, 0x35, 0xD2, 0x66, 0xDB, 0xB3, 0x72, 0x38, 0x6C, 0x40, 0x0B, 0x0D, 0x90, 0x29, 0xAD, 0x2C, 0x7E, 0x5C, 0xF4, 0x34, 0x08, /* x */ 0x23, 0xB2, 0xA8, 0x7D, 0xC6, 0x8C, 0x9E, 0x4C, 0xE3, 0x17, 0x4C, 0x1E, 0x6E, 0xFD, 0xEE, 0x12, 0xC0, 0x7D, 0x58, 0xAA, 0x56, 0xF7, 0x72, 0xC0, 0x72, 0x6F, 0x24, 0xC6, /* y */ 0xB8, 0x9E, 0x4E, 0xCD, 0xAC, 0x24, 0x35, 0x4B, 0x9E, 0x99, 0xCA, 0xA3, 0xF6, 0xD3, 0x76, 0x14, 0x02, 0xCD, 0xD7, 0xC1, 0x34, 0xAA, 0x26, 0x43, 0x66, 0x86, 0x2A, 0x18, /* order */ 0x30, 0x25, 0x75, 0xD0, 0xFB, 0x98, 0xD1, 0x16, 0xBC, 0x4B, 0x6D, 0xDE, 0xBC, 0xA3, 0xA5, 0xA7, 0x93, 0x9F } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 28 * 6]; } _EC_brainpoolP224t1 = { { NID_X9_62_prime_field, 0, 28, 1 }, { /* no seed */ 0xD7, 0xC1, 0x34, 0xAA, 0x26, 0x43, 0x66, 0x86, 0x2A, 0x18, /* p */ 0x30, 0x25, 0x75, 0xD1, 0xD7, 0x87, 0xB0, 0x9F, 0x07, 0x57, 0x97, 0xDA, 0x89, 0xF5, 0x7E, 0xC8, 0xC0, 0xFF, 0xD7, 0xC1, 0x34, 0xAA, 0x26, 0x43, 0x66, 0x86, 0x2A, 0x18, /* a */ 0x30, 0x25, 0x75, 0xD1, 0xD7, 0x87, 0xB0, 0x9F, 0x07, 0x57, 0x97, 0xDA, 0x89, 0xF5, 0x7E, 0xC8, 0xC0, 0xFC, 0x4B, 0x33, 0x7D, 0x93, 0x41, 0x04, 0xCD, 0x7B, 0xEF, 0x27, /* b */ 0x1B, 0xF6, 0x0C, 0xED, 0x1E, 0xD2, 0x0D, 0xA1, 0x4C, 0x08, 0xB3, 0xBB, 0x64, 0xF1, 0x8A, 0x60, 0x88, 0x8D, 0x6A, 0xB1, 0xE3, 0x44, 0xCE, 0x25, 0xFF, 0x38, 0x96, 0x42, /* x */ 0x4E, 0x7F, 0xFE, 0x14, 0x76, 0x2E, 0xCB, 0x49, 0xF8, 0x92, 0x8A, 0xC0, 0xC7, 0x60, 0x29, 0xB4, 0xD5, 0x80, 0x03, 0x74, 0xE9, 0xF5, 0x14, 0x3E, 0x56, 0x8C, 0xD2, 0x3F, /* y */ 0x3F, 0x4D, 0x7C, 0x0D, 0x4B, 0x1E, 0x41, 0xC8, 0xCC, 0x0D, 0x1C, 0x6A, 0xBD, 0x5F, 0x1A, 0x46, 0xDB, 0x4C, 0xD7, 0xC1, 0x34, 0xAA, 0x26, 0x43, 0x66, 0x86, 0x2A, 0x18, /* order */ 0x30, 0x25, 0x75, 0xD0, 0xFB, 0x98, 0xD1, 0x16, 0xBC, 0x4B, 0x6D, 0xDE, 0xBC, 0xA3, 0xA5, 0xA7, 0x93, 0x9F } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 32 * 6]; } _EC_brainpoolP256r1 = { { NID_X9_62_prime_field, 0, 32, 1 }, { /* no seed */ 0xA9, 0xFB, 0x57, 0xDB, 0xA1, 0xEE, 0xA9, 0xBC, 0x3E, 0x66, /* p */ 0x0A, 0x90, 0x9D, 0x83, 0x8D, 0x72, 0x6E, 0x3B, 0xF6, 0x23, 0xD5, 0x26, 0x20, 0x28, 0x20, 0x13, 0x48, 0x1D, 0x1F, 0x6E, 0x53, 0x77, 0x7D, 0x5A, 0x09, 0x75, 0xFC, 0x2C, 0x30, 0x57, 0xEE, 0xF6, /* a */ 0x75, 0x30, 0x41, 0x7A, 0xFF, 0xE7, 0xFB, 0x80, 0x55, 0xC1, 0x26, 0xDC, 0x5C, 0x6C, 0xE9, 0x4A, 0x4B, 0x44, 0xF3, 0x30, 0xB5, 0xD9, 0x26, 0xDC, 0x5C, 0x6C, 0xE9, 0x4A, 0x4B, 0x44, 0xF3, 0x30, /* b */ 0xB5, 0xD9, 0xBB, 0xD7, 0x7C, 0xBF, 0x95, 0x84, 0x16, 0x29, 0x5C, 0xF7, 0xE1, 0xCE, 0x6B, 0xCC, 0xDC, 0x18, 0xFF, 0x8C, 0x07, 0xB6, 0x8B, 0xD2, 0xAE, 0xB9, 0xCB, 0x7E, 0x57, 0xCB, 0x2C, 0x4B, /* x */ 0x48, 0x2F, 0xFC, 0x81, 0xB7, 0xAF, 0xB9, 0xDE, 0x27, 0xE1, 0xE3, 0xBD, 0x23, 0xC2, 0x3A, 0x44, 0x53, 0xBD, 0x9A, 0xCE, 0x32, 0x62, 0x54, 0x7E, 0xF8, 0x35, 0xC3, 0xDA, 0xC4, 0xFD, 0x97, 0xF8, /* y */ 0x46, 0x1A, 0x14, 0x61, 0x1D, 0xC9, 0xC2, 0x77, 0x45, 0x13, 0x2D, 0xED, 0x8E, 0x54, 0x5C, 0x1D, 0x54, 0xC7, 0x2F, 0x04, 0x69, 0x97, 0xA9, 0xFB, 0x57, 0xDB, 0xA1, 0xEE, 0xA9, 0xBC, 0x3E, 0x66, /* order */ 0x0A, 0x90, 0x9D, 0x83, 0x8D, 0x71, 0x8C, 0x39, 0x7A, 0xA3, 0xB5, 0x61, 0xA6, 0xF7, 0x90, 0x1E, 0x0E, 0x82, 0x97, 0x48, 0x56, 0xA7 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 32 * 6]; } _EC_brainpoolP256t1 = { { NID_X9_62_prime_field, 0, 32, 1 }, { /* no seed */ 0xA9, 0xFB, 0x57, 0xDB, 0xA1, 0xEE, 0xA9, 0xBC, 0x3E, 0x66, /* p */ 0x0A, 0x90, 0x9D, 0x83, 0x8D, 0x72, 0x6E, 0x3B, 0xF6, 0x23, 0xD5, 0x26, 0x20, 0x28, 0x20, 0x13, 0x48, 0x1D, 0x1F, 0x6E, 0x53, 0x77, 0xA9, 0xFB, 0x57, 0xDB, 0xA1, 0xEE, 0xA9, 0xBC, 0x3E, 0x66, /* a */ 0x0A, 0x90, 0x9D, 0x83, 0x8D, 0x72, 0x6E, 0x3B, 0xF6, 0x23, 0xD5, 0x26, 0x20, 0x28, 0x20, 0x13, 0x48, 0x1D, 0x1F, 0x6E, 0x53, 0x74, 0x66, 0x2C, 0x61, 0xC4, 0x30, 0xD8, 0x4E, 0xA4, 0xFE, 0x66, /* b */ 0xA7, 0x73, 0x3D, 0x0B, 0x76, 0xB7, 0xBF, 0x93, 0xEB, 0xC4, 0xAF, 0x2F, 0x49, 0x25, 0x6A, 0xE5, 0x81, 0x01, 0xFE, 0xE9, 0x2B, 0x04, 0xA3, 0xE8, 0xEB, 0x3C, 0xC1, 0xCF, 0xE7, 0xB7, 0x73, 0x22, /* x */ 0x13, 0xB2, 0x3A, 0x65, 0x61, 0x49, 0xAF, 0xA1, 0x42, 0xC4, 0x7A, 0xAF, 0xBC, 0x2B, 0x79, 0xA1, 0x91, 0x56, 0x2E, 0x13, 0x05, 0xF4, 0x2D, 0x99, 0x6C, 0x82, 0x34, 0x39, 0xC5, 0x6D, 0x7F, 0x7B, /* y */ 0x22, 0xE1, 0x46, 0x44, 0x41, 0x7E, 0x69, 0xBC, 0xB6, 0xDE, 0x39, 0xD0, 0x27, 0x00, 0x1D, 0xAB, 0xE8, 0xF3, 0x5B, 0x25, 0xC9, 0xBE, 0xA9, 0xFB, 0x57, 0xDB, 0xA1, 0xEE, 0xA9, 0xBC, 0x3E, 0x66, /* order */ 0x0A, 0x90, 0x9D, 0x83, 0x8D, 0x71, 0x8C, 0x39, 0x7A, 0xA3, 0xB5, 0x61, 0xA6, 0xF7, 0x90, 0x1E, 0x0E, 0x82, 0x97, 0x48, 0x56, 0xA7 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 40 * 6]; } _EC_brainpoolP320r1 = { { NID_X9_62_prime_field, 0, 40, 1 }, { /* no seed */ 0xD3, 0x5E, 0x47, 0x20, 0x36, 0xBC, 0x4F, 0xB7, 0xE1, 0x3C, /* p */ 0x78, 0x5E, 0xD2, 0x01, 0xE0, 0x65, 0xF9, 0x8F, 0xCF, 0xA6, 0xF6, 0xF4, 0x0D, 0xEF, 0x4F, 0x92, 0xB9, 0xEC, 0x78, 0x93, 0xEC, 0x28, 0xFC, 0xD4, 0x12, 0xB1, 0xF1, 0xB3, 0x2E, 0x27, 0x3E, 0xE3, 0x0B, 0x56, 0x8F, 0xBA, 0xB0, 0xF8, 0x83, 0xCC, /* a */ 0xEB, 0xD4, 0x6D, 0x3F, 0x3B, 0xB8, 0xA2, 0xA7, 0x35, 0x13, 0xF5, 0xEB, 0x79, 0xDA, 0x66, 0x19, 0x0E, 0xB0, 0x85, 0xFF, 0xA9, 0xF4, 0x92, 0xF3, 0x75, 0xA9, 0x7D, 0x86, 0x0E, 0xB4, 0x52, 0x08, 0x83, 0x94, 0x9D, 0xFD, 0xBC, 0x42, 0xD3, 0xAD, /* b */ 0x19, 0x86, 0x40, 0x68, 0x8A, 0x6F, 0xE1, 0x3F, 0x41, 0x34, 0x95, 0x54, 0xB4, 0x9A, 0xCC, 0x31, 0xDC, 0xCD, 0x88, 0x45, 0x39, 0x81, 0x6F, 0x5E, 0xB4, 0xAC, 0x8F, 0xB1, 0xF1, 0xA6, 0x43, 0xBD, 0x7E, 0x9A, 0xFB, 0x53, 0xD8, 0xB8, 0x52, 0x89, /* x */ 0xBC, 0xC4, 0x8E, 0xE5, 0xBF, 0xE6, 0xF2, 0x01, 0x37, 0xD1, 0x0A, 0x08, 0x7E, 0xB6, 0xE7, 0x87, 0x1E, 0x2A, 0x10, 0xA5, 0x99, 0xC7, 0x10, 0xAF, 0x8D, 0x0D, 0x39, 0xE2, 0x06, 0x11, 0x14, 0xFD, 0xD0, 0x55, 0x45, 0xEC, 0x1C, 0xC8, 0xAB, 0x40, /* y */ 0x93, 0x24, 0x7F, 0x77, 0x27, 0x5E, 0x07, 0x43, 0xFF, 0xED, 0x11, 0x71, 0x82, 0xEA, 0xA9, 0xC7, 0x78, 0x77, 0xAA, 0xAC, 0x6A, 0xC7, 0xD3, 0x52, 0x45, 0xD1, 0x69, 0x2E, 0x8E, 0xE1, 0xD3, 0x5E, 0x47, 0x20, 0x36, 0xBC, 0x4F, 0xB7, 0xE1, 0x3C, /* order */ 0x78, 0x5E, 0xD2, 0x01, 0xE0, 0x65, 0xF9, 0x8F, 0xCF, 0xA5, 0xB6, 0x8F, 0x12, 0xA3, 0x2D, 0x48, 0x2E, 0xC7, 0xEE, 0x86, 0x58, 0xE9, 0x86, 0x91, 0x55, 0x5B, 0x44, 0xC5, 0x93, 0x11 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 40 * 6]; } _EC_brainpoolP320t1 = { { NID_X9_62_prime_field, 0, 40, 1 }, { /* no seed */ 0xD3, 0x5E, 0x47, 0x20, 0x36, 0xBC, 0x4F, 0xB7, 0xE1, 0x3C, /* p */ 0x78, 0x5E, 0xD2, 0x01, 0xE0, 0x65, 0xF9, 0x8F, 0xCF, 0xA6, 0xF6, 0xF4, 0x0D, 0xEF, 0x4F, 0x92, 0xB9, 0xEC, 0x78, 0x93, 0xEC, 0x28, 0xFC, 0xD4, 0x12, 0xB1, 0xF1, 0xB3, 0x2E, 0x27, 0xD3, 0x5E, 0x47, 0x20, 0x36, 0xBC, 0x4F, 0xB7, 0xE1, 0x3C, /* a */ 0x78, 0x5E, 0xD2, 0x01, 0xE0, 0x65, 0xF9, 0x8F, 0xCF, 0xA6, 0xF6, 0xF4, 0x0D, 0xEF, 0x4F, 0x92, 0xB9, 0xEC, 0x78, 0x93, 0xEC, 0x28, 0xFC, 0xD4, 0x12, 0xB1, 0xF1, 0xB3, 0x2E, 0x24, 0xA7, 0xF5, 0x61, 0xE0, 0x38, 0xEB, 0x1E, 0xD5, 0x60, 0xB3, /* b */ 0xD1, 0x47, 0xDB, 0x78, 0x20, 0x13, 0x06, 0x4C, 0x19, 0xF2, 0x7E, 0xD2, 0x7C, 0x67, 0x80, 0xAA, 0xF7, 0x7F, 0xB8, 0xA5, 0x47, 0xCE, 0xB5, 0xB4, 0xFE, 0xF4, 0x22, 0x34, 0x03, 0x53, 0x92, 0x5B, 0xE9, 0xFB, 0x01, 0xAF, 0xC6, 0xFB, 0x4D, 0x3E, /* x */ 0x7D, 0x49, 0x90, 0x01, 0x0F, 0x81, 0x34, 0x08, 0xAB, 0x10, 0x6C, 0x4F, 0x09, 0xCB, 0x7E, 0xE0, 0x78, 0x68, 0xCC, 0x13, 0x6F, 0xFF, 0x33, 0x57, 0xF6, 0x24, 0xA2, 0x1B, 0xED, 0x52, 0x63, 0xBA, 0x3A, 0x7A, 0x27, 0x48, 0x3E, 0xBF, 0x66, 0x71, /* y */ 0xDB, 0xEF, 0x7A, 0xBB, 0x30, 0xEB, 0xEE, 0x08, 0x4E, 0x58, 0xA0, 0xB0, 0x77, 0xAD, 0x42, 0xA5, 0xA0, 0x98, 0x9D, 0x1E, 0xE7, 0x1B, 0x1B, 0x9B, 0xC0, 0x45, 0x5F, 0xB0, 0xD2, 0xC3, 0xD3, 0x5E, 0x47, 0x20, 0x36, 0xBC, 0x4F, 0xB7, 0xE1, 0x3C, /* order */ 0x78, 0x5E, 0xD2, 0x01, 0xE0, 0x65, 0xF9, 0x8F, 0xCF, 0xA5, 0xB6, 0x8F, 0x12, 0xA3, 0x2D, 0x48, 0x2E, 0xC7, 0xEE, 0x86, 0x58, 0xE9, 0x86, 0x91, 0x55, 0x5B, 0x44, 0xC5, 0x93, 0x11 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 48 * 6]; } _EC_brainpoolP384r1 = { { NID_X9_62_prime_field, 0, 48, 1 }, { /* no seed */ 0x8C, 0xB9, 0x1E, 0x82, 0xA3, 0x38, 0x6D, 0x28, 0x0F, 0x5D, /* p */ 0x6F, 0x7E, 0x50, 0xE6, 0x41, 0xDF, 0x15, 0x2F, 0x71, 0x09, 0xED, 0x54, 0x56, 0xB4, 0x12, 0xB1, 0xDA, 0x19, 0x7F, 0xB7, 0x11, 0x23, 0xAC, 0xD3, 0xA7, 0x29, 0x90, 0x1D, 0x1A, 0x71, 0x87, 0x47, 0x00, 0x13, 0x31, 0x07, 0xEC, 0x53, 0x7B, 0xC3, 0x82, 0xC6, 0x3D, 0x8C, 0x15, 0x0C, 0x3C, 0x72, /* a */ 0x08, 0x0A, 0xCE, 0x05, 0xAF, 0xA0, 0xC2, 0xBE, 0xA2, 0x8E, 0x4F, 0xB2, 0x27, 0x87, 0x13, 0x91, 0x65, 0xEF, 0xBA, 0x91, 0xF9, 0x0F, 0x8A, 0xA5, 0x81, 0x4A, 0x50, 0x3A, 0xD4, 0xEB, 0x04, 0xA8, 0xC7, 0xDD, 0x22, 0xCE, 0x28, 0x26, 0x04, 0xA8, 0xC7, 0xDD, 0x22, 0xCE, 0x28, 0x26, 0x8B, 0x39, /* b */ 0xB5, 0x54, 0x16, 0xF0, 0x44, 0x7C, 0x2F, 0xB7, 0x7D, 0xE1, 0x07, 0xDC, 0xD2, 0xA6, 0x2E, 0x88, 0x0E, 0xA5, 0x3E, 0xEB, 0x62, 0xD5, 0x7C, 0xB4, 0x39, 0x02, 0x95, 0xDB, 0xC9, 0x94, 0x3A, 0xB7, 0x86, 0x96, 0xFA, 0x50, 0x4C, 0x11, 0x1D, 0x1C, 0x64, 0xF0, 0x68, 0xCF, 0x45, 0xFF, 0xA2, 0xA6, /* x */ 0x3A, 0x81, 0xB7, 0xC1, 0x3F, 0x6B, 0x88, 0x47, 0xA3, 0xE7, 0x7E, 0xF1, 0x4F, 0xE3, 0xDB, 0x7F, 0xCA, 0xFE, 0x0C, 0xBD, 0x10, 0xE8, 0xE8, 0x26, 0xE0, 0x34, 0x36, 0xD6, 0x46, 0xAA, 0xEF, 0x87, 0xB2, 0xE2, 0x47, 0xD4, 0xAF, 0x1E, 0x8A, 0xBE, 0x1D, 0x75, 0x20, 0xF9, 0xC2, 0xA4, 0x5C, 0xB1, /* y */ 0xEB, 0x8E, 0x95, 0xCF, 0xD5, 0x52, 0x62, 0xB7, 0x0B, 0x29, 0xFE, 0xEC, 0x58, 0x64, 0xE1, 0x9C, 0x05, 0x4F, 0xF9, 0x91, 0x29, 0x28, 0x0E, 0x46, 0x46, 0x21, 0x77, 0x91, 0x81, 0x11, 0x42, 0x82, 0x03, 0x41, 0x26, 0x3C, 0x53, 0x15, 0x8C, 0xB9, 0x1E, 0x82, 0xA3, 0x38, 0x6D, 0x28, 0x0F, 0x5D, /* order */ 0x6F, 0x7E, 0x50, 0xE6, 0x41, 0xDF, 0x15, 0x2F, 0x71, 0x09, 0xED, 0x54, 0x56, 0xB3, 0x1F, 0x16, 0x6E, 0x6C, 0xAC, 0x04, 0x25, 0xA7, 0xCF, 0x3A, 0xB6, 0xAF, 0x6B, 0x7F, 0xC3, 0x10, 0x3B, 0x88, 0x32, 0x02, 0xE9, 0x04, 0x65, 0x65 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 48 * 6]; } _EC_brainpoolP384t1 = { { NID_X9_62_prime_field, 0, 48, 1 }, { /* no seed */ 0x8C, 0xB9, 0x1E, 0x82, 0xA3, 0x38, 0x6D, 0x28, 0x0F, 0x5D, /* p */ 0x6F, 0x7E, 0x50, 0xE6, 0x41, 0xDF, 0x15, 0x2F, 0x71, 0x09, 0xED, 0x54, 0x56, 0xB4, 0x12, 0xB1, 0xDA, 0x19, 0x7F, 0xB7, 0x11, 0x23, 0xAC, 0xD3, 0xA7, 0x29, 0x90, 0x1D, 0x1A, 0x71, 0x87, 0x47, 0x00, 0x13, 0x31, 0x07, 0xEC, 0x53, 0x8C, 0xB9, 0x1E, 0x82, 0xA3, 0x38, 0x6D, 0x28, 0x0F, 0x5D, /* a */ 0x6F, 0x7E, 0x50, 0xE6, 0x41, 0xDF, 0x15, 0x2F, 0x71, 0x09, 0xED, 0x54, 0x56, 0xB4, 0x12, 0xB1, 0xDA, 0x19, 0x7F, 0xB7, 0x11, 0x23, 0xAC, 0xD3, 0xA7, 0x29, 0x90, 0x1D, 0x1A, 0x71, 0x87, 0x47, 0x00, 0x13, 0x31, 0x07, 0xEC, 0x50, 0x7F, 0x51, 0x9E, 0xAD, 0xA7, 0xBD, 0xA8, 0x1B, 0xD8, 0x26, /* b */ 0xDB, 0xA6, 0x47, 0x91, 0x0F, 0x8C, 0x4B, 0x93, 0x46, 0xED, 0x8C, 0xCD, 0xC6, 0x4E, 0x4B, 0x1A, 0xBD, 0x11, 0x75, 0x6D, 0xCE, 0x1D, 0x20, 0x74, 0xAA, 0x26, 0x3B, 0x88, 0x80, 0x5C, 0xED, 0x70, 0x35, 0x5A, 0x33, 0xB4, 0x71, 0xEE, 0x18, 0xDE, 0x98, 0xB0, 0x2D, 0xB9, 0xA3, 0x06, 0xF2, 0xAF, /* x */ 0xCD, 0x72, 0x35, 0xF7, 0x2A, 0x81, 0x9B, 0x80, 0xAB, 0x12, 0xEB, 0xD6, 0x53, 0x17, 0x24, 0x76, 0xFE, 0xCD, 0x46, 0x2A, 0xAB, 0xFF, 0xC4, 0xFF, 0x19, 0x1B, 0x94, 0x6A, 0x5F, 0x54, 0xD8, 0xD0, 0xAA, 0x2F, 0x41, 0x88, 0x08, 0xCC, 0x25, 0xAB, 0x05, 0x69, 0x62, 0xD3, 0x06, 0x51, 0xA1, 0x14, /* y */ 0xAF, 0xD2, 0x75, 0x5A, 0xD3, 0x36, 0x74, 0x7F, 0x93, 0x47, 0x5B, 0x7A, 0x1F, 0xCA, 0x3B, 0x88, 0xF2, 0xB6, 0xA2, 0x08, 0xCC, 0xFE, 0x46, 0x94, 0x08, 0x58, 0x4D, 0xC2, 0xB2, 0x91, 0x26, 0x75, 0xBF, 0x5B, 0x9E, 0x58, 0x29, 0x28, 0x8C, 0xB9, 0x1E, 0x82, 0xA3, 0x38, 0x6D, 0x28, 0x0F, 0x5D, /* order */ 0x6F, 0x7E, 0x50, 0xE6, 0x41, 0xDF, 0x15, 0x2F, 0x71, 0x09, 0xED, 0x54, 0x56, 0xB3, 0x1F, 0x16, 0x6E, 0x6C, 0xAC, 0x04, 0x25, 0xA7, 0xCF, 0x3A, 0xB6, 0xAF, 0x6B, 0x7F, 0xC3, 0x10, 0x3B, 0x88, 0x32, 0x02, 0xE9, 0x04, 0x65, 0x65 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 64 * 6]; } _EC_brainpoolP512r1 = { { NID_X9_62_prime_field, 0, 64, 1 }, { /* no seed */ 0xAA, 0xDD, 0x9D, 0xB8, 0xDB, 0xE9, 0xC4, 0x8B, 0x3F, 0xD4, /* p */ 0xE6, 0xAE, 0x33, 0xC9, 0xFC, 0x07, 0xCB, 0x30, 0x8D, 0xB3, 0xB3, 0xC9, 0xD2, 0x0E, 0xD6, 0x63, 0x9C, 0xCA, 0x70, 0x33, 0x08, 0x71, 0x7D, 0x4D, 0x9B, 0x00, 0x9B, 0xC6, 0x68, 0x42, 0xAE, 0xCD, 0xA1, 0x2A, 0xE6, 0xA3, 0x80, 0xE6, 0x28, 0x81, 0xFF, 0x2F, 0x2D, 0x82, 0xC6, 0x85, 0x28, 0xAA, 0x60, 0x56, 0x58, 0x3A, 0x48, 0xF3, 0x78, 0x30, 0xA3, 0x31, 0x8B, 0x60, 0x3B, 0x89, 0xE2, 0x32, /* a */ 0x71, 0x45, 0xAC, 0x23, 0x4C, 0xC5, 0x94, 0xCB, 0xDD, 0x8D, 0x3D, 0xF9, 0x16, 0x10, 0xA8, 0x34, 0x41, 0xCA, 0xEA, 0x98, 0x63, 0xBC, 0x2D, 0xED, 0x5D, 0x5A, 0xA8, 0x25, 0x3A, 0xA1, 0x0A, 0x2E, 0xF1, 0xC9, 0x8B, 0x9A, 0xC8, 0xB5, 0x7F, 0x11, 0x17, 0xA7, 0x2B, 0xF2, 0xC7, 0xB9, 0xE7, 0xC1, 0xAC, 0x4D, 0x77, 0xFC, 0x94, 0xCA, 0x3D, 0xF9, 0x16, 0x10, 0xA8, 0x34, 0x41, 0xCA, 0xEA, 0x98, /* b */ 0x63, 0xBC, 0x2D, 0xED, 0x5D, 0x5A, 0xA8, 0x25, 0x3A, 0xA1, 0x0A, 0x2E, 0xF1, 0xC9, 0x8B, 0x9A, 0xC8, 0xB5, 0x7F, 0x11, 0x17, 0xA7, 0x2B, 0xF2, 0xC7, 0xB9, 0xE7, 0xC1, 0xAC, 0x4D, 0x77, 0xFC, 0x94, 0xCA, 0xDC, 0x08, 0x3E, 0x67, 0x98, 0x40, 0x50, 0xB7, 0x5E, 0xBA, 0xE5, 0xDD, 0x28, 0x09, 0xBD, 0x63, 0x80, 0x16, 0xF7, 0x23, 0x81, 0xAE, 0xE4, 0xBD, 0xD8, 0x2E, 0xD9, 0x64, 0x5A, 0x21, /* x */ 0x32, 0x2E, 0x9C, 0x4C, 0x6A, 0x93, 0x85, 0xED, 0x9F, 0x70, 0xB5, 0xD9, 0x16, 0xC1, 0xB4, 0x3B, 0x62, 0xEE, 0xF4, 0xD0, 0x09, 0x8E, 0xFF, 0x3B, 0x1F, 0x78, 0xE2, 0xD0, 0xD4, 0x8D, 0x50, 0xD1, 0x68, 0x7B, 0x93, 0xB9, 0x7D, 0x5F, 0x7C, 0x6D, 0x50, 0x47, 0x40, 0x6A, 0x5E, 0x68, 0x8B, 0x35, 0x22, 0x09, 0xBC, 0xB9, 0xF8, 0x22, 0x7D, 0xDE, 0x38, 0x5D, 0x56, 0x63, 0x32, 0xEC, 0xC0, 0xEA, /* y */ 0xBF, 0xA9, 0xCF, 0x78, 0x22, 0xFD, 0xF2, 0x09, 0xF7, 0x00, 0x24, 0xA5, 0x7B, 0x1A, 0xA0, 0x00, 0xC5, 0x5B, 0x88, 0x1F, 0x81, 0x11, 0xB2, 0xDC, 0xDE, 0x49, 0x4A, 0x5F, 0x48, 0x5E, 0x5B, 0xCA, 0x4B, 0xD8, 0x8A, 0x27, 0x63, 0xAE, 0xD1, 0xCA, 0x2B, 0x2F, 0xA8, 0xF0, 0x54, 0x06, 0x78, 0xCD, 0x1E, 0x0F, 0x3A, 0xD8, 0x08, 0x92, 0xAA, 0xDD, 0x9D, 0xB8, 0xDB, 0xE9, 0xC4, 0x8B, 0x3F, 0xD4, /* order */ 0xE6, 0xAE, 0x33, 0xC9, 0xFC, 0x07, 0xCB, 0x30, 0x8D, 0xB3, 0xB3, 0xC9, 0xD2, 0x0E, 0xD6, 0x63, 0x9C, 0xCA, 0x70, 0x33, 0x08, 0x70, 0x55, 0x3E, 0x5C, 0x41, 0x4C, 0xA9, 0x26, 0x19, 0x41, 0x86, 0x61, 0x19, 0x7F, 0xAC, 0x10, 0x47, 0x1D, 0xB1, 0xD3, 0x81, 0x08, 0x5D, 0xDA, 0xDD, 0xB5, 0x87, 0x96, 0x82, 0x9C, 0xA9, 0x00, 0x69 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 64 * 6]; } _EC_brainpoolP512t1 = { { NID_X9_62_prime_field, 0, 64, 1 }, { /* no seed */ 0xAA, 0xDD, 0x9D, 0xB8, 0xDB, 0xE9, 0xC4, 0x8B, 0x3F, 0xD4, /* p */ 0xE6, 0xAE, 0x33, 0xC9, 0xFC, 0x07, 0xCB, 0x30, 0x8D, 0xB3, 0xB3, 0xC9, 0xD2, 0x0E, 0xD6, 0x63, 0x9C, 0xCA, 0x70, 0x33, 0x08, 0x71, 0x7D, 0x4D, 0x9B, 0x00, 0x9B, 0xC6, 0x68, 0x42, 0xAE, 0xCD, 0xA1, 0x2A, 0xE6, 0xA3, 0x80, 0xE6, 0x28, 0x81, 0xFF, 0x2F, 0x2D, 0x82, 0xC6, 0x85, 0x28, 0xAA, 0x60, 0x56, 0x58, 0x3A, 0x48, 0xF3, 0xAA, 0xDD, 0x9D, 0xB8, 0xDB, 0xE9, 0xC4, 0x8B, 0x3F, 0xD4, /* a */ 0xE6, 0xAE, 0x33, 0xC9, 0xFC, 0x07, 0xCB, 0x30, 0x8D, 0xB3, 0xB3, 0xC9, 0xD2, 0x0E, 0xD6, 0x63, 0x9C, 0xCA, 0x70, 0x33, 0x08, 0x71, 0x7D, 0x4D, 0x9B, 0x00, 0x9B, 0xC6, 0x68, 0x42, 0xAE, 0xCD, 0xA1, 0x2A, 0xE6, 0xA3, 0x80, 0xE6, 0x28, 0x81, 0xFF, 0x2F, 0x2D, 0x82, 0xC6, 0x85, 0x28, 0xAA, 0x60, 0x56, 0x58, 0x3A, 0x48, 0xF0, 0x7C, 0xBB, 0xBC, 0xF9, 0x44, 0x1C, 0xFA, 0xB7, 0x6E, 0x18, /* b */ 0x90, 0xE4, 0x68, 0x84, 0xEA, 0xE3, 0x21, 0xF7, 0x0C, 0x0B, 0xCB, 0x49, 0x81, 0x52, 0x78, 0x97, 0x50, 0x4B, 0xEC, 0x3E, 0x36, 0xA6, 0x2B, 0xCD, 0xFA, 0x23, 0x04, 0x97, 0x65, 0x40, 0xF6, 0x45, 0x00, 0x85, 0xF2, 0xDA, 0xE1, 0x45, 0xC2, 0x25, 0x53, 0xB4, 0x65, 0x76, 0x36, 0x89, 0x18, 0x0E, 0xA2, 0x57, 0x18, 0x67, 0x42, 0x3E, 0x64, 0x0E, 0xCE, 0x5C, 0x12, 0x78, 0x87, 0x17, 0xB9, 0xC1, /* x */ 0xBA, 0x06, 0xCB, 0xC2, 0xA6, 0xFE, 0xBA, 0x85, 0x84, 0x24, 0x58, 0xC5, 0x6D, 0xDE, 0x9D, 0xB1, 0x75, 0x8D, 0x39, 0xC0, 0x31, 0x3D, 0x82, 0xBA, 0x51, 0x73, 0x5C, 0xDB, 0x3E, 0xA4, 0x99, 0xAA, 0x77, 0xA7, 0xD6, 0x94, 0x3A, 0x64, 0xF7, 0xA3, 0xF2, 0x5F, 0xE2, 0x6F, 0x06, 0xB5, 0x1B, 0xAA, 0x26, 0x96, 0xFA, 0x90, 0x35, 0xDA, 0x5B, 0x53, 0x4B, 0xD5, 0x95, 0xF5, 0xAF, 0x0F, 0xA2, 0xC8, /* y */ 0x92, 0x37, 0x6C, 0x84, 0xAC, 0xE1, 0xBB, 0x4E, 0x30, 0x19, 0xB7, 0x16, 0x34, 0xC0, 0x11, 0x31, 0x15, 0x9C, 0xAE, 0x03, 0xCE, 0xE9, 0xD9, 0x93, 0x21, 0x84, 0xBE, 0xEF, 0x21, 0x6B, 0xD7, 0x1D, 0xF2, 0xDA, 0xDF, 0x86, 0xA6, 0x27, 0x30, 0x6E, 0xCF, 0xF9, 0x6D, 0xBB, 0x8B, 0xAC, 0xE1, 0x98, 0xB6, 0x1E, 0x00, 0xF8, 0xB3, 0x32, 0xAA, 0xDD, 0x9D, 0xB8, 0xDB, 0xE9, 0xC4, 0x8B, 0x3F, 0xD4, /* order */ 0xE6, 0xAE, 0x33, 0xC9, 0xFC, 0x07, 0xCB, 0x30, 0x8D, 0xB3, 0xB3, 0xC9, 0xD2, 0x0E, 0xD6, 0x63, 0x9C, 0xCA, 0x70, 0x33, 0x08, 0x70, 0x55, 0x3E, 0x5C, 0x41, 0x4C, 0xA9, 0x26, 0x19, 0x41, 0x86, 0x61, 0x19, 0x7F, 0xAC, 0x10, 0x47, 0x1D, 0xB1, 0xD3, 0x81, 0x08, 0x5D, 0xDA, 0xDD, 0xB5, 0x87, 0x96, 0x82, 0x9C, 0xA9, 0x00, 0x69 } }; static const struct { EC_CURVE_DATA h; unsigned char data[0 + 32 * 6]; } _EC_FRP256v1 = { { NID_X9_62_prime_field, 0, 32, 1 }, { /* no seed */ 0xF1, 0xFD, 0x17, 0x8C, 0x0B, 0x3A, 0xD5, 0x8F, 0x10, 0x12, /* p */ 0x6D, 0xE8, 0xCE, 0x42, 0x43, 0x5B, 0x39, 0x61, 0xAD, 0xBC, 0xAB, 0xC8, 0xCA, 0x6D, 0xE8, 0xFC, 0xF3, 0x53, 0xD8, 0x6E, 0x9C, 0x03, 0xF1, 0xFD, 0x17, 0x8C, 0x0B, 0x3A, 0xD5, 0x8F, 0x10, 0x12, /* a */ 0x6D, 0xE8, 0xCE, 0x42, 0x43, 0x5B, 0x39, 0x61, 0xAD, 0xBC, 0xAB, 0xC8, 0xCA, 0x6D, 0xE8, 0xFC, 0xF3, 0x53, 0xD8, 0x6E, 0x9C, 0x00, 0xEE, 0x35, 0x3F, 0xCA, 0x54, 0x28, 0xA9, 0x30, 0x0D, 0x4A, /* b */ 0xBA, 0x75, 0x4A, 0x44, 0xC0, 0x0F, 0xDF, 0xEC, 0x0C, 0x9A, 0xE4, 0xB1, 0xA1, 0x80, 0x30, 0x75, 0xED, 0x96, 0x7B, 0x7B, 0xB7, 0x3F, 0xB6, 0xB3, 0xD4, 0xC3, 0x56, 0xC1, 0x39, 0xEB, 0x31, 0x18, /* x */ 0x3D, 0x47, 0x49, 0xD4, 0x23, 0x95, 0x8C, 0x27, 0xD2, 0xDC, 0xAF, 0x98, 0xB7, 0x01, 0x64, 0xC9, 0x7A, 0x2D, 0xD9, 0x8F, 0x5C, 0xFF, 0x61, 0x42, 0xE0, 0xF7, 0xC8, 0xB2, 0x04, 0x91, 0x1F, 0x92, /* y */ 0x71, 0xF0, 0xF3, 0xEC, 0xEF, 0x8C, 0x27, 0x01, 0xC3, 0x07, 0xE8, 0xE4, 0xC9, 0xE1, 0x83, 0x11, 0x5A, 0x15, 0x54, 0x06, 0x2C, 0xFB, 0xF1, 0xFD, 0x17, 0x8C, 0x0B, 0x3A, 0xD5, 0x8F, 0x10, 0x12, /* order */ 0x6D, 0xE8, 0xCE, 0x42, 0x43, 0x5B, 0x53, 0xDC, 0x67, 0xE1, 0x40, 0xD2, 0xBF, 0x94, 0x1F, 0xFD, 0xD4, 0x59, 0xC6, 0xD6, 0x55, 0xE1 } }; typedef struct _ec_list_element_st { int nid; const EC_CURVE_DATA *data; const EC_METHOD *(*meth) (void); const char *comment; } ec_list_element; static const ec_list_element curve_list[] = { /* prime field curves */ /* secg curves */ {NID_secp112r1, &_EC_SECG_PRIME_112R1.h, 0, "SECG/WTLS curve over a 112 bit prime field"}, {NID_secp112r2, &_EC_SECG_PRIME_112R2.h, 0, "SECG curve over a 112 bit prime field"}, {NID_secp128r1, &_EC_SECG_PRIME_128R1.h, 0, "SECG curve over a 128 bit prime field"}, {NID_secp128r2, &_EC_SECG_PRIME_128R2.h, 0, "SECG curve over a 128 bit prime field"}, {NID_secp160k1, &_EC_SECG_PRIME_160K1.h, 0, "SECG curve over a 160 bit prime field"}, {NID_secp160r1, &_EC_SECG_PRIME_160R1.h, 0, "SECG curve over a 160 bit prime field"}, {NID_secp160r2, &_EC_SECG_PRIME_160R2.h, 0, "SECG/WTLS curve over a 160 bit prime field"}, /* SECG secp192r1 is the same as X9.62 prime192v1 and hence omitted */ {NID_secp192k1, &_EC_SECG_PRIME_192K1.h, 0, "SECG curve over a 192 bit prime field"}, {NID_secp224k1, &_EC_SECG_PRIME_224K1.h, 0, "SECG curve over a 224 bit prime field"}, #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 {NID_secp224r1, &_EC_NIST_PRIME_224.h, EC_GFp_nistp224_method, "NIST/SECG curve over a 224 bit prime field"}, #else {NID_secp224r1, &_EC_NIST_PRIME_224.h, 0, "NIST/SECG curve over a 224 bit prime field"}, #endif {NID_secp256k1, &_EC_SECG_PRIME_256K1.h, 0, "SECG curve over a 256 bit prime field"}, /* SECG secp256r1 is the same as X9.62 prime256v1 and hence omitted */ {NID_secp384r1, &_EC_NIST_PRIME_384.h, 0, "NIST/SECG curve over a 384 bit prime field"}, #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 {NID_secp521r1, &_EC_NIST_PRIME_521.h, EC_GFp_nistp521_method, "NIST/SECG curve over a 521 bit prime field"}, #else {NID_secp521r1, &_EC_NIST_PRIME_521.h, 0, "NIST/SECG curve over a 521 bit prime field"}, #endif /* X9.62 curves */ {NID_X9_62_prime192v1, &_EC_NIST_PRIME_192.h, 0, "NIST/X9.62/SECG curve over a 192 bit prime field"}, {NID_X9_62_prime192v2, &_EC_X9_62_PRIME_192V2.h, 0, "X9.62 curve over a 192 bit prime field"}, {NID_X9_62_prime192v3, &_EC_X9_62_PRIME_192V3.h, 0, "X9.62 curve over a 192 bit prime field"}, {NID_X9_62_prime239v1, &_EC_X9_62_PRIME_239V1.h, 0, "X9.62 curve over a 239 bit prime field"}, {NID_X9_62_prime239v2, &_EC_X9_62_PRIME_239V2.h, 0, "X9.62 curve over a 239 bit prime field"}, {NID_X9_62_prime239v3, &_EC_X9_62_PRIME_239V3.h, 0, "X9.62 curve over a 239 bit prime field"}, #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 {NID_X9_62_prime256v1, &_EC_X9_62_PRIME_256V1.h, EC_GFp_nistp256_method, "X9.62/SECG curve over a 256 bit prime field"}, #else {NID_X9_62_prime256v1, &_EC_X9_62_PRIME_256V1.h, 0, "X9.62/SECG curve over a 256 bit prime field"}, #endif #ifndef OPENSSL_NO_EC2M /* characteristic two field curves */ /* NIST/SECG curves */ {NID_sect113r1, &_EC_SECG_CHAR2_113R1.h, 0, "SECG curve over a 113 bit binary field"}, {NID_sect113r2, &_EC_SECG_CHAR2_113R2.h, 0, "SECG curve over a 113 bit binary field"}, {NID_sect131r1, &_EC_SECG_CHAR2_131R1.h, 0, "SECG/WTLS curve over a 131 bit binary field"}, {NID_sect131r2, &_EC_SECG_CHAR2_131R2.h, 0, "SECG curve over a 131 bit binary field"}, {NID_sect163k1, &_EC_NIST_CHAR2_163K.h, 0, "NIST/SECG/WTLS curve over a 163 bit binary field"}, {NID_sect163r1, &_EC_SECG_CHAR2_163R1.h, 0, "SECG curve over a 163 bit binary field"}, {NID_sect163r2, &_EC_NIST_CHAR2_163B.h, 0, "NIST/SECG curve over a 163 bit binary field"}, {NID_sect193r1, &_EC_SECG_CHAR2_193R1.h, 0, "SECG curve over a 193 bit binary field"}, {NID_sect193r2, &_EC_SECG_CHAR2_193R2.h, 0, "SECG curve over a 193 bit binary field"}, {NID_sect233k1, &_EC_NIST_CHAR2_233K.h, 0, "NIST/SECG/WTLS curve over a 233 bit binary field"}, {NID_sect233r1, &_EC_NIST_CHAR2_233B.h, 0, "NIST/SECG/WTLS curve over a 233 bit binary field"}, {NID_sect239k1, &_EC_SECG_CHAR2_239K1.h, 0, "SECG curve over a 239 bit binary field"}, {NID_sect283k1, &_EC_NIST_CHAR2_283K.h, 0, "NIST/SECG curve over a 283 bit binary field"}, {NID_sect283r1, &_EC_NIST_CHAR2_283B.h, 0, "NIST/SECG curve over a 283 bit binary field"}, {NID_sect409k1, &_EC_NIST_CHAR2_409K.h, 0, "NIST/SECG curve over a 409 bit binary field"}, {NID_sect409r1, &_EC_NIST_CHAR2_409B.h, 0, "NIST/SECG curve over a 409 bit binary field"}, {NID_sect571k1, &_EC_NIST_CHAR2_571K.h, 0, "NIST/SECG curve over a 571 bit binary field"}, {NID_sect571r1, &_EC_NIST_CHAR2_571B.h, 0, "NIST/SECG curve over a 571 bit binary field"}, /* X9.62 curves */ {NID_X9_62_c2pnb163v1, &_EC_X9_62_CHAR2_163V1.h, 0, "X9.62 curve over a 163 bit binary field"}, {NID_X9_62_c2pnb163v2, &_EC_X9_62_CHAR2_163V2.h, 0, "X9.62 curve over a 163 bit binary field"}, {NID_X9_62_c2pnb163v3, &_EC_X9_62_CHAR2_163V3.h, 0, "X9.62 curve over a 163 bit binary field"}, {NID_X9_62_c2pnb176v1, &_EC_X9_62_CHAR2_176V1.h, 0, "X9.62 curve over a 176 bit binary field"}, {NID_X9_62_c2tnb191v1, &_EC_X9_62_CHAR2_191V1.h, 0, "X9.62 curve over a 191 bit binary field"}, {NID_X9_62_c2tnb191v2, &_EC_X9_62_CHAR2_191V2.h, 0, "X9.62 curve over a 191 bit binary field"}, {NID_X9_62_c2tnb191v3, &_EC_X9_62_CHAR2_191V3.h, 0, "X9.62 curve over a 191 bit binary field"}, {NID_X9_62_c2pnb208w1, &_EC_X9_62_CHAR2_208W1.h, 0, "X9.62 curve over a 208 bit binary field"}, {NID_X9_62_c2tnb239v1, &_EC_X9_62_CHAR2_239V1.h, 0, "X9.62 curve over a 239 bit binary field"}, {NID_X9_62_c2tnb239v2, &_EC_X9_62_CHAR2_239V2.h, 0, "X9.62 curve over a 239 bit binary field"}, {NID_X9_62_c2tnb239v3, &_EC_X9_62_CHAR2_239V3.h, 0, "X9.62 curve over a 239 bit binary field"}, {NID_X9_62_c2pnb272w1, &_EC_X9_62_CHAR2_272W1.h, 0, "X9.62 curve over a 272 bit binary field"}, {NID_X9_62_c2pnb304w1, &_EC_X9_62_CHAR2_304W1.h, 0, "X9.62 curve over a 304 bit binary field"}, {NID_X9_62_c2tnb359v1, &_EC_X9_62_CHAR2_359V1.h, 0, "X9.62 curve over a 359 bit binary field"}, {NID_X9_62_c2pnb368w1, &_EC_X9_62_CHAR2_368W1.h, 0, "X9.62 curve over a 368 bit binary field"}, {NID_X9_62_c2tnb431r1, &_EC_X9_62_CHAR2_431R1.h, 0, "X9.62 curve over a 431 bit binary field"}, /* * the WAP/WTLS curves [unlike SECG, spec has its own OIDs for curves * from X9.62] */ {NID_wap_wsg_idm_ecid_wtls1, &_EC_WTLS_1.h, 0, "WTLS curve over a 113 bit binary field"}, {NID_wap_wsg_idm_ecid_wtls3, &_EC_NIST_CHAR2_163K.h, 0, "NIST/SECG/WTLS curve over a 163 bit binary field"}, {NID_wap_wsg_idm_ecid_wtls4, &_EC_SECG_CHAR2_113R1.h, 0, "SECG curve over a 113 bit binary field"}, {NID_wap_wsg_idm_ecid_wtls5, &_EC_X9_62_CHAR2_163V1.h, 0, "X9.62 curve over a 163 bit binary field"}, #endif {NID_wap_wsg_idm_ecid_wtls6, &_EC_SECG_PRIME_112R1.h, 0, "SECG/WTLS curve over a 112 bit prime field"}, {NID_wap_wsg_idm_ecid_wtls7, &_EC_SECG_PRIME_160R2.h, 0, "SECG/WTLS curve over a 160 bit prime field"}, {NID_wap_wsg_idm_ecid_wtls8, &_EC_WTLS_8.h, 0, "WTLS curve over a 112 bit prime field"}, {NID_wap_wsg_idm_ecid_wtls9, &_EC_WTLS_9.h, 0, "WTLS curve over a 160 bit prime field"}, #ifndef OPENSSL_NO_EC2M {NID_wap_wsg_idm_ecid_wtls10, &_EC_NIST_CHAR2_233K.h, 0, "NIST/SECG/WTLS curve over a 233 bit binary field"}, {NID_wap_wsg_idm_ecid_wtls11, &_EC_NIST_CHAR2_233B.h, 0, "NIST/SECG/WTLS curve over a 233 bit binary field"}, #endif {NID_wap_wsg_idm_ecid_wtls12, &_EC_WTLS_12.h, 0, "WTLS curve over a 224 bit prime field"}, #ifndef OPENSSL_NO_EC2M /* IPSec curves */ {NID_ipsec3, &_EC_IPSEC_155_ID3.h, 0, "\n\tIPSec/IKE/Oakley curve #3 over a 155 bit binary field.\n" "\tNot suitable for ECDSA.\n\tQuestionable extension field!"}, {NID_ipsec4, &_EC_IPSEC_185_ID4.h, 0, "\n\tIPSec/IKE/Oakley curve #4 over a 185 bit binary field.\n" "\tNot suitable for ECDSA.\n\tQuestionable extension field!"}, #endif /* RFC 5639 curves */ {NID_brainpoolP160r1, &_EC_brainpoolP160r1.h, 0, "RFC 5639 curve over a 160 bit prime field"}, {NID_brainpoolP160t1, &_EC_brainpoolP160t1.h, 0, "RFC 5639 curve over a 160 bit prime field"}, {NID_brainpoolP192r1, &_EC_brainpoolP192r1.h, 0, "RFC 5639 curve over a 192 bit prime field"}, {NID_brainpoolP192t1, &_EC_brainpoolP192t1.h, 0, "RFC 5639 curve over a 192 bit prime field"}, {NID_brainpoolP224r1, &_EC_brainpoolP224r1.h, 0, "RFC 5639 curve over a 224 bit prime field"}, {NID_brainpoolP224t1, &_EC_brainpoolP224t1.h, 0, "RFC 5639 curve over a 224 bit prime field"}, {NID_brainpoolP256r1, &_EC_brainpoolP256r1.h, 0, "RFC 5639 curve over a 256 bit prime field"}, {NID_brainpoolP256t1, &_EC_brainpoolP256t1.h, 0, "RFC 5639 curve over a 256 bit prime field"}, {NID_brainpoolP320r1, &_EC_brainpoolP320r1.h, 0, "RFC 5639 curve over a 320 bit prime field"}, {NID_brainpoolP320t1, &_EC_brainpoolP320t1.h, 0, "RFC 5639 curve over a 320 bit prime field"}, {NID_brainpoolP384r1, &_EC_brainpoolP384r1.h, 0, "RFC 5639 curve over a 384 bit prime field"}, {NID_brainpoolP384t1, &_EC_brainpoolP384t1.h, 0, "RFC 5639 curve over a 384 bit prime field"}, {NID_brainpoolP512r1, &_EC_brainpoolP512r1.h, 0, "RFC 5639 curve over a 512 bit prime field"}, {NID_brainpoolP512t1, &_EC_brainpoolP512t1.h, 0, "RFC 5639 curve over a 512 bit prime field"}, /* ANSSI */ {NID_FRP256v1, &_EC_FRP256v1.h, 0, "FRP256v1"} }; #define curve_list_length (sizeof(curve_list)/sizeof(ec_list_element)) static EC_GROUP * ec_group_new_from_data(const ec_list_element curve) { EC_GROUP *group = NULL; EC_POINT *P = NULL; BN_CTX *ctx = NULL; BIGNUM *p = NULL, *a = NULL, *b = NULL, *x = NULL, *y = NULL, *order = NULL; int ok = 0; int seed_len, param_len; const EC_METHOD *meth; const EC_CURVE_DATA *data; const unsigned char *params; if ((ctx = BN_CTX_new()) == NULL) { ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_MALLOC_FAILURE); goto err; } data = curve.data; seed_len = data->seed_len; param_len = data->param_len; params = (const unsigned char *) (data + 1); /* skip header */ params += seed_len; /* skip seed */ if (!(p = BN_bin2bn(params + 0 * param_len, param_len, NULL)) || !(a = BN_bin2bn(params + 1 * param_len, param_len, NULL)) || !(b = BN_bin2bn(params + 2 * param_len, param_len, NULL))) { ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); goto err; } if (curve.meth != 0) { meth = curve.meth(); if (((group = EC_GROUP_new(meth)) == NULL) || (!(group->meth->group_set_curve(group, p, a, b, ctx)))) { ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); goto err; } } else if (data->field_type == NID_X9_62_prime_field) { if ((group = EC_GROUP_new_curve_GFp(p, a, b, ctx)) == NULL) { ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); goto err; } } #ifndef OPENSSL_NO_EC2M else { /* field_type == * NID_X9_62_characteristic_two_field */ if ((group = EC_GROUP_new_curve_GF2m(p, a, b, ctx)) == NULL) { ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); goto err; } } #endif if ((P = EC_POINT_new(group)) == NULL) { ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); goto err; } if (!(x = BN_bin2bn(params + 3 * param_len, param_len, NULL)) || !(y = BN_bin2bn(params + 4 * param_len, param_len, NULL))) { ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); goto err; } if (!EC_POINT_set_affine_coordinates_GFp(group, P, x, y, ctx)) { ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); goto err; } if (!(order = BN_bin2bn(params + 5 * param_len, param_len, NULL)) || !BN_set_word(x, (BN_ULONG) data->cofactor)) { ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); goto err; } if (!EC_GROUP_set_generator(group, P, order, x)) { ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); goto err; } if (seed_len) { if (!EC_GROUP_set_seed(group, params - seed_len, seed_len)) { ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); goto err; } } ok = 1; err: if (!ok) { EC_GROUP_free(group); group = NULL; } if (P) EC_POINT_free(P); if (ctx) BN_CTX_free(ctx); if (p) BN_free(p); if (a) BN_free(a); if (b) BN_free(b); if (order) BN_free(order); if (x) BN_free(x); if (y) BN_free(y); return group; } EC_GROUP * EC_GROUP_new_by_curve_name(int nid) { size_t i; EC_GROUP *ret = NULL; if (nid <= 0) return NULL; for (i = 0; i < curve_list_length; i++) if (curve_list[i].nid == nid) { ret = ec_group_new_from_data(curve_list[i]); break; } if (ret == NULL) { ECerr(EC_F_EC_GROUP_NEW_BY_CURVE_NAME, EC_R_UNKNOWN_GROUP); return NULL; } EC_GROUP_set_curve_name(ret, nid); return ret; } size_t EC_get_builtin_curves(EC_builtin_curve * r, size_t nitems) { size_t i, min; if (r == NULL || nitems == 0) return curve_list_length; min = nitems < curve_list_length ? nitems : curve_list_length; for (i = 0; i < min; i++) { r[i].nid = curve_list[i].nid; r[i].comment = curve_list[i].comment; } return curve_list_length; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ecp_mont.c0000644000175000017500000002125612360020705020620 0ustar /* $OpenBSD$ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * Portions of this software developed by SUN MICROSYSTEMS, INC., * and contributed to the OpenSSL project. */ #include #include "ec_lcl.h" const EC_METHOD * EC_GFp_mont_method(void) { static const EC_METHOD ret = { .flags = EC_FLAGS_DEFAULT_OCT, .field_type = NID_X9_62_prime_field, .group_init = ec_GFp_mont_group_init, .group_finish = ec_GFp_mont_group_finish, .group_clear_finish = ec_GFp_mont_group_clear_finish, .group_copy = ec_GFp_mont_group_copy, .group_set_curve = ec_GFp_mont_group_set_curve, .group_get_curve = ec_GFp_simple_group_get_curve, .group_get_degree = ec_GFp_simple_group_get_degree, .group_check_discriminant = ec_GFp_simple_group_check_discriminant, .point_init = ec_GFp_simple_point_init, .point_finish = ec_GFp_simple_point_finish, .point_clear_finish = ec_GFp_simple_point_clear_finish, .point_copy = ec_GFp_simple_point_copy, .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, .point_set_Jprojective_coordinates_GFp = ec_GFp_simple_set_Jprojective_coordinates_GFp, .point_get_Jprojective_coordinates_GFp = ec_GFp_simple_get_Jprojective_coordinates_GFp, .point_set_affine_coordinates = ec_GFp_simple_point_set_affine_coordinates, .point_get_affine_coordinates = ec_GFp_simple_point_get_affine_coordinates, .add = ec_GFp_simple_add, .dbl = ec_GFp_simple_dbl, .invert = ec_GFp_simple_invert, .is_at_infinity = ec_GFp_simple_is_at_infinity, .is_on_curve = ec_GFp_simple_is_on_curve, .point_cmp = ec_GFp_simple_cmp, .make_affine = ec_GFp_simple_make_affine, .points_make_affine = ec_GFp_simple_points_make_affine, .field_mul = ec_GFp_mont_field_mul, .field_sqr = ec_GFp_mont_field_sqr, .field_encode = ec_GFp_mont_field_encode, .field_decode = ec_GFp_mont_field_decode, .field_set_to_one = ec_GFp_mont_field_set_to_one }; return &ret; } int ec_GFp_mont_group_init(EC_GROUP * group) { int ok; ok = ec_GFp_simple_group_init(group); group->field_data1 = NULL; group->field_data2 = NULL; return ok; } void ec_GFp_mont_group_finish(EC_GROUP * group) { if (group->field_data1 != NULL) { BN_MONT_CTX_free(group->field_data1); group->field_data1 = NULL; } if (group->field_data2 != NULL) { BN_free(group->field_data2); group->field_data2 = NULL; } ec_GFp_simple_group_finish(group); } void ec_GFp_mont_group_clear_finish(EC_GROUP * group) { if (group->field_data1 != NULL) { BN_MONT_CTX_free(group->field_data1); group->field_data1 = NULL; } if (group->field_data2 != NULL) { BN_clear_free(group->field_data2); group->field_data2 = NULL; } ec_GFp_simple_group_clear_finish(group); } int ec_GFp_mont_group_copy(EC_GROUP * dest, const EC_GROUP * src) { if (dest->field_data1 != NULL) { BN_MONT_CTX_free(dest->field_data1); dest->field_data1 = NULL; } if (dest->field_data2 != NULL) { BN_clear_free(dest->field_data2); dest->field_data2 = NULL; } if (!ec_GFp_simple_group_copy(dest, src)) return 0; if (src->field_data1 != NULL) { dest->field_data1 = BN_MONT_CTX_new(); if (dest->field_data1 == NULL) return 0; if (!BN_MONT_CTX_copy(dest->field_data1, src->field_data1)) goto err; } if (src->field_data2 != NULL) { dest->field_data2 = BN_dup(src->field_data2); if (dest->field_data2 == NULL) goto err; } return 1; err: if (dest->field_data1 != NULL) { BN_MONT_CTX_free(dest->field_data1); dest->field_data1 = NULL; } return 0; } int ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { BN_CTX *new_ctx = NULL; BN_MONT_CTX *mont = NULL; BIGNUM *one = NULL; int ret = 0; if (group->field_data1 != NULL) { BN_MONT_CTX_free(group->field_data1); group->field_data1 = NULL; } if (group->field_data2 != NULL) { BN_free(group->field_data2); group->field_data2 = NULL; } if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } mont = BN_MONT_CTX_new(); if (mont == NULL) goto err; if (!BN_MONT_CTX_set(mont, p, ctx)) { ECerr(EC_F_EC_GFP_MONT_GROUP_SET_CURVE, ERR_R_BN_LIB); goto err; } one = BN_new(); if (one == NULL) goto err; if (!BN_to_montgomery(one, BN_value_one(), mont, ctx)) goto err; group->field_data1 = mont; mont = NULL; group->field_data2 = one; one = NULL; ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); if (!ret) { BN_MONT_CTX_free(group->field_data1); group->field_data1 = NULL; BN_free(group->field_data2); group->field_data2 = NULL; } err: if (new_ctx != NULL) BN_CTX_free(new_ctx); if (mont != NULL) BN_MONT_CTX_free(mont); return ret; } int ec_GFp_mont_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { if (group->field_data1 == NULL) { ECerr(EC_F_EC_GFP_MONT_FIELD_MUL, EC_R_NOT_INITIALIZED); return 0; } return BN_mod_mul_montgomery(r, a, b, group->field_data1, ctx); } int ec_GFp_mont_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) { if (group->field_data1 == NULL) { ECerr(EC_F_EC_GFP_MONT_FIELD_SQR, EC_R_NOT_INITIALIZED); return 0; } return BN_mod_mul_montgomery(r, a, a, group->field_data1, ctx); } int ec_GFp_mont_field_encode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) { if (group->field_data1 == NULL) { ECerr(EC_F_EC_GFP_MONT_FIELD_ENCODE, EC_R_NOT_INITIALIZED); return 0; } return BN_to_montgomery(r, a, (BN_MONT_CTX *) group->field_data1, ctx); } int ec_GFp_mont_field_decode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) { if (group->field_data1 == NULL) { ECerr(EC_F_EC_GFP_MONT_FIELD_DECODE, EC_R_NOT_INITIALIZED); return 0; } return BN_from_montgomery(r, a, group->field_data1, ctx); } int ec_GFp_mont_field_set_to_one(const EC_GROUP *group, BIGNUM *r, BN_CTX *ctx) { if (group->field_data2 == NULL) { ECerr(EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE, EC_R_NOT_INITIALIZED); return 0; } if (!BN_copy(r, group->field_data2)) return 0; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ec2_mult.c0000644000175000017500000003046612360020705020531 0ustar /* $OpenBSD: ec2_mult.c,v 1.3 2014/06/12 15:49:29 deraadt Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * The Elliptic Curve Public-Key Crypto Library (ECC Code) included * herein is developed by SUN MICROSYSTEMS, INC., and is contributed * to the OpenSSL project. * * The ECC Code is licensed pursuant to the OpenSSL open source * license provided below. * * The software is originally written by Sheueling Chang Shantz and * Douglas Stebila of Sun Microsystems Laboratories. * */ /* ==================================================================== * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "ec_lcl.h" #ifndef OPENSSL_NO_EC2M /* Compute the x-coordinate x/z for the point 2*(x/z) in Montgomery projective * coordinates. * Uses algorithm Mdouble in appendix of * Lopez, J. and Dahab, R. "Fast multiplication on elliptic curves over * GF(2^m) without precomputation" (CHES '99, LNCS 1717). * modified to not require precomputation of c=b^{2^{m-1}}. */ static int gf2m_Mdouble(const EC_GROUP *group, BIGNUM *x, BIGNUM *z, BN_CTX *ctx) { BIGNUM *t1; int ret = 0; /* Since Mdouble is static we can guarantee that ctx != NULL. */ BN_CTX_start(ctx); t1 = BN_CTX_get(ctx); if (t1 == NULL) goto err; if (!group->meth->field_sqr(group, x, x, ctx)) goto err; if (!group->meth->field_sqr(group, t1, z, ctx)) goto err; if (!group->meth->field_mul(group, z, x, t1, ctx)) goto err; if (!group->meth->field_sqr(group, x, x, ctx)) goto err; if (!group->meth->field_sqr(group, t1, t1, ctx)) goto err; if (!group->meth->field_mul(group, t1, &group->b, t1, ctx)) goto err; if (!BN_GF2m_add(x, x, t1)) goto err; ret = 1; err: BN_CTX_end(ctx); return ret; } /* Compute the x-coordinate x1/z1 for the point (x1/z1)+(x2/x2) in Montgomery * projective coordinates. * Uses algorithm Madd in appendix of * Lopez, J. and Dahab, R. "Fast multiplication on elliptic curves over * GF(2^m) without precomputation" (CHES '99, LNCS 1717). */ static int gf2m_Madd(const EC_GROUP *group, const BIGNUM *x, BIGNUM *x1, BIGNUM *z1, const BIGNUM *x2, const BIGNUM *z2, BN_CTX *ctx) { BIGNUM *t1, *t2; int ret = 0; /* Since Madd is static we can guarantee that ctx != NULL. */ BN_CTX_start(ctx); t1 = BN_CTX_get(ctx); t2 = BN_CTX_get(ctx); if (t2 == NULL) goto err; if (!BN_copy(t1, x)) goto err; if (!group->meth->field_mul(group, x1, x1, z2, ctx)) goto err; if (!group->meth->field_mul(group, z1, z1, x2, ctx)) goto err; if (!group->meth->field_mul(group, t2, x1, z1, ctx)) goto err; if (!BN_GF2m_add(z1, z1, x1)) goto err; if (!group->meth->field_sqr(group, z1, z1, ctx)) goto err; if (!group->meth->field_mul(group, x1, z1, t1, ctx)) goto err; if (!BN_GF2m_add(x1, x1, t2)) goto err; ret = 1; err: BN_CTX_end(ctx); return ret; } /* Compute the x, y affine coordinates from the point (x1, z1) (x2, z2) * using Montgomery point multiplication algorithm Mxy() in appendix of * Lopez, J. and Dahab, R. "Fast multiplication on elliptic curves over * GF(2^m) without precomputation" (CHES '99, LNCS 1717). * Returns: * 0 on error * 1 if return value should be the point at infinity * 2 otherwise */ static int gf2m_Mxy(const EC_GROUP *group, const BIGNUM *x, const BIGNUM *y, BIGNUM *x1, BIGNUM *z1, BIGNUM *x2, BIGNUM *z2, BN_CTX *ctx) { BIGNUM *t3, *t4, *t5; int ret = 0; if (BN_is_zero(z1)) { BN_zero(x2); BN_zero(z2); return 1; } if (BN_is_zero(z2)) { if (!BN_copy(x2, x)) return 0; if (!BN_GF2m_add(z2, x, y)) return 0; return 2; } /* Since Mxy is static we can guarantee that ctx != NULL. */ BN_CTX_start(ctx); t3 = BN_CTX_get(ctx); t4 = BN_CTX_get(ctx); t5 = BN_CTX_get(ctx); if (t5 == NULL) goto err; if (!BN_one(t5)) goto err; if (!group->meth->field_mul(group, t3, z1, z2, ctx)) goto err; if (!group->meth->field_mul(group, z1, z1, x, ctx)) goto err; if (!BN_GF2m_add(z1, z1, x1)) goto err; if (!group->meth->field_mul(group, z2, z2, x, ctx)) goto err; if (!group->meth->field_mul(group, x1, z2, x1, ctx)) goto err; if (!BN_GF2m_add(z2, z2, x2)) goto err; if (!group->meth->field_mul(group, z2, z2, z1, ctx)) goto err; if (!group->meth->field_sqr(group, t4, x, ctx)) goto err; if (!BN_GF2m_add(t4, t4, y)) goto err; if (!group->meth->field_mul(group, t4, t4, t3, ctx)) goto err; if (!BN_GF2m_add(t4, t4, z2)) goto err; if (!group->meth->field_mul(group, t3, t3, x, ctx)) goto err; if (!group->meth->field_div(group, t3, t5, t3, ctx)) goto err; if (!group->meth->field_mul(group, t4, t3, t4, ctx)) goto err; if (!group->meth->field_mul(group, x2, x1, t3, ctx)) goto err; if (!BN_GF2m_add(z2, x2, x)) goto err; if (!group->meth->field_mul(group, z2, z2, t4, ctx)) goto err; if (!BN_GF2m_add(z2, z2, y)) goto err; ret = 2; err: BN_CTX_end(ctx); return ret; } /* Computes scalar*point and stores the result in r. * point can not equal r. * Uses a modified algorithm 2P of * Lopez, J. and Dahab, R. "Fast multiplication on elliptic curves over * GF(2^m) without precomputation" (CHES '99, LNCS 1717). * * To protect against side-channel attack the function uses constant time swap, * avoiding conditional branches. */ static int ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, const EC_POINT *point, BN_CTX *ctx) { BIGNUM *x1, *x2, *z1, *z2; int ret = 0, i; BN_ULONG mask, word; if (r == point) { ECerr(EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY, EC_R_INVALID_ARGUMENT); return 0; } /* if result should be point at infinity */ if ((scalar == NULL) || BN_is_zero(scalar) || (point == NULL) || EC_POINT_is_at_infinity(group, point)) { return EC_POINT_set_to_infinity(group, r); } /* only support affine coordinates */ if (!point->Z_is_one) return 0; /* Since point_multiply is static we can guarantee that ctx != NULL. */ BN_CTX_start(ctx); x1 = BN_CTX_get(ctx); z1 = BN_CTX_get(ctx); if (z1 == NULL) goto err; x2 = &r->X; z2 = &r->Y; bn_wexpand(x1, group->field.top); bn_wexpand(z1, group->field.top); bn_wexpand(x2, group->field.top); bn_wexpand(z2, group->field.top); if (!BN_GF2m_mod_arr(x1, &point->X, group->poly)) goto err; /* x1 = x */ if (!BN_one(z1)) goto err; /* z1 = 1 */ if (!group->meth->field_sqr(group, z2, x1, ctx)) goto err; /* z2 = x1^2 = x^2 */ if (!group->meth->field_sqr(group, x2, z2, ctx)) goto err; if (!BN_GF2m_add(x2, x2, &group->b)) goto err; /* x2 = x^4 + b */ /* find top most bit and go one past it */ i = scalar->top - 1; mask = BN_TBIT; word = scalar->d[i]; while (!(word & mask)) mask >>= 1; mask >>= 1; /* if top most bit was at word break, go to next word */ if (!mask) { i--; mask = BN_TBIT; } for (; i >= 0; i--) { word = scalar->d[i]; while (mask) { BN_consttime_swap(word & mask, x1, x2, group->field.top); BN_consttime_swap(word & mask, z1, z2, group->field.top); if (!gf2m_Madd(group, &point->X, x2, z2, x1, z1, ctx)) goto err; if (!gf2m_Mdouble(group, x1, z1, ctx)) goto err; BN_consttime_swap(word & mask, x1, x2, group->field.top); BN_consttime_swap(word & mask, z1, z2, group->field.top); mask >>= 1; } mask = BN_TBIT; } /* convert out of "projective" coordinates */ i = gf2m_Mxy(group, &point->X, &point->Y, x1, z1, x2, z2, ctx); if (i == 0) goto err; else if (i == 1) { if (!EC_POINT_set_to_infinity(group, r)) goto err; } else { if (!BN_one(&r->Z)) goto err; r->Z_is_one = 1; } /* GF(2^m) field elements should always have BIGNUM::neg = 0 */ BN_set_negative(&r->X, 0); BN_set_negative(&r->Y, 0); ret = 1; err: BN_CTX_end(ctx); return ret; } /* Computes the sum * scalar*group->generator + scalars[0]*points[0] + ... + scalars[num-1]*points[num-1] * gracefully ignoring NULL scalar values. */ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx) { BN_CTX *new_ctx = NULL; int ret = 0; size_t i; EC_POINT *p = NULL; EC_POINT *acc = NULL; if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } /* * This implementation is more efficient than the wNAF implementation * for 2 or fewer points. Use the ec_wNAF_mul implementation for 3 * or more points, or if we can perform a fast multiplication based * on precomputation. */ if ((scalar && (num > 1)) || (num > 2) || (num == 0 && EC_GROUP_have_precompute_mult(group))) { ret = ec_wNAF_mul(group, r, scalar, num, points, scalars, ctx); goto err; } if ((p = EC_POINT_new(group)) == NULL) goto err; if ((acc = EC_POINT_new(group)) == NULL) goto err; if (!EC_POINT_set_to_infinity(group, acc)) goto err; if (scalar) { if (!ec_GF2m_montgomery_point_multiply(group, p, scalar, group->generator, ctx)) goto err; if (BN_is_negative(scalar)) if (!group->meth->invert(group, p, ctx)) goto err; if (!group->meth->add(group, acc, acc, p, ctx)) goto err; } for (i = 0; i < num; i++) { if (!ec_GF2m_montgomery_point_multiply(group, p, scalars[i], points[i], ctx)) goto err; if (BN_is_negative(scalars[i])) if (!group->meth->invert(group, p, ctx)) goto err; if (!group->meth->add(group, acc, acc, p, ctx)) goto err; } if (!EC_POINT_copy(r, acc)) goto err; ret = 1; err: if (p) EC_POINT_free(p); if (acc) EC_POINT_free(acc); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } /* Precomputation for point multiplication: fall back to wNAF methods * because ec_GF2m_simple_mul() uses ec_wNAF_mul() if appropriate */ int ec_GF2m_precompute_mult(EC_GROUP * group, BN_CTX * ctx) { return ec_wNAF_precompute_mult(group, ctx); } int ec_GF2m_have_precompute_mult(const EC_GROUP * group) { return ec_wNAF_have_precompute_mult(group); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ec/ec2_oct.c0000644000175000017500000002547512360020705020341 0ustar /* $OpenBSD: ec2_oct.c,v 1.3 2014/06/12 15:49:29 deraadt Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * The Elliptic Curve Public-Key Crypto Library (ECC Code) included * herein is developed by SUN MICROSYSTEMS, INC., and is contributed * to the OpenSSL project. * * The ECC Code is licensed pursuant to the OpenSSL open source * license provided below. * * The software is originally written by Sheueling Chang Shantz and * Douglas Stebila of Sun Microsystems Laboratories. * */ /* ==================================================================== * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "ec_lcl.h" #ifndef OPENSSL_NO_EC2M /* Calculates and sets the affine coordinates of an EC_POINT from the given * compressed coordinates. Uses algorithm 2.3.4 of SEC 1. * Note that the simple implementation only uses affine coordinates. * * The method is from the following publication: * * Harper, Menezes, Vanstone: * "Public-Key Cryptosystems with Very Small Key Lengths", * EUROCRYPT '92, Springer-Verlag LNCS 658, * published February 1993 * * US Patents 6,141,420 and 6,618,483 (Vanstone, Mullin, Agnew) describe * the same method, but claim no priority date earlier than July 29, 1994 * (and additionally fail to cite the EUROCRYPT '92 publication as prior art). */ int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point, const BIGNUM *x_, int y_bit, BN_CTX *ctx) { BN_CTX *new_ctx = NULL; BIGNUM *tmp, *x, *y, *z; int ret = 0, z0; /* clear error queue */ ERR_clear_error(); if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } y_bit = (y_bit != 0) ? 1 : 0; BN_CTX_start(ctx); tmp = BN_CTX_get(ctx); x = BN_CTX_get(ctx); y = BN_CTX_get(ctx); z = BN_CTX_get(ctx); if (z == NULL) goto err; if (!BN_GF2m_mod_arr(x, x_, group->poly)) goto err; if (BN_is_zero(x)) { if (!BN_GF2m_mod_sqrt_arr(y, &group->b, group->poly, ctx)) goto err; } else { if (!group->meth->field_sqr(group, tmp, x, ctx)) goto err; if (!group->meth->field_div(group, tmp, &group->b, tmp, ctx)) goto err; if (!BN_GF2m_add(tmp, &group->a, tmp)) goto err; if (!BN_GF2m_add(tmp, x, tmp)) goto err; if (!BN_GF2m_mod_solve_quad_arr(z, tmp, group->poly, ctx)) { unsigned long err = ERR_peek_last_error(); if (ERR_GET_LIB(err) == ERR_LIB_BN && ERR_GET_REASON(err) == BN_R_NO_SOLUTION) { ERR_clear_error(); ECerr(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES, EC_R_INVALID_COMPRESSED_POINT); } else ECerr(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES, ERR_R_BN_LIB); goto err; } z0 = (BN_is_odd(z)) ? 1 : 0; if (!group->meth->field_mul(group, y, x, z, ctx)) goto err; if (z0 != y_bit) { if (!BN_GF2m_add(y, y, x)) goto err; } } if (!EC_POINT_set_affine_coordinates_GF2m(group, point, x, y, ctx)) goto err; ret = 1; err: BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } /* Converts an EC_POINT to an octet string. * If buf is NULL, the encoded length will be returned. * If the length len of buf is smaller than required an error will be returned. */ size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form, unsigned char *buf, size_t len, BN_CTX * ctx) { size_t ret; BN_CTX *new_ctx = NULL; int used_ctx = 0; BIGNUM *x, *y, *yxi; size_t field_len, i, skip; if ((form != POINT_CONVERSION_COMPRESSED) && (form != POINT_CONVERSION_UNCOMPRESSED) && (form != POINT_CONVERSION_HYBRID)) { ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, EC_R_INVALID_FORM); goto err; } if (EC_POINT_is_at_infinity(group, point)) { /* encodes to a single 0 octet */ if (buf != NULL) { if (len < 1) { ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL); return 0; } buf[0] = 0; } return 1; } /* ret := required output buffer length */ field_len = (EC_GROUP_get_degree(group) + 7) / 8; ret = (form == POINT_CONVERSION_COMPRESSED) ? 1 + field_len : 1 + 2 * field_len; /* if 'buf' is NULL, just return required length */ if (buf != NULL) { if (len < ret) { ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL); goto err; } if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } BN_CTX_start(ctx); used_ctx = 1; x = BN_CTX_get(ctx); y = BN_CTX_get(ctx); yxi = BN_CTX_get(ctx); if (yxi == NULL) goto err; if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx)) goto err; buf[0] = form; if ((form != POINT_CONVERSION_UNCOMPRESSED) && !BN_is_zero(x)) { if (!group->meth->field_div(group, yxi, y, x, ctx)) goto err; if (BN_is_odd(yxi)) buf[0]++; } i = 1; skip = field_len - BN_num_bytes(x); if (skip > field_len) { ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); goto err; } while (skip > 0) { buf[i++] = 0; skip--; } skip = BN_bn2bin(x, buf + i); i += skip; if (i != 1 + field_len) { ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); goto err; } if (form == POINT_CONVERSION_UNCOMPRESSED || form == POINT_CONVERSION_HYBRID) { skip = field_len - BN_num_bytes(y); if (skip > field_len) { ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); goto err; } while (skip > 0) { buf[i++] = 0; skip--; } skip = BN_bn2bin(y, buf + i); i += skip; } if (i != ret) { ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); goto err; } } if (used_ctx) BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; err: if (used_ctx) BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return 0; } /* Converts an octet string representation to an EC_POINT. * Note that the simple implementation only uses affine coordinates. */ int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point, const unsigned char *buf, size_t len, BN_CTX *ctx) { point_conversion_form_t form; int y_bit; BN_CTX *new_ctx = NULL; BIGNUM *x, *y, *yxi; size_t field_len, enc_len; int ret = 0; if (len == 0) { ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_BUFFER_TOO_SMALL); return 0; } form = buf[0]; y_bit = form & 1; form = form & ~1U; if ((form != 0) && (form != POINT_CONVERSION_COMPRESSED) && (form != POINT_CONVERSION_UNCOMPRESSED) && (form != POINT_CONVERSION_HYBRID)) { ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); return 0; } if ((form == 0 || form == POINT_CONVERSION_UNCOMPRESSED) && y_bit) { ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); return 0; } if (form == 0) { if (len != 1) { ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); return 0; } return EC_POINT_set_to_infinity(group, point); } field_len = (EC_GROUP_get_degree(group) + 7) / 8; enc_len = (form == POINT_CONVERSION_COMPRESSED) ? 1 + field_len : 1 + 2 * field_len; if (len != enc_len) { ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); return 0; } if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } BN_CTX_start(ctx); x = BN_CTX_get(ctx); y = BN_CTX_get(ctx); yxi = BN_CTX_get(ctx); if (yxi == NULL) goto err; if (!BN_bin2bn(buf + 1, field_len, x)) goto err; if (BN_ucmp(x, &group->field) >= 0) { ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); goto err; } if (form == POINT_CONVERSION_COMPRESSED) { if (!EC_POINT_set_compressed_coordinates_GF2m(group, point, x, y_bit, ctx)) goto err; } else { if (!BN_bin2bn(buf + 1 + field_len, field_len, y)) goto err; if (BN_ucmp(y, &group->field) >= 0) { ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); goto err; } if (form == POINT_CONVERSION_HYBRID) { if (!group->meth->field_div(group, yxi, y, x, ctx)) goto err; if (y_bit != BN_is_odd(yxi)) { ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); goto err; } } if (!EC_POINT_set_affine_coordinates_GF2m(group, point, x, y, ctx)) goto err; } if (!EC_POINT_is_on_curve(group, point, ctx)) { /* test required by X9.62 */ ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_POINT_IS_NOT_ON_CURVE); goto err; } ret = 1; err: BN_CTX_end(ctx); if (new_ctx != NULL) BN_CTX_free(new_ctx); return ret; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rc4/0000755000000000000000000000000012666635521020542 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/rc4/rc4_skey.c0000644000175000017500000001045012360020706020633 0ustar /* $OpenBSD: rc4_skey.c,v 1.10 2014/06/12 15:49:30 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "rc4_locl.h" #include const char *RC4_options(void) { #ifdef RC4_INDEX if (sizeof(RC4_INT) == 1) return("rc4(idx,char)"); else return("rc4(idx,int)"); #else if (sizeof(RC4_INT) == 1) return("rc4(ptr,char)"); else return("rc4(ptr,int)"); #endif } /* RC4 as implemented from a posting from * Newsgroups: sci.crypt * From: sterndark@netcom.com (David Sterndark) * Subject: RC4 Algorithm revealed. * Message-ID: * Date: Wed, 14 Sep 1994 06:35:31 GMT */ void private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) { register RC4_INT tmp; register int id1,id2; register RC4_INT *d; unsigned int i; d= &(key->data[0]); key->x = 0; key->y = 0; id1=id2=0; #define SK_LOOP(d,n) { \ tmp=d[(n)]; \ id2 = (data[id1] + tmp + id2) & 0xff; \ if (++id1 == len) id1=0; \ d[(n)]=d[id2]; \ d[id2]=tmp; } for (i=0; i < 256; i++) d[i]=i; for (i=0; i < 256; i+=4) { SK_LOOP(d,i+0); SK_LOOP(d,i+1); SK_LOOP(d,i+2); SK_LOOP(d,i+3); } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rc4/rc4_utl.c0000644000175000017500000000515212360020706020467 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * */ #include #include #include void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) { private_RC4_set_key(key, len, data); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rc4/rc4_locl.h0000644000175000017500000000017712360020706020623 0ustar /* $OpenBSD: rc4_locl.h,v 1.3 2014/06/12 15:49:30 deraadt Exp $ */ #ifndef HEADER_RC4_LOCL_H #define HEADER_RC4_LOCL_H #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/rc4/rc4_enc.c0000644000175000017500000002362512360020706020435 0ustar /* $OpenBSD: rc4_enc.c,v 1.11 2014/06/12 15:49:30 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include "rc4_locl.h" /* RC4 as implemented from a posting from * Newsgroups: sci.crypt * From: sterndark@netcom.com (David Sterndark) * Subject: RC4 Algorithm revealed. * Message-ID: * Date: Wed, 14 Sep 1994 06:35:31 GMT */ void RC4(RC4_KEY *key, size_t len, const unsigned char *indata, unsigned char *outdata) { register RC4_INT *d; register RC4_INT x,y,tx,ty; size_t i; x=key->x; y=key->y; d=key->data; #if defined(RC4_CHUNK) /* * The original reason for implementing this(*) was the fact that * pre-21164a Alpha CPUs don't have byte load/store instructions * and e.g. a byte store has to be done with 64-bit load, shift, * and, or and finally 64-bit store. Peaking data and operating * at natural word size made it possible to reduce amount of * instructions as well as to perform early read-ahead without * suffering from RAW (read-after-write) hazard. This resulted * in ~40%(**) performance improvement on 21064 box with gcc. * But it's not only Alpha users who win here:-) Thanks to the * early-n-wide read-ahead this implementation also exhibits * >40% speed-up on SPARC and 20-30% on 64-bit MIPS (depending * on sizeof(RC4_INT)). * * (*) "this" means code which recognizes the case when input * and output pointers appear to be aligned at natural CPU * word boundary * (**) i.e. according to 'apps/openssl speed rc4' benchmark, * crypto/rc4/rc4speed.c exhibits almost 70% speed-up... * * Caveats. * * - RC4_CHUNK="unsigned long long" should be a #1 choice for * UltraSPARC. Unfortunately gcc generates very slow code * (2.5-3 times slower than one generated by Sun's WorkShop * C) and therefore gcc (at least 2.95 and earlier) should * always be told that RC4_CHUNK="unsigned long". * * */ # define RC4_STEP ( \ x=(x+1) &0xff, \ tx=d[x], \ y=(tx+y)&0xff, \ ty=d[y], \ d[y]=tx, \ d[x]=ty, \ (RC4_CHUNK)d[(tx+ty)&0xff]\ ) if ( ( ((size_t)indata & (sizeof(RC4_CHUNK)-1)) | ((size_t)outdata & (sizeof(RC4_CHUNK)-1)) ) == 0 ) { RC4_CHUNK ichunk,otp; /* * I reckon we can afford to implement both endian * cases and to decide which way to take at run-time * because the machine code appears to be very compact * and redundant 1-2KB is perfectly tolerable (i.e. * in case the compiler fails to eliminate it:-). By * suggestion from Terrel Larson . * * Special notes. * * - compilers (those I've tried) don't seem to have * problems eliminating either the operators guarded * by "if (sizeof(RC4_CHUNK)==8)" or the condition * expressions themselves so I've got 'em to replace * corresponding #ifdefs from the previous version; * - I chose to let the redundant switch cases when * sizeof(RC4_CHUNK)!=8 be (were also #ifdefed * before); * - in case you wonder "&(sizeof(RC4_CHUNK)*8-1)" in * [LB]ESHFT guards against "shift is out of range" * warnings when sizeof(RC4_CHUNK)!=8 * * */ if (BYTE_ORDER != LITTLE_ENDIAN) { /* BIG-ENDIAN CASE */ # define BESHFT(c) (((sizeof(RC4_CHUNK)-(c)-1)*8)&(sizeof(RC4_CHUNK)*8-1)) for (;len&(0-sizeof(RC4_CHUNK));len-=sizeof(RC4_CHUNK)) { ichunk = *(RC4_CHUNK *)indata; otp = RC4_STEP<x=x; key->y=y; return; } else { /* LITTLE-ENDIAN CASE */ # define LESHFT(c) (((c)*8)&(sizeof(RC4_CHUNK)*8-1)) for (;len&(0-sizeof(RC4_CHUNK));len-=sizeof(RC4_CHUNK)) { ichunk = *(RC4_CHUNK *)indata; otp = RC4_STEP; otp |= RC4_STEP<<8; otp |= RC4_STEP<<16; otp |= RC4_STEP<<24; if (sizeof(RC4_CHUNK)==8) { otp |= RC4_STEP<>= (sizeof(RC4_CHUNK)-len)<<3; switch (len&(sizeof(RC4_CHUNK)-1)) { case 7: otp = RC4_STEP, i+=8; case 6: otp |= RC4_STEP<x=x; key->y=y; return; } } #endif #define LOOP(in,out) \ x=((x+1)&0xff); \ tx=d[x]; \ y=(tx+y)&0xff; \ d[x]=ty=d[y]; \ d[y]=tx; \ (out) = d[(tx+ty)&0xff]^ (in); #ifndef RC4_INDEX #define RC4_LOOP(a,b,i) LOOP(*((a)++),*((b)++)) #else #define RC4_LOOP(a,b,i) LOOP(a[i],b[i]) #endif i=len>>3; if (i) { for (;;) { RC4_LOOP(indata,outdata,0); RC4_LOOP(indata,outdata,1); RC4_LOOP(indata,outdata,2); RC4_LOOP(indata,outdata,3); RC4_LOOP(indata,outdata,4); RC4_LOOP(indata,outdata,5); RC4_LOOP(indata,outdata,6); RC4_LOOP(indata,outdata,7); #ifdef RC4_INDEX indata+=8; outdata+=8; #endif if (--i == 0) break; } } i=len&0x07; if (i) { for (;;) { RC4_LOOP(indata,outdata,0); if (--i == 0) break; RC4_LOOP(indata,outdata,1); if (--i == 0) break; RC4_LOOP(indata,outdata,2); if (--i == 0) break; RC4_LOOP(indata,outdata,3); if (--i == 0) break; RC4_LOOP(indata,outdata,4); if (--i == 0) break; RC4_LOOP(indata,outdata,5); if (--i == 0) break; RC4_LOOP(indata,outdata,6); if (--i == 0) break; } } key->x=x; key->y=y; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/mem_clr.c0000644000175000017500000000036512360020705020041 0ustar /* $OpenBSD: mem_clr.c,v 1.3 2014/04/15 23:04:49 tedu Exp $ */ /* Ted Unangst places this file in the public domain. */ #include #include void OPENSSL_cleanse(void *ptr, size_t len) { explicit_bzero(ptr, len); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/buffer/0000755000000000000000000000000012666635521021323 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/buffer/buf_err.c0000644000175000017500000000732212360020705021320 0ustar /* $OpenBSD: buf_err.c,v 1.9 2014/06/12 15:49:28 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_BUF,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_BUF,0,reason) static ERR_STRING_DATA BUF_str_functs[] = { {ERR_FUNC(BUF_F_BUF_MEMDUP), "BUF_memdup"}, {ERR_FUNC(BUF_F_BUF_MEM_GROW), "BUF_MEM_grow"}, {ERR_FUNC(BUF_F_BUF_MEM_GROW_CLEAN), "BUF_MEM_grow_clean"}, {ERR_FUNC(BUF_F_BUF_MEM_NEW), "BUF_MEM_new"}, {ERR_FUNC(BUF_F_BUF_STRDUP), "BUF_strdup"}, {ERR_FUNC(BUF_F_BUF_STRNDUP), "BUF_strndup"}, {0, NULL} }; static ERR_STRING_DATA BUF_str_reasons[] = { {0, NULL} }; #endif void ERR_load_BUF_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(BUF_str_functs[0].error) == NULL) { ERR_load_strings(0, BUF_str_functs); ERR_load_strings(0, BUF_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/buffer/buffer.c0000644000175000017500000001347012360020705021146 0ustar /* $OpenBSD: buffer.c,v 1.20 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include /* LIMIT_BEFORE_EXPANSION is the maximum n such that (n+3)/3*4 < 2**31. That * function is applied in several functions in this file and this limit ensures * that the result fits in an int. */ #define LIMIT_BEFORE_EXPANSION 0x5ffffffc BUF_MEM * BUF_MEM_new(void) { BUF_MEM *ret; ret = malloc(sizeof(BUF_MEM)); if (ret == NULL) { BUFerr(BUF_F_BUF_MEM_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } ret->length = 0; ret->max = 0; ret->data = NULL; return (ret); } void BUF_MEM_free(BUF_MEM *a) { if (a == NULL) return; if (a->data != NULL) { explicit_bzero(a->data, a->max); free(a->data); } free(a); } int BUF_MEM_grow(BUF_MEM *str, size_t len) { char *ret; size_t n; if (str->length >= len) { str->length = len; return (len); } if (str->max >= len) { memset(&str->data[str->length], 0, len - str->length); str->length = len; return (len); } /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ if (len > LIMIT_BEFORE_EXPANSION) { BUFerr(BUF_F_BUF_MEM_GROW, ERR_R_MALLOC_FAILURE); return 0; } n = (len + 3) / 3 * 4; ret = realloc(str->data, n); if (ret == NULL) { BUFerr(BUF_F_BUF_MEM_GROW, ERR_R_MALLOC_FAILURE); len = 0; } else { str->data = ret; str->max = n; memset(&str->data[str->length], 0, len - str->length); str->length = len; } return (len); } int BUF_MEM_grow_clean(BUF_MEM *str, size_t len) { char *ret; size_t n; if (str->length >= len) { memset(&str->data[len], 0, str->length - len); str->length = len; return (len); } if (str->max >= len) { memset(&str->data[str->length], 0, len - str->length); str->length = len; return (len); } /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ if (len > LIMIT_BEFORE_EXPANSION) { BUFerr(BUF_F_BUF_MEM_GROW_CLEAN, ERR_R_MALLOC_FAILURE); return 0; } n = (len + 3) / 3 * 4; ret = malloc(n); /* we're not shrinking - that case returns above */ if ((ret != NULL) && (str->data != NULL)) { memcpy(ret, str->data, str->max); explicit_bzero(str->data, str->max); free(str->data); } if (ret == NULL) { BUFerr(BUF_F_BUF_MEM_GROW_CLEAN, ERR_R_MALLOC_FAILURE); len = 0; } else { str->data = ret; str->max = n; memset(&str->data[str->length], 0, len - str->length); str->length = len; } return (len); } void BUF_reverse(unsigned char *out, const unsigned char *in, size_t size) { size_t i; if (in) { out += size - 1; for (i = 0; i < size; i++) *out-- = *in++; } else { unsigned char *q; char c; q = out + size - 1; for (i = 0; i < size / 2; i++) { c = *q; *q-- = *out; *out++ = c; } } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/buffer/buf_str.c0000644000175000017500000000357112360020705021342 0ustar /* $OpenBSD: buf_str.c,v 1.8 2014/04/26 13:07:16 jsing Exp $ */ /* * Copyright (c) 2014 Bob Beck * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include /* * XXX these functions accept a NULL arg and return NULL * when the standard ones do not. we should at an appropriate * time change these to find the bad callers */ char * BUF_strdup(const char *str) { char *ret = NULL; if (str != NULL) { if (!(ret = strdup(str))) BUFerr(BUF_F_BUF_STRDUP, ERR_R_MALLOC_FAILURE); } return ret; } char * BUF_strndup(const char *str, size_t siz) { char *ret = NULL; if (str != NULL) { if (!(ret = strndup(str, siz))) BUFerr(BUF_F_BUF_STRNDUP, ERR_R_MALLOC_FAILURE); } return ret; } void * BUF_memdup(const void *data, size_t siz) { void *ret = NULL; if (data != NULL) { if (!(ret = malloc(siz))) BUFerr(BUF_F_BUF_MEMDUP, ERR_R_MALLOC_FAILURE); else (void) memcpy(ret, data, siz); } return ret; } size_t BUF_strlcpy(char *dst, const char *src, size_t size) { return strlcpy(dst, src, size); } size_t BUF_strlcat(char *dst, const char *src, size_t size) { return strlcat(dst, src, size); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/conf/0000755000000000000000000000000012666635521020777 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/conf/conf_api.c0000644000175000017500000002065112360020705021126 0ustar /* $OpenBSD: conf_api.c,v 1.10 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* Part of the code in here was originally in conf.c, which is now removed */ #ifndef CONF_DEBUG # undef NDEBUG /* avoid conflicting definitions */ # define NDEBUG #endif #include #include #include #include #include #include static void value_free_hash_doall_arg(CONF_VALUE *a, LHASH_OF(CONF_VALUE) *conf); static void value_free_stack_doall(CONF_VALUE *a); static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_hash, CONF_VALUE, LHASH_OF(CONF_VALUE)) static IMPLEMENT_LHASH_DOALL_FN(value_free_stack, CONF_VALUE) /* Up until OpenSSL 0.9.5a, this was get_section */ CONF_VALUE * _CONF_get_section(const CONF *conf, const char *section) { CONF_VALUE *v, vv; if ((conf == NULL) || (section == NULL)) return (NULL); vv.name = NULL; vv.section = (char *)section; v = lh_CONF_VALUE_retrieve(conf->data, &vv); return (v); } /* Up until OpenSSL 0.9.5a, this was CONF_get_section */ STACK_OF(CONF_VALUE) * _CONF_get_section_values(const CONF *conf, const char *section) { CONF_VALUE *v; v = _CONF_get_section(conf, section); if (v != NULL) return ((STACK_OF(CONF_VALUE) *)v->value); else return (NULL); } int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value) { CONF_VALUE *v = NULL; STACK_OF(CONF_VALUE) *ts; ts = (STACK_OF(CONF_VALUE) *)section->value; value->section = section->section; if (!sk_CONF_VALUE_push(ts, value)) { return 0; } v = lh_CONF_VALUE_insert(conf->data, value); if (v != NULL) { (void)sk_CONF_VALUE_delete_ptr(ts, v); free(v->name); free(v->value); free(v); } return 1; } char * _CONF_get_string(const CONF *conf, const char *section, const char *name) { CONF_VALUE *v, vv; char *p; if (name == NULL) return (NULL); if (conf != NULL) { if (section != NULL) { vv.name = (char *)name; vv.section = (char *)section; v = lh_CONF_VALUE_retrieve(conf->data, &vv); if (v != NULL) return (v->value); if (strcmp(section, "ENV") == 0) { if (issetugid() == 0) p = getenv(name); else p = NULL; if (p != NULL) return (p); } } vv.section = "default"; vv.name = (char *)name; v = lh_CONF_VALUE_retrieve(conf->data, &vv); if (v != NULL) return (v->value); else return (NULL); } else { if (issetugid()) return (NULL); return (getenv(name)); } } #if 0 /* There's no way to provide error checking with this function, so force implementors of the higher levels to get a string and read the number themselves. */ long _CONF_get_number(CONF *conf, char *section, char *name) { char *str; long ret = 0; str = _CONF_get_string(conf, section, name); if (str == NULL) return (0); for (;;) { if (conf->meth->is_number(conf, *str)) ret = ret * 10 + conf->meth->to_int(conf, *str); else return (ret); str++; } } #endif static unsigned long conf_value_hash(const CONF_VALUE *v) { return (lh_strhash(v->section) << 2) ^ lh_strhash(v->name); } static IMPLEMENT_LHASH_HASH_FN(conf_value, CONF_VALUE) static int conf_value_cmp(const CONF_VALUE *a, const CONF_VALUE *b) { int i; if (a->section != b->section) { i = strcmp(a->section, b->section); if (i) return (i); } if ((a->name != NULL) && (b->name != NULL)) { i = strcmp(a->name, b->name); return (i); } else if (a->name == b->name) return (0); else return ((a->name == NULL)?-1 : 1); } static IMPLEMENT_LHASH_COMP_FN(conf_value, CONF_VALUE) int _CONF_new_data(CONF *conf) { if (conf == NULL) { return 0; } if (conf->data == NULL) if ((conf->data = lh_CONF_VALUE_new()) == NULL) { return 0; } return 1; } void _CONF_free_data(CONF *conf) { if (conf == NULL || conf->data == NULL) return; lh_CONF_VALUE_down_load(conf->data) = 0; /* evil thing to make * sure the 'free()' works as * expected */ lh_CONF_VALUE_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_hash), LHASH_OF(CONF_VALUE), conf->data); /* We now have only 'section' entries in the hash table. * Due to problems with */ lh_CONF_VALUE_doall(conf->data, LHASH_DOALL_FN(value_free_stack)); lh_CONF_VALUE_free(conf->data); } static void value_free_hash_doall_arg(CONF_VALUE *a, LHASH_OF(CONF_VALUE) *conf) { if (a->name != NULL) (void)lh_CONF_VALUE_delete(conf, a); } static void value_free_stack_doall(CONF_VALUE *a) { CONF_VALUE *vv; STACK_OF(CONF_VALUE) *sk; int i; if (a->name != NULL) return; sk = (STACK_OF(CONF_VALUE) *)a->value; for (i = sk_CONF_VALUE_num(sk) - 1; i >= 0; i--) { vv = sk_CONF_VALUE_value(sk, i); free(vv->value); free(vv->name); free(vv); } if (sk != NULL) sk_CONF_VALUE_free(sk); free(a->section); free(a); } /* Up until OpenSSL 0.9.5a, this was new_section */ CONF_VALUE * _CONF_new_section(CONF *conf, const char *section) { STACK_OF(CONF_VALUE) *sk = NULL; int ok = 0, i; CONF_VALUE *v = NULL, *vv; if ((sk = sk_CONF_VALUE_new_null()) == NULL) goto err; if ((v = malloc(sizeof(CONF_VALUE))) == NULL) goto err; i = strlen(section) + 1; if ((v->section = malloc(i)) == NULL) goto err; memcpy(v->section, section, i); v->name = NULL; v->value = (char *)sk; vv = lh_CONF_VALUE_insert(conf->data, v); OPENSSL_assert(vv == NULL); ok = 1; err: if (!ok) { if (sk != NULL) sk_CONF_VALUE_free(sk); free(v); v = NULL; } return (v); } IMPLEMENT_STACK_OF(CONF_VALUE) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/conf/conf_mod.c0000644000175000017500000003306012360020705021132 0ustar /* $OpenBSD: conf_mod.c,v 1.22 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include #include #define DSO_mod_init_name "OPENSSL_init" #define DSO_mod_finish_name "OPENSSL_finish" /* This structure contains a data about supported modules. * entries in this table correspond to either dynamic or * static modules. */ struct conf_module_st { /* DSO of this module or NULL if static */ DSO *dso; /* Name of the module */ char *name; /* Init function */ conf_init_func *init; /* Finish function */ conf_finish_func *finish; /* Number of successfully initialized modules */ int links; void *usr_data; }; /* This structure contains information about modules that have been * successfully initialized. There may be more than one entry for a * given module. */ struct conf_imodule_st { CONF_MODULE *pmod; char *name; char *value; unsigned long flags; void *usr_data; }; static STACK_OF(CONF_MODULE) *supported_modules = NULL; static STACK_OF(CONF_IMODULE) *initialized_modules = NULL; static void module_free(CONF_MODULE *md); static void module_finish(CONF_IMODULE *imod); static int module_run(const CONF *cnf, char *name, char *value, unsigned long flags); static CONF_MODULE *module_add(DSO *dso, const char *name, conf_init_func *ifunc, conf_finish_func *ffunc); static CONF_MODULE *module_find(char *name); static int module_init(CONF_MODULE *pmod, char *name, char *value, const CONF *cnf); static CONF_MODULE *module_load_dso(const CONF *cnf, char *name, char *value, unsigned long flags); /* Main function: load modules from a CONF structure */ int CONF_modules_load(const CONF *cnf, const char *appname, unsigned long flags) { STACK_OF(CONF_VALUE) *values; CONF_VALUE *vl; char *vsection = NULL; int ret, i; if (!cnf) return 1; if (appname) vsection = NCONF_get_string(cnf, NULL, appname); if (!appname || (!vsection && (flags & CONF_MFLAGS_DEFAULT_SECTION))) vsection = NCONF_get_string(cnf, NULL, "openssl_conf"); if (!vsection) { ERR_clear_error(); return 1; } values = NCONF_get_section(cnf, vsection); if (!values) return 0; for (i = 0; i < sk_CONF_VALUE_num(values); i++) { vl = sk_CONF_VALUE_value(values, i); ret = module_run(cnf, vl->name, vl->value, flags); if (ret <= 0) if (!(flags & CONF_MFLAGS_IGNORE_ERRORS)) return ret; } return 1; } int CONF_modules_load_file(const char *filename, const char *appname, unsigned long flags) { char *file = NULL; CONF *conf = NULL; int ret = 0; conf = NCONF_new(NULL); if (!conf) goto err; if (filename == NULL) { file = CONF_get1_default_config_file(); if (!file) goto err; } else file = (char *)filename; if (NCONF_load(conf, file, NULL) <= 0) { if ((flags & CONF_MFLAGS_IGNORE_MISSING_FILE) && (ERR_GET_REASON(ERR_peek_last_error()) == CONF_R_NO_SUCH_FILE)) { ERR_clear_error(); ret = 1; } goto err; } ret = CONF_modules_load(conf, appname, flags); err: if (filename == NULL) free(file); NCONF_free(conf); return ret; } static int module_run(const CONF *cnf, char *name, char *value, unsigned long flags) { CONF_MODULE *md; int ret; md = module_find(name); /* Module not found: try to load DSO */ if (!md && !(flags & CONF_MFLAGS_NO_DSO)) md = module_load_dso(cnf, name, value, flags); if (!md) { if (!(flags & CONF_MFLAGS_SILENT)) { CONFerr(CONF_F_MODULE_RUN, CONF_R_UNKNOWN_MODULE_NAME); ERR_asprintf_error_data("module=%s", name); } return -1; } ret = module_init(md, name, value, cnf); if (ret <= 0) { if (!(flags & CONF_MFLAGS_SILENT)) { CONFerr(CONF_F_MODULE_RUN, CONF_R_MODULE_INITIALIZATION_ERROR); ERR_asprintf_error_data ("module=%s, value=%s, retcode=%-8d", name, value, ret); } } return ret; } /* Load a module from a DSO */ static CONF_MODULE * module_load_dso(const CONF *cnf, char *name, char *value, unsigned long flags) { DSO *dso = NULL; conf_init_func *ifunc; conf_finish_func *ffunc; char *path = NULL; int errcode = 0; CONF_MODULE *md; /* Look for alternative path in module section */ path = NCONF_get_string(cnf, value, "path"); if (!path) { ERR_clear_error(); path = name; } dso = DSO_load(NULL, path, NULL, 0); if (!dso) { errcode = CONF_R_ERROR_LOADING_DSO; goto err; } ifunc = (conf_init_func *)DSO_bind_func(dso, DSO_mod_init_name); if (!ifunc) { errcode = CONF_R_MISSING_INIT_FUNCTION; goto err; } ffunc = (conf_finish_func *)DSO_bind_func(dso, DSO_mod_finish_name); /* All OK, add module */ md = module_add(dso, name, ifunc, ffunc); if (!md) goto err; return md; err: if (dso) DSO_free(dso); CONFerr(CONF_F_MODULE_LOAD_DSO, errcode); ERR_asprintf_error_data("module=%s, path=%s", name, path); return NULL; } /* add module to list */ static CONF_MODULE * module_add(DSO *dso, const char *name, conf_init_func *ifunc, conf_finish_func *ffunc) { CONF_MODULE *tmod = NULL; if (supported_modules == NULL) supported_modules = sk_CONF_MODULE_new_null(); if (supported_modules == NULL) return NULL; tmod = malloc(sizeof(CONF_MODULE)); if (tmod == NULL) return NULL; tmod->dso = dso; tmod->name = BUF_strdup(name); tmod->init = ifunc; tmod->finish = ffunc; tmod->links = 0; if (!sk_CONF_MODULE_push(supported_modules, tmod)) { free(tmod); return NULL; } return tmod; } /* Find a module from the list. We allow module names of the * form modname.XXXX to just search for modname to allow the * same module to be initialized more than once. */ static CONF_MODULE * module_find(char *name) { CONF_MODULE *tmod; int i, nchar; char *p; p = strrchr(name, '.'); if (p) nchar = p - name; else nchar = strlen(name); for (i = 0; i < sk_CONF_MODULE_num(supported_modules); i++) { tmod = sk_CONF_MODULE_value(supported_modules, i); if (!strncmp(tmod->name, name, nchar)) return tmod; } return NULL; } /* initialize a module */ static int module_init(CONF_MODULE *pmod, char *name, char *value, const CONF *cnf) { int ret = 1; int init_called = 0; CONF_IMODULE *imod = NULL; /* Otherwise add initialized module to list */ imod = malloc(sizeof(CONF_IMODULE)); if (!imod) goto err; imod->pmod = pmod; imod->name = BUF_strdup(name); imod->value = BUF_strdup(value); imod->usr_data = NULL; if (!imod->name || !imod->value) goto memerr; /* Try to initialize module */ if (pmod->init) { ret = pmod->init(imod, cnf); init_called = 1; /* Error occurred, exit */ if (ret <= 0) goto err; } if (initialized_modules == NULL) { initialized_modules = sk_CONF_IMODULE_new_null(); if (!initialized_modules) { CONFerr(CONF_F_MODULE_INIT, ERR_R_MALLOC_FAILURE); goto err; } } if (!sk_CONF_IMODULE_push(initialized_modules, imod)) { CONFerr(CONF_F_MODULE_INIT, ERR_R_MALLOC_FAILURE); goto err; } pmod->links++; return ret; err: /* We've started the module so we'd better finish it */ if (pmod->finish && init_called) pmod->finish(imod); memerr: if (imod) { free(imod->name); free(imod->value); free(imod); } return -1; } /* Unload any dynamic modules that have a link count of zero: * i.e. have no active initialized modules. If 'all' is set * then all modules are unloaded including static ones. */ void CONF_modules_unload(int all) { int i; CONF_MODULE *md; CONF_modules_finish(); /* unload modules in reverse order */ for (i = sk_CONF_MODULE_num(supported_modules) - 1; i >= 0; i--) { md = sk_CONF_MODULE_value(supported_modules, i); /* If static or in use and 'all' not set ignore it */ if (((md->links > 0) || !md->dso) && !all) continue; /* Since we're working in reverse this is OK */ (void)sk_CONF_MODULE_delete(supported_modules, i); module_free(md); } if (sk_CONF_MODULE_num(supported_modules) == 0) { sk_CONF_MODULE_free(supported_modules); supported_modules = NULL; } } /* unload a single module */ static void module_free(CONF_MODULE *md) { if (md->dso) DSO_free(md->dso); free(md->name); free(md); } /* finish and free up all modules instances */ void CONF_modules_finish(void) { CONF_IMODULE *imod; while (sk_CONF_IMODULE_num(initialized_modules) > 0) { imod = sk_CONF_IMODULE_pop(initialized_modules); module_finish(imod); } sk_CONF_IMODULE_free(initialized_modules); initialized_modules = NULL; } /* finish a module instance */ static void module_finish(CONF_IMODULE *imod) { if (imod->pmod->finish) imod->pmod->finish(imod); imod->pmod->links--; free(imod->name); free(imod->value); free(imod); } /* Add a static module to OpenSSL */ int CONF_module_add(const char *name, conf_init_func *ifunc, conf_finish_func *ffunc) { if (module_add(NULL, name, ifunc, ffunc)) return 1; else return 0; } void CONF_modules_free(void) { CONF_modules_finish(); CONF_modules_unload(1); } /* Utility functions */ const char * CONF_imodule_get_name(const CONF_IMODULE *md) { return md->name; } const char * CONF_imodule_get_value(const CONF_IMODULE *md) { return md->value; } void * CONF_imodule_get_usr_data(const CONF_IMODULE *md) { return md->usr_data; } void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data) { md->usr_data = usr_data; } CONF_MODULE * CONF_imodule_get_module(const CONF_IMODULE *md) { return md->pmod; } unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md) { return md->flags; } void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags) { md->flags = flags; } void * CONF_module_get_usr_data(CONF_MODULE *pmod) { return pmod->usr_data; } void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data) { pmod->usr_data = usr_data; } /* Return default config file name */ char * CONF_get1_default_config_file(void) { char *file = NULL; if (issetugid() == 0) file = getenv("OPENSSL_CONF"); if (file) return BUF_strdup(file); if (asprintf(&file, "%s/openssl.cnf", X509_get_default_cert_area()) == -1) return (NULL); return file; } /* This function takes a list separated by 'sep' and calls the * callback function giving the start and length of each member * optionally stripping leading and trailing whitespace. This can * be used to parse comma separated lists for example. */ int CONF_parse_list(const char *list_, int sep, int nospc, int (*list_cb)(const char *elem, int len, void *usr), void *arg) { int ret; const char *lstart, *tmpend, *p; if (list_ == NULL) { CONFerr(CONF_F_CONF_PARSE_LIST, CONF_R_LIST_CANNOT_BE_NULL); return 0; } lstart = list_; for (;;) { if (nospc) { while (*lstart && isspace((unsigned char)*lstart)) lstart++; } p = strchr(lstart, sep); if (p == lstart || !*lstart) ret = list_cb(NULL, 0, arg); else { if (p) tmpend = p - 1; else tmpend = lstart + strlen(lstart) - 1; if (nospc) { while (isspace((unsigned char)*tmpend)) tmpend--; } ret = list_cb(lstart, tmpend - lstart + 1, arg); } if (ret <= 0) return ret; if (p == NULL) return 1; lstart = p + 1; } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/conf/conf_err.c0000644000175000017500000001320112360020705021136 0ustar /* $OpenBSD: conf_err.c,v 1.11 2014/06/12 15:49:28 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_CONF,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_CONF,0,reason) static ERR_STRING_DATA CONF_str_functs[]= { {ERR_FUNC(CONF_F_CONF_DUMP_FP), "CONF_dump_fp"}, {ERR_FUNC(CONF_F_CONF_LOAD), "CONF_load"}, {ERR_FUNC(CONF_F_CONF_LOAD_BIO), "CONF_load_bio"}, {ERR_FUNC(CONF_F_CONF_LOAD_FP), "CONF_load_fp"}, {ERR_FUNC(CONF_F_CONF_MODULES_LOAD), "CONF_modules_load"}, {ERR_FUNC(CONF_F_CONF_PARSE_LIST), "CONF_parse_list"}, {ERR_FUNC(CONF_F_DEF_LOAD), "DEF_LOAD"}, {ERR_FUNC(CONF_F_DEF_LOAD_BIO), "DEF_LOAD_BIO"}, {ERR_FUNC(CONF_F_MODULE_INIT), "MODULE_INIT"}, {ERR_FUNC(CONF_F_MODULE_LOAD_DSO), "MODULE_LOAD_DSO"}, {ERR_FUNC(CONF_F_MODULE_RUN), "MODULE_RUN"}, {ERR_FUNC(CONF_F_NCONF_DUMP_BIO), "NCONF_dump_bio"}, {ERR_FUNC(CONF_F_NCONF_DUMP_FP), "NCONF_dump_fp"}, {ERR_FUNC(CONF_F_NCONF_GET_NUMBER), "NCONF_get_number"}, {ERR_FUNC(CONF_F_NCONF_GET_NUMBER_E), "NCONF_get_number_e"}, {ERR_FUNC(CONF_F_NCONF_GET_SECTION), "NCONF_get_section"}, {ERR_FUNC(CONF_F_NCONF_GET_STRING), "NCONF_get_string"}, {ERR_FUNC(CONF_F_NCONF_LOAD), "NCONF_load"}, {ERR_FUNC(CONF_F_NCONF_LOAD_BIO), "NCONF_load_bio"}, {ERR_FUNC(CONF_F_NCONF_LOAD_FP), "NCONF_load_fp"}, {ERR_FUNC(CONF_F_NCONF_NEW), "NCONF_new"}, {ERR_FUNC(CONF_F_STR_COPY), "STR_COPY"}, {0, NULL} }; static ERR_STRING_DATA CONF_str_reasons[]= { {ERR_REASON(CONF_R_ERROR_LOADING_DSO) , "error loading dso"}, {ERR_REASON(CONF_R_LIST_CANNOT_BE_NULL) , "list cannot be null"}, {ERR_REASON(CONF_R_MISSING_CLOSE_SQUARE_BRACKET), "missing close square bracket"}, {ERR_REASON(CONF_R_MISSING_EQUAL_SIGN) , "missing equal sign"}, {ERR_REASON(CONF_R_MISSING_FINISH_FUNCTION), "missing finish function"}, {ERR_REASON(CONF_R_MISSING_INIT_FUNCTION), "missing init function"}, {ERR_REASON(CONF_R_MODULE_INITIALIZATION_ERROR), "module initialization error"}, {ERR_REASON(CONF_R_NO_CLOSE_BRACE) , "no close brace"}, {ERR_REASON(CONF_R_NO_CONF) , "no conf"}, {ERR_REASON(CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE), "no conf or environment variable"}, {ERR_REASON(CONF_R_NO_SECTION) , "no section"}, {ERR_REASON(CONF_R_NO_SUCH_FILE) , "no such file"}, {ERR_REASON(CONF_R_NO_VALUE) , "no value"}, {ERR_REASON(CONF_R_UNABLE_TO_CREATE_NEW_SECTION), "unable to create new section"}, {ERR_REASON(CONF_R_UNKNOWN_MODULE_NAME) , "unknown module name"}, {ERR_REASON(CONF_R_VARIABLE_HAS_NO_VALUE), "variable has no value"}, {0, NULL} }; #endif void ERR_load_CONF_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(CONF_str_functs[0].error) == NULL) { ERR_load_strings(0, CONF_str_functs); ERR_load_strings(0, CONF_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/conf/conf_lib.c0000644000175000017500000002200112360020705021112 0ustar /* $OpenBSD: conf_lib.c,v 1.11 2014/06/12 15:49:28 deraadt Exp $ */ /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include static CONF_METHOD *default_CONF_method = NULL; /* Init a 'CONF' structure from an old LHASH */ void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash) { if (default_CONF_method == NULL) default_CONF_method = NCONF_default(); default_CONF_method->init(conf); conf->data = hash; } /* The following section contains the "CONF classic" functions, rewritten in terms of the new CONF interface. */ int CONF_set_default_method(CONF_METHOD *meth) { default_CONF_method = meth; return 1; } LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file, long *eline) { LHASH_OF(CONF_VALUE) *ltmp; BIO *in = NULL; in = BIO_new_file(file, "rb"); if (in == NULL) { CONFerr(CONF_F_CONF_LOAD, ERR_R_SYS_LIB); return NULL; } ltmp = CONF_load_bio(conf, in, eline); BIO_free(in); return ltmp; } LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp, long *eline) { BIO *btmp; LHASH_OF(CONF_VALUE) *ltmp; if (!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) { CONFerr(CONF_F_CONF_LOAD_FP, ERR_R_BUF_LIB); return NULL; } ltmp = CONF_load_bio(conf, btmp, eline); BIO_free(btmp); return ltmp; } LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp, long *eline) { CONF ctmp; int ret; CONF_set_nconf(&ctmp, conf); ret = NCONF_load_bio(&ctmp, bp, eline); if (ret) return ctmp.data; return NULL; } STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf, const char *section) { if (conf == NULL) { return NULL; } else { CONF ctmp; CONF_set_nconf(&ctmp, conf); return NCONF_get_section(&ctmp, section); } } char * CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group, const char *name) { if (conf == NULL) { return NCONF_get_string(NULL, group, name); } else { CONF ctmp; CONF_set_nconf(&ctmp, conf); return NCONF_get_string(&ctmp, group, name); } } long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group, const char *name) { int status; long result = 0; if (conf == NULL) { status = NCONF_get_number_e(NULL, group, name, &result); } else { CONF ctmp; CONF_set_nconf(&ctmp, conf); status = NCONF_get_number_e(&ctmp, group, name, &result); } if (status == 0) { /* This function does not believe in errors... */ ERR_clear_error(); } return result; } void CONF_free(LHASH_OF(CONF_VALUE) *conf) { CONF ctmp; CONF_set_nconf(&ctmp, conf); NCONF_free_data(&ctmp); } int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out) { BIO *btmp; int ret; if (!(btmp = BIO_new_fp(out, BIO_NOCLOSE))) { CONFerr(CONF_F_CONF_DUMP_FP, ERR_R_BUF_LIB); return 0; } ret = CONF_dump_bio(conf, btmp); BIO_free(btmp); return ret; } int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out) { CONF ctmp; CONF_set_nconf(&ctmp, conf); return NCONF_dump_bio(&ctmp, out); } /* The following section contains the "New CONF" functions. They are completely centralised around a new CONF structure that may contain basically anything, but at least a method pointer and a table of data. These functions are also written in terms of the bridge functions used by the "CONF classic" functions, for consistency. */ CONF * NCONF_new(CONF_METHOD *meth) { CONF *ret; if (meth == NULL) meth = NCONF_default(); ret = meth->create(meth); if (ret == NULL) { CONFerr(CONF_F_NCONF_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } return ret; } void NCONF_free(CONF *conf) { if (conf == NULL) return; conf->meth->destroy(conf); } void NCONF_free_data(CONF *conf) { if (conf == NULL) return; conf->meth->destroy_data(conf); } int NCONF_load(CONF *conf, const char *file, long *eline) { if (conf == NULL) { CONFerr(CONF_F_NCONF_LOAD, CONF_R_NO_CONF); return 0; } return conf->meth->load(conf, file, eline); } int NCONF_load_fp(CONF *conf, FILE *fp, long *eline) { BIO *btmp; int ret; if (!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) { CONFerr(CONF_F_NCONF_LOAD_FP, ERR_R_BUF_LIB); return 0; } ret = NCONF_load_bio(conf, btmp, eline); BIO_free(btmp); return ret; } int NCONF_load_bio(CONF *conf, BIO *bp, long *eline) { if (conf == NULL) { CONFerr(CONF_F_NCONF_LOAD_BIO, CONF_R_NO_CONF); return 0; } return conf->meth->load_bio(conf, bp, eline); } STACK_OF(CONF_VALUE) * NCONF_get_section(const CONF *conf, const char *section) { if (conf == NULL) { CONFerr(CONF_F_NCONF_GET_SECTION, CONF_R_NO_CONF); return NULL; } if (section == NULL) { CONFerr(CONF_F_NCONF_GET_SECTION, CONF_R_NO_SECTION); return NULL; } return _CONF_get_section_values(conf, section); } char * NCONF_get_string(const CONF *conf, const char *group, const char *name) { char *s = _CONF_get_string(conf, group, name); /* Since we may get a value from an environment variable even if conf is NULL, let's check the value first */ if (s) return s; if (conf == NULL) { CONFerr(CONF_F_NCONF_GET_STRING, CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE); return NULL; } CONFerr(CONF_F_NCONF_GET_STRING, CONF_R_NO_VALUE); ERR_asprintf_error_data("group=%s name=%s", group, name); return NULL; } int NCONF_get_number_e(const CONF *conf, const char *group, const char *name, long *result) { char *str; if (result == NULL) { CONFerr(CONF_F_NCONF_GET_NUMBER_E, ERR_R_PASSED_NULL_PARAMETER); return 0; } str = NCONF_get_string(conf, group, name); if (str == NULL) return 0; for (*result = 0; conf->meth->is_number(conf, *str); ) { *result = (*result) * 10 + conf->meth->to_int(conf, *str); str++; } return 1; } int NCONF_dump_fp(const CONF *conf, FILE *out) { BIO *btmp; int ret; if (!(btmp = BIO_new_fp(out, BIO_NOCLOSE))) { CONFerr(CONF_F_NCONF_DUMP_FP, ERR_R_BUF_LIB); return 0; } ret = NCONF_dump_bio(conf, btmp); BIO_free(btmp); return ret; } int NCONF_dump_bio(const CONF *conf, BIO *out) { if (conf == NULL) { CONFerr(CONF_F_NCONF_DUMP_BIO, CONF_R_NO_CONF); return 0; } return conf->meth->dump(conf, out); } /* This function should be avoided */ #if 0 long NCONF_get_number(CONF *conf, char *group, char *name) { int status; long ret = 0; status = NCONF_get_number_e(conf, group, name, &ret); if (status == 0) { /* This function does not believe in errors... */ ERR_get_error(); } return ret; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/conf/conf_mall.c0000644000175000017500000000620112360020705021275 0ustar /* $OpenBSD: conf_mall.c,v 1.8 2014/07/10 22:45:56 jsing Exp $ */ /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif /* Load all OpenSSL builtin modules */ void OPENSSL_load_builtin_modules(void) { /* Add builtin modules here */ ASN1_add_oid_module(); #ifndef OPENSSL_NO_ENGINE ENGINE_add_conf_module(); #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/conf/conf_sap.c0000644000175000017500000000754012360020705021142 0ustar /* $OpenBSD: conf_sap.c,v 1.9 2014/07/10 22:45:56 jsing Exp $ */ /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif /* This is the automatic configuration loader: it is called automatically by * OpenSSL when any of a number of standard initialisation functions are called, * unless this is overridden by calling OPENSSL_no_config() */ static int openssl_configured = 0; void OPENSSL_config(const char *config_name) { if (openssl_configured) return; OPENSSL_load_builtin_modules(); #ifndef OPENSSL_NO_ENGINE /* Need to load ENGINEs */ ENGINE_load_builtin_engines(); #endif /* Add others here? */ ERR_clear_error(); if (CONF_modules_load_file(NULL, config_name, CONF_MFLAGS_DEFAULT_SECTION|CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0) { BIO *bio_err; ERR_load_crypto_strings(); if ((bio_err = BIO_new_fp(stderr, BIO_NOCLOSE)) != NULL) { BIO_printf(bio_err, "Auto configuration failed\n"); ERR_print_errors(bio_err); BIO_free(bio_err); } exit(1); } return; } void OPENSSL_no_config(void) { openssl_configured = 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/conf/conf_def.c0000644000175000017500000003675512360020705021127 0ustar /* $OpenBSD: conf_def.c,v 1.27 2014/07/11 08:44:48 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* Part of the code in here was originally in conf.c, which is now removed */ #include #include #include #include #include #include #include #include #include "conf_def.h" static char *eat_ws(CONF *conf, char *p); static char *eat_alpha_numeric(CONF *conf, char *p); static void clear_comments(CONF *conf, char *p); static int str_copy(CONF *conf, char *section, char **to, char *from); static char *scan_quote(CONF *conf, char *p); static char *scan_dquote(CONF *conf, char *p); #define scan_esc(conf,p) (((IS_EOF((conf),(p)[1]))?((p)+1):((p)+2))) static CONF *def_create(CONF_METHOD *meth); static int def_init_default(CONF *conf); static int def_init_WIN32(CONF *conf); static int def_destroy(CONF *conf); static int def_destroy_data(CONF *conf); static int def_load(CONF *conf, const char *name, long *eline); static int def_load_bio(CONF *conf, BIO *bp, long *eline); static int def_dump(const CONF *conf, BIO *bp); static int def_is_number(const CONF *conf, char c); static int def_to_int(const CONF *conf, char c); static CONF_METHOD default_method = { .name = "OpenSSL default", .create = def_create, .init = def_init_default, .destroy = def_destroy, .destroy_data = def_destroy_data, .load_bio = def_load_bio, .dump = def_dump, .is_number = def_is_number, .to_int = def_to_int, .load = def_load }; static CONF_METHOD WIN32_method = { "WIN32", def_create, def_init_WIN32, def_destroy, def_destroy_data, def_load_bio, def_dump, def_is_number, def_to_int, def_load }; CONF_METHOD * NCONF_default(void) { return &default_method; } CONF_METHOD * NCONF_WIN32(void) { return &WIN32_method; } static CONF * def_create(CONF_METHOD *meth) { CONF *ret; ret = malloc(sizeof(CONF) + sizeof(unsigned short *)); if (ret) if (meth->init(ret) == 0) { free(ret); ret = NULL; } return ret; } static int def_init_default(CONF *conf) { if (conf == NULL) return 0; conf->meth = &default_method; conf->meth_data = CONF_type_default; conf->data = NULL; return 1; } static int def_init_WIN32(CONF *conf) { if (conf == NULL) return 0; conf->meth = &WIN32_method; conf->meth_data = (void *)CONF_type_win32; conf->data = NULL; return 1; } static int def_destroy(CONF *conf) { if (def_destroy_data(conf)) { free(conf); return 1; } return 0; } static int def_destroy_data(CONF *conf) { if (conf == NULL) return 0; _CONF_free_data(conf); return 1; } static int def_load(CONF *conf, const char *name, long *line) { int ret; BIO *in = NULL; in = BIO_new_file(name, "rb"); if (in == NULL) { if (ERR_GET_REASON(ERR_peek_last_error()) == BIO_R_NO_SUCH_FILE) CONFerr(CONF_F_DEF_LOAD, CONF_R_NO_SUCH_FILE); else CONFerr(CONF_F_DEF_LOAD, ERR_R_SYS_LIB); return 0; } ret = def_load_bio(conf, in, line); BIO_free(in); return ret; } static int def_load_bio(CONF *conf, BIO *in, long *line) { /* The macro BUFSIZE conflicts with a system macro in VxWorks */ #define CONFBUFSIZE 512 int bufnum = 0, i, ii; BUF_MEM *buff = NULL; char *s, *p, *end; int again; long eline = 0; CONF_VALUE *v = NULL, *tv; CONF_VALUE *sv = NULL; char *section = NULL, *buf; char *start, *psection, *pname; void *h = (void *)(conf->data); if ((buff = BUF_MEM_new()) == NULL) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_BUF_LIB); goto err; } section = malloc(10); if (section == NULL) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); goto err; } strlcpy(section, "default",10); if (_CONF_new_data(conf) == 0) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); goto err; } sv = _CONF_new_section(conf, section); if (sv == NULL) { CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_UNABLE_TO_CREATE_NEW_SECTION); goto err; } bufnum = 0; again = 0; for (;;) { if (!BUF_MEM_grow(buff, bufnum + CONFBUFSIZE)) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_BUF_LIB); goto err; } p = &(buff->data[bufnum]); *p = '\0'; BIO_gets(in, p, CONFBUFSIZE - 1); p[CONFBUFSIZE - 1] = '\0'; ii = i = strlen(p); if (i == 0 && !again) break; again = 0; while (i > 0) { if ((p[i - 1] != '\r') && (p[i - 1] != '\n')) break; else i--; } /* we removed some trailing stuff so there is a new * line on the end. */ if (ii && i == ii) again = 1; /* long line */ else { p[i] = '\0'; eline++; /* another input line */ } /* we now have a line with trailing \r\n removed */ /* i is the number of bytes */ bufnum += i; v = NULL; /* check for line continuation */ if (bufnum >= 1) { /* If we have bytes and the last char '\\' and * second last char is not '\\' */ p = &(buff->data[bufnum - 1]); if (IS_ESC(conf, p[0]) && ((bufnum <= 1) || !IS_ESC(conf, p[-1]))) { bufnum--; again = 1; } } if (again) continue; bufnum = 0; buf = buff->data; clear_comments(conf, buf); s = eat_ws(conf, buf); if (IS_EOF(conf, *s)) continue; /* blank line */ if (*s == '[') { char *ss; s++; start = eat_ws(conf, s); ss = start; again: end = eat_alpha_numeric(conf, ss); p = eat_ws(conf, end); if (*p != ']') { if (*p != '\0' && ss != p) { ss = p; goto again; } CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_MISSING_CLOSE_SQUARE_BRACKET); goto err; } *end = '\0'; if (!str_copy(conf, NULL, §ion, start)) goto err; if ((sv = _CONF_get_section(conf, section)) == NULL) sv = _CONF_new_section(conf, section); if (sv == NULL) { CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_UNABLE_TO_CREATE_NEW_SECTION); goto err; } continue; } else { pname = s; psection = NULL; end = eat_alpha_numeric(conf, s); if ((end[0] == ':') && (end[1] == ':')) { *end = '\0'; end += 2; psection = pname; pname = end; end = eat_alpha_numeric(conf, end); } p = eat_ws(conf, end); if (*p != '=') { CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_MISSING_EQUAL_SIGN); goto err; } *end = '\0'; p++; start = eat_ws(conf, p); while (!IS_EOF(conf, *p)) p++; p--; while ((p != start) && (IS_WS(conf, *p))) p--; p++; *p = '\0'; if (!(v = malloc(sizeof(CONF_VALUE)))) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); goto err; } if (psection == NULL) psection = section; v->name = strdup(pname); v->value = NULL; if (v->name == NULL) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); goto err; } if (!str_copy(conf, psection, &(v->value), start)) goto err; if (strcmp(psection, section) != 0) { if ((tv = _CONF_get_section(conf, psection)) == NULL) tv = _CONF_new_section(conf, psection); if (tv == NULL) { CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_UNABLE_TO_CREATE_NEW_SECTION); goto err; } } else tv = sv; #if 1 if (_CONF_add_string(conf, tv, v) == 0) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); goto err; } #else v->section = tv->section; if (!sk_CONF_VALUE_push(ts, v)) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); goto err; } vv = (CONF_VALUE *)lh_insert(conf->data, v); if (vv != NULL) { sk_CONF_VALUE_delete_ptr(ts, vv); free(vv->name); free(vv->value); free(vv); } #endif v = NULL; } } if (buff != NULL) BUF_MEM_free(buff); free(section); return (1); err: if (buff != NULL) BUF_MEM_free(buff); free(section); if (line != NULL) *line = eline; ERR_asprintf_error_data("line %ld", eline); if ((h != conf->data) && (conf->data != NULL)) { CONF_free(conf->data); conf->data = NULL; } if (v != NULL) { free(v->name); free(v->value); free(v); } return (0); } static void clear_comments(CONF *conf, char *p) { for (;;) { if (IS_FCOMMENT(conf, *p)) { *p = '\0'; return; } if (!IS_WS(conf, *p)) { break; } p++; } for (;;) { if (IS_COMMENT(conf, *p)) { *p = '\0'; return; } if (IS_DQUOTE(conf, *p)) { p = scan_dquote(conf, p); continue; } if (IS_QUOTE(conf, *p)) { p = scan_quote(conf, p); continue; } if (IS_ESC(conf, *p)) { p = scan_esc(conf, p); continue; } if (IS_EOF(conf, *p)) return; else p++; } } static int str_copy(CONF *conf, char *section, char **pto, char *from) { int q, r,rr = 0, to = 0, len = 0; char *s, *e, *rp, *p, *rrp, *np, *cp, v; BUF_MEM *buf; if ((buf = BUF_MEM_new()) == NULL) return (0); len = strlen(from) + 1; if (!BUF_MEM_grow(buf, len)) goto err; for (;;) { if (IS_QUOTE(conf, *from)) { q = *from; from++; while (!IS_EOF(conf, *from) && (*from != q)) { if (IS_ESC(conf, *from)) { from++; if (IS_EOF(conf, *from)) break; } buf->data[to++] = *(from++); } if (*from == q) from++; } else if (IS_DQUOTE(conf, *from)) { q = *from; from++; while (!IS_EOF(conf, *from)) { if (*from == q) { if (*(from + 1) == q) { from++; } else { break; } } buf->data[to++] = *(from++); } if (*from == q) from++; } else if (IS_ESC(conf, *from)) { from++; v = *(from++); if (IS_EOF(conf, v)) break; else if (v == 'r') v = '\r'; else if (v == 'n') v = '\n'; else if (v == 'b') v = '\b'; else if (v == 't') v = '\t'; buf->data[to++] = v; } else if (IS_EOF(conf, *from)) break; else if (*from == '$') { /* try to expand it */ rrp = NULL; s = &(from[1]); if (*s == '{') q = '}'; else if (*s == '(') q = ')'; else q = 0; if (q) s++; cp = section; e = np = s; while (IS_ALPHA_NUMERIC(conf, *e)) e++; if ((e[0] == ':') && (e[1] == ':')) { cp = np; rrp = e; rr = *e; *rrp = '\0'; e += 2; np = e; while (IS_ALPHA_NUMERIC(conf, *e)) e++; } r = *e; *e = '\0'; rp = e; if (q) { if (r != q) { CONFerr(CONF_F_STR_COPY, CONF_R_NO_CLOSE_BRACE); goto err; } e++; } /* So at this point we have * np which is the start of the name string which is * '\0' terminated. * cp which is the start of the section string which is * '\0' terminated. * e is the 'next point after'. * r and rr are the chars replaced by the '\0' * rp and rrp is where 'r' and 'rr' came from. */ p = _CONF_get_string(conf, cp, np); if (rrp != NULL) *rrp = rr; *rp = r; if (p == NULL) { CONFerr(CONF_F_STR_COPY, CONF_R_VARIABLE_HAS_NO_VALUE); goto err; } BUF_MEM_grow_clean(buf, (strlen(p) + buf->length - (e - from))); while (*p) buf->data[to++] = *(p++); /* Since we change the pointer 'from', we also have to change the perceived length of the string it points at. /RL */ len -= e - from; from = e; /* In case there were no braces or parenthesis around the variable reference, we have to put back the character that was replaced with a '\0'. /RL */ *rp = r; } else buf->data[to++] = *(from++); } buf->data[to]='\0'; free(*pto); *pto = buf->data; free(buf); return (1); err: if (buf != NULL) BUF_MEM_free(buf); return (0); } static char * eat_ws(CONF *conf, char *p) { while (IS_WS(conf, *p) && (!IS_EOF(conf, *p))) p++; return (p); } static char * eat_alpha_numeric(CONF *conf, char *p) { for (;;) { if (IS_ESC(conf, *p)) { p = scan_esc(conf, p); continue; } if (!IS_ALPHA_NUMERIC_PUNCT(conf, *p)) return (p); p++; } } static char * scan_quote(CONF *conf, char *p) { int q = *p; p++; while (!(IS_EOF(conf, *p)) && (*p != q)) { if (IS_ESC(conf, *p)) { p++; if (IS_EOF(conf, *p)) return (p); } p++; } if (*p == q) p++; return (p); } static char * scan_dquote(CONF *conf, char *p) { int q = *p; p++; while (!(IS_EOF(conf, *p))) { if (*p == q) { if (*(p + 1) == q) { p++; } else { break; } } p++; } if (*p == q) p++; return (p); } static void dump_value_doall_arg(CONF_VALUE *a, BIO *out) { if (a->name) BIO_printf(out, "[%s] %s=%s\n", a->section, a->name, a->value); else BIO_printf(out, "[[%s]]\n", a->section); } static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE, BIO) static int def_dump(const CONF *conf, BIO *out) { lh_CONF_VALUE_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value), BIO, out); return 1; } static int def_is_number(const CONF *conf, char c) { return IS_NUMBER(conf, c); } static int def_to_int(const CONF *conf, char c) { return c - '0'; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/conf/conf_def.h0000644000175000017500000002114512360020705021117 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* THIS FILE WAS AUTOMAGICALLY GENERATED! Please modify and use keysets.pl to regenerate it. */ #define CONF_NUMBER 1 #define CONF_UPPER 2 #define CONF_LOWER 4 #define CONF_UNDER 256 #define CONF_PUNCTUATION 512 #define CONF_WS 16 #define CONF_ESC 32 #define CONF_QUOTE 64 #define CONF_DQUOTE 1024 #define CONF_COMMENT 128 #define CONF_FCOMMENT 2048 #define CONF_EOF 8 #define CONF_HIGHBIT 4096 #define CONF_ALPHA (CONF_UPPER|CONF_LOWER) #define CONF_ALPHA_NUMERIC (CONF_ALPHA|CONF_NUMBER|CONF_UNDER) #define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \ CONF_PUNCTUATION) #define KEYTYPES(c) ((unsigned short *)((c)->meth_data)) #define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_COMMENT) #define IS_FCOMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_FCOMMENT) #define IS_EOF(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_EOF) #define IS_ESC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ESC) #define IS_NUMBER(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_NUMBER) #define IS_WS(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_WS) #define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC) #define IS_ALPHA_NUMERIC_PUNCT(c,a) \ (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC_PUNCT) #define IS_QUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_QUOTE) #define IS_DQUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_DQUOTE) #define IS_HIGHBIT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_HIGHBIT) static unsigned short CONF_type_default[256] = { 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0010, 0x0010, 0x0000, 0x0000, 0x0010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0010, 0x0200, 0x0040, 0x0080, 0x0000, 0x0200, 0x0200, 0x0040, 0x0000, 0x0000, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0200, 0x0000, 0x0000, 0x0000, 0x0200, 0x0200, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0000, 0x0020, 0x0000, 0x0200, 0x0100, 0x0040, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0000, 0x0200, 0x0000, 0x0200, 0x0000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, }; static unsigned short CONF_type_win32[256] = { 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0010, 0x0010, 0x0000, 0x0000, 0x0010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0010, 0x0200, 0x0400, 0x0000, 0x0000, 0x0200, 0x0200, 0x0000, 0x0000, 0x0000, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0A00, 0x0000, 0x0000, 0x0000, 0x0200, 0x0200, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0000, 0x0000, 0x0000, 0x0200, 0x0100, 0x0000, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0000, 0x0200, 0x0000, 0x0200, 0x0000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/0000755000000000000000000000000012666635521020644 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/digest.c0000644000175000017500000002771412360020705020503 0ustar /* $OpenBSD: digest.c,v 1.20 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif void EVP_MD_CTX_init(EVP_MD_CTX *ctx) { memset(ctx, 0, sizeof *ctx); } EVP_MD_CTX * EVP_MD_CTX_create(void) { return calloc(1, sizeof(EVP_MD_CTX)); } int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type) { EVP_MD_CTX_init(ctx); return EVP_DigestInit_ex(ctx, type, NULL); } int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) { EVP_MD_CTX_clear_flags(ctx, EVP_MD_CTX_FLAG_CLEANED); #ifndef OPENSSL_NO_ENGINE /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts * so this context may already have an ENGINE! Try to avoid releasing * the previous handle, re-querying for an ENGINE, and having a * reinitialisation, when it may all be unecessary. */ if (ctx->engine && ctx->digest && (!type || (type && (type->type == ctx->digest->type)))) goto skip_to_init; if (type) { /* Ensure an ENGINE left lying around from last time is cleared * (the previous check attempted to avoid this if the same * ENGINE and EVP_MD could be used). */ if (ctx->engine) ENGINE_finish(ctx->engine); if (impl) { if (!ENGINE_init(impl)) { EVPerr(EVP_F_EVP_DIGESTINIT_EX, EVP_R_INITIALIZATION_ERROR); return 0; } } else /* Ask if an ENGINE is reserved for this job */ impl = ENGINE_get_digest_engine(type->type); if (impl) { /* There's an ENGINE for this job ... (apparently) */ const EVP_MD *d = ENGINE_get_digest(impl, type->type); if (!d) { /* Same comment from evp_enc.c */ EVPerr(EVP_F_EVP_DIGESTINIT_EX, EVP_R_INITIALIZATION_ERROR); ENGINE_finish(impl); return 0; } /* We'll use the ENGINE's private digest definition */ type = d; /* Store the ENGINE functional reference so we know * 'type' came from an ENGINE and we need to release * it when done. */ ctx->engine = impl; } else ctx->engine = NULL; } else if (!ctx->digest) { EVPerr(EVP_F_EVP_DIGESTINIT_EX, EVP_R_NO_DIGEST_SET); return 0; } #endif if (ctx->digest != type) { if (ctx->digest && ctx->digest->ctx_size) free(ctx->md_data); ctx->digest = type; if (!(ctx->flags & EVP_MD_CTX_FLAG_NO_INIT) && type->ctx_size) { ctx->update = type->update; ctx->md_data = malloc(type->ctx_size); if (ctx->md_data == NULL) { EVPerr(EVP_F_EVP_DIGESTINIT_EX, ERR_R_MALLOC_FAILURE); return 0; } } } #ifndef OPENSSL_NO_ENGINE skip_to_init: #endif if (ctx->pctx) { int r; r = EVP_PKEY_CTX_ctrl(ctx->pctx, -1, EVP_PKEY_OP_TYPE_SIG, EVP_PKEY_CTRL_DIGESTINIT, 0, ctx); if (r <= 0 && (r != -2)) return 0; } if (ctx->flags & EVP_MD_CTX_FLAG_NO_INIT) return 1; return ctx->digest->init(ctx); } int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count) { return ctx->update(ctx, data, count); } /* The caller can assume that this removes any secret data from the context */ int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size) { int ret; ret = EVP_DigestFinal_ex(ctx, md, size); EVP_MD_CTX_cleanup(ctx); return ret; } /* The caller can assume that this removes any secret data from the context */ int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size) { int ret; OPENSSL_assert(ctx->digest->md_size <= EVP_MAX_MD_SIZE); ret = ctx->digest->final(ctx, md); if (size != NULL) *size = ctx->digest->md_size; if (ctx->digest->cleanup) { ctx->digest->cleanup(ctx); EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_CLEANED); } memset(ctx->md_data, 0, ctx->digest->ctx_size); return ret; } int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in) { EVP_MD_CTX_init(out); return EVP_MD_CTX_copy_ex(out, in); } int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in) { unsigned char *tmp_buf; if ((in == NULL) || (in->digest == NULL)) { EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, EVP_R_INPUT_NOT_INITIALIZED); return 0; } #ifndef OPENSSL_NO_ENGINE /* Make sure it's safe to copy a digest context using an ENGINE */ if (in->engine && !ENGINE_init(in->engine)) { EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, ERR_R_ENGINE_LIB); return 0; } #endif if (out->digest == in->digest) { tmp_buf = out->md_data; EVP_MD_CTX_set_flags(out, EVP_MD_CTX_FLAG_REUSE); } else tmp_buf = NULL; EVP_MD_CTX_cleanup(out); memcpy(out, in, sizeof *out); if (in->md_data && out->digest->ctx_size) { if (tmp_buf) out->md_data = tmp_buf; else { out->md_data = malloc(out->digest->ctx_size); if (!out->md_data) { EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, ERR_R_MALLOC_FAILURE); return 0; } } memcpy(out->md_data, in->md_data, out->digest->ctx_size); } out->update = in->update; if (in->pctx) { out->pctx = EVP_PKEY_CTX_dup(in->pctx); if (!out->pctx) { EVP_MD_CTX_cleanup(out); return 0; } } if (out->digest->copy) return out->digest->copy(out, in); return 1; } int EVP_Digest(const void *data, size_t count, unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl) { EVP_MD_CTX ctx; int ret; EVP_MD_CTX_init(&ctx); EVP_MD_CTX_set_flags(&ctx, EVP_MD_CTX_FLAG_ONESHOT); ret = EVP_DigestInit_ex(&ctx, type, impl) && EVP_DigestUpdate(&ctx, data, count) && EVP_DigestFinal_ex(&ctx, md, size); EVP_MD_CTX_cleanup(&ctx); return ret; } void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx) { if (ctx) { EVP_MD_CTX_cleanup(ctx); free(ctx); } } /* This call frees resources associated with the context */ int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) { /* Don't assume ctx->md_data was cleaned in EVP_Digest_Final, * because sometimes only copies of the context are ever finalised. */ if (ctx->digest && ctx->digest->cleanup && !EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_CLEANED)) ctx->digest->cleanup(ctx); if (ctx->digest && ctx->digest->ctx_size && ctx->md_data && !EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_REUSE)) { OPENSSL_cleanse(ctx->md_data, ctx->digest->ctx_size); free(ctx->md_data); } if (ctx->pctx) EVP_PKEY_CTX_free(ctx->pctx); #ifndef OPENSSL_NO_ENGINE if (ctx->engine) /* The EVP_MD we used belongs to an ENGINE, release the * functional reference we held for this reason. */ ENGINE_finish(ctx->engine); #endif memset(ctx, 0, sizeof *ctx); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/pmeth_lib.c0000644000175000017500000003513012360020705021156 0ustar /* $OpenBSD: pmeth_lib.c,v 1.7 2014/07/10 22:45:57 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif #include "asn1_locl.h" #include "evp_locl.h" typedef int sk_cmp_fn_type(const char * const *a, const char * const *b); DECLARE_STACK_OF(EVP_PKEY_METHOD) STACK_OF(EVP_PKEY_METHOD) *app_pkey_methods = NULL; extern const EVP_PKEY_METHOD rsa_pkey_meth, dh_pkey_meth, dsa_pkey_meth; extern const EVP_PKEY_METHOD ec_pkey_meth, hmac_pkey_meth, cmac_pkey_meth; static const EVP_PKEY_METHOD *standard_methods[] = { #ifndef OPENSSL_NO_RSA &rsa_pkey_meth, #endif #ifndef OPENSSL_NO_DH &dh_pkey_meth, #endif #ifndef OPENSSL_NO_DSA &dsa_pkey_meth, #endif #ifndef OPENSSL_NO_EC &ec_pkey_meth, #endif &hmac_pkey_meth, &cmac_pkey_meth }; DECLARE_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_METHOD *, const EVP_PKEY_METHOD *, pmeth); static int pmeth_cmp(const EVP_PKEY_METHOD * const *a, const EVP_PKEY_METHOD * const *b) { return ((*a)->pkey_id - (*b)->pkey_id); } IMPLEMENT_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_METHOD *, const EVP_PKEY_METHOD *, pmeth); const EVP_PKEY_METHOD * EVP_PKEY_meth_find(int type) { EVP_PKEY_METHOD tmp; const EVP_PKEY_METHOD *t = &tmp, **ret; tmp.pkey_id = type; if (app_pkey_methods) { int idx; idx = sk_EVP_PKEY_METHOD_find(app_pkey_methods, &tmp); if (idx >= 0) return sk_EVP_PKEY_METHOD_value(app_pkey_methods, idx); } ret = OBJ_bsearch_pmeth(&t, standard_methods, sizeof(standard_methods)/sizeof(EVP_PKEY_METHOD *)); if (!ret || !*ret) return NULL; return *ret; } static EVP_PKEY_CTX * int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id) { EVP_PKEY_CTX *ret; const EVP_PKEY_METHOD *pmeth; if (id == -1) { if (!pkey || !pkey->ameth) return NULL; id = pkey->ameth->pkey_id; } #ifndef OPENSSL_NO_ENGINE if (pkey && pkey->engine) e = pkey->engine; /* Try to find an ENGINE which implements this method */ if (e) { if (!ENGINE_init(e)) { EVPerr(EVP_F_INT_CTX_NEW, ERR_R_ENGINE_LIB); return NULL; } } else e = ENGINE_get_pkey_meth_engine(id); /* If an ENGINE handled this method look it up. Othewise * use internal tables. */ if (e) pmeth = ENGINE_get_pkey_meth(e, id); else #endif pmeth = EVP_PKEY_meth_find(id); if (pmeth == NULL) { EVPerr(EVP_F_INT_CTX_NEW, EVP_R_UNSUPPORTED_ALGORITHM); return NULL; } ret = malloc(sizeof(EVP_PKEY_CTX)); if (!ret) { #ifndef OPENSSL_NO_ENGINE if (e) ENGINE_finish(e); #endif EVPerr(EVP_F_INT_CTX_NEW, ERR_R_MALLOC_FAILURE); return NULL; } ret->engine = e; ret->pmeth = pmeth; ret->operation = EVP_PKEY_OP_UNDEFINED; ret->pkey = pkey; ret->peerkey = NULL; ret->pkey_gencb = 0; if (pkey) CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY); ret->data = NULL; if (pmeth->init) { if (pmeth->init(ret) <= 0) { EVP_PKEY_CTX_free(ret); return NULL; } } return ret; } EVP_PKEY_METHOD* EVP_PKEY_meth_new(int id, int flags) { EVP_PKEY_METHOD *pmeth; pmeth = calloc(1, sizeof(EVP_PKEY_METHOD)); if (!pmeth) return NULL; pmeth->pkey_id = id; pmeth->flags = flags | EVP_PKEY_FLAG_DYNAMIC; pmeth->init = 0; pmeth->copy = 0; pmeth->cleanup = 0; pmeth->paramgen_init = 0; pmeth->paramgen = 0; pmeth->keygen_init = 0; pmeth->keygen = 0; pmeth->sign_init = 0; pmeth->sign = 0; pmeth->verify_init = 0; pmeth->verify = 0; pmeth->verify_recover_init = 0; pmeth->verify_recover = 0; pmeth->signctx_init = 0; pmeth->signctx = 0; pmeth->verifyctx_init = 0; pmeth->verifyctx = 0; pmeth->encrypt_init = 0; pmeth->encrypt = 0; pmeth->decrypt_init = 0; pmeth->decrypt = 0; pmeth->derive_init = 0; pmeth->derive = 0; pmeth->ctrl = 0; pmeth->ctrl_str = 0; return pmeth; } void EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags, const EVP_PKEY_METHOD *meth) { if (ppkey_id) *ppkey_id = meth->pkey_id; if (pflags) *pflags = meth->flags; } void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src) { dst->init = src->init; dst->copy = src->copy; dst->cleanup = src->cleanup; dst->paramgen_init = src->paramgen_init; dst->paramgen = src->paramgen; dst->keygen_init = src->keygen_init; dst->keygen = src->keygen; dst->sign_init = src->sign_init; dst->sign = src->sign; dst->verify_init = src->verify_init; dst->verify = src->verify; dst->verify_recover_init = src->verify_recover_init; dst->verify_recover = src->verify_recover; dst->signctx_init = src->signctx_init; dst->signctx = src->signctx; dst->verifyctx_init = src->verifyctx_init; dst->verifyctx = src->verifyctx; dst->encrypt_init = src->encrypt_init; dst->encrypt = src->encrypt; dst->decrypt_init = src->decrypt_init; dst->decrypt = src->decrypt; dst->derive_init = src->derive_init; dst->derive = src->derive; dst->ctrl = src->ctrl; dst->ctrl_str = src->ctrl_str; } void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth) { if (pmeth && (pmeth->flags & EVP_PKEY_FLAG_DYNAMIC)) free(pmeth); } EVP_PKEY_CTX * EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e) { return int_ctx_new(pkey, e, -1); } EVP_PKEY_CTX * EVP_PKEY_CTX_new_id(int id, ENGINE *e) { return int_ctx_new(NULL, e, id); } EVP_PKEY_CTX * EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx) { EVP_PKEY_CTX *rctx; if (!pctx->pmeth || !pctx->pmeth->copy) return NULL; #ifndef OPENSSL_NO_ENGINE /* Make sure it's safe to copy a pkey context using an ENGINE */ if (pctx->engine && !ENGINE_init(pctx->engine)) { EVPerr(EVP_F_EVP_PKEY_CTX_DUP, ERR_R_ENGINE_LIB); return 0; } #endif rctx = malloc(sizeof(EVP_PKEY_CTX)); if (!rctx) return NULL; rctx->pmeth = pctx->pmeth; #ifndef OPENSSL_NO_ENGINE rctx->engine = pctx->engine; #endif if (pctx->pkey) CRYPTO_add(&pctx->pkey->references, 1, CRYPTO_LOCK_EVP_PKEY); rctx->pkey = pctx->pkey; if (pctx->peerkey) CRYPTO_add(&pctx->peerkey->references, 1, CRYPTO_LOCK_EVP_PKEY); rctx->peerkey = pctx->peerkey; rctx->data = NULL; rctx->app_data = NULL; rctx->operation = pctx->operation; if (pctx->pmeth->copy(rctx, pctx) > 0) return rctx; EVP_PKEY_CTX_free(rctx); return NULL; } int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth) { if (app_pkey_methods == NULL) { app_pkey_methods = sk_EVP_PKEY_METHOD_new(pmeth_cmp); if (!app_pkey_methods) return 0; } if (!sk_EVP_PKEY_METHOD_push(app_pkey_methods, pmeth)) return 0; sk_EVP_PKEY_METHOD_sort(app_pkey_methods); return 1; } void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx) { if (ctx == NULL) return; if (ctx->pmeth && ctx->pmeth->cleanup) ctx->pmeth->cleanup(ctx); if (ctx->pkey) EVP_PKEY_free(ctx->pkey); if (ctx->peerkey) EVP_PKEY_free(ctx->peerkey); #ifndef OPENSSL_NO_ENGINE if (ctx->engine) /* The EVP_PKEY_CTX we used belongs to an ENGINE, release the * functional reference we held for this reason. */ ENGINE_finish(ctx->engine); #endif free(ctx); } int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, int cmd, int p1, void *p2) { int ret; if (!ctx || !ctx->pmeth || !ctx->pmeth->ctrl) { EVPerr(EVP_F_EVP_PKEY_CTX_CTRL, EVP_R_COMMAND_NOT_SUPPORTED); return -2; } if ((keytype != -1) && (ctx->pmeth->pkey_id != keytype)) return -1; if (ctx->operation == EVP_PKEY_OP_UNDEFINED) { EVPerr(EVP_F_EVP_PKEY_CTX_CTRL, EVP_R_NO_OPERATION_SET); return -1; } if ((optype != -1) && !(ctx->operation & optype)) { EVPerr(EVP_F_EVP_PKEY_CTX_CTRL, EVP_R_INVALID_OPERATION); return -1; } ret = ctx->pmeth->ctrl(ctx, cmd, p1, p2); if (ret == -2) EVPerr(EVP_F_EVP_PKEY_CTX_CTRL, EVP_R_COMMAND_NOT_SUPPORTED); return ret; } int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *name, const char *value) { if (!ctx || !ctx->pmeth || !ctx->pmeth->ctrl_str) { EVPerr(EVP_F_EVP_PKEY_CTX_CTRL_STR, EVP_R_COMMAND_NOT_SUPPORTED); return -2; } if (!strcmp(name, "digest")) { const EVP_MD *md; if (!value || !(md = EVP_get_digestbyname(value))) { EVPerr(EVP_F_EVP_PKEY_CTX_CTRL_STR, EVP_R_INVALID_DIGEST); return 0; } return EVP_PKEY_CTX_set_signature_md(ctx, md); } return ctx->pmeth->ctrl_str(ctx, name, value); } int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx) { return ctx->operation; } void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen) { ctx->keygen_info = dat; ctx->keygen_info_count = datlen; } void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data) { ctx->data = data; } void * EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx) { return ctx->data; } EVP_PKEY * EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx) { return ctx->pkey; } EVP_PKEY * EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx) { return ctx->peerkey; } void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data) { ctx->app_data = data; } void * EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx) { return ctx->app_data; } void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth, int (*init)(EVP_PKEY_CTX *ctx)) { pmeth->init = init; } void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth, int (*copy)(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)) { pmeth->copy = copy; } void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth, void (*cleanup)(EVP_PKEY_CTX *ctx)) { pmeth->cleanup = cleanup; } void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth, int (*paramgen_init)(EVP_PKEY_CTX *ctx), int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)) { pmeth->paramgen_init = paramgen_init; pmeth->paramgen = paramgen; } void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth, int (*keygen_init)(EVP_PKEY_CTX *ctx), int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)) { pmeth->keygen_init = keygen_init; pmeth->keygen = keygen; } void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth, int (*sign_init)(EVP_PKEY_CTX *ctx), int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, const unsigned char *tbs, size_t tbslen)) { pmeth->sign_init = sign_init; pmeth->sign = sign; } void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth, int (*verify_init)(EVP_PKEY_CTX *ctx), int (*verify)(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, const unsigned char *tbs, size_t tbslen)) { pmeth->verify_init = verify_init; pmeth->verify = verify; } void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth, int (*verify_recover_init)(EVP_PKEY_CTX *ctx), int (*verify_recover)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, const unsigned char *tbs, size_t tbslen)) { pmeth->verify_recover_init = verify_recover_init; pmeth->verify_recover = verify_recover; } void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth, int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx), int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, EVP_MD_CTX *mctx)) { pmeth->signctx_init = signctx_init; pmeth->signctx = signctx; } void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth, int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx), int (*verifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen, EVP_MD_CTX *mctx)) { pmeth->verifyctx_init = verifyctx_init; pmeth->verifyctx = verifyctx; } void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth, int (*encrypt_init)(EVP_PKEY_CTX *ctx), int (*encryptfn)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, const unsigned char *in, size_t inlen)) { pmeth->encrypt_init = encrypt_init; pmeth->encrypt = encryptfn; } void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth, int (*decrypt_init)(EVP_PKEY_CTX *ctx), int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, const unsigned char *in, size_t inlen)) { pmeth->decrypt_init = decrypt_init; pmeth->decrypt = decrypt; } void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth, int (*derive_init)(EVP_PKEY_CTX *ctx), int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen)) { pmeth->derive_init = derive_init; pmeth->derive = derive; } void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth, int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2), int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value)) { pmeth->ctrl = ctrl; pmeth->ctrl_str = ctrl_str; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/m_ecdsa.c0000644000175000017500000001532512360020705020612 0ustar /* $OpenBSD: m_ecdsa.c,v 1.7 2014/07/10 22:45:57 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #ifndef OPENSSL_NO_SHA static int init(EVP_MD_CTX *ctx) { return SHA1_Init(ctx->md_data); } static int update(EVP_MD_CTX *ctx, const void *data, size_t count) { return SHA1_Update(ctx->md_data, data, count); } static int final(EVP_MD_CTX *ctx, unsigned char *md) { return SHA1_Final(md, ctx->md_data); } static const EVP_MD ecdsa_md = { .type = NID_ecdsa_with_SHA1, .pkey_type = NID_ecdsa_with_SHA1, .md_size = SHA_DIGEST_LENGTH, .flags = EVP_MD_FLAG_PKEY_DIGEST, .init = init, .update = update, .final = final, .copy = NULL, .cleanup = NULL, #ifndef OPENSSL_NO_ECDSA .sign = (evp_sign_method *)ECDSA_sign, .verify = (evp_verify_method *)ECDSA_verify, .required_pkey_type = { EVP_PKEY_EC, 0, 0, 0, }, #endif .block_size = SHA_CBLOCK, .ctx_size = sizeof(EVP_MD *) + sizeof(SHA_CTX), }; const EVP_MD * EVP_ecdsa(void) { return (&ecdsa_md); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/c_all.c0000644000175000017500000000711212360020705020264 0ustar /* $OpenBSD: c_all.c,v 1.13 2014/06/12 15:49:29 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif #include "cryptlib.h" void OPENSSL_add_all_algorithms_noconf(void) { OPENSSL_cpuid_setup(); OpenSSL_add_all_ciphers(); OpenSSL_add_all_digests(); } void OPENSSL_add_all_algorithms_conf(void) { OPENSSL_add_all_algorithms_noconf(); OPENSSL_config(NULL); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/c_allc.c0000644000175000017500000002055412360020705020434 0ustar /* $OpenBSD: c_allc.c,v 1.12 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include void OpenSSL_add_all_ciphers(void) { #ifndef OPENSSL_NO_DES EVP_add_cipher(EVP_des_cfb()); EVP_add_cipher(EVP_des_cfb1()); EVP_add_cipher(EVP_des_cfb8()); EVP_add_cipher(EVP_des_ede_cfb()); EVP_add_cipher(EVP_des_ede3_cfb()); EVP_add_cipher(EVP_des_ede3_cfb1()); EVP_add_cipher(EVP_des_ede3_cfb8()); EVP_add_cipher(EVP_des_ofb()); EVP_add_cipher(EVP_des_ede_ofb()); EVP_add_cipher(EVP_des_ede3_ofb()); EVP_add_cipher(EVP_desx_cbc()); EVP_add_cipher_alias(SN_desx_cbc, "DESX"); EVP_add_cipher_alias(SN_desx_cbc, "desx"); EVP_add_cipher(EVP_des_cbc()); EVP_add_cipher_alias(SN_des_cbc, "DES"); EVP_add_cipher_alias(SN_des_cbc, "des"); EVP_add_cipher(EVP_des_ede_cbc()); EVP_add_cipher(EVP_des_ede3_cbc()); EVP_add_cipher_alias(SN_des_ede3_cbc, "DES3"); EVP_add_cipher_alias(SN_des_ede3_cbc, "des3"); EVP_add_cipher(EVP_des_ecb()); EVP_add_cipher(EVP_des_ede()); EVP_add_cipher(EVP_des_ede3()); #endif #ifndef OPENSSL_NO_RC4 EVP_add_cipher(EVP_rc4()); EVP_add_cipher(EVP_rc4_40()); #ifndef OPENSSL_NO_MD5 EVP_add_cipher(EVP_rc4_hmac_md5()); #endif #endif #ifndef OPENSSL_NO_IDEA EVP_add_cipher(EVP_idea_ecb()); EVP_add_cipher(EVP_idea_cfb()); EVP_add_cipher(EVP_idea_ofb()); EVP_add_cipher(EVP_idea_cbc()); EVP_add_cipher_alias(SN_idea_cbc, "IDEA"); EVP_add_cipher_alias(SN_idea_cbc, "idea"); #endif #ifndef OPENSSL_NO_RC2 EVP_add_cipher(EVP_rc2_ecb()); EVP_add_cipher(EVP_rc2_cfb()); EVP_add_cipher(EVP_rc2_ofb()); EVP_add_cipher(EVP_rc2_cbc()); EVP_add_cipher(EVP_rc2_40_cbc()); EVP_add_cipher(EVP_rc2_64_cbc()); EVP_add_cipher_alias(SN_rc2_cbc, "RC2"); EVP_add_cipher_alias(SN_rc2_cbc, "rc2"); #endif #ifndef OPENSSL_NO_BF EVP_add_cipher(EVP_bf_ecb()); EVP_add_cipher(EVP_bf_cfb()); EVP_add_cipher(EVP_bf_ofb()); EVP_add_cipher(EVP_bf_cbc()); EVP_add_cipher_alias(SN_bf_cbc, "BF"); EVP_add_cipher_alias(SN_bf_cbc, "bf"); EVP_add_cipher_alias(SN_bf_cbc, "blowfish"); #endif #ifndef OPENSSL_NO_CAST EVP_add_cipher(EVP_cast5_ecb()); EVP_add_cipher(EVP_cast5_cfb()); EVP_add_cipher(EVP_cast5_ofb()); EVP_add_cipher(EVP_cast5_cbc()); EVP_add_cipher_alias(SN_cast5_cbc, "CAST"); EVP_add_cipher_alias(SN_cast5_cbc, "cast"); EVP_add_cipher_alias(SN_cast5_cbc, "CAST-cbc"); EVP_add_cipher_alias(SN_cast5_cbc, "cast-cbc"); #endif #ifndef OPENSSL_NO_RC5 EVP_add_cipher(EVP_rc5_32_12_16_ecb()); EVP_add_cipher(EVP_rc5_32_12_16_cfb()); EVP_add_cipher(EVP_rc5_32_12_16_ofb()); EVP_add_cipher(EVP_rc5_32_12_16_cbc()); EVP_add_cipher_alias(SN_rc5_cbc, "rc5"); EVP_add_cipher_alias(SN_rc5_cbc, "RC5"); #endif #ifndef OPENSSL_NO_AES EVP_add_cipher(EVP_aes_128_ecb()); EVP_add_cipher(EVP_aes_128_cbc()); EVP_add_cipher(EVP_aes_128_cfb()); EVP_add_cipher(EVP_aes_128_cfb1()); EVP_add_cipher(EVP_aes_128_cfb8()); EVP_add_cipher(EVP_aes_128_ofb()); EVP_add_cipher(EVP_aes_128_ctr()); EVP_add_cipher(EVP_aes_128_gcm()); EVP_add_cipher(EVP_aes_128_xts()); EVP_add_cipher_alias(SN_aes_128_cbc, "AES128"); EVP_add_cipher_alias(SN_aes_128_cbc, "aes128"); EVP_add_cipher(EVP_aes_192_ecb()); EVP_add_cipher(EVP_aes_192_cbc()); EVP_add_cipher(EVP_aes_192_cfb()); EVP_add_cipher(EVP_aes_192_cfb1()); EVP_add_cipher(EVP_aes_192_cfb8()); EVP_add_cipher(EVP_aes_192_ofb()); EVP_add_cipher(EVP_aes_192_ctr()); EVP_add_cipher(EVP_aes_192_gcm()); EVP_add_cipher_alias(SN_aes_192_cbc, "AES192"); EVP_add_cipher_alias(SN_aes_192_cbc, "aes192"); EVP_add_cipher(EVP_aes_256_ecb()); EVP_add_cipher(EVP_aes_256_cbc()); EVP_add_cipher(EVP_aes_256_cfb()); EVP_add_cipher(EVP_aes_256_cfb1()); EVP_add_cipher(EVP_aes_256_cfb8()); EVP_add_cipher(EVP_aes_256_ofb()); EVP_add_cipher(EVP_aes_256_ctr()); EVP_add_cipher(EVP_aes_256_gcm()); EVP_add_cipher(EVP_aes_256_xts()); EVP_add_cipher_alias(SN_aes_256_cbc, "AES256"); EVP_add_cipher_alias(SN_aes_256_cbc, "aes256"); #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1) EVP_add_cipher(EVP_aes_128_cbc_hmac_sha1()); EVP_add_cipher(EVP_aes_256_cbc_hmac_sha1()); #endif #endif #ifndef OPENSSL_NO_CAMELLIA EVP_add_cipher(EVP_camellia_128_ecb()); EVP_add_cipher(EVP_camellia_128_cbc()); EVP_add_cipher(EVP_camellia_128_cfb()); EVP_add_cipher(EVP_camellia_128_cfb1()); EVP_add_cipher(EVP_camellia_128_cfb8()); EVP_add_cipher(EVP_camellia_128_ofb()); EVP_add_cipher_alias(SN_camellia_128_cbc, "CAMELLIA128"); EVP_add_cipher_alias(SN_camellia_128_cbc, "camellia128"); EVP_add_cipher(EVP_camellia_192_ecb()); EVP_add_cipher(EVP_camellia_192_cbc()); EVP_add_cipher(EVP_camellia_192_cfb()); EVP_add_cipher(EVP_camellia_192_cfb1()); EVP_add_cipher(EVP_camellia_192_cfb8()); EVP_add_cipher(EVP_camellia_192_ofb()); EVP_add_cipher_alias(SN_camellia_192_cbc, "CAMELLIA192"); EVP_add_cipher_alias(SN_camellia_192_cbc, "camellia192"); EVP_add_cipher(EVP_camellia_256_ecb()); EVP_add_cipher(EVP_camellia_256_cbc()); EVP_add_cipher(EVP_camellia_256_cfb()); EVP_add_cipher(EVP_camellia_256_cfb1()); EVP_add_cipher(EVP_camellia_256_cfb8()); EVP_add_cipher(EVP_camellia_256_ofb()); EVP_add_cipher_alias(SN_camellia_256_cbc, "CAMELLIA256"); EVP_add_cipher_alias(SN_camellia_256_cbc, "camellia256"); #endif #ifndef OPENSSL_NO_CHACHA EVP_add_cipher(EVP_chacha20()); #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/names.c0000644000175000017500000001514312360020705020320 0ustar /* $OpenBSD: names.c,v 1.11 2014/06/12 15:49:29 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include int EVP_add_cipher(const EVP_CIPHER *c) { int r; if (c == NULL) return 0; OPENSSL_init(); r = OBJ_NAME_add(OBJ_nid2sn(c->nid), OBJ_NAME_TYPE_CIPHER_METH, (const char *)c); if (r == 0) return (0); check_defer(c->nid); r = OBJ_NAME_add(OBJ_nid2ln(c->nid), OBJ_NAME_TYPE_CIPHER_METH, (const char *)c); return (r); } int EVP_add_digest(const EVP_MD *md) { int r; const char *name; OPENSSL_init(); name = OBJ_nid2sn(md->type); r = OBJ_NAME_add(name, OBJ_NAME_TYPE_MD_METH, (const char *)md); if (r == 0) return (0); check_defer(md->type); r = OBJ_NAME_add(OBJ_nid2ln(md->type), OBJ_NAME_TYPE_MD_METH, (const char *)md); if (r == 0) return (0); if (md->pkey_type && md->type != md->pkey_type) { r = OBJ_NAME_add(OBJ_nid2sn(md->pkey_type), OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS, name); if (r == 0) return (0); check_defer(md->pkey_type); r = OBJ_NAME_add(OBJ_nid2ln(md->pkey_type), OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS, name); } return (r); } const EVP_CIPHER * EVP_get_cipherbyname(const char *name) { const EVP_CIPHER *cp; cp = (const EVP_CIPHER *)OBJ_NAME_get(name, OBJ_NAME_TYPE_CIPHER_METH); return (cp); } const EVP_MD * EVP_get_digestbyname(const char *name) { const EVP_MD *cp; cp = (const EVP_MD *)OBJ_NAME_get(name, OBJ_NAME_TYPE_MD_METH); return (cp); } void EVP_cleanup(void) { OBJ_NAME_cleanup(OBJ_NAME_TYPE_CIPHER_METH); OBJ_NAME_cleanup(OBJ_NAME_TYPE_MD_METH); /* The above calls will only clean out the contents of the name hash table, but not the hash table itself. The following line does that part. -- Richard Levitte */ OBJ_NAME_cleanup(-1); EVP_PBE_cleanup(); if (obj_cleanup_defer == 2) { obj_cleanup_defer = 0; OBJ_cleanup(); } OBJ_sigid_free(); } struct doall_cipher { void *arg; void (*fn)(const EVP_CIPHER *ciph, const char *from, const char *to, void *arg); }; static void do_all_cipher_fn(const OBJ_NAME *nm, void *arg) { struct doall_cipher *dc = arg; if (nm->alias) dc->fn(NULL, nm->name, nm->data, dc->arg); else dc->fn((const EVP_CIPHER *)nm->data, nm->name, NULL, dc->arg); } void EVP_CIPHER_do_all(void (*fn)(const EVP_CIPHER *ciph, const char *from, const char *to, void *x), void *arg) { struct doall_cipher dc; dc.fn = fn; dc.arg = arg; OBJ_NAME_do_all(OBJ_NAME_TYPE_CIPHER_METH, do_all_cipher_fn, &dc); } void EVP_CIPHER_do_all_sorted(void (*fn)(const EVP_CIPHER *ciph, const char *from, const char *to, void *x), void *arg) { struct doall_cipher dc; dc.fn = fn; dc.arg = arg; OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH, do_all_cipher_fn, &dc); } struct doall_md { void *arg; void (*fn)(const EVP_MD *ciph, const char *from, const char *to, void *arg); }; static void do_all_md_fn(const OBJ_NAME *nm, void *arg) { struct doall_md *dc = arg; if (nm->alias) dc->fn(NULL, nm->name, nm->data, dc->arg); else dc->fn((const EVP_MD *)nm->data, nm->name, NULL, dc->arg); } void EVP_MD_do_all(void (*fn)(const EVP_MD *md, const char *from, const char *to, void *x), void *arg) { struct doall_md dc; dc.fn = fn; dc.arg = arg; OBJ_NAME_do_all(OBJ_NAME_TYPE_MD_METH, do_all_md_fn, &dc); } void EVP_MD_do_all_sorted(void (*fn)(const EVP_MD *md, const char *from, const char *to, void *x), void *arg) { struct doall_md dc; dc.fn = fn; dc.arg = arg; OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_MD_METH, do_all_md_fn, &dc); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/bio_b64.c0000644000175000017500000003465012360020705020445 0ustar /* $OpenBSD: bio_b64.c,v 1.18 2014/07/11 08:44:48 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include static int b64_write(BIO *h, const char *buf, int num); static int b64_read(BIO *h, char *buf, int size); static int b64_puts(BIO *h, const char *str); /*static int b64_gets(BIO *h, char *str, int size); */ static long b64_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int b64_new(BIO *h); static int b64_free(BIO *data); static long b64_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); #define B64_BLOCK_SIZE 1024 #define B64_BLOCK_SIZE2 768 #define B64_NONE 0 #define B64_ENCODE 1 #define B64_DECODE 2 typedef struct b64_struct { /*BIO *bio; moved to the BIO structure */ int buf_len; int buf_off; int tmp_len; /* used to find the start when decoding */ int tmp_nl; /* If true, scan until '\n' */ int encode; int start; /* have we started decoding yet? */ int cont; /* <= 0 when finished */ EVP_ENCODE_CTX base64; char buf[EVP_ENCODE_LENGTH(B64_BLOCK_SIZE) + 10]; char tmp[B64_BLOCK_SIZE]; } BIO_B64_CTX; static BIO_METHOD methods_b64 = { .type = BIO_TYPE_BASE64, .name = "base64 encoding", .bwrite = b64_write, .bread = b64_read, .bputs = b64_puts, .ctrl = b64_ctrl, .create = b64_new, .destroy = b64_free, .callback_ctrl = b64_callback_ctrl }; BIO_METHOD * BIO_f_base64(void) { return (&methods_b64); } static int b64_new(BIO *bi) { BIO_B64_CTX *ctx; ctx = malloc(sizeof(BIO_B64_CTX)); if (ctx == NULL) return (0); ctx->buf_len = 0; ctx->tmp_len = 0; ctx->tmp_nl = 0; ctx->buf_off = 0; ctx->cont = 1; ctx->start = 1; ctx->encode = 0; bi->init = 1; bi->ptr = (char *)ctx; bi->flags = 0; bi->num = 0; return (1); } static int b64_free(BIO *a) { if (a == NULL) return (0); free(a->ptr); a->ptr = NULL; a->init = 0; a->flags = 0; return (1); } static int b64_read(BIO *b, char *out, int outl) { int ret = 0, i, ii, j, k, x, n, num, ret_code = 0; BIO_B64_CTX *ctx; unsigned char *p, *q; if (out == NULL) return (0); ctx = (BIO_B64_CTX *)b->ptr; if ((ctx == NULL) || (b->next_bio == NULL)) return (0); BIO_clear_retry_flags(b); if (ctx->encode != B64_DECODE) { ctx->encode = B64_DECODE; ctx->buf_len = 0; ctx->buf_off = 0; ctx->tmp_len = 0; EVP_DecodeInit(&(ctx->base64)); } /* First check if there are bytes decoded/encoded */ if (ctx->buf_len > 0) { OPENSSL_assert(ctx->buf_len >= ctx->buf_off); i = ctx->buf_len - ctx->buf_off; if (i > outl) i = outl; OPENSSL_assert(ctx->buf_off + i < (int)sizeof(ctx->buf)); memcpy(out, &(ctx->buf[ctx->buf_off]), i); ret = i; out += i; outl -= i; ctx->buf_off += i; if (ctx->buf_len == ctx->buf_off) { ctx->buf_len = 0; ctx->buf_off = 0; } } /* At this point, we have room of outl bytes and an empty * buffer, so we should read in some more. */ ret_code = 0; while (outl > 0) { if (ctx->cont <= 0) break; i = BIO_read(b->next_bio, &(ctx->tmp[ctx->tmp_len]), B64_BLOCK_SIZE - ctx->tmp_len); if (i <= 0) { ret_code = i; /* Should we continue next time we are called? */ if (!BIO_should_retry(b->next_bio)) { ctx->cont = i; /* If buffer empty break */ if (ctx->tmp_len == 0) break; /* Fall through and process what we have */ else i = 0; } /* else we retry and add more data to buffer */ else break; } i += ctx->tmp_len; ctx->tmp_len = i; /* We need to scan, a line at a time until we * have a valid line if we are starting. */ if (ctx->start && (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL)) { /* ctx->start=1; */ ctx->tmp_len = 0; } else if (ctx->start) { q = p =(unsigned char *)ctx->tmp; num = 0; for (j = 0; j < i; j++) { if (*(q++) != '\n') continue; /* due to a previous very long line, * we need to keep on scanning for a '\n' * before we even start looking for * base64 encoded stuff. */ if (ctx->tmp_nl) { p = q; ctx->tmp_nl = 0; continue; } k = EVP_DecodeUpdate(&(ctx->base64), (unsigned char *)ctx->buf, &num, p, q - p); if ((k <= 0) && (num == 0) && (ctx->start)) EVP_DecodeInit(&ctx->base64); else { if (p != (unsigned char *) &(ctx->tmp[0])) { i -= (p - (unsigned char *) &(ctx->tmp[0])); for (x = 0; x < i; x++) ctx->tmp[x] = p[x]; } EVP_DecodeInit(&ctx->base64); ctx->start = 0; break; } p = q; } /* we fell off the end without starting */ if ((j == i) && (num == 0)) { /* Is this is one long chunk?, if so, keep on * reading until a new line. */ if (p == (unsigned char *)&(ctx->tmp[0])) { /* Check buffer full */ if (i == B64_BLOCK_SIZE) { ctx->tmp_nl = 1; ctx->tmp_len = 0; } } else if (p != q) /* finished on a '\n' */ { n = q - p; for (ii = 0; ii < n; ii++) ctx->tmp[ii] = p[ii]; ctx->tmp_len = n; } /* else finished on a '\n' */ continue; } else { ctx->tmp_len = 0; } } else if ((i < B64_BLOCK_SIZE) && (ctx->cont > 0)) { /* If buffer isn't full and we can retry then * restart to read in more data. */ continue; } if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL) { int z, jj; #if 0 jj = (i >> 2) << 2; #else jj = i & ~3; /* process per 4 */ #endif z = EVP_DecodeBlock((unsigned char *)ctx->buf, (unsigned char *)ctx->tmp, jj); if (jj > 2) { if (ctx->tmp[jj-1] == '=') { z--; if (ctx->tmp[jj-2] == '=') z--; } } /* z is now number of output bytes and jj is the * number consumed */ if (jj != i) { memmove(ctx->tmp, &ctx->tmp[jj], i - jj); ctx->tmp_len = i - jj; } ctx->buf_len = 0; if (z > 0) { ctx->buf_len = z; } i = z; } else { i = EVP_DecodeUpdate(&(ctx->base64), (unsigned char *)ctx->buf, &ctx->buf_len, (unsigned char *)ctx->tmp, i); ctx->tmp_len = 0; } ctx->buf_off = 0; if (i < 0) { ret_code = 0; ctx->buf_len = 0; break; } if (ctx->buf_len <= outl) i = ctx->buf_len; else i = outl; memcpy(out, ctx->buf, i); ret += i; ctx->buf_off = i; if (ctx->buf_off == ctx->buf_len) { ctx->buf_len = 0; ctx->buf_off = 0; } outl -= i; out += i; } /* BIO_clear_retry_flags(b); */ BIO_copy_next_retry(b); return ((ret == 0) ? ret_code : ret); } static int b64_write(BIO *b, const char *in, int inl) { int ret = 0; int n; int i; BIO_B64_CTX *ctx; ctx = (BIO_B64_CTX *)b->ptr; BIO_clear_retry_flags(b); if (ctx->encode != B64_ENCODE) { ctx->encode = B64_ENCODE; ctx->buf_len = 0; ctx->buf_off = 0; ctx->tmp_len = 0; EVP_EncodeInit(&(ctx->base64)); } OPENSSL_assert(ctx->buf_off < (int)sizeof(ctx->buf)); OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf)); OPENSSL_assert(ctx->buf_len >= ctx->buf_off); n = ctx->buf_len - ctx->buf_off; while (n > 0) { i = BIO_write(b->next_bio, &(ctx->buf[ctx->buf_off]), n); if (i <= 0) { BIO_copy_next_retry(b); return (i); } OPENSSL_assert(i <= n); ctx->buf_off += i; OPENSSL_assert(ctx->buf_off <= (int)sizeof(ctx->buf)); OPENSSL_assert(ctx->buf_len >= ctx->buf_off); n -= i; } /* at this point all pending data has been written */ ctx->buf_off = 0; ctx->buf_len = 0; if ((in == NULL) || (inl <= 0)) return (0); while (inl > 0) { n = (inl > B64_BLOCK_SIZE) ? B64_BLOCK_SIZE : inl; if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL) { if (ctx->tmp_len > 0) { OPENSSL_assert(ctx->tmp_len <= 3); n = 3 - ctx->tmp_len; /* There's a theoretical possibility for this */ if (n > inl) n = inl; memcpy(&(ctx->tmp[ctx->tmp_len]), in, n); ctx->tmp_len += n; ret += n; if (ctx->tmp_len < 3) break; ctx->buf_len = EVP_EncodeBlock( (unsigned char *)ctx->buf, (unsigned char *)ctx->tmp, ctx->tmp_len); OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf)); OPENSSL_assert(ctx->buf_len >= ctx->buf_off); /* Since we're now done using the temporary buffer, the length should be 0'd */ ctx->tmp_len = 0; } else { if (n < 3) { memcpy(ctx->tmp, in, n); ctx->tmp_len = n; ret += n; break; } n -= n % 3; ctx->buf_len = EVP_EncodeBlock( (unsigned char *)ctx->buf, (const unsigned char *)in, n); OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf)); OPENSSL_assert(ctx->buf_len >= ctx->buf_off); ret += n; } } else { EVP_EncodeUpdate(&(ctx->base64), (unsigned char *)ctx->buf, &ctx->buf_len, (unsigned char *)in, n); OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf)); OPENSSL_assert(ctx->buf_len >= ctx->buf_off); ret += n; } inl -= n; in += n; ctx->buf_off = 0; n = ctx->buf_len; while (n > 0) { i = BIO_write(b->next_bio, &(ctx->buf[ctx->buf_off]), n); if (i <= 0) { BIO_copy_next_retry(b); return ((ret == 0) ? i : ret); } OPENSSL_assert(i <= n); n -= i; ctx->buf_off += i; OPENSSL_assert(ctx->buf_off <= (int)sizeof(ctx->buf)); OPENSSL_assert(ctx->buf_len >= ctx->buf_off); } ctx->buf_len = 0; ctx->buf_off = 0; } return (ret); } static long b64_ctrl(BIO *b, int cmd, long num, void *ptr) { BIO_B64_CTX *ctx; long ret = 1; int i; ctx = (BIO_B64_CTX *)b->ptr; switch (cmd) { case BIO_CTRL_RESET: ctx->cont = 1; ctx->start = 1; ctx->encode = B64_NONE; ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; case BIO_CTRL_EOF: /* More to read */ if (ctx->cont <= 0) ret = 1; else ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; case BIO_CTRL_WPENDING: /* More to write in buffer */ OPENSSL_assert(ctx->buf_len >= ctx->buf_off); ret = ctx->buf_len - ctx->buf_off; if ((ret == 0) && (ctx->encode != B64_NONE) && (ctx->base64.num != 0)) ret = 1; else if (ret <= 0) ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; case BIO_CTRL_PENDING: /* More to read in buffer */ OPENSSL_assert(ctx->buf_len >= ctx->buf_off); ret = ctx->buf_len - ctx->buf_off; if (ret <= 0) ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; case BIO_CTRL_FLUSH: /* do a final write */ again: while (ctx->buf_len != ctx->buf_off) { i = b64_write(b, NULL, 0); if (i < 0) return i; } if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL) { if (ctx->tmp_len != 0) { ctx->buf_len = EVP_EncodeBlock( (unsigned char *)ctx->buf, (unsigned char *)ctx->tmp, ctx->tmp_len); ctx->buf_off = 0; ctx->tmp_len = 0; goto again; } } else if (ctx->encode != B64_NONE && ctx->base64.num != 0) { ctx->buf_off = 0; EVP_EncodeFinal(&(ctx->base64), (unsigned char *)ctx->buf, &(ctx->buf_len)); /* push out the bytes */ goto again; } /* Finally flush the underlying BIO */ ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; case BIO_C_DO_STATE_MACHINE: BIO_clear_retry_flags(b); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); BIO_copy_next_retry(b); break; case BIO_CTRL_DUP: break; case BIO_CTRL_INFO: case BIO_CTRL_GET: case BIO_CTRL_SET: default: ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; } return (ret); } static long b64_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) { long ret = 1; if (b->next_bio == NULL) return (0); switch (cmd) { default: ret = BIO_callback_ctrl(b->next_bio, cmd, fp); break; } return (ret); } static int b64_puts(BIO *b, const char *str) { return b64_write(b, str, strlen(str)); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/m_null.c0000644000175000017500000000750112360020705020502 0ustar /* $OpenBSD: m_null.c,v 1.8 2014/06/12 15:49:29 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include static int init(EVP_MD_CTX *ctx) { return 1; } static int update(EVP_MD_CTX *ctx, const void *data, size_t count) { return 1; } static int final(EVP_MD_CTX *ctx, unsigned char *md) { return 1; } static const EVP_MD null_md = { .type = NID_undef, .pkey_type = NID_undef, .md_size = 0, .flags = 0, .init = init, .update = update, .final = final, .copy = NULL, .cleanup = NULL, .sign = NULL, .verify = NULL, .required_pkey_type = { 0, 0, 0, 0, }, .block_size = 0, .ctx_size = sizeof(EVP_MD *), }; const EVP_MD * EVP_md_null(void) { return (&null_md); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/p5_crpt.c0000644000175000017500000001172712360020705020575 0ustar /* $OpenBSD: p5_crpt.c,v 1.12 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include /* Doesn't do anything now: Builtin PBE algorithms in static table. */ void PKCS5_PBE_add(void) { } int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, int en_de) { EVP_MD_CTX ctx; unsigned char md_tmp[EVP_MAX_MD_SIZE]; unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH]; int i; PBEPARAM *pbe; int saltlen, iter; unsigned char *salt; const unsigned char *pbuf; int mdsize; int rv = 0; EVP_MD_CTX_init(&ctx); /* Extract useful info from parameter */ if (param == NULL || param->type != V_ASN1_SEQUENCE || param->value.sequence == NULL) { EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN, EVP_R_DECODE_ERROR); return 0; } pbuf = param->value.sequence->data; if (!(pbe = d2i_PBEPARAM(NULL, &pbuf, param->value.sequence->length))) { EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN, EVP_R_DECODE_ERROR); return 0; } if (!pbe->iter) iter = 1; else iter = ASN1_INTEGER_get (pbe->iter); salt = pbe->salt->data; saltlen = pbe->salt->length; if (!pass) passlen = 0; else if (passlen == -1) passlen = strlen(pass); if (!EVP_DigestInit_ex(&ctx, md, NULL)) goto err; if (!EVP_DigestUpdate(&ctx, pass, passlen)) goto err; if (!EVP_DigestUpdate(&ctx, salt, saltlen)) goto err; PBEPARAM_free(pbe); if (!EVP_DigestFinal_ex(&ctx, md_tmp, NULL)) goto err; mdsize = EVP_MD_size(md); if (mdsize < 0) return 0; for (i = 1; i < iter; i++) { if (!EVP_DigestInit_ex(&ctx, md, NULL)) goto err; if (!EVP_DigestUpdate(&ctx, md_tmp, mdsize)) goto err; if (!EVP_DigestFinal_ex (&ctx, md_tmp, NULL)) goto err; } OPENSSL_assert(EVP_CIPHER_key_length(cipher) <= (int)sizeof(md_tmp)); memcpy(key, md_tmp, EVP_CIPHER_key_length(cipher)); OPENSSL_assert(EVP_CIPHER_iv_length(cipher) <= 16); memcpy(iv, md_tmp + (16 - EVP_CIPHER_iv_length(cipher)), EVP_CIPHER_iv_length(cipher)); if (!EVP_CipherInit_ex(cctx, cipher, NULL, key, iv, en_de)) goto err; OPENSSL_cleanse(md_tmp, EVP_MAX_MD_SIZE); OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH); OPENSSL_cleanse(iv, EVP_MAX_IV_LENGTH); rv = 1; err: EVP_MD_CTX_cleanup(&ctx); return rv; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/e_des3.c0000644000175000017500000002273712360020705020366 0ustar /* $OpenBSD: e_des3.c,v 1.15 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #ifndef OPENSSL_NO_DES #include #include #include #include #include "evp_locl.h" static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); static int des3_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr); typedef struct { DES_key_schedule ks1;/* key schedule */ DES_key_schedule ks2;/* key schedule (for ede) */ DES_key_schedule ks3;/* key schedule (for ede3) */ } DES_EDE_KEY; #define data(ctx) ((DES_EDE_KEY *)(ctx)->cipher_data) /* Because of various casts and different args can't use IMPLEMENT_BLOCK_CIPHER */ static int des_ede_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { BLOCK_CIPHER_ecb_loop() DES_ecb3_encrypt((const_DES_cblock *)(in + i), (DES_cblock *)(out + i), &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, ctx->encrypt); return 1; } static int des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while (inl >= EVP_MAXCHUNK) { DES_ede3_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK, &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, (DES_cblock *)ctx->iv, &ctx->num); inl -= EVP_MAXCHUNK; in += EVP_MAXCHUNK; out += EVP_MAXCHUNK; } if (inl) DES_ede3_ofb64_encrypt(in, out, (long)inl, &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, (DES_cblock *)ctx->iv, &ctx->num); return 1; } static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while (inl >= EVP_MAXCHUNK) { DES_ede3_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, (DES_cblock *)ctx->iv, ctx->encrypt); inl -= EVP_MAXCHUNK; in += EVP_MAXCHUNK; out += EVP_MAXCHUNK; } if (inl) DES_ede3_cbc_encrypt(in, out, (long)inl, &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, (DES_cblock *)ctx->iv, ctx->encrypt); return 1; } static int des_ede_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while (inl >= EVP_MAXCHUNK) { DES_ede3_cfb64_encrypt(in, out, (long)EVP_MAXCHUNK, &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt); inl -= EVP_MAXCHUNK; in += EVP_MAXCHUNK; out += EVP_MAXCHUNK; } if (inl) DES_ede3_cfb64_encrypt(in, out, (long)inl, &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt); return 1; } /* Although we have a CFB-r implementation for 3-DES, it doesn't pack the right way, so wrap it here */ static int des_ede3_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t n; unsigned char c[1], d[1]; for (n = 0; n < inl; ++n) { c[0] = (in[n/8]&(1 << (7 - n % 8))) ? 0x80 : 0; DES_ede3_cfb_encrypt(c, d, 1, 1, &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, (DES_cblock *)ctx->iv, ctx->encrypt); out[n / 8] = (out[n / 8] & ~(0x80 >> (unsigned int)(n % 8))) | ((d[0] & 0x80) >> (unsigned int)(n % 8)); } return 1; } static int des_ede3_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while (inl >= EVP_MAXCHUNK) { DES_ede3_cfb_encrypt(in, out, 8, (long)EVP_MAXCHUNK, &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, (DES_cblock *)ctx->iv, ctx->encrypt); inl -= EVP_MAXCHUNK; in += EVP_MAXCHUNK; out += EVP_MAXCHUNK; } if (inl) DES_ede3_cfb_encrypt(in, out, 8, (long)inl, &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, (DES_cblock *)ctx->iv, ctx->encrypt); return 1; } BLOCK_CIPHER_defs(des_ede, DES_EDE_KEY, NID_des_ede, 8, 16, 8, 64, EVP_CIPH_RAND_KEY, des_ede_init_key, NULL, EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des3_ctrl) #define des_ede3_cfb64_cipher des_ede_cfb64_cipher #define des_ede3_ofb_cipher des_ede_ofb_cipher #define des_ede3_cbc_cipher des_ede_cbc_cipher #define des_ede3_ecb_cipher des_ede_ecb_cipher BLOCK_CIPHER_defs(des_ede3, DES_EDE_KEY, NID_des_ede3, 8, 24, 8, 64, EVP_CIPH_RAND_KEY, des_ede3_init_key, NULL, EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des3_ctrl) BLOCK_CIPHER_def_cfb(des_ede3, DES_EDE_KEY, NID_des_ede3, 24, 8, 1, EVP_CIPH_RAND_KEY, des_ede3_init_key, NULL, EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des3_ctrl) BLOCK_CIPHER_def_cfb(des_ede3, DES_EDE_KEY, NID_des_ede3, 24, 8, 8, EVP_CIPH_RAND_KEY, des_ede3_init_key, NULL, EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des3_ctrl) static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { DES_cblock *deskey = (DES_cblock *)key; #ifdef EVP_CHECK_DES_KEY if (DES_set_key_checked(&deskey[0], &data(ctx)->ks1) !! DES_set_key_checked(&deskey[1], &data(ctx)->ks2)) return 0; #else DES_set_key_unchecked(&deskey[0], &data(ctx)->ks1); DES_set_key_unchecked(&deskey[1], &data(ctx)->ks2); #endif memcpy(&data(ctx)->ks3, &data(ctx)->ks1, sizeof(data(ctx)->ks1)); return 1; } static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { DES_cblock *deskey = (DES_cblock *)key; #ifdef EVP_CHECK_DES_KEY if (DES_set_key_checked(&deskey[0], &data(ctx)->ks1) || DES_set_key_checked(&deskey[1], &data(ctx)->ks2) || DES_set_key_checked(&deskey[2], &data(ctx)->ks3)) return 0; #else DES_set_key_unchecked(&deskey[0], &data(ctx)->ks1); DES_set_key_unchecked(&deskey[1], &data(ctx)->ks2); DES_set_key_unchecked(&deskey[2], &data(ctx)->ks3); #endif return 1; } static int des3_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) { DES_cblock *deskey = ptr; switch (type) { case EVP_CTRL_RAND_KEY: if (RAND_bytes(ptr, c->key_len) <= 0) return 0; DES_set_odd_parity(deskey); if (c->key_len >= 16) DES_set_odd_parity(deskey + 1); if (c->key_len >= 24) DES_set_odd_parity(deskey + 2); return 1; default: return -1; } } const EVP_CIPHER * EVP_des_ede(void) { return &des_ede_ecb; } const EVP_CIPHER * EVP_des_ede3(void) { return &des_ede3_ecb; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/e_cast.c0000644000175000017500000000767012360020705020461 0ustar /* $OpenBSD: e_cast.c,v 1.6 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #ifndef OPENSSL_NO_CAST #include #include #include #include "evp_locl.h" static int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); typedef struct { CAST_KEY ks; } EVP_CAST_KEY; #define data(ctx) EVP_C_DATA(EVP_CAST_KEY,ctx) IMPLEMENT_BLOCK_CIPHER(cast5, ks, CAST, EVP_CAST_KEY, NID_cast5, 8, CAST_KEY_LENGTH, 8, 64, EVP_CIPH_VARIABLE_LENGTH, cast_init_key, NULL, EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL) static int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { CAST_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx), key); return 1; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/evp_locl.h0000644000175000017500000003260512360020705021027 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Macros to code block cipher wrappers */ /* Wrapper functions for each cipher mode */ #define BLOCK_CIPHER_ecb_loop() \ size_t i, bl; \ bl = ctx->cipher->block_size;\ if(inl < bl) return 1;\ inl -= bl; \ for(i=0; i <= inl; i+=bl) #define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ {\ BLOCK_CIPHER_ecb_loop() \ cprefix##_ecb_encrypt(in + i, out + i, &((kstruct *)ctx->cipher_data)->ksched, ctx->encrypt);\ return 1;\ } #define EVP_MAXCHUNK ((size_t)1<<(sizeof(long)*8-2)) #define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \ static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ {\ while(inl>=EVP_MAXCHUNK)\ {\ cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num);\ inl-=EVP_MAXCHUNK;\ in +=EVP_MAXCHUNK;\ out+=EVP_MAXCHUNK;\ }\ if (inl)\ cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num);\ return 1;\ } #define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ {\ while(inl>=EVP_MAXCHUNK) \ {\ cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, ctx->encrypt);\ inl-=EVP_MAXCHUNK;\ in +=EVP_MAXCHUNK;\ out+=EVP_MAXCHUNK;\ }\ if (inl)\ cprefix##_cbc_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, ctx->encrypt);\ return 1;\ } #define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ {\ size_t chunk=EVP_MAXCHUNK;\ if (cbits==1) chunk>>=3;\ if (inl=chunk)\ {\ cprefix##_cfb##cbits##_encrypt(in, out, (long)((cbits==1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ?inl*8:inl), &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num, ctx->encrypt);\ inl-=chunk;\ in +=chunk;\ out+=chunk;\ if(inlc))+\ sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ set_asn1, get_asn1,\ ctrl, \ NULL \ };\ const EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\ static const EVP_CIPHER cname##_cfb = {\ nid##_cfb64, 1, key_len, iv_len, \ flags | EVP_CIPH_CFB_MODE,\ init_key,\ cname##_cfb_cipher,\ cleanup,\ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ set_asn1, get_asn1,\ ctrl,\ NULL \ };\ const EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\ static const EVP_CIPHER cname##_ofb = {\ nid##_ofb64, 1, key_len, iv_len, \ flags | EVP_CIPH_OFB_MODE,\ init_key,\ cname##_ofb_cipher,\ cleanup,\ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ set_asn1, get_asn1,\ ctrl,\ NULL \ };\ const EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\ static const EVP_CIPHER cname##_ecb = {\ nid##_ecb, block_size, key_len, iv_len, \ flags | EVP_CIPH_ECB_MODE,\ init_key,\ cname##_ecb_cipher,\ cleanup,\ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ set_asn1, get_asn1,\ ctrl,\ NULL \ };\ const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; } */ #define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \ block_size, key_len, iv_len, cbits, \ flags, init_key, \ cleanup, set_asn1, get_asn1, ctrl) \ BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \ cbits, flags, init_key, cleanup, set_asn1, \ get_asn1, ctrl) #define EVP_C_DATA(kstruct, ctx) ((kstruct *)(ctx)->cipher_data) #define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len) \ BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \ BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \ NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \ 0, cipher##_init_key, NULL, \ EVP_CIPHER_set_asn1_iv, \ EVP_CIPHER_get_asn1_iv, \ NULL) struct evp_pkey_ctx_st { /* Method associated with this operation */ const EVP_PKEY_METHOD *pmeth; /* Engine that implements this method or NULL if builtin */ ENGINE *engine; /* Key: may be NULL */ EVP_PKEY *pkey; /* Peer key for key agreement, may be NULL */ EVP_PKEY *peerkey; /* Actual operation */ int operation; /* Algorithm specific data */ void *data; /* Application specific data */ void *app_data; /* Keygen callback */ EVP_PKEY_gen_cb *pkey_gencb; /* implementation specific keygen data */ int *keygen_info; int keygen_info_count; } /* EVP_PKEY_CTX */; #define EVP_PKEY_FLAG_DYNAMIC 1 struct evp_pkey_method_st { int pkey_id; int flags; int (*init)(EVP_PKEY_CTX *ctx); int (*copy)(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src); void (*cleanup)(EVP_PKEY_CTX *ctx); int (*paramgen_init)(EVP_PKEY_CTX *ctx); int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); int (*keygen_init)(EVP_PKEY_CTX *ctx); int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); int (*sign_init)(EVP_PKEY_CTX *ctx); int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, const unsigned char *tbs, size_t tbslen); int (*verify_init)(EVP_PKEY_CTX *ctx); int (*verify)(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, const unsigned char *tbs, size_t tbslen); int (*verify_recover_init)(EVP_PKEY_CTX *ctx); int (*verify_recover)(EVP_PKEY_CTX *ctx, unsigned char *rout, size_t *routlen, const unsigned char *sig, size_t siglen); int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, EVP_MD_CTX *mctx); int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); int (*verifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen, EVP_MD_CTX *mctx); int (*encrypt_init)(EVP_PKEY_CTX *ctx); int (*encrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, const unsigned char *in, size_t inlen); int (*decrypt_init)(EVP_PKEY_CTX *ctx); int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, const unsigned char *in, size_t inlen); int (*derive_init)(EVP_PKEY_CTX *ctx); int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen); int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2); int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value); } /* EVP_PKEY_METHOD */; void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx); int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, ASN1_TYPE *param, const EVP_CIPHER *c, const EVP_MD *md, int en_de); /* EVP_AEAD represents a specific AEAD algorithm. */ struct evp_aead_st { unsigned char key_len; unsigned char nonce_len; unsigned char overhead; unsigned char max_tag_len; int (*init)(struct evp_aead_ctx_st*, const unsigned char *key, size_t key_len, size_t tag_len); void (*cleanup)(struct evp_aead_ctx_st*); int (*seal)(const struct evp_aead_ctx_st *ctx, unsigned char *out, size_t *out_len, size_t max_out_len, const unsigned char *nonce, size_t nonce_len, const unsigned char *in, size_t in_len, const unsigned char *ad, size_t ad_len); int (*open)(const struct evp_aead_ctx_st *ctx, unsigned char *out, size_t *out_len, size_t max_out_len, const unsigned char *nonce, size_t nonce_len, const unsigned char *in, size_t in_len, const unsigned char *ad, size_t ad_len); }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/evp_err.c0000644000175000017500000003253012360020705020656 0ustar /* $OpenBSD: evp_err.c,v 1.19 2014/06/12 15:49:29 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_EVP,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_EVP,0,reason) static ERR_STRING_DATA EVP_str_functs[] = { {ERR_FUNC(EVP_F_AEAD_AES_GCM_INIT), "AEAD_AES_GCM_INIT"}, {ERR_FUNC(EVP_F_AEAD_AES_GCM_OPEN), "AEAD_AES_GCM_OPEN"}, {ERR_FUNC(EVP_F_AEAD_AES_GCM_SEAL), "AEAD_AES_GCM_SEAL"}, {ERR_FUNC(EVP_F_AEAD_CHACHA20_POLY1305_INIT), "AEAD_CHACHA20_POLY1305_INIT"}, {ERR_FUNC(EVP_F_AEAD_CHACHA20_POLY1305_OPEN), "AEAD_CHACHA20_POLY1305_OPEN"}, {ERR_FUNC(EVP_F_AEAD_CHACHA20_POLY1305_SEAL), "AEAD_CHACHA20_POLY1305_SEAL"}, {ERR_FUNC(EVP_F_AESNI_INIT_KEY), "AESNI_INIT_KEY"}, {ERR_FUNC(EVP_F_AESNI_XTS_CIPHER), "AESNI_XTS_CIPHER"}, {ERR_FUNC(EVP_F_AES_INIT_KEY), "AES_INIT_KEY"}, {ERR_FUNC(EVP_F_AES_XTS), "AES_XTS"}, {ERR_FUNC(EVP_F_AES_XTS_CIPHER), "AES_XTS_CIPHER"}, {ERR_FUNC(EVP_F_ALG_MODULE_INIT), "ALG_MODULE_INIT"}, {ERR_FUNC(EVP_F_CAMELLIA_INIT_KEY), "CAMELLIA_INIT_KEY"}, {ERR_FUNC(EVP_F_CMAC_INIT), "CMAC_INIT"}, {ERR_FUNC(EVP_F_D2I_PKEY), "D2I_PKEY"}, {ERR_FUNC(EVP_F_DO_SIGVER_INIT), "DO_SIGVER_INIT"}, {ERR_FUNC(EVP_F_DSAPKEY2PKCS8), "DSAPKEY2PKCS8"}, {ERR_FUNC(EVP_F_DSA_PKEY2PKCS8), "DSA_PKEY2PKCS8"}, {ERR_FUNC(EVP_F_ECDSA_PKEY2PKCS8), "ECDSA_PKEY2PKCS8"}, {ERR_FUNC(EVP_F_ECKEY_PKEY2PKCS8), "ECKEY_PKEY2PKCS8"}, {ERR_FUNC(EVP_F_EVP_AEAD_CTX_INIT), "EVP_AEAD_CTX_init"}, {ERR_FUNC(EVP_F_EVP_AEAD_CTX_OPEN), "EVP_AEAD_CTX_open"}, {ERR_FUNC(EVP_F_EVP_AEAD_CTX_SEAL), "EVP_AEAD_CTX_seal"}, {ERR_FUNC(EVP_F_EVP_CIPHERINIT_EX), "EVP_CipherInit_ex"}, {ERR_FUNC(EVP_F_EVP_CIPHER_CTX_COPY), "EVP_CIPHER_CTX_copy"}, {ERR_FUNC(EVP_F_EVP_CIPHER_CTX_CTRL), "EVP_CIPHER_CTX_ctrl"}, {ERR_FUNC(EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH), "EVP_CIPHER_CTX_set_key_length"}, {ERR_FUNC(EVP_F_EVP_DECRYPTFINAL_EX), "EVP_DecryptFinal_ex"}, {ERR_FUNC(EVP_F_EVP_DIGESTINIT_EX), "EVP_DigestInit_ex"}, {ERR_FUNC(EVP_F_EVP_ENCRYPTFINAL_EX), "EVP_EncryptFinal_ex"}, {ERR_FUNC(EVP_F_EVP_MD_CTX_COPY_EX), "EVP_MD_CTX_copy_ex"}, {ERR_FUNC(EVP_F_EVP_MD_SIZE), "EVP_MD_size"}, {ERR_FUNC(EVP_F_EVP_OPENINIT), "EVP_OpenInit"}, {ERR_FUNC(EVP_F_EVP_PBE_ALG_ADD), "EVP_PBE_alg_add"}, {ERR_FUNC(EVP_F_EVP_PBE_ALG_ADD_TYPE), "EVP_PBE_alg_add_type"}, {ERR_FUNC(EVP_F_EVP_PBE_CIPHERINIT), "EVP_PBE_CipherInit"}, {ERR_FUNC(EVP_F_EVP_PKCS82PKEY), "EVP_PKCS82PKEY"}, {ERR_FUNC(EVP_F_EVP_PKCS82PKEY_BROKEN), "EVP_PKCS82PKEY_BROKEN"}, {ERR_FUNC(EVP_F_EVP_PKEY2PKCS8_BROKEN), "EVP_PKEY2PKCS8_broken"}, {ERR_FUNC(EVP_F_EVP_PKEY_COPY_PARAMETERS), "EVP_PKEY_copy_parameters"}, {ERR_FUNC(EVP_F_EVP_PKEY_CTX_CTRL), "EVP_PKEY_CTX_ctrl"}, {ERR_FUNC(EVP_F_EVP_PKEY_CTX_CTRL_STR), "EVP_PKEY_CTX_ctrl_str"}, {ERR_FUNC(EVP_F_EVP_PKEY_CTX_DUP), "EVP_PKEY_CTX_dup"}, {ERR_FUNC(EVP_F_EVP_PKEY_DECRYPT), "EVP_PKEY_decrypt"}, {ERR_FUNC(EVP_F_EVP_PKEY_DECRYPT_INIT), "EVP_PKEY_decrypt_init"}, {ERR_FUNC(EVP_F_EVP_PKEY_DECRYPT_OLD), "EVP_PKEY_decrypt_old"}, {ERR_FUNC(EVP_F_EVP_PKEY_DERIVE), "EVP_PKEY_derive"}, {ERR_FUNC(EVP_F_EVP_PKEY_DERIVE_INIT), "EVP_PKEY_derive_init"}, {ERR_FUNC(EVP_F_EVP_PKEY_DERIVE_SET_PEER), "EVP_PKEY_derive_set_peer"}, {ERR_FUNC(EVP_F_EVP_PKEY_ENCRYPT), "EVP_PKEY_encrypt"}, {ERR_FUNC(EVP_F_EVP_PKEY_ENCRYPT_INIT), "EVP_PKEY_encrypt_init"}, {ERR_FUNC(EVP_F_EVP_PKEY_ENCRYPT_OLD), "EVP_PKEY_encrypt_old"}, {ERR_FUNC(EVP_F_EVP_PKEY_GET1_DH), "EVP_PKEY_get1_DH"}, {ERR_FUNC(EVP_F_EVP_PKEY_GET1_DSA), "EVP_PKEY_get1_DSA"}, {ERR_FUNC(EVP_F_EVP_PKEY_GET1_ECDSA), "EVP_PKEY_GET1_ECDSA"}, {ERR_FUNC(EVP_F_EVP_PKEY_GET1_EC_KEY), "EVP_PKEY_get1_EC_KEY"}, {ERR_FUNC(EVP_F_EVP_PKEY_GET1_RSA), "EVP_PKEY_get1_RSA"}, {ERR_FUNC(EVP_F_EVP_PKEY_KEYGEN), "EVP_PKEY_keygen"}, {ERR_FUNC(EVP_F_EVP_PKEY_KEYGEN_INIT), "EVP_PKEY_keygen_init"}, {ERR_FUNC(EVP_F_EVP_PKEY_NEW), "EVP_PKEY_new"}, {ERR_FUNC(EVP_F_EVP_PKEY_PARAMGEN), "EVP_PKEY_paramgen"}, {ERR_FUNC(EVP_F_EVP_PKEY_PARAMGEN_INIT), "EVP_PKEY_paramgen_init"}, {ERR_FUNC(EVP_F_EVP_PKEY_SIGN), "EVP_PKEY_sign"}, {ERR_FUNC(EVP_F_EVP_PKEY_SIGN_INIT), "EVP_PKEY_sign_init"}, {ERR_FUNC(EVP_F_EVP_PKEY_VERIFY), "EVP_PKEY_verify"}, {ERR_FUNC(EVP_F_EVP_PKEY_VERIFY_INIT), "EVP_PKEY_verify_init"}, {ERR_FUNC(EVP_F_EVP_PKEY_VERIFY_RECOVER), "EVP_PKEY_verify_recover"}, {ERR_FUNC(EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT), "EVP_PKEY_verify_recover_init"}, {ERR_FUNC(EVP_F_EVP_RIJNDAEL), "EVP_RIJNDAEL"}, {ERR_FUNC(EVP_F_EVP_SIGNFINAL), "EVP_SignFinal"}, {ERR_FUNC(EVP_F_EVP_VERIFYFINAL), "EVP_VerifyFinal"}, {ERR_FUNC(EVP_F_FIPS_CIPHERINIT), "FIPS_CIPHERINIT"}, {ERR_FUNC(EVP_F_FIPS_CIPHER_CTX_COPY), "FIPS_CIPHER_CTX_COPY"}, {ERR_FUNC(EVP_F_FIPS_CIPHER_CTX_CTRL), "FIPS_CIPHER_CTX_CTRL"}, {ERR_FUNC(EVP_F_FIPS_CIPHER_CTX_SET_KEY_LENGTH), "FIPS_CIPHER_CTX_SET_KEY_LENGTH"}, {ERR_FUNC(EVP_F_FIPS_DIGESTINIT), "FIPS_DIGESTINIT"}, {ERR_FUNC(EVP_F_FIPS_MD_CTX_COPY), "FIPS_MD_CTX_COPY"}, {ERR_FUNC(EVP_F_HMAC_INIT_EX), "HMAC_Init_ex"}, {ERR_FUNC(EVP_F_INT_CTX_NEW), "INT_CTX_NEW"}, {ERR_FUNC(EVP_F_PKCS5_PBE_KEYIVGEN), "PKCS5_PBE_keyivgen"}, {ERR_FUNC(EVP_F_PKCS5_V2_PBE_KEYIVGEN), "PKCS5_v2_PBE_keyivgen"}, {ERR_FUNC(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN), "PKCS5_V2_PBKDF2_KEYIVGEN"}, {ERR_FUNC(EVP_F_PKCS8_SET_BROKEN), "PKCS8_set_broken"}, {ERR_FUNC(EVP_F_PKEY_SET_TYPE), "PKEY_SET_TYPE"}, {ERR_FUNC(EVP_F_RC2_MAGIC_TO_METH), "RC2_MAGIC_TO_METH"}, {ERR_FUNC(EVP_F_RC5_CTRL), "RC5_CTRL"}, {0, NULL} }; static ERR_STRING_DATA EVP_str_reasons[] = { {ERR_REASON(EVP_R_AES_IV_SETUP_FAILED) , "aes iv setup failed"}, {ERR_REASON(EVP_R_AES_KEY_SETUP_FAILED) , "aes key setup failed"}, {ERR_REASON(EVP_R_ASN1_LIB) , "asn1 lib"}, {ERR_REASON(EVP_R_BAD_BLOCK_LENGTH) , "bad block length"}, {ERR_REASON(EVP_R_BAD_DECRYPT) , "bad decrypt"}, {ERR_REASON(EVP_R_BAD_KEY_LENGTH) , "bad key length"}, {ERR_REASON(EVP_R_BN_DECODE_ERROR) , "bn decode error"}, {ERR_REASON(EVP_R_BN_PUBKEY_ERROR) , "bn pubkey error"}, {ERR_REASON(EVP_R_BUFFER_TOO_SMALL) , "buffer too small"}, {ERR_REASON(EVP_R_CAMELLIA_KEY_SETUP_FAILED), "camellia key setup failed"}, {ERR_REASON(EVP_R_CIPHER_PARAMETER_ERROR), "cipher parameter error"}, {ERR_REASON(EVP_R_COMMAND_NOT_SUPPORTED) , "command not supported"}, {ERR_REASON(EVP_R_CTRL_NOT_IMPLEMENTED) , "ctrl not implemented"}, {ERR_REASON(EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED), "ctrl operation not implemented"}, {ERR_REASON(EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH), "data not multiple of block length"}, {ERR_REASON(EVP_R_DECODE_ERROR) , "decode error"}, {ERR_REASON(EVP_R_DIFFERENT_KEY_TYPES) , "different key types"}, {ERR_REASON(EVP_R_DIFFERENT_PARAMETERS) , "different parameters"}, {ERR_REASON(EVP_R_DISABLED_FOR_FIPS) , "disabled for fips"}, {ERR_REASON(EVP_R_ENCODE_ERROR) , "encode error"}, {ERR_REASON(EVP_R_ERROR_LOADING_SECTION) , "error loading section"}, {ERR_REASON(EVP_R_ERROR_SETTING_FIPS_MODE), "error setting fips mode"}, {ERR_REASON(EVP_R_EVP_PBE_CIPHERINIT_ERROR), "evp pbe cipherinit error"}, {ERR_REASON(EVP_R_EXPECTING_AN_RSA_KEY) , "expecting an rsa key"}, {ERR_REASON(EVP_R_EXPECTING_A_DH_KEY) , "expecting a dh key"}, {ERR_REASON(EVP_R_EXPECTING_A_DSA_KEY) , "expecting a dsa key"}, {ERR_REASON(EVP_R_EXPECTING_A_ECDSA_KEY) , "expecting a ecdsa key"}, {ERR_REASON(EVP_R_EXPECTING_A_EC_KEY) , "expecting a ec key"}, {ERR_REASON(EVP_R_FIPS_MODE_NOT_SUPPORTED), "fips mode not supported"}, {ERR_REASON(EVP_R_INITIALIZATION_ERROR) , "initialization error"}, {ERR_REASON(EVP_R_INPUT_NOT_INITIALIZED) , "input not initialized"}, {ERR_REASON(EVP_R_INVALID_DIGEST) , "invalid digest"}, {ERR_REASON(EVP_R_INVALID_FIPS_MODE) , "invalid fips mode"}, {ERR_REASON(EVP_R_INVALID_KEY_LENGTH) , "invalid key length"}, {ERR_REASON(EVP_R_INVALID_OPERATION) , "invalid operation"}, {ERR_REASON(EVP_R_IV_TOO_LARGE) , "iv too large"}, {ERR_REASON(EVP_R_KEYGEN_FAILURE) , "keygen failure"}, {ERR_REASON(EVP_R_MESSAGE_DIGEST_IS_NULL), "message digest is null"}, {ERR_REASON(EVP_R_METHOD_NOT_SUPPORTED) , "method not supported"}, {ERR_REASON(EVP_R_MISSING_PARAMETERS) , "missing parameters"}, {ERR_REASON(EVP_R_NO_CIPHER_SET) , "no cipher set"}, {ERR_REASON(EVP_R_NO_DEFAULT_DIGEST) , "no default digest"}, {ERR_REASON(EVP_R_NO_DIGEST_SET) , "no digest set"}, {ERR_REASON(EVP_R_NO_DSA_PARAMETERS) , "no dsa parameters"}, {ERR_REASON(EVP_R_NO_KEY_SET) , "no key set"}, {ERR_REASON(EVP_R_NO_OPERATION_SET) , "no operation set"}, {ERR_REASON(EVP_R_NO_SIGN_FUNCTION_CONFIGURED), "no sign function configured"}, {ERR_REASON(EVP_R_NO_VERIFY_FUNCTION_CONFIGURED), "no verify function configured"}, {ERR_REASON(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE), "operation not supported for this keytype"}, {ERR_REASON(EVP_R_OPERATON_NOT_INITIALIZED), "operaton not initialized"}, {ERR_REASON(EVP_R_OUTPUT_ALIASES_INPUT), "output aliases input"}, {ERR_REASON(EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE), "pkcs8 unknown broken type"}, {ERR_REASON(EVP_R_PRIVATE_KEY_DECODE_ERROR), "private key decode error"}, {ERR_REASON(EVP_R_PRIVATE_KEY_ENCODE_ERROR), "private key encode error"}, {ERR_REASON(EVP_R_PUBLIC_KEY_NOT_RSA) , "public key not rsa"}, {ERR_REASON(EVP_R_TAG_TOO_LARGE), "tag too large"}, {ERR_REASON(EVP_R_TOO_LARGE) , "too large"}, {ERR_REASON(EVP_R_UNKNOWN_CIPHER) , "unknown cipher"}, {ERR_REASON(EVP_R_UNKNOWN_DIGEST) , "unknown digest"}, {ERR_REASON(EVP_R_UNKNOWN_OPTION) , "unknown option"}, {ERR_REASON(EVP_R_UNKNOWN_PBE_ALGORITHM) , "unknown pbe algorithm"}, {ERR_REASON(EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS), "unsuported number of rounds"}, {ERR_REASON(EVP_R_UNSUPPORTED_ALGORITHM) , "unsupported algorithm"}, {ERR_REASON(EVP_R_UNSUPPORTED_CIPHER) , "unsupported cipher"}, {ERR_REASON(EVP_R_UNSUPPORTED_KEYLENGTH) , "unsupported keylength"}, {ERR_REASON(EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION), "unsupported key derivation function"}, {ERR_REASON(EVP_R_UNSUPPORTED_KEY_SIZE) , "unsupported key size"}, {ERR_REASON(EVP_R_UNSUPPORTED_PRF) , "unsupported prf"}, {ERR_REASON(EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM), "unsupported private key algorithm"}, {ERR_REASON(EVP_R_UNSUPPORTED_SALT_TYPE) , "unsupported salt type"}, {ERR_REASON(EVP_R_WRONG_FINAL_BLOCK_LENGTH), "wrong final block length"}, {ERR_REASON(EVP_R_WRONG_PUBLIC_KEY_TYPE) , "wrong public key type"}, {0, NULL} }; #endif void ERR_load_EVP_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(EVP_str_functs[0].error) == NULL) { ERR_load_strings(0, EVP_str_functs); ERR_load_strings(0, EVP_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/p_enc.c0000644000175000017500000000743012360020705020301 0ustar /* $OpenBSD: p_enc.c,v 1.8 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #ifndef OPENSSL_NO_RSA #include #endif int EVP_PKEY_encrypt_old(unsigned char *ek, const unsigned char *key, int key_len, EVP_PKEY *pubk) { int ret = 0; #ifndef OPENSSL_NO_RSA if (pubk->type != EVP_PKEY_RSA) { #endif EVPerr(EVP_F_EVP_PKEY_ENCRYPT_OLD, EVP_R_PUBLIC_KEY_NOT_RSA); #ifndef OPENSSL_NO_RSA goto err; } ret = RSA_public_encrypt(key_len, key, ek, pubk->pkey.rsa, RSA_PKCS1_PADDING); err: #endif return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/m_md5.c0000644000175000017500000001032412360020705020212 0ustar /* $OpenBSD: m_md5.c,v 1.13 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #ifndef OPENSSL_NO_MD5 #include #include #include #include #ifndef OPENSSL_NO_RSA #include #endif #include "evp_locl.h" static int init(EVP_MD_CTX *ctx) { return MD5_Init(ctx->md_data); } static int update(EVP_MD_CTX *ctx, const void *data, size_t count) { return MD5_Update(ctx->md_data, data, count); } static int final(EVP_MD_CTX *ctx, unsigned char *md) { return MD5_Final(md, ctx->md_data); } static const EVP_MD md5_md = { .type = NID_md5, .pkey_type = NID_md5WithRSAEncryption, .md_size = MD5_DIGEST_LENGTH, .flags = 0, .init = init, .update = update, .final = final, .copy = NULL, .cleanup = NULL, #ifndef OPENSSL_NO_RSA .sign = (evp_sign_method *)RSA_sign, .verify = (evp_verify_method *)RSA_verify, .required_pkey_type = { EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, }, #endif .block_size = MD5_CBLOCK, .ctx_size = sizeof(EVP_MD *) + sizeof(MD5_CTX), }; const EVP_MD * EVP_md5(void) { return (&md5_md); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/m_dss.c0000644000175000017500000001032412360020705020316 0ustar /* $OpenBSD: m_dss.c,v 1.15 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #ifndef OPENSSL_NO_DSA #include #endif #ifndef OPENSSL_NO_SHA static int init(EVP_MD_CTX *ctx) { return SHA1_Init(ctx->md_data); } static int update(EVP_MD_CTX *ctx, const void *data, size_t count) { return SHA1_Update(ctx->md_data, data, count); } static int final(EVP_MD_CTX *ctx, unsigned char *md) { return SHA1_Final(md, ctx->md_data); } static const EVP_MD dsa_md = { .type = NID_dsaWithSHA, .pkey_type = NID_dsaWithSHA, .md_size = SHA_DIGEST_LENGTH, .flags = EVP_MD_FLAG_PKEY_DIGEST, .init = init, .update = update, .final = final, .copy = NULL, .cleanup = NULL, #ifndef OPENSSL_NO_DSA .sign = (evp_sign_method *)DSA_sign, .verify = (evp_verify_method *)DSA_verify, .required_pkey_type = { EVP_PKEY_DSA, EVP_PKEY_DSA2, EVP_PKEY_DSA3, EVP_PKEY_DSA4, 0, }, #endif .block_size = SHA_CBLOCK, .ctx_size = sizeof(EVP_MD *) + sizeof(SHA_CTX), }; const EVP_MD * EVP_dss(void) { return (&dsa_md); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/m_md4.c0000644000175000017500000001032412360020705020211 0ustar /* $OpenBSD: m_md4.c,v 1.12 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #ifndef OPENSSL_NO_MD4 #include #include #include #include #ifndef OPENSSL_NO_RSA #include #endif #include "evp_locl.h" static int init(EVP_MD_CTX *ctx) { return MD4_Init(ctx->md_data); } static int update(EVP_MD_CTX *ctx, const void *data, size_t count) { return MD4_Update(ctx->md_data, data, count); } static int final(EVP_MD_CTX *ctx, unsigned char *md) { return MD4_Final(md, ctx->md_data); } static const EVP_MD md4_md = { .type = NID_md4, .pkey_type = NID_md4WithRSAEncryption, .md_size = MD4_DIGEST_LENGTH, .flags = 0, .init = init, .update = update, .final = final, .copy = NULL, .cleanup = NULL, #ifndef OPENSSL_NO_RSA .sign = (evp_sign_method *)RSA_sign, .verify = (evp_verify_method *)RSA_verify, .required_pkey_type = { EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, }, #endif .block_size = MD4_CBLOCK, .ctx_size = sizeof(EVP_MD *) + sizeof(MD4_CTX), }; const EVP_MD * EVP_md4(void) { return (&md4_md); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/evp_pbe.c0000644000175000017500000002056712360020705020643 0ustar /* $OpenBSD: evp_pbe.c,v 1.20 2014/07/11 08:44:48 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include "evp_locl.h" /* Password based encryption (PBE) functions */ DECLARE_STACK_OF(EVP_PBE_CTL) static STACK_OF(EVP_PBE_CTL) *pbe_algs; /* Setup a cipher context from a PBE algorithm */ typedef struct { int pbe_type; int pbe_nid; int cipher_nid; int md_nid; EVP_PBE_KEYGEN *keygen; } EVP_PBE_CTL; static const EVP_PBE_CTL builtin_pbe[] = { {EVP_PBE_TYPE_OUTER, NID_pbeWithMD2AndDES_CBC, NID_des_cbc, NID_md2, PKCS5_PBE_keyivgen}, {EVP_PBE_TYPE_OUTER, NID_pbeWithMD5AndDES_CBC, NID_des_cbc, NID_md5, PKCS5_PBE_keyivgen}, {EVP_PBE_TYPE_OUTER, NID_pbeWithSHA1AndRC2_CBC, NID_rc2_64_cbc, NID_sha1, PKCS5_PBE_keyivgen}, #ifndef OPENSSL_NO_HMAC {EVP_PBE_TYPE_OUTER, NID_id_pbkdf2, -1, -1, PKCS5_v2_PBKDF2_keyivgen}, #endif {EVP_PBE_TYPE_OUTER, NID_pbe_WithSHA1And128BitRC4, NID_rc4, NID_sha1, PKCS12_PBE_keyivgen}, {EVP_PBE_TYPE_OUTER, NID_pbe_WithSHA1And40BitRC4, NID_rc4_40, NID_sha1, PKCS12_PBE_keyivgen}, {EVP_PBE_TYPE_OUTER, NID_pbe_WithSHA1And3_Key_TripleDES_CBC, NID_des_ede3_cbc, NID_sha1, PKCS12_PBE_keyivgen}, {EVP_PBE_TYPE_OUTER, NID_pbe_WithSHA1And2_Key_TripleDES_CBC, NID_des_ede_cbc, NID_sha1, PKCS12_PBE_keyivgen}, {EVP_PBE_TYPE_OUTER, NID_pbe_WithSHA1And128BitRC2_CBC, NID_rc2_cbc, NID_sha1, PKCS12_PBE_keyivgen}, {EVP_PBE_TYPE_OUTER, NID_pbe_WithSHA1And40BitRC2_CBC, NID_rc2_40_cbc, NID_sha1, PKCS12_PBE_keyivgen}, #ifndef OPENSSL_NO_HMAC {EVP_PBE_TYPE_OUTER, NID_pbes2, -1, -1, PKCS5_v2_PBE_keyivgen}, #endif {EVP_PBE_TYPE_OUTER, NID_pbeWithMD2AndRC2_CBC, NID_rc2_64_cbc, NID_md2, PKCS5_PBE_keyivgen}, {EVP_PBE_TYPE_OUTER, NID_pbeWithMD5AndRC2_CBC, NID_rc2_64_cbc, NID_md5, PKCS5_PBE_keyivgen}, {EVP_PBE_TYPE_OUTER, NID_pbeWithSHA1AndDES_CBC, NID_des_cbc, NID_sha1, PKCS5_PBE_keyivgen}, {EVP_PBE_TYPE_PRF, NID_hmacWithSHA1, -1, NID_sha1, 0}, {EVP_PBE_TYPE_PRF, NID_hmacWithMD5, -1, NID_md5, 0}, {EVP_PBE_TYPE_PRF, NID_hmacWithSHA224, -1, NID_sha224, 0}, {EVP_PBE_TYPE_PRF, NID_hmacWithSHA256, -1, NID_sha256, 0}, {EVP_PBE_TYPE_PRF, NID_hmacWithSHA384, -1, NID_sha384, 0}, {EVP_PBE_TYPE_PRF, NID_hmacWithSHA512, -1, NID_sha512, 0}, {EVP_PBE_TYPE_PRF, NID_id_HMACGostR3411_94, -1, NID_id_GostR3411_94, 0}, }; int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de) { const EVP_CIPHER *cipher; const EVP_MD *md; int cipher_nid, md_nid; EVP_PBE_KEYGEN *keygen; if (!EVP_PBE_find(EVP_PBE_TYPE_OUTER, OBJ_obj2nid(pbe_obj), &cipher_nid, &md_nid, &keygen)) { char obj_tmp[80]; EVPerr(EVP_F_EVP_PBE_CIPHERINIT, EVP_R_UNKNOWN_PBE_ALGORITHM); if (!pbe_obj) strlcpy (obj_tmp, "NULL", sizeof obj_tmp); else i2t_ASN1_OBJECT(obj_tmp, sizeof obj_tmp, pbe_obj); ERR_asprintf_error_data("TYPE=%s", obj_tmp); return 0; } if (!pass) passlen = 0; else if (passlen == -1) passlen = strlen(pass); if (cipher_nid == -1) cipher = NULL; else { cipher = EVP_get_cipherbynid(cipher_nid); if (!cipher) { EVPerr(EVP_F_EVP_PBE_CIPHERINIT, EVP_R_UNKNOWN_CIPHER); return 0; } } if (md_nid == -1) md = NULL; else { md = EVP_get_digestbynid(md_nid); if (!md) { EVPerr(EVP_F_EVP_PBE_CIPHERINIT, EVP_R_UNKNOWN_DIGEST); return 0; } } if (!keygen(ctx, pass, passlen, param, cipher, md, en_de)) { EVPerr(EVP_F_EVP_PBE_CIPHERINIT, EVP_R_KEYGEN_FAILURE); return 0; } return 1; } DECLARE_OBJ_BSEARCH_CMP_FN(EVP_PBE_CTL, EVP_PBE_CTL, pbe2); static int pbe2_cmp(const EVP_PBE_CTL *pbe1, const EVP_PBE_CTL *pbe2) { int ret = pbe1->pbe_type - pbe2->pbe_type; if (ret) return ret; else return pbe1->pbe_nid - pbe2->pbe_nid; } IMPLEMENT_OBJ_BSEARCH_CMP_FN(EVP_PBE_CTL, EVP_PBE_CTL, pbe2); static int pbe_cmp(const EVP_PBE_CTL * const *a, const EVP_PBE_CTL * const *b) { int ret = (*a)->pbe_type - (*b)->pbe_type; if (ret) return ret; else return (*a)->pbe_nid - (*b)->pbe_nid; } /* Add a PBE algorithm */ int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, int md_nid, EVP_PBE_KEYGEN *keygen) { EVP_PBE_CTL *pbe_tmp; if (!pbe_algs) pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp); if (!(pbe_tmp = (EVP_PBE_CTL*) malloc (sizeof(EVP_PBE_CTL)))) { EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE); return 0; } pbe_tmp->pbe_type = pbe_type; pbe_tmp->pbe_nid = pbe_nid; pbe_tmp->cipher_nid = cipher_nid; pbe_tmp->md_nid = md_nid; pbe_tmp->keygen = keygen; sk_EVP_PBE_CTL_push (pbe_algs, pbe_tmp); return 1; } int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, EVP_PBE_KEYGEN *keygen) { int cipher_nid, md_nid; if (cipher) cipher_nid = EVP_CIPHER_nid(cipher); else cipher_nid = -1; if (md) md_nid = EVP_MD_type(md); else md_nid = -1; return EVP_PBE_alg_add_type(EVP_PBE_TYPE_OUTER, nid, cipher_nid, md_nid, keygen); } int EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid, EVP_PBE_KEYGEN **pkeygen) { EVP_PBE_CTL *pbetmp = NULL, pbelu; int i; if (pbe_nid == NID_undef) return 0; pbelu.pbe_type = type; pbelu.pbe_nid = pbe_nid; if (pbe_algs) { i = sk_EVP_PBE_CTL_find(pbe_algs, &pbelu); if (i != -1) pbetmp = sk_EVP_PBE_CTL_value (pbe_algs, i); } if (pbetmp == NULL) { pbetmp = OBJ_bsearch_pbe2(&pbelu, builtin_pbe, sizeof(builtin_pbe)/sizeof(EVP_PBE_CTL)); } if (pbetmp == NULL) return 0; if (pcnid) *pcnid = pbetmp->cipher_nid; if (pmnid) *pmnid = pbetmp->md_nid; if (pkeygen) *pkeygen = pbetmp->keygen; return 1; } static void free_evp_pbe_ctl(EVP_PBE_CTL *pbe) { free(pbe); } void EVP_PBE_cleanup(void) { sk_EVP_PBE_CTL_pop_free(pbe_algs, free_evp_pbe_ctl); pbe_algs = NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/e_xcbc_d.c0000644000175000017500000001154412360020705020744 0ustar /* $OpenBSD: e_xcbc_d.c,v 1.11 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #ifndef OPENSSL_NO_DES #include #include #include #include "evp_locl.h" static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl); typedef struct { DES_key_schedule ks;/* key schedule */ DES_cblock inw; DES_cblock outw; } DESX_CBC_KEY; #define data(ctx) ((DESX_CBC_KEY *)(ctx)->cipher_data) static const EVP_CIPHER d_xcbc_cipher = { NID_desx_cbc, 8, 24, 8, EVP_CIPH_CBC_MODE, desx_cbc_init_key, desx_cbc_cipher, NULL, sizeof(DESX_CBC_KEY), EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL, NULL }; const EVP_CIPHER * EVP_desx_cbc(void) { return (&d_xcbc_cipher); } static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { DES_cblock *deskey = (DES_cblock *)key; DES_set_key_unchecked(deskey, &data(ctx)->ks); memcpy(&data(ctx)->inw[0], &key[8], 8); memcpy(&data(ctx)->outw[0], &key[16], 8); return 1; } static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while (inl >= EVP_MAXCHUNK) { DES_xcbc_encrypt(in, out, (long)EVP_MAXCHUNK, &data(ctx)->ks, (DES_cblock *)&(ctx->iv[0]), &data(ctx)->inw, &data(ctx)->outw, ctx->encrypt); inl -= EVP_MAXCHUNK; in += EVP_MAXCHUNK; out += EVP_MAXCHUNK; } if (inl) DES_xcbc_encrypt(in, out, (long)inl, &data(ctx)->ks, (DES_cblock *)&(ctx->iv[0]), &data(ctx)->inw, &data(ctx)->outw, ctx->encrypt); return 1; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/p_seal.c0000644000175000017500000001073012360020705020455 0ustar /* $OpenBSD: p_seal.c,v 1.12 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #ifndef OPENSSL_NO_RSA #include #endif int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek, int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk) { unsigned char key[EVP_MAX_KEY_LENGTH]; int i; if (type) { EVP_CIPHER_CTX_init(ctx); if (!EVP_EncryptInit_ex(ctx, type, NULL, NULL, NULL)) return 0; } if ((npubk <= 0) || !pubk) return 1; if (EVP_CIPHER_CTX_rand_key(ctx, key) <= 0) return 0; if (EVP_CIPHER_CTX_iv_length(ctx)) RAND_pseudo_bytes(iv, EVP_CIPHER_CTX_iv_length(ctx)); if (!EVP_EncryptInit_ex(ctx, NULL, NULL, key, iv)) return 0; for (i = 0; i < npubk; i++) { ekl[i] = EVP_PKEY_encrypt_old(ek[i], key, EVP_CIPHER_CTX_key_length(ctx), pubk[i]); if (ekl[i] <= 0) return (-1); } return (npubk); } /* MACRO void EVP_SealUpdate(ctx,out,outl,in,inl) EVP_CIPHER_CTX *ctx; unsigned char *out; int *outl; unsigned char *in; int inl; { EVP_EncryptUpdate(ctx,out,outl,in,inl); } */ int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) { int i; i = EVP_EncryptFinal_ex(ctx, out, outl); if (i) i = EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, NULL); return i; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/e_chacha20poly1305.c0000644000175000017500000001546112360020705022312 0ustar /* $OpenBSD: e_chacha20poly1305.c,v 1.7 2014/06/21 15:30:36 jsing Exp $ */ /* * Copyright (c) 2014, Google Inc. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) #include #include #include #include #include "evp_locl.h" #define POLY1305_TAG_LEN 16 #define CHACHA20_NONCE_LEN 8 struct aead_chacha20_poly1305_ctx { unsigned char key[32]; unsigned char tag_len; }; static int aead_chacha20_poly1305_init(EVP_AEAD_CTX *ctx, const unsigned char *key, size_t key_len, size_t tag_len) { struct aead_chacha20_poly1305_ctx *c20_ctx; if (tag_len == 0) tag_len = POLY1305_TAG_LEN; if (tag_len > POLY1305_TAG_LEN) { EVPerr(EVP_F_AEAD_CHACHA20_POLY1305_INIT, EVP_R_TOO_LARGE); return 0; } /* Internal error - EVP_AEAD_CTX_init should catch this. */ if (key_len != sizeof(c20_ctx->key)) return 0; c20_ctx = malloc(sizeof(struct aead_chacha20_poly1305_ctx)); if (c20_ctx == NULL) return 0; memcpy(&c20_ctx->key[0], key, key_len); c20_ctx->tag_len = tag_len; ctx->aead_state = c20_ctx; return 1; } static void aead_chacha20_poly1305_cleanup(EVP_AEAD_CTX *ctx) { struct aead_chacha20_poly1305_ctx *c20_ctx = ctx->aead_state; OPENSSL_cleanse(c20_ctx->key, sizeof(c20_ctx->key)); free(c20_ctx); } static void poly1305_update_with_length(poly1305_state *poly1305, const unsigned char *data, size_t data_len) { size_t j = data_len; unsigned char length_bytes[8]; unsigned i; for (i = 0; i < sizeof(length_bytes); i++) { length_bytes[i] = j; j >>= 8; } CRYPTO_poly1305_update(poly1305, data, data_len); CRYPTO_poly1305_update(poly1305, length_bytes, sizeof(length_bytes)); } static int aead_chacha20_poly1305_seal(const EVP_AEAD_CTX *ctx, unsigned char *out, size_t *out_len, size_t max_out_len, const unsigned char *nonce, size_t nonce_len, const unsigned char *in, size_t in_len, const unsigned char *ad, size_t ad_len) { const struct aead_chacha20_poly1305_ctx *c20_ctx = ctx->aead_state; unsigned char poly1305_key[32]; poly1305_state poly1305; const uint64_t in_len_64 = in_len; /* The underlying ChaCha implementation may not overflow the block * counter into the second counter word. Therefore we disallow * individual operations that work on more than 2TB at a time. * in_len_64 is needed because, on 32-bit platforms, size_t is only * 32-bits and this produces a warning because it's always false. * Casting to uint64_t inside the conditional is not sufficient to stop * the warning. */ if (in_len_64 >= (1ULL << 32) * 64 - 64) { EVPerr(EVP_F_AEAD_CHACHA20_POLY1305_SEAL, EVP_R_TOO_LARGE); return 0; } if (max_out_len < in_len + c20_ctx->tag_len) { EVPerr(EVP_F_AEAD_CHACHA20_POLY1305_SEAL, EVP_R_BUFFER_TOO_SMALL); return 0; } if (nonce_len != CHACHA20_NONCE_LEN) { EVPerr(EVP_F_AEAD_CHACHA20_POLY1305_SEAL, EVP_R_IV_TOO_LARGE); return 0; } memset(poly1305_key, 0, sizeof(poly1305_key)); CRYPTO_chacha_20(poly1305_key, poly1305_key, sizeof(poly1305_key), c20_ctx->key, nonce, 0); CRYPTO_poly1305_init(&poly1305, poly1305_key); poly1305_update_with_length(&poly1305, ad, ad_len); CRYPTO_chacha_20(out, in, in_len, c20_ctx->key, nonce, 1); poly1305_update_with_length(&poly1305, out, in_len); if (c20_ctx->tag_len != POLY1305_TAG_LEN) { unsigned char tag[POLY1305_TAG_LEN]; CRYPTO_poly1305_finish(&poly1305, tag); memcpy(out + in_len, tag, c20_ctx->tag_len); *out_len = in_len + c20_ctx->tag_len; return 1; } CRYPTO_poly1305_finish(&poly1305, out + in_len); *out_len = in_len + POLY1305_TAG_LEN; return 1; } static int aead_chacha20_poly1305_open(const EVP_AEAD_CTX *ctx, unsigned char *out, size_t *out_len, size_t max_out_len, const unsigned char *nonce, size_t nonce_len, const unsigned char *in, size_t in_len, const unsigned char *ad, size_t ad_len) { const struct aead_chacha20_poly1305_ctx *c20_ctx = ctx->aead_state; unsigned char mac[POLY1305_TAG_LEN]; unsigned char poly1305_key[32]; poly1305_state poly1305; const uint64_t in_len_64 = in_len; size_t plaintext_len; if (in_len < c20_ctx->tag_len) { EVPerr(EVP_F_AEAD_CHACHA20_POLY1305_OPEN, EVP_R_BAD_DECRYPT); return 0; } /* The underlying ChaCha implementation may not overflow the block * counter into the second counter word. Therefore we disallow * individual operations that work on more than 2TB at a time. * in_len_64 is needed because, on 32-bit platforms, size_t is only * 32-bits and this produces a warning because it's always false. * Casting to uint64_t inside the conditional is not sufficient to stop * the warning. */ if (in_len_64 >= (1ULL << 32) * 64 - 64) { EVPerr(EVP_F_AEAD_CHACHA20_POLY1305_OPEN, EVP_R_TOO_LARGE); return 0; } if (nonce_len != CHACHA20_NONCE_LEN) { EVPerr(EVP_F_AEAD_CHACHA20_POLY1305_OPEN, EVP_R_IV_TOO_LARGE); return 0; } plaintext_len = in_len - c20_ctx->tag_len; if (max_out_len < plaintext_len) { EVPerr(EVP_F_AEAD_CHACHA20_POLY1305_OPEN, EVP_R_BUFFER_TOO_SMALL); return 0; } memset(poly1305_key, 0, sizeof(poly1305_key)); CRYPTO_chacha_20(poly1305_key, poly1305_key, sizeof(poly1305_key), c20_ctx->key, nonce, 0); CRYPTO_poly1305_init(&poly1305, poly1305_key); poly1305_update_with_length(&poly1305, ad, ad_len); poly1305_update_with_length(&poly1305, in, plaintext_len); CRYPTO_poly1305_finish(&poly1305, mac); if (CRYPTO_memcmp(mac, in + plaintext_len, c20_ctx->tag_len) != 0) { EVPerr(EVP_F_AEAD_CHACHA20_POLY1305_OPEN, EVP_R_BAD_DECRYPT); return 0; } CRYPTO_chacha_20(out, in, plaintext_len, c20_ctx->key, nonce, 1); *out_len = plaintext_len; return 1; } static const EVP_AEAD aead_chacha20_poly1305 = { .key_len = 32, .nonce_len = CHACHA20_NONCE_LEN, .overhead = POLY1305_TAG_LEN, .max_tag_len = POLY1305_TAG_LEN, .init = aead_chacha20_poly1305_init, .cleanup = aead_chacha20_poly1305_cleanup, .seal = aead_chacha20_poly1305_seal, .open = aead_chacha20_poly1305_open, }; const EVP_AEAD * EVP_aead_chacha20_poly1305() { return &aead_chacha20_poly1305; } #endif /* !OPENSSL_NO_CHACHA && !OPENSSL_NO_POLY1305 */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/e_idea.c0000644000175000017500000001131712360020705020422 0ustar /* $OpenBSD: e_idea.c,v 1.8 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #ifndef OPENSSL_NO_IDEA #include #include #include #include "evp_locl.h" static int idea_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); /* NB idea_ecb_encrypt doesn't take an 'encrypt' argument so we treat it as a special * case */ static int idea_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { BLOCK_CIPHER_ecb_loop() idea_ecb_encrypt(in + i, out + i, ctx->cipher_data); return 1; } /* Can't use IMPLEMENT_BLOCK_CIPHER because idea_ecb_encrypt is different */ typedef struct { IDEA_KEY_SCHEDULE ks; } EVP_IDEA_KEY; BLOCK_CIPHER_func_cbc(idea, idea, EVP_IDEA_KEY, ks) BLOCK_CIPHER_func_ofb(idea, idea, 64, EVP_IDEA_KEY, ks) BLOCK_CIPHER_func_cfb(idea, idea, 64, EVP_IDEA_KEY, ks) BLOCK_CIPHER_defs(idea, IDEA_KEY_SCHEDULE, NID_idea, 8, 16, 8, 64, 0, idea_init_key, NULL, EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL) static int idea_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { if (!enc) { if (EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_OFB_MODE) enc = 1; else if (EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_CFB_MODE) enc = 1; } if (enc) idea_set_encrypt_key(key, ctx->cipher_data); else { IDEA_KEY_SCHEDULE tmp; idea_set_encrypt_key(key, &tmp); idea_set_decrypt_key(&tmp, ctx->cipher_data); OPENSSL_cleanse((unsigned char *)&tmp, sizeof(IDEA_KEY_SCHEDULE)); } return 1; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/m_sha.c0000644000175000017500000001033612360020705020303 0ustar /* $OpenBSD: m_sha.c,v 1.14 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA0) #include #include #include #ifndef OPENSSL_NO_RSA #include #endif #include "evp_locl.h" static int init(EVP_MD_CTX *ctx) { return SHA_Init(ctx->md_data); } static int update(EVP_MD_CTX *ctx, const void *data, size_t count) { return SHA_Update(ctx->md_data, data, count); } static int final(EVP_MD_CTX *ctx, unsigned char *md) { return SHA_Final(md, ctx->md_data); } static const EVP_MD sha_md = { .type = NID_sha, .pkey_type = NID_shaWithRSAEncryption, .md_size = SHA_DIGEST_LENGTH, .flags = 0, .init = init, .update = update, .final = final, .copy = NULL, .cleanup = NULL, #ifndef OPENSSL_NO_RSA .sign = (evp_sign_method *)RSA_sign, .verify = (evp_verify_method *)RSA_verify, .required_pkey_type = { EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, }, #endif .block_size = SHA_CBLOCK, .ctx_size = sizeof(EVP_MD *) + sizeof(SHA_CTX), }; const EVP_MD * EVP_sha(void) { return (&sha_md); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/e_rc4_hmac_md5.c0000644000175000017500000002077412360020705021754 0ustar /* $OpenBSD: e_rc4_hmac_md5.c,v 1.3 2014/06/12 15:49:29 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== */ #include #include #include #if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_MD5) #include #include #include #include #ifndef EVP_CIPH_FLAG_AEAD_CIPHER #define EVP_CIPH_FLAG_AEAD_CIPHER 0x200000 #define EVP_CTRL_AEAD_TLS1_AAD 0x16 #define EVP_CTRL_AEAD_SET_MAC_KEY 0x17 #endif /* FIXME: surely this is available elsewhere? */ #define EVP_RC4_KEY_SIZE 16 typedef struct { RC4_KEY ks; MD5_CTX head, tail, md; size_t payload_length; } EVP_RC4_HMAC_MD5; #define NO_PAYLOAD_LENGTH ((size_t)-1) void rc4_md5_enc (RC4_KEY *key, const void *in0, void *out, MD5_CTX *ctx, const void *inp, size_t blocks); #define data(ctx) ((EVP_RC4_HMAC_MD5 *)(ctx)->cipher_data) static int rc4_hmac_md5_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *inkey, const unsigned char *iv, int enc) { EVP_RC4_HMAC_MD5 *key = data(ctx); RC4_set_key(&key->ks, EVP_CIPHER_CTX_key_length(ctx), inkey); MD5_Init(&key->head); /* handy when benchmarking */ key->tail = key->head; key->md = key->head; key->payload_length = NO_PAYLOAD_LENGTH; return 1; } #if !defined(OPENSSL_NO_ASM) && ( \ defined(__x86_64) || defined(__x86_64__) || \ defined(_M_AMD64) || defined(_M_X64) || \ defined(__INTEL__) ) && \ !(defined(__APPLE__) && defined(__MACH__)) #define STITCHED_CALL #endif #if !defined(STITCHED_CALL) #define rc4_off 0 #define md5_off 0 #endif static int rc4_hmac_md5_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { EVP_RC4_HMAC_MD5 *key = data(ctx); #if defined(STITCHED_CALL) size_t rc4_off = 32-1-(key->ks.x&(32-1)), /* 32 is $MOD from rc4_md5-x86_64.pl */ md5_off = MD5_CBLOCK - key->md.num, blocks; unsigned int l; extern unsigned int OPENSSL_ia32cap_P[]; #endif size_t plen = key->payload_length; if (plen != NO_PAYLOAD_LENGTH && len != (plen + MD5_DIGEST_LENGTH)) return 0; if (ctx->encrypt) { if (plen == NO_PAYLOAD_LENGTH) plen = len; #if defined(STITCHED_CALL) /* cipher has to "fall behind" */ if (rc4_off > md5_off) md5_off += MD5_CBLOCK; if (plen > md5_off && (blocks = (plen - md5_off) / MD5_CBLOCK) && (OPENSSL_ia32cap_P[0]&(1 << 20)) == 0) { MD5_Update(&key->md, in, md5_off); RC4(&key->ks, rc4_off, in, out); rc4_md5_enc(&key->ks, in + rc4_off, out + rc4_off, &key->md, in + md5_off, blocks); blocks *= MD5_CBLOCK; rc4_off += blocks; md5_off += blocks; key->md.Nh += blocks >> 29; key->md.Nl += blocks <<= 3; if (key->md.Nl < (unsigned int)blocks) key->md.Nh++; } else { rc4_off = 0; md5_off = 0; } #endif MD5_Update(&key->md, in + md5_off, plen - md5_off); if (plen!=len) { /* "TLS" mode of operation */ if (in != out) memcpy(out + rc4_off, in + rc4_off, plen - rc4_off); /* calculate HMAC and append it to payload */ MD5_Final(out + plen, &key->md); key->md = key->tail; MD5_Update(&key->md, out + plen, MD5_DIGEST_LENGTH); MD5_Final(out + plen, &key->md); /* encrypt HMAC at once */ RC4(&key->ks, len - rc4_off, out + rc4_off, out + rc4_off); } else { RC4(&key->ks, len - rc4_off, in + rc4_off, out + rc4_off); } } else { unsigned char mac[MD5_DIGEST_LENGTH]; #if defined(STITCHED_CALL) /* digest has to "fall behind" */ if (md5_off > rc4_off) rc4_off += 2*MD5_CBLOCK; else rc4_off += MD5_CBLOCK; if (len > rc4_off && (blocks = (len - rc4_off) / MD5_CBLOCK) && (OPENSSL_ia32cap_P[0] & (1 << 20)) == 0) { RC4(&key->ks, rc4_off, in, out); MD5_Update(&key->md, out, md5_off); rc4_md5_enc(&key->ks, in + rc4_off, out + rc4_off, &key->md, out + md5_off, blocks); blocks *= MD5_CBLOCK; rc4_off += blocks; md5_off += blocks; l = (key->md.Nl + (blocks << 3)) & 0xffffffffU; if (l < key->md.Nl) key->md.Nh++; key->md.Nl = l; key->md.Nh += blocks >> 29; } else { md5_off = 0; rc4_off = 0; } #endif /* decrypt HMAC at once */ RC4(&key->ks, len - rc4_off, in + rc4_off, out + rc4_off); if (plen!=NO_PAYLOAD_LENGTH) { /* "TLS" mode of operation */ MD5_Update(&key->md, out + md5_off, plen - md5_off); /* calculate HMAC and verify it */ MD5_Final(mac, &key->md); key->md = key->tail; MD5_Update(&key->md, mac, MD5_DIGEST_LENGTH); MD5_Final(mac, &key->md); if (memcmp(out + plen, mac, MD5_DIGEST_LENGTH)) return 0; } else { MD5_Update(&key->md, out + md5_off, len - md5_off); } } key->payload_length = NO_PAYLOAD_LENGTH; return 1; } static int rc4_hmac_md5_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) { EVP_RC4_HMAC_MD5 *key = data(ctx); switch (type) { case EVP_CTRL_AEAD_SET_MAC_KEY: { unsigned int i; unsigned char hmac_key[64]; memset (hmac_key, 0, sizeof(hmac_key)); if (arg > (int)sizeof(hmac_key)) { MD5_Init(&key->head); MD5_Update(&key->head, ptr, arg); MD5_Final(hmac_key, &key->head); } else { memcpy(hmac_key, ptr, arg); } for (i = 0; i < sizeof(hmac_key); i++) hmac_key[i] ^= 0x36; /* ipad */ MD5_Init(&key->head); MD5_Update(&key->head, hmac_key, sizeof(hmac_key)); for (i = 0; i < sizeof(hmac_key); i++) hmac_key[i] ^= 0x36 ^ 0x5c; /* opad */ MD5_Init(&key->tail); MD5_Update(&key->tail, hmac_key, sizeof(hmac_key)); return 1; } case EVP_CTRL_AEAD_TLS1_AAD: { unsigned char *p = ptr; unsigned int len = p[arg - 2] << 8 | p[arg - 1]; if (!ctx->encrypt) { len -= MD5_DIGEST_LENGTH; p[arg - 2] = len >> 8; p[arg - 1] = len; } key->payload_length = len; key->md = key->head; MD5_Update(&key->md, p, arg); return MD5_DIGEST_LENGTH; } default: return -1; } } static EVP_CIPHER r4_hmac_md5_cipher = { #ifdef NID_rc4_hmac_md5 NID_rc4_hmac_md5, #else NID_undef, #endif 1, EVP_RC4_KEY_SIZE, 0, EVP_CIPH_STREAM_CIPHER|EVP_CIPH_VARIABLE_LENGTH|EVP_CIPH_FLAG_AEAD_CIPHER, rc4_hmac_md5_init_key, rc4_hmac_md5_cipher, NULL, sizeof(EVP_RC4_HMAC_MD5), NULL, NULL, rc4_hmac_md5_ctrl, NULL }; const EVP_CIPHER * EVP_rc4_hmac_md5(void) { return (&r4_hmac_md5_cipher); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/pmeth_gn.c0000644000175000017500000001400612360020705021013 0ustar /* $OpenBSD: pmeth_gn.c,v 1.3 2014/06/12 15:49:29 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include "evp_locl.h" int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx) { int ret; if (!ctx || !ctx->pmeth || !ctx->pmeth->paramgen) { EVPerr(EVP_F_EVP_PKEY_PARAMGEN_INIT, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } ctx->operation = EVP_PKEY_OP_PARAMGEN; if (!ctx->pmeth->paramgen_init) return 1; ret = ctx->pmeth->paramgen_init(ctx); if (ret <= 0) ctx->operation = EVP_PKEY_OP_UNDEFINED; return ret; } int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey) { int ret; if (!ctx || !ctx->pmeth || !ctx->pmeth->paramgen) { EVPerr(EVP_F_EVP_PKEY_PARAMGEN, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } if (ctx->operation != EVP_PKEY_OP_PARAMGEN) { EVPerr(EVP_F_EVP_PKEY_PARAMGEN, EVP_R_OPERATON_NOT_INITIALIZED); return -1; } if (!ppkey) return -1; if (!*ppkey) *ppkey = EVP_PKEY_new(); ret = ctx->pmeth->paramgen(ctx, *ppkey); if (ret <= 0) { EVP_PKEY_free(*ppkey); *ppkey = NULL; } return ret; } int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx) { int ret; if (!ctx || !ctx->pmeth || !ctx->pmeth->keygen) { EVPerr(EVP_F_EVP_PKEY_KEYGEN_INIT, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } ctx->operation = EVP_PKEY_OP_KEYGEN; if (!ctx->pmeth->keygen_init) return 1; ret = ctx->pmeth->keygen_init(ctx); if (ret <= 0) ctx->operation = EVP_PKEY_OP_UNDEFINED; return ret; } int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey) { int ret; if (!ctx || !ctx->pmeth || !ctx->pmeth->keygen) { EVPerr(EVP_F_EVP_PKEY_KEYGEN, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } if (ctx->operation != EVP_PKEY_OP_KEYGEN) { EVPerr(EVP_F_EVP_PKEY_KEYGEN, EVP_R_OPERATON_NOT_INITIALIZED); return -1; } if (!ppkey) return -1; if (!*ppkey) *ppkey = EVP_PKEY_new(); ret = ctx->pmeth->keygen(ctx, *ppkey); if (ret <= 0) { EVP_PKEY_free(*ppkey); *ppkey = NULL; } return ret; } void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb) { ctx->pkey_gencb = cb; } EVP_PKEY_gen_cb * EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx) { return ctx->pkey_gencb; } /* "translation callback" to call EVP_PKEY_CTX callbacks using BN_GENCB * style callbacks. */ static int trans_cb(int a, int b, BN_GENCB *gcb) { EVP_PKEY_CTX *ctx = gcb->arg; ctx->keygen_info[0] = a; ctx->keygen_info[1] = b; return ctx->pkey_gencb(ctx); } void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx) { BN_GENCB_set(cb, trans_cb, ctx) } int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx) { if (idx == -1) return ctx->keygen_info_count; if (idx < 0 || idx > ctx->keygen_info_count) return 0; return ctx->keygen_info[idx]; } EVP_PKEY * EVP_PKEY_new_mac_key(int type, ENGINE *e, const unsigned char *key, int keylen) { EVP_PKEY_CTX *mac_ctx = NULL; EVP_PKEY *mac_key = NULL; mac_ctx = EVP_PKEY_CTX_new_id(type, e); if (!mac_ctx) return NULL; if (EVP_PKEY_keygen_init(mac_ctx) <= 0) goto merr; if (EVP_PKEY_CTX_ctrl(mac_ctx, -1, EVP_PKEY_OP_KEYGEN, EVP_PKEY_CTRL_SET_MAC_KEY, keylen, (void *)key) <= 0) goto merr; if (EVP_PKEY_keygen(mac_ctx, &mac_key) <= 0) goto merr; merr: if (mac_ctx) EVP_PKEY_CTX_free(mac_ctx); return mac_key; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/e_null.c0000644000175000017500000000777212360020705020504 0ustar /* $OpenBSD: e_null.c,v 1.13 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl); static const EVP_CIPHER n_cipher = { NID_undef, 1, 0, 0, 0, null_init_key, null_cipher, NULL, 0, NULL, NULL, NULL, NULL }; const EVP_CIPHER * EVP_enc_null(void) { return (&n_cipher); } static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { /* memset(&(ctx->c),0,sizeof(ctx->c));*/ return 1; } static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { if (in != out) memcpy((char *)out, (const char *)in, inl); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/evp_aead.c0000644000175000017500000000732112360020705020760 0ustar /* $OpenBSD: evp_aead.c,v 1.4 2014/06/12 15:49:29 deraadt Exp $ */ /* * Copyright (c) 2014, Google Inc. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include "evp_locl.h" size_t EVP_AEAD_key_length(const EVP_AEAD *aead) { return aead->key_len; } size_t EVP_AEAD_nonce_length(const EVP_AEAD *aead) { return aead->nonce_len; } size_t EVP_AEAD_max_overhead(const EVP_AEAD *aead) { return aead->overhead; } size_t EVP_AEAD_max_tag_len(const EVP_AEAD *aead) { return aead->max_tag_len; } int EVP_AEAD_CTX_init(EVP_AEAD_CTX *ctx, const EVP_AEAD *aead, const unsigned char *key, size_t key_len, size_t tag_len, ENGINE *impl) { ctx->aead = aead; if (key_len != aead->key_len) { EVPerr(EVP_F_EVP_AEAD_CTX_INIT, EVP_R_UNSUPPORTED_KEY_SIZE); return 0; } return aead->init(ctx, key, key_len, tag_len); } void EVP_AEAD_CTX_cleanup(EVP_AEAD_CTX *ctx) { if (ctx->aead == NULL) return; ctx->aead->cleanup(ctx); ctx->aead = NULL; } /* check_alias returns 0 if out points within the buffer determined by in * and in_len and 1 otherwise. * * When processing, there's only an issue if out points within in[:in_len] * and isn't equal to in. If that's the case then writing the output will * stomp input that hasn't been read yet. * * This function checks for that case. */ static int check_alias(const unsigned char *in, size_t in_len, const unsigned char *out) { if (out <= in) return 1; if (in + in_len <= out) return 1; return 0; } int EVP_AEAD_CTX_seal(const EVP_AEAD_CTX *ctx, unsigned char *out, size_t *out_len, size_t max_out_len, const unsigned char *nonce, size_t nonce_len, const unsigned char *in, size_t in_len, const unsigned char *ad, size_t ad_len) { size_t possible_out_len = in_len + ctx->aead->overhead; /* Overflow. */ if (possible_out_len < in_len) { EVPerr(EVP_F_AEAD_CTX_SEAL, EVP_R_TOO_LARGE); goto error; } if (!check_alias(in, in_len, out)) { EVPerr(EVP_F_AEAD_CTX_SEAL, EVP_R_OUTPUT_ALIASES_INPUT); goto error; } if (ctx->aead->seal(ctx, out, out_len, max_out_len, nonce, nonce_len, in, in_len, ad, ad_len)) { return 1; } error: /* In the event of an error, clear the output buffer so that a caller * that doesn't check the return value doesn't send raw data. */ memset(out, 0, max_out_len); *out_len = 0; return 0; } int EVP_AEAD_CTX_open(const EVP_AEAD_CTX *ctx, unsigned char *out, size_t *out_len, size_t max_out_len, const unsigned char *nonce, size_t nonce_len, const unsigned char *in, size_t in_len, const unsigned char *ad, size_t ad_len) { if (!check_alias(in, in_len, out)) { EVPerr(EVP_F_AEAD_CTX_OPEN, EVP_R_OUTPUT_ALIASES_INPUT); goto error; } if (ctx->aead->open(ctx, out, out_len, max_out_len, nonce, nonce_len, in, in_len, ad, ad_len)) { return 1; } error: /* In the event of an error, clear the output buffer so that a caller * that doesn't check the return value doesn't try and process bad * data. */ memset(out, 0, max_out_len); *out_len = 0; return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/p_dec.c0000644000175000017500000000743112360020705020270 0ustar /* $OpenBSD: p_dec.c,v 1.8 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #ifndef OPENSSL_NO_RSA #include #endif int EVP_PKEY_decrypt_old(unsigned char *key, const unsigned char *ek, int ekl, EVP_PKEY *priv) { int ret = -1; #ifndef OPENSSL_NO_RSA if (priv->type != EVP_PKEY_RSA) { #endif EVPerr(EVP_F_EVP_PKEY_DECRYPT_OLD, EVP_R_PUBLIC_KEY_NOT_RSA); #ifndef OPENSSL_NO_RSA goto err; } ret = RSA_private_decrypt(ekl, ek, key, priv->pkey.rsa, RSA_PKCS1_PADDING); err: #endif return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/p_sign.c0000644000175000017500000001146612360020705020500 0ustar /* $OpenBSD: p_sign.c,v 1.11 2014/06/12 15:49:29 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #ifdef undef void EVP_SignInit(EVP_MD_CTX *ctx, EVP_MD *type) { EVP_DigestInit_ex(ctx, type); } void EVP_SignUpdate(EVP_MD_CTX *ctx, unsigned char *data, unsigned int count) { EVP_DigestUpdate(ctx, data, count); } #endif int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, EVP_PKEY *pkey) { unsigned char m[EVP_MAX_MD_SIZE]; unsigned int m_len; int i = 0, ok = 0, v; EVP_MD_CTX tmp_ctx; EVP_PKEY_CTX *pkctx = NULL; *siglen = 0; EVP_MD_CTX_init(&tmp_ctx); if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx)) goto err; if (!EVP_DigestFinal_ex(&tmp_ctx, &(m[0]), &m_len)) goto err; EVP_MD_CTX_cleanup(&tmp_ctx); if (ctx->digest->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) { size_t sltmp = (size_t)EVP_PKEY_size(pkey); i = 0; pkctx = EVP_PKEY_CTX_new(pkey, NULL); if (!pkctx) goto err; if (EVP_PKEY_sign_init(pkctx) <= 0) goto err; if (EVP_PKEY_CTX_set_signature_md(pkctx, ctx->digest) <= 0) goto err; if (EVP_PKEY_sign(pkctx, sigret, &sltmp, m, m_len) <= 0) goto err; *siglen = sltmp; i = 1; err: EVP_PKEY_CTX_free(pkctx); return i; } for (i = 0; i < 4; i++) { v = ctx->digest->required_pkey_type[i]; if (v == 0) break; if (pkey->type == v) { ok = 1; break; } } if (!ok) { EVPerr(EVP_F_EVP_SIGNFINAL, EVP_R_WRONG_PUBLIC_KEY_TYPE); return (0); } if (ctx->digest->sign == NULL) { EVPerr(EVP_F_EVP_SIGNFINAL, EVP_R_NO_SIGN_FUNCTION_CONFIGURED); return (0); } return(ctx->digest->sign(ctx->digest->type, m, m_len, sigret, siglen, pkey->pkey.ptr)); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/p5_crpt2.c0000644000175000017500000002300512360020705020647 0ustar /* $OpenBSD: p5_crpt2.c,v 1.16 2014/07/10 22:45:57 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #if !defined(OPENSSL_NO_HMAC) && !defined(OPENSSL_NO_SHA) #include #include #include #include #include "evp_locl.h" /* set this to print out info about the keygen algorithm */ /* #define DEBUG_PKCS5V2 */ #ifdef DEBUG_PKCS5V2 static void h__dump (const unsigned char *p, int len); #endif /* This is an implementation of PKCS#5 v2.0 password based encryption key * derivation function PBKDF2. * SHA1 version verified against test vectors posted by Peter Gutmann * to the PKCS-TNG mailing list. */ int PKCS5_PBKDF2_HMAC(const char *pass, int passlen, const unsigned char *salt, int saltlen, int iter, const EVP_MD *digest, int keylen, unsigned char *out) { unsigned char digtmp[EVP_MAX_MD_SIZE], *p, itmp[4]; int cplen, j, k, tkeylen, mdlen; unsigned long i = 1; HMAC_CTX hctx_tpl, hctx; mdlen = EVP_MD_size(digest); if (mdlen < 0) return 0; HMAC_CTX_init(&hctx_tpl); p = out; tkeylen = keylen; if (!pass) passlen = 0; else if (passlen == -1) passlen = strlen(pass); if (!HMAC_Init_ex(&hctx_tpl, pass, passlen, digest, NULL)) { HMAC_CTX_cleanup(&hctx_tpl); return 0; } while (tkeylen) { if (tkeylen > mdlen) cplen = mdlen; else cplen = tkeylen; /* We are unlikely to ever use more than 256 blocks (5120 bits!) * but just in case... */ itmp[0] = (unsigned char)((i >> 24) & 0xff); itmp[1] = (unsigned char)((i >> 16) & 0xff); itmp[2] = (unsigned char)((i >> 8) & 0xff); itmp[3] = (unsigned char)(i & 0xff); if (!HMAC_CTX_copy(&hctx, &hctx_tpl)) { HMAC_CTX_cleanup(&hctx_tpl); return 0; } if (!HMAC_Update(&hctx, salt, saltlen) || !HMAC_Update(&hctx, itmp, 4) || !HMAC_Final(&hctx, digtmp, NULL)) { HMAC_CTX_cleanup(&hctx_tpl); HMAC_CTX_cleanup(&hctx); return 0; } HMAC_CTX_cleanup(&hctx); memcpy(p, digtmp, cplen); for (j = 1; j < iter; j++) { if (!HMAC_CTX_copy(&hctx, &hctx_tpl)) { HMAC_CTX_cleanup(&hctx_tpl); return 0; } if (!HMAC_Update(&hctx, digtmp, mdlen) || !HMAC_Final(&hctx, digtmp, NULL)) { HMAC_CTX_cleanup(&hctx_tpl); HMAC_CTX_cleanup(&hctx); return 0; } HMAC_CTX_cleanup(&hctx); for (k = 0; k < cplen; k++) p[k] ^= digtmp[k]; } tkeylen -= cplen; i++; p += cplen; } HMAC_CTX_cleanup(&hctx_tpl); #ifdef DEBUG_PKCS5V2 fprintf(stderr, "Password:\n"); h__dump (pass, passlen); fprintf(stderr, "Salt:\n"); h__dump (salt, saltlen); fprintf(stderr, "Iteration count %d\n", iter); fprintf(stderr, "Key:\n"); h__dump (out, keylen); #endif return 1; } int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, const unsigned char *salt, int saltlen, int iter, int keylen, unsigned char *out) { return PKCS5_PBKDF2_HMAC(pass, passlen, salt, saltlen, iter, EVP_sha1(), keylen, out); } /* Now the key derivation function itself. This is a bit evil because * it has to check the ASN1 parameters are valid: and there are quite a * few of them... */ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, ASN1_TYPE *param, const EVP_CIPHER *c, const EVP_MD *md, int en_de) { const unsigned char *pbuf; int plen; PBE2PARAM *pbe2 = NULL; const EVP_CIPHER *cipher; int rv = 0; if (param == NULL || param->type != V_ASN1_SEQUENCE || param->value.sequence == NULL) { EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_DECODE_ERROR); goto err; } pbuf = param->value.sequence->data; plen = param->value.sequence->length; if (!(pbe2 = d2i_PBE2PARAM(NULL, &pbuf, plen))) { EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_DECODE_ERROR); goto err; } /* See if we recognise the key derivation function */ if (OBJ_obj2nid(pbe2->keyfunc->algorithm) != NID_id_pbkdf2) { EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION); goto err; } /* lets see if we recognise the encryption algorithm. */ cipher = EVP_get_cipherbyobj(pbe2->encryption->algorithm); if (!cipher) { EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_UNSUPPORTED_CIPHER); goto err; } /* Fixup cipher based on AlgorithmIdentifier */ if (!EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, en_de)) goto err; if (EVP_CIPHER_asn1_to_param(ctx, pbe2->encryption->parameter) < 0) { EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_CIPHER_PARAMETER_ERROR); goto err; } rv = PKCS5_v2_PBKDF2_keyivgen(ctx, pass, passlen, pbe2->keyfunc->parameter, c, md, en_de); err: PBE2PARAM_free(pbe2); return rv; } int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, ASN1_TYPE *param, const EVP_CIPHER *c, const EVP_MD *md, int en_de) { unsigned char *salt, key[EVP_MAX_KEY_LENGTH]; const unsigned char *pbuf; int saltlen, iter, plen; int rv = 0; unsigned int keylen = 0; int prf_nid, hmac_md_nid; PBKDF2PARAM *kdf = NULL; const EVP_MD *prfmd; if (EVP_CIPHER_CTX_cipher(ctx) == NULL) { EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_NO_CIPHER_SET); goto err; } keylen = EVP_CIPHER_CTX_key_length(ctx); OPENSSL_assert(keylen <= sizeof key); /* Decode parameter */ if (!param || (param->type != V_ASN1_SEQUENCE)) { EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_DECODE_ERROR); goto err; } pbuf = param->value.sequence->data; plen = param->value.sequence->length; if (!(kdf = d2i_PBKDF2PARAM(NULL, &pbuf, plen)) ) { EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_DECODE_ERROR); goto err; } keylen = EVP_CIPHER_CTX_key_length(ctx); /* Now check the parameters of the kdf */ if (kdf->keylength && (ASN1_INTEGER_get(kdf->keylength) != (int)keylen)){ EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_UNSUPPORTED_KEYLENGTH); goto err; } if (kdf->prf) prf_nid = OBJ_obj2nid(kdf->prf->algorithm); else prf_nid = NID_hmacWithSHA1; if (!EVP_PBE_find(EVP_PBE_TYPE_PRF, prf_nid, NULL, &hmac_md_nid, 0)) { EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_UNSUPPORTED_PRF); goto err; } prfmd = EVP_get_digestbynid(hmac_md_nid); if (prfmd == NULL) { EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_UNSUPPORTED_PRF); goto err; } if (kdf->salt->type != V_ASN1_OCTET_STRING) { EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_UNSUPPORTED_SALT_TYPE); goto err; } /* it seems that its all OK */ salt = kdf->salt->value.octet_string->data; saltlen = kdf->salt->value.octet_string->length; iter = ASN1_INTEGER_get(kdf->iter); if (!PKCS5_PBKDF2_HMAC(pass, passlen, salt, saltlen, iter, prfmd, keylen, key)) goto err; rv = EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, en_de); err: OPENSSL_cleanse(key, keylen); PBKDF2PARAM_free(kdf); return rv; } #ifdef DEBUG_PKCS5V2 static void h__dump (const unsigned char *p, int len) { for (; len --; p++) fprintf(stderr, "%02X ", *p); fprintf(stderr, "\n"); } #endif #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/e_bf.c0000644000175000017500000000761712360020705020117 0ustar /* $OpenBSD: e_bf.c,v 1.7 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #ifndef OPENSSL_NO_BF #include #include #include #include "evp_locl.h" static int bf_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); typedef struct { BF_KEY ks; } EVP_BF_KEY; #define data(ctx) EVP_C_DATA(EVP_BF_KEY,ctx) IMPLEMENT_BLOCK_CIPHER(bf, ks, BF, EVP_BF_KEY, NID_bf, 8, 16, 8, 64, EVP_CIPH_VARIABLE_LENGTH, bf_init_key, NULL, EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL) static int bf_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { BF_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx), key); return 1; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/evp_enc.c0000644000175000017500000003762212360020705020642 0ustar /* $OpenBSD: evp_enc.c,v 1.23 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif #include "evp_locl.h" #define M_do_cipher(ctx, out, in, inl) ctx->cipher->do_cipher(ctx, out, in, inl) void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx) { memset(ctx, 0, sizeof(EVP_CIPHER_CTX)); } EVP_CIPHER_CTX * EVP_CIPHER_CTX_new(void) { return calloc(1, sizeof(EVP_CIPHER_CTX)); } int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, const unsigned char *key, const unsigned char *iv, int enc) { if (cipher) EVP_CIPHER_CTX_init(ctx); return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc); } int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, const unsigned char *key, const unsigned char *iv, int enc) { if (enc == -1) enc = ctx->encrypt; else { if (enc) enc = 1; ctx->encrypt = enc; } #ifndef OPENSSL_NO_ENGINE /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts * so this context may already have an ENGINE! Try to avoid releasing * the previous handle, re-querying for an ENGINE, and having a * reinitialisation, when it may all be unecessary. */ if (ctx->engine && ctx->cipher && (!cipher || (cipher && (cipher->nid == ctx->cipher->nid)))) goto skip_to_init; #endif if (cipher) { /* Ensure a context left lying around from last time is cleared * (the previous check attempted to avoid this if the same * ENGINE and EVP_CIPHER could be used). */ if (ctx->cipher) { unsigned long flags = ctx->flags; EVP_CIPHER_CTX_cleanup(ctx); /* Restore encrypt and flags */ ctx->encrypt = enc; ctx->flags = flags; } #ifndef OPENSSL_NO_ENGINE if (impl) { if (!ENGINE_init(impl)) { EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR); return 0; } } else /* Ask if an ENGINE is reserved for this job */ impl = ENGINE_get_cipher_engine(cipher->nid); if (impl) { /* There's an ENGINE for this job ... (apparently) */ const EVP_CIPHER *c = ENGINE_get_cipher(impl, cipher->nid); if (!c) { /* One positive side-effect of US's export * control history, is that we should at least * be able to avoid using US mispellings of * "initialisation"? */ EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR); return 0; } /* We'll use the ENGINE's private cipher definition */ cipher = c; /* Store the ENGINE functional reference so we know * 'cipher' came from an ENGINE and we need to release * it when done. */ ctx->engine = impl; } else ctx->engine = NULL; #endif ctx->cipher = cipher; if (ctx->cipher->ctx_size) { ctx->cipher_data = malloc(ctx->cipher->ctx_size); if (!ctx->cipher_data) { EVPerr(EVP_F_EVP_CIPHERINIT_EX, ERR_R_MALLOC_FAILURE); return 0; } } else { ctx->cipher_data = NULL; } ctx->key_len = cipher->key_len; ctx->flags = 0; if (ctx->cipher->flags & EVP_CIPH_CTRL_INIT) { if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL)) { EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR); return 0; } } } else if (!ctx->cipher) { EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_NO_CIPHER_SET); return 0; } #ifndef OPENSSL_NO_ENGINE skip_to_init: #endif /* we assume block size is a power of 2 in *cryptUpdate */ OPENSSL_assert(ctx->cipher->block_size == 1 || ctx->cipher->block_size == 8 || ctx->cipher->block_size == 16); if (!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) { switch (EVP_CIPHER_CTX_mode(ctx)) { case EVP_CIPH_STREAM_CIPHER: case EVP_CIPH_ECB_MODE: break; case EVP_CIPH_CFB_MODE: case EVP_CIPH_OFB_MODE: ctx->num = 0; /* fall-through */ case EVP_CIPH_CBC_MODE: OPENSSL_assert(EVP_CIPHER_CTX_iv_length(ctx) <= (int)sizeof(ctx->iv)); if (iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx)); memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx)); break; case EVP_CIPH_CTR_MODE: ctx->num = 0; /* Don't reuse IV for CTR mode */ if (iv) memcpy(ctx->iv, iv, EVP_CIPHER_CTX_iv_length(ctx)); break; default: return 0; break; } } if (key || (ctx->cipher->flags & EVP_CIPH_ALWAYS_CALL_INIT)) { if (!ctx->cipher->init(ctx, key, iv, enc)) return 0; } ctx->buf_len = 0; ctx->final_used = 0; ctx->block_mask = ctx->cipher->block_size - 1; return 1; } int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl) { if (ctx->encrypt) return EVP_EncryptUpdate(ctx, out, outl, in, inl); else return EVP_DecryptUpdate(ctx, out, outl, in, inl); } int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) { if (ctx->encrypt) return EVP_EncryptFinal_ex(ctx, out, outl); else return EVP_DecryptFinal_ex(ctx, out, outl); } int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) { if (ctx->encrypt) return EVP_EncryptFinal(ctx, out, outl); else return EVP_DecryptFinal(ctx, out, outl); } int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, const unsigned char *key, const unsigned char *iv) { return EVP_CipherInit(ctx, cipher, key, iv, 1); } int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, const unsigned char *key, const unsigned char *iv) { return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 1); } int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, const unsigned char *key, const unsigned char *iv) { return EVP_CipherInit(ctx, cipher, key, iv, 0); } int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, const unsigned char *key, const unsigned char *iv) { return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 0); } int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl) { int i, j, bl; if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) { i = M_do_cipher(ctx, out, in, inl); if (i < 0) return 0; else *outl = i; return 1; } if (inl <= 0) { *outl = 0; return inl == 0; } if (ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0) { if (M_do_cipher(ctx, out, in, inl)) { *outl = inl; return 1; } else { *outl = 0; return 0; } } i = ctx->buf_len; bl = ctx->cipher->block_size; OPENSSL_assert(bl <= (int)sizeof(ctx->buf)); if (i != 0) { if (i + inl < bl) { memcpy(&(ctx->buf[i]), in, inl); ctx->buf_len += inl; *outl = 0; return 1; } else { j = bl - i; memcpy(&(ctx->buf[i]), in, j); if (!M_do_cipher(ctx, out, ctx->buf, bl)) return 0; inl -= j; in += j; out += bl; *outl = bl; } } else *outl = 0; i = inl&(bl - 1); inl -= i; if (inl > 0) { if (!M_do_cipher(ctx, out, in, inl)) return 0; *outl += inl; } if (i != 0) memcpy(ctx->buf, &(in[inl]), i); ctx->buf_len = i; return 1; } int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) { int ret; ret = EVP_EncryptFinal_ex(ctx, out, outl); return ret; } int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) { int n, ret; unsigned int i, b, bl; if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) { ret = M_do_cipher(ctx, out, NULL, 0); if (ret < 0) return 0; else *outl = ret; return 1; } b = ctx->cipher->block_size; OPENSSL_assert(b <= sizeof ctx->buf); if (b == 1) { *outl = 0; return 1; } bl = ctx->buf_len; if (ctx->flags & EVP_CIPH_NO_PADDING) { if (bl) { EVPerr(EVP_F_EVP_ENCRYPTFINAL_EX, EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH); return 0; } *outl = 0; return 1; } n = b - bl; for (i = bl; i < b; i++) ctx->buf[i] = n; ret = M_do_cipher(ctx, out, ctx->buf, b); if (ret) *outl = b; return ret; } int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl) { int fix_len; unsigned int b; if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) { fix_len = M_do_cipher(ctx, out, in, inl); if (fix_len < 0) { *outl = 0; return 0; } else *outl = fix_len; return 1; } if (inl <= 0) { *outl = 0; return inl == 0; } if (ctx->flags & EVP_CIPH_NO_PADDING) return EVP_EncryptUpdate(ctx, out, outl, in, inl); b = ctx->cipher->block_size; OPENSSL_assert(b <= sizeof ctx->final); if (ctx->final_used) { memcpy(out, ctx->final, b); out += b; fix_len = 1; } else fix_len = 0; if (!EVP_EncryptUpdate(ctx, out, outl, in, inl)) return 0; /* if we have 'decrypted' a multiple of block size, make sure * we have a copy of this last block */ if (b > 1 && !ctx->buf_len) { *outl -= b; ctx->final_used = 1; memcpy(ctx->final, &out[*outl], b); } else ctx->final_used = 0; if (fix_len) *outl += b; return 1; } int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) { int ret; ret = EVP_DecryptFinal_ex(ctx, out, outl); return ret; } int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) { int i, n; unsigned int b; *outl = 0; if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) { i = M_do_cipher(ctx, out, NULL, 0); if (i < 0) return 0; else *outl = i; return 1; } b = ctx->cipher->block_size; if (ctx->flags & EVP_CIPH_NO_PADDING) { if (ctx->buf_len) { EVPerr(EVP_F_EVP_DECRYPTFINAL_EX, EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH); return 0; } *outl = 0; return 1; } if (b > 1) { if (ctx->buf_len || !ctx->final_used) { EVPerr(EVP_F_EVP_DECRYPTFINAL_EX, EVP_R_WRONG_FINAL_BLOCK_LENGTH); return (0); } OPENSSL_assert(b <= sizeof ctx->final); n = ctx->final[b - 1]; if (n == 0 || n > (int)b) { EVPerr(EVP_F_EVP_DECRYPTFINAL_EX, EVP_R_BAD_DECRYPT); return (0); } for (i = 0; i < n; i++) { if (ctx->final[--b] != n) { EVPerr(EVP_F_EVP_DECRYPTFINAL_EX, EVP_R_BAD_DECRYPT); return (0); } } n = ctx->cipher->block_size - n; for (i = 0; i < n; i++) out[i] = ctx->final[i]; *outl = n; } else *outl = 0; return (1); } void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx) { if (ctx) { EVP_CIPHER_CTX_cleanup(ctx); free(ctx); } } int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c) { if (c->cipher != NULL) { if (c->cipher->cleanup && !c->cipher->cleanup(c)) return 0; /* Cleanse cipher context data */ if (c->cipher_data) OPENSSL_cleanse(c->cipher_data, c->cipher->ctx_size); } free(c->cipher_data); #ifndef OPENSSL_NO_ENGINE if (c->engine) /* The EVP_CIPHER we used belongs to an ENGINE, release the * functional reference we held for this reason. */ ENGINE_finish(c->engine); #endif memset(c, 0, sizeof(EVP_CIPHER_CTX)); return 1; } int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, int keylen) { if (c->cipher->flags & EVP_CIPH_CUSTOM_KEY_LENGTH) return EVP_CIPHER_CTX_ctrl(c, EVP_CTRL_SET_KEY_LENGTH, keylen, NULL); if (c->key_len == keylen) return 1; if ((keylen > 0) && (c->cipher->flags & EVP_CIPH_VARIABLE_LENGTH)) { c->key_len = keylen; return 1; } EVPerr(EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH, EVP_R_INVALID_KEY_LENGTH); return 0; } int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *ctx, int pad) { if (pad) ctx->flags &= ~EVP_CIPH_NO_PADDING; else ctx->flags |= EVP_CIPH_NO_PADDING; return 1; } int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) { int ret; if (!ctx->cipher) { EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_NO_CIPHER_SET); return 0; } if (!ctx->cipher->ctrl) { EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_CTRL_NOT_IMPLEMENTED); return 0; } ret = ctx->cipher->ctrl(ctx, type, arg, ptr); if (ret == -1) { EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED); return 0; } return ret; } int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key) { if (ctx->cipher->flags & EVP_CIPH_RAND_KEY) return EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_RAND_KEY, 0, key); if (RAND_bytes(key, ctx->key_len) <= 0) return 0; return 1; } int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in) { if ((in == NULL) || (in->cipher == NULL)) { EVPerr(EVP_F_EVP_CIPHER_CTX_COPY, EVP_R_INPUT_NOT_INITIALIZED); return 0; } #ifndef OPENSSL_NO_ENGINE /* Make sure it's safe to copy a cipher context using an ENGINE */ if (in->engine && !ENGINE_init(in->engine)) { EVPerr(EVP_F_EVP_CIPHER_CTX_COPY, ERR_R_ENGINE_LIB); return 0; } #endif EVP_CIPHER_CTX_cleanup(out); memcpy(out, in, sizeof *out); if (in->cipher_data && in->cipher->ctx_size) { out->cipher_data = malloc(in->cipher->ctx_size); if (!out->cipher_data) { EVPerr(EVP_F_EVP_CIPHER_CTX_COPY, ERR_R_MALLOC_FAILURE); return 0; } memcpy(out->cipher_data, in->cipher_data, in->cipher->ctx_size); } if (in->cipher->flags & EVP_CIPH_CUSTOM_COPY) return in->cipher->ctrl((EVP_CIPHER_CTX *)in, EVP_CTRL_COPY, 0, out); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/evp_lib.c0000644000175000017500000001732412360020705020640 0ustar /* $OpenBSD: evp_lib.c,v 1.12 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type) { int ret; if (c->cipher->set_asn1_parameters != NULL) ret = c->cipher->set_asn1_parameters(c, type); else if (c->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) ret = EVP_CIPHER_set_asn1_iv(c, type); else ret = -1; return (ret); } int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type) { int ret; if (c->cipher->get_asn1_parameters != NULL) ret = c->cipher->get_asn1_parameters(c, type); else if (c->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) ret = EVP_CIPHER_get_asn1_iv(c, type); else ret = -1; return (ret); } int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) { int i = 0; unsigned int l; if (type != NULL) { l = EVP_CIPHER_CTX_iv_length(c); OPENSSL_assert(l <= sizeof(c->iv)); i = ASN1_TYPE_get_octetstring(type, c->oiv, l); if (i != (int)l) return (-1); else if (i > 0) memcpy(c->iv, c->oiv, l); } return (i); } int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) { int i = 0; unsigned int j; if (type != NULL) { j = EVP_CIPHER_CTX_iv_length(c); OPENSSL_assert(j <= sizeof(c->iv)); i = ASN1_TYPE_set_octetstring(type, c->oiv, j); } return (i); } /* Convert the various cipher NIDs and dummies to a proper OID NID */ int EVP_CIPHER_type(const EVP_CIPHER *ctx) { int nid; ASN1_OBJECT *otmp; nid = EVP_CIPHER_nid(ctx); switch (nid) { case NID_rc2_cbc: case NID_rc2_64_cbc: case NID_rc2_40_cbc: return NID_rc2_cbc; case NID_rc4: case NID_rc4_40: return NID_rc4; case NID_aes_128_cfb128: case NID_aes_128_cfb8: case NID_aes_128_cfb1: return NID_aes_128_cfb128; case NID_aes_192_cfb128: case NID_aes_192_cfb8: case NID_aes_192_cfb1: return NID_aes_192_cfb128; case NID_aes_256_cfb128: case NID_aes_256_cfb8: case NID_aes_256_cfb1: return NID_aes_256_cfb128; case NID_des_cfb64: case NID_des_cfb8: case NID_des_cfb1: return NID_des_cfb64; case NID_des_ede3_cfb64: case NID_des_ede3_cfb8: case NID_des_ede3_cfb1: return NID_des_cfb64; default: /* Check it has an OID and it is valid */ otmp = OBJ_nid2obj(nid); if (!otmp || !otmp->data) nid = NID_undef; ASN1_OBJECT_free(otmp); return nid; } } int EVP_CIPHER_block_size(const EVP_CIPHER *e) { return e->block_size; } int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx) { return ctx->cipher->block_size; } int EVP_Cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) { return ctx->cipher->do_cipher(ctx, out, in, inl); } const EVP_CIPHER * EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx) { return ctx->cipher; } unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher) { return cipher->flags; } unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx) { return ctx->cipher->flags; } void * EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx) { return ctx->app_data; } void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data) { ctx->app_data = data; } int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher) { return cipher->iv_len; } int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx) { return ctx->cipher->iv_len; } int EVP_CIPHER_key_length(const EVP_CIPHER *cipher) { return cipher->key_len; } int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx) { return ctx->key_len; } int EVP_CIPHER_nid(const EVP_CIPHER *cipher) { return cipher->nid; } int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx) { return ctx->cipher->nid; } int EVP_MD_block_size(const EVP_MD *md) { return md->block_size; } int EVP_MD_type(const EVP_MD *md) { return md->type; } int EVP_MD_pkey_type(const EVP_MD *md) { return md->pkey_type; } int EVP_MD_size(const EVP_MD *md) { if (!md) { EVPerr(EVP_F_EVP_MD_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL); return -1; } return md->md_size; } unsigned long EVP_MD_flags(const EVP_MD *md) { return md->flags; } const EVP_MD * EVP_MD_CTX_md(const EVP_MD_CTX *ctx) { if (!ctx) return NULL; return ctx->digest; } void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags) { ctx->flags |= flags; } void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags) { ctx->flags &= ~flags; } int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags) { return (ctx->flags & flags); } void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags) { ctx->flags |= flags; } void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags) { ctx->flags &= ~flags; } int EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags) { return (ctx->flags & flags); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/bio_enc.c0000644000175000017500000002541712360020705020620 0ustar /* $OpenBSD: bio_enc.c,v 1.17 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include static int enc_write(BIO *h, const char *buf, int num); static int enc_read(BIO *h, char *buf, int size); /*static int enc_puts(BIO *h, const char *str); */ /*static int enc_gets(BIO *h, char *str, int size); */ static long enc_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int enc_new(BIO *h); static int enc_free(BIO *data); static long enc_callback_ctrl(BIO *h, int cmd, bio_info_cb *fps); #define ENC_BLOCK_SIZE (1024*4) #define BUF_OFFSET (EVP_MAX_BLOCK_LENGTH*2) typedef struct enc_struct { int buf_len; int buf_off; int cont; /* <= 0 when finished */ int finished; int ok; /* bad decrypt */ EVP_CIPHER_CTX cipher; /* buf is larger than ENC_BLOCK_SIZE because EVP_DecryptUpdate * can return up to a block more data than is presented to it */ char buf[ENC_BLOCK_SIZE + BUF_OFFSET + 2]; } BIO_ENC_CTX; static BIO_METHOD methods_enc = { .type = BIO_TYPE_CIPHER, .name = "cipher", .bwrite = enc_write, .bread = enc_read, .ctrl = enc_ctrl, .create = enc_new, .destroy = enc_free, .callback_ctrl = enc_callback_ctrl }; BIO_METHOD * BIO_f_cipher(void) { return (&methods_enc); } static int enc_new(BIO *bi) { BIO_ENC_CTX *ctx; ctx = malloc(sizeof(BIO_ENC_CTX)); if (ctx == NULL) return (0); EVP_CIPHER_CTX_init(&ctx->cipher); ctx->buf_len = 0; ctx->buf_off = 0; ctx->cont = 1; ctx->finished = 0; ctx->ok = 1; bi->init = 0; bi->ptr = (char *)ctx; bi->flags = 0; return (1); } static int enc_free(BIO *a) { BIO_ENC_CTX *b; if (a == NULL) return (0); b = (BIO_ENC_CTX *)a->ptr; EVP_CIPHER_CTX_cleanup(&(b->cipher)); OPENSSL_cleanse(a->ptr, sizeof(BIO_ENC_CTX)); free(a->ptr); a->ptr = NULL; a->init = 0; a->flags = 0; return (1); } static int enc_read(BIO *b, char *out, int outl) { int ret = 0, i; BIO_ENC_CTX *ctx; if (out == NULL) return (0); ctx = (BIO_ENC_CTX *)b->ptr; if ((ctx == NULL) || (b->next_bio == NULL)) return (0); /* First check if there are bytes decoded/encoded */ if (ctx->buf_len > 0) { i = ctx->buf_len - ctx->buf_off; if (i > outl) i = outl; memcpy(out, &(ctx->buf[ctx->buf_off]), i); ret = i; out += i; outl -= i; ctx->buf_off += i; if (ctx->buf_len == ctx->buf_off) { ctx->buf_len = 0; ctx->buf_off = 0; } } /* At this point, we have room of outl bytes and an empty * buffer, so we should read in some more. */ while (outl > 0) { if (ctx->cont <= 0) break; /* read in at IV offset, read the EVP_Cipher * documentation about why */ i = BIO_read(b->next_bio, &(ctx->buf[BUF_OFFSET]), ENC_BLOCK_SIZE); if (i <= 0) { /* Should be continue next time we are called? */ if (!BIO_should_retry(b->next_bio)) { ctx->cont = i; i = EVP_CipherFinal_ex(&(ctx->cipher), (unsigned char *)ctx->buf, &(ctx->buf_len)); ctx->ok = i; ctx->buf_off = 0; } else { ret = (ret == 0) ? i : ret; break; } } else { EVP_CipherUpdate(&(ctx->cipher), (unsigned char *)ctx->buf, &ctx->buf_len, (unsigned char *)&(ctx->buf[BUF_OFFSET]), i); ctx->cont = 1; /* Note: it is possible for EVP_CipherUpdate to * decrypt zero bytes because this is or looks like * the final block: if this happens we should retry * and either read more data or decrypt the final * block */ if (ctx->buf_len == 0) continue; } if (ctx->buf_len <= outl) i = ctx->buf_len; else i = outl; if (i <= 0) break; memcpy(out, ctx->buf, i); ret += i; ctx->buf_off = i; outl -= i; out += i; } BIO_clear_retry_flags(b); BIO_copy_next_retry(b); return ((ret == 0) ? ctx->cont : ret); } static int enc_write(BIO *b, const char *in, int inl) { int ret = 0, n, i; BIO_ENC_CTX *ctx; ctx = (BIO_ENC_CTX *)b->ptr; ret = inl; BIO_clear_retry_flags(b); n = ctx->buf_len - ctx->buf_off; while (n > 0) { i = BIO_write(b->next_bio, &(ctx->buf[ctx->buf_off]), n); if (i <= 0) { BIO_copy_next_retry(b); return (i); } ctx->buf_off += i; n -= i; } /* at this point all pending data has been written */ if ((in == NULL) || (inl <= 0)) return (0); ctx->buf_off = 0; while (inl > 0) { n = (inl > ENC_BLOCK_SIZE) ? ENC_BLOCK_SIZE : inl; EVP_CipherUpdate(&(ctx->cipher), (unsigned char *)ctx->buf, &ctx->buf_len, (unsigned char *)in, n); inl -= n; in += n; ctx->buf_off = 0; n = ctx->buf_len; while (n > 0) { i = BIO_write(b->next_bio, &(ctx->buf[ctx->buf_off]), n); if (i <= 0) { BIO_copy_next_retry(b); return (ret == inl) ? i : ret - inl; } n -= i; ctx->buf_off += i; } ctx->buf_len = 0; ctx->buf_off = 0; } BIO_copy_next_retry(b); return (ret); } static long enc_ctrl(BIO *b, int cmd, long num, void *ptr) { BIO *dbio; BIO_ENC_CTX *ctx, *dctx; long ret = 1; int i; EVP_CIPHER_CTX **c_ctx; ctx = (BIO_ENC_CTX *)b->ptr; switch (cmd) { case BIO_CTRL_RESET: ctx->ok = 1; ctx->finished = 0; EVP_CipherInit_ex(&(ctx->cipher), NULL, NULL, NULL, NULL, ctx->cipher.encrypt); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; case BIO_CTRL_EOF: /* More to read */ if (ctx->cont <= 0) ret = 1; else ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; case BIO_CTRL_WPENDING: ret = ctx->buf_len - ctx->buf_off; if (ret <= 0) ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; case BIO_CTRL_PENDING: /* More to read in buffer */ ret = ctx->buf_len - ctx->buf_off; if (ret <= 0) ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; case BIO_CTRL_FLUSH: /* do a final write */ again: while (ctx->buf_len != ctx->buf_off) { i = enc_write(b, NULL, 0); if (i < 0) return i; } if (!ctx->finished) { ctx->finished = 1; ctx->buf_off = 0; ret = EVP_CipherFinal_ex(&(ctx->cipher), (unsigned char *)ctx->buf, &(ctx->buf_len)); ctx->ok = (int)ret; if (ret <= 0) break; /* push out the bytes */ goto again; } /* Finally flush the underlying BIO */ ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; case BIO_C_GET_CIPHER_STATUS: ret = (long)ctx->ok; break; case BIO_C_DO_STATE_MACHINE: BIO_clear_retry_flags(b); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); BIO_copy_next_retry(b); break; case BIO_C_GET_CIPHER_CTX: c_ctx = (EVP_CIPHER_CTX **)ptr; (*c_ctx) = &(ctx->cipher); b->init = 1; break; case BIO_CTRL_DUP: dbio = (BIO *)ptr; dctx = (BIO_ENC_CTX *)dbio->ptr; EVP_CIPHER_CTX_init(&dctx->cipher); ret = EVP_CIPHER_CTX_copy(&dctx->cipher, &ctx->cipher); if (ret) dbio->init = 1; break; default: ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; } return (ret); } static long enc_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) { long ret = 1; if (b->next_bio == NULL) return (0); switch (cmd) { default: ret = BIO_callback_ctrl(b->next_bio, cmd, fp); break; } return (ret); } /* void BIO_set_cipher_ctx(b,c) BIO *b; EVP_CIPHER_ctx *c; { if (b == NULL) return; if ((b->callback != NULL) && (b->callback(b,BIO_CB_CTRL,(char *)c,BIO_CTRL_SET,e,0L) <= 0)) return; b->init=1; ctx=(BIO_ENC_CTX *)b->ptr; memcpy(ctx->cipher,c,sizeof(EVP_CIPHER_CTX)); if (b->callback != NULL) b->callback(b,BIO_CB_CTRL,(char *)c,BIO_CTRL_SET,e,1L); } */ void BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k, const unsigned char *i, int e) { BIO_ENC_CTX *ctx; if (b == NULL) return; if ((b->callback != NULL) && (b->callback(b, BIO_CB_CTRL, (const char *)c, BIO_CTRL_SET, e, 0L) <= 0)) return; b->init = 1; ctx = (BIO_ENC_CTX *)b->ptr; EVP_CipherInit_ex(&(ctx->cipher), c, NULL, k, i, e); if (b->callback != NULL) b->callback(b, BIO_CB_CTRL, (const char *)c, BIO_CTRL_SET, e, 1L); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/pmeth_fn.c0000644000175000017500000002451312360020705021016 0ustar /* $OpenBSD: pmeth_fn.c,v 1.3 2014/06/12 15:49:29 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include "evp_locl.h" #define M_check_autoarg(ctx, arg, arglen, err) \ if (ctx->pmeth->flags & EVP_PKEY_FLAG_AUTOARGLEN) \ { \ size_t pksize = (size_t)EVP_PKEY_size(ctx->pkey); \ if (!arg) \ { \ *arglen = pksize; \ return 1; \ } \ else if (*arglen < pksize) \ { \ EVPerr(err, EVP_R_BUFFER_TOO_SMALL); /*ckerr_ignore*/\ return 0; \ } \ } int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx) { int ret; if (!ctx || !ctx->pmeth || !ctx->pmeth->sign) { EVPerr(EVP_F_EVP_PKEY_SIGN_INIT, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } ctx->operation = EVP_PKEY_OP_SIGN; if (!ctx->pmeth->sign_init) return 1; ret = ctx->pmeth->sign_init(ctx); if (ret <= 0) ctx->operation = EVP_PKEY_OP_UNDEFINED; return ret; } int EVP_PKEY_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, const unsigned char *tbs, size_t tbslen) { if (!ctx || !ctx->pmeth || !ctx->pmeth->sign) { EVPerr(EVP_F_EVP_PKEY_SIGN, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } if (ctx->operation != EVP_PKEY_OP_SIGN) { EVPerr(EVP_F_EVP_PKEY_SIGN, EVP_R_OPERATON_NOT_INITIALIZED); return -1; } M_check_autoarg(ctx, sig, siglen, EVP_F_EVP_PKEY_SIGN) return ctx->pmeth->sign(ctx, sig, siglen, tbs, tbslen); } int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx) { int ret; if (!ctx || !ctx->pmeth || !ctx->pmeth->verify) { EVPerr(EVP_F_EVP_PKEY_VERIFY_INIT, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } ctx->operation = EVP_PKEY_OP_VERIFY; if (!ctx->pmeth->verify_init) return 1; ret = ctx->pmeth->verify_init(ctx); if (ret <= 0) ctx->operation = EVP_PKEY_OP_UNDEFINED; return ret; } int EVP_PKEY_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, const unsigned char *tbs, size_t tbslen) { if (!ctx || !ctx->pmeth || !ctx->pmeth->verify) { EVPerr(EVP_F_EVP_PKEY_VERIFY, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } if (ctx->operation != EVP_PKEY_OP_VERIFY) { EVPerr(EVP_F_EVP_PKEY_VERIFY, EVP_R_OPERATON_NOT_INITIALIZED); return -1; } return ctx->pmeth->verify(ctx, sig, siglen, tbs, tbslen); } int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx) { int ret; if (!ctx || !ctx->pmeth || !ctx->pmeth->verify_recover) { EVPerr(EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } ctx->operation = EVP_PKEY_OP_VERIFYRECOVER; if (!ctx->pmeth->verify_recover_init) return 1; ret = ctx->pmeth->verify_recover_init(ctx); if (ret <= 0) ctx->operation = EVP_PKEY_OP_UNDEFINED; return ret; } int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx, unsigned char *rout, size_t *routlen, const unsigned char *sig, size_t siglen) { if (!ctx || !ctx->pmeth || !ctx->pmeth->verify_recover) { EVPerr(EVP_F_EVP_PKEY_VERIFY_RECOVER, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } if (ctx->operation != EVP_PKEY_OP_VERIFYRECOVER) { EVPerr(EVP_F_EVP_PKEY_VERIFY_RECOVER, EVP_R_OPERATON_NOT_INITIALIZED); return -1; } M_check_autoarg(ctx, rout, routlen, EVP_F_EVP_PKEY_VERIFY_RECOVER) return ctx->pmeth->verify_recover(ctx, rout, routlen, sig, siglen); } int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx) { int ret; if (!ctx || !ctx->pmeth || !ctx->pmeth->encrypt) { EVPerr(EVP_F_EVP_PKEY_ENCRYPT_INIT, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } ctx->operation = EVP_PKEY_OP_ENCRYPT; if (!ctx->pmeth->encrypt_init) return 1; ret = ctx->pmeth->encrypt_init(ctx); if (ret <= 0) ctx->operation = EVP_PKEY_OP_UNDEFINED; return ret; } int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, const unsigned char *in, size_t inlen) { if (!ctx || !ctx->pmeth || !ctx->pmeth->encrypt) { EVPerr(EVP_F_EVP_PKEY_ENCRYPT, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } if (ctx->operation != EVP_PKEY_OP_ENCRYPT) { EVPerr(EVP_F_EVP_PKEY_ENCRYPT, EVP_R_OPERATON_NOT_INITIALIZED); return -1; } M_check_autoarg(ctx, out, outlen, EVP_F_EVP_PKEY_ENCRYPT) return ctx->pmeth->encrypt(ctx, out, outlen, in, inlen); } int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx) { int ret; if (!ctx || !ctx->pmeth || !ctx->pmeth->decrypt) { EVPerr(EVP_F_EVP_PKEY_DECRYPT_INIT, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } ctx->operation = EVP_PKEY_OP_DECRYPT; if (!ctx->pmeth->decrypt_init) return 1; ret = ctx->pmeth->decrypt_init(ctx); if (ret <= 0) ctx->operation = EVP_PKEY_OP_UNDEFINED; return ret; } int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, const unsigned char *in, size_t inlen) { if (!ctx || !ctx->pmeth || !ctx->pmeth->decrypt) { EVPerr(EVP_F_EVP_PKEY_DECRYPT, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } if (ctx->operation != EVP_PKEY_OP_DECRYPT) { EVPerr(EVP_F_EVP_PKEY_DECRYPT, EVP_R_OPERATON_NOT_INITIALIZED); return -1; } M_check_autoarg(ctx, out, outlen, EVP_F_EVP_PKEY_DECRYPT) return ctx->pmeth->decrypt(ctx, out, outlen, in, inlen); } int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx) { int ret; if (!ctx || !ctx->pmeth || !ctx->pmeth->derive) { EVPerr(EVP_F_EVP_PKEY_DERIVE_INIT, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } ctx->operation = EVP_PKEY_OP_DERIVE; if (!ctx->pmeth->derive_init) return 1; ret = ctx->pmeth->derive_init(ctx); if (ret <= 0) ctx->operation = EVP_PKEY_OP_UNDEFINED; return ret; } int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer) { int ret; if (!ctx || !ctx->pmeth || !(ctx->pmeth->derive || ctx->pmeth->encrypt || ctx->pmeth->decrypt) || !ctx->pmeth->ctrl) { EVPerr(EVP_F_EVP_PKEY_DERIVE_SET_PEER, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } if (ctx->operation != EVP_PKEY_OP_DERIVE && ctx->operation != EVP_PKEY_OP_ENCRYPT && ctx->operation != EVP_PKEY_OP_DECRYPT) { EVPerr(EVP_F_EVP_PKEY_DERIVE_SET_PEER, EVP_R_OPERATON_NOT_INITIALIZED); return -1; } ret = ctx->pmeth->ctrl(ctx, EVP_PKEY_CTRL_PEER_KEY, 0, peer); if (ret <= 0) return ret; if (ret == 2) return 1; if (!ctx->pkey) { EVPerr(EVP_F_EVP_PKEY_DERIVE_SET_PEER, EVP_R_NO_KEY_SET); return -1; } if (ctx->pkey->type != peer->type) { EVPerr(EVP_F_EVP_PKEY_DERIVE_SET_PEER, EVP_R_DIFFERENT_KEY_TYPES); return -1; } /* ran@cryptocom.ru: For clarity. The error is if parameters in peer are * present (!missing) but don't match. EVP_PKEY_cmp_parameters may return * 1 (match), 0 (don't match) and -2 (comparison is not defined). -1 * (different key types) is impossible here because it is checked earlier. * -2 is OK for us here, as well as 1, so we can check for 0 only. */ if (!EVP_PKEY_missing_parameters(peer) && !EVP_PKEY_cmp_parameters(ctx->pkey, peer)) { EVPerr(EVP_F_EVP_PKEY_DERIVE_SET_PEER, EVP_R_DIFFERENT_PARAMETERS); return -1; } if (ctx->peerkey) EVP_PKEY_free(ctx->peerkey); ctx->peerkey = peer; ret = ctx->pmeth->ctrl(ctx, EVP_PKEY_CTRL_PEER_KEY, 1, peer); if (ret <= 0) { ctx->peerkey = NULL; return ret; } CRYPTO_add(&peer->references, 1, CRYPTO_LOCK_EVP_PKEY); return 1; } int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *pkeylen) { if (!ctx || !ctx->pmeth || !ctx->pmeth->derive) { EVPerr(EVP_F_EVP_PKEY_DERIVE, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); return -2; } if (ctx->operation != EVP_PKEY_OP_DERIVE) { EVPerr(EVP_F_EVP_PKEY_DERIVE, EVP_R_OPERATON_NOT_INITIALIZED); return -1; } M_check_autoarg(ctx, key, pkeylen, EVP_F_EVP_PKEY_DERIVE) return ctx->pmeth->derive(ctx, key, pkeylen); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/e_rc2.c0000644000175000017500000001605412360020705020211 0ustar /* $OpenBSD: e_rc2.c,v 1.9 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #ifndef OPENSSL_NO_RC2 #include #include #include #include #include "evp_locl.h" static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); static int rc2_meth_to_magic(EVP_CIPHER_CTX *ctx); static int rc2_magic_to_meth(int i); static int rc2_set_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type); static int rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type); static int rc2_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr); typedef struct { int key_bits; /* effective key bits */ RC2_KEY ks; /* key schedule */ } EVP_RC2_KEY; #define data(ctx) ((EVP_RC2_KEY *)(ctx)->cipher_data) IMPLEMENT_BLOCK_CIPHER(rc2, ks, RC2, EVP_RC2_KEY, NID_rc2, 8, RC2_KEY_LENGTH, 8, 64, EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, rc2_init_key, NULL, rc2_set_asn1_type_and_iv, rc2_get_asn1_type_and_iv, rc2_ctrl) #define RC2_40_MAGIC 0xa0 #define RC2_64_MAGIC 0x78 #define RC2_128_MAGIC 0x3a static const EVP_CIPHER r2_64_cbc_cipher = { NID_rc2_64_cbc, 8, 8 /* 64 bit */, 8, EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, rc2_init_key, rc2_cbc_cipher, NULL, sizeof(EVP_RC2_KEY), rc2_set_asn1_type_and_iv, rc2_get_asn1_type_and_iv, rc2_ctrl, NULL }; static const EVP_CIPHER r2_40_cbc_cipher = { NID_rc2_40_cbc, 8, 5 /* 40 bit */, 8, EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, rc2_init_key, rc2_cbc_cipher, NULL, sizeof(EVP_RC2_KEY), rc2_set_asn1_type_and_iv, rc2_get_asn1_type_and_iv, rc2_ctrl, NULL }; const EVP_CIPHER * EVP_rc2_64_cbc(void) { return (&r2_64_cbc_cipher); } const EVP_CIPHER * EVP_rc2_40_cbc(void) { return (&r2_40_cbc_cipher); } static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { RC2_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx), key, data(ctx)->key_bits); return 1; } static int rc2_meth_to_magic(EVP_CIPHER_CTX *e) { int i; EVP_CIPHER_CTX_ctrl(e, EVP_CTRL_GET_RC2_KEY_BITS, 0, &i); if (i == 128) return (RC2_128_MAGIC); else if (i == 64) return (RC2_64_MAGIC); else if (i == 40) return (RC2_40_MAGIC); else return (0); } static int rc2_magic_to_meth(int i) { if (i == RC2_128_MAGIC) return 128; else if (i == RC2_64_MAGIC) return 64; else if (i == RC2_40_MAGIC) return 40; else { EVPerr(EVP_F_RC2_MAGIC_TO_METH, EVP_R_UNSUPPORTED_KEY_SIZE); return (0); } } static int rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) { long num = 0; int i = 0; int key_bits; unsigned int l; unsigned char iv[EVP_MAX_IV_LENGTH]; if (type != NULL) { l = EVP_CIPHER_CTX_iv_length(c); OPENSSL_assert(l <= sizeof(iv)); i = ASN1_TYPE_get_int_octetstring(type, &num, iv, l); if (i != (int)l) return (-1); key_bits = rc2_magic_to_meth((int)num); if (!key_bits) return (-1); if (i > 0 && !EVP_CipherInit_ex(c, NULL, NULL, NULL, iv, -1)) return -1; EVP_CIPHER_CTX_ctrl(c, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL); EVP_CIPHER_CTX_set_key_length(c, key_bits / 8); } return (i); } static int rc2_set_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) { long num; int i = 0, j; if (type != NULL) { num = rc2_meth_to_magic(c); j = EVP_CIPHER_CTX_iv_length(c); i = ASN1_TYPE_set_int_octetstring(type, num, c->oiv, j); } return (i); } static int rc2_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) { switch (type) { case EVP_CTRL_INIT: data(c)->key_bits = EVP_CIPHER_CTX_key_length(c) * 8; return 1; case EVP_CTRL_GET_RC2_KEY_BITS: *(int *)ptr = data(c)->key_bits; return 1; case EVP_CTRL_SET_RC2_KEY_BITS: if (arg > 0) { data(c)->key_bits = arg; return 1; } return 0; #ifdef PBE_PRF_TEST case EVP_CTRL_PBE_PRF_NID: *(int *)ptr = NID_hmacWithMD5; return 1; #endif default: return -1; } } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/m_wp.c0000644000175000017500000000201412360020705020150 0ustar /* $OpenBSD: m_wp.c,v 1.6 2014/07/10 22:45:57 jsing Exp $ */ #include #include #ifndef OPENSSL_NO_WHIRLPOOL #include #include #include #include #include "evp_locl.h" static int init(EVP_MD_CTX *ctx) { return WHIRLPOOL_Init(ctx->md_data); } static int update(EVP_MD_CTX *ctx, const void *data, size_t count) { return WHIRLPOOL_Update(ctx->md_data, data, count); } static int final(EVP_MD_CTX *ctx, unsigned char *md) { return WHIRLPOOL_Final(md, ctx->md_data); } static const EVP_MD whirlpool_md = { .type = NID_whirlpool, .pkey_type = 0, .md_size = WHIRLPOOL_DIGEST_LENGTH, .flags = 0, .init = init, .update = update, .final = final, .copy = NULL, .cleanup = NULL, .sign = NULL, .verify = NULL, .required_pkey_type = { 0, 0, 0, 0, }, .block_size = WHIRLPOOL_BBLOCK / 8, .ctx_size = sizeof(EVP_MD *) + sizeof(WHIRLPOOL_CTX), }; const EVP_MD * EVP_whirlpool(void) { return (&whirlpool_md); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/evp_pkey.c0000644000175000017500000001461312360020705021040 0ustar /* $OpenBSD: evp_pkey.c,v 1.15 2014/06/12 15:49:29 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include "asn1_locl.h" /* Extract a private key from a PKCS8 structure */ EVP_PKEY * EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8) { EVP_PKEY *pkey = NULL; ASN1_OBJECT *algoid; char obj_tmp[80]; if (!PKCS8_pkey_get0(&algoid, NULL, NULL, NULL, p8)) return NULL; if (!(pkey = EVP_PKEY_new())) { EVPerr(EVP_F_EVP_PKCS82PKEY, ERR_R_MALLOC_FAILURE); return NULL; } if (!EVP_PKEY_set_type(pkey, OBJ_obj2nid(algoid))) { EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM); i2t_ASN1_OBJECT(obj_tmp, 80, algoid); ERR_asprintf_error_data("TYPE=%s", obj_tmp); goto error; } if (pkey->ameth->priv_decode) { if (!pkey->ameth->priv_decode(pkey, p8)) { EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_PRIVATE_KEY_DECODE_ERROR); goto error; } } else { EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_METHOD_NOT_SUPPORTED); goto error; } return pkey; error: EVP_PKEY_free (pkey); return NULL; } PKCS8_PRIV_KEY_INFO * EVP_PKEY2PKCS8(EVP_PKEY *pkey) { return EVP_PKEY2PKCS8_broken(pkey, PKCS8_OK); } /* Turn a private key into a PKCS8 structure */ PKCS8_PRIV_KEY_INFO * EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken) { PKCS8_PRIV_KEY_INFO *p8; if (!(p8 = PKCS8_PRIV_KEY_INFO_new())) { EVPerr(EVP_F_EVP_PKEY2PKCS8_BROKEN, ERR_R_MALLOC_FAILURE); return NULL; } p8->broken = broken; if (pkey->ameth) { if (pkey->ameth->priv_encode) { if (!pkey->ameth->priv_encode(p8, pkey)) { EVPerr(EVP_F_EVP_PKEY2PKCS8_BROKEN, EVP_R_PRIVATE_KEY_ENCODE_ERROR); goto error; } } else { EVPerr(EVP_F_EVP_PKEY2PKCS8_BROKEN, EVP_R_METHOD_NOT_SUPPORTED); goto error; } } else { EVPerr(EVP_F_EVP_PKEY2PKCS8_BROKEN, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM); goto error; } return p8; error: PKCS8_PRIV_KEY_INFO_free(p8); return NULL; } PKCS8_PRIV_KEY_INFO * PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken) { switch (broken) { case PKCS8_OK: p8->broken = PKCS8_OK; return p8; break; case PKCS8_NO_OCTET: p8->broken = PKCS8_NO_OCTET; p8->pkey->type = V_ASN1_SEQUENCE; return p8; break; default: EVPerr(EVP_F_PKCS8_SET_BROKEN, EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE); return NULL; } } /* EVP_PKEY attribute functions */ int EVP_PKEY_get_attr_count(const EVP_PKEY *key) { return X509at_get_attr_count(key->attributes); } int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos) { return X509at_get_attr_by_NID(key->attributes, nid, lastpos); } int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj, int lastpos) { return X509at_get_attr_by_OBJ(key->attributes, obj, lastpos); } X509_ATTRIBUTE * EVP_PKEY_get_attr(const EVP_PKEY *key, int loc) { return X509at_get_attr(key->attributes, loc); } X509_ATTRIBUTE * EVP_PKEY_delete_attr(EVP_PKEY *key, int loc) { return X509at_delete_attr(key->attributes, loc); } int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr) { if (X509at_add1_attr(&key->attributes, attr)) return 1; return 0; } int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key, const ASN1_OBJECT *obj, int type, const unsigned char *bytes, int len) { if (X509at_add1_attr_by_OBJ(&key->attributes, obj, type, bytes, len)) return 1; return 0; } int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key, int nid, int type, const unsigned char *bytes, int len) { if (X509at_add1_attr_by_NID(&key->attributes, nid, type, bytes, len)) return 1; return 0; } int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key, const char *attrname, int type, const unsigned char *bytes, int len) { if (X509at_add1_attr_by_txt(&key->attributes, attrname, type, bytes, len)) return 1; return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/m_mdc2.c0000644000175000017500000001037312360020705020356 0ustar /* $OpenBSD: m_mdc2.c,v 1.13 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #ifndef OPENSSL_NO_MDC2 #include #include #include #include #ifndef OPENSSL_NO_RSA #include #endif #include "evp_locl.h" static int init(EVP_MD_CTX *ctx) { return MDC2_Init(ctx->md_data); } static int update(EVP_MD_CTX *ctx, const void *data, size_t count) { return MDC2_Update(ctx->md_data, data, count); } static int final(EVP_MD_CTX *ctx, unsigned char *md) { return MDC2_Final(md, ctx->md_data); } static const EVP_MD mdc2_md = { .type = NID_mdc2, .pkey_type = NID_mdc2WithRSA, .md_size = MDC2_DIGEST_LENGTH, .flags = 0, .init = init, .update = update, .final = final, .copy = NULL, .cleanup = NULL, #ifndef OPENSSL_NO_RSA .sign = (evp_sign_method *)RSA_sign_ASN1_OCTET_STRING, .verify = (evp_verify_method *)RSA_verify_ASN1_OCTET_STRING, .required_pkey_type = { EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, }, #endif .block_size = MDC2_BLOCK, .ctx_size = sizeof(EVP_MD *) + sizeof(MDC2_CTX), }; const EVP_MD * EVP_mdc2(void) { return (&mdc2_md); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/e_rc4.c0000644000175000017500000001111512360020705020204 0ustar /* $OpenBSD: e_rc4.c,v 1.13 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #ifndef OPENSSL_NO_RC4 #include #include #include #include "evp_locl.h" /* FIXME: surely this is available elsewhere? */ #define EVP_RC4_KEY_SIZE 16 typedef struct { RC4_KEY ks; /* working key */ } EVP_RC4_KEY; #define data(ctx) ((EVP_RC4_KEY *)(ctx)->cipher_data) static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl); static const EVP_CIPHER r4_cipher = { NID_rc4, 1, EVP_RC4_KEY_SIZE, 0, EVP_CIPH_VARIABLE_LENGTH, rc4_init_key, rc4_cipher, NULL, sizeof(EVP_RC4_KEY), NULL, NULL, NULL, NULL }; static const EVP_CIPHER r4_40_cipher = { NID_rc4_40, 1, 5 /* 40 bit */, 0, EVP_CIPH_VARIABLE_LENGTH, rc4_init_key, rc4_cipher, NULL, sizeof(EVP_RC4_KEY), NULL, NULL, NULL, NULL }; const EVP_CIPHER * EVP_rc4(void) { return (&r4_cipher); } const EVP_CIPHER * EVP_rc4_40(void) { return (&r4_40_cipher); } static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { RC4_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx), key); return 1; } static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { RC4(&data(ctx)->ks, inl, in, out); return 1; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/m_ripemd.c0000644000175000017500000001042512360020705021007 0ustar /* $OpenBSD: m_ripemd.c,v 1.10 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #ifndef OPENSSL_NO_RIPEMD #include #include #include #include #ifndef OPENSSL_NO_RSA #include #endif #include "evp_locl.h" static int init(EVP_MD_CTX *ctx) { return RIPEMD160_Init(ctx->md_data); } static int update(EVP_MD_CTX *ctx, const void *data, size_t count) { return RIPEMD160_Update(ctx->md_data, data, count); } static int final(EVP_MD_CTX *ctx, unsigned char *md) { return RIPEMD160_Final(md, ctx->md_data); } static const EVP_MD ripemd160_md = { .type = NID_ripemd160, .pkey_type = NID_ripemd160WithRSA, .md_size = RIPEMD160_DIGEST_LENGTH, .flags = 0, .init = init, .update = update, .final = final, .copy = NULL, .cleanup = NULL, #ifndef OPENSSL_NO_RSA .sign = (evp_sign_method *)RSA_sign, .verify = (evp_verify_method *)RSA_verify, .required_pkey_type = { EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, }, #endif .block_size = RIPEMD160_CBLOCK, .ctx_size = sizeof(EVP_MD *) + sizeof(RIPEMD160_CTX), }; const EVP_MD * EVP_ripemd160(void) { return (&ripemd160_md); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/e_aes_cbc_hmac_sha1.c0000644000175000017500000004000612360020705023000 0ustar /* $OpenBSD: e_aes_cbc_hmac_sha1.c,v 1.6 2014/06/12 15:49:29 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 2011-2013 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== */ #include #include #include #if !defined(OPENSSL_NO_AES) && !defined(OPENSSL_NO_SHA1) #include #include #include #include #include "evp_locl.h" #ifndef EVP_CIPH_FLAG_AEAD_CIPHER #define EVP_CIPH_FLAG_AEAD_CIPHER 0x200000 #define EVP_CTRL_AEAD_TLS1_AAD 0x16 #define EVP_CTRL_AEAD_SET_MAC_KEY 0x17 #endif #if !defined(EVP_CIPH_FLAG_DEFAULT_ASN1) #define EVP_CIPH_FLAG_DEFAULT_ASN1 0 #endif #define TLS1_1_VERSION 0x0302 typedef struct { AES_KEY ks; SHA_CTX head, tail, md; size_t payload_length; /* AAD length in decrypt case */ union { unsigned int tls_ver; unsigned char tls_aad[16]; /* 13 used */ } aux; } EVP_AES_HMAC_SHA1; #define NO_PAYLOAD_LENGTH ((size_t)-1) #if defined(AES_ASM) && ( \ defined(__x86_64) || defined(__x86_64__) || \ defined(_M_AMD64) || defined(_M_X64) || \ defined(__INTEL__) ) #if defined(__GNUC__) && __GNUC__>=2 # define BSWAP(x) ({ unsigned int r=(x); asm ("bswapl %0":"=r"(r):"0"(r)); r; }) #endif extern unsigned int OPENSSL_ia32cap_P[2]; #define AESNI_CAPABLE (1<<(57-32)) int aesni_set_encrypt_key(const unsigned char *userKey, int bits, AES_KEY *key); int aesni_set_decrypt_key(const unsigned char *userKey, int bits, AES_KEY *key); void aesni_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key, unsigned char *ivec, int enc); void aesni_cbc_sha1_enc (const void *inp, void *out, size_t blocks, const AES_KEY *key, unsigned char iv[16], SHA_CTX *ctx, const void *in0); #define data(ctx) ((EVP_AES_HMAC_SHA1 *)(ctx)->cipher_data) static int aesni_cbc_hmac_sha1_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *inkey, const unsigned char *iv, int enc) { EVP_AES_HMAC_SHA1 *key = data(ctx); int ret; if (enc) ret = aesni_set_encrypt_key(inkey, ctx->key_len * 8, &key->ks); else ret = aesni_set_decrypt_key(inkey, ctx->key_len * 8, &key->ks); SHA1_Init(&key->head); /* handy when benchmarking */ key->tail = key->head; key->md = key->head; key->payload_length = NO_PAYLOAD_LENGTH; return ret < 0 ? 0 : 1; } #define STITCHED_CALL #if !defined(STITCHED_CALL) #define aes_off 0 #endif void sha1_block_data_order (void *c, const void *p, size_t len); static void sha1_update(SHA_CTX *c, const void *data, size_t len) { const unsigned char *ptr = data; size_t res; if ((res = c->num)) { res = SHA_CBLOCK - res; if (len < res) res = len; SHA1_Update(c, ptr, res); ptr += res; len -= res; } res = len % SHA_CBLOCK; len -= res; if (len) { sha1_block_data_order(c, ptr, len / SHA_CBLOCK); ptr += len; c->Nh += len >> 29; c->Nl += len <<= 3; if (c->Nl < (unsigned int)len) c->Nh++; } if (res) SHA1_Update(c, ptr, res); } #ifdef SHA1_Update #undef SHA1_Update #endif #define SHA1_Update sha1_update static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { EVP_AES_HMAC_SHA1 *key = data(ctx); unsigned int l; size_t plen = key->payload_length, iv = 0, /* explicit IV in TLS 1.1 and later */ sha_off = 0; #if defined(STITCHED_CALL) size_t aes_off = 0, blocks; sha_off = SHA_CBLOCK - key->md.num; #endif key->payload_length = NO_PAYLOAD_LENGTH; if (len % AES_BLOCK_SIZE) return 0; if (ctx->encrypt) { if (plen == NO_PAYLOAD_LENGTH) plen = len; else if (len != ((plen + SHA_DIGEST_LENGTH + AES_BLOCK_SIZE) & -AES_BLOCK_SIZE)) return 0; else if (key->aux.tls_ver >= TLS1_1_VERSION) iv = AES_BLOCK_SIZE; #if defined(STITCHED_CALL) if (plen > (sha_off + iv) && (blocks = (plen - (sha_off + iv)) / SHA_CBLOCK)) { SHA1_Update(&key->md, in + iv, sha_off); aesni_cbc_sha1_enc(in, out, blocks, &key->ks, ctx->iv, &key->md, in + iv + sha_off); blocks *= SHA_CBLOCK; aes_off += blocks; sha_off += blocks; key->md.Nh += blocks >> 29; key->md.Nl += blocks <<= 3; if (key->md.Nl < (unsigned int)blocks) key->md.Nh++; } else { sha_off = 0; } #endif sha_off += iv; SHA1_Update(&key->md, in + sha_off, plen - sha_off); if (plen != len) { /* "TLS" mode of operation */ if (in != out) memcpy(out + aes_off, in + aes_off, plen - aes_off); /* calculate HMAC and append it to payload */ SHA1_Final(out + plen, &key->md); key->md = key->tail; SHA1_Update(&key->md, out + plen, SHA_DIGEST_LENGTH); SHA1_Final(out + plen, &key->md); /* pad the payload|hmac */ plen += SHA_DIGEST_LENGTH; for (l = len - plen - 1; plen < len; plen++) out[plen] = l; /* encrypt HMAC|padding at once */ aesni_cbc_encrypt(out + aes_off, out + aes_off, len - aes_off, &key->ks, ctx->iv, 1); } else { aesni_cbc_encrypt(in + aes_off, out + aes_off, len - aes_off, &key->ks, ctx->iv, 1); } } else { union { unsigned int u[SHA_DIGEST_LENGTH/sizeof(unsigned int)]; unsigned char c[32 + SHA_DIGEST_LENGTH]; } mac, *pmac; /* arrange cache line alignment */ pmac = (void *)(((size_t)mac.c + 31) & ((size_t)0 - 32)); /* decrypt HMAC|padding at once */ aesni_cbc_encrypt(in, out, len, &key->ks, ctx->iv, 0); if (plen) { /* "TLS" mode of operation */ size_t inp_len, mask, j, i; unsigned int res, maxpad, pad, bitlen; int ret = 1; union { unsigned int u[SHA_LBLOCK]; unsigned char c[SHA_CBLOCK]; } *data = (void *)key->md.data; if ((key->aux.tls_aad[plen - 4] << 8 | key->aux.tls_aad[plen - 3]) >= TLS1_1_VERSION) iv = AES_BLOCK_SIZE; if (len < (iv + SHA_DIGEST_LENGTH + 1)) return 0; /* omit explicit iv */ out += iv; len -= iv; /* figure out payload length */ pad = out[len - 1]; maxpad = len - (SHA_DIGEST_LENGTH + 1); maxpad |= (255 - maxpad) >> (sizeof(maxpad) * 8 - 8); maxpad &= 255; inp_len = len - (SHA_DIGEST_LENGTH + pad + 1); mask = (0 - ((inp_len - len) >> (sizeof(inp_len) * 8 - 1))); inp_len &= mask; ret &= (int)mask; key->aux.tls_aad[plen - 2] = inp_len >> 8; key->aux.tls_aad[plen - 1] = inp_len; /* calculate HMAC */ key->md = key->head; SHA1_Update(&key->md, key->aux.tls_aad, plen); #if 1 len -= SHA_DIGEST_LENGTH; /* amend mac */ if (len >= (256 + SHA_CBLOCK)) { j = (len - (256 + SHA_CBLOCK)) & (0 - SHA_CBLOCK); j += SHA_CBLOCK - key->md.num; SHA1_Update(&key->md, out, j); out += j; len -= j; inp_len -= j; } /* but pretend as if we hashed padded payload */ bitlen = key->md.Nl + (inp_len << 3); /* at most 18 bits */ #ifdef BSWAP bitlen = BSWAP(bitlen); #else mac.c[0] = 0; mac.c[1] = (unsigned char)(bitlen >> 16); mac.c[2] = (unsigned char)(bitlen >> 8); mac.c[3] = (unsigned char)bitlen; bitlen = mac.u[0]; #endif pmac->u[0] = 0; pmac->u[1] = 0; pmac->u[2] = 0; pmac->u[3] = 0; pmac->u[4] = 0; for (res = key->md.num, j = 0; j < len; j++) { size_t c = out[j]; mask = (j - inp_len) >> (sizeof(j) * 8 - 8); c &= mask; c |= 0x80 & ~mask & ~((inp_len - j) >> (sizeof(j) * 8 - 8)); data->c[res++] = (unsigned char)c; if (res != SHA_CBLOCK) continue; /* j is not incremented yet */ mask = 0 - ((inp_len + 7 - j) >> (sizeof(j) * 8 - 1)); data->u[SHA_LBLOCK - 1] |= bitlen&mask; sha1_block_data_order(&key->md, data, 1); mask &= 0 - ((j - inp_len - 72) >> (sizeof(j) * 8 - 1)); pmac->u[0] |= key->md.h0 & mask; pmac->u[1] |= key->md.h1 & mask; pmac->u[2] |= key->md.h2 & mask; pmac->u[3] |= key->md.h3 & mask; pmac->u[4] |= key->md.h4 & mask; res = 0; } for (i = res; i < SHA_CBLOCK; i++, j++) data->c[i] = 0; if (res > SHA_CBLOCK - 8) { mask = 0 - ((inp_len + 8 - j) >> (sizeof(j) * 8 - 1)); data->u[SHA_LBLOCK - 1] |= bitlen & mask; sha1_block_data_order(&key->md, data, 1); mask &= 0 - ((j - inp_len - 73) >> (sizeof(j) * 8 - 1)); pmac->u[0] |= key->md.h0 & mask; pmac->u[1] |= key->md.h1 & mask; pmac->u[2] |= key->md.h2 & mask; pmac->u[3] |= key->md.h3 & mask; pmac->u[4] |= key->md.h4 & mask; memset(data, 0, SHA_CBLOCK); j += 64; } data->u[SHA_LBLOCK - 1] = bitlen; sha1_block_data_order(&key->md, data, 1); mask = 0 - ((j - inp_len - 73) >> (sizeof(j) * 8 - 1)); pmac->u[0] |= key->md.h0 & mask; pmac->u[1] |= key->md.h1 & mask; pmac->u[2] |= key->md.h2 & mask; pmac->u[3] |= key->md.h3 & mask; pmac->u[4] |= key->md.h4 & mask; #ifdef BSWAP pmac->u[0] = BSWAP(pmac->u[0]); pmac->u[1] = BSWAP(pmac->u[1]); pmac->u[2] = BSWAP(pmac->u[2]); pmac->u[3] = BSWAP(pmac->u[3]); pmac->u[4] = BSWAP(pmac->u[4]); #else for (i = 0; i < 5; i++) { res = pmac->u[i]; pmac->c[4 * i + 0] = (unsigned char)(res >> 24); pmac->c[4 * i + 1] = (unsigned char)(res >> 16); pmac->c[4 * i + 2] = (unsigned char)(res >> 8); pmac->c[4 * i + 3] = (unsigned char)res; } #endif len += SHA_DIGEST_LENGTH; #else SHA1_Update(&key->md, out, inp_len); res = key->md.num; SHA1_Final(pmac->c, &key->md); { unsigned int inp_blocks, pad_blocks; /* but pretend as if we hashed padded payload */ inp_blocks = 1 + ((SHA_CBLOCK - 9 - res) >> (sizeof(res) * 8 - 1)); res += (unsigned int)(len - inp_len); pad_blocks = res / SHA_CBLOCK; res %= SHA_CBLOCK; pad_blocks += 1 + ((SHA_CBLOCK - 9 - res) >> (sizeof(res) * 8 - 1)); for (; inp_blocks < pad_blocks; inp_blocks++) sha1_block_data_order(&key->md, data, 1); } #endif key->md = key->tail; SHA1_Update(&key->md, pmac->c, SHA_DIGEST_LENGTH); SHA1_Final(pmac->c, &key->md); /* verify HMAC */ out += inp_len; len -= inp_len; #if 1 { unsigned char *p = out + len - 1 - maxpad - SHA_DIGEST_LENGTH; size_t off = out - p; unsigned int c, cmask; maxpad += SHA_DIGEST_LENGTH; for (res = 0, i = 0, j = 0; j < maxpad; j++) { c = p[j]; cmask = ((int)(j - off - SHA_DIGEST_LENGTH)) >> (sizeof(int) * 8 - 1); res |= (c ^ pad) & ~cmask; /* ... and padding */ cmask &= ((int)(off - 1 - j)) >> (sizeof(int) * 8 - 1); res |= (c ^ pmac->c[i]) & cmask; i += 1 & cmask; } maxpad -= SHA_DIGEST_LENGTH; res = 0 - ((0 - res) >> (sizeof(res) * 8 - 1)); ret &= (int)~res; } #else for (res = 0, i = 0; i < SHA_DIGEST_LENGTH; i++) res |= out[i] ^ pmac->c[i]; res = 0 - ((0 - res) >> (sizeof(res) * 8 - 1)); ret &= (int)~res; /* verify padding */ pad = (pad & ~res) | (maxpad & res); out = out + len - 1 - pad; for (res = 0, i = 0; i < pad; i++) res |= out[i] ^ pad; res = (0 - res) >> (sizeof(res) * 8 - 1); ret &= (int)~res; #endif return ret; } else { SHA1_Update(&key->md, out, len); } } return 1; } static int aesni_cbc_hmac_sha1_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) { EVP_AES_HMAC_SHA1 *key = data(ctx); switch (type) { case EVP_CTRL_AEAD_SET_MAC_KEY: { unsigned int i; unsigned char hmac_key[64]; memset (hmac_key, 0, sizeof(hmac_key)); if (arg > (int)sizeof(hmac_key)) { SHA1_Init(&key->head); SHA1_Update(&key->head, ptr, arg); SHA1_Final(hmac_key, &key->head); } else { memcpy(hmac_key, ptr, arg); } for (i = 0; i < sizeof(hmac_key); i++) hmac_key[i] ^= 0x36; /* ipad */ SHA1_Init(&key->head); SHA1_Update(&key->head, hmac_key, sizeof(hmac_key)); for (i = 0; i < sizeof(hmac_key); i++) hmac_key[i] ^= 0x36 ^ 0x5c; /* opad */ SHA1_Init(&key->tail); SHA1_Update(&key->tail, hmac_key, sizeof(hmac_key)); OPENSSL_cleanse(hmac_key, sizeof(hmac_key)); return 1; } case EVP_CTRL_AEAD_TLS1_AAD: { unsigned char *p = ptr; unsigned int len = p[arg - 2] << 8 | p[arg - 1]; if (ctx->encrypt) { key->payload_length = len; if ((key->aux.tls_ver = p[arg - 4] << 8 | p[arg - 3]) >= TLS1_1_VERSION) { len -= AES_BLOCK_SIZE; p[arg - 2] = len >> 8; p[arg - 1] = len; } key->md = key->head; SHA1_Update(&key->md, p, arg); return (int)(((len + SHA_DIGEST_LENGTH + AES_BLOCK_SIZE) & -AES_BLOCK_SIZE) - len); } else { if (arg > 13) arg = 13; memcpy(key->aux.tls_aad, ptr, arg); key->payload_length = arg; return SHA_DIGEST_LENGTH; } } default: return -1; } } static EVP_CIPHER aesni_128_cbc_hmac_sha1_cipher = { #ifdef NID_aes_128_cbc_hmac_sha1 NID_aes_128_cbc_hmac_sha1, #else NID_undef, #endif 16, 16, 16, EVP_CIPH_CBC_MODE|EVP_CIPH_FLAG_DEFAULT_ASN1|EVP_CIPH_FLAG_AEAD_CIPHER, aesni_cbc_hmac_sha1_init_key, aesni_cbc_hmac_sha1_cipher, NULL, sizeof(EVP_AES_HMAC_SHA1), EVP_CIPH_FLAG_DEFAULT_ASN1 ? NULL : EVP_CIPHER_set_asn1_iv, EVP_CIPH_FLAG_DEFAULT_ASN1 ? NULL : EVP_CIPHER_get_asn1_iv, aesni_cbc_hmac_sha1_ctrl, NULL }; static EVP_CIPHER aesni_256_cbc_hmac_sha1_cipher = { #ifdef NID_aes_256_cbc_hmac_sha1 NID_aes_256_cbc_hmac_sha1, #else NID_undef, #endif 16, 32, 16, EVP_CIPH_CBC_MODE|EVP_CIPH_FLAG_DEFAULT_ASN1|EVP_CIPH_FLAG_AEAD_CIPHER, aesni_cbc_hmac_sha1_init_key, aesni_cbc_hmac_sha1_cipher, NULL, sizeof(EVP_AES_HMAC_SHA1), EVP_CIPH_FLAG_DEFAULT_ASN1 ? NULL : EVP_CIPHER_set_asn1_iv, EVP_CIPH_FLAG_DEFAULT_ASN1 ? NULL : EVP_CIPHER_get_asn1_iv, aesni_cbc_hmac_sha1_ctrl, NULL }; const EVP_CIPHER * EVP_aes_128_cbc_hmac_sha1(void) { return(OPENSSL_ia32cap_P[1] & AESNI_CAPABLE? &aesni_128_cbc_hmac_sha1_cipher : NULL); } const EVP_CIPHER * EVP_aes_256_cbc_hmac_sha1(void) { return(OPENSSL_ia32cap_P[1] & AESNI_CAPABLE? &aesni_256_cbc_hmac_sha1_cipher : NULL); } #else const EVP_CIPHER * EVP_aes_128_cbc_hmac_sha1(void) { return NULL; } const EVP_CIPHER * EVP_aes_256_cbc_hmac_sha1(void) { return NULL; } #endif #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/e_des.c0000644000175000017500000001667512360020705020307 0ustar /* $OpenBSD: e_des.c,v 1.10 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #ifndef OPENSSL_NO_DES #include #include #include #include #include "evp_locl.h" static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); static int des_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr); /* Because of various casts and different names can't use IMPLEMENT_BLOCK_CIPHER */ static int des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { BLOCK_CIPHER_ecb_loop() DES_ecb_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i), ctx->cipher_data, ctx->encrypt); return 1; } static int des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while (inl >= EVP_MAXCHUNK) { DES_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK, ctx->cipher_data, (DES_cblock *)ctx->iv, &ctx->num); inl -= EVP_MAXCHUNK; in += EVP_MAXCHUNK; out += EVP_MAXCHUNK; } if (inl) DES_ofb64_encrypt(in, out, (long)inl, ctx->cipher_data, (DES_cblock *)ctx->iv, &ctx->num); return 1; } static int des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while (inl >= EVP_MAXCHUNK) { DES_ncbc_encrypt(in, out, (long)EVP_MAXCHUNK, ctx->cipher_data, (DES_cblock *)ctx->iv, ctx->encrypt); inl -= EVP_MAXCHUNK; in += EVP_MAXCHUNK; out += EVP_MAXCHUNK; } if (inl) DES_ncbc_encrypt(in, out, (long)inl, ctx->cipher_data, (DES_cblock *)ctx->iv, ctx->encrypt); return 1; } static int des_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while (inl >= EVP_MAXCHUNK) { DES_cfb64_encrypt(in, out, (long)EVP_MAXCHUNK, ctx->cipher_data, (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt); inl -= EVP_MAXCHUNK; in += EVP_MAXCHUNK; out += EVP_MAXCHUNK; } if (inl) DES_cfb64_encrypt(in, out, (long)inl, ctx->cipher_data, (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt); return 1; } /* Although we have a CFB-r implementation for DES, it doesn't pack the right way, so wrap it here */ static int des_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { size_t n, chunk = EVP_MAXCHUNK/8; unsigned char c[1], d[1]; if (inl < chunk) chunk = inl; while (inl && inl >= chunk) { for (n = 0; n < chunk*8; ++n) { c[0] = (in[n / 8] & (1 << (7 - n % 8))) ? 0x80 : 0; DES_cfb_encrypt(c, d, 1, 1, ctx->cipher_data, (DES_cblock *)ctx->iv, ctx->encrypt); out[n / 8] = (out[n / 8] & ~(0x80 >> (unsigned int)(n % 8))) | ((d[0] & 0x80) >> (unsigned int)(n % 8)); } inl -= chunk; in += chunk; out += chunk; if (inl < chunk) chunk = inl; } return 1; } static int des_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { while (inl >= EVP_MAXCHUNK) { DES_cfb_encrypt(in, out, 8, (long)EVP_MAXCHUNK, ctx->cipher_data, (DES_cblock *)ctx->iv, ctx->encrypt); inl -= EVP_MAXCHUNK; in += EVP_MAXCHUNK; out += EVP_MAXCHUNK; } if (inl) DES_cfb_encrypt(in, out, 8, (long)inl, ctx->cipher_data, (DES_cblock *)ctx->iv, ctx->encrypt); return 1; } BLOCK_CIPHER_defs(des, DES_key_schedule, NID_des, 8, 8, 8, 64, EVP_CIPH_RAND_KEY, des_init_key, NULL, EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des_ctrl) BLOCK_CIPHER_def_cfb(des, DES_key_schedule, NID_des, 8, 8, 1, EVP_CIPH_RAND_KEY, des_init_key, NULL, EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des_ctrl) BLOCK_CIPHER_def_cfb(des, DES_key_schedule, NID_des, 8, 8, 8, EVP_CIPH_RAND_KEY, des_init_key, NULL, EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, des_ctrl) static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { DES_cblock *deskey = (DES_cblock *)key; #ifdef EVP_CHECK_DES_KEY if (DES_set_key_checked(deskey, ctx->cipher_data) != 0) return 0; #else DES_set_key_unchecked(deskey, ctx->cipher_data); #endif return 1; } static int des_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) { switch (type) { case EVP_CTRL_RAND_KEY: if (RAND_bytes(ptr, 8) <= 0) return 0; DES_set_odd_parity((DES_cblock *)ptr); return 1; default: return -1; } } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/m_sha1.c0000644000175000017500000001736112360020705020371 0ustar /* $OpenBSD: m_sha1.c,v 1.16 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #ifndef OPENSSL_NO_SHA #include #include #include #ifndef OPENSSL_NO_RSA #include #endif static int init(EVP_MD_CTX *ctx) { return SHA1_Init(ctx->md_data); } static int update(EVP_MD_CTX *ctx, const void *data, size_t count) { return SHA1_Update(ctx->md_data, data, count); } static int final(EVP_MD_CTX *ctx, unsigned char *md) { return SHA1_Final(md, ctx->md_data); } static const EVP_MD sha1_md = { .type = NID_sha1, .pkey_type = NID_sha1WithRSAEncryption, .md_size = SHA_DIGEST_LENGTH, .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT, .init = init, .update = update, .final = final, .copy = NULL, .cleanup = NULL, #ifndef OPENSSL_NO_RSA .sign = (evp_sign_method *)RSA_sign, .verify = (evp_verify_method *)RSA_verify, .required_pkey_type = { EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, }, #endif .block_size = SHA_CBLOCK, .ctx_size = sizeof(EVP_MD *) + sizeof(SHA_CTX), }; const EVP_MD * EVP_sha1(void) { return (&sha1_md); } #endif #ifndef OPENSSL_NO_SHA256 static int init224(EVP_MD_CTX *ctx) { return SHA224_Init(ctx->md_data); } static int init256(EVP_MD_CTX *ctx) { return SHA256_Init(ctx->md_data); } /* * Even though there're separate SHA224_[Update|Final], we call * SHA256 functions even in SHA224 context. This is what happens * there anyway, so we can spare few CPU cycles:-) */ static int update256(EVP_MD_CTX *ctx, const void *data, size_t count) { return SHA256_Update(ctx->md_data, data, count); } static int final256(EVP_MD_CTX *ctx, unsigned char *md) { return SHA256_Final(md, ctx->md_data); } static const EVP_MD sha224_md = { .type = NID_sha224, .pkey_type = NID_sha224WithRSAEncryption, .md_size = SHA224_DIGEST_LENGTH, .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT, .init = init224, .update = update256, .final = final256, .copy = NULL, .cleanup = NULL, #ifndef OPENSSL_NO_RSA .sign = (evp_sign_method *)RSA_sign, .verify = (evp_verify_method *)RSA_verify, .required_pkey_type = { EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, }, #endif .block_size = SHA256_CBLOCK, .ctx_size = sizeof(EVP_MD *) + sizeof(SHA256_CTX), }; const EVP_MD * EVP_sha224(void) { return (&sha224_md); } static const EVP_MD sha256_md = { .type = NID_sha256, .pkey_type = NID_sha256WithRSAEncryption, .md_size = SHA256_DIGEST_LENGTH, .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT, .init = init256, .update = update256, .final = final256, .copy = NULL, .cleanup = NULL, #ifndef OPENSSL_NO_RSA .sign = (evp_sign_method *)RSA_sign, .verify = (evp_verify_method *)RSA_verify, .required_pkey_type = { EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, }, #endif .block_size = SHA256_CBLOCK, .ctx_size = sizeof(EVP_MD *) + sizeof(SHA256_CTX), }; const EVP_MD * EVP_sha256(void) { return (&sha256_md); } #endif /* ifndef OPENSSL_NO_SHA256 */ #ifndef OPENSSL_NO_SHA512 static int init384(EVP_MD_CTX *ctx) { return SHA384_Init(ctx->md_data); } static int init512(EVP_MD_CTX *ctx) { return SHA512_Init(ctx->md_data); } /* See comment in SHA224/256 section */ static int update512(EVP_MD_CTX *ctx, const void *data, size_t count) { return SHA512_Update(ctx->md_data, data, count); } static int final512(EVP_MD_CTX *ctx, unsigned char *md) { return SHA512_Final(md, ctx->md_data); } static const EVP_MD sha384_md = { .type = NID_sha384, .pkey_type = NID_sha384WithRSAEncryption, .md_size = SHA384_DIGEST_LENGTH, .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT, .init = init384, .update = update512, .final = final512, .copy = NULL, .cleanup = NULL, #ifndef OPENSSL_NO_RSA .sign = (evp_sign_method *)RSA_sign, .verify = (evp_verify_method *)RSA_verify, .required_pkey_type = { EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, }, #endif .block_size = SHA512_CBLOCK, .ctx_size = sizeof(EVP_MD *) + sizeof(SHA512_CTX), }; const EVP_MD * EVP_sha384(void) { return (&sha384_md); } static const EVP_MD sha512_md = { .type = NID_sha512, .pkey_type = NID_sha512WithRSAEncryption, .md_size = SHA512_DIGEST_LENGTH, .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT, .init = init512, .update = update512, .final = final512, .copy = NULL, .cleanup = NULL, #ifndef OPENSSL_NO_RSA .sign = (evp_sign_method *)RSA_sign, .verify = (evp_verify_method *)RSA_verify, .required_pkey_type = { EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, }, #endif .block_size = SHA512_CBLOCK, .ctx_size = sizeof(EVP_MD *) + sizeof(SHA512_CTX), }; const EVP_MD * EVP_sha512(void) { return (&sha512_md); } #endif /* ifndef OPENSSL_NO_SHA512 */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/bio_md.c0000644000175000017500000001556212360020705020453 0ustar /* $OpenBSD: bio_md.c,v 1.13 2014/06/12 15:49:29 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include /* BIO_put and BIO_get both add to the digest, * BIO_gets returns the digest */ static int md_write(BIO *h, char const *buf, int num); static int md_read(BIO *h, char *buf, int size); /*static int md_puts(BIO *h, const char *str); */ static int md_gets(BIO *h, char *str, int size); static long md_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int md_new(BIO *h); static int md_free(BIO *data); static long md_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); static BIO_METHOD methods_md = { .type = BIO_TYPE_MD, .name = "message digest", .bwrite = md_write, .bread = md_read, .bgets = md_gets, .ctrl = md_ctrl, .create = md_new, .destroy = md_free, .callback_ctrl = md_callback_ctrl }; BIO_METHOD * BIO_f_md(void) { return (&methods_md); } static int md_new(BIO *bi) { EVP_MD_CTX *ctx; ctx = EVP_MD_CTX_create(); if (ctx == NULL) return (0); bi->init = 0; bi->ptr = (char *)ctx; bi->flags = 0; return (1); } static int md_free(BIO *a) { if (a == NULL) return (0); EVP_MD_CTX_destroy(a->ptr); a->ptr = NULL; a->init = 0; a->flags = 0; return (1); } static int md_read(BIO *b, char *out, int outl) { int ret = 0; EVP_MD_CTX *ctx; if (out == NULL) return (0); ctx = b->ptr; if ((ctx == NULL) || (b->next_bio == NULL)) return (0); ret = BIO_read(b->next_bio, out, outl); if (b->init) { if (ret > 0) { if (EVP_DigestUpdate(ctx, (unsigned char *)out, (unsigned int)ret) <= 0) return (-1); } } BIO_clear_retry_flags(b); BIO_copy_next_retry(b); return (ret); } static int md_write(BIO *b, const char *in, int inl) { int ret = 0; EVP_MD_CTX *ctx; if ((in == NULL) || (inl <= 0)) return (0); ctx = b->ptr; if ((ctx != NULL) && (b->next_bio != NULL)) ret = BIO_write(b->next_bio, in, inl); if (b->init) { if (ret > 0) { if (!EVP_DigestUpdate(ctx, (const unsigned char *)in, (unsigned int)ret)) { BIO_clear_retry_flags(b); return 0; } } } if (b->next_bio != NULL) { BIO_clear_retry_flags(b); BIO_copy_next_retry(b); } return (ret); } static long md_ctrl(BIO *b, int cmd, long num, void *ptr) { EVP_MD_CTX *ctx, *dctx, **pctx; const EVP_MD **ppmd; EVP_MD *md; long ret = 1; BIO *dbio; ctx = b->ptr; switch (cmd) { case BIO_CTRL_RESET: if (b->init) ret = EVP_DigestInit_ex(ctx, ctx->digest, NULL); else ret = 0; if (ret > 0) ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; case BIO_C_GET_MD: if (b->init) { ppmd = ptr; *ppmd = ctx->digest; } else ret = 0; break; case BIO_C_GET_MD_CTX: pctx = ptr; *pctx = ctx; b->init = 1; break; case BIO_C_SET_MD_CTX: if (b->init) b->ptr = ptr; else ret = 0; break; case BIO_C_DO_STATE_MACHINE: BIO_clear_retry_flags(b); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); BIO_copy_next_retry(b); break; case BIO_C_SET_MD: md = ptr; ret = EVP_DigestInit_ex(ctx, md, NULL); if (ret > 0) b->init = 1; break; case BIO_CTRL_DUP: dbio = ptr; dctx = dbio->ptr; if (!EVP_MD_CTX_copy_ex(dctx, ctx)) return 0; b->init = 1; break; default: ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; } return (ret); } static long md_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) { long ret = 1; if (b->next_bio == NULL) return (0); switch (cmd) { default: ret = BIO_callback_ctrl(b->next_bio, cmd, fp); break; } return (ret); } static int md_gets(BIO *bp, char *buf, int size) { EVP_MD_CTX *ctx; unsigned int ret; ctx = bp->ptr; if (size < ctx->digest->md_size) return (0); if (EVP_DigestFinal_ex(ctx, (unsigned char *)buf, &ret) <= 0) return -1; return ((int)ret); } /* static int md_puts(bp,str) BIO *bp; char *str; { return(-1); } */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/p_open.c0000644000175000017500000001070112360020705020470 0ustar /* $OpenBSD: p_open.c,v 1.15 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #ifndef OPENSSL_NO_RSA #include #include #include #include #include int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, const unsigned char *ek, int ekl, const unsigned char *iv, EVP_PKEY *priv) { unsigned char *key = NULL; int i, size = 0, ret = 0; if (type) { EVP_CIPHER_CTX_init(ctx); if (!EVP_DecryptInit_ex(ctx, type, NULL, NULL, NULL)) return 0; } if (!priv) return 1; if (priv->type != EVP_PKEY_RSA) { EVPerr(EVP_F_EVP_OPENINIT, EVP_R_PUBLIC_KEY_NOT_RSA); goto err; } size = RSA_size(priv->pkey.rsa); key = malloc(size + 2); if (key == NULL) { /* ERROR */ EVPerr(EVP_F_EVP_OPENINIT, ERR_R_MALLOC_FAILURE); goto err; } i = EVP_PKEY_decrypt_old(key, ek, ekl, priv); if ((i <= 0) || !EVP_CIPHER_CTX_set_key_length(ctx, i)) { /* ERROR */ goto err; } if (!EVP_DecryptInit_ex(ctx, NULL, NULL, key, iv)) goto err; ret = 1; err: if (key != NULL) OPENSSL_cleanse(key, size); free(key); return (ret); } int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) { int i; i = EVP_DecryptFinal_ex(ctx, out, outl); if (i) i = EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, NULL); return (i); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/m_dss1.c0000644000175000017500000001033112360020705020375 0ustar /* $OpenBSD: m_dss1.c,v 1.15 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #ifndef OPENSSL_NO_SHA #include #include #include #ifndef OPENSSL_NO_DSA #include #endif static int init(EVP_MD_CTX *ctx) { return SHA1_Init(ctx->md_data); } static int update(EVP_MD_CTX *ctx, const void *data, size_t count) { return SHA1_Update(ctx->md_data, data, count); } static int final(EVP_MD_CTX *ctx, unsigned char *md) { return SHA1_Final(md, ctx->md_data); } static const EVP_MD dss1_md = { .type = NID_dsa, .pkey_type = NID_dsaWithSHA1, .md_size = SHA_DIGEST_LENGTH, .flags = EVP_MD_FLAG_PKEY_DIGEST, .init = init, .update = update, .final = final, .copy = NULL, .cleanup = NULL, #ifndef OPENSSL_NO_DSA .sign = (evp_sign_method *)DSA_sign, .verify = (evp_verify_method *)DSA_verify, .required_pkey_type = { EVP_PKEY_DSA, EVP_PKEY_DSA2, EVP_PKEY_DSA3, EVP_PKEY_DSA4, 0, }, #endif .block_size = SHA_CBLOCK, .ctx_size = sizeof(EVP_MD *) + sizeof(SHA_CTX), }; const EVP_MD * EVP_dss1(void) { return (&dss1_md); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/evp_key.c0000644000175000017500000001351412360020705020657 0ustar /* $OpenBSD: evp_key.c,v 1.17 2014/07/10 19:30:06 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include /* should be init to zeros. */ static char prompt_string[80]; void EVP_set_pw_prompt(const char *prompt) { if (prompt == NULL) prompt_string[0] = '\0'; else { strlcpy(prompt_string, prompt, sizeof(prompt_string)); } } char * EVP_get_pw_prompt(void) { if (prompt_string[0] == '\0') return (NULL); else return (prompt_string); } int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify) { return EVP_read_pw_string_min(buf, 0, len, prompt, verify); } int EVP_read_pw_string_min(char *buf, int min, int len, const char *prompt, int verify) { int ret; char buff[BUFSIZ]; UI *ui; if ((prompt == NULL) && (prompt_string[0] != '\0')) prompt = prompt_string; ui = UI_new(); UI_add_input_string(ui, prompt, 0, buf, min, (len >= BUFSIZ) ? BUFSIZ - 1 : len); if (verify) UI_add_verify_string(ui, prompt, 0, buff, min, (len >= BUFSIZ) ? BUFSIZ - 1 : len, buf); ret = UI_process(ui); UI_free(ui); OPENSSL_cleanse(buff, BUFSIZ); return ret; } int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, const unsigned char *salt, const unsigned char *data, int datal, int count, unsigned char *key, unsigned char *iv) { EVP_MD_CTX c; unsigned char md_buf[EVP_MAX_MD_SIZE]; int niv, nkey, addmd = 0; unsigned int mds = 0, i; int rv = 0; nkey = type->key_len; niv = type->iv_len; OPENSSL_assert(nkey <= EVP_MAX_KEY_LENGTH); OPENSSL_assert(niv <= EVP_MAX_IV_LENGTH); if (data == NULL) return (nkey); EVP_MD_CTX_init(&c); for (;;) { if (!EVP_DigestInit_ex(&c, md, NULL)) return 0; if (addmd++) if (!EVP_DigestUpdate(&c, &(md_buf[0]), mds)) goto err; if (!EVP_DigestUpdate(&c, data, datal)) goto err; if (salt != NULL) if (!EVP_DigestUpdate(&c, salt, PKCS5_SALT_LEN)) goto err; if (!EVP_DigestFinal_ex(&c, &(md_buf[0]), &mds)) goto err; for (i = 1; i < (unsigned int)count; i++) { if (!EVP_DigestInit_ex(&c, md, NULL)) goto err; if (!EVP_DigestUpdate(&c, &(md_buf[0]), mds)) goto err; if (!EVP_DigestFinal_ex(&c, &(md_buf[0]), &mds)) goto err; } i = 0; if (nkey) { for (;;) { if (nkey == 0) break; if (i == mds) break; if (key != NULL) *(key++) = md_buf[i]; nkey--; i++; } } if (niv && (i != mds)) { for (;;) { if (niv == 0) break; if (i == mds) break; if (iv != NULL) *(iv++) = md_buf[i]; niv--; i++; } } if ((nkey == 0) && (niv == 0)) break; } rv = type->key_len; err: EVP_MD_CTX_cleanup(&c); OPENSSL_cleanse(&(md_buf[0]), EVP_MAX_MD_SIZE); return rv; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/p_lib.c0000644000175000017500000002557212360020705020311 0ustar /* $OpenBSD: p_lib.c,v 1.14 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_DH #include #endif #ifndef OPENSSL_NO_DSA #include #endif #ifndef OPENSSL_NO_RSA #include #endif #ifndef OPENSSL_NO_ENGINE #include #endif #include "asn1_locl.h" static void EVP_PKEY_free_it(EVP_PKEY *x); int EVP_PKEY_bits(EVP_PKEY *pkey) { if (pkey && pkey->ameth && pkey->ameth->pkey_bits) return pkey->ameth->pkey_bits(pkey); return 0; } int EVP_PKEY_size(EVP_PKEY *pkey) { if (pkey && pkey->ameth && pkey->ameth->pkey_size) return pkey->ameth->pkey_size(pkey); return 0; } int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode) { #ifndef OPENSSL_NO_DSA if (pkey->type == EVP_PKEY_DSA) { int ret = pkey->save_parameters; if (mode >= 0) pkey->save_parameters = mode; return (ret); } #endif #ifndef OPENSSL_NO_EC if (pkey->type == EVP_PKEY_EC) { int ret = pkey->save_parameters; if (mode >= 0) pkey->save_parameters = mode; return (ret); } #endif return (0); } int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from) { if (to->type != from->type) { EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS, EVP_R_DIFFERENT_KEY_TYPES); goto err; } if (EVP_PKEY_missing_parameters(from)) { EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS, EVP_R_MISSING_PARAMETERS); goto err; } if (from->ameth && from->ameth->param_copy) return from->ameth->param_copy(to, from); err: return 0; } int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey) { if (pkey->ameth && pkey->ameth->param_missing) return pkey->ameth->param_missing(pkey); return 0; } int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b) { if (a->type != b->type) return -1; if (a->ameth && a->ameth->param_cmp) return a->ameth->param_cmp(a, b); return -2; } int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b) { if (a->type != b->type) return -1; if (a->ameth) { int ret; /* Compare parameters if the algorithm has them */ if (a->ameth->param_cmp) { ret = a->ameth->param_cmp(a, b); if (ret <= 0) return ret; } if (a->ameth->pub_cmp) return a->ameth->pub_cmp(a, b); } return -2; } EVP_PKEY * EVP_PKEY_new(void) { EVP_PKEY *ret; ret = malloc(sizeof(EVP_PKEY)); if (ret == NULL) { EVPerr(EVP_F_EVP_PKEY_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } ret->type = EVP_PKEY_NONE; ret->save_type = EVP_PKEY_NONE; ret->references = 1; ret->ameth = NULL; ret->engine = NULL; ret->pkey.ptr = NULL; ret->attributes = NULL; ret->save_parameters = 1; return (ret); } /* Setup a public key ASN1 method and ENGINE from a NID or a string. * If pkey is NULL just return 1 or 0 if the algorithm exists. */ static int pkey_set_type(EVP_PKEY *pkey, int type, const char *str, int len) { const EVP_PKEY_ASN1_METHOD *ameth; ENGINE *e = NULL; if (pkey) { if (pkey->pkey.ptr) EVP_PKEY_free_it(pkey); /* If key type matches and a method exists then this * lookup has succeeded once so just indicate success. */ if ((type == pkey->save_type) && pkey->ameth) return 1; #ifndef OPENSSL_NO_ENGINE /* If we have an ENGINE release it */ if (pkey->engine) { ENGINE_finish(pkey->engine); pkey->engine = NULL; } #endif } if (str) ameth = EVP_PKEY_asn1_find_str(&e, str, len); else ameth = EVP_PKEY_asn1_find(&e, type); #ifndef OPENSSL_NO_ENGINE if (!pkey && e) ENGINE_finish(e); #endif if (!ameth) { EVPerr(EVP_F_PKEY_SET_TYPE, EVP_R_UNSUPPORTED_ALGORITHM); return 0; } if (pkey) { pkey->ameth = ameth; pkey->engine = e; pkey->type = pkey->ameth->pkey_id; pkey->save_type = type; } return 1; } int EVP_PKEY_set_type(EVP_PKEY *pkey, int type) { return pkey_set_type(pkey, type, NULL, -1); } int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len) { return pkey_set_type(pkey, EVP_PKEY_NONE, str, len); } int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key) { if (!EVP_PKEY_set_type(pkey, type)) return 0; pkey->pkey.ptr = key; return (key != NULL); } void * EVP_PKEY_get0(EVP_PKEY *pkey) { return pkey->pkey.ptr; } #ifndef OPENSSL_NO_RSA int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key) { int ret = EVP_PKEY_assign_RSA(pkey, key); if (ret) RSA_up_ref(key); return ret; } RSA * EVP_PKEY_get1_RSA(EVP_PKEY *pkey) { if (pkey->type != EVP_PKEY_RSA) { EVPerr(EVP_F_EVP_PKEY_GET1_RSA, EVP_R_EXPECTING_AN_RSA_KEY); return NULL; } RSA_up_ref(pkey->pkey.rsa); return pkey->pkey.rsa; } #endif #ifndef OPENSSL_NO_DSA int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key) { int ret = EVP_PKEY_assign_DSA(pkey, key); if (ret) DSA_up_ref(key); return ret; } DSA * EVP_PKEY_get1_DSA(EVP_PKEY *pkey) { if (pkey->type != EVP_PKEY_DSA) { EVPerr(EVP_F_EVP_PKEY_GET1_DSA, EVP_R_EXPECTING_A_DSA_KEY); return NULL; } DSA_up_ref(pkey->pkey.dsa); return pkey->pkey.dsa; } #endif #ifndef OPENSSL_NO_EC int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key) { int ret = EVP_PKEY_assign_EC_KEY(pkey, key); if (ret) EC_KEY_up_ref(key); return ret; } EC_KEY * EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey) { if (pkey->type != EVP_PKEY_EC) { EVPerr(EVP_F_EVP_PKEY_GET1_EC_KEY, EVP_R_EXPECTING_A_EC_KEY); return NULL; } EC_KEY_up_ref(pkey->pkey.ec); return pkey->pkey.ec; } #endif #ifndef OPENSSL_NO_DH int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key) { int ret = EVP_PKEY_assign_DH(pkey, key); if (ret) DH_up_ref(key); return ret; } DH * EVP_PKEY_get1_DH(EVP_PKEY *pkey) { if (pkey->type != EVP_PKEY_DH) { EVPerr(EVP_F_EVP_PKEY_GET1_DH, EVP_R_EXPECTING_A_DH_KEY); return NULL; } DH_up_ref(pkey->pkey.dh); return pkey->pkey.dh; } #endif int EVP_PKEY_type(int type) { int ret; const EVP_PKEY_ASN1_METHOD *ameth; ENGINE *e; ameth = EVP_PKEY_asn1_find(&e, type); if (ameth) ret = ameth->pkey_id; else ret = NID_undef; #ifndef OPENSSL_NO_ENGINE if (e) ENGINE_finish(e); #endif return ret; } int EVP_PKEY_id(const EVP_PKEY *pkey) { return pkey->type; } int EVP_PKEY_base_id(const EVP_PKEY *pkey) { return EVP_PKEY_type(pkey->type); } void EVP_PKEY_free(EVP_PKEY *x) { int i; if (x == NULL) return; i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_EVP_PKEY); if (i > 0) return; EVP_PKEY_free_it(x); if (x->attributes) sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free); free(x); } static void EVP_PKEY_free_it(EVP_PKEY *x) { if (x->ameth && x->ameth->pkey_free) { x->ameth->pkey_free(x); x->pkey.ptr = NULL; } #ifndef OPENSSL_NO_ENGINE if (x->engine) { ENGINE_finish(x->engine); x->engine = NULL; } #endif } static int unsup_alg(BIO *out, const EVP_PKEY *pkey, int indent, const char *kstr) { BIO_indent(out, indent, 128); BIO_printf(out, "%s algorithm \"%s\" unsupported\n", kstr, OBJ_nid2ln(pkey->type)); return 1; } int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx) { if (pkey->ameth && pkey->ameth->pub_print) return pkey->ameth->pub_print(out, pkey, indent, pctx); return unsup_alg(out, pkey, indent, "Public Key"); } int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx) { if (pkey->ameth && pkey->ameth->priv_print) return pkey->ameth->priv_print(out, pkey, indent, pctx); return unsup_alg(out, pkey, indent, "Private Key"); } int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx) { if (pkey->ameth && pkey->ameth->param_print) return pkey->ameth->param_print(out, pkey, indent, pctx); return unsup_alg(out, pkey, indent, "Parameters"); } int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid) { if (!pkey->ameth || !pkey->ameth->pkey_ctrl) return -2; return pkey->ameth->pkey_ctrl(pkey, ASN1_PKEY_CTRL_DEFAULT_MD_NID, 0, pnid); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/c_alld.c0000644000175000017500000001121412360020705020426 0ustar /* $OpenBSD: c_alld.c,v 1.10 2014/07/10 22:45:57 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include void OpenSSL_add_all_digests(void) { #ifndef OPENSSL_NO_MD4 EVP_add_digest(EVP_md4()); #endif #ifndef OPENSSL_NO_MD5 EVP_add_digest(EVP_md5()); EVP_add_digest_alias(SN_md5, "ssl2-md5"); EVP_add_digest_alias(SN_md5, "ssl3-md5"); #endif #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA0) EVP_add_digest(EVP_sha()); #ifndef OPENSSL_NO_DSA EVP_add_digest(EVP_dss()); #endif #endif #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1) EVP_add_digest(EVP_sha1()); EVP_add_digest_alias(SN_sha1, "ssl3-sha1"); EVP_add_digest_alias(SN_sha1WithRSAEncryption, SN_sha1WithRSA); #ifndef OPENSSL_NO_DSA EVP_add_digest(EVP_dss1()); EVP_add_digest_alias(SN_dsaWithSHA1, SN_dsaWithSHA1_2); EVP_add_digest_alias(SN_dsaWithSHA1, "DSS1"); EVP_add_digest_alias(SN_dsaWithSHA1, "dss1"); #endif #ifndef OPENSSL_NO_ECDSA EVP_add_digest(EVP_ecdsa()); #endif #endif #if !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DES) EVP_add_digest(EVP_mdc2()); #endif #ifndef OPENSSL_NO_RIPEMD EVP_add_digest(EVP_ripemd160()); EVP_add_digest_alias(SN_ripemd160, "ripemd"); EVP_add_digest_alias(SN_ripemd160, "rmd160"); #endif #ifndef OPENSSL_NO_SHA256 EVP_add_digest(EVP_sha224()); EVP_add_digest(EVP_sha256()); #endif #ifndef OPENSSL_NO_SHA512 EVP_add_digest(EVP_sha384()); EVP_add_digest(EVP_sha512()); #endif #ifndef OPENSSL_NO_WHIRLPOOL EVP_add_digest(EVP_whirlpool()); #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/p_verify.c0000644000175000017500000001100612360020705021032 0ustar /* $OpenBSD: p_verify.c,v 1.11 2014/06/12 15:49:29 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf, unsigned int siglen, EVP_PKEY *pkey) { unsigned char m[EVP_MAX_MD_SIZE]; unsigned int m_len; int i = 0, ok = 0, v; EVP_MD_CTX tmp_ctx; EVP_PKEY_CTX *pkctx = NULL; EVP_MD_CTX_init(&tmp_ctx); if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx)) goto err; if (!EVP_DigestFinal_ex(&tmp_ctx, &(m[0]), &m_len)) goto err; EVP_MD_CTX_cleanup(&tmp_ctx); if (ctx->digest->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) { i = -1; pkctx = EVP_PKEY_CTX_new(pkey, NULL); if (!pkctx) goto err; if (EVP_PKEY_verify_init(pkctx) <= 0) goto err; if (EVP_PKEY_CTX_set_signature_md(pkctx, ctx->digest) <= 0) goto err; i = EVP_PKEY_verify(pkctx, sigbuf, siglen, m, m_len); err: EVP_PKEY_CTX_free(pkctx); return i; } for (i = 0; i < 4; i++) { v = ctx->digest->required_pkey_type[i]; if (v == 0) break; if (pkey->type == v) { ok = 1; break; } } if (!ok) { EVPerr(EVP_F_EVP_VERIFYFINAL, EVP_R_WRONG_PUBLIC_KEY_TYPE); return (-1); } if (ctx->digest->verify == NULL) { EVPerr(EVP_F_EVP_VERIFYFINAL, EVP_R_NO_VERIFY_FUNCTION_CONFIGURED); return (0); } return(ctx->digest->verify(ctx->digest->type, m, m_len, sigbuf, siglen, pkey->pkey.ptr)); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/e_old.c0000644000175000017500000001133112360020705020272 0ustar /* $OpenBSD: e_old.c,v 1.6 2014/06/12 15:49:29 deraadt Exp $ */ /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL * project 2004. */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #ifndef OPENSSL_NO_DEPRECATED #include /* Define some deprecated functions, so older programs don't crash and burn too quickly. On Windows and VMS, these will never be used, since functions and variables in shared libraries are selected by entry point location, not by name. */ #ifndef OPENSSL_NO_BF #undef EVP_bf_cfb const EVP_CIPHER *EVP_bf_cfb(void); const EVP_CIPHER * EVP_bf_cfb(void) { return EVP_bf_cfb64(); } #endif #ifndef OPENSSL_NO_DES #undef EVP_des_cfb const EVP_CIPHER *EVP_des_cfb(void); const EVP_CIPHER * EVP_des_cfb(void) { return EVP_des_cfb64(); } #undef EVP_des_ede3_cfb const EVP_CIPHER *EVP_des_ede3_cfb(void); const EVP_CIPHER * EVP_des_ede3_cfb(void) { return EVP_des_ede3_cfb64(); } #undef EVP_des_ede_cfb const EVP_CIPHER *EVP_des_ede_cfb(void); const EVP_CIPHER * EVP_des_ede_cfb(void) { return EVP_des_ede_cfb64(); } #endif #ifndef OPENSSL_NO_IDEA #undef EVP_idea_cfb const EVP_CIPHER *EVP_idea_cfb(void); const EVP_CIPHER * EVP_idea_cfb(void) { return EVP_idea_cfb64(); } #endif #ifndef OPENSSL_NO_RC2 #undef EVP_rc2_cfb const EVP_CIPHER *EVP_rc2_cfb(void); const EVP_CIPHER * EVP_rc2_cfb(void) { return EVP_rc2_cfb64(); } #endif #ifndef OPENSSL_NO_CAST #undef EVP_cast5_cfb const EVP_CIPHER *EVP_cast5_cfb(void); const EVP_CIPHER * EVP_cast5_cfb(void) { return EVP_cast5_cfb64(); } #endif #ifndef OPENSSL_NO_RC5 #undef EVP_rc5_32_12_16_cfb const EVP_CIPHER *EVP_rc5_32_12_16_cfb(void); const EVP_CIPHER * EVP_rc5_32_12_16_cfb(void) { return EVP_rc5_32_12_16_cfb64(); } #endif #ifndef OPENSSL_NO_AES #undef EVP_aes_128_cfb const EVP_CIPHER *EVP_aes_128_cfb(void); const EVP_CIPHER * EVP_aes_128_cfb(void) { return EVP_aes_128_cfb128(); } #undef EVP_aes_192_cfb const EVP_CIPHER *EVP_aes_192_cfb(void); const EVP_CIPHER * EVP_aes_192_cfb(void) { return EVP_aes_192_cfb128(); } #undef EVP_aes_256_cfb const EVP_CIPHER *EVP_aes_256_cfb(void); const EVP_CIPHER * EVP_aes_256_cfb(void) { return EVP_aes_256_cfb128(); } #endif #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/m_sigver.c0000644000175000017500000001341612360020705021031 0ustar /* $OpenBSD: m_sigver.c,v 1.3 2014/06/12 15:49:29 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ /* ==================================================================== * Copyright (c) 2006,2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include "evp_locl.h" static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey, int ver) { if (ctx->pctx == NULL) ctx->pctx = EVP_PKEY_CTX_new(pkey, e); if (ctx->pctx == NULL) return 0; if (type == NULL) { int def_nid; if (EVP_PKEY_get_default_digest_nid(pkey, &def_nid) > 0) type = EVP_get_digestbynid(def_nid); } if (type == NULL) { EVPerr(EVP_F_DO_SIGVER_INIT, EVP_R_NO_DEFAULT_DIGEST); return 0; } if (ver) { if (ctx->pctx->pmeth->verifyctx_init) { if (ctx->pctx->pmeth->verifyctx_init(ctx->pctx, ctx) <=0) return 0; ctx->pctx->operation = EVP_PKEY_OP_VERIFYCTX; } else if (EVP_PKEY_verify_init(ctx->pctx) <= 0) return 0; } else { if (ctx->pctx->pmeth->signctx_init) { if (ctx->pctx->pmeth->signctx_init(ctx->pctx, ctx) <= 0) return 0; ctx->pctx->operation = EVP_PKEY_OP_SIGNCTX; } else if (EVP_PKEY_sign_init(ctx->pctx) <= 0) return 0; } if (EVP_PKEY_CTX_set_signature_md(ctx->pctx, type) <= 0) return 0; if (pctx) *pctx = ctx->pctx; if (!EVP_DigestInit_ex(ctx, type, e)) return 0; return 1; } int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey) { return do_sigver_init(ctx, pctx, type, e, pkey, 0); } int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey) { return do_sigver_init(ctx, pctx, type, e, pkey, 1); } int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen) { int sctx, r = 0; if (ctx->pctx->pmeth->signctx) sctx = 1; else sctx = 0; if (sigret) { EVP_MD_CTX tmp_ctx; unsigned char md[EVP_MAX_MD_SIZE]; unsigned int mdlen; EVP_MD_CTX_init(&tmp_ctx); if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx)) return 0; if (sctx) r = tmp_ctx.pctx->pmeth->signctx(tmp_ctx.pctx, sigret, siglen, &tmp_ctx); else r = EVP_DigestFinal_ex(&tmp_ctx, md, &mdlen); EVP_MD_CTX_cleanup(&tmp_ctx); if (sctx || !r) return r; if (EVP_PKEY_sign(ctx->pctx, sigret, siglen, md, mdlen) <= 0) return 0; } else { if (sctx) { if (ctx->pctx->pmeth->signctx(ctx->pctx, sigret, siglen, ctx) <= 0) return 0; } else { int s = EVP_MD_size(ctx->digest); if (s < 0 || EVP_PKEY_sign(ctx->pctx, sigret, siglen, NULL, s) <= 0) return 0; } } return 1; } int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, unsigned char *sig, size_t siglen) { EVP_MD_CTX tmp_ctx; unsigned char md[EVP_MAX_MD_SIZE]; int r; unsigned int mdlen; int vctx; if (ctx->pctx->pmeth->verifyctx) vctx = 1; else vctx = 0; EVP_MD_CTX_init(&tmp_ctx); if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx)) return -1; if (vctx) { r = tmp_ctx.pctx->pmeth->verifyctx(tmp_ctx.pctx, sig, siglen, &tmp_ctx); } else r = EVP_DigestFinal_ex(&tmp_ctx, md, &mdlen); EVP_MD_CTX_cleanup(&tmp_ctx); if (vctx || !r) return r; return EVP_PKEY_verify(ctx->pctx, sig, siglen, md, mdlen); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/encode.c0000644000175000017500000002703112360020705020451 0ustar /* $OpenBSD: encode.c,v 1.17 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #define conv_bin2ascii(a) (data_bin2ascii[(a)&0x3f]) #define conv_ascii2bin(a) (data_ascii2bin[(a)&0x7f]) /* 64 char lines * pad input with 0 * left over chars are set to = * 1 byte => xx== * 2 bytes => xxx= * 3 bytes => xxxx */ #define BIN_PER_LINE (64/4*3) #define CHUNKS_PER_LINE (64/4) #define CHAR_PER_LINE (64+1) static const unsigned char data_bin2ascii[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz0123456789+/"; /* 0xF0 is a EOLN * 0xF1 is ignore but next needs to be 0xF0 (for \r\n processing). * 0xF2 is EOF * 0xE0 is ignore at start of line. * 0xFF is error */ #define B64_EOLN 0xF0 #define B64_CR 0xF1 #define B64_EOF 0xF2 #define B64_WS 0xE0 #define B64_ERROR 0xFF #define B64_NOT_BASE64(a) (((a)|0x13) == 0xF3) static const unsigned char data_ascii2bin[128] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xF0, 0xFF, 0xFF, 0xF1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3E, 0xFF, 0xF2, 0xFF, 0x3F, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }; void EVP_EncodeInit(EVP_ENCODE_CTX *ctx) { ctx->length = 48; ctx->num = 0; ctx->line_num = 0; } void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl) { int i, j; unsigned int total = 0; *outl = 0; if (inl == 0) return; OPENSSL_assert(ctx->length <= (int)sizeof(ctx->enc_data)); if ((ctx->num + inl) < ctx->length) { memcpy(&(ctx->enc_data[ctx->num]), in, inl); ctx->num += inl; return; } if (ctx->num != 0) { i = ctx->length - ctx->num; memcpy(&(ctx->enc_data[ctx->num]), in, i); in += i; inl -= i; j = EVP_EncodeBlock(out, ctx->enc_data, ctx->length); ctx->num = 0; out += j; *(out++) = '\n'; *out = '\0'; total = j + 1; } while (inl >= ctx->length) { j = EVP_EncodeBlock(out, in, ctx->length); in += ctx->length; inl -= ctx->length; out += j; *(out++) = '\n'; *out = '\0'; total += j + 1; } if (inl != 0) memcpy(&(ctx->enc_data[0]), in, inl); ctx->num = inl; *outl = total; } void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl) { unsigned int ret = 0; if (ctx->num != 0) { ret = EVP_EncodeBlock(out, ctx->enc_data, ctx->num); out[ret++] = '\n'; out[ret] = '\0'; ctx->num = 0; } *outl = ret; } int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int dlen) { int i, ret = 0; unsigned long l; for (i = dlen; i > 0; i -= 3) { if (i >= 3) { l = (((unsigned long)f[0]) << 16L) | (((unsigned long)f[1]) << 8L) | f[2]; *(t++) = conv_bin2ascii(l >> 18L); *(t++) = conv_bin2ascii(l >> 12L); *(t++) = conv_bin2ascii(l >> 6L); *(t++) = conv_bin2ascii(l ); } else { l = ((unsigned long)f[0]) << 16L; if (i == 2) l |= ((unsigned long)f[1] << 8L); *(t++) = conv_bin2ascii(l >> 18L); *(t++) = conv_bin2ascii(l >> 12L); *(t++) = (i == 1) ? '=' : conv_bin2ascii(l >> 6L); *(t++) = '='; } ret += 4; f += 3; } *t = '\0'; return (ret); } void EVP_DecodeInit(EVP_ENCODE_CTX *ctx) { ctx->length = 30; ctx->num = 0; ctx->line_num = 0; ctx->expect_nl = 0; } /* -1 for error * 0 for last line * 1 for full line */ int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl) { int seof = -1, eof = 0, rv = -1, ret = 0, i, v, tmp, n, ln, exp_nl; unsigned char *d; n = ctx->num; d = ctx->enc_data; ln = ctx->line_num; exp_nl = ctx->expect_nl; /* last line of input. */ if ((inl == 0) || ((n == 0) && (conv_ascii2bin(in[0]) == B64_EOF))) { rv = 0; goto end; } /* We parse the input data */ for (i = 0; i < inl; i++) { /* If the current line is > 80 characters, scream alot */ if (ln >= 80) { rv = -1; goto end; } /* Get char and put it into the buffer */ tmp= *(in++); v = conv_ascii2bin(tmp); /* only save the good data :-) */ if (!B64_NOT_BASE64(v)) { OPENSSL_assert(n < (int)sizeof(ctx->enc_data)); d[n++] = tmp; ln++; } else if (v == B64_ERROR) { rv = -1; goto end; } /* There should not be base64 data after padding. */ if (eof && tmp != '=' && tmp != '\r' && tmp != '\n') { rv = -1; goto end; } /* have we seen a '=' which is 'definitely' the last * input line. seof will point to the character that * holds it. and eof will hold how many characters to * chop off. */ if (tmp == '=') { if (seof == -1) seof = n; eof++; } /* There should be no more than two padding markers. */ if (eof > 2) { rv = -1; goto end; } if (v == B64_CR) { ln = 0; if (exp_nl) continue; } /* eoln */ if (v == B64_EOLN) { ln = 0; if (exp_nl) { exp_nl = 0; continue; } } exp_nl = 0; /* If we are at the end of input and it looks like a * line, process it. */ if (((i + 1) == inl) && (((n&3) == 0) || eof)) { v = B64_EOF; /* In case things were given us in really small records (so two '=' were given in separate updates), eof may contain the incorrect number of ending bytes to skip, so let's redo the count */ eof = 0; if (d[n-1] == '=') eof++; if (d[n-2] == '=') eof++; /* There will never be more than two '=' */ } if ((v == B64_EOF && (n&3) == 0) || (n >= 64)) { /* This is needed to work correctly on 64 byte input * lines. We process the line and then need to * accept the '\n' */ if ((v != B64_EOF) && (n >= 64)) exp_nl = 1; if (n > 0) { v = EVP_DecodeBlock(out, d, n); n = 0; if (v < 0) { rv = 0; goto end; } ret += (v - eof); } else { eof = 1; v = 0; } /* This is the case where we have had a short * but valid input line */ if ((v < ctx->length) && eof) { rv = 0; goto end; } else ctx->length = v; if (seof >= 0) { rv = 0; goto end; } out += v; } } rv = 1; end: *outl = ret; ctx->num = n; ctx->line_num = ln; ctx->expect_nl = exp_nl; return (rv); } int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n) { int i, ret = 0, a, b, c, d; unsigned long l; /* trim white space from the start of the line. */ while ((conv_ascii2bin(*f) == B64_WS) && (n > 0)) { f++; n--; } /* strip off stuff at the end of the line * ascii2bin values B64_WS, B64_EOLN, B64_EOLN and B64_EOF */ while ((n > 3) && (B64_NOT_BASE64(conv_ascii2bin(f[n - 1])))) n--; if (n % 4 != 0) return (-1); for (i = 0; i < n; i += 4) { a = conv_ascii2bin(*(f++)); b = conv_ascii2bin(*(f++)); c = conv_ascii2bin(*(f++)); d = conv_ascii2bin(*(f++)); if ((a & 0x80) || (b & 0x80) || (c & 0x80) || (d & 0x80)) return (-1); l = ((((unsigned long)a) << 18L) | (((unsigned long)b) << 12L) | (((unsigned long)c) << 6L) | (((unsigned long)d))); *(t++) = (unsigned char)(l >> 16L) & 0xff; *(t++) = (unsigned char)(l >> 8L) & 0xff; *(t++) = (unsigned char)(l) & 0xff; ret += 3; } return (ret); } int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl) { int i; *outl = 0; if (ctx->num != 0) { i = EVP_DecodeBlock(out, ctx->enc_data, ctx->num); if (i < 0) return (-1); ctx->num = 0; *outl = i; return (1); } else return (1); } #ifdef undef int EVP_DecodeValid(unsigned char *buf, int len) { int i, num = 0, bad = 0; if (len == 0) return (-1); while (conv_ascii2bin(*buf) == B64_WS) { buf++; len--; if (len == 0) return (-1); } for (i = len; i >= 4; i -= 4) { if ((conv_ascii2bin(buf[0]) >= 0x40) || (conv_ascii2bin(buf[1]) >= 0x40) || (conv_ascii2bin(buf[2]) >= 0x40) || (conv_ascii2bin(buf[3]) >= 0x40)) return (-1); buf += 4; num += 1 + (buf[2] != '=') + (buf[3] != '='); } if ((i == 1) && (conv_ascii2bin(buf[0]) == B64_EOLN)) return (num); if ((i == 2) && (conv_ascii2bin(buf[0]) == B64_EOLN) && (conv_ascii2bin(buf[0]) == B64_EOLN)) return (num); return (1); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/e_aes.c0000644000175000017500000011677312360020705020304 0ustar /* $OpenBSD: e_aes.c,v 1.23 2014/07/10 22:45:57 jsing Exp $ */ /* ==================================================================== * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * */ #include #include #include #ifndef OPENSSL_NO_AES #include #include #include #include #include "evp_locl.h" #include "modes_lcl.h" typedef struct { AES_KEY ks; block128_f block; union { cbc128_f cbc; ctr128_f ctr; } stream; } EVP_AES_KEY; typedef struct { AES_KEY ks; /* AES key schedule to use */ int key_set; /* Set if key initialised */ int iv_set; /* Set if an iv is set */ GCM128_CONTEXT gcm; unsigned char *iv; /* Temporary IV store */ int ivlen; /* IV length */ int taglen; int iv_gen; /* It is OK to generate IVs */ int tls_aad_len; /* TLS AAD length */ ctr128_f ctr; } EVP_AES_GCM_CTX; typedef struct { AES_KEY ks1, ks2; /* AES key schedules to use */ XTS128_CONTEXT xts; void (*stream)(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]); } EVP_AES_XTS_CTX; typedef struct { AES_KEY ks; /* AES key schedule to use */ int key_set; /* Set if key initialised */ int iv_set; /* Set if an iv is set */ int tag_set; /* Set if tag is valid */ int len_set; /* Set if message length set */ int L, M; /* L and M parameters from RFC3610 */ CCM128_CONTEXT ccm; ccm128_f str; } EVP_AES_CCM_CTX; #define MAXBITCHUNK ((size_t)1<<(sizeof(size_t)*8-4)) #ifdef VPAES_ASM int vpaes_set_encrypt_key(const unsigned char *userKey, int bits, AES_KEY *key); int vpaes_set_decrypt_key(const unsigned char *userKey, int bits, AES_KEY *key); void vpaes_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); void vpaes_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); void vpaes_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key, unsigned char *ivec, int enc); #endif #ifdef BSAES_ASM void bsaes_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key, unsigned char ivec[16], int enc); void bsaes_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out, size_t len, const AES_KEY *key, const unsigned char ivec[16]); void bsaes_xts_encrypt(const unsigned char *inp, unsigned char *out, size_t len, const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]); void bsaes_xts_decrypt(const unsigned char *inp, unsigned char *out, size_t len, const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]); #endif #ifdef AES_CTR_ASM void AES_ctr32_encrypt(const unsigned char *in, unsigned char *out, size_t blocks, const AES_KEY *key, const unsigned char ivec[AES_BLOCK_SIZE]); #endif #ifdef AES_XTS_ASM void AES_xts_encrypt(const char *inp, char *out, size_t len, const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]); void AES_xts_decrypt(const char *inp, char *out, size_t len, const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]); #endif #if defined(AES_ASM) && !defined(I386_ONLY) && ( \ ((defined(__i386) || defined(__i386__) || \ defined(_M_IX86)) && defined(OPENSSL_IA32_SSE2))|| \ defined(__x86_64) || defined(__x86_64__) || \ defined(_M_AMD64) || defined(_M_X64) || \ defined(__INTEL__) ) extern unsigned int OPENSSL_ia32cap_P[2]; #ifdef VPAES_ASM #define VPAES_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(41-32))) #endif #ifdef BSAES_ASM #define BSAES_CAPABLE VPAES_CAPABLE #endif /* * AES-NI section */ #define AESNI_CAPABLE (OPENSSL_ia32cap_P[1]&(1<<(57-32))) int aesni_set_encrypt_key(const unsigned char *userKey, int bits, AES_KEY *key); int aesni_set_decrypt_key(const unsigned char *userKey, int bits, AES_KEY *key); void aesni_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); void aesni_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); void aesni_ecb_encrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key, int enc); void aesni_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key, unsigned char *ivec, int enc); void aesni_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out, size_t blocks, const void *key, const unsigned char *ivec); void aesni_xts_encrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]); void aesni_xts_decrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]); void aesni_ccm64_encrypt_blocks (const unsigned char *in, unsigned char *out, size_t blocks, const void *key, const unsigned char ivec[16], unsigned char cmac[16]); void aesni_ccm64_decrypt_blocks (const unsigned char *in, unsigned char *out, size_t blocks, const void *key, const unsigned char ivec[16], unsigned char cmac[16]); static int aesni_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { int ret, mode; EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data; mode = ctx->cipher->flags & EVP_CIPH_MODE; if ((mode == EVP_CIPH_ECB_MODE || mode == EVP_CIPH_CBC_MODE) && !enc) { ret = aesni_set_decrypt_key(key, ctx->key_len * 8, ctx->cipher_data); dat->block = (block128_f)aesni_decrypt; dat->stream.cbc = mode == EVP_CIPH_CBC_MODE ? (cbc128_f)aesni_cbc_encrypt : NULL; } else { ret = aesni_set_encrypt_key(key, ctx->key_len * 8, ctx->cipher_data); dat->block = (block128_f)aesni_encrypt; if (mode == EVP_CIPH_CBC_MODE) dat->stream.cbc = (cbc128_f)aesni_cbc_encrypt; else if (mode == EVP_CIPH_CTR_MODE) dat->stream.ctr = (ctr128_f)aesni_ctr32_encrypt_blocks; else dat->stream.cbc = NULL; } if (ret < 0) { EVPerr(EVP_F_AESNI_INIT_KEY, EVP_R_AES_KEY_SETUP_FAILED); return 0; } return 1; } static int aesni_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { aesni_cbc_encrypt(in, out, len, ctx->cipher_data, ctx->iv, ctx->encrypt); return 1; } static int aesni_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { size_t bl = ctx->cipher->block_size; if (len < bl) return 1; aesni_ecb_encrypt(in, out, len, ctx->cipher_data, ctx->encrypt); return 1; } #define aesni_ofb_cipher aes_ofb_cipher static int aesni_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len); #define aesni_cfb_cipher aes_cfb_cipher static int aesni_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len); #define aesni_cfb8_cipher aes_cfb8_cipher static int aesni_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len); #define aesni_cfb1_cipher aes_cfb1_cipher static int aesni_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len); #define aesni_ctr_cipher aes_ctr_cipher static int aesni_ctr_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len); static int aesni_gcm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { EVP_AES_GCM_CTX *gctx = ctx->cipher_data; if (!iv && !key) return 1; if (key) { aesni_set_encrypt_key(key, ctx->key_len * 8, &gctx->ks); CRYPTO_gcm128_init(&gctx->gcm, &gctx->ks, (block128_f)aesni_encrypt); gctx->ctr = (ctr128_f)aesni_ctr32_encrypt_blocks; /* If we have an iv can set it directly, otherwise use * saved IV. */ if (iv == NULL && gctx->iv_set) iv = gctx->iv; if (iv) { CRYPTO_gcm128_setiv(&gctx->gcm, iv, gctx->ivlen); gctx->iv_set = 1; } gctx->key_set = 1; } else { /* If key set use IV, otherwise copy */ if (gctx->key_set) CRYPTO_gcm128_setiv(&gctx->gcm, iv, gctx->ivlen); else memcpy(gctx->iv, iv, gctx->ivlen); gctx->iv_set = 1; gctx->iv_gen = 0; } return 1; } #define aesni_gcm_cipher aes_gcm_cipher static int aesni_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len); static int aesni_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { EVP_AES_XTS_CTX *xctx = ctx->cipher_data; if (!iv && !key) return 1; if (key) { /* key_len is two AES keys */ if (enc) { aesni_set_encrypt_key(key, ctx->key_len * 4, &xctx->ks1); xctx->xts.block1 = (block128_f)aesni_encrypt; xctx->stream = aesni_xts_encrypt; } else { aesni_set_decrypt_key(key, ctx->key_len * 4, &xctx->ks1); xctx->xts.block1 = (block128_f)aesni_decrypt; xctx->stream = aesni_xts_decrypt; } aesni_set_encrypt_key(key + ctx->key_len / 2, ctx->key_len * 4, &xctx->ks2); xctx->xts.block2 = (block128_f)aesni_encrypt; xctx->xts.key1 = &xctx->ks1; } if (iv) { xctx->xts.key2 = &xctx->ks2; memcpy(ctx->iv, iv, 16); } return 1; } #define aesni_xts_cipher aes_xts_cipher static int aesni_xts_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len); static int aesni_ccm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { EVP_AES_CCM_CTX *cctx = ctx->cipher_data; if (!iv && !key) return 1; if (key) { aesni_set_encrypt_key(key, ctx->key_len * 8, &cctx->ks); CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, &cctx->ks, (block128_f)aesni_encrypt); cctx->str = enc ? (ccm128_f)aesni_ccm64_encrypt_blocks : (ccm128_f)aesni_ccm64_decrypt_blocks; cctx->key_set = 1; } if (iv) { memcpy(ctx->iv, iv, 15 - cctx->L); cctx->iv_set = 1; } return 1; } #define aesni_ccm_cipher aes_ccm_cipher static int aesni_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len); #define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,nmode,mode,MODE,flags) \ static const EVP_CIPHER aesni_##keylen##_##mode = { \ nid##_##keylen##_##nmode,blocksize,keylen/8,ivlen, \ flags|EVP_CIPH_##MODE##_MODE, \ aesni_init_key, \ aesni_##mode##_cipher, \ NULL, \ sizeof(EVP_AES_KEY), \ NULL,NULL,NULL,NULL }; \ static const EVP_CIPHER aes_##keylen##_##mode = { \ nid##_##keylen##_##nmode,blocksize, \ keylen/8,ivlen, \ flags|EVP_CIPH_##MODE##_MODE, \ aes_init_key, \ aes_##mode##_cipher, \ NULL, \ sizeof(EVP_AES_KEY), \ NULL,NULL,NULL,NULL }; \ const EVP_CIPHER *EVP_aes_##keylen##_##mode(void) \ { return AESNI_CAPABLE?&aesni_##keylen##_##mode:&aes_##keylen##_##mode; } #define BLOCK_CIPHER_custom(nid,keylen,blocksize,ivlen,mode,MODE,flags) \ static const EVP_CIPHER aesni_##keylen##_##mode = { \ nid##_##keylen##_##mode,blocksize, \ (EVP_CIPH_##MODE##_MODE==EVP_CIPH_XTS_MODE?2:1)*keylen/8, ivlen, \ flags|EVP_CIPH_##MODE##_MODE, \ aesni_##mode##_init_key, \ aesni_##mode##_cipher, \ aes_##mode##_cleanup, \ sizeof(EVP_AES_##MODE##_CTX), \ NULL,NULL,aes_##mode##_ctrl,NULL }; \ static const EVP_CIPHER aes_##keylen##_##mode = { \ nid##_##keylen##_##mode,blocksize, \ (EVP_CIPH_##MODE##_MODE==EVP_CIPH_XTS_MODE?2:1)*keylen/8, ivlen, \ flags|EVP_CIPH_##MODE##_MODE, \ aes_##mode##_init_key, \ aes_##mode##_cipher, \ aes_##mode##_cleanup, \ sizeof(EVP_AES_##MODE##_CTX), \ NULL,NULL,aes_##mode##_ctrl,NULL }; \ const EVP_CIPHER *EVP_aes_##keylen##_##mode(void) \ { return AESNI_CAPABLE?&aesni_##keylen##_##mode:&aes_##keylen##_##mode; } #else #define BLOCK_CIPHER_generic(nid,keylen,blocksize,ivlen,nmode,mode,MODE,flags) \ static const EVP_CIPHER aes_##keylen##_##mode = { \ nid##_##keylen##_##nmode,blocksize,keylen/8,ivlen, \ flags|EVP_CIPH_##MODE##_MODE, \ aes_init_key, \ aes_##mode##_cipher, \ NULL, \ sizeof(EVP_AES_KEY), \ NULL,NULL,NULL,NULL }; \ const EVP_CIPHER *EVP_aes_##keylen##_##mode(void) \ { return &aes_##keylen##_##mode; } #define BLOCK_CIPHER_custom(nid,keylen,blocksize,ivlen,mode,MODE,flags) \ static const EVP_CIPHER aes_##keylen##_##mode = { \ nid##_##keylen##_##mode,blocksize, \ (EVP_CIPH_##MODE##_MODE==EVP_CIPH_XTS_MODE?2:1)*keylen/8, ivlen, \ flags|EVP_CIPH_##MODE##_MODE, \ aes_##mode##_init_key, \ aes_##mode##_cipher, \ aes_##mode##_cleanup, \ sizeof(EVP_AES_##MODE##_CTX), \ NULL,NULL,aes_##mode##_ctrl,NULL }; \ const EVP_CIPHER *EVP_aes_##keylen##_##mode(void) \ { return &aes_##keylen##_##mode; } #endif #define BLOCK_CIPHER_generic_pack(nid,keylen,flags) \ BLOCK_CIPHER_generic(nid,keylen,16,16,cbc,cbc,CBC,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \ BLOCK_CIPHER_generic(nid,keylen,16,0,ecb,ecb,ECB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \ BLOCK_CIPHER_generic(nid,keylen,1,16,ofb128,ofb,OFB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \ BLOCK_CIPHER_generic(nid,keylen,1,16,cfb128,cfb,CFB,flags|EVP_CIPH_FLAG_DEFAULT_ASN1) \ BLOCK_CIPHER_generic(nid,keylen,1,16,cfb1,cfb1,CFB,flags) \ BLOCK_CIPHER_generic(nid,keylen,1,16,cfb8,cfb8,CFB,flags) \ BLOCK_CIPHER_generic(nid,keylen,1,16,ctr,ctr,CTR,flags) static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { int ret, mode; EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data; mode = ctx->cipher->flags & EVP_CIPH_MODE; if ((mode == EVP_CIPH_ECB_MODE || mode == EVP_CIPH_CBC_MODE) && !enc) #ifdef BSAES_CAPABLE if (BSAES_CAPABLE && mode == EVP_CIPH_CBC_MODE) { ret = AES_set_decrypt_key(key, ctx->key_len * 8, &dat->ks); dat->block = (block128_f)AES_decrypt; dat->stream.cbc = (cbc128_f)bsaes_cbc_encrypt; } else #endif #ifdef VPAES_CAPABLE if (VPAES_CAPABLE) { ret = vpaes_set_decrypt_key(key, ctx->key_len * 8, &dat->ks); dat->block = (block128_f)vpaes_decrypt; dat->stream.cbc = mode == EVP_CIPH_CBC_MODE ? (cbc128_f)vpaes_cbc_encrypt : NULL; } else #endif { ret = AES_set_decrypt_key(key, ctx->key_len * 8, &dat->ks); dat->block = (block128_f)AES_decrypt; dat->stream.cbc = mode == EVP_CIPH_CBC_MODE ? (cbc128_f)AES_cbc_encrypt : NULL; } else #ifdef BSAES_CAPABLE if (BSAES_CAPABLE && mode == EVP_CIPH_CTR_MODE) { ret = AES_set_encrypt_key(key, ctx->key_len * 8, &dat->ks); dat->block = (block128_f)AES_encrypt; dat->stream.ctr = (ctr128_f)bsaes_ctr32_encrypt_blocks; } else #endif #ifdef VPAES_CAPABLE if (VPAES_CAPABLE) { ret = vpaes_set_encrypt_key(key, ctx->key_len * 8, &dat->ks); dat->block = (block128_f)vpaes_encrypt; dat->stream.cbc = mode == EVP_CIPH_CBC_MODE ? (cbc128_f)vpaes_cbc_encrypt : NULL; } else #endif { ret = AES_set_encrypt_key(key, ctx->key_len * 8, &dat->ks); dat->block = (block128_f)AES_encrypt; dat->stream.cbc = mode == EVP_CIPH_CBC_MODE ? (cbc128_f)AES_cbc_encrypt : NULL; #ifdef AES_CTR_ASM if (mode == EVP_CIPH_CTR_MODE) dat->stream.ctr = (ctr128_f)AES_ctr32_encrypt; #endif } if (ret < 0) { EVPerr(EVP_F_AES_INIT_KEY, EVP_R_AES_KEY_SETUP_FAILED); return 0; } return 1; } static int aes_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data; if (dat->stream.cbc) (*dat->stream.cbc)(in, out, len, &dat->ks, ctx->iv, ctx->encrypt); else if (ctx->encrypt) CRYPTO_cbc128_encrypt(in, out, len, &dat->ks, ctx->iv, dat->block); else CRYPTO_cbc128_decrypt(in, out, len, &dat->ks, ctx->iv, dat->block); return 1; } static int aes_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { size_t bl = ctx->cipher->block_size; size_t i; EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data; if (len < bl) return 1; for (i = 0, len -= bl; i <= len; i += bl) (*dat->block)(in + i, out + i, &dat->ks); return 1; } static int aes_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data; CRYPTO_ofb128_encrypt(in, out, len, &dat->ks, ctx->iv, &ctx->num, dat->block); return 1; } static int aes_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data; CRYPTO_cfb128_encrypt(in, out, len, &dat->ks, ctx->iv, &ctx->num, ctx->encrypt, dat->block); return 1; } static int aes_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data; CRYPTO_cfb128_8_encrypt(in, out, len, &dat->ks, ctx->iv, &ctx->num, ctx->encrypt, dat->block); return 1; } static int aes_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data; if (ctx->flags&EVP_CIPH_FLAG_LENGTH_BITS) { CRYPTO_cfb128_1_encrypt(in, out, len, &dat->ks, ctx->iv, &ctx->num, ctx->encrypt, dat->block); return 1; } while (len >= MAXBITCHUNK) { CRYPTO_cfb128_1_encrypt(in, out, MAXBITCHUNK*8, &dat->ks, ctx->iv, &ctx->num, ctx->encrypt, dat->block); len -= MAXBITCHUNK; } if (len) CRYPTO_cfb128_1_encrypt(in, out, len*8, &dat->ks, ctx->iv, &ctx->num, ctx->encrypt, dat->block); return 1; } static int aes_ctr_cipher (EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { unsigned int num = ctx->num; EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data; if (dat->stream.ctr) CRYPTO_ctr128_encrypt_ctr32(in, out, len, &dat->ks, ctx->iv, ctx->buf, &num, dat->stream.ctr); else CRYPTO_ctr128_encrypt(in, out, len, &dat->ks, ctx->iv, ctx->buf, &num, dat->block); ctx->num = (size_t)num; return 1; } BLOCK_CIPHER_generic_pack(NID_aes, 128, EVP_CIPH_FLAG_FIPS) BLOCK_CIPHER_generic_pack(NID_aes, 192, EVP_CIPH_FLAG_FIPS) BLOCK_CIPHER_generic_pack(NID_aes, 256, EVP_CIPH_FLAG_FIPS) static int aes_gcm_cleanup(EVP_CIPHER_CTX *c) { EVP_AES_GCM_CTX *gctx = c->cipher_data; if (gctx->iv != c->iv) free(gctx->iv); OPENSSL_cleanse(gctx, sizeof(*gctx)); return 1; } /* increment counter (64-bit int) by 1 */ static void ctr64_inc(unsigned char *counter) { int n = 8; unsigned char c; do { --n; c = counter[n]; ++c; counter[n] = c; if (c) return; } while (n); } static int aes_gcm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) { EVP_AES_GCM_CTX *gctx = c->cipher_data; switch (type) { case EVP_CTRL_INIT: gctx->key_set = 0; gctx->iv_set = 0; gctx->ivlen = c->cipher->iv_len; gctx->iv = c->iv; gctx->taglen = -1; gctx->iv_gen = 0; gctx->tls_aad_len = -1; return 1; case EVP_CTRL_GCM_SET_IVLEN: if (arg <= 0) return 0; /* Allocate memory for IV if needed */ if ((arg > EVP_MAX_IV_LENGTH) && (arg > gctx->ivlen)) { if (gctx->iv != c->iv) free(gctx->iv); gctx->iv = malloc(arg); if (!gctx->iv) return 0; } gctx->ivlen = arg; return 1; case EVP_CTRL_GCM_SET_TAG: if (arg <= 0 || arg > 16 || c->encrypt) return 0; memcpy(c->buf, ptr, arg); gctx->taglen = arg; return 1; case EVP_CTRL_GCM_GET_TAG: if (arg <= 0 || arg > 16 || !c->encrypt || gctx->taglen < 0) return 0; memcpy(ptr, c->buf, arg); return 1; case EVP_CTRL_GCM_SET_IV_FIXED: /* Special case: -1 length restores whole IV */ if (arg == -1) { memcpy(gctx->iv, ptr, gctx->ivlen); gctx->iv_gen = 1; return 1; } /* Fixed field must be at least 4 bytes and invocation field * at least 8. */ if ((arg < 4) || (gctx->ivlen - arg) < 8) return 0; if (arg) memcpy(gctx->iv, ptr, arg); if (c->encrypt && RAND_bytes(gctx->iv + arg, gctx->ivlen - arg) <= 0) return 0; gctx->iv_gen = 1; return 1; case EVP_CTRL_GCM_IV_GEN: if (gctx->iv_gen == 0 || gctx->key_set == 0) return 0; CRYPTO_gcm128_setiv(&gctx->gcm, gctx->iv, gctx->ivlen); if (arg <= 0 || arg > gctx->ivlen) arg = gctx->ivlen; memcpy(ptr, gctx->iv + gctx->ivlen - arg, arg); /* Invocation field will be at least 8 bytes in size and * so no need to check wrap around or increment more than * last 8 bytes. */ ctr64_inc(gctx->iv + gctx->ivlen - 8); gctx->iv_set = 1; return 1; case EVP_CTRL_GCM_SET_IV_INV: if (gctx->iv_gen == 0 || gctx->key_set == 0 || c->encrypt) return 0; memcpy(gctx->iv + gctx->ivlen - arg, ptr, arg); CRYPTO_gcm128_setiv(&gctx->gcm, gctx->iv, gctx->ivlen); gctx->iv_set = 1; return 1; case EVP_CTRL_AEAD_TLS1_AAD: /* Save the AAD for later use */ if (arg != 13) return 0; memcpy(c->buf, ptr, arg); gctx->tls_aad_len = arg; { unsigned int len = c->buf[arg - 2] << 8 | c->buf[arg - 1]; /* Correct length for explicit IV */ len -= EVP_GCM_TLS_EXPLICIT_IV_LEN; /* If decrypting correct for tag too */ if (!c->encrypt) len -= EVP_GCM_TLS_TAG_LEN; c->buf[arg - 2] = len >> 8; c->buf[arg - 1] = len & 0xff; } /* Extra padding: tag appended to record */ return EVP_GCM_TLS_TAG_LEN; case EVP_CTRL_COPY: { EVP_CIPHER_CTX *out = ptr; EVP_AES_GCM_CTX *gctx_out = out->cipher_data; if (gctx->gcm.key) { if (gctx->gcm.key != &gctx->ks) return 0; gctx_out->gcm.key = &gctx_out->ks; } if (gctx->iv == c->iv) gctx_out->iv = out->iv; else { gctx_out->iv = malloc(gctx->ivlen); if (!gctx_out->iv) return 0; memcpy(gctx_out->iv, gctx->iv, gctx->ivlen); } return 1; } default: return -1; } } static ctr128_f aes_gcm_set_key(AES_KEY *aes_key, GCM128_CONTEXT *gcm_ctx, const unsigned char *key, size_t key_len) { #ifdef BSAES_CAPABLE if (BSAES_CAPABLE) { AES_set_encrypt_key(key, key_len * 8, aes_key); CRYPTO_gcm128_init(gcm_ctx, aes_key, (block128_f)AES_encrypt); return (ctr128_f)bsaes_ctr32_encrypt_blocks; } else #endif #ifdef VPAES_CAPABLE if (VPAES_CAPABLE) { vpaes_set_encrypt_key(key, key_len * 8, aes_key); CRYPTO_gcm128_init(gcm_ctx, aes_key, (block128_f)vpaes_encrypt); return NULL; } else #endif (void)0; /* terminate potentially open 'else' */ AES_set_encrypt_key(key, key_len * 8, aes_key); CRYPTO_gcm128_init(gcm_ctx, aes_key, (block128_f)AES_encrypt); #ifdef AES_CTR_ASM return (ctr128_f)AES_ctr32_encrypt; #else return NULL; #endif } static int aes_gcm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { EVP_AES_GCM_CTX *gctx = ctx->cipher_data; if (!iv && !key) return 1; if (key) { gctx->ctr = aes_gcm_set_key(&gctx->ks, &gctx->gcm, key, ctx->key_len); /* If we have an iv can set it directly, otherwise use * saved IV. */ if (iv == NULL && gctx->iv_set) iv = gctx->iv; if (iv) { CRYPTO_gcm128_setiv(&gctx->gcm, iv, gctx->ivlen); gctx->iv_set = 1; } gctx->key_set = 1; } else { /* If key set use IV, otherwise copy */ if (gctx->key_set) CRYPTO_gcm128_setiv(&gctx->gcm, iv, gctx->ivlen); else memcpy(gctx->iv, iv, gctx->ivlen); gctx->iv_set = 1; gctx->iv_gen = 0; } return 1; } /* Handle TLS GCM packet format. This consists of the last portion of the IV * followed by the payload and finally the tag. On encrypt generate IV, * encrypt payload and write the tag. On verify retrieve IV, decrypt payload * and verify tag. */ static int aes_gcm_tls_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { EVP_AES_GCM_CTX *gctx = ctx->cipher_data; int rv = -1; /* Encrypt/decrypt must be performed in place */ if (out != in || len < (EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN)) return -1; /* Set IV from start of buffer or generate IV and write to start * of buffer. */ if (EVP_CIPHER_CTX_ctrl(ctx, ctx->encrypt ? EVP_CTRL_GCM_IV_GEN : EVP_CTRL_GCM_SET_IV_INV, EVP_GCM_TLS_EXPLICIT_IV_LEN, out) <= 0) goto err; /* Use saved AAD */ if (CRYPTO_gcm128_aad(&gctx->gcm, ctx->buf, gctx->tls_aad_len)) goto err; /* Fix buffer and length to point to payload */ in += EVP_GCM_TLS_EXPLICIT_IV_LEN; out += EVP_GCM_TLS_EXPLICIT_IV_LEN; len -= EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN; if (ctx->encrypt) { /* Encrypt payload */ if (gctx->ctr) { if (CRYPTO_gcm128_encrypt_ctr32(&gctx->gcm, in, out, len, gctx->ctr)) goto err; } else { if (CRYPTO_gcm128_encrypt(&gctx->gcm, in, out, len)) goto err; } out += len; /* Finally write tag */ CRYPTO_gcm128_tag(&gctx->gcm, out, EVP_GCM_TLS_TAG_LEN); rv = len + EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN; } else { /* Decrypt */ if (gctx->ctr) { if (CRYPTO_gcm128_decrypt_ctr32(&gctx->gcm, in, out, len, gctx->ctr)) goto err; } else { if (CRYPTO_gcm128_decrypt(&gctx->gcm, in, out, len)) goto err; } /* Retrieve tag */ CRYPTO_gcm128_tag(&gctx->gcm, ctx->buf, EVP_GCM_TLS_TAG_LEN); /* If tag mismatch wipe buffer */ if (memcmp(ctx->buf, in + len, EVP_GCM_TLS_TAG_LEN)) { OPENSSL_cleanse(out, len); goto err; } rv = len; } err: gctx->iv_set = 0; gctx->tls_aad_len = -1; return rv; } static int aes_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { EVP_AES_GCM_CTX *gctx = ctx->cipher_data; /* If not set up, return error */ if (!gctx->key_set) return -1; if (gctx->tls_aad_len >= 0) return aes_gcm_tls_cipher(ctx, out, in, len); if (!gctx->iv_set) return -1; if (in) { if (out == NULL) { if (CRYPTO_gcm128_aad(&gctx->gcm, in, len)) return -1; } else if (ctx->encrypt) { if (gctx->ctr) { if (CRYPTO_gcm128_encrypt_ctr32(&gctx->gcm, in, out, len, gctx->ctr)) return -1; } else { if (CRYPTO_gcm128_encrypt(&gctx->gcm, in, out, len)) return -1; } } else { if (gctx->ctr) { if (CRYPTO_gcm128_decrypt_ctr32(&gctx->gcm, in, out, len, gctx->ctr)) return -1; } else { if (CRYPTO_gcm128_decrypt(&gctx->gcm, in, out, len)) return -1; } } return len; } else { if (!ctx->encrypt) { if (gctx->taglen < 0) return -1; if (CRYPTO_gcm128_finish(&gctx->gcm, ctx->buf, gctx->taglen) != 0) return -1; gctx->iv_set = 0; return 0; } CRYPTO_gcm128_tag(&gctx->gcm, ctx->buf, 16); gctx->taglen = 16; /* Don't reuse the IV */ gctx->iv_set = 0; return 0; } } #define CUSTOM_FLAGS \ ( EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CUSTOM_IV | \ EVP_CIPH_FLAG_CUSTOM_CIPHER | EVP_CIPH_ALWAYS_CALL_INIT | \ EVP_CIPH_CTRL_INIT | EVP_CIPH_CUSTOM_COPY ) BLOCK_CIPHER_custom(NID_aes, 128, 1, 12, gcm, GCM, EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS) BLOCK_CIPHER_custom(NID_aes, 192, 1, 12, gcm, GCM, EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS) BLOCK_CIPHER_custom(NID_aes, 256, 1, 12, gcm, GCM, EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS) static int aes_xts_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) { EVP_AES_XTS_CTX *xctx = c->cipher_data; switch (type) { case EVP_CTRL_INIT: /* * key1 and key2 are used as an indicator both key and IV * are set */ xctx->xts.key1 = NULL; xctx->xts.key2 = NULL; return 1; case EVP_CTRL_COPY: { EVP_CIPHER_CTX *out = ptr; EVP_AES_XTS_CTX *xctx_out = out->cipher_data; if (xctx->xts.key1) { if (xctx->xts.key1 != &xctx->ks1) return 0; xctx_out->xts.key1 = &xctx_out->ks1; } if (xctx->xts.key2) { if (xctx->xts.key2 != &xctx->ks2) return 0; xctx_out->xts.key2 = &xctx_out->ks2; } return 1; } } return -1; } static int aes_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { EVP_AES_XTS_CTX *xctx = ctx->cipher_data; if (!iv && !key) return 1; if (key) do { #ifdef AES_XTS_ASM xctx->stream = enc ? AES_xts_encrypt : AES_xts_decrypt; #else xctx->stream = NULL; #endif /* key_len is two AES keys */ #ifdef BSAES_CAPABLE if (BSAES_CAPABLE) xctx->stream = enc ? bsaes_xts_encrypt : bsaes_xts_decrypt; else #endif #ifdef VPAES_CAPABLE if (VPAES_CAPABLE) { if (enc) { vpaes_set_encrypt_key(key, ctx->key_len * 4, &xctx->ks1); xctx->xts.block1 = (block128_f)vpaes_encrypt; } else { vpaes_set_decrypt_key(key, ctx->key_len * 4, &xctx->ks1); xctx->xts.block1 = (block128_f)vpaes_decrypt; } vpaes_set_encrypt_key(key + ctx->key_len / 2, ctx->key_len * 4, &xctx->ks2); xctx->xts.block2 = (block128_f)vpaes_encrypt; xctx->xts.key1 = &xctx->ks1; break; } else #endif (void)0; /* terminate potentially open 'else' */ if (enc) { AES_set_encrypt_key(key, ctx->key_len * 4, &xctx->ks1); xctx->xts.block1 = (block128_f)AES_encrypt; } else { AES_set_decrypt_key(key, ctx->key_len * 4, &xctx->ks1); xctx->xts.block1 = (block128_f)AES_decrypt; } AES_set_encrypt_key(key + ctx->key_len / 2, ctx->key_len * 4, &xctx->ks2); xctx->xts.block2 = (block128_f)AES_encrypt; xctx->xts.key1 = &xctx->ks1; } while (0); if (iv) { xctx->xts.key2 = &xctx->ks2; memcpy(ctx->iv, iv, 16); } return 1; } static int aes_xts_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { EVP_AES_XTS_CTX *xctx = ctx->cipher_data; if (!xctx->xts.key1 || !xctx->xts.key2) return 0; if (!out || !in || len < AES_BLOCK_SIZE) return 0; if (xctx->stream) (*xctx->stream)(in, out, len, xctx->xts.key1, xctx->xts.key2, ctx->iv); else if (CRYPTO_xts128_encrypt(&xctx->xts, ctx->iv, in, out, len, ctx->encrypt)) return 0; return 1; } #define aes_xts_cleanup NULL #define XTS_FLAGS \ ( EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CUSTOM_IV | \ EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT | EVP_CIPH_CUSTOM_COPY ) BLOCK_CIPHER_custom(NID_aes, 128, 1, 16, xts, XTS, EVP_CIPH_FLAG_FIPS|XTS_FLAGS) BLOCK_CIPHER_custom(NID_aes, 256, 1, 16, xts, XTS, EVP_CIPH_FLAG_FIPS|XTS_FLAGS) static int aes_ccm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) { EVP_AES_CCM_CTX *cctx = c->cipher_data; switch (type) { case EVP_CTRL_INIT: cctx->key_set = 0; cctx->iv_set = 0; cctx->L = 8; cctx->M = 12; cctx->tag_set = 0; cctx->len_set = 0; return 1; case EVP_CTRL_CCM_SET_IVLEN: arg = 15 - arg; case EVP_CTRL_CCM_SET_L: if (arg < 2 || arg > 8) return 0; cctx->L = arg; return 1; case EVP_CTRL_CCM_SET_TAG: if ((arg & 1) || arg < 4 || arg > 16) return 0; if ((c->encrypt && ptr) || (!c->encrypt && !ptr)) return 0; if (ptr) { cctx->tag_set = 1; memcpy(c->buf, ptr, arg); } cctx->M = arg; return 1; case EVP_CTRL_CCM_GET_TAG: if (!c->encrypt || !cctx->tag_set) return 0; if (!CRYPTO_ccm128_tag(&cctx->ccm, ptr, (size_t)arg)) return 0; cctx->tag_set = 0; cctx->iv_set = 0; cctx->len_set = 0; return 1; case EVP_CTRL_COPY: { EVP_CIPHER_CTX *out = ptr; EVP_AES_CCM_CTX *cctx_out = out->cipher_data; if (cctx->ccm.key) { if (cctx->ccm.key != &cctx->ks) return 0; cctx_out->ccm.key = &cctx_out->ks; } return 1; } default: return -1; } } static int aes_ccm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { EVP_AES_CCM_CTX *cctx = ctx->cipher_data; if (!iv && !key) return 1; if (key) do { #ifdef VPAES_CAPABLE if (VPAES_CAPABLE) { vpaes_set_encrypt_key(key, ctx->key_len*8, &cctx->ks); CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, &cctx->ks, (block128_f)vpaes_encrypt); cctx->str = NULL; cctx->key_set = 1; break; } #endif AES_set_encrypt_key(key, ctx->key_len * 8, &cctx->ks); CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, &cctx->ks, (block128_f)AES_encrypt); cctx->str = NULL; cctx->key_set = 1; } while (0); if (iv) { memcpy(ctx->iv, iv, 15 - cctx->L); cctx->iv_set = 1; } return 1; } static int aes_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { EVP_AES_CCM_CTX *cctx = ctx->cipher_data; CCM128_CONTEXT *ccm = &cctx->ccm; /* If not set up, return error */ if (!cctx->iv_set && !cctx->key_set) return -1; if (!ctx->encrypt && !cctx->tag_set) return -1; if (!out) { if (!in) { if (CRYPTO_ccm128_setiv(ccm, ctx->iv, 15 - cctx->L, len)) return -1; cctx->len_set = 1; return len; } /* If have AAD need message length */ if (!cctx->len_set && len) return -1; CRYPTO_ccm128_aad(ccm, in, len); return len; } /* EVP_*Final() doesn't return any data */ if (!in) return 0; /* If not set length yet do it */ if (!cctx->len_set) { if (CRYPTO_ccm128_setiv(ccm, ctx->iv, 15 - cctx->L, len)) return -1; cctx->len_set = 1; } if (ctx->encrypt) { if (cctx->str ? CRYPTO_ccm128_encrypt_ccm64(ccm, in, out, len, cctx->str) : CRYPTO_ccm128_encrypt(ccm, in, out, len)) return -1; cctx->tag_set = 1; return len; } else { int rv = -1; if (cctx->str ? !CRYPTO_ccm128_decrypt_ccm64(ccm, in, out, len, cctx->str) : !CRYPTO_ccm128_decrypt(ccm, in, out, len)) { unsigned char tag[16]; if (CRYPTO_ccm128_tag(ccm, tag, cctx->M)) { if (!memcmp(tag, ctx->buf, cctx->M)) rv = len; } } if (rv == -1) OPENSSL_cleanse(out, len); cctx->iv_set = 0; cctx->tag_set = 0; cctx->len_set = 0; return rv; } } #define aes_ccm_cleanup NULL BLOCK_CIPHER_custom(NID_aes, 128, 1, 12, ccm, CCM, EVP_CIPH_FLAG_FIPS|CUSTOM_FLAGS) BLOCK_CIPHER_custom(NID_aes, 192, 1, 12, ccm, CCM, EVP_CIPH_FLAG_FIPS|CUSTOM_FLAGS) BLOCK_CIPHER_custom(NID_aes, 256, 1, 12, ccm, CCM, EVP_CIPH_FLAG_FIPS|CUSTOM_FLAGS) #define EVP_AEAD_AES_GCM_TAG_LEN 16 struct aead_aes_gcm_ctx { union { double align; AES_KEY ks; } ks; GCM128_CONTEXT gcm; ctr128_f ctr; unsigned char tag_len; }; static int aead_aes_gcm_init(EVP_AEAD_CTX *ctx, const unsigned char *key, size_t key_len, size_t tag_len) { struct aead_aes_gcm_ctx *gcm_ctx; const size_t key_bits = key_len * 8; /* EVP_AEAD_CTX_init should catch this. */ if (key_bits != 128 && key_bits != 256) { EVPerr(EVP_F_AEAD_AES_GCM_INIT, EVP_R_BAD_KEY_LENGTH); return 0; } if (tag_len == EVP_AEAD_DEFAULT_TAG_LENGTH) tag_len = EVP_AEAD_AES_GCM_TAG_LEN; if (tag_len > EVP_AEAD_AES_GCM_TAG_LEN) { EVPerr(EVP_F_AEAD_AES_GCM_INIT, EVP_R_TAG_TOO_LARGE); return 0; } gcm_ctx = malloc(sizeof(struct aead_aes_gcm_ctx)); if (gcm_ctx == NULL) return 0; #ifdef AESNI_CAPABLE if (AESNI_CAPABLE) { aesni_set_encrypt_key(key, key_bits, &gcm_ctx->ks.ks); CRYPTO_gcm128_init(&gcm_ctx->gcm, &gcm_ctx->ks.ks, (block128_f)aesni_encrypt); gcm_ctx->ctr = (ctr128_f) aesni_ctr32_encrypt_blocks; } else #endif { gcm_ctx->ctr = aes_gcm_set_key(&gcm_ctx->ks.ks, &gcm_ctx->gcm, key, key_len); } gcm_ctx->tag_len = tag_len; ctx->aead_state = gcm_ctx; return 1; } static void aead_aes_gcm_cleanup(EVP_AEAD_CTX *ctx) { struct aead_aes_gcm_ctx *gcm_ctx = ctx->aead_state; OPENSSL_cleanse(gcm_ctx, sizeof(*gcm_ctx)); free(gcm_ctx); } static int aead_aes_gcm_seal(const EVP_AEAD_CTX *ctx, unsigned char *out, size_t *out_len, size_t max_out_len, const unsigned char *nonce, size_t nonce_len, const unsigned char *in, size_t in_len, const unsigned char *ad, size_t ad_len) { const struct aead_aes_gcm_ctx *gcm_ctx = ctx->aead_state; GCM128_CONTEXT gcm; size_t bulk = 0; if (max_out_len < in_len + gcm_ctx->tag_len) { EVPerr(EVP_F_AEAD_AES_GCM_SEAL, EVP_R_BUFFER_TOO_SMALL); return 0; } memcpy(&gcm, &gcm_ctx->gcm, sizeof(gcm)); CRYPTO_gcm128_setiv(&gcm, nonce, nonce_len); if (ad_len > 0 && CRYPTO_gcm128_aad(&gcm, ad, ad_len)) return 0; if (gcm_ctx->ctr) { if (CRYPTO_gcm128_encrypt_ctr32(&gcm, in + bulk, out + bulk, in_len - bulk, gcm_ctx->ctr)) return 0; } else { if (CRYPTO_gcm128_encrypt(&gcm, in + bulk, out + bulk, in_len - bulk)) return 0; } CRYPTO_gcm128_tag(&gcm, out + in_len, gcm_ctx->tag_len); *out_len = in_len + gcm_ctx->tag_len; return 1; } static int aead_aes_gcm_open(const EVP_AEAD_CTX *ctx, unsigned char *out, size_t *out_len, size_t max_out_len, const unsigned char *nonce, size_t nonce_len, const unsigned char *in, size_t in_len, const unsigned char *ad, size_t ad_len) { const struct aead_aes_gcm_ctx *gcm_ctx = ctx->aead_state; unsigned char tag[EVP_AEAD_AES_GCM_TAG_LEN]; GCM128_CONTEXT gcm; size_t plaintext_len; size_t bulk = 0; if (in_len < gcm_ctx->tag_len) { EVPerr(EVP_F_AEAD_AES_GCM_OPEN, EVP_R_BAD_DECRYPT); return 0; } plaintext_len = in_len - gcm_ctx->tag_len; if (max_out_len < plaintext_len) { EVPerr(EVP_F_AEAD_AES_GCM_OPEN, EVP_R_BUFFER_TOO_SMALL); return 0; } memcpy(&gcm, &gcm_ctx->gcm, sizeof(gcm)); CRYPTO_gcm128_setiv(&gcm, nonce, nonce_len); if (CRYPTO_gcm128_aad(&gcm, ad, ad_len)) return 0; if (gcm_ctx->ctr) { if (CRYPTO_gcm128_decrypt_ctr32(&gcm, in + bulk, out + bulk, in_len - bulk - gcm_ctx->tag_len, gcm_ctx->ctr)) return 0; } else { if (CRYPTO_gcm128_decrypt(&gcm, in + bulk, out + bulk, in_len - bulk - gcm_ctx->tag_len)) return 0; } CRYPTO_gcm128_tag(&gcm, tag, gcm_ctx->tag_len); if (CRYPTO_memcmp(tag, in + plaintext_len, gcm_ctx->tag_len) != 0) { EVPerr(EVP_F_AEAD_AES_GCM_OPEN, EVP_R_BAD_DECRYPT); return 0; } *out_len = plaintext_len; return 1; } static const EVP_AEAD aead_aes_128_gcm = { .key_len = 16, .nonce_len = 12, .overhead = EVP_AEAD_AES_GCM_TAG_LEN, .max_tag_len = EVP_AEAD_AES_GCM_TAG_LEN, .init = aead_aes_gcm_init, .cleanup = aead_aes_gcm_cleanup, .seal = aead_aes_gcm_seal, .open = aead_aes_gcm_open, }; static const EVP_AEAD aead_aes_256_gcm = { .key_len = 32, .nonce_len = 12, .overhead = EVP_AEAD_AES_GCM_TAG_LEN, .max_tag_len = EVP_AEAD_AES_GCM_TAG_LEN, .init = aead_aes_gcm_init, .cleanup = aead_aes_gcm_cleanup, .seal = aead_aes_gcm_seal, .open = aead_aes_gcm_open, }; const EVP_AEAD * EVP_aead_aes_128_gcm(void) { return &aead_aes_128_gcm; } const EVP_AEAD * EVP_aead_aes_256_gcm(void) { return &aead_aes_256_gcm; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/evp/e_chacha.c0000644000175000017500000000373112360020705020730 0ustar /* $OpenBSD: e_chacha.c,v 1.3 2014/06/12 15:49:29 deraadt Exp $ */ /* * Copyright (c) 2014 Joel Sing * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #ifndef OPENSSL_NO_CHACHA #include #include #include #include "evp_locl.h" static int chacha_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len); static int chacha_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); static const EVP_CIPHER chacha20_cipher = { .nid = NID_chacha20, .block_size = 1, .key_len = 32, .iv_len = 8, .flags = EVP_CIPH_STREAM_CIPHER, .init = chacha_init, .do_cipher = chacha_cipher, .ctx_size = sizeof(ChaCha_ctx) }; const EVP_CIPHER * EVP_chacha20(void) { return (&chacha20_cipher); } static int chacha_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { ChaCha_set_key((ChaCha_ctx *)ctx->cipher_data, key, EVP_CIPHER_CTX_key_length(ctx) * 8); ChaCha_set_iv((ChaCha_ctx *)ctx->cipher_data, iv, NULL); return 1; } static int chacha_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { ChaCha((ChaCha_ctx *)ctx->cipher_data, out, in, len); return 1; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/stack/0000755000000000000000000000000012666635521021157 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/stack/stack.c0000644000175000017500000002007112360020706020632 0ustar /* $OpenBSD: stack.c,v 1.17 2014/07/10 13:58:23 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* Code for stacks * Author - Eric Young v 1.0 * 1.2 eay 12-Mar-97 - Modified sk_find so that it _DOES_ return the * lowest index for the searched item. * * 1.1 eay - Take from netdb and added to SSLeay * * 1.0 eay - First version 29/07/92 */ #include #include #include #include #undef MIN_NODES #define MIN_NODES 4 #include int (*sk_set_cmp_func(_STACK *sk, int (*c)(const void *, const void *)))( const void *, const void *) { int (*old)(const void *, const void *) = sk->comp; if (sk->comp != c) sk->sorted = 0; sk->comp = c; return old; } _STACK * sk_dup(_STACK *sk) { _STACK *ret; char **s; if ((ret = sk_new(sk->comp)) == NULL) goto err; s = reallocarray(ret->data, sk->num_alloc, sizeof(char *)); if (s == NULL) goto err; ret->data = s; ret->num = sk->num; memcpy(ret->data, sk->data, sizeof(char *) * sk->num); ret->sorted = sk->sorted; ret->num_alloc = sk->num_alloc; ret->comp = sk->comp; return (ret); err: if (ret) sk_free(ret); return (NULL); } _STACK * sk_new_null(void) { return sk_new((int (*)(const void *, const void *))0); } _STACK * sk_new(int (*c)(const void *, const void *)) { _STACK *ret; int i; if ((ret = malloc(sizeof(_STACK))) == NULL) goto err; if ((ret->data = reallocarray(NULL, MIN_NODES, sizeof(char *))) == NULL) goto err; for (i = 0; i < MIN_NODES; i++) ret->data[i] = NULL; ret->comp = c; ret->num_alloc = MIN_NODES; ret->num = 0; ret->sorted = 0; return (ret); err: free(ret); return (NULL); } int sk_insert(_STACK *st, void *data, int loc) { char **s; if (st == NULL) return 0; if (st->num_alloc <= st->num + 1) { s = reallocarray(st->data, st->num_alloc, 2 * sizeof(char *)); if (s == NULL) return (0); st->data = s; st->num_alloc *= 2; } if ((loc >= (int)st->num) || (loc < 0)) st->data[st->num] = data; else { memmove(&(st->data[loc + 1]), &(st->data[loc]), sizeof(char *)*(st->num - loc)); st->data[loc] = data; } st->num++; st->sorted = 0; return (st->num); } void * sk_delete_ptr(_STACK *st, void *p) { int i; for (i = 0; i < st->num; i++) if (st->data[i] == p) return (sk_delete(st, i)); return (NULL); } void * sk_delete(_STACK *st, int loc) { char *ret; if (!st || (loc < 0) || (loc >= st->num)) return NULL; ret = st->data[loc]; if (loc != st->num - 1) { memmove(&(st->data[loc]), &(st->data[loc + 1]), sizeof(char *)*(st->num - 1 - loc)); } st->num--; return (ret); } static int internal_find(_STACK *st, void *data, int ret_val_options) { const void * const *r; int i; if (st == NULL) return -1; if (st->comp == NULL) { for (i = 0; i < st->num; i++) if (st->data[i] == data) return (i); return (-1); } sk_sort(st); if (data == NULL) return (-1); r = OBJ_bsearch_ex_(&data, st->data, st->num, sizeof(void *), st->comp, ret_val_options); if (r == NULL) return (-1); return (int)((char **)r - st->data); } int sk_find(_STACK *st, void *data) { return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH); } int sk_find_ex(_STACK *st, void *data) { return internal_find(st, data, OBJ_BSEARCH_VALUE_ON_NOMATCH); } int sk_push(_STACK *st, void *data) { return (sk_insert(st, data, st->num)); } int sk_unshift(_STACK *st, void *data) { return (sk_insert(st, data, 0)); } void * sk_shift(_STACK *st) { if (st == NULL) return (NULL); if (st->num <= 0) return (NULL); return (sk_delete(st, 0)); } void * sk_pop(_STACK *st) { if (st == NULL) return (NULL); if (st->num <= 0) return (NULL); return (sk_delete(st, st->num - 1)); } void sk_zero(_STACK *st) { if (st == NULL) return; if (st->num <= 0) return; memset(st->data, 0, sizeof(st->data)*st->num); st->num = 0; } void sk_pop_free(_STACK *st, void (*func)(void *)) { int i; if (st == NULL) return; for (i = 0; i < st->num; i++) if (st->data[i] != NULL) func(st->data[i]); sk_free(st); } void sk_free(_STACK *st) { if (st == NULL) return; free(st->data); free(st); } int sk_num(const _STACK *st) { if (st == NULL) return -1; return st->num; } void * sk_value(const _STACK *st, int i) { if (!st || (i < 0) || (i >= st->num)) return NULL; return st->data[i]; } void * sk_set(_STACK *st, int i, void *value) { if (!st || (i < 0) || (i >= st->num)) return NULL; return (st->data[i] = value); } void sk_sort(_STACK *st) { if (st && !st->sorted) { int (*comp_func)(const void *, const void *); /* same comment as in sk_find ... previously st->comp was declared * as a (void*,void*) callback type, but this made the population * of the callback pointer illogical - our callbacks compare * type** with type**, so we leave the casting until absolutely * necessary (ie. "now"). */ comp_func = (int (*)(const void *, const void *))(st->comp); qsort(st->data, st->num, sizeof(char *), comp_func); st->sorted = 1; } } int sk_is_sorted(const _STACK *st) { if (!st) return 1; return st->sorted; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/o_time.h0000644000175000017500000000547712360020705017715 0ustar /* $OpenBSD$ */ /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #ifndef HEADER_O_TIME_H #define HEADER_O_TIME_H #include int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec); #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/poly1305/0000755000000000000000000000000012666635521021346 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/poly1305/poly1305.c0000644000175000017500000000227012360020706021211 0ustar /* $OpenBSD$ */ /* * Copyright (c) 2014 Joel Sing * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include "poly1305-donna.c" void CRYPTO_poly1305_init(poly1305_context *ctx, const unsigned char key[32]) { poly1305_init(ctx, key); } void CRYPTO_poly1305_update(poly1305_context *ctx, const unsigned char *in, size_t len) { poly1305_update(ctx, in, len); } void CRYPTO_poly1305_finish(poly1305_context *ctx, unsigned char mac[16]) { poly1305_finish(ctx, mac); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/poly1305/poly1305-donna.c0000644000175000017500000001712612360020706022314 0ustar /* $OpenBSD$ */ /* * Public Domain poly1305 from Andrew Moon * Based on poly1305-donna.c, poly1305-donna-32.h and poly1305-donna.h from: * https://github.com/floodyberry/poly1305-donna */ #include static inline void poly1305_init(poly1305_context *ctx, const unsigned char key[32]); static inline void poly1305_update(poly1305_context *ctx, const unsigned char *m, size_t bytes); static inline void poly1305_finish(poly1305_context *ctx, unsigned char mac[16]); /* * poly1305 implementation using 32 bit * 32 bit = 64 bit multiplication * and 64 bit addition. */ #define poly1305_block_size 16 /* 17 + sizeof(size_t) + 14*sizeof(unsigned long) */ typedef struct poly1305_state_internal_t { unsigned long r[5]; unsigned long h[5]; unsigned long pad[4]; size_t leftover; unsigned char buffer[poly1305_block_size]; unsigned char final; } poly1305_state_internal_t; /* interpret four 8 bit unsigned integers as a 32 bit unsigned integer in little endian */ static unsigned long U8TO32(const unsigned char *p) { return (((unsigned long)(p[0] & 0xff)) | ((unsigned long)(p[1] & 0xff) << 8) | ((unsigned long)(p[2] & 0xff) << 16) | ((unsigned long)(p[3] & 0xff) << 24)); } /* store a 32 bit unsigned integer as four 8 bit unsigned integers in little endian */ static void U32TO8(unsigned char *p, unsigned long v) { p[0] = (v) & 0xff; p[1] = (v >> 8) & 0xff; p[2] = (v >> 16) & 0xff; p[3] = (v >> 24) & 0xff; } static inline void poly1305_init(poly1305_context *ctx, const unsigned char key[32]) { poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx; /* r &= 0xffffffc0ffffffc0ffffffc0fffffff */ st->r[0] = (U8TO32(&key[0])) & 0x3ffffff; st->r[1] = (U8TO32(&key[3]) >> 2) & 0x3ffff03; st->r[2] = (U8TO32(&key[6]) >> 4) & 0x3ffc0ff; st->r[3] = (U8TO32(&key[9]) >> 6) & 0x3f03fff; st->r[4] = (U8TO32(&key[12]) >> 8) & 0x00fffff; /* h = 0 */ st->h[0] = 0; st->h[1] = 0; st->h[2] = 0; st->h[3] = 0; st->h[4] = 0; /* save pad for later */ st->pad[0] = U8TO32(&key[16]); st->pad[1] = U8TO32(&key[20]); st->pad[2] = U8TO32(&key[24]); st->pad[3] = U8TO32(&key[28]); st->leftover = 0; st->final = 0; } static void poly1305_blocks(poly1305_state_internal_t *st, const unsigned char *m, size_t bytes) { const unsigned long hibit = (st->final) ? 0 : (1 << 24); /* 1 << 128 */ unsigned long r0, r1, r2, r3, r4; unsigned long s1, s2, s3, s4; unsigned long h0, h1, h2, h3, h4; unsigned long long d0, d1, d2, d3, d4; unsigned long c; r0 = st->r[0]; r1 = st->r[1]; r2 = st->r[2]; r3 = st->r[3]; r4 = st->r[4]; s1 = r1 * 5; s2 = r2 * 5; s3 = r3 * 5; s4 = r4 * 5; h0 = st->h[0]; h1 = st->h[1]; h2 = st->h[2]; h3 = st->h[3]; h4 = st->h[4]; while (bytes >= poly1305_block_size) { /* h += m[i] */ h0 += (U8TO32(m + 0)) & 0x3ffffff; h1 += (U8TO32(m + 3) >> 2) & 0x3ffffff; h2 += (U8TO32(m + 6) >> 4) & 0x3ffffff; h3 += (U8TO32(m + 9) >> 6) & 0x3ffffff; h4 += (U8TO32(m + 12) >> 8) | hibit; /* h *= r */ d0 = ((unsigned long long)h0 * r0) + ((unsigned long long)h1 * s4) + ((unsigned long long)h2 * s3) + ((unsigned long long)h3 * s2) + ((unsigned long long)h4 * s1); d1 = ((unsigned long long)h0 * r1) + ((unsigned long long)h1 * r0) + ((unsigned long long)h2 * s4) + ((unsigned long long)h3 * s3) + ((unsigned long long)h4 * s2); d2 = ((unsigned long long)h0 * r2) + ((unsigned long long)h1 * r1) + ((unsigned long long)h2 * r0) + ((unsigned long long)h3 * s4) + ((unsigned long long)h4 * s3); d3 = ((unsigned long long)h0 * r3) + ((unsigned long long)h1 * r2) + ((unsigned long long)h2 * r1) + ((unsigned long long)h3 * r0) + ((unsigned long long)h4 * s4); d4 = ((unsigned long long)h0 * r4) + ((unsigned long long)h1 * r3) + ((unsigned long long)h2 * r2) + ((unsigned long long)h3 * r1) + ((unsigned long long)h4 * r0); /* (partial) h %= p */ c = (unsigned long)(d0 >> 26); h0 = (unsigned long)d0 & 0x3ffffff; d1 += c; c = (unsigned long)(d1 >> 26); h1 = (unsigned long)d1 & 0x3ffffff; d2 += c; c = (unsigned long)(d2 >> 26); h2 = (unsigned long)d2 & 0x3ffffff; d3 += c; c = (unsigned long)(d3 >> 26); h3 = (unsigned long)d3 & 0x3ffffff; d4 += c; c = (unsigned long)(d4 >> 26); h4 = (unsigned long)d4 & 0x3ffffff; h0 += c * 5; c = (h0 >> 26); h0 = h0 & 0x3ffffff; h1 += c; m += poly1305_block_size; bytes -= poly1305_block_size; } st->h[0] = h0; st->h[1] = h1; st->h[2] = h2; st->h[3] = h3; st->h[4] = h4; } static inline void poly1305_update(poly1305_context *ctx, const unsigned char *m, size_t bytes) { poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx; size_t i; /* handle leftover */ if (st->leftover) { size_t want = (poly1305_block_size - st->leftover); if (want > bytes) want = bytes; for (i = 0; i < want; i++) st->buffer[st->leftover + i] = m[i]; bytes -= want; m += want; st->leftover += want; if (st->leftover < poly1305_block_size) return; poly1305_blocks(st, st->buffer, poly1305_block_size); st->leftover = 0; } /* process full blocks */ if (bytes >= poly1305_block_size) { size_t want = (bytes & ~(poly1305_block_size - 1)); poly1305_blocks(st, m, want); m += want; bytes -= want; } /* store leftover */ if (bytes) { for (i = 0; i < bytes; i++) st->buffer[st->leftover + i] = m[i]; st->leftover += bytes; } } static inline void poly1305_finish(poly1305_context *ctx, unsigned char mac[16]) { poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx; unsigned long h0, h1, h2, h3, h4, c; unsigned long g0, g1, g2, g3, g4; unsigned long long f; unsigned long mask; /* process the remaining block */ if (st->leftover) { size_t i = st->leftover; st->buffer[i++] = 1; for (; i < poly1305_block_size; i++) st->buffer[i] = 0; st->final = 1; poly1305_blocks(st, st->buffer, poly1305_block_size); } /* fully carry h */ h0 = st->h[0]; h1 = st->h[1]; h2 = st->h[2]; h3 = st->h[3]; h4 = st->h[4]; c = h1 >> 26; h1 = h1 & 0x3ffffff; h2 += c; c = h2 >> 26; h2 = h2 & 0x3ffffff; h3 += c; c = h3 >> 26; h3 = h3 & 0x3ffffff; h4 += c; c = h4 >> 26; h4 = h4 & 0x3ffffff; h0 += c * 5; c = h0 >> 26; h0 = h0 & 0x3ffffff; h1 += c; /* compute h + -p */ g0 = h0 + 5; c = g0 >> 26; g0 &= 0x3ffffff; g1 = h1 + c; c = g1 >> 26; g1 &= 0x3ffffff; g2 = h2 + c; c = g2 >> 26; g2 &= 0x3ffffff; g3 = h3 + c; c = g3 >> 26; g3 &= 0x3ffffff; g4 = h4 + c - (1 << 26); /* select h if h < p, or h + -p if h >= p */ mask = (g4 >> ((sizeof(unsigned long) * 8) - 1)) - 1; g0 &= mask; g1 &= mask; g2 &= mask; g3 &= mask; g4 &= mask; mask = ~mask; h0 = (h0 & mask) | g0; h1 = (h1 & mask) | g1; h2 = (h2 & mask) | g2; h3 = (h3 & mask) | g3; h4 = (h4 & mask) | g4; /* h = h % (2^128) */ h0 = ((h0) | (h1 << 26)) & 0xffffffff; h1 = ((h1 >> 6) | (h2 << 20)) & 0xffffffff; h2 = ((h2 >> 12) | (h3 << 14)) & 0xffffffff; h3 = ((h3 >> 18) | (h4 << 8)) & 0xffffffff; /* mac = (h + pad) % (2^128) */ f = (unsigned long long)h0 + st->pad[0]; h0 = (unsigned long)f; f = (unsigned long long)h1 + st->pad[1] + (f >> 32); h1 = (unsigned long)f; f = (unsigned long long)h2 + st->pad[2] + (f >> 32); h2 = (unsigned long)f; f = (unsigned long long)h3 + st->pad[3] + (f >> 32); h3 = (unsigned long)f; U32TO8(mac + 0, h0); U32TO8(mac + 4, h1); U32TO8(mac + 8, h2); U32TO8(mac + 12, h3); /* zero out the state */ st->h[0] = 0; st->h[1] = 0; st->h[2] = 0; st->h[3] = 0; st->h[4] = 0; st->r[0] = 0; st->r[1] = 0; st->r[2] = 0; st->r[3] = 0; st->r[4] = 0; st->pad[0] = 0; st->pad[1] = 0; st->pad[2] = 0; st->pad[3] = 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/whrlpool/0000755000000000000000000000000012666635521021720 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/whrlpool/wp_locl.h0000644000175000017500000000015312360020706021731 0ustar /* $OpenBSD$ */ #include void whirlpool_block(WHIRLPOOL_CTX *,const void *,size_t); deps/libressl-pnacl-sys-2.1.6/libressl/crypto/whrlpool/wp_dgst.c0000644000175000017500000001564412360020706021747 0ustar /* $OpenBSD$ */ /** * The Whirlpool hashing function. * *

* References * *

* The Whirlpool algorithm was developed by * Paulo S. L. M. Barreto and * Vincent Rijmen. * * See * P.S.L.M. Barreto, V. Rijmen, * ``The Whirlpool hashing function,'' * NESSIE submission, 2000 (tweaked version, 2001), * * * Based on "@version 3.0 (2003.03.12)" by Paulo S.L.M. Barreto and * Vincent Rijmen. Lookup "reference implementations" on * * * ============================================================================= * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''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 THE AUTHORS OR CONTRIBUTORS 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. * */ /* * OpenSSL-specific implementation notes. * * WHIRLPOOL_Update as well as one-stroke WHIRLPOOL both expect * number of *bytes* as input length argument. Bit-oriented routine * as specified by authors is called WHIRLPOOL_BitUpdate[!] and * does not have one-stroke counterpart. * * WHIRLPOOL_BitUpdate implements byte-oriented loop, essentially * to serve WHIRLPOOL_Update. This is done for performance. * * Unlike authors' reference implementation, block processing * routine whirlpool_block is designed to operate on multi-block * input. This is done for perfomance. */ #include "wp_locl.h" #include #include int WHIRLPOOL_Init(WHIRLPOOL_CTX *c) { memset (c,0,sizeof(*c)); return(1); } int WHIRLPOOL_Update (WHIRLPOOL_CTX *c,const void *_inp,size_t bytes) { /* Well, largest suitable chunk size actually is * (1<<(sizeof(size_t)*8-3))-64, but below number * is large enough for not to care about excessive * calls to WHIRLPOOL_BitUpdate... */ size_t chunk = ((size_t)1)<<(sizeof(size_t)*8-4); const unsigned char *inp = _inp; while (bytes>=chunk) { WHIRLPOOL_BitUpdate(c,inp,chunk*8); bytes -= chunk; inp += chunk; } if (bytes) WHIRLPOOL_BitUpdate(c,inp,bytes*8); return(1); } void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c,const void *_inp,size_t bits) { size_t n; unsigned int bitoff = c->bitoff, bitrem = bitoff%8, inpgap = (8-(unsigned int)bits%8)&7; const unsigned char *inp=_inp; /* This 256-bit increment procedure relies on the size_t * being natural size of CPU register, so that we don't * have to mask the value in order to detect overflows. */ c->bitlen[0] += bits; if (c->bitlen[0] < bits) /* overflow */ { n = 1; do { c->bitlen[n]++; } while(c->bitlen[n]==0 && ++n<(WHIRLPOOL_COUNTER/sizeof(size_t))); } #ifndef OPENSSL_SMALL_FOOTPRINT reconsider: if (inpgap==0 && bitrem==0) /* byte-oriented loop */ { while (bits) { if (bitoff==0 && (n=bits/WHIRLPOOL_BBLOCK)) { whirlpool_block(c,inp,n); inp += n*WHIRLPOOL_BBLOCK/8; bits %= WHIRLPOOL_BBLOCK; } else { unsigned int byteoff = bitoff/8; bitrem = WHIRLPOOL_BBLOCK - bitoff;/* re-use bitrem */ if (bits >= bitrem) { bits -= bitrem; bitrem /= 8; memcpy(c->data+byteoff,inp,bitrem); inp += bitrem; whirlpool_block(c,c->data,1); bitoff = 0; } else { memcpy(c->data+byteoff,inp,bits/8); bitoff += (unsigned int)bits; bits = 0; } c->bitoff = bitoff; } } } else /* bit-oriented loop */ #endif { /* inp | +-------+-------+------- ||||||||||||||||||||| +-------+-------+------- +-------+-------+-------+-------+------- |||||||||||||| c->data +-------+-------+-------+-------+------- | c->bitoff/8 */ while (bits) { unsigned int byteoff = bitoff/8; unsigned char b; #ifndef OPENSSL_SMALL_FOOTPRINT if (bitrem==inpgap) { c->data[byteoff++] |= inp[0] & (0xff>>inpgap); inpgap = 8-inpgap; bitoff += inpgap; bitrem = 0; /* bitoff%8 */ bits -= inpgap; inpgap = 0; /* bits%8 */ inp++; if (bitoff==WHIRLPOOL_BBLOCK) { whirlpool_block(c,c->data,1); bitoff = 0; } c->bitoff = bitoff; goto reconsider; } else #endif if (bits>=8) { b = ((inp[0]<>(8-inpgap))); b &= 0xff; if (bitrem) c->data[byteoff++] |= b>>bitrem; else c->data[byteoff++] = b; bitoff += 8; bits -= 8; inp++; if (bitoff>=WHIRLPOOL_BBLOCK) { whirlpool_block(c,c->data,1); byteoff = 0; bitoff %= WHIRLPOOL_BBLOCK; } if (bitrem) c->data[byteoff] = b<<(8-bitrem); } else /* remaining less than 8 bits */ { b = (inp[0]<data[byteoff++] |= b>>bitrem; else c->data[byteoff++] = b; bitoff += (unsigned int)bits; if (bitoff==WHIRLPOOL_BBLOCK) { whirlpool_block(c,c->data,1); byteoff = 0; bitoff %= WHIRLPOOL_BBLOCK; } if (bitrem) c->data[byteoff] = b<<(8-bitrem); bits = 0; } c->bitoff = bitoff; } } } int WHIRLPOOL_Final (unsigned char *md,WHIRLPOOL_CTX *c) { unsigned int bitoff = c->bitoff, byteoff = bitoff/8; size_t i,j,v; unsigned char *p; bitoff %= 8; if (bitoff) c->data[byteoff] |= 0x80>>bitoff; else c->data[byteoff] = 0x80; byteoff++; /* pad with zeros */ if (byteoff > (WHIRLPOOL_BBLOCK/8-WHIRLPOOL_COUNTER)) { if (byteoffdata[byteoff],0,WHIRLPOOL_BBLOCK/8-byteoff); whirlpool_block(c,c->data,1); byteoff = 0; } if (byteoff < (WHIRLPOOL_BBLOCK/8-WHIRLPOOL_COUNTER)) memset(&c->data[byteoff],0, (WHIRLPOOL_BBLOCK/8-WHIRLPOOL_COUNTER)-byteoff); /* smash 256-bit c->bitlen in big-endian order */ p = &c->data[WHIRLPOOL_BBLOCK/8-1]; /* last byte in c->data */ for(i=0;ibitlen[i],j=0;j>=8) *p-- = (unsigned char)(v&0xff); whirlpool_block(c,c->data,1); if (md) { memcpy(md,c->H.c,WHIRLPOOL_DIGEST_LENGTH); memset(c,0,sizeof(*c)); return(1); } return(0); } unsigned char *WHIRLPOOL(const void *inp, size_t bytes,unsigned char *md) { WHIRLPOOL_CTX ctx; static unsigned char m[WHIRLPOOL_DIGEST_LENGTH]; if (md == NULL) md=m; WHIRLPOOL_Init(&ctx); WHIRLPOOL_Update(&ctx,inp,bytes); WHIRLPOOL_Final(md,&ctx); return(md); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/whrlpool/wp_block.c0000644000175000017500000006047212360020706022077 0ustar /* $OpenBSD: wp_block.c,v 1.8 2014/07/08 16:15:20 miod Exp $ */ /** * The Whirlpool hashing function. * *

* References * *

* The Whirlpool algorithm was developed by * Paulo S. L. M. Barreto and * Vincent Rijmen. * * See * P.S.L.M. Barreto, V. Rijmen, * ``The Whirlpool hashing function,'' * NESSIE submission, 2000 (tweaked version, 2001), * * * Based on "@version 3.0 (2003.03.12)" by Paulo S.L.M. Barreto and * Vincent Rijmen. Lookup "reference implementations" on * * * ============================================================================= * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''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 THE AUTHORS OR CONTRIBUTORS 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. * */ #include "wp_locl.h" #include #include typedef unsigned char u8; #if defined(_LP64) typedef unsigned long u64; #else typedef unsigned long long u64; #endif #define ROUNDS 10 #undef SMALL_REGISTER_BANK #if defined(__i386) || defined(__i386__) || defined(_M_IX86) # define SMALL_REGISTER_BANK # if defined(WHIRLPOOL_ASM) # ifndef OPENSSL_SMALL_FOOTPRINT # define OPENSSL_SMALL_FOOTPRINT /* it appears that for elder non-MMX CPUs this is actually faster! */ # endif # define GO_FOR_MMX(ctx,inp,num) do { \ extern unsigned int OPENSSL_ia32cap_P[]; \ void whirlpool_block_mmx(void *,const void *,size_t); \ if (!(OPENSSL_ia32cap_P[0] & (1<<23))) break; \ whirlpool_block_mmx(ctx->H.c,inp,num); return; \ } while (0) # endif #elif defined(__arm__) # define SMALL_REGISTER_BANK #elif defined(__vax__) # define SMALL_REGISTER_BANK #endif #undef ROTATE #if defined(__GNUC__) && __GNUC__>=2 # if defined(__x86_64) || defined(__x86_64__) # define ROTATE(a,n) ({ u64 ret; asm ("rolq %1,%0" \ : "=r"(ret) : "J"(n),"0"(a) : "cc"); ret; }) # elif defined(__ia64) || defined(__ia64__) # if BYTE_ORDER == LITTLE_ENDIAN # define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \ : "=r"(ret) : "r"(a),"M"(64-(n))); ret; }) # else # define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \ : "=r"(ret) : "r"(a),"M"(n)); ret; }) # endif # endif #endif #if defined(OPENSSL_SMALL_FOOTPRINT) # if !defined(ROTATE) # if BYTE_ORDER == LITTLE_ENDIAN /* little-endians have to rotate left */ # define ROTATE(i,n) ((i)<<(n) ^ (i)>>(64-n)) # else /* big-endians have to rotate right */ # define ROTATE(i,n) ((i)>>(n) ^ (i)<<(64-n)) # endif # endif # if defined(ROTATE) && !defined(__STRICT_ALIGNMENT) # define __STRICT_ALIGNMENT /* ensure smallest table size */ # endif #endif /* * Table size depends on __STRICT_ALIGNMENT and whether or not endian- * specific ROTATE macro is defined. If __STRICT_ALIGNMENT is not * defined, which is normally the case on x86[_64] CPUs, the table is * 4KB large unconditionally. Otherwise if ROTATE is defined, the * table is 2KB large, and otherwise - 16KB. 2KB table requires a * whole bunch of additional rotations, but I'm willing to "trade," * because 16KB table certainly trashes L1 cache. I wish all CPUs * could handle unaligned load as 4KB table doesn't trash the cache, * nor does it require additional rotations. */ /* * Note that every Cn macro expands as two loads: one byte load and * one quadword load. One can argue that that many single-byte loads * is too excessive, as one could load a quadword and "milk" it for * eight 8-bit values instead. Well, yes, but in order to do so *and* * avoid excessive loads you have to accomodate a handful of 64-bit * values in the register bank and issue a bunch of shifts and mask. * It's a tradeoff: loads vs. shift and mask in big register bank[!]. * On most CPUs eight single-byte loads are faster and I let other * ones to depend on smart compiler to fold byte loads if beneficial. * Hand-coded assembler would be another alternative:-) */ #ifdef __STRICT_ALIGNMENT # if defined(ROTATE) # define N 1 # define LL(c0,c1,c2,c3,c4,c5,c6,c7) c0,c1,c2,c3,c4,c5,c6,c7 # define C0(K,i) (Cx.q[K.c[(i)*8+0]]) # define C1(K,i) ROTATE(Cx.q[K.c[(i)*8+1]],8) # define C2(K,i) ROTATE(Cx.q[K.c[(i)*8+2]],16) # define C3(K,i) ROTATE(Cx.q[K.c[(i)*8+3]],24) # define C4(K,i) ROTATE(Cx.q[K.c[(i)*8+4]],32) # define C5(K,i) ROTATE(Cx.q[K.c[(i)*8+5]],40) # define C6(K,i) ROTATE(Cx.q[K.c[(i)*8+6]],48) # define C7(K,i) ROTATE(Cx.q[K.c[(i)*8+7]],56) # else # define N 8 # define LL(c0,c1,c2,c3,c4,c5,c6,c7) c0,c1,c2,c3,c4,c5,c6,c7, \ c7,c0,c1,c2,c3,c4,c5,c6, \ c6,c7,c0,c1,c2,c3,c4,c5, \ c5,c6,c7,c0,c1,c2,c3,c4, \ c4,c5,c6,c7,c0,c1,c2,c3, \ c3,c4,c5,c6,c7,c0,c1,c2, \ c2,c3,c4,c5,c6,c7,c0,c1, \ c1,c2,c3,c4,c5,c6,c7,c0 # define C0(K,i) (Cx.q[0+8*K.c[(i)*8+0]]) # define C1(K,i) (Cx.q[1+8*K.c[(i)*8+1]]) # define C2(K,i) (Cx.q[2+8*K.c[(i)*8+2]]) # define C3(K,i) (Cx.q[3+8*K.c[(i)*8+3]]) # define C4(K,i) (Cx.q[4+8*K.c[(i)*8+4]]) # define C5(K,i) (Cx.q[5+8*K.c[(i)*8+5]]) # define C6(K,i) (Cx.q[6+8*K.c[(i)*8+6]]) # define C7(K,i) (Cx.q[7+8*K.c[(i)*8+7]]) # endif #else # define N 2 # define LL(c0,c1,c2,c3,c4,c5,c6,c7) c0,c1,c2,c3,c4,c5,c6,c7, \ c0,c1,c2,c3,c4,c5,c6,c7 # define C0(K,i) (((u64*)(Cx.c+0))[2*K.c[(i)*8+0]]) # define C1(K,i) (((u64*)(Cx.c+7))[2*K.c[(i)*8+1]]) # define C2(K,i) (((u64*)(Cx.c+6))[2*K.c[(i)*8+2]]) # define C3(K,i) (((u64*)(Cx.c+5))[2*K.c[(i)*8+3]]) # define C4(K,i) (((u64*)(Cx.c+4))[2*K.c[(i)*8+4]]) # define C5(K,i) (((u64*)(Cx.c+3))[2*K.c[(i)*8+5]]) # define C6(K,i) (((u64*)(Cx.c+2))[2*K.c[(i)*8+6]]) # define C7(K,i) (((u64*)(Cx.c+1))[2*K.c[(i)*8+7]]) #endif static const union { u8 c[(256*N+ROUNDS)*sizeof(u64)]; u64 q[(256*N+ROUNDS)]; } Cx = { { /* Note endian-neutral representation:-) */ LL(0x18,0x18,0x60,0x18,0xc0,0x78,0x30,0xd8), LL(0x23,0x23,0x8c,0x23,0x05,0xaf,0x46,0x26), LL(0xc6,0xc6,0x3f,0xc6,0x7e,0xf9,0x91,0xb8), LL(0xe8,0xe8,0x87,0xe8,0x13,0x6f,0xcd,0xfb), LL(0x87,0x87,0x26,0x87,0x4c,0xa1,0x13,0xcb), LL(0xb8,0xb8,0xda,0xb8,0xa9,0x62,0x6d,0x11), LL(0x01,0x01,0x04,0x01,0x08,0x05,0x02,0x09), LL(0x4f,0x4f,0x21,0x4f,0x42,0x6e,0x9e,0x0d), LL(0x36,0x36,0xd8,0x36,0xad,0xee,0x6c,0x9b), LL(0xa6,0xa6,0xa2,0xa6,0x59,0x04,0x51,0xff), LL(0xd2,0xd2,0x6f,0xd2,0xde,0xbd,0xb9,0x0c), LL(0xf5,0xf5,0xf3,0xf5,0xfb,0x06,0xf7,0x0e), LL(0x79,0x79,0xf9,0x79,0xef,0x80,0xf2,0x96), LL(0x6f,0x6f,0xa1,0x6f,0x5f,0xce,0xde,0x30), LL(0x91,0x91,0x7e,0x91,0xfc,0xef,0x3f,0x6d), LL(0x52,0x52,0x55,0x52,0xaa,0x07,0xa4,0xf8), LL(0x60,0x60,0x9d,0x60,0x27,0xfd,0xc0,0x47), LL(0xbc,0xbc,0xca,0xbc,0x89,0x76,0x65,0x35), LL(0x9b,0x9b,0x56,0x9b,0xac,0xcd,0x2b,0x37), LL(0x8e,0x8e,0x02,0x8e,0x04,0x8c,0x01,0x8a), LL(0xa3,0xa3,0xb6,0xa3,0x71,0x15,0x5b,0xd2), LL(0x0c,0x0c,0x30,0x0c,0x60,0x3c,0x18,0x6c), LL(0x7b,0x7b,0xf1,0x7b,0xff,0x8a,0xf6,0x84), LL(0x35,0x35,0xd4,0x35,0xb5,0xe1,0x6a,0x80), LL(0x1d,0x1d,0x74,0x1d,0xe8,0x69,0x3a,0xf5), LL(0xe0,0xe0,0xa7,0xe0,0x53,0x47,0xdd,0xb3), LL(0xd7,0xd7,0x7b,0xd7,0xf6,0xac,0xb3,0x21), LL(0xc2,0xc2,0x2f,0xc2,0x5e,0xed,0x99,0x9c), LL(0x2e,0x2e,0xb8,0x2e,0x6d,0x96,0x5c,0x43), LL(0x4b,0x4b,0x31,0x4b,0x62,0x7a,0x96,0x29), LL(0xfe,0xfe,0xdf,0xfe,0xa3,0x21,0xe1,0x5d), LL(0x57,0x57,0x41,0x57,0x82,0x16,0xae,0xd5), LL(0x15,0x15,0x54,0x15,0xa8,0x41,0x2a,0xbd), LL(0x77,0x77,0xc1,0x77,0x9f,0xb6,0xee,0xe8), LL(0x37,0x37,0xdc,0x37,0xa5,0xeb,0x6e,0x92), LL(0xe5,0xe5,0xb3,0xe5,0x7b,0x56,0xd7,0x9e), LL(0x9f,0x9f,0x46,0x9f,0x8c,0xd9,0x23,0x13), LL(0xf0,0xf0,0xe7,0xf0,0xd3,0x17,0xfd,0x23), LL(0x4a,0x4a,0x35,0x4a,0x6a,0x7f,0x94,0x20), LL(0xda,0xda,0x4f,0xda,0x9e,0x95,0xa9,0x44), LL(0x58,0x58,0x7d,0x58,0xfa,0x25,0xb0,0xa2), LL(0xc9,0xc9,0x03,0xc9,0x06,0xca,0x8f,0xcf), LL(0x29,0x29,0xa4,0x29,0x55,0x8d,0x52,0x7c), LL(0x0a,0x0a,0x28,0x0a,0x50,0x22,0x14,0x5a), LL(0xb1,0xb1,0xfe,0xb1,0xe1,0x4f,0x7f,0x50), LL(0xa0,0xa0,0xba,0xa0,0x69,0x1a,0x5d,0xc9), LL(0x6b,0x6b,0xb1,0x6b,0x7f,0xda,0xd6,0x14), LL(0x85,0x85,0x2e,0x85,0x5c,0xab,0x17,0xd9), LL(0xbd,0xbd,0xce,0xbd,0x81,0x73,0x67,0x3c), LL(0x5d,0x5d,0x69,0x5d,0xd2,0x34,0xba,0x8f), LL(0x10,0x10,0x40,0x10,0x80,0x50,0x20,0x90), LL(0xf4,0xf4,0xf7,0xf4,0xf3,0x03,0xf5,0x07), LL(0xcb,0xcb,0x0b,0xcb,0x16,0xc0,0x8b,0xdd), LL(0x3e,0x3e,0xf8,0x3e,0xed,0xc6,0x7c,0xd3), LL(0x05,0x05,0x14,0x05,0x28,0x11,0x0a,0x2d), LL(0x67,0x67,0x81,0x67,0x1f,0xe6,0xce,0x78), LL(0xe4,0xe4,0xb7,0xe4,0x73,0x53,0xd5,0x97), LL(0x27,0x27,0x9c,0x27,0x25,0xbb,0x4e,0x02), LL(0x41,0x41,0x19,0x41,0x32,0x58,0x82,0x73), LL(0x8b,0x8b,0x16,0x8b,0x2c,0x9d,0x0b,0xa7), LL(0xa7,0xa7,0xa6,0xa7,0x51,0x01,0x53,0xf6), LL(0x7d,0x7d,0xe9,0x7d,0xcf,0x94,0xfa,0xb2), LL(0x95,0x95,0x6e,0x95,0xdc,0xfb,0x37,0x49), LL(0xd8,0xd8,0x47,0xd8,0x8e,0x9f,0xad,0x56), LL(0xfb,0xfb,0xcb,0xfb,0x8b,0x30,0xeb,0x70), LL(0xee,0xee,0x9f,0xee,0x23,0x71,0xc1,0xcd), LL(0x7c,0x7c,0xed,0x7c,0xc7,0x91,0xf8,0xbb), LL(0x66,0x66,0x85,0x66,0x17,0xe3,0xcc,0x71), LL(0xdd,0xdd,0x53,0xdd,0xa6,0x8e,0xa7,0x7b), LL(0x17,0x17,0x5c,0x17,0xb8,0x4b,0x2e,0xaf), LL(0x47,0x47,0x01,0x47,0x02,0x46,0x8e,0x45), LL(0x9e,0x9e,0x42,0x9e,0x84,0xdc,0x21,0x1a), LL(0xca,0xca,0x0f,0xca,0x1e,0xc5,0x89,0xd4), LL(0x2d,0x2d,0xb4,0x2d,0x75,0x99,0x5a,0x58), LL(0xbf,0xbf,0xc6,0xbf,0x91,0x79,0x63,0x2e), LL(0x07,0x07,0x1c,0x07,0x38,0x1b,0x0e,0x3f), LL(0xad,0xad,0x8e,0xad,0x01,0x23,0x47,0xac), LL(0x5a,0x5a,0x75,0x5a,0xea,0x2f,0xb4,0xb0), LL(0x83,0x83,0x36,0x83,0x6c,0xb5,0x1b,0xef), LL(0x33,0x33,0xcc,0x33,0x85,0xff,0x66,0xb6), LL(0x63,0x63,0x91,0x63,0x3f,0xf2,0xc6,0x5c), LL(0x02,0x02,0x08,0x02,0x10,0x0a,0x04,0x12), LL(0xaa,0xaa,0x92,0xaa,0x39,0x38,0x49,0x93), LL(0x71,0x71,0xd9,0x71,0xaf,0xa8,0xe2,0xde), LL(0xc8,0xc8,0x07,0xc8,0x0e,0xcf,0x8d,0xc6), LL(0x19,0x19,0x64,0x19,0xc8,0x7d,0x32,0xd1), LL(0x49,0x49,0x39,0x49,0x72,0x70,0x92,0x3b), LL(0xd9,0xd9,0x43,0xd9,0x86,0x9a,0xaf,0x5f), LL(0xf2,0xf2,0xef,0xf2,0xc3,0x1d,0xf9,0x31), LL(0xe3,0xe3,0xab,0xe3,0x4b,0x48,0xdb,0xa8), LL(0x5b,0x5b,0x71,0x5b,0xe2,0x2a,0xb6,0xb9), LL(0x88,0x88,0x1a,0x88,0x34,0x92,0x0d,0xbc), LL(0x9a,0x9a,0x52,0x9a,0xa4,0xc8,0x29,0x3e), LL(0x26,0x26,0x98,0x26,0x2d,0xbe,0x4c,0x0b), LL(0x32,0x32,0xc8,0x32,0x8d,0xfa,0x64,0xbf), LL(0xb0,0xb0,0xfa,0xb0,0xe9,0x4a,0x7d,0x59), LL(0xe9,0xe9,0x83,0xe9,0x1b,0x6a,0xcf,0xf2), LL(0x0f,0x0f,0x3c,0x0f,0x78,0x33,0x1e,0x77), LL(0xd5,0xd5,0x73,0xd5,0xe6,0xa6,0xb7,0x33), LL(0x80,0x80,0x3a,0x80,0x74,0xba,0x1d,0xf4), LL(0xbe,0xbe,0xc2,0xbe,0x99,0x7c,0x61,0x27), LL(0xcd,0xcd,0x13,0xcd,0x26,0xde,0x87,0xeb), LL(0x34,0x34,0xd0,0x34,0xbd,0xe4,0x68,0x89), LL(0x48,0x48,0x3d,0x48,0x7a,0x75,0x90,0x32), LL(0xff,0xff,0xdb,0xff,0xab,0x24,0xe3,0x54), LL(0x7a,0x7a,0xf5,0x7a,0xf7,0x8f,0xf4,0x8d), LL(0x90,0x90,0x7a,0x90,0xf4,0xea,0x3d,0x64), LL(0x5f,0x5f,0x61,0x5f,0xc2,0x3e,0xbe,0x9d), LL(0x20,0x20,0x80,0x20,0x1d,0xa0,0x40,0x3d), LL(0x68,0x68,0xbd,0x68,0x67,0xd5,0xd0,0x0f), LL(0x1a,0x1a,0x68,0x1a,0xd0,0x72,0x34,0xca), LL(0xae,0xae,0x82,0xae,0x19,0x2c,0x41,0xb7), LL(0xb4,0xb4,0xea,0xb4,0xc9,0x5e,0x75,0x7d), LL(0x54,0x54,0x4d,0x54,0x9a,0x19,0xa8,0xce), LL(0x93,0x93,0x76,0x93,0xec,0xe5,0x3b,0x7f), LL(0x22,0x22,0x88,0x22,0x0d,0xaa,0x44,0x2f), LL(0x64,0x64,0x8d,0x64,0x07,0xe9,0xc8,0x63), LL(0xf1,0xf1,0xe3,0xf1,0xdb,0x12,0xff,0x2a), LL(0x73,0x73,0xd1,0x73,0xbf,0xa2,0xe6,0xcc), LL(0x12,0x12,0x48,0x12,0x90,0x5a,0x24,0x82), LL(0x40,0x40,0x1d,0x40,0x3a,0x5d,0x80,0x7a), LL(0x08,0x08,0x20,0x08,0x40,0x28,0x10,0x48), LL(0xc3,0xc3,0x2b,0xc3,0x56,0xe8,0x9b,0x95), LL(0xec,0xec,0x97,0xec,0x33,0x7b,0xc5,0xdf), LL(0xdb,0xdb,0x4b,0xdb,0x96,0x90,0xab,0x4d), LL(0xa1,0xa1,0xbe,0xa1,0x61,0x1f,0x5f,0xc0), LL(0x8d,0x8d,0x0e,0x8d,0x1c,0x83,0x07,0x91), LL(0x3d,0x3d,0xf4,0x3d,0xf5,0xc9,0x7a,0xc8), LL(0x97,0x97,0x66,0x97,0xcc,0xf1,0x33,0x5b), LL(0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00), LL(0xcf,0xcf,0x1b,0xcf,0x36,0xd4,0x83,0xf9), LL(0x2b,0x2b,0xac,0x2b,0x45,0x87,0x56,0x6e), LL(0x76,0x76,0xc5,0x76,0x97,0xb3,0xec,0xe1), LL(0x82,0x82,0x32,0x82,0x64,0xb0,0x19,0xe6), LL(0xd6,0xd6,0x7f,0xd6,0xfe,0xa9,0xb1,0x28), LL(0x1b,0x1b,0x6c,0x1b,0xd8,0x77,0x36,0xc3), LL(0xb5,0xb5,0xee,0xb5,0xc1,0x5b,0x77,0x74), LL(0xaf,0xaf,0x86,0xaf,0x11,0x29,0x43,0xbe), LL(0x6a,0x6a,0xb5,0x6a,0x77,0xdf,0xd4,0x1d), LL(0x50,0x50,0x5d,0x50,0xba,0x0d,0xa0,0xea), LL(0x45,0x45,0x09,0x45,0x12,0x4c,0x8a,0x57), LL(0xf3,0xf3,0xeb,0xf3,0xcb,0x18,0xfb,0x38), LL(0x30,0x30,0xc0,0x30,0x9d,0xf0,0x60,0xad), LL(0xef,0xef,0x9b,0xef,0x2b,0x74,0xc3,0xc4), LL(0x3f,0x3f,0xfc,0x3f,0xe5,0xc3,0x7e,0xda), LL(0x55,0x55,0x49,0x55,0x92,0x1c,0xaa,0xc7), LL(0xa2,0xa2,0xb2,0xa2,0x79,0x10,0x59,0xdb), LL(0xea,0xea,0x8f,0xea,0x03,0x65,0xc9,0xe9), LL(0x65,0x65,0x89,0x65,0x0f,0xec,0xca,0x6a), LL(0xba,0xba,0xd2,0xba,0xb9,0x68,0x69,0x03), LL(0x2f,0x2f,0xbc,0x2f,0x65,0x93,0x5e,0x4a), LL(0xc0,0xc0,0x27,0xc0,0x4e,0xe7,0x9d,0x8e), LL(0xde,0xde,0x5f,0xde,0xbe,0x81,0xa1,0x60), LL(0x1c,0x1c,0x70,0x1c,0xe0,0x6c,0x38,0xfc), LL(0xfd,0xfd,0xd3,0xfd,0xbb,0x2e,0xe7,0x46), LL(0x4d,0x4d,0x29,0x4d,0x52,0x64,0x9a,0x1f), LL(0x92,0x92,0x72,0x92,0xe4,0xe0,0x39,0x76), LL(0x75,0x75,0xc9,0x75,0x8f,0xbc,0xea,0xfa), LL(0x06,0x06,0x18,0x06,0x30,0x1e,0x0c,0x36), LL(0x8a,0x8a,0x12,0x8a,0x24,0x98,0x09,0xae), LL(0xb2,0xb2,0xf2,0xb2,0xf9,0x40,0x79,0x4b), LL(0xe6,0xe6,0xbf,0xe6,0x63,0x59,0xd1,0x85), LL(0x0e,0x0e,0x38,0x0e,0x70,0x36,0x1c,0x7e), LL(0x1f,0x1f,0x7c,0x1f,0xf8,0x63,0x3e,0xe7), LL(0x62,0x62,0x95,0x62,0x37,0xf7,0xc4,0x55), LL(0xd4,0xd4,0x77,0xd4,0xee,0xa3,0xb5,0x3a), LL(0xa8,0xa8,0x9a,0xa8,0x29,0x32,0x4d,0x81), LL(0x96,0x96,0x62,0x96,0xc4,0xf4,0x31,0x52), LL(0xf9,0xf9,0xc3,0xf9,0x9b,0x3a,0xef,0x62), LL(0xc5,0xc5,0x33,0xc5,0x66,0xf6,0x97,0xa3), LL(0x25,0x25,0x94,0x25,0x35,0xb1,0x4a,0x10), LL(0x59,0x59,0x79,0x59,0xf2,0x20,0xb2,0xab), LL(0x84,0x84,0x2a,0x84,0x54,0xae,0x15,0xd0), LL(0x72,0x72,0xd5,0x72,0xb7,0xa7,0xe4,0xc5), LL(0x39,0x39,0xe4,0x39,0xd5,0xdd,0x72,0xec), LL(0x4c,0x4c,0x2d,0x4c,0x5a,0x61,0x98,0x16), LL(0x5e,0x5e,0x65,0x5e,0xca,0x3b,0xbc,0x94), LL(0x78,0x78,0xfd,0x78,0xe7,0x85,0xf0,0x9f), LL(0x38,0x38,0xe0,0x38,0xdd,0xd8,0x70,0xe5), LL(0x8c,0x8c,0x0a,0x8c,0x14,0x86,0x05,0x98), LL(0xd1,0xd1,0x63,0xd1,0xc6,0xb2,0xbf,0x17), LL(0xa5,0xa5,0xae,0xa5,0x41,0x0b,0x57,0xe4), LL(0xe2,0xe2,0xaf,0xe2,0x43,0x4d,0xd9,0xa1), LL(0x61,0x61,0x99,0x61,0x2f,0xf8,0xc2,0x4e), LL(0xb3,0xb3,0xf6,0xb3,0xf1,0x45,0x7b,0x42), LL(0x21,0x21,0x84,0x21,0x15,0xa5,0x42,0x34), LL(0x9c,0x9c,0x4a,0x9c,0x94,0xd6,0x25,0x08), LL(0x1e,0x1e,0x78,0x1e,0xf0,0x66,0x3c,0xee), LL(0x43,0x43,0x11,0x43,0x22,0x52,0x86,0x61), LL(0xc7,0xc7,0x3b,0xc7,0x76,0xfc,0x93,0xb1), LL(0xfc,0xfc,0xd7,0xfc,0xb3,0x2b,0xe5,0x4f), LL(0x04,0x04,0x10,0x04,0x20,0x14,0x08,0x24), LL(0x51,0x51,0x59,0x51,0xb2,0x08,0xa2,0xe3), LL(0x99,0x99,0x5e,0x99,0xbc,0xc7,0x2f,0x25), LL(0x6d,0x6d,0xa9,0x6d,0x4f,0xc4,0xda,0x22), LL(0x0d,0x0d,0x34,0x0d,0x68,0x39,0x1a,0x65), LL(0xfa,0xfa,0xcf,0xfa,0x83,0x35,0xe9,0x79), LL(0xdf,0xdf,0x5b,0xdf,0xb6,0x84,0xa3,0x69), LL(0x7e,0x7e,0xe5,0x7e,0xd7,0x9b,0xfc,0xa9), LL(0x24,0x24,0x90,0x24,0x3d,0xb4,0x48,0x19), LL(0x3b,0x3b,0xec,0x3b,0xc5,0xd7,0x76,0xfe), LL(0xab,0xab,0x96,0xab,0x31,0x3d,0x4b,0x9a), LL(0xce,0xce,0x1f,0xce,0x3e,0xd1,0x81,0xf0), LL(0x11,0x11,0x44,0x11,0x88,0x55,0x22,0x99), LL(0x8f,0x8f,0x06,0x8f,0x0c,0x89,0x03,0x83), LL(0x4e,0x4e,0x25,0x4e,0x4a,0x6b,0x9c,0x04), LL(0xb7,0xb7,0xe6,0xb7,0xd1,0x51,0x73,0x66), LL(0xeb,0xeb,0x8b,0xeb,0x0b,0x60,0xcb,0xe0), LL(0x3c,0x3c,0xf0,0x3c,0xfd,0xcc,0x78,0xc1), LL(0x81,0x81,0x3e,0x81,0x7c,0xbf,0x1f,0xfd), LL(0x94,0x94,0x6a,0x94,0xd4,0xfe,0x35,0x40), LL(0xf7,0xf7,0xfb,0xf7,0xeb,0x0c,0xf3,0x1c), LL(0xb9,0xb9,0xde,0xb9,0xa1,0x67,0x6f,0x18), LL(0x13,0x13,0x4c,0x13,0x98,0x5f,0x26,0x8b), LL(0x2c,0x2c,0xb0,0x2c,0x7d,0x9c,0x58,0x51), LL(0xd3,0xd3,0x6b,0xd3,0xd6,0xb8,0xbb,0x05), LL(0xe7,0xe7,0xbb,0xe7,0x6b,0x5c,0xd3,0x8c), LL(0x6e,0x6e,0xa5,0x6e,0x57,0xcb,0xdc,0x39), LL(0xc4,0xc4,0x37,0xc4,0x6e,0xf3,0x95,0xaa), LL(0x03,0x03,0x0c,0x03,0x18,0x0f,0x06,0x1b), LL(0x56,0x56,0x45,0x56,0x8a,0x13,0xac,0xdc), LL(0x44,0x44,0x0d,0x44,0x1a,0x49,0x88,0x5e), LL(0x7f,0x7f,0xe1,0x7f,0xdf,0x9e,0xfe,0xa0), LL(0xa9,0xa9,0x9e,0xa9,0x21,0x37,0x4f,0x88), LL(0x2a,0x2a,0xa8,0x2a,0x4d,0x82,0x54,0x67), LL(0xbb,0xbb,0xd6,0xbb,0xb1,0x6d,0x6b,0x0a), LL(0xc1,0xc1,0x23,0xc1,0x46,0xe2,0x9f,0x87), LL(0x53,0x53,0x51,0x53,0xa2,0x02,0xa6,0xf1), LL(0xdc,0xdc,0x57,0xdc,0xae,0x8b,0xa5,0x72), LL(0x0b,0x0b,0x2c,0x0b,0x58,0x27,0x16,0x53), LL(0x9d,0x9d,0x4e,0x9d,0x9c,0xd3,0x27,0x01), LL(0x6c,0x6c,0xad,0x6c,0x47,0xc1,0xd8,0x2b), LL(0x31,0x31,0xc4,0x31,0x95,0xf5,0x62,0xa4), LL(0x74,0x74,0xcd,0x74,0x87,0xb9,0xe8,0xf3), LL(0xf6,0xf6,0xff,0xf6,0xe3,0x09,0xf1,0x15), LL(0x46,0x46,0x05,0x46,0x0a,0x43,0x8c,0x4c), LL(0xac,0xac,0x8a,0xac,0x09,0x26,0x45,0xa5), LL(0x89,0x89,0x1e,0x89,0x3c,0x97,0x0f,0xb5), LL(0x14,0x14,0x50,0x14,0xa0,0x44,0x28,0xb4), LL(0xe1,0xe1,0xa3,0xe1,0x5b,0x42,0xdf,0xba), LL(0x16,0x16,0x58,0x16,0xb0,0x4e,0x2c,0xa6), LL(0x3a,0x3a,0xe8,0x3a,0xcd,0xd2,0x74,0xf7), LL(0x69,0x69,0xb9,0x69,0x6f,0xd0,0xd2,0x06), LL(0x09,0x09,0x24,0x09,0x48,0x2d,0x12,0x41), LL(0x70,0x70,0xdd,0x70,0xa7,0xad,0xe0,0xd7), LL(0xb6,0xb6,0xe2,0xb6,0xd9,0x54,0x71,0x6f), LL(0xd0,0xd0,0x67,0xd0,0xce,0xb7,0xbd,0x1e), LL(0xed,0xed,0x93,0xed,0x3b,0x7e,0xc7,0xd6), LL(0xcc,0xcc,0x17,0xcc,0x2e,0xdb,0x85,0xe2), LL(0x42,0x42,0x15,0x42,0x2a,0x57,0x84,0x68), LL(0x98,0x98,0x5a,0x98,0xb4,0xc2,0x2d,0x2c), LL(0xa4,0xa4,0xaa,0xa4,0x49,0x0e,0x55,0xed), LL(0x28,0x28,0xa0,0x28,0x5d,0x88,0x50,0x75), LL(0x5c,0x5c,0x6d,0x5c,0xda,0x31,0xb8,0x86), LL(0xf8,0xf8,0xc7,0xf8,0x93,0x3f,0xed,0x6b), LL(0x86,0x86,0x22,0x86,0x44,0xa4,0x11,0xc2), #define RC (&(Cx.q[256*N])) 0x18,0x23,0xc6,0xe8,0x87,0xb8,0x01,0x4f, /* rc[ROUNDS] */ 0x36,0xa6,0xd2,0xf5,0x79,0x6f,0x91,0x52, 0x60,0xbc,0x9b,0x8e,0xa3,0x0c,0x7b,0x35, 0x1d,0xe0,0xd7,0xc2,0x2e,0x4b,0xfe,0x57, 0x15,0x77,0x37,0xe5,0x9f,0xf0,0x4a,0xda, 0x58,0xc9,0x29,0x0a,0xb1,0xa0,0x6b,0x85, 0xbd,0x5d,0x10,0xf4,0xcb,0x3e,0x05,0x67, 0xe4,0x27,0x41,0x8b,0xa7,0x7d,0x95,0xd8, 0xfb,0xee,0x7c,0x66,0xdd,0x17,0x47,0x9e, 0xca,0x2d,0xbf,0x07,0xad,0x5a,0x83,0x33 } }; void whirlpool_block(WHIRLPOOL_CTX *ctx,const void *inp,size_t n) { int r; const u8 *p=inp; union { u64 q[8]; u8 c[64]; } S,K,*H=(void *)ctx->H.q; #ifdef GO_FOR_MMX GO_FOR_MMX(ctx,inp,n); #endif do { #ifdef OPENSSL_SMALL_FOOTPRINT u64 L[8]; int i; for (i=0;i<64;i++) S.c[i] = (K.c[i] = H->c[i]) ^ p[i]; for (r=0;rc[i] ^= S.c[i] ^ p[i]; #else u64 L0,L1,L2,L3,L4,L5,L6,L7; #ifdef __STRICT_ALIGNMENT if ((size_t)p & 7) { memcpy (S.c,p,64); S.q[0] ^= (K.q[0] = H->q[0]); S.q[1] ^= (K.q[1] = H->q[1]); S.q[2] ^= (K.q[2] = H->q[2]); S.q[3] ^= (K.q[3] = H->q[3]); S.q[4] ^= (K.q[4] = H->q[4]); S.q[5] ^= (K.q[5] = H->q[5]); S.q[6] ^= (K.q[6] = H->q[6]); S.q[7] ^= (K.q[7] = H->q[7]); } else #endif { const u64 *pa = (const u64*)p; S.q[0] = (K.q[0] = H->q[0]) ^ pa[0]; S.q[1] = (K.q[1] = H->q[1]) ^ pa[1]; S.q[2] = (K.q[2] = H->q[2]) ^ pa[2]; S.q[3] = (K.q[3] = H->q[3]) ^ pa[3]; S.q[4] = (K.q[4] = H->q[4]) ^ pa[4]; S.q[5] = (K.q[5] = H->q[5]) ^ pa[5]; S.q[6] = (K.q[6] = H->q[6]) ^ pa[6]; S.q[7] = (K.q[7] = H->q[7]) ^ pa[7]; } for(r=0;rc[i] ^= S.c[i] ^ p[i]; } else #endif { const u64 *pa=(const u64 *)p; H->q[0] ^= S.q[0] ^ pa[0]; H->q[1] ^= S.q[1] ^ pa[1]; H->q[2] ^= S.q[2] ^ pa[2]; H->q[3] ^= S.q[3] ^ pa[3]; H->q[4] ^= S.q[4] ^ pa[4]; H->q[5] ^= S.q[5] ^ pa[5]; H->q[6] ^= S.q[6] ^ pa[6]; H->q[7] ^= S.q[7] ^ pa[7]; } #endif p += 64; } while(--n); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/hmac/0000755000000000000000000000000012666635521020762 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/hmac/hm_pmeth.c0000644000175000017500000001502212360020705021130 0ustar /* $OpenBSD: hm_pmeth.c,v 1.7 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2007. */ /* ==================================================================== * Copyright (c) 2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include "evp_locl.h" /* HMAC pkey context structure */ typedef struct { const EVP_MD *md; /* MD for HMAC use */ ASN1_OCTET_STRING ktmp; /* Temp storage for key */ HMAC_CTX ctx; } HMAC_PKEY_CTX; static int pkey_hmac_init(EVP_PKEY_CTX *ctx) { HMAC_PKEY_CTX *hctx; hctx = malloc(sizeof(HMAC_PKEY_CTX)); if (!hctx) return 0; hctx->md = NULL; hctx->ktmp.data = NULL; hctx->ktmp.length = 0; hctx->ktmp.flags = 0; hctx->ktmp.type = V_ASN1_OCTET_STRING; HMAC_CTX_init(&hctx->ctx); ctx->data = hctx; ctx->keygen_info_count = 0; return 1; } static int pkey_hmac_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src) { HMAC_PKEY_CTX *sctx, *dctx; if (!pkey_hmac_init(dst)) return 0; sctx = src->data; dctx = dst->data; dctx->md = sctx->md; HMAC_CTX_init(&dctx->ctx); if (!HMAC_CTX_copy(&dctx->ctx, &sctx->ctx)) return 0; if (sctx->ktmp.data) { if (!ASN1_OCTET_STRING_set(&dctx->ktmp, sctx->ktmp.data, sctx->ktmp.length)) return 0; } return 1; } static void pkey_hmac_cleanup(EVP_PKEY_CTX *ctx) { HMAC_PKEY_CTX *hctx = ctx->data; HMAC_CTX_cleanup(&hctx->ctx); if (hctx->ktmp.data) { if (hctx->ktmp.length) OPENSSL_cleanse(hctx->ktmp.data, hctx->ktmp.length); free(hctx->ktmp.data); hctx->ktmp.data = NULL; } free(hctx); } static int pkey_hmac_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) { ASN1_OCTET_STRING *hkey = NULL; HMAC_PKEY_CTX *hctx = ctx->data; if (!hctx->ktmp.data) return 0; hkey = ASN1_OCTET_STRING_dup(&hctx->ktmp); if (!hkey) return 0; EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, hkey); return 1; } static int int_update(EVP_MD_CTX *ctx, const void *data, size_t count) { HMAC_PKEY_CTX *hctx = ctx->pctx->data; if (!HMAC_Update(&hctx->ctx, data, count)) return 0; return 1; } static int hmac_signctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx) { HMAC_PKEY_CTX *hctx = ctx->data; HMAC_CTX_set_flags(&hctx->ctx, mctx->flags & ~EVP_MD_CTX_FLAG_NO_INIT); EVP_MD_CTX_set_flags(mctx, EVP_MD_CTX_FLAG_NO_INIT); mctx->update = int_update; return 1; } static int hmac_signctx(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, EVP_MD_CTX *mctx) { unsigned int hlen; HMAC_PKEY_CTX *hctx = ctx->data; int l = EVP_MD_CTX_size(mctx); if (l < 0) return 0; *siglen = l; if (!sig) return 1; if (!HMAC_Final(&hctx->ctx, sig, &hlen)) return 0; *siglen = (size_t)hlen; return 1; } static int pkey_hmac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) { HMAC_PKEY_CTX *hctx = ctx->data; ASN1_OCTET_STRING *key; switch (type) { case EVP_PKEY_CTRL_SET_MAC_KEY: if ((!p2 && p1 > 0) || (p1 < -1)) return 0; if (!ASN1_OCTET_STRING_set(&hctx->ktmp, p2, p1)) return 0; break; case EVP_PKEY_CTRL_MD: hctx->md = p2; break; case EVP_PKEY_CTRL_DIGESTINIT: key = (ASN1_OCTET_STRING *)ctx->pkey->pkey.ptr; if (!HMAC_Init_ex(&hctx->ctx, key->data, key->length, hctx->md, ctx->engine)) return 0; break; default: return -2; } return 1; } static int pkey_hmac_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) { if (!value) return 0; if (!strcmp(type, "key")) { void *p = (void *)value; return pkey_hmac_ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY, -1, p); } if (!strcmp(type, "hexkey")) { unsigned char *key; int r; long keylen; key = string_to_hex(value, &keylen); if (!key) return 0; r = pkey_hmac_ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY, keylen, key); free(key); return r; } return -2; } const EVP_PKEY_METHOD hmac_pkey_meth = { .pkey_id = EVP_PKEY_HMAC, .init = pkey_hmac_init, .copy = pkey_hmac_copy, .cleanup = pkey_hmac_cleanup, .keygen = pkey_hmac_keygen, .signctx_init = hmac_signctx_init, .signctx = hmac_signctx, .ctrl = pkey_hmac_ctrl, .ctrl_str = pkey_hmac_ctrl_str }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/hmac/hm_ameth.c0000644000175000017500000001116512360020705021115 0ustar /* $OpenBSD: hm_ameth.c,v 1.7 2014/07/10 13:58:22 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2007. */ /* ==================================================================== * Copyright (c) 2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include "asn1_locl.h" #define HMAC_TEST_PRIVATE_KEY_FORMAT /* HMAC "ASN1" method. This is just here to indicate the * maximum HMAC output length and to free up an HMAC * key. */ static int hmac_size(const EVP_PKEY *pkey) { return EVP_MAX_MD_SIZE; } static void hmac_key_free(EVP_PKEY *pkey) { ASN1_OCTET_STRING *os = (ASN1_OCTET_STRING *)pkey->pkey.ptr; if (os) { if (os->data) OPENSSL_cleanse(os->data, os->length); ASN1_OCTET_STRING_free(os); } } static int hmac_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) { switch (op) { case ASN1_PKEY_CTRL_DEFAULT_MD_NID: *(int *)arg2 = NID_sha1; return 1; default: return -2; } } #ifdef HMAC_TEST_PRIVATE_KEY_FORMAT /* A bogus private key format for test purposes. This is simply the * HMAC key with "HMAC PRIVATE KEY" in the headers. When enabled the * genpkey utility can be used to "generate" HMAC keys. */ static int old_hmac_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) { ASN1_OCTET_STRING *os; os = ASN1_OCTET_STRING_new(); if (!os || !ASN1_OCTET_STRING_set(os, *pder, derlen)) return 0; EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os); return 1; } static int old_hmac_encode(const EVP_PKEY *pkey, unsigned char **pder) { int inc; ASN1_OCTET_STRING *os = (ASN1_OCTET_STRING *)pkey->pkey.ptr; if (pder) { if (!*pder) { *pder = malloc(os->length); inc = 0; } else inc = 1; memcpy(*pder, os->data, os->length); if (inc) *pder += os->length; } return os->length; } #endif const EVP_PKEY_ASN1_METHOD hmac_asn1_meth = { .pkey_id = EVP_PKEY_HMAC, .pkey_base_id = EVP_PKEY_HMAC, .pem_str = "HMAC", .info = "OpenSSL HMAC method", .pkey_size = hmac_size, .pkey_free = hmac_key_free, .pkey_ctrl = hmac_pkey_ctrl, #ifdef HMAC_TEST_PRIVATE_KEY_FORMAT .old_priv_decode = old_hmac_decode, .old_priv_encode = old_hmac_encode #endif }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/hmac/hmac.c0000644000175000017500000001513012360020705020237 0ustar /* $OpenBSD: hmac.c,v 1.20 2014/06/21 13:39:46 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md, ENGINE *impl) { int i, j, reset = 0; unsigned char pad[HMAC_MAX_MD_CBLOCK]; if (md != NULL) { reset = 1; ctx->md = md; } else md = ctx->md; if (key != NULL) { reset = 1; j = EVP_MD_block_size(md); OPENSSL_assert(j <= (int)sizeof(ctx->key)); if (j < len) { if (!EVP_DigestInit_ex(&ctx->md_ctx, md, impl)) goto err; if (!EVP_DigestUpdate(&ctx->md_ctx, key, len)) goto err; if (!EVP_DigestFinal_ex(&(ctx->md_ctx), ctx->key, &ctx->key_length)) goto err; } else { OPENSSL_assert(len >= 0 && len <= (int)sizeof(ctx->key)); memcpy(ctx->key, key, len); ctx->key_length = len; } if (ctx->key_length != HMAC_MAX_MD_CBLOCK) memset(&ctx->key[ctx->key_length], 0, HMAC_MAX_MD_CBLOCK - ctx->key_length); } if (reset) { for (i = 0; i < HMAC_MAX_MD_CBLOCK; i++) pad[i] = 0x36 ^ ctx->key[i]; if (!EVP_DigestInit_ex(&ctx->i_ctx, md, impl)) goto err; if (!EVP_DigestUpdate(&ctx->i_ctx, pad, EVP_MD_block_size(md))) goto err; for (i = 0; i < HMAC_MAX_MD_CBLOCK; i++) pad[i] = 0x5c ^ ctx->key[i]; if (!EVP_DigestInit_ex(&ctx->o_ctx, md, impl)) goto err; if (!EVP_DigestUpdate(&ctx->o_ctx, pad, EVP_MD_block_size(md))) goto err; } if (!EVP_MD_CTX_copy_ex(&ctx->md_ctx, &ctx->i_ctx)) goto err; return 1; err: return 0; } int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md) { if (key && md) HMAC_CTX_init(ctx); return HMAC_Init_ex(ctx, key, len, md, NULL); } int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len) { return EVP_DigestUpdate(&ctx->md_ctx, data, len); } int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) { unsigned int i; unsigned char buf[EVP_MAX_MD_SIZE]; if (!EVP_DigestFinal_ex(&ctx->md_ctx, buf, &i)) goto err; if (!EVP_MD_CTX_copy_ex(&ctx->md_ctx, &ctx->o_ctx)) goto err; if (!EVP_DigestUpdate(&ctx->md_ctx, buf, i)) goto err; if (!EVP_DigestFinal_ex(&ctx->md_ctx, md, len)) goto err; return 1; err: return 0; } void HMAC_CTX_init(HMAC_CTX *ctx) { EVP_MD_CTX_init(&ctx->i_ctx); EVP_MD_CTX_init(&ctx->o_ctx); EVP_MD_CTX_init(&ctx->md_ctx); } int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx) { if (!EVP_MD_CTX_copy(&dctx->i_ctx, &sctx->i_ctx)) goto err; if (!EVP_MD_CTX_copy(&dctx->o_ctx, &sctx->o_ctx)) goto err; if (!EVP_MD_CTX_copy(&dctx->md_ctx, &sctx->md_ctx)) goto err; memcpy(dctx->key, sctx->key, HMAC_MAX_MD_CBLOCK); dctx->key_length = sctx->key_length; dctx->md = sctx->md; return 1; err: return 0; } void HMAC_CTX_cleanup(HMAC_CTX *ctx) { EVP_MD_CTX_cleanup(&ctx->i_ctx); EVP_MD_CTX_cleanup(&ctx->o_ctx); EVP_MD_CTX_cleanup(&ctx->md_ctx); memset(ctx, 0, sizeof *ctx); } unsigned char * HMAC(const EVP_MD *evp_md, const void *key, int key_len, const unsigned char *d, size_t n, unsigned char *md, unsigned int *md_len) { HMAC_CTX c; static unsigned char m[EVP_MAX_MD_SIZE]; if (md == NULL) md = m; HMAC_CTX_init(&c); if (!HMAC_Init(&c, key, key_len, evp_md)) goto err; if (!HMAC_Update(&c, d, n)) goto err; if (!HMAC_Final(&c, md, md_len)) goto err; HMAC_CTX_cleanup(&c); return md; err: return NULL; } void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags) { EVP_MD_CTX_set_flags(&ctx->i_ctx, flags); EVP_MD_CTX_set_flags(&ctx->o_ctx, flags); EVP_MD_CTX_set_flags(&ctx->md_ctx, flags); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/md4/0000755000000000000000000000000012666635521020536 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/md4/md4_locl.h0000644000175000017500000001110512360020706020604 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #ifndef MD4_LONG_LOG2 #define MD4_LONG_LOG2 2 /* default to 32 bits */ #endif void md4_block_data_order (MD4_CTX *c, const void *p,size_t num); #define DATA_ORDER_IS_LITTLE_ENDIAN #define HASH_LONG MD4_LONG #define HASH_CTX MD4_CTX #define HASH_CBLOCK MD4_CBLOCK #define HASH_UPDATE MD4_Update #define HASH_TRANSFORM MD4_Transform #define HASH_FINAL MD4_Final #define HASH_MAKE_STRING(c,s) do { \ unsigned long ll; \ ll=(c)->A; (void)HOST_l2c(ll,(s)); \ ll=(c)->B; (void)HOST_l2c(ll,(s)); \ ll=(c)->C; (void)HOST_l2c(ll,(s)); \ ll=(c)->D; (void)HOST_l2c(ll,(s)); \ } while (0) #define HASH_BLOCK_DATA_ORDER md4_block_data_order #include "md32_common.h" /* #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z))) #define G(x,y,z) (((x) & (y)) | ((x) & ((z))) | ((y) & ((z)))) */ /* As pointed out by Wei Dai , the above can be * simplified to the code below. Wei attributes these optimizations * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel. */ #define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) #define G(b,c,d) (((b) & (c)) | ((b) & (d)) | ((c) & (d))) #define H(b,c,d) ((b) ^ (c) ^ (d)) #define R0(a,b,c,d,k,s,t) { \ a+=((k)+(t)+F((b),(c),(d))); \ a=ROTATE(a,s); }; #define R1(a,b,c,d,k,s,t) { \ a+=((k)+(t)+G((b),(c),(d))); \ a=ROTATE(a,s); };\ #define R2(a,b,c,d,k,s,t) { \ a+=((k)+(t)+H((b),(c),(d))); \ a=ROTATE(a,s); }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/md4/md4_one.c0000644000175000017500000000700312360020706020431 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md) { MD4_CTX c; static unsigned char m[MD4_DIGEST_LENGTH]; if (md == NULL) md=m; if (!MD4_Init(&c)) return NULL; MD4_Update(&c,d,n); MD4_Final(md,&c); OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */ return(md); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/md4/md4_dgst.c0000644000175000017500000001444012360020706020614 0ustar /* $OpenBSD: md4_dgst.c,v 1.11 2014/06/12 15:49:29 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include "md4_locl.h" /* Implemented from RFC1186 The MD4 Message-Digest Algorithm */ #define INIT_DATA_A (unsigned long)0x67452301L #define INIT_DATA_B (unsigned long)0xefcdab89L #define INIT_DATA_C (unsigned long)0x98badcfeL #define INIT_DATA_D (unsigned long)0x10325476L int MD4_Init(MD4_CTX *c) { memset (c,0,sizeof(*c)); c->A=INIT_DATA_A; c->B=INIT_DATA_B; c->C=INIT_DATA_C; c->D=INIT_DATA_D; return 1; } #ifndef md4_block_data_order #ifdef X #undef X #endif void md4_block_data_order (MD4_CTX *c, const void *data_, size_t num) { const unsigned char *data=data_; register unsigned MD32_REG_T A,B,C,D,l; #ifndef MD32_XARRAY /* See comment in crypto/sha/sha_locl.h for details. */ unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; # define X(i) XX##i #else MD4_LONG XX[MD4_LBLOCK]; # define X(i) XX[i] #endif A=c->A; B=c->B; C=c->C; D=c->D; for (;num--;) { (void)HOST_c2l(data,l); X( 0)=l; (void)HOST_c2l(data,l); X( 1)=l; /* Round 0 */ R0(A,B,C,D,X( 0), 3,0); (void)HOST_c2l(data,l); X( 2)=l; R0(D,A,B,C,X( 1), 7,0); (void)HOST_c2l(data,l); X( 3)=l; R0(C,D,A,B,X( 2),11,0); (void)HOST_c2l(data,l); X( 4)=l; R0(B,C,D,A,X( 3),19,0); (void)HOST_c2l(data,l); X( 5)=l; R0(A,B,C,D,X( 4), 3,0); (void)HOST_c2l(data,l); X( 6)=l; R0(D,A,B,C,X( 5), 7,0); (void)HOST_c2l(data,l); X( 7)=l; R0(C,D,A,B,X( 6),11,0); (void)HOST_c2l(data,l); X( 8)=l; R0(B,C,D,A,X( 7),19,0); (void)HOST_c2l(data,l); X( 9)=l; R0(A,B,C,D,X( 8), 3,0); (void)HOST_c2l(data,l); X(10)=l; R0(D,A,B,C,X( 9), 7,0); (void)HOST_c2l(data,l); X(11)=l; R0(C,D,A,B,X(10),11,0); (void)HOST_c2l(data,l); X(12)=l; R0(B,C,D,A,X(11),19,0); (void)HOST_c2l(data,l); X(13)=l; R0(A,B,C,D,X(12), 3,0); (void)HOST_c2l(data,l); X(14)=l; R0(D,A,B,C,X(13), 7,0); (void)HOST_c2l(data,l); X(15)=l; R0(C,D,A,B,X(14),11,0); R0(B,C,D,A,X(15),19,0); /* Round 1 */ R1(A,B,C,D,X( 0), 3,0x5A827999L); R1(D,A,B,C,X( 4), 5,0x5A827999L); R1(C,D,A,B,X( 8), 9,0x5A827999L); R1(B,C,D,A,X(12),13,0x5A827999L); R1(A,B,C,D,X( 1), 3,0x5A827999L); R1(D,A,B,C,X( 5), 5,0x5A827999L); R1(C,D,A,B,X( 9), 9,0x5A827999L); R1(B,C,D,A,X(13),13,0x5A827999L); R1(A,B,C,D,X( 2), 3,0x5A827999L); R1(D,A,B,C,X( 6), 5,0x5A827999L); R1(C,D,A,B,X(10), 9,0x5A827999L); R1(B,C,D,A,X(14),13,0x5A827999L); R1(A,B,C,D,X( 3), 3,0x5A827999L); R1(D,A,B,C,X( 7), 5,0x5A827999L); R1(C,D,A,B,X(11), 9,0x5A827999L); R1(B,C,D,A,X(15),13,0x5A827999L); /* Round 2 */ R2(A,B,C,D,X( 0), 3,0x6ED9EBA1L); R2(D,A,B,C,X( 8), 9,0x6ED9EBA1L); R2(C,D,A,B,X( 4),11,0x6ED9EBA1L); R2(B,C,D,A,X(12),15,0x6ED9EBA1L); R2(A,B,C,D,X( 2), 3,0x6ED9EBA1L); R2(D,A,B,C,X(10), 9,0x6ED9EBA1L); R2(C,D,A,B,X( 6),11,0x6ED9EBA1L); R2(B,C,D,A,X(14),15,0x6ED9EBA1L); R2(A,B,C,D,X( 1), 3,0x6ED9EBA1L); R2(D,A,B,C,X( 9), 9,0x6ED9EBA1L); R2(C,D,A,B,X( 5),11,0x6ED9EBA1L); R2(B,C,D,A,X(13),15,0x6ED9EBA1L); R2(A,B,C,D,X( 3), 3,0x6ED9EBA1L); R2(D,A,B,C,X(11), 9,0x6ED9EBA1L); R2(C,D,A,B,X( 7),11,0x6ED9EBA1L); R2(B,C,D,A,X(15),15,0x6ED9EBA1L); A = c->A += A; B = c->B += B; C = c->C += C; D = c->D += D; } } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/chacha/0000755000000000000000000000000012666635521021261 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/chacha/chacha.c0000644000175000017500000000437112360020705021042 0ustar /* $OpenBSD: chacha.c,v 1.5 2014/06/24 18:12:09 jsing Exp $ */ /* * Copyright (c) 2014 Joel Sing * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include "chacha-merged.c" void ChaCha_set_key(ChaCha_ctx *ctx, const unsigned char *key, uint32_t keybits) { chacha_keysetup((chacha_ctx *)ctx, key, keybits); ctx->unused = 0; } void ChaCha_set_iv(ChaCha_ctx *ctx, const unsigned char *iv, const unsigned char *counter) { chacha_ivsetup((chacha_ctx *)ctx, iv, counter); ctx->unused = 0; } void ChaCha(ChaCha_ctx *ctx, unsigned char *out, const unsigned char *in, size_t len) { unsigned char *k; int i, l; /* Consume remaining keystream, if any exists. */ if (ctx->unused > 0) { k = ctx->ks + 64 - ctx->unused; l = (len > ctx->unused) ? ctx->unused : len; for (i = 0; i < l; i++) *(out++) = *(in++) ^ *(k++); ctx->unused -= l; len -= l; } chacha_encrypt_bytes((chacha_ctx *)ctx, in, out, (uint32_t)len); } void CRYPTO_chacha_20(unsigned char *out, const unsigned char *in, size_t len, const unsigned char key[32], const unsigned char iv[8], size_t counter) { struct chacha_ctx ctx; /* * chacha_ivsetup expects the counter to be in u8. Rather than * converting size_t to u8 and then back again, pass a counter of * NULL and manually assign it afterwards. */ chacha_keysetup(&ctx, key, 256); chacha_ivsetup(&ctx, iv, NULL); if (counter != 0) { ctx.input[12] = (uint32_t)counter; ctx.input[13] = (uint32_t)(((uint64_t)counter) >> 32); } chacha_encrypt_bytes(&ctx, in, out, (uint32_t)len); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/chacha/chacha-merged.c0000644000175000017500000001513412360020705022302 0ustar /* $OpenBSD: chacha-merged.c,v 1.6 2014/06/24 18:12:09 jsing Exp $ */ /* chacha-merged.c version 20080118 D. J. Bernstein Public domain. */ #include #include #define CHACHA_MINKEYLEN 16 #define CHACHA_NONCELEN 8 #define CHACHA_CTRLEN 8 #define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN) #define CHACHA_BLOCKLEN 64 struct chacha_ctx { u_int input[16]; uint8_t ks[CHACHA_BLOCKLEN]; uint8_t unused; }; static inline void chacha_keysetup(struct chacha_ctx *x, const u_char *k, u_int kbits) __attribute__((__bounded__(__minbytes__, 2, CHACHA_MINKEYLEN))); static inline void chacha_ivsetup(struct chacha_ctx *x, const u_char *iv, const u_char *ctr) __attribute__((__bounded__(__minbytes__, 2, CHACHA_NONCELEN))) __attribute__((__bounded__(__minbytes__, 3, CHACHA_CTRLEN))); static inline void chacha_encrypt_bytes(struct chacha_ctx *x, const u_char *m, u_char *c, u_int bytes) __attribute__((__bounded__(__buffer__, 2, 4))) __attribute__((__bounded__(__buffer__, 3, 4))); typedef unsigned char u8; typedef unsigned int u32; typedef struct chacha_ctx chacha_ctx; #define U8C(v) (v##U) #define U32C(v) (v##U) #define U8V(v) ((u8)(v) & U8C(0xFF)) #define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF)) #define ROTL32(v, n) \ (U32V((v) << (n)) | ((v) >> (32 - (n)))) #define U8TO32_LITTLE(p) \ (((u32)((p)[0])) | \ ((u32)((p)[1]) << 8) | \ ((u32)((p)[2]) << 16) | \ ((u32)((p)[3]) << 24)) #define U32TO8_LITTLE(p, v) \ do { \ (p)[0] = U8V((v)); \ (p)[1] = U8V((v) >> 8); \ (p)[2] = U8V((v) >> 16); \ (p)[3] = U8V((v) >> 24); \ } while (0) #define ROTATE(v,c) (ROTL32(v,c)) #define XOR(v,w) ((v) ^ (w)) #define PLUS(v,w) (U32V((v) + (w))) #define PLUSONE(v) (PLUS((v),1)) #define QUARTERROUND(a,b,c,d) \ a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \ c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \ a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \ c = PLUS(c,d); b = ROTATE(XOR(b,c), 7); static const char sigma[16] = "expand 32-byte k"; static const char tau[16] = "expand 16-byte k"; static inline void chacha_keysetup(chacha_ctx *x, const u8 *k, u32 kbits) { const char *constants; x->input[4] = U8TO32_LITTLE(k + 0); x->input[5] = U8TO32_LITTLE(k + 4); x->input[6] = U8TO32_LITTLE(k + 8); x->input[7] = U8TO32_LITTLE(k + 12); if (kbits == 256) { /* recommended */ k += 16; constants = sigma; } else { /* kbits == 128 */ constants = tau; } x->input[8] = U8TO32_LITTLE(k + 0); x->input[9] = U8TO32_LITTLE(k + 4); x->input[10] = U8TO32_LITTLE(k + 8); x->input[11] = U8TO32_LITTLE(k + 12); x->input[0] = U8TO32_LITTLE(constants + 0); x->input[1] = U8TO32_LITTLE(constants + 4); x->input[2] = U8TO32_LITTLE(constants + 8); x->input[3] = U8TO32_LITTLE(constants + 12); } static inline void chacha_ivsetup(chacha_ctx *x, const u8 *iv, const u8 *counter) { x->input[12] = counter == NULL ? 0 : U8TO32_LITTLE(counter + 0); x->input[13] = counter == NULL ? 0 : U8TO32_LITTLE(counter + 4); x->input[14] = U8TO32_LITTLE(iv + 0); x->input[15] = U8TO32_LITTLE(iv + 4); } static inline void chacha_encrypt_bytes(chacha_ctx *x, const u8 *m, u8 *c, u32 bytes) { u32 x0, x1, x2, x3, x4, x5, x6, x7; u32 x8, x9, x10, x11, x12, x13, x14, x15; u32 j0, j1, j2, j3, j4, j5, j6, j7; u32 j8, j9, j10, j11, j12, j13, j14, j15; u8 *ctarget = NULL; u8 tmp[64]; u_int i; if (!bytes) return; j0 = x->input[0]; j1 = x->input[1]; j2 = x->input[2]; j3 = x->input[3]; j4 = x->input[4]; j5 = x->input[5]; j6 = x->input[6]; j7 = x->input[7]; j8 = x->input[8]; j9 = x->input[9]; j10 = x->input[10]; j11 = x->input[11]; j12 = x->input[12]; j13 = x->input[13]; j14 = x->input[14]; j15 = x->input[15]; for (;;) { if (bytes < 64) { for (i = 0; i < bytes; ++i) tmp[i] = m[i]; m = tmp; ctarget = c; c = tmp; } x0 = j0; x1 = j1; x2 = j2; x3 = j3; x4 = j4; x5 = j5; x6 = j6; x7 = j7; x8 = j8; x9 = j9; x10 = j10; x11 = j11; x12 = j12; x13 = j13; x14 = j14; x15 = j15; for (i = 20; i > 0; i -= 2) { QUARTERROUND(x0, x4, x8, x12) QUARTERROUND(x1, x5, x9, x13) QUARTERROUND(x2, x6, x10, x14) QUARTERROUND(x3, x7, x11, x15) QUARTERROUND(x0, x5, x10, x15) QUARTERROUND(x1, x6, x11, x12) QUARTERROUND(x2, x7, x8, x13) QUARTERROUND(x3, x4, x9, x14) } x0 = PLUS(x0, j0); x1 = PLUS(x1, j1); x2 = PLUS(x2, j2); x3 = PLUS(x3, j3); x4 = PLUS(x4, j4); x5 = PLUS(x5, j5); x6 = PLUS(x6, j6); x7 = PLUS(x7, j7); x8 = PLUS(x8, j8); x9 = PLUS(x9, j9); x10 = PLUS(x10, j10); x11 = PLUS(x11, j11); x12 = PLUS(x12, j12); x13 = PLUS(x13, j13); x14 = PLUS(x14, j14); x15 = PLUS(x15, j15); if (bytes < 64) { U32TO8_LITTLE(x->ks + 0, x0); U32TO8_LITTLE(x->ks + 4, x1); U32TO8_LITTLE(x->ks + 8, x2); U32TO8_LITTLE(x->ks + 12, x3); U32TO8_LITTLE(x->ks + 16, x4); U32TO8_LITTLE(x->ks + 20, x5); U32TO8_LITTLE(x->ks + 24, x6); U32TO8_LITTLE(x->ks + 28, x7); U32TO8_LITTLE(x->ks + 32, x8); U32TO8_LITTLE(x->ks + 36, x9); U32TO8_LITTLE(x->ks + 40, x10); U32TO8_LITTLE(x->ks + 44, x11); U32TO8_LITTLE(x->ks + 48, x12); U32TO8_LITTLE(x->ks + 52, x13); U32TO8_LITTLE(x->ks + 56, x14); U32TO8_LITTLE(x->ks + 60, x15); } x0 = XOR(x0, U8TO32_LITTLE(m + 0)); x1 = XOR(x1, U8TO32_LITTLE(m + 4)); x2 = XOR(x2, U8TO32_LITTLE(m + 8)); x3 = XOR(x3, U8TO32_LITTLE(m + 12)); x4 = XOR(x4, U8TO32_LITTLE(m + 16)); x5 = XOR(x5, U8TO32_LITTLE(m + 20)); x6 = XOR(x6, U8TO32_LITTLE(m + 24)); x7 = XOR(x7, U8TO32_LITTLE(m + 28)); x8 = XOR(x8, U8TO32_LITTLE(m + 32)); x9 = XOR(x9, U8TO32_LITTLE(m + 36)); x10 = XOR(x10, U8TO32_LITTLE(m + 40)); x11 = XOR(x11, U8TO32_LITTLE(m + 44)); x12 = XOR(x12, U8TO32_LITTLE(m + 48)); x13 = XOR(x13, U8TO32_LITTLE(m + 52)); x14 = XOR(x14, U8TO32_LITTLE(m + 56)); x15 = XOR(x15, U8TO32_LITTLE(m + 60)); j12 = PLUSONE(j12); if (!j12) { j13 = PLUSONE(j13); /* * Stopping at 2^70 bytes per nonce is the user's * responsibility. */ } U32TO8_LITTLE(c + 0, x0); U32TO8_LITTLE(c + 4, x1); U32TO8_LITTLE(c + 8, x2); U32TO8_LITTLE(c + 12, x3); U32TO8_LITTLE(c + 16, x4); U32TO8_LITTLE(c + 20, x5); U32TO8_LITTLE(c + 24, x6); U32TO8_LITTLE(c + 28, x7); U32TO8_LITTLE(c + 32, x8); U32TO8_LITTLE(c + 36, x9); U32TO8_LITTLE(c + 40, x10); U32TO8_LITTLE(c + 44, x11); U32TO8_LITTLE(c + 48, x12); U32TO8_LITTLE(c + 52, x13); U32TO8_LITTLE(c + 56, x14); U32TO8_LITTLE(c + 60, x15); if (bytes <= 64) { if (bytes < 64) { for (i = 0; i < bytes; ++i) ctarget[i] = c[i]; } x->input[12] = j12; x->input[13] = j13; x->unused = 64 - bytes; return; } bytes -= 64; c += 64; m += 64; } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/o_time.c0000644000175000017500000001211112360020705017667 0ustar /* $OpenBSD$ */ /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL * project 2001. */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2008. */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include "o_time.h" /* Take a tm structure and add an offset to it. This avoids any OS issues * with restricted date types and overflows which cause the year 2038 * problem. */ #define SECS_PER_DAY (24 * 60 * 60) static long date_to_julian(int y, int m, int d); static void julian_to_date(long jd, int *y, int *m, int *d); int OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec) { int offset_hms, offset_day; long time_jd; int time_year, time_month, time_day; /* split offset into days and day seconds */ offset_day = offset_sec / SECS_PER_DAY; /* Avoid sign issues with % operator */ offset_hms = offset_sec - (offset_day * SECS_PER_DAY); offset_day += off_day; /* Add current time seconds to offset */ offset_hms += tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec; /* Adjust day seconds if overflow */ if (offset_hms >= SECS_PER_DAY) { offset_day++; offset_hms -= SECS_PER_DAY; } else if (offset_hms < 0) { offset_day--; offset_hms += SECS_PER_DAY; } /* Convert date of time structure into a Julian day number. */ time_year = tm->tm_year + 1900; time_month = tm->tm_mon + 1; time_day = tm->tm_mday; time_jd = date_to_julian(time_year, time_month, time_day); /* Work out Julian day of new date */ time_jd += offset_day; if (time_jd < 0) return 0; /* Convert Julian day back to date */ julian_to_date(time_jd, &time_year, &time_month, &time_day); if (time_year < 1900 || time_year > 9999) return 0; /* Update tm structure */ tm->tm_year = time_year - 1900; tm->tm_mon = time_month - 1; tm->tm_mday = time_day; tm->tm_hour = offset_hms / 3600; tm->tm_min = (offset_hms / 60) % 60; tm->tm_sec = offset_hms % 60; return 1; } /* Convert date to and from julian day * Uses Fliegel & Van Flandern algorithm */ static long date_to_julian(int y, int m, int d) { return (1461 * (y + 4800 + (m - 14) / 12)) / 4 + (367 * (m - 2 - 12 * ((m - 14) / 12))) / 12 - (3 * ((y + 4900 + (m - 14) / 12) / 100)) / 4 + d - 32075; } static void julian_to_date(long jd, int *y, int *m, int *d) { long L = jd + 68569; long n = (4 * L) / 146097; long i, j; L = L - (146097 * n + 3) / 4; i = (4000 * (L + 1)) / 1461001; L = L - (1461 * i) / 4 + 31; j = (80 * L) / 2447; *d = L - (2447 * j) / 80; L = j / 11; *m = j + 2 - (12 * L); *y = 100 * (n - 49) + i + L; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/0000755000000000000000000000000012666635521020451 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_x931p.c0000644000175000017500000001536512360020705020373 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2005. */ /* ==================================================================== * Copyright (c) 2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include /* X9.31 routines for prime derivation */ /* X9.31 prime derivation. This is used to generate the primes pi * (p1, p2, q1, q2) from a parameter Xpi by checking successive odd * integers. */ static int bn_x931_derive_pi(BIGNUM *pi, const BIGNUM *Xpi, BN_CTX *ctx, BN_GENCB *cb) { int i = 0; if (!BN_copy(pi, Xpi)) return 0; if (!BN_is_odd(pi) && !BN_add_word(pi, 1)) return 0; for (;;) { i++; BN_GENCB_call(cb, 0, i); /* NB 27 MR is specificed in X9.31 */ if (BN_is_prime_fasttest_ex(pi, 27, ctx, 1, cb)) break; if (!BN_add_word(pi, 2)) return 0; } BN_GENCB_call(cb, 2, i); return 1; } /* This is the main X9.31 prime derivation function. From parameters * Xp1, Xp2 and Xp derive the prime p. If the parameters p1 or p2 are * not NULL they will be returned too: this is needed for testing. */ int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, const BIGNUM *Xp, const BIGNUM *Xp1, const BIGNUM *Xp2, const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb) { int ret = 0; BIGNUM *t, *p1p2, *pm1; /* Only even e supported */ if (!BN_is_odd(e)) return 0; BN_CTX_start(ctx); if (!p1) p1 = BN_CTX_get(ctx); if (!p2) p2 = BN_CTX_get(ctx); t = BN_CTX_get(ctx); p1p2 = BN_CTX_get(ctx); pm1 = BN_CTX_get(ctx); if (!bn_x931_derive_pi(p1, Xp1, ctx, cb)) goto err; if (!bn_x931_derive_pi(p2, Xp2, ctx, cb)) goto err; if (!BN_mul(p1p2, p1, p2, ctx)) goto err; /* First set p to value of Rp */ if (!BN_mod_inverse(p, p2, p1, ctx)) goto err; if (!BN_mul(p, p, p2, ctx)) goto err; if (!BN_mod_inverse(t, p1, p2, ctx)) goto err; if (!BN_mul(t, t, p1, ctx)) goto err; if (!BN_sub(p, p, t)) goto err; if (p->neg && !BN_add(p, p, p1p2)) goto err; /* p now equals Rp */ if (!BN_mod_sub(p, p, Xp, p1p2, ctx)) goto err; if (!BN_add(p, p, Xp)) goto err; /* p now equals Yp0 */ for (;;) { int i = 1; BN_GENCB_call(cb, 0, i++); if (!BN_copy(pm1, p)) goto err; if (!BN_sub_word(pm1, 1)) goto err; if (!BN_gcd(t, pm1, e, ctx)) goto err; if (BN_is_one(t) /* X9.31 specifies 8 MR and 1 Lucas test or any prime test * offering similar or better guarantees 50 MR is considerably * better. */ && BN_is_prime_fasttest_ex(p, 50, ctx, 1, cb)) break; if (!BN_add(p, p, p1p2)) goto err; } BN_GENCB_call(cb, 3, 0); ret = 1; err: BN_CTX_end(ctx); return ret; } /* Generate pair of paramters Xp, Xq for X9.31 prime generation. * Note: nbits paramter is sum of number of bits in both. */ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx) { BIGNUM *t; int i; /* Number of bits for each prime is of the form * 512+128s for s = 0, 1, ... */ if ((nbits < 1024) || (nbits & 0xff)) return 0; nbits >>= 1; /* The random value Xp must be between sqrt(2) * 2^(nbits-1) and * 2^nbits - 1. By setting the top two bits we ensure that the lower * bound is exceeded. */ if (!BN_rand(Xp, nbits, 1, 0)) return 0; BN_CTX_start(ctx); t = BN_CTX_get(ctx); for (i = 0; i < 1000; i++) { if (!BN_rand(Xq, nbits, 1, 0)) return 0; /* Check that |Xp - Xq| > 2^(nbits - 100) */ BN_sub(t, Xp, Xq); if (BN_num_bits(t) > (nbits - 100)) break; } BN_CTX_end(ctx); if (i < 1000) return 1; return 0; } /* Generate primes using X9.31 algorithm. Of the values p, p1, p2, Xp1 * and Xp2 only 'p' needs to be non-NULL. If any of the others are not NULL * the relevant parameter will be stored in it. * * Due to the fact that |Xp - Xq| > 2^(nbits - 100) must be satisfied Xp and Xq * are generated using the previous function and supplied as input. */ int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, BIGNUM *Xp1, BIGNUM *Xp2, const BIGNUM *Xp, const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb) { int ret = 0; BN_CTX_start(ctx); if (!Xp1) Xp1 = BN_CTX_get(ctx); if (!Xp2) Xp2 = BN_CTX_get(ctx); if (!BN_rand(Xp1, 101, 0, 0)) goto error; if (!BN_rand(Xp2, 101, 0, 0)) goto error; if (!BN_X931_derive_prime_ex(p, p1, p2, Xp, Xp1, Xp2, e, ctx, cb)) goto error; ret = 1; error: BN_CTX_end(ctx); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_lcl.h0000644000175000017500000003711512360020705020263 0ustar /* $OpenBSD: bn_lcl.h,v 1.19 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #ifndef HEADER_BN_LCL_H #define HEADER_BN_LCL_H #include #include #ifdef __cplusplus extern "C" { #endif /* * BN_window_bits_for_exponent_size -- macro for sliding window mod_exp functions * * * For window size 'w' (w >= 2) and a random 'b' bits exponent, * the number of multiplications is a constant plus on average * * 2^(w-1) + (b-w)/(w+1); * * here 2^(w-1) is for precomputing the table (we actually need * entries only for windows that have the lowest bit set), and * (b-w)/(w+1) is an approximation for the expected number of * w-bit windows, not counting the first one. * * Thus we should use * * w >= 6 if b > 671 * w = 5 if 671 > b > 239 * w = 4 if 239 > b > 79 * w = 3 if 79 > b > 23 * w <= 2 if 23 > b * * (with draws in between). Very small exponents are often selected * with low Hamming weight, so we use w = 1 for b <= 23. */ #define BN_window_bits_for_exponent_size(b) \ ((b) > 671 ? 6 : \ (b) > 239 ? 5 : \ (b) > 79 ? 4 : \ (b) > 23 ? 3 : 1) /* BN_mod_exp_mont_consttime is based on the assumption that the * L1 data cache line width of the target processor is at least * the following value. */ #define MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH ( 64 ) #define MOD_EXP_CTIME_MIN_CACHE_LINE_MASK (MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH - 1) /* Window sizes optimized for fixed window size modular exponentiation * algorithm (BN_mod_exp_mont_consttime). * * To achieve the security goals of BN_mode_exp_mont_consttime, the * maximum size of the window must not exceed * log_2(MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH). * * Window size thresholds are defined for cache line sizes of 32 and 64, * cache line sizes where log_2(32)=5 and log_2(64)=6 respectively. A * window size of 7 should only be used on processors that have a 128 * byte or greater cache line size. */ #if MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 64 # define BN_window_bits_for_ctime_exponent_size(b) \ ((b) > 937 ? 6 : \ (b) > 306 ? 5 : \ (b) > 89 ? 4 : \ (b) > 22 ? 3 : 1) # define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (6) #elif MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 32 # define BN_window_bits_for_ctime_exponent_size(b) \ ((b) > 306 ? 5 : \ (b) > 89 ? 4 : \ (b) > 22 ? 3 : 1) # define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (5) #endif /* Pentium pro 16,16,16,32,64 */ /* Alpha 16,16,16,16.64 */ #define BN_MULL_SIZE_NORMAL (16) /* 32 */ #define BN_MUL_RECURSIVE_SIZE_NORMAL (16) /* 32 less than */ #define BN_SQR_RECURSIVE_SIZE_NORMAL (16) /* 32 */ #define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32) /* 32 */ #define BN_MONT_CTX_SET_SIZE_WORD (64) /* 32 */ #if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) /* * BN_UMULT_HIGH section. * * No, I'm not trying to overwhelm you when stating that the * product of N-bit numbers is 2*N bits wide:-) No, I don't expect * you to be impressed when I say that if the compiler doesn't * support 2*N integer type, then you have to replace every N*N * multiplication with 4 (N/2)*(N/2) accompanied by some shifts * and additions which unavoidably results in severe performance * penalties. Of course provided that the hardware is capable of * producing 2*N result... That's when you normally start * considering assembler implementation. However! It should be * pointed out that some CPUs (most notably Alpha, PowerPC and * upcoming IA-64 family:-) provide *separate* instruction * calculating the upper half of the product placing the result * into a general purpose register. Now *if* the compiler supports * inline assembler, then it's not impossible to implement the * "bignum" routines (and have the compiler optimize 'em) * exhibiting "native" performance in C. That's what BN_UMULT_HIGH * macro is about:-) * * */ # if defined(__alpha) # if defined(__GNUC__) && __GNUC__>=2 # define BN_UMULT_HIGH(a,b) ({ \ register BN_ULONG ret; \ asm ("umulh %1,%2,%0" \ : "=r"(ret) \ : "r"(a), "r"(b)); \ ret; }) # endif /* compiler */ # elif defined(_ARCH_PPC) && defined(_LP64) # if defined(__GNUC__) && __GNUC__>=2 # define BN_UMULT_HIGH(a,b) ({ \ register BN_ULONG ret; \ asm ("mulhdu %0,%1,%2" \ : "=r"(ret) \ : "r"(a), "r"(b)); \ ret; }) # endif /* compiler */ # elif defined(__x86_64) || defined(__x86_64__) # if defined(__GNUC__) && __GNUC__>=2 # define BN_UMULT_HIGH(a,b) ({ \ register BN_ULONG ret,discard; \ asm ("mulq %3" \ : "=a"(discard),"=d"(ret) \ : "a"(a), "g"(b) \ : "cc"); \ ret; }) # define BN_UMULT_LOHI(low,high,a,b) \ asm ("mulq %3" \ : "=a"(low),"=d"(high) \ : "a"(a),"g"(b) \ : "cc"); # endif # elif defined(__mips) && defined(_LP64) # if defined(__GNUC__) && __GNUC__>=2 # if __GNUC__>=4 && __GNUC_MINOR__>=4 /* "h" constraint is no more since 4.4 */ # define BN_UMULT_HIGH(a,b) (((__uint128_t)(a)*(b))>>64) # define BN_UMULT_LOHI(low,high,a,b) ({ \ __uint128_t ret=(__uint128_t)(a)*(b); \ (high)=ret>>64; (low)=ret; }) # else # define BN_UMULT_HIGH(a,b) ({ \ register BN_ULONG ret; \ asm ("dmultu %1,%2" \ : "=h"(ret) \ : "r"(a), "r"(b) : "l"); \ ret; }) # define BN_UMULT_LOHI(low,high,a,b)\ asm ("dmultu %2,%3" \ : "=l"(low),"=h"(high) \ : "r"(a), "r"(b)); # endif # endif # endif /* cpu */ #endif /* OPENSSL_NO_ASM */ /************************************************************* * Using the long long type */ #define Lw(t) (((BN_ULONG)(t))&BN_MASK2) #define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2) #ifdef BN_DEBUG_RAND #define bn_clear_top2max(a) \ { \ int ind = (a)->dmax - (a)->top; \ BN_ULONG *ftl = &(a)->d[(a)->top-1]; \ for (; ind != 0; ind--) \ *(++ftl) = 0x0; \ } #else #define bn_clear_top2max(a) #endif #ifdef BN_LLONG #define mul_add(r,a,w,c) { \ BN_ULLONG t; \ t=(BN_ULLONG)w * (a) + (r) + (c); \ (r)= Lw(t); \ (c)= Hw(t); \ } #define mul(r,a,w,c) { \ BN_ULLONG t; \ t=(BN_ULLONG)w * (a) + (c); \ (r)= Lw(t); \ (c)= Hw(t); \ } #define sqr(r0,r1,a) { \ BN_ULLONG t; \ t=(BN_ULLONG)(a)*(a); \ (r0)=Lw(t); \ (r1)=Hw(t); \ } #elif defined(BN_UMULT_LOHI) #define mul_add(r,a,w,c) { \ BN_ULONG high,low,ret,tmp=(a); \ ret = (r); \ BN_UMULT_LOHI(low,high,w,tmp); \ ret += (c); \ (c) = (ret<(c))?1:0; \ (c) += high; \ ret += low; \ (c) += (ret>BN_BITS4)&BN_MASK2l) #define L2HBITS(a) (((a)<>(BN_BITS4-1); \ m =(m&BN_MASK2l)<<(BN_BITS4+1); \ l=(l+m)&BN_MASK2; if (l < m) h++; \ (lo)=l; \ (ho)=h; \ } #define mul_add(r,a,bl,bh,c) { \ BN_ULONG l,h; \ \ h= (a); \ l=LBITS(h); \ h=HBITS(h); \ mul64(l,h,(bl),(bh)); \ \ /* non-multiply part */ \ l=(l+(c))&BN_MASK2; if (l < (c)) h++; \ (c)=(r); \ l=(l+(c))&BN_MASK2; if (l < (c)) h++; \ (c)=h&BN_MASK2; \ (r)=l; \ } #define mul(r,a,bl,bh,c) { \ BN_ULONG l,h; \ \ h= (a); \ l=LBITS(h); \ h=HBITS(h); \ mul64(l,h,(bl),(bh)); \ \ /* non-multiply part */ \ l+=(c); if ((l&BN_MASK2) < (c)) h++; \ (c)=h&BN_MASK2; \ (r)=l&BN_MASK2; \ } #endif /* !BN_LLONG */ void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb); void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b); void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b); void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp); void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a); void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a); int bn_cmp_words(const BN_ULONG *a, const BN_ULONG *b, int n); int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b, int cl, int dl); void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, int dna, int dnb, BN_ULONG *t); void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n, int tna, int tnb, BN_ULONG *t); void bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t); void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n); void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, BN_ULONG *t); void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2, BN_ULONG *t); BN_ULONG bn_add_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int cl, int dl); BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int cl, int dl); int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num); #ifdef __cplusplus } #endif #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_word.c0000644000175000017500000001376112360020705020460 0ustar /* $OpenBSD: bn_word.c,v 1.11 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "bn_lcl.h" BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w) { #ifndef BN_LLONG BN_ULONG ret = 0; #else BN_ULLONG ret = 0; #endif int i; if (w == 0) return (BN_ULONG) - 1; bn_check_top(a); w &= BN_MASK2; for (i = a->top - 1; i >= 0; i--) { #ifndef BN_LLONG ret = ((ret << BN_BITS4) | ((a->d[i] >> BN_BITS4) & BN_MASK2l)) % w; ret = ((ret << BN_BITS4) | (a->d[i] & BN_MASK2l)) % w; #else ret = (BN_ULLONG)(((ret << (BN_ULLONG)BN_BITS2) | a->d[i]) % (BN_ULLONG)w); #endif } return ((BN_ULONG)ret); } BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w) { BN_ULONG ret = 0; int i, j; bn_check_top(a); w &= BN_MASK2; if (!w) /* actually this an error (division by zero) */ return (BN_ULONG) - 1; if (a->top == 0) return 0; /* normalize input (so bn_div_words doesn't complain) */ j = BN_BITS2 - BN_num_bits_word(w); w <<= j; if (!BN_lshift(a, a, j)) return (BN_ULONG) - 1; for (i = a->top - 1; i >= 0; i--) { BN_ULONG l, d; l = a->d[i]; d = bn_div_words(ret, l, w); ret = (l - ((d*w)&BN_MASK2))&BN_MASK2; a->d[i] = d; } if ((a->top > 0) && (a->d[a->top - 1] == 0)) a->top--; ret >>= j; bn_check_top(a); return (ret); } int BN_add_word(BIGNUM *a, BN_ULONG w) { BN_ULONG l; int i; bn_check_top(a); w &= BN_MASK2; /* degenerate case: w is zero */ if (!w) return 1; /* degenerate case: a is zero */ if (BN_is_zero(a)) return BN_set_word(a, w); /* handle 'a' when negative */ if (a->neg) { a->neg = 0; i = BN_sub_word(a, w); if (!BN_is_zero(a)) a->neg=!(a->neg); return (i); } for (i = 0; w != 0 && i < a->top; i++) { a->d[i] = l = (a->d[i] + w) & BN_MASK2; w = (w > l) ? 1 : 0; } if (w && i == a->top) { if (bn_wexpand(a, a->top + 1) == NULL) return 0; a->top++; a->d[i] = w; } bn_check_top(a); return (1); } int BN_sub_word(BIGNUM *a, BN_ULONG w) { int i; bn_check_top(a); w &= BN_MASK2; /* degenerate case: w is zero */ if (!w) return 1; /* degenerate case: a is zero */ if (BN_is_zero(a)) { i = BN_set_word(a, w); if (i != 0) BN_set_negative(a, 1); return i; } /* handle 'a' when negative */ if (a->neg) { a->neg = 0; i = BN_add_word(a, w); a->neg = 1; return (i); } if ((a->top == 1) && (a->d[0] < w)) { a->d[0] = w - a->d[0]; a->neg = 1; return (1); } i = 0; for (;;) { if (a->d[i] >= w) { a->d[i] -= w; break; } else { a->d[i] = (a->d[i] - w) & BN_MASK2; i++; w = 1; } } if ((a->d[i] == 0) && (i == (a->top - 1))) a->top--; bn_check_top(a); return (1); } int BN_mul_word(BIGNUM *a, BN_ULONG w) { BN_ULONG ll; bn_check_top(a); w &= BN_MASK2; if (a->top) { if (w == 0) BN_zero(a); else { ll = bn_mul_words(a->d, a->d, a->top, w); if (ll) { if (bn_wexpand(a, a->top + 1) == NULL) return (0); a->d[a->top++] = ll; } } } bn_check_top(a); return (1); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_rand.c0000644000175000017500000002215312360020705020424 0ustar /* $OpenBSD: bn_rand.c,v 1.14 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include "bn_lcl.h" static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) { unsigned char *buf = NULL; int ret = 0, bit, bytes, mask; if (bits == 0) { BN_zero(rnd); return 1; } bytes = (bits + 7) / 8; bit = (bits - 1) % 8; mask = 0xff << (bit + 1); buf = malloc(bytes); if (buf == NULL) { BNerr(BN_F_BNRAND, ERR_R_MALLOC_FAILURE); goto err; } /* make a random number and set the top and bottom bits */ if (pseudorand) { if (RAND_pseudo_bytes(buf, bytes) == -1) goto err; } else { if (RAND_bytes(buf, bytes) <= 0) goto err; } #if 1 if (pseudorand == 2) { /* generate patterns that are more likely to trigger BN library bugs */ int i; unsigned char c; for (i = 0; i < bytes; i++) { RAND_pseudo_bytes(&c, 1); if (c >= 128 && i > 0) buf[i] = buf[i - 1]; else if (c < 42) buf[i] = 0; else if (c < 84) buf[i] = 255; } } #endif if (top != -1) { if (top) { if (bit == 0) { buf[0] = 1; buf[1] |= 0x80; } else { buf[0] |= (3 << (bit - 1)); } } else { buf[0] |= (1 << bit); } } buf[0] &= ~mask; if (bottom) /* set bottom bit if requested */ buf[bytes - 1] |= 1; if (!BN_bin2bn(buf, bytes, rnd)) goto err; ret = 1; err: if (buf != NULL) { OPENSSL_cleanse(buf, bytes); free(buf); } bn_check_top(rnd); return (ret); } int BN_rand(BIGNUM *rnd, int bits, int top, int bottom) { return bnrand(0, rnd, bits, top, bottom); } int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom) { return bnrand(1, rnd, bits, top, bottom); } #if 1 int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom) { return bnrand(2, rnd, bits, top, bottom); } #endif /* random number r: 0 <= r < range */ static int bn_rand_range(int pseudo, BIGNUM *r, const BIGNUM *range) { int (*bn_rand)(BIGNUM *, int, int, int) = pseudo ? BN_pseudo_rand : BN_rand; int n; int count = 100; if (range->neg || BN_is_zero(range)) { BNerr(BN_F_BN_RAND_RANGE, BN_R_INVALID_RANGE); return 0; } n = BN_num_bits(range); /* n > 0 */ /* BN_is_bit_set(range, n - 1) always holds */ if (n == 1) BN_zero(r); else if (!BN_is_bit_set(range, n - 2) && !BN_is_bit_set(range, n - 3)) { /* range = 100..._2, * so 3*range (= 11..._2) is exactly one bit longer than range */ do { if (!bn_rand(r, n + 1, -1, 0)) return 0; /* If r < 3*range, use r := r MOD range * (which is either r, r - range, or r - 2*range). * Otherwise, iterate once more. * Since 3*range = 11..._2, each iteration succeeds with * probability >= .75. */ if (BN_cmp(r, range) >= 0) { if (!BN_sub(r, r, range)) return 0; if (BN_cmp(r, range) >= 0) if (!BN_sub(r, r, range)) return 0; } if (!--count) { BNerr(BN_F_BN_RAND_RANGE, BN_R_TOO_MANY_ITERATIONS); return 0; } } while (BN_cmp(r, range) >= 0); } else { do { /* range = 11..._2 or range = 101..._2 */ if (!bn_rand(r, n, -1, 0)) return 0; if (!--count) { BNerr(BN_F_BN_RAND_RANGE, BN_R_TOO_MANY_ITERATIONS); return 0; } } while (BN_cmp(r, range) >= 0); } bn_check_top(r); return 1; } int BN_rand_range(BIGNUM *r, const BIGNUM *range) { return bn_rand_range(0, r, range); } int BN_pseudo_rand_range(BIGNUM *r, const BIGNUM *range) { return bn_rand_range(1, r, range); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_recp.c0000644000175000017500000001540212360020705020430 0ustar /* $OpenBSD: bn_recp.c,v 1.10 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include "bn_lcl.h" void BN_RECP_CTX_init(BN_RECP_CTX *recp) { BN_init(&(recp->N)); BN_init(&(recp->Nr)); recp->num_bits = 0; recp->flags = 0; } BN_RECP_CTX * BN_RECP_CTX_new(void) { BN_RECP_CTX *ret; if ((ret = malloc(sizeof(BN_RECP_CTX))) == NULL) return (NULL); BN_RECP_CTX_init(ret); ret->flags = BN_FLG_MALLOCED; return (ret); } void BN_RECP_CTX_free(BN_RECP_CTX *recp) { if (recp == NULL) return; BN_free(&(recp->N)); BN_free(&(recp->Nr)); if (recp->flags & BN_FLG_MALLOCED) free(recp); } int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx) { if (!BN_copy(&(recp->N), d)) return 0; BN_zero(&(recp->Nr)); recp->num_bits = BN_num_bits(d); recp->shift = 0; return (1); } int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y, BN_RECP_CTX *recp, BN_CTX *ctx) { int ret = 0; BIGNUM *a; const BIGNUM *ca; BN_CTX_start(ctx); if ((a = BN_CTX_get(ctx)) == NULL) goto err; if (y != NULL) { if (x == y) { if (!BN_sqr(a, x, ctx)) goto err; } else { if (!BN_mul(a, x, y, ctx)) goto err; } ca = a; } else ca = x; /* Just do the mod */ ret = BN_div_recp(NULL, r, ca, recp, ctx); err: BN_CTX_end(ctx); bn_check_top(r); return (ret); } int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, BN_RECP_CTX *recp, BN_CTX *ctx) { int i, j, ret = 0; BIGNUM *a, *b, *d, *r; BN_CTX_start(ctx); a = BN_CTX_get(ctx); b = BN_CTX_get(ctx); if (dv != NULL) d = dv; else d = BN_CTX_get(ctx); if (rem != NULL) r = rem; else r = BN_CTX_get(ctx); if (a == NULL || b == NULL || d == NULL || r == NULL) goto err; if (BN_ucmp(m, &(recp->N)) < 0) { BN_zero(d); if (!BN_copy(r, m)) return 0; BN_CTX_end(ctx); return (1); } /* We want the remainder * Given input of ABCDEF / ab * we need multiply ABCDEF by 3 digests of the reciprocal of ab * */ /* i := max(BN_num_bits(m), 2*BN_num_bits(N)) */ i = BN_num_bits(m); j = recp->num_bits << 1; if (j > i) i = j; /* Nr := round(2^i / N) */ if (i != recp->shift) recp->shift = BN_reciprocal(&(recp->Nr), &(recp->N), i, ctx); /* BN_reciprocal returns i, or -1 for an error */ if (recp->shift == -1) goto err; /* d := |round(round(m / 2^BN_num_bits(N)) * recp->Nr / 2^(i - BN_num_bits(N)))| * = |round(round(m / 2^BN_num_bits(N)) * round(2^i / N) / 2^(i - BN_num_bits(N)))| * <= |(m / 2^BN_num_bits(N)) * (2^i / N) * (2^BN_num_bits(N) / 2^i)| * = |m/N| */ if (!BN_rshift(a, m, recp->num_bits)) goto err; if (!BN_mul(b, a,&(recp->Nr), ctx)) goto err; if (!BN_rshift(d, b, i - recp->num_bits)) goto err; d->neg = 0; if (!BN_mul(b, &(recp->N), d, ctx)) goto err; if (!BN_usub(r, m, b)) goto err; r->neg = 0; #if 1 j = 0; while (BN_ucmp(r, &(recp->N)) >= 0) { if (j++ > 2) { BNerr(BN_F_BN_DIV_RECP, BN_R_BAD_RECIPROCAL); goto err; } if (!BN_usub(r, r, &(recp->N))) goto err; if (!BN_add_word(d, 1)) goto err; } #endif r->neg = BN_is_zero(r) ? 0 : m->neg; d->neg = m->neg^recp->N.neg; ret = 1; err: BN_CTX_end(ctx); bn_check_top(dv); bn_check_top(rem); return (ret); } /* len is the expected size of the result * We actually calculate with an extra word of precision, so * we can do faster division if the remainder is not required. */ /* r := 2^len / m */ int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx) { int ret = -1; BIGNUM *t; BN_CTX_start(ctx); if ((t = BN_CTX_get(ctx)) == NULL) goto err; if (!BN_set_bit(t, len)) goto err; if (!BN_div(r, NULL, t,m, ctx)) goto err; ret = len; err: bn_check_top(r); BN_CTX_end(ctx); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_div.c0000644000175000017500000002600612360020705020263 0ustar /* $OpenBSD: bn_div.c,v 1.21 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include "bn_lcl.h" #if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) \ && !defined(BN_DIV3W) # if defined(__GNUC__) && __GNUC__>=2 # if defined(__i386) || defined (__i386__) /* * There were two reasons for implementing this template: * - GNU C generates a call to a function (__udivdi3 to be exact) * in reply to ((((BN_ULLONG)n0)< */ #undef bn_div_words # define bn_div_words(n0,n1,d0) \ ({ asm volatile ( \ "divl %4" \ : "=a"(q), "=d"(rem) \ : "a"(n1), "d"(n0), "g"(d0) \ : "cc"); \ q; \ }) # define REMAINDER_IS_ALREADY_CALCULATED # elif defined(__x86_64) /* * Same story here, but it's 128-bit by 64-bit division. Wow! * */ # undef bn_div_words # define bn_div_words(n0,n1,d0) \ ({ asm volatile ( \ "divq %4" \ : "=a"(q), "=d"(rem) \ : "a"(n1), "d"(n0), "g"(d0) \ : "cc"); \ q; \ }) # define REMAINDER_IS_ALREADY_CALCULATED # endif /* __ */ # endif /* __GNUC__ */ #endif /* OPENSSL_NO_ASM */ /* BN_div computes dv := num / divisor, rounding towards * zero, and sets up rm such that dv*divisor + rm = num holds. * Thus: * dv->neg == num->neg ^ divisor->neg (unless the result is zero) * rm->neg == num->neg (unless the remainder is zero) * If 'dv' or 'rm' is NULL, the respective value is not returned. */ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, BN_CTX *ctx) { int norm_shift, i, loop; BIGNUM *tmp, wnum, *snum, *sdiv, *res; BN_ULONG *resp, *wnump; BN_ULONG d0, d1; int num_n, div_n; int no_branch = 0; /* Invalid zero-padding would have particularly bad consequences * in the case of 'num', so don't just rely on bn_check_top() for this one * (bn_check_top() works only for BN_DEBUG builds) */ if (num->top > 0 && num->d[num->top - 1] == 0) { BNerr(BN_F_BN_DIV, BN_R_NOT_INITIALIZED); return 0; } bn_check_top(num); if ((BN_get_flags(num, BN_FLG_CONSTTIME) != 0) || (BN_get_flags(divisor, BN_FLG_CONSTTIME) != 0)) { no_branch = 1; } bn_check_top(dv); bn_check_top(rm); /* bn_check_top(num); */ /* 'num' has been checked already */ bn_check_top(divisor); if (BN_is_zero(divisor)) { BNerr(BN_F_BN_DIV, BN_R_DIV_BY_ZERO); return (0); } if (!no_branch && BN_ucmp(num, divisor) < 0) { if (rm != NULL) { if (BN_copy(rm, num) == NULL) return (0); } if (dv != NULL) BN_zero(dv); return (1); } BN_CTX_start(ctx); tmp = BN_CTX_get(ctx); snum = BN_CTX_get(ctx); sdiv = BN_CTX_get(ctx); if (dv == NULL) res = BN_CTX_get(ctx); else res = dv; if (sdiv == NULL || res == NULL || tmp == NULL || snum == NULL) goto err; /* First we normalise the numbers */ norm_shift = BN_BITS2 - ((BN_num_bits(divisor)) % BN_BITS2); if (!(BN_lshift(sdiv, divisor, norm_shift))) goto err; sdiv->neg = 0; norm_shift += BN_BITS2; if (!(BN_lshift(snum, num, norm_shift))) goto err; snum->neg = 0; if (no_branch) { /* Since we don't know whether snum is larger than sdiv, * we pad snum with enough zeroes without changing its * value. */ if (snum->top <= sdiv->top + 1) { if (bn_wexpand(snum, sdiv->top + 2) == NULL) goto err; for (i = snum->top; i < sdiv->top + 2; i++) snum->d[i] = 0; snum->top = sdiv->top + 2; } else { if (bn_wexpand(snum, snum->top + 1) == NULL) goto err; snum->d[snum->top] = 0; snum->top ++; } } div_n = sdiv->top; num_n = snum->top; loop = num_n - div_n; /* Lets setup a 'window' into snum * This is the part that corresponds to the current * 'area' being divided */ wnum.neg = 0; wnum.d = &(snum->d[loop]); wnum.top = div_n; /* only needed when BN_ucmp messes up the values between top and max */ wnum.dmax = snum->dmax - loop; /* so we don't step out of bounds */ wnum.flags = snum->flags | BN_FLG_STATIC_DATA; /* Get the top 2 words of sdiv */ /* div_n=sdiv->top; */ d0 = sdiv->d[div_n - 1]; d1 = (div_n == 1) ? 0 : sdiv->d[div_n - 2]; /* pointer to the 'top' of snum */ wnump = &(snum->d[num_n - 1]); /* Setup to 'res' */ res->neg = (num->neg ^ divisor->neg); if (!bn_wexpand(res, (loop + 1))) goto err; res->top = loop - no_branch; resp = &(res->d[loop - 1]); /* space for temp */ if (!bn_wexpand(tmp, (div_n + 1))) goto err; if (!no_branch) { if (BN_ucmp(&wnum, sdiv) >= 0) { /* If BN_DEBUG_RAND is defined BN_ucmp changes (via * bn_pollute) the const bignum arguments => * clean the values between top and max again */ bn_clear_top2max(&wnum); bn_sub_words(wnum.d, wnum.d, sdiv->d, div_n); *resp = 1; } else res->top--; } /* if res->top == 0 then clear the neg value otherwise decrease * the resp pointer */ if (res->top == 0) res->neg = 0; else resp--; for (i = 0; i < loop - 1; i++, wnump--, resp--) { BN_ULONG q, l0; /* the first part of the loop uses the top two words of * snum and sdiv to calculate a BN_ULONG q such that * | wnum - sdiv * q | < sdiv */ #if defined(BN_DIV3W) && !defined(OPENSSL_NO_ASM) BN_ULONG bn_div_3_words(BN_ULONG*, BN_ULONG, BN_ULONG); q = bn_div_3_words(wnump, d1, d0); #else BN_ULONG n0, n1, rem = 0; n0 = wnump[0]; n1 = wnump[-1]; if (n0 == d0) q = BN_MASK2; else /* n0 < d0 */ { #ifdef BN_LLONG BN_ULLONG t2; #if defined(BN_DIV2W) && !defined(bn_div_words) q = (BN_ULONG)(((((BN_ULLONG)n0) << BN_BITS2)|n1)/d0); #else q = bn_div_words(n0, n1, d0); #endif #ifndef REMAINDER_IS_ALREADY_CALCULATED /* * rem doesn't have to be BN_ULLONG. The least we * know it's less that d0, isn't it? */ rem = (n1 - q * d0) & BN_MASK2; #endif t2 = (BN_ULLONG)d1*q; for (;;) { if (t2 <= ((((BN_ULLONG)rem) << BN_BITS2) | wnump[-2])) break; q--; rem += d0; if (rem < d0) break; /* don't let rem overflow */ t2 -= d1; } #else /* !BN_LLONG */ BN_ULONG t2l, t2h; q = bn_div_words(n0, n1, d0); #ifndef REMAINDER_IS_ALREADY_CALCULATED rem = (n1 - q*d0)&BN_MASK2; #endif #if defined(BN_UMULT_LOHI) BN_UMULT_LOHI(t2l, t2h, d1, q); #elif defined(BN_UMULT_HIGH) t2l = d1 * q; t2h = BN_UMULT_HIGH(d1, q); #else { BN_ULONG ql, qh; t2l = LBITS(d1); t2h = HBITS(d1); ql = LBITS(q); qh = HBITS(q); mul64(t2l, t2h, ql, qh); /* t2=(BN_ULLONG)d1*q; */ } #endif for (;;) { if ((t2h < rem) || ((t2h == rem) && (t2l <= wnump[-2]))) break; q--; rem += d0; if (rem < d0) break; /* don't let rem overflow */ if (t2l < d1) t2h--; t2l -= d1; } #endif /* !BN_LLONG */ } #endif /* !BN_DIV3W */ l0 = bn_mul_words(tmp->d, sdiv->d, div_n, q); tmp->d[div_n] = l0; wnum.d--; /* ingore top values of the bignums just sub the two * BN_ULONG arrays with bn_sub_words */ if (bn_sub_words(wnum.d, wnum.d, tmp->d, div_n + 1)) { /* Note: As we have considered only the leading * two BN_ULONGs in the calculation of q, sdiv * q * might be greater than wnum (but then (q-1) * sdiv * is less or equal than wnum) */ q--; if (bn_add_words(wnum.d, wnum.d, sdiv->d, div_n)) /* we can't have an overflow here (assuming * that q != 0, but if q == 0 then tmp is * zero anyway) */ (*wnump)++; } /* store part of the result */ *resp = q; } bn_correct_top(snum); if (rm != NULL) { /* Keep a copy of the neg flag in num because if rm==num * BN_rshift() will overwrite it. */ int neg = num->neg; BN_rshift(rm, snum, norm_shift); if (!BN_is_zero(rm)) rm->neg = neg; bn_check_top(rm); } if (no_branch) bn_correct_top(res); BN_CTX_end(ctx); return (1); err: bn_check_top(rm); BN_CTX_end(ctx); return (0); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_mont.c0000644000175000017500000003435112360020705020460 0ustar /* $OpenBSD: bn_mont.c,v 1.22 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* * Details about Montgomery multiplication algorithms can be found at * http://security.ece.orst.edu/publications.html, e.g. * http://security.ece.orst.edu/koc/papers/j37acmon.pdf and * sections 3.8 and 4.2 in http://security.ece.orst.edu/koc/papers/r01rsasw.pdf */ #include #include #include "bn_lcl.h" #define MONT_WORD /* use the faster word-based algorithm */ #ifdef MONT_WORD static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont); #endif int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_MONT_CTX *mont, BN_CTX *ctx) { BIGNUM *tmp; int ret = 0; #if defined(OPENSSL_BN_ASM_MONT) && defined(MONT_WORD) int num = mont->N.top; if (num > 1 && a->top == num && b->top == num) { if (bn_wexpand(r, num) == NULL) return (0); if (bn_mul_mont(r->d, a->d, b->d, mont->N.d, mont->n0, num)) { r->neg = a->neg^b->neg; r->top = num; bn_correct_top(r); return (1); } } #endif BN_CTX_start(ctx); tmp = BN_CTX_get(ctx); if (tmp == NULL) goto err; bn_check_top(tmp); if (a == b) { if (!BN_sqr(tmp, a, ctx)) goto err; } else { if (!BN_mul(tmp, a,b, ctx)) goto err; } /* reduce from aRR to aR */ #ifdef MONT_WORD if (!BN_from_montgomery_word(r, tmp, mont)) goto err; #else if (!BN_from_montgomery(r, tmp, mont, ctx)) goto err; #endif bn_check_top(r); ret = 1; err: BN_CTX_end(ctx); return (ret); } #ifdef MONT_WORD static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont) { BIGNUM *n; BN_ULONG *ap, *np, *rp, n0, v, carry; int nl, max, i; n = &(mont->N); nl = n->top; if (nl == 0) { ret->top = 0; return (1); } max = (2 * nl); /* carry is stored separately */ if (bn_wexpand(r, max) == NULL) return (0); r->neg ^= n->neg; np = n->d; rp = r->d; /* clear the top words of T */ #if 1 for (i=r->top; itop]), 0, (max - r->top) * sizeof(BN_ULONG)); #endif r->top = max; n0 = mont->n0[0]; #ifdef BN_COUNT fprintf(stderr, "word BN_from_montgomery_word %d * %d\n", nl, nl); #endif for (carry = 0, i = 0; i < nl; i++, rp++) { v = bn_mul_add_words(rp, np, nl, (rp[0] * n0) & BN_MASK2); v = (v + carry + rp[nl]) & BN_MASK2; carry |= (v != rp[nl]); carry &= (v <= rp[nl]); rp[nl] = v; } if (bn_wexpand(ret, nl) == NULL) return (0); ret->top = nl; ret->neg = r->neg; rp = ret->d; ap = &(r->d[nl]); #define BRANCH_FREE 1 #if BRANCH_FREE { BN_ULONG *nrp; size_t m; v = bn_sub_words(rp, ap, np, nl) - carry; /* if subtraction result is real, then * trick unconditional memcpy below to perform in-place * "refresh" instead of actual copy. */ m = (0 - (size_t)v); nrp = (BN_ULONG *)(((uintptr_t)rp & ~m)|((uintptr_t)ap & m)); for (i = 0, nl -= 4; i < nl; i += 4) { BN_ULONG t1, t2, t3, t4; t1 = nrp[i + 0]; t2 = nrp[i + 1]; t3 = nrp[i + 2]; ap[i + 0] = 0; t4 = nrp[i + 3]; ap[i + 1] = 0; rp[i + 0] = t1; ap[i + 2] = 0; rp[i + 1] = t2; ap[i + 3] = 0; rp[i + 2] = t3; rp[i + 3] = t4; } for (nl += 4; i < nl; i++) rp[i] = nrp[i], ap[i] = 0; } #else if (bn_sub_words (rp, ap, np, nl) - carry) memcpy(rp, ap, nl*sizeof(BN_ULONG)); #endif bn_correct_top(r); bn_correct_top(ret); bn_check_top(ret); return (1); } #endif /* MONT_WORD */ int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx) { int retn = 0; #ifdef MONT_WORD BIGNUM *t; BN_CTX_start(ctx); if ((t = BN_CTX_get(ctx)) && BN_copy(t, a)) retn = BN_from_montgomery_word(ret, t, mont); BN_CTX_end(ctx); #else /* !MONT_WORD */ BIGNUM *t1, *t2; BN_CTX_start(ctx); t1 = BN_CTX_get(ctx); t2 = BN_CTX_get(ctx); if (t1 == NULL || t2 == NULL) goto err; if (!BN_copy(t1, a)) goto err; BN_mask_bits(t1, mont->ri); if (!BN_mul(t2, t1, &mont->Ni, ctx)) goto err; BN_mask_bits(t2, mont->ri); if (!BN_mul(t1, t2, &mont->N, ctx)) goto err; if (!BN_add(t2, a, t1)) goto err; if (!BN_rshift(ret, t2, mont->ri)) goto err; if (BN_ucmp(ret, &(mont->N)) >= 0) { if (!BN_usub(ret, ret, &(mont->N))) goto err; } retn = 1; bn_check_top(ret); err: BN_CTX_end(ctx); #endif /* MONT_WORD */ return (retn); } BN_MONT_CTX * BN_MONT_CTX_new(void) { BN_MONT_CTX *ret; if ((ret = malloc(sizeof(BN_MONT_CTX))) == NULL) return (NULL); BN_MONT_CTX_init(ret); ret->flags = BN_FLG_MALLOCED; return (ret); } void BN_MONT_CTX_init(BN_MONT_CTX *ctx) { ctx->ri = 0; BN_init(&(ctx->RR)); BN_init(&(ctx->N)); BN_init(&(ctx->Ni)); ctx->n0[0] = ctx->n0[1] = 0; ctx->flags = 0; } void BN_MONT_CTX_free(BN_MONT_CTX *mont) { if (mont == NULL) return; BN_clear_free(&(mont->RR)); BN_clear_free(&(mont->N)); BN_clear_free(&(mont->Ni)); if (mont->flags & BN_FLG_MALLOCED) free(mont); } int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx) { int ret = 0; BIGNUM *Ri, *R; BN_CTX_start(ctx); if ((Ri = BN_CTX_get(ctx)) == NULL) goto err; R = &(mont->RR); /* grab RR as a temp */ if (!BN_copy(&(mont->N), mod)) goto err; /* Set N */ mont->N.neg = 0; #ifdef MONT_WORD { BIGNUM tmod; BN_ULONG buf[2]; BN_init(&tmod); tmod.d = buf; tmod.dmax = 2; tmod.neg = 0; mont->ri = (BN_num_bits(mod) + (BN_BITS2 - 1)) / BN_BITS2 * BN_BITS2; #if defined(OPENSSL_BN_ASM_MONT) && (BN_BITS2<=32) /* Only certain BN_BITS2<=32 platforms actually make use of * n0[1], and we could use the #else case (with a shorter R * value) for the others. However, currently only the assembler * files do know which is which. */ BN_zero(R); if (!(BN_set_bit(R, 2 * BN_BITS2))) goto err; tmod.top = 0; if ((buf[0] = mod->d[0])) tmod.top = 1; if ((buf[1] = mod->top > 1 ? mod->d[1] : 0)) tmod.top = 2; if ((BN_mod_inverse(Ri, R, &tmod, ctx)) == NULL) goto err; if (!BN_lshift(Ri, Ri, 2 * BN_BITS2)) goto err; /* R*Ri */ if (!BN_is_zero(Ri)) { if (!BN_sub_word(Ri, 1)) goto err; } else /* if N mod word size == 1 */ { if (bn_expand(Ri, (int)sizeof(BN_ULONG) * 2) == NULL) goto err; /* Ri-- (mod double word size) */ Ri->neg = 0; Ri->d[0] = BN_MASK2; Ri->d[1] = BN_MASK2; Ri->top = 2; } if (!BN_div(Ri, NULL, Ri, &tmod, ctx)) goto err; /* Ni = (R*Ri-1)/N, * keep only couple of least significant words: */ mont->n0[0] = (Ri->top > 0) ? Ri->d[0] : 0; mont->n0[1] = (Ri->top > 1) ? Ri->d[1] : 0; #else BN_zero(R); if (!(BN_set_bit(R, BN_BITS2))) goto err; /* R */ buf[0] = mod->d[0]; /* tmod = N mod word size */ buf[1] = 0; tmod.top = buf[0] != 0 ? 1 : 0; /* Ri = R^-1 mod N*/ if ((BN_mod_inverse(Ri, R, &tmod, ctx)) == NULL) goto err; if (!BN_lshift(Ri, Ri, BN_BITS2)) goto err; /* R*Ri */ if (!BN_is_zero(Ri)) { if (!BN_sub_word(Ri, 1)) goto err; } else /* if N mod word size == 1 */ { if (!BN_set_word(Ri, BN_MASK2)) goto err; /* Ri-- (mod word size) */ } if (!BN_div(Ri, NULL, Ri, &tmod, ctx)) goto err; /* Ni = (R*Ri-1)/N, * keep only least significant word: */ mont->n0[0] = (Ri->top > 0) ? Ri->d[0] : 0; mont->n0[1] = 0; #endif } #else /* !MONT_WORD */ { /* bignum version */ mont->ri = BN_num_bits(&mont->N); BN_zero(R); if (!BN_set_bit(R, mont->ri)) goto err; /* R = 2^ri */ /* Ri = R^-1 mod N*/ if ((BN_mod_inverse(Ri, R, &mont->N, ctx)) == NULL) goto err; if (!BN_lshift(Ri, Ri, mont->ri)) goto err; /* R*Ri */ if (!BN_sub_word(Ri, 1)) goto err; /* Ni = (R*Ri-1) / N */ if (!BN_div(&(mont->Ni), NULL, Ri, &mont->N, ctx)) goto err; } #endif /* setup RR for conversions */ BN_zero(&(mont->RR)); if (!BN_set_bit(&(mont->RR), mont->ri*2)) goto err; if (!BN_mod(&(mont->RR), &(mont->RR), &(mont->N), ctx)) goto err; ret = 1; err: BN_CTX_end(ctx); return ret; } BN_MONT_CTX * BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from) { if (to == from) return (to); if (!BN_copy(&(to->RR), &(from->RR))) return NULL; if (!BN_copy(&(to->N), &(from->N))) return NULL; if (!BN_copy(&(to->Ni), &(from->Ni))) return NULL; to->ri = from->ri; to->n0[0] = from->n0[0]; to->n0[1] = from->n0[1]; return (to); } BN_MONT_CTX * BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock, const BIGNUM *mod, BN_CTX *ctx) { int got_write_lock = 0; BN_MONT_CTX *ret; CRYPTO_r_lock(lock); if (!*pmont) { CRYPTO_r_unlock(lock); CRYPTO_w_lock(lock); got_write_lock = 1; if (!*pmont) { ret = BN_MONT_CTX_new(); if (ret && !BN_MONT_CTX_set(ret, mod, ctx)) BN_MONT_CTX_free(ret); else *pmont = ret; } } ret = *pmont; if (got_write_lock) CRYPTO_w_unlock(lock); else CRYPTO_r_unlock(lock); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_exp2.c0000644000175000017500000002402712360020705020360 0ustar /* $OpenBSD: bn_exp2.c,v 1.8 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "bn_lcl.h" #define TABLE_SIZE 32 int BN_mod_exp2_mont(BIGNUM *rr, const BIGNUM *a1, const BIGNUM *p1, const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) { int i, j, bits, b, bits1, bits2, ret = 0, wpos1, wpos2, window1, window2, wvalue1, wvalue2; int r_is_one = 1; BIGNUM *d, *r; const BIGNUM *a_mod_m; /* Tables of variables obtained from 'ctx' */ BIGNUM *val1[TABLE_SIZE], *val2[TABLE_SIZE]; BN_MONT_CTX *mont = NULL; bn_check_top(a1); bn_check_top(p1); bn_check_top(a2); bn_check_top(p2); bn_check_top(m); if (!(m->d[0] & 1)) { BNerr(BN_F_BN_MOD_EXP2_MONT, BN_R_CALLED_WITH_EVEN_MODULUS); return (0); } bits1 = BN_num_bits(p1); bits2 = BN_num_bits(p2); if ((bits1 == 0) && (bits2 == 0)) { ret = BN_one(rr); return ret; } bits = (bits1 > bits2) ? bits1 : bits2; BN_CTX_start(ctx); d = BN_CTX_get(ctx); r = BN_CTX_get(ctx); val1[0] = BN_CTX_get(ctx); val2[0] = BN_CTX_get(ctx); if (!d || !r || !val1[0] || !val2[0]) goto err; if (in_mont != NULL) mont = in_mont; else { if ((mont = BN_MONT_CTX_new()) == NULL) goto err; if (!BN_MONT_CTX_set(mont, m, ctx)) goto err; } window1 = BN_window_bits_for_exponent_size(bits1); window2 = BN_window_bits_for_exponent_size(bits2); /* * Build table for a1: val1[i] := a1^(2*i + 1) mod m for i = 0 .. 2^(window1-1) */ if (a1->neg || BN_ucmp(a1, m) >= 0) { if (!BN_mod(val1[0], a1, m, ctx)) goto err; a_mod_m = val1[0]; } else a_mod_m = a1; if (BN_is_zero(a_mod_m)) { BN_zero(rr); ret = 1; goto err; } if (!BN_to_montgomery(val1[0], a_mod_m, mont, ctx)) goto err; if (window1 > 1) { if (!BN_mod_mul_montgomery(d, val1[0], val1[0], mont, ctx)) goto err; j = 1 << (window1 - 1); for (i = 1; i < j; i++) { if (((val1[i] = BN_CTX_get(ctx)) == NULL) || !BN_mod_mul_montgomery(val1[i], val1[i - 1], d, mont, ctx)) goto err; } } /* * Build table for a2: val2[i] := a2^(2*i + 1) mod m for i = 0 .. 2^(window2-1) */ if (a2->neg || BN_ucmp(a2, m) >= 0) { if (!BN_mod(val2[0], a2, m, ctx)) goto err; a_mod_m = val2[0]; } else a_mod_m = a2; if (BN_is_zero(a_mod_m)) { BN_zero(rr); ret = 1; goto err; } if (!BN_to_montgomery(val2[0], a_mod_m, mont, ctx)) goto err; if (window2 > 1) { if (!BN_mod_mul_montgomery(d, val2[0], val2[0], mont, ctx)) goto err; j = 1 << (window2 - 1); for (i = 1; i < j; i++) { if (((val2[i] = BN_CTX_get(ctx)) == NULL) || !BN_mod_mul_montgomery(val2[i], val2[i - 1], d, mont, ctx)) goto err; } } /* Now compute the power product, using independent windows. */ r_is_one = 1; wvalue1 = 0; /* The 'value' of the first window */ wvalue2 = 0; /* The 'value' of the second window */ wpos1 = 0; /* If wvalue1 > 0, the bottom bit of the first window */ wpos2 = 0; /* If wvalue2 > 0, the bottom bit of the second window */ if (!BN_to_montgomery(r, BN_value_one(), mont, ctx)) goto err; for (b = bits - 1; b >= 0; b--) { if (!r_is_one) { if (!BN_mod_mul_montgomery(r, r,r, mont, ctx)) goto err; } if (!wvalue1) if (BN_is_bit_set(p1, b)) { /* consider bits b-window1+1 .. b for this window */ i = b - window1 + 1; while (!BN_is_bit_set(p1, i)) /* works for i<0 */ i++; wpos1 = i; wvalue1 = 1; for (i = b - 1; i >= wpos1; i--) { wvalue1 <<= 1; if (BN_is_bit_set(p1, i)) wvalue1++; } } if (!wvalue2) if (BN_is_bit_set(p2, b)) { /* consider bits b-window2+1 .. b for this window */ i = b - window2 + 1; while (!BN_is_bit_set(p2, i)) i++; wpos2 = i; wvalue2 = 1; for (i = b - 1; i >= wpos2; i--) { wvalue2 <<= 1; if (BN_is_bit_set(p2, i)) wvalue2++; } } if (wvalue1 && b == wpos1) { /* wvalue1 is odd and < 2^window1 */ if (!BN_mod_mul_montgomery(r, r, val1[wvalue1 >> 1], mont, ctx)) goto err; wvalue1 = 0; r_is_one = 0; } if (wvalue2 && b == wpos2) { /* wvalue2 is odd and < 2^window2 */ if (!BN_mod_mul_montgomery(r, r, val2[wvalue2 >> 1], mont, ctx)) goto err; wvalue2 = 0; r_is_one = 0; } } if (!BN_from_montgomery(rr, r,mont, ctx)) goto err; ret = 1; err: if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont); BN_CTX_end(ctx); bn_check_top(rr); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_mod.c0000644000175000017500000002251112360020705020255 0ustar /* $OpenBSD: bn_mod.c,v 1.7 2014/06/12 15:49:28 deraadt Exp $ */ /* Includes code written by Lenka Fibikova * for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "bn_lcl.h" int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx) { /* like BN_mod, but returns non-negative remainder * (i.e., 0 <= r < |d| always holds) */ if (!(BN_mod(r, m,d, ctx))) return 0; if (!r->neg) return 1; /* now -|d| < r < 0, so we have to set r := r + |d| */ return (d->neg ? BN_sub : BN_add)(r, r, d); } int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx) { if (!BN_add(r, a, b)) return 0; return BN_nnmod(r, r, m, ctx); } /* BN_mod_add variant that may be used if both a and b are non-negative * and less than m */ int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m) { if (!BN_uadd(r, a, b)) return 0; if (BN_ucmp(r, m) >= 0) return BN_usub(r, r, m); return 1; } int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx) { if (!BN_sub(r, a, b)) return 0; return BN_nnmod(r, r, m, ctx); } /* BN_mod_sub variant that may be used if both a and b are non-negative * and less than m */ int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m) { if (!BN_sub(r, a, b)) return 0; if (r->neg) return BN_add(r, r, m); return 1; } /* slow but works */ int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx) { BIGNUM *t; int ret = 0; bn_check_top(a); bn_check_top(b); bn_check_top(m); BN_CTX_start(ctx); if ((t = BN_CTX_get(ctx)) == NULL) goto err; if (a == b) { if (!BN_sqr(t, a, ctx)) goto err; } else { if (!BN_mul(t, a,b, ctx)) goto err; } if (!BN_nnmod(r, t,m, ctx)) goto err; bn_check_top(r); ret = 1; err: BN_CTX_end(ctx); return (ret); } int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx) { if (!BN_sqr(r, a, ctx)) return 0; /* r->neg == 0, thus we don't need BN_nnmod */ return BN_mod(r, r, m, ctx); } int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx) { if (!BN_lshift1(r, a)) return 0; bn_check_top(r); return BN_nnmod(r, r, m, ctx); } /* BN_mod_lshift1 variant that may be used if a is non-negative * and less than m */ int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m) { if (!BN_lshift1(r, a)) return 0; bn_check_top(r); if (BN_cmp(r, m) >= 0) return BN_sub(r, r, m); return 1; } int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx) { BIGNUM *abs_m = NULL; int ret; if (!BN_nnmod(r, a, m, ctx)) return 0; if (m->neg) { abs_m = BN_dup(m); if (abs_m == NULL) return 0; abs_m->neg = 0; } ret = BN_mod_lshift_quick(r, r, n, (abs_m ? abs_m : m)); bn_check_top(r); if (abs_m) BN_free(abs_m); return ret; } /* BN_mod_lshift variant that may be used if a is non-negative * and less than m */ int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m) { if (r != a) { if (BN_copy(r, a) == NULL) return 0; } while (n > 0) { int max_shift; /* 0 < r < m */ max_shift = BN_num_bits(m) - BN_num_bits(r); /* max_shift >= 0 */ if (max_shift < 0) { BNerr(BN_F_BN_MOD_LSHIFT_QUICK, BN_R_INPUT_NOT_REDUCED); return 0; } if (max_shift > n) max_shift = n; if (max_shift) { if (!BN_lshift(r, r, max_shift)) return 0; n -= max_shift; } else { if (!BN_lshift1(r, r)) return 0; --n; } /* BN_num_bits(r) <= BN_num_bits(m) */ if (BN_cmp(r, m) >= 0) { if (!BN_sub(r, r, m)) return 0; } } bn_check_top(r); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_gcd.c0000644000175000017500000004243712360020705020244 0ustar /* $OpenBSD: bn_gcd.c,v 1.8 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include "bn_lcl.h" static BIGNUM *euclid(BIGNUM *a, BIGNUM *b); int BN_gcd(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx) { BIGNUM *a, *b, *t; int ret = 0; bn_check_top(in_a); bn_check_top(in_b); BN_CTX_start(ctx); a = BN_CTX_get(ctx); b = BN_CTX_get(ctx); if (a == NULL || b == NULL) goto err; if (BN_copy(a, in_a) == NULL) goto err; if (BN_copy(b, in_b) == NULL) goto err; a->neg = 0; b->neg = 0; if (BN_cmp(a, b) < 0) { t = a; a = b; b = t; } t = euclid(a, b); if (t == NULL) goto err; if (BN_copy(r, t) == NULL) goto err; ret = 1; err: BN_CTX_end(ctx); bn_check_top(r); return (ret); } static BIGNUM * euclid(BIGNUM *a, BIGNUM *b) { BIGNUM *t; int shifts = 0; bn_check_top(a); bn_check_top(b); /* 0 <= b <= a */ while (!BN_is_zero(b)) { /* 0 < b <= a */ if (BN_is_odd(a)) { if (BN_is_odd(b)) { if (!BN_sub(a, a, b)) goto err; if (!BN_rshift1(a, a)) goto err; if (BN_cmp(a, b) < 0) { t = a; a = b; b = t; } } else /* a odd - b even */ { if (!BN_rshift1(b, b)) goto err; if (BN_cmp(a, b) < 0) { t = a; a = b; b = t; } } } else /* a is even */ { if (BN_is_odd(b)) { if (!BN_rshift1(a, a)) goto err; if (BN_cmp(a, b) < 0) { t = a; a = b; b = t; } } else /* a even - b even */ { if (!BN_rshift1(a, a)) goto err; if (!BN_rshift1(b, b)) goto err; shifts++; } } /* 0 <= b <= a */ } if (shifts) { if (!BN_lshift(a, a, shifts)) goto err; } bn_check_top(a); return (a); err: return (NULL); } /* solves ax == 1 (mod n) */ static BIGNUM *BN_mod_inverse_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); BIGNUM * BN_mod_inverse(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx) { BIGNUM *A, *B, *X, *Y, *M, *D, *T, *R = NULL; BIGNUM *ret = NULL; int sign; if ((BN_get_flags(a, BN_FLG_CONSTTIME) != 0) || (BN_get_flags(n, BN_FLG_CONSTTIME) != 0)) { return BN_mod_inverse_no_branch(in, a, n, ctx); } bn_check_top(a); bn_check_top(n); BN_CTX_start(ctx); A = BN_CTX_get(ctx); B = BN_CTX_get(ctx); X = BN_CTX_get(ctx); D = BN_CTX_get(ctx); M = BN_CTX_get(ctx); Y = BN_CTX_get(ctx); T = BN_CTX_get(ctx); if (T == NULL) goto err; if (in == NULL) R = BN_new(); else R = in; if (R == NULL) goto err; BN_one(X); BN_zero(Y); if (BN_copy(B, a) == NULL) goto err; if (BN_copy(A, n) == NULL) goto err; A->neg = 0; if (B->neg || (BN_ucmp(B, A) >= 0)) { if (!BN_nnmod(B, B, A, ctx)) goto err; } sign = -1; /* From B = a mod |n|, A = |n| it follows that * * 0 <= B < A, * -sign*X*a == B (mod |n|), * sign*Y*a == A (mod |n|). */ if (BN_is_odd(n) && (BN_num_bits(n) <= (BN_BITS <= 32 ? 450 : 2048))) { /* Binary inversion algorithm; requires odd modulus. * This is faster than the general algorithm if the modulus * is sufficiently small (about 400 .. 500 bits on 32-bit * sytems, but much more on 64-bit systems) */ int shift; while (!BN_is_zero(B)) { /* * 0 < B < |n|, * 0 < A <= |n|, * (1) -sign*X*a == B (mod |n|), * (2) sign*Y*a == A (mod |n|) */ /* Now divide B by the maximum possible power of two in the integers, * and divide X by the same value mod |n|. * When we're done, (1) still holds. */ shift = 0; while (!BN_is_bit_set(B, shift)) /* note that 0 < B */ { shift++; if (BN_is_odd(X)) { if (!BN_uadd(X, X, n)) goto err; } /* now X is even, so we can easily divide it by two */ if (!BN_rshift1(X, X)) goto err; } if (shift > 0) { if (!BN_rshift(B, B, shift)) goto err; } /* Same for A and Y. Afterwards, (2) still holds. */ shift = 0; while (!BN_is_bit_set(A, shift)) /* note that 0 < A */ { shift++; if (BN_is_odd(Y)) { if (!BN_uadd(Y, Y, n)) goto err; } /* now Y is even */ if (!BN_rshift1(Y, Y)) goto err; } if (shift > 0) { if (!BN_rshift(A, A, shift)) goto err; } /* We still have (1) and (2). * Both A and B are odd. * The following computations ensure that * * 0 <= B < |n|, * 0 < A < |n|, * (1) -sign*X*a == B (mod |n|), * (2) sign*Y*a == A (mod |n|), * * and that either A or B is even in the next iteration. */ if (BN_ucmp(B, A) >= 0) { /* -sign*(X + Y)*a == B - A (mod |n|) */ if (!BN_uadd(X, X, Y)) goto err; /* NB: we could use BN_mod_add_quick(X, X, Y, n), but that * actually makes the algorithm slower */ if (!BN_usub(B, B, A)) goto err; } else { /* sign*(X + Y)*a == A - B (mod |n|) */ if (!BN_uadd(Y, Y, X)) goto err; /* as above, BN_mod_add_quick(Y, Y, X, n) would slow things down */ if (!BN_usub(A, A, B)) goto err; } } } else { /* general inversion algorithm */ while (!BN_is_zero(B)) { BIGNUM *tmp; /* * 0 < B < A, * (*) -sign*X*a == B (mod |n|), * sign*Y*a == A (mod |n|) */ /* (D, M) := (A/B, A%B) ... */ if (BN_num_bits(A) == BN_num_bits(B)) { if (!BN_one(D)) goto err; if (!BN_sub(M, A, B)) goto err; } else if (BN_num_bits(A) == BN_num_bits(B) + 1) { /* A/B is 1, 2, or 3 */ if (!BN_lshift1(T, B)) goto err; if (BN_ucmp(A, T) < 0) { /* A < 2*B, so D=1 */ if (!BN_one(D)) goto err; if (!BN_sub(M, A, B)) goto err; } else { /* A >= 2*B, so D=2 or D=3 */ if (!BN_sub(M, A, T)) goto err; if (!BN_add(D,T,B)) goto err; /* use D (:= 3*B) as temp */ if (BN_ucmp(A, D) < 0) { /* A < 3*B, so D=2 */ if (!BN_set_word(D, 2)) goto err; /* M (= A - 2*B) already has the correct value */ } else { /* only D=3 remains */ if (!BN_set_word(D, 3)) goto err; /* currently M = A - 2*B, but we need M = A - 3*B */ if (!BN_sub(M, M, B)) goto err; } } } else { if (!BN_div(D, M, A, B, ctx)) goto err; } /* Now * A = D*B + M; * thus we have * (**) sign*Y*a == D*B + M (mod |n|). */ tmp = A; /* keep the BIGNUM object, the value does not matter */ /* (A, B) := (B, A mod B) ... */ A = B; B = M; /* ... so we have 0 <= B < A again */ /* Since the former M is now B and the former B is now A, * (**) translates into * sign*Y*a == D*A + B (mod |n|), * i.e. * sign*Y*a - D*A == B (mod |n|). * Similarly, (*) translates into * -sign*X*a == A (mod |n|). * * Thus, * sign*Y*a + D*sign*X*a == B (mod |n|), * i.e. * sign*(Y + D*X)*a == B (mod |n|). * * So if we set (X, Y, sign) := (Y + D*X, X, -sign), we arrive back at * -sign*X*a == B (mod |n|), * sign*Y*a == A (mod |n|). * Note that X and Y stay non-negative all the time. */ /* most of the time D is very small, so we can optimize tmp := D*X+Y */ if (BN_is_one(D)) { if (!BN_add(tmp, X, Y)) goto err; } else { if (BN_is_word(D, 2)) { if (!BN_lshift1(tmp, X)) goto err; } else if (BN_is_word(D, 4)) { if (!BN_lshift(tmp, X, 2)) goto err; } else if (D->top == 1) { if (!BN_copy(tmp, X)) goto err; if (!BN_mul_word(tmp, D->d[0])) goto err; } else { if (!BN_mul(tmp, D,X, ctx)) goto err; } if (!BN_add(tmp, tmp, Y)) goto err; } M = Y; /* keep the BIGNUM object, the value does not matter */ Y = X; X = tmp; sign = -sign; } } /* * The while loop (Euclid's algorithm) ends when * A == gcd(a,n); * we have * sign*Y*a == A (mod |n|), * where Y is non-negative. */ if (sign < 0) { if (!BN_sub(Y, n, Y)) goto err; } /* Now Y*a == A (mod |n|). */ if (BN_is_one(A)) { /* Y*a == 1 (mod |n|) */ if (!Y->neg && BN_ucmp(Y, n) < 0) { if (!BN_copy(R, Y)) goto err; } else { if (!BN_nnmod(R, Y,n, ctx)) goto err; } } else { BNerr(BN_F_BN_MOD_INVERSE, BN_R_NO_INVERSE); goto err; } ret = R; err: if ((ret == NULL) && (in == NULL)) BN_free(R); BN_CTX_end(ctx); bn_check_top(ret); return (ret); } /* BN_mod_inverse_no_branch is a special version of BN_mod_inverse. * It does not contain branches that may leak sensitive information. */ static BIGNUM * BN_mod_inverse_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx) { BIGNUM *A, *B, *X, *Y, *M, *D, *T, *R = NULL; BIGNUM local_A, local_B; BIGNUM *pA, *pB; BIGNUM *ret = NULL; int sign; bn_check_top(a); bn_check_top(n); BN_CTX_start(ctx); A = BN_CTX_get(ctx); B = BN_CTX_get(ctx); X = BN_CTX_get(ctx); D = BN_CTX_get(ctx); M = BN_CTX_get(ctx); Y = BN_CTX_get(ctx); T = BN_CTX_get(ctx); if (T == NULL) goto err; if (in == NULL) R = BN_new(); else R = in; if (R == NULL) goto err; BN_one(X); BN_zero(Y); if (BN_copy(B, a) == NULL) goto err; if (BN_copy(A, n) == NULL) goto err; A->neg = 0; if (B->neg || (BN_ucmp(B, A) >= 0)) { /* Turn BN_FLG_CONSTTIME flag on, so that when BN_div is invoked, * BN_div_no_branch will be called eventually. */ pB = &local_B; BN_with_flags(pB, B, BN_FLG_CONSTTIME); if (!BN_nnmod(B, pB, A, ctx)) goto err; } sign = -1; /* From B = a mod |n|, A = |n| it follows that * * 0 <= B < A, * -sign*X*a == B (mod |n|), * sign*Y*a == A (mod |n|). */ while (!BN_is_zero(B)) { BIGNUM *tmp; /* * 0 < B < A, * (*) -sign*X*a == B (mod |n|), * sign*Y*a == A (mod |n|) */ /* Turn BN_FLG_CONSTTIME flag on, so that when BN_div is invoked, * BN_div_no_branch will be called eventually. */ pA = &local_A; BN_with_flags(pA, A, BN_FLG_CONSTTIME); /* (D, M) := (A/B, A%B) ... */ if (!BN_div(D, M, pA, B, ctx)) goto err; /* Now * A = D*B + M; * thus we have * (**) sign*Y*a == D*B + M (mod |n|). */ tmp = A; /* keep the BIGNUM object, the value does not matter */ /* (A, B) := (B, A mod B) ... */ A = B; B = M; /* ... so we have 0 <= B < A again */ /* Since the former M is now B and the former B is now A, * (**) translates into * sign*Y*a == D*A + B (mod |n|), * i.e. * sign*Y*a - D*A == B (mod |n|). * Similarly, (*) translates into * -sign*X*a == A (mod |n|). * * Thus, * sign*Y*a + D*sign*X*a == B (mod |n|), * i.e. * sign*(Y + D*X)*a == B (mod |n|). * * So if we set (X, Y, sign) := (Y + D*X, X, -sign), we arrive back at * -sign*X*a == B (mod |n|), * sign*Y*a == A (mod |n|). * Note that X and Y stay non-negative all the time. */ if (!BN_mul(tmp, D, X, ctx)) goto err; if (!BN_add(tmp, tmp, Y)) goto err; M = Y; /* keep the BIGNUM object, the value does not matter */ Y = X; X = tmp; sign = -sign; } /* * The while loop (Euclid's algorithm) ends when * A == gcd(a,n); * we have * sign*Y*a == A (mod |n|), * where Y is non-negative. */ if (sign < 0) { if (!BN_sub(Y, n, Y)) goto err; } /* Now Y*a == A (mod |n|). */ if (BN_is_one(A)) { /* Y*a == 1 (mod |n|) */ if (!Y->neg && BN_ucmp(Y, n) < 0) { if (!BN_copy(R, Y)) goto err; } else { if (!BN_nnmod(R, Y, n, ctx)) goto err; } } else { BNerr(BN_F_BN_MOD_INVERSE_NO_BRANCH, BN_R_NO_INVERSE); goto err; } ret = R; err: if ((ret == NULL) && (in == NULL)) BN_free(R); BN_CTX_end(ctx); bn_check_top(ret); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_shift.c0000644000175000017500000001337212360020705020620 0ustar /* $OpenBSD: bn_shift.c,v 1.11 2014/07/10 13:58:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include "bn_lcl.h" int BN_lshift1(BIGNUM *r, const BIGNUM *a) { register BN_ULONG *ap, *rp, t, c; int i; bn_check_top(r); bn_check_top(a); if (r != a) { r->neg = a->neg; if (bn_wexpand(r, a->top + 1) == NULL) return (0); r->top = a->top; } else { if (bn_wexpand(r, a->top + 1) == NULL) return (0); } ap = a->d; rp = r->d; c = 0; for (i = 0; i < a->top; i++) { t= *(ap++); *(rp++) = ((t << 1) | c) & BN_MASK2; c = (t & BN_TBIT) ? 1 : 0; } if (c) { *rp = 1; r->top++; } bn_check_top(r); return (1); } int BN_rshift1(BIGNUM *r, const BIGNUM *a) { BN_ULONG *ap, *rp, t, c; int i, j; bn_check_top(r); bn_check_top(a); if (BN_is_zero(a)) { BN_zero(r); return (1); } i = a->top; ap = a->d; j = i - (ap[i - 1]==1); if (a != r) { if (bn_wexpand(r, j) == NULL) return (0); r->neg = a->neg; } rp = r->d; t = ap[--i]; c = (t & 1) ? BN_TBIT : 0; if (t >>= 1) rp[i] = t; while (i > 0) { t = ap[--i]; rp[i] = ((t >> 1) & BN_MASK2) | c; c = (t & 1) ? BN_TBIT : 0; } r->top = j; bn_check_top(r); return (1); } int BN_lshift(BIGNUM *r, const BIGNUM *a, int n) { int i, nw, lb, rb; BN_ULONG *t, *f; BN_ULONG l; bn_check_top(r); bn_check_top(a); r->neg = a->neg; nw = n / BN_BITS2; if (bn_wexpand(r, a->top + nw + 1) == NULL) return (0); lb = n % BN_BITS2; rb = BN_BITS2 - lb; f = a->d; t = r->d; t[a->top + nw] = 0; if (lb == 0) for (i = a->top - 1; i >= 0; i--) t[nw + i] = f[i]; else for (i = a->top - 1; i >= 0; i--) { l = f[i]; t[nw + i + 1] |= (l >> rb) & BN_MASK2; t[nw + i] = (l << lb) & BN_MASK2; } memset(t, 0, nw * sizeof(t[0])); /* for (i=0; itop = a->top + nw + 1; bn_correct_top(r); bn_check_top(r); return (1); } int BN_rshift(BIGNUM *r, const BIGNUM *a, int n) { int i, j, nw, lb, rb; BN_ULONG *t, *f; BN_ULONG l, tmp; bn_check_top(r); bn_check_top(a); nw = n / BN_BITS2; rb = n % BN_BITS2; lb = BN_BITS2 - rb; if (nw >= a->top || a->top == 0) { BN_zero(r); return (1); } i = (BN_num_bits(a) - n + (BN_BITS2 - 1)) / BN_BITS2; if (r != a) { r->neg = a->neg; if (bn_wexpand(r, i) == NULL) return (0); } else { if (n == 0) return 1; /* or the copying loop will go berserk */ } f = &(a->d[nw]); t = r->d; j = a->top - nw; r->top = i; if (rb == 0) { for (i = j; i != 0; i--) *(t++) = *(f++); } else { l = *(f++); for (i = j - 1; i != 0; i--) { tmp = (l >> rb) & BN_MASK2; l = *(f++); *(t++) = (tmp|(l << lb)) & BN_MASK2; } if ((l = (l >> rb) & BN_MASK2)) *(t) = l; } bn_check_top(r); return (1); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_err.c0000644000175000017500000001510512360020705020267 0ustar /* $OpenBSD: bn_err.c,v 1.11 2014/06/12 15:49:28 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_BN,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_BN,0,reason) static ERR_STRING_DATA BN_str_functs[]= { {ERR_FUNC(BN_F_BNRAND), "BNRAND"}, {ERR_FUNC(BN_F_BN_BLINDING_CONVERT_EX), "BN_BLINDING_convert_ex"}, {ERR_FUNC(BN_F_BN_BLINDING_CREATE_PARAM), "BN_BLINDING_create_param"}, {ERR_FUNC(BN_F_BN_BLINDING_INVERT_EX), "BN_BLINDING_invert_ex"}, {ERR_FUNC(BN_F_BN_BLINDING_NEW), "BN_BLINDING_new"}, {ERR_FUNC(BN_F_BN_BLINDING_UPDATE), "BN_BLINDING_update"}, {ERR_FUNC(BN_F_BN_BN2DEC), "BN_bn2dec"}, {ERR_FUNC(BN_F_BN_BN2HEX), "BN_bn2hex"}, {ERR_FUNC(BN_F_BN_CTX_GET), "BN_CTX_get"}, {ERR_FUNC(BN_F_BN_CTX_NEW), "BN_CTX_new"}, {ERR_FUNC(BN_F_BN_CTX_START), "BN_CTX_start"}, {ERR_FUNC(BN_F_BN_DIV), "BN_div"}, {ERR_FUNC(BN_F_BN_DIV_NO_BRANCH), "BN_div_no_branch"}, {ERR_FUNC(BN_F_BN_DIV_RECP), "BN_div_recp"}, {ERR_FUNC(BN_F_BN_EXP), "BN_exp"}, {ERR_FUNC(BN_F_BN_EXPAND2), "bn_expand2"}, {ERR_FUNC(BN_F_BN_EXPAND_INTERNAL), "BN_EXPAND_INTERNAL"}, {ERR_FUNC(BN_F_BN_GF2M_MOD), "BN_GF2m_mod"}, {ERR_FUNC(BN_F_BN_GF2M_MOD_EXP), "BN_GF2m_mod_exp"}, {ERR_FUNC(BN_F_BN_GF2M_MOD_MUL), "BN_GF2m_mod_mul"}, {ERR_FUNC(BN_F_BN_GF2M_MOD_SOLVE_QUAD), "BN_GF2m_mod_solve_quad"}, {ERR_FUNC(BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR), "BN_GF2m_mod_solve_quad_arr"}, {ERR_FUNC(BN_F_BN_GF2M_MOD_SQR), "BN_GF2m_mod_sqr"}, {ERR_FUNC(BN_F_BN_GF2M_MOD_SQRT), "BN_GF2m_mod_sqrt"}, {ERR_FUNC(BN_F_BN_MOD_EXP2_MONT), "BN_mod_exp2_mont"}, {ERR_FUNC(BN_F_BN_MOD_EXP_MONT), "BN_mod_exp_mont"}, {ERR_FUNC(BN_F_BN_MOD_EXP_MONT_CONSTTIME), "BN_mod_exp_mont_consttime"}, {ERR_FUNC(BN_F_BN_MOD_EXP_MONT_WORD), "BN_mod_exp_mont_word"}, {ERR_FUNC(BN_F_BN_MOD_EXP_RECP), "BN_mod_exp_recp"}, {ERR_FUNC(BN_F_BN_MOD_EXP_SIMPLE), "BN_mod_exp_simple"}, {ERR_FUNC(BN_F_BN_MOD_INVERSE), "BN_mod_inverse"}, {ERR_FUNC(BN_F_BN_MOD_INVERSE_NO_BRANCH), "BN_mod_inverse_no_branch"}, {ERR_FUNC(BN_F_BN_MOD_LSHIFT_QUICK), "BN_mod_lshift_quick"}, {ERR_FUNC(BN_F_BN_MOD_MUL_RECIPROCAL), "BN_mod_mul_reciprocal"}, {ERR_FUNC(BN_F_BN_MOD_SQRT), "BN_mod_sqrt"}, {ERR_FUNC(BN_F_BN_MPI2BN), "BN_mpi2bn"}, {ERR_FUNC(BN_F_BN_NEW), "BN_new"}, {ERR_FUNC(BN_F_BN_RAND), "BN_rand"}, {ERR_FUNC(BN_F_BN_RAND_RANGE), "BN_rand_range"}, {ERR_FUNC(BN_F_BN_USUB), "BN_usub"}, {0, NULL} }; static ERR_STRING_DATA BN_str_reasons[]= { {ERR_REASON(BN_R_ARG2_LT_ARG3) , "arg2 lt arg3"}, {ERR_REASON(BN_R_BAD_RECIPROCAL) , "bad reciprocal"}, {ERR_REASON(BN_R_BIGNUM_TOO_LONG) , "bignum too long"}, {ERR_REASON(BN_R_CALLED_WITH_EVEN_MODULUS), "called with even modulus"}, {ERR_REASON(BN_R_DIV_BY_ZERO) , "div by zero"}, {ERR_REASON(BN_R_ENCODING_ERROR) , "encoding error"}, {ERR_REASON(BN_R_EXPAND_ON_STATIC_BIGNUM_DATA), "expand on static bignum data"}, {ERR_REASON(BN_R_INPUT_NOT_REDUCED) , "input not reduced"}, {ERR_REASON(BN_R_INVALID_LENGTH) , "invalid length"}, {ERR_REASON(BN_R_INVALID_RANGE) , "invalid range"}, {ERR_REASON(BN_R_NOT_A_SQUARE) , "not a square"}, {ERR_REASON(BN_R_NOT_INITIALIZED) , "not initialized"}, {ERR_REASON(BN_R_NO_INVERSE) , "no inverse"}, {ERR_REASON(BN_R_NO_SOLUTION) , "no solution"}, {ERR_REASON(BN_R_P_IS_NOT_PRIME) , "p is not prime"}, {ERR_REASON(BN_R_TOO_MANY_ITERATIONS) , "too many iterations"}, {ERR_REASON(BN_R_TOO_MANY_TEMPORARY_VARIABLES), "too many temporary variables"}, {0, NULL} }; #endif void ERR_load_BN_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(BN_str_functs[0].error) == NULL) { ERR_load_strings(0, BN_str_functs); ERR_load_strings(0, BN_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_lib.c0000644000175000017500000004537012360020705020254 0ustar /* $OpenBSD: bn_lib.c,v 1.31 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #ifndef BN_DEBUG # undef NDEBUG /* avoid conflicting definitions */ # define NDEBUG #endif #include #include #include #include #include #include #include "bn_lcl.h" /* This stuff appears to be completely unused, so is deprecated */ #ifndef OPENSSL_NO_DEPRECATED /* For a 32 bit machine * 2 - 4 == 128 * 3 - 8 == 256 * 4 - 16 == 512 * 5 - 32 == 1024 * 6 - 64 == 2048 * 7 - 128 == 4096 * 8 - 256 == 8192 */ static int bn_limit_bits = 0; static int bn_limit_num = 8; /* (1<= 0) { if (mult > (int)(sizeof(int) * 8) - 1) mult = sizeof(int) * 8 - 1; bn_limit_bits = mult; bn_limit_num = 1 << mult; } if (high >= 0) { if (high > (int)(sizeof(int) * 8) - 1) high = sizeof(int) * 8 - 1; bn_limit_bits_high = high; bn_limit_num_high = 1 << high; } if (low >= 0) { if (low > (int)(sizeof(int) * 8) - 1) low = sizeof(int) * 8 - 1; bn_limit_bits_low = low; bn_limit_num_low = 1 << low; } if (mont >= 0) { if (mont > (int)(sizeof(int) * 8) - 1) mont = sizeof(int) * 8 - 1; bn_limit_bits_mont = mont; bn_limit_num_mont = 1 << mont; } } int BN_get_params(int which) { if (which == 0) return (bn_limit_bits); else if (which == 1) return (bn_limit_bits_high); else if (which == 2) return (bn_limit_bits_low); else if (which == 3) return (bn_limit_bits_mont); else return (0); } #endif const BIGNUM * BN_value_one(void) { static const BN_ULONG data_one = 1L; static const BIGNUM const_one = { (BN_ULONG *)&data_one, 1, 1, 0, BN_FLG_STATIC_DATA }; return (&const_one); } int BN_num_bits_word(BN_ULONG l) { static const unsigned char bits[256] = { 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, }; #ifdef _LP64 if (l & 0xffffffff00000000L) { if (l & 0xffff000000000000L) { if (l & 0xff00000000000000L) { return (bits[(int)(l >> 56)] + 56); } else return (bits[(int)(l >> 48)] + 48); } else { if (l & 0x0000ff0000000000L) { return (bits[(int)(l >> 40)] + 40); } else return (bits[(int)(l >> 32)] + 32); } } else #endif { if (l & 0xffff0000L) { if (l & 0xff000000L) return (bits[(int)(l >> 24L)] + 24); else return (bits[(int)(l >> 16L)] + 16); } else { if (l & 0xff00L) return (bits[(int)(l >> 8)] + 8); else return (bits[(int)(l)]); } } } int BN_num_bits(const BIGNUM *a) { int i = a->top - 1; bn_check_top(a); if (BN_is_zero(a)) return 0; return ((i * BN_BITS2) + BN_num_bits_word(a->d[i])); } void BN_clear_free(BIGNUM *a) { int i; if (a == NULL) return; bn_check_top(a); if (a->d != NULL && !(BN_get_flags(a, BN_FLG_STATIC_DATA))) { OPENSSL_cleanse(a->d, a->dmax * sizeof(a->d[0])); free(a->d); } i = BN_get_flags(a, BN_FLG_MALLOCED); OPENSSL_cleanse(a, sizeof(BIGNUM)); if (i) free(a); } void BN_free(BIGNUM *a) { BN_clear_free(a); } void BN_init(BIGNUM *a) { memset(a, 0, sizeof(BIGNUM)); bn_check_top(a); } BIGNUM * BN_new(void) { BIGNUM *ret; if ((ret = malloc(sizeof(BIGNUM))) == NULL) { BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } ret->flags = BN_FLG_MALLOCED; ret->top = 0; ret->neg = 0; ret->dmax = 0; ret->d = NULL; bn_check_top(ret); return (ret); } /* This is used both by bn_expand2() and bn_dup_expand() */ /* The caller MUST check that words > b->dmax before calling this */ static BN_ULONG * bn_expand_internal(const BIGNUM *b, int words) { BN_ULONG *A, *a = NULL; const BN_ULONG *B; int i; bn_check_top(b); if (words > (INT_MAX/(4*BN_BITS2))) { BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_BIGNUM_TOO_LONG); return NULL; } if (BN_get_flags(b, BN_FLG_STATIC_DATA)) { BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_EXPAND_ON_STATIC_BIGNUM_DATA); return (NULL); } a = A = reallocarray(NULL, words, sizeof(BN_ULONG)); if (A == NULL) { BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE); return (NULL); } #if 1 B = b->d; /* Check if the previous number needs to be copied */ if (B != NULL) { for (i = b->top >> 2; i > 0; i--, A += 4, B += 4) { /* * The fact that the loop is unrolled * 4-wise is a tribute to Intel. It's * the one that doesn't have enough * registers to accomodate more data. * I'd unroll it 8-wise otherwise:-) * * */ BN_ULONG a0, a1, a2, a3; a0 = B[0]; a1 = B[1]; a2 = B[2]; a3 = B[3]; A[0] = a0; A[1] = a1; A[2] = a2; A[3] = a3; } switch (b->top & 3) { case 3: A[2] = B[2]; case 2: A[1] = B[1]; case 1: A[0] = B[0]; } } #else memset(A, 0, sizeof(BN_ULONG) * words); memcpy(A, b->d, sizeof(b->d[0]) * b->top); #endif return (a); } /* This is an internal function that can be used instead of bn_expand2() * when there is a need to copy BIGNUMs instead of only expanding the * data part, while still expanding them. * Especially useful when needing to expand BIGNUMs that are declared * 'const' and should therefore not be changed. * The reason to use this instead of a BN_dup() followed by a bn_expand2() * is memory allocation overhead. A BN_dup() followed by a bn_expand2() * will allocate new memory for the BIGNUM data twice, and free it once, * while bn_dup_expand() makes sure allocation is made only once. */ #ifndef OPENSSL_NO_DEPRECATED BIGNUM * bn_dup_expand(const BIGNUM *b, int words) { BIGNUM *r = NULL; bn_check_top(b); /* This function does not work if * words <= b->dmax && top < words * because BN_dup() does not preserve 'dmax'! * (But bn_dup_expand() is not used anywhere yet.) */ if (words > b->dmax) { BN_ULONG *a = bn_expand_internal(b, words); if (a) { r = BN_new(); if (r) { r->top = b->top; r->dmax = words; r->neg = b->neg; r->d = a; } else { /* r == NULL, BN_new failure */ free(a); } } /* If a == NULL, there was an error in allocation in bn_expand_internal(), and NULL should be returned */ } else { r = BN_dup(b); } bn_check_top(r); return r; } #endif /* This is an internal function that should not be used in applications. * It ensures that 'b' has enough room for a 'words' word number * and initialises any unused part of b->d with leading zeros. * It is mostly used by the various BIGNUM routines. If there is an error, * NULL is returned. If not, 'b' is returned. */ BIGNUM * bn_expand2(BIGNUM *b, int words) { bn_check_top(b); if (words > b->dmax) { BN_ULONG *a = bn_expand_internal(b, words); if (!a) return NULL; if (b->d) { OPENSSL_cleanse(b->d, b->dmax * sizeof(b->d[0])); free(b->d); } b->d = a; b->dmax = words; } /* None of this should be necessary because of what b->top means! */ #if 0 /* NB: bn_wexpand() calls this only if the BIGNUM really has to grow */ if (b->top < b->dmax) { int i; BN_ULONG *A = &(b->d[b->top]); for (i = (b->dmax - b->top) >> 3; i > 0; i--, A += 8) { A[0] = 0; A[1] = 0; A[2] = 0; A[3] = 0; A[4] = 0; A[5] = 0; A[6] = 0; A[7] = 0; } for (i = (b->dmax - b->top)&7; i > 0; i--, A++) A[0] = 0; assert(A == &(b->d[b->dmax])); } #endif bn_check_top(b); return b; } BIGNUM * BN_dup(const BIGNUM *a) { BIGNUM *t; if (a == NULL) return NULL; bn_check_top(a); t = BN_new(); if (t == NULL) return NULL; if (!BN_copy(t, a)) { BN_free(t); return NULL; } bn_check_top(t); return t; } BIGNUM * BN_copy(BIGNUM *a, const BIGNUM *b) { int i; BN_ULONG *A; const BN_ULONG *B; bn_check_top(b); if (a == b) return (a); if (bn_wexpand(a, b->top) == NULL) return (NULL); #if 1 A = a->d; B = b->d; for (i = b->top >> 2; i > 0; i--, A += 4, B += 4) { BN_ULONG a0, a1, a2, a3; a0 = B[0]; a1 = B[1]; a2 = B[2]; a3 = B[3]; A[0] = a0; A[1] = a1; A[2] = a2; A[3] = a3; } switch (b->top & 3) { case 3: A[2] = B[2]; case 2: A[1] = B[1]; case 1: A[0] = B[0]; } #else memcpy(a->d, b->d, sizeof(b->d[0]) * b->top); #endif a->top = b->top; a->neg = b->neg; bn_check_top(a); return (a); } void BN_swap(BIGNUM *a, BIGNUM *b) { int flags_old_a, flags_old_b; BN_ULONG *tmp_d; int tmp_top, tmp_dmax, tmp_neg; bn_check_top(a); bn_check_top(b); flags_old_a = a->flags; flags_old_b = b->flags; tmp_d = a->d; tmp_top = a->top; tmp_dmax = a->dmax; tmp_neg = a->neg; a->d = b->d; a->top = b->top; a->dmax = b->dmax; a->neg = b->neg; b->d = tmp_d; b->top = tmp_top; b->dmax = tmp_dmax; b->neg = tmp_neg; a->flags = (flags_old_a & BN_FLG_MALLOCED) | (flags_old_b & BN_FLG_STATIC_DATA); b->flags = (flags_old_b & BN_FLG_MALLOCED) | (flags_old_a & BN_FLG_STATIC_DATA); bn_check_top(a); bn_check_top(b); } void BN_clear(BIGNUM *a) { bn_check_top(a); if (a->d != NULL) memset(a->d, 0, a->dmax * sizeof(a->d[0])); a->top = 0; a->neg = 0; } BN_ULONG BN_get_word(const BIGNUM *a) { if (a->top > 1) return BN_MASK2; else if (a->top == 1) return a->d[0]; /* a->top == 0 */ return 0; } int BN_set_word(BIGNUM *a, BN_ULONG w) { bn_check_top(a); if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL) return (0); a->neg = 0; a->d[0] = w; a->top = (w ? 1 : 0); bn_check_top(a); return (1); } BIGNUM * BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret) { unsigned int i, m; unsigned int n; BN_ULONG l; BIGNUM *bn = NULL; if (ret == NULL) ret = bn = BN_new(); if (ret == NULL) return (NULL); bn_check_top(ret); l = 0; n = len; if (n == 0) { ret->top = 0; return (ret); } i = ((n - 1) / BN_BYTES) + 1; m = ((n - 1) % (BN_BYTES)); if (bn_wexpand(ret, (int)i) == NULL) { if (bn) BN_free(bn); return NULL; } ret->top = i; ret->neg = 0; while (n--) { l = (l << 8L) | *(s++); if (m-- == 0) { ret->d[--i] = l; l = 0; m = BN_BYTES - 1; } } /* need to call this due to clear byte at top if avoiding * having the top bit set (-ve number) */ bn_correct_top(ret); return (ret); } /* ignore negative */ int BN_bn2bin(const BIGNUM *a, unsigned char *to) { int n, i; BN_ULONG l; bn_check_top(a); n = i=BN_num_bytes(a); while (i--) { l = a->d[i / BN_BYTES]; *(to++) = (unsigned char)(l >> (8 * (i % BN_BYTES))) & 0xff; } return (n); } int BN_ucmp(const BIGNUM *a, const BIGNUM *b) { int i; BN_ULONG t1, t2, *ap, *bp; bn_check_top(a); bn_check_top(b); i = a->top - b->top; if (i != 0) return (i); ap = a->d; bp = b->d; for (i = a->top - 1; i >= 0; i--) { t1 = ap[i]; t2 = bp[i]; if (t1 != t2) return ((t1 > t2) ? 1 : -1); } return (0); } int BN_cmp(const BIGNUM *a, const BIGNUM *b) { int i; int gt, lt; BN_ULONG t1, t2; if ((a == NULL) || (b == NULL)) { if (a != NULL) return (-1); else if (b != NULL) return (1); else return (0); } bn_check_top(a); bn_check_top(b); if (a->neg != b->neg) { if (a->neg) return (-1); else return (1); } if (a->neg == 0) { gt = 1; lt = -1; } else { gt = -1; lt = 1; } if (a->top > b->top) return (gt); if (a->top < b->top) return (lt); for (i = a->top - 1; i >= 0; i--) { t1 = a->d[i]; t2 = b->d[i]; if (t1 > t2) return (gt); if (t1 < t2) return (lt); } return (0); } int BN_set_bit(BIGNUM *a, int n) { int i, j, k; if (n < 0) return 0; i = n / BN_BITS2; j = n % BN_BITS2; if (a->top <= i) { if (bn_wexpand(a, i + 1) == NULL) return (0); for (k = a->top; k < i + 1; k++) a->d[k] = 0; a->top = i + 1; } a->d[i] |= (((BN_ULONG)1) << j); bn_check_top(a); return (1); } int BN_clear_bit(BIGNUM *a, int n) { int i, j; bn_check_top(a); if (n < 0) return 0; i = n / BN_BITS2; j = n % BN_BITS2; if (a->top <= i) return (0); a->d[i] &= (~(((BN_ULONG)1) << j)); bn_correct_top(a); return (1); } int BN_is_bit_set(const BIGNUM *a, int n) { int i, j; bn_check_top(a); if (n < 0) return 0; i = n / BN_BITS2; j = n % BN_BITS2; if (a->top <= i) return 0; return (int)(((a->d[i]) >> j) & ((BN_ULONG)1)); } int BN_mask_bits(BIGNUM *a, int n) { int b, w; bn_check_top(a); if (n < 0) return 0; w = n / BN_BITS2; b = n % BN_BITS2; if (w >= a->top) return 0; if (b == 0) a->top = w; else { a->top = w + 1; a->d[w] &= ~(BN_MASK2 << b); } bn_correct_top(a); return (1); } void BN_set_negative(BIGNUM *a, int b) { if (b && !BN_is_zero(a)) a->neg = 1; else a->neg = 0; } int bn_cmp_words(const BN_ULONG *a, const BN_ULONG *b, int n) { int i; BN_ULONG aa, bb; aa = a[n - 1]; bb = b[n - 1]; if (aa != bb) return ((aa > bb) ? 1 : -1); for (i = n - 2; i >= 0; i--) { aa = a[i]; bb = b[i]; if (aa != bb) return ((aa > bb) ? 1 : -1); } return (0); } /* Here follows a specialised variants of bn_cmp_words(). It has the property of performing the operation on arrays of different sizes. The sizes of those arrays is expressed through cl, which is the common length ( basicall, min(len(a),len(b)) ), and dl, which is the delta between the two lengths, calculated as len(a)-len(b). All lengths are the number of BN_ULONGs... */ int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b, int cl, int dl) { int n, i; n = cl - 1; if (dl < 0) { for (i = dl; i < 0; i++) { if (b[n - i] != 0) return -1; /* a < b */ } } if (dl > 0) { for (i = dl; i > 0; i--) { if (a[n + i] != 0) return 1; /* a > b */ } } return bn_cmp_words(a, b, cl); } /* * Constant-time conditional swap of a and b. * a and b are swapped if condition is not 0. The code assumes that at most one bit of condition is set. * nwords is the number of words to swap. The code assumes that at least nwords are allocated in both a and b, * and that no more than nwords are used by either a or b. * a and b cannot be the same number */ void BN_consttime_swap(BN_ULONG condition, BIGNUM *a, BIGNUM *b, int nwords) { BN_ULONG t; int i; bn_wcheck_size(a, nwords); bn_wcheck_size(b, nwords); assert(a != b); assert((condition & (condition - 1)) == 0); assert(sizeof(BN_ULONG) >= sizeof(int)); condition = ((condition - 1) >> (BN_BITS2 - 1)) - 1; t = (a->top^b->top) & condition; a->top ^= t; b->top ^= t; #define BN_CONSTTIME_SWAP(ind) \ do { \ t = (a->d[ind] ^ b->d[ind]) & condition; \ a->d[ind] ^= t; \ b->d[ind] ^= t; \ } while (0) switch (nwords) { default: for (i = 10; i < nwords; i++) BN_CONSTTIME_SWAP(i); /* Fallthrough */ case 10: BN_CONSTTIME_SWAP(9); /* Fallthrough */ case 9: BN_CONSTTIME_SWAP(8); /* Fallthrough */ case 8: BN_CONSTTIME_SWAP(7); /* Fallthrough */ case 7: BN_CONSTTIME_SWAP(6); /* Fallthrough */ case 6: BN_CONSTTIME_SWAP(5); /* Fallthrough */ case 5: BN_CONSTTIME_SWAP(4); /* Fallthrough */ case 4: BN_CONSTTIME_SWAP(3); /* Fallthrough */ case 3: BN_CONSTTIME_SWAP(2); /* Fallthrough */ case 2: BN_CONSTTIME_SWAP(1); /* Fallthrough */ case 1: BN_CONSTTIME_SWAP(0); } #undef BN_CONSTTIME_SWAP } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_exp.c0000644000175000017500000007246312360020705020305 0ustar /* $OpenBSD: bn_exp.c,v 1.18 2014/07/11 08:44:47 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include "bn_lcl.h" /* maximum precomputation table size for *variable* sliding windows */ #define TABLE_SIZE 32 /* this one works - simple but works */ int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) { int i, bits, ret = 0; BIGNUM *v, *rr; if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0) { /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */ BNerr(BN_F_BN_EXP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return -1; } BN_CTX_start(ctx); if ((r == a) || (r == p)) rr = BN_CTX_get(ctx); else rr = r; v = BN_CTX_get(ctx); if (rr == NULL || v == NULL) goto err; if (BN_copy(v, a) == NULL) goto err; bits = BN_num_bits(p); if (BN_is_odd(p)) { if (BN_copy(rr, a) == NULL) goto err; } else { if (!BN_one(rr)) goto err; } for (i = 1; i < bits; i++) { if (!BN_sqr(v, v, ctx)) goto err; if (BN_is_bit_set(p, i)) { if (!BN_mul(rr, rr, v, ctx)) goto err; } } ret = 1; err: if (r != rr) BN_copy(r, rr); BN_CTX_end(ctx); bn_check_top(r); return (ret); } int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx) { int ret; bn_check_top(a); bn_check_top(p); bn_check_top(m); /* For even modulus m = 2^k*m_odd, it might make sense to compute * a^p mod m_odd and a^p mod 2^k separately (with Montgomery * exponentiation for the odd part), using appropriate exponent * reductions, and combine the results using the CRT. * * For now, we use Montgomery only if the modulus is odd; otherwise, * exponentiation using the reciprocal-based quick remaindering * algorithm is used. * * (Timing obtained with expspeed.c [computations a^p mod m * where a, p, m are of the same length: 256, 512, 1024, 2048, * 4096, 8192 bits], compared to the running time of the * standard algorithm: * * BN_mod_exp_mont 33 .. 40 % [AMD K6-2, Linux, debug configuration] * 55 .. 77 % [UltraSparc processor, but * debug-solaris-sparcv8-gcc conf.] * * BN_mod_exp_recp 50 .. 70 % [AMD K6-2, Linux, debug configuration] * 62 .. 118 % [UltraSparc, debug-solaris-sparcv8-gcc] * * On the Sparc, BN_mod_exp_recp was faster than BN_mod_exp_mont * at 2048 and more bits, but at 512 and 1024 bits, it was * slower even than the standard algorithm! * * "Real" timings [linux-elf, solaris-sparcv9-gcc configurations] * should be obtained when the new Montgomery reduction code * has been integrated into OpenSSL.) */ #define MONT_MUL_MOD #define MONT_EXP_WORD #define RECP_MUL_MOD #ifdef MONT_MUL_MOD /* I have finally been able to take out this pre-condition of * the top bit being set. It was caused by an error in BN_div * with negatives. There was also another problem when for a^b%m * a >= m. eay 07-May-97 */ /* if ((m->d[m->top-1]&BN_TBIT) && BN_is_odd(m)) */ if (BN_is_odd(m)) { # ifdef MONT_EXP_WORD if (a->top == 1 && !a->neg && (BN_get_flags(p, BN_FLG_CONSTTIME) == 0)) { BN_ULONG A = a->d[0]; ret = BN_mod_exp_mont_word(r, A,p, m,ctx, NULL); } else # endif ret = BN_mod_exp_mont(r, a,p, m,ctx, NULL); } else #endif #ifdef RECP_MUL_MOD { ret = BN_mod_exp_recp(r, a,p, m, ctx); } #else { ret = BN_mod_exp_simple(r, a,p, m, ctx); } #endif bn_check_top(r); return (ret); } int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx) { int i, j, bits, ret = 0, wstart, wend, window, wvalue; int start = 1; BIGNUM *aa; /* Table of variables obtained from 'ctx' */ BIGNUM *val[TABLE_SIZE]; BN_RECP_CTX recp; if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0) { /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */ BNerr(BN_F_BN_MOD_EXP_RECP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return -1; } bits = BN_num_bits(p); if (bits == 0) { ret = BN_one(r); return ret; } BN_CTX_start(ctx); aa = BN_CTX_get(ctx); val[0] = BN_CTX_get(ctx); if (!aa || !val[0]) goto err; BN_RECP_CTX_init(&recp); if (m->neg) { /* ignore sign of 'm' */ if (!BN_copy(aa, m)) goto err; aa->neg = 0; if (BN_RECP_CTX_set(&recp, aa, ctx) <= 0) goto err; } else { if (BN_RECP_CTX_set(&recp, m, ctx) <= 0) goto err; } if (!BN_nnmod(val[0], a, m, ctx)) goto err; /* 1 */ if (BN_is_zero(val[0])) { BN_zero(r); ret = 1; goto err; } window = BN_window_bits_for_exponent_size(bits); if (window > 1) { if (!BN_mod_mul_reciprocal(aa, val[0], val[0], &recp, ctx)) goto err; /* 2 */ j = 1 << (window - 1); for (i = 1; i < j; i++) { if (((val[i] = BN_CTX_get(ctx)) == NULL) || !BN_mod_mul_reciprocal(val[i], val[i - 1], aa, &recp, ctx)) goto err; } } start = 1; /* This is used to avoid multiplication etc * when there is only the value '1' in the * buffer. */ wvalue = 0; /* The 'value' of the window */ wstart = bits - 1; /* The top bit of the window */ wend = 0; /* The bottom bit of the window */ if (!BN_one(r)) goto err; for (;;) { if (BN_is_bit_set(p, wstart) == 0) { if (!start) if (!BN_mod_mul_reciprocal(r, r,r, &recp, ctx)) goto err; if (wstart == 0) break; wstart--; continue; } /* We now have wstart on a 'set' bit, we now need to work out * how bit a window to do. To do this we need to scan * forward until the last set bit before the end of the * window */ j = wstart; wvalue = 1; wend = 0; for (i = 1; i < window; i++) { if (wstart - i < 0) break; if (BN_is_bit_set(p, wstart - i)) { wvalue <<= (i - wend); wvalue |= 1; wend = i; } } /* wend is the size of the current window */ j = wend + 1; /* add the 'bytes above' */ if (!start) for (i = 0; i < j; i++) { if (!BN_mod_mul_reciprocal(r, r,r, &recp, ctx)) goto err; } /* wvalue will be an odd number < 2^window */ if (!BN_mod_mul_reciprocal(r, r,val[wvalue >> 1], &recp, ctx)) goto err; /* move the 'window' down further */ wstart -= wend + 1; wvalue = 0; start = 0; if (wstart < 0) break; } ret = 1; err: BN_CTX_end(ctx); BN_RECP_CTX_free(&recp); bn_check_top(r); return (ret); } int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) { int i, j, bits, ret = 0, wstart, wend, window, wvalue; int start = 1; BIGNUM *d, *r; const BIGNUM *aa; /* Table of variables obtained from 'ctx' */ BIGNUM *val[TABLE_SIZE]; BN_MONT_CTX *mont = NULL; if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0) { return BN_mod_exp_mont_consttime(rr, a, p, m, ctx, in_mont); } bn_check_top(a); bn_check_top(p); bn_check_top(m); if (!BN_is_odd(m)) { BNerr(BN_F_BN_MOD_EXP_MONT, BN_R_CALLED_WITH_EVEN_MODULUS); return (0); } bits = BN_num_bits(p); if (bits == 0) { ret = BN_one(rr); return ret; } BN_CTX_start(ctx); d = BN_CTX_get(ctx); r = BN_CTX_get(ctx); val[0] = BN_CTX_get(ctx); if (!d || !r || !val[0]) goto err; /* If this is not done, things will break in the montgomery * part */ if (in_mont != NULL) mont = in_mont; else { if ((mont = BN_MONT_CTX_new()) == NULL) goto err; if (!BN_MONT_CTX_set(mont, m, ctx)) goto err; } if (a->neg || BN_ucmp(a, m) >= 0) { if (!BN_nnmod(val[0], a,m, ctx)) goto err; aa = val[0]; } else aa = a; if (BN_is_zero(aa)) { BN_zero(rr); ret = 1; goto err; } if (!BN_to_montgomery(val[0], aa, mont, ctx)) goto err; /* 1 */ window = BN_window_bits_for_exponent_size(bits); if (window > 1) { if (!BN_mod_mul_montgomery(d, val[0], val[0], mont, ctx)) goto err; /* 2 */ j = 1 << (window - 1); for (i = 1; i < j; i++) { if (((val[i] = BN_CTX_get(ctx)) == NULL) || !BN_mod_mul_montgomery(val[i], val[i - 1], d, mont, ctx)) goto err; } } start = 1; /* This is used to avoid multiplication etc * when there is only the value '1' in the * buffer. */ wvalue = 0; /* The 'value' of the window */ wstart = bits - 1; /* The top bit of the window */ wend = 0; /* The bottom bit of the window */ if (!BN_to_montgomery(r, BN_value_one(), mont, ctx)) goto err; for (;;) { if (BN_is_bit_set(p, wstart) == 0) { if (!start) { if (!BN_mod_mul_montgomery(r, r, r, mont, ctx)) goto err; } if (wstart == 0) break; wstart--; continue; } /* We now have wstart on a 'set' bit, we now need to work out * how bit a window to do. To do this we need to scan * forward until the last set bit before the end of the * window */ j = wstart; wvalue = 1; wend = 0; for (i = 1; i < window; i++) { if (wstart - i < 0) break; if (BN_is_bit_set(p, wstart - i)) { wvalue <<= (i - wend); wvalue |= 1; wend = i; } } /* wend is the size of the current window */ j = wend + 1; /* add the 'bytes above' */ if (!start) for (i = 0; i < j; i++) { if (!BN_mod_mul_montgomery(r, r, r, mont, ctx)) goto err; } /* wvalue will be an odd number < 2^window */ if (!BN_mod_mul_montgomery(r, r, val[wvalue >> 1], mont, ctx)) goto err; /* move the 'window' down further */ wstart -= wend + 1; wvalue = 0; start = 0; if (wstart < 0) break; } if (!BN_from_montgomery(rr, r,mont, ctx)) goto err; ret = 1; err: if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont); BN_CTX_end(ctx); bn_check_top(rr); return (ret); } /* BN_mod_exp_mont_consttime() stores the precomputed powers in a specific layout * so that accessing any of these table values shows the same access pattern as far * as cache lines are concerned. The following functions are used to transfer a BIGNUM * from/to that table. */ static int MOD_EXP_CTIME_COPY_TO_PREBUF(const BIGNUM *b, int top, unsigned char *buf, int idx, int width) { size_t i, j; if (top > b->top) top = b->top; /* this works because 'buf' is explicitly zeroed */ for (i = 0, j = idx; i < top * sizeof b->d[0]; i++, j += width) { buf[j] = ((unsigned char*)b->d)[i]; } return 1; } static int MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, int top, unsigned char *buf, int idx, int width) { size_t i, j; if (bn_wexpand(b, top) == NULL) return 0; for (i = 0, j = idx; i < top * sizeof b->d[0]; i++, j += width) { ((unsigned char*)b->d)[i] = buf[j]; } b->top = top; bn_correct_top(b); return 1; } /* Given a pointer value, compute the next address that is a cache line multiple. */ #define MOD_EXP_CTIME_ALIGN(x_) \ ((unsigned char*)(x_) + (MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH - (((size_t)(x_)) & (MOD_EXP_CTIME_MIN_CACHE_LINE_MASK)))) /* This variant of BN_mod_exp_mont() uses fixed windows and the special * precomputation memory layout to limit data-dependency to a minimum * to protect secret exponents (cf. the hyper-threading timing attacks * pointed out by Colin Percival, * http://www.daemonology.net/hyperthreading-considered-harmful/) */ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) { int i, bits, ret = 0, window, wvalue; int top; BN_MONT_CTX *mont = NULL; int numPowers; unsigned char *powerbufFree = NULL; int powerbufLen = 0; unsigned char *powerbuf = NULL; BIGNUM tmp, am; bn_check_top(a); bn_check_top(p); bn_check_top(m); top = m->top; if (!(m->d[0] & 1)) { BNerr(BN_F_BN_MOD_EXP_MONT_CONSTTIME, BN_R_CALLED_WITH_EVEN_MODULUS); return (0); } bits = BN_num_bits(p); if (bits == 0) { ret = BN_one(rr); return ret; } BN_CTX_start(ctx); /* Allocate a montgomery context if it was not supplied by the caller. * If this is not done, things will break in the montgomery part. */ if (in_mont != NULL) mont = in_mont; else { if ((mont = BN_MONT_CTX_new()) == NULL) goto err; if (!BN_MONT_CTX_set(mont, m, ctx)) goto err; } /* Get the window size to use with size of p. */ window = BN_window_bits_for_ctime_exponent_size(bits); #if defined(OPENSSL_BN_ASM_MONT5) if (window == 6 && bits <= 1024) window = 5; /* ~5% improvement of 2048-bit RSA sign */ #endif /* Allocate a buffer large enough to hold all of the pre-computed * powers of am, am itself and tmp. */ numPowers = 1 << window; powerbufLen = sizeof(m->d[0]) * (top * numPowers + ((2*top) > numPowers ? (2*top) : numPowers)); if ((powerbufFree = malloc(powerbufLen + MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH)) == NULL) goto err; powerbuf = MOD_EXP_CTIME_ALIGN(powerbufFree); memset(powerbuf, 0, powerbufLen); /* lay down tmp and am right after powers table */ tmp.d = (BN_ULONG *)(powerbuf + sizeof(m->d[0]) * top * numPowers); am.d = tmp.d + top; tmp.top = am.top = 0; tmp.dmax = am.dmax = top; tmp.neg = am.neg = 0; tmp.flags = am.flags = BN_FLG_STATIC_DATA; /* prepare a^0 in Montgomery domain */ #if 1 if (!BN_to_montgomery(&tmp, BN_value_one(), mont, ctx)) goto err; #else tmp.d[0] = (0 - m - >d[0]) & BN_MASK2; /* 2^(top*BN_BITS2) - m */ for (i = 1; i < top; i++) tmp.d[i] = (~m->d[i]) & BN_MASK2; tmp.top = top; #endif /* prepare a^1 in Montgomery domain */ if (a->neg || BN_ucmp(a, m) >= 0) { if (!BN_mod(&am, a,m, ctx)) goto err; if (!BN_to_montgomery(&am, &am, mont, ctx)) goto err; } else if (!BN_to_montgomery(&am, a,mont, ctx)) goto err; #if defined(OPENSSL_BN_ASM_MONT5) /* This optimization uses ideas from http://eprint.iacr.org/2011/239, * specifically optimization of cache-timing attack countermeasures * and pre-computation optimization. */ /* Dedicated window==4 case improves 512-bit RSA sign by ~15%, but as * 512-bit RSA is hardly relevant, we omit it to spare size... */ if (window == 5 && top > 1) { void bn_mul_mont_gather5(BN_ULONG *rp, const BN_ULONG *ap, const void *table, const BN_ULONG *np, const BN_ULONG *n0, int num, int power); void bn_scatter5(const BN_ULONG *inp, size_t num, void *table, size_t power); void bn_gather5(BN_ULONG *out, size_t num, void *table, size_t power); BN_ULONG *np = mont->N.d, *n0 = mont->n0; /* BN_to_montgomery can contaminate words above .top * [in BN_DEBUG[_DEBUG] build]... */ for (i = am.top; i < top; i++) am.d[i] = 0; for (i = tmp.top; i < top; i++) tmp.d[i] = 0; bn_scatter5(tmp.d, top, powerbuf, 0); bn_scatter5(am.d, am.top, powerbuf, 1); bn_mul_mont(tmp.d, am.d, am.d, np, n0, top); bn_scatter5(tmp.d, top, powerbuf, 2); #if 0 for (i = 3; i < 32; i++) { /* Calculate a^i = a^(i-1) * a */ bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, n0, top, i - 1); bn_scatter5(tmp.d, top, powerbuf, i); } #else /* same as above, but uses squaring for 1/2 of operations */ for (i = 4; i < 32; i*=2) { bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); bn_scatter5(tmp.d, top, powerbuf, i); } for (i = 3; i < 8; i += 2) { int j; bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, n0, top, i - 1); bn_scatter5(tmp.d, top, powerbuf, i); for (j = 2 * i; j < 32; j *= 2) { bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); bn_scatter5(tmp.d, top, powerbuf, j); } } for (; i < 16; i += 2) { bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, n0, top, i - 1); bn_scatter5(tmp.d, top, powerbuf, i); bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); bn_scatter5(tmp.d, top, powerbuf, 2*i); } for (; i < 32; i += 2) { bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, n0, top, i - 1); bn_scatter5(tmp.d, top, powerbuf, i); } #endif bits--; for (wvalue = 0, i = bits % 5; i >= 0; i--, bits--) wvalue = (wvalue << 1) + BN_is_bit_set(p, bits); bn_gather5(tmp.d, top, powerbuf, wvalue); /* Scan the exponent one window at a time starting from the most * significant bits. */ while (bits >= 0) { for (wvalue = 0, i = 0; i < 5; i++, bits--) wvalue = (wvalue << 1) + BN_is_bit_set(p, bits); bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top); bn_mul_mont_gather5(tmp.d, tmp.d, powerbuf, np, n0, top, wvalue); } tmp.top = top; bn_correct_top(&tmp); } else #endif { if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&tmp, top, powerbuf, 0, numPowers)) goto err; if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&am, top, powerbuf, 1, numPowers)) goto err; /* If the window size is greater than 1, then calculate * val[i=2..2^winsize-1]. Powers are computed as a*a^(i-1) * (even powers could instead be computed as (a^(i/2))^2 * to use the slight performance advantage of sqr over mul). */ if (window > 1) { if (!BN_mod_mul_montgomery(&tmp, &am, &am, mont, ctx)) goto err; if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&tmp, top, powerbuf, 2, numPowers)) goto err; for (i = 3; i < numPowers; i++) { /* Calculate a^i = a^(i-1) * a */ if (!BN_mod_mul_montgomery(&tmp, &am, &tmp, mont, ctx)) goto err; if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&tmp, top, powerbuf, i, numPowers)) goto err; } } bits--; for (wvalue = 0, i = bits % window; i >= 0; i--, bits--) wvalue = (wvalue << 1) + BN_is_bit_set(p, bits); if (!MOD_EXP_CTIME_COPY_FROM_PREBUF(&tmp, top, powerbuf, wvalue, numPowers)) goto err; /* Scan the exponent one window at a time starting from the most * significant bits. */ while (bits >= 0) { wvalue = 0; /* The 'value' of the window */ /* Scan the window, squaring the result as we go */ for (i = 0; i < window; i++, bits--) { if (!BN_mod_mul_montgomery(&tmp, &tmp, &tmp, mont, ctx)) goto err; wvalue = (wvalue << 1) + BN_is_bit_set(p, bits); } /* Fetch the appropriate pre-computed value from the pre-buf */ if (!MOD_EXP_CTIME_COPY_FROM_PREBUF(&am, top, powerbuf, wvalue, numPowers)) goto err; /* Multiply the result into the intermediate result */ if (!BN_mod_mul_montgomery(&tmp, &tmp, &am, mont, ctx)) goto err; } } /* Convert the final result from montgomery to standard format */ if (!BN_from_montgomery(rr, &tmp, mont, ctx)) goto err; ret = 1; err: if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont); if (powerbuf != NULL) { OPENSSL_cleanse(powerbuf, powerbufLen); free(powerbufFree); } BN_CTX_end(ctx); return (ret); } int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) { BN_MONT_CTX *mont = NULL; int b, bits, ret = 0; int r_is_one; BN_ULONG w, next_w; BIGNUM *d, *r, *t; BIGNUM *swap_tmp; #define BN_MOD_MUL_WORD(r, w, m) \ (BN_mul_word(r, (w)) && \ (/* BN_ucmp(r, (m)) < 0 ? 1 :*/ \ (BN_mod(t, r, m, ctx) && (swap_tmp = r, r = t, t = swap_tmp, 1)))) /* BN_MOD_MUL_WORD is only used with 'w' large, * so the BN_ucmp test is probably more overhead * than always using BN_mod (which uses BN_copy if * a similar test returns true). */ /* We can use BN_mod and do not need BN_nnmod because our * accumulator is never negative (the result of BN_mod does * not depend on the sign of the modulus). */ #define BN_TO_MONTGOMERY_WORD(r, w, mont) \ (BN_set_word(r, (w)) && BN_to_montgomery(r, r, (mont), ctx)) if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0) { /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */ BNerr(BN_F_BN_MOD_EXP_MONT_WORD, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return -1; } bn_check_top(p); bn_check_top(m); if (!BN_is_odd(m)) { BNerr(BN_F_BN_MOD_EXP_MONT_WORD, BN_R_CALLED_WITH_EVEN_MODULUS); return (0); } if (m->top == 1) a %= m->d[0]; /* make sure that 'a' is reduced */ bits = BN_num_bits(p); if (bits == 0) { ret = BN_one(rr); return ret; } if (a == 0) { BN_zero(rr); ret = 1; return ret; } BN_CTX_start(ctx); d = BN_CTX_get(ctx); r = BN_CTX_get(ctx); t = BN_CTX_get(ctx); if (d == NULL || r == NULL || t == NULL) goto err; if (in_mont != NULL) mont = in_mont; else { if ((mont = BN_MONT_CTX_new()) == NULL) goto err; if (!BN_MONT_CTX_set(mont, m, ctx)) goto err; } r_is_one = 1; /* except for Montgomery factor */ /* bits-1 >= 0 */ /* The result is accumulated in the product r*w. */ w = a; /* bit 'bits-1' of 'p' is always set */ for (b = bits - 2; b >= 0; b--) { /* First, square r*w. */ next_w = w * w; if ((next_w / w) != w) /* overflow */ { if (r_is_one) { if (!BN_TO_MONTGOMERY_WORD(r, w, mont)) goto err; r_is_one = 0; } else { if (!BN_MOD_MUL_WORD(r, w, m)) goto err; } next_w = 1; } w = next_w; if (!r_is_one) { if (!BN_mod_mul_montgomery(r, r, r, mont, ctx)) goto err; } /* Second, multiply r*w by 'a' if exponent bit is set. */ if (BN_is_bit_set(p, b)) { next_w = w * a; if ((next_w / a) != w) /* overflow */ { if (r_is_one) { if (!BN_TO_MONTGOMERY_WORD(r, w, mont)) goto err; r_is_one = 0; } else { if (!BN_MOD_MUL_WORD(r, w, m)) goto err; } next_w = a; } w = next_w; } } /* Finally, set r:=r*w. */ if (w != 1) { if (r_is_one) { if (!BN_TO_MONTGOMERY_WORD(r, w, mont)) goto err; r_is_one = 0; } else { if (!BN_MOD_MUL_WORD(r, w, m)) goto err; } } if (r_is_one) /* can happen only if a == 1*/ { if (!BN_one(rr)) goto err; } else { if (!BN_from_montgomery(rr, r, mont, ctx)) goto err; } ret = 1; err: if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont); BN_CTX_end(ctx); bn_check_top(rr); return (ret); } /* The old fallback, simple version :-) */ int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx) { int i, j,bits, ret = 0, wstart, wend, window, wvalue; int start = 1; BIGNUM *d; /* Table of variables obtained from 'ctx' */ BIGNUM *val[TABLE_SIZE]; if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0) { /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */ BNerr(BN_F_BN_MOD_EXP_SIMPLE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return -1; } bits = BN_num_bits(p); if (bits == 0) { ret = BN_one(r); return ret; } BN_CTX_start(ctx); d = BN_CTX_get(ctx); val[0] = BN_CTX_get(ctx); if (!d || !val[0]) goto err; if (!BN_nnmod(val[0],a,m,ctx)) goto err; /* 1 */ if (BN_is_zero(val[0])) { BN_zero(r); ret = 1; goto err; } window = BN_window_bits_for_exponent_size(bits); if (window > 1) { if (!BN_mod_mul(d, val[0], val[0], m, ctx)) goto err; /* 2 */ j = 1 << (window - 1); for (i = 1; i < j; i++) { if (((val[i] = BN_CTX_get(ctx)) == NULL) || !BN_mod_mul(val[i], val[i - 1], d,m, ctx)) goto err; } } start = 1; /* This is used to avoid multiplication etc * when there is only the value '1' in the * buffer. */ wvalue = 0; /* The 'value' of the window */ wstart = bits - 1; /* The top bit of the window */ wend = 0; /* The bottom bit of the window */ if (!BN_one(r)) goto err; for (;;) { if (BN_is_bit_set(p, wstart) == 0) { if (!start) if (!BN_mod_mul(r, r, r, m, ctx)) goto err; if (wstart == 0) break; wstart--; continue; } /* We now have wstart on a 'set' bit, we now need to work out * how bit a window to do. To do this we need to scan * forward until the last set bit before the end of the * window */ j = wstart; wvalue = 1; wend = 0; for (i = 1; i < window; i++) { if (wstart - i < 0) break; if (BN_is_bit_set(p, wstart - i)) { wvalue <<= (i - wend); wvalue |= 1; wend = i; } } /* wend is the size of the current window */ j = wend + 1; /* add the 'bytes above' */ if (!start) for (i = 0; i < j; i++) { if (!BN_mod_mul(r, r, r, m, ctx)) goto err; } /* wvalue will be an odd number < 2^window */ if (!BN_mod_mul(r, r, val[wvalue >> 1], m, ctx)) goto err; /* move the 'window' down further */ wstart -= wend + 1; wvalue = 0; start = 0; if (wstart < 0) break; } ret = 1; err: BN_CTX_end(ctx); bn_check_top(r); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_sqrt.c0000644000175000017500000002346212360020705020475 0ustar /* $OpenBSD: bn_sqrt.c,v 1.4 2014/06/12 15:49:28 deraadt Exp $ */ /* Written by Lenka Fibikova * and Bodo Moeller for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include "bn_lcl.h" BIGNUM * BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) /* Returns 'ret' such that * ret^2 == a (mod p), * using the Tonelli/Shanks algorithm (cf. Henri Cohen, "A Course * in Algebraic Computational Number Theory", algorithm 1.5.1). * 'p' must be prime! */ { BIGNUM *ret = in; int err = 1; int r; BIGNUM *A, *b, *q, *t, *x, *y; int e, i, j; if (!BN_is_odd(p) || BN_abs_is_word(p, 1)) { if (BN_abs_is_word(p, 2)) { if (ret == NULL) ret = BN_new(); if (ret == NULL) goto end; if (!BN_set_word(ret, BN_is_bit_set(a, 0))) { if (ret != in) BN_free(ret); return NULL; } bn_check_top(ret); return ret; } BNerr(BN_F_BN_MOD_SQRT, BN_R_P_IS_NOT_PRIME); return (NULL); } if (BN_is_zero(a) || BN_is_one(a)) { if (ret == NULL) ret = BN_new(); if (ret == NULL) goto end; if (!BN_set_word(ret, BN_is_one(a))) { if (ret != in) BN_free(ret); return NULL; } bn_check_top(ret); return ret; } BN_CTX_start(ctx); A = BN_CTX_get(ctx); b = BN_CTX_get(ctx); q = BN_CTX_get(ctx); t = BN_CTX_get(ctx); x = BN_CTX_get(ctx); y = BN_CTX_get(ctx); if (y == NULL) goto end; if (ret == NULL) ret = BN_new(); if (ret == NULL) goto end; /* A = a mod p */ if (!BN_nnmod(A, a, p, ctx)) goto end; /* now write |p| - 1 as 2^e*q where q is odd */ e = 1; while (!BN_is_bit_set(p, e)) e++; /* we'll set q later (if needed) */ if (e == 1) { /* The easy case: (|p|-1)/2 is odd, so 2 has an inverse * modulo (|p|-1)/2, and square roots can be computed * directly by modular exponentiation. * We have * 2 * (|p|+1)/4 == 1 (mod (|p|-1)/2), * so we can use exponent (|p|+1)/4, i.e. (|p|-3)/4 + 1. */ if (!BN_rshift(q, p, 2)) goto end; q->neg = 0; if (!BN_add_word(q, 1)) goto end; if (!BN_mod_exp(ret, A, q, p, ctx)) goto end; err = 0; goto vrfy; } if (e == 2) { /* |p| == 5 (mod 8) * * In this case 2 is always a non-square since * Legendre(2,p) = (-1)^((p^2-1)/8) for any odd prime. * So if a really is a square, then 2*a is a non-square. * Thus for * b := (2*a)^((|p|-5)/8), * i := (2*a)*b^2 * we have * i^2 = (2*a)^((1 + (|p|-5)/4)*2) * = (2*a)^((p-1)/2) * = -1; * so if we set * x := a*b*(i-1), * then * x^2 = a^2 * b^2 * (i^2 - 2*i + 1) * = a^2 * b^2 * (-2*i) * = a*(-i)*(2*a*b^2) * = a*(-i)*i * = a. * * (This is due to A.O.L. Atkin, * , * November 1992.) */ /* t := 2*a */ if (!BN_mod_lshift1_quick(t, A, p)) goto end; /* b := (2*a)^((|p|-5)/8) */ if (!BN_rshift(q, p, 3)) goto end; q->neg = 0; if (!BN_mod_exp(b, t, q, p, ctx)) goto end; /* y := b^2 */ if (!BN_mod_sqr(y, b, p, ctx)) goto end; /* t := (2*a)*b^2 - 1*/ if (!BN_mod_mul(t, t, y, p, ctx)) goto end; if (!BN_sub_word(t, 1)) goto end; /* x = a*b*t */ if (!BN_mod_mul(x, A, b, p, ctx)) goto end; if (!BN_mod_mul(x, x, t, p, ctx)) goto end; if (!BN_copy(ret, x)) goto end; err = 0; goto vrfy; } /* e > 2, so we really have to use the Tonelli/Shanks algorithm. * First, find some y that is not a square. */ if (!BN_copy(q, p)) goto end; /* use 'q' as temp */ q->neg = 0; i = 2; do { /* For efficiency, try small numbers first; * if this fails, try random numbers. */ if (i < 22) { if (!BN_set_word(y, i)) goto end; } else { if (!BN_pseudo_rand(y, BN_num_bits(p), 0, 0)) goto end; if (BN_ucmp(y, p) >= 0) { if (!(p->neg ? BN_add : BN_sub)(y, y, p)) goto end; } /* now 0 <= y < |p| */ if (BN_is_zero(y)) if (!BN_set_word(y, i)) goto end; } r = BN_kronecker(y, q, ctx); /* here 'q' is |p| */ if (r < -1) goto end; if (r == 0) { /* m divides p */ BNerr(BN_F_BN_MOD_SQRT, BN_R_P_IS_NOT_PRIME); goto end; } } while (r == 1 && ++i < 82); if (r != -1) { /* Many rounds and still no non-square -- this is more likely * a bug than just bad luck. * Even if p is not prime, we should have found some y * such that r == -1. */ BNerr(BN_F_BN_MOD_SQRT, BN_R_TOO_MANY_ITERATIONS); goto end; } /* Here's our actual 'q': */ if (!BN_rshift(q, q, e)) goto end; /* Now that we have some non-square, we can find an element * of order 2^e by computing its q'th power. */ if (!BN_mod_exp(y, y, q, p, ctx)) goto end; if (BN_is_one(y)) { BNerr(BN_F_BN_MOD_SQRT, BN_R_P_IS_NOT_PRIME); goto end; } /* Now we know that (if p is indeed prime) there is an integer * k, 0 <= k < 2^e, such that * * a^q * y^k == 1 (mod p). * * As a^q is a square and y is not, k must be even. * q+1 is even, too, so there is an element * * X := a^((q+1)/2) * y^(k/2), * * and it satisfies * * X^2 = a^q * a * y^k * = a, * * so it is the square root that we are looking for. */ /* t := (q-1)/2 (note that q is odd) */ if (!BN_rshift1(t, q)) goto end; /* x := a^((q-1)/2) */ if (BN_is_zero(t)) /* special case: p = 2^e + 1 */ { if (!BN_nnmod(t, A, p, ctx)) goto end; if (BN_is_zero(t)) { /* special case: a == 0 (mod p) */ BN_zero(ret); err = 0; goto end; } else if (!BN_one(x)) goto end; } else { if (!BN_mod_exp(x, A, t, p, ctx)) goto end; if (BN_is_zero(x)) { /* special case: a == 0 (mod p) */ BN_zero(ret); err = 0; goto end; } } /* b := a*x^2 (= a^q) */ if (!BN_mod_sqr(b, x, p, ctx)) goto end; if (!BN_mod_mul(b, b, A, p, ctx)) goto end; /* x := a*x (= a^((q+1)/2)) */ if (!BN_mod_mul(x, x, A, p, ctx)) goto end; while (1) { /* Now b is a^q * y^k for some even k (0 <= k < 2^E * where E refers to the original value of e, which we * don't keep in a variable), and x is a^((q+1)/2) * y^(k/2). * * We have a*b = x^2, * y^2^(e-1) = -1, * b^2^(e-1) = 1. */ if (BN_is_one(b)) { if (!BN_copy(ret, x)) goto end; err = 0; goto vrfy; } /* find smallest i such that b^(2^i) = 1 */ i = 1; if (!BN_mod_sqr(t, b, p, ctx)) goto end; while (!BN_is_one(t)) { i++; if (i == e) { BNerr(BN_F_BN_MOD_SQRT, BN_R_NOT_A_SQUARE); goto end; } if (!BN_mod_mul(t, t, t, p, ctx)) goto end; } /* t := y^2^(e - i - 1) */ if (!BN_copy(t, y)) goto end; for (j = e - i - 1; j > 0; j--) { if (!BN_mod_sqr(t, t, p, ctx)) goto end; } if (!BN_mod_mul(y, t, t, p, ctx)) goto end; if (!BN_mod_mul(x, x, t, p, ctx)) goto end; if (!BN_mod_mul(b, b, y, p, ctx)) goto end; e = i; } vrfy: if (!err) { /* verify the result -- the input might have been not a square * (test added in 0.9.8) */ if (!BN_mod_sqr(x, ret, p, ctx)) err = 1; if (!err && 0 != BN_cmp(x, A)) { BNerr(BN_F_BN_MOD_SQRT, BN_R_NOT_A_SQUARE); err = 1; } } end: if (err) { if (ret != NULL && ret != in) { BN_clear_free(ret); } ret = NULL; } BN_CTX_end(ctx); bn_check_top(ret); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_asm.c0000644000175000017500000006046712360020705020272 0ustar /* $OpenBSD: bn_asm.c,v 1.12 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #ifndef BN_DEBUG # undef NDEBUG /* avoid conflicting definitions */ # define NDEBUG #endif #include #include #include #include "bn_lcl.h" #if defined(BN_LLONG) || defined(BN_UMULT_HIGH) BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w) { BN_ULONG c1 = 0; assert(num >= 0); if (num <= 0) return (c1); #ifndef OPENSSL_SMALL_FOOTPRINT while (num & ~3) { mul_add(rp[0], ap[0], w, c1); mul_add(rp[1], ap[1], w, c1); mul_add(rp[2], ap[2], w, c1); mul_add(rp[3], ap[3], w, c1); ap += 4; rp += 4; num -= 4; } #endif while (num) { mul_add(rp[0], ap[0], w, c1); ap++; rp++; num--; } return (c1); } BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w) { BN_ULONG c1 = 0; assert(num >= 0); if (num <= 0) return (c1); #ifndef OPENSSL_SMALL_FOOTPRINT while (num & ~3) { mul(rp[0], ap[0], w, c1); mul(rp[1], ap[1], w, c1); mul(rp[2], ap[2], w, c1); mul(rp[3], ap[3], w, c1); ap += 4; rp += 4; num -= 4; } #endif while (num) { mul(rp[0], ap[0], w, c1); ap++; rp++; num--; } return (c1); } void bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n) { assert(n >= 0); if (n <= 0) return; #ifndef OPENSSL_SMALL_FOOTPRINT while (n & ~3) { sqr(r[0], r[1], a[0]); sqr(r[2], r[3], a[1]); sqr(r[4], r[5], a[2]); sqr(r[6], r[7], a[3]); a += 4; r += 8; n -= 4; } #endif while (n) { sqr(r[0], r[1], a[0]); a++; r += 2; n--; } } #else /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */ BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w) { BN_ULONG c = 0; BN_ULONG bl, bh; assert(num >= 0); if (num <= 0) return ((BN_ULONG)0); bl = LBITS(w); bh = HBITS(w); #ifndef OPENSSL_SMALL_FOOTPRINT while (num & ~3) { mul_add(rp[0], ap[0], bl, bh, c); mul_add(rp[1], ap[1], bl, bh, c); mul_add(rp[2], ap[2], bl, bh, c); mul_add(rp[3], ap[3], bl, bh, c); ap += 4; rp += 4; num -= 4; } #endif while (num) { mul_add(rp[0], ap[0], bl, bh, c); ap++; rp++; num--; } return (c); } BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w) { BN_ULONG carry = 0; BN_ULONG bl, bh; assert(num >= 0); if (num <= 0) return ((BN_ULONG)0); bl = LBITS(w); bh = HBITS(w); #ifndef OPENSSL_SMALL_FOOTPRINT while (num & ~3) { mul(rp[0], ap[0], bl, bh, carry); mul(rp[1], ap[1], bl, bh, carry); mul(rp[2], ap[2], bl, bh, carry); mul(rp[3], ap[3], bl, bh, carry); ap += 4; rp += 4; num -= 4; } #endif while (num) { mul(rp[0], ap[0], bl, bh, carry); ap++; rp++; num--; } return (carry); } void bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n) { assert(n >= 0); if (n <= 0) return; #ifndef OPENSSL_SMALL_FOOTPRINT while (n & ~3) { sqr64(r[0], r[1], a[0]); sqr64(r[2], r[3], a[1]); sqr64(r[4], r[5], a[2]); sqr64(r[6], r[7], a[3]); a += 4; r += 8; n -= 4; } #endif while (n) { sqr64(r[0], r[1], a[0]); a++; r += 2; n--; } } #endif /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */ #if defined(BN_LLONG) && defined(BN_DIV2W) BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) { return ((BN_ULONG)(((((BN_ULLONG)h) << BN_BITS2)|l)/(BN_ULLONG)d)); } #else /* Divide h,l by d and return the result. */ /* I need to test this some more :-( */ BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) { BN_ULONG dh, dl, q,ret = 0, th, tl, t; int i, count = 2; if (d == 0) return (BN_MASK2); i = BN_num_bits_word(d); assert((i == BN_BITS2) || (h <= (BN_ULONG)1 << i)); i = BN_BITS2 - i; if (h >= d) h -= d; if (i) { d <<= i; h = (h << i) | (l >> (BN_BITS2 - i)); l <<= i; } dh = (d & BN_MASK2h) >> BN_BITS4; dl = (d & BN_MASK2l); for (;;) { if ((h >> BN_BITS4) == dh) q = BN_MASK2l; else q = h / dh; th = q * dh; tl = dl * q; for (;;) { t = h - th; if ((t & BN_MASK2h) || ((tl) <= ( (t << BN_BITS4) | ((l & BN_MASK2h) >> BN_BITS4)))) break; q--; th -= dh; tl -= dl; } t = (tl >> BN_BITS4); tl = (tl << BN_BITS4) & BN_MASK2h; th += t; if (l < tl) th++; l -= tl; if (h < th) { h += d; q--; } h -= th; if (--count == 0) break; ret = q << BN_BITS4; h = ((h << BN_BITS4) | (l >> BN_BITS4)) & BN_MASK2; l = (l & BN_MASK2l) << BN_BITS4; } ret |= q; return (ret); } #endif /* !defined(BN_LLONG) && defined(BN_DIV2W) */ #ifdef BN_LLONG BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n) { BN_ULLONG ll = 0; assert(n >= 0); if (n <= 0) return ((BN_ULONG)0); #ifndef OPENSSL_SMALL_FOOTPRINT while (n & ~3) { ll += (BN_ULLONG)a[0] + b[0]; r[0] = (BN_ULONG)ll & BN_MASK2; ll >>= BN_BITS2; ll += (BN_ULLONG)a[1] + b[1]; r[1] = (BN_ULONG)ll & BN_MASK2; ll >>= BN_BITS2; ll += (BN_ULLONG)a[2] + b[2]; r[2] = (BN_ULONG)ll & BN_MASK2; ll >>= BN_BITS2; ll += (BN_ULLONG)a[3] + b[3]; r[3] = (BN_ULONG)ll & BN_MASK2; ll >>= BN_BITS2; a += 4; b += 4; r += 4; n -= 4; } #endif while (n) { ll += (BN_ULLONG)a[0] + b[0]; r[0] = (BN_ULONG)ll & BN_MASK2; ll >>= BN_BITS2; a++; b++; r++; n--; } return ((BN_ULONG)ll); } #else /* !BN_LLONG */ BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n) { BN_ULONG c, l, t; assert(n >= 0); if (n <= 0) return ((BN_ULONG)0); c = 0; #ifndef OPENSSL_SMALL_FOOTPRINT while (n & ~3) { t = a[0]; t = (t + c) & BN_MASK2; c = (t < c); l = (t + b[0]) & BN_MASK2; c += (l < t); r[0] = l; t = a[1]; t = (t + c) & BN_MASK2; c = (t < c); l = (t + b[1]) & BN_MASK2; c += (l < t); r[1] = l; t = a[2]; t = (t + c) & BN_MASK2; c = (t < c); l = (t + b[2]) & BN_MASK2; c += (l < t); r[2] = l; t = a[3]; t = (t + c) & BN_MASK2; c = (t < c); l = (t + b[3]) & BN_MASK2; c += (l < t); r[3] = l; a += 4; b += 4; r += 4; n -= 4; } #endif while (n) { t = a[0]; t = (t + c) & BN_MASK2; c = (t < c); l = (t + b[0]) & BN_MASK2; c += (l < t); r[0] = l; a++; b++; r++; n--; } return ((BN_ULONG)c); } #endif /* !BN_LLONG */ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n) { BN_ULONG t1, t2; int c = 0; assert(n >= 0); if (n <= 0) return ((BN_ULONG)0); #ifndef OPENSSL_SMALL_FOOTPRINT while (n&~3) { t1 = a[0]; t2 = b[0]; r[0] = (t1 - t2 - c) & BN_MASK2; if (t1 != t2) c = (t1 < t2); t1 = a[1]; t2 = b[1]; r[1] = (t1 - t2 - c) & BN_MASK2; if (t1 != t2) c = (t1 < t2); t1 = a[2]; t2 = b[2]; r[2] = (t1 - t2 - c) & BN_MASK2; if (t1 != t2) c = (t1 < t2); t1 = a[3]; t2 = b[3]; r[3] = (t1 - t2 - c) & BN_MASK2; if (t1 != t2) c = (t1 < t2); a += 4; b += 4; r += 4; n -= 4; } #endif while (n) { t1 = a[0]; t2 = b[0]; r[0] = (t1 - t2 - c) & BN_MASK2; if (t1 != t2) c = (t1 < t2); a++; b++; r++; n--; } return (c); } #if defined(BN_MUL_COMBA) && !defined(OPENSSL_SMALL_FOOTPRINT) #undef bn_mul_comba8 #undef bn_mul_comba4 #undef bn_sqr_comba8 #undef bn_sqr_comba4 /* mul_add_c(a,b,c0,c1,c2) -- c+=a*b for three word number c=(c2,c1,c0) */ /* mul_add_c2(a,b,c0,c1,c2) -- c+=2*a*b for three word number c=(c2,c1,c0) */ /* sqr_add_c(a,i,c0,c1,c2) -- c+=a[i]^2 for three word number c=(c2,c1,c0) */ /* sqr_add_c2(a,i,c0,c1,c2) -- c+=2*a[i]*a[j] for three word number c=(c2,c1,c0) */ #ifdef BN_LLONG #define mul_add_c(a,b,c0,c1,c2) \ t=(BN_ULLONG)a*b; \ t1=(BN_ULONG)Lw(t); \ t2=(BN_ULONG)Hw(t); \ c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \ c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++; #define mul_add_c2(a,b,c0,c1,c2) \ t=(BN_ULLONG)a*b; \ tt=(t+t)&BN_MASK; \ if (tt < t) c2++; \ t1=(BN_ULONG)Lw(tt); \ t2=(BN_ULONG)Hw(tt); \ c0=(c0+t1)&BN_MASK2; \ if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \ c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++; #define sqr_add_c(a,i,c0,c1,c2) \ t=(BN_ULLONG)a[i]*a[i]; \ t1=(BN_ULONG)Lw(t); \ t2=(BN_ULONG)Hw(t); \ c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \ c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++; #define sqr_add_c2(a,i,j,c0,c1,c2) \ mul_add_c2((a)[i],(a)[j],c0,c1,c2) #elif defined(BN_UMULT_LOHI) #define mul_add_c(a,b,c0,c1,c2) { \ BN_ULONG ta=(a),tb=(b); \ BN_UMULT_LOHI(t1,t2,ta,tb); \ c0 += t1; t2 += (c0= np[num - 1]) { c0 = bn_sub_words(rp, tp, np, num); if (tp[num] != 0 || c0 == 0) { goto out; } } memcpy(rp, tp, num * sizeof(BN_ULONG)); out: explicit_bzero(tp, (num + 2) * sizeof(BN_ULONG)); free(tp); return 1; } #else /* * Return value of 0 indicates that multiplication/convolution was not * performed to signal the caller to fall down to alternative/original * code-path. */ int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num) { return 0; } #endif /* OPENSSL_BN_ASM_MONT */ #endif #else /* !BN_MUL_COMBA */ /* hmm... is it faster just to do a multiply? */ #undef bn_sqr_comba4 void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a) { BN_ULONG t[8]; bn_sqr_normal(r, a, 4, t); } #undef bn_sqr_comba8 void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a) { BN_ULONG t[16]; bn_sqr_normal(r, a, 8, t); } void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b) { r[4] = bn_mul_words(&(r[0]), a, 4, b[0]); r[5] = bn_mul_add_words(&(r[1]), a, 4, b[1]); r[6] = bn_mul_add_words(&(r[2]), a, 4, b[2]); r[7] = bn_mul_add_words(&(r[3]), a, 4, b[3]); } void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b) { r[8] = bn_mul_words(&(r[0]), a, 8, b[0]); r[9] = bn_mul_add_words(&(r[1]), a, 8, b[1]); r[10] = bn_mul_add_words(&(r[2]), a, 8, b[2]); r[11] = bn_mul_add_words(&(r[3]), a, 8, b[3]); r[12] = bn_mul_add_words(&(r[4]), a, 8, b[4]); r[13] = bn_mul_add_words(&(r[5]), a, 8, b[5]); r[14] = bn_mul_add_words(&(r[6]), a, 8, b[6]); r[15] = bn_mul_add_words(&(r[7]), a, 8, b[7]); } #ifdef OPENSSL_NO_ASM #ifdef OPENSSL_BN_ASM_MONT int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0p, int num) { BN_ULONG c0, c1, *tp, n0 = *n0p; int i = 0, j; tp = calloc(NULL, num + 2, sizeof(BN_ULONG)); if (tp == NULL) return 0; for (i = 0; i < num; i++) { c0 = bn_mul_add_words(tp, ap, num, bp[i]); c1 = (tp[num] + c0) & BN_MASK2; tp[num] = c1; tp[num + 1] = (c1 < c0 ? 1 : 0); c0 = bn_mul_add_words(tp, np, num, tp[0] * n0); c1 = (tp[num] + c0) & BN_MASK2; tp[num] = c1; tp[num + 1] += (c1 < c0 ? 1 : 0); for (j = 0; j <= num; j++) tp[j] = tp[j + 1]; } if (tp[num] != 0 || tp[num - 1] >= np[num - 1]) { c0 = bn_sub_words(rp, tp, np, num); if (tp[num] != 0 || c0 == 0) { goto out; } } memcpy(rp, tp, num * sizeof(BN_ULONG)); out: explicit_bzero(tp, (num + 2) * sizeof(BN_ULONG)); free(tp); return 1; } #else int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num) { return 0; } #endif /* OPENSSL_BN_ASM_MONT */ #endif #endif /* !BN_MUL_COMBA */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_blind.c0000644000175000017500000002633412360020705020575 0ustar /* $OpenBSD: bn_blind.c,v 1.12 2014/07/10 22:45:56 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include "bn_lcl.h" #define BN_BLINDING_COUNTER 32 struct bn_blinding_st { BIGNUM *A; BIGNUM *Ai; BIGNUM *e; BIGNUM *mod; /* just a reference */ #ifndef OPENSSL_NO_DEPRECATED unsigned long thread_id; /* added in OpenSSL 0.9.6j and 0.9.7b; * used only by crypto/rsa/rsa_eay.c, rsa_lib.c */ #endif CRYPTO_THREADID tid; int counter; unsigned long flags; BN_MONT_CTX *m_ctx; int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); }; BN_BLINDING * BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod) { BN_BLINDING *ret = NULL; bn_check_top(mod); if ((ret = calloc(1, sizeof(BN_BLINDING))) == NULL) { BNerr(BN_F_BN_BLINDING_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } if (A != NULL) { if ((ret->A = BN_dup(A)) == NULL) goto err; } if (Ai != NULL) { if ((ret->Ai = BN_dup(Ai)) == NULL) goto err; } /* save a copy of mod in the BN_BLINDING structure */ if ((ret->mod = BN_dup(mod)) == NULL) goto err; if (BN_get_flags(mod, BN_FLG_CONSTTIME) != 0) BN_set_flags(ret->mod, BN_FLG_CONSTTIME); /* Set the counter to the special value -1 * to indicate that this is never-used fresh blinding * that does not need updating before first use. */ ret->counter = -1; CRYPTO_THREADID_current(&ret->tid); return (ret); err: if (ret != NULL) BN_BLINDING_free(ret); return (NULL); } void BN_BLINDING_free(BN_BLINDING *r) { if (r == NULL) return; if (r->A != NULL) BN_clear_free(r->A ); if (r->Ai != NULL) BN_clear_free(r->Ai); if (r->e != NULL) BN_clear_free(r->e ); if (r->mod != NULL) BN_clear_free(r->mod); free(r); } int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx) { int ret = 0; if ((b->A == NULL) || (b->Ai == NULL)) { BNerr(BN_F_BN_BLINDING_UPDATE, BN_R_NOT_INITIALIZED); goto err; } if (b->counter == -1) b->counter = 0; if (++b->counter == BN_BLINDING_COUNTER && b->e != NULL && !(b->flags & BN_BLINDING_NO_RECREATE)) { /* re-create blinding parameters */ if (!BN_BLINDING_create_param(b, NULL, NULL, ctx, NULL, NULL)) goto err; } else if (!(b->flags & BN_BLINDING_NO_UPDATE)) { if (!BN_mod_mul(b->A, b->A, b->A, b->mod, ctx)) goto err; if (!BN_mod_mul(b->Ai, b->Ai, b->Ai, b->mod, ctx)) goto err; } ret = 1; err: if (b->counter == BN_BLINDING_COUNTER) b->counter = 0; return (ret); } int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx) { return BN_BLINDING_convert_ex(n, NULL, b, ctx); } int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx) { int ret = 1; bn_check_top(n); if ((b->A == NULL) || (b->Ai == NULL)) { BNerr(BN_F_BN_BLINDING_CONVERT_EX, BN_R_NOT_INITIALIZED); return (0); } if (b->counter == -1) /* Fresh blinding, doesn't need updating. */ b->counter = 0; else if (!BN_BLINDING_update(b, ctx)) return (0); if (r != NULL) { if (!BN_copy(r, b->Ai)) ret = 0; } if (!BN_mod_mul(n, n,b->A, b->mod, ctx)) ret = 0; return ret; } int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx) { return BN_BLINDING_invert_ex(n, NULL, b, ctx); } int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx) { int ret; bn_check_top(n); if (r != NULL) ret = BN_mod_mul(n, n, r, b->mod, ctx); else { if (b->Ai == NULL) { BNerr(BN_F_BN_BLINDING_INVERT_EX, BN_R_NOT_INITIALIZED); return (0); } ret = BN_mod_mul(n, n, b->Ai, b->mod, ctx); } bn_check_top(n); return (ret); } #ifndef OPENSSL_NO_DEPRECATED unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *b) { return b->thread_id; } void BN_BLINDING_set_thread_id(BN_BLINDING *b, unsigned long n) { b->thread_id = n; } #endif CRYPTO_THREADID * BN_BLINDING_thread_id(BN_BLINDING *b) { return &b->tid; } unsigned long BN_BLINDING_get_flags(const BN_BLINDING *b) { return b->flags; } void BN_BLINDING_set_flags(BN_BLINDING *b, unsigned long flags) { b->flags = flags; } BN_BLINDING * BN_BLINDING_create_param(BN_BLINDING *b, const BIGNUM *e, BIGNUM *m, BN_CTX *ctx, int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), BN_MONT_CTX *m_ctx) { int retry_counter = 32; BN_BLINDING *ret = NULL; if (b == NULL) ret = BN_BLINDING_new(NULL, NULL, m); else ret = b; if (ret == NULL) goto err; if (ret->A == NULL && (ret->A = BN_new()) == NULL) goto err; if (ret->Ai == NULL && (ret->Ai = BN_new()) == NULL) goto err; if (e != NULL) { if (ret->e != NULL) BN_free(ret->e); ret->e = BN_dup(e); } if (ret->e == NULL) goto err; if (bn_mod_exp != NULL) ret->bn_mod_exp = bn_mod_exp; if (m_ctx != NULL) ret->m_ctx = m_ctx; do { if (!BN_rand_range(ret->A, ret->mod)) goto err; if (BN_mod_inverse(ret->Ai, ret->A, ret->mod, ctx) == NULL) { /* this should almost never happen for good RSA keys */ unsigned long error = ERR_peek_last_error(); if (ERR_GET_REASON(error) == BN_R_NO_INVERSE) { if (retry_counter-- == 0) { BNerr(BN_F_BN_BLINDING_CREATE_PARAM, BN_R_TOO_MANY_ITERATIONS); goto err; } ERR_clear_error(); } else goto err; } else break; } while (1); if (ret->bn_mod_exp != NULL && ret->m_ctx != NULL) { if (!ret->bn_mod_exp(ret->A, ret->A, ret->e, ret->mod, ctx, ret->m_ctx)) goto err; } else { if (!BN_mod_exp(ret->A, ret->A, ret->e, ret->mod, ctx)) goto err; } return ret; err: if (b == NULL && ret != NULL) { BN_BLINDING_free(ret); ret = NULL; } return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_gf2m.c0000644000175000017500000007203412360020705020336 0ustar /* $OpenBSD: bn_gf2m.c,v 1.14 2014/07/10 22:45:56 jsing Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * The Elliptic Curve Public-Key Crypto Library (ECC Code) included * herein is developed by SUN MICROSYSTEMS, INC., and is contributed * to the OpenSSL project. * * The ECC Code is licensed pursuant to the OpenSSL open source * license provided below. * * In addition, Sun covenants to all licensees who provide a reciprocal * covenant with respect to their own patents if any, not to sue under * current and future patent claims necessarily infringed by the making, * using, practicing, selling, offering for sale and/or otherwise * disposing of the ECC Code as delivered hereunder (or portions thereof), * provided that such covenant shall not apply: * 1) for code that a licensee deletes from the ECC Code; * 2) separates from the ECC Code; or * 3) for infringements caused by: * i) the modification of the ECC Code or * ii) the combination of the ECC Code with other software or * devices where such combination causes the infringement. * * The software is originally written by Sheueling Chang Shantz and * Douglas Stebila of Sun Microsystems Laboratories. * */ /* NOTE: This file is licensed pursuant to the OpenSSL license below * and may be modified; but after modifications, the above covenant * may no longer apply! In such cases, the corresponding paragraph * ["In addition, Sun covenants ... causes the infringement."] and * this note can be edited out; but please keep the Sun copyright * notice and attribution. */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include "bn_lcl.h" #ifndef OPENSSL_NO_EC2M /* Maximum number of iterations before BN_GF2m_mod_solve_quad_arr should fail. */ #define MAX_ITERATIONS 50 static const BN_ULONG SQR_tb[16] = { 0, 1, 4, 5, 16, 17, 20, 21, 64, 65, 68, 69, 80, 81, 84, 85 }; /* Platform-specific macros to accelerate squaring. */ #ifdef _LP64 #define SQR1(w) \ SQR_tb[(w) >> 60 & 0xF] << 56 | SQR_tb[(w) >> 56 & 0xF] << 48 | \ SQR_tb[(w) >> 52 & 0xF] << 40 | SQR_tb[(w) >> 48 & 0xF] << 32 | \ SQR_tb[(w) >> 44 & 0xF] << 24 | SQR_tb[(w) >> 40 & 0xF] << 16 | \ SQR_tb[(w) >> 36 & 0xF] << 8 | SQR_tb[(w) >> 32 & 0xF] #define SQR0(w) \ SQR_tb[(w) >> 28 & 0xF] << 56 | SQR_tb[(w) >> 24 & 0xF] << 48 | \ SQR_tb[(w) >> 20 & 0xF] << 40 | SQR_tb[(w) >> 16 & 0xF] << 32 | \ SQR_tb[(w) >> 12 & 0xF] << 24 | SQR_tb[(w) >> 8 & 0xF] << 16 | \ SQR_tb[(w) >> 4 & 0xF] << 8 | SQR_tb[(w) & 0xF] #else #define SQR1(w) \ SQR_tb[(w) >> 28 & 0xF] << 24 | SQR_tb[(w) >> 24 & 0xF] << 16 | \ SQR_tb[(w) >> 20 & 0xF] << 8 | SQR_tb[(w) >> 16 & 0xF] #define SQR0(w) \ SQR_tb[(w) >> 12 & 0xF] << 24 | SQR_tb[(w) >> 8 & 0xF] << 16 | \ SQR_tb[(w) >> 4 & 0xF] << 8 | SQR_tb[(w) & 0xF] #endif #if !defined(OPENSSL_BN_ASM_GF2m) /* Product of two polynomials a, b each with degree < BN_BITS2 - 1, * result is a polynomial r with degree < 2 * BN_BITS - 1 * The caller MUST ensure that the variables have the right amount * of space allocated. */ static void bn_GF2m_mul_1x1(BN_ULONG *r1, BN_ULONG *r0, const BN_ULONG a, const BN_ULONG b) { #ifndef _LP64 register BN_ULONG h, l, s; BN_ULONG tab[8], top2b = a >> 30; register BN_ULONG a1, a2, a4; a1 = a & (0x3FFFFFFF); a2 = a1 << 1; a4 = a2 << 1; tab[0] = 0; tab[1] = a1; tab[2] = a2; tab[3] = a1 ^ a2; tab[4] = a4; tab[5] = a1 ^ a4; tab[6] = a2 ^ a4; tab[7] = a1 ^ a2 ^ a4; s = tab[b & 0x7]; l = s; s = tab[b >> 3 & 0x7]; l ^= s << 3; h = s >> 29; s = tab[b >> 6 & 0x7]; l ^= s << 6; h ^= s >> 26; s = tab[b >> 9 & 0x7]; l ^= s << 9; h ^= s >> 23; s = tab[b >> 12 & 0x7]; l ^= s << 12; h ^= s >> 20; s = tab[b >> 15 & 0x7]; l ^= s << 15; h ^= s >> 17; s = tab[b >> 18 & 0x7]; l ^= s << 18; h ^= s >> 14; s = tab[b >> 21 & 0x7]; l ^= s << 21; h ^= s >> 11; s = tab[b >> 24 & 0x7]; l ^= s << 24; h ^= s >> 8; s = tab[b >> 27 & 0x7]; l ^= s << 27; h ^= s >> 5; s = tab[b >> 30]; l ^= s << 30; h ^= s >> 2; /* compensate for the top two bits of a */ if (top2b & 01) { l ^= b << 30; h ^= b >> 2; } if (top2b & 02) { l ^= b << 31; h ^= b >> 1; } *r1 = h; *r0 = l; #else register BN_ULONG h, l, s; BN_ULONG tab[16], top3b = a >> 61; register BN_ULONG a1, a2, a4, a8; a1 = a & (0x1FFFFFFFFFFFFFFFULL); a2 = a1 << 1; a4 = a2 << 1; a8 = a4 << 1; tab[0] = 0; tab[1] = a1; tab[2] = a2; tab[3] = a1 ^ a2; tab[4] = a4; tab[5] = a1 ^ a4; tab[6] = a2 ^ a4; tab[7] = a1 ^ a2 ^ a4; tab[8] = a8; tab[9] = a1 ^ a8; tab[10] = a2 ^ a8; tab[11] = a1 ^ a2 ^ a8; tab[12] = a4 ^ a8; tab[13] = a1 ^ a4 ^ a8; tab[14] = a2 ^ a4 ^ a8; tab[15] = a1 ^ a2 ^ a4 ^ a8; s = tab[b & 0xF]; l = s; s = tab[b >> 4 & 0xF]; l ^= s << 4; h = s >> 60; s = tab[b >> 8 & 0xF]; l ^= s << 8; h ^= s >> 56; s = tab[b >> 12 & 0xF]; l ^= s << 12; h ^= s >> 52; s = tab[b >> 16 & 0xF]; l ^= s << 16; h ^= s >> 48; s = tab[b >> 20 & 0xF]; l ^= s << 20; h ^= s >> 44; s = tab[b >> 24 & 0xF]; l ^= s << 24; h ^= s >> 40; s = tab[b >> 28 & 0xF]; l ^= s << 28; h ^= s >> 36; s = tab[b >> 32 & 0xF]; l ^= s << 32; h ^= s >> 32; s = tab[b >> 36 & 0xF]; l ^= s << 36; h ^= s >> 28; s = tab[b >> 40 & 0xF]; l ^= s << 40; h ^= s >> 24; s = tab[b >> 44 & 0xF]; l ^= s << 44; h ^= s >> 20; s = tab[b >> 48 & 0xF]; l ^= s << 48; h ^= s >> 16; s = tab[b >> 52 & 0xF]; l ^= s << 52; h ^= s >> 12; s = tab[b >> 56 & 0xF]; l ^= s << 56; h ^= s >> 8; s = tab[b >> 60]; l ^= s << 60; h ^= s >> 4; /* compensate for the top three bits of a */ if (top3b & 01) { l ^= b << 61; h ^= b >> 3; } if (top3b & 02) { l ^= b << 62; h ^= b >> 2; } if (top3b & 04) { l ^= b << 63; h ^= b >> 1; } *r1 = h; *r0 = l; #endif } /* Product of two polynomials a, b each with degree < 2 * BN_BITS2 - 1, * result is a polynomial r with degree < 4 * BN_BITS2 - 1 * The caller MUST ensure that the variables have the right amount * of space allocated. */ static void bn_GF2m_mul_2x2(BN_ULONG *r, const BN_ULONG a1, const BN_ULONG a0, const BN_ULONG b1, const BN_ULONG b0) { BN_ULONG m1, m0; /* r[3] = h1, r[2] = h0; r[1] = l1; r[0] = l0 */ bn_GF2m_mul_1x1(r + 3, r + 2, a1, b1); bn_GF2m_mul_1x1(r + 1, r, a0, b0); bn_GF2m_mul_1x1(&m1, &m0, a0 ^ a1, b0 ^ b1); /* Correction on m1 ^= l1 ^ h1; m0 ^= l0 ^ h0; */ r[2] ^= m1 ^ r[1] ^ r[3]; /* h0 ^= m1 ^ l1 ^ h1; */ r[1] = r[3] ^ r[2] ^ r[0] ^ m1 ^ m0; /* l1 ^= l0 ^ h0 ^ m0; */ } #else void bn_GF2m_mul_2x2(BN_ULONG *r, BN_ULONG a1, BN_ULONG a0, BN_ULONG b1, BN_ULONG b0); #endif /* Add polynomials a and b and store result in r; r could be a or b, a and b * could be equal; r is the bitwise XOR of a and b. */ int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) { int i; const BIGNUM *at, *bt; bn_check_top(a); bn_check_top(b); if (a->top < b->top) { at = b; bt = a; } else { at = a; bt = b; } if (bn_wexpand(r, at->top) == NULL) return 0; for (i = 0; i < bt->top; i++) { r->d[i] = at->d[i] ^ bt->d[i]; } for (; i < at->top; i++) { r->d[i] = at->d[i]; } r->top = at->top; bn_correct_top(r); return 1; } /* Some functions allow for representation of the irreducible polynomials * as an int[], say p. The irreducible f(t) is then of the form: * t^p[0] + t^p[1] + ... + t^p[k] * where m = p[0] > p[1] > ... > p[k] = 0. */ /* Performs modular reduction of a and store result in r. r could be a. */ int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]) { int j, k; int n, dN, d0, d1; BN_ULONG zz, *z; bn_check_top(a); if (!p[0]) { /* reduction mod 1 => return 0 */ BN_zero(r); return 1; } /* Since the algorithm does reduction in the r value, if a != r, copy * the contents of a into r so we can do reduction in r. */ if (a != r) { if (!bn_wexpand(r, a->top)) return 0; for (j = 0; j < a->top; j++) { r->d[j] = a->d[j]; } r->top = a->top; } z = r->d; /* start reduction */ dN = p[0] / BN_BITS2; for (j = r->top - 1; j > dN; ) { zz = z[j]; if (z[j] == 0) { j--; continue; } z[j] = 0; for (k = 1; p[k] != 0; k++) { /* reducing component t^p[k] */ n = p[0] - p[k]; d0 = n % BN_BITS2; d1 = BN_BITS2 - d0; n /= BN_BITS2; z[j - n] ^= (zz >> d0); if (d0) z[j - n - 1] ^= (zz << d1); } /* reducing component t^0 */ n = dN; d0 = p[0] % BN_BITS2; d1 = BN_BITS2 - d0; z[j - n] ^= (zz >> d0); if (d0) z[j - n - 1] ^= (zz << d1); } /* final round of reduction */ while (j == dN) { d0 = p[0] % BN_BITS2; zz = z[dN] >> d0; if (zz == 0) break; d1 = BN_BITS2 - d0; /* clear up the top d1 bits */ if (d0) z[dN] = (z[dN] << d1) >> d1; else z[dN] = 0; z[0] ^= zz; /* reduction t^0 component */ for (k = 1; p[k] != 0; k++) { BN_ULONG tmp_ulong; /* reducing component t^p[k]*/ n = p[k] / BN_BITS2; d0 = p[k] % BN_BITS2; d1 = BN_BITS2 - d0; z[n] ^= (zz << d0); tmp_ulong = zz >> d1; if (d0 && tmp_ulong) z[n + 1] ^= tmp_ulong; } } bn_correct_top(r); return 1; } /* Performs modular reduction of a by p and store result in r. r could be a. * * This function calls down to the BN_GF2m_mod_arr implementation; this wrapper * function is only provided for convenience; for best performance, use the * BN_GF2m_mod_arr function. */ int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p) { int ret = 0; int arr[6]; bn_check_top(a); bn_check_top(p); ret = BN_GF2m_poly2arr(p, arr, sizeof(arr) / sizeof(arr[0])); if (!ret || ret > (int)(sizeof(arr) / sizeof(arr[0]))) { BNerr(BN_F_BN_GF2M_MOD, BN_R_INVALID_LENGTH); return 0; } ret = BN_GF2m_mod_arr(r, a, arr); bn_check_top(r); return ret; } /* Compute the product of two polynomials a and b, reduce modulo p, and store * the result in r. r could be a or b; a could be b. */ int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const int p[], BN_CTX *ctx) { int zlen, i, j, k, ret = 0; BIGNUM *s; BN_ULONG x1, x0, y1, y0, zz[4]; bn_check_top(a); bn_check_top(b); if (a == b) { return BN_GF2m_mod_sqr_arr(r, a, p, ctx); } BN_CTX_start(ctx); if ((s = BN_CTX_get(ctx)) == NULL) goto err; zlen = a->top + b->top + 4; if (!bn_wexpand(s, zlen)) goto err; s->top = zlen; for (i = 0; i < zlen; i++) s->d[i] = 0; for (j = 0; j < b->top; j += 2) { y0 = b->d[j]; y1 = ((j + 1) == b->top) ? 0 : b->d[j + 1]; for (i = 0; i < a->top; i += 2) { x0 = a->d[i]; x1 = ((i + 1) == a->top) ? 0 : a->d[i + 1]; bn_GF2m_mul_2x2(zz, x1, x0, y1, y0); for (k = 0; k < 4; k++) s->d[i + j + k] ^= zz[k]; } } bn_correct_top(s); if (BN_GF2m_mod_arr(r, s, p)) ret = 1; bn_check_top(r); err: BN_CTX_end(ctx); return ret; } /* Compute the product of two polynomials a and b, reduce modulo p, and store * the result in r. r could be a or b; a could equal b. * * This function calls down to the BN_GF2m_mod_mul_arr implementation; this wrapper * function is only provided for convenience; for best performance, use the * BN_GF2m_mod_mul_arr function. */ int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx) { int ret = 0; const int max = BN_num_bits(p) + 1; int *arr = NULL; bn_check_top(a); bn_check_top(b); bn_check_top(p); if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { BNerr(BN_F_BN_GF2M_MOD_MUL, BN_R_INVALID_LENGTH); goto err; } ret = BN_GF2m_mod_mul_arr(r, a, b, arr, ctx); bn_check_top(r); err: free(arr); return ret; } /* Square a, reduce the result mod p, and store it in a. r could be a. */ int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[], BN_CTX *ctx) { int i, ret = 0; BIGNUM *s; bn_check_top(a); BN_CTX_start(ctx); if ((s = BN_CTX_get(ctx)) == NULL) return 0; if (!bn_wexpand(s, 2 * a->top)) goto err; for (i = a->top - 1; i >= 0; i--) { s->d[2 * i + 1] = SQR1(a->d[i]); s->d[2 * i] = SQR0(a->d[i]); } s->top = 2 * a->top; bn_correct_top(s); if (!BN_GF2m_mod_arr(r, s, p)) goto err; bn_check_top(r); ret = 1; err: BN_CTX_end(ctx); return ret; } /* Square a, reduce the result mod p, and store it in a. r could be a. * * This function calls down to the BN_GF2m_mod_sqr_arr implementation; this wrapper * function is only provided for convenience; for best performance, use the * BN_GF2m_mod_sqr_arr function. */ int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) { int ret = 0; const int max = BN_num_bits(p) + 1; int *arr = NULL; bn_check_top(a); bn_check_top(p); if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { BNerr(BN_F_BN_GF2M_MOD_SQR, BN_R_INVALID_LENGTH); goto err; } ret = BN_GF2m_mod_sqr_arr(r, a, arr, ctx); bn_check_top(r); err: free(arr); return ret; } /* Invert a, reduce modulo p, and store the result in r. r could be a. * Uses Modified Almost Inverse Algorithm (Algorithm 10) from * Hankerson, D., Hernandez, J.L., and Menezes, A. "Software Implementation * of Elliptic Curve Cryptography Over Binary Fields". */ int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) { BIGNUM *b, *c = NULL, *u = NULL, *v = NULL, *tmp; int ret = 0; bn_check_top(a); bn_check_top(p); BN_CTX_start(ctx); if ((b = BN_CTX_get(ctx)) == NULL) goto err; if ((c = BN_CTX_get(ctx)) == NULL) goto err; if ((u = BN_CTX_get(ctx)) == NULL) goto err; if ((v = BN_CTX_get(ctx)) == NULL) goto err; if (!BN_GF2m_mod(u, a, p)) goto err; if (BN_is_zero(u)) goto err; if (!BN_copy(v, p)) goto err; #if 0 if (!BN_one(b)) goto err; while (1) { while (!BN_is_odd(u)) { if (BN_is_zero(u)) goto err; if (!BN_rshift1(u, u)) goto err; if (BN_is_odd(b)) { if (!BN_GF2m_add(b, b, p)) goto err; } if (!BN_rshift1(b, b)) goto err; } if (BN_abs_is_word(u, 1)) break; if (BN_num_bits(u) < BN_num_bits(v)) { tmp = u; u = v; v = tmp; tmp = b; b = c; c = tmp; } if (!BN_GF2m_add(u, u, v)) goto err; if (!BN_GF2m_add(b, b, c)) goto err; } #else { int i, ubits = BN_num_bits(u), vbits = BN_num_bits(v), /* v is copy of p */ top = p->top; BN_ULONG *udp, *bdp, *vdp, *cdp; bn_wexpand(u, top); udp = u->d; for (i = u->top; i < top; i++) udp[i] = 0; u->top = top; bn_wexpand(b, top); bdp = b->d; bdp[0] = 1; for (i = 1; i < top; i++) bdp[i] = 0; b->top = top; bn_wexpand(c, top); cdp = c->d; for (i = 0; i < top; i++) cdp[i] = 0; c->top = top; vdp = v->d; /* It pays off to "cache" *->d pointers, because * it allows optimizer to be more aggressive. * But we don't have to "cache" p->d, because *p * is declared 'const'... */ while (1) { while (ubits && !(udp[0]&1)) { BN_ULONG u0, u1, b0, b1, mask; u0 = udp[0]; b0 = bdp[0]; mask = (BN_ULONG)0 - (b0 & 1); b0 ^= p->d[0] & mask; for (i = 0; i < top - 1; i++) { u1 = udp[i + 1]; udp[i] = ((u0 >> 1) | (u1 << (BN_BITS2 - 1))) & BN_MASK2; u0 = u1; b1 = bdp[i + 1] ^ (p->d[i + 1] & mask); bdp[i] = ((b0 >> 1) | (b1 << (BN_BITS2 - 1))) & BN_MASK2; b0 = b1; } udp[i] = u0 >> 1; bdp[i] = b0 >> 1; ubits--; } if (ubits <= BN_BITS2 && udp[0] == 1) break; if (ubits < vbits) { i = ubits; ubits = vbits; vbits = i; tmp = u; u = v; v = tmp; tmp = b; b = c; c = tmp; udp = vdp; vdp = v->d; bdp = cdp; cdp = c->d; } for (i = 0; i < top; i++) { udp[i] ^= vdp[i]; bdp[i] ^= cdp[i]; } if (ubits == vbits) { BN_ULONG ul; int utop = (ubits - 1) / BN_BITS2; while ((ul = udp[utop]) == 0 && utop) utop--; ubits = utop*BN_BITS2 + BN_num_bits_word(ul); } } bn_correct_top(b); } #endif if (!BN_copy(r, b)) goto err; bn_check_top(r); ret = 1; err: #ifdef BN_DEBUG /* BN_CTX_end would complain about the expanded form */ bn_correct_top(c); bn_correct_top(u); bn_correct_top(v); #endif BN_CTX_end(ctx); return ret; } /* Invert xx, reduce modulo p, and store the result in r. r could be xx. * * This function calls down to the BN_GF2m_mod_inv implementation; this wrapper * function is only provided for convenience; for best performance, use the * BN_GF2m_mod_inv function. */ int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *xx, const int p[], BN_CTX *ctx) { BIGNUM *field; int ret = 0; bn_check_top(xx); BN_CTX_start(ctx); if ((field = BN_CTX_get(ctx)) == NULL) goto err; if (!BN_GF2m_arr2poly(p, field)) goto err; ret = BN_GF2m_mod_inv(r, xx, field, ctx); bn_check_top(r); err: BN_CTX_end(ctx); return ret; } #ifndef OPENSSL_SUN_GF2M_DIV /* Divide y by x, reduce modulo p, and store the result in r. r could be x * or y, x could equal y. */ int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x, const BIGNUM *p, BN_CTX *ctx) { BIGNUM *xinv = NULL; int ret = 0; bn_check_top(y); bn_check_top(x); bn_check_top(p); BN_CTX_start(ctx); xinv = BN_CTX_get(ctx); if (xinv == NULL) goto err; if (!BN_GF2m_mod_inv(xinv, x, p, ctx)) goto err; if (!BN_GF2m_mod_mul(r, y, xinv, p, ctx)) goto err; bn_check_top(r); ret = 1; err: BN_CTX_end(ctx); return ret; } #else /* Divide y by x, reduce modulo p, and store the result in r. r could be x * or y, x could equal y. * Uses algorithm Modular_Division_GF(2^m) from * Chang-Shantz, S. "From Euclid's GCD to Montgomery Multiplication to * the Great Divide". */ int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x, const BIGNUM *p, BN_CTX *ctx) { BIGNUM *a, *b, *u, *v; int ret = 0; bn_check_top(y); bn_check_top(x); bn_check_top(p); BN_CTX_start(ctx); a = BN_CTX_get(ctx); b = BN_CTX_get(ctx); u = BN_CTX_get(ctx); v = BN_CTX_get(ctx); if (v == NULL) goto err; /* reduce x and y mod p */ if (!BN_GF2m_mod(u, y, p)) goto err; if (!BN_GF2m_mod(a, x, p)) goto err; if (!BN_copy(b, p)) goto err; while (!BN_is_odd(a)) { if (!BN_rshift1(a, a)) goto err; if (BN_is_odd(u)) if (!BN_GF2m_add(u, u, p)) goto err; if (!BN_rshift1(u, u)) goto err; } do { if (BN_GF2m_cmp(b, a) > 0) { if (!BN_GF2m_add(b, b, a)) goto err; if (!BN_GF2m_add(v, v, u)) goto err; do { if (!BN_rshift1(b, b)) goto err; if (BN_is_odd(v)) if (!BN_GF2m_add(v, v, p)) goto err; if (!BN_rshift1(v, v)) goto err; } while (!BN_is_odd(b)); } else if (BN_abs_is_word(a, 1)) break; else { if (!BN_GF2m_add(a, a, b)) goto err; if (!BN_GF2m_add(u, u, v)) goto err; do { if (!BN_rshift1(a, a)) goto err; if (BN_is_odd(u)) if (!BN_GF2m_add(u, u, p)) goto err; if (!BN_rshift1(u, u)) goto err; } while (!BN_is_odd(a)); } } while (1); if (!BN_copy(r, u)) goto err; bn_check_top(r); ret = 1; err: BN_CTX_end(ctx); return ret; } #endif /* Divide yy by xx, reduce modulo p, and store the result in r. r could be xx * or yy, xx could equal yy. * * This function calls down to the BN_GF2m_mod_div implementation; this wrapper * function is only provided for convenience; for best performance, use the * BN_GF2m_mod_div function. */ int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *yy, const BIGNUM *xx, const int p[], BN_CTX *ctx) { BIGNUM *field; int ret = 0; bn_check_top(yy); bn_check_top(xx); BN_CTX_start(ctx); if ((field = BN_CTX_get(ctx)) == NULL) goto err; if (!BN_GF2m_arr2poly(p, field)) goto err; ret = BN_GF2m_mod_div(r, yy, xx, field, ctx); bn_check_top(r); err: BN_CTX_end(ctx); return ret; } /* Compute the bth power of a, reduce modulo p, and store * the result in r. r could be a. * Uses simple square-and-multiply algorithm A.5.1 from IEEE P1363. */ int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const int p[], BN_CTX *ctx) { int ret = 0, i, n; BIGNUM *u; bn_check_top(a); bn_check_top(b); if (BN_is_zero(b)) return (BN_one(r)); if (BN_abs_is_word(b, 1)) return (BN_copy(r, a) != NULL); BN_CTX_start(ctx); if ((u = BN_CTX_get(ctx)) == NULL) goto err; if (!BN_GF2m_mod_arr(u, a, p)) goto err; n = BN_num_bits(b) - 1; for (i = n - 1; i >= 0; i--) { if (!BN_GF2m_mod_sqr_arr(u, u, p, ctx)) goto err; if (BN_is_bit_set(b, i)) { if (!BN_GF2m_mod_mul_arr(u, u, a, p, ctx)) goto err; } } if (!BN_copy(r, u)) goto err; bn_check_top(r); ret = 1; err: BN_CTX_end(ctx); return ret; } /* Compute the bth power of a, reduce modulo p, and store * the result in r. r could be a. * * This function calls down to the BN_GF2m_mod_exp_arr implementation; this wrapper * function is only provided for convenience; for best performance, use the * BN_GF2m_mod_exp_arr function. */ int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx) { int ret = 0; const int max = BN_num_bits(p) + 1; int *arr = NULL; bn_check_top(a); bn_check_top(b); bn_check_top(p); if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { BNerr(BN_F_BN_GF2M_MOD_EXP, BN_R_INVALID_LENGTH); goto err; } ret = BN_GF2m_mod_exp_arr(r, a, b, arr, ctx); bn_check_top(r); err: free(arr); return ret; } /* Compute the square root of a, reduce modulo p, and store * the result in r. r could be a. * Uses exponentiation as in algorithm A.4.1 from IEEE P1363. */ int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, const int p[], BN_CTX *ctx) { int ret = 0; BIGNUM *u; bn_check_top(a); if (!p[0]) { /* reduction mod 1 => return 0 */ BN_zero(r); return 1; } BN_CTX_start(ctx); if ((u = BN_CTX_get(ctx)) == NULL) goto err; if (!BN_set_bit(u, p[0] - 1)) goto err; ret = BN_GF2m_mod_exp_arr(r, a, u, p, ctx); bn_check_top(r); err: BN_CTX_end(ctx); return ret; } /* Compute the square root of a, reduce modulo p, and store * the result in r. r could be a. * * This function calls down to the BN_GF2m_mod_sqrt_arr implementation; this wrapper * function is only provided for convenience; for best performance, use the * BN_GF2m_mod_sqrt_arr function. */ int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) { int ret = 0; const int max = BN_num_bits(p) + 1; int *arr = NULL; bn_check_top(a); bn_check_top(p); if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { BNerr(BN_F_BN_GF2M_MOD_SQRT, BN_R_INVALID_LENGTH); goto err; } ret = BN_GF2m_mod_sqrt_arr(r, a, arr, ctx); bn_check_top(r); err: free(arr); return ret; } /* Find r such that r^2 + r = a mod p. r could be a. If no r exists returns 0. * Uses algorithms A.4.7 and A.4.6 from IEEE P1363. */ int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a_, const int p[], BN_CTX *ctx) { int ret = 0, count = 0, j; BIGNUM *a, *z, *rho, *w, *w2, *tmp; bn_check_top(a_); if (!p[0]) { /* reduction mod 1 => return 0 */ BN_zero(r); return 1; } BN_CTX_start(ctx); a = BN_CTX_get(ctx); z = BN_CTX_get(ctx); w = BN_CTX_get(ctx); if (w == NULL) goto err; if (!BN_GF2m_mod_arr(a, a_, p)) goto err; if (BN_is_zero(a)) { BN_zero(r); ret = 1; goto err; } if (p[0] & 0x1) /* m is odd */ { /* compute half-trace of a */ if (!BN_copy(z, a)) goto err; for (j = 1; j <= (p[0] - 1) / 2; j++) { if (!BN_GF2m_mod_sqr_arr(z, z, p, ctx)) goto err; if (!BN_GF2m_mod_sqr_arr(z, z, p, ctx)) goto err; if (!BN_GF2m_add(z, z, a)) goto err; } } else /* m is even */ { rho = BN_CTX_get(ctx); w2 = BN_CTX_get(ctx); tmp = BN_CTX_get(ctx); if (tmp == NULL) goto err; do { if (!BN_rand(rho, p[0], 0, 0)) goto err; if (!BN_GF2m_mod_arr(rho, rho, p)) goto err; BN_zero(z); if (!BN_copy(w, rho)) goto err; for (j = 1; j <= p[0] - 1; j++) { if (!BN_GF2m_mod_sqr_arr(z, z, p, ctx)) goto err; if (!BN_GF2m_mod_sqr_arr(w2, w, p, ctx)) goto err; if (!BN_GF2m_mod_mul_arr(tmp, w2, a, p, ctx)) goto err; if (!BN_GF2m_add(z, z, tmp)) goto err; if (!BN_GF2m_add(w, w2, rho)) goto err; } count++; } while (BN_is_zero(w) && (count < MAX_ITERATIONS)); if (BN_is_zero(w)) { BNerr(BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR, BN_R_TOO_MANY_ITERATIONS); goto err; } } if (!BN_GF2m_mod_sqr_arr(w, z, p, ctx)) goto err; if (!BN_GF2m_add(w, z, w)) goto err; if (BN_GF2m_cmp(w, a)) { BNerr(BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR, BN_R_NO_SOLUTION); goto err; } if (!BN_copy(r, z)) goto err; bn_check_top(r); ret = 1; err: BN_CTX_end(ctx); return ret; } /* Find r such that r^2 + r = a mod p. r could be a. If no r exists returns 0. * * This function calls down to the BN_GF2m_mod_solve_quad_arr implementation; this wrapper * function is only provided for convenience; for best performance, use the * BN_GF2m_mod_solve_quad_arr function. */ int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) { int ret = 0; const int max = BN_num_bits(p) + 1; int *arr = NULL; bn_check_top(a); bn_check_top(p); if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { BNerr(BN_F_BN_GF2M_MOD_SOLVE_QUAD, BN_R_INVALID_LENGTH); goto err; } ret = BN_GF2m_mod_solve_quad_arr(r, a, arr, ctx); bn_check_top(r); err: free(arr); return ret; } /* Convert the bit-string representation of a polynomial * ( \sum_{i=0}^n a_i * x^i) into an array of integers corresponding * to the bits with non-zero coefficient. Array is terminated with -1. * Up to max elements of the array will be filled. Return value is total * number of array elements that would be filled if array was large enough. */ int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max) { int i, j, k = 0; BN_ULONG mask; if (BN_is_zero(a)) return 0; for (i = a->top - 1; i >= 0; i--) { if (!a->d[i]) /* skip word if a->d[i] == 0 */ continue; mask = BN_TBIT; for (j = BN_BITS2 - 1; j >= 0; j--) { if (a->d[i] & mask) { if (k < max) p[k] = BN_BITS2 * i + j; k++; } mask >>= 1; } } if (k < max) { p[k] = -1; k++; } return k; } /* Convert the coefficient array representation of a polynomial to a * bit-string. The array must be terminated by -1. */ int BN_GF2m_arr2poly(const int p[], BIGNUM *a) { int i; bn_check_top(a); BN_zero(a); for (i = 0; p[i] != -1; i++) { if (BN_set_bit(a, p[i]) == 0) return 0; } bn_check_top(a); return 1; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_mpi.c0000644000175000017500000001061412360020705020264 0ustar /* $OpenBSD: bn_mpi.c,v 1.6 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include "bn_lcl.h" int BN_bn2mpi(const BIGNUM *a, unsigned char *d) { int bits; int num = 0; int ext = 0; long l; bits = BN_num_bits(a); num = (bits + 7) / 8; if (bits > 0) { ext = ((bits & 0x07) == 0); } if (d == NULL) return (num + 4 + ext); l = num + ext; d[0] = (unsigned char)(l >> 24) & 0xff; d[1] = (unsigned char)(l >> 16) & 0xff; d[2] = (unsigned char)(l >> 8) & 0xff; d[3] = (unsigned char)(l) & 0xff; if (ext) d[4] = 0; num = BN_bn2bin(a, &(d[4 + ext])); if (a->neg) d[4] |= 0x80; return (num + 4 + ext); } BIGNUM * BN_mpi2bn(const unsigned char *d, int n, BIGNUM *a) { long len; int neg = 0; if (n < 4) { BNerr(BN_F_BN_MPI2BN, BN_R_INVALID_LENGTH); return (NULL); } len = ((long)d[0] << 24) | ((long)d[1] << 16) | ((int)d[2] << 8) | (int)d[3]; if ((len + 4) != n) { BNerr(BN_F_BN_MPI2BN, BN_R_ENCODING_ERROR); return (NULL); } if (a == NULL) a = BN_new(); if (a == NULL) return (NULL); if (len == 0) { a->neg = 0; a->top = 0; return (a); } d += 4; if ((*d) & 0x80) neg = 1; if (BN_bin2bn(d, (int)len, a) == NULL) return (NULL); a->neg = neg; if (neg) { BN_clear_bit(a, BN_num_bits(a) - 1); } bn_check_top(a); return (a); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_const.c0000644000175000017500000005623712360020705020640 0ustar /* $OpenBSD$ */ /* Insert boilerplate */ #include /* "First Oakley Default Group" from RFC2409, section 6.1. * * The prime is: 2^768 - 2 ^704 - 1 + 2^64 * { [2^638 pi] + 149686 } * * RFC2409 specifies a generator of 2. * RFC2412 specifies a generator of of 22. */ BIGNUM * get_rfc2409_prime_768(BIGNUM *bn) { static const unsigned char RFC2409_PRIME_768[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x3A, 0x36, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }; return BN_bin2bn(RFC2409_PRIME_768, sizeof(RFC2409_PRIME_768), bn); } /* "Second Oakley Default Group" from RFC2409, section 6.2. * * The prime is: 2^1024 - 2^960 - 1 + 2^64 * { [2^894 pi] + 129093 }. * * RFC2409 specifies a generator of 2. * RFC2412 specifies a generator of 22. */ BIGNUM * get_rfc2409_prime_1024(BIGNUM *bn) { static const unsigned char RFC2409_PRIME_1024[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE6, 0x53, 0x81, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }; return BN_bin2bn(RFC2409_PRIME_1024, sizeof(RFC2409_PRIME_1024), bn); } /* "1536-bit MODP Group" from RFC3526, Section 2. * * The prime is: 2^1536 - 2^1472 - 1 + 2^64 * { [2^1406 pi] + 741804 } * * RFC3526 specifies a generator of 2. * RFC2312 specifies a generator of 22. */ BIGNUM * get_rfc3526_prime_1536(BIGNUM *bn) { static const unsigned char RFC3526_PRIME_1536[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x23, 0x73, 0x27, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }; return BN_bin2bn(RFC3526_PRIME_1536, sizeof(RFC3526_PRIME_1536), bn); } /* "2048-bit MODP Group" from RFC3526, Section 3. * * The prime is: 2^2048 - 2^1984 - 1 + 2^64 * { [2^1918 pi] + 124476 } * * RFC3526 specifies a generator of 2. */ BIGNUM * get_rfc3526_prime_2048(BIGNUM *bn) { static const unsigned char RFC3526_PRIME_2048[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, 0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C, 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAC, 0xAA, 0x68, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }; return BN_bin2bn(RFC3526_PRIME_2048, sizeof(RFC3526_PRIME_2048), bn); } /* "3072-bit MODP Group" from RFC3526, Section 4. * * The prime is: 2^3072 - 2^3008 - 1 + 2^64 * { [2^2942 pi] + 1690314 } * * RFC3526 specifies a generator of 2. */ BIGNUM * get_rfc3526_prime_3072(BIGNUM *bn) { static const unsigned char RFC3526_PRIME_3072[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, 0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C, 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, 0xAD, 0x33, 0x17, 0x0D, 0x04, 0x50, 0x7A, 0x33, 0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A, 0x8A, 0xEA, 0x71, 0x57, 0x5D, 0x06, 0x0C, 0x7D, 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7, 0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, 0x1E, 0x8C, 0x94, 0xE0, 0x4A, 0x25, 0x61, 0x9D, 0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64, 0xD8, 0x76, 0x02, 0x73, 0x3E, 0xC8, 0x6A, 0x64, 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C, 0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, 0x77, 0x09, 0x88, 0xC0, 0xBA, 0xD9, 0x46, 0xE2, 0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E, 0x4B, 0x82, 0xD1, 0x20, 0xA9, 0x3A, 0xD2, 0xCA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }; return BN_bin2bn(RFC3526_PRIME_3072, sizeof(RFC3526_PRIME_3072), bn); } /* "4096-bit MODP Group" from RFC3526, Section 5. * * The prime is: 2^4096 - 2^4032 - 1 + 2^64 * { [2^3966 pi] + 240904 } * * RFC3526 specifies a generator of 2. */ BIGNUM * get_rfc3526_prime_4096(BIGNUM *bn) { static const unsigned char RFC3526_PRIME_4096[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, 0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C, 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, 0xAD, 0x33, 0x17, 0x0D, 0x04, 0x50, 0x7A, 0x33, 0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A, 0x8A, 0xEA, 0x71, 0x57, 0x5D, 0x06, 0x0C, 0x7D, 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7, 0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, 0x1E, 0x8C, 0x94, 0xE0, 0x4A, 0x25, 0x61, 0x9D, 0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64, 0xD8, 0x76, 0x02, 0x73, 0x3E, 0xC8, 0x6A, 0x64, 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C, 0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, 0x77, 0x09, 0x88, 0xC0, 0xBA, 0xD9, 0x46, 0xE2, 0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E, 0x4B, 0x82, 0xD1, 0x20, 0xA9, 0x21, 0x08, 0x01, 0x1A, 0x72, 0x3C, 0x12, 0xA7, 0x87, 0xE6, 0xD7, 0x88, 0x71, 0x9A, 0x10, 0xBD, 0xBA, 0x5B, 0x26, 0x99, 0xC3, 0x27, 0x18, 0x6A, 0xF4, 0xE2, 0x3C, 0x1A, 0x94, 0x68, 0x34, 0xB6, 0x15, 0x0B, 0xDA, 0x25, 0x83, 0xE9, 0xCA, 0x2A, 0xD4, 0x4C, 0xE8, 0xDB, 0xBB, 0xC2, 0xDB, 0x04, 0xDE, 0x8E, 0xF9, 0x2E, 0x8E, 0xFC, 0x14, 0x1F, 0xBE, 0xCA, 0xA6, 0x28, 0x7C, 0x59, 0x47, 0x4E, 0x6B, 0xC0, 0x5D, 0x99, 0xB2, 0x96, 0x4F, 0xA0, 0x90, 0xC3, 0xA2, 0x23, 0x3B, 0xA1, 0x86, 0x51, 0x5B, 0xE7, 0xED, 0x1F, 0x61, 0x29, 0x70, 0xCE, 0xE2, 0xD7, 0xAF, 0xB8, 0x1B, 0xDD, 0x76, 0x21, 0x70, 0x48, 0x1C, 0xD0, 0x06, 0x91, 0x27, 0xD5, 0xB0, 0x5A, 0xA9, 0x93, 0xB4, 0xEA, 0x98, 0x8D, 0x8F, 0xDD, 0xC1, 0x86, 0xFF, 0xB7, 0xDC, 0x90, 0xA6, 0xC0, 0x8F, 0x4D, 0xF4, 0x35, 0xC9, 0x34, 0x06, 0x31, 0x99, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }; return BN_bin2bn(RFC3526_PRIME_4096, sizeof(RFC3526_PRIME_4096), bn); } /* "6144-bit MODP Group" from RFC3526, Section 6. * * The prime is: 2^6144 - 2^6080 - 1 + 2^64 * { [2^6014 pi] + 929484 } * * RFC3526 specifies a generator of 2. */ BIGNUM * get_rfc3526_prime_6144(BIGNUM *bn) { static const unsigned char RFC3526_PRIME_6144[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, 0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C, 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, 0xAD, 0x33, 0x17, 0x0D, 0x04, 0x50, 0x7A, 0x33, 0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A, 0x8A, 0xEA, 0x71, 0x57, 0x5D, 0x06, 0x0C, 0x7D, 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7, 0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, 0x1E, 0x8C, 0x94, 0xE0, 0x4A, 0x25, 0x61, 0x9D, 0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64, 0xD8, 0x76, 0x02, 0x73, 0x3E, 0xC8, 0x6A, 0x64, 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C, 0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, 0x77, 0x09, 0x88, 0xC0, 0xBA, 0xD9, 0x46, 0xE2, 0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E, 0x4B, 0x82, 0xD1, 0x20, 0xA9, 0x21, 0x08, 0x01, 0x1A, 0x72, 0x3C, 0x12, 0xA7, 0x87, 0xE6, 0xD7, 0x88, 0x71, 0x9A, 0x10, 0xBD, 0xBA, 0x5B, 0x26, 0x99, 0xC3, 0x27, 0x18, 0x6A, 0xF4, 0xE2, 0x3C, 0x1A, 0x94, 0x68, 0x34, 0xB6, 0x15, 0x0B, 0xDA, 0x25, 0x83, 0xE9, 0xCA, 0x2A, 0xD4, 0x4C, 0xE8, 0xDB, 0xBB, 0xC2, 0xDB, 0x04, 0xDE, 0x8E, 0xF9, 0x2E, 0x8E, 0xFC, 0x14, 0x1F, 0xBE, 0xCA, 0xA6, 0x28, 0x7C, 0x59, 0x47, 0x4E, 0x6B, 0xC0, 0x5D, 0x99, 0xB2, 0x96, 0x4F, 0xA0, 0x90, 0xC3, 0xA2, 0x23, 0x3B, 0xA1, 0x86, 0x51, 0x5B, 0xE7, 0xED, 0x1F, 0x61, 0x29, 0x70, 0xCE, 0xE2, 0xD7, 0xAF, 0xB8, 0x1B, 0xDD, 0x76, 0x21, 0x70, 0x48, 0x1C, 0xD0, 0x06, 0x91, 0x27, 0xD5, 0xB0, 0x5A, 0xA9, 0x93, 0xB4, 0xEA, 0x98, 0x8D, 0x8F, 0xDD, 0xC1, 0x86, 0xFF, 0xB7, 0xDC, 0x90, 0xA6, 0xC0, 0x8F, 0x4D, 0xF4, 0x35, 0xC9, 0x34, 0x02, 0x84, 0x92, 0x36, 0xC3, 0xFA, 0xB4, 0xD2, 0x7C, 0x70, 0x26, 0xC1, 0xD4, 0xDC, 0xB2, 0x60, 0x26, 0x46, 0xDE, 0xC9, 0x75, 0x1E, 0x76, 0x3D, 0xBA, 0x37, 0xBD, 0xF8, 0xFF, 0x94, 0x06, 0xAD, 0x9E, 0x53, 0x0E, 0xE5, 0xDB, 0x38, 0x2F, 0x41, 0x30, 0x01, 0xAE, 0xB0, 0x6A, 0x53, 0xED, 0x90, 0x27, 0xD8, 0x31, 0x17, 0x97, 0x27, 0xB0, 0x86, 0x5A, 0x89, 0x18, 0xDA, 0x3E, 0xDB, 0xEB, 0xCF, 0x9B, 0x14, 0xED, 0x44, 0xCE, 0x6C, 0xBA, 0xCE, 0xD4, 0xBB, 0x1B, 0xDB, 0x7F, 0x14, 0x47, 0xE6, 0xCC, 0x25, 0x4B, 0x33, 0x20, 0x51, 0x51, 0x2B, 0xD7, 0xAF, 0x42, 0x6F, 0xB8, 0xF4, 0x01, 0x37, 0x8C, 0xD2, 0xBF, 0x59, 0x83, 0xCA, 0x01, 0xC6, 0x4B, 0x92, 0xEC, 0xF0, 0x32, 0xEA, 0x15, 0xD1, 0x72, 0x1D, 0x03, 0xF4, 0x82, 0xD7, 0xCE, 0x6E, 0x74, 0xFE, 0xF6, 0xD5, 0x5E, 0x70, 0x2F, 0x46, 0x98, 0x0C, 0x82, 0xB5, 0xA8, 0x40, 0x31, 0x90, 0x0B, 0x1C, 0x9E, 0x59, 0xE7, 0xC9, 0x7F, 0xBE, 0xC7, 0xE8, 0xF3, 0x23, 0xA9, 0x7A, 0x7E, 0x36, 0xCC, 0x88, 0xBE, 0x0F, 0x1D, 0x45, 0xB7, 0xFF, 0x58, 0x5A, 0xC5, 0x4B, 0xD4, 0x07, 0xB2, 0x2B, 0x41, 0x54, 0xAA, 0xCC, 0x8F, 0x6D, 0x7E, 0xBF, 0x48, 0xE1, 0xD8, 0x14, 0xCC, 0x5E, 0xD2, 0x0F, 0x80, 0x37, 0xE0, 0xA7, 0x97, 0x15, 0xEE, 0xF2, 0x9B, 0xE3, 0x28, 0x06, 0xA1, 0xD5, 0x8B, 0xB7, 0xC5, 0xDA, 0x76, 0xF5, 0x50, 0xAA, 0x3D, 0x8A, 0x1F, 0xBF, 0xF0, 0xEB, 0x19, 0xCC, 0xB1, 0xA3, 0x13, 0xD5, 0x5C, 0xDA, 0x56, 0xC9, 0xEC, 0x2E, 0xF2, 0x96, 0x32, 0x38, 0x7F, 0xE8, 0xD7, 0x6E, 0x3C, 0x04, 0x68, 0x04, 0x3E, 0x8F, 0x66, 0x3F, 0x48, 0x60, 0xEE, 0x12, 0xBF, 0x2D, 0x5B, 0x0B, 0x74, 0x74, 0xD6, 0xE6, 0x94, 0xF9, 0x1E, 0x6D, 0xCC, 0x40, 0x24, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }; return BN_bin2bn(RFC3526_PRIME_6144, sizeof(RFC3526_PRIME_6144), bn); } /* "8192-bit MODP Group" from RFC3526, Section 7. * * The prime is: 2^8192 - 2^8128 - 1 + 2^64 * { [2^8062 pi] + 4743158 } * * RFC3526 specifies a generator of 2. */ BIGNUM * get_rfc3526_prime_8192(BIGNUM *bn) { static const unsigned char RFC3526_PRIME_8192[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, 0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C, 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, 0xAD, 0x33, 0x17, 0x0D, 0x04, 0x50, 0x7A, 0x33, 0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A, 0x8A, 0xEA, 0x71, 0x57, 0x5D, 0x06, 0x0C, 0x7D, 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7, 0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, 0x1E, 0x8C, 0x94, 0xE0, 0x4A, 0x25, 0x61, 0x9D, 0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64, 0xD8, 0x76, 0x02, 0x73, 0x3E, 0xC8, 0x6A, 0x64, 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C, 0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, 0x77, 0x09, 0x88, 0xC0, 0xBA, 0xD9, 0x46, 0xE2, 0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E, 0x4B, 0x82, 0xD1, 0x20, 0xA9, 0x21, 0x08, 0x01, 0x1A, 0x72, 0x3C, 0x12, 0xA7, 0x87, 0xE6, 0xD7, 0x88, 0x71, 0x9A, 0x10, 0xBD, 0xBA, 0x5B, 0x26, 0x99, 0xC3, 0x27, 0x18, 0x6A, 0xF4, 0xE2, 0x3C, 0x1A, 0x94, 0x68, 0x34, 0xB6, 0x15, 0x0B, 0xDA, 0x25, 0x83, 0xE9, 0xCA, 0x2A, 0xD4, 0x4C, 0xE8, 0xDB, 0xBB, 0xC2, 0xDB, 0x04, 0xDE, 0x8E, 0xF9, 0x2E, 0x8E, 0xFC, 0x14, 0x1F, 0xBE, 0xCA, 0xA6, 0x28, 0x7C, 0x59, 0x47, 0x4E, 0x6B, 0xC0, 0x5D, 0x99, 0xB2, 0x96, 0x4F, 0xA0, 0x90, 0xC3, 0xA2, 0x23, 0x3B, 0xA1, 0x86, 0x51, 0x5B, 0xE7, 0xED, 0x1F, 0x61, 0x29, 0x70, 0xCE, 0xE2, 0xD7, 0xAF, 0xB8, 0x1B, 0xDD, 0x76, 0x21, 0x70, 0x48, 0x1C, 0xD0, 0x06, 0x91, 0x27, 0xD5, 0xB0, 0x5A, 0xA9, 0x93, 0xB4, 0xEA, 0x98, 0x8D, 0x8F, 0xDD, 0xC1, 0x86, 0xFF, 0xB7, 0xDC, 0x90, 0xA6, 0xC0, 0x8F, 0x4D, 0xF4, 0x35, 0xC9, 0x34, 0x02, 0x84, 0x92, 0x36, 0xC3, 0xFA, 0xB4, 0xD2, 0x7C, 0x70, 0x26, 0xC1, 0xD4, 0xDC, 0xB2, 0x60, 0x26, 0x46, 0xDE, 0xC9, 0x75, 0x1E, 0x76, 0x3D, 0xBA, 0x37, 0xBD, 0xF8, 0xFF, 0x94, 0x06, 0xAD, 0x9E, 0x53, 0x0E, 0xE5, 0xDB, 0x38, 0x2F, 0x41, 0x30, 0x01, 0xAE, 0xB0, 0x6A, 0x53, 0xED, 0x90, 0x27, 0xD8, 0x31, 0x17, 0x97, 0x27, 0xB0, 0x86, 0x5A, 0x89, 0x18, 0xDA, 0x3E, 0xDB, 0xEB, 0xCF, 0x9B, 0x14, 0xED, 0x44, 0xCE, 0x6C, 0xBA, 0xCE, 0xD4, 0xBB, 0x1B, 0xDB, 0x7F, 0x14, 0x47, 0xE6, 0xCC, 0x25, 0x4B, 0x33, 0x20, 0x51, 0x51, 0x2B, 0xD7, 0xAF, 0x42, 0x6F, 0xB8, 0xF4, 0x01, 0x37, 0x8C, 0xD2, 0xBF, 0x59, 0x83, 0xCA, 0x01, 0xC6, 0x4B, 0x92, 0xEC, 0xF0, 0x32, 0xEA, 0x15, 0xD1, 0x72, 0x1D, 0x03, 0xF4, 0x82, 0xD7, 0xCE, 0x6E, 0x74, 0xFE, 0xF6, 0xD5, 0x5E, 0x70, 0x2F, 0x46, 0x98, 0x0C, 0x82, 0xB5, 0xA8, 0x40, 0x31, 0x90, 0x0B, 0x1C, 0x9E, 0x59, 0xE7, 0xC9, 0x7F, 0xBE, 0xC7, 0xE8, 0xF3, 0x23, 0xA9, 0x7A, 0x7E, 0x36, 0xCC, 0x88, 0xBE, 0x0F, 0x1D, 0x45, 0xB7, 0xFF, 0x58, 0x5A, 0xC5, 0x4B, 0xD4, 0x07, 0xB2, 0x2B, 0x41, 0x54, 0xAA, 0xCC, 0x8F, 0x6D, 0x7E, 0xBF, 0x48, 0xE1, 0xD8, 0x14, 0xCC, 0x5E, 0xD2, 0x0F, 0x80, 0x37, 0xE0, 0xA7, 0x97, 0x15, 0xEE, 0xF2, 0x9B, 0xE3, 0x28, 0x06, 0xA1, 0xD5, 0x8B, 0xB7, 0xC5, 0xDA, 0x76, 0xF5, 0x50, 0xAA, 0x3D, 0x8A, 0x1F, 0xBF, 0xF0, 0xEB, 0x19, 0xCC, 0xB1, 0xA3, 0x13, 0xD5, 0x5C, 0xDA, 0x56, 0xC9, 0xEC, 0x2E, 0xF2, 0x96, 0x32, 0x38, 0x7F, 0xE8, 0xD7, 0x6E, 0x3C, 0x04, 0x68, 0x04, 0x3E, 0x8F, 0x66, 0x3F, 0x48, 0x60, 0xEE, 0x12, 0xBF, 0x2D, 0x5B, 0x0B, 0x74, 0x74, 0xD6, 0xE6, 0x94, 0xF9, 0x1E, 0x6D, 0xBE, 0x11, 0x59, 0x74, 0xA3, 0x92, 0x6F, 0x12, 0xFE, 0xE5, 0xE4, 0x38, 0x77, 0x7C, 0xB6, 0xA9, 0x32, 0xDF, 0x8C, 0xD8, 0xBE, 0xC4, 0xD0, 0x73, 0xB9, 0x31, 0xBA, 0x3B, 0xC8, 0x32, 0xB6, 0x8D, 0x9D, 0xD3, 0x00, 0x74, 0x1F, 0xA7, 0xBF, 0x8A, 0xFC, 0x47, 0xED, 0x25, 0x76, 0xF6, 0x93, 0x6B, 0xA4, 0x24, 0x66, 0x3A, 0xAB, 0x63, 0x9C, 0x5A, 0xE4, 0xF5, 0x68, 0x34, 0x23, 0xB4, 0x74, 0x2B, 0xF1, 0xC9, 0x78, 0x23, 0x8F, 0x16, 0xCB, 0xE3, 0x9D, 0x65, 0x2D, 0xE3, 0xFD, 0xB8, 0xBE, 0xFC, 0x84, 0x8A, 0xD9, 0x22, 0x22, 0x2E, 0x04, 0xA4, 0x03, 0x7C, 0x07, 0x13, 0xEB, 0x57, 0xA8, 0x1A, 0x23, 0xF0, 0xC7, 0x34, 0x73, 0xFC, 0x64, 0x6C, 0xEA, 0x30, 0x6B, 0x4B, 0xCB, 0xC8, 0x86, 0x2F, 0x83, 0x85, 0xDD, 0xFA, 0x9D, 0x4B, 0x7F, 0xA2, 0xC0, 0x87, 0xE8, 0x79, 0x68, 0x33, 0x03, 0xED, 0x5B, 0xDD, 0x3A, 0x06, 0x2B, 0x3C, 0xF5, 0xB3, 0xA2, 0x78, 0xA6, 0x6D, 0x2A, 0x13, 0xF8, 0x3F, 0x44, 0xF8, 0x2D, 0xDF, 0x31, 0x0E, 0xE0, 0x74, 0xAB, 0x6A, 0x36, 0x45, 0x97, 0xE8, 0x99, 0xA0, 0x25, 0x5D, 0xC1, 0x64, 0xF3, 0x1C, 0xC5, 0x08, 0x46, 0x85, 0x1D, 0xF9, 0xAB, 0x48, 0x19, 0x5D, 0xED, 0x7E, 0xA1, 0xB1, 0xD5, 0x10, 0xBD, 0x7E, 0xE7, 0x4D, 0x73, 0xFA, 0xF3, 0x6B, 0xC3, 0x1E, 0xCF, 0xA2, 0x68, 0x35, 0x90, 0x46, 0xF4, 0xEB, 0x87, 0x9F, 0x92, 0x40, 0x09, 0x43, 0x8B, 0x48, 0x1C, 0x6C, 0xD7, 0x88, 0x9A, 0x00, 0x2E, 0xD5, 0xEE, 0x38, 0x2B, 0xC9, 0x19, 0x0D, 0xA6, 0xFC, 0x02, 0x6E, 0x47, 0x95, 0x58, 0xE4, 0x47, 0x56, 0x77, 0xE9, 0xAA, 0x9E, 0x30, 0x50, 0xE2, 0x76, 0x56, 0x94, 0xDF, 0xC8, 0x1F, 0x56, 0xE8, 0x80, 0xB9, 0x6E, 0x71, 0x60, 0xC9, 0x80, 0xDD, 0x98, 0xED, 0xD3, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }; return BN_bin2bn(RFC3526_PRIME_8192, sizeof(RFC3526_PRIME_8192), bn); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_sqr.c0000644000175000017500000001704112360020705020305 0ustar /* $OpenBSD: bn_sqr.c,v 1.10 2014/07/11 08:44:48 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include "bn_lcl.h" /* r must not be a */ /* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96 */ int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) { int max, al; int ret = 0; BIGNUM *tmp, *rr; #ifdef BN_COUNT fprintf(stderr, "BN_sqr %d * %d\n", a->top, a->top); #endif bn_check_top(a); al = a->top; if (al <= 0) { r->top = 0; r->neg = 0; return 1; } BN_CTX_start(ctx); rr = (a != r) ? r : BN_CTX_get(ctx); tmp = BN_CTX_get(ctx); if (!rr || !tmp) goto err; max = 2 * al; /* Non-zero (from above) */ if (bn_wexpand(rr, max) == NULL) goto err; if (al == 4) { #ifndef BN_SQR_COMBA BN_ULONG t[8]; bn_sqr_normal(rr->d, a->d, 4, t); #else bn_sqr_comba4(rr->d, a->d); #endif } else if (al == 8) { #ifndef BN_SQR_COMBA BN_ULONG t[16]; bn_sqr_normal(rr->d, a->d, 8, t); #else bn_sqr_comba8(rr->d, a->d); #endif } else { #if defined(BN_RECURSION) if (al < BN_SQR_RECURSIVE_SIZE_NORMAL) { BN_ULONG t[BN_SQR_RECURSIVE_SIZE_NORMAL*2]; bn_sqr_normal(rr->d, a->d, al, t); } else { int j, k; j = BN_num_bits_word((BN_ULONG)al); j = 1 << (j - 1); k = j + j; if (al == j) { if (bn_wexpand(tmp, k * 2) == NULL) goto err; bn_sqr_recursive(rr->d, a->d, al, tmp->d); } else { if (bn_wexpand(tmp, max) == NULL) goto err; bn_sqr_normal(rr->d, a->d, al, tmp->d); } } #else if (bn_wexpand(tmp, max) == NULL) goto err; bn_sqr_normal(rr->d, a->d, al, tmp->d); #endif } rr->neg = 0; /* If the most-significant half of the top word of 'a' is zero, then * the square of 'a' will max-1 words. */ if (a->d[al - 1] == (a->d[al - 1] & BN_MASK2l)) rr->top = max - 1; else rr->top = max; if (rr != r) BN_copy(r, rr); ret = 1; err: bn_check_top(rr); bn_check_top(tmp); BN_CTX_end(ctx); return (ret); } /* tmp must have 2*n words */ void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp) { int i, j, max; const BN_ULONG *ap; BN_ULONG *rp; max = n * 2; ap = a; rp = r; rp[0] = rp[max - 1] = 0; rp++; j = n; if (--j > 0) { ap++; rp[j] = bn_mul_words(rp, ap, j, ap[-1]); rp += 2; } for (i = n - 2; i > 0; i--) { j--; ap++; rp[j] = bn_mul_add_words(rp, ap, j, ap[-1]); rp += 2; } bn_add_words(r, r, r, max); /* There will not be a carry */ bn_sqr_words(tmp, a, n); bn_add_words(r, r, tmp, max); } #ifdef BN_RECURSION /* r is 2*n words in size, * a and b are both n words in size. (There's not actually a 'b' here ...) * n must be a power of 2. * We multiply and return the result. * t must be 2*n words in size * We calculate * a[0]*b[0] * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0]) * a[1]*b[1] */ void bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t) { int n = n2 / 2; int zero, c1; BN_ULONG ln, lo, *p; #ifdef BN_COUNT fprintf(stderr, " bn_sqr_recursive %d * %d\n", n2, n2); #endif if (n2 == 4) { #ifndef BN_SQR_COMBA bn_sqr_normal(r, a, 4, t); #else bn_sqr_comba4(r, a); #endif return; } else if (n2 == 8) { #ifndef BN_SQR_COMBA bn_sqr_normal(r, a, 8, t); #else bn_sqr_comba8(r, a); #endif return; } if (n2 < BN_SQR_RECURSIVE_SIZE_NORMAL) { bn_sqr_normal(r, a, n2, t); return; } /* r=(a[0]-a[1])*(a[1]-a[0]) */ c1 = bn_cmp_words(a, &(a[n]), n); zero = 0; if (c1 > 0) bn_sub_words(t, a, &(a[n]), n); else if (c1 < 0) bn_sub_words(t, &(a[n]), a, n); else zero = 1; /* The result will always be negative unless it is zero */ p = &(t[n2*2]); if (!zero) bn_sqr_recursive(&(t[n2]), t, n, p); else memset(&(t[n2]), 0, n2 * sizeof(BN_ULONG)); bn_sqr_recursive(r, a, n, p); bn_sqr_recursive(&(r[n2]), &(a[n]), n, p); /* t[32] holds (a[0]-a[1])*(a[1]-a[0]), it is negative or zero * r[10] holds (a[0]*b[0]) * r[32] holds (b[1]*b[1]) */ c1 = (int)(bn_add_words(t, r, &(r[n2]), n2)); /* t[32] is negative */ c1 -= (int)(bn_sub_words(&(t[n2]), t, &(t[n2]), n2)); /* t[32] holds (a[0]-a[1])*(a[1]-a[0])+(a[0]*a[0])+(a[1]*a[1]) * r[10] holds (a[0]*a[0]) * r[32] holds (a[1]*a[1]) * c1 holds the carry bits */ c1 += (int)(bn_add_words(&(r[n]), &(r[n]), &(t[n2]), n2)); if (c1) { p = &(r[n + n2]); lo= *p; ln = (lo + c1) & BN_MASK2; *p = ln; /* The overflow will stop before we over write * words we should not overwrite */ if (ln < (BN_ULONG)c1) { do { p++; lo= *p; ln = (lo + 1) & BN_MASK2; *p = ln; } while (ln == 0); } } } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_kron.c0000644000175000017500000001200012360020705020437 0ustar /* $OpenBSD: bn_kron.c,v 1.4 2014/06/12 15:49:28 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "bn_lcl.h" /* least significant word */ #define BN_lsw(n) (((n)->top == 0) ? (BN_ULONG) 0 : (n)->d[0]) /* Returns -2 for errors because both -1 and 0 are valid results. */ int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { int i; int ret = -2; /* avoid 'uninitialized' warning */ int err = 0; BIGNUM *A, *B, *tmp; /* In 'tab', only odd-indexed entries are relevant: * For any odd BIGNUM n, * tab[BN_lsw(n) & 7] * is $(-1)^{(n^2-1)/8}$ (using TeX notation). * Note that the sign of n does not matter. */ static const int tab[8] = {0, 1, 0, -1, 0, -1, 0, 1}; bn_check_top(a); bn_check_top(b); BN_CTX_start(ctx); A = BN_CTX_get(ctx); B = BN_CTX_get(ctx); if (B == NULL) goto end; err = !BN_copy(A, a); if (err) goto end; err = !BN_copy(B, b); if (err) goto end; /* * Kronecker symbol, imlemented according to Henri Cohen, * "A Course in Computational Algebraic Number Theory" * (algorithm 1.4.10). */ /* Cohen's step 1: */ if (BN_is_zero(B)) { ret = BN_abs_is_word(A, 1); goto end; } /* Cohen's step 2: */ if (!BN_is_odd(A) && !BN_is_odd(B)) { ret = 0; goto end; } /* now B is non-zero */ i = 0; while (!BN_is_bit_set(B, i)) i++; err = !BN_rshift(B, B, i); if (err) goto end; if (i & 1) { /* i is odd */ /* (thus B was even, thus A must be odd!) */ /* set 'ret' to $(-1)^{(A^2-1)/8}$ */ ret = tab[BN_lsw(A) & 7]; } else { /* i is even */ ret = 1; } if (B->neg) { B->neg = 0; if (A->neg) ret = -ret; } /* now B is positive and odd, so what remains to be done is * to compute the Jacobi symbol (A/B) and multiply it by 'ret' */ while (1) { /* Cohen's step 3: */ /* B is positive and odd */ if (BN_is_zero(A)) { ret = BN_is_one(B) ? ret : 0; goto end; } /* now A is non-zero */ i = 0; while (!BN_is_bit_set(A, i)) i++; err = !BN_rshift(A, A, i); if (err) goto end; if (i & 1) { /* i is odd */ /* multiply 'ret' by $(-1)^{(B^2-1)/8}$ */ ret = ret * tab[BN_lsw(B) & 7]; } /* Cohen's step 4: */ /* multiply 'ret' by $(-1)^{(A-1)(B-1)/4}$ */ if ((A->neg ? ~BN_lsw(A) : BN_lsw(A)) & BN_lsw(B) & 2) ret = -ret; /* (A, B) := (B mod |A|, |A|) */ err = !BN_nnmod(B, B, A, ctx); if (err) goto end; tmp = A; A = B; B = tmp; tmp->neg = 0; } end: BN_CTX_end(ctx); if (err) return -2; else return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_print.c0000644000175000017500000002156412360020705020641 0ustar /* $OpenBSD: bn_print.c,v 1.21 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include "bn_lcl.h" static const char Hex[]="0123456789ABCDEF"; /* Must 'free' the returned data */ char * BN_bn2hex(const BIGNUM *a) { int i, j, v, z = 0; char *buf; char *p; buf = malloc(a->top * BN_BYTES * 2 + 2); if (buf == NULL) { BNerr(BN_F_BN_BN2HEX, ERR_R_MALLOC_FAILURE); goto err; } p = buf; if (a->neg) *(p++) = '-'; if (BN_is_zero(a)) *(p++) = '0'; for (i = a->top - 1; i >=0; i--) { for (j = BN_BITS2 - 8; j >= 0; j -= 8) { /* strip leading zeros */ v = ((int)(a->d[i] >> (long)j)) & 0xff; if (z || (v != 0)) { *(p++) = Hex[v >> 4]; *(p++) = Hex[v & 0x0f]; z = 1; } } } *p = '\0'; err: return (buf); } /* Must 'free' the returned data */ char * BN_bn2dec(const BIGNUM *a) { int i = 0, num, ok = 0; char *buf = NULL; char *p; BIGNUM *t = NULL; BN_ULONG *bn_data = NULL, *lp; /* get an upper bound for the length of the decimal integer * num <= (BN_num_bits(a) + 1) * log(2) * <= 3 * BN_num_bits(a) * 0.1001 + log(2) + 1 (rounding error) * <= BN_num_bits(a)/10 + BN_num_bits/1000 + 1 + 1 */ i = BN_num_bits(a) * 3; num = (i / 10 + i / 1000 + 1) + 1; bn_data = reallocarray(NULL, num / BN_DEC_NUM + 1, sizeof(BN_ULONG)); buf = malloc(num + 3); if ((buf == NULL) || (bn_data == NULL)) { BNerr(BN_F_BN_BN2DEC, ERR_R_MALLOC_FAILURE); goto err; } if ((t = BN_dup(a)) == NULL) goto err; #define BUF_REMAIN (num+3 - (size_t)(p - buf)) p = buf; lp = bn_data; if (BN_is_zero(t)) { *(p++) = '0'; *(p++) = '\0'; } else { if (BN_is_negative(t)) *p++ = '-'; i = 0; while (!BN_is_zero(t)) { *lp = BN_div_word(t, BN_DEC_CONV); lp++; } lp--; /* We now have a series of blocks, BN_DEC_NUM chars * in length, where the last one needs truncation. * The blocks need to be reversed in order. */ snprintf(p, BUF_REMAIN, BN_DEC_FMT1, *lp); while (*p) p++; while (lp != bn_data) { lp--; snprintf(p, BUF_REMAIN, BN_DEC_FMT2, *lp); while (*p) p++; } } ok = 1; err: free(bn_data); if (t != NULL) BN_free(t); if (!ok && buf) { free(buf); buf = NULL; } return (buf); } int BN_hex2bn(BIGNUM **bn, const char *a) { BIGNUM *ret = NULL; BN_ULONG l = 0; int neg = 0, h, m, i,j, k, c; int num; if ((a == NULL) || (*a == '\0')) return (0); if (*a == '-') { neg = 1; a++; } for (i = 0; isxdigit((unsigned char)a[i]); i++) ; num = i + neg; if (bn == NULL) return (num); /* a is the start of the hex digits, and it is 'i' long */ if (*bn == NULL) { if ((ret = BN_new()) == NULL) return (0); } else { ret= *bn; BN_zero(ret); } /* i is the number of hex digests; */ if (bn_expand(ret, i * 4) == NULL) goto err; j = i; /* least significant 'hex' */ m = 0; h = 0; while (j > 0) { m = ((BN_BYTES*2) <= j) ? (BN_BYTES * 2) : j; l = 0; for (;;) { c = a[j - m]; if ((c >= '0') && (c <= '9')) k = c - '0'; else if ((c >= 'a') && (c <= 'f')) k = c - 'a' + 10; else if ((c >= 'A') && (c <= 'F')) k = c - 'A' + 10; else k = 0; /* paranoia */ l = (l << 4) | k; if (--m <= 0) { ret->d[h++] = l; break; } } j -= (BN_BYTES * 2); } ret->top = h; bn_correct_top(ret); ret->neg = neg; *bn = ret; bn_check_top(ret); return (num); err: if (*bn == NULL) BN_free(ret); return (0); } int BN_dec2bn(BIGNUM **bn, const char *a) { BIGNUM *ret = NULL; BN_ULONG l = 0; int neg = 0, i, j; int num; if ((a == NULL) || (*a == '\0')) return (0); if (*a == '-') { neg = 1; a++; } for (i = 0; isdigit((unsigned char)a[i]); i++) ; num = i + neg; if (bn == NULL) return (num); /* a is the start of the digits, and it is 'i' long. * We chop it into BN_DEC_NUM digits at a time */ if (*bn == NULL) { if ((ret = BN_new()) == NULL) return (0); } else { ret = *bn; BN_zero(ret); } /* i is the number of digests, a bit of an over expand; */ if (bn_expand(ret, i * 4) == NULL) goto err; j = BN_DEC_NUM - (i % BN_DEC_NUM); if (j == BN_DEC_NUM) j = 0; l = 0; while (*a) { l *= 10; l += *a - '0'; a++; if (++j == BN_DEC_NUM) { BN_mul_word(ret, BN_DEC_CONV); BN_add_word(ret, l); l = 0; j = 0; } } ret->neg = neg; bn_correct_top(ret); *bn = ret; bn_check_top(ret); return (num); err: if (*bn == NULL) BN_free(ret); return (0); } int BN_asc2bn(BIGNUM **bn, const char *a) { const char *p = a; if (*p == '-') p++; if (p[0] == '0' && (p[1] == 'X' || p[1] == 'x')) { if (!BN_hex2bn(bn, p + 2)) return 0; } else { if (!BN_dec2bn(bn, p)) return 0; } if (*a == '-') (*bn)->neg = 1; return 1; } #ifndef OPENSSL_NO_BIO int BN_print_fp(FILE *fp, const BIGNUM *a) { BIO *b; int ret; if ((b = BIO_new(BIO_s_file())) == NULL) return (0); BIO_set_fp(b, fp, BIO_NOCLOSE); ret = BN_print(b, a); BIO_free(b); return (ret); } int BN_print(BIO *bp, const BIGNUM *a) { int i, j, v, z = 0; int ret = 0; if ((a->neg) && (BIO_write(bp, "-", 1) != 1)) goto end; if (BN_is_zero(a) && (BIO_write(bp, "0", 1) != 1)) goto end; for (i = a->top - 1; i >= 0; i--) { for (j = BN_BITS2 - 4; j >= 0; j -= 4) { /* strip leading zeros */ v = ((int)(a->d[i] >> (long)j)) & 0x0f; if (z || (v != 0)) { if (BIO_write(bp, &(Hex[v]), 1) != 1) goto end; z = 1; } } } ret = 1; end: return (ret); } #endif char * BN_options(void) { static int init = 0; static char data[16]; if (!init) { init++; #ifdef BN_LLONG snprintf(data,sizeof data, "bn(%d,%d)", (int)sizeof(BN_ULLONG) * 8, (int)sizeof(BN_ULONG) * 8); #else snprintf(data,sizeof data, "bn(%d,%d)", (int)sizeof(BN_ULONG) * 8, (int)sizeof(BN_ULONG) * 8); #endif } return (data); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_prime.h0000644000175000017500000004017312360020705020623 0ustar /* $OpenBSD$ */ /* Auto generated by bn_prime.pl */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #define NUMPRIMES 2048 typedef unsigned short prime_t; static const prime_t primes[NUMPRIMES] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 15923, 15937, 15959, 15971, 15973, 15991, 16001, 16007, 16033, 16057, 16061, 16063, 16067, 16069, 16073, 16087, 16091, 16097, 16103, 16111, 16127, 16139, 16141, 16183, 16187, 16189, 16193, 16217, 16223, 16229, 16231, 16249, 16253, 16267, 16273, 16301, 16319, 16333, 16339, 16349, 16361, 16363, 16369, 16381, 16411, 16417, 16421, 16427, 16433, 16447, 16451, 16453, 16477, 16481, 16487, 16493, 16519, 16529, 16547, 16553, 16561, 16567, 16573, 16603, 16607, 16619, 16631, 16633, 16649, 16651, 16657, 16661, 16673, 16691, 16693, 16699, 16703, 16729, 16741, 16747, 16759, 16763, 16787, 16811, 16823, 16829, 16831, 16843, 16871, 16879, 16883, 16889, 16901, 16903, 16921, 16927, 16931, 16937, 16943, 16963, 16979, 16981, 16987, 16993, 17011, 17021, 17027, 17029, 17033, 17041, 17047, 17053, 17077, 17093, 17099, 17107, 17117, 17123, 17137, 17159, 17167, 17183, 17189, 17191, 17203, 17207, 17209, 17231, 17239, 17257, 17291, 17293, 17299, 17317, 17321, 17327, 17333, 17341, 17351, 17359, 17377, 17383, 17387, 17389, 17393, 17401, 17417, 17419, 17431, 17443, 17449, 17467, 17471, 17477, 17483, 17489, 17491, 17497, 17509, 17519, 17539, 17551, 17569, 17573, 17579, 17581, 17597, 17599, 17609, 17623, 17627, 17657, 17659, 17669, 17681, 17683, 17707, 17713, 17729, 17737, 17747, 17749, 17761, 17783, 17789, 17791, 17807, 17827, 17837, 17839, 17851, 17863, }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_nist.c0000644000175000017500000010273212360020705020457 0ustar /* $OpenBSD: bn_nist.c,v 1.13 2014/07/10 13:58:22 jsing Exp $ */ /* * Written by Nils Larsch for the OpenSSL project */ /* ==================================================================== * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "bn_lcl.h" #define BN_NIST_192_TOP (192+BN_BITS2-1)/BN_BITS2 #define BN_NIST_224_TOP (224+BN_BITS2-1)/BN_BITS2 #define BN_NIST_256_TOP (256+BN_BITS2-1)/BN_BITS2 #define BN_NIST_384_TOP (384+BN_BITS2-1)/BN_BITS2 #define BN_NIST_521_TOP (521+BN_BITS2-1)/BN_BITS2 /* pre-computed tables are "carry-less" values of modulus*(i+1) */ #if BN_BITS2 == 64 static const BN_ULONG _nist_p_192[][BN_NIST_192_TOP] = { {0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFEULL, 0xFFFFFFFFFFFFFFFFULL}, {0xFFFFFFFFFFFFFFFEULL, 0xFFFFFFFFFFFFFFFDULL, 0xFFFFFFFFFFFFFFFFULL}, {0xFFFFFFFFFFFFFFFDULL, 0xFFFFFFFFFFFFFFFCULL, 0xFFFFFFFFFFFFFFFFULL} }; static const BN_ULONG _nist_p_192_sqr[] = { 0x0000000000000001ULL, 0x0000000000000002ULL, 0x0000000000000001ULL, 0xFFFFFFFFFFFFFFFEULL, 0xFFFFFFFFFFFFFFFDULL, 0xFFFFFFFFFFFFFFFFULL }; static const BN_ULONG _nist_p_224[][BN_NIST_224_TOP] = { { 0x0000000000000001ULL, 0xFFFFFFFF00000000ULL, 0xFFFFFFFFFFFFFFFFULL, 0x00000000FFFFFFFFULL }, { 0x0000000000000002ULL, 0xFFFFFFFE00000000ULL, 0xFFFFFFFFFFFFFFFFULL, 0x00000001FFFFFFFFULL } /* this one is "carry-full" */ }; static const BN_ULONG _nist_p_224_sqr[] = { 0x0000000000000001ULL, 0xFFFFFFFE00000000ULL, 0xFFFFFFFFFFFFFFFFULL, 0x0000000200000000ULL, 0x0000000000000000ULL, 0xFFFFFFFFFFFFFFFEULL, 0xFFFFFFFFFFFFFFFFULL }; static const BN_ULONG _nist_p_256[][BN_NIST_256_TOP] = { { 0xFFFFFFFFFFFFFFFFULL, 0x00000000FFFFFFFFULL, 0x0000000000000000ULL, 0xFFFFFFFF00000001ULL }, { 0xFFFFFFFFFFFFFFFEULL, 0x00000001FFFFFFFFULL, 0x0000000000000000ULL, 0xFFFFFFFE00000002ULL }, { 0xFFFFFFFFFFFFFFFDULL, 0x00000002FFFFFFFFULL, 0x0000000000000000ULL, 0xFFFFFFFD00000003ULL }, { 0xFFFFFFFFFFFFFFFCULL, 0x00000003FFFFFFFFULL, 0x0000000000000000ULL, 0xFFFFFFFC00000004ULL }, { 0xFFFFFFFFFFFFFFFBULL, 0x00000004FFFFFFFFULL, 0x0000000000000000ULL, 0xFFFFFFFB00000005ULL }, }; static const BN_ULONG _nist_p_256_sqr[] = { 0x0000000000000001ULL, 0xFFFFFFFE00000000ULL, 0xFFFFFFFFFFFFFFFFULL, 0x00000001FFFFFFFEULL, 0x00000001FFFFFFFEULL, 0x00000001FFFFFFFEULL, 0xFFFFFFFE00000001ULL, 0xFFFFFFFE00000002ULL }; static const BN_ULONG _nist_p_384[][BN_NIST_384_TOP] = { { 0x00000000FFFFFFFFULL, 0xFFFFFFFF00000000ULL, 0xFFFFFFFFFFFFFFFEULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL }, { 0x00000001FFFFFFFEULL, 0xFFFFFFFE00000000ULL, 0xFFFFFFFFFFFFFFFDULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL }, { 0x00000002FFFFFFFDULL, 0xFFFFFFFD00000000ULL, 0xFFFFFFFFFFFFFFFCULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL }, { 0x00000003FFFFFFFCULL, 0xFFFFFFFC00000000ULL, 0xFFFFFFFFFFFFFFFBULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL }, { 0x00000004FFFFFFFBULL, 0xFFFFFFFB00000000ULL, 0xFFFFFFFFFFFFFFFAULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL }, }; static const BN_ULONG _nist_p_384_sqr[] = { 0xFFFFFFFE00000001ULL, 0x0000000200000000ULL, 0xFFFFFFFE00000000ULL, 0x0000000200000000ULL, 0x0000000000000001ULL, 0x0000000000000000ULL, 0x00000001FFFFFFFEULL, 0xFFFFFFFE00000000ULL, 0xFFFFFFFFFFFFFFFDULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL }; static const BN_ULONG _nist_p_521[] = { 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0x00000000000001FFULL }; static const BN_ULONG _nist_p_521_sqr[] = { 0x0000000000000001ULL, 0x0000000000000000ULL, 0x0000000000000000ULL, 0x0000000000000000ULL, 0x0000000000000000ULL, 0x0000000000000000ULL, 0x0000000000000000ULL, 0x0000000000000000ULL, 0xFFFFFFFFFFFFFC00ULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0x000000000003FFFFULL }; #elif BN_BITS2 == 32 static const BN_ULONG _nist_p_192[][BN_NIST_192_TOP] = { { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }, { 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }, { 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF } }; static const BN_ULONG _nist_p_192_sqr[] = { 0x00000001, 0x00000000, 0x00000002, 0x00000000, 0x00000001, 0x00000000, 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; static const BN_ULONG _nist_p_224[][BN_NIST_224_TOP] = { { 0x00000001, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }, { 0x00000002, 0x00000000, 0x00000000, 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF } }; static const BN_ULONG _nist_p_224_sqr[] = { 0x00000001, 0x00000000, 0x00000000, 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; static const BN_ULONG _nist_p_256[][BN_NIST_256_TOP] = { { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0xFFFFFFFF }, { 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000001, 0x00000000, 0x00000000, 0x00000002, 0xFFFFFFFE }, { 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000002, 0x00000000, 0x00000000, 0x00000003, 0xFFFFFFFD }, { 0xFFFFFFFC, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000003, 0x00000000, 0x00000000, 0x00000004, 0xFFFFFFFC }, { 0xFFFFFFFB, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000004, 0x00000000, 0x00000000, 0x00000005, 0xFFFFFFFB }, }; static const BN_ULONG _nist_p_256_sqr[] = { 0x00000001, 0x00000000, 0x00000000, 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFE, 0x00000001, 0xFFFFFFFE, 0x00000001, 0xFFFFFFFE, 0x00000001, 0x00000001, 0xFFFFFFFE, 0x00000002, 0xFFFFFFFE }; static const BN_ULONG _nist_p_384[][BN_NIST_384_TOP] = { { 0xFFFFFFFF, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }, { 0xFFFFFFFE, 0x00000001, 0x00000000, 0xFFFFFFFE, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }, { 0xFFFFFFFD, 0x00000002, 0x00000000, 0xFFFFFFFD, 0xFFFFFFFC, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }, { 0xFFFFFFFC, 0x00000003, 0x00000000, 0xFFFFFFFC, 0xFFFFFFFB, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }, { 0xFFFFFFFB, 0x00000004, 0x00000000, 0xFFFFFFFB, 0xFFFFFFFA, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }, }; static const BN_ULONG _nist_p_384_sqr[] = { 0x00000001, 0xFFFFFFFE, 0x00000000, 0x00000002, 0x00000000, 0xFFFFFFFE, 0x00000000, 0x00000002, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFE, 0x00000001, 0x00000000, 0xFFFFFFFE, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; static const BN_ULONG _nist_p_521[] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x000001FF }; static const BN_ULONG _nist_p_521_sqr[] = { 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFC00, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0003FFFF }; #else #error "unsupported BN_BITS2" #endif static const BIGNUM _bignum_nist_p_192 = { (BN_ULONG *)_nist_p_192[0], BN_NIST_192_TOP, BN_NIST_192_TOP, 0, BN_FLG_STATIC_DATA }; static const BIGNUM _bignum_nist_p_224 = { (BN_ULONG *)_nist_p_224[0], BN_NIST_224_TOP, BN_NIST_224_TOP, 0, BN_FLG_STATIC_DATA }; static const BIGNUM _bignum_nist_p_256 = { (BN_ULONG *)_nist_p_256[0], BN_NIST_256_TOP, BN_NIST_256_TOP, 0, BN_FLG_STATIC_DATA }; static const BIGNUM _bignum_nist_p_384 = { (BN_ULONG *)_nist_p_384[0], BN_NIST_384_TOP, BN_NIST_384_TOP, 0, BN_FLG_STATIC_DATA }; static const BIGNUM _bignum_nist_p_521 = { (BN_ULONG *)_nist_p_521, BN_NIST_521_TOP, BN_NIST_521_TOP, 0, BN_FLG_STATIC_DATA }; const BIGNUM * BN_get0_nist_prime_192(void) { return &_bignum_nist_p_192; } const BIGNUM * BN_get0_nist_prime_224(void) { return &_bignum_nist_p_224; } const BIGNUM * BN_get0_nist_prime_256(void) { return &_bignum_nist_p_256; } const BIGNUM * BN_get0_nist_prime_384(void) { return &_bignum_nist_p_384; } const BIGNUM * BN_get0_nist_prime_521(void) { return &_bignum_nist_p_521; } static void nist_cp_bn_0(BN_ULONG *dst, const BN_ULONG *src, int top, int max) { int i; #ifdef BN_DEBUG OPENSSL_assert(top <= max); #endif for (i = 0; i < top; i++) dst[i] = src[i]; for (; i < max; i++) dst[i] = 0; } static void nist_cp_bn(BN_ULONG *dst, const BN_ULONG *src, int top) { int i; for (i = 0; i < top; i++) dst[i] = src[i]; } #if BN_BITS2 == 64 #define bn_cp_64(to, n, from, m) (to)[n] = (m>=0)?((from)[m]):0; #define bn_64_set_0(to, n) (to)[n] = (BN_ULONG)0; /* * two following macros are implemented under assumption that they * are called in a sequence with *ascending* n, i.e. as they are... */ #define bn_cp_32_naked(to, n, from, m) (((n)&1)?(to[(n)/2]|=((m)&1)?(from[(m)/2]&BN_MASK2h):(from[(m)/2]<<32))\ :(to[(n)/2] =((m)&1)?(from[(m)/2]>>32):(from[(m)/2]&BN_MASK2l))) #define bn_32_set_0(to, n) (((n)&1)?(to[(n)/2]&=BN_MASK2l):(to[(n)/2]=0)); #define bn_cp_32(to,n,from,m) ((m)>=0)?bn_cp_32_naked(to,n,from,m):bn_32_set_0(to,n) # if BYTE_ORDER == LITTLE_ENDIAN # if defined(_LP64) # define NIST_INT64 long # else # define NIST_INT64 long long # endif # endif #else #define bn_cp_64(to, n, from, m) \ { \ bn_cp_32(to, (n)*2, from, (m)*2); \ bn_cp_32(to, (n)*2+1, from, (m)*2+1); \ } #define bn_64_set_0(to, n) \ { \ bn_32_set_0(to, (n)*2); \ bn_32_set_0(to, (n)*2+1); \ } #define bn_cp_32(to, n, from, m) (to)[n] = (m>=0)?((from)[m]):0; #define bn_32_set_0(to, n) (to)[n] = (BN_ULONG)0; # if defined(BN_LLONG) # define NIST_INT64 long long # endif #endif /* BN_BITS2 != 64 */ #define nist_set_192(to, from, a1, a2, a3) \ { \ bn_cp_64(to, 0, from, (a3) - 3) \ bn_cp_64(to, 1, from, (a2) - 3) \ bn_cp_64(to, 2, from, (a1) - 3) \ } int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) { int top = a->top, i; int carry; register BN_ULONG *r_d, *a_d = a->d; union { BN_ULONG bn[BN_NIST_192_TOP]; unsigned int ui[BN_NIST_192_TOP * sizeof(BN_ULONG) / sizeof(unsigned int)]; } buf; BN_ULONG c_d[BN_NIST_192_TOP], *res; uintptr_t mask; static const BIGNUM _bignum_nist_p_192_sqr = { (BN_ULONG *)_nist_p_192_sqr, sizeof(_nist_p_192_sqr) / sizeof(_nist_p_192_sqr[0]), sizeof(_nist_p_192_sqr) / sizeof(_nist_p_192_sqr[0]), 0, BN_FLG_STATIC_DATA }; field = &_bignum_nist_p_192; /* just to make sure */ if (BN_is_negative(a) || BN_ucmp(a, &_bignum_nist_p_192_sqr) >= 0) return BN_nnmod(r, a, field, ctx); i = BN_ucmp(field, a); if (i == 0) { BN_zero(r); return 1; } else if (i > 0) return (r == a) ? 1 : (BN_copy(r , a) != NULL); if (r != a) { if (!bn_wexpand(r, BN_NIST_192_TOP)) return 0; r_d = r->d; nist_cp_bn(r_d, a_d, BN_NIST_192_TOP); } else r_d = a_d; nist_cp_bn_0(buf.bn, a_d + BN_NIST_192_TOP, top - BN_NIST_192_TOP, BN_NIST_192_TOP); #if defined(NIST_INT64) { NIST_INT64 acc; /* accumulator */ unsigned int *rp = (unsigned int *)r_d; const unsigned int *bp = (const unsigned int *)buf.ui; acc = rp[0]; acc += bp[3 * 2 - 6]; acc += bp[5 * 2 - 6]; rp[0] = (unsigned int)acc; acc >>= 32; acc += rp[1]; acc += bp[3 * 2 - 5]; acc += bp[5 * 2 - 5]; rp[1] = (unsigned int)acc; acc >>= 32; acc += rp[2]; acc += bp[3 * 2 - 6]; acc += bp[4 * 2 - 6]; acc += bp[5 * 2 - 6]; rp[2] = (unsigned int)acc; acc >>= 32; acc += rp[3]; acc += bp[3 * 2 - 5]; acc += bp[4 * 2 - 5]; acc += bp[5 * 2 - 5]; rp[3] = (unsigned int)acc; acc >>= 32; acc += rp[4]; acc += bp[4 * 2 - 6]; acc += bp[5 * 2 - 6]; rp[4] = (unsigned int)acc; acc >>= 32; acc += rp[5]; acc += bp[4 * 2 - 5]; acc += bp[5 * 2 - 5]; rp[5] = (unsigned int)acc; carry = (int)(acc >> 32); } #else { BN_ULONG t_d[BN_NIST_192_TOP]; nist_set_192(t_d, buf.bn, 0, 3, 3); carry = (int)bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP); nist_set_192(t_d, buf.bn, 4, 4, 0); carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP); nist_set_192(t_d, buf.bn, 5, 5, 5) carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP); } #endif if (carry > 0) carry = (int)bn_sub_words(r_d, r_d, _nist_p_192[carry - 1], BN_NIST_192_TOP); else carry = 1; /* * we need 'if (carry==0 || result>=modulus) result-=modulus;' * as comparison implies subtraction, we can write * 'tmp=result-modulus; if (!carry || !borrow) result=tmp;' * this is what happens below, but without explicit if:-) a. */ mask = 0 - (uintptr_t)bn_sub_words(c_d, r_d, _nist_p_192[0], BN_NIST_192_TOP); mask &= 0 - (uintptr_t)carry; res = c_d; res = (BN_ULONG *)(((uintptr_t)res & ~mask) | ((uintptr_t)r_d & mask)); nist_cp_bn(r_d, res, BN_NIST_192_TOP); r->top = BN_NIST_192_TOP; bn_correct_top(r); return 1; } typedef BN_ULONG (*bn_addsub_f)(BN_ULONG *, const BN_ULONG *, const BN_ULONG *, int); #define nist_set_224(to, from, a1, a2, a3, a4, a5, a6, a7) \ { \ bn_cp_32(to, 0, from, (a7) - 7) \ bn_cp_32(to, 1, from, (a6) - 7) \ bn_cp_32(to, 2, from, (a5) - 7) \ bn_cp_32(to, 3, from, (a4) - 7) \ bn_cp_32(to, 4, from, (a3) - 7) \ bn_cp_32(to, 5, from, (a2) - 7) \ bn_cp_32(to, 6, from, (a1) - 7) \ } int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) { int top = a->top, i; int carry; BN_ULONG *r_d, *a_d = a->d; union { BN_ULONG bn[BN_NIST_224_TOP]; unsigned int ui[BN_NIST_224_TOP * sizeof(BN_ULONG) / sizeof(unsigned int)]; } buf; BN_ULONG c_d[BN_NIST_224_TOP], *res; uintptr_t mask; union { bn_addsub_f f; uintptr_t p; } u; static const BIGNUM _bignum_nist_p_224_sqr = { (BN_ULONG *)_nist_p_224_sqr, sizeof(_nist_p_224_sqr) / sizeof(_nist_p_224_sqr[0]), sizeof(_nist_p_224_sqr) / sizeof(_nist_p_224_sqr[0]), 0, BN_FLG_STATIC_DATA }; field = &_bignum_nist_p_224; /* just to make sure */ if (BN_is_negative(a) || BN_ucmp(a, &_bignum_nist_p_224_sqr) >= 0) return BN_nnmod(r, a, field, ctx); i = BN_ucmp(field, a); if (i == 0) { BN_zero(r); return 1; } else if (i > 0) return (r == a) ? 1 : (BN_copy(r, a) != NULL); if (r != a) { if (!bn_wexpand(r, BN_NIST_224_TOP)) return 0; r_d = r->d; nist_cp_bn(r_d, a_d, BN_NIST_224_TOP); } else r_d = a_d; #if BN_BITS2==64 /* copy upper 256 bits of 448 bit number ... */ nist_cp_bn_0(c_d, a_d + (BN_NIST_224_TOP - 1), top - (BN_NIST_224_TOP - 1), BN_NIST_224_TOP); /* ... and right shift by 32 to obtain upper 224 bits */ nist_set_224(buf.bn, c_d, 14, 13, 12, 11, 10, 9, 8); /* truncate lower part to 224 bits too */ r_d[BN_NIST_224_TOP - 1] &= BN_MASK2l; #else nist_cp_bn_0(buf.bn, a_d + BN_NIST_224_TOP, top - BN_NIST_224_TOP, BN_NIST_224_TOP); #endif #if defined(NIST_INT64) && BN_BITS2!=64 { NIST_INT64 acc; /* accumulator */ unsigned int *rp = (unsigned int *)r_d; const unsigned int *bp = (const unsigned int *)buf.ui; acc = rp[0]; acc -= bp[7 - 7]; acc -= bp[11 - 7]; rp[0] = (unsigned int)acc; acc >>= 32; acc += rp[1]; acc -= bp[8 - 7]; acc -= bp[12 - 7]; rp[1] = (unsigned int)acc; acc >>= 32; acc += rp[2]; acc -= bp[9 - 7]; acc -= bp[13 - 7]; rp[2] = (unsigned int)acc; acc >>= 32; acc += rp[3]; acc += bp[7 - 7]; acc += bp[11 - 7]; acc -= bp[10 - 7]; rp[3] = (unsigned int)acc; acc >>= 32; acc += rp[4]; acc += bp[8 - 7]; acc += bp[12 - 7]; acc -= bp[11 - 7]; rp[4] = (unsigned int)acc; acc >>= 32; acc += rp[5]; acc += bp[9 - 7]; acc += bp[13 - 7]; acc -= bp[12 - 7]; rp[5] = (unsigned int)acc; acc >>= 32; acc += rp[6]; acc += bp[10 - 7]; acc -= bp[13 - 7]; rp[6] = (unsigned int)acc; carry = (int)(acc >> 32); # if BN_BITS2==64 rp[7] = carry; # endif } #else { BN_ULONG t_d[BN_NIST_224_TOP]; nist_set_224(t_d, buf.bn, 10, 9, 8, 7, 0, 0, 0); carry = (int)bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP); nist_set_224(t_d, buf.bn, 0, 13, 12, 11, 0, 0, 0); carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP); nist_set_224(t_d, buf.bn, 13, 12, 11, 10, 9, 8, 7); carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_224_TOP); nist_set_224(t_d, buf.bn, 0, 0, 0, 0, 13, 12, 11); carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_224_TOP); #if BN_BITS2==64 carry = (int)(r_d[BN_NIST_224_TOP - 1] >> 32); #endif } #endif u.f = bn_sub_words; if (carry > 0) { carry = (int)bn_sub_words(r_d, r_d, _nist_p_224[carry - 1], BN_NIST_224_TOP); #if BN_BITS2==64 carry = (int)(~(r_d[BN_NIST_224_TOP - 1] >> 32)) & 1; #endif } else if (carry < 0) { /* it's a bit more complicated logic in this case. * if bn_add_words yields no carry, then result * has to be adjusted by unconditionally *adding* * the modulus. but if it does, then result has * to be compared to the modulus and conditionally * adjusted by *subtracting* the latter. */ carry = (int)bn_add_words(r_d, r_d, _nist_p_224[-carry - 1], BN_NIST_224_TOP); mask = 0 - (uintptr_t)carry; u.p = ((uintptr_t)bn_sub_words & mask) | ((uintptr_t)bn_add_words & ~mask); } else carry = 1; /* otherwise it's effectively same as in BN_nist_mod_192... */ mask = 0 - (uintptr_t)(*u.f)(c_d, r_d, _nist_p_224[0], BN_NIST_224_TOP); mask &= 0 - (uintptr_t)carry; res = c_d; res = (BN_ULONG *)(((uintptr_t)res & ~mask) | ((uintptr_t)r_d & mask)); nist_cp_bn(r_d, res, BN_NIST_224_TOP); r->top = BN_NIST_224_TOP; bn_correct_top(r); return 1; } #define nist_set_256(to, from, a1, a2, a3, a4, a5, a6, a7, a8) \ { \ bn_cp_32(to, 0, from, (a8) - 8) \ bn_cp_32(to, 1, from, (a7) - 8) \ bn_cp_32(to, 2, from, (a6) - 8) \ bn_cp_32(to, 3, from, (a5) - 8) \ bn_cp_32(to, 4, from, (a4) - 8) \ bn_cp_32(to, 5, from, (a3) - 8) \ bn_cp_32(to, 6, from, (a2) - 8) \ bn_cp_32(to, 7, from, (a1) - 8) \ } int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) { int i, top = a->top; int carry = 0; register BN_ULONG *a_d = a->d, *r_d; union { BN_ULONG bn[BN_NIST_256_TOP]; unsigned int ui[BN_NIST_256_TOP * sizeof(BN_ULONG) / sizeof(unsigned int)]; } buf; BN_ULONG c_d[BN_NIST_256_TOP], *res; uintptr_t mask; union { bn_addsub_f f; uintptr_t p; } u; static const BIGNUM _bignum_nist_p_256_sqr = { (BN_ULONG *)_nist_p_256_sqr, sizeof(_nist_p_256_sqr) / sizeof(_nist_p_256_sqr[0]), sizeof(_nist_p_256_sqr) / sizeof(_nist_p_256_sqr[0]), 0, BN_FLG_STATIC_DATA }; field = &_bignum_nist_p_256; /* just to make sure */ if (BN_is_negative(a) || BN_ucmp(a, &_bignum_nist_p_256_sqr) >= 0) return BN_nnmod(r, a, field, ctx); i = BN_ucmp(field, a); if (i == 0) { BN_zero(r); return 1; } else if (i > 0) return (r == a) ? 1 : (BN_copy(r, a) != NULL); if (r != a) { if (!bn_wexpand(r, BN_NIST_256_TOP)) return 0; r_d = r->d; nist_cp_bn(r_d, a_d, BN_NIST_256_TOP); } else r_d = a_d; nist_cp_bn_0(buf.bn, a_d + BN_NIST_256_TOP, top - BN_NIST_256_TOP, BN_NIST_256_TOP); #if defined(NIST_INT64) { NIST_INT64 acc; /* accumulator */ unsigned int *rp = (unsigned int *)r_d; const unsigned int *bp = (const unsigned int *)buf.ui; acc = rp[0]; acc += bp[8 - 8]; acc += bp[9 - 8]; acc -= bp[11 - 8]; acc -= bp[12 - 8]; acc -= bp[13 - 8]; acc -= bp[14 - 8]; rp[0] = (unsigned int)acc; acc >>= 32; acc += rp[1]; acc += bp[9 - 8]; acc += bp[10 - 8]; acc -= bp[12 - 8]; acc -= bp[13 - 8]; acc -= bp[14 - 8]; acc -= bp[15 - 8]; rp[1] = (unsigned int)acc; acc >>= 32; acc += rp[2]; acc += bp[10 - 8]; acc += bp[11 - 8]; acc -= bp[13 - 8]; acc -= bp[14 - 8]; acc -= bp[15 - 8]; rp[2] = (unsigned int)acc; acc >>= 32; acc += rp[3]; acc += bp[11 - 8]; acc += bp[11 - 8]; acc += bp[12 - 8]; acc += bp[12 - 8]; acc += bp[13 - 8]; acc -= bp[15 - 8]; acc -= bp[8 - 8]; acc -= bp[9 - 8]; rp[3] = (unsigned int)acc; acc >>= 32; acc += rp[4]; acc += bp[12 - 8]; acc += bp[12 - 8]; acc += bp[13 - 8]; acc += bp[13 - 8]; acc += bp[14 - 8]; acc -= bp[9 - 8]; acc -= bp[10 - 8]; rp[4] = (unsigned int)acc; acc >>= 32; acc += rp[5]; acc += bp[13 - 8]; acc += bp[13 - 8]; acc += bp[14 - 8]; acc += bp[14 - 8]; acc += bp[15 - 8]; acc -= bp[10 - 8]; acc -= bp[11 - 8]; rp[5] = (unsigned int)acc; acc >>= 32; acc += rp[6]; acc += bp[14 - 8]; acc += bp[14 - 8]; acc += bp[15 - 8]; acc += bp[15 - 8]; acc += bp[14 - 8]; acc += bp[13 - 8]; acc -= bp[8 - 8]; acc -= bp[9 - 8]; rp[6] = (unsigned int)acc; acc >>= 32; acc += rp[7]; acc += bp[15 - 8]; acc += bp[15 - 8]; acc += bp[15 - 8]; acc += bp[8 - 8]; acc -= bp[10 - 8]; acc -= bp[11 - 8]; acc -= bp[12 - 8]; acc -= bp[13 - 8]; rp[7] = (unsigned int)acc; carry = (int)(acc >> 32); } #else { BN_ULONG t_d[BN_NIST_256_TOP]; /*S1*/ nist_set_256(t_d, buf.bn, 15, 14, 13, 12, 11, 0, 0, 0); /*S2*/ nist_set_256(c_d, buf.bn, 0, 15, 14, 13, 12, 0, 0, 0); carry = (int)bn_add_words(t_d, t_d, c_d, BN_NIST_256_TOP); /* left shift */ { register BN_ULONG *ap, t, c; ap = t_d; c = 0; for (i = BN_NIST_256_TOP; i != 0; --i) { t = *ap; *(ap++) = ((t << 1) | c) & BN_MASK2; c = (t & BN_TBIT) ? 1 : 0; } carry <<= 1; carry |= c; } carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP); /*S3*/ nist_set_256(t_d, buf.bn, 15, 14, 0, 0, 0, 10, 9, 8); carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP); /*S4*/ nist_set_256(t_d, buf.bn, 8, 13, 15, 14, 13, 11, 10, 9); carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP); /*D1*/ nist_set_256(t_d, buf.bn, 10, 8, 0, 0, 0, 13, 12, 11); carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP); /*D2*/ nist_set_256(t_d, buf.bn, 11, 9, 0, 0, 15, 14, 13, 12); carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP); /*D3*/ nist_set_256(t_d, buf.bn, 12, 0, 10, 9, 8, 15, 14, 13); carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP); /*D4*/ nist_set_256(t_d, buf.bn, 13, 0, 11, 10, 9, 0, 15, 14); carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP); } #endif /* see BN_nist_mod_224 for explanation */ u.f = bn_sub_words; if (carry > 0) carry = (int)bn_sub_words(r_d, r_d, _nist_p_256[carry - 1], BN_NIST_256_TOP); else if (carry < 0) { carry = (int)bn_add_words(r_d, r_d, _nist_p_256[-carry - 1], BN_NIST_256_TOP); mask = 0 - (uintptr_t)carry; u.p = ((uintptr_t)bn_sub_words & mask) | ((uintptr_t)bn_add_words & ~mask); } else carry = 1; mask = 0 - (uintptr_t)(*u.f)(c_d, r_d, _nist_p_256[0], BN_NIST_256_TOP); mask &= 0 - (uintptr_t)carry; res = c_d; res = (BN_ULONG *)(((uintptr_t)res & ~mask) | ((uintptr_t)r_d & mask)); nist_cp_bn(r_d, res, BN_NIST_256_TOP); r->top = BN_NIST_256_TOP; bn_correct_top(r); return 1; } #define nist_set_384(to,from,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \ { \ bn_cp_32(to, 0, from, (a12) - 12) \ bn_cp_32(to, 1, from, (a11) - 12) \ bn_cp_32(to, 2, from, (a10) - 12) \ bn_cp_32(to, 3, from, (a9) - 12) \ bn_cp_32(to, 4, from, (a8) - 12) \ bn_cp_32(to, 5, from, (a7) - 12) \ bn_cp_32(to, 6, from, (a6) - 12) \ bn_cp_32(to, 7, from, (a5) - 12) \ bn_cp_32(to, 8, from, (a4) - 12) \ bn_cp_32(to, 9, from, (a3) - 12) \ bn_cp_32(to, 10, from, (a2) - 12) \ bn_cp_32(to, 11, from, (a1) - 12) \ } int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) { int i, top = a->top; int carry = 0; register BN_ULONG *r_d, *a_d = a->d; union { BN_ULONG bn[BN_NIST_384_TOP]; unsigned int ui[BN_NIST_384_TOP * sizeof(BN_ULONG) / sizeof(unsigned int)]; } buf; BN_ULONG c_d[BN_NIST_384_TOP], *res; uintptr_t mask; union { bn_addsub_f f; uintptr_t p; } u; static const BIGNUM _bignum_nist_p_384_sqr = { (BN_ULONG *)_nist_p_384_sqr, sizeof(_nist_p_384_sqr) / sizeof(_nist_p_384_sqr[0]), sizeof(_nist_p_384_sqr) / sizeof(_nist_p_384_sqr[0]), 0, BN_FLG_STATIC_DATA }; field = &_bignum_nist_p_384; /* just to make sure */ if (BN_is_negative(a) || BN_ucmp(a, &_bignum_nist_p_384_sqr) >= 0) return BN_nnmod(r, a, field, ctx); i = BN_ucmp(field, a); if (i == 0) { BN_zero(r); return 1; } else if (i > 0) return (r == a) ? 1 : (BN_copy(r, a) != NULL); if (r != a) { if (!bn_wexpand(r, BN_NIST_384_TOP)) return 0; r_d = r->d; nist_cp_bn(r_d, a_d, BN_NIST_384_TOP); } else r_d = a_d; nist_cp_bn_0(buf.bn, a_d + BN_NIST_384_TOP, top - BN_NIST_384_TOP, BN_NIST_384_TOP); #if defined(NIST_INT64) { NIST_INT64 acc; /* accumulator */ unsigned int *rp = (unsigned int *)r_d; const unsigned int *bp = (const unsigned int *)buf.ui; acc = rp[0]; acc += bp[12 - 12]; acc += bp[21 - 12]; acc += bp[20 - 12]; acc -= bp[23 - 12]; rp[0] = (unsigned int)acc; acc >>= 32; acc += rp[1]; acc += bp[13 - 12]; acc += bp[22 - 12]; acc += bp[23 - 12]; acc -= bp[12 - 12]; acc -= bp[20 - 12]; rp[1] = (unsigned int)acc; acc >>= 32; acc += rp[2]; acc += bp[14 - 12]; acc += bp[23 - 12]; acc -= bp[13 - 12]; acc -= bp[21 - 12]; rp[2] = (unsigned int)acc; acc >>= 32; acc += rp[3]; acc += bp[15 - 12]; acc += bp[12 - 12]; acc += bp[20 - 12]; acc += bp[21 - 12]; acc -= bp[14 - 12]; acc -= bp[22 - 12]; acc -= bp[23 - 12]; rp[3] = (unsigned int)acc; acc >>= 32; acc += rp[4]; acc += bp[21 - 12]; acc += bp[21 - 12]; acc += bp[16 - 12]; acc += bp[13 - 12]; acc += bp[12 - 12]; acc += bp[20 - 12]; acc += bp[22 - 12]; acc -= bp[15 - 12]; acc -= bp[23 - 12]; acc -= bp[23 - 12]; rp[4] = (unsigned int)acc; acc >>= 32; acc += rp[5]; acc += bp[22 - 12]; acc += bp[22 - 12]; acc += bp[17 - 12]; acc += bp[14 - 12]; acc += bp[13 - 12]; acc += bp[21 - 12]; acc += bp[23 - 12]; acc -= bp[16 - 12]; rp[5] = (unsigned int)acc; acc >>= 32; acc += rp[6]; acc += bp[23 - 12]; acc += bp[23 - 12]; acc += bp[18 - 12]; acc += bp[15 - 12]; acc += bp[14 - 12]; acc += bp[22 - 12]; acc -= bp[17 - 12]; rp[6] = (unsigned int)acc; acc >>= 32; acc += rp[7]; acc += bp[19 - 12]; acc += bp[16 - 12]; acc += bp[15 - 12]; acc += bp[23 - 12]; acc -= bp[18 - 12]; rp[7] = (unsigned int)acc; acc >>= 32; acc += rp[8]; acc += bp[20 - 12]; acc += bp[17 - 12]; acc += bp[16 - 12]; acc -= bp[19 - 12]; rp[8] = (unsigned int)acc; acc >>= 32; acc += rp[9]; acc += bp[21 - 12]; acc += bp[18 - 12]; acc += bp[17 - 12]; acc -= bp[20 - 12]; rp[9] = (unsigned int)acc; acc >>= 32; acc += rp[10]; acc += bp[22 - 12]; acc += bp[19 - 12]; acc += bp[18 - 12]; acc -= bp[21 - 12]; rp[10] = (unsigned int)acc; acc >>= 32; acc += rp[11]; acc += bp[23 - 12]; acc += bp[20 - 12]; acc += bp[19 - 12]; acc -= bp[22 - 12]; rp[11] = (unsigned int)acc; carry = (int)(acc >> 32); } #else { BN_ULONG t_d[BN_NIST_384_TOP]; /*S1*/ nist_set_256(t_d, buf.bn, 0, 0, 0, 0, 0, 23 - 4, 22 - 4, 21 - 4); /* left shift */ { register BN_ULONG *ap, t, c; ap = t_d; c = 0; for (i = 3; i != 0; --i) { t= *ap; *(ap++) = ((t << 1)|c) & BN_MASK2; c = (t & BN_TBIT) ? 1 : 0; } *ap = c; } carry = (int)bn_add_words(r_d + (128 / BN_BITS2), r_d + (128 / BN_BITS2), t_d, BN_NIST_256_TOP); /*S2 */ carry += (int)bn_add_words(r_d, r_d, buf.bn, BN_NIST_384_TOP); /*S3*/ nist_set_384(t_d, buf.bn, 20, 19, 18, 17, 16, 15, 14, 13, 12, 23, 22, 21); carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP); /*S4*/ nist_set_384(t_d, buf.bn, 19, 18, 17, 16, 15, 14, 13, 12, 20, 0, 23, 0); carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP); /*S5*/ nist_set_384(t_d, buf.bn, 0,0, 0,0, 23, 22, 21, 20, 0,0, 0, 0); carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP); /*S6*/ nist_set_384(t_d, buf.bn, 0,0, 0,0, 0,0, 23, 22, 21, 0,0, 20); carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP); /*D1*/ nist_set_384(t_d, buf.bn, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 23); carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP); /*D2*/ nist_set_384(t_d, buf.bn, 0,0, 0,0, 0,0, 0,23, 22, 21, 20, 0); carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP); /*D3*/ nist_set_384(t_d, buf.bn, 0,0, 0,0, 0,0, 0,23, 23, 0,0, 0); carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP); } #endif /* see BN_nist_mod_224 for explanation */ u.f = bn_sub_words; if (carry > 0) carry = (int)bn_sub_words(r_d, r_d, _nist_p_384[carry - 1], BN_NIST_384_TOP); else if (carry < 0) { carry = (int)bn_add_words(r_d, r_d, _nist_p_384[-carry - 1], BN_NIST_384_TOP); mask = 0 - (uintptr_t)carry; u.p = ((uintptr_t)bn_sub_words & mask) | ((uintptr_t)bn_add_words & ~mask); } else carry = 1; mask = 0 - (uintptr_t)(*u.f)(c_d, r_d, _nist_p_384[0], BN_NIST_384_TOP); mask &= 0 - (uintptr_t)carry; res = c_d; res = (BN_ULONG *)(((uintptr_t)res & ~mask) | ((uintptr_t)r_d & mask)); nist_cp_bn(r_d, res, BN_NIST_384_TOP); r->top = BN_NIST_384_TOP; bn_correct_top(r); return 1; } #define BN_NIST_521_RSHIFT (521%BN_BITS2) #define BN_NIST_521_LSHIFT (BN_BITS2-BN_NIST_521_RSHIFT) #define BN_NIST_521_TOP_MASK ((BN_ULONG)BN_MASK2>>BN_NIST_521_LSHIFT) int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) { int top = a->top, i; BN_ULONG *r_d, *a_d = a->d, t_d[BN_NIST_521_TOP], val, tmp, *res; uintptr_t mask; static const BIGNUM _bignum_nist_p_521_sqr = { (BN_ULONG *)_nist_p_521_sqr, sizeof(_nist_p_521_sqr) / sizeof(_nist_p_521_sqr[0]), sizeof(_nist_p_521_sqr) / sizeof(_nist_p_521_sqr[0]), 0, BN_FLG_STATIC_DATA }; field = &_bignum_nist_p_521; /* just to make sure */ if (BN_is_negative(a) || BN_ucmp(a, &_bignum_nist_p_521_sqr) >= 0) return BN_nnmod(r, a, field, ctx); i = BN_ucmp(field, a); if (i == 0) { BN_zero(r); return 1; } else if (i > 0) return (r == a) ? 1 : (BN_copy(r, a) != NULL); if (r != a) { if (!bn_wexpand(r, BN_NIST_521_TOP)) return 0; r_d = r->d; nist_cp_bn(r_d, a_d, BN_NIST_521_TOP); } else r_d = a_d; /* upper 521 bits, copy ... */ nist_cp_bn_0(t_d, a_d + (BN_NIST_521_TOP - 1), top - (BN_NIST_521_TOP - 1), BN_NIST_521_TOP); /* ... and right shift */ for (val = t_d[0], i = 0; i < BN_NIST_521_TOP - 1; i++) { tmp = val >> BN_NIST_521_RSHIFT; val = t_d[i + 1]; t_d[i] = (tmp | val << BN_NIST_521_LSHIFT) & BN_MASK2; } t_d[i] = val >> BN_NIST_521_RSHIFT; /* lower 521 bits */ r_d[i] &= BN_NIST_521_TOP_MASK; bn_add_words(r_d, r_d, t_d, BN_NIST_521_TOP); mask = 0 - (uintptr_t)bn_sub_words(t_d, r_d, _nist_p_521, BN_NIST_521_TOP); res = t_d; res = (BN_ULONG *)(((uintptr_t)res & ~mask) | ((uintptr_t)r_d & mask)); nist_cp_bn(r_d, res, BN_NIST_521_TOP); r->top = BN_NIST_521_TOP; bn_correct_top(r); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_add.c0000644000175000017500000001543212360020705020232 0ustar /* $OpenBSD: bn_add.c,v 1.8 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include "bn_lcl.h" /* r can == a or b */ int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) { const BIGNUM *tmp; int a_neg = a->neg, ret; bn_check_top(a); bn_check_top(b); /* a + b a+b * a + -b a-b * -a + b b-a * -a + -b -(a+b) */ if (a_neg ^ b->neg) { /* only one is negative */ if (a_neg) { tmp = a; a = b; b = tmp; } /* we are now a - b */ if (BN_ucmp(a, b) < 0) { if (!BN_usub(r, b, a)) return (0); r->neg = 1; } else { if (!BN_usub(r, a, b)) return (0); r->neg = 0; } return (1); } ret = BN_uadd(r, a, b); r->neg = a_neg; bn_check_top(r); return ret; } /* unsigned add of b to a */ int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) { int max, min, dif; BN_ULONG *ap, *bp, *rp, carry, t1, t2; const BIGNUM *tmp; bn_check_top(a); bn_check_top(b); if (a->top < b->top) { tmp = a; a = b; b = tmp; } max = a->top; min = b->top; dif = max - min; if (bn_wexpand(r, max + 1) == NULL) return 0; r->top = max; ap = a->d; bp = b->d; rp = r->d; carry = bn_add_words(rp, ap, bp, min); rp += min; ap += min; bp += min; if (carry) { while (dif) { dif--; t1 = *(ap++); t2 = (t1 + 1) & BN_MASK2; *(rp++) = t2; if (t2) { carry = 0; break; } } if (carry) { /* carry != 0 => dif == 0 */ *rp = 1; r->top++; } } if (dif && rp != ap) while (dif--) /* copy remaining words if ap != rp */ *(rp++) = *(ap++); r->neg = 0; bn_check_top(r); return 1; } /* unsigned subtraction of b from a, a must be larger than b. */ int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) { int max, min, dif; register BN_ULONG t1, t2, *ap, *bp, *rp; int i, carry; bn_check_top(a); bn_check_top(b); max = a->top; min = b->top; dif = max - min; if (dif < 0) /* hmm... should not be happening */ { BNerr(BN_F_BN_USUB, BN_R_ARG2_LT_ARG3); return (0); } if (bn_wexpand(r, max) == NULL) return (0); ap = a->d; bp = b->d; rp = r->d; #if 1 carry = 0; for (i = min; i != 0; i--) { t1= *(ap++); t2= *(bp++); if (carry) { carry = (t1 <= t2); t1 = (t1 - t2 - 1)&BN_MASK2; } else { carry = (t1 < t2); t1 = (t1 - t2)&BN_MASK2; } *(rp++) = t1&BN_MASK2; } #else carry = bn_sub_words(rp, ap, bp, min); ap += min; bp += min; rp += min; #endif if (carry) /* subtracted */ { if (!dif) /* error: a < b */ return 0; while (dif) { dif--; t1 = *(ap++); t2 = (t1 - 1)&BN_MASK2; *(rp++) = t2; if (t1) break; } } #if 0 memcpy(rp, ap, sizeof(*rp)*(max - i)); #else if (rp != ap) { for (;;) { if (!dif--) break; rp[0] = ap[0]; if (!dif--) break; rp[1] = ap[1]; if (!dif--) break; rp[2] = ap[2]; if (!dif--) break; rp[3] = ap[3]; rp += 4; ap += 4; } } #endif r->top = max; r->neg = 0; bn_correct_top(r); return (1); } int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) { int max; int add = 0, neg = 0; const BIGNUM *tmp; bn_check_top(a); bn_check_top(b); /* a - b a-b * a - -b a+b * -a - b -(a+b) * -a - -b b-a */ if (a->neg) { if (b->neg) { tmp = a; a = b; b = tmp; } else { add = 1; neg = 1; } } else { if (b->neg) { add = 1; neg = 0; } } if (add) { if (!BN_uadd(r, a, b)) return (0); r->neg = neg; return (1); } /* We are actually doing a - b :-) */ max = (a->top > b->top) ? a->top : b->top; if (bn_wexpand(r, max) == NULL) return (0); if (BN_ucmp(a, b) < 0) { if (!BN_usub(r, b, a)) return (0); r->neg = 1; } else { if (!BN_usub(r, a, b)) return (0); r->neg = 0; } bn_check_top(r); return (1); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_depr.c0000644000175000017500000000775312360020705020443 0ustar /* $OpenBSD: bn_depr.c,v 1.5 2014/07/10 22:45:56 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* Support for deprecated functions goes here - static linkage will only slurp * this code if applications are using them directly. */ #include #include #include #include #include "bn_lcl.h" #ifndef OPENSSL_NO_DEPRECATED BIGNUM * BN_generate_prime(BIGNUM *ret, int bits, int safe, const BIGNUM *add, const BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg) { BN_GENCB cb; BIGNUM *rnd = NULL; int found = 0; BN_GENCB_set_old(&cb, callback, cb_arg); if (ret == NULL) { if ((rnd = BN_new()) == NULL) goto err; } else rnd = ret; if (!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb)) goto err; /* we have a prime :-) */ found = 1; err: if (!found && (ret == NULL) && (rnd != NULL)) BN_free(rnd); return (found ? rnd : NULL); } int BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int, int, void *), BN_CTX *ctx_passed, void *cb_arg) { BN_GENCB cb; BN_GENCB_set_old(&cb, callback, cb_arg); return BN_is_prime_ex(a, checks, ctx_passed, &cb); } int BN_is_prime_fasttest(const BIGNUM *a, int checks, void (*callback)(int, int, void *), BN_CTX *ctx_passed, void *cb_arg, int do_trial_division) { BN_GENCB cb; BN_GENCB_set_old(&cb, callback, cb_arg); return BN_is_prime_fasttest_ex(a, checks, ctx_passed, do_trial_division, &cb); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_mul.c0000644000175000017500000006347312360020705020307 0ustar /* $OpenBSD: bn_mul.c,v 1.18 2014/07/10 22:45:56 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #ifndef BN_DEBUG # undef NDEBUG /* avoid conflicting definitions */ # define NDEBUG #endif #include #include #include #include #include "bn_lcl.h" #if defined(OPENSSL_NO_ASM) || !defined(OPENSSL_BN_ASM_PART_WORDS) /* Here follows specialised variants of bn_add_words() and bn_sub_words(). They have the property performing operations on arrays of different sizes. The sizes of those arrays is expressed through cl, which is the common length ( basicall, min(len(a),len(b)) ), and dl, which is the delta between the two lengths, calculated as len(a)-len(b). All lengths are the number of BN_ULONGs... For the operations that require a result array as parameter, it must have the length cl+abs(dl). These functions should probably end up in bn_asm.c as soon as there are assembler counterparts for the systems that use assembler files. */ BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int cl, int dl) { BN_ULONG c, t; assert(cl >= 0); c = bn_sub_words(r, a, b, cl); if (dl == 0) return c; r += cl; a += cl; b += cl; if (dl < 0) { #ifdef BN_COUNT fprintf(stderr, " bn_sub_part_words %d + %d (dl < 0, c = %d)\n", cl, dl, c); #endif for (;;) { t = b[0]; r[0] = (0 - t - c) & BN_MASK2; if (t != 0) c = 1; if (++dl >= 0) break; t = b[1]; r[1] = (0 - t - c) & BN_MASK2; if (t != 0) c = 1; if (++dl >= 0) break; t = b[2]; r[2] = (0 - t - c) & BN_MASK2; if (t != 0) c = 1; if (++dl >= 0) break; t = b[3]; r[3] = (0 - t - c) & BN_MASK2; if (t != 0) c = 1; if (++dl >= 0) break; b += 4; r += 4; } } else { int save_dl = dl; #ifdef BN_COUNT fprintf(stderr, " bn_sub_part_words %d + %d (dl > 0, c = %d)\n", cl, dl, c); #endif while (c) { t = a[0]; r[0] = (t - c) & BN_MASK2; if (t != 0) c = 0; if (--dl <= 0) break; t = a[1]; r[1] = (t - c) & BN_MASK2; if (t != 0) c = 0; if (--dl <= 0) break; t = a[2]; r[2] = (t - c) & BN_MASK2; if (t != 0) c = 0; if (--dl <= 0) break; t = a[3]; r[3] = (t - c) & BN_MASK2; if (t != 0) c = 0; if (--dl <= 0) break; save_dl = dl; a += 4; r += 4; } if (dl > 0) { #ifdef BN_COUNT fprintf(stderr, " bn_sub_part_words %d + %d (dl > 0, c == 0)\n", cl, dl); #endif if (save_dl > dl) { switch (save_dl - dl) { case 1: r[1] = a[1]; if (--dl <= 0) break; case 2: r[2] = a[2]; if (--dl <= 0) break; case 3: r[3] = a[3]; if (--dl <= 0) break; } a += 4; r += 4; } } if (dl > 0) { #ifdef BN_COUNT fprintf(stderr, " bn_sub_part_words %d + %d (dl > 0, copy)\n", cl, dl); #endif for (;;) { r[0] = a[0]; if (--dl <= 0) break; r[1] = a[1]; if (--dl <= 0) break; r[2] = a[2]; if (--dl <= 0) break; r[3] = a[3]; if (--dl <= 0) break; a += 4; r += 4; } } } return c; } #endif BN_ULONG bn_add_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int cl, int dl) { BN_ULONG c, l, t; assert(cl >= 0); c = bn_add_words(r, a, b, cl); if (dl == 0) return c; r += cl; a += cl; b += cl; if (dl < 0) { int save_dl = dl; #ifdef BN_COUNT fprintf(stderr, " bn_add_part_words %d + %d (dl < 0, c = %d)\n", cl, dl, c); #endif while (c) { l = (c + b[0]) & BN_MASK2; c = (l < c); r[0] = l; if (++dl >= 0) break; l = (c + b[1]) & BN_MASK2; c = (l < c); r[1] = l; if (++dl >= 0) break; l = (c + b[2]) & BN_MASK2; c = (l < c); r[2] = l; if (++dl >= 0) break; l = (c + b[3]) & BN_MASK2; c = (l < c); r[3] = l; if (++dl >= 0) break; save_dl = dl; b += 4; r += 4; } if (dl < 0) { #ifdef BN_COUNT fprintf(stderr, " bn_add_part_words %d + %d (dl < 0, c == 0)\n", cl, dl); #endif if (save_dl < dl) { switch (dl - save_dl) { case 1: r[1] = b[1]; if (++dl >= 0) break; case 2: r[2] = b[2]; if (++dl >= 0) break; case 3: r[3] = b[3]; if (++dl >= 0) break; } b += 4; r += 4; } } if (dl < 0) { #ifdef BN_COUNT fprintf(stderr, " bn_add_part_words %d + %d (dl < 0, copy)\n", cl, dl); #endif for (;;) { r[0] = b[0]; if (++dl >= 0) break; r[1] = b[1]; if (++dl >= 0) break; r[2] = b[2]; if (++dl >= 0) break; r[3] = b[3]; if (++dl >= 0) break; b += 4; r += 4; } } } else { int save_dl = dl; #ifdef BN_COUNT fprintf(stderr, " bn_add_part_words %d + %d (dl > 0)\n", cl, dl); #endif while (c) { t = (a[0] + c) & BN_MASK2; c = (t < c); r[0] = t; if (--dl <= 0) break; t = (a[1] + c) & BN_MASK2; c = (t < c); r[1] = t; if (--dl <= 0) break; t = (a[2] + c) & BN_MASK2; c = (t < c); r[2] = t; if (--dl <= 0) break; t = (a[3] + c) & BN_MASK2; c = (t < c); r[3] = t; if (--dl <= 0) break; save_dl = dl; a += 4; r += 4; } #ifdef BN_COUNT fprintf(stderr, " bn_add_part_words %d + %d (dl > 0, c == 0)\n", cl, dl); #endif if (dl > 0) { if (save_dl > dl) { switch (save_dl - dl) { case 1: r[1] = a[1]; if (--dl <= 0) break; case 2: r[2] = a[2]; if (--dl <= 0) break; case 3: r[3] = a[3]; if (--dl <= 0) break; } a += 4; r += 4; } } if (dl > 0) { #ifdef BN_COUNT fprintf(stderr, " bn_add_part_words %d + %d (dl > 0, copy)\n", cl, dl); #endif for (;;) { r[0] = a[0]; if (--dl <= 0) break; r[1] = a[1]; if (--dl <= 0) break; r[2] = a[2]; if (--dl <= 0) break; r[3] = a[3]; if (--dl <= 0) break; a += 4; r += 4; } } } return c; } #ifdef BN_RECURSION /* Karatsuba recursive multiplication algorithm * (cf. Knuth, The Art of Computer Programming, Vol. 2) */ /* r is 2*n2 words in size, * a and b are both n2 words in size. * n2 must be a power of 2. * We multiply and return the result. * t must be 2*n2 words in size * We calculate * a[0]*b[0] * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0]) * a[1]*b[1] */ /* dnX may not be positive, but n2/2+dnX has to be */ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, int dna, int dnb, BN_ULONG *t) { int n = n2 / 2, c1, c2; int tna = n + dna, tnb = n + dnb; unsigned int neg, zero; BN_ULONG ln, lo, *p; # ifdef BN_COUNT fprintf(stderr, " bn_mul_recursive %d%+d * %d%+d\n",n2,dna,n2,dnb); # endif # ifdef BN_MUL_COMBA # if 0 if (n2 == 4) { bn_mul_comba4(r, a, b); return; } # endif /* Only call bn_mul_comba 8 if n2 == 8 and the * two arrays are complete [steve] */ if (n2 == 8 && dna == 0 && dnb == 0) { bn_mul_comba8(r, a, b); return; } # endif /* BN_MUL_COMBA */ /* Else do normal multiply */ if (n2 < BN_MUL_RECURSIVE_SIZE_NORMAL) { bn_mul_normal(r, a, n2 + dna, b, n2 + dnb); if ((dna + dnb) < 0) memset(&r[2*n2 + dna + dnb], 0, sizeof(BN_ULONG) * -(dna + dnb)); return; } /* r=(a[0]-a[1])*(b[1]-b[0]) */ c1 = bn_cmp_part_words(a, &(a[n]), tna, n - tna); c2 = bn_cmp_part_words(&(b[n]), b,tnb, tnb - n); zero = neg = 0; switch (c1 * 3 + c2) { case -4: bn_sub_part_words(t, &(a[n]), a, tna, tna - n); /* - */ bn_sub_part_words(&(t[n]), b, &(b[n]), tnb, n - tnb); /* - */ break; case -3: zero = 1; break; case -2: bn_sub_part_words(t, &(a[n]), a, tna, tna - n); /* - */ bn_sub_part_words(&(t[n]), &(b[n]), b, tnb, tnb - n); /* + */ neg = 1; break; case -1: case 0: case 1: zero = 1; break; case 2: bn_sub_part_words(t, a, &(a[n]), tna, n - tna); /* + */ bn_sub_part_words(&(t[n]), b, &(b[n]), tnb, n - tnb); /* - */ neg = 1; break; case 3: zero = 1; break; case 4: bn_sub_part_words(t, a, &(a[n]), tna, n - tna); bn_sub_part_words(&(t[n]), &(b[n]), b, tnb, tnb - n); break; } # ifdef BN_MUL_COMBA if (n == 4 && dna == 0 && dnb == 0) /* XXX: bn_mul_comba4 could take extra args to do this well */ { if (!zero) bn_mul_comba4(&(t[n2]), t, &(t[n])); else memset(&(t[n2]), 0, 8 * sizeof(BN_ULONG)); bn_mul_comba4(r, a, b); bn_mul_comba4(&(r[n2]), &(a[n]), &(b[n])); } else if (n == 8 && dna == 0 && dnb == 0) /* XXX: bn_mul_comba8 could take extra args to do this well */ { if (!zero) bn_mul_comba8(&(t[n2]), t, &(t[n])); else memset(&(t[n2]), 0, 16 * sizeof(BN_ULONG)); bn_mul_comba8(r, a, b); bn_mul_comba8(&(r[n2]), &(a[n]), &(b[n])); } else # endif /* BN_MUL_COMBA */ { p = &(t[n2 * 2]); if (!zero) bn_mul_recursive(&(t[n2]), t, &(t[n]), n, 0, 0, p); else memset(&(t[n2]), 0, n2 * sizeof(BN_ULONG)); bn_mul_recursive(r, a, b, n, 0, 0, p); bn_mul_recursive(&(r[n2]), &(a[n]), &(b[n]), n, dna, dnb, p); } /* t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign * r[10] holds (a[0]*b[0]) * r[32] holds (b[1]*b[1]) */ c1 = (int)(bn_add_words(t, r, &(r[n2]), n2)); if (neg) /* if t[32] is negative */ { c1 -= (int)(bn_sub_words(&(t[n2]), t, &(t[n2]), n2)); } else { /* Might have a carry */ c1 += (int)(bn_add_words(&(t[n2]), &(t[n2]), t, n2)); } /* t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1]) * r[10] holds (a[0]*b[0]) * r[32] holds (b[1]*b[1]) * c1 holds the carry bits */ c1 += (int)(bn_add_words(&(r[n]), &(r[n]), &(t[n2]), n2)); if (c1) { p = &(r[n + n2]); lo= *p; ln = (lo + c1) & BN_MASK2; *p = ln; /* The overflow will stop before we over write * words we should not overwrite */ if (ln < (BN_ULONG)c1) { do { p++; lo= *p; ln = (lo + 1) & BN_MASK2; *p = ln; } while (ln == 0); } } } /* n+tn is the word length * t needs to be n*4 is size, as does r */ /* tnX may not be negative but less than n */ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n, int tna, int tnb, BN_ULONG *t) { int i, j, n2 = n * 2; int c1, c2, neg; BN_ULONG ln, lo, *p; # ifdef BN_COUNT fprintf(stderr, " bn_mul_part_recursive (%d%+d) * (%d%+d)\n", n, tna, n, tnb); # endif if (n < 8) { bn_mul_normal(r, a, n + tna, b, n + tnb); return; } /* r=(a[0]-a[1])*(b[1]-b[0]) */ c1 = bn_cmp_part_words(a, &(a[n]), tna, n - tna); c2 = bn_cmp_part_words(&(b[n]), b, tnb, tnb - n); neg = 0; switch (c1 * 3 + c2) { case -4: bn_sub_part_words(t, &(a[n]), a, tna, tna - n); /* - */ bn_sub_part_words(&(t[n]), b, &(b[n]), tnb, n - tnb); /* - */ break; case -3: /* break; */ case -2: bn_sub_part_words(t, &(a[n]), a, tna, tna - n); /* - */ bn_sub_part_words(&(t[n]), &(b[n]), b, tnb, tnb - n); /* + */ neg = 1; break; case -1: case 0: case 1: /* break; */ case 2: bn_sub_part_words(t, a, &(a[n]), tna, n - tna); /* + */ bn_sub_part_words(&(t[n]), b, &(b[n]), tnb, n - tnb); /* - */ neg = 1; break; case 3: /* break; */ case 4: bn_sub_part_words(t, a, &(a[n]), tna, n - tna); bn_sub_part_words(&(t[n]), &(b[n]), b, tnb, tnb - n); break; } /* The zero case isn't yet implemented here. The speedup would probably be negligible. */ # if 0 if (n == 4) { bn_mul_comba4(&(t[n2]), t, &(t[n])); bn_mul_comba4(r, a, b); bn_mul_normal(&(r[n2]), &(a[n]), tn, &(b[n]), tn); memset(&(r[n2 + tn * 2]), 0, sizeof(BN_ULONG) * (n2 - tn * 2)); } else # endif if (n == 8) { bn_mul_comba8(&(t[n2]), t, &(t[n])); bn_mul_comba8(r, a, b); bn_mul_normal(&(r[n2]), &(a[n]), tna, &(b[n]), tnb); memset(&(r[n2 + tna + tnb]), 0, sizeof(BN_ULONG) * (n2 - tna - tnb)); } else { p = &(t[n2*2]); bn_mul_recursive(&(t[n2]), t, &(t[n]), n, 0, 0, p); bn_mul_recursive(r, a, b, n, 0, 0, p); i = n / 2; /* If there is only a bottom half to the number, * just do it */ if (tna > tnb) j = tna - i; else j = tnb - i; if (j == 0) { bn_mul_recursive(&(r[n2]), &(a[n]), &(b[n]), i, tna - i, tnb - i, p); memset(&(r[n2 + i * 2]), 0, sizeof(BN_ULONG) * (n2 - i * 2)); } else if (j > 0) /* eg, n == 16, i == 8 and tn == 11 */ { bn_mul_part_recursive(&(r[n2]), &(a[n]), &(b[n]), i, tna - i, tnb - i, p); memset(&(r[n2 + tna + tnb]), 0, sizeof(BN_ULONG) * (n2 - tna - tnb)); } else /* (j < 0) eg, n == 16, i == 8 and tn == 5 */ { memset(&(r[n2]), 0, sizeof(BN_ULONG) * n2); if (tna < BN_MUL_RECURSIVE_SIZE_NORMAL && tnb < BN_MUL_RECURSIVE_SIZE_NORMAL) { bn_mul_normal(&(r[n2]), &(a[n]), tna, &(b[n]), tnb); } else { for (;;) { i /= 2; /* these simplified conditions work * exclusively because difference * between tna and tnb is 1 or 0 */ if (i < tna || i < tnb) { bn_mul_part_recursive(&(r[n2]), &(a[n]), &(b[n]), i, tna - i, tnb - i, p); break; } else if (i == tna || i == tnb) { bn_mul_recursive(&(r[n2]), &(a[n]), &(b[n]), i, tna - i, tnb - i, p); break; } } } } } /* t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign * r[10] holds (a[0]*b[0]) * r[32] holds (b[1]*b[1]) */ c1 = (int)(bn_add_words(t, r,&(r[n2]), n2)); if (neg) /* if t[32] is negative */ { c1 -= (int)(bn_sub_words(&(t[n2]), t,&(t[n2]), n2)); } else { /* Might have a carry */ c1 += (int)(bn_add_words(&(t[n2]), &(t[n2]), t, n2)); } /* t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1]) * r[10] holds (a[0]*b[0]) * r[32] holds (b[1]*b[1]) * c1 holds the carry bits */ c1 += (int)(bn_add_words(&(r[n]), &(r[n]), &(t[n2]), n2)); if (c1) { p = &(r[n + n2]); lo= *p; ln = (lo + c1)&BN_MASK2; *p = ln; /* The overflow will stop before we over write * words we should not overwrite */ if (ln < (BN_ULONG)c1) { do { p++; lo= *p; ln = (lo + 1) & BN_MASK2; *p = ln; } while (ln == 0); } } } /* a and b must be the same size, which is n2. * r needs to be n2 words and t needs to be n2*2 */ void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, BN_ULONG *t) { int n = n2 / 2; # ifdef BN_COUNT fprintf(stderr, " bn_mul_low_recursive %d * %d\n",n2,n2); # endif bn_mul_recursive(r, a, b, n, 0, 0, &(t[0])); if (n >= BN_MUL_LOW_RECURSIVE_SIZE_NORMAL) { bn_mul_low_recursive(&(t[0]), &(a[0]), &(b[n]), n, &(t[n2])); bn_add_words(&(r[n]), &(r[n]), &(t[0]), n); bn_mul_low_recursive(&(t[0]), &(a[n]), &(b[0]), n, &(t[n2])); bn_add_words(&(r[n]), &(r[n]), &(t[0]), n); } else { bn_mul_low_normal(&(t[0]), &(a[0]), &(b[n]), n); bn_mul_low_normal(&(t[n]), &(a[n]), &(b[0]), n); bn_add_words(&(r[n]), &(r[n]), &(t[0]), n); bn_add_words(&(r[n]), &(r[n]), &(t[n]), n); } } /* a and b must be the same size, which is n2. * r needs to be n2 words and t needs to be n2*2 * l is the low words of the output. * t needs to be n2*3 */ void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2, BN_ULONG *t) { int i, n; int c1, c2; int neg, oneg, zero; BN_ULONG ll, lc, *lp, *mp; # ifdef BN_COUNT fprintf(stderr, " bn_mul_high %d * %d\n",n2,n2); # endif n = n2 / 2; /* Calculate (al-ah)*(bh-bl) */ neg = zero = 0; c1 = bn_cmp_words(&(a[0]), &(a[n]), n); c2 = bn_cmp_words(&(b[n]), &(b[0]), n); switch (c1 * 3 + c2) { case -4: bn_sub_words(&(r[0]), &(a[n]), &(a[0]), n); bn_sub_words(&(r[n]), &(b[0]), &(b[n]), n); break; case -3: zero = 1; break; case -2: bn_sub_words(&(r[0]), &(a[n]), &(a[0]), n); bn_sub_words(&(r[n]), &(b[n]), &(b[0]), n); neg = 1; break; case -1: case 0: case 1: zero = 1; break; case 2: bn_sub_words(&(r[0]), &(a[0]), &(a[n]), n); bn_sub_words(&(r[n]), &(b[0]), &(b[n]), n); neg = 1; break; case 3: zero = 1; break; case 4: bn_sub_words(&(r[0]), &(a[0]), &(a[n]), n); bn_sub_words(&(r[n]), &(b[n]), &(b[0]), n); break; } oneg = neg; /* t[10] = (a[0]-a[1])*(b[1]-b[0]) */ /* r[10] = (a[1]*b[1]) */ # ifdef BN_MUL_COMBA if (n == 8) { bn_mul_comba8(&(t[0]), &(r[0]), &(r[n])); bn_mul_comba8(r, &(a[n]), &(b[n])); } else # endif { bn_mul_recursive(&(t[0]), &(r[0]), &(r[n]), n, 0, 0, &(t[n2])); bn_mul_recursive(r, &(a[n]), &(b[n]), n, 0, 0, &(t[n2])); } /* s0 == low(al*bl) * s1 == low(ah*bh)+low((al-ah)*(bh-bl))+low(al*bl)+high(al*bl) * We know s0 and s1 so the only unknown is high(al*bl) * high(al*bl) == s1 - low(ah*bh+s0+(al-ah)*(bh-bl)) * high(al*bl) == s1 - (r[0]+l[0]+t[0]) */ if (l != NULL) { lp = &(t[n2 + n]); c1 = (int)(bn_add_words(lp, &(r[0]), &(l[0]), n)); } else { c1 = 0; lp = &(r[0]); } if (neg) neg = (int)(bn_sub_words(&(t[n2]), lp, &(t[0]), n)); else { bn_add_words(&(t[n2]), lp, &(t[0]), n); neg = 0; } if (l != NULL) { bn_sub_words(&(t[n2 + n]), &(l[n]), &(t[n2]), n); } else { lp = &(t[n2 + n]); mp = &(t[n2]); for (i = 0; i < n; i++) lp[i] = ((~mp[i]) + 1) & BN_MASK2; } /* s[0] = low(al*bl) * t[3] = high(al*bl) * t[10] = (a[0]-a[1])*(b[1]-b[0]) neg is the sign * r[10] = (a[1]*b[1]) */ /* R[10] = al*bl * R[21] = al*bl + ah*bh + (a[0]-a[1])*(b[1]-b[0]) * R[32] = ah*bh */ /* R[1]=t[3]+l[0]+r[0](+-)t[0] (have carry/borrow) * R[2]=r[0]+t[3]+r[1](+-)t[1] (have carry/borrow) * R[3]=r[1]+(carry/borrow) */ if (l != NULL) { lp = &(t[n2]); c1 = (int)(bn_add_words(lp, &(t[n2 + n]), &(l[0]), n)); } else { lp = &(t[n2 + n]); c1 = 0; } c1 += (int)(bn_add_words(&(t[n2]), lp, &(r[0]), n)); if (oneg) c1 -= (int)(bn_sub_words(&(t[n2]), &(t[n2]), &(t[0]), n)); else c1 += (int)(bn_add_words(&(t[n2]), &(t[n2]), &(t[0]), n)); c2 = (int)(bn_add_words(&(r[0]), &(r[0]), &(t[n2 + n]), n)); c2 += (int)(bn_add_words(&(r[0]), &(r[0]), &(r[n]), n)); if (oneg) c2 -= (int)(bn_sub_words(&(r[0]), &(r[0]), &(t[n]), n)); else c2 += (int)(bn_add_words(&(r[0]), &(r[0]), &(t[n]), n)); if (c1 != 0) /* Add starting at r[0], could be +ve or -ve */ { i = 0; if (c1 > 0) { lc = c1; do { ll = (r[i] + lc) & BN_MASK2; r[i++] = ll; lc = (lc > ll); } while (lc); } else { lc = -c1; do { ll = r[i]; r[i++] = (ll - lc) & BN_MASK2; lc = (lc > ll); } while (lc); } } if (c2 != 0) /* Add starting at r[1] */ { i = n; if (c2 > 0) { lc = c2; do { ll = (r[i] + lc) & BN_MASK2; r[i++] = ll; lc = (lc > ll); } while (lc); } else { lc = -c2; do { ll = r[i]; r[i++] = (ll - lc) & BN_MASK2; lc = (lc > ll); } while (lc); } } } #endif /* BN_RECURSION */ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { int ret = 0; int top, al, bl; BIGNUM *rr; #if defined(BN_MUL_COMBA) || defined(BN_RECURSION) int i; #endif #ifdef BN_RECURSION BIGNUM *t = NULL; int j = 0, k; #endif #ifdef BN_COUNT fprintf(stderr, "BN_mul %d * %d\n",a->top,b->top); #endif bn_check_top(a); bn_check_top(b); bn_check_top(r); al = a->top; bl = b->top; if ((al == 0) || (bl == 0)) { BN_zero(r); return (1); } top = al + bl; BN_CTX_start(ctx); if ((r == a) || (r == b)) { if ((rr = BN_CTX_get(ctx)) == NULL) goto err; } else rr = r; rr->neg = a->neg ^ b->neg; #if defined(BN_MUL_COMBA) || defined(BN_RECURSION) i = al - bl; #endif #ifdef BN_MUL_COMBA if (i == 0) { # if 0 if (al == 4) { if (bn_wexpand(rr, 8) == NULL) goto err; rr->top = 8; bn_mul_comba4(rr->d, a->d, b->d); goto end; } # endif if (al == 8) { if (bn_wexpand(rr, 16) == NULL) goto err; rr->top = 16; bn_mul_comba8(rr->d, a->d, b->d); goto end; } } #endif /* BN_MUL_COMBA */ #ifdef BN_RECURSION if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL)) { if (i >= -1 && i <= 1) { /* Find out the power of two lower or equal to the longest of the two numbers */ if (i >= 0) { j = BN_num_bits_word((BN_ULONG)al); } if (i == -1) { j = BN_num_bits_word((BN_ULONG)bl); } j = 1 << (j - 1); assert(j <= al || j <= bl); k = j + j; t = BN_CTX_get(ctx); if (t == NULL) goto err; if (al > j || bl > j) { if (bn_wexpand(t, k * 4) == NULL) goto err; if (bn_wexpand(rr, k * 4) == NULL) goto err; bn_mul_part_recursive(rr->d, a->d, b->d, j, al - j, bl - j, t->d); } else /* al <= j || bl <= j */ { if (bn_wexpand(t, k * 2) == NULL) goto err; if (bn_wexpand(rr, k * 2) == NULL) goto err; bn_mul_recursive(rr->d, a->d, b->d, j, al - j, bl - j, t->d); } rr->top = top; goto end; } #if 0 if (i == 1 && !BN_get_flags(b, BN_FLG_STATIC_DATA)) { BIGNUM *tmp_bn = (BIGNUM *)b; if (bn_wexpand(tmp_bn, al) == NULL) goto err; tmp_bn->d[bl] = 0; bl++; i--; } else if (i == -1 && !BN_get_flags(a, BN_FLG_STATIC_DATA)) { BIGNUM *tmp_bn = (BIGNUM *)a; if (bn_wexpand(tmp_bn, bl) == NULL) goto err; tmp_bn->d[al] = 0; al++; i++; } if (i == 0) { /* symmetric and > 4 */ /* 16 or larger */ j = BN_num_bits_word((BN_ULONG)al); j = 1 << (j - 1); k = j + j; t = BN_CTX_get(ctx); if (al == j) /* exact multiple */ { if (bn_wexpand(t, k * 2) == NULL) goto err; if (bn_wexpand(rr, k * 2) == NULL) goto err; bn_mul_recursive(rr->d, a->d, b->d, al, t->d); } else { if (bn_wexpand(t, k * 4) == NULL) goto err; if (bn_wexpand(rr, k * 4) == NULL) goto err; bn_mul_part_recursive(rr->d, a->d, b->d, al - j, j, t->d); } rr->top = top; goto end; } #endif } #endif /* BN_RECURSION */ if (bn_wexpand(rr, top) == NULL) goto err; rr->top = top; bn_mul_normal(rr->d, a->d, al, b->d, bl); #if defined(BN_MUL_COMBA) || defined(BN_RECURSION) end: #endif bn_correct_top(rr); if (r != rr) BN_copy(r, rr); ret = 1; err: bn_check_top(r); BN_CTX_end(ctx); return (ret); } void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb) { BN_ULONG *rr; #ifdef BN_COUNT fprintf(stderr, " bn_mul_normal %d * %d\n", na, nb); #endif if (na < nb) { int itmp; BN_ULONG *ltmp; itmp = na; na = nb; nb = itmp; ltmp = a; a = b; b = ltmp; } rr = &(r[na]); if (nb <= 0) { (void)bn_mul_words(r, a, na, 0); return; } else rr[0] = bn_mul_words(r, a, na, b[0]); for (;;) { if (--nb <= 0) return; rr[1] = bn_mul_add_words(&(r[1]), a, na, b[1]); if (--nb <= 0) return; rr[2] = bn_mul_add_words(&(r[2]), a, na, b[2]); if (--nb <= 0) return; rr[3] = bn_mul_add_words(&(r[3]), a, na, b[3]); if (--nb <= 0) return; rr[4] = bn_mul_add_words(&(r[4]), a, na, b[4]); rr += 4; r += 4; b += 4; } } void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) { #ifdef BN_COUNT fprintf(stderr, " bn_mul_low_normal %d * %d\n", n, n); #endif bn_mul_words(r, a, n, b[0]); for (;;) { if (--n <= 0) return; bn_mul_add_words(&(r[1]), a, n, b[1]); if (--n <= 0) return; bn_mul_add_words(&(r[2]), a, n, b[2]); if (--n <= 0) return; bn_mul_add_words(&(r[3]), a, n, b[3]); if (--n <= 0) return; bn_mul_add_words(&(r[4]), a, n, b[4]); r += 4; b += 4; } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_ctx.c0000644000175000017500000002714112360020705020300 0ustar /* $OpenBSD: bn_ctx.c,v 1.12 2014/07/10 22:45:56 jsing Exp $ */ /* Written by Ulf Moeller for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2004 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #if !defined(BN_CTX_DEBUG) && !defined(BN_DEBUG) #ifndef NDEBUG #define NDEBUG #endif #endif #include #include #include #include #include #include "bn_lcl.h" /* TODO list * * 1. Check a bunch of "(words+1)" type hacks in various bignum functions and * check they can be safely removed. * - Check +1 and other ugliness in BN_from_montgomery() * * 2. Consider allowing a BN_new_ex() that, at least, lets you specify an * appropriate 'block' size that will be honoured by bn_expand_internal() to * prevent piddly little reallocations. OTOH, profiling bignum expansions in * BN_CTX doesn't show this to be a big issue. */ /* How many bignums are in each "pool item"; */ #define BN_CTX_POOL_SIZE 16 /* The stack frame info is resizing, set a first-time expansion size; */ #define BN_CTX_START_FRAMES 32 /***********/ /* BN_POOL */ /***********/ /* A bundle of bignums that can be linked with other bundles */ typedef struct bignum_pool_item { /* The bignum values */ BIGNUM vals[BN_CTX_POOL_SIZE]; /* Linked-list admin */ struct bignum_pool_item *prev, *next; } BN_POOL_ITEM; /* A linked-list of bignums grouped in bundles */ typedef struct bignum_pool { /* Linked-list admin */ BN_POOL_ITEM *head, *current, *tail; /* Stack depth and allocation size */ unsigned used, size; } BN_POOL; static void BN_POOL_init(BN_POOL *); static void BN_POOL_finish(BN_POOL *); #ifndef OPENSSL_NO_DEPRECATED static void BN_POOL_reset(BN_POOL *); #endif static BIGNUM * BN_POOL_get(BN_POOL *); static void BN_POOL_release(BN_POOL *, unsigned int); /************/ /* BN_STACK */ /************/ /* A wrapper to manage the "stack frames" */ typedef struct bignum_ctx_stack { /* Array of indexes into the bignum stack */ unsigned int *indexes; /* Number of stack frames, and the size of the allocated array */ unsigned int depth, size; } BN_STACK; static void BN_STACK_init(BN_STACK *); static void BN_STACK_finish(BN_STACK *); #ifndef OPENSSL_NO_DEPRECATED static void BN_STACK_reset(BN_STACK *); #endif static int BN_STACK_push(BN_STACK *, unsigned int); static unsigned int BN_STACK_pop(BN_STACK *); /**********/ /* BN_CTX */ /**********/ /* The opaque BN_CTX type */ struct bignum_ctx { /* The bignum bundles */ BN_POOL pool; /* The "stack frames", if you will */ BN_STACK stack; /* The number of bignums currently assigned */ unsigned int used; /* Depth of stack overflow */ int err_stack; /* Block "gets" until an "end" (compatibility behaviour) */ int too_many; }; /* Enable this to find BN_CTX bugs */ #ifdef BN_CTX_DEBUG static const char *ctxdbg_cur = NULL; static void ctxdbg(BN_CTX *ctx) { unsigned int bnidx = 0, fpidx = 0; BN_POOL_ITEM *item = ctx->pool.head; BN_STACK *stack = &ctx->stack; fprintf(stderr, "(%08x): ", (unsigned int)ctx); while (bnidx < ctx->used) { fprintf(stderr, "%03x ", item->vals[bnidx++ % BN_CTX_POOL_SIZE].dmax); if (!(bnidx % BN_CTX_POOL_SIZE)) item = item->next; } fprintf(stderr, "\n"); bnidx = 0; fprintf(stderr, " : "); while (fpidx < stack->depth) { while (bnidx++ < stack->indexes[fpidx]) fprintf(stderr, " "); fprintf(stderr, "^^^ "); bnidx++; fpidx++; } fprintf(stderr, "\n"); } #define CTXDBG_ENTRY(str, ctx) \ do { \ ctxdbg_cur = (str); \ fprintf(stderr, "Starting %s\n", ctxdbg_cur); \ ctxdbg(ctx); \ } while(0) #define CTXDBG_EXIT(ctx) \ do { \ fprintf(stderr, "Ending %s\n", ctxdbg_cur); \ ctxdbg(ctx); \ } while(0) #define CTXDBG_RET(ctx,ret) #else #define CTXDBG_ENTRY(str, ctx) #define CTXDBG_EXIT(ctx) #define CTXDBG_RET(ctx,ret) #endif /* This function is an evil legacy and should not be used. This implementation * is WYSIWYG, though I've done my best. */ #ifndef OPENSSL_NO_DEPRECATED void BN_CTX_init(BN_CTX *ctx) { /* Assume the caller obtained the context via BN_CTX_new() and so is * trying to reset it for use. Nothing else makes sense, least of all * binary compatibility from a time when they could declare a static * variable. */ BN_POOL_reset(&ctx->pool); BN_STACK_reset(&ctx->stack); ctx->used = 0; ctx->err_stack = 0; ctx->too_many = 0; } #endif BN_CTX * BN_CTX_new(void) { BN_CTX *ret = malloc(sizeof(BN_CTX)); if (!ret) { BNerr(BN_F_BN_CTX_NEW, ERR_R_MALLOC_FAILURE); return NULL; } /* Initialise the structure */ BN_POOL_init(&ret->pool); BN_STACK_init(&ret->stack); ret->used = 0; ret->err_stack = 0; ret->too_many = 0; return ret; } void BN_CTX_free(BN_CTX *ctx) { if (ctx == NULL) return; #ifdef BN_CTX_DEBUG { BN_POOL_ITEM *pool = ctx->pool.head; fprintf(stderr, "BN_CTX_free, stack-size=%d, pool-bignums=%d\n", ctx->stack.size, ctx->pool.size); fprintf(stderr, "dmaxs: "); while (pool) { unsigned loop = 0; while (loop < BN_CTX_POOL_SIZE) fprintf(stderr, "%02x ", pool->vals[loop++].dmax); pool = pool->next; } fprintf(stderr, "\n"); } #endif BN_STACK_finish(&ctx->stack); BN_POOL_finish(&ctx->pool); free(ctx); } void BN_CTX_start(BN_CTX *ctx) { CTXDBG_ENTRY("BN_CTX_start", ctx); /* If we're already overflowing ... */ if (ctx->err_stack || ctx->too_many) ctx->err_stack++; /* (Try to) get a new frame pointer */ else if (!BN_STACK_push(&ctx->stack, ctx->used)) { BNerr(BN_F_BN_CTX_START, BN_R_TOO_MANY_TEMPORARY_VARIABLES); ctx->err_stack++; } CTXDBG_EXIT(ctx); } void BN_CTX_end(BN_CTX *ctx) { CTXDBG_ENTRY("BN_CTX_end", ctx); if (ctx->err_stack) ctx->err_stack--; else { unsigned int fp = BN_STACK_pop(&ctx->stack); /* Does this stack frame have anything to release? */ if (fp < ctx->used) BN_POOL_release(&ctx->pool, ctx->used - fp); ctx->used = fp; /* Unjam "too_many" in case "get" had failed */ ctx->too_many = 0; } CTXDBG_EXIT(ctx); } BIGNUM * BN_CTX_get(BN_CTX *ctx) { BIGNUM *ret; CTXDBG_ENTRY("BN_CTX_get", ctx); if (ctx->err_stack || ctx->too_many) return NULL; if ((ret = BN_POOL_get(&ctx->pool)) == NULL) { /* Setting too_many prevents repeated "get" attempts from * cluttering the error stack. */ ctx->too_many = 1; BNerr(BN_F_BN_CTX_GET, BN_R_TOO_MANY_TEMPORARY_VARIABLES); return NULL; } /* OK, make sure the returned bignum is "zero" */ BN_zero(ret); ctx->used++; CTXDBG_RET(ctx, ret); return ret; } /************/ /* BN_STACK */ /************/ static void BN_STACK_init(BN_STACK *st) { st->indexes = NULL; st->depth = st->size = 0; } static void BN_STACK_finish(BN_STACK *st) { if (st->size) free(st->indexes); } #ifndef OPENSSL_NO_DEPRECATED static void BN_STACK_reset(BN_STACK *st) { st->depth = 0; } #endif static int BN_STACK_push(BN_STACK *st, unsigned int idx) { if (st->depth == st->size) /* Need to expand */ { unsigned int newsize = (st->size ? (st->size * 3 / 2) : BN_CTX_START_FRAMES); unsigned int *newitems = reallocarray(NULL, newsize, sizeof(unsigned int)); if (!newitems) return 0; if (st->depth) memcpy(newitems, st->indexes, st->depth * sizeof(unsigned int)); if (st->size) free(st->indexes); st->indexes = newitems; st->size = newsize; } st->indexes[(st->depth)++] = idx; return 1; } static unsigned int BN_STACK_pop(BN_STACK *st) { return st->indexes[--(st->depth)]; } /***********/ /* BN_POOL */ /***********/ static void BN_POOL_init(BN_POOL *p) { p->head = p->current = p->tail = NULL; p->used = p->size = 0; } static void BN_POOL_finish(BN_POOL *p) { while (p->head) { unsigned int loop = 0; BIGNUM *bn = p->head->vals; while (loop++ < BN_CTX_POOL_SIZE) { if (bn->d) BN_clear_free(bn); bn++; } p->current = p->head->next; free(p->head); p->head = p->current; } } #ifndef OPENSSL_NO_DEPRECATED static void BN_POOL_reset(BN_POOL *p) { BN_POOL_ITEM *item = p->head; while (item) { unsigned int loop = 0; BIGNUM *bn = item->vals; while (loop++ < BN_CTX_POOL_SIZE) { if (bn->d) BN_clear(bn); bn++; } item = item->next; } p->current = p->head; p->used = 0; } #endif static BIGNUM * BN_POOL_get(BN_POOL *p) { if (p->used == p->size) { BIGNUM *bn; unsigned int loop = 0; BN_POOL_ITEM *item = malloc(sizeof(BN_POOL_ITEM)); if (!item) return NULL; /* Initialise the structure */ bn = item->vals; while (loop++ < BN_CTX_POOL_SIZE) BN_init(bn++); item->prev = p->tail; item->next = NULL; /* Link it in */ if (!p->head) p->head = p->current = p->tail = item; else { p->tail->next = item; p->tail = item; p->current = item; } p->size += BN_CTX_POOL_SIZE; p->used++; /* Return the first bignum from the new pool */ return item->vals; } if (!p->used) p->current = p->head; else if ((p->used % BN_CTX_POOL_SIZE) == 0) p->current = p->current->next; return p->current->vals + ((p->used++) % BN_CTX_POOL_SIZE); } static void BN_POOL_release(BN_POOL *p, unsigned int num) { unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE; p->used -= num; while (num--) { bn_check_top(p->current->vals + offset); if (!offset) { offset = BN_CTX_POOL_SIZE - 1; p->current = p->current->prev; } else offset--; } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bn/bn_prime.c0000644000175000017500000003406512360020705020621 0ustar /* $OpenBSD: bn_prime.c,v 1.9 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include "bn_lcl.h" /* NB: these functions have been "upgraded", the deprecated versions (which are * compatibility wrappers using these functions) are in bn_depr.c. * - Geoff */ /* The quick sieve algorithm approach to weeding out primes is * Philip Zimmermann's, as implemented in PGP. I have had a read of * his comments and implemented my own version. */ #include "bn_prime.h" static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1, const BIGNUM *a1_odd, int k, BN_CTX *ctx, BN_MONT_CTX *mont); static int probable_prime(BIGNUM *rnd, int bits); static int probable_prime_dh(BIGNUM *rnd, int bits, const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx); static int probable_prime_dh_safe(BIGNUM *rnd, int bits, const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx); int BN_GENCB_call(BN_GENCB *cb, int a, int b) { /* No callback means continue */ if (!cb) return 1; switch (cb->ver) { case 1: /* Deprecated-style callbacks */ if (!cb->cb.cb_1) return 1; cb->cb.cb_1(a, b, cb->arg); return 1; case 2: /* New-style callbacks */ return cb->cb.cb_2(a, b, cb); default: break; } /* Unrecognised callback type */ return 0; } int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, const BIGNUM *rem, BN_GENCB *cb) { BIGNUM *t; int found = 0; int i, j, c1 = 0; BN_CTX *ctx; int checks = BN_prime_checks_for_size(bits); ctx = BN_CTX_new(); if (ctx == NULL) goto err; BN_CTX_start(ctx); t = BN_CTX_get(ctx); if (!t) goto err; loop: /* make a random number and set the top and bottom bits */ if (add == NULL) { if (!probable_prime(ret, bits)) goto err; } else { if (safe) { if (!probable_prime_dh_safe(ret, bits, add, rem, ctx)) goto err; } else { if (!probable_prime_dh(ret, bits, add, rem, ctx)) goto err; } } /* if (BN_mod_word(ret,(BN_ULONG)3) == 1) goto loop; */ if (!BN_GENCB_call(cb, 0, c1++)) /* aborted */ goto err; if (!safe) { i = BN_is_prime_fasttest_ex(ret, checks, ctx, 0, cb); if (i == -1) goto err; if (i == 0) goto loop; } else { /* for "safe prime" generation, * check that (p-1)/2 is prime. * Since a prime is odd, We just * need to divide by 2 */ if (!BN_rshift1(t, ret)) goto err; for (i = 0; i < checks; i++) { j = BN_is_prime_fasttest_ex(ret, 1, ctx, 0, cb); if (j == -1) goto err; if (j == 0) goto loop; j = BN_is_prime_fasttest_ex(t, 1, ctx, 0, cb); if (j == -1) goto err; if (j == 0) goto loop; if (!BN_GENCB_call(cb, 2, c1 - 1)) goto err; /* We have a safe prime test pass */ } } /* we have a prime :-) */ found = 1; err: if (ctx != NULL) { BN_CTX_end(ctx); BN_CTX_free(ctx); } bn_check_top(ret); return found; } int BN_is_prime_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, BN_GENCB *cb) { return BN_is_prime_fasttest_ex(a, checks, ctx_passed, 0, cb); } int BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, int do_trial_division, BN_GENCB *cb) { int i, j, ret = -1; int k; BN_CTX *ctx = NULL; BIGNUM *A1, *A1_odd, *check; /* taken from ctx */ BN_MONT_CTX *mont = NULL; const BIGNUM *A = NULL; if (BN_cmp(a, BN_value_one()) <= 0) return 0; if (checks == BN_prime_checks) checks = BN_prime_checks_for_size(BN_num_bits(a)); /* first look for small factors */ if (!BN_is_odd(a)) /* a is even => a is prime if and only if a == 2 */ return BN_is_word(a, 2); if (do_trial_division) { for (i = 1; i < NUMPRIMES; i++) if (BN_mod_word(a, primes[i]) == 0) return 0; if (!BN_GENCB_call(cb, 1, -1)) goto err; } if (ctx_passed != NULL) ctx = ctx_passed; else if ((ctx = BN_CTX_new()) == NULL) goto err; BN_CTX_start(ctx); /* A := abs(a) */ if (a->neg) { BIGNUM *t; if ((t = BN_CTX_get(ctx)) == NULL) goto err; BN_copy(t, a); t->neg = 0; A = t; } else A = a; A1 = BN_CTX_get(ctx); A1_odd = BN_CTX_get(ctx); check = BN_CTX_get(ctx); if (check == NULL) goto err; /* compute A1 := A - 1 */ if (!BN_copy(A1, A)) goto err; if (!BN_sub_word(A1, 1)) goto err; if (BN_is_zero(A1)) { ret = 0; goto err; } /* write A1 as A1_odd * 2^k */ k = 1; while (!BN_is_bit_set(A1, k)) k++; if (!BN_rshift(A1_odd, A1, k)) goto err; /* Montgomery setup for computations mod A */ mont = BN_MONT_CTX_new(); if (mont == NULL) goto err; if (!BN_MONT_CTX_set(mont, A, ctx)) goto err; for (i = 0; i < checks; i++) { if (!BN_pseudo_rand_range(check, A1)) goto err; if (!BN_add_word(check, 1)) goto err; /* now 1 <= check < A */ j = witness(check, A, A1, A1_odd, k, ctx, mont); if (j == -1) goto err; if (j) { ret = 0; goto err; } if (!BN_GENCB_call(cb, 1, i)) goto err; } ret = 1; err: if (ctx != NULL) { BN_CTX_end(ctx); if (ctx_passed == NULL) BN_CTX_free(ctx); } if (mont != NULL) BN_MONT_CTX_free(mont); return (ret); } static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1, const BIGNUM *a1_odd, int k, BN_CTX *ctx, BN_MONT_CTX *mont) { if (!BN_mod_exp_mont(w, w, a1_odd, a, ctx, mont)) /* w := w^a1_odd mod a */ return -1; if (BN_is_one(w)) return 0; /* probably prime */ if (BN_cmp(w, a1) == 0) return 0; /* w == -1 (mod a), 'a' is probably prime */ while (--k) { if (!BN_mod_mul(w, w, w, a, ctx)) /* w := w^2 mod a */ return -1; if (BN_is_one(w)) return 1; /* 'a' is composite, otherwise a previous 'w' would * have been == -1 (mod 'a') */ if (BN_cmp(w, a1) == 0) return 0; /* w == -1 (mod a), 'a' is probably prime */ } /* If we get here, 'w' is the (a-1)/2-th power of the original 'w', * and it is neither -1 nor +1 -- so 'a' cannot be prime */ bn_check_top(w); return 1; } static int probable_prime(BIGNUM *rnd, int bits) { int i; prime_t mods[NUMPRIMES]; BN_ULONG delta, maxdelta; again: if (!BN_rand(rnd, bits, 1, 1)) return (0); /* we now have a random number 'rand' to test. */ for (i = 1; i < NUMPRIMES; i++) mods[i] = (prime_t)BN_mod_word(rnd, (BN_ULONG)primes[i]); maxdelta = BN_MASK2 - primes[NUMPRIMES - 1]; delta = 0; loop: for (i = 1; i < NUMPRIMES; i++) { /* check that rnd is not a prime and also * that gcd(rnd-1,primes) == 1 (except for 2) */ if (((mods[i] + delta) % primes[i]) <= 1) { delta += 2; if (delta > maxdelta) goto again; goto loop; } } if (!BN_add_word(rnd, delta)) return (0); bn_check_top(rnd); return (1); } static int probable_prime_dh(BIGNUM *rnd, int bits, const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx) { int i, ret = 0; BIGNUM *t1; BN_CTX_start(ctx); if ((t1 = BN_CTX_get(ctx)) == NULL) goto err; if (!BN_rand(rnd, bits, 0, 1)) goto err; /* we need ((rnd-rem) % add) == 0 */ if (!BN_mod(t1, rnd, add, ctx)) goto err; if (!BN_sub(rnd, rnd, t1)) goto err; if (rem == NULL) { if (!BN_add_word(rnd, 1)) goto err; } else { if (!BN_add(rnd, rnd, rem)) goto err; } /* we now have a random number 'rand' to test. */ loop: for (i = 1; i < NUMPRIMES; i++) { /* check that rnd is a prime */ if (BN_mod_word(rnd, (BN_ULONG)primes[i]) <= 1) { if (!BN_add(rnd, rnd, add)) goto err; goto loop; } } ret = 1; err: BN_CTX_end(ctx); bn_check_top(rnd); return (ret); } static int probable_prime_dh_safe(BIGNUM *p, int bits, const BIGNUM *padd, const BIGNUM *rem, BN_CTX *ctx) { int i, ret = 0; BIGNUM *t1, *qadd, *q; bits--; BN_CTX_start(ctx); t1 = BN_CTX_get(ctx); q = BN_CTX_get(ctx); qadd = BN_CTX_get(ctx); if (qadd == NULL) goto err; if (!BN_rshift1(qadd, padd)) goto err; if (!BN_rand(q, bits, 0, 1)) goto err; /* we need ((rnd-rem) % add) == 0 */ if (!BN_mod(t1, q,qadd, ctx)) goto err; if (!BN_sub(q, q, t1)) goto err; if (rem == NULL) { if (!BN_add_word(q, 1)) goto err; } else { if (!BN_rshift1(t1, rem)) goto err; if (!BN_add(q, q, t1)) goto err; } /* we now have a random number 'rand' to test. */ if (!BN_lshift1(p, q)) goto err; if (!BN_add_word(p, 1)) goto err; loop: for (i = 1; i < NUMPRIMES; i++) { /* check that p and q are prime */ /* check that for p and q * gcd(p-1,primes) == 1 (except for 2) */ if ((BN_mod_word(p, (BN_ULONG)primes[i]) == 0) || (BN_mod_word(q, (BN_ULONG)primes[i]) == 0)) { if (!BN_add(p, p, padd)) goto err; if (!BN_add(q, q, qadd)) goto err; goto loop; } } ret = 1; err: BN_CTX_end(ctx); bn_check_top(p); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ui/0000755000000000000000000000000012666635521020467 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/ui/ui_lib.c0000644000175000017500000004633412360020706020312 0ustar /* $OpenBSD: ui_lib.c,v 1.25 2014/07/11 08:44:49 jsing Exp $ */ /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include "ui_locl.h" IMPLEMENT_STACK_OF(UI_STRING_ST) static const UI_METHOD *default_UI_meth = NULL; UI * UI_new(void) { return (UI_new_method(NULL)); } UI * UI_new_method(const UI_METHOD *method) { UI *ret; ret = malloc(sizeof(UI)); if (ret == NULL) { UIerr(UI_F_UI_NEW_METHOD, ERR_R_MALLOC_FAILURE); return NULL; } if (method == NULL) ret->meth = UI_get_default_method(); else ret->meth = method; ret->strings = NULL; ret->user_data = NULL; ret->flags = 0; CRYPTO_new_ex_data(CRYPTO_EX_INDEX_UI, ret, &ret->ex_data); return ret; } static void free_string(UI_STRING *uis) { if (uis->flags & OUT_STRING_FREEABLE) { free((char *) uis->out_string); switch (uis->type) { case UIT_BOOLEAN: free((char *)uis->_.boolean_data.action_desc); free((char *)uis->_.boolean_data.ok_chars); free((char *)uis->_.boolean_data.cancel_chars); break; default: break; } } free(uis); } void UI_free(UI *ui) { if (ui == NULL) return; sk_UI_STRING_pop_free(ui->strings, free_string); CRYPTO_free_ex_data(CRYPTO_EX_INDEX_UI, ui, &ui->ex_data); free(ui); } static int allocate_string_stack(UI *ui) { if (ui->strings == NULL) { ui->strings = sk_UI_STRING_new_null(); if (ui->strings == NULL) { return -1; } } return 0; } static UI_STRING * general_allocate_prompt(UI *ui, const char *prompt, int prompt_freeable, enum UI_string_types type, int input_flags, char *result_buf) { UI_STRING *ret = NULL; if (prompt == NULL) { UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, ERR_R_PASSED_NULL_PARAMETER); } else if ((type == UIT_PROMPT || type == UIT_VERIFY || type == UIT_BOOLEAN) && result_buf == NULL) { UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, UI_R_NO_RESULT_BUFFER); } else if ((ret = malloc(sizeof(UI_STRING)))) { ret->out_string = prompt; ret->flags = prompt_freeable ? OUT_STRING_FREEABLE : 0; ret->input_flags = input_flags; ret->type = type; ret->result_buf = result_buf; } return ret; } static int general_allocate_string(UI *ui, const char *prompt, int prompt_freeable, enum UI_string_types type, int input_flags, char *result_buf, int minsize, int maxsize, const char *test_buf) { int ret = -1; UI_STRING *s = general_allocate_prompt(ui, prompt, prompt_freeable, type, input_flags, result_buf); if (s) { if (allocate_string_stack(ui) >= 0) { s->_.string_data.result_minsize = minsize; s->_.string_data.result_maxsize = maxsize; s->_.string_data.test_buf = test_buf; ret = sk_UI_STRING_push(ui->strings, s); /* sk_push() returns 0 on error. Let's adapt that */ if (ret <= 0) ret--; } else free_string(s); } return ret; } static int general_allocate_boolean(UI *ui, const char *prompt, const char *action_desc, const char *ok_chars, const char *cancel_chars, int prompt_freeable, enum UI_string_types type, int input_flags, char *result_buf) { int ret = -1; UI_STRING *s; const char *p; if (ok_chars == NULL) { UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN, ERR_R_PASSED_NULL_PARAMETER); } else if (cancel_chars == NULL) { UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN, ERR_R_PASSED_NULL_PARAMETER); } else { for (p = ok_chars; *p; p++) { if (strchr(cancel_chars, *p)) { UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN, UI_R_COMMON_OK_AND_CANCEL_CHARACTERS); } } s = general_allocate_prompt(ui, prompt, prompt_freeable, type, input_flags, result_buf); if (s) { if (allocate_string_stack(ui) >= 0) { s->_.boolean_data.action_desc = action_desc; s->_.boolean_data.ok_chars = ok_chars; s->_.boolean_data.cancel_chars = cancel_chars; ret = sk_UI_STRING_push(ui->strings, s); /* * sk_push() returns 0 on error. Let's adapt * that */ if (ret <= 0) ret--; } else free_string(s); } } return ret; } /* Returns the index to the place in the stack or -1 for error. Uses a direct reference to the prompt. */ int UI_add_input_string(UI *ui, const char *prompt, int flags, char *result_buf, int minsize, int maxsize) { return general_allocate_string(ui, prompt, 0, UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL); } /* Same as UI_add_input_string(), excepts it takes a copy of the prompt */ int UI_dup_input_string(UI *ui, const char *prompt, int flags, char *result_buf, int minsize, int maxsize) { char *prompt_copy = NULL; if (prompt) { prompt_copy = BUF_strdup(prompt); if (prompt_copy == NULL) { UIerr(UI_F_UI_DUP_INPUT_STRING, ERR_R_MALLOC_FAILURE); return 0; } } return general_allocate_string(ui, prompt_copy, 1, UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL); } int UI_add_verify_string(UI *ui, const char *prompt, int flags, char *result_buf, int minsize, int maxsize, const char *test_buf) { return general_allocate_string(ui, prompt, 0, UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf); } int UI_dup_verify_string(UI *ui, const char *prompt, int flags, char *result_buf, int minsize, int maxsize, const char *test_buf) { char *prompt_copy = NULL; if (prompt) { prompt_copy = BUF_strdup(prompt); if (prompt_copy == NULL) { UIerr(UI_F_UI_DUP_VERIFY_STRING, ERR_R_MALLOC_FAILURE); return -1; } } return general_allocate_string(ui, prompt_copy, 1, UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf); } int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, const char *ok_chars, const char *cancel_chars, int flags, char *result_buf) { return general_allocate_boolean(ui, prompt, action_desc, ok_chars, cancel_chars, 0, UIT_BOOLEAN, flags, result_buf); } int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, const char *ok_chars, const char *cancel_chars, int flags, char *result_buf) { char *prompt_copy = NULL; char *action_desc_copy = NULL; char *ok_chars_copy = NULL; char *cancel_chars_copy = NULL; if (prompt) { prompt_copy = BUF_strdup(prompt); if (prompt_copy == NULL) { UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE); goto err; } } if (action_desc) { action_desc_copy = BUF_strdup(action_desc); if (action_desc_copy == NULL) { UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE); goto err; } } if (ok_chars) { ok_chars_copy = BUF_strdup(ok_chars); if (ok_chars_copy == NULL) { UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE); goto err; } } if (cancel_chars) { cancel_chars_copy = BUF_strdup(cancel_chars); if (cancel_chars_copy == NULL) { UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE); goto err; } } return general_allocate_boolean(ui, prompt_copy, action_desc_copy, ok_chars_copy, cancel_chars_copy, 1, UIT_BOOLEAN, flags, result_buf); err: free(prompt_copy); free(action_desc_copy); free(ok_chars_copy); free(cancel_chars_copy); return -1; } int UI_add_info_string(UI *ui, const char *text) { return general_allocate_string(ui, text, 0, UIT_INFO, 0, NULL, 0, 0, NULL); } int UI_dup_info_string(UI *ui, const char *text) { char *text_copy = NULL; if (text) { text_copy = BUF_strdup(text); if (text_copy == NULL) { UIerr(UI_F_UI_DUP_INFO_STRING, ERR_R_MALLOC_FAILURE); return -1; } } return general_allocate_string(ui, text_copy, 1, UIT_INFO, 0, NULL, 0, 0, NULL); } int UI_add_error_string(UI *ui, const char *text) { return general_allocate_string(ui, text, 0, UIT_ERROR, 0, NULL, 0, 0, NULL); } int UI_dup_error_string(UI *ui, const char *text) { char *text_copy = NULL; if (text) { text_copy = BUF_strdup(text); if (text_copy == NULL) { UIerr(UI_F_UI_DUP_ERROR_STRING, ERR_R_MALLOC_FAILURE); return -1; } } return general_allocate_string(ui, text_copy, 1, UIT_ERROR, 0, NULL, 0, 0, NULL); } char * UI_construct_prompt(UI *ui, const char *object_desc, const char *object_name) { const char *format = "Enter %s for %s:"; char *prompt; if (ui->meth->ui_construct_prompt) return ui->meth->ui_construct_prompt(ui, object_desc, object_name); if (object_desc == NULL) return NULL; if (object_name == NULL) format = "Enter %s:"; if (asprintf(&prompt, format, object_desc, object_name) == -1) return NULL; return prompt; } void * UI_add_user_data(UI *ui, void *user_data) { void *old_data = ui->user_data; ui->user_data = user_data; return old_data; } void * UI_get0_user_data(UI *ui) { return ui->user_data; } const char * UI_get0_result(UI *ui, int i) { if (i < 0) { UIerr(UI_F_UI_GET0_RESULT, UI_R_INDEX_TOO_SMALL); return NULL; } if (i >= sk_UI_STRING_num(ui->strings)) { UIerr(UI_F_UI_GET0_RESULT, UI_R_INDEX_TOO_LARGE); return NULL; } return UI_get0_result_string(sk_UI_STRING_value(ui->strings, i)); } static int print_error(const char *str, size_t len, UI *ui) { UI_STRING uis; memset(&uis, 0, sizeof(uis)); uis.type = UIT_ERROR; uis.out_string = str; if (ui->meth->ui_write_string && !ui->meth->ui_write_string(ui, &uis)) return -1; return 0; } int UI_process(UI *ui) { int i, ok = 0; if (ui->meth->ui_open_session && !ui->meth->ui_open_session(ui)) return -1; if (ui->flags & UI_FLAG_PRINT_ERRORS) ERR_print_errors_cb( (int (*)(const char *, size_t, void *)) print_error, (void *)ui); for (i = 0; i < sk_UI_STRING_num(ui->strings); i++) { if (ui->meth->ui_write_string && !ui->meth->ui_write_string(ui, sk_UI_STRING_value(ui->strings, i))) { ok = -1; goto err; } } if (ui->meth->ui_flush) switch (ui->meth->ui_flush(ui)) { case -1: /* Interrupt/Cancel/something... */ ok = -2; goto err; case 0: /* Errors */ ok = -1; goto err; default: /* Success */ ok = 0; break; } for (i = 0; i < sk_UI_STRING_num(ui->strings); i++) { if (ui->meth->ui_read_string) { switch (ui->meth->ui_read_string(ui, sk_UI_STRING_value(ui->strings, i))) { case -1: /* Interrupt/Cancel/something... */ ok = -2; goto err; case 0: /* Errors */ ok = -1; goto err; default: /* Success */ ok = 0; break; } } } err: if (ui->meth->ui_close_session && !ui->meth->ui_close_session(ui)) return -1; return ok; } int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void)) { if (ui == NULL) { UIerr(UI_F_UI_CTRL, ERR_R_PASSED_NULL_PARAMETER); return -1; } switch (cmd) { case UI_CTRL_PRINT_ERRORS: { int save_flag = !!(ui->flags & UI_FLAG_PRINT_ERRORS); if (i) ui->flags |= UI_FLAG_PRINT_ERRORS; else ui->flags &= ~UI_FLAG_PRINT_ERRORS; return save_flag; } case UI_CTRL_IS_REDOABLE: return !!(ui->flags & UI_FLAG_REDOABLE); default: break; } UIerr(UI_F_UI_CTRL, UI_R_UNKNOWN_CONTROL_COMMAND); return -1; } int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, argl, argp, new_func, dup_func, free_func); } int UI_set_ex_data(UI *r, int idx, void *arg) { return (CRYPTO_set_ex_data(&r->ex_data, idx, arg)); } void * UI_get_ex_data(UI *r, int idx) { return (CRYPTO_get_ex_data(&r->ex_data, idx)); } void UI_set_default_method(const UI_METHOD *meth) { default_UI_meth = meth; } const UI_METHOD * UI_get_default_method(void) { if (default_UI_meth == NULL) { default_UI_meth = UI_OpenSSL(); } return default_UI_meth; } const UI_METHOD * UI_get_method(UI *ui) { return ui->meth; } const UI_METHOD * UI_set_method(UI *ui, const UI_METHOD *meth) { ui->meth = meth; return ui->meth; } UI_METHOD * UI_create_method(char *name) { UI_METHOD *ui_method = calloc(1, sizeof(UI_METHOD)); if (ui_method) ui_method->name = BUF_strdup(name); return ui_method; } /* BIG FSCKING WARNING!!!! If you use this on a statically allocated method (that is, it hasn't been allocated using UI_create_method(), you deserve anything Murphy can throw at you and more! You have been warned. */ void UI_destroy_method(UI_METHOD *ui_method) { free(ui_method->name); ui_method->name = NULL; free(ui_method); } int UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui)) { if (method) { method->ui_open_session = opener; return 0; } else return -1; } int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis)) { if (method) { method->ui_write_string = writer; return 0; } else return -1; } int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui)) { if (method) { method->ui_flush = flusher; return 0; } else return -1; } int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis)) { if (method) { method->ui_read_string = reader; return 0; } else return -1; } int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui)) { if (method) { method->ui_close_session = closer; return 0; } else return -1; } int UI_method_set_prompt_constructor(UI_METHOD *method, char *(*prompt_constructor)(UI *ui, const char *object_desc, const char *object_name)) { if (method) { method->ui_construct_prompt = prompt_constructor; return 0; } else return -1; } int (*UI_method_get_opener(UI_METHOD * method))(UI *) { if (method) return method->ui_open_session; else return NULL; } int (*UI_method_get_writer(UI_METHOD *method))(UI *, UI_STRING *) { if (method) return method->ui_write_string; else return NULL; } int (*UI_method_get_flusher(UI_METHOD *method)) (UI *) { if (method) return method->ui_flush; else return NULL; } int (*UI_method_get_reader(UI_METHOD *method))(UI *, UI_STRING *) { if (method) return method->ui_read_string; else return NULL; } int (*UI_method_get_closer(UI_METHOD *method))(UI *) { if (method) return method->ui_close_session; else return NULL; } char * (*UI_method_get_prompt_constructor(UI_METHOD *method))(UI *, const char *, const char *) { if (method) return method->ui_construct_prompt; else return NULL; } enum UI_string_types UI_get_string_type(UI_STRING *uis) { if (!uis) return UIT_NONE; return uis->type; } int UI_get_input_flags(UI_STRING *uis) { if (!uis) return 0; return uis->input_flags; } const char * UI_get0_output_string(UI_STRING *uis) { if (!uis) return NULL; return uis->out_string; } const char * UI_get0_action_string(UI_STRING *uis) { if (!uis) return NULL; switch (uis->type) { case UIT_PROMPT: case UIT_BOOLEAN: return uis->_.boolean_data.action_desc; default: return NULL; } } const char * UI_get0_result_string(UI_STRING *uis) { if (!uis) return NULL; switch (uis->type) { case UIT_PROMPT: case UIT_VERIFY: return uis->result_buf; default: return NULL; } } const char * UI_get0_test_string(UI_STRING *uis) { if (!uis) return NULL; switch (uis->type) { case UIT_VERIFY: return uis->_.string_data.test_buf; default: return NULL; } } int UI_get_result_minsize(UI_STRING *uis) { if (!uis) return -1; switch (uis->type) { case UIT_PROMPT: case UIT_VERIFY: return uis->_.string_data.result_minsize; default: return -1; } } int UI_get_result_maxsize(UI_STRING *uis) { if (!uis) return -1; switch (uis->type) { case UIT_PROMPT: case UIT_VERIFY: return uis->_.string_data.result_maxsize; default: return -1; } } int UI_set_result(UI *ui, UI_STRING *uis, const char *result) { int l = strlen(result); ui->flags &= ~UI_FLAG_REDOABLE; if (!uis) return -1; switch (uis->type) { case UIT_PROMPT: case UIT_VERIFY: if (l < uis->_.string_data.result_minsize) { ui->flags |= UI_FLAG_REDOABLE; UIerr(UI_F_UI_SET_RESULT, UI_R_RESULT_TOO_SMALL); ERR_asprintf_error_data ("You must type in %d to %d characters", uis->_.string_data.result_minsize, uis->_.string_data.result_maxsize); return -1; } if (l > uis->_.string_data.result_maxsize) { ui->flags |= UI_FLAG_REDOABLE; UIerr(UI_F_UI_SET_RESULT, UI_R_RESULT_TOO_LARGE); ERR_asprintf_error_data ("You must type in %d to %d characters", uis->_.string_data.result_minsize, uis->_.string_data.result_maxsize); return -1; } if (!uis->result_buf) { UIerr(UI_F_UI_SET_RESULT, UI_R_NO_RESULT_BUFFER); return -1; } strlcpy(uis->result_buf, result, uis->_.string_data.result_maxsize + 1); break; case UIT_BOOLEAN: { const char *p; if (!uis->result_buf) { UIerr(UI_F_UI_SET_RESULT, UI_R_NO_RESULT_BUFFER); return -1; } uis->result_buf[0] = '\0'; for (p = result; *p; p++) { if (strchr(uis->_.boolean_data.ok_chars, *p)) { uis->result_buf[0] = uis->_.boolean_data.ok_chars[0]; break; } if (strchr(uis->_.boolean_data.cancel_chars, *p)) { uis->result_buf[0] = uis->_.boolean_data.cancel_chars[0]; break; } } default: break; } } return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ui/ui_openssl.c0000644000175000017500000002630612360020706021224 0ustar /* $OpenBSD: ui_openssl.c,v 1.21 2014/06/12 15:49:31 deraadt Exp $ */ /* Written by Richard Levitte (richard@levitte.org) and others * for the OpenSSL project 2001. */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* The lowest level part of this file was previously in crypto/des/read_pwd.c, * Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #include #include "ui_locl.h" #ifndef NX509_SIG #define NX509_SIG 32 #endif /* Define globals. They are protected by a lock */ static struct sigaction savsig[NX509_SIG]; static struct termios tty_orig, tty_new; static FILE *tty_in, *tty_out; static int is_a_tty; /* Declare static functions */ static int read_till_nl(FILE *); static void recsig(int); static void pushsig(void); static void popsig(void); static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl); static int read_string(UI *ui, UI_STRING *uis); static int write_string(UI *ui, UI_STRING *uis); static int open_console(UI *ui); static int echo_console(UI *ui); static int noecho_console(UI *ui); static int close_console(UI *ui); static UI_METHOD ui_openssl = { .name = "OpenSSL default user interface", .ui_open_session = open_console, .ui_write_string = write_string, .ui_read_string = read_string, .ui_close_session = close_console, }; /* The method with all the built-in thingies */ UI_METHOD * UI_OpenSSL(void) { return &ui_openssl; } /* The following function makes sure that info and error strings are printed before any prompt. */ static int write_string(UI *ui, UI_STRING *uis) { switch (UI_get_string_type(uis)) { case UIT_ERROR: case UIT_INFO: fputs(UI_get0_output_string(uis), tty_out); fflush(tty_out); break; default: break; } return 1; } static int read_string(UI *ui, UI_STRING *uis) { int ok = 0; switch (UI_get_string_type(uis)) { case UIT_BOOLEAN: fputs(UI_get0_output_string(uis), tty_out); fputs(UI_get0_action_string(uis), tty_out); fflush(tty_out); return read_string_inner(ui, uis, UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 0); case UIT_PROMPT: fputs(UI_get0_output_string(uis), tty_out); fflush(tty_out); return read_string_inner(ui, uis, UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 1); case UIT_VERIFY: fprintf(tty_out, "Verifying - %s", UI_get0_output_string(uis)); fflush(tty_out); if ((ok = read_string_inner(ui, uis, UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 1)) <= 0) return ok; if (strcmp(UI_get0_result_string(uis), UI_get0_test_string(uis)) != 0) { fprintf(tty_out, "Verify failure\n"); fflush(tty_out); return 0; } break; default: break; } return 1; } /* Internal functions to read a string without echoing */ static int read_till_nl(FILE *in) { #define SIZE 4 char buf[SIZE + 1]; do { if (!fgets(buf, SIZE, in)) return 0; } while (strchr(buf, '\n') == NULL); return 1; } static volatile sig_atomic_t intr_signal; static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl) { static int ps; int ok; char result[BUFSIZ]; int maxsize = BUFSIZ - 1; char *p; intr_signal = 0; ok = 0; ps = 0; pushsig(); ps = 1; if (!echo && !noecho_console(ui)) goto error; ps = 2; result[0] = '\0'; p = fgets(result, maxsize, tty_in); if (!p) goto error; if (feof(tty_in)) goto error; if (ferror(tty_in)) goto error; if ((p = (char *) strchr(result, '\n')) != NULL) { if (strip_nl) *p = '\0'; } else if (!read_till_nl(tty_in)) goto error; if (UI_set_result(ui, uis, result) >= 0) ok = 1; error: if (intr_signal == SIGINT) ok = -1; if (!echo) fprintf(tty_out, "\n"); if (ps >= 2 && !echo && !echo_console(ui)) ok = 0; if (ps >= 1) popsig(); OPENSSL_cleanse(result, BUFSIZ); return ok; } /* Internal functions to open, handle and close a channel to the console. */ static int open_console(UI *ui) { CRYPTO_w_lock(CRYPTO_LOCK_UI); is_a_tty = 1; #define DEV_TTY "/dev/tty" if ((tty_in = fopen(DEV_TTY, "r")) == NULL) tty_in = stdin; if ((tty_out = fopen(DEV_TTY, "w")) == NULL) tty_out = stderr; if (tcgetattr(fileno(tty_in), &tty_orig) == -1) { if (errno == ENOTTY) is_a_tty = 0; else /* * Ariel Glenn ariel@columbia.edu reports that * solaris can return EINVAL instead. This should be * ok */ if (errno == EINVAL) is_a_tty = 0; else return 0; } return 1; } static int noecho_console(UI *ui) { memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); tty_new.c_lflag &= ~ECHO; if (is_a_tty && (tcsetattr(fileno(tty_in), TCSANOW, &tty_new) == -1)) return 0; return 1; } static int echo_console(UI *ui) { memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); tty_new.c_lflag |= ECHO; if (is_a_tty && (tcsetattr(fileno(tty_in), TCSANOW, &tty_new) == -1)) return 0; return 1; } static int close_console(UI *ui) { if (tty_in != stdin) fclose(tty_in); if (tty_out != stderr) fclose(tty_out); CRYPTO_w_unlock(CRYPTO_LOCK_UI); return 1; } /* Internal functions to handle signals and act on them */ static void pushsig(void) { int i; struct sigaction sa; memset(&sa, 0, sizeof sa); sa.sa_handler = recsig; for (i = 1; i < NX509_SIG; i++) { if (i == SIGUSR1) continue; if (i == SIGUSR2) continue; if (i == SIGKILL) /* We can't make any action on that. */ continue; sigaction(i, &sa, &savsig[i]); } signal(SIGWINCH, SIG_DFL); } static void popsig(void) { int i; for (i = 1; i < NX509_SIG; i++) { if (i == SIGUSR1) continue; if (i == SIGUSR2) continue; sigaction(i, &savsig[i], NULL); } } static void recsig(int i) { intr_signal = i; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ui/ui_util.c0000644000175000017500000000730212360020706020511 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "ui_locl.h" int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, int verify) { char buff[BUFSIZ]; int ret; ret = UI_UTIL_read_pw(buf, buff, (length > BUFSIZ) ? BUFSIZ : length, prompt, verify); OPENSSL_cleanse(buff, BUFSIZ); return (ret); } int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, int verify) { int ok = 0; UI *ui; if (size < 1) return -1; ui = UI_new(); if (ui) { ok = UI_add_input_string(ui, prompt, 0, buf, 0, size - 1); if (ok >= 0 && verify) ok = UI_add_verify_string(ui, prompt, 0, buff, 0, size - 1, buf); if (ok >= 0) ok = UI_process(ui); UI_free(ui); } if (ok > 0) ok = 0; return (ok); } /* * Old compatibility glue - see comment in ui_compat.h. */ int _ossl_old_des_read_pw_string(char *buf, int length, const char *prompt, int verify) { return UI_UTIL_read_pw_string(buf, length, prompt, verify); } int _ossl_old_des_read_pw(char *buf, char *buff, int size, const char *prompt, int verify) { return UI_UTIL_read_pw(buf, buff, size, prompt, verify); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ui/ui_locl.h0000644000175000017500000001214512360020706020473 0ustar /* $OpenBSD$ */ /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #ifndef HEADER_UI_LOCL_H #define HEADER_UI_LOCL_H #include #include #ifdef _ #undef _ #endif struct ui_method_st { char *name; /* All the functions return 1 or non-NULL for success and 0 or NULL for failure */ /* Open whatever channel for this, be it the console, an X window or whatever. This function should use the ex_data structure to save intermediate data. */ int (*ui_open_session)(UI *ui); int (*ui_write_string)(UI *ui, UI_STRING *uis); /* Flush the output. If a GUI dialog box is used, this function can be used to actually display it. */ int (*ui_flush)(UI *ui); int (*ui_read_string)(UI *ui, UI_STRING *uis); int (*ui_close_session)(UI *ui); /* Construct a prompt in a user-defined manner. object_desc is a textual short description of the object, for example "pass phrase", and object_name is the name of the object (might be a card name or a file name. The returned string shall always be allocated on the heap with malloc(), and need to be free'd with free(). */ char *(*ui_construct_prompt)(UI *ui, const char *object_desc, const char *object_name); }; struct ui_string_st { enum UI_string_types type; /* Input */ const char *out_string; /* Input */ int input_flags; /* Flags from the user */ /* The following parameters are completely irrelevant for UIT_INFO, and can therefore be set to 0 or NULL */ char *result_buf; /* Input and Output: If not NULL, user-defined with size in result_maxsize. Otherwise, it may be allocated by the UI routine, meaning result_minsize is going to be overwritten.*/ union { struct { int result_minsize; /* Input: minimum required size of the result. */ int result_maxsize; /* Input: maximum permitted size of the result */ const char *test_buf; /* Input: test string to verify against */ } string_data; struct { const char *action_desc; /* Input */ const char *ok_chars; /* Input */ const char *cancel_chars; /* Input */ } boolean_data; } _; #define OUT_STRING_FREEABLE 0x01 int flags; /* flags for internal use */ }; struct ui_st { const UI_METHOD *meth; STACK_OF(UI_STRING) *strings; /* We might want to prompt for more than one thing at a time, and with different echoing status. */ void *user_data; CRYPTO_EX_DATA ex_data; #define UI_FLAG_REDOABLE 0x0001 #define UI_FLAG_PRINT_ERRORS 0x0100 int flags; }; #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/ui/ui_err.c0000644000175000017500000001104712360020706020325 0ustar /* $OpenBSD: ui_err.c,v 1.7 2014/06/12 15:49:31 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_UI,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_UI,0,reason) static ERR_STRING_DATA UI_str_functs[] = { {ERR_FUNC(UI_F_GENERAL_ALLOCATE_BOOLEAN), "GENERAL_ALLOCATE_BOOLEAN"}, {ERR_FUNC(UI_F_GENERAL_ALLOCATE_PROMPT), "GENERAL_ALLOCATE_PROMPT"}, {ERR_FUNC(UI_F_GENERAL_ALLOCATE_STRING), "GENERAL_ALLOCATE_STRING"}, {ERR_FUNC(UI_F_UI_CTRL), "UI_ctrl"}, {ERR_FUNC(UI_F_UI_DUP_ERROR_STRING), "UI_dup_error_string"}, {ERR_FUNC(UI_F_UI_DUP_INFO_STRING), "UI_dup_info_string"}, {ERR_FUNC(UI_F_UI_DUP_INPUT_BOOLEAN), "UI_dup_input_boolean"}, {ERR_FUNC(UI_F_UI_DUP_INPUT_STRING), "UI_dup_input_string"}, {ERR_FUNC(UI_F_UI_DUP_VERIFY_STRING), "UI_dup_verify_string"}, {ERR_FUNC(UI_F_UI_GET0_RESULT), "UI_get0_result"}, {ERR_FUNC(UI_F_UI_NEW_METHOD), "UI_new_method"}, {ERR_FUNC(UI_F_UI_SET_RESULT), "UI_set_result"}, {0, NULL} }; static ERR_STRING_DATA UI_str_reasons[] = { {ERR_REASON(UI_R_COMMON_OK_AND_CANCEL_CHARACTERS), "common ok and cancel characters"}, {ERR_REASON(UI_R_INDEX_TOO_LARGE), "index too large"}, {ERR_REASON(UI_R_INDEX_TOO_SMALL), "index too small"}, {ERR_REASON(UI_R_NO_RESULT_BUFFER), "no result buffer"}, {ERR_REASON(UI_R_RESULT_TOO_LARGE), "result too large"}, {ERR_REASON(UI_R_RESULT_TOO_SMALL), "result too small"}, {ERR_REASON(UI_R_UNKNOWN_CONTROL_COMMAND), "unknown control command"}, {0, NULL} }; #endif void ERR_load_UI_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(UI_str_functs[0].error) == NULL) { ERR_load_strings(0, UI_str_functs); ERR_load_strings(0, UI_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/o_init.c0000644000175000017500000000020412360020705017674 0ustar /* $OpenBSD$ */ /* Ted Unangst places this file in the public domain. */ #include void OPENSSL_init(void) { } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs12/0000755000000000000000000000000012666635521021155 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs12/p12_decr.c0000644000175000017500000001300512360020706021121 0ustar /* $OpenBSD: p12_decr.c,v 1.12 2014/07/10 10:01:23 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include /* Encrypt/Decrypt a buffer based on password and algor, result in a * malloc'ed buffer */ unsigned char * PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, int passlen, unsigned char *in, int inlen, unsigned char **data, int *datalen, int en_de) { unsigned char *out; int outlen, i; EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX_init(&ctx); /* Decrypt data */ if (!EVP_PBE_CipherInit(algor->algorithm, pass, passlen, algor->parameter, &ctx, en_de)) { PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT, PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR); return NULL; } if (!(out = malloc(inlen + EVP_CIPHER_CTX_block_size(&ctx)))) { PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT, ERR_R_MALLOC_FAILURE); goto err; } if (!EVP_CipherUpdate(&ctx, out, &i, in, inlen)) { free(out); out = NULL; PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT, ERR_R_EVP_LIB); goto err; } outlen = i; if (!EVP_CipherFinal_ex(&ctx, out + i, &i)) { free(out); out = NULL; PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT, PKCS12_R_PKCS12_CIPHERFINAL_ERROR); goto err; } outlen += i; if (datalen) *datalen = outlen; if (data) *data = out; err: EVP_CIPHER_CTX_cleanup(&ctx); return out; } /* Decrypt an OCTET STRING and decode ASN1 structure * if zbuf set zero buffer after use. */ void * PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it, const char *pass, int passlen, ASN1_OCTET_STRING *oct, int zbuf) { unsigned char *out; const unsigned char *p; void *ret; int outlen; if (!PKCS12_pbe_crypt(algor, pass, passlen, oct->data, oct->length, &out, &outlen, 0)) { PKCS12err(PKCS12_F_PKCS12_ITEM_DECRYPT_D2I, PKCS12_R_PKCS12_PBE_CRYPT_ERROR); return NULL; } p = out; ret = ASN1_item_d2i(NULL, &p, outlen, it); if (zbuf) OPENSSL_cleanse(out, outlen); if (!ret) PKCS12err(PKCS12_F_PKCS12_ITEM_DECRYPT_D2I, PKCS12_R_DECODE_ERROR); free(out); return ret; } /* Encode ASN1 structure and encrypt, return OCTET STRING * if zbuf set zero encoding. */ ASN1_OCTET_STRING * PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *it, const char *pass, int passlen, void *obj, int zbuf) { ASN1_OCTET_STRING *oct; unsigned char *in = NULL; int inlen; if (!(oct = M_ASN1_OCTET_STRING_new ())) { PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT, ERR_R_MALLOC_FAILURE); return NULL; } inlen = ASN1_item_i2d(obj, &in, it); if (!in) { PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT, PKCS12_R_ENCODE_ERROR); return NULL; } if (!PKCS12_pbe_crypt(algor, pass, passlen, in, inlen, &oct->data, &oct->length, 1)) { PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT, PKCS12_R_ENCRYPT_ERROR); free(in); return NULL; } if (zbuf) OPENSSL_cleanse(in, inlen); free(in); return oct; } IMPLEMENT_PKCS12_STACK_OF(PKCS7) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs12/p12_crt.c0000644000175000017500000002005412360020706020776 0ustar /* $OpenBSD: p12_crt.c,v 1.14 2014/07/08 09:24:53 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ /* ==================================================================== * Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include static int pkcs12_add_bag(STACK_OF(PKCS12_SAFEBAG) **pbags, PKCS12_SAFEBAG *bag); static int copy_bag_attr(PKCS12_SAFEBAG *bag, EVP_PKEY *pkey, int nid) { int idx; X509_ATTRIBUTE *attr; idx = EVP_PKEY_get_attr_by_NID(pkey, nid, -1); if (idx < 0) return 1; attr = EVP_PKEY_get_attr(pkey, idx); if (!X509at_add1_attr(&bag->attrib, attr)) return 0; return 1; } PKCS12 * PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter, int mac_iter, int keytype) { PKCS12 *p12 = NULL; STACK_OF(PKCS7) *safes = NULL; STACK_OF(PKCS12_SAFEBAG) *bags = NULL; PKCS12_SAFEBAG *bag = NULL; int i; unsigned char keyid[EVP_MAX_MD_SIZE]; unsigned int keyidlen = 0; /* Set defaults */ if (!nid_cert) { nid_cert = NID_pbe_WithSHA1And40BitRC2_CBC; } if (!nid_key) nid_key = NID_pbe_WithSHA1And3_Key_TripleDES_CBC; if (!iter) iter = PKCS12_DEFAULT_ITER; if (!mac_iter) mac_iter = 1; if (!pkey && !cert && !ca) { PKCS12err(PKCS12_F_PKCS12_CREATE, PKCS12_R_INVALID_NULL_ARGUMENT); return NULL; } if (pkey && cert) { if (!X509_check_private_key(cert, pkey)) return NULL; X509_digest(cert, EVP_sha1(), keyid, &keyidlen); } if (cert) { bag = PKCS12_add_cert(&bags, cert); if (name && !PKCS12_add_friendlyname(bag, name, -1)) goto err; if (keyidlen && !PKCS12_add_localkeyid(bag, keyid, keyidlen)) goto err; } /* Add all other certificates */ for (i = 0; i < sk_X509_num(ca); i++) { if (!PKCS12_add_cert(&bags, sk_X509_value(ca, i))) goto err; } if (bags && !PKCS12_add_safe(&safes, bags, nid_cert, iter, pass)) goto err; sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); bags = NULL; if (pkey) { bag = PKCS12_add_key(&bags, pkey, keytype, iter, nid_key, pass); if (!bag) goto err; if (!copy_bag_attr(bag, pkey, NID_ms_csp_name)) goto err; if (!copy_bag_attr(bag, pkey, NID_LocalKeySet)) goto err; if (name && !PKCS12_add_friendlyname(bag, name, -1)) goto err; if (keyidlen && !PKCS12_add_localkeyid(bag, keyid, keyidlen)) goto err; } if (bags && !PKCS12_add_safe(&safes, bags, -1, 0, NULL)) goto err; sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); bags = NULL; p12 = PKCS12_add_safes(safes, 0); if (!p12) goto err; sk_PKCS7_pop_free(safes, PKCS7_free); safes = NULL; if ((mac_iter != -1) && !PKCS12_set_mac(p12, pass, -1, NULL, 0, mac_iter, NULL)) goto err; return p12; err: if (p12) PKCS12_free(p12); if (safes) sk_PKCS7_pop_free(safes, PKCS7_free); if (bags) sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); return NULL; } PKCS12_SAFEBAG * PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert) { PKCS12_SAFEBAG *bag = NULL; char *name; int namelen = -1; unsigned char *keyid; int keyidlen = -1; /* Add user certificate */ if (!(bag = PKCS12_x5092certbag(cert))) goto err; /* Use friendlyName and localKeyID in certificate. * (if present) */ name = (char *)X509_alias_get0(cert, &namelen); if (name && !PKCS12_add_friendlyname(bag, name, namelen)) goto err; keyid = X509_keyid_get0(cert, &keyidlen); if (keyid && !PKCS12_add_localkeyid(bag, keyid, keyidlen)) goto err; if (!pkcs12_add_bag(pbags, bag)) goto err; return bag; err: if (bag) PKCS12_SAFEBAG_free(bag); return NULL; } PKCS12_SAFEBAG * PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, EVP_PKEY *key, int key_usage, int iter, int nid_key, char *pass) { PKCS12_SAFEBAG *bag = NULL; PKCS8_PRIV_KEY_INFO *p8 = NULL; /* Make a PKCS#8 structure */ if (!(p8 = EVP_PKEY2PKCS8(key))) goto err; if (key_usage && !PKCS8_add_keyusage(p8, key_usage)) goto err; if (nid_key != -1) { bag = PKCS12_MAKE_SHKEYBAG(nid_key, pass, -1, NULL, 0, iter, p8); PKCS8_PRIV_KEY_INFO_free(p8); } else bag = PKCS12_MAKE_KEYBAG(p8); if (!bag) goto err; if (!pkcs12_add_bag(pbags, bag)) goto err; return bag; err: if (bag) PKCS12_SAFEBAG_free(bag); return NULL; } int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, int nid_safe, int iter, char *pass) { PKCS7 *p7 = NULL; int free_safes = 0; if (!*psafes) { *psafes = sk_PKCS7_new_null(); if (!*psafes) return 0; free_safes = 1; } else free_safes = 0; if (nid_safe == 0) nid_safe = NID_pbe_WithSHA1And40BitRC2_CBC; if (nid_safe == -1) p7 = PKCS12_pack_p7data(bags); else p7 = PKCS12_pack_p7encdata(nid_safe, pass, -1, NULL, 0, iter, bags); if (!p7) goto err; if (!sk_PKCS7_push(*psafes, p7)) goto err; return 1; err: if (free_safes) { sk_PKCS7_free(*psafes); *psafes = NULL; } if (p7) PKCS7_free(p7); return 0; } static int pkcs12_add_bag(STACK_OF(PKCS12_SAFEBAG) **pbags, PKCS12_SAFEBAG *bag) { int free_bags; if (!pbags) return 1; if (!*pbags) { *pbags = sk_PKCS12_SAFEBAG_new_null(); if (!*pbags) return 0; free_bags = 1; } else free_bags = 0; if (!sk_PKCS12_SAFEBAG_push(*pbags, bag)) { if (free_bags) { sk_PKCS12_SAFEBAG_free(*pbags); *pbags = NULL; } return 0; } return 1; } PKCS12 * PKCS12_add_safes(STACK_OF(PKCS7) *safes, int nid_p7) { PKCS12 *p12; if (nid_p7 <= 0) nid_p7 = NID_pkcs7_data; p12 = PKCS12_init(nid_p7); if (!p12) return NULL; if (!PKCS12_pack_authsafes(p12, safes)) { PKCS12_free(p12); return NULL; } return p12; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs12/p12_asn.c0000644000175000017500000001237612360020706020777 0ustar /* $OpenBSD: p12_asn.c,v 1.5 2014/07/08 09:24:53 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include /* PKCS#12 ASN1 module */ ASN1_SEQUENCE(PKCS12) = { ASN1_SIMPLE(PKCS12, version, ASN1_INTEGER), ASN1_SIMPLE(PKCS12, authsafes, PKCS7), ASN1_OPT(PKCS12, mac, PKCS12_MAC_DATA) } ASN1_SEQUENCE_END(PKCS12) IMPLEMENT_ASN1_FUNCTIONS(PKCS12) ASN1_SEQUENCE(PKCS12_MAC_DATA) = { ASN1_SIMPLE(PKCS12_MAC_DATA, dinfo, X509_SIG), ASN1_SIMPLE(PKCS12_MAC_DATA, salt, ASN1_OCTET_STRING), ASN1_OPT(PKCS12_MAC_DATA, iter, ASN1_INTEGER) } ASN1_SEQUENCE_END(PKCS12_MAC_DATA) IMPLEMENT_ASN1_FUNCTIONS(PKCS12_MAC_DATA) ASN1_ADB_TEMPLATE(bag_default) = ASN1_EXP(PKCS12_BAGS, value.other, ASN1_ANY, 0); ASN1_ADB(PKCS12_BAGS) = { ADB_ENTRY(NID_x509Certificate, ASN1_EXP(PKCS12_BAGS, value.x509cert, ASN1_OCTET_STRING, 0)), ADB_ENTRY(NID_x509Crl, ASN1_EXP(PKCS12_BAGS, value.x509crl, ASN1_OCTET_STRING, 0)), ADB_ENTRY(NID_sdsiCertificate, ASN1_EXP(PKCS12_BAGS, value.sdsicert, ASN1_IA5STRING, 0)), } ASN1_ADB_END(PKCS12_BAGS, 0, type, 0, &bag_default_tt, NULL); ASN1_SEQUENCE(PKCS12_BAGS) = { ASN1_SIMPLE(PKCS12_BAGS, type, ASN1_OBJECT), ASN1_ADB_OBJECT(PKCS12_BAGS), } ASN1_SEQUENCE_END(PKCS12_BAGS) IMPLEMENT_ASN1_FUNCTIONS(PKCS12_BAGS) ASN1_ADB_TEMPLATE(safebag_default) = ASN1_EXP(PKCS12_SAFEBAG, value.other, ASN1_ANY, 0); ASN1_ADB(PKCS12_SAFEBAG) = { ADB_ENTRY(NID_keyBag, ASN1_EXP(PKCS12_SAFEBAG, value.keybag, PKCS8_PRIV_KEY_INFO, 0)), ADB_ENTRY(NID_pkcs8ShroudedKeyBag, ASN1_EXP(PKCS12_SAFEBAG, value.shkeybag, X509_SIG, 0)), ADB_ENTRY(NID_safeContentsBag, ASN1_EXP_SET_OF(PKCS12_SAFEBAG, value.safes, PKCS12_SAFEBAG, 0)), ADB_ENTRY(NID_certBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)), ADB_ENTRY(NID_crlBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)), ADB_ENTRY(NID_secretBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)) } ASN1_ADB_END(PKCS12_SAFEBAG, 0, type, 0, &safebag_default_tt, NULL); ASN1_SEQUENCE(PKCS12_SAFEBAG) = { ASN1_SIMPLE(PKCS12_SAFEBAG, type, ASN1_OBJECT), ASN1_ADB_OBJECT(PKCS12_SAFEBAG), ASN1_SET_OF_OPT(PKCS12_SAFEBAG, attrib, X509_ATTRIBUTE) } ASN1_SEQUENCE_END(PKCS12_SAFEBAG) IMPLEMENT_ASN1_FUNCTIONS(PKCS12_SAFEBAG) /* SEQUENCE OF SafeBag */ ASN1_ITEM_TEMPLATE(PKCS12_SAFEBAGS) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, PKCS12_SAFEBAGS, PKCS12_SAFEBAG) ASN1_ITEM_TEMPLATE_END(PKCS12_SAFEBAGS) /* Authsafes: SEQUENCE OF PKCS7 */ ASN1_ITEM_TEMPLATE(PKCS12_AUTHSAFES) = ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, PKCS12_AUTHSAFES, PKCS7) ASN1_ITEM_TEMPLATE_END(PKCS12_AUTHSAFES) deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs12/p12_npas.c0000644000175000017500000001651312360020706021154 0ustar /* $OpenBSD: p12_npas.c,v 1.8 2014/06/12 15:49:30 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include /* PKCS#12 password change routine */ static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass); static int newpass_bags(STACK_OF(PKCS12_SAFEBAG) *bags, char *oldpass, char *newpass); static int newpass_bag(PKCS12_SAFEBAG *bag, char *oldpass, char *newpass); static int alg_get(X509_ALGOR *alg, int *pnid, int *piter, int *psaltlen); /* * Change the password on a PKCS#12 structure. */ int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass) { /* Check for NULL PKCS12 structure */ if (!p12) { PKCS12err(PKCS12_F_PKCS12_NEWPASS, PKCS12_R_INVALID_NULL_PKCS12_POINTER); return 0; } /* Check the mac */ if (!PKCS12_verify_mac(p12, oldpass, -1)) { PKCS12err(PKCS12_F_PKCS12_NEWPASS, PKCS12_R_MAC_VERIFY_FAILURE); return 0; } if (!newpass_p12(p12, oldpass, newpass)) { PKCS12err(PKCS12_F_PKCS12_NEWPASS, PKCS12_R_PARSE_ERROR); return 0; } return 1; } /* Parse the outer PKCS#12 structure */ static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass) { STACK_OF(PKCS7) *asafes, *newsafes; STACK_OF(PKCS12_SAFEBAG) *bags; int i, bagnid, pbe_nid = 0, pbe_iter = 0, pbe_saltlen = 0; PKCS7 *p7, *p7new; ASN1_OCTET_STRING *p12_data_tmp = NULL, *macnew = NULL; unsigned char mac[EVP_MAX_MD_SIZE]; unsigned int maclen; if (!(asafes = PKCS12_unpack_authsafes(p12))) return 0; if (!(newsafes = sk_PKCS7_new_null())) return 0; for (i = 0; i < sk_PKCS7_num (asafes); i++) { p7 = sk_PKCS7_value(asafes, i); bagnid = OBJ_obj2nid(p7->type); if (bagnid == NID_pkcs7_data) { bags = PKCS12_unpack_p7data(p7); } else if (bagnid == NID_pkcs7_encrypted) { bags = PKCS12_unpack_p7encdata(p7, oldpass, -1); if (!alg_get(p7->d.encrypted->enc_data->algorithm, &pbe_nid, &pbe_iter, &pbe_saltlen)) { sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); bags = NULL; } } else continue; if (!bags) { sk_PKCS7_pop_free(asafes, PKCS7_free); return 0; } if (!newpass_bags(bags, oldpass, newpass)) { sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); sk_PKCS7_pop_free(asafes, PKCS7_free); return 0; } /* Repack bag in same form with new password */ if (bagnid == NID_pkcs7_data) p7new = PKCS12_pack_p7data(bags); else p7new = PKCS12_pack_p7encdata(pbe_nid, newpass, -1, NULL, pbe_saltlen, pbe_iter, bags); sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); if (!p7new) { sk_PKCS7_pop_free(asafes, PKCS7_free); return 0; } sk_PKCS7_push(newsafes, p7new); } sk_PKCS7_pop_free(asafes, PKCS7_free); /* Repack safe: save old safe in case of error */ p12_data_tmp = p12->authsafes->d.data; if (!(p12->authsafes->d.data = ASN1_OCTET_STRING_new())) goto saferr; if (!PKCS12_pack_authsafes(p12, newsafes)) goto saferr; if (!PKCS12_gen_mac(p12, newpass, -1, mac, &maclen)) goto saferr; if (!(macnew = ASN1_OCTET_STRING_new())) goto saferr; if (!ASN1_OCTET_STRING_set(macnew, mac, maclen)) goto saferr; ASN1_OCTET_STRING_free(p12->mac->dinfo->digest); p12->mac->dinfo->digest = macnew; ASN1_OCTET_STRING_free(p12_data_tmp); return 1; saferr: /* Restore old safe */ ASN1_OCTET_STRING_free(p12->authsafes->d.data); ASN1_OCTET_STRING_free(macnew); p12->authsafes->d.data = p12_data_tmp; return 0; } static int newpass_bags(STACK_OF(PKCS12_SAFEBAG) *bags, char *oldpass, char *newpass) { int i; for (i = 0; i < sk_PKCS12_SAFEBAG_num(bags); i++) { if (!newpass_bag(sk_PKCS12_SAFEBAG_value(bags, i), oldpass, newpass)) return 0; } return 1; } /* Change password of safebag: only needs handle shrouded keybags */ static int newpass_bag(PKCS12_SAFEBAG *bag, char *oldpass, char *newpass) { PKCS8_PRIV_KEY_INFO *p8; X509_SIG *p8new; int p8_nid, p8_saltlen, p8_iter; if (M_PKCS12_bag_type(bag) != NID_pkcs8ShroudedKeyBag) return 1; if (!(p8 = PKCS8_decrypt(bag->value.shkeybag, oldpass, -1))) return 0; if (!alg_get(bag->value.shkeybag->algor, &p8_nid, &p8_iter, &p8_saltlen)) return 0; if (!(p8new = PKCS8_encrypt(p8_nid, NULL, newpass, -1, NULL, p8_saltlen, p8_iter, p8))) return 0; X509_SIG_free(bag->value.shkeybag); bag->value.shkeybag = p8new; return 1; } static int alg_get(X509_ALGOR *alg, int *pnid, int *piter, int *psaltlen) { PBEPARAM *pbe; const unsigned char *p; p = alg->parameter->value.sequence->data; pbe = d2i_PBEPARAM(NULL, &p, alg->parameter->value.sequence->length); if (!pbe) return 0; *pnid = OBJ_obj2nid(alg->algorithm); *piter = ASN1_INTEGER_get(pbe->iter); *psaltlen = pbe->salt->length; PBEPARAM_free(pbe); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs12/p12_p8d.c0000644000175000017500000000572712360020706020713 0ustar /* $OpenBSD: p12_p8d.c,v 1.4 2014/07/08 09:24:53 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include PKCS8_PRIV_KEY_INFO * PKCS8_decrypt(X509_SIG *p8, const char *pass, int passlen) { return PKCS12_item_decrypt_d2i(p8->algor, ASN1_ITEM_rptr(PKCS8_PRIV_KEY_INFO), pass, passlen, p8->digest, 1); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs12/p12_key.c0000644000175000017500000001370212360020706021000 0ustar /* $OpenBSD: p12_key.c,v 1.19 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include /* PKCS12 compatible key/IV generation */ #ifndef min #define min(a,b) ((a) < (b) ? (a) : (b)) #endif int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, int saltlen, int id, int iter, int n, unsigned char *out, const EVP_MD *md_type) { int ret; unsigned char *unipass; int uniplen; if (!pass) { unipass = NULL; uniplen = 0; } else if (!OPENSSL_asc2uni(pass, passlen, &unipass, &uniplen)) { PKCS12err(PKCS12_F_PKCS12_KEY_GEN_ASC, ERR_R_MALLOC_FAILURE); return 0; } ret = PKCS12_key_gen_uni(unipass, uniplen, salt, saltlen, id, iter, n, out, md_type); if (ret <= 0) return 0; if (unipass) { OPENSSL_cleanse(unipass, uniplen); free(unipass); } return ret; } int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, int saltlen, int id, int iter, int n, unsigned char *out, const EVP_MD *md_type) { unsigned char *B, *D, *I, *p, *Ai; int Slen, Plen, Ilen, Ijlen; int i, j, u, v; int ret = 0; BIGNUM *Ij, *Bpl1; /* These hold Ij and B + 1 */ EVP_MD_CTX ctx; #if 0 if (!pass) { PKCS12err(PKCS12_F_PKCS12_KEY_GEN_UNI, ERR_R_PASSED_NULL_PARAMETER); return 0; } #endif EVP_MD_CTX_init(&ctx); v = EVP_MD_block_size(md_type); u = EVP_MD_size(md_type); if (u < 0) return 0; D = malloc(v); Ai = malloc(u); B = malloc(v + 1); Slen = v * ((saltlen + v - 1) / v); if (passlen) Plen = v * ((passlen + v - 1)/v); else Plen = 0; Ilen = Slen + Plen; I = malloc(Ilen); Ij = BN_new(); Bpl1 = BN_new(); if (!D || !Ai || !B || !I || !Ij || !Bpl1) goto err; for (i = 0; i < v; i++) D[i] = id; p = I; for (i = 0; i < Slen; i++) *p++ = salt[i % saltlen]; for (i = 0; i < Plen; i++) *p++ = pass[i % passlen]; for (;;) { if (!EVP_DigestInit_ex(&ctx, md_type, NULL) || !EVP_DigestUpdate(&ctx, D, v) || !EVP_DigestUpdate(&ctx, I, Ilen) || !EVP_DigestFinal_ex(&ctx, Ai, NULL)) goto err; for (j = 1; j < iter; j++) { if (!EVP_DigestInit_ex(&ctx, md_type, NULL) || !EVP_DigestUpdate(&ctx, Ai, u) || !EVP_DigestFinal_ex(&ctx, Ai, NULL)) goto err; } memcpy (out, Ai, min (n, u)); if (u >= n) { ret = 1; goto end; } n -= u; out += u; for (j = 0; j < v; j++) B[j] = Ai[j % u]; /* Work out B + 1 first then can use B as tmp space */ if (!BN_bin2bn (B, v, Bpl1)) goto err; if (!BN_add_word (Bpl1, 1)) goto err; for (j = 0; j < Ilen; j += v) { if (!BN_bin2bn(I + j, v, Ij)) goto err; if (!BN_add(Ij, Ij, Bpl1)) goto err; if (!BN_bn2bin(Ij, B)) goto err; Ijlen = BN_num_bytes (Ij); /* If more than 2^(v*8) - 1 cut off MSB */ if (Ijlen > v) { if (!BN_bn2bin (Ij, B)) goto err; memcpy (I + j, B + 1, v); #ifndef PKCS12_BROKEN_KEYGEN /* If less than v bytes pad with zeroes */ } else if (Ijlen < v) { memset(I + j, 0, v - Ijlen); if (!BN_bn2bin(Ij, I + j + v - Ijlen)) goto err; #endif } else if (!BN_bn2bin (Ij, I + j)) goto err; } } err: PKCS12err(PKCS12_F_PKCS12_KEY_GEN_UNI, ERR_R_MALLOC_FAILURE); end: free (Ai); free (B); free (D); free (I); BN_free (Ij); BN_free (Bpl1); EVP_MD_CTX_cleanup(&ctx); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs12/p12_init.c0000644000175000017500000000671012360020706021154 0ustar /* $OpenBSD: p12_init.c,v 1.8 2014/07/08 09:24:53 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include /* Initialise a PKCS12 structure to take data */ PKCS12 * PKCS12_init(int mode) { PKCS12 *pkcs12; if (!(pkcs12 = PKCS12_new())) { PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE); return NULL; } ASN1_INTEGER_set(pkcs12->version, 3); pkcs12->authsafes->type = OBJ_nid2obj(mode); switch (mode) { case NID_pkcs7_data: if (!(pkcs12->authsafes->d.data = M_ASN1_OCTET_STRING_new())) { PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE); goto err; } break; default: PKCS12err(PKCS12_F_PKCS12_INIT, PKCS12_R_UNSUPPORTED_PKCS12_MODE); goto err; } return pkcs12; err: if (pkcs12 != NULL) PKCS12_free(pkcs12); return NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs12/p12_kiss.c0000644000175000017500000002004412360020706021156 0ustar /* $OpenBSD: p12_kiss.c,v 1.15 2014/07/08 09:24:53 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include /* Simplified PKCS#12 routines */ static int parse_pk12( PKCS12 *p12, const char *pass, int passlen, EVP_PKEY **pkey, STACK_OF(X509) *ocerts); static int parse_bags( STACK_OF(PKCS12_SAFEBAG) *bags, const char *pass, int passlen, EVP_PKEY **pkey, STACK_OF(X509) *ocerts); static int parse_bag( PKCS12_SAFEBAG *bag, const char *pass, int passlen, EVP_PKEY **pkey, STACK_OF(X509) *ocerts); /* Parse and decrypt a PKCS#12 structure returning user key, user cert * and other (CA) certs. Note either ca should be NULL, *ca should be NULL, * or it should point to a valid STACK structure. pkey and cert can be * passed unitialised. */ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca) { STACK_OF(X509) *ocerts = NULL; X509 *x = NULL; /* Check for NULL PKCS12 structure */ if (!p12) { PKCS12err(PKCS12_F_PKCS12_PARSE, PKCS12_R_INVALID_NULL_PKCS12_POINTER); return 0; } if (pkey) *pkey = NULL; if (cert) *cert = NULL; /* Check the mac */ /* If password is zero length or NULL then try verifying both cases * to determine which password is correct. The reason for this is that * under PKCS#12 password based encryption no password and a zero length * password are two different things... */ if (!pass || !*pass) { if (PKCS12_verify_mac(p12, NULL, 0)) pass = NULL; else if (PKCS12_verify_mac(p12, "", 0)) pass = ""; else { PKCS12err(PKCS12_F_PKCS12_PARSE, PKCS12_R_MAC_VERIFY_FAILURE); goto err; } } else if (!PKCS12_verify_mac(p12, pass, -1)) { PKCS12err(PKCS12_F_PKCS12_PARSE, PKCS12_R_MAC_VERIFY_FAILURE); goto err; } /* Allocate stack for other certificates */ ocerts = sk_X509_new_null(); if (!ocerts) { PKCS12err(PKCS12_F_PKCS12_PARSE, ERR_R_MALLOC_FAILURE); return 0; } if (!parse_pk12 (p12, pass, -1, pkey, ocerts)) { PKCS12err(PKCS12_F_PKCS12_PARSE, PKCS12_R_PARSE_ERROR); goto err; } while ((x = sk_X509_pop(ocerts))) { if (pkey && *pkey && cert && !*cert) { if (X509_check_private_key(x, *pkey)) { *cert = x; x = NULL; } } if (ca && x) { if (!*ca) *ca = sk_X509_new_null(); if (!*ca) goto err; if (!sk_X509_push(*ca, x)) goto err; x = NULL; } if (x) X509_free(x); } if (ocerts) sk_X509_pop_free(ocerts, X509_free); return 1; err: if (pkey && *pkey) EVP_PKEY_free(*pkey); if (cert && *cert) X509_free(*cert); if (x) X509_free(x); if (ocerts) sk_X509_pop_free(ocerts, X509_free); return 0; } /* Parse the outer PKCS#12 structure */ static int parse_pk12(PKCS12 *p12, const char *pass, int passlen, EVP_PKEY **pkey, STACK_OF(X509) *ocerts) { STACK_OF(PKCS7) *asafes; STACK_OF(PKCS12_SAFEBAG) *bags; int i, bagnid; PKCS7 *p7; if (!(asafes = PKCS12_unpack_authsafes (p12))) return 0; for (i = 0; i < sk_PKCS7_num (asafes); i++) { p7 = sk_PKCS7_value (asafes, i); bagnid = OBJ_obj2nid (p7->type); if (bagnid == NID_pkcs7_data) { bags = PKCS12_unpack_p7data(p7); } else if (bagnid == NID_pkcs7_encrypted) { bags = PKCS12_unpack_p7encdata(p7, pass, passlen); } else continue; if (!bags) { sk_PKCS7_pop_free(asafes, PKCS7_free); return 0; } if (!parse_bags(bags, pass, passlen, pkey, ocerts)) { sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); sk_PKCS7_pop_free(asafes, PKCS7_free); return 0; } sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); } sk_PKCS7_pop_free(asafes, PKCS7_free); return 1; } static int parse_bags(STACK_OF(PKCS12_SAFEBAG) *bags, const char *pass, int passlen, EVP_PKEY **pkey, STACK_OF(X509) *ocerts) { int i; for (i = 0; i < sk_PKCS12_SAFEBAG_num(bags); i++) { if (!parse_bag(sk_PKCS12_SAFEBAG_value(bags, i), pass, passlen, pkey, ocerts)) return 0; } return 1; } static int parse_bag(PKCS12_SAFEBAG *bag, const char *pass, int passlen, EVP_PKEY **pkey, STACK_OF(X509) *ocerts) { PKCS8_PRIV_KEY_INFO *p8; X509 *x509; ASN1_TYPE *attrib; ASN1_BMPSTRING *fname = NULL; ASN1_OCTET_STRING *lkid = NULL; if ((attrib = PKCS12_get_attr (bag, NID_friendlyName))) fname = attrib->value.bmpstring; if ((attrib = PKCS12_get_attr (bag, NID_localKeyID))) lkid = attrib->value.octet_string; switch (M_PKCS12_bag_type(bag)) { case NID_keyBag: if (!pkey || *pkey) return 1; if (!(*pkey = EVP_PKCS82PKEY(bag->value.keybag))) return 0; break; case NID_pkcs8ShroudedKeyBag: if (!pkey || *pkey) return 1; if (!(p8 = PKCS12_decrypt_skey(bag, pass, passlen))) return 0; *pkey = EVP_PKCS82PKEY(p8); PKCS8_PRIV_KEY_INFO_free(p8); if (!(*pkey)) return 0; break; case NID_certBag: if (M_PKCS12_cert_bag_type(bag) != NID_x509Certificate ) return 1; if (!(x509 = PKCS12_certbag2x509(bag))) return 0; if (lkid && !X509_keyid_set1(x509, lkid->data, lkid->length)) { X509_free(x509); return 0; } if (fname) { int len, r; unsigned char *data; len = ASN1_STRING_to_UTF8(&data, fname); if (len >= 0) { r = X509_alias_set1(x509, data, len); free(data); if (!r) { X509_free(x509); return 0; } } } if (!sk_X509_push(ocerts, x509)) { X509_free(x509); return 0; } break; case NID_safeContentsBag: return parse_bags(bag->value.safes, pass, passlen, pkey, ocerts); break; default: return 1; break; } return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs12/p12_mutl.c0000644000175000017500000001501212360020706021165 0ustar /* $OpenBSD: p12_mutl.c,v 1.16 2014/07/10 22:45:57 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #ifndef OPENSSL_NO_HMAC #include #include #include #include /* Generate a MAC */ int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, unsigned char *mac, unsigned int *maclen) { const EVP_MD *md_type; HMAC_CTX hmac; unsigned char key[EVP_MAX_MD_SIZE], *salt; int saltlen, iter; int md_size; if (!PKCS7_type_is_data(p12->authsafes)) { PKCS12err(PKCS12_F_PKCS12_GEN_MAC, PKCS12_R_CONTENT_TYPE_NOT_DATA); return 0; } salt = p12->mac->salt->data; saltlen = p12->mac->salt->length; if (!p12->mac->iter) iter = 1; else iter = ASN1_INTEGER_get(p12->mac->iter); if (!(md_type = EVP_get_digestbyobj( p12->mac->dinfo->algor->algorithm))) { PKCS12err(PKCS12_F_PKCS12_GEN_MAC, PKCS12_R_UNKNOWN_DIGEST_ALGORITHM); return 0; } md_size = EVP_MD_size(md_type); if (md_size < 0) return 0; if (!PKCS12_key_gen (pass, passlen, salt, saltlen, PKCS12_MAC_ID, iter, md_size, key, md_type)) { PKCS12err(PKCS12_F_PKCS12_GEN_MAC, PKCS12_R_KEY_GEN_ERROR); return 0; } HMAC_CTX_init(&hmac); if (!HMAC_Init_ex(&hmac, key, md_size, md_type, NULL) || !HMAC_Update(&hmac, p12->authsafes->d.data->data, p12->authsafes->d.data->length) || !HMAC_Final(&hmac, mac, maclen)) { HMAC_CTX_cleanup(&hmac); return 0; } HMAC_CTX_cleanup(&hmac); return 1; } /* Verify the mac */ int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen) { unsigned char mac[EVP_MAX_MD_SIZE]; unsigned int maclen; if (p12->mac == NULL) { PKCS12err(PKCS12_F_PKCS12_VERIFY_MAC, PKCS12_R_MAC_ABSENT); return 0; } if (!PKCS12_gen_mac (p12, pass, passlen, mac, &maclen)) { PKCS12err(PKCS12_F_PKCS12_VERIFY_MAC, PKCS12_R_MAC_GENERATION_ERROR); return 0; } if ((maclen != (unsigned int)p12->mac->dinfo->digest->length) || memcmp(mac, p12->mac->dinfo->digest->data, maclen)) return 0; return 1; } /* Set a mac */ int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen, unsigned char *salt, int saltlen, int iter, const EVP_MD *md_type) { unsigned char mac[EVP_MAX_MD_SIZE]; unsigned int maclen; if (!md_type) md_type = EVP_sha1(); if (PKCS12_setup_mac (p12, iter, salt, saltlen, md_type) == PKCS12_ERROR) { PKCS12err(PKCS12_F_PKCS12_SET_MAC, PKCS12_R_MAC_SETUP_ERROR); return 0; } if (!PKCS12_gen_mac (p12, pass, passlen, mac, &maclen)) { PKCS12err(PKCS12_F_PKCS12_SET_MAC, PKCS12_R_MAC_GENERATION_ERROR); return 0; } if (!(M_ASN1_OCTET_STRING_set (p12->mac->dinfo->digest, mac, maclen))) { PKCS12err(PKCS12_F_PKCS12_SET_MAC, PKCS12_R_MAC_STRING_SET_ERROR); return 0; } return 1; } /* Set up a mac structure */ int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen, const EVP_MD *md_type) { if (!(p12->mac = PKCS12_MAC_DATA_new())) return PKCS12_ERROR; if (iter > 1) { if (!(p12->mac->iter = M_ASN1_INTEGER_new())) { PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); return 0; } if (!ASN1_INTEGER_set(p12->mac->iter, iter)) { PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); return 0; } } if (!saltlen) saltlen = PKCS12_SALT_LEN; p12->mac->salt->length = saltlen; if (!(p12->mac->salt->data = malloc (saltlen))) { PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); return 0; } if (!salt) { if (RAND_pseudo_bytes (p12->mac->salt->data, saltlen) < 0) return 0; } else memcpy (p12->mac->salt->data, salt, saltlen); p12->mac->dinfo->algor->algorithm = OBJ_nid2obj(EVP_MD_type(md_type)); if (!(p12->mac->dinfo->algor->parameter = ASN1_TYPE_new())) { PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); return 0; } p12->mac->dinfo->algor->parameter->type = V_ASN1_NULL; return 1; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs12/p12_add.c0000644000175000017500000001715212360020706020743 0ustar /* $OpenBSD: p12_add.c,v 1.10 2014/07/08 09:24:53 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include /* Pack an object into an OCTET STRING and turn into a safebag */ PKCS12_SAFEBAG * PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, int nid1, int nid2) { PKCS12_BAGS *bag; PKCS12_SAFEBAG *safebag; if (!(bag = PKCS12_BAGS_new())) { PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE); return NULL; } bag->type = OBJ_nid2obj(nid1); if (!ASN1_item_pack(obj, it, &bag->value.octet)) { PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE); return NULL; } if (!(safebag = PKCS12_SAFEBAG_new())) { PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE); return NULL; } safebag->value.bag = bag; safebag->type = OBJ_nid2obj(nid2); return safebag; } /* Turn PKCS8 object into a keybag */ PKCS12_SAFEBAG * PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8) { PKCS12_SAFEBAG *bag; if (!(bag = PKCS12_SAFEBAG_new())) { PKCS12err(PKCS12_F_PKCS12_MAKE_KEYBAG, ERR_R_MALLOC_FAILURE); return NULL; } bag->type = OBJ_nid2obj(NID_keyBag); bag->value.keybag = p8; return bag; } /* Turn PKCS8 object into a shrouded keybag */ PKCS12_SAFEBAG * PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass, int passlen, unsigned char *salt, int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8) { PKCS12_SAFEBAG *bag; const EVP_CIPHER *pbe_ciph; /* Set up the safe bag */ if (!(bag = PKCS12_SAFEBAG_new())) { PKCS12err(PKCS12_F_PKCS12_MAKE_SHKEYBAG, ERR_R_MALLOC_FAILURE); return NULL; } bag->type = OBJ_nid2obj(NID_pkcs8ShroudedKeyBag); pbe_ciph = EVP_get_cipherbynid(pbe_nid); if (pbe_ciph) pbe_nid = -1; if (!(bag->value.shkeybag = PKCS8_encrypt(pbe_nid, pbe_ciph, pass, passlen, salt, saltlen, iter, p8))) { PKCS12err(PKCS12_F_PKCS12_MAKE_SHKEYBAG, ERR_R_MALLOC_FAILURE); return NULL; } return bag; } /* Turn a stack of SAFEBAGS into a PKCS#7 data Contentinfo */ PKCS7 * PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk) { PKCS7 *p7; if (!(p7 = PKCS7_new())) { PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, ERR_R_MALLOC_FAILURE); return NULL; } p7->type = OBJ_nid2obj(NID_pkcs7_data); if (!(p7->d.data = M_ASN1_OCTET_STRING_new())) { PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, ERR_R_MALLOC_FAILURE); return NULL; } if (!ASN1_item_pack(sk, ASN1_ITEM_rptr(PKCS12_SAFEBAGS), &p7->d.data)) { PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, PKCS12_R_CANT_PACK_STRUCTURE); return NULL; } return p7; } /* Unpack SAFEBAGS from PKCS#7 data ContentInfo */ STACK_OF(PKCS12_SAFEBAG) * PKCS12_unpack_p7data(PKCS7 *p7) { if (!PKCS7_type_is_data(p7)) { PKCS12err(PKCS12_F_PKCS12_UNPACK_P7DATA, PKCS12_R_CONTENT_TYPE_NOT_DATA); return NULL; } return ASN1_item_unpack(p7->d.data, ASN1_ITEM_rptr(PKCS12_SAFEBAGS)); } /* Turn a stack of SAFEBAGS into a PKCS#7 encrypted data ContentInfo */ PKCS7 * PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, unsigned char *salt, int saltlen, int iter, STACK_OF(PKCS12_SAFEBAG) *bags) { PKCS7 *p7; X509_ALGOR *pbe; const EVP_CIPHER *pbe_ciph; if (!(p7 = PKCS7_new())) { PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); return NULL; } if (!PKCS7_set_type(p7, NID_pkcs7_encrypted)) { PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE); return NULL; } pbe_ciph = EVP_get_cipherbynid(pbe_nid); if (pbe_ciph) pbe = PKCS5_pbe2_set(pbe_ciph, iter, salt, saltlen); else pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen); if (!pbe) { PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); return NULL; } X509_ALGOR_free(p7->d.encrypted->enc_data->algorithm); p7->d.encrypted->enc_data->algorithm = pbe; M_ASN1_OCTET_STRING_free(p7->d.encrypted->enc_data->enc_data); if (!(p7->d.encrypted->enc_data->enc_data = PKCS12_item_i2d_encrypt( pbe, ASN1_ITEM_rptr(PKCS12_SAFEBAGS), pass, passlen, bags, 1))) { PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, PKCS12_R_ENCRYPT_ERROR); return NULL; } return p7; } STACK_OF(PKCS12_SAFEBAG) * PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, int passlen) { if (!PKCS7_type_is_encrypted(p7)) return NULL; return PKCS12_item_decrypt_d2i(p7->d.encrypted->enc_data->algorithm, ASN1_ITEM_rptr(PKCS12_SAFEBAGS), pass, passlen, p7->d.encrypted->enc_data->enc_data, 1); } PKCS8_PRIV_KEY_INFO * PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag, const char *pass, int passlen) { return PKCS8_decrypt(bag->value.shkeybag, pass, passlen); } int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes) { if (ASN1_item_pack(safes, ASN1_ITEM_rptr(PKCS12_AUTHSAFES), &p12->authsafes->d.data)) return 1; return 0; } STACK_OF(PKCS7) * PKCS12_unpack_authsafes(PKCS12 *p12) { if (!PKCS7_type_is_data(p12->authsafes)) { PKCS12err(PKCS12_F_PKCS12_UNPACK_AUTHSAFES, PKCS12_R_CONTENT_TYPE_NOT_DATA); return NULL; } return ASN1_item_unpack(p12->authsafes->d.data, ASN1_ITEM_rptr(PKCS12_AUTHSAFES)); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs12/p12_p8e.c0000644000175000017500000000723412360020706020707 0ustar /* $OpenBSD: p12_p8e.c,v 1.4 2014/07/08 09:24:53 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include X509_SIG * PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, const char *pass, int passlen, unsigned char *salt, int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8inf) { X509_SIG *p8 = NULL; X509_ALGOR *pbe; if (!(p8 = X509_SIG_new())) { PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_MALLOC_FAILURE); goto err; } if (pbe_nid == -1) pbe = PKCS5_pbe2_set(cipher, iter, salt, saltlen); else pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen); if (!pbe) { PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_ASN1_LIB); goto err; } X509_ALGOR_free(p8->algor); p8->algor = pbe; M_ASN1_OCTET_STRING_free(p8->digest); p8->digest = PKCS12_item_i2d_encrypt(pbe, ASN1_ITEM_rptr(PKCS8_PRIV_KEY_INFO), pass, passlen, p8inf, 1); if (!p8->digest) { PKCS12err(PKCS12_F_PKCS8_ENCRYPT, PKCS12_R_ENCRYPT_ERROR); goto err; } return p8; err: X509_SIG_free(p8); return NULL; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs12/p12_crpt.c0000644000175000017500000001047712360020706021166 0ustar /* $OpenBSD: p12_crpt.c,v 1.10 2014/07/08 09:24:53 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include /* PKCS#12 PBE algorithms now in static table */ void PKCS12_PBE_add(void) { } int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, int en_de) { PBEPARAM *pbe; int saltlen, iter, ret; unsigned char *salt; const unsigned char *pbuf; unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH]; /* Extract useful info from parameter */ if (param == NULL || param->type != V_ASN1_SEQUENCE || param->value.sequence == NULL) { PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_DECODE_ERROR); return 0; } pbuf = param->value.sequence->data; if (!(pbe = d2i_PBEPARAM(NULL, &pbuf, param->value.sequence->length))) { PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_DECODE_ERROR); return 0; } if (!pbe->iter) iter = 1; else iter = ASN1_INTEGER_get (pbe->iter); salt = pbe->salt->data; saltlen = pbe->salt->length; if (!PKCS12_key_gen (pass, passlen, salt, saltlen, PKCS12_KEY_ID, iter, EVP_CIPHER_key_length(cipher), key, md)) { PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_KEY_GEN_ERROR); PBEPARAM_free(pbe); return 0; } if (!PKCS12_key_gen (pass, passlen, salt, saltlen, PKCS12_IV_ID, iter, EVP_CIPHER_iv_length(cipher), iv, md)) { PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_IV_GEN_ERROR); PBEPARAM_free(pbe); return 0; } PBEPARAM_free(pbe); ret = EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, en_de); OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH); OPENSSL_cleanse(iv, EVP_MAX_IV_LENGTH); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs12/pk12err.c0000644000175000017500000001541012360020706021012 0ustar /* $OpenBSD: pk12err.c,v 1.9 2014/07/08 09:24:53 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_PKCS12,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_PKCS12,0,reason) static ERR_STRING_DATA PKCS12_str_functs[]= { {ERR_FUNC(PKCS12_F_PARSE_BAG), "PARSE_BAG"}, {ERR_FUNC(PKCS12_F_PARSE_BAGS), "PARSE_BAGS"}, {ERR_FUNC(PKCS12_F_PKCS12_ADD_FRIENDLYNAME), "PKCS12_ADD_FRIENDLYNAME"}, {ERR_FUNC(PKCS12_F_PKCS12_ADD_FRIENDLYNAME_ASC), "PKCS12_add_friendlyname_asc"}, {ERR_FUNC(PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI), "PKCS12_add_friendlyname_uni"}, {ERR_FUNC(PKCS12_F_PKCS12_ADD_LOCALKEYID), "PKCS12_add_localkeyid"}, {ERR_FUNC(PKCS12_F_PKCS12_CREATE), "PKCS12_create"}, {ERR_FUNC(PKCS12_F_PKCS12_GEN_MAC), "PKCS12_gen_mac"}, {ERR_FUNC(PKCS12_F_PKCS12_INIT), "PKCS12_init"}, {ERR_FUNC(PKCS12_F_PKCS12_ITEM_DECRYPT_D2I), "PKCS12_item_decrypt_d2i"}, {ERR_FUNC(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT), "PKCS12_item_i2d_encrypt"}, {ERR_FUNC(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG), "PKCS12_item_pack_safebag"}, {ERR_FUNC(PKCS12_F_PKCS12_KEY_GEN_ASC), "PKCS12_key_gen_asc"}, {ERR_FUNC(PKCS12_F_PKCS12_KEY_GEN_UNI), "PKCS12_key_gen_uni"}, {ERR_FUNC(PKCS12_F_PKCS12_MAKE_KEYBAG), "PKCS12_MAKE_KEYBAG"}, {ERR_FUNC(PKCS12_F_PKCS12_MAKE_SHKEYBAG), "PKCS12_MAKE_SHKEYBAG"}, {ERR_FUNC(PKCS12_F_PKCS12_NEWPASS), "PKCS12_newpass"}, {ERR_FUNC(PKCS12_F_PKCS12_PACK_P7DATA), "PKCS12_pack_p7data"}, {ERR_FUNC(PKCS12_F_PKCS12_PACK_P7ENCDATA), "PKCS12_pack_p7encdata"}, {ERR_FUNC(PKCS12_F_PKCS12_PARSE), "PKCS12_parse"}, {ERR_FUNC(PKCS12_F_PKCS12_PBE_CRYPT), "PKCS12_pbe_crypt"}, {ERR_FUNC(PKCS12_F_PKCS12_PBE_KEYIVGEN), "PKCS12_PBE_keyivgen"}, {ERR_FUNC(PKCS12_F_PKCS12_SETUP_MAC), "PKCS12_setup_mac"}, {ERR_FUNC(PKCS12_F_PKCS12_SET_MAC), "PKCS12_set_mac"}, {ERR_FUNC(PKCS12_F_PKCS12_UNPACK_AUTHSAFES), "PKCS12_unpack_authsafes"}, {ERR_FUNC(PKCS12_F_PKCS12_UNPACK_P7DATA), "PKCS12_unpack_p7data"}, {ERR_FUNC(PKCS12_F_PKCS12_VERIFY_MAC), "PKCS12_verify_mac"}, {ERR_FUNC(PKCS12_F_PKCS8_ADD_KEYUSAGE), "PKCS8_add_keyusage"}, {ERR_FUNC(PKCS12_F_PKCS8_ENCRYPT), "PKCS8_encrypt"}, {0, NULL} }; static ERR_STRING_DATA PKCS12_str_reasons[]= { {ERR_REASON(PKCS12_R_CANT_PACK_STRUCTURE), "cant pack structure"}, {ERR_REASON(PKCS12_R_CONTENT_TYPE_NOT_DATA), "content type not data"}, {ERR_REASON(PKCS12_R_DECODE_ERROR) , "decode error"}, {ERR_REASON(PKCS12_R_ENCODE_ERROR) , "encode error"}, {ERR_REASON(PKCS12_R_ENCRYPT_ERROR) , "encrypt error"}, {ERR_REASON(PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE), "error setting encrypted data type"}, {ERR_REASON(PKCS12_R_INVALID_NULL_ARGUMENT), "invalid null argument"}, {ERR_REASON(PKCS12_R_INVALID_NULL_PKCS12_POINTER), "invalid null pkcs12 pointer"}, {ERR_REASON(PKCS12_R_IV_GEN_ERROR) , "iv gen error"}, {ERR_REASON(PKCS12_R_KEY_GEN_ERROR) , "key gen error"}, {ERR_REASON(PKCS12_R_MAC_ABSENT) , "mac absent"}, {ERR_REASON(PKCS12_R_MAC_GENERATION_ERROR), "mac generation error"}, {ERR_REASON(PKCS12_R_MAC_SETUP_ERROR) , "mac setup error"}, {ERR_REASON(PKCS12_R_MAC_STRING_SET_ERROR), "mac string set error"}, {ERR_REASON(PKCS12_R_MAC_VERIFY_ERROR) , "mac verify error"}, {ERR_REASON(PKCS12_R_MAC_VERIFY_FAILURE) , "mac verify failure"}, {ERR_REASON(PKCS12_R_PARSE_ERROR) , "parse error"}, {ERR_REASON(PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR), "pkcs12 algor cipherinit error"}, {ERR_REASON(PKCS12_R_PKCS12_CIPHERFINAL_ERROR), "pkcs12 cipherfinal error"}, {ERR_REASON(PKCS12_R_PKCS12_PBE_CRYPT_ERROR), "pkcs12 pbe crypt error"}, {ERR_REASON(PKCS12_R_UNKNOWN_DIGEST_ALGORITHM), "unknown digest algorithm"}, {ERR_REASON(PKCS12_R_UNSUPPORTED_PKCS12_MODE), "unsupported pkcs12 mode"}, {0, NULL} }; #endif void ERR_load_PKCS12_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(PKCS12_str_functs[0].error) == NULL) { ERR_load_strings(0, PKCS12_str_functs); ERR_load_strings(0, PKCS12_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs12/p12_utl.c0000644000175000017500000001164712360020706021022 0ustar /* $OpenBSD: p12_utl.c,v 1.11 2014/07/10 13:58:23 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include /* Cheap and nasty Unicode stuff */ unsigned char * OPENSSL_asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen) { int ulen, i; unsigned char *unitmp; if (asclen == -1) asclen = strlen(asc); ulen = asclen * 2 + 2; if (!(unitmp = malloc(ulen))) return NULL; for (i = 0; i < ulen - 2; i += 2) { unitmp[i] = 0; unitmp[i + 1] = asc[i >> 1]; } /* Make result double null terminated */ unitmp[ulen - 2] = 0; unitmp[ulen - 1] = 0; if (unilen) *unilen = ulen; if (uni) *uni = unitmp; return unitmp; } char * OPENSSL_uni2asc(unsigned char *uni, int unilen) { int asclen, i; char *asctmp; asclen = unilen / 2; /* If no terminating zero allow for one */ if (!unilen || uni[unilen - 1]) asclen++; uni++; if (!(asctmp = malloc(asclen))) return NULL; for (i = 0; i < unilen; i += 2) asctmp[i >> 1] = uni[i]; asctmp[asclen - 1] = 0; return asctmp; } int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12) { return ASN1_item_i2d_bio(ASN1_ITEM_rptr(PKCS12), bp, p12); } int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12) { return ASN1_item_i2d_fp(ASN1_ITEM_rptr(PKCS12), fp, p12); } PKCS12 * d2i_PKCS12_bio(BIO *bp, PKCS12 **p12) { return ASN1_item_d2i_bio(ASN1_ITEM_rptr(PKCS12), bp, p12); } PKCS12 * d2i_PKCS12_fp(FILE *fp, PKCS12 **p12) { return ASN1_item_d2i_fp(ASN1_ITEM_rptr(PKCS12), fp, p12); } PKCS12_SAFEBAG * PKCS12_x5092certbag(X509 *x509) { return PKCS12_item_pack_safebag(x509, ASN1_ITEM_rptr(X509), NID_x509Certificate, NID_certBag); } PKCS12_SAFEBAG * PKCS12_x509crl2certbag(X509_CRL *crl) { return PKCS12_item_pack_safebag(crl, ASN1_ITEM_rptr(X509_CRL), NID_x509Crl, NID_crlBag); } X509 * PKCS12_certbag2x509(PKCS12_SAFEBAG *bag) { if (M_PKCS12_bag_type(bag) != NID_certBag) return NULL; if (M_PKCS12_cert_bag_type(bag) != NID_x509Certificate) return NULL; return ASN1_item_unpack(bag->value.bag->value.octet, ASN1_ITEM_rptr(X509)); } X509_CRL * PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag) { if (M_PKCS12_bag_type(bag) != NID_crlBag) return NULL; if (M_PKCS12_cert_bag_type(bag) != NID_x509Crl) return NULL; return ASN1_item_unpack(bag->value.bag->value.octet, ASN1_ITEM_rptr(X509_CRL)); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/pkcs12/p12_attr.c0000644000175000017500000001134412360020706021162 0ustar /* $OpenBSD: p12_attr.c,v 1.9 2014/07/08 09:24:53 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include /* Add a local keyid to a safebag */ int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, int namelen) { if (X509at_add1_attr_by_NID(&bag->attrib, NID_localKeyID, V_ASN1_OCTET_STRING, name, namelen)) return 1; else return 0; } /* Add key usage to PKCS#8 structure */ int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage) { unsigned char us_val; us_val = (unsigned char) usage; if (X509at_add1_attr_by_NID(&p8->attributes, NID_key_usage, V_ASN1_BIT_STRING, &us_val, 1)) return 1; else return 0; } /* Add a friendlyname to a safebag */ int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name, int namelen) { if (X509at_add1_attr_by_NID(&bag->attrib, NID_friendlyName, MBSTRING_ASC, (unsigned char *)name, namelen)) return 1; else return 0; } int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, const unsigned char *name, int namelen) { if (X509at_add1_attr_by_NID(&bag->attrib, NID_friendlyName, MBSTRING_BMP, name, namelen)) return 1; else return 0; } int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name, int namelen) { if (X509at_add1_attr_by_NID(&bag->attrib, NID_ms_csp_name, MBSTRING_ASC, (unsigned char *)name, namelen)) return 1; else return 0; } ASN1_TYPE * PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid) { X509_ATTRIBUTE *attrib; int i; if (!attrs) return NULL; for (i = 0; i < sk_X509_ATTRIBUTE_num (attrs); i++) { attrib = sk_X509_ATTRIBUTE_value (attrs, i); if (OBJ_obj2nid (attrib->object) == attr_nid) { if (sk_ASN1_TYPE_num (attrib->value.set)) return sk_ASN1_TYPE_value(attrib->value.set, 0); else return NULL; } } return NULL; } char * PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag) { ASN1_TYPE *atype; if (!(atype = PKCS12_get_attr(bag, NID_friendlyName))) return NULL; if (atype->type != V_ASN1_BMPSTRING) return NULL; return OPENSSL_uni2asc(atype->value.bmpstring->data, atype->value.bmpstring->length); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/txt_db/0000755000000000000000000000000012666635521021336 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/txt_db/txt_db.c0000644000175000017500000002267612360020706021205 0ustar /* $OpenBSD: txt_db.c,v 1.17 2014/07/09 11:10:51 bcook Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #undef BUFSIZE #define BUFSIZE 512 TXT_DB * TXT_DB_read(BIO *in, int num) { TXT_DB *ret = NULL; int er = 1; int esc = 0; long ln = 0; int i, add, n; int size = BUFSIZE; int offset = 0; char *p, *f; OPENSSL_STRING *pp; BUF_MEM *buf = NULL; if ((buf = BUF_MEM_new()) == NULL) goto err; if (!BUF_MEM_grow(buf, size)) goto err; if ((ret = malloc(sizeof(TXT_DB))) == NULL) goto err; ret->num_fields = num; ret->index = NULL; ret->qual = NULL; if ((ret->data = sk_OPENSSL_PSTRING_new_null()) == NULL) goto err; if ((ret->index = reallocarray(NULL, num, sizeof(*ret->index))) == NULL) goto err; if ((ret->qual = reallocarray(NULL, num, sizeof(*(ret->qual)))) == NULL) goto err; for (i = 0; i < num; i++) { ret->index[i] = NULL; ret->qual[i] = NULL; } add = (num + 1)*sizeof(char *); buf->data[size-1] = '\0'; offset = 0; for (;;) { if (offset != 0) { size += BUFSIZE; if (!BUF_MEM_grow_clean(buf, size)) goto err; } buf->data[offset] = '\0'; BIO_gets(in, &(buf->data[offset]), size - offset); ln++; if (buf->data[offset] == '\0') break; if ((offset == 0) && (buf->data[0] == '#')) continue; i = strlen(&(buf->data[offset])); offset += i; if (buf->data[offset-1] != '\n') continue; else { buf->data[offset-1] = '\0'; /* blat the '\n' */ if (!(p = malloc(add + offset))) goto err; offset = 0; } pp = (char **)p; p += add; n = 0; pp[n++] = p; i = 0; f = buf->data; esc = 0; for (;;) { if (*f == '\0') break; if (*f == '\t') { if (esc) p--; else { *(p++)='\0'; f++; if (n >= num) break; pp[n++] = p; continue; } } esc=(*f == '\\'); *(p++)= *(f++); } *(p++)='\0'; if ((n != num) || (*f != '\0')) { fprintf(stderr, "wrong number of fields on line %ld (looking for field %d, got %d, '%s' left)\n",ln,num,n,f); er = 2; goto err; } pp[n] = p; if (!sk_OPENSSL_PSTRING_push(ret->data, pp)) { fprintf(stderr, "failure in sk_push\n"); er = 2; goto err; } } er = 0; err: BUF_MEM_free(buf); if (er) { if (er == 1) fprintf(stderr, "malloc failure\n"); if (ret != NULL) { if (ret->data != NULL) sk_OPENSSL_PSTRING_free(ret->data); free(ret->index); free(ret->qual); free(ret); } return (NULL); } else return (ret); } OPENSSL_STRING * TXT_DB_get_by_index(TXT_DB *db, int idx, OPENSSL_STRING *value) { OPENSSL_STRING *ret; LHASH_OF(OPENSSL_STRING) *lh; if (idx >= db->num_fields) { db->error = DB_ERROR_INDEX_OUT_OF_RANGE; return (NULL); } lh = db->index[idx]; if (lh == NULL) { db->error = DB_ERROR_NO_INDEX; return (NULL); } ret = lh_OPENSSL_STRING_retrieve(lh, value); db->error = DB_ERROR_OK; return (ret); } int TXT_DB_create_index(TXT_DB *db, int field, int (*qual)(OPENSSL_STRING *), LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp) { LHASH_OF(OPENSSL_STRING) *idx; OPENSSL_STRING *r; int i, n; if (field >= db->num_fields) { db->error = DB_ERROR_INDEX_OUT_OF_RANGE; return (0); } /* FIXME: we lose type checking at this point */ if ((idx = (LHASH_OF(OPENSSL_STRING) *)lh_new(hash, cmp)) == NULL) { db->error = DB_ERROR_MALLOC; return (0); } n = sk_OPENSSL_PSTRING_num(db->data); for (i = 0; i < n; i++) { r = sk_OPENSSL_PSTRING_value(db->data, i); if ((qual != NULL) && (qual(r) == 0)) continue; if ((r = lh_OPENSSL_STRING_insert(idx, r)) != NULL) { db->error = DB_ERROR_INDEX_CLASH; db->arg1 = sk_OPENSSL_PSTRING_find(db->data, r); db->arg2 = i; lh_OPENSSL_STRING_free(idx); return (0); } } if (db->index[field] != NULL) lh_OPENSSL_STRING_free(db->index[field]); db->index[field] = idx; db->qual[field] = qual; return (1); } long TXT_DB_write(BIO *out, TXT_DB *db) { long i, j,n, nn, l, tot = 0; char *p, **pp, *f; BUF_MEM *buf = NULL; long ret = -1; if ((buf = BUF_MEM_new()) == NULL) goto err; n = sk_OPENSSL_PSTRING_num(db->data); nn = db->num_fields; for (i = 0; i < n; i++) { pp = sk_OPENSSL_PSTRING_value(db->data, i); l = 0; for (j = 0; j < nn; j++) { if (pp[j] != NULL) l += strlen(pp[j]); } if (!BUF_MEM_grow_clean(buf, (int)(l*2 + nn))) goto err; p = buf->data; for (j = 0; j < nn; j++) { f = pp[j]; if (f != NULL) for (;;) { if (*f == '\0') break; if (*f == '\t') *(p++) = '\\'; *(p++) = *(f++); } *(p++) = '\t'; } p[-1] = '\n'; j = p - buf->data; if (BIO_write(out, buf->data, (int)j) != j) goto err; tot += j; } ret = tot; err: if (buf != NULL) BUF_MEM_free(buf); return (ret); } int TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *row) { int i; OPENSSL_STRING *r; for (i = 0; i < db->num_fields; i++) { if (db->index[i] != NULL) { if ((db->qual[i] != NULL) && (db->qual[i](row) == 0)) continue; r = lh_OPENSSL_STRING_retrieve(db->index[i], row); if (r != NULL) { db->error = DB_ERROR_INDEX_CLASH; db->arg1 = i; db->arg_row = r; goto err; } } } /* We have passed the index checks, now just append and insert */ if (!sk_OPENSSL_PSTRING_push(db->data, row)) { db->error = DB_ERROR_MALLOC; goto err; } for (i = 0; i < db->num_fields; i++) { if (db->index[i] != NULL) { if ((db->qual[i] != NULL) && (db->qual[i](row) == 0)) continue; (void)lh_OPENSSL_STRING_insert(db->index[i], row); } } return (1); err: return (0); } void TXT_DB_free(TXT_DB *db) { int i, n; char **p, *max; if (db == NULL) return; if (db->index != NULL) { for (i = db->num_fields - 1; i >= 0; i--) if (db->index[i] != NULL) lh_OPENSSL_STRING_free(db->index[i]); free(db->index); } free(db->qual); if (db->data != NULL) { for (i = sk_OPENSSL_PSTRING_num(db->data) - 1; i >= 0; i--) { /* check if any 'fields' have been allocated * from outside of the initial block */ p = sk_OPENSSL_PSTRING_value(db->data, i); max = p[db->num_fields]; /* last address */ if (max == NULL) /* new row */ { for (n = 0; n < db->num_fields; n++) free(p[n]); } else { for (n = 0; n < db->num_fields; n++) { if (((p[n] < (char *)p) || (p[n] > max)) && (p[n] != NULL)) free(p[n]); } } free(sk_OPENSSL_PSTRING_value(db->data, i)); } sk_OPENSSL_PSTRING_free(db->data); } free(db); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bf/0000755000000000000000000000000012666635521020441 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/bf/bf_cfb64.c0000644000175000017500000001053712360020705020367 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "bf_locl.h" /* The input and output encrypted as though 64bit cfb mode is being * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, const BF_KEY *schedule, unsigned char *ivec, int *num, int encrypt) { register BF_LONG v0,v1,t; register int n= *num; register long l=length; BF_LONG ti[2]; unsigned char *iv,c,cc; iv=(unsigned char *)ivec; if (encrypt) { while (l--) { if (n == 0) { n2l(iv,v0); ti[0]=v0; n2l(iv,v1); ti[1]=v1; BF_encrypt((BF_LONG *)ti,schedule); iv=(unsigned char *)ivec; t=ti[0]; l2n(t,iv); t=ti[1]; l2n(t,iv); iv=(unsigned char *)ivec; } c= *(in++)^iv[n]; *(out++)=c; iv[n]=c; n=(n+1)&0x07; } } else { while (l--) { if (n == 0) { n2l(iv,v0); ti[0]=v0; n2l(iv,v1); ti[1]=v1; BF_encrypt((BF_LONG *)ti,schedule); iv=(unsigned char *)ivec; t=ti[0]; l2n(t,iv); t=ti[1]; l2n(t,iv); iv=(unsigned char *)ivec; } cc= *(in++); c=iv[n]; iv[n]=cc; *(out++)=c^cc; n=(n+1)&0x07; } } v0=v1=ti[0]=ti[1]=t=c=cc=0; *num=n; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bf/bf_pi.h0000644000175000017500000004161612360020705020102 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ static const BF_KEY bf_init= { { 0x243f6a88L, 0x85a308d3L, 0x13198a2eL, 0x03707344L, 0xa4093822L, 0x299f31d0L, 0x082efa98L, 0xec4e6c89L, 0x452821e6L, 0x38d01377L, 0xbe5466cfL, 0x34e90c6cL, 0xc0ac29b7L, 0xc97c50ddL, 0x3f84d5b5L, 0xb5470917L, 0x9216d5d9L, 0x8979fb1b },{ 0xd1310ba6L, 0x98dfb5acL, 0x2ffd72dbL, 0xd01adfb7L, 0xb8e1afedL, 0x6a267e96L, 0xba7c9045L, 0xf12c7f99L, 0x24a19947L, 0xb3916cf7L, 0x0801f2e2L, 0x858efc16L, 0x636920d8L, 0x71574e69L, 0xa458fea3L, 0xf4933d7eL, 0x0d95748fL, 0x728eb658L, 0x718bcd58L, 0x82154aeeL, 0x7b54a41dL, 0xc25a59b5L, 0x9c30d539L, 0x2af26013L, 0xc5d1b023L, 0x286085f0L, 0xca417918L, 0xb8db38efL, 0x8e79dcb0L, 0x603a180eL, 0x6c9e0e8bL, 0xb01e8a3eL, 0xd71577c1L, 0xbd314b27L, 0x78af2fdaL, 0x55605c60L, 0xe65525f3L, 0xaa55ab94L, 0x57489862L, 0x63e81440L, 0x55ca396aL, 0x2aab10b6L, 0xb4cc5c34L, 0x1141e8ceL, 0xa15486afL, 0x7c72e993L, 0xb3ee1411L, 0x636fbc2aL, 0x2ba9c55dL, 0x741831f6L, 0xce5c3e16L, 0x9b87931eL, 0xafd6ba33L, 0x6c24cf5cL, 0x7a325381L, 0x28958677L, 0x3b8f4898L, 0x6b4bb9afL, 0xc4bfe81bL, 0x66282193L, 0x61d809ccL, 0xfb21a991L, 0x487cac60L, 0x5dec8032L, 0xef845d5dL, 0xe98575b1L, 0xdc262302L, 0xeb651b88L, 0x23893e81L, 0xd396acc5L, 0x0f6d6ff3L, 0x83f44239L, 0x2e0b4482L, 0xa4842004L, 0x69c8f04aL, 0x9e1f9b5eL, 0x21c66842L, 0xf6e96c9aL, 0x670c9c61L, 0xabd388f0L, 0x6a51a0d2L, 0xd8542f68L, 0x960fa728L, 0xab5133a3L, 0x6eef0b6cL, 0x137a3be4L, 0xba3bf050L, 0x7efb2a98L, 0xa1f1651dL, 0x39af0176L, 0x66ca593eL, 0x82430e88L, 0x8cee8619L, 0x456f9fb4L, 0x7d84a5c3L, 0x3b8b5ebeL, 0xe06f75d8L, 0x85c12073L, 0x401a449fL, 0x56c16aa6L, 0x4ed3aa62L, 0x363f7706L, 0x1bfedf72L, 0x429b023dL, 0x37d0d724L, 0xd00a1248L, 0xdb0fead3L, 0x49f1c09bL, 0x075372c9L, 0x80991b7bL, 0x25d479d8L, 0xf6e8def7L, 0xe3fe501aL, 0xb6794c3bL, 0x976ce0bdL, 0x04c006baL, 0xc1a94fb6L, 0x409f60c4L, 0x5e5c9ec2L, 0x196a2463L, 0x68fb6fafL, 0x3e6c53b5L, 0x1339b2ebL, 0x3b52ec6fL, 0x6dfc511fL, 0x9b30952cL, 0xcc814544L, 0xaf5ebd09L, 0xbee3d004L, 0xde334afdL, 0x660f2807L, 0x192e4bb3L, 0xc0cba857L, 0x45c8740fL, 0xd20b5f39L, 0xb9d3fbdbL, 0x5579c0bdL, 0x1a60320aL, 0xd6a100c6L, 0x402c7279L, 0x679f25feL, 0xfb1fa3ccL, 0x8ea5e9f8L, 0xdb3222f8L, 0x3c7516dfL, 0xfd616b15L, 0x2f501ec8L, 0xad0552abL, 0x323db5faL, 0xfd238760L, 0x53317b48L, 0x3e00df82L, 0x9e5c57bbL, 0xca6f8ca0L, 0x1a87562eL, 0xdf1769dbL, 0xd542a8f6L, 0x287effc3L, 0xac6732c6L, 0x8c4f5573L, 0x695b27b0L, 0xbbca58c8L, 0xe1ffa35dL, 0xb8f011a0L, 0x10fa3d98L, 0xfd2183b8L, 0x4afcb56cL, 0x2dd1d35bL, 0x9a53e479L, 0xb6f84565L, 0xd28e49bcL, 0x4bfb9790L, 0xe1ddf2daL, 0xa4cb7e33L, 0x62fb1341L, 0xcee4c6e8L, 0xef20cadaL, 0x36774c01L, 0xd07e9efeL, 0x2bf11fb4L, 0x95dbda4dL, 0xae909198L, 0xeaad8e71L, 0x6b93d5a0L, 0xd08ed1d0L, 0xafc725e0L, 0x8e3c5b2fL, 0x8e7594b7L, 0x8ff6e2fbL, 0xf2122b64L, 0x8888b812L, 0x900df01cL, 0x4fad5ea0L, 0x688fc31cL, 0xd1cff191L, 0xb3a8c1adL, 0x2f2f2218L, 0xbe0e1777L, 0xea752dfeL, 0x8b021fa1L, 0xe5a0cc0fL, 0xb56f74e8L, 0x18acf3d6L, 0xce89e299L, 0xb4a84fe0L, 0xfd13e0b7L, 0x7cc43b81L, 0xd2ada8d9L, 0x165fa266L, 0x80957705L, 0x93cc7314L, 0x211a1477L, 0xe6ad2065L, 0x77b5fa86L, 0xc75442f5L, 0xfb9d35cfL, 0xebcdaf0cL, 0x7b3e89a0L, 0xd6411bd3L, 0xae1e7e49L, 0x00250e2dL, 0x2071b35eL, 0x226800bbL, 0x57b8e0afL, 0x2464369bL, 0xf009b91eL, 0x5563911dL, 0x59dfa6aaL, 0x78c14389L, 0xd95a537fL, 0x207d5ba2L, 0x02e5b9c5L, 0x83260376L, 0x6295cfa9L, 0x11c81968L, 0x4e734a41L, 0xb3472dcaL, 0x7b14a94aL, 0x1b510052L, 0x9a532915L, 0xd60f573fL, 0xbc9bc6e4L, 0x2b60a476L, 0x81e67400L, 0x08ba6fb5L, 0x571be91fL, 0xf296ec6bL, 0x2a0dd915L, 0xb6636521L, 0xe7b9f9b6L, 0xff34052eL, 0xc5855664L, 0x53b02d5dL, 0xa99f8fa1L, 0x08ba4799L, 0x6e85076aL, 0x4b7a70e9L, 0xb5b32944L, 0xdb75092eL, 0xc4192623L, 0xad6ea6b0L, 0x49a7df7dL, 0x9cee60b8L, 0x8fedb266L, 0xecaa8c71L, 0x699a17ffL, 0x5664526cL, 0xc2b19ee1L, 0x193602a5L, 0x75094c29L, 0xa0591340L, 0xe4183a3eL, 0x3f54989aL, 0x5b429d65L, 0x6b8fe4d6L, 0x99f73fd6L, 0xa1d29c07L, 0xefe830f5L, 0x4d2d38e6L, 0xf0255dc1L, 0x4cdd2086L, 0x8470eb26L, 0x6382e9c6L, 0x021ecc5eL, 0x09686b3fL, 0x3ebaefc9L, 0x3c971814L, 0x6b6a70a1L, 0x687f3584L, 0x52a0e286L, 0xb79c5305L, 0xaa500737L, 0x3e07841cL, 0x7fdeae5cL, 0x8e7d44ecL, 0x5716f2b8L, 0xb03ada37L, 0xf0500c0dL, 0xf01c1f04L, 0x0200b3ffL, 0xae0cf51aL, 0x3cb574b2L, 0x25837a58L, 0xdc0921bdL, 0xd19113f9L, 0x7ca92ff6L, 0x94324773L, 0x22f54701L, 0x3ae5e581L, 0x37c2dadcL, 0xc8b57634L, 0x9af3dda7L, 0xa9446146L, 0x0fd0030eL, 0xecc8c73eL, 0xa4751e41L, 0xe238cd99L, 0x3bea0e2fL, 0x3280bba1L, 0x183eb331L, 0x4e548b38L, 0x4f6db908L, 0x6f420d03L, 0xf60a04bfL, 0x2cb81290L, 0x24977c79L, 0x5679b072L, 0xbcaf89afL, 0xde9a771fL, 0xd9930810L, 0xb38bae12L, 0xdccf3f2eL, 0x5512721fL, 0x2e6b7124L, 0x501adde6L, 0x9f84cd87L, 0x7a584718L, 0x7408da17L, 0xbc9f9abcL, 0xe94b7d8cL, 0xec7aec3aL, 0xdb851dfaL, 0x63094366L, 0xc464c3d2L, 0xef1c1847L, 0x3215d908L, 0xdd433b37L, 0x24c2ba16L, 0x12a14d43L, 0x2a65c451L, 0x50940002L, 0x133ae4ddL, 0x71dff89eL, 0x10314e55L, 0x81ac77d6L, 0x5f11199bL, 0x043556f1L, 0xd7a3c76bL, 0x3c11183bL, 0x5924a509L, 0xf28fe6edL, 0x97f1fbfaL, 0x9ebabf2cL, 0x1e153c6eL, 0x86e34570L, 0xeae96fb1L, 0x860e5e0aL, 0x5a3e2ab3L, 0x771fe71cL, 0x4e3d06faL, 0x2965dcb9L, 0x99e71d0fL, 0x803e89d6L, 0x5266c825L, 0x2e4cc978L, 0x9c10b36aL, 0xc6150ebaL, 0x94e2ea78L, 0xa5fc3c53L, 0x1e0a2df4L, 0xf2f74ea7L, 0x361d2b3dL, 0x1939260fL, 0x19c27960L, 0x5223a708L, 0xf71312b6L, 0xebadfe6eL, 0xeac31f66L, 0xe3bc4595L, 0xa67bc883L, 0xb17f37d1L, 0x018cff28L, 0xc332ddefL, 0xbe6c5aa5L, 0x65582185L, 0x68ab9802L, 0xeecea50fL, 0xdb2f953bL, 0x2aef7dadL, 0x5b6e2f84L, 0x1521b628L, 0x29076170L, 0xecdd4775L, 0x619f1510L, 0x13cca830L, 0xeb61bd96L, 0x0334fe1eL, 0xaa0363cfL, 0xb5735c90L, 0x4c70a239L, 0xd59e9e0bL, 0xcbaade14L, 0xeecc86bcL, 0x60622ca7L, 0x9cab5cabL, 0xb2f3846eL, 0x648b1eafL, 0x19bdf0caL, 0xa02369b9L, 0x655abb50L, 0x40685a32L, 0x3c2ab4b3L, 0x319ee9d5L, 0xc021b8f7L, 0x9b540b19L, 0x875fa099L, 0x95f7997eL, 0x623d7da8L, 0xf837889aL, 0x97e32d77L, 0x11ed935fL, 0x16681281L, 0x0e358829L, 0xc7e61fd6L, 0x96dedfa1L, 0x7858ba99L, 0x57f584a5L, 0x1b227263L, 0x9b83c3ffL, 0x1ac24696L, 0xcdb30aebL, 0x532e3054L, 0x8fd948e4L, 0x6dbc3128L, 0x58ebf2efL, 0x34c6ffeaL, 0xfe28ed61L, 0xee7c3c73L, 0x5d4a14d9L, 0xe864b7e3L, 0x42105d14L, 0x203e13e0L, 0x45eee2b6L, 0xa3aaabeaL, 0xdb6c4f15L, 0xfacb4fd0L, 0xc742f442L, 0xef6abbb5L, 0x654f3b1dL, 0x41cd2105L, 0xd81e799eL, 0x86854dc7L, 0xe44b476aL, 0x3d816250L, 0xcf62a1f2L, 0x5b8d2646L, 0xfc8883a0L, 0xc1c7b6a3L, 0x7f1524c3L, 0x69cb7492L, 0x47848a0bL, 0x5692b285L, 0x095bbf00L, 0xad19489dL, 0x1462b174L, 0x23820e00L, 0x58428d2aL, 0x0c55f5eaL, 0x1dadf43eL, 0x233f7061L, 0x3372f092L, 0x8d937e41L, 0xd65fecf1L, 0x6c223bdbL, 0x7cde3759L, 0xcbee7460L, 0x4085f2a7L, 0xce77326eL, 0xa6078084L, 0x19f8509eL, 0xe8efd855L, 0x61d99735L, 0xa969a7aaL, 0xc50c06c2L, 0x5a04abfcL, 0x800bcadcL, 0x9e447a2eL, 0xc3453484L, 0xfdd56705L, 0x0e1e9ec9L, 0xdb73dbd3L, 0x105588cdL, 0x675fda79L, 0xe3674340L, 0xc5c43465L, 0x713e38d8L, 0x3d28f89eL, 0xf16dff20L, 0x153e21e7L, 0x8fb03d4aL, 0xe6e39f2bL, 0xdb83adf7L, 0xe93d5a68L, 0x948140f7L, 0xf64c261cL, 0x94692934L, 0x411520f7L, 0x7602d4f7L, 0xbcf46b2eL, 0xd4a20068L, 0xd4082471L, 0x3320f46aL, 0x43b7d4b7L, 0x500061afL, 0x1e39f62eL, 0x97244546L, 0x14214f74L, 0xbf8b8840L, 0x4d95fc1dL, 0x96b591afL, 0x70f4ddd3L, 0x66a02f45L, 0xbfbc09ecL, 0x03bd9785L, 0x7fac6dd0L, 0x31cb8504L, 0x96eb27b3L, 0x55fd3941L, 0xda2547e6L, 0xabca0a9aL, 0x28507825L, 0x530429f4L, 0x0a2c86daL, 0xe9b66dfbL, 0x68dc1462L, 0xd7486900L, 0x680ec0a4L, 0x27a18deeL, 0x4f3ffea2L, 0xe887ad8cL, 0xb58ce006L, 0x7af4d6b6L, 0xaace1e7cL, 0xd3375fecL, 0xce78a399L, 0x406b2a42L, 0x20fe9e35L, 0xd9f385b9L, 0xee39d7abL, 0x3b124e8bL, 0x1dc9faf7L, 0x4b6d1856L, 0x26a36631L, 0xeae397b2L, 0x3a6efa74L, 0xdd5b4332L, 0x6841e7f7L, 0xca7820fbL, 0xfb0af54eL, 0xd8feb397L, 0x454056acL, 0xba489527L, 0x55533a3aL, 0x20838d87L, 0xfe6ba9b7L, 0xd096954bL, 0x55a867bcL, 0xa1159a58L, 0xcca92963L, 0x99e1db33L, 0xa62a4a56L, 0x3f3125f9L, 0x5ef47e1cL, 0x9029317cL, 0xfdf8e802L, 0x04272f70L, 0x80bb155cL, 0x05282ce3L, 0x95c11548L, 0xe4c66d22L, 0x48c1133fL, 0xc70f86dcL, 0x07f9c9eeL, 0x41041f0fL, 0x404779a4L, 0x5d886e17L, 0x325f51ebL, 0xd59bc0d1L, 0xf2bcc18fL, 0x41113564L, 0x257b7834L, 0x602a9c60L, 0xdff8e8a3L, 0x1f636c1bL, 0x0e12b4c2L, 0x02e1329eL, 0xaf664fd1L, 0xcad18115L, 0x6b2395e0L, 0x333e92e1L, 0x3b240b62L, 0xeebeb922L, 0x85b2a20eL, 0xe6ba0d99L, 0xde720c8cL, 0x2da2f728L, 0xd0127845L, 0x95b794fdL, 0x647d0862L, 0xe7ccf5f0L, 0x5449a36fL, 0x877d48faL, 0xc39dfd27L, 0xf33e8d1eL, 0x0a476341L, 0x992eff74L, 0x3a6f6eabL, 0xf4f8fd37L, 0xa812dc60L, 0xa1ebddf8L, 0x991be14cL, 0xdb6e6b0dL, 0xc67b5510L, 0x6d672c37L, 0x2765d43bL, 0xdcd0e804L, 0xf1290dc7L, 0xcc00ffa3L, 0xb5390f92L, 0x690fed0bL, 0x667b9ffbL, 0xcedb7d9cL, 0xa091cf0bL, 0xd9155ea3L, 0xbb132f88L, 0x515bad24L, 0x7b9479bfL, 0x763bd6ebL, 0x37392eb3L, 0xcc115979L, 0x8026e297L, 0xf42e312dL, 0x6842ada7L, 0xc66a2b3bL, 0x12754cccL, 0x782ef11cL, 0x6a124237L, 0xb79251e7L, 0x06a1bbe6L, 0x4bfb6350L, 0x1a6b1018L, 0x11caedfaL, 0x3d25bdd8L, 0xe2e1c3c9L, 0x44421659L, 0x0a121386L, 0xd90cec6eL, 0xd5abea2aL, 0x64af674eL, 0xda86a85fL, 0xbebfe988L, 0x64e4c3feL, 0x9dbc8057L, 0xf0f7c086L, 0x60787bf8L, 0x6003604dL, 0xd1fd8346L, 0xf6381fb0L, 0x7745ae04L, 0xd736fcccL, 0x83426b33L, 0xf01eab71L, 0xb0804187L, 0x3c005e5fL, 0x77a057beL, 0xbde8ae24L, 0x55464299L, 0xbf582e61L, 0x4e58f48fL, 0xf2ddfda2L, 0xf474ef38L, 0x8789bdc2L, 0x5366f9c3L, 0xc8b38e74L, 0xb475f255L, 0x46fcd9b9L, 0x7aeb2661L, 0x8b1ddf84L, 0x846a0e79L, 0x915f95e2L, 0x466e598eL, 0x20b45770L, 0x8cd55591L, 0xc902de4cL, 0xb90bace1L, 0xbb8205d0L, 0x11a86248L, 0x7574a99eL, 0xb77f19b6L, 0xe0a9dc09L, 0x662d09a1L, 0xc4324633L, 0xe85a1f02L, 0x09f0be8cL, 0x4a99a025L, 0x1d6efe10L, 0x1ab93d1dL, 0x0ba5a4dfL, 0xa186f20fL, 0x2868f169L, 0xdcb7da83L, 0x573906feL, 0xa1e2ce9bL, 0x4fcd7f52L, 0x50115e01L, 0xa70683faL, 0xa002b5c4L, 0x0de6d027L, 0x9af88c27L, 0x773f8641L, 0xc3604c06L, 0x61a806b5L, 0xf0177a28L, 0xc0f586e0L, 0x006058aaL, 0x30dc7d62L, 0x11e69ed7L, 0x2338ea63L, 0x53c2dd94L, 0xc2c21634L, 0xbbcbee56L, 0x90bcb6deL, 0xebfc7da1L, 0xce591d76L, 0x6f05e409L, 0x4b7c0188L, 0x39720a3dL, 0x7c927c24L, 0x86e3725fL, 0x724d9db9L, 0x1ac15bb4L, 0xd39eb8fcL, 0xed545578L, 0x08fca5b5L, 0xd83d7cd3L, 0x4dad0fc4L, 0x1e50ef5eL, 0xb161e6f8L, 0xa28514d9L, 0x6c51133cL, 0x6fd5c7e7L, 0x56e14ec4L, 0x362abfceL, 0xddc6c837L, 0xd79a3234L, 0x92638212L, 0x670efa8eL, 0x406000e0L, 0x3a39ce37L, 0xd3faf5cfL, 0xabc27737L, 0x5ac52d1bL, 0x5cb0679eL, 0x4fa33742L, 0xd3822740L, 0x99bc9bbeL, 0xd5118e9dL, 0xbf0f7315L, 0xd62d1c7eL, 0xc700c47bL, 0xb78c1b6bL, 0x21a19045L, 0xb26eb1beL, 0x6a366eb4L, 0x5748ab2fL, 0xbc946e79L, 0xc6a376d2L, 0x6549c2c8L, 0x530ff8eeL, 0x468dde7dL, 0xd5730a1dL, 0x4cd04dc6L, 0x2939bbdbL, 0xa9ba4650L, 0xac9526e8L, 0xbe5ee304L, 0xa1fad5f0L, 0x6a2d519aL, 0x63ef8ce2L, 0x9a86ee22L, 0xc089c2b8L, 0x43242ef6L, 0xa51e03aaL, 0x9cf2d0a4L, 0x83c061baL, 0x9be96a4dL, 0x8fe51550L, 0xba645bd6L, 0x2826a2f9L, 0xa73a3ae1L, 0x4ba99586L, 0xef5562e9L, 0xc72fefd3L, 0xf752f7daL, 0x3f046f69L, 0x77fa0a59L, 0x80e4a915L, 0x87b08601L, 0x9b09e6adL, 0x3b3ee593L, 0xe990fd5aL, 0x9e34d797L, 0x2cf0b7d9L, 0x022b8b51L, 0x96d5ac3aL, 0x017da67dL, 0xd1cf3ed6L, 0x7c7d2d28L, 0x1f9f25cfL, 0xadf2b89bL, 0x5ad6b472L, 0x5a88f54cL, 0xe029ac71L, 0xe019a5e6L, 0x47b0acfdL, 0xed93fa9bL, 0xe8d3c48dL, 0x283b57ccL, 0xf8d56629L, 0x79132e28L, 0x785f0191L, 0xed756055L, 0xf7960e44L, 0xe3d35e8cL, 0x15056dd4L, 0x88f46dbaL, 0x03a16125L, 0x0564f0bdL, 0xc3eb9e15L, 0x3c9057a2L, 0x97271aecL, 0xa93a072aL, 0x1b3f6d9bL, 0x1e6321f5L, 0xf59c66fbL, 0x26dcf319L, 0x7533d928L, 0xb155fdf5L, 0x03563482L, 0x8aba3cbbL, 0x28517711L, 0xc20ad9f8L, 0xabcc5167L, 0xccad925fL, 0x4de81751L, 0x3830dc8eL, 0x379d5862L, 0x9320f991L, 0xea7a90c2L, 0xfb3e7bceL, 0x5121ce64L, 0x774fbe32L, 0xa8b6e37eL, 0xc3293d46L, 0x48de5369L, 0x6413e680L, 0xa2ae0810L, 0xdd6db224L, 0x69852dfdL, 0x09072166L, 0xb39a460aL, 0x6445c0ddL, 0x586cdecfL, 0x1c20c8aeL, 0x5bbef7ddL, 0x1b588d40L, 0xccd2017fL, 0x6bb4e3bbL, 0xdda26a7eL, 0x3a59ff45L, 0x3e350a44L, 0xbcb4cdd5L, 0x72eacea8L, 0xfa6484bbL, 0x8d6612aeL, 0xbf3c6f47L, 0xd29be463L, 0x542f5d9eL, 0xaec2771bL, 0xf64e6370L, 0x740e0d8dL, 0xe75b1357L, 0xf8721671L, 0xaf537d5dL, 0x4040cb08L, 0x4eb4e2ccL, 0x34d2466aL, 0x0115af84L, 0xe1b00428L, 0x95983a1dL, 0x06b89fb4L, 0xce6ea048L, 0x6f3f3b82L, 0x3520ab82L, 0x011a1d4bL, 0x277227f8L, 0x611560b1L, 0xe7933fdcL, 0xbb3a792bL, 0x344525bdL, 0xa08839e1L, 0x51ce794bL, 0x2f32c9b7L, 0xa01fbac9L, 0xe01cc87eL, 0xbcc7d1f6L, 0xcf0111c3L, 0xa1e8aac7L, 0x1a908749L, 0xd44fbd9aL, 0xd0dadecbL, 0xd50ada38L, 0x0339c32aL, 0xc6913667L, 0x8df9317cL, 0xe0b12b4fL, 0xf79e59b7L, 0x43f5bb3aL, 0xf2d519ffL, 0x27d9459cL, 0xbf97222cL, 0x15e6fc2aL, 0x0f91fc71L, 0x9b941525L, 0xfae59361L, 0xceb69cebL, 0xc2a86459L, 0x12baa8d1L, 0xb6c1075eL, 0xe3056a0cL, 0x10d25065L, 0xcb03a442L, 0xe0ec6e0eL, 0x1698db3bL, 0x4c98a0beL, 0x3278e964L, 0x9f1f9532L, 0xe0d392dfL, 0xd3a0342bL, 0x8971f21eL, 0x1b0a7441L, 0x4ba3348cL, 0xc5be7120L, 0xc37632d8L, 0xdf359f8dL, 0x9b992f2eL, 0xe60b6f47L, 0x0fe3f11dL, 0xe54cda54L, 0x1edad891L, 0xce6279cfL, 0xcd3e7e6fL, 0x1618b166L, 0xfd2c1d05L, 0x848fd2c5L, 0xf6fb2299L, 0xf523f357L, 0xa6327623L, 0x93a83531L, 0x56cccd02L, 0xacf08162L, 0x5a75ebb5L, 0x6e163697L, 0x88d273ccL, 0xde966292L, 0x81b949d0L, 0x4c50901bL, 0x71c65614L, 0xe6c6c7bdL, 0x327a140aL, 0x45e1d006L, 0xc3f27b9aL, 0xc9aa53fdL, 0x62a80f00L, 0xbb25bfe2L, 0x35bdd2f6L, 0x71126905L, 0xb2040222L, 0xb6cbcf7cL, 0xcd769c2bL, 0x53113ec0L, 0x1640e3d3L, 0x38abbd60L, 0x2547adf0L, 0xba38209cL, 0xf746ce76L, 0x77afa1c5L, 0x20756060L, 0x85cbfe4eL, 0x8ae88dd8L, 0x7aaaf9b0L, 0x4cf9aa7eL, 0x1948c25cL, 0x02fb8a8cL, 0x01c36ae4L, 0xd6ebe1f9L, 0x90d4f869L, 0xa65cdea0L, 0x3f09252dL, 0xc208e69fL, 0xb74e6132L, 0xce77e25bL, 0x578fdfe3L, 0x3ac372e6L, } }; deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bf/bf_enc.c0000644000175000017500000001677012360020705020235 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "bf_locl.h" /* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' * (From LECTURE NOTES IN COMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993) */ #if (BF_ROUNDS != 16) && (BF_ROUNDS != 20) #error If you set BF_ROUNDS to some value other than 16 or 20, you will have \ to modify the code. #endif void BF_encrypt(BF_LONG *data, const BF_KEY *key) { #ifndef BF_PTR2 register BF_LONG l,r; register const BF_LONG *p,*s; p=key->P; s= &(key->S[0]); l=data[0]; r=data[1]; l^=p[0]; BF_ENC(r,l,s,p[ 1]); BF_ENC(l,r,s,p[ 2]); BF_ENC(r,l,s,p[ 3]); BF_ENC(l,r,s,p[ 4]); BF_ENC(r,l,s,p[ 5]); BF_ENC(l,r,s,p[ 6]); BF_ENC(r,l,s,p[ 7]); BF_ENC(l,r,s,p[ 8]); BF_ENC(r,l,s,p[ 9]); BF_ENC(l,r,s,p[10]); BF_ENC(r,l,s,p[11]); BF_ENC(l,r,s,p[12]); BF_ENC(r,l,s,p[13]); BF_ENC(l,r,s,p[14]); BF_ENC(r,l,s,p[15]); BF_ENC(l,r,s,p[16]); #if BF_ROUNDS == 20 BF_ENC(r,l,s,p[17]); BF_ENC(l,r,s,p[18]); BF_ENC(r,l,s,p[19]); BF_ENC(l,r,s,p[20]); #endif r^=p[BF_ROUNDS+1]; data[1]=l&0xffffffffL; data[0]=r&0xffffffffL; #else register BF_LONG l,r,t,*k; l=data[0]; r=data[1]; k=(BF_LONG*)key; l^=k[0]; BF_ENC(r,l,k, 1); BF_ENC(l,r,k, 2); BF_ENC(r,l,k, 3); BF_ENC(l,r,k, 4); BF_ENC(r,l,k, 5); BF_ENC(l,r,k, 6); BF_ENC(r,l,k, 7); BF_ENC(l,r,k, 8); BF_ENC(r,l,k, 9); BF_ENC(l,r,k,10); BF_ENC(r,l,k,11); BF_ENC(l,r,k,12); BF_ENC(r,l,k,13); BF_ENC(l,r,k,14); BF_ENC(r,l,k,15); BF_ENC(l,r,k,16); #if BF_ROUNDS == 20 BF_ENC(r,l,k,17); BF_ENC(l,r,k,18); BF_ENC(r,l,k,19); BF_ENC(l,r,k,20); #endif r^=k[BF_ROUNDS+1]; data[1]=l&0xffffffffL; data[0]=r&0xffffffffL; #endif } #ifndef BF_DEFAULT_OPTIONS void BF_decrypt(BF_LONG *data, const BF_KEY *key) { #ifndef BF_PTR2 register BF_LONG l,r; register const BF_LONG *p,*s; p=key->P; s= &(key->S[0]); l=data[0]; r=data[1]; l^=p[BF_ROUNDS+1]; #if BF_ROUNDS == 20 BF_ENC(r,l,s,p[20]); BF_ENC(l,r,s,p[19]); BF_ENC(r,l,s,p[18]); BF_ENC(l,r,s,p[17]); #endif BF_ENC(r,l,s,p[16]); BF_ENC(l,r,s,p[15]); BF_ENC(r,l,s,p[14]); BF_ENC(l,r,s,p[13]); BF_ENC(r,l,s,p[12]); BF_ENC(l,r,s,p[11]); BF_ENC(r,l,s,p[10]); BF_ENC(l,r,s,p[ 9]); BF_ENC(r,l,s,p[ 8]); BF_ENC(l,r,s,p[ 7]); BF_ENC(r,l,s,p[ 6]); BF_ENC(l,r,s,p[ 5]); BF_ENC(r,l,s,p[ 4]); BF_ENC(l,r,s,p[ 3]); BF_ENC(r,l,s,p[ 2]); BF_ENC(l,r,s,p[ 1]); r^=p[0]; data[1]=l&0xffffffffL; data[0]=r&0xffffffffL; #else register BF_LONG l,r,t,*k; l=data[0]; r=data[1]; k=(BF_LONG *)key; l^=k[BF_ROUNDS+1]; #if BF_ROUNDS == 20 BF_ENC(r,l,k,20); BF_ENC(l,r,k,19); BF_ENC(r,l,k,18); BF_ENC(l,r,k,17); #endif BF_ENC(r,l,k,16); BF_ENC(l,r,k,15); BF_ENC(r,l,k,14); BF_ENC(l,r,k,13); BF_ENC(r,l,k,12); BF_ENC(l,r,k,11); BF_ENC(r,l,k,10); BF_ENC(l,r,k, 9); BF_ENC(r,l,k, 8); BF_ENC(l,r,k, 7); BF_ENC(r,l,k, 6); BF_ENC(l,r,k, 5); BF_ENC(r,l,k, 4); BF_ENC(l,r,k, 3); BF_ENC(r,l,k, 2); BF_ENC(l,r,k, 1); r^=k[0]; data[1]=l&0xffffffffL; data[0]=r&0xffffffffL; #endif } void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, const BF_KEY *schedule, unsigned char *ivec, int encrypt) { register BF_LONG tin0,tin1; register BF_LONG tout0,tout1,xor0,xor1; register long l=length; BF_LONG tin[2]; if (encrypt) { n2l(ivec,tout0); n2l(ivec,tout1); ivec-=8; for (l-=8; l>=0; l-=8) { n2l(in,tin0); n2l(in,tin1); tin0^=tout0; tin1^=tout1; tin[0]=tin0; tin[1]=tin1; BF_encrypt(tin,schedule); tout0=tin[0]; tout1=tin[1]; l2n(tout0,out); l2n(tout1,out); } if (l != -8) { n2ln(in,tin0,tin1,l+8); tin0^=tout0; tin1^=tout1; tin[0]=tin0; tin[1]=tin1; BF_encrypt(tin,schedule); tout0=tin[0]; tout1=tin[1]; l2n(tout0,out); l2n(tout1,out); } l2n(tout0,ivec); l2n(tout1,ivec); } else { n2l(ivec,xor0); n2l(ivec,xor1); ivec-=8; for (l-=8; l>=0; l-=8) { n2l(in,tin0); n2l(in,tin1); tin[0]=tin0; tin[1]=tin1; BF_decrypt(tin,schedule); tout0=tin[0]^xor0; tout1=tin[1]^xor1; l2n(tout0,out); l2n(tout1,out); xor0=tin0; xor1=tin1; } if (l != -8) { n2l(in,tin0); n2l(in,tin1); tin[0]=tin0; tin[1]=tin1; BF_decrypt(tin,schedule); tout0=tin[0]^xor0; tout1=tin[1]^xor1; l2nn(tout0,tout1,out,l+8); xor0=tin0; xor1=tin1; } l2n(xor0,ivec); l2n(xor1,ivec); } tin0=tin1=tout0=tout1=xor0=xor1=0; tin[0]=tin[1]=0; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bf/bf_ecb.c0000644000175000017500000000762112360020705020214 0ustar /* $OpenBSD: bf_ecb.c,v 1.5 2014/06/12 15:49:28 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "bf_locl.h" #include /* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' * (From LECTURE NOTES IN COMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993) */ const char *BF_options(void) { #ifdef BF_PTR return("blowfish(ptr)"); #elif defined(BF_PTR2) return("blowfish(ptr2)"); #else return("blowfish(idx)"); #endif } void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, const BF_KEY *key, int encrypt) { BF_LONG l,d[2]; n2l(in,l); d[0]=l; n2l(in,l); d[1]=l; if (encrypt) BF_encrypt(d,key); else BF_decrypt(d,key); l=d[0]; l2n(l,out); l=d[1]; l2n(l,out); l=d[0]=d[1]=0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bf/bf_ofb64.c0000644000175000017500000001013212360020705020372 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include "bf_locl.h" /* The input and output encrypted as though 64bit ofb mode is being * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, const BF_KEY *schedule, unsigned char *ivec, int *num) { register BF_LONG v0,v1,t; register int n= *num; register long l=length; unsigned char d[8]; register char *dp; BF_LONG ti[2]; unsigned char *iv; int save=0; iv=(unsigned char *)ivec; n2l(iv,v0); n2l(iv,v1); ti[0]=v0; ti[1]=v1; dp=(char *)d; l2n(v0,dp); l2n(v1,dp); while (l--) { if (n == 0) { BF_encrypt((BF_LONG *)ti,schedule); dp=(char *)d; t=ti[0]; l2n(t,dp); t=ti[1]; l2n(t,dp); save++; } *(out++)= *(in++)^d[n]; n=(n+1)&0x07; } if (save) { v0=ti[0]; v1=ti[1]; iv=(unsigned char *)ivec; l2n(v0,iv); l2n(v1,iv); } t=v0=v1=ti[0]=ti[1]=0; *num=n; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bf/bf_locl.h0000644000175000017500000002112112360020705020410 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #ifndef HEADER_BF_LOCL_H #define HEADER_BF_LOCL_H #include /* BF_PTR, BF_PTR2 */ #undef c2l #define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ l|=((unsigned long)(*((c)++)))<< 8L, \ l|=((unsigned long)(*((c)++)))<<16L, \ l|=((unsigned long)(*((c)++)))<<24L) /* NOTE - c is not incremented as per c2l */ #undef c2ln #define c2ln(c,l1,l2,n) { \ c+=n; \ l1=l2=0; \ switch (n) { \ case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ case 5: l2|=((unsigned long)(*(--(c)))); \ case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ case 1: l1|=((unsigned long)(*(--(c)))); \ } \ } #undef l2c #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>>24L)&0xff)) /* NOTE - c is not incremented as per l2c */ #undef l2cn #define l2cn(l1,l2,c,n) { \ c+=n; \ switch (n) { \ case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ } \ } /* NOTE - c is not incremented as per n2l */ #define n2ln(c,l1,l2,n) { \ c+=n; \ l1=l2=0; \ switch (n) { \ case 8: l2 =((unsigned long)(*(--(c)))) ; \ case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ case 6: l2|=((unsigned long)(*(--(c))))<<16; \ case 5: l2|=((unsigned long)(*(--(c))))<<24; \ case 4: l1 =((unsigned long)(*(--(c)))) ; \ case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ case 2: l1|=((unsigned long)(*(--(c))))<<16; \ case 1: l1|=((unsigned long)(*(--(c))))<<24; \ } \ } /* NOTE - c is not incremented as per l2n */ #define l2nn(l1,l2,c,n) { \ c+=n; \ switch (n) { \ case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ } \ } #undef n2l #define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ l|=((unsigned long)(*((c)++)))<<16L, \ l|=((unsigned long)(*((c)++)))<< 8L, \ l|=((unsigned long)(*((c)++)))) #undef l2n #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l) )&0xff)) /* This is actually a big endian algorithm, the most significant byte * is used to lookup array 0 */ #if defined(BF_PTR2) /* * This is basically a special Intel version. Point is that Intel * doesn't have many registers, but offers a reach choice of addressing * modes. So we spare some registers by directly traversing BF_KEY * structure and hiring the most decorated addressing mode. The code * generated by EGCS is *perfectly* competitive with assembler * implementation! */ #define BF_ENC(LL,R,KEY,Pi) (\ LL^=KEY[Pi], \ t= KEY[BF_ROUNDS+2 + 0 + ((R>>24)&0xFF)], \ t+= KEY[BF_ROUNDS+2 + 256 + ((R>>16)&0xFF)], \ t^= KEY[BF_ROUNDS+2 + 512 + ((R>>8 )&0xFF)], \ t+= KEY[BF_ROUNDS+2 + 768 + ((R )&0xFF)], \ LL^=t \ ) #elif defined(BF_PTR) #ifndef BF_LONG_LOG2 #define BF_LONG_LOG2 2 /* default to BF_LONG being 32 bits */ #endif #define BF_M (0xFF<>BF_i)&BF_M gets folded into a single instruction, namely * rlwinm. So let'em double-check if their compiler does it. */ #define BF_ENC(LL,R,S,P) ( \ LL^=P, \ LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \ *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \ *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \ *(BF_LONG *)((unsigned char *)&(S[768])+((R<>24)&0xff)] + \ S[0x0100+((int)(R>>16)&0xff)])^ \ S[0x0200+((int)(R>> 8)&0xff)])+ \ S[0x0300+((int)(R )&0xff)])&0xffffffffL \ ) #endif #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/bf/bf_skey.c0000644000175000017500000000772212360020705020440 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include "bf_locl.h" #include "bf_pi.h" void BF_set_key(BF_KEY *key, int len, const unsigned char *data) { int i; BF_LONG *p,ri,in[2]; const unsigned char *d,*end; memcpy(key,&bf_init,sizeof(BF_KEY)); p=key->P; if (len > ((BF_ROUNDS+2)*4)) len=(BF_ROUNDS+2)*4; d=data; end= &(data[len]); for (i=0; i<(BF_ROUNDS+2); i++) { ri= *(d++); if (d >= end) d=data; ri<<=8; ri|= *(d++); if (d >= end) d=data; ri<<=8; ri|= *(d++); if (d >= end) d=data; ri<<=8; ri|= *(d++); if (d >= end) d=data; p[i]^=ri; } in[0]=0L; in[1]=0L; for (i=0; i<(BF_ROUNDS+2); i+=2) { BF_encrypt(in,key); p[i ]=in[0]; p[i+1]=in[1]; } p=key->S; for (i=0; i<4*256; i+=2) { BF_encrypt(in,key); p[i ]=in[0]; p[i+1]=in[1]; } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/0000755000000000000000000000000012666635521021317 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/tb_dsa.c0000644000175000017500000001015312360020705021120 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "eng_int.h" /* If this symbol is defined then ENGINE_get_default_DSA(), the function that is * used by DSA to hook in implementation code and cache defaults (etc), will * display brief debugging summaries to stderr with the 'nid'. */ /* #define ENGINE_DSA_DEBUG */ static ENGINE_TABLE *dsa_table = NULL; static const int dummy_nid = 1; void ENGINE_unregister_DSA(ENGINE *e) { engine_table_unregister(&dsa_table, e); } static void engine_unregister_all_DSA(void) { engine_table_cleanup(&dsa_table); } int ENGINE_register_DSA(ENGINE *e) { if (e->dsa_meth) return engine_table_register(&dsa_table, engine_unregister_all_DSA, e, &dummy_nid, 1, 0); return 1; } void ENGINE_register_all_DSA(void) { ENGINE *e; for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_DSA(e); } int ENGINE_set_default_DSA(ENGINE *e) { if (e->dsa_meth) return engine_table_register(&dsa_table, engine_unregister_all_DSA, e, &dummy_nid, 1, 1); return 1; } /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references). */ ENGINE * ENGINE_get_default_DSA(void) { return engine_table_select(&dsa_table, dummy_nid); } /* Obtains an DSA implementation from an ENGINE functional reference */ const DSA_METHOD * ENGINE_get_DSA(const ENGINE *e) { return e->dsa_meth; } /* Sets an DSA implementation in an ENGINE structure */ int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth) { e->dsa_meth = dsa_meth; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/tb_pkmeth.c0000644000175000017500000001231712360020705021645 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "eng_int.h" #include /* If this symbol is defined then ENGINE_get_pkey_meth_engine(), the function * that is used by EVP to hook in pkey_meth code and cache defaults (etc), will * display brief debugging summaries to stderr with the 'nid'. */ /* #define ENGINE_PKEY_METH_DEBUG */ static ENGINE_TABLE *pkey_meth_table = NULL; void ENGINE_unregister_pkey_meths(ENGINE *e) { engine_table_unregister(&pkey_meth_table, e); } static void engine_unregister_all_pkey_meths(void) { engine_table_cleanup(&pkey_meth_table); } int ENGINE_register_pkey_meths(ENGINE *e) { if (e->pkey_meths) { const int *nids; int num_nids = e->pkey_meths(e, NULL, &nids, 0); if (num_nids > 0) return engine_table_register(&pkey_meth_table, engine_unregister_all_pkey_meths, e, nids, num_nids, 0); } return 1; } void ENGINE_register_all_pkey_meths(void) { ENGINE *e; for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_pkey_meths(e); } int ENGINE_set_default_pkey_meths(ENGINE *e) { if (e->pkey_meths) { const int *nids; int num_nids = e->pkey_meths(e, NULL, &nids, 0); if (num_nids > 0) return engine_table_register(&pkey_meth_table, engine_unregister_all_pkey_meths, e, nids, num_nids, 1); } return 1; } /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references) for a given pkey_meth 'nid' */ ENGINE * ENGINE_get_pkey_meth_engine(int nid) { return engine_table_select(&pkey_meth_table, nid); } /* Obtains a pkey_meth implementation from an ENGINE functional reference */ const EVP_PKEY_METHOD * ENGINE_get_pkey_meth(ENGINE *e, int nid) { EVP_PKEY_METHOD *ret; ENGINE_PKEY_METHS_PTR fn = ENGINE_get_pkey_meths(e); if (!fn || !fn(e, &ret, NULL, nid)) { ENGINEerr(ENGINE_F_ENGINE_GET_PKEY_METH, ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD); return NULL; } return ret; } /* Gets the pkey_meth callback from an ENGINE structure */ ENGINE_PKEY_METHS_PTR ENGINE_get_pkey_meths(const ENGINE *e) { return e->pkey_meths; } /* Sets the pkey_meth callback in an ENGINE structure */ int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f) { e->pkey_meths = f; return 1; } /* Internal function to free up EVP_PKEY_METHOD structures before an * ENGINE is destroyed */ void engine_pkey_meths_free(ENGINE *e) { int i; EVP_PKEY_METHOD *pkm; if (e->pkey_meths) { const int *pknids; int npknids; npknids = e->pkey_meths(e, NULL, &pknids, 0); for (i = 0; i < npknids; i++) { if (e->pkey_meths(e, &pkm, NULL, pknids[i])) { EVP_PKEY_meth_free(pkm); } } } } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/tb_rand.c0000644000175000017500000001021112360020705021270 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "eng_int.h" /* If this symbol is defined then ENGINE_get_default_RAND(), the function that is * used by RAND to hook in implementation code and cache defaults (etc), will * display brief debugging summaries to stderr with the 'nid'. */ /* #define ENGINE_RAND_DEBUG */ static ENGINE_TABLE *rand_table = NULL; static const int dummy_nid = 1; void ENGINE_unregister_RAND(ENGINE *e) { engine_table_unregister(&rand_table, e); } static void engine_unregister_all_RAND(void) { engine_table_cleanup(&rand_table); } int ENGINE_register_RAND(ENGINE *e) { if (e->rand_meth) return engine_table_register(&rand_table, engine_unregister_all_RAND, e, &dummy_nid, 1, 0); return 1; } void ENGINE_register_all_RAND(void) { ENGINE *e; for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_RAND(e); } int ENGINE_set_default_RAND(ENGINE *e) { if (e->rand_meth) return engine_table_register(&rand_table, engine_unregister_all_RAND, e, &dummy_nid, 1, 1); return 1; } /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references). */ ENGINE * ENGINE_get_default_RAND(void) { return engine_table_select(&rand_table, dummy_nid); } /* Obtains an RAND implementation from an ENGINE functional reference */ const RAND_METHOD * ENGINE_get_RAND(const ENGINE *e) { return e->rand_meth; } /* Sets an RAND implementation in an ENGINE structure */ int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth) { e->rand_meth = rand_meth; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/eng_list.c0000644000175000017500000002723012360020705021474 0ustar /* $OpenBSD: eng_list.c,v 1.14 2014/07/10 22:45:57 jsing Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * ECDH support in OpenSSL originally developed by * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. */ #include #include #include #include "cryptlib.h" #include "eng_int.h" /* The linked-list of pointers to engine types. engine_list_head * incorporates an implicit structural reference but engine_list_tail * does not - the latter is a computational niceity and only points * to something that is already pointed to by its predecessor in the * list (or engine_list_head itself). In the same way, the use of the * "prev" pointer in each ENGINE is to save excessive list iteration, * it doesn't correspond to an extra structural reference. Hence, * engine_list_head, and each non-null "next" pointer account for * the list itself assuming exactly 1 structural reference on each * list member. */ static ENGINE *engine_list_head = NULL; static ENGINE *engine_list_tail = NULL; /* This cleanup function is only needed internally. If it should be called, we * register it with the "ENGINE_cleanup()" stack to be called during cleanup. */ static void engine_list_cleanup(void) { ENGINE *iterator = engine_list_head; while (iterator != NULL) { ENGINE_remove(iterator); iterator = engine_list_head; } return; } /* These static functions starting with a lower case "engine_" always * take place when CRYPTO_LOCK_ENGINE has been locked up. */ static int engine_list_add(ENGINE *e) { int conflict = 0; ENGINE *iterator = NULL; if (e == NULL) { ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, ERR_R_PASSED_NULL_PARAMETER); return 0; } iterator = engine_list_head; while (iterator && !conflict) { conflict = (strcmp(iterator->id, e->id) == 0); iterator = iterator->next; } if (conflict) { ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, ENGINE_R_CONFLICTING_ENGINE_ID); return 0; } if (engine_list_head == NULL) { /* We are adding to an empty list. */ if (engine_list_tail) { ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, ENGINE_R_INTERNAL_LIST_ERROR); return 0; } engine_list_head = e; e->prev = NULL; /* The first time the list allocates, we should register the * cleanup. */ engine_cleanup_add_last(engine_list_cleanup); } else { /* We are adding to the tail of an existing list. */ if ((engine_list_tail == NULL) || (engine_list_tail->next != NULL)) { ENGINEerr(ENGINE_F_ENGINE_LIST_ADD, ENGINE_R_INTERNAL_LIST_ERROR); return 0; } engine_list_tail->next = e; e->prev = engine_list_tail; } /* Having the engine in the list assumes a structural * reference. */ e->struct_ref++; engine_ref_debug(e, 0, 1) /* However it came to be, e is the last item in the list. */ engine_list_tail = e; e->next = NULL; return 1; } static int engine_list_remove(ENGINE *e) { ENGINE *iterator; if (e == NULL) { ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE, ERR_R_PASSED_NULL_PARAMETER); return 0; } /* We need to check that e is in our linked list! */ iterator = engine_list_head; while (iterator && (iterator != e)) iterator = iterator->next; if (iterator == NULL) { ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE, ENGINE_R_ENGINE_IS_NOT_IN_LIST); return 0; } /* un-link e from the chain. */ if (e->next) e->next->prev = e->prev; if (e->prev) e->prev->next = e->next; /* Correct our head/tail if necessary. */ if (engine_list_head == e) engine_list_head = e->next; if (engine_list_tail == e) engine_list_tail = e->prev; engine_free_util(e, 0); return 1; } /* Get the first/last "ENGINE" type available. */ ENGINE * ENGINE_get_first(void) { ENGINE *ret; CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); ret = engine_list_head; if (ret) { ret->struct_ref++; engine_ref_debug(ret, 0, 1) } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); return ret; } ENGINE * ENGINE_get_last(void) { ENGINE *ret; CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); ret = engine_list_tail; if (ret) { ret->struct_ref++; engine_ref_debug(ret, 0, 1) } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); return ret; } /* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */ ENGINE * ENGINE_get_next(ENGINE *e) { ENGINE *ret = NULL; if (e == NULL) { ENGINEerr(ENGINE_F_ENGINE_GET_NEXT, ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); ret = e->next; if (ret) { /* Return a valid structural refernce to the next ENGINE */ ret->struct_ref++; engine_ref_debug(ret, 0, 1) } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); /* Release the structural reference to the previous ENGINE */ ENGINE_free(e); return ret; } ENGINE * ENGINE_get_prev(ENGINE *e) { ENGINE *ret = NULL; if (e == NULL) { ENGINEerr(ENGINE_F_ENGINE_GET_PREV, ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); ret = e->prev; if (ret) { /* Return a valid structural reference to the next ENGINE */ ret->struct_ref++; engine_ref_debug(ret, 0, 1) } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); /* Release the structural reference to the previous ENGINE */ ENGINE_free(e); return ret; } /* Add another "ENGINE" type into the list. */ int ENGINE_add(ENGINE *e) { int to_return = 1; if (e == NULL) { ENGINEerr(ENGINE_F_ENGINE_ADD, ERR_R_PASSED_NULL_PARAMETER); return 0; } if ((e->id == NULL) || (e->name == NULL)) { ENGINEerr(ENGINE_F_ENGINE_ADD, ENGINE_R_ID_OR_NAME_MISSING); } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (!engine_list_add(e)) { ENGINEerr(ENGINE_F_ENGINE_ADD, ENGINE_R_INTERNAL_LIST_ERROR); to_return = 0; } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); return to_return; } /* Remove an existing "ENGINE" type from the array. */ int ENGINE_remove(ENGINE *e) { int to_return = 1; if (e == NULL) { ENGINEerr(ENGINE_F_ENGINE_REMOVE, ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (!engine_list_remove(e)) { ENGINEerr(ENGINE_F_ENGINE_REMOVE, ENGINE_R_INTERNAL_LIST_ERROR); to_return = 0; } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); return to_return; } static void engine_cpy(ENGINE *dest, const ENGINE *src) { dest->id = src->id; dest->name = src->name; #ifndef OPENSSL_NO_RSA dest->rsa_meth = src->rsa_meth; #endif #ifndef OPENSSL_NO_DSA dest->dsa_meth = src->dsa_meth; #endif #ifndef OPENSSL_NO_DH dest->dh_meth = src->dh_meth; #endif #ifndef OPENSSL_NO_ECDH dest->ecdh_meth = src->ecdh_meth; #endif #ifndef OPENSSL_NO_ECDSA dest->ecdsa_meth = src->ecdsa_meth; #endif dest->rand_meth = src->rand_meth; dest->store_meth = src->store_meth; dest->ciphers = src->ciphers; dest->digests = src->digests; dest->pkey_meths = src->pkey_meths; dest->destroy = src->destroy; dest->init = src->init; dest->finish = src->finish; dest->ctrl = src->ctrl; dest->load_privkey = src->load_privkey; dest->load_pubkey = src->load_pubkey; dest->cmd_defns = src->cmd_defns; dest->flags = src->flags; } ENGINE * ENGINE_by_id(const char *id) { ENGINE *iterator; char *load_dir = NULL; if (id == NULL) { ENGINEerr(ENGINE_F_ENGINE_BY_ID, ERR_R_PASSED_NULL_PARAMETER); return NULL; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); iterator = engine_list_head; while (iterator && (strcmp(id, iterator->id) != 0)) iterator = iterator->next; if (iterator) { /* We need to return a structural reference. If this is an * ENGINE type that returns copies, make a duplicate - otherwise * increment the existing ENGINE's reference count. */ if (iterator->flags & ENGINE_FLAGS_BY_ID_COPY) { ENGINE *cp = ENGINE_new(); if (!cp) iterator = NULL; else { engine_cpy(cp, iterator); iterator = cp; } } else { iterator->struct_ref++; engine_ref_debug(iterator, 0, 1) } } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); #if 0 if (iterator == NULL) { ENGINEerr(ENGINE_F_ENGINE_BY_ID, ENGINE_R_NO_SUCH_ENGINE); ERR_asprintf_error_data("id=%s", id); } return iterator; #else /* EEK! Experimental code starts */ if (iterator) return iterator; /* Prevent infinite recusrion if we're looking for the dynamic engine. */ if (strcmp(id, "dynamic")) { if (issetugid() == 0) { load_dir = getenv("OPENSSL_ENGINES"); if (load_dir == NULL) load_dir = ENGINESDIR; } else load_dir = ENGINESDIR; iterator = ENGINE_by_id("dynamic"); if (!iterator || !ENGINE_ctrl_cmd_string(iterator, "ID", id, 0) || !ENGINE_ctrl_cmd_string(iterator, "DIR_LOAD", "2", 0) || !ENGINE_ctrl_cmd_string(iterator, "DIR_ADD", load_dir, 0) || !ENGINE_ctrl_cmd_string(iterator, "LIST_ADD", "1", 0) || !ENGINE_ctrl_cmd_string(iterator, "LOAD", NULL, 0)) goto notfound; return iterator; } notfound: ENGINE_free(iterator); ENGINEerr(ENGINE_F_ENGINE_BY_ID, ENGINE_R_NO_SUCH_ENGINE); ERR_asprintf_error_data("id=%s", id); return NULL; /* EEK! Experimental code ends */ #endif } int ENGINE_up_ref(ENGINE *e) { if (e == NULL) { ENGINEerr(ENGINE_F_ENGINE_UP_REF, ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_add(&e->struct_ref, 1, CRYPTO_LOCK_ENGINE); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/eng_pkey.c0000644000175000017500000001337212360020705021473 0ustar /* $OpenBSD: eng_pkey.c,v 1.4 2014/06/12 15:49:29 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "eng_int.h" /* Basic get/set stuff */ int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f) { e->load_privkey = loadpriv_f; return 1; } int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f) { e->load_pubkey = loadpub_f; return 1; } int ENGINE_set_load_ssl_client_cert_function(ENGINE *e, ENGINE_SSL_CLIENT_CERT_PTR loadssl_f) { e->load_ssl_client_cert = loadssl_f; return 1; } ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e) { return e->load_privkey; } ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e) { return e->load_pubkey; } ENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const ENGINE *e) { return e->load_ssl_client_cert; } /* API functions to load public/private keys */ EVP_PKEY * ENGINE_load_private_key(ENGINE *e, const char *key_id, UI_METHOD *ui_method, void *callback_data) { EVP_PKEY *pkey; if (e == NULL) { ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY, ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (e->funct_ref == 0) { CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY, ENGINE_R_NOT_INITIALISED); return 0; } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); if (!e->load_privkey) { ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY, ENGINE_R_NO_LOAD_FUNCTION); return 0; } pkey = e->load_privkey(e, key_id, ui_method, callback_data); if (!pkey) { ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY, ENGINE_R_FAILED_LOADING_PRIVATE_KEY); return 0; } return pkey; } EVP_PKEY * ENGINE_load_public_key(ENGINE *e, const char *key_id, UI_METHOD *ui_method, void *callback_data) { EVP_PKEY *pkey; if (e == NULL) { ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY, ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (e->funct_ref == 0) { CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY, ENGINE_R_NOT_INITIALISED); return 0; } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); if (!e->load_pubkey) { ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY, ENGINE_R_NO_LOAD_FUNCTION); return 0; } pkey = e->load_pubkey(e, key_id, ui_method, callback_data); if (!pkey) { ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY, ENGINE_R_FAILED_LOADING_PUBLIC_KEY); return 0; } return pkey; } int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s, STACK_OF(X509_NAME) *ca_dn, X509 **pcert, EVP_PKEY **ppkey, STACK_OF(X509) **pother, UI_METHOD *ui_method, void *callback_data) { if (e == NULL) { ENGINEerr(ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT, ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (e->funct_ref == 0) { CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); ENGINEerr(ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT, ENGINE_R_NOT_INITIALISED); return 0; } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); if (!e->load_ssl_client_cert) { ENGINEerr(ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT, ENGINE_R_NO_LOAD_FUNCTION); return 0; } return e->load_ssl_client_cert(e, s, ca_dn, pcert, ppkey, pother, ui_method, callback_data); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/tb_cipher.c0000644000175000017500000001124712360020705021630 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "eng_int.h" /* If this symbol is defined then ENGINE_get_cipher_engine(), the function that * is used by EVP to hook in cipher code and cache defaults (etc), will display * brief debugging summaries to stderr with the 'nid'. */ /* #define ENGINE_CIPHER_DEBUG */ static ENGINE_TABLE *cipher_table = NULL; void ENGINE_unregister_ciphers(ENGINE *e) { engine_table_unregister(&cipher_table, e); } static void engine_unregister_all_ciphers(void) { engine_table_cleanup(&cipher_table); } int ENGINE_register_ciphers(ENGINE *e) { if (e->ciphers) { const int *nids; int num_nids = e->ciphers(e, NULL, &nids, 0); if (num_nids > 0) return engine_table_register(&cipher_table, engine_unregister_all_ciphers, e, nids, num_nids, 0); } return 1; } void ENGINE_register_all_ciphers(void) { ENGINE *e; for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_ciphers(e); } int ENGINE_set_default_ciphers(ENGINE *e) { if (e->ciphers) { const int *nids; int num_nids = e->ciphers(e, NULL, &nids, 0); if (num_nids > 0) return engine_table_register(&cipher_table, engine_unregister_all_ciphers, e, nids, num_nids, 1); } return 1; } /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references) for a given cipher 'nid' */ ENGINE * ENGINE_get_cipher_engine(int nid) { return engine_table_select(&cipher_table, nid); } /* Obtains a cipher implementation from an ENGINE functional reference */ const EVP_CIPHER * ENGINE_get_cipher(ENGINE *e, int nid) { const EVP_CIPHER *ret; ENGINE_CIPHERS_PTR fn = ENGINE_get_ciphers(e); if (!fn || !fn(e, &ret, NULL, nid)) { ENGINEerr(ENGINE_F_ENGINE_GET_CIPHER, ENGINE_R_UNIMPLEMENTED_CIPHER); return NULL; } return ret; } /* Gets the cipher callback from an ENGINE structure */ ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e) { return e->ciphers; } /* Sets the cipher callback in an ENGINE structure */ int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f) { e->ciphers = f; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/eng_init.c0000644000175000017500000001166612360020705021472 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "eng_int.h" /* Initialise a engine type for use (or up its functional reference count * if it's already in use). This version is only used internally. */ int engine_unlocked_init(ENGINE *e) { int to_return = 1; if ((e->funct_ref == 0) && e->init) /* This is the first functional reference and the engine * requires initialisation so we do it now. */ to_return = e->init(e); if (to_return) { /* OK, we return a functional reference which is also a * structural reference. */ e->struct_ref++; e->funct_ref++; engine_ref_debug(e, 0, 1) engine_ref_debug(e, 1, 1) } return to_return; } /* Free a functional reference to a engine type. This version is only used * internally. */ int engine_unlocked_finish(ENGINE *e, int unlock_for_handlers) { int to_return = 1; /* Reduce the functional reference count here so if it's the terminating * case, we can release the lock safely and call the finish() handler * without risk of a race. We get a race if we leave the count until * after and something else is calling "finish" at the same time - * there's a chance that both threads will together take the count from * 2 to 0 without either calling finish(). */ e->funct_ref--; engine_ref_debug(e, 1, -1); if ((e->funct_ref == 0) && e->finish) { if (unlock_for_handlers) CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); to_return = e->finish(e); if (unlock_for_handlers) CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (!to_return) return 0; } /* Release the structural reference too */ if (!engine_free_util(e, 0)) { ENGINEerr(ENGINE_F_ENGINE_UNLOCKED_FINISH, ENGINE_R_FINISH_FAILED); return 0; } return to_return; } /* The API (locked) version of "init" */ int ENGINE_init(ENGINE *e) { int ret; if (e == NULL) { ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); ret = engine_unlocked_init(e); CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); return ret; } /* The API (locked) version of "finish" */ int ENGINE_finish(ENGINE *e) { int to_return = 1; if (e == NULL) { ENGINEerr(ENGINE_F_ENGINE_FINISH, ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); to_return = engine_unlocked_finish(e, 1); CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); if (!to_return) { ENGINEerr(ENGINE_F_ENGINE_FINISH, ENGINE_R_FINISH_FAILED); return 0; } return to_return; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/eng_cnf.c0000644000175000017500000001572312360020705021273 0ustar /* $OpenBSD: eng_cnf.c,v 1.11 2014/06/22 11:33:47 jsing Exp $ */ /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include "eng_int.h" #include /* #define ENGINE_CONF_DEBUG */ /* ENGINE config module */ static char * skip_dot(char *name) { char *p; p = strchr(name, '.'); if (p) return p + 1; return name; } static STACK_OF(ENGINE) *initialized_engines = NULL; static int int_engine_init(ENGINE *e) { if (!ENGINE_init(e)) return 0; if (!initialized_engines) initialized_engines = sk_ENGINE_new_null(); if (!initialized_engines || !sk_ENGINE_push(initialized_engines, e)) { ENGINE_finish(e); return 0; } return 1; } static int int_engine_configure(char *name, char *value, const CONF *cnf) { int i; int ret = 0; long do_init = -1; STACK_OF(CONF_VALUE) *ecmds; CONF_VALUE *ecmd = NULL; char *ctrlname, *ctrlvalue; ENGINE *e = NULL; int soft = 0; name = skip_dot(name); #ifdef ENGINE_CONF_DEBUG fprintf(stderr, "Configuring engine %s\n", name); #endif /* Value is a section containing ENGINE commands */ ecmds = NCONF_get_section(cnf, value); if (!ecmds) { ENGINEerr(ENGINE_F_INT_ENGINE_CONFIGURE, ENGINE_R_ENGINE_SECTION_ERROR); return 0; } for (i = 0; i < sk_CONF_VALUE_num(ecmds); i++) { ecmd = sk_CONF_VALUE_value(ecmds, i); ctrlname = skip_dot(ecmd->name); ctrlvalue = ecmd->value; #ifdef ENGINE_CONF_DEBUG fprintf(stderr, "ENGINE conf: doing ctrl(%s,%s)\n", ctrlname, ctrlvalue); #endif /* First handle some special pseudo ctrls */ /* Override engine name to use */ if (!strcmp(ctrlname, "engine_id")) name = ctrlvalue; else if (!strcmp(ctrlname, "soft_load")) soft = 1; /* Load a dynamic ENGINE */ else if (!strcmp(ctrlname, "dynamic_path")) { e = ENGINE_by_id("dynamic"); if (!e) goto err; if (!ENGINE_ctrl_cmd_string(e, "SO_PATH", ctrlvalue, 0)) goto err; if (!ENGINE_ctrl_cmd_string(e, "LIST_ADD", "2", 0)) goto err; if (!ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0)) goto err; } /* ... add other pseudos here ... */ else { /* At this point we need an ENGINE structural reference * if we don't already have one. */ if (!e) { e = ENGINE_by_id(name); if (!e && soft) { ERR_clear_error(); return 1; } if (!e) goto err; } /* Allow "EMPTY" to mean no value: this allows a valid * "value" to be passed to ctrls of type NO_INPUT */ if (!strcmp(ctrlvalue, "EMPTY")) ctrlvalue = NULL; if (!strcmp(ctrlname, "init")) { if (!NCONF_get_number_e(cnf, value, "init", &do_init)) goto err; if (do_init == 1) { if (!int_engine_init(e)) goto err; } else if (do_init != 0) { ENGINEerr(ENGINE_F_INT_ENGINE_CONFIGURE, ENGINE_R_INVALID_INIT_VALUE); goto err; } } else if (!strcmp(ctrlname, "default_algorithms")) { if (!ENGINE_set_default_string(e, ctrlvalue)) goto err; } else if (!ENGINE_ctrl_cmd_string(e, ctrlname, ctrlvalue, 0)) goto err; } } if (e && (do_init == -1) && !int_engine_init(e)) { ecmd = NULL; goto err; } ret = 1; err: if (ret != 1) { ENGINEerr(ENGINE_F_INT_ENGINE_CONFIGURE, ENGINE_R_ENGINE_CONFIGURATION_ERROR); if (ecmd) ERR_asprintf_error_data( "section=%s, name=%s, value=%s", ecmd->section, ecmd->name, ecmd->value); } if (e) ENGINE_free(e); return ret; } static int int_engine_module_init(CONF_IMODULE *md, const CONF *cnf) { STACK_OF(CONF_VALUE) *elist; CONF_VALUE *cval; int i; #ifdef ENGINE_CONF_DEBUG fprintf(stderr, "Called engine module: name %s, value %s\n", CONF_imodule_get_name(md), CONF_imodule_get_value(md)); #endif /* Value is a section containing ENGINEs to configure */ elist = NCONF_get_section(cnf, CONF_imodule_get_value(md)); if (!elist) { ENGINEerr(ENGINE_F_INT_ENGINE_MODULE_INIT, ENGINE_R_ENGINES_SECTION_ERROR); return 0; } for (i = 0; i < sk_CONF_VALUE_num(elist); i++) { cval = sk_CONF_VALUE_value(elist, i); if (!int_engine_configure(cval->name, cval->value, cnf)) return 0; } return 1; } static void int_engine_module_finish(CONF_IMODULE *md) { ENGINE *e; while ((e = sk_ENGINE_pop(initialized_engines))) ENGINE_finish(e); sk_ENGINE_free(initialized_engines); initialized_engines = NULL; } void ENGINE_add_conf_module(void) { CONF_module_add("engines", int_engine_module_init, int_engine_module_finish); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/eng_fat.c0000644000175000017500000001406012360020705021270 0ustar /* $OpenBSD: eng_fat.c,v 1.13 2014/07/10 13:58:22 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * ECDH support in OpenSSL originally developed by * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. */ #include #include #include "eng_int.h" #include int ENGINE_set_default(ENGINE *e, unsigned int flags) { if ((flags & ENGINE_METHOD_CIPHERS) && !ENGINE_set_default_ciphers(e)) return 0; if ((flags & ENGINE_METHOD_DIGESTS) && !ENGINE_set_default_digests(e)) return 0; #ifndef OPENSSL_NO_RSA if ((flags & ENGINE_METHOD_RSA) && !ENGINE_set_default_RSA(e)) return 0; #endif #ifndef OPENSSL_NO_DSA if ((flags & ENGINE_METHOD_DSA) && !ENGINE_set_default_DSA(e)) return 0; #endif #ifndef OPENSSL_NO_DH if ((flags & ENGINE_METHOD_DH) && !ENGINE_set_default_DH(e)) return 0; #endif #ifndef OPENSSL_NO_ECDH if ((flags & ENGINE_METHOD_ECDH) && !ENGINE_set_default_ECDH(e)) return 0; #endif #ifndef OPENSSL_NO_ECDSA if ((flags & ENGINE_METHOD_ECDSA) && !ENGINE_set_default_ECDSA(e)) return 0; #endif if ((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e)) return 0; if ((flags & ENGINE_METHOD_PKEY_METHS) && !ENGINE_set_default_pkey_meths(e)) return 0; if ((flags & ENGINE_METHOD_PKEY_ASN1_METHS) && !ENGINE_set_default_pkey_asn1_meths(e)) return 0; return 1; } /* Set default algorithms using a string */ static int int_def_cb(const char *alg, int len, void *arg) { unsigned int *pflags = arg; if (!strncmp(alg, "ALL", len)) *pflags |= ENGINE_METHOD_ALL; else if (!strncmp(alg, "RSA", len)) *pflags |= ENGINE_METHOD_RSA; else if (!strncmp(alg, "DSA", len)) *pflags |= ENGINE_METHOD_DSA; else if (!strncmp(alg, "ECDH", len)) *pflags |= ENGINE_METHOD_ECDH; else if (!strncmp(alg, "ECDSA", len)) *pflags |= ENGINE_METHOD_ECDSA; else if (!strncmp(alg, "DH", len)) *pflags |= ENGINE_METHOD_DH; else if (!strncmp(alg, "RAND", len)) *pflags |= ENGINE_METHOD_RAND; else if (!strncmp(alg, "CIPHERS", len)) *pflags |= ENGINE_METHOD_CIPHERS; else if (!strncmp(alg, "DIGESTS", len)) *pflags |= ENGINE_METHOD_DIGESTS; else if (!strncmp(alg, "PKEY", len)) *pflags |= ENGINE_METHOD_PKEY_METHS | ENGINE_METHOD_PKEY_ASN1_METHS; else if (!strncmp(alg, "PKEY_CRYPTO", len)) *pflags |= ENGINE_METHOD_PKEY_METHS; else if (!strncmp(alg, "PKEY_ASN1", len)) *pflags |= ENGINE_METHOD_PKEY_ASN1_METHS; else return 0; return 1; } int ENGINE_set_default_string(ENGINE *e, const char *def_list) { unsigned int flags = 0; if (!CONF_parse_list(def_list, ',', 1, int_def_cb, &flags)) { ENGINEerr(ENGINE_F_ENGINE_SET_DEFAULT_STRING, ENGINE_R_INVALID_STRING); ERR_asprintf_error_data("str=%s",def_list); return 0; } return ENGINE_set_default(e, flags); } int ENGINE_register_complete(ENGINE *e) { ENGINE_register_ciphers(e); ENGINE_register_digests(e); #ifndef OPENSSL_NO_RSA ENGINE_register_RSA(e); #endif #ifndef OPENSSL_NO_DSA ENGINE_register_DSA(e); #endif #ifndef OPENSSL_NO_DH ENGINE_register_DH(e); #endif #ifndef OPENSSL_NO_ECDH ENGINE_register_ECDH(e); #endif #ifndef OPENSSL_NO_ECDSA ENGINE_register_ECDSA(e); #endif ENGINE_register_RAND(e); ENGINE_register_pkey_meths(e); return 1; } int ENGINE_register_all_complete(void) { ENGINE *e; for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) if (!(e->flags & ENGINE_FLAGS_NO_REGISTER_ALL)) ENGINE_register_complete(e); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/tb_dh.c0000644000175000017500000001011512360020705020742 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "eng_int.h" /* If this symbol is defined then ENGINE_get_default_DH(), the function that is * used by DH to hook in implementation code and cache defaults (etc), will * display brief debugging summaries to stderr with the 'nid'. */ /* #define ENGINE_DH_DEBUG */ static ENGINE_TABLE *dh_table = NULL; static const int dummy_nid = 1; void ENGINE_unregister_DH(ENGINE *e) { engine_table_unregister(&dh_table, e); } static void engine_unregister_all_DH(void) { engine_table_cleanup(&dh_table); } int ENGINE_register_DH(ENGINE *e) { if (e->dh_meth) return engine_table_register(&dh_table, engine_unregister_all_DH, e, &dummy_nid, 1, 0); return 1; } void ENGINE_register_all_DH(void) { ENGINE *e; for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_DH(e); } int ENGINE_set_default_DH(ENGINE *e) { if (e->dh_meth) return engine_table_register(&dh_table, engine_unregister_all_DH, e, &dummy_nid, 1, 1); return 1; } /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references). */ ENGINE * ENGINE_get_default_DH(void) { return engine_table_select(&dh_table, dummy_nid); } /* Obtains an DH implementation from an ENGINE functional reference */ const DH_METHOD * ENGINE_get_DH(const ENGINE *e) { return e->dh_meth; } /* Sets an DH implementation in an ENGINE structure */ int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth) { e->dh_meth = dh_meth; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/tb_ecdsa.c0000644000175000017500000001025412360020705021432 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "eng_int.h" /* If this symbol is defined then ENGINE_get_default_ECDSA(), the function that is * used by ECDSA to hook in implementation code and cache defaults (etc), will * display brief debugging summaries to stderr with the 'nid'. */ /* #define ENGINE_ECDSA_DEBUG */ static ENGINE_TABLE *ecdsa_table = NULL; static const int dummy_nid = 1; void ENGINE_unregister_ECDSA(ENGINE *e) { engine_table_unregister(&ecdsa_table, e); } static void engine_unregister_all_ECDSA(void) { engine_table_cleanup(&ecdsa_table); } int ENGINE_register_ECDSA(ENGINE *e) { if (e->ecdsa_meth) return engine_table_register(&ecdsa_table, engine_unregister_all_ECDSA, e, &dummy_nid, 1, 0); return 1; } void ENGINE_register_all_ECDSA(void) { ENGINE *e; for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_ECDSA(e); } int ENGINE_set_default_ECDSA(ENGINE *e) { if (e->ecdsa_meth) return engine_table_register(&ecdsa_table, engine_unregister_all_ECDSA, e, &dummy_nid, 1, 1); return 1; } /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references). */ ENGINE * ENGINE_get_default_ECDSA(void) { return engine_table_select(&ecdsa_table, dummy_nid); } /* Obtains an ECDSA implementation from an ENGINE functional reference */ const ECDSA_METHOD * ENGINE_get_ECDSA(const ENGINE *e) { return e->ecdsa_meth; } /* Sets an ECDSA implementation in an ENGINE structure */ int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth) { e->ecdsa_meth = ecdsa_meth; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/tb_ecdh.c0000644000175000017500000001123312360020705021254 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * The Elliptic Curve Public-Key Crypto Library (ECC Code) included * herein is developed by SUN MICROSYSTEMS, INC., and is contributed * to the OpenSSL project. * * The ECC Code is licensed pursuant to the OpenSSL open source * license provided below. * * The ECDH engine software is originally written by Nils Gura and * Douglas Stebila of Sun Microsystems Laboratories. * */ /* ==================================================================== * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "eng_int.h" /* If this symbol is defined then ENGINE_get_default_ECDH(), the function that is * used by ECDH to hook in implementation code and cache defaults (etc), will * display brief debugging summaries to stderr with the 'nid'. */ /* #define ENGINE_ECDH_DEBUG */ static ENGINE_TABLE *ecdh_table = NULL; static const int dummy_nid = 1; void ENGINE_unregister_ECDH(ENGINE *e) { engine_table_unregister(&ecdh_table, e); } static void engine_unregister_all_ECDH(void) { engine_table_cleanup(&ecdh_table); } int ENGINE_register_ECDH(ENGINE *e) { if (e->ecdh_meth) return engine_table_register(&ecdh_table, engine_unregister_all_ECDH, e, &dummy_nid, 1, 0); return 1; } void ENGINE_register_all_ECDH(void) { ENGINE *e; for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_ECDH(e); } int ENGINE_set_default_ECDH(ENGINE *e) { if (e->ecdh_meth) return engine_table_register(&ecdh_table, engine_unregister_all_ECDH, e, &dummy_nid, 1, 1); return 1; } /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references). */ ENGINE * ENGINE_get_default_ECDH(void) { return engine_table_select(&ecdh_table, dummy_nid); } /* Obtains an ECDH implementation from an ENGINE functional reference */ const ECDH_METHOD * ENGINE_get_ECDH(const ENGINE *e) { return e->ecdh_meth; } /* Sets an ECDH implementation in an ENGINE structure */ int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth) { e->ecdh_meth = ecdh_meth; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/eng_table.c0000644000175000017500000002360312360020705021610 0ustar /* $OpenBSD: eng_table.c,v 1.6 2014/06/22 12:05:09 jsing Exp $ */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "eng_int.h" /* The type of the items in the table */ typedef struct st_engine_pile { /* The 'nid' of this algorithm/mode */ int nid; /* ENGINEs that implement this algorithm/mode. */ STACK_OF(ENGINE) *sk; /* The default ENGINE to perform this algorithm/mode. */ ENGINE *funct; /* Zero if 'sk' is newer than the cached 'funct', non-zero otherwise */ int uptodate; } ENGINE_PILE; DECLARE_LHASH_OF(ENGINE_PILE); /* The type exposed in eng_int.h */ struct st_engine_table { LHASH_OF(ENGINE_PILE) piles; }; /* ENGINE_TABLE */ typedef struct st_engine_pile_doall { engine_table_doall_cb *cb; void *arg; } ENGINE_PILE_DOALL; /* Global flags (ENGINE_TABLE_FLAG_***). */ static unsigned int table_flags = 0; /* API function manipulating 'table_flags' */ unsigned int ENGINE_get_table_flags(void) { return table_flags; } void ENGINE_set_table_flags(unsigned int flags) { table_flags = flags; } /* Internal functions for the "piles" hash table */ static unsigned long engine_pile_hash(const ENGINE_PILE *c) { return c->nid; } static int engine_pile_cmp(const ENGINE_PILE *a, const ENGINE_PILE *b) { return a->nid - b->nid; } static IMPLEMENT_LHASH_HASH_FN(engine_pile, ENGINE_PILE) static IMPLEMENT_LHASH_COMP_FN(engine_pile, ENGINE_PILE) static int int_table_check(ENGINE_TABLE **t, int create) { LHASH_OF(ENGINE_PILE) *lh; if (*t) return 1; if (!create) return 0; if ((lh = lh_ENGINE_PILE_new()) == NULL) return 0; *t = (ENGINE_TABLE *)lh; return 1; } /* Privately exposed (via eng_int.h) functions for adding and/or removing * ENGINEs from the implementation table */ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup, ENGINE *e, const int *nids, int num_nids, int setdefault) { int ret = 0, added = 0; ENGINE_PILE tmplate, *fnd; CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (!(*table)) added = 1; if (!int_table_check(table, 1)) goto end; if (added) /* The cleanup callback needs to be added */ engine_cleanup_add_first(cleanup); while (num_nids--) { tmplate.nid = *nids; fnd = lh_ENGINE_PILE_retrieve(&(*table)->piles, &tmplate); if (!fnd) { fnd = malloc(sizeof(ENGINE_PILE)); if (!fnd) goto end; fnd->uptodate = 1; fnd->nid = *nids; fnd->sk = sk_ENGINE_new_null(); if (!fnd->sk) { free(fnd); goto end; } fnd->funct = NULL; (void)lh_ENGINE_PILE_insert(&(*table)->piles, fnd); } /* A registration shouldn't add duplciate entries */ (void)sk_ENGINE_delete_ptr(fnd->sk, e); /* if 'setdefault', this ENGINE goes to the head of the list */ if (!sk_ENGINE_push(fnd->sk, e)) goto end; /* "touch" this ENGINE_PILE */ fnd->uptodate = 0; if (setdefault) { if (!engine_unlocked_init(e)) { ENGINEerr(ENGINE_F_ENGINE_TABLE_REGISTER, ENGINE_R_INIT_FAILED); goto end; } if (fnd->funct) engine_unlocked_finish(fnd->funct, 0); fnd->funct = e; fnd->uptodate = 1; } nids++; } ret = 1; end: CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); return ret; } static void int_unregister_cb_doall_arg(ENGINE_PILE *pile, ENGINE *e) { int n; /* Iterate the 'c->sk' stack removing any occurance of 'e' */ while ((n = sk_ENGINE_find(pile->sk, e)) >= 0) { (void)sk_ENGINE_delete(pile->sk, n); pile->uptodate = 0; } if (pile->funct == e) { engine_unlocked_finish(e, 0); pile->funct = NULL; } } static IMPLEMENT_LHASH_DOALL_ARG_FN(int_unregister_cb, ENGINE_PILE, ENGINE) void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e) { CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (int_table_check(table, 0)) lh_ENGINE_PILE_doall_arg(&(*table)->piles, LHASH_DOALL_ARG_FN(int_unregister_cb), ENGINE, e); CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); } static void int_cleanup_cb_doall(ENGINE_PILE *p) { sk_ENGINE_free(p->sk); if (p->funct) engine_unlocked_finish(p->funct, 0); free(p); } static IMPLEMENT_LHASH_DOALL_FN(int_cleanup_cb, ENGINE_PILE) void engine_table_cleanup(ENGINE_TABLE **table) { CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (*table) { lh_ENGINE_PILE_doall(&(*table)->piles, LHASH_DOALL_FN(int_cleanup_cb)); lh_ENGINE_PILE_free(&(*table)->piles); *table = NULL; } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); } /* return a functional reference for a given 'nid' */ #ifndef ENGINE_TABLE_DEBUG ENGINE * engine_table_select(ENGINE_TABLE **table, int nid) #else ENGINE * engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, int l) #endif { ENGINE *ret = NULL; ENGINE_PILE tmplate, *fnd = NULL; int initres, loop = 0; if (!(*table)) { #ifdef ENGINE_TABLE_DEBUG fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, nothing " "registered!\n", f, l, nid); #endif return NULL; } ERR_set_mark(); CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); /* Check again inside the lock otherwise we could race against cleanup * operations. But don't worry about a fprintf(stderr). */ if (!int_table_check(table, 0)) goto end; tmplate.nid = nid; fnd = lh_ENGINE_PILE_retrieve(&(*table)->piles, &tmplate); if (!fnd) goto end; if (fnd->funct && engine_unlocked_init(fnd->funct)) { #ifdef ENGINE_TABLE_DEBUG fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, using " "ENGINE '%s' cached\n", f, l, nid, fnd->funct->id); #endif ret = fnd->funct; goto end; } if (fnd->uptodate) { ret = fnd->funct; goto end; } trynext: ret = sk_ENGINE_value(fnd->sk, loop++); if (!ret) { #ifdef ENGINE_TABLE_DEBUG fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, no " "registered implementations would initialise\n", f, l, nid); #endif goto end; } /* Try to initialise the ENGINE? */ if ((ret->funct_ref > 0) || !(table_flags & ENGINE_TABLE_FLAG_NOINIT)) initres = engine_unlocked_init(ret); else initres = 0; if (initres) { /* Update 'funct' */ if ((fnd->funct != ret) && engine_unlocked_init(ret)) { /* If there was a previous default we release it. */ if (fnd->funct) engine_unlocked_finish(fnd->funct, 0); fnd->funct = ret; #ifdef ENGINE_TABLE_DEBUG fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, " "setting default to '%s'\n", f, l, nid, ret->id); #endif } #ifdef ENGINE_TABLE_DEBUG fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, using " "newly initialised '%s'\n", f, l, nid, ret->id); #endif goto end; } goto trynext; end: /* If it failed, it is unlikely to succeed again until some future * registrations have taken place. In all cases, we cache. */ if (fnd) fnd->uptodate = 1; #ifdef ENGINE_TABLE_DEBUG if (ret) fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, caching " "ENGINE '%s'\n", f, l, nid, ret->id); else fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, caching " "'no matching ENGINE'\n", f, l, nid); #endif CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); /* Whatever happened, any failed init()s are not failures in this * context, so clear our error state. */ ERR_pop_to_mark(); return ret; } /* Table enumeration */ static void int_cb_doall_arg(ENGINE_PILE *pile, ENGINE_PILE_DOALL *dall) { dall->cb(pile->nid, pile->sk, pile->funct, dall->arg); } static IMPLEMENT_LHASH_DOALL_ARG_FN(int_cb, ENGINE_PILE, ENGINE_PILE_DOALL) void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb, void *arg) { ENGINE_PILE_DOALL dall; dall.cb = cb; dall.arg = arg; lh_ENGINE_PILE_doall_arg(&table->piles, LHASH_DOALL_ARG_FN(int_cb), ENGINE_PILE_DOALL, &dall); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/eng_int.h0000644000175000017500000002017312360020705021317 0ustar /* $OpenBSD: eng_int.h,v 1.7 2014/07/10 22:45:57 jsing Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * ECDH support in OpenSSL originally developed by * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. */ #ifndef HEADER_ENGINE_INT_H #define HEADER_ENGINE_INT_H /* Take public definitions from engine.h */ #include #ifdef __cplusplus extern "C" { #endif /* If we compile with this symbol defined, then both reference counts in the * ENGINE structure will be monitored with a line of output on stderr for each * change. This prints the engine's pointer address (truncated to unsigned int), * "struct" or "funct" to indicate the reference type, the before and after * reference count, and the file:line-number pair. The "engine_ref_debug" * statements must come *after* the change. */ #ifdef ENGINE_REF_COUNT_DEBUG #define engine_ref_debug(e, isfunct, diff) \ fprintf(stderr, "engine: %08x %s from %d to %d (%s:%d)\n", \ (unsigned int)(e), (isfunct ? "funct" : "struct"), \ ((isfunct) ? ((e)->funct_ref - (diff)) : ((e)->struct_ref - (diff))), \ ((isfunct) ? (e)->funct_ref : (e)->struct_ref), \ (__FILE__), (__LINE__)); #else #define engine_ref_debug(e, isfunct, diff) #endif /* Any code that will need cleanup operations should use these functions to * register callbacks. ENGINE_cleanup() will call all registered callbacks in * order. NB: both the "add" functions assume CRYPTO_LOCK_ENGINE to already be * held (in "write" mode). */ typedef void (ENGINE_CLEANUP_CB)(void); typedef struct st_engine_cleanup_item { ENGINE_CLEANUP_CB *cb; } ENGINE_CLEANUP_ITEM; DECLARE_STACK_OF(ENGINE_CLEANUP_ITEM) void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb); void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb); /* We need stacks of ENGINEs for use in eng_table.c */ DECLARE_STACK_OF(ENGINE) /* If this symbol is defined then engine_table_select(), the function that is * used by RSA, DSA (etc) code to select registered ENGINEs, cache defaults and * functional references (etc), will display debugging summaries to stderr. */ /* #define ENGINE_TABLE_DEBUG */ /* This represents an implementation table. Dependent code should instantiate it * as a (ENGINE_TABLE *) pointer value set initially to NULL. */ typedef struct st_engine_table ENGINE_TABLE; int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup, ENGINE *e, const int *nids, int num_nids, int setdefault); void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e); void engine_table_cleanup(ENGINE_TABLE **table); #ifndef ENGINE_TABLE_DEBUG ENGINE *engine_table_select(ENGINE_TABLE **table, int nid); #else ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, int l); #define engine_table_select(t,n) engine_table_select_tmp(t,n,__FILE__,__LINE__) #endif typedef void (engine_table_doall_cb)(int nid, STACK_OF(ENGINE) *sk, ENGINE *def, void *arg); void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb, void *arg); /* Internal versions of API functions that have control over locking. These are * used between C files when functionality needs to be shared but the caller may * already be controlling of the CRYPTO_LOCK_ENGINE lock. */ int engine_unlocked_init(ENGINE *e); int engine_unlocked_finish(ENGINE *e, int unlock_for_handlers); int engine_free_util(ENGINE *e, int locked); /* This function will reset all "set"able values in an ENGINE to NULL. This * won't touch reference counts or ex_data, but is equivalent to calling all the * ENGINE_set_***() functions with a NULL value. */ void engine_set_all_null(ENGINE *e); /* NB: Bitwise OR-able values for the "flags" variable in ENGINE are now exposed * in engine.h. */ /* Free up dynamically allocated public key methods associated with ENGINE */ void engine_pkey_meths_free(ENGINE *e); void engine_pkey_asn1_meths_free(ENGINE *e); /* This is a structure for storing implementations of various crypto * algorithms and functions. */ struct engine_st { const char *id; const char *name; const RSA_METHOD *rsa_meth; const DSA_METHOD *dsa_meth; const DH_METHOD *dh_meth; const ECDH_METHOD *ecdh_meth; const ECDSA_METHOD *ecdsa_meth; const RAND_METHOD *rand_meth; const STORE_METHOD *store_meth; /* Cipher handling is via this callback */ ENGINE_CIPHERS_PTR ciphers; /* Digest handling is via this callback */ ENGINE_DIGESTS_PTR digests; /* Public key handling via this callback */ ENGINE_PKEY_METHS_PTR pkey_meths; /* ASN1 public key handling via this callback */ ENGINE_PKEY_ASN1_METHS_PTR pkey_asn1_meths; ENGINE_GEN_INT_FUNC_PTR destroy; ENGINE_GEN_INT_FUNC_PTR init; ENGINE_GEN_INT_FUNC_PTR finish; ENGINE_CTRL_FUNC_PTR ctrl; ENGINE_LOAD_KEY_PTR load_privkey; ENGINE_LOAD_KEY_PTR load_pubkey; ENGINE_SSL_CLIENT_CERT_PTR load_ssl_client_cert; const ENGINE_CMD_DEFN *cmd_defns; int flags; /* reference count on the structure itself */ int struct_ref; /* reference count on usability of the engine type. NB: This * controls the loading and initialisation of any functionlity * required by this engine, whereas the previous count is * simply to cope with (de)allocation of this structure. Hence, * running_ref <= struct_ref at all times. */ int funct_ref; /* A place to store per-ENGINE data */ CRYPTO_EX_DATA ex_data; /* Used to maintain the linked-list of engines. */ struct engine_st *prev; struct engine_st *next; }; #ifdef __cplusplus } #endif #endif /* HEADER_ENGINE_INT_H */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/eng_rsax.c0000644000175000017500000004234212360020705021477 0ustar /* $OpenBSD: eng_rsax.c,v 1.8 2014/06/22 12:18:33 jsing Exp $ */ /* Copyright (c) 2010-2010 Intel Corp. * Author: Vinodh.Gopal@intel.com * Jim Guilford * Erdinc.Ozturk@intel.com * Maxim.Perminov@intel.com * Ying.Huang@intel.com * * More information about algorithm used can be found at: * http://www.cse.buffalo.edu/srds2009/escs2009_submission_Gopal.pdf */ /* ==================================================================== * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). */ #include #include #include #include #include #include #include #ifndef OPENSSL_NO_RSA #include #endif #include #include /* RSAX is available **ONLY* on x86_64 CPUs */ #undef COMPILE_RSAX #if (defined(__x86_64) || defined(__x86_64__) || \ defined(_M_AMD64) || defined (_M_X64)) && !defined(OPENSSL_NO_ASM) #define COMPILE_RSAX static ENGINE *ENGINE_rsax (void); #endif void ENGINE_load_rsax (void) { /* On non-x86 CPUs it just returns. */ #ifdef COMPILE_RSAX ENGINE *toadd = ENGINE_rsax(); if (!toadd) return; ENGINE_add(toadd); ENGINE_free(toadd); ERR_clear_error(); #endif } #ifdef COMPILE_RSAX #define E_RSAX_LIB_NAME "rsax engine" static int e_rsax_destroy(ENGINE *e); static int e_rsax_init(ENGINE *e); static int e_rsax_finish(ENGINE *e); static int e_rsax_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)); #ifndef OPENSSL_NO_RSA /* RSA stuff */ static int e_rsax_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa, BN_CTX *ctx); static int e_rsax_rsa_finish(RSA *r); #endif static const ENGINE_CMD_DEFN e_rsax_cmd_defns[] = { {0, NULL, NULL, 0} }; #ifndef OPENSSL_NO_RSA /* Our internal RSA_METHOD that we provide pointers to */ static RSA_METHOD e_rsax_rsa = { .name = "Intel RSA-X method", .rsa_mod_exp = e_rsax_rsa_mod_exp, .finish = e_rsax_rsa_finish, .flags = RSA_FLAG_CACHE_PUBLIC|RSA_FLAG_CACHE_PRIVATE, }; #endif /* Constants used when creating the ENGINE */ static const char *engine_e_rsax_id = "rsax"; static const char *engine_e_rsax_name = "RSAX engine support"; /* This internal function is used by ENGINE_rsax() */ static int bind_helper(ENGINE *e) { #ifndef OPENSSL_NO_RSA const RSA_METHOD *meth1; #endif if (!ENGINE_set_id(e, engine_e_rsax_id) || !ENGINE_set_name(e, engine_e_rsax_name) || #ifndef OPENSSL_NO_RSA !ENGINE_set_RSA(e, &e_rsax_rsa) || #endif !ENGINE_set_destroy_function(e, e_rsax_destroy) || !ENGINE_set_init_function(e, e_rsax_init) || !ENGINE_set_finish_function(e, e_rsax_finish) || !ENGINE_set_ctrl_function(e, e_rsax_ctrl) || !ENGINE_set_cmd_defns(e, e_rsax_cmd_defns)) return 0; #ifndef OPENSSL_NO_RSA meth1 = RSA_PKCS1_SSLeay(); e_rsax_rsa.rsa_pub_enc = meth1->rsa_pub_enc; e_rsax_rsa.rsa_pub_dec = meth1->rsa_pub_dec; e_rsax_rsa.rsa_priv_enc = meth1->rsa_priv_enc; e_rsax_rsa.rsa_priv_dec = meth1->rsa_priv_dec; e_rsax_rsa.bn_mod_exp = meth1->bn_mod_exp; #endif return 1; } static ENGINE * ENGINE_rsax(void) { ENGINE *ret = ENGINE_new(); if (!ret) return NULL; if (!bind_helper(ret)) { ENGINE_free(ret); return NULL; } return ret; } #ifndef OPENSSL_NO_RSA /* Used to attach our own key-data to an RSA structure */ static int rsax_ex_data_idx = -1; #endif static int e_rsax_destroy(ENGINE *e) { return 1; } /* (de)initialisation functions. */ static int e_rsax_init(ENGINE *e) { #ifndef OPENSSL_NO_RSA if (rsax_ex_data_idx == -1) rsax_ex_data_idx = RSA_get_ex_new_index(0, NULL, NULL, NULL, NULL); #endif if (rsax_ex_data_idx == -1) return 0; return 1; } static int e_rsax_finish(ENGINE *e) { return 1; } static int e_rsax_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)) { int to_return = 1; switch (cmd) { /* The command isn't understood by this engine */ default: to_return = 0; break; } return to_return; } #ifndef OPENSSL_NO_RSA typedef unsigned long long UINT64; typedef unsigned short UINT16; /* Table t is interleaved in the following manner: * The order in memory is t[0][0], t[0][1], ..., t[0][7], t[1][0], ... * A particular 512-bit value is stored in t[][index] rather than the more * normal t[index][]; i.e. the qwords of a particular entry in t are not * adjacent in memory */ /* Init BIGNUM b from the interleaved UINT64 array */ static int interleaved_array_to_bn_512(BIGNUM* b, UINT64 *array); /* Extract array elements from BIGNUM b * To set the whole array from b, call with n=8 */ static int bn_extract_to_array_512(const BIGNUM* b, unsigned int n, UINT64 *array); struct mod_ctx_512 { UINT64 t[8][8]; UINT64 m[8]; UINT64 m1[8]; /* 2^278 % m */ UINT64 m2[8]; /* 2^640 % m */ UINT64 k1[2]; /* (- 1/m) % 2^128 */ }; static int mod_exp_pre_compute_data_512(UINT64 *m, struct mod_ctx_512 *data); void mod_exp_512(UINT64 *result, /* 512 bits, 8 qwords */ UINT64 *g, /* 512 bits, 8 qwords */ UINT64 *exp, /* 512 bits, 8 qwords */ struct mod_ctx_512 *data); typedef struct st_e_rsax_mod_ctx { UINT64 type; union { struct mod_ctx_512 b512; } ctx; } E_RSAX_MOD_CTX; static E_RSAX_MOD_CTX * e_rsax_get_ctx(RSA *rsa, int idx, BIGNUM* m) { E_RSAX_MOD_CTX *hptr; if (idx < 0 || idx > 2) return NULL; hptr = RSA_get_ex_data(rsa, rsax_ex_data_idx); if (!hptr) { hptr = reallocarray(NULL, 3, sizeof(E_RSAX_MOD_CTX)); if (!hptr) return NULL; hptr[2].type = hptr[1].type = hptr[0].type = 0; RSA_set_ex_data(rsa, rsax_ex_data_idx, hptr); } if (hptr[idx].type == (UINT64)BN_num_bits(m)) return hptr + idx; if (BN_num_bits(m) == 512) { UINT64 _m[8]; bn_extract_to_array_512(m, 8, _m); memset( &hptr[idx].ctx.b512, 0, sizeof(struct mod_ctx_512)); mod_exp_pre_compute_data_512(_m, &hptr[idx].ctx.b512); } hptr[idx].type = BN_num_bits(m); return hptr + idx; } static int e_rsax_rsa_finish(RSA *rsa) { E_RSAX_MOD_CTX *hptr = RSA_get_ex_data(rsa, rsax_ex_data_idx); if (hptr) { free(hptr); RSA_set_ex_data(rsa, rsax_ex_data_idx, NULL); } if (rsa->_method_mod_n) BN_MONT_CTX_free(rsa->_method_mod_n); if (rsa->_method_mod_p) BN_MONT_CTX_free(rsa->_method_mod_p); if (rsa->_method_mod_q) BN_MONT_CTX_free(rsa->_method_mod_q); return 1; } static int e_rsax_bn_mod_exp(BIGNUM *r, const BIGNUM *g, const BIGNUM *e, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont, E_RSAX_MOD_CTX* rsax_mod_ctx) { if (rsax_mod_ctx && BN_get_flags(e, BN_FLG_CONSTTIME) != 0) { if (BN_num_bits(m) == 512) { UINT64 _r[8]; UINT64 _g[8]; UINT64 _e[8]; /* Init the arrays from the BIGNUMs */ bn_extract_to_array_512(g, 8, _g); bn_extract_to_array_512(e, 8, _e); mod_exp_512(_r, _g, _e, &rsax_mod_ctx->ctx.b512); /* Return the result in the BIGNUM */ interleaved_array_to_bn_512(r, _r); return 1; } } return BN_mod_exp_mont(r, g, e, m, ctx, in_mont); } /* Declares for the Intel CIAP 512-bit / CRT / 1024 bit RSA modular * exponentiation routine precalculations and a structure to hold the * necessary values. These files are meant to live in crypto/rsa/ in * the target openssl. */ /* * Local method: extracts a piece from a BIGNUM, to fit it into * an array. Call with n=8 to extract an entire 512-bit BIGNUM */ static int bn_extract_to_array_512(const BIGNUM* b, unsigned int n, UINT64 *array) { int i; UINT64 tmp; unsigned char bn_buff[64]; memset(bn_buff, 0, 64); if (BN_num_bytes(b) > 64) { printf ("Can't support this byte size\n"); return 0; } if (BN_num_bytes(b) != 0) { if (!BN_bn2bin(b, bn_buff + (64 - BN_num_bytes(b)))) { printf ("Error's in bn2bin\n"); /* We have to error, here */ return 0; } } while (n-- > 0) { array[n] = 0; for (i = 7; i >= 0; i--) { tmp = bn_buff[63 - (n*8 + i)]; array[n] |= tmp << (8*i); } } return 1; } /* Init a 512-bit BIGNUM from the UINT64*_ (8 * 64) interleaved array */ static int interleaved_array_to_bn_512(BIGNUM* b, UINT64 *array) { unsigned char tmp[64]; int n = 8; int i; while (n-- > 0) { for (i = 7; i >= 0; i--) { tmp[63 - (n * 8 + i)] = (unsigned char)(array[n] >> (8 * i)); } } BN_bin2bn(tmp, 64, b); return 0; } /* The main 512bit precompute call */ static int mod_exp_pre_compute_data_512(UINT64 *m, struct mod_ctx_512 *data) { BIGNUM two_768, two_640, two_128, two_512, tmp, _m, tmp2; /* We need a BN_CTX for the modulo functions */ BN_CTX* ctx; /* Some tmps */ UINT64 _t[8]; int i, j, ret = 0; /* Init _m with m */ BN_init(&_m); interleaved_array_to_bn_512(&_m, m); memset(_t, 0, 64); /* Inits */ BN_init(&two_768); BN_init(&two_640); BN_init(&two_128); BN_init(&two_512); BN_init(&tmp); BN_init(&tmp2); /* Create our context */ if ((ctx = BN_CTX_new()) == NULL) { goto err; } BN_CTX_start(ctx); /* * For production, if you care, these only need to be set once, * and may be made constants. */ BN_lshift(&two_768, BN_value_one(), 768); BN_lshift(&two_640, BN_value_one(), 640); BN_lshift(&two_128, BN_value_one(), 128); BN_lshift(&two_512, BN_value_one(), 512); if (0 == (m[7] & 0x8000000000000000)) { exit(1); } if (0 == (m[0] & 0x1)) { /* Odd modulus required for Mont */ exit(1); } /* Precompute m1 */ BN_mod(&tmp, &two_768, &_m, ctx); if (!bn_extract_to_array_512(&tmp, 8, &data->m1[0])) { goto err; } /* Precompute m2 */ BN_mod(&tmp, &two_640, &_m, ctx); if (!bn_extract_to_array_512(&tmp, 8, &data->m2[0])) { goto err; } /* * Precompute k1, a 128b number = ((-1)* m-1 ) mod 2128; k1 should * be non-negative. */ BN_mod_inverse(&tmp, &_m, &two_128, ctx); if (!BN_is_zero(&tmp)) { BN_sub(&tmp, &two_128, &tmp); } if (!bn_extract_to_array_512(&tmp, 2, &data->k1[0])) { goto err; } /* Precompute t */ for (i = 0; i < 8; i++) { BN_zero(&tmp); if (i & 1) { BN_add(&tmp, &two_512, &tmp); } if (i & 2) { BN_add(&tmp, &two_512, &tmp); } if (i & 4) { BN_add(&tmp, &two_640, &tmp); } BN_nnmod(&tmp2, &tmp, &_m, ctx); if (!bn_extract_to_array_512(&tmp2, 8, _t)) { goto err; } for (j = 0; j < 8; j++) data->t[j][i] = _t[j]; } /* Precompute m */ for (i = 0; i < 8; i++) { data->m[i] = m[i]; } ret = 1; err: /* Cleanup */ if (ctx != NULL) { BN_CTX_end(ctx); BN_CTX_free(ctx); } BN_free(&two_768); BN_free(&two_640); BN_free(&two_128); BN_free(&two_512); BN_free(&tmp); BN_free(&tmp2); BN_free(&_m); return ret; } static int e_rsax_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) { BIGNUM *r1, *m1, *vrfy; BIGNUM local_dmp1, local_dmq1, local_c, local_r1; BIGNUM *dmp1, *dmq1, *c, *pr1; int ret = 0; BN_CTX_start(ctx); r1 = BN_CTX_get(ctx); m1 = BN_CTX_get(ctx); vrfy = BN_CTX_get(ctx); { BIGNUM local_p, local_q; BIGNUM *p = NULL, *q = NULL; int error = 0; /* Make sure BN_mod_inverse in Montgomery * intialization uses the BN_FLG_CONSTTIME flag * (unless RSA_FLAG_NO_CONSTTIME is set) */ if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { BN_init(&local_p); p = &local_p; BN_with_flags(p, rsa->p, BN_FLG_CONSTTIME); BN_init(&local_q); q = &local_q; BN_with_flags(q, rsa->q, BN_FLG_CONSTTIME); } else { p = rsa->p; q = rsa->q; } if (rsa->flags & RSA_FLAG_CACHE_PRIVATE) { if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_p, CRYPTO_LOCK_RSA, p, ctx)) error = 1; if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_q, CRYPTO_LOCK_RSA, q, ctx)) error = 1; } /* clean up */ if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { BN_free(&local_p); BN_free(&local_q); } if (error ) goto err; } if (rsa->flags & RSA_FLAG_CACHE_PUBLIC) if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_n, CRYPTO_LOCK_RSA, rsa->n, ctx)) goto err; /* compute I mod q */ if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { c = &local_c; BN_with_flags(c, I, BN_FLG_CONSTTIME); if (!BN_mod(r1, c, rsa->q, ctx)) goto err; } else { if (!BN_mod(r1, I, rsa->q, ctx)) goto err; } /* compute r1^dmq1 mod q */ if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { dmq1 = &local_dmq1; BN_with_flags(dmq1, rsa->dmq1, BN_FLG_CONSTTIME); } else dmq1 = rsa->dmq1; if (!e_rsax_bn_mod_exp(m1, r1, dmq1, rsa->q, ctx, rsa->_method_mod_q, e_rsax_get_ctx(rsa, 0, rsa->q))) goto err; /* compute I mod p */ if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { c = &local_c; BN_with_flags(c, I, BN_FLG_CONSTTIME); if (!BN_mod(r1, c, rsa->p, ctx)) goto err; } else { if (!BN_mod(r1, I, rsa->p, ctx)) goto err; } /* compute r1^dmp1 mod p */ if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { dmp1 = &local_dmp1; BN_with_flags(dmp1, rsa->dmp1, BN_FLG_CONSTTIME); } else dmp1 = rsa->dmp1; if (!e_rsax_bn_mod_exp(r0, r1, dmp1, rsa->p, ctx, rsa->_method_mod_p, e_rsax_get_ctx(rsa, 1, rsa->p))) goto err; if (!BN_sub(r0, r0, m1)) goto err; /* This will help stop the size of r0 increasing, which does * affect the multiply if it optimised for a power of 2 size */ if (BN_is_negative(r0)) if (!BN_add(r0, r0, rsa->p)) goto err; if (!BN_mul(r1, r0, rsa->iqmp, ctx)) goto err; /* Turn BN_FLG_CONSTTIME flag on before division operation */ if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { pr1 = &local_r1; BN_with_flags(pr1, r1, BN_FLG_CONSTTIME); } else pr1 = r1; if (!BN_mod(r0, pr1, rsa->p, ctx)) goto err; /* If p < q it is occasionally possible for the correction of * adding 'p' if r0 is negative above to leave the result still * negative. This can break the private key operations: the following * second correction should *always* correct this rare occurrence. * This will *never* happen with OpenSSL generated keys because * they ensure p > q [steve] */ if (BN_is_negative(r0)) if (!BN_add(r0, r0, rsa->p)) goto err; if (!BN_mul(r1, r0, rsa->q, ctx)) goto err; if (!BN_add(r0, r1, m1)) goto err; if (rsa->e && rsa->n) { if (!e_rsax_bn_mod_exp(vrfy, r0, rsa->e, rsa->n, ctx, rsa->_method_mod_n, e_rsax_get_ctx(rsa, 2, rsa->n))) goto err; /* If 'I' was greater than (or equal to) rsa->n, the operation * will be equivalent to using 'I mod n'. However, the result of * the verify will *always* be less than 'n' so we don't check * for absolute equality, just congruency. */ if (!BN_sub(vrfy, vrfy, I)) goto err; if (!BN_mod(vrfy, vrfy, rsa->n, ctx)) goto err; if (BN_is_negative(vrfy)) if (!BN_add(vrfy, vrfy, rsa->n)) goto err; if (!BN_is_zero(vrfy)) { /* 'I' and 'vrfy' aren't congruent mod n. Don't leak * miscalculated CRT output, just do a raw (slower) * mod_exp and return that instead. */ BIGNUM local_d; BIGNUM *d = NULL; if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME)) { d = &local_d; BN_with_flags(d, rsa->d, BN_FLG_CONSTTIME); } else d = rsa->d; if (!e_rsax_bn_mod_exp(r0, I,d, rsa->n, ctx, rsa->_method_mod_n, e_rsax_get_ctx(rsa, 2, rsa->n))) goto err; } } ret = 1; err: BN_CTX_end(ctx); return ret; } #endif /* !OPENSSL_NO_RSA */ #endif /* !COMPILE_RSAX */ deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/tb_digest.c0000644000175000017500000001123712360020705021634 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "eng_int.h" /* If this symbol is defined then ENGINE_get_digest_engine(), the function that * is used by EVP to hook in digest code and cache defaults (etc), will display * brief debugging summaries to stderr with the 'nid'. */ /* #define ENGINE_DIGEST_DEBUG */ static ENGINE_TABLE *digest_table = NULL; void ENGINE_unregister_digests(ENGINE *e) { engine_table_unregister(&digest_table, e); } static void engine_unregister_all_digests(void) { engine_table_cleanup(&digest_table); } int ENGINE_register_digests(ENGINE *e) { if (e->digests) { const int *nids; int num_nids = e->digests(e, NULL, &nids, 0); if (num_nids > 0) return engine_table_register(&digest_table, engine_unregister_all_digests, e, nids, num_nids, 0); } return 1; } void ENGINE_register_all_digests(void) { ENGINE *e; for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_digests(e); } int ENGINE_set_default_digests(ENGINE *e) { if (e->digests) { const int *nids; int num_nids = e->digests(e, NULL, &nids, 0); if (num_nids > 0) return engine_table_register(&digest_table, engine_unregister_all_digests, e, nids, num_nids, 1); } return 1; } /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references) for a given digest 'nid' */ ENGINE * ENGINE_get_digest_engine(int nid) { return engine_table_select(&digest_table, nid); } /* Obtains a digest implementation from an ENGINE functional reference */ const EVP_MD * ENGINE_get_digest(ENGINE *e, int nid) { const EVP_MD *ret; ENGINE_DIGESTS_PTR fn = ENGINE_get_digests(e); if (!fn || !fn(e, &ret, NULL, nid)) { ENGINEerr(ENGINE_F_ENGINE_GET_DIGEST, ENGINE_R_UNIMPLEMENTED_DIGEST); return NULL; } return ret; } /* Gets the digest callback from an ENGINE structure */ ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e) { return e->digests; } /* Sets the digest callback in an ENGINE structure */ int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f) { e->digests = f; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/eng_dyn.c0000644000175000017500000004267312360020705021323 0ustar /* $OpenBSD: eng_dyn.c,v 1.10 2014/07/09 08:52:00 bcook Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2001. */ /* ==================================================================== * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include "eng_int.h" #include /* Shared libraries implementing ENGINEs for use by the "dynamic" ENGINE loader * should implement the hook-up functions with the following prototypes. */ /* Our ENGINE handlers */ static int dynamic_init(ENGINE *e); static int dynamic_finish(ENGINE *e); static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)); /* Predeclare our context type */ typedef struct st_dynamic_data_ctx dynamic_data_ctx; /* The implementation for the important control command */ static int dynamic_load(ENGINE *e, dynamic_data_ctx *ctx); #define DYNAMIC_CMD_SO_PATH ENGINE_CMD_BASE #define DYNAMIC_CMD_NO_VCHECK (ENGINE_CMD_BASE + 1) #define DYNAMIC_CMD_ID (ENGINE_CMD_BASE + 2) #define DYNAMIC_CMD_LIST_ADD (ENGINE_CMD_BASE + 3) #define DYNAMIC_CMD_DIR_LOAD (ENGINE_CMD_BASE + 4) #define DYNAMIC_CMD_DIR_ADD (ENGINE_CMD_BASE + 5) #define DYNAMIC_CMD_LOAD (ENGINE_CMD_BASE + 6) /* The constants used when creating the ENGINE */ static const char *engine_dynamic_id = "dynamic"; static const char *engine_dynamic_name = "Dynamic engine loading support"; static const ENGINE_CMD_DEFN dynamic_cmd_defns[] = { { DYNAMIC_CMD_SO_PATH, "SO_PATH", "Specifies the path to the new ENGINE shared library", ENGINE_CMD_FLAG_STRING}, { DYNAMIC_CMD_NO_VCHECK, "NO_VCHECK", "Specifies to continue even if version checking fails (boolean)", ENGINE_CMD_FLAG_NUMERIC}, { DYNAMIC_CMD_ID, "ID", "Specifies an ENGINE id name for loading", ENGINE_CMD_FLAG_STRING}, { DYNAMIC_CMD_LIST_ADD, "LIST_ADD", "Whether to add a loaded ENGINE to the internal list (0=no,1=yes,2=mandatory)", ENGINE_CMD_FLAG_NUMERIC}, { DYNAMIC_CMD_DIR_LOAD, "DIR_LOAD", "Specifies whether to load from 'DIR_ADD' directories (0=no,1=yes,2=mandatory)", ENGINE_CMD_FLAG_NUMERIC}, { DYNAMIC_CMD_DIR_ADD, "DIR_ADD", "Adds a directory from which ENGINEs can be loaded", ENGINE_CMD_FLAG_STRING}, { DYNAMIC_CMD_LOAD, "LOAD", "Load up the ENGINE specified by other settings", ENGINE_CMD_FLAG_NO_INPUT}, {0, NULL, NULL, 0} }; /* Loading code stores state inside the ENGINE structure via the "ex_data" * element. We load all our state into a single structure and use that as a * single context in the "ex_data" stack. */ struct st_dynamic_data_ctx { /* The DSO object we load that supplies the ENGINE code */ DSO *dynamic_dso; /* The function pointer to the version checking shared library function */ dynamic_v_check_fn v_check; /* The function pointer to the engine-binding shared library function */ dynamic_bind_engine bind_engine; /* The default name/path for loading the shared library */ const char *DYNAMIC_LIBNAME; /* Whether to continue loading on a version check failure */ int no_vcheck; /* If non-NULL, stipulates the 'id' of the ENGINE to be loaded */ const char *engine_id; /* If non-zero, a successfully loaded ENGINE should be added to the internal * ENGINE list. If 2, the add must succeed or the entire load should fail. */ int list_add_value; /* The symbol name for the version checking function */ const char *DYNAMIC_F1; /* The symbol name for the "initialise ENGINE structure" function */ const char *DYNAMIC_F2; /* Whether to never use 'dirs', use 'dirs' as a fallback, or only use * 'dirs' for loading. Default is to use 'dirs' as a fallback. */ int dir_load; /* A stack of directories from which ENGINEs could be loaded */ STACK_OF(OPENSSL_STRING) *dirs; }; /* This is the "ex_data" index we obtain and reserve for use with our context * structure. */ static int dynamic_ex_data_idx = -1; static void int_free_str(char *s) { free(s); } /* Because our ex_data element may or may not get allocated depending on whether * a "first-use" occurs before the ENGINE is freed, we have a memory leak * problem to solve. We can't declare a "new" handler for the ex_data as we * don't want a dynamic_data_ctx in *all* ENGINE structures of all types (this * is a bug in the design of CRYPTO_EX_DATA). As such, we just declare a "free" * handler and that will get called if an ENGINE is being destroyed and there * was an ex_data element corresponding to our context type. */ static void dynamic_data_ctx_free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad, int idx, long argl, void *argp) { if (ptr) { dynamic_data_ctx *ctx = (dynamic_data_ctx *)ptr; if (ctx->dynamic_dso) DSO_free(ctx->dynamic_dso); free((void *)ctx->DYNAMIC_LIBNAME); free((void *)ctx->engine_id); if (ctx->dirs) sk_OPENSSL_STRING_pop_free(ctx->dirs, int_free_str); free(ctx); } } /* Construct the per-ENGINE context. We create it blindly and then use a lock to * check for a race - if so, all but one of the threads "racing" will have * wasted their time. The alternative involves creating everything inside the * lock which is far worse. */ static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx) { dynamic_data_ctx *c; c = malloc(sizeof(dynamic_data_ctx)); if (!c) { ENGINEerr(ENGINE_F_DYNAMIC_SET_DATA_CTX, ERR_R_MALLOC_FAILURE); return 0; } memset(c, 0, sizeof(dynamic_data_ctx)); c->dynamic_dso = NULL; c->v_check = NULL; c->bind_engine = NULL; c->DYNAMIC_LIBNAME = NULL; c->no_vcheck = 0; c->engine_id = NULL; c->list_add_value = 0; c->DYNAMIC_F1 = "v_check"; c->DYNAMIC_F2 = "bind_engine"; c->dir_load = 1; c->dirs = sk_OPENSSL_STRING_new_null(); if (!c->dirs) { ENGINEerr(ENGINE_F_DYNAMIC_SET_DATA_CTX, ERR_R_MALLOC_FAILURE); free(c); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if ((*ctx = (dynamic_data_ctx *)ENGINE_get_ex_data(e, dynamic_ex_data_idx)) == NULL) { /* Good, we're the first */ ENGINE_set_ex_data(e, dynamic_ex_data_idx, c); *ctx = c; c = NULL; } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); /* If we lost the race to set the context, c is non-NULL and *ctx is the * context of the thread that won. */ free(c); return 1; } /* This function retrieves the context structure from an ENGINE's "ex_data", or * if it doesn't exist yet, sets it up. */ static dynamic_data_ctx * dynamic_get_data_ctx(ENGINE *e) { dynamic_data_ctx *ctx; if (dynamic_ex_data_idx < 0) { /* Create and register the ENGINE ex_data, and associate our * "free" function with it to ensure any allocated contexts get * freed when an ENGINE goes underground. */ int new_idx = ENGINE_get_ex_new_index(0, NULL, NULL, NULL, dynamic_data_ctx_free_func); if (new_idx == -1) { ENGINEerr(ENGINE_F_DYNAMIC_GET_DATA_CTX, ENGINE_R_NO_INDEX); return NULL; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); /* Avoid a race by checking again inside this lock */ if (dynamic_ex_data_idx < 0) { /* Good, someone didn't beat us to it */ dynamic_ex_data_idx = new_idx; new_idx = -1; } CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); /* In theory we could "give back" the index here if * (new_idx>-1), but it's not possible and wouldn't gain us much * if it were. */ } ctx = (dynamic_data_ctx *)ENGINE_get_ex_data(e, dynamic_ex_data_idx); /* Check if the context needs to be created */ if ((ctx == NULL) && !dynamic_set_data_ctx(e, &ctx)) /* "set_data" will set errors if necessary */ return NULL; return ctx; } static ENGINE * engine_dynamic(void) { ENGINE *ret = ENGINE_new(); if (!ret) return NULL; if (!ENGINE_set_id(ret, engine_dynamic_id) || !ENGINE_set_name(ret, engine_dynamic_name) || !ENGINE_set_init_function(ret, dynamic_init) || !ENGINE_set_finish_function(ret, dynamic_finish) || !ENGINE_set_ctrl_function(ret, dynamic_ctrl) || !ENGINE_set_flags(ret, ENGINE_FLAGS_BY_ID_COPY) || !ENGINE_set_cmd_defns(ret, dynamic_cmd_defns)) { ENGINE_free(ret); return NULL; } return ret; } void ENGINE_load_dynamic(void) { ENGINE *toadd = engine_dynamic(); if (!toadd) return; ENGINE_add(toadd); /* If the "add" worked, it gets a structural reference. So either way, * we release our just-created reference. */ ENGINE_free(toadd); /* If the "add" didn't work, it was probably a conflict because it was * already added (eg. someone calling ENGINE_load_blah then calling * ENGINE_load_builtin_engines() perhaps). */ ERR_clear_error(); } static int dynamic_init(ENGINE *e) { /* We always return failure - the "dyanamic" engine itself can't be used * for anything. */ return 0; } static int dynamic_finish(ENGINE *e) { /* This should never be called on account of "dynamic_init" always * failing. */ return 0; } static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)) { dynamic_data_ctx *ctx = dynamic_get_data_ctx(e); int initialised; if (!ctx) { ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ENGINE_R_NOT_LOADED); return 0; } initialised = ((ctx->dynamic_dso == NULL) ? 0 : 1); /* All our control commands require the ENGINE to be uninitialised */ if (initialised) { ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ENGINE_R_ALREADY_LOADED); return 0; } switch (cmd) { case DYNAMIC_CMD_SO_PATH: /* a NULL 'p' or a string of zero-length is the same thing */ if (p && (strlen((const char *)p) < 1)) p = NULL; free((void *)ctx->DYNAMIC_LIBNAME); if (p) ctx->DYNAMIC_LIBNAME = BUF_strdup(p); else ctx->DYNAMIC_LIBNAME = NULL; return (ctx->DYNAMIC_LIBNAME ? 1 : 0); case DYNAMIC_CMD_NO_VCHECK: ctx->no_vcheck = ((i == 0) ? 0 : 1); return 1; case DYNAMIC_CMD_ID: /* a NULL 'p' or a string of zero-length is the same thing */ if (p && (strlen((const char *)p) < 1)) p = NULL; free((void *)ctx->engine_id); if (p) ctx->engine_id = BUF_strdup(p); else ctx->engine_id = NULL; return (ctx->engine_id ? 1 : 0); case DYNAMIC_CMD_LIST_ADD: if ((i < 0) || (i > 2)) { ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ENGINE_R_INVALID_ARGUMENT); return 0; } ctx->list_add_value = (int)i; return 1; case DYNAMIC_CMD_LOAD: return dynamic_load(e, ctx); case DYNAMIC_CMD_DIR_LOAD: if ((i < 0) || (i > 2)) { ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ENGINE_R_INVALID_ARGUMENT); return 0; } ctx->dir_load = (int)i; return 1; case DYNAMIC_CMD_DIR_ADD: /* a NULL 'p' or a string of zero-length is the same thing */ if (!p || (strlen((const char *)p) < 1)) { ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ENGINE_R_INVALID_ARGUMENT); return 0; } { char *tmp_str = BUF_strdup(p); if (!tmp_str) { ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ERR_R_MALLOC_FAILURE); return 0; } sk_OPENSSL_STRING_insert(ctx->dirs, tmp_str, -1); } return 1; default: break; } ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED); return 0; } static int int_load(dynamic_data_ctx *ctx) { int num, loop; /* Unless told not to, try a direct load */ if ((ctx->dir_load != 2) && (DSO_load(ctx->dynamic_dso, ctx->DYNAMIC_LIBNAME, NULL, 0)) != NULL) return 1; /* If we're not allowed to use 'dirs' or we have none, fail */ if (!ctx->dir_load || (num = sk_OPENSSL_STRING_num(ctx->dirs)) < 1) return 0; for (loop = 0; loop < num; loop++) { const char *s = sk_OPENSSL_STRING_value(ctx->dirs, loop); char *merge = DSO_merge(ctx->dynamic_dso, ctx->DYNAMIC_LIBNAME, s); if (!merge) return 0; if (DSO_load(ctx->dynamic_dso, merge, NULL, 0)) { /* Found what we're looking for */ free(merge); return 1; } free(merge); } return 0; } static int dynamic_load(ENGINE *e, dynamic_data_ctx *ctx) { ENGINE cpy; dynamic_fns fns; if (!ctx->dynamic_dso) ctx->dynamic_dso = DSO_new(); if (!ctx->DYNAMIC_LIBNAME) { if (!ctx->engine_id) return 0; ctx->DYNAMIC_LIBNAME = DSO_convert_filename(ctx->dynamic_dso, ctx->engine_id); } if (!int_load(ctx)) { ENGINEerr(ENGINE_F_DYNAMIC_LOAD, ENGINE_R_DSO_NOT_FOUND); DSO_free(ctx->dynamic_dso); ctx->dynamic_dso = NULL; return 0; } /* We have to find a bind function otherwise it'll always end badly */ if (!(ctx->bind_engine = (dynamic_bind_engine)DSO_bind_func( ctx->dynamic_dso, ctx->DYNAMIC_F2))) { ctx->bind_engine = NULL; DSO_free(ctx->dynamic_dso); ctx->dynamic_dso = NULL; ENGINEerr(ENGINE_F_DYNAMIC_LOAD, ENGINE_R_DSO_FAILURE); return 0; } /* Do we perform version checking? */ if (!ctx->no_vcheck) { unsigned long vcheck_res = 0; /* Now we try to find a version checking function and decide how * to cope with failure if/when it fails. */ ctx->v_check = (dynamic_v_check_fn)DSO_bind_func( ctx->dynamic_dso, ctx->DYNAMIC_F1); if (ctx->v_check) vcheck_res = ctx->v_check(OSSL_DYNAMIC_VERSION); /* We fail if the version checker veto'd the load *or* if it is * deferring to us (by returning its version) and we think it is * too old. */ if (vcheck_res < OSSL_DYNAMIC_OLDEST) { /* Fail */ ctx->bind_engine = NULL; ctx->v_check = NULL; DSO_free(ctx->dynamic_dso); ctx->dynamic_dso = NULL; ENGINEerr(ENGINE_F_DYNAMIC_LOAD, ENGINE_R_VERSION_INCOMPATIBILITY); return 0; } } /* First binary copy the ENGINE structure so that we can roll back if * the hand-over fails */ memcpy(&cpy, e, sizeof(ENGINE)); /* Provide the ERR, "ex_data", memory, and locking callbacks so the * loaded library uses our state rather than its own. FIXME: As noted in * engine.h, much of this would be simplified if each area of code * provided its own "summary" structure of all related callbacks. It * would also increase opaqueness. */ fns.static_state = ENGINE_get_static_state(); fns.err_fns = ERR_get_implementation(); fns.ex_data_fns = CRYPTO_get_ex_data_implementation(); CRYPTO_get_mem_functions(&fns.mem_fns.malloc_cb, &fns.mem_fns.realloc_cb, &fns.mem_fns.free_cb); fns.lock_fns.lock_locking_cb = CRYPTO_get_locking_callback(); fns.lock_fns.lock_add_lock_cb = CRYPTO_get_add_lock_callback(); fns.lock_fns.dynlock_create_cb = CRYPTO_get_dynlock_create_callback(); fns.lock_fns.dynlock_lock_cb = CRYPTO_get_dynlock_lock_callback(); fns.lock_fns.dynlock_destroy_cb = CRYPTO_get_dynlock_destroy_callback(); /* Now that we've loaded the dynamic engine, make sure no "dynamic" * ENGINE elements will show through. */ engine_set_all_null(e); /* Try to bind the ENGINE onto our own ENGINE structure */ if (!ctx->bind_engine(e, ctx->engine_id, &fns)) { ctx->bind_engine = NULL; ctx->v_check = NULL; DSO_free(ctx->dynamic_dso); ctx->dynamic_dso = NULL; ENGINEerr(ENGINE_F_DYNAMIC_LOAD, ENGINE_R_INIT_FAILED); /* Copy the original ENGINE structure back */ memcpy(e, &cpy, sizeof(ENGINE)); return 0; } /* Do we try to add this ENGINE to the internal list too? */ if (ctx->list_add_value > 0) { if (!ENGINE_add(e)) { /* Do we tolerate this or fail? */ if (ctx->list_add_value > 1) { /* Fail - NB: By this time, it's too late to * rollback, and trying to do so allows the * bind_engine() code to have created leaks. We * just have to fail where we are, after the * ENGINE has changed. */ ENGINEerr(ENGINE_F_DYNAMIC_LOAD, ENGINE_R_CONFLICTING_ENGINE_ID); return 0; } /* Tolerate */ ERR_clear_error(); } } return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/tb_rsa.c0000644000175000017500000001015312360020705021136 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "eng_int.h" /* If this symbol is defined then ENGINE_get_default_RSA(), the function that is * used by RSA to hook in implementation code and cache defaults (etc), will * display brief debugging summaries to stderr with the 'nid'. */ /* #define ENGINE_RSA_DEBUG */ static ENGINE_TABLE *rsa_table = NULL; static const int dummy_nid = 1; void ENGINE_unregister_RSA(ENGINE *e) { engine_table_unregister(&rsa_table, e); } static void engine_unregister_all_RSA(void) { engine_table_cleanup(&rsa_table); } int ENGINE_register_RSA(ENGINE *e) { if (e->rsa_meth) return engine_table_register(&rsa_table, engine_unregister_all_RSA, e, &dummy_nid, 1, 0); return 1; } void ENGINE_register_all_RSA(void) { ENGINE *e; for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_RSA(e); } int ENGINE_set_default_RSA(ENGINE *e) { if (e->rsa_meth) return engine_table_register(&rsa_table, engine_unregister_all_RSA, e, &dummy_nid, 1, 1); return 1; } /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references). */ ENGINE * ENGINE_get_default_RSA(void) { return engine_table_select(&rsa_table, dummy_nid); } /* Obtains an RSA implementation from an ENGINE functional reference */ const RSA_METHOD * ENGINE_get_RSA(const ENGINE *e) { return e->rsa_meth; } /* Sets an RSA implementation in an ENGINE structure */ int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth) { e->rsa_meth = rsa_meth; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/tb_store.c0000644000175000017500000001041012360020705021501 0ustar /* $OpenBSD$ */ /* ==================================================================== * Copyright (c) 2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "eng_int.h" /* If this symbol is defined then ENGINE_get_default_STORE(), the function that is * used by STORE to hook in implementation code and cache defaults (etc), will * display brief debugging summaries to stderr with the 'nid'. */ /* #define ENGINE_STORE_DEBUG */ static ENGINE_TABLE *store_table = NULL; static const int dummy_nid = 1; void ENGINE_unregister_STORE(ENGINE *e) { engine_table_unregister(&store_table, e); } static void engine_unregister_all_STORE(void) { engine_table_cleanup(&store_table); } int ENGINE_register_STORE(ENGINE *e) { if (e->store_meth) return engine_table_register(&store_table, engine_unregister_all_STORE, e, &dummy_nid, 1, 0); return 1; } void ENGINE_register_all_STORE(void) { ENGINE *e; for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_STORE(e); } /* The following two functions are removed because they're useless. */ #if 0 int ENGINE_set_default_STORE(ENGINE *e) { if (e->store_meth) return engine_table_register(&store_table, engine_unregister_all_STORE, e, &dummy_nid, 1, 1); return 1; } #endif #if 0 /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references). */ ENGINE * ENGINE_get_default_STORE(void) { return engine_table_select(&store_table, dummy_nid); } #endif /* Obtains an STORE implementation from an ENGINE functional reference */ const STORE_METHOD * ENGINE_get_STORE(const ENGINE *e) { return e->store_meth; } /* Sets an STORE implementation in an ENGINE structure */ int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth) { e->store_meth = store_meth; return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/eng_lib.c0000644000175000017500000002072312360020705021267 0ustar /* $OpenBSD: eng_lib.c,v 1.8 2014/06/22 12:05:09 jsing Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include "eng_int.h" #include /* The "new"/"free" stuff first */ ENGINE * ENGINE_new(void) { ENGINE *ret; ret = malloc(sizeof(ENGINE)); if (ret == NULL) { ENGINEerr(ENGINE_F_ENGINE_NEW, ERR_R_MALLOC_FAILURE); return NULL; } memset(ret, 0, sizeof(ENGINE)); ret->struct_ref = 1; engine_ref_debug(ret, 0, 1) CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ENGINE, ret, &ret->ex_data); return ret; } /* Placed here (close proximity to ENGINE_new) so that modifications to the * elements of the ENGINE structure are more likely to be caught and changed * here. */ void engine_set_all_null(ENGINE *e) { e->id = NULL; e->name = NULL; e->rsa_meth = NULL; e->dsa_meth = NULL; e->dh_meth = NULL; e->rand_meth = NULL; e->store_meth = NULL; e->ciphers = NULL; e->digests = NULL; e->destroy = NULL; e->init = NULL; e->finish = NULL; e->ctrl = NULL; e->load_privkey = NULL; e->load_pubkey = NULL; e->cmd_defns = NULL; e->flags = 0; } int engine_free_util(ENGINE *e, int locked) { int i; if (e == NULL) { ENGINEerr(ENGINE_F_ENGINE_FREE_UTIL, ERR_R_PASSED_NULL_PARAMETER); return 0; } if (locked) i = CRYPTO_add(&e->struct_ref, -1, CRYPTO_LOCK_ENGINE); else i = --e->struct_ref; engine_ref_debug(e, 0, -1) if (i > 0) return 1; /* Free up any dynamically allocated public key methods */ engine_pkey_meths_free(e); engine_pkey_asn1_meths_free(e); /* Give the ENGINE a chance to do any structural cleanup corresponding * to allocation it did in its constructor (eg. unload error strings) */ if (e->destroy) e->destroy(e); CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ENGINE, e, &e->ex_data); free(e); return 1; } int ENGINE_free(ENGINE *e) { return engine_free_util(e, 1); } /* Cleanup stuff */ /* ENGINE_cleanup() is coded such that anything that does work that will need * cleanup can register a "cleanup" callback here. That way we don't get linker * bloat by referring to all *possible* cleanups, but any linker bloat into code * "X" will cause X's cleanup function to end up here. */ static STACK_OF(ENGINE_CLEANUP_ITEM) *cleanup_stack = NULL; static int int_cleanup_check(int create) { if (cleanup_stack) return 1; if (!create) return 0; cleanup_stack = sk_ENGINE_CLEANUP_ITEM_new_null(); return (cleanup_stack ? 1 : 0); } static ENGINE_CLEANUP_ITEM * int_cleanup_item(ENGINE_CLEANUP_CB *cb) { ENGINE_CLEANUP_ITEM *item = malloc(sizeof(ENGINE_CLEANUP_ITEM)); if (!item) return NULL; item->cb = cb; return item; } void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb) { ENGINE_CLEANUP_ITEM *item; if (!int_cleanup_check(1)) return; item = int_cleanup_item(cb); if (item) sk_ENGINE_CLEANUP_ITEM_insert(cleanup_stack, item, 0); } void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb) { ENGINE_CLEANUP_ITEM *item; if (!int_cleanup_check(1)) return; item = int_cleanup_item(cb); if (item) sk_ENGINE_CLEANUP_ITEM_push(cleanup_stack, item); } /* The API function that performs all cleanup */ static void engine_cleanup_cb_free(ENGINE_CLEANUP_ITEM *item) { (*(item->cb))(); free(item); } void ENGINE_cleanup(void) { if (int_cleanup_check(0)) { sk_ENGINE_CLEANUP_ITEM_pop_free(cleanup_stack, engine_cleanup_cb_free); cleanup_stack = NULL; } /* FIXME: This should be handled (somehow) through RAND, eg. by it * registering a cleanup callback. */ RAND_set_rand_method(NULL); } /* Now the "ex_data" support */ int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ENGINE, argl, argp, new_func, dup_func, free_func); } int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg) { return (CRYPTO_set_ex_data(&e->ex_data, idx, arg)); } void * ENGINE_get_ex_data(const ENGINE *e, int idx) { return (CRYPTO_get_ex_data(&e->ex_data, idx)); } /* Functions to get/set an ENGINE's elements - mainly to avoid exposing the * ENGINE structure itself. */ int ENGINE_set_id(ENGINE *e, const char *id) { if (id == NULL) { ENGINEerr(ENGINE_F_ENGINE_SET_ID, ERR_R_PASSED_NULL_PARAMETER); return 0; } e->id = id; return 1; } int ENGINE_set_name(ENGINE *e, const char *name) { if (name == NULL) { ENGINEerr(ENGINE_F_ENGINE_SET_NAME, ERR_R_PASSED_NULL_PARAMETER); return 0; } e->name = name; return 1; } int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f) { e->destroy = destroy_f; return 1; } int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f) { e->init = init_f; return 1; } int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f) { e->finish = finish_f; return 1; } int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f) { e->ctrl = ctrl_f; return 1; } int ENGINE_set_flags(ENGINE *e, int flags) { e->flags = flags; return 1; } int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns) { e->cmd_defns = defns; return 1; } const char * ENGINE_get_id(const ENGINE *e) { return e->id; } const char * ENGINE_get_name(const ENGINE *e) { return e->name; } ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e) { return e->destroy; } ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e) { return e->init; } ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e) { return e->finish; } ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e) { return e->ctrl; } int ENGINE_get_flags(const ENGINE *e) { return e->flags; } const ENGINE_CMD_DEFN * ENGINE_get_cmd_defns(const ENGINE *e) { return e->cmd_defns; } /* eng_lib.o is pretty much linked into anything that touches ENGINE already, so * put the "static_state" hack here. */ static int internal_static_hack = 0; void * ENGINE_get_static_state(void) { return &internal_static_hack; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/tb_asnmth.c0000644000175000017500000001650412360020705021651 0ustar /* $OpenBSD: tb_asnmth.c,v 1.3 2014/06/12 15:49:29 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include "eng_int.h" #include "asn1_locl.h" #include /* If this symbol is defined then ENGINE_get_pkey_asn1_meth_engine(), the * function that is used by EVP to hook in pkey_asn1_meth code and cache * defaults (etc), will display brief debugging summaries to stderr with the * 'nid'. */ /* #define ENGINE_PKEY_ASN1_METH_DEBUG */ static ENGINE_TABLE *pkey_asn1_meth_table = NULL; void ENGINE_unregister_pkey_asn1_meths(ENGINE *e) { engine_table_unregister(&pkey_asn1_meth_table, e); } static void engine_unregister_all_pkey_asn1_meths(void) { engine_table_cleanup(&pkey_asn1_meth_table); } int ENGINE_register_pkey_asn1_meths(ENGINE *e) { if (e->pkey_asn1_meths) { const int *nids; int num_nids = e->pkey_asn1_meths(e, NULL, &nids, 0); if (num_nids > 0) return engine_table_register(&pkey_asn1_meth_table, engine_unregister_all_pkey_asn1_meths, e, nids, num_nids, 0); } return 1; } void ENGINE_register_all_pkey_asn1_meths(void) { ENGINE *e; for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_pkey_asn1_meths(e); } int ENGINE_set_default_pkey_asn1_meths(ENGINE *e) { if (e->pkey_asn1_meths) { const int *nids; int num_nids = e->pkey_asn1_meths(e, NULL, &nids, 0); if (num_nids > 0) return engine_table_register(&pkey_asn1_meth_table, engine_unregister_all_pkey_asn1_meths, e, nids, num_nids, 1); } return 1; } /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references) for a given pkey_asn1_meth 'nid' */ ENGINE * ENGINE_get_pkey_asn1_meth_engine(int nid) { return engine_table_select(&pkey_asn1_meth_table, nid); } /* Obtains a pkey_asn1_meth implementation from an ENGINE functional reference */ const EVP_PKEY_ASN1_METHOD * ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid) { EVP_PKEY_ASN1_METHOD *ret; ENGINE_PKEY_ASN1_METHS_PTR fn = ENGINE_get_pkey_asn1_meths(e); if (!fn || !fn(e, &ret, NULL, nid)) { ENGINEerr(ENGINE_F_ENGINE_GET_PKEY_ASN1_METH, ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD); return NULL; } return ret; } /* Gets the pkey_asn1_meth callback from an ENGINE structure */ ENGINE_PKEY_ASN1_METHS_PTR ENGINE_get_pkey_asn1_meths(const ENGINE *e) { return e->pkey_asn1_meths; } /* Sets the pkey_asn1_meth callback in an ENGINE structure */ int ENGINE_set_pkey_asn1_meths(ENGINE *e, ENGINE_PKEY_ASN1_METHS_PTR f) { e->pkey_asn1_meths = f; return 1; } /* Internal function to free up EVP_PKEY_ASN1_METHOD structures before an * ENGINE is destroyed */ void engine_pkey_asn1_meths_free(ENGINE *e) { int i; EVP_PKEY_ASN1_METHOD *pkm; if (e->pkey_asn1_meths) { const int *pknids; int npknids; npknids = e->pkey_asn1_meths(e, NULL, &pknids, 0); for (i = 0; i < npknids; i++) { if (e->pkey_asn1_meths(e, &pkm, NULL, pknids[i])) { EVP_PKEY_asn1_free(pkm); } } } } /* Find a method based on a string. This does a linear search through * all implemented algorithms. This is OK in practice because only * a small number of algorithms are likely to be implemented in an engine * and it is not used for speed critical operations. */ const EVP_PKEY_ASN1_METHOD * ENGINE_get_pkey_asn1_meth_str(ENGINE *e, const char *str, int len) { int i, nidcount; const int *nids; EVP_PKEY_ASN1_METHOD *ameth; if (!e->pkey_asn1_meths) return NULL; if (len == -1) len = strlen(str); nidcount = e->pkey_asn1_meths(e, NULL, &nids, 0); for (i = 0; i < nidcount; i++) { e->pkey_asn1_meths(e, &ameth, NULL, nids[i]); if (((int)strlen(ameth->pem_str) == len) && !strncasecmp(ameth->pem_str, str, len)) return ameth; } return NULL; } typedef struct { ENGINE *e; const EVP_PKEY_ASN1_METHOD *ameth; const char *str; int len; } ENGINE_FIND_STR; static void look_str_cb(int nid, STACK_OF(ENGINE) *sk, ENGINE *def, void *arg) { ENGINE_FIND_STR *lk = arg; int i; if (lk->ameth) return; for (i = 0; i < sk_ENGINE_num(sk); i++) { ENGINE *e = sk_ENGINE_value(sk, i); EVP_PKEY_ASN1_METHOD *ameth; e->pkey_asn1_meths(e, &ameth, NULL, nid); if (((int)strlen(ameth->pem_str) == lk->len) && !strncasecmp(ameth->pem_str, lk->str, lk->len)) { lk->e = e; lk->ameth = ameth; return; } } } const EVP_PKEY_ASN1_METHOD * ENGINE_pkey_asn1_find_str(ENGINE **pe, const char *str, int len) { ENGINE_FIND_STR fstr; fstr.e = NULL; fstr.ameth = NULL; fstr.str = str; fstr.len = len; CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); engine_table_doall(pkey_asn1_meth_table, look_str_cb, &fstr); /* If found obtain a structural reference to engine */ if (fstr.e) { fstr.e->struct_ref++; engine_ref_debug(fstr.e, 0, 1) } *pe = fstr.e; CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); return fstr.ameth; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/eng_all.c0000644000175000017500000000664412360020705021277 0ustar /* $OpenBSD: eng_all.c,v 1.25 2014/06/12 15:49:29 deraadt Exp $ */ /* Written by Richard Levitte for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include "cryptlib.h" #include "eng_int.h" void ENGINE_load_builtin_engines(void) { /* Some ENGINEs need this */ OPENSSL_cpuid_setup(); #if 0 /* There's no longer any need for an "openssl" ENGINE unless, one day, * it is the *only* way for standard builtin implementations to be be * accessed (ie. it would be possible to statically link binaries with * *no* builtin implementations). */ ENGINE_load_openssl(); #endif #ifndef OPENSSL_NO_RSAX ENGINE_load_rsax(); #endif ENGINE_load_dynamic(); #ifndef OPENSSL_NO_STATIC_ENGINE #ifndef OPENSSL_NO_HW #ifndef OPENSSL_NO_HW_PADLOCK ENGINE_load_padlock(); #endif #endif #endif ENGINE_register_all_complete(); } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/eng_openssl.c0000644000175000017500000002671612360020705022214 0ustar /* $OpenBSD: eng_openssl.c,v 1.8 2014/07/10 22:45:57 jsing Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * ECDH support in OpenSSL originally developed by * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. */ #include #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_DH #include #endif #ifndef OPENSSL_NO_DSA #include #endif #ifndef OPENSSL_NO_RSA #include #endif /* This testing gunk is implemented (and explained) lower down. It also assumes * the application explicitly calls "ENGINE_load_openssl()" because this is no * longer automatic in ENGINE_load_builtin_engines(). */ #define TEST_ENG_OPENSSL_RC4 #define TEST_ENG_OPENSSL_PKEY /* #define TEST_ENG_OPENSSL_RC4_OTHERS */ #define TEST_ENG_OPENSSL_RC4_P_INIT /* #define TEST_ENG_OPENSSL_RC4_P_CIPHER */ #define TEST_ENG_OPENSSL_SHA /* #define TEST_ENG_OPENSSL_SHA_OTHERS */ /* #define TEST_ENG_OPENSSL_SHA_P_INIT */ /* #define TEST_ENG_OPENSSL_SHA_P_UPDATE */ /* #define TEST_ENG_OPENSSL_SHA_P_FINAL */ /* Now check what of those algorithms are actually enabled */ #ifdef OPENSSL_NO_RC4 #undef TEST_ENG_OPENSSL_RC4 #undef TEST_ENG_OPENSSL_RC4_OTHERS #undef TEST_ENG_OPENSSL_RC4_P_INIT #undef TEST_ENG_OPENSSL_RC4_P_CIPHER #endif #if defined(OPENSSL_NO_SHA) || defined(OPENSSL_NO_SHA0) || defined(OPENSSL_NO_SHA1) #undef TEST_ENG_OPENSSL_SHA #undef TEST_ENG_OPENSSL_SHA_OTHERS #undef TEST_ENG_OPENSSL_SHA_P_INIT #undef TEST_ENG_OPENSSL_SHA_P_UPDATE #undef TEST_ENG_OPENSSL_SHA_P_FINAL #endif #ifdef TEST_ENG_OPENSSL_RC4 static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid); #endif #ifdef TEST_ENG_OPENSSL_SHA static int openssl_digests(ENGINE *e, const EVP_MD **digest, const int **nids, int nid); #endif #ifdef TEST_ENG_OPENSSL_PKEY static EVP_PKEY *openssl_load_privkey(ENGINE *eng, const char *key_id, UI_METHOD *ui_method, void *callback_data); #endif /* The constants used when creating the ENGINE */ static const char *engine_openssl_id = "openssl"; static const char *engine_openssl_name = "Software engine support"; /* This internal function is used by ENGINE_openssl() and possibly by the * "dynamic" ENGINE support too */ static int bind_helper(ENGINE *e) { if (!ENGINE_set_id(e, engine_openssl_id) || !ENGINE_set_name(e, engine_openssl_name) #ifndef TEST_ENG_OPENSSL_NO_ALGORITHMS #ifndef OPENSSL_NO_RSA || !ENGINE_set_RSA(e, RSA_get_default_method()) #endif #ifndef OPENSSL_NO_DSA || !ENGINE_set_DSA(e, DSA_get_default_method()) #endif #ifndef OPENSSL_NO_ECDH || !ENGINE_set_ECDH(e, ECDH_OpenSSL()) #endif #ifndef OPENSSL_NO_ECDSA || !ENGINE_set_ECDSA(e, ECDSA_OpenSSL()) #endif #ifndef OPENSSL_NO_DH || !ENGINE_set_DH(e, DH_get_default_method()) #endif || !ENGINE_set_RAND(e, RAND_SSLeay()) #ifdef TEST_ENG_OPENSSL_RC4 || !ENGINE_set_ciphers(e, openssl_ciphers) #endif #ifdef TEST_ENG_OPENSSL_SHA || !ENGINE_set_digests(e, openssl_digests) #endif #endif #ifdef TEST_ENG_OPENSSL_PKEY || !ENGINE_set_load_privkey_function(e, openssl_load_privkey) #endif ) return 0; /* If we add errors to this ENGINE, ensure the error handling is setup here */ /* openssl_load_error_strings(); */ return 1; } static ENGINE * engine_openssl(void) { ENGINE *ret = ENGINE_new(); if (!ret) return NULL; if (!bind_helper(ret)) { ENGINE_free(ret); return NULL; } return ret; } void ENGINE_load_openssl(void) { ENGINE *toadd = engine_openssl(); if (!toadd) return; ENGINE_add(toadd); /* If the "add" worked, it gets a structural reference. So either way, * we release our just-created reference. */ ENGINE_free(toadd); ERR_clear_error(); } /* This stuff is needed if this ENGINE is being compiled into a self-contained * shared-library. */ #ifdef ENGINE_DYNAMIC_SUPPORT static int bind_fn(ENGINE *e, const char *id) { if (id && (strcmp(id, engine_openssl_id) != 0)) return 0; if (!bind_helper(e)) return 0; return 1; } IMPLEMENT_DYNAMIC_CHECK_FN() IMPLEMENT_DYNAMIC_BIND_FN(bind_fn) #endif /* ENGINE_DYNAMIC_SUPPORT */ #ifdef TEST_ENG_OPENSSL_RC4 /* This section of code compiles an "alternative implementation" of two modes of * RC4 into this ENGINE. The result is that EVP_CIPHER operation for "rc4" * should under normal circumstances go via this support rather than the default * EVP support. There are other symbols to tweak the testing; * TEST_ENC_OPENSSL_RC4_OTHERS - print a one line message to stderr each time * we're asked for a cipher we don't support (should not happen). * TEST_ENG_OPENSSL_RC4_P_INIT - print a one line message to stderr each time * the "init_key" handler is called. * TEST_ENG_OPENSSL_RC4_P_CIPHER - ditto for the "cipher" handler. */ #include #define TEST_RC4_KEY_SIZE 16 static int test_cipher_nids[] = {NID_rc4, NID_rc4_40}; static int test_cipher_nids_number = 2; typedef struct { unsigned char key[TEST_RC4_KEY_SIZE]; RC4_KEY ks; } TEST_RC4_KEY; #define test(ctx) ((TEST_RC4_KEY *)(ctx)->cipher_data) static int test_rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { #ifdef TEST_ENG_OPENSSL_RC4_P_INIT fprintf(stderr, "(TEST_ENG_OPENSSL_RC4) test_init_key() called\n"); #endif memcpy(&test(ctx)->key[0], key, EVP_CIPHER_CTX_key_length(ctx)); RC4_set_key(&test(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx), test(ctx)->key); return 1; } static int test_rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) { #ifdef TEST_ENG_OPENSSL_RC4_P_CIPHER fprintf(stderr, "(TEST_ENG_OPENSSL_RC4) test_cipher() called\n"); #endif RC4(&test(ctx)->ks, inl, in, out); return 1; } static const EVP_CIPHER test_r4_cipher = { NID_rc4, 1, TEST_RC4_KEY_SIZE, 0, EVP_CIPH_VARIABLE_LENGTH, test_rc4_init_key, test_rc4_cipher, NULL, sizeof(TEST_RC4_KEY), NULL, NULL, NULL, NULL }; static const EVP_CIPHER test_r4_40_cipher = { NID_rc4_40, 1,5 /* 40 bit */,0, EVP_CIPH_VARIABLE_LENGTH, test_rc4_init_key, test_rc4_cipher, NULL, sizeof(TEST_RC4_KEY), NULL, NULL, NULL, NULL }; static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid) { if (!cipher) { /* We are returning a list of supported nids */ *nids = test_cipher_nids; return test_cipher_nids_number; } /* We are being asked for a specific cipher */ if (nid == NID_rc4) *cipher = &test_r4_cipher; else if (nid == NID_rc4_40) *cipher = &test_r4_40_cipher; else { #ifdef TEST_ENG_OPENSSL_RC4_OTHERS fprintf(stderr, "(TEST_ENG_OPENSSL_RC4) returning NULL for " "nid %d\n", nid); #endif *cipher = NULL; return 0; } return 1; } #endif #ifdef TEST_ENG_OPENSSL_SHA /* Much the same sort of comment as for TEST_ENG_OPENSSL_RC4 */ #include static int test_digest_nids[] = {NID_sha1}; static int test_digest_nids_number = 1; static int test_sha1_init(EVP_MD_CTX *ctx) { #ifdef TEST_ENG_OPENSSL_SHA_P_INIT fprintf(stderr, "(TEST_ENG_OPENSSL_SHA) test_sha1_init() called\n"); #endif return SHA1_Init(ctx->md_data); } static int test_sha1_update(EVP_MD_CTX *ctx, const void *data, size_t count) { #ifdef TEST_ENG_OPENSSL_SHA_P_UPDATE fprintf(stderr, "(TEST_ENG_OPENSSL_SHA) test_sha1_update() called\n"); #endif return SHA1_Update(ctx->md_data, data, count); } static int test_sha1_final(EVP_MD_CTX *ctx, unsigned char *md) { #ifdef TEST_ENG_OPENSSL_SHA_P_FINAL fprintf(stderr, "(TEST_ENG_OPENSSL_SHA) test_sha1_final() called\n"); #endif return SHA1_Final(md, ctx->md_data); } static const EVP_MD test_sha_md = { NID_sha1, NID_sha1WithRSAEncryption, SHA_DIGEST_LENGTH, 0, test_sha1_init, test_sha1_update, test_sha1_final, NULL, NULL, EVP_PKEY_RSA_method, SHA_CBLOCK, sizeof(EVP_MD *) + sizeof(SHA_CTX), }; static int openssl_digests(ENGINE *e, const EVP_MD **digest, const int **nids, int nid) { if (!digest) { /* We are returning a list of supported nids */ *nids = test_digest_nids; return test_digest_nids_number; } /* We are being asked for a specific digest */ if (nid == NID_sha1) *digest = &test_sha_md; else { #ifdef TEST_ENG_OPENSSL_SHA_OTHERS fprintf(stderr, "(TEST_ENG_OPENSSL_SHA) returning NULL for " "nid %d\n", nid); #endif *digest = NULL; return 0; } return 1; } #endif #ifdef TEST_ENG_OPENSSL_PKEY static EVP_PKEY * openssl_load_privkey(ENGINE *eng, const char *key_id, UI_METHOD *ui_method, void *callback_data) { BIO *in; EVP_PKEY *key; fprintf(stderr, "(TEST_ENG_OPENSSL_PKEY)Loading Private key %s\n", key_id); in = BIO_new_file(key_id, "r"); if (!in) return NULL; key = PEM_read_bio_PrivateKey(in, NULL, 0, NULL); BIO_free(in); return key; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/eng_ctrl.c0000644000175000017500000003046312360020705021467 0ustar /* $OpenBSD: eng_ctrl.c,v 1.8 2014/06/12 15:49:29 deraadt Exp $ */ /* ==================================================================== * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include "eng_int.h" /* When querying a ENGINE-specific control command's 'description', this string * is used if the ENGINE_CMD_DEFN has cmd_desc set to NULL. */ static const char *int_no_description = ""; /* These internal functions handle 'CMD'-related control commands when the * ENGINE in question has asked us to take care of it (ie. the ENGINE did not * set the ENGINE_FLAGS_MANUAL_CMD_CTRL flag. */ static int int_ctrl_cmd_is_null(const ENGINE_CMD_DEFN *defn) { if ((defn->cmd_num == 0) || (defn->cmd_name == NULL)) return 1; return 0; } static int int_ctrl_cmd_by_name(const ENGINE_CMD_DEFN *defn, const char *s) { int idx = 0; while (!int_ctrl_cmd_is_null(defn) && (strcmp(defn->cmd_name, s) != 0)) { idx++; defn++; } if (int_ctrl_cmd_is_null(defn)) /* The given name wasn't found */ return -1; return idx; } static int int_ctrl_cmd_by_num(const ENGINE_CMD_DEFN *defn, unsigned int num) { int idx = 0; /* NB: It is stipulated that 'cmd_defn' lists are ordered by cmd_num. So * our searches don't need to take any longer than necessary. */ while (!int_ctrl_cmd_is_null(defn) && (defn->cmd_num < num)) { idx++; defn++; } if (defn->cmd_num == num) return idx; /* The given cmd_num wasn't found */ return -1; } static int int_ctrl_helper(ENGINE *e, int cmd, long i, void *p, void (*f)(void)) { int idx; int ret; char *s = (char *)p; /* Take care of the easy one first (eg. it requires no searches) */ if (cmd == ENGINE_CTRL_GET_FIRST_CMD_TYPE) { if ((e->cmd_defns == NULL) || int_ctrl_cmd_is_null(e->cmd_defns)) return 0; return e->cmd_defns->cmd_num; } /* One or two commands require that "p" be a valid string buffer */ if ((cmd == ENGINE_CTRL_GET_CMD_FROM_NAME) || (cmd == ENGINE_CTRL_GET_NAME_FROM_CMD) || (cmd == ENGINE_CTRL_GET_DESC_FROM_CMD)) { if (s == NULL) { ENGINEerr(ENGINE_F_INT_CTRL_HELPER, ERR_R_PASSED_NULL_PARAMETER); return -1; } } /* Now handle cmd_name -> cmd_num conversion */ if (cmd == ENGINE_CTRL_GET_CMD_FROM_NAME) { if ((e->cmd_defns == NULL) || ((idx = int_ctrl_cmd_by_name(e->cmd_defns, s)) < 0)) { ENGINEerr(ENGINE_F_INT_CTRL_HELPER, ENGINE_R_INVALID_CMD_NAME); return -1; } return e->cmd_defns[idx].cmd_num; } /* For the rest of the commands, the 'long' argument must specify a * valie command number - so we need to conduct a search. */ if ((e->cmd_defns == NULL) || ((idx = int_ctrl_cmd_by_num(e->cmd_defns, (unsigned int)i)) < 0)) { ENGINEerr(ENGINE_F_INT_CTRL_HELPER, ENGINE_R_INVALID_CMD_NUMBER); return -1; } /* Now the logic splits depending on command type */ switch (cmd) { case ENGINE_CTRL_GET_NEXT_CMD_TYPE: idx++; if (int_ctrl_cmd_is_null(e->cmd_defns + idx)) /* end-of-list */ return 0; else return e->cmd_defns[idx].cmd_num; case ENGINE_CTRL_GET_NAME_LEN_FROM_CMD: return strlen(e->cmd_defns[idx].cmd_name); case ENGINE_CTRL_GET_NAME_FROM_CMD: ret = snprintf(s, strlen(e->cmd_defns[idx].cmd_name) + 1, "%s", e->cmd_defns[idx].cmd_name); if (ret >= (strlen(e->cmd_defns[idx].cmd_name) + 1)) ret = -1; return ret; case ENGINE_CTRL_GET_DESC_LEN_FROM_CMD: if (e->cmd_defns[idx].cmd_desc) return strlen(e->cmd_defns[idx].cmd_desc); return strlen(int_no_description); case ENGINE_CTRL_GET_DESC_FROM_CMD: if (e->cmd_defns[idx].cmd_desc) { ret = snprintf(s, strlen(e->cmd_defns[idx].cmd_desc) + 1, "%s", e->cmd_defns[idx].cmd_desc); if (ret >= strlen(e->cmd_defns[idx].cmd_desc) + 1) ret = -1; return ret; } ret = snprintf(s, strlen(int_no_description) + 1, "%s", int_no_description); if (ret >= strlen(int_no_description) + 1) ret = -1; return ret; case ENGINE_CTRL_GET_CMD_FLAGS: return e->cmd_defns[idx].cmd_flags; } /* Shouldn't really be here ... */ ENGINEerr(ENGINE_F_INT_CTRL_HELPER, ENGINE_R_INTERNAL_LIST_ERROR); return -1; } int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)) { int ctrl_exists, ref_exists; if (e == NULL) { ENGINEerr(ENGINE_F_ENGINE_CTRL, ERR_R_PASSED_NULL_PARAMETER); return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); ref_exists = ((e->struct_ref > 0) ? 1 : 0); CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); ctrl_exists = ((e->ctrl == NULL) ? 0 : 1); if (!ref_exists) { ENGINEerr(ENGINE_F_ENGINE_CTRL, ENGINE_R_NO_REFERENCE); return 0; } /* Intercept any "root-level" commands before trying to hand them on to * ctrl() handlers. */ switch (cmd) { case ENGINE_CTRL_HAS_CTRL_FUNCTION: return ctrl_exists; case ENGINE_CTRL_GET_FIRST_CMD_TYPE: case ENGINE_CTRL_GET_NEXT_CMD_TYPE: case ENGINE_CTRL_GET_CMD_FROM_NAME: case ENGINE_CTRL_GET_NAME_LEN_FROM_CMD: case ENGINE_CTRL_GET_NAME_FROM_CMD: case ENGINE_CTRL_GET_DESC_LEN_FROM_CMD: case ENGINE_CTRL_GET_DESC_FROM_CMD: case ENGINE_CTRL_GET_CMD_FLAGS: if (ctrl_exists && !(e->flags & ENGINE_FLAGS_MANUAL_CMD_CTRL)) return int_ctrl_helper(e, cmd, i, p, f); if (!ctrl_exists) { ENGINEerr(ENGINE_F_ENGINE_CTRL, ENGINE_R_NO_CONTROL_FUNCTION); /* For these cmd-related functions, failure is indicated * by a -1 return value (because 0 is used as a valid * return in some places). */ return -1; } default: break; } /* Anything else requires a ctrl() handler to exist. */ if (!ctrl_exists) { ENGINEerr(ENGINE_F_ENGINE_CTRL, ENGINE_R_NO_CONTROL_FUNCTION); return 0; } return e->ctrl(e, cmd, i, p, f); } int ENGINE_cmd_is_executable(ENGINE *e, int cmd) { int flags; if ((flags = ENGINE_ctrl(e, ENGINE_CTRL_GET_CMD_FLAGS, cmd, NULL, NULL)) < 0) { ENGINEerr(ENGINE_F_ENGINE_CMD_IS_EXECUTABLE, ENGINE_R_INVALID_CMD_NUMBER); return 0; } if (!(flags & ENGINE_CMD_FLAG_NO_INPUT) && !(flags & ENGINE_CMD_FLAG_NUMERIC) && !(flags & ENGINE_CMD_FLAG_STRING)) return 0; return 1; } int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, long i, void *p, void (*f)(void), int cmd_optional) { int num; if ((e == NULL) || (cmd_name == NULL)) { ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD, ERR_R_PASSED_NULL_PARAMETER); return 0; } if ((e->ctrl == NULL) || ((num = ENGINE_ctrl(e, ENGINE_CTRL_GET_CMD_FROM_NAME, 0, (void *)cmd_name, NULL)) <= 0)) { /* If the command didn't *have* to be supported, we fake * success. This allows certain settings to be specified for * multiple ENGINEs and only require a change of ENGINE id * (without having to selectively apply settings). Eg. changing * from a hardware device back to the regular software ENGINE * without editing the config file, etc. */ if (cmd_optional) { ERR_clear_error(); return 1; } ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD, ENGINE_R_INVALID_CMD_NAME); return 0; } /* Force the result of the control command to 0 or 1, for the reasons * mentioned before. */ if (ENGINE_ctrl(e, num, i, p, f) > 0) return 1; return 0; } int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, int cmd_optional) { int num, flags; long l; char *ptr; if ((e == NULL) || (cmd_name == NULL)) { ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, ERR_R_PASSED_NULL_PARAMETER); return 0; } if ((e->ctrl == NULL) || ((num = ENGINE_ctrl(e, ENGINE_CTRL_GET_CMD_FROM_NAME, 0, (void *)cmd_name, NULL)) <= 0)) { /* If the command didn't *have* to be supported, we fake * success. This allows certain settings to be specified for * multiple ENGINEs and only require a change of ENGINE id * (without having to selectively apply settings). Eg. changing * from a hardware device back to the regular software ENGINE * without editing the config file, etc. */ if (cmd_optional) { ERR_clear_error(); return 1; } ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, ENGINE_R_INVALID_CMD_NAME); return 0; } if (!ENGINE_cmd_is_executable(e, num)) { ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, ENGINE_R_CMD_NOT_EXECUTABLE); return 0; } if ((flags = ENGINE_ctrl(e, ENGINE_CTRL_GET_CMD_FLAGS, num, NULL, NULL)) < 0) { /* Shouldn't happen, given that ENGINE_cmd_is_executable() * returned success. */ ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, ENGINE_R_INTERNAL_LIST_ERROR); return 0; } /* If the command takes no input, there must be no input. And vice * versa. */ if (flags & ENGINE_CMD_FLAG_NO_INPUT) { if (arg != NULL) { ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, ENGINE_R_COMMAND_TAKES_NO_INPUT); return 0; } /* We deliberately force the result of ENGINE_ctrl() to 0 or 1 * rather than returning it as "return data". This is to ensure * usage of these commands is consistent across applications and * that certain applications don't understand it one way, and * others another. */ if (ENGINE_ctrl(e, num, 0, (void *)arg, NULL) > 0) return 1; return 0; } /* So, we require input */ if (arg == NULL) { ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, ENGINE_R_COMMAND_TAKES_INPUT); return 0; } /* If it takes string input, that's easy */ if (flags & ENGINE_CMD_FLAG_STRING) { /* Same explanation as above */ if (ENGINE_ctrl(e, num, 0, (void *)arg, NULL) > 0) return 1; return 0; } /* If it doesn't take numeric either, then it is unsupported for use in * a config-setting situation, which is what this function is for. This * should never happen though, because ENGINE_cmd_is_executable() was * used. */ if (!(flags & ENGINE_CMD_FLAG_NUMERIC)) { ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, ENGINE_R_INTERNAL_LIST_ERROR); return 0; } l = strtol(arg, &ptr, 10); if ((arg == ptr) || (*ptr != '\0')) { ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER); return 0; } /* Force the result of the control command to 0 or 1, for the reasons * mentioned before. */ if (ENGINE_ctrl(e, num, l, NULL, NULL) > 0) return 1; return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/crypto/engine/eng_err.c0000644000175000017500000002114712360020705021312 0ustar /* $OpenBSD: eng_err.c,v 1.9 2014/06/22 11:33:47 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1999-2010 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes * made to it will be overwritten when the script next updates this file, * only reason strings will be preserved. */ #include #include #include #include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR #define ERR_FUNC(func) ERR_PACK(ERR_LIB_ENGINE,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_ENGINE,0,reason) static ERR_STRING_DATA ENGINE_str_functs[] = { {ERR_FUNC(ENGINE_F_DYNAMIC_CTRL), "DYNAMIC_CTRL"}, {ERR_FUNC(ENGINE_F_DYNAMIC_GET_DATA_CTX), "DYNAMIC_GET_DATA_CTX"}, {ERR_FUNC(ENGINE_F_DYNAMIC_LOAD), "DYNAMIC_LOAD"}, {ERR_FUNC(ENGINE_F_DYNAMIC_SET_DATA_CTX), "DYNAMIC_SET_DATA_CTX"}, {ERR_FUNC(ENGINE_F_ENGINE_ADD), "ENGINE_add"}, {ERR_FUNC(ENGINE_F_ENGINE_BY_ID), "ENGINE_by_id"}, {ERR_FUNC(ENGINE_F_ENGINE_CMD_IS_EXECUTABLE), "ENGINE_cmd_is_executable"}, {ERR_FUNC(ENGINE_F_ENGINE_CTRL), "ENGINE_ctrl"}, {ERR_FUNC(ENGINE_F_ENGINE_CTRL_CMD), "ENGINE_ctrl_cmd"}, {ERR_FUNC(ENGINE_F_ENGINE_CTRL_CMD_STRING), "ENGINE_ctrl_cmd_string"}, {ERR_FUNC(ENGINE_F_ENGINE_FINISH), "ENGINE_finish"}, {ERR_FUNC(ENGINE_F_ENGINE_FREE_UTIL), "ENGINE_FREE_UTIL"}, {ERR_FUNC(ENGINE_F_ENGINE_GET_CIPHER), "ENGINE_get_cipher"}, {ERR_FUNC(ENGINE_F_ENGINE_GET_DEFAULT_TYPE), "ENGINE_GET_DEFAULT_TYPE"}, {ERR_FUNC(ENGINE_F_ENGINE_GET_DIGEST), "ENGINE_get_digest"}, {ERR_FUNC(ENGINE_F_ENGINE_GET_NEXT), "ENGINE_get_next"}, {ERR_FUNC(ENGINE_F_ENGINE_GET_PKEY_ASN1_METH), "ENGINE_get_pkey_asn1_meth"}, {ERR_FUNC(ENGINE_F_ENGINE_GET_PKEY_METH), "ENGINE_get_pkey_meth"}, {ERR_FUNC(ENGINE_F_ENGINE_GET_PREV), "ENGINE_get_prev"}, {ERR_FUNC(ENGINE_F_ENGINE_INIT), "ENGINE_init"}, {ERR_FUNC(ENGINE_F_ENGINE_LIST_ADD), "ENGINE_LIST_ADD"}, {ERR_FUNC(ENGINE_F_ENGINE_LIST_REMOVE), "ENGINE_LIST_REMOVE"}, {ERR_FUNC(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY), "ENGINE_load_private_key"}, {ERR_FUNC(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY), "ENGINE_load_public_key"}, {ERR_FUNC(ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT), "ENGINE_load_ssl_client_cert"}, {ERR_FUNC(ENGINE_F_ENGINE_NEW), "ENGINE_new"}, {ERR_FUNC(ENGINE_F_ENGINE_REMOVE), "ENGINE_remove"}, {ERR_FUNC(ENGINE_F_ENGINE_SET_DEFAULT_STRING), "ENGINE_set_default_string"}, {ERR_FUNC(ENGINE_F_ENGINE_SET_DEFAULT_TYPE), "ENGINE_SET_DEFAULT_TYPE"}, {ERR_FUNC(ENGINE_F_ENGINE_SET_ID), "ENGINE_set_id"}, {ERR_FUNC(ENGINE_F_ENGINE_SET_NAME), "ENGINE_set_name"}, {ERR_FUNC(ENGINE_F_ENGINE_TABLE_REGISTER), "ENGINE_TABLE_REGISTER"}, {ERR_FUNC(ENGINE_F_ENGINE_UNLOAD_KEY), "ENGINE_UNLOAD_KEY"}, {ERR_FUNC(ENGINE_F_ENGINE_UNLOCKED_FINISH), "ENGINE_UNLOCKED_FINISH"}, {ERR_FUNC(ENGINE_F_ENGINE_UP_REF), "ENGINE_up_ref"}, {ERR_FUNC(ENGINE_F_INT_CTRL_HELPER), "INT_CTRL_HELPER"}, {ERR_FUNC(ENGINE_F_INT_ENGINE_CONFIGURE), "INT_ENGINE_CONFIGURE"}, {ERR_FUNC(ENGINE_F_INT_ENGINE_MODULE_INIT), "INT_ENGINE_MODULE_INIT"}, {ERR_FUNC(ENGINE_F_LOG_MESSAGE), "LOG_MESSAGE"}, {0, NULL} }; static ERR_STRING_DATA ENGINE_str_reasons[] = { {ERR_REASON(ENGINE_R_ALREADY_LOADED) , "already loaded"}, {ERR_REASON(ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER), "argument is not a number"}, {ERR_REASON(ENGINE_R_CMD_NOT_EXECUTABLE) , "cmd not executable"}, {ERR_REASON(ENGINE_R_COMMAND_TAKES_INPUT), "command takes input"}, {ERR_REASON(ENGINE_R_COMMAND_TAKES_NO_INPUT), "command takes no input"}, {ERR_REASON(ENGINE_R_CONFLICTING_ENGINE_ID), "conflicting engine id"}, {ERR_REASON(ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED), "ctrl command not implemented"}, {ERR_REASON(ENGINE_R_DH_NOT_IMPLEMENTED) , "dh not implemented"}, {ERR_REASON(ENGINE_R_DSA_NOT_IMPLEMENTED), "dsa not implemented"}, {ERR_REASON(ENGINE_R_DSO_FAILURE) , "DSO failure"}, {ERR_REASON(ENGINE_R_DSO_NOT_FOUND) , "dso not found"}, {ERR_REASON(ENGINE_R_ENGINES_SECTION_ERROR), "engines section error"}, {ERR_REASON(ENGINE_R_ENGINE_CONFIGURATION_ERROR), "engine configuration error"}, {ERR_REASON(ENGINE_R_ENGINE_IS_NOT_IN_LIST), "engine is not in the list"}, {ERR_REASON(ENGINE_R_ENGINE_SECTION_ERROR), "engine section error"}, {ERR_REASON(ENGINE_R_FAILED_LOADING_PRIVATE_KEY), "failed loading private key"}, {ERR_REASON(ENGINE_R_FAILED_LOADING_PUBLIC_KEY), "failed loading public key"}, {ERR_REASON(ENGINE_R_FINISH_FAILED) , "finish failed"}, {ERR_REASON(ENGINE_R_GET_HANDLE_FAILED) , "could not obtain hardware handle"}, {ERR_REASON(ENGINE_R_ID_OR_NAME_MISSING) , "'id' or 'name' missing"}, {ERR_REASON(ENGINE_R_INIT_FAILED) , "init failed"}, {ERR_REASON(ENGINE_R_INTERNAL_LIST_ERROR), "internal list error"}, {ERR_REASON(ENGINE_R_INVALID_ARGUMENT) , "invalid argument"}, {ERR_REASON(ENGINE_R_INVALID_CMD_NAME) , "invalid cmd name"}, {ERR_REASON(ENGINE_R_INVALID_CMD_NUMBER) , "invalid cmd number"}, {ERR_REASON(ENGINE_R_INVALID_INIT_VALUE) , "invalid init value"}, {ERR_REASON(ENGINE_R_INVALID_STRING) , "invalid string"}, {ERR_REASON(ENGINE_R_NOT_INITIALISED) , "not initialised"}, {ERR_REASON(ENGINE_R_NOT_LOADED) , "not loaded"}, {ERR_REASON(ENGINE_R_NO_CONTROL_FUNCTION), "no control function"}, {ERR_REASON(ENGINE_R_NO_INDEX) , "no index"}, {ERR_REASON(ENGINE_R_NO_LOAD_FUNCTION) , "no load function"}, {ERR_REASON(ENGINE_R_NO_REFERENCE) , "no reference"}, {ERR_REASON(ENGINE_R_NO_SUCH_ENGINE) , "no such engine"}, {ERR_REASON(ENGINE_R_NO_UNLOAD_FUNCTION) , "no unload function"}, {ERR_REASON(ENGINE_R_PROVIDE_PARAMETERS) , "provide parameters"}, {ERR_REASON(ENGINE_R_RSA_NOT_IMPLEMENTED), "rsa not implemented"}, {ERR_REASON(ENGINE_R_UNIMPLEMENTED_CIPHER), "unimplemented cipher"}, {ERR_REASON(ENGINE_R_UNIMPLEMENTED_DIGEST), "unimplemented digest"}, {ERR_REASON(ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD), "unimplemented public key method"}, {ERR_REASON(ENGINE_R_VERSION_INCOMPATIBILITY), "version incompatibility"}, {0, NULL} }; #endif void ERR_load_ENGINE_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(ENGINE_str_functs[0].error) == NULL) { ERR_load_strings(0, ENGINE_str_functs); ERR_load_strings(0, ENGINE_str_reasons); } #endif } deps/libressl-pnacl-sys-2.1.6/libressl/Makefile.in0000664000175000017500000006064212437255267017034 0ustar # Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = . DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \ $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) COPYING compile \ config.guess config.sub depcomp install-sh missing ltmain.sh ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ cscope distdir dist dist-all distcheck am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best DIST_TARGETS = dist-gzip distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ NO_ARC4RANDOM_BUF = @NO_ARC4RANDOM_BUF@ NO_GETENTROPY = @NO_GETENTROPY@ NO_ISSETUGID = @NO_ISSETUGID@ NO_REALLOCARRAY = @NO_REALLOCARRAY@ NO_STRLCAT = @NO_STRLCAT@ NO_STRLCPY = @NO_STRLCPY@ NO_STRTONUM = @NO_STRTONUM@ NO_TIMINGSAFE_BCMP = @NO_TIMINGSAFE_BCMP@ NO_TIMINGSAFE_MEMCMP = @NO_TIMINGSAFE_MEMCMP@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PLATFORM_LDADD = @PLATFORM_LDADD@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ USER_CFLAGS = @USER_CFLAGS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = crypto ssl include apps tests man ACLOCAL_AMFLAGS = -I m4 all: all-recursive .SUFFIXES: am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool config.lt # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-libtool \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--refresh check check-am clean clean-cscope clean-generic \ clean-libtool cscope cscopelist-am ctags ctags-am dist \ dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \ dist-xz dist-zip distcheck distclean distclean-generic \ distclean-libtool distclean-tags distcleancheck distdir \ distuninstallcheck dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: deps/libressl-pnacl-sys-2.1.6/libressl/NEWS0000644000175000017500000000000012357514212015427 0ustar deps/libressl-pnacl-sys-2.1.6/libressl/ChangeLog0000644000175000017500000000003412360020705016502 0ustar Please see OpenBSD CVS logs deps/libressl-pnacl-sys-2.1.6/libressl/tests/0000755000000000000000000000000012666635521017674 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/tests/ectest.c0000644000175000017500000013041512360020706017535 0ustar /* crypto/ec/ectest.c */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * Portions of the attached software ("Contribution") are developed by * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. * * The Contribution is licensed pursuant to the OpenSSL open source * license provided above. * * The elliptic curve binary polynomial software is originally written by * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. * */ #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif #include #include #include #include #include #include #define ABORT do { \ fflush(stdout); \ fprintf(stderr, "%s:%d: ABORT\n", __FILE__, __LINE__); \ ERR_print_errors_fp(stderr); \ exit(1); \ } while (0) #define TIMING_BASE_PT 0 #define TIMING_RAND_PT 1 #define TIMING_SIMUL 2 /* test multiplication with group order, long and negative scalars */ static void group_order_tests(EC_GROUP *group) { BIGNUM *n1, *n2, *order; EC_POINT *P = EC_POINT_new(group); EC_POINT *Q = EC_POINT_new(group); BN_CTX *ctx = BN_CTX_new(); n1 = BN_new(); n2 = BN_new(); order = BN_new(); fprintf(stdout, "verify group order ..."); fflush(stdout); if (!EC_GROUP_get_order(group, order, ctx)) ABORT; if (!EC_POINT_mul(group, Q, order, NULL, NULL, ctx)) ABORT; if (!EC_POINT_is_at_infinity(group, Q)) ABORT; fprintf(stdout, "."); fflush(stdout); if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; if (!EC_POINT_mul(group, Q, order, NULL, NULL, ctx)) ABORT; if (!EC_POINT_is_at_infinity(group, Q)) ABORT; fprintf(stdout, " ok\n"); fprintf(stdout, "long/negative scalar tests ... "); if (!BN_one(n1)) ABORT; /* n1 = 1 - order */ if (!BN_sub(n1, n1, order)) ABORT; if(!EC_POINT_mul(group, Q, NULL, P, n1, ctx)) ABORT; if (0 != EC_POINT_cmp(group, Q, P, ctx)) ABORT; /* n2 = 1 + order */ if (!BN_add(n2, order, BN_value_one())) ABORT; if(!EC_POINT_mul(group, Q, NULL, P, n2, ctx)) ABORT; if (0 != EC_POINT_cmp(group, Q, P, ctx)) ABORT; /* n2 = (1 - order) * (1 + order) */ if (!BN_mul(n2, n1, n2, ctx)) ABORT; if(!EC_POINT_mul(group, Q, NULL, P, n2, ctx)) ABORT; if (0 != EC_POINT_cmp(group, Q, P, ctx)) ABORT; fprintf(stdout, "ok\n"); EC_POINT_free(P); EC_POINT_free(Q); BN_free(n1); BN_free(n2); BN_free(order); BN_CTX_free(ctx); } static void prime_field_tests(void) { BN_CTX *ctx = NULL; BIGNUM *p, *a, *b; EC_GROUP *group; EC_GROUP *P_160 = NULL, *P_192 = NULL, *P_224 = NULL, *P_256 = NULL, *P_384 = NULL, *P_521 = NULL; EC_POINT *P, *Q, *R; BIGNUM *x, *y, *z; unsigned char buf[100]; size_t i, len; int k; #if 1 /* optional */ ctx = BN_CTX_new(); if (!ctx) ABORT; #endif p = BN_new(); a = BN_new(); b = BN_new(); if (!p || !a || !b) ABORT; if (!BN_hex2bn(&p, "17")) ABORT; if (!BN_hex2bn(&a, "1")) ABORT; if (!BN_hex2bn(&b, "1")) ABORT; group = EC_GROUP_new(EC_GFp_mont_method()); /* applications should use EC_GROUP_new_curve_GFp * so that the library gets to choose the EC_METHOD */ if (!group) ABORT; if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT; { EC_GROUP *tmp; tmp = EC_GROUP_new(EC_GROUP_method_of(group)); if (!tmp) ABORT; if (!EC_GROUP_copy(tmp, group)) ABORT; EC_GROUP_free(group); group = tmp; } if (!EC_GROUP_get_curve_GFp(group, p, a, b, ctx)) ABORT; fprintf(stdout, "Curve defined by Weierstrass equation\n y^2 = x^3 + a*x + b (mod 0x"); BN_print_fp(stdout, p); fprintf(stdout, ")\n a = 0x"); BN_print_fp(stdout, a); fprintf(stdout, "\n b = 0x"); BN_print_fp(stdout, b); fprintf(stdout, "\n"); P = EC_POINT_new(group); Q = EC_POINT_new(group); R = EC_POINT_new(group); if (!P || !Q || !R) ABORT; if (!EC_POINT_set_to_infinity(group, P)) ABORT; if (!EC_POINT_is_at_infinity(group, P)) ABORT; buf[0] = 0; if (!EC_POINT_oct2point(group, Q, buf, 1, ctx)) ABORT; if (!EC_POINT_add(group, P, P, Q, ctx)) ABORT; if (!EC_POINT_is_at_infinity(group, P)) ABORT; x = BN_new(); y = BN_new(); z = BN_new(); if (!x || !y || !z) ABORT; if (!BN_hex2bn(&x, "D")) ABORT; if (!EC_POINT_set_compressed_coordinates_GFp(group, Q, x, 1, ctx)) ABORT; if (!EC_POINT_is_on_curve(group, Q, ctx)) { if (!EC_POINT_get_affine_coordinates_GFp(group, Q, x, y, ctx)) ABORT; fprintf(stderr, "Point is not on curve: x = 0x"); BN_print_fp(stderr, x); fprintf(stderr, ", y = 0x"); BN_print_fp(stderr, y); fprintf(stderr, "\n"); ABORT; } fprintf(stdout, "A cyclic subgroup:\n"); k = 100; do { if (k-- == 0) ABORT; if (EC_POINT_is_at_infinity(group, P)) fprintf(stdout, " point at infinity\n"); else { if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT; fprintf(stdout, " x = 0x"); BN_print_fp(stdout, x); fprintf(stdout, ", y = 0x"); BN_print_fp(stdout, y); fprintf(stdout, "\n"); } if (!EC_POINT_copy(R, P)) ABORT; if (!EC_POINT_add(group, P, P, Q, ctx)) ABORT; #if 0 /* optional */ { EC_POINT *points[3]; points[0] = R; points[1] = Q; points[2] = P; if (!EC_POINTs_make_affine(group, 2, points, ctx)) ABORT; } #endif } while (!EC_POINT_is_at_infinity(group, P)); if (!EC_POINT_add(group, P, Q, R, ctx)) ABORT; if (!EC_POINT_is_at_infinity(group, P)) ABORT; len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_COMPRESSED, buf, sizeof buf, ctx); if (len == 0) ABORT; if (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT; if (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT; fprintf(stdout, "Generator as octet string, compressed form:\n "); for (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]); len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_UNCOMPRESSED, buf, sizeof buf, ctx); if (len == 0) ABORT; if (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT; if (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT; fprintf(stdout, "\nGenerator as octet string, uncompressed form:\n "); for (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]); len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof buf, ctx); if (len == 0) ABORT; if (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT; if (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT; fprintf(stdout, "\nGenerator as octet string, hybrid form:\n "); for (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]); if (!EC_POINT_get_Jprojective_coordinates_GFp(group, R, x, y, z, ctx)) ABORT; fprintf(stdout, "\nA representation of the inverse of that generator in\nJacobian projective coordinates:\n X = 0x"); BN_print_fp(stdout, x); fprintf(stdout, ", Y = 0x"); BN_print_fp(stdout, y); fprintf(stdout, ", Z = 0x"); BN_print_fp(stdout, z); fprintf(stdout, "\n"); if (!EC_POINT_invert(group, P, ctx)) ABORT; if (0 != EC_POINT_cmp(group, P, R, ctx)) ABORT; /* Curve secp160r1 (Certicom Research SEC 2 Version 1.0, section 2.4.2, 2000) * -- not a NIST curve, but commonly used */ if (!BN_hex2bn(&p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF")) ABORT; if (1 != BN_is_prime_ex(p, BN_prime_checks, ctx, NULL)) ABORT; if (!BN_hex2bn(&a, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC")) ABORT; if (!BN_hex2bn(&b, "1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45")) ABORT; if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT; if (!BN_hex2bn(&x, "4A96B5688EF573284664698968C38BB913CBFC82")) ABORT; if (!BN_hex2bn(&y, "23a628553168947d59dcc912042351377ac5fb32")) ABORT; if (!EC_POINT_set_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT; if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT; if (!BN_hex2bn(&z, "0100000000000000000001F4C8F927AED3CA752257")) ABORT; if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT; if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT; fprintf(stdout, "\nSEC2 curve secp160r1 -- Generator:\n x = 0x"); BN_print_fp(stdout, x); fprintf(stdout, "\n y = 0x"); BN_print_fp(stdout, y); fprintf(stdout, "\n"); /* G_y value taken from the standard: */ if (!BN_hex2bn(&z, "23a628553168947d59dcc912042351377ac5fb32")) ABORT; if (0 != BN_cmp(y, z)) ABORT; fprintf(stdout, "verify degree ..."); if (EC_GROUP_get_degree(group) != 160) ABORT; fprintf(stdout, " ok\n"); group_order_tests(group); if (!(P_160 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; if (!EC_GROUP_copy(P_160, group)) ABORT; /* Curve P-192 (FIPS PUB 186-2, App. 6) */ if (!BN_hex2bn(&p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF")) ABORT; if (1 != BN_is_prime_ex(p, BN_prime_checks, ctx, NULL)) ABORT; if (!BN_hex2bn(&a, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC")) ABORT; if (!BN_hex2bn(&b, "64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1")) ABORT; if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT; if (!BN_hex2bn(&x, "188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012")) ABORT; if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, ctx)) ABORT; if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT; if (!BN_hex2bn(&z, "FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831")) ABORT; if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT; if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT; fprintf(stdout, "\nNIST curve P-192 -- Generator:\n x = 0x"); BN_print_fp(stdout, x); fprintf(stdout, "\n y = 0x"); BN_print_fp(stdout, y); fprintf(stdout, "\n"); /* G_y value taken from the standard: */ if (!BN_hex2bn(&z, "07192B95FFC8DA78631011ED6B24CDD573F977A11E794811")) ABORT; if (0 != BN_cmp(y, z)) ABORT; fprintf(stdout, "verify degree ..."); if (EC_GROUP_get_degree(group) != 192) ABORT; fprintf(stdout, " ok\n"); group_order_tests(group); if (!(P_192 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; if (!EC_GROUP_copy(P_192, group)) ABORT; /* Curve P-224 (FIPS PUB 186-2, App. 6) */ if (!BN_hex2bn(&p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001")) ABORT; if (1 != BN_is_prime_ex(p, BN_prime_checks, ctx, NULL)) ABORT; if (!BN_hex2bn(&a, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE")) ABORT; if (!BN_hex2bn(&b, "B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4")) ABORT; if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT; if (!BN_hex2bn(&x, "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21")) ABORT; if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 0, ctx)) ABORT; if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT; if (!BN_hex2bn(&z, "FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D")) ABORT; if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT; if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT; fprintf(stdout, "\nNIST curve P-224 -- Generator:\n x = 0x"); BN_print_fp(stdout, x); fprintf(stdout, "\n y = 0x"); BN_print_fp(stdout, y); fprintf(stdout, "\n"); /* G_y value taken from the standard: */ if (!BN_hex2bn(&z, "BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34")) ABORT; if (0 != BN_cmp(y, z)) ABORT; fprintf(stdout, "verify degree ..."); if (EC_GROUP_get_degree(group) != 224) ABORT; fprintf(stdout, " ok\n"); group_order_tests(group); if (!(P_224 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; if (!EC_GROUP_copy(P_224, group)) ABORT; /* Curve P-256 (FIPS PUB 186-2, App. 6) */ if (!BN_hex2bn(&p, "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF")) ABORT; if (1 != BN_is_prime_ex(p, BN_prime_checks, ctx, NULL)) ABORT; if (!BN_hex2bn(&a, "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC")) ABORT; if (!BN_hex2bn(&b, "5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B")) ABORT; if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT; if (!BN_hex2bn(&x, "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296")) ABORT; if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, ctx)) ABORT; if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT; if (!BN_hex2bn(&z, "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E" "84F3B9CAC2FC632551")) ABORT; if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT; if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT; fprintf(stdout, "\nNIST curve P-256 -- Generator:\n x = 0x"); BN_print_fp(stdout, x); fprintf(stdout, "\n y = 0x"); BN_print_fp(stdout, y); fprintf(stdout, "\n"); /* G_y value taken from the standard: */ if (!BN_hex2bn(&z, "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5")) ABORT; if (0 != BN_cmp(y, z)) ABORT; fprintf(stdout, "verify degree ..."); if (EC_GROUP_get_degree(group) != 256) ABORT; fprintf(stdout, " ok\n"); group_order_tests(group); if (!(P_256 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; if (!EC_GROUP_copy(P_256, group)) ABORT; /* Curve P-384 (FIPS PUB 186-2, App. 6) */ if (!BN_hex2bn(&p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" "FFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF")) ABORT; if (1 != BN_is_prime_ex(p, BN_prime_checks, ctx, NULL)) ABORT; if (!BN_hex2bn(&a, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" "FFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC")) ABORT; if (!BN_hex2bn(&b, "B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141" "120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF")) ABORT; if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT; if (!BN_hex2bn(&x, "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B" "9859F741E082542A385502F25DBF55296C3A545E3872760AB7")) ABORT; if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, ctx)) ABORT; if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT; if (!BN_hex2bn(&z, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" "FFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973")) ABORT; if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT; if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT; fprintf(stdout, "\nNIST curve P-384 -- Generator:\n x = 0x"); BN_print_fp(stdout, x); fprintf(stdout, "\n y = 0x"); BN_print_fp(stdout, y); fprintf(stdout, "\n"); /* G_y value taken from the standard: */ if (!BN_hex2bn(&z, "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A14" "7CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F")) ABORT; if (0 != BN_cmp(y, z)) ABORT; fprintf(stdout, "verify degree ..."); if (EC_GROUP_get_degree(group) != 384) ABORT; fprintf(stdout, " ok\n"); group_order_tests(group); if (!(P_384 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; if (!EC_GROUP_copy(P_384, group)) ABORT; /* Curve P-521 (FIPS PUB 186-2, App. 6) */ if (!BN_hex2bn(&p, "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" "FFFFFFFFFFFFFFFFFFFFFFFFFFFF")) ABORT; if (1 != BN_is_prime_ex(p, BN_prime_checks, ctx, NULL)) ABORT; if (!BN_hex2bn(&a, "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" "FFFFFFFFFFFFFFFFFFFFFFFFFFFC")) ABORT; if (!BN_hex2bn(&b, "051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B" "315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573" "DF883D2C34F1EF451FD46B503F00")) ABORT; if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT; if (!BN_hex2bn(&x, "C6858E06B70404E9CD9E3ECB662395B4429C648139053F" "B521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B" "3C1856A429BF97E7E31C2E5BD66")) ABORT; if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 0, ctx)) ABORT; if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT; if (!BN_hex2bn(&z, "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" "FFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5" "C9B8899C47AEBB6FB71E91386409")) ABORT; if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT; if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT; fprintf(stdout, "\nNIST curve P-521 -- Generator:\n x = 0x"); BN_print_fp(stdout, x); fprintf(stdout, "\n y = 0x"); BN_print_fp(stdout, y); fprintf(stdout, "\n"); /* G_y value taken from the standard: */ if (!BN_hex2bn(&z, "11839296A789A3BC0045C8A5FB42C7D1BD998F54449579" "B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C" "7086A272C24088BE94769FD16650")) ABORT; if (0 != BN_cmp(y, z)) ABORT; fprintf(stdout, "verify degree ..."); if (EC_GROUP_get_degree(group) != 521) ABORT; fprintf(stdout, " ok\n"); group_order_tests(group); if (!(P_521 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; if (!EC_GROUP_copy(P_521, group)) ABORT; /* more tests using the last curve */ if (!EC_POINT_copy(Q, P)) ABORT; if (EC_POINT_is_at_infinity(group, Q)) ABORT; if (!EC_POINT_dbl(group, P, P, ctx)) ABORT; if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT; if (!EC_POINT_invert(group, Q, ctx)) ABORT; /* P = -2Q */ if (!EC_POINT_add(group, R, P, Q, ctx)) ABORT; if (!EC_POINT_add(group, R, R, Q, ctx)) ABORT; if (!EC_POINT_is_at_infinity(group, R)) ABORT; /* R = P + 2Q */ { const EC_POINT *points[4]; const BIGNUM *scalars[4]; BIGNUM scalar3; if (EC_POINT_is_at_infinity(group, Q)) ABORT; points[0] = Q; points[1] = Q; points[2] = Q; points[3] = Q; if (!EC_GROUP_get_order(group, z, ctx)) ABORT; if (!BN_add(y, z, BN_value_one())) ABORT; if (BN_is_odd(y)) ABORT; if (!BN_rshift1(y, y)) ABORT; scalars[0] = y; /* (group order + 1)/2, so y*Q + y*Q = Q */ scalars[1] = y; fprintf(stdout, "combined multiplication ..."); fflush(stdout); /* z is still the group order */ if (!EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx)) ABORT; if (!EC_POINTs_mul(group, R, z, 2, points, scalars, ctx)) ABORT; if (0 != EC_POINT_cmp(group, P, R, ctx)) ABORT; if (0 != EC_POINT_cmp(group, R, Q, ctx)) ABORT; fprintf(stdout, "."); fflush(stdout); if (!BN_pseudo_rand(y, BN_num_bits(y), 0, 0)) ABORT; if (!BN_add(z, z, y)) ABORT; BN_set_negative(z, 1); scalars[0] = y; scalars[1] = z; /* z = -(order + y) */ if (!EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx)) ABORT; if (!EC_POINT_is_at_infinity(group, P)) ABORT; fprintf(stdout, "."); fflush(stdout); if (!BN_pseudo_rand(x, BN_num_bits(y) - 1, 0, 0)) ABORT; if (!BN_add(z, x, y)) ABORT; BN_set_negative(z, 1); scalars[0] = x; scalars[1] = y; scalars[2] = z; /* z = -(x+y) */ BN_init(&scalar3); BN_zero(&scalar3); scalars[3] = &scalar3; if (!EC_POINTs_mul(group, P, NULL, 4, points, scalars, ctx)) ABORT; if (!EC_POINT_is_at_infinity(group, P)) ABORT; fprintf(stdout, " ok\n\n"); BN_free(&scalar3); } if (ctx) BN_CTX_free(ctx); BN_free(p); BN_free(a); BN_free(b); EC_GROUP_free(group); EC_POINT_free(P); EC_POINT_free(Q); EC_POINT_free(R); BN_free(x); BN_free(y); BN_free(z); if (P_160) EC_GROUP_free(P_160); if (P_192) EC_GROUP_free(P_192); if (P_224) EC_GROUP_free(P_224); if (P_256) EC_GROUP_free(P_256); if (P_384) EC_GROUP_free(P_384); if (P_521) EC_GROUP_free(P_521); } /* Change test based on whether binary point compression is enabled or not. */ #ifdef OPENSSL_EC_BIN_PT_COMP #define CHAR2_CURVE_TEST_INTERNAL(_name, _p, _a, _b, _x, _y, _y_bit, _order, _cof, _degree, _variable) \ if (!BN_hex2bn(&x, _x)) ABORT; \ if (!EC_POINT_set_compressed_coordinates_GF2m(group, P, x, _y_bit, ctx)) ABORT; \ if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT; \ if (!BN_hex2bn(&z, _order)) ABORT; \ if (!BN_hex2bn(&cof, _cof)) ABORT; \ if (!EC_GROUP_set_generator(group, P, z, cof)) ABORT; \ if (!EC_POINT_get_affine_coordinates_GF2m(group, P, x, y, ctx)) ABORT; \ fprintf(stdout, "\n%s -- Generator:\n x = 0x", _name); \ BN_print_fp(stdout, x); \ fprintf(stdout, "\n y = 0x"); \ BN_print_fp(stdout, y); \ fprintf(stdout, "\n"); \ /* G_y value taken from the standard: */ \ if (!BN_hex2bn(&z, _y)) ABORT; \ if (0 != BN_cmp(y, z)) ABORT; #else #define CHAR2_CURVE_TEST_INTERNAL(_name, _p, _a, _b, _x, _y, _y_bit, _order, _cof, _degree, _variable) \ if (!BN_hex2bn(&x, _x)) ABORT; \ if (!BN_hex2bn(&y, _y)) ABORT; \ if (!EC_POINT_set_affine_coordinates_GF2m(group, P, x, y, ctx)) ABORT; \ if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT; \ if (!BN_hex2bn(&z, _order)) ABORT; \ if (!BN_hex2bn(&cof, _cof)) ABORT; \ if (!EC_GROUP_set_generator(group, P, z, cof)) ABORT; \ fprintf(stdout, "\n%s -- Generator:\n x = 0x", _name); \ BN_print_fp(stdout, x); \ fprintf(stdout, "\n y = 0x"); \ BN_print_fp(stdout, y); \ fprintf(stdout, "\n"); #endif #define CHAR2_CURVE_TEST(_name, _p, _a, _b, _x, _y, _y_bit, _order, _cof, _degree, _variable) \ if (!BN_hex2bn(&p, _p)) ABORT; \ if (!BN_hex2bn(&a, _a)) ABORT; \ if (!BN_hex2bn(&b, _b)) ABORT; \ if (!EC_GROUP_set_curve_GF2m(group, p, a, b, ctx)) ABORT; \ CHAR2_CURVE_TEST_INTERNAL(_name, _p, _a, _b, _x, _y, _y_bit, _order, _cof, _degree, _variable) \ fprintf(stdout, "verify degree ..."); \ if (EC_GROUP_get_degree(group) != _degree) ABORT; \ fprintf(stdout, " ok\n"); \ group_order_tests(group); \ if (!(_variable = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; \ if (!EC_GROUP_copy(_variable, group)) ABORT; \ #ifndef OPENSSL_NO_EC2M static void char2_field_tests(void) { BN_CTX *ctx = NULL; BIGNUM *p, *a, *b; EC_GROUP *group; EC_GROUP *C2_K163 = NULL, *C2_K233 = NULL, *C2_K283 = NULL, *C2_K409 = NULL, *C2_K571 = NULL; EC_GROUP *C2_B163 = NULL, *C2_B233 = NULL, *C2_B283 = NULL, *C2_B409 = NULL, *C2_B571 = NULL; EC_POINT *P, *Q, *R; BIGNUM *x, *y, *z, *cof; unsigned char buf[100]; size_t i, len; int k; #if 1 /* optional */ ctx = BN_CTX_new(); if (!ctx) ABORT; #endif p = BN_new(); a = BN_new(); b = BN_new(); if (!p || !a || !b) ABORT; if (!BN_hex2bn(&p, "13")) ABORT; if (!BN_hex2bn(&a, "3")) ABORT; if (!BN_hex2bn(&b, "1")) ABORT; group = EC_GROUP_new(EC_GF2m_simple_method()); /* applications should use EC_GROUP_new_curve_GF2m * so that the library gets to choose the EC_METHOD */ if (!group) ABORT; if (!EC_GROUP_set_curve_GF2m(group, p, a, b, ctx)) ABORT; { EC_GROUP *tmp; tmp = EC_GROUP_new(EC_GROUP_method_of(group)); if (!tmp) ABORT; if (!EC_GROUP_copy(tmp, group)) ABORT; EC_GROUP_free(group); group = tmp; } if (!EC_GROUP_get_curve_GF2m(group, p, a, b, ctx)) ABORT; fprintf(stdout, "Curve defined by Weierstrass equation\n y^2 + x*y = x^3 + a*x^2 + b (mod 0x"); BN_print_fp(stdout, p); fprintf(stdout, ")\n a = 0x"); BN_print_fp(stdout, a); fprintf(stdout, "\n b = 0x"); BN_print_fp(stdout, b); fprintf(stdout, "\n(0x... means binary polynomial)\n"); P = EC_POINT_new(group); Q = EC_POINT_new(group); R = EC_POINT_new(group); if (!P || !Q || !R) ABORT; if (!EC_POINT_set_to_infinity(group, P)) ABORT; if (!EC_POINT_is_at_infinity(group, P)) ABORT; buf[0] = 0; if (!EC_POINT_oct2point(group, Q, buf, 1, ctx)) ABORT; if (!EC_POINT_add(group, P, P, Q, ctx)) ABORT; if (!EC_POINT_is_at_infinity(group, P)) ABORT; x = BN_new(); y = BN_new(); z = BN_new(); cof = BN_new(); if (!x || !y || !z || !cof) ABORT; if (!BN_hex2bn(&x, "6")) ABORT; /* Change test based on whether binary point compression is enabled or not. */ #ifdef OPENSSL_EC_BIN_PT_COMP if (!EC_POINT_set_compressed_coordinates_GF2m(group, Q, x, 1, ctx)) ABORT; #else if (!BN_hex2bn(&y, "8")) ABORT; if (!EC_POINT_set_affine_coordinates_GF2m(group, Q, x, y, ctx)) ABORT; #endif if (!EC_POINT_is_on_curve(group, Q, ctx)) { /* Change test based on whether binary point compression is enabled or not. */ #ifdef OPENSSL_EC_BIN_PT_COMP if (!EC_POINT_get_affine_coordinates_GF2m(group, Q, x, y, ctx)) ABORT; #endif fprintf(stderr, "Point is not on curve: x = 0x"); BN_print_fp(stderr, x); fprintf(stderr, ", y = 0x"); BN_print_fp(stderr, y); fprintf(stderr, "\n"); ABORT; } fprintf(stdout, "A cyclic subgroup:\n"); k = 100; do { if (k-- == 0) ABORT; if (EC_POINT_is_at_infinity(group, P)) fprintf(stdout, " point at infinity\n"); else { if (!EC_POINT_get_affine_coordinates_GF2m(group, P, x, y, ctx)) ABORT; fprintf(stdout, " x = 0x"); BN_print_fp(stdout, x); fprintf(stdout, ", y = 0x"); BN_print_fp(stdout, y); fprintf(stdout, "\n"); } if (!EC_POINT_copy(R, P)) ABORT; if (!EC_POINT_add(group, P, P, Q, ctx)) ABORT; } while (!EC_POINT_is_at_infinity(group, P)); if (!EC_POINT_add(group, P, Q, R, ctx)) ABORT; if (!EC_POINT_is_at_infinity(group, P)) ABORT; /* Change test based on whether binary point compression is enabled or not. */ #ifdef OPENSSL_EC_BIN_PT_COMP len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_COMPRESSED, buf, sizeof buf, ctx); if (len == 0) ABORT; if (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT; if (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT; fprintf(stdout, "Generator as octet string, compressed form:\n "); for (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]); #endif len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_UNCOMPRESSED, buf, sizeof buf, ctx); if (len == 0) ABORT; if (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT; if (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT; fprintf(stdout, "\nGenerator as octet string, uncompressed form:\n "); for (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]); /* Change test based on whether binary point compression is enabled or not. */ #ifdef OPENSSL_EC_BIN_PT_COMP len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof buf, ctx); if (len == 0) ABORT; if (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT; if (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT; fprintf(stdout, "\nGenerator as octet string, hybrid form:\n "); for (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]); #endif fprintf(stdout, "\n"); if (!EC_POINT_invert(group, P, ctx)) ABORT; if (0 != EC_POINT_cmp(group, P, R, ctx)) ABORT; /* Curve K-163 (FIPS PUB 186-2, App. 6) */ CHAR2_CURVE_TEST ( "NIST curve K-163", "0800000000000000000000000000000000000000C9", "1", "1", "02FE13C0537BBC11ACAA07D793DE4E6D5E5C94EEE8", "0289070FB05D38FF58321F2E800536D538CCDAA3D9", 1, "04000000000000000000020108A2E0CC0D99F8A5EF", "2", 163, C2_K163 ); /* Curve B-163 (FIPS PUB 186-2, App. 6) */ CHAR2_CURVE_TEST ( "NIST curve B-163", "0800000000000000000000000000000000000000C9", "1", "020A601907B8C953CA1481EB10512F78744A3205FD", "03F0EBA16286A2D57EA0991168D4994637E8343E36", "00D51FBC6C71A0094FA2CDD545B11C5C0C797324F1", 1, "040000000000000000000292FE77E70C12A4234C33", "2", 163, C2_B163 ); /* Curve K-233 (FIPS PUB 186-2, App. 6) */ CHAR2_CURVE_TEST ( "NIST curve K-233", "020000000000000000000000000000000000000004000000000000000001", "0", "1", "017232BA853A7E731AF129F22FF4149563A419C26BF50A4C9D6EEFAD6126", "01DB537DECE819B7F70F555A67C427A8CD9BF18AEB9B56E0C11056FAE6A3", 0, "008000000000000000000000000000069D5BB915BCD46EFB1AD5F173ABDF", "4", 233, C2_K233 ); /* Curve B-233 (FIPS PUB 186-2, App. 6) */ CHAR2_CURVE_TEST ( "NIST curve B-233", "020000000000000000000000000000000000000004000000000000000001", "000000000000000000000000000000000000000000000000000000000001", "0066647EDE6C332C7F8C0923BB58213B333B20E9CE4281FE115F7D8F90AD", "00FAC9DFCBAC8313BB2139F1BB755FEF65BC391F8B36F8F8EB7371FD558B", "01006A08A41903350678E58528BEBF8A0BEFF867A7CA36716F7E01F81052", 1, "01000000000000000000000000000013E974E72F8A6922031D2603CFE0D7", "2", 233, C2_B233 ); /* Curve K-283 (FIPS PUB 186-2, App. 6) */ CHAR2_CURVE_TEST ( "NIST curve K-283", "0800000000000000000000000000000000000000000000000000000000000000000010A1", "0", "1", "0503213F78CA44883F1A3B8162F188E553CD265F23C1567A16876913B0C2AC2458492836", "01CCDA380F1C9E318D90F95D07E5426FE87E45C0E8184698E45962364E34116177DD2259", 0, "01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE9AE2ED07577265DFF7F94451E061E163C61", "4", 283, C2_K283 ); /* Curve B-283 (FIPS PUB 186-2, App. 6) */ CHAR2_CURVE_TEST ( "NIST curve B-283", "0800000000000000000000000000000000000000000000000000000000000000000010A1", "000000000000000000000000000000000000000000000000000000000000000000000001", "027B680AC8B8596DA5A4AF8A19A0303FCA97FD7645309FA2A581485AF6263E313B79A2F5", "05F939258DB7DD90E1934F8C70B0DFEC2EED25B8557EAC9C80E2E198F8CDBECD86B12053", "03676854FE24141CB98FE6D4B20D02B4516FF702350EDDB0826779C813F0DF45BE8112F4", 1, "03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF90399660FC938A90165B042A7CEFADB307", "2", 283, C2_B283 ); /* Curve K-409 (FIPS PUB 186-2, App. 6) */ CHAR2_CURVE_TEST ( "NIST curve K-409", "02000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001", "0", "1", "0060F05F658F49C1AD3AB1890F7184210EFD0987E307C84C27ACCFB8F9F67CC2C460189EB5AAAA62EE222EB1B35540CFE9023746", "01E369050B7C4E42ACBA1DACBF04299C3460782F918EA427E6325165E9EA10E3DA5F6C42E9C55215AA9CA27A5863EC48D8E0286B", 1, "007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE5F83B2D4EA20400EC4557D5ED3E3E7CA5B4B5C83B8E01E5FCF", "4", 409, C2_K409 ); /* Curve B-409 (FIPS PUB 186-2, App. 6) */ CHAR2_CURVE_TEST ( "NIST curve B-409", "02000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001", "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", "0021A5C2C8EE9FEB5C4B9A753B7B476B7FD6422EF1F3DD674761FA99D6AC27C8A9A197B272822F6CD57A55AA4F50AE317B13545F", "015D4860D088DDB3496B0C6064756260441CDE4AF1771D4DB01FFE5B34E59703DC255A868A1180515603AEAB60794E54BB7996A7", "0061B1CFAB6BE5F32BBFA78324ED106A7636B9C5A7BD198D0158AA4F5488D08F38514F1FDF4B4F40D2181B3681C364BA0273C706", 1, "010000000000000000000000000000000000000000000000000001E2AAD6A612F33307BE5FA47C3C9E052F838164CD37D9A21173", "2", 409, C2_B409 ); /* Curve K-571 (FIPS PUB 186-2, App. 6) */ CHAR2_CURVE_TEST ( "NIST curve K-571", "80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425", "0", "1", "026EB7A859923FBC82189631F8103FE4AC9CA2970012D5D46024804801841CA44370958493B205E647DA304DB4CEB08CBBD1BA39494776FB988B47174DCA88C7E2945283A01C8972", "0349DC807F4FBF374F4AEADE3BCA95314DD58CEC9F307A54FFC61EFC006D8A2C9D4979C0AC44AEA74FBEBBB9F772AEDCB620B01A7BA7AF1B320430C8591984F601CD4C143EF1C7A3", 0, "020000000000000000000000000000000000000000000000000000000000000000000000131850E1F19A63E4B391A8DB917F4138B630D84BE5D639381E91DEB45CFE778F637C1001", "4", 571, C2_K571 ); /* Curve B-571 (FIPS PUB 186-2, App. 6) */ CHAR2_CURVE_TEST ( "NIST curve B-571", "80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425", "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", "02F40E7E2221F295DE297117B7F3D62F5C6A97FFCB8CEFF1CD6BA8CE4A9A18AD84FFABBD8EFA59332BE7AD6756A66E294AFD185A78FF12AA520E4DE739BACA0C7FFEFF7F2955727A", "0303001D34B856296C16C0D40D3CD7750A93D1D2955FA80AA5F40FC8DB7B2ABDBDE53950F4C0D293CDD711A35B67FB1499AE60038614F1394ABFA3B4C850D927E1E7769C8EEC2D19", "037BF27342DA639B6DCCFFFEB73D69D78C6C27A6009CBBCA1980F8533921E8A684423E43BAB08A576291AF8F461BB2A8B3531D2F0485C19B16E2F1516E23DD3C1A4827AF1B8AC15B", 1, "03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE661CE18FF55987308059B186823851EC7DD9CA1161DE93D5174D66E8382E9BB2FE84E47", "2", 571, C2_B571 ); /* more tests using the last curve */ if (!EC_POINT_copy(Q, P)) ABORT; if (EC_POINT_is_at_infinity(group, Q)) ABORT; if (!EC_POINT_dbl(group, P, P, ctx)) ABORT; if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT; if (!EC_POINT_invert(group, Q, ctx)) ABORT; /* P = -2Q */ if (!EC_POINT_add(group, R, P, Q, ctx)) ABORT; if (!EC_POINT_add(group, R, R, Q, ctx)) ABORT; if (!EC_POINT_is_at_infinity(group, R)) ABORT; /* R = P + 2Q */ { const EC_POINT *points[3]; const BIGNUM *scalars[3]; if (EC_POINT_is_at_infinity(group, Q)) ABORT; points[0] = Q; points[1] = Q; points[2] = Q; if (!BN_add(y, z, BN_value_one())) ABORT; if (BN_is_odd(y)) ABORT; if (!BN_rshift1(y, y)) ABORT; scalars[0] = y; /* (group order + 1)/2, so y*Q + y*Q = Q */ scalars[1] = y; fprintf(stdout, "combined multiplication ..."); fflush(stdout); /* z is still the group order */ if (!EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx)) ABORT; if (!EC_POINTs_mul(group, R, z, 2, points, scalars, ctx)) ABORT; if (0 != EC_POINT_cmp(group, P, R, ctx)) ABORT; if (0 != EC_POINT_cmp(group, R, Q, ctx)) ABORT; fprintf(stdout, "."); fflush(stdout); if (!BN_pseudo_rand(y, BN_num_bits(y), 0, 0)) ABORT; if (!BN_add(z, z, y)) ABORT; BN_set_negative(z, 1); scalars[0] = y; scalars[1] = z; /* z = -(order + y) */ if (!EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx)) ABORT; if (!EC_POINT_is_at_infinity(group, P)) ABORT; fprintf(stdout, "."); fflush(stdout); if (!BN_pseudo_rand(x, BN_num_bits(y) - 1, 0, 0)) ABORT; if (!BN_add(z, x, y)) ABORT; BN_set_negative(z, 1); scalars[0] = x; scalars[1] = y; scalars[2] = z; /* z = -(x+y) */ if (!EC_POINTs_mul(group, P, NULL, 3, points, scalars, ctx)) ABORT; if (!EC_POINT_is_at_infinity(group, P)) ABORT; fprintf(stdout, " ok\n\n"); } if (ctx) BN_CTX_free(ctx); BN_free(p); BN_free(a); BN_free(b); EC_GROUP_free(group); EC_POINT_free(P); EC_POINT_free(Q); EC_POINT_free(R); BN_free(x); BN_free(y); BN_free(z); BN_free(cof); if (C2_K163) EC_GROUP_free(C2_K163); if (C2_B163) EC_GROUP_free(C2_B163); if (C2_K233) EC_GROUP_free(C2_K233); if (C2_B233) EC_GROUP_free(C2_B233); if (C2_K283) EC_GROUP_free(C2_K283); if (C2_B283) EC_GROUP_free(C2_B283); if (C2_K409) EC_GROUP_free(C2_K409); if (C2_B409) EC_GROUP_free(C2_B409); if (C2_K571) EC_GROUP_free(C2_K571); if (C2_B571) EC_GROUP_free(C2_B571); } #endif static void internal_curve_test(void) { EC_builtin_curve *curves = NULL; size_t crv_len = 0, n = 0; int ok = 1; crv_len = EC_get_builtin_curves(NULL, 0); curves = reallocarray(NULL, sizeof(EC_builtin_curve), crv_len); if (curves == NULL) return; if (!EC_get_builtin_curves(curves, crv_len)) { free(curves); return; } fprintf(stdout, "testing internal curves: "); for (n = 0; n < crv_len; n++) { EC_GROUP *group = NULL; int nid = curves[n].nid; if ((group = EC_GROUP_new_by_curve_name(nid)) == NULL) { ok = 0; fprintf(stdout, "\nEC_GROUP_new_curve_name() failed with" " curve %s\n", OBJ_nid2sn(nid)); /* try next curve */ continue; } if (!EC_GROUP_check(group, NULL)) { ok = 0; fprintf(stdout, "\nEC_GROUP_check() failed with" " curve %s\n", OBJ_nid2sn(nid)); EC_GROUP_free(group); /* try the next curve */ continue; } fprintf(stdout, "."); fflush(stdout); EC_GROUP_free(group); } if (ok) fprintf(stdout, " ok\n\n"); else { fprintf(stdout, " failed\n\n"); ABORT; } free(curves); return; } #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 /* nistp_test_params contains magic numbers for testing our optimized * implementations of several NIST curves with characteristic > 3. */ struct nistp_test_params { const EC_METHOD* (*meth) (); int degree; /* Qx, Qy and D are taken from * http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/ECDSA_Prime.pdf * Otherwise, values are standard curve parameters from FIPS 180-3 */ const char *p, *a, *b, *Qx, *Qy, *Gx, *Gy, *order, *d; }; static const struct nistp_test_params nistp_tests_params[] = { { /* P-224 */ EC_GFp_nistp224_method, 224, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001", /* p */ "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE", /* a */ "B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4", /* b */ "E84FB0B8E7000CB657D7973CF6B42ED78B301674276DF744AF130B3E", /* Qx */ "4376675C6FC5612C21A0FF2D2A89D2987DF7A2BC52183B5982298555", /* Qy */ "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21", /* Gx */ "BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34", /* Gy */ "FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D", /* order */ "3F0C488E987C80BE0FEE521F8D90BE6034EC69AE11CA72AA777481E8", /* d */ }, { /* P-256 */ EC_GFp_nistp256_method, 256, "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff", /* p */ "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc", /* a */ "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", /* b */ "b7e08afdfe94bad3f1dc8c734798ba1c62b3a0ad1e9ea2a38201cd0889bc7a19", /* Qx */ "3603f747959dbf7a4bb226e41928729063adc7ae43529e61b563bbc606cc5e09", /* Qy */ "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296", /* Gx */ "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5", /* Gy */ "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551", /* order */ "c477f9f65c22cce20657faa5b2d1d8122336f851a508a1ed04e479c34985bf96", /* d */ }, { /* P-521 */ EC_GFp_nistp521_method, 521, "1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", /* p */ "1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc", /* a */ "051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00", /* b */ "0098e91eef9a68452822309c52fab453f5f117c1da8ed796b255e9ab8f6410cca16e59df403a6bdc6ca467a37056b1e54b3005d8ac030decfeb68df18b171885d5c4", /* Qx */ "0164350c321aecfc1cca1ba4364c9b15656150b4b78d6a48d7d28e7f31985ef17be8554376b72900712c4b83ad668327231526e313f5f092999a4632fd50d946bc2e", /* Qy */ "c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66", /* Gx */ "11839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650", /* Gy */ "1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409", /* order */ "0100085f47b8e1b8b11b7eb33028c0b2888e304bfc98501955b45bba1478dc184eeedf09b86a5f7c21994406072787205e69a63709fe35aa93ba333514b24f961722", /* d */ }, }; void nistp_single_test(const struct nistp_test_params *test) { BN_CTX *ctx; BIGNUM *p, *a, *b, *x, *y, *n, *m, *order; EC_GROUP *NISTP; EC_POINT *G, *P, *Q, *Q_CHECK; fprintf(stdout, "\nNIST curve P-%d (optimised implementation):\n", test->degree); ctx = BN_CTX_new(); p = BN_new(); a = BN_new(); b = BN_new(); x = BN_new(); y = BN_new(); m = BN_new(); n = BN_new(); order = BN_new(); NISTP = EC_GROUP_new(test->meth()); if(!NISTP) ABORT; if (!BN_hex2bn(&p, test->p)) ABORT; if (1 != BN_is_prime_ex(p, BN_prime_checks, ctx, NULL)) ABORT; if (!BN_hex2bn(&a, test->a)) ABORT; if (!BN_hex2bn(&b, test->b)) ABORT; if (!EC_GROUP_set_curve_GFp(NISTP, p, a, b, ctx)) ABORT; G = EC_POINT_new(NISTP); P = EC_POINT_new(NISTP); Q = EC_POINT_new(NISTP); Q_CHECK = EC_POINT_new(NISTP); if(!BN_hex2bn(&x, test->Qx)) ABORT; if(!BN_hex2bn(&y, test->Qy)) ABORT; if(!EC_POINT_set_affine_coordinates_GFp(NISTP, Q_CHECK, x, y, ctx)) ABORT; if (!BN_hex2bn(&x, test->Gx)) ABORT; if (!BN_hex2bn(&y, test->Gy)) ABORT; if (!EC_POINT_set_affine_coordinates_GFp(NISTP, G, x, y, ctx)) ABORT; if (!BN_hex2bn(&order, test->order)) ABORT; if (!EC_GROUP_set_generator(NISTP, G, order, BN_value_one())) ABORT; fprintf(stdout, "verify degree ... "); if (EC_GROUP_get_degree(NISTP) != test->degree) ABORT; fprintf(stdout, "ok\n"); fprintf(stdout, "NIST test vectors ... "); if (!BN_hex2bn(&n, test->d)) ABORT; /* fixed point multiplication */ EC_POINT_mul(NISTP, Q, n, NULL, NULL, ctx); if (0 != EC_POINT_cmp(NISTP, Q, Q_CHECK, ctx)) ABORT; /* random point multiplication */ EC_POINT_mul(NISTP, Q, NULL, G, n, ctx); if (0 != EC_POINT_cmp(NISTP, Q, Q_CHECK, ctx)) ABORT; /* set generator to P = 2*G, where G is the standard generator */ if (!EC_POINT_dbl(NISTP, P, G, ctx)) ABORT; if (!EC_GROUP_set_generator(NISTP, P, order, BN_value_one())) ABORT; /* set the scalar to m=n/2, where n is the NIST test scalar */ if (!BN_rshift(m, n, 1)) ABORT; /* test the non-standard generator */ /* fixed point multiplication */ EC_POINT_mul(NISTP, Q, m, NULL, NULL, ctx); if (0 != EC_POINT_cmp(NISTP, Q, Q_CHECK, ctx)) ABORT; /* random point multiplication */ EC_POINT_mul(NISTP, Q, NULL, P, m, ctx); if (0 != EC_POINT_cmp(NISTP, Q, Q_CHECK, ctx)) ABORT; /* now repeat all tests with precomputation */ if (!EC_GROUP_precompute_mult(NISTP, ctx)) ABORT; /* fixed point multiplication */ EC_POINT_mul(NISTP, Q, m, NULL, NULL, ctx); if (0 != EC_POINT_cmp(NISTP, Q, Q_CHECK, ctx)) ABORT; /* random point multiplication */ EC_POINT_mul(NISTP, Q, NULL, P, m, ctx); if (0 != EC_POINT_cmp(NISTP, Q, Q_CHECK, ctx)) ABORT; /* reset generator */ if (!EC_GROUP_set_generator(NISTP, G, order, BN_value_one())) ABORT; /* fixed point multiplication */ EC_POINT_mul(NISTP, Q, n, NULL, NULL, ctx); if (0 != EC_POINT_cmp(NISTP, Q, Q_CHECK, ctx)) ABORT; /* random point multiplication */ EC_POINT_mul(NISTP, Q, NULL, G, n, ctx); if (0 != EC_POINT_cmp(NISTP, Q, Q_CHECK, ctx)) ABORT; fprintf(stdout, "ok\n"); group_order_tests(NISTP); EC_GROUP_free(NISTP); EC_POINT_free(G); EC_POINT_free(P); EC_POINT_free(Q); EC_POINT_free(Q_CHECK); BN_free(n); BN_free(m); BN_free(p); BN_free(a); BN_free(b); BN_free(x); BN_free(y); BN_free(order); BN_CTX_free(ctx); } void nistp_tests() { unsigned i; for (i = 0; i < sizeof(nistp_tests_params) / sizeof(struct nistp_test_params); i++) { nistp_single_test(&nistp_tests_params[i]); } } #endif int main(int argc, char *argv[]) { ERR_load_crypto_strings(); prime_field_tests(); puts(""); #ifndef OPENSSL_NO_EC2M char2_field_tests(); #endif #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 nistp_tests(); #endif /* test the internal curves */ internal_curve_test(); #ifndef OPENSSL_NO_ENGINE ENGINE_cleanup(); #endif CRYPTO_cleanup_all_ex_data(); ERR_free_strings(); ERR_remove_thread_state(NULL); CRYPTO_mem_leaks_fp(stderr); return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/arc4randomforktest.c0000644000175000017500000000744012360020706022063 0ustar /* * Copyright (c) 2014 Google Inc. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include #include #include #include #define CHECK(x) assert(x) #define CHECK_EQ(a, b) assert((a) == (b)) #define CHECK_NE(a, b) assert((a) != (b)) #define CHECK_GE(a, b) assert((a) >= (b)) #define CHECK_LE(a, b) assert((a) <= (b)) /* Test arc4random_buf(3) instead of arc4random(3). */ static int flagbuf; /* Initialize arc4random(3) before forking. */ static int flagprefork; enum { N = 4096 }; typedef struct { uint32_t x[N]; } Buf; static int isfullbuf(const Buf *buf) { size_t i; for (i = 0; i < N; i++) if (buf->x[i]) return (1); return (0); } static void fillbuf(Buf *buf) { if (flagbuf) { arc4random_buf(buf->x, sizeof(buf->x)); } else { size_t i; for (i = 0; i < N; i++) buf->x[i] = arc4random(); } } static void usage() { extern const char *__progname; errx(1, "usage: %s [-bp]", __progname); } static pid_t safewaitpid(pid_t pid, int *status, int options) { pid_t ret; do { ret = waitpid(pid, status, options); } while (ret == -1 && errno == EINTR); return (ret); } int main(int argc, char *argv[]) { int opt, status; Buf *bufparent, *bufchildone, *bufchildtwo; pid_t pidone, pidtwo; size_t i, countone = 0, counttwo = 0, countkids = 0; /* Ensure SIGCHLD isn't set to SIG_IGN. */ const struct sigaction sa = { .sa_handler = SIG_DFL, }; CHECK_EQ(0, sigaction(SIGCHLD, &sa, NULL)); while ((opt = getopt(argc, argv, "bp")) != -1) { switch (opt) { case 'b': flagbuf = 1; break; case 'p': flagprefork = 1; break; default: usage(); } } if (flagprefork) arc4random(); bufparent = mmap(NULL, sizeof(Buf), PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0); CHECK_NE(MAP_FAILED, bufparent); bufchildone = mmap(NULL, sizeof(Buf), PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); CHECK_NE(MAP_FAILED, bufchildone); bufchildtwo = mmap(NULL, sizeof(Buf), PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); CHECK_NE(MAP_FAILED, bufchildtwo); pidone = fork(); CHECK_GE(pidone, 0); if (pidone == 0) { fillbuf(bufchildone); _exit(0); } pidtwo = fork(); CHECK_GE(pidtwo, 0); if (pidtwo == 0) { fillbuf(bufchildtwo); _exit(0); } fillbuf(bufparent); CHECK_EQ(pidone, safewaitpid(pidone, &status, 0)); CHECK(WIFEXITED(status)); CHECK_EQ(0, WEXITSTATUS(status)); CHECK_EQ(pidtwo, safewaitpid(pidtwo, &status, 0)); CHECK(WIFEXITED(status)); CHECK_EQ(0, WEXITSTATUS(status)); CHECK(isfullbuf(bufchildone)); CHECK(isfullbuf(bufchildtwo)); for (i = 0; i < N; i++) { countone += bufparent->x[i] == bufchildone->x[i]; counttwo += bufparent->x[i] == bufchildtwo->x[i]; countkids += bufchildone->x[i] == bufchildtwo->x[i]; } /* * These checks are inherently probabilistic and theoretically risk * flaking, but there's less than a 1 in 2^40 chance of more than * one pairwise match between two vectors of 4096 32-bit integers. */ CHECK_LE(countone, 1); CHECK_LE(counttwo, 1); CHECK_LE(countkids, 1); return (0); } deps/libressl-pnacl-sys-2.1.6/libressl/tests/base64test.c0000644000175000017500000002312112360020706020225 0ustar /* * Copyright (c) 2014 Joel Sing * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #define BUF_SIZE 128 struct base64_test { const unsigned char in[BUF_SIZE]; const ssize_t in_len; const unsigned char out[BUF_SIZE]; const ssize_t out_len; const ssize_t valid_len; }; /* * Many of these tests are based on those found in Go's encoding/base64 tests. */ struct base64_test base64_tests[] = { /* RFC3548 examples. */ { "\x14\xfb\x9c\x03\xd9\x7e", 6, "FPucA9l+", 8, 6, }, { "\x14\xfb\x9c\x03\xd9", 5, "FPucA9k=", 8, 5, }, { "\x14\xfb\x9c\x03", 4, "FPucAw==", 8, 4, }, /* RFC4648 examples. */ { "", 0, "", 0, 0, }, { "f", 1, "Zg==", 4, 1, }, { "fo", 2, "Zm8=", 4, 2, }, { "foo", 3, "Zm9v", 4, 3, }, { "foob", 4, "Zm9vYg==", 8, 4, }, { "fooba", 5, "Zm9vYmE=", 8, 5, }, { "foobar", 6, "Zm9vYmFy", 8, 6, }, /* Wikipedia examples. */ { "sure.", 5, "c3VyZS4=", 8, 5, }, { "sure", 4, "c3VyZQ==", 8, 4, }, { "sur", 3, "c3Vy", 4, 3, }, { "su", 2, "c3U=", 4, 2, }, { "leasure.", 8, "bGVhc3VyZS4=", 12, 8, }, { "easure.", 7, "ZWFzdXJlLg==", 12, 7, }, { "asure.", 6, "YXN1cmUu", 8, 6, }, { "abcd", 4, "YWJjZA==", 8, 4, }, { "Twas brillig, and the slithy toves", 34, "VHdhcyBicmlsbGlnLCBhbmQgdGhlIHNsaXRoeSB0b3Zlcw==", 48, 34, }, }; #define N_TESTS (sizeof(base64_tests) / sizeof(*base64_tests)) struct base64_test base64_nl_tests[] = { /* Corrupt/invalid encodings. */ { "", -1, "", 0, 0, }, { "", -1, "!!!!", 4, 0, }, { "", -1, "====", 4, 0, }, { "", -1, "x===", 4, 0, }, { "", -1, "=AAA", 4, 0, }, { "", -1, "A=AA", 4, 0, }, { "", -1, "AA=A", 4, 0, }, { "", -1, "AA==A", 5, 0, }, { "", -1, "AAA=AAAA", 8, 0, }, { "", -1, "AAAAA", 5, 0, }, { "", -1, "AAAAAA", 6, 0, }, { "", -1, "A=", 2, 0, }, { "", -1, "A==", 3, 0, }, { "", -1, "AA=", 3, 0, }, { "", -1, "AA==", 4, 1, }, /* XXX - output ix 0x0. */ { "", -1, "AAA=", 4, 2, }, /* XXX - output ix 2x 0x0. */ { "", -1, "AAAA", 4, 3, }, /* XXX - output ix 3x 0x0. */ { "", -1, "AAAAAA=", 7, 0, }, { "", -1, "YWJjZA=====", 11, 0, }, /* Encodings with embedded CR/LF. */ { "sure", 4, "c3VyZQ==", 8, 4, }, { "sure", 4, "c3VyZQ==\r", 9, 4, }, { "sure", 4, "c3VyZQ==\n", 9, 4, }, { "sure", 4, "c3VyZQ==\r\n", 10, 4, }, { "sure", 4, "c3VyZ\r\nQ==", 10, 4, }, { "sure", 4, "c3V\ryZ\nQ==", 10, 4, }, { "sure", 4, "c3V\nyZ\rQ==", 10, 4, }, { "sure", 4, "c3VyZ\nQ==", 9, 4, }, { "sure", 4, "c3VyZQ\n==", 9, 4, }, { "sure", 4, "c3VyZQ=\n=", 9, 4, }, { "sure", 4, "c3VyZQ=\r\n\r\n=", 12, 4, }, { "", -1, "YWJjZA======================================================" "============", 74, 0, }, }; #define N_NL_TESTS (sizeof(base64_nl_tests) / sizeof(*base64_nl_tests)) struct base64_test base64_no_nl_tests[] = { /* * In non-newline mode, the output resulting from corrupt/invalid * encodings is completely crazy. A number of zero bytes is returned * rather than nothing. */ /* Corrupt/invalid encodings. */ { "", -1, "", 0, 0, }, { "", -1, "!!!!", 4, 0, }, { "", -1, "====", 4, 1, }, { "", -1, "x===", 4, 1, }, { "", -1, "=AAA", 4, 3, }, { "", -1, "A=AA", 4, 3, }, { "", -1, "AA=A", 4, 3, }, { "", -1, "AA==A", 5, 1, }, { "", -1, "AAA=AAAA", 8, 6, }, { "", -1, "AAAAA", 5, 3, }, { "", -1, "AAAAAA", 6, 3, }, { "", -1, "A=", 2, 0, }, { "", -1, "A==", 3, 0, }, { "", -1, "AA=", 3, 0, }, { "", -1, "AA==", 4, 1, }, { "", -1, "AAA=", 4, 2, }, { "", -1, "AAAA", 4, 3, }, { "", -1, "AAAAAA=", 7, 3, }, { "", -1, "YWJjZA=====", 11, 4, }, /* Encodings with embedded CR/LF. */ { "sure", 4, "c3VyZQ==", 8, 4, }, { "sure", 4, "c3VyZQ==\r", 9, 4, }, { "sure", 4, "c3VyZQ==\n", 9, 4, }, { "sure", 4, "c3VyZQ==\r\n", 10, 4, }, { "sure", -1, "c3VyZ\r\nQ==", 10, 0, }, { "sure", -1, "c3V\ryZ\nQ==", 10, 0, }, { "sure", -1, "c3V\nyZ\rQ==", 10, 0, }, { "sure", -1, "c3VyZ\nQ==", 9, 0, }, { "sure", -1, "c3VyZQ\n==", 9, 0, }, { "sure", -1, "c3VyZQ=\n=", 9, 0, }, { "sure", -1, "c3VyZQ=\r\n\r\n=", 12, 0, }, /* * This is invalid, yet results in 'abcd' followed by a stream of * zero value bytes. */ { "", -1, "YWJjZA======================================================" "============", 74, 52, }, }; #define N_NO_NL_TESTS (sizeof(base64_no_nl_tests) / sizeof(*base64_no_nl_tests)) static int base64_encoding_test(int test_no, struct base64_test *bt, int test_nl) { BIO *bio_b64, *bio_mem; unsigned char *buf, *out; ssize_t i, len, b64len; int failure = 0; buf = malloc(BUF_SIZE); if (buf == NULL) errx(1, "malloc"); bio_b64 = BIO_new(BIO_f_base64()); if (bio_b64 == NULL) errx(1, "BIO_new failed for BIO_f_base64"); bio_mem = BIO_new(BIO_s_mem()); if (bio_mem == NULL) errx(1, "BIO_new failed for BIO_s_mem"); bio_mem = BIO_push(bio_b64, bio_mem); if (!test_nl) BIO_set_flags(bio_b64, BIO_FLAGS_BASE64_NO_NL); len = BIO_write(bio_mem, bt->in, bt->in_len); if (len != bt->in_len) { fprintf(stderr, "FAIL: test %i - only wrote %zi out of %zi " "characters\n", test_no, len, bt->in_len); failure = 1; goto done; } if (BIO_flush(bio_mem) < 0) { fprintf(stderr, "FAIL: test %i - flush failed\n", test_no); failure = 1; goto done; } b64len = 0; for (i = 0; i < bt->out_len; i++) { if (bt->out[i] == '\r' || bt->out[i] == '\n') continue; buf[b64len++] = bt->out[i]; } if (test_nl) buf[b64len++] = '\n'; len = BIO_get_mem_data(bio_mem, &out); /* An empty string with NL results in no output, rather than '\n'. */ if (test_nl && b64len == 1 && len == 0) goto done; if (len != b64len) { fprintf(stderr, "FAIL: test %i - encoding resulted in %zi " "characters instead of %zi\n", test_no, len, b64len); failure = 1; goto done; } if (memcmp(buf, out, b64len) != 0) { fprintf(stderr, "FAIL: test %i - encoding differs:\n", test_no); fprintf(stderr, " encoding: "); for (i = 0; i < len; i++) fprintf(stderr, "%c", out[i]); fprintf(stderr, "\n"); fprintf(stderr, " test data: "); for (i = 0; i < bt->out_len; i++) fprintf(stderr, "%c", buf[i]); fprintf(stderr, "\n"); failure = 1; } done: BIO_free_all(bio_mem); free(buf); return failure; } static int base64_decoding_test(int test_no, struct base64_test *bt, int test_nl) { BIO *bio_b64, *bio_mem; char *buf, *input; ssize_t i, inlen, len; int failure = 0; buf = malloc(BUF_SIZE); if (buf == NULL) errx(1, "malloc"); input = (char *)bt->out; inlen = bt->out_len; if (test_nl) inlen = asprintf(&input, "%s\r\n", bt->out); bio_mem = BIO_new_mem_buf(input, inlen); if (bio_mem == NULL) errx(1, "BIO_new_mem_buf failed"); bio_b64 = BIO_new(BIO_f_base64()); if (bio_b64 == NULL) errx(1, "BIO_new failed for BIO_f_base64"); if (!test_nl) BIO_set_flags(bio_b64, BIO_FLAGS_BASE64_NO_NL); bio_mem = BIO_push(bio_b64, bio_mem); /* * If we wrote zero characters then a BIO_read will result in a return * value of -1, hence we need to handle this case. */ len = BIO_read(bio_mem, buf, BUF_SIZE); if (len != bt->valid_len && (bt->in_len != 0 || len != -1)) { fprintf(stderr, "FAIL: test %i - decoding resulted in %zi " "characters instead of %zi\n", test_no, len, bt->valid_len); fprintf(stderr, " input: "); for (i = 0; i < inlen; i++) fprintf(stderr, "%c", input[i]); fprintf(stderr, "\n"); fprintf(stderr, " decoding: "); for (i = 0; i < len; i++) fprintf(stderr, "0x%x ", buf[i]); fprintf(stderr, "\n"); failure = 1; goto done; } /* See if we expect this to fail decoding. */ if (bt->in_len == -1) goto done; if (memcmp(bt->in, buf, bt->in_len) != 0) { fprintf(stderr, "FAIL: test %i - decoding differs:\n", test_no); fprintf(stderr, " decoding: "); for (i = 0; i < len; i++) fprintf(stderr, "0x%x ", buf[i]); fprintf(stderr, "\n"); fprintf(stderr, " test data: "); for (i = 0; i < inlen; i++) fprintf(stderr, "0x%x ", input[i]); fprintf(stderr, "\n"); failure = 1; } done: BIO_free_all(bio_mem); free(buf); if (test_nl) free(input); return failure; } int main(int argc, char **argv) { struct base64_test *bt; int failed = 0; size_t i; fprintf(stderr, "Starting combined tests...\n"); for (i = 0; i < N_TESTS; i++) { bt = &base64_tests[i]; if (bt->in_len != -1) failed += base64_encoding_test(i, bt, 0); if (bt->out_len != -1) failed += base64_decoding_test(i, bt, 0); if (bt->in_len != -1) failed += base64_encoding_test(i, bt, 1); if (bt->out_len != -1) failed += base64_decoding_test(i, bt, 1); } fprintf(stderr, "Starting NL tests...\n"); for (i = 0; i < N_NL_TESTS; i++) { bt = &base64_nl_tests[i]; if (bt->in_len != -1) failed += base64_encoding_test(i, bt, 1); if (bt->out_len != -1) failed += base64_decoding_test(i, bt, 1); } fprintf(stderr, "Starting NO NL tests...\n"); for (i = 0; i < N_NO_NL_TESTS; i++) { bt = &base64_no_nl_tests[i]; if (bt->in_len != -1) failed += base64_encoding_test(i, bt, 0); if (bt->out_len != -1) failed += base64_decoding_test(i, bt, 0); } return failed; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/dsatest.c0000644000175000017500000001617112360020706017717 0ustar /* crypto/dsa/dsatest.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* Until the key-gen callbacks are modified to use newer prototypes, we allow * deprecated functions for openssl-internal code */ #ifdef OPENSSL_NO_DEPRECATED #undef OPENSSL_NO_DEPRECATED #endif #include #include #include #include #include #include #include #include #include #include #include static int dsa_cb(int p, int n, BN_GENCB *arg); /* seed, out_p, out_q, out_g are taken from the updated Appendix 5 to * FIPS PUB 186 and also appear in Appendix 5 to FIPS PIB 186-1 */ static unsigned char seed[20]={ 0xd5,0x01,0x4e,0x4b,0x60,0xef,0x2b,0xa8,0xb6,0x21,0x1b,0x40, 0x62,0xba,0x32,0x24,0xe0,0x42,0x7d,0xd3, }; static unsigned char out_p[]={ 0x8d,0xf2,0xa4,0x94,0x49,0x22,0x76,0xaa, 0x3d,0x25,0x75,0x9b,0xb0,0x68,0x69,0xcb, 0xea,0xc0,0xd8,0x3a,0xfb,0x8d,0x0c,0xf7, 0xcb,0xb8,0x32,0x4f,0x0d,0x78,0x82,0xe5, 0xd0,0x76,0x2f,0xc5,0xb7,0x21,0x0e,0xaf, 0xc2,0xe9,0xad,0xac,0x32,0xab,0x7a,0xac, 0x49,0x69,0x3d,0xfb,0xf8,0x37,0x24,0xc2, 0xec,0x07,0x36,0xee,0x31,0xc8,0x02,0x91, }; static unsigned char out_q[]={ 0xc7,0x73,0x21,0x8c,0x73,0x7e,0xc8,0xee, 0x99,0x3b,0x4f,0x2d,0xed,0x30,0xf4,0x8e, 0xda,0xce,0x91,0x5f, }; static unsigned char out_g[]={ 0x62,0x6d,0x02,0x78,0x39,0xea,0x0a,0x13, 0x41,0x31,0x63,0xa5,0x5b,0x4c,0xb5,0x00, 0x29,0x9d,0x55,0x22,0x95,0x6c,0xef,0xcb, 0x3b,0xff,0x10,0xf3,0x99,0xce,0x2c,0x2e, 0x71,0xcb,0x9d,0xe5,0xfa,0x24,0xba,0xbf, 0x58,0xe5,0xb7,0x95,0x21,0x92,0x5c,0x9c, 0xc4,0x2e,0x9f,0x6f,0x46,0x4b,0x08,0x8c, 0xc5,0x72,0xaf,0x53,0xe6,0xd7,0x88,0x02, }; static const unsigned char str1[]="12345678901234567890"; static BIO *bio_err=NULL; int main(int argc, char **argv) { BN_GENCB cb; DSA *dsa=NULL; int counter,ret=0,i,j; unsigned char buf[256]; unsigned long h; unsigned char sig[256]; unsigned int siglen; if (bio_err == NULL) bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); ERR_load_crypto_strings(); BIO_printf(bio_err,"test generation of DSA parameters\n"); BN_GENCB_set(&cb, dsa_cb, bio_err); if(((dsa = DSA_new()) == NULL) || !DSA_generate_parameters_ex(dsa, 512, seed, 20, &counter, &h, &cb)) goto end; BIO_printf(bio_err,"seed\n"); for (i=0; i<20; i+=4) { BIO_printf(bio_err,"%02X%02X%02X%02X ", seed[i],seed[i+1],seed[i+2],seed[i+3]); } BIO_printf(bio_err,"\ncounter=%d h=%ld\n",counter,h); DSA_print(bio_err,dsa,0); if (counter != 105) { BIO_printf(bio_err,"counter should be 105\n"); goto end; } if (h != 2) { BIO_printf(bio_err,"h should be 2\n"); goto end; } i=BN_bn2bin(dsa->q,buf); j=sizeof(out_q); if ((i != j) || (memcmp(buf,out_q,i) != 0)) { BIO_printf(bio_err,"q value is wrong\n"); goto end; } i=BN_bn2bin(dsa->p,buf); j=sizeof(out_p); if ((i != j) || (memcmp(buf,out_p,i) != 0)) { BIO_printf(bio_err,"p value is wrong\n"); goto end; } i=BN_bn2bin(dsa->g,buf); j=sizeof(out_g); if ((i != j) || (memcmp(buf,out_g,i) != 0)) { BIO_printf(bio_err,"g value is wrong\n"); goto end; } dsa->flags |= DSA_FLAG_NO_EXP_CONSTTIME; DSA_generate_key(dsa); DSA_sign(0, str1, 20, sig, &siglen, dsa); if (DSA_verify(0, str1, 20, sig, siglen, dsa) == 1) ret=1; dsa->flags &= ~DSA_FLAG_NO_EXP_CONSTTIME; DSA_generate_key(dsa); DSA_sign(0, str1, 20, sig, &siglen, dsa); if (DSA_verify(0, str1, 20, sig, siglen, dsa) == 1) ret=1; end: if (!ret) ERR_print_errors(bio_err); if (dsa != NULL) DSA_free(dsa); CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); ERR_free_strings(); CRYPTO_mem_leaks(bio_err); if (bio_err != NULL) { BIO_free(bio_err); bio_err = NULL; } exit(!ret); } static int dsa_cb(int p, int n, BN_GENCB *arg) { char c='*'; static int ok=0,num=0; if (p == 0) { c='.'; num++; }; if (p == 1) c='+'; if (p == 2) { c='*'; ok++; } if (p == 3) c='\n'; BIO_write(arg->arg,&c,1); (void)BIO_flush(arg->arg); if (!ok && (p == 0) && (num > 1)) { BIO_printf((BIO *)arg,"error in dsatest\n"); return 0; } return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/timingsafe.c0000644000175000017500000000353012360020706020371 0ustar /* $OpenBSD: timingsafe.c,v 1.2 2014/06/13 02:12:17 matthew Exp $ */ /* * Copyright (c) 2014 Google Inc. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #define ASSERT_EQ(a, b) assert((a) == (b)) enum { N = 8 }; static unsigned char bufone[N], buftwo[N]; void check() { int cmp = memcmp(bufone, buftwo, N); /* Check for reflexivity. */ ASSERT_EQ(0, timingsafe_bcmp(bufone, bufone, N)); ASSERT_EQ(0, timingsafe_bcmp(buftwo, buftwo, N)); ASSERT_EQ(0, timingsafe_memcmp(bufone, bufone, N)); ASSERT_EQ(0, timingsafe_memcmp(buftwo, buftwo, N)); /* Check that timingsafe_bcmp returns 0 iff memcmp returns 0. */ ASSERT_EQ(cmp == 0, timingsafe_bcmp(bufone, buftwo, N) == 0); /* Check that timingsafe_memcmp returns cmp... */ ASSERT_EQ(cmp < 0, timingsafe_memcmp(bufone, buftwo, N) < 0); /* ... or -cmp if the argument order is swapped. */ ASSERT_EQ(-cmp < 0, timingsafe_memcmp(buftwo, bufone, N) < 0); } int main() { int i, j; for (i = 0; i < 10000; i++) { arc4random_buf(bufone, N); arc4random_buf(buftwo, N); check(); for (j = 0; j < N; j++) { buftwo[j] = bufone[j]; check(); } } return (0); } deps/libressl-pnacl-sys-2.1.6/libressl/tests/casttest.c0000644000175000017500000001636412360020706020106 0ustar /* crypto/cast/casttest.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include /* To see if OPENSSL_NO_CAST is defined */ #include #define FULL_TEST static unsigned char k[16]={ 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A }; static unsigned char in[8]={ 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}; static int k_len[3]={16,10,5}; static unsigned char c[3][8]={ {0x23,0x8B,0x4F,0xE5,0x84,0x7E,0x44,0xB2}, {0xEB,0x6A,0x71,0x1A,0x2C,0x02,0x27,0x1B}, {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E}, }; static unsigned char out[80]; static unsigned char in_a[16]={ 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A}; static unsigned char in_b[16]={ 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A}; static unsigned char c_a[16]={ 0xEE,0xA9,0xD0,0xA2,0x49,0xFD,0x3B,0xA6, 0xB3,0x43,0x6F,0xB8,0x9D,0x6D,0xCA,0x92}; static unsigned char c_b[16]={ 0xB2,0xC9,0x5E,0xB0,0x0C,0x31,0xAD,0x71, 0x80,0xAC,0x05,0xB8,0xE8,0x3D,0x69,0x6E}; #if 0 char *text="Hello to all people out there"; static unsigned char cfb_key[16]={ 0xe1,0xf0,0xc3,0xd2,0xa5,0xb4,0x87,0x96, 0x69,0x78,0x4b,0x5a,0x2d,0x3c,0x0f,0x1e, }; static unsigned char cfb_iv[80]={0x34,0x12,0x78,0x56,0xab,0x90,0xef,0xcd}; static unsigned char cfb_buf1[40],cfb_buf2[40],cfb_tmp[8]; #define CFB_TEST_SIZE 24 static unsigned char plain[CFB_TEST_SIZE]= { 0x4e,0x6f,0x77,0x20,0x69,0x73, 0x20,0x74,0x68,0x65,0x20,0x74, 0x69,0x6d,0x65,0x20,0x66,0x6f, 0x72,0x20,0x61,0x6c,0x6c,0x20 }; static unsigned char cfb_cipher64[CFB_TEST_SIZE]={ 0x59,0xD8,0xE2,0x65,0x00,0x58,0x6C,0x3F, 0x2C,0x17,0x25,0xD0,0x1A,0x38,0xB7,0x2A, 0x39,0x61,0x37,0xDC,0x79,0xFB,0x9F,0x45 /* 0xF9,0x78,0x32,0xB5,0x42,0x1A,0x6B,0x38, 0x9A,0x44,0xD6,0x04,0x19,0x43,0xC4,0xD9, 0x3D,0x1E,0xAE,0x47,0xFC,0xCF,0x29,0x0B,*/ }; #endif int main(int argc, char *argv[]) { #ifdef FULL_TEST long l; CAST_KEY key_b; #endif int i,z,err=0; CAST_KEY key; for (z=0; z<3; z++) { CAST_set_key(&key,k_len[z],k); CAST_ecb_encrypt(in,out,&key,CAST_ENCRYPT); if (memcmp(out,&(c[z][0]),8) != 0) { printf("ecb cast error encrypting for keysize %d\n",k_len[z]*8); printf("got :"); for (i=0; i<8; i++) printf("%02X ",out[i]); printf("\n"); printf("expected:"); for (i=0; i<8; i++) printf("%02X ",c[z][i]); err=20; printf("\n"); } CAST_ecb_encrypt(out,out,&key,CAST_DECRYPT); if (memcmp(out,in,8) != 0) { printf("ecb cast error decrypting for keysize %d\n",k_len[z]*8); printf("got :"); for (i=0; i<8; i++) printf("%02X ",out[i]); printf("\n"); printf("expected:"); for (i=0; i<8; i++) printf("%02X ",in[i]); printf("\n"); err=3; } } if (err == 0) printf("ecb cast5 ok\n"); #ifdef FULL_TEST { unsigned char out_a[16],out_b[16]; static char *hex="0123456789ABCDEF"; printf("This test will take some time...."); fflush(stdout); memcpy(out_a,in_a,sizeof(in_a)); memcpy(out_b,in_b,sizeof(in_b)); i=1; for (l=0; l<1000000L; l++) { CAST_set_key(&key_b,16,out_b); CAST_ecb_encrypt(&(out_a[0]),&(out_a[0]),&key_b,CAST_ENCRYPT); CAST_ecb_encrypt(&(out_a[8]),&(out_a[8]),&key_b,CAST_ENCRYPT); CAST_set_key(&key,16,out_a); CAST_ecb_encrypt(&(out_b[0]),&(out_b[0]),&key,CAST_ENCRYPT); CAST_ecb_encrypt(&(out_b[8]),&(out_b[8]),&key,CAST_ENCRYPT); if ((l & 0xffff) == 0xffff) { printf("%c",hex[i&0x0f]); fflush(stdout); i++; } } if ( (memcmp(out_a,c_a,sizeof(c_a)) != 0) || (memcmp(out_b,c_b,sizeof(c_b)) != 0)) { printf("\n"); printf("Error\n"); printf("A out ="); for (i=0; i<16; i++) printf("%02X ",out_a[i]); printf("\nactual="); for (i=0; i<16; i++) printf("%02X ",c_a[i]); printf("\n"); printf("B out ="); for (i=0; i<16; i++) printf("%02X ",out_b[i]); printf("\nactual="); for (i=0; i<16; i++) printf("%02X ",c_b[i]); printf("\n"); } else printf(" ok\n"); } #endif exit(err); } deps/libressl-pnacl-sys-2.1.6/libressl/tests/arc4randomforktest.sh0000755000175000017500000000015712357514212022262 0ustar #!/bin/sh set -e ./arc4randomforktest ./arc4randomforktest -b ./arc4randomforktest -p ./arc4randomforktest -bp deps/libressl-pnacl-sys-2.1.6/libressl/tests/exptest.c0000644000175000017500000001362212360020706017742 0ustar /* crypto/bn/exptest.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include #include #define NUM_BITS (BN_BITS*2) int main(int argc, char *argv[]) { BN_CTX *ctx; BIO *out=NULL; int i,ret; unsigned char c; BIGNUM *r_mont,*r_mont_const,*r_recp,*r_simple,*a,*b,*m; ERR_load_BN_strings(); ctx=BN_CTX_new(); if (ctx == NULL) exit(1); r_mont=BN_new(); r_mont_const=BN_new(); r_recp=BN_new(); r_simple=BN_new(); a=BN_new(); b=BN_new(); m=BN_new(); if ( (r_mont == NULL) || (r_recp == NULL) || (a == NULL) || (b == NULL)) goto err; out=BIO_new(BIO_s_file()); if (out == NULL) exit(1); BIO_set_fp(out,stdout,BIO_NOCLOSE); for (i=0; i<200; i++) { RAND_bytes(&c,1); c=(c%BN_BITS)-BN_BITS2; BN_rand(a,NUM_BITS+c,0,0); RAND_bytes(&c,1); c=(c%BN_BITS)-BN_BITS2; BN_rand(b,NUM_BITS+c,0,0); RAND_bytes(&c,1); c=(c%BN_BITS)-BN_BITS2; BN_rand(m,NUM_BITS+c,0,1); BN_mod(a,a,m,ctx); BN_mod(b,b,m,ctx); ret=BN_mod_exp_mont(r_mont,a,b,m,ctx,NULL); if (ret <= 0) { printf("BN_mod_exp_mont() problems\n"); ERR_print_errors(out); exit(1); } ret=BN_mod_exp_recp(r_recp,a,b,m,ctx); if (ret <= 0) { printf("BN_mod_exp_recp() problems\n"); ERR_print_errors(out); exit(1); } ret=BN_mod_exp_simple(r_simple,a,b,m,ctx); if (ret <= 0) { printf("BN_mod_exp_simple() problems\n"); ERR_print_errors(out); exit(1); } ret=BN_mod_exp_mont_consttime(r_mont_const,a,b,m,ctx,NULL); if (ret <= 0) { printf("BN_mod_exp_mont_consttime() problems\n"); ERR_print_errors(out); exit(1); } if (BN_cmp(r_simple, r_mont) == 0 && BN_cmp(r_simple,r_recp) == 0 && BN_cmp(r_simple,r_mont_const) == 0) { printf("."); fflush(stdout); } else { if (BN_cmp(r_simple,r_mont) != 0) printf("\nsimple and mont results differ\n"); if (BN_cmp(r_simple,r_mont_const) != 0) printf("\nsimple and mont const time results differ\n"); if (BN_cmp(r_simple,r_recp) != 0) printf("\nsimple and recp results differ\n"); printf("a (%3d) = ",BN_num_bits(a)); BN_print(out,a); printf("\nb (%3d) = ",BN_num_bits(b)); BN_print(out,b); printf("\nm (%3d) = ",BN_num_bits(m)); BN_print(out,m); printf("\nsimple ="); BN_print(out,r_simple); printf("\nrecp ="); BN_print(out,r_recp); printf("\nmont ="); BN_print(out,r_mont); printf("\nmont_ct ="); BN_print(out,r_mont_const); printf("\n"); exit(1); } } BN_free(r_mont); BN_free(r_mont_const); BN_free(r_recp); BN_free(r_simple); BN_free(a); BN_free(b); BN_free(m); BN_CTX_free(ctx); ERR_remove_thread_state(NULL); CRYPTO_mem_leaks(out); BIO_free(out); printf(" done\n"); exit(0); err: ERR_load_crypto_strings(); ERR_print_errors(out); exit(1); } deps/libressl-pnacl-sys-2.1.6/libressl/tests/shatest.c0000644000175000017500000001154312360020706017721 0ustar /* crypto/sha/shatest.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #define SHA_0 /* FIPS 180 */ #undef SHA_1 /* FIPS 180-1 */ static char *test[]={ "abc", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", NULL, }; #ifdef SHA_0 static char *ret[]={ "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880", "d2516ee1acfa5baf33dfc1c471e438449ef134c8", }; static char *bigret= "3232affa48628a26653b5aaa44541fd90d690603"; #endif #ifdef SHA_1 static char *ret[]={ "a9993e364706816aba3e25717850c26c9cd0d89d", "84983e441c3bd26ebaae4aa1f95129e5e54670f1", }; static char *bigret= "34aa973cd4c4daa4f61eeb2bdbad27316534016f"; #endif static char *pt(unsigned char *md); int main(int argc, char *argv[]) { int i,err=0; char **P,**R; static unsigned char buf[1000]; char *p,*r; EVP_MD_CTX c; unsigned char md[SHA_DIGEST_LENGTH]; EVP_MD_CTX_init(&c); P=test; R=ret; i=1; while (*P != NULL) { EVP_Digest(*P,strlen(*P),md,NULL,EVP_sha(), NULL); p=pt(md); if (strcmp(p,*R) != 0) { printf("error calculating SHA on '%s'\n",*P); printf("got %s instead of %s\n",p,*R); err++; } else printf("test %d ok\n",i); i++; R++; P++; } memset(buf,'a',1000); EVP_DigestInit_ex(&c,EVP_sha(), NULL); for (i=0; i<1000; i++) EVP_DigestUpdate(&c,buf,1000); EVP_DigestFinal_ex(&c,md,NULL); p=pt(md); r=bigret; if (strcmp(p,r) != 0) { printf("error calculating SHA on '%s'\n",p); printf("got %s instead of %s\n",p,r); err++; } else printf("test 3 ok\n"); EVP_MD_CTX_cleanup(&c); exit(err); } static char *pt(unsigned char *md) { int i; static char buf[80]; for (i=0; i #include #include #ifdef OPENSSL_NO_ENGINE int main(int argc, char *argv[]) { printf("No ENGINE support\n"); return(0); } #else #include #include #include #include static void display_engine_list(void) { ENGINE *h; int loop; h = ENGINE_get_first(); loop = 0; printf("listing available engine types\n"); while(h) { printf("engine %i, id = \"%s\", name = \"%s\"\n", loop++, ENGINE_get_id(h), ENGINE_get_name(h)); h = ENGINE_get_next(h); } printf("end of list\n"); /* ENGINE_get_first() increases the struct_ref counter, so we must call ENGINE_free() to decrease it again */ ENGINE_free(h); } int main(int argc, char *argv[]) { ENGINE *block[512]; char buf[256]; const char *id, *name; ENGINE *ptr; int loop; int to_return = 1; ENGINE *new_h1 = NULL; ENGINE *new_h2 = NULL; ENGINE *new_h3 = NULL; ENGINE *new_h4 = NULL; ERR_load_crypto_strings(); memset(block, 0, 512 * sizeof(ENGINE *)); if(((new_h1 = ENGINE_new()) == NULL) || !ENGINE_set_id(new_h1, "test_id0") || !ENGINE_set_name(new_h1, "First test item") || ((new_h2 = ENGINE_new()) == NULL) || !ENGINE_set_id(new_h2, "test_id1") || !ENGINE_set_name(new_h2, "Second test item") || ((new_h3 = ENGINE_new()) == NULL) || !ENGINE_set_id(new_h3, "test_id2") || !ENGINE_set_name(new_h3, "Third test item") || ((new_h4 = ENGINE_new()) == NULL) || !ENGINE_set_id(new_h4, "test_id3") || !ENGINE_set_name(new_h4, "Fourth test item")) { printf("Couldn't set up test ENGINE structures\n"); goto end; } printf("\nenginetest beginning\n\n"); display_engine_list(); if(!ENGINE_add(new_h1)) { printf("Add failed!\n"); goto end; } display_engine_list(); ptr = ENGINE_get_first(); if(!ENGINE_remove(ptr)) { printf("Remove failed!\n"); goto end; } if (ptr) ENGINE_free(ptr); display_engine_list(); if(!ENGINE_add(new_h3) || !ENGINE_add(new_h2)) { printf("Add failed!\n"); goto end; } display_engine_list(); if(!ENGINE_remove(new_h2)) { printf("Remove failed!\n"); goto end; } display_engine_list(); if(!ENGINE_add(new_h4)) { printf("Add failed!\n"); goto end; } display_engine_list(); if(ENGINE_add(new_h3)) { printf("Add *should* have failed but didn't!\n"); goto end; } else printf("Add that should fail did.\n"); ERR_clear_error(); if(ENGINE_remove(new_h2)) { printf("Remove *should* have failed but didn't!\n"); goto end; } else printf("Remove that should fail did.\n"); ERR_clear_error(); if(!ENGINE_remove(new_h3)) { printf("Remove failed!\n"); goto end; } display_engine_list(); if(!ENGINE_remove(new_h4)) { printf("Remove failed!\n"); goto end; } display_engine_list(); /* Depending on whether there's any hardware support compiled * in, this remove may be destined to fail. */ ptr = ENGINE_get_first(); if(ptr) if(!ENGINE_remove(ptr)) printf("Remove failed!i - probably no hardware " "support present.\n"); if (ptr) ENGINE_free(ptr); display_engine_list(); if(!ENGINE_add(new_h1) || !ENGINE_remove(new_h1)) { printf("Couldn't add and remove to an empty list!\n"); goto end; } else printf("Successfully added and removed to an empty list!\n"); printf("About to beef up the engine-type list\n"); for(loop = 0; loop < 512; loop++) { sprintf(buf, "id%i", loop); id = BUF_strdup(buf); sprintf(buf, "Fake engine type %i", loop); name = BUF_strdup(buf); if(((block[loop] = ENGINE_new()) == NULL) || !ENGINE_set_id(block[loop], id) || !ENGINE_set_name(block[loop], name)) { printf("Couldn't create block of ENGINE structures.\n" "I'll probably also core-dump now, damn.\n"); goto end; } } for(loop = 0; loop < 512; loop++) { if(!ENGINE_add(block[loop])) { printf("\nAdding stopped at %i, (%s,%s)\n", loop, ENGINE_get_id(block[loop]), ENGINE_get_name(block[loop])); goto cleanup_loop; } else printf("."); fflush(stdout); } cleanup_loop: printf("\nAbout to empty the engine-type list\n"); while((ptr = ENGINE_get_first()) != NULL) { if(!ENGINE_remove(ptr)) { printf("\nRemove failed!\n"); goto end; } ENGINE_free(ptr); printf("."); fflush(stdout); } for(loop = 0; loop < 512; loop++) { free((void *)ENGINE_get_id(block[loop])); free((void *)ENGINE_get_name(block[loop])); } printf("\nTests completed happily\n"); to_return = 0; end: if(to_return) ERR_print_errors_fp(stderr); if(new_h1) ENGINE_free(new_h1); if(new_h2) ENGINE_free(new_h2); if(new_h3) ENGINE_free(new_h3); if(new_h4) ENGINE_free(new_h4); for(loop = 0; loop < 512; loop++) if(block[loop]) ENGINE_free(block[loop]); ENGINE_cleanup(); CRYPTO_cleanup_all_ex_data(); ERR_free_strings(); ERR_remove_thread_state(NULL); CRYPTO_mem_leaks_fp(stderr); return to_return; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/tests/testssl0000755000175000017500000001176512360020706017537 0ustar #!/bin/sh key="$1" cert="$2" CA="-CAfile $3" extra="$4" ssltest="./ssltest -key $key -cert $cert -c_key $key -c_cert $cert" if openssl x509 -in $cert -text -noout | fgrep 'DSA Public Key' >/dev/null; then dsa_cert=YES else dsa_cert=NO fi ############################################################################# echo test sslv2 $ssltest -ssl2 $extra || exit 1 echo test sslv2 with server authentication $ssltest -ssl2 -server_auth $CA $extra || exit 1 if [ $dsa_cert = NO ]; then echo test sslv2 with client authentication $ssltest -ssl2 -client_auth $CA $extra || exit 1 echo test sslv2 with both client and server authentication $ssltest -ssl2 -server_auth -client_auth $CA $extra || exit 1 fi echo test sslv3 $ssltest -ssl3 $extra || exit 1 echo test sslv3 with server authentication $ssltest -ssl3 -server_auth $CA $extra || exit 1 echo test sslv3 with client authentication $ssltest -ssl3 -client_auth $CA $extra || exit 1 echo test sslv3 with both client and server authentication $ssltest -ssl3 -server_auth -client_auth $CA $extra || exit 1 echo test sslv2/sslv3 $ssltest $extra || exit 1 echo test sslv2/sslv3 with server authentication $ssltest -server_auth $CA $extra || exit 1 echo test sslv2/sslv3 with client authentication $ssltest -client_auth $CA $extra || exit 1 echo test sslv2/sslv3 with both client and server authentication $ssltest -server_auth -client_auth $CA $extra || exit 1 echo test sslv2 via BIO pair $ssltest -bio_pair -ssl2 $extra || exit 1 echo test sslv2 with server authentication via BIO pair $ssltest -bio_pair -ssl2 -server_auth $CA $extra || exit 1 if [ $dsa_cert = NO ]; then echo test sslv2 with client authentication via BIO pair $ssltest -bio_pair -ssl2 -client_auth $CA $extra || exit 1 echo test sslv2 with both client and server authentication via BIO pair $ssltest -bio_pair -ssl2 -server_auth -client_auth $CA $extra || exit 1 fi echo test sslv3 via BIO pair $ssltest -bio_pair -ssl3 $extra || exit 1 echo test sslv3 with server authentication via BIO pair $ssltest -bio_pair -ssl3 -server_auth $CA $extra || exit 1 echo test sslv3 with client authentication via BIO pair $ssltest -bio_pair -ssl3 -client_auth $CA $extra || exit 1 echo test sslv3 with both client and server authentication via BIO pair $ssltest -bio_pair -ssl3 -server_auth -client_auth $CA $extra || exit 1 echo test sslv2/sslv3 via BIO pair $ssltest $extra || exit 1 if [ $dsa_cert = NO ]; then echo 'test sslv2/sslv3 w/o (EC)DHE via BIO pair' $ssltest -bio_pair -no_dhe -no_ecdhe $extra || exit 1 fi echo test sslv2/sslv3 with 1024bit DHE via BIO pair $ssltest -bio_pair -dhe1024dsa -v $extra || exit 1 echo test sslv2/sslv3 with server authentication $ssltest -bio_pair -server_auth $CA $extra || exit 1 echo test sslv2/sslv3 with client authentication via BIO pair $ssltest -bio_pair -client_auth $CA $extra || exit 1 echo test sslv2/sslv3 with both client and server authentication via BIO pair $ssltest -bio_pair -server_auth -client_auth $CA $extra || exit 1 echo test sslv2/sslv3 with both client and server authentication via BIO pair and app verify $ssltest -bio_pair -server_auth -client_auth -app_verify $CA $extra || exit 1 echo "Testing ciphersuites" for protocol in TLSv1.2 SSLv3; do echo "Testing ciphersuites for $protocol" for cipher in `openssl ciphers "RSA+$protocol" | tr ':' ' '`; do echo "Testing $cipher" prot="" if [ $protocol = "SSLv3" ] ; then prot="-ssl3" fi $ssltest -cipher $cipher $prot if [ $? -ne 0 ] ; then echo "Failed $cipher" exit 1 fi done done ############################################################################# if openssl no-dh; then echo skipping anonymous DH tests else echo test tls1 with 1024bit anonymous DH, multiple handshakes $ssltest -v -bio_pair -tls1 -cipher ADH -dhe1024dsa -num 10 -f -time $extra || exit 1 fi #if openssl no-rsa; then # echo skipping RSA tests #else # echo 'test tls1 with 1024bit RSA, no (EC)DHE, multiple handshakes' # ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -no_dhe -no_ecdhe -num 10 -f -time $extra || exit 1 # # if openssl no-dh; then # echo skipping RSA+DHE tests # else # echo test tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes # ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -dhe1024dsa -num 10 -f -time $extra || exit 1 # fi #fi # # DTLS # echo test dtlsv1 $ssltest -dtls1 $extra || exit 1 echo test dtlsv1 with server authentication $ssltest -dtls1 -server_auth $CA $extra || exit 1 echo test dtlsv1 with client authentication $ssltest -dtls1 -client_auth $CA $extra || exit 1 echo test dtlsv1 with both client and server authentication $ssltest -dtls1 -server_auth -client_auth $CA $extra || exit 1 echo "Testing DTLS ciphersuites" for protocol in SSLv3; do echo "Testing ciphersuites for $protocol" for cipher in `openssl ciphers "RSA+$protocol" | tr ':' '\n' | grep -v RC4`; do echo "Testing $cipher" $ssltest -cipher $cipher -dtls1 if [ $? -ne 0 ] ; then echo "Failed $cipher" exit 1 fi done done deps/libressl-pnacl-sys-2.1.6/libressl/tests/server.pem0000644000175000017500000000617412360020706020117 0ustar subject= C = UK, O = OpenSSL Group, OU = FOR TESTING PURPOSES ONLY, CN = Test Server Cert issuer= C = UK, O = OpenSSL Group, OU = FOR TESTING PURPOSES ONLY, CN = OpenSSL Test Intermediate CA -----BEGIN CERTIFICATE----- MIIDpTCCAo2gAwIBAgIJAPYm3GvOr5eUMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV BAYTAlVLMRYwFAYDVQQKDA1PcGVuU1NMIEdyb3VwMSIwIAYDVQQLDBlGT1IgVEVT VElORyBQVVJQT1NFUyBPTkxZMSUwIwYDVQQDDBxPcGVuU1NMIFRlc3QgSW50ZXJt ZWRpYXRlIENBMB4XDTE0MDUyNDE0NDUxMloXDTI0MDQwMTE0NDUxMlowZDELMAkG A1UEBhMCVUsxFjAUBgNVBAoMDU9wZW5TU0wgR3JvdXAxIjAgBgNVBAsMGUZPUiBU RVNUSU5HIFBVUlBPU0VTIE9OTFkxGTAXBgNVBAMMEFRlc3QgU2VydmVyIENlcnQw ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDzhPOSNtyyRspmeuUpxfNJ KCLTuf7g3uQ4zu4iHOmRO5TQci+HhVlLZrHF9XqFXcIP0y4pWDbMSGuiorUmzmfi R7bfSdI/+qIQt8KXRH6HNG1t8ou0VSvWId5TS5Dq/er5ODUr9OaaDva7EquHIcMv vPQGuI+OEAcnleVCy9HVEIySrO4P3CNIicnGkwwiAud05yUAq/gPXBC1hTtmlPD7 TVcGVSEiJdvzqqlgv02qedGrkki6GY4S7GjZxrrf7Foc2EP+51LJzwLQx3/JfrCU 41NEWAsu/Sl0tQabXESN+zJ1pDqoZ3uHMgpQjeGiE0olr+YcsSW/tJmiU9OiAr8R AgMBAAGjTjBMMAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgXgMCwGCWCGSAGG +EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTANBgkqhkiG9w0B AQUFAAOCAQEADfy8VrY5er5ebYLyiC1il5kVOuJHSf8aN5SciJz/VcifA1+Hl2Bu CfuizhP/kUdB9PTSj8ep9sL+5PBFl7CZJDO6Sxs5+qJe15XvLBP8UEdvc779plL6 StUMJT0aU/MaqUZZCldC3G4CcbwzOzKSD5YzvxxIGspxBWRduZKKMOju/4aqK76p dwA/VGCve9mjft3LIrb0gSaPi5KmdGtpAjzW3H1+63DSqxCYb1oiPtUZBs4STwjh WPRmAEVR4RPCETM3Sth4C+bE0QMCGY12ctcbzhj7Xgo7LcSpqviq6JD8SPuU7ISL hy4NcnBBHJr9OV9WTLpmS9V9Vg6QmOpxQw== -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEA84TzkjbcskbKZnrlKcXzSSgi07n+4N7kOM7uIhzpkTuU0HIv h4VZS2axxfV6hV3CD9MuKVg2zEhroqK1Js5n4ke230nSP/qiELfCl0R+hzRtbfKL tFUr1iHeU0uQ6v3q+Tg1K/Tmmg72uxKrhyHDL7z0BriPjhAHJ5XlQsvR1RCMkqzu D9wjSInJxpMMIgLndOclAKv4D1wQtYU7ZpTw+01XBlUhIiXb86qpYL9NqnnRq5JI uhmOEuxo2ca63+xaHNhD/udSyc8C0Md/yX6wlONTRFgLLv0pdLUGm1xEjfsydaQ6 qGd7hzIKUI3hohNKJa/mHLElv7SZolPTogK/EQIDAQABAoIBAADq9FwNtuE5IRQn zGtO4q7Y5uCzZ8GDNYr9RKp+P2cbuWDbvVAecYq2NV9QoIiWJOAYZKklOvekIju3 r0UZLA0PRiIrTg6NrESx3JrjWDK8QNlUO7CPTZ39/K+FrmMkV9lem9yxjJjyC34D AQB+YRTx+l14HppjdxNwHjAVQpIx/uO2F5xAMuk32+3K+pq9CZUtrofe1q4Agj9R 5s8mSy9pbRo9kW9wl5xdEotz1LivFOEiqPUJTUq5J5PeMKao3vdK726XI4Z455Nm W2/MA0YV0ug2FYinHcZdvKM6dimH8GLfa3X8xKRfzjGjTiMSwsdjgMa4awY3tEHH 674jhAECgYEA/zqMrc0zsbNk83sjgaYIug5kzEpN4ic020rSZsmQxSCerJTgNhmg utKSCt0Re09Jt3LqG48msahX8ycqDsHNvlEGPQSbMu9IYeO3Wr3fAm75GEtFWePY BhM73I7gkRt4s8bUiUepMG/wY45c5tRF23xi8foReHFFe9MDzh8fJFECgYEA9EFX 4qAik1pOJGNei9BMwmx0I0gfVEIgu0tzeVqT45vcxbxr7RkTEaDoAG6PlbWP6D9a WQNLp4gsgRM90ZXOJ4up5DsAWDluvaF4/omabMA+MJJ5kGZ0gCj5rbZbKqUws7x8 bp+6iBfUPJUbcqNqFmi/08Yt7vrDnMnyMw2A/sECgYEAiiuRMxnuzVm34hQcsbhH 6ymVqf7j0PW2qK0F4H1ocT9qhzWFd+RB3kHWrCjnqODQoI6GbGr/4JepHUpre1ex 4UEN5oSS3G0ru0rC3U4C59dZ5KwDHFm7ffZ1pr52ljfQDUsrjjIMRtuiwNK2OoRa WSsqiaL+SDzSB+nBmpnAizECgYBdt/y6rerWUx4MhDwwtTnel7JwHyo2MDFS6/5g n8qC2Lj6/fMDRE22w+CA2esp7EJNQJGv+b27iFpbJEDh+/Lf5YzIT4MwVskQ5bYB JFcmRxUVmf4e09D7o705U/DjCgMH09iCsbLmqQ38ONIRSHZaJtMDtNTHD1yi+jF+ OT43gQKBgQC/2OHZoko6iRlNOAQ/tMVFNq7fL81GivoQ9F1U0Qr+DH3ZfaH8eIkX xT0ToMPJUzWAn8pZv0snA0um6SIgvkCuxO84OkANCVbttzXImIsL7pFzfcwV/ERK UM6j0ZuSMFOCr/lGPAoOQU0fskidGEHi1/kW+suSr28TqsyYZpwBDQ== -----END RSA PRIVATE KEY----- deps/libressl-pnacl-sys-2.1.6/libressl/tests/explicit_bzero.c0000644000175000017500000001207112360020706021265 0ustar /* $OpenBSD: explicit_bzero.c,v 1.5 2014/07/11 00:38:17 matthew Exp $ */ /* * Copyright (c) 2014 Google Inc. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #define ASSERT_EQ(a, b) assert((a) == (b)) #define ASSERT_NE(a, b) assert((a) != (b)) #define ASSERT_GE(a, b) assert((a) >= (b)) /* 128 bits of random data. */ static const char secret[16] = { 0xa0, 0x6c, 0x0c, 0x81, 0xba, 0xd8, 0x5b, 0x0c, 0xb0, 0xd6, 0xd4, 0xe3, 0xeb, 0x52, 0x5f, 0x96, }; enum { SECRETCOUNT = 64, SECRETBYTES = SECRETCOUNT * sizeof(secret) }; static char altstack[SIGSTKSZ + SECRETBYTES]; static void setup_stack(void) { const stack_t sigstk = { .ss_sp = altstack, .ss_size = sizeof(altstack), }; ASSERT_EQ(0, sigaltstack(&sigstk, NULL)); } static void assert_on_stack(void) { stack_t cursigstk; ASSERT_EQ(0, sigaltstack(NULL, &cursigstk)); ASSERT_EQ(SS_ONSTACK, cursigstk.ss_flags & (SS_DISABLE|SS_ONSTACK)); } static void call_on_stack(void (*fn)(int)) { /* * This is a bit more complicated than strictly necessary, but * it ensures we don't have any flaky test failures due to * inherited signal masks/actions/etc. * * On systems where SA_ONSTACK is not supported, this could * alternatively be implemented using makecontext() or * pthread_attr_setstack(). */ const struct sigaction sigact = { .sa_handler = fn, .sa_flags = SA_ONSTACK, }; struct sigaction oldsigact; sigset_t sigset, oldsigset; /* First, block all signals. */ ASSERT_EQ(0, sigemptyset(&sigset)); ASSERT_EQ(0, sigfillset(&sigset)); ASSERT_EQ(0, sigprocmask(SIG_BLOCK, &sigset, &oldsigset)); /* Next setup the signal handler for SIGUSR1. */ ASSERT_EQ(0, sigaction(SIGUSR1, &sigact, &oldsigact)); /* Raise SIGUSR1 and momentarily unblock it to run the handler. */ ASSERT_EQ(0, raise(SIGUSR1)); ASSERT_EQ(0, sigdelset(&sigset, SIGUSR1)); ASSERT_EQ(-1, sigsuspend(&sigset)); ASSERT_EQ(EINTR, errno); /* Restore the original signal action, stack, and mask. */ ASSERT_EQ(0, sigaction(SIGUSR1, &oldsigact, NULL)); ASSERT_EQ(0, sigprocmask(SIG_SETMASK, &oldsigset, NULL)); } static void populate_secret(char *buf, size_t len) { int i, fds[2]; ASSERT_EQ(0, pipe(fds)); for (i = 0; i < SECRETCOUNT; i++) ASSERT_EQ(sizeof(secret), write(fds[1], secret, sizeof(secret))); ASSERT_EQ(0, close(fds[1])); ASSERT_EQ(len, read(fds[0], buf, len)); ASSERT_EQ(0, close(fds[0])); } static int count_secrets(const char *buf) { int res = 0; size_t i; for (i = 0; i < SECRETCOUNT; i++) { if (memcmp(buf + i * sizeof(secret), secret, sizeof(secret)) == 0) res += 1; } return (res); } static char * test_without_bzero() { char buf[SECRETBYTES]; assert_on_stack(); populate_secret(buf, sizeof(buf)); char *res = memmem(altstack, sizeof(altstack), buf, sizeof(buf)); ASSERT_NE(NULL, res); return (res); } static char * test_with_bzero() { char buf[SECRETBYTES]; assert_on_stack(); populate_secret(buf, sizeof(buf)); char *res = memmem(altstack, sizeof(altstack), buf, sizeof(buf)); ASSERT_NE(NULL, res); explicit_bzero(buf, sizeof(buf)); return (res); } static void do_test_without_bzero(int signo) { char *buf = test_without_bzero(); ASSERT_GE(count_secrets(buf), 1); } static void do_test_with_bzero(int signo) { char *buf = test_with_bzero(); ASSERT_EQ(count_secrets(buf), 0); } int main() { setup_stack(); /* * Solaris and OS X clobber the signal stack after returning to the * normal stack, so we need to inspect altstack while we're still * running on it. Unfortunately, this means we risk clobbering the * buffer ourselves. * * To minimize this risk, test_with{,out}_bzero() are responsible for * locating the offset of their buf variable within altstack, and * and returning that address. Then we can simply memcmp() repeatedly * to count how many instances of secret we found. */ /* * First, test that if we *don't* call explicit_bzero, that we * *are* able to find at least one instance of the secret data still * on the stack. This sanity checks that call_on_stack() and * populate_secret() work as intended. */ memset(altstack, 0, sizeof(altstack)); call_on_stack(do_test_without_bzero); /* * Now test with a call to explicit_bzero() and check that we * *don't* find any instances of the secret data. */ memset(altstack, 0, sizeof(altstack)); call_on_stack(do_test_with_bzero); return (0); } deps/libressl-pnacl-sys-2.1.6/libressl/tests/hmactest.c0000644000175000017500000001211212360020706020047 0ustar /* crypto/hmac/hmactest.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #ifndef OPENSSL_NO_MD5 #include #endif #ifndef OPENSSL_NO_MD5 static struct test_st { unsigned char key[16]; int key_len; unsigned char data[64]; int data_len; unsigned char *digest; } test[4]={ { "", 0, "More text test vectors to stuff up EBCDIC machines :-)", 54, (unsigned char *)"e9139d1e6ee064ef8cf514fc7dc83e86", },{ {0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b, 0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,}, 16, "Hi There", 8, (unsigned char *)"9294727a3638bb1c13f48ef8158bfc9d", },{ "Jefe", 4, "what do ya want for nothing?", 28, (unsigned char *)"750c783e6ab0b503eaa86e310a5db738", },{ {0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,}, 16, {0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd, 0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd, 0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd, 0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd, 0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd, 0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd, 0xdd,0xdd}, 50, (unsigned char *)"56be34521d144c88dbb8c733f0e8b3f6", }, }; #endif static char *pt(unsigned char *md); int main(int argc, char *argv[]) { #ifndef OPENSSL_NO_MD5 int i; char *p; #endif int err=0; #ifdef OPENSSL_NO_MD5 printf("test skipped: MD5 disabled\n"); #else for (i=0; i<4; i++) { p=pt(HMAC(EVP_md5(), test[i].key, test[i].key_len, test[i].data, test[i].data_len, NULL,NULL)); if (strcmp(p,(char *)test[i].digest) != 0) { printf("error calculating HMAC on %d entry'\n",i); printf("got %s instead of %s\n",p,test[i].digest); err++; } else printf("test %d ok\n",i); } #endif /* OPENSSL_NO_MD5 */ exit(err); return(0); } #ifndef OPENSSL_NO_MD5 static char *pt(unsigned char *md) { int i; static char buf[80]; for (i=0; i #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif #include #include #include #include #ifndef OPENSSL_NO_DH #include #endif #include #define _XOPEN_SOURCE_EXTENDED 1 /* Or gethostname won't be declared properly on Compaq platforms (at least with DEC C). Do not try to put it earlier, or IPv6 includes get screwed... */ # define TEST_SERVER_CERT "../apps/server.pem" # define TEST_CLIENT_CERT "../apps/client.pem" static int verify_callback(int ok, X509_STORE_CTX *ctx); static RSA *tmp_rsa_cb(SSL *s, int is_export, int keylength); static void free_tmp_rsa(void); static int app_verify_callback(X509_STORE_CTX *ctx, void *arg); #define APP_CALLBACK_STRING "Test Callback Argument" struct app_verify_arg { char *string; int app_verify; int allow_proxy_certs; char *proxy_auth; char *proxy_cond; }; #ifndef OPENSSL_NO_DH static DH *get_dh512(void); static DH *get_dh1024(void); static DH *get_dh1024dsa(void); #endif static BIO *bio_err = NULL; static BIO *bio_stdout = NULL; static char *cipher = NULL; static int verbose = 0; static int debug = 0; int doit_biopair(SSL *s_ssl, SSL *c_ssl, long bytes, clock_t *s_time, clock_t *c_time); int doit(SSL *s_ssl, SSL *c_ssl, long bytes); static int do_test_cipherlist(void); static void sv_usage(void) { fprintf(stderr, "usage: ssltest [args ...]\n"); fprintf(stderr, "\n"); fprintf(stderr, " -server_auth - check server certificate\n"); fprintf(stderr, " -client_auth - do client authentication\n"); fprintf(stderr, " -proxy - allow proxy certificates\n"); fprintf(stderr, " -proxy_auth - set proxy policy rights\n"); fprintf(stderr, " -proxy_cond - experssion to test proxy policy rights\n"); fprintf(stderr, " -v - more output\n"); fprintf(stderr, " -d - debug output\n"); fprintf(stderr, " -reuse - use session-id reuse\n"); fprintf(stderr, " -num - number of connections to perform\n"); fprintf(stderr, " -bytes - number of bytes to swap between client/server\n"); #ifndef OPENSSL_NO_DH fprintf(stderr, " -dhe1024 - use 1024 bit key (safe prime) for DHE\n"); fprintf(stderr, " -dhe1024dsa - use 1024 bit key (with 160-bit subprime) for DHE\n"); fprintf(stderr, " -no_dhe - disable DHE\n"); #endif #ifndef OPENSSL_NO_ECDH fprintf(stderr, " -no_ecdhe - disable ECDHE\n"); #endif fprintf(stderr, " -dtls1 - use DTLSv1\n"); fprintf(stderr, " -ssl3 - use SSLv3\n"); fprintf(stderr, " -tls1 - use TLSv1\n"); fprintf(stderr, " -CApath arg - PEM format directory of CA's\n"); fprintf(stderr, " -CAfile arg - PEM format file of CA's\n"); fprintf(stderr, " -cert arg - Server certificate file\n"); fprintf(stderr, " -key arg - Server key file (default: same as -cert)\n"); fprintf(stderr, " -c_cert arg - Client certificate file\n"); fprintf(stderr, " -c_key arg - Client key file (default: same as -c_cert)\n"); fprintf(stderr, " -cipher arg - The cipher list\n"); fprintf(stderr, " -bio_pair - Use BIO pairs\n"); fprintf(stderr, " -f - Test even cases that can't work\n"); fprintf(stderr, " -time - measure processor time used by client and server\n"); #ifndef OPENSSL_NO_ECDH fprintf(stderr, " -named_curve arg - Elliptic curve name to use for ephemeral ECDH keys.\n" \ " Use \"openssl ecparam -list_curves\" for all names\n" \ " (default is sect163r2).\n"); #endif fprintf(stderr, " -test_cipherlist - verifies the order of the ssl cipher lists\n"); } static void print_details(SSL *c_ssl, const char *prefix) { const SSL_CIPHER *ciph; X509 *cert; ciph = SSL_get_current_cipher(c_ssl); BIO_printf(bio_stdout, "%s%s, cipher %s %s", prefix, SSL_get_version(c_ssl), SSL_CIPHER_get_version(ciph), SSL_CIPHER_get_name(ciph)); cert = SSL_get_peer_certificate(c_ssl); if (cert != NULL) { EVP_PKEY *pkey = X509_get_pubkey(cert); if (pkey != NULL) { if (pkey->type == EVP_PKEY_RSA && pkey->pkey.rsa != NULL && pkey->pkey.rsa->n != NULL) { BIO_printf(bio_stdout, ", %d bit RSA", BN_num_bits(pkey->pkey.rsa->n)); } else if (pkey->type == EVP_PKEY_DSA && pkey->pkey.dsa != NULL && pkey->pkey.dsa->p != NULL) { BIO_printf(bio_stdout, ", %d bit DSA", BN_num_bits(pkey->pkey.dsa->p)); } EVP_PKEY_free(pkey); } X509_free(cert); } /* The SSL API does not allow us to look at temporary RSA/DH keys, * otherwise we should print their lengths too */ BIO_printf(bio_stdout, "\n"); } static void lock_dbg_cb(int mode, int type, const char *file, int line) { static int modes[CRYPTO_NUM_LOCKS]; /* = {0, 0, ... } */ const char *errstr = NULL; int rw; rw = mode & (CRYPTO_READ|CRYPTO_WRITE); if (!((rw == CRYPTO_READ) || (rw == CRYPTO_WRITE))) { errstr = "invalid mode"; goto err; } if (type < 0 || type >= CRYPTO_NUM_LOCKS) { errstr = "type out of bounds"; goto err; } if (mode & CRYPTO_LOCK) { if (modes[type]) { errstr = "already locked"; /* must not happen in a single-threaded program * (would deadlock) */ goto err; } modes[type] = rw; } else if (mode & CRYPTO_UNLOCK) { if (!modes[type]) { errstr = "not locked"; goto err; } if (modes[type] != rw) { errstr = (rw == CRYPTO_READ) ? "CRYPTO_r_unlock on write lock" : "CRYPTO_w_unlock on read lock"; } modes[type] = 0; } else { errstr = "invalid mode"; goto err; } err: if (errstr) { /* we cannot use bio_err here */ fprintf(stderr, "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n", errstr, mode, type, file, line); } } int main(int argc, char *argv[]) { char *CApath = NULL, *CAfile = NULL; int badop = 0; int bio_pair = 0; int force = 0; int tls1 = 0, ssl2 = 0, ssl3 = 0, dtls1 = 0, ret = 1; int client_auth = 0; int server_auth = 0, i; struct app_verify_arg app_verify_arg = { APP_CALLBACK_STRING, 0, 0, NULL, NULL }; char *server_cert = TEST_SERVER_CERT; char *server_key = NULL; char *client_cert = TEST_CLIENT_CERT; char *client_key = NULL; #ifndef OPENSSL_NO_ECDH char *named_curve = NULL; #endif SSL_CTX *s_ctx = NULL; SSL_CTX *c_ctx = NULL; const SSL_METHOD *meth = NULL; SSL *c_ssl, *s_ssl; int number = 1, reuse = 0; long bytes = 256L; #ifndef OPENSSL_NO_DH DH *dh; int dhe1024 = 0, dhe1024dsa = 0; #endif #ifndef OPENSSL_NO_ECDH EC_KEY *ecdh = NULL; #endif int no_dhe = 0; int no_ecdhe = 0; int print_time = 0; clock_t s_time = 0, c_time = 0; int test_cipherlist = 0; verbose = 0; debug = 0; cipher = 0; bio_err = BIO_new_fp(stderr, BIO_NOCLOSE|BIO_FP_TEXT); CRYPTO_set_locking_callback(lock_dbg_cb); bio_stdout = BIO_new_fp(stdout, BIO_NOCLOSE|BIO_FP_TEXT); argc--; argv++; while (argc >= 1) { if (!strcmp(*argv, "-F")) { fprintf(stderr, "not compiled with FIPS support, so exitting without running.\n"); exit(0); } else if (strcmp(*argv, "-server_auth") == 0) server_auth = 1; else if (strcmp(*argv, "-client_auth") == 0) client_auth = 1; else if (strcmp(*argv, "-proxy_auth") == 0) { if (--argc < 1) goto bad; app_verify_arg.proxy_auth= *(++argv); } else if (strcmp(*argv, "-proxy_cond") == 0) { if (--argc < 1) goto bad; app_verify_arg.proxy_cond= *(++argv); } else if (strcmp(*argv, "-v") == 0) verbose = 1; else if (strcmp(*argv, "-d") == 0) debug = 1; else if (strcmp(*argv, "-reuse") == 0) reuse = 1; else if (strcmp(*argv, "-dhe1024") == 0) { #ifndef OPENSSL_NO_DH dhe1024 = 1; #else fprintf(stderr, "ignoring -dhe1024, since I'm compiled without DH\n"); #endif } else if (strcmp(*argv, "-dhe1024dsa") == 0) { #ifndef OPENSSL_NO_DH dhe1024dsa = 1; #else fprintf(stderr, "ignoring -dhe1024, since I'm compiled without DH\n"); #endif } else if (strcmp(*argv, "-no_dhe") == 0) no_dhe = 1; else if (strcmp(*argv, "-no_ecdhe") == 0) no_ecdhe = 1; else if (strcmp(*argv, "-dtls1") == 0) dtls1 = 1; else if (strcmp(*argv, "-ssl2") == 0) ssl2 = 1; else if (strcmp(*argv, "-ssl3") == 0) ssl3 = 1; else if (strcmp(*argv, "-tls1") == 0) tls1 = 1; else if (strncmp(*argv, "-num", 4) == 0) { if (--argc < 1) goto bad; number = atoi(*(++argv)); if (number == 0) number = 1; } else if (strcmp(*argv, "-bytes") == 0) { if (--argc < 1) goto bad; bytes = atol(*(++argv)); if (bytes == 0L) bytes = 1L; i = strlen(argv[0]); if (argv[0][i - 1] == 'k') bytes*=1024L; if (argv[0][i - 1] == 'm') bytes*=1024L*1024L; } else if (strcmp(*argv, "-cert") == 0) { if (--argc < 1) goto bad; server_cert= *(++argv); } else if (strcmp(*argv, "-s_cert") == 0) { if (--argc < 1) goto bad; server_cert= *(++argv); } else if (strcmp(*argv, "-key") == 0) { if (--argc < 1) goto bad; server_key= *(++argv); } else if (strcmp(*argv, "-s_key") == 0) { if (--argc < 1) goto bad; server_key= *(++argv); } else if (strcmp(*argv, "-c_cert") == 0) { if (--argc < 1) goto bad; client_cert= *(++argv); } else if (strcmp(*argv, "-c_key") == 0) { if (--argc < 1) goto bad; client_key= *(++argv); } else if (strcmp(*argv, "-cipher") == 0) { if (--argc < 1) goto bad; cipher= *(++argv); } else if (strcmp(*argv, "-CApath") == 0) { if (--argc < 1) goto bad; CApath= *(++argv); } else if (strcmp(*argv, "-CAfile") == 0) { if (--argc < 1) goto bad; CAfile= *(++argv); } else if (strcmp(*argv, "-bio_pair") == 0) { bio_pair = 1; } else if (strcmp(*argv, "-f") == 0) { force = 1; } else if (strcmp(*argv, "-time") == 0) { print_time = 1; } else if (strcmp(*argv, "-named_curve") == 0) { if (--argc < 1) goto bad; #ifndef OPENSSL_NO_ECDH named_curve = *(++argv); #else fprintf(stderr, "ignoring -named_curve, since I'm compiled without ECDH\n"); ++argv; #endif } else if (strcmp(*argv, "-app_verify") == 0) { app_verify_arg.app_verify = 1; } else if (strcmp(*argv, "-proxy") == 0) { app_verify_arg.allow_proxy_certs = 1; } else if (strcmp(*argv, "-test_cipherlist") == 0) { test_cipherlist = 1; } else { fprintf(stderr, "unknown option %s\n", *argv); badop = 1; break; } argc--; argv++; } if (badop) { bad: sv_usage(); goto end; } if (test_cipherlist == 1) { /* ensure that the cipher list are correctly sorted and exit */ if (do_test_cipherlist() == 0) exit(1); ret = 0; goto end; } if (!dtls1 && !ssl2 && !ssl3 && !tls1 && number > 1 && !reuse && !force) { fprintf(stderr, "This case cannot work. Use -f to perform " "the test anyway (and\n-d to see what happens), " "or add one of -dtls1, -ssl2, -ssl3, -tls1, -reuse\n" "to avoid protocol mismatch.\n"); exit(1); } if (print_time) { if (!bio_pair) { fprintf(stderr, "Using BIO pair (-bio_pair)\n"); bio_pair = 1; } if (number < 50 && !force) fprintf(stderr, "Warning: For accurate timings, use more connections (e.g. -num 1000)\n"); } /* if (cipher == NULL) cipher=getenv("SSL_CIPHER"); */ SSL_library_init(); SSL_load_error_strings(); if (dtls1) meth = DTLSv1_method(); else if (tls1) meth = TLSv1_method(); else if (ssl3) meth = SSLv3_method(); else meth = SSLv23_method(); c_ctx = SSL_CTX_new(meth); s_ctx = SSL_CTX_new(meth); if ((c_ctx == NULL) || (s_ctx == NULL)) { ERR_print_errors(bio_err); goto end; } if (cipher != NULL) { SSL_CTX_set_cipher_list(c_ctx, cipher); SSL_CTX_set_cipher_list(s_ctx, cipher); } #ifndef OPENSSL_NO_DH if (!no_dhe) { if (dhe1024dsa) { /* use SSL_OP_SINGLE_DH_USE to avoid small subgroup attacks */ SSL_CTX_set_options(s_ctx, SSL_OP_SINGLE_DH_USE); dh = get_dh1024dsa(); } else if (dhe1024) dh = get_dh1024(); else dh = get_dh512(); SSL_CTX_set_tmp_dh(s_ctx, dh); DH_free(dh); } #else (void)no_dhe; #endif #ifndef OPENSSL_NO_ECDH if (!no_ecdhe) { int nid; if (named_curve != NULL) { nid = OBJ_sn2nid(named_curve); if (nid == 0) { BIO_printf(bio_err, "unknown curve name (%s)\n", named_curve); goto end; } } else #ifdef OPENSSL_NO_EC2M nid = NID_X9_62_prime256v1; #else nid = NID_sect163r2; #endif ecdh = EC_KEY_new_by_curve_name(nid); if (ecdh == NULL) { BIO_printf(bio_err, "unable to create curve\n"); goto end; } SSL_CTX_set_tmp_ecdh(s_ctx, ecdh); SSL_CTX_set_options(s_ctx, SSL_OP_SINGLE_ECDH_USE); EC_KEY_free(ecdh); } #else (void)no_ecdhe; #endif SSL_CTX_set_tmp_rsa_callback(s_ctx, tmp_rsa_cb); if (!SSL_CTX_use_certificate_file(s_ctx, server_cert, SSL_FILETYPE_PEM)) { ERR_print_errors(bio_err); } else if (!SSL_CTX_use_PrivateKey_file(s_ctx, (server_key ? server_key : server_cert), SSL_FILETYPE_PEM)) { ERR_print_errors(bio_err); goto end; } if (client_auth) { SSL_CTX_use_certificate_file(c_ctx, client_cert, SSL_FILETYPE_PEM); SSL_CTX_use_PrivateKey_file(c_ctx, (client_key ? client_key : client_cert), SSL_FILETYPE_PEM); } if ((!SSL_CTX_load_verify_locations(s_ctx, CAfile, CApath)) || (!SSL_CTX_set_default_verify_paths(s_ctx)) || (!SSL_CTX_load_verify_locations(c_ctx, CAfile, CApath)) || (!SSL_CTX_set_default_verify_paths(c_ctx))) { /* fprintf(stderr,"SSL_load_verify_locations\n"); */ ERR_print_errors(bio_err); /* goto end; */ } if (client_auth) { BIO_printf(bio_err, "client authentication\n"); SSL_CTX_set_verify(s_ctx, SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT, verify_callback); SSL_CTX_set_cert_verify_callback(s_ctx, app_verify_callback, &app_verify_arg); } if (server_auth) { BIO_printf(bio_err, "server authentication\n"); SSL_CTX_set_verify(c_ctx, SSL_VERIFY_PEER, verify_callback); SSL_CTX_set_cert_verify_callback(c_ctx, app_verify_callback, &app_verify_arg); } { int session_id_context = 0; SSL_CTX_set_session_id_context(s_ctx, (void *)&session_id_context, sizeof session_id_context); } c_ssl = SSL_new(c_ctx); s_ssl = SSL_new(s_ctx); for (i = 0; i < number; i++) { if (!reuse) SSL_set_session(c_ssl, NULL); if (bio_pair) ret = doit_biopair(s_ssl, c_ssl, bytes, &s_time, &c_time); else ret = doit(s_ssl, c_ssl, bytes); } if (!verbose) { print_details(c_ssl, ""); } if ((number > 1) || (bytes > 1L)) BIO_printf(bio_stdout, "%d handshakes of %ld bytes done\n", number, bytes); if (print_time) { #ifdef CLOCKS_PER_SEC /* "To determine the time in seconds, the value returned * by the clock function should be divided by the value * of the macro CLOCKS_PER_SEC." * -- ISO/IEC 9899 */ BIO_printf(bio_stdout, "Approximate total server time: %6.2f s\n" "Approximate total client time: %6.2f s\n", (double)s_time/CLOCKS_PER_SEC, (double)c_time/CLOCKS_PER_SEC); #else /* "`CLOCKS_PER_SEC' undeclared (first use this function)" * -- cc on NeXTstep/OpenStep */ BIO_printf(bio_stdout, "Approximate total server time: %6.2f units\n" "Approximate total client time: %6.2f units\n", (double)s_time, (double)c_time); #endif } SSL_free(s_ssl); SSL_free(c_ssl); end: if (s_ctx != NULL) SSL_CTX_free(s_ctx); if (c_ctx != NULL) SSL_CTX_free(c_ctx); if (bio_stdout != NULL) BIO_free(bio_stdout); free_tmp_rsa(); #ifndef OPENSSL_NO_ENGINE ENGINE_cleanup(); #endif CRYPTO_cleanup_all_ex_data(); ERR_free_strings(); ERR_remove_thread_state(NULL); EVP_cleanup(); CRYPTO_mem_leaks(bio_err); if (bio_err != NULL) BIO_free(bio_err); exit(ret); return ret; } int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count, clock_t *s_time, clock_t *c_time) { long cw_num = count, cr_num = count, sw_num = count, sr_num = count; BIO *s_ssl_bio = NULL, *c_ssl_bio = NULL; BIO *server = NULL, *server_io = NULL, *client = NULL, *client_io = NULL; int ret = 1; size_t bufsiz = 256; /* small buffer for testing */ if (!BIO_new_bio_pair(&server, bufsiz, &server_io, bufsiz)) goto err; if (!BIO_new_bio_pair(&client, bufsiz, &client_io, bufsiz)) goto err; s_ssl_bio = BIO_new(BIO_f_ssl()); if (!s_ssl_bio) goto err; c_ssl_bio = BIO_new(BIO_f_ssl()); if (!c_ssl_bio) goto err; SSL_set_connect_state(c_ssl); SSL_set_bio(c_ssl, client, client); (void)BIO_set_ssl(c_ssl_bio, c_ssl, BIO_NOCLOSE); SSL_set_accept_state(s_ssl); SSL_set_bio(s_ssl, server, server); (void)BIO_set_ssl(s_ssl_bio, s_ssl, BIO_NOCLOSE); do { /* c_ssl_bio: SSL filter BIO * * client: pseudo-I/O for SSL library * * client_io: client's SSL communication; usually to be * relayed over some I/O facility, but in this * test program, we're the server, too: * * server_io: server's SSL communication * * server: pseudo-I/O for SSL library * * s_ssl_bio: SSL filter BIO * * The client and the server each employ a "BIO pair": * client + client_io, server + server_io. * BIO pairs are symmetric. A BIO pair behaves similar * to a non-blocking socketpair (but both endpoints must * be handled by the same thread). * [Here we could connect client and server to the ends * of a single BIO pair, but then this code would be less * suitable as an example for BIO pairs in general.] * * Useful functions for querying the state of BIO pair endpoints: * * BIO_ctrl_pending(bio) number of bytes we can read now * BIO_ctrl_get_read_request(bio) number of bytes needed to fulfil * other side's read attempt * BIO_ctrl_get_write_guarantee(bio) number of bytes we can write now * * ..._read_request is never more than ..._write_guarantee; * it depends on the application which one you should use. */ /* We have non-blocking behaviour throughout this test program, but * can be sure that there is *some* progress in each iteration; so * we don't have to worry about ..._SHOULD_READ or ..._SHOULD_WRITE * -- we just try everything in each iteration */ { /* CLIENT */ char cbuf[1024*8]; int i, r; clock_t c_clock = clock(); memset(cbuf, 0, sizeof(cbuf)); if (debug) if (SSL_in_init(c_ssl)) printf("client waiting in SSL_connect - %s\n", SSL_state_string_long(c_ssl)); if (cw_num > 0) { /* Write to server. */ if (cw_num > (long)sizeof cbuf) i = sizeof cbuf; else i = (int)cw_num; r = BIO_write(c_ssl_bio, cbuf, i); if (r < 0) { if (!BIO_should_retry(c_ssl_bio)) { fprintf(stderr, "ERROR in CLIENT\n"); goto err; } /* BIO_should_retry(...) can just be ignored here. * The library expects us to call BIO_write with * the same arguments again, and that's what we will * do in the next iteration. */ } else if (r == 0) { fprintf(stderr, "SSL CLIENT STARTUP FAILED\n"); goto err; } else { if (debug) printf("client wrote %d\n", r); cw_num -= r; } } if (cr_num > 0) { /* Read from server. */ r = BIO_read(c_ssl_bio, cbuf, sizeof(cbuf)); if (r < 0) { if (!BIO_should_retry(c_ssl_bio)) { fprintf(stderr, "ERROR in CLIENT\n"); goto err; } /* Again, "BIO_should_retry" can be ignored. */ } else if (r == 0) { fprintf(stderr, "SSL CLIENT STARTUP FAILED\n"); goto err; } else { if (debug) printf("client read %d\n", r); cr_num -= r; } } /* c_time and s_time increments will typically be very small * (depending on machine speed and clock tick intervals), * but sampling over a large number of connections should * result in fairly accurate figures. We cannot guarantee * a lot, however -- if each connection lasts for exactly * one clock tick, it will be counted only for the client * or only for the server or even not at all. */ *c_time += (clock() - c_clock); } { /* SERVER */ char sbuf[1024*8]; int i, r; clock_t s_clock = clock(); memset(sbuf, 0, sizeof(sbuf)); if (debug) if (SSL_in_init(s_ssl)) printf("server waiting in SSL_accept - %s\n", SSL_state_string_long(s_ssl)); if (sw_num > 0) { /* Write to client. */ if (sw_num > (long)sizeof sbuf) i = sizeof sbuf; else i = (int)sw_num; r = BIO_write(s_ssl_bio, sbuf, i); if (r < 0) { if (!BIO_should_retry(s_ssl_bio)) { fprintf(stderr, "ERROR in SERVER\n"); goto err; } /* Ignore "BIO_should_retry". */ } else if (r == 0) { fprintf(stderr, "SSL SERVER STARTUP FAILED\n"); goto err; } else { if (debug) printf("server wrote %d\n", r); sw_num -= r; } } if (sr_num > 0) { /* Read from client. */ r = BIO_read(s_ssl_bio, sbuf, sizeof(sbuf)); if (r < 0) { if (!BIO_should_retry(s_ssl_bio)) { fprintf(stderr, "ERROR in SERVER\n"); goto err; } /* blah, blah */ } else if (r == 0) { fprintf(stderr, "SSL SERVER STARTUP FAILED\n"); goto err; } else { if (debug) printf("server read %d\n", r); sr_num -= r; } } *s_time += (clock() - s_clock); } { /* "I/O" BETWEEN CLIENT AND SERVER. */ size_t r1, r2; BIO *io1 = server_io, *io2 = client_io; /* we use the non-copying interface for io1 * and the standard BIO_write/BIO_read interface for io2 */ static int prev_progress = 1; int progress = 0; /* io1 to io2 */ do { size_t num; int r; r1 = BIO_ctrl_pending(io1); r2 = BIO_ctrl_get_write_guarantee(io2); num = r1; if (r2 < num) num = r2; if (num) { char *dataptr; if (INT_MAX < num) /* yeah, right */ num = INT_MAX; r = BIO_nread(io1, &dataptr, (int)num); assert(r > 0); assert(r <= (int)num); /* possibly r < num (non-contiguous data) */ num = r; r = BIO_write(io2, dataptr, (int)num); if (r != (int)num) /* can't happen */ { fprintf(stderr, "ERROR: BIO_write could not write " "BIO_ctrl_get_write_guarantee() bytes"); goto err; } progress = 1; if (debug) printf((io1 == client_io) ? "C->S relaying: %d bytes\n" : "S->C relaying: %d bytes\n", (int)num); } } while (r1 && r2); /* io2 to io1 */ { size_t num; int r; r1 = BIO_ctrl_pending(io2); r2 = BIO_ctrl_get_read_request(io1); /* here we could use ..._get_write_guarantee instead of * ..._get_read_request, but by using the latter * we test restartability of the SSL implementation * more thoroughly */ num = r1; if (r2 < num) num = r2; if (num) { char *dataptr; if (INT_MAX < num) num = INT_MAX; if (num > 1) --num; /* test restartability even more thoroughly */ r = BIO_nwrite0(io1, &dataptr); assert(r > 0); if (r < (int)num) num = r; r = BIO_read(io2, dataptr, (int)num); if (r != (int)num) /* can't happen */ { fprintf(stderr, "ERROR: BIO_read could not read " "BIO_ctrl_pending() bytes"); goto err; } progress = 1; r = BIO_nwrite(io1, &dataptr, (int)num); if (r != (int)num) /* can't happen */ { fprintf(stderr, "ERROR: BIO_nwrite() did not accept " "BIO_nwrite0() bytes"); goto err; } if (debug) printf((io2 == client_io) ? "C->S relaying: %d bytes\n" : "S->C relaying: %d bytes\n", (int)num); } } /* no loop, BIO_ctrl_get_read_request now returns 0 anyway */ if (!progress && !prev_progress) if (cw_num > 0 || cr_num > 0 || sw_num > 0 || sr_num > 0) { fprintf(stderr, "ERROR: got stuck\n"); if (strcmp("SSLv2", SSL_get_version(c_ssl)) == 0) { fprintf(stderr, "This can happen for SSL2 because " "CLIENT-FINISHED and SERVER-VERIFY are written \n" "concurrently ..."); if (strncmp("2SCF", SSL_state_string(c_ssl), 4) == 0 && strncmp("2SSV", SSL_state_string(s_ssl), 4) == 0) { fprintf(stderr, " ok.\n"); goto end; } } fprintf(stderr, " ERROR.\n"); goto err; } prev_progress = progress; } } while (cw_num > 0 || cr_num > 0 || sw_num > 0 || sr_num > 0); if (verbose) print_details(c_ssl, "DONE via BIO pair: "); end: ret = 0; err: ERR_print_errors(bio_err); if (server) BIO_free(server); if (server_io) BIO_free(server_io); if (client) BIO_free(client); if (client_io) BIO_free(client_io); if (s_ssl_bio) BIO_free(s_ssl_bio); if (c_ssl_bio) BIO_free(c_ssl_bio); return ret; } #define W_READ 1 #define W_WRITE 2 #define C_DONE 1 #define S_DONE 2 int doit(SSL *s_ssl, SSL *c_ssl, long count) { char cbuf[1024*8], sbuf[1024*8]; long cw_num = count, cr_num = count; long sw_num = count, sr_num = count; int ret = 1; BIO *c_to_s = NULL; BIO *s_to_c = NULL; BIO *c_bio = NULL; BIO *s_bio = NULL; int c_r, c_w, s_r, s_w; int i, j; int done = 0; int c_write, s_write; int do_server = 0, do_client = 0; memset(cbuf, 0, sizeof(cbuf)); memset(sbuf, 0, sizeof(sbuf)); c_to_s = BIO_new(BIO_s_mem()); s_to_c = BIO_new(BIO_s_mem()); if ((s_to_c == NULL) || (c_to_s == NULL)) { ERR_print_errors(bio_err); goto err; } c_bio = BIO_new(BIO_f_ssl()); s_bio = BIO_new(BIO_f_ssl()); if ((c_bio == NULL) || (s_bio == NULL)) { ERR_print_errors(bio_err); goto err; } SSL_set_connect_state(c_ssl); SSL_set_bio(c_ssl, s_to_c, c_to_s); BIO_set_ssl(c_bio, c_ssl, BIO_NOCLOSE); SSL_set_accept_state(s_ssl); SSL_set_bio(s_ssl, c_to_s, s_to_c); BIO_set_ssl(s_bio, s_ssl, BIO_NOCLOSE); c_r = 0; s_r = 1; c_w = 1; s_w = 0; c_write = 1, s_write = 0; /* We can always do writes */ for (;;) { do_server = 0; do_client = 0; i = (int)BIO_pending(s_bio); if ((i && s_r) || s_w) do_server = 1; i = (int)BIO_pending(c_bio); if ((i && c_r) || c_w) do_client = 1; if (do_server && debug) { if (SSL_in_init(s_ssl)) printf("server waiting in SSL_accept - %s\n", SSL_state_string_long(s_ssl)); /* else if (s_write) printf("server:SSL_write()\n"); else printf("server:SSL_read()\n"); */ } if (do_client && debug) { if (SSL_in_init(c_ssl)) printf("client waiting in SSL_connect - %s\n", SSL_state_string_long(c_ssl)); /* else if (c_write) printf("client:SSL_write()\n"); else printf("client:SSL_read()\n"); */ } if (!do_client && !do_server) { fprintf(stdout, "ERROR IN STARTUP\n"); ERR_print_errors(bio_err); break; } if (do_client && !(done & C_DONE)) { if (c_write) { j = (cw_num > (long)sizeof(cbuf)) ? (int)sizeof(cbuf) : (int)cw_num; i = BIO_write(c_bio, cbuf, j); if (i < 0) { c_r = 0; c_w = 0; if (BIO_should_retry(c_bio)) { if (BIO_should_read(c_bio)) c_r = 1; if (BIO_should_write(c_bio)) c_w = 1; } else { fprintf(stderr, "ERROR in CLIENT\n"); ERR_print_errors(bio_err); goto err; } } else if (i == 0) { fprintf(stderr, "SSL CLIENT STARTUP FAILED\n"); goto err; } else { if (debug) printf("client wrote %d\n", i); /* ok */ s_r = 1; c_write = 0; cw_num -= i; } } else { i = BIO_read(c_bio, cbuf, sizeof(cbuf)); if (i < 0) { c_r = 0; c_w = 0; if (BIO_should_retry(c_bio)) { if (BIO_should_read(c_bio)) c_r = 1; if (BIO_should_write(c_bio)) c_w = 1; } else { fprintf(stderr, "ERROR in CLIENT\n"); ERR_print_errors(bio_err); goto err; } } else if (i == 0) { fprintf(stderr, "SSL CLIENT STARTUP FAILED\n"); goto err; } else { if (debug) printf("client read %d\n", i); cr_num -= i; if (sw_num > 0) { s_write = 1; s_w = 1; } if (cr_num <= 0) { s_write = 1; s_w = 1; done = S_DONE|C_DONE; } } } } if (do_server && !(done & S_DONE)) { if (!s_write) { i = BIO_read(s_bio, sbuf, sizeof(cbuf)); if (i < 0) { s_r = 0; s_w = 0; if (BIO_should_retry(s_bio)) { if (BIO_should_read(s_bio)) s_r = 1; if (BIO_should_write(s_bio)) s_w = 1; } else { fprintf(stderr, "ERROR in SERVER\n"); ERR_print_errors(bio_err); goto err; } } else if (i == 0) { ERR_print_errors(bio_err); fprintf(stderr, "SSL SERVER STARTUP FAILED in SSL_read\n"); goto err; } else { if (debug) printf("server read %d\n", i); sr_num -= i; if (cw_num > 0) { c_write = 1; c_w = 1; } if (sr_num <= 0) { s_write = 1; s_w = 1; c_write = 0; } } } else { j = (sw_num > (long)sizeof(sbuf)) ? (int)sizeof(sbuf) : (int)sw_num; i = BIO_write(s_bio, sbuf, j); if (i < 0) { s_r = 0; s_w = 0; if (BIO_should_retry(s_bio)) { if (BIO_should_read(s_bio)) s_r = 1; if (BIO_should_write(s_bio)) s_w = 1; } else { fprintf(stderr, "ERROR in SERVER\n"); ERR_print_errors(bio_err); goto err; } } else if (i == 0) { ERR_print_errors(bio_err); fprintf(stderr, "SSL SERVER STARTUP FAILED in SSL_write\n"); goto err; } else { if (debug) printf("server wrote %d\n", i); sw_num -= i; s_write = 0; c_r = 1; if (sw_num <= 0) done|=S_DONE; } } } if ((done & S_DONE) && (done & C_DONE)) break; } if (verbose) print_details(c_ssl, "DONE: "); ret = 0; err: /* We have to set the BIO's to NULL otherwise they will be * free()ed twice. Once when th s_ssl is SSL_free()ed and * again when c_ssl is SSL_free()ed. * This is a hack required because s_ssl and c_ssl are sharing the same * BIO structure and SSL_set_bio() and SSL_free() automatically * BIO_free non NULL entries. * You should not normally do this or be required to do this */ if (s_ssl != NULL) { s_ssl->rbio = NULL; s_ssl->wbio = NULL; } if (c_ssl != NULL) { c_ssl->rbio = NULL; c_ssl->wbio = NULL; } if (c_to_s != NULL) BIO_free(c_to_s); if (s_to_c != NULL) BIO_free(s_to_c); if (c_bio != NULL) BIO_free_all(c_bio); if (s_bio != NULL) BIO_free_all(s_bio); return (ret); } static int get_proxy_auth_ex_data_idx(void) { static volatile int idx = -1; if (idx < 0) { CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); if (idx < 0) { idx = X509_STORE_CTX_get_ex_new_index(0, "SSLtest for verify callback", NULL, NULL, NULL); } CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); } return idx; } static int verify_callback(int ok, X509_STORE_CTX *ctx) { char *s, buf[256]; s = X509_NAME_oneline(X509_get_subject_name(ctx->current_cert), buf, sizeof buf); if (s != NULL) { if (ok) fprintf(stderr, "depth=%d %s\n", ctx->error_depth, buf); else { fprintf(stderr, "depth=%d error=%d %s\n", ctx->error_depth, ctx->error, buf); } } if (ok == 0) { fprintf(stderr, "Error string: %s\n", X509_verify_cert_error_string(ctx->error)); switch (ctx->error) { case X509_V_ERR_CERT_NOT_YET_VALID: case X509_V_ERR_CERT_HAS_EXPIRED: case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: fprintf(stderr, " ... ignored.\n"); ok = 1; } } if (ok == 1) { X509 *xs = ctx->current_cert; #if 0 X509 *xi = ctx->current_issuer; #endif if (xs->ex_flags & EXFLAG_PROXY) { unsigned int *letters = X509_STORE_CTX_get_ex_data(ctx, get_proxy_auth_ex_data_idx()); if (letters) { int found_any = 0; int i; PROXY_CERT_INFO_EXTENSION *pci = X509_get_ext_d2i(xs, NID_proxyCertInfo, NULL, NULL); switch (OBJ_obj2nid(pci->proxyPolicy->policyLanguage)) { case NID_Independent: /* Completely meaningless in this program, as there's no way to grant explicit rights to a specific PrC. Basically, using id-ppl-Independent is the perfect way to grant no rights at all. */ fprintf(stderr, " Independent proxy certificate"); for (i = 0; i < 26; i++) letters[i] = 0; break; case NID_id_ppl_inheritAll: /* This is basically a NOP, we simply let the current rights stand as they are. */ fprintf(stderr, " Proxy certificate inherits all"); break; default: s = (char *) pci->proxyPolicy->policy->data; i = pci->proxyPolicy->policy->length; /* The algorithm works as follows: it is assumed that previous iterations or the initial granted rights has already set some elements of `letters'. What we need to do is to clear those that weren't granted by the current PrC as well. The easiest way to do this is to add 1 to all the elements whose letters are given with the current policy. That way, all elements that are set by the current policy and were already set by earlier policies and through the original grant of rights will get the value 2 or higher. The last thing to do is to sweep through `letters' and keep the elements having the value 2 as set, and clear all the others. */ fprintf(stderr, " Certificate proxy rights = %*.*s", i, i, s); while (i-- > 0) { int c = *s++; if (isascii(c) && isalpha(c)) { if (islower(c)) c = toupper(c); letters[c - 'A']++; } } for (i = 0; i < 26; i++) if (letters[i] < 2) letters[i] = 0; else letters[i] = 1; } found_any = 0; fprintf(stderr, ", resulting proxy rights = "); for (i = 0; i < 26; i++) if (letters[i]) { fprintf(stderr, "%c", i + 'A'); found_any = 1; } if (!found_any) fprintf(stderr, "none"); fprintf(stderr, "\n"); PROXY_CERT_INFO_EXTENSION_free(pci); } } } return (ok); } static void process_proxy_debug(int indent, const char *format, ...) { static const char indentation[] = ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"; /* That's 80 > */ char my_format[256]; va_list args; (void) snprintf(my_format, sizeof(my_format), "%*.*s %s", indent, indent, indentation, format); va_start(args, format); vfprintf(stderr, my_format, args); va_end(args); } /* Priority levels: 0 [!]var, () 1 & ^ 2 | */ static int process_proxy_cond_adders(unsigned int letters[26], const char *cond, const char **cond_end, int *pos, int indent); static int process_proxy_cond_val(unsigned int letters[26], const char *cond, const char **cond_end, int *pos, int indent) { int c; int ok = 1; int negate = 0; while (isspace((int)*cond)) { cond++; (*pos)++; } c = *cond; if (debug) process_proxy_debug(indent, "Start process_proxy_cond_val at position %d: %s\n", *pos, cond); while (c == '!') { negate = !negate; cond++; (*pos)++; while (isspace((int)*cond)) { cond++; (*pos)++; } c = *cond; } if (c == '(') { cond++; (*pos)++; ok = process_proxy_cond_adders(letters, cond, cond_end, pos, indent + 1); cond = *cond_end; if (ok < 0) goto end; while (isspace((int)*cond)) { cond++; (*pos)++; } c = *cond; if (c != ')') { fprintf(stderr, "Weird condition character in position %d: " "%c\n", *pos, c); ok = -1; goto end; } cond++; (*pos)++; } else if (isascii(c) && isalpha(c)) { if (islower(c)) c = toupper(c); ok = letters[c - 'A']; cond++; (*pos)++; } else { fprintf(stderr, "Weird condition character in position %d: " "%c\n", *pos, c); ok = -1; goto end; } end: *cond_end = cond; if (ok >= 0 && negate) ok = !ok; if (debug) process_proxy_debug(indent, "End process_proxy_cond_val at position %d: %s, returning %d\n", *pos, cond, ok); return ok; } static int process_proxy_cond_multipliers(unsigned int letters[26], const char *cond, const char **cond_end, int *pos, int indent) { int ok; char c; if (debug) process_proxy_debug(indent, "Start process_proxy_cond_multipliers at position %d: %s\n", *pos, cond); ok = process_proxy_cond_val(letters, cond, cond_end, pos, indent + 1); cond = *cond_end; if (ok < 0) goto end; while (ok >= 0) { while (isspace((int)*cond)) { cond++; (*pos)++; } c = *cond; switch (c) { case '&': case '^': { int save_ok = ok; cond++; (*pos)++; ok = process_proxy_cond_val(letters, cond, cond_end, pos, indent + 1); cond = *cond_end; if (ok < 0) break; switch (c) { case '&': ok &= save_ok; break; case '^': ok ^= save_ok; break; default: fprintf(stderr, "SOMETHING IS SERIOUSLY WRONG!" " STOPPING\n"); exit(1); } } break; default: goto end; } } end: if (debug) process_proxy_debug(indent, "End process_proxy_cond_multipliers at position %d: %s, returning %d\n", *pos, cond, ok); *cond_end = cond; return ok; } static int process_proxy_cond_adders(unsigned int letters[26], const char *cond, const char **cond_end, int *pos, int indent) { int ok; char c; if (debug) process_proxy_debug(indent, "Start process_proxy_cond_adders at position %d: %s\n", *pos, cond); ok = process_proxy_cond_multipliers(letters, cond, cond_end, pos, indent + 1); cond = *cond_end; if (ok < 0) goto end; while (ok >= 0) { while (isspace((int)*cond)) { cond++; (*pos)++; } c = *cond; switch (c) { case '|': { int save_ok = ok; cond++; (*pos)++; ok = process_proxy_cond_multipliers(letters, cond, cond_end, pos, indent + 1); cond = *cond_end; if (ok < 0) break; switch (c) { case '|': ok |= save_ok; break; default: fprintf(stderr, "SOMETHING IS SERIOUSLY WRONG!" " STOPPING\n"); exit(1); } } break; default: goto end; } } end: if (debug) process_proxy_debug(indent, "End process_proxy_cond_adders at position %d: %s, returning %d\n", *pos, cond, ok); *cond_end = cond; return ok; } static int process_proxy_cond(unsigned int letters[26], const char *cond, const char **cond_end) { int pos = 1; return process_proxy_cond_adders(letters, cond, cond_end, &pos, 1); } static int app_verify_callback(X509_STORE_CTX *ctx, void *arg) { int ok = 1; struct app_verify_arg *cb_arg = arg; unsigned int letters[26]; /* only used with proxy_auth */ if (cb_arg->app_verify) { char *s = NULL, buf[256]; fprintf(stderr, "In app_verify_callback, allowing cert. "); fprintf(stderr, "Arg is: %s\n", cb_arg->string); fprintf(stderr, "Finished printing do we have a context? 0x%p a cert? 0x%p\n", (void *)ctx, (void *)ctx->cert); if (ctx->cert) s = X509_NAME_oneline(X509_get_subject_name(ctx->cert), buf, 256); if (s != NULL) { fprintf(stderr, "cert depth=%d %s\n", ctx->error_depth, buf); } return (1); } if (cb_arg->proxy_auth) { int found_any = 0, i; char *sp; for (i = 0; i < 26; i++) letters[i] = 0; for (sp = cb_arg->proxy_auth; *sp; sp++) { int c = *sp; if (isascii(c) && isalpha(c)) { if (islower(c)) c = toupper(c); letters[c - 'A'] = 1; } } fprintf(stderr, " Initial proxy rights = "); for (i = 0; i < 26; i++) if (letters[i]) { fprintf(stderr, "%c", i + 'A'); found_any = 1; } if (!found_any) fprintf(stderr, "none"); fprintf(stderr, "\n"); X509_STORE_CTX_set_ex_data(ctx, get_proxy_auth_ex_data_idx(), letters); } if (cb_arg->allow_proxy_certs) { X509_STORE_CTX_set_flags(ctx, X509_V_FLAG_ALLOW_PROXY_CERTS); } #ifndef OPENSSL_NO_X509_VERIFY ok = X509_verify_cert(ctx); #endif if (cb_arg->proxy_auth) { if (ok > 0) { const char *cond_end = NULL; ok = process_proxy_cond(letters, cb_arg->proxy_cond, &cond_end); if (ok < 0) exit(3); if (*cond_end) { fprintf(stderr, "Stopped processing condition before it's end.\n"); ok = 0; } if (!ok) fprintf(stderr, "Proxy rights check with condition '%s' proved invalid\n", cb_arg->proxy_cond); else fprintf(stderr, "Proxy rights check with condition '%s' proved valid\n", cb_arg->proxy_cond); } } return (ok); } static RSA *rsa_tmp = NULL; static RSA * tmp_rsa_cb(SSL *s, int is_export, int keylength) { BIGNUM *bn = NULL; if (rsa_tmp == NULL) { bn = BN_new(); rsa_tmp = RSA_new(); if (!bn || !rsa_tmp || !BN_set_word(bn, RSA_F4)) { BIO_printf(bio_err, "Memory error..."); goto end; } BIO_printf(bio_err, "Generating temp (%d bit) RSA key...", keylength); (void)BIO_flush(bio_err); if (!RSA_generate_key_ex(rsa_tmp, keylength, bn, NULL)) { BIO_printf(bio_err, "Error generating key."); RSA_free(rsa_tmp); rsa_tmp = NULL; } end: BIO_printf(bio_err, "\n"); (void)BIO_flush(bio_err); } if (bn) BN_free(bn); return (rsa_tmp); } static void free_tmp_rsa(void) { if (rsa_tmp != NULL) { RSA_free(rsa_tmp); rsa_tmp = NULL; } } #ifndef OPENSSL_NO_DH /* These DH parameters have been generated as follows: * $ openssl dhparam -C -noout 512 * $ openssl dhparam -C -noout 1024 * $ openssl dhparam -C -noout -dsaparam 1024 * (The third function has been renamed to avoid name conflicts.) */ static DH * get_dh512() { static unsigned char dh512_p[] = { 0xCB, 0xC8, 0xE1, 0x86, 0xD0, 0x1F, 0x94, 0x17, 0xA6, 0x99, 0xF0, 0xC6, 0x1F, 0x0D, 0xAC, 0xB6, 0x25, 0x3E, 0x06, 0x39, 0xCA, 0x72, 0x04, 0xB0, 0x6E, 0xDA, 0xC0, 0x61, 0xE6, 0x7A, 0x77, 0x25, 0xE8, 0x3B, 0xB9, 0x5F, 0x9A, 0xB6, 0xB5, 0xFE, 0x99, 0x0B, 0xA1, 0x93, 0x4E, 0x35, 0x33, 0xB8, 0xE1, 0xF1, 0x13, 0x4F, 0x59, 0x1A, 0xD2, 0x57, 0xC0, 0x26, 0x21, 0x33, 0x02, 0xC5, 0xAE, 0x23, }; static unsigned char dh512_g[] = { 0x02, }; DH *dh; if ((dh = DH_new()) == NULL) return (NULL); dh->p = BN_bin2bn(dh512_p, sizeof(dh512_p), NULL); dh->g = BN_bin2bn(dh512_g, sizeof(dh512_g), NULL); if ((dh->p == NULL) || (dh->g == NULL)) { DH_free(dh); return (NULL); } return (dh); } static DH * get_dh1024() { static unsigned char dh1024_p[] = { 0xF8, 0x81, 0x89, 0x7D, 0x14, 0x24, 0xC5, 0xD1, 0xE6, 0xF7, 0xBF, 0x3A, 0xE4, 0x90, 0xF4, 0xFC, 0x73, 0xFB, 0x34, 0xB5, 0xFA, 0x4C, 0x56, 0xA2, 0xEA, 0xA7, 0xE9, 0xC0, 0xC0, 0xCE, 0x89, 0xE1, 0xFA, 0x63, 0x3F, 0xB0, 0x6B, 0x32, 0x66, 0xF1, 0xD1, 0x7B, 0xB0, 0x00, 0x8F, 0xCA, 0x87, 0xC2, 0xAE, 0x98, 0x89, 0x26, 0x17, 0xC2, 0x05, 0xD2, 0xEC, 0x08, 0xD0, 0x8C, 0xFF, 0x17, 0x52, 0x8C, 0xC5, 0x07, 0x93, 0x03, 0xB1, 0xF6, 0x2F, 0xB8, 0x1C, 0x52, 0x47, 0x27, 0x1B, 0xDB, 0xD1, 0x8D, 0x9D, 0x69, 0x1D, 0x52, 0x4B, 0x32, 0x81, 0xAA, 0x7F, 0x00, 0xC8, 0xDC, 0xE6, 0xD9, 0xCC, 0xC1, 0x11, 0x2D, 0x37, 0x34, 0x6C, 0xEA, 0x02, 0x97, 0x4B, 0x0E, 0xBB, 0xB1, 0x71, 0x33, 0x09, 0x15, 0xFD, 0xDD, 0x23, 0x87, 0x07, 0x5E, 0x89, 0xAB, 0x6B, 0x7C, 0x5F, 0xEC, 0xA6, 0x24, 0xDC, 0x53, }; static unsigned char dh1024_g[] = { 0x02, }; DH *dh; if ((dh = DH_new()) == NULL) return (NULL); dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL); dh->g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), NULL); if ((dh->p == NULL) || (dh->g == NULL)) { DH_free(dh); return (NULL); } return (dh); } static DH * get_dh1024dsa() { static unsigned char dh1024_p[] = { 0xC8, 0x00, 0xF7, 0x08, 0x07, 0x89, 0x4D, 0x90, 0x53, 0xF3, 0xD5, 0x00, 0x21, 0x1B, 0xF7, 0x31, 0xA6, 0xA2, 0xDA, 0x23, 0x9A, 0xC7, 0x87, 0x19, 0x3B, 0x47, 0xB6, 0x8C, 0x04, 0x6F, 0xFF, 0xC6, 0x9B, 0xB8, 0x65, 0xD2, 0xC2, 0x5F, 0x31, 0x83, 0x4A, 0xA7, 0x5F, 0x2F, 0x88, 0x38, 0xB6, 0x55, 0xCF, 0xD9, 0x87, 0x6D, 0x6F, 0x9F, 0xDA, 0xAC, 0xA6, 0x48, 0xAF, 0xFC, 0x33, 0x84, 0x37, 0x5B, 0x82, 0x4A, 0x31, 0x5D, 0xE7, 0xBD, 0x52, 0x97, 0xA1, 0x77, 0xBF, 0x10, 0x9E, 0x37, 0xEA, 0x64, 0xFA, 0xCA, 0x28, 0x8D, 0x9D, 0x3B, 0xD2, 0x6E, 0x09, 0x5C, 0x68, 0xC7, 0x45, 0x90, 0xFD, 0xBB, 0x70, 0xC9, 0x3A, 0xBB, 0xDF, 0xD4, 0x21, 0x0F, 0xC4, 0x6A, 0x3C, 0xF6, 0x61, 0xCF, 0x3F, 0xD6, 0x13, 0xF1, 0x5F, 0xBC, 0xCF, 0xBC, 0x26, 0x9E, 0xBC, 0x0B, 0xBD, 0xAB, 0x5D, 0xC9, 0x54, 0x39, }; static unsigned char dh1024_g[] = { 0x3B, 0x40, 0x86, 0xE7, 0xF3, 0x6C, 0xDE, 0x67, 0x1C, 0xCC, 0x80, 0x05, 0x5A, 0xDF, 0xFE, 0xBD, 0x20, 0x27, 0x74, 0x6C, 0x24, 0xC9, 0x03, 0xF3, 0xE1, 0x8D, 0xC3, 0x7D, 0x98, 0x27, 0x40, 0x08, 0xB8, 0x8C, 0x6A, 0xE9, 0xBB, 0x1A, 0x3A, 0xD6, 0x86, 0x83, 0x5E, 0x72, 0x41, 0xCE, 0x85, 0x3C, 0xD2, 0xB3, 0xFC, 0x13, 0xCE, 0x37, 0x81, 0x9E, 0x4C, 0x1C, 0x7B, 0x65, 0xD3, 0xE6, 0xA6, 0x00, 0xF5, 0x5A, 0x95, 0x43, 0x5E, 0x81, 0xCF, 0x60, 0xA2, 0x23, 0xFC, 0x36, 0xA7, 0x5D, 0x7A, 0x4C, 0x06, 0x91, 0x6E, 0xF6, 0x57, 0xEE, 0x36, 0xCB, 0x06, 0xEA, 0xF5, 0x3D, 0x95, 0x49, 0xCB, 0xA7, 0xDD, 0x81, 0xDF, 0x80, 0x09, 0x4A, 0x97, 0x4D, 0xA8, 0x22, 0x72, 0xA1, 0x7F, 0xC4, 0x70, 0x56, 0x70, 0xE8, 0x20, 0x10, 0x18, 0x8F, 0x2E, 0x60, 0x07, 0xE7, 0x68, 0x1A, 0x82, 0x5D, 0x32, 0xA2, }; DH *dh; if ((dh = DH_new()) == NULL) return (NULL); dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL); dh->g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), NULL); if ((dh->p == NULL) || (dh->g == NULL)) { DH_free(dh); return (NULL); } dh->length = 160; return (dh); } #endif static int do_test_cipherlist(void) { int i = 0; const SSL_METHOD *meth; const SSL_CIPHER *ci, *tci = NULL; fprintf(stderr, "testing SSLv3 cipher list order: "); meth = SSLv3_method(); tci = NULL; while ((ci = meth->get_cipher(i++)) != NULL) { if (tci != NULL) if (ci->id >= tci->id) { fprintf(stderr, "failed %lx vs. %lx\n", ci->id, tci->id); return 0; } tci = ci; } fprintf(stderr, "ok\n"); fprintf(stderr, "testing TLSv1 cipher list order: "); meth = TLSv1_method(); tci = NULL; while ((ci = meth->get_cipher(i++)) != NULL) { if (tci != NULL) if (ci->id >= tci->id) { fprintf(stderr, "failed %lx vs. %lx\n", ci->id, tci->id); return 0; } tci = ci; } fprintf(stderr, "ok\n"); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/pkcs7test.c0000644000175000017500000002225512360020706020177 0ustar /* $OpenBSD: pkcs7test.c,v 1.1 2014/07/02 16:29:36 jsing Exp $ */ /* * Copyright (c) 2014 Joel Sing * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include #include #include #include #include const char certificate[] = "\ -----BEGIN CERTIFICATE----- \n\ MIIDpTCCAo2gAwIBAgIJAPYm3GvOr5eTMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV \n\ BAYTAlVLMRYwFAYDVQQKDA1PcGVuU1NMIEdyb3VwMSIwIAYDVQQLDBlGT1IgVEVT \n\ VElORyBQVVJQT1NFUyBPTkxZMSUwIwYDVQQDDBxPcGVuU1NMIFRlc3QgSW50ZXJt \n\ ZWRpYXRlIENBMB4XDTE0MDUyNDE0NDUxMVoXDTI0MDQwMTE0NDUxMVowZDELMAkG \n\ A1UEBhMCVUsxFjAUBgNVBAoMDU9wZW5TU0wgR3JvdXAxIjAgBgNVBAsMGUZPUiBU \n\ RVNUSU5HIFBVUlBPU0VTIE9OTFkxGTAXBgNVBAMMEFRlc3QgQ2xpZW50IENlcnQw \n\ ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC0ranbHRLcLVqN+0BzcZpY \n\ +yOLqxzDWT1LD9eW1stC4NzXX9/DCtSIVyN7YIHdGLrIPr64IDdXXaMRzgZ2rOKs \n\ lmHCAiFpO/ja99gGCJRxH0xwQatqAULfJVHeUhs7OEGOZc2nWifjqKvGfNTilP7D \n\ nwi69ipQFq9oS19FmhwVHk2wg7KZGHI1qDyG04UrfCZMRitvS9+UVhPpIPjuiBi2 \n\ x3/FZIpL5gXJvvFK6xHY63oq2asyzBATntBgnP4qJFWWcvRx24wF1PnZabxuVoL2 \n\ bPnQ/KvONDrw3IdqkKhYNTul7jEcu3OlcZIMw+7DiaKJLAzKb/bBF5gm/pwW6As9 \n\ AgMBAAGjTjBMMAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgXgMCwGCWCGSAGG \n\ +EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTANBgkqhkiG9w0B \n\ AQUFAAOCAQEAJzA4KTjkjXGSC4He63yX9Br0DneGBzjAwc1H6f72uqnCs8m7jgkE \n\ PQJFdTzQUKh97QPUuayZ2gl8XHagg+iWGy60Kw37gQ0+lumCN2sllvifhHU9R03H \n\ bWtS4kue+yQjMbrzf3zWygMDgwvFOUAIgBpH9qGc+CdNu97INTYd0Mvz51vLlxRn \n\ sC5aBYCWaZFnw3lWYxf9eVFRy9U+DkYFqX0LpmbDtcKP7AZGE6ZwSzaim+Cnoz1u \n\ Cgn+QmpFXgJKMFIZ82iSZISn+JkCCGxctZX1lMvai4Wi8Y0HxW9FTFZ6KBNwwE4B \n\ zjbN/ehBkgLlW/DWfi44DvwUHmuU6QP3cw== \n\ -----END CERTIFICATE----- \n\ "; const char private_key[] = "\ -----BEGIN RSA PRIVATE KEY----- \n\ MIIEpQIBAAKCAQEAtK2p2x0S3C1ajftAc3GaWPsji6scw1k9Sw/XltbLQuDc11/f \n\ wwrUiFcje2CB3Ri6yD6+uCA3V12jEc4GdqzirJZhwgIhaTv42vfYBgiUcR9McEGr \n\ agFC3yVR3lIbOzhBjmXNp1on46irxnzU4pT+w58IuvYqUBavaEtfRZocFR5NsIOy \n\ mRhyNag8htOFK3wmTEYrb0vflFYT6SD47ogYtsd/xWSKS+YFyb7xSusR2Ot6Ktmr \n\ MswQE57QYJz+KiRVlnL0cduMBdT52Wm8blaC9mz50PyrzjQ68NyHapCoWDU7pe4x \n\ HLtzpXGSDMPuw4miiSwMym/2wReYJv6cFugLPQIDAQABAoIBAAZOyc9MhIwLSU4L \n\ p4RgQvM4UVVe8/Id+3XTZ8NsXExJbWxXfIhiqGjaIfL8u4vsgRjcl+v1s/jo2/iT \n\ KMab4o4D8gXD7UavQVDjtjb/ta79WL3SjRl2Uc9YjjMkyq6WmDNQeo2NKDdafCTB \n\ 1uzSJtLNipB8Z53ELPuHJhxX9QMHrMnuha49riQgXZ7buP9iQrHJFhImBjSzbxJx \n\ L+TI6rkyLSf9Wi0Pd3L27Ob3QWNfNRYNSeTE+08eSRChkur5W0RuXAcuAICdQlCl \n\ LBvWO/LmmvbzCqiDcgy/TliSb6CGGwgiNG7LJZmlkYNj8laGwalNlYZs3UrVv6NO \n\ Br2loAECgYEA2kvCvPGj0Dg/6g7WhXDvAkEbcaL1tSeCxBbNH+6HS2UWMWvyTtCn \n\ /bbD519QIdkvayy1QjEf32GV/UjUVmlULMLBcDy0DGjtL3+XpIhLKWDNxN1v1/ai \n\ 1oz23ZJCOgnk6K4qtFtlRS1XtynjA+rBetvYvLP9SKeFrnpzCgaA2r0CgYEA0+KX \n\ 1ACXDTNH5ySX3kMjSS9xdINf+OOw4CvPHFwbtc9aqk2HePlEsBTz5I/W3rKwXva3 \n\ NqZ/bRqVVeZB/hHKFywgdUQk2Uc5z/S7Lw70/w1HubNTXGU06Ngb6zOFAo/o/TwZ \n\ zTP1BMIKSOB6PAZPS3l+aLO4FRIRotfFhgRHOoECgYEAmiZbqt8cJaJDB/5YYDzC \n\ mp3tSk6gIb936Q6M5VqkMYp9pIKsxhk0N8aDCnTU+kIK6SzWBpr3/d9Ecmqmfyq7 \n\ 5SvWO3KyVf0WWK9KH0abhOm2BKm2HBQvI0DB5u8sUx2/hsvOnjPYDISbZ11t0MtK \n\ u35Zy89yMYcSsIYJjG/ROCUCgYEAgI2P9G5PNxEP5OtMwOsW84Y3Xat/hPAQFlI+ \n\ HES+AzbFGWJkeT8zL2nm95tVkFP1sggZ7Kxjz3w7cpx7GX0NkbWSE9O+T51pNASV \n\ tN1sQ3p5M+/a+cnlqgfEGJVvc7iAcXQPa3LEi5h2yPR49QYXAgG6cifn3dDSpmwn \n\ SUI7PQECgYEApGCIIpSRPLAEHTGmP87RBL1smurhwmy2s/pghkvUkWehtxg0sGHh \n\ kuaqDWcskogv+QC0sVdytiLSz8G0DwcEcsHK1Fkyb8A+ayiw6jWJDo2m9+IF4Fww \n\ 1Te6jFPYDESnbhq7+TLGgHGhtwcu5cnb4vSuYXGXKupZGzoLOBbv1Zw= \n\ -----END RSA PRIVATE KEY----- \n\ "; const char message[] = "\ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do \r\n\ eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut \r\n\ enim ad minim veniam, quis nostrud exercitation ullamco laboris \r\n\ nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor \r\n\ in reprehenderit in voluptate velit esse cillum dolore eu fugiat \r\n\ nulla pariatur. Excepteur sint occaecat cupidatat non proident, \r\n\ sunt in culpa qui officia deserunt mollit anim id est laborum. \r\n\ "; static int x509_store_callback(int ok, X509_STORE_CTX *ctx) { /* Pretend the certificate issuer is valid... */ return 1; } static void fatal(const char *msg) { warnx("%s", msg); ERR_print_errors(BIO_new_fd(STDERR_FILENO, 0)); exit(1); } static void message_compare(const char *out, size_t len) { if (len != sizeof(message)) { fprintf(stderr, "FAILURE: length mismatch (%zu != %zu)\n", len, sizeof(message)); exit(1); } if (bcmp(out, message, len) != 0) { fprintf(stderr, "FAILURE: message mismatch\n"); fprintf(stderr, "Got:\n%s\n", out); fprintf(stderr, "Want:\n%s\n", message); exit(1); } } int main(int argc, char **argv) { BIO *bio_in, *bio_content, *bio_out, *bio_cert, *bio_pkey; STACK_OF(X509) *certs; const EVP_CIPHER *cipher; EVP_PKEY *pkey; X509_STORE *store; X509 *cert; PKCS7 *p7; size_t len; char *out; int flags; ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); /* * A bunch of setup... */ cipher = EVP_aes_256_cbc(); if (cipher == NULL) fatal("cipher"); certs = sk_X509_new_null(); if (certs == NULL) fatal("sk_X509_new_null"); bio_cert = BIO_new_mem_buf((char *)certificate, sizeof(certificate)); if (bio_cert == NULL) fatal("BIO_new_mem_buf certificate"); cert = PEM_read_bio_X509_AUX(bio_cert, NULL, NULL, NULL); if (cert == NULL) fatal("PEM_read_bio_X509_AUX"); sk_X509_push(certs, cert); store = X509_STORE_new(); if (store == NULL) fatal("X509_STORE_new"); X509_STORE_set_verify_cb(store, x509_store_callback); bio_pkey = BIO_new_mem_buf((char *)private_key, sizeof(private_key)); if (bio_pkey == NULL) fatal("BIO_new_mem_buf private_key"); pkey = PEM_read_bio_PrivateKey(bio_pkey, NULL, NULL, NULL); if (pkey == NULL) fatal("PEM_read_bio_PrivateKey"); bio_content = BIO_new_mem_buf((char *)message, sizeof(message)); if (bio_content == NULL) fatal("BIO_new_mem_buf message"); /* * Encrypt and then decrypt. */ if (BIO_reset(bio_content) != 1) fatal("BIO_reset"); bio_out = BIO_new(BIO_s_mem()); if (bio_out == NULL) fatal("BIO_new"); p7 = PKCS7_encrypt(certs, bio_content, cipher, 0); if (p7 == NULL) fatal("PKCS7_encrypt"); if (PEM_write_bio_PKCS7(bio_out, p7) != 1) fatal("PEM_write_bio_PKCS7"); PKCS7_free(p7); bio_in = bio_out; bio_out = BIO_new(BIO_s_mem()); if (bio_out == NULL) fatal("BIO_new"); p7 = PEM_read_bio_PKCS7(bio_in, NULL, NULL, NULL); if (p7 == NULL) fatal("PEM_read_bio_PKCS7"); if (PKCS7_decrypt(p7, pkey, cert, bio_out, 0) != 1) fatal("PKCS7_decrypt"); len = BIO_get_mem_data(bio_out, &out); message_compare(out, len); BIO_free(bio_out); /* * Sign and then verify. */ if (BIO_reset(bio_content) != 1) fatal("BIO_reset"); bio_out = BIO_new(BIO_s_mem()); if (bio_out == NULL) fatal("BIO_new"); p7 = PKCS7_sign(cert, pkey, certs, bio_content, 0); if (p7 == NULL) fatal("PKCS7_sign"); if (PEM_write_bio_PKCS7(bio_out, p7) != 1) fatal("PEM_write_bio_PKCS7"); PKCS7_free(p7); bio_in = bio_out; bio_out = BIO_new(BIO_s_mem()); if (bio_out == NULL) fatal("BIO_new"); p7 = PEM_read_bio_PKCS7(bio_in, NULL, NULL, NULL); if (p7 == NULL) fatal("PEM_read_bio_PKCS7"); if (PKCS7_verify(p7, certs, store, NULL, bio_out, 0) != 1) fatal("PKCS7_verify"); len = BIO_get_mem_data(bio_out, &out); message_compare(out, len); BIO_free(bio_in); BIO_free(bio_out); /* * Sign and then verify with a detached signature. */ if (BIO_reset(bio_content) != 1) fatal("BIO_reset"); bio_out = BIO_new(BIO_s_mem()); if (bio_out == NULL) fatal("BIO_new"); flags = PKCS7_DETACHED|PKCS7_PARTIAL; p7 = PKCS7_sign(NULL, NULL, NULL, bio_content, flags); if (p7 == NULL) fatal("PKCS7_sign"); if (PKCS7_sign_add_signer(p7, cert, pkey, NULL, flags) == NULL) fatal("PKCS7_sign_add_signer"); if (PKCS7_final(p7, bio_content, flags) != 1) fatal("PKCS7_final"); if (PEM_write_bio_PKCS7(bio_out, p7) != 1) fatal("PEM_write_bio_PKCS7"); PKCS7_free(p7); /* bio_out contains only the detached signature. */ bio_in = bio_out; if (BIO_reset(bio_content) != 1) fatal("BIO_reset"); bio_out = BIO_new(BIO_s_mem()); if (bio_out == NULL) fatal("BIO_new"); p7 = PEM_read_bio_PKCS7(bio_in, NULL, NULL, NULL); if (p7 == NULL) fatal("PEM_read_bio_PKCS7"); if (PKCS7_verify(p7, certs, store, bio_content, bio_out, flags) != 1) fatal("PKCS7_verify"); len = BIO_get_mem_data(bio_out, &out); message_compare(out, len); BIO_free(bio_in); BIO_free(bio_out); BIO_free(bio_content); return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/bntest.c0000644000175000017500000011521212360020706017543 0ustar /* crypto/bn/bntest.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * Portions of the attached software ("Contribution") are developed by * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. * * The Contribution is licensed pursuant to the Eric Young open source * license provided above. * * The binary polynomial arithmetic software is originally written by * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. * */ /* Until the key-gen callbacks are modified to use newer prototypes, we allow * deprecated functions for openssl-internal code */ #ifdef OPENSSL_NO_DEPRECATED #undef OPENSSL_NO_DEPRECATED #endif #include #include #include #include #include #include #include #include const int num0 = 100; /* number of tests */ const int num1 = 50; /* additional tests for some functions */ const int num2 = 5; /* number of tests for slow functions */ int test_add(BIO *bp); int test_sub(BIO *bp); int test_lshift1(BIO *bp); int test_lshift(BIO *bp,BN_CTX *ctx,BIGNUM *a_); int test_rshift1(BIO *bp); int test_rshift(BIO *bp,BN_CTX *ctx); int test_div(BIO *bp,BN_CTX *ctx); int test_div_word(BIO *bp); int test_div_recp(BIO *bp,BN_CTX *ctx); int test_mul(BIO *bp); int test_sqr(BIO *bp,BN_CTX *ctx); int test_mont(BIO *bp,BN_CTX *ctx); int test_mod(BIO *bp,BN_CTX *ctx); int test_mod_mul(BIO *bp,BN_CTX *ctx); int test_mod_exp(BIO *bp,BN_CTX *ctx); int test_mod_exp_mont_consttime(BIO *bp,BN_CTX *ctx); int test_exp(BIO *bp,BN_CTX *ctx); int test_gf2m_add(BIO *bp); int test_gf2m_mod(BIO *bp); int test_gf2m_mod_mul(BIO *bp,BN_CTX *ctx); int test_gf2m_mod_sqr(BIO *bp,BN_CTX *ctx); int test_gf2m_mod_inv(BIO *bp,BN_CTX *ctx); int test_gf2m_mod_div(BIO *bp,BN_CTX *ctx); int test_gf2m_mod_exp(BIO *bp,BN_CTX *ctx); int test_gf2m_mod_sqrt(BIO *bp,BN_CTX *ctx); int test_gf2m_mod_solve_quad(BIO *bp,BN_CTX *ctx); int test_kron(BIO *bp,BN_CTX *ctx); int test_sqrt(BIO *bp,BN_CTX *ctx); int rand_neg(void); static int results=0; static unsigned char lst[]="\xC6\x4F\x43\x04\x2A\xEA\xCA\x6E\x58\x36\x80\x5B\xE8\xC9" "\x9B\x04\x5D\x48\x36\xC2\xFD\x16\xC9\x64\xF0"; static void message(BIO *out, char *m) { fprintf(stderr, "test %s\n", m); BIO_puts(out, "print \"test "); BIO_puts(out, m); BIO_puts(out, "\\n\"\n"); } int main(int argc, char *argv[]) { BN_CTX *ctx; BIO *out; char *outfile=NULL; results = 0; argc--; argv++; while (argc >= 1) { if (strcmp(*argv,"-results") == 0) results=1; else if (strcmp(*argv,"-out") == 0) { if (--argc < 1) break; outfile= *(++argv); } argc--; argv++; } ctx=BN_CTX_new(); if (ctx == NULL) exit(1); out=BIO_new(BIO_s_file()); if (out == NULL) exit(1); if (outfile == NULL) { BIO_set_fp(out,stdout,BIO_NOCLOSE); } else { if (!BIO_write_filename(out,outfile)) { perror(outfile); exit(1); } } if (!results) BIO_puts(out,"obase=16\nibase=16\n"); message(out,"BN_add"); if (!test_add(out)) goto err; (void)BIO_flush(out); message(out,"BN_sub"); if (!test_sub(out)) goto err; (void)BIO_flush(out); message(out,"BN_lshift1"); if (!test_lshift1(out)) goto err; (void)BIO_flush(out); message(out,"BN_lshift (fixed)"); if (!test_lshift(out,ctx,BN_bin2bn(lst,sizeof(lst)-1,NULL))) goto err; (void)BIO_flush(out); message(out,"BN_lshift"); if (!test_lshift(out,ctx,NULL)) goto err; (void)BIO_flush(out); message(out,"BN_rshift1"); if (!test_rshift1(out)) goto err; (void)BIO_flush(out); message(out,"BN_rshift"); if (!test_rshift(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_sqr"); if (!test_sqr(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_mul"); if (!test_mul(out)) goto err; (void)BIO_flush(out); message(out,"BN_div"); if (!test_div(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_div_word"); if (!test_div_word(out)) goto err; (void)BIO_flush(out); message(out,"BN_div_recp"); if (!test_div_recp(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_mod"); if (!test_mod(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_mod_mul"); if (!test_mod_mul(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_mont"); if (!test_mont(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_mod_exp"); if (!test_mod_exp(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_mod_exp_mont_consttime"); if (!test_mod_exp_mont_consttime(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_exp"); if (!test_exp(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_kronecker"); if (!test_kron(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_mod_sqrt"); if (!test_sqrt(out,ctx)) goto err; (void)BIO_flush(out); #ifndef OPENSSL_NO_EC2M message(out,"BN_GF2m_add"); if (!test_gf2m_add(out)) goto err; (void)BIO_flush(out); message(out,"BN_GF2m_mod"); if (!test_gf2m_mod(out)) goto err; (void)BIO_flush(out); message(out,"BN_GF2m_mod_mul"); if (!test_gf2m_mod_mul(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_GF2m_mod_sqr"); if (!test_gf2m_mod_sqr(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_GF2m_mod_inv"); if (!test_gf2m_mod_inv(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_GF2m_mod_div"); if (!test_gf2m_mod_div(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_GF2m_mod_exp"); if (!test_gf2m_mod_exp(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_GF2m_mod_sqrt"); if (!test_gf2m_mod_sqrt(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_GF2m_mod_solve_quad"); if (!test_gf2m_mod_solve_quad(out,ctx)) goto err; (void)BIO_flush(out); #endif BN_CTX_free(ctx); BIO_free(out); /**/ exit(0); err: BIO_puts(out,"1\n"); /* make sure the Perl script fed by bc notices * the failure, see test_bn in test/Makefile.ssl*/ (void)BIO_flush(out); ERR_load_crypto_strings(); ERR_print_errors_fp(stderr); exit(1); } int test_add(BIO *bp) { BIGNUM a,b,c; int i; BN_init(&a); BN_init(&b); BN_init(&c); BN_bntest_rand(&a,512,0,0); for (i=0; i sizeof(unsigned long)) { unsigned long h=(unsigned long)(w>>32), l=(unsigned long)(w); if (h) BIO_printf(bp,"%lX%08lX",h,l); else BIO_printf(bp,"%lX",l); return; } #endif BIO_printf(bp,BN_HEX_FMT1,w); } int test_div_word(BIO *bp) { BIGNUM a,b; BN_ULONG r,s; int i; BN_init(&a); BN_init(&b); for (i=0; iN)); BIO_puts(bp," - "); } BN_print(bp,&A); BIO_puts(bp,"\n"); } BN_mod_mul(&d,&a,&b,&n,ctx); BN_sub(&d,&d,&A); if(!BN_is_zero(&d)) { fprintf(stderr,"Montgomery multiplication test failed!\n"); return 0; } } BN_MONT_CTX_free(mont); BN_free(&a); BN_free(&b); BN_free(&c); BN_free(&d); BN_free(&A); BN_free(&B); BN_free(&n); return(1); } int test_mod(BIO *bp, BN_CTX *ctx) { BIGNUM *a,*b,*c,*d,*e; int i; a=BN_new(); b=BN_new(); c=BN_new(); d=BN_new(); e=BN_new(); BN_bntest_rand(a,1024,0,0); /**/ for (i=0; ineg=rand_neg(); b->neg=rand_neg(); BN_mod(c,a,b,ctx);/**/ if (bp != NULL) { if (!results) { BN_print(bp,a); BIO_puts(bp," % "); BN_print(bp,b); BIO_puts(bp," - "); } BN_print(bp,c); BIO_puts(bp,"\n"); } BN_div(d,e,a,b,ctx); BN_sub(e,e,c); if(!BN_is_zero(e)) { fprintf(stderr,"Modulo test failed!\n"); return 0; } } BN_free(a); BN_free(b); BN_free(c); BN_free(d); BN_free(e); return(1); } int test_mod_mul(BIO *bp, BN_CTX *ctx) { BIGNUM *a,*b,*c,*d,*e; int i,j; a=BN_new(); b=BN_new(); c=BN_new(); d=BN_new(); e=BN_new(); for (j=0; j<3; j++) { BN_bntest_rand(c,1024,0,0); /**/ for (i=0; ineg=rand_neg(); b->neg=rand_neg(); if (!BN_mod_mul(e,a,b,c,ctx)) { unsigned long l; while ((l=ERR_get_error())) fprintf(stderr,"ERROR:%s\n", ERR_error_string(l,NULL)); exit(1); } if (bp != NULL) { if (!results) { BN_print(bp,a); BIO_puts(bp," * "); BN_print(bp,b); BIO_puts(bp," % "); BN_print(bp,c); if ((a->neg ^ b->neg) && !BN_is_zero(e)) { /* If (a*b) % c is negative, c must be added * in order to obtain the normalized remainder * (new with OpenSSL 0.9.7, previous versions of * BN_mod_mul could generate negative results) */ BIO_puts(bp," + "); BN_print(bp,c); } BIO_puts(bp," - "); } BN_print(bp,e); BIO_puts(bp,"\n"); } BN_mul(d,a,b,ctx); BN_sub(d,d,e); BN_div(a,b,d,c,ctx); if(!BN_is_zero(b)) { fprintf(stderr,"Modulo multiply test failed!\n"); ERR_print_errors_fp(stderr); return 0; } } } BN_free(a); BN_free(b); BN_free(c); BN_free(d); BN_free(e); return(1); } int test_mod_exp(BIO *bp, BN_CTX *ctx) { BIGNUM *a,*b,*c,*d,*e; int i; a=BN_new(); b=BN_new(); c=BN_new(); d=BN_new(); e=BN_new(); BN_bntest_rand(c,30,0,1); /* must be odd for montgomery */ for (i=0; ineg = rand_neg(); putc('\n', stderr); for (i = 0; i < num0; i++) { if (!BN_bntest_rand(a, 512, 0, 0)) goto err; a->neg = rand_neg(); /* t := (|b|-1)/2 (note that b is odd) */ if (!BN_copy(t, b)) goto err; t->neg = 0; if (!BN_sub_word(t, 1)) goto err; if (!BN_rshift1(t, t)) goto err; /* r := a^t mod b */ b->neg=0; if (!BN_mod_exp_recp(r, a, t, b, ctx)) goto err; b->neg=1; if (BN_is_word(r, 1)) legendre = 1; else if (BN_is_zero(r)) legendre = 0; else { if (!BN_add_word(r, 1)) goto err; if (0 != BN_ucmp(r, b)) { fprintf(stderr, "Legendre symbol computation failed\n"); goto err; } legendre = -1; } kronecker = BN_kronecker(a, b, ctx); if (kronecker < -1) goto err; /* we actually need BN_kronecker(a, |b|) */ if (a->neg && b->neg) kronecker = -kronecker; if (legendre != kronecker) { fprintf(stderr, "legendre != kronecker; a = "); BN_print_fp(stderr, a); fprintf(stderr, ", b = "); BN_print_fp(stderr, b); fprintf(stderr, "\n"); goto err; } putc('.', stderr); fflush(stderr); } putc('\n', stderr); fflush(stderr); ret = 1; err: if (a != NULL) BN_free(a); if (b != NULL) BN_free(b); if (r != NULL) BN_free(r); if (t != NULL) BN_free(t); return ret; } int test_sqrt(BIO *bp, BN_CTX *ctx) { BN_GENCB cb; BIGNUM *a,*p,*r; int i, j; int ret = 0; a = BN_new(); p = BN_new(); r = BN_new(); if (a == NULL || p == NULL || r == NULL) goto err; BN_GENCB_set(&cb, genprime_cb, NULL); for (i = 0; i < 16; i++) { if (i < 8) { unsigned primes[8] = { 2, 3, 5, 7, 11, 13, 17, 19 }; if (!BN_set_word(p, primes[i])) goto err; } else { if (!BN_set_word(a, 32)) goto err; if (!BN_set_word(r, 2*i + 1)) goto err; if (!BN_generate_prime_ex(p, 256, 0, a, r, &cb)) goto err; putc('\n', stderr); } p->neg = rand_neg(); for (j = 0; j < num2; j++) { /* construct 'a' such that it is a square modulo p, * but in general not a proper square and not reduced modulo p */ if (!BN_bntest_rand(r, 256, 0, 3)) goto err; if (!BN_nnmod(r, r, p, ctx)) goto err; if (!BN_mod_sqr(r, r, p, ctx)) goto err; if (!BN_bntest_rand(a, 256, 0, 3)) goto err; if (!BN_nnmod(a, a, p, ctx)) goto err; if (!BN_mod_sqr(a, a, p, ctx)) goto err; if (!BN_mul(a, a, r, ctx)) goto err; if (rand_neg()) if (!BN_sub(a, a, p)) goto err; if (!BN_mod_sqrt(r, a, p, ctx)) goto err; if (!BN_mod_sqr(r, r, p, ctx)) goto err; if (!BN_nnmod(a, a, p, ctx)) goto err; if (BN_cmp(a, r) != 0) { fprintf(stderr, "BN_mod_sqrt failed: a = "); BN_print_fp(stderr, a); fprintf(stderr, ", r = "); BN_print_fp(stderr, r); fprintf(stderr, ", p = "); BN_print_fp(stderr, p); fprintf(stderr, "\n"); goto err; } putc('.', stderr); fflush(stderr); } putc('\n', stderr); fflush(stderr); } ret = 1; err: if (a != NULL) BN_free(a); if (p != NULL) BN_free(p); if (r != NULL) BN_free(r); return ret; } int test_lshift(BIO *bp,BN_CTX *ctx,BIGNUM *a_) { BIGNUM *a,*b,*c,*d; int i; b=BN_new(); c=BN_new(); d=BN_new(); BN_one(c); if(a_) a=a_; else { a=BN_new(); BN_bntest_rand(a,200,0,0); /**/ a->neg=rand_neg(); } for (i=0; ineg=rand_neg(); for (i=0; ineg=rand_neg(); for (i=0; ineg=rand_neg(); for (i=0; i #include #include #include #include static char *test[]={ "", "a", "abc", "message digest", "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "12345678901234567890123456789012345678901234567890123456789012345678901234567890", NULL, }; static char *ret[]={ "31d6cfe0d16ae931b73c59d7e0c089c0", "bde52cb31de33e46245e05fbdbd6fb24", "a448017aaf21d8525fc10ae87aa6729d", "d9130a8164549fe818874806e1c7014b", "d79e1c308aa5bbcdeea8ed63df412da9", "043f8582f241db351ce627e153e7f0e4", "e33b4ddc9c38f2199c3e7b164fcc0536", }; static char *pt(unsigned char *md); int main(int argc, char *argv[]) { int i,err=0; char **P,**R; char *p; unsigned char md[MD4_DIGEST_LENGTH]; P=test; R=ret; i=1; while (*P != NULL) { EVP_Digest(&(P[0][0]),strlen((char *)*P),md,NULL,EVP_md4(), NULL); p=pt(md); if (strcmp(p,(char *)*R) != 0) { printf("error calculating MD4 on '%s'\n",*P); printf("got %s instead of %s\n",p,*R); err++; } else printf("test %d ok\n",i); i++; R++; P++; } exit(err); } static char *pt(unsigned char *md) { int i; static char buf[80]; for (i=0; i #include #include #include #include #include #include #include #include /* * Test for proper bn_mul_mont behaviour when operands are of vastly different * sizes. */ int main(int argc, char *argv[]) { DH *dh; unsigned char *key, r[32 + 16 * 8]; size_t privsz; RAND_bytes(r, sizeof r); for (privsz = 32; privsz <= sizeof(r); privsz += 8) { dh = DH_new(); if (dh == NULL) goto err; if (DH_generate_parameters_ex(dh, 32, DH_GENERATOR_2, NULL) == 0) goto err; /* force private key to be much larger than public one */ dh->priv_key = BN_bin2bn(r, privsz, NULL); if (dh->priv_key == NULL) goto err; if (DH_generate_key(dh) == 0) goto err; key = malloc(DH_size(dh)); if (key == NULL) err(1, "malloc"); if (DH_compute_key(key, dh->pub_key, dh) == -1) goto err; free(key); DH_free(dh); } return 0; err: ERR_print_errors_fp(stderr); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/igetest.c0000644000175000017500000002726212360020706017717 0ustar /* test/igetest.c -*- mode:C; c-file-style: "eay" -*- */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * */ #include #include #include #include #include #define TEST_SIZE 128 #define BIG_TEST_SIZE 10240 static void hexdump(FILE *f,const char *title,const unsigned char *s,int l) { int n=0; fprintf(f,"%s",title); for( ; n < l ; ++n) { if((n%16) == 0) fprintf(f,"\n%04x",n); fprintf(f," %02x",s[n]); } fprintf(f,"\n"); } #define MAX_VECTOR_SIZE 64 struct ige_test { const unsigned char key[16]; const unsigned char iv[32]; const unsigned char in[MAX_VECTOR_SIZE]; const unsigned char out[MAX_VECTOR_SIZE]; const size_t length; const int encrypt; }; static struct ige_test const ige_test_vectors[] = { { { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, /* key */ { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }, /* iv */ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* in */ { 0x1a, 0x85, 0x19, 0xa6, 0x55, 0x7b, 0xe6, 0x52, 0xe9, 0xda, 0x8e, 0x43, 0xda, 0x4e, 0xf4, 0x45, 0x3c, 0xf4, 0x56, 0xb4, 0xca, 0x48, 0x8a, 0xa3, 0x83, 0xc7, 0x9c, 0x98, 0xb3, 0x47, 0x97, 0xcb }, /* out */ 32, AES_ENCRYPT }, /* test vector 0 */ { { 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x6e, 0x20, 0x69, 0x6d, 0x70, 0x6c, 0x65 }, /* key */ { 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x49, 0x47, 0x45, 0x20, 0x6d, 0x6f, 0x64, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x4f, 0x70, 0x65, 0x6e, 0x53, 0x53 }, /* iv */ { 0x4c, 0x2e, 0x20, 0x4c, 0x65, 0x74, 0x27, 0x73, 0x20, 0x68, 0x6f, 0x70, 0x65, 0x20, 0x42, 0x65, 0x6e, 0x20, 0x67, 0x6f, 0x74, 0x20, 0x69, 0x74, 0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x21, 0x0a }, /* in */ { 0x99, 0x70, 0x64, 0x87, 0xa1, 0xcd, 0xe6, 0x13, 0xbc, 0x6d, 0xe0, 0xb6, 0xf2, 0x4b, 0x1c, 0x7a, 0xa4, 0x48, 0xc8, 0xb9, 0xc3, 0x40, 0x3e, 0x34, 0x67, 0xa8, 0xca, 0xd8, 0x93, 0x40, 0xf5, 0x3b }, /* out */ 32, AES_DECRYPT }, /* test vector 1 */ }; static int run_test_vectors(void) { unsigned int n; int errs = 0; for(n=0 ; n < sizeof(ige_test_vectors)/sizeof(ige_test_vectors[0]) ; ++n) { const struct ige_test * const v = &ige_test_vectors[n]; AES_KEY key; unsigned char buf[MAX_VECTOR_SIZE]; unsigned char iv[AES_BLOCK_SIZE*2]; assert(v->length <= MAX_VECTOR_SIZE); if(v->encrypt == AES_ENCRYPT) AES_set_encrypt_key(v->key, 8*sizeof v->key, &key); else AES_set_decrypt_key(v->key, 8*sizeof v->key, &key); memcpy(iv, v->iv, sizeof iv); AES_ige_encrypt(v->in, buf, v->length, &key, iv, v->encrypt); if(memcmp(v->out, buf, v->length)) { printf("IGE test vector %d failed\n", n); hexdump(stdout, "key", v->key, sizeof v->key); hexdump(stdout, "iv", v->iv, sizeof v->iv); hexdump(stdout, "in", v->in, v->length); hexdump(stdout, "expected", v->out, v->length); hexdump(stdout, "got", buf, v->length); ++errs; } /* try with in == out */ memcpy(iv, v->iv, sizeof iv); memcpy(buf, v->in, v->length); AES_ige_encrypt(buf, buf, v->length, &key, iv, v->encrypt); if(memcmp(v->out, buf, v->length)) { printf("IGE test vector %d failed (with in == out)\n", n); hexdump(stdout, "key", v->key, sizeof v->key); hexdump(stdout, "iv", v->iv, sizeof v->iv); hexdump(stdout, "in", v->in, v->length); hexdump(stdout, "expected", v->out, v->length); hexdump(stdout, "got", buf, v->length); ++errs; } } return errs; } int main(int argc, char **argv) { unsigned char rkey[16]; unsigned char rkey2[16]; AES_KEY key; AES_KEY key2; unsigned char plaintext[BIG_TEST_SIZE]; unsigned char ciphertext[BIG_TEST_SIZE]; unsigned char checktext[BIG_TEST_SIZE]; unsigned char iv[AES_BLOCK_SIZE*4]; unsigned char saved_iv[AES_BLOCK_SIZE*4]; int err = 0; unsigned int n; unsigned matches; assert(BIG_TEST_SIZE >= TEST_SIZE); RAND_pseudo_bytes(rkey, sizeof rkey); RAND_pseudo_bytes(plaintext, sizeof plaintext); RAND_pseudo_bytes(iv, sizeof iv); memcpy(saved_iv, iv, sizeof saved_iv); /* Forward IGE only... */ /* Straight encrypt/decrypt */ AES_set_encrypt_key(rkey, 8*sizeof rkey, &key); AES_ige_encrypt(plaintext, ciphertext, TEST_SIZE, &key, iv, AES_ENCRYPT); AES_set_decrypt_key(rkey, 8*sizeof rkey, &key); memcpy(iv, saved_iv, sizeof iv); AES_ige_encrypt(ciphertext, checktext, TEST_SIZE, &key, iv, AES_DECRYPT); if(memcmp(checktext, plaintext, TEST_SIZE)) { printf("Encrypt+decrypt doesn't match\n"); hexdump(stdout, "Plaintext", plaintext, TEST_SIZE); hexdump(stdout, "Checktext", checktext, TEST_SIZE); ++err; } /* Now check encrypt chaining works */ AES_set_encrypt_key(rkey, 8*sizeof rkey, &key); memcpy(iv, saved_iv, sizeof iv); AES_ige_encrypt(plaintext, ciphertext, TEST_SIZE/2, &key, iv, AES_ENCRYPT); AES_ige_encrypt(plaintext+TEST_SIZE/2, ciphertext+TEST_SIZE/2, TEST_SIZE/2, &key, iv, AES_ENCRYPT); AES_set_decrypt_key(rkey, 8*sizeof rkey, &key); memcpy(iv, saved_iv, sizeof iv); AES_ige_encrypt(ciphertext, checktext, TEST_SIZE, &key, iv, AES_DECRYPT); if(memcmp(checktext, plaintext, TEST_SIZE)) { printf("Chained encrypt+decrypt doesn't match\n"); hexdump(stdout, "Plaintext", plaintext, TEST_SIZE); hexdump(stdout, "Checktext", checktext, TEST_SIZE); ++err; } /* And check decrypt chaining */ AES_set_encrypt_key(rkey, 8*sizeof rkey, &key); memcpy(iv, saved_iv, sizeof iv); AES_ige_encrypt(plaintext, ciphertext, TEST_SIZE/2, &key, iv, AES_ENCRYPT); AES_ige_encrypt(plaintext+TEST_SIZE/2, ciphertext+TEST_SIZE/2, TEST_SIZE/2, &key, iv, AES_ENCRYPT); AES_set_decrypt_key(rkey, 8*sizeof rkey, &key); memcpy(iv, saved_iv, sizeof iv); AES_ige_encrypt(ciphertext, checktext, TEST_SIZE/2, &key, iv, AES_DECRYPT); AES_ige_encrypt(ciphertext+TEST_SIZE/2, checktext+TEST_SIZE/2, TEST_SIZE/2, &key, iv, AES_DECRYPT); if(memcmp(checktext, plaintext, TEST_SIZE)) { printf("Chained encrypt+chained decrypt doesn't match\n"); hexdump(stdout, "Plaintext", plaintext, TEST_SIZE); hexdump(stdout, "Checktext", checktext, TEST_SIZE); ++err; } /* make sure garble extends forwards only */ AES_set_encrypt_key(rkey, 8*sizeof rkey, &key); memcpy(iv, saved_iv, sizeof iv); AES_ige_encrypt(plaintext, ciphertext, sizeof plaintext, &key, iv, AES_ENCRYPT); /* corrupt halfway through */ ++ciphertext[sizeof ciphertext/2]; AES_set_decrypt_key(rkey, 8*sizeof rkey, &key); memcpy(iv, saved_iv, sizeof iv); AES_ige_encrypt(ciphertext, checktext, sizeof checktext, &key, iv, AES_DECRYPT); matches=0; for(n=0 ; n < sizeof checktext ; ++n) if(checktext[n] == plaintext[n]) ++matches; if(matches > sizeof checktext/2+sizeof checktext/100) { printf("More than 51%% matches after garbling\n"); ++err; } if(matches < sizeof checktext/2) { printf("Garble extends backwards!\n"); ++err; } /* make sure garble extends both ways */ AES_set_encrypt_key(rkey, 8*sizeof rkey, &key); AES_set_encrypt_key(rkey2, 8*sizeof rkey2, &key2); AES_ige_encrypt(plaintext, ciphertext, sizeof plaintext, &key, iv, AES_ENCRYPT); /* corrupt halfway through */ ++ciphertext[sizeof ciphertext/2]; AES_set_decrypt_key(rkey, 8*sizeof rkey, &key); AES_set_decrypt_key(rkey2, 8*sizeof rkey2, &key2); AES_ige_encrypt(ciphertext, checktext, sizeof checktext, &key, iv, AES_DECRYPT); matches=0; for(n=0 ; n < sizeof checktext ; ++n) if(checktext[n] == plaintext[n]) ++matches; if(matches > sizeof checktext/100) { printf("More than 1%% matches after bidirectional garbling\n"); ++err; } /* make sure garble extends both ways (2) */ AES_set_encrypt_key(rkey, 8*sizeof rkey, &key); AES_set_encrypt_key(rkey2, 8*sizeof rkey2, &key2); AES_ige_encrypt(plaintext, ciphertext, sizeof plaintext, &key, iv, AES_ENCRYPT); /* corrupt right at the end */ ++ciphertext[sizeof ciphertext-1]; AES_set_decrypt_key(rkey, 8*sizeof rkey, &key); AES_set_decrypt_key(rkey2, 8*sizeof rkey2, &key2); AES_ige_encrypt(ciphertext, checktext, sizeof checktext, &key, iv, AES_DECRYPT); matches=0; for(n=0 ; n < sizeof checktext ; ++n) if(checktext[n] == plaintext[n]) ++matches; if(matches > sizeof checktext/100) { printf("More than 1%% matches after bidirectional garbling (2)\n"); ++err; } /* make sure garble extends both ways (3) */ AES_set_encrypt_key(rkey, 8*sizeof rkey, &key); AES_set_encrypt_key(rkey2, 8*sizeof rkey2, &key2); AES_ige_encrypt(plaintext, ciphertext, sizeof plaintext, &key, iv, AES_ENCRYPT); /* corrupt right at the start */ ++ciphertext[0]; AES_set_decrypt_key(rkey, 8*sizeof rkey, &key); AES_set_decrypt_key(rkey2, 8*sizeof rkey2, &key2); AES_ige_encrypt(ciphertext, checktext, sizeof checktext, &key, iv, AES_DECRYPT); matches=0; for(n=0 ; n < sizeof checktext ; ++n) if(checktext[n] == plaintext[n]) ++matches; if(matches > sizeof checktext/100) { printf("More than 1%% matches after bidirectional garbling (3)\n"); ++err; } err += run_test_vectors(); return err; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/aeadtest.sh0000755000175000017500000000006212357514212020233 0ustar #!/bin/sh set -e ./aeadtest $srcdir/aeadtests.txt deps/libressl-pnacl-sys-2.1.6/libressl/tests/sha1test.c0000644000175000017500000001157412360020706020006 0ustar /* crypto/sha/sha1test.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #undef SHA_0 /* FIPS 180 */ #define SHA_1 /* FIPS 180-1 */ static char *test[]={ "abc", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", NULL, }; #ifdef SHA_0 static char *ret[]={ "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880", "d2516ee1acfa5baf33dfc1c471e438449ef134c8", }; static char *bigret= "3232affa48628a26653b5aaa44541fd90d690603"; #endif #ifdef SHA_1 static char *ret[]={ "a9993e364706816aba3e25717850c26c9cd0d89d", "84983e441c3bd26ebaae4aa1f95129e5e54670f1", }; static char *bigret= "34aa973cd4c4daa4f61eeb2bdbad27316534016f"; #endif static char *pt(unsigned char *md); int main(int argc, char *argv[]) { int i,err=0; char **P,**R; static unsigned char buf[1000]; char *p,*r; EVP_MD_CTX c; unsigned char md[SHA_DIGEST_LENGTH]; EVP_MD_CTX_init(&c); P=test; R=ret; i=1; while (*P != NULL) { EVP_Digest(*P,strlen((char *)*P),md,NULL,EVP_sha1(), NULL); p=pt(md); if (strcmp(p,(char *)*R) != 0) { printf("error calculating SHA1 on '%s'\n",*P); printf("got %s instead of %s\n",p,*R); err++; } else printf("test %d ok\n",i); i++; R++; P++; } memset(buf,'a',1000); EVP_DigestInit_ex(&c,EVP_sha1(), NULL); for (i=0; i<1000; i++) EVP_DigestUpdate(&c,buf,1000); EVP_DigestFinal_ex(&c,md,NULL); p=pt(md); r=bigret; if (strcmp(p,r) != 0) { printf("error calculating SHA1 on 'a' * 1000\n"); printf("got %s instead of %s\n",p,r); err++; } else printf("test 3 ok\n"); EVP_MD_CTX_cleanup(&c); exit(err); } static char *pt(unsigned char *md) { int i; static char buf[80]; for (i=0; i #include #include #include #include static unsigned char pad1[16]={ 0x42,0xE5,0x0C,0xD2,0x24,0xBA,0xCE,0xBA, 0x76,0x0B,0xDD,0x2B,0xD4,0x09,0x28,0x1A }; static unsigned char pad2[16]={ 0x2E,0x46,0x79,0xB5,0xAD,0xD9,0xCA,0x75, 0x35,0xD8,0x7A,0xFE,0xAB,0x33,0xBE,0xE2 }; int main(int argc, char *argv[]) { int ret=0; unsigned char md[MDC2_DIGEST_LENGTH]; int i; EVP_MD_CTX c; static char *text="Now is the time for all "; EVP_MD_CTX_init(&c); EVP_DigestInit_ex(&c,EVP_mdc2(), NULL); EVP_DigestUpdate(&c,(unsigned char *)text,strlen(text)); EVP_DigestFinal_ex(&c,&(md[0]),NULL); if (memcmp(md,pad1,MDC2_DIGEST_LENGTH) != 0) { for (i=0; ipad_type=2; EVP_DigestUpdate(&c,(unsigned char *)text,strlen(text)); EVP_DigestFinal_ex(&c,&(md[0]),NULL); if (memcmp(md,pad2,MDC2_DIGEST_LENGTH) != 0) { for (i=0; i #include #include #include #include /* This program tests an AEAD against a series of test vectors from a file. The * test vector file consists of key-value lines where the key and value are * separated by a colon and optional whitespace. The keys are listed in * NAMES, below. The values are hex-encoded data. * * After a number of key-value lines, a blank line indicates the end of the * test case. * * For example, here's a valid test case: * * AEAD: chacha20-poly1305 * KEY: bcb2639bf989c6251b29bf38d39a9bdce7c55f4b2ac12a39c8a37b5d0a5cc2b5 * NONCE: 1e8b4c510f5ca083 * IN: 8c8419bc27 * AD: 34ab88c265 * CT: 1a7c2f33f5 * TAG: 2875c659d0f2808de3a40027feff91a4 */ #define BUF_MAX 1024 /* These are the different types of line that are found in the input file. */ enum { AEAD = 0, /* name of the AEAD algorithm. */ KEY, /* hex encoded key. */ NONCE, /* hex encoded nonce. */ IN, /* hex encoded plaintext. */ AD, /* hex encoded additional data. */ CT, /* hex encoded ciphertext (not including the * authenticator, which is next. */ TAG, /* hex encoded authenticator. */ NUM_TYPES }; static const char NAMES[NUM_TYPES][6] = { "AEAD", "KEY", "NONCE", "IN", "AD", "CT", "TAG", }; static unsigned char hex_digit(char h) { if (h >= '0' && h <= '9') return h - '0'; else if (h >= 'a' && h <= 'f') return h - 'a' + 10; else if (h >= 'A' && h <= 'F') return h - 'A' + 10; else return 16; } static int aead_from_name(const EVP_AEAD **aead, const char *name) { *aead = NULL; if (strcmp(name, "aes-128-gcm") == 0) { #ifndef OPENSSL_NO_AES *aead = EVP_aead_aes_128_gcm(); #else fprintf(stderr, "No AES support.\n"); #endif } else if (strcmp(name, "aes-256-gcm") == 0) { #ifndef OPENSSL_NO_AES *aead = EVP_aead_aes_256_gcm(); #else fprintf(stderr, "No AES support.\n"); #endif } else if (strcmp(name, "chacha20-poly1305") == 0) { #if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) *aead = EVP_aead_chacha20_poly1305(); #else fprintf(stderr, "No chacha20-poly1305 support.\n"); #endif } else { fprintf(stderr, "Unknown AEAD: %s\n", name); return -1; } if (aead == NULL) return 0; return 1; } static int run_test_case(const EVP_AEAD* aead, unsigned char bufs[NUM_TYPES][BUF_MAX], const unsigned int lengths[NUM_TYPES], unsigned int line_no) { EVP_AEAD_CTX ctx; unsigned char out[BUF_MAX + EVP_AEAD_MAX_TAG_LENGTH], out2[BUF_MAX]; size_t out_len, out_len2; if (!EVP_AEAD_CTX_init(&ctx, aead, bufs[KEY], lengths[KEY], lengths[TAG], NULL)) { fprintf(stderr, "Failed to init AEAD on line %u\n", line_no); return 0; } if (!EVP_AEAD_CTX_seal(&ctx, out, &out_len, sizeof(out), bufs[NONCE], lengths[NONCE], bufs[IN], lengths[IN], bufs[AD], lengths[AD])) { fprintf(stderr, "Failed to run AEAD on line %u\n", line_no); return 0; } if (out_len != lengths[CT] + lengths[TAG]) { fprintf(stderr, "Bad output length on line %u: %zu vs %u\n", line_no, out_len, (unsigned)(lengths[CT] + lengths[TAG])); return 0; } if (memcmp(out, bufs[CT], lengths[CT]) != 0) { fprintf(stderr, "Bad output on line %u\n", line_no); return 0; } if (memcmp(out + lengths[CT], bufs[TAG], lengths[TAG]) != 0) { fprintf(stderr, "Bad tag on line %u\n", line_no); return 0; } if (!EVP_AEAD_CTX_open(&ctx, out2, &out_len2, lengths[IN], bufs[NONCE], lengths[NONCE], out, out_len, bufs[AD], lengths[AD])) { fprintf(stderr, "Failed to decrypt on line %u\n", line_no); return 0; } if (out_len2 != lengths[IN]) { fprintf(stderr, "Bad decrypt on line %u: %zu\n", line_no, out_len2); return 0; } out[0] ^= 0x80; if (EVP_AEAD_CTX_open(&ctx, out2, &out_len2, lengths[IN], bufs[NONCE], lengths[NONCE], out, out_len, bufs[AD], lengths[AD])) { fprintf(stderr, "Decrypted bad data on line %u\n", line_no); return 0; } EVP_AEAD_CTX_cleanup(&ctx); return 1; } int main(int argc, char **argv) { FILE *f; const EVP_AEAD *aead = NULL; unsigned int line_no = 0, num_tests = 0, j; unsigned char bufs[NUM_TYPES][BUF_MAX]; unsigned int lengths[NUM_TYPES]; if (argc != 2) { fprintf(stderr, "%s \n", argv[0]); return 1; } f = fopen(argv[1], "r"); if (f == NULL) { perror("failed to open input"); return 1; } for (j = 0; j < NUM_TYPES; j++) lengths[j] = 0; for (;;) { char line[4096]; unsigned int i, type_len = 0; unsigned char *buf = NULL; unsigned int *buf_len = NULL; if (!fgets(line, sizeof(line), f)) break; line_no++; if (line[0] == '#') continue; if (line[0] == '\n' || line[0] == 0) { /* Run a test, if possible. */ char any_values_set = 0; for (j = 0; j < NUM_TYPES; j++) { if (lengths[j] != 0) { any_values_set = 1; break; } } if (!any_values_set) continue; switch (aead_from_name(&aead, bufs[AEAD])) { case 0: fprintf(stderr, "Skipping test...\n"); continue; case -1: fprintf(stderr, "Aborting...\n"); return 4; } if (!run_test_case(aead, bufs, lengths, line_no)) return 4; for (j = 0; j < NUM_TYPES; j++) lengths[j] = 0; num_tests++; continue; } /* Each line looks like: * TYPE: 0123abc * Where "TYPE" is the type of the data on the line, * e.g. "KEY". */ for (i = 0; line[i] != 0 && line[i] != '\n'; i++) { if (line[i] == ':') { type_len = i; break; } } i++; if (type_len == 0) { fprintf(stderr, "Parse error on line %u\n", line_no); return 3; } /* After the colon, there's optional whitespace. */ for (; line[i] != 0 && line[i] != '\n'; i++) { if (line[i] != ' ' && line[i] != '\t') break; } line[type_len] = 0; for (j = 0; j < NUM_TYPES; j++) { if (strcmp(line, NAMES[j]) != 0) continue; if (lengths[j] != 0) { fprintf(stderr, "Duplicate value on line %u\n", line_no); return 3; } buf = bufs[j]; buf_len = &lengths[j]; break; } if (buf == NULL) { fprintf(stderr, "Unknown line type on line %u\n", line_no); return 3; } if (j == AEAD) { *buf_len = strlcpy(buf, line + i, BUF_MAX); for (j = 0; j < BUF_MAX; j++) { if (buf[j] == '\n') buf[j] = '\0'; } continue; } for (j = 0; line[i] != 0 && line[i] != '\n'; i++) { unsigned char v, v2; v = hex_digit(line[i++]); if (line[i] == 0 || line[i] == '\n') { fprintf(stderr, "Odd-length hex data on " "line %u\n", line_no); return 3; } v2 = hex_digit(line[i]); if (v > 15 || v2 > 15) { fprintf(stderr, "Invalid hex char on line %u\n", line_no); return 3; } v <<= 4; v |= v2; if (j == BUF_MAX) { fprintf(stderr, "Too much hex data on line %u " "(max is %u bytes)\n", line_no, (unsigned) BUF_MAX); return 3; } buf[j++] = v; *buf_len = *buf_len + 1; } } printf("Completed %u test cases\n", num_tests); printf("PASS\n"); fclose(f); return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/cts128test.c0000644000175000017500000001463012360020706020172 0ustar /* ==================================================================== * Copyright (c) 2008 The OpenSSL Project. All rights reserved. * * Rights for redistribution and usage in source and binary * forms are granted according to the OpenSSL license. */ #include #include #include #include #include void test_vector(const unsigned char *vector,size_t len); void test_nistvector(const unsigned char *vector,size_t len); /* test vectors from RFC 3962 */ static const unsigned char test_key[16] = "chicken teriyaki"; static const unsigned char test_input[64] = "I would like the" " General Gau's C" "hicken, please, " "and wonton soup."; static const unsigned char test_iv[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; static const unsigned char vector_17[17] = {0xc6,0x35,0x35,0x68,0xf2,0xbf,0x8c,0xb4, 0xd8,0xa5,0x80,0x36,0x2d,0xa7,0xff,0x7f, 0x97}; static const unsigned char vector_31[31] = {0xfc,0x00,0x78,0x3e,0x0e,0xfd,0xb2,0xc1, 0xd4,0x45,0xd4,0xc8,0xef,0xf7,0xed,0x22, 0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5}; static const unsigned char vector_32[32] = {0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5,0xa8, 0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84}; static const unsigned char vector_47[47] = {0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84, 0xb3,0xff,0xfd,0x94,0x0c,0x16,0xa1,0x8c, 0x1b,0x55,0x49,0xd2,0xf8,0x38,0x02,0x9e, 0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5}; static const unsigned char vector_48[48] = {0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84, 0x9d,0xad,0x8b,0xbb,0x96,0xc4,0xcd,0xc0, 0x3b,0xc1,0x03,0xe1,0xa1,0x94,0xbb,0xd8, 0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5,0xa8}; static const unsigned char vector_64[64] = {0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84, 0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5,0xa8, 0x48,0x07,0xef,0xe8,0x36,0xee,0x89,0xa5, 0x26,0x73,0x0d,0xbc,0x2f,0x7b,0xc8,0x40, 0x9d,0xad,0x8b,0xbb,0x96,0xc4,0xcd,0xc0, 0x3b,0xc1,0x03,0xe1,0xa1,0x94,0xbb,0xd8}; static AES_KEY encks, decks; void test_vector(const unsigned char *vector,size_t len) { unsigned char iv[sizeof(test_iv)]; unsigned char cleartext[64],ciphertext[64]; size_t tail; printf("vector_%zu\n",len); fflush(stdout); if ((tail=len%16) == 0) tail = 16; tail += 16; /* test block-based encryption */ memcpy(iv,test_iv,sizeof(test_iv)); CRYPTO_cts128_encrypt_block(test_input,ciphertext,len,&encks,iv,(block128_f)AES_encrypt); if (memcmp(ciphertext,vector,len)) fprintf(stderr,"output_%zu mismatch\n",len), exit(1); if (memcmp(iv,vector+len-tail,sizeof(iv))) fprintf(stderr,"iv_%zu mismatch\n",len), exit(1); /* test block-based decryption */ memcpy(iv,test_iv,sizeof(test_iv)); CRYPTO_cts128_decrypt_block(ciphertext,cleartext,len,&decks,iv,(block128_f)AES_decrypt); if (memcmp(cleartext,test_input,len)) fprintf(stderr,"input_%zu mismatch\n",len), exit(2); if (memcmp(iv,vector+len-tail,sizeof(iv))) fprintf(stderr,"iv_%zu mismatch\n",len), exit(2); /* test streamed encryption */ memcpy(iv,test_iv,sizeof(test_iv)); CRYPTO_cts128_encrypt(test_input,ciphertext,len,&encks,iv,(cbc128_f)AES_cbc_encrypt); if (memcmp(ciphertext,vector,len)) fprintf(stderr,"output_%zu mismatch\n",len), exit(3); if (memcmp(iv,vector+len-tail,sizeof(iv))) fprintf(stderr,"iv_%zu mismatch\n",len), exit(3); /* test streamed decryption */ memcpy(iv,test_iv,sizeof(test_iv)); CRYPTO_cts128_decrypt(ciphertext,cleartext,len,&decks,iv,(cbc128_f)AES_cbc_encrypt); if (memcmp(cleartext,test_input,len)) fprintf(stderr,"input_%zu mismatch\n",len), exit(4); if (memcmp(iv,vector+len-tail,sizeof(iv))) fprintf(stderr,"iv_%zu mismatch\n",len), exit(4); } void test_nistvector(const unsigned char *vector,size_t len) { unsigned char iv[sizeof(test_iv)]; unsigned char cleartext[64],ciphertext[64],nistvector[64]; size_t tail; printf("nistvector_%zu\n",len); fflush(stdout); if ((tail=len%16) == 0) tail = 16; len -= 16 + tail; memcpy(nistvector,vector,len); /* flip two last blocks */ memcpy(nistvector+len,vector+len+16,tail); memcpy(nistvector+len+tail,vector+len,16); len += 16 + tail; tail = 16; /* test block-based encryption */ memcpy(iv,test_iv,sizeof(test_iv)); CRYPTO_nistcts128_encrypt_block(test_input,ciphertext,len,&encks,iv,(block128_f)AES_encrypt); if (memcmp(ciphertext,nistvector,len)) fprintf(stderr,"output_%zu mismatch\n",len), exit(1); if (memcmp(iv,nistvector+len-tail,sizeof(iv))) fprintf(stderr,"iv_%zu mismatch\n",len), exit(1); /* test block-based decryption */ memcpy(iv,test_iv,sizeof(test_iv)); CRYPTO_nistcts128_decrypt_block(ciphertext,cleartext,len,&decks,iv,(block128_f)AES_decrypt); if (memcmp(cleartext,test_input,len)) fprintf(stderr,"input_%zu mismatch\n",len), exit(2); if (memcmp(iv,nistvector+len-tail,sizeof(iv))) fprintf(stderr,"iv_%zu mismatch\n",len), exit(2); /* test streamed encryption */ memcpy(iv,test_iv,sizeof(test_iv)); CRYPTO_nistcts128_encrypt(test_input,ciphertext,len,&encks,iv,(cbc128_f)AES_cbc_encrypt); if (memcmp(ciphertext,nistvector,len)) fprintf(stderr,"output_%zu mismatch\n",len), exit(3); if (memcmp(iv,nistvector+len-tail,sizeof(iv))) fprintf(stderr,"iv_%zu mismatch\n",len), exit(3); /* test streamed decryption */ memcpy(iv,test_iv,sizeof(test_iv)); CRYPTO_nistcts128_decrypt(ciphertext,cleartext,len,&decks,iv,(cbc128_f)AES_cbc_encrypt); if (memcmp(cleartext,test_input,len)) fprintf(stderr,"input_%zu mismatch\n",len), exit(4); if (memcmp(iv,nistvector+len-tail,sizeof(iv))) fprintf(stderr,"iv_%zu mismatch\n",len), exit(4); } int main(int argc, char *argv[]) { AES_set_encrypt_key(test_key,128,&encks); AES_set_decrypt_key(test_key,128,&decks); test_vector(vector_17,sizeof(vector_17)); test_vector(vector_31,sizeof(vector_31)); test_vector(vector_32,sizeof(vector_32)); test_vector(vector_47,sizeof(vector_47)); test_vector(vector_48,sizeof(vector_48)); test_vector(vector_64,sizeof(vector_64)); test_nistvector(vector_17,sizeof(vector_17)); test_nistvector(vector_31,sizeof(vector_31)); test_nistvector(vector_32,sizeof(vector_32)); test_nistvector(vector_47,sizeof(vector_47)); test_nistvector(vector_48,sizeof(vector_48)); test_nistvector(vector_64,sizeof(vector_64)); return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/Makefile.in0000664000175000017500000021421412437255271020165 0ustar # Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ DIST_COMMON = $(top_srcdir)/Makefile.am.common $(srcdir)/Makefile.in \ $(srcdir)/Makefile.am $(top_srcdir)/depcomp \ $(top_srcdir)/test-driver TESTS = aes_wrap$(EXEEXT) base64test$(EXEEXT) bftest$(EXEEXT) \ bntest$(EXEEXT) casttest$(EXEEXT) chachatest$(EXEEXT) \ cts128test$(EXEEXT) destest$(EXEEXT) dhtest$(EXEEXT) \ dsatest$(EXEEXT) ecdhtest$(EXEEXT) ecdsatest$(EXEEXT) \ ectest$(EXEEXT) enginetest$(EXEEXT) explicit_bzero$(EXEEXT) \ exptest$(EXEEXT) gcm128test$(EXEEXT) hmactest$(EXEEXT) \ ideatest$(EXEEXT) igetest$(EXEEXT) md4test$(EXEEXT) \ md5test$(EXEEXT) mdc2test$(EXEEXT) mont$(EXEEXT) \ pkcs7test$(EXEEXT) poly1305test$(EXEEXT) randtest$(EXEEXT) \ rc2test$(EXEEXT) rc4test$(EXEEXT) rmdtest$(EXEEXT) \ sha1test$(EXEEXT) sha256test$(EXEEXT) sha512test$(EXEEXT) \ shatest$(EXEEXT) timingsafe$(EXEEXT) utf8test$(EXEEXT) \ aeadtest.sh evptest.sh pq_test.sh ssltest.sh \ arc4randomforktest.sh check_PROGRAMS = aeadtest$(EXEEXT) aes_wrap$(EXEEXT) \ arc4randomforktest$(EXEEXT) base64test$(EXEEXT) \ bftest$(EXEEXT) biotest$(EXEEXT) bntest$(EXEEXT) \ casttest$(EXEEXT) chachatest$(EXEEXT) cts128test$(EXEEXT) \ destest$(EXEEXT) dhtest$(EXEEXT) dsatest$(EXEEXT) \ ecdhtest$(EXEEXT) ecdsatest$(EXEEXT) ectest$(EXEEXT) \ enginetest$(EXEEXT) evptest$(EXEEXT) explicit_bzero$(EXEEXT) \ exptest$(EXEEXT) gcm128test$(EXEEXT) hmactest$(EXEEXT) \ ideatest$(EXEEXT) igetest$(EXEEXT) md4test$(EXEEXT) \ md5test$(EXEEXT) mdc2test$(EXEEXT) mont$(EXEEXT) \ pkcs7test$(EXEEXT) poly1305test$(EXEEXT) pq_test$(EXEEXT) \ randtest$(EXEEXT) rc2test$(EXEEXT) rc4test$(EXEEXT) \ rmdtest$(EXEEXT) sha1test$(EXEEXT) sha256test$(EXEEXT) \ sha512test$(EXEEXT) shatest$(EXEEXT) ssltest$(EXEEXT) \ timingsafe$(EXEEXT) utf8test$(EXEEXT) subdir = tests ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am_aeadtest_OBJECTS = aeadtest.$(OBJEXT) aeadtest_OBJECTS = $(am_aeadtest_OBJECTS) am__DEPENDENCIES_1 = aeadtest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_aes_wrap_OBJECTS = aes_wrap.$(OBJEXT) aes_wrap_OBJECTS = $(am_aes_wrap_OBJECTS) aes_wrap_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_arc4randomforktest_OBJECTS = arc4randomforktest.$(OBJEXT) arc4randomforktest_OBJECTS = $(am_arc4randomforktest_OBJECTS) arc4randomforktest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_base64test_OBJECTS = base64test.$(OBJEXT) base64test_OBJECTS = $(am_base64test_OBJECTS) base64test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_bftest_OBJECTS = bftest.$(OBJEXT) bftest_OBJECTS = $(am_bftest_OBJECTS) bftest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_biotest_OBJECTS = biotest.$(OBJEXT) biotest_OBJECTS = $(am_biotest_OBJECTS) biotest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_bntest_OBJECTS = bntest.$(OBJEXT) bntest_OBJECTS = $(am_bntest_OBJECTS) bntest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_casttest_OBJECTS = casttest.$(OBJEXT) casttest_OBJECTS = $(am_casttest_OBJECTS) casttest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_chachatest_OBJECTS = chachatest.$(OBJEXT) chachatest_OBJECTS = $(am_chachatest_OBJECTS) chachatest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_cts128test_OBJECTS = cts128test.$(OBJEXT) cts128test_OBJECTS = $(am_cts128test_OBJECTS) cts128test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_destest_OBJECTS = destest.$(OBJEXT) destest_OBJECTS = $(am_destest_OBJECTS) destest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_dhtest_OBJECTS = dhtest.$(OBJEXT) dhtest_OBJECTS = $(am_dhtest_OBJECTS) dhtest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_dsatest_OBJECTS = dsatest.$(OBJEXT) dsatest_OBJECTS = $(am_dsatest_OBJECTS) dsatest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_ecdhtest_OBJECTS = ecdhtest.$(OBJEXT) ecdhtest_OBJECTS = $(am_ecdhtest_OBJECTS) ecdhtest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_ecdsatest_OBJECTS = ecdsatest.$(OBJEXT) ecdsatest_OBJECTS = $(am_ecdsatest_OBJECTS) ecdsatest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_ectest_OBJECTS = ectest.$(OBJEXT) ectest_OBJECTS = $(am_ectest_OBJECTS) ectest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_enginetest_OBJECTS = enginetest.$(OBJEXT) enginetest_OBJECTS = $(am_enginetest_OBJECTS) enginetest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_evptest_OBJECTS = evptest.$(OBJEXT) evptest_OBJECTS = $(am_evptest_OBJECTS) evptest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_explicit_bzero_OBJECTS = explicit_bzero.$(OBJEXT) explicit_bzero_OBJECTS = $(am_explicit_bzero_OBJECTS) explicit_bzero_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_exptest_OBJECTS = exptest.$(OBJEXT) exptest_OBJECTS = $(am_exptest_OBJECTS) exptest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_gcm128test_OBJECTS = gcm128test.$(OBJEXT) gcm128test_OBJECTS = $(am_gcm128test_OBJECTS) gcm128test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_hmactest_OBJECTS = hmactest.$(OBJEXT) hmactest_OBJECTS = $(am_hmactest_OBJECTS) hmactest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_ideatest_OBJECTS = ideatest.$(OBJEXT) ideatest_OBJECTS = $(am_ideatest_OBJECTS) ideatest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_igetest_OBJECTS = igetest.$(OBJEXT) igetest_OBJECTS = $(am_igetest_OBJECTS) igetest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_md4test_OBJECTS = md4test.$(OBJEXT) md4test_OBJECTS = $(am_md4test_OBJECTS) md4test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_md5test_OBJECTS = md5test.$(OBJEXT) md5test_OBJECTS = $(am_md5test_OBJECTS) md5test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_mdc2test_OBJECTS = mdc2test.$(OBJEXT) mdc2test_OBJECTS = $(am_mdc2test_OBJECTS) mdc2test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_mont_OBJECTS = mont.$(OBJEXT) mont_OBJECTS = $(am_mont_OBJECTS) mont_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_pkcs7test_OBJECTS = pkcs7test.$(OBJEXT) pkcs7test_OBJECTS = $(am_pkcs7test_OBJECTS) pkcs7test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_poly1305test_OBJECTS = poly1305test.$(OBJEXT) poly1305test_OBJECTS = $(am_poly1305test_OBJECTS) poly1305test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_pq_test_OBJECTS = pq_test.$(OBJEXT) pq_test_OBJECTS = $(am_pq_test_OBJECTS) pq_test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_randtest_OBJECTS = randtest.$(OBJEXT) randtest_OBJECTS = $(am_randtest_OBJECTS) randtest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_rc2test_OBJECTS = rc2test.$(OBJEXT) rc2test_OBJECTS = $(am_rc2test_OBJECTS) rc2test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_rc4test_OBJECTS = rc4test.$(OBJEXT) rc4test_OBJECTS = $(am_rc4test_OBJECTS) rc4test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_rmdtest_OBJECTS = rmdtest.$(OBJEXT) rmdtest_OBJECTS = $(am_rmdtest_OBJECTS) rmdtest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_sha1test_OBJECTS = sha1test.$(OBJEXT) sha1test_OBJECTS = $(am_sha1test_OBJECTS) sha1test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_sha256test_OBJECTS = sha256test.$(OBJEXT) sha256test_OBJECTS = $(am_sha256test_OBJECTS) sha256test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_sha512test_OBJECTS = sha512test.$(OBJEXT) sha512test_OBJECTS = $(am_sha512test_OBJECTS) sha512test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_shatest_OBJECTS = shatest.$(OBJEXT) shatest_OBJECTS = $(am_shatest_OBJECTS) shatest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_ssltest_OBJECTS = ssltest.$(OBJEXT) ssltest_OBJECTS = $(am_ssltest_OBJECTS) ssltest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_timingsafe_OBJECTS = timingsafe.$(OBJEXT) timingsafe_OBJECTS = $(am_timingsafe_OBJECTS) timingsafe_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la am_utf8test_OBJECTS = utf8test.$(OBJEXT) utf8test_OBJECTS = $(am_utf8test_OBJECTS) utf8test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(aeadtest_SOURCES) $(aes_wrap_SOURCES) \ $(arc4randomforktest_SOURCES) $(base64test_SOURCES) \ $(bftest_SOURCES) $(biotest_SOURCES) $(bntest_SOURCES) \ $(casttest_SOURCES) $(chachatest_SOURCES) \ $(cts128test_SOURCES) $(destest_SOURCES) $(dhtest_SOURCES) \ $(dsatest_SOURCES) $(ecdhtest_SOURCES) $(ecdsatest_SOURCES) \ $(ectest_SOURCES) $(enginetest_SOURCES) $(evptest_SOURCES) \ $(explicit_bzero_SOURCES) $(exptest_SOURCES) \ $(gcm128test_SOURCES) $(hmactest_SOURCES) $(ideatest_SOURCES) \ $(igetest_SOURCES) $(md4test_SOURCES) $(md5test_SOURCES) \ $(mdc2test_SOURCES) $(mont_SOURCES) $(pkcs7test_SOURCES) \ $(poly1305test_SOURCES) $(pq_test_SOURCES) $(randtest_SOURCES) \ $(rc2test_SOURCES) $(rc4test_SOURCES) $(rmdtest_SOURCES) \ $(sha1test_SOURCES) $(sha256test_SOURCES) \ $(sha512test_SOURCES) $(shatest_SOURCES) $(ssltest_SOURCES) \ $(timingsafe_SOURCES) $(utf8test_SOURCES) DIST_SOURCES = $(aeadtest_SOURCES) $(aes_wrap_SOURCES) \ $(arc4randomforktest_SOURCES) $(base64test_SOURCES) \ $(bftest_SOURCES) $(biotest_SOURCES) $(bntest_SOURCES) \ $(casttest_SOURCES) $(chachatest_SOURCES) \ $(cts128test_SOURCES) $(destest_SOURCES) $(dhtest_SOURCES) \ $(dsatest_SOURCES) $(ecdhtest_SOURCES) $(ecdsatest_SOURCES) \ $(ectest_SOURCES) $(enginetest_SOURCES) $(evptest_SOURCES) \ $(explicit_bzero_SOURCES) $(exptest_SOURCES) \ $(gcm128test_SOURCES) $(hmactest_SOURCES) $(ideatest_SOURCES) \ $(igetest_SOURCES) $(md4test_SOURCES) $(md5test_SOURCES) \ $(mdc2test_SOURCES) $(mont_SOURCES) $(pkcs7test_SOURCES) \ $(poly1305test_SOURCES) $(pq_test_SOURCES) $(randtest_SOURCES) \ $(rc2test_SOURCES) $(rc4test_SOURCES) $(rmdtest_SOURCES) \ $(sha1test_SOURCES) $(sha256test_SOURCES) \ $(sha512test_SOURCES) $(shatest_SOURCES) $(ssltest_SOURCES) \ $(timingsafe_SOURCES) $(utf8test_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no am__tty_colors = { \ $(am__tty_colors_dummy); \ if test "X$(AM_COLOR_TESTS)" = Xno; then \ am__color_tests=no; \ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ am__color_tests=yes; \ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ am__color_tests=yes; \ fi; \ if test $$am__color_tests = yes; then \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ mgn=''; \ brg=''; \ std=''; \ fi; \ } am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* # A command that, given a newline-separated list of test names on the # standard input, print the name of the tests that are to be re-run # upon "make recheck". am__list_recheck_tests = $(AWK) '{ \ recheck = 1; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ { \ if ((getline line2 < ($$0 ".log")) < 0) \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ { \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ { \ break; \ } \ }; \ if (recheck) \ print $$0; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # A command that, given a newline-separated list of test names on the # standard input, create the global log from their .trs and .log files. am__create_global_log = $(AWK) ' \ function fatal(msg) \ { \ print "fatal: making $@: " msg | "cat >&2"; \ exit 1; \ } \ function rst_section(header) \ { \ print header; \ len = length(header); \ for (i = 1; i <= len; i = i + 1) \ printf "="; \ printf "\n\n"; \ } \ { \ copy_in_global_log = 1; \ global_test_result = "RUN"; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".trs"); \ if (line ~ /$(am__global_test_result_rx)/) \ { \ sub("$(am__global_test_result_rx)", "", line); \ sub("[ ]*$$", "", line); \ global_test_result = line; \ } \ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ copy_in_global_log = 0; \ }; \ if (copy_in_global_log) \ { \ rst_section(global_test_result ": " $$0); \ while ((rc = (getline line < ($$0 ".log"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".log"); \ print line; \ }; \ printf "\n"; \ }; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # Restructured Text title. am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it # by disabling -e (using the XSI extension "set +e") if it's set. am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the # directory for the log if needed. Stores in $dir the directory # containing $f, in $tst the test, in $log the log. Executes the # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and # passes TESTS_ENVIRONMENT. Set up options for the wrapper that # will run the test scripts (or their associated LOG_COMPILER, if # thy have one). am__check_pre = \ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ case "$@" in \ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ *) am__odir=.;; \ esac; \ test "x$$am__odir" = x"." || test -d "$$am__odir" \ || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ am__enable_hard_errors=yes; \ fi; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ am__expect_failure=yes;; \ *) \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with # the '.log' extension removed). The result is saved in the shell variable # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` RECHECK_LOGS = $(TEST_LOGS) AM_RECURSIVE_TARGETS = check recheck TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) am__set_b = \ case '$@' in \ */*) \ case '$*' in \ */*) b='$*';; \ *) b=`echo '$@' | sed 's/\.log$$//'`; \ esac;; \ *) \ b='$*';; \ esac am__test_logs1 = $(TESTS:=.log) am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ NO_ARC4RANDOM_BUF = @NO_ARC4RANDOM_BUF@ NO_GETENTROPY = @NO_GETENTROPY@ NO_ISSETUGID = @NO_ISSETUGID@ NO_REALLOCARRAY = @NO_REALLOCARRAY@ NO_STRLCAT = @NO_STRLCAT@ NO_STRLCPY = @NO_STRLCPY@ NO_STRTONUM = @NO_STRTONUM@ NO_TIMINGSAFE_BCMP = @NO_TIMINGSAFE_BCMP@ NO_TIMINGSAFE_MEMCMP = @NO_TIMINGSAFE_MEMCMP@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PLATFORM_LDADD = @PLATFORM_LDADD@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ USER_CFLAGS = @USER_CFLAGS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = -I$(top_srcdir)/include -DOPENSSL_NO_ASM \ -DHAVE_CRYPTODEV -DLIBRESSL_INTERNAL -I \ $(top_srcdir)/crypto/modes -I $(top_srcdir)/crypto/asn1 EXTRA_DIST = aeadtest.sh evptest.sh pq_test.sh ssltest.sh \ arc4randomforktest.sh aeadtests.txt evptests.txt \ pq_expected.txt testssl ca.pem server.pem aeadtest_SOURCES = aeadtest.c aeadtest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la aes_wrap_SOURCES = aes_wrap.c aes_wrap_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la arc4randomforktest_SOURCES = arc4randomforktest.c arc4randomforktest_LDADD = $(PLATFORM_LDADD) \ $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la base64test_SOURCES = base64test.c base64test_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la bftest_SOURCES = bftest.c bftest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la biotest_SOURCES = biotest.c biotest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la bntest_SOURCES = bntest.c bntest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la casttest_SOURCES = casttest.c casttest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la chachatest_SOURCES = chachatest.c chachatest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la cts128test_SOURCES = cts128test.c cts128test_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la destest_SOURCES = destest.c destest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la dhtest_SOURCES = dhtest.c dhtest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la dsatest_SOURCES = dsatest.c dsatest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la ecdhtest_SOURCES = ecdhtest.c ecdhtest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la ecdsatest_SOURCES = ecdsatest.c ecdsatest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la ectest_SOURCES = ectest.c ectest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la enginetest_SOURCES = enginetest.c enginetest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la evptest_SOURCES = evptest.c evptest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la explicit_bzero_SOURCES = explicit_bzero.c explicit_bzero_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la exptest_SOURCES = exptest.c exptest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la gcm128test_SOURCES = gcm128test.c gcm128test_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la hmactest_SOURCES = hmactest.c hmactest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la ideatest_SOURCES = ideatest.c ideatest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la igetest_SOURCES = igetest.c igetest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la md4test_SOURCES = md4test.c md4test_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la md5test_SOURCES = md5test.c md5test_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la mdc2test_SOURCES = mdc2test.c mdc2test_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la mont_SOURCES = mont.c mont_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la pkcs7test_SOURCES = pkcs7test.c pkcs7test_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la poly1305test_SOURCES = poly1305test.c poly1305test_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la pq_test_SOURCES = pq_test.c pq_test_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la randtest_SOURCES = randtest.c randtest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la rc2test_SOURCES = rc2test.c rc2test_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la rc4test_SOURCES = rc4test.c rc4test_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la rmdtest_SOURCES = rmdtest.c rmdtest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la sha1test_SOURCES = sha1test.c sha1test_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la sha256test_SOURCES = sha256test.c sha256test_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la sha512test_SOURCES = sha512test.c sha512test_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la shatest_SOURCES = shatest.c shatest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la ssltest_SOURCES = ssltest.c ssltest_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la timingsafe_SOURCES = timingsafe.c timingsafe_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la utf8test_SOURCES = utf8test.c utf8test_LDADD = $(PLATFORM_LDADD) $(top_builddir)/ssl/libssl.la \ $(top_builddir)/crypto/libcrypto.la all: all-am .SUFFIXES: .SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.am.common $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu tests/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_srcdir)/Makefile.am.common: $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list aeadtest$(EXEEXT): $(aeadtest_OBJECTS) $(aeadtest_DEPENDENCIES) $(EXTRA_aeadtest_DEPENDENCIES) @rm -f aeadtest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(aeadtest_OBJECTS) $(aeadtest_LDADD) $(LIBS) aes_wrap$(EXEEXT): $(aes_wrap_OBJECTS) $(aes_wrap_DEPENDENCIES) $(EXTRA_aes_wrap_DEPENDENCIES) @rm -f aes_wrap$(EXEEXT) $(AM_V_CCLD)$(LINK) $(aes_wrap_OBJECTS) $(aes_wrap_LDADD) $(LIBS) arc4randomforktest$(EXEEXT): $(arc4randomforktest_OBJECTS) $(arc4randomforktest_DEPENDENCIES) $(EXTRA_arc4randomforktest_DEPENDENCIES) @rm -f arc4randomforktest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(arc4randomforktest_OBJECTS) $(arc4randomforktest_LDADD) $(LIBS) base64test$(EXEEXT): $(base64test_OBJECTS) $(base64test_DEPENDENCIES) $(EXTRA_base64test_DEPENDENCIES) @rm -f base64test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(base64test_OBJECTS) $(base64test_LDADD) $(LIBS) bftest$(EXEEXT): $(bftest_OBJECTS) $(bftest_DEPENDENCIES) $(EXTRA_bftest_DEPENDENCIES) @rm -f bftest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(bftest_OBJECTS) $(bftest_LDADD) $(LIBS) biotest$(EXEEXT): $(biotest_OBJECTS) $(biotest_DEPENDENCIES) $(EXTRA_biotest_DEPENDENCIES) @rm -f biotest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(biotest_OBJECTS) $(biotest_LDADD) $(LIBS) bntest$(EXEEXT): $(bntest_OBJECTS) $(bntest_DEPENDENCIES) $(EXTRA_bntest_DEPENDENCIES) @rm -f bntest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(bntest_OBJECTS) $(bntest_LDADD) $(LIBS) casttest$(EXEEXT): $(casttest_OBJECTS) $(casttest_DEPENDENCIES) $(EXTRA_casttest_DEPENDENCIES) @rm -f casttest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(casttest_OBJECTS) $(casttest_LDADD) $(LIBS) chachatest$(EXEEXT): $(chachatest_OBJECTS) $(chachatest_DEPENDENCIES) $(EXTRA_chachatest_DEPENDENCIES) @rm -f chachatest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(chachatest_OBJECTS) $(chachatest_LDADD) $(LIBS) cts128test$(EXEEXT): $(cts128test_OBJECTS) $(cts128test_DEPENDENCIES) $(EXTRA_cts128test_DEPENDENCIES) @rm -f cts128test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cts128test_OBJECTS) $(cts128test_LDADD) $(LIBS) destest$(EXEEXT): $(destest_OBJECTS) $(destest_DEPENDENCIES) $(EXTRA_destest_DEPENDENCIES) @rm -f destest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(destest_OBJECTS) $(destest_LDADD) $(LIBS) dhtest$(EXEEXT): $(dhtest_OBJECTS) $(dhtest_DEPENDENCIES) $(EXTRA_dhtest_DEPENDENCIES) @rm -f dhtest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(dhtest_OBJECTS) $(dhtest_LDADD) $(LIBS) dsatest$(EXEEXT): $(dsatest_OBJECTS) $(dsatest_DEPENDENCIES) $(EXTRA_dsatest_DEPENDENCIES) @rm -f dsatest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(dsatest_OBJECTS) $(dsatest_LDADD) $(LIBS) ecdhtest$(EXEEXT): $(ecdhtest_OBJECTS) $(ecdhtest_DEPENDENCIES) $(EXTRA_ecdhtest_DEPENDENCIES) @rm -f ecdhtest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ecdhtest_OBJECTS) $(ecdhtest_LDADD) $(LIBS) ecdsatest$(EXEEXT): $(ecdsatest_OBJECTS) $(ecdsatest_DEPENDENCIES) $(EXTRA_ecdsatest_DEPENDENCIES) @rm -f ecdsatest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ecdsatest_OBJECTS) $(ecdsatest_LDADD) $(LIBS) ectest$(EXEEXT): $(ectest_OBJECTS) $(ectest_DEPENDENCIES) $(EXTRA_ectest_DEPENDENCIES) @rm -f ectest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ectest_OBJECTS) $(ectest_LDADD) $(LIBS) enginetest$(EXEEXT): $(enginetest_OBJECTS) $(enginetest_DEPENDENCIES) $(EXTRA_enginetest_DEPENDENCIES) @rm -f enginetest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(enginetest_OBJECTS) $(enginetest_LDADD) $(LIBS) evptest$(EXEEXT): $(evptest_OBJECTS) $(evptest_DEPENDENCIES) $(EXTRA_evptest_DEPENDENCIES) @rm -f evptest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(evptest_OBJECTS) $(evptest_LDADD) $(LIBS) explicit_bzero$(EXEEXT): $(explicit_bzero_OBJECTS) $(explicit_bzero_DEPENDENCIES) $(EXTRA_explicit_bzero_DEPENDENCIES) @rm -f explicit_bzero$(EXEEXT) $(AM_V_CCLD)$(LINK) $(explicit_bzero_OBJECTS) $(explicit_bzero_LDADD) $(LIBS) exptest$(EXEEXT): $(exptest_OBJECTS) $(exptest_DEPENDENCIES) $(EXTRA_exptest_DEPENDENCIES) @rm -f exptest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(exptest_OBJECTS) $(exptest_LDADD) $(LIBS) gcm128test$(EXEEXT): $(gcm128test_OBJECTS) $(gcm128test_DEPENDENCIES) $(EXTRA_gcm128test_DEPENDENCIES) @rm -f gcm128test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(gcm128test_OBJECTS) $(gcm128test_LDADD) $(LIBS) hmactest$(EXEEXT): $(hmactest_OBJECTS) $(hmactest_DEPENDENCIES) $(EXTRA_hmactest_DEPENDENCIES) @rm -f hmactest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(hmactest_OBJECTS) $(hmactest_LDADD) $(LIBS) ideatest$(EXEEXT): $(ideatest_OBJECTS) $(ideatest_DEPENDENCIES) $(EXTRA_ideatest_DEPENDENCIES) @rm -f ideatest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ideatest_OBJECTS) $(ideatest_LDADD) $(LIBS) igetest$(EXEEXT): $(igetest_OBJECTS) $(igetest_DEPENDENCIES) $(EXTRA_igetest_DEPENDENCIES) @rm -f igetest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(igetest_OBJECTS) $(igetest_LDADD) $(LIBS) md4test$(EXEEXT): $(md4test_OBJECTS) $(md4test_DEPENDENCIES) $(EXTRA_md4test_DEPENDENCIES) @rm -f md4test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(md4test_OBJECTS) $(md4test_LDADD) $(LIBS) md5test$(EXEEXT): $(md5test_OBJECTS) $(md5test_DEPENDENCIES) $(EXTRA_md5test_DEPENDENCIES) @rm -f md5test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(md5test_OBJECTS) $(md5test_LDADD) $(LIBS) mdc2test$(EXEEXT): $(mdc2test_OBJECTS) $(mdc2test_DEPENDENCIES) $(EXTRA_mdc2test_DEPENDENCIES) @rm -f mdc2test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(mdc2test_OBJECTS) $(mdc2test_LDADD) $(LIBS) mont$(EXEEXT): $(mont_OBJECTS) $(mont_DEPENDENCIES) $(EXTRA_mont_DEPENDENCIES) @rm -f mont$(EXEEXT) $(AM_V_CCLD)$(LINK) $(mont_OBJECTS) $(mont_LDADD) $(LIBS) pkcs7test$(EXEEXT): $(pkcs7test_OBJECTS) $(pkcs7test_DEPENDENCIES) $(EXTRA_pkcs7test_DEPENDENCIES) @rm -f pkcs7test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(pkcs7test_OBJECTS) $(pkcs7test_LDADD) $(LIBS) poly1305test$(EXEEXT): $(poly1305test_OBJECTS) $(poly1305test_DEPENDENCIES) $(EXTRA_poly1305test_DEPENDENCIES) @rm -f poly1305test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(poly1305test_OBJECTS) $(poly1305test_LDADD) $(LIBS) pq_test$(EXEEXT): $(pq_test_OBJECTS) $(pq_test_DEPENDENCIES) $(EXTRA_pq_test_DEPENDENCIES) @rm -f pq_test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(pq_test_OBJECTS) $(pq_test_LDADD) $(LIBS) randtest$(EXEEXT): $(randtest_OBJECTS) $(randtest_DEPENDENCIES) $(EXTRA_randtest_DEPENDENCIES) @rm -f randtest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(randtest_OBJECTS) $(randtest_LDADD) $(LIBS) rc2test$(EXEEXT): $(rc2test_OBJECTS) $(rc2test_DEPENDENCIES) $(EXTRA_rc2test_DEPENDENCIES) @rm -f rc2test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(rc2test_OBJECTS) $(rc2test_LDADD) $(LIBS) rc4test$(EXEEXT): $(rc4test_OBJECTS) $(rc4test_DEPENDENCIES) $(EXTRA_rc4test_DEPENDENCIES) @rm -f rc4test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(rc4test_OBJECTS) $(rc4test_LDADD) $(LIBS) rmdtest$(EXEEXT): $(rmdtest_OBJECTS) $(rmdtest_DEPENDENCIES) $(EXTRA_rmdtest_DEPENDENCIES) @rm -f rmdtest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(rmdtest_OBJECTS) $(rmdtest_LDADD) $(LIBS) sha1test$(EXEEXT): $(sha1test_OBJECTS) $(sha1test_DEPENDENCIES) $(EXTRA_sha1test_DEPENDENCIES) @rm -f sha1test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(sha1test_OBJECTS) $(sha1test_LDADD) $(LIBS) sha256test$(EXEEXT): $(sha256test_OBJECTS) $(sha256test_DEPENDENCIES) $(EXTRA_sha256test_DEPENDENCIES) @rm -f sha256test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(sha256test_OBJECTS) $(sha256test_LDADD) $(LIBS) sha512test$(EXEEXT): $(sha512test_OBJECTS) $(sha512test_DEPENDENCIES) $(EXTRA_sha512test_DEPENDENCIES) @rm -f sha512test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(sha512test_OBJECTS) $(sha512test_LDADD) $(LIBS) shatest$(EXEEXT): $(shatest_OBJECTS) $(shatest_DEPENDENCIES) $(EXTRA_shatest_DEPENDENCIES) @rm -f shatest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(shatest_OBJECTS) $(shatest_LDADD) $(LIBS) ssltest$(EXEEXT): $(ssltest_OBJECTS) $(ssltest_DEPENDENCIES) $(EXTRA_ssltest_DEPENDENCIES) @rm -f ssltest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ssltest_OBJECTS) $(ssltest_LDADD) $(LIBS) timingsafe$(EXEEXT): $(timingsafe_OBJECTS) $(timingsafe_DEPENDENCIES) $(EXTRA_timingsafe_DEPENDENCIES) @rm -f timingsafe$(EXEEXT) $(AM_V_CCLD)$(LINK) $(timingsafe_OBJECTS) $(timingsafe_LDADD) $(LIBS) utf8test$(EXEEXT): $(utf8test_OBJECTS) $(utf8test_DEPENDENCIES) $(EXTRA_utf8test_DEPENDENCIES) @rm -f utf8test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(utf8test_OBJECTS) $(utf8test_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aeadtest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aes_wrap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arc4randomforktest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base64test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bftest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/biotest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bntest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/casttest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chachatest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cts128test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/destest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dhtest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dsatest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecdhtest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecdsatest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ectest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enginetest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evptest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/explicit_bzero.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exptest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gcm128test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hmactest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ideatest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/igetest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md4test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mdc2test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mont.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pkcs7test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poly1305test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pq_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/randtest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rc2test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rc4test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rmdtest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha256test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha512test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shatest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssltest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timingsafe.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utf8test.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ else \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all $(check_PROGRAMS) @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ log_list=`for i in $$bases; do echo $$i.log; done`; \ log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? aes_wrap.log: aes_wrap$(EXEEXT) @p='aes_wrap$(EXEEXT)'; \ b='aes_wrap'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) base64test.log: base64test$(EXEEXT) @p='base64test$(EXEEXT)'; \ b='base64test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) bftest.log: bftest$(EXEEXT) @p='bftest$(EXEEXT)'; \ b='bftest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) bntest.log: bntest$(EXEEXT) @p='bntest$(EXEEXT)'; \ b='bntest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) casttest.log: casttest$(EXEEXT) @p='casttest$(EXEEXT)'; \ b='casttest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) chachatest.log: chachatest$(EXEEXT) @p='chachatest$(EXEEXT)'; \ b='chachatest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) cts128test.log: cts128test$(EXEEXT) @p='cts128test$(EXEEXT)'; \ b='cts128test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) destest.log: destest$(EXEEXT) @p='destest$(EXEEXT)'; \ b='destest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) dhtest.log: dhtest$(EXEEXT) @p='dhtest$(EXEEXT)'; \ b='dhtest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) dsatest.log: dsatest$(EXEEXT) @p='dsatest$(EXEEXT)'; \ b='dsatest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) ecdhtest.log: ecdhtest$(EXEEXT) @p='ecdhtest$(EXEEXT)'; \ b='ecdhtest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) ecdsatest.log: ecdsatest$(EXEEXT) @p='ecdsatest$(EXEEXT)'; \ b='ecdsatest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) ectest.log: ectest$(EXEEXT) @p='ectest$(EXEEXT)'; \ b='ectest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) enginetest.log: enginetest$(EXEEXT) @p='enginetest$(EXEEXT)'; \ b='enginetest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) explicit_bzero.log: explicit_bzero$(EXEEXT) @p='explicit_bzero$(EXEEXT)'; \ b='explicit_bzero'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) exptest.log: exptest$(EXEEXT) @p='exptest$(EXEEXT)'; \ b='exptest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) gcm128test.log: gcm128test$(EXEEXT) @p='gcm128test$(EXEEXT)'; \ b='gcm128test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) hmactest.log: hmactest$(EXEEXT) @p='hmactest$(EXEEXT)'; \ b='hmactest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) ideatest.log: ideatest$(EXEEXT) @p='ideatest$(EXEEXT)'; \ b='ideatest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) igetest.log: igetest$(EXEEXT) @p='igetest$(EXEEXT)'; \ b='igetest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) md4test.log: md4test$(EXEEXT) @p='md4test$(EXEEXT)'; \ b='md4test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) md5test.log: md5test$(EXEEXT) @p='md5test$(EXEEXT)'; \ b='md5test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) mdc2test.log: mdc2test$(EXEEXT) @p='mdc2test$(EXEEXT)'; \ b='mdc2test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) mont.log: mont$(EXEEXT) @p='mont$(EXEEXT)'; \ b='mont'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) pkcs7test.log: pkcs7test$(EXEEXT) @p='pkcs7test$(EXEEXT)'; \ b='pkcs7test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) poly1305test.log: poly1305test$(EXEEXT) @p='poly1305test$(EXEEXT)'; \ b='poly1305test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) randtest.log: randtest$(EXEEXT) @p='randtest$(EXEEXT)'; \ b='randtest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) rc2test.log: rc2test$(EXEEXT) @p='rc2test$(EXEEXT)'; \ b='rc2test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) rc4test.log: rc4test$(EXEEXT) @p='rc4test$(EXEEXT)'; \ b='rc4test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) rmdtest.log: rmdtest$(EXEEXT) @p='rmdtest$(EXEEXT)'; \ b='rmdtest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) sha1test.log: sha1test$(EXEEXT) @p='sha1test$(EXEEXT)'; \ b='sha1test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) sha256test.log: sha256test$(EXEEXT) @p='sha256test$(EXEEXT)'; \ b='sha256test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) sha512test.log: sha512test$(EXEEXT) @p='sha512test$(EXEEXT)'; \ b='sha512test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) shatest.log: shatest$(EXEEXT) @p='shatest$(EXEEXT)'; \ b='shatest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) timingsafe.log: timingsafe$(EXEEXT) @p='timingsafe$(EXEEXT)'; \ b='timingsafe'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) utf8test.log: utf8test$(EXEEXT) @p='utf8test$(EXEEXT)'; \ b='utf8test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) aeadtest.sh.log: aeadtest.sh @p='aeadtest.sh'; \ b='aeadtest.sh'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) evptest.sh.log: evptest.sh @p='evptest.sh'; \ b='evptest.sh'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) pq_test.sh.log: pq_test.sh @p='pq_test.sh'; \ b='pq_test.sh'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) ssltest.sh.log: ssltest.sh @p='ssltest.sh'; \ b='ssltest.sh'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) arc4randomforktest.sh.log: arc4randomforktest.sh @p='arc4randomforktest.sh'; \ b='arc4randomforktest.sh'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @am__EXEEXT_TRUE@ @p='$<'; \ @am__EXEEXT_TRUE@ $(am__set_b); \ @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \ ctags ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ recheck tags tags-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: deps/libressl-pnacl-sys-2.1.6/libressl/tests/sha512test.c0000644000175000017500000001355412360020706020155 0ustar /* crypto/sha/sha512t.c */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved. * ==================================================================== */ #include #include #include #include #include #include #if defined(OPENSSL_NO_SHA) || defined(OPENSSL_NO_SHA512) int main(int argc, char *argv[]) { printf("No SHA512 support\n"); return (0); } #else unsigned char app_c1[SHA512_DIGEST_LENGTH] = { 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba, 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31, 0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2, 0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a, 0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8, 0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd, 0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e, 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f, }; unsigned char app_c2[SHA512_DIGEST_LENGTH] = { 0x8e, 0x95, 0x9b, 0x75, 0xda, 0xe3, 0x13, 0xda, 0x8c, 0xf4, 0xf7, 0x28, 0x14, 0xfc, 0x14, 0x3f, 0x8f, 0x77, 0x79, 0xc6, 0xeb, 0x9f, 0x7f, 0xa1, 0x72, 0x99, 0xae, 0xad, 0xb6, 0x88, 0x90, 0x18, 0x50, 0x1d, 0x28, 0x9e, 0x49, 0x00, 0xf7, 0xe4, 0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a, 0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54, 0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09, }; unsigned char app_c3[SHA512_DIGEST_LENGTH] = { 0xe7, 0x18, 0x48, 0x3d, 0x0c, 0xe7, 0x69, 0x64, 0x4e, 0x2e, 0x42, 0xc7, 0xbc, 0x15, 0xb4, 0x63, 0x8e, 0x1f, 0x98, 0xb1, 0x3b, 0x20, 0x44, 0x28, 0x56, 0x32, 0xa8, 0x03, 0xaf, 0xa9, 0x73, 0xeb, 0xde, 0x0f, 0xf2, 0x44, 0x87, 0x7e, 0xa6, 0x0a, 0x4c, 0xb0, 0x43, 0x2c, 0xe5, 0x77, 0xc3, 0x1b, 0xeb, 0x00, 0x9c, 0x5c, 0x2c, 0x49, 0xaa, 0x2e, 0x4e, 0xad, 0xb2, 0x17, 0xad, 0x8c, 0xc0, 0x9b, }; unsigned char app_d1[SHA384_DIGEST_LENGTH] = { 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b, 0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07, 0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63, 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed, 0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23, 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7, }; unsigned char app_d2[SHA384_DIGEST_LENGTH] = { 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8, 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47, 0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2, 0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12, 0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9, 0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39, }; unsigned char app_d3[SHA384_DIGEST_LENGTH] = { 0x9d, 0x0e, 0x18, 0x09, 0x71, 0x64, 0x74, 0xcb, 0x08, 0x6e, 0x83, 0x4e, 0x31, 0x0a, 0x4a, 0x1c, 0xed, 0x14, 0x9e, 0x9c, 0x00, 0xf2, 0x48, 0x52, 0x79, 0x72, 0xce, 0xc5, 0x70, 0x4c, 0x2a, 0x5b, 0x07, 0xb8, 0xb3, 0xdc, 0x38, 0xec, 0xc4, 0xeb, 0xae, 0x97, 0xdd, 0xd8, 0x7f, 0x3d, 0x89, 0x85, }; int main(int argc, char **argv) { unsigned char md[SHA512_DIGEST_LENGTH]; int i; EVP_MD_CTX evp; #ifdef OPENSSL_IA32_SSE2 /* Alternative to this is to call OpenSSL_add_all_algorithms... * The below code is retained exclusively for debugging purposes. */ { char *env; if ((env=getenv("OPENSSL_ia32cap"))) OPENSSL_ia32cap = strtoul (env, NULL, 0); } #endif fprintf(stdout, "Testing SHA-512 "); EVP_Digest("abc", 3, md, NULL, EVP_sha512(), NULL); if (memcmp(md, app_c1, sizeof(app_c1))) { fflush(stdout); fprintf(stderr, "\nTEST 1 of 3 failed.\n"); return 1; } else fprintf(stdout, "."); fflush(stdout); EVP_Digest( "abcdefgh""bcdefghi""cdefghij""defghijk" "efghijkl""fghijklm""ghijklmn""hijklmno" "ijklmnop""jklmnopq""klmnopqr""lmnopqrs" "mnopqrst""nopqrstu", 112, md, NULL, EVP_sha512(), NULL); if (memcmp(md, app_c2, sizeof(app_c2))) { fflush(stdout); fprintf(stderr, "\nTEST 2 of 3 failed.\n"); return 1; } fprintf(stdout, "."); fflush(stdout); EVP_MD_CTX_init(&evp); EVP_DigestInit_ex(&evp, EVP_sha512(), NULL); for (i = 0; i < 1000000; i += 288) EVP_DigestUpdate(&evp, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", (1000000 - i) < 288 ? 1000000 - i : 288); EVP_DigestFinal_ex(&evp, md, NULL); EVP_MD_CTX_cleanup(&evp); if (memcmp(md, app_c3, sizeof(app_c3))) { fflush(stdout); fprintf(stderr, "\nTEST 3 of 3 failed.\n"); return 1; } fprintf(stdout, "."); fflush(stdout); fprintf(stdout, " passed.\n"); fflush(stdout); fprintf(stdout, "Testing SHA-384 "); EVP_Digest("abc", 3, md, NULL, EVP_sha384(), NULL); if (memcmp(md, app_d1, sizeof(app_d1))) { fflush(stdout); fprintf(stderr, "\nTEST 1 of 3 failed.\n"); return 1; } fprintf(stdout, "."); fflush(stdout); EVP_Digest( "abcdefgh""bcdefghi""cdefghij""defghijk" "efghijkl""fghijklm""ghijklmn""hijklmno" "ijklmnop""jklmnopq""klmnopqr""lmnopqrs" "mnopqrst""nopqrstu", 112, md, NULL, EVP_sha384(), NULL); if (memcmp(md, app_d2, sizeof(app_d2))) { fflush(stdout); fprintf(stderr, "\nTEST 2 of 3 failed.\n"); return 1; } fprintf(stdout, "."); fflush(stdout); EVP_MD_CTX_init(&evp); EVP_DigestInit_ex(&evp, EVP_sha384(), NULL); for (i = 0; i < 1000000; i += 64) EVP_DigestUpdate(&evp, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", (1000000 - i) < 64 ? 1000000 - i : 64); EVP_DigestFinal_ex(&evp, md, NULL); EVP_MD_CTX_cleanup(&evp); if (memcmp(md, app_d3, sizeof(app_d3))) { fflush(stdout); fprintf(stderr, "\nTEST 3 of 3 failed.\n"); return 1; } fprintf(stdout, "."); fflush(stdout); fprintf(stdout, " passed.\n"); fflush(stdout); return 0; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/tests/evptests.txt0000644000175000017500000010673412360020706020527 0ustar #cipher:key:iv:plaintext:ciphertext:0/1(decrypt/encrypt) #digest:::input:output # SHA(1) tests (from shatest.c) SHA1:::616263:a9993e364706816aba3e25717850c26c9cd0d89d # MD5 tests (from md5test.c) MD5::::d41d8cd98f00b204e9800998ecf8427e MD5:::61:0cc175b9c0f1b6a831c399e269772661 MD5:::616263:900150983cd24fb0d6963f7d28e17f72 MD5:::6d65737361676520646967657374:f96b697d7cb7938d525a2f31aaf161d0 MD5:::6162636465666768696a6b6c6d6e6f707172737475767778797a:c3fcd3d76192e4007dfb496cca67e13b MD5:::4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a30313233343536373839:d174ab98d277d9f5a5611c2c9f419d9f MD5:::3132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930:57edf4a22be3c955ac49da2e2107b67a # AES 128 ECB tests (from FIPS-197 test vectors, encrypt) AES-128-ECB:000102030405060708090A0B0C0D0E0F::00112233445566778899AABBCCDDEEFF:69C4E0D86A7B0430D8CDB78070B4C55A:1 # AES 192 ECB tests (from FIPS-197 test vectors, encrypt) AES-192-ECB:000102030405060708090A0B0C0D0E0F1011121314151617::00112233445566778899AABBCCDDEEFF:DDA97CA4864CDFE06EAF70A0EC0D7191:1 # AES 256 ECB tests (from FIPS-197 test vectors, encrypt) AES-256-ECB:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F::00112233445566778899AABBCCDDEEFF:8EA2B7CA516745BFEAFC49904B496089:1 # AES 128 ECB tests (from NIST test vectors, encrypt) #AES-128-ECB:00000000000000000000000000000000::00000000000000000000000000000000:C34C052CC0DA8D73451AFE5F03BE297F:1 # AES 128 ECB tests (from NIST test vectors, decrypt) #AES-128-ECB:00000000000000000000000000000000::44416AC2D1F53C583303917E6BE9EBE0:00000000000000000000000000000000:0 # AES 192 ECB tests (from NIST test vectors, decrypt) #AES-192-ECB:000000000000000000000000000000000000000000000000::48E31E9E256718F29229319C19F15BA4:00000000000000000000000000000000:0 # AES 256 ECB tests (from NIST test vectors, decrypt) #AES-256-ECB:0000000000000000000000000000000000000000000000000000000000000000::058CCFFDBBCB382D1F6F56585D8A4ADE:00000000000000000000000000000000:0 # AES 128 CBC tests (from NIST test vectors, encrypt) #AES-128-CBC:00000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:8A05FC5E095AF4848A08D328D3688E3D:1 # AES 192 CBC tests (from NIST test vectors, encrypt) #AES-192-CBC:000000000000000000000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:7BD966D53AD8C1BB85D2ADFAE87BB104:1 # AES 256 CBC tests (from NIST test vectors, encrypt) #AES-256-CBC:0000000000000000000000000000000000000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:FE3C53653E2F45B56FCD88B2CC898FF0:1 # AES 128 CBC tests (from NIST test vectors, decrypt) #AES-128-CBC:00000000000000000000000000000000:00000000000000000000000000000000:FACA37E0B0C85373DF706E73F7C9AF86:00000000000000000000000000000000:0 # AES tests from NIST document SP800-38A # For all ECB encrypts and decrypts, the transformed sequence is # AES-bits-ECB:key::plaintext:ciphertext:encdec # ECB-AES128.Encrypt and ECB-AES128.Decrypt AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::6BC1BEE22E409F96E93D7E117393172A:3AD77BB40D7A3660A89ECAF32466EF97 AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::AE2D8A571E03AC9C9EB76FAC45AF8E51:F5D3D58503B9699DE785895A96FDBAAF AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::30C81C46A35CE411E5FBC1191A0A52EF:43B1CD7F598ECE23881B00E3ED030688 AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::F69F2445DF4F9B17AD2B417BE66C3710:7B0C785E27E8AD3F8223207104725DD4 # ECB-AES192.Encrypt and ECB-AES192.Decrypt AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::6BC1BEE22E409F96E93D7E117393172A:BD334F1D6E45F25FF712A214571FA5CC AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::AE2D8A571E03AC9C9EB76FAC45AF8E51:974104846D0AD3AD7734ECB3ECEE4EEF AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::30C81C46A35CE411E5FBC1191A0A52EF:EF7AFD2270E2E60ADCE0BA2FACE6444E AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::F69F2445DF4F9B17AD2B417BE66C3710:9A4B41BA738D6C72FB16691603C18E0E # ECB-AES256.Encrypt and ECB-AES256.Decrypt AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::6BC1BEE22E409F96E93D7E117393172A:F3EED1BDB5D2A03C064B5A7E3DB181F8 AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::AE2D8A571E03AC9C9EB76FAC45AF8E51:591CCB10D410ED26DC5BA74A31362870 AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::30C81C46A35CE411E5FBC1191A0A52EF:B6ED21B99CA6F4F9F153E7B1BEAFED1D AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::F69F2445DF4F9B17AD2B417BE66C3710:23304B7A39F9F3FF067D8D8F9E24ECC7 # For all CBC encrypts and decrypts, the transformed sequence is # AES-bits-CBC:key:IV/ciphertext':plaintext:ciphertext:encdec # CBC-AES128.Encrypt and CBC-AES128.Decrypt AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:7649ABAC8119B246CEE98E9B12E9197D AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:7649ABAC8119B246CEE98E9B12E9197D:AE2D8A571E03AC9C9EB76FAC45AF8E51:5086CB9B507219EE95DB113A917678B2 AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:5086CB9B507219EE95DB113A917678B2:30C81C46A35CE411E5FBC1191A0A52EF:73BED6B8E3C1743B7116E69E22229516 AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:73BED6B8E3C1743B7116E69E22229516:F69F2445DF4F9B17AD2B417BE66C3710:3FF1CAA1681FAC09120ECA307586E1A7 # CBC-AES192.Encrypt and CBC-AES192.Decrypt AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:4F021DB243BC633D7178183A9FA071E8 AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:4F021DB243BC633D7178183A9FA071E8:AE2D8A571E03AC9C9EB76FAC45AF8E51:B4D9ADA9AD7DEDF4E5E738763F69145A AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:B4D9ADA9AD7DEDF4E5E738763F69145A:30C81C46A35CE411E5FBC1191A0A52EF:571B242012FB7AE07FA9BAAC3DF102E0 AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:571B242012FB7AE07FA9BAAC3DF102E0:F69F2445DF4F9B17AD2B417BE66C3710:08B0E27988598881D920A9E64F5615CD # CBC-AES256.Encrypt and CBC-AES256.Decrypt AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:F58C4C04D6E5F1BA779EABFB5F7BFBD6 AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:F58C4C04D6E5F1BA779EABFB5F7BFBD6:AE2D8A571E03AC9C9EB76FAC45AF8E51:9CFC4E967EDB808D679F777BC6702C7D AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:9CFC4E967EDB808D679F777BC6702C7D:30C81C46A35CE411E5FBC1191A0A52EF:39F23369A9D9BACFA530E26304231461 AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39F23369A9D9BACFA530E26304231461:F69F2445DF4F9B17AD2B417BE66C3710:B2EB05E2C39BE9FCDA6C19078C6A9D1B # We don't support CFB{1,8}-AESxxx.{En,De}crypt # For all CFB128 encrypts and decrypts, the transformed sequence is # AES-bits-CFB:key:IV/ciphertext':plaintext:ciphertext:encdec # CFB128-AES128.Encrypt AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:1 AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:3B3FD92EB72DAD20333449F8E83CFB4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:C8A64537A0B3A93FCDE3CDAD9F1CE58B:1 AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:C8A64537A0B3A93FCDE3CDAD9F1CE58B:30C81C46A35CE411E5FBC1191A0A52EF:26751F67A3CBB140B1808CF187A4F4DF:1 AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:26751F67A3CBB140B1808CF187A4F4DF:F69F2445DF4F9B17AD2B417BE66C3710:C04B05357C5D1C0EEAC4C66F9FF7F2E6:1 # CFB128-AES128.Decrypt AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:0 AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:3B3FD92EB72DAD20333449F8E83CFB4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:C8A64537A0B3A93FCDE3CDAD9F1CE58B:0 AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:C8A64537A0B3A93FCDE3CDAD9F1CE58B:30C81C46A35CE411E5FBC1191A0A52EF:26751F67A3CBB140B1808CF187A4F4DF:0 AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:26751F67A3CBB140B1808CF187A4F4DF:F69F2445DF4F9B17AD2B417BE66C3710:C04B05357C5D1C0EEAC4C66F9FF7F2E6:0 # CFB128-AES192.Encrypt AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:1 AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:CDC80D6FDDF18CAB34C25909C99A4174:AE2D8A571E03AC9C9EB76FAC45AF8E51:67CE7F7F81173621961A2B70171D3D7A:1 AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:67CE7F7F81173621961A2B70171D3D7A:30C81C46A35CE411E5FBC1191A0A52EF:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:1 AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:F69F2445DF4F9B17AD2B417BE66C3710:C05F9F9CA9834FA042AE8FBA584B09FF:1 # CFB128-AES192.Decrypt AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:0 AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:CDC80D6FDDF18CAB34C25909C99A4174:AE2D8A571E03AC9C9EB76FAC45AF8E51:67CE7F7F81173621961A2B70171D3D7A:0 AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:67CE7F7F81173621961A2B70171D3D7A:30C81C46A35CE411E5FBC1191A0A52EF:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:0 AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:F69F2445DF4F9B17AD2B417BE66C3710:C05F9F9CA9834FA042AE8FBA584B09FF:0 # CFB128-AES256.Encrypt AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:1 AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DC7E84BFDA79164B7ECD8486985D3860:AE2D8A571E03AC9C9EB76FAC45AF8E51:39FFED143B28B1C832113C6331E5407B:1 AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39FFED143B28B1C832113C6331E5407B:30C81C46A35CE411E5FBC1191A0A52EF:DF10132415E54B92A13ED0A8267AE2F9:1 AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DF10132415E54B92A13ED0A8267AE2F9:F69F2445DF4F9B17AD2B417BE66C3710:75A385741AB9CEF82031623D55B1E471:1 # CFB128-AES256.Decrypt AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:0 AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DC7E84BFDA79164B7ECD8486985D3860:AE2D8A571E03AC9C9EB76FAC45AF8E51:39FFED143B28B1C832113C6331E5407B:0 AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39FFED143B28B1C832113C6331E5407B:30C81C46A35CE411E5FBC1191A0A52EF:DF10132415E54B92A13ED0A8267AE2F9:0 AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DF10132415E54B92A13ED0A8267AE2F9:F69F2445DF4F9B17AD2B417BE66C3710:75A385741AB9CEF82031623D55B1E471:0 # For all OFB encrypts and decrypts, the transformed sequence is # AES-bits-CFB:key:IV/output':plaintext:ciphertext:encdec # OFB-AES128.Encrypt AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:1 AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:50FE67CC996D32B6DA0937E99BAFEC60:AE2D8A571E03AC9C9EB76FAC45AF8E51:7789508D16918F03F53C52DAC54ED825:1 AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:D9A4DADA0892239F6B8B3D7680E15674:30C81C46A35CE411E5FBC1191A0A52EF:9740051E9C5FECF64344F7A82260EDCC:1 AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:A78819583F0308E7A6BF36B1386ABF23:F69F2445DF4F9B17AD2B417BE66C3710:304C6528F659C77866A510D9C1D6AE5E:1 # OFB-AES128.Decrypt AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:0 AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:50FE67CC996D32B6DA0937E99BAFEC60:AE2D8A571E03AC9C9EB76FAC45AF8E51:7789508D16918F03F53C52DAC54ED825:0 AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:D9A4DADA0892239F6B8B3D7680E15674:30C81C46A35CE411E5FBC1191A0A52EF:9740051E9C5FECF64344F7A82260EDCC:0 AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:A78819583F0308E7A6BF36B1386ABF23:F69F2445DF4F9B17AD2B417BE66C3710:304C6528F659C77866A510D9C1D6AE5E:0 # OFB-AES192.Encrypt AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:1 AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:A609B38DF3B1133DDDFF2718BA09565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:FCC28B8D4C63837C09E81700C1100401:1 AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:52EF01DA52602FE0975F78AC84BF8A50:30C81C46A35CE411E5FBC1191A0A52EF:8D9A9AEAC0F6596F559C6D4DAF59A5F2:1 AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:BD5286AC63AABD7EB067AC54B553F71D:F69F2445DF4F9B17AD2B417BE66C3710:6D9F200857CA6C3E9CAC524BD9ACC92A:1 # OFB-AES192.Decrypt AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:0 AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:A609B38DF3B1133DDDFF2718BA09565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:FCC28B8D4C63837C09E81700C1100401:0 AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:52EF01DA52602FE0975F78AC84BF8A50:30C81C46A35CE411E5FBC1191A0A52EF:8D9A9AEAC0F6596F559C6D4DAF59A5F2:0 AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:BD5286AC63AABD7EB067AC54B553F71D:F69F2445DF4F9B17AD2B417BE66C3710:6D9F200857CA6C3E9CAC524BD9ACC92A:0 # OFB-AES256.Encrypt AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:1 AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7BF3A5DF43989DD97F0FA97EBCE2F4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:4FEBDC6740D20B3AC88F6AD82A4FB08D:1 AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:71AB47A086E86EEDF39D1C5BBA97C408:1 AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0126141D67F37BE8538F5A8BE740E484:1 # OFB-AES256.Decrypt AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:0 AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7BF3A5DF43989DD97F0FA97EBCE2F4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:4FEBDC6740D20B3AC88F6AD82A4FB08D:0 AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:71AB47A086E86EEDF39D1C5BBA97C408:0 AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0126141D67F37BE8538F5A8BE740E484:0 # AES Counter test vectors from RFC3686 aes-128-ctr:AE6852F8121067CC4BF7A5765577F39E:00000030000000000000000000000001:53696E676C6520626C6F636B206D7367:E4095D4FB7A7B3792D6175A3261311B8:1 aes-128-ctr:7E24067817FAE0D743D6CE1F32539163:006CB6DBC0543B59DA48D90B00000001:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F:5104A106168A72D9790D41EE8EDAD388EB2E1EFC46DA57C8FCE630DF9141BE28:1 aes-128-ctr:7691BE035E5020A8AC6E618529F9A0DC:00E0017B27777F3F4A1786F000000001:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223:C1CF48A89F2FFDD9CF4652E9EFDB72D74540A42BDE6D7836D59A5CEAAEF3105325B2072F:1 aes-192-ctr:16AF5B145FC9F579C175F93E3BFB0EED863D06CCFDB78515:0000004836733C147D6D93CB00000001:53696E676C6520626C6F636B206D7367:4B55384FE259C9C84E7935A003CBE928:1 aes-192-ctr:7C5CB2401B3DC33C19E7340819E0F69C678C3DB8E6F6A91A:0096B03B020C6EADC2CB500D00000001:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F:453243FC609B23327EDFAAFA7131CD9F8490701C5AD4A79CFC1FE0FF42F4FB00:1 aes-192-ctr:02BF391EE8ECB159B959617B0965279BF59B60A786D3E0FE:0007BDFD5CBD60278DCC091200000001:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223:96893FC55E5C722F540B7DD1DDF7E758D288BC95C69165884536C811662F2188ABEE0935:1 aes-256-ctr:776BEFF2851DB06F4C8A0542C8696F6C6A81AF1EEC96B4D37FC1D689E6C1C104:00000060DB5672C97AA8F0B200000001:53696E676C6520626C6F636B206D7367:145AD01DBF824EC7560863DC71E3E0C0:1 aes-256-ctr:F6D66D6BD52D59BB0796365879EFF886C66DD51A5B6A99744B50590C87A23884:00FAAC24C1585EF15A43D87500000001:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F:F05E231B3894612C49EE000B804EB2A9B8306B508F839D6A5530831D9344AF1C:1 aes-256-ctr:FF7A617CE69148E4F1726E2F43581DE2AA62D9F805532EDFF1EED687FB54153D:001CC5B751A51D70A1C1114800000001:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223:EB6C52821D0BBBF7CE7594462ACA4FAAB407DF866569FD07F48CC0B583D6071F1EC0E6B8:1 # DES ECB tests (from destest) DES-ECB:0000000000000000::0000000000000000:8CA64DE9C1B123A7 DES-ECB:FFFFFFFFFFFFFFFF::FFFFFFFFFFFFFFFF:7359B2163E4EDC58 DES-ECB:3000000000000000::1000000000000001:958E6E627A05557B DES-ECB:1111111111111111::1111111111111111:F40379AB9E0EC533 DES-ECB:0123456789ABCDEF::1111111111111111:17668DFC7292532D DES-ECB:1111111111111111::0123456789ABCDEF:8A5AE1F81AB8F2DD DES-ECB:FEDCBA9876543210::0123456789ABCDEF:ED39D950FA74BCC4 # DESX-CBC tests (from destest) DESX-CBC:0123456789abcdeff1e0d3c2b5a49786fedcba9876543210:fedcba9876543210:37363534333231204E6F77206973207468652074696D6520666F722000000000:846B2914851E9A2954732F8AA0A611C115CDC2D7951B1053A63C5E03B21AA3C4 # DES EDE3 CBC tests (from destest) DES-EDE3-CBC:0123456789abcdeff1e0d3c2b5a49786fedcba9876543210:fedcba9876543210:37363534333231204E6F77206973207468652074696D6520666F722000000000:3FE301C962AC01D02213763C1CBD4CDC799657C064ECF5D41C673812CFDE9675 # RC4 tests (from rc4test) RC4:0123456789abcdef0123456789abcdef::0123456789abcdef:75b7878099e0c596 RC4:0123456789abcdef0123456789abcdef::0000000000000000:7494c2e7104b0879 RC4:00000000000000000000000000000000::0000000000000000:de188941a3375d3a RC4:ef012345ef012345ef012345ef012345::0000000000000000000000000000000000000000:d6a141a7ec3c38dfbd615a1162e1c7ba36b67858 RC4:0123456789abcdef0123456789abcdef::123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345678:66a0949f8af7d6891f7f832ba833c00c892ebe30143ce28740011ecf RC4:ef012345ef012345ef012345ef012345::00000000000000000000:d6a141a7ec3c38dfbd61 # Camellia tests from RFC3713 # For all ECB encrypts and decrypts, the transformed sequence is # CAMELLIA-bits-ECB:key::plaintext:ciphertext:encdec CAMELLIA-128-ECB:0123456789abcdeffedcba9876543210::0123456789abcdeffedcba9876543210:67673138549669730857065648eabe43 CAMELLIA-192-ECB:0123456789abcdeffedcba98765432100011223344556677::0123456789abcdeffedcba9876543210:b4993401b3e996f84ee5cee7d79b09b9 CAMELLIA-256-ECB:0123456789abcdeffedcba987654321000112233445566778899aabbccddeeff::0123456789abcdeffedcba9876543210:9acc237dff16d76c20ef7c919e3a7509 # ECB-CAMELLIA128.Encrypt CAMELLIA-128-ECB:000102030405060708090A0B0C0D0E0F::00112233445566778899AABBCCDDEEFF:77CF412067AF8270613529149919546F:1 CAMELLIA-192-ECB:000102030405060708090A0B0C0D0E0F1011121314151617::00112233445566778899AABBCCDDEEFF:B22F3C36B72D31329EEE8ADDC2906C68:1 CAMELLIA-256-ECB:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F::00112233445566778899AABBCCDDEEFF:2EDF1F3418D53B88841FC8985FB1ECF2:1 # ECB-CAMELLIA128.Encrypt and ECB-CAMELLIA128.Decrypt CAMELLIA-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::6BC1BEE22E409F96E93D7E117393172A:432FC5DCD628115B7C388D770B270C96 CAMELLIA-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::AE2D8A571E03AC9C9EB76FAC45AF8E51:0BE1F14023782A22E8384C5ABB7FAB2B CAMELLIA-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::30C81C46A35CE411E5FBC1191A0A52EF:A0A1ABCD1893AB6FE0FE5B65DF5F8636 CAMELLIA-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::F69F2445DF4F9B17AD2B417BE66C3710:E61925E0D5DFAA9BB29F815B3076E51A # ECB-CAMELLIA192.Encrypt and ECB-CAMELLIA192.Decrypt CAMELLIA-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::6BC1BEE22E409F96E93D7E117393172A:CCCC6C4E138B45848514D48D0D3439D3 CAMELLIA-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::AE2D8A571E03AC9C9EB76FAC45AF8E51:5713C62C14B2EC0F8393B6AFD6F5785A CAMELLIA-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::30C81C46A35CE411E5FBC1191A0A52EF:B40ED2B60EB54D09D030CF511FEEF366 CAMELLIA-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::F69F2445DF4F9B17AD2B417BE66C3710:909DBD95799096748CB27357E73E1D26 # ECB-CAMELLIA256.Encrypt and ECB-CAMELLIA256.Decrypt CAMELLIA-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::6BC1BEE22E409F96E93D7E117393172A:BEFD219B112FA00098919CD101C9CCFA CAMELLIA-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::AE2D8A571E03AC9C9EB76FAC45AF8E51:C91D3A8F1AEA08A9386CF4B66C0169EA CAMELLIA-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::30C81C46A35CE411E5FBC1191A0A52EF:A623D711DC5F25A51BB8A80D56397D28 CAMELLIA-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::F69F2445DF4F9B17AD2B417BE66C3710:7960109FB6DC42947FCFE59EA3C5EB6B # For all CBC encrypts and decrypts, the transformed sequence is # CAMELLIA-bits-CBC:key:IV/ciphertext':plaintext:ciphertext:encdec # CBC-CAMELLIA128.Encrypt and CBC-CAMELLIA128.Decrypt CAMELLIA-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:1607CF494B36BBF00DAEB0B503C831AB CAMELLIA-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:1607CF494B36BBF00DAEB0B503C831AB:AE2D8A571E03AC9C9EB76FAC45AF8E51:A2F2CF671629EF7840C5A5DFB5074887 CAMELLIA-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:A2F2CF671629EF7840C5A5DFB5074887:30C81C46A35CE411E5FBC1191A0A52EF:0F06165008CF8B8B5A63586362543E54 CAMELLIA-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:36A84CDAFD5F9A85ADA0F0A993D6D577:F69F2445DF4F9B17AD2B417BE66C3710:74C64268CDB8B8FAF5B34E8AF3732980 # CBC-CAMELLIA192.Encrypt and CBC-CAMELLIA192.Decrypt CAMELLIA-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:2A4830AB5AC4A1A2405955FD2195CF93 CAMELLIA-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:2A4830AB5AC4A1A2405955FD2195CF93:AE2D8A571E03AC9C9EB76FAC45AF8E51:5D5A869BD14CE54264F892A6DD2EC3D5 CAMELLIA-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:5D5A869BD14CE54264F892A6DD2EC3D5:30C81C46A35CE411E5FBC1191A0A52EF:37D359C3349836D884E310ADDF68C449 CAMELLIA-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:37D359C3349836D884E310ADDF68C449:F69F2445DF4F9B17AD2B417BE66C3710:01FAAA930B4AB9916E9668E1428C6B08 # CBC-CAMELLIA256.Encrypt and CBC-CAMELLIA256.Decrypt CAMELLIA-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:E6CFA35FC02B134A4D2C0B6737AC3EDA CAMELLIA-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E6CFA35FC02B134A4D2C0B6737AC3EDA:AE2D8A571E03AC9C9EB76FAC45AF8E51:36CBEB73BD504B4070B1B7DE2B21EB50 CAMELLIA-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:36CBEB73BD504B4070B1B7DE2B21EB50:30C81C46A35CE411E5FBC1191A0A52EF:E31A6055297D96CA3330CDF1B1860A83 CAMELLIA-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E31A6055297D96CA3330CDF1B1860A83:F69F2445DF4F9B17AD2B417BE66C3710:5D563F6D1CCCF236051C0C5C1C58F28F # We don't support CFB{1,8}-CAMELLIAxxx.{En,De}crypt # For all CFB128 encrypts and decrypts, the transformed sequence is # CAMELLIA-bits-CFB:key:IV/ciphertext':plaintext:ciphertext:encdec # CFB128-CAMELLIA128.Encrypt CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:14F7646187817EB586599146B82BD719:1 CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:14F7646187817EB586599146B82BD719:AE2D8A571E03AC9C9EB76FAC45AF8E51:A53D28BB82DF741103EA4F921A44880B:1 CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:A53D28BB82DF741103EA4F921A44880B:30C81C46A35CE411E5FBC1191A0A52EF:9C2157A664626D1DEF9EA420FDE69B96:1 CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:9C2157A664626D1DEF9EA420FDE69B96:F69F2445DF4F9B17AD2B417BE66C3710:742A25F0542340C7BAEF24CA8482BB09:1 # CFB128-CAMELLIA128.Decrypt CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:14F7646187817EB586599146B82BD719:0 CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:14F7646187817EB586599146B82BD719:AE2D8A571E03AC9C9EB76FAC45AF8E51:A53D28BB82DF741103EA4F921A44880B:0 CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:A53D28BB82DF741103EA4F921A44880B:30C81C46A35CE411E5FBC1191A0A52EF:9C2157A664626D1DEF9EA420FDE69B96:0 CAMELLIA-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:9C2157A664626D1DEF9EA420FDE69B96:F69F2445DF4F9B17AD2B417BE66C3710:742A25F0542340C7BAEF24CA8482BB09:0 # CFB128-CAMELLIA192.Encrypt CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:C832BB9780677DAA82D9B6860DCD565E:1 CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:C832BB9780677DAA82D9B6860DCD565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:86F8491627906D780C7A6D46EA331F98:1 CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:86F8491627906D780C7A6D46EA331F98:30C81C46A35CE411E5FBC1191A0A52EF:69511CCE594CF710CB98BB63D7221F01:1 CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:69511CCE594CF710CB98BB63D7221F01:F69F2445DF4F9B17AD2B417BE66C3710:D5B5378A3ABED55803F25565D8907B84:1 # CFB128-CAMELLIA192.Decrypt CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:C832BB9780677DAA82D9B6860DCD565E:0 CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:C832BB9780677DAA82D9B6860DCD565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:86F8491627906D780C7A6D46EA331F98:0 CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:86F8491627906D780C7A6D46EA331F98:30C81C46A35CE411E5FBC1191A0A52EF:69511CCE594CF710CB98BB63D7221F01:0 CAMELLIA-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:69511CCE594CF710CB98BB63D7221F01:F69F2445DF4F9B17AD2B417BE66C3710:D5B5378A3ABED55803F25565D8907B84:0 # CFB128-CAMELLIA256.Encrypt CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CF6107BB0CEA7D7FB1BD31F5E7B06C93:1 CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:CF6107BB0CEA7D7FB1BD31F5E7B06C93:AE2D8A571E03AC9C9EB76FAC45AF8E51:89BEDB4CCDD864EA11BA4CBE849B5E2B:1 CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:89BEDB4CCDD864EA11BA4CBE849B5E2B:30C81C46A35CE411E5FBC1191A0A52EF:555FC3F34BDD2D54C62D9E3BF338C1C4:1 CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:555FC3F34BDD2D54C62D9E3BF338C1C4:F69F2445DF4F9B17AD2B417BE66C3710:5953ADCE14DB8C7F39F1BD39F359BFFA:1 # CFB128-CAMELLIA256.Decrypt CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CF6107BB0CEA7D7FB1BD31F5E7B06C93:0 CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:CF6107BB0CEA7D7FB1BD31F5E7B06C93:AE2D8A571E03AC9C9EB76FAC45AF8E51:89BEDB4CCDD864EA11BA4CBE849B5E2B:0 CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:89BEDB4CCDD864EA11BA4CBE849B5E2B:30C81C46A35CE411E5FBC1191A0A52EF:555FC3F34BDD2D54C62D9E3BF338C1C4:0 CAMELLIA-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:555FC3F34BDD2D54C62D9E3BF338C1C4:F69F2445DF4F9B17AD2B417BE66C3710:5953ADCE14DB8C7F39F1BD39F359BFFA:0 # For all OFB encrypts and decrypts, the transformed sequence is # CAMELLIA-bits-OFB:key:IV/output':plaintext:ciphertext:encdec # OFB-CAMELLIA128.Encrypt CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:14F7646187817EB586599146B82BD719:1 CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:50FE67CC996D32B6DA0937E99BAFEC60:AE2D8A571E03AC9C9EB76FAC45AF8E51:25623DB569CA51E01482649977E28D84:1 CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:D9A4DADA0892239F6B8B3D7680E15674:30C81C46A35CE411E5FBC1191A0A52EF:C776634A60729DC657D12B9FCA801E98:1 CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:A78819583F0308E7A6BF36B1386ABF23:F69F2445DF4F9B17AD2B417BE66C3710:D776379BE0E50825E681DA1A4C980E8E:1 # OFB-CAMELLIA128.Decrypt CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:14F7646187817EB586599146B82BD719:0 CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:50FE67CC996D32B6DA0937E99BAFEC60:AE2D8A571E03AC9C9EB76FAC45AF8E51:25623DB569CA51E01482649977E28D84:0 CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:D9A4DADA0892239F6B8B3D7680E15674:30C81C46A35CE411E5FBC1191A0A52EF:C776634A60729DC657D12B9FCA801E98:0 CAMELLIA-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:A78819583F0308E7A6BF36B1386ABF23:F69F2445DF4F9B17AD2B417BE66C3710:D776379BE0E50825E681DA1A4C980E8E:0 # OFB-CAMELLIA192.Encrypt CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:C832BB9780677DAA82D9B6860DCD565E:1 CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:A609B38DF3B1133DDDFF2718BA09565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:8ECEB7D0350D72C7F78562AEBDF99339:1 CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:52EF01DA52602FE0975F78AC84BF8A50:30C81C46A35CE411E5FBC1191A0A52EF:BDD62DBBB9700846C53B507F544696F0:1 CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:BD5286AC63AABD7EB067AC54B553F71D:F69F2445DF4F9B17AD2B417BE66C3710:E28014E046B802F385C4C2E13EAD4A72:1 # OFB-CAMELLIA192.Decrypt CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:C832BB9780677DAA82D9B6860DCD565E:0 CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:A609B38DF3B1133DDDFF2718BA09565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:8ECEB7D0350D72C7F78562AEBDF99339:0 CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:52EF01DA52602FE0975F78AC84BF8A50:30C81C46A35CE411E5FBC1191A0A52EF:BDD62DBBB9700846C53B507F544696F0:0 CAMELLIA-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:BD5286AC63AABD7EB067AC54B553F71D:F69F2445DF4F9B17AD2B417BE66C3710:E28014E046B802F385C4C2E13EAD4A72:0 # OFB-CAMELLIA256.Encrypt CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CF6107BB0CEA7D7FB1BD31F5E7B06C93:1 CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7BF3A5DF43989DD97F0FA97EBCE2F4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:127AD97E8E3994E4820027D7BA109368:1 CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:6BFF6265A6A6B7A535BC65A80B17214E:1 CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0A4A0404E26AA78A27CB271E8BF3CF20:1 # OFB-CAMELLIA256.Decrypt CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CF6107BB0CEA7D7FB1BD31F5E7B06C93:0 CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7BF3A5DF43989DD97F0FA97EBCE2F4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:127AD97E8E3994E4820027D7BA109368:0 CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:6BFF6265A6A6B7A535BC65A80B17214E:0 CAMELLIA-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0A4A0404E26AA78A27CB271E8BF3CF20:0 # SEED test vectors from RFC4269 SEED-ECB:00000000000000000000000000000000::000102030405060708090A0B0C0D0E0F:5EBAC6E0054E166819AFF1CC6D346CDB:0 SEED-ECB:000102030405060708090A0B0C0D0E0F::00000000000000000000000000000000:C11F22F20140505084483597E4370F43:0 SEED-ECB:4706480851E61BE85D74BFB3FD956185::83A2F8A288641FB9A4E9A5CC2F131C7D:EE54D13EBCAE706D226BC3142CD40D4A:0 SEED-ECB:28DBC3BC49FFD87DCFA509B11D422BE7::B41E6BE2EBA84A148E2EED84593C5EC7:9B9B7BFCD1813CB95D0B3618F40F5122:0 SEED-ECB:00000000000000000000000000000000::000102030405060708090A0B0C0D0E0F:5EBAC6E0054E166819AFF1CC6D346CDB:1 SEED-ECB:000102030405060708090A0B0C0D0E0F::00000000000000000000000000000000:C11F22F20140505084483597E4370F43:1 SEED-ECB:4706480851E61BE85D74BFB3FD956185::83A2F8A288641FB9A4E9A5CC2F131C7D:EE54D13EBCAE706D226BC3142CD40D4A:1 SEED-ECB:28DBC3BC49FFD87DCFA509B11D422BE7::B41E6BE2EBA84A148E2EED84593C5EC7:9B9B7BFCD1813CB95D0B3618F40F5122:1 # ChaCha test vectors ChaCha:0000000000000000000000000000000000000000000000000000000000000000:0000000000000000:00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000:76b8e0ada0f13d90405d6ae55386bd28bdd219b8a08ded1aa836efcc8b770dc7da41597c5157488d7724e03fb8d84a376a43b8f41518a11cc387b669b2ee6586:1 ChaCha:0100000000000000000000000000000000000000000000000000000000000000:0000000000000000:00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000:c5d30a7ce1ec119378c84f487d775a8542f13ece238a9455e8229e888de85bbd29eb63d0a17a5b999b52da22be4023eb07620a54f6fa6ad8737b71eb0464dac0:1 ChaCha:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff:ffffffffffffffff:00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000:d9bf3f6bce6ed0b54254557767fb57443dd4778911b606055c39cc25e674b8363feabc57fde54f790c52c8ae43240b79d49042b777bfd6cb80e931270b7f50eb:1 ChaCha:5555555555555555555555555555555555555555555555555555555555555555:aaaaaaaaaaaaaaaa:00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000:aff7418293f3a553894b1e7484bd1e8ede196eced5a1d6814de37091e07e076e34bbba8107a686c982850f0a7353940d40db1ab0b5765b78b4cf473d9485a3dd:1 ChaCha:5555555555555555555555555555555555555555555555555555555555555555:5555555555555555:00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000:bea9411aa453c5434a5ae8c92862f564396855a9ea6e22d6d3b50ae1b3663311a4a3606c671d605ce16c3aece8e61ea145c59775017bee2fa6f88afc758069f7:1 ChaCha:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:aaaaaaaaaaaaaaaa:00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000:9aa2a9f656efde5aa7591c5fed4b35aea2895dec7cb4543b9e9f21f5e7bcbcf3c43c748a970888f8248393a09d43e0b7e164bc4d0b0fb240a2d72115c4808906:1 ChaCha:00112233445566778899aabbccddeeffffeeddccbbaa99887766554433221100:0f1e2d3c4b5a6978:00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000:9fadf409c00811d00431d67efbd88fba59218d5d6708b1d685863fabbb0e961eea480fd6fb532bfd494b2151015057423ab60a63fe4f55f7a212e2167ccab931:1 ChaCha:c46ec1b18ce8a878725a37e780dfb7351f68ed2e194c79fbc6aebee1a667975d:1ada31d5cf688221:00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000:f63a89b75c2271f9368816542ba52f06ed49241792302b00b5e8f80ae9a473afc25b218f519af0fdd406362e8d69de7f54c604a6e00f353f110f771bdca8ab92:1 deps/libressl-pnacl-sys-2.1.6/libressl/tests/chachatest.c0000644000175000017500000002320312360020706020351 0ustar /* * Copyright (c) 2014 Joel Sing * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include struct chacha_tv { const char *desc; const unsigned char key[32]; const unsigned char iv[8]; const size_t len; const unsigned char out[512]; }; /* * Test vectors from: * http://tools.ietf.org/html/draft-strombergson-chacha-test-vectors-01 */ struct chacha_tv chacha_test_vectors[] = { { "TC1: All zero key and IV", { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 64, { 0x76, 0xb8, 0xe0, 0xad, 0xa0, 0xf1, 0x3d, 0x90, 0x40, 0x5d, 0x6a, 0xe5, 0x53, 0x86, 0xbd, 0x28, 0xbd, 0xd2, 0x19, 0xb8, 0xa0, 0x8d, 0xed, 0x1a, 0xa8, 0x36, 0xef, 0xcc, 0x8b, 0x77, 0x0d, 0xc7, 0xda, 0x41, 0x59, 0x7c, 0x51, 0x57, 0x48, 0x8d, 0x77, 0x24, 0xe0, 0x3f, 0xb8, 0xd8, 0x4a, 0x37, 0x6a, 0x43, 0xb8, 0xf4, 0x15, 0x18, 0xa1, 0x1c, 0xc3, 0x87, 0xb6, 0x69, 0xb2, 0xee, 0x65, 0x86, }, }, { "TC2: Single bit in key set, all zero IV", { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 64, { 0xc5, 0xd3, 0x0a, 0x7c, 0xe1, 0xec, 0x11, 0x93, 0x78, 0xc8, 0x4f, 0x48, 0x7d, 0x77, 0x5a, 0x85, 0x42, 0xf1, 0x3e, 0xce, 0x23, 0x8a, 0x94, 0x55, 0xe8, 0x22, 0x9e, 0x88, 0x8d, 0xe8, 0x5b, 0xbd, 0x29, 0xeb, 0x63, 0xd0, 0xa1, 0x7a, 0x5b, 0x99, 0x9b, 0x52, 0xda, 0x22, 0xbe, 0x40, 0x23, 0xeb, 0x07, 0x62, 0x0a, 0x54, 0xf6, 0xfa, 0x6a, 0xd8, 0x73, 0x7b, 0x71, 0xeb, 0x04, 0x64, 0xda, 0xc0, }, }, { "TC3: Single bit in IV set, all zero key", { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }, { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }, 64, { 0xd9, 0xbf, 0x3f, 0x6b, 0xce, 0x6e, 0xd0, 0xb5, 0x42, 0x54, 0x55, 0x77, 0x67, 0xfb, 0x57, 0x44, 0x3d, 0xd4, 0x77, 0x89, 0x11, 0xb6, 0x06, 0x05, 0x5c, 0x39, 0xcc, 0x25, 0xe6, 0x74, 0xb8, 0x36, 0x3f, 0xea, 0xbc, 0x57, 0xfd, 0xe5, 0x4f, 0x79, 0x0c, 0x52, 0xc8, 0xae, 0x43, 0x24, 0x0b, 0x79, 0xd4, 0x90, 0x42, 0xb7, 0x77, 0xbf, 0xd6, 0xcb, 0x80, 0xe9, 0x31, 0x27, 0x0b, 0x7f, 0x50, 0xeb, }, }, { "TC4: All bits in key and IV are set", { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, }, { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, 64, { 0xaf, 0xf7, 0x41, 0x82, 0x93, 0xf3, 0xa5, 0x53, 0x89, 0x4b, 0x1e, 0x74, 0x84, 0xbd, 0x1e, 0x8e, 0xde, 0x19, 0x6e, 0xce, 0xd5, 0xa1, 0xd6, 0x81, 0x4d, 0xe3, 0x70, 0x91, 0xe0, 0x7e, 0x07, 0x6e, 0x34, 0xbb, 0xba, 0x81, 0x07, 0xa6, 0x86, 0xc9, 0x82, 0x85, 0x0f, 0x0a, 0x73, 0x53, 0x94, 0x0d, 0x40, 0xdb, 0x1a, 0xb0, 0xb5, 0x76, 0x5b, 0x78, 0xb4, 0xcf, 0x47, 0x3d, 0x94, 0x85, 0xa3, 0xdd, }, }, { "TC5: Every even bit set in key and IV", { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, }, { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, }, 64, { 0xbe, 0xa9, 0x41, 0x1a, 0xa4, 0x53, 0xc5, 0x43, 0x4a, 0x5a, 0xe8, 0xc9, 0x28, 0x62, 0xf5, 0x64, 0x39, 0x68, 0x55, 0xa9, 0xea, 0x6e, 0x22, 0xd6, 0xd3, 0xb5, 0x0a, 0xe1, 0xb3, 0x66, 0x33, 0x11, 0xa4, 0xa3, 0x60, 0x6c, 0x67, 0x1d, 0x60, 0x5c, 0xe1, 0x6c, 0x3a, 0xec, 0xe8, 0xe6, 0x1e, 0xa1, 0x45, 0xc5, 0x97, 0x75, 0x01, 0x7b, 0xee, 0x2f, 0xa6, 0xf8, 0x8a, 0xfc, 0x75, 0x80, 0x69, 0xf7, }, }, { "TC6: Every odd bit set in key and IV", { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, 64, { 0x9a, 0xa2, 0xa9, 0xf6, 0x56, 0xef, 0xde, 0x5a, 0xa7, 0x59, 0x1c, 0x5f, 0xed, 0x4b, 0x35, 0xae, 0xa2, 0x89, 0x5d, 0xec, 0x7c, 0xb4, 0x54, 0x3b, 0x9e, 0x9f, 0x21, 0xf5, 0xe7, 0xbc, 0xbc, 0xf3, 0xc4, 0x3c, 0x74, 0x8a, 0x97, 0x08, 0x88, 0xf8, 0x24, 0x83, 0x93, 0xa0, 0x9d, 0x43, 0xe0, 0xb7, 0xe1, 0x64, 0xbc, 0x4d, 0x0b, 0x0f, 0xb2, 0x40, 0xa2, 0xd7, 0x21, 0x15, 0xc4, 0x80, 0x89, 0x06, }, }, { "TC7: Sequence patterns in key and IV", { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00, }, { 0x0f, 0x1e, 0x2d, 0x3c, 0x4b, 0x5a, 0x69, 0x78, }, 64, { 0x9f, 0xad, 0xf4, 0x09, 0xc0, 0x08, 0x11, 0xd0, 0x04, 0x31, 0xd6, 0x7e, 0xfb, 0xd8, 0x8f, 0xba, 0x59, 0x21, 0x8d, 0x5d, 0x67, 0x08, 0xb1, 0xd6, 0x85, 0x86, 0x3f, 0xab, 0xbb, 0x0e, 0x96, 0x1e, 0xea, 0x48, 0x0f, 0xd6, 0xfb, 0x53, 0x2b, 0xfd, 0x49, 0x4b, 0x21, 0x51, 0x01, 0x50, 0x57, 0x42, 0x3a, 0xb6, 0x0a, 0x63, 0xfe, 0x4f, 0x55, 0xf7, 0xa2, 0x12, 0xe2, 0x16, 0x7c, 0xca, 0xb9, 0x31, }, }, { "TC8: key: 'All your base are belong to us!, IV: 'IETF2013'", { 0xc4, 0x6e, 0xc1, 0xb1, 0x8c, 0xe8, 0xa8, 0x78, 0x72, 0x5a, 0x37, 0xe7, 0x80, 0xdf, 0xb7, 0x35, 0x1f, 0x68, 0xed, 0x2e, 0x19, 0x4c, 0x79, 0xfb, 0xc6, 0xae, 0xbe, 0xe1, 0xa6, 0x67, 0x97, 0x5d, }, { 0x1a, 0xda, 0x31, 0xd5, 0xcf, 0x68, 0x82, 0x21, }, 64, { 0xf6, 0x3a, 0x89, 0xb7, 0x5c, 0x22, 0x71, 0xf9, 0x36, 0x88, 0x16, 0x54, 0x2b, 0xa5, 0x2f, 0x06, 0xed, 0x49, 0x24, 0x17, 0x92, 0x30, 0x2b, 0x00, 0xb5, 0xe8, 0xf8, 0x0a, 0xe9, 0xa4, 0x73, 0xaf, 0xc2, 0x5b, 0x21, 0x8f, 0x51, 0x9a, 0xf0, 0xfd, 0xd4, 0x06, 0x36, 0x2e, 0x8d, 0x69, 0xde, 0x7f, 0x54, 0xc6, 0x04, 0xa6, 0xe0, 0x0f, 0x35, 0x3f, 0x11, 0x0f, 0x77, 0x1b, 0xdc, 0xa8, 0xab, 0x92, }, }, }; #define N_VECTORS (sizeof(chacha_test_vectors) / sizeof(*chacha_test_vectors)) /* Single-shot ChaCha20 using CRYPTO_chacha_20 interface. */ static void crypto_chacha_20_test(struct chacha_tv *tv, unsigned char *out, unsigned char *in) { CRYPTO_chacha_20(out, in, tv->len, tv->key, tv->iv, 0); } /* Single-shot ChaCha20 using the ChaCha interface. */ static void chacha_ctx_full_test(struct chacha_tv *tv, unsigned char *out, unsigned char *in) { ChaCha_ctx ctx; ChaCha_set_key(&ctx, tv->key, 256); ChaCha_set_iv(&ctx, tv->iv, NULL); ChaCha(&ctx, out, in, tv->len); } /* ChaCha20 with partial writes using the Chacha interface. */ static void chacha_ctx_partial_test(struct chacha_tv *tv, unsigned char *out, unsigned char *in) { ChaCha_ctx ctx; int len, size = 0; ChaCha_set_key(&ctx, tv->key, 256); ChaCha_set_iv(&ctx, tv->iv, NULL); len = tv->len - 1; while (len > 1) { size = len / 2; ChaCha(&ctx, out, in, size); in += size; out += size; len -= size; } ChaCha(&ctx, out, in, len + 1); } /* ChaCha20 with single byte writes using the Chacha interface. */ static void chacha_ctx_single_test(struct chacha_tv *tv, unsigned char *out, unsigned char *in) { ChaCha_ctx ctx; size_t i; ChaCha_set_key(&ctx, tv->key, 256); ChaCha_set_iv(&ctx, tv->iv, NULL); for (i = 0; i < tv->len; i++) ChaCha(&ctx, out + i, in + i, 1); } struct chacha_test_function { char *name; void (*func)(struct chacha_tv *, unsigned char *, unsigned char *); }; struct chacha_test_function chacha_test_functions[] = { {"crypto_chacha_20_test", crypto_chacha_20_test}, {"chacha_ctx_full_test", chacha_ctx_full_test}, {"chacha_ctx_partial_test", chacha_ctx_partial_test}, {"chacha_ctx_single_test", chacha_ctx_single_test}, }; #define N_FUNCS (sizeof(chacha_test_functions) / sizeof(*chacha_test_functions)) int main(int argc, char **argv) { struct chacha_tv *tv; unsigned char *in, *out; size_t i, j, k; int failed = 0; for (i = 0; i < N_VECTORS; i++) { tv = &chacha_test_vectors[i]; for (j = 0; j < N_FUNCS; j++) { in = calloc(1, tv->len); if (in == NULL) errx(1, "calloc in"); out = calloc(1, tv->len); if (out == NULL) errx(1, "calloc out"); chacha_test_functions[j].func(tv, out, in); if (memcmp(out, tv->out, tv->len) != 0) { printf("ChaCha %s failed for \"%s\"!\n", chacha_test_functions[j].name, tv->desc); printf("Got:\t"); for (k = 0; k < tv->len; k++) printf("%2.2x", out[k]); printf("\n"); printf("Want:\t"); for (k = 0; k < tv->len; k++) printf("%2.2x", tv->out[k]); printf("\n"); failed = 1; } free(in); free(out); } } return failed; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/aes_wrap.c0000644000175000017500000001411712360020706020047 0ustar /* crypto/aes/aes_wrap.c */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ /* ==================================================================== * Copyright (c) 2008 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== */ #include #include #include #include int AES_wrap_unwrap_test(const unsigned char *, int, const unsigned char *, const unsigned char *, const unsigned char *, int); int AES_wrap_unwrap_test(const unsigned char *kek, int keybits, const unsigned char *iv, const unsigned char *eout, const unsigned char *key, int keylen) { unsigned char *otmp = NULL, *ptmp = NULL; int r, ret = 0; AES_KEY wctx; otmp = malloc(keylen + 8); ptmp = malloc(keylen); if (!otmp || !ptmp) return 0; if (AES_set_encrypt_key(kek, keybits, &wctx)) goto err; r = AES_wrap_key(&wctx, iv, otmp, key, keylen); if (r <= 0) goto err; if (eout && memcmp(eout, otmp, keylen)) goto err; if (AES_set_decrypt_key(kek, keybits, &wctx)) goto err; r = AES_unwrap_key(&wctx, iv, ptmp, otmp, r); if (memcmp(key, ptmp, keylen)) goto err; ret = 1; err: free(otmp); free(ptmp); return ret; } int main(int argc, char **argv) { static const unsigned char kek[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }; static const unsigned char key[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; static const unsigned char e1[] = { 0x1f, 0xa6, 0x8b, 0x0a, 0x81, 0x12, 0xb4, 0x47, 0xae, 0xf3, 0x4b, 0xd8, 0xfb, 0x5a, 0x7b, 0x82, 0x9d, 0x3e, 0x86, 0x23, 0x71, 0xd2, 0xcf, 0xe5 }; static const unsigned char e2[] = { 0x96, 0x77, 0x8b, 0x25, 0xae, 0x6c, 0xa4, 0x35, 0xf9, 0x2b, 0x5b, 0x97, 0xc0, 0x50, 0xae, 0xd2, 0x46, 0x8a, 0xb8, 0xa1, 0x7a, 0xd8, 0x4e, 0x5d }; static const unsigned char e3[] = { 0x64, 0xe8, 0xc3, 0xf9, 0xce, 0x0f, 0x5b, 0xa2, 0x63, 0xe9, 0x77, 0x79, 0x05, 0x81, 0x8a, 0x2a, 0x93, 0xc8, 0x19, 0x1e, 0x7d, 0x6e, 0x8a, 0xe7 }; static const unsigned char e4[] = { 0x03, 0x1d, 0x33, 0x26, 0x4e, 0x15, 0xd3, 0x32, 0x68, 0xf2, 0x4e, 0xc2, 0x60, 0x74, 0x3e, 0xdc, 0xe1, 0xc6, 0xc7, 0xdd, 0xee, 0x72, 0x5a, 0x93, 0x6b, 0xa8, 0x14, 0x91, 0x5c, 0x67, 0x62, 0xd2 }; static const unsigned char e5[] = { 0xa8, 0xf9, 0xbc, 0x16, 0x12, 0xc6, 0x8b, 0x3f, 0xf6, 0xe6, 0xf4, 0xfb, 0xe3, 0x0e, 0x71, 0xe4, 0x76, 0x9c, 0x8b, 0x80, 0xa3, 0x2c, 0xb8, 0x95, 0x8c, 0xd5, 0xd1, 0x7d, 0x6b, 0x25, 0x4d, 0xa1 }; static const unsigned char e6[] = { 0x28, 0xc9, 0xf4, 0x04, 0xc4, 0xb8, 0x10, 0xf4, 0xcb, 0xcc, 0xb3, 0x5c, 0xfb, 0x87, 0xf8, 0x26, 0x3f, 0x57, 0x86, 0xe2, 0xd8, 0x0e, 0xd3, 0x26, 0xcb, 0xc7, 0xf0, 0xe7, 0x1a, 0x99, 0xf4, 0x3b, 0xfb, 0x98, 0x8b, 0x9b, 0x7a, 0x02, 0xdd, 0x21 }; int ret, nfailures = 0; ret = AES_wrap_unwrap_test(kek, 128, NULL, e1, key, 16); if (ret == 0) nfailures++; fprintf(stderr, "Key test result %d\n", ret); ret = AES_wrap_unwrap_test(kek, 192, NULL, e2, key, 16); if (ret == 0) nfailures++; fprintf(stderr, "Key test result %d\n", ret); ret = AES_wrap_unwrap_test(kek, 256, NULL, e3, key, 16); if (ret == 0) nfailures++; fprintf(stderr, "Key test result %d\n", ret); ret = AES_wrap_unwrap_test(kek, 192, NULL, e4, key, 24); if (ret == 0) nfailures++; fprintf(stderr, "Key test result %d\n", ret); ret = AES_wrap_unwrap_test(kek, 256, NULL, e5, key, 24); if (ret == 0) nfailures++; fprintf(stderr, "Key test result %d\n", ret); ret = AES_wrap_unwrap_test(kek, 256, NULL, e6, key, 32); if (ret == 0) nfailures++; fprintf(stderr, "Key test result %d\n", ret); return nfailures; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/ecdhtest.c0000644000175000017500000003277212360020706020060 0ustar /* crypto/ecdh/ecdhtest.c */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * The Elliptic Curve Public-Key Crypto Library (ECC Code) included * herein is developed by SUN MICROSYSTEMS, INC., and is contributed * to the OpenSSL project. * * The ECC Code is licensed pursuant to the OpenSSL open source * license provided below. * * The ECDH software is originally written by Douglas Stebila of * Sun Microsystems Laboratories. * */ /* ==================================================================== * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include #include #include #include #include static const int KDF1_SHA1_len = 20; static void *KDF1_SHA1(const void *in, size_t inlen, void *out, size_t *outlen) { #ifndef OPENSSL_NO_SHA if (*outlen < SHA_DIGEST_LENGTH) return NULL; else *outlen = SHA_DIGEST_LENGTH; return SHA1(in, inlen, out); #else return NULL; #endif } static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out) { EC_KEY *a=NULL; EC_KEY *b=NULL; BIGNUM *x_a=NULL, *y_a=NULL, *x_b=NULL, *y_b=NULL; char buf[12]; unsigned char *abuf=NULL,*bbuf=NULL; int i,alen,blen,aout,bout,ret=0; const EC_GROUP *group; a = EC_KEY_new_by_curve_name(nid); b = EC_KEY_new_by_curve_name(nid); if (a == NULL || b == NULL) goto err; group = EC_KEY_get0_group(a); if ((x_a=BN_new()) == NULL) goto err; if ((y_a=BN_new()) == NULL) goto err; if ((x_b=BN_new()) == NULL) goto err; if ((y_b=BN_new()) == NULL) goto err; BIO_puts(out,"Testing key generation with "); BIO_puts(out,text); (void)BIO_flush(out); if (!EC_KEY_generate_key(a)) goto err; if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field) { if (!EC_POINT_get_affine_coordinates_GFp(group, EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err; } #ifndef OPENSSL_NO_EC2M else { if (!EC_POINT_get_affine_coordinates_GF2m(group, EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err; } #endif BIO_printf(out," ."); (void)BIO_flush(out); if (!EC_KEY_generate_key(b)) goto err; if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field) { if (!EC_POINT_get_affine_coordinates_GFp(group, EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err; } #ifndef OPENSSL_NO_EC2M else { if (!EC_POINT_get_affine_coordinates_GF2m(group, EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err; } #endif BIO_printf(out,"."); (void)BIO_flush(out); alen=KDF1_SHA1_len; abuf=malloc(alen); aout=ECDH_compute_key(abuf,alen,EC_KEY_get0_public_key(b),a,KDF1_SHA1); BIO_printf(out,"."); (void)BIO_flush(out); blen=KDF1_SHA1_len; bbuf=malloc(blen); bout=ECDH_compute_key(bbuf,blen,EC_KEY_get0_public_key(a),b,KDF1_SHA1); BIO_printf(out,"."); (void)BIO_flush(out); if ((aout < 4) || (bout != aout) || (memcmp(abuf,bbuf,aout) != 0)) { BIO_printf(out, " failed\n\n"); BIO_printf(out, "key a:\n"); BIO_printf(out, "private key: "); BN_print(out, EC_KEY_get0_private_key(a)); BIO_printf(out, "\n"); BIO_printf(out, "public key (x,y): "); BN_print(out, x_a); BIO_printf(out, ","); BN_print(out, y_a); BIO_printf(out, "\nkey b:\n"); BIO_printf(out, "private key: "); BN_print(out, EC_KEY_get0_private_key(b)); BIO_printf(out, "\n"); BIO_printf(out, "public key (x,y): "); BN_print(out, x_b); BIO_printf(out, ","); BN_print(out, y_b); BIO_printf(out, "\n"); BIO_printf(out, "generated key a: "); for (i=0; i #include #include #include static unsigned char RC2key[4][16]={ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F}, }; static unsigned char RC2plain[4][8]={ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, }; static unsigned char RC2cipher[4][8]={ {0x1C,0x19,0x8A,0x83,0x8D,0xF0,0x28,0xB7}, {0x21,0x82,0x9C,0x78,0xA9,0xF9,0xC0,0x74}, {0x13,0xDB,0x35,0x17,0xD3,0x21,0x86,0x9E}, {0x50,0xDC,0x01,0x62,0xBD,0x75,0x7F,0x31}, }; /************/ int main(int argc, char *argv[]) { int i,n,err=0; RC2_KEY key; unsigned char buf[8],buf2[8]; for (n=0; n<4; n++) { RC2_set_key(&key,16,&(RC2key[n][0]),0 /* or 1024 */); RC2_ecb_encrypt(&(RC2plain[n][0]),buf,&key,RC2_ENCRYPT); if (memcmp(&(RC2cipher[n][0]),buf,8) != 0) { printf("ecb rc2 error encrypting\n"); printf("got :"); for (i=0; i<8; i++) printf("%02X ",buf[i]); printf("\n"); printf("expected:"); for (i=0; i<8; i++) printf("%02X ",RC2cipher[n][i]); err=20; printf("\n"); } RC2_ecb_encrypt(buf,buf2,&key,RC2_DECRYPT); if (memcmp(&(RC2plain[n][0]),buf2,8) != 0) { printf("ecb RC2 error decrypting\n"); printf("got :"); for (i=0; i<8; i++) printf("%02X ",buf[i]); printf("\n"); printf("expected:"); for (i=0; i<8; i++) printf("%02X ",RC2plain[n][i]); printf("\n"); err=3; } } if (err == 0) printf("ecb RC2 ok\n"); exit(err); } deps/libressl-pnacl-sys-2.1.6/libressl/tests/sha256test.c0000644000175000017500000001045612360020706020160 0ustar /* crypto/sha/sha256t.c */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved. * ==================================================================== */ #include #include #include #include #include #if defined(OPENSSL_NO_SHA) || defined(OPENSSL_NO_SHA256) int main(int argc, char *argv[]) { printf("No SHA256 support\n"); return (0); } #else unsigned char app_b1[SHA256_DIGEST_LENGTH] = { 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad, }; unsigned char app_b2[SHA256_DIGEST_LENGTH] = { 0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8, 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39, 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67, 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1, }; unsigned char app_b3[SHA256_DIGEST_LENGTH] = { 0xcd, 0xc7, 0x6e, 0x5c, 0x99, 0x14, 0xfb, 0x92, 0x81, 0xa1, 0xc7, 0xe2, 0x84, 0xd7, 0x3e, 0x67, 0xf1, 0x80, 0x9a, 0x48, 0xa4, 0x97, 0x20, 0x0e, 0x04, 0x6d, 0x39, 0xcc, 0xc7, 0x11, 0x2c, 0xd0, }; unsigned char addenum_1[SHA224_DIGEST_LENGTH] = { 0x23, 0x09, 0x7d, 0x22, 0x34, 0x05, 0xd8, 0x22, 0x86, 0x42, 0xa4, 0x77, 0xbd, 0xa2, 0x55, 0xb3, 0x2a, 0xad, 0xbc, 0xe4, 0xbd, 0xa0, 0xb3, 0xf7, 0xe3, 0x6c, 0x9d, 0xa7, }; unsigned char addenum_2[SHA224_DIGEST_LENGTH] = { 0x75, 0x38, 0x8b, 0x16, 0x51, 0x27, 0x76, 0xcc, 0x5d, 0xba, 0x5d, 0xa1, 0xfd, 0x89, 0x01, 0x50, 0xb0, 0xc6, 0x45, 0x5c, 0xb4, 0xf5, 0x8b, 0x19, 0x52, 0x52, 0x25, 0x25, }; unsigned char addenum_3[SHA224_DIGEST_LENGTH] = { 0x20, 0x79, 0x46, 0x55, 0x98, 0x0c, 0x91, 0xd8, 0xbb, 0xb4, 0xc1, 0xea, 0x97, 0x61, 0x8a, 0x4b, 0xf0, 0x3f, 0x42, 0x58, 0x19, 0x48, 0xb2, 0xee, 0x4e, 0xe7, 0xad, 0x67, }; int main(int argc, char **argv) { unsigned char md[SHA256_DIGEST_LENGTH]; int i; EVP_MD_CTX evp; fprintf(stdout, "Testing SHA-256 "); EVP_Digest("abc",3,md,NULL,EVP_sha256(),NULL); if (memcmp(md, app_b1, sizeof(app_b1))) { fflush(stdout); fprintf(stderr, "\nTEST 1 of 3 failed.\n"); return 1; } fprintf(stdout, "."); fflush(stdout); EVP_Digest( "abcdbcde""cdefdefg""efghfghi""ghijhijk" "ijkljklm""klmnlmno""mnopnopq", 56, md, NULL, EVP_sha256(), NULL); if (memcmp(md, app_b2, sizeof(app_b2))) { fflush(stdout); fprintf(stderr, "\nTEST 2 of 3 failed.\n"); return 1; } fprintf(stdout, "."); fflush(stdout); EVP_MD_CTX_init(&evp); EVP_DigestInit_ex(&evp, EVP_sha256(), NULL); for (i = 0; i < 1000000; i += 160) EVP_DigestUpdate(&evp, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", (1000000 - i) < 160 ? 1000000 - i : 160); EVP_DigestFinal_ex(&evp, md, NULL); EVP_MD_CTX_cleanup(&evp); if (memcmp(md, app_b3, sizeof(app_b3))) { fflush(stdout); fprintf(stderr, "\nTEST 3 of 3 failed.\n"); return 1; } fprintf(stdout, "."); fflush(stdout); fprintf(stdout, " passed.\n"); fflush(stdout); fprintf(stdout, "Testing SHA-224 "); EVP_Digest ("abc",3,md,NULL,EVP_sha224(),NULL); if (memcmp(md, addenum_1, sizeof(addenum_1))) { fflush(stdout); fprintf(stderr, "\nTEST 1 of 3 failed.\n"); return 1; } fprintf(stdout, "."); fflush(stdout); EVP_Digest( "abcdbcde""cdefdefg""efghfghi""ghijhijk" "ijkljklm""klmnlmno""mnopnopq", 56, md, NULL, EVP_sha224(), NULL); if (memcmp(md, addenum_2, sizeof(addenum_2))) { fflush(stdout); fprintf(stderr, "\nTEST 2 of 3 failed.\n"); return 1; } fprintf(stdout, "."); fflush(stdout); EVP_MD_CTX_init(&evp); EVP_DigestInit_ex (&evp, EVP_sha224(), NULL); for (i = 0; i < 1000000; i += 64) EVP_DigestUpdate(&evp, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa" "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa", (1000000 - i) < 64 ? 1000000 - i : 64); EVP_DigestFinal_ex(&evp, md, NULL); EVP_MD_CTX_cleanup(&evp); if (memcmp(md, addenum_3, sizeof(addenum_3))) { fflush(stdout); fprintf(stderr, "\nTEST 3 of 3 failed.\n"); return 1; } fprintf(stdout, "."); fflush(stdout); fprintf(stdout, " passed.\n"); fflush(stdout); return 0; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/tests/ecdsatest.c0000644000175000017500000002730412360020706020227 0ustar /* crypto/ecdsa/ecdsatest.c */ /* * Written by Nils Larsch for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * Portions of the attached software ("Contribution") are developed by * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. * * The Contribution is licensed pursuant to the OpenSSL open source * license provided above. * * The elliptic curve binary polynomial software is originally written by * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. * */ #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif #include #include /* declaration of the test functions */ int x9_62_test_internal(BIO *out, int nid, const char *r, const char *s); int test_builtin(BIO *); /* some tests from the X9.62 draft */ int x9_62_test_internal(BIO *out, int nid, const char *r_in, const char *s_in) { int ret = 0; const char message[] = "abc"; unsigned char digest[20]; unsigned int dgst_len = 0; EVP_MD_CTX md_ctx; EC_KEY *key = NULL; ECDSA_SIG *signature = NULL; BIGNUM *r = NULL, *s = NULL; EVP_MD_CTX_init(&md_ctx); /* get the message digest */ EVP_DigestInit(&md_ctx, EVP_ecdsa()); EVP_DigestUpdate(&md_ctx, (const void*)message, 3); EVP_DigestFinal(&md_ctx, digest, &dgst_len); BIO_printf(out, "testing %s: ", OBJ_nid2sn(nid)); /* create the key */ if ((key = EC_KEY_new_by_curve_name(nid)) == NULL) goto x962_int_err; if (!EC_KEY_generate_key(key)) goto x962_int_err; BIO_printf(out, "."); (void)BIO_flush(out); /* create the signature */ signature = ECDSA_do_sign(digest, 20, key); if (signature == NULL) goto x962_int_err; BIO_printf(out, "."); (void)BIO_flush(out); /* compare the created signature with the expected signature */ if ((r = BN_new()) == NULL || (s = BN_new()) == NULL) goto x962_int_err; if (!BN_dec2bn(&r, r_in) || !BN_dec2bn(&s, s_in)) goto x962_int_err; if (BN_cmp(signature->r ,r) || BN_cmp(signature->s, s)) goto x962_int_err; BIO_printf(out, "."); (void)BIO_flush(out); /* verify the signature */ if (ECDSA_do_verify(digest, 20, signature, key) != 1) goto x962_int_err; BIO_printf(out, "."); (void)BIO_flush(out); BIO_printf(out, " ok\n"); ret = 1; x962_int_err: if (!ret) BIO_printf(out, " failed\n"); if (key) EC_KEY_free(key); if (signature) ECDSA_SIG_free(signature); if (r) BN_free(r); if (s) BN_free(s); EVP_MD_CTX_cleanup(&md_ctx); return ret; } int test_builtin(BIO *out) { EC_builtin_curve *curves = NULL; size_t crv_len = 0, n = 0; EC_KEY *eckey = NULL, *wrong_eckey = NULL; EC_GROUP *group; ECDSA_SIG *ecdsa_sig = NULL; unsigned char digest[20], wrong_digest[20]; unsigned char *signature = NULL; const unsigned char *sig_ptr; unsigned char *sig_ptr2; unsigned char *raw_buf = NULL; unsigned int sig_len, degree, r_len, s_len, bn_len, buf_len; int nid, ret = 0; /* fill digest values with some random data */ if (!RAND_pseudo_bytes(digest, 20) || !RAND_pseudo_bytes(wrong_digest, 20)) { BIO_printf(out, "ERROR: unable to get random data\n"); goto builtin_err; } /* create and verify a ecdsa signature with every availble curve * (with ) */ BIO_printf(out, "\ntesting ECDSA_sign() and ECDSA_verify() " "with some internal curves:\n"); /* get a list of all internal curves */ crv_len = EC_get_builtin_curves(NULL, 0); curves = reallocarray(NULL, sizeof(EC_builtin_curve), crv_len); if (curves == NULL) { BIO_printf(out, "malloc error\n"); goto builtin_err; } if (!EC_get_builtin_curves(curves, crv_len)) { BIO_printf(out, "unable to get internal curves\n"); goto builtin_err; } /* now create and verify a signature for every curve */ for (n = 0; n < crv_len; n++) { unsigned char dirt, offset; nid = curves[n].nid; if (nid == NID_ipsec4) continue; /* create new ecdsa key (== EC_KEY) */ if ((eckey = EC_KEY_new()) == NULL) goto builtin_err; group = EC_GROUP_new_by_curve_name(nid); if (group == NULL) goto builtin_err; if (EC_KEY_set_group(eckey, group) == 0) goto builtin_err; EC_GROUP_free(group); degree = EC_GROUP_get_degree(EC_KEY_get0_group(eckey)); if (degree < 160) /* drop the curve */ { EC_KEY_free(eckey); eckey = NULL; continue; } BIO_printf(out, "%s: ", OBJ_nid2sn(nid)); /* create key */ if (!EC_KEY_generate_key(eckey)) { BIO_printf(out, " failed\n"); goto builtin_err; } /* create second key */ if ((wrong_eckey = EC_KEY_new()) == NULL) goto builtin_err; group = EC_GROUP_new_by_curve_name(nid); if (group == NULL) goto builtin_err; if (EC_KEY_set_group(wrong_eckey, group) == 0) goto builtin_err; EC_GROUP_free(group); if (!EC_KEY_generate_key(wrong_eckey)) { BIO_printf(out, " failed\n"); goto builtin_err; } BIO_printf(out, "."); (void)BIO_flush(out); /* check key */ if (!EC_KEY_check_key(eckey)) { BIO_printf(out, " failed\n"); goto builtin_err; } BIO_printf(out, "."); (void)BIO_flush(out); /* create signature */ sig_len = ECDSA_size(eckey); if ((signature = malloc(sig_len)) == NULL) goto builtin_err; if (!ECDSA_sign(0, digest, 20, signature, &sig_len, eckey)) { BIO_printf(out, " failed\n"); goto builtin_err; } BIO_printf(out, "."); (void)BIO_flush(out); /* verify signature */ if (ECDSA_verify(0, digest, 20, signature, sig_len, eckey) != 1) { BIO_printf(out, " failed\n"); goto builtin_err; } BIO_printf(out, "."); (void)BIO_flush(out); /* verify signature with the wrong key */ if (ECDSA_verify(0, digest, 20, signature, sig_len, wrong_eckey) == 1) { BIO_printf(out, " failed\n"); goto builtin_err; } BIO_printf(out, "."); (void)BIO_flush(out); /* wrong digest */ if (ECDSA_verify(0, wrong_digest, 20, signature, sig_len, eckey) == 1) { BIO_printf(out, " failed\n"); goto builtin_err; } BIO_printf(out, "."); (void)BIO_flush(out); /* wrong length */ if (ECDSA_verify(0, digest, 20, signature, sig_len - 1, eckey) == 1) { BIO_printf(out, " failed\n"); goto builtin_err; } BIO_printf(out, "."); (void)BIO_flush(out); /* Modify a single byte of the signature: to ensure we don't * garble the ASN1 structure, we read the raw signature and * modify a byte in one of the bignums directly. */ sig_ptr = signature; if ((ecdsa_sig = d2i_ECDSA_SIG(NULL, &sig_ptr, sig_len)) == NULL) { BIO_printf(out, " failed\n"); goto builtin_err; } /* Store the two BIGNUMs in raw_buf. */ r_len = BN_num_bytes(ecdsa_sig->r); s_len = BN_num_bytes(ecdsa_sig->s); bn_len = (degree + 7) / 8; if ((r_len > bn_len) || (s_len > bn_len)) { BIO_printf(out, " failed\n"); goto builtin_err; } buf_len = 2 * bn_len; if ((raw_buf = calloc(1, buf_len)) == NULL) goto builtin_err; BN_bn2bin(ecdsa_sig->r, raw_buf + bn_len - r_len); BN_bn2bin(ecdsa_sig->s, raw_buf + buf_len - s_len); /* Modify a single byte in the buffer. */ offset = raw_buf[10] % buf_len; dirt = raw_buf[11] ? raw_buf[11] : 1; raw_buf[offset] ^= dirt; /* Now read the BIGNUMs back in from raw_buf. */ if ((BN_bin2bn(raw_buf, bn_len, ecdsa_sig->r) == NULL) || (BN_bin2bn(raw_buf + bn_len, bn_len, ecdsa_sig->s) == NULL)) goto builtin_err; sig_ptr2 = signature; sig_len = i2d_ECDSA_SIG(ecdsa_sig, &sig_ptr2); if (ECDSA_verify(0, digest, 20, signature, sig_len, eckey) == 1) { BIO_printf(out, " failed\n"); goto builtin_err; } /* Sanity check: undo the modification and verify signature. */ raw_buf[offset] ^= dirt; if ((BN_bin2bn(raw_buf, bn_len, ecdsa_sig->r) == NULL) || (BN_bin2bn(raw_buf + bn_len, bn_len, ecdsa_sig->s) == NULL)) goto builtin_err; sig_ptr2 = signature; sig_len = i2d_ECDSA_SIG(ecdsa_sig, &sig_ptr2); if (ECDSA_verify(0, digest, 20, signature, sig_len, eckey) != 1) { BIO_printf(out, " failed\n"); goto builtin_err; } BIO_printf(out, "."); (void)BIO_flush(out); BIO_printf(out, " ok\n"); /* cleanup */ /* clean bogus errors */ ERR_clear_error(); free(signature); signature = NULL; EC_KEY_free(eckey); eckey = NULL; EC_KEY_free(wrong_eckey); wrong_eckey = NULL; ECDSA_SIG_free(ecdsa_sig); ecdsa_sig = NULL; free(raw_buf); raw_buf = NULL; } ret = 1; builtin_err: if (eckey) EC_KEY_free(eckey); if (wrong_eckey) EC_KEY_free(wrong_eckey); if (ecdsa_sig) ECDSA_SIG_free(ecdsa_sig); free(signature); free(raw_buf); free(curves); return ret; } int main(void) { int ret = 1; BIO *out; out = BIO_new_fp(stdout, BIO_NOCLOSE); ERR_load_crypto_strings(); /* the tests */ if (!test_builtin(out)) goto err; ret = 0; err: if (ret) BIO_printf(out, "\nECDSA test failed\n"); else BIO_printf(out, "\nECDSA test passed\n"); if (ret) ERR_print_errors(out); CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); ERR_free_strings(); CRYPTO_mem_leaks(out); if (out != NULL) BIO_free(out); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/pq_test.c0000644000175000017500000000775612360020706017740 0ustar /* crypto/pqueue/pq_test.c */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. */ /* ==================================================================== * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include "pqueue.h" /* remember to change expected.txt if you change these values */ unsigned char prio1[8] = "supercal"; unsigned char prio2[8] = "ifragili"; unsigned char prio3[8] = "sticexpi"; static void pqueue_print(pqueue pq) { pitem *iter, *item; iter = pqueue_iterator(pq); for (item = pqueue_next(&iter); item != NULL; item = pqueue_next(&iter)) { printf("item\t%02x%02x%02x%02x%02x%02x%02x%02x\n", item->priority[0], item->priority[1], item->priority[2], item->priority[3], item->priority[4], item->priority[5], item->priority[6], item->priority[7]); } } int main(void) { pitem *item; pqueue pq; pq = pqueue_new(); item = pitem_new(prio3, NULL); pqueue_insert(pq, item); item = pitem_new(prio1, NULL); pqueue_insert(pq, item); item = pitem_new(prio2, NULL); pqueue_insert(pq, item); item = pqueue_find(pq, prio1); fprintf(stderr, "found %p\n", item->priority); item = pqueue_find(pq, prio2); fprintf(stderr, "found %p\n", item->priority); item = pqueue_find(pq, prio3); fprintf(stderr, "found %p\n", item ? item->priority: 0); pqueue_print(pq); for (item = pqueue_pop(pq); item != NULL; item = pqueue_pop(pq)) pitem_free(item); pqueue_free(pq); return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/rmdtest.c0000644000175000017500000001117212360020706017726 0ustar /* crypto/ripemd/rmdtest.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include static char *test[]={ "", "a", "abc", "message digest", "abcdefghijklmnopqrstuvwxyz", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "12345678901234567890123456789012345678901234567890123456789012345678901234567890", NULL, }; static char *ret[]={ "9c1185a5c5e9fc54612808977ee8f548b2258d31", "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe", "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc", "5d0689ef49d2fae572b881b123a85ffa21595f36", "f71c27109c692c1b56bbdceb5b9d2865b3708dbc", "12a053384a9c0c88e405a06c27dcf49ada62eb2b", "b0e20b6e3116640286ed3a87a5713079b21f5189", "9b752e45573d4b39f4dbd3323cab82bf63326bfb", }; static char *pt(unsigned char *md); int main(int argc, char *argv[]) { int i,err=0; char **P,**R; char *p; unsigned char md[RIPEMD160_DIGEST_LENGTH]; P=test; R=ret; i=1; while (*P != NULL) { EVP_Digest(&(P[0][0]),strlen((char *)*P),md,NULL,EVP_ripemd160(), NULL); p=pt(md); if (strcmp(p,(char *)*R) != 0) { printf("error calculating RIPEMD160 on '%s'\n",*P); printf("got %s instead of %s\n",p,*R); err++; } else printf("test %d ok\n",i); i++; R++; P++; } exit(err); return(0); } static char *pt(unsigned char *md) { int i; static char buf[80]; for (i=0; i #include #include #include #include #include #include #include #include static int cb(int p, int n, BN_GENCB *arg); int main(int argc, char *argv[]) { BN_GENCB _cb; DH *a; DH *b=NULL; char buf[12]; unsigned char *abuf=NULL,*bbuf=NULL; int i,alen,blen,aout,bout,ret=1; BIO *out; out=BIO_new(BIO_s_file()); if (out == NULL) exit(1); BIO_set_fp(out,stdout,BIO_NOCLOSE); BN_GENCB_set(&_cb, &cb, out); if(((a = DH_new()) == NULL) || !DH_generate_parameters_ex(a, 64, DH_GENERATOR_5, &_cb)) goto err; if (!DH_check(a, &i)) goto err; if (i & DH_CHECK_P_NOT_PRIME) BIO_puts(out, "p value is not prime\n"); if (i & DH_CHECK_P_NOT_SAFE_PRIME) BIO_puts(out, "p value is not a safe prime\n"); if (i & DH_UNABLE_TO_CHECK_GENERATOR) BIO_puts(out, "unable to check the generator value\n"); if (i & DH_NOT_SUITABLE_GENERATOR) BIO_puts(out, "the g value is not a generator\n"); BIO_puts(out,"\np ="); BN_print(out,a->p); BIO_puts(out,"\ng ="); BN_print(out,a->g); BIO_puts(out,"\n"); b=DH_new(); if (b == NULL) goto err; b->p=BN_dup(a->p); b->g=BN_dup(a->g); if ((b->p == NULL) || (b->g == NULL)) goto err; /* Set a to run with normal modexp and b to use constant time */ a->flags &= ~DH_FLAG_NO_EXP_CONSTTIME; b->flags |= DH_FLAG_NO_EXP_CONSTTIME; if (!DH_generate_key(a)) goto err; BIO_puts(out,"pri 1="); BN_print(out,a->priv_key); BIO_puts(out,"\npub 1="); BN_print(out,a->pub_key); BIO_puts(out,"\n"); if (!DH_generate_key(b)) goto err; BIO_puts(out,"pri 2="); BN_print(out,b->priv_key); BIO_puts(out,"\npub 2="); BN_print(out,b->pub_key); BIO_puts(out,"\n"); alen=DH_size(a); abuf=malloc(alen); aout=DH_compute_key(abuf,b->pub_key,a); BIO_puts(out,"key1 ="); for (i=0; ipub_key,b); BIO_puts(out,"key2 ="); for (i=0; iarg,&c,1); (void)BIO_flush(arg->arg); return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/ssltest.sh0000755000175000017500000000016012357706234020150 0ustar #!/bin/sh set -e export PATH=../apps:$PATH $srcdir/testssl $srcdir/server.pem $srcdir/server.pem $srcdir/ca.pem deps/libressl-pnacl-sys-2.1.6/libressl/tests/randtest.c0000644000175000017500000001330312360020706020066 0ustar /* crypto/rand/randtest.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include /* some FIPS 140-1 random number test */ /* some simple tests */ int main(int argc,char **argv) { unsigned char buf[2500]; int i,j,k,s,sign,nsign,err=0; unsigned long n1; unsigned long n2[16]; unsigned long runs[2][34]; /*double d; */ long d; i = RAND_pseudo_bytes(buf,2500); if (i < 0) { printf ("init failed, the rand method is not properly installed\n"); err++; goto err; } n1=0; for (i=0; i<16; i++) n2[i]=0; for (i=0; i<34; i++) runs[0][i]=runs[1][i]=0; /* test 1 and 2 */ sign=0; nsign=0; for (i=0; i<2500; i++) { j=buf[i]; n2[j&0x0f]++; n2[(j>>4)&0x0f]++; for (k=0; k<8; k++) { s=(j&0x01); if (s == sign) nsign++; else { if (nsign > 34) nsign=34; if (nsign != 0) { runs[sign][nsign-1]++; if (nsign > 6) runs[sign][5]++; } sign=s; nsign=1; } if (s) n1++; j>>=1; } } if (nsign > 34) nsign=34; if (nsign != 0) runs[sign][nsign-1]++; /* test 1 */ if (!((9654 < n1) && (n1 < 10346))) { printf("test 1 failed, X=%lu\n",n1); err++; } printf("test 1 done\n"); /* test 2 */ d=0; for (i=0; i<16; i++) d+=n2[i]*n2[i]; d=(d*8)/25-500000; if (!((103 < d) && (d < 5740))) { printf("test 2 failed, X=%ld.%02ld\n",d/100L,d%100L); err++; } printf("test 2 done\n"); /* test 3 */ for (i=0; i<2; i++) { if (!((2267 < runs[i][0]) && (runs[i][0] < 2733))) { printf("test 3 failed, bit=%d run=%d num=%lu\n", i,1,runs[i][0]); err++; } if (!((1079 < runs[i][1]) && (runs[i][1] < 1421))) { printf("test 3 failed, bit=%d run=%d num=%lu\n", i,2,runs[i][1]); err++; } if (!(( 502 < runs[i][2]) && (runs[i][2] < 748))) { printf("test 3 failed, bit=%d run=%d num=%lu\n", i,3,runs[i][2]); err++; } if (!(( 223 < runs[i][3]) && (runs[i][3] < 402))) { printf("test 3 failed, bit=%d run=%d num=%lu\n", i,4,runs[i][3]); err++; } if (!(( 90 < runs[i][4]) && (runs[i][4] < 223))) { printf("test 3 failed, bit=%d run=%d num=%lu\n", i,5,runs[i][4]); err++; } if (!(( 90 < runs[i][5]) && (runs[i][5] < 223))) { printf("test 3 failed, bit=%d run=%d num=%lu\n", i,6,runs[i][5]); err++; } } printf("test 3 done\n"); /* test 4 */ if (runs[0][33] != 0) { printf("test 4 failed, bit=%d run=%d num=%lu\n", 0,34,runs[0][33]); err++; } if (runs[1][33] != 0) { printf("test 4 failed, bit=%d run=%d num=%lu\n", 1,34,runs[1][33]); err++; } printf("test 4 done\n"); err: err=((err)?1:0); exit(err); } deps/libressl-pnacl-sys-2.1.6/libressl/tests/aeadtests.txt0000644000175000017500000021732212360020706020623 0ustar # # MACsec GCM-AES Test Vectors (bn-randall-test-vectors-0511-v1.pdf) # # 2.5.1 65-byte Packet Authentication Using GCM-AES-128 AEAD: aes-128-gcm KEY: 013FE00B5F11BE7F866D0CBBC55A7A90 NONCE: 7CFDE9F9E33724C68932D612 IN: AD: 84C5D513D2AAF6E5BBD2727788E523008932D6127CFDE9F9E33724C608000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F0005 CT: TAG: 217867E50C2DAD74C28C3B50ABDF695A # 2.5.2 65-byte Packet Authentication Using GCM-AES-256 AEAD: aes-256-gcm KEY: 83C093B58DE7FFE1C0DA926AC43FB3609AC1C80FEE1B624497EF942E2F79A823 NONCE: 7CFDE9F9E33724C68932D612 IN: AD: 84C5D513D2AAF6E5BBD2727788E523008932D6127CFDE9F9E33724C608000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F0005 CT: TAG: 6EE160E8FAECA4B36C86B234920CA975 # 2.8.1 75-byte Packet Encryption Using GCM-AES-128 AEAD: aes-128-gcm KEY: 88EE087FD95DA9FBF6725AA9D757B0CD NONCE: 7AE8E2CA4EC500012E58495C IN: 08000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748490008 AD: 68F2E77696CE7AE8E2CA4EC588E54D002E58495C CT: C31F53D99E5687F7365119B832D2AAE70741D593F1F9E2AB3455779B078EB8FEACDFEC1F8E3E5277F8180B43361F6512ADB16D2E38548A2C719DBA7228D840 TAG: 88F8757ADB8AA788D8F65AD668BE70E7 # 2.8.2 75-byte Packet Encryption Using GCM-AES-256 AEAD: aes-256-gcm KEY: 4C973DBC7364621674F8B5B89E5C15511FCED9216490FB1C1A2CAA0FFE0407E5 NONCE: 7AE8E2CA4EC500012E58495C IN: 08000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748490008 AD: 68F2E77696CE7AE8E2CA4EC588E54D002E58495C CT: BA8AE31BC506486D6873E4FCE460E7DC57591FF00611F31C3834FE1C04AD80B66803AFCF5B27E6333FA67C99DA47C2F0CED68D531BD741A943CFF7A6713BD0 TAG: 2611CD7DAA01D61C5C886DC1A8170107 # # Test vector from draft-agl-tls-chacha20poly1305-04 section 7. # AEAD: chacha20-poly1305 KEY: 4290bcb154173531f314af57f3be3b5006da371ece272afa1b5dbdd1100a1007 NONCE: cd7cf67be39c794a IN: 86d09974840bded2a5ca AD: 87e229d4500845a079c0 CT: e3e446f7ede9a19b62a4677dabf4e3d24b876bb284753896e1d6 # # The following are ChaCha20-Poly1305 test vectors from: # https://code.google.com/p/chromium/issues/detail?id=341598 # AEAD: chacha20-poly1305 KEY: 9a97f65b9b4c721b960a672145fca8d4e32e67f9111ea979ce9c4826806aeee6 NONCE: 3de9c0da2bd7f91e IN: AD: CT: TAG: 5a6e21f4ba6dbee57380e79e79c30def AEAD: chacha20-poly1305 KEY: bcb2639bf989c6251b29bf38d39a9bdce7c55f4b2ac12a39c8a37b5d0a5cc2b5 NONCE: 1e8b4c510f5ca083 IN: 8c8419bc27 AD: 34ab88c265 CT: 1a7c2f33f5 TAG: 2875c659d0f2808de3a40027feff91a4 AEAD: chacha20-poly1305 KEY: 4290bcb154173531f314af57f3be3b5006da371ece272afa1b5dbdd1100a1007 NONCE: cd7cf67be39c794a IN: 86d09974840bded2a5ca AD: 87e229d4500845a079c0 CT: e3e446f7ede9a19b62a4 TAG: 677dabf4e3d24b876bb284753896e1d6 AEAD: chacha20-poly1305 KEY: 422a5355b56dcf2b436aa8152858106a88d9ba23cdfe087b5e74e817a52388b3 NONCE: 1d12d6d91848f2ea IN: 537a645387f22d6f6dbbea568d3feb AD: bef267c99aec8af56bc238612bfea6 CT: 281a366705c5a24b94e56146681e44 TAG: 38f2b8ee3be44abba3c010d9cab6e042 AEAD: chacha20-poly1305 KEY: ec7b864a078c3d05d970b6ea3ba6d33d6bb73dfa64c622a4727a96ede876f685 NONCE: 2bca0e59e39508d3 IN: b76733895c871edd728a45ed1a21f15a9597d49d AD: cc1243ea54272db602fb0853c8e7027c56338b6c CT: 1fb9b2958fce47a5cada9d895fbb0c00d3569858 TAG: 042ad5042c89ebc1aad57d3fb703d314 AEAD: chacha20-poly1305 KEY: 2c4c0fdb611df2d4d5e7898c6af0022795364adb8749155e2c68776a090e7d5c NONCE: 13ce7382734c4a71 IN: 0dc6ff21a346e1337dd0db81d8f7d9f6fd1864418b98aadcdb AD: 0115edcb176ab8bfa947d1f7c3a86a845d310bf6706c59a8f9 CT: dad65e4244a1a17ce59d88b00af4f7434bd7830ffdd4c5558f TAG: ac1437b45d8eacf9c0fe547c84fb82a2 AEAD: chacha20-poly1305 KEY: c66e89fbab01208f6a60847f4f34b38d27b554c119cf8d9e0b118aa7266ab865 NONCE: 5d9856060c54ab06 IN: f9e3e9b5ed07b2080db8c1ffc37e4a6cb3cd544608921e18610d00b17c6e AD: 85c112a1efe0a20ef3a550526a7afbc98f6367ebbede4e703099abd78f51 CT: b5cc754f6dd19ef2d66f90e6bc9a322ddf216ef248cbe76b5ab6dd53bc36 TAG: 6dd98710d8a889dceea0d0a936f98617 AEAD: chacha20-poly1305 KEY: a8b9766f404dea8cf7d7dfaf5822f53df9ccd092e332a57f007b301b507d5e14 NONCE: c7f2f7a233104a2d IN: 4d6faeaee39179a7c892faae3719656cc614c7e6ecd8fcb570a3b82c4dace969090338 AD: c6d83b6a56408a356e68d0494d4eff150530b09551d008373d6dee2b8d6b5619d67fdb CT: a15443f083316eef627a371f4c9ac654d0dd75255d8a303125e9f51af4233ff4ceb7fe TAG: 52504e880f6792a60708cc6db72eae42 AEAD: chacha20-poly1305 KEY: 5e8d0e5f1467f7a750c55144d0c670f7d91075f386795b230c9bf1c04ba250bc NONCE: 88049f44ba61b88f IN: 51a1eebcc348e0582196a0bce16ed1f8ac2e91c3e8a690e04a9f4b5cf63313d7ad08d1efbff85c89 AD: 5d09bf0be90026f9fc51f73418d6d864b6d197ea030b3de072bd2c2f5cab5860a342abbd29dba9dc CT: 35aa4bd4537aa611fd7578fc227df50ebcb00c692a1cf6f02e50ed9270bd93af3bc68f4c75b96638 TAG: ccea1cbbc83944cc66df4dbf6fb7fc46 AEAD: chacha20-poly1305 KEY: 21a9f07ec891d488805e9b92bb1b2286f3f0410c323b07fee1dc6f7379e22e48 NONCE: 066215be6567377a IN: c1b0affaf2b8d7ef51cca9aacf7969f92f928c2e3cc7db2e15f47ee1f65023910d09f209d007b7436ee898133d AD: dfdfdf4d3a68b47ad0d48828dc17b2585da9c81c3a8d71d826b5fa8020fee002397e91fc9658e9d61d728b93eb CT: 8ff4ceb600e7d45696d02467f8e30df0d33864a040a41ffb9e4c2da09b92e88b6f6b850e9f7258d827b9aaf346 TAG: 4eeddc99784011f0758ba5ebfba61827 AEAD: chacha20-poly1305 KEY: 54c93db9aa0e00d10b45041c7a7e41ee9f90ab78ae4c1bba18d673c3b370abde NONCE: 3f2d44e7b352360f IN: 1241e7d6fbe5eef5d8af9c2fb8b516e0f1dd49aa4ebe5491205194fe5aea3704efaf30d392f44cc99e0925b84460d4873344 AD: f1d1b08dd6fe96c46578c1d1ad38881840b10cb5eae41e5f05fe5287223fa72242aea48cb374a80be937b541f9381efa66bb CT: 027b86865b80b4c4da823a7d3dbcf5845bf57d58ee334eb357e82369cc628979e2947830d9d4817efd3d0bc4779f0b388943 TAG: 4303fa0174ac2b9916bf89c593baee37 AEAD: chacha20-poly1305 KEY: 808e0e73e9bcd274d4c6f65df2fe957822a602f039d4752616ba29a28926ef4a NONCE: 1b9cd73d2fc3cb8e IN: 3436c7b5be2394af7e88320c82326a6db37887ff9de41961c7d654dd22dd1f7d40444d48f5c663b86ff41f3e15b5c8ca1337f97635858f AD: d57cfbe5f2538044282e53b2f0bb4e86ea2233041fb36adb8338ded092148f8c2e894ef8766a7ec2dd02c6ac5dbab0c3703c5e9119e37c CT: 9b950b3caf7d25eaf5fca6fa3fe12ed077d80dcd5579851233c766bb8bb613ec91d925a939bb52fb88d5eda803cfe2a8cda2e055b962fd TAG: 6bf5b718f5bbe1395a5fdfcbbef752f5 AEAD: chacha20-poly1305 KEY: 4adfe1a26c5636536cd7cb72aa5bded0b1aa64487ad0e4078f311e8782768e97 NONCE: d69e54badec11560 IN: 19b3f9411ce875fcb684cbdc07938c4c1347e164f9640d37b22f975b4b9a373c4302ae0e7dfdeba1e0d00ced446e338f4c5bc01b4becef5115825276 AD: bda1b0f6c2f4eb8121dcbd2eebd91a03ae1d6e0523b9b6f34b6f16ceca0d086654fb0552bfd5c8e1887730e1449ea02d7f647ae835bc2dab4bbc65b9 CT: ea765a829d961e08bacaed801237ef4067df38ad3737b7c6de4db587a102a86fc4abbaabea0ee97c95ca7f571c7bab6f38cbae60cd6e6a4ce3c7a320 TAG: b425cdf10cd0123a7e64b347c6b4b1f0 AEAD: chacha20-poly1305 KEY: eb3db86c14b7cc2e494345d0dfb4841bbd3aa1e2bc640cca0c6c405520685639 NONCE: 88b54b28d6da8c81 IN: f75c0a357271430b1ecff07a307b6c29325c6e66935046704a19845e629f87a9e3b8aa6c1df55dd426a487d533bb333e46f0d3418464ac1bef059231f8e87e6284 AD: 34b08bb0df821c573dcb56f5b8b4a9920465067f3b5bf3e3254ea1da1a7fc9847fd38bdfe6b30927945263a91fa288c7cf1bee0fddb0fadf5948c5d83eb4623575 CT: 146ec84f5dc1c9fe9de3307a9182dbaa75965bf85f5e64563e68d039a5b659aa8863b89228edb93ff3d8c3323ab0d03300476aa4aca206d4626a6b269b2078912d TAG: 0058a8dff32c29935c62210c359bd281 AEAD: chacha20-poly1305 KEY: dd5b49b5953e04d926d664da3b65ebcffbbf06abbe93a3819dfc1abbecbaab13 NONCE: c5c8009459b9e31a IN: f21f6706a4dc33a361362c214defd56d353bcb29811e5819ab3c5c2c13950c7aa0000b9d1fe69bb46454514dcce88a4a5eda097c281b81e51d6a4dba47c80326ba6cea8e2bab AD: fe6f4cbb00794adea59e9de8b03c7fdf482e46f6c47a35f96997669c735ed5e729a49416b42468777e6a8d7aa173c18b8177418ded600124a98cbb65489f9c24a04f1e7127ce CT: 911ead61b2aa81d00c5eff53aeea3ab713709ed571765890d558fb59d3993b45f598a39e5eff4be844c4d4bd1ef9622e60412b21140007d54dcf31b2c0e3e98cf33a00fd27f0 TAG: d38d672665e2c8c4a07954b10ecff7d9 AEAD: chacha20-poly1305 KEY: 3b319e40148a67dc0bb19271d9272b327bc5eee087173d3d134ad56c8c7dc020 NONCE: ce5cf6fef84d0010 IN: 27b5627b17a2de31ad00fc2ecb347da0a399bb75cc6eadd4d6ee02de8fbd6a2168d4763ba9368ba982e97a2db8126df0343cdad06d2bc7d7e12eec731d130f8b8745c1954bfd1d717b4ea2 AD: a026b6638f2939ec9cc28d935fb7113157f3b5b7e26c12f8f25b36412b0cd560b7f11b62788a76bd171342e2ae858bcecb8266ff8482bbaed593afe818b9829e05e8e2b281ae7799580142 CT: 368fb69892447b75778f1c5236e1e9d5d89255c3d68d565a5bba4f524d6ad27de13087f301e2ef4c08f5e2c6128b1d3e26de845c4ac4869e4c8bd8858ad0d26dec3b5d61a9e3666a3911ba TAG: 2e70564c3999c448d92cc6df29d095c4 AEAD: chacha20-poly1305 KEY: 43bf97407a82d0f684bb85342380d66b85fcc81c3e22f1c0d972cd5bfdf407f4 NONCE: 8b6ba494c540fba4 IN: 4b4c7e292a357f56fdf567c32fc0f33608110d7ce5c69112987d7b5a0bd46d8627a721b0aed070b54ea9726084188c518cba829f3920365afc9382c6a5eb0dd332b84612366735be2479b63c9efc7ff5 AD: 1e0acf4070e8d6758b60d81b6d289a4ecdc30e3de4f9090c13691d5b93d5bbcef984f90956de53c5cf44be6c70440661fa58e65dec2734ff51d6d03f57bddda1f47807247e3194e2f7ddd5f3cafd250f CT: d0076c88ad4bc12d77eb8ae8d9b5bf3a2c5888a8d4c15297b38ece5d64f673191dc81547240a0cbe066c9c563f5c3424809971b5a07dcc70b107305561ce85aecb0b0ea0e8b4ff4d1e4f84836955a945 TAG: 75c9347425b459af6d99b17345c61ff7 AEAD: chacha20-poly1305 KEY: 12fc0bc94104ed8150bde1e56856ce3c57cd1cf633954d22552140e1f4e7c65d NONCE: d3875d1b6c808353 IN: 24592082d6e73eb65c409b26ceae032e57f6877514947fc45eb007b8a6034494dde5563ac586ea081dc12fa6cda32266be858e4748be40bb20f71320711bf84c3f0e2783a63ad6e25a63b44c373a99af845cdf452c AD: b8be08463e84a909d071f5ff87213391b7da889dc56fd2f1e3cf86a0a03e2c8eaa2f539bf73f90f5298c26f27ef4a673a12784833acb4d0861562142c974ee37b09ae7708a19f14d1ad8c402bd1ecf5ea280fab280 CT: 9d9ae6328711fb897a88462d20b8aa1b278134cdf7b23e1f1c809fa408b68a7bfc2be61a790008edaa98823381f45ae65f71042689d88acfa5f63332f0fba737c4772c972eba266640056452903d6522cefd3f264e TAG: e9c982d4ade7397bcfaa1e4c5a6cd578 AEAD: chacha20-poly1305 KEY: 7b6300f7dc21c9fddeaa71f439d53b553a7bf3e69ff515b5cb6495d652a0f99c NONCE: 40b32e3fdc646453 IN: 572f60d98c8becc8ba80dd6b8d2d0f7b7bbfd7e4abc235f374abd44d9035c7650a79d1dd545fa2f6fb0b5eba271779913e5c5eb450528e4128909a96d11a652bf3f7ae9d0d17adbf612ec9ca32e73ef6e87d7f4e21fe3412ce14 AD: 9ff377545a35cf1bfb77c734ad900c703aee6c3174fdb3736664863036a3a9d09163c2992f093e2408911b8751f001e493decc41e4eeeed04f698b6daed48452a7e1a74ec3b4f3dcf2151ca249fa568aa084c8428a41f20be5fd CT: 229da76844426639e2fd3ef253a195e0a93f08452ba37219b6773f103134f3f87b1345f9b4bf8cfc11277c311780a2b6e19a363b6ac2efe6c4cc54a39b144e29c94b9ebbde6fd094c30f59d1b770ebf9fcad2a5c695dc003bf51 TAG: b72acab50131a29558d56ae7b9d48e4e AEAD: chacha20-poly1305 KEY: 4aeb62f024e187606ee7cc9f5865c391c43df1963f459c87ba00e44bb163a866 NONCE: 9559bd08718b75af IN: c5d586ceece6f41812c969bcf1e727fe6ff8d1ae8c8c52367c612caa7cdf50e0662f5dffc5ea7d3cc39400dfe3dc1897905f6490fd7747b5f5f9842739c67d07ce7c339a5b3997a7fb4cd0d8e4817ff8916b251c11ef919167f858e41504b9 AD: 51f5b503b73a5de8b96534c2a3f2d859ece0bd063ea6dfa486a7eec99f6c020983f7148cccb86202cf9685cc1cc266930f04e536ad8bc26094252baa4606d883bd2aeed6b430152202e9b6cc797ff24fc365315ed67391374c1357c9a845f2 CT: 252ea42b6e5740306816974a4fe67b66e793ebe0914778ef485d55288eb6c9c45fa34ac853dc7a39252520514c3cb34c72b973b14b32bc257687d398f36f64cc2a668faffa7305ab240171343b5f9f49b6c2197e4fbe187b10540d7cdcfa37 TAG: 711ff33ef8d2b067a1b85c64f32f1814 AEAD: chacha20-poly1305 KEY: 9a19e72f005cae1ae78b8e350d7aabe59fc8845999e8c52fad545b942c225eaf NONCE: d9dae2ea8d2ffc31 IN: 2110378d856ded07eb2be8e8f43308e0c75bc8a3fcc7b1773b0725b7de49f6a166c4528e64120bdf7c9776615d3ce6feeb03de964a7b919206a77392f80437faceb6745845cafc166e1c13b68e70ca2a1d00c71737b8fcbbbd50902565c32159e05fcd23 AD: 1cd73b72c4e103afbefd7c777e0480f3f5e68c60b85bd2e71ef5caebb175d7fc6535d39f38f92c24f2eb0fe97d878ed3d5967c0bb4394a5d41f7d34cda6e1523d3848f049cde554a7d31e1afeab5d3e6150f85858335cbd28c8a7f87d528058df50eea06 CT: 5f009fbce4ec8e4ca9d8d42258b1a3e4e920b2fbad33d5e9f07557d9595e841025193b521ba440110dd83958e8ee30219d952b418e98a6c624894aa248aedc0678f2d263e7bfaf54ca379fef6c5d2f7ac422ea4b4369408b82d6225a7a2cf9a9f46fd4ef TAG: aa0a5fa7d3cf717a4704a59973b1cd15 AEAD: chacha20-poly1305 KEY: ba1d0b3329ecc009f1da0fab4c854b00ad944870fdca561838e38bad364da507 NONCE: 8a81c92b37221f2f IN: 6289944ffa3ccea4bf25cd601b271f64e6deb0eba77d65efb4d69ca93e01996e4727168b6f74f3ccf17bd44715f23ceb8fc030c0e035e77f53263db025021fd2d04b87a1b54b12229c5e860481452a80a125cb0693a2ba1b47e28ee7cbaf9e683c178232c7f6d34f97 AD: e57883961b8d041d9b9eeaddcfd61fa9f59213f66571fadffffdd1498b9b014f1ef2e7e56c3044d7f9fa7a1403a1169e86430a2a782137093f5456e142aad03a5f7a66d38009dd01b7fc02c9cf61642dedaf7cc8d46066c281ee17780674c3a36eae66c58d2d765075 CT: 9c44d9135db0dbf81c862c1f69bec55a279794cdd29a58e61909aa29ec4c120c9c5a508d856b9e56138095714a4bb58402a1ad06774cf4ecdf2273839c0007cb88b5444b25c76f6d2424281101d043fc6369ebb3b2ff63cdb0f11a6ea1b8a7dafc80cdaef2813fa661 TAG: 65c746f659bcbdcd054e768c57c848c9 AEAD: chacha20-poly1305 KEY: 0cf8c73a6cffc1b8b2f5d320da1d859d314374e4a9468db7fd42c8d270b7613a NONCE: 3c4c6f0281841aff IN: 4434728d234603c916e2faa06b25d83bad3348990ecde2344368d1a7af1309bd04251bb2e0b72044948f8dea33cce2618283b6af742073a9586b26c1089335fe735141e099785a1235810a3a67ff309e2f0ce68220ba0077ad1a5dc1a4aef898a3b9ff8f5ad7fe60149bd0bd6d83 AD: a38d09a4f1c9241623c639b7688d8d35345ea5824080c9d74e4352919db63c74d318f19e1cbb9b14eebd7c74b0ad0119247651911f3551583e749ea50ff648858dcaaa789b7419d9e93a5bf6c8167188dbac2f36804380db325201982b8b06597efeb7684546b272642941591e92 CT: bdfbfea261b1f4c134445321db9e6e40476e2dd2f4e4dbe86e31d6a116d25830762e065b07b11a3799aab93a94b4f98c31c0faeb77ec52c02048e9579257e67f5a6bae9bc65210c25b37fc16ee93bda88fd5f30a533e470b6188c6ce5739fa3e90f77120b490fc1027964f277f40 TAG: 4993ee9582f58eabdb26b98c4d56a244 AEAD: chacha20-poly1305 KEY: 69f4e5788d486a75adf9207df1bd262dd2fe3dd3a0236420390d16e2a3040466 NONCE: 6255bf5c71bb27d1 IN: c15048ca2941ef9600e767a5045aa98ac615225b805a9fbda3ac6301cd5a66aef611400fa3bc04838ead9924d382bef8251a47f1e487d2f3ca4bccd3476a6ca7f13e94fd639a259ef23cc2f8b8d248a471d30ac9219631c3e6985100dc45e0b59b8fc62046309165ddb6f092da3a4f067c8a44 AD: 0c83039504c8464b49d63b7f944802f0d39c85e9f3745e250f10119fa2c960490f75ae4dced8503b156d072a69f20400e9494ab2fa58446c255d82ff0be4b7e43046580bc1cf34060c6f076c72ea455c3687381a3b908e152b10c95c7b94155b0b4b303b7764a8a27d1db0a885f1040d5dbcc3 CT: f0bb2b73d94f2a7cef70fe77e054f206998eacf2b86c05c4fa3f40f2b8cebf034fe17bcbee4dea821f51c18c0aa85b160f8508bd1dc455cc7f49668b1fb25557cdae147bf2399e07fcacaca18eccded741e026ef25365a6b0f44a6b3dd975ee6bb580f5fccd040b73c18b0fbf8f63199ba10fe TAG: 4236a8750f0cafee3c4a06a577a85cb3 AEAD: chacha20-poly1305 KEY: ad7b9409147a896648a2a2fe2128f79022a70d96dc482730cd85c70db492b638 NONCE: a28a6dedf3f2b01a IN: 791d293ff0a3b8510b4d494b30f50b38a01638bf130e58c7601904f12cb8900871e8cf3d50abd4d34fda122c76dfee5b7f82cd6e8590647535c915ae08714e427da52f80aef09f40040036034ca52718ea68313c534e7a045cd51745ec52f2e1b59463db07de7ca401c6f6453841d247f370341b2dbc1212 AD: 9a6defddb9b8d5c24a26dd8096f5b8c3af7a89e1f7d886f560fabbe64f14db838d6eb9d6879f4f0b769fe1f9eebf67fcd47b6f9ceb4840b2dba7587e98dc5cae186ef2a0f8601060e8058d9dda812d91387c583da701d2ba3347f285c5d44385a2b0bf07150cbc95e7fcfa8ae07132849a023c98817c03d2 CT: c2f109d6d94f77a7289c8a2ab33bc6a98d976554721b0c726cbf4121069473e62ba36e7090e02414f3edc25c5d83ac80b49ad528cda1e3ad815b5a8c8ae9ad0753de725319df236983abd3f69ab4465d9b806c075b1896d40bdba72d73ba84c4a530896eb94ffccf5fb67eb59119e66a1861872218f928cf TAG: e48dc0153d5b0f7edb76fc97a0224987 AEAD: chacha20-poly1305 KEY: 48470da98228c9b53f58747673504f74ca1737d7d4bb6dbf7c0cba6ca42f80b9 NONCE: 56fb4923a97e9320 IN: bc6626d651e2b237f22ee51608ddcffeba5f31c26df72f443f701f2b085d6f34f806e29673584cb21522179edb62a82427d946acabce065b88b2878e9eb87ed1004e55ef58f51ec46375ac542c5782725ff013136cb506fcf99496e13fcd224b8a74a971cc8ddb8b393ccc6ac910bd1906ea9f2ed8a5d066dc639c20cd AD: df8ab634d3dca14e2e091b15ecc78f91e229a1a13cba5edd6526d182525ec575aa45bc70fb6193ffcd59bad3c347159099c4f139c323c30a230753d070018786b2e59b758dd4a97d1a88e8f672092bef780b451fd66ba7431cbb5660ea7816cdf26e19a6ebb9aadc3088e6923f29f53f877a6758068f79a6f2a182b4bf CT: a62e313ecf258cc9087cbb94fcc12643eb722d255c3f98c39f130e10058a375f0809662442c7b18044feb1602d89be40facae8e89ca967015f0b7f8c2e4e4a3855dbb46a066e49abf9cef67e6036400c8ff46b241fc99ba1974ba3ba6ea20dc52ec6753f6fc7697adbccd02b0bbea1df8352629b03b43cc3d632576787 TAG: 675287f8143b9b976e50a80f8531bd39 AEAD: chacha20-poly1305 KEY: b62fb85c1decd0faf242ce662140ad1b82975e99a3fa01666cac2385ab91da54 NONCE: 2f4a5ca096a4faf8 IN: 03b14f13c0065e4a4421de62ab1d842bffb80f3da30bf47d115c09857f5bdd5756fd7c9ac3d9af1c9fb94f2640f7f4386cfba74db468e5288dbe4dd78bfe4f69e41480ca6138e8beacc6eaa3374157c713cfa900c07dd836eaecc8827fa3e70e052ae09e8473e2ae1a10b1bb669ef60a8dd957f6553daa8114918e17371f2ac327bd AD: cfe3b7ab7550b0e8e2e8235fa0dcef95647ce6814abd3dc3f5a3bd7d6d282504660c34ad8341e4d11402c7d46c83a494d7ddb105e1002979023e0e3dc2978c9ae53e10eb8567e7a02b60e51e945c7040d832ca900d132b4205a35034fed939a1b7965183c25654931a9b744401c4649c945710b0d9733b87451348b32ba81de30ea7 CT: 8965db3d3ae4fb483208f147276e7d81b71a86e7202ffc9b1eaade009bc016838dc09ca4bcf30887b2f4243fbd652cd90ebed1ceef8151ff17ea70518d03b0f2a24960aa7de9b30fa65c2e2d57360061aae6d9376e984e9fcd5e5dd0911a4bc8deca832ffb76f252bd7da523076593ba6b174f7d9fb0377e066ecbb6638036241e86 TAG: 3d0fc53e9058c2be32aa0850e0fab5a6 AEAD: chacha20-poly1305 KEY: de9c657258774d4ebc09d109a0fc79d66493ae578797cac4eb8830a6a4b547e0 NONCE: b5e35fe3398efa34 IN: 4d68fb683aa4f4c7a16ba1114fc0b1b8d8898610fa2763e435ded8771b3651078bef73d4dfd14e76a34cd5eb9ef4db4ead4da9e83f4ce50fe059977b2d17d687c29335a04d87389d211f8215449749969f7652dc1935a0f9a94538dc81dc9a39af63446a6517609076987920547d0098a9c6766cf5e704883ea32feaea1889b1554b5eb0ce5ecc AD: 436ea5a5fee8293b93e4e8488116c94d3269c19f1d5050def23d280515457b931bbed64a542b317cc5023d648330a4b7adca14dd6f3783207b94f86ccaa0a0ac39b7db00ac87a99e3cd8a764ed9c75da8454479636ab2b29e770b166a5b75cacc425c919bf1ce9ac34afe6b4425c3d9fd2e48bc81e7d15516d60e592bfcc2ebefb660f0995f2b5 CT: 97a97b8f0f5420845ae8d57567f9bba693d30e6db916fad0b971f553ad7d993f806f27ab8b458d8046062ced4778c004b4f958a4436141637c6039963308dea2f54008b7feab79650295ed41bf9e65e1a2d75ab1c7b2a70ebb9e9f38d07a9a672d3e95ea78afe9ac02f2566b48b0251aef6eeeca8bd15bd8d43b559426aa9d15d960ee35cb3edf TAG: e55dbb21851e8a5b365f86d02518331c AEAD: chacha20-poly1305 KEY: 6885bd333c336c7672db8ebdf24c1a1b605c5a4ae279f0f698162f47e6c73401 NONCE: f0c4a213a6168aab IN: fa905a2bfa5b5bad767239fb070a7bc0b303d1503ecd2b429418cc8feba843e5444ed89022fdb379c3b155a0f9ceab2979000a0f60292a631771f2fde4ef065aa746426609082969530a9c70ad145308c30ba389ea122fd766081511a031ce3a0bd9f9f583c7000b333b79ac004fbde6ec3eb2d905977ff95dcff77858e3c424fe8932a6a12139e6ec8d5e98 AD: 8ded368f919efb522bb6a9ad009e02ffbc6a16536e34d95cdb34f1153d7cb7b0f3c2b13dd05cedae27cfe68ec3aca8047e0930a29c9d0770c1b83c234dcb0385deae7ae85da73a5f8de3dfb28612a001f4e552c4f67ae0e2ec53853289b7017a58591fd6f70b0e954876bb2f7ec33001e298856a64bb16181017ba924648c09fc63c62eff262c80d614679bd CT: 0cb3d6c31e0f4029eca5524f951244df042fc637c4162511fea512a52d3f7581af097eb642e79e48666cb1086edbd38c4777c535a20945fabc23e7c9277e2b960aac46865f1026eb6da82759108b9baece5da930ccfc1052b1656b0eadaa120ed0c45ad04b24ae8cdb22ceab76c5f180b46a392ab45b1b99c612546e6b947f4d5c06ad5abee92ff96345ad43 TAG: d3b541ac446c84626daf800c0172eec6 AEAD: chacha20-poly1305 KEY: fbc978abb1240a6937ccc16735b8d6ed5411cdbc1897214165a174e16f4e699b NONCE: 7968379a8ce88117 IN: 1a8196cd4a1389ec916ef8b7da5078a2afa8e9f1081223fa72f6524ac0a1a8019e44a09563a953615587429295052cc904b89f778ef446ed341430d7d8f747cf2db4308478524639f44457253ae5a4451c7efca8ae0b6c5c051aaa781e9c505489b381a6dcba87b157edc7f820a8fbaf2a52e484dc121f33d9d8b9ac59d4901d6ed8996ed4f62d9d4d82274c449cd74efa AD: 3913cd01299b8a4e507f067d887d7e9a6ded16dd9f9bb3115c5779aa14239fd33ee9f25756d45262dc3011069356425b5c81a4729594e17c9747119f81463e85625d5603d05e00f568b0c800bb181eb717be8d7a93166a504ce1bc817e15530c5bd2b3df1d4222245ea78a38bc10f66c5cf68d661503131f11af885c8a910b6dce70bc3a7448dfae00595beb707fe054d3 CT: d152bcb4c24c3711b0fad28548dc4db605bbc89237cdbea7dbf956b8855d1161a0781f27bd56d798141e2ace339955efb98fe05d9b44cd011e645106bf47726183958cb6df34ce5766695f60bc70b6fe0fabb9afa009a8ef043dbf75f861881368fa07726625448fe608d578cdc48277f2dc53eaaf1bdc075269a42f9302a57cad387a82c6969608acacda20e1cac4596c TAG: 945dca73cf2f007ae243991c4fbe0479 AEAD: chacha20-poly1305 KEY: 77d1a857fbadfe01aba7974eea2dfb3dc7bf41de73686aece403993e5016c714 NONCE: fdd913a321c40eb0 IN: db8915bfe651e2ecb3ce0b27d99a6bfa7a7c507cfcb2987293018636c365a459c6a138b4428be538413db15bda69e697cbb92b154b7f4d2cbb07965225aa6865d7dcd1ba2c17c484b00b1986fed63e889f25a4966dc3ed4273f1577768f665362d7d3e824484f0dded7f82b8be8797ad951719719365e45abbf76324bc7d657799d4d4f4bb1dba67d96ab1c88519a5bee704f7214814 AD: 3cb2c06c20cb0832bbacebfc205d77393ca1816346ea2681de4d3ab1fadb774ad273e4713290454496f5281ebc65e04cfe84ed37cd0aedc4bbe3decbd8d79d04a4e434876650e0d64309e336bfb10e924066a64acb92260b2dbd96735d03af03909aa6a80a6e89fda81037257aec21fe9be7e91a64e88e0a58fa38ecba4c4c4cffb61958f3c486cbb0b1d0b0014a2d1d3df248eec1ca CT: acb825e6023b44b03b2efc265603e887954e8612b2ee134bdcb61501cfb9492952bf67be597c3a005b09af74d9e421a576d2c65e98104780feab838d8cb1bd135452ea39dc8907a4c1a6a9161805e4fa3e16989e6a418a7eea2582bf895da967028eab7c95d846a6de4b9980785814cf00484baa2f6de609912fff689bce6e854261ffe866bd8e63274605c7c5ad677bd7897ade543e TAG: 938478a41a3223a2199f9276d116210f AEAD: chacha20-poly1305 KEY: b7e9b90dc02b5cd6df5df7283ef293ed4dc07513d9e67331b606f4d42dec7d29 NONCE: a6c191f6d1818f8e IN: 2ada0e3c7ca6db1f780ce8c79472af4e8e951ddc828e0d6e8a67df520638ff5f14a2f95a5e5931749ae2c4e9946ae4d5eb5de42fb5b77d2236e2e2bd817df51be40b1b8a6c21015a7c79fe06dba4a08b34013dfa02747b5f03930268404c455dc54a74d9c6e35485e10026da573cb41cd50b64cfafe4cfcdf3c9684ef877e45d84e22bd5e15fa6c8fd5be921366ff0dc6fe2df45f7252972c9b303 AD: 0f4269ed5ef0bfff7be39946a4e86e8bf79f84b70cd0b14fecb7be3c071316ce86de3d99d6871e0ba5667d9d7bba7dcaba10cb2a36668b6c3e2fb6c102938b75008bb9c213ebf9b85b5e91a802df0d31d7f11d764b2289f6225212694ab6b7c0e3ff36e84245d9f4f43fc5f98e654dea7ba9bd918658879c5bb4a1642af0d83113e3cf935d3c0d5208318f66f654eb17d8c28a602543e77ad3e815 CT: 22586fe7338e99cdaad9f85bd724ba4cfe6249b8a71399f9a3707b5c4323b8d96679568dfc8d230aefb453df596e13eb3e8a439249bd64bc93a58f95089a62b94f6562b821c83d91f56c55147381e9de4beb4ae81bd6fe7caef7e7e9a2078f2fba8f3e70d4910da9accc92b8e81a61b0fefbece4bd89443e66e8ddda8e47a66a62f17fd0e7d0a4852ce1a4d43d72a0b5e8914bbec698f060f2b092 TAG: c082470297da8c5f682a169d28bc0239 AEAD: chacha20-poly1305 KEY: 6b2cb2678d1102f2fbbd028794a79f14585c223d405e1ae904c0361e9b241e99 NONCE: 7b3ae31f8f938251 IN: b3cb745930e05f3ab8c926c0a343a6eb14809fd21b8390a6fcc58adb5579e5432021765b2d249a0ecf6ba678634c4f53f71495865f031ee97aa159f9ead3a3fcb823ee5238bdf12706a9c6137d236e2e7110ce650c321e41daf0afd62bab2a8fe55d7018de49a14efe6d83a15b2f256d595e998d25309f23633360f5745c50c4e5af8ccc9a8a2cb47064105a023e919c7795d2dc331d3f2afb8c42e5c0bcc26d AD: 1c32fd3df22b3e440e2a3c7a7624990194cb16a5f74af36f87fd6ca7d410ce9064316a2d091945deef7d9b35ceec8396069307caced2b80afd7d53ec479c35cedf2dfd4c95c3dd8400f71ad34028c6e4f8681d93d0774064ba38f3fb9b0c1dfa1f5f0c7d20676a5911d999fb6a1d41367a8e99d852bf3d3b7b3f4c233249ed1ca135389a674ff48232ded3f6800a97b6d409c40e6cd70d09bf9d2ad25d9b9485 CT: ef70c7de98ab1d4ad817024a970be463443640eb0cd7ff234bdd00e653074a77a1d5749e698bd526dc709f82df06f4c0e64046b3dc5f3c7044aef53aebb807d32239d0652dd990362c44ec25bf5aeae641e27bf716e0c4a1c9fbd37bbf602bb0d0c35b0638be20dd5d5891d446137e842f92c0ee075c68225e4dbacb63cc6fb32442b4bcda5e62cb500a4df2741a4059034d2ccb71b0b8b0112bf1c4ca6eec74 TAG: 393ae233848034248c191ac0e36b6123 AEAD: chacha20-poly1305 KEY: 4dbc80a402c9fceaa755e1105dc49ef6489016776883e06fcf3aed93bf7f6af7 NONCE: 2358ae0ce3fb8e9f IN: 197c06403eb896d2fa6465e4d64426d24cc7476aa1ae4127cd2bd8a48ce2c99c16b1cbf3064856e84073b6cf12e7406698ef3dd1240c026cbd1ab04ee603e1e6e735c9b7551fd0d355202b4f64b482dd4a7c7d82c4fe2eb494d0d5e17788982d704c1356c41a94655530deda23118cba281d0f717e149fbeb2c59b22d0c0574c1a2e640afad1a6ceb92e1bf1dde71752a1c991e9a5517fe98688a16b073dbf6884cfde61ac AD: cf6ce7b899fb700a90d2a5466d54d31358ecf0562e02b330a27ba0138006b342b7ed6349d73c4c5c6d29bde75a25089b11dac5b27adea7e7640ca1a7ceb050e3aae84a47e11640a6e485bd54ae9fdb547edc7313d24a0328429fcffd8b18f39880edd616447344ebeec9eadb2dcb1fa7e67179e7f913c194ebd8f5a58aea73b0c5d1133561245b6d9c5cfd8bb0c25b38ffb37db5e2de5cdded6b57355e9d215cb095b8731f CT: aa87f9a83048b6919c8f2b050315db4e2adae4a9c2ca0109b81961b520e63299dcb028cec0b9d3249a945ee67dd029b40f361245c740f004f8cf0d2214fcfa65e6124a3e74b78aa94345c46fdc158d34823ed249ee550431eaae9218367321cdd6e6a477650469bb3cc137a8f48d9cf27934b16703608b383d2145659922fb83bb2e7ee2ef938a90f2ff846a4a949129b1fb74dde55c5ae013c2f285de84f7dac7d1662f23 TAG: 06b4318ac7f65d556f781428a0514ffe AEAD: chacha20-poly1305 KEY: 9e4a62016dae4b3223fed1d01d0787e31d30694f79e8142224fe4c4735248a83 NONCE: 263a2fc06a2872e7 IN: 5a46946601f93a0cee5993c69575e599cc24f51aafa2d7c28d816a5b9b4decda2e59c111075fb60a903d701ad2680bb14aeda14af2ae9c07a759d8388b30446f28b85f0a05cd150050bd2e715ff550ebbd24da3ebb1eac15aba23d448659de34be962ab3ab31cb1758db76c468b5bb8ce44b06c4e4db9bd2f0615b1e727f053f6b4ffb6358d248f022bcad6ca973044bed23d3920906a89a9a9c5d8024ec67d7f061f64529a955ce16b3 AD: 4cd65f68f9f88c0516231f2a425c8f8a287de47d409d5ecde3ad151e906b3839fb01bb91a456f20ea9d394d4b06604ab1f9009ef29019af7968d965d1643161ab33a5354cda2fdc9f1d21ec9cb71c325c65964a14f9b26eb16560beb9792075a1597394000fd5f331bd8b7d20d88e5f89cf8d0b33e4e78e4904bb59c9c8d5d31ac86b893e4a0667af1be85fdb77f7ec3e2594a68048d20c2fb9422f5879078772ee26a1c560cbcbb2113 CT: e944bb2ab06d138ad633c16ce82706ecf0ef5d119be1f3460c9ce101d9c4e04ef1677707fca40d1f8ca181e07273707b06624d6d7063c3b7b0bb0151b757b3e5237fb8004c161233d8bc7e5f28ea1c18da1874b3d54c5ad6ff0835eed35c8853704585cf83996e5e7cec68180af414e04f08134d3b0384ebdf0393c9310b55d8698fe10cb362defc0995e9a13b48b42cff61ffd9fe4c3c8c6dab355713b88f6e98a02e7231a0c6644ec4 TAG: 27de0d4ca7648f6396d5419a7b1243b7 AEAD: chacha20-poly1305 KEY: 18ca3ea3e8baeed1b341189297d33cef7f4e0a2fab40ec3b6bb67385d0969cfe NONCE: b6aef34c75818e7c IN: ef6d1bb4094782f602fcf41561cba4970679661c63befe35ff2ca7ad1a280bf6b1e7f153fa848edfeffe25153f540b71253e8baba9aeb719a02752cda60ea5938aab339eead5aabf81b19b0fc5c1ed556be6ad8970ea43c303d3046205b12c419dea71c4245cfedd0a31b0f4150b5a9fe80052790188529ab32f5e61d8ccde5973ed30bdf290cbfbd5f073c0c6a020eac0332fced17a9a08cef6f9217bd6bef68c1505d6eed40953e15508d87f08fc AD: f40f03beaa023db6311bad9b4d5d0d66a58d978e0bcbbf78acebde1f4eb9a284095628955a0b15afc454152f962ec3ea2b9a3b089b99658e68ede4dee5acd56672025eb7323bcbc6ba5d91c94310f18c918e3914bbbf869e1b8721476f9def31b9d32c471a54132481aa89f6c735ab193369496d8dbeb49b130d85fbff3f9cb7dccea4c1da7a2846eef5e6929d9009a9149e39c6c8ec150c9ab49a09c18c4749a0a9fcba77057cdea6efd4d142256c CT: c531633c0c98230dcf059c1081d1d69c96bab71c3143ae60f9fc2b9cd18762314496ab6e90bf6796252cb9f667a1f08da47fc2b0eecda813228cae00d4c0d71f5e01b6ce762fa636efffe55d0e89fdc89ba42521cc019ab9d408fcd79c14914e8bbf0ea44d8a1d35743ad628327e432fdcfeb0b6679ddca8c92b998473732abd55dba54eefff83c78488eee5f92b145a74b6866531476fc46279d4fde24d049c1ce2b42358ff3ab2ba3a8866e547af TAG: a0a5242759a6d9b1aa5baf9a4ef895a2 AEAD: chacha20-poly1305 KEY: 95fdd2d3d4296069055b6b79e5d1387628254a7be647baafdf99dd8af354d817 NONCE: cd7ed9e70f608613 IN: 0248284acffa4b2c46636bdf8cc70028dd151a6d8e7a5a5bc2d39acc1020e736885031b252bfe9f96490921f41d1e174bf1ac03707bc2ae5088a1208a7c664583835e8bb93c787b96dea9fc4b884930c57799e7b7a6649c61340376d042b9f5faee8956c70a63cf1cff4fc2c7cb8535c10214e73cec6b79669d824f23ff8c8a2ca1c05974dd6189cfee484d0906df487b6bd85671ce2b23825052e44b84803e2839a96391abc25945cb867b527cdd9b373fbfb83 AD: 24a45a3a0076a5bcfd5afe1c54f7b77496117d29f4c0909f1e6940b81dde3abacb71ec71f0f4db8a7e540bd4c2c60faee21dd3ce72963855be1b0ce54fb20ad82dbc45be20cd6c171e2bebb79e65e7d01567ad0eeb869883e4e814c93688607a12b3b732c1703b09566c308d29ce676a5c762a85700639b70d82aaef408cf98821a372c6a0614a73ba9918a7951ea8b2bb77cd9896d26988086d8586d72edc92af2042ff5e5f1429a22f61065e03cfcd7edc2a93 CT: 40c6318d9e383e107cdd3e1c8951562193c3ef64ee442432a63e2edefc78f32ab07772aeac172cb67ecf4d21f8b448423527bbeb9d8ddd0b46bdb27f74096ceb24e41963b4cdca176676a75bdbe3abc270b349ac0c6cbd9c3a5cd5bce20202fc5cc0c1bdd4fd25e121e0a24bd7bbeb9b19b1912467bf5338ee2ce88aa383c082b42cc399c9654ca325f35523e81438beb3f8926be79c378822d7c8f785614408a5f7cac49e4543188725643e6c1a70b46d0ec400 TAG: 5801e84192c7267f66b0e04607a39a3e AEAD: chacha20-poly1305 KEY: 6ae1102f84ed4dc114bb9d63f4dc78d7dbb1ab63f1659dd95f47940a7b7a811f NONCE: c965d578ba91d227 IN: b82a8a9209618f1f5be9c2c32aba3dc45b4947007b14c851cd694456b303ad59a465662803006705673d6c3e29f1d3510dfc0405463c03414e0e07e359f1f1816c68b2434a19d3eee0464873e23c43f3ab60a3f606a0e5be81e3ab4aa27fb7707a57b949f00d6cd3a11ae4827d4889dd455a0b6d39e99012fd40db23fb50e79e11f8a6451669beb2fbd913effd49ad1b43926311f6e13a6e7a09cf4bebb1c0bf63ce59cd5a08e4b8d8dbf9d002e8a3d9e80c7995bb0b485280 AD: dfd4ac3e80b2904623ff79ea8ee87862268939decf5306c07a175b6b9da0eb13ac209b4d164755929e03240a0fe26599f136fb2afdffd12bb20354aa1d20e5799839abb68ae46d50c8974e13e361d87ef550fe6d82e8b5b172cf5cd08482efdef793ede3530d24667faf3a1e96348867c2942641f4c036981b83f50236b8e8a10b83ebf6909aad0076302f1083f72de4cf4a1a3183fe6ec6bfe2e73e2af8e1e8c9d85079083fd179ccc2ee9ff002f213dbd7333053a46c5e43 CT: a9aeb8f0a2b3ca141ac71a808dcc0c9798ac117c5d2bd09b3cfe622693a9f8ca62e841b58bddb2042f888e3099b53638b88dfc930b7a6ee4272d77e4b1d7e442bab6afbde96ab0b432f0092d9ca50eef42f63c60c09e7b8de019b32ebe4030c37b8183cc1e3b913b0ce4ee4d744398fa03f9af1c070bed8cdafd65b3a84140cb4deadc70184de757332ce3780af84353f540755227e886a8d7ad980f3dd6fd68263d82e93f883381dec888bc9f4f48349aa2b4c342cb9f48c6 TAG: f26b3af8a45c416291ce66330733b2f8 AEAD: chacha20-poly1305 KEY: 405bb7b94715b875df068655f00513cb1ae23ffaac977ce273e57d3f83b43663 NONCE: 5c6da1259451119a IN: f9f143c0c52c94b4ba7b0608b144156a49e7b5d27c97315743d171911e3645ab7957c80924e3c6b9c22ab7a1cac4b7e9c0de84e49fd5e4a2d1ab51d764fc5670318688ec942f7ab34c331dce8f90fea6972e07f0dadec29d8eb3b7b6521ddd678a6527a962f4d8af78c077e27f7a0b2ef7eabd19e92b7f8c1e8fb166d4763ce9c40c888cf49aa9cdfc3e997c8fe1cce3fe802441bbd698de269ff316f31c196e62d12c6bb5cd93fb3c79ca6369f8c1ac9102daf818975ea7f513bb38576a AD: 6fe6446505677bf08b385e2f6d83ef70e1547712208d9cebc010cba8c16ea4ece058d73c72273eed650afdc9f954f35aa1bdf90f1118b1173368acbc8d38d93ebf85bd30d6dc6d1b90913790c3efa55f34d31531f70c958759b2ba6f956c6fcdd289b58cb4c26e9515bf550f0fd71ab8527f062c9505cbb16e8e037d34de1756bef02a133dbf4a9c00ac03befc3fb7f137af04e12595ce9560f98b612480fcdba3b8be01db56ebec40f9deae532c3b0370b5c23a2a6b02a4de69efa8900c CT: 1a4b073881922c6366680cc9c2a127b26f264148651b29abb0c388cf6c9b1865dba5a991e1f8309efbdb91bce44b278772c58fd41273526c33fec84beb53d1689b9da8483f71be6db73a73417069bb4cd3f195236e8d0a00d124eed3a6b6f89415b19a27fbe35774f6a1a6ee4bd4350b252b975f0db2d2eea82f4836350850d6290901e726e8af13644e2d98bc1d569c20800521e6affe976bd407049a2e6d9dd23f88d52e651391ecd2fc45b864310824aaadfa203762a77c1d64562dae TAG: 0060026d3efc120f11c0739959ae0066 AEAD: chacha20-poly1305 KEY: 8c602bd94c630cd00c7a9c508067a5a9f133d12f06d9f6fe2a7b68dce4786d8a NONCE: 760de0f7b7cb67e2 IN: c3ff559cf1d6ba6c0cc793ca09a0ba573a28359386a6ec93e1bacd8e630209e0b477a20aedec3c9cbf513ee6a1e3887112218d6155b9875f7e6c4bbba2c31972e905d19f529f4f0f9502996199f94f8728ba8d6424bb15f87fcacd88bb42c63fcc513759712bd0172b1e87c9da122f1993ffb7efd3a5c34b240dd3db89dddea36dbeb2836d9f8648f8e7cd428c0f948097af753b35f9876059e7702027bb00dc69071206e785f48fcbf81b39cc0343974ac70784a2e60c0df93b40379bea4ad8cac625 AD: 9e14907c3a8e96c2636db1f3d78eb1f673d6ef043cbbb349467f1fe29bf60f23d5d5d1c3b133a8ad72065d822347541c13d1574baf737eb3cc3382fb479e6d5193b9c8e7d2444c66971ef099dc7f37f6cd97b9f7959d46e2cf25e8a5b3111b4d9e2ef906d905f0ee2d17587f7082d7c8e9a51509bde03d3d64338e1838d71700f1b4fcb100b5e0402969da462f26f974b4f9e766121f8fd54be99fc10beb9a606e13fbb1f960062815d19e67f80093360324013095719273c65542b0e31b1a2a3d928f CT: 2794e6e133f6892f23837fff60cf7c28ee9942f8982ef8089db117903d0143293fdf12ea1cc014bcd8806fb83c19570eed7af522db0de489bbc87133a13434518bcfb9cda4d9f6d832a69209657a447abf8afd816ae15f313c7ea95ec4bc694efc2386cdd8d915dc475e8fadf3421fbb0319a3c0b3b6dfa80ca3bb22c7aab07fe14a3fea5f0aee17ab1302338eeac010a04e505e20096a95f3347dc2b4510f62d6a4c1fae6b36939503a6ac22780a62d72f2fc3849d4ef21267fffdef23196d88fbb9b TAG: 457cce6e075ffdb180765ab2e105c707 AEAD: chacha20-poly1305 KEY: bd68ff5eb296c71cfe6bc903c14907f7726bcb1331f0c75f7801cd1b7948f3a1 NONCE: 65a748004b352ba6 IN: 52bf78c00f6e5dca2fc60e2e9a52e827df97808e9cf727773860cafc89f4b64178a19b30b46ed813fe00c8f09b25a6a1b6e350d5b005122934a59bfbd5e6e0c635c84a5226c3f2f7dcf951560f18ac220453d583015fdb2e446c69c6e6fdecf2e595e04fab1b0c506e3c6bd5e4414a35f15021e97f447aa334f54a8f1ef942dec6273511b5668b696fca97188ff15ed84b2f46145cce031c1a7f00bd88bb83d90797edc46161b3fda7a2299173496d73b812139556e8b4eb318078b9eb2ae5046e83b79dd3d45950 AD: 5557b08a5010cbc9f46bb140c2505f68684eb24889324bff44b27234fd7a95a99cfb4ff90a8f9982085b725f78ac42eca6ce7f3314e457dc41f404008681a9d29ba765660de2e05bb679d65b81f5e797d8417b94eb9aabbd0576b5c57f86eae25f6050a7918e4c8021a85b47f7a83b4c8446898441c5cc4e0229776ef3e809cb085d71f3c75ec03378730cb066150f07e60f96aec983c0e7e72bf6bf87ae42228dfda195f97855fcdf4e6d1c4479d978abcfa276d16ed60ecbfbfc664041335ce65a40a2ca3424df CT: a5c8cf42287d4760fca755e2111817b981c47e85b0047de270ec301ca5f7b3679f4749210892b6ea6568f3a6a4344734a0efc0120ffedecf212d55cbcbb67815ac964875af45f735b70092a8f8435f52fc01b981ae971d486026fb69a9c3927acfe1f2eab0340ae95f8dbee41b2548e400805ece191db5fd1f0804053f1dbfaf7f8d6fded3874cb92d99a2729d3faaa60522060cf0b8101b463b3eb35b380fcddb6406c027d73fe701a5090c8dd531c203ce979e26b9ced3431e2b726a7244a20d9377bd62951bf5 TAG: 4579fa1fdb4c674cc3cd232b8da52a97 AEAD: chacha20-poly1305 KEY: 934fd043c32d16a88fad01c3506469b077cb79d258b5664fa55ad8521afdcaa2 NONCE: c7091f6afbbeb360 IN: 2bdd1fc4f011ef97ea52ec643819941c7e0fb39023c2f3c7683804a0ddee14a5d1784a5246966d533b3538edc7d8742d27061c3cab88df0318ab242102de3a54d03632eeb871b72c7e8f8065b49f4a91e95e15f3f46b29fd76b8fcea0d23570c5530e3bbb8a6aafa9ae32c1b3eac653c5ed5fdb2da5a986075808f6385870c85b1913e26042a9d8e78f5bc2ea6de5a64f8aeafa22adcffc7f6932d543c29bb3a04614783f948680e433a71573568d2ce984d249fb4fc06a9f358c76aa3e64a357f4eae924c1356bd5baccf7e0f AD: f737dd85638eb324dd3891219c5eef7c2dd053cfd055d447a411eba304a4b27dce981d112c4540590933c153d603022c91ebd2b4a58069d27e6ca17a462ef822ca41bffa80b43a68b1b564644cb3c5a7f0fddf7a13a30ff24437fddd8ef93c6f6f205d054f81890d982bd4d4ece0b1563677e843fe48c1f54e9a57ed4da66061482712e710a401073be5080d5b8b96525bffa67de5af31d50385fbbf1a87c21bf0e0a1fdff69ec32c7b7103e0b8ee6c844245e0fc84b9f89fcce62966cea68e2871d3b82e8df424c76309fc88d CT: dd13fbf22c8d18354d774bcd18f7eb814e9b528e9e424abc4e3f2463195e8018576565d16ab48845d11c9277f2865ebb4dc412fd5b27078f8325eadf971e6944c66542e34d9dda971e2aba70dbd3e94a1e638d521477a027776b52acf90520ca229ebc760b73128879475d1cbe1f70fc598b549cd92d8a9ac6833e500c138c56474db84cb3d70b7aa4f293a4c2b4d818b0ff9fd85918dc590a12a8c0e375c4d98b7fc87596547eb960676aad5559834588f00f251a9d53f95c47af4df3c4299175d5211779c148cfc988a5e9d9 TAG: 476616ea15190c1093fdc4a087643cae AEAD: chacha20-poly1305 KEY: f9f6eb9ad736a8f66e7459fef5ec2890188dc26baf34a95f6f0384e79f5c6559 NONCE: 7858dfc084fe4b0f IN: a644ca6e7cc076e87eb2929fd257693fce0f6fb64fd632f7f07c648ebd03696c8e262e6a810d7b7c4e5eef8c65b5323c99dbba50a70b4a9e5c2a9e7315973cd67f35d8052ce9a85a206416dd3031929f4f929b13d0a5fb10cb73c65f6c0ace019da146b51c5274a099f44e3669d26add6f2ff081e886f3cf952fe0dbbe6b0534c23e307574bd35fbd657f5fcbd5dc19fb382a1dc0a2dc8285a0350f71554e4c601497749e35567dd4a273cddc9a48ce53a5f1d297fd8baf8d1b9feb35d9151114345abada4d90db947bb9a743c175f5653d1 AD: 2048d1c2ddfb5ec385b201832c7a993f229ba72ec16d6ebf723ef0c5032b9966209a9e8a63151b40412e96b82f86728ea6588c7e8e11ac71cc8eabab8c4b54de866658d9c5011def61fb3dbe4e630158a45ea41a2ed55ebd1efb1abeda7637de6fa5fd2f151c6d2f385bf6cd002ca8b4a2896e0d65944ee913e3c784669dd201b1985ef3577f7f123a5f9bcffa176c8f557c4f729133cac518642f27d9b22ca9b97faaafe5b669a10b79ace4a7d5727df146c77ce681357d69f9c2d65b4401bd73cd113387e3b3a05d897adad7a24c485e7b CT: 4146faffd7313f5d9f625370d20413cc62ab65f4acfa3c7ee1125b937dd7a39f638fc46c8ed004fb525698de5d8620ec153435571817c3de257b0d0e648ebb92940c86a98262d54e764f28cbdd4f7d9bea970291f2110414f62064d7229c6332236c507b3dac742e651d85a2a22fb243c0cc7cc2d016e5bea38f33f9a9ce048944a5fe8b078d71d23168e12dfe5a0f0b829771edc7073fb96032b7be471337a37aca0cf7c0cdd543eed686cd34934717fd79a3f18492eef72f9f450b880aa7e2e1b65e3b04c22e72301338b43aa32ceec2e6 TAG: 10ffaf2be316676da02d7473a9df87b9 AEAD: chacha20-poly1305 KEY: 29b19636cdd32507fd98ec4ee26caab1a917646fb8f05b0dc01728a9f4a127f0 NONCE: 06699d245916686d IN: 5fdf913aceab1d6dbaf7d9a29352fa8a3eb22718043a79cffa2fe8c35c820aec7c07644b8785dcf7a433b4189abb257fb12b06fae0662641011a069873c3e3c5ccc78e7358184a62c2005c44b8a92254958eb5ff460d73cd80284d6daba22c3faba046c5426fe8b7cacec64b235a8f8d3e2641e5bc378830594bcfb27c177aea745951ee5780a63705727ef42c4ad3abf556d88e3830f3db6b09e93edd09485cbf907f79de61f8dc5cb5fb7665ffa0ef53cb48702f6a81d8ad421cef20c1dbdf402b8fafed56a5361b2f93f914a2380fdd0557faf1f4de AD: 39116c49cc13adb065b92cb7635f73d5f6bf6b5ccbf72a3f65a5df6bd4a661105015358d9e69f42e98aed795e8161282bc113058b7ef3b9e23fcd8eeab34a392e03f4d6329c112cb968385ec52a7afc98bb8695785af6b27b700973cc952630b7247ce226b4fbb99b8a486370bf6345d4516c52c64e33f407c4f2d1ba90545c88732d98bbd97972ac5e94c694624a9b3782b0099824651cb7567914d25b3e13181a791dbcd40e76e836b3350d310a52151bf835d3c357c9871482c2928e8404c6e533406d4d6fa8f63366f2c4ed828141f1ff00f01a536 CT: 01e237220b619054a1f3670928fe67d40484b5af40fbd04d032500aac5acaa3b4584dd99a58c390627636a50de5d744f76a56a33205f9e3b00e16162eb47ff3333e1e208ca200f1a5338a86e17bd92dd2d16af8bb022a7dc05b923d019e05247f1a0d0b4bfcfce58dd6d83830705707676d55739abee89fcd5cb94b8fde006a5da02df64b00a467f45970b5ca440f22319b9735a55d454b9fba0588fef0c59d3d83823eba6e0601a96e10233826c5adeea6b2a51d386a07a9e047ad405b23d4c3d89f30c31e3199f0c8f927bfac43ceea1f969de0a8c0f TAG: 092f9f3c5d4f2570c9946c87967f4579 AEAD: chacha20-poly1305 KEY: bae06b9b5456707551c7b0e207aae02a19b4848ad8ca4ce40705bf8c856a6e52 NONCE: 9c27065c3ef2d522 IN: 50cdd88137ff428a88e87b5845be4924f6387537bb5c0b654c80107ab5698db75b2e131848e7aec156d31aed0766d31c379fece4095d38264c6d5945974d25f729c3b0ba11ea853e9cebdb6f03bb670fce08adff74d0a8f02d633fb34e0fb7337a8e66e1c12084d914fb6173b8105684db822752c6751a372bb16690284d661b8b8bc6a6dfbddf45ebc2219596f9f2f878c118df69030de38b4d99dde43b9b9e20a3dab691645dd518342f49b06a0fe0a397adf261e99f07af5b0b3798b1022ba0939c42a54d3b93641cffa3c2e174bce9ab7ad7e7c7924308d1a77a AD: 5d5590db1bd316eb7a0e30e4c7a6dfdbef9d3287fdb8d824389599c3c2ee262b2192eb5b9708e66e22dbc7eca83fa1a995da3ce64c86fe5aa08b826d476dc439497e2d12e2702c63c8d27aa7f09fedee816dc8bffe1351d53271a34d4292b613b7efcedb7e3cf3e6ad389eef12471e9e20e38e7ae22a323abbadfe8f2e84271bffb1819feb4f77b82843cb8757cfae293631bc6d39669107e7015c85d7343ffa6fc1bbe6f5ab4de30cd752a281e03061ea89de2a3f5e90e20da22fd6e8525c100738667f42212b2cf45fcb23bbb54b21c117484b22c6e514685314df CT: 66b7f69ac49fab4e5975aeb6fa9287d8eac02ac312c4de78f77f59da16cbcf87274e66801c4b862c33ea79cdc76528862bb2956c06db8b8acfac4794ebf39e35ac03cc73a4351a4ff762f681a48d6f25cad36e2814c9b5c40b9ae92509e58429106847789454d376836936bebc7a80e6c66e7aa52936d6b361378a41f849ad4e48f9ee2d3e92217a908fa8eb35736ac8ada7d32ae05391f2d807be3512543c36138a5fe660dd4cd4cd184bb43b6ba6bc0bae634e2fa9669304cd510ed5103f630068ff76d3375738de60a381842b421477e25a490cdd6894b2704125 TAG: c9998a677dfb0e91924aec9de0afd585 AEAD: chacha20-poly1305 KEY: 2cb374cb048c168f2e43597f028d9e73cade1b458284ffc260d4fc6b9011c414 NONCE: 9fb909169bc9f4e9 IN: 39eb929482784b463546f5d84f80510f2019923d465b99d194246d68c7ae343f91971d8f7059cebb86aa5dd099289aa648248b8c5ca04e66ac5e9bf06776e3883495397618a0227f035666806e636836b47d3d2d255a49db79866cf00d9ddabda259c4f968a1e01e651c7811cebbee2ee71803ea1d9d23487eb221f2d9555756800aba5e6abbefd6fb72b3151cc99ced599cd86df2a9b1ce94f89f347eeb124d9e7f0d9cc48d3dedd819e6d3dbac57ecee199547b266116a2035c9acc4c8ca3271ac74952372897c4a5f2cb84e2d81817fec9d6774f6d8a5b2021684132db4fca3 AD: 0c7bd4f3a30ee944ccf9489181e6911684dcffad4593a9b65a67dfc80718c69b35897d01281016b7731e12c15cad8482e79458e08a755622e3f3f22a23ef6c8487a36ad1771ba06c641f06f85de0db3776cc6df06ad8fe3b4d60d58508de943083f17cbb9dc0d390ac94d8429e8c6fcfe063f424fbde0f62f6a7f91a626d195dc498a6e69bd93109c4e9ba13e7330aba456d710a4b0cc279d4045660406e26d61dff70d4a33c4f1052869f9248024e7a0f85f1effb32f6f7ccb1f860f3ef04e8f7b29096e6bcf9d4b3e0ce703e9bf228fdf515c2ff9cbabd16987be0f9babd3d8a CT: 91ddadb86b7ebef798ddaa59da51d71316fcf6c9678143178227d778750dc9827fc6cc21e605c505023e6db25849df7fb6fc1ca4d223aa215f8c85b724643c83bf8218815a9f9e2952384e0ca6a80a3760b39daf91a3c6154c4728c2371fd181fa3764753d0b0c23808a82cd8f0497246e3a0f17f8906a07c725d2891ce968a9d432c2b102d85c05510b28e715bb60d0403a77490e7f18be81218bc4f39287b9bb09f50227dd2f55e4fb70c4438da8ba3c8ffbced87d90155913faa9979fc57e6cbeddfaba3d3ab4163c0eebc7d94279c27d3ed56338893dba542eaefba30f8c3b TAG: 728e60f8124effbac234f70da925881c AEAD: chacha20-poly1305 KEY: f0f16b6f12b3840bbd1c4a6a0811eef237f1521b45de9986daec9f28fca6485c NONCE: 7ac93e754e290323 IN: 0530556424d823f90a7f1c524c4baa706aad2807e289e9479301e3e7a71f2a5e14e6232ea785f339c669af2e6d25f1d5a261096a548d23864945c3a589b67b09b0304a784d61b42b2419139485242e0d51fcbe9e8fed996d214de8717e6a71f8987ccad65eb92e66707034a5ae38e6486e26eb4374c565aad5df949dab209f7f7bcd8eb6fc52761a26cfe5d01fd349e59f4042e6dbe6b232f9301b971dee121d8aa1e62d40f043a42f3aa859d867eb809b1ced5ae1ec62cacf94a69fafd0631a8b5dfd66d855900fb295eec90ae5fcbf77beae267a79d24081bb322d8c4e0630fed252541b36 AD: 13bfcc17b810099cda31ca53a1323db9b07633ceb2088a42263a4cbd6a4d47978776005c9a20203319c3a3ae434e9a26fb541047dc9df38dc36c095267272e203d0b24d119a70a7e96041b6d82b7c4d5570e1e4a1cf2f6e44ae63fe005a1f5b900778c482f7bd89e2e02305e35b8f61b7bb2c78a13aebfce0145d1c5aa0bf1d10d23616d5a3a446de550302f56f81dc56fe4f3700f14242688d9b92d8a427979b403c8de8c493a2cde510eaf6b285e6675b173aa0314a386b635c7577d5aff0d868a0cb3f73c8d2005f8c7c9dab5a060ef80102c9d4a4af988838afe87aff04c0689e8c3c7f9 CT: 2c14c3931e98e84507c4c165c2ed47ad4a178f0e216cd7ac2453bbbf9f85dd06bd8ef54a9ff1fd3dd8e0cafb635d8f2de861a0db5b14d03f17aaea8c89b3010797c71c13a0e666899d7ff6e53c4f08be8ddb3e37688b5afa088079b6c7519b833e16560073e699530302028a3496e05edddec01a23a4c7983956250e8d9e616f7b940856955cde81c1efabf6b7b92f153d03f4cd17e7f7d2907670cfc84d45c1d7936775a3fce47968504278ffaecacea0871b227f250e2979516f6fa310fec0d8df1af7872e5a534e82870aa05f43ef0a455846b93ce938064fa33e92de262e4156dae56775 TAG: d95d73bf9aeb71eba9042396f3725424 AEAD: chacha20-poly1305 KEY: 3792943c0396f1840496917ce8ad89608385007e796febeea3805f3f4cbeccf7 NONCE: 23b2f9068b2c4c85 IN: be6b67eb943ee7b5c785cd882f653e73a8f75b4a41a2a7c56ae5a10f729caf39948fe48ad0e51240e2e7aa43193c7ec6ce7f4909fc94c9f99e38e6a0ad7e98eb29c5c2e61c99e9cbe890f154185cec213a74725d23c1a4e4d0cb9b1a36b78c87e5eee20d2aa29aae80d4759eb0c51c5dc3a95bdbbf7e14eb434419a6c88a954ac03d0c98739f4211b8732acd71c297f578b8cb64ccac45f7235ddc7f2a3f5f997525c1ed39dc550126cdf9cedaf55425489085e91b170be6205a5a395f2dd4084a3e8dbc4fd8b13252f7effae067b571cb94a1e54aba45b1b9841308db0cc75b03cfce4ddafe89ce20f2d1 AD: 7eb6d7b7bbaaa3c202a4f0f1de2263767169eb4a64853240d48c0f8d5d31b08d5baf42977614a57aad99426cde76d242cb37d2956d8c77dc4fd62a3abf30e8ac6cd58c8ef35e67497022960138c57787818892460f3bfc16e37ff388b1edc6ce2bc53c22717edc7a03d4c78b0dbbe9121c7fd8a3e3993b87a4fe389bff13bdae3b349de0b6db561602c53f746022aeb4483c723b67825042f4af20b7dd1e6031cf54215266295c524ac8e1370424c5c5e607fb3e23e97c8eebe64656775edf616422a8b974e1acf13ab45c9a367a7dd9b2d62f48bbc05819b65eccb813ca813f57b22ee4c280dbb5a9d8d5 CT: 0b316ab2bcf5359900fa4082d5d253b49ad94b70e3fab544f98bd111cbcef6766cf953deec08cae1f489fe12f7acc0032db8a6b0c0eee0c206ea5fb973feaebf90f690e840094db5e13fdd7157ba127368c995b426529435a1bcdd1f14ce9125b8a0e4c96b6ec09e3c36a180adf81941c002d19c19d53c2009be803b987504606b7d43bdee5e0b32ff23c466b6cccfcd0d4e88fd1332e73712b5ab725c1a383e584f34f80daff29d285ae5e43cf1d0cc7a828e75c25daced3a581a93d7a50f313b33f38dddfaa23cd5b9914797db820ee2400d52bf5fa982277fe9b5881ac42981633b3957b0e935051828 TAG: 01973ee2e81cef22751a6a8831d752ef AEAD: chacha20-poly1305 KEY: fe4be6054773f634356ac328591fbc6f833b0d1beeb38dd5b6feb7481b4489d4 NONCE: 0b3f16f898a5a7d5 IN: 76ced1ade6d1ef4069afddb32e7432d4ff2fd06685121f7b16464e7a72d365744f547d2ccf53486310e38b42d8bacaf711e54c5458d2d68c4dbcc8de31ab6732f4430e88a64565f5b287640775aaa2af1cc461d3e415bb275c6246b1b58517aa72667eae291a2982eda175d1b22c5a58e6fec2b3743d55712f201ca24ba5c0ae8c25724871b2ec2fb914a8da5a52670ab9b43a83b8568ce74db5c634061cb80530c8070c38b8f48c33ba136cb9f2158ee7eda8b65f2192fc94d1291f182f101795b7190c74b319d2d3e02a97c824d9c9471a83797e4936310b207e3a1e0bcf75f7c3e3ee48a747641cdc4377f2d55082 AD: 834cd775cbefe4b33a3ca53a00c06a3c4a666983e4115a029f15729460daa45d1505e95172d3695625a186b28b8be173a925af04665f209267b3c5123e8be13da447ee1ae856bb0925f35aaa76e04a7bca8460f76c2024de2149f38a8cfba81694b854885d72568105571b6b213a0bc188a44cc7fe13153cbf261401b238cf12a95e23cb56f240114f16e2f1e3a514615aab4449c0c49e4d900b0e17d1a8dabb53d43dca32fa052d576b73dd9b40856b515d6d7efc2a5c17e0ebcb17bd59dc86f22ce909301a2652f134e82ef0e4519487ed12d51536024f2ae8f75d937c42d003076e5dea8de0c684cda1f34253d8fc CT: f8defb6fe95dfec499b909996a1f75a198a90e4d6c6464d00a357a555311c42fe92dbbc4b79c935e4f0b1a95e44fdbc1380bebabca28db4dd0d2870daaafc38ef27908c3509e945714801cc51f1a07b2430c74fa64f2a7c2f7fd1551d258c9c3be020873fc1bf19f33ab6c660911dcf2317195d0efee82d20ec26d22611f9cf86c51a64e28b3a1f344500018e0855c88dae3c07acaeaa10b60388484dce93e16e6e1a6e69e899806648a92568c8780e9f4baacd98cbb353ac2f908e775d92303cfab843f15be0e0c322a958802fb1a60fcc7631f151f4c2b8cb965d2d296acef250275a2fecc0cea803ce7c058b12dd2 TAG: ade515091930dd7861b27f78a87ef60c AEAD: chacha20-poly1305 KEY: a288b11ce5382ec724ce4ab2d7efa8e777e91ebd04367935e15f9dac483e9596 NONCE: 874144dbf648b325 IN: 4c9195280a79a509919af4947e9e07231695fd7c5088539f23936ce88770ce07d9ad3ae4a463b3a57d0634d3a77ceaadf347a334682b04be8e58b8e86fb94a1f93255132b8cdb0df86f5bea354eea4e8315fea83e3fdf6e58aa9f26e93caa08e5e2551a94bd916a51fed29ec16f66800cda6a0aa24ec308bf5fb885afba272685de27c1edcdd3668048ef07b06e90d464a8aa28664903cac45e154e8e1e39c257e1ff506b9d95cef4f300bb73b899e7828602c3c1d290b8cf55ee5fd72ecce9e6efc9293aebf674a70e2a7673e75629c12950622dff71d3ec0992e57776c788c6927d30b4e24b749191c3ce8017f0ada6276e43720 AD: 04abe8588c8c8c39a182092e5e7840442bd1c1149da102c4ee412bd8b82baa5087ef7291b5cd077c177c42770b0023e0e462b06e7553f191bcb0315a34918dcdbffe2b99c3e011b4220cc1775debcc0db55fa60df9b52234f3d3fa9606508badc26f30b47cdb4f1c0f4708d417b6853e66c2f1f67f6200daf760ceb64ffc43db27f057ad3ee973e31d7e5d5deb050315c1c687980c0c148ee1a492d47acfcd6132334176c11258c89b19ba02e6acc55d852f87b6a2169ed34a6147caa60906ac8c0813c0f05522af7b7f0faddb4bc297405e28ecf5a0f6aac6258422d29cfe250d61402840f3c27d0ce39b3e2d5f1e520541d2965e CT: 0afce770a12f15d67ac104ba0640aab95922390607473cbda71321156a5559906be933fb0980da56f27e89796eaa1054f5aacf1668d9f273cc69071b9e8e22af6a205a6a88f7ad918e22f616bddbb07c78913c7e056e769e6fcf91c7600c2740212e3a176e4110cac9e361a59a773457064d2dc652dd115d04f1c3756c0e1d39f6737a16b4508663e310934c49c58058b3c7b9af7bb2334c8a163608c42499658986927cda365e2aead3ac29de16e47e954383ea566f8fb245a4e5a934c767bb3bf7e0eb8a477fd0e1f61bcb238462a0d19c5cea9293ca58ade76829413216a7882cd2846323046694f78cd8b0347792ebb75abdc1 TAG: 973e58b1b8adb176a6f1e5c963bfdc5c AEAD: chacha20-poly1305 KEY: 65b63ed53750c88c508c44881ae59e6fff69c66288f3c14cfec503391262cafc NONCE: 7f5e560a1de434ba IN: 845ef27b6615fb699d37971db6b597930a7ef1e6f90054791eb04ddfe7252b5f88fd60eba5af469bc09661c0987a496fa540621afeec51bebda786826800943d977039dee76235248112ff8b743f25ed5f3cb0d3307f5e118d84fdbb9c3f5531bc177fb84549c994ea4496c65e5249da987dd755d46dc1788f582410266a10f291c1474f732183a2a39afe603771bb9c423fe3e8906f2be44a0c9a7c3f0ceb09d1d0f92d942383a875c0567c7869f045e56dd1a4d6e90c58d44fe0c5760bb4fd01de55439db52b56831e5a26a47de14249453a4f8e7da3cb3282c6622916197ebfaad85dd65c61e7d2d3ba626276366746f396394c1bf75f51ce AD: 51a3588398808e1d6a98505c6e5601ae2a2766f1f28f8f69d1ccbcad18038c157b41525be58ae4527a073748b7a04809e52a5df0c7988417607738e63d7ead47db795a346b04e740186e73ccad79f725b58ee22dc6e30d1f0a218eda1791e2229b253d4ab2b963a43e12318c8b0785c20fca3abcf220c08745d9f9602f0ece544a05736d76b12d249699c9e3e99f3f13cf4e5dc13a04125c949a5b30d034b23cb364c8781964bc6c30e5e5ca9673d517ef5f35965d8a8cf1be017e343df97b6bee37b30638b154286d1f36d2f9a0eaa23cc484eac5a05b15d9efc537d989dbc8b3106c0dc1a56e97e6aec2eff54a82cf7ae9df2af46b4c860f83 CT: 027b14197b4012256b133b78ddc94e72fb4d724fefa4ae329f5a5fa3fa784fe6d7e1e805e3f7a75557de64de506d38237b467fa577efb59e7cfe2356bed6655c5aa4e238dcfeb75c16549a0917268768a96acb5e20546a1fb7e3a7cff887f49f2cd7a135f72a98a779150f3207bf733e88861fd79eadbf77fa3bfe97bfe8b6a991cb3bcc2cde8287f7e89384846561934b0f3e05e0646e0e1907770df67a7594161a4d0763faa6fa844080932159999d528ee0558710058ce16f97d13ac9fd9bf5044191188bbfb598d0fafbdf790b61ce0781ecc04218a30ded45efd498cc9ba03562ed2b4a993ee98876b3ab7a9bc07829f1c4ca6ead98c06b TAG: e4d18a701b8308697b5e79141ed783c1 AEAD: chacha20-poly1305 KEY: 4986fd62d6cb86b2eaf219174bec681bebcdef86c8be291f27d3e5dc69e2feba NONCE: d08d486620ed2e84 IN: 3a22ad5de387db4fdd5d62a1b728c23a8dddc50b1e89f54f6198b90499f9da3122ebeb38ebf5fdfe30309734f79aff01e3de1e196b35bffa33bae451f31f74b8aec03763f9e0861a34fe5db0b40c76e57c7fc582bfa19c94ee25b5e168270f379bf9f8a0a18bed05de256f8f0dd7c23ba2ff1c7f721409462f04cc611ad9bd4c3c9acf30742acfb9518a6375cbb15d65a1bc6993ea434894f93d4f6e05996ebc1bd56579296309a2c6b8fde95072168b5fd31927c4c0abaa056bcd16221d5f220be47591f43255013a262dce439817f534830ba82155347e5fe3101f8011b89365a6568214ed0661914e8cb3431d6c8f2347dfc1209a3eca4aaf0a111f47fe AD: 7dd3f656a03c001b45ca0680bc3ac9d68c6e96b591d3c69eb8c65e489009d845cb331c98b82e627e06d5bf01e74c573df268c2386f12628c019951d42f55991ff20d72a7b2c45f41d0be7af428c92f324aaab8df70d900301cdf09a3d93eb711c919d34a86fff9cb078322ee2e0ad48dbdf3b7884f0f2dc5c36262c59bcfd75ac6200f59c6fcd0ce10ff5005fef5df8f0432377dfbfc1db8f559e27e1aeef3380ea3864867d36a25a18654779a751586cad3b8a46b90864ee697b08605673b8d2123433c020a21c4db243dde2420c12fd4d54a2704a0c8c376454a1b5e80fd6db89aabd56d9b421f29649e474824dfa56cb5c673c504d10be52b53751709fe CT: c40180afd53001663ff4834110f56e6b0f178cd3c0e7f7de5d0089ee41d8403ffb98e84922706544a344d7e2625b12cf66b9c966f9f57d7b94e3e4b34e6f0aaed1763ce012782e2f5e1682e6c343fc7961fedddd0919d0b910e9923c17e36406979b256b85aec24ee352f03b48c1302eab419c83dccc5372cc059e9de596224fa70098eb32fc9579e97917b923914fa2efc30ab29b457bf14e45583b3771486bdc0876f3ea6e1a646746c4f8c5cb2641a1557c8473e6ea67d4811a67485ae9a678ff3a2408ca845c3b51957e189eef47dfc1d46bde4b9d754d7df13f828ddadb06e4ebddb5f0dafbdb28de4c5e6078926f20cdf9e97ecd58e309e640f74f06 TAG: fd5e29332832a14a31a9ce2ca8568498 AEAD: chacha20-poly1305 KEY: 7d28a60810e43d3dfa32e97c07957ec069fc80cc6a50061830aa29b3aa777dfc NONCE: 47738ac8f10f2c3a IN: b50278ae0f0fa2f918bb9a5ed3a0797c328e452974d33cbf26a1e213aa20c03d0d89490869754abf84dbbe231d7bccdced77d53fd4527356d8e02b681fc89a535ae87308bf7fbc26197a5ea85bdb3aa033b8da5cd197ea6d72f96f63b03f4ecc7adedf399a5043776cdb32c08f30b77f34df85f8adb8e02649a04b020b03e17d445ca63e4ed73ae432c481392e031eba2f9d2f7f981d1e50917822bd6ff71c239d33444ada3523a59dfbce5457eadec1ab926c9e6c5299c7521e3f204b96901a712504fcc782e8cea80ba12a7f7e71cec3d0871899b6ca059061da037715f7d13fed01c9cade1e687b4fbb1f4ac4b040db3b43800f112fb900e4f772d61b921cbce4da6f AD: 324292813b7df15bc070cc5d8a4bf74ead036430be63abc43304cf653959a24a91c7de5a671c50fa8a87e21bb82b069999aadfb6895d8bda4c3083d17b8ca55b9ab1511ed8c4b39d8c28c11a22ef90c08a983e3fe2d988df9e02b16a20b24f39ddb28429625f511db08298c4dc321f6c268fc836a6191df6232f51c463a397a8d8b33374abe94e62c0f5c322387e1fc4a1c1980a04a1a3c2c31b32f183a11c3268c6dca521149dc16af120a78be6627210e8ddbc44472bc24d66ce3681c7579b3d9a425212a704a4f5105cb80f0d18ee860953d10b59c114826779bbc368d7a0eece9f223e47cd8e5fd453607d101d9d9c2bd9a658d6520b87d7b4263f6d845a524a36e4 CT: 2c217e969c04740a1acfa30117eb5b32dc573df3354f4cc3bf8f696ff905f1e640f3b2c250473b376622e0c9bda13b94640521be1ef0fc660b4c10dbe2bfc093030753e04f6aaecf813b43b61f960455974b8bb8a9b461d1e8fd3802315e863c00448f24dd38deb90e135493274eb14ccbde15c50dcad734ed815a806be6622492a84cd062e3ba567b909a205a1d0d2bedd40169697d261c7b6c2e0b1f069853fd470e8f364a142c386c439a6dbe192ded5a3d0fbf73799f588c59e58c60249d980ddcf0d9693631cd9b3f972509c3a77123d38d9e267ecad06e1208e3f1c0a69fbca7c3bb1a48fda19493d0f8f48398820057b94120f3ef97d87e9e8a1b301a2534c68f TAG: 1fdd2dcd935f55822bf7231a516ca841 AEAD: chacha20-poly1305 KEY: a76e9b916f5a67b78a5949651c8c3a9741a1bc3c41cdf85fd2c8f3e9a0616098 NONCE: 0808da8292dc14e0 IN: 9c149eeb09345c3c22462b03e49eb4dba6bc98b269b1086d752bcd8eea53b8977b238a04a994baf915591686baab90b79a3bf7d9adb2c6c2e31acd3e72f0813fb745aa5fb2e3da408f78001c9c09bd26a1a2646011b6120aaa2bbacc4a16c39fb5257b9b2ea2ad8bf70bcc9855cf11841116c2767310cf3cd49d1aa44cd505f079761e064d5bc7cea4a7173b086882a77d3fc179efc86fc4db8a373491d2ed81eabc63c950e832db17d09f474d4ec46bde47830caf26fabaa0372b81fccc449c0e19ccd630caf693a7b43bb1c408a54e03f50c44280a05ad89fb6e8f01d8ac278edf556e5d86ceb4b614fb2ef133819c6e1ff6abb86c54a135256204b5cd400b93624d3932e7c2b046 AD: 6aeb7031e4a2e23eea93f05fdc562aa2bf43b8998bea7344377aaddc60fbdb7bcb1491d379ed0cb613ee757cfb66490db61bb431d2fad34b38ddd55bc5b22aa6c4773b9992f34b878c5663f6e8cdb5f80a17f4d312bf342492e48d1ce4c6d754076a634fece61500acf8168d47381af4faf980c6cac2bfd5da8c09b6edb0f543bf0fe02643e38d73fa37d8ae87fb66193f22e57faf4393c007d48c8631a685d520578f8f89db684fb371ea02f3a58b1e2168f0216321139472e0d03b6d90ba8aab65402e1c1ac4f9172a60e27e3d997b9b05e2f672120d6c87bcafa6d4c9b4cf8ba8a82932d92840368fc53dc5b48526103dcab5f1531038aabe89171327ac559b98a3cf4ea70bf051 CT: 9c3faab9261a63cea9477b3269007283995b06ba77ef83d9e693f7e4ee9855550eef94855be39a7a435b6a3584b202973777c7b2482376ba47b49311947a64983b60236756ee4455d4cfada8c36af8eb06b06ba2f6b79ffb1185c89f2b2a831cfaa3855fc1841d8910908be5078352011168a67d36372d851a3217cabf593ea462dcd325cf9a4f67e85418fd5c924e9b92ab026cbee4e7ab1067066cb5949dfc699a68fe539e1abb13cec33904e5207e6963d24f5a0b770613b8b00014e791bfff88f9c25ca126127a2f8d1d1e9794efd28dce98b53e228073faae8d5047530d502184fc341321c3f55fcbf41187fc31262c325b97f519959b6a29b36c71f76f60196bb1457b77c8bb TAG: b45df119043d29008fcef36a169ef886 AEAD: chacha20-poly1305 KEY: 98cd2477a7a072c69f375b88d09ed9d7b9c3df3f87e36ce621726f76e3b41a1d NONCE: 77d185aaf715aa48 IN: 42b31eefdacab0f03ef6060156000c8195adb0976cabbe1a42bfcc09f85659c60b98638401f2d2e2facfb9a97a62926bb0cecaf3af0180a01bfb6e576babf7fc43331937a92abd30cddfa3e450f895e9dd914dea3fafd759c136d685310ebce28ac0613ccdbf30115946c9634b67510b77d0e37f07714b2ddac9d7095b8d4bd887c132c4a9127eb01c8dedb4c39c87b98a741316656f9a8d5a5b0c0ac84789aa2347a5f99ca5ad55cd1bcf98f703eb4b00badb8a8555f38b3b368db8ba7ceea94e8b219f51edce75d84166b5602156ed5962a93a51db73c59d87e906179d7a74a2a2a69d8ad99f323225c87e475d3f771b4a203a2e2b03b458401044649fa6536dfab24d7037807dcbf6518e6578 AD: f5bb1496052a4361dddf72a288e36953a3d815d6876c013f1d6ba839e127f721b052b1f7d8ca20c7dc0386a7d459ebd7eb9fc8cb08941e6ca9ddb980f3115f65bc1928a414d441ae71dcb879d5bfe0cde0562bc37f8fde0d5291ad405c92fcbb860c43b55ac0fe663b54b3d0616aca13a5c82b7b5d34125a05c2acb5530141030e6f2aa0c8322b2c8fa307e7518918e550e9f48921c6168f094d8758e16b9f815fd0458095c4143f0922adb1840d0e685636825a9c90ee90ee537f4b8dceecbc4287c82dc9a00d7e51671e37ea284ee3ca501b1b2596459d3f592f70186f41125739e342c9f6be9241973b1414dfe5fb8cba1af82e679278cfcf95420df0c5364af4d7e72ad57d5c871fcbc35462 CT: 7a3bf3e3ad5ae3ab71fb1f7121c3d8fb511099484b50af7ca128ee0337ed4b828dc4cde0b88dc1e8089101fa82c9beb3eb48fdcf0f5b16da441f5a3fce9a590022af95a94aed6a3e71e505f60f303c78c356f274ea85a55354078530664ecda32c80e77dc20974b3b38f4825b8fbee8c3970769a2f42c5181608a8d7d76ef4d093961b665ee42b9708fcafe2c82d3a307173e2a25ad2528c3bf83352b9265e45b70722d7cf8c9b80826d21335234ee3db69d0d37871c83222365900c96c17a7e9f5742d0bfe383be24d0d44590d4b0f29f7abe0c65daaffb968b3f2657b1eb300534eacb52ec7a6b6f9f57a50a91b1799f491361cf613c934b7f520dc4eeeb40ffc45e10be0a95e76f366d4eac14 TAG: f613b65226afb64c614fe60d9c71ed74 AEAD: chacha20-poly1305 KEY: 2f0f4631ab1c1bcf8f3ad0559c818d50e0af7d8cd63faa357f2069f30881d9cb NONCE: 7d0ced2fdb1c9173 IN: 6516ba1d29357144eebfa486d21decf223da3aa76ec29bbfcbe7f1eeaf4a847710e5080177f7e5a7c8b4752c219b1cc70aef4db861ba67d0fa6222d9f4a1dc756a0ba44e62906f9374a960c16198866d867854d88f528a60e212eb91645787e75685b2e215c0a41990abc344a77236ec0186ba63a664592938cc5a8ac1d3eb99c95ce00e19fbe249263083d85b052d48bfdffc01585dc57bb2a2c6c4a819604c1ec0548c6f0f78dc05e4418b36277dc07233c7532f9c289d6aed0cc6bc7df4fd0a536c497b982e2dad2c30d2db1c6545a845c5dfa83a4ac49ef06fc9c919079d3e299e31b5c3be370814ae5022ae469d3ee55246a41bd0dc4e64351cc38c3c09af0a1aee3b388a6892deff0df3f93cd92d722b AD: 1ccfa1ececc8de1e200d0ecc19dcf67b7c96bea3a282c2bccba61035db5c14776387b8b8f58e5757deb0129d4e5e315f64df354a5985d2e47ebbbeafe0c914f7cf1d63dd0311ace19e69a8b6ff0ab25cc8df0408d22132205e89e5eb679268d82b2913e64e3f885bbf4a6d379b760b94590e3140dd7275ab4713cb56d0b716e2718f11316640cb394802862d39e77a46d0c065af3caf7dec14e887039d8aa8c3d3a8ac1ee06026f49d00b2f59d971b54735e95a51f199389a93a4fc24ebaba1f7a2eef7412f61febf79084fbf481afc6fb6b204084e5ef5df71f30506459dea074f11fc055cd2a8c0fc922c4811a849984352a56a15659b7d07a4cc90b88623638ea00c4c8bc13884df2237b359f2877aa41d6 CT: e580093789ba17ffb46672dc326f09278aca08598d3e5458eaa53e6ed45d5c71a396e35b5ea3fe7b7c0496a734d24f1c75420694be2ff095d5172fd3407794e4b99fd7c374fbe8d1564a048614d3f355bfb5866de1a53e1a51f9f5e8312253cfd82f36efaa1898c850ca0d975ad1e8b0d9597a5a9e6516fe2a3c92efb7495557a8afc3da15b0d3e2ba58f612519836946cf2d15b898320d16a026c8c00a1be2e35f0ebe68f28d91c6c45d24c3f3c157cb132fa659b7794df883d90741fa2d2afcc4f27858e13ecd41b154a35d24947ae7361170060c107d8ecacb393ea67104b60457278a392fdf1794bab97d3b02b71a4eb015eaa38a4b4c944c2bc7cd5e329da4a1ab2937a6af81a6caa5fce752331fdefd4 TAG: 0fd7419c54bc84265ed310a3411a3f2e AEAD: chacha20-poly1305 KEY: a48b9b6df475e566aba7671fbd76772cb0eff0b12499967978ce3e25fac92feb NONCE: 2ccbf0d6c40cb302 IN: 09da1cacd001dce4f7573a065a4406fe0da04ab367a2d87780a2762e168957a88d3fa78f0a4b6978d449026e5a801d32884b6e14fdaaaf864214f928ebc03dead081fee96683ebb032362d5088c4c2a3b1e242f055f2604919f4dd551db777a258cf9da6d95a2bde249247812b9efc7985cf08707620808524d6dd3079b0b63bf0f71ea5de834ccb8b7c6a97125fd6ca49148e866d3134bbf1d8a6b714e9a80fe549c8bfefe342f41be2ba2300e0028f78cefab65274632dfdbe70bf7d655ec4036df561f2d4fc4d56a482bbe2f9f2ae279b3aa216b39afee75e53602de319484db89a51e844f38c361634e474f8f1f01c340f3f3594860d671346449c6d08ee38de22d246309bc7e4a252a29c86aa6d94b5b4fa58904c70 AD: 1c2503d5aa1aad193f0da12874074ea0432bb76a61cd43a3017061514da0759846a0f3ae3a49fdb0b6d29f713de665beacb6568f2694112ca380d13f3c1698316866a7a7f87f1d7503a92176ab84fc08977b46ba664508a858e7525753c45511b3d2f407d5e993c6ede77f13d12975707e5195704970a89f71fc30828049f92f944f3aa93d6a5297e678e08952919beb7eac5919df1919cab3c3da6aa696a1eeab6371f310f7e81143e7d240b0213ae554524b52000306160dd4877bf13ba0f13bbe867da7c7d707f31335eef4cd942938ac890a0829ec66bd30ae01a2188a6e5ea0f17cd7dc875e17f03c0ab5dd18e36db8a1fc1f72859ee046b62368f168b3bea2234e0432c07b7d8e1b9277f21e692c513b9e816e6860 CT: 7d35cfe4be56bd6e0e09dedcd01735b915bc1891a4d1f6a541abc4bcd0ebe89dcb8e365e5813742e8ec65777b6159422fada747da99394252baf8a046fc1b60ad79755f545f4448627b7acaf403000894f5641e78d3f946dfca29ec617f0660dcd6e8d8827e67e1022a245c595d86e60fbd176bf721b171bbe5ecaf4ae671b9f3dd3920146e6ad431bd8fc431820e19454b6ca209723d80fdbee187fca9c937c979206ae97be55f6ba7366a5608770a11d537396485eb0a66586385f4d4cf3905d1fc90831c3e136d5d513fa22be285193142994a3ed477145bacdcbdd791e8b3b88b0d4f1d18b27382550a818c4fd8884bf36f677c6c3ff5677406e510911e696af75e5b3f859bef699bdd16e6215fdb98d874025eada50 TAG: 2aabff35611b3e0013f6ae0df130799b AEAD: chacha20-poly1305 KEY: 923d4b086b9e43b986f7b65e4cea6113a3d8aabefa89323c5e4d5b6f158bb7e0 NONCE: a0f73297b87f5deb IN: 21435e8d5c8edf0684f58c2cba4070c10b4801adf46b6c4d322eb3990a38a9ad338ad704b9df6597f3e68d66cd5b56290c8466db2231e56d6bcb9c44e1bd081f42ca2a894dad369df2bd0d2c63d6c881732d6ea22bb22b5bc9a62eaffa1b094d0845f6b966d2cb095e7b3b8bcbc15e707449d35c8df4aea30c3b7243e977fffd59c80f1c5c9af4bb5a54b9c786fbbe8d21b2b906a87a786caed841a34a3e0cc0ac3209d83c58afba19edd63622dd261532d2cfb0b49d527d8eaa0887a087f5129d897f665264b229f860363d71a88b7d49c8dc6360182b357b0662391bb41337f46010ac32b9fada2d60a2efcb99365d3b27b7ac396900d1c821d0df8b86cc9cc1f2673259a33efea610bf8e1d00d7e9db2afea21da8f58c55f799999d AD: c853a8b39c0dc597d562f123cd221e4104b65423a062a4f4ba890ba344feb84290f61817e23330c365f58c3583ce08360d3c1171982ead5496d525ac878f23a57480a6ee39d4e65afd6268245bb982a2545fa1195427cdbbcd404cdad5198f55cce2a5a028fae435f71b15921d066e8d43766c32b2f2c3f57c0674e129607dcd3703eca529414adaee79d81fed432153cceb6f3fc53404810d8ec878f7d94be5d379d0e0e1aa9bc404b4b5d396038a9d76a5ce53c9f3759b8e50fb331858ca58cee81bfc3ee58baef5d19c402a3dc8b36370ec1ace5a4aa2527fb94b4f933a4ab8ccaaf6a5af5a779eae5667c2a24ab027e781c8d4f30c377aa5885a2fdaf6507d18cd824a847c35368b4ea984d2c3c3824a5b8ba3042e1852504a21a3 CT: f2e21052eebbb86a4f5e803360855d8632aa727dca6f5e79dd74d7aff106e442001928d113005b030f8446f8eff2ee951db663978abe43090dd5ad2c51ba97a0ecf988c607d95e486d02524f690fa3c28d5c48c1f75c1f555e7b43fe7e46f2ca2b9fdb408ec4ba18b6cdde2af673183cb7b1a3c23ae77eddd4cac75e1ea14743fc571f8d31ce2e96787524cd48aadaa474181c096a032184574ddc25a6e0ac8441c212bc36298708e33c963ae931e6c6241d1affeef7b6ef759495df44b6ab647447693cf703569e69aa72f1def9a342b8978c1edea9703a421ca75b92cac4de14b88c693200022b8a2ed22b1c4678b99f4d695e080dd1196d7168e14f0d0f8ff880d742e97b9f6d00af1f7118e10b77c5ef3ea6c52f84a20fd6ea46dc TAG: fa8ee13400fb3f63b899df582f2fec45 AEAD: chacha20-poly1305 KEY: df73adab2768559ea983cce85453fe81d79be3b3c57f202b31b94d6635cf2e4b NONCE: e7a87e6bf6b5a354 IN: 0032a37abf661faa18c587fd2aa88885c061deeba81105dd221969bed5d59c7204b09b1a8c4c8de3b9f748c7fc70626ebeaca060233a57b102221b1bf0f3d9fdaaad3d2b1439c24d08f9c67f49f3c47128f92ee530abf4c4f4573bc60ae4b38109f55bca3ca9e1ba9f9fd6e34ba0d174892977a53356e1f5c88c614fe3ff3b3dd0818e7a2285412e3b37444bbe8a80942efcfd03958809a6966cda9430b2f0c9e552f4bced6e19eb3e85fc5758bd7b588297ccbed37ed94c3adc8c08ea8b058462aac9d57a939ec711bc4ecfec944d2b653b7cfc7b02a65d7057c9fdadd51b9da8cc4a3c68dae9da8b9c5319c1a2baa3d6c891c5ac4a39461484b5a01abc64df447ada24c04a4363e605eaccf339a9aa515e724206206da6d22bbd2f52e64cd7c895 AD: f833e5ab4f8bc89167f80f576b1d6b22cdd0e30721f5f735799746cf645b6eff531d4c7b03584f3dfcb73cbd35ac42736216dc7f0de098a4f42c61ceb4b227ee288e47d697a0a76afc762f084e8fdbf9351c28340c324771c109a469341ab10ca10483ed2af5e878d7d3dc2bced2f72da3d1a25852b103ee9878e8158eb4309c1ce528f3a178ace153b6d3ae0af0d577cb3cb1540489e80427f792217ad8a09b84f027fca7ceb651b4264e98e94b4cb8a37b133390897233e8ba9103628d05b9609e8552c4a4b11e3f2fa8d56af36957390e88cba44656be3edace798cf8cdf7771bac338a256bc3cba6df97728f222f423ca7c6d149c9372d66163a98f79a234b00d4b75fb2ec860dcc2d1998105e4b9c01d68f079f3e0aa21cc534047fc7b858f8 CT: b842eadfdf431c135bd6581d3eccae54e2267d8890036aa33dfe2d2d9715c44625441210a3a0d666d708d30588fe851ec36e10d8fa3584ed77b095149494b7c54379d62c8935e1d2b9a8f47e4759ad0b3437fdf2cc2fb6c5ea25ad10e0bdc9dc5b0517fc237eb783cc461c46665e2b1d1a5b8008dbf409ea2a63fea0276de23a32c99d92a498807a0f95e208fc6262321a78aafaf0cc3f833fff37bd4efa66f6023a25cdc6702cee3912799563d908a5183c9956a06aa71085d855dc7c809ed6e2889592b361ab3ab39060f8e419152187a794a19c2a1128882201900ea2cd597860674bf78d9720643df8701676718fd201baed4935a88e50558daf86edd08a9ab227ac7afae55c974b68de8dacad4a4d79b13ed6dfe74017a4cb9148e033436fb6 TAG: 184095b7a8190abec08bb72d19eeb103 AEAD: chacha20-poly1305 KEY: 55a4be2448b464c2ea52a2f2664ed6aba865c14ea1fea77f4689331fd105c8d4 NONCE: db37c0a405b4626d IN: d266e66272e5d3462081b004cb42429c8b9741e9f678153754d726f6f9aa513464763c5e793b482fe512fece97585f1426120d4cefb3d0a8cc0a8db4bde93fc72c78f44d4fecca14650c660d3e285b327e7cdd813063e7e867b8a2d059a41bab70432b7f857199894da90dca3fe5272bae1ec694a1a07b60b05df275784d4975637e4673109f3ba846dfd1a048b202ed8e89973be608b91ee4743b1e759900f1443038951fe6189e806638985f3c16338c3c60695df58e621154d79bb973859c4558e9dca90470f77c73f004443ad5db0717abbe43266f90e57397b83ac34d1fef2e897e2483d5bcdcb627abd64b0d1aef525835f25e76d6e9158232cdde6dce970b59f58de8a98e653be32fb58edabbcefa5065d73afdf1c9c4fbf50c1022bd22bfcb98e4b422 AD: fd6a3fdd879f8880843eac20ae01c1b9dc3487d270a806572088ef2ddc1f1e0de495e71d4813bf5c501ad31e5d791c4b5b3a0a71b63fdddcc8de4b056064ef467989ecccc5d0160d403bf3a025d4892b3b1de3e062bc3581d4410f273338311eb4637529e4a680a6e4a5e26e308630a5b6d49ead6d543f8f2bf9050aa94ce091318721e1d8b96e279f34b9759b65037bec4bf6ccda6929705aeeeebe49e327e4d7a916620c9faf3765120658af34c53fbb97ec07657b3f088fcbdc401aa7949ddeda34d885018c2c23f4f0bb8218bf0d4fc90643658b4d8834f4a8c08e590c2a790995baa9e77627c342d283e454f84fcc05be15e9627a2d9be340c9d72f222bbdfc47905f56616cd9f936d49e4732f319f020513340fb8b22828db251b102b6b137c9533936d6 CT: bd11ed07b7b4b30eeaf25d6a41a549cca0a5aee71f990ac566a37265d7af2ce3c03703427ee0b2755c2bdfc29f9d826aec6ee4ad28af48079ac23db16580b97424f3a4e35cc23625d39f95699d9ff5143e9a2bc26fcfee4f125f5aa2d968ccfc2faaf9db3c28850f6757f735cbc50c94c498bcde4f23bffafa8dd5f70d1a011e35eb26e905d4e68848fedebeb197be595c085ba33f11ba8398258445051751888e9bba111f800f31b37c447074ca6dce6d54b4dfad6cee5138643d4f6ac045e8047248924e88ea4294c7878bc22c9b41924ce301f22693c33733107bf1ba85e34806c5e4366ea66fc52a5f89dd9bf213239158b3d4d2600dde696c61d76c398b9bf10de9118e812e891c8f3355c0ecc6405f79bc32a58905e37888a1d8395fbedc3ac54eca569f TAG: f7d3b58a34a86e99267e5db206f17bbe KEY: 3304e4917ad7777b86c26a636292c9cc4c10d32003c49e07209eb0ef8505031a NONCE: 4d572d116fbd8c4d IN: 2f242c2ba33790ecef862b0e077ff8b15eb9d10cf2ff621ed65902494431dcbd AD: e699bbf250cdd93d229d0740e433897e2d19132e2b722df8b69bb6a7c2cf3b93 CT: fb81e30436e437c7f686f86b1b65c73549a9d09db810d320785c3634934150b3 TAG: 8b AEAD: chacha20-poly1305 KEY: ed6057bb163f1609ff28b938122f495e3d5ae4ec3dbd7456c9b5c82e28e952dc NONCE: e6ff6852f3a3afde IN: 3c50edc967eb0b3b2355f6400e0a036e796c8b7d72c5e583a86e820d53e76c43 AD: 2441db55148e14e9e241d68296eb60d529408f0534143089671bce546db96d88 CT: 6ecabccee31519374d4bed11296e7483d1cb759bea3f4446a96bda8b4ca6d7ac TAG: 355f AEAD: chacha20-poly1305 KEY: 73568183c1f9725af30e0f2067606ce802c3fe3ab5cff8d02b3db8c35176ee0d NONCE: 0bc9e19321b3d00a IN: ec2590af5ccd226a32ff750c1b029c11e3dd76c469a5579da9418e4c3fdc0d41 AD: df30160ae0cbf2cf8992221bd62dffe691dd602afa784ca691479e957af3acf1 CT: 9e8d8ac30626f8b831448d6976933aa5bb8c6dbc794e1f4b7eeb0e4a59342c07 TAG: 9fd36a AEAD: chacha20-poly1305 KEY: 273bcb3f8c067da4ec3418799ad40e7e4aee74ad7e629499d646df4a7e585025 NONCE: f60be3eb894b4030 IN: 697498ba964d5ef401da4d94844fab1efc635e7157d0831a325bb5a4cf1fbd34 AD: 9129715deab14f02c76ba8172571b1fa9d50365cd795bfccdfc28e7e7b4f66fc CT: bd4cd5af83be1c13933302675d9fcaf1c4cacdf269f6ff441d1ea2211c54e7ed TAG: 7ab12a37 AEAD: chacha20-poly1305 KEY: ad39610c2e6a6d0961207390e076e972c2edadca885c92965fa648b2ce34fdbf NONCE: a90db690bba83b78 IN: 31c49e3cd3d80a82e6b90316dfb94b38b8a23042519bf40c8181fec873c99002 AD: ddbd7d821d18d44c66295abf245b227b5cf4366811b7b34c07679600abdbfc29 CT: 94628fc303a0546edd51e966f2bd87968f37800c607d5e5a91f727fc1fec406f TAG: c22ec4e4c8 AEAD: chacha20-poly1305 KEY: 29984954060ba06ece1bcfc0e50195f4632c6df48da1e02ae6c14f7065668971 NONCE: cce53a25aeeaf747 IN: b9b87433a9894f3c9ca8212623d62369a565a2edcddd276e07d611eda3597426 AD: 19fa9aa59697559d8b46d9cd49c3b763c0b73b26b9e334a3eeac2c86fdbaca8d CT: b68c83397770c36f073710882fa86d43b0e54e8efef0ff75075604d0d7ec4e1b TAG: 40d4ab752f3d AEAD: chacha20-poly1305 KEY: 5c3b838b84100b2a818c0842e9fe19a7c50cf5f3ea73364c816ef588e500ff3f NONCE: fdf6b0229e4bcc2a IN: 2ba91904c143be99297b39f52856904af41705c176c8c6554b6bc89bddffbcc1 AD: 3539d9dd821f004f4ced1637071f4be6abd7fe98f017f0a8ce3f49dc8d496f46 CT: ff9d6d924e737a1df8c2bd3047e40ab401f903aa0e5b51acb991bac38ac2cc4d TAG: 1bcaa415a6a3c7 AEAD: chacha20-poly1305 KEY: 6d65e627cab6d5eb1a088b25bd6c3a8a004a7a19cccae909d62fed3559c812f7 NONCE: 7ff00a8798b792de IN: 6848ee4ac820291a2e1dc3baad97f1ad8b7160dfeaa1bc83b2700ae42b5a366b AD: d2437b1306bf0ea211449fac863ca0d1074d84caee9009c5d54b9e9bdc8de6b1 CT: 2da0abe2a71e1c0b1ab309c160a8cebe45c6e16170aa5561806484ba2b5b9a9a TAG: 566003e1f78d2a90 AEAD: chacha20-poly1305 KEY: 63401046a96efbc8c6483a2c396b2a593d3fae0db565525b85999fae13a46b6a NONCE: 051393d775e635ee IN: 2b4b6477580382aae782f8b5772c0948a444d8d95caacd85c0856c7e4393fe09 AD: 3d84d2e70e9c062d1f511eb685a9a90c8d5fa50eadf8455c7148666b3e7155e0 CT: 880c1123e54fd8ffb3c293720dd174913572e619ef46504cdaa64fc451b0ec1c TAG: 339274339c88d50ac0 AEAD: chacha20-poly1305 KEY: 291fccfce0782f1787d62d4b9293d2ada4c04d37a8288ba9ba9aae0d31aad204 NONCE: 7450bbd62e4aba7b IN: adc251e793181e5d4c4bd983b853eb13f2096ccb340996b6eca4cd2157efcec7 AD: 4c598f6deedc8c1d97da33654763495cca3517430eec4edb006b10c95e031ae6 CT: 28bda22e4922cd8ff6739cd8a6bdafce036d9c61a145a65ca1b86f6d4d3206a1 TAG: d98fd43fe7ac74d4b016 AEAD: chacha20-poly1305 KEY: fa3a9674d4a0eb36b2f7547c956443d09e6b4e4acfc9deda838eb7ebdb999a8d NONCE: 0a2572592c3bbbf6 IN: ae27f70fda9f5a5be0f704a27f0b8a9c04ce83d3c2e0d7ec152da25f473b0c8a AD: 6ee8705a9a3655d198497ad410da02005872ecbe397824851b80f4050bfdd311 CT: f356cbd88e4e2aff62d91e3f914032085388955bbba995fde013758b8702e38f TAG: 00324c76fecd3f50e1e3b8 AEAD: chacha20-poly1305 KEY: 471ec87b992b104d369748d96856b5f66149cb45ca05c17f29d24eb9526fe6db NONCE: 23a2df9ed0b47439 IN: 2b9452bca0f48e5519ec3d0736597608df6ad9ce799eba913cff71573d79c092 AD: a56722ddfaee5f1b64398c225ee8bcdcfde5c2127101c363bfac52bc409c1082 CT: 7bbc464aac5dd29c25262fe0b116c176d827c2cc8dd63428393b0a9110f3c194 TAG: 2e87f4a6663a62e47c7e197f AEAD: chacha20-poly1305 KEY: a29d1cfd4ccdc18803fbca9500f4bb29ce99cfcbf8acc41b8208dae4b7ee5d64 NONCE: 634f99e88e237ef0 IN: 09ee5982c5743f396d0c29c13e3fbb8fb89f61705da05466291e010effd51a5c AD: 564dddfcc3227b413244f1105b610f192decf15c4cfa067f4d7fcd6bd7af11b8 CT: 32916b67a6f32733623344c98c49773f3e721dc2ded105fb245799525bc9c84c TAG: ff463c07e7ef831321d3fd775f AEAD: chacha20-poly1305 KEY: 08ba23616d911188f91da063278bef1237dcbf17f52585e53c2c4b6cf3ac9f0d NONCE: 989ae593eddd3874 IN: 749152c9478944c8271c0c11e07bc1c569eec01493e65b3b94842a1bf5d721f8 AD: a12d1a45b7c9b91ab08751a70b753714052ad24e0b2619fe8c3be303c65f2dbc CT: 34c40538ee1d22ddf8ac290dd7d423dfc622b5cf8f3412a5343e277822aea713 TAG: 014c7c678e0949e88071d1fe3531 AEAD: chacha20-poly1305 KEY: c2ba8bed8634156afc6bfe3754c91744d4131de39d059f3a866399f916553b5c NONCE: 80fbf7b433a4cd9c IN: 419be6623e7964f9f26068dd969e4a139617e67c5ffb269b3013c433fe771c77 AD: 3937592db78a61ff469691b6800792019bc2b3d42512f23c1b1a66a8274495cb CT: 9d5bd1c7e766763eb00684c038043111d8c6390a8d6e17a15ef97c02ab16f09c TAG: a64d0eeb4a01481ec0cee8c1c357e3 AEAD: chacha20-poly1305 KEY: b23d7afdb317ab79cda4522612be9f7c18d9d9d03619d5cb30204e9f74aaf881 NONCE: 0000000000000006 IN: 80030001010002490000000100000000800038EAE3C6A7C202A52A5076B2821608C2C0421218FC25C57AE9F9F9E939A97AC9E0F282DD0A91AADD5D43C03A0A12C16517234000E903041058BE185852E6828BD38C929202506AE7B0C29EC81125B91722E4B087055A8859835C6C090DD1F2D4A4021D2D7D2DB0A005F65A40102370B0570D7CA979BAA1C1C020811BC606CB748CF200011410E4EA66EBE9629B6A966A91689962966660916C6C69686EE5E6666B6015E26B6B686C6964606A61686962E5E36B6B686C6964606A61686962156CEB9751EC54E2ED62E417EF15561E1811660D10802078DB4110040000FA2BFD001BDABC3DF8D0B41994C446EBF6E288921C1A129AE2D777CE8AA03C0DA354C2CBE0BFAE9F5D59C753E2EB5AC102FFE85792739E34A6D10F1BE79355F0CEEC4667B3279E9409D911CA036C59F95E84590FADB3DCEBF81260E5F60ACDC558F6F6A0DD51B52709AB0000AE23B354D90D24DB7044FD5FC506E5C195F1A6A699D60001A4E0EE18106C6B68159F6D985596EA91951E1C641C915F5E99E69AE9911C999CEA9D919CEA996E959555E164E958151E60949B1854E6186A0D10400AEE8E3E11B67996E5E6EE61A61E198916000184515C4EF4CDAFCACCC949D437D53350D0F0C9CC2BADB05670CC4B29CACF4C5130D133D133B2560876F40D0EF573D70D76F7D0F534373157702ACDCC49D1F7F60F31B1F4D004E65660DE0E4F4DF2CE2CD1373536D7333653D0F0F608F1F5D151C8C9CC4E55704F4DCECED75470CE00D666A9FAC6C67A067AA0724BCF1C94759380853C30A3A6251665423503000000FFFF AD: 00000000000000061703030251 CT: d62561a166e0319d21dc9fd813b00343602fa8ac58cd0b6077dcc786af12c532478b14b5524f5f38feb24f05688d569ecdca190d330a7843ddd75928c67653c0e6742182ec214fc7b84e892c26a3aa9caea181c90b1c0e5f89e57151daeb6309b231dca9c3396b25b5c6d1cae376164aac5b392a4421f56d2fe6c7c109a562a533900c4d998127824b7b2066af5b2ab287f3a3751395d96bb0a81b2745543ccee1a806e5a623c8a088ec27f0346b9d01accf8192556c56fd3bee85d6fcef7f09383637f2e8d7fd3adf3d2d9f1c1eccde05b3b17eb6c99b1ca8be260ae1154e5658a5cd1e9e27d61915db081c2888fc37faa4a75294236b51c449f78881198c3bb702d4d3797b3cd958911060d606280f9ef74b7eef47517f1485291bfec5587d3dbae51fa26ea6f119e24ee72fc2e4e9db5c65aa20209492f504ad657333a7b29cb5ec6ff975ed7cbff20938bb02382276de32b8a21966946b8dcf297c3aacd25cf8903d3060aafd00ad19043e24cf17b404898d3f4aac02727d436a1e5bad07e6c07c88eb12664c1e38dfdf6e280347554629c8903ceb7703ad72eda21354bd963b9bdf05b4c126dc0e5f8d74dd2c45036fd0219e7f32124f27ab26e1d66d87a3c6e873a9c78505a5209265aa90b4a5f4acafe1443dcd3810c0455fa5c471e22a4d9623d34902abf310d414036b7773c8725534b4e03b6261d92346509a70b08e94eac0906d8e26e669a7dea38dfe2532af1167a133b75b4193acbef193dead0c08d65f2cfe7012afd9ee5452d714c6f1a2f810cd13ac2f36b6a1a4580154831a1098aa7ed3c506bebc24de46d7a03f6e TAG: 1df6f94253edb794e81221d3bc838599 deps/libressl-pnacl-sys-2.1.6/libressl/tests/bftest.c0000644000175000017500000004067412360020706017544 0ustar /* crypto/bf/bftest.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* This has been a quickly hacked 'ideatest.c'. When I add tests for other * RC2 modes, more of the code will be uncommented. */ #include #include #include #include static char *bf_key[2]={ "abcdefghijklmnopqrstuvwxyz", "Who is John Galt?" }; /* big endian */ static BF_LONG bf_plain[2][2]={ {0x424c4f57L,0x46495348L}, {0xfedcba98L,0x76543210L} }; static BF_LONG bf_cipher[2][2]={ {0x324ed0feL,0xf413a203L}, {0xcc91732bL,0x8022f684L} }; /************/ /* Lets use the DES test vectors :-) */ #define NUM_TESTS 34 static unsigned char ecb_data[NUM_TESTS][8]={ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, {0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11}, {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10}, {0x7C,0xA1,0x10,0x45,0x4A,0x1A,0x6E,0x57}, {0x01,0x31,0xD9,0x61,0x9D,0xC1,0x37,0x6E}, {0x07,0xA1,0x13,0x3E,0x4A,0x0B,0x26,0x86}, {0x38,0x49,0x67,0x4C,0x26,0x02,0x31,0x9E}, {0x04,0xB9,0x15,0xBA,0x43,0xFE,0xB5,0xB6}, {0x01,0x13,0xB9,0x70,0xFD,0x34,0xF2,0xCE}, {0x01,0x70,0xF1,0x75,0x46,0x8F,0xB5,0xE6}, {0x43,0x29,0x7F,0xAD,0x38,0xE3,0x73,0xFE}, {0x07,0xA7,0x13,0x70,0x45,0xDA,0x2A,0x16}, {0x04,0x68,0x91,0x04,0xC2,0xFD,0x3B,0x2F}, {0x37,0xD0,0x6B,0xB5,0x16,0xCB,0x75,0x46}, {0x1F,0x08,0x26,0x0D,0x1A,0xC2,0x46,0x5E}, {0x58,0x40,0x23,0x64,0x1A,0xBA,0x61,0x76}, {0x02,0x58,0x16,0x16,0x46,0x29,0xB0,0x07}, {0x49,0x79,0x3E,0xBC,0x79,0xB3,0x25,0x8F}, {0x4F,0xB0,0x5E,0x15,0x15,0xAB,0x73,0xA7}, {0x49,0xE9,0x5D,0x6D,0x4C,0xA2,0x29,0xBF}, {0x01,0x83,0x10,0xDC,0x40,0x9B,0x26,0xD6}, {0x1C,0x58,0x7F,0x1C,0x13,0x92,0x4F,0xEF}, {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, {0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E}, {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10}}; static unsigned char plain_data[NUM_TESTS][8]={ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, {0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x01}, {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11}, {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11}, {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, {0x01,0xA1,0xD6,0xD0,0x39,0x77,0x67,0x42}, {0x5C,0xD5,0x4C,0xA8,0x3D,0xEF,0x57,0xDA}, {0x02,0x48,0xD4,0x38,0x06,0xF6,0x71,0x72}, {0x51,0x45,0x4B,0x58,0x2D,0xDF,0x44,0x0A}, {0x42,0xFD,0x44,0x30,0x59,0x57,0x7F,0xA2}, {0x05,0x9B,0x5E,0x08,0x51,0xCF,0x14,0x3A}, {0x07,0x56,0xD8,0xE0,0x77,0x47,0x61,0xD2}, {0x76,0x25,0x14,0xB8,0x29,0xBF,0x48,0x6A}, {0x3B,0xDD,0x11,0x90,0x49,0x37,0x28,0x02}, {0x26,0x95,0x5F,0x68,0x35,0xAF,0x60,0x9A}, {0x16,0x4D,0x5E,0x40,0x4F,0x27,0x52,0x32}, {0x6B,0x05,0x6E,0x18,0x75,0x9F,0x5C,0xCA}, {0x00,0x4B,0xD6,0xEF,0x09,0x17,0x60,0x62}, {0x48,0x0D,0x39,0x00,0x6E,0xE7,0x62,0xF2}, {0x43,0x75,0x40,0xC8,0x69,0x8F,0x3C,0xFA}, {0x07,0x2D,0x43,0xA0,0x77,0x07,0x52,0x92}, {0x02,0xFE,0x55,0x77,0x81,0x17,0xF1,0x2A}, {0x1D,0x9D,0x5C,0x50,0x18,0xF7,0x28,0xC2}, {0x30,0x55,0x32,0x28,0x6D,0x6F,0x29,0x5A}, {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}}; static unsigned char cipher_data[NUM_TESTS][8]={ {0x4E,0xF9,0x97,0x45,0x61,0x98,0xDD,0x78}, {0x51,0x86,0x6F,0xD5,0xB8,0x5E,0xCB,0x8A}, {0x7D,0x85,0x6F,0x9A,0x61,0x30,0x63,0xF2}, {0x24,0x66,0xDD,0x87,0x8B,0x96,0x3C,0x9D}, {0x61,0xF9,0xC3,0x80,0x22,0x81,0xB0,0x96}, {0x7D,0x0C,0xC6,0x30,0xAF,0xDA,0x1E,0xC7}, {0x4E,0xF9,0x97,0x45,0x61,0x98,0xDD,0x78}, {0x0A,0xCE,0xAB,0x0F,0xC6,0xA0,0xA2,0x8D}, {0x59,0xC6,0x82,0x45,0xEB,0x05,0x28,0x2B}, {0xB1,0xB8,0xCC,0x0B,0x25,0x0F,0x09,0xA0}, {0x17,0x30,0xE5,0x77,0x8B,0xEA,0x1D,0xA4}, {0xA2,0x5E,0x78,0x56,0xCF,0x26,0x51,0xEB}, {0x35,0x38,0x82,0xB1,0x09,0xCE,0x8F,0x1A}, {0x48,0xF4,0xD0,0x88,0x4C,0x37,0x99,0x18}, {0x43,0x21,0x93,0xB7,0x89,0x51,0xFC,0x98}, {0x13,0xF0,0x41,0x54,0xD6,0x9D,0x1A,0xE5}, {0x2E,0xED,0xDA,0x93,0xFF,0xD3,0x9C,0x79}, {0xD8,0x87,0xE0,0x39,0x3C,0x2D,0xA6,0xE3}, {0x5F,0x99,0xD0,0x4F,0x5B,0x16,0x39,0x69}, {0x4A,0x05,0x7A,0x3B,0x24,0xD3,0x97,0x7B}, {0x45,0x20,0x31,0xC1,0xE4,0xFA,0xDA,0x8E}, {0x75,0x55,0xAE,0x39,0xF5,0x9B,0x87,0xBD}, {0x53,0xC5,0x5F,0x9C,0xB4,0x9F,0xC0,0x19}, {0x7A,0x8E,0x7B,0xFA,0x93,0x7E,0x89,0xA3}, {0xCF,0x9C,0x5D,0x7A,0x49,0x86,0xAD,0xB5}, {0xD1,0xAB,0xB2,0x90,0x65,0x8B,0xC7,0x78}, {0x55,0xCB,0x37,0x74,0xD1,0x3E,0xF2,0x01}, {0xFA,0x34,0xEC,0x48,0x47,0xB2,0x68,0xB2}, {0xA7,0x90,0x79,0x51,0x08,0xEA,0x3C,0xAE}, {0xC3,0x9E,0x07,0x2D,0x9F,0xAC,0x63,0x1D}, {0x01,0x49,0x33,0xE0,0xCD,0xAF,0xF6,0xE4}, {0xF2,0x1E,0x9A,0x77,0xB7,0x1C,0x49,0xBC}, {0x24,0x59,0x46,0x88,0x57,0x54,0x36,0x9A}, {0x6B,0x5C,0x5A,0x9C,0x5D,0x9E,0x0A,0x5A}, }; static unsigned char cbc_key [16]={ 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87}; static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}; static char cbc_data[40]="7654321 Now is the time for "; static unsigned char cbc_ok[32]={ 0x6B,0x77,0xB4,0xD6,0x30,0x06,0xDE,0xE6, 0x05,0xB1,0x56,0xE2,0x74,0x03,0x97,0x93, 0x58,0xDE,0xB9,0xE7,0x15,0x46,0x16,0xD9, 0x59,0xF1,0x65,0x2B,0xD5,0xFF,0x92,0xCC}; static unsigned char cfb64_ok[]={ 0xE7,0x32,0x14,0xA2,0x82,0x21,0x39,0xCA, 0xF2,0x6E,0xCF,0x6D,0x2E,0xB9,0xE7,0x6E, 0x3D,0xA3,0xDE,0x04,0xD1,0x51,0x72,0x00, 0x51,0x9D,0x57,0xA6,0xC3}; static unsigned char ofb64_ok[]={ 0xE7,0x32,0x14,0xA2,0x82,0x21,0x39,0xCA, 0x62,0xB3,0x43,0xCC,0x5B,0x65,0x58,0x73, 0x10,0xDD,0x90,0x8D,0x0C,0x24,0x1B,0x22, 0x63,0xC2,0xCF,0x80,0xDA}; #define KEY_TEST_NUM 25 static unsigned char key_test[KEY_TEST_NUM]={ 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87, 0x78,0x69,0x5a,0x4b,0x3c,0x2d,0x1e,0x0f, 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77, 0x88}; static unsigned char key_data[8]= {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10}; static unsigned char key_out[KEY_TEST_NUM][8]={ {0xF9,0xAD,0x59,0x7C,0x49,0xDB,0x00,0x5E}, {0xE9,0x1D,0x21,0xC1,0xD9,0x61,0xA6,0xD6}, {0xE9,0xC2,0xB7,0x0A,0x1B,0xC6,0x5C,0xF3}, {0xBE,0x1E,0x63,0x94,0x08,0x64,0x0F,0x05}, {0xB3,0x9E,0x44,0x48,0x1B,0xDB,0x1E,0x6E}, {0x94,0x57,0xAA,0x83,0xB1,0x92,0x8C,0x0D}, {0x8B,0xB7,0x70,0x32,0xF9,0x60,0x62,0x9D}, {0xE8,0x7A,0x24,0x4E,0x2C,0xC8,0x5E,0x82}, {0x15,0x75,0x0E,0x7A,0x4F,0x4E,0xC5,0x77}, {0x12,0x2B,0xA7,0x0B,0x3A,0xB6,0x4A,0xE0}, {0x3A,0x83,0x3C,0x9A,0xFF,0xC5,0x37,0xF6}, {0x94,0x09,0xDA,0x87,0xA9,0x0F,0x6B,0xF2}, {0x88,0x4F,0x80,0x62,0x50,0x60,0xB8,0xB4}, {0x1F,0x85,0x03,0x1C,0x19,0xE1,0x19,0x68}, {0x79,0xD9,0x37,0x3A,0x71,0x4C,0xA3,0x4F}, {0x93,0x14,0x28,0x87,0xEE,0x3B,0xE1,0x5C}, {0x03,0x42,0x9E,0x83,0x8C,0xE2,0xD1,0x4B}, {0xA4,0x29,0x9E,0x27,0x46,0x9F,0xF6,0x7B}, {0xAF,0xD5,0xAE,0xD1,0xC1,0xBC,0x96,0xA8}, {0x10,0x85,0x1C,0x0E,0x38,0x58,0xDA,0x9F}, {0xE6,0xF5,0x1E,0xD7,0x9B,0x9D,0xB2,0x1F}, {0x64,0xA6,0xE1,0x4A,0xFD,0x36,0xB4,0x6F}, {0x80,0xC7,0xD7,0xD4,0x5A,0x54,0x79,0xAD}, {0x05,0x04,0x4B,0x62,0xFA,0x52,0xD0,0x80}, }; static int test(void ); static int print_test_data(void ); int main(int argc, char *argv[]) { int ret; if (argc > 1) ret=print_test_data(); else ret=test(); return ret; } static int print_test_data(void) { unsigned int i,j; printf("ecb test data\n"); printf("key bytes\t\tclear bytes\t\tcipher bytes\n"); for (i=0; i * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * A mostly exhaustive test of UTF-8 decoder and encoder */ #include #include #include #include #include "asn1_locl.h" /* peek into the internals */ #define UNCHANGED 0xfedcba98 #define ASSERT(x) \ do { \ if (!(x)) \ errx(1, "test failed at line %d: %s", \ __LINE__, #x); \ } while (0) int main(void) { unsigned char testbuf[] = "012345"; const unsigned char zerobuf[sizeof testbuf] = { 0 }; unsigned long value; unsigned int i, j, k, l; int ret; /* * First, verify UTF8_getc() */ value = UNCHANGED; ret = UTF8_getc(testbuf, 0, &value); ASSERT(ret == 0); ASSERT(value == UNCHANGED); /* check all valid single-byte chars */ for (i = 0; i < 0x80; i++) { testbuf[0] = i; ret = UTF8_getc(testbuf, 1, &value); ASSERT(ret == 1); ASSERT(value == i); ret = UTF8_getc(testbuf, 2, &value); ASSERT(ret == 1); ASSERT(value == i); } /* * Verify failure on all invalid initial bytes: * 0x80 - 0xBF following bytes only * 0xC0 - 0xC1 used to be in non-shortest forms * 0xF5 - 0xFD used to be initial for 5 and 6 byte sequences * 0xFE - 0xFF have never been valid in utf-8 */ for (i = 0x80; i < 0xC2; i++) { value = UNCHANGED; testbuf[0] = i; ret = UTF8_getc(testbuf, 1, &value); ASSERT(ret == -2); ASSERT(value == UNCHANGED); } for (i = 0xF5; i < 0x100; i++) { value = UNCHANGED; testbuf[0] = i; ret = UTF8_getc(testbuf, 1, &value); ASSERT(ret == -2); ASSERT(value == UNCHANGED); } /* * Verify handling of all two-byte sequences */ for (i = 0xC2; i < 0xE0; i++) { testbuf[0] = i; for (j = 0; j < 0x100; j++) { testbuf[1] = j; value = UNCHANGED; ret = UTF8_getc(testbuf, 1, &value); ASSERT(ret == -1); ASSERT(value == UNCHANGED); ret = UTF8_getc(testbuf, 2, &value); /* outside range of trailing bytes */ if (j < 0x80 || j > 0xBF) { ASSERT(ret == -3); ASSERT(value == UNCHANGED); continue; } /* valid */ ASSERT(ret == 2); ASSERT((value & 0x3F) == (j & 0x3F)); ASSERT(value >> 6 == (i & 0x1F)); } } /* * Verify handling of all three-byte sequences */ for (i = 0xE0; i < 0xF0; i++) { testbuf[0] = i; for (j = 0; j < 0x100; j++) { testbuf[1] = j; for (k = 0; k < 0x100; k++) { testbuf[2] = k; value = UNCHANGED; ret = UTF8_getc(testbuf, 2, &value); ASSERT(ret == -1); ASSERT(value == UNCHANGED); ret = UTF8_getc(testbuf, 3, &value); /* outside range of trailing bytes */ if (j < 0x80 || j > 0xBF || k < 0x80 || k > 0xBF) { ASSERT(ret == -3); ASSERT(value == UNCHANGED); continue; } /* non-shortest form */ if (i == 0xE0 && j < 0xA0) { ASSERT(ret == -4); ASSERT(value == UNCHANGED); continue; } /* surrogate pair code point */ if (i == 0xED && j > 0x9F) { ASSERT(ret == -2); ASSERT(value == UNCHANGED); continue; } ASSERT(ret == 3); ASSERT((value & 0x3F) == (k & 0x3F)); ASSERT(((value >> 6) & 0x3F) == (j & 0x3F)); ASSERT(value >> 12 == (i & 0x0F)); } } } /* * Verify handling of all four-byte sequences */ for (i = 0xF0; i < 0xF5; i++) { testbuf[0] = i; for (j = 0; j < 0x100; j++) { testbuf[1] = j; for (k = 0; k < 0x100; k++) { testbuf[2] = k; for (l = 0; l < 0x100; l++) { testbuf[3] = l; value = UNCHANGED; ret = UTF8_getc(testbuf, 3, &value); ASSERT(ret == -1); ASSERT(value == UNCHANGED); ret = UTF8_getc(testbuf, 4, &value); /* outside range of trailing bytes */ if (j < 0x80 || j > 0xBF || k < 0x80 || k > 0xBF || l < 0x80 || l > 0xBF) { ASSERT(ret == -3); ASSERT(value == UNCHANGED); continue; } /* non-shortest form */ if (i == 0xF0 && j < 0x90) { ASSERT(ret == -4); ASSERT(value == UNCHANGED); continue; } /* beyond end of UCS range */ if (i == 0xF4 && j > 0x8F) { ASSERT(ret == -2); ASSERT(value == UNCHANGED); continue; } ASSERT(ret == 4); ASSERT((value & 0x3F) == (l & 0x3F)); ASSERT(((value >> 6) & 0x3F) == (k & 0x3F)); ASSERT(((value >> 12) & 0x3F) == (j & 0x3F)); ASSERT(value >> 18 == (i & 0x07)); } } } } /* * Next, verify UTF8_putc() */ memset(testbuf, 0, sizeof testbuf); /* single-byte sequences */ for (i = 0; i < 0x80; i++) { ret = UTF8_putc(NULL, 0, i); ASSERT(ret == 1); testbuf[0] = 0; ret = UTF8_putc(testbuf, 0, i); ASSERT(ret == -1); ASSERT(memcmp(testbuf, zerobuf, sizeof testbuf) == 0); ret = UTF8_putc(testbuf, 1, i); ASSERT(ret == 1); ASSERT(testbuf[0] == i); ASSERT(memcmp(testbuf+1, zerobuf, sizeof(testbuf)-1) == 0); } /* two-byte sequences */ for (i = 0x80; i < 0x800; i++) { ret = UTF8_putc(NULL, 0, i); ASSERT(ret == 2); testbuf[0] = testbuf[1] = 0; ret = UTF8_putc(testbuf, 1, i); ASSERT(ret == -1); ASSERT(memcmp(testbuf, zerobuf, sizeof testbuf) == 0); ret = UTF8_putc(testbuf, 2, i); ASSERT(ret == 2); ASSERT(memcmp(testbuf+2, zerobuf, sizeof(testbuf)-2) == 0); ret = UTF8_getc(testbuf, 2, &value); ASSERT(ret == 2); ASSERT(value == i); } /* three-byte sequences */ for (i = 0x800; i < 0x10000; i++) { if (i >= 0xD800 && i < 0xE000) { /* surrogates aren't valid */ ret = UTF8_putc(NULL, 0, i); ASSERT(ret == -2); continue; } ret = UTF8_putc(NULL, 0, i); ASSERT(ret == 3); testbuf[0] = testbuf[1] = testbuf[2] = 0; ret = UTF8_putc(testbuf, 2, i); ASSERT(ret == -1); ASSERT(memcmp(testbuf, zerobuf, sizeof testbuf) == 0); ret = UTF8_putc(testbuf, 3, i); ASSERT(ret == 3); ASSERT(memcmp(testbuf+3, zerobuf, sizeof(testbuf)-3) == 0); ret = UTF8_getc(testbuf, 3, &value); ASSERT(ret == 3); ASSERT(value == i); } /* four-byte sequences */ for (i = 0x10000; i < 0x110000; i++) { ret = UTF8_putc(NULL, 0, i); ASSERT(ret == 4); testbuf[0] = testbuf[1] = testbuf[2] = testbuf[3] = 0; ret = UTF8_putc(testbuf, 3, i); ASSERT(ret == -1); ASSERT(memcmp(testbuf, zerobuf, sizeof testbuf) == 0); ret = UTF8_putc(testbuf, 4, i); ASSERT(ret == 4); ASSERT(memcmp(testbuf+4, zerobuf, sizeof(testbuf)-4) == 0); ret = UTF8_getc(testbuf, 4, &value); ASSERT(ret == 4); ASSERT(value == i); } /* spot check some larger values to confirm error return */ for (i = 0x110000; i < 0x110100; i++) { ret = UTF8_putc(NULL, 0, i); ASSERT(ret == -2); } for (value = (unsigned long)-1; value > (unsigned long)-256; value--) { ret = UTF8_putc(NULL, 0, value); ASSERT(ret == -2); } return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/poly1305test.c0000644000175000017500000001205512360020706020441 0ustar /* * Public Domain poly1305 from Andrew Moon * Based on poly1305-donna.c from: * https://github.com/floodyberry/poly1305-donna */ #include #include void poly1305_auth(unsigned char mac[16], const unsigned char *m, size_t bytes, const unsigned char key[32]); int poly1305_verify(const unsigned char mac1[16], const unsigned char mac2[16]); int poly1305_power_on_self_test(void); void poly1305_auth(unsigned char mac[16], const unsigned char *m, size_t bytes, const unsigned char key[32]) { poly1305_context ctx; CRYPTO_poly1305_init(&ctx, key); CRYPTO_poly1305_update(&ctx, m, bytes); CRYPTO_poly1305_finish(&ctx, mac); } int poly1305_verify(const unsigned char mac1[16], const unsigned char mac2[16]) { size_t i; unsigned int dif = 0; for (i = 0; i < 16; i++) dif |= (mac1[i] ^ mac2[i]); dif = (dif - 1) >> ((sizeof(unsigned int) * 8) - 1); return (dif & 1); } /* test a few basic operations */ int poly1305_power_on_self_test(void) { /* example from nacl */ static const unsigned char nacl_key[32] = { 0xee, 0xa6, 0xa7, 0x25, 0x1c, 0x1e, 0x72, 0x91, 0x6d, 0x11, 0xc2, 0xcb, 0x21, 0x4d, 0x3c, 0x25, 0x25, 0x39, 0x12, 0x1d, 0x8e, 0x23, 0x4e, 0x65, 0x2d, 0x65, 0x1f, 0xa4, 0xc8, 0xcf, 0xf8, 0x80, }; static const unsigned char nacl_msg[131] = { 0x8e, 0x99, 0x3b, 0x9f, 0x48, 0x68, 0x12, 0x73, 0xc2, 0x96, 0x50, 0xba, 0x32, 0xfc, 0x76, 0xce, 0x48, 0x33, 0x2e, 0xa7, 0x16, 0x4d, 0x96, 0xa4, 0x47, 0x6f, 0xb8, 0xc5, 0x31, 0xa1, 0x18, 0x6a, 0xc0, 0xdf, 0xc1, 0x7c, 0x98, 0xdc, 0xe8, 0x7b, 0x4d, 0xa7, 0xf0, 0x11, 0xec, 0x48, 0xc9, 0x72, 0x71, 0xd2, 0xc2, 0x0f, 0x9b, 0x92, 0x8f, 0xe2, 0x27, 0x0d, 0x6f, 0xb8, 0x63, 0xd5, 0x17, 0x38, 0xb4, 0x8e, 0xee, 0xe3, 0x14, 0xa7, 0xcc, 0x8a, 0xb9, 0x32, 0x16, 0x45, 0x48, 0xe5, 0x26, 0xae, 0x90, 0x22, 0x43, 0x68, 0x51, 0x7a, 0xcf, 0xea, 0xbd, 0x6b, 0xb3, 0x73, 0x2b, 0xc0, 0xe9, 0xda, 0x99, 0x83, 0x2b, 0x61, 0xca, 0x01, 0xb6, 0xde, 0x56, 0x24, 0x4a, 0x9e, 0x88, 0xd5, 0xf9, 0xb3, 0x79, 0x73, 0xf6, 0x22, 0xa4, 0x3d, 0x14, 0xa6, 0x59, 0x9b, 0x1f, 0x65, 0x4c, 0xb4, 0x5a, 0x74, 0xe3, 0x55, 0xa5 }; static const unsigned char nacl_mac[16] = { 0xf3, 0xff, 0xc7, 0x70, 0x3f, 0x94, 0x00, 0xe5, 0x2a, 0x7d, 0xfb, 0x4b, 0x3d, 0x33, 0x05, 0xd9 }; /* generates a final value of (2^130 - 2) == 3 */ static const unsigned char wrap_key[32] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; static const unsigned char wrap_msg[16] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; static const unsigned char wrap_mac[16] = { 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; /* mac of the macs of messages of length 0 to 256, where the key and messages have all their values set to the length */ static const unsigned char total_key[32] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; static const unsigned char total_mac[16] = { 0x64, 0xaf, 0xe2, 0xe8, 0xd6, 0xad, 0x7b, 0xbd, 0xd2, 0x87, 0xf9, 0x7c, 0x44, 0x62, 0x3d, 0x39 }; poly1305_context ctx; poly1305_context total_ctx; unsigned char all_key[32]; unsigned char all_msg[256]; unsigned char mac[16]; size_t i, j; int result = 1; for (i = 0; i < sizeof(mac); i++) mac[i] = 0; poly1305_auth(mac, nacl_msg, sizeof(nacl_msg), nacl_key); result &= poly1305_verify(nacl_mac, mac); for (i = 0; i < sizeof(mac); i++) mac[i] = 0; CRYPTO_poly1305_init(&ctx, nacl_key); CRYPTO_poly1305_update(&ctx, nacl_msg + 0, 32); CRYPTO_poly1305_update(&ctx, nacl_msg + 32, 64); CRYPTO_poly1305_update(&ctx, nacl_msg + 96, 16); CRYPTO_poly1305_update(&ctx, nacl_msg + 112, 8); CRYPTO_poly1305_update(&ctx, nacl_msg + 120, 4); CRYPTO_poly1305_update(&ctx, nacl_msg + 124, 2); CRYPTO_poly1305_update(&ctx, nacl_msg + 126, 1); CRYPTO_poly1305_update(&ctx, nacl_msg + 127, 1); CRYPTO_poly1305_update(&ctx, nacl_msg + 128, 1); CRYPTO_poly1305_update(&ctx, nacl_msg + 129, 1); CRYPTO_poly1305_update(&ctx, nacl_msg + 130, 1); CRYPTO_poly1305_finish(&ctx, mac); result &= poly1305_verify(nacl_mac, mac); for (i = 0; i < sizeof(mac); i++) mac[i] = 0; poly1305_auth(mac, wrap_msg, sizeof(wrap_msg), wrap_key); result &= poly1305_verify(wrap_mac, mac); CRYPTO_poly1305_init(&total_ctx, total_key); for (i = 0; i < 256; i++) { /* set key and message to 'i,i,i..' */ for (j = 0; j < sizeof(all_key); j++) all_key[j] = i; for (j = 0; j < i; j++) all_msg[j] = i; poly1305_auth(mac, all_msg, i, all_key); CRYPTO_poly1305_update(&total_ctx, mac, 16); } CRYPTO_poly1305_finish(&total_ctx, mac); result &= poly1305_verify(total_mac, mac); return result; } int main(int argc, char **argv) { if (!poly1305_power_on_self_test()) { fprintf(stderr, "One or more self tests failed!\n"); return 1; } return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/pq_expected.txt0000644000175000017500000000010212360020706021131 0ustar item 6966726167696c69 item 7374696365787069 item 737570657263616c deps/libressl-pnacl-sys-2.1.6/libressl/tests/pq_test.sh0000755000175000017500000000010412357514212020115 0ustar #!/bin/sh set -e ./pq_test | cmp $srcdir/pq_expected.txt /dev/stdin deps/libressl-pnacl-sys-2.1.6/libressl/tests/rc4test.c0000644000175000017500000001643112360020706017637 0ustar /* crypto/rc4/rc4test.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include static unsigned char keys[7][30]={ {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}, {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}, {8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {4,0xef,0x01,0x23,0x45}, {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}, {4,0xef,0x01,0x23,0x45}, }; static unsigned char data_len[7]={8,8,8,20,28,10}; static unsigned char data[7][30]={ {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xff}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xff}, {0x12,0x34,0x56,0x78,0x9A,0xBC,0xDE,0xF0, 0x12,0x34,0x56,0x78,0x9A,0xBC,0xDE,0xF0, 0x12,0x34,0x56,0x78,0x9A,0xBC,0xDE,0xF0, 0x12,0x34,0x56,0x78,0xff}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff}, {0}, }; static unsigned char output[7][30]={ {0x75,0xb7,0x87,0x80,0x99,0xe0,0xc5,0x96,0x00}, {0x74,0x94,0xc2,0xe7,0x10,0x4b,0x08,0x79,0x00}, {0xde,0x18,0x89,0x41,0xa3,0x37,0x5d,0x3a,0x00}, {0xd6,0xa1,0x41,0xa7,0xec,0x3c,0x38,0xdf, 0xbd,0x61,0x5a,0x11,0x62,0xe1,0xc7,0xba, 0x36,0xb6,0x78,0x58,0x00}, {0x66,0xa0,0x94,0x9f,0x8a,0xf7,0xd6,0x89, 0x1f,0x7f,0x83,0x2b,0xa8,0x33,0xc0,0x0c, 0x89,0x2e,0xbe,0x30,0x14,0x3c,0xe2,0x87, 0x40,0x01,0x1e,0xcf,0x00}, {0xd6,0xa1,0x41,0xa7,0xec,0x3c,0x38,0xdf,0xbd,0x61,0x00}, {0}, }; int main(int argc, char *argv[]) { int i,err=0; int j; unsigned char *p; RC4_KEY key; unsigned char obuf[512]; OPENSSL_add_all_algorithms_noconf(); for (i=0; i<6; i++) { RC4_set_key(&key,keys[i][0],&(keys[i][1])); memset(obuf,0x00,sizeof(obuf)); RC4(&key,data_len[i],&(data[i][0]),obuf); if (memcmp(obuf,output[i],data_len[i]+1) != 0) { printf("error calculating RC4\n"); printf("output:"); for (j=0; j #include #include #include #include static char *test[]={ "", "a", "abc", "message digest", "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "12345678901234567890123456789012345678901234567890123456789012345678901234567890", NULL, }; static char *ret[]={ "d41d8cd98f00b204e9800998ecf8427e", "0cc175b9c0f1b6a831c399e269772661", "900150983cd24fb0d6963f7d28e17f72", "f96b697d7cb7938d525a2f31aaf161d0", "c3fcd3d76192e4007dfb496cca67e13b", "d174ab98d277d9f5a5611c2c9f419d9f", "57edf4a22be3c955ac49da2e2107b67a", }; static char *pt(unsigned char *md); int main(int argc, char *argv[]) { int i,err=0; char **P,**R; char *p; unsigned char md[MD5_DIGEST_LENGTH]; P=test; R=ret; i=1; while (*P != NULL) { EVP_Digest(&(P[0][0]),strlen((char *)*P),md,NULL,EVP_md5(), NULL); p=pt(md); if (strcmp(p,(char *)*R) != 0) { printf("error calculating MD5 on '%s'\n",*P); printf("got %s instead of %s\n",p,*R); err++; } else printf("test %d ok\n",i); i++; R++; P++; } exit(err); } static char *pt(unsigned char *md) { int i; static char buf[80]; for (i=0; i #include #include #include unsigned char k[16]={ 0x00,0x01,0x00,0x02,0x00,0x03,0x00,0x04, 0x00,0x05,0x00,0x06,0x00,0x07,0x00,0x08}; unsigned char in[8]={0x00,0x00,0x00,0x01,0x00,0x02,0x00,0x03}; unsigned char c[8]={0x11,0xFB,0xED,0x2B,0x01,0x98,0x6D,0xE5}; unsigned char out[80]; char *text="Hello to all people out there"; static unsigned char cfb_key[16]={ 0xe1,0xf0,0xc3,0xd2,0xa5,0xb4,0x87,0x96, 0x69,0x78,0x4b,0x5a,0x2d,0x3c,0x0f,0x1e, }; static unsigned char cfb_iv[80]={0x34,0x12,0x78,0x56,0xab,0x90,0xef,0xcd}; static unsigned char cfb_buf1[40],cfb_buf2[40],cfb_tmp[8]; #define CFB_TEST_SIZE 24 static unsigned char plain[CFB_TEST_SIZE]= { 0x4e,0x6f,0x77,0x20,0x69,0x73, 0x20,0x74,0x68,0x65,0x20,0x74, 0x69,0x6d,0x65,0x20,0x66,0x6f, 0x72,0x20,0x61,0x6c,0x6c,0x20 }; static unsigned char cfb_cipher64[CFB_TEST_SIZE]={ 0x59,0xD8,0xE2,0x65,0x00,0x58,0x6C,0x3F, 0x2C,0x17,0x25,0xD0,0x1A,0x38,0xB7,0x2A, 0x39,0x61,0x37,0xDC,0x79,0xFB,0x9F,0x45 /* 0xF9,0x78,0x32,0xB5,0x42,0x1A,0x6B,0x38, 0x9A,0x44,0xD6,0x04,0x19,0x43,0xC4,0xD9, 0x3D,0x1E,0xAE,0x47,0xFC,0xCF,0x29,0x0B,*/ }; static int cfb64_test(unsigned char *cfb_cipher); static char *pt(unsigned char *p); int main(int argc, char *argv[]) { int i,err=0; IDEA_KEY_SCHEDULE key,dkey; unsigned char iv[8]; idea_set_encrypt_key(k,&key); idea_ecb_encrypt(in,out,&key); if (memcmp(out,c,8) != 0) { printf("ecb idea error encrypting\n"); printf("got :"); for (i=0; i<8; i++) printf("%02X ",out[i]); printf("\n"); printf("expected:"); for (i=0; i<8; i++) printf("%02X ",c[i]); err=20; printf("\n"); } idea_set_decrypt_key(&key,&dkey); idea_ecb_encrypt(c,out,&dkey); if (memcmp(out,in,8) != 0) { printf("ecb idea error decrypting\n"); printf("got :"); for (i=0; i<8; i++) printf("%02X ",out[i]); printf("\n"); printf("expected:"); for (i=0; i<8; i++) printf("%02X ",in[i]); printf("\n"); err=3; } if (err == 0) printf("ecb idea ok\n"); memcpy(iv,k,8); idea_cbc_encrypt((unsigned char *)text,out,strlen(text)+1,&key,iv,1); memcpy(iv,k,8); idea_cbc_encrypt(out,out,8,&dkey,iv,0); idea_cbc_encrypt(&(out[8]),&(out[8]),strlen(text)+1-8,&dkey,iv,0); if (memcmp(text,out,strlen(text)+1) != 0) { printf("cbc idea bad\n"); err=4; } else printf("cbc idea ok\n"); printf("cfb64 idea "); if (cfb64_test(cfb_cipher64)) { printf("bad\n"); err=5; } else printf("ok\n"); exit(err); } static int cfb64_test(unsigned char *cfb_cipher) { IDEA_KEY_SCHEDULE eks,dks; int err=0,i,n; idea_set_encrypt_key(cfb_key,&eks); idea_set_decrypt_key(&eks,&dks); memcpy(cfb_tmp,cfb_iv,8); n=0; idea_cfb64_encrypt(plain,cfb_buf1,(long)12,&eks, cfb_tmp,&n,IDEA_ENCRYPT); idea_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]), (long)CFB_TEST_SIZE-12,&eks, cfb_tmp,&n,IDEA_ENCRYPT); if (memcmp(cfb_cipher,cfb_buf1,CFB_TEST_SIZE) != 0) { err=1; printf("idea_cfb64_encrypt encrypt error\n"); for (i=0; i>4)&0xf]; ret[i*2+1]=f[p[i]&0xf]; } ret[16]='\0'; return(ret); } deps/libressl-pnacl-sys-2.1.6/libressl/tests/ca.pem0000644000175000017500000000522112360020706017164 0ustar -----BEGIN CERTIFICATE----- MIIDtjCCAp6gAwIBAgIJAJz/hGfwYXLrMA0GCSqGSIb3DQEBBQUAMGgxCzAJBgNV BAYTAlVLMRYwFAYDVQQKDA1PcGVuU1NMIEdyb3VwMSIwIAYDVQQLDBlGT1IgVEVT VElORyBQVVJQT1NFUyBPTkxZMR0wGwYDVQQDDBRPcGVuU1NMIFRlc3QgUm9vdCBD QTAeFw0xNDA1MjQxNDQ1MTFaFw0yNDA1MjExNDQ1MTFaMGgxCzAJBgNVBAYTAlVL MRYwFAYDVQQKDA1PcGVuU1NMIEdyb3VwMSIwIAYDVQQLDBlGT1IgVEVTVElORyBQ VVJQT1NFUyBPTkxZMR0wGwYDVQQDDBRPcGVuU1NMIFRlc3QgUm9vdCBDQTCCASIw DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANMaarigKGOra5Mc/LrhOkcmHzDs vkYL7dfaaht8fLBKRTYwzSBvO9x54koTWjq7HkbaxkYAg3HnDTkNCyzkGKNdM89H q/PtGIFFlceQIOat3Kjd05Iw3PtLEWTDjT6FMA9Mkjk/XbpmycqRIwNKtgICoFsG juIpc4P31kxK7i3ri+JnlyvVmRZjJxrheJB0qHGXilrOVDPOliDn//jXbcyzXemu R8KgAeQM4IIs9jYHJOgHrTItIpwa9wNTEp9KCGkO6xr20NkKyDp6XRyd+hmnUB7r 77WTptvKPFFTjTDFqEtcif9U2kVkCfn2mSRO8noCbVH++fuR8LMWlD99gt8CAwEA AaNjMGEwHQYDVR0OBBYEFIwZD9dCMXcFBuHTsZ/rOft4cTpFMB8GA1UdIwQYMBaA FIwZD9dCMXcFBuHTsZ/rOft4cTpFMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/ BAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQCPfqm4KbYtXEB8aP1RdUH2BkPSjyau WQLMGfKNF/zkUQue0REgdJ4wVR06NTTlOCsfHC6b68vgz2QFC1mM8ZANgDiyr4M1 6gjvP0eZQVxokJ3EMzjDMFRHIiFrZZAFr7aGq8dxoruuehovqyehuJRakAe0oNUb 4ZTKrGuTKh9Mwti9721XNFByjeTFL2dlH6ulz7qyfI+lrTi+pNsUchuVYE8a1TP3 OEiG6whsyPU1YoTlemC1mvW0ixtj8Tcem0KyotCUyOmJlwyWj0bA43sCI6z/OVqJ tVvwgfqrOeVNk9nN2JslCsttnwstwqUfDoEXFoScej2CT0QezFGPTN21 -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- MIIDvjCCAqagAwIBAgIJAPrXr2k7uM/OMA0GCSqGSIb3DQEBBQUAMGgxCzAJBgNV BAYTAlVLMRYwFAYDVQQKDA1PcGVuU1NMIEdyb3VwMSIwIAYDVQQLDBlGT1IgVEVT VElORyBQVVJQT1NFUyBPTkxZMR0wGwYDVQQDDBRPcGVuU1NMIFRlc3QgUm9vdCBD QTAeFw0xNDA1MjQxNDQ1MTFaFw0yNDA1MDExNDQ1MTFaMHAxCzAJBgNVBAYTAlVL MRYwFAYDVQQKDA1PcGVuU1NMIEdyb3VwMSIwIAYDVQQLDBlGT1IgVEVTVElORyBQ VVJQT1NFUyBPTkxZMSUwIwYDVQQDDBxPcGVuU1NMIFRlc3QgSW50ZXJtZWRpYXRl IENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsErw75CmLYD6pkrG W/YhAl/K8L5wJYxDjqu2FghxjD8K308W3EHq4uBxEwR1OHXaM1+6ZZw7/r2I37VL IdurBEAIEUdbzx0so74FPawgz5EW2CTqoJnK8F71/vo5Kj1VPwW46CxwxUR3cfvJ GNXND2ip0TcyTSPLROXOyQakcVfIGJmdSa1wHKi+c2gMA4emADudZUOYLrg80gr2 ldePm07ynbVsKKzCcStw8MdmoW9Qt3fLnPJn2TFUUBNWj+4kvL+88edWCVQXKNds ysD/CDrH4W/hjyPDStVsM6XpiNU0+L2ZY6fcj3OP8d0goOx45xotMn9m8hNkCGsr VXx9IwIDAQABo2MwYTAdBgNVHQ4EFgQUNsNsiOeV/rC97M4+PYarIYGH2towHwYD VR0jBBgwFoAUjBkP10IxdwUG4dOxn+s5+3hxOkUwDwYDVR0TAQH/BAUwAwEB/zAO BgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQEFBQADggEBAAIwwR8jyFN6qYGIRAKi ahyeHd26hNPC4RiCvjz6dytuvDUqfMTUZcjBy6Ez1Wsfs1/PC8u3IDpOTwZSz72K ACQzPpmXREWkO5nx8I+W+94yJsbklhsTxDlZj3X2oJCQ7qO4hdIpYESWfMchYra9 5e55SMBXeGDp+uRILt+6UfOXCGaXaoYqyrzQROJAiGy1x96A/5sU6ZU3KdKN1JLM XTZ268ihubCMRVScHnpYUjRDoGrhnQM7007ybVfRUGNXDs+ENqjGfyxc5ScR+Un4 UQtOd4zD2g9wrdXvlDiqxci6W7IOEPVP6qHG2GIh+T2zpO3GOAuZCe5cjLiCDATs hNw= -----END CERTIFICATE----- deps/libressl-pnacl-sys-2.1.6/libressl/tests/destest.c0000644000175000017500000006711512360020706017727 0ustar /* crypto/des/destest.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #define crypt(c,s) (DES_crypt((c),(s))) /* tisk tisk - the test keys don't all have odd parity :-( */ /* test data */ #define NUM_TESTS 34 static unsigned char key_data[NUM_TESTS][8]={ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, {0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11}, {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10}, {0x7C,0xA1,0x10,0x45,0x4A,0x1A,0x6E,0x57}, {0x01,0x31,0xD9,0x61,0x9D,0xC1,0x37,0x6E}, {0x07,0xA1,0x13,0x3E,0x4A,0x0B,0x26,0x86}, {0x38,0x49,0x67,0x4C,0x26,0x02,0x31,0x9E}, {0x04,0xB9,0x15,0xBA,0x43,0xFE,0xB5,0xB6}, {0x01,0x13,0xB9,0x70,0xFD,0x34,0xF2,0xCE}, {0x01,0x70,0xF1,0x75,0x46,0x8F,0xB5,0xE6}, {0x43,0x29,0x7F,0xAD,0x38,0xE3,0x73,0xFE}, {0x07,0xA7,0x13,0x70,0x45,0xDA,0x2A,0x16}, {0x04,0x68,0x91,0x04,0xC2,0xFD,0x3B,0x2F}, {0x37,0xD0,0x6B,0xB5,0x16,0xCB,0x75,0x46}, {0x1F,0x08,0x26,0x0D,0x1A,0xC2,0x46,0x5E}, {0x58,0x40,0x23,0x64,0x1A,0xBA,0x61,0x76}, {0x02,0x58,0x16,0x16,0x46,0x29,0xB0,0x07}, {0x49,0x79,0x3E,0xBC,0x79,0xB3,0x25,0x8F}, {0x4F,0xB0,0x5E,0x15,0x15,0xAB,0x73,0xA7}, {0x49,0xE9,0x5D,0x6D,0x4C,0xA2,0x29,0xBF}, {0x01,0x83,0x10,0xDC,0x40,0x9B,0x26,0xD6}, {0x1C,0x58,0x7F,0x1C,0x13,0x92,0x4F,0xEF}, {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, {0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E}, {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10}}; static unsigned char plain_data[NUM_TESTS][8]={ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, {0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x01}, {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11}, {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11}, {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, {0x01,0xA1,0xD6,0xD0,0x39,0x77,0x67,0x42}, {0x5C,0xD5,0x4C,0xA8,0x3D,0xEF,0x57,0xDA}, {0x02,0x48,0xD4,0x38,0x06,0xF6,0x71,0x72}, {0x51,0x45,0x4B,0x58,0x2D,0xDF,0x44,0x0A}, {0x42,0xFD,0x44,0x30,0x59,0x57,0x7F,0xA2}, {0x05,0x9B,0x5E,0x08,0x51,0xCF,0x14,0x3A}, {0x07,0x56,0xD8,0xE0,0x77,0x47,0x61,0xD2}, {0x76,0x25,0x14,0xB8,0x29,0xBF,0x48,0x6A}, {0x3B,0xDD,0x11,0x90,0x49,0x37,0x28,0x02}, {0x26,0x95,0x5F,0x68,0x35,0xAF,0x60,0x9A}, {0x16,0x4D,0x5E,0x40,0x4F,0x27,0x52,0x32}, {0x6B,0x05,0x6E,0x18,0x75,0x9F,0x5C,0xCA}, {0x00,0x4B,0xD6,0xEF,0x09,0x17,0x60,0x62}, {0x48,0x0D,0x39,0x00,0x6E,0xE7,0x62,0xF2}, {0x43,0x75,0x40,0xC8,0x69,0x8F,0x3C,0xFA}, {0x07,0x2D,0x43,0xA0,0x77,0x07,0x52,0x92}, {0x02,0xFE,0x55,0x77,0x81,0x17,0xF1,0x2A}, {0x1D,0x9D,0x5C,0x50,0x18,0xF7,0x28,0xC2}, {0x30,0x55,0x32,0x28,0x6D,0x6F,0x29,0x5A}, {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}}; static unsigned char cipher_data[NUM_TESTS][8]={ {0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7}, {0x73,0x59,0xB2,0x16,0x3E,0x4E,0xDC,0x58}, {0x95,0x8E,0x6E,0x62,0x7A,0x05,0x55,0x7B}, {0xF4,0x03,0x79,0xAB,0x9E,0x0E,0xC5,0x33}, {0x17,0x66,0x8D,0xFC,0x72,0x92,0x53,0x2D}, {0x8A,0x5A,0xE1,0xF8,0x1A,0xB8,0xF2,0xDD}, {0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7}, {0xED,0x39,0xD9,0x50,0xFA,0x74,0xBC,0xC4}, {0x69,0x0F,0x5B,0x0D,0x9A,0x26,0x93,0x9B}, {0x7A,0x38,0x9D,0x10,0x35,0x4B,0xD2,0x71}, {0x86,0x8E,0xBB,0x51,0xCA,0xB4,0x59,0x9A}, {0x71,0x78,0x87,0x6E,0x01,0xF1,0x9B,0x2A}, {0xAF,0x37,0xFB,0x42,0x1F,0x8C,0x40,0x95}, {0x86,0xA5,0x60,0xF1,0x0E,0xC6,0xD8,0x5B}, {0x0C,0xD3,0xDA,0x02,0x00,0x21,0xDC,0x09}, {0xEA,0x67,0x6B,0x2C,0xB7,0xDB,0x2B,0x7A}, {0xDF,0xD6,0x4A,0x81,0x5C,0xAF,0x1A,0x0F}, {0x5C,0x51,0x3C,0x9C,0x48,0x86,0xC0,0x88}, {0x0A,0x2A,0xEE,0xAE,0x3F,0xF4,0xAB,0x77}, {0xEF,0x1B,0xF0,0x3E,0x5D,0xFA,0x57,0x5A}, {0x88,0xBF,0x0D,0xB6,0xD7,0x0D,0xEE,0x56}, {0xA1,0xF9,0x91,0x55,0x41,0x02,0x0B,0x56}, {0x6F,0xBF,0x1C,0xAF,0xCF,0xFD,0x05,0x56}, {0x2F,0x22,0xE4,0x9B,0xAB,0x7C,0xA1,0xAC}, {0x5A,0x6B,0x61,0x2C,0xC2,0x6C,0xCE,0x4A}, {0x5F,0x4C,0x03,0x8E,0xD1,0x2B,0x2E,0x41}, {0x63,0xFA,0xC0,0xD0,0x34,0xD9,0xF7,0x93}, {0x61,0x7B,0x3A,0x0C,0xE8,0xF0,0x71,0x00}, {0xDB,0x95,0x86,0x05,0xF8,0xC8,0xC6,0x06}, {0xED,0xBF,0xD1,0xC6,0x6C,0x29,0xCC,0xC7}, {0x35,0x55,0x50,0xB2,0x15,0x0E,0x24,0x51}, {0xCA,0xAA,0xAF,0x4D,0xEA,0xF1,0xDB,0xAE}, {0xD5,0xD4,0x4F,0xF7,0x20,0x68,0x3D,0x0D}, {0x2A,0x2B,0xB0,0x08,0xDF,0x97,0xC2,0xF2}}; static unsigned char cipher_ecb2[NUM_TESTS-1][8]={ {0x92,0x95,0xB5,0x9B,0xB3,0x84,0x73,0x6E}, {0x19,0x9E,0x9D,0x6D,0xF3,0x9A,0xA8,0x16}, {0x2A,0x4B,0x4D,0x24,0x52,0x43,0x84,0x27}, {0x35,0x84,0x3C,0x01,0x9D,0x18,0xC5,0xB6}, {0x4A,0x5B,0x2F,0x42,0xAA,0x77,0x19,0x25}, {0xA0,0x6B,0xA9,0xB8,0xCA,0x5B,0x17,0x8A}, {0xAB,0x9D,0xB7,0xFB,0xED,0x95,0xF2,0x74}, {0x3D,0x25,0x6C,0x23,0xA7,0x25,0x2F,0xD6}, {0xB7,0x6F,0xAB,0x4F,0xBD,0xBD,0xB7,0x67}, {0x8F,0x68,0x27,0xD6,0x9C,0xF4,0x1A,0x10}, {0x82,0x57,0xA1,0xD6,0x50,0x5E,0x81,0x85}, {0xA2,0x0F,0x0A,0xCD,0x80,0x89,0x7D,0xFA}, {0xCD,0x2A,0x53,0x3A,0xDB,0x0D,0x7E,0xF3}, {0xD2,0xC2,0xBE,0x27,0xE8,0x1B,0x68,0xE3}, {0xE9,0x24,0xCF,0x4F,0x89,0x3C,0x5B,0x0A}, {0xA7,0x18,0xC3,0x9F,0xFA,0x9F,0xD7,0x69}, {0x77,0x2C,0x79,0xB1,0xD2,0x31,0x7E,0xB1}, {0x49,0xAB,0x92,0x7F,0xD0,0x22,0x00,0xB7}, {0xCE,0x1C,0x6C,0x7D,0x85,0xE3,0x4A,0x6F}, {0xBE,0x91,0xD6,0xE1,0x27,0xB2,0xE9,0x87}, {0x70,0x28,0xAE,0x8F,0xD1,0xF5,0x74,0x1A}, {0xAA,0x37,0x80,0xBB,0xF3,0x22,0x1D,0xDE}, {0xA6,0xC4,0xD2,0x5E,0x28,0x93,0xAC,0xB3}, {0x22,0x07,0x81,0x5A,0xE4,0xB7,0x1A,0xAD}, {0xDC,0xCE,0x05,0xE7,0x07,0xBD,0xF5,0x84}, {0x26,0x1D,0x39,0x2C,0xB3,0xBA,0xA5,0x85}, {0xB4,0xF7,0x0F,0x72,0xFB,0x04,0xF0,0xDC}, {0x95,0xBA,0xA9,0x4E,0x87,0x36,0xF2,0x89}, {0xD4,0x07,0x3A,0xF1,0x5A,0x17,0x82,0x0E}, {0xEF,0x6F,0xAF,0xA7,0x66,0x1A,0x7E,0x89}, {0xC1,0x97,0xF5,0x58,0x74,0x8A,0x20,0xE7}, {0x43,0x34,0xCF,0xDA,0x22,0xC4,0x86,0xC8}, {0x08,0xD7,0xB4,0xFB,0x62,0x9D,0x08,0x85}}; static unsigned char cbc_key [8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; static unsigned char cbc2_key[8]={0xf1,0xe0,0xd3,0xc2,0xb5,0xa4,0x97,0x86}; static unsigned char cbc3_key[8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}; static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}; /* Changed the following text constant to binary so it will work on ebcdic * machines :-) */ /* static char cbc_data[40]="7654321 Now is the time for \0001"; */ static unsigned char cbc_data[40]={ 0x37,0x36,0x35,0x34,0x33,0x32,0x31,0x20, 0x4E,0x6F,0x77,0x20,0x69,0x73,0x20,0x74, 0x68,0x65,0x20,0x74,0x69,0x6D,0x65,0x20, 0x66,0x6F,0x72,0x20,0x00,0x31,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; static unsigned char cbc_ok[32]={ 0xcc,0xd1,0x73,0xff,0xab,0x20,0x39,0xf4, 0xac,0xd8,0xae,0xfd,0xdf,0xd8,0xa1,0xeb, 0x46,0x8e,0x91,0x15,0x78,0x88,0xba,0x68, 0x1d,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4}; #ifdef SCREW_THE_PARITY #error "SCREW_THE_PARITY is not ment to be defined." #error "Original vectors are preserved for reference only." static unsigned char cbc2_key[8]={0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87}; static unsigned char xcbc_ok[32]={ 0x86,0x74,0x81,0x0D,0x61,0xA4,0xA5,0x48, 0xB9,0x93,0x03,0xE1,0xB8,0xBB,0xBD,0xBD, 0x64,0x30,0x0B,0xB9,0x06,0x65,0x81,0x76, 0x04,0x1D,0x77,0x62,0x17,0xCA,0x2B,0xD2, }; #else static unsigned char xcbc_ok[32]={ 0x84,0x6B,0x29,0x14,0x85,0x1E,0x9A,0x29, 0x54,0x73,0x2F,0x8A,0xA0,0xA6,0x11,0xC1, 0x15,0xCD,0xC2,0xD7,0x95,0x1B,0x10,0x53, 0xA6,0x3C,0x5E,0x03,0xB2,0x1A,0xA3,0xC4, }; #endif static unsigned char cbc3_ok[32]={ 0x3F,0xE3,0x01,0xC9,0x62,0xAC,0x01,0xD0, 0x22,0x13,0x76,0x3C,0x1C,0xBD,0x4C,0xDC, 0x79,0x96,0x57,0xC0,0x64,0xEC,0xF5,0xD4, 0x1C,0x67,0x38,0x12,0xCF,0xDE,0x96,0x75}; static unsigned char pcbc_ok[32]={ 0xcc,0xd1,0x73,0xff,0xab,0x20,0x39,0xf4, 0x6d,0xec,0xb4,0x70,0xa0,0xe5,0x6b,0x15, 0xae,0xa6,0xbf,0x61,0xed,0x7d,0x9c,0x9f, 0xf7,0x17,0x46,0x3b,0x8a,0xb3,0xcc,0x88}; static unsigned char cfb_key[8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; static unsigned char cfb_iv[8]={0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef}; static unsigned char cfb_buf1[40],cfb_buf2[40],cfb_tmp[8]; static unsigned char plain[24]= { 0x4e,0x6f,0x77,0x20,0x69,0x73, 0x20,0x74,0x68,0x65,0x20,0x74, 0x69,0x6d,0x65,0x20,0x66,0x6f, 0x72,0x20,0x61,0x6c,0x6c,0x20 }; static unsigned char cfb_cipher8[24]= { 0xf3,0x1f,0xda,0x07,0x01,0x14, 0x62,0xee,0x18,0x7f,0x43,0xd8, 0x0a,0x7c,0xd9,0xb5,0xb0,0xd2, 0x90,0xda,0x6e,0x5b,0x9a,0x87 }; static unsigned char cfb_cipher16[24]={ 0xF3,0x09,0x87,0x87,0x7F,0x57, 0xF7,0x3C,0x36,0xB6,0xDB,0x70, 0xD8,0xD5,0x34,0x19,0xD3,0x86, 0xB2,0x23,0xB7,0xB2,0xAD,0x1B }; static unsigned char cfb_cipher32[24]={ 0xF3,0x09,0x62,0x49,0xA4,0xDF, 0xA4,0x9F,0x33,0xDC,0x7B,0xAD, 0x4C,0xC8,0x9F,0x64,0xE4,0x53, 0xE5,0xEC,0x67,0x20,0xDA,0xB6 }; static unsigned char cfb_cipher48[24]={ 0xF3,0x09,0x62,0x49,0xC7,0xF4, 0x30,0xB5,0x15,0xEC,0xBB,0x85, 0x97,0x5A,0x13,0x8C,0x68,0x60, 0xE2,0x38,0x34,0x3C,0xDC,0x1F }; static unsigned char cfb_cipher64[24]={ 0xF3,0x09,0x62,0x49,0xC7,0xF4, 0x6E,0x51,0xA6,0x9E,0x83,0x9B, 0x1A,0x92,0xF7,0x84,0x03,0x46, 0x71,0x33,0x89,0x8E,0xA6,0x22 }; static unsigned char ofb_key[8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; static unsigned char ofb_iv[8]={0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef}; static unsigned char ofb_buf1[24],ofb_buf2[24],ofb_tmp[8]; static unsigned char ofb_cipher[24]= { 0xf3,0x09,0x62,0x49,0xc7,0xf4,0x6e,0x51, 0x35,0xf2,0x4a,0x24,0x2e,0xeb,0x3d,0x3f, 0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3 }; #if 0 static DES_LONG cbc_cksum_ret=0xB462FEF7L; #else static DES_LONG cbc_cksum_ret=0xF7FE62B4L; #endif static unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4}; static char *pt(unsigned char *p); static int cfb_test(int bits, unsigned char *cfb_cipher); static int cfb64_test(unsigned char *cfb_cipher); static int ede_cfb64_test(unsigned char *cfb_cipher); int main(int argc, char *argv[]) { int j,err=0; unsigned int i; DES_cblock in,out,outin,iv3,iv2; DES_key_schedule ks,ks2,ks3; unsigned char cbc_in[40]; unsigned char cbc_out[40]; DES_LONG cs; unsigned char cret[8]; DES_LONG lqret[4]; int num; char *str; #ifndef OPENSSL_NO_DESCBCM printf("Doing cbcm\n"); if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0) { printf("Key error %d\n",j); err=1; } if ((j=DES_set_key_checked(&cbc2_key,&ks2)) != 0) { printf("Key error %d\n",j); err=1; } if ((j=DES_set_key_checked(&cbc3_key,&ks3)) != 0) { printf("Key error %d\n",j); err=1; } memset(cbc_out,0,40); memset(cbc_in,0,40); i=strlen((char *)cbc_data)+1; /* i=((i+7)/8)*8; */ memcpy(iv3,cbc_iv,sizeof(cbc_iv)); memset(iv2,'\0',sizeof iv2); DES_ede3_cbcm_encrypt(cbc_data,cbc_out,16L,&ks,&ks2,&ks3,&iv3,&iv2, DES_ENCRYPT); DES_ede3_cbcm_encrypt(&cbc_data[16],&cbc_out[16],i-16,&ks,&ks2,&ks3, &iv3,&iv2,DES_ENCRYPT); /* if (memcmp(cbc_out,cbc3_ok, (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0) { printf("des_ede3_cbc_encrypt encrypt error\n"); err=1; } */ memcpy(iv3,cbc_iv,sizeof(cbc_iv)); memset(iv2,'\0',sizeof iv2); DES_ede3_cbcm_encrypt(cbc_out,cbc_in,i,&ks,&ks2,&ks3,&iv3,&iv2,DES_DECRYPT); if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) { unsigned int n; printf("des_ede3_cbcm_encrypt decrypt error\n"); for(n=0 ; n < i ; ++n) printf(" %02x",cbc_data[n]); printf("\n"); for(n=0 ; n < i ; ++n) printf(" %02x",cbc_in[n]); printf("\n"); err=1; } #endif printf("Doing ecb\n"); for (i=0; i>4)&0xf]; ret[i*2+1]=f[p[i]&0xf]; } ret[16]='\0'; return(ret); } static int cfb_test(int bits, unsigned char *cfb_cipher) { DES_key_schedule ks; int i,err=0; DES_set_key_checked(&cfb_key,&ks); memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); DES_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),&ks,&cfb_tmp, DES_ENCRYPT); if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0) { err=1; printf("cfb_encrypt encrypt error\n"); for (i=0; i<24; i+=8) printf("%s\n",pt(&(cfb_buf1[i]))); } memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); DES_cfb_encrypt(cfb_buf1,cfb_buf2,bits,sizeof(plain),&ks,&cfb_tmp, DES_DECRYPT); if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) { err=1; printf("cfb_encrypt decrypt error\n"); for (i=0; i<24; i+=8) printf("%s\n",pt(&(cfb_buf1[i]))); } return(err); } static int cfb64_test(unsigned char *cfb_cipher) { DES_key_schedule ks; int err=0,i,n; DES_set_key_checked(&cfb_key,&ks); memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); n=0; DES_cfb64_encrypt(plain,cfb_buf1,12,&ks,&cfb_tmp,&n,DES_ENCRYPT); DES_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),sizeof(plain)-12,&ks, &cfb_tmp,&n,DES_ENCRYPT); if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0) { err=1; printf("cfb_encrypt encrypt error\n"); for (i=0; i<24; i+=8) printf("%s\n",pt(&(cfb_buf1[i]))); } memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); n=0; DES_cfb64_encrypt(cfb_buf1,cfb_buf2,17,&ks,&cfb_tmp,&n,DES_DECRYPT); DES_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]), sizeof(plain)-17,&ks,&cfb_tmp,&n,DES_DECRYPT); if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) { err=1; printf("cfb_encrypt decrypt error\n"); for (i=0; i<24; i+=8) printf("%s\n",pt(&(cfb_buf2[i]))); } return(err); } static int ede_cfb64_test(unsigned char *cfb_cipher) { DES_key_schedule ks; int err=0,i,n; DES_set_key_checked(&cfb_key,&ks); memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); n=0; DES_ede3_cfb64_encrypt(plain,cfb_buf1,12,&ks,&ks,&ks,&cfb_tmp,&n, DES_ENCRYPT); DES_ede3_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]), sizeof(plain)-12,&ks,&ks,&ks, &cfb_tmp,&n,DES_ENCRYPT); if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0) { err=1; printf("ede_cfb_encrypt encrypt error\n"); for (i=0; i<24; i+=8) printf("%s\n",pt(&(cfb_buf1[i]))); } memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); n=0; DES_ede3_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,&ks,&ks,&ks, &cfb_tmp,&n,DES_DECRYPT); DES_ede3_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]), sizeof(plain)-17,&ks,&ks,&ks, &cfb_tmp,&n,DES_DECRYPT); if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) { err=1; printf("ede_cfb_encrypt decrypt error\n"); for (i=0; i<24; i+=8) printf("%s\n",pt(&(cfb_buf2[i]))); } return(err); } deps/libressl-pnacl-sys-2.1.6/libressl/tests/biotest.c0000644000175000017500000000702512360020706017717 0ustar /* $OpenBSD: biotest.c,v 1.3 2014/07/08 14:17:38 bcook Exp $ */ /* * Copyright (c) 2014 Joel Sing * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include #include struct bio_get_host_ip_test { char *input; uint32_t ip; int ret; }; struct bio_get_host_ip_test bio_get_host_ip_tests[] = { {"", 0, 0}, {".", 0, 0}, {"1", 0, 0}, {"1.2", 0, 0}, {"1.2.3", 0, 0}, {"1.2.3.", 0, 0}, {"1.2.3.4", 0x01020304, 1}, {"1.2.3.256", 0, 0}, {"1:2:3::4", 0, 0}, {"0.0.0.0", INADDR_ANY, 1}, {"127.0.0.1", INADDR_LOOPBACK, 1}, {"localhost", INADDR_LOOPBACK, 1}, {"255.255.255.255", INADDR_BROADCAST, 1}, {"0xff.0xff.0xff.0xff", 0, 0}, }; #define N_BIO_GET_IP_TESTS \ (sizeof(bio_get_host_ip_tests) / sizeof(*bio_get_host_ip_tests)) struct bio_get_port_test { char *input; unsigned short port; int ret; }; struct bio_get_port_test bio_get_port_tests[] = { {NULL, 0, 0}, {"", 0, 0}, {"-1", 0, 0}, {"0", 0, 1}, {"1", 1, 1}, {"12345", 12345, 1}, {"65535", 65535, 1}, {"65536", 0, 0}, {"999999999999", 0, 0}, {"xyzzy", 0, 0}, {"https", 443, 1}, {"imaps", 993, 1}, {"telnet", 23, 1}, }; #define N_BIO_GET_PORT_TESTS \ (sizeof(bio_get_port_tests) / sizeof(*bio_get_port_tests)) static int do_bio_get_host_ip_tests(void) { struct bio_get_host_ip_test *bgit; unsigned char ip[4]; int failed = 0; size_t i; int ret; for (i = 0; i < N_BIO_GET_IP_TESTS; i++) { bgit = &bio_get_host_ip_tests[i]; memset(ip, 0, sizeof(*ip)); ret = BIO_get_host_ip(bgit->input, ip); if (ret != bgit->ret) { fprintf(stderr, "FAIL: test %zi (\"%s\") %s, want %s\n", i, bgit->input, ret ? "success" : "failure", bgit->ret ? "success" : "failure"); failed = 1; continue; } if (ret && ntohl(*((uint32_t *)ip)) != bgit->ip) { fprintf(stderr, "FAIL: test %zi (\"%s\") returned ip " "%x != %x\n", i, bgit->input, ntohl(*((uint32_t *)ip)), bgit->ip); failed = 1; } } return failed; } static int do_bio_get_port_tests(void) { struct bio_get_port_test *bgpt; unsigned short port; int failed = 0; size_t i; int ret; for (i = 0; i < N_BIO_GET_PORT_TESTS; i++) { bgpt = &bio_get_port_tests[i]; port = 0; ret = BIO_get_port(bgpt->input, &port); if (ret != bgpt->ret) { fprintf(stderr, "FAIL: test %zi (\"%s\") %s, want %s\n", i, bgpt->input, ret ? "success" : "failure", bgpt->ret ? "success" : "failure"); failed = 1; continue; } if (ret && port != bgpt->port) { fprintf(stderr, "FAIL: test %zi (\"%s\") returned port " "%u != %u\n", i, bgpt->input, port, bgpt->port); failed = 1; } } return failed; } int main(int argc, char **argv) { int ret = 0; ret |= do_bio_get_host_ip_tests(); ret |= do_bio_get_port_tests(); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/tests/gcm128test.c0000644000175000017500000006704312360020706020155 0ustar /* ==================================================================== * Copyright (c) 2010 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== */ #include #include #include #include #include #include #include /* XXX - something like this should be in the public headers. */ struct gcm128_context { uint64_t opaque[64]; }; struct gcm128_test { const uint8_t K[128]; size_t K_len; const uint8_t IV[128]; size_t IV_len; const uint8_t P[512]; size_t P_len; const uint8_t A[128]; size_t A_len; const uint8_t C[512]; size_t C_len; const uint8_t T[16]; }; struct gcm128_test gcm128_tests[] = { { /* Test Case 1. */ .K = {}, .K_len = 16, .IV = {}, .IV_len = 12, .P = {}, .P_len = 0, .A = {}, .A_len = 0, .C = {}, .C_len = 0, .T = { 0x58, 0xe2, 0xfc, 0xce, 0xfa, 0x7e, 0x30, 0x61, 0x36, 0x7f, 0x1d, 0x57, 0xa4, 0xe7, 0x45, 0x5a, }, }, { /* Test Case 2. */ .K = {}, .K_len = 16, .IV = {}, .IV_len = 12, .P = {}, .P_len = 16, .A = {}, .A_len = 0, .C = { 0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92, 0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78, }, .C_len = 16, .T = { 0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd, 0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf, }, }, { /* Test Case 3. */ .K = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, }, .K_len = 16, .IV = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88, }, .IV_len = 12, .P = { 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55, }, .P_len = 64, .A = {}, .A_len = 0, .C = { 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, 0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c, 0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0, 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e, 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c, 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05, 0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97, 0x3d, 0x58, 0xe0, 0x91, 0x47, 0x3f, 0x59, 0x85, }, .C_len = 64, .T = { 0x4d, 0x5c, 0x2a, 0xf3, 0x27, 0xcd, 0x64, 0xa6, 0x2c, 0xf3, 0x5a, 0xbd, 0x2b, 0xa6, 0xfa, 0xb4, } }, { /* Test Case 4. */ .K = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, }, .K_len = 16, .IV = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88, }, .IV_len = 12, .P = { 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, }, .P_len = 60, .A = { 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xab, 0xad, 0xda, 0xd2, }, .A_len = 20, .C = { 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, 0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c, 0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0, 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e, 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c, 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05, 0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97, 0x3d, 0x58, 0xe0, 0x91, }, .C_len = 60, .T = { 0x5b, 0xc9, 0x4f, 0xbc, 0x32, 0x21, 0xa5, 0xdb, 0x94, 0xfa, 0xe9, 0x5a, 0xe7, 0x12, 0x1a, 0x47, }, }, { /* Test Case 5. */ /* K, P, A are the same as TC4. */ .K = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, }, .K_len = 16, .IV = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, }, .IV_len = 8, .P = { 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, }, .P_len = 60, .A = { 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xab, 0xad, 0xda, 0xd2, }, .A_len = 20, .C = { 0x61, 0x35, 0x3b, 0x4c, 0x28, 0x06, 0x93, 0x4a, 0x77, 0x7f, 0xf5, 0x1f, 0xa2, 0x2a, 0x47, 0x55, 0x69, 0x9b, 0x2a, 0x71, 0x4f, 0xcd, 0xc6, 0xf8, 0x37, 0x66, 0xe5, 0xf9, 0x7b, 0x6c, 0x74, 0x23, 0x73, 0x80, 0x69, 0x00, 0xe4, 0x9f, 0x24, 0xb2, 0x2b, 0x09, 0x75, 0x44, 0xd4, 0x89, 0x6b, 0x42, 0x49, 0x89, 0xb5, 0xe1, 0xeb, 0xac, 0x0f, 0x07, 0xc2, 0x3f, 0x45, 0x98, }, .C_len = 60, .T = { 0x36, 0x12, 0xd2, 0xe7, 0x9e, 0x3b, 0x07, 0x85, 0x56, 0x1b, 0xe1, 0x4a, 0xac, 0xa2, 0xfc, 0xcb, }, }, { /* Test Case 6. */ /* K, P, A are the same as TC4. */ .K = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, }, .K_len = 16, .IV = { 0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5, 0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa, 0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1, 0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28, 0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39, 0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54, 0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57, 0xa6, 0x37, 0xb3, 0x9b, }, .IV_len = 60, .P = { 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, }, .P_len = 60, .A = { 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xab, 0xad, 0xda, 0xd2, }, .A_len = 20, .C = { 0x8c, 0xe2, 0x49, 0x98, 0x62, 0x56, 0x15, 0xb6, 0x03, 0xa0, 0x33, 0xac, 0xa1, 0x3f, 0xb8, 0x94, 0xbe, 0x91, 0x12, 0xa5, 0xc3, 0xa2, 0x11, 0xa8, 0xba, 0x26, 0x2a, 0x3c, 0xca, 0x7e, 0x2c, 0xa7, 0x01, 0xe4, 0xa9, 0xa4, 0xfb, 0xa4, 0x3c, 0x90, 0xcc, 0xdc, 0xb2, 0x81, 0xd4, 0x8c, 0x7c, 0x6f, 0xd6, 0x28, 0x75, 0xd2, 0xac, 0xa4, 0x17, 0x03, 0x4c, 0x34, 0xae, 0xe5, }, .C_len = 60, .T = { 0x61, 0x9c, 0xc5, 0xae, 0xff, 0xfe, 0x0b, 0xfa, 0x46, 0x2a, 0xf4, 0x3c, 0x16, 0x99, 0xd0, 0x50, }, }, { /* Test Case 7. */ .K = {}, .K_len = 24, .IV = {}, .IV_len = 12, .P = {}, .P_len = 0, .A = {}, .A_len = 0, .C = {}, .C_len = 0, .T = { 0xcd, 0x33, 0xb2, 0x8a, 0xc7, 0x73, 0xf7, 0x4b, 0xa0, 0x0e, 0xd1, 0xf3, 0x12, 0x57, 0x24, 0x35, }, }, { /* Test Case 8. */ .K = {}, .K_len = 24, .IV = {}, .IV_len = 12, .P = {}, .P_len = 16, .A = {}, .A_len = 0, .C = { 0x98, 0xe7, 0x24, 0x7c, 0x07, 0xf0, 0xfe, 0x41, 0x1c, 0x26, 0x7e, 0x43, 0x84, 0xb0, 0xf6, 0x00, }, .C_len = 16, .T = { 0x2f, 0xf5, 0x8d, 0x80, 0x03, 0x39, 0x27, 0xab, 0x8e, 0xf4, 0xd4, 0x58, 0x75, 0x14, 0xf0, 0xfb, }, }, { /* Test Case 9. */ .K = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, }, .K_len = 24, .IV = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88, }, .IV_len = 12, .P = { 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55, }, .P_len = 64, .A = {}, .A_len = 0, .C = { 0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41, 0xeb, 0x06, 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57, 0x85, 0x9e, 0x1c, 0xea, 0xa6, 0xef, 0xd9, 0x84, 0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1, 0xe1, 0x9c, 0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25, 0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47, 0x18, 0xe2, 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9, 0xcc, 0xda, 0x27, 0x10, 0xac, 0xad, 0xe2, 0x56, }, .C_len = 64, .T = { 0x99, 0x24, 0xa7, 0xc8, 0x58, 0x73, 0x36, 0xbf, 0xb1, 0x18, 0x02, 0x4d, 0xb8, 0x67, 0x4a, 0x14, }, }, { /* Test Case 10. */ /* K and IV are the same as TC9. */ .K = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, }, .K_len = 24, .IV = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88, }, .IV_len = 12, .P = { 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, }, .P_len = 60, .A = { 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xab, 0xad, 0xda, 0xd2, }, .A_len = 20, .C = { 0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41, 0xeb, 0x06, 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57, 0x85, 0x9e, 0x1c, 0xea, 0xa6, 0xef, 0xd9, 0x84, 0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1, 0xe1, 0x9c, 0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25, 0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47, 0x18, 0xe2, 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9, 0xcc, 0xda, 0x27, 0x10, }, .C_len = 60, .T = { 0x25, 0x19, 0x49, 0x8e, 0x80, 0xf1, 0x47, 0x8f, 0x37, 0xba, 0x55, 0xbd, 0x6d, 0x27, 0x61, 0x8c, }, }, { /* Test Case 11. */ /* K is the same as TC9, P and A are the same as TC10. */ .K = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, }, .K_len = 24, .IV = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, }, .IV_len = 8, .P = { 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, }, .P_len = 60, .A = { 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xab, 0xad, 0xda, 0xd2, }, .A_len = 20, .C = { 0x0f, 0x10, 0xf5, 0x99, 0xae, 0x14, 0xa1, 0x54, 0xed, 0x24, 0xb3, 0x6e, 0x25, 0x32, 0x4d, 0xb8, 0xc5, 0x66, 0x63, 0x2e, 0xf2, 0xbb, 0xb3, 0x4f, 0x83, 0x47, 0x28, 0x0f, 0xc4, 0x50, 0x70, 0x57, 0xfd, 0xdc, 0x29, 0xdf, 0x9a, 0x47, 0x1f, 0x75, 0xc6, 0x65, 0x41, 0xd4, 0xd4, 0xda, 0xd1, 0xc9, 0xe9, 0x3a, 0x19, 0xa5, 0x8e, 0x8b, 0x47, 0x3f, 0xa0, 0xf0, 0x62, 0xf7 }, .C_len = 60, .T = { 0x65, 0xdc, 0xc5, 0x7f, 0xcf, 0x62, 0x3a, 0x24, 0x09, 0x4f, 0xcc, 0xa4, 0x0d, 0x35, 0x33, 0xf8, }, }, { /* Test Case 12. */ /* K is the same as TC9, P and A are the same as TC10. */ .K = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, }, .K_len = 24, .IV = { 0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5, 0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa, 0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1, 0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28, 0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39, 0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54, 0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57, 0xa6, 0x37, 0xb3, 0x9b, }, .IV_len = 60, .P = { 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, }, .P_len = 60, .A = { 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xab, 0xad, 0xda, 0xd2, }, .A_len = 20, .C = { 0xd2, 0x7e, 0x88, 0x68, 0x1c, 0xe3, 0x24, 0x3c, 0x48, 0x30, 0x16, 0x5a, 0x8f, 0xdc, 0xf9, 0xff, 0x1d, 0xe9, 0xa1, 0xd8, 0xe6, 0xb4, 0x47, 0xef, 0x6e, 0xf7, 0xb7, 0x98, 0x28, 0x66, 0x6e, 0x45, 0x81, 0xe7, 0x90, 0x12, 0xaf, 0x34, 0xdd, 0xd9, 0xe2, 0xf0, 0x37, 0x58, 0x9b, 0x29, 0x2d, 0xb3, 0xe6, 0x7c, 0x03, 0x67, 0x45, 0xfa, 0x22, 0xe7, 0xe9, 0xb7, 0x37, 0x3b, }, .C_len = 60, .T = { 0xdc, 0xf5, 0x66, 0xff, 0x29, 0x1c, 0x25, 0xbb, 0xb8, 0x56, 0x8f, 0xc3, 0xd3, 0x76, 0xa6, 0xd9, }, }, { /* Test Case 13. */ .K = {}, .K_len = 32, .IV = {}, .IV_len = 12, .P = {}, .P_len = 0, .A = {}, .A_len = 0, .C = {}, .C_len = 0, .T = { 0x53, 0x0f, 0x8a, 0xfb, 0xc7, 0x45, 0x36, 0xb9, 0xa9, 0x63, 0xb4, 0xf1, 0xc4, 0xcb, 0x73, 0x8b, }, }, { /* Test Case 14. */ .K = {}, .K_len = 32, .IV = {}, .IV_len = 12, .P = {}, .P_len = 16, .A = {}, .A_len = 0, .C = { 0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e, 0x07, 0x4e, 0xc5, 0xd3, 0xba, 0xf3, 0x9d, 0x18, }, .C_len = 16, .T = { 0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0, 0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19, }, }, { /* Test Case 15. */ .K = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, }, .K_len = 32, .IV = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88, }, .IV_len = 12, .P = { 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55, }, .P_len = 64, .A = {}, .A_len = 0, .C = { 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07, 0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d, 0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9, 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa, 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d, 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38, 0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a, 0xbc, 0xc9, 0xf6, 0x62, 0x89, 0x80, 0x15, 0xad, }, .C_len = 64, .T = { 0xb0, 0x94, 0xda, 0xc5, 0xd9, 0x34, 0x71, 0xbd, 0xec, 0x1a, 0x50, 0x22, 0x70, 0xe3, 0xcc, 0x6c, }, }, { /* Test Case 16. */ /* K and IV are the same as TC15. */ .K = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, }, .K_len = 32, .IV = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88, }, .IV_len = 12, .P = { 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, }, .P_len = 60, .A = { 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xab, 0xad, 0xda, 0xd2, }, .A_len = 20, .C = { 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07, 0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d, 0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9, 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa, 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d, 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38, 0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a, 0xbc, 0xc9, 0xf6, 0x62, }, .C_len = 60, .T = { 0x76, 0xfc, 0x6e, 0xce, 0x0f, 0x4e, 0x17, 0x68, 0xcd, 0xdf, 0x88, 0x53, 0xbb, 0x2d, 0x55, 0x1b, }, }, { /* Test Case 17. */ /* K is the same as TC15, P and A are the same as TC 16. */ .K = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, }, .K_len = 32, .IV = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, }, .IV_len = 8, .P = { 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, }, .P_len = 60, .A = { 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xab, 0xad, 0xda, 0xd2, }, .A_len = 20, .C = { 0xc3, 0x76, 0x2d, 0xf1, 0xca, 0x78, 0x7d, 0x32, 0xae, 0x47, 0xc1, 0x3b, 0xf1, 0x98, 0x44, 0xcb, 0xaf, 0x1a, 0xe1, 0x4d, 0x0b, 0x97, 0x6a, 0xfa, 0xc5, 0x2f, 0xf7, 0xd7, 0x9b, 0xba, 0x9d, 0xe0, 0xfe, 0xb5, 0x82, 0xd3, 0x39, 0x34, 0xa4, 0xf0, 0x95, 0x4c, 0xc2, 0x36, 0x3b, 0xc7, 0x3f, 0x78, 0x62, 0xac, 0x43, 0x0e, 0x64, 0xab, 0xe4, 0x99, 0xf4, 0x7c, 0x9b, 0x1f, }, .C_len = 60, .T = { 0x3a, 0x33, 0x7d, 0xbf, 0x46, 0xa7, 0x92, 0xc4, 0x5e, 0x45, 0x49, 0x13, 0xfe, 0x2e, 0xa8, 0xf2, }, }, { /* Test Case 18. */ /* K is the same as TC15, P and A are the same as TC 16. */ .K = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, }, .K_len = 32, .IV = { 0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5, 0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa, 0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1, 0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28, 0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39, 0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54, 0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57, 0xa6, 0x37, 0xb3, 0x9b, }, .IV_len = 60, .P = { 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, }, .P_len = 60, .A = { 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 0xab, 0xad, 0xda, 0xd2, }, .A_len = 20, .C = { 0x5a, 0x8d, 0xef, 0x2f, 0x0c, 0x9e, 0x53, 0xf1, 0xf7, 0x5d, 0x78, 0x53, 0x65, 0x9e, 0x2a, 0x20, 0xee, 0xb2, 0xb2, 0x2a, 0xaf, 0xde, 0x64, 0x19, 0xa0, 0x58, 0xab, 0x4f, 0x6f, 0x74, 0x6b, 0xf4, 0x0f, 0xc0, 0xc3, 0xb7, 0x80, 0xf2, 0x44, 0x45, 0x2d, 0xa3, 0xeb, 0xf1, 0xc5, 0xd8, 0x2c, 0xde, 0xa2, 0x41, 0x89, 0x97, 0x20, 0x0e, 0xf8, 0x2e, 0x44, 0xae, 0x7e, 0x3f, }, .C_len = 60, .T = { 0xa4, 0x4a, 0x82, 0x66, 0xee, 0x1c, 0x8e, 0xb0, 0xc8, 0xb5, 0xd4, 0xcf, 0x5a, 0xe9, 0xf1, 0x9a, }, }, { /* Test Case 19. */ .K = {}, .K_len = 16, .IV = {}, .IV_len = 12, .P = {}, .P_len = 0, .A = { 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55, 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07, 0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d, 0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9, 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa, 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d, 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38, 0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a, 0xbc, 0xc9, 0xf6, 0x62, 0x89, 0x80, 0x15, 0xad, }, .A_len = 128, .C = {}, .C_len = 0, .T = { 0x5f, 0xea, 0x79, 0x3a, 0x2d, 0x6f, 0x97, 0x4d, 0x37, 0xe6, 0x8e, 0x0c, 0xb8, 0xff, 0x94, 0x92, }, }, { /* Test Case 20. */ .K = {}, .K_len = 16, .IV = { /* This results in 0xff in counter LSB. */ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, .IV_len = 64, .P = {}, .P_len = 288, .A = {}, .A_len = 0, .C = { 0x56, 0xb3, 0x37, 0x3c, 0xa9, 0xef, 0x6e, 0x4a, 0x2b, 0x64, 0xfe, 0x1e, 0x9a, 0x17, 0xb6, 0x14, 0x25, 0xf1, 0x0d, 0x47, 0xa7, 0x5a, 0x5f, 0xce, 0x13, 0xef, 0xc6, 0xbc, 0x78, 0x4a, 0xf2, 0x4f, 0x41, 0x41, 0xbd, 0xd4, 0x8c, 0xf7, 0xc7, 0x70, 0x88, 0x7a, 0xfd, 0x57, 0x3c, 0xca, 0x54, 0x18, 0xa9, 0xae, 0xff, 0xcd, 0x7c, 0x5c, 0xed, 0xdf, 0xc6, 0xa7, 0x83, 0x97, 0xb9, 0xa8, 0x5b, 0x49, 0x9d, 0xa5, 0x58, 0x25, 0x72, 0x67, 0xca, 0xab, 0x2a, 0xd0, 0xb2, 0x3c, 0xa4, 0x76, 0xa5, 0x3c, 0xb1, 0x7f, 0xb4, 0x1c, 0x4b, 0x8b, 0x47, 0x5c, 0xb4, 0xf3, 0xf7, 0x16, 0x50, 0x94, 0xc2, 0x29, 0xc9, 0xe8, 0xc4, 0xdc, 0x0a, 0x2a, 0x5f, 0xf1, 0x90, 0x3e, 0x50, 0x15, 0x11, 0x22, 0x13, 0x76, 0xa1, 0xcd, 0xb8, 0x36, 0x4c, 0x50, 0x61, 0xa2, 0x0c, 0xae, 0x74, 0xbc, 0x4a, 0xcd, 0x76, 0xce, 0xb0, 0xab, 0xc9, 0xfd, 0x32, 0x17, 0xef, 0x9f, 0x8c, 0x90, 0xbe, 0x40, 0x2d, 0xdf, 0x6d, 0x86, 0x97, 0xf4, 0xf8, 0x80, 0xdf, 0xf1, 0x5b, 0xfb, 0x7a, 0x6b, 0x28, 0x24, 0x1e, 0xc8, 0xfe, 0x18, 0x3c, 0x2d, 0x59, 0xe3, 0xf9, 0xdf, 0xff, 0x65, 0x3c, 0x71, 0x26, 0xf0, 0xac, 0xb9, 0xe6, 0x42, 0x11, 0xf4, 0x2b, 0xae, 0x12, 0xaf, 0x46, 0x2b, 0x10, 0x70, 0xbe, 0xf1, 0xab, 0x5e, 0x36, 0x06, 0x87, 0x2c, 0xa1, 0x0d, 0xee, 0x15, 0xb3, 0x24, 0x9b, 0x1a, 0x1b, 0x95, 0x8f, 0x23, 0x13, 0x4c, 0x4b, 0xcc, 0xb7, 0xd0, 0x32, 0x00, 0xbc, 0xe4, 0x20, 0xa2, 0xf8, 0xeb, 0x66, 0xdc, 0xf3, 0x64, 0x4d, 0x14, 0x23, 0xc1, 0xb5, 0x69, 0x90, 0x03, 0xc1, 0x3e, 0xce, 0xf4, 0xbf, 0x38, 0xa3, 0xb6, 0x0e, 0xed, 0xc3, 0x40, 0x33, 0xba, 0xc1, 0x90, 0x27, 0x83, 0xdc, 0x6d, 0x89, 0xe2, 0xe7, 0x74, 0x18, 0x8a, 0x43, 0x9c, 0x7e, 0xbc, 0xc0, 0x67, 0x2d, 0xbd, 0xa4, 0xdd, 0xcf, 0xb2, 0x79, 0x46, 0x13, 0xb0, 0xbe, 0x41, 0x31, 0x5e, 0xf7, 0x78, 0x70, 0x8a, 0x70, 0xee, 0x7d, 0x75, 0x16, 0x5c, }, .C_len = 288, .T = { 0x8b, 0x30, 0x7f, 0x6b, 0x33, 0x28, 0x6d, 0x0a, 0xb0, 0x26, 0xa9, 0xed, 0x3f, 0xe1, 0xe8, 0x5f, }, }, }; #define N_TESTS (sizeof(gcm128_tests) / sizeof(*gcm128_tests)) static int do_gcm128_test(int test_no, struct gcm128_test *tv) { GCM128_CONTEXT ctx; AES_KEY key; uint8_t *out; size_t out_len; int ret = 1; out_len = tv->P_len; out = malloc(out_len); if (out == NULL) err(1, "malloc"); AES_set_encrypt_key(tv->K, tv->K_len * 8, &key); memset(out, 0, out_len); CRYPTO_gcm128_init(&ctx, &key, (block128_f)AES_encrypt); CRYPTO_gcm128_setiv(&ctx, tv->IV, tv->IV_len); if (tv->A_len > 0) CRYPTO_gcm128_aad(&ctx, tv->A, tv->A_len); if (tv->P_len > 0) CRYPTO_gcm128_encrypt(&ctx, tv->P, out, out_len); if (CRYPTO_gcm128_finish(&ctx, tv->T, 16)) { fprintf(stderr, "TEST %i: CRYPTO_gcm128_finish failed\n", test_no); goto fail; } if (tv->C_len > 0 && memcmp(out, tv->C, out_len)) { fprintf(stderr, "TEST %i: encrypt failed\n", test_no); goto fail; } memset(out, 0, out_len); CRYPTO_gcm128_setiv(&ctx, tv->IV, tv->IV_len); if (tv->A_len > 0) CRYPTO_gcm128_aad(&ctx, tv->A, tv->A_len); if (tv->C_len > 0) CRYPTO_gcm128_decrypt(&ctx, tv->C, out, out_len); if (CRYPTO_gcm128_finish(&ctx, tv->T, 16)) { fprintf(stderr, "TEST %i: CRYPTO_gcm128_finish failed\n", test_no); goto fail; } if (tv->P_len > 0 && memcmp(out, tv->P, out_len)) { fprintf(stderr, "TEST %i: decrypt failed\n", test_no); goto fail; } ret = 0; fail: free(out); return (ret); } int main(int argc, char **argv) { int ret = 0; size_t i; for (i = 0; i < N_TESTS; i++) ret |= do_gcm128_test(i + 1, &gcm128_tests[i]); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/tests/evptest.c0000644000175000017500000002476112360020706017746 0ustar /* Written by Ben Laurie, 2001 */ /* * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. */ #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif #include #include static void hexdump(FILE *f, const char *title, const unsigned char *s, int l) { int n = 0; fprintf(f, "%s",title); for (; n < l; ++n) { if ((n % 16) == 0) fprintf(f, "\n%04x",n); fprintf(f, " %02x",s[n]); } fprintf(f, "\n"); } static int convert(unsigned char *s) { unsigned char *d; for (d = s; *s; s += 2,++d) { unsigned int n; if (!s[1]) { fprintf(stderr, "Odd number of hex digits!"); exit(4); } sscanf((char *)s, "%2x",&n); *d = (unsigned char)n; } return s - d; } static char * sstrsep(char **string, const char *delim) { char isdelim[256]; char *token = *string; if (**string == 0) return NULL; memset(isdelim, 0, 256); isdelim[0] = 1; while (*delim) { isdelim[(unsigned char)(*delim)] = 1; delim++; } while (!isdelim[(unsigned char)(**string)]) { (*string)++; } if (**string) { **string = 0; (*string)++; } return token; } static unsigned char * ustrsep(char **p, const char *sep) { return (unsigned char *)sstrsep(p, sep); } static int test1_exit(int ec) { exit(ec); return(0); /* To keep some compilers quiet */ } static void test1(const EVP_CIPHER *c, const unsigned char *key, int kn, const unsigned char *iv, int in, const unsigned char *plaintext, int pn, const unsigned char *ciphertext, int cn, int encdec) { EVP_CIPHER_CTX ctx; unsigned char out[4096]; int outl, outl2; printf("Testing cipher %s%s\n", EVP_CIPHER_name(c), (encdec == 1 ? "(encrypt)" : (encdec == 0 ? "(decrypt)" : "(encrypt/decrypt)"))); hexdump(stdout, "Key",key,kn); if (in) hexdump(stdout, "IV",iv,in); hexdump(stdout, "Plaintext",plaintext,pn); hexdump(stdout, "Ciphertext",ciphertext,cn); if (kn != c->key_len) { fprintf(stderr, "Key length doesn't match, got %d expected %lu\n",kn, (unsigned long)c->key_len); test1_exit(5); } EVP_CIPHER_CTX_init(&ctx); if (encdec != 0) { if (!EVP_EncryptInit_ex(&ctx, c,NULL, key, iv)) { fprintf(stderr, "EncryptInit failed\n"); ERR_print_errors_fp(stderr); test1_exit(10); } EVP_CIPHER_CTX_set_padding(&ctx, 0); if (!EVP_EncryptUpdate(&ctx, out, &outl, plaintext, pn)) { fprintf(stderr, "Encrypt failed\n"); ERR_print_errors_fp(stderr); test1_exit(6); } if (!EVP_EncryptFinal_ex(&ctx, out + outl, &outl2)) { fprintf(stderr, "EncryptFinal failed\n"); ERR_print_errors_fp(stderr); test1_exit(7); } if (outl + outl2 != cn) { fprintf(stderr, "Ciphertext length mismatch got %d expected %d\n", outl + outl2, cn); test1_exit(8); } if (memcmp(out, ciphertext, cn)) { fprintf(stderr, "Ciphertext mismatch\n"); hexdump(stderr, "Got",out,cn); hexdump(stderr, "Expected",ciphertext,cn); test1_exit(9); } } if (encdec <= 0) { if (!EVP_DecryptInit_ex(&ctx, c,NULL, key, iv)) { fprintf(stderr, "DecryptInit failed\n"); ERR_print_errors_fp(stderr); test1_exit(11); } EVP_CIPHER_CTX_set_padding(&ctx, 0); if (!EVP_DecryptUpdate(&ctx, out, &outl, ciphertext, cn)) { fprintf(stderr, "Decrypt failed\n"); ERR_print_errors_fp(stderr); test1_exit(6); } if (!EVP_DecryptFinal_ex(&ctx, out + outl, &outl2)) { fprintf(stderr, "DecryptFinal failed\n"); ERR_print_errors_fp(stderr); test1_exit(7); } if (outl + outl2 != pn) { fprintf(stderr, "Plaintext length mismatch got %d expected %d\n", outl + outl2, pn); test1_exit(8); } if (memcmp(out, plaintext, pn)) { fprintf(stderr, "Plaintext mismatch\n"); hexdump(stderr, "Got",out,pn); hexdump(stderr, "Expected",plaintext,pn); test1_exit(9); } } EVP_CIPHER_CTX_cleanup(&ctx); printf("\n"); } static int test_cipher(const char *cipher, const unsigned char *key, int kn, const unsigned char *iv, int in, const unsigned char *plaintext, int pn, const unsigned char *ciphertext, int cn, int encdec) { const EVP_CIPHER *c; c = EVP_get_cipherbyname(cipher); if (!c) return 0; test1(c, key, kn, iv, in, plaintext, pn, ciphertext, cn, encdec); return 1; } static int test_digest(const char *digest, const unsigned char *plaintext, int pn, const unsigned char *ciphertext, unsigned int cn) { const EVP_MD *d; EVP_MD_CTX ctx; unsigned char md[EVP_MAX_MD_SIZE]; unsigned int mdn; d = EVP_get_digestbyname(digest); if (!d) return 0; printf("Testing digest %s\n",EVP_MD_name(d)); hexdump(stdout, "Plaintext",plaintext,pn); hexdump(stdout, "Digest",ciphertext,cn); EVP_MD_CTX_init(&ctx); if (!EVP_DigestInit_ex(&ctx, d, NULL)) { fprintf(stderr, "DigestInit failed\n"); ERR_print_errors_fp(stderr); exit(100); } if (!EVP_DigestUpdate(&ctx, plaintext, pn)) { fprintf(stderr, "DigestUpdate failed\n"); ERR_print_errors_fp(stderr); exit(101); } if (!EVP_DigestFinal_ex(&ctx, md, &mdn)) { fprintf(stderr, "DigestFinal failed\n"); ERR_print_errors_fp(stderr); exit(101); } EVP_MD_CTX_cleanup(&ctx); if (mdn != cn) { fprintf(stderr, "Digest length mismatch, got %d expected %d\n",mdn,cn); exit(102); } if (memcmp(md, ciphertext, cn)) { fprintf(stderr, "Digest mismatch\n"); hexdump(stderr, "Got",md,cn); hexdump(stderr, "Expected",ciphertext,cn); exit(103); } printf("\n"); EVP_MD_CTX_cleanup(&ctx); return 1; } int main(int argc, char **argv) { const char *szTestFile; FILE *f; if (argc != 2) { fprintf(stderr, "%s \n",argv[0]); exit(1); } szTestFile = argv[1]; f=fopen(szTestFile, "r"); if (!f) { perror(szTestFile); exit(2); } /* Load up the software EVP_CIPHER and EVP_MD definitions */ OpenSSL_add_all_ciphers(); OpenSSL_add_all_digests(); #ifndef OPENSSL_NO_ENGINE /* Load all compiled-in ENGINEs */ ENGINE_load_builtin_engines(); #endif #if 0 OPENSSL_config(); #endif #ifndef OPENSSL_NO_ENGINE /* Register all available ENGINE implementations of ciphers and digests. * This could perhaps be changed to "ENGINE_register_all_complete()"? */ ENGINE_register_all_ciphers(); ENGINE_register_all_digests(); /* If we add command-line options, this statement should be switchable. * It'll prevent ENGINEs being ENGINE_init()ialised for cipher/digest use if * they weren't already initialised. */ /* ENGINE_set_cipher_flags(ENGINE_CIPHER_FLAG_NOINIT); */ #endif for (;;) { char line[4096]; char *p; char *cipher; unsigned char *iv, *key, *plaintext, *ciphertext; int encdec; int kn, in, pn, cn; if (!fgets((char *)line, sizeof line, f)) break; if (line[0] == '#' || line[0] == '\n') continue; p = line; cipher=sstrsep(&p, ":"); key=ustrsep(&p, ":"); iv=ustrsep(&p, ":"); plaintext=ustrsep(&p, ":"); ciphertext=ustrsep(&p, ":"); if (p[-1] == '\n') { p[-1] = '\0'; encdec = -1; } else { encdec = atoi(sstrsep(&p, "\n")); } kn = convert(key); in = convert(iv); pn = convert(plaintext); cn = convert(ciphertext); if (!test_cipher(cipher, key, kn, iv, in, plaintext, pn, ciphertext, cn, encdec) && !test_digest(cipher, plaintext, pn, ciphertext, cn)) { #ifdef OPENSSL_NO_AES if (strstr(cipher, "AES") == cipher) { fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); continue; } #endif #ifdef OPENSSL_NO_DES if (strstr(cipher, "DES") == cipher) { fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); continue; } #endif #ifdef OPENSSL_NO_RC4 if (strstr(cipher, "RC4") == cipher) { fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); continue; } #endif #ifdef OPENSSL_NO_CAMELLIA if (strstr(cipher, "CAMELLIA") == cipher) { fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); continue; } #endif #ifdef OPENSSL_NO_SEED if (strstr(cipher, "SEED") == cipher) { fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); continue; } #endif #ifdef OPENSSL_NO_CHACHA if (strstr(cipher, "ChaCha") == cipher) { fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); continue; } #endif fprintf(stderr, "Can't find %s\n",cipher); exit(3); } } fclose(f); #ifndef OPENSSL_NO_ENGINE ENGINE_cleanup(); #endif EVP_cleanup(); CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); ERR_free_strings(); CRYPTO_mem_leaks_fp(stderr); return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/config.guess0000555000175000017500000013135512360020752017263 0ustar #! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2013 Free Software Foundation, Inc. timestamp='2013-11-29' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # # Please send patches with a ChangeLog entry to config-patches@gnu.org. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` ;; esac # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="gnulibc1" ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; or1k:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; or32:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-${LIBC} exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: deps/libressl-pnacl-sys-2.1.6/libressl/man/0000755000000000000000000000000012666635521017305 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/man/i2d_CMS_bio_stream.30000644000175000017500000001200012360020730021145 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "i2d_CMS_bio_stream 3" .TH i2d_CMS_bio_stream 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" .Vb 1 \& i2d_CMS_bio_stream \- output CMS_ContentInfo structure in BER format. .Ve .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *data, int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIi2d_CMS_bio_stream()\fR outputs a CMS_ContentInfo structure in \s-1BER\s0 format. .PP It is otherwise identical to the function \fISMIME_write_CMS()\fR. .SH "NOTES" .IX Header "NOTES" This function is effectively a version of the \fIi2d_CMS_bio()\fR supporting streaming. .SH "BUGS" .IX Header "BUGS" The prefix \*(L"i2d\*(R" is arguably wrong because the function outputs \s-1BER\s0 format. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIi2d_CMS_bio_stream()\fR returns 1 for success or 0 for failure. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_sign\fR\|(3), \&\fICMS_verify\fR\|(3), \fICMS_encrypt\fR\|(3) \&\fICMS_decrypt\fR\|(3), \&\fISMIME_write_CMS\fR\|(3), \&\fIPEM_write_bio_CMS_stream\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIi2d_CMS_bio_stream()\fR was added to OpenSSL 1.0.0 deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_read.30000644000175000017500000002245212360020736017237 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_read 3" .TH SSL_read 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_read \- read bytes from a TLS/SSL connection. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_read(SSL *ssl, void *buf, int num); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_read()\fR tries to read \fBnum\fR bytes from the specified \fBssl\fR into the buffer \fBbuf\fR. .SH "NOTES" .IX Header "NOTES" If necessary, \fISSL_read()\fR will negotiate a \s-1TLS/SSL\s0 session, if not already explicitly performed by \fISSL_connect\fR\|(3) or \&\fISSL_accept\fR\|(3). If the peer requests a re-negotiation, it will be performed transparently during the \fISSL_read()\fR operation. The behaviour of \fISSL_read()\fR depends on the underlying \s-1BIO.\s0 .PP For the transparent negotiation to succeed, the \fBssl\fR must have been initialized to client or server mode. This is being done by calling \&\fISSL_set_connect_state\fR\|(3) or \fISSL_set_accept_state()\fR before the first call to an \fISSL_read()\fR or \fISSL_write\fR\|(3) function. .PP \&\fISSL_read()\fR works based on the \s-1SSL/TLS\s0 records. The data are received in records (with a maximum record size of 16kB for SSLv3/TLSv1). Only when a record has been completely received, it can be processed (decryption and check of integrity). Therefore data that was not retrieved at the last call of \fISSL_read()\fR can still be buffered inside the \s-1SSL\s0 layer and will be retrieved on the next call to \fISSL_read()\fR. If \fBnum\fR is higher than the number of bytes buffered, \fISSL_read()\fR will return with the bytes buffered. If no more bytes are in the buffer, \fISSL_read()\fR will trigger the processing of the next record. Only when the record has been received and processed completely, \fISSL_read()\fR will return reporting success. At most the contents of the record will be returned. As the size of an \s-1SSL/TLS\s0 record may exceed the maximum packet size of the underlying transport (e.g. \s-1TCP\s0), it may be necessary to read several packets from the transport layer before the record is complete and \fISSL_read()\fR can succeed. .PP If the underlying \s-1BIO\s0 is \fBblocking\fR, \fISSL_read()\fR will only return, once the read operation has been finished or an error occurred, except when a renegotiation take place, in which case a \s-1SSL_ERROR_WANT_READ\s0 may occur. This behaviour can be controlled with the \s-1SSL_MODE_AUTO_RETRY\s0 flag of the \&\fISSL_CTX_set_mode\fR\|(3) call. .PP If the underlying \s-1BIO\s0 is \fBnon-blocking\fR, \fISSL_read()\fR will also return when the underlying \s-1BIO\s0 could not satisfy the needs of \fISSL_read()\fR to continue the operation. In this case a call to \&\fISSL_get_error\fR\|(3) with the return value of \fISSL_read()\fR will yield \fB\s-1SSL_ERROR_WANT_READ\s0\fR or \&\fB\s-1SSL_ERROR_WANT_WRITE\s0\fR. As at any time a re-negotiation is possible, a call to \fISSL_read()\fR can also cause write operations! The calling process then must repeat the call after taking appropriate action to satisfy the needs of \fISSL_read()\fR. The action depends on the underlying \s-1BIO.\s0 When using a non-blocking socket, nothing is to be done, but \fIselect()\fR can be used to check for the required condition. When using a buffering \s-1BIO,\s0 like a \s-1BIO\s0 pair, data must be written into or retrieved out of the \s-1BIO\s0 before being able to continue. .PP \&\fISSL_pending\fR\|(3) can be used to find out whether there are buffered bytes available for immediate retrieval. In this case \&\fISSL_read()\fR can be called without blocking or actually receiving new data from the underlying socket. .SH "WARNING" .IX Header "WARNING" When an \fISSL_read()\fR operation has to be repeated because of \&\fB\s-1SSL_ERROR_WANT_READ\s0\fR or \fB\s-1SSL_ERROR_WANT_WRITE\s0\fR, it must be repeated with the same arguments. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .ie n .IP """>0""" 4 .el .IP "\f(CW>0\fR" 4 .IX Item ">0" The read operation was successful; the return value is the number of bytes actually read from the \s-1TLS/SSL\s0 connection. .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" The read operation was not successful. The reason may either be a clean shutdown due to a \*(L"close notify\*(R" alert sent by the peer (in which case the \s-1SSL_RECEIVED_SHUTDOWN\s0 flag in the ssl shutdown state is set (see \fISSL_shutdown\fR\|(3), \&\fISSL_set_shutdown\fR\|(3)). It is also possible, that the peer simply shut down the underlying transport and the shutdown is incomplete. Call \fISSL_get_error()\fR with the return value \fBret\fR to find out, whether an error occurred or the connection was shut down cleanly (\s-1SSL_ERROR_ZERO_RETURN\s0). .Sp SSLv2 (deprecated) does not support a shutdown alert protocol, so it can only be detected, whether the underlying connection was closed. It cannot be checked, whether the closure was initiated by the peer or by something else. .ie n .IP """<0""" 4 .el .IP "\f(CW<0\fR" 4 .IX Item "<0" The read operation was not successful, because either an error occurred or action must be taken by the calling process. Call \fISSL_get_error()\fR with the return value \fBret\fR to find out the reason. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_get_error\fR\|(3), \fISSL_write\fR\|(3), \&\fISSL_CTX_set_mode\fR\|(3), \fISSL_CTX_new\fR\|(3), \&\fISSL_connect\fR\|(3), \fISSL_accept\fR\|(3) \&\fISSL_set_connect_state\fR\|(3), \&\fISSL_pending\fR\|(3), \&\fISSL_shutdown\fR\|(3), \fISSL_set_shutdown\fR\|(3), \&\fIssl\fR\|(3), \fIbio\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/X509_NAME_get_index_by_NID.30000644000175000017500000001731012360020725022255 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "X509_NAME_get_index_by_NID 3" .TH X509_NAME_get_index_by_NID 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" X509_NAME_get_index_by_NID, X509_NAME_get_index_by_OBJ, X509_NAME_get_entry, X509_NAME_entry_count, X509_NAME_get_text_by_NID, X509_NAME_get_text_by_OBJ \- X509_NAME lookup and enumeration functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos); \& int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj, int lastpos); \& \& int X509_NAME_entry_count(X509_NAME *name); \& X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc); \& \& int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf,int len); \& int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, char *buf,int len); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions allow an \fBX509_NAME\fR structure to be examined. The \&\fBX509_NAME\fR structure is the same as the \fBName\fR type defined in \&\s-1RFC2459 \s0(and elsewhere) and used for example in certificate subject and issuer names. .PP \&\fIX509_NAME_get_index_by_NID()\fR and \fIX509_NAME_get_index_by_OBJ()\fR retrieve the next index matching \fBnid\fR or \fBobj\fR after \fBlastpos\fR. \fBlastpos\fR should initially be set to \-1. If there are no more entries \-1 is returned. .PP \&\fIX509_NAME_entry_count()\fR returns the total number of entries in \fBname\fR. .PP \&\fIX509_NAME_get_entry()\fR retrieves the \fBX509_NAME_ENTRY\fR from \fBname\fR corresponding to index \fBloc\fR. Acceptable values for \fBloc\fR run from 0 to (X509_NAME_entry_count(name) \- 1). The value returned is an internal pointer which must not be freed. .PP \&\fIX509_NAME_get_text_by_NID()\fR, \fIX509_NAME_get_text_by_OBJ()\fR retrieve the \*(L"text\*(R" from the first entry in \fBname\fR which matches \fBnid\fR or \&\fBobj\fR, if no such entry exists \-1 is returned. At most \fBlen\fR bytes will be written and the text written to \fBbuf\fR will be null terminated. The length of the output string written is returned excluding the terminating null. If \fBbuf\fR is <\s-1NULL\s0> then the amount of space needed in \fBbuf\fR (excluding the final null) is returned. .SH "NOTES" .IX Header "NOTES" \&\fIX509_NAME_get_text_by_NID()\fR and \fIX509_NAME_get_text_by_OBJ()\fR are legacy functions which have various limitations which make them of minimal use in practice. They can only find the first matching entry and will copy the contents of the field verbatim: this can be highly confusing if the target is a muticharacter string type like a BMPString or a UTF8String. .PP For a more general solution \fIX509_NAME_get_index_by_NID()\fR or \&\fIX509_NAME_get_index_by_OBJ()\fR should be used followed by \&\fIX509_NAME_get_entry()\fR on any matching indices and then the various \fBX509_NAME_ENTRY\fR utility functions on the result. .SH "EXAMPLES" .IX Header "EXAMPLES" Process all entries: .PP .Vb 2 \& int i; \& X509_NAME_ENTRY *e; \& \& for (i = 0; i < X509_NAME_entry_count(nm); i++) { \& e = X509_NAME_get_entry(nm, i); \& /* Do something with e */ \& } .Ve .PP Process all commonName entries: .PP .Vb 2 \& int loc; \& X509_NAME_ENTRY *e; \& \& loc = \-1; \& for (;;) { \& lastpos = X509_NAME_get_index_by_NID(nm, NID_commonName, lastpos); \& if (lastpos == \-1) \& break; \& e = X509_NAME_get_entry(nm, lastpos); \& /* Do something with e */ \& } .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIX509_NAME_get_index_by_NID()\fR and \fIX509_NAME_get_index_by_OBJ()\fR return the index of the next matching entry or \-1 if not found. .PP \&\fIX509_NAME_entry_count()\fR returns the total number of entries. .PP \&\fIX509_NAME_get_entry()\fR returns an \fBX509_NAME\fR pointer to the requested entry or \fB\s-1NULL\s0\fR if the index is invalid. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fId2i_X509_NAME\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_set_verify_result.30000644000175000017500000001171512360020737022102 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_set_verify_result 3" .TH SSL_set_verify_result 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_set_verify_result \- override result of peer certificate verification .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_set_verify_result(SSL *ssl, long verify_result); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_set_verify_result()\fR sets \fBverify_result\fR of the object \fBssl\fR to be the result of the verification of the X509 certificate presented by the peer, if any. .SH "NOTES" .IX Header "NOTES" \&\fISSL_set_verify_result()\fR overrides the verification result. It only changes the verification result of the \fBssl\fR object. It does not become part of the established session, so if the session is to be reused later, the original value will reappear. .PP The valid codes for \fBverify_result\fR are documented in \fIverify\fR\|(1). .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_set_verify_result()\fR does not provide a return value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_get_verify_result\fR\|(3), \&\fISSL_get_peer_certificate\fR\|(3), \&\fIverify\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/DSA_size.30000644000175000017500000001104712360020716017240 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DSA_size 3" .TH DSA_size 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DSA_size \- get DSA signature size .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int DSA_size(const DSA *dsa); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This function returns the size of an \s-1ASN.1\s0 encoded \s-1DSA\s0 signature in bytes. It can be used to determine how much memory must be allocated for a \s-1DSA\s0 signature. .PP \&\fBdsa\->q\fR must not be \fB\s-1NULL\s0\fR. .SH "RETURN VALUE" .IX Header "RETURN VALUE" The size in bytes. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdsa\fR\|(3), \fIDSA_sign\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIDSA_size()\fR is available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/X509_STORE_CTX_get_error.30000644000175000017500000004601412360020725022010 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "X509_STORE_CTX_get_error 3" .TH X509_STORE_CTX_get_error 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" X509_STORE_CTX_get_error, X509_STORE_CTX_set_error, X509_STORE_CTX_get_error_depth, X509_STORE_CTX_get_current_cert, X509_STORE_CTX_get1_chain, X509_verify_cert_error_string \- get or set certificate verification status information .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx); \& void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s); \& int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx); \& X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx); \& \& STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx); \& \& const char *X509_verify_cert_error_string(long n); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions are typically called after \fIX509_verify_cert()\fR has indicated an error or in a verification callback to determine the nature of an error. .PP \&\fIX509_STORE_CTX_get_error()\fR returns the error code of \fBctx\fR, see the \fB\s-1ERROR CODES\s0\fR section for a full description of all error codes. .PP \&\fIX509_STORE_CTX_set_error()\fR sets the error code of \fBctx\fR to \fBs\fR. For example it might be used in a verification callback to set an error based on additional checks. .PP \&\fIX509_STORE_CTX_get_error_depth()\fR returns the \fBdepth\fR of the error. This is a non-negative integer representing where in the certificate chain the error occurred. If it is zero it occured in the end entity certificate, one if it is the certificate which signed the end entity certificate and so on. .PP \&\fIX509_STORE_CTX_get_current_cert()\fR returns the certificate in \fBctx\fR which caused the error or \fB\s-1NULL\s0\fR if no certificate is relevant. .PP \&\fIX509_STORE_CTX_get1_chain()\fR returns a complete validate chain if a previous call to \fIX509_verify_cert()\fR is successful. If the call to \fIX509_verify_cert()\fR is \fBnot\fR successful the returned chain may be incomplete or invalid. The returned chain persists after the \fBctx\fR structure is freed, when it is no longer needed it should be free up using: .PP .Vb 1 \& sk_X509_pop_free(chain, X509_free); .Ve .PP \&\fIX509_verify_cert_error_string()\fR returns a human readable error string for verification error \fBn\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIX509_STORE_CTX_get_error()\fR returns \fBX509_V_OK\fR or an error code. .PP \&\fIX509_STORE_CTX_get_error_depth()\fR returns a non-negative error depth. .PP \&\fIX509_STORE_CTX_get_current_cert()\fR returns the cerificate which caused the error or \fB\s-1NULL\s0\fR if no certificate is relevant to the error. .PP \&\fIX509_verify_cert_error_string()\fR returns a human readable error string for verification error \fBn\fR. .SH "ERROR CODES" .IX Header "ERROR CODES" A list of error codes and messages is shown below. Some of the error codes are defined but currently never returned: these are described as \&\*(L"unused\*(R". .IP "\fBX509_V_OK: ok\fR" 4 .IX Item "X509_V_OK: ok" the operation was successful. .IP "\fBX509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate\fR" 4 .IX Item "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate" the issuer certificate could not be found: this occurs if the issuer certificate of an untrusted certificate cannot be found. .IP "\fBX509_V_ERR_UNABLE_TO_GET_CRL: unable to get certificate \s-1CRL\s0\fR" 4 .IX Item "X509_V_ERR_UNABLE_TO_GET_CRL: unable to get certificate CRL" the \s-1CRL\s0 of a certificate could not be found. .IP "\fBX509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate's signature\fR" 4 .IX Item "X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate's signature" the certificate signature could not be decrypted. This means that the actual signature value could not be determined rather than it not matching the expected value, this is only meaningful for \s-1RSA\s0 keys. .IP "\fBX509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt \s-1CRL\s0's signature\fR" 4 .IX Item "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt CRL's signature" the \s-1CRL\s0 signature could not be decrypted: this means that the actual signature value could not be determined rather than it not matching the expected value. Unused. .IP "\fBX509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key\fR" 4 .IX Item "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key" the public key in the certificate SubjectPublicKeyInfo could not be read. .IP "\fBX509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure\fR" 4 .IX Item "X509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure" the signature of the certificate is invalid. .IP "\fBX509_V_ERR_CRL_SIGNATURE_FAILURE: \s-1CRL\s0 signature failure\fR" 4 .IX Item "X509_V_ERR_CRL_SIGNATURE_FAILURE: CRL signature failure" the signature of the certificate is invalid. .IP "\fBX509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid\fR" 4 .IX Item "X509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid" the certificate is not yet valid: the notBefore date is after the current time. .IP "\fBX509_V_ERR_CERT_HAS_EXPIRED: certificate has expired\fR" 4 .IX Item "X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired" the certificate has expired: that is the notAfter date is before the current time. .IP "\fBX509_V_ERR_CRL_NOT_YET_VALID: \s-1CRL\s0 is not yet valid\fR" 4 .IX Item "X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid" the \s-1CRL\s0 is not yet valid. .IP "\fBX509_V_ERR_CRL_HAS_EXPIRED: \s-1CRL\s0 has expired\fR" 4 .IX Item "X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired" the \s-1CRL\s0 has expired. .IP "\fBX509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate's notBefore field\fR" 4 .IX Item "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate's notBefore field" the certificate notBefore field contains an invalid time. .IP "\fBX509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate's notAfter field\fR" 4 .IX Item "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate's notAfter field" the certificate notAfter field contains an invalid time. .IP "\fBX509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in \s-1CRL\s0's lastUpdate field\fR" 4 .IX Item "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in CRL's lastUpdate field" the \s-1CRL\s0 lastUpdate field contains an invalid time. .IP "\fBX509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in \s-1CRL\s0's nextUpdate field\fR" 4 .IX Item "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in CRL's nextUpdate field" the \s-1CRL\s0 nextUpdate field contains an invalid time. .IP "\fBX509_V_ERR_OUT_OF_MEM: out of memory\fR" 4 .IX Item "X509_V_ERR_OUT_OF_MEM: out of memory" an error occurred trying to allocate memory. This should never happen. .IP "\fBX509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate\fR" 4 .IX Item "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate" the passed certificate is self signed and the same certificate cannot be found in the list of trusted certificates. .IP "\fBX509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain\fR" 4 .IX Item "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain" the certificate chain could be built up using the untrusted certificates but the root could not be found locally. .IP "\fBX509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate\fR" 4 .IX Item "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate" the issuer certificate of a locally looked up certificate could not be found. This normally means the list of trusted certificates is not complete. .IP "\fBX509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate\fR" 4 .IX Item "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate" no signatures could be verified because the chain contains only one certificate and it is not self signed. .IP "\fBX509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long\fR" 4 .IX Item "X509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long" the certificate chain length is greater than the supplied maximum depth. Unused. .IP "\fBX509_V_ERR_CERT_REVOKED: certificate revoked\fR" 4 .IX Item "X509_V_ERR_CERT_REVOKED: certificate revoked" the certificate has been revoked. .IP "\fBX509_V_ERR_INVALID_CA: invalid \s-1CA\s0 certificate\fR" 4 .IX Item "X509_V_ERR_INVALID_CA: invalid CA certificate" a \s-1CA\s0 certificate is invalid. Either it is not a \s-1CA\s0 or its extensions are not consistent with the supplied purpose. .IP "\fBX509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded\fR" 4 .IX Item "X509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded" the basicConstraints pathlength parameter has been exceeded. .IP "\fBX509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose\fR" 4 .IX Item "X509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose" the supplied certificate cannot be used for the specified purpose. .IP "\fBX509_V_ERR_CERT_UNTRUSTED: certificate not trusted\fR" 4 .IX Item "X509_V_ERR_CERT_UNTRUSTED: certificate not trusted" the root \s-1CA\s0 is not marked as trusted for the specified purpose. .IP "\fBX509_V_ERR_CERT_REJECTED: certificate rejected\fR" 4 .IX Item "X509_V_ERR_CERT_REJECTED: certificate rejected" the root \s-1CA\s0 is marked to reject the specified purpose. .IP "\fBX509_V_ERR_SUBJECT_ISSUER_MISMATCH: subject issuer mismatch\fR" 4 .IX Item "X509_V_ERR_SUBJECT_ISSUER_MISMATCH: subject issuer mismatch" the current candidate issuer certificate was rejected because its subject name did not match the issuer name of the current certificate. This is only set if issuer check debugging is enabled it is used for status notification and is \fBnot\fR in itself an error. .IP "\fBX509_V_ERR_AKID_SKID_MISMATCH: authority and subject key identifier mismatch\fR" 4 .IX Item "X509_V_ERR_AKID_SKID_MISMATCH: authority and subject key identifier mismatch" the current candidate issuer certificate was rejected because its subject key identifier was present and did not match the authority key identifier current certificate. This is only set if issuer check debugging is enabled it is used for status notification and is \fBnot\fR in itself an error. .IP "\fBX509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: authority and issuer serial number mismatch\fR" 4 .IX Item "X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: authority and issuer serial number mismatch" the current candidate issuer certificate was rejected because its issuer name and serial number was present and did not match the authority key identifier of the current certificate. This is only set if issuer check debugging is enabled it is used for status notification and is \fBnot\fR in itself an error. .IP "\fBX509_V_ERR_KEYUSAGE_NO_CERTSIGN:key usage does not include certificate signing\fR" 4 .IX Item "X509_V_ERR_KEYUSAGE_NO_CERTSIGN:key usage does not include certificate signing" the current candidate issuer certificate was rejected because its keyUsage extension does not permit certificate signing. This is only set if issuer check debugging is enabled it is used for status notification and is \fBnot\fR in itself an error. .IP "\fBX509_V_ERR_INVALID_EXTENSION: invalid or inconsistent certificate extension\fR" 4 .IX Item "X509_V_ERR_INVALID_EXTENSION: invalid or inconsistent certificate extension" A certificate extension had an invalid value (for example an incorrect encoding) or some value inconsistent with other extensions. .IP "\fBX509_V_ERR_INVALID_POLICY_EXTENSION: invalid or inconsistent certificate policy extension\fR" 4 .IX Item "X509_V_ERR_INVALID_POLICY_EXTENSION: invalid or inconsistent certificate policy extension" A certificate policies extension had an invalid value (for example an incorrect encoding) or some value inconsistent with other extensions. This error only occurs if policy processing is enabled. .IP "\fBX509_V_ERR_NO_EXPLICIT_POLICY: no explicit policy\fR" 4 .IX Item "X509_V_ERR_NO_EXPLICIT_POLICY: no explicit policy" The verification flags were set to require and explicit policy but none was present. .IP "\fBX509_V_ERR_DIFFERENT_CRL_SCOPE: Different \s-1CRL\s0 scope\fR" 4 .IX Item "X509_V_ERR_DIFFERENT_CRL_SCOPE: Different CRL scope" The only CRLs that could be found did not match the scope of the certificate. .IP "\fBX509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE: Unsupported extension feature\fR" 4 .IX Item "X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE: Unsupported extension feature" Some feature of a certificate extension is not supported. Unused. .IP "\fBX509_V_ERR_PERMITTED_VIOLATION: permitted subtree violation\fR" 4 .IX Item "X509_V_ERR_PERMITTED_VIOLATION: permitted subtree violation" A name constraint violation occured in the permitted subtrees. .IP "\fBX509_V_ERR_EXCLUDED_VIOLATION: excluded subtree violation\fR" 4 .IX Item "X509_V_ERR_EXCLUDED_VIOLATION: excluded subtree violation" A name constraint violation occured in the excluded subtrees. .IP "\fBX509_V_ERR_SUBTREE_MINMAX: name constraints minimum and maximum not supported\fR" 4 .IX Item "X509_V_ERR_SUBTREE_MINMAX: name constraints minimum and maximum not supported" A certificate name constraints extension included a minimum or maximum field: this is not supported. .IP "\fBX509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE: unsupported name constraint type\fR" 4 .IX Item "X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE: unsupported name constraint type" An unsupported name constraint type was encountered. OpenSSL currently only supports directory name, \s-1DNS\s0 name, email and \s-1URI\s0 types. .IP "\fBX509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX: unsupported or invalid name constraint syntax\fR" 4 .IX Item "X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX: unsupported or invalid name constraint syntax" The format of the name constraint is not recognised: for example an email address format of a form not mentioned in \s-1RFC3280.\s0 This could be caused by a garbage extension or some new feature not currently supported. .IP "\fBX509_V_ERR_CRL_PATH_VALIDATION_ERROR: \s-1CRL\s0 path validation error\fR" 4 .IX Item "X509_V_ERR_CRL_PATH_VALIDATION_ERROR: CRL path validation error" An error occured when attempting to verify the \s-1CRL\s0 path. This error can only happen if extended \s-1CRL\s0 checking is enabled. .IP "\fBX509_V_ERR_APPLICATION_VERIFICATION: application verification failure\fR" 4 .IX Item "X509_V_ERR_APPLICATION_VERIFICATION: application verification failure" an application specific error. This will never be returned unless explicitly set by an application. .SH "NOTES" .IX Header "NOTES" The above functions should be used instead of directly referencing the fields in the \fBX509_VERIFY_CTX\fR structure. .PP In versions of OpenSSL before 1.0 the current certificate returned by \&\fIX509_STORE_CTX_get_current_cert()\fR was never \fB\s-1NULL\s0\fR. Applications should check the return value before printing out any debugging information relating to the current certificate. .PP If an unrecognised error code is passed to \fIX509_verify_cert_error_string()\fR the numerical value of the unknown code is returned in a static buffer. This is not thread safe but will never happen unless an invalid code is passed. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIX509_verify_cert\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/DSA_SIG_new.30000644000175000017500000001161612360020715017562 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DSA_SIG_new 3" .TH DSA_SIG_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DSA_SIG_new, DSA_SIG_free \- allocate and free DSA signature objects .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& DSA_SIG *DSA_SIG_new(void); \& \& void DSA_SIG_free(DSA_SIG *a); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIDSA_SIG_new()\fR allocates and initializes a \fB\s-1DSA_SIG\s0\fR structure. .PP \&\fIDSA_SIG_free()\fR frees the \fB\s-1DSA_SIG\s0\fR structure and its components. The values are erased before the memory is returned to the system. .SH "RETURN VALUES" .IX Header "RETURN VALUES" If the allocation fails, \fIDSA_SIG_new()\fR returns \fB\s-1NULL\s0\fR and sets an error code that can be obtained by \&\fIERR_get_error\fR\|(3). Otherwise it returns a pointer to the newly allocated structure. .PP \&\fIDSA_SIG_free()\fR returns no value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdsa\fR\|(3), \fIERR_get_error\fR\|(3), \&\fIDSA_do_sign\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIDSA_SIG_new()\fR and \fIDSA_SIG_free()\fR were added in OpenSSL 0.9.3. deps/libressl-pnacl-sys-2.1.6/libressl/man/dsa.10000644000175000017500000002176312360020740016347 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "dsa 1" .TH dsa 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" dsa \- DSA key processing .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBdsa\fR [\fB\-inform PEM|DER\fR] [\fB\-outform PEM|DER\fR] [\fB\-in filename\fR] [\fB\-passin arg\fR] [\fB\-out filename\fR] [\fB\-passout arg\fR] [\fB\-des\fR] [\fB\-des3\fR] [\fB\-idea\fR] [\fB\-text\fR] [\fB\-noout\fR] [\fB\-modulus\fR] [\fB\-pubin\fR] [\fB\-pubout\fR] [\fB\-engine id\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBdsa\fR command processes \s-1DSA\s0 keys. They can be converted between various forms and their components printed out. \fBNote\fR This command uses the traditional SSLeay compatible format for private key encryption: newer applications should use the more secure PKCS#8 format using the \fBpkcs8\fR .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" .IP "\fB\-inform DER|PEM\fR" 4 .IX Item "-inform DER|PEM" This specifies the input format. The \fB\s-1DER\s0\fR option with a private key uses an \s-1ASN1 DER\s0 encoded form of an \s-1ASN.1 SEQUENCE\s0 consisting of the values of version (currently zero), p, q, g, the public and private key components respectively as \s-1ASN.1\s0 INTEGERs. When used with a public key it uses a SubjectPublicKeyInfo structure: it is an error if the key is not \s-1DSA.\s0 .Sp The \fB\s-1PEM\s0\fR form is the default format: it consists of the \fB\s-1DER\s0\fR format base64 encoded with additional header and footer lines. In the case of a private key PKCS#8 format is also accepted. .IP "\fB\-outform DER|PEM\fR" 4 .IX Item "-outform DER|PEM" This specifies the output format, the options have the same meaning as the \&\fB\-inform\fR option. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read a key from or standard input if this option is not specified. If the key is encrypted a pass phrase will be prompted for. .IP "\fB\-passin arg\fR" 4 .IX Item "-passin arg" the input file password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" This specifies the output filename to write a key to or standard output by is not specified. If any encryption options are set then a pass phrase will be prompted for. The output filename should \fBnot\fR be the same as the input filename. .IP "\fB\-passout arg\fR" 4 .IX Item "-passout arg" the output file password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-des|\-des3|\-idea\fR" 4 .IX Item "-des|-des3|-idea" These options encrypt the private key with the \s-1DES,\s0 triple \s-1DES,\s0 or the \&\s-1IDEA\s0 ciphers respectively before outputting it. A pass phrase is prompted for. If none of these options is specified the key is written in plain text. This means that using the \fBdsa\fR utility to read in an encrypted key with no encryption option can be used to remove the pass phrase from a key, or by setting the encryption options it can be use to add or change the pass phrase. These options can only be used with \s-1PEM\s0 format output files. .IP "\fB\-text\fR" 4 .IX Item "-text" prints out the public, private key components and parameters. .IP "\fB\-noout\fR" 4 .IX Item "-noout" this option prevents output of the encoded version of the key. .IP "\fB\-modulus\fR" 4 .IX Item "-modulus" this option prints out the value of the public key component of the key. .IP "\fB\-pubin\fR" 4 .IX Item "-pubin" by default a private key is read from the input file: with this option a public key is read instead. .IP "\fB\-pubout\fR" 4 .IX Item "-pubout" by default a private key is output. With this option a public key will be output instead. This option is automatically set if the input is a public key. .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBdsa\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .SH "NOTES" .IX Header "NOTES" The \s-1PEM\s0 private key format uses the header and footer lines: .PP .Vb 2 \& \-\-\-\-\-BEGIN DSA PRIVATE KEY\-\-\-\-\- \& \-\-\-\-\-END DSA PRIVATE KEY\-\-\-\-\- .Ve .PP The \s-1PEM\s0 public key format uses the header and footer lines: .PP .Vb 2 \& \-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\- \& \-\-\-\-\-END PUBLIC KEY\-\-\-\-\- .Ve .SH "EXAMPLES" .IX Header "EXAMPLES" To remove the pass phrase on a \s-1DSA\s0 private key: .PP .Vb 1 \& openssl dsa \-in key.pem \-out keyout.pem .Ve .PP To encrypt a private key using triple \s-1DES:\s0 .PP .Vb 1 \& openssl dsa \-in key.pem \-des3 \-out keyout.pem .Ve .PP To convert a private key from \s-1PEM\s0 to \s-1DER\s0 format: .PP .Vb 1 \& openssl dsa \-in key.pem \-outform DER \-out keyout.der .Ve .PP To print out the components of a private key to standard output: .PP .Vb 1 \& openssl dsa \-in key.pem \-text \-noout .Ve .PP To just output the public part of a private key: .PP .Vb 1 \& openssl dsa \-in key.pem \-pubout \-out pubkey.pem .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdsaparam\fR\|(1), \fIgendsa\fR\|(1), \fIrsa\fR\|(1), \&\fIgenrsa\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_should_retry.30000644000175000017500000002210512360020711021003 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_should_retry 3" .TH BIO_should_retry 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_should_retry, BIO_should_read, BIO_should_write, BIO_should_io_special, BIO_retry_type, BIO_should_retry, BIO_get_retry_BIO, BIO_get_retry_reason \- BIO retry functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& #define BIO_should_read(a) ((a)\->flags & BIO_FLAGS_READ) \& #define BIO_should_write(a) ((a)\->flags & BIO_FLAGS_WRITE) \& #define BIO_should_io_special(a) ((a)\->flags & BIO_FLAGS_IO_SPECIAL) \& #define BIO_retry_type(a) ((a)\->flags & BIO_FLAGS_RWS) \& #define BIO_should_retry(a) ((a)\->flags & BIO_FLAGS_SHOULD_RETRY) \& \& #define BIO_FLAGS_READ 0x01 \& #define BIO_FLAGS_WRITE 0x02 \& #define BIO_FLAGS_IO_SPECIAL 0x04 \& #define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL) \& #define BIO_FLAGS_SHOULD_RETRY 0x08 \& \& BIO * BIO_get_retry_BIO(BIO *bio, int *reason); \& int BIO_get_retry_reason(BIO *bio); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions determine why a \s-1BIO\s0 is not able to read or write data. They will typically be called after a failed \fIBIO_read()\fR or \fIBIO_write()\fR call. .PP \&\fIBIO_should_retry()\fR is true if the call that produced this condition should then be retried at a later time. .PP If \fIBIO_should_retry()\fR is false then the cause is an error condition. .PP \&\fIBIO_should_read()\fR is true if the cause of the condition is that a \s-1BIO\s0 needs to read data. .PP \&\fIBIO_should_write()\fR is true if the cause of the condition is that a \s-1BIO\s0 needs to read data. .PP \&\fIBIO_should_io_special()\fR is true if some \*(L"special\*(R" condition, that is a reason other than reading or writing is the cause of the condition. .PP \&\fIBIO_retry_type()\fR returns a mask of the cause of a retry condition consisting of the values \fB\s-1BIO_FLAGS_READ\s0\fR, \fB\s-1BIO_FLAGS_WRITE\s0\fR, \&\fB\s-1BIO_FLAGS_IO_SPECIAL\s0\fR though current \s-1BIO\s0 types will only set one of these. .PP \&\fIBIO_get_retry_BIO()\fR determines the precise reason for the special condition, it returns the \s-1BIO\s0 that caused this condition and if \&\fBreason\fR is not \s-1NULL\s0 it contains the reason code. The meaning of the reason code and the action that should be taken depends on the type of \s-1BIO\s0 that resulted in this condition. .PP \&\fIBIO_get_retry_reason()\fR returns the reason for a special condition if passed the relevant \s-1BIO,\s0 for example as returned by \fIBIO_get_retry_BIO()\fR. .SH "NOTES" .IX Header "NOTES" If \fIBIO_should_retry()\fR returns false then the precise \*(L"error condition\*(R" depends on the \s-1BIO\s0 type that caused it and the return code of the \s-1BIO\s0 operation. For example if a call to \fIBIO_read()\fR on a socket \s-1BIO\s0 returns 0 and \fIBIO_should_retry()\fR is false then the cause will be that the connection closed. A similar condition on a file \s-1BIO\s0 will mean that it has reached \s-1EOF.\s0 Some \s-1BIO\s0 types may place additional information on the error queue. For more details see the individual \s-1BIO\s0 type manual pages. .PP If the underlying I/O structure is in a blocking mode almost all current \&\s-1BIO\s0 types will not request a retry, because the underlying I/O calls will not. If the application knows that the \s-1BIO\s0 type will never signal a retry then it need not call \fIBIO_should_retry()\fR after a failed \&\s-1BIO I/O\s0 call. This is typically done with file BIOs. .PP \&\s-1SSL\s0 BIOs are the only current exception to this rule: they can request a retry even if the underlying I/O structure is blocking, if a handshake occurs during a call to \fIBIO_read()\fR. An application can retry the failed call immediately or avoid this situation by setting \s-1SSL_MODE_AUTO_RETRY\s0 on the underlying \s-1SSL\s0 structure. .PP While an application may retry a failed non blocking call immediately this is likely to be very inefficient because the call will fail repeatedly until data can be processed or is available. An application will normally wait until the necessary condition is satisfied. How this is done depends on the underlying I/O structure. .PP For example if the cause is ultimately a socket and \fIBIO_should_read()\fR is true then a call to \fIselect()\fR may be made to wait until data is available and then retry the \s-1BIO\s0 operation. By combining the retry conditions of several non blocking BIOs in a single \fIselect()\fR call it is possible to service several BIOs in a single thread, though the performance may be poor if \s-1SSL\s0 BIOs are present because long delays can occur during the initial handshake process. .PP It is possible for a \s-1BIO\s0 to block indefinitely if the underlying I/O structure cannot process or return any data. This depends on the behaviour of the platforms I/O functions. This is often not desirable: one solution is to use non blocking I/O and use a timeout on the \fIselect()\fR (or equivalent) call. .SH "BUGS" .IX Header "BUGS" The OpenSSL \s-1ASN1\s0 functions cannot gracefully deal with non blocking I/O: that is they cannot retry after a partial read or write. This is usually worked around by only passing the relevant data to \s-1ASN1\s0 functions when the entire structure can be read or written. deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_f_ssl.30000644000175000017500000003617312360020730017401 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_f_ssl 3" .TH BIO_f_ssl 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_f_ssl, BIO_set_ssl, BIO_get_ssl, BIO_set_ssl_mode, BIO_set_ssl_renegotiate_bytes, BIO_get_num_renegotiates, BIO_set_ssl_renegotiate_timeout, BIO_new_ssl, BIO_new_ssl_connect, BIO_new_buffer_ssl_connect, BIO_ssl_copy_session_id, BIO_ssl_shutdown \- SSL BIO .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& BIO_METHOD *BIO_f_ssl(void); \& \& #define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl) \& #define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp) \& #define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL) \& #define BIO_set_ssl_renegotiate_bytes(b,num) \e \& BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL); \& #define BIO_set_ssl_renegotiate_timeout(b,seconds) \e \& BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL); \& #define BIO_get_num_renegotiates(b) \e \& BIO_ctrl(b,BIO_C_SET_SSL_NUM_RENEGOTIATES,0,NULL); \& \& BIO *BIO_new_ssl(SSL_CTX *ctx,int client); \& BIO *BIO_new_ssl_connect(SSL_CTX *ctx); \& BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx); \& int BIO_ssl_copy_session_id(BIO *to,BIO *from); \& void BIO_ssl_shutdown(BIO *bio); \& \& #define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL) .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_f_ssl()\fR returns the \s-1SSL BIO\s0 method. This is a filter \s-1BIO\s0 which is a wrapper round the OpenSSL \s-1SSL\s0 routines adding a \s-1BIO \s0\*(L"flavour\*(R" to \&\s-1SSL I/O.\s0 .PP I/O performed on an \s-1SSL BIO\s0 communicates using the \s-1SSL\s0 protocol with the SSLs read and write BIOs. If an \s-1SSL\s0 connection is not established then an attempt is made to establish one on the first I/O call. .PP If a \s-1BIO\s0 is appended to an \s-1SSL BIO\s0 using \fIBIO_push()\fR it is automatically used as the \s-1SSL\s0 BIOs read and write BIOs. .PP Calling \fIBIO_reset()\fR on an \s-1SSL BIO\s0 closes down any current \s-1SSL\s0 connection by calling \fISSL_shutdown()\fR. \fIBIO_reset()\fR is then sent to the next \s-1BIO\s0 in the chain: this will typically disconnect the underlying transport. The \s-1SSL BIO\s0 is then reset to the initial accept or connect state. .PP If the close flag is set when an \s-1SSL BIO\s0 is freed then the internal \&\s-1SSL\s0 structure is also freed using \fISSL_free()\fR. .PP \&\fIBIO_set_ssl()\fR sets the internal \s-1SSL\s0 pointer of \s-1BIO \s0\fBb\fR to \fBssl\fR using the close flag \fBc\fR. .PP \&\fIBIO_get_ssl()\fR retrieves the \s-1SSL\s0 pointer of \s-1BIO \s0\fBb\fR, it can then be manipulated using the standard \s-1SSL\s0 library functions. .PP \&\fIBIO_set_ssl_mode()\fR sets the \s-1SSL BIO\s0 mode to \fBclient\fR. If \fBclient\fR is 1 client mode is set. If \fBclient\fR is 0 server mode is set. .PP \&\fIBIO_set_ssl_renegotiate_bytes()\fR sets the renegotiate byte count to \fBnum\fR. When set after every \fBnum\fR bytes of I/O (read and write) the \s-1SSL\s0 session is automatically renegotiated. \fBnum\fR must be at least 512 bytes. .PP \&\fIBIO_set_ssl_renegotiate_timeout()\fR sets the renegotiate timeout to \&\fBseconds\fR. When the renegotiate timeout elapses the session is automatically renegotiated. .PP \&\fIBIO_get_num_renegotiates()\fR returns the total number of session renegotiations due to I/O or timeout. .PP \&\fIBIO_new_ssl()\fR allocates an \s-1SSL BIO\s0 using \s-1SSL_CTX \s0\fBctx\fR and using client mode if \fBclient\fR is non zero. .PP \&\fIBIO_new_ssl_connect()\fR creates a new \s-1BIO\s0 chain consisting of an \&\s-1SSL BIO \s0(using \fBctx\fR) followed by a connect \s-1BIO.\s0 .PP \&\fIBIO_new_buffer_ssl_connect()\fR creates a new \s-1BIO\s0 chain consisting of a buffering \s-1BIO,\s0 an \s-1SSL BIO \s0(using \fBctx\fR) and a connect \&\s-1BIO.\s0 .PP \&\fIBIO_ssl_copy_session_id()\fR copies an \s-1SSL\s0 session id between \&\s-1BIO\s0 chains \fBfrom\fR and \fBto\fR. It does this by locating the \&\s-1SSL\s0 BIOs in each chain and calling \fISSL_copy_session_id()\fR on the internal \s-1SSL\s0 pointer. .PP \&\fIBIO_ssl_shutdown()\fR closes down an \s-1SSL\s0 connection on \s-1BIO\s0 chain \fBbio\fR. It does this by locating the \s-1SSL BIO\s0 in the chain and calling \fISSL_shutdown()\fR on its internal \s-1SSL\s0 pointer. .PP \&\fIBIO_do_handshake()\fR attempts to complete an \s-1SSL\s0 handshake on the supplied \s-1BIO\s0 and establish the \s-1SSL\s0 connection. It returns 1 if the connection was established successfully. A zero or negative value is returned if the connection could not be established, the call \fIBIO_should_retry()\fR should be used for non blocking connect BIOs to determine if the call should be retried. If an \s-1SSL\s0 connection has already been established this call has no effect. .SH "NOTES" .IX Header "NOTES" \&\s-1SSL\s0 BIOs are exceptional in that if the underlying transport is non blocking they can still request a retry in exceptional circumstances. Specifically this will happen if a session renegotiation takes place during a \fIBIO_read()\fR operation, one case where this happens is when \s-1SGC\s0 or step up occurs. .PP In OpenSSL 0.9.6 and later the \s-1SSL\s0 flag \s-1SSL_AUTO_RETRY\s0 can be set to disable this behaviour. That is when this flag is set an \s-1SSL BIO\s0 using a blocking transport will never request a retry. .PP Since unknown \fIBIO_ctrl()\fR operations are sent through filter BIOs the servers name and port can be set using \fIBIO_set_host()\fR on the \s-1BIO\s0 returned by \fIBIO_new_ssl_connect()\fR without having to locate the connect \s-1BIO\s0 first. .PP Applications do not have to call \fIBIO_do_handshake()\fR but may wish to do so to separate the handshake process from other I/O processing. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\s-1TBA\s0 .SH "EXAMPLE" .IX Header "EXAMPLE" This \s-1SSL/TLS\s0 client example, attempts to retrieve a page from an \&\s-1SSL/TLS\s0 web server. The I/O routines are identical to those of the unencrypted example in \fIBIO_s_connect\fR\|(3). .PP .Vb 5 \& BIO *sbio, *out; \& int len; \& char tmpbuf[1024]; \& SSL_CTX *ctx; \& SSL *ssl; \& \& ERR_load_crypto_strings(); \& ERR_load_SSL_strings(); \& OpenSSL_add_all_algorithms(); \& \& /* We would seed the PRNG here if the platform didn\*(Aqt \& * do it automatically \& */ \& \& ctx = SSL_CTX_new(SSLv23_client_method()); \& \& /* We\*(Aqd normally set some stuff like the verify paths and \& * mode here because as things stand this will connect to \& * any server whose certificate is signed by any CA. \& */ \& \& sbio = BIO_new_ssl_connect(ctx); \& \& BIO_get_ssl(sbio, &ssl); \& \& if(!ssl) { \& fprintf(stderr, "Can\*(Aqt locate SSL pointer\en"); \& /* whatever ... */ \& } \& \& /* Don\*(Aqt want any retries */ \& SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); \& \& /* We might want to do other things with ssl here */ \& \& BIO_set_conn_hostname(sbio, "localhost:https"); \& \& out = BIO_new_fp(stdout, BIO_NOCLOSE); \& if(BIO_do_connect(sbio) <= 0) { \& fprintf(stderr, "Error connecting to server\en"); \& ERR_print_errors_fp(stderr); \& /* whatever ... */ \& } \& \& if(BIO_do_handshake(sbio) <= 0) { \& fprintf(stderr, "Error establishing SSL connection\en"); \& ERR_print_errors_fp(stderr); \& /* whatever ... */ \& } \& \& /* Could examine ssl here to get connection info */ \& \& BIO_puts(sbio, "GET / HTTP/1.0\en\en"); \& for(;;) { \& len = BIO_read(sbio, tmpbuf, 1024); \& if(len <= 0) break; \& BIO_write(out, tmpbuf, len); \& } \& BIO_free_all(sbio); \& BIO_free(out); .Ve .PP Here is a simple server example. It makes use of a buffering \&\s-1BIO\s0 to allow lines to be read from the \s-1SSL BIO\s0 using BIO_gets. It creates a pseudo web page containing the actual request from a client and also echoes the request to standard output. .PP .Vb 5 \& BIO *sbio, *bbio, *acpt, *out; \& int len; \& char tmpbuf[1024]; \& SSL_CTX *ctx; \& SSL *ssl; \& \& ERR_load_crypto_strings(); \& ERR_load_SSL_strings(); \& OpenSSL_add_all_algorithms(); \& \& /* Might seed PRNG here */ \& \& ctx = SSL_CTX_new(SSLv23_server_method()); \& \& if (!SSL_CTX_use_certificate_file(ctx,"server.pem",SSL_FILETYPE_PEM) \& || !SSL_CTX_use_PrivateKey_file(ctx,"server.pem",SSL_FILETYPE_PEM) \& || !SSL_CTX_check_private_key(ctx)) { \& \& fprintf(stderr, "Error setting up SSL_CTX\en"); \& ERR_print_errors_fp(stderr); \& return 0; \& } \& \& /* Might do other things here like setting verify locations and \& * DH and/or RSA temporary key callbacks \& */ \& \& /* New SSL BIO setup as server */ \& sbio=BIO_new_ssl(ctx,0); \& \& BIO_get_ssl(sbio, &ssl); \& \& if(!ssl) { \& fprintf(stderr, "Can\*(Aqt locate SSL pointer\en"); \& /* whatever ... */ \& } \& \& /* Don\*(Aqt want any retries */ \& SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); \& \& /* Create the buffering BIO */ \& \& bbio = BIO_new(BIO_f_buffer()); \& \& /* Add to chain */ \& sbio = BIO_push(bbio, sbio); \& \& acpt=BIO_new_accept("4433"); \& \& /* By doing this when a new connection is established \& * we automatically have sbio inserted into it. The \& * BIO chain is now \*(Aqswallowed\*(Aq by the accept BIO and \& * will be freed when the accept BIO is freed. \& */ \& \& BIO_set_accept_bios(acpt,sbio); \& \& out = BIO_new_fp(stdout, BIO_NOCLOSE); \& \& /* Setup accept BIO */ \& if(BIO_do_accept(acpt) <= 0) { \& fprintf(stderr, "Error setting up accept BIO\en"); \& ERR_print_errors_fp(stderr); \& return 0; \& } \& \& /* Now wait for incoming connection */ \& if(BIO_do_accept(acpt) <= 0) { \& fprintf(stderr, "Error in connection\en"); \& ERR_print_errors_fp(stderr); \& return 0; \& } \& \& /* We only want one connection so remove and free \& * accept BIO \& */ \& \& sbio = BIO_pop(acpt); \& \& BIO_free_all(acpt); \& \& if(BIO_do_handshake(sbio) <= 0) { \& fprintf(stderr, "Error in SSL handshake\en"); \& ERR_print_errors_fp(stderr); \& return 0; \& } \& \& BIO_puts(sbio, "HTTP/1.0 200 OK\er\enContent\-type: text/plain\er\en\er\en"); \& BIO_puts(sbio, "\er\enConnection Established\er\enRequest headers:\er\en"); \& BIO_puts(sbio, "\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\er\en"); \& \& for(;;) { \& len = BIO_gets(sbio, tmpbuf, 1024); \& if(len <= 0) break; \& BIO_write(sbio, tmpbuf, len); \& BIO_write(out, tmpbuf, len); \& /* Look for blank line signifying end of headers*/ \& if((tmpbuf[0] == \*(Aq\er\*(Aq) || (tmpbuf[0] == \*(Aq\en\*(Aq)) break; \& } \& \& BIO_puts(sbio, "\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\er\en"); \& BIO_puts(sbio, "\er\en"); \& \& /* Since there is a buffering BIO present we had better flush it */ \& BIO_flush(sbio); \& \& BIO_free_all(sbio); .Ve .SH "BUGS" .IX Header "BUGS" In OpenSSL versions before 1.0.0 the \fIBIO_pop()\fR call was handled incorrectly, the I/O \s-1BIO\s0 reference count was incorrectly incremented (instead of decremented) and dissociated with the \s-1SSL BIO\s0 even if the \s-1SSL BIO\s0 was not explicitly being popped (e.g. a pop higher up the chain). Applications which included workarounds for this bug (e.g. freeing BIOs more than once) should be modified to handle this fix or they may free up an already freed \s-1BIO.\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\s-1TBA\s0 deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_ssl_version.30000644000175000017500000001322012360020733022251 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_ssl_version 3" .TH SSL_CTX_set_ssl_version 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_ssl_version, SSL_set_ssl_method, SSL_get_ssl_method \&\- choose a new TLS/SSL method .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *method); \& int SSL_set_ssl_method(SSL *s, const SSL_METHOD *method); \& const SSL_METHOD *SSL_get_ssl_method(SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_ssl_version()\fR sets a new default \s-1TLS/SSL \s0\fBmethod\fR for \s-1SSL\s0 objects newly created from this \fBctx\fR. \s-1SSL\s0 objects already created with \&\fISSL_new\fR\|(3) are not affected, except when \&\fISSL_clear\fR\|(3) is being called. .PP \&\fISSL_set_ssl_method()\fR sets a new \s-1TLS/SSL \s0\fBmethod\fR for a particular \fBssl\fR object. It may be reset, when \fISSL_clear()\fR is called. .PP \&\fISSL_get_ssl_method()\fR returns a function pointer to the \s-1TLS/SSL\s0 method set in \fBssl\fR. .SH "NOTES" .IX Header "NOTES" The available \fBmethod\fR choices are described in \&\fISSL_CTX_new\fR\|(3). .PP When \fISSL_clear\fR\|(3) is called and no session is connected to an \s-1SSL\s0 object, the method of the \s-1SSL\s0 object is reset to the method currently set in the corresponding \s-1SSL_CTX\s0 object. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur for \fISSL_CTX_set_ssl_version()\fR and \fISSL_set_ssl_method()\fR: .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" The new choice failed, check the error stack to find out the reason. .ie n .IP "1" 4 .el .IP "\f(CW1\fR" 4 .IX Item "1" The operation succeeded. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_CTX_new\fR\|(3), \fISSL_new\fR\|(3), \&\fISSL_clear\fR\|(3), \fIssl\fR\|(3), \&\fISSL_set_connect_state\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/RSA_sign_ASN1_OCTET_STRING.30000644000175000017500000001322612360020724022052 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RSA_sign_ASN1_OCTET_STRING 3" .TH RSA_sign_ASN1_OCTET_STRING 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RSA_sign_ASN1_OCTET_STRING, RSA_verify_ASN1_OCTET_STRING \- RSA signatures .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int RSA_sign_ASN1_OCTET_STRING(int dummy, unsigned char *m, \& unsigned int m_len, unsigned char *sigret, unsigned int *siglen, \& RSA *rsa); \& \& int RSA_verify_ASN1_OCTET_STRING(int dummy, unsigned char *m, \& unsigned int m_len, unsigned char *sigbuf, unsigned int siglen, \& RSA *rsa); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIRSA_sign_ASN1_OCTET_STRING()\fR signs the octet string \fBm\fR of size \&\fBm_len\fR using the private key \fBrsa\fR represented in \s-1DER\s0 using \s-1PKCS\s0 #1 padding. It stores the signature in \fBsigret\fR and the signature size in \fBsiglen\fR. \fBsigret\fR must point to \fBRSA_size(rsa)\fR bytes of memory. .PP \&\fBdummy\fR is ignored. .PP \&\fIRSA_verify_ASN1_OCTET_STRING()\fR verifies that the signature \fBsigbuf\fR of size \fBsiglen\fR is the \s-1DER\s0 representation of a given octet string \&\fBm\fR of size \fBm_len\fR. \fBdummy\fR is ignored. \fBrsa\fR is the signer's public key. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIRSA_sign_ASN1_OCTET_STRING()\fR returns 1 on success, 0 otherwise. \&\fIRSA_verify_ASN1_OCTET_STRING()\fR returns 1 on successful verification, 0 otherwise. .PP The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "BUGS" .IX Header "BUGS" These functions serve no recognizable purpose. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fIobjects\fR\|(3), \&\fIrand\fR\|(3), \fIrsa\fR\|(3), \fIRSA_sign\fR\|(3), \&\fIRSA_verify\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIRSA_sign_ASN1_OCTET_STRING()\fR and \fIRSA_verify_ASN1_OCTET_STRING()\fR were added in SSLeay 0.8. deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_generate_prime.30000644000175000017500000002317412360020712021144 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_generate_prime 3" .TH BN_generate_prime 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_generate_prime, BN_is_prime_ex, BN_is_prime_fasttest_ex, BN_GENCB_call, BN_GENCB_set_old, BN_GENCB_set, BN_generate_prime, BN_is_prime, BN_is_prime_fasttest \- generate primes and test for primality .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int BN_generate_prime_ex(BIGNUM *ret,int bits,int safe, const BIGNUM *add, \& const BIGNUM *rem, BN_GENCB *cb); \& \& int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb); \& \& int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, \& int do_trial_division, BN_GENCB *cb); \& \& int BN_GENCB_call(BN_GENCB *cb, int a, int b); \& \& #define BN_GENCB_set_old(gencb, callback, cb_arg) ... \& \& #define BN_GENCB_set(gencb, callback, cb_arg) ... .Ve .PP Deprecated: .PP \&\s-1BIGNUM\s0 *BN_generate_prime(\s-1BIGNUM\s0 *ret, int num, int safe, \s-1BIGNUM\s0 *add, \s-1BIGNUM\s0 *rem, void (*callback)(int, int, void *), void *cb_arg); .PP .Vb 2 \& int BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int, int, \& void *), BN_CTX *ctx, void *cb_arg); \& \& int BN_is_prime_fasttest(const BIGNUM *a, int checks, \& void (*callback)(int, int, void *), BN_CTX *ctx, void *cb_arg, \& int do_trial_division); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBN_generate_prime_ex()\fR generates a pseudo-random prime number of bit length \fBbits\fR. If \fBret\fR is not \fB\s-1NULL\s0\fR, it will be used to store the number. .PP If \fBcb\fR is not \fB\s-1NULL\s0\fR, it is used as follows: .IP "\(bu" 4 \&\fBBN_GENCB_call(cb, 0, i)\fR is called after generating the i\-th potential prime number. .IP "\(bu" 4 While the number is being tested for primality, \&\fBBN_GENCB_call(cb, 1, j)\fR is called as described below. .IP "\(bu" 4 When a prime has been found, \fBBN_GENCB_call(cb, 2, i)\fR is called. .PP The prime may have to fulfill additional requirements for use in Diffie-Hellman key exchange: .PP If \fBadd\fR is not \fB\s-1NULL\s0\fR, the prime will fulfill the condition p % \fBadd\fR == \fBrem\fR (p % \fBadd\fR == 1 if \fBrem\fR == \fB\s-1NULL\s0\fR) in order to suit a given generator. .PP If \fBsafe\fR is true, it will be a safe prime (i.e. a prime p so that (p\-1)/2 is also prime). .PP The prime number generation has a negligible error probability. .PP \&\fIBN_is_prime_ex()\fR and \fIBN_is_prime_fasttest_ex()\fR test if the number \fBp\fR is prime. The following tests are performed until one of them shows that \&\fBp\fR is composite; if \fBp\fR passes all these tests, it is considered prime. .PP \&\fIBN_is_prime_fasttest_ex()\fR, when called with \fBdo_trial_division == 1\fR, first attempts trial division by a number of small primes; if no divisors are found by this test and \fBcb\fR is not \fB\s-1NULL\s0\fR, \&\fBBN_GENCB_call(cb, 1, \-1)\fR is called. If \fBdo_trial_division == 0\fR, this test is skipped. .PP Both \fIBN_is_prime_ex()\fR and \fIBN_is_prime_fasttest_ex()\fR perform a Miller-Rabin probabilistic primality test with \fBnchecks\fR iterations. If \&\fBnchecks == BN_prime_checks\fR, a number of iterations is used that yields a false positive rate of at most 2^\-80 for random input. .PP If \fBcb\fR is not \fB\s-1NULL\s0\fR, \fBBN_GENCB_call(cb, 1, j)\fR is called after the j\-th iteration (j = 0, 1, ...). \fBctx\fR is a pre-allocated \fB\s-1BN_CTX\s0\fR (to save the overhead of allocating and freeing the structure in a loop), or \fB\s-1NULL\s0\fR. .PP BN_GENCB_call calls the callback function held in the \fB\s-1BN_GENCB\s0\fR structure and passes the ints \fBa\fR and \fBb\fR as arguments. There are two types of \&\fB\s-1BN_GENCB\s0\fR structure that are supported: \*(L"new\*(R" style and \*(L"old\*(R" style. New programs should prefer the \*(L"new\*(R" style, whilst the \*(L"old\*(R" style is provided for backwards compatibility purposes. .PP For \*(L"new\*(R" style callbacks a \s-1BN_GENCB\s0 structure should be initialised with a call to BN_GENCB_set, where \fBgencb\fR is a \fB\s-1BN_GENCB\s0 *\fR, \fBcallback\fR is of type \fBint (*callback)(int, int, \s-1BN_GENCB\s0 *)\fR and \fBcb_arg\fR is a \fBvoid *\fR. \&\*(L"Old\*(R" style callbacks are the same except they are initialised with a call to BN_GENCB_set_old and \fBcallback\fR is of type \&\fBvoid (*callback)(int, int, void *)\fR. .PP A callback is invoked through a call to \fBBN_GENCB_call\fR. This will check the type of the callback and will invoke \fBcallback(a, b, gencb)\fR for new style callbacks or \fBcallback(a, b, cb_arg)\fR for old style. .PP BN_generate_prime (deprecated) works in the same way as BN_generate_prime_ex but expects an old style callback function directly in the \fBcallback\fR parameter, and an argument to pass to it in the \fBcb_arg\fR. Similarly BN_is_prime and BN_is_prime_fasttest are deprecated and can be compared to BN_is_prime_ex and BN_is_prime_fasttest_ex respectively. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBN_generate_prime_ex()\fR returns 1 on success or 0 on error. .PP \&\fIBN_is_prime_ex()\fR, \fIBN_is_prime_fasttest_ex()\fR, \fIBN_is_prime()\fR and \&\fIBN_is_prime_fasttest()\fR return 0 if the number is composite, 1 if it is prime with an error probability of less than 0.25^\fBnchecks\fR, and \&\-1 on error. .PP \&\fIBN_generate_prime()\fR returns the prime number on success, \fB\s-1NULL\s0\fR otherwise. .PP Callback functions should return 1 on success or 0 on error. .PP The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3), \fIERR_get_error\fR\|(3), \fIrand\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" The \fBcb_arg\fR arguments to \fIBN_generate_prime()\fR and to \fIBN_is_prime()\fR were added in SSLeay 0.9.0. The \fBret\fR argument to \fIBN_generate_prime()\fR was added in SSLeay 0.9.1. \&\fIBN_is_prime_fasttest()\fR was added in OpenSSL 0.9.5. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_client_cert_cb.30000644000175000017500000002072712360020732022653 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_client_cert_cb 3" .TH SSL_CTX_set_client_cert_cb 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_client_cert_cb, SSL_CTX_get_client_cert_cb \- handle client certificate callback function .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey)); \& int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL *ssl, X509 **x509, EVP_PKEY **pkey); \& int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_client_cert_cb()\fR sets the \fB\f(BIclient_cert_cb()\fB\fR callback, that is called when a client certificate is requested by a server and no certificate was yet set for the \s-1SSL\s0 object. .PP When \fB\f(BIclient_cert_cb()\fB\fR is \s-1NULL,\s0 no callback function is used. .PP \&\fISSL_CTX_get_client_cert_cb()\fR returns a pointer to the currently set callback function. .PP \&\fIclient_cert_cb()\fR is the application defined callback. If it wants to set a certificate, a certificate/private key combination must be set using the \fBx509\fR and \fBpkey\fR arguments and \*(L"1\*(R" must be returned. The certificate will be installed into \fBssl\fR, see the \s-1NOTES\s0 and \s-1BUGS\s0 sections. If no certificate should be set, \*(L"0\*(R" has to be returned and no certificate will be sent. A negative return value will suspend the handshake and the handshake function will return immediately. \fISSL_get_error\fR\|(3) will return \s-1SSL_ERROR_WANT_X509_LOOKUP\s0 to indicate, that the handshake was suspended. The next call to the handshake function will again lead to the call of \fIclient_cert_cb()\fR. It is the job of the \fIclient_cert_cb()\fR to store information about the state of the last call, if required to continue. .SH "NOTES" .IX Header "NOTES" During a handshake (or renegotiation) a server may request a certificate from the client. A client certificate must only be sent, when the server did send the request. .PP When a certificate was set using the \&\fISSL_CTX_use_certificate\fR\|(3) family of functions, it will be sent to the server. The \s-1TLS\s0 standard requires that only a certificate is sent, if it matches the list of acceptable CAs sent by the server. This constraint is violated by the default behavior of the OpenSSL library. Using the callback function it is possible to implement a proper selection routine or to allow a user interaction to choose the certificate to be sent. .PP If a callback function is defined and no certificate was yet defined for the \&\s-1SSL\s0 object, the callback function will be called. If the callback function returns a certificate, the OpenSSL library will try to load the private key and certificate data into the \s-1SSL\s0 object using the \fISSL_use_certificate()\fR and \fISSL_use_private_key()\fR functions. Thus it will permanently install the certificate and key for this \s-1SSL\s0 object. It will not be reset by calling \fISSL_clear\fR\|(3). If the callback returns no certificate, the OpenSSL library will not send a certificate. .SH "BUGS" .IX Header "BUGS" The \fIclient_cert_cb()\fR cannot return a complete certificate chain, it can only return one client certificate. If the chain only has a length of 2, the root \s-1CA\s0 certificate may be omitted according to the \s-1TLS\s0 standard and thus a standard conforming answer can be sent to the server. For a longer chain, the client must send the complete chain (with the option to leave out the root \s-1CA\s0 certificate). This can only be accomplished by either adding the intermediate \s-1CA\s0 certificates into the trusted certificate store for the \s-1SSL_CTX\s0 object (resulting in having to add \&\s-1CA\s0 certificates that otherwise maybe would not be trusted), or by adding the chain certificates using the \&\fISSL_CTX_add_extra_chain_cert\fR\|(3) function, which is only available for the \s-1SSL_CTX\s0 object as a whole and that therefore probably can only apply for one client certificate, making the concept of the callback function (to allow the choice from several certificates) questionable. .PP Once the \s-1SSL\s0 object has been used in conjunction with the callback function, the certificate will be set for the \s-1SSL\s0 object and will not be cleared even when \fISSL_clear\fR\|(3) is being called. It is therefore mandatory to destroy the \s-1SSL\s0 object using \fISSL_free\fR\|(3) and create a new one to return to the previous state. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_CTX_use_certificate\fR\|(3), \&\fISSL_CTX_add_extra_chain_cert\fR\|(3), \&\fISSL_get_client_CA_list\fR\|(3), \&\fISSL_clear\fR\|(3), \fISSL_free\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_library_init.30000644000175000017500000001314012360020736021005 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_library_init 3" .TH SSL_library_init 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_library_init, OpenSSL_add_ssl_algorithms, SSLeay_add_ssl_algorithms \&\- initialize SSL library by registering algorithms .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_library_init(void); \& #define OpenSSL_add_ssl_algorithms() SSL_library_init() \& #define SSLeay_add_ssl_algorithms() SSL_library_init() .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_library_init()\fR registers the available \s-1SSL/TLS\s0 ciphers and digests. .PP \&\fIOpenSSL_add_ssl_algorithms()\fR and \fISSLeay_add_ssl_algorithms()\fR are synonyms for \fISSL_library_init()\fR. .SH "NOTES" .IX Header "NOTES" \&\fISSL_library_init()\fR must be called before any other action takes place. \&\fISSL_library_init()\fR is not reentrant. .SH "WARNING" .IX Header "WARNING" \&\fISSL_library_init()\fR adds ciphers and digests used directly and indirectly by \&\s-1SSL/TLS.\s0 .SH "EXAMPLES" .IX Header "EXAMPLES" A typical \s-1TLS/SSL\s0 application will start with the library initialization, and provide readable error messages. .PP .Vb 2 \& SSL_load_error_strings(); /* readable error messages */ \& SSL_library_init(); /* initialize library */ .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_library_init()\fR always returns \*(L"1\*(R", so it is safe to discard the return value. .SH "NOTES" .IX Header "NOTES" OpenSSL 0.9.8o and 1.0.0a and later added \s-1SHA2\s0 algorithms to \fISSL_library_init()\fR. Applications which need to use \s-1SHA2\s0 in earlier versions of OpenSSL should call \&\fIOpenSSL_add_all_algorithms()\fR as well. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_load_error_strings\fR\|(3), \&\fIRAND_add\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/EC_GFp_simple_method.30000644000175000017500000001551312360020716021535 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EC_GFp_simple_method 3" .TH EC_GFp_simple_method 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EC_GFp_simple_method, EC_GFp_mont_method, EC_GFp_nist_method, EC_GFp_nistp224_method, EC_GFp_nistp256_method, EC_GFp_nistp521_method, EC_GF2m_simple_method, EC_METHOD_get_field_type \- Functions for obtaining EC_METHOD objects. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& const EC_METHOD *EC_GFp_simple_method(void); \& const EC_METHOD *EC_GFp_mont_method(void); \& const EC_METHOD *EC_GFp_nist_method(void); \& const EC_METHOD *EC_GFp_nistp224_method(void); \& const EC_METHOD *EC_GFp_nistp256_method(void); \& const EC_METHOD *EC_GFp_nistp521_method(void); \& \& const EC_METHOD *EC_GF2m_simple_method(void); \& \& int EC_METHOD_get_field_type(const EC_METHOD *meth); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The Elliptic Curve library provides a number of different implementations through a single common interface. When constructing a curve using EC_GROUP_new (see \fIEC_GROUP_new\fR\|(3)) an implementation method must be provided. The functions described here all return a const pointer to an \&\fB\s-1EC_METHOD\s0\fR structure that can be passed to \s-1EC_GROUP_NEW.\s0 It is important that the correct implementation type for the form of curve selected is used. .PP For F2^m curves there is only one implementation choice, i.e. EC_GF2_simple_method. .PP For Fp curves the lowest common denominator implementation is the EC_GFp_simple_method implementation. All other implementations are based on this one. EC_GFp_mont_method builds on EC_GFp_simple_method but adds the use of montgomery multiplication (see \fIBN_mod_mul_montgomery\fR\|(3)). EC_GFp_nist_method offers an implementation optimised for use with \s-1NIST\s0 recommended curves (\s-1NIST\s0 curves are available through EC_GROUP_new_by_curve_name as described in \fIEC_GROUP_new\fR\|(3)). .PP The functions EC_GFp_nistp224_method, EC_GFp_nistp256_method and EC_GFp_nistp521_method offer 64 bit optimised implementations for the \s-1NIST P224, P256\s0 and P521 curves respectively. Note, however, that these implementations are not available on all platforms. .PP EC_METHOD_get_field_type identifies what type of field the \s-1EC_METHOD\s0 structure supports, which will be either F2^m or Fp. If the field type is Fp then the value \fBNID_X9_62_prime_field\fR is returned. If the field type is F2^m then the value \fBNID_X9_62_characteristic_two_field\fR is returned. These values are defined in the obj_mac.h header file. .SH "RETURN VALUES" .IX Header "RETURN VALUES" All EC_GFp* functions and EC_GF2m_simple_method always return a const pointer to an \s-1EC_METHOD\s0 structure. .PP EC_METHOD_get_field_type returns an integer that identifies the type of field the \s-1EC_METHOD\s0 structure supports. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIcrypto\fR\|(3), \fIec\fR\|(3), \fIEC_GROUP_new\fR\|(3), \fIEC_GROUP_copy\fR\|(3), \&\fIEC_POINT_new\fR\|(3), \fIEC_POINT_add\fR\|(3), \fIEC_KEY_new\fR\|(3), \&\fId2i_ECPKParameters\fR\|(3), \&\fIBN_mod_mul_montgomery\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_s_bio.30000644000175000017500000003047412360020710017362 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_s_bio 3" .TH BIO_s_bio 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_s_bio, BIO_make_bio_pair, BIO_destroy_bio_pair, BIO_shutdown_wr, BIO_set_write_buf_size, BIO_get_write_buf_size, BIO_new_bio_pair, BIO_get_write_guarantee, BIO_ctrl_get_write_guarantee, BIO_get_read_request, BIO_ctrl_get_read_request, BIO_ctrl_reset_read_request \- BIO pair BIO .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIO_METHOD *BIO_s_bio(void); \& \& #define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2) \& #define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL) \& \& #define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL) \& \& #define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL) \& #define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL) \& \& int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, BIO **bio2, size_t writebuf2); \& \& #define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL) \& size_t BIO_ctrl_get_write_guarantee(BIO *b); \& \& #define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL) \& size_t BIO_ctrl_get_read_request(BIO *b); \& \& int BIO_ctrl_reset_read_request(BIO *b); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_s_bio()\fR returns the method for a \s-1BIO\s0 pair. A \s-1BIO\s0 pair is a pair of source/sink BIOs where data written to either half of the pair is buffered and can be read from the other half. Both halves must usually by handled by the same application thread since no locking is done on the internal data structures. .PP Since \s-1BIO\s0 chains typically end in a source/sink \s-1BIO\s0 it is possible to make this one half of a \s-1BIO\s0 pair and have all the data processed by the chain under application control. .PP One typical use of \s-1BIO\s0 pairs is to place \s-1TLS/SSL I/O\s0 under application control, this can be used when the application wishes to use a non standard transport for \s-1TLS/SSL\s0 or the normal socket routines are inappropriate. .PP Calls to \fIBIO_read()\fR will read data from the buffer or request a retry if no data is available. .PP Calls to \fIBIO_write()\fR will place data in the buffer or request a retry if the buffer is full. .PP The standard calls \fIBIO_ctrl_pending()\fR and \fIBIO_ctrl_wpending()\fR can be used to determine the amount of pending data in the read or write buffer. .PP \&\fIBIO_reset()\fR clears any data in the write buffer. .PP \&\fIBIO_make_bio_pair()\fR joins two separate BIOs into a connected pair. .PP \&\fIBIO_destroy_pair()\fR destroys the association between two connected BIOs. Freeing up any half of the pair will automatically destroy the association. .PP \&\fIBIO_shutdown_wr()\fR is used to close down a \s-1BIO \s0\fBb\fR. After this call no further writes on \s-1BIO \s0\fBb\fR are allowed (they will return an error). Reads on the other half of the pair will return any pending data or \s-1EOF\s0 when all pending data has been read. .PP \&\fIBIO_set_write_buf_size()\fR sets the write buffer size of \s-1BIO \s0\fBb\fR to \fBsize\fR. If the size is not initialized a default value is used. This is currently 17K, sufficient for a maximum size \s-1TLS\s0 record. .PP \&\fIBIO_get_write_buf_size()\fR returns the size of the write buffer. .PP \&\fIBIO_new_bio_pair()\fR combines the calls to \fIBIO_new()\fR, \fIBIO_make_bio_pair()\fR and \&\fIBIO_set_write_buf_size()\fR to create a connected pair of BIOs \fBbio1\fR, \fBbio2\fR with write buffer sizes \fBwritebuf1\fR and \fBwritebuf2\fR. If either size is zero then the default size is used. \fIBIO_new_bio_pair()\fR does not check whether \&\fBbio1\fR or \fBbio2\fR do point to some other \s-1BIO,\s0 the values are overwritten, \&\fIBIO_free()\fR is not called. .PP \&\fIBIO_get_write_guarantee()\fR and \fIBIO_ctrl_get_write_guarantee()\fR return the maximum length of data that can be currently written to the \s-1BIO.\s0 Writes larger than this value will return a value from \fIBIO_write()\fR less than the amount requested or if the buffer is full request a retry. \fIBIO_ctrl_get_write_guarantee()\fR is a function whereas \fIBIO_get_write_guarantee()\fR is a macro. .PP \&\fIBIO_get_read_request()\fR and \fIBIO_ctrl_get_read_request()\fR return the amount of data requested, or the buffer size if it is less, if the last read attempt at the other half of the \s-1BIO\s0 pair failed due to an empty buffer. This can be used to determine how much data should be written to the \s-1BIO\s0 so the next read will succeed: this is most useful in \s-1TLS/SSL\s0 applications where the amount of data read is usually meaningful rather than just a buffer size. After a successful read this call will return zero. It also will return zero once new data has been written satisfying the read request or part of it. Note that \fIBIO_get_read_request()\fR never returns an amount larger than that returned by \fIBIO_get_write_guarantee()\fR. .PP \&\fIBIO_ctrl_reset_read_request()\fR can also be used to reset the value returned by \&\fIBIO_get_read_request()\fR to zero. .SH "NOTES" .IX Header "NOTES" Both halves of a \s-1BIO\s0 pair should be freed. That is even if one half is implicit freed due to a \fIBIO_free_all()\fR or \fISSL_free()\fR call the other half needs to be freed. .PP When used in bidirectional applications (such as \s-1TLS/SSL\s0) care should be taken to flush any data in the write buffer. This can be done by calling \&\fIBIO_pending()\fR on the other half of the pair and, if any data is pending, reading it and sending it to the underlying transport. This must be done before any normal processing (such as calling \fIselect()\fR ) due to a request and \&\fIBIO_should_read()\fR being true. .PP To see why this is important consider a case where a request is sent using \&\fIBIO_write()\fR and a response read with \fIBIO_read()\fR, this can occur during an \&\s-1TLS/SSL\s0 handshake for example. \fIBIO_write()\fR will succeed and place data in the write buffer. \fIBIO_read()\fR will initially fail and \fIBIO_should_read()\fR will be true. If the application then waits for data to be available on the underlying transport before flushing the write buffer it will never succeed because the request was never sent! .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBIO_new_bio_pair()\fR returns 1 on success, with the new BIOs available in \&\fBbio1\fR and \fBbio2\fR, or 0 on failure, with \s-1NULL\s0 pointers stored into the locations for \fBbio1\fR and \fBbio2\fR. Check the error stack for more information. .PP [\s-1TODO:\s0 More return values need to be added here] .SH "EXAMPLE" .IX Header "EXAMPLE" The \s-1BIO\s0 pair can be used to have full control over the network access of an application. The application can call \fIselect()\fR on the socket as required without having to go through the SSL-interface. .PP .Vb 6 \& BIO *internal_bio, *network_bio; \& ... \& BIO_new_bio_pair(internal_bio, 0, network_bio, 0); \& SSL_set_bio(ssl, internal_bio, internal_bio); \& SSL_operations(); \& ... \& \& application | TLS\-engine \& | | \& +\-\-\-\-\-\-\-\-\-\-> SSL_operations() \& | /\e || \& | || \e/ \& | BIO\-pair (internal_bio) \& +\-\-\-\-\-\-\-\-\-\-< BIO\-pair (network_bio) \& | | \& socket | \& \& ... \& SSL_free(ssl); /* implicitly frees internal_bio */ \& BIO_free(network_bio); \& ... .Ve .PP As the \s-1BIO\s0 pair will only buffer the data and never directly access the connection, it behaves non-blocking and will return as soon as the write buffer is full or the read buffer is drained. Then the application has to flush the write buffer and/or fill the read buffer. .PP Use the \fIBIO_ctrl_pending()\fR, to find out whether data is buffered in the \s-1BIO\s0 and must be transfered to the network. Use \fIBIO_ctrl_get_read_request()\fR to find out, how many bytes must be written into the buffer before the \&\fISSL_operation()\fR can successfully be continued. .SH "WARNING" .IX Header "WARNING" As the data is buffered, \fISSL_operation()\fR may return with a \s-1ERROR_SSL_WANT_READ\s0 condition, but there is still data in the write buffer. An application must not rely on the error value of \fISSL_operation()\fR but must assure that the write buffer is always flushed first. Otherwise a deadlock may occur as the peer might be waiting for the data before being able to continue. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_set_bio\fR\|(3), \fIssl\fR\|(3), \fIbio\fR\|(3), \&\fIBIO_should_retry\fR\|(3), \fIBIO_read\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/version.10000644000175000017500000001164712360020743017270 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "version 1" .TH version 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" version \- print OpenSSL version information .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl version\fR [\fB\-a\fR] [\fB\-v\fR] [\fB\-b\fR] [\fB\-o\fR] [\fB\-f\fR] [\fB\-p\fR] [\fB\-d\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" This command is used to print out version information about OpenSSL. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-a\fR" 4 .IX Item "-a" all information, this is the same as setting all the other flags. .IP "\fB\-v\fR" 4 .IX Item "-v" the current OpenSSL version. .IP "\fB\-b\fR" 4 .IX Item "-b" the date the current version of OpenSSL was built. .IP "\fB\-o\fR" 4 .IX Item "-o" option information: various options set when the library was built. .IP "\fB\-f\fR" 4 .IX Item "-f" compilation flags. .IP "\fB\-p\fR" 4 .IX Item "-p" platform setting. .IP "\fB\-d\fR" 4 .IX Item "-d" \&\s-1OPENSSLDIR\s0 setting. .SH "NOTES" .IX Header "NOTES" The output of \fBopenssl version \-a\fR would typically be used when sending in a bug report. .SH "HISTORY" .IX Header "HISTORY" The \fB\-d\fR option was added in OpenSSL 0.9.7. deps/libressl-pnacl-sys-2.1.6/libressl/man/DSA_sign.30000644000175000017500000001431212360020716017224 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DSA_sign 3" .TH DSA_sign 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DSA_sign, DSA_sign_setup, DSA_verify \- DSA signatures .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int DSA_sign(int type, const unsigned char *dgst, int len, \& unsigned char *sigret, unsigned int *siglen, DSA *dsa); \& \& int DSA_sign_setup(DSA *dsa, BN_CTX *ctx, BIGNUM **kinvp, \& BIGNUM **rp); \& \& int DSA_verify(int type, const unsigned char *dgst, int len, \& unsigned char *sigbuf, int siglen, DSA *dsa); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIDSA_sign()\fR computes a digital signature on the \fBlen\fR byte message digest \fBdgst\fR using the private key \fBdsa\fR and places its \s-1ASN.1 DER\s0 encoding at \fBsigret\fR. The length of the signature is places in *\fBsiglen\fR. \fBsigret\fR must point to DSA_size(\fBdsa\fR) bytes of memory. .PP \&\fIDSA_sign_setup()\fR may be used to precompute part of the signing operation in case signature generation is time-critical. It expects \&\fBdsa\fR to contain \s-1DSA\s0 parameters. It places the precomputed values in newly allocated \fB\s-1BIGNUM\s0\fRs at *\fBkinvp\fR and *\fBrp\fR, after freeing the old ones unless *\fBkinvp\fR and *\fBrp\fR are \s-1NULL.\s0 These values may be passed to \fIDSA_sign()\fR in \fBdsa\->kinv\fR and \fBdsa\->r\fR. \&\fBctx\fR is a pre-allocated \fB\s-1BN_CTX\s0\fR or \s-1NULL.\s0 .PP \&\fIDSA_verify()\fR verifies that the signature \fBsigbuf\fR of size \fBsiglen\fR matches a given message digest \fBdgst\fR of size \fBlen\fR. \&\fBdsa\fR is the signer's public key. .PP The \fBtype\fR parameter is ignored. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIDSA_sign()\fR and \fIDSA_sign_setup()\fR return 1 on success, 0 on error. \&\fIDSA_verify()\fR returns 1 for a valid signature, 0 for an incorrect signature and \-1 on error. The error codes can be obtained by \&\fIERR_get_error\fR\|(3). .SH "CONFORMING TO" .IX Header "CONFORMING TO" \&\s-1US\s0 Federal Information Processing Standard \s-1FIPS 186 \s0(Digital Signature Standard, \s-1DSS\s0), \s-1ANSI X9.30\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdsa\fR\|(3), \fIERR_get_error\fR\|(3), \fIrand\fR\|(3), \&\fIDSA_do_sign\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIDSA_sign()\fR and \fIDSA_verify()\fR are available in all versions of SSLeay. \&\fIDSA_sign_setup()\fR was added in SSLeay 0.8. deps/libressl-pnacl-sys-2.1.6/libressl/man/errstr.10000644000175000017500000001126412360020741017115 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "errstr 1" .TH errstr 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" errstr \- lookup error codes .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl errstr error_code\fR .SH "DESCRIPTION" .IX Header "DESCRIPTION" Sometimes an application will not load error message and only numerical forms will be available. The \fBerrstr\fR utility can be used to display the meaning of the hex code. The hex code is the hex digits after the second colon. .SH "EXAMPLE" .IX Header "EXAMPLE" The error code: .PP .Vb 1 \& 27594:error:2006D080:lib(32):func(109):reason(128):bss_file.c:107: .Ve .PP can be displayed with: .PP .Vb 1 \& openssl errstr 2006D080 .Ve .PP to produce the error message: .PP .Vb 1 \& error:2006D080:BIO routines:BIO_new_file:no such file .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIerr\fR\|(3), \&\fIERR_load_crypto_strings\fR\|(3), \&\fISSL_load_error_strings\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/s_time.10000644000175000017500000002501712360020743017057 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "s_time 1" .TH s_time 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" s_time \- SSL/TLS performance timing program .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBs_time\fR [\fB\-connect host:port\fR] [\fB\-www page\fR] [\fB\-cert filename\fR] [\fB\-key filename\fR] [\fB\-CApath directory\fR] [\fB\-CAfile filename\fR] [\fB\-reuse\fR] [\fB\-new\fR] [\fB\-verify depth\fR] [\fB\-nbio\fR] [\fB\-time seconds\fR] [\fB\-ssl2\fR] [\fB\-ssl3\fR] [\fB\-bugs\fR] [\fB\-cipher cipherlist\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBs_client\fR command implements a generic \s-1SSL/TLS\s0 client which connects to a remote host using \s-1SSL/TLS.\s0 It can request a page from the server and includes the time to transfer the payload data in its timing measurements. It measures the number of connections within a given timeframe, the amount of data transferred (if any), and calculates the average time spent for one connection. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-connect host:port\fR" 4 .IX Item "-connect host:port" This specifies the host and optional port to connect to. .IP "\fB\-www page\fR" 4 .IX Item "-www page" This specifies the page to \s-1GET\s0 from the server. A value of '/' gets the index.htm[l] page. If this parameter is not specified, then \fBs_time\fR will only perform the handshake to establish \s-1SSL\s0 connections but not transfer any payload data. .IP "\fB\-cert certname\fR" 4 .IX Item "-cert certname" The certificate to use, if one is requested by the server. The default is not to use a certificate. The file is in \s-1PEM\s0 format. .IP "\fB\-key keyfile\fR" 4 .IX Item "-key keyfile" The private key to use. If not specified then the certificate file will be used. The file is in \s-1PEM\s0 format. .IP "\fB\-verify depth\fR" 4 .IX Item "-verify depth" The verify depth to use. This specifies the maximum length of the server certificate chain and turns on server certificate verification. Currently the verify operation continues after errors so all the problems with a certificate chain can be seen. As a side effect the connection will never fail due to a server certificate verify failure. .IP "\fB\-CApath directory\fR" 4 .IX Item "-CApath directory" The directory to use for server certificate verification. This directory must be in \*(L"hash format\*(R", see \fBverify\fR for more information. These are also used when building the client certificate chain. .IP "\fB\-CAfile file\fR" 4 .IX Item "-CAfile file" A file containing trusted certificates to use during server authentication and to use when attempting to build the client certificate chain. .IP "\fB\-new\fR" 4 .IX Item "-new" performs the timing test using a new session \s-1ID\s0 for each connection. If neither \fB\-new\fR nor \fB\-reuse\fR are specified, they are both on by default and executed in sequence. .IP "\fB\-reuse\fR" 4 .IX Item "-reuse" performs the timing test using the same session \s-1ID\s0; this can be used as a test that session caching is working. If neither \fB\-new\fR nor \fB\-reuse\fR are specified, they are both on by default and executed in sequence. .IP "\fB\-nbio\fR" 4 .IX Item "-nbio" turns on non-blocking I/O. .IP "\fB\-ssl2\fR, \fB\-ssl3\fR" 4 .IX Item "-ssl2, -ssl3" these options disable the use of certain \s-1SSL\s0 or \s-1TLS\s0 protocols. By default the initial handshake uses a method which should be compatible with all servers and permit them to use \s-1SSL\s0 v3, \s-1SSL\s0 v2 or \s-1TLS\s0 as appropriate. The timing program is not as rich in options to turn protocols on and off as the \fIs_client\fR\|(1) program and may not connect to all servers. .Sp Unfortunately there are a lot of ancient and broken servers in use which cannot handle this technique and will fail to connect. Some servers only work if \s-1TLS\s0 is turned off with the \fB\-ssl3\fR option; others will only support \s-1SSL\s0 v2 and may need the \fB\-ssl2\fR option. .IP "\fB\-bugs\fR" 4 .IX Item "-bugs" there are several known bug in \s-1SSL\s0 and \s-1TLS\s0 implementations. Adding this option enables various workarounds. .IP "\fB\-cipher cipherlist\fR" 4 .IX Item "-cipher cipherlist" this allows the cipher list sent by the client to be modified. Although the server determines which cipher suite is used it should take the first supported cipher in the list sent by the client. See the \fIciphers\fR\|(1) command for more information. .IP "\fB\-time length\fR" 4 .IX Item "-time length" specifies how long (in seconds) \fBs_time\fR should establish connections and optionally transfer payload data from a server. Server and client performance and the link speed determine how many connections \fBs_time\fR can establish. .SH "NOTES" .IX Header "NOTES" \&\fBs_client\fR can be used to measure the performance of an \s-1SSL\s0 connection. To connect to an \s-1SSL HTTP\s0 server and get the default page the command .PP .Vb 1 \& openssl s_time \-connect servername:443 \-www / \-CApath yourdir \-CAfile yourfile.pem \-cipher commoncipher [\-ssl3] .Ve .PP would typically be used (https uses port 443). 'commoncipher' is a cipher to which both client and server can agree, see the \fIciphers\fR\|(1) command for details. .PP If the handshake fails then there are several possible causes, if it is nothing obvious like no client certificate then the \fB\-bugs\fR, \fB\-ssl2\fR, \&\fB\-ssl3\fR options can be tried in case it is a buggy server. In particular you should play with these options \fBbefore\fR submitting a bug report to an OpenSSL mailing list. .PP A frequent problem when attempting to get client certificates working is that a web client complains it has no certificates or gives an empty list to choose from. This is normally because the server is not sending the clients certificate authority in its \*(L"acceptable \s-1CA\s0 list\*(R" when it requests a certificate. By using \fIs_client\fR\|(1) the \s-1CA\s0 list can be viewed and checked. However some servers only request client authentication after a specific \s-1URL\s0 is requested. To obtain the list in this case it is necessary to use the \fB\-prexit\fR option of \fIs_client\fR\|(1) and send an \s-1HTTP\s0 request for an appropriate page. .PP If a certificate is specified on the command line using the \fB\-cert\fR option it will not be used unless the server specifically requests a client certificate. Therefor merely including a client certificate on the command line is no guarantee that the certificate works. .SH "BUGS" .IX Header "BUGS" Because this program does not have all the options of the \&\fIs_client\fR\|(1) program to turn protocols on and off, you may not be able to measure the performance of all protocols with all servers. .PP The \fB\-verify\fR option should really exit if the server verification fails. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIs_client\fR\|(1), \fIs_server\fR\|(1), \fIciphers\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_SealInit.30000644000175000017500000001615112360020721020016 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_SealInit 3" .TH EVP_SealInit 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_SealInit, EVP_SealUpdate, EVP_SealFinal \- EVP envelope encryption .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, \& unsigned char **ek, int *ekl, unsigned char *iv, \& EVP_PKEY **pubk, int npubk); \& int EVP_SealUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, \& int *outl, unsigned char *in, int inl); \& int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, \& int *outl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \s-1EVP\s0 envelope routines are a high level interface to envelope encryption. They generate a random key and \s-1IV \s0(if required) then \&\*(L"envelope\*(R" it by using public key encryption. Data can then be encrypted using this key. .PP \&\fIEVP_SealInit()\fR initializes a cipher context \fBctx\fR for encryption with cipher \fBtype\fR using a random secret key and \s-1IV. \s0\fBtype\fR is normally supplied by a function such as \fIEVP_aes_256_cbc()\fR. The secret key is encrypted using one or more public keys, this allows the same encrypted data to be decrypted using any of the corresponding private keys. \fBek\fR is an array of buffers where the public key encrypted secret key will be written, each buffer must contain enough room for the corresponding encrypted key: that is \&\fBek[i]\fR must have room for \fBEVP_PKEY_size(pubk[i])\fR bytes. The actual size of each encrypted secret key is written to the array \fBekl\fR. \fBpubk\fR is an array of \fBnpubk\fR public keys. .PP The \fBiv\fR parameter is a buffer where the generated \s-1IV\s0 is written to. It must contain enough room for the corresponding cipher's \s-1IV,\s0 as determined by (for example) EVP_CIPHER_iv_length(type). .PP If the cipher does not require an \s-1IV\s0 then the \fBiv\fR parameter is ignored and can be \fB\s-1NULL\s0\fR. .PP \&\fIEVP_SealUpdate()\fR and \fIEVP_SealFinal()\fR have exactly the same properties as the \fIEVP_EncryptUpdate()\fR and \fIEVP_EncryptFinal()\fR routines, as documented on the \fIEVP_EncryptInit\fR\|(3) manual page. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_SealInit()\fR returns 0 on error or \fBnpubk\fR if successful. .PP \&\fIEVP_SealUpdate()\fR and \fIEVP_SealFinal()\fR return 1 for success and 0 for failure. .SH "NOTES" .IX Header "NOTES" The public key must be \s-1RSA\s0 because it is the only OpenSSL public key algorithm that supports key transport. .PP Envelope encryption is the usual method of using public key encryption on large amounts of data, this is because public key encryption is slow but symmetric encryption is fast. So symmetric encryption is used for bulk encryption and the small random symmetric key used is transferred using public key encryption. .PP It is possible to call \fIEVP_SealInit()\fR twice in the same way as \&\fIEVP_EncryptInit()\fR. The first call should have \fBnpubk\fR set to 0 and (after setting any cipher parameters) it should be called again with \fBtype\fR set to \s-1NULL.\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIevp\fR\|(3), \fIrand\fR\|(3), \&\fIEVP_EncryptInit\fR\|(3), \&\fIEVP_OpenInit\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIEVP_SealFinal()\fR did not return a value before OpenSSL 0.9.7. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_verify.30000644000175000017500000003776712360020733021235 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_verify 3" .TH SSL_CTX_set_verify 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_verify, SSL_set_verify, SSL_CTX_set_verify_depth, SSL_set_verify_depth \- set peer certificate verification parameters .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, \& int (*verify_callback)(int, X509_STORE_CTX *)); \& void SSL_set_verify(SSL *s, int mode, \& int (*verify_callback)(int, X509_STORE_CTX *)); \& void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth); \& void SSL_set_verify_depth(SSL *s, int depth); \& \& int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_verify()\fR sets the verification flags for \fBctx\fR to be \fBmode\fR and specifies the \fBverify_callback\fR function to be used. If no callback function shall be specified, the \s-1NULL\s0 pointer can be used for \fBverify_callback\fR. .PP \&\fISSL_set_verify()\fR sets the verification flags for \fBssl\fR to be \fBmode\fR and specifies the \fBverify_callback\fR function to be used. If no callback function shall be specified, the \s-1NULL\s0 pointer can be used for \fBverify_callback\fR. In this case last \fBverify_callback\fR set specifically for this \fBssl\fR remains. If no special \fBcallback\fR was set before, the default callback for the underlying \&\fBctx\fR is used, that was valid at the time \fBssl\fR was created with \&\fISSL_new\fR\|(3). .PP \&\fISSL_CTX_set_verify_depth()\fR sets the maximum \fBdepth\fR for the certificate chain verification that shall be allowed for \fBctx\fR. (See the \s-1BUGS\s0 section.) .PP \&\fISSL_set_verify_depth()\fR sets the maximum \fBdepth\fR for the certificate chain verification that shall be allowed for \fBssl\fR. (See the \s-1BUGS\s0 section.) .SH "NOTES" .IX Header "NOTES" The verification of certificates can be controlled by a set of logically or'ed \fBmode\fR flags: .IP "\s-1SSL_VERIFY_NONE\s0" 4 .IX Item "SSL_VERIFY_NONE" \&\fBServer mode:\fR the server will not send a client certificate request to the client, so the client will not send a certificate. .Sp \&\fBClient mode:\fR if not using an anonymous cipher (by default disabled), the server will send a certificate which will be checked. The result of the certificate verification process can be checked after the \s-1TLS/SSL\s0 handshake using the \fISSL_get_verify_result\fR\|(3) function. The handshake will be continued regardless of the verification result. .IP "\s-1SSL_VERIFY_PEER\s0" 4 .IX Item "SSL_VERIFY_PEER" \&\fBServer mode:\fR the server sends a client certificate request to the client. The certificate returned (if any) is checked. If the verification process fails, the \s-1TLS/SSL\s0 handshake is immediately terminated with an alert message containing the reason for the verification failure. The behaviour can be controlled by the additional \&\s-1SSL_VERIFY_FAIL_IF_NO_PEER_CERT\s0 and \s-1SSL_VERIFY_CLIENT_ONCE\s0 flags. .Sp \&\fBClient mode:\fR the server certificate is verified. If the verification process fails, the \s-1TLS/SSL\s0 handshake is immediately terminated with an alert message containing the reason for the verification failure. If no server certificate is sent, because an anonymous cipher is used, \s-1SSL_VERIFY_PEER\s0 is ignored. .IP "\s-1SSL_VERIFY_FAIL_IF_NO_PEER_CERT\s0" 4 .IX Item "SSL_VERIFY_FAIL_IF_NO_PEER_CERT" \&\fBServer mode:\fR if the client did not return a certificate, the \s-1TLS/SSL\s0 handshake is immediately terminated with a \*(L"handshake failure\*(R" alert. This flag must be used together with \s-1SSL_VERIFY_PEER.\s0 .Sp \&\fBClient mode:\fR ignored .IP "\s-1SSL_VERIFY_CLIENT_ONCE\s0" 4 .IX Item "SSL_VERIFY_CLIENT_ONCE" \&\fBServer mode:\fR only request a client certificate on the initial \s-1TLS/SSL\s0 handshake. Do not ask for a client certificate again in case of a renegotiation. This flag must be used together with \s-1SSL_VERIFY_PEER.\s0 .Sp \&\fBClient mode:\fR ignored .PP Exactly one of the \fBmode\fR flags \s-1SSL_VERIFY_NONE\s0 and \s-1SSL_VERIFY_PEER\s0 must be set at any time. .PP The actual verification procedure is performed either using the built-in verification procedure or using another application provided verification function set with \&\fISSL_CTX_set_cert_verify_callback\fR\|(3). The following descriptions apply in the case of the built-in procedure. An application provided procedure also has access to the verify depth information and the \fIverify_callback()\fR function, but the way this information is used may be different. .PP \&\fISSL_CTX_set_verify_depth()\fR and \fISSL_set_verify_depth()\fR set the limit up to which depth certificates in a chain are used during the verification procedure. If the certificate chain is longer than allowed, the certificates above the limit are ignored. Error messages are generated as if these certificates would not be present, most likely a X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY will be issued. The depth count is \*(L"level 0:peer certificate\*(R", \*(L"level 1: \s-1CA\s0 certificate\*(R", \&\*(L"level 2: higher level \s-1CA\s0 certificate\*(R", and so on. Setting the maximum depth to 2 allows the levels 0, 1, and 2. The default depth limit is 100, allowing for the peer certificate and additional 100 \s-1CA\s0 certificates. .PP The \fBverify_callback\fR function is used to control the behaviour when the \&\s-1SSL_VERIFY_PEER\s0 flag is set. It must be supplied by the application and receives two arguments: \fBpreverify_ok\fR indicates, whether the verification of the certificate in question was passed (preverify_ok=1) or not (preverify_ok=0). \fBx509_ctx\fR is a pointer to the complete context used for the certificate chain verification. .PP The certificate chain is checked starting with the deepest nesting level (the root \s-1CA\s0 certificate) and worked upward to the peer's certificate. At each level signatures and issuer attributes are checked. Whenever a verification error is found, the error number is stored in \fBx509_ctx\fR and \fBverify_callback\fR is called with \fBpreverify_ok\fR=0. By applying X509_CTX_store_* functions \fBverify_callback\fR can locate the certificate in question and perform additional steps (see \s-1EXAMPLES\s0). If no error is found for a certificate, \fBverify_callback\fR is called with \fBpreverify_ok\fR=1 before advancing to the next level. .PP The return value of \fBverify_callback\fR controls the strategy of the further verification process. If \fBverify_callback\fR returns 0, the verification process is immediately stopped with \*(L"verification failed\*(R" state. If \&\s-1SSL_VERIFY_PEER\s0 is set, a verification failure alert is sent to the peer and the \s-1TLS/SSL\s0 handshake is terminated. If \fBverify_callback\fR returns 1, the verification process is continued. If \fBverify_callback\fR always returns 1, the \s-1TLS/SSL\s0 handshake will not be terminated with respect to verification failures and the connection will be established. The calling process can however retrieve the error code of the last verification error using \&\fISSL_get_verify_result\fR\|(3) or by maintaining its own error storage managed by \fBverify_callback\fR. .PP If no \fBverify_callback\fR is specified, the default callback will be used. Its return value is identical to \fBpreverify_ok\fR, so that any verification failure will lead to a termination of the \s-1TLS/SSL\s0 handshake with an alert message, if \s-1SSL_VERIFY_PEER\s0 is set. .SH "BUGS" .IX Header "BUGS" In client mode, it is not checked whether the \s-1SSL_VERIFY_PEER\s0 flag is set, but whether \s-1SSL_VERIFY_NONE\s0 is not set. This can lead to unexpected behaviour, if the \s-1SSL_VERIFY_PEER\s0 and \s-1SSL_VERIFY_NONE\s0 are not used as required (exactly one must be set at any time). .PP The certificate verification depth set with SSL[_CTX]\fI_verify_depth()\fR stops the verification at a certain depth. The error message produced will be that of an incomplete certificate chain and not X509_V_ERR_CERT_CHAIN_TOO_LONG as may be expected. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The SSL*_set_verify*() functions do not provide diagnostic information. .SH "EXAMPLES" .IX Header "EXAMPLES" The following code sequence realizes an example \fBverify_callback\fR function that will always continue the \s-1TLS/SSL\s0 handshake regardless of verification failure, if wished. The callback realizes a verification depth limit with more informational output. .PP All verification errors are printed; information about the certificate chain is printed on request. The example is realized for a server that does allow but not require client certificates. .PP The example makes use of the ex_data technique to store application data into/retrieve application data from the \s-1SSL\s0 structure (see \fISSL_get_ex_new_index\fR\|(3), \&\fISSL_get_ex_data_X509_STORE_CTX_idx\fR\|(3)). .PP .Vb 10 \& ... \& typedef struct { \& int verbose_mode; \& int verify_depth; \& int always_continue; \& } mydata_t; \& int mydata_index; \& ... \& static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) \& { \& char buf[256]; \& X509 *err_cert; \& int err, depth; \& SSL *ssl; \& mydata_t *mydata; \& \& err_cert = X509_STORE_CTX_get_current_cert(ctx); \& err = X509_STORE_CTX_get_error(ctx); \& depth = X509_STORE_CTX_get_error_depth(ctx); \& \& /* \& * Retrieve the pointer to the SSL of the connection currently treated \& * and the application specific data stored into the SSL object. \& */ \& ssl = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()); \& mydata = SSL_get_ex_data(ssl, mydata_index); \& \& X509_NAME_oneline(X509_get_subject_name(err_cert), buf, 256); \& \& /* \& * Catch a too long certificate chain. The depth limit set using \& * SSL_CTX_set_verify_depth() is by purpose set to "limit+1" so \& * that whenever the "depth>verify_depth" condition is met, we \& * have violated the limit and want to log this error condition. \& * We must do it here, because the CHAIN_TOO_LONG error would not \& * be found explicitly; only errors introduced by cutting off the \& * additional certificates would be logged. \& */ \& if (depth > mydata\->verify_depth) { \& preverify_ok = 0; \& err = X509_V_ERR_CERT_CHAIN_TOO_LONG; \& X509_STORE_CTX_set_error(ctx, err); \& } \& if (!preverify_ok) { \& printf("verify error:num=%d:%s:depth=%d:%s\en", err, \& X509_verify_cert_error_string(err), depth, buf); \& } \& else if (mydata\->verbose_mode) \& { \& printf("depth=%d:%s\en", depth, buf); \& } \& \& /* \& * At this point, err contains the last verification error. We can use \& * it for something special \& */ \& if (!preverify_ok && (err == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT)) \& { \& X509_NAME_oneline(X509_get_issuer_name(ctx\->current_cert), buf, 256); \& printf("issuer= %s\en", buf); \& } \& \& if (mydata\->always_continue) \& return 1; \& else \& return preverify_ok; \& } \& ... \& \& mydata_t mydata; \& \& ... \& mydata_index = SSL_get_ex_new_index(0, "mydata index", NULL, NULL, NULL); \& \& ... \& SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE, \& verify_callback); \& \& /* \& * Let the verify_callback catch the verify_depth error so that we get \& * an appropriate error in the logfile. \& */ \& SSL_CTX_set_verify_depth(verify_depth + 1); \& \& /* \& * Set up the SSL specific data into "mydata" and store it into th SSL \& * structure. \& */ \& mydata.verify_depth = verify_depth; ... \& SSL_set_ex_data(ssl, mydata_index, &mydata); \& \& ... \& SSL_accept(ssl); /* check of success left out for clarity */ \& if (peer = SSL_get_peer_certificate(ssl)) \& { \& if (SSL_get_verify_result(ssl) == X509_V_OK) \& { \& /* The client sent a certificate which verified OK */ \& } \& } .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_new\fR\|(3), \&\fISSL_CTX_get_verify_mode\fR\|(3), \&\fISSL_get_verify_result\fR\|(3), \&\fISSL_CTX_load_verify_locations\fR\|(3), \&\fISSL_get_peer_certificate\fR\|(3), \&\fISSL_CTX_set_cert_verify_callback\fR\|(3), \&\fISSL_get_ex_data_X509_STORE_CTX_idx\fR\|(3), \&\fISSL_get_ex_new_index\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_rand.30000644000175000017500000001371112360020712017076 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_rand 3" .TH BN_rand 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_rand, BN_pseudo_rand, BN_rand_range, BN_pseudo_rand_range \- generate pseudo\-random number .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int BN_rand(BIGNUM *rnd, int bits, int top, int bottom); \& \& int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom); \& \& int BN_rand_range(BIGNUM *rnd, BIGNUM *range); \& \& int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBN_rand()\fR generates a cryptographically strong pseudo-random number of \&\fBbits\fR bits in length and stores it in \fBrnd\fR. If \fBtop\fR is \-1, the most significant bit of the random number can be zero. If \fBtop\fR is 0, it is set to 1, and if \fBtop\fR is 1, the two most significant bits of the number will be set to 1, so that the product of two such random numbers will always have 2*\fBbits\fR length. If \fBbottom\fR is true, the number will be odd. .PP \&\fIBN_pseudo_rand()\fR does the same, but pseudo-random numbers generated by this function are not necessarily unpredictable. They can be used for non-cryptographic purposes and for certain purposes in cryptographic protocols, but usually not for key generation etc. .PP \&\fIBN_rand_range()\fR generates a cryptographically strong pseudo-random number \fBrnd\fR in the range 0 = \fBrnd\fR < \fBrange\fR. \&\fIBN_pseudo_rand_range()\fR does the same, but is based on \fIBN_pseudo_rand()\fR, and hence numbers generated by it are not necessarily unpredictable. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The functions return 1 on success, 0 on error. The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3), \fIERR_get_error\fR\|(3), \fIrand\fR\|(3), \&\fIRAND_add\fR\|(3), \fIRAND_bytes\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIBN_rand()\fR is available in all versions of SSLeay and OpenSSL. \&\fIBN_pseudo_rand()\fR was added in OpenSSL 0.9.5. The \fBtop\fR == \-1 case and the function \fIBN_rand_range()\fR were added in OpenSSL 0.9.6a. \&\fIBN_pseudo_rand_range()\fR was added in OpenSSL 0.9.6c. deps/libressl-pnacl-sys-2.1.6/libressl/man/RC4.30000644000175000017500000001361412360020723016167 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RC4 3" .TH RC4 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RC4_set_key, RC4 \- RC4 encryption .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); \& \& void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata, \& unsigned char *outdata); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This library implements the Alleged \s-1RC4\s0 cipher, which is described for example in \fIApplied Cryptography\fR. It is believed to be compatible with RC4[\s-1TM\s0], a proprietary cipher of \s-1RSA\s0 Security Inc. .PP \&\s-1RC4\s0 is a stream cipher with variable key length. Typically, 128 bit (16 byte) keys are used for strong encryption, but shorter insecure key sizes have been widely used due to export restrictions. .PP \&\s-1RC4\s0 consists of a key setup phase and the actual encryption or decryption phase. .PP \&\fIRC4_set_key()\fR sets up the \fB\s-1RC4_KEY\s0\fR \fBkey\fR using the \fBlen\fR bytes long key at \fBdata\fR. .PP \&\s-1\fIRC4\s0()\fR encrypts or decrypts the \fBlen\fR bytes of data at \fBindata\fR using \&\fBkey\fR and places the result at \fBoutdata\fR. Repeated \s-1\fIRC4\s0()\fR calls with the same \fBkey\fR yield a continuous key stream. .PP Since \s-1RC4\s0 is a stream cipher (the input is XORed with a pseudo-random key stream to produce the output), decryption uses the same function calls as encryption. .PP Applications should use the higher level functions \&\fIEVP_EncryptInit\fR\|(3) etc. instead of calling the \s-1RC4\s0 functions directly. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIRC4_set_key()\fR and \s-1\fIRC4\s0()\fR do not return values. .SH "NOTE" .IX Header "NOTE" Certain conditions have to be observed to securely use stream ciphers. It is not permissible to perform multiple encryptions using the same key stream. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIblowfish\fR\|(3), \fIdes\fR\|(3), \fIrc2\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIRC4_set_key()\fR and \s-1\fIRC4\s0()\fR are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/rsa.10000644000175000017500000002533612360020742016367 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "rsa 1" .TH rsa 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" rsa \- RSA key processing tool .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBrsa\fR [\fB\-inform PEM|NET|DER\fR] [\fB\-outform PEM|NET|DER\fR] [\fB\-in filename\fR] [\fB\-passin arg\fR] [\fB\-out filename\fR] [\fB\-passout arg\fR] [\fB\-sgckey\fR] [\fB\-des\fR] [\fB\-des3\fR] [\fB\-idea\fR] [\fB\-text\fR] [\fB\-noout\fR] [\fB\-modulus\fR] [\fB\-check\fR] [\fB\-pubin\fR] [\fB\-pubout\fR] [\fB\-RSAPublicKey_in\fR] [\fB\-RSAPublicKey_out\fR] [\fB\-engine id\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBrsa\fR command processes \s-1RSA\s0 keys. They can be converted between various forms and their components printed out. \fBNote\fR this command uses the traditional SSLeay compatible format for private key encryption: newer applications should use the more secure PKCS#8 format using the \fBpkcs8\fR utility. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" .IP "\fB\-inform DER|NET|PEM\fR" 4 .IX Item "-inform DER|NET|PEM" This specifies the input format. The \fB\s-1DER\s0\fR option uses an \s-1ASN1 DER\s0 encoded form compatible with the PKCS#1 RSAPrivateKey or SubjectPublicKeyInfo format. The \fB\s-1PEM\s0\fR form is the default format: it consists of the \fB\s-1DER\s0\fR format base64 encoded with additional header and footer lines. On input PKCS#8 format private keys are also accepted. The \fB\s-1NET\s0\fR form is a format is described in the \fB\s-1NOTES\s0\fR section. .IP "\fB\-outform DER|NET|PEM\fR" 4 .IX Item "-outform DER|NET|PEM" This specifies the output format, the options have the same meaning as the \&\fB\-inform\fR option. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read a key from or standard input if this option is not specified. If the key is encrypted a pass phrase will be prompted for. .IP "\fB\-passin arg\fR" 4 .IX Item "-passin arg" the input file password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" This specifies the output filename to write a key to or standard output if this option is not specified. If any encryption options are set then a pass phrase will be prompted for. The output filename should \fBnot\fR be the same as the input filename. .IP "\fB\-passout password\fR" 4 .IX Item "-passout password" the output file password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-sgckey\fR" 4 .IX Item "-sgckey" use the modified \s-1NET\s0 algorithm used with some versions of Microsoft \s-1IIS\s0 and \s-1SGC\s0 keys. .IP "\fB\-des|\-des3|\-idea\fR" 4 .IX Item "-des|-des3|-idea" These options encrypt the private key with the \s-1DES,\s0 triple \s-1DES,\s0 or the \&\s-1IDEA\s0 ciphers respectively before outputting it. A pass phrase is prompted for. If none of these options is specified the key is written in plain text. This means that using the \fBrsa\fR utility to read in an encrypted key with no encryption option can be used to remove the pass phrase from a key, or by setting the encryption options it can be use to add or change the pass phrase. These options can only be used with \s-1PEM\s0 format output files. .IP "\fB\-text\fR" 4 .IX Item "-text" prints out the various public or private key components in plain text in addition to the encoded version. .IP "\fB\-noout\fR" 4 .IX Item "-noout" this option prevents output of the encoded version of the key. .IP "\fB\-modulus\fR" 4 .IX Item "-modulus" this option prints out the value of the modulus of the key. .IP "\fB\-check\fR" 4 .IX Item "-check" this option checks the consistency of an \s-1RSA\s0 private key. .IP "\fB\-pubin\fR" 4 .IX Item "-pubin" by default a private key is read from the input file: with this option a public key is read instead. .IP "\fB\-pubout\fR" 4 .IX Item "-pubout" by default a private key is output: with this option a public key will be output instead. This option is automatically set if the input is a public key. .IP "\fB\-RSAPublicKey_in\fR, \fB\-RSAPublicKey_out\fR" 4 .IX Item "-RSAPublicKey_in, -RSAPublicKey_out" like \fB\-pubin\fR and \fB\-pubout\fR except \fBRSAPublicKey\fR format is used instead. .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBrsa\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .SH "NOTES" .IX Header "NOTES" The \s-1PEM\s0 private key format uses the header and footer lines: .PP .Vb 2 \& \-\-\-\-\-BEGIN RSA PRIVATE KEY\-\-\-\-\- \& \-\-\-\-\-END RSA PRIVATE KEY\-\-\-\-\- .Ve .PP The \s-1PEM\s0 public key format uses the header and footer lines: .PP .Vb 2 \& \-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\- \& \-\-\-\-\-END PUBLIC KEY\-\-\-\-\- .Ve .PP The \s-1PEM \s0\fBRSAPublicKey\fR format uses the header and footer lines: .PP .Vb 2 \& \-\-\-\-\-BEGIN RSA PUBLIC KEY\-\-\-\-\- \& \-\-\-\-\-END RSA PUBLIC KEY\-\-\-\-\- .Ve .PP The \fB\s-1NET\s0\fR form is a format compatible with older Netscape servers and Microsoft \s-1IIS \s0.key files, this uses unsalted \s-1RC4\s0 for its encryption. It is not very secure and so should only be used when necessary. .PP Some newer version of \s-1IIS\s0 have additional data in the exported .key files. To use these with the utility, view the file with a binary editor and look for the string \*(L"private-key\*(R", then trace back to the byte sequence 0x30, 0x82 (this is an \s-1ASN1 SEQUENCE\s0). Copy all the data from this point onwards to another file and use that as the input to the \fBrsa\fR utility with the \fB\-inform \s-1NET\s0\fR option. If you get an error after entering the password try the \fB\-sgckey\fR option. .SH "EXAMPLES" .IX Header "EXAMPLES" To remove the pass phrase on an \s-1RSA\s0 private key: .PP .Vb 1 \& openssl rsa \-in key.pem \-out keyout.pem .Ve .PP To encrypt a private key using triple \s-1DES:\s0 .PP .Vb 1 \& openssl rsa \-in key.pem \-des3 \-out keyout.pem .Ve .PP To convert a private key from \s-1PEM\s0 to \s-1DER\s0 format: .PP .Vb 1 \& openssl rsa \-in key.pem \-outform DER \-out keyout.der .Ve .PP To print out the components of a private key to standard output: .PP .Vb 1 \& openssl rsa \-in key.pem \-text \-noout .Ve .PP To just output the public part of a private key: .PP .Vb 1 \& openssl rsa \-in key.pem \-pubout \-out pubkey.pem .Ve .PP Output the public part of a private key in \fBRSAPublicKey\fR format: .PP .Vb 1 \& openssl rsa \-in key.pem \-RSAPublicKey_out \-out pubkey.pem .Ve .SH "BUGS" .IX Header "BUGS" The command line password arguments don't currently work with \&\fB\s-1NET\s0\fR format. .PP There should be an option that automatically handles .key files, without having to manually edit them. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIpkcs8\fR\|(1), \fIdsa\fR\|(1), \fIgenrsa\fR\|(1), \&\fIgendsa\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_SignInit.30000644000175000017500000001747412360020721020043 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_SignInit 3" .TH EVP_SignInit 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_SignInit, EVP_SignUpdate, EVP_SignFinal \- EVP signing functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_SignInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); \& int EVP_SignUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); \& int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *sig,unsigned int *s, EVP_PKEY *pkey); \& \& void EVP_SignInit(EVP_MD_CTX *ctx, const EVP_MD *type); \& \& int EVP_PKEY_size(EVP_PKEY *pkey); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \s-1EVP\s0 signature routines are a high level interface to digital signatures. .PP \&\fIEVP_SignInit_ex()\fR sets up signing context \fBctx\fR to use digest \&\fBtype\fR from \s-1ENGINE \s0\fBimpl\fR. \fBctx\fR must be initialized with \&\fIEVP_MD_CTX_init()\fR before calling this function. .PP \&\fIEVP_SignUpdate()\fR hashes \fBcnt\fR bytes of data at \fBd\fR into the signature context \fBctx\fR. This function can be called several times on the same \fBctx\fR to include additional data. .PP \&\fIEVP_SignFinal()\fR signs the data in \fBctx\fR using the private key \fBpkey\fR and places the signature in \fBsig\fR. \fBsig\fR must be at least EVP_PKEY_size(pkey) bytes in size. \fBs\fR is an \s-1OUT\s0 parameter, and not used as an \s-1IN\s0 parameter. The number of bytes of data written (i.e. the length of the signature) will be written to the integer at \fBs\fR, at most EVP_PKEY_size(pkey) bytes will be written. .PP \&\fIEVP_SignInit()\fR initializes a signing context \fBctx\fR to use the default implementation of digest \fBtype\fR. .PP \&\fIEVP_PKEY_size()\fR returns the maximum size of a signature in bytes. The actual signature returned by \fIEVP_SignFinal()\fR may be smaller. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_SignInit_ex()\fR, \fIEVP_SignUpdate()\fR and \fIEVP_SignFinal()\fR return 1 for success and 0 for failure. .PP \&\fIEVP_PKEY_size()\fR returns the maximum size of a signature in bytes. .PP The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "NOTES" .IX Header "NOTES" The \fB\s-1EVP\s0\fR interface to digital signatures should almost always be used in preference to the low level interfaces. This is because the code then becomes transparent to the algorithm used and much more flexible. .PP Due to the link between message digests and public key algorithms the correct digest algorithm must be used with the correct public key type. A list of algorithms and associated public key algorithms appears in \&\fIEVP_DigestInit\fR\|(3). .PP The call to \fIEVP_SignFinal()\fR internally finalizes a copy of the digest context. This means that calls to \fIEVP_SignUpdate()\fR and \fIEVP_SignFinal()\fR can be called later to digest and sign additional data. .PP Since only a copy of the digest context is ever finalized the context must be cleaned up after use by calling \fIEVP_MD_CTX_cleanup()\fR or a memory leak will occur. .SH "BUGS" .IX Header "BUGS" Older versions of this documentation wrongly stated that calls to \&\fIEVP_SignUpdate()\fR could not be made after calling \fIEVP_SignFinal()\fR. .PP Since the private key is passed in the call to \fIEVP_SignFinal()\fR any error relating to the private key (for example an unsuitable key and digest combination) will not be indicated until after potentially large amounts of data have been passed through \fIEVP_SignUpdate()\fR. .PP It is not possible to change the signing parameters using these function. .PP The previous two bugs are fixed in the newer EVP_SignDigest*() function. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_VerifyInit\fR\|(3), \&\fIEVP_DigestInit\fR\|(3), \fIerr\fR\|(3), \&\fIevp\fR\|(3), \fIhmac\fR\|(3), \fImd2\fR\|(3), \&\fImd5\fR\|(3), \fImdc2\fR\|(3), \fIripemd\fR\|(3), \&\fIsha\fR\|(3), \fIdgst\fR\|(1) .SH "HISTORY" .IX Header "HISTORY" \&\fIEVP_SignInit()\fR, \fIEVP_SignUpdate()\fR and \fIEVP_SignFinal()\fR are available in all versions of SSLeay and OpenSSL. .PP \&\fIEVP_SignInit_ex()\fR was added in OpenSSL 0.9.7. deps/libressl-pnacl-sys-2.1.6/libressl/man/RAND_add.30000644000175000017500000001105712360020723017132 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RAND_add 3" .TH RAND_add 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RAND_add, RAND_seed, RAND_status \- add entropy to the PRNG (DEPRECATED) .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void RAND_seed(const void *buf, int num); \& \& void RAND_add(const void *buf, int num, double entropy); \& \& int RAND_status(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions used to allow for the state of the random number generator to be controlled by external sources. .PP They are kept for \s-1ABI\s0 compatibility but are no longer functional, and should not be used in new programs. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIrand\fR\|(3), \&\fIRAND_load_file\fR\|(3), \fIRAND_cleanup\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_s_socket.30000644000175000017500000001331312360020711020073 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_s_socket 3" .TH BIO_s_socket 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_s_socket, BIO_new_socket \- socket BIO .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIO_METHOD *BIO_s_socket(void); \& \& long BIO_set_fd(BIO *b, int fd, long close_flag); \& long BIO_get_fd(BIO *b, int *c); \& \& BIO *BIO_new_socket(int sock, int close_flag); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_s_socket()\fR returns the socket \s-1BIO\s0 method. This is a wrapper round the platform's socket routines. .PP \&\fIBIO_read()\fR and \fIBIO_write()\fR read or write the underlying socket. \&\fIBIO_puts()\fR is supported but \fIBIO_gets()\fR is not. .PP If the close flag is set then the socket is shut down and closed when the \s-1BIO\s0 is freed. .PP \&\fIBIO_set_fd()\fR sets the socket of \s-1BIO \s0\fBb\fR to \fBfd\fR and the close flag to \fBclose_flag\fR. .PP \&\fIBIO_get_fd()\fR places the socket in \fBc\fR if it is not \s-1NULL,\s0 it also returns the socket. If \fBc\fR is not \s-1NULL\s0 it should be of type (int *). .PP \&\fIBIO_new_socket()\fR returns a socket \s-1BIO\s0 using \fBsock\fR and \fBclose_flag\fR. .SH "NOTES" .IX Header "NOTES" Socket BIOs also support any relevant functionality of file descriptor BIOs. .PP The reason for having separate file descriptor and socket BIOs is that on some platforms sockets are not file descriptors and use distinct I/O routines, Windows is one such platform. Any code mixing the two will not work on all platforms. .PP \&\fIBIO_set_fd()\fR and \fIBIO_get_fd()\fR are macros. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBIO_s_socket()\fR returns the socket \s-1BIO\s0 method. .PP \&\fIBIO_set_fd()\fR always returns 1. .PP \&\fIBIO_get_fd()\fR returns the socket or \-1 if the \s-1BIO\s0 has not been initialized. .PP \&\fIBIO_new_socket()\fR returns the newly allocated \s-1BIO\s0 or \s-1NULL\s0 is an error occurred. deps/libressl-pnacl-sys-2.1.6/libressl/man/pkcs12.10000644000175000017500000004244512360020742016705 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "pkcs12 1" .TH pkcs12 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" pkcs12 \- PKCS#12 file utility .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBpkcs12\fR [\fB\-export\fR] [\fB\-chain\fR] [\fB\-inkey filename\fR] [\fB\-certfile filename\fR] [\fB\-name name\fR] [\fB\-caname name\fR] [\fB\-in filename\fR] [\fB\-out filename\fR] [\fB\-noout\fR] [\fB\-nomacver\fR] [\fB\-nocerts\fR] [\fB\-clcerts\fR] [\fB\-cacerts\fR] [\fB\-nokeys\fR] [\fB\-info\fR] [\fB\-des | \-des3 | \-idea | \-aes128 | \-aes192 | \-aes256 | \-camellia128 | \-camellia192 | \-camellia256 | \-nodes\fR] [\fB\-noiter\fR] [\fB\-maciter | \-nomaciter | \-nomac\fR] [\fB\-twopass\fR] [\fB\-descert\fR] [\fB\-certpbe cipher\fR] [\fB\-keypbe cipher\fR] [\fB\-macalg digest\fR] [\fB\-keyex\fR] [\fB\-keysig\fR] [\fB\-password arg\fR] [\fB\-passin arg\fR] [\fB\-passout arg\fR] [\fB\-rand file(s)\fR] [\fB\-CAfile file\fR] [\fB\-CApath dir\fR] [\fB\-CSP name\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBpkcs12\fR command allows PKCS#12 files (sometimes referred to as \&\s-1PFX\s0 files) to be created and parsed. PKCS#12 files are used by several programs including Netscape, \s-1MSIE\s0 and \s-1MS\s0 Outlook. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" There are a lot of options the meaning of some depends of whether a PKCS#12 file is being created or parsed. By default a PKCS#12 file is parsed. A PKCS#12 file can be created by using the \fB\-export\fR option (see below). .SH "PARSING OPTIONS" .IX Header "PARSING OPTIONS" .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies filename of the PKCS#12 file to be parsed. Standard input is used by default. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" The filename to write certificates and private keys to, standard output by default. They are all written in \s-1PEM\s0 format. .IP "\fB\-passin arg\fR" 4 .IX Item "-passin arg" the PKCS#12 file (i.e. input file) password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \&\fIopenssl\fR\|(1). .IP "\fB\-passout arg\fR" 4 .IX Item "-passout arg" pass phrase source to encrypt any outputted private keys with. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-password arg\fR" 4 .IX Item "-password arg" With \-export, \-password is equivalent to \-passout. Otherwise, \-password is equivalent to \-passin. .IP "\fB\-noout\fR" 4 .IX Item "-noout" this option inhibits output of the keys and certificates to the output file version of the PKCS#12 file. .IP "\fB\-clcerts\fR" 4 .IX Item "-clcerts" only output client certificates (not \s-1CA\s0 certificates). .IP "\fB\-cacerts\fR" 4 .IX Item "-cacerts" only output \s-1CA\s0 certificates (not client certificates). .IP "\fB\-nocerts\fR" 4 .IX Item "-nocerts" no certificates at all will be output. .IP "\fB\-nokeys\fR" 4 .IX Item "-nokeys" no private keys will be output. .IP "\fB\-info\fR" 4 .IX Item "-info" output additional information about the PKCS#12 file structure, algorithms used and iteration counts. .IP "\fB\-des\fR" 4 .IX Item "-des" use \s-1DES\s0 to encrypt private keys before outputting. .IP "\fB\-des3\fR" 4 .IX Item "-des3" use triple \s-1DES\s0 to encrypt private keys before outputting, this is the default. .IP "\fB\-idea\fR" 4 .IX Item "-idea" use \s-1IDEA\s0 to encrypt private keys before outputting. .IP "\fB\-aes128\fR, \fB\-aes192\fR, \fB\-aes256\fR" 4 .IX Item "-aes128, -aes192, -aes256" use \s-1AES\s0 to encrypt private keys before outputting. .IP "\fB\-camellia128\fR, \fB\-camellia192\fR, \fB\-camellia256\fR" 4 .IX Item "-camellia128, -camellia192, -camellia256" use Camellia to encrypt private keys before outputting. .IP "\fB\-nodes\fR" 4 .IX Item "-nodes" don't encrypt the private keys at all. .IP "\fB\-nomacver\fR" 4 .IX Item "-nomacver" don't attempt to verify the integrity \s-1MAC\s0 before reading the file. .IP "\fB\-twopass\fR" 4 .IX Item "-twopass" prompt for separate integrity and encryption passwords: most software always assumes these are the same so this option will render such PKCS#12 files unreadable. .SH "FILE CREATION OPTIONS" .IX Header "FILE CREATION OPTIONS" .IP "\fB\-export\fR" 4 .IX Item "-export" This option specifies that a PKCS#12 file will be created rather than parsed. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" This specifies filename to write the PKCS#12 file to. Standard output is used by default. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" The filename to read certificates and private keys from, standard input by default. They must all be in \s-1PEM\s0 format. The order doesn't matter but one private key and its corresponding certificate should be present. If additional certificates are present they will also be included in the PKCS#12 file. .IP "\fB\-inkey filename\fR" 4 .IX Item "-inkey filename" file to read private key from. If not present then a private key must be present in the input file. .IP "\fB\-name friendlyname\fR" 4 .IX Item "-name friendlyname" This specifies the \*(L"friendly name\*(R" for the certificate and private key. This name is typically displayed in list boxes by software importing the file. .IP "\fB\-certfile filename\fR" 4 .IX Item "-certfile filename" A filename to read additional certificates from. .IP "\fB\-caname friendlyname\fR" 4 .IX Item "-caname friendlyname" This specifies the \*(L"friendly name\*(R" for other certificates. This option may be used multiple times to specify names for all certificates in the order they appear. Netscape ignores friendly names on other certificates whereas \s-1MSIE\s0 displays them. .IP "\fB\-pass arg\fR, \fB\-passout arg\fR" 4 .IX Item "-pass arg, -passout arg" the PKCS#12 file (i.e. output file) password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \&\fIopenssl\fR\|(1). .IP "\fB\-passin password\fR" 4 .IX Item "-passin password" pass phrase source to decrypt any input private keys with. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \&\fIopenssl\fR\|(1). .IP "\fB\-chain\fR" 4 .IX Item "-chain" if this option is present then an attempt is made to include the entire certificate chain of the user certificate. The standard \s-1CA\s0 store is used for this search. If the search fails it is considered a fatal error. .IP "\fB\-descert\fR" 4 .IX Item "-descert" encrypt the certificate using triple \s-1DES,\s0 this may render the PKCS#12 file unreadable by some \*(L"export grade\*(R" software. By default the private key is encrypted using triple \s-1DES\s0 and the certificate using 40 bit \s-1RC2.\s0 .IP "\fB\-keypbe alg\fR, \fB\-certpbe alg\fR" 4 .IX Item "-keypbe alg, -certpbe alg" these options allow the algorithm used to encrypt the private key and certificates to be selected. Any PKCS#5 v1.5 or PKCS#12 \s-1PBE\s0 algorithm name can be used (see \fB\s-1NOTES\s0\fR section for more information). If a a cipher name (as output by the \fBlist-cipher-algorithms\fR command is specified then it is used with PKCS#5 v2.0. For interoperability reasons it is advisable to only use PKCS#12 algorithms. .IP "\fB\-keyex|\-keysig\fR" 4 .IX Item "-keyex|-keysig" specifies that the private key is to be used for key exchange or just signing. This option is only interpreted by \s-1MSIE\s0 and similar \s-1MS\s0 software. Normally \&\*(L"export grade\*(R" software will only allow 512 bit \s-1RSA\s0 keys to be used for encryption purposes but arbitrary length keys for signing. The \fB\-keysig\fR option marks the key for signing only. Signing only keys can be used for S/MIME signing, authenticode (ActiveX control signing) and \s-1SSL\s0 client authentication, however due to a bug only \s-1MSIE 5.0\s0 and later support the use of signing only keys for \s-1SSL\s0 client authentication. .IP "\fB\-macalg digest\fR" 4 .IX Item "-macalg digest" specify the \s-1MAC\s0 digest algorithm. If not included them \s-1SHA1\s0 will be used. .IP "\fB\-nomaciter\fR, \fB\-noiter\fR" 4 .IX Item "-nomaciter, -noiter" these options affect the iteration counts on the \s-1MAC\s0 and key algorithms. Unless you wish to produce files compatible with \s-1MSIE 4.0\s0 you should leave these options alone. .Sp To discourage attacks by using large dictionaries of common passwords the algorithm that derives keys from passwords can have an iteration count applied to it: this causes a certain part of the algorithm to be repeated and slows it down. The \s-1MAC\s0 is used to check the file integrity but since it will normally have the same password as the keys and certificates it could also be attacked. By default both \s-1MAC\s0 and encryption iteration counts are set to 2048, using these options the \s-1MAC\s0 and encryption iteration counts can be set to 1, since this reduces the file security you should not use these options unless you really have to. Most software supports both \s-1MAC\s0 and key iteration counts. \&\s-1MSIE 4.0\s0 doesn't support \s-1MAC\s0 iteration counts so it needs the \fB\-nomaciter\fR option. .IP "\fB\-maciter\fR" 4 .IX Item "-maciter" This option is included for compatibility with previous versions, it used to be needed to use \s-1MAC\s0 iterations counts but they are now used by default. .IP "\fB\-nomac\fR" 4 .IX Item "-nomac" don't attempt to provide the \s-1MAC\s0 integrity. .IP "\fB\-rand file(s)\fR" 4 .IX Item "-rand file(s)" a file or files containing random data used to seed the random number generator, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)). Multiple files can be specified separated by a OS-dependent character. The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for all others. .IP "\fB\-CAfile file\fR" 4 .IX Item "-CAfile file" \&\s-1CA\s0 storage as a file. .IP "\fB\-CApath dir\fR" 4 .IX Item "-CApath dir" \&\s-1CA\s0 storage as a directory. This directory must be a standard certificate directory: that is a hash of each subject name (using \fBx509 \-hash\fR) should be linked to each certificate. .IP "\fB\-CSP name\fR" 4 .IX Item "-CSP name" write \fBname\fR as a Microsoft \s-1CSP\s0 name. .SH "NOTES" .IX Header "NOTES" Although there are a large number of options most of them are very rarely used. For PKCS#12 file parsing only \fB\-in\fR and \fB\-out\fR need to be used for PKCS#12 file creation \fB\-export\fR and \fB\-name\fR are also used. .PP If none of the \fB\-clcerts\fR, \fB\-cacerts\fR or \fB\-nocerts\fR options are present then all certificates will be output in the order they appear in the input PKCS#12 files. There is no guarantee that the first certificate present is the one corresponding to the private key. Certain software which requires a private key and certificate and assumes the first certificate in the file is the one corresponding to the private key: this may not always be the case. Using the \fB\-clcerts\fR option will solve this problem by only outputting the certificate corresponding to the private key. If the \s-1CA\s0 certificates are required then they can be output to a separate file using the \fB\-nokeys \-cacerts\fR options to just output \s-1CA\s0 certificates. .PP The \fB\-keypbe\fR and \fB\-certpbe\fR algorithms allow the precise encryption algorithms for private keys and certificates to be specified. Normally the defaults are fine but occasionally software can't handle triple \s-1DES\s0 encrypted private keys, then the option \fB\-keypbe \s-1PBE\-SHA1\-RC2\-40\s0\fR can be used to reduce the private key encryption to 40 bit \s-1RC2. A\s0 complete description of all algorithms is contained in the \fBpkcs8\fR manual page. .SH "EXAMPLES" .IX Header "EXAMPLES" Parse a PKCS#12 file and output it to a file: .PP .Vb 1 \& openssl pkcs12 \-in file.p12 \-out file.pem .Ve .PP Output only client certificates to a file: .PP .Vb 1 \& openssl pkcs12 \-in file.p12 \-clcerts \-out file.pem .Ve .PP Don't encrypt the private key: .PP .Vb 1 \& openssl pkcs12 \-in file.p12 \-out file.pem \-nodes .Ve .PP Print some info about a PKCS#12 file: .PP .Vb 1 \& openssl pkcs12 \-in file.p12 \-info \-noout .Ve .PP Create a PKCS#12 file: .PP .Vb 1 \& openssl pkcs12 \-export \-in file.pem \-out file.p12 \-name "My Certificate" .Ve .PP Include some extra certificates: .PP .Vb 2 \& openssl pkcs12 \-export \-in file.pem \-out file.p12 \-name "My Certificate" \e \& \-certfile othercerts.pem .Ve .SH "BUGS" .IX Header "BUGS" Some would argue that the PKCS#12 standard is one big bug :\-) .PP Versions of OpenSSL before 0.9.6a had a bug in the PKCS#12 key generation routines. Under rare circumstances this could produce a PKCS#12 file encrypted with an invalid key. As a result some PKCS#12 files which triggered this bug from other implementations (\s-1MSIE\s0 or Netscape) could not be decrypted by OpenSSL and similarly OpenSSL could produce PKCS#12 files which could not be decrypted by other implementations. The chances of producing such a file are relatively small: less than 1 in 256. .PP A side effect of fixing this bug is that any old invalidly encrypted PKCS#12 files cannot no longer be parsed by the fixed version. Under such circumstances the \fBpkcs12\fR utility will report that the \s-1MAC\s0 is \s-1OK\s0 but fail with a decryption error when extracting private keys. .PP This problem can be resolved by extracting the private keys and certificates from the PKCS#12 file using an older version of OpenSSL and recreating the PKCS#12 file from the keys and certificates using a newer version of OpenSSL. For example: .PP .Vb 2 \& old\-openssl \-in bad.p12 \-out keycerts.pem \& openssl \-in keycerts.pem \-export \-name "My PKCS#12 file" \-out fixed.p12 .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIpkcs8\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/ecdsa.30000644000175000017500000002671612360020727016671 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ecdsa 3" .TH ecdsa 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ECDSA_SIG_new, ECDSA_SIG_free, i2d_ECDSA_SIG, d2i_ECDSA_SIG, ECDSA_size, ECDSA_sign_setup, ECDSA_sign, ECDSA_sign_ex, ECDSA_verify, ECDSA_do_sign, ECDSA_do_sign_ex, ECDSA_do_verify \- Elliptic Curve Digital Signature Algorithm .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& ECDSA_SIG* ECDSA_SIG_new(void); \& void ECDSA_SIG_free(ECDSA_SIG *sig); \& int i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp); \& ECDSA_SIG* d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, \& long len); \& \& ECDSA_SIG* ECDSA_do_sign(const unsigned char *dgst, int dgst_len, \& EC_KEY *eckey); \& ECDSA_SIG* ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, \& const BIGNUM *kinv, const BIGNUM *rp, \& EC_KEY *eckey); \& int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, \& const ECDSA_SIG *sig, EC_KEY* eckey); \& int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, \& BIGNUM **kinv, BIGNUM **rp); \& int ECDSA_sign(int type, const unsigned char *dgst, \& int dgstlen, unsigned char *sig, \& unsigned int *siglen, EC_KEY *eckey); \& int ECDSA_sign_ex(int type, const unsigned char *dgst, \& int dgstlen, unsigned char *sig, \& unsigned int *siglen, const BIGNUM *kinv, \& const BIGNUM *rp, EC_KEY *eckey); \& int ECDSA_verify(int type, const unsigned char *dgst, \& int dgstlen, const unsigned char *sig, \& int siglen, EC_KEY *eckey); \& int ECDSA_size(const EC_KEY *eckey); \& \& const ECDSA_METHOD* ECDSA_OpenSSL(void); \& void ECDSA_set_default_method(const ECDSA_METHOD *meth); \& const ECDSA_METHOD* ECDSA_get_default_method(void); \& int ECDSA_set_method(EC_KEY *eckey,const ECDSA_METHOD *meth); \& \& int ECDSA_get_ex_new_index(long argl, void *argp, \& CRYPTO_EX_new *new_func, \& CRYPTO_EX_dup *dup_func, \& CRYPTO_EX_free *free_func); \& int ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg); \& void* ECDSA_get_ex_data(EC_KEY *d, int idx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fB\s-1ECDSA_SIG\s0\fR structure consists of two BIGNUMs for the r and s value of a \s-1ECDSA\s0 signature (see X9.62 or \s-1FIPS 186\-2\s0). .PP .Vb 5 \& struct \& { \& BIGNUM *r; \& BIGNUM *s; \& } ECDSA_SIG; .Ve .PP \&\fIECDSA_SIG_new()\fR allocates a new \fB\s-1ECDSA_SIG\s0\fR structure (note: this function also allocates the BIGNUMs) and initialize it. .PP \&\fIECDSA_SIG_free()\fR frees the \fB\s-1ECDSA_SIG\s0\fR structure \fBsig\fR. .PP \&\fIi2d_ECDSA_SIG()\fR creates the \s-1DER\s0 encoding of the \s-1ECDSA\s0 signature \&\fBsig\fR and writes the encoded signature to \fB*pp\fR (note: if \fBpp\fR is \s-1NULL \s0\fBi2d_ECDSA_SIG\fR returns the expected length in bytes of the \s-1DER\s0 encoded signature). \fBi2d_ECDSA_SIG\fR returns the length of the \s-1DER\s0 encoded signature (or 0 on error). .PP \&\fId2i_ECDSA_SIG()\fR decodes a \s-1DER\s0 encoded \s-1ECDSA\s0 signature and returns the decoded signature in a newly allocated \fB\s-1ECDSA_SIG\s0\fR structure. \&\fB*sig\fR points to the buffer containing the \s-1DER\s0 encoded signature of size \fBlen\fR. .PP \&\fIECDSA_size()\fR returns the maximum length of a \s-1DER\s0 encoded \&\s-1ECDSA\s0 signature created with the private \s-1EC\s0 key \fBeckey\fR. .PP \&\fIECDSA_sign_setup()\fR may be used to precompute parts of the signing operation. \fBeckey\fR is the private \s-1EC\s0 key and \fBctx\fR is a pointer to \fB\s-1BN_CTX\s0\fR structure (or \s-1NULL\s0). The precomputed values or returned in \fBkinv\fR and \fBrp\fR and can be used in a later call to \fBECDSA_sign_ex\fR or \fBECDSA_do_sign_ex\fR. .PP \&\fIECDSA_sign()\fR is wrapper function for ECDSA_sign_ex with \fBkinv\fR and \fBrp\fR set to \s-1NULL.\s0 .PP \&\fIECDSA_sign_ex()\fR computes a digital signature of the \fBdgstlen\fR bytes hash value \fBdgst\fR using the private \s-1EC\s0 key \fBeckey\fR and the optional pre-computed values \fBkinv\fR and \fBrp\fR. The \s-1DER\s0 encoded signatures is stored in \fBsig\fR and it's length is returned in \fBsig_len\fR. Note: \fBsig\fR must point to \fBECDSA_size\fR bytes of memory. The parameter \fBtype\fR is ignored. .PP \&\fIECDSA_verify()\fR verifies that the signature in \fBsig\fR of size \&\fBsiglen\fR is a valid \s-1ECDSA\s0 signature of the hash value \&\fBdgst\fR of size \fBdgstlen\fR using the public key \fBeckey\fR. The parameter \fBtype\fR is ignored. .PP \&\fIECDSA_do_sign()\fR is wrapper function for ECDSA_do_sign_ex with \fBkinv\fR and \fBrp\fR set to \s-1NULL.\s0 .PP \&\fIECDSA_do_sign_ex()\fR computes a digital signature of the \fBdgst_len\fR bytes hash value \fBdgst\fR using the private key \fBeckey\fR and the optional pre-computed values \fBkinv\fR and \fBrp\fR. The signature is returned in a newly allocated \fB\s-1ECDSA_SIG\s0\fR structure (or \s-1NULL\s0 on error). .PP \&\fIECDSA_do_verify()\fR verifies that the signature \fBsig\fR is a valid \&\s-1ECDSA\s0 signature of the hash value \fBdgst\fR of size \fBdgst_len\fR using the public key \fBeckey\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIECDSA_size()\fR returns the maximum length signature or 0 on error. .PP \&\fIECDSA_sign_setup()\fR and \fIECDSA_sign()\fR return 1 if successful or 0 on error. .PP \&\fIECDSA_verify()\fR and \fIECDSA_do_verify()\fR return 1 for a valid signature, 0 for an invalid signature and \-1 on error. The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "EXAMPLES" .IX Header "EXAMPLES" Creating a \s-1ECDSA\s0 signature of given \s-1SHA\-1\s0 hash value using the named curve secp192k1. .PP First step: create a \s-1EC_KEY\s0 object (note: this part is \fBnot\fR \s-1ECDSA\s0 specific) .PP .Vb 3 \& int ret; \& ECDSA_SIG *sig; \& EC_KEY *eckey; \& \& eckey = EC_KEY_new_by_curve_name(NID_secp192k1); \& if (eckey == NULL) { \& /* error */ \& } \& if (!EC_KEY_generate_key(eckey)) { \& /* error */ \& } .Ve .PP Second step: compute the \s-1ECDSA\s0 signature of a \s-1SHA\-1\s0 hash value using \fBECDSA_do_sign\fR .PP .Vb 4 \& sig = ECDSA_do_sign(digest, 20, eckey); \& if (sig == NULL) { \& /* error */ \& } .Ve .PP or using \fBECDSA_sign\fR .PP .Vb 2 \& unsigned char *buffer, *pp; \& int buf_len; \& \& buf_len = ECDSA_size(eckey); \& buffer = OPENSSL_malloc(buf_len); \& pp = buffer; \& if (!ECDSA_sign(0, dgst, dgstlen, pp, &buf_len, eckey) { \& /* error */ \& } .Ve .PP Third step: verify the created \s-1ECDSA\s0 signature using \fBECDSA_do_verify\fR .PP .Vb 1 \& ret = ECDSA_do_verify(digest, 20, sig, eckey); .Ve .PP or using \fBECDSA_verify\fR .PP .Vb 1 \& ret = ECDSA_verify(0, digest, 20, buffer, buf_len, eckey); .Ve .PP and finally evaluate the return value: .PP .Vb 8 \& if (ret == \-1) { \& /* error */ \& } else if (ret == 0) { \& /* incorrect signature */ \& } else { \& /* ret == 1 */ \& /* signature ok */ \& } .Ve .SH "CONFORMING TO" .IX Header "CONFORMING TO" \&\s-1ANSI X9.62, US\s0 Federal Information Processing Standard \s-1FIPS 186\-2 \&\s0(Digital Signature Standard, \s-1DSS\s0) .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdsa\fR\|(3), \fIrsa\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" The ecdsa implementation was first introduced in OpenSSL 0.9.8 .SH "AUTHOR" .IX Header "AUTHOR" Nils Larsch for the OpenSSL project (http://www.openssl.org). deps/libressl-pnacl-sys-2.1.6/libressl/man/spkac.10000644000175000017500000001764312360020743016706 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "spkac 1" .TH spkac 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" spkac \- SPKAC printing and generating utility .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBspkac\fR [\fB\-in filename\fR] [\fB\-out filename\fR] [\fB\-key keyfile\fR] [\fB\-passin arg\fR] [\fB\-challenge string\fR] [\fB\-pubkey\fR] [\fB\-spkac spkacname\fR] [\fB\-spksect section\fR] [\fB\-noout\fR] [\fB\-verify\fR] [\fB\-engine id\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBspkac\fR command processes Netscape signed public key and challenge (\s-1SPKAC\s0) files. It can print out their contents, verify the signature and produce its own SPKACs from a supplied private key. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read from or standard input if this option is not specified. Ignored if the \fB\-key\fR option is used. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" specifies the output filename to write to or standard output by default. .IP "\fB\-key keyfile\fR" 4 .IX Item "-key keyfile" create an \s-1SPKAC\s0 file using the private key in \fBkeyfile\fR. The \&\fB\-in\fR, \fB\-noout\fR, \fB\-spksect\fR and \fB\-verify\fR options are ignored if present. .IP "\fB\-passin password\fR" 4 .IX Item "-passin password" the input file password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-challenge string\fR" 4 .IX Item "-challenge string" specifies the challenge string if an \s-1SPKAC\s0 is being created. .IP "\fB\-spkac spkacname\fR" 4 .IX Item "-spkac spkacname" allows an alternative name form the variable containing the \&\s-1SPKAC.\s0 The default is \*(L"\s-1SPKAC\*(R".\s0 This option affects both generated and input \s-1SPKAC\s0 files. .IP "\fB\-spksect section\fR" 4 .IX Item "-spksect section" allows an alternative name form the section containing the \&\s-1SPKAC.\s0 The default is the default section. .IP "\fB\-noout\fR" 4 .IX Item "-noout" don't output the text version of the \s-1SPKAC \s0(not used if an \&\s-1SPKAC\s0 is being created). .IP "\fB\-pubkey\fR" 4 .IX Item "-pubkey" output the public key of an \s-1SPKAC \s0(not used if an \s-1SPKAC\s0 is being created). .IP "\fB\-verify\fR" 4 .IX Item "-verify" verifies the digital signature on the supplied \s-1SPKAC.\s0 .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBspkac\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .SH "EXAMPLES" .IX Header "EXAMPLES" Print out the contents of an \s-1SPKAC:\s0 .PP .Vb 1 \& openssl spkac \-in spkac.cnf .Ve .PP Verify the signature of an \s-1SPKAC:\s0 .PP .Vb 1 \& openssl spkac \-in spkac.cnf \-noout \-verify .Ve .PP Create an \s-1SPKAC\s0 using the challenge string \*(L"hello\*(R": .PP .Vb 1 \& openssl spkac \-key key.pem \-challenge hello \-out spkac.cnf .Ve .PP Example of an \s-1SPKAC, \s0(long lines split up for clarity): .PP .Vb 5 \& SPKAC=MIG5MGUwXDANBgkqhkiG9w0BAQEFAANLADBIAkEA1cCoq2Wa3Ixs47uI7F\e \& PVwHVIPDx5yso105Y6zpozam135a8R0CpoRvkkigIyXfcCjiVi5oWk+6FfPaD03u\e \& PFoQIDAQABFgVoZWxsbzANBgkqhkiG9w0BAQQFAANBAFpQtY/FojdwkJh1bEIYuc\e \& 2EeM2KHTWPEepWYeawvHD0gQ3DngSC75YCWnnDdq+NQ3F+X4deMx9AaEglZtULwV\e \& 4= .Ve .SH "NOTES" .IX Header "NOTES" A created \s-1SPKAC\s0 with suitable \s-1DN\s0 components appended can be fed into the \fBca\fR utility. .PP SPKACs are typically generated by Netscape when a form is submitted containing the \fB\s-1KEYGEN\s0\fR tag as part of the certificate enrollment process. .PP The challenge string permits a primitive form of proof of possession of private key. By checking the \s-1SPKAC\s0 signature and a random challenge string some guarantee is given that the user knows the private key corresponding to the public key being certified. This is important in some applications. Without this it is possible for a previous \s-1SPKAC\s0 to be used in a \*(L"replay attack\*(R". .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIca\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_f_md.30000644000175000017500000002201112360020710017160 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_f_md 3" .TH BIO_f_md 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_f_md, BIO_set_md, BIO_get_md, BIO_get_md_ctx \- message digest BIO filter .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& BIO_METHOD * BIO_f_md(void); \& int BIO_set_md(BIO *b,EVP_MD *md); \& int BIO_get_md(BIO *b,EVP_MD **mdp); \& int BIO_get_md_ctx(BIO *b,EVP_MD_CTX **mdcp); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_f_md()\fR returns the message digest \s-1BIO\s0 method. This is a filter \&\s-1BIO\s0 that digests any data passed through it, it is a \s-1BIO\s0 wrapper for the digest routines \fIEVP_DigestInit()\fR, \fIEVP_DigestUpdate()\fR and \fIEVP_DigestFinal()\fR. .PP Any data written or read through a digest \s-1BIO\s0 using \fIBIO_read()\fR and \&\fIBIO_write()\fR is digested. .PP \&\fIBIO_gets()\fR, if its \fBsize\fR parameter is large enough finishes the digest calculation and returns the digest value. \fIBIO_puts()\fR is not supported. .PP \&\fIBIO_reset()\fR reinitialises a digest \s-1BIO.\s0 .PP \&\fIBIO_set_md()\fR sets the message digest of \s-1BIO \s0\fBb\fR to \fBmd\fR: this must be called to initialize a digest \s-1BIO\s0 before any data is passed through it. It is a \fIBIO_ctrl()\fR macro. .PP \&\fIBIO_get_md()\fR places the a pointer to the digest BIOs digest method in \fBmdp\fR, it is a \fIBIO_ctrl()\fR macro. .PP \&\fIBIO_get_md_ctx()\fR returns the digest BIOs context into \fBmdcp\fR. .SH "NOTES" .IX Header "NOTES" The context returned by \fIBIO_get_md_ctx()\fR can be used in calls to \fIEVP_DigestFinal()\fR and also the signature routines \fIEVP_SignFinal()\fR and \fIEVP_VerifyFinal()\fR. .PP The context returned by \fIBIO_get_md_ctx()\fR is an internal context structure. Changes made to this context will affect the digest \&\s-1BIO\s0 itself and the context pointer will become invalid when the digest \&\s-1BIO\s0 is freed. .PP After the digest has been retrieved from a digest \s-1BIO\s0 it must be reinitialized by calling \fIBIO_reset()\fR, or \fIBIO_set_md()\fR before any more data is passed through it. .PP If an application needs to call \fIBIO_gets()\fR or \fIBIO_puts()\fR through a chain containing digest BIOs then this can be done by prepending a buffering \s-1BIO.\s0 .PP Before OpenSSL 1.0.0 the call to \fIBIO_get_md_ctx()\fR would only work if the \s-1BIO\s0 had been initialized for example by calling \fIBIO_set_md()\fR ). In OpenSSL 1.0.0 and later the context is always returned and the \s-1BIO\s0 is state is set to initialized. This allows applications to initialize the context externally if the standard calls such as \fIBIO_set_md()\fR are not sufficiently flexible. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBIO_f_md()\fR returns the digest \s-1BIO\s0 method. .PP \&\fIBIO_set_md()\fR, \fIBIO_get_md()\fR and \fIBIO_md_ctx()\fR return 1 for success and 0 for failure. .SH "EXAMPLES" .IX Header "EXAMPLES" The following example creates a \s-1BIO\s0 chain containing an \s-1SHA1\s0 and \s-1MD5\s0 digest \s-1BIO\s0 and passes the string \*(L"Hello World\*(R" through it. Error checking has been omitted for clarity. .PP .Vb 10 \& BIO *bio, *mdtmp; \& const char message[] = "Hello World"; \& bio = BIO_new(BIO_s_null()); \& mdtmp = BIO_new(BIO_f_md()); \& BIO_set_md(mdtmp, EVP_sha1()); \& /* \& * For BIO_push() we want to append the sink BIO and keep a note of \& * the start of the chain. \& */ \& bio = BIO_push(mdtmp, bio); \& mdtmp = BIO_new(BIO_f_md()); \& BIO_set_md(mdtmp, EVP_md5()); \& bio = BIO_push(mdtmp, bio); \& /* Note: mdtmp can now be discarded */ \& BIO_write(bio, message, strlen(message)); .Ve .PP The next example digests data by reading through a chain instead: .PP .Vb 3 \& BIO *bio, *mdtmp; \& char buf[1024]; \& int rdlen; \& \& bio = BIO_new_file(file, "rb"); \& mdtmp = BIO_new(BIO_f_md()); \& BIO_set_md(mdtmp, EVP_sha1()); \& bio = BIO_push(mdtmp, bio); \& mdtmp = BIO_new(BIO_f_md()); \& BIO_set_md(mdtmp, EVP_md5()); \& bio = BIO_push(mdtmp, bio); \& do { \& rdlen = BIO_read(bio, buf, sizeof(buf)); \& /* Might want to do something with the data here */ \& } while (rdlen > 0); .Ve .PP This next example retrieves the message digests from a \s-1BIO\s0 chain and outputs them. This could be used with the examples above. .PP .Vb 4 \& BIO *mdtmp; \& unsigned char mdbuf[EVP_MAX_MD_SIZE]; \& int mdlen; \& int i; \& \& mdtmp = bio; /* Assume bio has previously been set up */ \& do { \& EVP_MD *md; \& mdtmp = BIO_find_type(mdtmp, BIO_TYPE_MD); \& if (!mdtmp) \& break; \& BIO_get_md(mdtmp, &md); \& printf("%s digest", OBJ_nid2sn(EVP_MD_type(md))); \& mdlen = BIO_gets(mdtmp, mdbuf, EVP_MAX_MD_SIZE); \& for(i = 0; i < mdlen; i++) \& printf(":%02X", mdbuf[i]); \& printf("\en"); \& mdtmp = BIO_next(mdtmp); \& } while(mdtmp); \& BIO_free_all(bio); .Ve .SH "BUGS" .IX Header "BUGS" The lack of support for \fIBIO_puts()\fR and the non standard behaviour of \&\fIBIO_gets()\fR could be regarded as anomalous. It could be argued that \fIBIO_gets()\fR and \fIBIO_puts()\fR should be passed to the next \s-1BIO\s0 in the chain and digest the data passed through and that digests should be retrieved using a separate \fIBIO_ctrl()\fR call. deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_num_bytes.30000644000175000017500000001333012360020712020154 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_num_bytes 3" .TH BN_num_bytes 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_num_bits, BN_num_bytes, BN_num_bits_word \- get BIGNUM size .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int BN_num_bytes(const BIGNUM *a); \& \& int BN_num_bits(const BIGNUM *a); \& \& int BN_num_bits_word(BN_ULONG w); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBN_num_bytes()\fR returns the size of a \fB\s-1BIGNUM\s0\fR in bytes. .PP \&\fIBN_num_bits_word()\fR returns the number of significant bits in a word. If we take 0x00000432 as an example, it returns 11, not 16, not 32. Basically, except for a zero, it returns \fIfloor(log2(w))+1\fR. .PP \&\fIBN_num_bits()\fR returns the number of significant bits in a \fB\s-1BIGNUM\s0\fR, following the same principle as \fIBN_num_bits_word()\fR. .PP \&\fIBN_num_bytes()\fR is a macro. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The size. .SH "NOTES" .IX Header "NOTES" Some have tried using \fIBN_num_bits()\fR on individual numbers in \s-1RSA\s0 keys, \&\s-1DH\s0 keys and \s-1DSA\s0 keys, and found that they don't always come up with the number of bits they expected (something like 512, 1024, 2048, \&...). This is because generating a number with some specific number of bits doesn't always set the highest bits, thereby making the number of \fIsignificant\fR bits a little lower. If you want to know the \*(L"key size\*(R" of such a key, either use functions like \fIRSA_size()\fR, \fIDH_size()\fR and \fIDSA_size()\fR, or use \fIBN_num_bytes()\fR and multiply with 8 (although there's no real guarantee that will match the \*(L"key size\*(R", just a lot more probability). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3), \fIDH_size\fR\|(3), \fIDSA_size\fR\|(3), \&\fIRSA_size\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIBN_num_bytes()\fR, \fIBN_num_bits()\fR and \fIBN_num_bits_word()\fR are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/RAND_set_rand_method.30000644000175000017500000001206212360020723021536 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RAND_set_rand_method 3" .TH RAND_set_rand_method 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RAND_set_rand_method, RAND_get_rand_method, RAND_SSLeay \- select RAND method .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void RAND_set_rand_method(const RAND_METHOD *meth); \& \& const RAND_METHOD *RAND_get_rand_method(void); \& \& RAND_METHOD *RAND_SSLeay(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions used to allow for the random number generator functions to be replaced by arbitrary code. .PP They are kept for \s-1ABI\s0 compatibility but are no longer functional, and should not be used in new programs. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIrand\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIRAND_set_rand_method()\fR, \fIRAND_get_rand_method()\fR and \fIRAND_SSLeay()\fR are available in all versions of OpenSSL. .PP In the engine version of version 0.9.6, \fIRAND_set_rand_method()\fR was altered to take an \s-1ENGINE\s0 pointer as its argument. As of version 0.9.7, that has been reverted as the \s-1ENGINE API\s0 transparently overrides \s-1RAND\s0 defaults if used, otherwise \s-1RAND API\s0 functions work as before. \fIRAND_set_rand_engine()\fR was also introduced in version 0.9.7. deps/libressl-pnacl-sys-2.1.6/libressl/man/CMS_add0_cert.30000644000175000017500000001424412360020713020125 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CMS_add0_cert 3" .TH CMS_add0_cert 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CMS_add0_cert, CMS_add1_cert, CMS_get1_certs, CMS_add0_crl, CMS_add1_crl, CMS_get1_crls \- CMS certificate and CRL utility functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert); \& int CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert); \& STACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms); \& \& int CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl); \& int CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl); \& STACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fICMS_add0_cert()\fR and \fICMS_add1_cert()\fR add certificate \fBcert\fR to \fBcms\fR. must be of type signed data or enveloped data. .PP \&\fICMS_get1_certs()\fR returns all certificates in \fBcms\fR. .PP \&\fICMS_add0_crl()\fR and \fICMS_add1_crl()\fR add \s-1CRL \s0\fBcrl\fR to \fBcms\fR. \fICMS_get1_crls()\fR returns any CRLs in \fBcms\fR. .SH "NOTES" .IX Header "NOTES" The CMS_ContentInfo structure \fBcms\fR must be of type signed data or enveloped data or an error will be returned. .PP For signed data certificates and CRLs are added to the \fBcertificates\fR and \&\fBcrls\fR fields of SignedData structure. For enveloped data they are added to \&\fBOriginatorInfo\fR. .PP As the \fB0\fR implies \fICMS_add0_cert()\fR adds \fBcert\fR internally to \fBcms\fR and it must not be freed up after the call as opposed to \fICMS_add1_cert()\fR where \fBcert\fR must be freed up. .PP The same certificate or \s-1CRL\s0 must not be added to the same cms structure more than once. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICMS_add0_cert()\fR, \fICMS_add1_cert()\fR and \fICMS_add0_crl()\fR and \fICMS_add1_crl()\fR return 1 for success and 0 for failure. .PP \&\fICMS_get1_certs()\fR and \fICMS_get1_crls()\fR return the \s-1STACK\s0 of certificates or CRLs or \s-1NULL\s0 if there are none or an error occurs. The only error which will occur in practice is if the \fBcms\fR type is invalid. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \&\fICMS_sign\fR\|(3), \&\fICMS_encrypt\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fICMS_add0_cert()\fR, \fICMS_add1_cert()\fR, \fICMS_get1_certs()\fR, \fICMS_add0_crl()\fR and \fICMS_get1_crls()\fR were all first added to OpenSSL 0.9.8 deps/libressl-pnacl-sys-2.1.6/libressl/man/s_server.10000644000175000017500000003760212360020743017432 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "s_server 1" .TH s_server 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" s_server \- SSL/TLS server program .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBs_server\fR [\fB\-accept port\fR] [\fB\-context id\fR] [\fB\-verify depth\fR] [\fB\-Verify depth\fR] [\fB\-crl_check\fR] [\fB\-crl_check_all\fR] [\fB\-cert filename\fR] [\fB\-certform DER|PEM\fR] [\fB\-key keyfile\fR] [\fB\-keyform DER|PEM\fR] [\fB\-pass arg\fR] [\fB\-dcert filename\fR] [\fB\-dcertform DER|PEM\fR] [\fB\-dkey keyfile\fR] [\fB\-dkeyform DER|PEM\fR] [\fB\-dpass arg\fR] [\fB\-dhparam filename\fR] [\fB\-nbio\fR] [\fB\-nbio_test\fR] [\fB\-crlf\fR] [\fB\-debug\fR] [\fB\-msg\fR] [\fB\-state\fR] [\fB\-CApath directory\fR] [\fB\-CAfile filename\fR] [\fB\-nocert\fR] [\fB\-cipher cipherlist\fR] [\fB\-quiet\fR] [\fB\-no_tmp_rsa\fR] [\fB\-ssl2\fR] [\fB\-ssl3\fR] [\fB\-tls1\fR] [\fB\-no_ssl2\fR] [\fB\-no_ssl3\fR] [\fB\-no_tls1\fR] [\fB\-no_dhe\fR] [\fB\-bugs\fR] [\fB\-hack\fR] [\fB\-www\fR] [\fB\-WWW\fR] [\fB\-HTTP\fR] [\fB\-engine id\fR] [\fB\-tlsextdebug\fR] [\fB\-no_ticket\fR] [\fB\-id_prefix arg\fR] [\fB\-rand file(s)\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBs_server\fR command implements a generic \s-1SSL/TLS\s0 server which listens for connections on a given port using \s-1SSL/TLS.\s0 .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-accept port\fR" 4 .IX Item "-accept port" the \s-1TCP\s0 port to listen on for connections. If not specified 4433 is used. .IP "\fB\-context id\fR" 4 .IX Item "-context id" sets the \s-1SSL\s0 context id. It can be given any string value. If this option is not present a default value will be used. .IP "\fB\-cert certname\fR" 4 .IX Item "-cert certname" The certificate to use, most servers cipher suites require the use of a certificate and some require a certificate with a certain public key type: for example the \s-1DSS\s0 cipher suites require a certificate containing a \s-1DSS \&\s0(\s-1DSA\s0) key. If not specified then the filename \*(L"server.pem\*(R" will be used. .IP "\fB\-certform format\fR" 4 .IX Item "-certform format" The certificate format to use: \s-1DER\s0 or \s-1PEM. PEM\s0 is the default. .IP "\fB\-key keyfile\fR" 4 .IX Item "-key keyfile" The private key to use. If not specified then the certificate file will be used. .IP "\fB\-keyform format\fR" 4 .IX Item "-keyform format" The private format to use: \s-1DER\s0 or \s-1PEM. PEM\s0 is the default. .IP "\fB\-pass arg\fR" 4 .IX Item "-pass arg" the private key password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-dcert filename\fR, \fB\-dkey keyname\fR" 4 .IX Item "-dcert filename, -dkey keyname" specify an additional certificate and private key, these behave in the same manner as the \fB\-cert\fR and \fB\-key\fR options except there is no default if they are not specified (no additional certificate and key is used). As noted above some cipher suites require a certificate containing a key of a certain type. Some cipher suites need a certificate carrying an \s-1RSA\s0 key and some a \s-1DSS \s0(\s-1DSA\s0) key. By using \s-1RSA\s0 and \s-1DSS\s0 certificates and keys a server can support clients which only support \s-1RSA\s0 or \s-1DSS\s0 cipher suites by using an appropriate certificate. .IP "\fB\-dcertform format\fR, \fB\-dkeyform format\fR, \fB\-dpass arg\fR" 4 .IX Item "-dcertform format, -dkeyform format, -dpass arg" additional certificate and private key format and passphrase respectively. .IP "\fB\-nocert\fR" 4 .IX Item "-nocert" if this option is set then no certificate is used. This restricts the cipher suites available to the anonymous ones (currently just anonymous \&\s-1DH\s0). .IP "\fB\-dhparam filename\fR" 4 .IX Item "-dhparam filename" the \s-1DH\s0 parameter file to use. The ephemeral \s-1DH\s0 cipher suites generate keys using a set of \s-1DH\s0 parameters. If not specified then an attempt is made to load the parameters from the server certificate file. If this fails then a static set of parameters hard coded into the s_server program will be used. .IP "\fB\-no_dhe\fR" 4 .IX Item "-no_dhe" if this option is set then no \s-1DH\s0 parameters will be loaded effectively disabling the ephemeral \s-1DH\s0 cipher suites. .IP "\fB\-no_tmp_rsa\fR" 4 .IX Item "-no_tmp_rsa" certain export cipher suites sometimes use a temporary \s-1RSA\s0 key, this option disables temporary \s-1RSA\s0 key generation. .IP "\fB\-verify depth\fR, \fB\-Verify depth\fR" 4 .IX Item "-verify depth, -Verify depth" The verify depth to use. This specifies the maximum length of the client certificate chain and makes the server request a certificate from the client. With the \fB\-verify\fR option a certificate is requested but the client does not have to send one, with the \fB\-Verify\fR option the client must supply a certificate or an error occurs. .IP "\fB\-crl_check\fR, \fB\-crl_check_all\fR" 4 .IX Item "-crl_check, -crl_check_all" Check the peer certificate has not been revoked by its \s-1CA.\s0 The \s-1CRL\s0(s) are appended to the certificate file. With the \fB\-crl_check_all\fR option all CRLs of all CAs in the chain are checked. .IP "\fB\-CApath directory\fR" 4 .IX Item "-CApath directory" The directory to use for client certificate verification. This directory must be in \*(L"hash format\*(R", see \fBverify\fR for more information. These are also used when building the server certificate chain. .IP "\fB\-CAfile file\fR" 4 .IX Item "-CAfile file" A file containing trusted certificates to use during client authentication and to use when attempting to build the server certificate chain. The list is also used in the list of acceptable client CAs passed to the client when a certificate is requested. .IP "\fB\-state\fR" 4 .IX Item "-state" prints out the \s-1SSL\s0 session states. .IP "\fB\-debug\fR" 4 .IX Item "-debug" print extensive debugging information including a hex dump of all traffic. .IP "\fB\-msg\fR" 4 .IX Item "-msg" show all protocol messages with hex dump. .IP "\fB\-nbio_test\fR" 4 .IX Item "-nbio_test" tests non blocking I/O .IP "\fB\-nbio\fR" 4 .IX Item "-nbio" turns on non blocking I/O .IP "\fB\-crlf\fR" 4 .IX Item "-crlf" this option translated a line feed from the terminal into \s-1CR+LF.\s0 .IP "\fB\-quiet\fR" 4 .IX Item "-quiet" inhibit printing of session and certificate information. .IP "\fB\-psk_hint hint\fR" 4 .IX Item "-psk_hint hint" Use the \s-1PSK\s0 identity hint \fBhint\fR when using a \s-1PSK\s0 cipher suite. .IP "\fB\-psk key\fR" 4 .IX Item "-psk key" Use the \s-1PSK\s0 key \fBkey\fR when using a \s-1PSK\s0 cipher suite. The key is given as a hexadecimal number without leading 0x, for example \-psk 1a2b3c4d. .IP "\fB\-ssl2\fR, \fB\-ssl3\fR, \fB\-tls1\fR, \fB\-no_ssl2\fR, \fB\-no_ssl3\fR, \fB\-no_tls1\fR" 4 .IX Item "-ssl2, -ssl3, -tls1, -no_ssl2, -no_ssl3, -no_tls1" these options disable the use of certain \s-1SSL\s0 or \s-1TLS\s0 protocols. By default the initial handshake uses a method which should be compatible with all servers and permit them to use \s-1SSL\s0 v3, \s-1SSL\s0 v2 or \s-1TLS\s0 as appropriate. .IP "\fB\-bugs\fR" 4 .IX Item "-bugs" there are several known bug in \s-1SSL\s0 and \s-1TLS\s0 implementations. Adding this option enables various workarounds. .IP "\fB\-hack\fR" 4 .IX Item "-hack" this option enables a further workaround for some some early Netscape \&\s-1SSL\s0 code (?). .IP "\fB\-cipher cipherlist\fR" 4 .IX Item "-cipher cipherlist" this allows the cipher list used by the server to be modified. When the client sends a list of supported ciphers the first client cipher also included in the server list is used. Because the client specifies the preference order, the order of the server cipherlist irrelevant. See the \fBciphers\fR command for more information. .IP "\fB\-tlsextdebug\fR" 4 .IX Item "-tlsextdebug" print out a hex dump of any \s-1TLS\s0 extensions received from the server. .IP "\fB\-no_ticket\fR" 4 .IX Item "-no_ticket" disable RFC4507bis session ticket support. .IP "\fB\-www\fR" 4 .IX Item "-www" sends a status message back to the client when it connects. This includes lots of information about the ciphers used and various session parameters. The output is in \s-1HTML\s0 format so this option will normally be used with a web browser. .IP "\fB\-WWW\fR" 4 .IX Item "-WWW" emulates a simple web server. Pages will be resolved relative to the current directory, for example if the \s-1URL\s0 https://myhost/page.html is requested the file ./page.html will be loaded. .IP "\fB\-HTTP\fR" 4 .IX Item "-HTTP" emulates a simple web server. Pages will be resolved relative to the current directory, for example if the \s-1URL\s0 https://myhost/page.html is requested the file ./page.html will be loaded. The files loaded are assumed to contain a complete and correct \s-1HTTP\s0 response (lines that are part of the \s-1HTTP\s0 response line and headers must end with \s-1CRLF\s0). .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBs_server\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .IP "\fB\-id_prefix arg\fR" 4 .IX Item "-id_prefix arg" generate \s-1SSL/TLS\s0 session IDs prefixed by \fBarg\fR. This is mostly useful for testing any \s-1SSL/TLS\s0 code (eg. proxies) that wish to deal with multiple servers, when each of which might be generating a unique range of session IDs (eg. with a certain prefix). .IP "\fB\-rand file(s)\fR" 4 .IX Item "-rand file(s)" a file or files containing random data used to seed the random number generator, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)). Multiple files can be specified separated by a OS-dependent character. The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for all others. .SH "CONNECTED COMMANDS" .IX Header "CONNECTED COMMANDS" If a connection request is established with an \s-1SSL\s0 client and neither the \&\fB\-www\fR nor the \fB\-WWW\fR option has been used then normally any data received from the client is displayed and any key presses will be sent to the client. .PP Certain single letter commands are also recognized which perform special operations: these are listed below. .IP "\fBq\fR" 4 .IX Item "q" end the current \s-1SSL\s0 connection but still accept new connections. .IP "\fBQ\fR" 4 .IX Item "Q" end the current \s-1SSL\s0 connection and exit. .IP "\fBr\fR" 4 .IX Item "r" renegotiate the \s-1SSL\s0 session. .IP "\fBR\fR" 4 .IX Item "R" renegotiate the \s-1SSL\s0 session and request a client certificate. .IP "\fBP\fR" 4 .IX Item "P" send some plain text down the underlying \s-1TCP\s0 connection: this should cause the client to disconnect due to a protocol violation. .IP "\fBS\fR" 4 .IX Item "S" print out some session cache status information. .SH "NOTES" .IX Header "NOTES" \&\fBs_server\fR can be used to debug \s-1SSL\s0 clients. To accept connections from a web browser the command: .PP .Vb 1 \& openssl s_server \-accept 443 \-www .Ve .PP can be used for example. .PP Most web browsers (in particular Netscape and \s-1MSIE\s0) only support \s-1RSA\s0 cipher suites, so they cannot connect to servers which don't use a certificate carrying an \s-1RSA\s0 key or a version of OpenSSL with \s-1RSA\s0 disabled. .PP Although specifying an empty list of CAs when requesting a client certificate is strictly speaking a protocol violation, some \s-1SSL\s0 clients interpret this to mean any \s-1CA\s0 is acceptable. This is useful for debugging purposes. .PP The session parameters can printed out using the \fBsess_id\fR program. .SH "BUGS" .IX Header "BUGS" Because this program has a lot of options and also because some of the techniques used are rather old, the C source of s_server is rather hard to read and not a model of how things should be done. A typical \&\s-1SSL\s0 server program would be much simpler. .PP The output of common ciphers is wrong: it just gives the list of ciphers that OpenSSL recognizes and the client supports. .PP There should be a way for the \fBs_server\fR program to print out details of any unknown cipher suites a client says it supports. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIsess_id\fR\|(1), \fIs_client\fR\|(1), \fIciphers\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_sess_set_cache_size.30000644000175000017500000001303112360020731023033 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_sess_set_cache_size 3" .TH SSL_CTX_sess_set_cache_size 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_sess_set_cache_size, SSL_CTX_sess_get_cache_size \- manipulate session cache size .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& long SSL_CTX_sess_set_cache_size(SSL_CTX *ctx, long t); \& long SSL_CTX_sess_get_cache_size(SSL_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_sess_set_cache_size()\fR sets the size of the internal session cache of context \fBctx\fR to \fBt\fR. .PP \&\fISSL_CTX_sess_get_cache_size()\fR returns the currently valid session cache size. .SH "NOTES" .IX Header "NOTES" The internal session cache size is \s-1SSL_SESSION_CACHE_MAX_SIZE_DEFAULT,\s0 currently 1024*20, so that up to 20000 sessions can be held. This size can be modified using the \fISSL_CTX_sess_set_cache_size()\fR call. A special case is the size 0, which is used for unlimited size. .PP When the maximum number of sessions is reached, no more new sessions are added to the cache. New space may be added by calling \&\fISSL_CTX_flush_sessions\fR\|(3) to remove expired sessions. .PP If the size of the session cache is reduced and more sessions are already in the session cache, old session will be removed at the next time a session shall be added. This removal is not synchronized with the expiration of sessions. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_sess_set_cache_size()\fR returns the previously valid size. .PP \&\fISSL_CTX_sess_get_cache_size()\fR returns the currently valid size. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \&\fISSL_CTX_set_session_cache_mode\fR\|(3), \&\fISSL_CTX_sess_number\fR\|(3), \&\fISSL_CTX_flush_sessions\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/d2i_ECPKParameters.30000644000175000017500000002007012360020726021100 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "d2i_ECPKParameters 3" .TH d2i_ECPKParameters 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" d2i_ECPKParameters, i2d_ECPKParameters, d2i_ECPKParameters_bio, i2d_ECPKParameters_bio, d2i_ECPKParameters_fp, i2d_ECPKParameters_fp, ECPKParameters_print, ECPKParameters_print_fp \- Functions for decoding and encoding ASN1 representations of elliptic curve entities .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& EC_GROUP *d2i_ECPKParameters(EC_GROUP **px, const unsigned char **in, long len); \& int i2d_ECPKParameters(const EC_GROUP *x, unsigned char **out); \& #define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x) \& #define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x) \& #define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \e \& (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x)) \& #define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \e \& (unsigned char *)(x)) \& int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off); \& int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The ECPKParameters encode and decode routines encode and parse the public parameters for an \&\fB\s-1EC_GROUP\s0\fR structure, which represents a curve. .PP \&\fId2i_ECPKParameters()\fR attempts to decode \fBlen\fR bytes at \fB*in\fR. If successful a pointer to the \fB\s-1EC_GROUP\s0\fR structure is returned. If an error occurred then \fB\s-1NULL\s0\fR is returned. If \fBpx\fR is not \fB\s-1NULL\s0\fR then the returned structure is written to \fB*px\fR. If \fB*px\fR is not \fB\s-1NULL\s0\fR then it is assumed that \fB*px\fR contains a valid \fB\s-1EC_GROUP\s0\fR structure and an attempt is made to reuse it. If the call is successful \fB*in\fR is incremented to the byte following the parsed data. .PP \&\fIi2d_ECPKParameters()\fR encodes the structure pointed to by \fBx\fR into \s-1DER\s0 format. If \fBout\fR is not \fB\s-1NULL\s0\fR is writes the \s-1DER\s0 encoded data to the buffer at \fB*out\fR, and increments it to point after the data just written. If the return value is negative an error occurred, otherwise it returns the length of the encoded data. .PP If \fB*out\fR is \fB\s-1NULL\s0\fR memory will be allocated for a buffer and the encoded data written to it. In this case \fB*out\fR is not incremented and it points to the start of the data just written. .PP \&\fId2i_ECPKParameters_bio()\fR is similar to \fId2i_ECPKParameters()\fR except it attempts to parse data from \s-1BIO \s0\fBbp\fR. .PP \&\fId2i_ECPKParameters_fp()\fR is similar to \fId2i_ECPKParameters()\fR except it attempts to parse data from \s-1FILE\s0 pointer \fBfp\fR. .PP \&\fIi2d_ECPKParameters_bio()\fR is similar to \fIi2d_ECPKParameters()\fR except it writes the encoding of the structure \fBx\fR to \s-1BIO \s0\fBbp\fR and it returns 1 for success and 0 for failure. .PP \&\fIi2d_ECPKParameters_fp()\fR is similar to \fIi2d_ECPKParameters()\fR except it writes the encoding of the structure \fBx\fR to \s-1BIO \s0\fBbp\fR and it returns 1 for success and 0 for failure. .PP These functions are very similar to the X509 functions described in \fId2i_X509\fR\|(3), where further notes and examples are available. .PP The ECPKParameters_print and ECPKParameters_print_fp functions print a human-readable output of the public parameters of the \s-1EC_GROUP\s0 to \fBbp\fR or \fBfp\fR. The output lines are indented by \fBoff\fR spaces. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fId2i_ECPKParameters()\fR, \fId2i_ECPKParameters_bio()\fR and \fId2i_ECPKParameters_fp()\fR return a valid \fB\s-1EC_GROUP\s0\fR structure or \fB\s-1NULL\s0\fR if an error occurs. .PP \&\fIi2d_ECPKParameters()\fR returns the number of bytes successfully encoded or a negative value if an error occurs. .PP \&\fIi2d_ECPKParameters_bio()\fR, \fIi2d_ECPKParameters_fp()\fR, ECPKParameters_print and ECPKParameters_print_fp return 1 for success and 0 if an error occurs. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIcrypto\fR\|(3), \fIec\fR\|(3), \fIEC_GROUP_new\fR\|(3), \fIEC_GROUP_copy\fR\|(3), \&\fIEC_POINT_new\fR\|(3), \fIEC_POINT_add\fR\|(3), \fIEC_KEY_new\fR\|(3), \&\fIEC_GFp_simple_method\fR\|(3), \fId2i_X509\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/pkcs8.10000644000175000017500000003202412360020742016622 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "pkcs8 1" .TH pkcs8 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" pkcs8 \- PKCS#8 format private key conversion tool .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBpkcs8\fR [\fB\-topk8\fR] [\fB\-inform PEM|DER\fR] [\fB\-outform PEM|DER\fR] [\fB\-in filename\fR] [\fB\-passin arg\fR] [\fB\-out filename\fR] [\fB\-passout arg\fR] [\fB\-noiter\fR] [\fB\-nocrypt\fR] [\fB\-nooct\fR] [\fB\-embed\fR] [\fB\-nsdb\fR] [\fB\-v2 alg\fR] [\fB\-v1 alg\fR] [\fB\-engine id\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBpkcs8\fR command processes private keys in PKCS#8 format. It can handle both unencrypted PKCS#8 PrivateKeyInfo format and EncryptedPrivateKeyInfo format with a variety of PKCS#5 (v1.5 and v2.0) and PKCS#12 algorithms. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" .IP "\fB\-topk8\fR" 4 .IX Item "-topk8" Normally a PKCS#8 private key is expected on input and a traditional format private key will be written. With the \fB\-topk8\fR option the situation is reversed: it reads a traditional format private key and writes a PKCS#8 format key. .IP "\fB\-inform DER|PEM\fR" 4 .IX Item "-inform DER|PEM" This specifies the input format. If a PKCS#8 format key is expected on input then either a \fB\s-1DER\s0\fR or \fB\s-1PEM\s0\fR encoded version of a PKCS#8 key will be expected. Otherwise the \fB\s-1DER\s0\fR or \fB\s-1PEM\s0\fR format of the traditional format private key is used. .IP "\fB\-outform DER|PEM\fR" 4 .IX Item "-outform DER|PEM" This specifies the output format, the options have the same meaning as the \&\fB\-inform\fR option. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read a key from or standard input if this option is not specified. If the key is encrypted a pass phrase will be prompted for. .IP "\fB\-passin arg\fR" 4 .IX Item "-passin arg" the input file password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" This specifies the output filename to write a key to or standard output by default. If any encryption options are set then a pass phrase will be prompted for. The output filename should \fBnot\fR be the same as the input filename. .IP "\fB\-passout arg\fR" 4 .IX Item "-passout arg" the output file password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-nocrypt\fR" 4 .IX Item "-nocrypt" PKCS#8 keys generated or input are normally PKCS#8 EncryptedPrivateKeyInfo structures using an appropriate password based encryption algorithm. With this option an unencrypted PrivateKeyInfo structure is expected or output. This option does not encrypt private keys at all and should only be used when absolutely necessary. Certain software such as some versions of Java code signing software used unencrypted private keys. .IP "\fB\-nooct\fR" 4 .IX Item "-nooct" This option generates \s-1RSA\s0 private keys in a broken format that some software uses. Specifically the private key should be enclosed in a \s-1OCTET STRING\s0 but some software just includes the structure itself without the surrounding \s-1OCTET STRING.\s0 .IP "\fB\-embed\fR" 4 .IX Item "-embed" This option generates \s-1DSA\s0 keys in a broken format. The \s-1DSA\s0 parameters are embedded inside the PrivateKey structure. In this form the \s-1OCTET STRING\s0 contains an \s-1ASN1 SEQUENCE\s0 consisting of two structures: a \s-1SEQUENCE\s0 containing the parameters and an \s-1ASN1 INTEGER\s0 containing the private key. .IP "\fB\-nsdb\fR" 4 .IX Item "-nsdb" This option generates \s-1DSA\s0 keys in a broken format compatible with Netscape private key databases. The PrivateKey contains a \s-1SEQUENCE\s0 consisting of the public and private keys respectively. .IP "\fB\-v2 alg\fR" 4 .IX Item "-v2 alg" This option enables the use of PKCS#5 v2.0 algorithms. Normally PKCS#8 private keys are encrypted with the password based encryption algorithm called \fBpbeWithMD5AndDES\-CBC\fR this uses 56 bit \s-1DES\s0 encryption but it was the strongest encryption algorithm supported in PKCS#5 v1.5. Using the \fB\-v2\fR option PKCS#5 v2.0 algorithms are used which can use any encryption algorithm such as 168 bit triple \s-1DES\s0 or 128 bit \s-1RC2\s0 however not many implementations support PKCS#5 v2.0 yet. If you are just using private keys with OpenSSL then this doesn't matter. .Sp The \fBalg\fR argument is the encryption algorithm to use, valid values include \&\fBdes\fR, \fBdes3\fR and \fBrc2\fR. It is recommended that \fBdes3\fR is used. .IP "\fB\-v1 alg\fR" 4 .IX Item "-v1 alg" This option specifies a PKCS#5 v1.5 or PKCS#12 algorithm to use. A complete list of possible algorithms is included below. .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBpkcs8\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .SH "NOTES" .IX Header "NOTES" The encrypted form of a \s-1PEM\s0 encode PKCS#8 files uses the following headers and footers: .PP .Vb 2 \& \-\-\-\-\-BEGIN ENCRYPTED PRIVATE KEY\-\-\-\-\- \& \-\-\-\-\-END ENCRYPTED PRIVATE KEY\-\-\-\-\- .Ve .PP The unencrypted form uses: .PP .Vb 2 \& \-\-\-\-\-BEGIN PRIVATE KEY\-\-\-\-\- \& \-\-\-\-\-END PRIVATE KEY\-\-\-\-\- .Ve .PP Private keys encrypted using PKCS#5 v2.0 algorithms and high iteration counts are more secure that those encrypted using the traditional SSLeay compatible formats. So if additional security is considered important the keys should be converted. .PP The default encryption is only 56 bits because this is the encryption that most current implementations of PKCS#8 will support. .PP Some software may use PKCS#12 password based encryption algorithms with PKCS#8 format private keys: these are handled automatically but there is no option to produce them. .PP It is possible to write out \s-1DER\s0 encoded encrypted private keys in PKCS#8 format because the encryption details are included at an \s-1ASN1\s0 level whereas the traditional format includes them at a \s-1PEM\s0 level. .SH "PKCS#5 v1.5 and PKCS#12 algorithms." .IX Header "PKCS#5 v1.5 and PKCS#12 algorithms." Various algorithms can be used with the \fB\-v1\fR command line option, including PKCS#5 v1.5 and PKCS#12. These are described in more detail below. .IP "\fB\s-1PBE\-MD2\-DES PBE\-MD5\-DES\s0\fR" 4 .IX Item "PBE-MD2-DES PBE-MD5-DES" These algorithms were included in the original PKCS#5 v1.5 specification. They only offer 56 bits of protection since they both use \s-1DES.\s0 .IP "\fB\s-1PBE\-SHA1\-RC2\-64 PBE\-MD2\-RC2\-64 PBE\-MD5\-RC2\-64 PBE\-SHA1\-DES\s0\fR" 4 .IX Item "PBE-SHA1-RC2-64 PBE-MD2-RC2-64 PBE-MD5-RC2-64 PBE-SHA1-DES" These algorithms are not mentioned in the original PKCS#5 v1.5 specification but they use the same key derivation algorithm and are supported by some software. They are mentioned in PKCS#5 v2.0. They use either 64 bit \s-1RC2\s0 or 56 bit \s-1DES.\s0 .IP "\fB\s-1PBE\-SHA1\-RC4\-128 PBE\-SHA1\-RC4\-40 PBE\-SHA1\-3DES PBE\-SHA1\-2DES PBE\-SHA1\-RC2\-128 PBE\-SHA1\-RC2\-40\s0\fR" 4 .IX Item "PBE-SHA1-RC4-128 PBE-SHA1-RC4-40 PBE-SHA1-3DES PBE-SHA1-2DES PBE-SHA1-RC2-128 PBE-SHA1-RC2-40" These algorithms use the PKCS#12 password based encryption algorithm and allow strong encryption algorithms like triple \s-1DES\s0 or 128 bit \s-1RC2\s0 to be used. .SH "EXAMPLES" .IX Header "EXAMPLES" Convert a private from traditional to PKCS#5 v2.0 format using triple \&\s-1DES:\s0 .PP .Vb 1 \& openssl pkcs8 \-in key.pem \-topk8 \-v2 des3 \-out enckey.pem .Ve .PP Convert a private key to PKCS#8 using a PKCS#5 1.5 compatible algorithm (\s-1DES\s0): .PP .Vb 1 \& openssl pkcs8 \-in key.pem \-topk8 \-out enckey.pem .Ve .PP Convert a private key to PKCS#8 using a PKCS#12 compatible algorithm (3DES): .PP .Vb 1 \& openssl pkcs8 \-in key.pem \-topk8 \-out enckey.pem \-v1 PBE\-SHA1\-3DES .Ve .PP Read a \s-1DER\s0 unencrypted PKCS#8 format private key: .PP .Vb 1 \& openssl pkcs8 \-inform DER \-nocrypt \-in key.der \-out key.pem .Ve .PP Convert a private key from any PKCS#8 format to traditional format: .PP .Vb 1 \& openssl pkcs8 \-in pk8.pem \-out key.pem .Ve .SH "STANDARDS" .IX Header "STANDARDS" Test vectors from this PKCS#5 v2.0 implementation were posted to the pkcs-tng mailing list using triple \s-1DES, DES\s0 and \s-1RC2\s0 with high iteration counts, several people confirmed that they could decrypt the private keys produced and Therefore it can be assumed that the PKCS#5 v2.0 implementation is reasonably accurate at least as far as these algorithms are concerned. .PP The format of PKCS#8 \s-1DSA \s0(and other) private keys is not well documented: it is hidden away in PKCS#11 v2.01, section 11.9. OpenSSL's default \s-1DSA\s0 PKCS#8 private key format complies with this standard. .SH "BUGS" .IX Header "BUGS" There should be an option that prints out the encryption algorithm in use and other details such as the iteration count. .PP PKCS#8 using triple \s-1DES\s0 and PKCS#5 v2.0 should be the default private key format for OpenSSL: for compatibility several of the utilities use the old format at present. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdsa\fR\|(1), \fIrsa\fR\|(1), \fIgenrsa\fR\|(1), \&\fIgendsa\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_get_session.30000644000175000017500000001453412360020736020650 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_get_session 3" .TH SSL_get_session 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_get_session, SSL_get0_session, SSL_get1_session \- retrieve TLS/SSL session data .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& SSL_SESSION *SSL_get_session(const SSL *ssl); \& SSL_SESSION *SSL_get0_session(const SSL *ssl); \& SSL_SESSION *SSL_get1_session(SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_get_session()\fR returns a pointer to the \fB\s-1SSL_SESSION\s0\fR actually used in \&\fBssl\fR. The reference count of the \fB\s-1SSL_SESSION\s0\fR is not incremented, so that the pointer can become invalid by other operations. .PP \&\fISSL_get0_session()\fR is the same as \fISSL_get_session()\fR. .PP \&\fISSL_get1_session()\fR is the same as \fISSL_get_session()\fR, but the reference count of the \fB\s-1SSL_SESSION\s0\fR is incremented by one. .SH "NOTES" .IX Header "NOTES" The ssl session contains all information required to re-establish the connection without a new handshake. .PP \&\fISSL_get0_session()\fR returns a pointer to the actual session. As the reference counter is not incremented, the pointer is only valid while the connection is in use. If \fISSL_clear\fR\|(3) or \&\fISSL_free\fR\|(3) is called, the session may be removed completely (if considered bad), and the pointer obtained will become invalid. Even if the session is valid, it can be removed at any time due to timeout during \fISSL_CTX_flush_sessions\fR\|(3). .PP If the data is to be kept, \fISSL_get1_session()\fR will increment the reference count, so that the session will not be implicitly removed by other operations but stays in memory. In order to remove the session \&\fISSL_SESSION_free\fR\|(3) must be explicitly called once to decrement the reference count again. .PP \&\s-1SSL_SESSION\s0 objects keep internal link information about the session cache list, when being inserted into one \s-1SSL_CTX\s0 object's session cache. One \s-1SSL_SESSION\s0 object, regardless of its reference count, must therefore only be used with one \s-1SSL_CTX\s0 object (and the \s-1SSL\s0 objects created from this \s-1SSL_CTX\s0 object). .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .IP "\s-1NULL\s0" 4 .IX Item "NULL" There is no session available in \fBssl\fR. .IP "Pointer to an \s-1SSL\s0" 4 .IX Item "Pointer to an SSL" The return value points to the data of an \s-1SSL\s0 session. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_free\fR\|(3), \&\fISSL_clear\fR\|(3), \&\fISSL_SESSION_free\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_get_peer_cert_chain.30000644000175000017500000001260112360020735022267 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_get_peer_cert_chain 3" .TH SSL_get_peer_cert_chain 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_get_peer_cert_chain \- get the X509 certificate chain of the peer .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_get_peer_cert_chain()\fR returns a pointer to \s-1STACK_OF\s0(X509) certificates forming the certificate chain of the peer. If called on the client side, the stack also contains the peer's certificate; if called on the server side, the peer's certificate must be obtained separately using \&\fISSL_get_peer_certificate\fR\|(3). If the peer did not present a certificate, \s-1NULL\s0 is returned. .SH "NOTES" .IX Header "NOTES" The peer certificate chain is not necessarily available after reusing a session, in which case a \s-1NULL\s0 pointer is returned. .PP The reference count of the \s-1STACK_OF\s0(X509) object is not incremented. If the corresponding session is freed, the pointer must not be used any longer. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .IP "\s-1NULL\s0" 4 .IX Item "NULL" No certificate was presented by the peer or no connection was established or the certificate chain is no longer available when a session is reused. .IP "Pointer to a \s-1STACK_OF\s0(X509)" 4 .IX Item "Pointer to a STACK_OF(X509)" The return value points to the certificate chain presented by the peer. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_get_peer_certificate\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_PKEY_cmp.30000644000175000017500000001376112360020720017720 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_PKEY_cmp 3" .TH EVP_PKEY_cmp 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_PKEY_copy_parameters, EVP_PKEY_missing_parameters, EVP_PKEY_cmp_parameters, EVP_PKEY_cmp \- public key parameter and comparison functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey); \& int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from); \& \& int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b); \& int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The function \fIEVP_PKEY_missing_parameters()\fR returns 1 if the public key parameters of \fBpkey\fR are missing and 0 if they are present or the algorithm doesn't use parameters. .PP The function \fIEVP_PKEY_copy_parameters()\fR copies the parameters from key \&\fBfrom\fR to key \fBto\fR. .PP The funcion \fIEVP_PKEY_cmp_parameters()\fR compares the parameters of keys \&\fBa\fR and \fBb\fR. .PP The funcion \fIEVP_PKEY_cmp()\fR compares the public key components and paramters (if present) of keys \fBa\fR and \fBb\fR. .SH "NOTES" .IX Header "NOTES" The main purpose of the functions \fIEVP_PKEY_missing_parameters()\fR and \&\fIEVP_PKEY_copy_parameters()\fR is to handle public keys in certificates where the parameters are sometimes omitted from a public key if they are inherited from the \s-1CA\s0 that signed it. .PP Since OpenSSL private keys contain public key components too the function \&\fIEVP_PKEY_cmp()\fR can also be used to determine if a private key matches a public key. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The function \fIEVP_PKEY_missing_parameters()\fR returns 1 if the public key parameters of \fBpkey\fR are missing and 0 if they are present or the algorithm doesn't use parameters. .PP These functions \fIEVP_PKEY_copy_parameters()\fR returns 1 for success and 0 for failure. .PP The function \fIEVP_PKEY_cmp_parameters()\fR and \fIEVP_PKEY_cmp()\fR return 1 if the keys match, 0 if they don't match, \-1 if the key types are different and \&\-2 if the operation is not supported. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_PKEY_CTX_new\fR\|(3), \&\fIEVP_PKEY_keygen\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_SESSION_get_ex_new_index.30000644000175000017500000001422112360020734023033 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_SESSION_get_ex_new_index 3" .TH SSL_SESSION_get_ex_new_index 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_SESSION_get_ex_new_index, SSL_SESSION_set_ex_data, SSL_SESSION_get_ex_data \&\- internal application specific data functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_SESSION_get_ex_new_index(long argl, void *argp, \& CRYPTO_EX_new *new_func, \& CRYPTO_EX_dup *dup_func, \& CRYPTO_EX_free *free_func); \& \& int SSL_SESSION_set_ex_data(SSL_SESSION *session, int idx, void *arg); \& \& void *SSL_SESSION_get_ex_data(const SSL_SESSION *session, int idx); \& \& typedef int new_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad, \& int idx, long argl, void *argp); \& typedef void free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad, \& int idx, long argl, void *argp); \& typedef int dup_func(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, \& int idx, long argl, void *argp); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Several OpenSSL structures can have application specific data attached to them. These functions are used internally by OpenSSL to manipulate application specific data attached to a specific structure. .PP \&\fISSL_SESSION_get_ex_new_index()\fR is used to register a new index for application specific data. .PP \&\fISSL_SESSION_set_ex_data()\fR is used to store application data at \fBarg\fR for \fBidx\fR into the \fBsession\fR object. .PP \&\fISSL_SESSION_get_ex_data()\fR is used to retrieve the information for \fBidx\fR from \&\fBsession\fR. .PP A detailed description for the \fB*\f(BI_get_ex_new_index()\fB\fR functionality can be found in \fIRSA_get_ex_new_index\fR\|(3). The \fB*\f(BI_get_ex_data()\fB\fR and \fB*\f(BI_set_ex_data()\fB\fR functionality is described in \&\fICRYPTO_set_ex_data\fR\|(3). .SH "WARNINGS" .IX Header "WARNINGS" The application data is only maintained for sessions held in memory. The application data is not included when dumping the session with \&\fIi2d_SSL_SESSION()\fR (and all functions indirectly calling the dump functions like \fIPEM_write_SSL_SESSION()\fR and \fIPEM_write_bio_SSL_SESSION()\fR) and can therefore not be restored. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \&\fIRSA_get_ex_new_index\fR\|(3), \&\fICRYPTO_set_ex_data\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/X509_STORE_CTX_new.30000644000175000017500000002201112360020725020600 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "X509_STORE_CTX_new 3" .TH X509_STORE_CTX_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" X509_STORE_CTX_new, X509_STORE_CTX_cleanup, X509_STORE_CTX_free, X509_STORE_CTX_init, X509_STORE_CTX_trusted_stack, X509_STORE_CTX_set_cert, X509_STORE_CTX_set_chain, X509_STORE_CTX_set0_crls, X509_STORE_CTX_get0_param, X509_STORE_CTX_set0_param, X509_STORE_CTX_set_default \- X509_STORE_CTX initialisation .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& X509_STORE_CTX *X509_STORE_CTX_new(void); \& void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); \& void X509_STORE_CTX_free(X509_STORE_CTX *ctx); \& \& int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, \& X509 *x509, STACK_OF(X509) *chain); \& \& void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); \& \& void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx,X509 *x); \& void X509_STORE_CTX_set_chain(X509_STORE_CTX *ctx,STACK_OF(X509) *sk); \& void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk); \& \& X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx); \& void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param); \& int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions initialise an \fBX509_STORE_CTX\fR structure for subsequent use by \fIX509_verify_cert()\fR. .PP \&\fIX509_STORE_CTX_new()\fR returns a newly initialised \fBX509_STORE_CTX\fR structure. .PP \&\fIX509_STORE_CTX_cleanup()\fR internally cleans up an \fBX509_STORE_CTX\fR structure. The context can then be reused with an new call to \fIX509_STORE_CTX_init()\fR. .PP \&\fIX509_STORE_CTX_free()\fR completely frees up \fBctx\fR. After this call \fBctx\fR is no longer valid. .PP \&\fIX509_STORE_CTX_init()\fR sets up \fBctx\fR for a subsequent verification operation. The trusted certificate store is set to \fBstore\fR, the end entity certificate to be verified is set to \fBx509\fR and a set of additional certificates (which will be untrusted but may be used to build the chain) in \fBchain\fR. Any or all of the \fBstore\fR, \fBx509\fR and \fBchain\fR parameters can be \fB\s-1NULL\s0\fR. .PP \&\fIX509_STORE_CTX_trusted_stack()\fR sets the set of trusted certificates of \fBctx\fR to \fBsk\fR. This is an alternative way of specifying trusted certificates instead of using an \fBX509_STORE\fR. .PP \&\fIX509_STORE_CTX_set_cert()\fR sets the certificate to be vertified in \fBctx\fR to \&\fBx\fR. .PP \&\fIX509_STORE_CTX_set_chain()\fR sets the additional certificate chain used by \fBctx\fR to \fBsk\fR. .PP \&\fIX509_STORE_CTX_set0_crls()\fR sets a set of CRLs to use to aid certificate verification to \fBsk\fR. These CRLs will only be used if \s-1CRL\s0 verification is enabled in the associated \fBX509_VERIFY_PARAM\fR structure. This might be used where additional \*(L"useful\*(R" CRLs are supplied as part of a protocol, for example in a PKCS#7 structure. .PP X509_VERIFY_PARAM *\fIX509_STORE_CTX_get0_param()\fR retrieves an intenal pointer to the verification parameters associated with \fBctx\fR. .PP \&\fIX509_STORE_CTX_set0_param()\fR sets the intenal verification parameter pointer to \fBparam\fR. After this call \fBparam\fR should not be used. .PP \&\fIX509_STORE_CTX_set_default()\fR looks up and sets the default verification method to \fBname\fR. This uses the function \fIX509_VERIFY_PARAM_lookup()\fR to find an appropriate set of parameters from \fBname\fR. .SH "NOTES" .IX Header "NOTES" The certificates and CRLs in a store are used internally and should \fBnot\fR be freed up until after the associated \fBX509_STORE_CTX\fR is freed. Legacy applications might implicitly use an \fBX509_STORE_CTX\fR like this: .PP .Vb 2 \& X509_STORE_CTX ctx; \& X509_STORE_CTX_init(&ctx, store, cert, chain); .Ve .PP this is \fBnot\fR recommended in new applications they should instead do: .PP .Vb 5 \& X509_STORE_CTX *ctx; \& ctx = X509_STORE_CTX_new(); \& if (ctx == NULL) \& /* Bad error */ \& X509_STORE_CTX_init(ctx, store, cert, chain); .Ve .SH "BUGS" .IX Header "BUGS" The certificates and CRLs in a context are used internally and should \fBnot\fR be freed up until after the associated \fBX509_STORE_CTX\fR is freed. Copies should be made or reference counts increased instead. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIX509_STORE_CTX_new()\fR returns an newly allocates context or \fB\s-1NULL\s0\fR is an error occurred. .PP \&\fIX509_STORE_CTX_init()\fR returns 1 for success or 0 if an error occurred. .PP \&\fIX509_STORE_CTX_get0_param()\fR returns a pointer to an \fBX509_VERIFY_PARAM\fR structure or \fB\s-1NULL\s0\fR if an error occurred. .PP \&\fIX509_STORE_CTX_cleanup()\fR, \fIX509_STORE_CTX_free()\fR, \fIX509_STORE_CTX_trusted_stack()\fR, \&\fIX509_STORE_CTX_set_cert()\fR, \fIX509_STORE_CTX_set_chain()\fR, \&\fIX509_STORE_CTX_set0_crls()\fR and \fIX509_STORE_CTX_set0_param()\fR do not return values. .PP \&\fIX509_STORE_CTX_set_default()\fR returns 1 for success or 0 if an error occurred. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIX509_verify_cert\fR\|(3) \&\fIX509_VERIFY_PARAM_set_flags\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIX509_STORE_CTX_set0_crls()\fR was first added to OpenSSL 1.0.0 deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_get_ex_data_X509_STORE_CTX_idx.30000644000175000017500000001345412360020735023654 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_get_ex_data_X509_STORE_CTX_idx 3" .TH SSL_get_ex_data_X509_STORE_CTX_idx 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_get_ex_data_X509_STORE_CTX_idx \- get ex_data index to access SSL structure from X509_STORE_CTX .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_get_ex_data_X509_STORE_CTX_idx(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_get_ex_data_X509_STORE_CTX_idx()\fR returns the index number under which the pointer to the \s-1SSL\s0 object is stored into the X509_STORE_CTX object. .SH "NOTES" .IX Header "NOTES" Whenever a X509_STORE_CTX object is created for the verification of the peers certificate during a handshake, a pointer to the \s-1SSL\s0 object is stored into the X509_STORE_CTX object to identify the connection affected. To retrieve this pointer the \fIX509_STORE_CTX_get_ex_data()\fR function can be used with the correct index. This index is globally the same for all X509_STORE_CTX objects and can be retrieved using \&\fISSL_get_ex_data_X509_STORE_CTX_idx()\fR. The index value is set when \&\fISSL_get_ex_data_X509_STORE_CTX_idx()\fR is first called either by the application program directly or indirectly during other \s-1SSL\s0 setup functions or during the handshake. .PP The value depends on other index values defined for X509_STORE_CTX objects before the \s-1SSL\s0 index is created. .SH "RETURN VALUES" .IX Header "RETURN VALUES" .IP ">=0" 4 .IX Item ">=0" The index value to access the pointer. .IP "<0" 4 .IX Item "<0" An error occurred, check the error stack for a detailed error message. .SH "EXAMPLES" .IX Header "EXAMPLES" The index returned from \fISSL_get_ex_data_X509_STORE_CTX_idx()\fR allows to access the \s-1SSL\s0 object for the connection to be accessed during the \&\fIverify_callback()\fR when checking the peers certificate. Please check the example in \fISSL_CTX_set_verify\fR\|(3), .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_CTX_set_verify\fR\|(3), \&\fICRYPTO_set_ex_data\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_get_verify_result.30000644000175000017500000001260112360020736022060 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_get_verify_result 3" .TH SSL_get_verify_result 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_get_verify_result \- get result of peer certificate verification .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& long SSL_get_verify_result(const SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_get_verify_result()\fR returns the result of the verification of the X509 certificate presented by the peer, if any. .SH "NOTES" .IX Header "NOTES" \&\fISSL_get_verify_result()\fR can only return one error code while the verification of a certificate can fail because of many reasons at the same time. Only the last verification error that occurred during the processing is available from \fISSL_get_verify_result()\fR. .PP The verification result is part of the established session and is restored when a session is reused. .SH "BUGS" .IX Header "BUGS" If no peer certificate was presented, the returned result code is X509_V_OK. This is because no verification error occurred, it does however not indicate success. \fISSL_get_verify_result()\fR is only useful in connection with \fISSL_get_peer_certificate\fR\|(3). .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can currently occur: .IP "X509_V_OK" 4 .IX Item "X509_V_OK" The verification succeeded or no peer certificate was presented. .IP "Any other value" 4 .IX Item "Any other value" Documented in \fIverify\fR\|(1). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_set_verify_result\fR\|(3), \&\fISSL_get_peer_certificate\fR\|(3), \&\fIverify\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_client_CA_list.30000644000175000017500000001641112360020732022563 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_client_CA_list 3" .TH SSL_CTX_set_client_CA_list 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_client_CA_list, SSL_set_client_CA_list, SSL_CTX_add_client_CA, SSL_add_client_CA \- set list of CAs sent to the client when requesting a client certificate .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *list); \& void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *list); \& int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *cacert); \& int SSL_add_client_CA(SSL *ssl, X509 *cacert); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_client_CA_list()\fR sets the \fBlist\fR of CAs sent to the client when requesting a client certificate for \fBctx\fR. .PP \&\fISSL_set_client_CA_list()\fR sets the \fBlist\fR of CAs sent to the client when requesting a client certificate for the chosen \fBssl\fR, overriding the setting valid for \fBssl\fR's \s-1SSL_CTX\s0 object. .PP \&\fISSL_CTX_add_client_CA()\fR adds the \s-1CA\s0 name extracted from \fBcacert\fR to the list of CAs sent to the client when requesting a client certificate for \&\fBctx\fR. .PP \&\fISSL_add_client_CA()\fR adds the \s-1CA\s0 name extracted from \fBcacert\fR to the list of CAs sent to the client when requesting a client certificate for the chosen \fBssl\fR, overriding the setting valid for \fBssl\fR's \s-1SSL_CTX\s0 object. .SH "NOTES" .IX Header "NOTES" When a \s-1TLS/SSL\s0 server requests a client certificate (see \&\fB\f(BISSL_CTX_set_verify\fB\|(3)\fR), it sends a list of CAs, for which it will accept certificates, to the client. .PP This list must explicitly be set using \fISSL_CTX_set_client_CA_list()\fR for \&\fBctx\fR and \fISSL_set_client_CA_list()\fR for the specific \fBssl\fR. The list specified overrides the previous setting. The CAs listed do not become trusted (\fBlist\fR only contains the names, not the complete certificates); use \&\fISSL_CTX_load_verify_locations\fR\|(3) to additionally load them for verification. .PP If the list of acceptable CAs is compiled in a file, the \&\fISSL_load_client_CA_file\fR\|(3) function can be used to help importing the necessary data. .PP \&\fISSL_CTX_add_client_CA()\fR and \fISSL_add_client_CA()\fR can be used to add additional items the list of client CAs. If no list was specified before using \&\fISSL_CTX_set_client_CA_list()\fR or \fISSL_set_client_CA_list()\fR, a new client \&\s-1CA\s0 list for \fBctx\fR or \fBssl\fR (as appropriate) is opened. .PP These functions are only useful for \s-1TLS/SSL\s0 servers. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_set_client_CA_list()\fR and \fISSL_set_client_CA_list()\fR do not return diagnostic information. .PP \&\fISSL_CTX_add_client_CA()\fR and \fISSL_add_client_CA()\fR have the following return values: .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" A failure while manipulating the \s-1STACK_OF\s0(X509_NAME) object occurred or the X509_NAME could not be extracted from \fBcacert\fR. Check the error stack to find out the reason. .ie n .IP "1" 4 .el .IP "\f(CW1\fR" 4 .IX Item "1" The operation succeeded. .SH "EXAMPLES" .IX Header "EXAMPLES" Scan all certificates in \fBCAfile\fR and list them as acceptable CAs: .PP .Vb 1 \& SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(CAfile)); .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \&\fISSL_get_client_CA_list\fR\|(3), \&\fISSL_load_client_CA_file\fR\|(3), \&\fISSL_CTX_load_verify_locations\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/d2i_X509.30000644000175000017500000002606512360020727017012 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "d2i_X509 3" .TH d2i_X509 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" d2i_X509, i2d_X509, d2i_X509_bio, d2i_X509_fp, i2d_X509_bio, i2d_X509_fp \- X509 encode and decode functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& X509 *d2i_X509(X509 **px, const unsigned char **in, int len); \& int i2d_X509(X509 *x, unsigned char **out); \& \& X509 *d2i_X509_bio(BIO *bp, X509 **x); \& X509 *d2i_X509_fp(FILE *fp, X509 **x); \& \& int i2d_X509_bio(BIO *bp, X509 *x); \& int i2d_X509_fp(FILE *fp, X509 *x); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The X509 encode and decode routines encode and parse an \&\fBX509\fR structure, which represents an X509 certificate. .PP \&\fId2i_X509()\fR attempts to decode \fBlen\fR bytes at \fB*in\fR. If successful a pointer to the \fBX509\fR structure is returned. If an error occurred then \fB\s-1NULL\s0\fR is returned. If \fBpx\fR is not \fB\s-1NULL\s0\fR then the returned structure is written to \fB*px\fR. If \fB*px\fR is not \fB\s-1NULL\s0\fR then it is assumed that \fB*px\fR contains a valid \fBX509\fR structure and an attempt is made to reuse it. If the call is successful \fB*in\fR is incremented to the byte following the parsed data. .PP \&\fIi2d_X509()\fR encodes the structure pointed to by \fBx\fR into \s-1DER\s0 format. If \fBout\fR is not \fB\s-1NULL\s0\fR is writes the \s-1DER\s0 encoded data to the buffer at \fB*out\fR, and increments it to point after the data just written. If the return value is negative an error occurred, otherwise it returns the length of the encoded data. .PP For OpenSSL 0.9.7 and later if \fB*out\fR is \fB\s-1NULL\s0\fR memory will be allocated for a buffer and the encoded data written to it. In this case \fB*out\fR is not incremented and it points to the start of the data just written. .PP \&\fId2i_X509_bio()\fR is similar to \fId2i_X509()\fR except it attempts to parse data from \s-1BIO \s0\fBbp\fR. .PP \&\fId2i_X509_fp()\fR is similar to \fId2i_X509()\fR except it attempts to parse data from \s-1FILE\s0 pointer \fBfp\fR. .PP \&\fIi2d_X509_bio()\fR is similar to \fIi2d_X509()\fR except it writes the encoding of the structure \fBx\fR to \s-1BIO \s0\fBbp\fR and it returns 1 for success and 0 for failure. .PP \&\fIi2d_X509_fp()\fR is similar to \fIi2d_X509()\fR except it writes the encoding of the structure \fBx\fR to \s-1BIO \s0\fBbp\fR and it returns 1 for success and 0 for failure. .SH "NOTES" .IX Header "NOTES" The letters \fBi\fR and \fBd\fR in for example \fBi2d_X509\fR stand for \&\*(L"internal\*(R" (that is an internal C structure) and \*(L"\s-1DER\*(R".\s0 So that \&\fBi2d_X509\fR converts from internal to \s-1DER.\s0 .PP The functions can also understand \fB\s-1BER\s0\fR forms. .PP The actual X509 structure passed to \fIi2d_X509()\fR must be a valid populated \fBX509\fR structure it can \fBnot\fR simply be fed with an empty structure such as that returned by \fIX509_new()\fR. .PP The encoded data is in binary form and may contain embedded zeroes. Therefore any \s-1FILE\s0 pointers or BIOs should be opened in binary mode. Functions such as \fB\f(BIstrlen()\fB\fR will \fBnot\fR return the correct length of the encoded structure. .PP The ways that \fB*in\fR and \fB*out\fR are incremented after the operation can trap the unwary. See the \fB\s-1WARNINGS\s0\fR section for some common errors. .PP The reason for the auto increment behaviour is to reflect a typical usage of \s-1ASN1\s0 functions: after one structure is encoded or decoded another will processed after it. .SH "EXAMPLES" .IX Header "EXAMPLES" Allocate and encode the \s-1DER\s0 encoding of an X509 structure: .PP .Vb 2 \& int len; \& unsigned char *buf, *p; \& \& len = i2d_X509(x, NULL); \& \& buf = OPENSSL_malloc(len); \& \& if (buf == NULL) \& /* error */ \& \& p = buf; \& \& i2d_X509(x, &p); .Ve .PP If you are using OpenSSL 0.9.7 or later then this can be simplified to: .PP .Vb 2 \& int len; \& unsigned char *buf; \& \& buf = NULL; \& \& len = i2d_X509(x, &buf); \& \& if (len < 0) \& /* error */ .Ve .PP Attempt to decode a buffer: .PP .Vb 1 \& X509 *x; \& \& unsigned char *buf, *p; \& \& int len; \& \& /* Something to setup buf and len */ \& \& p = buf; \& \& x = d2i_X509(NULL, &p, len); \& \& if (x == NULL) \& /* Some error */ .Ve .PP Alternative technique: .PP .Vb 1 \& X509 *x; \& \& unsigned char *buf, *p; \& \& int len; \& \& /* Something to setup buf and len */ \& \& p = buf; \& \& x = NULL; \& \& if(!d2i_X509(&x, &p, len)) \& /* Some error */ .Ve .SH "WARNINGS" .IX Header "WARNINGS" The use of temporary variable is mandatory. A common mistake is to attempt to use a buffer directly as follows: .PP .Vb 2 \& int len; \& unsigned char *buf; \& \& len = i2d_X509(x, NULL); \& \& buf = OPENSSL_malloc(len); \& \& if (buf == NULL) \& /* error */ \& \& i2d_X509(x, &buf); \& \& /* Other stuff ... */ \& \& OPENSSL_free(buf); .Ve .PP This code will result in \fBbuf\fR apparently containing garbage because it was incremented after the call to point after the data just written. Also \fBbuf\fR will no longer contain the pointer allocated by \fB\f(BIOPENSSL_malloc()\fB\fR and the subsequent call to \fB\f(BIOPENSSL_free()\fB\fR may well crash. .PP The auto allocation feature (setting buf to \s-1NULL\s0) only works on OpenSSL 0.9.7 and later. Attempts to use it on earlier versions will typically cause a segmentation violation. .PP Another trap to avoid is misuse of the \fBxp\fR argument to \fB\f(BId2i_X509()\fB\fR: .PP .Vb 1 \& X509 *x; \& \& if (!d2i_X509(&x, &p, len)) \& /* Some error */ .Ve .PP This will probably crash somewhere in \fB\f(BId2i_X509()\fB\fR. The reason for this is that the variable \fBx\fR is uninitialized and an attempt will be made to interpret its (invalid) value as an \fBX509\fR structure, typically causing a segmentation violation. If \fBx\fR is set to \s-1NULL\s0 first then this will not happen. .SH "BUGS" .IX Header "BUGS" In some versions of OpenSSL the \*(L"reuse\*(R" behaviour of \fId2i_X509()\fR when \&\fB*px\fR is valid is broken and some parts of the reused structure may persist if they are not present in the new one. As a result the use of this \*(L"reuse\*(R" behaviour is strongly discouraged. .PP \&\fIi2d_X509()\fR will not return an error in many versions of OpenSSL, if mandatory fields are not initialized due to a programming error then the encoded structure may contain invalid data or omit the fields entirely and will not be parsed by \fId2i_X509()\fR. This may be fixed in future so code should not assume that \fIi2d_X509()\fR will always succeed. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fId2i_X509()\fR, \fId2i_X509_bio()\fR and \fId2i_X509_fp()\fR return a valid \fBX509\fR structure or \fB\s-1NULL\s0\fR if an error occurs. The error code that can be obtained by \&\fIERR_get_error\fR\|(3). .PP \&\fIi2d_X509()\fR returns the number of bytes successfully encoded or a negative value if an error occurs. The error code can be obtained by \&\fIERR_get_error\fR\|(3). .PP \&\fIi2d_X509_bio()\fR and \fIi2d_X509_fp()\fR return 1 for success and 0 if an error occurs The error code can be obtained by \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" d2i_X509, i2d_X509, d2i_X509_bio, d2i_X509_fp, i2d_X509_bio and i2d_X509_fp are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/RAND.30000644000175000017500000001133312360020723016317 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RAND 3" .TH RAND 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" rand \- pseudo\-random number generator .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int RAND_bytes(unsigned char *buf, int num); \& int RAND_pseudo_bytes(unsigned char *buf, int num); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions give access to the systems cryptographically secure pseudo-random number generator (\s-1PRNG\s0). It is used by other library functions for example to generate random keys, and applications can use it when they need randomness. .PP \&\fIRAND_bytes\fR\|(3) describes how to obtain random data from the \&\s-1PRNG.\s0 .SH "INTERNALS" .IX Header "INTERNALS" The \fIRAND_SSLeay()\fR method implements a \s-1PRNG\s0 based on the systems' \&\fIarc4random_buf\fR\|(3) random number generator. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIBN_rand\fR\|(3), \&\fIRAND_bytes\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_DigestVerifyInit.30000644000175000017500000001643612360020717021551 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_DigestVerifyInit 3" .TH EVP_DigestVerifyInit 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_DigestVerifyInit, EVP_DigestVerifyUpdate, EVP_DigestVerifyFinal \- EVP signature verification functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, \& const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey); \& int EVP_DigestVerifyUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); \& int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, unsigned char *sig, size_t siglen); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \s-1EVP\s0 signature routines are a high level interface to digital signatures. .PP \&\fIEVP_DigestVerifyInit()\fR sets up verification context \fBctx\fR to use digest \&\fBtype\fR from \s-1ENGINE \s0\fBimpl\fR and public key \fBpkey\fR. \fBctx\fR must be initialized with \fIEVP_MD_CTX_init()\fR before calling this function. If \fBpctx\fR is not \s-1NULL\s0 the \&\s-1EVP_PKEY_CTX\s0 of the verification operation will be written to \fB*pctx\fR: this can be used to set alternative verification options. .PP \&\fIEVP_DigestVerifyUpdate()\fR hashes \fBcnt\fR bytes of data at \fBd\fR into the verification context \fBctx\fR. This function can be called several times on the same \fBctx\fR to include additional data. This function is currently implemented using a macro. .PP \&\fIEVP_DigestVerifyFinal()\fR verifies the data in \fBctx\fR against the signature in \&\fBsig\fR of length \fBsiglen\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_DigestVerifyInit()\fR and \fIEVP_DigestVerifyUpdate()\fR return 1 for success and 0 or a negative value for failure. In particular a return value of \-2 indicates the operation is not supported by the public key algorithm. .PP Unlike other functions the return value 0 from \fIEVP_DigestVerifyFinal()\fR only indicates that the signature did not not verify successfully (that is tbs did not match the original data or the signature was of invalid form) it is not an indication of a more serious error. .PP The error codes can be obtained from \fIERR_get_error\fR\|(3). .SH "NOTES" .IX Header "NOTES" The \fB\s-1EVP\s0\fR interface to digital signatures should almost always be used in preference to the low level interfaces. This is because the code then becomes transparent to the algorithm used and much more flexible. .PP In previous versions of OpenSSL there was a link between message digest types and public key algorithms. This meant that \*(L"clone\*(R" digests such as \fIEVP_dss1()\fR needed to be used to sign using \s-1SHA1\s0 and \s-1DSA.\s0 This is no longer necessary and the use of clone digest is now discouraged. .PP The call to \fIEVP_DigestVerifyFinal()\fR internally finalizes a copy of the digest context. This means that calls to \fIEVP_VerifyUpdate()\fR and \fIEVP_VerifyFinal()\fR can be called later to digest and verify additional data. .PP Since only a copy of the digest context is ever finalized the context must be cleaned up after use by calling \fIEVP_MD_CTX_cleanup()\fR or a memory leak will occur. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_DigestSignInit\fR\|(3), \&\fIEVP_DigestInit\fR\|(3), \fIerr\fR\|(3), \&\fIevp\fR\|(3), \fIhmac\fR\|(3), \fImd2\fR\|(3), \&\fImd5\fR\|(3), \fImdc2\fR\|(3), \fIripemd\fR\|(3), \&\fIsha\fR\|(3), \fIdgst\fR\|(1) .SH "HISTORY" .IX Header "HISTORY" \&\fIEVP_DigestVerifyInit()\fR, \fIEVP_DigestVerifyUpdate()\fR and \fIEVP_DigestVerifyFinal()\fR were first added to OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/RSA_sign.30000644000175000017500000001374512360020724017252 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RSA_sign 3" .TH RSA_sign 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RSA_sign, RSA_verify \- RSA signatures .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int RSA_sign(int type, const unsigned char *m, unsigned int m_len, \& unsigned char *sigret, unsigned int *siglen, RSA *rsa); \& \& int RSA_verify(int type, const unsigned char *m, unsigned int m_len, \& unsigned char *sigbuf, unsigned int siglen, RSA *rsa); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIRSA_sign()\fR signs the message digest \fBm\fR of size \fBm_len\fR using the private key \fBrsa\fR as specified in \s-1PKCS\s0 #1 v2.0. It stores the signature in \fBsigret\fR and the signature size in \fBsiglen\fR. \fBsigret\fR must point to RSA_size(\fBrsa\fR) bytes of memory. Note that \s-1PKCS\s0 #1 adds meta-data, placing limits on the size of the key that can be used. See \fIRSA_private_encrypt\fR\|(3) for lower-level operations. .PP \&\fBtype\fR denotes the message digest algorithm that was used to generate \&\fBm\fR. It usually is one of \fBNID_sha1\fR, \fBNID_ripemd160\fR and \fBNID_md5\fR; see \fIobjects\fR\|(3) for details. If \fBtype\fR is \fBNID_md5_sha1\fR, an \s-1SSL\s0 signature (\s-1MD5\s0 and \s-1SHA1\s0 message digests with \s-1PKCS\s0 #1 padding and no algorithm identifier) is created. .PP \&\fIRSA_verify()\fR verifies that the signature \fBsigbuf\fR of size \fBsiglen\fR matches a given message digest \fBm\fR of size \fBm_len\fR. \fBtype\fR denotes the message digest algorithm that was used to generate the signature. \&\fBrsa\fR is the signer's public key. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIRSA_sign()\fR returns 1 on success, 0 otherwise. \fIRSA_verify()\fR returns 1 on successful verification, 0 otherwise. .PP The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "CONFORMING TO" .IX Header "CONFORMING TO" \&\s-1SSL, PKCS\s0 #1 v2.0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fIobjects\fR\|(3), \&\fIrsa\fR\|(3), \fIRSA_private_encrypt\fR\|(3), \&\fIRSA_public_decrypt\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIRSA_sign()\fR and \fIRSA_verify()\fR are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/RAND_bytes.30000644000175000017500000001206612360020723017531 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RAND_bytes 3" .TH RAND_bytes 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RAND_bytes, RAND_pseudo_bytes \- generate random data .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int RAND_bytes(unsigned char *buf, int num); \& \& int RAND_pseudo_bytes(unsigned char *buf, int num); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIRAND_bytes()\fR puts \fBnum\fR cryptographically strong pseudo-random bytes into \fBbuf\fR. .PP \&\fIRAND_pseudo_bytes()\fR puts \fBnum\fR pseudo-random bytes into \fBbuf\fR. Pseudo-random byte sequences generated by \fIRAND_pseudo_bytes()\fR will be unique if they are of sufficient length, but are not necessarily unpredictable. They can be used for non-cryptographic purposes and for certain purposes in cryptographic protocols, but usually not for key generation etc. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIRAND_bytes()\fR returns 1. \&\fIRAND_pseudo_bytes()\fR returns 1. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIrand\fR\|(3), \fIERR_get_error\fR\|(3), \&\fIRAND_add\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIRAND_bytes()\fR is available in all versions of SSLeay and OpenSSL. It has a return value since OpenSSL 0.9.5. \fIRAND_pseudo_bytes()\fR was added in OpenSSL 0.9.5. deps/libressl-pnacl-sys-2.1.6/libressl/man/PEM_read_bio_PrivateKey.30000644000175000017500000006034712360020722022213 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PEM_read_bio_PrivateKey 3" .TH PEM_read_bio_PrivateKey 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PEM, PEM_read_bio_PrivateKey, PEM_read_PrivateKey, PEM_write_bio_PrivateKey, PEM_write_PrivateKey, PEM_write_bio_PKCS8PrivateKey, PEM_write_PKCS8PrivateKey, PEM_write_bio_PKCS8PrivateKey_nid, PEM_write_PKCS8PrivateKey_nid, PEM_read_bio_PUBKEY, PEM_read_PUBKEY, PEM_write_bio_PUBKEY, PEM_write_PUBKEY, PEM_read_bio_RSAPrivateKey, PEM_read_RSAPrivateKey, PEM_write_bio_RSAPrivateKey, PEM_write_RSAPrivateKey, PEM_read_bio_RSAPublicKey, PEM_read_RSAPublicKey, PEM_write_bio_RSAPublicKey, PEM_write_RSAPublicKey, PEM_read_bio_RSA_PUBKEY, PEM_read_RSA_PUBKEY, PEM_write_bio_RSA_PUBKEY, PEM_write_RSA_PUBKEY, PEM_read_bio_DSAPrivateKey, PEM_read_DSAPrivateKey, PEM_write_bio_DSAPrivateKey, PEM_write_DSAPrivateKey, PEM_read_bio_DSA_PUBKEY, PEM_read_DSA_PUBKEY, PEM_write_bio_DSA_PUBKEY, PEM_write_DSA_PUBKEY, PEM_read_bio_DSAparams, PEM_read_DSAparams, PEM_write_bio_DSAparams, PEM_write_DSAparams, PEM_read_bio_DHparams, PEM_read_DHparams, PEM_write_bio_DHparams, PEM_write_DHparams, PEM_read_bio_X509, PEM_read_X509, PEM_write_bio_X509, PEM_write_X509, PEM_read_bio_X509_AUX, PEM_read_X509_AUX, PEM_write_bio_X509_AUX, PEM_write_X509_AUX, PEM_read_bio_X509_REQ, PEM_read_X509_REQ, PEM_write_bio_X509_REQ, PEM_write_X509_REQ, PEM_write_bio_X509_REQ_NEW, PEM_write_X509_REQ_NEW, PEM_read_bio_X509_CRL, PEM_read_X509_CRL, PEM_write_bio_X509_CRL, PEM_write_X509_CRL, PEM_read_bio_PKCS7, PEM_read_PKCS7, PEM_write_bio_PKCS7, PEM_write_PKCS7, PEM_read_bio_NETSCAPE_CERT_SEQUENCE, PEM_read_NETSCAPE_CERT_SEQUENCE, PEM_write_bio_NETSCAPE_CERT_SEQUENCE, PEM_write_NETSCAPE_CERT_SEQUENCE \- PEM routines .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, \& pem_password_cb *cb, void *u); \& \& EVP_PKEY *PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x, \& pem_password_cb *cb, void *u); \& \& int PEM_write_bio_PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, \& unsigned char *kstr, int klen, \& pem_password_cb *cb, void *u); \& \& int PEM_write_PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, \& unsigned char *kstr, int klen, \& pem_password_cb *cb, void *u); \& \& int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, \& char *kstr, int klen, \& pem_password_cb *cb, void *u); \& \& int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, \& char *kstr, int klen, \& pem_password_cb *cb, void *u); \& \& int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, \& char *kstr, int klen, \& pem_password_cb *cb, void *u); \& \& int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, \& char *kstr, int klen, \& pem_password_cb *cb, void *u); \& \& EVP_PKEY *PEM_read_bio_PUBKEY(BIO *bp, EVP_PKEY **x, \& pem_password_cb *cb, void *u); \& \& EVP_PKEY *PEM_read_PUBKEY(FILE *fp, EVP_PKEY **x, \& pem_password_cb *cb, void *u); \& \& int PEM_write_bio_PUBKEY(BIO *bp, EVP_PKEY *x); \& int PEM_write_PUBKEY(FILE *fp, EVP_PKEY *x); \& \& RSA *PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **x, \& pem_password_cb *cb, void *u); \& \& RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **x, \& pem_password_cb *cb, void *u); \& \& int PEM_write_bio_RSAPrivateKey(BIO *bp, RSA *x, const EVP_CIPHER *enc, \& unsigned char *kstr, int klen, \& pem_password_cb *cb, void *u); \& \& int PEM_write_RSAPrivateKey(FILE *fp, RSA *x, const EVP_CIPHER *enc, \& unsigned char *kstr, int klen, \& pem_password_cb *cb, void *u); \& \& RSA *PEM_read_bio_RSAPublicKey(BIO *bp, RSA **x, \& pem_password_cb *cb, void *u); \& \& RSA *PEM_read_RSAPublicKey(FILE *fp, RSA **x, \& pem_password_cb *cb, void *u); \& \& int PEM_write_bio_RSAPublicKey(BIO *bp, RSA *x); \& \& int PEM_write_RSAPublicKey(FILE *fp, RSA *x); \& \& RSA *PEM_read_bio_RSA_PUBKEY(BIO *bp, RSA **x, \& pem_password_cb *cb, void *u); \& \& RSA *PEM_read_RSA_PUBKEY(FILE *fp, RSA **x, \& pem_password_cb *cb, void *u); \& \& int PEM_write_bio_RSA_PUBKEY(BIO *bp, RSA *x); \& \& int PEM_write_RSA_PUBKEY(FILE *fp, RSA *x); \& \& DSA *PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **x, \& pem_password_cb *cb, void *u); \& \& DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **x, \& pem_password_cb *cb, void *u); \& \& int PEM_write_bio_DSAPrivateKey(BIO *bp, DSA *x, const EVP_CIPHER *enc, \& unsigned char *kstr, int klen, \& pem_password_cb *cb, void *u); \& \& int PEM_write_DSAPrivateKey(FILE *fp, DSA *x, const EVP_CIPHER *enc, \& unsigned char *kstr, int klen, \& pem_password_cb *cb, void *u); \& \& DSA *PEM_read_bio_DSA_PUBKEY(BIO *bp, DSA **x, \& pem_password_cb *cb, void *u); \& \& DSA *PEM_read_DSA_PUBKEY(FILE *fp, DSA **x, \& pem_password_cb *cb, void *u); \& \& int PEM_write_bio_DSA_PUBKEY(BIO *bp, DSA *x); \& \& int PEM_write_DSA_PUBKEY(FILE *fp, DSA *x); \& \& DSA *PEM_read_bio_DSAparams(BIO *bp, DSA **x, pem_password_cb *cb, void *u); \& \& DSA *PEM_read_DSAparams(FILE *fp, DSA **x, pem_password_cb *cb, void *u); \& \& int PEM_write_bio_DSAparams(BIO *bp, DSA *x); \& \& int PEM_write_DSAparams(FILE *fp, DSA *x); \& \& DH *PEM_read_bio_DHparams(BIO *bp, DH **x, pem_password_cb *cb, void *u); \& \& DH *PEM_read_DHparams(FILE *fp, DH **x, pem_password_cb *cb, void *u); \& \& int PEM_write_bio_DHparams(BIO *bp, DH *x); \& \& int PEM_write_DHparams(FILE *fp, DH *x); \& \& X509 *PEM_read_bio_X509(BIO *bp, X509 **x, pem_password_cb *cb, void *u); \& \& X509 *PEM_read_X509(FILE *fp, X509 **x, pem_password_cb *cb, void *u); \& \& int PEM_write_bio_X509(BIO *bp, X509 *x); \& \& int PEM_write_X509(FILE *fp, X509 *x); \& \& X509 *PEM_read_bio_X509_AUX(BIO *bp, X509 **x, pem_password_cb *cb, void *u); \& \& X509 *PEM_read_X509_AUX(FILE *fp, X509 **x, pem_password_cb *cb, void *u); \& \& int PEM_write_bio_X509_AUX(BIO *bp, X509 *x); \& \& int PEM_write_X509_AUX(FILE *fp, X509 *x); \& \& X509_REQ *PEM_read_bio_X509_REQ(BIO *bp, X509_REQ **x, \& pem_password_cb *cb, void *u); \& \& X509_REQ *PEM_read_X509_REQ(FILE *fp, X509_REQ **x, \& pem_password_cb *cb, void *u); \& \& int PEM_write_bio_X509_REQ(BIO *bp, X509_REQ *x); \& \& int PEM_write_X509_REQ(FILE *fp, X509_REQ *x); \& \& int PEM_write_bio_X509_REQ_NEW(BIO *bp, X509_REQ *x); \& \& int PEM_write_X509_REQ_NEW(FILE *fp, X509_REQ *x); \& \& X509_CRL *PEM_read_bio_X509_CRL(BIO *bp, X509_CRL **x, \& pem_password_cb *cb, void *u); \& X509_CRL *PEM_read_X509_CRL(FILE *fp, X509_CRL **x, \& pem_password_cb *cb, void *u); \& int PEM_write_bio_X509_CRL(BIO *bp, X509_CRL *x); \& int PEM_write_X509_CRL(FILE *fp, X509_CRL *x); \& \& PKCS7 *PEM_read_bio_PKCS7(BIO *bp, PKCS7 **x, pem_password_cb *cb, void *u); \& \& PKCS7 *PEM_read_PKCS7(FILE *fp, PKCS7 **x, pem_password_cb *cb, void *u); \& \& int PEM_write_bio_PKCS7(BIO *bp, PKCS7 *x); \& \& int PEM_write_PKCS7(FILE *fp, PKCS7 *x); \& \& NETSCAPE_CERT_SEQUENCE *PEM_read_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp, \& NETSCAPE_CERT_SEQUENCE **x, \& pem_password_cb *cb, void *u); \& \& NETSCAPE_CERT_SEQUENCE *PEM_read_NETSCAPE_CERT_SEQUENCE(FILE *fp, \& NETSCAPE_CERT_SEQUENCE **x, \& pem_password_cb *cb, void *u); \& \& int PEM_write_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp, NETSCAPE_CERT_SEQUENCE *x); \& \& int PEM_write_NETSCAPE_CERT_SEQUENCE(FILE *fp, NETSCAPE_CERT_SEQUENCE *x); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \s-1PEM\s0 functions read or write structures in \s-1PEM\s0 format. In this sense \s-1PEM\s0 format is simply base64 encoded data surrounded by header lines. .PP For more details about the meaning of arguments see the \&\fB\s-1PEM FUNCTION ARGUMENTS\s0\fR section. .PP Each operation has four functions associated with it. For clarity the term "\fBfoobar\fR functions" will be used to collectively refer to the \fIPEM_read_bio_foobar()\fR, \fIPEM_read_foobar()\fR, \&\fIPEM_write_bio_foobar()\fR and \fIPEM_write_foobar()\fR functions. .PP The \fBPrivateKey\fR functions read or write a private key in \&\s-1PEM\s0 format using an \s-1EVP_PKEY\s0 structure. The write routines use \&\*(L"traditional\*(R" private key format and can handle both \s-1RSA\s0 and \s-1DSA\s0 private keys. The read functions can additionally transparently handle PKCS#8 format encrypted and unencrypted keys too. .PP \&\fIPEM_write_bio_PKCS8PrivateKey()\fR and \fIPEM_write_PKCS8PrivateKey()\fR write a private key in an \s-1EVP_PKEY\s0 structure in PKCS#8 EncryptedPrivateKeyInfo format using PKCS#5 v2.0 password based encryption algorithms. The \fBcipher\fR argument specifies the encryption algorithm to use: unlike all other \s-1PEM\s0 routines the encryption is applied at the PKCS#8 level and not in the \s-1PEM\s0 headers. If \fBcipher\fR is \s-1NULL\s0 then no encryption is used and a PKCS#8 PrivateKeyInfo structure is used instead. .PP \&\fIPEM_write_bio_PKCS8PrivateKey_nid()\fR and \fIPEM_write_PKCS8PrivateKey_nid()\fR also write out a private key as a PKCS#8 EncryptedPrivateKeyInfo however it uses PKCS#5 v1.5 or PKCS#12 encryption algorithms instead. The algorithm to use is specified in the \fBnid\fR parameter and should be the \s-1NID\s0 of the corresponding \s-1OBJECT IDENTIFIER \s0(see \s-1NOTES\s0 section). .PP The \fB\s-1PUBKEY\s0\fR functions process a public key using an \s-1EVP_PKEY\s0 structure. The public key is encoded as a SubjectPublicKeyInfo structure. .PP The \fBRSAPrivateKey\fR functions process an \s-1RSA\s0 private key using an \&\s-1RSA\s0 structure. It handles the same formats as the \fBPrivateKey\fR functions but an error occurs if the private key is not \s-1RSA.\s0 .PP The \fBRSAPublicKey\fR functions process an \s-1RSA\s0 public key using an \&\s-1RSA\s0 structure. The public key is encoded using a PKCS#1 RSAPublicKey structure. .PP The \fB\s-1RSA_PUBKEY\s0\fR functions also process an \s-1RSA\s0 public key using an \s-1RSA\s0 structure. However the public key is encoded using a SubjectPublicKeyInfo structure and an error occurs if the public key is not \s-1RSA.\s0 .PP The \fBDSAPrivateKey\fR functions process a \s-1DSA\s0 private key using a \&\s-1DSA\s0 structure. It handles the same formats as the \fBPrivateKey\fR functions but an error occurs if the private key is not \s-1DSA.\s0 .PP The \fB\s-1DSA_PUBKEY\s0\fR functions process a \s-1DSA\s0 public key using a \s-1DSA\s0 structure. The public key is encoded using a SubjectPublicKeyInfo structure and an error occurs if the public key is not \s-1DSA.\s0 .PP The \fBDSAparams\fR functions process \s-1DSA\s0 parameters using a \s-1DSA\s0 structure. The parameters are encoded using a foobar structure. .PP The \fBDHparams\fR functions process \s-1DH\s0 parameters using a \s-1DH\s0 structure. The parameters are encoded using a PKCS#3 DHparameter structure. .PP The \fBX509\fR functions process an X509 certificate using an X509 structure. They will also process a trusted X509 certificate but any trust settings are discarded. .PP The \fBX509_AUX\fR functions process a trusted X509 certificate using an X509 structure. .PP The \fBX509_REQ\fR and \fBX509_REQ_NEW\fR functions process a PKCS#10 certificate request using an X509_REQ structure. The \fBX509_REQ\fR write functions use \fB\s-1CERTIFICATE REQUEST\s0\fR in the header whereas the \fBX509_REQ_NEW\fR functions use \fB\s-1NEW CERTIFICATE REQUEST\s0\fR (as required by some CAs). The \fBX509_REQ\fR read functions will handle either form so there are no \fBX509_REQ_NEW\fR read functions. .PP The \fBX509_CRL\fR functions process an X509 \s-1CRL\s0 using an X509_CRL structure. .PP The \fB\s-1PKCS7\s0\fR functions process a PKCS#7 ContentInfo using a \s-1PKCS7\s0 structure. .PP The \fB\s-1NETSCAPE_CERT_SEQUENCE\s0\fR functions process a Netscape Certificate Sequence using a \s-1NETSCAPE_CERT_SEQUENCE\s0 structure. .SH "PEM FUNCTION ARGUMENTS" .IX Header "PEM FUNCTION ARGUMENTS" The \s-1PEM\s0 functions have many common arguments. .PP The \fBbp\fR \s-1BIO\s0 parameter (if present) specifies the \s-1BIO\s0 to read from or write to. .PP The \fBfp\fR \s-1FILE\s0 parameter (if present) specifies the \s-1FILE\s0 pointer to read from or write to. .PP The \s-1PEM\s0 read functions all take an argument \fB\s-1TYPE\s0 **x\fR and return a \fB\s-1TYPE\s0 *\fR pointer. Where \fB\s-1TYPE\s0\fR is whatever structure the function uses. If \fBx\fR is \s-1NULL\s0 then the parameter is ignored. If \fBx\fR is not \&\s-1NULL\s0 but \fB*x\fR is \s-1NULL\s0 then the structure returned will be written to \fB*x\fR. If neither \fBx\fR nor \fB*x\fR is \s-1NULL\s0 then an attempt is made to reuse the structure at \fB*x\fR (but see \s-1BUGS\s0 and \s-1EXAMPLES\s0 sections). Irrespective of the value of \fBx\fR a pointer to the structure is always returned (or \s-1NULL\s0 if an error occurred). .PP The \s-1PEM\s0 functions which write private keys take an \fBenc\fR parameter which specifies the encryption algorithm to use, encryption is done at the \s-1PEM\s0 level. If this parameter is set to \s-1NULL\s0 then the private key is written in unencrypted form. .PP The \fBcb\fR argument is the callback to use when querying for the pass phrase used for encrypted \s-1PEM\s0 structures (normally only private keys). .PP For the \s-1PEM\s0 write routines if the \fBkstr\fR parameter is not \s-1NULL\s0 then \&\fBklen\fR bytes at \fBkstr\fR are used as the passphrase and \fBcb\fR is ignored. .PP If the \fBcb\fR parameters is set to \s-1NULL\s0 and the \fBu\fR parameter is not \&\s-1NULL\s0 then the \fBu\fR parameter is interpreted as a null terminated string to use as the passphrase. If both \fBcb\fR and \fBu\fR are \s-1NULL\s0 then the default callback routine is used which will typically prompt for the passphrase on the current terminal with echoing turned off. .PP The default passphrase callback is sometimes inappropriate (for example in a \s-1GUI\s0 application) so an alternative can be supplied. The callback routine has the following form: .PP .Vb 1 \& int cb(char *buf, int size, int rwflag, void *u); .Ve .PP \&\fBbuf\fR is the buffer to write the passphrase to. \fBsize\fR is the maximum length of the passphrase (i.e. the size of buf). \fBrwflag\fR is a flag which is set to 0 when reading and 1 when writing. A typical routine will ask the user to verify the passphrase (for example by prompting for it twice) if \fBrwflag\fR is 1. The \fBu\fR parameter has the same value as the \fBu\fR parameter passed to the \s-1PEM\s0 routine. It allows arbitrary data to be passed to the callback by the application (for example a window handle in a \s-1GUI\s0 application). The callback \&\fBmust\fR return the number of characters in the passphrase or 0 if an error occurred. .SH "EXAMPLES" .IX Header "EXAMPLES" Although the \s-1PEM\s0 routines take several arguments in almost all applications most of them are set to 0 or \s-1NULL.\s0 .PP Read a certificate in \s-1PEM\s0 format from a \s-1BIO:\s0 .PP .Vb 5 \& X509 *x; \& x = PEM_read_bio_X509(bp, NULL, 0, NULL); \& if (x == NULL) { \& /* Error */ \& } .Ve .PP Alternative method: .PP .Vb 4 \& X509 *x = NULL; \& if (!PEM_read_bio_X509(bp, &x, 0, NULL)) { \& /* Error */ \& } .Ve .PP Write a certificate to a \s-1BIO:\s0 .PP .Vb 3 \& if (!PEM_write_bio_X509(bp, x)) { \& /* Error */ \& } .Ve .PP Write an unencrypted private key to a \s-1FILE\s0 pointer: .PP .Vb 3 \& if (!PEM_write_PrivateKey(fp, key, NULL, NULL, 0, 0, NULL)) { \& /* Error */ \& } .Ve .PP Write a private key (using traditional format) to a \s-1BIO\s0 using triple \s-1DES\s0 encryption, the pass phrase is prompted for: .PP .Vb 4 \& if (!PEM_write_bio_PrivateKey(bp, key, EVP_des_ede3_cbc(), \& NULL, 0, 0, NULL)) { \& /* Error */ \& } .Ve .PP Write a private key (using PKCS#8 format) to a \s-1BIO\s0 using triple \&\s-1DES\s0 encryption, using the pass phrase \*(L"hello\*(R": .PP .Vb 4 \& if (!PEM_write_bio_PKCS8PrivateKey(bp, key, EVP_des_ede3_cbc(), \& NULL, 0, 0, "hello")) { \& /* Error */ \& } .Ve .PP Read a private key from a \s-1BIO\s0 using the pass phrase \*(L"hello\*(R": .PP .Vb 4 \& key = PEM_read_bio_PrivateKey(bp, NULL, 0, "hello"); \& if (key == NULL) { \& /* Error */ \& } .Ve .PP Read a private key from a \s-1BIO\s0 using a pass phrase callback: .PP .Vb 4 \& key = PEM_read_bio_PrivateKey(bp, NULL, pass_cb, "My Private Key"); \& if (key == NULL) { \& /* Error */ \& } .Ve .PP Skeleton pass phrase callback: .PP .Vb 5 \& int \& pass_cb(char *buf, int size, int rwflag, void *u) \& { \& int len; \& char *tmp; \& \& /* We\*(Aqd probably do something else if \*(Aqrwflag\*(Aq is 1 */ \& printf("Enter pass phrase for \e"%s\e"\en", u); \& \& /* get pass phrase, length \*(Aqlen\*(Aq into \*(Aqtmp\*(Aq */ \& tmp = "hello"; \& len = strlen(tmp); \& \& if (len == 0) \& return 0; \& /* if too long, truncate */ \& if (len > size) \& len = size; \& memcpy(buf, tmp, len); \& return len; \& } .Ve .SH "NOTES" .IX Header "NOTES" The old \fBPrivateKey\fR write routines are retained for compatibility. New applications should write private keys using the \&\fIPEM_write_bio_PKCS8PrivateKey()\fR or \fIPEM_write_PKCS8PrivateKey()\fR routines because they are more secure (they use an iteration count of 2048 whereas the traditional routines use a count of 1) unless compatibility with older versions of OpenSSL is important. .PP The \fBPrivateKey\fR read routines can be used in all applications because they handle all formats transparently. .PP A frequent cause of problems is attempting to use the \s-1PEM\s0 routines like this: .PP .Vb 2 \& X509 *x; \& PEM_read_bio_X509(bp, &x, 0, NULL); .Ve .PP this is a bug because an attempt will be made to reuse the data at \fBx\fR which is an uninitialised pointer. .SH "PEM ENCRYPTION FORMAT" .IX Header "PEM ENCRYPTION FORMAT" This old \fBPrivateKey\fR routines use a non standard technique for encryption. .PP The private key (or other data) takes the following form: .PP .Vb 3 \& \-\-\-\-\-BEGIN RSA PRIVATE KEY\-\-\-\-\- \& Proc\-Type: 4,ENCRYPTED \& DEK\-Info: DES\-EDE3\-CBC,3F17F5316E2BAC89 \& \& ...base64 encoded data... \& \-\-\-\-\-END RSA PRIVATE KEY\-\-\-\-\- .Ve .PP The line beginning DEK-Info contains two comma separated pieces of information: the encryption algorithm name as used by \fIEVP_get_cipherbyname()\fR and an 8 byte \fBsalt\fR encoded as a set of hexadecimal digits. .PP After this is the base64 encoded encrypted data. .PP The encryption key is determined using \fIEVP_bytestokey()\fR, using \fBsalt\fR and an iteration count of 1. The \s-1IV\s0 used is the value of \fBsalt\fR and *not* the \s-1IV\s0 returned by \fIEVP_bytestokey()\fR. .SH "BUGS" .IX Header "BUGS" The \s-1PEM\s0 read routines in some versions of OpenSSL will not correctly reuse an existing structure. Therefore the following: .PP .Vb 1 \& PEM_read_bio_X509(bp, &x, 0, NULL); .Ve .PP where \fBx\fR already contains a valid certificate, may not work, whereas: .PP .Vb 2 \& X509_free(x); \& x = PEM_read_bio_X509(bp, NULL, 0, NULL); .Ve .PP is guaranteed to work. .SH "RETURN CODES" .IX Header "RETURN CODES" The read routines return either a pointer to the structure read or \s-1NULL\s0 if an error occurred. .PP The write routines return 1 for success or 0 for failure. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_get_peer_certificate.30000644000175000017500000001272212360020735022456 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_get_peer_certificate 3" .TH SSL_get_peer_certificate 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_get_peer_certificate \- get the X509 certificate of the peer .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& X509 *SSL_get_peer_certificate(const SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_get_peer_certificate()\fR returns a pointer to the X509 certificate the peer presented. If the peer did not present a certificate, \s-1NULL\s0 is returned. .SH "NOTES" .IX Header "NOTES" Due to the protocol definition, a \s-1TLS/SSL\s0 server will always send a certificate, if present. A client will only send a certificate when explicitly requested to do so by the server (see \&\fISSL_CTX_set_verify\fR\|(3)). If an anonymous cipher is used, no certificates are sent. .PP That a certificate is returned does not indicate information about the verification state, use \fISSL_get_verify_result\fR\|(3) to check the verification state. .PP The reference count of the X509 object is incremented by one, so that it will not be destroyed when the session containing the peer certificate is freed. The X509 object must be explicitly freed using \fIX509_free()\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .IP "\s-1NULL\s0" 4 .IX Item "NULL" No certificate was presented by the peer or no connection was established. .IP "Pointer to an X509 certificate" 4 .IX Item "Pointer to an X509 certificate" The return value points to the certificate presented by the peer. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_get_verify_result\fR\|(3), \&\fISSL_CTX_set_verify\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/dh.30000644000175000017500000001506212360020727016175 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "dh 3" .TH dh 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" dh \- Diffie\-Hellman key agreement .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& DH * DH_new(void); \& void DH_free(DH *dh); \& \& int DH_size(const DH *dh); \& \& DH * DH_generate_parameters(int prime_len, int generator, \& void (*callback)(int, int, void *), void *cb_arg); \& int DH_check(const DH *dh, int *codes); \& \& int DH_generate_key(DH *dh); \& int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh); \& \& void DH_set_default_method(const DH_METHOD *meth); \& const DH_METHOD *DH_get_default_method(void); \& int DH_set_method(DH *dh, const DH_METHOD *meth); \& DH *DH_new_method(ENGINE *engine); \& const DH_METHOD *DH_OpenSSL(void); \& \& int DH_get_ex_new_index(long argl, char *argp, int (*new_func)(), \& int (*dup_func)(), void (*free_func)()); \& int DH_set_ex_data(DH *d, int idx, char *arg); \& char *DH_get_ex_data(DH *d, int idx); \& \& DH * d2i_DHparams(DH **a, unsigned char **pp, long length); \& int i2d_DHparams(const DH *a, unsigned char **pp); \& \& int DHparams_print_fp(FILE *fp, const DH *x); \& int DHparams_print(BIO *bp, const DH *x); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions implement the Diffie-Hellman key agreement protocol. The generation of shared \s-1DH\s0 parameters is described in \&\fIDH_generate_parameters\fR\|(3); \&\fIDH_generate_key\fR\|(3) describes how to perform a key agreement. .PP The \fB\s-1DH\s0\fR structure consists of several \s-1BIGNUM\s0 components. .PP .Vb 9 \& struct \& { \& BIGNUM *p; // prime number (shared) \& BIGNUM *g; // generator of Z_p (shared) \& BIGNUM *priv_key; // private DH value x \& BIGNUM *pub_key; // public DH value g^x \& // ... \& }; \& DH .Ve .PP Note that \s-1DH\s0 keys may use non-standard \fB\s-1DH_METHOD\s0\fR implementations, either directly or by the use of \fB\s-1ENGINE\s0\fR modules. In some cases (eg. an \&\s-1ENGINE\s0 providing support for hardware-embedded keys), these \s-1BIGNUM\s0 values will not be used by the implementation or may be used for alternative data storage. For this reason, applications should generally avoid using \s-1DH\s0 structure elements directly and instead use \s-1API\s0 functions to query or modify keys. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdhparam\fR\|(1), \fIbn\fR\|(3), \fIdsa\fR\|(3), \fIerr\fR\|(3), \&\fIrand\fR\|(3), \fIrsa\fR\|(3), \fIengine\fR\|(3), \&\fIDH_set_method\fR\|(3), \fIDH_new\fR\|(3), \&\fIDH_get_ex_new_index\fR\|(3), \&\fIDH_generate_parameters\fR\|(3), \&\fIDH_compute_key\fR\|(3), \fId2i_DHparams\fR\|(3), \&\fIRSA_print\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_new.30000644000175000017500000001262312360020712016744 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_new 3" .TH BN_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_new, BN_init, BN_clear, BN_free, BN_clear_free \- allocate and free BIGNUMs .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIGNUM *BN_new(void); \& \& void BN_init(BIGNUM *); \& \& void BN_clear(BIGNUM *a); \& \& void BN_free(BIGNUM *a); \& \& void BN_clear_free(BIGNUM *a); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBN_new()\fR allocates and initializes a \fB\s-1BIGNUM\s0\fR structure. \fIBN_init()\fR initializes an existing uninitialized \fB\s-1BIGNUM\s0\fR. .PP \&\fIBN_clear()\fR is used to destroy sensitive data such as keys when they are no longer needed. It erases the memory used by \fBa\fR and sets it to the value 0. .PP \&\fIBN_free()\fR frees the components of the \fB\s-1BIGNUM\s0\fR, and if it was created by \fIBN_new()\fR, also the structure itself. \fIBN_clear_free()\fR additionally overwrites the data before the memory is returned to the system. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBN_new()\fR returns a pointer to the \fB\s-1BIGNUM\s0\fR. If the allocation fails, it returns \fB\s-1NULL\s0\fR and sets an error code that can be obtained by \fIERR_get_error\fR\|(3). .PP \&\fIBN_init()\fR, \fIBN_clear()\fR, \fIBN_free()\fR and \fIBN_clear_free()\fR have no return values. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3), \fIERR_get_error\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIBN_new()\fR, \fIBN_clear()\fR, \fIBN_free()\fR and \fIBN_clear_free()\fR are available in all versions on SSLeay and OpenSSL. \fIBN_init()\fR was added in SSLeay 0.9.1b. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_free.30000644000175000017500000001261112360020734017237 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_free 3" .TH SSL_free 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_free \- free an allocated SSL structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_free(SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_free()\fR decrements the reference count of \fBssl\fR, and removes the \s-1SSL\s0 structure pointed to by \fBssl\fR and frees up the allocated memory if the reference count has reached 0. .SH "NOTES" .IX Header "NOTES" \&\fISSL_free()\fR also calls the \fIfree()\fRing procedures for indirectly affected items, if applicable: the buffering \s-1BIO,\s0 the read and write BIOs, cipher lists specially created for this \fBssl\fR, the \fB\s-1SSL_SESSION\s0\fR. Do not explicitly free these indirectly freed up items before or after calling \fISSL_free()\fR, as trying to free things twice may lead to program failure. .PP The ssl session has reference counts from two users: the \s-1SSL\s0 object, for which the reference count is removed by \fISSL_free()\fR and the internal session cache. If the session is considered bad, because \&\fISSL_shutdown\fR\|(3) was not called for the connection and \fISSL_set_shutdown\fR\|(3) was not used to set the \&\s-1SSL_SENT_SHUTDOWN\s0 state, the session will also be removed from the session cache as required by \s-1RFC2246.\s0 .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_free()\fR does not provide diagnostic information. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_new\fR\|(3), \fISSL_clear\fR\|(3), \&\fISSL_shutdown\fR\|(3), \fISSL_set_shutdown\fR\|(3), \&\fIssl\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_s_accept.30000644000175000017500000002710612360020710020046 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_s_accept 3" .TH BIO_s_accept 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_s_accept, BIO_set_accept_port, BIO_get_accept_port, BIO_new_accept, BIO_set_nbio_accept, BIO_set_accept_bios, BIO_set_bind_mode, BIO_get_bind_mode, BIO_do_accept \- accept BIO .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIO_METHOD *BIO_s_accept(void); \& \& long BIO_set_accept_port(BIO *b, char *name); \& char *BIO_get_accept_port(BIO *b); \& \& BIO *BIO_new_accept(char *host_port); \& \& long BIO_set_nbio_accept(BIO *b, int n); \& long BIO_set_accept_bios(BIO *b, char *bio); \& \& long BIO_set_bind_mode(BIO *b, long mode); \& long BIO_get_bind_mode(BIO *b, long dummy); \& \& #define BIO_BIND_NORMAL 0 \& #define BIO_BIND_REUSEADDR_IF_UNUSED 1 \& #define BIO_BIND_REUSEADDR 2 \& \& int BIO_do_accept(BIO *b); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_s_accept()\fR returns the accept \s-1BIO\s0 method. This is a wrapper round the platform's \s-1TCP/IP\s0 socket accept routines. .PP Using accept BIOs, \s-1TCP/IP\s0 connections can be accepted and data transferred using only \s-1BIO\s0 routines. In this way any platform specific operations are hidden by the \s-1BIO\s0 abstraction. .PP Read and write operations on an accept \s-1BIO\s0 will perform I/O on the underlying connection. If no connection is established and the port (see below) is set up properly then the \s-1BIO\s0 waits for an incoming connection. .PP Accept BIOs support \fIBIO_puts()\fR but not \fIBIO_gets()\fR. .PP If the close flag is set on an accept \s-1BIO\s0 then any active connection on that chain is shutdown and the socket closed when the \s-1BIO\s0 is freed. .PP Calling \fIBIO_reset()\fR on a accept \s-1BIO\s0 will close any active connection and reset the \s-1BIO\s0 into a state where it awaits another incoming connection. .PP \&\fIBIO_get_fd()\fR and \fIBIO_set_fd()\fR can be called to retrieve or set the accept socket. See \fIBIO_s_fd\fR\|(3) .PP \&\fIBIO_set_accept_port()\fR uses the string \fBname\fR to set the accept port. The port is represented as a string of the form \*(L"host:port\*(R", where \*(L"host\*(R" is the interface to use and \*(L"port\*(R" is the port. Either or both values can be \*(L"*\*(R" which is interpreted as meaning any interface or port respectively. \*(L"port\*(R" has the same syntax as the port specified in \fIBIO_set_conn_port()\fR for connect BIOs, that is it can be a numerical port string or a string to lookup using \fIgetservbyname()\fR and a string table. .PP \&\fIBIO_new_accept()\fR combines \fIBIO_new()\fR and \fIBIO_set_accept_port()\fR into a single call: that is it creates a new accept \s-1BIO\s0 with port \&\fBhost_port\fR. .PP \&\fIBIO_set_nbio_accept()\fR sets the accept socket to blocking mode (the default) if \fBn\fR is 0 or non blocking mode if \fBn\fR is 1. .PP \&\fIBIO_set_accept_bios()\fR can be used to set a chain of BIOs which will be duplicated and prepended to the chain when an incoming connection is received. This is useful if, for example, a buffering or \s-1SSL BIO\s0 is required for each connection. The chain of BIOs must not be freed after this call, they will be automatically freed when the accept \s-1BIO\s0 is freed. .PP \&\fIBIO_set_bind_mode()\fR and \fIBIO_get_bind_mode()\fR set and retrieve the current bind mode. If \s-1BIO_BIND_NORMAL \s0(the default) is set then another socket cannot be bound to the same port. If \&\s-1BIO_BIND_REUSEADDR\s0 is set then other sockets can bind to the same port. If \s-1BIO_BIND_REUSEADDR_IF_UNUSED\s0 is set then and attempt is first made to use \s-1BIO_BIN_NORMAL,\s0 if this fails and the port is not in use then a second attempt is made using \s-1BIO_BIND_REUSEADDR.\s0 .PP \&\fIBIO_do_accept()\fR serves two functions. When it is first called, after the accept \s-1BIO\s0 has been setup, it will attempt to create the accept socket and bind an address to it. Second and subsequent calls to \fIBIO_do_accept()\fR will await an incoming connection, or request a retry in non blocking mode. .SH "NOTES" .IX Header "NOTES" When an accept \s-1BIO\s0 is at the end of a chain it will await an incoming connection before processing I/O calls. When an accept \&\s-1BIO\s0 is not at then end of a chain it passes I/O calls to the next \&\s-1BIO\s0 in the chain. .PP When a connection is established a new socket \s-1BIO\s0 is created for the connection and appended to the chain. That is the chain is now accept\->socket. This effectively means that attempting I/O on an initial accept socket will await an incoming connection then perform I/O on it. .PP If any additional BIOs have been set using \fIBIO_set_accept_bios()\fR then they are placed between the socket and the accept \s-1BIO,\s0 that is the chain will be accept\->otherbios\->socket. .PP If a server wishes to process multiple connections (as is normally the case) then the accept \s-1BIO\s0 must be made available for further incoming connections. This can be done by waiting for a connection and then calling: .PP .Vb 1 \& connection = BIO_pop(accept); .Ve .PP After this call \fBconnection\fR will contain a \s-1BIO\s0 for the recently established connection and \fBaccept\fR will now be a single \s-1BIO\s0 again which can be used to await further incoming connections. If no further connections will be accepted the \fBaccept\fR can be freed using \fIBIO_free()\fR. .PP If only a single connection will be processed it is possible to perform I/O using the accept \s-1BIO\s0 itself. This is often undesirable however because the accept \s-1BIO\s0 will still accept additional incoming connections. This can be resolved by using \fIBIO_pop()\fR (see above) and freeing up the accept \s-1BIO\s0 after the initial connection. .PP If the underlying accept socket is non-blocking and \fIBIO_do_accept()\fR is called to await an incoming connection it is possible for \&\fIBIO_should_io_special()\fR with the reason \s-1BIO_RR_ACCEPT.\s0 If this happens then it is an indication that an accept attempt would block: the application should take appropriate action to wait until the underlying socket has accepted a connection and retry the call. .PP \&\fIBIO_set_accept_port()\fR, \fIBIO_get_accept_port()\fR, \fIBIO_set_nbio_accept()\fR, \&\fIBIO_set_accept_bios()\fR, \fIBIO_set_bind_mode()\fR, \fIBIO_get_bind_mode()\fR and \&\fIBIO_do_accept()\fR are macros. .SH "EXAMPLE" .IX Header "EXAMPLE" This example accepts two connections on port 4444, sends messages down each and finally closes both down. .PP .Vb 3 \& BIO *abio, *cbio, *cbio2; \& ERR_load_crypto_strings(); \& abio = BIO_new_accept("4444"); \& \& /* First call to BIO_accept() sets up accept BIO */ \& if (BIO_do_accept(abio) <= 0) { \& fprintf(stderr, "Error setting up accept\en"); \& ERR_print_errors_fp(stderr); \& exit(0); \& } \& \& /* Wait for incoming connection */ \& if (BIO_do_accept(abio) <= 0) { \& fprintf(stderr, "Error accepting connection\en"); \& ERR_print_errors_fp(stderr); \& exit(0); \& } \& fprintf(stderr, "Connection 1 established\en"); \& /* Retrieve BIO for connection */ \& cbio = BIO_pop(abio); \& BIO_puts(cbio, "Connection 1: Sending out Data on initial connection\en"); \& fprintf(stderr, "Sent out data on connection 1\en"); \& /* Wait for another connection */ \& if (BIO_do_accept(abio) <= 0) { \& fprintf(stderr, "Error accepting connection\en"); \& ERR_print_errors_fp(stderr); \& exit(0); \& } \& fprintf(stderr, "Connection 2 established\en"); \& /* Close accept BIO to refuse further connections */ \& cbio2 = BIO_pop(abio); \& BIO_free(abio); \& BIO_puts(cbio2, "Connection 2: Sending out Data on second\en"); \& fprintf(stderr, "Sent out data on connection 2\en"); \& \& BIO_puts(cbio, "Connection 1: Second connection established\en"); \& /* Close the two established connections */ \& BIO_free(cbio); \& BIO_free(cbio2); .Ve deps/libressl-pnacl-sys-2.1.6/libressl/man/ASN1_STRING_print_ex.30000644000175000017500000002005512360020707021276 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ASN1_STRING_print_ex 3" .TH ASN1_STRING_print_ex 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ASN1_STRING_print_ex, ASN1_STRING_print_ex_fp, ASN1_STRING_print \- ASN1_STRING output routines. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags); \& int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags); \& int ASN1_STRING_print(BIO *out, ASN1_STRING *str); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions output an \fB\s-1ASN1_STRING\s0\fR structure. \fB\s-1ASN1_STRING\s0\fR is used to represent all the \s-1ASN1\s0 string types. .PP \&\fIASN1_STRING_print_ex()\fR outputs \fBstr\fR to \fBout\fR, the format is determined by the options \fBflags\fR. \fIASN1_STRING_print_ex_fp()\fR is identical except it outputs to \fBfp\fR instead. .PP \&\fIASN1_STRING_print()\fR prints \fBstr\fR to \fBout\fR but using a different format to \&\fIASN1_STRING_print_ex()\fR. It replaces unprintable characters (other than \s-1CR, LF\s0) with '.'. .SH "NOTES" .IX Header "NOTES" \&\fIASN1_STRING_print()\fR is a legacy function which should be avoided in new applications. .PP Although there are a large number of options frequently \fB\s-1ASN1_STRFLGS_RFC2253\s0\fR is suitable, or on \s-1UTF8\s0 terminals \fB\s-1ASN1_STRFLGS_RFC2253 &\s0 ~ASN1_STRFLGS_ESC_MSB\fR. .PP The complete set of supported options for \fBflags\fR is listed below. .PP Various characters can be escaped. If \fB\s-1ASN1_STRFLGS_ESC_2253\s0\fR is set the characters determined by \s-1RFC2253\s0 are escaped. If \fB\s-1ASN1_STRFLGS_ESC_CTRL\s0\fR is set control characters are escaped. If \fB\s-1ASN1_STRFLGS_ESC_MSB\s0\fR is set characters with the \s-1MSB\s0 set are escaped: this option should \fBnot\fR be used if the terminal correctly interprets \s-1UTF8\s0 sequences. .PP Escaping takes several forms. .PP If the character being escaped is a 16 bit character then the form \*(L"\eUXXXX\*(R" is used using exactly four characters for the hex representation. If it is 32 bits then \*(L"\eWXXXXXXXX\*(R" is used using eight characters of its hex representation. These forms will only be used if \s-1UTF8\s0 conversion is not set (see below). .PP Printable characters are normally escaped using the backslash '\e' character. If \&\fB\s-1ASN1_STRFLGS_ESC_QUOTE\s0\fR is set then the whole string is instead surrounded by double quote characters: this is arguably more readable than the backslash notation. Other characters use the \*(L"\eXX\*(R" using exactly two characters of the hex representation. .PP If \fB\s-1ASN1_STRFLGS_UTF8_CONVERT\s0\fR is set then characters are converted to \s-1UTF8\s0 format first. If the terminal supports the display of \s-1UTF8\s0 sequences then this option will correctly display multi byte characters. .PP If \fB\s-1ASN1_STRFLGS_IGNORE_TYPE\s0\fR is set then the string type is not interpreted at all: everything is assumed to be one byte per character. This is primarily for debugging purposes and can result in confusing output in multi character strings. .PP If \fB\s-1ASN1_STRFLGS_SHOW_TYPE\s0\fR is set then the string type itself is printed out before its value (for example \*(L"\s-1BMPSTRING\*(R"\s0), this actually uses \fIASN1_tag2str()\fR. .PP The content of a string instead of being interpreted can be \*(L"dumped\*(R": this just outputs the value of the string using the form #XXXX using hex format for each octet. .PP If \fB\s-1ASN1_STRFLGS_DUMP_ALL\s0\fR is set then any type is dumped. .PP Normally non character string types (such as \s-1OCTET STRING\s0) are assumed to be one byte per character, if \fB\s-1ASN1_STRFLGS_DUMP_UNKNOWN\s0\fR is set then they will be dumped instead. .PP When a type is dumped normally just the content octets are printed, if \&\fB\s-1ASN1_STRFLGS_DUMP_DER\s0\fR is set then the complete encoding is dumped instead (including tag and length octets). .PP \&\fB\s-1ASN1_STRFLGS_RFC2253\s0\fR includes all the flags required by \s-1RFC2253.\s0 It is equivalent to: \s-1ASN1_STRFLGS_ESC_2253\s0 | \s-1ASN1_STRFLGS_ESC_CTRL\s0 | \s-1ASN1_STRFLGS_ESC_MSB\s0 | \s-1ASN1_STRFLGS_UTF8_CONVERT\s0 | \s-1ASN1_STRFLGS_DUMP_UNKNOWN ASN1_STRFLGS_DUMP_DER\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIX509_NAME_print_ex\fR\|(3), \&\fIASN1_tag2str\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/passwd.10000644000175000017500000001366712360020742017107 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "passwd 1" .TH passwd 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" passwd \- compute password hashes .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl passwd\fR [\fB\-crypt\fR] [\fB\-1\fR] [\fB\-apr1\fR] [\fB\-salt\fR \fIstring\fR] [\fB\-in\fR \fIfile\fR] [\fB\-stdin\fR] [\fB\-noverify\fR] [\fB\-quiet\fR] [\fB\-table\fR] {\fIpassword\fR} .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBpasswd\fR command computes the hash of a password typed at run-time or the hash of each password in a list. The password list is taken from the named file for option \fB\-in file\fR, from stdin for option \fB\-stdin\fR, or from the command line, or from the terminal otherwise. The Unix standard algorithm \fBcrypt\fR and the MD5\-based \s-1BSD\s0 password algorithm \fB1\fR and its Apache variant \fBapr1\fR are available. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-crypt\fR" 4 .IX Item "-crypt" Use the \fBcrypt\fR algorithm (default). .IP "\fB\-1\fR" 4 .IX Item "-1" Use the \s-1MD5\s0 based \s-1BSD\s0 password algorithm \fB1\fR. .IP "\fB\-apr1\fR" 4 .IX Item "-apr1" Use the \fBapr1\fR algorithm (Apache variant of the \s-1BSD\s0 algorithm). .IP "\fB\-salt\fR \fIstring\fR" 4 .IX Item "-salt string" Use the specified salt. When reading a password from the terminal, this implies \fB\-noverify\fR. .IP "\fB\-in\fR \fIfile\fR" 4 .IX Item "-in file" Read passwords from \fIfile\fR. .IP "\fB\-stdin\fR" 4 .IX Item "-stdin" Read passwords from \fBstdin\fR. .IP "\fB\-noverify\fR" 4 .IX Item "-noverify" Don't verify when reading a password from the terminal. .IP "\fB\-quiet\fR" 4 .IX Item "-quiet" Don't output warnings when passwords given at the command line are truncated. .IP "\fB\-table\fR" 4 .IX Item "-table" In the output list, prepend the cleartext password and a \s-1TAB\s0 character to each password hash. .SH "EXAMPLES" .IX Header "EXAMPLES" \&\fBopenssl passwd \-crypt \-salt xx password\fR prints \fBxxj31ZMTZzkVA\fR. .PP \&\fBopenssl passwd \-1 \-salt xxxxxxxx password\fR prints \fB\f(CB$1\fB$xxxxxxxx$UYCIxa628.9qXjpQCjM4a.\fR. .PP \&\fBopenssl passwd \-apr1 \-salt xxxxxxxx password\fR prints \fB\f(CB$apr1\fB$xxxxxxxx$dxHfLAsjHkDRmG83UXe8K0\fR. deps/libressl-pnacl-sys-2.1.6/libressl/man/RSA_print.30000644000175000017500000001244612360020724017443 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RSA_print 3" .TH RSA_print 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RSA_print, RSA_print_fp, DSAparams_print, DSAparams_print_fp, DSA_print, DSA_print_fp, DHparams_print, DHparams_print_fp \- print cryptographic parameters .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int RSA_print(BIO *bp, RSA *x, int offset); \& int RSA_print_fp(FILE *fp, RSA *x, int offset); \& \& #include \& \& int DSAparams_print(BIO *bp, DSA *x); \& int DSAparams_print_fp(FILE *fp, DSA *x); \& int DSA_print(BIO *bp, DSA *x, int offset); \& int DSA_print_fp(FILE *fp, DSA *x, int offset); \& \& #include \& \& int DHparams_print(BIO *bp, DH *x); \& int DHparams_print_fp(FILE *fp, DH *x); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" A human-readable hexadecimal output of the components of the \s-1RSA\s0 key, \s-1DSA\s0 parameters or key or \s-1DH\s0 parameters is printed to \fBbp\fR or \fBfp\fR. .PP The output lines are indented by \fBoffset\fR spaces. .SH "RETURN VALUES" .IX Header "RETURN VALUES" These functions return 1 on success, 0 on error. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdh\fR\|(3), \fIdsa\fR\|(3), \fIrsa\fR\|(3), \fIBN_bn2bin\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIRSA_print()\fR, \fIRSA_print_fp()\fR, \fIDSA_print()\fR, \fIDSA_print_fp()\fR, \fIDH_print()\fR, \&\fIDH_print_fp()\fR are available in all versions of SSLeay and OpenSSL. \&\fIDSAparams_print()\fR and \fIDSAparams_print_fp()\fR were added in SSLeay 0.8. deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_CTX_start.30000644000175000017500000001314112360020711020021 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_CTX_start 3" .TH BN_CTX_start 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_CTX_start, BN_CTX_get, BN_CTX_end \- use temporary BIGNUM variables .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void BN_CTX_start(BN_CTX *ctx); \& \& BIGNUM *BN_CTX_get(BN_CTX *ctx); \& \& void BN_CTX_end(BN_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions are used to obtain temporary \fB\s-1BIGNUM\s0\fR variables from a \fB\s-1BN_CTX\s0\fR (which can been created by using \fIBN_CTX_new\fR\|(3)) in order to save the overhead of repeatedly creating and freeing \fB\s-1BIGNUM\s0\fRs in functions that are called from inside a loop. .PP A function must call \fIBN_CTX_start()\fR first. Then, \fIBN_CTX_get()\fR may be called repeatedly to obtain temporary \fB\s-1BIGNUM\s0\fRs. All \fIBN_CTX_get()\fR calls must be made before calling any other functions that use the \&\fBctx\fR as an argument. .PP Finally, \fIBN_CTX_end()\fR must be called before returning from the function. When \fIBN_CTX_end()\fR is called, the \fB\s-1BIGNUM\s0\fR pointers obtained from \&\fIBN_CTX_get()\fR become invalid. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBN_CTX_start()\fR and \fIBN_CTX_end()\fR return no values. .PP \&\fIBN_CTX_get()\fR returns a pointer to the \fB\s-1BIGNUM\s0\fR, or \fB\s-1NULL\s0\fR on error. Once \fIBN_CTX_get()\fR has failed, the subsequent calls will return \fB\s-1NULL\s0\fR as well, so it is sufficient to check the return value of the last \&\fIBN_CTX_get()\fR call. In case of an error, an error code is set, which can be obtained by \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIBN_CTX_new\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIBN_CTX_start()\fR, \fIBN_CTX_get()\fR and \fIBN_CTX_end()\fR were added in OpenSSL 0.9.5. deps/libressl-pnacl-sys-2.1.6/libressl/man/MD5.30000644000175000017500000001655012360020721016164 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "MD5 3" .TH MD5 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" MD2, MD4, MD5, MD2_Init, MD2_Update, MD2_Final, MD4_Init, MD4_Update, MD4_Final, MD5_Init, MD5_Update, MD5_Final \- MD2, MD4, and MD5 hash functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& unsigned char *MD2(const unsigned char *d, unsigned long n, \& unsigned char *md); \& \& int MD2_Init(MD2_CTX *c); \& int MD2_Update(MD2_CTX *c, const unsigned char *data, \& unsigned long len); \& int MD2_Final(unsigned char *md, MD2_CTX *c); \& \& \& #include \& \& unsigned char *MD4(const unsigned char *d, unsigned long n, \& unsigned char *md); \& \& int MD4_Init(MD4_CTX *c); \& int MD4_Update(MD4_CTX *c, const void *data, \& unsigned long len); \& int MD4_Final(unsigned char *md, MD4_CTX *c); \& \& \& #include \& \& unsigned char *MD5(const unsigned char *d, unsigned long n, \& unsigned char *md); \& \& int MD5_Init(MD5_CTX *c); \& int MD5_Update(MD5_CTX *c, const void *data, \& unsigned long len); \& int MD5_Final(unsigned char *md, MD5_CTX *c); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\s-1MD2, MD4,\s0 and \s-1MD5\s0 are cryptographic hash functions with a 128 bit output. .PP \&\s-1\fIMD2\s0()\fR, \s-1\fIMD4\s0()\fR, and \s-1\fIMD5\s0()\fR compute the \s-1MD2, MD4,\s0 and \s-1MD5\s0 message digest of the \fBn\fR bytes at \fBd\fR and place it in \fBmd\fR (which must have space for \s-1MD2_DIGEST_LENGTH\s0 == \s-1MD4_DIGEST_LENGTH\s0 == \s-1MD5_DIGEST_LENGTH\s0 == 16 bytes of output). If \fBmd\fR is \s-1NULL,\s0 the digest is placed in a static array. .PP The following functions may be used if the message is not completely stored in memory: .PP \&\fIMD2_Init()\fR initializes a \fB\s-1MD2_CTX\s0\fR structure. .PP \&\fIMD2_Update()\fR can be called repeatedly with chunks of the message to be hashed (\fBlen\fR bytes at \fBdata\fR). .PP \&\fIMD2_Final()\fR places the message digest in \fBmd\fR, which must have space for \s-1MD2_DIGEST_LENGTH\s0 == 16 bytes of output, and erases the \fB\s-1MD2_CTX\s0\fR. .PP \&\fIMD4_Init()\fR, \fIMD4_Update()\fR, \fIMD4_Final()\fR, \fIMD5_Init()\fR, \fIMD5_Update()\fR, and \&\fIMD5_Final()\fR are analogous using an \fB\s-1MD4_CTX\s0\fR and \fB\s-1MD5_CTX\s0\fR structure. .PP Applications should use the higher level functions \&\fIEVP_DigestInit\fR\|(3) etc. instead of calling the hash functions directly. .SH "NOTE" .IX Header "NOTE" \&\s-1MD2, MD4,\s0 and \s-1MD5\s0 are recommended only for compatibility with existing applications. In new applications, \s-1SHA\-1\s0 or \s-1RIPEMD\-160\s0 should be preferred. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\s-1\fIMD2\s0()\fR, \s-1\fIMD4\s0()\fR, and \s-1\fIMD5\s0()\fR return pointers to the hash value. .PP \&\fIMD2_Init()\fR, \fIMD2_Update()\fR, \fIMD2_Final()\fR, \fIMD4_Init()\fR, \fIMD4_Update()\fR, \&\fIMD4_Final()\fR, \fIMD5_Init()\fR, \fIMD5_Update()\fR, and \fIMD5_Final()\fR return 1 for success, 0 otherwise. .SH "CONFORMING TO" .IX Header "CONFORMING TO" \&\s-1RFC 1319, RFC 1320, RFC 1321\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIsha\fR\|(3), \fIripemd\fR\|(3), \fIEVP_DigestInit\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\s-1\fIMD2\s0()\fR, \fIMD2_Init()\fR, \fIMD2_Update()\fR \fIMD2_Final()\fR, \s-1\fIMD5\s0()\fR, \fIMD5_Init()\fR, \&\fIMD5_Update()\fR and \fIMD5_Final()\fR are available in all versions of SSLeay and OpenSSL. .PP \&\s-1\fIMD4\s0()\fR, \fIMD4_Init()\fR, and \fIMD4_Update()\fR are available in OpenSSL 0.9.6 and above. deps/libressl-pnacl-sys-2.1.6/libressl/man/CMS_get0_SignerInfos.30000644000175000017500000001535412360020713021450 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CMS_get0_SignerInfos 3" .TH CMS_get0_SignerInfos 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CMS_get0_SignerInfos, CMS_SignerInfo_get0_signer_id, CMS_SignerInfo_cert_cmp, CMS_set1_signer_certs \- CMS signedData signer functions. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& STACK_OF(CMS_SignerInfo) *CMS_get0_SignerInfos(CMS_ContentInfo *cms); \& \& int CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si, ASN1_OCTET_STRING **keyid, X509_NAME **issuer, ASN1_INTEGER **sno); \& int CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert); \& void CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The function \fICMS_get0_SignerInfos()\fR returns all the CMS_SignerInfo structures associated with a \s-1CMS\s0 signedData structure. .PP \&\fICMS_SignerInfo_get0_signer_id()\fR retrieves the certificate signer identifier associated with a specific CMS_SignerInfo structure \fBsi\fR. Either the keyidentifier will be set in \fBkeyid\fR or \fBboth\fR issuer name and serial number in \fBissuer\fR and \fBsno\fR. .PP \&\fICMS_SignerInfo_cert_cmp()\fR compares the certificate \fBcert\fR against the signer identifier \fBsi\fR. It returns zero if the comparison is successful and non zero if not. .PP \&\fICMS_SignerInfo_set1_signer_cert()\fR sets the signers certificate of \fBsi\fR to \&\fBsigner\fR. .SH "NOTES" .IX Header "NOTES" The main purpose of these functions is to enable an application to lookup signers certificates using any appropriate technique when the simpler method of \fICMS_verify()\fR is not appropriate. .PP In typical usage and application will retrieve all CMS_SignerInfo structures using \fICMS_get0_SignerInfo()\fR and retrieve the identifier information using \&\s-1CMS.\s0 It will then obtain the signer certificate by some unspecified means (or return and error if it cannot be found) and set it using \&\fICMS_SignerInfo_set1_signer_cert()\fR. .PP Once all signer certificates have been set \fICMS_verify()\fR can be used. .PP Although \fICMS_get0_SignerInfos()\fR can return \s-1NULL\s0 is an error occur \fBor\fR if there are no signers this is not a problem in practice because the only error which can occur is if the \fBcms\fR structure is not of type signedData due to application error. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICMS_get0_SignerInfos()\fR returns all CMS_SignerInfo structures, or \s-1NULL\s0 there are no signers or an error occurs. .PP \&\fICMS_SignerInfo_get0_signer_id()\fR returns 1 for success and 0 for failure. .PP \&\fICMS_SignerInfo_cert_cmp()\fR returns 0 for a successful comparison and non zero otherwise. .PP \&\fICMS_SignerInfo_set1_signer_cert()\fR does not return a value. .PP Any error can be obtained from \fIERR_get_error\fR\|(3) .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_verify\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" These functions were first was added to OpenSSL 0.9.8 deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_CTX_new.30000644000175000017500000001326012360020711017457 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_CTX_new 3" .TH BN_CTX_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_CTX_new, BN_CTX_init, BN_CTX_free \- allocate and free BN_CTX structures .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BN_CTX *BN_CTX_new(void); \& \& void BN_CTX_free(BN_CTX *c); .Ve .PP Deprecated: .PP .Vb 1 \& void BN_CTX_init(BN_CTX *c); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" A \fB\s-1BN_CTX\s0\fR is a structure that holds \fB\s-1BIGNUM\s0\fR temporary variables used by library functions. Since dynamic memory allocation to create \fB\s-1BIGNUM\s0\fRs is rather expensive when used in conjunction with repeated subroutine calls, the \fB\s-1BN_CTX\s0\fR structure is used. .PP \&\fIBN_CTX_new()\fR allocates and initializes a \fB\s-1BN_CTX\s0\fR structure. .PP \&\fIBN_CTX_free()\fR frees the components of the \fB\s-1BN_CTX\s0\fR, and if it was created by \fIBN_CTX_new()\fR, also the structure itself. If \fIBN_CTX_start\fR\|(3) has been used on the \fB\s-1BN_CTX\s0\fR, \&\fIBN_CTX_end\fR\|(3) must be called before the \fB\s-1BN_CTX\s0\fR may be freed by \fIBN_CTX_free()\fR. .PP \&\fIBN_CTX_init()\fR (deprecated) initializes an existing uninitialized \fB\s-1BN_CTX\s0\fR. This should not be used for new programs. Use \fIBN_CTX_new()\fR instead. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBN_CTX_new()\fR returns a pointer to the \fB\s-1BN_CTX\s0\fR. If the allocation fails, it returns \fB\s-1NULL\s0\fR and sets an error code that can be obtained by \&\fIERR_get_error\fR\|(3). .PP \&\fIBN_CTX_init()\fR and \fIBN_CTX_free()\fR have no return values. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3), \fIERR_get_error\fR\|(3), \fIBN_add\fR\|(3), \&\fIBN_CTX_start\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIBN_CTX_new()\fR and \fIBN_CTX_free()\fR are available in all versions on SSLeay and OpenSSL. \fIBN_CTX_init()\fR was added in SSLeay 0.9.1b. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_state_string.30000644000175000017500000001247612360020737021040 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_state_string 3" .TH SSL_state_string 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_state_string, SSL_state_string_long \- get textual description of state of an SSL object .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& const char *SSL_state_string(const SSL *ssl); \& const char *SSL_state_string_long(const SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_state_string()\fR returns a 6 letter string indicating the current state of the \s-1SSL\s0 object \fBssl\fR. .PP \&\fISSL_state_string_long()\fR returns a string indicating the current state of the \s-1SSL\s0 object \fBssl\fR. .SH "NOTES" .IX Header "NOTES" During its use, an \s-1SSL\s0 objects passes several states. The state is internally maintained. Querying the state information is not very informative before or when a connection has been established. It however can be of significant interest during the handshake. .PP When using non-blocking sockets, the function call performing the handshake may return with \s-1SSL_ERROR_WANT_READ\s0 or \s-1SSL_ERROR_WANT_WRITE\s0 condition, so that SSL_state_string[_long]() may be called. .PP For both blocking or non-blocking sockets, the details state information can be used within the info_callback function set with the \&\fISSL_set_info_callback()\fR call. .SH "RETURN VALUES" .IX Header "RETURN VALUES" Detailed description of possible states to be included later. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_CTX_set_info_callback\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_generate_session_id.30000644000175000017500000002501212360020732023715 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_generate_session_id 3" .TH SSL_CTX_set_generate_session_id 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_generate_session_id, SSL_set_generate_session_id, SSL_has_matching_session_id \- manipulate generation of SSL session IDs (server only) .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id, \& unsigned int *id_len); \& \& int SSL_CTX_set_generate_session_id(SSL_CTX *ctx, GEN_SESSION_CB cb); \& int SSL_set_generate_session_id(SSL *ssl, GEN_SESSION_CB, cb); \& int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id, \& unsigned int id_len); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_generate_session_id()\fR sets the callback function for generating new session ids for \s-1SSL/TLS\s0 sessions for \fBctx\fR to be \fBcb\fR. .PP \&\fISSL_set_generate_session_id()\fR sets the callback function for generating new session ids for \s-1SSL/TLS\s0 sessions for \fBssl\fR to be \fBcb\fR. .PP \&\fISSL_has_matching_session_id()\fR checks, whether a session with id \fBid\fR (of length \fBid_len\fR) is already contained in the internal session cache of the parent context of \fBssl\fR. .SH "NOTES" .IX Header "NOTES" When a new session is established between client and server, the server generates a session id. The session id is an arbitrary sequence of bytes. The length of the session id is 16 bytes for SSLv2 sessions and between 1 and 32 bytes for SSLv3/TLSv1. The session id is not security critical but must be unique for the server. Additionally, the session id is transmitted in the clear when reusing the session so it must not contain sensitive information. .PP Without a callback being set, an OpenSSL server will generate a unique session id from pseudo random numbers of the maximum possible length. Using the callback function, the session id can be changed to contain additional information like e.g. a host id in order to improve load balancing or external caching techniques. .PP The callback function receives a pointer to the memory location to put \&\fBid\fR into and a pointer to the maximum allowed length \fBid_len\fR. The buffer at location \fBid\fR is only guaranteed to have the size \fBid_len\fR. The callback is only allowed to generate a shorter id and reduce \fBid_len\fR; the callback \fBmust never\fR increase \fBid_len\fR or write to the location \&\fBid\fR exceeding the given limit. .PP If a SSLv2 session id is generated and \fBid_len\fR is reduced, it will be restored after the callback has finished and the session id will be padded with 0x00. It is not recommended to change the \fBid_len\fR for SSLv2 sessions. The callback can use the \fISSL_get_version\fR\|(3) function to check, whether the session is of type SSLv2. .PP The location \fBid\fR is filled with 0x00 before the callback is called, so the callback may only fill part of the possible length and leave \fBid_len\fR untouched while maintaining reproducibility. .PP Since the sessions must be distinguished, session ids must be unique. Without the callback a random number is used, so that the probability of generating the same session id is extremely small (2^128 possible ids for an SSLv2 session, 2^256 for SSLv3/TLSv1). In order to assure the uniqueness of the generated session id, the callback must call \&\fISSL_has_matching_session_id()\fR and generate another id if a conflict occurs. If an id conflict is not resolved, the handshake will fail. If the application codes e.g. a unique host id, a unique process number, and a unique sequence number into the session id, uniqueness could easily be achieved without randomness added (it should however be taken care that no confidential information is leaked this way). If the application can not guarantee uniqueness, it is recommended to use the maximum \fBid_len\fR and fill in the bytes not used to code special information with random data to avoid collisions. .PP \&\fISSL_has_matching_session_id()\fR will only query the internal session cache, not the external one. Since the session id is generated before the handshake is completed, it is not immediately added to the cache. If another thread is using the same internal session cache, a race condition can occur in that another thread generates the same session id. Collisions can also occur when using an external session cache, since the external cache is not tested with \fISSL_has_matching_session_id()\fR and the same race condition applies. .PP When calling \fISSL_has_matching_session_id()\fR for an SSLv2 session with reduced \fBid_len\fR, the match operation will be performed using the fixed length required and with a 0x00 padded id. .PP The callback must return 0 if it cannot generate a session id for whatever reason and return 1 on success. .SH "EXAMPLES" .IX Header "EXAMPLES" The callback function listed will generate a session id with the server id given, and will fill the rest with pseudo random bytes: .PP .Vb 1 \& const char session_id_prefix = "www\-18"; \& \& #define MAX_SESSION_ID_ATTEMPTS 10 \& static int generate_session_id(const SSL *ssl, unsigned char *id, \& unsigned int *id_len) \& { \& unsigned int count = 0; \& const char *version; \& \& version = SSL_get_version(ssl); \& if (!strcmp(version, "SSLv2")) \& /* we must not change id_len */; \& \& do { \& RAND_pseudo_bytes(id, *id_len); \& /* Prefix the session_id with the required prefix. NB: If our \& * prefix is too long, clip it \- but there will be worse effects \& * anyway, eg. the server could only possibly create 1 session \& * ID (ie. the prefix!) so all future session negotiations will \& * fail due to conflicts. */ \& memcpy(id, session_id_prefix, \& (strlen(session_id_prefix) < *id_len) ? \& strlen(session_id_prefix) : *id_len); \& } \& while(SSL_has_matching_session_id(ssl, id, *id_len) && \& (++count < MAX_SESSION_ID_ATTEMPTS)); \& if(count >= MAX_SESSION_ID_ATTEMPTS) \& return 0; \& return 1; \& } .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_set_generate_session_id()\fR and \fISSL_set_generate_session_id()\fR always return 1. .PP \&\fISSL_has_matching_session_id()\fR returns 1 if another session with the same id is already in the cache. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_get_version\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fISSL_CTX_set_generate_session_id()\fR, \fISSL_set_generate_session_id()\fR and \fISSL_has_matching_session_id()\fR have been introduced in OpenSSL 0.9.7. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_session_reused.30000644000175000017500000001153712360020736021360 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_session_reused 3" .TH SSL_session_reused 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_session_reused \- query whether a reused session was negotiated during handshake .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_session_reused(SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Query, whether a reused session was negotiated during the handshake. .SH "NOTES" .IX Header "NOTES" During the negotiation, a client can propose to reuse a session. The server then looks up the session in its cache. If both client and server agree on the session, it will be reused and a flag is being set that can be queried by the application. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" A new session was negotiated. .ie n .IP "1" 4 .el .IP "\f(CW1\fR" 4 .IX Item "1" A session was reused. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_set_session\fR\|(3), \&\fISSL_CTX_set_session_cache_mode\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/rsautl.10000644000175000017500000002314512360020742017110 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "rsautl 1" .TH rsautl 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" rsautl \- RSA utility .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBrsautl\fR [\fB\-in file\fR] [\fB\-out file\fR] [\fB\-inkey file\fR] [\fB\-pubin\fR] [\fB\-certin\fR] [\fB\-sign\fR] [\fB\-verify\fR] [\fB\-encrypt\fR] [\fB\-decrypt\fR] [\fB\-pkcs\fR] [\fB\-ssl\fR] [\fB\-raw\fR] [\fB\-hexdump\fR] [\fB\-asn1parse\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBrsautl\fR command can be used to sign, verify, encrypt and decrypt data using the \s-1RSA\s0 algorithm. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read data from or standard input if this option is not specified. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" specifies the output filename to write to or standard output by default. .IP "\fB\-inkey file\fR" 4 .IX Item "-inkey file" the input key file, by default it should be an \s-1RSA\s0 private key. .IP "\fB\-pubin\fR" 4 .IX Item "-pubin" the input file is an \s-1RSA\s0 public key. .IP "\fB\-certin\fR" 4 .IX Item "-certin" the input is a certificate containing an \s-1RSA\s0 public key. .IP "\fB\-sign\fR" 4 .IX Item "-sign" sign the input data and output the signed result. This requires and \s-1RSA\s0 private key. .IP "\fB\-verify\fR" 4 .IX Item "-verify" verify the input data and output the recovered data. .IP "\fB\-encrypt\fR" 4 .IX Item "-encrypt" encrypt the input data using an \s-1RSA\s0 public key. .IP "\fB\-decrypt\fR" 4 .IX Item "-decrypt" decrypt the input data using an \s-1RSA\s0 private key. .IP "\fB\-pkcs, \-oaep, \-ssl, \-raw\fR" 4 .IX Item "-pkcs, -oaep, -ssl, -raw" the padding to use: PKCS#1 v1.5 (the default), PKCS#1 \s-1OAEP,\s0 special padding used in \s-1SSL\s0 v2 backwards compatible handshakes, or no padding, respectively. For signatures, only \fB\-pkcs\fR and \fB\-raw\fR can be used. .IP "\fB\-hexdump\fR" 4 .IX Item "-hexdump" hex dump the output data. .IP "\fB\-asn1parse\fR" 4 .IX Item "-asn1parse" asn1parse the output data, this is useful when combined with the \&\fB\-verify\fR option. .SH "NOTES" .IX Header "NOTES" \&\fBrsautl\fR because it uses the \s-1RSA\s0 algorithm directly can only be used to sign or verify small pieces of data. .SH "EXAMPLES" .IX Header "EXAMPLES" Sign some data using a private key: .PP .Vb 1 \& openssl rsautl \-sign \-in file \-inkey key.pem \-out sig .Ve .PP Recover the signed data .PP .Vb 1 \& openssl rsautl \-verify \-in sig \-inkey key.pem .Ve .PP Examine the raw signed data: .PP .Vb 1 \& openssl rsautl \-verify \-in file \-inkey key.pem \-raw \-hexdump \& \& 0000 \- 00 01 ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff ................ \& 0010 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff ................ \& 0020 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff ................ \& 0030 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff ................ \& 0040 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff ................ \& 0050 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff ................ \& 0060 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff ................ \& 0070 \- ff ff ff ff 00 68 65 6c\-6c 6f 20 77 6f 72 6c 64 .....hello world .Ve .PP The PKCS#1 block formatting is evident from this. If this was done using encrypt and decrypt the block would have been of type 2 (the second byte) and random padding data visible instead of the 0xff bytes. .PP It is possible to analyse the signature of certificates using this utility in conjunction with \fBasn1parse\fR. Consider the self signed example in certs/pca\-cert.pem . Running \fBasn1parse\fR as follows yields: .PP .Vb 1 \& openssl asn1parse \-in pca\-cert.pem \& \& 0:d=0 hl=4 l= 742 cons: SEQUENCE \& 4:d=1 hl=4 l= 591 cons: SEQUENCE \& 8:d=2 hl=2 l= 3 cons: cont [ 0 ] \& 10:d=3 hl=2 l= 1 prim: INTEGER :02 \& 13:d=2 hl=2 l= 1 prim: INTEGER :00 \& 16:d=2 hl=2 l= 13 cons: SEQUENCE \& 18:d=3 hl=2 l= 9 prim: OBJECT :md5WithRSAEncryption \& 29:d=3 hl=2 l= 0 prim: NULL \& 31:d=2 hl=2 l= 92 cons: SEQUENCE \& 33:d=3 hl=2 l= 11 cons: SET \& 35:d=4 hl=2 l= 9 cons: SEQUENCE \& 37:d=5 hl=2 l= 3 prim: OBJECT :countryName \& 42:d=5 hl=2 l= 2 prim: PRINTABLESTRING :AU \& .... \& 599:d=1 hl=2 l= 13 cons: SEQUENCE \& 601:d=2 hl=2 l= 9 prim: OBJECT :md5WithRSAEncryption \& 612:d=2 hl=2 l= 0 prim: NULL \& 614:d=1 hl=3 l= 129 prim: BIT STRING .Ve .PP The final \s-1BIT STRING\s0 contains the actual signature. It can be extracted with: .PP .Vb 1 \& openssl asn1parse \-in pca\-cert.pem \-out sig \-noout \-strparse 614 .Ve .PP The certificate public key can be extracted with: .PP .Vb 1 \& openssl x509 \-in test/testx509.pem \-pubkey \-noout >pubkey.pem .Ve .PP The signature can be analysed with: .PP .Vb 1 \& openssl rsautl \-in sig \-verify \-asn1parse \-inkey pubkey.pem \-pubin \& \& 0:d=0 hl=2 l= 32 cons: SEQUENCE \& 2:d=1 hl=2 l= 12 cons: SEQUENCE \& 4:d=2 hl=2 l= 8 prim: OBJECT :md5 \& 14:d=2 hl=2 l= 0 prim: NULL \& 16:d=1 hl=2 l= 16 prim: OCTET STRING \& 0000 \- f3 46 9e aa 1a 4a 73 c9\-37 ea 93 00 48 25 08 b5 .F...Js.7...H%.. .Ve .PP This is the parsed version of an \s-1ASN1\s0 DigestInfo structure. It can be seen that the digest used was md5. The actual part of the certificate that was signed can be extracted with: .PP .Vb 1 \& openssl asn1parse \-in pca\-cert.pem \-out tbs \-noout \-strparse 4 .Ve .PP and its digest computed with: .PP .Vb 2 \& openssl md5 \-c tbs \& MD5(tbs)= f3:46:9e:aa:1a:4a:73:c9:37:ea:93:00:48:25:08:b5 .Ve .PP which it can be seen agrees with the recovered value above. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdgst\fR\|(1), \fIrsa\fR\|(1), \fIgenrsa\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/DH_get_ex_new_index.30000644000175000017500000001157212360020715021467 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DH_get_ex_new_index 3" .TH DH_get_ex_new_index 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DH_get_ex_new_index, DH_set_ex_data, DH_get_ex_data \- add application specific data to DH structures .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int DH_get_ex_new_index(long argl, void *argp, \& CRYPTO_EX_new *new_func, \& CRYPTO_EX_dup *dup_func, \& CRYPTO_EX_free *free_func); \& \& int DH_set_ex_data(DH *d, int idx, void *arg); \& \& char *DH_get_ex_data(DH *d, int idx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions handle application specific data in \s-1DH\s0 structures. Their usage is identical to that of \&\fIRSA_get_ex_new_index()\fR, \fIRSA_set_ex_data()\fR and \fIRSA_get_ex_data()\fR as described in \fIRSA_get_ex_new_index\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIRSA_get_ex_new_index\fR\|(3), \fIdh\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIDH_get_ex_new_index()\fR, \fIDH_set_ex_data()\fR and \fIDH_get_ex_data()\fR are available since OpenSSL 0.9.5. deps/libressl-pnacl-sys-2.1.6/libressl/man/X509_NAME_add_entry_by_txt.30000644000175000017500000002076612360020725022476 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "X509_NAME_add_entry_by_txt 3" .TH X509_NAME_add_entry_by_txt 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" X509_NAME_add_entry_by_txt, X509_NAME_add_entry_by_OBJ, X509_NAME_add_entry_by_NID, X509_NAME_add_entry, X509_NAME_delete_entry \- X509_NAME modification functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, const unsigned char *bytes, int len, int loc, int set); \& \& int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type, unsigned char *bytes, int len, int loc, int set); \& \& int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, unsigned char *bytes, int len, int loc, int set); \& \& int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne, int loc, int set); \& \& X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIX509_NAME_add_entry_by_txt()\fR, \fIX509_NAME_add_entry_by_OBJ()\fR and \&\fIX509_NAME_add_entry_by_NID()\fR add a field whose name is defined by a string \fBfield\fR, an object \fBobj\fR or a \s-1NID \s0\fBnid\fR respectively. The field value to be added is in \fBbytes\fR of length \fBlen\fR. If \&\fBlen\fR is \-1 then the field length is calculated internally using strlen(bytes). .PP The type of field is determined by \fBtype\fR which can either be a definition of the type of \fBbytes\fR (such as \fB\s-1MBSTRING_ASC\s0\fR) or a standard \s-1ASN1\s0 type (such as \fBV_ASN1_IA5STRING\fR). The new entry is added to a position determined by \fBloc\fR and \fBset\fR. .PP \&\fIX509_NAME_add_entry()\fR adds a copy of \fBX509_NAME_ENTRY\fR structure \fBne\fR to \fBname\fR. The new entry is added to a position determined by \fBloc\fR and \fBset\fR. Since a copy of \fBne\fR is added \fBne\fR must be freed up after the call. .PP \&\fIX509_NAME_delete_entry()\fR deletes an entry from \fBname\fR at position \&\fBloc\fR. The deleted entry is returned and must be freed up. .SH "NOTES" .IX Header "NOTES" The use of string types such as \fB\s-1MBSTRING_ASC\s0\fR or \fB\s-1MBSTRING_UTF8\s0\fR is strongly recommened for the \fBtype\fR parameter. This allows the internal code to correctly determine the type of the field and to apply length checks according to the relevant standards. This is done using \fIASN1_STRING_set_by_NID()\fR. .PP If instead an \s-1ASN1\s0 type is used no checks are performed and the supplied data in \fBbytes\fR is used directly. .PP In \fIX509_NAME_add_entry_by_txt()\fR the \fBfield\fR string represents the field name using OBJ_txt2obj(field, 0). .PP The \fBloc\fR and \fBset\fR parameters determine where a new entry should be added. For almost all applications \fBloc\fR can be set to \-1 and \fBset\fR to 0. This adds a new entry to the end of \fBname\fR as a single valued RelativeDistinguishedName (\s-1RDN\s0). .PP \&\fBloc\fR actually determines the index where the new entry is inserted: if it is \-1 it is appended. .PP \&\fBset\fR determines how the new type is added. If it is zero a new \s-1RDN\s0 is created. .PP If \fBset\fR is \-1 or 1 it is added to the previous or next \s-1RDN\s0 structure respectively. This will then be a multivalued \s-1RDN:\s0 since multivalues RDNs are very seldom used \fBset\fR is almost always set to zero. .SH "EXAMPLES" .IX Header "EXAMPLES" Create an \fBX509_NAME\fR structure: .PP \&\*(L"C=UK, O=Disorganized Organization, CN=Joe Bloggs\*(R" .PP .Vb 10 \& X509_NAME *nm; \& nm = X509_NAME_new(); \& if (nm == NULL) \& /* Some error */ \& if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC, \& "C", "UK", \-1, \-1, 0)) \& /* Error */ \& if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC, \& "O", "Disorganized Organization", \-1, \-1, 0)) \& /* Error */ \& if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC, \& "CN", "Joe Bloggs", \-1, \-1, 0)) \& /* Error */ .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIX509_NAME_add_entry_by_txt()\fR, \fIX509_NAME_add_entry_by_OBJ()\fR, \&\fIX509_NAME_add_entry_by_NID()\fR and \fIX509_NAME_add_entry()\fR return 1 for success of 0 if an error occurred. .PP \&\fIX509_NAME_delete_entry()\fR returns either the deleted \fBX509_NAME_ENTRY\fR structure of \fB\s-1NULL\s0\fR if an error occurred. .SH "BUGS" .IX Header "BUGS" \&\fBtype\fR can still be set to \fBV_ASN1_APP_CHOOSE\fR to use a different algorithm to determine field types. Since this form does not understand multicharacter types, performs no length checks and can result in invalid field types its use is strongly discouraged. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fId2i_X509_NAME\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_tmp_dh_callback.30000644000175000017500000002552712360020733023007 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_tmp_dh_callback 3" .TH SSL_CTX_set_tmp_dh_callback 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_tmp_dh_callback, SSL_CTX_set_tmp_dh, SSL_set_tmp_dh_callback, SSL_set_tmp_dh \- handle DH keys for ephemeral key exchange .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, \& DH *(*tmp_dh_callback)(SSL *ssl, int is_export, int keylength)); \& long SSL_CTX_set_tmp_dh(SSL_CTX *ctx, DH *dh); \& \& void SSL_set_tmp_dh_callback(SSL *ssl, \& DH *(*tmp_dh_callback)(SSL *ssl, int is_export, int keylength)); \& long SSL_set_tmp_dh(SSL *ssl, DH *dh) .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_tmp_dh_callback()\fR sets the callback function for \fBctx\fR to be used when a \s-1DH\s0 parameters are required to \fBtmp_dh_callback\fR. The callback is inherited by all \fBssl\fR objects created from \fBctx\fR. .PP \&\fISSL_CTX_set_tmp_dh()\fR sets \s-1DH\s0 parameters to be used to be \fBdh\fR. The key is inherited by all \fBssl\fR objects created from \fBctx\fR. .PP \&\fISSL_set_tmp_dh_callback()\fR sets the callback only for \fBssl\fR. .PP \&\fISSL_set_tmp_dh()\fR sets the parameters only for \fBssl\fR. .PP These functions apply to \s-1SSL/TLS\s0 servers only. .SH "NOTES" .IX Header "NOTES" When using a cipher with \s-1RSA\s0 authentication, an ephemeral \s-1DH\s0 key exchange can take place. Ciphers with \s-1DSA\s0 keys always use ephemeral \s-1DH\s0 keys as well. In these cases, the session data are negotiated using the ephemeral/temporary \s-1DH\s0 key and the key supplied and certified by the certificate chain is only used for signing. Anonymous ciphers (without a permanent server key) also use ephemeral \s-1DH\s0 keys. .PP Using ephemeral \s-1DH\s0 key exchange yields forward secrecy, as the connection can only be decrypted, when the \s-1DH\s0 key is known. By generating a temporary \&\s-1DH\s0 key inside the server application that is lost when the application is left, it becomes impossible for an attacker to decrypt past sessions, even if he gets hold of the normal (certified) key, as this key was only used for signing. .PP In order to perform a \s-1DH\s0 key exchange the server must use a \s-1DH\s0 group (\s-1DH\s0 parameters) and generate a \s-1DH\s0 key. The server will always generate a new \&\s-1DH\s0 key during the negotiation, when the \s-1DH\s0 parameters are supplied via callback and/or when the \s-1SSL_OP_SINGLE_DH_USE\s0 option of \&\fISSL_CTX_set_options\fR\|(3) is set. It will immediately create a \s-1DH\s0 key, when \s-1DH\s0 parameters are supplied via \&\fISSL_CTX_set_tmp_dh()\fR and \s-1SSL_OP_SINGLE_DH_USE\s0 is not set. In this case, it may happen that a key is generated on initialization without later being needed, while on the other hand the computer time during the negotiation is being saved. .PP If \*(L"strong\*(R" primes were used to generate the \s-1DH\s0 parameters, it is not strictly necessary to generate a new key for each handshake but it does improve forward secrecy. If it is not assured, that \*(L"strong\*(R" primes were used (see especially the section about \s-1DSA\s0 parameters below), \s-1SSL_OP_SINGLE_DH_USE\s0 must be used in order to prevent small subgroup attacks. Always using \s-1SSL_OP_SINGLE_DH_USE\s0 has an impact on the computer time needed during negotiation, but it is not very large, so application authors/users should consider to always enable this option. .PP As generating \s-1DH\s0 parameters is extremely time consuming, an application should not generate the parameters on the fly but supply the parameters. \&\s-1DH\s0 parameters can be reused, as the actual key is newly generated during the negotiation. The risk in reusing \s-1DH\s0 parameters is that an attacker may specialize on a very often used \s-1DH\s0 group. Applications should therefore generate their own \s-1DH\s0 parameters during the installation process using the openssl \fIdhparam\fR\|(1) application. In order to reduce the computer time needed for this generation, it is possible to use \s-1DSA\s0 parameters instead (see \fIdhparam\fR\|(1)), but in this case \s-1SSL_OP_SINGLE_DH_USE\s0 is mandatory. .PP Application authors may compile in \s-1DH\s0 parameters. Files dh512.pem, dh1024.pem, dh2048.pem, and dh4096.pem in the 'apps' directory of current version of the OpenSSL distribution contain the '\s-1SKIP\s0' \s-1DH\s0 parameters, which use safe primes and were generated verifiably pseudo-randomly. These files can be converted into C code using the \fB\-C\fR option of the \&\fIdhparam\fR\|(1) application. Authors may also generate their own set of parameters using \&\fIdhparam\fR\|(1), but a user may not be sure how the parameters were generated. The generation of \s-1DH\s0 parameters during installation is therefore recommended. .PP An application may either directly specify the \s-1DH\s0 parameters or can supply the \s-1DH\s0 parameters via a callback function. The callback approach has the advantage, that the callback may supply \s-1DH\s0 parameters for different key lengths. .PP The \fBtmp_dh_callback\fR is called with the \fBkeylength\fR needed and the \fBis_export\fR information. The \fBis_export\fR flag is set, when the ephemeral \s-1DH\s0 key exchange is performed with an export cipher. .SH "EXAMPLES" .IX Header "EXAMPLES" Handle \s-1DH\s0 parameters for key lengths of 512 and 1024 bits. (Error handling partly left out.) .PP .Vb 5 \& ... \& /* Set up ephemeral DH stuff */ \& DH *dh_512 = NULL; \& DH *dh_1024 = NULL; \& FILE *paramfile; \& \& ... \& /* "openssl dhparam \-out dh_param_512.pem \-2 512" */ \& paramfile = fopen("dh_param_512.pem", "r"); \& if (paramfile) { \& dh_512 = PEM_read_DHparams(paramfile, NULL, NULL, NULL); \& fclose(paramfile); \& } \& /* "openssl dhparam \-out dh_param_1024.pem \-2 1024" */ \& paramfile = fopen("dh_param_1024.pem", "r"); \& if (paramfile) { \& dh_1024 = PEM_read_DHparams(paramfile, NULL, NULL, NULL); \& fclose(paramfile); \& } \& ... \& \& /* "openssl dhparam \-C \-2 512" etc... */ \& DH *get_dh512() { ... } \& DH *get_dh1024() { ... } \& \& DH *tmp_dh_callback(SSL *s, int is_export, int keylength) \& { \& DH *dh_tmp=NULL; \& \& switch (keylength) { \& case 512: \& if (!dh_512) \& dh_512 = get_dh512(); \& dh_tmp = dh_512; \& break; \& case 1024: \& if (!dh_1024) \& dh_1024 = get_dh1024(); \& dh_tmp = dh_1024; \& break; \& default: \& /* Generating a key on the fly is very costly, so use what is there */ \& setup_dh_parameters_like_above(); \& } \& return(dh_tmp); \& } .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_set_tmp_dh_callback()\fR and \fISSL_set_tmp_dh_callback()\fR do not return diagnostic output. .PP \&\fISSL_CTX_set_tmp_dh()\fR and \fISSL_set_tmp_dh()\fR do return 1 on success and 0 on failure. Check the error queue to find out the reason of failure. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_CTX_set_cipher_list\fR\|(3), \&\fISSL_CTX_set_tmp_rsa_callback\fR\|(3), \&\fISSL_CTX_set_options\fR\|(3), \&\fIciphers\fR\|(1), \fIdhparam\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/x509.30000644000175000017500000001404312360020730016277 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "x509 3" .TH x509 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" x509 \- X.509 certificate handling .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" A X.509 certificate is a structured grouping of information about an individual, a device, or anything one can imagine. A X.509 \s-1CRL \&\s0(certificate revocation list) is a tool to help determine if a certificate is still valid. The exact definition of those can be found in the X.509 document from ITU-T, or in \s-1RFC3280\s0 from \s-1PKIX.\s0 In OpenSSL, the type X509 is used to express such a certificate, and the type X509_CRL is used to express a \s-1CRL.\s0 .PP A related structure is a certificate request, defined in PKCS#10 from \&\s-1RSA\s0 Security, Inc, also reflected in \s-1RFC2896. \s0 In OpenSSL, the type X509_REQ is used to express such a certificate request. .PP To handle some complex parts of a certificate, there are the types X509_NAME (to express a certificate name), X509_ATTRIBUTE (to express a certificate attributes), X509_EXTENSION (to express a certificate extension) and a few more. .PP Finally, there's the supertype X509_INFO, which can contain a \s-1CRL,\s0 a certificate and a corresponding private key. .PP \&\fBX509_\fR\fI...\fR, \fBd2i_X509_\fR\fI...\fR and \fBi2d_X509_\fR\fI...\fR handle X.509 certificates, with some exceptions, shown below. .PP \&\fBX509_CRL_\fR\fI...\fR, \fBd2i_X509_CRL_\fR\fI...\fR and \fBi2d_X509_CRL_\fR\fI...\fR handle X.509 CRLs. .PP \&\fBX509_REQ_\fR\fI...\fR, \fBd2i_X509_REQ_\fR\fI...\fR and \fBi2d_X509_REQ_\fR\fI...\fR handle PKCS#10 certificate requests. .PP \&\fBX509_NAME_\fR\fI...\fR handle certificate names. .PP \&\fBX509_ATTRIBUTE_\fR\fI...\fR handle certificate attributes. .PP \&\fBX509_EXTENSION_\fR\fI...\fR handle certificate extensions. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIX509_NAME_ENTRY_get_object\fR\|(3), \&\fIX509_NAME_add_entry_by_txt\fR\|(3), \&\fIX509_NAME_add_entry_by_NID\fR\|(3), \&\fIX509_NAME_print_ex\fR\|(3), \&\fIX509_NAME_new\fR\|(3), \&\fId2i_X509\fR\|(3), \&\fId2i_X509_ALGOR\fR\|(3), \&\fId2i_X509_CRL\fR\|(3), \&\fId2i_X509_NAME\fR\|(3), \&\fId2i_X509_REQ\fR\|(3), \&\fId2i_X509_SIG\fR\|(3), \&\fIcrypto\fR\|(3), \&\fIx509v3\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_get_SSL_CTX.30000644000175000017500000001067012360020735020340 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_get_SSL_CTX 3" .TH SSL_get_SSL_CTX 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_get_SSL_CTX \- get the SSL_CTX from which an SSL is created .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_get_SSL_CTX()\fR returns a pointer to the \s-1SSL_CTX\s0 object, from which \&\fBssl\fR was created with \fISSL_new\fR\|(3). .SH "RETURN VALUES" .IX Header "RETURN VALUES" The pointer to the \s-1SSL_CTX\s0 object is returned. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_new\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_session_cache_mode.30000644000175000017500000002260212360020733023521 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_session_cache_mode 3" .TH SSL_CTX_set_session_cache_mode 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_session_cache_mode, SSL_CTX_get_session_cache_mode \- enable/disable session caching .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& long SSL_CTX_set_session_cache_mode(SSL_CTX ctx, long mode); \& long SSL_CTX_get_session_cache_mode(SSL_CTX ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_session_cache_mode()\fR enables/disables session caching by setting the operational mode for \fBctx\fR to . .PP \&\fISSL_CTX_get_session_cache_mode()\fR returns the currently used cache mode. .SH "NOTES" .IX Header "NOTES" The OpenSSL library can store/retrieve \s-1SSL/TLS\s0 sessions for later reuse. The sessions can be held in memory for each \fBctx\fR, if more than one \&\s-1SSL_CTX\s0 object is being maintained, the sessions are unique for each \s-1SSL_CTX\s0 object. .PP In order to reuse a session, a client must send the session's id to the server. It can only send exactly one id. The server then either agrees to reuse the session or it starts a full handshake (to create a new session). .PP A server will lookup up the session in its internal session storage. If the session is not found in internal storage or lookups for the internal storage have been deactivated (\s-1SSL_SESS_CACHE_NO_INTERNAL_LOOKUP\s0), the server will try the external storage if available. .PP Since a client may try to reuse a session intended for use in a different context, the session id context must be set by the server (see \&\fISSL_CTX_set_session_id_context\fR\|(3)). .PP The following session cache modes and modifiers are available: .IP "\s-1SSL_SESS_CACHE_OFF\s0" 4 .IX Item "SSL_SESS_CACHE_OFF" No session caching for client or server takes place. .IP "\s-1SSL_SESS_CACHE_CLIENT\s0" 4 .IX Item "SSL_SESS_CACHE_CLIENT" Client sessions are added to the session cache. As there is no reliable way for the OpenSSL library to know whether a session should be reused or which session to choose (due to the abstract \s-1BIO\s0 layer the \s-1SSL\s0 engine does not have details about the connection), the application must select the session to be reused by using the \fISSL_set_session\fR\|(3) function. This option is not activated by default. .IP "\s-1SSL_SESS_CACHE_SERVER\s0" 4 .IX Item "SSL_SESS_CACHE_SERVER" Server sessions are added to the session cache. When a client proposes a session to be reused, the server looks for the corresponding session in (first) the internal session cache (unless \s-1SSL_SESS_CACHE_NO_INTERNAL_LOOKUP\s0 is set), then (second) in the external cache if available. If the session is found, the server will try to reuse the session. This is the default. .IP "\s-1SSL_SESS_CACHE_BOTH\s0" 4 .IX Item "SSL_SESS_CACHE_BOTH" Enable both \s-1SSL_SESS_CACHE_CLIENT\s0 and \s-1SSL_SESS_CACHE_SERVER\s0 at the same time. .IP "\s-1SSL_SESS_CACHE_NO_AUTO_CLEAR\s0" 4 .IX Item "SSL_SESS_CACHE_NO_AUTO_CLEAR" Normally the session cache is checked for expired sessions every 255 connections using the \&\fISSL_CTX_flush_sessions\fR\|(3) function. Since this may lead to a delay which cannot be controlled, the automatic flushing may be disabled and \&\fISSL_CTX_flush_sessions\fR\|(3) can be called explicitly by the application. .IP "\s-1SSL_SESS_CACHE_NO_INTERNAL_LOOKUP\s0" 4 .IX Item "SSL_SESS_CACHE_NO_INTERNAL_LOOKUP" By setting this flag, session-resume operations in an \s-1SSL/TLS\s0 server will not automatically look up sessions in the internal cache, even if sessions are automatically stored there. If external session caching callbacks are in use, this flag guarantees that all lookups are directed to the external cache. As automatic lookup only applies for \s-1SSL/TLS\s0 servers, the flag has no effect on clients. .IP "\s-1SSL_SESS_CACHE_NO_INTERNAL_STORE\s0" 4 .IX Item "SSL_SESS_CACHE_NO_INTERNAL_STORE" Depending on the presence of \s-1SSL_SESS_CACHE_CLIENT\s0 and/or \s-1SSL_SESS_CACHE_SERVER,\s0 sessions negotiated in an \s-1SSL/TLS\s0 handshake may be cached for possible reuse. Normally a new session is added to the internal cache as well as any external session caching (callback) that is configured for the \s-1SSL_CTX.\s0 This flag will prevent sessions being stored in the internal cache (though the application can add them manually using \fISSL_CTX_add_session\fR\|(3)). Note: in any \s-1SSL/TLS\s0 servers where external caching is configured, any successful session lookups in the external cache (ie. for session-resume requests) would normally be copied into the local cache before processing continues \- this flag prevents these additions to the internal cache as well. .IP "\s-1SSL_SESS_CACHE_NO_INTERNAL\s0" 4 .IX Item "SSL_SESS_CACHE_NO_INTERNAL" Enable both \s-1SSL_SESS_CACHE_NO_INTERNAL_LOOKUP\s0 and \&\s-1SSL_SESS_CACHE_NO_INTERNAL_STORE\s0 at the same time. .PP The default mode is \s-1SSL_SESS_CACHE_SERVER.\s0 .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_set_session_cache_mode()\fR returns the previously set cache mode. .PP \&\fISSL_CTX_get_session_cache_mode()\fR returns the currently set cache mode. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_set_session\fR\|(3), \&\fISSL_session_reused\fR\|(3), \&\fISSL_CTX_add_session\fR\|(3), \&\fISSL_CTX_sess_number\fR\|(3), \&\fISSL_CTX_sess_set_cache_size\fR\|(3), \&\fISSL_CTX_sess_set_get_cb\fR\|(3), \&\fISSL_CTX_set_session_id_context\fR\|(3), \&\fISSL_CTX_set_timeout\fR\|(3), \&\fISSL_CTX_flush_sessions\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\s-1SSL_SESS_CACHE_NO_INTERNAL_STORE\s0 and \s-1SSL_SESS_CACHE_NO_INTERNAL\s0 were introduced in OpenSSL 0.9.6h. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_info_callback.30000644000175000017500000002312212360020732022453 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_info_callback 3" .TH SSL_CTX_set_info_callback 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_info_callback, SSL_CTX_get_info_callback, SSL_set_info_callback, SSL_get_info_callback \- handle information callback for SSL connections .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*callback)()); \& void (*SSL_CTX_get_info_callback(const SSL_CTX *ctx))(); \& \& void SSL_set_info_callback(SSL *ssl, void (*callback)()); \& void (*SSL_get_info_callback(const SSL *ssl))(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_info_callback()\fR sets the \fBcallback\fR function, that can be used to obtain state information for \s-1SSL\s0 objects created from \fBctx\fR during connection setup and use. The setting for \fBctx\fR is overridden from the setting for a specific \s-1SSL\s0 object, if specified. When \fBcallback\fR is \s-1NULL,\s0 no callback function is used. .PP \&\fISSL_set_info_callback()\fR sets the \fBcallback\fR function, that can be used to obtain state information for \fBssl\fR during connection setup and use. When \fBcallback\fR is \s-1NULL,\s0 the callback setting currently valid for \&\fBctx\fR is used. .PP \&\fISSL_CTX_get_info_callback()\fR returns a pointer to the currently set information callback function for \fBctx\fR. .PP \&\fISSL_get_info_callback()\fR returns a pointer to the currently set information callback function for \fBssl\fR. .SH "NOTES" .IX Header "NOTES" When setting up a connection and during use, it is possible to obtain state information from the \s-1SSL/TLS\s0 engine. When set, an information callback function is called whenever the state changes, an alert appears, or an error occurs. .PP The callback function is called as \fBcallback(\s-1SSL\s0 *ssl, int where, int ret)\fR. The \fBwhere\fR argument specifies information about where (in which context) the callback function was called. If \fBret\fR is 0, an error condition occurred. If an alert is handled, \s-1SSL_CB_ALERT\s0 is set and \fBret\fR specifies the alert information. .PP \&\fBwhere\fR is a bitmask made up of the following bits: .IP "\s-1SSL_CB_LOOP\s0" 4 .IX Item "SSL_CB_LOOP" Callback has been called to indicate state change inside a loop. .IP "\s-1SSL_CB_EXIT\s0" 4 .IX Item "SSL_CB_EXIT" Callback has been called to indicate error exit of a handshake function. (May be soft error with retry option for non-blocking setups.) .IP "\s-1SSL_CB_READ\s0" 4 .IX Item "SSL_CB_READ" Callback has been called during read operation. .IP "\s-1SSL_CB_WRITE\s0" 4 .IX Item "SSL_CB_WRITE" Callback has been called during write operation. .IP "\s-1SSL_CB_ALERT\s0" 4 .IX Item "SSL_CB_ALERT" Callback has been called due to an alert being sent or received. .IP "\s-1SSL_CB_READ_ALERT \s0(SSL_CB_ALERT|SSL_CB_READ)" 4 .IX Item "SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ)" .PD 0 .IP "\s-1SSL_CB_WRITE_ALERT \s0(SSL_CB_ALERT|SSL_CB_WRITE)" 4 .IX Item "SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE)" .IP "\s-1SSL_CB_ACCEPT_LOOP \s0(SSL_ST_ACCEPT|SSL_CB_LOOP)" 4 .IX Item "SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP)" .IP "\s-1SSL_CB_ACCEPT_EXIT \s0(SSL_ST_ACCEPT|SSL_CB_EXIT)" 4 .IX Item "SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT)" .IP "\s-1SSL_CB_CONNECT_LOOP \s0(SSL_ST_CONNECT|SSL_CB_LOOP)" 4 .IX Item "SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP)" .IP "\s-1SSL_CB_CONNECT_EXIT \s0(SSL_ST_CONNECT|SSL_CB_EXIT)" 4 .IX Item "SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT)" .IP "\s-1SSL_CB_HANDSHAKE_START\s0" 4 .IX Item "SSL_CB_HANDSHAKE_START" .PD Callback has been called because a new handshake is started. .IP "\s-1SSL_CB_HANDSHAKE_DONE \s0 0x20" 4 .IX Item "SSL_CB_HANDSHAKE_DONE 0x20" Callback has been called because a handshake is finished. .PP The current state information can be obtained using the \&\fISSL_state_string\fR\|(3) family of functions. .PP The \fBret\fR information can be evaluated using the \&\fISSL_alert_type_string\fR\|(3) family of functions. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_set_info_callback()\fR does not provide diagnostic information. .PP \&\fISSL_get_info_callback()\fR returns the current setting. .SH "EXAMPLES" .IX Header "EXAMPLES" The following example callback function prints state strings, information about alerts being handled and error messages to the \fBbio_err\fR \s-1BIO.\s0 .PP .Vb 4 \& void apps_ssl_info_callback(SSL *s, int where, int ret) \& { \& const char *str; \& int w; \& \& w=where& ~SSL_ST_MASK; \& \& if (w & SSL_ST_CONNECT) str="SSL_connect"; \& else if (w & SSL_ST_ACCEPT) str="SSL_accept"; \& else str="undefined"; \& \& if (where & SSL_CB_LOOP) \& { \& BIO_printf(bio_err,"%s:%s\en",str,SSL_state_string_long(s)); \& } \& else if (where & SSL_CB_ALERT) \& { \& str=(where & SSL_CB_READ)?"read":"write"; \& BIO_printf(bio_err,"SSL3 alert %s:%s:%s\en", \& str, \& SSL_alert_type_string_long(ret), \& SSL_alert_desc_string_long(ret)); \& } \& else if (where & SSL_CB_EXIT) \& { \& if (ret == 0) \& BIO_printf(bio_err,"%s:failed in %s\en", \& str,SSL_state_string_long(s)); \& else if (ret < 0) \& { \& BIO_printf(bio_err,"%s:error in %s\en", \& str,SSL_state_string_long(s)); \& } \& } \& } .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_state_string\fR\|(3), \&\fISSL_alert_type_string\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/CMS_add1_recipient_cert.30000644000175000017500000001474312360020713022174 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CMS_add1_recipient_cert 3" .TH CMS_add1_recipient_cert 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CMS_add1_recipient_cert, CMS_add0_recipient_key \- add recipients to a CMS enveloped data structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms, X509 *recip, unsigned int flags); \& \& CMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid, unsigned char *key, size_t keylen, unsigned char *id, size_t idlen, ASN1_GENERALIZEDTIME *date, ASN1_OBJECT *otherTypeId, ASN1_TYPE *otherType); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fICMS_add1_recipient_cert()\fR adds recipient \fBrecip\fR to CMS_ContentInfo enveloped data structure \fBcms\fR as a KeyTransRecipientInfo structure. .PP \&\fICMS_add0_recipient_key()\fR adds symmetric key \fBkey\fR of length \fBkeylen\fR using wrapping algorithm \fBnid\fR, identifier \fBid\fR of length \fBidlen\fR and optional values \fBdate\fR, \fBotherTypeId\fR and \fBotherType\fR to CMS_ContentInfo enveloped data structure \fBcms\fR as a KEKRecipientInfo structure. .PP The CMS_ContentInfo structure should be obtained from an initial call to \&\fICMS_encrypt()\fR with the flag \fB\s-1CMS_PARTIAL\s0\fR set. .SH "NOTES" .IX Header "NOTES" The main purpose of this function is to provide finer control over a \s-1CMS\s0 enveloped data structure where the simpler \fICMS_encrypt()\fR function defaults are not appropriate. For example if one or more KEKRecipientInfo structures need to be added. New attributes can also be added using the returned CMS_RecipientInfo structure and the \s-1CMS\s0 attribute utility functions. .PP OpenSSL will by default identify recipient certificates using issuer name and serial number. If \fB\s-1CMS_USE_KEYID\s0\fR is set it will use the subject key identifier value instead. An error occurs if all recipient certificates do not have a subject key identifier extension. .PP Currently only \s-1AES\s0 based key wrapping algorithms are supported for \fBnid\fR, specifically: NID_id_aes128_wrap, NID_id_aes192_wrap and NID_id_aes256_wrap. If \fBnid\fR is set to \fBNID_undef\fR then an \s-1AES\s0 wrap algorithm will be used consistent with \fBkeylen\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICMS_add1_recipient_cert()\fR and \fICMS_add0_recipient_key()\fR return an internal pointer to the CMS_RecipientInfo structure just added or \s-1NULL\s0 if an error occurs. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_decrypt\fR\|(3), \&\fICMS_final\fR\|(3), .SH "HISTORY" .IX Header "HISTORY" \&\fICMS_add1_recipient_cert()\fR and \fICMS_add0_recipient_key()\fR were added to OpenSSL 0.9.8 deps/libressl-pnacl-sys-2.1.6/libressl/man/crl2pkcs7.10000644000175000017500000001541612360020740017410 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "crl2pkcs7 1" .TH crl2pkcs7 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" crl2pkcs7 \- Create a PKCS#7 structure from a CRL and certificates. .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBcrl2pkcs7\fR [\fB\-inform PEM|DER\fR] [\fB\-outform PEM|DER\fR] [\fB\-in filename\fR] [\fB\-out filename\fR] [\fB\-certfile filename\fR] [\fB\-nocrl\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBcrl2pkcs7\fR command takes an optional \s-1CRL\s0 and one or more certificates and converts them into a PKCS#7 degenerate \*(L"certificates only\*(R" structure. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" .IP "\fB\-inform DER|PEM\fR" 4 .IX Item "-inform DER|PEM" This specifies the \s-1CRL\s0 input format. \fB\s-1DER\s0\fR format is \s-1DER\s0 encoded \s-1CRL\s0 structure.\fB\s-1PEM\s0\fR (the default) is a base64 encoded version of the \s-1DER\s0 form with header and footer lines. .IP "\fB\-outform DER|PEM\fR" 4 .IX Item "-outform DER|PEM" This specifies the PKCS#7 structure output format. \fB\s-1DER\s0\fR format is \s-1DER\s0 encoded PKCS#7 structure.\fB\s-1PEM\s0\fR (the default) is a base64 encoded version of the \s-1DER\s0 form with header and footer lines. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read a \s-1CRL\s0 from or standard input if this option is not specified. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" specifies the output filename to write the PKCS#7 structure to or standard output by default. .IP "\fB\-certfile filename\fR" 4 .IX Item "-certfile filename" specifies a filename containing one or more certificates in \fB\s-1PEM\s0\fR format. All certificates in the file will be added to the PKCS#7 structure. This option can be used more than once to read certificates form multiple files. .IP "\fB\-nocrl\fR" 4 .IX Item "-nocrl" normally a \s-1CRL\s0 is included in the output file. With this option no \s-1CRL\s0 is included in the output file and a \s-1CRL\s0 is not read from the input file. .SH "EXAMPLES" .IX Header "EXAMPLES" Create a PKCS#7 structure from a certificate and \s-1CRL:\s0 .PP .Vb 1 \& openssl crl2pkcs7 \-in crl.pem \-certfile cert.pem \-out p7.pem .Ve .PP Creates a PKCS#7 structure in \s-1DER\s0 format with no \s-1CRL\s0 from several different certificates: .PP .Vb 2 \& openssl crl2pkcs7 \-nocrl \-certfile newcert.pem \& \-certfile demoCA/cacert.pem \-outform DER \-out p7.der .Ve .SH "NOTES" .IX Header "NOTES" The output file is a PKCS#7 signed data structure containing no signers and just certificates and an optional \s-1CRL.\s0 .PP This utility can be used to send certificates and CAs to Netscape as part of the certificate enrollment process. This involves sending the \s-1DER\s0 encoded output as \s-1MIME\s0 type application/x\-x509\-user\-cert. .PP The \fB\s-1PEM\s0\fR encoded form with the header and footer lines removed can be used to install user certificates and CAs in \s-1MSIE\s0 using the Xenroll control. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIpkcs7\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/rsa.30000644000175000017500000002034412360020730016360 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "rsa 3" .TH rsa 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" rsa \- RSA public key cryptosystem .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& RSA * RSA_new(void); \& void RSA_free(RSA *rsa); \& \& int RSA_public_encrypt(int flen, unsigned char *from, \& unsigned char *to, RSA *rsa, int padding); \& int RSA_private_decrypt(int flen, unsigned char *from, \& unsigned char *to, RSA *rsa, int padding); \& int RSA_private_encrypt(int flen, unsigned char *from, \& unsigned char *to, RSA *rsa,int padding); \& int RSA_public_decrypt(int flen, unsigned char *from, \& unsigned char *to, RSA *rsa,int padding); \& \& int RSA_sign(int type, unsigned char *m, unsigned int m_len, \& unsigned char *sigret, unsigned int *siglen, RSA *rsa); \& int RSA_verify(int type, unsigned char *m, unsigned int m_len, \& unsigned char *sigbuf, unsigned int siglen, RSA *rsa); \& \& int RSA_size(const RSA *rsa); \& \& RSA *RSA_generate_key(int num, unsigned long e, \& void (*callback)(int,int,void *), void *cb_arg); \& \& int RSA_check_key(RSA *rsa); \& \& int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); \& void RSA_blinding_off(RSA *rsa); \& \& void RSA_set_default_method(const RSA_METHOD *meth); \& const RSA_METHOD *RSA_get_default_method(void); \& int RSA_set_method(RSA *rsa, const RSA_METHOD *meth); \& const RSA_METHOD *RSA_get_method(const RSA *rsa); \& RSA_METHOD *RSA_PKCS1_SSLeay(void); \& RSA_METHOD *RSA_null_method(void); \& int RSA_flags(const RSA *rsa); \& RSA *RSA_new_method(ENGINE *engine); \& \& int RSA_print(BIO *bp, RSA *x, int offset); \& int RSA_print_fp(FILE *fp, RSA *x, int offset); \& \& int RSA_get_ex_new_index(long argl, char *argp, int (*new_func)(), \& int (*dup_func)(), void (*free_func)()); \& int RSA_set_ex_data(RSA *r,int idx,char *arg); \& char *RSA_get_ex_data(RSA *r, int idx); \& \& int RSA_sign_ASN1_OCTET_STRING(int dummy, unsigned char *m, \& unsigned int m_len, unsigned char *sigret, unsigned int *siglen, \& RSA *rsa); \& int RSA_verify_ASN1_OCTET_STRING(int dummy, unsigned char *m, \& unsigned int m_len, unsigned char *sigbuf, unsigned int siglen, \& RSA *rsa); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions implement \s-1RSA\s0 public key encryption and signatures as defined in \s-1PKCS\s0 #1 v2.0 [\s-1RFC 2437\s0]. .PP The \fB\s-1RSA\s0\fR structure consists of several \s-1BIGNUM\s0 components. It can contain public as well as private \s-1RSA\s0 keys: .PP .Vb 10 \& struct \& { \& BIGNUM *n; // public modulus \& BIGNUM *e; // public exponent \& BIGNUM *d; // private exponent \& BIGNUM *p; // secret prime factor \& BIGNUM *q; // secret prime factor \& BIGNUM *dmp1; // d mod (p\-1) \& BIGNUM *dmq1; // d mod (q\-1) \& BIGNUM *iqmp; // q^\-1 mod p \& // ... \& }; \& RSA .Ve .PP In public keys, the private exponent and the related secret values are \&\fB\s-1NULL\s0\fR. .PP \&\fBp\fR, \fBq\fR, \fBdmp1\fR, \fBdmq1\fR and \fBiqmp\fR may be \fB\s-1NULL\s0\fR in private keys, but the \s-1RSA\s0 operations are much faster when these values are available. .PP Note that \s-1RSA\s0 keys may use non-standard \fB\s-1RSA_METHOD\s0\fR implementations, either directly or by the use of \fB\s-1ENGINE\s0\fR modules. In some cases (eg. an \&\s-1ENGINE\s0 providing support for hardware-embedded keys), these \s-1BIGNUM\s0 values will not be used by the implementation or may be used for alternative data storage. For this reason, applications should generally avoid using \s-1RSA\s0 structure elements directly and instead use \s-1API\s0 functions to query or modify keys. .SH "CONFORMING TO" .IX Header "CONFORMING TO" \&\s-1SSL, PKCS\s0 #1 v2.0 .SH "PATENTS" .IX Header "PATENTS" \&\s-1RSA\s0 was covered by a \s-1US\s0 patent which expired in September 2000. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIrsa\fR\|(1), \fIbn\fR\|(3), \fIdsa\fR\|(3), \fIdh\fR\|(3), \&\fIrand\fR\|(3), \fIengine\fR\|(3), \fIRSA_new\fR\|(3), \&\fIRSA_public_encrypt\fR\|(3), \&\fIRSA_sign\fR\|(3), \fIRSA_size\fR\|(3), \&\fIRSA_generate_key\fR\|(3), \&\fIRSA_check_key\fR\|(3), \&\fIRSA_blinding_on\fR\|(3), \&\fIRSA_set_method\fR\|(3), \fIRSA_print\fR\|(3), \&\fIRSA_get_ex_new_index\fR\|(3), \&\fIRSA_private_encrypt\fR\|(3), \&\fIRSA_sign_ASN1_OCTET_STRING\fR\|(3), \&\fIRSA_padding_add_PKCS1_type_1\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO.30000644000175000017500000001347212360020707016214 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO 3" .TH BIO 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" bio \- I/O abstraction .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" A \s-1BIO\s0 is an I/O abstraction, it hides many of the underlying I/O details from an application. If an application uses a \s-1BIO\s0 for its I/O it can transparently handle \s-1SSL\s0 connections, unencrypted network connections and file I/O. .PP There are two type of \s-1BIO,\s0 a source/sink \s-1BIO\s0 and a filter \s-1BIO.\s0 .PP As its name implies a source/sink \s-1BIO\s0 is a source and/or sink of data, examples include a socket \s-1BIO\s0 and a file \s-1BIO.\s0 .PP A filter \s-1BIO\s0 takes data from one \s-1BIO\s0 and passes it through to another, or the application. The data may be left unmodified (for example a message digest \s-1BIO\s0) or translated (for example an encryption \s-1BIO\s0). The effect of a filter \s-1BIO\s0 may change according to the I/O operation it is performing: for example an encryption \&\s-1BIO\s0 will encrypt data if it is being written to and decrypt data if it is being read from. .PP BIOs can be joined together to form a chain (a single \s-1BIO\s0 is a chain with one component). A chain normally consist of one source/sink \&\s-1BIO\s0 and one or more filter BIOs. Data read from or written to the first \s-1BIO\s0 then traverses the chain to the end (normally a source/sink \&\s-1BIO\s0). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIBIO_ctrl\fR\|(3), \&\fIBIO_f_base64\fR\|(3), \fIBIO_f_buffer\fR\|(3), \&\fIBIO_f_cipher\fR\|(3), \fIBIO_f_md\fR\|(3), \&\fIBIO_f_null\fR\|(3), \fIBIO_f_ssl\fR\|(3), \&\fIBIO_find_type\fR\|(3), \fIBIO_new\fR\|(3), \&\fIBIO_new_bio_pair\fR\|(3), \&\fIBIO_push\fR\|(3), \fIBIO_read\fR\|(3), \&\fIBIO_s_accept\fR\|(3), \fIBIO_s_bio\fR\|(3), \&\fIBIO_s_connect\fR\|(3), \fIBIO_s_fd\fR\|(3), \&\fIBIO_s_file\fR\|(3), \fIBIO_s_mem\fR\|(3), \&\fIBIO_s_null\fR\|(3), \fIBIO_s_socket\fR\|(3), \&\fIBIO_set_callback\fR\|(3), \&\fIBIO_should_retry\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/PKCS12_parse.30000644000175000017500000001340112360020722017665 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PKCS12_parse 3" .TH PKCS12_parse 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PKCS12_parse \- parse a PKCS#12 structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include .Ve .PP int PKCS12_parse(\s-1PKCS12\s0 *p12, const char *pass, \s-1EVP_PKEY\s0 **pkey, X509 **cert, \s-1STACK_OF\s0(X509) **ca); .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIPKCS12_parse()\fR parses a \s-1PKCS12\s0 structure. .PP \&\fBp12\fR is the \fB\s-1PKCS12\s0\fR structure to parse. \fBpass\fR is the passphrase to use. If successful the private key will be written to \fB*pkey\fR, the corresponding certificate to \fB*cert\fR and any additional certificates to \fB*ca\fR. .SH "NOTES" .IX Header "NOTES" The parameters \fBpkey\fR and \fBcert\fR cannot be \fB\s-1NULL\s0\fR. \fBca\fR can be <\s-1NULL\s0> in which case additional certificates will be discarded. \fB*ca\fR can also be a valid \s-1STACK\s0 in which case additional certificates are appended to \fB*ca\fR. If \&\fB*ca\fR is \fB\s-1NULL\s0\fR a new \s-1STACK\s0 will be allocated. .PP The \fBfriendlyName\fR and \fBlocalKeyID\fR attributes (if present) on each certificate will be stored in the \fBalias\fR and \fBkeyid\fR attributes of the \&\fBX509\fR structure. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIPKCS12_parse()\fR returns 1 for success and zero if an error occurred. .PP The error can be obtained from \fIERR_get_error\fR\|(3) .SH "BUGS" .IX Header "BUGS" Only a single private key and corresponding certificate is returned by this function. More complex PKCS#12 files with multiple private keys will only return the first match. .PP Only \fBfriendlyName\fR and \fBlocalKeyID\fR attributes are currently stored in certificates. Other attributes are discarded. .PP Attributes currently cannot be stored in the private key \fB\s-1EVP_PKEY\s0\fR structure. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fId2i_PKCS12\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" PKCS12_parse was added in OpenSSL 0.9.3 deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_options.30000644000175000017500000004344512360020733021412 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_options 3" .TH SSL_CTX_set_options 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_options, SSL_set_options, SSL_CTX_clear_options, SSL_clear_options, SSL_CTX_get_options, SSL_get_options, SSL_get_secure_renegotiation_support \- manipulate SSL options .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& long SSL_CTX_set_options(SSL_CTX *ctx, long options); \& long SSL_set_options(SSL *ssl, long options); \& \& long SSL_CTX_clear_options(SSL_CTX *ctx, long options); \& long SSL_clear_options(SSL *ssl, long options); \& \& long SSL_CTX_get_options(SSL_CTX *ctx); \& long SSL_get_options(SSL *ssl); \& \& long SSL_get_secure_renegotiation_support(SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Note: all these functions are implemented using macros. .PP \&\fISSL_CTX_set_options()\fR adds the options set via bitmask in \fBoptions\fR to \fBctx\fR. Options already set before are not cleared! .PP \&\fISSL_set_options()\fR adds the options set via bitmask in \fBoptions\fR to \fBssl\fR. Options already set before are not cleared! .PP \&\fISSL_CTX_clear_options()\fR clears the options set via bitmask in \fBoptions\fR to \fBctx\fR. .PP \&\fISSL_clear_options()\fR clears the options set via bitmask in \fBoptions\fR to \fBssl\fR. .PP \&\fISSL_CTX_get_options()\fR returns the options set for \fBctx\fR. .PP \&\fISSL_get_options()\fR returns the options set for \fBssl\fR. .PP \&\fISSL_get_secure_renegotiation_support()\fR indicates whether the peer supports secure renegotiation. .SH "NOTES" .IX Header "NOTES" The behaviour of the \s-1SSL\s0 library can be changed by setting several options. The options are coded as bitmasks and can be combined by a bitwise \fBor\fR operation (|). .PP \&\fISSL_CTX_set_options()\fR and \fISSL_set_options()\fR affect the (external) protocol behaviour of the \s-1SSL\s0 library. The (internal) behaviour of the \s-1API\s0 can be changed by using the similar \&\fISSL_CTX_set_mode\fR\|(3) and \fISSL_set_mode()\fR functions. .PP During a handshake, the option settings of the \s-1SSL\s0 object are used. When a new \s-1SSL\s0 object is created from a context using \fISSL_new()\fR, the current option setting is copied. Changes to \fBctx\fR do not affect already created \&\s-1SSL\s0 objects. \fISSL_clear()\fR does not affect the settings. .PP The following \fBbug workaround\fR options are available: .IP "\s-1SSL_OP_MICROSOFT_SESS_ID_BUG\s0" 4 .IX Item "SSL_OP_MICROSOFT_SESS_ID_BUG" www.microsoft.com \- when talking SSLv2, if session-id reuse is performed, the session-id passed back in the server-finished message is different from the one decided upon. .IP "\s-1SSL_OP_NETSCAPE_CHALLENGE_BUG\s0" 4 .IX Item "SSL_OP_NETSCAPE_CHALLENGE_BUG" Netscape\-Commerce/1.12, when talking SSLv2, accepts a 32 byte challenge but then appears to only use 16 bytes when generating the encryption keys. Using 16 bytes is ok but it should be ok to use 32. According to the SSLv3 spec, one should use 32 bytes for the challenge when operating in SSLv2/v3 compatibility mode, but as mentioned above, this breaks this server so 16 bytes is the way to go. .IP "\s-1SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG\s0" 4 .IX Item "SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG" As of OpenSSL 0.9.8q and 1.0.0c, this option has no effect. .IP "\s-1SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG\s0" 4 .IX Item "SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG" \&... .IP "\s-1SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER\s0" 4 .IX Item "SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER" \&... .IP "\s-1SSL_OP_SAFARI_ECDHE_ECDSA_BUG\s0" 4 .IX Item "SSL_OP_SAFARI_ECDHE_ECDSA_BUG" Don't prefer ECDHE-ECDSA ciphers when the client appears to be Safari on \s-1OS X. OS X 10.8..10.8.3\s0 has broken support for ECDHE-ECDSA ciphers. .IP "\s-1SSL_OP_SSLEAY_080_CLIENT_DH_BUG\s0" 4 .IX Item "SSL_OP_SSLEAY_080_CLIENT_DH_BUG" \&... .IP "\s-1SSL_OP_TLS_D5_BUG\s0" 4 .IX Item "SSL_OP_TLS_D5_BUG" \&... .IP "\s-1SSL_OP_TLS_BLOCK_PADDING_BUG\s0" 4 .IX Item "SSL_OP_TLS_BLOCK_PADDING_BUG" \&... .IP "\s-1SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS\s0" 4 .IX Item "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS" Disables a countermeasure against a \s-1SSL 3.0/TLS 1.0\s0 protocol vulnerability affecting \s-1CBC\s0 ciphers, which cannot be handled by some broken \s-1SSL\s0 implementations. This option has no effect for connections using other ciphers. .IP "\s-1SSL_OP_ALL\s0" 4 .IX Item "SSL_OP_ALL" All of the above bug workarounds. .PP It is usually safe to use \fB\s-1SSL_OP_ALL\s0\fR to enable the bug workaround options if compatibility with somewhat broken implementations is desired. .PP The following \fBmodifying\fR options are available: .IP "\s-1SSL_OP_TLS_ROLLBACK_BUG\s0" 4 .IX Item "SSL_OP_TLS_ROLLBACK_BUG" Disable version rollback attack detection. .Sp During the client key exchange, the client must send the same information about acceptable \s-1SSL/TLS\s0 protocol levels as during the first hello. Some clients violate this rule by adapting to the server's answer. (Example: the client sends a SSLv2 hello and accepts up to SSLv3.1=TLSv1, the server only understands up to SSLv3. In this case the client must still use the same SSLv3.1=TLSv1 announcement. Some clients step down to SSLv3 with respect to the server's answer and violate the version rollback protection.) .IP "\s-1SSL_OP_SINGLE_DH_USE\s0" 4 .IX Item "SSL_OP_SINGLE_DH_USE" Always create a new key when using temporary/ephemeral \s-1DH\s0 parameters (see \fISSL_CTX_set_tmp_dh_callback\fR\|(3)). This option must be used to prevent small subgroup attacks, when the \s-1DH\s0 parameters were not generated using \*(L"strong\*(R" primes (e.g. when using DSA-parameters, see \fIdhparam\fR\|(1)). If \*(L"strong\*(R" primes were used, it is not strictly necessary to generate a new \s-1DH\s0 key during each handshake but it is also recommended. \&\fB\s-1SSL_OP_SINGLE_DH_USE\s0\fR should therefore be enabled whenever temporary/ephemeral \s-1DH\s0 parameters are used. .IP "\s-1SSL_OP_EPHEMERAL_RSA\s0" 4 .IX Item "SSL_OP_EPHEMERAL_RSA" Always use ephemeral (temporary) \s-1RSA\s0 key when doing \s-1RSA\s0 operations (see \fISSL_CTX_set_tmp_rsa_callback\fR\|(3)). According to the specifications this is only done, when a \s-1RSA\s0 key can only be used for signature operations (namely under export ciphers with restricted \s-1RSA\s0 keylength). By setting this option, ephemeral \&\s-1RSA\s0 keys are always used. This option breaks compatibility with the \&\s-1SSL/TLS\s0 specifications and may lead to interoperability problems with clients and should therefore never be used. Ciphers with \s-1EDH \s0(ephemeral Diffie-Hellman) key exchange should be used instead. .IP "\s-1SSL_OP_CIPHER_SERVER_PREFERENCE\s0" 4 .IX Item "SSL_OP_CIPHER_SERVER_PREFERENCE" When choosing a cipher, use the server's preferences instead of the client preferences. When not set, the \s-1SSL\s0 server will always follow the clients preferences. When set, the SSLv3/TLSv1 server will choose following its own preferences. Because of the different protocol, for SSLv2 the server will send its list of preferences to the client and the client chooses. .IP "\s-1SSL_OP_NETSCAPE_CA_DN_BUG\s0" 4 .IX Item "SSL_OP_NETSCAPE_CA_DN_BUG" If we accept a netscape connection, demand a client cert, have a non-self-signed \s-1CA\s0 which does not have its \s-1CA\s0 in netscape, and the browser has a cert, it will crash/hang. Works for 3.x and 4.xbeta .IP "\s-1SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG\s0" 4 .IX Item "SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG" \&... .IP "SSL_OP_NO_SSLv2" 4 .IX Item "SSL_OP_NO_SSLv2" As of OpenBSD 5.6, this option has no effect as SSLv2 support has been removed. In previous versions it disabled use of the SSLv2 protocol. .IP "SSL_OP_NO_SSLv3" 4 .IX Item "SSL_OP_NO_SSLv3" Do not use the SSLv3 protocol. .IP "SSL_OP_NO_TLSv1" 4 .IX Item "SSL_OP_NO_TLSv1" Do not use the TLSv1.0 protocol. .IP "SSL_OP_NO_TLSv1_1" 4 .IX Item "SSL_OP_NO_TLSv1_1" Do not use the TLSv1.1 protocol. .IP "SSL_OP_NO_TLSv1_2" 4 .IX Item "SSL_OP_NO_TLSv1_2" Do not use the TLSv1.2 protocol. .IP "\s-1SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION\s0" 4 .IX Item "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION" When performing renegotiation as a server, always start a new session (i.e., session resumption requests are only accepted in the initial handshake). This option is not needed for clients. .IP "\s-1SSL_OP_NO_TICKET\s0" 4 .IX Item "SSL_OP_NO_TICKET" Normally clients and servers will, where possible, transparently make use of RFC4507bis tickets for stateless session resumption. .Sp If this option is set this functionality is disabled and tickets will not be used by clients or servers. .IP "\s-1SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION\s0" 4 .IX Item "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION" As of OpenBSD 5.6, this option has no effect. In previous versions it allowed legacy insecure renegotiation between OpenSSL and unpatched clients or servers. See the \fB\s-1SECURE RENEGOTIATION\s0\fR section for more details. .IP "\s-1SSL_OP_LEGACY_SERVER_CONNECT\s0" 4 .IX Item "SSL_OP_LEGACY_SERVER_CONNECT" Allow legacy insecure renegotiation between OpenSSL and unpatched servers \&\fBonly\fR: this option is currently set by default. See the \&\fB\s-1SECURE RENEGOTIATION\s0\fR section for more details. .SH "SECURE RENEGOTIATION" .IX Header "SECURE RENEGOTIATION" OpenSSL 0.9.8m and later always attempts to use secure renegotiation as described in \s-1RFC5746.\s0 This counters the prefix attack described in \&\s-1CVE\-2009\-3555\s0 and elsewhere. .PP The deprecated and highly broken SSLv2 protocol does not support renegotiation at all: its use is \fBstrongly\fR discouraged. .PP This attack has far reaching consequences which application writers should be aware of. In the description below an implementation supporting secure renegotiation is referred to as \fIpatched\fR. A server not supporting secure renegotiation is referred to as \fIunpatched\fR. .PP The following sections describe the operations permitted by OpenSSL's secure renegotiation implementation. .SS "Patched client and server" .IX Subsection "Patched client and server" Connections and renegotiation are always permitted by OpenSSL implementations. .SS "Unpatched client and patched OpenSSL server" .IX Subsection "Unpatched client and patched OpenSSL server" The initial connection succeeds but client renegotiation is denied by the server with a \fBno_renegotiation\fR warning alert if \s-1TLS\s0 v1.0 is used or a fatal \&\fBhandshake_failure\fR alert in \s-1SSL\s0 v3.0. .PP If the patched OpenSSL server attempts to renegotiate a fatal \&\fBhandshake_failure\fR alert is sent. This is because the server code may be unaware of the unpatched nature of the client. .PP \&\fB\s-1NB:\s0\fR a bug in OpenSSL clients earlier than 0.9.8m (all of which are unpatched) will result in the connection hanging if it receives a \&\fBno_renegotiation\fR alert. OpenSSL versions 0.9.8m and later will regard a \fBno_renegotiation\fR alert as fatal and respond with a fatal \&\fBhandshake_failure\fR alert. This is because the OpenSSL \s-1API\s0 currently has no provision to indicate to an application that a renegotiation attempt was refused. .SS "Patched OpenSSL client and unpatched server." .IX Subsection "Patched OpenSSL client and unpatched server." If the option \fB\s-1SSL_OP_LEGACY_SERVER_CONNECT\s0\fR is set then initial connections and renegotiation between patched OpenSSL clients and unpatched servers succeeds. If neither option is set then initial connections to unpatched servers will fail. .PP The option \fB\s-1SSL_OP_LEGACY_SERVER_CONNECT\s0\fR is currently set by default even though it has security implications: otherwise it would be impossible to connect to unpatched servers (i.e. all of them initially) and this is clearly not acceptable. Renegotiation is permitted because this does not add any additional security issues: during an attack clients do not see any renegotiations anyway. .PP As more servers become patched the option \fB\s-1SSL_OP_LEGACY_SERVER_CONNECT\s0\fR will \&\fBnot\fR be set by default in a future version of OpenSSL. .PP OpenSSL client applications wishing to ensure they can connect to unpatched servers should always \fBset\fR \fB\s-1SSL_OP_LEGACY_SERVER_CONNECT\s0\fR .PP OpenSSL client applications that want to ensure they can \fBnot\fR connect to unpatched servers (and thus avoid any security issues) should always \fBclear\fR \&\fB\s-1SSL_OP_LEGACY_SERVER_CONNECT\s0\fR using \fISSL_CTX_clear_options()\fR or \&\fISSL_clear_options()\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_set_options()\fR and \fISSL_set_options()\fR return the new options bitmask after adding \fBoptions\fR. .PP \&\fISSL_CTX_clear_options()\fR and \fISSL_clear_options()\fR return the new options bitmask after clearing \fBoptions\fR. .PP \&\fISSL_CTX_get_options()\fR and \fISSL_get_options()\fR return the current bitmask. .PP \&\fISSL_get_secure_renegotiation_support()\fR returns 1 is the peer supports secure renegotiation and 0 if it does not. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_new\fR\|(3), \fISSL_clear\fR\|(3), \&\fISSL_CTX_set_tmp_dh_callback\fR\|(3), \&\fISSL_CTX_set_tmp_rsa_callback\fR\|(3), \&\fIdhparam\fR\|(1) .SH "HISTORY" .IX Header "HISTORY" \&\fB\s-1SSL_OP_CIPHER_SERVER_PREFERENCE\s0\fR and \&\fB\s-1SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION\s0\fR have been added in OpenSSL 0.9.7. .PP \&\fB\s-1SSL_OP_TLS_ROLLBACK_BUG\s0\fR has been added in OpenSSL 0.9.6 and was automatically enabled with \fB\s-1SSL_OP_ALL\s0\fR. As of 0.9.7, it is no longer included in \fB\s-1SSL_OP_ALL\s0\fR and must be explicitly set. .PP \&\fB\s-1SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS\s0\fR has been added in OpenSSL 0.9.6e. Versions up to OpenSSL 0.9.6c do not include the countermeasure that can be disabled with this option (in OpenSSL 0.9.6d, it was always enabled). .PP \&\fISSL_CTX_clear_options()\fR and \fISSL_clear_options()\fR were first added in OpenSSL 0.9.8m. .PP \&\fB\s-1SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION\s0\fR, \fB\s-1SSL_OP_LEGACY_SERVER_CONNECT\s0\fR and the function \fISSL_get_secure_renegotiation_support()\fR were first added in OpenSSL 0.9.8m. .PP \&\fBSSL_OP_NO_SSLv2\fR and \fB\s-1SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION\s0\fR were changed to have no effect in OpenBSD 5.6. deps/libressl-pnacl-sys-2.1.6/libressl/man/Makefile.am0000644000175000017500000032207112360020744017552 0ustar include $(top_srcdir)/Makefile.am.common dist_man_MANS= dist_man_MANS += ASN1_OBJECT_new.3 dist_man_MANS += ASN1_STRING_length.3 dist_man_MANS += ASN1_STRING_new.3 dist_man_MANS += ASN1_STRING_print_ex.3 dist_man_MANS += ASN1_generate_nconf.3 dist_man_MANS += BF_set_key.3 dist_man_MANS += BIO.3 dist_man_MANS += BIO_ctrl.3 dist_man_MANS += BIO_f_base64.3 dist_man_MANS += BIO_f_buffer.3 dist_man_MANS += BIO_f_cipher.3 dist_man_MANS += BIO_f_md.3 dist_man_MANS += BIO_f_null.3 dist_man_MANS += BIO_find_type.3 dist_man_MANS += BIO_new.3 dist_man_MANS += BIO_new_CMS.3 dist_man_MANS += BIO_push.3 dist_man_MANS += BIO_read.3 dist_man_MANS += BIO_s_accept.3 dist_man_MANS += BIO_s_bio.3 dist_man_MANS += BIO_s_connect.3 dist_man_MANS += BIO_s_fd.3 dist_man_MANS += BIO_s_file.3 dist_man_MANS += BIO_s_mem.3 dist_man_MANS += BIO_s_null.3 dist_man_MANS += BIO_s_socket.3 dist_man_MANS += BIO_set_callback.3 dist_man_MANS += BIO_should_retry.3 dist_man_MANS += BN_BLINDING_new.3 dist_man_MANS += BN_CTX_new.3 dist_man_MANS += BN_CTX_start.3 dist_man_MANS += BN_add.3 dist_man_MANS += BN_add_word.3 dist_man_MANS += BN_bn2bin.3 dist_man_MANS += BN_cmp.3 dist_man_MANS += BN_copy.3 dist_man_MANS += BN_generate_prime.3 dist_man_MANS += BN_mod_inverse.3 dist_man_MANS += BN_mod_mul_montgomery.3 dist_man_MANS += BN_mod_mul_reciprocal.3 dist_man_MANS += BN_new.3 dist_man_MANS += BN_num_bytes.3 dist_man_MANS += BN_rand.3 dist_man_MANS += BN_set_bit.3 dist_man_MANS += BN_swap.3 dist_man_MANS += BN_zero.3 dist_man_MANS += BUF_MEM_new.3 dist_man_MANS += CMS_add0_cert.3 dist_man_MANS += CMS_add1_recipient_cert.3 dist_man_MANS += CMS_compress.3 dist_man_MANS += CMS_decrypt.3 dist_man_MANS += CMS_encrypt.3 dist_man_MANS += CMS_final.3 dist_man_MANS += CMS_get0_RecipientInfos.3 dist_man_MANS += CMS_get0_SignerInfos.3 dist_man_MANS += CMS_get0_type.3 dist_man_MANS += CMS_get1_ReceiptRequest.3 dist_man_MANS += CMS_sign.3 dist_man_MANS += CMS_sign_add1_signer.3 dist_man_MANS += CMS_sign_receipt.3 dist_man_MANS += CMS_uncompress.3 dist_man_MANS += CMS_verify.3 dist_man_MANS += CMS_verify_receipt.3 dist_man_MANS += CONF_modules_free.3 dist_man_MANS += CONF_modules_load_file.3 dist_man_MANS += CRYPTO_set_ex_data.3 dist_man_MANS += CRYPTO_set_locking_callback.3 dist_man_MANS += DES_set_key.3 dist_man_MANS += DH_generate_key.3 dist_man_MANS += DH_generate_parameters.3 dist_man_MANS += DH_get_ex_new_index.3 dist_man_MANS += DH_new.3 dist_man_MANS += DH_set_method.3 dist_man_MANS += DH_size.3 dist_man_MANS += DSA_SIG_new.3 dist_man_MANS += DSA_do_sign.3 dist_man_MANS += DSA_dup_DH.3 dist_man_MANS += DSA_generate_key.3 dist_man_MANS += DSA_generate_parameters.3 dist_man_MANS += DSA_get_ex_new_index.3 dist_man_MANS += DSA_new.3 dist_man_MANS += DSA_set_method.3 dist_man_MANS += DSA_sign.3 dist_man_MANS += DSA_size.3 dist_man_MANS += EC_GFp_simple_method.3 dist_man_MANS += EC_GROUP_copy.3 dist_man_MANS += EC_GROUP_new.3 dist_man_MANS += EC_KEY_new.3 dist_man_MANS += EC_POINT_add.3 dist_man_MANS += EC_POINT_new.3 dist_man_MANS += ERR.3 dist_man_MANS += ERR_GET_LIB.3 dist_man_MANS += ERR_clear_error.3 dist_man_MANS += ERR_error_string.3 dist_man_MANS += ERR_get_error.3 dist_man_MANS += ERR_load_crypto_strings.3 dist_man_MANS += ERR_load_strings.3 dist_man_MANS += ERR_print_errors.3 dist_man_MANS += ERR_put_error.3 dist_man_MANS += ERR_remove_state.3 dist_man_MANS += ERR_set_mark.3 dist_man_MANS += EVP_BytesToKey.3 dist_man_MANS += EVP_DigestInit.3 dist_man_MANS += EVP_DigestSignInit.3 dist_man_MANS += EVP_DigestVerifyInit.3 dist_man_MANS += EVP_EncryptInit.3 dist_man_MANS += EVP_OpenInit.3 dist_man_MANS += EVP_PKEY_CTX_ctrl.3 dist_man_MANS += EVP_PKEY_CTX_new.3 dist_man_MANS += EVP_PKEY_cmp.3 dist_man_MANS += EVP_PKEY_decrypt.3 dist_man_MANS += EVP_PKEY_derive.3 dist_man_MANS += EVP_PKEY_encrypt.3 dist_man_MANS += EVP_PKEY_get_default_digest.3 dist_man_MANS += EVP_PKEY_keygen.3 dist_man_MANS += EVP_PKEY_new.3 dist_man_MANS += EVP_PKEY_print_private.3 dist_man_MANS += EVP_PKEY_set1_RSA.3 dist_man_MANS += EVP_PKEY_sign.3 dist_man_MANS += EVP_PKEY_verify.3 dist_man_MANS += EVP_PKEY_verify_recover.3 dist_man_MANS += EVP_SealInit.3 dist_man_MANS += EVP_SignInit.3 dist_man_MANS += EVP_VerifyInit.3 dist_man_MANS += HMAC.3 dist_man_MANS += MD5.3 dist_man_MANS += OBJ_nid2obj.3 dist_man_MANS += OPENSSL_VERSION_NUMBER.3 dist_man_MANS += OPENSSL_config.3 dist_man_MANS += OPENSSL_load_builtin_modules.3 dist_man_MANS += OpenSSL_add_all_algorithms.3 dist_man_MANS += PEM_read_bio_PrivateKey.3 dist_man_MANS += PEM_write_bio_CMS_stream.3 dist_man_MANS += PEM_write_bio_PKCS7_stream.3 dist_man_MANS += PKCS12_create.3 dist_man_MANS += PKCS12_parse.3 dist_man_MANS += PKCS5_PBKDF2_HMAC.3 dist_man_MANS += PKCS7_decrypt.3 dist_man_MANS += PKCS7_encrypt.3 dist_man_MANS += PKCS7_sign.3 dist_man_MANS += PKCS7_sign_add_signer.3 dist_man_MANS += PKCS7_verify.3 dist_man_MANS += RAND.3 dist_man_MANS += RAND_add.3 dist_man_MANS += RAND_bytes.3 dist_man_MANS += RAND_cleanup.3 dist_man_MANS += RAND_load_file.3 dist_man_MANS += RAND_set_rand_method.3 dist_man_MANS += RC4.3 dist_man_MANS += RIPEMD160.3 dist_man_MANS += RSA_blinding_on.3 dist_man_MANS += RSA_check_key.3 dist_man_MANS += RSA_generate_key.3 dist_man_MANS += RSA_get_ex_new_index.3 dist_man_MANS += RSA_new.3 dist_man_MANS += RSA_padding_add_PKCS1_type_1.3 dist_man_MANS += RSA_print.3 dist_man_MANS += RSA_private_encrypt.3 dist_man_MANS += RSA_public_encrypt.3 dist_man_MANS += RSA_set_method.3 dist_man_MANS += RSA_sign.3 dist_man_MANS += RSA_sign_ASN1_OCTET_STRING.3 dist_man_MANS += RSA_size.3 dist_man_MANS += SHA1.3 dist_man_MANS += SMIME_read_CMS.3 dist_man_MANS += SMIME_read_PKCS7.3 dist_man_MANS += SMIME_write_CMS.3 dist_man_MANS += SMIME_write_PKCS7.3 dist_man_MANS += X509_NAME_ENTRY_get_object.3 dist_man_MANS += X509_NAME_add_entry_by_txt.3 dist_man_MANS += X509_NAME_get_index_by_NID.3 dist_man_MANS += X509_NAME_print_ex.3 dist_man_MANS += X509_STORE_CTX_get_error.3 dist_man_MANS += X509_STORE_CTX_get_ex_new_index.3 dist_man_MANS += X509_STORE_CTX_new.3 dist_man_MANS += X509_STORE_CTX_set_verify_cb.3 dist_man_MANS += X509_STORE_set_verify_cb_func.3 dist_man_MANS += X509_VERIFY_PARAM_set_flags.3 dist_man_MANS += X509_new.3 dist_man_MANS += X509_verify_cert.3 dist_man_MANS += bn.3 dist_man_MANS += bn_internal.3 dist_man_MANS += crypto.3 dist_man_MANS += d2i_ASN1_OBJECT.3 dist_man_MANS += d2i_DHparams.3 dist_man_MANS += d2i_DSAPublicKey.3 dist_man_MANS += d2i_ECPKParameters.3 dist_man_MANS += d2i_PKCS8PrivateKey.3 dist_man_MANS += d2i_RSAPublicKey.3 dist_man_MANS += d2i_X509.3 dist_man_MANS += d2i_X509_ALGOR.3 dist_man_MANS += d2i_X509_CRL.3 dist_man_MANS += d2i_X509_NAME.3 dist_man_MANS += d2i_X509_REQ.3 dist_man_MANS += d2i_X509_SIG.3 dist_man_MANS += dh.3 dist_man_MANS += dsa.3 dist_man_MANS += ec.3 dist_man_MANS += ecdsa.3 dist_man_MANS += engine.3 dist_man_MANS += evp.3 dist_man_MANS += i2d_CMS_bio_stream.3 dist_man_MANS += i2d_PKCS7_bio_stream.3 dist_man_MANS += lh_stats.3 dist_man_MANS += lhash.3 dist_man_MANS += rsa.3 dist_man_MANS += ui.3 dist_man_MANS += ui_compat.3 dist_man_MANS += x509.3 dist_man_MANS += BIO_f_ssl.3 dist_man_MANS += SSL_CIPHER_get_name.3 dist_man_MANS += SSL_COMP_add_compression_method.3 dist_man_MANS += SSL_CTX_add_extra_chain_cert.3 dist_man_MANS += SSL_CTX_add_session.3 dist_man_MANS += SSL_CTX_ctrl.3 dist_man_MANS += SSL_CTX_flush_sessions.3 dist_man_MANS += SSL_CTX_free.3 dist_man_MANS += SSL_CTX_get_ex_new_index.3 dist_man_MANS += SSL_CTX_get_verify_mode.3 dist_man_MANS += SSL_CTX_load_verify_locations.3 dist_man_MANS += SSL_CTX_new.3 dist_man_MANS += SSL_CTX_sess_number.3 dist_man_MANS += SSL_CTX_sess_set_cache_size.3 dist_man_MANS += SSL_CTX_sess_set_get_cb.3 dist_man_MANS += SSL_CTX_sessions.3 dist_man_MANS += SSL_CTX_set_cert_store.3 dist_man_MANS += SSL_CTX_set_cert_verify_callback.3 dist_man_MANS += SSL_CTX_set_cipher_list.3 dist_man_MANS += SSL_CTX_set_client_CA_list.3 dist_man_MANS += SSL_CTX_set_client_cert_cb.3 dist_man_MANS += SSL_CTX_set_default_passwd_cb.3 dist_man_MANS += SSL_CTX_set_generate_session_id.3 dist_man_MANS += SSL_CTX_set_info_callback.3 dist_man_MANS += SSL_CTX_set_max_cert_list.3 dist_man_MANS += SSL_CTX_set_mode.3 dist_man_MANS += SSL_CTX_set_msg_callback.3 dist_man_MANS += SSL_CTX_set_options.3 dist_man_MANS += SSL_CTX_set_psk_client_callback.3 dist_man_MANS += SSL_CTX_set_quiet_shutdown.3 dist_man_MANS += SSL_CTX_set_session_cache_mode.3 dist_man_MANS += SSL_CTX_set_session_id_context.3 dist_man_MANS += SSL_CTX_set_ssl_version.3 dist_man_MANS += SSL_CTX_set_timeout.3 dist_man_MANS += SSL_CTX_set_tmp_dh_callback.3 dist_man_MANS += SSL_CTX_set_tmp_rsa_callback.3 dist_man_MANS += SSL_CTX_set_verify.3 dist_man_MANS += SSL_CTX_use_certificate.3 dist_man_MANS += SSL_CTX_use_psk_identity_hint.3 dist_man_MANS += SSL_SESSION_free.3 dist_man_MANS += SSL_SESSION_get_ex_new_index.3 dist_man_MANS += SSL_SESSION_get_time.3 dist_man_MANS += SSL_accept.3 dist_man_MANS += SSL_alert_type_string.3 dist_man_MANS += SSL_clear.3 dist_man_MANS += SSL_connect.3 dist_man_MANS += SSL_do_handshake.3 dist_man_MANS += SSL_free.3 dist_man_MANS += SSL_get_SSL_CTX.3 dist_man_MANS += SSL_get_ciphers.3 dist_man_MANS += SSL_get_client_CA_list.3 dist_man_MANS += SSL_get_current_cipher.3 dist_man_MANS += SSL_get_default_timeout.3 dist_man_MANS += SSL_get_error.3 dist_man_MANS += SSL_get_ex_data_X509_STORE_CTX_idx.3 dist_man_MANS += SSL_get_ex_new_index.3 dist_man_MANS += SSL_get_fd.3 dist_man_MANS += SSL_get_peer_cert_chain.3 dist_man_MANS += SSL_get_peer_certificate.3 dist_man_MANS += SSL_get_psk_identity.3 dist_man_MANS += SSL_get_rbio.3 dist_man_MANS += SSL_get_session.3 dist_man_MANS += SSL_get_verify_result.3 dist_man_MANS += SSL_get_version.3 dist_man_MANS += SSL_library_init.3 dist_man_MANS += SSL_load_client_CA_file.3 dist_man_MANS += SSL_new.3 dist_man_MANS += SSL_pending.3 dist_man_MANS += SSL_read.3 dist_man_MANS += SSL_rstate_string.3 dist_man_MANS += SSL_session_reused.3 dist_man_MANS += SSL_set_bio.3 dist_man_MANS += SSL_set_connect_state.3 dist_man_MANS += SSL_set_fd.3 dist_man_MANS += SSL_set_session.3 dist_man_MANS += SSL_set_shutdown.3 dist_man_MANS += SSL_set_verify_result.3 dist_man_MANS += SSL_shutdown.3 dist_man_MANS += SSL_state_string.3 dist_man_MANS += SSL_want.3 dist_man_MANS += SSL_write.3 dist_man_MANS += d2i_SSL_SESSION.3 dist_man_MANS += ssl.3 dist_man_MANS += asn1parse.1 dist_man_MANS += ca.1 dist_man_MANS += ciphers.1 dist_man_MANS += cms.1 dist_man_MANS += config.1 dist_man_MANS += crl.1 dist_man_MANS += crl2pkcs7.1 dist_man_MANS += dgst.1 dist_man_MANS += dhparam.1 dist_man_MANS += dsa.1 dist_man_MANS += dsaparam.1 dist_man_MANS += ec.1 dist_man_MANS += ecparam.1 dist_man_MANS += enc.1 dist_man_MANS += errstr.1 dist_man_MANS += gendsa.1 dist_man_MANS += genpkey.1 dist_man_MANS += genrsa.1 dist_man_MANS += nseq.1 dist_man_MANS += ocsp.1 dist_man_MANS += openssl.1 dist_man_MANS += passwd.1 dist_man_MANS += pkcs12.1 dist_man_MANS += pkcs7.1 dist_man_MANS += pkcs8.1 dist_man_MANS += pkey.1 dist_man_MANS += pkeyparam.1 dist_man_MANS += pkeyutl.1 dist_man_MANS += rand.1 dist_man_MANS += req.1 dist_man_MANS += rsa.1 dist_man_MANS += rsautl.1 dist_man_MANS += s_client.1 dist_man_MANS += s_server.1 dist_man_MANS += s_time.1 dist_man_MANS += sess_id.1 dist_man_MANS += smime.1 dist_man_MANS += speed.1 dist_man_MANS += spkac.1 dist_man_MANS += ts.1 dist_man_MANS += verify.1 dist_man_MANS += version.1 dist_man_MANS += x509.1 dist_man_MANS += x509v3_config.1 dist_man_MANS += openssl.1 install-data-hook: ln -f $(DESTDIR)$(mandir)/man3/ASN1_OBJECT_new.3 $(DESTDIR)$(mandir)/man3/ASN1_OBJECT_free.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_length.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_cmp.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_length.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_data.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_length.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_dup.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_length.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_set.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_length.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_to_UTF8.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_length.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_type.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_new.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_free.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_new.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_type_new.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_print_ex.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_print.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_print_ex.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_print_ex_fp.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_generate_nconf.3 $(DESTDIR)$(mandir)/man3/ASN1_generate_v3.3 ln -f $(DESTDIR)$(mandir)/man3/BF_set_key.3 $(DESTDIR)$(mandir)/man3/BF_cbc_encrypt.3 ln -f $(DESTDIR)$(mandir)/man3/BF_set_key.3 $(DESTDIR)$(mandir)/man3/BF_cfb64_encrypt.3 ln -f $(DESTDIR)$(mandir)/man3/BF_set_key.3 $(DESTDIR)$(mandir)/man3/BF_decrypt.3 ln -f $(DESTDIR)$(mandir)/man3/BF_set_key.3 $(DESTDIR)$(mandir)/man3/BF_ecb_encrypt.3 ln -f $(DESTDIR)$(mandir)/man3/BF_set_key.3 $(DESTDIR)$(mandir)/man3/BF_encrypt.3 ln -f $(DESTDIR)$(mandir)/man3/BF_set_key.3 $(DESTDIR)$(mandir)/man3/BF_ofb64_encrypt.3 ln -f $(DESTDIR)$(mandir)/man3/BF_set_key.3 $(DESTDIR)$(mandir)/man3/BF_options.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_callback_ctrl.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_ctrl_pending.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_ctrl_wpending.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_eof.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_flush.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_get_close.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_get_info_callback.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_int_ctrl.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_pending.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_ptr_ctrl.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_reset.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_seek.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_set_close.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_set_info_callback.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_tell.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_buffer.3 $(DESTDIR)$(mandir)/man3/BIO_get_buffer_num_lines.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_buffer.3 $(DESTDIR)$(mandir)/man3/BIO_set_buffer_read_data.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_buffer.3 $(DESTDIR)$(mandir)/man3/BIO_set_buffer_size.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_buffer.3 $(DESTDIR)$(mandir)/man3/BIO_set_read_buffer_size.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_buffer.3 $(DESTDIR)$(mandir)/man3/BIO_set_write_buffer_size.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_cipher.3 $(DESTDIR)$(mandir)/man3/BIO_get_cipher_ctx.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_cipher.3 $(DESTDIR)$(mandir)/man3/BIO_get_cipher_status.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_cipher.3 $(DESTDIR)$(mandir)/man3/BIO_set_cipher.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_md.3 $(DESTDIR)$(mandir)/man3/BIO_get_md.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_md.3 $(DESTDIR)$(mandir)/man3/BIO_get_md_ctx.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_md.3 $(DESTDIR)$(mandir)/man3/BIO_set_md.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_find_type.3 $(DESTDIR)$(mandir)/man3/BIO_method_type.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_find_type.3 $(DESTDIR)$(mandir)/man3/BIO_next.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_new.3 $(DESTDIR)$(mandir)/man3/BIO_free.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_new.3 $(DESTDIR)$(mandir)/man3/BIO_free_all.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_new.3 $(DESTDIR)$(mandir)/man3/BIO_set.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_new.3 $(DESTDIR)$(mandir)/man3/BIO_vfree.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_push.3 $(DESTDIR)$(mandir)/man3/BIO_pop.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_read.3 $(DESTDIR)$(mandir)/man3/BIO_gets.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_read.3 $(DESTDIR)$(mandir)/man3/BIO_puts.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_read.3 $(DESTDIR)$(mandir)/man3/BIO_write.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_accept.3 $(DESTDIR)$(mandir)/man3/BIO_do_accept.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_accept.3 $(DESTDIR)$(mandir)/man3/BIO_get_accept_port.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_accept.3 $(DESTDIR)$(mandir)/man3/BIO_get_bind_mode.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_accept.3 $(DESTDIR)$(mandir)/man3/BIO_new_accept.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_accept.3 $(DESTDIR)$(mandir)/man3/BIO_set_accept_bios.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_accept.3 $(DESTDIR)$(mandir)/man3/BIO_set_accept_port.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_accept.3 $(DESTDIR)$(mandir)/man3/BIO_set_bind_mode.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_accept.3 $(DESTDIR)$(mandir)/man3/BIO_set_nbio_accept.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_ctrl_get_read_request.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_ctrl_get_write_guarantee.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_ctrl_reset_read_request.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_destroy_bio_pair.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_get_read_request.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_get_write_buf_size.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_get_write_guarantee.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_make_bio_pair.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_new_bio_pair.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_set_write_buf_size.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_shutdown_wr.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_do_connect.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_get_conn_hostname.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_get_conn_int_port.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_get_conn_ip.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_get_conn_port.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_new_connect.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_set_conn_hostname.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_set_conn_int_port.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_set_conn_ip.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_set_conn_port.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_set_nbio.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_fd.3 $(DESTDIR)$(mandir)/man3/BIO_get_fd.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_fd.3 $(DESTDIR)$(mandir)/man3/BIO_new_fd.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_fd.3 $(DESTDIR)$(mandir)/man3/BIO_set_fd.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_file.3 $(DESTDIR)$(mandir)/man3/BIO_append_filename.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_file.3 $(DESTDIR)$(mandir)/man3/BIO_get_fp.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_file.3 $(DESTDIR)$(mandir)/man3/BIO_new_file.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_file.3 $(DESTDIR)$(mandir)/man3/BIO_new_fp.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_file.3 $(DESTDIR)$(mandir)/man3/BIO_read_filename.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_file.3 $(DESTDIR)$(mandir)/man3/BIO_rw_filename.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_file.3 $(DESTDIR)$(mandir)/man3/BIO_set_fp.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_file.3 $(DESTDIR)$(mandir)/man3/BIO_write_filename.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_mem.3 $(DESTDIR)$(mandir)/man3/BIO_get_mem_data.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_mem.3 $(DESTDIR)$(mandir)/man3/BIO_get_mem_ptr.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_mem.3 $(DESTDIR)$(mandir)/man3/BIO_new_mem_buf.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_mem.3 $(DESTDIR)$(mandir)/man3/BIO_set_mem_buf.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_mem.3 $(DESTDIR)$(mandir)/man3/BIO_set_mem_eof_return.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_socket.3 $(DESTDIR)$(mandir)/man3/BIO_new_socket.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_set_callback.3 $(DESTDIR)$(mandir)/man3/BIO_debug_callback.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_set_callback.3 $(DESTDIR)$(mandir)/man3/BIO_get_callback.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_set_callback.3 $(DESTDIR)$(mandir)/man3/BIO_get_callback_arg.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_set_callback.3 $(DESTDIR)$(mandir)/man3/BIO_set_callback_arg.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_should_retry.3 $(DESTDIR)$(mandir)/man3/BIO_get_retry_BIO.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_should_retry.3 $(DESTDIR)$(mandir)/man3/BIO_get_retry_reason.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_should_retry.3 $(DESTDIR)$(mandir)/man3/BIO_retry_type.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_should_retry.3 $(DESTDIR)$(mandir)/man3/BIO_should_io_special.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_should_retry.3 $(DESTDIR)$(mandir)/man3/BIO_should_read.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_should_retry.3 $(DESTDIR)$(mandir)/man3/BIO_should_write.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_convert.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_convert_ex.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_create_param.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_free.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_get_thread_id.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_invert.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_invert_ex.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_get_flags.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_set_flags.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_set_thread_id.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_thread_id.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_update.3 ln -f $(DESTDIR)$(mandir)/man3/BN_CTX_new.3 $(DESTDIR)$(mandir)/man3/BN_CTX_free.3 ln -f $(DESTDIR)$(mandir)/man3/BN_CTX_new.3 $(DESTDIR)$(mandir)/man3/BN_CTX_init.3 ln -f $(DESTDIR)$(mandir)/man3/BN_CTX_start.3 $(DESTDIR)$(mandir)/man3/BN_CTX_end.3 ln -f $(DESTDIR)$(mandir)/man3/BN_CTX_start.3 $(DESTDIR)$(mandir)/man3/BN_CTX_get.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_div.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_exp.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_gcd.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_mod.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_mod_exp.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_mod_mul.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_mul.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_sqr.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_sub.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add_word.3 $(DESTDIR)$(mandir)/man3/BN_div_word.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add_word.3 $(DESTDIR)$(mandir)/man3/BN_mod_word.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add_word.3 $(DESTDIR)$(mandir)/man3/BN_mul_word.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add_word.3 $(DESTDIR)$(mandir)/man3/BN_sub_word.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_bin2bn.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_bn2dec.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_bn2hex.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_bn2mpi.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_dec2bn.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_hex2bn.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_mpi2bn.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_print.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_print_fp.3 ln -f $(DESTDIR)$(mandir)/man3/BN_cmp.3 $(DESTDIR)$(mandir)/man3/BN_is_odd.3 ln -f $(DESTDIR)$(mandir)/man3/BN_cmp.3 $(DESTDIR)$(mandir)/man3/BN_is_one.3 ln -f $(DESTDIR)$(mandir)/man3/BN_cmp.3 $(DESTDIR)$(mandir)/man3/BN_is_word.3 ln -f $(DESTDIR)$(mandir)/man3/BN_cmp.3 $(DESTDIR)$(mandir)/man3/BN_is_zero.3 ln -f $(DESTDIR)$(mandir)/man3/BN_cmp.3 $(DESTDIR)$(mandir)/man3/BN_ucmp.3 ln -f $(DESTDIR)$(mandir)/man3/BN_copy.3 $(DESTDIR)$(mandir)/man3/BN_dup.3 ln -f $(DESTDIR)$(mandir)/man3/BN_generate_prime.3 $(DESTDIR)$(mandir)/man3/BN_GENCB_call.3 ln -f $(DESTDIR)$(mandir)/man3/BN_generate_prime.3 $(DESTDIR)$(mandir)/man3/BN_GENCB_set.3 ln -f $(DESTDIR)$(mandir)/man3/BN_generate_prime.3 $(DESTDIR)$(mandir)/man3/BN_GENCB_set_old.3 ln -f $(DESTDIR)$(mandir)/man3/BN_generate_prime.3 $(DESTDIR)$(mandir)/man3/BN_is_prime.3 ln -f $(DESTDIR)$(mandir)/man3/BN_generate_prime.3 $(DESTDIR)$(mandir)/man3/BN_is_prime_ex.3 ln -f $(DESTDIR)$(mandir)/man3/BN_generate_prime.3 $(DESTDIR)$(mandir)/man3/BN_is_prime_fasttest.3 ln -f $(DESTDIR)$(mandir)/man3/BN_generate_prime.3 $(DESTDIR)$(mandir)/man3/BN_is_prime_fasttest_ex.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_montgomery.3 $(DESTDIR)$(mandir)/man3/BN_MONT_CTX_copy.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_montgomery.3 $(DESTDIR)$(mandir)/man3/BN_MONT_CTX_free.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_montgomery.3 $(DESTDIR)$(mandir)/man3/BN_MONT_CTX_init.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_montgomery.3 $(DESTDIR)$(mandir)/man3/BN_MONT_CTX_new.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_montgomery.3 $(DESTDIR)$(mandir)/man3/BN_MONT_CTX_set.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_montgomery.3 $(DESTDIR)$(mandir)/man3/BN_from_montgomery.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_montgomery.3 $(DESTDIR)$(mandir)/man3/BN_to_montgomery.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_reciprocal.3 $(DESTDIR)$(mandir)/man3/BN_RECP_CTX_free.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_reciprocal.3 $(DESTDIR)$(mandir)/man3/BN_RECP_CTX_init.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_reciprocal.3 $(DESTDIR)$(mandir)/man3/BN_RECP_CTX_new.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_reciprocal.3 $(DESTDIR)$(mandir)/man3/BN_RECP_CTX_set.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_reciprocal.3 $(DESTDIR)$(mandir)/man3/BN_div_recp.3 ln -f $(DESTDIR)$(mandir)/man3/BN_new.3 $(DESTDIR)$(mandir)/man3/BN_clear.3 ln -f $(DESTDIR)$(mandir)/man3/BN_new.3 $(DESTDIR)$(mandir)/man3/BN_clear_free.3 ln -f $(DESTDIR)$(mandir)/man3/BN_new.3 $(DESTDIR)$(mandir)/man3/BN_free.3 ln -f $(DESTDIR)$(mandir)/man3/BN_new.3 $(DESTDIR)$(mandir)/man3/BN_init.3 ln -f $(DESTDIR)$(mandir)/man3/BN_num_bytes.3 $(DESTDIR)$(mandir)/man3/BN_num_bits.3 ln -f $(DESTDIR)$(mandir)/man3/BN_num_bytes.3 $(DESTDIR)$(mandir)/man3/BN_num_bits_word.3 ln -f $(DESTDIR)$(mandir)/man3/BN_rand.3 $(DESTDIR)$(mandir)/man3/BN_pseudo_rand.3 ln -f $(DESTDIR)$(mandir)/man3/BN_rand.3 $(DESTDIR)$(mandir)/man3/BN_pseudo_rand_range.3 ln -f $(DESTDIR)$(mandir)/man3/BN_rand.3 $(DESTDIR)$(mandir)/man3/BN_rand_range.3 ln -f $(DESTDIR)$(mandir)/man3/BN_set_bit.3 $(DESTDIR)$(mandir)/man3/BN_clear_bit.3 ln -f $(DESTDIR)$(mandir)/man3/BN_set_bit.3 $(DESTDIR)$(mandir)/man3/BN_is_bit_set.3 ln -f $(DESTDIR)$(mandir)/man3/BN_set_bit.3 $(DESTDIR)$(mandir)/man3/BN_lshift.3 ln -f $(DESTDIR)$(mandir)/man3/BN_set_bit.3 $(DESTDIR)$(mandir)/man3/BN_lshift1.3 ln -f $(DESTDIR)$(mandir)/man3/BN_set_bit.3 $(DESTDIR)$(mandir)/man3/BN_mask_bits.3 ln -f $(DESTDIR)$(mandir)/man3/BN_set_bit.3 $(DESTDIR)$(mandir)/man3/BN_rshift.3 ln -f $(DESTDIR)$(mandir)/man3/BN_set_bit.3 $(DESTDIR)$(mandir)/man3/BN_rshift1.3 ln -f $(DESTDIR)$(mandir)/man3/BN_zero.3 $(DESTDIR)$(mandir)/man3/BN_get_word.3 ln -f $(DESTDIR)$(mandir)/man3/BN_zero.3 $(DESTDIR)$(mandir)/man3/BN_one.3 ln -f $(DESTDIR)$(mandir)/man3/BN_zero.3 $(DESTDIR)$(mandir)/man3/BN_set_word.3 ln -f $(DESTDIR)$(mandir)/man3/BN_zero.3 $(DESTDIR)$(mandir)/man3/BN_value_one.3 ln -f $(DESTDIR)$(mandir)/man3/BUF_MEM_new.3 $(DESTDIR)$(mandir)/man3/BUF_MEM_free.3 ln -f $(DESTDIR)$(mandir)/man3/BUF_MEM_new.3 $(DESTDIR)$(mandir)/man3/BUF_MEM_grow.3 ln -f $(DESTDIR)$(mandir)/man3/BUF_MEM_new.3 $(DESTDIR)$(mandir)/man3/BUF_strdup.3 ln -f $(DESTDIR)$(mandir)/man3/CONF_modules_free.3 $(DESTDIR)$(mandir)/man3/CONF_modules_finish.3 ln -f $(DESTDIR)$(mandir)/man3/CONF_modules_free.3 $(DESTDIR)$(mandir)/man3/CONF_modules_unload.3 ln -f $(DESTDIR)$(mandir)/man3/CONF_modules_load_file.3 $(DESTDIR)$(mandir)/man3/CONF_modules_load.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_ex_data.3 $(DESTDIR)$(mandir)/man3/CRYPTO_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_add.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_add_lock.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_destroy_dynlockid.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_get_new_dynlockid.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_lock.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_num_locks.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_r_lock.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_r_unlock.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_set_dynlock_create_callback.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_set_dynlock_destroy_callback.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_set_dynlock_lock_callback.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_set_id_callback.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_w_lock.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_w_unlock.3 ln -f $(DESTDIR)$(mandir)/man3/DH_generate_key.3 $(DESTDIR)$(mandir)/man3/DH_compute_key.3 ln -f $(DESTDIR)$(mandir)/man3/DH_generate_parameters.3 $(DESTDIR)$(mandir)/man3/DH_check.3 ln -f $(DESTDIR)$(mandir)/man3/DH_generate_parameters.3 $(DESTDIR)$(mandir)/man3/DH_generate_parameters_ex.3 ln -f $(DESTDIR)$(mandir)/man3/DH_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/DH_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/DH_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/DH_set_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/DH_new.3 $(DESTDIR)$(mandir)/man3/DH_free.3 ln -f $(DESTDIR)$(mandir)/man3/DH_set_method.3 $(DESTDIR)$(mandir)/man3/DH_OpenSSL.3 ln -f $(DESTDIR)$(mandir)/man3/DH_set_method.3 $(DESTDIR)$(mandir)/man3/DH_get_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/DH_set_method.3 $(DESTDIR)$(mandir)/man3/DH_get_default_openssl_method.3 ln -f $(DESTDIR)$(mandir)/man3/DH_set_method.3 $(DESTDIR)$(mandir)/man3/DH_new_method.3 ln -f $(DESTDIR)$(mandir)/man3/DH_set_method.3 $(DESTDIR)$(mandir)/man3/DH_set_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/DH_set_method.3 $(DESTDIR)$(mandir)/man3/DH_set_default_openssl_method.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_generate_parameters.3 $(DESTDIR)$(mandir)/man3/DSA_generate_parameters_ex.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_new.3 $(DESTDIR)$(mandir)/man3/DSA_free.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_set_method.3 $(DESTDIR)$(mandir)/man3/DSA_OpenSSL.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_set_method.3 $(DESTDIR)$(mandir)/man3/DSA_get_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_set_method.3 $(DESTDIR)$(mandir)/man3/DSA_get_default_openssl_method.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_set_method.3 $(DESTDIR)$(mandir)/man3/DSA_new_method.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_set_method.3 $(DESTDIR)$(mandir)/man3/DSA_set_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_set_method.3 $(DESTDIR)$(mandir)/man3/DSA_set_default_openssl_method.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_sign.3 $(DESTDIR)$(mandir)/man3/DSA_sign_setup.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_sign.3 $(DESTDIR)$(mandir)/man3/DSA_verify.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GFp_simple_method.3 $(DESTDIR)$(mandir)/man3/EC_GF2m_simple_method.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GFp_simple_method.3 $(DESTDIR)$(mandir)/man3/EC_GFp_mont_method.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GFp_simple_method.3 $(DESTDIR)$(mandir)/man3/EC_GFp_nist_method.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GFp_simple_method.3 $(DESTDIR)$(mandir)/man3/EC_GFp_nistp224_method.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GFp_simple_method.3 $(DESTDIR)$(mandir)/man3/EC_GFp_nistp256_method.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GFp_simple_method.3 $(DESTDIR)$(mandir)/man3/EC_GFp_nistp521_method.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GFp_simple_method.3 $(DESTDIR)$(mandir)/man3/EC_METHOD_get_field_type.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_check.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_check_discriminant.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_cmp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_dup.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get0_generator.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get0_seed.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_asn1_flag.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_basis_type.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_cofactor.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_curve_name.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_degree.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_order.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_pentanomial_basis.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_point_conversion_form.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_seed_len.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_trinomial_basis.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_method_of.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_set_asn1_flag.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_set_curve_name.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_set_point_conversion_form.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_set_seed.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_set_generator.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_clear_free.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_free.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_curve_GF2m.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_curve_GFp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_new_by_curve_name.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_new_curve_GF2m.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_new_curve_GFp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_set_curve_GF2m.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_set_curve_GFp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_get_builtin_curves.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_check_key.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_clear_flags.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_copy.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_dup.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_free.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_generate_key.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_get0_group.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_get0_private_key.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_get0_public_key.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_get_conv_form.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_get_enc_flags.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_get_flags.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_get_key_method_data.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_insert_key_method_data.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_new_by_curve_name.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_precompute_mult.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_set_asn1_flag.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_set_conv_form.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_set_enc_flags.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_set_flags.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_set_group.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_set_private_key.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_set_public_key.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_set_public_key_affine_coordinates.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_up_ref.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_have_precompute_mult.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_precompute_mult.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINT_cmp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINT_dbl.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINT_invert.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINT_is_at_infinity.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINT_is_on_curve.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINT_make_affine.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINT_mul.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINTs_make_affine.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINTs_mul.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_bn2point.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_clear_free.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_copy.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_dup.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_free.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_get_Jprojective_coordinates_GFp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_get_affine_coordinates_GF2m.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_get_affine_coordinates_GFp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_hex2point.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_method_of.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_oct2point.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_point2bn.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_point2hex.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_point2oct.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_set_Jprojective_coordinates.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_set_affine_coordinates_GF2m.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_set_affine_coordinates_GFp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_set_compressed_coordinates_GF2m.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_set_compressed_coordinates_GFp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_set_to_infinity.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_GET_LIB.3 $(DESTDIR)$(mandir)/man3/ERR_GET_FUNC.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_GET_LIB.3 $(DESTDIR)$(mandir)/man3/ERR_GET_REASON.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_error_string.3 $(DESTDIR)$(mandir)/man3/ERR_error_string_n.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_error_string.3 $(DESTDIR)$(mandir)/man3/ERR_func_error_string.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_error_string.3 $(DESTDIR)$(mandir)/man3/ERR_lib_error_string.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_error_string.3 $(DESTDIR)$(mandir)/man3/ERR_reason_error_string.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_get_error.3 $(DESTDIR)$(mandir)/man3/ERR_get_error_line.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_get_error.3 $(DESTDIR)$(mandir)/man3/ERR_get_error_line_data.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_get_error.3 $(DESTDIR)$(mandir)/man3/ERR_peek_error.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_get_error.3 $(DESTDIR)$(mandir)/man3/ERR_peek_error_line.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_get_error.3 $(DESTDIR)$(mandir)/man3/ERR_peek_error_line_data.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_load_crypto_strings.3 $(DESTDIR)$(mandir)/man3/ERR_free_strings.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_load_strings.3 $(DESTDIR)$(mandir)/man3/ERR_PACK.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_load_strings.3 $(DESTDIR)$(mandir)/man3/ERR_get_next_error_library.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_print_errors.3 $(DESTDIR)$(mandir)/man3/ERR_print_errors_fp.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_put_error.3 $(DESTDIR)$(mandir)/man3/ERR_add_error_data.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_remove_state.3 $(DESTDIR)$(mandir)/man3/ERR_remove_thread_state.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_set_mark.3 $(DESTDIR)$(mandir)/man3/ERR_pop_to_mark.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_DigestFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_DigestUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_CTX_block_size.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_CTX_copy.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_CTX_md.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_CTX_size.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_CTX_type.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_block_size.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_pkey_type.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_size.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_type.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_dss.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_dss1.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_get_digestbyname.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_get_digestbynid.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_get_digestbyobj.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_md2.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_md5.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_md_null.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_mdc2.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_ripemd160.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_sha.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_sha1.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestSignInit.3 $(DESTDIR)$(mandir)/man3/EVP_DigestSignUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestSignInit.3 $(DESTDIR)$(mandir)/man3/EVP_DigestSignFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestVerifyInit.3 $(DESTDIR)$(mandir)/man3/EVP_DigestVerifyUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestVerifyInit.3 $(DESTDIR)$(mandir)/man3/EVP_DigestVerifyFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_block_size.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_cipher.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_cleanup.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_ctrl.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_iv_length.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_key_length.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_nid.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_set_key_length.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_type.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_asn1_to_param.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_block_size.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_iv_length.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_key_length.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_nid.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_param_to_asn1.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_type.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CipherFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CipherInit.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CipherUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_DecryptFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_DecryptInit.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_DecryptUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_EncryptFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_EncryptUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_aes_128_ccm.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_aes_128_gcm.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_aes_192_ccm.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_aes_192_gcm.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_aes_256_ccm.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_aes_256_gcm.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_bf_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_bf_cfb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_bf_ecb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_bf_ofb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_cast5_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_cast5_cfb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_cast5_ecb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_cast5_ofb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_cfb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ecb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ede.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ede3.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ede3_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ede3_cfb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ede3_ofb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ede_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ede_cfb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ede_ofb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ofb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_desx_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_enc_null.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_get_cipherbyname.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_get_cipherbynid.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_get_cipherbyobj.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_idea_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_idea_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_idea_cfb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_idea_ecb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_idea_ofb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc2_40_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc2_64_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc2_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc2_cfb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc2_ecb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc2_ofb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc4.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc4_40.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc5_32_12_16_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc5_32_12_16_cfb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc5_32_12_16_ecb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc5_32_12_16_ofb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_OpenInit.3 $(DESTDIR)$(mandir)/man3/EVP_OpenFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_OpenInit.3 $(DESTDIR)$(mandir)/man3/EVP_OpenUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_dh_paramgen_generator.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_dh_paramgen_prime_len.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_dsa_paramgen_bits.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_ec_paramgen_curve_nid.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_rsa_keygen_pubexp.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_rsa_padding.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_rsa_pss_saltlen.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_rsa_rsa_keygen_bits.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_signature_md.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_ctrl_str.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_get_default_digest_nid.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_new.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_new_id.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_new.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_dup.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_new.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_free.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_cmp.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_copy_parameters.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_cmp.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_missing_parameters.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_cmp.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_cmp_parameters.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_new.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_free.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_decrypt.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_decrypt_init.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_derive.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_derive_init.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_derive.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_derive_set_peer.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_get_default_digest.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_get_default_digest_nid.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_encrypt.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_encrypt_init.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen_init.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_paramgen_init.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_paramgen.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_cb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_get_cb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_get_keygen_info.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_app_data.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_get_app_data.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_print_private.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_print_public.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_print_private.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_print_params.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_sign.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_sign_init.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_verify.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_verify_init.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_verify_recover.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_verify_recover_init.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_assign_DH.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_assign_DSA.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_assign_EC_KEY.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_assign_RSA.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_get1_DH.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_get1_DSA.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_get1_EC_KEY.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_get1_RSA.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_DH.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_DSA.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_EC_KEY.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_type.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_SealInit.3 $(DESTDIR)$(mandir)/man3/EVP_SealFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_SealInit.3 $(DESTDIR)$(mandir)/man3/EVP_SealUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_SignInit.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_size.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_SignInit.3 $(DESTDIR)$(mandir)/man3/EVP_SignFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_SignInit.3 $(DESTDIR)$(mandir)/man3/EVP_SignUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_VerifyInit.3 $(DESTDIR)$(mandir)/man3/EVP_VerifyFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_VerifyInit.3 $(DESTDIR)$(mandir)/man3/EVP_VerifyUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/HMAC.3 $(DESTDIR)$(mandir)/man3/HMAC_Final.3 ln -f $(DESTDIR)$(mandir)/man3/HMAC.3 $(DESTDIR)$(mandir)/man3/HMAC_Init.3 ln -f $(DESTDIR)$(mandir)/man3/HMAC.3 $(DESTDIR)$(mandir)/man3/HMAC_Update.3 ln -f $(DESTDIR)$(mandir)/man3/HMAC.3 $(DESTDIR)$(mandir)/man3/HMAC_cleanup.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD2.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD2_Final.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD2_Init.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD2_Update.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD4.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD4_Final.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD4_Init.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD4_Update.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD5_Final.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD5_Init.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD5_Update.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_cleanup.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_cmp.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_create.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_dup.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_ln2nid.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_nid2ln.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_nid2sn.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_obj2nid.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_obj2txt.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_sn2nid.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_txt2nid.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_txt2obj.3 ln -f $(DESTDIR)$(mandir)/man3/OPENSSL_VERSION_NUMBER.3 $(DESTDIR)$(mandir)/man3/SSLeay.3 ln -f $(DESTDIR)$(mandir)/man3/OPENSSL_VERSION_NUMBER.3 $(DESTDIR)$(mandir)/man3/SSLeay_version.3 ln -f $(DESTDIR)$(mandir)/man3/OPENSSL_config.3 $(DESTDIR)$(mandir)/man3/OPENSSL_no_config.3 ln -f $(DESTDIR)$(mandir)/man3/OPENSSL_load_builtin_modules.3 $(DESTDIR)$(mandir)/man3/ASN1_add_oid_module.3 ln -f $(DESTDIR)$(mandir)/man3/OPENSSL_load_builtin_modules.3 $(DESTDIR)$(mandir)/man3/ENGINE_add_conf_module.3 ln -f $(DESTDIR)$(mandir)/man3/OpenSSL_add_all_algorithms.3 $(DESTDIR)$(mandir)/man3/EVP_cleanup.3 ln -f $(DESTDIR)$(mandir)/man3/OpenSSL_add_all_algorithms.3 $(DESTDIR)$(mandir)/man3/OpenSSL_add_all_ciphers.3 ln -f $(DESTDIR)$(mandir)/man3/OpenSSL_add_all_algorithms.3 $(DESTDIR)$(mandir)/man3/OpenSSL_add_all_digests.3 ln -f $(DESTDIR)$(mandir)/man3/PKCS5_PBKDF2_HMAC.3 $(DESTDIR)$(mandir)/man3/PKCS5_PBKDF2_HMAC_SHA1.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_DHparams.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_DSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_DSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_DSAparams.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_NETSCAPE_CERT_SEQUENCE.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_PKCS7.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_PrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_RSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_RSAPublicKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_RSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_X509.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_X509_AUX.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_X509_CRL.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_X509_REQ.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_DHparams.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_DSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_DSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_DSAparams.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_NETSCAPE_CERT_SEQUENCE.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_PKCS7.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_RSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_RSAPublicKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_RSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_X509.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_X509_AUX.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_X509_CRL.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_X509_REQ.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_DHparams.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_DSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_DSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_DSAparams.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_NETSCAPE_CERT_SEQUENCE.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_PKCS7.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_PKCS8PrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_PKCS8PrivateKey_nid.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_PrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_RSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_RSAPublicKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_RSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_X509.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_X509_AUX.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_X509_CRL.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_X509_REQ.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_X509_REQ_NEW.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_DHparams.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_DSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_DSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_DSAparams.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_NETSCAPE_CERT_SEQUENCE.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_PKCS7.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_PKCS8PrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_PKCS8PrivateKey_nid.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_PrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_RSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_RSAPublicKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_RSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_X509.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_X509_AUX.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_X509_CRL.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_X509_REQ.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_X509_REQ_NEW.3 ln -f $(DESTDIR)$(mandir)/man3/PKCS7_verify.3 $(DESTDIR)$(mandir)/man3/PKCS7_get0_signers.3 ln -f $(DESTDIR)$(mandir)/man3/RAND_add.3 $(DESTDIR)$(mandir)/man3/RAND_seed.3 ln -f $(DESTDIR)$(mandir)/man3/RAND_add.3 $(DESTDIR)$(mandir)/man3/RAND_status.3 ln -f $(DESTDIR)$(mandir)/man3/RAND_bytes.3 $(DESTDIR)$(mandir)/man3/RAND_pseudo_bytes.3 ln -f $(DESTDIR)$(mandir)/man3/RAND_load_file.3 $(DESTDIR)$(mandir)/man3/RAND_file_name.3 ln -f $(DESTDIR)$(mandir)/man3/RAND_load_file.3 $(DESTDIR)$(mandir)/man3/RAND_write_file.3 ln -f $(DESTDIR)$(mandir)/man3/RAND_set_rand_method.3 $(DESTDIR)$(mandir)/man3/RAND_SSLeay.3 ln -f $(DESTDIR)$(mandir)/man3/RAND_set_rand_method.3 $(DESTDIR)$(mandir)/man3/RAND_get_rand_method.3 ln -f $(DESTDIR)$(mandir)/man3/RC4.3 $(DESTDIR)$(mandir)/man3/RC4_set_key.3 ln -f $(DESTDIR)$(mandir)/man3/RIPEMD160.3 $(DESTDIR)$(mandir)/man3/RIPEMD160_Final.3 ln -f $(DESTDIR)$(mandir)/man3/RIPEMD160.3 $(DESTDIR)$(mandir)/man3/RIPEMD160_Init.3 ln -f $(DESTDIR)$(mandir)/man3/RIPEMD160.3 $(DESTDIR)$(mandir)/man3/RIPEMD160_Update.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_blinding_on.3 $(DESTDIR)$(mandir)/man3/RSA_blinding_off.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_generate_key.3 $(DESTDIR)$(mandir)/man3/RSA_generate_key_ex.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/RSA_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/RSA_set_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_new.3 $(DESTDIR)$(mandir)/man3/RSA_free.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_OAEP.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_2.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_add_SSLv23.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_add_none.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_check_PKCS1_OAEP.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_check_PKCS1_type_1.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_check_PKCS1_type_2.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_check_SSLv23.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_check_none.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_print.3 $(DESTDIR)$(mandir)/man3/DHparams_print.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_print.3 $(DESTDIR)$(mandir)/man3/DHparams_print_fp.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_print.3 $(DESTDIR)$(mandir)/man3/DSA_print.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_print.3 $(DESTDIR)$(mandir)/man3/DSA_print_fp.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_print.3 $(DESTDIR)$(mandir)/man3/DSAparams_print.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_print.3 $(DESTDIR)$(mandir)/man3/DSAparams_print_fp.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_print.3 $(DESTDIR)$(mandir)/man3/RSA_print_fp.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_private_encrypt.3 $(DESTDIR)$(mandir)/man3/RSA_public_decrypt.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_public_encrypt.3 $(DESTDIR)$(mandir)/man3/RSA_private_decrypt.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_PKCS1_RSAref.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_PKCS1_SSLeay.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_flags.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_get_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_get_default_openssl_method.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_get_method.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_new_method.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_null_method.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_set_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_set_default_openssl_method.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_sign.3 $(DESTDIR)$(mandir)/man3/RSA_verify.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_sign_ASN1_OCTET_STRING.3 $(DESTDIR)$(mandir)/man3/RSA_verify_ASN1_OCTET_STRING.3 ln -f $(DESTDIR)$(mandir)/man3/SHA1.3 $(DESTDIR)$(mandir)/man3/SHA1_Final.3 ln -f $(DESTDIR)$(mandir)/man3/SHA1.3 $(DESTDIR)$(mandir)/man3/SHA1_Init.3 ln -f $(DESTDIR)$(mandir)/man3/SHA1.3 $(DESTDIR)$(mandir)/man3/SHA1_Update.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_get_object.3 $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_create_by_NID.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_get_object.3 $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_create_by_OBJ.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_get_object.3 $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_create_by_txt.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_get_object.3 $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_get_data.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_get_object.3 $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_set_data.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_get_object.3 $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_set_object.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_add_entry_by_txt.3 $(DESTDIR)$(mandir)/man3/X509_NAME_add_entry.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_add_entry_by_txt.3 $(DESTDIR)$(mandir)/man3/X509_NAME_add_entry_by_NID.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_add_entry_by_txt.3 $(DESTDIR)$(mandir)/man3/X509_NAME_add_entry_by_OBJ.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_add_entry_by_txt.3 $(DESTDIR)$(mandir)/man3/X509_NAME_delete_entry.3 ln -f $(DESTDIR)$(mandir)/man3/X509_new.3 $(DESTDIR)$(mandir)/man3/X509_free.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_error.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get1_chain.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_error.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_current_cert.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_error.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_error_depth.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_error.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_error.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_error.3 $(DESTDIR)$(mandir)/man3/X509_verify_cert_error_string.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_cleanup.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_free.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get0_param.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_init.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set0_crls.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set0_param.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_cert.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_chain.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_default.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_trusted_stack.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_set_verify_cb_func.3 $(DESTDIR)$(mandir)/man3/X509_STORE_set_verify_cb.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_add0_policy.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_clear_flags.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_get_depth.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_get_flags.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set1_policies.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_depth.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_purpose.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_time.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_trust.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_add_words.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_check_top.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_cmp_words.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_div_words.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_dump.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_expand.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_expand2.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_fix_top.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_add_words.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_comba4.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_comba8.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_high.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_low_normal.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_low_recursive.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_normal.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_part_recursive.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_recursive.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_words.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_print.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_set_high.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_set_low.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_set_max.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_sqr_comba4.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_sqr_comba8.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_sqr_normal.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_sqr_recursive.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_sqr_words.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_sub_words.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_wexpand.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/mul.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/mul_add.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/sqr.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_ASN1_OBJECT.3 $(DESTDIR)$(mandir)/man3/i2d_ASN1_OBJECT.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DHparams.3 $(DESTDIR)$(mandir)/man3/i2d_DHparams.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/d2i_DSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/d2i_DSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/d2i_DSA_SIG.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/d2i_DSAparams.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/i2d_DSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/i2d_DSAPublicKey.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/i2d_DSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/i2d_DSA_SIG.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/i2d_DSAparams.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters.3 $(DESTDIR)$(mandir)/man3/ECPKParameters_print.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters.3 $(DESTDIR)$(mandir)/man3/ECPKParameters_print_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters.3 $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters.3 $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters.3 $(DESTDIR)$(mandir)/man3/i2d_ECPKParameters.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters.3 $(DESTDIR)$(mandir)/man3/i2d_ECPKParameters_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters.3 $(DESTDIR)$(mandir)/man3/i2d_ECPKParameters_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_PKCS8PrivateKey.3 $(DESTDIR)$(mandir)/man3/d2i_PKCS8PrivateKey_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_PKCS8PrivateKey.3 $(DESTDIR)$(mandir)/man3/d2i_PKCS8PrivateKey_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_PKCS8PrivateKey.3 $(DESTDIR)$(mandir)/man3/i2d_PKCS8PrivateKey_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_PKCS8PrivateKey.3 $(DESTDIR)$(mandir)/man3/i2d_PKCS8PrivateKey_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_PKCS8PrivateKey.3 $(DESTDIR)$(mandir)/man3/i2d_PKCS8PrivateKey_nid_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_PKCS8PrivateKey.3 $(DESTDIR)$(mandir)/man3/i2d_PKCS8PrivateKey_nid_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_RSAPublicKey.3 $(DESTDIR)$(mandir)/man3/d2i_Netscape_RSA.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_RSAPublicKey.3 $(DESTDIR)$(mandir)/man3/d2i_RSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_RSAPublicKey.3 $(DESTDIR)$(mandir)/man3/i2d_Netscape_RSA.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_RSAPublicKey.3 $(DESTDIR)$(mandir)/man3/i2d_RSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_RSAPublicKey.3 $(DESTDIR)$(mandir)/man3/i2d_RSAPublicKey.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509.3 $(DESTDIR)$(mandir)/man3/d2i_X509_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509.3 $(DESTDIR)$(mandir)/man3/d2i_X509_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509.3 $(DESTDIR)$(mandir)/man3/i2d_X509.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509.3 $(DESTDIR)$(mandir)/man3/i2d_X509_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509.3 $(DESTDIR)$(mandir)/man3/i2d_X509_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_ALGOR.3 $(DESTDIR)$(mandir)/man3/i2d_X509_ALGOR.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_CRL.3 $(DESTDIR)$(mandir)/man3/d2i_X509_CRL_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_CRL.3 $(DESTDIR)$(mandir)/man3/d2i_X509_CRL_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_CRL.3 $(DESTDIR)$(mandir)/man3/i2d_X509_CRL.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_CRL.3 $(DESTDIR)$(mandir)/man3/i2d_X509_CRL_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_CRL.3 $(DESTDIR)$(mandir)/man3/i2d_X509_CRL_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_NAME.3 $(DESTDIR)$(mandir)/man3/i2d_X509_NAME.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_REQ.3 $(DESTDIR)$(mandir)/man3/d2i_X509_REQ_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_REQ.3 $(DESTDIR)$(mandir)/man3/d2i_X509_REQ_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_REQ.3 $(DESTDIR)$(mandir)/man3/i2d_X509_REQ.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_REQ.3 $(DESTDIR)$(mandir)/man3/i2d_X509_REQ_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_REQ.3 $(DESTDIR)$(mandir)/man3/i2d_X509_REQ_fp.3 ln -f $(DESTDIR)$(mandir)/man3/dsa.3 $(DESTDIR)$(mandir)/man3/DSA_SIG_free.3 ln -f $(DESTDIR)$(mandir)/man3/dsa.3 $(DESTDIR)$(mandir)/man3/DSA_do_verify.3 ln -f $(DESTDIR)$(mandir)/man3/dsa.3 $(DESTDIR)$(mandir)/man3/DSA_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/dsa.3 $(DESTDIR)$(mandir)/man3/DSA_set_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_OpenSSL.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_SIG_free.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_SIG_new.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_do_sign.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_do_sign_ex.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_do_verify.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_get_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_get_ex_new_index.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_set_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_set_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_set_method.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_sign.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_sign_ex.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_sign_setup.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_verify.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/d2i_ECDSA_SIG.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/i2d_ECDSA_SIG.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_add.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_by_id.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_finish.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_get_first.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_get_last.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_get_next.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_get_prev.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_init.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_load_builtin_engines.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_remove.3 ln -f $(DESTDIR)$(mandir)/man3/lh_stats.3 $(DESTDIR)$(mandir)/man3/lh_node_stats.3 ln -f $(DESTDIR)$(mandir)/man3/lh_stats.3 $(DESTDIR)$(mandir)/man3/lh_node_stats_bio.3 ln -f $(DESTDIR)$(mandir)/man3/lh_stats.3 $(DESTDIR)$(mandir)/man3/lh_node_usage_stats.3 ln -f $(DESTDIR)$(mandir)/man3/lh_stats.3 $(DESTDIR)$(mandir)/man3/lh_node_usage_stats_bio.3 ln -f $(DESTDIR)$(mandir)/man3/lh_stats.3 $(DESTDIR)$(mandir)/man3/lh_stats_bio.3 ln -f $(DESTDIR)$(mandir)/man3/lhash.3 $(DESTDIR)$(mandir)/man3/lh_delete.3 ln -f $(DESTDIR)$(mandir)/man3/lhash.3 $(DESTDIR)$(mandir)/man3/lh_doall.3 ln -f $(DESTDIR)$(mandir)/man3/lhash.3 $(DESTDIR)$(mandir)/man3/lh_doall_arg.3 ln -f $(DESTDIR)$(mandir)/man3/lhash.3 $(DESTDIR)$(mandir)/man3/lh_error.3 ln -f $(DESTDIR)$(mandir)/man3/lhash.3 $(DESTDIR)$(mandir)/man3/lh_free.3 ln -f $(DESTDIR)$(mandir)/man3/lhash.3 $(DESTDIR)$(mandir)/man3/lh_insert.3 ln -f $(DESTDIR)$(mandir)/man3/lhash.3 $(DESTDIR)$(mandir)/man3/lh_new.3 ln -f $(DESTDIR)$(mandir)/man3/lhash.3 $(DESTDIR)$(mandir)/man3/lh_retrieve.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_OpenSSL.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_add_error_string.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_add_info_string.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_add_input_boolean.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_add_input_string.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_add_user_data.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_add_verify_string.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_construct_prompt.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_ctrl.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_dup_error_string.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_dup_info_string.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_dup_input_boolean.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_dup_input_string.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_dup_verify_string.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_free.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_get0_result.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_get0_user_data.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_get_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_get_method.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_new.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_new_method.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_process.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_set_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_set_method.3 ln -f $(DESTDIR)$(mandir)/man3/ui_compat.3 $(DESTDIR)$(mandir)/man3/des_read_2passwords.3 ln -f $(DESTDIR)$(mandir)/man3/ui_compat.3 $(DESTDIR)$(mandir)/man3/des_read_password.3 ln -f $(DESTDIR)$(mandir)/man3/ui_compat.3 $(DESTDIR)$(mandir)/man3/des_read_pw.3 ln -f $(DESTDIR)$(mandir)/man3/ui_compat.3 $(DESTDIR)$(mandir)/man3/des_read_pw_string.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_do_handshake.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_get_num_renegotiates.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_get_ssl.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_new_buffer_ssl_connect.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_new_ssl.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_new_ssl_connect.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_set_ssl.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_set_ssl_mode.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_set_ssl_renegotiate_bytes.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_set_ssl_renegotiate_timeout.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_ssl_copy_session_id.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_ssl_shutdown.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_load_crypto_strings.3 $(DESTDIR)$(mandir)/man3/SSL_load_error_strings.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CIPHER_get_name.3 $(DESTDIR)$(mandir)/man3/SSL_CIPHER_description.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CIPHER_get_name.3 $(DESTDIR)$(mandir)/man3/SSL_CIPHER_get_bits.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CIPHER_get_name.3 $(DESTDIR)$(mandir)/man3/SSL_CIPHER_get_version.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_add_session.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_remove_session.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_add_session.3 $(DESTDIR)$(mandir)/man3/SSL_add_session.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_add_session.3 $(DESTDIR)$(mandir)/man3/SSL_remove_session.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_callback_ctrl.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/SSL_callback_ctrl.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/SSL_ctrl.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_flush_sessions.3 $(DESTDIR)$(mandir)/man3/SSL_flush_sessions.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_set_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_get_verify_mode.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_verify_callback.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_get_verify_mode.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_verify_depth.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_get_verify_mode.3 $(DESTDIR)$(mandir)/man3/SSL_get_verify_callback.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_get_verify_mode.3 $(DESTDIR)$(mandir)/man3/SSL_get_verify_depth.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_get_verify_mode.3 $(DESTDIR)$(mandir)/man3/SSL_get_verify_mode.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/SSLv23_client_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/SSLv23_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/SSLv23_server_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/SSLv3_client_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/SSLv3_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/SSLv3_server_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/TLSv1_1_client_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/TLSv1_1_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/TLSv1_1_server_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/TLSv1_client_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/TLSv1_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/TLSv1_server_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_accept.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_accept_good.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_accept_renegotiate.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_cache_full.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_cb_hits.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_connect.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_connect_good.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_connect_renegotiate.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_hits.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_misses.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_timeouts.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_set_cache_size.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_get_cache_size.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_set_get_cb.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_get_get_cb.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_set_get_cb.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_get_new_cb.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_set_get_cb.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_get_remove_cb.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_set_get_cb.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_set_new_cb.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_set_get_cb.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_set_remove.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_cert_store.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_cert_store.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_cipher_list.3 $(DESTDIR)$(mandir)/man3/SSL_set_cipher_list.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_client_CA_list.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_add_client_CA.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_client_CA_list.3 $(DESTDIR)$(mandir)/man3/SSL_add_client_CA.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_client_CA_list.3 $(DESTDIR)$(mandir)/man3/SSL_set_client_CA_list.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_default_passwd_cb.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_set_default_passwd_cb_userdata.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_max_cert_list.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_max_cert_list.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_max_cert_list.3 $(DESTDIR)$(mandir)/man3/SSL_get_max_cert_list.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_max_cert_list.3 $(DESTDIR)$(mandir)/man3/SSL_set_max_cert_list.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_mode.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_mode.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_mode.3 $(DESTDIR)$(mandir)/man3/SSL_get_mode.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_mode.3 $(DESTDIR)$(mandir)/man3/SSL_set_mode.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_msg_callback.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_set_msg_callback_arg.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_msg_callback.3 $(DESTDIR)$(mandir)/man3/SSL_set_msg_callback.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_msg_callback.3 $(DESTDIR)$(mandir)/man3/SSL_set_msg_callback_arg.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_options.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_options.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_options.3 $(DESTDIR)$(mandir)/man3/SSL_get_options.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_options.3 $(DESTDIR)$(mandir)/man3/SSL_set_options.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_psk_client_callback.3 $(DESTDIR)$(mandir)/man3/SSL_set_psk_client_callback.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_quiet_shutdown.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_quiet_shutdown.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_quiet_shutdown.3 $(DESTDIR)$(mandir)/man3/SSL_get_quiet_shutdown.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_quiet_shutdown.3 $(DESTDIR)$(mandir)/man3/SSL_set_quiet_shutdown.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_session_cache_mode.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_session_cache_mode.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_session_id_context.3 $(DESTDIR)$(mandir)/man3/SSL_set_session_id_context.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_ssl_version.3 $(DESTDIR)$(mandir)/man3/SSL_get_ssl_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_ssl_version.3 $(DESTDIR)$(mandir)/man3/SSL_set_ssl_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_timeout.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_timeout.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_dh_callback.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_dh.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_dh_callback.3 $(DESTDIR)$(mandir)/man3/SSL_set_tmp_dh.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_dh_callback.3 $(DESTDIR)$(mandir)/man3/SSL_set_tmp_dh_callback.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_rsa_callback.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_need_tmp_rsa.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_rsa_callback.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_rsa.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_rsa_callback.3 $(DESTDIR)$(mandir)/man3/SSL_need_tmp_rsa.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_rsa_callback.3 $(DESTDIR)$(mandir)/man3/SSL_set_tmp_rsa.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_rsa_callback.3 $(DESTDIR)$(mandir)/man3/SSL_set_tmp_rsa_callback.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_verify.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_set_verify_depth.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_verify.3 $(DESTDIR)$(mandir)/man3/SSL_set_verify.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_verify.3 $(DESTDIR)$(mandir)/man3/SSL_set_verify_depth.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_check_private_key.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_PrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_PrivateKey_ASN1.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_PrivateKey_file.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_RSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_RSAPrivateKey_ASN1.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_RSAPrivateKey_file.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate_ASN1.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate_chain_file.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate_file.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_check_private_key.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_PrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_PrivateKey_ASN1.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_PrivateKey_file.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_RSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_RSAPrivateKey_ASN1.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_RSAPrivateKey_file.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_certificate.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_certificate_ASN1.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_certificate_file.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_psk_identity_hint.3 $(DESTDIR)$(mandir)/man3/SSL_use_psk_identity_hint.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_psk_identity_hint.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_set_psk_server_callback.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_psk_identity_hint.3 $(DESTDIR)$(mandir)/man3/SSL_set_psk_server_callback.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/SSL_SESSION_set_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_time.3 $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_timeout.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_time.3 $(DESTDIR)$(mandir)/man3/SSL_SESSION_set_time.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_time.3 $(DESTDIR)$(mandir)/man3/SSL_SESSION_set_timeout.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_time.3 $(DESTDIR)$(mandir)/man3/SSL_get_time.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_time.3 $(DESTDIR)$(mandir)/man3/SSL_get_timeout.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_time.3 $(DESTDIR)$(mandir)/man3/SSL_set_time.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_time.3 $(DESTDIR)$(mandir)/man3/SSL_set_timeout.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_alert_type_string.3 $(DESTDIR)$(mandir)/man3/SSL_alert_desc_string.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_alert_type_string.3 $(DESTDIR)$(mandir)/man3/SSL_alert_desc_string_long.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_alert_type_string.3 $(DESTDIR)$(mandir)/man3/SSL_alert_type_string_long.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_ciphers.3 $(DESTDIR)$(mandir)/man3/SSL_get_cipher_list.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_client_CA_list.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_client_CA_list.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_current_cipher.3 $(DESTDIR)$(mandir)/man3/SSL_get_cipher.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_current_cipher.3 $(DESTDIR)$(mandir)/man3/SSL_get_cipher_bits.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_current_cipher.3 $(DESTDIR)$(mandir)/man3/SSL_get_cipher_name.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_current_cipher.3 $(DESTDIR)$(mandir)/man3/SSL_get_cipher_version.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/SSL_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/SSL_set_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_fd.3 $(DESTDIR)$(mandir)/man3/SSL_get_rfd.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_fd.3 $(DESTDIR)$(mandir)/man3/SSL_get_wfd.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_psk_identity.3 $(DESTDIR)$(mandir)/man3/SSL_get_psk_identity_hint.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_rbio.3 $(DESTDIR)$(mandir)/man3/SSL_get_wbio.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_session.3 $(DESTDIR)$(mandir)/man3/SSL_get0_session.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_session.3 $(DESTDIR)$(mandir)/man3/SSL_get1_session.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_library_init.3 $(DESTDIR)$(mandir)/man3/OpenSSL_add_ssl_algorithms.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_library_init.3 $(DESTDIR)$(mandir)/man3/SSLeay_add_ssl_algorithms.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_rstate_string.3 $(DESTDIR)$(mandir)/man3/SSL_rstate_string_long.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_set_connect_state.3 $(DESTDIR)$(mandir)/man3/SSL_set_accept_state.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_set_fd.3 $(DESTDIR)$(mandir)/man3/SSL_set_rfd.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_set_fd.3 $(DESTDIR)$(mandir)/man3/SSL_set_wfd.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_set_shutdown.3 $(DESTDIR)$(mandir)/man3/SSL_get_shutdown.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_state_string.3 $(DESTDIR)$(mandir)/man3/SSL_state_string_long.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_want.3 $(DESTDIR)$(mandir)/man3/SSL_want_nothing.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_want.3 $(DESTDIR)$(mandir)/man3/SSL_want_read.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_want.3 $(DESTDIR)$(mandir)/man3/SSL_want_write.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_want.3 $(DESTDIR)$(mandir)/man3/SSL_want_x509_lookup.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_SSL_SESSION.3 $(DESTDIR)$(mandir)/man3/i2d_SSL_SESSION.3 deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_get_ex_new_index.30000644000175000017500000001356212360020735021640 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_get_ex_new_index 3" .TH SSL_get_ex_new_index 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_get_ex_new_index, SSL_set_ex_data, SSL_get_ex_data \- internal application specific data functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_get_ex_new_index(long argl, void *argp, \& CRYPTO_EX_new *new_func, \& CRYPTO_EX_dup *dup_func, \& CRYPTO_EX_free *free_func); \& \& int SSL_set_ex_data(SSL *ssl, int idx, void *arg); \& \& void *SSL_get_ex_data(const SSL *ssl, int idx); \& \& typedef int new_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad, \& int idx, long argl, void *argp); \& typedef void free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad, \& int idx, long argl, void *argp); \& typedef int dup_func(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, \& int idx, long argl, void *argp); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Several OpenSSL structures can have application specific data attached to them. These functions are used internally by OpenSSL to manipulate application specific data attached to a specific structure. .PP \&\fISSL_get_ex_new_index()\fR is used to register a new index for application specific data. .PP \&\fISSL_set_ex_data()\fR is used to store application data at \fBarg\fR for \fBidx\fR into the \fBssl\fR object. .PP \&\fISSL_get_ex_data()\fR is used to retrieve the information for \fBidx\fR from \&\fBssl\fR. .PP A detailed description for the \fB*\f(BI_get_ex_new_index()\fB\fR functionality can be found in \fIRSA_get_ex_new_index\fR\|(3). The \fB*\f(BI_get_ex_data()\fB\fR and \fB*\f(BI_set_ex_data()\fB\fR functionality is described in \&\fICRYPTO_set_ex_data\fR\|(3). .SH "EXAMPLES" .IX Header "EXAMPLES" An example on how to use the functionality is included in the example \&\fIverify_callback()\fR in \fISSL_CTX_set_verify\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \&\fIRSA_get_ex_new_index\fR\|(3), \&\fICRYPTO_set_ex_data\fR\|(3), \&\fISSL_CTX_set_verify\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_load_client_CA_file.30000644000175000017500000001262112360020736022140 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_load_client_CA_file 3" .TH SSL_load_client_CA_file 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_load_client_CA_file \- load certificate names from file .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_load_client_CA_file()\fR reads certificates from \fBfile\fR and returns a \s-1STACK_OF\s0(X509_NAME) with the subject names found. .SH "NOTES" .IX Header "NOTES" \&\fISSL_load_client_CA_file()\fR reads a file of \s-1PEM\s0 formatted certificates and extracts the X509_NAMES of the certificates found. While the name suggests the specific usage as support function for \&\fISSL_CTX_set_client_CA_list\fR\|(3), it is not limited to \s-1CA\s0 certificates. .SH "EXAMPLES" .IX Header "EXAMPLES" Load names of CAs from file and use it as a client \s-1CA\s0 list: .PP .Vb 2 \& SSL_CTX *ctx; \& STACK_OF(X509_NAME) *cert_names; \& \& ... \& cert_names = SSL_load_client_CA_file("/path/to/CAfile.pem"); \& if (cert_names != NULL) \& SSL_CTX_set_client_CA_list(ctx, cert_names); \& else \& error_handling(); \& ... .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .IP "\s-1NULL\s0" 4 .IX Item "NULL" The operation failed, check out the error stack for the reason. .IP "Pointer to \s-1STACK_OF\s0(X509_NAME)" 4 .IX Item "Pointer to STACK_OF(X509_NAME)" Pointer to the subject names of the successfully read certificates. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \&\fISSL_CTX_set_client_CA_list\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/rand.10000644000175000017500000001230712360020742016520 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "rand 1" .TH rand 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" rand \- generate pseudo\-random bytes .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl rand\fR [\fB\-out\fR \fIfile\fR] [\fB\-rand\fR \fIfile(s)\fR] [\fB\-base64\fR] [\fB\-hex\fR] \&\fInum\fR .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBrand\fR command outputs \fInum\fR pseudo-random bytes after seeding the random number generator once. As in other \fBopenssl\fR command line tools, \s-1PRNG\s0 seeding uses the file \fI\f(CI$HOME\fI/\fR\fB.rnd\fR or \fB.rnd\fR in addition to the files given in the \fB\-rand\fR option. A new \&\fI\f(CI$HOME\fI\fR/\fB.rnd\fR or \fB.rnd\fR file will be written back if enough seeding was obtained from these sources. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-out\fR \fIfile\fR" 4 .IX Item "-out file" Write to \fIfile\fR instead of standard output. .IP "\fB\-rand\fR \fIfile(s)\fR" 4 .IX Item "-rand file(s)" Use specified file or files or \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)) for seeding the random number generator. Multiple files can be specified separated by a OS-dependent character. The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for all others. .IP "\fB\-base64\fR" 4 .IX Item "-base64" Perform base64 encoding on the output. .IP "\fB\-hex\fR" 4 .IX Item "-hex" Show the output as a hex string. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIRAND_bytes\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/ui.30000644000175000017500000003132412360020730016210 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ui 3" .TH ui 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" UI_new, UI_new_method, UI_free, UI_add_input_string, UI_dup_input_string, UI_add_verify_string, UI_dup_verify_string, UI_add_input_boolean, UI_dup_input_boolean, UI_add_info_string, UI_dup_info_string, UI_add_error_string, UI_dup_error_string, UI_construct_prompt, UI_add_user_data, UI_get0_user_data, UI_get0_result, UI_process, UI_ctrl, UI_set_default_method, UI_get_default_method, UI_get_method, UI_set_method, UI_OpenSSL, ERR_load_UI_strings \- New User Interface .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& typedef struct ui_st UI; \& typedef struct ui_method_st UI_METHOD; \& \& UI *UI_new(void); \& UI *UI_new_method(const UI_METHOD *method); \& void UI_free(UI *ui); \& \& int UI_add_input_string(UI *ui, const char *prompt, int flags, \& char *result_buf, int minsize, int maxsize); \& int UI_dup_input_string(UI *ui, const char *prompt, int flags, \& char *result_buf, int minsize, int maxsize); \& int UI_add_verify_string(UI *ui, const char *prompt, int flags, \& char *result_buf, int minsize, int maxsize, const char *test_buf); \& int UI_dup_verify_string(UI *ui, const char *prompt, int flags, \& char *result_buf, int minsize, int maxsize, const char *test_buf); \& int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, \& const char *ok_chars, const char *cancel_chars, \& int flags, char *result_buf); \& int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, \& const char *ok_chars, const char *cancel_chars, \& int flags, char *result_buf); \& int UI_add_info_string(UI *ui, const char *text); \& int UI_dup_info_string(UI *ui, const char *text); \& int UI_add_error_string(UI *ui, const char *text); \& int UI_dup_error_string(UI *ui, const char *text); \& \& /* These are the possible flags. They can be or\*(Aqed together. */ \& #define UI_INPUT_FLAG_ECHO 0x01 \& #define UI_INPUT_FLAG_DEFAULT_PWD 0x02 \& \& char *UI_construct_prompt(UI *ui_method, \& const char *object_desc, const char *object_name); \& \& void *UI_add_user_data(UI *ui, void *user_data); \& void *UI_get0_user_data(UI *ui); \& \& const char *UI_get0_result(UI *ui, int i); \& \& int UI_process(UI *ui); \& \& int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)()); \& #define UI_CTRL_PRINT_ERRORS 1 \& #define UI_CTRL_IS_REDOABLE 2 \& \& void UI_set_default_method(const UI_METHOD *meth); \& const UI_METHOD *UI_get_default_method(void); \& const UI_METHOD *UI_get_method(UI *ui); \& const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth); \& \& UI_METHOD *UI_OpenSSL(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\s-1UI\s0 stands for User Interface, and is general purpose set of routines to prompt the user for text-based information. Through user-written methods (see \fIui_create\fR\|(3)), prompting can be done in any way imaginable, be it plain text prompting, through dialog boxes or from a cell phone. .PP All the functions work through a context of the type \s-1UI. \s0 This context contains all the information needed to prompt correctly as well as a reference to a \s-1UI_METHOD,\s0 which is an ordered vector of functions that carry out the actual prompting. .PP The first thing to do is to create a \s-1UI\s0 with \fIUI_new()\fR or \fIUI_new_method()\fR, then add information to it with the UI_add or UI_dup functions. Also, user-defined random data can be passed down to the underlying method through calls to UI_add_user_data. The default \s-1UI\s0 method doesn't care about these data, but other methods might. Finally, use \fIUI_process()\fR to actually perform the prompting and \fIUI_get0_result()\fR to find the result to the prompt. .PP A \s-1UI\s0 can contain more than one prompt, which are performed in the given sequence. Each prompt gets an index number which is returned by the UI_add and UI_dup functions, and has to be used to get the corresponding result with \fIUI_get0_result()\fR. .PP The functions are as follows: .PP \&\fIUI_new()\fR creates a new \s-1UI\s0 using the default \s-1UI\s0 method. When done with this \s-1UI,\s0 it should be freed using \fIUI_free()\fR. .PP \&\fIUI_new_method()\fR creates a new \s-1UI\s0 using the given \s-1UI\s0 method. When done with this \s-1UI,\s0 it should be freed using \fIUI_free()\fR. .PP \&\fIUI_OpenSSL()\fR returns the built-in \s-1UI\s0 method (note: not the default one, since the default can be changed. See further on). This method is the most machine/OS dependent part of OpenSSL and normally generates the most problems when porting. .PP \&\fIUI_free()\fR removes a \s-1UI\s0 from memory, along with all other pieces of memory that's connected to it, like duplicated input strings, results and others. .PP \&\fIUI_add_input_string()\fR and \fIUI_add_verify_string()\fR add a prompt to the \s-1UI,\s0 as well as flags and a result buffer and the desired minimum and maximum sizes of the result. The given information is used to prompt for information, for example a password, and to verify a password (i.e. having the user enter it twice and check that the same string was entered twice). \&\fIUI_add_verify_string()\fR takes and extra argument that should be a pointer to the result buffer of the input string that it's supposed to verify, or verification will fail. .PP \&\fIUI_add_input_boolean()\fR adds a prompt to the \s-1UI\s0 that's supposed to be answered in a boolean way, with a single character for yes and a different character for no. A set of characters that can be used to cancel the prompt is given as well. The prompt itself is really divided in two, one part being the descriptive text (given through the \fIprompt\fR argument) and one describing the possible answers (given through the \fIaction_desc\fR argument). .PP \&\fIUI_add_info_string()\fR and \fIUI_add_error_string()\fR add strings that are shown at the same time as the prompt for extra information or to show an error string. The difference between the two is only conceptual. With the builtin method, there's no technical difference between them. Other methods may make a difference between them, however. .PP The flags currently supported are \s-1UI_INPUT_FLAG_ECHO,\s0 which is relevant for \&\fIUI_add_input_string()\fR and will have the users response be echoed (when prompting for a password, this flag should obviously not be used, and \&\s-1UI_INPUT_FLAG_DEFAULT_PWD,\s0 which means that a default password of some sort will be used (completely depending on the application and the \s-1UI\s0 method). .PP \&\fIUI_dup_input_string()\fR, \fIUI_dup_verify_string()\fR, \fIUI_dup_input_boolean()\fR, \&\fIUI_dup_info_string()\fR and \fIUI_dup_error_string()\fR are basically the same as their UI_add counterparts, except that they make their own copies of all strings. .PP \&\fIUI_construct_prompt()\fR is a helper function that can be used to create a prompt from two pieces of information: an description and a name. The default constructor (if there is none provided by the method used) creates a string "Enter \fIdescription\fR for \fIname\fR:\*(L". With the description \*(R"pass phrase\*(L" and the file name \*(R"foo.key\*(L", that becomes \&\*(R"Enter pass phrase for foo.key:". Other methods may create whatever string and may include encodings that will be processed by the other method functions. .PP \&\fIUI_add_user_data()\fR adds a piece of memory for the method to use at any time. The builtin \s-1UI\s0 method doesn't care about this info. Note that several calls to this function doesn't add data, it replaces the previous blob with the one given as argument. .PP \&\fIUI_get0_user_data()\fR retrieves the data that has last been given to the \&\s-1UI\s0 with \fIUI_add_user_data()\fR. .PP \&\fIUI_get0_result()\fR returns a pointer to the result buffer associated with the information indexed by \fIi\fR. .PP \&\fIUI_process()\fR goes through the information given so far, does all the printing and prompting and returns. .PP \&\fIUI_ctrl()\fR adds extra control for the application author. For now, it understands two commands: \s-1UI_CTRL_PRINT_ERRORS,\s0 which makes \fIUI_process()\fR print the OpenSSL error stack as part of processing the \s-1UI,\s0 and \&\s-1UI_CTRL_IS_REDOABLE,\s0 which returns a flag saying if the used \s-1UI\s0 can be used again or not. .PP \&\fIUI_set_default_method()\fR changes the default \s-1UI\s0 method to the one given. .PP \&\fIUI_get_default_method()\fR returns a pointer to the current default \s-1UI\s0 method. .PP \&\fIUI_get_method()\fR returns the \s-1UI\s0 method associated with a given \s-1UI.\s0 .PP \&\fIUI_set_method()\fR changes the \s-1UI\s0 method associated with a given \s-1UI.\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIui_create\fR\|(3), \fIui_compat\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" The \s-1UI\s0 section was first introduced in OpenSSL 0.9.7. .SH "AUTHOR" .IX Header "AUTHOR" Richard Levitte (richard@levitte.org) for the OpenSSL project (http://www.openssl.org). deps/libressl-pnacl-sys-2.1.6/libressl/man/EC_POINT_add.30000644000175000017500000001746112360020716017655 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EC_POINT_add 3" .TH EC_POINT_add 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EC_POINT_add, EC_POINT_dbl, EC_POINT_invert, EC_POINT_is_at_infinity, EC_POINT_is_on_curve, EC_POINT_cmp, EC_POINT_make_affine, EC_POINTs_make_affine, EC_POINTs_mul, EC_POINT_mul, EC_GROUP_precompute_mult, EC_GROUP_have_precompute_mult \- Functions for performing mathematical operations and tests on EC_POINT objects. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx); \& int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx); \& int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx); \& int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p); \& int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx); \& int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx); \& int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx); \& int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx); \& int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, size_t num, const EC_POINT *p[], const BIGNUM *m[], BN_CTX *ctx); \& int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); \& int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx); \& int EC_GROUP_have_precompute_mult(const EC_GROUP *group); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" EC_POINT_add adds the two points \fBa\fR and \fBb\fR and places the result in \fBr\fR. Similarly EC_POINT_dbl doubles the point \fBa\fR and places the result in \fBr\fR. In both cases it is valid for \fBr\fR to be one of \fBa\fR or \fBb\fR. .PP EC_POINT_invert calculates the inverse of the supplied point \fBa\fR. The result is placed back in \fBa\fR. .PP The function EC_POINT_is_at_infinity tests whether the supplied point is at infinity or not. .PP EC_POINT_is_on_curve tests whether the supplied point is on the curve or not. .PP EC_POINT_cmp compares the two supplied points and tests whether or not they are equal. .PP The functions EC_POINT_make_affine and EC_POINTs_make_affine force the internal representation of the \s-1EC_POINT\s0(s) into the affine co-ordinate system. In the case of EC_POINTs_make_affine the value \fBnum\fR provides the number of points in the array \fBpoints\fR to be forced. .PP EC_POINT_mul calculates the value generator * \fBn\fR + \fBq\fR * \fBm\fR and stores the result in \fBr\fR. The value \fBn\fR may be \s-1NULL\s0 in which case the result is just \fBq\fR * \fBm\fR. .PP EC_POINTs_mul calculates the value generator * \fBn\fR + \fBq[0]\fR * \fBm[0]\fR + ... + \fBq[num\-1]\fR * \fBm[num\-1]\fR. As for EC_POINT_mul the value \&\fBn\fR may be \s-1NULL.\s0 .PP The function EC_GROUP_precompute_mult stores multiples of the generator for faster point multiplication, whilst EC_GROUP_have_precompute_mult tests whether precomputation has already been done. See \fIEC_GROUP_copy\fR\|(3) for information about the generator. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following functions return 1 on success or 0 on error: EC_POINT_add, EC_POINT_dbl, EC_POINT_invert, EC_POINT_make_affine, EC_POINTs_make_affine, EC_POINTs_make_affine, EC_POINT_mul, EC_POINTs_mul and EC_GROUP_precompute_mult. .PP EC_POINT_is_at_infinity returns 1 if the point is at infinity, or 0 otherwise. .PP EC_POINT_is_on_curve returns 1 if the point is on the curve, 0 if not, or \-1 on error. .PP EC_POINT_cmp returns 1 if the points are not equal, 0 if they are, or \-1 on error. .PP EC_GROUP_have_precompute_mult return 1 if a precomputation has been done, or 0 if not. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIcrypto\fR\|(3), \fIec\fR\|(3), \fIEC_GROUP_new\fR\|(3), \fIEC_GROUP_copy\fR\|(3), \&\fIEC_POINT_new\fR\|(3), \fIEC_KEY_new\fR\|(3), \&\fIEC_GFp_simple_method\fR\|(3), \fId2i_ECPKParameters\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_sessions.30000644000175000017500000001147312360020732020705 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_sessions 3" .TH SSL_CTX_sessions 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_sessions \- access internal session cache .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_sessions()\fR returns a pointer to the lhash databases containing the internal session cache for \fBctx\fR. .SH "NOTES" .IX Header "NOTES" The sessions in the internal session cache are kept in an \&\fIlhash\fR\|(3) type database. It is possible to directly access this database e.g. for searching. In parallel, the sessions form a linked list which is maintained separately from the \&\fIlhash\fR\|(3) operations, so that the database must not be modified directly but by using the \&\fISSL_CTX_add_session\fR\|(3) family of functions. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fIlhash\fR\|(3), \&\fISSL_CTX_add_session\fR\|(3), \&\fISSL_CTX_set_session_cache_mode\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/CMS_verify_receipt.30000644000175000017500000001254512360020714021322 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CMS_verify_receipt 3" .TH CMS_verify_receipt 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CMS_verify_receipt \- verify a CMS signed receipt .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms, STACK_OF(X509) *certs, X509_STORE *store, unsigned int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fICMS_verify_receipt()\fR verifies a \s-1CMS\s0 signed receipt. \fBrcms\fR is the signed receipt to verify. \fBocms\fR is the original SignedData structure containing the receipt request. \fBcerts\fR is a set of certificates in which to search for the signing certificate. \fBstore\fR is a trusted certificate store (used for chain verification). .PP \&\fBflags\fR is an optional set of flags, which can be used to modify the verify operation. .SH "NOTES" .IX Header "NOTES" This functions behaves in a similar way to \fICMS_verify()\fR except the flag values \&\fB\s-1CMS_DETACHED\s0\fR, \fB\s-1CMS_BINARY\s0\fR, \fB\s-1CMS_TEXT\s0\fR and \fB\s-1CMS_STREAM\s0\fR are not supported since they do not make sense in the context of signed receipts. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICMS_verify_receipt()\fR returns 1 for a successful verification and zero if an error occurred. .PP The error can be obtained from \fIERR_get_error\fR\|(3) .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \&\fICMS_sign_receipt\fR\|(3), \&\fICMS_verify\fR\|(3), .SH "HISTORY" .IX Header "HISTORY" \&\fICMS_verify_receipt()\fR was added to OpenSSL 0.9.8 deps/libressl-pnacl-sys-2.1.6/libressl/man/gendsa.10000644000175000017500000001352312360020741017035 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "gendsa 1" .TH gendsa 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" gendsa \- generate a DSA private key from a set of parameters .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBgendsa\fR [\fB\-out filename\fR] [\fB\-des\fR] [\fB\-des3\fR] [\fB\-idea\fR] [\fB\-rand file(s)\fR] [\fB\-engine id\fR] [\fBparamfile\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBgendsa\fR command generates a \s-1DSA\s0 private key from a \s-1DSA\s0 parameter file (which will be typically generated by the \fBopenssl dsaparam\fR command). .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-des|\-des3|\-idea\fR" 4 .IX Item "-des|-des3|-idea" These options encrypt the private key with the \s-1DES,\s0 triple \s-1DES,\s0 or the \&\s-1IDEA\s0 ciphers respectively before outputting it. A pass phrase is prompted for. If none of these options is specified no encryption is used. .IP "\fB\-rand file(s)\fR" 4 .IX Item "-rand file(s)" a file or files containing random data used to seed the random number generator, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)). Multiple files can be specified separated by a OS-dependent character. The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for all others. .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBgendsa\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .IP "\fBparamfile\fR" 4 .IX Item "paramfile" This option specifies the \s-1DSA\s0 parameter file to use. The parameters in this file determine the size of the private key. \s-1DSA\s0 parameters can be generated and examined using the \fBopenssl dsaparam\fR command. .SH "NOTES" .IX Header "NOTES" \&\s-1DSA\s0 key generation is little more than random number generation so it is much quicker that \s-1RSA\s0 key generation for example. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdsaparam\fR\|(1), \fIdsa\fR\|(1), \fIgenrsa\fR\|(1), \&\fIrsa\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/CMS_get1_ReceiptRequest.30000644000175000017500000001564412360020713022171 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CMS_get1_ReceiptRequest 3" .TH CMS_get1_ReceiptRequest 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CMS_ReceiptRequest_create0, CMS_add1_ReceiptRequest, CMS_get1_ReceiptRequest, CMS_ReceiptRequest_get0_values \- CMS signed receipt request functions. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& CMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen, int allorfirst, STACK_OF(GENERAL_NAMES) *receiptList, STACK_OF(GENERAL_NAMES) *receiptsTo); \& int CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr); \& int CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr); \& void CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr, ASN1_STRING **pcid, int *pallorfirst, STACK_OF(GENERAL_NAMES) **plist, STACK_OF(GENERAL_NAMES) **prto); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fICMS_ReceiptRequest_create0()\fR creates a signed receipt request structure. The \&\fBsignedContentIdentifier\fR field is set using \fBid\fR and \fBidlen\fR, or it is set to 32 bytes of pseudo random data if \fBid\fR is \s-1NULL.\s0 If \fBreceiptList\fR is \s-1NULL\s0 the allOrFirstTier option in \fBreceiptsFrom\fR is used and set to the value of the \fBallorfirst\fR parameter. If \fBreceiptList\fR is not \s-1NULL\s0 the \fBreceiptList\fR option in \fBreceiptsFrom\fR is used. The \fBreceiptsTo\fR parameter specifies the \&\fBreceiptsTo\fR field value. .PP The \fICMS_add1_ReceiptRequest()\fR function adds a signed receipt request \fBrr\fR to SignerInfo structure \fBsi\fR. .PP int \fICMS_get1_ReceiptRequest()\fR looks for a signed receipt request in \fBsi\fR, if any is found it is decoded and written to \fBprr\fR. .PP \&\fICMS_ReceiptRequest_get0_values()\fR retrieves the values of a receipt request. The signedContentIdentifier is copied to \fBpcid\fR. If the \fBallOrFirstTier\fR option of \fBreceiptsFrom\fR is used its value is copied to \fBpallorfirst\fR otherwise the \fBreceiptList\fR field is copied to \fBplist\fR. The \fBreceiptsTo\fR parameter is copied to \fBprto\fR. .SH "NOTES" .IX Header "NOTES" For more details of the meaning of the fields see \s-1RFC2634.\s0 .PP The contents of a signed receipt should only be considered meaningful if the corresponding CMS_ContentInfo structure can be successfully verified using \&\fICMS_verify()\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICMS_ReceiptRequest_create0()\fR returns a signed receipt request structure or \&\s-1NULL\s0 if an error occurred. .PP \&\fICMS_add1_ReceiptRequest()\fR returns 1 for success or 0 is an error occurred. .PP \&\fICMS_get1_ReceiptRequest()\fR returns 1 is a signed receipt request is found and decoded. It returns 0 if a signed receipt request is not present and \-1 if it is present but malformed. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_sign\fR\|(3), \&\fICMS_sign_receipt\fR\|(3), \fICMS_verify\fR\|(3) \&\fICMS_verify_receipt\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fICMS_ReceiptRequest_create0()\fR, \fICMS_add1_ReceiptRequest()\fR, \&\fICMS_get1_ReceiptRequest()\fR and \fICMS_ReceiptRequest_get0_values()\fR were added to OpenSSL 0.9.8 deps/libressl-pnacl-sys-2.1.6/libressl/man/req.10000644000175000017500000007170012360020742016365 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "req 1" .TH req 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" req \- PKCS#10 certificate request and certificate generating utility. .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBreq\fR [\fB\-inform PEM|DER\fR] [\fB\-outform PEM|DER\fR] [\fB\-in filename\fR] [\fB\-passin arg\fR] [\fB\-out filename\fR] [\fB\-passout arg\fR] [\fB\-text\fR] [\fB\-pubkey\fR] [\fB\-noout\fR] [\fB\-verify\fR] [\fB\-modulus\fR] [\fB\-new\fR] [\fB\-rand file(s)\fR] [\fB\-newkey rsa:bits\fR] [\fB\-newkey alg:file\fR] [\fB\-nodes\fR] [\fB\-key filename\fR] [\fB\-keyform PEM|DER\fR] [\fB\-keyout filename\fR] [\fB\-keygen_engine id\fR] [\fB\-[digest]\fR] [\fB\-config filename\fR] [\fB\-subj arg\fR] [\fB\-multivalue\-rdn\fR] [\fB\-x509\fR] [\fB\-days n\fR] [\fB\-set_serial n\fR] [\fB\-asn1\-kludge\fR] [\fB\-no\-asn1\-kludge\fR] [\fB\-newhdr\fR] [\fB\-extensions section\fR] [\fB\-reqexts section\fR] [\fB\-utf8\fR] [\fB\-nameopt\fR] [\fB\-reqopt\fR] [\fB\-subject\fR] [\fB\-subj arg\fR] [\fB\-batch\fR] [\fB\-verbose\fR] [\fB\-engine id\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBreq\fR command primarily creates and processes certificate requests in PKCS#10 format. It can additionally create self signed certificates for use as root CAs for example. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" .IP "\fB\-inform DER|PEM\fR" 4 .IX Item "-inform DER|PEM" This specifies the input format. The \fB\s-1DER\s0\fR option uses an \s-1ASN1 DER\s0 encoded form compatible with the PKCS#10. The \fB\s-1PEM\s0\fR form is the default format: it consists of the \fB\s-1DER\s0\fR format base64 encoded with additional header and footer lines. .IP "\fB\-outform DER|PEM\fR" 4 .IX Item "-outform DER|PEM" This specifies the output format, the options have the same meaning as the \&\fB\-inform\fR option. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read a request from or standard input if this option is not specified. A request is only read if the creation options (\fB\-new\fR and \fB\-newkey\fR) are not specified. .IP "\fB\-passin arg\fR" 4 .IX Item "-passin arg" the input file password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" This specifies the output filename to write to or standard output by default. .IP "\fB\-passout arg\fR" 4 .IX Item "-passout arg" the output file password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-text\fR" 4 .IX Item "-text" prints out the certificate request in text form. .IP "\fB\-subject\fR" 4 .IX Item "-subject" prints out the request subject (or certificate subject if \fB\-x509\fR is specified) .IP "\fB\-pubkey\fR" 4 .IX Item "-pubkey" outputs the public key. .IP "\fB\-noout\fR" 4 .IX Item "-noout" this option prevents output of the encoded version of the request. .IP "\fB\-modulus\fR" 4 .IX Item "-modulus" this option prints out the value of the modulus of the public key contained in the request. .IP "\fB\-verify\fR" 4 .IX Item "-verify" verifies the signature on the request. .IP "\fB\-new\fR" 4 .IX Item "-new" this option generates a new certificate request. It will prompt the user for the relevant field values. The actual fields prompted for and their maximum and minimum sizes are specified in the configuration file and any requested extensions. .Sp If the \fB\-key\fR option is not used it will generate a new \s-1RSA\s0 private key using information specified in the configuration file. .IP "\fB\-subj arg\fR" 4 .IX Item "-subj arg" Replaces subject field of input request with specified data and outputs modified request. The arg must be formatted as \&\fI/type0=value0/type1=value1/type2=...\fR, characters may be escaped by \e (backslash), no spaces are skipped. .IP "\fB\-rand file(s)\fR" 4 .IX Item "-rand file(s)" a file or files containing random data used to seed the random number generator, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)). Multiple files can be specified separated by a OS-dependent character. The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for all others. .IP "\fB\-newkey arg\fR" 4 .IX Item "-newkey arg" this option creates a new certificate request and a new private key. The argument takes one of several forms. \fBrsa:nbits\fR, where \&\fBnbits\fR is the number of bits, generates an \s-1RSA\s0 key \fBnbits\fR in size. If \fBnbits\fR is omitted, i.e. \fB\-newkey rsa\fR specified, the default key size, specified in the configuration file is used. .Sp All other algorithms support the \fB\-newkey alg:file\fR form, where file may be an algorithm parameter file, created by the \fBgenpkey \-genparam\fR command or and X.509 certificate for a key with approriate algorithm. .Sp \&\fBparam:file\fR generates a key using the parameter file or certificate \fBfile\fR, the algorithm is determined by the parameters. \fBalgname:file\fR use algorithm \&\fBalgname\fR and parameter file \fBfile\fR: the two algorithms must match or an error occurs. \fBalgname\fR just uses algorithm \fBalgname\fR, and parameters, if neccessary should be specified via \fB\-pkeyopt\fR parameter. .Sp \&\fBdsa:filename\fR generates a \s-1DSA\s0 key using the parameters in the file \fBfilename\fR. \fBec:filename\fR generates \s-1EC\s0 key (usable both with \&\s-1ECDSA\s0 or \s-1ECDH\s0 algorithms), \fBgost2001:filename\fR generates \s-1GOST R 34.10\-2001\s0 key (requires \fBccgost\fR engine configured in the configuration file). If just \fBgost2001\fR is specified a parameter set should be specified by \fB\-pkeyopt paramset:X\fR .IP "\fB\-pkeyopt opt:value\fR" 4 .IX Item "-pkeyopt opt:value" set the public key algorithm option \fBopt\fR to \fBvalue\fR. The precise set of options supported depends on the public key algorithm used and its implementation. See \fB\s-1KEY GENERATION OPTIONS\s0\fR in the \fBgenpkey\fR manual page for more details. .IP "\fB\-key filename\fR" 4 .IX Item "-key filename" This specifies the file to read the private key from. It also accepts PKCS#8 format private keys for \s-1PEM\s0 format files. .IP "\fB\-keyform PEM|DER\fR" 4 .IX Item "-keyform PEM|DER" the format of the private key file specified in the \fB\-key\fR argument. \s-1PEM\s0 is the default. .IP "\fB\-keyout filename\fR" 4 .IX Item "-keyout filename" this gives the filename to write the newly created private key to. If this option is not specified then the filename present in the configuration file is used. .IP "\fB\-nodes\fR" 4 .IX Item "-nodes" if this option is specified then if a private key is created it will not be encrypted. .IP "\fB\-[digest]\fR" 4 .IX Item "-[digest]" this specifies the message digest to sign the request with (such as \&\fB\-md5\fR, \fB\-sha1\fR). This overrides the digest algorithm specified in the configuration file. .Sp Some public key algorithms may override this choice. For instance, \s-1DSA\s0 signatures always use \s-1SHA1, GOST R 34.10\s0 signatures always use \&\s-1GOST R 34.11\-94 \s0(\fB\-md_gost94\fR). .IP "\fB\-config filename\fR" 4 .IX Item "-config filename" this allows an alternative configuration file to be specified, this overrides the compile time filename or any specified in the \fB\s-1OPENSSL_CONF\s0\fR environment variable. .IP "\fB\-subj arg\fR" 4 .IX Item "-subj arg" sets subject name for new request or supersedes the subject name when processing a request. The arg must be formatted as \fI/type0=value0/type1=value1/type2=...\fR, characters may be escaped by \e (backslash), no spaces are skipped. .IP "\fB\-multivalue\-rdn\fR" 4 .IX Item "-multivalue-rdn" this option causes the \-subj argument to be interpreted with full support for multivalued RDNs. Example: .Sp \&\fI/DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe\fR .Sp If \-multi\-rdn is not used then the \s-1UID\s0 value is \fI123456+CN=John Doe\fR. .IP "\fB\-x509\fR" 4 .IX Item "-x509" this option outputs a self signed certificate instead of a certificate request. This is typically used to generate a test certificate or a self signed root \s-1CA.\s0 The extensions added to the certificate (if any) are specified in the configuration file. Unless specified using the \fBset_serial\fR option \fB0\fR will be used for the serial number. .IP "\fB\-days n\fR" 4 .IX Item "-days n" when the \fB\-x509\fR option is being used this specifies the number of days to certify the certificate for. The default is 30 days. .IP "\fB\-set_serial n\fR" 4 .IX Item "-set_serial n" serial number to use when outputting a self signed certificate. This may be specified as a decimal value or a hex value if preceded by \fB0x\fR. It is possible to use negative serial numbers but this is not recommended. .IP "\fB\-extensions section\fR" 4 .IX Item "-extensions section" .PD 0 .IP "\fB\-reqexts section\fR" 4 .IX Item "-reqexts section" .PD these options specify alternative sections to include certificate extensions (if the \fB\-x509\fR option is present) or certificate request extensions. This allows several different sections to be used in the same configuration file to specify requests for a variety of purposes. .IP "\fB\-utf8\fR" 4 .IX Item "-utf8" this option causes field values to be interpreted as \s-1UTF8\s0 strings, by default they are interpreted as \s-1ASCII.\s0 This means that the field values, whether prompted from a terminal or obtained from a configuration file, must be valid \s-1UTF8\s0 strings. .IP "\fB\-nameopt option\fR" 4 .IX Item "-nameopt option" option which determines how the subject or issuer names are displayed. The \&\fBoption\fR argument can be a single option or multiple options separated by commas. Alternatively the \fB\-nameopt\fR switch may be used more than once to set multiple options. See the \fIx509\fR\|(1) manual page for details. .IP "\fB\-reqopt\fR" 4 .IX Item "-reqopt" customise the output format used with \fB\-text\fR. The \fBoption\fR argument can be a single option or multiple options separated by commas. .Sp See discission of the \fB\-certopt\fR parameter in the \fBx509\fR command. .IP "\fB\-asn1\-kludge\fR" 4 .IX Item "-asn1-kludge" by default the \fBreq\fR command outputs certificate requests containing no attributes in the correct PKCS#10 format. However certain CAs will only accept requests containing no attributes in an invalid form: this option produces this invalid format. .Sp More precisely the \fBAttributes\fR in a PKCS#10 certificate request are defined as a \fB\s-1SET OF\s0 Attribute\fR. They are \fBnot \s-1OPTIONAL\s0\fR so if no attributes are present then they should be encoded as an empty \fB\s-1SET OF\s0\fR. The invalid form does not include the empty \&\fB\s-1SET OF\s0\fR whereas the correct form does. .Sp It should be noted that very few CAs still require the use of this option. .IP "\fB\-no\-asn1\-kludge\fR" 4 .IX Item "-no-asn1-kludge" Reverses effect of \fB\-asn1\-kludge\fR .IP "\fB\-newhdr\fR" 4 .IX Item "-newhdr" Adds the word \fB\s-1NEW\s0\fR to the \s-1PEM\s0 file header and footer lines on the outputted request. Some software (Netscape certificate server) and some CAs need this. .IP "\fB\-batch\fR" 4 .IX Item "-batch" non-interactive mode. .IP "\fB\-verbose\fR" 4 .IX Item "-verbose" print extra details about the operations being performed. .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBreq\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .IP "\fB\-keygen_engine id\fR" 4 .IX Item "-keygen_engine id" specifies an engine (by its unique \fBid\fR string) which would be used for key generation operations. .SH "CONFIGURATION FILE FORMAT" .IX Header "CONFIGURATION FILE FORMAT" The configuration options are specified in the \fBreq\fR section of the configuration file. As with all configuration files if no value is specified in the specific section (i.e. \fBreq\fR) then the initial unnamed or \fBdefault\fR section is searched too. .PP The options available are described in detail below. .IP "\fBinput_password output_password\fR" 4 .IX Item "input_password output_password" The passwords for the input private key file (if present) and the output private key file (if one will be created). The command line options \fBpassin\fR and \fBpassout\fR override the configuration file values. .IP "\fBdefault_bits\fR" 4 .IX Item "default_bits" This specifies the default key size in bits. If not specified then 512 is used. It is used if the \fB\-new\fR option is used. It can be overridden by using the \fB\-newkey\fR option. .IP "\fBdefault_keyfile\fR" 4 .IX Item "default_keyfile" This is the default filename to write a private key to. If not specified the key is written to standard output. This can be overridden by the \fB\-keyout\fR option. .IP "\fBoid_file\fR" 4 .IX Item "oid_file" This specifies a file containing additional \fB\s-1OBJECT IDENTIFIERS\s0\fR. Each line of the file should consist of the numerical form of the object identifier followed by white space then the short name followed by white space and finally the long name. .IP "\fBoid_section\fR" 4 .IX Item "oid_section" This specifies a section in the configuration file containing extra object identifiers. Each line should consist of the short name of the object identifier followed by \fB=\fR and the numerical form. The short and long names are the same when this option is used. .IP "\fB\s-1RANDFILE\s0\fR" 4 .IX Item "RANDFILE" This specifies a filename in which random number seed information is placed and read from, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)). It is used for private key generation. .IP "\fBencrypt_key\fR" 4 .IX Item "encrypt_key" If this is set to \fBno\fR then if a private key is generated it is \&\fBnot\fR encrypted. This is equivalent to the \fB\-nodes\fR command line option. For compatibility \fBencrypt_rsa_key\fR is an equivalent option. .IP "\fBdefault_md\fR" 4 .IX Item "default_md" This option specifies the digest algorithm to use. Possible values include \fBmd5 sha1 mdc2\fR. If not present then \s-1MD5\s0 is used. This option can be overridden on the command line. .IP "\fBstring_mask\fR" 4 .IX Item "string_mask" This option masks out the use of certain string types in certain fields. Most users will not need to change this option. .Sp It can be set to several values \fBdefault\fR which is also the default option uses PrintableStrings, T61Strings and BMPStrings if the \&\fBpkix\fR value is used then only PrintableStrings and BMPStrings will be used. This follows the \s-1PKIX\s0 recommendation in \s-1RFC2459.\s0 If the \&\fButf8only\fR option is used then only UTF8Strings will be used: this is the \s-1PKIX\s0 recommendation in \s-1RFC2459\s0 after 2003. Finally the \fBnombstr\fR option just uses PrintableStrings and T61Strings: certain software has problems with BMPStrings and UTF8Strings: in particular Netscape. .IP "\fBreq_extensions\fR" 4 .IX Item "req_extensions" this specifies the configuration file section containing a list of extensions to add to the certificate request. It can be overridden by the \fB\-reqexts\fR command line switch. See the \&\fIx509v3_config\fR\|(5) manual page for details of the extension section format. .IP "\fBx509_extensions\fR" 4 .IX Item "x509_extensions" this specifies the configuration file section containing a list of extensions to add to certificate generated when the \fB\-x509\fR switch is used. It can be overridden by the \fB\-extensions\fR command line switch. .IP "\fBprompt\fR" 4 .IX Item "prompt" if set to the value \fBno\fR this disables prompting of certificate fields and just takes values from the config file directly. It also changes the expected format of the \fBdistinguished_name\fR and \fBattributes\fR sections. .IP "\fButf8\fR" 4 .IX Item "utf8" if set to the value \fByes\fR then field values to be interpreted as \s-1UTF8\s0 strings, by default they are interpreted as \s-1ASCII.\s0 This means that the field values, whether prompted from a terminal or obtained from a configuration file, must be valid \s-1UTF8\s0 strings. .IP "\fBattributes\fR" 4 .IX Item "attributes" this specifies the section containing any request attributes: its format is the same as \fBdistinguished_name\fR. Typically these may contain the challengePassword or unstructuredName types. They are currently ignored by OpenSSL's request signing utilities but some CAs might want them. .IP "\fBdistinguished_name\fR" 4 .IX Item "distinguished_name" This specifies the section containing the distinguished name fields to prompt for when generating a certificate or certificate request. The format is described in the next section. .SH "DISTINGUISHED NAME AND ATTRIBUTE SECTION FORMAT" .IX Header "DISTINGUISHED NAME AND ATTRIBUTE SECTION FORMAT" There are two separate formats for the distinguished name and attribute sections. If the \fBprompt\fR option is set to \fBno\fR then these sections just consist of field names and values: for example, .PP .Vb 3 \& CN=My Name \& OU=My Organization \& emailAddress=someone@somewhere.org .Ve .PP This allows external programs (e.g. \s-1GUI\s0 based) to generate a template file with all the field names and values and just pass it to \fBreq\fR. An example of this kind of configuration file is contained in the \fB\s-1EXAMPLES\s0\fR section. .PP Alternatively if the \fBprompt\fR option is absent or not set to \fBno\fR then the file contains field prompting information. It consists of lines of the form: .PP .Vb 4 \& fieldName="prompt" \& fieldName_default="default field value" \& fieldName_min= 2 \& fieldName_max= 4 .Ve .PP \&\*(L"fieldName\*(R" is the field name being used, for example commonName (or \s-1CN\s0). The \*(L"prompt\*(R" string is used to ask the user to enter the relevant details. If the user enters nothing then the default value is used if no default value is present then the field is omitted. A field can still be omitted if a default value is present if the user just enters the '.' character. .PP The number of characters entered must be between the fieldName_min and fieldName_max limits: there may be additional restrictions based on the field being used (for example countryName can only ever be two characters long and must fit in a PrintableString). .PP Some fields (such as organizationName) can be used more than once in a \s-1DN.\s0 This presents a problem because configuration files will not recognize the same name occurring twice. To avoid this problem if the fieldName contains some characters followed by a full stop they will be ignored. So for example a second organizationName can be input by calling it \*(L"1.organizationName\*(R". .PP The actual permitted field names are any object identifier short or long names. These are compiled into OpenSSL and include the usual values such as commonName, countryName, localityName, organizationName, organizationUnitName, stateOrProvinceName. Additionally emailAddress is include as well as name, surname, givenName initials and dnQualifier. .PP Additional object identifiers can be defined with the \fBoid_file\fR or \&\fBoid_section\fR options in the configuration file. Any additional fields will be treated as though they were a DirectoryString. .SH "EXAMPLES" .IX Header "EXAMPLES" Examine and verify certificate request: .PP .Vb 1 \& openssl req \-in req.pem \-text \-verify \-noout .Ve .PP Create a private key and then generate a certificate request from it: .PP .Vb 2 \& openssl genrsa \-out key.pem 1024 \& openssl req \-new \-key key.pem \-out req.pem .Ve .PP The same but just using req: .PP .Vb 1 \& openssl req \-newkey rsa:1024 \-keyout key.pem \-out req.pem .Ve .PP Generate a self signed root certificate: .PP .Vb 1 \& openssl req \-x509 \-newkey rsa:1024 \-keyout key.pem \-out req.pem .Ve .PP Example of a file pointed to by the \fBoid_file\fR option: .PP .Vb 2 \& 1.2.3.4 shortName A longer Name \& 1.2.3.6 otherName Other longer Name .Ve .PP Example of a section pointed to by \fBoid_section\fR making use of variable expansion: .PP .Vb 2 \& testoid1=1.2.3.5 \& testoid2=${testoid1}.6 .Ve .PP Sample configuration file prompting for field values: .PP .Vb 6 \& [ req ] \& default_bits = 1024 \& default_keyfile = privkey.pem \& distinguished_name = req_distinguished_name \& attributes = req_attributes \& x509_extensions = v3_ca \& \& dirstring_type = nobmp \& \& [ req_distinguished_name ] \& countryName = Country Name (2 letter code) \& countryName_default = AU \& countryName_min = 2 \& countryName_max = 2 \& \& localityName = Locality Name (eg, city) \& \& organizationalUnitName = Organizational Unit Name (eg, section) \& \& commonName = Common Name (eg, YOUR name) \& commonName_max = 64 \& \& emailAddress = Email Address \& emailAddress_max = 40 \& \& [ req_attributes ] \& challengePassword = A challenge password \& challengePassword_min = 4 \& challengePassword_max = 20 \& \& [ v3_ca ] \& \& subjectKeyIdentifier=hash \& authorityKeyIdentifier=keyid:always,issuer:always \& basicConstraints = CA:true .Ve .PP Sample configuration containing all field values: .PP .Vb 1 \& RANDFILE = $ENV::HOME/.rnd \& \& [ req ] \& default_bits = 1024 \& default_keyfile = keyfile.pem \& distinguished_name = req_distinguished_name \& attributes = req_attributes \& prompt = no \& output_password = mypass \& \& [ req_distinguished_name ] \& C = GB \& ST = Test State or Province \& L = Test Locality \& O = Organization Name \& OU = Organizational Unit Name \& CN = Common Name \& emailAddress = test@email.address \& \& [ req_attributes ] \& challengePassword = A challenge password .Ve .SH "NOTES" .IX Header "NOTES" The header and footer lines in the \fB\s-1PEM\s0\fR format are normally: .PP .Vb 2 \& \-\-\-\-\-BEGIN CERTIFICATE REQUEST\-\-\-\-\- \& \-\-\-\-\-END CERTIFICATE REQUEST\-\-\-\-\- .Ve .PP some software (some versions of Netscape certificate server) instead needs: .PP .Vb 2 \& \-\-\-\-\-BEGIN NEW CERTIFICATE REQUEST\-\-\-\-\- \& \-\-\-\-\-END NEW CERTIFICATE REQUEST\-\-\-\-\- .Ve .PP which is produced with the \fB\-newhdr\fR option but is otherwise compatible. Either form is accepted transparently on input. .PP The certificate requests generated by \fBXenroll\fR with \s-1MSIE\s0 have extensions added. It includes the \fBkeyUsage\fR extension which determines the type of key (signature only or general purpose) and any additional OIDs entered by the script in an extendedKeyUsage extension. .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" The following messages are frequently asked about: .PP .Vb 2 \& Using configuration from /some/path/openssl.cnf \& Unable to load config info .Ve .PP This is followed some time later by... .PP .Vb 2 \& unable to find \*(Aqdistinguished_name\*(Aq in config \& problems making Certificate Request .Ve .PP The first error message is the clue: it can't find the configuration file! Certain operations (like examining a certificate request) don't need a configuration file so its use isn't enforced. Generation of certificates or requests however does need a configuration file. This could be regarded as a bug. .PP Another puzzling message is this: .PP .Vb 2 \& Attributes: \& a0:00 .Ve .PP this is displayed when no attributes are present and the request includes the correct empty \fB\s-1SET OF\s0\fR structure (the \s-1DER\s0 encoding of which is 0xa0 0x00). If you just see: .PP .Vb 1 \& Attributes: .Ve .PP then the \fB\s-1SET OF\s0\fR is missing and the encoding is technically invalid (but it is tolerated). See the description of the command line option \fB\-asn1\-kludge\fR for more information. .SH "ENVIRONMENT VARIABLES" .IX Header "ENVIRONMENT VARIABLES" The variable \fB\s-1OPENSSL_CONF\s0\fR if defined allows an alternative configuration file location to be specified, it will be overridden by the \fB\-config\fR command line switch if it is present. For compatibility reasons the \fB\s-1SSLEAY_CONF\s0\fR environment variable serves the same purpose but its use is discouraged. .SH "BUGS" .IX Header "BUGS" OpenSSL's handling of T61Strings (aka TeletexStrings) is broken: it effectively treats them as \s-1ISO\-8859\-1 \s0(Latin 1), Netscape and \s-1MSIE\s0 have similar behaviour. This can cause problems if you need characters that aren't available in PrintableStrings and you don't want to or can't use BMPStrings. .PP As a consequence of the T61String handling the only correct way to represent accented characters in OpenSSL is to use a BMPString: unfortunately Netscape currently chokes on these. If you have to use accented characters with Netscape and \s-1MSIE\s0 then you currently need to use the invalid T61String form. .PP The current prompting is not very friendly. It doesn't allow you to confirm what you've just entered. Other things like extensions in certificate requests are statically defined in the configuration file. Some of these: like an email address in subjectAltName should be input by the user. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIx509\fR\|(1), \fIca\fR\|(1), \fIgenrsa\fR\|(1), \&\fIgendsa\fR\|(1), \fIconfig\fR\|(5), \&\fIx509v3_config\fR\|(5) deps/libressl-pnacl-sys-2.1.6/libressl/man/genpkey.10000644000175000017500000002502012360020741017231 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "genpkey 1" .TH genpkey 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" genpkey \- generate a private key .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBgenpkey\fR [\fB\-out filename\fR] [\fB\-outform PEM|DER\fR] [\fB\-pass arg\fR] [\fB\-cipher\fR] [\fB\-engine id\fR] [\fB\-paramfile file\fR] [\fB\-algorithm alg\fR] [\fB\-pkeyopt opt:value\fR] [\fB\-genparam\fR] [\fB\-text\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBgenpkey\fR command generates a private key. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" the output filename. If this argument is not specified then standard output is used. .IP "\fB\-outform DER|PEM\fR" 4 .IX Item "-outform DER|PEM" This specifies the output format \s-1DER\s0 or \s-1PEM.\s0 .IP "\fB\-pass arg\fR" 4 .IX Item "-pass arg" the output file password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-cipher\fR" 4 .IX Item "-cipher" This option encrypts the private key with the supplied cipher. Any algorithm name accepted by \fIEVP_get_cipherbyname()\fR is acceptable such as \fBdes3\fR. .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBgenpkey\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. If used this option should precede all other options. .IP "\fB\-algorithm alg\fR" 4 .IX Item "-algorithm alg" public key algorithm to use such as \s-1RSA, DSA\s0 or \s-1DH.\s0 If used this option must precede any \fB\-pkeyopt\fR options. The options \fB\-paramfile\fR and \fB\-algorithm\fR are mutually exclusive. .IP "\fB\-pkeyopt opt:value\fR" 4 .IX Item "-pkeyopt opt:value" set the public key algorithm option \fBopt\fR to \fBvalue\fR. The precise set of options supported depends on the public key algorithm used and its implementation. See \fB\s-1KEY GENERATION OPTIONS\s0\fR below for more details. .IP "\fB\-genparam\fR" 4 .IX Item "-genparam" generate a set of parameters instead of a private key. If used this option must precede and \fB\-algorithm\fR, \fB\-paramfile\fR or \fB\-pkeyopt\fR options. .IP "\fB\-paramfile filename\fR" 4 .IX Item "-paramfile filename" Some public key algorithms generate a private key based on a set of parameters. They can be supplied using this option. If this option is used the public key algorithm used is determined by the parameters. If used this option must precede and \fB\-pkeyopt\fR options. The options \fB\-paramfile\fR and \fB\-algorithm\fR are mutually exclusive. .IP "\fB\-text\fR" 4 .IX Item "-text" Print an (unencrypted) text representation of private and public keys and parameters along with the \s-1PEM\s0 or \s-1DER\s0 structure. .SH "KEY GENERATION OPTIONS" .IX Header "KEY GENERATION OPTIONS" The options supported by each algorith and indeed each implementation of an algorithm can vary. The options for the OpenSSL implementations are detailed below. .SH "RSA KEY GENERATION OPTIONS" .IX Header "RSA KEY GENERATION OPTIONS" .IP "\fBrsa_keygen_bits:numbits\fR" 4 .IX Item "rsa_keygen_bits:numbits" The number of bits in the generated key. If not specified 2048 is used. .IP "\fBrsa_keygen_pubexp:value\fR" 4 .IX Item "rsa_keygen_pubexp:value" The \s-1RSA\s0 public exponent value. This can be a large decimal or hexadecimal value if preceded by \fB0x\fR. Default value is 65537. .SH "DSA PARAMETER GENERATION OPTIONS" .IX Header "DSA PARAMETER GENERATION OPTIONS" .IP "\fBdsa_paramgen_bits:numbits\fR" 4 .IX Item "dsa_paramgen_bits:numbits" The number of bits in the generated parameters. If not specified 1024 is used. .SH "DH PARAMETER GENERATION OPTIONS" .IX Header "DH PARAMETER GENERATION OPTIONS" .IP "\fBdh_paramgen_prime_len:numbits\fR" 4 .IX Item "dh_paramgen_prime_len:numbits" The number of bits in the prime parameter \fBp\fR. .IP "\fBdh_paramgen_generator:value\fR" 4 .IX Item "dh_paramgen_generator:value" The value to use for the generator \fBg\fR. .SH "EC PARAMETER GENERATION OPTIONS" .IX Header "EC PARAMETER GENERATION OPTIONS" .IP "\fBec_paramgen_curve:curve\fR" 4 .IX Item "ec_paramgen_curve:curve" the \s-1EC\s0 curve to use. .SH "GOST2001 KEY GENERATION AND PARAMETER OPTIONS" .IX Header "GOST2001 KEY GENERATION AND PARAMETER OPTIONS" Gost 2001 support is not enabled by default. To enable this algorithm, one should load the ccgost engine in the OpenSSL configuration file. See \s-1README\s0.gost file in the engines/ccgost directiry of the source distribution for more details. .PP Use of a parameter file for the \s-1GOST R 34.10\s0 algorithm is optional. Parameters can be specified during key generation directly as well as during generation of parameter file. .IP "\fBparamset:name\fR" 4 .IX Item "paramset:name" Specifies \s-1GOST R 34.10\-2001\s0 parameter set according to \s-1RFC 4357.\s0 Parameter set can be specified using abbreviated name, object short name or numeric \s-1OID.\s0 Following parameter sets are supported: .Sp .Vb 7 \& paramset OID Usage \& A 1.2.643.2.2.35.1 Signature \& B 1.2.643.2.2.35.2 Signature \& C 1.2.643.2.2.35.3 Signature \& XA 1.2.643.2.2.36.0 Key exchange \& XB 1.2.643.2.2.36.1 Key exchange \& test 1.2.643.2.2.35.0 Test purposes .Ve .SH "NOTES" .IX Header "NOTES" The use of the genpkey program is encouraged over the algorithm specific utilities because additional algorithm options and \s-1ENGINE\s0 provided algorithms can be used. .SH "EXAMPLES" .IX Header "EXAMPLES" Generate an \s-1RSA\s0 private key using default parameters: .PP .Vb 1 \& openssl genpkey \-algorithm RSA \-out key.pem .Ve .PP Encrypt output private key using 128 bit \s-1AES\s0 and the passphrase \*(L"hello\*(R": .PP .Vb 1 \& openssl genpkey \-algorithm RSA \-out key.pem \-aes\-128\-cbc \-pass pass:hello .Ve .PP Generate a 2048 bit \s-1RSA\s0 key using 3 as the public exponent: .PP .Vb 2 \& openssl genpkey \-algorithm RSA \-out key.pem \-pkeyopt rsa_keygen_bits:2048 \e \& \-pkeyopt rsa_keygen_pubexp:3 .Ve .PP Generate 1024 bit \s-1DSA\s0 parameters: .PP .Vb 2 \& openssl genpkey \-genparam \-algorithm DSA \-out dsap.pem \e \& \-pkeyopt dsa_paramgen_bits:1024 .Ve .PP Generate \s-1DSA\s0 key from parameters: .PP .Vb 1 \& openssl genpkey \-paramfile dsap.pem \-out dsakey.pem .Ve .PP Generate 1024 bit \s-1DH\s0 parameters: .PP .Vb 2 \& openssl genpkey \-genparam \-algorithm DH \-out dhp.pem \e \& \-pkeyopt dh_paramgen_prime_len:1024 .Ve .PP Generate \s-1DH\s0 key from parameters: .PP .Vb 1 \& openssl genpkey \-paramfile dhp.pem \-out dhkey.pem .Ve deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_new_CMS.30000644000175000017500000001440712360020710017560 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_new_CMS 3" .TH BIO_new_CMS 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" .Vb 1 \& BIO_new_CMS \- CMS streaming filter BIO .Ve .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_new_CMS()\fR returns a streaming filter \s-1BIO\s0 chain based on \fBcms\fR. The output of the filter is written to \fBout\fR. Any data written to the chain is automatically translated to a \s-1BER\s0 format \s-1CMS\s0 structure of the appropriate type. .SH "NOTES" .IX Header "NOTES" The chain returned by this function behaves like a standard filter \s-1BIO.\s0 It supports non blocking I/O. Content is processed and streamed on the fly and not all held in memory at once: so it is possible to encode very large structures. After all content has been written through the chain \fIBIO_flush()\fR must be called to finalise the structure. .PP The \fB\s-1CMS_STREAM\s0\fR flag must be included in the corresponding \fBflags\fR parameter of the \fBcms\fR creation function. .PP If an application wishes to write additional data to \fBout\fR BIOs should be removed from the chain using \fIBIO_pop()\fR and freed with \fIBIO_free()\fR until \fBout\fR is reached. If no additional data needs to be written \fIBIO_free_all()\fR can be called to free up the whole chain. .PP Any content written through the filter is used verbatim: no canonical translation is performed. .PP It is possible to chain multiple BIOs to, for example, create a triple wrapped signed, enveloped, signed structure. In this case it is the applications responsibility to set the inner content type of any outer CMS_ContentInfo structures. .PP Large numbers of small writes through the chain should be avoided as this will produce an output consisting of lots of \s-1OCTET STRING\s0 structures. Prepending a \fIBIO_f_buffer()\fR buffering \s-1BIO\s0 will prevent this. .SH "BUGS" .IX Header "BUGS" There is currently no corresponding inverse \s-1BIO:\s0 i.e. one which can decode a \s-1CMS\s0 structure on the fly. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBIO_new_CMS()\fR returns a \s-1BIO\s0 chain when successful or \s-1NULL\s0 if an error occurred. The error can be obtained from \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_sign\fR\|(3), \&\fICMS_encrypt\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIBIO_new_CMS()\fR was added to OpenSSL 1.0.0 deps/libressl-pnacl-sys-2.1.6/libressl/man/evp.30000644000175000017500000002157512360020730016374 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "evp 3" .TH evp 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" evp \- high\-level cryptographic functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \s-1EVP\s0 library provides a high-level interface to cryptographic functions. .PP \&\fBEVP_Seal\fR\fI...\fR and \fBEVP_Open\fR\fI...\fR provide public key encryption and decryption to implement digital \*(L"envelopes\*(R". .PP The \fBEVP_DigestSign\fR\fI...\fR and \&\fBEVP_DigestVerify\fR\fI...\fR functions implement digital signatures and Message Authentication Codes (MACs). Also see the older \&\fBEVP_Sign\fR\fI...\fR and \fBEVP_Verify\fR\fI...\fR functions. .PP Symmetric encryption is available with the \fBEVP_Encrypt\fR\fI...\fR functions. The \fBEVP_Digest\fR\fI...\fR functions provide message digests. .PP The \fB\s-1EVP_PKEY\s0\fR\fI...\fR functions provide a high level interface to asymmetric algorithms. To create a new \s-1EVP_PKEY\s0 see \&\fIEVP_PKEY_new\fR\|(3). EVP_PKEYs can be associated with a private key of a particular algorithm by using the functions described on the \fIEVP_PKEY_set1_RSA\fR\|(3) page, or new keys can be generated using \fIEVP_PKEY_keygen\fR\|(3). EVP_PKEYs can be compared using \fIEVP_PKEY_cmp\fR\|(3), or printed using \&\fIEVP_PKEY_print_private\fR\|(3). .PP The \s-1EVP_PKEY\s0 functions support the full range of asymmetric algorithm operations: .IP "For key agreement see \fIEVP_PKEY_derive\fR\|(3)" 4 .IX Item "For key agreement see EVP_PKEY_derive" .PD 0 .IP "For signing and verifying see \fIEVP_PKEY_sign\fR\|(3), \fIEVP_PKEY_verify\fR\|(3) and \fIEVP_PKEY_verify_recover\fR\|(3). However, note that these functions do not perform a digest of the data to be signed. Therefore normally you would use the \fBEVP_DigestSign\fR\fI...\fR functions for this purpose." 4 .IX Item "For signing and verifying see EVP_PKEY_sign, EVP_PKEY_verify and EVP_PKEY_verify_recover. However, note that these functions do not perform a digest of the data to be signed. Therefore normally you would use the EVP_DigestSign... functions for this purpose." .ie n .IP "For encryption and decryption see \fIEVP_PKEY_encrypt\fR\|(3) and \fIEVP_PKEY_decrypt\fR\|(3) respectively. However, note that these functions perform encryption and decryption only. As public key encryption is an expensive operation, normally you would wrap an encrypted message in a ""digital envelope"" using the \fBEVP_Seal\fR\fI...\fR and \fBEVP_Open\fR\fI...\fR functions." 4 .el .IP "For encryption and decryption see \fIEVP_PKEY_encrypt\fR\|(3) and \fIEVP_PKEY_decrypt\fR\|(3) respectively. However, note that these functions perform encryption and decryption only. As public key encryption is an expensive operation, normally you would wrap an encrypted message in a ``digital envelope'' using the \fBEVP_Seal\fR\fI...\fR and \fBEVP_Open\fR\fI...\fR functions." 4 .IX Item "For encryption and decryption see EVP_PKEY_encrypt and EVP_PKEY_decrypt respectively. However, note that these functions perform encryption and decryption only. As public key encryption is an expensive operation, normally you would wrap an encrypted message in a digital envelope using the EVP_Seal... and EVP_Open... functions." .PD .PP The \fIEVP_BytesToKey\fR\|(3) function provides some limited support for password based encryption. Careful selection of the parameters will provide a PKCS#5 \s-1PBKDF1\s0 compatible implementation. However, new applications should not typically use this (preferring, for example, \&\s-1PBKDF2\s0 from PCKS#5). .PP Algorithms are loaded with \fIOpenSSL_add_all_algorithms\fR\|(3). .PP All the symmetric algorithms (ciphers), digests and asymmetric algorithms (public key algorithms) can be replaced by \s-1ENGINE\s0 modules providing alternative implementations. If \s-1ENGINE\s0 implementations of ciphers or digests are registered as defaults, then the various \s-1EVP\s0 functions will automatically use those implementations automatically in preference to built in software implementations. For more information, consult the \fIengine\fR\|(3) man page. .PP Although low level algorithm specific functions exist for many algorithms their use is discouraged. They cannot be used with an \s-1ENGINE\s0 and \s-1ENGINE\s0 versions of new algorithms cannot be accessed using the low level functions. Also makes code harder to adapt to new algorithms and some options are not cleanly supported at the low level and some operations are more efficient using the high level interface. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_DigestInit\fR\|(3), \&\fIEVP_EncryptInit\fR\|(3), \&\fIEVP_OpenInit\fR\|(3), \&\fIEVP_SealInit\fR\|(3), \&\fIEVP_DigestSignInit\fR\|(3), \&\fIEVP_SignInit\fR\|(3), \&\fIEVP_VerifyInit\fR\|(3), \&\fIEVP_PKEY_new\fR\|(3), \&\fIEVP_PKEY_set1_RSA\fR\|(3), \&\fIEVP_PKEY_keygen\fR\|(3), \&\fIEVP_PKEY_print_private\fR\|(3), \&\fIEVP_PKEY_decrypt\fR\|(3), \&\fIEVP_PKEY_encrypt\fR\|(3), \&\fIEVP_PKEY_sign\fR\|(3), \&\fIEVP_PKEY_verify\fR\|(3), \&\fIEVP_PKEY_verify_recover\fR\|(3), \&\fIEVP_PKEY_derive\fR\|(3), \&\fIEVP_BytesToKey\fR\|(3), \&\fIOpenSSL_add_all_algorithms\fR\|(3), \&\fIengine\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_f_null.30000644000175000017500000001116012360020710017535 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_f_null 3" .TH BIO_f_null 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_f_null \- null filter .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIO_METHOD * BIO_f_null(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_f_null()\fR returns the null filter \s-1BIO\s0 method. This is a filter \s-1BIO\s0 that does nothing. .PP All requests to a null filter \s-1BIO\s0 are passed through to the next \s-1BIO\s0 in the chain: this means that a \s-1BIO\s0 chain containing a null filter \s-1BIO\s0 behaves just as though the \s-1BIO\s0 was not there. .SH "NOTES" .IX Header "NOTES" As may be apparent a null filter \s-1BIO\s0 is not particularly useful. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBIO_f_null()\fR returns the null filter \s-1BIO\s0 method. deps/libressl-pnacl-sys-2.1.6/libressl/man/DH_generate_parameters.30000644000175000017500000001530012360020714022161 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DH_generate_parameters 3" .TH DH_generate_parameters 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DH_generate_parameters_ex, DH_generate_parameters, DH_check \- generate and check Diffie\-Hellman parameters .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int DH_generate_parameters_ex(DH *dh, int prime_len,int generator, BN_GENCB *cb); \& \& int DH_check(DH *dh, int *codes); .Ve .PP Deprecated: .PP .Vb 2 \& DH *DH_generate_parameters(int prime_len, int generator, \& void (*callback)(int, int, void *), void *cb_arg); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIDH_generate_parameters_ex()\fR generates Diffie-Hellman parameters that can be shared among a group of users, and stores them in the provided \fB\s-1DH\s0\fR structure. .PP \&\fBprime_len\fR is the length in bits of the safe prime to be generated. \&\fBgenerator\fR is a small number > 1, typically 2 or 5. .PP A callback function may be used to provide feedback about the progress of the key generation. If \fBcb\fR is not \fB\s-1NULL\s0\fR, it will be called as described in \fIBN_generate_prime\fR\|(3) while a random prime number is generated, and when a prime has been found, \fBBN_GENCB_call(cb, 3, 0)\fR is called. See \fIBN_generate_prime\fR\|(3) for information on the \fIBN_GENCB_call()\fR function. .PP \&\fIDH_check()\fR validates Diffie-Hellman parameters. It checks that \fBp\fR is a safe prime, and that \fBg\fR is a suitable generator. In the case of an error, the bit flags \s-1DH_CHECK_P_NOT_SAFE_PRIME\s0 or \&\s-1DH_NOT_SUITABLE_GENERATOR\s0 are set in \fB*codes\fR. \&\s-1DH_UNABLE_TO_CHECK_GENERATOR\s0 is set if the generator cannot be checked, i.e. it does not equal 2 or 5. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIDH_generate_parameters_ex()\fR and \fIDH_check()\fR return 1 if the check could be performed, 0 otherwise. .PP \&\fIDH_generate_parameters()\fR (deprecated) returns a pointer to the \s-1DH\s0 structure, or \&\s-1NULL\s0 if the parameter generation fails. .PP The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "NOTES" .IX Header "NOTES" \&\fIDH_generate_parameters_ex()\fR and \fIDH_generate_parameters()\fR may run for several hours before finding a suitable prime. .PP The parameters generated by \fIDH_generate_parameters_ex()\fR and \fIDH_generate_parameters()\fR are not to be used in signature schemes. .SH "BUGS" .IX Header "BUGS" If \fBgenerator\fR is not 2 or 5, \fBdh\->g\fR=\fBgenerator\fR is not a usable generator. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdh\fR\|(3), \fIERR_get_error\fR\|(3), \fIrand\fR\|(3), \&\fIDH_free\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIDH_check()\fR is available in all versions of SSLeay and OpenSSL. The \fBcb_arg\fR argument to \fIDH_generate_parameters()\fR was added in SSLeay 0.9.0. .PP In versions before OpenSSL 0.9.5, \s-1DH_CHECK_P_NOT_STRONG_PRIME\s0 is used instead of \s-1DH_CHECK_P_NOT_SAFE_PRIME.\s0 deps/libressl-pnacl-sys-2.1.6/libressl/man/RAND_cleanup.30000644000175000017500000001061712360020723020032 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RAND_cleanup 3" .TH RAND_cleanup 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RAND_cleanup \- erase the PRNG state .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void RAND_cleanup(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIRAND_cleanup()\fR erases the memory used by the \s-1PRNG.\s0 .SH "RETURN VALUE" .IX Header "RETURN VALUE" \&\fIRAND_cleanup()\fR returns no value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIrand\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIRAND_cleanup()\fR is available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_find_type.30000644000175000017500000001623512360020710020247 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_find_type 3" .TH BIO_find_type 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_find_type, BIO_next, BIO_method_type \- BIO chain traversal .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIO * BIO_find_type(BIO *b,int bio_type); \& BIO * BIO_next(BIO *b); \& \& #define BIO_method_type(b) ((b)\->method\->type) \& \& #define BIO_TYPE_NONE 0 \& #define BIO_TYPE_MEM (1|0x0400) \& #define BIO_TYPE_FILE (2|0x0400) \& \& #define BIO_TYPE_FD (4|0x0400|0x0100) \& #define BIO_TYPE_SOCKET (5|0x0400|0x0100) \& #define BIO_TYPE_NULL (6|0x0400) \& #define BIO_TYPE_SSL (7|0x0200) \& #define BIO_TYPE_MD (8|0x0200) \& #define BIO_TYPE_BUFFER (9|0x0200) \& #define BIO_TYPE_CIPHER (10|0x0200) \& #define BIO_TYPE_BASE64 (11|0x0200) \& #define BIO_TYPE_CONNECT (12|0x0400|0x0100) \& #define BIO_TYPE_ACCEPT (13|0x0400|0x0100) \& #define BIO_TYPE_PROXY_CLIENT (14|0x0200) \& #define BIO_TYPE_PROXY_SERVER (15|0x0200) \& #define BIO_TYPE_NBIO_TEST (16|0x0200) \& #define BIO_TYPE_NULL_FILTER (17|0x0200) \& #define BIO_TYPE_BER (18|0x0200) \& #define BIO_TYPE_BIO (19|0x0400) \& \& #define BIO_TYPE_DESCRIPTOR 0x0100 \& #define BIO_TYPE_FILTER 0x0200 \& #define BIO_TYPE_SOURCE_SINK 0x0400 .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fIBIO_find_type()\fR searches for a \s-1BIO\s0 of a given type in a chain, starting at \s-1BIO \s0\fBb\fR. If \fBtype\fR is a specific type (such as \s-1BIO_TYPE_MEM\s0) then a search is made for a \s-1BIO\s0 of that type. If \fBtype\fR is a general type (such as \&\fB\s-1BIO_TYPE_SOURCE_SINK\s0\fR) then the next matching \s-1BIO\s0 of the given general type is searched for. \fIBIO_find_type()\fR returns the next matching \s-1BIO\s0 or \s-1NULL\s0 if none is found. .PP Note: not all the \fBBIO_TYPE_*\fR types above have corresponding \s-1BIO\s0 implementations. .PP \&\fIBIO_next()\fR returns the next \s-1BIO\s0 in a chain. It can be used to traverse all BIOs in a chain or used in conjunction with \fIBIO_find_type()\fR to find all BIOs of a certain type. .PP \&\fIBIO_method_type()\fR returns the type of a \s-1BIO.\s0 .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBIO_find_type()\fR returns a matching \s-1BIO\s0 or \s-1NULL\s0 for no match. .PP \&\fIBIO_next()\fR returns the next \s-1BIO\s0 in a chain. .PP \&\fIBIO_method_type()\fR returns the type of the \s-1BIO \s0\fBb\fR. .SH "NOTES" .IX Header "NOTES" \&\fIBIO_next()\fR was added to OpenSSL 0.9.6 to provide a 'clean' way to traverse a \s-1BIO\s0 chain or find multiple matches using \fIBIO_find_type()\fR. Previous versions had to use: .PP .Vb 1 \& next = bio\->next_bio; .Ve .SH "BUGS" .IX Header "BUGS" \&\fIBIO_find_type()\fR in OpenSSL 0.9.5a and earlier could not be safely passed a \&\s-1NULL\s0 pointer for the \fBb\fR argument. .SH "EXAMPLE" .IX Header "EXAMPLE" Traverse a chain looking for digest BIOs: .PP .Vb 2 \& BIO *btmp; \& btmp = in_bio; /* in_bio is chain to search through */ \& \& do { \& btmp = BIO_find_type(btmp, BIO_TYPE_MD); \& if (btmp == NULL) \& break; /* Not found */ \& /* btmp is a digest BIO, do something with it ...*/ \& ... \& \& btmp = BIO_next(btmp); \& } while(btmp); .Ve deps/libressl-pnacl-sys-2.1.6/libressl/man/smime.10000644000175000017500000005075512360020743016720 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "smime 1" .TH smime 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" smime \- S/MIME utility .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBsmime\fR [\fB\-encrypt\fR] [\fB\-decrypt\fR] [\fB\-sign\fR] [\fB\-resign\fR] [\fB\-verify\fR] [\fB\-pk7out\fR] [\fB\-[cipher]\fR] [\fB\-in file\fR] [\fB\-certfile file\fR] [\fB\-signer file\fR] [\fB\-recip file\fR] [\fB\-inform SMIME|PEM|DER\fR] [\fB\-passin arg\fR] [\fB\-inkey file\fR] [\fB\-out file\fR] [\fB\-outform SMIME|PEM|DER\fR] [\fB\-content file\fR] [\fB\-to addr\fR] [\fB\-from ad\fR] [\fB\-subject s\fR] [\fB\-text\fR] [\fB\-indef\fR] [\fB\-noindef\fR] [\fB\-stream\fR] [\fB\-rand file(s)\fR] [\fB\-md digest\fR] [cert.pem]... .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBsmime\fR command handles S/MIME mail. It can encrypt, decrypt, sign and verify S/MIME messages. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" There are six operation options that set the type of operation to be performed. The meaning of the other options varies according to the operation type. .IP "\fB\-encrypt\fR" 4 .IX Item "-encrypt" encrypt mail for the given recipient certificates. Input file is the message to be encrypted. The output file is the encrypted mail in \s-1MIME\s0 format. .IP "\fB\-decrypt\fR" 4 .IX Item "-decrypt" decrypt mail using the supplied certificate and private key. Expects an encrypted mail message in \s-1MIME\s0 format for the input file. The decrypted mail is written to the output file. .IP "\fB\-sign\fR" 4 .IX Item "-sign" sign mail using the supplied certificate and private key. Input file is the message to be signed. The signed message in \s-1MIME\s0 format is written to the output file. .IP "\fB\-verify\fR" 4 .IX Item "-verify" verify signed mail. Expects a signed mail message on input and outputs the signed data. Both clear text and opaque signing is supported. .IP "\fB\-pk7out\fR" 4 .IX Item "-pk7out" takes an input message and writes out a \s-1PEM\s0 encoded PKCS#7 structure. .IP "\fB\-resign\fR" 4 .IX Item "-resign" resign a message: take an existing message and one or more new signers. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" the input message to be encrypted or signed or the \s-1MIME\s0 message to be decrypted or verified. .IP "\fB\-inform SMIME|PEM|DER\fR" 4 .IX Item "-inform SMIME|PEM|DER" this specifies the input format for the PKCS#7 structure. The default is \fB\s-1SMIME\s0\fR which reads an S/MIME format message. \fB\s-1PEM\s0\fR and \fB\s-1DER\s0\fR format change this to expect \s-1PEM\s0 and \s-1DER\s0 format PKCS#7 structures instead. This currently only affects the input format of the PKCS#7 structure, if no PKCS#7 structure is being input (for example with \&\fB\-encrypt\fR or \fB\-sign\fR) this option has no effect. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" the message text that has been decrypted or verified or the output \s-1MIME\s0 format message that has been signed or verified. .IP "\fB\-outform SMIME|PEM|DER\fR" 4 .IX Item "-outform SMIME|PEM|DER" this specifies the output format for the PKCS#7 structure. The default is \fB\s-1SMIME\s0\fR which write an S/MIME format message. \fB\s-1PEM\s0\fR and \fB\s-1DER\s0\fR format change this to write \s-1PEM\s0 and \s-1DER\s0 format PKCS#7 structures instead. This currently only affects the output format of the PKCS#7 structure, if no PKCS#7 structure is being output (for example with \&\fB\-verify\fR or \fB\-decrypt\fR) this option has no effect. .IP "\fB\-stream \-indef \-noindef\fR" 4 .IX Item "-stream -indef -noindef" the \fB\-stream\fR and \fB\-indef\fR options are equivalent and enable streaming I/O for encoding operations. This permits single pass processing of data without the need to hold the entire contents in memory, potentially supporting very large files. Streaming is automatically set for S/MIME signing with detached data if the output format is \fB\s-1SMIME\s0\fR it is currently off by default for all other operations. .IP "\fB\-noindef\fR" 4 .IX Item "-noindef" disable streaming I/O where it would produce and indefinite length constructed encoding. This option currently has no effect. In future streaming will be enabled by default on all relevant operations and this option will disable it. .IP "\fB\-content filename\fR" 4 .IX Item "-content filename" This specifies a file containing the detached content, this is only useful with the \fB\-verify\fR command. This is only usable if the PKCS#7 structure is using the detached signature form where the content is not included. This option will override any content if the input format is S/MIME and it uses the multipart/signed \s-1MIME\s0 content type. .IP "\fB\-text\fR" 4 .IX Item "-text" this option adds plain text (text/plain) \s-1MIME\s0 headers to the supplied message if encrypting or signing. If decrypting or verifying it strips off text headers: if the decrypted or verified message is not of \s-1MIME\s0 type text/plain then an error occurs. .IP "\fB\-CAfile file\fR" 4 .IX Item "-CAfile file" a file containing trusted \s-1CA\s0 certificates, only used with \fB\-verify\fR. .IP "\fB\-CApath dir\fR" 4 .IX Item "-CApath dir" a directory containing trusted \s-1CA\s0 certificates, only used with \&\fB\-verify\fR. This directory must be a standard certificate directory: that is a hash of each subject name (using \fBx509 \-hash\fR) should be linked to each certificate. .IP "\fB\-md digest\fR" 4 .IX Item "-md digest" digest algorithm to use when signing or resigning. If not present then the default digest algorithm for the signing key will be used (usually \s-1SHA1\s0). .IP "\fB\-[cipher]\fR" 4 .IX Item "-[cipher]" the encryption algorithm to use. For example \s-1DES \s0(56 bits) \- \fB\-des\fR, triple \s-1DES \s0(168 bits) \- \fB\-des3\fR, \&\fIEVP_get_cipherbyname()\fR function) can also be used preceded by a dash, for example \fB\-aes_128_cbc\fR. See \fBenc\fR for list of ciphers supported by your version of OpenSSL. .Sp If not specified 40 bit \s-1RC2\s0 is used. Only used with \fB\-encrypt\fR. .IP "\fB\-nointern\fR" 4 .IX Item "-nointern" when verifying a message normally certificates (if any) included in the message are searched for the signing certificate. With this option only the certificates specified in the \fB\-certfile\fR option are used. The supplied certificates can still be used as untrusted CAs however. .IP "\fB\-noverify\fR" 4 .IX Item "-noverify" do not verify the signers certificate of a signed message. .IP "\fB\-nochain\fR" 4 .IX Item "-nochain" do not do chain verification of signers certificates: that is don't use the certificates in the signed message as untrusted CAs. .IP "\fB\-nosigs\fR" 4 .IX Item "-nosigs" don't try to verify the signatures on the message. .IP "\fB\-nocerts\fR" 4 .IX Item "-nocerts" when signing a message the signer's certificate is normally included with this option it is excluded. This will reduce the size of the signed message but the verifier must have a copy of the signers certificate available locally (passed using the \fB\-certfile\fR option for example). .IP "\fB\-noattr\fR" 4 .IX Item "-noattr" normally when a message is signed a set of attributes are included which include the signing time and supported symmetric algorithms. With this option they are not included. .IP "\fB\-binary\fR" 4 .IX Item "-binary" normally the input message is converted to \*(L"canonical\*(R" format which is effectively using \s-1CR\s0 and \s-1LF\s0 as end of line: as required by the S/MIME specification. When this option is present no translation occurs. This is useful when handling binary data which may not be in \s-1MIME\s0 format. .IP "\fB\-nodetach\fR" 4 .IX Item "-nodetach" when signing a message use opaque signing: this form is more resistant to translation by mail relays but it cannot be read by mail agents that do not support S/MIME. Without this option cleartext signing with the \s-1MIME\s0 type multipart/signed is used. .IP "\fB\-certfile file\fR" 4 .IX Item "-certfile file" allows additional certificates to be specified. When signing these will be included with the message. When verifying these will be searched for the signers certificates. The certificates should be in \s-1PEM\s0 format. .IP "\fB\-signer file\fR" 4 .IX Item "-signer file" a signing certificate when signing or resigning a message, this option can be used multiple times if more than one signer is required. If a message is being verified then the signers certificates will be written to this file if the verification was successful. .IP "\fB\-recip file\fR" 4 .IX Item "-recip file" the recipients certificate when decrypting a message. This certificate must match one of the recipients of the message or an error occurs. .IP "\fB\-inkey file\fR" 4 .IX Item "-inkey file" the private key to use when signing or decrypting. This must match the corresponding certificate. If this option is not specified then the private key must be included in the certificate file specified with the \fB\-recip\fR or \fB\-signer\fR file. When signing this option can be used multiple times to specify successive keys. .IP "\fB\-passin arg\fR" 4 .IX Item "-passin arg" the private key password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-rand file(s)\fR" 4 .IX Item "-rand file(s)" a file or files containing random data used to seed the random number generator, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)). Multiple files can be specified separated by a OS-dependent character. The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for all others. .IP "\fBcert.pem...\fR" 4 .IX Item "cert.pem..." one or more certificates of message recipients: used when encrypting a message. .IP "\fB\-to, \-from, \-subject\fR" 4 .IX Item "-to, -from, -subject" the relevant mail headers. These are included outside the signed portion of a message so they may be included manually. If signing then many S/MIME mail clients check the signers certificate's email address matches that specified in the From: address. .IP "\fB\-purpose, \-ignore_critical, \-issuer_checks, \-crl_check, \-crl_check_all, \-policy_check, \-extended_crl, \-x509_strict, \-policy \-check_ss_sig\fR" 4 .IX Item "-purpose, -ignore_critical, -issuer_checks, -crl_check, -crl_check_all, -policy_check, -extended_crl, -x509_strict, -policy -check_ss_sig" Set various options of certificate chain verification. See \&\fBverify\fR manual page for details. .SH "NOTES" .IX Header "NOTES" The \s-1MIME\s0 message must be sent without any blank lines between the headers and the output. Some mail programs will automatically add a blank line. Piping the mail directly to sendmail is one way to achieve the correct format. .PP The supplied message to be signed or encrypted must include the necessary \s-1MIME\s0 headers or many S/MIME clients wont display it properly (if at all). You can use the \fB\-text\fR option to automatically add plain text headers. .PP A \*(L"signed and encrypted\*(R" message is one where a signed message is then encrypted. This can be produced by encrypting an already signed message: see the examples section. .PP This version of the program only allows one signer per message but it will verify multiple signers on received messages. Some S/MIME clients choke if a message contains multiple signers. It is possible to sign messages \*(L"in parallel\*(R" by signing an already signed message. .PP The options \fB\-encrypt\fR and \fB\-decrypt\fR reflect common usage in S/MIME clients. Strictly speaking these process PKCS#7 enveloped data: PKCS#7 encrypted data is used for other purposes. .PP The \fB\-resign\fR option uses an existing message digest when adding a new signer. This means that attributes must be present in at least one existing signer using the same message digest or this operation will fail. .PP The \fB\-stream\fR and \fB\-indef\fR options enable experimental streaming I/O support. As a result the encoding is \s-1BER\s0 using indefinite length constructed encoding and no longer \s-1DER.\s0 Streaming is supported for the \fB\-encrypt\fR operation and the \&\fB\-sign\fR operation if the content is not detached. .PP Streaming is always used for the \fB\-sign\fR operation with detached data but since the content is no longer part of the PKCS#7 structure the encoding remains \s-1DER.\s0 .SH "EXIT CODES" .IX Header "EXIT CODES" .ie n .IP """0""" 4 .el .IP "``0''" 4 .IX Item "0" the operation was completely successfully. .ie n .IP """1""" 4 .el .IP "``1''" 4 .IX Item "1" an error occurred parsing the command options. .ie n .IP """2""" 4 .el .IP "``2''" 4 .IX Item "2" one of the input files could not be read. .ie n .IP """3""" 4 .el .IP "``3''" 4 .IX Item "3" an error occurred creating the PKCS#7 file or when reading the \s-1MIME\s0 message. .ie n .IP """4""" 4 .el .IP "``4''" 4 .IX Item "4" an error occurred decrypting or verifying the message. .ie n .IP """5""" 4 .el .IP "``5''" 4 .IX Item "5" the message was verified correctly but an error occurred writing out the signers certificates. .SH "EXAMPLES" .IX Header "EXAMPLES" Create a cleartext signed message: .PP .Vb 2 \& openssl smime \-sign \-in message.txt \-text \-out mail.msg \e \& \-signer mycert.pem .Ve .PP Create an opaque signed message: .PP .Vb 2 \& openssl smime \-sign \-in message.txt \-text \-out mail.msg \-nodetach \e \& \-signer mycert.pem .Ve .PP Create a signed message, include some additional certificates and read the private key from another file: .PP .Vb 2 \& openssl smime \-sign \-in in.txt \-text \-out mail.msg \e \& \-signer mycert.pem \-inkey mykey.pem \-certfile mycerts.pem .Ve .PP Create a signed message with two signers: .PP .Vb 2 \& openssl smime \-sign \-in message.txt \-text \-out mail.msg \e \& \-signer mycert.pem \-signer othercert.pem .Ve .PP Send a signed message under Unix directly to sendmail, including headers: .PP .Vb 3 \& openssl smime \-sign \-in in.txt \-text \-signer mycert.pem \e \& \-from steve@openssl.org \-to someone@somewhere \e \& \-subject "Signed message" | sendmail someone@somewhere .Ve .PP Verify a message and extract the signer's certificate if successful: .PP .Vb 1 \& openssl smime \-verify \-in mail.msg \-signer user.pem \-out signedtext.txt .Ve .PP Send encrypted mail using triple \s-1DES:\s0 .PP .Vb 3 \& openssl smime \-encrypt \-in in.txt \-from steve@openssl.org \e \& \-to someone@somewhere \-subject "Encrypted message" \e \& \-des3 user.pem \-out mail.msg .Ve .PP Sign and encrypt mail: .PP .Vb 4 \& openssl smime \-sign \-in ml.txt \-signer my.pem \-text \e \& | openssl smime \-encrypt \-out mail.msg \e \& \-from steve@openssl.org \-to someone@somewhere \e \& \-subject "Signed and Encrypted message" \-des3 user.pem .Ve .PP Note: the encryption command does not include the \fB\-text\fR option because the message being encrypted already has \s-1MIME\s0 headers. .PP Decrypt mail: .PP .Vb 1 \& openssl smime \-decrypt \-in mail.msg \-recip mycert.pem \-inkey key.pem .Ve .PP The output from Netscape form signing is a PKCS#7 structure with the detached signature format. You can use this program to verify the signature by line wrapping the base64 encoded structure and surrounding it with: .PP .Vb 2 \& \-\-\-\-\-BEGIN PKCS7\-\-\-\-\- \& \-\-\-\-\-END PKCS7\-\-\-\-\- .Ve .PP and using the command: .PP .Vb 1 \& openssl smime \-verify \-inform PEM \-in signature.pem \-content content.txt .Ve .PP Alternatively you can base64 decode the signature and use: .PP .Vb 1 \& openssl smime \-verify \-inform DER \-in signature.der \-content content.txt .Ve .PP Create an encrypted message using 128 bit Camellia: .PP .Vb 1 \& openssl smime \-encrypt \-in plain.txt \-camellia128 \-out mail.msg cert.pem .Ve .PP Add a signer to an existing message: .PP .Vb 1 \& openssl smime \-resign \-in mail.msg \-signer newsign.pem \-out mail2.msg .Ve .SH "BUGS" .IX Header "BUGS" The \s-1MIME\s0 parser isn't very clever: it seems to handle most messages that I've thrown at it but it may choke on others. .PP The code currently will only write out the signer's certificate to a file: if the signer has a separate encryption certificate this must be manually extracted. There should be some heuristic that determines the correct encryption certificate. .PP Ideally a database should be maintained of a certificates for each email address. .PP The code doesn't currently take note of the permitted symmetric encryption algorithms as supplied in the SMIMECapabilities signed attribute. This means the user has to manually include the correct encryption algorithm. It should store the list of permitted ciphers in a database and only use those. .PP No revocation checking is done on the signer's certificate. .PP The current code can only handle S/MIME v2 messages, the more complex S/MIME v3 structures may cause parsing errors. .SH "HISTORY" .IX Header "HISTORY" The use of multiple \fB\-signer\fR options and the \fB\-resign\fR command were first added in OpenSSL 1.0.0 deps/libressl-pnacl-sys-2.1.6/libressl/man/OBJ_nid2obj.30000644000175000017500000002252312360020721017615 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "OBJ_nid2obj 3" .TH OBJ_nid2obj 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" OBJ_nid2obj, OBJ_nid2ln, OBJ_nid2sn, OBJ_obj2nid, OBJ_txt2nid, OBJ_ln2nid, OBJ_sn2nid, OBJ_cmp, OBJ_dup, OBJ_txt2obj, OBJ_obj2txt, OBJ_create, OBJ_cleanup \&\- ASN1 object utility functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& ASN1_OBJECT * OBJ_nid2obj(int n); \& const char * OBJ_nid2ln(int n); \& const char * OBJ_nid2sn(int n); \& \& int OBJ_obj2nid(const ASN1_OBJECT *o); \& int OBJ_ln2nid(const char *ln); \& int OBJ_sn2nid(const char *sn); \& \& int OBJ_txt2nid(const char *s); \& \& ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name); \& int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name); \& \& int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b); \& ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o); \& \& int OBJ_create(const char *oid,const char *sn,const char *ln); \& void OBJ_cleanup(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \s-1ASN1\s0 object utility functions process \s-1ASN1_OBJECT\s0 structures which are a representation of the \s-1ASN1 OBJECT IDENTIFIER \s0(\s-1OID\s0) type. .PP \&\fIOBJ_nid2obj()\fR, \fIOBJ_nid2ln()\fR and \fIOBJ_nid2sn()\fR convert the \s-1NID \s0\fBn\fR to an \s-1ASN1_OBJECT\s0 structure, its long name and its short name respectively, or \fB\s-1NULL\s0\fR is an error occurred. .PP \&\fIOBJ_obj2nid()\fR, \fIOBJ_ln2nid()\fR, \fIOBJ_sn2nid()\fR return the corresponding \s-1NID\s0 for the object \fBo\fR, the long name or the short name respectively or NID_undef if an error occurred. .PP \&\fIOBJ_txt2nid()\fR returns \s-1NID\s0 corresponding to text string . \fBs\fR can be a long name, a short name or the numerical respresentation of an object. .PP \&\fIOBJ_txt2obj()\fR converts the text string \fBs\fR into an \s-1ASN1_OBJECT\s0 structure. If \fBno_name\fR is 0 then long names and short names will be interpreted as well as numerical forms. If \fBno_name\fR is 1 only the numerical form is acceptable. .PP \&\fIOBJ_obj2txt()\fR converts the \fB\s-1ASN1_OBJECT\s0\fR \fBa\fR into a textual representation. The representation is written as a null terminated string to \fBbuf\fR at most \fBbuf_len\fR bytes are written, truncating the result if necessary. The total amount of space required is returned. If \fBno_name\fR is 0 then if the object has a long or short name then that will be used, otherwise the numerical form will be used. If \fBno_name\fR is 1 then the numerical form will always be used. .PP \&\fIOBJ_cmp()\fR compares \fBa\fR to \fBb\fR. If the two are identical 0 is returned. .PP \&\fIOBJ_dup()\fR returns a copy of \fBo\fR. .PP \&\fIOBJ_create()\fR adds a new object to the internal table. \fBoid\fR is the numerical form of the object, \fBsn\fR the short name and \fBln\fR the long name. A new \s-1NID\s0 is returned for the created object. .PP \&\fIOBJ_cleanup()\fR cleans up OpenSSLs internal object table: this should be called before an application exits if any new objects were added using \fIOBJ_create()\fR. .SH "NOTES" .IX Header "NOTES" Objects in OpenSSL can have a short name, a long name and a numerical identifier (\s-1NID\s0) associated with them. A standard set of objects is represented in an internal table. The appropriate values are defined in the header file \fBobjects.h\fR. .PP For example the \s-1OID\s0 for commonName has the following definitions: .PP .Vb 3 \& #define SN_commonName "CN" \& #define LN_commonName "commonName" \& #define NID_commonName 13 .Ve .PP New objects can be added by calling \fIOBJ_create()\fR. .PP Table objects have certain advantages over other objects: for example their NIDs can be used in a C language switch statement. They are also static constant structures which are shared: that is there is only a single constant structure for each table object. .PP Objects which are not in the table have the \s-1NID\s0 value NID_undef. .PP Objects do not need to be in the internal tables to be processed, the functions \fIOBJ_txt2obj()\fR and \fIOBJ_obj2txt()\fR can process the numerical form of an \s-1OID.\s0 .SH "EXAMPLES" .IX Header "EXAMPLES" Create an object for \fBcommonName\fR: .PP .Vb 2 \& ASN1_OBJECT *o; \& o = OBJ_nid2obj(NID_commonName); .Ve .PP Check if an object is \fBcommonName\fR .PP .Vb 2 \& if (OBJ_obj2nid(obj) == NID_commonName) \& /* Do something */ .Ve .PP Create a new \s-1NID\s0 and initialize an object from it: .PP .Vb 3 \& int new_nid; \& ASN1_OBJECT *obj; \& new_nid = OBJ_create("1.2.3.4", "NewOID", "New Object Identifier"); \& \& obj = OBJ_nid2obj(new_nid); .Ve .PP Create a new object directly: .PP .Vb 1 \& obj = OBJ_txt2obj("1.2.3.4", 1); .Ve .SH "BUGS" .IX Header "BUGS" \&\fIOBJ_obj2txt()\fR is awkward and messy to use: it doesn't follow the convention of other OpenSSL functions where the buffer can be set to \fB\s-1NULL\s0\fR to determine the amount of data that should be written. Instead \fBbuf\fR must point to a valid buffer and \fBbuf_len\fR should be set to a positive value. A buffer length of 80 should be more than enough to handle any \s-1OID\s0 encountered in practice. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIOBJ_nid2obj()\fR returns an \fB\s-1ASN1_OBJECT\s0\fR structure or \fB\s-1NULL\s0\fR is an error occurred. .PP \&\fIOBJ_nid2ln()\fR and \fIOBJ_nid2sn()\fR returns a valid string or \fB\s-1NULL\s0\fR on error. .PP \&\fIOBJ_obj2nid()\fR, \fIOBJ_ln2nid()\fR, \fIOBJ_sn2nid()\fR and \fIOBJ_txt2nid()\fR return a \s-1NID\s0 or \fBNID_undef\fR on error. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_set_callback.30000644000175000017500000001755012360020711020677 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_set_callback 3" .TH BIO_set_callback 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_set_callback, BIO_get_callback, BIO_set_callback_arg, BIO_get_callback_arg, BIO_debug_callback \- BIO callback functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& #define BIO_set_callback(b,cb) ((b)\->callback=(cb)) \& #define BIO_get_callback(b) ((b)\->callback) \& #define BIO_set_callback_arg(b,arg) ((b)\->cb_arg=(char *)(arg)) \& #define BIO_get_callback_arg(b) ((b)\->cb_arg) \& \& long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, \& long argl,long ret); \& \& typedef long (*callback)(BIO *b, int oper, const char *argp, \& int argi, long argl, long retvalue); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_set_callback()\fR and \fIBIO_get_callback()\fR set and retrieve the \s-1BIO\s0 callback, they are both macros. The callback is called during most high level \s-1BIO\s0 operations. It can be used for debugging purposes to trace operations on a \s-1BIO\s0 or to modify its operation. .PP \&\fIBIO_set_callback_arg()\fR and \fIBIO_get_callback_arg()\fR are macros which can be used to set and retrieve an argument for use in the callback. .PP \&\fIBIO_debug_callback()\fR is a standard debugging callback which prints out information relating to each \s-1BIO\s0 operation. If the callback argument is set if is interpreted as a \s-1BIO\s0 to send the information to, otherwise stderr is used. .PP \&\fIcallback()\fR is the callback function itself. The meaning of each argument is described below. .PP The \s-1BIO\s0 the callback is attached to is passed in \fBb\fR. .PP \&\fBoper\fR is set to the operation being performed. For some operations the callback is called twice, once before and once after the actual operation, the latter case has \fBoper\fR or'ed with \s-1BIO_CB_RETURN.\s0 .PP The meaning of the arguments \fBargp\fR, \fBargi\fR and \fBargl\fR depends on the value of \fBoper\fR, that is the operation being performed. .PP \&\fBretvalue\fR is the return value that would be returned to the application if no callback were present. The actual value returned is the return value of the callback itself. In the case of callbacks called before the actual \s-1BIO\s0 operation 1 is placed in retvalue, if the return value is not positive it will be immediately returned to the application and the \s-1BIO\s0 operation will not be performed. .PP The callback should normally simply return \fBretvalue\fR when it has finished processing, unless if specifically wishes to modify the value returned to the application. .SH "CALLBACK OPERATIONS" .IX Header "CALLBACK OPERATIONS" .IP "\fBBIO_free(b)\fR" 4 .IX Item "BIO_free(b)" callback(b, \s-1BIO_CB_FREE, NULL, 0L, 0L, 1L\s0) is called before the free operation. .IP "\fBBIO_read(b, out, outl)\fR" 4 .IX Item "BIO_read(b, out, outl)" callback(b, \s-1BIO_CB_READ,\s0 out, outl, 0L, 1L) is called before the read and callback(b, BIO_CB_READ|BIO_CB_RETURN, out, outl, 0L, retvalue) after. .IP "\fBBIO_write(b, in, inl)\fR" 4 .IX Item "BIO_write(b, in, inl)" callback(b, \s-1BIO_CB_WRITE,\s0 in, inl, 0L, 1L) is called before the write and callback(b, BIO_CB_WRITE|BIO_CB_RETURN, in, inl, 0L, retvalue) after. .IP "\fBBIO_gets(b, out, outl)\fR" 4 .IX Item "BIO_gets(b, out, outl)" callback(b, \s-1BIO_CB_GETS,\s0 out, outl, 0L, 1L) is called before the operation and callback(b, BIO_CB_GETS|BIO_CB_RETURN, out, outl, 0L, retvalue) after. .IP "\fBBIO_puts(b, in)\fR" 4 .IX Item "BIO_puts(b, in)" callback(b, \s-1BIO_CB_WRITE,\s0 in, 0, 0L, 1L) is called before the operation and callback(b, BIO_CB_WRITE|BIO_CB_RETURN, in, 0, 0L, retvalue) after. .IP "\fBBIO_ctrl(\s-1BIO\s0 *b, int cmd, long larg, void *parg)\fR" 4 .IX Item "BIO_ctrl(BIO *b, int cmd, long larg, void *parg)" callback(b,BIO_CB_CTRL,parg,cmd,larg,1L) is called before the call and callback(b,BIO_CB_CTRL|BIO_CB_RETURN,parg,cmd, larg,ret) after. .SH "EXAMPLE" .IX Header "EXAMPLE" The \fIBIO_debug_callback()\fR function is a good example, its source is in crypto/bio/bio_cb.c deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_SESSION_get_time.30000644000175000017500000001411312360020734021315 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_SESSION_get_time 3" .TH SSL_SESSION_get_time 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_SESSION_get_time, SSL_SESSION_set_time, SSL_SESSION_get_timeout, SSL_SESSION_set_timeout \- retrieve and manipulate session time and timeout settings .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& long SSL_SESSION_get_time(const SSL_SESSION *s); \& long SSL_SESSION_set_time(SSL_SESSION *s, long tm); \& long SSL_SESSION_get_timeout(const SSL_SESSION *s); \& long SSL_SESSION_set_timeout(SSL_SESSION *s, long tm); \& \& long SSL_get_time(const SSL_SESSION *s); \& long SSL_set_time(SSL_SESSION *s, long tm); \& long SSL_get_timeout(const SSL_SESSION *s); \& long SSL_set_timeout(SSL_SESSION *s, long tm); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_SESSION_get_time()\fR returns the time at which the session \fBs\fR was established. The time is given in seconds since the Epoch and therefore compatible to the time delivered by the \fItime()\fR call. .PP \&\fISSL_SESSION_set_time()\fR replaces the creation time of the session \fBs\fR with the chosen value \fBtm\fR. .PP \&\fISSL_SESSION_get_timeout()\fR returns the timeout value set for session \fBs\fR in seconds. .PP \&\fISSL_SESSION_set_timeout()\fR sets the timeout value for session \fBs\fR in seconds to \fBtm\fR. .PP The \fISSL_get_time()\fR, \fISSL_set_time()\fR, \fISSL_get_timeout()\fR, and \fISSL_set_timeout()\fR functions are synonyms for the SSL_SESSION_*() counterparts. .SH "NOTES" .IX Header "NOTES" Sessions are expired by examining the creation time and the timeout value. Both are set at creation time of the session to the actual time and the default timeout value at creation, respectively, as set by \&\fISSL_CTX_set_timeout\fR\|(3). Using these functions it is possible to extend or shorten the lifetime of the session. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_SESSION_get_time()\fR and \fISSL_SESSION_get_timeout()\fR return the currently valid values. .PP \&\fISSL_SESSION_set_time()\fR and \fISSL_SESSION_set_timeout()\fR return 1 on success. .PP If any of the function is passed the \s-1NULL\s0 pointer for the session \fBs\fR, 0 is returned. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \&\fISSL_CTX_set_timeout\fR\|(3), \&\fISSL_get_default_timeout\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/engine.30000644000175000017500000010544012360020730017041 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "engine 3" .TH engine 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" engine \- ENGINE cryptographic module support .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& ENGINE *ENGINE_get_first(void); \& ENGINE *ENGINE_get_last(void); \& ENGINE *ENGINE_get_next(ENGINE *e); \& ENGINE *ENGINE_get_prev(ENGINE *e); \& \& int ENGINE_add(ENGINE *e); \& int ENGINE_remove(ENGINE *e); \& \& ENGINE *ENGINE_by_id(const char *id); \& \& int ENGINE_init(ENGINE *e); \& int ENGINE_finish(ENGINE *e); \& \& void ENGINE_load_openssl(void); \& void ENGINE_load_dynamic(void); \& void ENGINE_load_cryptodev(void); \& void ENGINE_load_builtin_engines(void); \& \& void ENGINE_cleanup(void); \& \& ENGINE *ENGINE_get_default_RSA(void); \& ENGINE *ENGINE_get_default_DSA(void); \& ENGINE *ENGINE_get_default_ECDH(void); \& ENGINE *ENGINE_get_default_ECDSA(void); \& ENGINE *ENGINE_get_default_DH(void); \& ENGINE *ENGINE_get_default_RAND(void); \& ENGINE *ENGINE_get_cipher_engine(int nid); \& ENGINE *ENGINE_get_digest_engine(int nid); \& \& int ENGINE_set_default_RSA(ENGINE *e); \& int ENGINE_set_default_DSA(ENGINE *e); \& int ENGINE_set_default_ECDH(ENGINE *e); \& int ENGINE_set_default_ECDSA(ENGINE *e); \& int ENGINE_set_default_DH(ENGINE *e); \& int ENGINE_set_default_RAND(ENGINE *e); \& int ENGINE_set_default_ciphers(ENGINE *e); \& int ENGINE_set_default_digests(ENGINE *e); \& int ENGINE_set_default_string(ENGINE *e, const char *list); \& \& int ENGINE_set_default(ENGINE *e, unsigned int flags); \& \& unsigned int ENGINE_get_table_flags(void); \& void ENGINE_set_table_flags(unsigned int flags); \& \& int ENGINE_register_RSA(ENGINE *e); \& void ENGINE_unregister_RSA(ENGINE *e); \& void ENGINE_register_all_RSA(void); \& int ENGINE_register_DSA(ENGINE *e); \& void ENGINE_unregister_DSA(ENGINE *e); \& void ENGINE_register_all_DSA(void); \& int ENGINE_register_ECDH(ENGINE *e); \& void ENGINE_unregister_ECDH(ENGINE *e); \& void ENGINE_register_all_ECDH(void); \& int ENGINE_register_ECDSA(ENGINE *e); \& void ENGINE_unregister_ECDSA(ENGINE *e); \& void ENGINE_register_all_ECDSA(void); \& int ENGINE_register_DH(ENGINE *e); \& void ENGINE_unregister_DH(ENGINE *e); \& void ENGINE_register_all_DH(void); \& int ENGINE_register_RAND(ENGINE *e); \& void ENGINE_unregister_RAND(ENGINE *e); \& void ENGINE_register_all_RAND(void); \& int ENGINE_register_STORE(ENGINE *e); \& void ENGINE_unregister_STORE(ENGINE *e); \& void ENGINE_register_all_STORE(void); \& int ENGINE_register_ciphers(ENGINE *e); \& void ENGINE_unregister_ciphers(ENGINE *e); \& void ENGINE_register_all_ciphers(void); \& int ENGINE_register_digests(ENGINE *e); \& void ENGINE_unregister_digests(ENGINE *e); \& void ENGINE_register_all_digests(void); \& int ENGINE_register_complete(ENGINE *e); \& int ENGINE_register_all_complete(void); \& \& int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)); \& int ENGINE_cmd_is_executable(ENGINE *e, int cmd); \& int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, \& long i, void *p, void (*f)(void), int cmd_optional); \& int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, \& int cmd_optional); \& \& int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); \& void *ENGINE_get_ex_data(const ENGINE *e, int idx); \& \& int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, \& CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); \& \& ENGINE *ENGINE_new(void); \& int ENGINE_free(ENGINE *e); \& int ENGINE_up_ref(ENGINE *e); \& \& int ENGINE_set_id(ENGINE *e, const char *id); \& int ENGINE_set_name(ENGINE *e, const char *name); \& int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); \& int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); \& int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *dh_meth); \& int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *dh_meth); \& int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); \& int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); \& int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *rand_meth); \& int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f); \& int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f); \& int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f); \& int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f); \& int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f); \& int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f); \& int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f); \& int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f); \& int ENGINE_set_flags(ENGINE *e, int flags); \& int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns); \& \& const char *ENGINE_get_id(const ENGINE *e); \& const char *ENGINE_get_name(const ENGINE *e); \& const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); \& const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); \& const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e); \& const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e); \& const DH_METHOD *ENGINE_get_DH(const ENGINE *e); \& const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); \& const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e); \& ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e); \& ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e); \& ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e); \& ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e); \& ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e); \& ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e); \& ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e); \& ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e); \& const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid); \& const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid); \& int ENGINE_get_flags(const ENGINE *e); \& const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); \& \& EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, \& UI_METHOD *ui_method, void *callback_data); \& EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, \& UI_METHOD *ui_method, void *callback_data); \& \& void ENGINE_add_conf_module(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions create, manipulate, and use cryptographic modules in the form of \fB\s-1ENGINE\s0\fR objects. These objects act as containers for implementations of cryptographic algorithms, and support a reference-counted mechanism to allow them to be dynamically loaded in and out of the running application. .PP The cryptographic functionality that can be provided by an \fB\s-1ENGINE\s0\fR implementation includes the following abstractions; .PP .Vb 6 \& RSA_METHOD \- for providing alternative RSA implementations \& DSA_METHOD, DH_METHOD, RAND_METHOD, ECDH_METHOD, ECDSA_METHOD, \& STORE_METHOD \- similarly for other OpenSSL APIs \& EVP_CIPHER \- potentially multiple cipher algorithms (indexed by \*(Aqnid\*(Aq) \& EVP_DIGEST \- potentially multiple hash algorithms (indexed by \*(Aqnid\*(Aq) \& key\-loading \- loading public and/or private EVP_PKEY keys .Ve .SS "Reference counting and handles" .IX Subsection "Reference counting and handles" Due to the modular nature of the \s-1ENGINE API,\s0 pointers to ENGINEs need to be treated as handles \- ie. not only as pointers, but also as references to the underlying \s-1ENGINE\s0 object. Ie. one should obtain a new reference when making copies of an \s-1ENGINE\s0 pointer if the copies will be used (and released) independently. .PP \&\s-1ENGINE\s0 objects have two levels of reference-counting to match the way in which the objects are used. At the most basic level, each \s-1ENGINE\s0 pointer is inherently a \fBstructural\fR reference \- a structural reference is required to use the pointer value at all, as this kind of reference is a guarantee that the structure can not be deallocated until the reference is released. .PP However, a structural reference provides no guarantee that the \s-1ENGINE\s0 is initiliased and able to use any of its cryptographic implementations. Indeed it's quite possible that most ENGINEs will not initialise at all in typical environments, as ENGINEs are typically used to support specialised hardware. To use an \s-1ENGINE\s0's functionality, you need a \&\fBfunctional\fR reference. This kind of reference can be considered a specialised form of structural reference, because each functional reference implicitly contains a structural reference as well \- however to avoid difficult-to-find programming bugs, it is recommended to treat the two kinds of reference independently. If you have a functional reference to an \&\s-1ENGINE,\s0 you have a guarantee that the \s-1ENGINE\s0 has been initialised ready to perform cryptographic operations and will remain uninitialised until after you have released your reference. .PP \&\fIStructural references\fR .PP This basic type of reference is used for instantiating new ENGINEs, iterating across OpenSSL's internal linked-list of loaded ENGINEs, reading information about an \s-1ENGINE,\s0 etc. Essentially a structural reference is sufficient if you only need to query or manipulate the data of an \s-1ENGINE\s0 implementation rather than use its functionality. .PP The \fIENGINE_new()\fR function returns a structural reference to a new (empty) \&\s-1ENGINE\s0 object. There are other \s-1ENGINE API\s0 functions that return structural references such as; \fIENGINE_by_id()\fR, \fIENGINE_get_first()\fR, \fIENGINE_get_last()\fR, \&\fIENGINE_get_next()\fR, \fIENGINE_get_prev()\fR. All structural references should be released by a corresponding to call to the \fIENGINE_free()\fR function \- the \&\s-1ENGINE\s0 object itself will only actually be cleaned up and deallocated when the last structural reference is released. .PP It should also be noted that many \s-1ENGINE API\s0 function calls that accept a structural reference will internally obtain another reference \- typically this happens whenever the supplied \s-1ENGINE\s0 will be needed by OpenSSL after the function has returned. Eg. the function to add a new \s-1ENGINE\s0 to OpenSSL's internal list is \fIENGINE_add()\fR \- if this function returns success, then OpenSSL will have stored a new structural reference internally so the caller is still responsible for freeing their own reference with \&\fIENGINE_free()\fR when they are finished with it. In a similar way, some functions will automatically release the structural reference passed to it if part of the function's job is to do so. Eg. the \fIENGINE_get_next()\fR and \&\fIENGINE_get_prev()\fR functions are used for iterating across the internal \&\s-1ENGINE\s0 list \- they will return a new structural reference to the next (or previous) \s-1ENGINE\s0 in the list or \s-1NULL\s0 if at the end (or beginning) of the list, but in either case the structural reference passed to the function is released on behalf of the caller. .PP To clarify a particular function's handling of references, one should always consult that function's documentation \*(L"man\*(R" page, or failing that the openssl/engine.h header file includes some hints. .PP \&\fIFunctional references\fR .PP As mentioned, functional references exist when the cryptographic functionality of an \s-1ENGINE\s0 is required to be available. A functional reference can be obtained in one of two ways; from an existing structural reference to the required \s-1ENGINE,\s0 or by asking OpenSSL for the default operational \s-1ENGINE\s0 for a given cryptographic purpose. .PP To obtain a functional reference from an existing structural reference, call the \fIENGINE_init()\fR function. This returns zero if the \s-1ENGINE\s0 was not already operational and couldn't be successfully initialised (eg. lack of system drivers, no special hardware attached, etc), otherwise it will return non-zero to indicate that the \s-1ENGINE\s0 is now operational and will have allocated a new \fBfunctional\fR reference to the \s-1ENGINE.\s0 All functional references are released by calling \fIENGINE_finish()\fR (which removes the implicit structural reference as well). .PP The second way to get a functional reference is by asking OpenSSL for a default implementation for a given task, eg. by \fIENGINE_get_default_RSA()\fR, \&\fIENGINE_get_default_cipher_engine()\fR, etc. These are discussed in the next section, though they are not usually required by application programmers as they are used automatically when creating and using the relevant algorithm-specific types in OpenSSL, such as \s-1RSA, DSA, EVP_CIPHER_CTX,\s0 etc. .SS "Default implementations" .IX Subsection "Default implementations" For each supported abstraction, the \s-1ENGINE\s0 code maintains an internal table of state to control which implementations are available for a given abstraction and which should be used by default. These implementations are registered in the tables and indexed by an 'nid' value, because abstractions like \s-1EVP_CIPHER\s0 and \s-1EVP_DIGEST\s0 support many distinct algorithms and modes, and ENGINEs can support arbitrarily many of them. In the case of other abstractions like \s-1RSA, DSA,\s0 etc, there is only one \&\*(L"algorithm\*(R" so all implementations implicitly register using the same 'nid' index. .PP When a default \s-1ENGINE\s0 is requested for a given abstraction/algorithm/mode, (eg. when calling RSA_new_method(\s-1NULL\s0)), a \*(L"get_default\*(R" call will be made to the \&\s-1ENGINE\s0 subsystem to process the corresponding state table and return a functional reference to an initialised \s-1ENGINE\s0 whose implementation should be used. If no \s-1ENGINE\s0 should (or can) be used, it will return \s-1NULL\s0 and the caller will operate with a \s-1NULL ENGINE\s0 handle \- this usually equates to using the conventional software implementation. In the latter case, OpenSSL will from then on behave the way it used to before the \s-1ENGINE API\s0 existed. .PP Each state table has a flag to note whether it has processed this \&\*(L"get_default\*(R" query since the table was last modified, because to process this question it must iterate across all the registered ENGINEs in the table trying to initialise each of them in turn, in case one of them is operational. If it returns a functional reference to an \s-1ENGINE,\s0 it will also cache another reference to speed up processing future queries (without needing to iterate across the table). Likewise, it will cache a \s-1NULL\s0 response if no \s-1ENGINE\s0 was available so that future queries won't repeat the same iteration unless the state table changes. This behaviour can also be changed; if the \s-1ENGINE_TABLE_FLAG_NOINIT\s0 flag is set (using \&\fIENGINE_set_table_flags()\fR), no attempted initialisations will take place, instead the only way for the state table to return a non-NULL \s-1ENGINE\s0 to the \&\*(L"get_default\*(R" query will be if one is expressly set in the table. Eg. \&\fIENGINE_set_default_RSA()\fR does the same job as \fIENGINE_register_RSA()\fR except that it also sets the state table's cached response for the \*(L"get_default\*(R" query. In the case of abstractions like \s-1EVP_CIPHER,\s0 where implementations are indexed by 'nid', these flags and cached-responses are distinct for each 'nid' value. .SS "Application requirements" .IX Subsection "Application requirements" This section will explain the basic things an application programmer should support to make the most useful elements of the \s-1ENGINE\s0 functionality available to the user. The first thing to consider is whether the programmer wishes to make alternative \s-1ENGINE\s0 modules available to the application and user. OpenSSL maintains an internal linked list of \&\*(L"visible\*(R" ENGINEs from which it has to operate \- at start-up, this list is empty and in fact if an application does not call any \s-1ENGINE API\s0 calls and it uses static linking against openssl, then the resulting application binary will not contain any alternative \s-1ENGINE\s0 code at all. So the first consideration is whether any/all available \s-1ENGINE\s0 implementations should be made visible to OpenSSL \- this is controlled by calling the various \*(L"load\*(R" functions, eg. .PP .Vb 5 \& /* Make the "dynamic" ENGINE available */ \& void ENGINE_load_dynamic(void); \& ... \& /* Make ALL ENGINE implementations bundled with OpenSSL available */ \& void ENGINE_load_builtin_engines(void); .Ve .PP Having called any of these functions, \s-1ENGINE\s0 objects would have been dynamically allocated and populated with these implementations and linked into OpenSSL's internal linked list. At this point it is important to mention an important \s-1API\s0 function; .PP .Vb 1 \& void ENGINE_cleanup(void); .Ve .PP If no \s-1ENGINE API\s0 functions are called at all in an application, then there are no inherent memory leaks to worry about from the \s-1ENGINE\s0 functionality, however if any ENGINEs are loaded, even if they are never registered or used, it is necessary to use the \fIENGINE_cleanup()\fR function to correspondingly cleanup before program exit, if the caller wishes to avoid memory leaks. This mechanism uses an internal callback registration table so that any \s-1ENGINE API\s0 functionality that knows it requires cleanup can register its cleanup details to be called during \fIENGINE_cleanup()\fR. This approach allows \fIENGINE_cleanup()\fR to clean up after any \s-1ENGINE\s0 functionality at all that your program uses, yet doesn't automatically create linker dependencies to all possible \s-1ENGINE\s0 functionality \- only the cleanup callbacks required by the functionality you do use will be required by the linker. .PP The fact that ENGINEs are made visible to OpenSSL (and thus are linked into the program and loaded into memory at run-time) does not mean they are \&\*(L"registered\*(R" or called into use by OpenSSL automatically \- that behaviour is something for the application to control. Some applications will want to allow the user to specify exactly which \s-1ENGINE\s0 they want used if any is to be used at all. Others may prefer to load all support and have OpenSSL automatically use at run-time any \s-1ENGINE\s0 that is able to successfully initialise \- ie. to assume that this corresponds to acceleration hardware attached to the machine or some such thing. There are probably numerous other ways in which applications may prefer to handle things, so we will simply illustrate the consequences as they apply to a couple of simple cases and leave developers to consider these and the source code to openssl's builtin utilities as guides. .PP \&\fIUsing a specific \s-1ENGINE\s0 implementation\fR .PP Here we'll assume an application has been configured by its user or admin to want to use the \*(L"\s-1ACME\*(R" ENGINE\s0 if it is available in the version of OpenSSL the application was compiled with. If it is available, it should be used by default for all \s-1RSA, DSA,\s0 and symmetric cipher operation, otherwise OpenSSL should use its builtin software as per usual. The following code illustrates how to approach this; .PP .Vb 10 \& ENGINE *e; \& const char *engine_id = "ACME"; \& ENGINE_load_builtin_engines(); \& e = ENGINE_by_id(engine_id); \& if (!e) \& /* the engine isn\*(Aqt available */ \& return; \& if (!ENGINE_init(e)) { \& /* the engine couldn\*(Aqt initialise, release \*(Aqe\*(Aq */ \& ENGINE_free(e); \& return; \& } \& if (!ENGINE_set_default_RSA(e)) \& /* This should only happen when \*(Aqe\*(Aq can\*(Aqt initialise, but the previous \& * statement suggests it did. */ \& abort(); \& ENGINE_set_default_DSA(e); \& ENGINE_set_default_ciphers(e); \& /* Release the functional reference from ENGINE_init() */ \& ENGINE_finish(e); \& /* Release the structural reference from ENGINE_by_id() */ \& ENGINE_free(e); .Ve .PP \&\fIAutomatically using builtin \s-1ENGINE\s0 implementations\fR .PP Here we'll assume we want to load and register all \s-1ENGINE\s0 implementations bundled with OpenSSL, such that for any cryptographic algorithm required by OpenSSL \- if there is an \s-1ENGINE\s0 that implements it and can be initialise, it should be used. The following code illustrates how this can work; .PP .Vb 4 \& /* Load all bundled ENGINEs into memory and make them visible */ \& ENGINE_load_builtin_engines(); \& /* Register all of them for every algorithm they collectively implement */ \& ENGINE_register_all_complete(); .Ve .PP That's all that's required. Eg. the next time OpenSSL tries to set up an \&\s-1RSA\s0 key, any bundled ENGINEs that implement \s-1RSA_METHOD\s0 will be passed to \&\fIENGINE_init()\fR and if any of those succeed, that \s-1ENGINE\s0 will be set as the default for \s-1RSA\s0 use from then on. .SS "Advanced configuration support" .IX Subsection "Advanced configuration support" There is a mechanism supported by the \s-1ENGINE\s0 framework that allows each \&\s-1ENGINE\s0 implementation to define an arbitrary set of configuration \&\*(L"commands\*(R" and expose them to OpenSSL and any applications based on OpenSSL. This mechanism is entirely based on the use of name-value pairs and assumes \s-1ASCII\s0 input (no unicode or \s-1UTF\s0 for now!), so it is ideal if applications want to provide a transparent way for users to provide arbitrary configuration \*(L"directives\*(R" directly to such ENGINEs. It is also possible for the application to dynamically interrogate the loaded \s-1ENGINE\s0 implementations for the names, descriptions, and input flags of their available \*(L"control commands\*(R", providing a more flexible configuration scheme. However, if the user is expected to know which \s-1ENGINE\s0 device he/she is using (in the case of specialised hardware, this goes without saying) then applications may not need to concern themselves with discovering the supported control commands and simply prefer to pass settings into ENGINEs exactly as they are provided by the user. .PP Before illustrating how control commands work, it is worth mentioning what they are typically used for. Broadly speaking there are two uses for control commands; the first is to provide the necessary details to the implementation (which may know nothing at all specific to the host system) so that it can be initialised for use. This could include the path to any driver or config files it needs to load, required network addresses, smart-card identifiers, passwords to initialise protected devices, logging information, etc etc. This class of commands typically needs to be passed to an \s-1ENGINE \s0\fBbefore\fR attempting to initialise it, ie. before calling \fIENGINE_init()\fR. The other class of commands consist of settings or operations that tweak certain behaviour or cause certain operations to take place, and these commands may work either before or after \fIENGINE_init()\fR, or in some cases both. \s-1ENGINE\s0 implementations should provide indications of this in the descriptions attached to builtin control commands and/or in external product documentation. .PP \&\fIIssuing control commands to an \s-1ENGINE\s0\fR .PP Let's illustrate by example; a function for which the caller supplies the name of the \s-1ENGINE\s0 it wishes to use, a table of string-pairs for use before initialisation, and another table for use after initialisation. Note that the string-pairs used for control commands consist of a command \*(L"name\*(R" followed by the command \*(L"parameter\*(R" \- the parameter could be \s-1NULL\s0 in some cases but the name can not. This function should initialise the \s-1ENGINE \&\s0(issuing the \*(L"pre\*(R" commands beforehand and the \*(L"post\*(R" commands afterwards) and set it as the default for everything except \s-1RAND\s0 and then return a boolean success or failure. .PP .Vb 6 \& int \& generic_load_engine_fn(const char *engine_id, \& const char **pre_cmds, int pre_num, \& const char **post_cmds, int post_num) \& { \& ENGINE *e = ENGINE_by_id(engine_id); \& \& if (!e) \& return 0; \& while (pre_num\-\-) { \& if (!ENGINE_ctrl_cmd_string(e, \& pre_cmds[0], pre_cmds[1], 0)) { \& fprintf(stderr, \& "Failed command (%s \- %s:%s)\en", \& engine_id, pre_cmds[0], \& pre_cmds[1] ? pre_cmds[1] : "(NULL)"); \& ENGINE_free(e); \& return 0; \& } \& pre_cmds += 2; \& } \& if (!ENGINE_init(e)) { \& fprintf(stderr, "Failed initialisation\en"); \& ENGINE_free(e); \& return 0; \& } \& /* \& * ENGINE_init() returned a functional reference, \& * so free the structural reference from \& * ENGINE_by_id(). \& */ \& ENGINE_free(e); \& while (post_num\-\-) { \& if (!ENGINE_ctrl_cmd_string(e, \& post_cmds[0], post_cmds[1], 0)) { \& fprintf(stderr, \& "Failed command (%s \- %s:%s)\en", \& engine_id, post_cmds[0], \& post_cmds[1] ? post_cmds[1] : "(NULL)"); \& ENGINE_finish(e); \& return 0; \& } \& post_cmds += 2; \& } \& ENGINE_set_default(e, ENGINE_METHOD_ALL & ~ENGINE_METHOD_RAND); \& /* Success */ \& return 1; \&} .Ve .PP Note that \fIENGINE_ctrl_cmd_string()\fR accepts a boolean argument that can relax the semantics of the function \- if set non-zero it will only return failure if the \s-1ENGINE\s0 supported the given command name but failed while executing it, if the \s-1ENGINE\s0 doesn't support the command name it will simply return success without doing anything. In this case we assume the user is only supplying commands specific to the given \s-1ENGINE\s0 so we set this to \&\s-1FALSE.\s0 .PP \&\fIDiscovering supported control commands\fR .PP It is possible to discover at run-time the names, numerical-ids, descriptions and input parameters of the control commands supported by an \s-1ENGINE\s0 using a structural reference. Note that some control commands are defined by OpenSSL itself and it will intercept and handle these control commands on behalf of the \&\s-1ENGINE,\s0 ie. the \s-1ENGINE\s0's \fIctrl()\fR handler is not used for the control command. openssl/engine.h defines an index, \s-1ENGINE_CMD_BASE,\s0 that all control commands implemented by ENGINEs should be numbered from. Any command value lower than this symbol is considered a \*(L"generic\*(R" command is handled directly by the OpenSSL core routines. .PP It is using these \*(L"core\*(R" control commands that one can discover the the control commands implemented by a given \s-1ENGINE,\s0 specifically the commands; .PP .Vb 9 \& #define ENGINE_HAS_CTRL_FUNCTION 10 \& #define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11 \& #define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12 \& #define ENGINE_CTRL_GET_CMD_FROM_NAME 13 \& #define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14 \& #define ENGINE_CTRL_GET_NAME_FROM_CMD 15 \& #define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16 \& #define ENGINE_CTRL_GET_DESC_FROM_CMD 17 \& #define ENGINE_CTRL_GET_CMD_FLAGS 18 .Ve .PP Whilst these commands are automatically processed by the OpenSSL framework code, they use various properties exposed by each \s-1ENGINE\s0 to process these queries. An \s-1ENGINE\s0 has 3 properties it exposes that can affect how this behaves; it can supply a \fIctrl()\fR handler, it can specify \s-1ENGINE_FLAGS_MANUAL_CMD_CTRL\s0 in the \s-1ENGINE\s0's flags, and it can expose an array of control command descriptions. If an \s-1ENGINE\s0 specifies the \s-1ENGINE_FLAGS_MANUAL_CMD_CTRL\s0 flag, then it will simply pass all these \*(L"core\*(R" control commands directly to the \s-1ENGINE\s0's \fIctrl()\fR handler (and thus, it must have supplied one), so it is up to the \s-1ENGINE\s0 to reply to these \*(L"discovery\*(R" commands itself. If that flag is not set, then the OpenSSL framework code will work with the following rules; .PP .Vb 9 \& if no ctrl() handler supplied; \& ENGINE_HAS_CTRL_FUNCTION returns FALSE (zero), \& all other commands fail. \& if a ctrl() handler was supplied but no array of control commands; \& ENGINE_HAS_CTRL_FUNCTION returns TRUE, \& all other commands fail. \& if a ctrl() handler and array of control commands was supplied; \& ENGINE_HAS_CTRL_FUNCTION returns TRUE, \& all other commands proceed processing ... .Ve .PP If the \s-1ENGINE\s0's array of control commands is empty then all other commands will fail, otherwise; \s-1ENGINE_CTRL_GET_FIRST_CMD_TYPE\s0 returns the identifier of the first command supported by the \s-1ENGINE, ENGINE_GET_NEXT_CMD_TYPE\s0 takes the identifier of a command supported by the \s-1ENGINE\s0 and returns the next command identifier or fails if there are no more, \s-1ENGINE_CMD_FROM_NAME\s0 takes a string name for a command and returns the corresponding identifier or fails if no such command name exists, and the remaining commands take a command identifier and return properties of the corresponding commands. All except \&\s-1ENGINE_CTRL_GET_FLAGS\s0 return the string length of a command name or description, or populate a supplied character buffer with a copy of the command name or description. \s-1ENGINE_CTRL_GET_FLAGS\s0 returns a bitwise-OR'd mask of the following possible values; .PP .Vb 4 \& #define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001 \& #define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002 \& #define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004 \& #define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008 .Ve .PP If the \s-1ENGINE_CMD_FLAG_INTERNAL\s0 flag is set, then any other flags are purely informational to the caller \- this flag will prevent the command being usable for any higher-level \s-1ENGINE\s0 functions such as \fIENGINE_ctrl_cmd_string()\fR. \&\*(L"\s-1INTERNAL\*(R"\s0 commands are not intended to be exposed to text-based configuration by applications, administrations, users, etc. These can support arbitrary operations via \fIENGINE_ctrl()\fR, including passing to and/or from the control commands data of any arbitrary type. These commands are supported in the discovery mechanisms simply to allow applications determinie if an \s-1ENGINE\s0 supports certain specific commands it might want to use (eg. application \*(L"foo\*(R" might query various ENGINEs to see if they implement \*(L"\s-1FOO_GET_VENDOR_LOGO_GIF\*(R" \-\s0 and \s-1ENGINE\s0 could therefore decide whether or not to support this \*(L"foo\*(R"\-specific extension). .SS "Future developments" .IX Subsection "Future developments" The \s-1ENGINE API\s0 and internal architecture is currently being reviewed. Slated for possible release in 0.9.8 is support for transparent loading of \*(L"dynamic\*(R" ENGINEs (built as self-contained shared-libraries). This would allow \s-1ENGINE\s0 implementations to be provided independently of OpenSSL libraries and/or OpenSSL-based applications, and would also remove any requirement for applications to explicitly use the \*(L"dynamic\*(R" \s-1ENGINE\s0 to bind to shared-library implementations. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIrsa\fR\|(3), \fIdsa\fR\|(3), \fIdh\fR\|(3), \fIrand\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_get_rbio.30000644000175000017500000001127012360020736020112 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_get_rbio 3" .TH SSL_get_rbio 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_get_rbio, SSL_get_wbio \- get BIO linked to an SSL object .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIO *SSL_get_rbio(SSL *ssl); \& BIO *SSL_get_wbio(SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_get_rbio()\fR and \fISSL_get_wbio()\fR return pointers to the BIOs for the read or the write channel, which can be different. The reference count of the \s-1BIO\s0 is not incremented. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .IP "\s-1NULL\s0" 4 .IX Item "NULL" No \s-1BIO\s0 was connected to the \s-1SSL\s0 object .IP "Any other pointer" 4 .IX Item "Any other pointer" The \s-1BIO\s0 linked to \fBssl\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_set_bio\fR\|(3), \fIssl\fR\|(3) , \fIbio\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/verify.10000644000175000017500000005320412360020743017102 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "verify 1" .TH verify 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" verify \- Utility to verify certificates. .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBverify\fR [\fB\-CApath directory\fR] [\fB\-CAfile file\fR] [\fB\-purpose purpose\fR] [\fB\-policy arg\fR] [\fB\-ignore_critical\fR] [\fB\-crl_check\fR] [\fB\-crl_check_all\fR] [\fB\-policy_check\fR] [\fB\-explicit_policy\fR] [\fB\-inhibit_any\fR] [\fB\-inhibit_map\fR] [\fB\-x509_strict\fR] [\fB\-extended_crl\fR] [\fB\-use_deltas\fR] [\fB\-policy_print\fR] [\fB\-untrusted file\fR] [\fB\-help\fR] [\fB\-issuer_checks\fR] [\fB\-verbose\fR] [\fB\-\fR] [certificates] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBverify\fR command verifies certificate chains. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" .IP "\fB\-CApath directory\fR" 4 .IX Item "-CApath directory" A directory of trusted certificates. The certificates should have names of the form: hash.0 or have symbolic links to them of this form (\*(L"hash\*(R" is the hashed certificate subject name: see the \fB\-hash\fR option of the \fBx509\fR utility). .IP "\fB\-CAfile file\fR" 4 .IX Item "-CAfile file" A file of trusted certificates. The file should contain multiple certificates in \s-1PEM\s0 format concatenated together. .IP "\fB\-untrusted file\fR" 4 .IX Item "-untrusted file" A file of untrusted certificates. The file should contain multiple certificates in \s-1PEM\s0 format concatenated together. .IP "\fB\-purpose purpose\fR" 4 .IX Item "-purpose purpose" The intended use for the certificate. If this option is not specified, \&\fBverify\fR will not consider certificate purpose during chain verification. Currently accepted uses are \fBsslclient\fR, \fBsslserver\fR, \fBnssslserver\fR, \&\fBsmimesign\fR, \fBsmimeencrypt\fR. See the \fB\s-1VERIFY OPERATION\s0\fR section for more information. .IP "\fB\-help\fR" 4 .IX Item "-help" Print out a usage message. .IP "\fB\-verbose\fR" 4 .IX Item "-verbose" Print extra information about the operations being performed. .IP "\fB\-issuer_checks\fR" 4 .IX Item "-issuer_checks" Print out diagnostics relating to searches for the issuer certificate of the current certificate. This shows why each candidate issuer certificate was rejected. The presence of rejection messages does not itself imply that anything is wrong; during the normal verification process, several rejections may take place. .IP "\fB\-policy arg\fR" 4 .IX Item "-policy arg" Enable policy processing and add \fBarg\fR to the user-initial-policy-set (see \&\s-1RFC5280\s0). The policy \fBarg\fR can be an object name an \s-1OID\s0 in numeric form. This argument can appear more than once. .IP "\fB\-policy_check\fR" 4 .IX Item "-policy_check" Enables certificate policy processing. .IP "\fB\-explicit_policy\fR" 4 .IX Item "-explicit_policy" Set policy variable require-explicit-policy (see \s-1RFC5280\s0). .IP "\fB\-inhibit_any\fR" 4 .IX Item "-inhibit_any" Set policy variable inhibit-any-policy (see \s-1RFC5280\s0). .IP "\fB\-inhibit_map\fR" 4 .IX Item "-inhibit_map" Set policy variable inhibit-policy-mapping (see \s-1RFC5280\s0). .IP "\fB\-policy_print\fR" 4 .IX Item "-policy_print" Print out diagnostics related to policy processing. .IP "\fB\-crl_check\fR" 4 .IX Item "-crl_check" Checks end entity certificate validity by attempting to look up a valid \s-1CRL.\s0 If a valid \s-1CRL\s0 cannot be found an error occurs. .IP "\fB\-crl_check_all\fR" 4 .IX Item "-crl_check_all" Checks the validity of \fBall\fR certificates in the chain by attempting to look up valid CRLs. .IP "\fB\-ignore_critical\fR" 4 .IX Item "-ignore_critical" Normally if an unhandled critical extension is present which is not supported by OpenSSL the certificate is rejected (as required by \s-1RFC5280\s0). If this option is set critical extensions are ignored. .IP "\fB\-x509_strict\fR" 4 .IX Item "-x509_strict" For strict X.509 compliance, disable non-compliant workarounds for broken certificates. .IP "\fB\-extended_crl\fR" 4 .IX Item "-extended_crl" Enable extended \s-1CRL\s0 features such as indirect CRLs and alternate \s-1CRL\s0 signing keys. .IP "\fB\-use_deltas\fR" 4 .IX Item "-use_deltas" Enable support for delta CRLs. .IP "\fB\-check_ss_sig\fR" 4 .IX Item "-check_ss_sig" Verify the signature on the self-signed root \s-1CA.\s0 This is disabled by default because it doesn't add any security. .IP "\fB\-\fR" 4 .IX Item "-" Indicates the last option. All arguments following this are assumed to be certificate files. This is useful if the first certificate filename begins with a \fB\-\fR. .IP "\fBcertificates\fR" 4 .IX Item "certificates" One or more certificates to verify. If no certificates are given, \fBverify\fR will attempt to read a certificate from standard input. Certificates must be in \s-1PEM\s0 format. .SH "VERIFY OPERATION" .IX Header "VERIFY OPERATION" The \fBverify\fR program uses the same functions as the internal \s-1SSL\s0 and S/MIME verification, therefore this description applies to these verify operations too. .PP There is one crucial difference between the verify operations performed by the \fBverify\fR program: wherever possible an attempt is made to continue after an error whereas normally the verify operation would halt on the first error. This allows all the problems with a certificate chain to be determined. .PP The verify operation consists of a number of separate steps. .PP Firstly a certificate chain is built up starting from the supplied certificate and ending in the root \s-1CA.\s0 It is an error if the whole chain cannot be built up. The chain is built up by looking up the issuers certificate of the current certificate. If a certificate is found which is its own issuer it is assumed to be the root \s-1CA.\s0 .PP The process of 'looking up the issuers certificate' itself involves a number of steps. In versions of OpenSSL before 0.9.5a the first certificate whose subject name matched the issuer of the current certificate was assumed to be the issuers certificate. In OpenSSL 0.9.6 and later all certificates whose subject name matches the issuer name of the current certificate are subject to further tests. The relevant authority key identifier components of the current certificate (if present) must match the subject key identifier (if present) and issuer and serial number of the candidate issuer, in addition the keyUsage extension of the candidate issuer (if present) must permit certificate signing. .PP The lookup first looks in the list of untrusted certificates and if no match is found the remaining lookups are from the trusted certificates. The root \s-1CA\s0 is always looked up in the trusted certificate list: if the certificate to verify is a root certificate then an exact match must be found in the trusted list. .PP The second operation is to check every untrusted certificate's extensions for consistency with the supplied purpose. If the \fB\-purpose\fR option is not included then no checks are done. The supplied or \*(L"leaf\*(R" certificate must have extensions compatible with the supplied purpose and all other certificates must also be valid \&\s-1CA\s0 certificates. The precise extensions required are described in more detail in the \fB\s-1CERTIFICATE EXTENSIONS\s0\fR section of the \fBx509\fR utility. .PP The third operation is to check the trust settings on the root \s-1CA.\s0 The root \&\s-1CA\s0 should be trusted for the supplied purpose. For compatibility with previous versions of SSLeay and OpenSSL a certificate with no trust settings is considered to be valid for all purposes. .PP The final operation is to check the validity of the certificate chain. The validity period is checked against the current system time and the notBefore and notAfter dates in the certificate. The certificate signatures are also checked at this point. .PP If all operations complete successfully then certificate is considered valid. If any operation fails then the certificate is not valid. .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" When a verify operation fails the output messages can be somewhat cryptic. The general form of the error message is: .PP .Vb 2 \& server.pem: /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024 bit) \& error 24 at 1 depth lookup:invalid CA certificate .Ve .PP The first line contains the name of the certificate being verified followed by the subject name of the certificate. The second line contains the error number and the depth. The depth is number of the certificate being verified when a problem was detected starting with zero for the certificate being verified itself then 1 for the \s-1CA\s0 that signed the certificate and so on. Finally a text version of the error number is presented. .PP An exhaustive list of the error codes and messages is shown below, this also includes the name of the error code as defined in the header file x509_vfy.h Some of the error codes are defined but never returned: these are described as \*(L"unused\*(R". .IP "\fB0 X509_V_OK: ok\fR" 4 .IX Item "0 X509_V_OK: ok" the operation was successful. .IP "\fB2 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate\fR" 4 .IX Item "2 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate" the issuer certificate of a looked up certificate could not be found. This normally means the list of trusted certificates is not complete. .IP "\fB3 X509_V_ERR_UNABLE_TO_GET_CRL: unable to get certificate \s-1CRL\s0\fR" 4 .IX Item "3 X509_V_ERR_UNABLE_TO_GET_CRL: unable to get certificate CRL" the \s-1CRL\s0 of a certificate could not be found. .IP "\fB4 X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate's signature\fR" 4 .IX Item "4 X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate's signature" the certificate signature could not be decrypted. This means that the actual signature value could not be determined rather than it not matching the expected value, this is only meaningful for \s-1RSA\s0 keys. .IP "\fB5 X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt \s-1CRL\s0's signature\fR" 4 .IX Item "5 X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt CRL's signature" the \s-1CRL\s0 signature could not be decrypted: this means that the actual signature value could not be determined rather than it not matching the expected value. Unused. .IP "\fB6 X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key\fR" 4 .IX Item "6 X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key" the public key in the certificate SubjectPublicKeyInfo could not be read. .IP "\fB7 X509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure\fR" 4 .IX Item "7 X509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure" the signature of the certificate is invalid. .IP "\fB8 X509_V_ERR_CRL_SIGNATURE_FAILURE: \s-1CRL\s0 signature failure\fR" 4 .IX Item "8 X509_V_ERR_CRL_SIGNATURE_FAILURE: CRL signature failure" the signature of the certificate is invalid. .IP "\fB9 X509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid\fR" 4 .IX Item "9 X509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid" the certificate is not yet valid: the notBefore date is after the current time. .IP "\fB10 X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired\fR" 4 .IX Item "10 X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired" the certificate has expired: that is the notAfter date is before the current time. .IP "\fB11 X509_V_ERR_CRL_NOT_YET_VALID: \s-1CRL\s0 is not yet valid\fR" 4 .IX Item "11 X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid" the \s-1CRL\s0 is not yet valid. .IP "\fB12 X509_V_ERR_CRL_HAS_EXPIRED: \s-1CRL\s0 has expired\fR" 4 .IX Item "12 X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired" the \s-1CRL\s0 has expired. .IP "\fB13 X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate's notBefore field\fR" 4 .IX Item "13 X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate's notBefore field" the certificate notBefore field contains an invalid time. .IP "\fB14 X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate's notAfter field\fR" 4 .IX Item "14 X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate's notAfter field" the certificate notAfter field contains an invalid time. .IP "\fB15 X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in \s-1CRL\s0's lastUpdate field\fR" 4 .IX Item "15 X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in CRL's lastUpdate field" the \s-1CRL\s0 lastUpdate field contains an invalid time. .IP "\fB16 X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in \s-1CRL\s0's nextUpdate field\fR" 4 .IX Item "16 X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in CRL's nextUpdate field" the \s-1CRL\s0 nextUpdate field contains an invalid time. .IP "\fB17 X509_V_ERR_OUT_OF_MEM: out of memory\fR" 4 .IX Item "17 X509_V_ERR_OUT_OF_MEM: out of memory" an error occurred trying to allocate memory. This should never happen. .IP "\fB18 X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate\fR" 4 .IX Item "18 X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate" the passed certificate is self signed and the same certificate cannot be found in the list of trusted certificates. .IP "\fB19 X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain\fR" 4 .IX Item "19 X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain" the certificate chain could be built up using the untrusted certificates but the root could not be found locally. .IP "\fB20 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate\fR" 4 .IX Item "20 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate" the issuer certificate could not be found: this occurs if the issuer certificate of an untrusted certificate cannot be found. .IP "\fB21 X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate\fR" 4 .IX Item "21 X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate" no signatures could be verified because the chain contains only one certificate and it is not self signed. .IP "\fB22 X509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long\fR" 4 .IX Item "22 X509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long" the certificate chain length is greater than the supplied maximum depth. Unused. .IP "\fB23 X509_V_ERR_CERT_REVOKED: certificate revoked\fR" 4 .IX Item "23 X509_V_ERR_CERT_REVOKED: certificate revoked" the certificate has been revoked. .IP "\fB24 X509_V_ERR_INVALID_CA: invalid \s-1CA\s0 certificate\fR" 4 .IX Item "24 X509_V_ERR_INVALID_CA: invalid CA certificate" a \s-1CA\s0 certificate is invalid. Either it is not a \s-1CA\s0 or its extensions are not consistent with the supplied purpose. .IP "\fB25 X509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded\fR" 4 .IX Item "25 X509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded" the basicConstraints pathlength parameter has been exceeded. .IP "\fB26 X509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose\fR" 4 .IX Item "26 X509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose" the supplied certificate cannot be used for the specified purpose. .IP "\fB27 X509_V_ERR_CERT_UNTRUSTED: certificate not trusted\fR" 4 .IX Item "27 X509_V_ERR_CERT_UNTRUSTED: certificate not trusted" the root \s-1CA\s0 is not marked as trusted for the specified purpose. .IP "\fB28 X509_V_ERR_CERT_REJECTED: certificate rejected\fR" 4 .IX Item "28 X509_V_ERR_CERT_REJECTED: certificate rejected" the root \s-1CA\s0 is marked to reject the specified purpose. .IP "\fB29 X509_V_ERR_SUBJECT_ISSUER_MISMATCH: subject issuer mismatch\fR" 4 .IX Item "29 X509_V_ERR_SUBJECT_ISSUER_MISMATCH: subject issuer mismatch" the current candidate issuer certificate was rejected because its subject name did not match the issuer name of the current certificate. Only displayed when the \fB\-issuer_checks\fR option is set. .IP "\fB30 X509_V_ERR_AKID_SKID_MISMATCH: authority and subject key identifier mismatch\fR" 4 .IX Item "30 X509_V_ERR_AKID_SKID_MISMATCH: authority and subject key identifier mismatch" the current candidate issuer certificate was rejected because its subject key identifier was present and did not match the authority key identifier current certificate. Only displayed when the \fB\-issuer_checks\fR option is set. .IP "\fB31 X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: authority and issuer serial number mismatch\fR" 4 .IX Item "31 X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: authority and issuer serial number mismatch" the current candidate issuer certificate was rejected because its issuer name and serial number was present and did not match the authority key identifier of the current certificate. Only displayed when the \fB\-issuer_checks\fR option is set. .IP "\fB32 X509_V_ERR_KEYUSAGE_NO_CERTSIGN:key usage does not include certificate signing\fR" 4 .IX Item "32 X509_V_ERR_KEYUSAGE_NO_CERTSIGN:key usage does not include certificate signing" the current candidate issuer certificate was rejected because its keyUsage extension does not permit certificate signing. .IP "\fB50 X509_V_ERR_APPLICATION_VERIFICATION: application verification failure\fR" 4 .IX Item "50 X509_V_ERR_APPLICATION_VERIFICATION: application verification failure" an application specific error. Unused. .SH "BUGS" .IX Header "BUGS" Although the issuer checks are a considerable improvement over the old technique they still suffer from limitations in the underlying X509_LOOKUP \s-1API.\s0 One consequence of this is that trusted certificates with matching subject name must either appear in a file (as specified by the \&\fB\-CAfile\fR option) or a directory (as specified by \fB\-CApath\fR. If they occur in both then only the certificates in the file will be recognised. .PP Previous versions of OpenSSL assume certificates with matching subject name are identical and mishandled them. .PP Previous versions of this documentation swapped the meaning of the \&\fBX509_V_ERR_UNABLE_TO_GET_ISSUER_CERT\fR and \&\fB20 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY\fR error codes. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIx509\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/d2i_X509_CRL.30000644000175000017500000001141712360020727017505 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "d2i_X509_CRL 3" .TH d2i_X509_CRL 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" d2i_X509_CRL, i2d_X509_CRL, d2i_X509_CRL_bio, d2i_X509_CRL_fp, i2d_X509_CRL_bio, i2d_X509_CRL_fp \- PKCS#10 certificate request functions. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& X509_CRL *d2i_X509_CRL(X509_CRL **a, const unsigned char **pp, long length); \& int i2d_X509_CRL(X509_CRL *a, unsigned char **pp); \& \& X509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **x); \& X509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **x); \& \& int i2d_X509_CRL_bio(BIO *bp, X509_CRL *x); \& int i2d_X509_CRL_fp(FILE *fp, X509_CRL *x); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions decode and encode an X509 \s-1CRL \s0(certificate revocation list). .PP Othewise the functions behave in a similar way to \fId2i_X509()\fR and \fIi2d_X509()\fR described in the \fId2i_X509\fR\|(3) manual page. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fId2i_X509\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/X509_STORE_set_verify_cb_func.30000644000175000017500000001277712360020726023152 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "X509_STORE_set_verify_cb_func 3" .TH X509_STORE_set_verify_cb_func 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" X509_STORE_set_verify_cb_func, X509_STORE_set_verify_cb \- set verification callback .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void X509_STORE_set_verify_cb(X509_STORE *st, \& int (*verify_cb)(int ok, X509_STORE_CTX *ctx)); \& \& void X509_STORE_set_verify_cb_func(X509_STORE *st, \& int (*verify_cb)(int ok, X509_STORE_CTX *ctx)); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIX509_STORE_set_verify_cb()\fR sets the verification callback of \fBctx\fR to \&\fBverify_cb\fR overwriting any existing callback. .PP \&\fIX509_STORE_set_verify_cb_func()\fR also sets the verification callback but it is implemented as a macro. .SH "NOTES" .IX Header "NOTES" The verification callback from an \fBX509_STORE\fR is inherited by the corresponding \fBX509_STORE_CTX\fR structure when it is initialized. This can be used to set the verification callback when the \fBX509_STORE_CTX\fR is otherwise inaccessible (for example during S/MIME verification). .SH "BUGS" .IX Header "BUGS" The macro version of this function was the only one available before OpenSSL 1.0.0. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIX509_STORE_set_verify_cb()\fR and \fIX509_STORE_set_verify_cb_func()\fR do not return a value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIX509_STORE_CTX_set_verify_cb\fR\|(3) \&\fICMS_verify\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIX509_STORE_set_verify_cb_func()\fR is available in all versions of SSLeay and OpenSSL. .PP \&\fIX509_STORE_set_verify_cb()\fR was added to OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_add_extra_chain_cert.30000644000175000017500000001236112360020731023145 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_add_extra_chain_cert 3" .TH SSL_CTX_add_extra_chain_cert 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_add_extra_chain_cert \- add certificate to chain .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& long SSL_CTX_add_extra_chain_cert(SSL_CTX ctx, X509 *x509) .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_add_extra_chain_cert()\fR adds the certificate \fBx509\fR to the certificate chain presented together with the certificate. Several certificates can be added one after the other. .SH "NOTES" .IX Header "NOTES" When constructing the certificate chain, the chain will be formed from these certificates explicitly specified. If no chain is specified, the library will try to complete the chain from the available \s-1CA\s0 certificates in the trusted \s-1CA\s0 storage, see \&\fISSL_CTX_load_verify_locations\fR\|(3). .PP The \fBx509\fR certificate provided to \fISSL_CTX_add_extra_chain_cert()\fR will be freed by the library when the \fB\s-1SSL_CTX\s0\fR is destroyed. An application \fBshould not\fR free the \fBx509\fR object. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_add_extra_chain_cert()\fR returns 1 on success. Check out the error stack to find out the reason for failure otherwise. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \&\fISSL_CTX_use_certificate\fR\|(3), \&\fISSL_CTX_set_client_cert_cb\fR\|(3), \&\fISSL_CTX_load_verify_locations\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_PKEY_get_default_digest.30000644000175000017500000001212312360020720022752 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_PKEY_get_default_digest 3" .TH EVP_PKEY_get_default_digest 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_PKEY_get_default_digest_nid \- get default signature digest .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fIEVP_PKEY_get_default_digest_nid()\fR function sets \fBpnid\fR to the default message digest \s-1NID\s0 for the public key signature operations associated with key \&\fBpkey\fR. .SH "NOTES" .IX Header "NOTES" For all current standard OpenSSL public key algorithms \s-1SHA1\s0 is returned. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The \fIEVP_PKEY_get_default_digest_nid()\fR function returns 1 if the message digest is advisory (that is other digests can be used) and 2 if it is mandatory (other digests can not be used). It returns 0 or a negative value for failure. In particular a return value of \-2 indicates the operation is not supported by the public key algorithm. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_PKEY_CTX_new\fR\|(3), \&\fIEVP_PKEY_sign\fR\|(3), \&\fIEVP_PKEY_verify\fR\|(3), \&\fIEVP_PKEY_verify_recover\fR\|(3), .SH "HISTORY" .IX Header "HISTORY" This function was first added to OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/DSA_dup_DH.30000644000175000017500000001135512360020715017432 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DSA_dup_DH 3" .TH DSA_dup_DH 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DSA_dup_DH \- create a DH structure out of DSA structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& DH * DSA_dup_DH(const DSA *r); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIDSA_dup_DH()\fR duplicates \s-1DSA\s0 parameters/keys as \s-1DH\s0 parameters/keys. q is lost during that conversion, but the resulting \s-1DH\s0 parameters contain its length. .SH "RETURN VALUE" .IX Header "RETURN VALUE" \&\fIDSA_dup_DH()\fR returns the new \fB\s-1DH\s0\fR structure, and \s-1NULL\s0 on error. The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "NOTE" .IX Header "NOTE" Be careful to avoid small subgroup attacks when using this. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdh\fR\|(3), \fIdsa\fR\|(3), \fIERR_get_error\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIDSA_dup_DH()\fR was added in OpenSSL 0.9.4. deps/libressl-pnacl-sys-2.1.6/libressl/man/DSA_new.30000644000175000017500000001170012360020715017052 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DSA_new 3" .TH DSA_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DSA_new, DSA_free \- allocate and free DSA objects .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& DSA* DSA_new(void); \& \& void DSA_free(DSA *dsa); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIDSA_new()\fR allocates and initializes a \fB\s-1DSA\s0\fR structure. It is equivalent to calling DSA_new_method(\s-1NULL\s0). .PP \&\fIDSA_free()\fR frees the \fB\s-1DSA\s0\fR structure and its components. The values are erased before the memory is returned to the system. .SH "RETURN VALUES" .IX Header "RETURN VALUES" If the allocation fails, \fIDSA_new()\fR returns \fB\s-1NULL\s0\fR and sets an error code that can be obtained by \&\fIERR_get_error\fR\|(3). Otherwise it returns a pointer to the newly allocated structure. .PP \&\fIDSA_free()\fR returns no value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdsa\fR\|(3), \fIERR_get_error\fR\|(3), \&\fIDSA_generate_parameters\fR\|(3), \&\fIDSA_generate_key\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIDSA_new()\fR and \fIDSA_free()\fR are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_free.30000644000175000017500000001225012360020731017751 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_free 3" .TH SSL_CTX_free 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_free \- free an allocated SSL_CTX object .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_CTX_free(SSL_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_free()\fR decrements the reference count of \fBctx\fR, and removes the \&\s-1SSL_CTX\s0 object pointed to by \fBctx\fR and frees up the allocated memory if the the reference count has reached 0. .PP It also calls the \fIfree()\fRing procedures for indirectly affected items, if applicable: the session cache, the list of ciphers, the list of Client CAs, the certificates and keys. .SH "WARNINGS" .IX Header "WARNINGS" If a session-remove callback is set (\fISSL_CTX_sess_set_remove_cb()\fR), this callback will be called for each session being freed from \fBctx\fR's session cache. This implies, that all corresponding sessions from an external session cache are removed as well. If this is not desired, the user should explicitly unset the callback by calling SSL_CTX_sess_set_remove_cb(\fBctx\fR, \s-1NULL\s0) prior to calling \fISSL_CTX_free()\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_free()\fR does not provide diagnostic information. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_CTX_new\fR\|(3), \fIssl\fR\|(3), \&\fISSL_CTX_sess_set_get_cb\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/Makefile.in0000664000175000017500000035115012437255271017577 0ustar # Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ DIST_COMMON = $(top_srcdir)/Makefile.am.common $(srcdir)/Makefile.in \ $(srcdir)/Makefile.am $(dist_man_MANS) subdir = man ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } man1dir = $(mandir)/man1 am__installdirs = "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man3dir)" man3dir = $(mandir)/man3 NROFF = nroff MANS = $(dist_man_MANS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ NO_ARC4RANDOM_BUF = @NO_ARC4RANDOM_BUF@ NO_GETENTROPY = @NO_GETENTROPY@ NO_ISSETUGID = @NO_ISSETUGID@ NO_REALLOCARRAY = @NO_REALLOCARRAY@ NO_STRLCAT = @NO_STRLCAT@ NO_STRLCPY = @NO_STRLCPY@ NO_STRTONUM = @NO_STRTONUM@ NO_TIMINGSAFE_BCMP = @NO_TIMINGSAFE_BCMP@ NO_TIMINGSAFE_MEMCMP = @NO_TIMINGSAFE_MEMCMP@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PLATFORM_LDADD = @PLATFORM_LDADD@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ USER_CFLAGS = @USER_CFLAGS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = -I$(top_srcdir)/include -DOPENSSL_NO_ASM \ -DHAVE_CRYPTODEV -DLIBRESSL_INTERNAL dist_man_MANS = ASN1_OBJECT_new.3 ASN1_STRING_length.3 \ ASN1_STRING_new.3 ASN1_STRING_print_ex.3 ASN1_generate_nconf.3 \ BF_set_key.3 BIO.3 BIO_ctrl.3 BIO_f_base64.3 BIO_f_buffer.3 \ BIO_f_cipher.3 BIO_f_md.3 BIO_f_null.3 BIO_find_type.3 \ BIO_new.3 BIO_new_CMS.3 BIO_push.3 BIO_read.3 BIO_s_accept.3 \ BIO_s_bio.3 BIO_s_connect.3 BIO_s_fd.3 BIO_s_file.3 \ BIO_s_mem.3 BIO_s_null.3 BIO_s_socket.3 BIO_set_callback.3 \ BIO_should_retry.3 BN_BLINDING_new.3 BN_CTX_new.3 \ BN_CTX_start.3 BN_add.3 BN_add_word.3 BN_bn2bin.3 BN_cmp.3 \ BN_copy.3 BN_generate_prime.3 BN_mod_inverse.3 \ BN_mod_mul_montgomery.3 BN_mod_mul_reciprocal.3 BN_new.3 \ BN_num_bytes.3 BN_rand.3 BN_set_bit.3 BN_swap.3 BN_zero.3 \ BUF_MEM_new.3 CMS_add0_cert.3 CMS_add1_recipient_cert.3 \ CMS_compress.3 CMS_decrypt.3 CMS_encrypt.3 CMS_final.3 \ CMS_get0_RecipientInfos.3 CMS_get0_SignerInfos.3 \ CMS_get0_type.3 CMS_get1_ReceiptRequest.3 CMS_sign.3 \ CMS_sign_add1_signer.3 CMS_sign_receipt.3 CMS_uncompress.3 \ CMS_verify.3 CMS_verify_receipt.3 CONF_modules_free.3 \ CONF_modules_load_file.3 CRYPTO_set_ex_data.3 \ CRYPTO_set_locking_callback.3 DES_set_key.3 DH_generate_key.3 \ DH_generate_parameters.3 DH_get_ex_new_index.3 DH_new.3 \ DH_set_method.3 DH_size.3 DSA_SIG_new.3 DSA_do_sign.3 \ DSA_dup_DH.3 DSA_generate_key.3 DSA_generate_parameters.3 \ DSA_get_ex_new_index.3 DSA_new.3 DSA_set_method.3 DSA_sign.3 \ DSA_size.3 EC_GFp_simple_method.3 EC_GROUP_copy.3 \ EC_GROUP_new.3 EC_KEY_new.3 EC_POINT_add.3 EC_POINT_new.3 \ ERR.3 ERR_GET_LIB.3 ERR_clear_error.3 ERR_error_string.3 \ ERR_get_error.3 ERR_load_crypto_strings.3 ERR_load_strings.3 \ ERR_print_errors.3 ERR_put_error.3 ERR_remove_state.3 \ ERR_set_mark.3 EVP_BytesToKey.3 EVP_DigestInit.3 \ EVP_DigestSignInit.3 EVP_DigestVerifyInit.3 EVP_EncryptInit.3 \ EVP_OpenInit.3 EVP_PKEY_CTX_ctrl.3 EVP_PKEY_CTX_new.3 \ EVP_PKEY_cmp.3 EVP_PKEY_decrypt.3 EVP_PKEY_derive.3 \ EVP_PKEY_encrypt.3 EVP_PKEY_get_default_digest.3 \ EVP_PKEY_keygen.3 EVP_PKEY_new.3 EVP_PKEY_print_private.3 \ EVP_PKEY_set1_RSA.3 EVP_PKEY_sign.3 EVP_PKEY_verify.3 \ EVP_PKEY_verify_recover.3 EVP_SealInit.3 EVP_SignInit.3 \ EVP_VerifyInit.3 HMAC.3 MD5.3 OBJ_nid2obj.3 \ OPENSSL_VERSION_NUMBER.3 OPENSSL_config.3 \ OPENSSL_load_builtin_modules.3 OpenSSL_add_all_algorithms.3 \ PEM_read_bio_PrivateKey.3 PEM_write_bio_CMS_stream.3 \ PEM_write_bio_PKCS7_stream.3 PKCS12_create.3 PKCS12_parse.3 \ PKCS5_PBKDF2_HMAC.3 PKCS7_decrypt.3 PKCS7_encrypt.3 \ PKCS7_sign.3 PKCS7_sign_add_signer.3 PKCS7_verify.3 RAND.3 \ RAND_add.3 RAND_bytes.3 RAND_cleanup.3 RAND_load_file.3 \ RAND_set_rand_method.3 RC4.3 RIPEMD160.3 RSA_blinding_on.3 \ RSA_check_key.3 RSA_generate_key.3 RSA_get_ex_new_index.3 \ RSA_new.3 RSA_padding_add_PKCS1_type_1.3 RSA_print.3 \ RSA_private_encrypt.3 RSA_public_encrypt.3 RSA_set_method.3 \ RSA_sign.3 RSA_sign_ASN1_OCTET_STRING.3 RSA_size.3 SHA1.3 \ SMIME_read_CMS.3 SMIME_read_PKCS7.3 SMIME_write_CMS.3 \ SMIME_write_PKCS7.3 X509_NAME_ENTRY_get_object.3 \ X509_NAME_add_entry_by_txt.3 X509_NAME_get_index_by_NID.3 \ X509_NAME_print_ex.3 X509_STORE_CTX_get_error.3 \ X509_STORE_CTX_get_ex_new_index.3 X509_STORE_CTX_new.3 \ X509_STORE_CTX_set_verify_cb.3 X509_STORE_set_verify_cb_func.3 \ X509_VERIFY_PARAM_set_flags.3 X509_new.3 X509_verify_cert.3 \ bn.3 bn_internal.3 crypto.3 d2i_ASN1_OBJECT.3 d2i_DHparams.3 \ d2i_DSAPublicKey.3 d2i_ECPKParameters.3 d2i_PKCS8PrivateKey.3 \ d2i_RSAPublicKey.3 d2i_X509.3 d2i_X509_ALGOR.3 d2i_X509_CRL.3 \ d2i_X509_NAME.3 d2i_X509_REQ.3 d2i_X509_SIG.3 dh.3 dsa.3 ec.3 \ ecdsa.3 engine.3 evp.3 i2d_CMS_bio_stream.3 \ i2d_PKCS7_bio_stream.3 lh_stats.3 lhash.3 rsa.3 ui.3 \ ui_compat.3 x509.3 BIO_f_ssl.3 SSL_CIPHER_get_name.3 \ SSL_COMP_add_compression_method.3 \ SSL_CTX_add_extra_chain_cert.3 SSL_CTX_add_session.3 \ SSL_CTX_ctrl.3 SSL_CTX_flush_sessions.3 SSL_CTX_free.3 \ SSL_CTX_get_ex_new_index.3 SSL_CTX_get_verify_mode.3 \ SSL_CTX_load_verify_locations.3 SSL_CTX_new.3 \ SSL_CTX_sess_number.3 SSL_CTX_sess_set_cache_size.3 \ SSL_CTX_sess_set_get_cb.3 SSL_CTX_sessions.3 \ SSL_CTX_set_cert_store.3 SSL_CTX_set_cert_verify_callback.3 \ SSL_CTX_set_cipher_list.3 SSL_CTX_set_client_CA_list.3 \ SSL_CTX_set_client_cert_cb.3 SSL_CTX_set_default_passwd_cb.3 \ SSL_CTX_set_generate_session_id.3 SSL_CTX_set_info_callback.3 \ SSL_CTX_set_max_cert_list.3 SSL_CTX_set_mode.3 \ SSL_CTX_set_msg_callback.3 SSL_CTX_set_options.3 \ SSL_CTX_set_psk_client_callback.3 SSL_CTX_set_quiet_shutdown.3 \ SSL_CTX_set_session_cache_mode.3 \ SSL_CTX_set_session_id_context.3 SSL_CTX_set_ssl_version.3 \ SSL_CTX_set_timeout.3 SSL_CTX_set_tmp_dh_callback.3 \ SSL_CTX_set_tmp_rsa_callback.3 SSL_CTX_set_verify.3 \ SSL_CTX_use_certificate.3 SSL_CTX_use_psk_identity_hint.3 \ SSL_SESSION_free.3 SSL_SESSION_get_ex_new_index.3 \ SSL_SESSION_get_time.3 SSL_accept.3 SSL_alert_type_string.3 \ SSL_clear.3 SSL_connect.3 SSL_do_handshake.3 SSL_free.3 \ SSL_get_SSL_CTX.3 SSL_get_ciphers.3 SSL_get_client_CA_list.3 \ SSL_get_current_cipher.3 SSL_get_default_timeout.3 \ SSL_get_error.3 SSL_get_ex_data_X509_STORE_CTX_idx.3 \ SSL_get_ex_new_index.3 SSL_get_fd.3 SSL_get_peer_cert_chain.3 \ SSL_get_peer_certificate.3 SSL_get_psk_identity.3 \ SSL_get_rbio.3 SSL_get_session.3 SSL_get_verify_result.3 \ SSL_get_version.3 SSL_library_init.3 SSL_load_client_CA_file.3 \ SSL_new.3 SSL_pending.3 SSL_read.3 SSL_rstate_string.3 \ SSL_session_reused.3 SSL_set_bio.3 SSL_set_connect_state.3 \ SSL_set_fd.3 SSL_set_session.3 SSL_set_shutdown.3 \ SSL_set_verify_result.3 SSL_shutdown.3 SSL_state_string.3 \ SSL_want.3 SSL_write.3 d2i_SSL_SESSION.3 ssl.3 asn1parse.1 \ ca.1 ciphers.1 cms.1 config.1 crl.1 crl2pkcs7.1 dgst.1 \ dhparam.1 dsa.1 dsaparam.1 ec.1 ecparam.1 enc.1 errstr.1 \ gendsa.1 genpkey.1 genrsa.1 nseq.1 ocsp.1 openssl.1 passwd.1 \ pkcs12.1 pkcs7.1 pkcs8.1 pkey.1 pkeyparam.1 pkeyutl.1 rand.1 \ req.1 rsa.1 rsautl.1 s_client.1 s_server.1 s_time.1 sess_id.1 \ smime.1 speed.1 spkac.1 ts.1 verify.1 version.1 x509.1 \ x509v3_config.1 openssl.1 all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.am.common $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu man/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu man/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_srcdir)/Makefile.am.common: $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-man1: $(dist_man_MANS) @$(NORMAL_INSTALL) @list1=''; \ list2='$(dist_man_MANS)'; \ test -n "$(man1dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.1[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ done; } uninstall-man1: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.1[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) install-man3: $(dist_man_MANS) @$(NORMAL_INSTALL) @list1=''; \ list2='$(dist_man_MANS)'; \ test -n "$(man3dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man3dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man3dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.3[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man3dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man3dir)" || exit $$?; }; \ done; } uninstall-man3: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man3dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.3[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir) tags TAGS: ctags CTAGS: cscope cscopelist: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(MANS) installdirs: for dir in "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man3dir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-man @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-data-hook install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-man1 install-man3 install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-man uninstall-man: uninstall-man1 uninstall-man3 .MAKE: install-am install-data-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ cscopelist-am ctags-am distclean distclean-generic \ distclean-libtool distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am \ install-data-hook install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-man1 install-man3 \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags-am uninstall uninstall-am uninstall-man uninstall-man1 \ uninstall-man3 install-data-hook: ln -f $(DESTDIR)$(mandir)/man3/ASN1_OBJECT_new.3 $(DESTDIR)$(mandir)/man3/ASN1_OBJECT_free.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_length.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_cmp.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_length.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_data.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_length.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_dup.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_length.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_set.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_length.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_to_UTF8.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_length.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_type.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_new.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_free.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_new.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_type_new.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_print_ex.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_print.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_STRING_print_ex.3 $(DESTDIR)$(mandir)/man3/ASN1_STRING_print_ex_fp.3 ln -f $(DESTDIR)$(mandir)/man3/ASN1_generate_nconf.3 $(DESTDIR)$(mandir)/man3/ASN1_generate_v3.3 ln -f $(DESTDIR)$(mandir)/man3/BF_set_key.3 $(DESTDIR)$(mandir)/man3/BF_cbc_encrypt.3 ln -f $(DESTDIR)$(mandir)/man3/BF_set_key.3 $(DESTDIR)$(mandir)/man3/BF_cfb64_encrypt.3 ln -f $(DESTDIR)$(mandir)/man3/BF_set_key.3 $(DESTDIR)$(mandir)/man3/BF_decrypt.3 ln -f $(DESTDIR)$(mandir)/man3/BF_set_key.3 $(DESTDIR)$(mandir)/man3/BF_ecb_encrypt.3 ln -f $(DESTDIR)$(mandir)/man3/BF_set_key.3 $(DESTDIR)$(mandir)/man3/BF_encrypt.3 ln -f $(DESTDIR)$(mandir)/man3/BF_set_key.3 $(DESTDIR)$(mandir)/man3/BF_ofb64_encrypt.3 ln -f $(DESTDIR)$(mandir)/man3/BF_set_key.3 $(DESTDIR)$(mandir)/man3/BF_options.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_callback_ctrl.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_ctrl_pending.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_ctrl_wpending.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_eof.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_flush.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_get_close.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_get_info_callback.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_int_ctrl.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_pending.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_ptr_ctrl.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_reset.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_seek.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_set_close.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_set_info_callback.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_ctrl.3 $(DESTDIR)$(mandir)/man3/BIO_tell.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_buffer.3 $(DESTDIR)$(mandir)/man3/BIO_get_buffer_num_lines.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_buffer.3 $(DESTDIR)$(mandir)/man3/BIO_set_buffer_read_data.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_buffer.3 $(DESTDIR)$(mandir)/man3/BIO_set_buffer_size.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_buffer.3 $(DESTDIR)$(mandir)/man3/BIO_set_read_buffer_size.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_buffer.3 $(DESTDIR)$(mandir)/man3/BIO_set_write_buffer_size.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_cipher.3 $(DESTDIR)$(mandir)/man3/BIO_get_cipher_ctx.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_cipher.3 $(DESTDIR)$(mandir)/man3/BIO_get_cipher_status.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_cipher.3 $(DESTDIR)$(mandir)/man3/BIO_set_cipher.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_md.3 $(DESTDIR)$(mandir)/man3/BIO_get_md.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_md.3 $(DESTDIR)$(mandir)/man3/BIO_get_md_ctx.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_md.3 $(DESTDIR)$(mandir)/man3/BIO_set_md.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_find_type.3 $(DESTDIR)$(mandir)/man3/BIO_method_type.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_find_type.3 $(DESTDIR)$(mandir)/man3/BIO_next.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_new.3 $(DESTDIR)$(mandir)/man3/BIO_free.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_new.3 $(DESTDIR)$(mandir)/man3/BIO_free_all.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_new.3 $(DESTDIR)$(mandir)/man3/BIO_set.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_new.3 $(DESTDIR)$(mandir)/man3/BIO_vfree.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_push.3 $(DESTDIR)$(mandir)/man3/BIO_pop.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_read.3 $(DESTDIR)$(mandir)/man3/BIO_gets.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_read.3 $(DESTDIR)$(mandir)/man3/BIO_puts.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_read.3 $(DESTDIR)$(mandir)/man3/BIO_write.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_accept.3 $(DESTDIR)$(mandir)/man3/BIO_do_accept.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_accept.3 $(DESTDIR)$(mandir)/man3/BIO_get_accept_port.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_accept.3 $(DESTDIR)$(mandir)/man3/BIO_get_bind_mode.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_accept.3 $(DESTDIR)$(mandir)/man3/BIO_new_accept.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_accept.3 $(DESTDIR)$(mandir)/man3/BIO_set_accept_bios.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_accept.3 $(DESTDIR)$(mandir)/man3/BIO_set_accept_port.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_accept.3 $(DESTDIR)$(mandir)/man3/BIO_set_bind_mode.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_accept.3 $(DESTDIR)$(mandir)/man3/BIO_set_nbio_accept.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_ctrl_get_read_request.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_ctrl_get_write_guarantee.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_ctrl_reset_read_request.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_destroy_bio_pair.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_get_read_request.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_get_write_buf_size.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_get_write_guarantee.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_make_bio_pair.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_new_bio_pair.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_set_write_buf_size.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_bio.3 $(DESTDIR)$(mandir)/man3/BIO_shutdown_wr.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_do_connect.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_get_conn_hostname.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_get_conn_int_port.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_get_conn_ip.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_get_conn_port.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_new_connect.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_set_conn_hostname.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_set_conn_int_port.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_set_conn_ip.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_set_conn_port.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_connect.3 $(DESTDIR)$(mandir)/man3/BIO_set_nbio.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_fd.3 $(DESTDIR)$(mandir)/man3/BIO_get_fd.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_fd.3 $(DESTDIR)$(mandir)/man3/BIO_new_fd.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_fd.3 $(DESTDIR)$(mandir)/man3/BIO_set_fd.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_file.3 $(DESTDIR)$(mandir)/man3/BIO_append_filename.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_file.3 $(DESTDIR)$(mandir)/man3/BIO_get_fp.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_file.3 $(DESTDIR)$(mandir)/man3/BIO_new_file.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_file.3 $(DESTDIR)$(mandir)/man3/BIO_new_fp.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_file.3 $(DESTDIR)$(mandir)/man3/BIO_read_filename.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_file.3 $(DESTDIR)$(mandir)/man3/BIO_rw_filename.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_file.3 $(DESTDIR)$(mandir)/man3/BIO_set_fp.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_file.3 $(DESTDIR)$(mandir)/man3/BIO_write_filename.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_mem.3 $(DESTDIR)$(mandir)/man3/BIO_get_mem_data.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_mem.3 $(DESTDIR)$(mandir)/man3/BIO_get_mem_ptr.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_mem.3 $(DESTDIR)$(mandir)/man3/BIO_new_mem_buf.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_mem.3 $(DESTDIR)$(mandir)/man3/BIO_set_mem_buf.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_mem.3 $(DESTDIR)$(mandir)/man3/BIO_set_mem_eof_return.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_s_socket.3 $(DESTDIR)$(mandir)/man3/BIO_new_socket.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_set_callback.3 $(DESTDIR)$(mandir)/man3/BIO_debug_callback.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_set_callback.3 $(DESTDIR)$(mandir)/man3/BIO_get_callback.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_set_callback.3 $(DESTDIR)$(mandir)/man3/BIO_get_callback_arg.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_set_callback.3 $(DESTDIR)$(mandir)/man3/BIO_set_callback_arg.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_should_retry.3 $(DESTDIR)$(mandir)/man3/BIO_get_retry_BIO.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_should_retry.3 $(DESTDIR)$(mandir)/man3/BIO_get_retry_reason.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_should_retry.3 $(DESTDIR)$(mandir)/man3/BIO_retry_type.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_should_retry.3 $(DESTDIR)$(mandir)/man3/BIO_should_io_special.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_should_retry.3 $(DESTDIR)$(mandir)/man3/BIO_should_read.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_should_retry.3 $(DESTDIR)$(mandir)/man3/BIO_should_write.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_convert.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_convert_ex.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_create_param.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_free.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_get_thread_id.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_invert.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_invert_ex.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_get_flags.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_set_flags.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_set_thread_id.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_thread_id.3 ln -f $(DESTDIR)$(mandir)/man3/BN_BLINDING_new.3 $(DESTDIR)$(mandir)/man3/BN_BLINDING_update.3 ln -f $(DESTDIR)$(mandir)/man3/BN_CTX_new.3 $(DESTDIR)$(mandir)/man3/BN_CTX_free.3 ln -f $(DESTDIR)$(mandir)/man3/BN_CTX_new.3 $(DESTDIR)$(mandir)/man3/BN_CTX_init.3 ln -f $(DESTDIR)$(mandir)/man3/BN_CTX_start.3 $(DESTDIR)$(mandir)/man3/BN_CTX_end.3 ln -f $(DESTDIR)$(mandir)/man3/BN_CTX_start.3 $(DESTDIR)$(mandir)/man3/BN_CTX_get.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_div.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_exp.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_gcd.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_mod.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_mod_exp.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_mod_mul.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_mul.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_sqr.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add.3 $(DESTDIR)$(mandir)/man3/BN_sub.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add_word.3 $(DESTDIR)$(mandir)/man3/BN_div_word.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add_word.3 $(DESTDIR)$(mandir)/man3/BN_mod_word.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add_word.3 $(DESTDIR)$(mandir)/man3/BN_mul_word.3 ln -f $(DESTDIR)$(mandir)/man3/BN_add_word.3 $(DESTDIR)$(mandir)/man3/BN_sub_word.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_bin2bn.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_bn2dec.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_bn2hex.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_bn2mpi.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_dec2bn.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_hex2bn.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_mpi2bn.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_print.3 ln -f $(DESTDIR)$(mandir)/man3/BN_bn2bin.3 $(DESTDIR)$(mandir)/man3/BN_print_fp.3 ln -f $(DESTDIR)$(mandir)/man3/BN_cmp.3 $(DESTDIR)$(mandir)/man3/BN_is_odd.3 ln -f $(DESTDIR)$(mandir)/man3/BN_cmp.3 $(DESTDIR)$(mandir)/man3/BN_is_one.3 ln -f $(DESTDIR)$(mandir)/man3/BN_cmp.3 $(DESTDIR)$(mandir)/man3/BN_is_word.3 ln -f $(DESTDIR)$(mandir)/man3/BN_cmp.3 $(DESTDIR)$(mandir)/man3/BN_is_zero.3 ln -f $(DESTDIR)$(mandir)/man3/BN_cmp.3 $(DESTDIR)$(mandir)/man3/BN_ucmp.3 ln -f $(DESTDIR)$(mandir)/man3/BN_copy.3 $(DESTDIR)$(mandir)/man3/BN_dup.3 ln -f $(DESTDIR)$(mandir)/man3/BN_generate_prime.3 $(DESTDIR)$(mandir)/man3/BN_GENCB_call.3 ln -f $(DESTDIR)$(mandir)/man3/BN_generate_prime.3 $(DESTDIR)$(mandir)/man3/BN_GENCB_set.3 ln -f $(DESTDIR)$(mandir)/man3/BN_generate_prime.3 $(DESTDIR)$(mandir)/man3/BN_GENCB_set_old.3 ln -f $(DESTDIR)$(mandir)/man3/BN_generate_prime.3 $(DESTDIR)$(mandir)/man3/BN_is_prime.3 ln -f $(DESTDIR)$(mandir)/man3/BN_generate_prime.3 $(DESTDIR)$(mandir)/man3/BN_is_prime_ex.3 ln -f $(DESTDIR)$(mandir)/man3/BN_generate_prime.3 $(DESTDIR)$(mandir)/man3/BN_is_prime_fasttest.3 ln -f $(DESTDIR)$(mandir)/man3/BN_generate_prime.3 $(DESTDIR)$(mandir)/man3/BN_is_prime_fasttest_ex.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_montgomery.3 $(DESTDIR)$(mandir)/man3/BN_MONT_CTX_copy.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_montgomery.3 $(DESTDIR)$(mandir)/man3/BN_MONT_CTX_free.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_montgomery.3 $(DESTDIR)$(mandir)/man3/BN_MONT_CTX_init.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_montgomery.3 $(DESTDIR)$(mandir)/man3/BN_MONT_CTX_new.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_montgomery.3 $(DESTDIR)$(mandir)/man3/BN_MONT_CTX_set.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_montgomery.3 $(DESTDIR)$(mandir)/man3/BN_from_montgomery.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_montgomery.3 $(DESTDIR)$(mandir)/man3/BN_to_montgomery.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_reciprocal.3 $(DESTDIR)$(mandir)/man3/BN_RECP_CTX_free.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_reciprocal.3 $(DESTDIR)$(mandir)/man3/BN_RECP_CTX_init.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_reciprocal.3 $(DESTDIR)$(mandir)/man3/BN_RECP_CTX_new.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_reciprocal.3 $(DESTDIR)$(mandir)/man3/BN_RECP_CTX_set.3 ln -f $(DESTDIR)$(mandir)/man3/BN_mod_mul_reciprocal.3 $(DESTDIR)$(mandir)/man3/BN_div_recp.3 ln -f $(DESTDIR)$(mandir)/man3/BN_new.3 $(DESTDIR)$(mandir)/man3/BN_clear.3 ln -f $(DESTDIR)$(mandir)/man3/BN_new.3 $(DESTDIR)$(mandir)/man3/BN_clear_free.3 ln -f $(DESTDIR)$(mandir)/man3/BN_new.3 $(DESTDIR)$(mandir)/man3/BN_free.3 ln -f $(DESTDIR)$(mandir)/man3/BN_new.3 $(DESTDIR)$(mandir)/man3/BN_init.3 ln -f $(DESTDIR)$(mandir)/man3/BN_num_bytes.3 $(DESTDIR)$(mandir)/man3/BN_num_bits.3 ln -f $(DESTDIR)$(mandir)/man3/BN_num_bytes.3 $(DESTDIR)$(mandir)/man3/BN_num_bits_word.3 ln -f $(DESTDIR)$(mandir)/man3/BN_rand.3 $(DESTDIR)$(mandir)/man3/BN_pseudo_rand.3 ln -f $(DESTDIR)$(mandir)/man3/BN_rand.3 $(DESTDIR)$(mandir)/man3/BN_pseudo_rand_range.3 ln -f $(DESTDIR)$(mandir)/man3/BN_rand.3 $(DESTDIR)$(mandir)/man3/BN_rand_range.3 ln -f $(DESTDIR)$(mandir)/man3/BN_set_bit.3 $(DESTDIR)$(mandir)/man3/BN_clear_bit.3 ln -f $(DESTDIR)$(mandir)/man3/BN_set_bit.3 $(DESTDIR)$(mandir)/man3/BN_is_bit_set.3 ln -f $(DESTDIR)$(mandir)/man3/BN_set_bit.3 $(DESTDIR)$(mandir)/man3/BN_lshift.3 ln -f $(DESTDIR)$(mandir)/man3/BN_set_bit.3 $(DESTDIR)$(mandir)/man3/BN_lshift1.3 ln -f $(DESTDIR)$(mandir)/man3/BN_set_bit.3 $(DESTDIR)$(mandir)/man3/BN_mask_bits.3 ln -f $(DESTDIR)$(mandir)/man3/BN_set_bit.3 $(DESTDIR)$(mandir)/man3/BN_rshift.3 ln -f $(DESTDIR)$(mandir)/man3/BN_set_bit.3 $(DESTDIR)$(mandir)/man3/BN_rshift1.3 ln -f $(DESTDIR)$(mandir)/man3/BN_zero.3 $(DESTDIR)$(mandir)/man3/BN_get_word.3 ln -f $(DESTDIR)$(mandir)/man3/BN_zero.3 $(DESTDIR)$(mandir)/man3/BN_one.3 ln -f $(DESTDIR)$(mandir)/man3/BN_zero.3 $(DESTDIR)$(mandir)/man3/BN_set_word.3 ln -f $(DESTDIR)$(mandir)/man3/BN_zero.3 $(DESTDIR)$(mandir)/man3/BN_value_one.3 ln -f $(DESTDIR)$(mandir)/man3/BUF_MEM_new.3 $(DESTDIR)$(mandir)/man3/BUF_MEM_free.3 ln -f $(DESTDIR)$(mandir)/man3/BUF_MEM_new.3 $(DESTDIR)$(mandir)/man3/BUF_MEM_grow.3 ln -f $(DESTDIR)$(mandir)/man3/BUF_MEM_new.3 $(DESTDIR)$(mandir)/man3/BUF_strdup.3 ln -f $(DESTDIR)$(mandir)/man3/CONF_modules_free.3 $(DESTDIR)$(mandir)/man3/CONF_modules_finish.3 ln -f $(DESTDIR)$(mandir)/man3/CONF_modules_free.3 $(DESTDIR)$(mandir)/man3/CONF_modules_unload.3 ln -f $(DESTDIR)$(mandir)/man3/CONF_modules_load_file.3 $(DESTDIR)$(mandir)/man3/CONF_modules_load.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_ex_data.3 $(DESTDIR)$(mandir)/man3/CRYPTO_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_add.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_add_lock.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_destroy_dynlockid.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_get_new_dynlockid.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_lock.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_num_locks.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_r_lock.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_r_unlock.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_set_dynlock_create_callback.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_set_dynlock_destroy_callback.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_set_dynlock_lock_callback.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_set_id_callback.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_w_lock.3 ln -f $(DESTDIR)$(mandir)/man3/CRYPTO_set_locking_callback.3 $(DESTDIR)$(mandir)/man3/CRYPTO_w_unlock.3 ln -f $(DESTDIR)$(mandir)/man3/DH_generate_key.3 $(DESTDIR)$(mandir)/man3/DH_compute_key.3 ln -f $(DESTDIR)$(mandir)/man3/DH_generate_parameters.3 $(DESTDIR)$(mandir)/man3/DH_check.3 ln -f $(DESTDIR)$(mandir)/man3/DH_generate_parameters.3 $(DESTDIR)$(mandir)/man3/DH_generate_parameters_ex.3 ln -f $(DESTDIR)$(mandir)/man3/DH_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/DH_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/DH_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/DH_set_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/DH_new.3 $(DESTDIR)$(mandir)/man3/DH_free.3 ln -f $(DESTDIR)$(mandir)/man3/DH_set_method.3 $(DESTDIR)$(mandir)/man3/DH_OpenSSL.3 ln -f $(DESTDIR)$(mandir)/man3/DH_set_method.3 $(DESTDIR)$(mandir)/man3/DH_get_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/DH_set_method.3 $(DESTDIR)$(mandir)/man3/DH_get_default_openssl_method.3 ln -f $(DESTDIR)$(mandir)/man3/DH_set_method.3 $(DESTDIR)$(mandir)/man3/DH_new_method.3 ln -f $(DESTDIR)$(mandir)/man3/DH_set_method.3 $(DESTDIR)$(mandir)/man3/DH_set_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/DH_set_method.3 $(DESTDIR)$(mandir)/man3/DH_set_default_openssl_method.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_generate_parameters.3 $(DESTDIR)$(mandir)/man3/DSA_generate_parameters_ex.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_new.3 $(DESTDIR)$(mandir)/man3/DSA_free.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_set_method.3 $(DESTDIR)$(mandir)/man3/DSA_OpenSSL.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_set_method.3 $(DESTDIR)$(mandir)/man3/DSA_get_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_set_method.3 $(DESTDIR)$(mandir)/man3/DSA_get_default_openssl_method.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_set_method.3 $(DESTDIR)$(mandir)/man3/DSA_new_method.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_set_method.3 $(DESTDIR)$(mandir)/man3/DSA_set_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_set_method.3 $(DESTDIR)$(mandir)/man3/DSA_set_default_openssl_method.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_sign.3 $(DESTDIR)$(mandir)/man3/DSA_sign_setup.3 ln -f $(DESTDIR)$(mandir)/man3/DSA_sign.3 $(DESTDIR)$(mandir)/man3/DSA_verify.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GFp_simple_method.3 $(DESTDIR)$(mandir)/man3/EC_GF2m_simple_method.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GFp_simple_method.3 $(DESTDIR)$(mandir)/man3/EC_GFp_mont_method.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GFp_simple_method.3 $(DESTDIR)$(mandir)/man3/EC_GFp_nist_method.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GFp_simple_method.3 $(DESTDIR)$(mandir)/man3/EC_GFp_nistp224_method.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GFp_simple_method.3 $(DESTDIR)$(mandir)/man3/EC_GFp_nistp256_method.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GFp_simple_method.3 $(DESTDIR)$(mandir)/man3/EC_GFp_nistp521_method.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GFp_simple_method.3 $(DESTDIR)$(mandir)/man3/EC_METHOD_get_field_type.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_check.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_check_discriminant.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_cmp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_dup.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get0_generator.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get0_seed.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_asn1_flag.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_basis_type.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_cofactor.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_curve_name.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_degree.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_order.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_pentanomial_basis.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_point_conversion_form.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_seed_len.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_trinomial_basis.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_method_of.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_set_asn1_flag.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_set_curve_name.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_set_point_conversion_form.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_set_seed.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_copy.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_set_generator.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_clear_free.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_free.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_curve_GF2m.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_get_curve_GFp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_new_by_curve_name.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_new_curve_GF2m.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_new_curve_GFp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_set_curve_GF2m.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_set_curve_GFp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_GROUP_new.3 $(DESTDIR)$(mandir)/man3/EC_get_builtin_curves.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_check_key.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_clear_flags.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_copy.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_dup.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_free.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_generate_key.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_get0_group.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_get0_private_key.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_get0_public_key.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_get_conv_form.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_get_enc_flags.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_get_flags.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_get_key_method_data.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_insert_key_method_data.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_new_by_curve_name.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_precompute_mult.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_set_asn1_flag.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_set_conv_form.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_set_enc_flags.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_set_flags.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_set_group.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_set_private_key.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_set_public_key.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_set_public_key_affine_coordinates.3 ln -f $(DESTDIR)$(mandir)/man3/EC_KEY_new.3 $(DESTDIR)$(mandir)/man3/EC_KEY_up_ref.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_have_precompute_mult.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_GROUP_precompute_mult.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINT_cmp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINT_dbl.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINT_invert.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINT_is_at_infinity.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINT_is_on_curve.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINT_make_affine.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINT_mul.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINTs_make_affine.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_add.3 $(DESTDIR)$(mandir)/man3/EC_POINTs_mul.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_bn2point.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_clear_free.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_copy.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_dup.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_free.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_get_Jprojective_coordinates_GFp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_get_affine_coordinates_GF2m.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_get_affine_coordinates_GFp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_hex2point.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_method_of.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_oct2point.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_point2bn.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_point2hex.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_point2oct.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_set_Jprojective_coordinates.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_set_affine_coordinates_GF2m.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_set_affine_coordinates_GFp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_set_compressed_coordinates_GF2m.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_set_compressed_coordinates_GFp.3 ln -f $(DESTDIR)$(mandir)/man3/EC_POINT_new.3 $(DESTDIR)$(mandir)/man3/EC_POINT_set_to_infinity.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_GET_LIB.3 $(DESTDIR)$(mandir)/man3/ERR_GET_FUNC.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_GET_LIB.3 $(DESTDIR)$(mandir)/man3/ERR_GET_REASON.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_error_string.3 $(DESTDIR)$(mandir)/man3/ERR_error_string_n.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_error_string.3 $(DESTDIR)$(mandir)/man3/ERR_func_error_string.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_error_string.3 $(DESTDIR)$(mandir)/man3/ERR_lib_error_string.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_error_string.3 $(DESTDIR)$(mandir)/man3/ERR_reason_error_string.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_get_error.3 $(DESTDIR)$(mandir)/man3/ERR_get_error_line.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_get_error.3 $(DESTDIR)$(mandir)/man3/ERR_get_error_line_data.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_get_error.3 $(DESTDIR)$(mandir)/man3/ERR_peek_error.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_get_error.3 $(DESTDIR)$(mandir)/man3/ERR_peek_error_line.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_get_error.3 $(DESTDIR)$(mandir)/man3/ERR_peek_error_line_data.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_load_crypto_strings.3 $(DESTDIR)$(mandir)/man3/ERR_free_strings.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_load_strings.3 $(DESTDIR)$(mandir)/man3/ERR_PACK.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_load_strings.3 $(DESTDIR)$(mandir)/man3/ERR_get_next_error_library.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_print_errors.3 $(DESTDIR)$(mandir)/man3/ERR_print_errors_fp.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_put_error.3 $(DESTDIR)$(mandir)/man3/ERR_add_error_data.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_remove_state.3 $(DESTDIR)$(mandir)/man3/ERR_remove_thread_state.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_set_mark.3 $(DESTDIR)$(mandir)/man3/ERR_pop_to_mark.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_DigestFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_DigestUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_CTX_block_size.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_CTX_copy.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_CTX_md.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_CTX_size.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_CTX_type.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_block_size.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_pkey_type.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_size.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_MD_type.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_dss.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_dss1.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_get_digestbyname.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_get_digestbynid.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_get_digestbyobj.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_md2.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_md5.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_md_null.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_mdc2.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_ripemd160.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_sha.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestInit.3 $(DESTDIR)$(mandir)/man3/EVP_sha1.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestSignInit.3 $(DESTDIR)$(mandir)/man3/EVP_DigestSignUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestSignInit.3 $(DESTDIR)$(mandir)/man3/EVP_DigestSignFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestVerifyInit.3 $(DESTDIR)$(mandir)/man3/EVP_DigestVerifyUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_DigestVerifyInit.3 $(DESTDIR)$(mandir)/man3/EVP_DigestVerifyFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_block_size.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_cipher.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_cleanup.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_ctrl.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_iv_length.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_key_length.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_nid.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_set_key_length.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_CTX_type.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_asn1_to_param.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_block_size.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_iv_length.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_key_length.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_nid.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_param_to_asn1.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CIPHER_type.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CipherFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CipherInit.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_CipherUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_DecryptFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_DecryptInit.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_DecryptUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_EncryptFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_EncryptUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_aes_128_ccm.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_aes_128_gcm.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_aes_192_ccm.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_aes_192_gcm.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_aes_256_ccm.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_aes_256_gcm.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_bf_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_bf_cfb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_bf_ecb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_bf_ofb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_cast5_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_cast5_cfb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_cast5_ecb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_cast5_ofb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_cfb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ecb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ede.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ede3.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ede3_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ede3_cfb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ede3_ofb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ede_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ede_cfb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ede_ofb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_des_ofb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_desx_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_enc_null.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_get_cipherbyname.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_get_cipherbynid.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_get_cipherbyobj.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_idea_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_idea_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_idea_cfb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_idea_ecb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_idea_ofb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc2_40_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc2_64_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc2_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc2_cfb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc2_ecb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc2_ofb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc4.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc4_40.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc5_32_12_16_cbc.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc5_32_12_16_cfb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc5_32_12_16_ecb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_EncryptInit.3 $(DESTDIR)$(mandir)/man3/EVP_rc5_32_12_16_ofb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_OpenInit.3 $(DESTDIR)$(mandir)/man3/EVP_OpenFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_OpenInit.3 $(DESTDIR)$(mandir)/man3/EVP_OpenUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_dh_paramgen_generator.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_dh_paramgen_prime_len.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_dsa_paramgen_bits.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_ec_paramgen_curve_nid.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_rsa_keygen_pubexp.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_rsa_padding.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_rsa_pss_saltlen.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_rsa_rsa_keygen_bits.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_signature_md.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_ctrl_str.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_get_default_digest_nid.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_new.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_new_id.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_new.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_dup.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_new.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_free.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_cmp.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_copy_parameters.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_cmp.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_missing_parameters.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_cmp.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_cmp_parameters.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_new.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_free.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_decrypt.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_decrypt_init.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_derive.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_derive_init.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_derive.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_derive_set_peer.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_get_default_digest.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_get_default_digest_nid.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_encrypt.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_encrypt_init.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen_init.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_paramgen_init.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_paramgen.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_cb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_get_cb.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_get_keygen_info.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_set_app_data.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_keygen.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_CTX_get_app_data.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_print_private.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_print_public.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_print_private.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_print_params.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_sign.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_sign_init.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_verify.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_verify_init.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_verify_recover.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_verify_recover_init.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_assign_DH.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_assign_DSA.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_assign_EC_KEY.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_assign_RSA.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_get1_DH.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_get1_DSA.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_get1_EC_KEY.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_get1_RSA.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_DH.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_DSA.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_EC_KEY.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_PKEY_set1_RSA.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_type.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_SealInit.3 $(DESTDIR)$(mandir)/man3/EVP_SealFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_SealInit.3 $(DESTDIR)$(mandir)/man3/EVP_SealUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_SignInit.3 $(DESTDIR)$(mandir)/man3/EVP_PKEY_size.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_SignInit.3 $(DESTDIR)$(mandir)/man3/EVP_SignFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_SignInit.3 $(DESTDIR)$(mandir)/man3/EVP_SignUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_VerifyInit.3 $(DESTDIR)$(mandir)/man3/EVP_VerifyFinal.3 ln -f $(DESTDIR)$(mandir)/man3/EVP_VerifyInit.3 $(DESTDIR)$(mandir)/man3/EVP_VerifyUpdate.3 ln -f $(DESTDIR)$(mandir)/man3/HMAC.3 $(DESTDIR)$(mandir)/man3/HMAC_Final.3 ln -f $(DESTDIR)$(mandir)/man3/HMAC.3 $(DESTDIR)$(mandir)/man3/HMAC_Init.3 ln -f $(DESTDIR)$(mandir)/man3/HMAC.3 $(DESTDIR)$(mandir)/man3/HMAC_Update.3 ln -f $(DESTDIR)$(mandir)/man3/HMAC.3 $(DESTDIR)$(mandir)/man3/HMAC_cleanup.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD2.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD2_Final.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD2_Init.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD2_Update.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD4.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD4_Final.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD4_Init.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD4_Update.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD5_Final.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD5_Init.3 ln -f $(DESTDIR)$(mandir)/man3/MD5.3 $(DESTDIR)$(mandir)/man3/MD5_Update.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_cleanup.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_cmp.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_create.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_dup.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_ln2nid.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_nid2ln.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_nid2sn.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_obj2nid.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_obj2txt.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_sn2nid.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_txt2nid.3 ln -f $(DESTDIR)$(mandir)/man3/OBJ_nid2obj.3 $(DESTDIR)$(mandir)/man3/OBJ_txt2obj.3 ln -f $(DESTDIR)$(mandir)/man3/OPENSSL_VERSION_NUMBER.3 $(DESTDIR)$(mandir)/man3/SSLeay.3 ln -f $(DESTDIR)$(mandir)/man3/OPENSSL_VERSION_NUMBER.3 $(DESTDIR)$(mandir)/man3/SSLeay_version.3 ln -f $(DESTDIR)$(mandir)/man3/OPENSSL_config.3 $(DESTDIR)$(mandir)/man3/OPENSSL_no_config.3 ln -f $(DESTDIR)$(mandir)/man3/OPENSSL_load_builtin_modules.3 $(DESTDIR)$(mandir)/man3/ASN1_add_oid_module.3 ln -f $(DESTDIR)$(mandir)/man3/OPENSSL_load_builtin_modules.3 $(DESTDIR)$(mandir)/man3/ENGINE_add_conf_module.3 ln -f $(DESTDIR)$(mandir)/man3/OpenSSL_add_all_algorithms.3 $(DESTDIR)$(mandir)/man3/EVP_cleanup.3 ln -f $(DESTDIR)$(mandir)/man3/OpenSSL_add_all_algorithms.3 $(DESTDIR)$(mandir)/man3/OpenSSL_add_all_ciphers.3 ln -f $(DESTDIR)$(mandir)/man3/OpenSSL_add_all_algorithms.3 $(DESTDIR)$(mandir)/man3/OpenSSL_add_all_digests.3 ln -f $(DESTDIR)$(mandir)/man3/PKCS5_PBKDF2_HMAC.3 $(DESTDIR)$(mandir)/man3/PKCS5_PBKDF2_HMAC_SHA1.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_DHparams.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_DSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_DSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_DSAparams.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_NETSCAPE_CERT_SEQUENCE.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_PKCS7.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_PrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_RSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_RSAPublicKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_RSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_X509.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_X509_AUX.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_X509_CRL.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_X509_REQ.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_DHparams.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_DSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_DSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_DSAparams.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_NETSCAPE_CERT_SEQUENCE.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_PKCS7.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_RSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_RSAPublicKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_RSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_X509.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_X509_AUX.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_X509_CRL.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_read_bio_X509_REQ.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_DHparams.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_DSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_DSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_DSAparams.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_NETSCAPE_CERT_SEQUENCE.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_PKCS7.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_PKCS8PrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_PKCS8PrivateKey_nid.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_PrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_RSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_RSAPublicKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_RSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_X509.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_X509_AUX.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_X509_CRL.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_X509_REQ.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_X509_REQ_NEW.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_DHparams.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_DSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_DSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_DSAparams.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_NETSCAPE_CERT_SEQUENCE.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_PKCS7.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_PKCS8PrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_PKCS8PrivateKey_nid.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_PrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_RSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_RSAPublicKey.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_RSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_X509.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_X509_AUX.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_X509_CRL.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_X509_REQ.3 ln -f $(DESTDIR)$(mandir)/man3/PEM_read_bio_PrivateKey.3 $(DESTDIR)$(mandir)/man3/PEM_write_bio_X509_REQ_NEW.3 ln -f $(DESTDIR)$(mandir)/man3/PKCS7_verify.3 $(DESTDIR)$(mandir)/man3/PKCS7_get0_signers.3 ln -f $(DESTDIR)$(mandir)/man3/RAND_add.3 $(DESTDIR)$(mandir)/man3/RAND_seed.3 ln -f $(DESTDIR)$(mandir)/man3/RAND_add.3 $(DESTDIR)$(mandir)/man3/RAND_status.3 ln -f $(DESTDIR)$(mandir)/man3/RAND_bytes.3 $(DESTDIR)$(mandir)/man3/RAND_pseudo_bytes.3 ln -f $(DESTDIR)$(mandir)/man3/RAND_load_file.3 $(DESTDIR)$(mandir)/man3/RAND_file_name.3 ln -f $(DESTDIR)$(mandir)/man3/RAND_load_file.3 $(DESTDIR)$(mandir)/man3/RAND_write_file.3 ln -f $(DESTDIR)$(mandir)/man3/RAND_set_rand_method.3 $(DESTDIR)$(mandir)/man3/RAND_SSLeay.3 ln -f $(DESTDIR)$(mandir)/man3/RAND_set_rand_method.3 $(DESTDIR)$(mandir)/man3/RAND_get_rand_method.3 ln -f $(DESTDIR)$(mandir)/man3/RC4.3 $(DESTDIR)$(mandir)/man3/RC4_set_key.3 ln -f $(DESTDIR)$(mandir)/man3/RIPEMD160.3 $(DESTDIR)$(mandir)/man3/RIPEMD160_Final.3 ln -f $(DESTDIR)$(mandir)/man3/RIPEMD160.3 $(DESTDIR)$(mandir)/man3/RIPEMD160_Init.3 ln -f $(DESTDIR)$(mandir)/man3/RIPEMD160.3 $(DESTDIR)$(mandir)/man3/RIPEMD160_Update.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_blinding_on.3 $(DESTDIR)$(mandir)/man3/RSA_blinding_off.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_generate_key.3 $(DESTDIR)$(mandir)/man3/RSA_generate_key_ex.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/RSA_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/RSA_set_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_new.3 $(DESTDIR)$(mandir)/man3/RSA_free.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_OAEP.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_2.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_add_SSLv23.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_add_none.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_check_PKCS1_OAEP.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_check_PKCS1_type_1.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_check_PKCS1_type_2.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_check_SSLv23.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_padding_add_PKCS1_type_1.3 $(DESTDIR)$(mandir)/man3/RSA_padding_check_none.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_print.3 $(DESTDIR)$(mandir)/man3/DHparams_print.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_print.3 $(DESTDIR)$(mandir)/man3/DHparams_print_fp.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_print.3 $(DESTDIR)$(mandir)/man3/DSA_print.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_print.3 $(DESTDIR)$(mandir)/man3/DSA_print_fp.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_print.3 $(DESTDIR)$(mandir)/man3/DSAparams_print.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_print.3 $(DESTDIR)$(mandir)/man3/DSAparams_print_fp.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_print.3 $(DESTDIR)$(mandir)/man3/RSA_print_fp.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_private_encrypt.3 $(DESTDIR)$(mandir)/man3/RSA_public_decrypt.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_public_encrypt.3 $(DESTDIR)$(mandir)/man3/RSA_private_decrypt.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_PKCS1_RSAref.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_PKCS1_SSLeay.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_flags.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_get_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_get_default_openssl_method.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_get_method.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_new_method.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_null_method.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_set_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_set_method.3 $(DESTDIR)$(mandir)/man3/RSA_set_default_openssl_method.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_sign.3 $(DESTDIR)$(mandir)/man3/RSA_verify.3 ln -f $(DESTDIR)$(mandir)/man3/RSA_sign_ASN1_OCTET_STRING.3 $(DESTDIR)$(mandir)/man3/RSA_verify_ASN1_OCTET_STRING.3 ln -f $(DESTDIR)$(mandir)/man3/SHA1.3 $(DESTDIR)$(mandir)/man3/SHA1_Final.3 ln -f $(DESTDIR)$(mandir)/man3/SHA1.3 $(DESTDIR)$(mandir)/man3/SHA1_Init.3 ln -f $(DESTDIR)$(mandir)/man3/SHA1.3 $(DESTDIR)$(mandir)/man3/SHA1_Update.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_get_object.3 $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_create_by_NID.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_get_object.3 $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_create_by_OBJ.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_get_object.3 $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_create_by_txt.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_get_object.3 $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_get_data.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_get_object.3 $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_set_data.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_get_object.3 $(DESTDIR)$(mandir)/man3/X509_NAME_ENTRY_set_object.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_add_entry_by_txt.3 $(DESTDIR)$(mandir)/man3/X509_NAME_add_entry.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_add_entry_by_txt.3 $(DESTDIR)$(mandir)/man3/X509_NAME_add_entry_by_NID.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_add_entry_by_txt.3 $(DESTDIR)$(mandir)/man3/X509_NAME_add_entry_by_OBJ.3 ln -f $(DESTDIR)$(mandir)/man3/X509_NAME_add_entry_by_txt.3 $(DESTDIR)$(mandir)/man3/X509_NAME_delete_entry.3 ln -f $(DESTDIR)$(mandir)/man3/X509_new.3 $(DESTDIR)$(mandir)/man3/X509_free.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_error.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get1_chain.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_error.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_current_cert.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_error.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_error_depth.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_error.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_error.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_error.3 $(DESTDIR)$(mandir)/man3/X509_verify_cert_error_string.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_cleanup.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_free.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get0_param.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_init.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set0_crls.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set0_param.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_cert.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_chain.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_default.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_new.3 $(DESTDIR)$(mandir)/man3/X509_STORE_CTX_trusted_stack.3 ln -f $(DESTDIR)$(mandir)/man3/X509_STORE_set_verify_cb_func.3 $(DESTDIR)$(mandir)/man3/X509_STORE_set_verify_cb.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_add0_policy.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_clear_flags.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_get_depth.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_get_flags.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set1_policies.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_depth.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_purpose.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_time.3 ln -f $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_flags.3 $(DESTDIR)$(mandir)/man3/X509_VERIFY_PARAM_set_trust.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_add_words.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_check_top.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_cmp_words.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_div_words.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_dump.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_expand.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_expand2.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_fix_top.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_add_words.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_comba4.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_comba8.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_high.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_low_normal.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_low_recursive.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_normal.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_part_recursive.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_recursive.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_mul_words.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_print.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_set_high.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_set_low.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_set_max.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_sqr_comba4.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_sqr_comba8.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_sqr_normal.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_sqr_recursive.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_sqr_words.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_sub_words.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/bn_wexpand.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/mul.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/mul_add.3 ln -f $(DESTDIR)$(mandir)/man3/bn_internal.3 $(DESTDIR)$(mandir)/man3/sqr.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_ASN1_OBJECT.3 $(DESTDIR)$(mandir)/man3/i2d_ASN1_OBJECT.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DHparams.3 $(DESTDIR)$(mandir)/man3/i2d_DHparams.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/d2i_DSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/d2i_DSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/d2i_DSA_SIG.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/d2i_DSAparams.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/i2d_DSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/i2d_DSAPublicKey.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/i2d_DSA_PUBKEY.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/i2d_DSA_SIG.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_DSAPublicKey.3 $(DESTDIR)$(mandir)/man3/i2d_DSAparams.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters.3 $(DESTDIR)$(mandir)/man3/ECPKParameters_print.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters.3 $(DESTDIR)$(mandir)/man3/ECPKParameters_print_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters.3 $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters.3 $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters.3 $(DESTDIR)$(mandir)/man3/i2d_ECPKParameters.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters.3 $(DESTDIR)$(mandir)/man3/i2d_ECPKParameters_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_ECPKParameters.3 $(DESTDIR)$(mandir)/man3/i2d_ECPKParameters_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_PKCS8PrivateKey.3 $(DESTDIR)$(mandir)/man3/d2i_PKCS8PrivateKey_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_PKCS8PrivateKey.3 $(DESTDIR)$(mandir)/man3/d2i_PKCS8PrivateKey_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_PKCS8PrivateKey.3 $(DESTDIR)$(mandir)/man3/i2d_PKCS8PrivateKey_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_PKCS8PrivateKey.3 $(DESTDIR)$(mandir)/man3/i2d_PKCS8PrivateKey_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_PKCS8PrivateKey.3 $(DESTDIR)$(mandir)/man3/i2d_PKCS8PrivateKey_nid_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_PKCS8PrivateKey.3 $(DESTDIR)$(mandir)/man3/i2d_PKCS8PrivateKey_nid_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_RSAPublicKey.3 $(DESTDIR)$(mandir)/man3/d2i_Netscape_RSA.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_RSAPublicKey.3 $(DESTDIR)$(mandir)/man3/d2i_RSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_RSAPublicKey.3 $(DESTDIR)$(mandir)/man3/i2d_Netscape_RSA.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_RSAPublicKey.3 $(DESTDIR)$(mandir)/man3/i2d_RSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_RSAPublicKey.3 $(DESTDIR)$(mandir)/man3/i2d_RSAPublicKey.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509.3 $(DESTDIR)$(mandir)/man3/d2i_X509_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509.3 $(DESTDIR)$(mandir)/man3/d2i_X509_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509.3 $(DESTDIR)$(mandir)/man3/i2d_X509.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509.3 $(DESTDIR)$(mandir)/man3/i2d_X509_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509.3 $(DESTDIR)$(mandir)/man3/i2d_X509_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_ALGOR.3 $(DESTDIR)$(mandir)/man3/i2d_X509_ALGOR.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_CRL.3 $(DESTDIR)$(mandir)/man3/d2i_X509_CRL_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_CRL.3 $(DESTDIR)$(mandir)/man3/d2i_X509_CRL_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_CRL.3 $(DESTDIR)$(mandir)/man3/i2d_X509_CRL.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_CRL.3 $(DESTDIR)$(mandir)/man3/i2d_X509_CRL_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_CRL.3 $(DESTDIR)$(mandir)/man3/i2d_X509_CRL_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_NAME.3 $(DESTDIR)$(mandir)/man3/i2d_X509_NAME.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_REQ.3 $(DESTDIR)$(mandir)/man3/d2i_X509_REQ_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_REQ.3 $(DESTDIR)$(mandir)/man3/d2i_X509_REQ_fp.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_REQ.3 $(DESTDIR)$(mandir)/man3/i2d_X509_REQ.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_REQ.3 $(DESTDIR)$(mandir)/man3/i2d_X509_REQ_bio.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_X509_REQ.3 $(DESTDIR)$(mandir)/man3/i2d_X509_REQ_fp.3 ln -f $(DESTDIR)$(mandir)/man3/dsa.3 $(DESTDIR)$(mandir)/man3/DSA_SIG_free.3 ln -f $(DESTDIR)$(mandir)/man3/dsa.3 $(DESTDIR)$(mandir)/man3/DSA_do_verify.3 ln -f $(DESTDIR)$(mandir)/man3/dsa.3 $(DESTDIR)$(mandir)/man3/DSA_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/dsa.3 $(DESTDIR)$(mandir)/man3/DSA_set_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_OpenSSL.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_SIG_free.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_SIG_new.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_do_sign.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_do_sign_ex.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_do_verify.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_get_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_get_ex_new_index.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_set_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_set_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_set_method.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_sign.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_sign_ex.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_sign_setup.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/ECDSA_verify.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/d2i_ECDSA_SIG.3 ln -f $(DESTDIR)$(mandir)/man3/ecdsa.3 $(DESTDIR)$(mandir)/man3/i2d_ECDSA_SIG.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_add.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_by_id.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_finish.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_get_first.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_get_last.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_get_next.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_get_prev.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_init.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_load_builtin_engines.3 ln -f $(DESTDIR)$(mandir)/man3/engine.3 $(DESTDIR)$(mandir)/man3/ENGINE_remove.3 ln -f $(DESTDIR)$(mandir)/man3/lh_stats.3 $(DESTDIR)$(mandir)/man3/lh_node_stats.3 ln -f $(DESTDIR)$(mandir)/man3/lh_stats.3 $(DESTDIR)$(mandir)/man3/lh_node_stats_bio.3 ln -f $(DESTDIR)$(mandir)/man3/lh_stats.3 $(DESTDIR)$(mandir)/man3/lh_node_usage_stats.3 ln -f $(DESTDIR)$(mandir)/man3/lh_stats.3 $(DESTDIR)$(mandir)/man3/lh_node_usage_stats_bio.3 ln -f $(DESTDIR)$(mandir)/man3/lh_stats.3 $(DESTDIR)$(mandir)/man3/lh_stats_bio.3 ln -f $(DESTDIR)$(mandir)/man3/lhash.3 $(DESTDIR)$(mandir)/man3/lh_delete.3 ln -f $(DESTDIR)$(mandir)/man3/lhash.3 $(DESTDIR)$(mandir)/man3/lh_doall.3 ln -f $(DESTDIR)$(mandir)/man3/lhash.3 $(DESTDIR)$(mandir)/man3/lh_doall_arg.3 ln -f $(DESTDIR)$(mandir)/man3/lhash.3 $(DESTDIR)$(mandir)/man3/lh_error.3 ln -f $(DESTDIR)$(mandir)/man3/lhash.3 $(DESTDIR)$(mandir)/man3/lh_free.3 ln -f $(DESTDIR)$(mandir)/man3/lhash.3 $(DESTDIR)$(mandir)/man3/lh_insert.3 ln -f $(DESTDIR)$(mandir)/man3/lhash.3 $(DESTDIR)$(mandir)/man3/lh_new.3 ln -f $(DESTDIR)$(mandir)/man3/lhash.3 $(DESTDIR)$(mandir)/man3/lh_retrieve.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_OpenSSL.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_add_error_string.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_add_info_string.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_add_input_boolean.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_add_input_string.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_add_user_data.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_add_verify_string.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_construct_prompt.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_ctrl.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_dup_error_string.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_dup_info_string.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_dup_input_boolean.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_dup_input_string.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_dup_verify_string.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_free.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_get0_result.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_get0_user_data.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_get_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_get_method.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_new.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_new_method.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_process.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_set_default_method.3 ln -f $(DESTDIR)$(mandir)/man3/ui.3 $(DESTDIR)$(mandir)/man3/UI_set_method.3 ln -f $(DESTDIR)$(mandir)/man3/ui_compat.3 $(DESTDIR)$(mandir)/man3/des_read_2passwords.3 ln -f $(DESTDIR)$(mandir)/man3/ui_compat.3 $(DESTDIR)$(mandir)/man3/des_read_password.3 ln -f $(DESTDIR)$(mandir)/man3/ui_compat.3 $(DESTDIR)$(mandir)/man3/des_read_pw.3 ln -f $(DESTDIR)$(mandir)/man3/ui_compat.3 $(DESTDIR)$(mandir)/man3/des_read_pw_string.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_do_handshake.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_get_num_renegotiates.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_get_ssl.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_new_buffer_ssl_connect.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_new_ssl.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_new_ssl_connect.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_set_ssl.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_set_ssl_mode.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_set_ssl_renegotiate_bytes.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_set_ssl_renegotiate_timeout.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_ssl_copy_session_id.3 ln -f $(DESTDIR)$(mandir)/man3/BIO_f_ssl.3 $(DESTDIR)$(mandir)/man3/BIO_ssl_shutdown.3 ln -f $(DESTDIR)$(mandir)/man3/ERR_load_crypto_strings.3 $(DESTDIR)$(mandir)/man3/SSL_load_error_strings.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CIPHER_get_name.3 $(DESTDIR)$(mandir)/man3/SSL_CIPHER_description.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CIPHER_get_name.3 $(DESTDIR)$(mandir)/man3/SSL_CIPHER_get_bits.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CIPHER_get_name.3 $(DESTDIR)$(mandir)/man3/SSL_CIPHER_get_version.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_add_session.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_remove_session.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_add_session.3 $(DESTDIR)$(mandir)/man3/SSL_add_session.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_add_session.3 $(DESTDIR)$(mandir)/man3/SSL_remove_session.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_callback_ctrl.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/SSL_callback_ctrl.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_ctrl.3 $(DESTDIR)$(mandir)/man3/SSL_ctrl.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_flush_sessions.3 $(DESTDIR)$(mandir)/man3/SSL_flush_sessions.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_set_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_get_verify_mode.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_verify_callback.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_get_verify_mode.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_verify_depth.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_get_verify_mode.3 $(DESTDIR)$(mandir)/man3/SSL_get_verify_callback.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_get_verify_mode.3 $(DESTDIR)$(mandir)/man3/SSL_get_verify_depth.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_get_verify_mode.3 $(DESTDIR)$(mandir)/man3/SSL_get_verify_mode.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/SSLv23_client_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/SSLv23_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/SSLv23_server_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/SSLv3_client_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/SSLv3_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/SSLv3_server_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/TLSv1_1_client_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/TLSv1_1_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/TLSv1_1_server_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/TLSv1_client_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/TLSv1_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_new.3 $(DESTDIR)$(mandir)/man3/TLSv1_server_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_accept.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_accept_good.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_accept_renegotiate.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_cache_full.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_cb_hits.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_connect.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_connect_good.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_connect_renegotiate.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_hits.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_misses.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_number.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_timeouts.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_set_cache_size.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_get_cache_size.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_set_get_cb.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_get_get_cb.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_set_get_cb.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_get_new_cb.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_set_get_cb.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_get_remove_cb.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_set_get_cb.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_set_new_cb.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_set_get_cb.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_sess_set_remove.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_cert_store.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_cert_store.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_cipher_list.3 $(DESTDIR)$(mandir)/man3/SSL_set_cipher_list.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_client_CA_list.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_add_client_CA.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_client_CA_list.3 $(DESTDIR)$(mandir)/man3/SSL_add_client_CA.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_client_CA_list.3 $(DESTDIR)$(mandir)/man3/SSL_set_client_CA_list.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_default_passwd_cb.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_set_default_passwd_cb_userdata.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_max_cert_list.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_max_cert_list.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_max_cert_list.3 $(DESTDIR)$(mandir)/man3/SSL_get_max_cert_list.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_max_cert_list.3 $(DESTDIR)$(mandir)/man3/SSL_set_max_cert_list.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_mode.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_mode.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_mode.3 $(DESTDIR)$(mandir)/man3/SSL_get_mode.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_mode.3 $(DESTDIR)$(mandir)/man3/SSL_set_mode.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_msg_callback.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_set_msg_callback_arg.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_msg_callback.3 $(DESTDIR)$(mandir)/man3/SSL_set_msg_callback.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_msg_callback.3 $(DESTDIR)$(mandir)/man3/SSL_set_msg_callback_arg.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_options.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_options.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_options.3 $(DESTDIR)$(mandir)/man3/SSL_get_options.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_options.3 $(DESTDIR)$(mandir)/man3/SSL_set_options.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_psk_client_callback.3 $(DESTDIR)$(mandir)/man3/SSL_set_psk_client_callback.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_quiet_shutdown.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_quiet_shutdown.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_quiet_shutdown.3 $(DESTDIR)$(mandir)/man3/SSL_get_quiet_shutdown.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_quiet_shutdown.3 $(DESTDIR)$(mandir)/man3/SSL_set_quiet_shutdown.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_session_cache_mode.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_session_cache_mode.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_session_id_context.3 $(DESTDIR)$(mandir)/man3/SSL_set_session_id_context.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_ssl_version.3 $(DESTDIR)$(mandir)/man3/SSL_get_ssl_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_ssl_version.3 $(DESTDIR)$(mandir)/man3/SSL_set_ssl_method.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_timeout.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_timeout.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_dh_callback.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_dh.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_dh_callback.3 $(DESTDIR)$(mandir)/man3/SSL_set_tmp_dh.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_dh_callback.3 $(DESTDIR)$(mandir)/man3/SSL_set_tmp_dh_callback.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_rsa_callback.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_need_tmp_rsa.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_rsa_callback.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_rsa.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_rsa_callback.3 $(DESTDIR)$(mandir)/man3/SSL_need_tmp_rsa.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_rsa_callback.3 $(DESTDIR)$(mandir)/man3/SSL_set_tmp_rsa.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_tmp_rsa_callback.3 $(DESTDIR)$(mandir)/man3/SSL_set_tmp_rsa_callback.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_verify.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_set_verify_depth.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_verify.3 $(DESTDIR)$(mandir)/man3/SSL_set_verify.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_set_verify.3 $(DESTDIR)$(mandir)/man3/SSL_set_verify_depth.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_check_private_key.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_PrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_PrivateKey_ASN1.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_PrivateKey_file.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_RSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_RSAPrivateKey_ASN1.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_RSAPrivateKey_file.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate_ASN1.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate_chain_file.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate_file.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_check_private_key.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_PrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_PrivateKey_ASN1.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_PrivateKey_file.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_RSAPrivateKey.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_RSAPrivateKey_ASN1.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_RSAPrivateKey_file.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_certificate.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_certificate_ASN1.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_certificate.3 $(DESTDIR)$(mandir)/man3/SSL_use_certificate_file.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_psk_identity_hint.3 $(DESTDIR)$(mandir)/man3/SSL_use_psk_identity_hint.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_psk_identity_hint.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_set_psk_server_callback.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_CTX_use_psk_identity_hint.3 $(DESTDIR)$(mandir)/man3/SSL_set_psk_server_callback.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/SSL_SESSION_set_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_time.3 $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_timeout.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_time.3 $(DESTDIR)$(mandir)/man3/SSL_SESSION_set_time.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_time.3 $(DESTDIR)$(mandir)/man3/SSL_SESSION_set_timeout.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_time.3 $(DESTDIR)$(mandir)/man3/SSL_get_time.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_time.3 $(DESTDIR)$(mandir)/man3/SSL_get_timeout.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_time.3 $(DESTDIR)$(mandir)/man3/SSL_set_time.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_SESSION_get_time.3 $(DESTDIR)$(mandir)/man3/SSL_set_timeout.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_alert_type_string.3 $(DESTDIR)$(mandir)/man3/SSL_alert_desc_string.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_alert_type_string.3 $(DESTDIR)$(mandir)/man3/SSL_alert_desc_string_long.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_alert_type_string.3 $(DESTDIR)$(mandir)/man3/SSL_alert_type_string_long.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_ciphers.3 $(DESTDIR)$(mandir)/man3/SSL_get_cipher_list.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_client_CA_list.3 $(DESTDIR)$(mandir)/man3/SSL_CTX_get_client_CA_list.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_current_cipher.3 $(DESTDIR)$(mandir)/man3/SSL_get_cipher.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_current_cipher.3 $(DESTDIR)$(mandir)/man3/SSL_get_cipher_bits.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_current_cipher.3 $(DESTDIR)$(mandir)/man3/SSL_get_cipher_name.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_current_cipher.3 $(DESTDIR)$(mandir)/man3/SSL_get_cipher_version.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/SSL_get_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_ex_new_index.3 $(DESTDIR)$(mandir)/man3/SSL_set_ex_data.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_fd.3 $(DESTDIR)$(mandir)/man3/SSL_get_rfd.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_fd.3 $(DESTDIR)$(mandir)/man3/SSL_get_wfd.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_psk_identity.3 $(DESTDIR)$(mandir)/man3/SSL_get_psk_identity_hint.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_rbio.3 $(DESTDIR)$(mandir)/man3/SSL_get_wbio.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_session.3 $(DESTDIR)$(mandir)/man3/SSL_get0_session.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_get_session.3 $(DESTDIR)$(mandir)/man3/SSL_get1_session.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_library_init.3 $(DESTDIR)$(mandir)/man3/OpenSSL_add_ssl_algorithms.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_library_init.3 $(DESTDIR)$(mandir)/man3/SSLeay_add_ssl_algorithms.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_rstate_string.3 $(DESTDIR)$(mandir)/man3/SSL_rstate_string_long.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_set_connect_state.3 $(DESTDIR)$(mandir)/man3/SSL_set_accept_state.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_set_fd.3 $(DESTDIR)$(mandir)/man3/SSL_set_rfd.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_set_fd.3 $(DESTDIR)$(mandir)/man3/SSL_set_wfd.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_set_shutdown.3 $(DESTDIR)$(mandir)/man3/SSL_get_shutdown.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_state_string.3 $(DESTDIR)$(mandir)/man3/SSL_state_string_long.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_want.3 $(DESTDIR)$(mandir)/man3/SSL_want_nothing.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_want.3 $(DESTDIR)$(mandir)/man3/SSL_want_read.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_want.3 $(DESTDIR)$(mandir)/man3/SSL_want_write.3 ln -f $(DESTDIR)$(mandir)/man3/SSL_want.3 $(DESTDIR)$(mandir)/man3/SSL_want_x509_lookup.3 ln -f $(DESTDIR)$(mandir)/man3/d2i_SSL_SESSION.3 $(DESTDIR)$(mandir)/man3/i2d_SSL_SESSION.3 # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: deps/libressl-pnacl-sys-2.1.6/libressl/man/PKCS5_PBKDF2_HMAC.30000644000175000017500000001452412360020722020204 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PKCS5_PBKDF2_HMAC 3" .TH PKCS5_PBKDF2_HMAC 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PKCS5_PBKDF2_HMAC, PKCS5_PBKDF2_HMAC_SHA1 \- password based derivation routines with salt and iteration count .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int PKCS5_PBKDF2_HMAC(const char *pass, int passlen, \& const unsigned char *salt, int saltlen, int iter, \& const EVP_MD *digest, \& int keylen, unsigned char *out); .Ve .PP int \s-1PKCS5_PBKDF2_HMAC_SHA1\s0(const char *pass, int passlen, const unsigned char *salt, int saltlen, int iter, int keylen, unsigned char *out); .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\s-1\fIPKCS5_PBKDF2_HMAC\s0()\fR derives a key from a password using a salt and iteration count as specified in \s-1RFC 2898.\s0 .PP \&\fBpass\fR is the password used in the derivation of length \fBpasslen\fR. \fBpass\fR is an optional parameter and can be \s-1NULL.\s0 If \fBpasslen\fR is \-1, then the function will calculate the length of \fBpass\fR using \fIstrlen()\fR. .PP \&\fBsalt\fR is the salt used in the derivation of length \fBsaltlen\fR. If the \&\fBsalt\fR is \s-1NULL,\s0 then \fBsaltlen\fR must be 0. The function will not attempt to calculate the length of the \fBsalt\fR because it is not assumed to be \s-1NULL\s0 terminated. .PP \&\fBiter\fR is the iteration count and its value should be greater than or equal to 1. \s-1RFC 2898\s0 suggests an iteration count of at least 1000. Any \&\fBiter\fR less than 1 is treated as a single iteration. .PP \&\fBdigest\fR is the message digest function used in the derivation. Values include any of the EVP_* message digests. \s-1\fIPKCS5_PBKDF2_HMAC_SHA1\s0()\fR calls \&\s-1\fIPKCS5_PBKDF2_HMAC\s0()\fR with \fIEVP_sha1()\fR. .PP The derived key will be written to \fBout\fR. The size of the \fBout\fR buffer is specified via \fBkeylen\fR. .SH "NOTES" .IX Header "NOTES" A typical application of this function is to derive keying material for an encryption algorithm from a password in the \fBpass\fR, a salt in \fBsalt\fR, and an iteration count. .PP Increasing the \fBiter\fR parameter slows down the algorithm which makes it harder for an attacker to peform a brute force attack using a large number of candidate passwords. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\s-1\fIPKCS5_PBKDF2_HMAC\s0()\fR and \s-1\fIPBKCS5_PBKDF2_HMAC_SHA1\s0()\fR return 1 on success or 0 on error. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIevp\fR\|(3), \fIrand\fR\|(3), \&\fIEVP_BytesToKey\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/DSA_generate_key.30000644000175000017500000001122312360020715020723 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DSA_generate_key 3" .TH DSA_generate_key 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DSA_generate_key \- generate DSA key pair .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int DSA_generate_key(DSA *a); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIDSA_generate_key()\fR expects \fBa\fR to contain \s-1DSA\s0 parameters. It generates a new key pair and stores it in \fBa\->pub_key\fR and \fBa\->priv_key\fR. .SH "RETURN VALUE" .IX Header "RETURN VALUE" \&\fIDSA_generate_key()\fR returns 1 on success, 0 otherwise. The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdsa\fR\|(3), \fIERR_get_error\fR\|(3), \fIrand\fR\|(3), \&\fIDSA_generate_parameters\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIDSA_generate_key()\fR is available since SSLeay 0.8. deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_PKEY_CTX_new.30000644000175000017500000001327312360020720020446 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_PKEY_CTX_new 3" .TH EVP_PKEY_CTX_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_PKEY_CTX_new, EVP_PKEY_CTX_new_id, EVP_PKEY_CTX_dup, EVP_PKEY_CTX_free \- public key algorithm context functions. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e); \& EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e); \& EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *ctx); \& void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fIEVP_PKEY_CTX_new()\fR function allocates public key algorithm context using the algorithm specified in \fBpkey\fR and \s-1ENGINE \s0\fBe\fR. .PP The \fIEVP_PKEY_CTX_new_id()\fR function allocates public key algorithm context using the algorithm specified by \fBid\fR and \s-1ENGINE \s0\fBe\fR. It is normally used when no \fB\s-1EVP_PKEY\s0\fR structure is associated with the operations, for example during parameter generation of key genration for some algorithms. .PP \&\fIEVP_PKEY_CTX_dup()\fR duplicates the context \fBctx\fR. .PP \&\fIEVP_PKEY_CTX_free()\fR frees up the context \fBctx\fR. .SH "NOTES" .IX Header "NOTES" The \fB\s-1EVP_PKEY_CTX\s0\fR structure is an opaque public key algorithm context used by the OpenSSL high level public key \s-1API.\s0 Contexts \fB\s-1MUST NOT\s0\fR be shared between threads: that is it is not permissible to use the same context simultaneously in two threads. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_PKEY_CTX_new()\fR, \fIEVP_PKEY_CTX_new_id()\fR, \fIEVP_PKEY_CTX_dup()\fR returns either the newly allocated \fB\s-1EVP_PKEY_CTX\s0\fR structure of \fB\s-1NULL\s0\fR if an error occurred. .PP \&\fIEVP_PKEY_CTX_free()\fR does not return a value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_PKEY_new\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" These functions were first added to OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_get_client_CA_list.30000644000175000017500000001267612360020735022045 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_get_client_CA_list 3" .TH SSL_get_client_CA_list 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_get_client_CA_list, SSL_CTX_get_client_CA_list \- get list of client CAs .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s); \& STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_get_client_CA_list()\fR returns the list of client CAs explicitly set for \&\fBctx\fR using \fISSL_CTX_set_client_CA_list\fR\|(3). .PP \&\fISSL_get_client_CA_list()\fR returns the list of client CAs explicitly set for \fBssl\fR using \fISSL_set_client_CA_list()\fR or \fBssl\fR's \s-1SSL_CTX\s0 object with \&\fISSL_CTX_set_client_CA_list\fR\|(3), when in server mode. In client mode, SSL_get_client_CA_list returns the list of client CAs sent from the server, if any. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_set_client_CA_list()\fR and \fISSL_set_client_CA_list()\fR do not return diagnostic information. .PP \&\fISSL_CTX_add_client_CA()\fR and \fISSL_add_client_CA()\fR have the following return values: .IP "\s-1STACK_OF\s0(X509_NAMES)" 4 .IX Item "STACK_OF(X509_NAMES)" List of \s-1CA\s0 names explicitly set (for \fBctx\fR or in server mode) or send by the server (client mode). .IP "\s-1NULL\s0" 4 .IX Item "NULL" No client \s-1CA\s0 list was explicitly set (for \fBctx\fR or in server mode) or the server did not send a list of CAs (client mode). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \&\fISSL_CTX_set_client_CA_list\fR\|(3), \&\fISSL_CTX_set_client_cert_cb\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_bn2bin.30000644000175000017500000001747012360020711017331 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_bn2bin 3" .TH BN_bn2bin 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_bn2bin, BN_bin2bn, BN_bn2hex, BN_bn2dec, BN_hex2bn, BN_dec2bn, BN_print, BN_print_fp, BN_bn2mpi, BN_mpi2bn \- format conversions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int BN_bn2bin(const BIGNUM *a, unsigned char *to); \& BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret); \& \& char *BN_bn2hex(const BIGNUM *a); \& char *BN_bn2dec(const BIGNUM *a); \& int BN_hex2bn(BIGNUM **a, const char *str); \& int BN_dec2bn(BIGNUM **a, const char *str); \& \& int BN_print(BIO *fp, const BIGNUM *a); \& int BN_print_fp(FILE *fp, const BIGNUM *a); \& \& int BN_bn2mpi(const BIGNUM *a, unsigned char *to); \& BIGNUM *BN_mpi2bn(unsigned char *s, int len, BIGNUM *ret); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBN_bn2bin()\fR converts the absolute value of \fBa\fR into big-endian form and stores it at \fBto\fR. \fBto\fR must point to BN_num_bytes(\fBa\fR) bytes of memory. .PP \&\fIBN_bin2bn()\fR converts the positive integer in big-endian form of length \&\fBlen\fR at \fBs\fR into a \fB\s-1BIGNUM\s0\fR and places it in \fBret\fR. If \fBret\fR is \&\s-1NULL,\s0 a new \fB\s-1BIGNUM\s0\fR is created. .PP \&\fIBN_bn2hex()\fR and \fIBN_bn2dec()\fR return printable strings containing the hexadecimal and decimal encoding of \fBa\fR respectively. For negative numbers, the string is prefaced with a leading '\-'. The string must be freed later using \fIOPENSSL_free()\fR. .PP \&\fIBN_hex2bn()\fR converts the string \fBstr\fR containing a hexadecimal number to a \fB\s-1BIGNUM\s0\fR and stores it in **\fBbn\fR. If *\fBbn\fR is \s-1NULL,\s0 a new \&\fB\s-1BIGNUM\s0\fR is created. If \fBbn\fR is \s-1NULL,\s0 it only computes the number's length in hexadecimal digits. If the string starts with '\-', the number is negative. \fIBN_dec2bn()\fR is the same using the decimal system. .PP \&\fIBN_print()\fR and \fIBN_print_fp()\fR write the hexadecimal encoding of \fBa\fR, with a leading '\-' for negative numbers, to the \fB\s-1BIO\s0\fR or \fB\s-1FILE\s0\fR \&\fBfp\fR. .PP \&\fIBN_bn2mpi()\fR and \fIBN_mpi2bn()\fR convert \fB\s-1BIGNUM\s0\fRs from and to a format that consists of the number's length in bytes represented as a 4\-byte big-endian number, and the number itself in big-endian format, where the most significant bit signals a negative number (the representation of numbers with the \s-1MSB\s0 set is prefixed with null byte). .PP \&\fIBN_bn2mpi()\fR stores the representation of \fBa\fR at \fBto\fR, where \fBto\fR must be large enough to hold the result. The size can be determined by calling BN_bn2mpi(\fBa\fR, \s-1NULL\s0). .PP \&\fIBN_mpi2bn()\fR converts the \fBlen\fR bytes long representation at \fBs\fR to a \fB\s-1BIGNUM\s0\fR and stores it at \fBret\fR, or in a newly allocated \fB\s-1BIGNUM\s0\fR if \fBret\fR is \s-1NULL.\s0 .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBN_bn2bin()\fR returns the length of the big-endian number placed at \fBto\fR. \&\fIBN_bin2bn()\fR returns the \fB\s-1BIGNUM\s0\fR, \s-1NULL\s0 on error. .PP \&\fIBN_bn2hex()\fR and \fIBN_bn2dec()\fR return a null-terminated string, or \s-1NULL\s0 on error. \fIBN_hex2bn()\fR and \fIBN_dec2bn()\fR return the number's length in hexadecimal or decimal digits, and 0 on error. .PP \&\fIBN_print_fp()\fR and \fIBN_print()\fR return 1 on success, 0 on write errors. .PP \&\fIBN_bn2mpi()\fR returns the length of the representation. \fIBN_mpi2bn()\fR returns the \fB\s-1BIGNUM\s0\fR, and \s-1NULL\s0 on error. .PP The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3), \fIERR_get_error\fR\|(3), \fIBN_zero\fR\|(3), \&\fIASN1_INTEGER_to_BN\fR\|(3), \&\fIBN_num_bytes\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIBN_bn2bin()\fR, \fIBN_bin2bn()\fR, \fIBN_print_fp()\fR and \fIBN_print()\fR are available in all versions of SSLeay and OpenSSL. .PP \&\fIBN_bn2hex()\fR, \fIBN_bn2dec()\fR, \fIBN_hex2bn()\fR, \fIBN_dec2bn()\fR, \fIBN_bn2mpi()\fR and \&\fIBN_mpi2bn()\fR were added in SSLeay 0.9.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_DigestSignInit.30000644000175000017500000001717012360020717021201 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_DigestSignInit 3" .TH EVP_DigestSignInit 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_DigestSignInit, EVP_DigestSignUpdate, EVP_DigestSignFinal \- EVP signing functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, \& const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey); \& int EVP_DigestSignUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); \& int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \s-1EVP\s0 signature routines are a high level interface to digital signatures. .PP \&\fIEVP_DigestSignInit()\fR sets up signing context \fBctx\fR to use digest \fBtype\fR from \&\s-1ENGINE \s0\fBimpl\fR and private key \fBpkey\fR. \fBctx\fR must be initialized with \&\fIEVP_MD_CTX_init()\fR before calling this function. If \fBpctx\fR is not \s-1NULL\s0 the \&\s-1EVP_PKEY_CTX\s0 of the signing operation will be written to \fB*pctx\fR: this can be used to set alternative signing options. .PP \&\fIEVP_DigestSignUpdate()\fR hashes \fBcnt\fR bytes of data at \fBd\fR into the signature context \fBctx\fR. This function can be called several times on the same \fBctx\fR to include additional data. This function is currently implemented usig a macro. .PP \&\fIEVP_DigestSignFinal()\fR signs the data in \fBctx\fR places the signature in \fBsig\fR. If \fBsig\fR is \fB\s-1NULL\s0\fR then the maximum size of the output buffer is written to the \fBsiglen\fR parameter. If \fBsig\fR is not \fB\s-1NULL\s0\fR then before the call the \&\fBsiglen\fR parameter should contain the length of the \fBsig\fR buffer, if the call is successful the signature is written to \fBsig\fR and the amount of data written to \fBsiglen\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_DigestSignInit()\fR \fIEVP_DigestSignUpdate()\fR and \fIEVP_DigestSignaFinal()\fR return 1 for success and 0 or a negative value for failure. In particular a return value of \-2 indicates the operation is not supported by the public key algorithm. .PP The error codes can be obtained from \fIERR_get_error\fR\|(3). .SH "NOTES" .IX Header "NOTES" The \fB\s-1EVP\s0\fR interface to digital signatures should almost always be used in preference to the low level interfaces. This is because the code then becomes transparent to the algorithm used and much more flexible. .PP In previous versions of OpenSSL there was a link between message digest types and public key algorithms. This meant that \*(L"clone\*(R" digests such as \fIEVP_dss1()\fR needed to be used to sign using \s-1SHA1\s0 and \s-1DSA.\s0 This is no longer necessary and the use of clone digest is now discouraged. .PP The call to \fIEVP_DigestSignFinal()\fR internally finalizes a copy of the digest context. This means that calls to \fIEVP_DigestSignUpdate()\fR and \&\fIEVP_DigestSignFinal()\fR can be called later to digest and sign additional data. .PP Since only a copy of the digest context is ever finalized the context must be cleaned up after use by calling \fIEVP_MD_CTX_cleanup()\fR or a memory leak will occur. .PP The use of \fIEVP_PKEY_size()\fR with these functions is discouraged because some signature operations may have a signature length which depends on the parameters set. As a result \fIEVP_PKEY_size()\fR would have to return a value which indicates the maximum possible signature for any set of parameters. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_DigestVerifyInit\fR\|(3), \&\fIEVP_DigestInit\fR\|(3), \fIerr\fR\|(3), \&\fIevp\fR\|(3), \fIhmac\fR\|(3), \fImd2\fR\|(3), \&\fImd5\fR\|(3), \fImdc2\fR\|(3), \fIripemd\fR\|(3), \&\fIsha\fR\|(3), \fIdgst\fR\|(1) .SH "HISTORY" .IX Header "HISTORY" \&\fIEVP_DigestSignInit()\fR, \fIEVP_DigestSignUpdate()\fR and \fIEVP_DigestSignFinal()\fR were first added to OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/crl.10000644000175000017500000001553212360020740016355 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "crl 1" .TH crl 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" crl \- CRL utility .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBcrl\fR [\fB\-inform PEM|DER\fR] [\fB\-outform PEM|DER\fR] [\fB\-text\fR] [\fB\-in filename\fR] [\fB\-out filename\fR] [\fB\-noout\fR] [\fB\-hash\fR] [\fB\-issuer\fR] [\fB\-lastupdate\fR] [\fB\-nextupdate\fR] [\fB\-CAfile file\fR] [\fB\-CApath dir\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBcrl\fR command processes \s-1CRL\s0 files in \s-1DER\s0 or \s-1PEM\s0 format. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" .IP "\fB\-inform DER|PEM\fR" 4 .IX Item "-inform DER|PEM" This specifies the input format. \fB\s-1DER\s0\fR format is \s-1DER\s0 encoded \s-1CRL\s0 structure. \fB\s-1PEM\s0\fR (the default) is a base64 encoded version of the \s-1DER\s0 form with header and footer lines. .IP "\fB\-outform DER|PEM\fR" 4 .IX Item "-outform DER|PEM" This specifies the output format, the options have the same meaning as the \&\fB\-inform\fR option. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read from or standard input if this option is not specified. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" specifies the output filename to write to or standard output by default. .IP "\fB\-text\fR" 4 .IX Item "-text" print out the \s-1CRL\s0 in text form. .IP "\fB\-noout\fR" 4 .IX Item "-noout" don't output the encoded version of the \s-1CRL.\s0 .IP "\fB\-hash\fR" 4 .IX Item "-hash" output a hash of the issuer name. This can be use to lookup CRLs in a directory by issuer name. .IP "\fB\-hash_old\fR" 4 .IX Item "-hash_old" outputs the \*(L"hash\*(R" of the \s-1CRL\s0 issuer name using the older algorithm as used by OpenSSL versions before 1.0.0. .IP "\fB\-issuer\fR" 4 .IX Item "-issuer" output the issuer name. .IP "\fB\-lastupdate\fR" 4 .IX Item "-lastupdate" output the lastUpdate field. .IP "\fB\-nextupdate\fR" 4 .IX Item "-nextupdate" output the nextUpdate field. .IP "\fB\-CAfile file\fR" 4 .IX Item "-CAfile file" verify the signature on a \s-1CRL\s0 by looking up the issuing certificate in \&\fBfile\fR .IP "\fB\-CApath dir\fR" 4 .IX Item "-CApath dir" verify the signature on a \s-1CRL\s0 by looking up the issuing certificate in \&\fBdir\fR. This directory must be a standard certificate directory: that is a hash of each subject name (using \fBx509 \-hash\fR) should be linked to each certificate. .SH "NOTES" .IX Header "NOTES" The \s-1PEM CRL\s0 format uses the header and footer lines: .PP .Vb 2 \& \-\-\-\-\-BEGIN X509 CRL\-\-\-\-\- \& \-\-\-\-\-END X509 CRL\-\-\-\-\- .Ve .SH "EXAMPLES" .IX Header "EXAMPLES" Convert a \s-1CRL\s0 file from \s-1PEM\s0 to \s-1DER:\s0 .PP .Vb 1 \& openssl crl \-in crl.pem \-outform DER \-out crl.der .Ve .PP Output the text form of a \s-1DER\s0 encoded certificate: .PP .Vb 1 \& openssl crl \-in crl.der \-text \-noout .Ve .SH "BUGS" .IX Header "BUGS" Ideally it should be possible to create a \s-1CRL\s0 using appropriate options and files too. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIcrl2pkcs7\fR\|(1), \fIca\fR\|(1), \fIx509\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/nseq.10000644000175000017500000001347712360020741016552 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "nseq 1" .TH nseq 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" nseq \- create or examine a netscape certificate sequence .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBnseq\fR [\fB\-in filename\fR] [\fB\-out filename\fR] [\fB\-toseq\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBnseq\fR command takes a file containing a Netscape certificate sequence and prints out the certificates contained in it or takes a file of certificates and converts it into a Netscape certificate sequence. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read or standard input if this option is not specified. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" specifies the output filename or standard output by default. .IP "\fB\-toseq\fR" 4 .IX Item "-toseq" normally a Netscape certificate sequence will be input and the output is the certificates contained in it. With the \fB\-toseq\fR option the situation is reversed: a Netscape certificate sequence is created from a file of certificates. .SH "EXAMPLES" .IX Header "EXAMPLES" Output the certificates in a Netscape certificate sequence .PP .Vb 1 \& openssl nseq \-in nseq.pem \-out certs.pem .Ve .PP Create a Netscape certificate sequence .PP .Vb 1 \& openssl nseq \-in certs.pem \-toseq \-out nseq.pem .Ve .SH "NOTES" .IX Header "NOTES" The \fB\s-1PEM\s0\fR encoded form uses the same headers and footers as a certificate: .PP .Vb 2 \& \-\-\-\-\-BEGIN CERTIFICATE\-\-\-\-\- \& \-\-\-\-\-END CERTIFICATE\-\-\-\-\- .Ve .PP A Netscape certificate sequence is a Netscape specific form that can be sent to browsers as an alternative to the standard PKCS#7 format when several certificates are sent to the browser: for example during certificate enrollment. It is used by Netscape certificate server for example. .SH "BUGS" .IX Header "BUGS" This program needs a few more options: like allowing \s-1DER\s0 or \s-1PEM\s0 input and output files and allowing multiple certificate files to be used. deps/libressl-pnacl-sys-2.1.6/libressl/man/d2i_RSAPublicKey.30000644000175000017500000001367412360020727020604 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "d2i_RSAPublicKey 3" .TH d2i_RSAPublicKey 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" d2i_RSAPublicKey, i2d_RSAPublicKey, d2i_RSAPrivateKey, i2d_RSAPrivateKey, d2i_RSA_PUBKEY, i2d_RSA_PUBKEY, i2d_Netscape_RSA, d2i_Netscape_RSA \- RSA public and private key encoding functions. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& RSA * d2i_RSAPublicKey(RSA **a, const unsigned char **pp, long length); \& \& int i2d_RSAPublicKey(RSA *a, unsigned char **pp); \& \& RSA * d2i_RSA_PUBKEY(RSA **a, const unsigned char **pp, long length); \& \& int i2d_RSA_PUBKEY(RSA *a, unsigned char **pp); \& \& RSA * d2i_RSAPrivateKey(RSA **a, const unsigned char **pp, long length); \& \& int i2d_RSAPrivateKey(RSA *a, unsigned char **pp); \& \& int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)()); \& \& RSA * d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length, int (*cb)()); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fId2i_RSAPublicKey()\fR and \fIi2d_RSAPublicKey()\fR decode and encode a PKCS#1 RSAPublicKey structure. .PP \&\fId2i_RSA_PUBKEY()\fR and \fIi2d_RSA_PUBKEY()\fR decode and encode an \s-1RSA\s0 public key using a SubjectPublicKeyInfo (certificate public key) structure. .PP \&\fId2i_RSAPrivateKey()\fR, \fIi2d_RSAPrivateKey()\fR decode and encode a PKCS#1 RSAPrivateKey structure. .PP \&\fId2i_Netscape_RSA()\fR, \fIi2d_Netscape_RSA()\fR decode and encode an \s-1RSA\s0 private key in \&\s-1NET\s0 format. .PP The usage of all of these functions is similar to the \fId2i_X509()\fR and \&\fIi2d_X509()\fR described in the \fId2i_X509\fR\|(3) manual page. .SH "NOTES" .IX Header "NOTES" The \fB\s-1RSA\s0\fR structure passed to the private key encoding functions should have all the PKCS#1 private key components present. .PP The data encoded by the private key functions is unencrypted and therefore offers no private key security. .PP The \s-1NET\s0 format functions are present to provide compatibility with certain very old software. This format has some severe security weaknesses and should be avoided if possible. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fId2i_X509\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_f_base64.30000644000175000017500000001412112360020707017655 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_f_base64 3" .TH BIO_f_base64 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_f_base64 \- base64 BIO filter .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& BIO_METHOD * BIO_f_base64(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_f_base64()\fR returns the base64 \s-1BIO\s0 method. This is a filter \&\s-1BIO\s0 that base64 encodes any data written through it and decodes any data read through it. .PP Base64 BIOs do not support \fIBIO_gets()\fR or \fIBIO_puts()\fR. .PP \&\fIBIO_flush()\fR on a base64 \s-1BIO\s0 that is being written through is used to signal that no more data is to be encoded: this is used to flush the final block through the \s-1BIO.\s0 .PP The flag \s-1BIO_FLAGS_BASE64_NO_NL\s0 can be set with \fIBIO_set_flags()\fR to encode the data all on one line or expect the data to be all on one line. .SH "NOTES" .IX Header "NOTES" Because of the format of base64 encoding the end of the encoded block cannot always be reliably determined. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBIO_f_base64()\fR returns the base64 \s-1BIO\s0 method. .SH "EXAMPLES" .IX Header "EXAMPLES" Base64 encode the string \*(L"Hello World\en\*(R" and write the result to standard output: .PP .Vb 2 \& BIO *bio, *b64; \& char message[] = "Hello World \en"; \& \& b64 = BIO_new(BIO_f_base64()); \& bio = BIO_new_fp(stdout, BIO_NOCLOSE); \& BIO_push(b64, bio); \& BIO_write(b64, message, strlen(message)); \& BIO_flush(b64); \& \& BIO_free_all(b64); .Ve .PP Read Base64 encoded data from standard input and write the decoded data to standard output: .PP .Vb 3 \& BIO *bio, *b64, *bio_out; \& char inbuf[512]; \& int inlen; \& \& b64 = BIO_new(BIO_f_base64()); \& bio = BIO_new_fp(stdin, BIO_NOCLOSE); \& bio_out = BIO_new_fp(stdout, BIO_NOCLOSE); \& BIO_push(b64, bio); \& while((inlen = BIO_read(b64, inbuf, 512)) > 0) \& BIO_write(bio_out, inbuf, inlen); \& \& BIO_flush(bio_out); \& BIO_free_all(b64); .Ve .SH "BUGS" .IX Header "BUGS" The ambiguity of \s-1EOF\s0 in base64 encoded data can cause additional data following the base64 encoded block to be misinterpreted. .PP There should be some way of specifying a test that the \s-1BIO\s0 can perform to reliably determine \s-1EOF \s0(for example a \s-1MIME\s0 boundary). deps/libressl-pnacl-sys-2.1.6/libressl/man/RSA_new.30000644000175000017500000001166312360020724017100 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RSA_new 3" .TH RSA_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RSA_new, RSA_free \- allocate and free RSA objects .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& RSA * RSA_new(void); \& \& void RSA_free(RSA *rsa); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIRSA_new()\fR allocates and initializes an \fB\s-1RSA\s0\fR structure. It is equivalent to calling RSA_new_method(\s-1NULL\s0). .PP \&\fIRSA_free()\fR frees the \fB\s-1RSA\s0\fR structure and its components. The key is erased before the memory is returned to the system. .SH "RETURN VALUES" .IX Header "RETURN VALUES" If the allocation fails, \fIRSA_new()\fR returns \fB\s-1NULL\s0\fR and sets an error code that can be obtained by \fIERR_get_error\fR\|(3). Otherwise it returns a pointer to the newly allocated structure. .PP \&\fIRSA_free()\fR returns no value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fIrsa\fR\|(3), \&\fIRSA_generate_key\fR\|(3), \&\fIRSA_new_method\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIRSA_new()\fR and \fIRSA_free()\fR are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/d2i_DSAPublicKey.30000644000175000017500000001561112360020726020556 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "d2i_DSAPublicKey 3" .TH d2i_DSAPublicKey 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" d2i_DSAPublicKey, i2d_DSAPublicKey, d2i_DSAPrivateKey, i2d_DSAPrivateKey, d2i_DSA_PUBKEY, i2d_DSA_PUBKEY, d2i_DSAparams, i2d_DSAparams, d2i_DSA_SIG, i2d_DSA_SIG \- DSA key encoding and parsing functions. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& DSA * d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length); \& \& int i2d_DSAPublicKey(const DSA *a, unsigned char **pp); \& \& DSA * d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length); \& \& int i2d_DSA_PUBKEY(const DSA *a, unsigned char **pp); \& \& DSA * d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length); \& \& int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp); \& \& DSA * d2i_DSAparams(DSA **a, const unsigned char **pp, long length); \& \& int i2d_DSAparams(const DSA *a, unsigned char **pp); \& \& DSA * d2i_DSA_SIG(DSA_SIG **a, const unsigned char **pp, long length); \& \& int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fId2i_DSAPublicKey()\fR and \fIi2d_DSAPublicKey()\fR decode and encode the \s-1DSA\s0 public key components structure. .PP \&\fId2i_DSA_PUBKEY()\fR and \fIi2d_DSA_PUBKEY()\fR decode and encode an \s-1DSA\s0 public key using a SubjectPublicKeyInfo (certificate public key) structure. .PP \&\fId2i_DSAPrivateKey()\fR, \fIi2d_DSAPrivateKey()\fR decode and encode the \s-1DSA\s0 private key components. .PP \&\fId2i_DSAparams()\fR, \fIi2d_DSAparams()\fR decode and encode the \s-1DSA\s0 parameters using a \fBDss-Parms\fR structure as defined in \s-1RFC2459.\s0 .PP \&\fId2i_DSA_SIG()\fR, \fIi2d_DSA_SIG()\fR decode and encode a \s-1DSA\s0 signature using a \&\fBDss-Sig-Value\fR structure as defined in \s-1RFC2459.\s0 .PP The usage of all of these functions is similar to the \fId2i_X509()\fR and \&\fIi2d_X509()\fR described in the \fId2i_X509\fR\|(3) manual page. .SH "NOTES" .IX Header "NOTES" The \fB\s-1DSA\s0\fR structure passed to the private key encoding functions should have all the private key components present. .PP The data encoded by the private key functions is unencrypted and therefore offers no private key security. .PP The \fB\s-1DSA_PUBKEY\s0\fR functions should be used in preference to the \fBDSAPublicKey\fR functions when encoding public keys because they use a standard format. .PP The \fBDSAPublicKey\fR functions use an non standard format the actual data encoded depends on the value of the \fBwrite_params\fR field of the \fBa\fR key parameter. If \fBwrite_params\fR is zero then only the \fBpub_key\fR field is encoded as an \&\fB\s-1INTEGER\s0\fR. If \fBwrite_params\fR is 1 then a \fB\s-1SEQUENCE\s0\fR consisting of the \&\fBp\fR, \fBq\fR, \fBg\fR and \fBpub_key\fR respectively fields are encoded. .PP The \fBDSAPrivateKey\fR functions also use a non standard structure consiting consisting of a \s-1SEQUENCE\s0 containing the \fBp\fR, \fBq\fR, \fBg\fR and \fBpub_key\fR and \&\fBpriv_key\fR fields respectively. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fId2i_X509\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_PKEY_encrypt.30000644000175000017500000001550112360020720020617 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_PKEY_encrypt 3" .TH EVP_PKEY_encrypt 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_PKEY_encrypt_init, EVP_PKEY_encrypt \- encrypt using a public key algorithm .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx); \& int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx, \& unsigned char *out, size_t *outlen, \& const unsigned char *in, size_t inlen); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fIEVP_PKEY_encrypt_init()\fR function initializes a public key algorithm context using key \fBpkey\fR for an encryption operation. .PP The \fIEVP_PKEY_encrypt()\fR function performs a public key encryption operation using \fBctx\fR. The data to be encrypted is specified using the \fBin\fR and \&\fBinlen\fR parameters. If \fBout\fR is \fB\s-1NULL\s0\fR then the maximum size of the output buffer is written to the \fBoutlen\fR parameter. If \fBout\fR is not \fB\s-1NULL\s0\fR then before the call the \fBoutlen\fR parameter should contain the length of the \&\fBout\fR buffer, if the call is successful the encrypted data is written to \&\fBout\fR and the amount of data written to \fBoutlen\fR. .SH "NOTES" .IX Header "NOTES" After the call to \fIEVP_PKEY_encrypt_init()\fR algorithm specific control operations can be performed to set any appropriate parameters for the operation. .PP The function \fIEVP_PKEY_encrypt()\fR can be called more than once on the same context if several operations are performed using the same parameters. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_PKEY_encrypt_init()\fR and \fIEVP_PKEY_encrypt()\fR return 1 for success and 0 or a negative value for failure. In particular a return value of \-2 indicates the operation is not supported by the public key algorithm. .SH "EXAMPLE" .IX Header "EXAMPLE" Encrypt data using \s-1OAEP \s0(for \s-1RSA\s0 keys): .PP .Vb 2 \& #include \& #include \& \& EVP_PKEY_CTX *ctx; \& unsigned char *out, *in; \& size_t outlen, inlen; \& EVP_PKEY *key; \& /* NB: assumes key in, inlen are already set up \& * and that key is an RSA public key \& */ \& ctx = EVP_PKEY_CTX_new(key); \& if (!ctx) \& /* Error occurred */ \& if (EVP_PKEY_encrypt_init(ctx) <= 0) \& /* Error */ \& if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_OAEP_PADDING) <= 0) \& /* Error */ \& \& /* Determine buffer length */ \& if (EVP_PKEY_encrypt(ctx, NULL, &outlen, in, inlen) <= 0) \& /* Error */ \& \& out = OPENSSL_malloc(outlen); \& \& if (!out) \& /* malloc failure */ \& \& if (EVP_PKEY_encrypt(ctx, out, &outlen, in, inlen) <= 0) \& /* Error */ \& \& /* Encrypted data is outlen bytes written to buffer out */ .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_PKEY_CTX_new\fR\|(3), \&\fIEVP_PKEY_decrypt\fR\|(3), \&\fIEVP_PKEY_sign\fR\|(3), \&\fIEVP_PKEY_verify\fR\|(3), \&\fIEVP_PKEY_verify_recover\fR\|(3), \&\fIEVP_PKEY_derive\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" These functions were first added to OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_s_file.30000644000175000017500000002210012360020711017514 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_s_file 3" .TH BIO_s_file 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_s_file, BIO_new_file, BIO_new_fp, BIO_set_fp, BIO_get_fp, BIO_read_filename, BIO_write_filename, BIO_append_filename, BIO_rw_filename \- FILE bio .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIO_METHOD * BIO_s_file(void); \& BIO *BIO_new_file(const char *filename, const char *mode); \& BIO *BIO_new_fp(FILE *stream, int flags); \& \& BIO_set_fp(BIO *b,FILE *fp, int flags); \& BIO_get_fp(BIO *b,FILE **fpp); \& \& int BIO_read_filename(BIO *b, char *name) \& int BIO_write_filename(BIO *b, char *name) \& int BIO_append_filename(BIO *b, char *name) \& int BIO_rw_filename(BIO *b, char *name) .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_s_file()\fR returns the \s-1BIO\s0 file method. As its name implies it is a wrapper round the stdio \s-1FILE\s0 structure and it is a source/sink \s-1BIO.\s0 .PP Calls to \fIBIO_read()\fR and \fIBIO_write()\fR read and write data to the underlying stream. \fIBIO_gets()\fR and \fIBIO_puts()\fR are supported on file BIOs. .PP \&\fIBIO_flush()\fR on a file \s-1BIO\s0 calls the \fIfflush()\fR function on the wrapped stream. .PP \&\fIBIO_reset()\fR attempts to change the file pointer to the start of file using fseek(stream, 0, 0). .PP \&\fIBIO_seek()\fR sets the file pointer to position \fBofs\fR from start of file using fseek(stream, ofs, 0). .PP \&\fIBIO_eof()\fR calls \fIfeof()\fR. .PP Setting the \s-1BIO_CLOSE\s0 flag calls \fIfclose()\fR on the stream when the \s-1BIO\s0 is freed. .PP \&\fIBIO_new_file()\fR creates a new file \s-1BIO\s0 with mode \fBmode\fR the meaning of \fBmode\fR is the same as the stdio function \fIfopen()\fR. The \s-1BIO_CLOSE\s0 flag is set on the returned \s-1BIO.\s0 .PP \&\fIBIO_new_fp()\fR creates a file \s-1BIO\s0 wrapping \fBstream\fR. Flags can be: \&\s-1BIO_CLOSE, BIO_NOCLOSE \s0(the close flag) \s-1BIO_FP_TEXT \s0(sets the underlying stream to text mode, default is binary: this only has any effect under Win32). .PP \&\fIBIO_set_fp()\fR set the fp of a file \s-1BIO\s0 to \fBfp\fR. \fBflags\fR has the same meaning as in \fIBIO_new_fp()\fR, it is a macro. .PP \&\fIBIO_get_fp()\fR retrieves the fp of a file \s-1BIO,\s0 it is a macro. .PP \&\fIBIO_seek()\fR is a macro that sets the position pointer to \fBoffset\fR bytes from the start of file. .PP \&\fIBIO_tell()\fR returns the value of the position pointer. .PP \&\fIBIO_read_filename()\fR, \fIBIO_write_filename()\fR, \fIBIO_append_filename()\fR and \&\fIBIO_rw_filename()\fR set the file \s-1BIO \s0\fBb\fR to use file \fBname\fR for reading, writing, append or read write respectively. .SH "NOTES" .IX Header "NOTES" When wrapping stdout, stdin or stderr the underlying stream should not normally be closed so the \s-1BIO_NOCLOSE\s0 flag should be set. .PP Because the file \s-1BIO\s0 calls the underlying stdio functions any quirks in stdio behaviour will be mirrored by the corresponding \s-1BIO.\s0 .PP On Windows BIO_new_files reserves for the filename argument to be \&\s-1UTF\-8\s0 encoded. In other words if you have to make it work in multi\- lingual environment, encode file names in \s-1UTF\-8.\s0 .SH "EXAMPLES" .IX Header "EXAMPLES" File \s-1BIO \s0\*(L"hello world\*(R": .PP .Vb 3 \& BIO *bio_out; \& bio_out = BIO_new_fp(stdout, BIO_NOCLOSE); \& BIO_printf(bio_out, "Hello World\en"); .Ve .PP Alternative technique: .PP .Vb 5 \& BIO *bio_out; \& bio_out = BIO_new(BIO_s_file()); \& if(bio_out == NULL) /* Error ... */ \& if(!BIO_set_fp(bio_out, stdout, BIO_NOCLOSE)) /* Error ... */ \& BIO_printf(bio_out, "Hello World\en"); .Ve .PP Write to a file: .PP .Vb 5 \& BIO *out; \& out = BIO_new_file("filename.txt", "w"); \& if(!out) /* Error occurred */ \& BIO_printf(out, "Hello World\en"); \& BIO_free(out); .Ve .PP Alternative technique: .PP .Vb 6 \& BIO *out; \& out = BIO_new(BIO_s_file()); \& if(out == NULL) /* Error ... */ \& if(!BIO_write_filename(out, "filename.txt")) /* Error ... */ \& BIO_printf(out, "Hello World\en"); \& BIO_free(out); .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBIO_s_file()\fR returns the file \s-1BIO\s0 method. .PP \&\fIBIO_new_file()\fR and \fIBIO_new_fp()\fR return a file \s-1BIO\s0 or \s-1NULL\s0 if an error occurred. .PP \&\fIBIO_set_fp()\fR and \fIBIO_get_fp()\fR return 1 for success or 0 for failure (although the current implementation never return 0). .PP \&\fIBIO_seek()\fR returns the same value as the underlying \fIfseek()\fR function: 0 for success or \-1 for failure. .PP \&\fIBIO_tell()\fR returns the current file position. .PP \&\fIBIO_read_filename()\fR, \fIBIO_write_filename()\fR, \fIBIO_append_filename()\fR and \&\fIBIO_rw_filename()\fR return 1 for success or 0 for failure. .SH "BUGS" .IX Header "BUGS" \&\fIBIO_reset()\fR and \fIBIO_seek()\fR are implemented using \fIfseek()\fR on the underlying stream. The return value for \fIfseek()\fR is 0 for success or \-1 if an error occurred this differs from other types of \s-1BIO\s0 which will typically return 1 for success and a non positive value if an error occurred. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIBIO_seek\fR\|(3), \fIBIO_tell\fR\|(3), \&\fIBIO_reset\fR\|(3), \fIBIO_flush\fR\|(3), \&\fIBIO_read\fR\|(3), \&\fIBIO_write\fR\|(3), \fIBIO_puts\fR\|(3), \&\fIBIO_gets\fR\|(3), \fIBIO_printf\fR\|(3), \&\fIBIO_set_close\fR\|(3), \fIBIO_get_close\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_shutdown.30000644000175000017500000002705412360020737020203 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_shutdown 3" .TH SSL_shutdown 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_shutdown \- shut down a TLS/SSL connection .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_shutdown(SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_shutdown()\fR shuts down an active \s-1TLS/SSL\s0 connection. It sends the \&\*(L"close notify\*(R" shutdown alert to the peer. .SH "NOTES" .IX Header "NOTES" \&\fISSL_shutdown()\fR tries to send the \*(L"close notify\*(R" shutdown alert to the peer. Whether the operation succeeds or not, the \s-1SSL_SENT_SHUTDOWN\s0 flag is set and a currently open session is considered closed and good and will be kept in the session cache for further reuse. .PP The shutdown procedure consists of 2 steps: the sending of the \*(L"close notify\*(R" shutdown alert and the reception of the peer's \*(L"close notify\*(R" shutdown alert. According to the \s-1TLS\s0 standard, it is acceptable for an application to only send its shutdown alert and then close the underlying connection without waiting for the peer's response (this way resources can be saved, as the process can already terminate or serve another connection). When the underlying connection shall be used for more communications, the complete shutdown procedure (bidirectional \*(L"close notify\*(R" alerts) must be performed, so that the peers stay synchronized. .PP \&\fISSL_shutdown()\fR supports both uni\- and bidirectional shutdown by its 2 step behaviour. .ie n .IP "When the application is the first party to send the ""close notify"" alert, \fISSL_shutdown()\fR will only send the alert and then set the \s-1SSL_SENT_SHUTDOWN\s0 flag (so that the session is considered good and will be kept in cache). \fISSL_shutdown()\fR will then return with 0. If a unidirectional shutdown is enough (the underlying connection shall be closed anyway), this first call to \fISSL_shutdown()\fR is sufficient. In order to complete the bidirectional shutdown handshake, \fISSL_shutdown()\fR must be called again. The second call will make \fISSL_shutdown()\fR wait for the peer's ""close notify"" shutdown alert. On success, the second call to \fISSL_shutdown()\fR will return with 1." 4 .el .IP "When the application is the first party to send the ``close notify'' alert, \fISSL_shutdown()\fR will only send the alert and then set the \s-1SSL_SENT_SHUTDOWN\s0 flag (so that the session is considered good and will be kept in cache). \fISSL_shutdown()\fR will then return with 0. If a unidirectional shutdown is enough (the underlying connection shall be closed anyway), this first call to \fISSL_shutdown()\fR is sufficient. In order to complete the bidirectional shutdown handshake, \fISSL_shutdown()\fR must be called again. The second call will make \fISSL_shutdown()\fR wait for the peer's ``close notify'' shutdown alert. On success, the second call to \fISSL_shutdown()\fR will return with 1." 4 .IX Item "When the application is the first party to send the close notify alert, SSL_shutdown() will only send the alert and then set the SSL_SENT_SHUTDOWN flag (so that the session is considered good and will be kept in cache). SSL_shutdown() will then return with 0. If a unidirectional shutdown is enough (the underlying connection shall be closed anyway), this first call to SSL_shutdown() is sufficient. In order to complete the bidirectional shutdown handshake, SSL_shutdown() must be called again. The second call will make SSL_shutdown() wait for the peer's close notify shutdown alert. On success, the second call to SSL_shutdown() will return with 1." .PD 0 .ie n .IP "If the peer already sent the ""close notify"" alert \fBand\fR it was already processed implicitly inside another function (\fISSL_read\fR\|(3)), the \s-1SSL_RECEIVED_SHUTDOWN\s0 flag is set. \fISSL_shutdown()\fR will send the ""close notify"" alert, set the \s-1SSL_SENT_SHUTDOWN\s0 flag and will immediately return with 1. Whether \s-1SSL_RECEIVED_SHUTDOWN\s0 is already set can be checked using the \fISSL_get_shutdown()\fR (see also \fISSL_set_shutdown\fR\|(3) call." 4 .el .IP "If the peer already sent the ``close notify'' alert \fBand\fR it was already processed implicitly inside another function (\fISSL_read\fR\|(3)), the \s-1SSL_RECEIVED_SHUTDOWN\s0 flag is set. \fISSL_shutdown()\fR will send the ``close notify'' alert, set the \s-1SSL_SENT_SHUTDOWN\s0 flag and will immediately return with 1. Whether \s-1SSL_RECEIVED_SHUTDOWN\s0 is already set can be checked using the \fISSL_get_shutdown()\fR (see also \fISSL_set_shutdown\fR\|(3) call." 4 .IX Item "If the peer already sent the close notify alert and it was already processed implicitly inside another function (SSL_read), the SSL_RECEIVED_SHUTDOWN flag is set. SSL_shutdown() will send the close notify alert, set the SSL_SENT_SHUTDOWN flag and will immediately return with 1. Whether SSL_RECEIVED_SHUTDOWN is already set can be checked using the SSL_get_shutdown() (see also SSL_set_shutdown call." .PD .PP It is therefore recommended, to check the return value of \fISSL_shutdown()\fR and call \fISSL_shutdown()\fR again, if the bidirectional shutdown is not yet complete (return value of the first call is 0). As the shutdown is not specially handled in the SSLv2 protocol, \fISSL_shutdown()\fR will succeed on the first call. .PP The behaviour of \fISSL_shutdown()\fR additionally depends on the underlying \s-1BIO.\s0 .PP If the underlying \s-1BIO\s0 is \fBblocking\fR, \fISSL_shutdown()\fR will only return once the handshake step has been finished or an error occurred. .PP If the underlying \s-1BIO\s0 is \fBnon-blocking\fR, \fISSL_shutdown()\fR will also return when the underlying \s-1BIO\s0 could not satisfy the needs of \fISSL_shutdown()\fR to continue the handshake. In this case a call to \fISSL_get_error()\fR with the return value of \fISSL_shutdown()\fR will yield \fB\s-1SSL_ERROR_WANT_READ\s0\fR or \&\fB\s-1SSL_ERROR_WANT_WRITE\s0\fR. The calling process then must repeat the call after taking appropriate action to satisfy the needs of \fISSL_shutdown()\fR. The action depends on the underlying \s-1BIO.\s0 When using a non-blocking socket, nothing is to be done, but \fIselect()\fR can be used to check for the required condition. When using a buffering \s-1BIO,\s0 like a \s-1BIO\s0 pair, data must be written into or retrieved out of the \s-1BIO\s0 before being able to continue. .PP \&\fISSL_shutdown()\fR can be modified to only set the connection to \*(L"shutdown\*(R" state but not actually send the \*(L"close notify\*(R" alert messages, see \fISSL_CTX_set_quiet_shutdown\fR\|(3). When \*(L"quiet shutdown\*(R" is enabled, \fISSL_shutdown()\fR will always succeed and return 1. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" The shutdown is not yet finished. Call \fISSL_shutdown()\fR for a second time, if a bidirectional shutdown shall be performed. The output of \fISSL_get_error\fR\|(3) may be misleading, as an erroneous \s-1SSL_ERROR_SYSCALL\s0 may be flagged even though no error occurred. .ie n .IP "1" 4 .el .IP "\f(CW1\fR" 4 .IX Item "1" The shutdown was successfully completed. The \*(L"close notify\*(R" alert was sent and the peer's \*(L"close notify\*(R" alert was received. .ie n .IP """\-1""" 4 .el .IP "\f(CW\-1\fR" 4 .IX Item "-1" The shutdown was not successful because a fatal error occurred either at the protocol level or a connection failure occurred. It can also occur if action is need to continue the operation for non-blocking BIOs. Call \fISSL_get_error\fR\|(3) with the return value \fBret\fR to find out the reason. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_get_error\fR\|(3), \fISSL_connect\fR\|(3), \&\fISSL_accept\fR\|(3), \fISSL_set_shutdown\fR\|(3), \&\fISSL_CTX_set_quiet_shutdown\fR\|(3), \&\fISSL_clear\fR\|(3), \fISSL_free\fR\|(3), \&\fIssl\fR\|(3), \fIbio\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_rstate_string.30000644000175000017500000001313312360020736021210 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_rstate_string 3" .TH SSL_rstate_string 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_rstate_string, SSL_rstate_string_long \- get textual description of state of an SSL object during read operation .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& const char *SSL_rstate_string(SSL *ssl); \& const char *SSL_rstate_string_long(SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_rstate_string()\fR returns a 2 letter string indicating the current read state of the \s-1SSL\s0 object \fBssl\fR. .PP \&\fISSL_rstate_string_long()\fR returns a string indicating the current read state of the \s-1SSL\s0 object \fBssl\fR. .SH "NOTES" .IX Header "NOTES" When performing a read operation, the \s-1SSL/TLS\s0 engine must parse the record, consisting of header and body. When working in a blocking environment, SSL_rstate_string[_long]() should always return \*(L"\s-1RD\*(R"/\s0\*(L"read done\*(R". .PP This function should only seldom be needed in applications. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_rstate_string()\fR and \fISSL_rstate_string_long()\fR can return the following values: .ie n .IP """\s-1RH""/\s0""read header""" 4 .el .IP "``\s-1RH''/\s0``read header''" 4 .IX Item "RH/read header" The header of the record is being evaluated. .ie n .IP """\s-1RB""/\s0""read body""" 4 .el .IP "``\s-1RB''/\s0``read body''" 4 .IX Item "RB/read body" The body of the record is being evaluated. .ie n .IP """\s-1RD""/\s0""read done""" 4 .el .IP "``\s-1RD''/\s0``read done''" 4 .IX Item "RD/read done" The record has been completely processed. .ie n .IP """unknown""/""unknown""" 4 .el .IP "``unknown''/``unknown''" 4 .IX Item "unknown/unknown" The read state is unknown. This should never happen. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/CMS_sign_add1_signer.30000644000175000017500000002050212360020714021473 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CMS_sign_add1_signer 3" .TH CMS_sign_add1_signer 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CMS_sign_add1_signer, CMS_SignerInfo_sign \- add a signer to a CMS_ContentInfo signed data structure. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& CMS_SignerInfo *CMS_sign_add1_signer(CMS_ContentInfo *cms, X509 *signcert, EVP_PKEY *pkey, const EVP_MD *md, unsigned int flags); \& \& int CMS_SignerInfo_sign(CMS_SignerInfo *si); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fICMS_sign_add1_signer()\fR adds a signer with certificate \fBsigncert\fR and private key \fBpkey\fR using message digest \fBmd\fR to CMS_ContentInfo SignedData structure \fBcms\fR. .PP The CMS_ContentInfo structure should be obtained from an initial call to \&\fICMS_sign()\fR with the flag \fB\s-1CMS_PARTIAL\s0\fR set or in the case or re-signing a valid CMS_ContentInfo SignedData structure. .PP If the \fBmd\fR parameter is \fB\s-1NULL\s0\fR then the default digest for the public key algorithm will be used. .PP Unless the \fB\s-1CMS_REUSE_DIGEST\s0\fR flag is set the returned CMS_ContentInfo structure is not complete and must be finalized either by streaming (if applicable) or a call to \fICMS_final()\fR. .PP The \fICMS_SignerInfo_sign()\fR function will explicitly sign a CMS_SignerInfo structure, its main use is when \fB\s-1CMS_REUSE_DIGEST\s0\fR and \fB\s-1CMS_PARTIAL\s0\fR flags are both set. .SH "NOTES" .IX Header "NOTES" The main purpose of \fICMS_sign_add1_signer()\fR is to provide finer control over a \s-1CMS\s0 signed data structure where the simpler \fICMS_sign()\fR function defaults are not appropriate. For example if multiple signers or non default digest algorithms are needed. New attributes can also be added using the returned CMS_SignerInfo structure and the \s-1CMS\s0 attribute utility functions or the \&\s-1CMS\s0 signed receipt request functions. .PP Any of the following flags (ored together) can be passed in the \fBflags\fR parameter. .PP If \fB\s-1CMS_REUSE_DIGEST\s0\fR is set then an attempt is made to copy the content digest value from the CMS_ContentInfo structure: to add a signer to an existing structure. An error occurs if a matching digest value cannot be found to copy. The returned CMS_ContentInfo structure will be valid and finalized when this flag is set. .PP If \fB\s-1CMS_PARTIAL\s0\fR is set in addition to \fB\s-1CMS_REUSE_DIGEST\s0\fR then the CMS_SignerInfo structure will not be finalized so additional attributes can be added. In this case an explicit call to \fICMS_SignerInfo_sign()\fR is needed to finalize it. .PP If \fB\s-1CMS_NOCERTS\s0\fR is set the signer's certificate will not be included in the CMS_ContentInfo structure, the signer's certificate must still be supplied in the \fBsigncert\fR parameter though. This can reduce the size of the signature if the signers certificate can be obtained by other means: for example a previously signed message. .PP The SignedData structure includes several \s-1CMS\s0 signedAttributes including the signing time, the \s-1CMS\s0 content type and the supported list of ciphers in an SMIMECapabilities attribute. If \fB\s-1CMS_NOATTR\s0\fR is set then no signedAttributes will be used. If \fB\s-1CMS_NOSMIMECAP\s0\fR is set then just the SMIMECapabilities are omitted. .PP OpenSSL will by default identify signing certificates using issuer name and serial number. If \fB\s-1CMS_USE_KEYID\s0\fR is set it will use the subject key identifier value instead. An error occurs if the signing certificate does not have a subject key identifier extension. .PP If present the SMIMECapabilities attribute indicates support for the following algorithms in preference order: 256 bit \s-1AES,\s0 Gost R3411\-94, Gost 28147\-89, 192 bit \s-1AES, 128\s0 bit \s-1AES,\s0 triple \s-1DES, 128\s0 bit \s-1RC2, 64\s0 bit \s-1RC2, DES\s0 and 40 bit \s-1RC2.\s0 If any of these algorithms is not available then it will not be included: for example the \s-1GOST\s0 algorithms will not be included if the \s-1GOST ENGINE\s0 is not loaded. .PP \&\fICMS_sign_add1_signer()\fR returns an internal pointer to the CMS_SignerInfo structure just added, this can be used to set additional attributes before it is finalized. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICMS_sign1_add_signers()\fR returns an internal pointer to the CMS_SignerInfo structure just added or \s-1NULL\s0 if an error occurs. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_sign\fR\|(3), \&\fICMS_final\fR\|(3), .SH "HISTORY" .IX Header "HISTORY" \&\fICMS_sign_add1_signer()\fR was added to OpenSSL 0.9.8 deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_swap.30000644000175000017500000001040312360020712017117 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_swap 3" .TH BN_swap 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_swap \- exchange BIGNUMs .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void BN_swap(BIGNUM *a, BIGNUM *b); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBN_swap()\fR exchanges the values of \fIa\fR and \fIb\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" BN_swap was added in OpenSSL 0.9.7. deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_PKEY_verify_recover.30000644000175000017500000001667312360020721022200 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_PKEY_verify_recover 3" .TH EVP_PKEY_verify_recover 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_PKEY_verify_recover_init, EVP_PKEY_verify_recover \- recover signature using a public key algorithm .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx); \& int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx, \& unsigned char *rout, size_t *routlen, \& const unsigned char *sig, size_t siglen); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fIEVP_PKEY_verify_recover_init()\fR function initializes a public key algorithm context using key \fBpkey\fR for a verify recover operation. .PP The \fIEVP_PKEY_verify_recover()\fR function recovers signed data using \fBctx\fR. The signature is specified using the \fBsig\fR and \&\fBsiglen\fR parameters. If \fBrout\fR is \fB\s-1NULL\s0\fR then the maximum size of the output buffer is written to the \fBroutlen\fR parameter. If \fBrout\fR is not \fB\s-1NULL\s0\fR then before the call the \fBroutlen\fR parameter should contain the length of the \&\fBrout\fR buffer, if the call is successful recovered data is written to \&\fBrout\fR and the amount of data written to \fBroutlen\fR. .SH "NOTES" .IX Header "NOTES" Normally an application is only interested in whether a signature verification operation is successful in those cases the \fIEVP_verify()\fR function should be used. .PP Sometimes however it is useful to obtain the data originally signed using a signing operation. Only certain public key algorithms can recover a signature in this way (for example \s-1RSA\s0 in \s-1PKCS\s0 padding mode). .PP After the call to \fIEVP_PKEY_verify_recover_init()\fR algorithm specific control operations can be performed to set any appropriate parameters for the operation. .PP The function \fIEVP_PKEY_verify_recover()\fR can be called more than once on the same context if several operations are performed using the same parameters. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_PKEY_verify_recover_init()\fR and \fIEVP_PKEY_verify_recover()\fR return 1 for success and 0 or a negative value for failure. In particular a return value of \-2 indicates the operation is not supported by the public key algorithm. .SH "EXAMPLE" .IX Header "EXAMPLE" Recover digest originally signed using PKCS#1 and \s-1SHA256\s0 digest: .PP .Vb 2 \& #include \& #include \& \& EVP_PKEY_CTX *ctx; \& unsigned char *rout, *sig; \& size_t routlen, siglen; \& EVP_PKEY *verify_key; \& /* NB: assumes verify_key, sig and siglen are already set up \& * and that verify_key is an RSA public key \& */ \& ctx = EVP_PKEY_CTX_new(verify_key); \& if (!ctx) \& /* Error occurred */ \& if (EVP_PKEY_verify_recover_init(ctx) <= 0) \& /* Error */ \& if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0) \& /* Error */ \& if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0) \& /* Error */ \& \& /* Determine buffer length */ \& if (EVP_PKEY_verify_recover(ctx, NULL, &routlen, sig, siglen) <= 0) \& /* Error */ \& \& rout = OPENSSL_malloc(routlen); \& \& if (!rout) \& /* malloc failure */ \& \& if (EVP_PKEY_verify_recover(ctx, rout, &routlen, sig, siglen) <= 0) \& /* Error */ \& \& /* Recovered data is routlen bytes written to buffer rout */ .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_PKEY_CTX_new\fR\|(3), \&\fIEVP_PKEY_encrypt\fR\|(3), \&\fIEVP_PKEY_decrypt\fR\|(3), \&\fIEVP_PKEY_sign\fR\|(3), \&\fIEVP_PKEY_verify\fR\|(3), \&\fIEVP_PKEY_derive\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" These functions were first added to OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_new.30000644000175000017500000001712512360020731017627 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_new 3" .TH SSL_CTX_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_new, SSLv3_method, SSLv3_server_method, SSLv3_client_method, TLSv1_method, TLSv1_server_method, TLSv1_client_method, TLSv1_1_method, TLSv1_1_server_method, TLSv1_1_client_method, SSLv23_method, SSLv23_server_method, SSLv23_client_method \- create a new SSL_CTX object as framework for TLS/SSL enabled functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& SSL_CTX *SSL_CTX_new(const SSL_METHOD *method); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_new()\fR creates a new \fB\s-1SSL_CTX\s0\fR object as framework to establish \&\s-1TLS/SSL\s0 enabled connections. .SH "NOTES" .IX Header "NOTES" The \s-1SSL_CTX\s0 object uses \fBmethod\fR as connection method. The methods exist in a generic type (for client and server use), a server only type, and a client only type. \fBmethod\fR can be of the following types: .IP "SSLv3_method(void), SSLv3_server_method(void), SSLv3_client_method(void)" 4 .IX Item "SSLv3_method(void), SSLv3_server_method(void), SSLv3_client_method(void)" A \s-1TLS/SSL\s0 connection established with these methods will only understand the SSLv3 protocol. A client will send out SSLv3 client hello messages and will indicate that it only understands SSLv3. A server will only understand SSLv3 client hello messages. This especially means, that it will not understand SSLv2 client hello messages which are widely used for compatibility reasons, see SSLv23_*\fI_method()\fR. .IP "TLSv1_method(void), TLSv1_server_method(void), TLSv1_client_method(void)" 4 .IX Item "TLSv1_method(void), TLSv1_server_method(void), TLSv1_client_method(void)" A \s-1TLS/SSL\s0 connection established with these methods will only understand the TLSv1 protocol. A client will send out TLSv1 client hello messages and will indicate that it only understands TLSv1. A server will only understand TLSv1 client hello messages. This especially means, that it will not understand SSLv2 client hello messages which are widely used for compatibility reasons, see SSLv23_*\fI_method()\fR. It will also not understand SSLv3 client hello messages. .IP "SSLv23_method(void), SSLv23_server_method(void), SSLv23_client_method(void)" 4 .IX Item "SSLv23_method(void), SSLv23_server_method(void), SSLv23_client_method(void)" A \s-1TLS/SSL\s0 connection established with these methods may understand the SSLv3, TLSv1, TLSv1.1 and TLSv1.2 protocols. .Sp A client will send out TLSv1 client hello messages including extensions and will indicate that it also understands TLSv1.1, TLSv1.2 and permits a fallback to SSLv3. A server will support SSLv3, TLSv1, TLSv1.1 and TLSv1.2 protocols. This is the best choice when compatibility is a concern. .PP The list of protocols available can later be limited using the SSL_OP_NO_SSLv3, SSL_OP_NO_TLSv1, SSL_OP_NO_TLSv1_1 and SSL_OP_NO_TLSv1_2 options of the \fISSL_CTX_set_options()\fR or \fISSL_set_options()\fR functions. Using these options it is possible to choose e.g. \fISSLv23_server_method()\fR and be able to negotiate with all possible clients, but to only allow newer protocols like TLSv1, TLSv1.1 or \s-1TLS\s0 v1.2. .PP \&\fISSL_CTX_new()\fR initializes the list of ciphers, the session cache setting, the callbacks, the keys and certificates and the options to its default values. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .IP "\s-1NULL\s0" 4 .IX Item "NULL" The creation of a new \s-1SSL_CTX\s0 object failed. Check the error stack to find out the reason. .IP "Pointer to an \s-1SSL_CTX\s0 object" 4 .IX Item "Pointer to an SSL_CTX object" The return value points to an allocated \s-1SSL_CTX\s0 object. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_CTX_free\fR\|(3), \fISSL_accept\fR\|(3), \&\fIssl\fR\|(3), \fISSL_set_connect_state\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/CMS_compress.30000644000175000017500000001515312360020713020133 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CMS_compress 3" .TH CMS_compress 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CMS_compress \- create a CMS CompressedData structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& CMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fICMS_compress()\fR creates and returns a \s-1CMS\s0 CompressedData structure. \fBcomp_nid\fR is the compression algorithm to use or \fBNID_undef\fR to use the default algorithm (zlib compression). \fBin\fR is the content to be compressed. \&\fBflags\fR is an optional set of flags. .SH "NOTES" .IX Header "NOTES" The only currently supported compression algorithm is zlib using the \s-1NID\s0 NID_zlib_compression. .PP If zlib support is not compiled into OpenSSL then \fICMS_compress()\fR will return an error. .PP If the \fB\s-1CMS_TEXT\s0\fR flag is set \s-1MIME\s0 headers for type \fBtext/plain\fR are prepended to the data. .PP Normally the supplied content is translated into \s-1MIME\s0 canonical format (as required by the S/MIME specifications) if \fB\s-1CMS_BINARY\s0\fR is set no translation occurs. This option should be used if the supplied data is in binary format otherwise the translation will corrupt it. If \fB\s-1CMS_BINARY\s0\fR is set then \&\fB\s-1CMS_TEXT\s0\fR is ignored. .PP If the \fB\s-1CMS_STREAM\s0\fR flag is set a partial \fBCMS_ContentInfo\fR structure is returned suitable for streaming I/O: no data is read from the \s-1BIO \s0\fBin\fR. .PP The compressed data is included in the CMS_ContentInfo structure, unless \&\fB\s-1CMS_DETACHED\s0\fR is set in which case it is omitted. This is rarely used in practice and is not supported by \fISMIME_write_CMS()\fR. .SH "NOTES" .IX Header "NOTES" If the flag \fB\s-1CMS_STREAM\s0\fR is set the returned \fBCMS_ContentInfo\fR structure is \&\fBnot\fR complete and outputting its contents via a function that does not properly finalize the \fBCMS_ContentInfo\fR structure will give unpredictable results. .PP Several functions including \fISMIME_write_CMS()\fR, \fIi2d_CMS_bio_stream()\fR, \&\fIPEM_write_bio_CMS_stream()\fR finalize the structure. Alternatively finalization can be performed by obtaining the streaming \s-1ASN1 \s0\fB\s-1BIO\s0\fR directly using \&\fIBIO_new_CMS()\fR. .PP Additional compression parameters such as the zlib compression level cannot currently be set. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICMS_compress()\fR returns either a CMS_ContentInfo structure or \s-1NULL\s0 if an error occurred. The error can be obtained from \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_uncompress\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fICMS_compress()\fR was added to OpenSSL 0.9.8 The \fB\s-1CMS_STREAM\s0\fR flag was first supported in OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/RSA_get_ex_new_index.30000644000175000017500000002330112360020724021612 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RSA_get_ex_new_index 3" .TH RSA_get_ex_new_index 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RSA_get_ex_new_index, RSA_set_ex_data, RSA_get_ex_data \- add application specific data to RSA structures .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int RSA_get_ex_new_index(long argl, void *argp, \& CRYPTO_EX_new *new_func, \& CRYPTO_EX_dup *dup_func, \& CRYPTO_EX_free *free_func); \& \& int RSA_set_ex_data(RSA *r, int idx, void *arg); \& \& void *RSA_get_ex_data(RSA *r, int idx); \& \& typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, \& int idx, long argl, void *argp); \& typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, \& int idx, long argl, void *argp); \& typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, \& int idx, long argl, void *argp); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Several OpenSSL structures can have application specific data attached to them. This has several potential uses, it can be used to cache data associated with a structure (for example the hash of some part of the structure) or some additional data (for example a handle to the data in an external library). .PP Since the application data can be anything at all it is passed and retrieved as a \fBvoid *\fR type. .PP The \fB\f(BIRSA_get_ex_new_index()\fB\fR function is initially called to \*(L"register\*(R" some new application specific data. It takes three optional function pointers which are called when the parent structure (in this case an \s-1RSA\s0 structure) is initially created, when it is copied and when it is freed up. If any or all of these function pointer arguments are not used they should be set to \s-1NULL.\s0 The precise manner in which these function pointers are called is described in more detail below. \fB\f(BIRSA_get_ex_new_index()\fB\fR also takes additional long and pointer parameters which will be passed to the supplied functions but which otherwise have no special meaning. It returns an \fBindex\fR which should be stored (typically in a static variable) and passed used in the \fBidx\fR parameter in the remaining functions. Each successful call to \fB\f(BIRSA_get_ex_new_index()\fB\fR will return an index greater than any previously returned, this is important because the optional functions are called in order of increasing index value. .PP \&\fB\f(BIRSA_set_ex_data()\fB\fR is used to set application specific data, the data is supplied in the \fBarg\fR parameter and its precise meaning is up to the application. .PP \&\fB\f(BIRSA_get_ex_data()\fB\fR is used to retrieve application specific data. The data is returned to the application, this will be the same value as supplied to a previous \fB\f(BIRSA_set_ex_data()\fB\fR call. .PP \&\fB\f(BInew_func()\fB\fR is called when a structure is initially allocated (for example with \fB\f(BIRSA_new()\fB\fR. The parent structure members will not have any meaningful values at this point. This function will typically be used to allocate any application specific structure. .PP \&\fB\f(BIfree_func()\fB\fR is called when a structure is being freed up. The dynamic parent structure members should not be accessed because they will be freed up when this function is called. .PP \&\fB\f(BInew_func()\fB\fR and \fB\f(BIfree_func()\fB\fR take the same parameters. \fBparent\fR is a pointer to the parent \s-1RSA\s0 structure. \fBptr\fR is a the application specific data (this wont be of much use in \fB\f(BInew_func()\fB\fR. \fBad\fR is a pointer to the \&\fB\s-1CRYPTO_EX_DATA\s0\fR structure from the parent \s-1RSA\s0 structure: the functions \&\fB\f(BICRYPTO_get_ex_data()\fB\fR and \fB\f(BICRYPTO_set_ex_data()\fB\fR can be called to manipulate it. The \fBidx\fR parameter is the index: this will be the same value returned by \&\fB\f(BIRSA_get_ex_new_index()\fB\fR when the functions were initially registered. Finally the \fBargl\fR and \fBargp\fR parameters are the values originally passed to the same corresponding parameters when \fB\f(BIRSA_get_ex_new_index()\fB\fR was called. .PP \&\fB\f(BIdup_func()\fB\fR is called when a structure is being copied. Pointers to the destination and source \fB\s-1CRYPTO_EX_DATA\s0\fR structures are passed in the \fBto\fR and \&\fBfrom\fR parameters respectively. The \fBfrom_d\fR parameter is passed a pointer to the source application data when the function is called, when the function returns the value is copied to the destination: the application can thus modify the data pointed to by \fBfrom_d\fR and have different values in the source and destination. The \fBidx\fR, \fBargl\fR and \fBargp\fR parameters are the same as those in \fB\f(BInew_func()\fB\fR and \fB\f(BIfree_func()\fB\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fB\f(BIRSA_get_ex_new_index()\fB\fR returns a new index or \-1 on failure (note 0 is a valid index value). .PP \&\fB\f(BIRSA_set_ex_data()\fB\fR returns 1 on success or 0 on failure. .PP \&\fB\f(BIRSA_get_ex_data()\fB\fR returns the application data or 0 on failure. 0 may also be valid application data but currently it can only fail if given an invalid \&\fBidx\fR parameter. .PP \&\fB\f(BInew_func()\fB\fR and \fB\f(BIdup_func()\fB\fR should return 0 for failure and 1 for success. .PP On failure an error code can be obtained from \&\fIERR_get_error\fR\|(3). .SH "BUGS" .IX Header "BUGS" \&\fB\f(BIdup_func()\fB\fR is currently never called. .PP The return value of \fB\f(BInew_func()\fB\fR is ignored. .PP The \fB\f(BInew_func()\fB\fR function isn't very useful because no meaningful values are present in the parent \s-1RSA\s0 structure when it is called. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIrsa\fR\|(3), \fICRYPTO_set_ex_data\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIRSA_get_ex_new_index()\fR, \fIRSA_set_ex_data()\fR and \fIRSA_get_ex_data()\fR are available since SSLeay 0.9.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_add_session.30000644000175000017500000001470112360020731021326 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_add_session 3" .TH SSL_CTX_add_session 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_add_session, SSL_add_session, SSL_CTX_remove_session, SSL_remove_session \- manipulate session cache .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *c); \& int SSL_add_session(SSL_CTX *ctx, SSL_SESSION *c); \& \& int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c); \& int SSL_remove_session(SSL_CTX *ctx, SSL_SESSION *c); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_add_session()\fR adds the session \fBc\fR to the context \fBctx\fR. The reference count for session \fBc\fR is incremented by 1. If a session with the same session id already exists, the old session is removed by calling \&\fISSL_SESSION_free\fR\|(3). .PP \&\fISSL_CTX_remove_session()\fR removes the session \fBc\fR from the context \fBctx\fR. \&\fISSL_SESSION_free\fR\|(3) is called once for \fBc\fR. .PP \&\fISSL_add_session()\fR and \fISSL_remove_session()\fR are synonyms for their SSL_CTX_*() counterparts. .SH "NOTES" .IX Header "NOTES" When adding a new session to the internal session cache, it is examined whether a session with the same session id already exists. In this case it is assumed that both sessions are identical. If the same session is stored in a different \s-1SSL_SESSION\s0 object, The old session is removed and replaced by the new session. If the session is actually identical (the \s-1SSL_SESSION\s0 object is identical), \fISSL_CTX_add_session()\fR is a no-op, and the return value is 0. .PP If a server \s-1SSL_CTX\s0 is configured with the \s-1SSL_SESS_CACHE_NO_INTERNAL_STORE\s0 flag then the internal cache will not be populated automatically by new sessions negotiated by the \s-1SSL/TLS\s0 implementation, even though the internal cache will be searched automatically for session-resume requests (the latter can be suppressed by \s-1SSL_SESS_CACHE_NO_INTERNAL_LOOKUP\s0). So the application can use \fISSL_CTX_add_session()\fR directly to have full control over the sessions that can be resumed if desired. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following values are returned by all functions: .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" .Vb 3 \& The operation failed. In case of the add operation, it was tried to add \& the same (identical) session twice. In case of the remove operation, the \& session was not found in the cache. .Ve .ie n .IP "1" 4 .el .IP "\f(CW1\fR" 4 .IX Item "1" .Vb 1 \& The operation succeeded. .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \&\fISSL_CTX_set_session_cache_mode\fR\|(3), \&\fISSL_SESSION_free\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/ERR_remove_state.30000644000175000017500000001242612360020717021007 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ERR_remove_state 3" .TH ERR_remove_state 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ERR_remove_thread_state, ERR_remove_state \- free a thread's error queue .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void ERR_remove_thread_state(const CRYPTO_THREADID *tid); .Ve .PP Deprecated: .PP .Vb 1 \& void ERR_remove_state(unsigned long pid); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIERR_remove_thread_state()\fR frees the error queue associated with thread \fBtid\fR. If \fBtid\fR == \fB\s-1NULL\s0\fR, the current thread will have its error queue removed. .PP Since error queue data structures are allocated automatically for new threads, they must be freed when threads are terminated in order to avoid memory leaks. .PP ERR_remove_state is deprecated and has been replaced by ERR_remove_thread_state. Since threads in OpenSSL are no longer identified by unsigned long values any argument to this function is ignored. Calling ERR_remove_state is equivalent to \fBERR_remove_thread_state(\s-1NULL\s0)\fR. .SH "RETURN VALUE" .IX Header "RETURN VALUE" ERR_remove_thread_state and \fIERR_remove_state()\fR return no value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIerr\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIERR_remove_state()\fR is available in all versions of SSLeay and OpenSSL. It was deprecated in OpenSSL 1.0.0 when ERR_remove_thread_state was introduced and thread IDs were introduced to identify threads instead of 'unsigned long'. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_accept.30000644000175000017500000001536612360020734017567 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_accept 3" .TH SSL_accept 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_accept \- wait for a TLS/SSL client to initiate a TLS/SSL handshake .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_accept(SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_accept()\fR waits for a \s-1TLS/SSL\s0 client to initiate the \s-1TLS/SSL\s0 handshake. The communication channel must already have been set and assigned to the \&\fBssl\fR by setting an underlying \fB\s-1BIO\s0\fR. .SH "NOTES" .IX Header "NOTES" The behaviour of \fISSL_accept()\fR depends on the underlying \s-1BIO.\s0 .PP If the underlying \s-1BIO\s0 is \fBblocking\fR, \fISSL_accept()\fR will only return once the handshake has been finished or an error occurred, except for \s-1SGC \s0(Server Gated Cryptography). For \s-1SGC,\s0 \fISSL_accept()\fR may return with \-1, but \&\fISSL_get_error()\fR will yield \fB\s-1SSL_ERROR_WANT_READ/WRITE\s0\fR and \fISSL_accept()\fR should be called again. .PP If the underlying \s-1BIO\s0 is \fBnon-blocking\fR, \fISSL_accept()\fR will also return when the underlying \s-1BIO\s0 could not satisfy the needs of \fISSL_accept()\fR to continue the handshake, indicating the problem by the return value \-1. In this case a call to \fISSL_get_error()\fR with the return value of \fISSL_accept()\fR will yield \fB\s-1SSL_ERROR_WANT_READ\s0\fR or \&\fB\s-1SSL_ERROR_WANT_WRITE\s0\fR. The calling process then must repeat the call after taking appropriate action to satisfy the needs of \fISSL_accept()\fR. The action depends on the underlying \s-1BIO.\s0 When using a non-blocking socket, nothing is to be done, but \fIselect()\fR can be used to check for the required condition. When using a buffering \s-1BIO,\s0 like a \s-1BIO\s0 pair, data must be written into or retrieved out of the \s-1BIO\s0 before being able to continue. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" The \s-1TLS/SSL\s0 handshake was not successful but was shut down controlled and by the specifications of the \s-1TLS/SSL\s0 protocol. Call \fISSL_get_error()\fR with the return value \fBret\fR to find out the reason. .ie n .IP "1" 4 .el .IP "\f(CW1\fR" 4 .IX Item "1" The \s-1TLS/SSL\s0 handshake was successfully completed, a \s-1TLS/SSL\s0 connection has been established. .IP "<0" 4 .IX Item "<0" The \s-1TLS/SSL\s0 handshake was not successful because a fatal error occurred either at the protocol level or a connection failure occurred. The shutdown was not clean. It can also occur of action is need to continue the operation for non-blocking BIOs. Call \fISSL_get_error()\fR with the return value \fBret\fR to find out the reason. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_get_error\fR\|(3), \fISSL_connect\fR\|(3), \&\fISSL_shutdown\fR\|(3), \fIssl\fR\|(3), \fIbio\fR\|(3), \&\fISSL_set_connect_state\fR\|(3), \&\fISSL_do_handshake\fR\|(3), \&\fISSL_CTX_new\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/ERR_error_string.30000644000175000017500000001473612360020717021037 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ERR_error_string 3" .TH ERR_error_string 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ERR_error_string, ERR_error_string_n, ERR_lib_error_string, ERR_func_error_string, ERR_reason_error_string \- obtain human\-readable error message .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& char *ERR_error_string(unsigned long e, char *buf); \& void ERR_error_string_n(unsigned long e, char *buf, size_t len); \& \& const char *ERR_lib_error_string(unsigned long e); \& const char *ERR_func_error_string(unsigned long e); \& const char *ERR_reason_error_string(unsigned long e); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIERR_error_string()\fR generates a human-readable string representing the error code \fIe\fR, and places it at \fIbuf\fR. \fIbuf\fR must be at least 120 bytes long. If \fIbuf\fR is \fB\s-1NULL\s0\fR, the error string is placed in a static buffer. \&\fIERR_error_string_n()\fR is a variant of \fIERR_error_string()\fR that writes at most \fIlen\fR characters (including the terminating 0) and truncates the string if necessary. For \fIERR_error_string_n()\fR, \fIbuf\fR may not be \fB\s-1NULL\s0\fR. .PP The string will have the following format: .PP .Vb 1 \& error:[error code]:[library name]:[function name]:[reason string] .Ve .PP \&\fIerror code\fR is an 8 digit hexadecimal number, \fIlibrary name\fR, \&\fIfunction name\fR and \fIreason string\fR are \s-1ASCII\s0 text. .PP \&\fIERR_lib_error_string()\fR, \fIERR_func_error_string()\fR and \&\fIERR_reason_error_string()\fR return the library name, function name and reason string respectively. .PP The OpenSSL error strings should be loaded by calling \&\fIERR_load_crypto_strings\fR\|(3) or, for \s-1SSL\s0 applications, \fISSL_load_error_strings\fR\|(3) first. If there is no text string registered for the given error code, the error string will contain the numeric code. .PP \&\fIERR_print_errors\fR\|(3) can be used to print all error codes currently in the queue. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIERR_error_string()\fR returns a pointer to a static buffer containing the string if \fIbuf\fR \fB== \s-1NULL\s0\fR, \fIbuf\fR otherwise. .PP \&\fIERR_lib_error_string()\fR, \fIERR_func_error_string()\fR and \&\fIERR_reason_error_string()\fR return the strings, and \fB\s-1NULL\s0\fR if none is registered for the error code. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIerr\fR\|(3), \fIERR_get_error\fR\|(3), \&\fIERR_load_crypto_strings\fR\|(3), \&\fISSL_load_error_strings\fR\|(3) \&\fIERR_print_errors\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIERR_error_string()\fR is available in all versions of SSLeay and OpenSSL. \&\fIERR_error_string_n()\fR was added in OpenSSL 0.9.6. deps/libressl-pnacl-sys-2.1.6/libressl/man/PKCS7_verify.30000644000175000017500000002154012360020723020007 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PKCS7_verify 3" .TH PKCS7_verify 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PKCS7_verify, PKCS7_get0_signers \- verify a PKCS#7 signedData structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, BIO *indata, BIO *out, int flags); \& \& STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIPKCS7_verify()\fR verifies a PKCS#7 signedData structure. \fBp7\fR is the \s-1PKCS7\s0 structure to verify. \fBcerts\fR is a set of certificates in which to search for the signer's certificate. \fBstore\fR is a trusted certficate store (used for chain verification). \fBindata\fR is the signed data if the content is not present in \fBp7\fR (that is it is detached). The content is written to \fBout\fR if it is not \s-1NULL.\s0 .PP \&\fBflags\fR is an optional set of flags, which can be used to modify the verify operation. .PP \&\fIPKCS7_get0_signers()\fR retrieves the signer's certificates from \fBp7\fR, it does \&\fBnot\fR check their validity or whether any signatures are valid. The \fBcerts\fR and \fBflags\fR parameters have the same meanings as in \fIPKCS7_verify()\fR. .SH "VERIFY PROCESS" .IX Header "VERIFY PROCESS" Normally the verify process proceeds as follows. .PP Initially some sanity checks are performed on \fBp7\fR. The type of \fBp7\fR must be signedData. There must be at least one signature on the data and if the content is detached \fBindata\fR cannot be \fB\s-1NULL\s0\fR. .PP An attempt is made to locate all the signer's certificates, first looking in the \fBcerts\fR parameter (if it is not \fB\s-1NULL\s0\fR) and then looking in any certificates contained in the \fBp7\fR structure itself. If any signer's certificates cannot be located the operation fails. .PP Each signer's certificate is chain verified using the \fBsmimesign\fR purpose and the supplied trusted certificate store. Any internal certificates in the message are used as untrusted CAs. If any chain verify fails an error code is returned. .PP Finally the signed content is read (and written to \fBout\fR is it is not \s-1NULL\s0) and the signature's checked. .PP If all signature's verify correctly then the function is successful. .PP Any of the following flags (ored together) can be passed in the \fBflags\fR parameter to change the default verify behaviour. Only the flag \&\fB\s-1PKCS7_NOINTERN\s0\fR is meaningful to \fIPKCS7_get0_signers()\fR. .PP If \fB\s-1PKCS7_NOINTERN\s0\fR is set the certificates in the message itself are not searched when locating the signer's certificate. This means that all the signers certificates must be in the \fBcerts\fR parameter. .PP If the \fB\s-1PKCS7_TEXT\s0\fR flag is set \s-1MIME\s0 headers for type \fBtext/plain\fR are deleted from the content. If the content is not of type \fBtext/plain\fR then an error is returned. .PP If \fB\s-1PKCS7_NOVERIFY\s0\fR is set the signer's certificates are not chain verified. .PP If \fB\s-1PKCS7_NOCHAIN\s0\fR is set then the certificates contained in the message are not used as untrusted CAs. This means that the whole verify chain (apart from the signer's certificate) must be contained in the trusted store. .PP If \fB\s-1PKCS7_NOSIGS\s0\fR is set then the signatures on the data are not checked. .SH "NOTES" .IX Header "NOTES" One application of \fB\s-1PKCS7_NOINTERN\s0\fR is to only accept messages signed by a small number of certificates. The acceptable certificates would be passed in the \fBcerts\fR parameter. In this case if the signer is not one of the certificates supplied in \fBcerts\fR then the verify will fail because the signer cannot be found. .PP Care should be taken when modifying the default verify behaviour, for example setting \fBPKCS7_NOVERIFY|PKCS7_NOSIGS\fR will totally disable all verification and any signed message will be considered valid. This combination is however useful if one merely wishes to write the content to \fBout\fR and its validity is not considered important. .PP Chain verification should arguably be performed using the signing time rather than the current time. However since the signing time is supplied by the signer it cannot be trusted without additional evidence (such as a trusted timestamp). .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIPKCS7_verify()\fR returns 1 for a successful verification and zero or a negative value if an error occurs. .PP \&\fIPKCS7_get0_signers()\fR returns all signers or \fB\s-1NULL\s0\fR if an error occurred. .PP The error can be obtained from \fIERR_get_error\fR\|(3) .SH "BUGS" .IX Header "BUGS" The trusted certificate store is not searched for the signers certificate, this is primarily due to the inadequacies of the current \fBX509_STORE\fR functionality. .PP The lack of single pass processing and need to hold all data in memory as mentioned in \fIPKCS7_sign()\fR also applies to \fIPKCS7_verify()\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fIPKCS7_sign\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIPKCS7_verify()\fR was added to OpenSSL 0.9.5 deps/libressl-pnacl-sys-2.1.6/libressl/man/bn_internal.30000644000175000017500000003533312360020726020077 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "bn_internal 3" .TH bn_internal 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" bn_mul_words, bn_mul_add_words, bn_sqr_words, bn_div_words, bn_add_words, bn_sub_words, bn_mul_comba4, bn_mul_comba8, bn_sqr_comba4, bn_sqr_comba8, bn_cmp_words, bn_mul_normal, bn_mul_low_normal, bn_mul_recursive, bn_mul_part_recursive, bn_mul_low_recursive, bn_mul_high, bn_sqr_normal, bn_sqr_recursive, bn_expand, bn_wexpand, bn_expand2, bn_fix_top, bn_check_top, bn_print, bn_dump, bn_set_max, bn_set_high, bn_set_low \- BIGNUM library internal functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w); \& BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, \& BN_ULONG w); \& void bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num); \& BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d); \& BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp, \& int num); \& BN_ULONG bn_sub_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp, \& int num); \& \& void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b); \& void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b); \& void bn_sqr_comba4(BN_ULONG *r, BN_ULONG *a); \& void bn_sqr_comba8(BN_ULONG *r, BN_ULONG *a); \& \& int bn_cmp_words(BN_ULONG *a, BN_ULONG *b, int n); \& \& void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, \& int nb); \& void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n); \& void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, \& int dna,int dnb,BN_ULONG *tmp); \& void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, \& int n, int tna,int tnb, BN_ULONG *tmp); \& void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, \& int n2, BN_ULONG *tmp); \& void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, \& int n2, BN_ULONG *tmp); \& \& void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp); \& void bn_sqr_recursive(BN_ULONG *r, BN_ULONG *a, int n2, BN_ULONG *tmp); \& \& void mul(BN_ULONG r, BN_ULONG a, BN_ULONG w, BN_ULONG c); \& void mul_add(BN_ULONG r, BN_ULONG a, BN_ULONG w, BN_ULONG c); \& void sqr(BN_ULONG r0, BN_ULONG r1, BN_ULONG a); \& \& BIGNUM *bn_expand(BIGNUM *a, int bits); \& BIGNUM *bn_wexpand(BIGNUM *a, int n); \& BIGNUM *bn_expand2(BIGNUM *a, int n); \& void bn_fix_top(BIGNUM *a); \& \& void bn_check_top(BIGNUM *a); \& void bn_print(BIGNUM *a); \& void bn_dump(BN_ULONG *d, int n); \& void bn_set_max(BIGNUM *a); \& void bn_set_high(BIGNUM *r, BIGNUM *a, int n); \& void bn_set_low(BIGNUM *r, BIGNUM *a, int n); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This page documents the internal functions used by the OpenSSL \&\fB\s-1BIGNUM\s0\fR implementation. They are described here to facilitate debugging and extending the library. They are \fInot\fR to be used by applications. .SS "The \s-1BIGNUM\s0 structure" .IX Subsection "The BIGNUM structure" .Vb 1 \& typedef struct bignum_st BIGNUM; \& \& struct bignum_st \& { \& BN_ULONG *d; /* Pointer to an array of \*(AqBN_BITS2\*(Aq bit chunks. */ \& int top; /* Index of last used d +1. */ \& /* The next are internal book keeping for bn_expand. */ \& int dmax; /* Size of the d array. */ \& int neg; /* one if the number is negative */ \& int flags; \& }; .Ve .PP The integer value is stored in \fBd\fR, a \fImalloc()\fRed array of words (\fB\s-1BN_ULONG\s0\fR), least significant word first. A \fB\s-1BN_ULONG\s0\fR can be either 16, 32 or 64 bits in size, depending on the 'number of bits' (\fB\s-1BITS2\s0\fR) specified in \&\f(CW\*(C`openssl/bn.h\*(C'\fR. .PP \&\fBdmax\fR is the size of the \fBd\fR array that has been allocated. \fBtop\fR is the number of words being used, so for a value of 4, bn.d[0]=4 and bn.top=1. \fBneg\fR is 1 if the number is negative. When a \fB\s-1BIGNUM\s0\fR is \&\fB0\fR, the \fBd\fR field can be \fB\s-1NULL\s0\fR and \fBtop\fR == \fB0\fR. .PP \&\fBflags\fR is a bit field of flags which are defined in \f(CW\*(C`openssl/bn.h\*(C'\fR. The flags begin with \fB\s-1BN_FLG_\s0\fR. The macros BN_set_flags(b,n) and BN_get_flags(b,n) exist to enable or fetch flag(s) \fBn\fR from \fB\s-1BIGNUM\s0\fR structure \fBb\fR. .PP Various routines in this library require the use of temporary \&\fB\s-1BIGNUM\s0\fR variables during their execution. Since dynamic memory allocation to create \fB\s-1BIGNUM\s0\fRs is rather expensive when used in conjunction with repeated subroutine calls, the \fB\s-1BN_CTX\s0\fR structure is used. This structure contains \fB\s-1BN_CTX_NUM\s0\fR \fB\s-1BIGNUM\s0\fRs, see \&\fIBN_CTX_start\fR\|(3). .SS "Low-level arithmetic operations" .IX Subsection "Low-level arithmetic operations" These functions are implemented in C and for several platforms in assembly language: .PP bn_mul_words(\fBrp\fR, \fBap\fR, \fBnum\fR, \fBw\fR) operates on the \fBnum\fR word arrays \fBrp\fR and \fBap\fR. It computes \fBap\fR * \fBw\fR, places the result in \fBrp\fR, and returns the high word (carry). .PP bn_mul_add_words(\fBrp\fR, \fBap\fR, \fBnum\fR, \fBw\fR) operates on the \fBnum\fR word arrays \fBrp\fR and \fBap\fR. It computes \fBap\fR * \fBw\fR + \fBrp\fR, places the result in \fBrp\fR, and returns the high word (carry). .PP bn_sqr_words(\fBrp\fR, \fBap\fR, \fBn\fR) operates on the \fBnum\fR word array \&\fBap\fR and the 2*\fBnum\fR word array \fBap\fR. It computes \fBap\fR * \fBap\fR word-wise, and places the low and high bytes of the result in \fBrp\fR. .PP bn_div_words(\fBh\fR, \fBl\fR, \fBd\fR) divides the two word number (\fBh\fR,\fBl\fR) by \fBd\fR and returns the result. .PP bn_add_words(\fBrp\fR, \fBap\fR, \fBbp\fR, \fBnum\fR) operates on the \fBnum\fR word arrays \fBap\fR, \fBbp\fR and \fBrp\fR. It computes \fBap\fR + \fBbp\fR, places the result in \fBrp\fR, and returns the high word (carry). .PP bn_sub_words(\fBrp\fR, \fBap\fR, \fBbp\fR, \fBnum\fR) operates on the \fBnum\fR word arrays \fBap\fR, \fBbp\fR and \fBrp\fR. It computes \fBap\fR \- \fBbp\fR, places the result in \fBrp\fR, and returns the carry (1 if \fBbp\fR > \fBap\fR, 0 otherwise). .PP bn_mul_comba4(\fBr\fR, \fBa\fR, \fBb\fR) operates on the 4 word arrays \fBa\fR and \&\fBb\fR and the 8 word array \fBr\fR. It computes \fBa\fR*\fBb\fR and places the result in \fBr\fR. .PP bn_mul_comba8(\fBr\fR, \fBa\fR, \fBb\fR) operates on the 8 word arrays \fBa\fR and \&\fBb\fR and the 16 word array \fBr\fR. It computes \fBa\fR*\fBb\fR and places the result in \fBr\fR. .PP bn_sqr_comba4(\fBr\fR, \fBa\fR, \fBb\fR) operates on the 4 word arrays \fBa\fR and \&\fBb\fR and the 8 word array \fBr\fR. .PP bn_sqr_comba8(\fBr\fR, \fBa\fR, \fBb\fR) operates on the 8 word arrays \fBa\fR and \&\fBb\fR and the 16 word array \fBr\fR. .PP The following functions are implemented in C: .PP bn_cmp_words(\fBa\fR, \fBb\fR, \fBn\fR) operates on the \fBn\fR word arrays \fBa\fR and \fBb\fR. It returns 1, 0 and \-1 if \fBa\fR is greater than, equal and less than \fBb\fR. .PP bn_mul_normal(\fBr\fR, \fBa\fR, \fBna\fR, \fBb\fR, \fBnb\fR) operates on the \fBna\fR word array \fBa\fR, the \fBnb\fR word array \fBb\fR and the \fBna\fR+\fBnb\fR word array \fBr\fR. It computes \fBa\fR*\fBb\fR and places the result in \fBr\fR. .PP bn_mul_low_normal(\fBr\fR, \fBa\fR, \fBb\fR, \fBn\fR) operates on the \fBn\fR word arrays \fBr\fR, \fBa\fR and \fBb\fR. It computes the \fBn\fR low words of \&\fBa\fR*\fBb\fR and places the result in \fBr\fR. .PP bn_mul_recursive(\fBr\fR, \fBa\fR, \fBb\fR, \fBn2\fR, \fBdna\fR, \fBdnb\fR, \fBt\fR) operates on the word arrays \fBa\fR and \fBb\fR of length \fBn2\fR+\fBdna\fR and \fBn2\fR+\fBdnb\fR (\fBdna\fR and \fBdnb\fR are currently allowed to be 0 or negative) and the 2*\fBn2\fR word arrays \fBr\fR and \fBt\fR. \fBn2\fR must be a power of 2. It computes \&\fBa\fR*\fBb\fR and places the result in \fBr\fR. .PP bn_mul_part_recursive(\fBr\fR, \fBa\fR, \fBb\fR, \fBn\fR, \fBtna\fR, \fBtnb\fR, \fBtmp\fR) operates on the word arrays \fBa\fR and \fBb\fR of length \fBn\fR+\fBtna\fR and \&\fBn\fR+\fBtnb\fR and the 4*\fBn\fR word arrays \fBr\fR and \fBtmp\fR. .PP bn_mul_low_recursive(\fBr\fR, \fBa\fR, \fBb\fR, \fBn2\fR, \fBtmp\fR) operates on the \&\fBn2\fR word arrays \fBr\fR and \fBtmp\fR and the \fBn2\fR/2 word arrays \fBa\fR and \fBb\fR. .PP bn_mul_high(\fBr\fR, \fBa\fR, \fBb\fR, \fBl\fR, \fBn2\fR, \fBtmp\fR) operates on the \&\fBn2\fR word arrays \fBr\fR, \fBa\fR, \fBb\fR and \fBl\fR (?) and the 3*\fBn2\fR word array \fBtmp\fR. .PP \&\fIBN_mul()\fR calls \fIbn_mul_normal()\fR, or an optimized implementation if the factors have the same size: \fIbn_mul_comba8()\fR is used if they are 8 words long, \fIbn_mul_recursive()\fR if they are larger than \&\fB\s-1BN_MULL_SIZE_NORMAL\s0\fR and the size is an exact multiple of the word size, and \fIbn_mul_part_recursive()\fR for others that are larger than \&\fB\s-1BN_MULL_SIZE_NORMAL\s0\fR. .PP bn_sqr_normal(\fBr\fR, \fBa\fR, \fBn\fR, \fBtmp\fR) operates on the \fBn\fR word array \&\fBa\fR and the 2*\fBn\fR word arrays \fBtmp\fR and \fBr\fR. .PP The implementations use the following macros which, depending on the architecture, may use \*(L"long long\*(R" C operations or inline assembler. They are defined in \f(CW\*(C`bn_lcl.h\*(C'\fR. .PP mul(\fBr\fR, \fBa\fR, \fBw\fR, \fBc\fR) computes \fBw\fR*\fBa\fR+\fBc\fR and places the low word of the result in \fBr\fR and the high word in \fBc\fR. .PP mul_add(\fBr\fR, \fBa\fR, \fBw\fR, \fBc\fR) computes \fBw\fR*\fBa\fR+\fBr\fR+\fBc\fR and places the low word of the result in \fBr\fR and the high word in \fBc\fR. .PP sqr(\fBr0\fR, \fBr1\fR, \fBa\fR) computes \fBa\fR*\fBa\fR and places the low word of the result in \fBr0\fR and the high word in \fBr1\fR. .SS "Size changes" .IX Subsection "Size changes" \&\fIbn_expand()\fR ensures that \fBb\fR has enough space for a \fBbits\fR bit number. \fIbn_wexpand()\fR ensures that \fBb\fR has enough space for an \&\fBn\fR word number. If the number has to be expanded, both macros call \fIbn_expand2()\fR, which allocates a new \fBd\fR array and copies the data. They return \fB\s-1NULL\s0\fR on error, \fBb\fR otherwise. .PP The \fIbn_fix_top()\fR macro reduces \fBa\->top\fR to point to the most significant non-zero word plus one when \fBa\fR has shrunk. .SS "Debugging" .IX Subsection "Debugging" \&\fIbn_check_top()\fR verifies that \f(CW\*(C`((a)\->top >= 0 && (a)\->top <= (a)\->dmax)\*(C'\fR. A violation will cause the program to abort. .PP \&\fIbn_print()\fR prints \fBa\fR to stderr. \fIbn_dump()\fR prints \fBn\fR words at \fBd\fR (in reverse order, i.e. most significant word first) to stderr. .PP \&\fIbn_set_max()\fR makes \fBa\fR a static number with a \fBdmax\fR of its current size. This is used by \fIbn_set_low()\fR and \fIbn_set_high()\fR to make \fBr\fR a read-only \&\fB\s-1BIGNUM\s0\fR that contains the \fBn\fR low or high words of \fBa\fR. .PP If \fB\s-1BN_DEBUG\s0\fR is not defined, \fIbn_check_top()\fR, \fIbn_print()\fR, \fIbn_dump()\fR and \fIbn_set_max()\fR are defined as empty macros. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/sess_id.10000644000175000017500000002044312360020743017226 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "sess_id 1" .TH sess_id 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" sess_id \- SSL/TLS session handling utility .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBsess_id\fR [\fB\-inform PEM|DER\fR] [\fB\-outform PEM|DER\fR] [\fB\-in filename\fR] [\fB\-out filename\fR] [\fB\-text\fR] [\fB\-noout\fR] [\fB\-context \s-1ID\s0\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBsess_id\fR process the encoded version of the \s-1SSL\s0 session structure and optionally prints out \s-1SSL\s0 session details (for example the \s-1SSL\s0 session master key) in human readable format. Since this is a diagnostic tool that needs some knowledge of the \s-1SSL\s0 protocol to use properly, most users will not need to use it. .IP "\fB\-inform DER|PEM\fR" 4 .IX Item "-inform DER|PEM" This specifies the input format. The \fB\s-1DER\s0\fR option uses an \s-1ASN1 DER\s0 encoded format containing session details. The precise format can vary from one version to the next. The \fB\s-1PEM\s0\fR form is the default format: it consists of the \fB\s-1DER\s0\fR format base64 encoded with additional header and footer lines. .IP "\fB\-outform DER|PEM\fR" 4 .IX Item "-outform DER|PEM" This specifies the output format, the options have the same meaning as the \&\fB\-inform\fR option. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read session information from or standard input by default. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" This specifies the output filename to write session information to or standard output if this option is not specified. .IP "\fB\-text\fR" 4 .IX Item "-text" prints out the various public or private key components in plain text in addition to the encoded version. .IP "\fB\-cert\fR" 4 .IX Item "-cert" if a certificate is present in the session it will be output using this option, if the \fB\-text\fR option is also present then it will be printed out in text form. .IP "\fB\-noout\fR" 4 .IX Item "-noout" this option prevents output of the encoded version of the session. .IP "\fB\-context \s-1ID\s0\fR" 4 .IX Item "-context ID" this option can set the session id so the output session information uses the supplied \s-1ID.\s0 The \s-1ID\s0 can be any string of characters. This option wont normally be used. .SH "OUTPUT" .IX Header "OUTPUT" Typical output: .PP .Vb 10 \& SSL\-Session: \& Protocol : TLSv1 \& Cipher : 0016 \& Session\-ID: 871E62626C554CE95488823752CBD5F3673A3EF3DCE9C67BD916C809914B40ED \& Session\-ID\-ctx: 01000000 \& Master\-Key: A7CEFC571974BE02CAC305269DC59F76EA9F0B180CB6642697A68251F2D2BB57E51DBBB4C7885573192AE9AEE220FACD \& Key\-Arg : None \& Start Time: 948459261 \& Timeout : 300 (sec) \& Verify return code 0 (ok) .Ve .PP Theses are described below in more detail. .IP "\fBProtocol\fR" 4 .IX Item "Protocol" this is the protocol in use TLSv1, SSLv3 or SSLv2. .IP "\fBCipher\fR" 4 .IX Item "Cipher" the cipher used this is the actual raw \s-1SSL\s0 or \s-1TLS\s0 cipher code, see the \s-1SSL\s0 or \s-1TLS\s0 specifications for more information. .IP "\fBSession-ID\fR" 4 .IX Item "Session-ID" the \s-1SSL\s0 session \s-1ID\s0 in hex format. .IP "\fBSession-ID-ctx\fR" 4 .IX Item "Session-ID-ctx" the session \s-1ID\s0 context in hex format. .IP "\fBMaster-Key\fR" 4 .IX Item "Master-Key" this is the \s-1SSL\s0 session master key. .IP "\fBKey-Arg\fR" 4 .IX Item "Key-Arg" the key argument, this is only used in \s-1SSL\s0 v2. .IP "\fBStart Time\fR" 4 .IX Item "Start Time" this is the session start time represented as an integer in standard Unix format. .IP "\fBTimeout\fR" 4 .IX Item "Timeout" the timeout in seconds. .IP "\fBVerify return code\fR" 4 .IX Item "Verify return code" this is the return code when an \s-1SSL\s0 client certificate is verified. .SH "NOTES" .IX Header "NOTES" The \s-1PEM\s0 encoded session format uses the header and footer lines: .PP .Vb 2 \& \-\-\-\-\-BEGIN SSL SESSION PARAMETERS\-\-\-\-\- \& \-\-\-\-\-END SSL SESSION PARAMETERS\-\-\-\-\- .Ve .PP Since the \s-1SSL\s0 session output contains the master key it is possible to read the contents of an encrypted session using this information. Therefore appropriate security precautions should be taken if the information is being output by a \*(L"real\*(R" application. This is however strongly discouraged and should only be used for debugging purposes. .SH "BUGS" .IX Header "BUGS" The cipher and start time should be printed out in human readable form. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIciphers\fR\|(1), \fIs_server\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/RSA_set_method.30000644000175000017500000003144012360020724020435 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RSA_set_method 3" .TH RSA_set_method 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RSA_set_default_method, RSA_get_default_method, RSA_set_method, RSA_get_method, RSA_PKCS1_SSLeay, RSA_null_method, RSA_flags, RSA_new_method \- select RSA method .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void RSA_set_default_method(const RSA_METHOD *meth); \& \& RSA_METHOD *RSA_get_default_method(void); \& \& int RSA_set_method(RSA *rsa, const RSA_METHOD *meth); \& \& RSA_METHOD *RSA_get_method(const RSA *rsa); \& \& RSA_METHOD *RSA_PKCS1_SSLeay(void); \& \& RSA_METHOD *RSA_null_method(void); \& \& int RSA_flags(const RSA *rsa); \& \& RSA *RSA_new_method(RSA_METHOD *method); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" An \fB\s-1RSA_METHOD\s0\fR specifies the functions that OpenSSL uses for \s-1RSA\s0 operations. By modifying the method, alternative implementations such as hardware accelerators may be used. \s-1IMPORTANT:\s0 See the \s-1NOTES\s0 section for important information about how these \s-1RSA API\s0 functions are affected by the use of \fB\s-1ENGINE\s0\fR \s-1API\s0 calls. .PP Initially, the default \s-1RSA_METHOD\s0 is the OpenSSL internal implementation, as returned by \fIRSA_PKCS1_SSLeay()\fR. .PP \&\fIRSA_set_default_method()\fR makes \fBmeth\fR the default method for all \s-1RSA\s0 structures created later. \fB\s-1NB\s0\fR: This is true only whilst no \s-1ENGINE\s0 has been set as a default for \s-1RSA,\s0 so this function is no longer recommended. .PP \&\fIRSA_get_default_method()\fR returns a pointer to the current default \&\s-1RSA_METHOD.\s0 However, the meaningfulness of this result is dependent on whether the \s-1ENGINE API\s0 is being used, so this function is no longer recommended. .PP \&\fIRSA_set_method()\fR selects \fBmeth\fR to perform all operations using the key \&\fBrsa\fR. This will replace the \s-1RSA_METHOD\s0 used by the \s-1RSA\s0 key and if the previous method was supplied by an \s-1ENGINE,\s0 the handle to that \s-1ENGINE\s0 will be released during the change. It is possible to have \s-1RSA\s0 keys that only work with certain \s-1RSA_METHOD\s0 implementations (eg. from an \s-1ENGINE\s0 module that supports embedded hardware-protected keys), and in such cases attempting to change the \s-1RSA_METHOD\s0 for the key can have unexpected results. .PP \&\fIRSA_get_method()\fR returns a pointer to the \s-1RSA_METHOD\s0 being used by \fBrsa\fR. This method may or may not be supplied by an \s-1ENGINE\s0 implementation, but if it is, the return value can only be guaranteed to be valid as long as the \&\s-1RSA\s0 key itself is valid and does not have its implementation changed by \&\fIRSA_set_method()\fR. .PP \&\fIRSA_flags()\fR returns the \fBflags\fR that are set for \fBrsa\fR's current \&\s-1RSA_METHOD.\s0 See the \s-1BUGS\s0 section. .PP \&\fIRSA_new_method()\fR allocates and initializes an \s-1RSA\s0 structure so that \&\fBengine\fR will be used for the \s-1RSA\s0 operations. If \fBengine\fR is \s-1NULL,\s0 the default \s-1ENGINE\s0 for \s-1RSA\s0 operations is used, and if no default \s-1ENGINE\s0 is set, the \s-1RSA_METHOD\s0 controlled by \fIRSA_set_default_method()\fR is used. .PP \&\fIRSA_flags()\fR returns the \fBflags\fR that are set for \fBrsa\fR's current method. .PP \&\fIRSA_new_method()\fR allocates and initializes an \fB\s-1RSA\s0\fR structure so that \&\fBmethod\fR will be used for the \s-1RSA\s0 operations. If \fBmethod\fR is \fB\s-1NULL\s0\fR, the default method is used. .SH "THE RSA_METHOD STRUCTURE" .IX Header "THE RSA_METHOD STRUCTURE" .Vb 4 \& typedef struct rsa_meth_st \& { \& /* name of the implementation */ \& const char *name; \& \& /* encrypt */ \& int (*rsa_pub_enc)(int flen, unsigned char *from, \& unsigned char *to, RSA *rsa, int padding); \& \& /* verify arbitrary data */ \& int (*rsa_pub_dec)(int flen, unsigned char *from, \& unsigned char *to, RSA *rsa, int padding); \& \& /* sign arbitrary data */ \& int (*rsa_priv_enc)(int flen, unsigned char *from, \& unsigned char *to, RSA *rsa, int padding); \& \& /* decrypt */ \& int (*rsa_priv_dec)(int flen, unsigned char *from, \& unsigned char *to, RSA *rsa, int padding); \& \& /* compute r0 = r0 ^ I mod rsa\->n (May be NULL for some \& implementations) */ \& int (*rsa_mod_exp)(BIGNUM *r0, BIGNUM *I, RSA *rsa); \& \& /* compute r = a ^ p mod m (May be NULL for some implementations) */ \& int (*bn_mod_exp)(BIGNUM *r, BIGNUM *a, const BIGNUM *p, \& const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); \& \& /* called at RSA_new */ \& int (*init)(RSA *rsa); \& \& /* called at RSA_free */ \& int (*finish)(RSA *rsa); \& \& /* RSA_FLAG_EXT_PKEY \- rsa_mod_exp is called for private key \& * operations, even if p,q,dmp1,dmq1,iqmp \& * are NULL \& * RSA_FLAG_SIGN_VER \- enable rsa_sign and rsa_verify \& * RSA_METHOD_FLAG_NO_CHECK \- don\*(Aqt check pub/private match \& */ \& int flags; \& \& char *app_data; /* ?? */ \& \& /* sign. For backward compatibility, this is used only \& * if (flags & RSA_FLAG_SIGN_VER) \& */ \& int (*rsa_sign)(int type, unsigned char *m, unsigned int m_len, \& unsigned char *sigret, unsigned int *siglen, RSA *rsa); \& \& /* verify. For backward compatibility, this is used only \& * if (flags & RSA_FLAG_SIGN_VER) \& */ \& int (*rsa_verify)(int type, unsigned char *m, unsigned int m_len, \& unsigned char *sigbuf, unsigned int siglen, RSA *rsa); \& \& } RSA_METHOD; .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIRSA_PKCS1_SSLeay()\fR, \fIRSA_PKCS1_null_method()\fR, \fIRSA_get_default_method()\fR and \fIRSA_get_method()\fR return pointers to the respective RSA_METHODs. .PP \&\fIRSA_set_default_method()\fR returns no value. .PP \&\fIRSA_set_method()\fR returns a pointer to the old \s-1RSA_METHOD\s0 implementation that was replaced. However, this return value should probably be ignored because if it was supplied by an \s-1ENGINE,\s0 the pointer could be invalidated at any time if the \s-1ENGINE\s0 is unloaded (in fact it could be unloaded as a result of the \fIRSA_set_method()\fR function releasing its handle to the \&\s-1ENGINE\s0). For this reason, the return type may be replaced with a \fBvoid\fR declaration in a future release. .PP \&\fIRSA_new_method()\fR returns \s-1NULL\s0 and sets an error code that can be obtained by \fIERR_get_error\fR\|(3) if the allocation fails. Otherwise it returns a pointer to the newly allocated structure. .SH "NOTES" .IX Header "NOTES" As of version 0.9.7, \s-1RSA_METHOD\s0 implementations are grouped together with other algorithmic APIs (eg. \s-1DSA_METHOD, EVP_CIPHER,\s0 etc) into \fB\s-1ENGINE\s0\fR modules. If a default \s-1ENGINE\s0 is specified for \s-1RSA\s0 functionality using an \&\s-1ENGINE API\s0 function, that will override any \s-1RSA\s0 defaults set using the \s-1RSA API \s0(ie. \fIRSA_set_default_method()\fR). For this reason, the \s-1ENGINE API\s0 is the recommended way to control default implementations for use in \s-1RSA\s0 and other cryptographic algorithms. .SH "BUGS" .IX Header "BUGS" The behaviour of \fIRSA_flags()\fR is a mis-feature that is left as-is for now to avoid creating compatibility problems. \s-1RSA\s0 functionality, such as the encryption functions, are controlled by the \fBflags\fR value in the \s-1RSA\s0 key itself, not by the \fBflags\fR value in the \s-1RSA_METHOD\s0 attached to the \s-1RSA\s0 key (which is what this function returns). If the flags element of an \s-1RSA\s0 key is changed, the changes will be honoured by \s-1RSA\s0 functionality but will not be reflected in the return value of the \fIRSA_flags()\fR function \- in effect \&\fIRSA_flags()\fR behaves more like an \fIRSA_default_flags()\fR function (which does not currently exist). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIrsa\fR\|(3), \fIRSA_new\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIRSA_new_method()\fR and \fIRSA_set_default_method()\fR appeared in SSLeay 0.8. \&\fIRSA_get_default_method()\fR, \fIRSA_set_method()\fR and \fIRSA_get_method()\fR as well as the rsa_sign and rsa_verify components of \s-1RSA_METHOD\s0 were added in OpenSSL 0.9.4. .PP \&\fIRSA_set_default_openssl_method()\fR and \fIRSA_get_default_openssl_method()\fR replaced \fIRSA_set_default_method()\fR and \fIRSA_get_default_method()\fR respectively, and \fIRSA_set_method()\fR and \fIRSA_new_method()\fR were altered to use \&\fB\s-1ENGINE\s0\fRs rather than \fB\s-1RSA_METHOD\s0\fRs during development of the engine version of OpenSSL 0.9.6. For 0.9.7, the handling of defaults in the \s-1ENGINE API\s0 was restructured so that this change was reversed, and behaviour of the other functions resembled more closely the previous behaviour. The behaviour of defaults in the \s-1ENGINE API\s0 now transparently overrides the behaviour of defaults in the \s-1RSA API\s0 without requiring changing these function prototypes. deps/libressl-pnacl-sys-2.1.6/libressl/man/genrsa.10000644000175000017500000001547112360020741017057 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "genrsa 1" .TH genrsa 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" genrsa \- generate an RSA private key .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBgenrsa\fR [\fB\-out filename\fR] [\fB\-passout arg\fR] [\fB\-des\fR] [\fB\-des3\fR] [\fB\-idea\fR] [\fB\-f4\fR] [\fB\-3\fR] [\fB\-rand file(s)\fR] [\fB\-engine id\fR] [\fBnumbits\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBgenrsa\fR command generates an \s-1RSA\s0 private key. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" the output filename. If this argument is not specified then standard output is used. .IP "\fB\-passout arg\fR" 4 .IX Item "-passout arg" the output file password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-des|\-des3|\-idea\fR" 4 .IX Item "-des|-des3|-idea" These options encrypt the private key with the \s-1DES,\s0 triple \s-1DES,\s0 or the \&\s-1IDEA\s0 ciphers respectively before outputting it. If none of these options is specified no encryption is used. If encryption is used a pass phrase is prompted for if it is not supplied via the \fB\-passout\fR argument. .IP "\fB\-F4|\-3\fR" 4 .IX Item "-F4|-3" the public exponent to use, either 65537 or 3. The default is 65537. .IP "\fB\-rand file(s)\fR" 4 .IX Item "-rand file(s)" a file or files containing random data used to seed the random number generator, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)). Multiple files can be specified separated by a OS-dependent character. The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for all others. .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBgenrsa\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .IP "\fBnumbits\fR" 4 .IX Item "numbits" the size of the private key to generate in bits. This must be the last option specified. The default is 2048. .SH "NOTES" .IX Header "NOTES" \&\s-1RSA\s0 private key generation essentially involves the generation of two prime numbers. When generating a private key various symbols will be output to indicate the progress of the generation. A \fB.\fR represents each number which has passed an initial sieve test, \fB+\fR means a number has passed a single round of the Miller-Rabin primality test. A newline means that the number has passed all the prime tests (the actual number depends on the key size). .PP Because key generation is a random process the time taken to generate a key may vary somewhat. .SH "BUGS" .IX Header "BUGS" A quirk of the prime generation algorithm is that it cannot generate small primes. Therefore the number of bits should not be less that 64. For typical private keys this will not matter because for security reasons they will be much larger (typically 1024 bits). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIgendsa\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/CONF_modules_load_file.30000644000175000017500000001402712360020714022051 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CONF_modules_load_file 3" .TH CONF_modules_load_file 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CONF_modules_load_file, CONF_modules_load \- OpenSSL configuration functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int CONF_modules_load_file(const char *filename, const char *appname, \& unsigned long flags); \& int CONF_modules_load(const CONF *cnf, const char *appname, \& unsigned long flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The function \fICONF_modules_load_file()\fR configures OpenSSL using file \&\fBfilename\fR and application name \fBappname\fR. If \fBfilename\fR is \s-1NULL\s0 the standard OpenSSL configuration file is used. If \fBappname\fR is \&\s-1NULL\s0 the standard OpenSSL application name \fBopenssl_conf\fR is used. The behaviour can be cutomized using \fBflags\fR. .PP \&\fICONF_modules_load()\fR is idential to \fICONF_modules_load_file()\fR except it read configuration information from \fBcnf\fR. .SH "NOTES" .IX Header "NOTES" The following \fBflags\fR are currently recognized: .PP \&\fB\s-1CONF_MFLAGS_IGNORE_ERRORS\s0\fR if set errors returned by individual configuration modules are ignored. If not set the first module error is considered fatal and no further modules are loads. .PP Normally any modules errors will add error information to the error queue. If \&\fB\s-1CONF_MFLAGS_SILENT\s0\fR is set no error information is added. .PP If \fB\s-1CONF_MFLAGS_NO_DSO\s0\fR is set configuration module loading from DSOs is disabled. .PP \&\fB\s-1CONF_MFLAGS_IGNORE_MISSING_FILE\s0\fR if set will make \fICONF_load_modules_file()\fR ignore missing configuration files. Normally a missing configuration file return an error. .SH "RETURN VALUE" .IX Header "RETURN VALUE" These functions return 1 for success and a zero or negative value for failure. If module errors are not ignored the return code will reflect the return value of the failing module (this will always be zero or negative). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIconf\fR\|(5), \fIOPENSSL_config\fR\|(3), \&\fICONF_free\fR\|(3), \fIerr\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" CONF_modules_load_file and CONF_modules_load first appeared in OpenSSL 0.9.7. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_ctrl.30000644000175000017500000001167312360020731020004 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_ctrl 3" .TH SSL_CTX_ctrl 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_ctrl, SSL_CTX_callback_ctrl, SSL_ctrl, SSL_callback_ctrl \- internal handling functions for SSL_CTX and SSL objects .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg); \& long SSL_CTX_callback_ctrl(SSL_CTX *, int cmd, void (*fp)()); \& \& long SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg); \& long SSL_callback_ctrl(SSL *, int cmd, void (*fp)()); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The SSL_*\fI_ctrl()\fR family of functions is used to manipulate settings of the \s-1SSL_CTX\s0 and \s-1SSL\s0 objects. Depending on the command \fBcmd\fR the arguments \&\fBlarg\fR, \fBparg\fR, or \fBfp\fR are evaluated. These functions should never be called directly. All functionalities needed are made available via other functions or macros. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The return values of the SSL*\fI_ctrl()\fR functions depend on the command supplied via the \fBcmd\fR parameter. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/config.10000644000175000017500000003517612360020740017050 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "config 1" .TH config 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" config \- OpenSSL CONF library configuration files .SH "DESCRIPTION" .IX Header "DESCRIPTION" The OpenSSL \s-1CONF\s0 library can be used to read configuration files. It is used for the OpenSSL master configuration file \fBopenssl.cnf\fR and in a few other places like \fB\s-1SPKAC\s0\fR files and certificate extension files for the \fBx509\fR utility. OpenSSL applications can also use the \&\s-1CONF\s0 library for their own purposes. .PP A configuration file is divided into a number of sections. Each section starts with a line \fB[ section_name ]\fR and ends when a new section is started or end of file is reached. A section name can consist of alphanumeric characters and underscores. .PP The first section of a configuration file is special and is referred to as the \fBdefault\fR section this is usually unnamed and is from the start of file until the first named section. When a name is being looked up it is first looked up in a named section (if any) and then the default section. .PP The environment is mapped onto a section called \fB\s-1ENV\s0\fR. .PP Comments can be included by preceding them with the \fB#\fR character .PP Each section in a configuration file consists of a number of name and value pairs of the form \fBname=value\fR .PP The \fBname\fR string can contain any alphanumeric characters as well as a few punctuation symbols such as \fB.\fR \fB,\fR \fB;\fR and \fB_\fR. .PP The \fBvalue\fR string consists of the string following the \fB=\fR character until end of line with any leading and trailing white space removed. .PP The value string undergoes variable expansion. This can be done by including the form \fB\f(CB$var\fB\fR or \fB${var}\fR: this will substitute the value of the named variable in the current section. It is also possible to substitute a value from another section using the syntax \fB\f(CB$section::name\fB\fR or \fB${section::name}\fR. By using the form \fB\f(CB$ENV::name\fB\fR environment variables can be substituted. It is also possible to assign values to environment variables by using the name \fBENV::name\fR, this will work if the program looks up environment variables using the \fB\s-1CONF\s0\fR library instead of calling \fB\f(BIgetenv()\fB\fR directly. .PP It is possible to escape certain characters by using any kind of quote or the \fB\e\fR character. By making the last character of a line a \fB\e\fR a \fBvalue\fR string can be spread across multiple lines. In addition the sequences \fB\en\fR, \fB\er\fR, \fB\eb\fR and \fB\et\fR are recognized. .SH "OPENSSL LIBRARY CONFIGURATION" .IX Header "OPENSSL LIBRARY CONFIGURATION" In OpenSSL 0.9.7 and later applications can automatically configure certain aspects of OpenSSL using the master OpenSSL configuration file, or optionally an alternative configuration file. The \fBopenssl\fR utility includes this functionality: any sub command uses the master OpenSSL configuration file unless an option is used in the sub command to use an alternative configuration file. .PP To enable library configuration the default section needs to contain an appropriate line which points to the main configuration section. The default name is \fBopenssl_conf\fR which is used by the \fBopenssl\fR utility. Other applications may use an alternative name such as \fBmyapplicaton_conf\fR. .PP The configuration section should consist of a set of name value pairs which contain specific module configuration information. The \fBname\fR represents the name of the \fIconfiguration module\fR the meaning of the \fBvalue\fR is module specific: it may, for example, represent a further configuration section containing configuration module specific information. E.g. .PP .Vb 1 \& openssl_conf = openssl_init \& \& [openssl_init] \& \& oid_section = new_oids \& engines = engine_section \& \& [new_oids] \& \& ... new oids here ... \& \& [engine_section] \& \& ... engine stuff here ... .Ve .PP Currently there are two configuration modules. One for \s-1ASN1\s0 objects another for \s-1ENGINE\s0 configuration. .SS "\s-1ASN1 OBJECT CONFIGURATION MODULE\s0" .IX Subsection "ASN1 OBJECT CONFIGURATION MODULE" This module has the name \fBoid_section\fR. The value of this variable points to a section containing name value pairs of OIDs: the name is the \s-1OID\s0 short and long name, the value is the numerical form of the \s-1OID.\s0 Although some of the \fBopenssl\fR utility sub commands already have their own \s-1ASN1 OBJECT\s0 section functionality not all do. By using the \s-1ASN1 OBJECT\s0 configuration module \&\fBall\fR the \fBopenssl\fR utility sub commands can see the new objects as well as any compliant applications. For example: .PP .Vb 1 \& [new_oids] \& \& some_new_oid = 1.2.3.4 \& some_other_oid = 1.2.3.5 .Ve .PP In OpenSSL 0.9.8 it is also possible to set the value to the long name followed by a comma and the numerical \s-1OID\s0 form. For example: .PP .Vb 1 \& shortName = some object long name, 1.2.3.4 .Ve .SS "\s-1ENGINE CONFIGURATION MODULE\s0" .IX Subsection "ENGINE CONFIGURATION MODULE" This \s-1ENGINE\s0 configuration module has the name \fBengines\fR. The value of this variable points to a section containing further \s-1ENGINE\s0 configuration information. .PP The section pointed to by \fBengines\fR is a table of engine names (though see \&\fBengine_id\fR below) and further sections containing configuration information specific to each \s-1ENGINE.\s0 .PP Each \s-1ENGINE\s0 specific section is used to set default algorithms, load dynamic, perform initialization and send ctrls. The actual operation performed depends on the \fIcommand\fR name which is the name of the name value pair. The currently supported commands are listed below. .PP For example: .PP .Vb 1 \& [engine_section] \& \& # Configure ENGINE named "foo" \& foo = foo_section \& # Configure ENGINE named "bar" \& bar = bar_section \& \& [foo_section] \& ... foo ENGINE specific commands ... \& \& [bar_section] \& ... "bar" ENGINE specific commands ... .Ve .PP The command \fBengine_id\fR is used to give the \s-1ENGINE\s0 name. If used this command must be first. For example: .PP .Vb 3 \& [engine_section] \& # This would normally handle an ENGINE named "foo" \& foo = foo_section \& \& [foo_section] \& # Override default name and use "myfoo" instead. \& engine_id = myfoo .Ve .PP The command \fBdynamic_path\fR loads and adds an \s-1ENGINE\s0 from the given path. It is equivalent to sending the ctrls \fB\s-1SO_PATH\s0\fR with the path argument followed by \fB\s-1LIST_ADD\s0\fR with value 2 and \fB\s-1LOAD\s0\fR to the dynamic \s-1ENGINE.\s0 If this is not the required behaviour then alternative ctrls can be sent directly to the dynamic \s-1ENGINE\s0 using ctrl commands. .PP The command \fBinit\fR determines whether to initialize the \s-1ENGINE.\s0 If the value is \fB0\fR the \s-1ENGINE\s0 will not be initialized, if \fB1\fR and attempt it made to initialized the \s-1ENGINE\s0 immediately. If the \fBinit\fR command is not present then an attempt will be made to initialize the \s-1ENGINE\s0 after all commands in its section have been processed. .PP The command \fBdefault_algorithms\fR sets the default algorithms an \s-1ENGINE\s0 will supply using the functions \fB\f(BIENGINE_set_default_string()\fB\fR .PP If the name matches none of the above command names it is assumed to be a ctrl command which is sent to the \s-1ENGINE.\s0 The value of the command is the argument to the ctrl command. If the value is the string \fB\s-1EMPTY\s0\fR then no value is sent to the command. .PP For example: .PP .Vb 1 \& [engine_section] \& \& # Configure ENGINE named "foo" \& foo = foo_section \& \& [foo_section] \& # Load engine from DSO \& dynamic_path = /some/path/fooengine.so \& # A foo specific ctrl. \& some_ctrl = some_value \& # Another ctrl that doesn\*(Aqt take a value. \& other_ctrl = EMPTY \& # Supply all default algorithms \& default_algorithms = ALL .Ve .SH "NOTES" .IX Header "NOTES" If a configuration file attempts to expand a variable that doesn't exist then an error is flagged and the file will not load. This can happen if an attempt is made to expand an environment variable that doesn't exist. For example in a previous version of OpenSSL the default OpenSSL master configuration file used the value of \fB\s-1HOME\s0\fR which may not be defined on non Unix systems and would cause an error. .PP This can be worked around by including a \fBdefault\fR section to provide a default value: then if the environment lookup fails the default value will be used instead. For this to work properly the default value must be defined earlier in the configuration file than the expansion. See the \fB\s-1EXAMPLES\s0\fR section for an example of how to do this. .PP If the same variable exists in the same section then all but the last value will be silently ignored. In certain circumstances such as with DNs the same field may occur multiple times. This is usually worked around by ignoring any characters before an initial \fB.\fR e.g. .PP .Vb 2 \& 1.OU="My first OU" \& 2.OU="My Second OU" .Ve .SH "EXAMPLES" .IX Header "EXAMPLES" Here is a sample configuration file using some of the features mentioned above. .PP .Vb 1 \& # This is the default section. \& \& HOME=/temp \& RANDFILE= ${ENV::HOME}/.rnd \& configdir=$ENV::HOME/config \& \& [ section_one ] \& \& # We are now in section one. \& \& # Quotes permit leading and trailing whitespace \& any = " any variable name " \& \& other = A string that can \e \& cover several lines \e \& by including \e\e characters \& \& message = Hello World\en \& \& [ section_two ] \& \& greeting = $section_one::message .Ve .PP This next example shows how to expand environment variables safely. .PP Suppose you want a variable called \fBtmpfile\fR to refer to a temporary filename. The directory it is placed in can determined by the the \fB\s-1TEMP\s0\fR or \fB\s-1TMP\s0\fR environment variables but they may not be set to any value at all. If you just include the environment variable names and the variable doesn't exist then this will cause an error when an attempt is made to load the configuration file. By making use of the default section both values can be looked up with \fB\s-1TEMP\s0\fR taking priority and \fB/tmp\fR used if neither is defined: .PP .Vb 5 \& TMP=/tmp \& # The above value is used if TMP isn\*(Aqt in the environment \& TEMP=$ENV::TMP \& # The above value is used if TEMP isn\*(Aqt in the environment \& tmpfile=${ENV::TEMP}/tmp.filename .Ve .SH "BUGS" .IX Header "BUGS" Currently there is no way to include characters using the octal \fB\ennn\fR form. Strings are all null terminated so nulls cannot form part of the value. .PP The escaping isn't quite right: if you want to use sequences like \fB\en\fR you can't use any quote escaping on the same line. .PP Files are loaded in a single pass. This means that an variable expansion will only work if the variables referenced are defined earlier in the file. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIx509\fR\|(1), \fIreq\fR\|(1), \fIca\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/RSA_public_encrypt.30000644000175000017500000001515312360020724021327 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RSA_public_encrypt 3" .TH RSA_public_encrypt 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RSA_public_encrypt, RSA_private_decrypt \- RSA public key cryptography .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int RSA_public_encrypt(int flen, unsigned char *from, \& unsigned char *to, RSA *rsa, int padding); \& \& int RSA_private_decrypt(int flen, unsigned char *from, \& unsigned char *to, RSA *rsa, int padding); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIRSA_public_encrypt()\fR encrypts the \fBflen\fR bytes at \fBfrom\fR (usually a session key) using the public key \fBrsa\fR and stores the ciphertext in \&\fBto\fR. \fBto\fR must point to RSA_size(\fBrsa\fR) bytes of memory. .PP \&\fBpadding\fR denotes one of the following modes: .IP "\s-1RSA_PKCS1_PADDING\s0" 4 .IX Item "RSA_PKCS1_PADDING" \&\s-1PKCS\s0 #1 v1.5 padding. This currently is the most widely used mode. .IP "\s-1RSA_PKCS1_OAEP_PADDING\s0" 4 .IX Item "RSA_PKCS1_OAEP_PADDING" EME-OAEP as defined in \s-1PKCS\s0 #1 v2.0 with \s-1SHA\-1, MGF1\s0 and an empty encoding parameter. This mode is recommended for all new applications. .IP "\s-1RSA_SSLV23_PADDING\s0" 4 .IX Item "RSA_SSLV23_PADDING" \&\s-1PKCS\s0 #1 v1.5 padding with an SSL-specific modification that denotes that the server is \s-1SSL3\s0 capable. .IP "\s-1RSA_NO_PADDING\s0" 4 .IX Item "RSA_NO_PADDING" Raw \s-1RSA\s0 encryption. This mode should \fIonly\fR be used to implement cryptographically sound padding modes in the application code. Encrypting user data directly with \s-1RSA\s0 is insecure. .PP \&\fBflen\fR must be less than RSA_size(\fBrsa\fR) \- 11 for the \s-1PKCS\s0 #1 v1.5 based padding modes, less than RSA_size(\fBrsa\fR) \- 41 for \&\s-1RSA_PKCS1_OAEP_PADDING\s0 and exactly RSA_size(\fBrsa\fR) for \s-1RSA_NO_PADDING.\s0 .PP \&\fIRSA_private_decrypt()\fR decrypts the \fBflen\fR bytes at \fBfrom\fR using the private key \fBrsa\fR and stores the plaintext in \fBto\fR. \fBto\fR must point to a memory section large enough to hold the decrypted data (which is smaller than RSA_size(\fBrsa\fR)). \fBpadding\fR is the padding mode that was used to encrypt the data. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIRSA_public_encrypt()\fR returns the size of the encrypted data (i.e., RSA_size(\fBrsa\fR)). \fIRSA_private_decrypt()\fR returns the size of the recovered plaintext. .PP On error, \-1 is returned; the error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "CONFORMING TO" .IX Header "CONFORMING TO" \&\s-1SSL, PKCS\s0 #1 v2.0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fIrand\fR\|(3), \fIrsa\fR\|(3), \&\fIRSA_size\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" The \fBpadding\fR argument was added in SSLeay 0.8. \s-1RSA_NO_PADDING\s0 is available since SSLeay 0.9.0, \s-1OAEP\s0 was added in OpenSSL 0.9.2b. deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_add_word.30000644000175000017500000001350512360020711017735 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_add_word 3" .TH BN_add_word 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_add_word, BN_sub_word, BN_mul_word, BN_div_word, BN_mod_word \- arithmetic functions on BIGNUMs with integers .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int BN_add_word(BIGNUM *a, BN_ULONG w); \& \& int BN_sub_word(BIGNUM *a, BN_ULONG w); \& \& int BN_mul_word(BIGNUM *a, BN_ULONG w); \& \& BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); \& \& BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions perform arithmetic operations on BIGNUMs with unsigned integers. They are much more efficient than the normal \s-1BIGNUM\s0 arithmetic operations. .PP \&\fIBN_add_word()\fR adds \fBw\fR to \fBa\fR (\f(CW\*(C`a+=w\*(C'\fR). .PP \&\fIBN_sub_word()\fR subtracts \fBw\fR from \fBa\fR (\f(CW\*(C`a\-=w\*(C'\fR). .PP \&\fIBN_mul_word()\fR multiplies \fBa\fR and \fBw\fR (\f(CW\*(C`a*=w\*(C'\fR). .PP \&\fIBN_div_word()\fR divides \fBa\fR by \fBw\fR (\f(CW\*(C`a/=w\*(C'\fR) and returns the remainder. .PP \&\fIBN_mod_word()\fR returns the remainder of \fBa\fR divided by \fBw\fR (\f(CW\*(C`a%w\*(C'\fR). .PP For \fIBN_div_word()\fR and \fIBN_mod_word()\fR, \fBw\fR must not be 0. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBN_add_word()\fR, \fIBN_sub_word()\fR and \fIBN_mul_word()\fR return 1 for success, 0 on error. The error codes can be obtained by \fIERR_get_error\fR\|(3). .PP \&\fIBN_mod_word()\fR and \fIBN_div_word()\fR return \fBa\fR%\fBw\fR on success and \&\fB(\s-1BN_ULONG\s0)\-1\fR if an error occurred. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3), \fIERR_get_error\fR\|(3), \fIBN_add\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIBN_add_word()\fR and \fIBN_mod_word()\fR are available in all versions of SSLeay and OpenSSL. \fIBN_div_word()\fR was added in SSLeay 0.8, and \&\fIBN_sub_word()\fR and \fIBN_mul_word()\fR in SSLeay 0.9.0. .PP Before 0.9.8a the return value for \fIBN_div_word()\fR and \fIBN_mod_word()\fR in case of an error was 0. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_sess_set_get_cb.30000644000175000017500000001776312360020732022202 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_sess_set_get_cb 3" .TH SSL_CTX_sess_set_get_cb 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_sess_set_new_cb, SSL_CTX_sess_set_remove_cb, SSL_CTX_sess_set_get_cb, SSL_CTX_sess_get_new_cb, SSL_CTX_sess_get_remove_cb, SSL_CTX_sess_get_get_cb \- provide callback functions for server side external session caching .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx, \& int (*new_session_cb)(SSL *, SSL_SESSION *)); \& void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx, \& void (*remove_session_cb)(SSL_CTX *ctx, SSL_SESSION *)); \& void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx, \& SSL_SESSION (*get_session_cb)(SSL *, unsigned char *, int, int *)); \& \& int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))(struct ssl_st *ssl, SSL_SESSION *sess); \& void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))(struct ssl_ctx_st *ctx, SSL_SESSION *sess); \& SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(struct ssl_st *ssl, unsigned char *data, int len, int *copy); \& \& int (*new_session_cb)(struct ssl_st *ssl, SSL_SESSION *sess); \& void (*remove_session_cb)(struct ssl_ctx_st *ctx, SSL_SESSION *sess); \& SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, unsigned char *data, \& int len, int *copy); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_sess_set_new_cb()\fR sets the callback function, which is automatically called whenever a new session was negotiated. .PP \&\fISSL_CTX_sess_set_remove_cb()\fR sets the callback function, which is automatically called whenever a session is removed by the \s-1SSL\s0 engine, because it is considered faulty or the session has become obsolete because of exceeding the timeout value. .PP \&\fISSL_CTX_sess_set_get_cb()\fR sets the callback function which is called, whenever a \s-1SSL/TLS\s0 client proposed to resume a session but the session could not be found in the internal session cache (see \&\fISSL_CTX_set_session_cache_mode\fR\|(3)). (\s-1SSL/TLS\s0 server only.) .PP \&\fISSL_CTX_sess_get_new_cb()\fR, \fISSL_CTX_sess_get_remove_cb()\fR, and \&\fISSL_CTX_sess_get_get_cb()\fR allow to retrieve the function pointers of the provided callback functions. If a callback function has not been set, the \s-1NULL\s0 pointer is returned. .SH "NOTES" .IX Header "NOTES" In order to allow external session caching, synchronization with the internal session cache is realized via callback functions. Inside these callback functions, session can be saved to disk or put into a database using the \&\fId2i_SSL_SESSION\fR\|(3) interface. .PP The \fInew_session_cb()\fR is called, whenever a new session has been negotiated and session caching is enabled (see \&\fISSL_CTX_set_session_cache_mode\fR\|(3)). The \fInew_session_cb()\fR is passed the \fBssl\fR connection and the ssl session \&\fBsess\fR. If the callback returns \fB0\fR, the session will be immediately removed again. .PP The \fIremove_session_cb()\fR is called, whenever the \s-1SSL\s0 engine removes a session from the internal cache. This happens when the session is removed because it is expired or when a connection was not shutdown cleanly. It also happens for all sessions in the internal session cache when \&\fISSL_CTX_free\fR\|(3) is called. The \fIremove_session_cb()\fR is passed the \fBctx\fR and the ssl session \fBsess\fR. It does not provide any feedback. .PP The \fIget_session_cb()\fR is only called on \s-1SSL/TLS\s0 servers with the session id proposed by the client. The \fIget_session_cb()\fR is always called, also when session caching was disabled. The \fIget_session_cb()\fR is passed the \&\fBssl\fR connection, the session id of length \fBlength\fR at the memory location \&\fBdata\fR. With the parameter \fBcopy\fR the callback can require the \&\s-1SSL\s0 engine to increment the reference count of the \s-1SSL_SESSION\s0 object, Normally the reference count is not incremented and therefore the session must not be explicitly freed with \&\fISSL_SESSION_free\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fId2i_SSL_SESSION\fR\|(3), \&\fISSL_CTX_set_session_cache_mode\fR\|(3), \&\fISSL_CTX_flush_sessions\fR\|(3), \&\fISSL_SESSION_free\fR\|(3), \&\fISSL_CTX_free\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/OpenSSL_add_all_algorithms.30000644000175000017500000001416412360020722022753 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "OpenSSL_add_all_algorithms 3" .TH OpenSSL_add_all_algorithms 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" OpenSSL_add_all_algorithms, OpenSSL_add_all_ciphers, OpenSSL_add_all_digests, EVP_cleanup \- add algorithms to internal table .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void OpenSSL_add_all_algorithms(void); \& void OpenSSL_add_all_ciphers(void); \& void OpenSSL_add_all_digests(void); \& \& void EVP_cleanup(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" OpenSSL keeps an internal table of digest algorithms and ciphers. It uses this table to lookup ciphers via functions such as \fIEVP_get_cipher_byname()\fR. .PP \&\fIOpenSSL_add_all_digests()\fR adds all digest algorithms to the table. .PP \&\fIOpenSSL_add_all_algorithms()\fR adds all algorithms to the table (digests and ciphers). .PP \&\fIOpenSSL_add_all_ciphers()\fR adds all encryption algorithms to the table including password based encryption algorithms. .PP \&\fIEVP_cleanup()\fR removes all ciphers and digests from the table. .SH "RETURN VALUES" .IX Header "RETURN VALUES" None of the functions return a value. .SH "NOTES" .IX Header "NOTES" A typical application will call \fIOpenSSL_add_all_algorithms()\fR initially and \&\fIEVP_cleanup()\fR before exiting. .PP An application does not need to add algorithms to use them explicitly, for example by \fIEVP_sha1()\fR. It just needs to add them if it (or any of the functions it calls) needs to lookup algorithms. .PP The cipher and digest lookup functions are used in many parts of the library. If the table is not initialized several functions will misbehave and complain they cannot find algorithms. This includes the \s-1PEM,\s0 PKCS#12, \s-1SSL\s0 and S/MIME libraries. This is a common query in the OpenSSL mailing lists. .PP Calling \fIOpenSSL_add_all_algorithms()\fR links in all algorithms: as a result a statically linked executable can be quite large. If this is important it is possible to just add the required ciphers and digests. .SH "BUGS" .IX Header "BUGS" Although the functions do not return error codes it is possible for them to fail. This will only happen as a result of a memory allocation failure so this is not too much of a problem in practice. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIevp\fR\|(3), \fIEVP_DigestInit\fR\|(3), \&\fIEVP_EncryptInit\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/ca.10000644000175000017500000007215612360020740016165 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ca 1" .TH ca 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ca \- sample minimal CA application .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBca\fR [\fB\-verbose\fR] [\fB\-config filename\fR] [\fB\-name section\fR] [\fB\-gencrl\fR] [\fB\-revoke file\fR] [\fB\-crl_reason reason\fR] [\fB\-crl_hold instruction\fR] [\fB\-crl_compromise time\fR] [\fB\-crl_CA_compromise time\fR] [\fB\-crldays days\fR] [\fB\-crlhours hours\fR] [\fB\-crlexts section\fR] [\fB\-startdate date\fR] [\fB\-enddate date\fR] [\fB\-days arg\fR] [\fB\-md arg\fR] [\fB\-policy arg\fR] [\fB\-keyfile arg\fR] [\fB\-key arg\fR] [\fB\-passin arg\fR] [\fB\-cert file\fR] [\fB\-selfsign\fR] [\fB\-in file\fR] [\fB\-out file\fR] [\fB\-notext\fR] [\fB\-outdir dir\fR] [\fB\-infiles\fR] [\fB\-spkac file\fR] [\fB\-ss_cert file\fR] [\fB\-preserveDN\fR] [\fB\-noemailDN\fR] [\fB\-batch\fR] [\fB\-msie_hack\fR] [\fB\-extensions section\fR] [\fB\-extfile section\fR] [\fB\-engine id\fR] [\fB\-subj arg\fR] [\fB\-utf8\fR] [\fB\-multivalue\-rdn\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBca\fR command is a minimal \s-1CA\s0 application. It can be used to sign certificate requests in a variety of forms and generate CRLs it also maintains a text database of issued certificates and their status. .PP The options descriptions will be divided into each purpose. .SH "CA OPTIONS" .IX Header "CA OPTIONS" .IP "\fB\-config filename\fR" 4 .IX Item "-config filename" specifies the configuration file to use. .IP "\fB\-name section\fR" 4 .IX Item "-name section" specifies the configuration file section to use (overrides \&\fBdefault_ca\fR in the \fBca\fR section). .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" an input filename containing a single certificate request to be signed by the \s-1CA.\s0 .IP "\fB\-ss_cert filename\fR" 4 .IX Item "-ss_cert filename" a single self signed certificate to be signed by the \s-1CA.\s0 .IP "\fB\-spkac filename\fR" 4 .IX Item "-spkac filename" a file containing a single Netscape signed public key and challenge and additional field values to be signed by the \s-1CA.\s0 See the \fB\s-1SPKAC FORMAT\s0\fR section for information on the required format. .IP "\fB\-infiles\fR" 4 .IX Item "-infiles" if present this should be the last option, all subsequent arguments are assumed to the the names of files containing certificate requests. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" the output file to output certificates to. The default is standard output. The certificate details will also be printed out to this file. .IP "\fB\-outdir directory\fR" 4 .IX Item "-outdir directory" the directory to output certificates to. The certificate will be written to a filename consisting of the serial number in hex with \&\*(L".pem\*(R" appended. .IP "\fB\-cert\fR" 4 .IX Item "-cert" the \s-1CA\s0 certificate file. .IP "\fB\-keyfile filename\fR" 4 .IX Item "-keyfile filename" the private key to sign requests with. .IP "\fB\-key password\fR" 4 .IX Item "-key password" the password used to encrypt the private key. Since on some systems the command line arguments are visible (e.g. Unix with the 'ps' utility) this option should be used with caution. .IP "\fB\-selfsign\fR" 4 .IX Item "-selfsign" indicates the issued certificates are to be signed with the key the certificate requests were signed with (given with \fB\-keyfile\fR). Cerificate requests signed with a different key are ignored. If \&\fB\-spkac\fR, \fB\-ss_cert\fR or \fB\-gencrl\fR are given, \fB\-selfsign\fR is ignored. .Sp A consequence of using \fB\-selfsign\fR is that the self-signed certificate appears among the entries in the certificate database (see the configuration option \fBdatabase\fR), and uses the same serial number counter as all other certificates sign with the self-signed certificate. .IP "\fB\-passin arg\fR" 4 .IX Item "-passin arg" the key password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-verbose\fR" 4 .IX Item "-verbose" this prints extra details about the operations being performed. .IP "\fB\-notext\fR" 4 .IX Item "-notext" don't output the text form of a certificate to the output file. .IP "\fB\-startdate date\fR" 4 .IX Item "-startdate date" this allows the start date to be explicitly set. The format of the date is \s-1YYMMDDHHMMSSZ \s0(the same as an \s-1ASN1\s0 UTCTime structure). .IP "\fB\-enddate date\fR" 4 .IX Item "-enddate date" this allows the expiry date to be explicitly set. The format of the date is \s-1YYMMDDHHMMSSZ \s0(the same as an \s-1ASN1\s0 UTCTime structure). .IP "\fB\-days arg\fR" 4 .IX Item "-days arg" the number of days to certify the certificate for. .IP "\fB\-md alg\fR" 4 .IX Item "-md alg" the message digest to use. Possible values include md5, sha1 and mdc2. This option also applies to CRLs. .IP "\fB\-policy arg\fR" 4 .IX Item "-policy arg" this option defines the \s-1CA \s0\*(L"policy\*(R" to use. This is a section in the configuration file which decides which fields should be mandatory or match the \s-1CA\s0 certificate. Check out the \fB\s-1POLICY FORMAT\s0\fR section for more information. .IP "\fB\-msie_hack\fR" 4 .IX Item "-msie_hack" this is a legacy option to make \fBca\fR work with very old versions of the \s-1IE\s0 certificate enrollment control \*(L"certenr3\*(R". It used UniversalStrings for almost everything. Since the old control has various security bugs its use is strongly discouraged. The newer control \*(L"Xenroll\*(R" does not need this option. .IP "\fB\-preserveDN\fR" 4 .IX Item "-preserveDN" Normally the \s-1DN\s0 order of a certificate is the same as the order of the fields in the relevant policy section. When this option is set the order is the same as the request. This is largely for compatibility with the older \s-1IE\s0 enrollment control which would only accept certificates if their DNs match the order of the request. This is not needed for Xenroll. .IP "\fB\-noemailDN\fR" 4 .IX Item "-noemailDN" The \s-1DN\s0 of a certificate can contain the \s-1EMAIL\s0 field if present in the request \s-1DN,\s0 however it is good policy just having the e\-mail set into the altName extension of the certificate. When this option is set the \&\s-1EMAIL\s0 field is removed from the certificate' subject and set only in the, eventually present, extensions. The \fBemail_in_dn\fR keyword can be used in the configuration file to enable this behaviour. .IP "\fB\-batch\fR" 4 .IX Item "-batch" this sets the batch mode. In this mode no questions will be asked and all certificates will be certified automatically. .IP "\fB\-extensions section\fR" 4 .IX Item "-extensions section" the section of the configuration file containing certificate extensions to be added when a certificate is issued (defaults to \fBx509_extensions\fR unless the \fB\-extfile\fR option is used). If no extension section is present then, a V1 certificate is created. If the extension section is present (even if it is empty), then a V3 certificate is created. See the:w \&\fIx509v3_config\fR\|(5) manual page for details of the extension section format. .IP "\fB\-extfile file\fR" 4 .IX Item "-extfile file" an additional configuration file to read certificate extensions from (using the default section unless the \fB\-extensions\fR option is also used). .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBca\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .IP "\fB\-subj arg\fR" 4 .IX Item "-subj arg" supersedes subject name given in the request. The arg must be formatted as \fI/type0=value0/type1=value1/type2=...\fR, characters may be escaped by \e (backslash), no spaces are skipped. .IP "\fB\-utf8\fR" 4 .IX Item "-utf8" this option causes field values to be interpreted as \s-1UTF8\s0 strings, by default they are interpreted as \s-1ASCII.\s0 This means that the field values, whether prompted from a terminal or obtained from a configuration file, must be valid \s-1UTF8\s0 strings. .IP "\fB\-multivalue\-rdn\fR" 4 .IX Item "-multivalue-rdn" this option causes the \-subj argument to be interpretedt with full support for multivalued RDNs. Example: .Sp \&\fI/DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe\fR .Sp If \-multi\-rdn is not used then the \s-1UID\s0 value is \fI123456+CN=John Doe\fR. .SH "CRL OPTIONS" .IX Header "CRL OPTIONS" .IP "\fB\-gencrl\fR" 4 .IX Item "-gencrl" this option generates a \s-1CRL\s0 based on information in the index file. .IP "\fB\-crldays num\fR" 4 .IX Item "-crldays num" the number of days before the next \s-1CRL\s0 is due. That is the days from now to place in the \s-1CRL\s0 nextUpdate field. .IP "\fB\-crlhours num\fR" 4 .IX Item "-crlhours num" the number of hours before the next \s-1CRL\s0 is due. .IP "\fB\-revoke filename\fR" 4 .IX Item "-revoke filename" a filename containing a certificate to revoke. .IP "\fB\-crl_reason reason\fR" 4 .IX Item "-crl_reason reason" revocation reason, where \fBreason\fR is one of: \fBunspecified\fR, \fBkeyCompromise\fR, \&\fBCACompromise\fR, \fBaffiliationChanged\fR, \fBsuperseded\fR, \fBcessationOfOperation\fR, \&\fBcertificateHold\fR or \fBremoveFromCRL\fR. The matching of \fBreason\fR is case insensitive. Setting any revocation reason will make the \s-1CRL\s0 v2. .Sp In practive \fBremoveFromCRL\fR is not particularly useful because it is only used in delta CRLs which are not currently implemented. .IP "\fB\-crl_hold instruction\fR" 4 .IX Item "-crl_hold instruction" This sets the \s-1CRL\s0 revocation reason code to \fBcertificateHold\fR and the hold instruction to \fBinstruction\fR which must be an \s-1OID.\s0 Although any \s-1OID\s0 can be used only \fBholdInstructionNone\fR (the use of which is discouraged by \s-1RFC2459\s0) \&\fBholdInstructionCallIssuer\fR or \fBholdInstructionReject\fR will normally be used. .IP "\fB\-crl_compromise time\fR" 4 .IX Item "-crl_compromise time" This sets the revocation reason to \fBkeyCompromise\fR and the compromise time to \&\fBtime\fR. \fBtime\fR should be in GeneralizedTime format that is \fB\s-1YYYYMMDDHHMMSSZ\s0\fR. .IP "\fB\-crl_CA_compromise time\fR" 4 .IX Item "-crl_CA_compromise time" This is the same as \fBcrl_compromise\fR except the revocation reason is set to \&\fBCACompromise\fR. .IP "\fB\-crlexts section\fR" 4 .IX Item "-crlexts section" the section of the configuration file containing \s-1CRL\s0 extensions to include. If no \s-1CRL\s0 extension section is present then a V1 \s-1CRL\s0 is created, if the \s-1CRL\s0 extension section is present (even if it is empty) then a V2 \s-1CRL\s0 is created. The \s-1CRL\s0 extensions specified are \&\s-1CRL\s0 extensions and \fBnot\fR \s-1CRL\s0 entry extensions. It should be noted that some software (for example Netscape) can't handle V2 CRLs. See \&\fIx509v3_config\fR\|(5) manual page for details of the extension section format. .SH "CONFIGURATION FILE OPTIONS" .IX Header "CONFIGURATION FILE OPTIONS" The section of the configuration file containing options for \fBca\fR is found as follows: If the \fB\-name\fR command line option is used, then it names the section to be used. Otherwise the section to be used must be named in the \fBdefault_ca\fR option of the \fBca\fR section of the configuration file (or in the default section of the configuration file). Besides \fBdefault_ca\fR, the following options are read directly from the \fBca\fR section: \s-1RANDFILE \&\s0 preserve msie_hack With the exception of \fB\s-1RANDFILE\s0\fR, this is probably a bug and may change in future releases. .PP Many of the configuration file options are identical to command line options. Where the option is present in the configuration file and the command line the command line value is used. Where an option is described as mandatory then it must be present in the configuration file or the command line equivalent (if any) used. .IP "\fBoid_file\fR" 4 .IX Item "oid_file" This specifies a file containing additional \fB\s-1OBJECT IDENTIFIERS\s0\fR. Each line of the file should consist of the numerical form of the object identifier followed by white space then the short name followed by white space and finally the long name. .IP "\fBoid_section\fR" 4 .IX Item "oid_section" This specifies a section in the configuration file containing extra object identifiers. Each line should consist of the short name of the object identifier followed by \fB=\fR and the numerical form. The short and long names are the same when this option is used. .IP "\fBnew_certs_dir\fR" 4 .IX Item "new_certs_dir" the same as the \fB\-outdir\fR command line option. It specifies the directory where new certificates will be placed. Mandatory. .IP "\fBcertificate\fR" 4 .IX Item "certificate" the same as \fB\-cert\fR. It gives the file containing the \s-1CA\s0 certificate. Mandatory. .IP "\fBprivate_key\fR" 4 .IX Item "private_key" same as the \fB\-keyfile\fR option. The file containing the \&\s-1CA\s0 private key. Mandatory. .IP "\fB\s-1RANDFILE\s0\fR" 4 .IX Item "RANDFILE" a file used to read and write random number seed information, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)). .IP "\fBdefault_days\fR" 4 .IX Item "default_days" the same as the \fB\-days\fR option. The number of days to certify a certificate for. .IP "\fBdefault_startdate\fR" 4 .IX Item "default_startdate" the same as the \fB\-startdate\fR option. The start date to certify a certificate for. If not set the current time is used. .IP "\fBdefault_enddate\fR" 4 .IX Item "default_enddate" the same as the \fB\-enddate\fR option. Either this option or \&\fBdefault_days\fR (or the command line equivalents) must be present. .IP "\fBdefault_crl_hours default_crl_days\fR" 4 .IX Item "default_crl_hours default_crl_days" the same as the \fB\-crlhours\fR and the \fB\-crldays\fR options. These will only be used if neither command line option is present. At least one of these must be present to generate a \s-1CRL.\s0 .IP "\fBdefault_md\fR" 4 .IX Item "default_md" the same as the \fB\-md\fR option. The message digest to use. Mandatory. .IP "\fBdatabase\fR" 4 .IX Item "database" the text database file to use. Mandatory. This file must be present though initially it will be empty. .IP "\fBunique_subject\fR" 4 .IX Item "unique_subject" if the value \fByes\fR is given, the valid certificate entries in the database must have unique subjects. if the value \fBno\fR is given, several valid certificate entries may have the exact same subject. The default value is \fByes\fR, to be compatible with older (pre 0.9.8) versions of OpenSSL. However, to make \s-1CA\s0 certificate roll-over easier, it's recommended to use the value \fBno\fR, especially if combined with the \fB\-selfsign\fR command line option. .IP "\fBserial\fR" 4 .IX Item "serial" a text file containing the next serial number to use in hex. Mandatory. This file must be present and contain a valid serial number. .IP "\fBcrlnumber\fR" 4 .IX Item "crlnumber" a text file containing the next \s-1CRL\s0 number to use in hex. The crl number will be inserted in the CRLs only if this file exists. If this file is present, it must contain a valid \s-1CRL\s0 number. .IP "\fBx509_extensions\fR" 4 .IX Item "x509_extensions" the same as \fB\-extensions\fR. .IP "\fBcrl_extensions\fR" 4 .IX Item "crl_extensions" the same as \fB\-crlexts\fR. .IP "\fBpreserve\fR" 4 .IX Item "preserve" the same as \fB\-preserveDN\fR .IP "\fBemail_in_dn\fR" 4 .IX Item "email_in_dn" the same as \fB\-noemailDN\fR. If you want the \s-1EMAIL\s0 field to be removed from the \s-1DN\s0 of the certificate simply set this to 'no'. If not present the default is to allow for the \s-1EMAIL\s0 filed in the certificate's \s-1DN.\s0 .IP "\fBmsie_hack\fR" 4 .IX Item "msie_hack" the same as \fB\-msie_hack\fR .IP "\fBpolicy\fR" 4 .IX Item "policy" the same as \fB\-policy\fR. Mandatory. See the \fB\s-1POLICY FORMAT\s0\fR section for more information. .IP "\fBname_opt\fR, \fBcert_opt\fR" 4 .IX Item "name_opt, cert_opt" these options allow the format used to display the certificate details when asking the user to confirm signing. All the options supported by the \fBx509\fR utilities \fB\-nameopt\fR and \fB\-certopt\fR switches can be used here, except the \fBno_signame\fR and \fBno_sigdump\fR are permanently set and cannot be disabled (this is because the certificate signature cannot be displayed because the certificate has not been signed at this point). .Sp For convenience the values \fBca_default\fR are accepted by both to produce a reasonable output. .Sp If neither option is present the format used in earlier versions of OpenSSL is used. Use of the old format is \fBstrongly\fR discouraged because it only displays fields mentioned in the \fBpolicy\fR section, mishandles multicharacter string types and does not display extensions. .IP "\fBcopy_extensions\fR" 4 .IX Item "copy_extensions" determines how extensions in certificate requests should be handled. If set to \fBnone\fR or this option is not present then extensions are ignored and not copied to the certificate. If set to \fBcopy\fR then any extensions present in the request that are not already present are copied to the certificate. If set to \fBcopyall\fR then all extensions in the request are copied to the certificate: if the extension is already present in the certificate it is deleted first. See the \fB\s-1WARNINGS\s0\fR section before using this option. .Sp The main use of this option is to allow a certificate request to supply values for certain extensions such as subjectAltName. .SH "POLICY FORMAT" .IX Header "POLICY FORMAT" The policy section consists of a set of variables corresponding to certificate \s-1DN\s0 fields. If the value is \*(L"match\*(R" then the field value must match the same field in the \s-1CA\s0 certificate. If the value is \&\*(L"supplied\*(R" then it must be present. If the value is \*(L"optional\*(R" then it may be present. Any fields not mentioned in the policy section are silently deleted, unless the \fB\-preserveDN\fR option is set but this can be regarded more of a quirk than intended behaviour. .SH "SPKAC FORMAT" .IX Header "SPKAC FORMAT" The input to the \fB\-spkac\fR command line option is a Netscape signed public key and challenge. This will usually come from the \fB\s-1KEYGEN\s0\fR tag in an \s-1HTML\s0 form to create a new private key. It is however possible to create SPKACs using the \fBspkac\fR utility. .PP The file should contain the variable \s-1SPKAC\s0 set to the value of the \s-1SPKAC\s0 and also the required \s-1DN\s0 components as name value pairs. If you need to include the same component twice then it can be preceded by a number and a '.'. .SH "EXAMPLES" .IX Header "EXAMPLES" Note: these examples assume that the \fBca\fR directory structure is already set up and the relevant files already exist. This usually involves creating a \s-1CA\s0 certificate and private key with \fBreq\fR, a serial number file and an empty index file and placing them in the relevant directories. .PP To use the sample configuration file below the directories demoCA, demoCA/private and demoCA/newcerts would be created. The \s-1CA\s0 certificate would be copied to demoCA/cacert.pem and its private key to demoCA/private/cakey.pem. A file demoCA/serial would be created containing for example \*(L"01\*(R" and the empty index file demoCA/index.txt. .PP Sign a certificate request: .PP .Vb 1 \& openssl ca \-in req.pem \-out newcert.pem .Ve .PP Sign a certificate request, using \s-1CA\s0 extensions: .PP .Vb 1 \& openssl ca \-in req.pem \-extensions v3_ca \-out newcert.pem .Ve .PP Generate a \s-1CRL\s0 .PP .Vb 1 \& openssl ca \-gencrl \-out crl.pem .Ve .PP Sign several requests: .PP .Vb 1 \& openssl ca \-infiles req1.pem req2.pem req3.pem .Ve .PP Certify a Netscape \s-1SPKAC:\s0 .PP .Vb 1 \& openssl ca \-spkac spkac.txt .Ve .PP A sample \s-1SPKAC\s0 file (the \s-1SPKAC\s0 line has been truncated for clarity): .PP .Vb 5 \& SPKAC=MIG0MGAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAn7PDhCeV/xIxUg8V70YRxK2A5 \& CN=Steve Test \& emailAddress=steve@openssl.org \& 0.OU=OpenSSL Group \& 1.OU=Another Group .Ve .PP A sample configuration file with the relevant sections for \fBca\fR: .PP .Vb 2 \& [ ca ] \& default_ca = CA_default # The default ca section \& \& [ CA_default ] \& \& dir = ./demoCA # top dir \& database = $dir/index.txt # index file. \& new_certs_dir = $dir/newcerts # new certs dir \& \& certificate = $dir/cacert.pem # The CA cert \& serial = $dir/serial # serial no file \& private_key = $dir/private/cakey.pem# CA private key \& RANDFILE = $dir/private/.rand # random number file \& \& default_days = 365 # how long to certify for \& default_crl_days= 30 # how long before next CRL \& default_md = md5 # md to use \& \& policy = policy_any # default policy \& email_in_dn = no # Don\*(Aqt add the email into cert DN \& \& name_opt = ca_default # Subject name display option \& cert_opt = ca_default # Certificate display option \& copy_extensions = none # Don\*(Aqt copy extensions from request \& \& [ policy_any ] \& countryName = supplied \& stateOrProvinceName = optional \& organizationName = optional \& organizationalUnitName = optional \& commonName = supplied \& emailAddress = optional .Ve .SH "FILES" .IX Header "FILES" Note: the location of all files can change either by compile time options, configuration file entries, environment variables or command line options. The values below reflect the default values. .PP .Vb 10 \& /usr/local/ssl/lib/openssl.cnf \- master configuration file \& ./demoCA \- main CA directory \& ./demoCA/cacert.pem \- CA certificate \& ./demoCA/private/cakey.pem \- CA private key \& ./demoCA/serial \- CA serial number file \& ./demoCA/serial.old \- CA serial number backup file \& ./demoCA/index.txt \- CA text database file \& ./demoCA/index.txt.old \- CA text database backup file \& ./demoCA/certs \- certificate output file \& ./demoCA/.rnd \- CA random seed information .Ve .SH "ENVIRONMENT VARIABLES" .IX Header "ENVIRONMENT VARIABLES" \&\fB\s-1OPENSSL_CONF\s0\fR reflects the location of master configuration file it can be overridden by the \fB\-config\fR command line option. .SH "RESTRICTIONS" .IX Header "RESTRICTIONS" The text database index file is a critical part of the process and if corrupted it can be difficult to fix. It is theoretically possible to rebuild the index file from all the issued certificates and a current \&\s-1CRL:\s0 however there is no option to do this. .PP V2 \s-1CRL\s0 features like delta CRLs are not currently supported. .PP Although several requests can be input and handled at once it is only possible to include one \s-1SPKAC\s0 or self signed certificate. .SH "BUGS" .IX Header "BUGS" The use of an in memory text database can cause problems when large numbers of certificates are present because, as the name implies the database has to be kept in memory. .PP The \fBca\fR command really needs rewriting or the required functionality exposed at either a command or interface level so a more friendly utility (perl script or \s-1GUI\s0) can handle things properly. The scripts \fB\s-1CA\s0.sh\fR and \&\fB\s-1CA\s0.pl\fR help a little but not very much. .PP Any fields in a request that are not present in a policy are silently deleted. This does not happen if the \fB\-preserveDN\fR option is used. To enforce the absence of the \s-1EMAIL\s0 field within the \s-1DN,\s0 as suggested by RFCs, regardless the contents of the request' subject the \fB\-noemailDN\fR option can be used. The behaviour should be more friendly and configurable. .PP Cancelling some commands by refusing to certify a certificate can create an empty file. .SH "WARNINGS" .IX Header "WARNINGS" The \fBca\fR command is quirky and at times downright unfriendly. .PP The \fBca\fR utility was originally meant as an example of how to do things in a \s-1CA.\s0 It was not supposed to be used as a full blown \s-1CA\s0 itself: nevertheless some people are using it for this purpose. .PP The \fBca\fR command is effectively a single user command: no locking is done on the various files and attempts to run more than one \fBca\fR command on the same database can have unpredictable results. .PP The \fBcopy_extensions\fR option should be used with caution. If care is not taken then it can be a security risk. For example if a certificate request contains a basicConstraints extension with \s-1CA:TRUE\s0 and the \&\fBcopy_extensions\fR value is set to \fBcopyall\fR and the user does not spot this when the certificate is displayed then this will hand the requestor a valid \s-1CA\s0 certificate. .PP This situation can be avoided by setting \fBcopy_extensions\fR to \fBcopy\fR and including basicConstraints with \s-1CA:FALSE\s0 in the configuration file. Then if the request contains a basicConstraints extension it will be ignored. .PP It is advisable to also include values for other extensions such as \fBkeyUsage\fR to prevent a request supplying its own values. .PP Additional restrictions can be placed on the \s-1CA\s0 certificate itself. For example if the \s-1CA\s0 certificate has: .PP .Vb 1 \& basicConstraints = CA:TRUE, pathlen:0 .Ve .PP then even if a certificate is issued with \s-1CA:TRUE\s0 it will not be valid. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIreq\fR\|(1), \fIspkac\fR\|(1), \fIx509\fR\|(1), \s-1\fICA\s0.pl\fR\|(1), \&\fIconfig\fR\|(5), \fIx509v3_config\fR\|(5) deps/libressl-pnacl-sys-2.1.6/libressl/man/d2i_PKCS8PrivateKey.30000644000175000017500000001422512360020727021174 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "d2i_PKCS8PrivateKey 3" .TH d2i_PKCS8PrivateKey 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" d2i_PKCS8PrivateKey_bio, d2i_PKCS8PrivateKey_fp, i2d_PKCS8PrivateKey_bio, i2d_PKCS8PrivateKey_fp, i2d_PKCS8PrivateKey_nid_bio, i2d_PKCS8PrivateKey_nid_fp \&\- PKCS#8 format private key functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u); \& EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u); \& \& int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, \& char *kstr, int klen, \& pem_password_cb *cb, void *u); \& \& int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, \& char *kstr, int klen, \& pem_password_cb *cb, void *u); \& \& int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, \& char *kstr, int klen, \& pem_password_cb *cb, void *u); \& \& int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, \& char *kstr, int klen, \& pem_password_cb *cb, void *u); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The PKCS#8 functions encode and decode private keys in PKCS#8 format using both PKCS#5 v1.5 and PKCS#5 v2.0 password based encryption algorithms. .PP Other than the use of \s-1DER\s0 as opposed to \s-1PEM\s0 these functions are identical to the corresponding \fB\s-1PEM\s0\fR function as described in the \fIpem\fR\|(3) manual page. .SH "NOTES" .IX Header "NOTES" Before using these functions \&\fIOpenSSL_add_all_algorithms\fR\|(3) should be called to initialize the internal algorithm lookup tables otherwise errors about unknown algorithms will occur if an attempt is made to decrypt a private key. .PP These functions are currently the only way to store encrypted private keys using \s-1DER\s0 format. .PP Currently all the functions use BIOs or \s-1FILE\s0 pointers, there are no functions which work directly on memory: this can be readily worked around by converting the buffers to memory BIOs, see \fIBIO_s_mem\fR\|(3) for details. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIpem\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/CMS_sign.30000644000175000017500000002263412360020713017242 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CMS_sign 3" .TH CMS_sign 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CMS_sign \- create a CMS SignedData structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, BIO *data, unsigned int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fICMS_sign()\fR creates and returns a \s-1CMS\s0 SignedData structure. \fBsigncert\fR is the certificate to sign with, \fBpkey\fR is the corresponding private key. \&\fBcerts\fR is an optional additional set of certificates to include in the \s-1CMS\s0 structure (for example any intermediate CAs in the chain). Any or all of these parameters can be \fB\s-1NULL\s0\fR, see \fB\s-1NOTES\s0\fR below. .PP The data to be signed is read from \s-1BIO \s0\fBdata\fR. .PP \&\fBflags\fR is an optional set of flags. .SH "NOTES" .IX Header "NOTES" Any of the following flags (ored together) can be passed in the \fBflags\fR parameter. .PP Many S/MIME clients expect the signed content to include valid \s-1MIME\s0 headers. If the \fB\s-1CMS_TEXT\s0\fR flag is set \s-1MIME\s0 headers for type \fBtext/plain\fR are prepended to the data. .PP If \fB\s-1CMS_NOCERTS\s0\fR is set the signer's certificate will not be included in the CMS_ContentInfo structure, the signer's certificate must still be supplied in the \fBsigncert\fR parameter though. This can reduce the size of the signature if the signers certificate can be obtained by other means: for example a previously signed message. .PP The data being signed is included in the CMS_ContentInfo structure, unless \&\fB\s-1CMS_DETACHED\s0\fR is set in which case it is omitted. This is used for CMS_ContentInfo detached signatures which are used in S/MIME plaintext signed messages for example. .PP Normally the supplied content is translated into \s-1MIME\s0 canonical format (as required by the S/MIME specifications) if \fB\s-1CMS_BINARY\s0\fR is set no translation occurs. This option should be used if the supplied data is in binary format otherwise the translation will corrupt it. .PP The SignedData structure includes several \s-1CMS\s0 signedAttributes including the signing time, the \s-1CMS\s0 content type and the supported list of ciphers in an SMIMECapabilities attribute. If \fB\s-1CMS_NOATTR\s0\fR is set then no signedAttributes will be used. If \fB\s-1CMS_NOSMIMECAP\s0\fR is set then just the SMIMECapabilities are omitted. .PP If present the SMIMECapabilities attribute indicates support for the following algorithms in preference order: 256 bit \s-1AES,\s0 Gost R3411\-94, Gost 28147\-89, 192 bit \s-1AES, 128\s0 bit \s-1AES,\s0 triple \s-1DES, 128\s0 bit \s-1RC2, 64\s0 bit \s-1RC2, DES\s0 and 40 bit \s-1RC2.\s0 If any of these algorithms is not available then it will not be included: for example the \s-1GOST\s0 algorithms will not be included if the \s-1GOST ENGINE\s0 is not loaded. .PP OpenSSL will by default identify signing certificates using issuer name and serial number. If \fB\s-1CMS_USE_KEYID\s0\fR is set it will use the subject key identifier value instead. An error occurs if the signing certificate does not have a subject key identifier extension. .PP If the flags \fB\s-1CMS_STREAM\s0\fR is set then the returned \fBCMS_ContentInfo\fR structure is just initialized ready to perform the signing operation. The signing is however \fBnot\fR performed and the data to be signed is not read from the \fBdata\fR parameter. Signing is deferred until after the data has been written. In this way data can be signed in a single pass. .PP If the \fB\s-1CMS_PARTIAL\s0\fR flag is set a partial \fBCMS_ContentInfo\fR structure is output to which additional signers and capabilities can be added before finalization. .PP If the flag \fB\s-1CMS_STREAM\s0\fR is set the returned \fBCMS_ContentInfo\fR structure is \&\fBnot\fR complete and outputting its contents via a function that does not properly finalize the \fBCMS_ContentInfo\fR structure will give unpredictable results. .PP Several functions including \fISMIME_write_CMS()\fR, \fIi2d_CMS_bio_stream()\fR, \&\fIPEM_write_bio_CMS_stream()\fR finalize the structure. Alternatively finalization can be performed by obtaining the streaming \s-1ASN1 \s0\fB\s-1BIO\s0\fR directly using \&\fIBIO_new_CMS()\fR. .PP If a signer is specified it will use the default digest for the signing algorithm. This is \fB\s-1SHA1\s0\fR for both \s-1RSA\s0 and \s-1DSA\s0 keys. .PP If \fBsigncert\fR and \fBpkey\fR are \s-1NULL\s0 then a certificates only \s-1CMS\s0 structure is output. .PP The function \fICMS_sign()\fR is a basic \s-1CMS\s0 signing function whose output will be suitable for many purposes. For finer control of the output format the \&\fBcerts\fR, \fBsigncert\fR and \fBpkey\fR parameters can all be \fB\s-1NULL\s0\fR and the \&\fB\s-1CMS_PARTIAL\s0\fR flag set. Then one or more signers can be added using the function \fICMS_sign_add1_signer()\fR, non default digests can be used and custom attributes added. \fB\f(BICMS_final()\fB\fR must then be called to finalize the structure if streaming is not enabled. .SH "BUGS" .IX Header "BUGS" Some attributes such as counter signatures are not supported. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICMS_sign()\fR returns either a valid CMS_ContentInfo structure or \s-1NULL\s0 if an error occurred. The error can be obtained from \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_verify\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fICMS_sign()\fR was added to OpenSSL 0.9.8 .PP The \fB\s-1CMS_STREAM\s0\fR flag is only supported for detached data in OpenSSL 0.9.8, it is supported for embedded data in OpenSSL 1.0.0 and later. deps/libressl-pnacl-sys-2.1.6/libressl/man/DSA_get_ex_new_index.30000644000175000017500000001161312360020715021577 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DSA_get_ex_new_index 3" .TH DSA_get_ex_new_index 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DSA_get_ex_new_index, DSA_set_ex_data, DSA_get_ex_data \- add application specific data to DSA structures .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int DSA_get_ex_new_index(long argl, void *argp, \& CRYPTO_EX_new *new_func, \& CRYPTO_EX_dup *dup_func, \& CRYPTO_EX_free *free_func); \& \& int DSA_set_ex_data(DSA *d, int idx, void *arg); \& \& char *DSA_get_ex_data(DSA *d, int idx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions handle application specific data in \s-1DSA\s0 structures. Their usage is identical to that of \&\fIRSA_get_ex_new_index()\fR, \fIRSA_set_ex_data()\fR and \fIRSA_get_ex_data()\fR as described in \fIRSA_get_ex_new_index\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIRSA_get_ex_new_index\fR\|(3), \fIdsa\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIDSA_get_ex_new_index()\fR, \fIDSA_set_ex_data()\fR and \fIDSA_get_ex_data()\fR are available since OpenSSL 0.9.5. deps/libressl-pnacl-sys-2.1.6/libressl/man/SMIME_write_CMS.30000644000175000017500000001414712360020725020371 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SMIME_write_CMS 3" .TH SMIME_write_CMS 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" .Vb 1 \& SMIME_write_CMS \- convert CMS structure to S/MIME format. .Ve .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SMIME_write_CMS(BIO *out, CMS_ContentInfo *cms, BIO *data, int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISMIME_write_CMS()\fR adds the appropriate \s-1MIME\s0 headers to a \s-1CMS\s0 structure to produce an S/MIME message. .PP \&\fBout\fR is the \s-1BIO\s0 to write the data to. \fBcms\fR is the appropriate \&\fBCMS_ContentInfo\fR structure. If streaming is enabled then the content must be supplied in the \fBdata\fR argument. \fBflags\fR is an optional set of flags. .SH "NOTES" .IX Header "NOTES" The following flags can be passed in the \fBflags\fR parameter. .PP If \fB\s-1CMS_DETACHED\s0\fR is set then cleartext signing will be used, this option only makes sense for SignedData where \fB\s-1CMS_DETACHED\s0\fR is also set when \fICMS_sign()\fR is called. .PP If the \fB\s-1CMS_TEXT\s0\fR flag is set \s-1MIME\s0 headers for type \fBtext/plain\fR are added to the content, this only makes sense if \fB\s-1CMS_DETACHED\s0\fR is also set. .PP If the \fB\s-1CMS_STREAM\s0\fR flag is set streaming is performed. This flag should only be set if \fB\s-1CMS_STREAM\s0\fR was also set in the previous call to a CMS_ContentInfo creation function. .PP If cleartext signing is being used and \fB\s-1CMS_STREAM\s0\fR not set then the data must be read twice: once to compute the signature in \fICMS_sign()\fR and once to output the S/MIME message. .PP If streaming is performed the content is output in \s-1BER\s0 format using indefinite length constructed encoding except in the case of signed data with detached content where the content is absent and \s-1DER\s0 format is used. .SH "BUGS" .IX Header "BUGS" \&\fISMIME_write_CMS()\fR always base64 encodes \s-1CMS\s0 structures, there should be an option to disable this. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISMIME_write_CMS()\fR returns 1 for success or 0 for failure. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_sign\fR\|(3), \&\fICMS_verify\fR\|(3), \fICMS_encrypt\fR\|(3) \&\fICMS_decrypt\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fISMIME_write_CMS()\fR was added to OpenSSL 0.9.8 deps/libressl-pnacl-sys-2.1.6/libressl/man/d2i_ASN1_OBJECT.30000644000175000017500000001076312360020726020072 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "d2i_ASN1_OBJECT 3" .TH d2i_ASN1_OBJECT 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" d2i_ASN1_OBJECT, i2d_ASN1_OBJECT \- ASN1 OBJECT IDENTIFIER functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, unsigned char **pp, long length); \& int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions decode and encode an \s-1ASN1 OBJECT IDENTIFIER.\s0 .PP Othewise these behave in a similar way to \fId2i_X509()\fR and \fIi2d_X509()\fR described in the \fId2i_X509\fR\|(3) manual page. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fId2i_X509\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/DSA_generate_parameters.30000644000175000017500000002016112360020715022277 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DSA_generate_parameters 3" .TH DSA_generate_parameters 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DSA_generate_parameters_ex, DSA_generate_parameters \- generate DSA parameters .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int DSA_generate_parameters_ex(DSA *dsa, int bits, \& const unsigned char *seed,int seed_len, \& int *counter_ret, unsigned long *h_ret, BN_GENCB *cb); .Ve .PP Deprecated: .PP .Vb 3 \& DSA *DSA_generate_parameters(int bits, unsigned char *seed, \& int seed_len, int *counter_ret, unsigned long *h_ret, \& void (*callback)(int, int, void *), void *cb_arg); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIDSA_generate_parameters_ex()\fR generates primes p and q and a generator g for use in the \s-1DSA\s0 and stores the result in \fBdsa\fR. .PP \&\fBbits\fR is the length of the prime to be generated; the \s-1DSS\s0 allows a maximum of 1024 bits. .PP If \fBseed\fR is \fB\s-1NULL\s0\fR or \fBseed_len\fR < 20, the primes will be generated at random. Otherwise, the seed is used to generate them. If the given seed does not yield a prime q, a new random seed is chosen and placed at \fBseed\fR. .PP \&\fIDSA_generate_parameters_ex()\fR places the iteration count in *\fBcounter_ret\fR and a counter used for finding a generator in *\fBh_ret\fR, unless these are \fB\s-1NULL\s0\fR. .PP A callback function may be used to provide feedback about the progress of the key generation. If \fBcb\fR is not \fB\s-1NULL\s0\fR, it will be called as shown below. For information on the \s-1BN_GENCB\s0 structure and the BN_GENCB_call function discussed below, refer to \&\fIBN_generate_prime\fR\|(3). .IP "\(bu" 4 When a candidate for q is generated, \fBBN_GENCB_call(cb, 0, m++)\fR is called (m is 0 for the first candidate). .IP "\(bu" 4 When a candidate for q has passed a test by trial division, \&\fBBN_GENCB_call(cb, 1, \-1)\fR is called. While a candidate for q is tested by Miller-Rabin primality tests, \&\fBBN_GENCB_call(cb, 1, i)\fR is called in the outer loop (once for each witness that confirms that the candidate may be prime); i is the loop counter (starting at 0). .IP "\(bu" 4 When a prime q has been found, \fBBN_GENCB_call(cb, 2, 0)\fR and \&\fBBN_GENCB_call(cb, 3, 0)\fR are called. .IP "\(bu" 4 Before a candidate for p (other than the first) is generated and tested, \&\fBBN_GENCB_call(cb, 0, counter)\fR is called. .IP "\(bu" 4 When a candidate for p has passed the test by trial division, \&\fBBN_GENCB_call(cb, 1, \-1)\fR is called. While it is tested by the Miller-Rabin primality test, \&\fBBN_GENCB_call(cb, 1, i)\fR is called in the outer loop (once for each witness that confirms that the candidate may be prime). i is the loop counter (starting at 0). .IP "\(bu" 4 When p has been found, \fBBN_GENCB_call(cb, 2, 1)\fR is called. .IP "\(bu" 4 When the generator has been found, \fBBN_GENCB_call(cb, 3, 1)\fR is called. .PP \&\fIDSA_generate_parameters()\fR (deprecated) works in much the same way as for DSA_generate_parameters_ex, except that no \fBdsa\fR parameter is passed and instead a newly allocated \fB\s-1DSA\s0\fR structure is returned. Additionally \*(L"old style\*(R" callbacks are used instead of the newer \s-1BN_GENCB\s0 based approach. Refer to \fIBN_generate_prime\fR\|(3) for further information. .SH "RETURN VALUE" .IX Header "RETURN VALUE" \&\fIDSA_generate_parameters_ex()\fR returns a 1 on success, or 0 otherwise. .PP \&\fIDSA_generate_parameters()\fR returns a pointer to the \s-1DSA\s0 structure, or \&\fB\s-1NULL\s0\fR if the parameter generation fails. .PP The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "BUGS" .IX Header "BUGS" Seed lengths > 20 are not supported. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdsa\fR\|(3), \fIERR_get_error\fR\|(3), \fIrand\fR\|(3), \&\fIDSA_free\fR\|(3), \fIBN_generate_prime\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIDSA_generate_parameters()\fR appeared in SSLeay 0.8. The \fBcb_arg\fR argument was added in SSLeay 0.9.0. In versions up to OpenSSL 0.9.4, \fBcallback(1, ...)\fR was called in the inner loop of the Miller-Rabin test whenever it reached the squaring step (the parameters to \fBcallback\fR did not reveal how many witnesses had been tested); since OpenSSL 0.9.5, \fBcallback(1, ...)\fR is called as in \fIBN_is_prime\fR\|(3), i.e. once for each witness. deps/libressl-pnacl-sys-2.1.6/libressl/man/ERR.30000644000175000017500000002560712360020716016236 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ERR 3" .TH ERR 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" err \- error codes .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& unsigned long ERR_get_error(void); \& unsigned long ERR_peek_error(void); \& unsigned long ERR_get_error_line(const char **file, int *line); \& unsigned long ERR_peek_error_line(const char **file, int *line); \& unsigned long ERR_get_error_line_data(const char **file, int *line, \& const char **data, int *flags); \& unsigned long ERR_peek_error_line_data(const char **file, int *line, \& const char **data, int *flags); \& \& int ERR_GET_LIB(unsigned long e); \& int ERR_GET_FUNC(unsigned long e); \& int ERR_GET_REASON(unsigned long e); \& \& void ERR_clear_error(void); \& \& char *ERR_error_string(unsigned long e, char *buf); \& const char *ERR_lib_error_string(unsigned long e); \& const char *ERR_func_error_string(unsigned long e); \& const char *ERR_reason_error_string(unsigned long e); \& \& void ERR_print_errors(BIO *bp); \& void ERR_print_errors_fp(FILE *fp); \& \& void ERR_load_crypto_strings(void); \& void ERR_free_strings(void); \& \& void ERR_remove_state(unsigned long pid); \& \& void ERR_put_error(int lib, int func, int reason, const char *file, \& int line); \& void ERR_add_error_data(int num, ...); \& \& void ERR_load_strings(int lib,ERR_STRING_DATA str[]); \& unsigned long ERR_PACK(int lib, int func, int reason); \& int ERR_get_next_error_library(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" When a call to the OpenSSL library fails, this is usually signalled by the return value, and an error code is stored in an error queue associated with the current thread. The \fBerr\fR library provides functions to obtain these error codes and textual error messages. .PP The \fIERR_get_error\fR\|(3) manpage describes how to access error codes. .PP Error codes contain information about where the error occurred, and what went wrong. \s-1\fIERR_GET_LIB\s0\fR\|(3) describes how to extract this information. A method to obtain human-readable error messages is described in \fIERR_error_string\fR\|(3). .PP \&\fIERR_clear_error\fR\|(3) can be used to clear the error queue. .PP Note that \fIERR_remove_state\fR\|(3) should be used to avoid memory leaks when threads are terminated. .SH "ADDING NEW ERROR CODES TO OPENSSL" .IX Header "ADDING NEW ERROR CODES TO OPENSSL" See \fIERR_put_error\fR\|(3) if you want to record error codes in the OpenSSL error system from within your application. .PP The remainder of this section is of interest only if you want to add new error codes to OpenSSL or add error codes from external libraries. .SS "Reporting errors" .IX Subsection "Reporting errors" Each sub-library has a specific macro \fIXXXerr()\fR that is used to report errors. Its first argument is a function code \fB\s-1XXX_F_...\s0\fR, the second argument is a reason code \fB\s-1XXX_R_...\s0\fR. Function codes are derived from the function names; reason codes consist of textual error descriptions. For example, the function \fIssl23_read()\fR reports a \&\*(L"handshake failure\*(R" as follows: .PP .Vb 1 \& SSLerr(SSL_F_SSL23_READ, SSL_R_SSL_HANDSHAKE_FAILURE); .Ve .PP Function and reason codes should consist of upper case characters, numbers and underscores only. The error file generation script translates function codes into function names by looking in the header files for an appropriate function name, if none is found it just uses the capitalized form such as \*(L"\s-1SSL23_READ\*(R"\s0 in the above example. .PP The trailing section of a reason code (after the \*(L"_R_\*(R") is translated into lower case and underscores changed to spaces. .PP When you are using new function or reason codes, run \fBmake errors\fR. The necessary \fB#define\fRs will then automatically be added to the sub-library's header file. .PP Although a library will normally report errors using its own specific XXXerr macro, another library's macro can be used. This is normally only done when a library wants to include \s-1ASN1\s0 code which must use the \fIASN1err()\fR macro. .SS "Adding new libraries" .IX Subsection "Adding new libraries" When adding a new sub-library to OpenSSL, assign it a library number \&\fB\s-1ERR_LIB_XXX\s0\fR, define a macro \fIXXXerr()\fR (both in \fBerr.h\fR), add its name to \fBERR_str_libraries[]\fR (in \fBcrypto/err/err.c\fR), and add \&\f(CW\*(C`ERR_load_XXX_strings()\*(C'\fR to the \fIERR_load_crypto_strings()\fR function (in \fBcrypto/err/err_all.c\fR). Finally, add an entry .PP .Vb 1 \& L XXX xxx.h xxx_err.c .Ve .PP to \fBcrypto/err/openssl.ec\fR, and add \fBxxx_err.c\fR to the Makefile. Running \fBmake errors\fR will then generate a file \fBxxx_err.c\fR, and add all error codes used in the library to \fBxxx.h\fR. .PP Additionally the library include file must have a certain form. Typically it will initially look like this: .PP .Vb 2 \& #ifndef HEADER_XXX_H \& #define HEADER_XXX_H \& \& #ifdef _\|_cplusplus \& extern "C" { \& #endif \& \& /* Include files */ \& \& #include \& #include \& \& /* Macros, structures and function prototypes */ \& \& \& /* BEGIN ERROR CODES */ .Ve .PP The \fB\s-1BEGIN ERROR CODES\s0\fR sequence is used by the error code generation script as the point to place new error codes, any text after this point will be overwritten when \fBmake errors\fR is run. The closing #endif etc will be automatically added by the script. .PP The generated C error code file \fBxxx_err.c\fR will load the header files \fBstdio.h\fR, \fBopenssl/err.h\fR and \fBopenssl/xxx.h\fR so the header file must load any additional header files containing any definitions it uses. .SH "USING ERROR CODES IN EXTERNAL LIBRARIES" .IX Header "USING ERROR CODES IN EXTERNAL LIBRARIES" It is also possible to use OpenSSL's error code scheme in external libraries. The library needs to load its own codes and call the OpenSSL error code insertion script \fBmkerr.pl\fR explicitly to add codes to the header file and generate the C error code file. This will normally be done if the external library needs to generate new \s-1ASN1\s0 structures but it can also be used to add more general purpose error code handling. .SH "INTERNALS" .IX Header "INTERNALS" The error queues are stored in a hash table with one \fB\s-1ERR_STATE\s0\fR entry for each pid. \fIERR_get_state()\fR returns the current thread's \&\fB\s-1ERR_STATE\s0\fR. An \fB\s-1ERR_STATE\s0\fR can hold up to \fB\s-1ERR_NUM_ERRORS\s0\fR error codes. When more error codes are added, the old ones are overwritten, on the assumption that the most recent errors are most important. .PP Error strings are also stored in hash table. The hash tables can be obtained by calling ERR_get_err_state_table(void) and ERR_get_string_table(void) respectively. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fICRYPTO_set_id_callback\fR\|(3), \&\fICRYPTO_set_locking_callback\fR\|(3), \&\fIERR_get_error\fR\|(3), \&\s-1\fIERR_GET_LIB\s0\fR\|(3), \&\fIERR_clear_error\fR\|(3), \&\fIERR_error_string\fR\|(3), \&\fIERR_print_errors\fR\|(3), \&\fIERR_load_crypto_strings\fR\|(3), \&\fIERR_remove_state\fR\|(3), \&\fIERR_put_error\fR\|(3), \&\fIERR_load_strings\fR\|(3), \&\fISSL_get_error\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/ciphers.10000644000175000017500000005346612360020740017242 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ciphers 1" .TH ciphers 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ciphers \- SSL cipher display and cipher list tool. .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBciphers\fR [\fB\-v\fR] [\fB\-V\fR] [\fB\-ssl2\fR] [\fB\-ssl3\fR] [\fB\-tls1\fR] [\fBcipherlist\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBciphers\fR command converts textual OpenSSL cipher lists into ordered \&\s-1SSL\s0 cipher preference lists. It can be used as a test tool to determine the appropriate cipherlist. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" .IP "\fB\-v\fR" 4 .IX Item "-v" Verbose option. List ciphers with a complete description of protocol version (SSLv2 or SSLv3; the latter includes \s-1TLS\s0), key exchange, authentication, encryption and mac algorithms used along with any key size restrictions and whether the algorithm is classed as an \*(L"export\*(R" cipher. Note that without the \fB\-v\fR option, ciphers may seem to appear twice in a cipher list; this is when similar ciphers are available for \&\s-1SSL\s0 v2 and for \s-1SSL\s0 v3/TLS v1. .IP "\fB\-V\fR" 4 .IX Item "-V" Like \fB\-V\fR, but include cipher suite codes in output (hex format). .IP "\fB\-ssl3\fR" 4 .IX Item "-ssl3" only include \s-1SSL\s0 v3 ciphers. .IP "\fB\-ssl2\fR" 4 .IX Item "-ssl2" only include \s-1SSL\s0 v2 ciphers. .IP "\fB\-tls1\fR" 4 .IX Item "-tls1" only include \s-1TLS\s0 v1 ciphers. .IP "\fB\-h\fR, \fB\-?\fR" 4 .IX Item "-h, -?" print a brief usage message. .IP "\fBcipherlist\fR" 4 .IX Item "cipherlist" a cipher list to convert to a cipher preference list. If it is not included then the default cipher list will be used. The format is described below. .SH "CIPHER LIST FORMAT" .IX Header "CIPHER LIST FORMAT" The cipher list consists of one or more \fIcipher strings\fR separated by colons. Commas or spaces are also acceptable separators but colons are normally used. .PP The actual cipher string can take several different forms. .PP It can consist of a single cipher suite such as \fB\s-1RC4\-SHA\s0\fR. .PP It can represent a list of cipher suites containing a certain algorithm, or cipher suites of a certain type. For example \fB\s-1SHA1\s0\fR represents all ciphers suites using the digest algorithm \s-1SHA1\s0 and \fBSSLv3\fR represents all \s-1SSL\s0 v3 algorithms. .PP Lists of cipher suites can be combined in a single cipher string using the \&\fB+\fR character. This is used as a logical \fBand\fR operation. For example \&\fB\s-1SHA1+DES\s0\fR represents all cipher suites containing the \s-1SHA1 \s0\fBand\fR the \s-1DES\s0 algorithms. .PP Each cipher string can be optionally preceded by the characters \fB!\fR, \&\fB\-\fR or \fB+\fR. .PP If \fB!\fR is used then the ciphers are permanently deleted from the list. The ciphers deleted can never reappear in the list even if they are explicitly stated. .PP If \fB\-\fR is used then the ciphers are deleted from the list, but some or all of the ciphers can be added again by later options. .PP If \fB+\fR is used then the ciphers are moved to the end of the list. This option doesn't add any new ciphers it just moves matching existing ones. .PP If none of these characters is present then the string is just interpreted as a list of ciphers to be appended to the current preference list. If the list includes any ciphers already present they will be ignored: that is they will not moved to the end of the list. .PP Additionally the cipher string \fB\f(CB@STRENGTH\fB\fR can be used at any point to sort the current cipher list in order of encryption algorithm key length. .SH "CIPHER STRINGS" .IX Header "CIPHER STRINGS" The following is a list of all permitted cipher strings and their meanings. .IP "\fB\s-1DEFAULT\s0\fR" 4 .IX Item "DEFAULT" the default cipher list. This is determined at compile time and, as of OpenSSL 1.0.0, is normally \fB\s-1ALL:\s0!aNULL:!eNULL\fR. This must be the first cipher string specified. .IP "\fB\s-1COMPLEMENTOFDEFAULT\s0\fR" 4 .IX Item "COMPLEMENTOFDEFAULT" the ciphers included in \fB\s-1ALL\s0\fR, but not enabled by default. Currently this is \fB\s-1ADH\s0\fR. Note that this rule does not cover \fBeNULL\fR, which is not included by \fB\s-1ALL\s0\fR (use \fB\s-1COMPLEMENTOFALL\s0\fR if necessary). .IP "\fB\s-1ALL\s0\fR" 4 .IX Item "ALL" all cipher suites except the \fBeNULL\fR ciphers which must be explicitly enabled; as of OpenSSL, the \fB\s-1ALL\s0\fR cipher suites are reasonably ordered by default .IP "\fB\s-1COMPLEMENTOFALL\s0\fR" 4 .IX Item "COMPLEMENTOFALL" the cipher suites not enabled by \fB\s-1ALL\s0\fR, currently being \fBeNULL\fR. .IP "\fB\s-1HIGH\s0\fR" 4 .IX Item "HIGH" \&\*(L"high\*(R" encryption cipher suites. This currently means those with key lengths larger than 128 bits, and some cipher suites with 128\-bit keys. .IP "\fB\s-1MEDIUM\s0\fR" 4 .IX Item "MEDIUM" \&\*(L"medium\*(R" encryption cipher suites, currently some of those using 128 bit encryption. .IP "\fB\s-1LOW\s0\fR" 4 .IX Item "LOW" \&\*(L"low\*(R" encryption cipher suites, currently those using 64 or 56 bit encryption algorithms but excluding export cipher suites. .IP "\fB\s-1EXP\s0\fR, \fB\s-1EXPORT\s0\fR" 4 .IX Item "EXP, EXPORT" export encryption algorithms. Including 40 and 56 bits algorithms. .IP "\fB\s-1EXPORT40\s0\fR" 4 .IX Item "EXPORT40" 40 bit export encryption algorithms .IP "\fB\s-1EXPORT56\s0\fR" 4 .IX Item "EXPORT56" 56 bit export encryption algorithms. In OpenSSL 0.9.8c and later the set of 56 bit export ciphers is empty unless OpenSSL has been explicitly configured with support for experimental ciphers. .IP "\fBeNULL\fR, \fB\s-1NULL\s0\fR" 4 .IX Item "eNULL, NULL" the \*(L"\s-1NULL\*(R"\s0 ciphers that is those offering no encryption. Because these offer no encryption at all and are a security risk they are disabled unless explicitly included. .IP "\fBaNULL\fR" 4 .IX Item "aNULL" the cipher suites offering no authentication. This is currently the anonymous \&\s-1DH\s0 algorithms. These cipher suites are vulnerable to a \*(L"man in the middle\*(R" attack and so their use is normally discouraged. .IP "\fBkRSA\fR, \fB\s-1RSA\s0\fR" 4 .IX Item "kRSA, RSA" cipher suites using \s-1RSA\s0 key exchange. .IP "\fBkEDH\fR" 4 .IX Item "kEDH" cipher suites using ephemeral \s-1DH\s0 key agreement. .IP "\fBkDHr\fR, \fBkDHd\fR" 4 .IX Item "kDHr, kDHd" cipher suites using \s-1DH\s0 key agreement and \s-1DH\s0 certificates signed by CAs with \s-1RSA\s0 and \s-1DSS\s0 keys respectively. Not implemented. .IP "\fBaRSA\fR" 4 .IX Item "aRSA" cipher suites using \s-1RSA\s0 authentication, i.e. the certificates carry \s-1RSA\s0 keys. .IP "\fBaDSS\fR, \fB\s-1DSS\s0\fR" 4 .IX Item "aDSS, DSS" cipher suites using \s-1DSS\s0 authentication, i.e. the certificates carry \s-1DSS\s0 keys. .IP "\fBaDH\fR" 4 .IX Item "aDH" cipher suites effectively using \s-1DH\s0 authentication, i.e. the certificates carry \&\s-1DH\s0 keys. Not implemented. .IP "\fBkFZA\fR, \fBaFZA\fR, \fBeFZA\fR, \fB\s-1FZA\s0\fR" 4 .IX Item "kFZA, aFZA, eFZA, FZA" ciphers suites using \s-1FORTEZZA\s0 key exchange, authentication, encryption or all \&\s-1FORTEZZA\s0 algorithms. Not implemented. .IP "\fBTLSv1\fR, \fBSSLv3\fR, \fBSSLv2\fR" 4 .IX Item "TLSv1, SSLv3, SSLv2" \&\s-1TLS\s0 v1.0, \s-1SSL\s0 v3.0 or \s-1SSL\s0 v2.0 cipher suites respectively. .IP "\fB\s-1DH\s0\fR" 4 .IX Item "DH" cipher suites using \s-1DH,\s0 including anonymous \s-1DH.\s0 .IP "\fB\s-1ADH\s0\fR" 4 .IX Item "ADH" anonymous \s-1DH\s0 cipher suites. .IP "\fB\s-1AES\s0\fR" 4 .IX Item "AES" cipher suites using \s-1AES.\s0 .IP "\fB\s-1CAMELLIA\s0\fR" 4 .IX Item "CAMELLIA" cipher suites using Camellia. .IP "\fB3DES\fR" 4 .IX Item "3DES" cipher suites using triple \s-1DES.\s0 .IP "\fB\s-1DES\s0\fR" 4 .IX Item "DES" cipher suites using \s-1DES \s0(not triple \s-1DES\s0). .IP "\fB\s-1RC4\s0\fR" 4 .IX Item "RC4" cipher suites using \s-1RC4.\s0 .IP "\fB\s-1RC2\s0\fR" 4 .IX Item "RC2" cipher suites using \s-1RC2.\s0 .IP "\fB\s-1IDEA\s0\fR" 4 .IX Item "IDEA" cipher suites using \s-1IDEA.\s0 .IP "\fB\s-1SEED\s0\fR" 4 .IX Item "SEED" cipher suites using \s-1SEED.\s0 .IP "\fB\s-1MD5\s0\fR" 4 .IX Item "MD5" cipher suites using \s-1MD5.\s0 .IP "\fB\s-1SHA1\s0\fR, \fB\s-1SHA\s0\fR" 4 .IX Item "SHA1, SHA" cipher suites using \s-1SHA1.\s0 .IP "\fBaGOST\fR" 4 .IX Item "aGOST" cipher suites using \s-1GOST R 34.10 \s0(either 2001 or 94) for authenticaction (needs an engine supporting \s-1GOST\s0 algorithms). .IP "\fBaGOST01\fR" 4 .IX Item "aGOST01" cipher suites using \s-1GOST R 34.10\-2001\s0 authentication. .IP "\fBaGOST94\fR" 4 .IX Item "aGOST94" cipher suites using \s-1GOST R 34.10\-94\s0 authentication (note that R 34.10\-94 standard has been expired so use \s-1GOST R 34.10\-2001\s0) .IP "\fBkGOST\fR" 4 .IX Item "kGOST" cipher suites, using \s-1VKO 34.10\s0 key exchange, specified in the \s-1RFC 4357.\s0 .IP "\fB\s-1GOST94\s0\fR" 4 .IX Item "GOST94" cipher suites, using \s-1HMAC\s0 based on \s-1GOST R 34.11\-94.\s0 .IP "\fB\s-1GOST89MAC\s0\fR" 4 .IX Item "GOST89MAC" cipher suites using \s-1GOST 28147\-89 MAC \s0\fBinstead of\fR \s-1HMAC.\s0 .SH "CIPHER SUITE NAMES" .IX Header "CIPHER SUITE NAMES" The following lists give the \s-1SSL\s0 or \s-1TLS\s0 cipher suites names from the relevant specification and their OpenSSL equivalents. It should be noted, that several cipher suite names do not include the authentication used, e.g. \s-1DES\-CBC3\-SHA.\s0 In these cases, \s-1RSA\s0 authentication is used. .SS "\s-1SSL\s0 v3.0 cipher suites." .IX Subsection "SSL v3.0 cipher suites." .Vb 10 \& SSL_RSA_WITH_NULL_MD5 NULL\-MD5 \& SSL_RSA_WITH_NULL_SHA NULL\-SHA \& SSL_RSA_EXPORT_WITH_RC4_40_MD5 EXP\-RC4\-MD5 \& SSL_RSA_WITH_RC4_128_MD5 RC4\-MD5 \& SSL_RSA_WITH_RC4_128_SHA RC4\-SHA \& SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5 EXP\-RC2\-CBC\-MD5 \& SSL_RSA_WITH_IDEA_CBC_SHA IDEA\-CBC\-SHA \& SSL_RSA_EXPORT_WITH_DES40_CBC_SHA EXP\-DES\-CBC\-SHA \& SSL_RSA_WITH_DES_CBC_SHA DES\-CBC\-SHA \& SSL_RSA_WITH_3DES_EDE_CBC_SHA DES\-CBC3\-SHA \& \& SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA Not implemented. \& SSL_DH_DSS_WITH_DES_CBC_SHA Not implemented. \& SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA Not implemented. \& SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA Not implemented. \& SSL_DH_RSA_WITH_DES_CBC_SHA Not implemented. \& SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA Not implemented. \& SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA EXP\-EDH\-DSS\-DES\-CBC\-SHA \& SSL_DHE_DSS_WITH_DES_CBC_SHA EDH\-DSS\-CBC\-SHA \& SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA EDH\-DSS\-DES\-CBC3\-SHA \& SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA EXP\-EDH\-RSA\-DES\-CBC\-SHA \& SSL_DHE_RSA_WITH_DES_CBC_SHA EDH\-RSA\-DES\-CBC\-SHA \& SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA EDH\-RSA\-DES\-CBC3\-SHA \& \& SSL_DH_anon_EXPORT_WITH_RC4_40_MD5 EXP\-ADH\-RC4\-MD5 \& SSL_DH_anon_WITH_RC4_128_MD5 ADH\-RC4\-MD5 \& SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA EXP\-ADH\-DES\-CBC\-SHA \& SSL_DH_anon_WITH_DES_CBC_SHA ADH\-DES\-CBC\-SHA \& SSL_DH_anon_WITH_3DES_EDE_CBC_SHA ADH\-DES\-CBC3\-SHA \& \& SSL_FORTEZZA_KEA_WITH_NULL_SHA Not implemented. \& SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA Not implemented. \& SSL_FORTEZZA_KEA_WITH_RC4_128_SHA Not implemented. .Ve .SS "\s-1TLS\s0 v1.0 cipher suites." .IX Subsection "TLS v1.0 cipher suites." .Vb 10 \& TLS_RSA_WITH_NULL_MD5 NULL\-MD5 \& TLS_RSA_WITH_NULL_SHA NULL\-SHA \& TLS_RSA_EXPORT_WITH_RC4_40_MD5 EXP\-RC4\-MD5 \& TLS_RSA_WITH_RC4_128_MD5 RC4\-MD5 \& TLS_RSA_WITH_RC4_128_SHA RC4\-SHA \& TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 EXP\-RC2\-CBC\-MD5 \& TLS_RSA_WITH_IDEA_CBC_SHA IDEA\-CBC\-SHA \& TLS_RSA_EXPORT_WITH_DES40_CBC_SHA EXP\-DES\-CBC\-SHA \& TLS_RSA_WITH_DES_CBC_SHA DES\-CBC\-SHA \& TLS_RSA_WITH_3DES_EDE_CBC_SHA DES\-CBC3\-SHA \& \& TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA Not implemented. \& TLS_DH_DSS_WITH_DES_CBC_SHA Not implemented. \& TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA Not implemented. \& TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA Not implemented. \& TLS_DH_RSA_WITH_DES_CBC_SHA Not implemented. \& TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA Not implemented. \& TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA EXP\-EDH\-DSS\-DES\-CBC\-SHA \& TLS_DHE_DSS_WITH_DES_CBC_SHA EDH\-DSS\-CBC\-SHA \& TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA EDH\-DSS\-DES\-CBC3\-SHA \& TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA EXP\-EDH\-RSA\-DES\-CBC\-SHA \& TLS_DHE_RSA_WITH_DES_CBC_SHA EDH\-RSA\-DES\-CBC\-SHA \& TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA EDH\-RSA\-DES\-CBC3\-SHA \& \& TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 EXP\-ADH\-RC4\-MD5 \& TLS_DH_anon_WITH_RC4_128_MD5 ADH\-RC4\-MD5 \& TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA EXP\-ADH\-DES\-CBC\-SHA \& TLS_DH_anon_WITH_DES_CBC_SHA ADH\-DES\-CBC\-SHA \& TLS_DH_anon_WITH_3DES_EDE_CBC_SHA ADH\-DES\-CBC3\-SHA .Ve .SS "\s-1AES\s0 ciphersuites from \s-1RFC3268,\s0 extending \s-1TLS\s0 v1.0" .IX Subsection "AES ciphersuites from RFC3268, extending TLS v1.0" .Vb 2 \& TLS_RSA_WITH_AES_128_CBC_SHA AES128\-SHA \& TLS_RSA_WITH_AES_256_CBC_SHA AES256\-SHA \& \& TLS_DH_DSS_WITH_AES_128_CBC_SHA Not implemented. \& TLS_DH_DSS_WITH_AES_256_CBC_SHA Not implemented. \& TLS_DH_RSA_WITH_AES_128_CBC_SHA Not implemented. \& TLS_DH_RSA_WITH_AES_256_CBC_SHA Not implemented. \& \& TLS_DHE_DSS_WITH_AES_128_CBC_SHA DHE\-DSS\-AES128\-SHA \& TLS_DHE_DSS_WITH_AES_256_CBC_SHA DHE\-DSS\-AES256\-SHA \& TLS_DHE_RSA_WITH_AES_128_CBC_SHA DHE\-RSA\-AES128\-SHA \& TLS_DHE_RSA_WITH_AES_256_CBC_SHA DHE\-RSA\-AES256\-SHA \& \& TLS_DH_anon_WITH_AES_128_CBC_SHA ADH\-AES128\-SHA \& TLS_DH_anon_WITH_AES_256_CBC_SHA ADH\-AES256\-SHA .Ve .SS "Camellia ciphersuites from \s-1RFC4132,\s0 extending \s-1TLS\s0 v1.0" .IX Subsection "Camellia ciphersuites from RFC4132, extending TLS v1.0" .Vb 2 \& TLS_RSA_WITH_CAMELLIA_128_CBC_SHA CAMELLIA128\-SHA \& TLS_RSA_WITH_CAMELLIA_256_CBC_SHA CAMELLIA256\-SHA \& \& TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA Not implemented. \& TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA Not implemented. \& TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA Not implemented. \& TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA Not implemented. \& \& TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA DHE\-DSS\-CAMELLIA128\-SHA \& TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA DHE\-DSS\-CAMELLIA256\-SHA \& TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA DHE\-RSA\-CAMELLIA128\-SHA \& TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA DHE\-RSA\-CAMELLIA256\-SHA \& \& TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA ADH\-CAMELLIA128\-SHA \& TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA ADH\-CAMELLIA256\-SHA .Ve .SS "\s-1SEED\s0 ciphersuites from \s-1RFC4162,\s0 extending \s-1TLS\s0 v1.0" .IX Subsection "SEED ciphersuites from RFC4162, extending TLS v1.0" .Vb 1 \& TLS_RSA_WITH_SEED_CBC_SHA SEED\-SHA \& \& TLS_DH_DSS_WITH_SEED_CBC_SHA Not implemented. \& TLS_DH_RSA_WITH_SEED_CBC_SHA Not implemented. \& \& TLS_DHE_DSS_WITH_SEED_CBC_SHA DHE\-DSS\-SEED\-SHA \& TLS_DHE_RSA_WITH_SEED_CBC_SHA DHE\-RSA\-SEED\-SHA \& \& TLS_DH_anon_WITH_SEED_CBC_SHA ADH\-SEED\-SHA .Ve .SS "\s-1GOST\s0 ciphersuites from draft-chudov-cryptopro-cptls, extending \s-1TLS\s0 v1.0" .IX Subsection "GOST ciphersuites from draft-chudov-cryptopro-cptls, extending TLS v1.0" Note: these ciphers require an engine which including \s-1GOST\s0 cryptographic algorithms, such as the \fBccgost\fR engine, included in the OpenSSL distribution. .PP .Vb 4 \& TLS_GOSTR341094_WITH_28147_CNT_IMIT GOST94\-GOST89\-GOST89 \& TLS_GOSTR341001_WITH_28147_CNT_IMIT GOST2001\-GOST89\-GOST89 \& TLS_GOSTR341094_WITH_NULL_GOSTR3411 GOST94\-NULL\-GOST94 \& TLS_GOSTR341001_WITH_NULL_GOSTR3411 GOST2001\-NULL\-GOST94 .Ve .SS "Additional Export 1024 and other cipher suites" .IX Subsection "Additional Export 1024 and other cipher suites" Note: these ciphers can also be used in \s-1SSL\s0 v3. .PP .Vb 5 \& TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA EXP1024\-DES\-CBC\-SHA \& TLS_RSA_EXPORT1024_WITH_RC4_56_SHA EXP1024\-RC4\-SHA \& TLS_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA EXP1024\-DHE\-DSS\-DES\-CBC\-SHA \& TLS_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA EXP1024\-DHE\-DSS\-RC4\-SHA \& TLS_DHE_DSS_WITH_RC4_128_SHA DHE\-DSS\-RC4\-SHA .Ve .SS "\s-1SSL\s0 v2.0 cipher suites." .IX Subsection "SSL v2.0 cipher suites." .Vb 7 \& SSL_CK_RC4_128_WITH_MD5 RC4\-MD5 \& SSL_CK_RC4_128_EXPORT40_WITH_MD5 EXP\-RC4\-MD5 \& SSL_CK_RC2_128_CBC_WITH_MD5 RC2\-MD5 \& SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5 EXP\-RC2\-MD5 \& SSL_CK_IDEA_128_CBC_WITH_MD5 IDEA\-CBC\-MD5 \& SSL_CK_DES_64_CBC_WITH_MD5 DES\-CBC\-MD5 \& SSL_CK_DES_192_EDE3_CBC_WITH_MD5 DES\-CBC3\-MD5 .Ve .SH "NOTES" .IX Header "NOTES" The non-ephemeral \s-1DH\s0 modes are currently unimplemented in OpenSSL because there is no support for \s-1DH\s0 certificates. .PP Some compiled versions of OpenSSL may not include all the ciphers listed here because some ciphers were excluded at compile time. .SH "EXAMPLES" .IX Header "EXAMPLES" Verbose listing of all OpenSSL ciphers including \s-1NULL\s0 ciphers: .PP .Vb 1 \& openssl ciphers \-v \*(AqALL:eNULL\*(Aq .Ve .PP Include all ciphers except \s-1NULL\s0 and anonymous \s-1DH\s0 then sort by strength: .PP .Vb 1 \& openssl ciphers \-v \*(AqALL:!ADH:@STRENGTH\*(Aq .Ve .PP Include only 3DES ciphers and then place \s-1RSA\s0 ciphers last: .PP .Vb 1 \& openssl ciphers \-v \*(Aq3DES:+RSA\*(Aq .Ve .PP Include all \s-1RC4\s0 ciphers but leave out those without authentication: .PP .Vb 1 \& openssl ciphers \-v \*(AqRC4:!COMPLEMENTOFDEFAULT\*(Aq .Ve .PP Include all chiphers with \s-1RSA\s0 authentication but leave out ciphers without encryption. .PP .Vb 1 \& openssl ciphers \-v \*(AqRSA:!COMPLEMENTOFALL\*(Aq .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIs_client\fR\|(1), \fIs_server\fR\|(1), \fIssl\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" The \fB\s-1COMPLENTOFALL\s0\fR and \fB\s-1COMPLEMENTOFDEFAULT\s0\fR selection options for cipherlist strings were added in OpenSSL 0.9.7. The \fB\-V\fR option for the \fBciphers\fR command was added in OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_PKEY_derive.30000644000175000017500000001537312360020720020420 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_PKEY_derive 3" .TH EVP_PKEY_derive 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_PKEY_derive_init, EVP_PKEY_derive_set_peer, EVP_PKEY_derive \- derive public key algorithm shared secret. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx); \& int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer); \& int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fIEVP_PKEY_derive_init()\fR function initializes a public key algorithm context using key \fBpkey\fR for shared secret derivation. .PP The \fIEVP_PKEY_derive_set_peer()\fR function sets the peer key: this will normally be a public key. .PP The \fIEVP_PKEY_derive()\fR derives a shared secret using \fBctx\fR. If \fBkey\fR is \fB\s-1NULL\s0\fR then the maximum size of the output buffer is written to the \fBkeylen\fR parameter. If \fBkey\fR is not \fB\s-1NULL\s0\fR then before the call the \&\fBkeylen\fR parameter should contain the length of the \fBkey\fR buffer, if the call is successful the shared secret is written to \fBkey\fR and the amount of data written to \fBkeylen\fR. .SH "NOTES" .IX Header "NOTES" After the call to \fIEVP_PKEY_derive_init()\fR algorithm specific control operations can be performed to set any appropriate parameters for the operation. .PP The function \fIEVP_PKEY_derive()\fR can be called more than once on the same context if several operations are performed using the same parameters. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_PKEY_derive_init()\fR and \fIEVP_PKEY_derive()\fR return 1 for success and 0 or a negative value for failure. In particular a return value of \-2 indicates the operation is not supported by the public key algorithm. .SH "EXAMPLE" .IX Header "EXAMPLE" Derive shared secret (for example \s-1DH\s0 or \s-1EC\s0 keys): .PP .Vb 2 \& #include \& #include \& \& EVP_PKEY_CTX *ctx; \& unsigned char *skey; \& size_t skeylen; \& EVP_PKEY *pkey, *peerkey; \& /* NB: assumes pkey, peerkey have been already set up */ \& \& ctx = EVP_PKEY_CTX_new(pkey); \& if (!ctx) \& /* Error occurred */ \& if (EVP_PKEY_derive_init(ctx) <= 0) \& /* Error */ \& if (EVP_PKEY_derive_set_peer(ctx, peerkey) <= 0) \& /* Error */ \& \& /* Determine buffer length */ \& if (EVP_PKEY_derive(ctx, NULL, &skeylen) <= 0) \& /* Error */ \& \& skey = OPENSSL_malloc(skeylen); \& \& if (!skey) \& /* malloc failure */ \& \& if (EVP_PKEY_derive(ctx, skey, &skeylen) <= 0) \& /* Error */ \& \& /* Shared secret is skey bytes written to buffer skey */ .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_PKEY_CTX_new\fR\|(3), \&\fIEVP_PKEY_encrypt\fR\|(3), \&\fIEVP_PKEY_decrypt\fR\|(3), \&\fIEVP_PKEY_sign\fR\|(3), \&\fIEVP_PKEY_verify\fR\|(3), \&\fIEVP_PKEY_verify_recover\fR\|(3), .SH "HISTORY" .IX Header "HISTORY" These functions were first added to OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/dsaparam.10000644000175000017500000001633512360020740017367 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "dsaparam 1" .TH dsaparam 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" dsaparam \- DSA parameter manipulation and generation .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl dsaparam\fR [\fB\-inform DER|PEM\fR] [\fB\-outform DER|PEM\fR] [\fB\-in filename\fR] [\fB\-out filename\fR] [\fB\-noout\fR] [\fB\-text\fR] [\fB\-C\fR] [\fB\-rand file(s)\fR] [\fB\-genkey\fR] [\fB\-engine id\fR] [\fBnumbits\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" This command is used to manipulate or generate \s-1DSA\s0 parameter files. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-inform DER|PEM\fR" 4 .IX Item "-inform DER|PEM" This specifies the input format. The \fB\s-1DER\s0\fR option uses an \s-1ASN1 DER\s0 encoded form compatible with \s-1RFC2459 \s0(\s-1PKIX\s0) DSS-Parms that is a \s-1SEQUENCE\s0 consisting of p, q and g respectively. The \s-1PEM\s0 form is the default format: it consists of the \fB\s-1DER\s0\fR format base64 encoded with additional header and footer lines. .IP "\fB\-outform DER|PEM\fR" 4 .IX Item "-outform DER|PEM" This specifies the output format, the options have the same meaning as the \&\fB\-inform\fR option. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read parameters from or standard input if this option is not specified. If the \fBnumbits\fR parameter is included then this option will be ignored. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" This specifies the output filename parameters to. Standard output is used if this option is not present. The output filename should \fBnot\fR be the same as the input filename. .IP "\fB\-noout\fR" 4 .IX Item "-noout" this option inhibits the output of the encoded version of the parameters. .IP "\fB\-text\fR" 4 .IX Item "-text" this option prints out the \s-1DSA\s0 parameters in human readable form. .IP "\fB\-C\fR" 4 .IX Item "-C" this option converts the parameters into C code. The parameters can then be loaded by calling the \fB\f(BIget_dsaXXX()\fB\fR function. .IP "\fB\-genkey\fR" 4 .IX Item "-genkey" this option will generate a \s-1DSA\s0 either using the specified or generated parameters. .IP "\fB\-rand file(s)\fR" 4 .IX Item "-rand file(s)" a file or files containing random data used to seed the random number generator, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)). Multiple files can be specified separated by a OS-dependent character. The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for all others. .IP "\fBnumbits\fR" 4 .IX Item "numbits" this option specifies that a parameter set should be generated of size \&\fBnumbits\fR. It must be the last option. If this option is included then the input file (if any) is ignored. .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBdsaparam\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .SH "NOTES" .IX Header "NOTES" \&\s-1PEM\s0 format \s-1DSA\s0 parameters use the header and footer lines: .PP .Vb 2 \& \-\-\-\-\-BEGIN DSA PARAMETERS\-\-\-\-\- \& \-\-\-\-\-END DSA PARAMETERS\-\-\-\-\- .Ve .PP \&\s-1DSA\s0 parameter generation is a slow process and as a result the same set of \&\s-1DSA\s0 parameters is often used to generate several distinct keys. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIgendsa\fR\|(1), \fIdsa\fR\|(1), \fIgenrsa\fR\|(1), \&\fIrsa\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_cipher_list.30000644000175000017500000001540412360020732022215 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_cipher_list 3" .TH SSL_CTX_set_cipher_list 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_cipher_list, SSL_set_cipher_list \- choose list of available SSL_CIPHERs .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str); \& int SSL_set_cipher_list(SSL *ssl, const char *str); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_cipher_list()\fR sets the list of available ciphers for \fBctx\fR using the control string \fBstr\fR. The format of the string is described in \fIciphers\fR\|(1). The list of ciphers is inherited by all \&\fBssl\fR objects created from \fBctx\fR. .PP \&\fISSL_set_cipher_list()\fR sets the list of ciphers only for \fBssl\fR. .SH "NOTES" .IX Header "NOTES" The control string \fBstr\fR should be universally usable and not depend on details of the library configuration (ciphers compiled in). Thus no syntax checking takes place. Items that are not recognized, because the corresponding ciphers are not compiled in or because they are mistyped, are simply ignored. Failure is only flagged if no ciphers could be collected at all. .PP It should be noted, that inclusion of a cipher to be used into the list is a necessary condition. On the client side, the inclusion into the list is also sufficient. On the server side, additional restrictions apply. All ciphers have additional requirements. \s-1ADH\s0 ciphers don't need a certificate, but DH-parameters must have been set. All other ciphers need a corresponding certificate and key. .PP A \s-1RSA\s0 cipher can only be chosen, when a \s-1RSA\s0 certificate is available. \&\s-1RSA\s0 export ciphers with a keylength of 512 bits for the \s-1RSA\s0 key require a temporary 512 bit \s-1RSA\s0 key, as typically the supplied key has a length of 1024 bit (see \&\fISSL_CTX_set_tmp_rsa_callback\fR\|(3)). \&\s-1RSA\s0 ciphers using \s-1EDH\s0 need a certificate and key and additional DH-parameters (see \fISSL_CTX_set_tmp_dh_callback\fR\|(3)). .PP A \s-1DSA\s0 cipher can only be chosen, when a \s-1DSA\s0 certificate is available. \&\s-1DSA\s0 ciphers always use \s-1DH\s0 key exchange and therefore need DH-parameters (see \fISSL_CTX_set_tmp_dh_callback\fR\|(3)). .PP When these conditions are not met for any cipher in the list (e.g. a client only supports export \s-1RSA\s0 ciphers with a asymmetric key length of 512 bits and the server is not configured to use temporary \s-1RSA\s0 keys), the \*(L"no shared cipher\*(R" (\s-1SSL_R_NO_SHARED_CIPHER\s0) error is generated and the handshake will fail. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_set_cipher_list()\fR and \fISSL_set_cipher_list()\fR return 1 if any cipher could be selected and 0 on complete failure. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_get_ciphers\fR\|(3), \&\fISSL_CTX_use_certificate\fR\|(3), \&\fISSL_CTX_set_tmp_rsa_callback\fR\|(3), \&\fISSL_CTX_set_tmp_dh_callback\fR\|(3), \&\fIciphers\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_EncryptInit.30000644000175000017500000007366112360020720020566 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_EncryptInit 3" .TH EVP_EncryptInit 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_CIPHER_CTX_init, EVP_EncryptInit_ex, EVP_EncryptUpdate, EVP_EncryptFinal_ex, EVP_DecryptInit_ex, EVP_DecryptUpdate, EVP_DecryptFinal_ex, EVP_CipherInit_ex, EVP_CipherUpdate, EVP_CipherFinal_ex, EVP_CIPHER_CTX_set_key_length, EVP_CIPHER_CTX_ctrl, EVP_CIPHER_CTX_cleanup, EVP_EncryptInit, EVP_EncryptFinal, EVP_DecryptInit, EVP_DecryptFinal, EVP_CipherInit, EVP_CipherFinal, EVP_get_cipherbyname, EVP_get_cipherbynid, EVP_get_cipherbyobj, EVP_CIPHER_nid, EVP_CIPHER_block_size, EVP_CIPHER_key_length, EVP_CIPHER_iv_length, EVP_CIPHER_flags, EVP_CIPHER_mode, EVP_CIPHER_type, EVP_CIPHER_CTX_cipher, EVP_CIPHER_CTX_nid, EVP_CIPHER_CTX_block_size, EVP_CIPHER_CTX_key_length, EVP_CIPHER_CTX_iv_length, EVP_CIPHER_CTX_get_app_data, EVP_CIPHER_CTX_set_app_data, EVP_CIPHER_CTX_type, EVP_CIPHER_CTX_flags, EVP_CIPHER_CTX_mode, EVP_CIPHER_param_to_asn1, EVP_CIPHER_asn1_to_param, EVP_CIPHER_CTX_set_padding, EVP_enc_null, EVP_des_cbc, EVP_des_ecb, EVP_des_cfb, EVP_des_ofb, EVP_des_ede_cbc, EVP_des_ede, EVP_des_ede_ofb, EVP_des_ede_cfb, EVP_des_ede3_cbc, EVP_des_ede3, EVP_des_ede3_ofb, EVP_des_ede3_cfb, EVP_desx_cbc, EVP_rc4, EVP_rc4_40, EVP_idea_cbc, EVP_idea_ecb, EVP_idea_cfb, EVP_idea_ofb, EVP_idea_cbc, EVP_rc2_cbc, EVP_rc2_ecb, EVP_rc2_cfb, EVP_rc2_ofb, EVP_rc2_40_cbc, EVP_rc2_64_cbc, EVP_bf_cbc, EVP_bf_ecb, EVP_bf_cfb, EVP_bf_ofb, EVP_cast5_cbc, EVP_cast5_ecb, EVP_cast5_cfb, EVP_cast5_ofb, EVP_aes_128_gcm, EVP_aes_192_gcm, EVP_aes_256_gcm, EVP_aes_128_ccm, EVP_aes_192_ccm, EVP_aes_256_ccm \- EVP cipher routines .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a); \& \& int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, \& ENGINE *impl, unsigned char *key, unsigned char *iv); \& int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, \& int *outl, unsigned char *in, int inl); \& int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, \& int *outl); \& \& int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, \& ENGINE *impl, unsigned char *key, unsigned char *iv); \& int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, \& int *outl, unsigned char *in, int inl); \& int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, \& int *outl); \& \& int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, \& ENGINE *impl, unsigned char *key, unsigned char *iv, int enc); \& int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, \& int *outl, unsigned char *in, int inl); \& int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, \& int *outl); \& \& int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, \& unsigned char *key, unsigned char *iv); \& int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, \& int *outl); \& \& int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, \& unsigned char *key, unsigned char *iv); \& int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, \& int *outl); \& \& int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, \& unsigned char *key, unsigned char *iv, int enc); \& int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, \& int *outl); \& \& int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *x, int padding); \& int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); \& int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); \& int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a); \& \& const EVP_CIPHER *EVP_get_cipherbyname(const char *name); \& #define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a)) \& #define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a)) \& \& #define EVP_CIPHER_nid(e) ((e)\->nid) \& #define EVP_CIPHER_block_size(e) ((e)\->block_size) \& #define EVP_CIPHER_key_length(e) ((e)\->key_len) \& #define EVP_CIPHER_iv_length(e) ((e)\->iv_len) \& #define EVP_CIPHER_flags(e) ((e)\->flags) \& #define EVP_CIPHER_mode(e) ((e)\->flags) & EVP_CIPH_MODE) \& int EVP_CIPHER_type(const EVP_CIPHER *ctx); \& \& #define EVP_CIPHER_CTX_cipher(e) ((e)\->cipher) \& #define EVP_CIPHER_CTX_nid(e) ((e)\->cipher\->nid) \& #define EVP_CIPHER_CTX_block_size(e) ((e)\->cipher\->block_size) \& #define EVP_CIPHER_CTX_key_length(e) ((e)\->key_len) \& #define EVP_CIPHER_CTX_iv_length(e) ((e)\->cipher\->iv_len) \& #define EVP_CIPHER_CTX_get_app_data(e) ((e)\->app_data) \& #define EVP_CIPHER_CTX_set_app_data(e,d) ((e)\->app_data=(char *)(d)) \& #define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c)) \& #define EVP_CIPHER_CTX_flags(e) ((e)\->cipher\->flags) \& #define EVP_CIPHER_CTX_mode(e) ((e)\->cipher\->flags & EVP_CIPH_MODE) \& \& int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type); \& int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \s-1EVP\s0 cipher routines are a high level interface to certain symmetric ciphers. .PP \&\fIEVP_CIPHER_CTX_init()\fR initializes cipher contex \fBctx\fR. .PP \&\fIEVP_EncryptInit_ex()\fR sets up cipher context \fBctx\fR for encryption with cipher \fBtype\fR from \s-1ENGINE \s0\fBimpl\fR. \fBctx\fR must be initialized before calling this function. \fBtype\fR is normally supplied by a function such as \fIEVP_aes_256_cbc()\fR. If \fBimpl\fR is \s-1NULL\s0 then the default implementation is used. \fBkey\fR is the symmetric key to use and \fBiv\fR is the \s-1IV\s0 to use (if necessary), the actual number of bytes used for the key and \s-1IV\s0 depends on the cipher. It is possible to set all parameters to \s-1NULL\s0 except \fBtype\fR in an initial call and supply the remaining parameters in subsequent calls, all of which have \fBtype\fR set to \s-1NULL.\s0 This is done when the default cipher parameters are not appropriate. .PP \&\fIEVP_EncryptUpdate()\fR encrypts \fBinl\fR bytes from the buffer \fBin\fR and writes the encrypted version to \fBout\fR. This function can be called multiple times to encrypt successive blocks of data. The amount of data written depends on the block alignment of the encrypted data: as a result the amount of data written may be anything from zero bytes to (inl + cipher_block_size \- 1) so \fBoutl\fR should contain sufficient room. The actual number of bytes written is placed in \fBoutl\fR. .PP If padding is enabled (the default) then \fIEVP_EncryptFinal_ex()\fR encrypts the \*(L"final\*(R" data, that is any data that remains in a partial block. It uses standard block padding (aka \s-1PKCS\s0 padding). The encrypted final data is written to \fBout\fR which should have sufficient space for one cipher block. The number of bytes written is placed in \fBoutl\fR. After this function is called the encryption operation is finished and no further calls to \fIEVP_EncryptUpdate()\fR should be made. .PP If padding is disabled then \fIEVP_EncryptFinal_ex()\fR will not encrypt any more data and it will return an error if any data remains in a partial block: that is if the total data length is not a multiple of the block size. .PP \&\fIEVP_DecryptInit_ex()\fR, \fIEVP_DecryptUpdate()\fR and \fIEVP_DecryptFinal_ex()\fR are the corresponding decryption operations. \fIEVP_DecryptFinal()\fR will return an error code if padding is enabled and the final block is not correctly formatted. The parameters and restrictions are identical to the encryption operations except that if padding is enabled the decrypted data buffer \fBout\fR passed to \fIEVP_DecryptUpdate()\fR should have sufficient room for (\fBinl\fR + cipher_block_size) bytes unless the cipher block size is 1 in which case \fBinl\fR bytes is sufficient. .PP \&\fIEVP_CipherInit_ex()\fR, \fIEVP_CipherUpdate()\fR and \fIEVP_CipherFinal_ex()\fR are functions that can be used for decryption or encryption. The operation performed depends on the value of the \fBenc\fR parameter. It should be set to 1 for encryption, 0 for decryption and \-1 to leave the value unchanged (the actual value of 'enc' being supplied in a previous call). .PP \&\fIEVP_CIPHER_CTX_cleanup()\fR clears all information from a cipher context and free up any allocated memory associate with it. It should be called after all operations using a cipher are complete so sensitive information does not remain in memory. .PP \&\fIEVP_EncryptInit()\fR, \fIEVP_DecryptInit()\fR and \fIEVP_CipherInit()\fR behave in a similar way to \fIEVP_EncryptInit_ex()\fR, EVP_DecryptInit_ex and \&\fIEVP_CipherInit_ex()\fR except the \fBctx\fR parameter does not need to be initialized and they always use the default cipher implementation. .PP \&\fIEVP_EncryptFinal()\fR, \fIEVP_DecryptFinal()\fR and \fIEVP_CipherFinal()\fR are identical to \fIEVP_EncryptFinal_ex()\fR, \fIEVP_DecryptFinal_ex()\fR and \&\fIEVP_CipherFinal_ex()\fR. In previous releases they also used to clean up the \fBctx\fR, but this is no longer done and \fIEVP_CIPHER_CTX_clean()\fR must be called to free any context resources. .PP \&\fIEVP_get_cipherbyname()\fR, \fIEVP_get_cipherbynid()\fR and \fIEVP_get_cipherbyobj()\fR return an \s-1EVP_CIPHER\s0 structure when passed a cipher name, a \s-1NID\s0 or an \&\s-1ASN1_OBJECT\s0 structure. .PP \&\fIEVP_CIPHER_nid()\fR and \fIEVP_CIPHER_CTX_nid()\fR return the \s-1NID\s0 of a cipher when passed an \fB\s-1EVP_CIPHER\s0\fR or \fB\s-1EVP_CIPHER_CTX\s0\fR structure. The actual \s-1NID\s0 value is an internal value which may not have a corresponding \s-1OBJECT IDENTIFIER.\s0 .PP \&\fIEVP_CIPHER_CTX_set_padding()\fR enables or disables padding. By default encryption operations are padded using standard block padding and the padding is checked and removed when decrypting. If the \fBpad\fR parameter is zero then no padding is performed, the total amount of data encrypted or decrypted must then be a multiple of the block size or an error will occur. .PP \&\fIEVP_CIPHER_key_length()\fR and \fIEVP_CIPHER_CTX_key_length()\fR return the key length of a cipher when passed an \fB\s-1EVP_CIPHER\s0\fR or \fB\s-1EVP_CIPHER_CTX\s0\fR structure. The constant \fB\s-1EVP_MAX_KEY_LENGTH\s0\fR is the maximum key length for all ciphers. Note: although \fIEVP_CIPHER_key_length()\fR is fixed for a given cipher, the value of \fIEVP_CIPHER_CTX_key_length()\fR may be different for variable key length ciphers. .PP \&\fIEVP_CIPHER_CTX_set_key_length()\fR sets the key length of the cipher ctx. If the cipher is a fixed length cipher then attempting to set the key length to any value other than the fixed value is an error. .PP \&\fIEVP_CIPHER_iv_length()\fR and \fIEVP_CIPHER_CTX_iv_length()\fR return the \s-1IV\s0 length of a cipher when passed an \fB\s-1EVP_CIPHER\s0\fR or \fB\s-1EVP_CIPHER_CTX\s0\fR. It will return zero if the cipher does not use an \s-1IV. \s0 The constant \&\fB\s-1EVP_MAX_IV_LENGTH\s0\fR is the maximum \s-1IV\s0 length for all ciphers. .PP \&\fIEVP_CIPHER_block_size()\fR and \fIEVP_CIPHER_CTX_block_size()\fR return the block size of a cipher when passed an \fB\s-1EVP_CIPHER\s0\fR or \fB\s-1EVP_CIPHER_CTX\s0\fR structure. The constant \fB\s-1EVP_MAX_IV_LENGTH\s0\fR is also the maximum block length for all ciphers. .PP \&\fIEVP_CIPHER_type()\fR and \fIEVP_CIPHER_CTX_type()\fR return the type of the passed cipher or context. This \*(L"type\*(R" is the actual \s-1NID\s0 of the cipher \s-1OBJECT IDENTIFIER\s0 as such it ignores the cipher parameters and 40 bit \s-1RC2\s0 and 128 bit \s-1RC2\s0 have the same \s-1NID.\s0 If the cipher does not have an object identifier or does not have \s-1ASN1\s0 support this function will return \&\fBNID_undef\fR. .PP \&\fIEVP_CIPHER_CTX_cipher()\fR returns the \fB\s-1EVP_CIPHER\s0\fR structure when passed an \fB\s-1EVP_CIPHER_CTX\s0\fR structure. .PP \&\fIEVP_CIPHER_mode()\fR and \fIEVP_CIPHER_CTX_mode()\fR return the block cipher mode: \&\s-1EVP_CIPH_ECB_MODE, EVP_CIPH_CBC_MODE, EVP_CIPH_CFB_MODE\s0 or \&\s-1EVP_CIPH_OFB_MODE.\s0 If the cipher is a stream cipher then \&\s-1EVP_CIPH_STREAM_CIPHER\s0 is returned. .PP \&\fIEVP_CIPHER_param_to_asn1()\fR sets the AlgorithmIdentifier \*(L"parameter\*(R" based on the passed cipher. This will typically include any parameters and an \&\s-1IV.\s0 The cipher \s-1IV \s0(if any) must be set when this call is made. This call should be made before the cipher is actually \*(L"used\*(R" (before any \&\fIEVP_EncryptUpdate()\fR, \fIEVP_DecryptUpdate()\fR calls for example). This function may fail if the cipher does not have any \s-1ASN1\s0 support. .PP \&\fIEVP_CIPHER_asn1_to_param()\fR sets the cipher parameters based on an \s-1ASN1\s0 AlgorithmIdentifier \*(L"parameter\*(R". The precise effect depends on the cipher In the case of \s-1RC2,\s0 for example, it will set the \s-1IV\s0 and effective key length. This function should be called after the base cipher type is set but before the key is set. For example \fIEVP_CipherInit()\fR will be called with the \s-1IV\s0 and key set to \s-1NULL,\s0 \fIEVP_CIPHER_asn1_to_param()\fR will be called and finally \&\fIEVP_CipherInit()\fR again with all parameters except the key set to \s-1NULL.\s0 It is possible for this function to fail if the cipher does not have any \s-1ASN1\s0 support or the parameters cannot be set (for example the \s-1RC2\s0 effective key length is not supported. .PP \&\fIEVP_CIPHER_CTX_ctrl()\fR allows various cipher specific parameters to be determined and set. Currently only the \s-1RC2\s0 effective key length and the number of rounds of \&\s-1RC5\s0 can be set. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_EncryptInit_ex()\fR, \fIEVP_EncryptUpdate()\fR and \fIEVP_EncryptFinal_ex()\fR return 1 for success and 0 for failure. .PP \&\fIEVP_DecryptInit_ex()\fR and \fIEVP_DecryptUpdate()\fR return 1 for success and 0 for failure. \fIEVP_DecryptFinal_ex()\fR returns 0 if the decrypt failed or 1 for success. .PP \&\fIEVP_CipherInit_ex()\fR and \fIEVP_CipherUpdate()\fR return 1 for success and 0 for failure. \fIEVP_CipherFinal_ex()\fR returns 0 for a decryption failure or 1 for success. .PP \&\fIEVP_CIPHER_CTX_cleanup()\fR returns 1 for success and 0 for failure. .PP \&\fIEVP_get_cipherbyname()\fR, \fIEVP_get_cipherbynid()\fR and \fIEVP_get_cipherbyobj()\fR return an \fB\s-1EVP_CIPHER\s0\fR structure or \s-1NULL\s0 on error. .PP \&\fIEVP_CIPHER_nid()\fR and \fIEVP_CIPHER_CTX_nid()\fR return a \s-1NID.\s0 .PP \&\fIEVP_CIPHER_block_size()\fR and \fIEVP_CIPHER_CTX_block_size()\fR return the block size. .PP \&\fIEVP_CIPHER_key_length()\fR and \fIEVP_CIPHER_CTX_key_length()\fR return the key length. .PP \&\fIEVP_CIPHER_CTX_set_padding()\fR always returns 1. .PP \&\fIEVP_CIPHER_iv_length()\fR and \fIEVP_CIPHER_CTX_iv_length()\fR return the \s-1IV\s0 length or zero if the cipher does not use an \s-1IV.\s0 .PP \&\fIEVP_CIPHER_type()\fR and \fIEVP_CIPHER_CTX_type()\fR return the \s-1NID\s0 of the cipher's \&\s-1OBJECT IDENTIFIER\s0 or NID_undef if it has no defined \s-1OBJECT IDENTIFIER.\s0 .PP \&\fIEVP_CIPHER_CTX_cipher()\fR returns an \fB\s-1EVP_CIPHER\s0\fR structure. .PP \&\fIEVP_CIPHER_param_to_asn1()\fR and \fIEVP_CIPHER_asn1_to_param()\fR return 1 for success or zero for failure. .SH "CIPHER LISTING" .IX Header "CIPHER LISTING" All algorithms have a fixed key length unless otherwise stated. .IP "EVP_enc_null(void)" 4 .IX Item "EVP_enc_null(void)" Null cipher: does nothing. .IP "EVP_aes_128_cbc(void), EVP_aes_128_ecb(void), EVP_aes_128_cfb(void), EVP_aes_128_ofb(void)" 4 .IX Item "EVP_aes_128_cbc(void), EVP_aes_128_ecb(void), EVP_aes_128_cfb(void), EVP_aes_128_ofb(void)" 128\-bit \s-1AES\s0 in \s-1CBC, ECB, CFB\s0 and \s-1OFB\s0 modes respectively. .IP "EVP_aes_192_cbc(void), EVP_aes_192_ecb(void), EVP_aes_192_cfb(void), EVP_aes_192_ofb(void)" 4 .IX Item "EVP_aes_192_cbc(void), EVP_aes_192_ecb(void), EVP_aes_192_cfb(void), EVP_aes_192_ofb(void)" 192\-bit \s-1AES\s0 in \s-1CBC, ECB, CFB\s0 and \s-1OFB\s0 modes respectively. .IP "EVP_aes_256_cbc(void), EVP_aes_256_ecb(void), EVP_aes_256_cfb(void), EVP_aes_256_ofb(void)" 4 .IX Item "EVP_aes_256_cbc(void), EVP_aes_256_ecb(void), EVP_aes_256_cfb(void), EVP_aes_256_ofb(void)" 256\-bit \s-1AES\s0 in \s-1CBC, ECB, CFB\s0 and \s-1OFB\s0 modes respectively. .IP "EVP_des_cbc(void), EVP_des_ecb(void), EVP_des_cfb(void), EVP_des_ofb(void)" 4 .IX Item "EVP_des_cbc(void), EVP_des_ecb(void), EVP_des_cfb(void), EVP_des_ofb(void)" \&\s-1DES\s0 in \s-1CBC, ECB, CFB\s0 and \s-1OFB\s0 modes respectively. .IP "EVP_des_ede_cbc(void), \fIEVP_des_ede()\fR, EVP_des_ede_ofb(void), EVP_des_ede_cfb(void)" 4 .IX Item "EVP_des_ede_cbc(void), EVP_des_ede(), EVP_des_ede_ofb(void), EVP_des_ede_cfb(void)" Two key triple \s-1DES\s0 in \s-1CBC, ECB, CFB\s0 and \s-1OFB\s0 modes respectively. .IP "EVP_des_ede3_cbc(void), \fIEVP_des_ede3()\fR, EVP_des_ede3_ofb(void), EVP_des_ede3_cfb(void)" 4 .IX Item "EVP_des_ede3_cbc(void), EVP_des_ede3(), EVP_des_ede3_ofb(void), EVP_des_ede3_cfb(void)" Three key triple \s-1DES\s0 in \s-1CBC, ECB, CFB\s0 and \s-1OFB\s0 modes respectively. .IP "EVP_desx_cbc(void)" 4 .IX Item "EVP_desx_cbc(void)" \&\s-1DESX\s0 algorithm in \s-1CBC\s0 mode. .IP "EVP_rc4(void)" 4 .IX Item "EVP_rc4(void)" \&\s-1RC4\s0 stream cipher. This is a variable key length cipher with default key length 128 bits. .IP "EVP_rc4_40(void)" 4 .IX Item "EVP_rc4_40(void)" \&\s-1RC4\s0 stream cipher with 40 bit key length. This is obsolete and new code should use \fIEVP_rc4()\fR and the \fIEVP_CIPHER_CTX_set_key_length()\fR function. .IP "\fIEVP_idea_cbc()\fR EVP_idea_ecb(void), EVP_idea_cfb(void), EVP_idea_ofb(void), EVP_idea_cbc(void)" 4 .IX Item "EVP_idea_cbc() EVP_idea_ecb(void), EVP_idea_cfb(void), EVP_idea_ofb(void), EVP_idea_cbc(void)" \&\s-1IDEA\s0 encryption algorithm in \s-1CBC, ECB, CFB\s0 and \s-1OFB\s0 modes respectively. .IP "EVP_rc2_cbc(void), EVP_rc2_ecb(void), EVP_rc2_cfb(void), EVP_rc2_ofb(void)" 4 .IX Item "EVP_rc2_cbc(void), EVP_rc2_ecb(void), EVP_rc2_cfb(void), EVP_rc2_ofb(void)" \&\s-1RC2\s0 encryption algorithm in \s-1CBC, ECB, CFB\s0 and \s-1OFB\s0 modes respectively. This is a variable key length cipher with an additional parameter called \*(L"effective key bits\*(R" or \*(L"effective key length\*(R". By default both are set to 128 bits. .IP "EVP_rc2_40_cbc(void), EVP_rc2_64_cbc(void)" 4 .IX Item "EVP_rc2_40_cbc(void), EVP_rc2_64_cbc(void)" \&\s-1RC2\s0 algorithm in \s-1CBC\s0 mode with a default key length and effective key length of 40 and 64 bits. These are obsolete and new code should use \fIEVP_rc2_cbc()\fR, \&\fIEVP_CIPHER_CTX_set_key_length()\fR and \fIEVP_CIPHER_CTX_ctrl()\fR to set the key length and effective key length. .IP "EVP_bf_cbc(void), EVP_bf_ecb(void), EVP_bf_cfb(void), EVP_bf_ofb(void);" 4 .IX Item "EVP_bf_cbc(void), EVP_bf_ecb(void), EVP_bf_cfb(void), EVP_bf_ofb(void);" Blowfish encryption algorithm in \s-1CBC, ECB, CFB\s0 and \s-1OFB\s0 modes respectively. This is a variable key length cipher. .IP "EVP_cast5_cbc(void), EVP_cast5_ecb(void), EVP_cast5_cfb(void), EVP_cast5_ofb(void)" 4 .IX Item "EVP_cast5_cbc(void), EVP_cast5_ecb(void), EVP_cast5_cfb(void), EVP_cast5_ofb(void)" \&\s-1CAST\s0 encryption algorithm in \s-1CBC, ECB, CFB\s0 and \s-1OFB\s0 modes respectively. This is a variable key length cipher. .IP "EVP_rc5_32_12_16_cbc(void), EVP_rc5_32_12_16_ecb(void), EVP_rc5_32_12_16_cfb(void), EVP_rc5_32_12_16_ofb(void)" 4 .IX Item "EVP_rc5_32_12_16_cbc(void), EVP_rc5_32_12_16_ecb(void), EVP_rc5_32_12_16_cfb(void), EVP_rc5_32_12_16_ofb(void)" \&\s-1RC5\s0 encryption algorithm in \s-1CBC, ECB, CFB\s0 and \s-1OFB\s0 modes respectively. This is a variable key length cipher with an additional \*(L"number of rounds\*(R" parameter. By default the key length is set to 128 bits and 12 rounds. .SH "NOTES" .IX Header "NOTES" Where possible the \fB\s-1EVP\s0\fR interface to symmetric ciphers should be used in preference to the low level interfaces. This is because the code then becomes transparent to the cipher used and much more flexible. .PP \&\s-1PKCS\s0 padding works by adding \fBn\fR padding bytes of value \fBn\fR to make the total length of the encrypted data a multiple of the block size. Padding is always added so if the data is already a multiple of the block size \fBn\fR will equal the block size. For example if the block size is 8 and 11 bytes are to be encrypted then 5 padding bytes of value 5 will be added. .PP When decrypting the final block is checked to see if it has the correct form. .PP Although the decryption operation can produce an error if padding is enabled, it is not a strong test that the input data or key is correct. A random block has better than 1 in 256 chance of being of the correct format and problems with the input data earlier on will not produce a final decrypt error. .PP If padding is disabled then the decryption operation will always succeed if the total amount of data decrypted is a multiple of the block size. .PP The functions \fIEVP_EncryptInit()\fR, \fIEVP_EncryptFinal()\fR, \fIEVP_DecryptInit()\fR, \&\fIEVP_CipherInit()\fR and \fIEVP_CipherFinal()\fR are obsolete but are retained for compatibility with existing code. New code should use \fIEVP_EncryptInit_ex()\fR, \&\fIEVP_EncryptFinal_ex()\fR, \fIEVP_DecryptInit_ex()\fR, \fIEVP_DecryptFinal_ex()\fR, \&\fIEVP_CipherInit_ex()\fR and \fIEVP_CipherFinal_ex()\fR because they can reuse an existing context without allocating and freeing it up on each call. .SH "BUGS" .IX Header "BUGS" For \s-1RC5\s0 the number of rounds can currently only be set to 8, 12 or 16. This is a limitation of the current \s-1RC5\s0 code rather than the \s-1EVP\s0 interface. .PP \&\s-1EVP_MAX_KEY_LENGTH\s0 and \s-1EVP_MAX_IV_LENGTH\s0 only refer to the internal ciphers with default key lengths. If custom ciphers exceed these values the results are unpredictable. This is because it has become standard practice to define a generic key as a fixed unsigned char array containing \s-1EVP_MAX_KEY_LENGTH\s0 bytes. .PP The \s-1ASN1\s0 code is incomplete (and sometimes inaccurate) it has only been tested for certain common S/MIME ciphers (\s-1RC2, DES,\s0 triple \s-1DES\s0) in \s-1CBC\s0 mode. .SH "EXAMPLES" .IX Header "EXAMPLES" Get the number of rounds used in \s-1RC5:\s0 .PP .Vb 2 \& int nrounds; \& EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC5_ROUNDS, 0, &nrounds); .Ve .PP Get the \s-1RC2\s0 effective key length: .PP .Vb 2 \& int key_bits; \& EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC2_KEY_BITS, 0, &key_bits); .Ve .PP Set the number of rounds used in \s-1RC5:\s0 .PP .Vb 2 \& int nrounds; \& EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC5_ROUNDS, nrounds, NULL); .Ve .PP Set the effective key length used in \s-1RC2:\s0 .PP .Vb 2 \& int key_bits; \& EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL); .Ve .PP Encrypt a string using blowfish: .PP .Vb 10 \& int \& do_crypt(char *outfile) \& { \& unsigned char outbuf[1024]; \& int outlen, tmplen; \& /* \& * Bogus key and IV: we\*(Aqd normally set these from \& * another source. \& */ \& unsigned char key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; \& unsigned char iv[] = {1,2,3,4,5,6,7,8}; \& const char intext[] = "Some Crypto Text"; \& EVP_CIPHER_CTX ctx; \& FILE *out; \& EVP_CIPHER_CTX_init(&ctx); \& EVP_EncryptInit_ex(&ctx, EVP_bf_cbc(), NULL, key, iv); \& \& if (!EVP_EncryptUpdate(&ctx, outbuf, &outlen, intext, \& strlen(intext))) { \& /* Error */ \& return 0; \& } \& /* \& * Buffer passed to EVP_EncryptFinal() must be after data just \& * encrypted to avoid overwriting it. \& */ \& if (!EVP_EncryptFinal_ex(&ctx, outbuf + outlen, &tmplen)) { \& /* Error */ \& return 0; \& } \& outlen += tmplen; \& EVP_CIPHER_CTX_cleanup(&ctx); \& /* \& * Need binary mode for fopen because encrypted data is \& * binary data. Also cannot use strlen() on it because \& * it won\*(Aqt be NUL terminated and may contain embedded \& * NULs. \& */ \& out = fopen(outfile, "wb"); \& fwrite(outbuf, 1, outlen, out); \& fclose(out); \& return 1; \& } .Ve .PP The ciphertext from the above example can be decrypted using the \fBopenssl\fR utility with the command line: .PP .Vb 1 \& S .Ve .PP General encryption, decryption function example using \s-1FILE I/O\s0 and \s-1RC2\s0 with an 80 bit key: .PP .Vb 12 \& int \& do_crypt(FILE *in, FILE *out, int do_encrypt) \& { \& /* Allow enough space in output buffer for additional block */ \& inbuf[1024], outbuf[1024 + EVP_MAX_BLOCK_LENGTH]; \& int inlen, outlen; \& /* \& * Bogus key and IV: we\*(Aqd normally set these from \& * another source. \& */ \& unsigned char key[] = "0123456789"; \& unsigned char iv[] = "12345678"; \& \& /* Don\*(Aqt set key or IV because we will modify the parameters */ \& EVP_CIPHER_CTX_init(&ctx); \& EVP_CipherInit_ex(&ctx, EVP_rc2(), NULL, NULL, NULL, do_encrypt); \& EVP_CIPHER_CTX_set_key_length(&ctx, 10); \& /* We finished modifying parameters so now we can set key and IV */ \& EVP_CipherInit_ex(&ctx, NULL, NULL, key, iv, do_encrypt); \& \& for(;;) { \& inlen = fread(inbuf, 1, 1024, in); \& if (inlen <= 0) \& break; \& if (!EVP_CipherUpdate(&ctx, outbuf, &outlen, inbuf, \& inlen)) { \& /* Error */ \& EVP_CIPHER_CTX_cleanup(&ctx); \& return 0; \& } \& fwrite(outbuf, 1, outlen, out); \& } \& if (!EVP_CipherFinal_ex(&ctx, outbuf, &outlen)) { \& /* Error */ \& EVP_CIPHER_CTX_cleanup(&ctx); \& return 0; \& } \& fwrite(outbuf, 1, outlen, out); \& \& EVP_CIPHER_CTX_cleanup(&ctx); \& return 1; \& } .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIevp\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIEVP_CIPHER_CTX_init()\fR, \fIEVP_EncryptInit_ex()\fR, \fIEVP_EncryptFinal_ex()\fR, \&\fIEVP_DecryptInit_ex()\fR, \fIEVP_DecryptFinal_ex()\fR, \fIEVP_CipherInit_ex()\fR, \&\fIEVP_CipherFinal_ex()\fR and \fIEVP_CIPHER_CTX_set_padding()\fR appeared in OpenSSL 0.9.7. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_set_bio.30000644000175000017500000001152212360020736017744 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_set_bio 3" .TH SSL_set_bio 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_set_bio \- connect the SSL object with a BIO .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_set_bio(SSL *ssl, BIO *rbio, BIO *wbio); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_set_bio()\fR connects the BIOs \fBrbio\fR and \fBwbio\fR for the read and write operations of the \s-1TLS/SSL \s0(encrypted) side of \fBssl\fR. .PP The \s-1SSL\s0 engine inherits the behaviour of \fBrbio\fR and \fBwbio\fR, respectively. If a \s-1BIO\s0 is non-blocking, the \fBssl\fR will also have non-blocking behaviour. .PP If there was already a \s-1BIO\s0 connected to \fBssl\fR, \fIBIO_free()\fR will be called (for both the reading and writing side, if different). .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_set_bio()\fR cannot fail. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_get_rbio\fR\|(3), \&\fISSL_connect\fR\|(3), \fISSL_accept\fR\|(3), \&\fISSL_shutdown\fR\|(3), \fIssl\fR\|(3), \fIbio\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/dgst.10000644000175000017500000002121712360020740016533 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "dgst 1" .TH dgst 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" dgst, md5, md4, md2, sha1, sha, mdc2, ripemd160 \- message digests .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBdgst\fR [\fB\-md5|\-md4|\-md2|\-sha1|\-sha|\-mdc2|\-ripemd160|\-dss1\fR] [\fB\-c\fR] [\fB\-d\fR] [\fB\-hex\fR] [\fB\-binary\fR] [\fB\-out filename\fR] [\fB\-sign filename\fR] [\fB\-keyform arg\fR] [\fB\-passin arg\fR] [\fB\-verify filename\fR] [\fB\-prverify filename\fR] [\fB\-signature filename\fR] [\fB\-hmac key\fR] [\fBfile...\fR] .PP [\fBmd5|md4|md2|sha1|sha|mdc2|ripemd160\fR] [\fB\-c\fR] [\fB\-d\fR] [\fBfile...\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The digest functions output the message digest of a supplied file or files in hexadecimal form. They can also be used for digital signing and verification. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-c\fR" 4 .IX Item "-c" print out the digest in two digit groups separated by colons, only relevant if \&\fBhex\fR format output is used. .IP "\fB\-d\fR" 4 .IX Item "-d" print out \s-1BIO\s0 debugging information. .IP "\fB\-hex\fR" 4 .IX Item "-hex" digest is to be output as a hex dump. This is the default case for a \*(L"normal\*(R" digest as opposed to a digital signature. .IP "\fB\-binary\fR" 4 .IX Item "-binary" output the digest or signature in binary form. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" filename to output to, or standard output by default. .IP "\fB\-sign filename\fR" 4 .IX Item "-sign filename" digitally sign the digest using the private key in \*(L"filename\*(R". .IP "\fB\-keyform arg\fR" 4 .IX Item "-keyform arg" Specifies the key format to sign digest with. Only \s-1PEM\s0 and \s-1ENGINE\s0 formats are supported by the \fBdgst\fR command. .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" Use engine \fBid\fR for operations (including private key storage). This engine is not used as source for digest algorithms, unless it is also specified in the configuration file. .IP "\fB\-sigopt nm:v\fR" 4 .IX Item "-sigopt nm:v" Pass options to the signature algorithm during sign or verify operations. Names and values of these options are algorithm-specific. .IP "\fB\-passin arg\fR" 4 .IX Item "-passin arg" the private key password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-verify filename\fR" 4 .IX Item "-verify filename" verify the signature using the the public key in \*(L"filename\*(R". The output is either \*(L"Verification \s-1OK\*(R"\s0 or \*(L"Verification Failure\*(R". .IP "\fB\-prverify filename\fR" 4 .IX Item "-prverify filename" verify the signature using the the private key in \*(L"filename\*(R". .IP "\fB\-signature filename\fR" 4 .IX Item "-signature filename" the actual signature to verify. .IP "\fB\-hmac key\fR" 4 .IX Item "-hmac key" create a hashed \s-1MAC\s0 using \*(L"key\*(R". .IP "\fB\-mac alg\fR" 4 .IX Item "-mac alg" create \s-1MAC \s0(keyed Message Authentication Code). The most popular \s-1MAC\s0 algorithm is \s-1HMAC \s0(hash-based \s-1MAC\s0), but there are other \s-1MAC\s0 algorithms which are not based on hash, for instance \fBgost-mac\fR algorithm, supported by \fBccgost\fR engine. \s-1MAC\s0 keys and other options should be set via \fB\-macopt\fR parameter. .IP "\fB\-macopt nm:v\fR" 4 .IX Item "-macopt nm:v" Passes options to \s-1MAC\s0 algorithm, specified by \fB\-mac\fR key. Following options are supported by both by \fB\s-1HMAC\s0\fR and \fBgost-mac\fR: .RS 4 .IP "\fBkey:string\fR" 8 .IX Item "key:string" Specifies \s-1MAC\s0 key as alphnumeric string (use if key contain printable characters only). String length must conform to any restrictions of the \s-1MAC\s0 algorithm for example exactly 32 chars for gost-mac. .IP "\fBhexkey:string\fR" 8 .IX Item "hexkey:string" Specifies \s-1MAC\s0 key in hexadecimal form (two hex digits per byte). Key length must conform to any restrictions of the \s-1MAC\s0 algorithm for example exactly 32 chars for gost-mac. .RE .RS 4 .RE .IP "\fB\-rand file(s)\fR" 4 .IX Item "-rand file(s)" a file or files containing random data used to seed the random number generator, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)). Multiple files can be specified separated by a OS-dependent character. The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for all others. .IP "\fBfile...\fR" 4 .IX Item "file..." file or files to digest. If no files are specified then standard input is used. .SH "NOTES" .IX Header "NOTES" The digest of choice for all new applications is \s-1SHA1.\s0 Other digests are however still widely used. .PP If you wish to sign or verify data using the \s-1DSA\s0 algorithm then the dss1 digest must be used. .PP A source of random numbers is required for certain signing algorithms, in particular \s-1DSA.\s0 .PP The signing and verify options should only be used if a single file is being signed or verified. deps/libressl-pnacl-sys-2.1.6/libressl/man/CRYPTO_set_locking_callback.30000644000175000017500000003011512360020714023007 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CRYPTO_set_locking_callback 3" .TH CRYPTO_set_locking_callback 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CRYPTO_THREADID_set_callback, CRYPTO_THREADID_get_callback, CRYPTO_THREADID_current, CRYPTO_THREADID_cmp, CRYPTO_THREADID_cpy, CRYPTO_THREADID_hash, CRYPTO_set_locking_callback, CRYPTO_num_locks, CRYPTO_set_dynlock_create_callback, CRYPTO_set_dynlock_lock_callback, CRYPTO_set_dynlock_destroy_callback, CRYPTO_get_new_dynlockid, CRYPTO_destroy_dynlockid, CRYPTO_lock \- OpenSSL thread support .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& /* Don\*(Aqt use this structure directly. */ \& typedef struct crypto_threadid_st \& { \& void *ptr; \& unsigned long val; \& } CRYPTO_THREADID; \& /* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */ \& void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val); \& void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr); \& int CRYPTO_THREADID_set_callback(void (*threadid_func)(CRYPTO_THREADID *)); \& void (*CRYPTO_THREADID_get_callback(void))(CRYPTO_THREADID *); \& void CRYPTO_THREADID_current(CRYPTO_THREADID *id); \& int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, \& const CRYPTO_THREADID *b); \& void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, \& const CRYPTO_THREADID *src); \& unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id); \& \& int CRYPTO_num_locks(void); \& \& /* struct CRYPTO_dynlock_value needs to be defined by the user */ \& struct CRYPTO_dynlock_value; \& \& void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value * \& (*dyn_create_function)(char *file, int line)); \& void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function) \& (int mode, struct CRYPTO_dynlock_value *l, \& const char *file, int line)); \& void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function) \& (struct CRYPTO_dynlock_value *l, const char *file, int line)); \& \& int CRYPTO_get_new_dynlockid(void); \& \& void CRYPTO_destroy_dynlockid(int i); \& \& void CRYPTO_lock(int mode, int n, const char *file, int line); \& \& #define CRYPTO_w_lock(type) \e \& CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,_\|_FILE_\|_,_\|_LINE_\|_) \& #define CRYPTO_w_unlock(type) \e \& CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,_\|_FILE_\|_,_\|_LINE_\|_) \& #define CRYPTO_r_lock(type) \e \& CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,_\|_FILE_\|_,_\|_LINE_\|_) \& #define CRYPTO_r_unlock(type) \e \& CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,_\|_FILE_\|_,_\|_LINE_\|_) \& #define CRYPTO_add(addr,amount,type) \e \& CRYPTO_add_lock(addr,amount,type,_\|_FILE_\|_,_\|_LINE_\|_) .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" OpenSSL can safely be used in multi-threaded applications provided that at least two callback functions are set, locking_function and threadid_func. .PP locking_function(int mode, int n, const char *file, int line) is needed to perform locking on shared data structures. (Note that OpenSSL uses a number of global data structures that will be implicitly shared whenever multiple threads use OpenSSL.) Multi-threaded applications will crash at random if it is not set. .PP \&\fIlocking_function()\fR must be able to handle up to \fICRYPTO_num_locks()\fR different mutex locks. It sets the \fBn\fR\-th lock if \fBmode\fR & \&\fB\s-1CRYPTO_LOCK\s0\fR, and releases it otherwise. .PP \&\fBfile\fR and \fBline\fR are the file number of the function setting the lock. They can be useful for debugging. .PP threadid_func(\s-1CRYPTO_THREADID\s0 *id) is needed to record the currently-executing thread's identifier into \fBid\fR. The implementation of this callback should not fill in \fBid\fR directly, but should use \fICRYPTO_THREADID_set_numeric()\fR if thread IDs are numeric, or \fICRYPTO_THREADID_set_pointer()\fR if they are pointer-based. If the application does not register such a callback using \&\fICRYPTO_THREADID_set_callback()\fR, then a default implementation is used \- on Windows and BeOS this uses the system's default thread identifying APIs, and on all other platforms it uses the address of \fBerrno\fR. The latter is satisfactory for thread-safety if and only if the platform has a thread-local error number facility. .PP Once \fIthreadid_func()\fR is registered, or if the built-in default implementation is to be used; .IP "\(bu" 4 \&\fICRYPTO_THREADID_current()\fR records the currently-executing thread \s-1ID\s0 into the given \fBid\fR object. .IP "\(bu" 4 \&\fICRYPTO_THREADID_cmp()\fR compares two thread IDs (returning zero for equality, ie. the same semantics as \fImemcmp()\fR). .IP "\(bu" 4 \&\fICRYPTO_THREADID_cpy()\fR duplicates a thread \s-1ID\s0 value, .IP "\(bu" 4 \&\fICRYPTO_THREADID_hash()\fR returns a numeric value usable as a hash-table key. This is usually the exact numeric or pointer-based thread \s-1ID\s0 used internally, however this also handles the unusual case where pointers are larger than 'long' variables and the platform's thread IDs are pointer-based \- in this case, mixing is done to attempt to produce a unique numeric value even though it is not as wide as the platform's true thread IDs. .PP Additionally, OpenSSL supports dynamic locks, and sometimes, some parts of OpenSSL need it for better performance. To enable this, the following is required: .IP "\(bu" 4 Three additional callback function, dyn_create_function, dyn_lock_function and dyn_destroy_function. .IP "\(bu" 4 A structure defined with the data that each lock needs to handle. .PP struct CRYPTO_dynlock_value has to be defined to contain whatever structure is needed to handle locks. .PP dyn_create_function(const char *file, int line) is needed to create a lock. Multi-threaded applications might crash at random if it is not set. .PP dyn_lock_function(int mode, CRYPTO_dynlock *l, const char *file, int line) is needed to perform locking off dynamic lock numbered n. Multi-threaded applications might crash at random if it is not set. .PP dyn_destroy_function(CRYPTO_dynlock *l, const char *file, int line) is needed to destroy the lock l. Multi-threaded applications might crash at random if it is not set. .PP \&\fICRYPTO_get_new_dynlockid()\fR is used to create locks. It will call dyn_create_function for the actual creation. .PP \&\fICRYPTO_destroy_dynlockid()\fR is used to destroy locks. It will call dyn_destroy_function for the actual destruction. .PP \&\fICRYPTO_lock()\fR is used to lock and unlock the locks. mode is a bitfield describing what should be done with the lock. n is the number of the lock as returned from \fICRYPTO_get_new_dynlockid()\fR. mode can be combined from the following values. These values are pairwise exclusive, with undefined behaviour if misused (for example, \s-1CRYPTO_READ\s0 and \s-1CRYPTO_WRITE\s0 should not be used together): .PP .Vb 4 \& CRYPTO_LOCK 0x01 \& CRYPTO_UNLOCK 0x02 \& CRYPTO_READ 0x04 \& CRYPTO_WRITE 0x08 .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICRYPTO_num_locks()\fR returns the required number of locks. .PP \&\fICRYPTO_get_new_dynlockid()\fR returns the index to the newly created lock. .PP The other functions return no values. .SH "NOTES" .IX Header "NOTES" You can find out if OpenSSL was configured with thread support: .PP .Vb 7 \& #define OPENSSL_THREAD_DEFINES \& #include \& #if defined(OPENSSL_THREADS) \& // thread support enabled \& #else \& // no thread support \& #endif .Ve .PP Also, dynamic locks are currently not used internally by OpenSSL, but may do so in the future. .SH "EXAMPLES" .IX Header "EXAMPLES" \&\fBcrypto/threads/mttest.c\fR shows examples of the callback functions on Solaris, Irix and Win32. .SH "HISTORY" .IX Header "HISTORY" \&\fICRYPTO_set_locking_callback()\fR is available in all versions of SSLeay and OpenSSL. \&\fICRYPTO_num_locks()\fR was added in OpenSSL 0.9.4. All functions dealing with dynamic locks were added in OpenSSL 0.9.5b\-dev. \&\fB\s-1CRYPTO_THREADID\s0\fR and associated functions were introduced in OpenSSL 1.0.0 to replace (actually, deprecate) the previous \fICRYPTO_set_id_callback()\fR, \&\fICRYPTO_get_id_callback()\fR, and \fICRYPTO_thread_id()\fR functions which assumed thread IDs to always be represented by 'unsigned long'. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIcrypto\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/d2i_X509_ALGOR.30000644000175000017500000001104112360020727017722 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "d2i_X509_ALGOR 3" .TH d2i_X509_ALGOR 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" d2i_X509_ALGOR, i2d_X509_ALGOR \- AlgorithmIdentifier functions. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& X509_ALGOR *d2i_X509_ALGOR(X509_ALGOR **a, unsigned char **pp, long length); \& int i2d_X509_ALGOR(X509_ALGOR *a, unsigned char **pp); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions decode and encode an \fBX509_ALGOR\fR structure which is equivalent to the \fBAlgorithmIdentifier\fR structure. .PP Othewise these behave in a similar way to \fId2i_X509()\fR and \fIi2d_X509()\fR described in the \fId2i_X509\fR\|(3) manual page. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fId2i_X509\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_set_bit.30000644000175000017500000001412312360020712017601 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_set_bit 3" .TH BN_set_bit 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_set_bit, BN_clear_bit, BN_is_bit_set, BN_mask_bits, BN_lshift, BN_lshift1, BN_rshift, BN_rshift1 \- bit operations on BIGNUMs .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int BN_set_bit(BIGNUM *a, int n); \& int BN_clear_bit(BIGNUM *a, int n); \& \& int BN_is_bit_set(const BIGNUM *a, int n); \& \& int BN_mask_bits(BIGNUM *a, int n); \& \& int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); \& int BN_lshift1(BIGNUM *r, BIGNUM *a); \& \& int BN_rshift(BIGNUM *r, BIGNUM *a, int n); \& int BN_rshift1(BIGNUM *r, BIGNUM *a); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBN_set_bit()\fR sets bit \fBn\fR in \fBa\fR to 1 (\f(CW\*(C`a|=(1<>n)\*(C'\fR). An error occurs if \fBa\fR already is shorter than \fBn\fR bits. .PP \&\fIBN_lshift()\fR shifts \fBa\fR left by \fBn\fR bits and places the result in \&\fBr\fR (\f(CW\*(C`r=a*2^n\*(C'\fR). \fIBN_lshift1()\fR shifts \fBa\fR left by one and places the result in \fBr\fR (\f(CW\*(C`r=2*a\*(C'\fR). .PP \&\fIBN_rshift()\fR shifts \fBa\fR right by \fBn\fR bits and places the result in \&\fBr\fR (\f(CW\*(C`r=a/2^n\*(C'\fR). \fIBN_rshift1()\fR shifts \fBa\fR right by one and places the result in \fBr\fR (\f(CW\*(C`r=a/2\*(C'\fR). .PP For the shift functions, \fBr\fR and \fBa\fR may be the same variable. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBN_is_bit_set()\fR returns 1 if the bit is set, 0 otherwise. .PP All other functions return 1 for success, 0 on error. The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3), \fIBN_num_bytes\fR\|(3), \fIBN_add\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIBN_set_bit()\fR, \fIBN_clear_bit()\fR, \fIBN_is_bit_set()\fR, \fIBN_mask_bits()\fR, \&\fIBN_lshift()\fR, \fIBN_lshift1()\fR, \fIBN_rshift()\fR, and \fIBN_rshift1()\fR are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/EC_POINT_new.30000644000175000017500000002770412360020716017717 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EC_POINT_new 3" .TH EC_POINT_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EC_POINT_new, EC_POINT_free, EC_POINT_clear_free, EC_POINT_copy, EC_POINT_dup, EC_POINT_method_of, EC_POINT_set_to_infinity, EC_POINT_set_Jprojective_coordinates, EC_POINT_get_Jprojective_coordinates_GFp, EC_POINT_set_affine_coordinates_GFp, EC_POINT_get_affine_coordinates_GFp, EC_POINT_set_compressed_coordinates_GFp, EC_POINT_set_affine_coordinates_GF2m, EC_POINT_get_affine_coordinates_GF2m, EC_POINT_set_compressed_coordinates_GF2m, EC_POINT_point2oct, EC_POINT_oct2point, EC_POINT_point2bn, EC_POINT_bn2point, EC_POINT_point2hex, EC_POINT_hex2point \- Functions for creating, destroying and manipulating EC_POINT objects. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& EC_POINT *EC_POINT_new(const EC_GROUP *group); \& void EC_POINT_free(EC_POINT *point); \& void EC_POINT_clear_free(EC_POINT *point); \& int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src); \& EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group); \& const EC_METHOD *EC_POINT_method_of(const EC_POINT *point); \& int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point); \& int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, \& const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx); \& int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, \& const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx); \& int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, \& const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx); \& int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, \& const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); \& int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, \& const BIGNUM *x, int y_bit, BN_CTX *ctx); \& int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, \& const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx); \& int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, \& const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); \& int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, \& const BIGNUM *x, int y_bit, BN_CTX *ctx); \& size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, \& point_conversion_form_t form, \& unsigned char *buf, size_t len, BN_CTX *ctx); \& int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, \& const unsigned char *buf, size_t len, BN_CTX *ctx); \& BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, \& point_conversion_form_t form, BIGNUM *, BN_CTX *); \& EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *, \& EC_POINT *, BN_CTX *); \& char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, \& point_conversion_form_t form, BN_CTX *); \& EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, \& EC_POINT *, BN_CTX *); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" An \s-1EC_POINT\s0 represents a point on a curve. A new point is constructed by calling the function EC_POINT_new and providing the \fBgroup\fR object that the point relates to. .PP EC_POINT_free frees the memory associated with the \s-1EC_POINT.\s0 .PP EC_POINT_clear_free destroys any sensitive data held within the \s-1EC_POINT\s0 and then frees its memory. .PP EC_POINT_copy copies the point \fBsrc\fR into \fBdst\fR. Both \fBsrc\fR and \fBdst\fR must use the same \s-1EC_METHOD.\s0 .PP EC_POINT_dup creates a new \s-1EC_POINT\s0 object and copies the content from \fBsrc\fR to the newly created \&\s-1EC_POINT\s0 object. .PP EC_POINT_method_of obtains the \s-1EC_METHOD\s0 associated with \fBpoint\fR. .PP A valid point on a curve is the special point at infinity. A point is set to be at infinity by calling EC_POINT_set_to_infinity. .PP The affine co-ordinates for a point describe a point in terms of its x and y position. The functions EC_POINT_set_affine_coordinates_GFp and EC_POINT_set_affine_coordinates_GF2m set the \fBx\fR and \fBy\fR co-ordinates for the point \&\fBp\fR defined over the curve given in \fBgroup\fR. .PP As well as the affine co-ordinates, a point can alternatively be described in terms of its Jacobian projective co-ordinates (for Fp curves only). Jacobian projective co-ordinates are expressed as three values x, y and z. Working in this co-ordinate system provides more efficient point multiplication operations. A mapping exists between Jacobian projective co-ordinates and affine co-ordinates. A Jacobian projective co-ordinate (x, y, z) can be written as an affine co-ordinate as (x/(z^2), y/(z^3)). Conversion to Jacobian projective to affine co-ordinates is simple. The co-ordinate (x, y) is mapped to (x, y, 1). To set or get the projective co-ordinates use EC_POINT_set_Jprojective_coordinates_GFp and EC_POINT_get_Jprojective_coordinates_GFp respectively. .PP Points can also be described in terms of their compressed co-ordinates. For a point (x, y), for any given value for x such that the point is on the curve there will only ever be two possible values for y. Therefore a point can be set using the EC_POINT_set_compressed_coordinates_GFp and EC_POINT_set_compressed_coordinates_GF2m functions where \fBx\fR is the x co-ordinate and \fBy_bit\fR is a value 0 or 1 to identify which of the two possible values for y should be used. .PP In addition EC_POINTs can be converted to and from various external representations. Supported representations are octet strings, BIGNUMs and hexadecimal. The format of the external representation is described by the point_conversion_form. See \fIEC_GROUP_copy\fR\|(3) for a description of point_conversion_form. Octet strings are stored in a buffer along with an associated buffer length. A point held in a \s-1BIGNUM\s0 is calculated by converting the point to an octet string and then converting that octet string into a \s-1BIGNUM\s0 integer. Points in hexadecimal format are stored in a \s-1NULL\s0 terminated character string where each character is one of the printable values 0\-9 or A\-F (or a\-f). .PP The functions EC_POINT_point2oct, EC_POINT_oct2point, EC_POINT_point2bn, EC_POINT_bn2point, EC_POINT_point2hex and EC_POINT_hex2point convert from and to EC_POINTs for the formats: octet string, \s-1BIGNUM\s0 and hexadecimal respectively. .PP The function EC_POINT_point2oct must be supplied with a buffer long enough to store the octet string. The return value provides the number of octets stored. Calling the function with a \s-1NULL\s0 buffer will not perform the conversion but will still return the required buffer length. .PP The function EC_POINT_point2hex will allocate sufficient memory to store the hexadecimal string. It is the caller's responsibility to free this memory with a subsequent call to \fIOPENSSL_free()\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" EC_POINT_new and EC_POINT_dup return the newly allocated \s-1EC_POINT\s0 or \s-1NULL\s0 on error. .PP The following functions return 1 on success or 0 on error: EC_POINT_copy, EC_POINT_set_to_infinity, EC_POINT_set_Jprojective_coordinates_GFp, EC_POINT_get_Jprojective_coordinates_GFp, EC_POINT_set_affine_coordinates_GFp, EC_POINT_get_affine_coordinates_GFp, EC_POINT_set_compressed_coordinates_GFp, EC_POINT_set_affine_coordinates_GF2m, EC_POINT_get_affine_coordinates_GF2m, EC_POINT_set_compressed_coordinates_GF2m and EC_POINT_oct2point. .PP EC_POINT_method_of returns the \s-1EC_METHOD\s0 associated with the supplied \s-1EC_POINT.\s0 .PP EC_POINT_point2oct returns the length of the required buffer, or 0 on error. .PP EC_POINT_point2bn returns the pointer to the \s-1BIGNUM\s0 supplied, or \s-1NULL\s0 on error. .PP EC_POINT_bn2point returns the pointer to the \s-1EC_POINT\s0 supplied, or \s-1NULL\s0 on error. .PP EC_POINT_point2hex returns a pointer to the hex string, or \s-1NULL\s0 on error. .PP EC_POINT_hex2point returns the pointer to the \s-1EC_POINT\s0 supplied, or \s-1NULL\s0 on error. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIcrypto\fR\|(3), \fIec\fR\|(3), \fIEC_GROUP_new\fR\|(3), \fIEC_GROUP_copy\fR\|(3), \&\fIEC_POINT_add\fR\|(3), \fIEC_KEY_new\fR\|(3), \&\fIEC_GFp_simple_method\fR\|(3), \fId2i_ECPKParameters\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_PKEY_CTX_ctrl.30000644000175000017500000002442012360020720020615 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_PKEY_CTX_ctrl 3" .TH EVP_PKEY_CTX_ctrl 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_PKEY_CTX_ctrl, EVP_PKEY_CTX_ctrl_str, EVP_PKEY_get_default_digest_nid, EVP_PKEY_CTX_set_signature_md, EVP_PKEY_CTX_set_rsa_padding, EVP_PKEY_CTX_set_rsa_pss_saltlen, EVP_PKEY_CTX_set_rsa_rsa_keygen_bits, EVP_PKEY_CTX_set_rsa_keygen_pubexp, EVP_PKEY_CTX_set_dsa_paramgen_bits, EVP_PKEY_CTX_set_dh_paramgen_prime_len, EVP_PKEY_CTX_set_dh_paramgen_generator, EVP_PKEY_CTX_set_ec_paramgen_curve_nid \- algorithm specific control operations .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, \& int cmd, int p1, void *p2); \& int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, \& const char *value); \& \& int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid); \& \& #include \& \& int EVP_PKEY_CTX_set_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); \& \& int EVP_PKEY_CTX_set_rsa_padding(EVP_PKEY_CTX *ctx, int pad); \& int EVP_PKEY_CTX_set_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int len); \& int EVP_PKEY_CTX_set_rsa_rsa_keygen_bits(EVP_PKEY_CTX *ctx, int mbits); \& int EVP_PKEY_CTX_set_rsa_keygen_pubexp(EVP_PKEY_CTX *ctx, BIGNUM *pubexp); \& \& #include \& int EVP_PKEY_CTX_set_dsa_paramgen_bits(EVP_PKEY_CTX *ctx, int nbits); \& \& #include \& int EVP_PKEY_CTX_set_dh_paramgen_prime_len(EVP_PKEY_CTX *ctx, int len); \& int EVP_PKEY_CTX_set_dh_paramgen_generator(EVP_PKEY_CTX *ctx, int gen); \& \& #include \& int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The function \fIEVP_PKEY_CTX_ctrl()\fR sends a control operation to the context \&\fBctx\fR. The key type used must match \fBkeytype\fR if it is not \-1. The parameter \&\fBoptype\fR is a mask indicating which operations the control can be applied to. The control command is indicated in \fBcmd\fR and any additional arguments in \&\fBp1\fR and \fBp2\fR. .PP Applications will not normally call \fIEVP_PKEY_CTX_ctrl()\fR directly but will instead call one of the algorithm specific macros below. .PP The function \fIEVP_PKEY_CTX_ctrl_str()\fR allows an application to send an algorithm specific control operation to a context \fBctx\fR in string form. This is intended to be used for options specified on the command line or in text files. The commands supported are documented in the openssl utility command line pages for the option \fB\-pkeyopt\fR which is supported by the \&\fBpkeyutl\fR, \fBgenpkey\fR and \fBreq\fR commands. .PP All the remaining \*(L"functions\*(R" are implemented as macros. .PP The \fIEVP_PKEY_CTX_set_signature_md()\fR macro sets the message digest type used in a signature. It can be used with any public key algorithm supporting signature operations. .PP The macro \fIEVP_PKEY_CTX_set_rsa_padding()\fR sets the \s-1RSA\s0 padding mode for \fBctx\fR. The \fBpad\fR parameter can take the value \s-1RSA_PKCS1_PADDING\s0 for PKCS#1 padding, \&\s-1RSA_SSLV23_PADDING\s0 for SSLv23 padding, \s-1RSA_NO_PADDING\s0 for no padding, \&\s-1RSA_PKCS1_OAEP_PADDING\s0 for \s-1OAEP\s0 padding (encrypt and decrypt only), \&\s-1RSA_X931_PADDING\s0 for X9.31 padding (signature operations only) and \&\s-1RSA_PKCS1_PSS_PADDING \s0(sign and verify only). .PP Two \s-1RSA\s0 padding modes behave differently if \fIEVP_PKEY_CTX_set_signature_md()\fR is used. If this macro is called for PKCS#1 padding the plaintext buffer is an actual digest value and is encapsulated in a DigestInfo structure according to PKCS#1 when signing and this structure is expected (and stripped off) when verifying. If this control is not used with \s-1RSA\s0 and PKCS#1 padding then the supplied data is used directly and not encapsulated. In the case of X9.31 padding for \s-1RSA\s0 the algorithm identifier byte is added or checked and removed if this control is called. If it is not called then the first byte of the plaintext buffer is expected to be the algorithm identifier byte. .PP The \fIEVP_PKEY_CTX_set_rsa_pss_saltlen()\fR macro sets the \s-1RSA PSS\s0 salt length to \&\fBlen\fR as its name implies it is only supported for \s-1PSS\s0 padding. Two special values are supported: \-1 sets the salt length to the digest length. When signing \-2 sets the salt length to the maximum permissible value. When verifying \-2 causes the salt length to be automatically determined based on the \&\fB\s-1PSS\s0\fR block structure. If this macro is not called a salt length value of \-2 is used by default. .PP The \fIEVP_PKEY_CTX_set_rsa_rsa_keygen_bits()\fR macro sets the \s-1RSA\s0 key length for \&\s-1RSA\s0 key genration to \fBbits\fR. If not specified 1024 bits is used. .PP The \fIEVP_PKEY_CTX_set_rsa_keygen_pubexp()\fR macro sets the public exponent value for \s-1RSA\s0 key generation to \fBpubexp\fR currently it should be an odd integer. The \&\fBpubexp\fR pointer is used internally by this function so it should not be modified or free after the call. If this macro is not called then 65537 is used. .PP The macro \fIEVP_PKEY_CTX_set_dsa_paramgen_bits()\fR sets the number of bits used for \s-1DSA\s0 parameter generation to \fBbits\fR. If not specified 1024 is used. .PP The macro \fIEVP_PKEY_CTX_set_dh_paramgen_prime_len()\fR sets the length of the \s-1DH\s0 prime parameter \fBp\fR for \s-1DH\s0 parameter generation. If this macro is not called then 1024 is used. .PP The \fIEVP_PKEY_CTX_set_dh_paramgen_generator()\fR macro sets \s-1DH\s0 generator to \fBgen\fR for \s-1DH\s0 parameter generation. If not specified 2 is used. .PP The \fIEVP_PKEY_CTX_set_ec_paramgen_curve_nid()\fR sets the \s-1EC\s0 curve for \s-1EC\s0 parameter generation to \fBnid\fR. For \s-1EC\s0 parameter generation this macro must be called or an error occurs because there is no default curve. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_PKEY_CTX_ctrl()\fR and its macros return a positive value for success and 0 or a negative value for failure. In particular a return value of \-2 indicates the operation is not supported by the public key algorithm. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_PKEY_CTX_new\fR\|(3), \&\fIEVP_PKEY_encrypt\fR\|(3), \&\fIEVP_PKEY_decrypt\fR\|(3), \&\fIEVP_PKEY_sign\fR\|(3), \&\fIEVP_PKEY_verify\fR\|(3), \&\fIEVP_PKEY_verify_recover\fR\|(3), \&\fIEVP_PKEY_derive\fR\|(3) \&\fIEVP_PKEY_keygen\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" These functions were first added to OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/asn1parse.10000644000175000017500000002314112360020740017465 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "asn1parse 1" .TH asn1parse 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" asn1parse \- ASN.1 parsing tool .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBasn1parse\fR [\fB\-inform PEM|DER\fR] [\fB\-in filename\fR] [\fB\-out filename\fR] [\fB\-noout\fR] [\fB\-offset number\fR] [\fB\-length number\fR] [\fB\-i\fR] [\fB\-oid filename\fR] [\fB\-strparse offset\fR] [\fB\-genstr string\fR] [\fB\-genconf file\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBasn1parse\fR command is a diagnostic utility that can parse \s-1ASN.1\s0 structures. It can also be used to extract data from \s-1ASN.1\s0 formatted data. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-inform\fR \fBDER|PEM\fR" 4 .IX Item "-inform DER|PEM" the input format. \fB\s-1DER\s0\fR is binary format and \fB\s-1PEM\s0\fR (the default) is base64 encoded. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" the input file, default is standard input .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" output file to place the \s-1DER\s0 encoded data into. If this option is not present then no data will be output. This is most useful when combined with the \fB\-strparse\fR option. .IP "\fB\-noout\fR" 4 .IX Item "-noout" don't output the parsed version of the input file. .IP "\fB\-offset number\fR" 4 .IX Item "-offset number" starting offset to begin parsing, default is start of file. .IP "\fB\-length number\fR" 4 .IX Item "-length number" number of bytes to parse, default is until end of file. .IP "\fB\-i\fR" 4 .IX Item "-i" indents the output according to the \*(L"depth\*(R" of the structures. .IP "\fB\-oid filename\fR" 4 .IX Item "-oid filename" a file containing additional \s-1OBJECT\s0 IDENTIFIERs (OIDs). The format of this file is described in the \s-1NOTES\s0 section below. .IP "\fB\-strparse offset\fR" 4 .IX Item "-strparse offset" parse the contents octets of the \s-1ASN.1\s0 object starting at \fBoffset\fR. This option can be used multiple times to \*(L"drill down\*(R" into a nested structure. .IP "\fB\-genstr string\fR, \fB\-genconf file\fR" 4 .IX Item "-genstr string, -genconf file" generate encoded data based on \fBstring\fR, \fBfile\fR or both using \&\fIASN1_generate_nconf\fR\|(3) format. If \fBfile\fR only is present then the string is obtained from the default section using the name \&\fBasn1\fR. The encoded data is passed through the \s-1ASN1\s0 parser and printed out as though it came from a file, the contents can thus be examined and written to a file using the \fBout\fR option. .SS "\s-1OUTPUT\s0" .IX Subsection "OUTPUT" The output will typically contain lines like this: .PP .Vb 1 \& 0:d=0 hl=4 l= 681 cons: SEQUENCE .Ve .PP \&..... .PP .Vb 10 \& 229:d=3 hl=3 l= 141 prim: BIT STRING \& 373:d=2 hl=3 l= 162 cons: cont [ 3 ] \& 376:d=3 hl=3 l= 159 cons: SEQUENCE \& 379:d=4 hl=2 l= 29 cons: SEQUENCE \& 381:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Subject Key Identifier \& 386:d=5 hl=2 l= 22 prim: OCTET STRING \& 410:d=4 hl=2 l= 112 cons: SEQUENCE \& 412:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Authority Key Identifier \& 417:d=5 hl=2 l= 105 prim: OCTET STRING \& 524:d=4 hl=2 l= 12 cons: SEQUENCE .Ve .PP \&..... .PP This example is part of a self signed certificate. Each line starts with the offset in decimal. \fBd=XX\fR specifies the current depth. The depth is increased within the scope of any \s-1SET\s0 or \s-1SEQUENCE. \s0\fBhl=XX\fR gives the header length (tag and length octets) of the current type. \fBl=XX\fR gives the length of the contents octets. .PP The \fB\-i\fR option can be used to make the output more readable. .PP Some knowledge of the \s-1ASN.1\s0 structure is needed to interpret the output. .PP In this example the \s-1BIT STRING\s0 at offset 229 is the certificate public key. The contents octets of this will contain the public key information. This can be examined using the option \fB\-strparse 229\fR to yield: .PP .Vb 3 \& 0:d=0 hl=3 l= 137 cons: SEQUENCE \& 3:d=1 hl=3 l= 129 prim: INTEGER :E5D21E1F5C8D208EA7A2166C7FAF9F6BDF2059669C60876DDB70840F1A5AAFA59699FE471F379F1DD6A487E7D5409AB6A88D4A9746E24B91D8CF55DB3521015460C8EDE44EE8A4189F7A7BE77D6CD3A9AF2696F486855CF58BF0EDF2B4068058C7A947F52548DDF7E15E96B385F86422BEA9064A3EE9E1158A56E4A6F47E5897 \& 135:d=1 hl=2 l= 3 prim: INTEGER :010001 .Ve .SH "NOTES" .IX Header "NOTES" If an \s-1OID\s0 is not part of OpenSSL's internal table it will be represented in numerical form (for example 1.2.3.4). The file passed to the \fB\-oid\fR option allows additional OIDs to be included. Each line consists of three columns, the first column is the \s-1OID\s0 in numerical format and should be followed by white space. The second column is the \*(L"short name\*(R" which is a single word followed by white space. The final column is the rest of the line and is the \&\*(L"long name\*(R". \fBasn1parse\fR displays the long name. Example: .PP \&\f(CW\*(C`1.2.3.4 shortName A long name\*(C'\fR .SH "EXAMPLES" .IX Header "EXAMPLES" Parse a file: .PP .Vb 1 \& openssl asn1parse \-in file.pem .Ve .PP Parse a \s-1DER\s0 file: .PP .Vb 1 \& openssl asn1parse \-inform DER \-in file.der .Ve .PP Generate a simple UTF8String: .PP .Vb 1 \& openssl asn1parse \-genstr \*(AqUTF8:Hello World\*(Aq .Ve .PP Generate and write out a UTF8String, don't print parsed output: .PP .Vb 1 \& openssl asn1parse \-genstr \*(AqUTF8:Hello World\*(Aq \-noout \-out utf8.der .Ve .PP Generate using a config file: .PP .Vb 1 \& openssl asn1parse \-genconf asn1.cnf \-noout \-out asn1.der .Ve .PP Example config file: .PP .Vb 1 \& asn1=SEQUENCE:seq_sect \& \& [seq_sect] \& \& field1=BOOL:TRUE \& field2=EXP:0, UTF8:some random string .Ve .SH "BUGS" .IX Header "BUGS" There should be options to change the format of output lines. The output of some \&\s-1ASN.1\s0 types is not well handled (if at all). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIASN1_generate_nconf\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_s_null.30000644000175000017500000001147312360020711017562 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_s_null 3" .TH BIO_s_null 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_s_null \- null data sink .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIO_METHOD * BIO_s_null(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_s_null()\fR returns the null sink \s-1BIO\s0 method. Data written to the null sink is discarded, reads return \s-1EOF.\s0 .SH "NOTES" .IX Header "NOTES" A null sink \s-1BIO\s0 behaves in a similar manner to the Unix /dev/null device. .PP A null bio can be placed on the end of a chain to discard any data passed through it. .PP A null sink is useful if, for example, an application wishes to digest some data by writing through a digest bio but not send the digested data anywhere. Since a \s-1BIO\s0 chain must normally include a source/sink \s-1BIO\s0 this can be achieved by adding a null sink \s-1BIO\s0 to the end of the chain .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBIO_s_null()\fR returns the null sink \s-1BIO\s0 method. deps/libressl-pnacl-sys-2.1.6/libressl/man/PKCS7_decrypt.30000644000175000017500000001334712360020722020162 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PKCS7_decrypt 3" .TH PKCS7_decrypt 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PKCS7_decrypt \- decrypt content from a PKCS#7 envelopedData structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIPKCS7_decrypt()\fR extracts and decrypts the content from a PKCS#7 envelopedData structure. \fBpkey\fR is the private key of the recipient, \fBcert\fR is the recipients certificate, \fBdata\fR is a \s-1BIO\s0 to write the content to and \&\fBflags\fR is an optional set of flags. .SH "NOTES" .IX Header "NOTES" \&\fIOpenSSL_add_all_algorithms()\fR (or equivalent) should be called before using this function or errors about unknown algorithms will occur. .PP Although the recipients certificate is not needed to decrypt the data it is needed to locate the appropriate (of possible several) recipients in the PKCS#7 structure. .PP The following flags can be passed in the \fBflags\fR parameter. .PP If the \fB\s-1PKCS7_TEXT\s0\fR flag is set \s-1MIME\s0 headers for type \fBtext/plain\fR are deleted from the content. If the content is not of type \fBtext/plain\fR then an error is returned. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIPKCS7_decrypt()\fR returns either 1 for success or 0 for failure. The error can be obtained from \fIERR_get_error\fR\|(3) .SH "BUGS" .IX Header "BUGS" \&\fIPKCS7_decrypt()\fR must be passed the correct recipient key and certificate. It would be better if it could look up the correct key and certificate from a database. .PP The lack of single pass processing and need to hold all data in memory as mentioned in \fIPKCS7_sign()\fR also applies to \fIPKCS7_verify()\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fIPKCS7_encrypt\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIPKCS7_decrypt()\fR was added to OpenSSL 0.9.5 deps/libressl-pnacl-sys-2.1.6/libressl/man/CRYPTO_set_ex_data.30000644000175000017500000001341312360020714021154 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CRYPTO_set_ex_data 3" .TH CRYPTO_set_ex_data 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CRYPTO_set_ex_data, CRYPTO_get_ex_data \- internal application specific data functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int CRYPTO_set_ex_data(CRYPTO_EX_DATA *r, int idx, void *arg); \& \& void *CRYPTO_get_ex_data(CRYPTO_EX_DATA *r, int idx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Several OpenSSL structures can have application specific data attached to them. These functions are used internally by OpenSSL to manipulate application specific data attached to a specific structure. .PP These functions should only be used by applications to manipulate \&\fB\s-1CRYPTO_EX_DATA\s0\fR structures passed to the \fB\f(BInew_func()\fB\fR, \fB\f(BIfree_func()\fB\fR and \&\fB\f(BIdup_func()\fB\fR callbacks: as passed to \fB\f(BIRSA_get_ex_new_index()\fB\fR for example. .PP \&\fB\f(BICRYPTO_set_ex_data()\fB\fR is used to set application specific data, the data is supplied in the \fBarg\fR parameter and its precise meaning is up to the application. .PP \&\fB\f(BICRYPTO_get_ex_data()\fB\fR is used to retrieve application specific data. The data is returned to the application, this will be the same value as supplied to a previous \fB\f(BICRYPTO_set_ex_data()\fB\fR call. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fB\f(BICRYPTO_set_ex_data()\fB\fR returns 1 on success or 0 on failure. .PP \&\fB\f(BICRYPTO_get_ex_data()\fB\fR returns the application data or 0 on failure. 0 may also be valid application data but currently it can only fail if given an invalid \fBidx\fR parameter. .PP On failure an error code can be obtained from \&\fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIRSA_get_ex_new_index\fR\|(3), \&\fIDSA_get_ex_new_index\fR\|(3), \&\fIDH_get_ex_new_index\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fICRYPTO_set_ex_data()\fR and \fICRYPTO_get_ex_data()\fR have been available since SSLeay 0.9.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/CMS_final.30000644000175000017500000001212412360020713017364 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CMS_final 3" .TH CMS_final 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CMS_final \- finalise a CMS_ContentInfo structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont, unsigned int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fICMS_final()\fR finalises the structure \fBcms\fR. It's purpose is to perform any operations necessary on \fBcms\fR (digest computation for example) and set the appropriate fields. The parameter \fBdata\fR contains the content to be processed. The \fBdcont\fR parameter contains a \s-1BIO\s0 to write content to after processing: this is only used with detached data and will usually be set to \&\s-1NULL.\s0 .SH "NOTES" .IX Header "NOTES" This function will normally be called when the \fB\s-1CMS_PARTIAL\s0\fR flag is used. It should only be used when streaming is not performed because the streaming I/O functions perform finalisation operations internally. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICMS_final()\fR returns 1 for success or 0 for failure. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_sign\fR\|(3), \&\fICMS_encrypt\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fICMS_final()\fR was added to OpenSSL 0.9.8 deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_set_shutdown.30000644000175000017500000001414212360020737021050 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_set_shutdown 3" .TH SSL_set_shutdown 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_set_shutdown, SSL_get_shutdown \- manipulate shutdown state of an SSL connection .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_set_shutdown(SSL *ssl, int mode); \& \& int SSL_get_shutdown(const SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_set_shutdown()\fR sets the shutdown state of \fBssl\fR to \fBmode\fR. .PP \&\fISSL_get_shutdown()\fR returns the shutdown mode of \fBssl\fR. .SH "NOTES" .IX Header "NOTES" The shutdown state of an ssl connection is a bitmask of: .IP "0" 4 No shutdown setting, yet. .IP "\s-1SSL_SENT_SHUTDOWN\s0" 4 .IX Item "SSL_SENT_SHUTDOWN" A \*(L"close notify\*(R" shutdown alert was sent to the peer, the connection is being considered closed and the session is closed and correct. .IP "\s-1SSL_RECEIVED_SHUTDOWN\s0" 4 .IX Item "SSL_RECEIVED_SHUTDOWN" A shutdown alert was received form the peer, either a normal \*(L"close notify\*(R" or a fatal error. .PP \&\s-1SSL_SENT_SHUTDOWN\s0 and \s-1SSL_RECEIVED_SHUTDOWN\s0 can be set at the same time. .PP The shutdown state of the connection is used to determine the state of the ssl session. If the session is still open, when \&\fISSL_clear\fR\|(3) or \fISSL_free\fR\|(3) is called, it is considered bad and removed according to \s-1RFC2246.\s0 The actual condition for a correctly closed session is \s-1SSL_SENT_SHUTDOWN \&\s0(according to the \s-1TLS RFC,\s0 it is acceptable to only send the \*(L"close notify\*(R" alert but to not wait for the peer's answer, when the underlying connection is closed). \&\fISSL_set_shutdown()\fR can be used to set this state without sending a close alert to the peer (see \fISSL_shutdown\fR\|(3)). .PP If a \*(L"close notify\*(R" was received, \s-1SSL_RECEIVED_SHUTDOWN\s0 will be set, for setting \s-1SSL_SENT_SHUTDOWN\s0 the application must however still call \&\fISSL_shutdown\fR\|(3) or \fISSL_set_shutdown()\fR itself. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_set_shutdown()\fR does not return diagnostic information. .PP \&\fISSL_get_shutdown()\fR returns the current setting. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_shutdown\fR\|(3), \&\fISSL_CTX_set_quiet_shutdown\fR\|(3), \&\fISSL_clear\fR\|(3), \fISSL_free\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/PEM_write_bio_CMS_stream.30000644000175000017500000001170112360020722022332 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PEM_write_bio_CMS_stream 3" .TH PEM_write_bio_CMS_stream 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PEM_write_bio_CMS_stream \- output CMS_ContentInfo structure in PEM format. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& int PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *data, int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIPEM_write_bio_CMS_stream()\fR outputs a CMS_ContentInfo structure in \s-1PEM\s0 format. .PP It is otherwise identical to the function \fISMIME_write_CMS()\fR. .SH "NOTES" .IX Header "NOTES" This function is effectively a version of the \fIPEM_write_bio_CMS()\fR supporting streaming. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIPEM_write_bio_CMS_stream()\fR returns 1 for success or 0 for failure. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_sign\fR\|(3), \&\fICMS_verify\fR\|(3), \fICMS_encrypt\fR\|(3) \&\fICMS_decrypt\fR\|(3), \&\fISMIME_write_CMS\fR\|(3), \&\fIi2d_CMS_bio_stream\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIPEM_write_bio_CMS_stream()\fR was added to OpenSSL 1.0.0 deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_read.30000644000175000017500000001510712360020710017176 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_read 3" .TH BIO_read 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_read, BIO_write, BIO_gets, BIO_puts \- BIO I/O functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int BIO_read(BIO *b, void *buf, int len); \& int BIO_gets(BIO *b,char *buf, int size); \& int BIO_write(BIO *b, const void *buf, int len); \& int BIO_puts(BIO *b,const char *buf); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_read()\fR attempts to read \fBlen\fR bytes from \s-1BIO \s0\fBb\fR and places the data in \fBbuf\fR. .PP \&\fIBIO_gets()\fR performs the BIOs \*(L"gets\*(R" operation and places the data in \fBbuf\fR. Usually this operation will attempt to read a line of data from the \s-1BIO\s0 of maximum length \fBlen\fR. There are exceptions to this however, for example \fIBIO_gets()\fR on a digest \s-1BIO\s0 will calculate and return the digest and other BIOs may not support \fIBIO_gets()\fR at all. .PP \&\fIBIO_write()\fR attempts to write \fBlen\fR bytes from \fBbuf\fR to \s-1BIO \s0\fBb\fR. .PP \&\fIBIO_puts()\fR attempts to write a null terminated string \fBbuf\fR to \s-1BIO \s0\fBb\fR .SH "RETURN VALUES" .IX Header "RETURN VALUES" All these functions return either the amount of data successfully read or written (if the return value is positive) or that no data was successfully read or written if the result is 0 or \-1. If the return value is \-2 then the operation is not implemented in the specific \s-1BIO\s0 type. .SH "NOTES" .IX Header "NOTES" A 0 or \-1 return is not necessarily an indication of an error. In particular when the source/sink is non-blocking or of a certain type it may merely be an indication that no data is currently available and that the application should retry the operation later. .PP One technique sometimes used with blocking sockets is to use a system call (such as \fIselect()\fR, \fIpoll()\fR or equivalent) to determine when data is available and then call \fIread()\fR to read the data. The equivalent with BIOs (that is call \&\fIselect()\fR on the underlying I/O structure and then call \fIBIO_read()\fR to read the data) should \fBnot\fR be used because a single call to \fIBIO_read()\fR can cause several reads (and writes in the case of \s-1SSL\s0 BIOs) on the underlying I/O structure and may block as a result. Instead \fIselect()\fR (or equivalent) should be combined with non blocking I/O so successive reads will request a retry instead of blocking. .PP See \fIBIO_should_retry\fR\|(3) for details of how to determine the cause of a retry and other I/O issues. .PP If the \fIBIO_gets()\fR function is not supported by a \s-1BIO\s0 then it possible to work around this by adding a buffering \s-1BIO \s0\fIBIO_f_buffer\fR\|(3) to the chain. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIBIO_should_retry\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/enc.10000644000175000017500000003540712360020741016346 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "enc 1" .TH enc 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" enc \- symmetric cipher routines .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl enc \-ciphername\fR [\fB\-in filename\fR] [\fB\-out filename\fR] [\fB\-pass arg\fR] [\fB\-e\fR] [\fB\-d\fR] [\fB\-a/\-base64\fR] [\fB\-A\fR] [\fB\-k password\fR] [\fB\-kfile filename\fR] [\fB\-K key\fR] [\fB\-iv \s-1IV\s0\fR] [\fB\-S salt\fR] [\fB\-salt\fR] [\fB\-nosalt\fR] [\fB\-z\fR] [\fB\-md\fR] [\fB\-p\fR] [\fB\-P\fR] [\fB\-bufsize number\fR] [\fB\-nopad\fR] [\fB\-debug\fR] [\fB\-none\fR] [\fB\-engine id\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The symmetric cipher commands allow data to be encrypted or decrypted using various block and stream ciphers using keys based on passwords or explicitly provided. Base64 encoding or decoding can also be performed either by itself or in addition to the encryption or decryption. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" the input filename, standard input by default. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" the output filename, standard output by default. .IP "\fB\-pass arg\fR" 4 .IX Item "-pass arg" the password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-salt\fR" 4 .IX Item "-salt" use a salt in the key derivation routines. This is the default. .IP "\fB\-nosalt\fR" 4 .IX Item "-nosalt" don't use a salt in the key derivation routines. This option \fB\s-1SHOULD NOT\s0\fR be used except for test purposes or compatibility with ancient versions of OpenSSL and SSLeay. .IP "\fB\-e\fR" 4 .IX Item "-e" encrypt the input data: this is the default. .IP "\fB\-d\fR" 4 .IX Item "-d" decrypt the input data. .IP "\fB\-a\fR" 4 .IX Item "-a" base64 process the data. This means that if encryption is taking place the data is base64 encoded after encryption. If decryption is set then the input data is base64 decoded before being decrypted. .IP "\fB\-base64\fR" 4 .IX Item "-base64" same as \fB\-a\fR .IP "\fB\-A\fR" 4 .IX Item "-A" if the \fB\-a\fR option is set then base64 process the data on one line. .IP "\fB\-k password\fR" 4 .IX Item "-k password" the password to derive the key from. This is for compatibility with previous versions of OpenSSL. Superseded by the \fB\-pass\fR argument. .IP "\fB\-kfile filename\fR" 4 .IX Item "-kfile filename" read the password to derive the key from the first line of \fBfilename\fR. This is for compatibility with previous versions of OpenSSL. Superseded by the \fB\-pass\fR argument. .IP "\fB\-nosalt\fR" 4 .IX Item "-nosalt" do not use a salt .IP "\fB\-salt\fR" 4 .IX Item "-salt" use salt (randomly generated or provide with \fB\-S\fR option) when encrypting (this is the default). .IP "\fB\-S salt\fR" 4 .IX Item "-S salt" the actual salt to use: this must be represented as a string of hex digits. .IP "\fB\-K key\fR" 4 .IX Item "-K key" the actual key to use: this must be represented as a string comprised only of hex digits. If only the key is specified, the \s-1IV\s0 must additionally specified using the \fB\-iv\fR option. When both a key and a password are specified, the key given with the \fB\-K\fR option will be used and the \s-1IV\s0 generated from the password will be taken. It probably does not make much sense to specify both key and password. .IP "\fB\-iv \s-1IV\s0\fR" 4 .IX Item "-iv IV" the actual \s-1IV\s0 to use: this must be represented as a string comprised only of hex digits. When only the key is specified using the \fB\-K\fR option, the \&\s-1IV\s0 must explicitly be defined. When a password is being specified using one of the other options, the \s-1IV\s0 is generated from this password. .IP "\fB\-p\fR" 4 .IX Item "-p" print out the key and \s-1IV\s0 used. .IP "\fB\-P\fR" 4 .IX Item "-P" print out the key and \s-1IV\s0 used then immediately exit: don't do any encryption or decryption. .IP "\fB\-bufsize number\fR" 4 .IX Item "-bufsize number" set the buffer size for I/O .IP "\fB\-nopad\fR" 4 .IX Item "-nopad" disable standard block padding .IP "\fB\-debug\fR" 4 .IX Item "-debug" debug the BIOs used for I/O. .IP "\fB\-z\fR" 4 .IX Item "-z" Compress or decompress clear text using zlib before encryption or after decryption. This option exists only if OpenSSL with compiled with zlib or zlib-dynamic option. .IP "\fB\-none\fR" 4 .IX Item "-none" Use \s-1NULL\s0 cipher (no encryption or decryption of input). .SH "NOTES" .IX Header "NOTES" The program can be called either as \fBopenssl ciphername\fR or \&\fBopenssl enc \-ciphername\fR. But the first form doesn't work with engine-provided ciphers, because this form is processed before the configuration file is read and any ENGINEs loaded. .PP Engines which provide entirely new encryption algorithms (such as ccgost engine which provides gost89 algorithm) should be configured in the configuration file. Engines, specified in the command line using \-engine options can only be used for hadrware-assisted implementations of ciphers, which are supported by OpenSSL core or other engine, specified in the configuration file. .PP When enc command lists supported ciphers, ciphers provided by engines, specified in the configuration files are listed too. .PP A password will be prompted for to derive the key and \s-1IV\s0 if necessary. .PP The \fB\-salt\fR option should \fB\s-1ALWAYS\s0\fR be used if the key is being derived from a password unless you want compatibility with previous versions of OpenSSL and SSLeay. .PP Without the \fB\-salt\fR option it is possible to perform efficient dictionary attacks on the password and to attack stream cipher encrypted data. The reason for this is that without the salt the same password always generates the same encryption key. When the salt is being used the first eight bytes of the encrypted data are reserved for the salt: it is generated at random when encrypting a file and read from the encrypted file when it is decrypted. .PP Some of the ciphers do not have large keys and others have security implications if not used correctly. A beginner is advised to just use a strong block cipher in \s-1CBC\s0 mode such as bf or des3. .PP All the block ciphers normally use PKCS#5 padding also known as standard block padding: this allows a rudimentary integrity or password check to be performed. However since the chance of random data passing the test is better than 1 in 256 it isn't a very good test. .PP If padding is disabled then the input data must be a multiple of the cipher block length. .PP All \s-1RC2\s0 ciphers have the same key and effective key length. .PP Blowfish and \s-1RC5\s0 algorithms use a 128 bit key. .SH "SUPPORTED CIPHERS" .IX Header "SUPPORTED CIPHERS" Note that some of these ciphers can be disabled at compile time and some are available only if an appropriate engine is configured in the configuration file. The output of the \fBenc\fR command run with unsupported options (for example \fBopenssl enc \-help\fR) includes a list of ciphers, supported by your versesion of OpenSSL, including ones provided by configured engines. .PP .Vb 1 \& base64 Base 64 \& \& bf\-cbc Blowfish in CBC mode \& bf Alias for bf\-cbc \& bf\-cfb Blowfish in CFB mode \& bf\-ecb Blowfish in ECB mode \& bf\-ofb Blowfish in OFB mode \& \& cast\-cbc CAST in CBC mode \& cast Alias for cast\-cbc \& cast5\-cbc CAST5 in CBC mode \& cast5\-cfb CAST5 in CFB mode \& cast5\-ecb CAST5 in ECB mode \& cast5\-ofb CAST5 in OFB mode \& \& des\-cbc DES in CBC mode \& des Alias for des\-cbc \& des\-cfb DES in CBC mode \& des\-ofb DES in OFB mode \& des\-ecb DES in ECB mode \& \& des\-ede\-cbc Two key triple DES EDE in CBC mode \& des\-ede Two key triple DES EDE in ECB mode \& des\-ede\-cfb Two key triple DES EDE in CFB mode \& des\-ede\-ofb Two key triple DES EDE in OFB mode \& \& des\-ede3\-cbc Three key triple DES EDE in CBC mode \& des\-ede3 Three key triple DES EDE in ECB mode \& des3 Alias for des\-ede3\-cbc \& des\-ede3\-cfb Three key triple DES EDE CFB mode \& des\-ede3\-ofb Three key triple DES EDE in OFB mode \& \& desx DESX algorithm. \& \& gost89 GOST 28147\-89 in CFB mode (provided by ccgost engine) \& gost89\-cnt \`GOST 28147\-89 in CNT mode (provided by ccgost engine) \& \& idea\-cbc IDEA algorithm in CBC mode \& idea same as idea\-cbc \& idea\-cfb IDEA in CFB mode \& idea\-ecb IDEA in ECB mode \& idea\-ofb IDEA in OFB mode \& \& rc2\-cbc 128 bit RC2 in CBC mode \& rc2 Alias for rc2\-cbc \& rc2\-cfb 128 bit RC2 in CFB mode \& rc2\-ecb 128 bit RC2 in ECB mode \& rc2\-ofb 128 bit RC2 in OFB mode \& rc2\-64\-cbc 64 bit RC2 in CBC mode \& rc2\-40\-cbc 40 bit RC2 in CBC mode \& \& rc4 128 bit RC4 \& rc4\-64 64 bit RC4 \& rc4\-40 40 bit RC4 \& \& rc5\-cbc RC5 cipher in CBC mode \& rc5 Alias for rc5\-cbc \& rc5\-cfb RC5 cipher in CFB mode \& rc5\-ecb RC5 cipher in ECB mode \& rc5\-ofb RC5 cipher in OFB mode \& \& aes\-[128|192|256]\-cbc 128/192/256 bit AES in CBC mode \& aes\-[128|192|256] Alias for aes\-[128|192|256]\-cbc \& aes\-[128|192|256]\-cfb 128/192/256 bit AES in 128 bit CFB mode \& aes\-[128|192|256]\-cfb1 128/192/256 bit AES in 1 bit CFB mode \& aes\-[128|192|256]\-cfb8 128/192/256 bit AES in 8 bit CFB mode \& aes\-[128|192|256]\-ecb 128/192/256 bit AES in ECB mode \& aes\-[128|192|256]\-ofb 128/192/256 bit AES in OFB mode .Ve .SH "EXAMPLES" .IX Header "EXAMPLES" Just base64 encode a binary file: .PP .Vb 1 \& openssl base64 \-in file.bin \-out file.b64 .Ve .PP Decode the same file .PP .Vb 1 \& openssl base64 \-d \-in file.b64 \-out file.bin .Ve .PP Encrypt a file using triple \s-1DES\s0 in \s-1CBC\s0 mode using a prompted password: .PP .Vb 1 \& openssl des3 \-salt \-in file.txt \-out file.des3 .Ve .PP Decrypt a file using a supplied password: .PP .Vb 1 \& openssl des3 \-d \-salt \-in file.des3 \-out file.txt \-k mypassword .Ve .PP Encrypt a file then base64 encode it (so it can be sent via mail for example) using Blowfish in \s-1CBC\s0 mode: .PP .Vb 1 \& openssl bf \-a \-salt \-in file.txt \-out file.bf .Ve .PP Base64 decode a file then decrypt it: .PP .Vb 1 \& openssl bf \-d \-salt \-a \-in file.bf \-out file.txt .Ve .PP Decrypt some data using a supplied 40 bit \s-1RC4\s0 key: .PP .Vb 1 \& openssl rc4\-40 \-in file.rc4 \-out file.txt \-K 0102030405 .Ve .SH "BUGS" .IX Header "BUGS" The \fB\-A\fR option when used with large files doesn't work properly. .PP There should be an option to allow an iteration count to be included. .PP The \fBenc\fR program only supports a fixed number of algorithms with certain parameters. So if, for example, you want to use \s-1RC2\s0 with a 76 bit key or \s-1RC4\s0 with an 84 bit key you can't use this program. deps/libressl-pnacl-sys-2.1.6/libressl/man/SMIME_read_PKCS7.30000644000175000017500000001410212360020725020346 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SMIME_read_PKCS7 3" .TH SMIME_read_PKCS7 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SMIME_read_PKCS7 \- parse S/MIME message. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& PKCS7 *SMIME_read_PKCS7(BIO *in, BIO **bcont); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISMIME_read_PKCS7()\fR parses a message in S/MIME format. .PP \&\fBin\fR is a \s-1BIO\s0 to read the message from. .PP If cleartext signing is used then the content is saved in a memory bio which is written to \fB*bcont\fR, otherwise \&\fB*bcont\fR is set to \fB\s-1NULL\s0\fR. .PP The parsed PKCS#7 structure is returned or \fB\s-1NULL\s0\fR if an error occurred. .SH "NOTES" .IX Header "NOTES" If \fB*bcont\fR is not \fB\s-1NULL\s0\fR then the message is clear text signed. \fB*bcont\fR can then be passed to \fIPKCS7_verify()\fR with the \fB\s-1PKCS7_DETACHED\s0\fR flag set. .PP Otherwise the type of the returned structure can be determined using \fIPKCS7_type()\fR. .PP To support future functionality if \fBbcont\fR is not \fB\s-1NULL\s0\fR \&\fB*bcont\fR should be initialized to \fB\s-1NULL\s0\fR. For example: .PP .Vb 2 \& BIO *cont = NULL; \& PKCS7 *p7; \& \& p7 = SMIME_read_PKCS7(in, &cont); .Ve .SH "BUGS" .IX Header "BUGS" The \s-1MIME\s0 parser used by \fISMIME_read_PKCS7()\fR is somewhat primitive. While it will handle most S/MIME messages more complex compound formats may not work. .PP The parser assumes that the \s-1PKCS7\s0 structure is always base64 encoded and will not handle the case where it is in binary format or uses quoted printable format. .PP The use of a memory \s-1BIO\s0 to hold the signed content limits the size of message which can be processed due to memory restraints: a streaming single pass option should be available. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISMIME_read_PKCS7()\fR returns a valid \fB\s-1PKCS7\s0\fR structure or \fB\s-1NULL\s0\fR is an error occurred. The error can be obtained from \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fIPKCS7_type\fR\|(3) \&\fISMIME_read_PKCS7\fR\|(3), \fIPKCS7_sign\fR\|(3), \&\fIPKCS7_verify\fR\|(3), \fIPKCS7_encrypt\fR\|(3) \&\fIPKCS7_decrypt\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fISMIME_read_PKCS7()\fR was added to OpenSSL 0.9.5 deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_write.30000644000175000017500000002056312360020737017460 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_write 3" .TH SSL_write 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_write \- write bytes to a TLS/SSL connection. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_write(SSL *ssl, const void *buf, int num); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_write()\fR writes \fBnum\fR bytes from the buffer \fBbuf\fR into the specified \&\fBssl\fR connection. .SH "NOTES" .IX Header "NOTES" If necessary, \fISSL_write()\fR will negotiate a \s-1TLS/SSL\s0 session, if not already explicitly performed by \fISSL_connect\fR\|(3) or \&\fISSL_accept\fR\|(3). If the peer requests a re-negotiation, it will be performed transparently during the \fISSL_write()\fR operation. The behaviour of \fISSL_write()\fR depends on the underlying \s-1BIO.\s0 .PP For the transparent negotiation to succeed, the \fBssl\fR must have been initialized to client or server mode. This is being done by calling \&\fISSL_set_connect_state\fR\|(3) or \fISSL_set_accept_state()\fR before the first call to an \fISSL_read\fR\|(3) or \fISSL_write()\fR function. .PP If the underlying \s-1BIO\s0 is \fBblocking\fR, \fISSL_write()\fR will only return, once the write operation has been finished or an error occurred, except when a renegotiation take place, in which case a \s-1SSL_ERROR_WANT_READ\s0 may occur. This behaviour can be controlled with the \s-1SSL_MODE_AUTO_RETRY\s0 flag of the \&\fISSL_CTX_set_mode\fR\|(3) call. .PP If the underlying \s-1BIO\s0 is \fBnon-blocking\fR, \fISSL_write()\fR will also return, when the underlying \s-1BIO\s0 could not satisfy the needs of \fISSL_write()\fR to continue the operation. In this case a call to \&\fISSL_get_error\fR\|(3) with the return value of \fISSL_write()\fR will yield \fB\s-1SSL_ERROR_WANT_READ\s0\fR or \&\fB\s-1SSL_ERROR_WANT_WRITE\s0\fR. As at any time a re-negotiation is possible, a call to \fISSL_write()\fR can also cause read operations! The calling process then must repeat the call after taking appropriate action to satisfy the needs of \fISSL_write()\fR. The action depends on the underlying \s-1BIO.\s0 When using a non-blocking socket, nothing is to be done, but \fIselect()\fR can be used to check for the required condition. When using a buffering \s-1BIO,\s0 like a \s-1BIO\s0 pair, data must be written into or retrieved out of the \s-1BIO\s0 before being able to continue. .PP \&\fISSL_write()\fR will only return with success, when the complete contents of \fBbuf\fR of length \fBnum\fR has been written. This default behaviour can be changed with the \s-1SSL_MODE_ENABLE_PARTIAL_WRITE\s0 option of \&\fISSL_CTX_set_mode\fR\|(3). When this flag is set, \&\fISSL_write()\fR will also return with success, when a partial write has been successfully completed. In this case the \fISSL_write()\fR operation is considered completed. The bytes are sent and a new \fISSL_write()\fR operation with a new buffer (with the already sent bytes removed) must be started. A partial write is performed with the size of a message block, which is 16kB for SSLv3/TLSv1. .SH "WARNING" .IX Header "WARNING" When an \fISSL_write()\fR operation has to be repeated because of \&\fB\s-1SSL_ERROR_WANT_READ\s0\fR or \fB\s-1SSL_ERROR_WANT_WRITE\s0\fR, it must be repeated with the same arguments. .PP When calling \fISSL_write()\fR with num=0 bytes to be sent the behaviour is undefined. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .ie n .IP """>0""" 4 .el .IP "\f(CW>0\fR" 4 .IX Item ">0" The write operation was successful, the return value is the number of bytes actually written to the \s-1TLS/SSL\s0 connection. .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" The write operation was not successful. Probably the underlying connection was closed. Call \fISSL_get_error()\fR with the return value \fBret\fR to find out, whether an error occurred or the connection was shut down cleanly (\s-1SSL_ERROR_ZERO_RETURN\s0). .Sp SSLv2 (deprecated) does not support a shutdown alert protocol, so it can only be detected, whether the underlying connection was closed. It cannot be checked, why the closure happened. .ie n .IP """<0""" 4 .el .IP "\f(CW<0\fR" 4 .IX Item "<0" The write operation was not successful, because either an error occurred or action must be taken by the calling process. Call \fISSL_get_error()\fR with the return value \fBret\fR to find out the reason. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_get_error\fR\|(3), \fISSL_read\fR\|(3), \&\fISSL_CTX_set_mode\fR\|(3), \fISSL_CTX_new\fR\|(3), \&\fISSL_connect\fR\|(3), \fISSL_accept\fR\|(3) \&\fISSL_set_connect_state\fR\|(3), \&\fIssl\fR\|(3), \fIbio\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/DES_set_key.30000644000175000017500000005051712360020714017740 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DES_set_key 3" .TH DES_set_key 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DES_random_key, DES_set_key, DES_key_sched, DES_set_key_checked, DES_set_key_unchecked, DES_set_odd_parity, DES_is_weak_key, DES_ecb_encrypt, DES_ecb2_encrypt, DES_ecb3_encrypt, DES_ncbc_encrypt, DES_cfb_encrypt, DES_ofb_encrypt, DES_pcbc_encrypt, DES_cfb64_encrypt, DES_ofb64_encrypt, DES_xcbc_encrypt, DES_ede2_cbc_encrypt, DES_ede2_cfb64_encrypt, DES_ede2_ofb64_encrypt, DES_ede3_cbc_encrypt, DES_ede3_cbcm_encrypt, DES_ede3_cfb64_encrypt, DES_ede3_ofb64_encrypt, DES_cbc_cksum, DES_quad_cksum, DES_string_to_key, DES_string_to_2keys, DES_fcrypt, DES_crypt, DES_enc_read, DES_enc_write \- DES encryption .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void DES_random_key(DES_cblock *ret); \& \& int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule); \& int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule); \& int DES_set_key_checked(const_DES_cblock *key, \& DES_key_schedule *schedule); \& void DES_set_key_unchecked(const_DES_cblock *key, \& DES_key_schedule *schedule); \& \& void DES_set_odd_parity(DES_cblock *key); \& int DES_is_weak_key(const_DES_cblock *key); \& \& void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, \& DES_key_schedule *ks, int enc); \& void DES_ecb2_encrypt(const_DES_cblock *input, DES_cblock *output, \& DES_key_schedule *ks1, DES_key_schedule *ks2, int enc); \& void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, \& DES_key_schedule *ks1, DES_key_schedule *ks2, \& DES_key_schedule *ks3, int enc); \& \& void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output, \& long length, DES_key_schedule *schedule, DES_cblock *ivec, \& int enc); \& void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, \& int numbits, long length, DES_key_schedule *schedule, \& DES_cblock *ivec, int enc); \& void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, \& int numbits, long length, DES_key_schedule *schedule, \& DES_cblock *ivec); \& void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, \& long length, DES_key_schedule *schedule, DES_cblock *ivec, \& int enc); \& void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out, \& long length, DES_key_schedule *schedule, DES_cblock *ivec, \& int *num, int enc); \& void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out, \& long length, DES_key_schedule *schedule, DES_cblock *ivec, \& int *num); \& \& void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output, \& long length, DES_key_schedule *schedule, DES_cblock *ivec, \& const_DES_cblock *inw, const_DES_cblock *outw, int enc); \& \& void DES_ede2_cbc_encrypt(const unsigned char *input, \& unsigned char *output, long length, DES_key_schedule *ks1, \& DES_key_schedule *ks2, DES_cblock *ivec, int enc); \& void DES_ede2_cfb64_encrypt(const unsigned char *in, \& unsigned char *out, long length, DES_key_schedule *ks1, \& DES_key_schedule *ks2, DES_cblock *ivec, int *num, int enc); \& void DES_ede2_ofb64_encrypt(const unsigned char *in, \& unsigned char *out, long length, DES_key_schedule *ks1, \& DES_key_schedule *ks2, DES_cblock *ivec, int *num); \& \& void DES_ede3_cbc_encrypt(const unsigned char *input, \& unsigned char *output, long length, DES_key_schedule *ks1, \& DES_key_schedule *ks2, DES_key_schedule *ks3, DES_cblock *ivec, \& int enc); \& void DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, \& long length, DES_key_schedule *ks1, DES_key_schedule *ks2, \& DES_key_schedule *ks3, DES_cblock *ivec1, DES_cblock *ivec2, \& int enc); \& void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, \& long length, DES_key_schedule *ks1, DES_key_schedule *ks2, \& DES_key_schedule *ks3, DES_cblock *ivec, int *num, int enc); \& void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out, \& long length, DES_key_schedule *ks1, \& DES_key_schedule *ks2, DES_key_schedule *ks3, \& DES_cblock *ivec, int *num); \& \& DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output, \& long length, DES_key_schedule *schedule, \& const_DES_cblock *ivec); \& DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[], \& long length, int out_count, DES_cblock *seed); \& void DES_string_to_key(const char *str, DES_cblock *key); \& void DES_string_to_2keys(const char *str, DES_cblock *key1, \& DES_cblock *key2); \& \& char *DES_fcrypt(const char *buf, const char *salt, char *ret); \& char *DES_crypt(const char *buf, const char *salt); \& \& int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched, \& DES_cblock *iv); \& int DES_enc_write(int fd, const void *buf, int len, \& DES_key_schedule *sched, DES_cblock *iv); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This library contains a fast implementation of the \s-1DES\s0 encryption algorithm. .PP There are two phases to the use of \s-1DES\s0 encryption. The first is the generation of a \fIDES_key_schedule\fR from a key, the second is the actual encryption. A \s-1DES\s0 key is of type \fIDES_cblock\fR. This type is consists of 8 bytes with odd parity. The least significant bit in each byte is the parity bit. The key schedule is an expanded form of the key; it is used to speed the encryption process. .PP \&\fIDES_random_key()\fR generates a random key. .PP Before a \s-1DES\s0 key can be used, it must be converted into the architecture dependent \fIDES_key_schedule\fR via the \&\fIDES_set_key_checked()\fR or \fIDES_set_key_unchecked()\fR function. .PP \&\fIDES_set_key_checked()\fR will check that the key passed is of odd parity and is not a week or semi-weak key. If the parity is wrong, then \-1 is returned. If the key is a weak key, then \-2 is returned. If an error is returned, the key schedule is not generated. .PP \&\fIDES_set_key()\fR works like \&\fIDES_set_key_checked()\fR if the \fIDES_check_key\fR flag is non-zero, otherwise like \fIDES_set_key_unchecked()\fR. These functions are available for compatibility; it is recommended to use a function that does not depend on a global variable. .PP \&\fIDES_set_odd_parity()\fR sets the parity of the passed \fIkey\fR to odd. .PP \&\fIDES_is_weak_key()\fR returns 1 is the passed key is a weak key, 0 if it is ok. The probability that a randomly generated key is weak is 1/2^52, so it is not really worth checking for them. .PP The following routines mostly operate on an input and output stream of \&\fIDES_cblock\fRs. .PP \&\fIDES_ecb_encrypt()\fR is the basic \s-1DES\s0 encryption routine that encrypts or decrypts a single 8\-byte \fIDES_cblock\fR in \fIelectronic code book\fR (\s-1ECB\s0) mode. It always transforms the input data, pointed to by \&\fIinput\fR, into the output data, pointed to by the \fIoutput\fR argument. If the \fIencrypt\fR argument is non-zero (\s-1DES_ENCRYPT\s0), the \fIinput\fR (cleartext) is encrypted in to the \fIoutput\fR (ciphertext) using the key_schedule specified by the \fIschedule\fR argument, previously set via \&\fIDES_set_key\fR. If \fIencrypt\fR is zero (\s-1DES_DECRYPT\s0), the \fIinput\fR (now ciphertext) is decrypted into the \fIoutput\fR (now cleartext). Input and output may overlap. \fIDES_ecb_encrypt()\fR does not return a value. .PP \&\fIDES_ecb3_encrypt()\fR encrypts/decrypts the \fIinput\fR block by using three-key Triple-DES encryption in \s-1ECB\s0 mode. This involves encrypting the input with \fIks1\fR, decrypting with the key schedule \fIks2\fR, and then encrypting with \fIks3\fR. This routine greatly reduces the chances of brute force breaking of \s-1DES\s0 and has the advantage of if \fIks1\fR, \&\fIks2\fR and \fIks3\fR are the same, it is equivalent to just encryption using \s-1ECB\s0 mode and \fIks1\fR as the key. .PP The macro \fIDES_ecb2_encrypt()\fR is provided to perform two-key Triple-DES encryption by using \fIks1\fR for the final encryption. .PP \&\fIDES_ncbc_encrypt()\fR encrypts/decrypts using the \fIcipher-block-chaining\fR (\s-1CBC\s0) mode of \s-1DES. \s0 If the \fIencrypt\fR argument is non-zero, the routine cipher-block-chain encrypts the cleartext data pointed to by the \fIinput\fR argument into the ciphertext pointed to by the \fIoutput\fR argument, using the key schedule provided by the \fIschedule\fR argument, and initialization vector provided by the \fIivec\fR argument. If the \&\fIlength\fR argument is not an integral multiple of eight bytes, the last block is copied to a temporary area and zero filled. The output is always an integral multiple of eight bytes. .PP \&\fIDES_xcbc_encrypt()\fR is \s-1RSA\s0's \s-1DESX\s0 mode of \s-1DES. \s0 It uses \fIinw\fR and \&\fIoutw\fR to 'whiten' the encryption. \fIinw\fR and \fIoutw\fR are secret (unlike the iv) and are as such, part of the key. So the key is sort of 24 bytes. This is much better than \s-1CBC DES.\s0 .PP \&\fIDES_ede3_cbc_encrypt()\fR implements outer triple \s-1CBC DES\s0 encryption with three keys. This means that each \s-1DES\s0 operation inside the \s-1CBC\s0 mode is really an \f(CW\*(C`C=E(ks3,D(ks2,E(ks1,M)))\*(C'\fR. This mode is used by \s-1SSL.\s0 .PP The \fIDES_ede2_cbc_encrypt()\fR macro implements two-key Triple-DES by reusing \fIks1\fR for the final encryption. \f(CW\*(C`C=E(ks1,D(ks2,E(ks1,M)))\*(C'\fR. This form of Triple-DES is used by the \s-1RSAREF\s0 library. .PP \&\fIDES_pcbc_encrypt()\fR encrypt/decrypts using the propagating cipher block chaining mode used by Kerberos v4. Its parameters are the same as \&\fIDES_ncbc_encrypt()\fR. .PP \&\fIDES_cfb_encrypt()\fR encrypt/decrypts using cipher feedback mode. This method takes an array of characters as input and outputs and array of characters. It does not require any padding to 8 character groups. Note: the \fIivec\fR variable is changed and the new changed value needs to be passed to the next call to this function. Since this function runs a complete \s-1DES ECB\s0 encryption per \fInumbits\fR, this function is only suggested for use when sending small numbers of characters. .PP \&\fIDES_cfb64_encrypt()\fR implements \s-1CFB\s0 mode of \s-1DES\s0 with 64bit feedback. Why is this useful you ask? Because this routine will allow you to encrypt an arbitrary number of bytes, no 8 byte padding. Each call to this routine will encrypt the input bytes to output and then update ivec and num. num contains 'how far' we are though ivec. If this does not make much sense, read more about cfb mode of \s-1DES :\-\s0). .PP \&\fIDES_ede3_cfb64_encrypt()\fR and \fIDES_ede2_cfb64_encrypt()\fR is the same as \&\fIDES_cfb64_encrypt()\fR except that Triple-DES is used. .PP \&\fIDES_ofb_encrypt()\fR encrypts using output feedback mode. This method takes an array of characters as input and outputs and array of characters. It does not require any padding to 8 character groups. Note: the \fIivec\fR variable is changed and the new changed value needs to be passed to the next call to this function. Since this function runs a complete \s-1DES ECB\s0 encryption per numbits, this function is only suggested for use when sending small numbers of characters. .PP \&\fIDES_ofb64_encrypt()\fR is the same as \fIDES_cfb64_encrypt()\fR using Output Feed Back mode. .PP \&\fIDES_ede3_ofb64_encrypt()\fR and \fIDES_ede2_ofb64_encrypt()\fR is the same as \&\fIDES_ofb64_encrypt()\fR, using Triple-DES. .PP The following functions are included in the \s-1DES\s0 library for compatibility with the \s-1MIT\s0 Kerberos library. .PP \&\fIDES_cbc_cksum()\fR produces an 8 byte checksum based on the input stream (via \s-1CBC\s0 encryption). The last 4 bytes of the checksum are returned and the complete 8 bytes are placed in \fIoutput\fR. This function is used by Kerberos v4. Other applications should use \&\fIEVP_DigestInit\fR\|(3) etc. instead. .PP \&\fIDES_quad_cksum()\fR is a Kerberos v4 function. It returns a 4 byte checksum from the input bytes. The algorithm can be iterated over the input, depending on \fIout_count\fR, 1, 2, 3 or 4 times. If \fIoutput\fR is non-NULL, the 8 bytes generated by each pass are written into \&\fIoutput\fR. .PP The following are DES-based transformations: .PP \&\fIDES_fcrypt()\fR is a fast version of the Unix \fIcrypt\fR\|(3) function. This version takes only a small amount of space relative to other fast \&\fIcrypt()\fR implementations. This is different to the normal crypt in that the third parameter is the buffer that the return value is written into. It needs to be at least 14 bytes long. This function is thread safe, unlike the normal crypt. .PP \&\fIDES_crypt()\fR is a faster replacement for the normal system \fIcrypt()\fR. This function calls \fIDES_fcrypt()\fR with a static array passed as the third parameter. This emulates the normal non-thread safe semantics of \fIcrypt\fR\|(3). .PP \&\fIDES_enc_write()\fR writes \fIlen\fR bytes to file descriptor \fIfd\fR from buffer \fIbuf\fR. The data is encrypted via \fIpcbc_encrypt\fR (default) using \fIsched\fR for the key and \fIiv\fR as a starting vector. The actual data send down \fIfd\fR consists of 4 bytes (in network byte order) containing the length of the following encrypted data. The encrypted data then follows, padded with random data out to a multiple of 8 bytes. .PP \&\fIDES_enc_read()\fR is used to read \fIlen\fR bytes from file descriptor \&\fIfd\fR into buffer \fIbuf\fR. The data being read from \fIfd\fR is assumed to have come from \fIDES_enc_write()\fR and is decrypted using \fIsched\fR for the key schedule and \fIiv\fR for the initial vector. .PP \&\fBWarning:\fR The data format used by \fIDES_enc_write()\fR and \fIDES_enc_read()\fR has a cryptographic weakness: When asked to write more than \s-1MAXWRITE\s0 bytes, \fIDES_enc_write()\fR will split the data into several chunks that are all encrypted using the same \s-1IV. \s0 So don't use these functions unless you are sure you know what you do (in which case you might not want to use them anyway). They cannot handle non-blocking sockets. \&\fIDES_enc_read()\fR uses an internal state and thus cannot be used on multiple files. .PP \&\fIDES_rw_mode\fR is used to specify the encryption mode to use with \&\fIDES_enc_read()\fR and \fIDES_end_write()\fR. If set to \fI\s-1DES_PCBC_MODE\s0\fR (the default), DES_pcbc_encrypt is used. If set to \fI\s-1DES_CBC_MODE\s0\fR DES_cbc_encrypt is used. .SH "NOTES" .IX Header "NOTES" Single-key \s-1DES\s0 is insecure due to its short key size. \s-1ECB\s0 mode is not suitable for most applications. .PP The \fIevp\fR\|(3) library provides higher-level encryption functions. .SH "BUGS" .IX Header "BUGS" \&\fIDES_cbc_encrypt()\fR does not modify \fBivec\fR; use \fIDES_ncbc_encrypt()\fR instead. .PP \&\fIDES_cfb_encrypt()\fR and \fIDES_ofb_encrypt()\fR operates on input of 8 bits. What this means is that if you set numbits to 12, and length to 2, the first 12 bits will come from the 1st input byte and the low half of the second input byte. The second 12 bits will have the low 8 bits taken from the 3rd input byte and the top 4 bits taken from the 4th input byte. The same holds for output. This function has been implemented this way because most people will be using a multiple of 8 and because once you get into pulling bytes input bytes apart things get ugly! .PP \&\fIDES_string_to_key()\fR is available for backward compatibility with the \&\s-1MIT\s0 library. New applications should use a cryptographic hash function. The same applies for \fIDES_string_to_2key()\fR. .SH "CONFORMING TO" .IX Header "CONFORMING TO" \&\s-1ANSI X3.106\s0 .PP The \fBdes\fR library was initially written to be source code compatible with the \s-1MIT\s0 Kerberos library. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIcrypt\fR\|(3), \fIevp\fR\|(3), \fIrand\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" In OpenSSL 0.9.7, all des_ functions were renamed to \s-1DES_\s0 to avoid clashes with older versions of libdes. .PP \&\fIDES_set_key_checked()\fR and \fIDES_set_key_unchecked()\fR were added in OpenSSL 0.9.5. .PP \&\fIdes_generate_random_block()\fR, \fIdes_init_random_number_generator()\fR, \&\fIdes_new_random_key()\fR, \fIdes_set_random_generator_seed()\fR and \&\fIdes_set_sequence_number()\fR and \fIdes_rand_data()\fR are used in newer versions of Kerberos but are not implemented here. .PP \&\fIDES_random_key()\fR generated cryptographically weak random data in SSLeay and in OpenSSL prior version 0.9.5, as well as in the original \&\s-1MIT\s0 library. .SH "AUTHOR" .IX Header "AUTHOR" Eric Young (eay@cryptsoft.com). Modified for the OpenSSL project (http://www.openssl.org). deps/libressl-pnacl-sys-2.1.6/libressl/man/RSA_padding_add_PKCS1_type_1.30000644000175000017500000001775412360020724022716 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RSA_padding_add_PKCS1_type_1 3" .TH RSA_padding_add_PKCS1_type_1 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RSA_padding_add_PKCS1_type_1, RSA_padding_check_PKCS1_type_1, RSA_padding_add_PKCS1_type_2, RSA_padding_check_PKCS1_type_2, RSA_padding_add_PKCS1_OAEP, RSA_padding_check_PKCS1_OAEP, RSA_padding_add_SSLv23, RSA_padding_check_SSLv23, RSA_padding_add_none, RSA_padding_check_none \- asymmetric encryption padding .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen, \& unsigned char *f, int fl); \& \& int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen, \& unsigned char *f, int fl, int rsa_len); \& \& int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen, \& unsigned char *f, int fl); \& \& int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, \& unsigned char *f, int fl, int rsa_len); \& \& int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, \& unsigned char *f, int fl, unsigned char *p, int pl); \& \& int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, \& unsigned char *f, int fl, int rsa_len, unsigned char *p, int pl); \& \& int RSA_padding_add_SSLv23(unsigned char *to, int tlen, \& unsigned char *f, int fl); \& \& int RSA_padding_check_SSLv23(unsigned char *to, int tlen, \& unsigned char *f, int fl, int rsa_len); \& \& int RSA_padding_add_none(unsigned char *to, int tlen, \& unsigned char *f, int fl); \& \& int RSA_padding_check_none(unsigned char *to, int tlen, \& unsigned char *f, int fl, int rsa_len); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fIRSA_padding_xxx_xxx()\fR functions are called from the \s-1RSA\s0 encrypt, decrypt, sign and verify functions. Normally they should not be called from application programs. .PP However, they can also be called directly to implement padding for other asymmetric ciphers. \fIRSA_padding_add_PKCS1_OAEP()\fR and \&\fIRSA_padding_check_PKCS1_OAEP()\fR may be used in an application combined with \fB\s-1RSA_NO_PADDING\s0\fR in order to implement \s-1OAEP\s0 with an encoding parameter. .PP \&\fIRSA_padding_add_xxx()\fR encodes \fBfl\fR bytes from \fBf\fR so as to fit into \&\fBtlen\fR bytes and stores the result at \fBto\fR. An error occurs if \fBfl\fR does not meet the size requirements of the encoding method. .PP The following encoding methods are implemented: .IP "PKCS1_type_1" 4 .IX Item "PKCS1_type_1" \&\s-1PKCS\s0 #1 v2.0 EMSA\-PKCS1\-v1_5 (\s-1PKCS\s0 #1 v1.5 block type 1); used for signatures .IP "PKCS1_type_2" 4 .IX Item "PKCS1_type_2" \&\s-1PKCS\s0 #1 v2.0 EME\-PKCS1\-v1_5 (\s-1PKCS\s0 #1 v1.5 block type 2) .IP "\s-1PKCS1_OAEP\s0" 4 .IX Item "PKCS1_OAEP" \&\s-1PKCS\s0 #1 v2.0 EME-OAEP .IP "SSLv23" 4 .IX Item "SSLv23" \&\s-1PKCS\s0 #1 EME\-PKCS1\-v1_5 with SSL-specific modification .IP "none" 4 .IX Item "none" simply copy the data .PP \&\fIRSA_padding_check_xxx()\fR verifies that the \fBfl\fR bytes at \fBf\fR contain a valid encoding for a \fBrsa_len\fR byte \s-1RSA\s0 key in the respective encoding method and stores the recovered data of at most \fBtlen\fR bytes (for \fB\s-1RSA_NO_PADDING\s0\fR: of size \fBtlen\fR) at \fBto\fR. .PP For \fIRSA_padding_xxx_OAEP()\fR, \fBp\fR points to the encoding parameter of length \fBpl\fR. \fBp\fR may be \fB\s-1NULL\s0\fR if \fBpl\fR is 0. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The \fIRSA_padding_add_xxx()\fR functions return 1 on success, 0 on error. The \fIRSA_padding_check_xxx()\fR functions return the length of the recovered data, \-1 on error. Error codes can be obtained by calling \&\fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIRSA_public_encrypt\fR\|(3), \&\fIRSA_private_decrypt\fR\|(3), \&\fIRSA_sign\fR\|(3), \fIRSA_verify\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIRSA_padding_add_PKCS1_type_1()\fR, \fIRSA_padding_check_PKCS1_type_1()\fR, \&\fIRSA_padding_add_PKCS1_type_2()\fR, \fIRSA_padding_check_PKCS1_type_2()\fR, \&\fIRSA_padding_add_SSLv23()\fR, \fIRSA_padding_check_SSLv23()\fR, \&\fIRSA_padding_add_none()\fR and \fIRSA_padding_check_none()\fR appeared in SSLeay 0.9.0. .PP \&\fIRSA_padding_add_PKCS1_OAEP()\fR and \fIRSA_padding_check_PKCS1_OAEP()\fR were added in OpenSSL 0.9.2b. deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_DigestInit.30000644000175000017500000003746312360020717020367 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_DigestInit 3" .TH EVP_DigestInit 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_MD_CTX_init, EVP_MD_CTX_create, EVP_DigestInit_ex, EVP_DigestUpdate, EVP_DigestFinal_ex, EVP_MD_CTX_cleanup, EVP_MD_CTX_destroy, EVP_MAX_MD_SIZE, EVP_MD_CTX_copy_ex, EVP_MD_CTX_copy, EVP_MD_type, EVP_MD_pkey_type, EVP_MD_size, EVP_MD_block_size, EVP_MD_CTX_md, EVP_MD_CTX_size, EVP_MD_CTX_block_size, EVP_MD_CTX_type, EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_sha224, EVP_sha256, EVP_sha384, EVP_sha512, EVP_dss, EVP_dss1, EVP_mdc2, EVP_ripemd160, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj \- EVP digest routines .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void EVP_MD_CTX_init(EVP_MD_CTX *ctx); \& EVP_MD_CTX *EVP_MD_CTX_create(void); \& \& int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); \& int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt); \& int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, \& unsigned int *s); \& \& int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx); \& void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx); \& \& int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in); \& \& int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); \& int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, \& unsigned int *s); \& \& int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in); \& \& #define EVP_MAX_MD_SIZE 64 /* SHA512 */ \& \& int EVP_MD_type(const EVP_MD *md); \& int EVP_MD_pkey_type(const EVP_MD *md); \& int EVP_MD_size(const EVP_MD *md); \& int EVP_MD_block_size(const EVP_MD *md); \& \& const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx); \& #define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e)) \& #define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)\->digest) \& #define EVP_MD_CTX_type(e) EVP_MD_type((e)\->digest) \& \& const EVP_MD *EVP_md_null(void); \& const EVP_MD *EVP_md2(void); \& const EVP_MD *EVP_md5(void); \& const EVP_MD *EVP_sha(void); \& const EVP_MD *EVP_sha1(void); \& const EVP_MD *EVP_dss(void); \& const EVP_MD *EVP_dss1(void); \& const EVP_MD *EVP_mdc2(void); \& const EVP_MD *EVP_ripemd160(void); \& \& const EVP_MD *EVP_sha224(void); \& const EVP_MD *EVP_sha256(void); \& const EVP_MD *EVP_sha384(void); \& const EVP_MD *EVP_sha512(void); \& \& const EVP_MD *EVP_get_digestbyname(const char *name); \& #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) \& #define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a)) .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \s-1EVP\s0 digest routines are a high level interface to message digests. .PP \&\fIEVP_MD_CTX_init()\fR initializes digest context \fBctx\fR. .PP \&\fIEVP_MD_CTX_create()\fR allocates, initializes and returns a digest context. .PP \&\fIEVP_DigestInit_ex()\fR sets up digest context \fBctx\fR to use a digest \&\fBtype\fR from \s-1ENGINE \s0\fBimpl\fR. \fBctx\fR must be initialized before calling this function. \fBtype\fR will typically be supplied by a functionsuch as \fIEVP_sha1()\fR. If \fBimpl\fR is \s-1NULL\s0 then the default implementation of digest \fBtype\fR is used. .PP \&\fIEVP_DigestUpdate()\fR hashes \fBcnt\fR bytes of data at \fBd\fR into the digest context \fBctx\fR. This function can be called several times on the same \fBctx\fR to hash additional data. .PP \&\fIEVP_DigestFinal_ex()\fR retrieves the digest value from \fBctx\fR and places it in \fBmd\fR. If the \fBs\fR parameter is not \s-1NULL\s0 then the number of bytes of data written (i.e. the length of the digest) will be written to the integer at \fBs\fR, at most \fB\s-1EVP_MAX_MD_SIZE\s0\fR bytes will be written. After calling \fIEVP_DigestFinal_ex()\fR no additional calls to \fIEVP_DigestUpdate()\fR can be made, but \fIEVP_DigestInit_ex()\fR can be called to initialize a new digest operation. .PP \&\fIEVP_MD_CTX_cleanup()\fR cleans up digest context \fBctx\fR, it should be called after a digest context is no longer needed. .PP \&\fIEVP_MD_CTX_destroy()\fR cleans up digest context \fBctx\fR and frees up the space allocated to it, it should be called only on a context created using \fIEVP_MD_CTX_create()\fR. .PP \&\fIEVP_MD_CTX_copy_ex()\fR can be used to copy the message digest state from \&\fBin\fR to \fBout\fR. This is useful if large amounts of data are to be hashed which only differ in the last few bytes. \fBout\fR must be initialized before calling this function. .PP \&\fIEVP_DigestInit()\fR behaves in the same way as \fIEVP_DigestInit_ex()\fR except the passed context \fBctx\fR does not have to be initialized, and it always uses the default digest implementation. .PP \&\fIEVP_DigestFinal()\fR is similar to \fIEVP_DigestFinal_ex()\fR except the digest context \fBctx\fR is automatically cleaned up. .PP \&\fIEVP_MD_CTX_copy()\fR is similar to \fIEVP_MD_CTX_copy_ex()\fR except the destination \&\fBout\fR does not have to be initialized. .PP \&\fIEVP_MD_size()\fR and \fIEVP_MD_CTX_size()\fR return the size of the message digest when passed an \fB\s-1EVP_MD\s0\fR or an \fB\s-1EVP_MD_CTX\s0\fR structure, i.e. the size of the hash. .PP \&\fIEVP_MD_block_size()\fR and \fIEVP_MD_CTX_block_size()\fR return the block size of the message digest when passed an \fB\s-1EVP_MD\s0\fR or an \fB\s-1EVP_MD_CTX\s0\fR structure. .PP \&\fIEVP_MD_type()\fR and \fIEVP_MD_CTX_type()\fR return the \s-1NID\s0 of the \s-1OBJECT IDENTIFIER\s0 representing the given message digest when passed an \fB\s-1EVP_MD\s0\fR structure. For example EVP_MD_type(\fIEVP_sha1()\fR) returns \fBNID_sha1\fR. This function is normally used when setting \s-1ASN1\s0 OIDs. .PP \&\fIEVP_MD_CTX_md()\fR returns the \fB\s-1EVP_MD\s0\fR structure corresponding to the passed \&\fB\s-1EVP_MD_CTX\s0\fR. .PP \&\fIEVP_MD_pkey_type()\fR returns the \s-1NID\s0 of the public key signing algorithm associated with this digest. For example \fIEVP_sha1()\fR is associated with \s-1RSA\s0 so this will return \fBNID_sha1WithRSAEncryption\fR. Since digests and signature algorithms are no longer linked this function is only retained for compatibility reasons. .PP \&\fIEVP_md2()\fR, \fIEVP_md5()\fR, \fIEVP_sha()\fR, \fIEVP_sha1()\fR, \fIEVP_sha224()\fR, \fIEVP_sha256()\fR, \&\fIEVP_sha384()\fR, \fIEVP_sha512()\fR, \fIEVP_mdc2()\fR and \fIEVP_ripemd160()\fR return \fB\s-1EVP_MD\s0\fR structures for the \s-1MD2, MD5, SHA, SHA1, SHA224, SHA256, SHA384, SHA512, MDC2\s0 and \s-1RIPEMD160\s0 digest algorithms respectively. .PP \&\fIEVP_dss()\fR and \fIEVP_dss1()\fR return \fB\s-1EVP_MD\s0\fR structures for \s-1SHA\s0 and \s-1SHA1\s0 digest algorithms but using \s-1DSS \s0(\s-1DSA\s0) for the signature algorithm. Note: there is no need to use these pseudo-digests in OpenSSL 1.0.0 and later, they are however retained for compatibility. .PP \&\fIEVP_md_null()\fR is a \*(L"null\*(R" message digest that does nothing: i.e. the hash it returns is of zero length. .PP \&\fIEVP_get_digestbyname()\fR, \fIEVP_get_digestbynid()\fR and \fIEVP_get_digestbyobj()\fR return an \fB\s-1EVP_MD\s0\fR structure when passed a digest name, a digest \s-1NID\s0 or an \s-1ASN1_OBJECT\s0 structure respectively. The digest table must be initialized using, for example, \fIOpenSSL_add_all_digests()\fR for these functions to work. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_DigestInit_ex()\fR, \fIEVP_DigestUpdate()\fR and \fIEVP_DigestFinal_ex()\fR return 1 for success and 0 for failure. .PP \&\fIEVP_MD_CTX_copy_ex()\fR returns 1 if successful or 0 for failure. .PP \&\fIEVP_MD_type()\fR, \fIEVP_MD_pkey_type()\fR and \fIEVP_MD_type()\fR return the \s-1NID\s0 of the corresponding \s-1OBJECT IDENTIFIER\s0 or NID_undef if none exists. .PP \&\fIEVP_MD_size()\fR, \fIEVP_MD_block_size()\fR, \fIEVP_MD_CTX_size()\fR and \&\fIEVP_MD_CTX_block_size()\fR return the digest or block size in bytes. .PP \&\fIEVP_md_null()\fR, \fIEVP_md2()\fR, \fIEVP_md5()\fR, \fIEVP_sha()\fR, \fIEVP_sha1()\fR, \fIEVP_dss()\fR, \&\fIEVP_dss1()\fR, \fIEVP_mdc2()\fR and \fIEVP_ripemd160()\fR return pointers to the corresponding \s-1EVP_MD\s0 structures. .PP \&\fIEVP_get_digestbyname()\fR, \fIEVP_get_digestbynid()\fR and \fIEVP_get_digestbyobj()\fR return either an \fB\s-1EVP_MD\s0\fR structure or \s-1NULL\s0 if an error occurs. .SH "NOTES" .IX Header "NOTES" The \fB\s-1EVP\s0\fR interface to message digests should almost always be used in preference to the low level interfaces. This is because the code then becomes transparent to the digest used and much more flexible. .PP New applications should use the \s-1SHA2\s0 digest algorithms such as \s-1SHA256.\s0 The other digest algorithms are still in common use. .PP For most applications the \fBimpl\fR parameter to \fIEVP_DigestInit_ex()\fR will be set to \s-1NULL\s0 to use the default digest implementation. .PP The functions \fIEVP_DigestInit()\fR, \fIEVP_DigestFinal()\fR and \fIEVP_MD_CTX_copy()\fR are obsolete but are retained to maintain compatibility with existing code. New applications should use \fIEVP_DigestInit_ex()\fR, \fIEVP_DigestFinal_ex()\fR and \&\fIEVP_MD_CTX_copy_ex()\fR because they can efficiently reuse a digest context instead of initializing and cleaning it up on each call and allow non default implementations of digests to be specified. .PP In OpenSSL 0.9.7 and later if digest contexts are not cleaned up after use memory leaks will occur. .PP Stack allocation of \s-1EVP_MD_CTX\s0 structures is common, for example: .PP .Vb 2 \& EVP_MD_CTX mctx; \& EVP_MD_CTX_init(&mctx); .Ve .PP This will cause binary compatibility issues if the size of \s-1EVP_MD_CTX\s0 structure changes (this will only happen with a major release of OpenSSL). Applications wishing to avoid this should use \fIEVP_MD_CTX_create()\fR instead: .PP .Vb 2 \& EVP_MD_CTX *mctx; \& mctx = EVP_MD_CTX_create(); .Ve .SH "EXAMPLE" .IX Header "EXAMPLE" This example digests the data \*(L"Test Message\en\*(R" and \*(L"Hello World\en\*(R", using the digest name passed on the command line. .PP .Vb 2 \& #include \& #include \& \& int \& main(int argc, char *argv[]) \& { \& EVP_MD_CTX *mdctx; \& const EVP_MD *md; \& const char mess1[] = "Test Message\en"; \& const char mess2[] = "Hello World\en"; \& unsigned char md_value[EVP_MAX_MD_SIZE]; \& int md_len, i; \& \& OpenSSL_add_all_digests(); \& \& if (argc <= 1) { \& printf("Usage: mdtest digestname\en"); \& exit(1); \& } \& \& md = EVP_get_digestbyname(argv[1]); \& if (md == NULL) { \& printf("Unknown message digest %s\en", argv[1]); \& exit(1); \& } \& \& mdctx = EVP_MD_CTX_create(); \& EVP_DigestInit_ex(mdctx, md, NULL); \& EVP_DigestUpdate(mdctx, mess1, strlen(mess1)); \& EVP_DigestUpdate(mdctx, mess2, strlen(mess2)); \& EVP_DigestFinal_ex(mdctx, md_value, &md_len); \& EVP_MD_CTX_destroy(mdctx); \& \& printf("Digest is: "); \& for(i = 0; i < md_len; i++) \& printf("%02x", md_value[i]); \& printf("\en"); \& } .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIevp\fR\|(3), \fIhmac\fR\|(3), \fImd2\fR\|(3), \&\fImd5\fR\|(3), \fImdc2\fR\|(3), \fIripemd\fR\|(3), \&\fIsha\fR\|(3), \fIdgst\fR\|(1) .SH "HISTORY" .IX Header "HISTORY" \&\fIEVP_DigestInit()\fR, \fIEVP_DigestUpdate()\fR and \fIEVP_DigestFinal()\fR are available in all versions of SSLeay and OpenSSL. .PP \&\fIEVP_MD_CTX_init()\fR, \fIEVP_MD_CTX_create()\fR, \fIEVP_MD_CTX_copy_ex()\fR, \&\fIEVP_MD_CTX_cleanup()\fR, \fIEVP_MD_CTX_destroy()\fR, \fIEVP_DigestInit_ex()\fR and \fIEVP_DigestFinal_ex()\fR were added in OpenSSL 0.9.7. .PP \&\fIEVP_md_null()\fR, \fIEVP_md2()\fR, \fIEVP_md5()\fR, \fIEVP_sha()\fR, \fIEVP_sha1()\fR, \&\fIEVP_dss()\fR, \fIEVP_dss1()\fR, \fIEVP_mdc2()\fR and \fIEVP_ripemd160()\fR were changed to return truely const \s-1EVP_MD\s0 * in OpenSSL 0.9.7. .PP The link between digests and signing algorithms was fixed in OpenSSL 1.0 and later, so now \fIEVP_sha1()\fR can be used with \s-1RSA\s0 and \s-1DSA,\s0 there is no need to use \fIEVP_dss1()\fR any more. .PP OpenSSL 1.0 and later does not include the \s-1MD2\s0 digest algorithm in the default configuration due to its security weaknesses. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_get_ciphers.30000644000175000017500000001225212360020735020614 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_get_ciphers 3" .TH SSL_get_ciphers 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_get_ciphers, SSL_get_cipher_list \- get list of available SSL_CIPHERs .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *ssl); \& const char *SSL_get_cipher_list(const SSL *ssl, int priority); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_get_ciphers()\fR returns the stack of available SSL_CIPHERs for \fBssl\fR, sorted by preference. If \fBssl\fR is \s-1NULL\s0 or no ciphers are available, \s-1NULL\s0 is returned. .PP \&\fISSL_get_cipher_list()\fR returns a pointer to the name of the \s-1SSL_CIPHER\s0 listed for \fBssl\fR with \fBpriority\fR. If \fBssl\fR is \s-1NULL,\s0 no ciphers are available, or there are less ciphers than \fBpriority\fR available, \s-1NULL\s0 is returned. .SH "NOTES" .IX Header "NOTES" The details of the ciphers obtained by \fISSL_get_ciphers()\fR can be obtained using the \fISSL_CIPHER_get_name\fR\|(3) family of functions. .PP Call \fISSL_get_cipher_list()\fR with \fBpriority\fR starting from 0 to obtain the sorted list of available ciphers, until \s-1NULL\s0 is returned. .SH "RETURN VALUES" .IX Header "RETURN VALUES" See \s-1DESCRIPTION\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_CTX_set_cipher_list\fR\|(3), \&\fISSL_CIPHER_get_name\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/dsa.30000644000175000017500000002016412360020727016350 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "dsa 3" .TH dsa 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" dsa \- Digital Signature Algorithm .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& DSA * DSA_new(void); \& void DSA_free(DSA *dsa); \& \& int DSA_size(const DSA *dsa); \& \& DSA * DSA_generate_parameters(int bits, unsigned char *seed, \& int seed_len, int *counter_ret, unsigned long *h_ret, \& void (*callback)(int, int, void *), void *cb_arg); \& \& DH * DSA_dup_DH(const DSA *r); \& \& int DSA_generate_key(DSA *dsa); \& \& int DSA_sign(int dummy, const unsigned char *dgst, int len, \& unsigned char *sigret, unsigned int *siglen, DSA *dsa); \& int DSA_sign_setup(DSA *dsa, BN_CTX *ctx, BIGNUM **kinvp, \& BIGNUM **rp); \& int DSA_verify(int dummy, const unsigned char *dgst, int len, \& const unsigned char *sigbuf, int siglen, DSA *dsa); \& \& void DSA_set_default_method(const DSA_METHOD *meth); \& const DSA_METHOD *DSA_get_default_method(void); \& int DSA_set_method(DSA *dsa, const DSA_METHOD *meth); \& DSA *DSA_new_method(ENGINE *engine); \& const DSA_METHOD *DSA_OpenSSL(void); \& \& int DSA_get_ex_new_index(long argl, char *argp, int (*new_func)(), \& int (*dup_func)(), void (*free_func)()); \& int DSA_set_ex_data(DSA *d, int idx, char *arg); \& char *DSA_get_ex_data(DSA *d, int idx); \& \& DSA_SIG *DSA_SIG_new(void); \& void DSA_SIG_free(DSA_SIG *a); \& int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp); \& DSA_SIG *d2i_DSA_SIG(DSA_SIG **v, unsigned char **pp, long length); \& \& DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); \& int DSA_do_verify(const unsigned char *dgst, int dgst_len, \& DSA_SIG *sig, DSA *dsa); \& \& DSA * d2i_DSAPublicKey(DSA **a, unsigned char **pp, long length); \& DSA * d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length); \& DSA * d2i_DSAparams(DSA **a, unsigned char **pp, long length); \& int i2d_DSAPublicKey(const DSA *a, unsigned char **pp); \& int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp); \& int i2d_DSAparams(const DSA *a,unsigned char **pp); \& \& int DSAparams_print(BIO *bp, const DSA *x); \& int DSAparams_print_fp(FILE *fp, const DSA *x); \& int DSA_print(BIO *bp, const DSA *x, int off); \& int DSA_print_fp(FILE *bp, const DSA *x, int off); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions implement the Digital Signature Algorithm (\s-1DSA\s0). The generation of shared \s-1DSA\s0 parameters is described in \&\fIDSA_generate_parameters\fR\|(3); \&\fIDSA_generate_key\fR\|(3) describes how to generate a signature key. Signature generation and verification are described in \fIDSA_sign\fR\|(3). .PP The \fB\s-1DSA\s0\fR structure consists of several \s-1BIGNUM\s0 components. .PP .Vb 10 \& struct \& { \& BIGNUM *p; // prime number (public) \& BIGNUM *q; // 160\-bit subprime, q | p\-1 (public) \& BIGNUM *g; // generator of subgroup (public) \& BIGNUM *priv_key; // private key x \& BIGNUM *pub_key; // public key y = g^x \& // ... \& } \& DSA; .Ve .PP In public keys, \fBpriv_key\fR is \s-1NULL.\s0 .PP Note that \s-1DSA\s0 keys may use non-standard \fB\s-1DSA_METHOD\s0\fR implementations, either directly or by the use of \fB\s-1ENGINE\s0\fR modules. In some cases (eg. an \&\s-1ENGINE\s0 providing support for hardware-embedded keys), these \s-1BIGNUM\s0 values will not be used by the implementation or may be used for alternative data storage. For this reason, applications should generally avoid using \s-1DSA\s0 structure elements directly and instead use \s-1API\s0 functions to query or modify keys. .SH "CONFORMING TO" .IX Header "CONFORMING TO" \&\s-1US\s0 Federal Information Processing Standard \s-1FIPS 186 \s0(Digital Signature Standard, \s-1DSS\s0), \s-1ANSI X9.30\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3), \fIdh\fR\|(3), \fIerr\fR\|(3), \fIrand\fR\|(3), \&\fIrsa\fR\|(3), \fIsha\fR\|(3), \fIengine\fR\|(3), \&\fIDSA_new\fR\|(3), \&\fIDSA_size\fR\|(3), \&\fIDSA_generate_parameters\fR\|(3), \&\fIDSA_dup_DH\fR\|(3), \&\fIDSA_generate_key\fR\|(3), \&\fIDSA_sign\fR\|(3), \fIDSA_set_method\fR\|(3), \&\fIDSA_get_ex_new_index\fR\|(3), \&\fIRSA_print\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/PKCS12_create.30000644000175000017500000001546612360020722020033 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PKCS12_create 3" .TH PKCS12_create 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PKCS12_create \- create a PKCS#12 structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, \& X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert, \& int iter, int mac_iter, int keytype); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIPKCS12_create()\fR creates a PKCS#12 structure. .PP \&\fBpass\fR is the passphrase to use. \fBname\fR is the \fBfriendlyName\fR to use for the supplied certifictate and key. \fBpkey\fR is the private key to include in the structure and \fBcert\fR its corresponding certificates. \fBca\fR is an optional set of certificates to also include in the structure. Either \fBpkey\fR, \fBcert\fR or both can be \fB\s-1NULL\s0\fR to indicate that no key or certficate is required. .PP \&\fBnid_key\fR and \fBnid_cert\fR are the encryption algorithms that should be used for the key and certificate respectively. If either \fBnid_key\fR or \fBnid_cert\fR is set to \-1, no encryption will be used. .PP \&\fBiter\fR is the encryption algorithm iteration count to use and \fBmac_iter\fR is the \s-1MAC\s0 iteration count to use. If \fBmac_iter\fR is set to \-1, the \s-1MAC\s0 will be omitted entirely. .PP \&\fBkeytype\fR is the type of key. .SH "NOTES" .IX Header "NOTES" The parameters \fBnid_key\fR, \fBnid_cert\fR, \fBiter\fR, \fBmac_iter\fR and \fBkeytype\fR can all be set to zero and sensible defaults will be used. .PP These defaults are: 40 bit \s-1RC2\s0 encryption for certificates, triple \s-1DES\s0 encryption for private keys, a key iteration count of \s-1PKCS12_DEFAULT_ITER \&\s0(currently 2048) and a \s-1MAC\s0 iteration count of 1. .PP The default \s-1MAC\s0 iteration count is 1 in order to retain compatibility with old software which did not interpret \s-1MAC\s0 iteration counts. If such compatibility is not required then \fBmac_iter\fR should be set to \s-1PKCS12_DEFAULT_ITER.\s0 .PP \&\fBkeytype\fR adds a flag to the store private key. This is a non standard extension that is only currently interpreted by \s-1MSIE.\s0 If set to zero the flag is omitted, if set to \fB\s-1KEY_SIG\s0\fR the key can be used for signing only, if set to \fB\s-1KEY_EX\s0\fR it can be used for signing and encryption. This option was useful for old export grade software which could use signing only keys of arbitrary size but had restrictions on the permissible sizes of keys which could be used for encryption. .PP If a certificate contains an \fBalias\fR or \fBkeyid\fR then this will be used for the corresponding \fBfriendlyName\fR or \fBlocalKeyID\fR in the \&\s-1PKCS12\s0 structure. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fId2i_PKCS12\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" PKCS12_create was added in OpenSSL 0.9.3. .PP Before OpenSSL 0.9.8, neither \fBpkey\fR nor \fBcert\fR were allowed to be \fB\s-1NULL\s0\fR, and a value of \fB\-1\fR was not allowed for \fBnid_key\fR, \fBnid_cert\fR and \&\fBmac_iter\fR. deps/libressl-pnacl-sys-2.1.6/libressl/man/pkey.10000644000175000017500000001740012360020742016543 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "pkey 1" .TH pkey 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" pkey \- public or private key processing tool .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBpkey\fR [\fB\-inform PEM|DER\fR] [\fB\-outform PEM|DER\fR] [\fB\-in filename\fR] [\fB\-passin arg\fR] [\fB\-out filename\fR] [\fB\-passout arg\fR] [\fB\-cipher\fR] [\fB\-text\fR] [\fB\-text_pub\fR] [\fB\-noout\fR] [\fB\-pubin\fR] [\fB\-pubout\fR] [\fB\-engine id\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBpkey\fR command processes public or private keys. They can be converted between various forms and their components printed out. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" .IP "\fB\-inform DER|PEM\fR" 4 .IX Item "-inform DER|PEM" This specifies the input format \s-1DER\s0 or \s-1PEM.\s0 .IP "\fB\-outform DER|PEM\fR" 4 .IX Item "-outform DER|PEM" This specifies the output format, the options have the same meaning as the \&\fB\-inform\fR option. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read a key from or standard input if this option is not specified. If the key is encrypted a pass phrase will be prompted for. .IP "\fB\-passin arg\fR" 4 .IX Item "-passin arg" the input file password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" This specifies the output filename to write a key to or standard output if this option is not specified. If any encryption options are set then a pass phrase will be prompted for. The output filename should \fBnot\fR be the same as the input filename. .IP "\fB\-passout password\fR" 4 .IX Item "-passout password" the output file password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-cipher\fR" 4 .IX Item "-cipher" These options encrypt the private key with the supplied cipher. Any algorithm name accepted by \fIEVP_get_cipherbyname()\fR is acceptable such as \fBdes3\fR. .IP "\fB\-text\fR" 4 .IX Item "-text" prints out the various public or private key components in plain text in addition to the encoded version. .IP "\fB\-text_pub\fR" 4 .IX Item "-text_pub" print out only public key components even if a private key is being processed. .IP "\fB\-noout\fR" 4 .IX Item "-noout" do not output the encoded version of the key. .IP "\fB\-pubin\fR" 4 .IX Item "-pubin" by default a private key is read from the input file: with this option a public key is read instead. .IP "\fB\-pubout\fR" 4 .IX Item "-pubout" by default a private key is output: with this option a public key will be output instead. This option is automatically set if the input is a public key. .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBpkey\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .SH "EXAMPLES" .IX Header "EXAMPLES" To remove the pass phrase on an \s-1RSA\s0 private key: .PP .Vb 1 \& openssl pkey \-in key.pem \-out keyout.pem .Ve .PP To encrypt a private key using triple \s-1DES:\s0 .PP .Vb 1 \& openssl pkey \-in key.pem \-des3 \-out keyout.pem .Ve .PP To convert a private key from \s-1PEM\s0 to \s-1DER\s0 format: .PP .Vb 1 \& openssl pkey \-in key.pem \-outform DER \-out keyout.der .Ve .PP To print out the components of a private key to standard output: .PP .Vb 1 \& openssl pkey \-in key.pem \-text \-noout .Ve .PP To print out the public components of a private key to standard output: .PP .Vb 1 \& openssl pkey \-in key.pem \-text_pub \-noout .Ve .PP To just output the public part of a private key: .PP .Vb 1 \& openssl pkey \-in key.pem \-pubout \-out pubkey.pem .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIgenpkey\fR\|(1), \fIrsa\fR\|(1), \fIpkcs8\fR\|(1), \&\fIdsa\fR\|(1), \fIgenrsa\fR\|(1), \fIgendsa\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/RIPEMD160.30000644000175000017500000001371512360020723017010 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RIPEMD160 3" .TH RIPEMD160 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RIPEMD160, RIPEMD160_Init, RIPEMD160_Update, RIPEMD160_Final \- RIPEMD\-160 hash function .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& unsigned char *RIPEMD160(const unsigned char *d, unsigned long n, \& unsigned char *md); \& \& int RIPEMD160_Init(RIPEMD160_CTX *c); \& int RIPEMD160_Update(RIPEMD_CTX *c, const void *data, \& unsigned long len); \& int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\s-1RIPEMD\-160\s0 is a cryptographic hash function with a 160 bit output. .PP \&\s-1\fIRIPEMD160\s0()\fR computes the \s-1RIPEMD\-160\s0 message digest of the \fBn\fR bytes at \fBd\fR and places it in \fBmd\fR (which must have space for \&\s-1RIPEMD160_DIGEST_LENGTH\s0 == 20 bytes of output). If \fBmd\fR is \s-1NULL,\s0 the digest is placed in a static array. .PP The following functions may be used if the message is not completely stored in memory: .PP \&\fIRIPEMD160_Init()\fR initializes a \fB\s-1RIPEMD160_CTX\s0\fR structure. .PP \&\fIRIPEMD160_Update()\fR can be called repeatedly with chunks of the message to be hashed (\fBlen\fR bytes at \fBdata\fR). .PP \&\fIRIPEMD160_Final()\fR places the message digest in \fBmd\fR, which must have space for \s-1RIPEMD160_DIGEST_LENGTH\s0 == 20 bytes of output, and erases the \fB\s-1RIPEMD160_CTX\s0\fR. .PP Applications should use the higher level functions \&\fIEVP_DigestInit\fR\|(3) etc. instead of calling the hash functions directly. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\s-1\fIRIPEMD160\s0()\fR returns a pointer to the hash value. .PP \&\fIRIPEMD160_Init()\fR, \fIRIPEMD160_Update()\fR and \fIRIPEMD160_Final()\fR return 1 for success, 0 otherwise. .SH "CONFORMING TO" .IX Header "CONFORMING TO" \&\s-1ISO/IEC 10118\-3 \s0(draft) (??) .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIsha\fR\|(3), \fIhmac\fR\|(3), \fIEVP_DigestInit\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\s-1\fIRIPEMD160\s0()\fR, \fIRIPEMD160_Init()\fR, \fIRIPEMD160_Update()\fR and \&\fIRIPEMD160_Final()\fR are available since SSLeay 0.9.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/CMS_verify.30000644000175000017500000002202712360020714017603 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CMS_verify 3" .TH CMS_verify 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CMS_verify, CMS_get0_signers \- verify a CMS SignedData structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, X509_STORE *store, BIO *indata, BIO *out, unsigned int flags); \& \& STACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fICMS_verify()\fR verifies a \s-1CMS\s0 SignedData structure. \fBcms\fR is the CMS_ContentInfo structure to verify. \fBcerts\fR is a set of certificates in which to search for the signing certificate(s). \fBstore\fR is a trusted certificate store used for chain verification. \fBindata\fR is the detached content if the content is not present in \fBcms\fR. The content is written to \fBout\fR if it is not \s-1NULL.\s0 .PP \&\fBflags\fR is an optional set of flags, which can be used to modify the verify operation. .PP \&\fICMS_get0_signers()\fR retrieves the signing certificate(s) from \fBcms\fR, it must be called after a successful \fICMS_verify()\fR operation. .SH "VERIFY PROCESS" .IX Header "VERIFY PROCESS" Normally the verify process proceeds as follows. .PP Initially some sanity checks are performed on \fBcms\fR. The type of \fBcms\fR must be SignedData. There must be at least one signature on the data and if the content is detached \fBindata\fR cannot be \fB\s-1NULL\s0\fR. .PP An attempt is made to locate all the signing certificate(s), first looking in the \fBcerts\fR parameter (if it is not \s-1NULL\s0) and then looking in any certificates contained in the \fBcms\fR structure itself. If any signing certificate cannot be located the operation fails. .PP Each signing certificate is chain verified using the \fBsmimesign\fR purpose and the supplied trusted certificate store. Any internal certificates in the message are used as untrusted CAs. If \s-1CRL\s0 checking is enabled in \fBstore\fR any internal CRLs are used in addition to attempting to look them up in \fBstore\fR. If any chain verify fails an error code is returned. .PP Finally the signed content is read (and written to \fBout\fR is it is not \s-1NULL\s0) and the signature's checked. .PP If all signature's verify correctly then the function is successful. .PP Any of the following flags (ored together) can be passed in the \fBflags\fR parameter to change the default verify behaviour. .PP If \fB\s-1CMS_NOINTERN\s0\fR is set the certificates in the message itself are not searched when locating the signing certificate(s). This means that all the signing certificates must be in the \fBcerts\fR parameter. .PP If \fB\s-1CMS_NOCRL\s0\fR is set and \s-1CRL\s0 checking is enabled in \fBstore\fR then any CRLs in the message itself are ignored. .PP If the \fB\s-1CMS_TEXT\s0\fR flag is set \s-1MIME\s0 headers for type \fBtext/plain\fR are deleted from the content. If the content is not of type \fBtext/plain\fR then an error is returned. .PP If \fB\s-1CMS_NO_SIGNER_CERT_VERIFY\s0\fR is set the signing certificates are not verified. .PP If \fB\s-1CMS_NO_ATTR_VERIFY\s0\fR is set the signed attributes signature is not verified. .PP If \fB\s-1CMS_NO_CONTENT_VERIFY\s0\fR is set then the content digest is not checked. .SH "NOTES" .IX Header "NOTES" One application of \fB\s-1CMS_NOINTERN\s0\fR is to only accept messages signed by a small number of certificates. The acceptable certificates would be passed in the \fBcerts\fR parameter. In this case if the signer is not one of the certificates supplied in \fBcerts\fR then the verify will fail because the signer cannot be found. .PP In some cases the standard techniques for looking up and validating certificates are not appropriate: for example an application may wish to lookup certificates in a database or perform customised verification. This can be achieved by setting and verifying the signers certificates manually using the signed data utility functions. .PP Care should be taken when modifying the default verify behaviour, for example setting \fB\s-1CMS_NO_CONTENT_VERIFY\s0\fR will totally disable all content verification and any modified content will be considered valid. This combination is however useful if one merely wishes to write the content to \fBout\fR and its validity is not considered important. .PP Chain verification should arguably be performed using the signing time rather than the current time. However since the signing time is supplied by the signer it cannot be trusted without additional evidence (such as a trusted timestamp). .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICMS_verify()\fR returns 1 for a successful verification and zero if an error occurred. .PP \&\fICMS_get0_signers()\fR returns all signers or \s-1NULL\s0 if an error occurred. .PP The error can be obtained from \fIERR_get_error\fR\|(3) .SH "BUGS" .IX Header "BUGS" The trusted certificate store is not searched for the signing certificate, this is primarily due to the inadequacies of the current \fBX509_STORE\fR functionality. .PP The lack of single pass processing means that the signed content must all be held in memory if it is not detached. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_sign\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fICMS_verify()\fR was added to OpenSSL 0.9.8 deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_zero.30000644000175000017500000001304112360020712017125 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_zero 3" .TH BN_zero 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_zero, BN_one, BN_value_one, BN_set_word, BN_get_word \- BIGNUM assignment operations .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int BN_zero(BIGNUM *a); \& int BN_one(BIGNUM *a); \& \& const BIGNUM *BN_value_one(void); \& \& int BN_set_word(BIGNUM *a, unsigned long w); \& unsigned long BN_get_word(BIGNUM *a); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBN_zero()\fR, \fIBN_one()\fR and \fIBN_set_word()\fR set \fBa\fR to the values 0, 1 and \&\fBw\fR respectively. \fIBN_zero()\fR and \fIBN_one()\fR are macros. .PP \&\fIBN_value_one()\fR returns a \fB\s-1BIGNUM\s0\fR constant of value 1. This constant is useful for use in comparisons and assignment. .PP \&\fIBN_get_word()\fR returns \fBa\fR, if it can be represented as an unsigned long. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBN_get_word()\fR returns the value \fBa\fR, and 0xffffffffL if \fBa\fR cannot be represented as an unsigned long. .PP \&\fIBN_zero()\fR, \fIBN_one()\fR and \fIBN_set_word()\fR return 1 on success, 0 otherwise. \&\fIBN_value_one()\fR returns the constant. .SH "BUGS" .IX Header "BUGS" Someone might change the constant. .PP If a \fB\s-1BIGNUM\s0\fR is equal to 0xffffffffL it can be represented as an unsigned long but this value is also returned on error. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3), \fIBN_bn2bin\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIBN_zero()\fR, \fIBN_one()\fR and \fIBN_set_word()\fR are available in all versions of SSLeay and OpenSSL. \fIBN_value_one()\fR and \fIBN_get_word()\fR were added in SSLeay 0.8. .PP \&\fIBN_value_one()\fR was changed to return a true const \s-1BIGNUM\s0 * in OpenSSL 0.9.7. deps/libressl-pnacl-sys-2.1.6/libressl/man/DH_new.30000644000175000017500000001155712360020715016750 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DH_new 3" .TH DH_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DH_new, DH_free \- allocate and free DH objects .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& DH* DH_new(void); \& \& void DH_free(DH *dh); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIDH_new()\fR allocates and initializes a \fB\s-1DH\s0\fR structure. .PP \&\fIDH_free()\fR frees the \fB\s-1DH\s0\fR structure and its components. The values are erased before the memory is returned to the system. .SH "RETURN VALUES" .IX Header "RETURN VALUES" If the allocation fails, \fIDH_new()\fR returns \fB\s-1NULL\s0\fR and sets an error code that can be obtained by \fIERR_get_error\fR\|(3). Otherwise it returns a pointer to the newly allocated structure. .PP \&\fIDH_free()\fR returns no value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdh\fR\|(3), \fIERR_get_error\fR\|(3), \&\fIDH_generate_parameters\fR\|(3), \&\fIDH_generate_key\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIDH_new()\fR and \fIDH_free()\fR are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_cmp.30000644000175000017500000001245112360020712016731 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_cmp 3" .TH BN_cmp 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_cmp, BN_ucmp, BN_is_zero, BN_is_one, BN_is_word, BN_is_odd \- BIGNUM comparison and test functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int BN_cmp(BIGNUM *a, BIGNUM *b); \& int BN_ucmp(BIGNUM *a, BIGNUM *b); \& \& int BN_is_zero(BIGNUM *a); \& int BN_is_one(BIGNUM *a); \& int BN_is_word(BIGNUM *a, BN_ULONG w); \& int BN_is_odd(BIGNUM *a); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBN_cmp()\fR compares the numbers \fBa\fR and \fBb\fR. \fIBN_ucmp()\fR compares their absolute values. .PP \&\fIBN_is_zero()\fR, \fIBN_is_one()\fR and \fIBN_is_word()\fR test if \fBa\fR equals 0, 1, or \fBw\fR respectively. \fIBN_is_odd()\fR tests if a is odd. .PP \&\fIBN_is_zero()\fR, \fIBN_is_one()\fR, \fIBN_is_word()\fR and \fIBN_is_odd()\fR are macros. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBN_cmp()\fR returns \-1 if \fBa\fR < \fBb\fR, 0 if \fBa\fR == \fBb\fR and 1 if \&\fBa\fR > \fBb\fR. \fIBN_ucmp()\fR is the same using the absolute values of \fBa\fR and \fBb\fR. .PP \&\fIBN_is_zero()\fR, \fIBN_is_one()\fR \fIBN_is_word()\fR and \fIBN_is_odd()\fR return 1 if the condition is true, 0 otherwise. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIBN_cmp()\fR, \fIBN_ucmp()\fR, \fIBN_is_zero()\fR, \fIBN_is_one()\fR and \fIBN_is_word()\fR are available in all versions of SSLeay and OpenSSL. \&\fIBN_is_odd()\fR was added in SSLeay 0.8. deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_s_mem.30000644000175000017500000002044212360020711017362 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_s_mem 3" .TH BIO_s_mem 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_s_mem, BIO_set_mem_eof_return, BIO_get_mem_data, BIO_set_mem_buf, BIO_get_mem_ptr, BIO_new_mem_buf \- memory BIO .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIO_METHOD * BIO_s_mem(void); \& \& BIO_set_mem_eof_return(BIO *b,int v) \& long BIO_get_mem_data(BIO *b, char **pp) \& BIO_set_mem_buf(BIO *b,BUF_MEM *bm,int c) \& BIO_get_mem_ptr(BIO *b,BUF_MEM **pp) \& \& BIO *BIO_new_mem_buf(void *buf, int len); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_s_mem()\fR return the memory \s-1BIO\s0 method function. .PP A memory \s-1BIO\s0 is a source/sink \s-1BIO\s0 which uses memory for its I/O. Data written to a memory \s-1BIO\s0 is stored in a \s-1BUF_MEM\s0 structure which is extended as appropriate to accommodate the stored data. .PP Any data written to a memory \s-1BIO\s0 can be recalled by reading from it. Unless the memory \s-1BIO\s0 is read only any data read from it is deleted from the \s-1BIO.\s0 .PP Memory BIOs support \fIBIO_gets()\fR and \fIBIO_puts()\fR. .PP If the \s-1BIO_CLOSE\s0 flag is set when a memory \s-1BIO\s0 is freed then the underlying \&\s-1BUF_MEM\s0 structure is also freed. .PP Calling \fIBIO_reset()\fR on a read write memory \s-1BIO\s0 clears any data in it. On a read only \s-1BIO\s0 it restores the \s-1BIO\s0 to its original state and the read only data can be read again. .PP \&\fIBIO_eof()\fR is true if no data is in the \s-1BIO.\s0 .PP \&\fIBIO_ctrl_pending()\fR returns the number of bytes currently stored. .PP \&\fIBIO_set_mem_eof_return()\fR sets the behaviour of memory \s-1BIO \s0\fBb\fR when it is empty. If the \fBv\fR is zero then an empty memory \s-1BIO\s0 will return \s-1EOF \s0(that is it will return zero and BIO_should_retry(b) will be false. If \fBv\fR is non zero then it will return \fBv\fR when it is empty and it will set the read retry flag (that is BIO_read_retry(b) is true). To avoid ambiguity with a normal positive return value \fBv\fR should be set to a negative value, typically \-1. .PP \&\fIBIO_get_mem_data()\fR sets \fBpp\fR to a pointer to the start of the memory BIOs data and returns the total amount of data available. It is implemented as a macro. .PP \&\fIBIO_set_mem_buf()\fR sets the internal \s-1BUF_MEM\s0 structure to \fBbm\fR and sets the close flag to \fBc\fR, that is \fBc\fR should be either \s-1BIO_CLOSE\s0 or \s-1BIO_NOCLOSE.\s0 It is a macro. .PP \&\fIBIO_get_mem_ptr()\fR places the underlying \s-1BUF_MEM\s0 structure in \fBpp\fR. It is a macro. .PP \&\fIBIO_new_mem_buf()\fR creates a memory \s-1BIO\s0 using \fBlen\fR bytes of data at \fBbuf\fR, if \fBlen\fR is \-1 then the \fBbuf\fR is assumed to be null terminated and its length is determined by \fBstrlen\fR. The \s-1BIO\s0 is set to a read only state and as a result cannot be written to. This is useful when some data needs to be made available from a static area of memory in the form of a \s-1BIO.\s0 The supplied data is read directly from the supplied buffer: it is \fBnot\fR copied first, so the supplied area of memory must be unchanged until the \s-1BIO\s0 is freed. .SH "NOTES" .IX Header "NOTES" Writes to memory BIOs will always succeed if memory is available: that is their size can grow indefinitely. .PP Every read from a read write memory \s-1BIO\s0 will remove the data just read with an internal copy operation, if a \s-1BIO\s0 contains a lot of data and it is read in small chunks the operation can be very slow. The use of a read only memory \s-1BIO\s0 avoids this problem. If the \s-1BIO\s0 must be read write then adding a buffering \s-1BIO\s0 to the chain will speed up the process. .SH "BUGS" .IX Header "BUGS" There should be an option to set the maximum size of a memory \s-1BIO.\s0 .PP There should be a way to \*(L"rewind\*(R" a read write \s-1BIO\s0 without destroying its contents. .PP The copying operation should not occur after every small read of a large \s-1BIO\s0 to improve efficiency. .SH "EXAMPLE" .IX Header "EXAMPLE" Create a memory \s-1BIO\s0 and write some data to it: .PP .Vb 2 \& BIO *mem = BIO_new(BIO_s_mem()); \& BIO_puts(mem, "Hello World\en"); .Ve .PP Create a read only memory \s-1BIO:\s0 .PP .Vb 3 \& char data[] = "Hello World"; \& BIO *mem; \& mem = BIO_new_mem_buf(data, \-1); .Ve .PP Extract the \s-1BUF_MEM\s0 structure from a memory \s-1BIO\s0 and then free up the \s-1BIO:\s0 .PP .Vb 4 \& BUF_MEM *bptr; \& BIO_get_mem_ptr(mem, &bptr); \& BIO_set_close(mem, BIO_NOCLOSE); /* So BIO_free() leaves BUF_MEM alone */ \& BIO_free(mem); .Ve deps/libressl-pnacl-sys-2.1.6/libressl/man/dhparam.10000644000175000017500000002053712360020740017212 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "dhparam 1" .TH dhparam 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" dhparam \- DH parameter manipulation and generation .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl dhparam\fR [\fB\-inform DER|PEM\fR] [\fB\-outform DER|PEM\fR] [\fB\-in\fR \fIfilename\fR] [\fB\-out\fR \fIfilename\fR] [\fB\-dsaparam\fR] [\fB\-noout\fR] [\fB\-text\fR] [\fB\-C\fR] [\fB\-2\fR] [\fB\-5\fR] [\fB\-rand\fR \fIfile(s)\fR] [\fB\-engine id\fR] [\fInumbits\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" This command is used to manipulate \s-1DH\s0 parameter files. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-inform DER|PEM\fR" 4 .IX Item "-inform DER|PEM" This specifies the input format. The \fB\s-1DER\s0\fR option uses an \s-1ASN1 DER\s0 encoded form compatible with the PKCS#3 DHparameter structure. The \s-1PEM\s0 form is the default format: it consists of the \fB\s-1DER\s0\fR format base64 encoded with additional header and footer lines. .IP "\fB\-outform DER|PEM\fR" 4 .IX Item "-outform DER|PEM" This specifies the output format, the options have the same meaning as the \&\fB\-inform\fR option. .IP "\fB\-in\fR \fIfilename\fR" 4 .IX Item "-in filename" This specifies the input filename to read parameters from or standard input if this option is not specified. .IP "\fB\-out\fR \fIfilename\fR" 4 .IX Item "-out filename" This specifies the output filename parameters to. Standard output is used if this option is not present. The output filename should \fBnot\fR be the same as the input filename. .IP "\fB\-dsaparam\fR" 4 .IX Item "-dsaparam" If this option is used, \s-1DSA\s0 rather than \s-1DH\s0 parameters are read or created; they are converted to \s-1DH\s0 format. Otherwise, \*(L"strong\*(R" primes (such that (p\-1)/2 is also prime) will be used for \s-1DH\s0 parameter generation. .Sp \&\s-1DH\s0 parameter generation with the \fB\-dsaparam\fR option is much faster, and the recommended exponent length is shorter, which makes \s-1DH\s0 key exchange more efficient. Beware that with such DSA-style \s-1DH\s0 parameters, a fresh \s-1DH\s0 key should be created for each use to avoid small-subgroup attacks that may be possible otherwise. .IP "\fB\-2\fR, \fB\-5\fR" 4 .IX Item "-2, -5" The generator to use, either 2 or 5. 2 is the default. If present then the input file is ignored and parameters are generated instead. .IP "\fB\-rand\fR \fIfile(s)\fR" 4 .IX Item "-rand file(s)" a file or files containing random data used to seed the random number generator, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)). Multiple files can be specified separated by a OS-dependent character. The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for all others. .IP "\fInumbits\fR" 4 .IX Item "numbits" this option specifies that a parameter set should be generated of size \&\fInumbits\fR. It must be the last option. If not present then a value of 512 is used. If this option is present then the input file is ignored and parameters are generated instead. .IP "\fB\-noout\fR" 4 .IX Item "-noout" this option inhibits the output of the encoded version of the parameters. .IP "\fB\-text\fR" 4 .IX Item "-text" this option prints out the \s-1DH\s0 parameters in human readable form. .IP "\fB\-C\fR" 4 .IX Item "-C" this option converts the parameters into C code. The parameters can then be loaded by calling the \fBget_dh\fR\fInumbits\fR\fB()\fR function. .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBdhparam\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .SH "WARNINGS" .IX Header "WARNINGS" The program \fBdhparam\fR combines the functionality of the programs \fBdh\fR and \&\fBgendh\fR in previous versions of OpenSSL and SSLeay. The \fBdh\fR and \fBgendh\fR programs are retained for now but may have different purposes in future versions of OpenSSL. .SH "NOTES" .IX Header "NOTES" \&\s-1PEM\s0 format \s-1DH\s0 parameters use the header and footer lines: .PP .Vb 2 \& \-\-\-\-\-BEGIN DH PARAMETERS\-\-\-\-\- \& \-\-\-\-\-END DH PARAMETERS\-\-\-\-\- .Ve .PP OpenSSL currently only supports the older PKCS#3 \s-1DH,\s0 not the newer X9.42 \&\s-1DH.\s0 .PP This program manipulates \s-1DH\s0 parameters not keys. .SH "BUGS" .IX Header "BUGS" There should be a way to generate and manipulate \s-1DH\s0 keys. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdsaparam\fR\|(1) .SH "HISTORY" .IX Header "HISTORY" The \fBdhparam\fR command was added in OpenSSL 0.9.5. The \fB\-dsaparam\fR option was added in OpenSSL 0.9.6. deps/libressl-pnacl-sys-2.1.6/libressl/man/X509_STORE_CTX_get_ex_new_index.30000644000175000017500000001235712360020725023336 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "X509_STORE_CTX_get_ex_new_index 3" .TH X509_STORE_CTX_get_ex_new_index 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" X509_STORE_CTX_get_ex_new_index, X509_STORE_CTX_set_ex_data, X509_STORE_CTX_get_ex_data \- add application specific data to X509_STORE_CTX structures .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, \& CRYPTO_EX_new *new_func, \& CRYPTO_EX_dup *dup_func, \& CRYPTO_EX_free *free_func); \& \& int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *d, int idx, void *arg); \& \& void *X509_STORE_CTX_get_ex_data(X509_STORE_CTX *d, int idx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions handle application specific data in X509_STORE_CTX structures. Their usage is identical to that of \fIRSA_get_ex_new_index()\fR, \fIRSA_set_ex_data()\fR and \fIRSA_get_ex_data()\fR as described in \fIRSA_get_ex_new_index\fR\|(3). .SH "NOTES" .IX Header "NOTES" This mechanism is used internally by the \fBssl\fR library to store the \fB\s-1SSL\s0\fR structure associated with a verification operation in an \fBX509_STORE_CTX\fR structure. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIRSA_get_ex_new_index\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIX509_STORE_CTX_get_ex_new_index()\fR, \fIX509_STORE_CTX_set_ex_data()\fR and \&\fIX509_STORE_CTX_get_ex_data()\fR are available since OpenSSL 0.9.5. deps/libressl-pnacl-sys-2.1.6/libressl/man/X509_VERIFY_PARAM_set_flags.30000644000175000017500000002664412360020726022311 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "X509_VERIFY_PARAM_set_flags 3" .TH X509_VERIFY_PARAM_set_flags 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" X509_VERIFY_PARAM_set_flags, X509_VERIFY_PARAM_clear_flags, X509_VERIFY_PARAM_get_flags, X509_VERIFY_PARAM_set_purpose, X509_VERIFY_PARAM_set_trust, X509_VERIFY_PARAM_set_depth, X509_VERIFY_PARAM_get_depth, X509_VERIFY_PARAM_set_time, X509_VERIFY_PARAM_add0_policy, X509_VERIFY_PARAM_set1_policies \- X509 verification parameters .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags); \& int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, \& unsigned long flags); \& unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param); \& \& int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose); \& int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust); \& \& void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t); \& \& int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, \& ASN1_OBJECT *policy); \& int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, \& STACK_OF(ASN1_OBJECT) *policies); \& \& void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth); \& int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions manipulate the \fBX509_VERIFY_PARAM\fR structure associated with a certificate verification operation. .PP The \fIX509_VERIFY_PARAM_set_flags()\fR function sets the flags in \fBparam\fR by oring it with \fBflags\fR. See the \fB\s-1VERIFICATION FLAGS\s0\fR section for a complete description of values the \fBflags\fR parameter can take. .PP \&\fIX509_VERIFY_PARAM_get_flags()\fR returns the flags in \fBparam\fR. .PP \&\fIX509_VERIFY_PARAM_clear_flags()\fR clears the flags \fBflags\fR in \fBparam\fR. .PP \&\fIX509_VERIFY_PARAM_set_purpose()\fR sets the verification purpose in \fBparam\fR to \fBpurpose\fR. This determines the acceptable purpose of the certificate chain, for example \s-1SSL\s0 client or \s-1SSL\s0 server. .PP \&\fIX509_VERIFY_PARAM_set_trust()\fR sets the trust setting in \fBparam\fR to \&\fBtrust\fR. .PP \&\fIX509_VERIFY_PARAM_set_time()\fR sets the verification time in \fBparam\fR to \&\fBt\fR. Normally the current time is used. .PP \&\fIX509_VERIFY_PARAM_add0_policy()\fR enables policy checking (it is disabled by default) and adds \fBpolicy\fR to the acceptable policy set. .PP \&\fIX509_VERIFY_PARAM_set1_policies()\fR enables policy checking (it is disabled by default) and sets the acceptable policy set to \fBpolicies\fR. Any existing policy set is cleared. The \fBpolicies\fR parameter can be \fB\s-1NULL\s0\fR to clear an existing policy set. .PP \&\fIX509_VERIFY_PARAM_set_depth()\fR sets the maximum verification depth to \fBdepth\fR. That is the maximum number of untrusted \s-1CA\s0 certificates that can appear in a chain. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIX509_VERIFY_PARAM_set_flags()\fR, \fIX509_VERIFY_PARAM_clear_flags()\fR, \&\fIX509_VERIFY_PARAM_set_purpose()\fR, \fIX509_VERIFY_PARAM_set_trust()\fR, \&\fIX509_VERIFY_PARAM_add0_policy()\fR and \fIX509_VERIFY_PARAM_set1_policies()\fR return 1 for success and 0 for failure. .PP \&\fIX509_VERIFY_PARAM_get_flags()\fR returns the current verification flags. .PP \&\fIX509_VERIFY_PARAM_set_time()\fR and \fIX509_VERIFY_PARAM_set_depth()\fR do not return values. .PP \&\fIX509_VERIFY_PARAM_get_depth()\fR returns the current verification depth. .SH "VERIFICATION FLAGS" .IX Header "VERIFICATION FLAGS" The verification flags consists of zero or more of the following flags ored together. .PP \&\fBX509_V_FLAG_CRL_CHECK\fR enables \s-1CRL\s0 checking for the certificate chain leaf certificate. An error occurs if a suitable \s-1CRL\s0 cannot be found. .PP \&\fBX509_V_FLAG_CRL_CHECK_ALL\fR enables \s-1CRL\s0 checking for the entire certificate chain. .PP \&\fBX509_V_FLAG_IGNORE_CRITICAL\fR disabled critical extension checking. By default any unhandled critical extensions in certificates or (if checked) CRLs results in a fatal error. If this flag is set unhandled critical extensions are ignored. \fB\s-1WARNING\s0\fR setting this option for anything other than debugging purposes can be a security risk. Finer control over which extensions are supported can be performed in the verification callback. .PP THe \fBX509_V_FLAG_X509_STRICT\fR flag disables workarounds for some broken certificates and makes the verification strictly apply \fBX509\fR rules. .PP \&\fBX509_V_FLAG_ALLOW_PROXY_CERTS\fR enables proxy certificate verification. .PP \&\fBX509_V_FLAG_POLICY_CHECK\fR enables certificate policy checking, by default no policy checking is peformed. Additional information is sent to the verification callback relating to policy checking. .PP \&\fBX509_V_FLAG_EXPLICIT_POLICY\fR, \fBX509_V_FLAG_INHIBIT_ANY\fR and \&\fBX509_V_FLAG_INHIBIT_MAP\fR set the \fBrequire explicit policy\fR, \fBinhibit any policy\fR and \fBinhibit policy mapping\fR flags respectively as defined in \&\fB\s-1RFC3280\s0\fR. Policy checking is automatically enabled if any of these flags are set. .PP If \fBX509_V_FLAG_NOTIFY_POLICY\fR is set and the policy checking is successful a special status code is set to the verification callback. This permits it to examine the valid policy tree and perform additional checks or simply log it for debugging purposes. .PP By default some additional features such as indirect CRLs and CRLs signed by different keys are disabled. If \fBX509_V_FLAG_EXTENDED_CRL_SUPPORT\fR is set they are enabled. .PP If \fBX509_V_FLAG_USE_DELTAS\fR ise set delta CRLs (if present) are used to determine certificate status. If not set deltas are ignored. .PP \&\fBX509_V_FLAG_CHECK_SS_SIGNATURE\fR enables checking of the root \s-1CA\s0 self signed cerificate signature. By default this check is disabled because it doesn't add any additional security but in some cases applications might want to check the signature anyway. A side effect of not checking the root \s-1CA\s0 signature is that disabled or unsupported message digests on the root \s-1CA\s0 are not treated as fatal errors. .PP The \fBX509_V_FLAG_CB_ISSUER_CHECK\fR flag enables debugging of certificate issuer checks. It is \fBnot\fR needed unless you are logging certificate verification. If this flag is set then additional status codes will be sent to the verification callback and it \fBmust\fR be prepared to handle such cases without assuming they are hard errors. .SH "NOTES" .IX Header "NOTES" The above functions should be used to manipulate verification parameters instead of legacy functions which work in specific structures such as \&\fIX509_STORE_CTX_set_flags()\fR. .SH "BUGS" .IX Header "BUGS" Delta \s-1CRL\s0 checking is currently primitive. Only a single delta can be used and (partly due to limitations of \fBX509_STORE\fR) constructed CRLs are not maintained. .PP If CRLs checking is enable CRLs are expected to be available in the corresponding \fBX509_STORE\fR structure. No attempt is made to download CRLs from the \s-1CRL\s0 distribution points extension. .SH "EXAMPLE" .IX Header "EXAMPLE" Enable \s-1CRL\s0 checking when performing certificate verification during \s-1SSL\s0 connections associated with an \fB\s-1SSL_CTX\s0\fR structure \fBctx\fR: .PP .Vb 5 \& X509_VERIFY_PARAM *param; \& param = X509_VERIFY_PARAM_new(); \& X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_CRL_CHECK); \& SSL_CTX_set1_param(ctx, param); \& X509_VERIFY_PARAM_free(param); .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIX509_verify_cert\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/PKCS7_encrypt.30000644000175000017500000001541312360020722020170 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PKCS7_encrypt 3" .TH PKCS7_encrypt 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PKCS7_encrypt \- create a PKCS#7 envelopedData structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIPKCS7_encrypt()\fR creates and returns a PKCS#7 envelopedData structure. \fBcerts\fR is a list of recipient certificates. \fBin\fR is the content to be encrypted. \&\fBcipher\fR is the symmetric cipher to use. \fBflags\fR is an optional set of flags. .SH "NOTES" .IX Header "NOTES" Only \s-1RSA\s0 keys are supported in PKCS#7 and envelopedData so the recipient certificates supplied to this function must all contain \s-1RSA\s0 public keys, though they do not have to be signed using the \s-1RSA\s0 algorithm. .PP The algorithm passed in the \fBcipher\fR parameter must support \s-1ASN1\s0 encoding of its parameters. .PP Many browsers implement a \*(L"sign and encrypt\*(R" option which is simply an S/MIME envelopedData containing an S/MIME signed message. This can be readily produced by storing the S/MIME signed message in a memory \s-1BIO\s0 and passing it to \&\fIPKCS7_encrypt()\fR. .PP The following flags can be passed in the \fBflags\fR parameter. .PP If the \fB\s-1PKCS7_TEXT\s0\fR flag is set \s-1MIME\s0 headers for type \fBtext/plain\fR are prepended to the data. .PP Normally the supplied content is translated into \s-1MIME\s0 canonical format (as required by the S/MIME specifications) if \fB\s-1PKCS7_BINARY\s0\fR is set no translation occurs. This option should be used if the supplied data is in binary format otherwise the translation will corrupt it. If \fB\s-1PKCS7_BINARY\s0\fR is set then \&\fB\s-1PKCS7_TEXT\s0\fR is ignored. .PP If the \fB\s-1PKCS7_STREAM\s0\fR flag is set a partial \fB\s-1PKCS7\s0\fR structure is output suitable for streaming I/O: no data is read from the \s-1BIO \s0\fBin\fR. .SH "NOTES" .IX Header "NOTES" If the flag \fB\s-1PKCS7_STREAM\s0\fR is set the returned \fB\s-1PKCS7\s0\fR structure is \fBnot\fR complete and outputting its contents via a function that does not properly finalize the \fB\s-1PKCS7\s0\fR structure will give unpredictable results. .PP Several functions including \fISMIME_write_PKCS7()\fR, \fIi2d_PKCS7_bio_stream()\fR, \&\fIPEM_write_bio_PKCS7_stream()\fR finalize the structure. Alternatively finalization can be performed by obtaining the streaming \s-1ASN1 \s0\fB\s-1BIO\s0\fR directly using \&\fIBIO_new_PKCS7()\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIPKCS7_encrypt()\fR returns either a \s-1PKCS7\s0 structure or \s-1NULL\s0 if an error occurred. The error can be obtained from \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fIPKCS7_decrypt\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIPKCS7_decrypt()\fR was added to OpenSSL 0.9.5 The \fB\s-1PKCS7_STREAM\s0\fR flag was first supported in OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_get_verify_mode.30000644000175000017500000001336112360020731022203 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_get_verify_mode 3" .TH SSL_CTX_get_verify_mode 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_get_verify_mode, SSL_get_verify_mode, SSL_CTX_get_verify_depth, SSL_get_verify_depth, SSL_get_verify_callback, SSL_CTX_get_verify_callback \- get currently set verification parameters .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_CTX_get_verify_mode(const SSL_CTX *ctx); \& int SSL_get_verify_mode(const SSL *ssl); \& int SSL_CTX_get_verify_depth(const SSL_CTX *ctx); \& int SSL_get_verify_depth(const SSL *ssl); \& int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(int, X509_STORE_CTX *); \& int (*SSL_get_verify_callback(const SSL *ssl))(int, X509_STORE_CTX *); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_get_verify_mode()\fR returns the verification mode currently set in \&\fBctx\fR. .PP \&\fISSL_get_verify_mode()\fR returns the verification mode currently set in \&\fBssl\fR. .PP \&\fISSL_CTX_get_verify_depth()\fR returns the verification depth limit currently set in \fBctx\fR. If no limit has been explicitly set, \-1 is returned and the default value will be used. .PP \&\fISSL_get_verify_depth()\fR returns the verification depth limit currently set in \fBssl\fR. If no limit has been explicitly set, \-1 is returned and the default value will be used. .PP \&\fISSL_CTX_get_verify_callback()\fR returns a function pointer to the verification callback currently set in \fBctx\fR. If no callback was explicitly set, the \&\s-1NULL\s0 pointer is returned and the default callback will be used. .PP \&\fISSL_get_verify_callback()\fR returns a function pointer to the verification callback currently set in \fBssl\fR. If no callback was explicitly set, the \&\s-1NULL\s0 pointer is returned and the default callback will be used. .SH "RETURN VALUES" .IX Header "RETURN VALUES" See \s-1DESCRIPTION\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_CTX_set_verify\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/ERR_put_error.30000644000175000017500000001215712360020717020334 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ERR_put_error 3" .TH ERR_put_error 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ERR_put_error, ERR_add_error_data \- record an error .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void ERR_put_error(int lib, int func, int reason, const char *file, \& int line); \& \& void ERR_add_error_data(int num, ...); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIERR_put_error()\fR adds an error code to the thread's error queue. It signals that the error of reason code \fBreason\fR occurred in function \&\fBfunc\fR of library \fBlib\fR, in line number \fBline\fR of \fBfile\fR. This function is usually called by a macro. .PP \&\fIERR_add_error_data()\fR associates the concatenation of its \fBnum\fR string arguments with the error code added last. .PP \&\fIERR_load_strings\fR\|(3) can be used to register error strings so that the application can a generate human-readable error messages for the error code. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIERR_put_error()\fR and \fIERR_add_error_data()\fR return no values. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIerr\fR\|(3), \fIERR_load_strings\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIERR_put_error()\fR is available in all versions of SSLeay and OpenSSL. \&\fIERR_add_error_data()\fR was added in SSLeay 0.9.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/X509_NAME_ENTRY_get_object.30000644000175000017500000001563012360020725022214 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "X509_NAME_ENTRY_get_object 3" .TH X509_NAME_ENTRY_get_object 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" X509_NAME_ENTRY_get_object, X509_NAME_ENTRY_get_data, X509_NAME_ENTRY_set_object, X509_NAME_ENTRY_set_data, X509_NAME_ENTRY_create_by_txt, X509_NAME_ENTRY_create_by_NID, X509_NAME_ENTRY_create_by_OBJ \- X509_NAME_ENTRY utility functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne); \& ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne); \& \& int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, ASN1_OBJECT *obj); \& int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, const unsigned char *bytes, int len); \& \& X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, const char *field, int type, const unsigned char *bytes, int len); \& X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, int type,unsigned char *bytes, int len); \& X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, ASN1_OBJECT *obj, int type, const unsigned char *bytes, int len); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIX509_NAME_ENTRY_get_object()\fR retrieves the field name of \fBne\fR in and \fB\s-1ASN1_OBJECT\s0\fR structure. .PP \&\fIX509_NAME_ENTRY_get_data()\fR retrieves the field value of \fBne\fR in and \fB\s-1ASN1_STRING\s0\fR structure. .PP \&\fIX509_NAME_ENTRY_set_object()\fR sets the field name of \fBne\fR to \fBobj\fR. .PP \&\fIX509_NAME_ENTRY_set_data()\fR sets the field value of \fBne\fR to string type \&\fBtype\fR and value determined by \fBbytes\fR and \fBlen\fR. .PP \&\fIX509_NAME_ENTRY_create_by_txt()\fR, \fIX509_NAME_ENTRY_create_by_NID()\fR and \fIX509_NAME_ENTRY_create_by_OBJ()\fR create and return an \&\fBX509_NAME_ENTRY\fR structure. .SH "NOTES" .IX Header "NOTES" \&\fIX509_NAME_ENTRY_get_object()\fR and \fIX509_NAME_ENTRY_get_data()\fR can be used to examine an \fBX509_NAME_ENTRY\fR function as returned by \&\fIX509_NAME_get_entry()\fR for example. .PP \&\fIX509_NAME_ENTRY_create_by_txt()\fR, \fIX509_NAME_ENTRY_create_by_NID()\fR, and \fIX509_NAME_ENTRY_create_by_OBJ()\fR create and return an .PP \&\fIX509_NAME_ENTRY_create_by_txt()\fR, \fIX509_NAME_ENTRY_create_by_OBJ()\fR, \&\fIX509_NAME_ENTRY_create_by_NID()\fR and \fIX509_NAME_ENTRY_set_data()\fR are seldom used in practice because \fBX509_NAME_ENTRY\fR structures are almost always part of \fBX509_NAME\fR structures and the corresponding \fBX509_NAME\fR functions are typically used to create and add new entries in a single operation. .PP The arguments of these functions support similar options to the similarly named ones of the corresponding \fBX509_NAME\fR functions such as \&\fIX509_NAME_add_entry_by_txt()\fR. So for example \fBtype\fR can be set to \&\fB\s-1MBSTRING_ASC\s0\fR but in the case of \fIX509_set_data()\fR the field name must be set first so the relevant field information can be looked up internally. .SH "RETURN VALUES" .IX Header "RETURN VALUES" .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fId2i_X509_NAME\fR\|(3), \&\fIOBJ_nid2obj\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/RAND_load_file.30000644000175000017500000001257312360020723020324 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RAND_load_file 3" .TH RAND_load_file 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RAND_load_file, RAND_write_file, RAND_file_name \- PRNG seed file .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& const char *RAND_file_name(char *buf, size_t num); \& \& int RAND_load_file(const char *filename, long max_bytes); \& \& int RAND_write_file(const char *filename); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIRAND_file_name()\fR returns a default path for the random seed file. \&\fBbuf\fR points to a buffer of size \fBnum\fR in which to store the filename. If \fBnum\fR is too small for the path name, an error occurs. .PP \&\fIRAND_load_file()\fR used to allow for the state of the random number generator to be controlled by external sources. .PP It is kept for \s-1ABI\s0 compatibility but is no longer functional, and should not used in new programs. .PP \&\fIRAND_write_file()\fR writes a number of random bytes (currently 1024) to file \fBfilename\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIRAND_load_file()\fR always returns 0. .PP \&\fIRAND_write_file()\fR returns the number of bytes written, and \-1 if the bytes written were generated without appropriate seed. .PP \&\fIRAND_file_name()\fR returns a pointer to \fBbuf\fR on success, and \s-1NULL\s0 on error. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIrand\fR\|(3), \fIRAND_add\fR\|(3), \&\fIRAND_cleanup\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIRAND_load_file()\fR, \fIRAND_write_file()\fR and \fIRAND_file_name()\fR are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_pending.30000644000175000017500000001203212360020736017741 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_pending 3" .TH SSL_pending 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_pending \- obtain number of readable bytes buffered in an SSL object .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_pending(const SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_pending()\fR returns the number of bytes which are available inside \&\fBssl\fR for immediate read. .SH "NOTES" .IX Header "NOTES" Data are received in blocks from the peer. Therefore data can be buffered inside \fBssl\fR and are ready for immediate retrieval with \&\fISSL_read\fR\|(3). .SH "RETURN VALUES" .IX Header "RETURN VALUES" The number of bytes pending is returned. .SH "BUGS" .IX Header "BUGS" \&\fISSL_pending()\fR takes into account only bytes from the \s-1TLS/SSL\s0 record that is currently being processed (if any). If the \fB\s-1SSL\s0\fR object's \&\fIread_ahead\fR flag is set, additional protocol bytes may have been read containing more \s-1TLS/SSL\s0 records; these are ignored by \&\fISSL_pending()\fR. .PP Up to OpenSSL 0.9.6, \fISSL_pending()\fR does not check if the record type of pending data is application data. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_read\fR\|(3), \fIssl\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/PKCS7_sign_add_signer.30000644000175000017500000001664512360020723021634 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PKCS7_sign_add_signer 3" .TH PKCS7_sign_add_signer 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PKCS7_sign_add_signer \- add a signer PKCS7 signed data structure. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7, X509 *signcert, EVP_PKEY *pkey, const EVP_MD *md, int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIPKCS7_sign_add_signer()\fR adds a signer with certificate \fBsigncert\fR and private key \fBpkey\fR using message digest \fBmd\fR to a \s-1PKCS7\s0 signed data structure \&\fBp7\fR. .PP The \s-1PKCS7\s0 structure should be obtained from an initial call to \fIPKCS7_sign()\fR with the flag \fB\s-1PKCS7_PARTIAL\s0\fR set or in the case or re-signing a valid \s-1PKCS7\s0 signed data structure. .PP If the \fBmd\fR parameter is \fB\s-1NULL\s0\fR then the default digest for the public key algorithm will be used. .PP Unless the \fB\s-1PKCS7_REUSE_DIGEST\s0\fR flag is set the returned \s-1PKCS7\s0 structure is not complete and must be finalized either by streaming (if applicable) or a call to \fIPKCS7_final()\fR. .SH "NOTES" .IX Header "NOTES" The main purpose of this function is to provide finer control over a PKCS#7 signed data structure where the simpler \fIPKCS7_sign()\fR function defaults are not appropriate. For example if multiple signers or non default digest algorithms are needed. .PP Any of the following flags (ored together) can be passed in the \fBflags\fR parameter. .PP If \fB\s-1PKCS7_REUSE_DIGEST\s0\fR is set then an attempt is made to copy the content digest value from the \s-1PKCS7\s0 struture: to add a signer to an existing structure. An error occurs if a matching digest value cannot be found to copy. The returned \s-1PKCS7\s0 structure will be valid and finalized when this flag is set. .PP If \fB\s-1PKCS7_PARTIAL\s0\fR is set in addition to \fB\s-1PKCS7_REUSE_DIGEST\s0\fR then the \&\fB\s-1PKCS7_SIGNER_INO\s0\fR structure will not be finalized so additional attributes can be added. In this case an explicit call to \fIPKCS7_SIGNER_INFO_sign()\fR is needed to finalize it. .PP If \fB\s-1PKCS7_NOCERTS\s0\fR is set the signer's certificate will not be included in the \&\s-1PKCS7\s0 structure, the signer's certificate must still be supplied in the \&\fBsigncert\fR parameter though. This can reduce the size of the signature if the signers certificate can be obtained by other means: for example a previously signed message. .PP The signedData structure includes several PKCS#7 autenticatedAttributes including the signing time, the PKCS#7 content type and the supported list of ciphers in an SMIMECapabilities attribute. If \fB\s-1PKCS7_NOATTR\s0\fR is set then no authenticatedAttributes will be used. If \fB\s-1PKCS7_NOSMIMECAP\s0\fR is set then just the SMIMECapabilities are omitted. .PP If present the SMIMECapabilities attribute indicates support for the following algorithms: triple \s-1DES, 128\s0 bit \s-1RC2, 64\s0 bit \s-1RC2, DES\s0 and 40 bit \s-1RC2.\s0 If any of these algorithms is disabled then it will not be included. .PP \&\fIPKCS7_sign_add_signers()\fR returns an internal pointer to the \s-1PKCS7_SIGNER_INFO\s0 structure just added, this can be used to set additional attributes before it is finalized. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIPKCS7_sign_add_signers()\fR returns an internal pointer to the \s-1PKCS7_SIGNER_INFO\s0 structure just added or \s-1NULL\s0 if an error occurs. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fIPKCS7_sign\fR\|(3), \&\fIPKCS7_final\fR\|(3), .SH "HISTORY" .IX Header "HISTORY" \&\fIPPKCS7_sign_add_signer()\fR was added to OpenSSL 1.0.0 deps/libressl-pnacl-sys-2.1.6/libressl/man/BF_set_key.30000644000175000017500000002204212360020707017606 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BF_set_key 3" .TH BF_set_key 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" blowfish, BF_set_key, BF_encrypt, BF_decrypt, BF_ecb_encrypt, BF_cbc_encrypt, BF_cfb64_encrypt, BF_ofb64_encrypt, BF_options \- Blowfish encryption .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void BF_set_key(BF_KEY *key, int len, const unsigned char *data); \& \& void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, \& BF_KEY *key, int enc); \& void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, \& long length, BF_KEY *schedule, unsigned char *ivec, int enc); \& void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, \& long length, BF_KEY *schedule, unsigned char *ivec, int *num, \& int enc); \& void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, \& long length, BF_KEY *schedule, unsigned char *ivec, int *num); \& const char *BF_options(void); \& \& void BF_encrypt(BF_LONG *data,const BF_KEY *key); \& void BF_decrypt(BF_LONG *data,const BF_KEY *key); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This library implements the Blowfish cipher, which was invented and described by Counterpane (see http://www.counterpane.com/blowfish.html ). .PP Blowfish is a block cipher that operates on 64 bit (8 byte) blocks of data. It uses a variable size key, but typically, 128 bit (16 byte) keys are considered good for strong encryption. Blowfish can be used in the same modes as \s-1DES \s0(see \fIdes_modes\fR\|(7)). Blowfish is currently one of the faster block ciphers. It is quite a bit faster than \s-1DES,\s0 and much faster than \s-1IDEA\s0 or \s-1RC2.\s0 .PP Blowfish consists of a key setup phase and the actual encryption or decryption phase. .PP \&\fIBF_set_key()\fR sets up the \fB\s-1BF_KEY\s0\fR \fBkey\fR using the \fBlen\fR bytes long key at \fBdata\fR. .PP \&\fIBF_ecb_encrypt()\fR is the basic Blowfish encryption and decryption function. It encrypts or decrypts the first 64 bits of \fBin\fR using the key \fBkey\fR, putting the result in \fBout\fR. \fBenc\fR decides if encryption (\fB\s-1BF_ENCRYPT\s0\fR) or decryption (\fB\s-1BF_DECRYPT\s0\fR) shall be performed. The vector pointed at by \&\fBin\fR and \fBout\fR must be 64 bits in length, no less. If they are larger, everything after the first 64 bits is ignored. .PP The mode functions \fIBF_cbc_encrypt()\fR, \fIBF_cfb64_encrypt()\fR and \fIBF_ofb64_encrypt()\fR all operate on variable length data. They all take an initialization vector \&\fBivec\fR which needs to be passed along into the next call of the same function for the same message. \fBivec\fR may be initialized with anything, but the recipient needs to know what it was initialized with, or it won't be able to decrypt. Some programs and protocols simplify this, like \s-1SSH,\s0 where \&\fBivec\fR is simply initialized to zero. \&\fIBF_cbc_encrypt()\fR operates on data that is a multiple of 8 bytes long, while \&\fIBF_cfb64_encrypt()\fR and \fIBF_ofb64_encrypt()\fR are used to encrypt an variable number of bytes (the amount does not have to be an exact multiple of 8). The purpose of the latter two is to simulate stream ciphers, and therefore, they need the parameter \fBnum\fR, which is a pointer to an integer where the current offset in \fBivec\fR is stored between calls. This integer must be initialized to zero when \fBivec\fR is initialized. .PP \&\fIBF_cbc_encrypt()\fR is the Cipher Block Chaining function for Blowfish. It encrypts or decrypts the 64 bits chunks of \fBin\fR using the key \fBschedule\fR, putting the result in \fBout\fR. \fBenc\fR decides if encryption (\s-1BF_ENCRYPT\s0) or decryption (\s-1BF_DECRYPT\s0) shall be performed. \fBivec\fR must point at an 8 byte long initialization vector. .PP \&\fIBF_cfb64_encrypt()\fR is the \s-1CFB\s0 mode for Blowfish with 64 bit feedback. It encrypts or decrypts the bytes in \fBin\fR using the key \fBschedule\fR, putting the result in \fBout\fR. \fBenc\fR decides if encryption (\fB\s-1BF_ENCRYPT\s0\fR) or decryption (\fB\s-1BF_DECRYPT\s0\fR) shall be performed. \fBivec\fR must point at an 8 byte long initialization vector. \fBnum\fR must point at an integer which must be initially zero. .PP \&\fIBF_ofb64_encrypt()\fR is the \s-1OFB\s0 mode for Blowfish with 64 bit feedback. It uses the same parameters as \fIBF_cfb64_encrypt()\fR, which must be initialized the same way. .PP \&\fIBF_encrypt()\fR and \fIBF_decrypt()\fR are the lowest level functions for Blowfish encryption. They encrypt/decrypt the first 64 bits of the vector pointed by \&\fBdata\fR, using the key \fBkey\fR. These functions should not be used unless you implement 'modes' of Blowfish. The alternative is to use \fIBF_ecb_encrypt()\fR. If you still want to use these functions, you should be aware that they take each 32\-bit chunk in host-byte order, which is little-endian on little-endian platforms and big-endian on big-endian ones. .SH "RETURN VALUES" .IX Header "RETURN VALUES" None of the functions presented here return any value. .SH "NOTE" .IX Header "NOTE" Applications should use the higher level functions \&\fIEVP_EncryptInit\fR\|(3) etc. instead of calling the blowfish functions directly. .SH "HISTORY" .IX Header "HISTORY" The Blowfish functions are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CIPHER_get_name.30000644000175000017500000002117512360020730021130 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CIPHER_get_name 3" .TH SSL_CIPHER_get_name 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CIPHER_get_name, SSL_CIPHER_get_bits, SSL_CIPHER_get_version, SSL_CIPHER_description \- get SSL_CIPHER properties .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& const char *SSL_CIPHER_get_name(const SSL_CIPHER *cipher); \& int SSL_CIPHER_get_bits(const SSL_CIPHER *cipher, int *alg_bits); \& char *SSL_CIPHER_get_version(const SSL_CIPHER *cipher); \& char *SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int size); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CIPHER_get_name()\fR returns a pointer to the name of \fBcipher\fR. If the argument is the \s-1NULL\s0 pointer, a pointer to the constant value \*(L"\s-1NONE\*(R"\s0 is returned. .PP \&\fISSL_CIPHER_get_bits()\fR returns the number of secret bits used for \fBcipher\fR. If \&\fBalg_bits\fR is not \s-1NULL,\s0 it contains the number of bits processed by the chosen algorithm. If \fBcipher\fR is \s-1NULL, 0\s0 is returned. .PP \&\fISSL_CIPHER_get_version()\fR returns string which indicates the \s-1SSL/TLS\s0 protocol version that first defined the cipher. This is currently \fBSSLv2\fR or \fBTLSv1/SSLv3\fR. In some cases it should possibly return \*(L"TLSv1.2\*(R" but the function does not; use \fISSL_CIPHER_description()\fR instead. If \fBcipher\fR is \s-1NULL, \*(L"\s0(\s-1NONE\s0)\*(R" is returned. .PP \&\fISSL_CIPHER_description()\fR returns a textual description of the cipher used into the buffer \fBbuf\fR of length \fBlen\fR provided. If \fBbuf\fR is \s-1NULL,\s0 a buffer is allocated using \fIasprintf()\fR; that buffer should be freed up using the \fBfree\fR function. If \fBlen\fR is too small, or if \fBbuf\fR is \s-1NULL\s0 and the allocation fails, a pointer to the string \*(L"Buffer too small\*(R" is returned. .SH "NOTES" .IX Header "NOTES" The number of bits processed can be different from the secret bits. An export cipher like e.g. \s-1EXP\-RC4\-MD5\s0 has only 40 secret bits. The algorithm does use the full 128 bits (which would be returned for \fBalg_bits\fR), of which however 88bits are fixed. The search space is hence only 40 bits. .PP The string returned by \fISSL_CIPHER_description()\fR in case of success consists of cleartext information separated by one or more blanks in the following sequence: .IP "" 4 .IX Item "" Textual representation of the cipher name. .IP "" 4 .IX Item "" Protocol version: \fBSSLv2\fR, \fBSSLv3\fR, \fBTLSv1.2\fR. The TLSv1.0 ciphers are flagged with SSLv3. No new ciphers were added by TLSv1.1. .IP "Kx=" 4 .IX Item "Kx=" Key exchange method: \fB\s-1RSA\s0\fR (for export ciphers as \fB\s-1RSA\s0(512)\fR or \&\fB\s-1RSA\s0(1024)\fR), \fB\s-1DH\s0\fR (for export ciphers as \fB\s-1DH\s0(512)\fR or \fB\s-1DH\s0(1024)\fR), \&\fB\s-1DH/RSA\s0\fR, \fB\s-1DH/DSS\s0\fR, \fBFortezza\fR. .IP "Au=" 4 .IX Item "Au=" Authentication method: \fB\s-1RSA\s0\fR, \fB\s-1DSS\s0\fR, \fB\s-1DH\s0\fR, \fBNone\fR. None is the representation of anonymous ciphers. .IP "Enc=" 4 .IX Item "Enc=" Encryption method with number of secret bits: \fB\s-1DES\s0(40)\fR, \fB\s-1DES\s0(56)\fR, \&\fB3DES(168)\fR, \fB\s-1RC4\s0(40)\fR, \fB\s-1RC4\s0(56)\fR, \fB\s-1RC4\s0(64)\fR, \fB\s-1RC4\s0(128)\fR, \&\fB\s-1RC2\s0(40)\fR, \fB\s-1RC2\s0(56)\fR, \fB\s-1RC2\s0(128)\fR, \fB\s-1IDEA\s0(128)\fR, \fBFortezza\fR, \fBNone\fR. .IP "Mac=" 4 .IX Item "Mac=" Message digest: \fB\s-1MD5\s0\fR, \fB\s-1SHA1\s0\fR. .IP "" 4 .IX Item "" If the cipher is flagged exportable with respect to old \s-1US\s0 crypto regulations, the word "\fBexport\fR" is printed. .SH "EXAMPLES" .IX Header "EXAMPLES" Some examples for the output of \fISSL_CIPHER_description()\fR: .PP .Vb 4 \& EDH\-RSA\-DES\-CBC3\-SHA SSLv3 Kx=DH Au=RSA Enc=3DES(168) Mac=SHA1 \& EDH\-DSS\-DES\-CBC3\-SHA SSLv3 Kx=DH Au=DSS Enc=3DES(168) Mac=SHA1 \& RC4\-MD5 SSLv3 Kx=RSA Au=RSA Enc=RC4(128) Mac=MD5 \& EXP\-RC4\-MD5 SSLv3 Kx=RSA(512) Au=RSA Enc=RC4(40) Mac=MD5 export .Ve .PP A complete list can be retrieved by invoking the following command: .PP .Vb 1 \& openssl ciphers \-v ALL .Ve .SH "BUGS" .IX Header "BUGS" If \fISSL_CIPHER_description()\fR is called with \fBcipher\fR being \s-1NULL,\s0 the library crashes. .PP If \fISSL_CIPHER_description()\fR cannot handle a built-in cipher, the according description of the cipher property is \fBunknown\fR. This case should not occur. .SH "RETURN VALUES" .IX Header "RETURN VALUES" See \s-1DESCRIPTION\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_get_current_cipher\fR\|(3), \&\fISSL_get_ciphers\fR\|(3), \fIciphers\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/PKCS7_sign.30000644000175000017500000002157112360020722017446 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PKCS7_sign 3" .TH PKCS7_sign 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PKCS7_sign \- create a PKCS#7 signedData structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, BIO *data, int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIPKCS7_sign()\fR creates and returns a PKCS#7 signedData structure. \fBsigncert\fR is the certificate to sign with, \fBpkey\fR is the corresponsding private key. \&\fBcerts\fR is an optional additional set of certificates to include in the PKCS#7 structure (for example any intermediate CAs in the chain). .PP The data to be signed is read from \s-1BIO \s0\fBdata\fR. .PP \&\fBflags\fR is an optional set of flags. .SH "NOTES" .IX Header "NOTES" Any of the following flags (ored together) can be passed in the \fBflags\fR parameter. .PP Many S/MIME clients expect the signed content to include valid \s-1MIME\s0 headers. If the \fB\s-1PKCS7_TEXT\s0\fR flag is set \s-1MIME\s0 headers for type \fBtext/plain\fR are prepended to the data. .PP If \fB\s-1PKCS7_NOCERTS\s0\fR is set the signer's certificate will not be included in the \&\s-1PKCS7\s0 structure, the signer's certificate must still be supplied in the \&\fBsigncert\fR parameter though. This can reduce the size of the signature if the signers certificate can be obtained by other means: for example a previously signed message. .PP The data being signed is included in the \s-1PKCS7\s0 structure, unless \&\fB\s-1PKCS7_DETACHED\s0\fR is set in which case it is omitted. This is used for \s-1PKCS7\s0 detached signatures which are used in S/MIME plaintext signed messages for example. .PP Normally the supplied content is translated into \s-1MIME\s0 canonical format (as required by the S/MIME specifications) if \fB\s-1PKCS7_BINARY\s0\fR is set no translation occurs. This option should be used if the supplied data is in binary format otherwise the translation will corrupt it. .PP The signedData structure includes several PKCS#7 autenticatedAttributes including the signing time, the PKCS#7 content type and the supported list of ciphers in an SMIMECapabilities attribute. If \fB\s-1PKCS7_NOATTR\s0\fR is set then no authenticatedAttributes will be used. If \fB\s-1PKCS7_NOSMIMECAP\s0\fR is set then just the SMIMECapabilities are omitted. .PP If present the SMIMECapabilities attribute indicates support for the following algorithms: triple \s-1DES, 128\s0 bit \s-1RC2, 64\s0 bit \s-1RC2, DES\s0 and 40 bit \s-1RC2.\s0 If any of these algorithms is disabled then it will not be included. .PP If the flags \fB\s-1PKCS7_STREAM\s0\fR is set then the returned \fB\s-1PKCS7\s0\fR structure is just initialized ready to perform the signing operation. The signing is however \&\fBnot\fR performed and the data to be signed is not read from the \fBdata\fR parameter. Signing is deferred until after the data has been written. In this way data can be signed in a single pass. .PP If the \fB\s-1PKCS7_PARTIAL\s0\fR flag is set a partial \fB\s-1PKCS7\s0\fR structure is output to which additional signers and capabilities can be added before finalization. .SH "NOTES" .IX Header "NOTES" If the flag \fB\s-1PKCS7_STREAM\s0\fR is set the returned \fB\s-1PKCS7\s0\fR structure is \fBnot\fR complete and outputting its contents via a function that does not properly finalize the \fB\s-1PKCS7\s0\fR structure will give unpredictable results. .PP Several functions including \fISMIME_write_PKCS7()\fR, \fIi2d_PKCS7_bio_stream()\fR, \&\fIPEM_write_bio_PKCS7_stream()\fR finalize the structure. Alternatively finalization can be performed by obtaining the streaming \s-1ASN1 \s0\fB\s-1BIO\s0\fR directly using \&\fIBIO_new_PKCS7()\fR. .PP If a signer is specified it will use the default digest for the signing algorithm. This is \fB\s-1SHA1\s0\fR for both \s-1RSA\s0 and \s-1DSA\s0 keys. .PP In OpenSSL 1.0.0 the \fBcerts\fR, \fBsigncert\fR and \fBpkey\fR parameters can all be \&\fB\s-1NULL\s0\fR if the \fB\s-1PKCS7_PARTIAL\s0\fR flag is set. One or more signers can be added using the function \fB\f(BIPKCS7_sign_add_signer()\fB\fR. \fB\f(BIPKCS7_final()\fB\fR must also be called to finalize the structure if streaming is not enabled. Alternative signing digests can also be specified using this method. .PP In OpenSSL 1.0.0 if \fBsigncert\fR and \fBpkey\fR are \s-1NULL\s0 then a certificates only PKCS#7 structure is output. .PP In versions of OpenSSL before 1.0.0 the \fBsigncert\fR and \fBpkey\fR parameters must \&\fB\s-1NOT\s0\fR be \s-1NULL.\s0 .SH "BUGS" .IX Header "BUGS" Some advanced attributes such as counter signatures are not supported. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIPKCS7_sign()\fR returns either a valid \s-1PKCS7\s0 structure or \s-1NULL\s0 if an error occurred. The error can be obtained from \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fIPKCS7_verify\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIPKCS7_sign()\fR was added to OpenSSL 0.9.5 .PP The \fB\s-1PKCS7_PARTIAL\s0\fR flag was added in OpenSSL 1.0.0 .PP The \fB\s-1PKCS7_STREAM\s0\fR flag was added in OpenSSL 1.0.0 deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_timeout.30000644000175000017500000001357212360020733021403 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_timeout 3" .TH SSL_CTX_set_timeout 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_timeout, SSL_CTX_get_timeout \- manipulate timeout values for session caching .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& long SSL_CTX_set_timeout(SSL_CTX *ctx, long t); \& long SSL_CTX_get_timeout(SSL_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_timeout()\fR sets the timeout for newly created sessions for \&\fBctx\fR to \fBt\fR. The timeout value \fBt\fR must be given in seconds. .PP \&\fISSL_CTX_get_timeout()\fR returns the currently set timeout value for \fBctx\fR. .SH "NOTES" .IX Header "NOTES" Whenever a new session is created, it is assigned a maximum lifetime. This lifetime is specified by storing the creation time of the session and the timeout value valid at this time. If the actual time is later than creation time plus timeout, the session is not reused. .PP Due to this realization, all sessions behave according to the timeout value valid at the time of the session negotiation. Changes of the timeout value do not affect already established sessions. .PP The expiration time of a single session can be modified using the \&\fISSL_SESSION_get_time\fR\|(3) family of functions. .PP Expired sessions are removed from the internal session cache, whenever \&\fISSL_CTX_flush_sessions\fR\|(3) is called, either directly by the application or automatically (see \&\fISSL_CTX_set_session_cache_mode\fR\|(3)) .PP The default value for session timeout is decided on a per protocol basis, see \fISSL_get_default_timeout\fR\|(3). All currently supported protocols have the same default timeout value of 300 seconds. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_set_timeout()\fR returns the previously set timeout value. .PP \&\fISSL_CTX_get_timeout()\fR returns the currently set timeout value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \&\fISSL_CTX_set_session_cache_mode\fR\|(3), \&\fISSL_SESSION_get_time\fR\|(3), \&\fISSL_CTX_flush_sessions\fR\|(3), \&\fISSL_get_default_timeout\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SHA1.30000644000175000017500000001422612360020724016274 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SHA1 3" .TH SHA1 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SHA1, SHA1_Init, SHA1_Update, SHA1_Final \- Secure Hash Algorithm .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& unsigned char *SHA1(const unsigned char *d, unsigned long n, \& unsigned char *md); \& \& int SHA1_Init(SHA_CTX *c); \& int SHA1_Update(SHA_CTX *c, const void *data, \& unsigned long len); \& int SHA1_Final(unsigned char *md, SHA_CTX *c); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\s-1SHA\-1 \s0(Secure Hash Algorithm) is a cryptographic hash function with a 160 bit output. .PP \&\s-1\fISHA1\s0()\fR computes the \s-1SHA\-1\s0 message digest of the \fBn\fR bytes at \fBd\fR and places it in \fBmd\fR (which must have space for \&\s-1SHA_DIGEST_LENGTH\s0 == 20 bytes of output). If \fBmd\fR is \s-1NULL,\s0 the digest is placed in a static array. .PP The following functions may be used if the message is not completely stored in memory: .PP \&\fISHA1_Init()\fR initializes a \fB\s-1SHA_CTX\s0\fR structure. .PP \&\fISHA1_Update()\fR can be called repeatedly with chunks of the message to be hashed (\fBlen\fR bytes at \fBdata\fR). .PP \&\fISHA1_Final()\fR places the message digest in \fBmd\fR, which must have space for \s-1SHA_DIGEST_LENGTH\s0 == 20 bytes of output, and erases the \fB\s-1SHA_CTX\s0\fR. .PP Applications should use the higher level functions \&\fIEVP_DigestInit\fR\|(3) etc. instead of calling the hash functions directly. .PP The predecessor of \s-1SHA\-1, SHA,\s0 is also implemented, but it should be used only when backward compatibility is required. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\s-1\fISHA1\s0()\fR returns a pointer to the hash value. .PP \&\fISHA1_Init()\fR, \fISHA1_Update()\fR and \fISHA1_Final()\fR return 1 for success, 0 otherwise. .SH "CONFORMING TO" .IX Header "CONFORMING TO" \&\s-1SHA: US\s0 Federal Information Processing Standard \s-1FIPS PUB 180 \s0(Secure Hash Standard), \&\s-1SHA\-1: US\s0 Federal Information Processing Standard \s-1FIPS PUB 180\-1 \s0(Secure Hash Standard), \&\s-1ANSI X9.30\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIripemd\fR\|(3), \fIhmac\fR\|(3), \&\fIEVP_DigestInit\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\s-1\fISHA1\s0()\fR, \fISHA1_Init()\fR, \fISHA1_Update()\fR and \fISHA1_Final()\fR are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/CMS_decrypt.30000644000175000017500000001630212360020713017747 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CMS_decrypt 3" .TH CMS_decrypt 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CMS_decrypt \- decrypt content from a CMS envelopedData structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert, BIO *dcont, BIO *out, unsigned int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fICMS_decrypt()\fR extracts and decrypts the content from a \s-1CMS\s0 EnvelopedData structure. \fBpkey\fR is the private key of the recipient, \fBcert\fR is the recipient's certificate, \fBout\fR is a \s-1BIO\s0 to write the content to and \&\fBflags\fR is an optional set of flags. .PP The \fBdcont\fR parameter is used in the rare case where the encrypted content is detached. It will normally be set to \s-1NULL.\s0 .SH "NOTES" .IX Header "NOTES" \&\fIOpenSSL_add_all_algorithms()\fR (or equivalent) should be called before using this function or errors about unknown algorithms will occur. .PP Although the recipients certificate is not needed to decrypt the data it is needed to locate the appropriate (of possible several) recipients in the \s-1CMS\s0 structure. .PP If \fBcert\fR is set to \s-1NULL\s0 all possible recipients are tried. This case however is problematic. To thwart the \s-1MMA\s0 attack (Bleichenbacher's attack on \&\s-1PKCS\s0 #1 v1.5 \s-1RSA\s0 padding) all recipients are tried whether they succeed or not. If no recipient succeeds then a random symmetric key is used to decrypt the content: this will typically output garbage and may (but is not guaranteed to) ultimately return a padding error only. If \fICMS_decrypt()\fR just returned an error when all recipient encrypted keys failed to decrypt an attacker could use this in a timing attack. If the special flag \fB\s-1CMS_DEBUG_DECRYPT\s0\fR is set then the above behaviour is modified and an error \fBis\fR returned if no recipient encrypted key can be decrypted \fBwithout\fR generating a random content encryption key. Applications should use this flag with \&\fBextreme caution\fR especially in automated gateways as it can leave them open to attack. .PP It is possible to determine the correct recipient key by other means (for example looking them up in a database) and setting them in the \s-1CMS\s0 structure in advance using the \s-1CMS\s0 utility functions such as \fICMS_set1_pkey()\fR. In this case both \fBcert\fR and \fBpkey\fR should be set to \s-1NULL.\s0 .PP To process KEKRecipientInfo types \fICMS_set1_key()\fR or \fICMS_RecipientInfo_set0_key()\fR and \fICMS_ReceipientInfo_decrypt()\fR should be called before \fICMS_decrypt()\fR and \&\fBcert\fR and \fBpkey\fR set to \s-1NULL.\s0 .PP The following flags can be passed in the \fBflags\fR parameter. .PP If the \fB\s-1CMS_TEXT\s0\fR flag is set \s-1MIME\s0 headers for type \fBtext/plain\fR are deleted from the content. If the content is not of type \fBtext/plain\fR then an error is returned. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICMS_decrypt()\fR returns either 1 for success or 0 for failure. The error can be obtained from \fIERR_get_error\fR\|(3) .SH "BUGS" .IX Header "BUGS" The lack of single pass processing and the need to hold all data in memory as mentioned in \fICMS_verify()\fR also applies to \fICMS_decrypt()\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_encrypt\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fICMS_decrypt()\fR was added to OpenSSL 0.9.8 deps/libressl-pnacl-sys-2.1.6/libressl/man/ssl.30000644000175000017500000013317012360020737016405 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ssl 3" .TH ssl 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL \- OpenSSL SSL/TLS library .SH "SYNOPSIS" .IX Header "SYNOPSIS" .SH "DESCRIPTION" .IX Header "DESCRIPTION" The OpenSSL \fBssl\fR library implements the Secure Sockets Layer (\s-1SSL\s0 v2/v3) and Transport Layer Security (\s-1TLS\s0 v1) protocols. It provides a rich \s-1API\s0 which is documented here. .PP At first the library must be initialized; see \&\fISSL_library_init\fR\|(3). .PP Then an \fB\s-1SSL_CTX\s0\fR object is created as a framework to establish \&\s-1TLS/SSL\s0 enabled connections (see \fISSL_CTX_new\fR\|(3)). Various options regarding certificates, algorithms etc. can be set in this object. .PP When a network connection has been created, it can be assigned to an \&\fB\s-1SSL\s0\fR object. After the \fB\s-1SSL\s0\fR object has been created using \&\fISSL_new\fR\|(3), \fISSL_set_fd\fR\|(3) or \&\fISSL_set_bio\fR\|(3) can be used to associate the network connection with the object. .PP Then the \s-1TLS/SSL\s0 handshake is performed using \&\fISSL_accept\fR\|(3) or \fISSL_connect\fR\|(3) respectively. \&\fISSL_read\fR\|(3) and \fISSL_write\fR\|(3) are used to read and write data on the \s-1TLS/SSL\s0 connection. \&\fISSL_shutdown\fR\|(3) can be used to shut down the \&\s-1TLS/SSL\s0 connection. .SH "DATA STRUCTURES" .IX Header "DATA STRUCTURES" Currently the OpenSSL \fBssl\fR library functions deals with the following data structures: .IP "\fB\s-1SSL_METHOD\s0\fR (\s-1SSL\s0 Method)" 4 .IX Item "SSL_METHOD (SSL Method)" That's a dispatch structure describing the internal \fBssl\fR library methods/functions which implement the various protocol versions (SSLv1, SSLv2 and TLSv1). It's needed to create an \fB\s-1SSL_CTX\s0\fR. .IP "\fB\s-1SSL_CIPHER\s0\fR (\s-1SSL\s0 Cipher)" 4 .IX Item "SSL_CIPHER (SSL Cipher)" This structure holds the algorithm information for a particular cipher which are a core part of the \s-1SSL/TLS\s0 protocol. The available ciphers are configured on a \fB\s-1SSL_CTX\s0\fR basis and the actually used ones are then part of the \&\fB\s-1SSL_SESSION\s0\fR. .IP "\fB\s-1SSL_CTX\s0\fR (\s-1SSL\s0 Context)" 4 .IX Item "SSL_CTX (SSL Context)" That's the global context structure which is created by a server or client once per program life-time and which holds mainly default values for the \&\fB\s-1SSL\s0\fR structures which are later created for the connections. .IP "\fB\s-1SSL_SESSION\s0\fR (\s-1SSL\s0 Session)" 4 .IX Item "SSL_SESSION (SSL Session)" This is a structure containing the current \s-1TLS/SSL\s0 session details for a connection: \fB\s-1SSL_CIPHER\s0\fRs, client and server certificates, keys, etc. .IP "\fB\s-1SSL\s0\fR (\s-1SSL\s0 Connection)" 4 .IX Item "SSL (SSL Connection)" That's the main \s-1SSL/TLS\s0 structure which is created by a server or client per established connection. This actually is the core structure in the \s-1SSL API.\s0 Under run-time the application usually deals with this structure which has links to mostly all other structures. .SH "HEADER FILES" .IX Header "HEADER FILES" Currently the OpenSSL \fBssl\fR library provides the following C header files containing the prototypes for the data structures and and functions: .IP "\fBssl.h\fR" 4 .IX Item "ssl.h" That's the common header file for the \s-1SSL/TLS API. \s0 Include it into your program to make the \s-1API\s0 of the \fBssl\fR library available. It internally includes both more private \s-1SSL\s0 headers and headers from the \fBcrypto\fR library. Whenever you need hard-core details on the internals of the \s-1SSL API,\s0 look inside this header file. .IP "\fBssl2.h\fR" 4 .IX Item "ssl2.h" That's the sub header file dealing with the SSLv2 protocol only. \&\fIUsually you don't have to include it explicitly because it's already included by ssl.h\fR. .IP "\fBssl3.h\fR" 4 .IX Item "ssl3.h" That's the sub header file dealing with the SSLv3 protocol only. \&\fIUsually you don't have to include it explicitly because it's already included by ssl.h\fR. .IP "\fBssl23.h\fR" 4 .IX Item "ssl23.h" That's the sub header file dealing with the combined use of the SSLv2 and SSLv3 protocols. \&\fIUsually you don't have to include it explicitly because it's already included by ssl.h\fR. .IP "\fBtls1.h\fR" 4 .IX Item "tls1.h" That's the sub header file dealing with the TLSv1 protocol only. \&\fIUsually you don't have to include it explicitly because it's already included by ssl.h\fR. .SH "API FUNCTIONS" .IX Header "API FUNCTIONS" Currently the OpenSSL \fBssl\fR library exports 214 \s-1API\s0 functions. They are documented in the following: .SS "\s-1DEALING WITH PROTOCOL METHODS\s0" .IX Subsection "DEALING WITH PROTOCOL METHODS" Here we document the various \s-1API\s0 functions which deal with the \s-1SSL/TLS\s0 protocol methods defined in \fB\s-1SSL_METHOD\s0\fR structures. .IP "const \s-1SSL_METHOD\s0 *\fBSSLv2_client_method\fR(void);" 4 .IX Item "const SSL_METHOD *SSLv2_client_method(void);" Constructor for the SSLv2 \s-1SSL_METHOD\s0 structure for a dedicated client. .IP "const \s-1SSL_METHOD\s0 *\fBSSLv2_server_method\fR(void);" 4 .IX Item "const SSL_METHOD *SSLv2_server_method(void);" Constructor for the SSLv2 \s-1SSL_METHOD\s0 structure for a dedicated server. .IP "const \s-1SSL_METHOD\s0 *\fBSSLv2_method\fR(void);" 4 .IX Item "const SSL_METHOD *SSLv2_method(void);" Constructor for the SSLv2 \s-1SSL_METHOD\s0 structure for combined client and server. .IP "const \s-1SSL_METHOD\s0 *\fBSSLv3_client_method\fR(void);" 4 .IX Item "const SSL_METHOD *SSLv3_client_method(void);" Constructor for the SSLv3 \s-1SSL_METHOD\s0 structure for a dedicated client. .IP "const \s-1SSL_METHOD\s0 *\fBSSLv3_server_method\fR(void);" 4 .IX Item "const SSL_METHOD *SSLv3_server_method(void);" Constructor for the SSLv3 \s-1SSL_METHOD\s0 structure for a dedicated server. .IP "const \s-1SSL_METHOD\s0 *\fBSSLv3_method\fR(void);" 4 .IX Item "const SSL_METHOD *SSLv3_method(void);" Constructor for the SSLv3 \s-1SSL_METHOD\s0 structure for combined client and server. .IP "const \s-1SSL_METHOD\s0 *\fBTLSv1_client_method\fR(void);" 4 .IX Item "const SSL_METHOD *TLSv1_client_method(void);" Constructor for the TLSv1 \s-1SSL_METHOD\s0 structure for a dedicated client. .IP "const \s-1SSL_METHOD\s0 *\fBTLSv1_server_method\fR(void);" 4 .IX Item "const SSL_METHOD *TLSv1_server_method(void);" Constructor for the TLSv1 \s-1SSL_METHOD\s0 structure for a dedicated server. .IP "const \s-1SSL_METHOD\s0 *\fBTLSv1_method\fR(void);" 4 .IX Item "const SSL_METHOD *TLSv1_method(void);" Constructor for the TLSv1 \s-1SSL_METHOD\s0 structure for combined client and server. .SS "\s-1DEALING WITH CIPHERS\s0" .IX Subsection "DEALING WITH CIPHERS" Here we document the various \s-1API\s0 functions which deal with the \s-1SSL/TLS\s0 ciphers defined in \fB\s-1SSL_CIPHER\s0\fR structures. .IP "char *\fBSSL_CIPHER_description\fR(\s-1SSL_CIPHER\s0 *cipher, char *buf, int len);" 4 .IX Item "char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len);" Write a string to \fIbuf\fR (with a maximum size of \fIlen\fR) containing a human readable description of \fIcipher\fR. Returns \fIbuf\fR. .IP "int \fBSSL_CIPHER_get_bits\fR(\s-1SSL_CIPHER\s0 *cipher, int *alg_bits);" 4 .IX Item "int SSL_CIPHER_get_bits(SSL_CIPHER *cipher, int *alg_bits);" Determine the number of bits in \fIcipher\fR. Because of export crippled ciphers there are two bits: The bits the algorithm supports in general (stored to \&\fIalg_bits\fR) and the bits which are actually used (the return value). .IP "const char *\fBSSL_CIPHER_get_name\fR(\s-1SSL_CIPHER\s0 *cipher);" 4 .IX Item "const char *SSL_CIPHER_get_name(SSL_CIPHER *cipher);" Return the internal name of \fIcipher\fR as a string. These are the various strings defined by the \fISSL2_TXT_xxx\fR, \fISSL3_TXT_xxx\fR and \fITLS1_TXT_xxx\fR definitions in the header files. .IP "char *\fBSSL_CIPHER_get_version\fR(\s-1SSL_CIPHER\s0 *cipher);" 4 .IX Item "char *SSL_CIPHER_get_version(SSL_CIPHER *cipher);" Returns a string like "\f(CW\*(C`TLSv1/SSLv3\*(C'\fR\*(L" or \*(R"\f(CW\*(C`SSLv2\*(C'\fR" which indicates the \&\s-1SSL/TLS\s0 protocol version to which \fIcipher\fR belongs (i.e. where it was defined in the specification the first time). .SS "\s-1DEALING WITH PROTOCOL CONTEXTS\s0" .IX Subsection "DEALING WITH PROTOCOL CONTEXTS" Here we document the various \s-1API\s0 functions which deal with the \s-1SSL/TLS\s0 protocol context defined in the \fB\s-1SSL_CTX\s0\fR structure. .IP "int \fBSSL_CTX_add_client_CA\fR(\s-1SSL_CTX\s0 *ctx, X509 *x);" 4 .IX Item "int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x);" .PD 0 .IP "long \fBSSL_CTX_add_extra_chain_cert\fR(\s-1SSL_CTX\s0 *ctx, X509 *x509);" 4 .IX Item "long SSL_CTX_add_extra_chain_cert(SSL_CTX *ctx, X509 *x509);" .IP "int \fBSSL_CTX_add_session\fR(\s-1SSL_CTX\s0 *ctx, \s-1SSL_SESSION\s0 *c);" 4 .IX Item "int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *c);" .IP "int \fBSSL_CTX_check_private_key\fR(const \s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_check_private_key(const SSL_CTX *ctx);" .IP "long \fBSSL_CTX_ctrl\fR(\s-1SSL_CTX\s0 *ctx, int cmd, long larg, char *parg);" 4 .IX Item "long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg);" .IP "void \fBSSL_CTX_flush_sessions\fR(\s-1SSL_CTX\s0 *s, long t);" 4 .IX Item "void SSL_CTX_flush_sessions(SSL_CTX *s, long t);" .IP "void \fBSSL_CTX_free\fR(\s-1SSL_CTX\s0 *a);" 4 .IX Item "void SSL_CTX_free(SSL_CTX *a);" .IP "char *\fBSSL_CTX_get_app_data\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "char *SSL_CTX_get_app_data(SSL_CTX *ctx);" .IP "X509_STORE *\fBSSL_CTX_get_cert_store\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "X509_STORE *SSL_CTX_get_cert_store(SSL_CTX *ctx);" .IP "\s-1STACK\s0 *\fBSSL_CTX_get_client_CA_list\fR(const \s-1SSL_CTX\s0 *ctx);" 4 .IX Item "STACK *SSL_CTX_get_client_CA_list(const SSL_CTX *ctx);" .IP "int (*\fBSSL_CTX_get_client_cert_cb\fR(\s-1SSL_CTX\s0 *ctx))(\s-1SSL\s0 *ssl, X509 **x509, \s-1EVP_PKEY\s0 **pkey);" 4 .IX Item "int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL *ssl, X509 **x509, EVP_PKEY **pkey);" .IP "char *\fBSSL_CTX_get_ex_data\fR(const \s-1SSL_CTX\s0 *s, int idx);" 4 .IX Item "char *SSL_CTX_get_ex_data(const SSL_CTX *s, int idx);" .IP "int \fBSSL_CTX_get_ex_new_index\fR(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))" 4 .IX Item "int SSL_CTX_get_ex_new_index(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))" .IP "void (*\fBSSL_CTX_get_info_callback\fR(\s-1SSL_CTX\s0 *ctx))(\s-1SSL\s0 *ssl, int cb, int ret);" 4 .IX Item "void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(SSL *ssl, int cb, int ret);" .IP "int \fBSSL_CTX_get_quiet_shutdown\fR(const \s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx);" .IP "int \fBSSL_CTX_get_session_cache_mode\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_get_session_cache_mode(SSL_CTX *ctx);" .IP "long \fBSSL_CTX_get_timeout\fR(const \s-1SSL_CTX\s0 *ctx);" 4 .IX Item "long SSL_CTX_get_timeout(const SSL_CTX *ctx);" .IP "int (*\fBSSL_CTX_get_verify_callback\fR(const \s-1SSL_CTX\s0 *ctx))(int ok, X509_STORE_CTX *ctx);" 4 .IX Item "int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(int ok, X509_STORE_CTX *ctx);" .IP "int \fBSSL_CTX_get_verify_mode\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_get_verify_mode(SSL_CTX *ctx);" .IP "int \fBSSL_CTX_load_verify_locations\fR(\s-1SSL_CTX\s0 *ctx, char *CAfile, char *CApath);" 4 .IX Item "int SSL_CTX_load_verify_locations(SSL_CTX *ctx, char *CAfile, char *CApath);" .IP "long \fBSSL_CTX_need_tmp_RSA\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "long SSL_CTX_need_tmp_RSA(SSL_CTX *ctx);" .IP "\s-1SSL_CTX\s0 *\fBSSL_CTX_new\fR(const \s-1SSL_METHOD\s0 *meth);" 4 .IX Item "SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth);" .IP "int \fBSSL_CTX_remove_session\fR(\s-1SSL_CTX\s0 *ctx, \s-1SSL_SESSION\s0 *c);" 4 .IX Item "int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c);" .IP "int \fBSSL_CTX_sess_accept\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_sess_accept(SSL_CTX *ctx);" .IP "int \fBSSL_CTX_sess_accept_good\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_sess_accept_good(SSL_CTX *ctx);" .IP "int \fBSSL_CTX_sess_accept_renegotiate\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_sess_accept_renegotiate(SSL_CTX *ctx);" .IP "int \fBSSL_CTX_sess_cache_full\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_sess_cache_full(SSL_CTX *ctx);" .IP "int \fBSSL_CTX_sess_cb_hits\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_sess_cb_hits(SSL_CTX *ctx);" .IP "int \fBSSL_CTX_sess_connect\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_sess_connect(SSL_CTX *ctx);" .IP "int \fBSSL_CTX_sess_connect_good\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_sess_connect_good(SSL_CTX *ctx);" .IP "int \fBSSL_CTX_sess_connect_renegotiate\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_sess_connect_renegotiate(SSL_CTX *ctx);" .IP "int \fBSSL_CTX_sess_get_cache_size\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_sess_get_cache_size(SSL_CTX *ctx);" .IP "\s-1SSL_SESSION\s0 *(*\fBSSL_CTX_sess_get_get_cb\fR(\s-1SSL_CTX\s0 *ctx))(\s-1SSL\s0 *ssl, unsigned char *data, int len, int *copy);" 4 .IX Item "SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(SSL *ssl, unsigned char *data, int len, int *copy);" .IP "int (*\fBSSL_CTX_sess_get_new_cb\fR(\s-1SSL_CTX\s0 *ctx)(\s-1SSL\s0 *ssl, \s-1SSL_SESSION\s0 *sess);" 4 .IX Item "int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx)(SSL *ssl, SSL_SESSION *sess);" .IP "void (*\fBSSL_CTX_sess_get_remove_cb\fR(\s-1SSL_CTX\s0 *ctx)(\s-1SSL_CTX\s0 *ctx, \s-1SSL_SESSION\s0 *sess);" 4 .IX Item "void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx)(SSL_CTX *ctx, SSL_SESSION *sess);" .IP "int \fBSSL_CTX_sess_hits\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_sess_hits(SSL_CTX *ctx);" .IP "int \fBSSL_CTX_sess_misses\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_sess_misses(SSL_CTX *ctx);" .IP "int \fBSSL_CTX_sess_number\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_sess_number(SSL_CTX *ctx);" .IP "void \fBSSL_CTX_sess_set_cache_size\fR(\s-1SSL_CTX\s0 *ctx,t);" 4 .IX Item "void SSL_CTX_sess_set_cache_size(SSL_CTX *ctx,t);" .IP "void \fBSSL_CTX_sess_set_get_cb\fR(\s-1SSL_CTX\s0 *ctx, \s-1SSL_SESSION\s0 *(*cb)(\s-1SSL\s0 *ssl, unsigned char *data, int len, int *copy));" 4 .IX Item "void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx, SSL_SESSION *(*cb)(SSL *ssl, unsigned char *data, int len, int *copy));" .IP "void \fBSSL_CTX_sess_set_new_cb\fR(\s-1SSL_CTX\s0 *ctx, int (*cb)(\s-1SSL\s0 *ssl, \s-1SSL_SESSION\s0 *sess));" 4 .IX Item "void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx, int (*cb)(SSL *ssl, SSL_SESSION *sess));" .IP "void \fBSSL_CTX_sess_set_remove_cb\fR(\s-1SSL_CTX\s0 *ctx, void (*cb)(\s-1SSL_CTX\s0 *ctx, \s-1SSL_SESSION\s0 *sess));" 4 .IX Item "void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx, void (*cb)(SSL_CTX *ctx, SSL_SESSION *sess));" .IP "int \fBSSL_CTX_sess_timeouts\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_sess_timeouts(SSL_CTX *ctx);" .IP "\s-1LHASH\s0 *\fBSSL_CTX_sessions\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "LHASH *SSL_CTX_sessions(SSL_CTX *ctx);" .IP "void \fBSSL_CTX_set_app_data\fR(\s-1SSL_CTX\s0 *ctx, void *arg);" 4 .IX Item "void SSL_CTX_set_app_data(SSL_CTX *ctx, void *arg);" .IP "void \fBSSL_CTX_set_cert_store\fR(\s-1SSL_CTX\s0 *ctx, X509_STORE *cs);" 4 .IX Item "void SSL_CTX_set_cert_store(SSL_CTX *ctx, X509_STORE *cs);" .IP "void \fBSSL_CTX_set_cert_verify_cb\fR(\s-1SSL_CTX\s0 *ctx, int (*cb)(), char *arg)" 4 .IX Item "void SSL_CTX_set_cert_verify_cb(SSL_CTX *ctx, int (*cb)(), char *arg)" .IP "int \fBSSL_CTX_set_cipher_list\fR(\s-1SSL_CTX\s0 *ctx, char *str);" 4 .IX Item "int SSL_CTX_set_cipher_list(SSL_CTX *ctx, char *str);" .IP "void \fBSSL_CTX_set_client_CA_list\fR(\s-1SSL_CTX\s0 *ctx, \s-1STACK\s0 *list);" 4 .IX Item "void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK *list);" .IP "void \fBSSL_CTX_set_client_cert_cb\fR(\s-1SSL_CTX\s0 *ctx, int (*cb)(\s-1SSL\s0 *ssl, X509 **x509, \s-1EVP_PKEY\s0 **pkey));" 4 .IX Item "void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, int (*cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey));" .IP "void \fBSSL_CTX_set_default_passwd_cb\fR(\s-1SSL_CTX\s0 *ctx, int (*cb);(void))" 4 .IX Item "void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, int (*cb);(void))" .IP "void \fBSSL_CTX_set_default_read_ahead\fR(\s-1SSL_CTX\s0 *ctx, int m);" 4 .IX Item "void SSL_CTX_set_default_read_ahead(SSL_CTX *ctx, int m);" .IP "int \fBSSL_CTX_set_default_verify_paths\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);" .IP "int \fBSSL_CTX_set_ex_data\fR(\s-1SSL_CTX\s0 *s, int idx, char *arg);" 4 .IX Item "int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, char *arg);" .IP "void \fBSSL_CTX_set_info_callback\fR(\s-1SSL_CTX\s0 *ctx, void (*cb)(\s-1SSL\s0 *ssl, int cb, int ret));" 4 .IX Item "void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*cb)(SSL *ssl, int cb, int ret));" .IP "void \fBSSL_CTX_set_msg_callback\fR(\s-1SSL_CTX\s0 *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, \s-1SSL\s0 *ssl, void *arg));" 4 .IX Item "void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));" .IP "void \fBSSL_CTX_set_msg_callback_arg\fR(\s-1SSL_CTX\s0 *ctx, void *arg);" 4 .IX Item "void SSL_CTX_set_msg_callback_arg(SSL_CTX *ctx, void *arg);" .IP "void \fBSSL_CTX_set_options\fR(\s-1SSL_CTX\s0 *ctx, unsigned long op);" 4 .IX Item "void SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);" .IP "void \fBSSL_CTX_set_quiet_shutdown\fR(\s-1SSL_CTX\s0 *ctx, int mode);" 4 .IX Item "void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode);" .IP "void \fBSSL_CTX_set_session_cache_mode\fR(\s-1SSL_CTX\s0 *ctx, int mode);" 4 .IX Item "void SSL_CTX_set_session_cache_mode(SSL_CTX *ctx, int mode);" .IP "int \fBSSL_CTX_set_ssl_version\fR(\s-1SSL_CTX\s0 *ctx, const \s-1SSL_METHOD\s0 *meth);" 4 .IX Item "int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth);" .IP "void \fBSSL_CTX_set_timeout\fR(\s-1SSL_CTX\s0 *ctx, long t);" 4 .IX Item "void SSL_CTX_set_timeout(SSL_CTX *ctx, long t);" .IP "long \fBSSL_CTX_set_tmp_dh\fR(SSL_CTX* ctx, \s-1DH\s0 *dh);" 4 .IX Item "long SSL_CTX_set_tmp_dh(SSL_CTX* ctx, DH *dh);" .IP "long \fBSSL_CTX_set_tmp_dh_callback\fR(\s-1SSL_CTX\s0 *ctx, \s-1DH\s0 *(*cb)(void));" 4 .IX Item "long SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, DH *(*cb)(void));" .IP "long \fBSSL_CTX_set_tmp_rsa\fR(\s-1SSL_CTX\s0 *ctx, \s-1RSA\s0 *rsa);" 4 .IX Item "long SSL_CTX_set_tmp_rsa(SSL_CTX *ctx, RSA *rsa);" .IP "SSL_CTX_set_tmp_rsa_callback" 4 .IX Item "SSL_CTX_set_tmp_rsa_callback" .PD \&\f(CW\*(C`long \f(CBSSL_CTX_set_tmp_rsa_callback\f(CW(SSL_CTX *\f(CBctx\f(CW, RSA *(*\f(CBcb\f(CW)(SSL *\f(CBssl\f(CW, int \f(CBexport\f(CW, int \f(CBkeylength\f(CW));\*(C'\fR .Sp Sets the callback which will be called when a temporary private key is required. The \fB\f(CB\*(C`export\*(C'\fB\fR flag will be set if the reason for needing a temp key is that an export ciphersuite is in use, in which case, \&\fB\f(CB\*(C`keylength\*(C'\fB\fR will contain the required keylength in bits. Generate a key of appropriate size (using ???) and return it. .IP "SSL_set_tmp_rsa_callback" 4 .IX Item "SSL_set_tmp_rsa_callback" long \fBSSL_set_tmp_rsa_callback\fR(\s-1SSL\s0 *ssl, \s-1RSA\s0 *(*cb)(\s-1SSL\s0 *ssl, int export, int keylength)); .Sp The same as \fBSSL_CTX_set_tmp_rsa_callback\fR, except it operates on an \s-1SSL\s0 session instead of a context. .IP "void \fBSSL_CTX_set_verify\fR(\s-1SSL_CTX\s0 *ctx, int mode, int (*cb);(void))" 4 .IX Item "void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, int (*cb);(void))" .PD 0 .IP "int \fBSSL_CTX_use_PrivateKey\fR(\s-1SSL_CTX\s0 *ctx, \s-1EVP_PKEY\s0 *pkey);" 4 .IX Item "int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey);" .IP "int \fBSSL_CTX_use_PrivateKey_ASN1\fR(int type, \s-1SSL_CTX\s0 *ctx, unsigned char *d, long len);" 4 .IX Item "int SSL_CTX_use_PrivateKey_ASN1(int type, SSL_CTX *ctx, unsigned char *d, long len);" .IP "int \fBSSL_CTX_use_PrivateKey_file\fR(\s-1SSL_CTX\s0 *ctx, char *file, int type);" 4 .IX Item "int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, char *file, int type);" .IP "int \fBSSL_CTX_use_RSAPrivateKey\fR(\s-1SSL_CTX\s0 *ctx, \s-1RSA\s0 *rsa);" 4 .IX Item "int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa);" .IP "int \fBSSL_CTX_use_RSAPrivateKey_ASN1\fR(\s-1SSL_CTX\s0 *ctx, unsigned char *d, long len);" 4 .IX Item "int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len);" .IP "int \fBSSL_CTX_use_RSAPrivateKey_file\fR(\s-1SSL_CTX\s0 *ctx, char *file, int type);" 4 .IX Item "int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, char *file, int type);" .IP "int \fBSSL_CTX_use_certificate\fR(\s-1SSL_CTX\s0 *ctx, X509 *x);" 4 .IX Item "int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x);" .IP "int \fBSSL_CTX_use_certificate_ASN1\fR(\s-1SSL_CTX\s0 *ctx, int len, unsigned char *d);" 4 .IX Item "int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, unsigned char *d);" .IP "int \fBSSL_CTX_use_certificate_file\fR(\s-1SSL_CTX\s0 *ctx, char *file, int type);" 4 .IX Item "int SSL_CTX_use_certificate_file(SSL_CTX *ctx, char *file, int type);" .IP "void \fBSSL_CTX_set_psk_client_callback\fR(\s-1SSL_CTX\s0 *ctx, unsigned int (*callback)(\s-1SSL\s0 *ssl, const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len));" 4 .IX Item "void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, unsigned int (*callback)(SSL *ssl, const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len));" .IP "int \fBSSL_CTX_use_psk_identity_hint\fR(\s-1SSL_CTX\s0 *ctx, const char *hint);" 4 .IX Item "int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *hint);" .IP "void \fBSSL_CTX_set_psk_server_callback\fR(\s-1SSL_CTX\s0 *ctx, unsigned int (*callback)(\s-1SSL\s0 *ssl, const char *identity, unsigned char *psk, int max_psk_len));" 4 .IX Item "void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, unsigned int (*callback)(SSL *ssl, const char *identity, unsigned char *psk, int max_psk_len));" .PD .SS "\s-1DEALING WITH SESSIONS\s0" .IX Subsection "DEALING WITH SESSIONS" Here we document the various \s-1API\s0 functions which deal with the \s-1SSL/TLS\s0 sessions defined in the \fB\s-1SSL_SESSION\s0\fR structures. .IP "int \fBSSL_SESSION_cmp\fR(const \s-1SSL_SESSION\s0 *a, const \s-1SSL_SESSION\s0 *b);" 4 .IX Item "int SSL_SESSION_cmp(const SSL_SESSION *a, const SSL_SESSION *b);" .PD 0 .IP "void \fBSSL_SESSION_free\fR(\s-1SSL_SESSION\s0 *ss);" 4 .IX Item "void SSL_SESSION_free(SSL_SESSION *ss);" .IP "char *\fBSSL_SESSION_get_app_data\fR(\s-1SSL_SESSION\s0 *s);" 4 .IX Item "char *SSL_SESSION_get_app_data(SSL_SESSION *s);" .IP "char *\fBSSL_SESSION_get_ex_data\fR(const \s-1SSL_SESSION\s0 *s, int idx);" 4 .IX Item "char *SSL_SESSION_get_ex_data(const SSL_SESSION *s, int idx);" .IP "int \fBSSL_SESSION_get_ex_new_index\fR(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))" 4 .IX Item "int SSL_SESSION_get_ex_new_index(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))" .IP "long \fBSSL_SESSION_get_time\fR(const \s-1SSL_SESSION\s0 *s);" 4 .IX Item "long SSL_SESSION_get_time(const SSL_SESSION *s);" .IP "long \fBSSL_SESSION_get_timeout\fR(const \s-1SSL_SESSION\s0 *s);" 4 .IX Item "long SSL_SESSION_get_timeout(const SSL_SESSION *s);" .IP "unsigned long \fBSSL_SESSION_hash\fR(const \s-1SSL_SESSION\s0 *a);" 4 .IX Item "unsigned long SSL_SESSION_hash(const SSL_SESSION *a);" .IP "\s-1SSL_SESSION\s0 *\fBSSL_SESSION_new\fR(void);" 4 .IX Item "SSL_SESSION *SSL_SESSION_new(void);" .IP "int \fBSSL_SESSION_print\fR(\s-1BIO\s0 *bp, const \s-1SSL_SESSION\s0 *x);" 4 .IX Item "int SSL_SESSION_print(BIO *bp, const SSL_SESSION *x);" .IP "int \fBSSL_SESSION_print_fp\fR(\s-1FILE\s0 *fp, const \s-1SSL_SESSION\s0 *x);" 4 .IX Item "int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *x);" .IP "void \fBSSL_SESSION_set_app_data\fR(\s-1SSL_SESSION\s0 *s, char *a);" 4 .IX Item "void SSL_SESSION_set_app_data(SSL_SESSION *s, char *a);" .IP "int \fBSSL_SESSION_set_ex_data\fR(\s-1SSL_SESSION\s0 *s, int idx, char *arg);" 4 .IX Item "int SSL_SESSION_set_ex_data(SSL_SESSION *s, int idx, char *arg);" .IP "long \fBSSL_SESSION_set_time\fR(\s-1SSL_SESSION\s0 *s, long t);" 4 .IX Item "long SSL_SESSION_set_time(SSL_SESSION *s, long t);" .IP "long \fBSSL_SESSION_set_timeout\fR(\s-1SSL_SESSION\s0 *s, long t);" 4 .IX Item "long SSL_SESSION_set_timeout(SSL_SESSION *s, long t);" .PD .SS "\s-1DEALING WITH CONNECTIONS\s0" .IX Subsection "DEALING WITH CONNECTIONS" Here we document the various \s-1API\s0 functions which deal with the \s-1SSL/TLS\s0 connection defined in the \fB\s-1SSL\s0\fR structure. .IP "int \fBSSL_accept\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_accept(SSL *ssl);" .PD 0 .IP "int \fBSSL_add_dir_cert_subjects_to_stack\fR(\s-1STACK\s0 *stack, const char *dir);" 4 .IX Item "int SSL_add_dir_cert_subjects_to_stack(STACK *stack, const char *dir);" .IP "int \fBSSL_add_file_cert_subjects_to_stack\fR(\s-1STACK\s0 *stack, const char *file);" 4 .IX Item "int SSL_add_file_cert_subjects_to_stack(STACK *stack, const char *file);" .IP "int \fBSSL_add_client_CA\fR(\s-1SSL\s0 *ssl, X509 *x);" 4 .IX Item "int SSL_add_client_CA(SSL *ssl, X509 *x);" .IP "char *\fBSSL_alert_desc_string\fR(int value);" 4 .IX Item "char *SSL_alert_desc_string(int value);" .IP "char *\fBSSL_alert_desc_string_long\fR(int value);" 4 .IX Item "char *SSL_alert_desc_string_long(int value);" .IP "char *\fBSSL_alert_type_string\fR(int value);" 4 .IX Item "char *SSL_alert_type_string(int value);" .IP "char *\fBSSL_alert_type_string_long\fR(int value);" 4 .IX Item "char *SSL_alert_type_string_long(int value);" .IP "int \fBSSL_check_private_key\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_check_private_key(const SSL *ssl);" .IP "void \fBSSL_clear\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "void SSL_clear(SSL *ssl);" .IP "long \fBSSL_clear_num_renegotiations\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "long SSL_clear_num_renegotiations(SSL *ssl);" .IP "int \fBSSL_connect\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_connect(SSL *ssl);" .IP "void \fBSSL_copy_session_id\fR(\s-1SSL\s0 *t, const \s-1SSL\s0 *f);" 4 .IX Item "void SSL_copy_session_id(SSL *t, const SSL *f);" .IP "long \fBSSL_ctrl\fR(\s-1SSL\s0 *ssl, int cmd, long larg, char *parg);" 4 .IX Item "long SSL_ctrl(SSL *ssl, int cmd, long larg, char *parg);" .IP "int \fBSSL_do_handshake\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_do_handshake(SSL *ssl);" .IP "\s-1SSL\s0 *\fBSSL_dup\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "SSL *SSL_dup(SSL *ssl);" .IP "\s-1STACK\s0 *\fBSSL_dup_CA_list\fR(\s-1STACK\s0 *sk);" 4 .IX Item "STACK *SSL_dup_CA_list(STACK *sk);" .IP "void \fBSSL_free\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "void SSL_free(SSL *ssl);" .IP "\s-1SSL_CTX\s0 *\fBSSL_get_SSL_CTX\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl);" .IP "char *\fBSSL_get_app_data\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "char *SSL_get_app_data(SSL *ssl);" .IP "X509 *\fBSSL_get_certificate\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "X509 *SSL_get_certificate(const SSL *ssl);" .IP "const char *\fBSSL_get_cipher\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "const char *SSL_get_cipher(const SSL *ssl);" .IP "int \fBSSL_get_cipher_bits\fR(const \s-1SSL\s0 *ssl, int *alg_bits);" 4 .IX Item "int SSL_get_cipher_bits(const SSL *ssl, int *alg_bits);" .IP "char *\fBSSL_get_cipher_list\fR(const \s-1SSL\s0 *ssl, int n);" 4 .IX Item "char *SSL_get_cipher_list(const SSL *ssl, int n);" .IP "char *\fBSSL_get_cipher_name\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "char *SSL_get_cipher_name(const SSL *ssl);" .IP "char *\fBSSL_get_cipher_version\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "char *SSL_get_cipher_version(const SSL *ssl);" .IP "\s-1STACK\s0 *\fBSSL_get_ciphers\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "STACK *SSL_get_ciphers(const SSL *ssl);" .IP "\s-1STACK\s0 *\fBSSL_get_client_CA_list\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "STACK *SSL_get_client_CA_list(const SSL *ssl);" .IP "\s-1SSL_CIPHER\s0 *\fBSSL_get_current_cipher\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "SSL_CIPHER *SSL_get_current_cipher(SSL *ssl);" .IP "long \fBSSL_get_default_timeout\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "long SSL_get_default_timeout(const SSL *ssl);" .IP "int \fBSSL_get_error\fR(const \s-1SSL\s0 *ssl, int i);" 4 .IX Item "int SSL_get_error(const SSL *ssl, int i);" .IP "char *\fBSSL_get_ex_data\fR(const \s-1SSL\s0 *ssl, int idx);" 4 .IX Item "char *SSL_get_ex_data(const SSL *ssl, int idx);" .IP "int \fBSSL_get_ex_data_X509_STORE_CTX_idx\fR(void);" 4 .IX Item "int SSL_get_ex_data_X509_STORE_CTX_idx(void);" .IP "int \fBSSL_get_ex_new_index\fR(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))" 4 .IX Item "int SSL_get_ex_new_index(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))" .IP "int \fBSSL_get_fd\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_get_fd(const SSL *ssl);" .IP "void (*\fBSSL_get_info_callback\fR(const \s-1SSL\s0 *ssl);)()" 4 .IX Item "void (*SSL_get_info_callback(const SSL *ssl);)()" .IP "\s-1STACK\s0 *\fBSSL_get_peer_cert_chain\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "STACK *SSL_get_peer_cert_chain(const SSL *ssl);" .IP "X509 *\fBSSL_get_peer_certificate\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "X509 *SSL_get_peer_certificate(const SSL *ssl);" .IP "\s-1EVP_PKEY\s0 *\fBSSL_get_privatekey\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "EVP_PKEY *SSL_get_privatekey(SSL *ssl);" .IP "int \fBSSL_get_quiet_shutdown\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_get_quiet_shutdown(const SSL *ssl);" .IP "\s-1BIO\s0 *\fBSSL_get_rbio\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "BIO *SSL_get_rbio(const SSL *ssl);" .IP "int \fBSSL_get_read_ahead\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_get_read_ahead(const SSL *ssl);" .IP "\s-1SSL_SESSION\s0 *\fBSSL_get_session\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "SSL_SESSION *SSL_get_session(const SSL *ssl);" .IP "char *\fBSSL_get_shared_ciphers\fR(const \s-1SSL\s0 *ssl, char *buf, int len);" 4 .IX Item "char *SSL_get_shared_ciphers(const SSL *ssl, char *buf, int len);" .IP "int \fBSSL_get_shutdown\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_get_shutdown(const SSL *ssl);" .IP "const \s-1SSL_METHOD\s0 *\fBSSL_get_ssl_method\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "const SSL_METHOD *SSL_get_ssl_method(SSL *ssl);" .IP "int \fBSSL_get_state\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_get_state(const SSL *ssl);" .IP "long \fBSSL_get_time\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "long SSL_get_time(const SSL *ssl);" .IP "long \fBSSL_get_timeout\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "long SSL_get_timeout(const SSL *ssl);" .IP "int (*\fBSSL_get_verify_callback\fR(const \s-1SSL\s0 *ssl))(int,X509_STORE_CTX *)" 4 .IX Item "int (*SSL_get_verify_callback(const SSL *ssl))(int,X509_STORE_CTX *)" .IP "int \fBSSL_get_verify_mode\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_get_verify_mode(const SSL *ssl);" .IP "long \fBSSL_get_verify_result\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "long SSL_get_verify_result(const SSL *ssl);" .IP "char *\fBSSL_get_version\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "char *SSL_get_version(const SSL *ssl);" .IP "\s-1BIO\s0 *\fBSSL_get_wbio\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "BIO *SSL_get_wbio(const SSL *ssl);" .IP "int \fBSSL_in_accept_init\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_in_accept_init(SSL *ssl);" .IP "int \fBSSL_in_before\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_in_before(SSL *ssl);" .IP "int \fBSSL_in_connect_init\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_in_connect_init(SSL *ssl);" .IP "int \fBSSL_in_init\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_in_init(SSL *ssl);" .IP "int \fBSSL_is_init_finished\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_is_init_finished(SSL *ssl);" .IP "\s-1STACK\s0 *\fBSSL_load_client_CA_file\fR(char *file);" 4 .IX Item "STACK *SSL_load_client_CA_file(char *file);" .IP "void \fBSSL_load_error_strings\fR(void);" 4 .IX Item "void SSL_load_error_strings(void);" .IP "\s-1SSL\s0 *\fBSSL_new\fR(\s-1SSL_CTX\s0 *ctx);" 4 .IX Item "SSL *SSL_new(SSL_CTX *ctx);" .IP "long \fBSSL_num_renegotiations\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "long SSL_num_renegotiations(SSL *ssl);" .IP "int \fBSSL_peek\fR(\s-1SSL\s0 *ssl, void *buf, int num);" 4 .IX Item "int SSL_peek(SSL *ssl, void *buf, int num);" .IP "int \fBSSL_pending\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_pending(const SSL *ssl);" .IP "int \fBSSL_read\fR(\s-1SSL\s0 *ssl, void *buf, int num);" 4 .IX Item "int SSL_read(SSL *ssl, void *buf, int num);" .IP "int \fBSSL_renegotiate\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_renegotiate(SSL *ssl);" .IP "char *\fBSSL_rstate_string\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "char *SSL_rstate_string(SSL *ssl);" .IP "char *\fBSSL_rstate_string_long\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "char *SSL_rstate_string_long(SSL *ssl);" .IP "long \fBSSL_session_reused\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "long SSL_session_reused(SSL *ssl);" .IP "void \fBSSL_set_accept_state\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "void SSL_set_accept_state(SSL *ssl);" .IP "void \fBSSL_set_app_data\fR(\s-1SSL\s0 *ssl, char *arg);" 4 .IX Item "void SSL_set_app_data(SSL *ssl, char *arg);" .IP "void \fBSSL_set_bio\fR(\s-1SSL\s0 *ssl, \s-1BIO\s0 *rbio, \s-1BIO\s0 *wbio);" 4 .IX Item "void SSL_set_bio(SSL *ssl, BIO *rbio, BIO *wbio);" .IP "int \fBSSL_set_cipher_list\fR(\s-1SSL\s0 *ssl, char *str);" 4 .IX Item "int SSL_set_cipher_list(SSL *ssl, char *str);" .IP "void \fBSSL_set_client_CA_list\fR(\s-1SSL\s0 *ssl, \s-1STACK\s0 *list);" 4 .IX Item "void SSL_set_client_CA_list(SSL *ssl, STACK *list);" .IP "void \fBSSL_set_connect_state\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "void SSL_set_connect_state(SSL *ssl);" .IP "int \fBSSL_set_ex_data\fR(\s-1SSL\s0 *ssl, int idx, char *arg);" 4 .IX Item "int SSL_set_ex_data(SSL *ssl, int idx, char *arg);" .IP "int \fBSSL_set_fd\fR(\s-1SSL\s0 *ssl, int fd);" 4 .IX Item "int SSL_set_fd(SSL *ssl, int fd);" .IP "void \fBSSL_set_info_callback\fR(\s-1SSL\s0 *ssl, void (*cb);(void))" 4 .IX Item "void SSL_set_info_callback(SSL *ssl, void (*cb);(void))" .IP "void \fBSSL_set_msg_callback\fR(\s-1SSL\s0 *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, \s-1SSL\s0 *ssl, void *arg));" 4 .IX Item "void SSL_set_msg_callback(SSL *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));" .IP "void \fBSSL_set_msg_callback_arg\fR(\s-1SSL\s0 *ctx, void *arg);" 4 .IX Item "void SSL_set_msg_callback_arg(SSL *ctx, void *arg);" .IP "void \fBSSL_set_options\fR(\s-1SSL\s0 *ssl, unsigned long op);" 4 .IX Item "void SSL_set_options(SSL *ssl, unsigned long op);" .IP "void \fBSSL_set_quiet_shutdown\fR(\s-1SSL\s0 *ssl, int mode);" 4 .IX Item "void SSL_set_quiet_shutdown(SSL *ssl, int mode);" .IP "void \fBSSL_set_read_ahead\fR(\s-1SSL\s0 *ssl, int yes);" 4 .IX Item "void SSL_set_read_ahead(SSL *ssl, int yes);" .IP "int \fBSSL_set_rfd\fR(\s-1SSL\s0 *ssl, int fd);" 4 .IX Item "int SSL_set_rfd(SSL *ssl, int fd);" .IP "int \fBSSL_set_session\fR(\s-1SSL\s0 *ssl, \s-1SSL_SESSION\s0 *session);" 4 .IX Item "int SSL_set_session(SSL *ssl, SSL_SESSION *session);" .IP "void \fBSSL_set_shutdown\fR(\s-1SSL\s0 *ssl, int mode);" 4 .IX Item "void SSL_set_shutdown(SSL *ssl, int mode);" .IP "int \fBSSL_set_ssl_method\fR(\s-1SSL\s0 *ssl, const \s-1SSL_METHOD\s0 *meth);" 4 .IX Item "int SSL_set_ssl_method(SSL *ssl, const SSL_METHOD *meth);" .IP "void \fBSSL_set_time\fR(\s-1SSL\s0 *ssl, long t);" 4 .IX Item "void SSL_set_time(SSL *ssl, long t);" .IP "void \fBSSL_set_timeout\fR(\s-1SSL\s0 *ssl, long t);" 4 .IX Item "void SSL_set_timeout(SSL *ssl, long t);" .IP "void \fBSSL_set_verify\fR(\s-1SSL\s0 *ssl, int mode, int (*callback);(void))" 4 .IX Item "void SSL_set_verify(SSL *ssl, int mode, int (*callback);(void))" .IP "void \fBSSL_set_verify_result\fR(\s-1SSL\s0 *ssl, long arg);" 4 .IX Item "void SSL_set_verify_result(SSL *ssl, long arg);" .IP "int \fBSSL_set_wfd\fR(\s-1SSL\s0 *ssl, int fd);" 4 .IX Item "int SSL_set_wfd(SSL *ssl, int fd);" .IP "int \fBSSL_shutdown\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_shutdown(SSL *ssl);" .IP "int \fBSSL_state\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_state(const SSL *ssl);" .IP "char *\fBSSL_state_string\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "char *SSL_state_string(const SSL *ssl);" .IP "char *\fBSSL_state_string_long\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "char *SSL_state_string_long(const SSL *ssl);" .IP "long \fBSSL_total_renegotiations\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "long SSL_total_renegotiations(SSL *ssl);" .IP "int \fBSSL_use_PrivateKey\fR(\s-1SSL\s0 *ssl, \s-1EVP_PKEY\s0 *pkey);" 4 .IX Item "int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey);" .IP "int \fBSSL_use_PrivateKey_ASN1\fR(int type, \s-1SSL\s0 *ssl, unsigned char *d, long len);" 4 .IX Item "int SSL_use_PrivateKey_ASN1(int type, SSL *ssl, unsigned char *d, long len);" .IP "int \fBSSL_use_PrivateKey_file\fR(\s-1SSL\s0 *ssl, char *file, int type);" 4 .IX Item "int SSL_use_PrivateKey_file(SSL *ssl, char *file, int type);" .IP "int \fBSSL_use_RSAPrivateKey\fR(\s-1SSL\s0 *ssl, \s-1RSA\s0 *rsa);" 4 .IX Item "int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa);" .IP "int \fBSSL_use_RSAPrivateKey_ASN1\fR(\s-1SSL\s0 *ssl, unsigned char *d, long len);" 4 .IX Item "int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len);" .IP "int \fBSSL_use_RSAPrivateKey_file\fR(\s-1SSL\s0 *ssl, char *file, int type);" 4 .IX Item "int SSL_use_RSAPrivateKey_file(SSL *ssl, char *file, int type);" .IP "int \fBSSL_use_certificate\fR(\s-1SSL\s0 *ssl, X509 *x);" 4 .IX Item "int SSL_use_certificate(SSL *ssl, X509 *x);" .IP "int \fBSSL_use_certificate_ASN1\fR(\s-1SSL\s0 *ssl, int len, unsigned char *d);" 4 .IX Item "int SSL_use_certificate_ASN1(SSL *ssl, int len, unsigned char *d);" .IP "int \fBSSL_use_certificate_file\fR(\s-1SSL\s0 *ssl, char *file, int type);" 4 .IX Item "int SSL_use_certificate_file(SSL *ssl, char *file, int type);" .IP "int \fBSSL_version\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_version(const SSL *ssl);" .IP "int \fBSSL_want\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_want(const SSL *ssl);" .IP "int \fBSSL_want_nothing\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_want_nothing(const SSL *ssl);" .IP "int \fBSSL_want_read\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_want_read(const SSL *ssl);" .IP "int \fBSSL_want_write\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_want_write(const SSL *ssl);" .IP "int \fBSSL_want_x509_lookup\fR(const \s-1SSL\s0 *ssl);" 4 .IX Item "int SSL_want_x509_lookup(const SSL *ssl);" .IP "int \fBSSL_write\fR(\s-1SSL\s0 *ssl, const void *buf, int num);" 4 .IX Item "int SSL_write(SSL *ssl, const void *buf, int num);" .IP "void \fBSSL_set_psk_client_callback\fR(\s-1SSL\s0 *ssl, unsigned int (*callback)(\s-1SSL\s0 *ssl, const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len));" 4 .IX Item "void SSL_set_psk_client_callback(SSL *ssl, unsigned int (*callback)(SSL *ssl, const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len));" .IP "int \fBSSL_use_psk_identity_hint\fR(\s-1SSL\s0 *ssl, const char *hint);" 4 .IX Item "int SSL_use_psk_identity_hint(SSL *ssl, const char *hint);" .IP "void \fBSSL_set_psk_server_callback\fR(\s-1SSL\s0 *ssl, unsigned int (*callback)(\s-1SSL\s0 *ssl, const char *identity, unsigned char *psk, int max_psk_len));" 4 .IX Item "void SSL_set_psk_server_callback(SSL *ssl, unsigned int (*callback)(SSL *ssl, const char *identity, unsigned char *psk, int max_psk_len));" .IP "const char *\fBSSL_get_psk_identity_hint\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "const char *SSL_get_psk_identity_hint(SSL *ssl);" .IP "const char *\fBSSL_get_psk_identity\fR(\s-1SSL\s0 *ssl);" 4 .IX Item "const char *SSL_get_psk_identity(SSL *ssl);" .PD .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIopenssl\fR\|(1), \fIcrypto\fR\|(3), \&\fISSL_accept\fR\|(3), \fISSL_clear\fR\|(3), \&\fISSL_connect\fR\|(3), \&\fISSL_CIPHER_get_name\fR\|(3), \&\fISSL_COMP_add_compression_method\fR\|(3), \&\fISSL_CTX_add_extra_chain_cert\fR\|(3), \&\fISSL_CTX_add_session\fR\|(3), \&\fISSL_CTX_ctrl\fR\|(3), \&\fISSL_CTX_flush_sessions\fR\|(3), \&\fISSL_CTX_get_ex_new_index\fR\|(3), \&\fISSL_CTX_get_verify_mode\fR\|(3), \&\fISSL_CTX_load_verify_locations\fR\|(3) \&\fISSL_CTX_new\fR\|(3), \&\fISSL_CTX_sess_number\fR\|(3), \&\fISSL_CTX_sess_set_cache_size\fR\|(3), \&\fISSL_CTX_sess_set_get_cb\fR\|(3), \&\fISSL_CTX_sessions\fR\|(3), \&\fISSL_CTX_set_cert_store\fR\|(3), \&\fISSL_CTX_set_cert_verify_callback\fR\|(3), \&\fISSL_CTX_set_cipher_list\fR\|(3), \&\fISSL_CTX_set_client_CA_list\fR\|(3), \&\fISSL_CTX_set_client_cert_cb\fR\|(3), \&\fISSL_CTX_set_default_passwd_cb\fR\|(3), \&\fISSL_CTX_set_generate_session_id\fR\|(3), \&\fISSL_CTX_set_info_callback\fR\|(3), \&\fISSL_CTX_set_max_cert_list\fR\|(3), \&\fISSL_CTX_set_mode\fR\|(3), \&\fISSL_CTX_set_msg_callback\fR\|(3), \&\fISSL_CTX_set_options\fR\|(3), \&\fISSL_CTX_set_quiet_shutdown\fR\|(3), \&\fISSL_CTX_set_session_cache_mode\fR\|(3), \&\fISSL_CTX_set_session_id_context\fR\|(3), \&\fISSL_CTX_set_ssl_version\fR\|(3), \&\fISSL_CTX_set_timeout\fR\|(3), \&\fISSL_CTX_set_tmp_rsa_callback\fR\|(3), \&\fISSL_CTX_set_tmp_dh_callback\fR\|(3), \&\fISSL_CTX_set_verify\fR\|(3), \&\fISSL_CTX_use_certificate\fR\|(3), \&\fISSL_alert_type_string\fR\|(3), \&\fISSL_do_handshake\fR\|(3), \&\fISSL_get_SSL_CTX\fR\|(3), \&\fISSL_get_ciphers\fR\|(3), \&\fISSL_get_client_CA_list\fR\|(3), \&\fISSL_get_default_timeout\fR\|(3), \&\fISSL_get_error\fR\|(3), \&\fISSL_get_ex_data_X509_STORE_CTX_idx\fR\|(3), \&\fISSL_get_ex_new_index\fR\|(3), \&\fISSL_get_fd\fR\|(3), \&\fISSL_get_peer_cert_chain\fR\|(3), \&\fISSL_get_rbio\fR\|(3), \&\fISSL_get_session\fR\|(3), \&\fISSL_get_verify_result\fR\|(3), \&\fISSL_get_version\fR\|(3), \&\fISSL_library_init\fR\|(3), \&\fISSL_load_client_CA_file\fR\|(3), \&\fISSL_new\fR\|(3), \&\fISSL_pending\fR\|(3), \&\fISSL_read\fR\|(3), \&\fISSL_rstate_string\fR\|(3), \&\fISSL_session_reused\fR\|(3), \&\fISSL_set_bio\fR\|(3), \&\fISSL_set_connect_state\fR\|(3), \&\fISSL_set_fd\fR\|(3), \&\fISSL_set_session\fR\|(3), \&\fISSL_set_shutdown\fR\|(3), \&\fISSL_shutdown\fR\|(3), \&\fISSL_state_string\fR\|(3), \&\fISSL_want\fR\|(3), \&\fISSL_write\fR\|(3), \&\fISSL_SESSION_free\fR\|(3), \&\fISSL_SESSION_get_ex_new_index\fR\|(3), \&\fISSL_SESSION_get_time\fR\|(3), \&\fId2i_SSL_SESSION\fR\|(3), \&\fISSL_CTX_set_psk_client_callback\fR\|(3), \&\fISSL_CTX_use_psk_identity_hint\fR\|(3), \&\fISSL_get_psk_identity\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" The \fIssl\fR\|(3) document appeared in OpenSSL 0.9.2 deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_OpenInit.30000644000175000017500000001405512360020720020033 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_OpenInit 3" .TH EVP_OpenInit 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_OpenInit, EVP_OpenUpdate, EVP_OpenFinal \- EVP envelope decryption .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_OpenInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type,unsigned char *ek, \& int ekl,unsigned char *iv,EVP_PKEY *priv); \& int EVP_OpenUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, \& int *outl, unsigned char *in, int inl); \& int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, \& int *outl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \s-1EVP\s0 envelope routines are a high level interface to envelope decryption. They decrypt a public key encrypted symmetric key and then decrypt data using it. .PP \&\fIEVP_OpenInit()\fR initializes a cipher context \fBctx\fR for decryption with cipher \fBtype\fR. It decrypts the encrypted symmetric key of length \&\fBekl\fR bytes passed in the \fBek\fR parameter using the private key \fBpriv\fR. The \s-1IV\s0 is supplied in the \fBiv\fR parameter. .PP \&\fIEVP_OpenUpdate()\fR and \fIEVP_OpenFinal()\fR have exactly the same properties as the \fIEVP_DecryptUpdate()\fR and \fIEVP_DecryptFinal()\fR routines, as documented on the \fIEVP_EncryptInit\fR\|(3) manual page. .SH "NOTES" .IX Header "NOTES" It is possible to call \fIEVP_OpenInit()\fR twice in the same way as \&\fIEVP_DecryptInit()\fR. The first call should have \fBpriv\fR set to \s-1NULL\s0 and (after setting any cipher parameters) it should be called again with \fBtype\fR set to \s-1NULL.\s0 .PP If the cipher passed in the \fBtype\fR parameter is a variable length cipher then the key length will be set to the value of the recovered key length. If the cipher is a fixed length cipher then the recovered key length must match the fixed cipher length. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_OpenInit()\fR returns 0 on error or a non zero integer (actually the recovered secret key size) if successful. .PP \&\fIEVP_OpenUpdate()\fR returns 1 for success or 0 for failure. .PP \&\fIEVP_OpenFinal()\fR returns 0 if the decrypt failed or 1 for success. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIevp\fR\|(3), \fIrand\fR\|(3), \&\fIEVP_EncryptInit\fR\|(3), \&\fIEVP_SealInit\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_psk_client_callback.30000644000175000017500000001353012360020733023656 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_psk_client_callback 3" .TH SSL_CTX_set_psk_client_callback 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_psk_client_callback, SSL_set_psk_client_callback \- set PSK client callback .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, \& unsigned int (*callback)(SSL *ssl, const char *hint, \& char *identity, unsigned int max_identity_len, \& unsigned char *psk, unsigned int max_psk_len)); \& void SSL_set_psk_client_callback(SSL *ssl, \& unsigned int (*callback)(SSL *ssl, const char *hint, \& char *identity, unsigned int max_identity_len, \& unsigned char *psk, unsigned int max_psk_len)); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" A client application must provide a callback function which is called when the client is sending the ClientKeyExchange message to the server. .PP The purpose of the callback function is to select the \s-1PSK\s0 identity and the pre-shared key to use during the connection setup phase. .PP The callback is set using functions \fISSL_CTX_set_psk_client_callback()\fR or \fISSL_set_psk_client_callback()\fR. The callback function is given the connection in parameter \fBssl\fR, a \fB\s-1NULL\s0\fR\-terminated \s-1PSK\s0 identity hint sent by the server in parameter \fBhint\fR, a buffer \fBidentity\fR of length \fBmax_identity_len\fR bytes where the the resulting \&\fB\s-1NULL\s0\fR\-terminated identity is to be stored, and a buffer \fBpsk\fR of length \fBmax_psk_len\fR bytes where the resulting pre-shared key is to be stored. .SH "NOTES" .IX Header "NOTES" Note that parameter \fBhint\fR given to the callback may be \fB\s-1NULL\s0\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" Return values from the client callback are interpreted as follows: .PP On success (callback found a \s-1PSK\s0 identity and a pre-shared key to use) the length (> 0) of \fBpsk\fR in bytes is returned. .PP Otherwise or on errors callback should return 0. In this case the connection setup fails. deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_f_cipher.30000644000175000017500000001523712360020707020054 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_f_cipher 3" .TH BIO_f_cipher 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_f_cipher, BIO_set_cipher, BIO_get_cipher_status, BIO_get_cipher_ctx \- cipher BIO filter .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& BIO_METHOD * BIO_f_cipher(void); \& void BIO_set_cipher(BIO *b,const EVP_CIPHER *cipher, \& unsigned char *key, unsigned char *iv, int enc); \& int BIO_get_cipher_status(BIO *b) \& int BIO_get_cipher_ctx(BIO *b, EVP_CIPHER_CTX **pctx) .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_f_cipher()\fR returns the cipher \s-1BIO\s0 method. This is a filter \&\s-1BIO\s0 that encrypts any data written through it, and decrypts any data read from it. It is a \s-1BIO\s0 wrapper for the cipher routines \&\fIEVP_CipherInit()\fR, \fIEVP_CipherUpdate()\fR and \fIEVP_CipherFinal()\fR. .PP Cipher BIOs do not support \fIBIO_gets()\fR or \fIBIO_puts()\fR. .PP \&\fIBIO_flush()\fR on an encryption \s-1BIO\s0 that is being written through is used to signal that no more data is to be encrypted: this is used to flush and possibly pad the final block through the \s-1BIO.\s0 .PP \&\fIBIO_set_cipher()\fR sets the cipher of \s-1BIO \s0\fBb\fR to \fBcipher\fR using key \fBkey\fR and \s-1IV \s0\fBiv\fR. \fBenc\fR should be set to 1 for encryption and zero for decryption. .PP When reading from an encryption \s-1BIO\s0 the final block is automatically decrypted and checked when \s-1EOF\s0 is detected. \fIBIO_get_cipher_status()\fR is a \fIBIO_ctrl()\fR macro which can be called to determine whether the decryption operation was successful. .PP \&\fIBIO_get_cipher_ctx()\fR is a \fIBIO_ctrl()\fR macro which retrieves the internal \&\s-1BIO\s0 cipher context. The retrieved context can be used in conjunction with the standard cipher routines to set it up. This is useful when \&\fIBIO_set_cipher()\fR is not flexible enough for the applications needs. .SH "NOTES" .IX Header "NOTES" When encrypting \fIBIO_flush()\fR \fBmust\fR be called to flush the final block through the \s-1BIO.\s0 If it is not then the final block will fail a subsequent decrypt. .PP When decrypting an error on the final block is signalled by a zero return value from the read operation. A successful decrypt followed by \s-1EOF\s0 will also return zero for the final read. \fIBIO_get_cipher_status()\fR should be called to determine if the decrypt was successful. .PP As always, if \fIBIO_gets()\fR or \fIBIO_puts()\fR support is needed then it can be achieved by preceding the cipher \s-1BIO\s0 with a buffering \s-1BIO.\s0 .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBIO_f_cipher()\fR returns the cipher \s-1BIO\s0 method. .PP \&\fIBIO_set_cipher()\fR does not return a value. .PP \&\fIBIO_get_cipher_status()\fR returns 1 for a successful decrypt and 0 for failure. .PP \&\fIBIO_get_cipher_ctx()\fR currently always returns 1. deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_mod_mul_montgomery.30000644000175000017500000001700612360020712022067 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_mod_mul_montgomery 3" .TH BN_mod_mul_montgomery 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_mod_mul_montgomery, BN_MONT_CTX_new, BN_MONT_CTX_init, BN_MONT_CTX_free, BN_MONT_CTX_set, BN_MONT_CTX_copy, BN_from_montgomery, BN_to_montgomery \- Montgomery multiplication .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BN_MONT_CTX *BN_MONT_CTX_new(void); \& void BN_MONT_CTX_init(BN_MONT_CTX *ctx); \& void BN_MONT_CTX_free(BN_MONT_CTX *mont); \& \& int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *m, BN_CTX *ctx); \& BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from); \& \& int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b, \& BN_MONT_CTX *mont, BN_CTX *ctx); \& \& int BN_from_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont, \& BN_CTX *ctx); \& \& int BN_to_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont, \& BN_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions implement Montgomery multiplication. They are used automatically when \fIBN_mod_exp\fR\|(3) is called with suitable input, but they may be useful when several operations are to be performed using the same modulus. .PP \&\fIBN_MONT_CTX_new()\fR allocates and initializes a \fB\s-1BN_MONT_CTX\s0\fR structure. \&\fIBN_MONT_CTX_init()\fR initializes an existing uninitialized \fB\s-1BN_MONT_CTX\s0\fR. .PP \&\fIBN_MONT_CTX_set()\fR sets up the \fImont\fR structure from the modulus \fIm\fR by precomputing its inverse and a value R. .PP \&\fIBN_MONT_CTX_copy()\fR copies the \fB\s-1BN_MONT_CTX\s0\fR \fIfrom\fR to \fIto\fR. .PP \&\fIBN_MONT_CTX_free()\fR frees the components of the \fB\s-1BN_MONT_CTX\s0\fR, and, if it was created by \fIBN_MONT_CTX_new()\fR, also the structure itself. .PP \&\fIBN_mod_mul_montgomery()\fR computes Mont(\fIa\fR,\fIb\fR):=\fIa\fR*\fIb\fR*R^\-1 and places the result in \fIr\fR. .PP \&\fIBN_from_montgomery()\fR performs the Montgomery reduction \fIr\fR = \fIa\fR*R^\-1. .PP \&\fIBN_to_montgomery()\fR computes Mont(\fIa\fR,R^2), i.e. \fIa\fR*R. Note that \fIa\fR must be non-negative and smaller than the modulus. .PP For all functions, \fIctx\fR is a previously allocated \fB\s-1BN_CTX\s0\fR used for temporary variables. .PP The \fB\s-1BN_MONT_CTX\s0\fR structure is defined as follows: .PP .Vb 10 \& typedef struct bn_mont_ctx_st \& { \& int ri; /* number of bits in R */ \& BIGNUM RR; /* R^2 (used to convert to Montgomery form) */ \& BIGNUM N; /* The modulus */ \& BIGNUM Ni; /* R*(1/R mod N) \- N*Ni = 1 \& * (Ni is only stored for bignum algorithm) */ \& BN_ULONG n0; /* least significant word of Ni */ \& int flags; \& } BN_MONT_CTX; .Ve .PP \&\fIBN_to_montgomery()\fR is a macro. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBN_MONT_CTX_new()\fR returns the newly allocated \fB\s-1BN_MONT_CTX\s0\fR, and \s-1NULL\s0 on error. .PP \&\fIBN_MONT_CTX_init()\fR and \fIBN_MONT_CTX_free()\fR have no return values. .PP For the other functions, 1 is returned for success, 0 on error. The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "WARNING" .IX Header "WARNING" The inputs must be reduced modulo \fBm\fR, otherwise the result will be outside the expected range. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3), \fIERR_get_error\fR\|(3), \fIBN_add\fR\|(3), \&\fIBN_CTX_new\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIBN_MONT_CTX_new()\fR, \fIBN_MONT_CTX_free()\fR, \fIBN_MONT_CTX_set()\fR, \&\fIBN_mod_mul_montgomery()\fR, \fIBN_from_montgomery()\fR and \fIBN_to_montgomery()\fR are available in all versions of SSLeay and OpenSSL. .PP \&\fIBN_MONT_CTX_init()\fR and \fIBN_MONT_CTX_copy()\fR were added in SSLeay 0.9.1b. deps/libressl-pnacl-sys-2.1.6/libressl/man/RSA_check_key.30000644000175000017500000001470612360020723020234 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RSA_check_key 3" .TH RSA_check_key 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RSA_check_key \- validate private RSA keys .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int RSA_check_key(RSA *rsa); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This function validates \s-1RSA\s0 keys. It checks that \fBp\fR and \fBq\fR are in fact prime, and that \fBn = p*q\fR. .PP It also checks that \fBd*e = 1 mod (p\-1*q\-1)\fR, and that \fBdmp1\fR, \fBdmq1\fR and \fBiqmp\fR are set correctly or are \fB\s-1NULL\s0\fR. .PP As such, this function can not be used with any arbitrary \s-1RSA\s0 key object, even if it is otherwise fit for regular \s-1RSA\s0 operation. See \fB\s-1NOTES\s0\fR for more information. .SH "RETURN VALUE" .IX Header "RETURN VALUE" \&\fIRSA_check_key()\fR returns 1 if \fBrsa\fR is a valid \s-1RSA\s0 key, and 0 otherwise. \&\-1 is returned if an error occurs while checking the key. .PP If the key is invalid or an error occurred, the reason code can be obtained using \fIERR_get_error\fR\|(3). .SH "NOTES" .IX Header "NOTES" This function does not work on \s-1RSA\s0 public keys that have only the modulus and public exponent elements populated. It performs integrity checks on all the \s-1RSA\s0 key material, so the \s-1RSA\s0 key structure must contain all the private key data too. .PP Unlike most other \s-1RSA\s0 functions, this function does \fBnot\fR work transparently with any underlying \s-1ENGINE\s0 implementation because it uses the key data in the \s-1RSA\s0 structure directly. An \s-1ENGINE\s0 implementation can override the way key data is stored and handled, and can even provide support for \s-1HSM\s0 keys \- in which case the \s-1RSA\s0 structure may contain \fBno\fR key data at all! If the \s-1ENGINE\s0 in question is only being used for acceleration or analysis purposes, then in all likelihood the \s-1RSA\s0 key data is complete and untouched, but this can't be assumed in the general case. .SH "BUGS" .IX Header "BUGS" A method of verifying the \s-1RSA\s0 key using opaque \s-1RSA API\s0 functions might need to be considered. Right now \fIRSA_check_key()\fR simply uses the \s-1RSA\s0 structure elements directly, bypassing the \s-1RSA_METHOD\s0 table altogether (and completely violating encapsulation and object-orientation in the process). The best fix will probably be to introduce a \*(L"\fIcheck_key()\fR\*(R" handler to the \&\s-1RSA_METHOD\s0 function table so that alternative implementations can also provide their own verifiers. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIrsa\fR\|(3), \fIERR_get_error\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIRSA_check_key()\fR appeared in OpenSSL 0.9.4. deps/libressl-pnacl-sys-2.1.6/libressl/man/lhash.30000644000175000017500000004454612360020730016704 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "lhash 3" .TH lhash 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" lh_new, lh_free, lh_insert, lh_delete, lh_retrieve, lh_doall, lh_doall_arg, lh_error \- dynamic hash table .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& DECLARE_LHASH_OF(); \& \& LHASH *lh__new(); \& void lh__free(LHASH_OF( *table); \& \& *lh__insert(LHASH_OF( *table, *data); \& *lh__delete(LHASH_OF( *table, *data); \& *lh_retrieve(LHASH_OF *table, *data); \& \& void lh__doall(LHASH_OF( *table, LHASH_DOALL_FN_TYPE func); \& void lh__doall_arg(LHASH_OF( *table, LHASH_DOALL_ARG_FN_TYPE func, \& , *arg); \& \& int lh__error(LHASH_OF( *table); \& \& typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *); \& typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *); \& typedef void (*LHASH_DOALL_FN_TYPE)(const void *); \& typedef void (*LHASH_DOALL_ARG_FN_TYPE)(const void *, const void *); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This library implements type-checked dynamic hash tables. The hash table entries can be arbitrary structures. Usually they consist of key and value fields. .PP lh_\fI_new()\fR creates a new \fB\s-1LHASH_OF\s0( structure to store arbitrary data entries, and provides the 'hash' and 'compare' callbacks to be used in organising the table's entries. The \fBhash\fR callback takes a pointer to a table entry as its argument and returns an unsigned long hash value for its key field. The hash value is normally truncated to a power of 2, so make sure that your hash function returns well mixed low order bits. The \fBcompare\fR callback takes two arguments (pointers to two hash table entries), and returns 0 if their keys are equal, non-zero otherwise. If your hash table will contain items of some particular type and the \fBhash\fR and \&\fBcompare\fR callbacks hash/compare these types, then the \&\fB\s-1DECLARE_LHASH_HASH_FN\s0\fR and \fB\s-1IMPLEMENT_LHASH_COMP_FN\s0\fR macros can be used to create callback wrappers of the prototypes required by lh_\fI_new()\fR. These provide per-variable casts before calling the type-specific callbacks written by the application author. These macros, as well as those used for the \*(L"doall\*(R" callbacks, are defined as; .PP .Vb 7 \& #define DECLARE_LHASH_HASH_FN(name, o_type) \e \& unsigned long name##_LHASH_HASH(const void *); \& #define IMPLEMENT_LHASH_HASH_FN(name, o_type) \e \& unsigned long name##_LHASH_HASH(const void *arg) { \e \& const o_type *a = arg; \e \& return name##_hash(a); } \& #define LHASH_HASH_FN(name) name##_LHASH_HASH \& \& #define DECLARE_LHASH_COMP_FN(name, o_type) \e \& int name##_LHASH_COMP(const void *, const void *); \& #define IMPLEMENT_LHASH_COMP_FN(name, o_type) \e \& int name##_LHASH_COMP(const void *arg1, const void *arg2) { \e \& const o_type *a = arg1; \e \& const o_type *b = arg2; \e \& return name##_cmp(a,b); } \& #define LHASH_COMP_FN(name) name##_LHASH_COMP \& \& #define DECLARE_LHASH_DOALL_FN(name, o_type) \e \& void name##_LHASH_DOALL(void *); \& #define IMPLEMENT_LHASH_DOALL_FN(name, o_type) \e \& void name##_LHASH_DOALL(void *arg) { \e \& o_type *a = arg; \e \& name##_doall(a); } \& #define LHASH_DOALL_FN(name) name##_LHASH_DOALL \& \& #define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \e \& void name##_LHASH_DOALL_ARG(void *, void *); \& #define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \e \& void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \e \& o_type *a = arg1; \e \& a_type *b = arg2; \e \& name##_doall_arg(a, b); } \& #define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG \& \& An example of a hash table storing (pointers to) structures of type \*(AqSTUFF\*(Aq \& could be defined as follows; \& \& /* Calculates the hash value of \*(Aqtohash\*(Aq (implemented elsewhere) */ \& unsigned long STUFF_hash(const STUFF *tohash); \& /* Orders \*(Aqarg1\*(Aq and \*(Aqarg2\*(Aq (implemented elsewhere) */ \& int stuff_cmp(const STUFF *arg1, const STUFF *arg2); \& /* Create the type\-safe wrapper functions for use in the LHASH internals */ \& static IMPLEMENT_LHASH_HASH_FN(stuff, STUFF); \& static IMPLEMENT_LHASH_COMP_FN(stuff, STUFF); \& /* ... */ \& int main(int argc, char *argv[]) { \& /* Create the new hash table using the hash/compare wrappers */ \& LHASH_OF(STUFF) *hashtable = lh_STUFF_new(LHASH_HASH_FN(STUFF_hash), \& LHASH_COMP_FN(STUFF_cmp)); \& /* ... */ \& } .Ve .PP lh_\fI_free()\fR frees the \fB\s-1LHASH_OF\s0( structure \&\fBtable\fR. Allocated hash table entries will not be freed; consider using lh_\fI_doall()\fR to deallocate any remaining entries in the hash table (see below). .PP lh_\fI_insert()\fR inserts the structure pointed to by \fBdata\fR into \&\fBtable\fR. If there already is an entry with the same key, the old value is replaced. Note that lh_\fI_insert()\fR stores pointers, the data are not copied. .PP lh_\fI_delete()\fR deletes an entry from \fBtable\fR. .PP lh_\fI_retrieve()\fR looks up an entry in \fBtable\fR. Normally, \fBdata\fR is a structure with the key field(s) set; the function will return a pointer to a fully populated structure. .PP lh_\fI_doall()\fR will, for every entry in the hash table, call \&\fBfunc\fR with the data item as its parameter. For lh_\fI_doall()\fR and lh_\fI_doall_arg()\fR, function pointer casting should be avoided in the callbacks (see \fB\s-1NOTE\s0\fR) \- instead use the declare/implement macros to create type-checked wrappers that cast variables prior to calling your type-specific callbacks. An example of this is illustrated here where the callback is used to cleanup resources for items in the hash table prior to the hashtable itself being deallocated: .PP .Vb 9 \& /* Cleans up resources belonging to \*(Aqa\*(Aq (this is implemented elsewhere) */ \& void STUFF_cleanup_doall(STUFF *a); \& /* Implement a prototype\-compatible wrapper for "STUFF_cleanup" */ \& IMPLEMENT_LHASH_DOALL_FN(STUFF_cleanup, STUFF) \& /* ... then later in the code ... */ \& /* So to run "STUFF_cleanup" against all items in a hash table ... */ \& lh_STUFF_doall(hashtable, LHASH_DOALL_FN(STUFF_cleanup)); \& /* Then the hash table itself can be deallocated */ \& lh_STUFF_free(hashtable); .Ve .PP When doing this, be careful if you delete entries from the hash table in your callbacks: the table may decrease in size, moving the item that you are currently on down lower in the hash table \- this could cause some entries to be skipped during the iteration. The second best solution to this problem is to set hash\->down_load=0 before you start (which will stop the hash table ever decreasing in size). The best solution is probably to avoid deleting items from the hash table inside a \*(L"doall\*(R" callback! .PP lh_\fI_doall_arg()\fR is the same as lh_\fI_doall()\fR except that \&\fBfunc\fR will be called with \fBarg\fR as the second argument and \fBfunc\fR should be of type \fB\s-1LHASH_DOALL_ARG_FN_TYPE\s0\fR (a callback prototype that is passed both the table entry and an extra argument). As with \&\fIlh_doall()\fR, you can instead choose to declare your callback with a prototype matching the types you are dealing with and use the declare/implement macros to create compatible wrappers that cast variables before calling your type-specific callbacks. An example of this is demonstrated here (printing all hash table entries to a \s-1BIO\s0 that is provided by the caller): .PP .Vb 8 \& /* Prints item \*(Aqa\*(Aq to \*(Aqoutput_bio\*(Aq (this is implemented elsewhere) */ \& void STUFF_print_doall_arg(const STUFF *a, BIO *output_bio); \& /* Implement a prototype\-compatible wrapper for "STUFF_print" */ \& static IMPLEMENT_LHASH_DOALL_ARG_FN(STUFF, const STUFF, BIO) \& /* ... then later in the code ... */ \& /* Print out the entire hashtable to a particular BIO */ \& lh_STUFF_doall_arg(hashtable, LHASH_DOALL_ARG_FN(STUFF_print), BIO, \& logging_bio); .Ve .PP lh_\fI_error()\fR can be used to determine if an error occurred in the last operation. lh_\fI_error()\fR is a macro. .SH "RETURN VALUES" .IX Header "RETURN VALUES" lh_\fI_new()\fR returns \fB\s-1NULL\s0\fR on error, otherwise a pointer to the new \&\fB\s-1LHASH\s0\fR structure. .PP When a hash table entry is replaced, lh_\fI_insert()\fR returns the value being replaced. \fB\s-1NULL\s0\fR is returned on normal operation and on error. .PP lh_\fI_delete()\fR returns the entry being deleted. \fB\s-1NULL\s0\fR is returned if there is no such value in the hash table. .PP lh_\fI_retrieve()\fR returns the hash table entry if it has been found, \&\fB\s-1NULL\s0\fR otherwise. .PP lh_\fI_error()\fR returns 1 if an error occurred in the last operation, 0 otherwise. .PP lh_\fI_free()\fR, lh_\fI_doall()\fR and lh_\fI_doall_arg()\fR return no values. .SH "NOTE" .IX Header "NOTE" The various \s-1LHASH\s0 macros and callback types exist to make it possible to write type-checked code without resorting to function-prototype casting \- an evil that makes application code much harder to audit/verify and also opens the window of opportunity for stack corruption and other hard-to-find bugs. It also, apparently, violates ANSI-C. .PP The \s-1LHASH\s0 code regards table entries as constant data. As such, it internally represents \fIlh_insert()\fR'd items with a \*(L"const void *\*(R" pointer type. This is why callbacks such as those used by \fIlh_doall()\fR and \fIlh_doall_arg()\fR declare their prototypes with \*(L"const\*(R", even for the parameters that pass back the table items' data pointers \- for consistency, user-provided data is \*(L"const\*(R" at all times as far as the \&\s-1LHASH\s0 code is concerned. However, as callers are themselves providing these pointers, they can choose whether they too should be treating all such parameters as constant. .PP As an example, a hash table may be maintained by code that, for reasons of encapsulation, has only \*(L"const\*(R" access to the data being indexed in the hash table (ie. it is returned as \*(L"const\*(R" from elsewhere in their code) \- in this case the \s-1LHASH\s0 prototypes are appropriate as-is. Conversely, if the caller is responsible for the life-time of the data in question, then they may well wish to make modifications to table item passed back in the \fIlh_doall()\fR or \&\fIlh_doall_arg()\fR callbacks (see the \*(L"STUFF_cleanup\*(R" example above). If so, the caller can either cast the \*(L"const\*(R" away (if they're providing the raw callbacks themselves) or use the macros to declare/implement the wrapper functions without \*(L"const\*(R" types. .PP Callers that only have \*(L"const\*(R" access to data they're indexing in a table, yet declare callbacks without constant types (or cast the \&\*(L"const\*(R" away themselves), are therefore creating their own risks/bugs without being encouraged to do so by the \s-1API. \s0 On a related note, those auditing code should pay special attention to any instances of DECLARE/IMPLEMENT_LHASH_DOALL_[\s-1ARG_\s0]_FN macros that provide types without any \*(L"const\*(R" qualifiers. .SH "BUGS" .IX Header "BUGS" lh_\fI_insert()\fR returns \fB\s-1NULL\s0\fR both for success and error. .SH "INTERNALS" .IX Header "INTERNALS" The following description is based on the SSLeay documentation: .PP The \fBlhash\fR library implements a hash table described in the \&\fICommunications of the \s-1ACM\s0\fR in 1991. What makes this hash table different is that as the table fills, the hash table is increased (or decreased) in size via \fIOPENSSL_realloc()\fR. When a 'resize' is done, instead of all hashes being redistributed over twice as many 'buckets', one bucket is split. So when an 'expand' is done, there is only a minimal cost to redistribute some values. Subsequent inserts will cause more single 'bucket' redistributions but there will never be a sudden large cost due to redistributing all the 'buckets'. .PP The state for a particular hash table is kept in the \fB\s-1LHASH\s0\fR structure. The decision to increase or decrease the hash table size is made depending on the 'load' of the hash table. The load is the number of items in the hash table divided by the size of the hash table. The default values are as follows. If (hash\->up_load < load) => expand. if (hash\->down_load > load) => contract. The \&\fBup_load\fR has a default value of 1 and \fBdown_load\fR has a default value of 2. These numbers can be modified by the application by just playing with the \fBup_load\fR and \fBdown_load\fR variables. The 'load' is kept in a form which is multiplied by 256. So hash\->up_load=8*256; will cause a load of 8 to be set. .PP If you are interested in performance the field to watch is num_comp_calls. The hash library keeps track of the 'hash' value for each item so when a lookup is done, the 'hashes' are compared, if there is a match, then a full compare is done, and hash\->num_comp_calls is incremented. If num_comp_calls is not equal to num_delete plus num_retrieve it means that your hash function is generating hashes that are the same for different values. It is probably worth changing your hash function if this is the case because even if your hash table has 10 items in a 'bucket', it can be searched with 10 \fBunsigned long\fR compares and 10 linked list traverses. This will be much less expensive that 10 calls to your compare function. .PP \&\fIlh_strhash()\fR is a demo string hashing function: .PP .Vb 1 \& unsigned long lh_strhash(const char *c); .Ve .PP Since the \fB\s-1LHASH\s0\fR routines would normally be passed structures, this routine would not normally be passed to lh_\fI_new()\fR, rather it would be used in the function passed to lh_\fI_new()\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIlh_stats\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" The \fBlhash\fR library is available in all versions of SSLeay and OpenSSL. \&\fIlh_error()\fR was added in SSLeay 0.9.1b. .PP This manpage is derived from the SSLeay documentation. .PP In OpenSSL 0.9.7, all lhash functions that were passed function pointers were changed for better type safety, and the function types \s-1LHASH_COMP_FN_TYPE, LHASH_HASH_FN_TYPE, LHASH_DOALL_FN_TYPE\s0 and \s-1LHASH_DOALL_ARG_FN_TYPE\s0 became available. .PP In OpenSSL 1.0.0, the lhash interface was revamped for even better type checking. deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_add.30000644000175000017500000002156412360020711016706 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_add 3" .TH BN_add 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_add, BN_sub, BN_mul, BN_sqr, BN_div, BN_mod, BN_nnmod, BN_mod_add, BN_mod_sub, BN_mod_mul, BN_mod_sqr, BN_exp, BN_mod_exp, BN_gcd \- arithmetic operations on BIGNUMs .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); \& \& int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); \& \& int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); \& \& int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx); \& \& int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d, \& BN_CTX *ctx); \& \& int BN_mod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); \& \& int BN_nnmod(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); \& \& int BN_mod_add(BIGNUM *r, BIGNUM *a, BIGNUM *b, const BIGNUM *m, \& BN_CTX *ctx); \& \& int BN_mod_sub(BIGNUM *r, BIGNUM *a, BIGNUM *b, const BIGNUM *m, \& BN_CTX *ctx); \& \& int BN_mod_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, const BIGNUM *m, \& BN_CTX *ctx); \& \& int BN_mod_sqr(BIGNUM *r, BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); \& \& int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx); \& \& int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, \& const BIGNUM *m, BN_CTX *ctx); \& \& int BN_gcd(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBN_add()\fR adds \fIa\fR and \fIb\fR and places the result in \fIr\fR (\f(CW\*(C`r=a+b\*(C'\fR). \&\fIr\fR may be the same \fB\s-1BIGNUM\s0\fR as \fIa\fR or \fIb\fR. .PP \&\fIBN_sub()\fR subtracts \fIb\fR from \fIa\fR and places the result in \fIr\fR (\f(CW\*(C`r=a\-b\*(C'\fR). .PP \&\fIBN_mul()\fR multiplies \fIa\fR and \fIb\fR and places the result in \fIr\fR (\f(CW\*(C`r=a*b\*(C'\fR). \&\fIr\fR may be the same \fB\s-1BIGNUM\s0\fR as \fIa\fR or \fIb\fR. For multiplication by powers of 2, use \fIBN_lshift\fR\|(3). .PP \&\fIBN_sqr()\fR takes the square of \fIa\fR and places the result in \fIr\fR (\f(CW\*(C`r=a^2\*(C'\fR). \fIr\fR and \fIa\fR may be the same \fB\s-1BIGNUM\s0\fR. This function is faster than BN_mul(r,a,a). .PP \&\fIBN_div()\fR divides \fIa\fR by \fId\fR and places the result in \fIdv\fR and the remainder in \fIrem\fR (\f(CW\*(C`dv=a/d, rem=a%d\*(C'\fR). Either of \fIdv\fR and \fIrem\fR may be \fB\s-1NULL\s0\fR, in which case the respective value is not returned. The result is rounded towards zero; thus if \fIa\fR is negative, the remainder will be zero or negative. For division by powers of 2, use \fIBN_rshift\fR\|(3). .PP \&\fIBN_mod()\fR corresponds to \fIBN_div()\fR with \fIdv\fR set to \fB\s-1NULL\s0\fR. .PP \&\fIBN_nnmod()\fR reduces \fIa\fR modulo \fIm\fR and places the non-negative remainder in \fIr\fR. .PP \&\fIBN_mod_add()\fR adds \fIa\fR to \fIb\fR modulo \fIm\fR and places the non-negative result in \fIr\fR. .PP \&\fIBN_mod_sub()\fR subtracts \fIb\fR from \fIa\fR modulo \fIm\fR and places the non-negative result in \fIr\fR. .PP \&\fIBN_mod_mul()\fR multiplies \fIa\fR by \fIb\fR and finds the non-negative remainder respective to modulus \fIm\fR (\f(CW\*(C`r=(a*b) mod m\*(C'\fR). \fIr\fR may be the same \fB\s-1BIGNUM\s0\fR as \fIa\fR or \fIb\fR. For more efficient algorithms for repeated computations using the same modulus, see \&\fIBN_mod_mul_montgomery\fR\|(3) and \&\fIBN_mod_mul_reciprocal\fR\|(3). .PP \&\fIBN_mod_sqr()\fR takes the square of \fIa\fR modulo \fBm\fR and places the result in \fIr\fR. .PP \&\fIBN_exp()\fR raises \fIa\fR to the \fIp\fR\-th power and places the result in \fIr\fR (\f(CW\*(C`r=a^p\*(C'\fR). This function is faster than repeated applications of \&\fIBN_mul()\fR. .PP \&\fIBN_mod_exp()\fR computes \fIa\fR to the \fIp\fR\-th power modulo \fIm\fR (\f(CW\*(C`r=a^p % m\*(C'\fR). This function uses less time and space than \fIBN_exp()\fR. .PP \&\fIBN_gcd()\fR computes the greatest common divisor of \fIa\fR and \fIb\fR and places the result in \fIr\fR. \fIr\fR may be the same \fB\s-1BIGNUM\s0\fR as \fIa\fR or \&\fIb\fR. .PP For all functions, \fIctx\fR is a previously allocated \fB\s-1BN_CTX\s0\fR used for temporary variables; see \fIBN_CTX_new\fR\|(3). .PP Unless noted otherwise, the result \fB\s-1BIGNUM\s0\fR must be different from the arguments. .SH "RETURN VALUES" .IX Header "RETURN VALUES" For all functions, 1 is returned for success, 0 on error. The return value should always be checked (e.g., \f(CW\*(C`if (!BN_add(r,a,b)) goto err;\*(C'\fR). The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3), \fIERR_get_error\fR\|(3), \&\fIBN_CTX_new\fR\|(3), \fIBN_add_word\fR\|(3), \&\fIBN_set_bit\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIBN_add()\fR, \fIBN_sub()\fR, \fIBN_sqr()\fR, \fIBN_div()\fR, \fIBN_mod()\fR, \fIBN_mod_mul()\fR, \&\fIBN_mod_exp()\fR and \fIBN_gcd()\fR are available in all versions of SSLeay and OpenSSL. The \fIctx\fR argument to \fIBN_mul()\fR was added in SSLeay 0.9.1b. \fIBN_exp()\fR appeared in SSLeay 0.9.0. \&\fIBN_nnmod()\fR, \fIBN_mod_add()\fR, \fIBN_mod_sub()\fR, and \fIBN_mod_sqr()\fR were added in OpenSSL 0.9.7. deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_PKEY_decrypt.30000644000175000017500000001550112360020720020605 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_PKEY_decrypt 3" .TH EVP_PKEY_decrypt 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_PKEY_decrypt_init, EVP_PKEY_decrypt \- decrypt using a public key algorithm .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx); \& int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx, \& unsigned char *out, size_t *outlen, \& const unsigned char *in, size_t inlen); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fIEVP_PKEY_decrypt_init()\fR function initializes a public key algorithm context using key \fBpkey\fR for a decryption operation. .PP The \fIEVP_PKEY_decrypt()\fR function performs a public key decryption operation using \fBctx\fR. The data to be decrypted is specified using the \fBin\fR and \&\fBinlen\fR parameters. If \fBout\fR is \fB\s-1NULL\s0\fR then the maximum size of the output buffer is written to the \fBoutlen\fR parameter. If \fBout\fR is not \fB\s-1NULL\s0\fR then before the call the \fBoutlen\fR parameter should contain the length of the \&\fBout\fR buffer, if the call is successful the decrypted data is written to \&\fBout\fR and the amount of data written to \fBoutlen\fR. .SH "NOTES" .IX Header "NOTES" After the call to \fIEVP_PKEY_decrypt_init()\fR algorithm specific control operations can be performed to set any appropriate parameters for the operation. .PP The function \fIEVP_PKEY_decrypt()\fR can be called more than once on the same context if several operations are performed using the same parameters. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_PKEY_decrypt_init()\fR and \fIEVP_PKEY_decrypt()\fR return 1 for success and 0 or a negative value for failure. In particular a return value of \-2 indicates the operation is not supported by the public key algorithm. .SH "EXAMPLE" .IX Header "EXAMPLE" Decrypt data using \s-1OAEP \s0(for \s-1RSA\s0 keys): .PP .Vb 2 \& #include \& #include \& \& EVP_PKEY_CTX *ctx; \& unsigned char *out, *in; \& size_t outlen, inlen; \& EVP_PKEY *key; \& /* NB: assumes key in, inlen are already set up \& * and that key is an RSA private key \& */ \& ctx = EVP_PKEY_CTX_new(key); \& if (!ctx) \& /* Error occurred */ \& if (EVP_PKEY_decrypt_init(ctx) <= 0) \& /* Error */ \& if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_OAEP_PADDING) <= 0) \& /* Error */ \& \& /* Determine buffer length */ \& if (EVP_PKEY_decrypt(ctx, NULL, &outlen, in, inlen) <= 0) \& /* Error */ \& \& out = OPENSSL_malloc(outlen); \& \& if (!out) \& /* malloc failure */ \& \& if (EVP_PKEY_decrypt(ctx, out, &outlen, in, inlen) <= 0) \& /* Error */ \& \& /* Decrypted data is outlen bytes written to buffer out */ .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_PKEY_CTX_new\fR\|(3), \&\fIEVP_PKEY_encrypt\fR\|(3), \&\fIEVP_PKEY_sign\fR\|(3), \&\fIEVP_PKEY_verify\fR\|(3), \&\fIEVP_PKEY_verify_recover\fR\|(3), \&\fIEVP_PKEY_derive\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" These functions were first added to OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_default_passwd_cb.30000644000175000017500000001563212360020732023364 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_default_passwd_cb 3" .TH SSL_CTX_set_default_passwd_cb 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_default_passwd_cb, SSL_CTX_set_default_passwd_cb_userdata \- set passwd callback for encrypted PEM file handling .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb); \& void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u); \& \& int pem_passwd_cb(char *buf, int size, int rwflag, void *userdata); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_default_passwd_cb()\fR sets the default password callback called when loading/storing a \s-1PEM\s0 certificate with encryption. .PP \&\fISSL_CTX_set_default_passwd_cb_userdata()\fR sets a pointer to \fBuserdata\fR which will be provided to the password callback on invocation. .PP The \fIpem_passwd_cb()\fR, which must be provided by the application, hands back the password to be used during decryption. On invocation a pointer to \fBuserdata\fR is provided. The pem_passwd_cb must write the password into the provided buffer \&\fBbuf\fR which is of size \fBsize\fR. The actual length of the password must be returned to the calling function. \fBrwflag\fR indicates whether the callback is used for reading/decryption (rwflag=0) or writing/encryption (rwflag=1). .SH "NOTES" .IX Header "NOTES" When loading or storing private keys, a password might be supplied to protect the private key. The way this password can be supplied may depend on the application. If only one private key is handled, it can be practical to have \fIpem_passwd_cb()\fR handle the password dialog interactively. If several keys have to be handled, it can be practical to ask for the password once, then keep it in memory and use it several times. In the last case, the password could be stored into the \fBuserdata\fR storage and the \&\fIpem_passwd_cb()\fR only returns the password already stored. .PP When asking for the password interactively, \fIpem_passwd_cb()\fR can use \&\fBrwflag\fR to check, whether an item shall be encrypted (rwflag=1). In this case the password dialog may ask for the same password twice for comparison in order to catch typos, that would make decryption impossible. .PP Other items in \s-1PEM\s0 formatting (certificates) can also be encrypted, it is however not usual, as certificate information is considered public. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_set_default_passwd_cb()\fR and \fISSL_CTX_set_default_passwd_cb_userdata()\fR do not provide diagnostic information. .SH "EXAMPLES" .IX Header "EXAMPLES" The following example returns the password provided as \fBuserdata\fR to the calling function. The password is considered to be a '\e0' terminated string. If the password does not fit into the buffer, the password is truncated. .PP .Vb 6 \& int pem_passwd_cb(char *buf, int size, int rwflag, void *password) \& { \& strncpy(buf, (char *)(password), size); \& buf[size \- 1] = \*(Aq\e0\*(Aq; \& return(strlen(buf)); \& } .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \&\fISSL_CTX_use_certificate\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_PKEY_new.30000644000175000017500000001177112360020720017731 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_PKEY_new 3" .TH EVP_PKEY_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_PKEY_new, EVP_PKEY_free \- private key allocation functions. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& EVP_PKEY *EVP_PKEY_new(void); \& void EVP_PKEY_free(EVP_PKEY *key); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fIEVP_PKEY_new()\fR function allocates an empty \fB\s-1EVP_PKEY\s0\fR structure which is used by OpenSSL to store private keys. .PP \&\fIEVP_PKEY_free()\fR frees up the private key \fBkey\fR. .SH "NOTES" .IX Header "NOTES" The \fB\s-1EVP_PKEY\s0\fR structure is used by various OpenSSL functions which require a general private key without reference to any particular algorithm. .PP The structure returned by \fIEVP_PKEY_new()\fR is empty. To add a private key to this empty structure the functions described in \&\fIEVP_PKEY_set1_RSA\fR\|(3) should be used. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_PKEY_new()\fR returns either the newly allocated \fB\s-1EVP_PKEY\s0\fR structure of \fB\s-1NULL\s0\fR if an error occurred. .PP \&\fIEVP_PKEY_free()\fR does not return a value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_PKEY_set1_RSA\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_new.30000644000175000017500000001410112360020710017045 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_new 3" .TH BIO_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_new, BIO_set, BIO_free, BIO_vfree, BIO_free_all \- BIO allocation and freeing functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIO * BIO_new(BIO_METHOD *type); \& int BIO_set(BIO *a,BIO_METHOD *type); \& int BIO_free(BIO *a); \& void BIO_vfree(BIO *a); \& void BIO_free_all(BIO *a); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fIBIO_new()\fR function returns a new \s-1BIO\s0 using method \fBtype\fR. .PP \&\fIBIO_set()\fR sets the method of an already existing \s-1BIO.\s0 .PP \&\fIBIO_free()\fR frees up a single \s-1BIO,\s0 \fIBIO_vfree()\fR also frees up a single \s-1BIO\s0 but it does not return a value. Calling \fIBIO_free()\fR may also have some effect on the underlying I/O structure, for example it may close the file being referred to under certain circumstances. For more details see the individual \&\s-1BIO_METHOD\s0 descriptions. .PP \&\fIBIO_free_all()\fR frees up an entire \s-1BIO\s0 chain, it does not halt if an error occurs freeing up an individual \s-1BIO\s0 in the chain. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBIO_new()\fR returns a newly created \s-1BIO\s0 or \s-1NULL\s0 if the call fails. .PP \&\fIBIO_set()\fR, \fIBIO_free()\fR return 1 for success and 0 for failure. .PP \&\fIBIO_free_all()\fR and \fIBIO_vfree()\fR do not return values. .SH "NOTES" .IX Header "NOTES" Some BIOs (such as memory BIOs) can be used immediately after calling \&\fIBIO_new()\fR. Others (such as file BIOs) need some additional initialization, and frequently a utility function exists to create and initialize such BIOs. .PP If \fIBIO_free()\fR is called on a \s-1BIO\s0 chain it will only free one \s-1BIO\s0 resulting in a memory leak. .PP Calling \fIBIO_free_all()\fR a single \s-1BIO\s0 has the same effect as calling \fIBIO_free()\fR on it other than the discarded return value. .PP Normally the \fBtype\fR argument is supplied by a function which returns a pointer to a \s-1BIO_METHOD.\s0 There is a naming convention for such functions: a source/sink \s-1BIO\s0 is normally called BIO_s_*() and a filter \s-1BIO\s0 BIO_f_*(); .SH "EXAMPLE" .IX Header "EXAMPLE" Create a memory \s-1BIO:\s0 .PP .Vb 1 \& BIO *mem = BIO_new(BIO_s_mem()); .Ve deps/libressl-pnacl-sys-2.1.6/libressl/man/ASN1_OBJECT_new.30000644000175000017500000001237312360020707020203 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ASN1_OBJECT_new 3" .TH ASN1_OBJECT_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ASN1_OBJECT_new, ASN1_OBJECT_free, \- object allocation functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& ASN1_OBJECT *ASN1_OBJECT_new(void); \& void ASN1_OBJECT_free(ASN1_OBJECT *a); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \s-1ASN1_OBJECT\s0 allocation routines, allocate and free an \&\s-1ASN1_OBJECT\s0 structure, which represents an \s-1ASN1 OBJECT IDENTIFIER.\s0 .PP \&\fIASN1_OBJECT_new()\fR allocates and initializes a \s-1ASN1_OBJECT\s0 structure. .PP \&\fIASN1_OBJECT_free()\fR frees up the \fB\s-1ASN1_OBJECT\s0\fR structure \fBa\fR. .SH "NOTES" .IX Header "NOTES" Although \fIASN1_OBJECT_new()\fR allocates a new \s-1ASN1_OBJECT\s0 structure it is almost never used in applications. The \s-1ASN1\s0 object utility functions such as \fIOBJ_nid2obj()\fR are used instead. .SH "RETURN VALUES" .IX Header "RETURN VALUES" If the allocation fails, \fIASN1_OBJECT_new()\fR returns \fB\s-1NULL\s0\fR and sets an error code that can be obtained by \fIERR_get_error\fR\|(3). Otherwise it returns a pointer to the newly allocated structure. .PP \&\fIASN1_OBJECT_free()\fR returns no value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fId2i_ASN1_OBJECT\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIASN1_OBJECT_new()\fR and \fIASN1_OBJECT_free()\fR are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/CMS_uncompress.30000644000175000017500000001306512360020714020477 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CMS_uncompress 3" .TH CMS_uncompress 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CMS_uncompress \- uncompress a CMS CompressedData structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out, unsigned int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fICMS_uncompress()\fR extracts and uncompresses the content from a \s-1CMS\s0 CompressedData structure \fBcms\fR. \fBdata\fR is a \s-1BIO\s0 to write the content to and \&\fBflags\fR is an optional set of flags. .PP The \fBdcont\fR parameter is used in the rare case where the compressed content is detached. It will normally be set to \s-1NULL.\s0 .SH "NOTES" .IX Header "NOTES" The only currently supported compression algorithm is zlib: if the structure indicates the use of any other algorithm an error is returned. .PP If zlib support is not compiled into OpenSSL then \fICMS_uncompress()\fR will always return an error. .PP The following flags can be passed in the \fBflags\fR parameter. .PP If the \fB\s-1CMS_TEXT\s0\fR flag is set \s-1MIME\s0 headers for type \fBtext/plain\fR are deleted from the content. If the content is not of type \fBtext/plain\fR then an error is returned. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICMS_uncompress()\fR returns either 1 for success or 0 for failure. The error can be obtained from \fIERR_get_error\fR\|(3) .SH "BUGS" .IX Header "BUGS" The lack of single pass processing and the need to hold all data in memory as mentioned in \fICMS_verify()\fR also applies to \fICMS_decompress()\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_compress\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fICMS_uncompress()\fR was added to OpenSSL 0.9.8 deps/libressl-pnacl-sys-2.1.6/libressl/man/DSA_do_sign.30000644000175000017500000001241012360020715017702 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DSA_do_sign 3" .TH DSA_do_sign 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DSA_do_sign, DSA_do_verify \- raw DSA signature operations .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); \& \& int DSA_do_verify(const unsigned char *dgst, int dgst_len, \& DSA_SIG *sig, DSA *dsa); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIDSA_do_sign()\fR computes a digital signature on the \fBlen\fR byte message digest \fBdgst\fR using the private key \fBdsa\fR and returns it in a newly allocated \fB\s-1DSA_SIG\s0\fR structure. .PP \&\fIDSA_sign_setup\fR\|(3) may be used to precompute part of the signing operation in case signature generation is time-critical. .PP \&\fIDSA_do_verify()\fR verifies that the signature \fBsig\fR matches a given message digest \fBdgst\fR of size \fBlen\fR. \fBdsa\fR is the signer's public key. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIDSA_do_sign()\fR returns the signature, \s-1NULL\s0 on error. \fIDSA_do_verify()\fR returns 1 for a valid signature, 0 for an incorrect signature and \-1 on error. The error codes can be obtained by \&\fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdsa\fR\|(3), \fIERR_get_error\fR\|(3), \fIrand\fR\|(3), \&\fIDSA_SIG_new\fR\|(3), \&\fIDSA_sign\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIDSA_do_sign()\fR and \fIDSA_do_verify()\fR were added in OpenSSL 0.9.3. deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_PKEY_verify.30000644000175000017500000001562012360020721020442 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_PKEY_verify 3" .TH EVP_PKEY_verify 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_PKEY_verify_init, EVP_PKEY_verify \- signature verification using a public key algorithm .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx); \& int EVP_PKEY_verify(EVP_PKEY_CTX *ctx, \& const unsigned char *sig, size_t siglen, \& const unsigned char *tbs, size_t tbslen); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fIEVP_PKEY_verify_init()\fR function initializes a public key algorithm context using key \fBpkey\fR for a signature verification operation. .PP The \fIEVP_PKEY_verify()\fR function performs a public key verification operation using \fBctx\fR. The signature is specified using the \fBsig\fR and \&\fBsiglen\fR parameters. The verified data (i.e. the data believed originally signed) is specified using the \fBtbs\fR and \fBtbslen\fR parameters. .SH "NOTES" .IX Header "NOTES" After the call to \fIEVP_PKEY_verify_init()\fR algorithm specific control operations can be performed to set any appropriate parameters for the operation. .PP The function \fIEVP_PKEY_verify()\fR can be called more than once on the same context if several operations are performed using the same parameters. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_PKEY_verify_init()\fR and \fIEVP_PKEY_verify()\fR return 1 if the verification was successful and 0 if it failed. Unlike other functions the return value 0 from \&\fIEVP_PKEY_verify()\fR only indicates that the signature did not not verify successfully (that is tbs did not match the original data or the signature was of invalid form) it is not an indication of a more serious error. .PP A negative value indicates an error other that signature verification failure. In particular a return value of \-2 indicates the operation is not supported by the public key algorithm. .SH "EXAMPLE" .IX Header "EXAMPLE" Verify signature using PKCS#1 and \s-1SHA256\s0 digest: .PP .Vb 2 \& #include \& #include \& \& EVP_PKEY_CTX *ctx; \& unsigned char *md, *sig; \& size_t mdlen, siglen; \& EVP_PKEY *verify_key; \& /* NB: assumes verify_key, sig, siglen md and mdlen are already set up \& * and that verify_key is an RSA public key \& */ \& ctx = EVP_PKEY_CTX_new(verify_key); \& if (!ctx) \& /* Error occurred */ \& if (EVP_PKEY_verify_init(ctx) <= 0) \& /* Error */ \& if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0) \& /* Error */ \& if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0) \& /* Error */ \& \& /* Perform operation */ \& ret = EVP_PKEY_verify(ctx, sig, siglen, md, mdlen); \& \& /* ret == 1 indicates success, 0 verify failure and < 0 for some \& * other error. \& */ .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_PKEY_CTX_new\fR\|(3), \&\fIEVP_PKEY_encrypt\fR\|(3), \&\fIEVP_PKEY_decrypt\fR\|(3), \&\fIEVP_PKEY_sign\fR\|(3), \&\fIEVP_PKEY_verify_recover\fR\|(3), \&\fIEVP_PKEY_derive\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" These functions were first added to OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/crypto.30000644000175000017500000001507512360020726017125 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "crypto 3" .TH crypto 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" crypto \- OpenSSL cryptographic library .SH "SYNOPSIS" .IX Header "SYNOPSIS" .SH "DESCRIPTION" .IX Header "DESCRIPTION" The OpenSSL \fBcrypto\fR library implements a wide range of cryptographic algorithms used in various Internet standards. The services provided by this library are used by the OpenSSL implementations of \s-1SSL, TLS\s0 and S/MIME, and they have also been used to implement \s-1SSH,\s0 OpenPGP, and other cryptographic standards. .SH "OVERVIEW" .IX Header "OVERVIEW" \&\fBlibcrypto\fR consists of a number of sub-libraries that implement the individual algorithms. .PP The functionality includes symmetric encryption, public key cryptography and key agreement, certificate handling, cryptographic hash functions and a cryptographic pseudo-random number generator. .IP "\s-1SYMMETRIC CIPHERS\s0" 4 .IX Item "SYMMETRIC CIPHERS" \&\fIblowfish\fR\|(3), \fIcast\fR\|(3), \fIdes\fR\|(3), \&\fIidea\fR\|(3), \fIrc2\fR\|(3), \fIrc4\fR\|(3), \fIrc5\fR\|(3) .IP "\s-1PUBLIC KEY CRYPTOGRAPHY AND KEY AGREEMENT\s0" 4 .IX Item "PUBLIC KEY CRYPTOGRAPHY AND KEY AGREEMENT" \&\fIdsa\fR\|(3), \fIdh\fR\|(3), \fIrsa\fR\|(3) .IP "\s-1CERTIFICATES\s0" 4 .IX Item "CERTIFICATES" \&\fIx509\fR\|(3), \fIx509v3\fR\|(3) .IP "\s-1AUTHENTICATION CODES, HASH FUNCTIONS\s0" 4 .IX Item "AUTHENTICATION CODES, HASH FUNCTIONS" \&\fIhmac\fR\|(3), \fImd2\fR\|(3), \fImd4\fR\|(3), \&\fImd5\fR\|(3), \fImdc2\fR\|(3), \fIripemd\fR\|(3), \&\fIsha\fR\|(3) .IP "\s-1AUXILIARY FUNCTIONS\s0" 4 .IX Item "AUXILIARY FUNCTIONS" \&\fIerr\fR\|(3), \fIthreads\fR\|(3), \fIrand\fR\|(3), \&\s-1\fIOPENSSL_VERSION_NUMBER\s0\fR\|(3) .IP "\s-1INPUT/OUTPUT, DATA ENCODING\s0" 4 .IX Item "INPUT/OUTPUT, DATA ENCODING" \&\fIasn1\fR\|(3), \fIbio\fR\|(3), \fIevp\fR\|(3), \fIpem\fR\|(3), \&\fIpkcs7\fR\|(3), \fIpkcs12\fR\|(3) .IP "\s-1INTERNAL FUNCTIONS\s0" 4 .IX Item "INTERNAL FUNCTIONS" \&\fIbn\fR\|(3), \fIbuffer\fR\|(3), \fIec\fR\|(3), \fIlhash\fR\|(3), \&\fIobjects\fR\|(3), \fIstack\fR\|(3), \&\fItxt_db\fR\|(3) .SH "NOTES" .IX Header "NOTES" Some of the newer functions follow a naming convention using the numbers \&\fB0\fR and \fB1\fR. For example the functions: .PP .Vb 2 \& int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev); \& int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj); .Ve .PP The \fB0\fR version uses the supplied structure pointer directly in the parent and it will be freed up when the parent is freed. In the above example \fBcrl\fR would be freed but \fBrev\fR would not. .PP The \fB1\fR function uses a copy of the supplied structure pointer (or in some cases increases its link count) in the parent and so both (\fBx\fR and \fBobj\fR above) should be freed up. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIopenssl\fR\|(1), \fIssl\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/s_client.10000644000175000017500000003667112360020743017407 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "s_client 1" .TH s_client 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" s_client \- SSL/TLS client program .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBs_client\fR [\fB\-connect host:port\fR] [\fB\-verify depth\fR] [\fB\-verify_return_error\fR] [\fB\-cert filename\fR] [\fB\-certform DER|PEM\fR] [\fB\-key filename\fR] [\fB\-keyform DER|PEM\fR] [\fB\-pass arg\fR] [\fB\-CApath directory\fR] [\fB\-CAfile filename\fR] [\fB\-reconnect\fR] [\fB\-pause\fR] [\fB\-showcerts\fR] [\fB\-debug\fR] [\fB\-msg\fR] [\fB\-nbio_test\fR] [\fB\-state\fR] [\fB\-nbio\fR] [\fB\-crlf\fR] [\fB\-ign_eof\fR] [\fB\-quiet\fR] [\fB\-ssl2\fR] [\fB\-ssl3\fR] [\fB\-tls1\fR] [\fB\-no_ssl2\fR] [\fB\-no_ssl3\fR] [\fB\-no_tls1\fR] [\fB\-bugs\fR] [\fB\-cipher cipherlist\fR] [\fB\-starttls protocol\fR] [\fB\-engine id\fR] [\fB\-tlsextdebug\fR] [\fB\-no_ticket\fR] [\fB\-sess_out filename\fR] [\fB\-sess_in filename\fR] [\fB\-rand file(s)\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBs_client\fR command implements a generic \s-1SSL/TLS\s0 client which connects to a remote host using \s-1SSL/TLS.\s0 It is a \fIvery\fR useful diagnostic tool for \&\s-1SSL\s0 servers. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-connect host:port\fR" 4 .IX Item "-connect host:port" This specifies the host and optional port to connect to. If not specified then an attempt is made to connect to the local host on port 4433. .IP "\fB\-cert certname\fR" 4 .IX Item "-cert certname" The certificate to use, if one is requested by the server. The default is not to use a certificate. .IP "\fB\-certform format\fR" 4 .IX Item "-certform format" The certificate format to use: \s-1DER\s0 or \s-1PEM. PEM\s0 is the default. .IP "\fB\-key keyfile\fR" 4 .IX Item "-key keyfile" The private key to use. If not specified then the certificate file will be used. .IP "\fB\-keyform format\fR" 4 .IX Item "-keyform format" The private format to use: \s-1DER\s0 or \s-1PEM. PEM\s0 is the default. .IP "\fB\-pass arg\fR" 4 .IX Item "-pass arg" the private key password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-verify depth\fR" 4 .IX Item "-verify depth" The verify depth to use. This specifies the maximum length of the server certificate chain and turns on server certificate verification. Currently the verify operation continues after errors so all the problems with a certificate chain can be seen. As a side effect the connection will never fail due to a server certificate verify failure. .IP "\fB\-verify_return_error\fR" 4 .IX Item "-verify_return_error" Return verification errors instead of continuing. This will typically abort the handshake with a fatal error. .IP "\fB\-CApath directory\fR" 4 .IX Item "-CApath directory" The directory to use for server certificate verification. This directory must be in \*(L"hash format\*(R", see \fBverify\fR for more information. These are also used when building the client certificate chain. .IP "\fB\-CAfile file\fR" 4 .IX Item "-CAfile file" A file containing trusted certificates to use during server authentication and to use when attempting to build the client certificate chain. .IP "\fB\-purpose, \-ignore_critical, \-issuer_checks, \-crl_check, \-crl_check_all, \-policy_check, \-extended_crl, \-x509_strict, \-policy \-check_ss_sig\fR" 4 .IX Item "-purpose, -ignore_critical, -issuer_checks, -crl_check, -crl_check_all, -policy_check, -extended_crl, -x509_strict, -policy -check_ss_sig" Set various certificate chain valiadition option. See the \&\fBverify\fR manual page for details. .IP "\fB\-reconnect\fR" 4 .IX Item "-reconnect" reconnects to the same server 5 times using the same session \s-1ID,\s0 this can be used as a test that session caching is working. .IP "\fB\-pause\fR" 4 .IX Item "-pause" pauses 1 second between each read and write call. .IP "\fB\-showcerts\fR" 4 .IX Item "-showcerts" display the whole server certificate chain: normally only the server certificate itself is displayed. .IP "\fB\-prexit\fR" 4 .IX Item "-prexit" print session information when the program exits. This will always attempt to print out information even if the connection fails. Normally information will only be printed out once if the connection succeeds. This option is useful because the cipher in use may be renegotiated or the connection may fail because a client certificate is required or is requested only after an attempt is made to access a certain \s-1URL.\s0 Note: the output produced by this option is not always accurate because a connection might never have been established. .IP "\fB\-state\fR" 4 .IX Item "-state" prints out the \s-1SSL\s0 session states. .IP "\fB\-debug\fR" 4 .IX Item "-debug" print extensive debugging information including a hex dump of all traffic. .IP "\fB\-msg\fR" 4 .IX Item "-msg" show all protocol messages with hex dump. .IP "\fB\-nbio_test\fR" 4 .IX Item "-nbio_test" tests non-blocking I/O .IP "\fB\-nbio\fR" 4 .IX Item "-nbio" turns on non-blocking I/O .IP "\fB\-crlf\fR" 4 .IX Item "-crlf" this option translated a line feed from the terminal into \s-1CR+LF\s0 as required by some servers. .IP "\fB\-ign_eof\fR" 4 .IX Item "-ign_eof" inhibit shutting down the connection when end of file is reached in the input. .IP "\fB\-quiet\fR" 4 .IX Item "-quiet" inhibit printing of session and certificate information. This implicitly turns on \fB\-ign_eof\fR as well. .IP "\fB\-psk_identity identity\fR" 4 .IX Item "-psk_identity identity" Use the \s-1PSK\s0 identity \fBidentity\fR when using a \s-1PSK\s0 cipher suite. .IP "\fB\-psk key\fR" 4 .IX Item "-psk key" Use the \s-1PSK\s0 key \fBkey\fR when using a \s-1PSK\s0 cipher suite. The key is given as a hexadecimal number without leading 0x, for example \-psk 1a2b3c4d. .IP "\fB\-ssl2\fR, \fB\-ssl3\fR, \fB\-tls1\fR, \fB\-no_ssl2\fR, \fB\-no_ssl3\fR, \fB\-no_tls1\fR" 4 .IX Item "-ssl2, -ssl3, -tls1, -no_ssl2, -no_ssl3, -no_tls1" these options disable the use of certain \s-1SSL\s0 or \s-1TLS\s0 protocols. By default the initial handshake uses a method which should be compatible with all servers and permit them to use \s-1SSL\s0 v3, \s-1SSL\s0 v2 or \s-1TLS\s0 as appropriate. .Sp Unfortunately there are a lot of ancient and broken servers in use which cannot handle this technique and will fail to connect. Some servers only work if \s-1TLS\s0 is turned off with the \fB\-no_tls\fR option others will only support \s-1SSL\s0 v2 and may need the \fB\-ssl2\fR option. .IP "\fB\-bugs\fR" 4 .IX Item "-bugs" there are several known bug in \s-1SSL\s0 and \s-1TLS\s0 implementations. Adding this option enables various workarounds. .IP "\fB\-cipher cipherlist\fR" 4 .IX Item "-cipher cipherlist" this allows the cipher list sent by the client to be modified. Although the server determines which cipher suite is used it should take the first supported cipher in the list sent by the client. See the \fBciphers\fR command for more information. .IP "\fB\-starttls protocol\fR" 4 .IX Item "-starttls protocol" send the protocol-specific message(s) to switch to \s-1TLS\s0 for communication. \&\fBprotocol\fR is a keyword for the intended protocol. Currently, the only supported keywords are \*(L"smtp\*(R", \*(L"lmtp\*(R", \*(L"pop3\*(R", \*(L"imap\*(R", and \*(L"ftp\*(R". .IP "\fB\-tlsextdebug\fR" 4 .IX Item "-tlsextdebug" print out a hex dump of any \s-1TLS\s0 extensions received from the server. .IP "\fB\-no_ticket\fR" 4 .IX Item "-no_ticket" disable RFC4507bis session ticket support. .IP "\fB\-sess_out filename\fR" 4 .IX Item "-sess_out filename" output \s-1SSL\s0 session to \fBfilename\fR .IP "\fB\-sess_in sess.pem\fR" 4 .IX Item "-sess_in sess.pem" load \s-1SSL\s0 session from \fBfilename\fR. The client will attempt to resume a connection from this session. .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBs_client\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .IP "\fB\-rand file(s)\fR" 4 .IX Item "-rand file(s)" a file or files containing random data used to seed the random number generator, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)). Multiple files can be specified separated by a OS-dependent character. The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for all others. .SH "CONNECTED COMMANDS" .IX Header "CONNECTED COMMANDS" If a connection is established with an \s-1SSL\s0 server then any data received from the server is displayed and any key presses will be sent to the server. When used interactively (which means neither \fB\-quiet\fR nor \fB\-ign_eof\fR have been given), the session will be renegotiated if the line begins with an \&\fBR\fR, and if the line begins with a \fBQ\fR or if end of file is reached, the connection will be closed down. .SH "NOTES" .IX Header "NOTES" \&\fBs_client\fR can be used to debug \s-1SSL\s0 servers. To connect to an \s-1SSL HTTP\s0 server the command: .PP .Vb 1 \& openssl s_client \-connect servername:443 .Ve .PP would typically be used (https uses port 443). If the connection succeeds then an \s-1HTTP\s0 command can be given such as \*(L"\s-1GET /\*(R"\s0 to retrieve a web page. .PP If the handshake fails then there are several possible causes, if it is nothing obvious like no client certificate then the \fB\-bugs\fR, \fB\-ssl2\fR, \&\fB\-ssl3\fR, \fB\-tls1\fR, \fB\-no_ssl2\fR, \fB\-no_ssl3\fR, \fB\-no_tls1\fR options can be tried in case it is a buggy server. In particular you should play with these options \fBbefore\fR submitting a bug report to an OpenSSL mailing list. .PP A frequent problem when attempting to get client certificates working is that a web client complains it has no certificates or gives an empty list to choose from. This is normally because the server is not sending the clients certificate authority in its \*(L"acceptable \s-1CA\s0 list\*(R" when it requests a certificate. By using \fBs_client\fR the \s-1CA\s0 list can be viewed and checked. However some servers only request client authentication after a specific \s-1URL\s0 is requested. To obtain the list in this case it is necessary to use the \fB\-prexit\fR option and send an \s-1HTTP\s0 request for an appropriate page. .PP If a certificate is specified on the command line using the \fB\-cert\fR option it will not be used unless the server specifically requests a client certificate. Therefor merely including a client certificate on the command line is no guarantee that the certificate works. .PP If there are problems verifying a server certificate then the \&\fB\-showcerts\fR option can be used to show the whole chain. .PP Since the SSLv23 client hello cannot include compression methods or extensions these will only be supported if its use is disabled, for example by using the \&\fB\-no_sslv2\fR option. .PP The \fBs_client\fR utility is a test tool and is designed to continue the handshake after any certificate verification errors. As a result it will accept any certificate chain (trusted or not) sent by the peer. None test applications should \fBnot\fR do this as it makes them vulnerable to a \s-1MITM\s0 attack. This behaviour can be changed by with the \fB\-verify_return_error\fR option: any verify errors are then returned aborting the handshake. .SH "BUGS" .IX Header "BUGS" Because this program has a lot of options and also because some of the techniques used are rather old, the C source of s_client is rather hard to read and not a model of how things should be done. A typical \&\s-1SSL\s0 client program would be much simpler. .PP The \fB\-prexit\fR option is a bit of a hack. We should really report information whenever a session is renegotiated. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIsess_id\fR\|(1), \fIs_server\fR\|(1), \fIciphers\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/d2i_SSL_SESSION.30000644000175000017500000001614312360020737020206 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "d2i_SSL_SESSION 3" .TH d2i_SSL_SESSION 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" d2i_SSL_SESSION, i2d_SSL_SESSION \- convert SSL_SESSION object from/to ASN1 representation .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, long length); \& int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fId2i_SSL_SESSION()\fR transforms the external \s-1ASN1\s0 representation of an \s-1SSL/TLS\s0 session, stored as binary data at location \fBpp\fR with length \fBlength\fR, into an \s-1SSL_SESSION\s0 object. .PP \&\fIi2d_SSL_SESSION()\fR transforms the \s-1SSL_SESSION\s0 object \fBin\fR into the \s-1ASN1\s0 representation and stores it into the memory location pointed to by \fBpp\fR. The length of the resulting \s-1ASN1\s0 representation is returned. If \fBpp\fR is the \s-1NULL\s0 pointer, only the length is calculated and returned. .SH "NOTES" .IX Header "NOTES" The \s-1SSL_SESSION\s0 object is built from several \fImalloc()\fRed parts, it can therefore not be moved, copied or stored directly. In order to store session data on disk or into a database, it must be transformed into a binary \s-1ASN1\s0 representation. .PP When using \fId2i_SSL_SESSION()\fR, the \s-1SSL_SESSION\s0 object is automatically allocated. The reference count is 1, so that the session must be explicitly removed using \fISSL_SESSION_free\fR\|(3), unless the \s-1SSL_SESSION\s0 object is completely taken over, when being called inside the \fIget_session_cb()\fR (see \&\fISSL_CTX_sess_set_get_cb\fR\|(3)). .PP \&\s-1SSL_SESSION\s0 objects keep internal link information about the session cache list, when being inserted into one \s-1SSL_CTX\s0 object's session cache. One \s-1SSL_SESSION\s0 object, regardless of its reference count, must therefore only be used with one \s-1SSL_CTX\s0 object (and the \s-1SSL\s0 objects created from this \s-1SSL_CTX\s0 object). .PP When using \fIi2d_SSL_SESSION()\fR, the memory location pointed to by \fBpp\fR must be large enough to hold the binary representation of the session. There is no known limit on the size of the created \s-1ASN1\s0 representation, so the necessary amount of space should be obtained by first calling \fIi2d_SSL_SESSION()\fR with \&\fBpp=NULL\fR, and obtain the size needed, then allocate the memory and call \fIi2d_SSL_SESSION()\fR again. Note that this will advance the value contained in \fB*pp\fR so it is necessary to save a copy of the original allocation. For example: int i, j; char *p, *temp; .PP .Vb 7 \& i = i2d_SSL_SESSION(sess, NULL); \& p = temp = malloc(i); \& if (temp != NULL) { \& j = i2d_SSL_SESSION(sess, &temp); \& assert(i == j); \& assert(p + i == temp); \& } .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fId2i_SSL_SESSION()\fR returns a pointer to the newly allocated \s-1SSL_SESSION\s0 object. In case of failure the NULL-pointer is returned and the error message can be retrieved from the error stack. .PP \&\fIi2d_SSL_SESSION()\fR returns the size of the \s-1ASN1\s0 representation in bytes. When the session is not valid, \fB0\fR is returned and no operation is performed. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_SESSION_free\fR\|(3), \&\fISSL_CTX_sess_set_get_cb\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/ocsp.10000644000175000017500000004523412360020741016544 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ocsp 1" .TH ocsp 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ocsp \- Online Certificate Status Protocol utility .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBocsp\fR [\fB\-out file\fR] [\fB\-issuer file\fR] [\fB\-cert file\fR] [\fB\-serial n\fR] [\fB\-signer file\fR] [\fB\-signkey file\fR] [\fB\-sign_other file\fR] [\fB\-no_certs\fR] [\fB\-req_text\fR] [\fB\-resp_text\fR] [\fB\-text\fR] [\fB\-reqout file\fR] [\fB\-respout file\fR] [\fB\-reqin file\fR] [\fB\-respin file\fR] [\fB\-nonce\fR] [\fB\-no_nonce\fR] [\fB\-url \s-1URL\s0\fR] [\fB\-host host:n\fR] [\fB\-path\fR] [\fB\-CApath dir\fR] [\fB\-CAfile file\fR] [\fB\-VAfile file\fR] [\fB\-validity_period n\fR] [\fB\-status_age n\fR] [\fB\-noverify\fR] [\fB\-verify_other file\fR] [\fB\-trust_other\fR] [\fB\-no_intern\fR] [\fB\-no_signature_verify\fR] [\fB\-no_cert_verify\fR] [\fB\-no_chain\fR] [\fB\-no_cert_checks\fR] [\fB\-port num\fR] [\fB\-index file\fR] [\fB\-CA file\fR] [\fB\-rsigner file\fR] [\fB\-rkey file\fR] [\fB\-rother file\fR] [\fB\-resp_no_certs\fR] [\fB\-nmin n\fR] [\fB\-ndays n\fR] [\fB\-resp_key_id\fR] [\fB\-nrequest n\fR] [\fB\-md5|\-sha1|...\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The Online Certificate Status Protocol (\s-1OCSP\s0) enables applications to determine the (revocation) state of an identified certificate (\s-1RFC 2560\s0). .PP The \fBocsp\fR command performs many common \s-1OCSP\s0 tasks. It can be used to print out requests and responses, create requests and send queries to an \s-1OCSP\s0 responder and behave like a mini \s-1OCSP\s0 server itself. .SH "OCSP CLIENT OPTIONS" .IX Header "OCSP CLIENT OPTIONS" .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" specify output filename, default is standard output. .IP "\fB\-issuer filename\fR" 4 .IX Item "-issuer filename" This specifies the current issuer certificate. This option can be used multiple times. The certificate specified in \fBfilename\fR must be in \&\s-1PEM\s0 format. This option \fB\s-1MUST\s0\fR come before any \fB\-cert\fR options. .IP "\fB\-cert filename\fR" 4 .IX Item "-cert filename" Add the certificate \fBfilename\fR to the request. The issuer certificate is taken from the previous \fBissuer\fR option, or an error occurs if no issuer certificate is specified. .IP "\fB\-serial num\fR" 4 .IX Item "-serial num" Same as the \fBcert\fR option except the certificate with serial number \&\fBnum\fR is added to the request. The serial number is interpreted as a decimal integer unless preceded by \fB0x\fR. Negative integers can also be specified by preceding the value by a \fB\-\fR sign. .IP "\fB\-signer filename\fR, \fB\-signkey filename\fR" 4 .IX Item "-signer filename, -signkey filename" Sign the \s-1OCSP\s0 request using the certificate specified in the \fBsigner\fR option and the private key specified by the \fBsignkey\fR option. If the \fBsignkey\fR option is not present then the private key is read from the same file as the certificate. If neither option is specified then the \s-1OCSP\s0 request is not signed. .IP "\fB\-sign_other filename\fR" 4 .IX Item "-sign_other filename" Additional certificates to include in the signed request. .IP "\fB\-nonce\fR, \fB\-no_nonce\fR" 4 .IX Item "-nonce, -no_nonce" Add an \s-1OCSP\s0 nonce extension to a request or disable \s-1OCSP\s0 nonce addition. Normally if an \s-1OCSP\s0 request is input using the \fBrespin\fR option no nonce is added: using the \fBnonce\fR option will force addition of a nonce. If an \s-1OCSP\s0 request is being created (using \fBcert\fR and \fBserial\fR options) a nonce is automatically added specifying \fBno_nonce\fR overrides this. .IP "\fB\-req_text\fR, \fB\-resp_text\fR, \fB\-text\fR" 4 .IX Item "-req_text, -resp_text, -text" print out the text form of the \s-1OCSP\s0 request, response or both respectively. .IP "\fB\-reqout file\fR, \fB\-respout file\fR" 4 .IX Item "-reqout file, -respout file" write out the \s-1DER\s0 encoded certificate request or response to \fBfile\fR. .IP "\fB\-reqin file\fR, \fB\-respin file\fR" 4 .IX Item "-reqin file, -respin file" read \s-1OCSP\s0 request or response file from \fBfile\fR. These option are ignored if \s-1OCSP\s0 request or response creation is implied by other options (for example with \fBserial\fR, \fBcert\fR and \fBhost\fR options). .IP "\fB\-url responder_url\fR" 4 .IX Item "-url responder_url" specify the responder \s-1URL.\s0 Both \s-1HTTP\s0 and \s-1HTTPS \s0(\s-1SSL/TLS\s0) URLs can be specified. .IP "\fB\-host hostname:port\fR, \fB\-path pathname\fR" 4 .IX Item "-host hostname:port, -path pathname" if the \fBhost\fR option is present then the \s-1OCSP\s0 request is sent to the host \&\fBhostname\fR on port \fBport\fR. \fBpath\fR specifies the \s-1HTTP\s0 path name to use or \*(L"/\*(R" by default. .IP "\fB\-CAfile file\fR, \fB\-CApath pathname\fR" 4 .IX Item "-CAfile file, -CApath pathname" file or pathname containing trusted \s-1CA\s0 certificates. These are used to verify the signature on the \s-1OCSP\s0 response. .IP "\fB\-verify_other file\fR" 4 .IX Item "-verify_other file" file containing additional certificates to search when attempting to locate the \s-1OCSP\s0 response signing certificate. Some responders omit the actual signer's certificate from the response: this option can be used to supply the necessary certificate in such cases. .IP "\fB\-trust_other\fR" 4 .IX Item "-trust_other" the certificates specified by the \fB\-verify_other\fR option should be explicitly trusted and no additional checks will be performed on them. This is useful when the complete responder certificate chain is not available or trusting a root \s-1CA\s0 is not appropriate. .IP "\fB\-VAfile file\fR" 4 .IX Item "-VAfile file" file containing explicitly trusted responder certificates. Equivalent to the \&\fB\-verify_other\fR and \fB\-trust_other\fR options. .IP "\fB\-noverify\fR" 4 .IX Item "-noverify" don't attempt to verify the \s-1OCSP\s0 response signature or the nonce values. This option will normally only be used for debugging since it disables all verification of the responders certificate. .IP "\fB\-no_intern\fR" 4 .IX Item "-no_intern" ignore certificates contained in the \s-1OCSP\s0 response when searching for the signers certificate. With this option the signers certificate must be specified with either the \fB\-verify_other\fR or \fB\-VAfile\fR options. .IP "\fB\-no_signature_verify\fR" 4 .IX Item "-no_signature_verify" don't check the signature on the \s-1OCSP\s0 response. Since this option tolerates invalid signatures on \s-1OCSP\s0 responses it will normally only be used for testing purposes. .IP "\fB\-no_cert_verify\fR" 4 .IX Item "-no_cert_verify" don't verify the \s-1OCSP\s0 response signers certificate at all. Since this option allows the \s-1OCSP\s0 response to be signed by any certificate it should only be used for testing purposes. .IP "\fB\-no_chain\fR" 4 .IX Item "-no_chain" do not use certificates in the response as additional untrusted \s-1CA\s0 certificates. .IP "\fB\-no_cert_checks\fR" 4 .IX Item "-no_cert_checks" don't perform any additional checks on the \s-1OCSP\s0 response signers certificate. That is do not make any checks to see if the signers certificate is authorised to provide the necessary status information: as a result this option should only be used for testing purposes. .IP "\fB\-validity_period nsec\fR, \fB\-status_age age\fR" 4 .IX Item "-validity_period nsec, -status_age age" these options specify the range of times, in seconds, which will be tolerated in an \s-1OCSP\s0 response. Each certificate status response includes a \fBnotBefore\fR time and an optional \fBnotAfter\fR time. The current time should fall between these two values, but the interval between the two times may be only a few seconds. In practice the \s-1OCSP\s0 responder and clients clocks may not be precisely synchronised and so such a check may fail. To avoid this the \fB\-validity_period\fR option can be used to specify an acceptable error range in seconds, the default value is 5 minutes. .Sp If the \fBnotAfter\fR time is omitted from a response then this means that new status information is immediately available. In this case the age of the \fBnotBefore\fR field is checked to see it is not older than \fBage\fR seconds old. By default this additional check is not performed. .IP "\fB\-md5|\-sha1|\-sha256|\-ripemod160|...\fR" 4 .IX Item "-md5|-sha1|-sha256|-ripemod160|..." this option sets digest algorithm to use for certificate identification in the \s-1OCSP\s0 request. By default \s-1SHA\-1\s0 is used. .SH "OCSP SERVER OPTIONS" .IX Header "OCSP SERVER OPTIONS" .IP "\fB\-index indexfile\fR" 4 .IX Item "-index indexfile" \&\fBindexfile\fR is a text index file in \fBca\fR format containing certificate revocation information. .Sp If the \fBindex\fR option is specified the \fBocsp\fR utility is in responder mode, otherwise it is in client mode. The request(s) the responder processes can be either specified on the command line (using \fBissuer\fR and \fBserial\fR options), supplied in a file (using the \&\fBrespin\fR option) or via external \s-1OCSP\s0 clients (if \fBport\fR or \fBurl\fR is specified). .Sp If the \fBindex\fR option is present then the \fB\s-1CA\s0\fR and \fBrsigner\fR options must also be present. .IP "\fB\-CA file\fR" 4 .IX Item "-CA file" \&\s-1CA\s0 certificate corresponding to the revocation information in \fBindexfile\fR. .IP "\fB\-rsigner file\fR" 4 .IX Item "-rsigner file" The certificate to sign \s-1OCSP\s0 responses with. .IP "\fB\-rother file\fR" 4 .IX Item "-rother file" Additional certificates to include in the \s-1OCSP\s0 response. .IP "\fB\-resp_no_certs\fR" 4 .IX Item "-resp_no_certs" Don't include any certificates in the \s-1OCSP\s0 response. .IP "\fB\-resp_key_id\fR" 4 .IX Item "-resp_key_id" Identify the signer certificate using the key \s-1ID,\s0 default is to use the subject name. .IP "\fB\-rkey file\fR" 4 .IX Item "-rkey file" The private key to sign \s-1OCSP\s0 responses with: if not present the file specified in the \&\fBrsigner\fR option is used. .IP "\fB\-port portnum\fR" 4 .IX Item "-port portnum" Port to listen for \s-1OCSP\s0 requests on. The port may also be specified using the \fBurl\fR option. .IP "\fB\-nrequest number\fR" 4 .IX Item "-nrequest number" The \s-1OCSP\s0 server will exit after receiving \fBnumber\fR requests, default unlimited. .IP "\fB\-nmin minutes\fR, \fB\-ndays days\fR" 4 .IX Item "-nmin minutes, -ndays days" Number of minutes or days when fresh revocation information is available: used in the \&\fBnextUpdate\fR field. If neither option is present then the \fBnextUpdate\fR field is omitted meaning fresh revocation information is immediately available. .SH "OCSP Response verification." .IX Header "OCSP Response verification." \&\s-1OCSP\s0 Response follows the rules specified in \s-1RFC2560.\s0 .PP Initially the \s-1OCSP\s0 responder certificate is located and the signature on the \s-1OCSP\s0 request checked using the responder certificate's public key. .PP Then a normal certificate verify is performed on the \s-1OCSP\s0 responder certificate building up a certificate chain in the process. The locations of the trusted certificates used to build the chain can be specified by the \fBCAfile\fR and \fBCApath\fR options or they will be looked for in the standard OpenSSL certificates directory. .PP If the initial verify fails then the \s-1OCSP\s0 verify process halts with an error. .PP Otherwise the issuing \s-1CA\s0 certificate in the request is compared to the \s-1OCSP\s0 responder certificate: if there is a match then the \s-1OCSP\s0 verify succeeds. .PP Otherwise the \s-1OCSP\s0 responder certificate's \s-1CA\s0 is checked against the issuing \&\s-1CA\s0 certificate in the request. If there is a match and the OCSPSigning extended key usage is present in the \s-1OCSP\s0 responder certificate then the \&\s-1OCSP\s0 verify succeeds. .PP Otherwise the root \s-1CA\s0 of the \s-1OCSP\s0 responders \s-1CA\s0 is checked to see if it is trusted for \s-1OCSP\s0 signing. If it is the \s-1OCSP\s0 verify succeeds. .PP If none of these checks is successful then the \s-1OCSP\s0 verify fails. .PP What this effectively means if that if the \s-1OCSP\s0 responder certificate is authorised directly by the \s-1CA\s0 it is issuing revocation information about (and it is correctly configured) then verification will succeed. .PP If the \s-1OCSP\s0 responder is a \*(L"global responder\*(R" which can give details about multiple CAs and has its own separate certificate chain then its root \&\s-1CA\s0 can be trusted for \s-1OCSP\s0 signing. For example: .PP .Vb 1 \& openssl x509 \-in ocspCA.pem \-addtrust OCSPSigning \-out trustedCA.pem .Ve .PP Alternatively the responder certificate itself can be explicitly trusted with the \fB\-VAfile\fR option. .SH "NOTES" .IX Header "NOTES" As noted, most of the verify options are for testing or debugging purposes. Normally only the \fB\-CApath\fR, \fB\-CAfile\fR and (if the responder is a 'global \&\s-1VA\s0') \fB\-VAfile\fR options need to be used. .PP The \s-1OCSP\s0 server is only useful for test and demonstration purposes: it is not really usable as a full \s-1OCSP\s0 responder. It contains only a very simple \s-1HTTP\s0 request handling and can only handle the \s-1POST\s0 form of \s-1OCSP\s0 queries. It also handles requests serially meaning it cannot respond to new requests until it has processed the current one. The text index file format of revocation is also inefficient for large quantities of revocation data. .PP It is possible to run the \fBocsp\fR application in responder mode via a \s-1CGI\s0 script using the \fBrespin\fR and \fBrespout\fR options. .SH "EXAMPLES" .IX Header "EXAMPLES" Create an \s-1OCSP\s0 request and write it to a file: .PP .Vb 1 \& openssl ocsp \-issuer issuer.pem \-cert c1.pem \-cert c2.pem \-reqout req.der .Ve .PP Send a query to an \s-1OCSP\s0 responder with \s-1URL\s0 http://ocsp.myhost.com/ save the response to a file and print it out in text form .PP .Vb 2 \& openssl ocsp \-issuer issuer.pem \-cert c1.pem \-cert c2.pem \e \& \-url http://ocsp.myhost.com/ \-resp_text \-respout resp.der .Ve .PP Read in an \s-1OCSP\s0 response and print out text form: .PP .Vb 1 \& openssl ocsp \-respin resp.der \-text .Ve .PP \&\s-1OCSP\s0 server on port 8888 using a standard \fBca\fR configuration, and a separate responder certificate. All requests and responses are printed to a file. .PP .Vb 2 \& openssl ocsp \-index demoCA/index.txt \-port 8888 \-rsigner rcert.pem \-CA demoCA/cacert.pem \& \-text \-out log.txt .Ve .PP As above but exit after processing one request: .PP .Vb 2 \& openssl ocsp \-index demoCA/index.txt \-port 8888 \-rsigner rcert.pem \-CA demoCA/cacert.pem \& \-nrequest 1 .Ve .PP Query status information using internally generated request: .PP .Vb 2 \& openssl ocsp \-index demoCA/index.txt \-rsigner rcert.pem \-CA demoCA/cacert.pem \& \-issuer demoCA/cacert.pem \-serial 1 .Ve .PP Query status information using request read from a file, write response to a second file. .PP .Vb 2 \& openssl ocsp \-index demoCA/index.txt \-rsigner rcert.pem \-CA demoCA/cacert.pem \& \-reqin req.der \-respout resp.der .Ve deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_PKEY_sign.30000644000175000017500000001562112360020721020077 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_PKEY_sign 3" .TH EVP_PKEY_sign 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_PKEY_sign_init, EVP_PKEY_sign \- sign using a public key algorithm .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx); \& int EVP_PKEY_sign(EVP_PKEY_CTX *ctx, \& unsigned char *sig, size_t *siglen, \& const unsigned char *tbs, size_t tbslen); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fIEVP_PKEY_sign_init()\fR function initializes a public key algorithm context using key \fBpkey\fR for a signing operation. .PP The \fIEVP_PKEY_sign()\fR function performs a public key signing operation using \fBctx\fR. The data to be signed is specified using the \fBtbs\fR and \&\fBtbslen\fR parameters. If \fBsig\fR is \fB\s-1NULL\s0\fR then the maximum size of the output buffer is written to the \fBsiglen\fR parameter. If \fBsig\fR is not \fB\s-1NULL\s0\fR then before the call the \fBsiglen\fR parameter should contain the length of the \&\fBsig\fR buffer, if the call is successful the signature is written to \&\fBsig\fR and the amount of data written to \fBsiglen\fR. .SH "NOTES" .IX Header "NOTES" After the call to \fIEVP_PKEY_sign_init()\fR algorithm specific control operations can be performed to set any appropriate parameters for the operation. .PP The function \fIEVP_PKEY_sign()\fR can be called more than once on the same context if several operations are performed using the same parameters. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_PKEY_sign_init()\fR and \fIEVP_PKEY_sign()\fR return 1 for success and 0 or a negative value for failure. In particular a return value of \-2 indicates the operation is not supported by the public key algorithm. .SH "EXAMPLE" .IX Header "EXAMPLE" Sign data using \s-1RSA\s0 with PKCS#1 padding and \s-1SHA256\s0 digest: .PP .Vb 2 \& #include \& #include \& \& EVP_PKEY_CTX *ctx; \& unsigned char *md, *sig; \& size_t mdlen, siglen; \& EVP_PKEY *signing_key; \& /* NB: assumes signing_key, md and mdlen are already set up \& * and that signing_key is an RSA private key \& */ \& ctx = EVP_PKEY_CTX_new(signing_key); \& if (!ctx) \& /* Error occurred */ \& if (EVP_PKEY_sign_init(ctx) <= 0) \& /* Error */ \& if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0) \& /* Error */ \& if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0) \& /* Error */ \& \& /* Determine buffer length */ \& if (EVP_PKEY_sign(ctx, NULL, &siglen, md, mdlen) <= 0) \& /* Error */ \& \& sig = OPENSSL_malloc(siglen); \& \& if (!sig) \& /* malloc failure */ \& \& if (EVP_PKEY_sign(ctx, sig, &siglen, md, mdlen) <= 0) \& /* Error */ \& \& /* Signature is siglen bytes written to buffer sig */ .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_PKEY_CTX_new\fR\|(3), \&\fIEVP_PKEY_encrypt\fR\|(3), \&\fIEVP_PKEY_decrypt\fR\|(3), \&\fIEVP_PKEY_verify\fR\|(3), \&\fIEVP_PKEY_verify_recover\fR\|(3), \&\fIEVP_PKEY_derive\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" These functions were first added to OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/ERR_clear_error.30000644000175000017500000001070112360020716020602 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ERR_clear_error 3" .TH ERR_clear_error 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ERR_clear_error \- clear the error queue .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void ERR_clear_error(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIERR_clear_error()\fR empties the current thread's error queue. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIERR_clear_error()\fR has no return value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIerr\fR\|(3), \fIERR_get_error\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIERR_clear_error()\fR is available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/DH_set_method.30000644000175000017500000002250312360020715020303 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DH_set_method 3" .TH DH_set_method 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DH_set_default_method, DH_get_default_method, DH_set_method, DH_new_method, DH_OpenSSL \- select DH method .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& void DH_set_default_method(const DH_METHOD *meth); \& \& const DH_METHOD *DH_get_default_method(void); \& \& int DH_set_method(DH *dh, const DH_METHOD *meth); \& \& DH *DH_new_method(ENGINE *engine); \& \& const DH_METHOD *DH_OpenSSL(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" A \fB\s-1DH_METHOD\s0\fR specifies the functions that OpenSSL uses for Diffie-Hellman operations. By modifying the method, alternative implementations such as hardware accelerators may be used. \s-1IMPORTANT:\s0 See the \s-1NOTES\s0 section for important information about how these \s-1DH API\s0 functions are affected by the use of \fB\s-1ENGINE\s0\fR \s-1API\s0 calls. .PP Initially, the default \s-1DH_METHOD\s0 is the OpenSSL internal implementation, as returned by \fIDH_OpenSSL()\fR. .PP \&\fIDH_set_default_method()\fR makes \fBmeth\fR the default method for all \s-1DH\s0 structures created later. \fB\s-1NB\s0\fR: This is true only whilst no \s-1ENGINE\s0 has been set as a default for \s-1DH,\s0 so this function is no longer recommended. .PP \&\fIDH_get_default_method()\fR returns a pointer to the current default \s-1DH_METHOD.\s0 However, the meaningfulness of this result is dependent on whether the \s-1ENGINE API\s0 is being used, so this function is no longer recommended. .PP \&\fIDH_set_method()\fR selects \fBmeth\fR to perform all operations using the key \fBdh\fR. This will replace the \s-1DH_METHOD\s0 used by the \s-1DH\s0 key and if the previous method was supplied by an \s-1ENGINE,\s0 the handle to that \s-1ENGINE\s0 will be released during the change. It is possible to have \s-1DH\s0 keys that only work with certain \s-1DH_METHOD\s0 implementations (eg. from an \s-1ENGINE\s0 module that supports embedded hardware-protected keys), and in such cases attempting to change the \s-1DH_METHOD\s0 for the key can have unexpected results. .PP \&\fIDH_new_method()\fR allocates and initializes a \s-1DH\s0 structure so that \fBengine\fR will be used for the \s-1DH\s0 operations. If \fBengine\fR is \s-1NULL,\s0 the default \s-1ENGINE\s0 for \s-1DH\s0 operations is used, and if no default \s-1ENGINE\s0 is set, the \s-1DH_METHOD\s0 controlled by \&\fIDH_set_default_method()\fR is used. .SH "THE DH_METHOD STRUCTURE" .IX Header "THE DH_METHOD STRUCTURE" .Vb 4 \& typedef struct dh_meth_st \& { \& /* name of the implementation */ \& const char *name; \& \& /* generate private and public DH values for key agreement */ \& int (*generate_key)(DH *dh); \& \& /* compute shared secret */ \& int (*compute_key)(unsigned char *key, BIGNUM *pub_key, DH *dh); \& \& /* compute r = a ^ p mod m (May be NULL for some implementations) */ \& int (*bn_mod_exp)(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p, \& const BIGNUM *m, BN_CTX *ctx, \& BN_MONT_CTX *m_ctx); \& \& /* called at DH_new */ \& int (*init)(DH *dh); \& \& /* called at DH_free */ \& int (*finish)(DH *dh); \& \& int flags; \& \& char *app_data; /* ?? */ \& \& } DH_METHOD; .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIDH_OpenSSL()\fR and \fIDH_get_default_method()\fR return pointers to the respective \&\fB\s-1DH_METHOD\s0\fRs. .PP \&\fIDH_set_default_method()\fR returns no value. .PP \&\fIDH_set_method()\fR returns non-zero if the provided \fBmeth\fR was successfully set as the method for \fBdh\fR (including unloading the \s-1ENGINE\s0 handle if the previous method was supplied by an \s-1ENGINE\s0). .PP \&\fIDH_new_method()\fR returns \s-1NULL\s0 and sets an error code that can be obtained by \&\fIERR_get_error\fR\|(3) if the allocation fails. Otherwise it returns a pointer to the newly allocated structure. .SH "NOTES" .IX Header "NOTES" As of version 0.9.7, \s-1DH_METHOD\s0 implementations are grouped together with other algorithmic APIs (eg. \s-1RSA_METHOD, EVP_CIPHER,\s0 etc) in \fB\s-1ENGINE\s0\fR modules. If a default \s-1ENGINE\s0 is specified for \s-1DH\s0 functionality using an \s-1ENGINE API\s0 function, that will override any \s-1DH\s0 defaults set using the \s-1DH API \s0(ie. \&\fIDH_set_default_method()\fR). For this reason, the \s-1ENGINE API\s0 is the recommended way to control default implementations for use in \s-1DH\s0 and other cryptographic algorithms. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdh\fR\|(3), \fIDH_new\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIDH_set_default_method()\fR, \fIDH_get_default_method()\fR, \fIDH_set_method()\fR, \&\fIDH_new_method()\fR and \fIDH_OpenSSL()\fR were added in OpenSSL 0.9.4. .PP \&\fIDH_set_default_openssl_method()\fR and \fIDH_get_default_openssl_method()\fR replaced \&\fIDH_set_default_method()\fR and \fIDH_get_default_method()\fR respectively, and \&\fIDH_set_method()\fR and \fIDH_new_method()\fR were altered to use \fB\s-1ENGINE\s0\fRs rather than \&\fB\s-1DH_METHOD\s0\fRs during development of the engine version of OpenSSL 0.9.6. For 0.9.7, the handling of defaults in the \s-1ENGINE API\s0 was restructured so that this change was reversed, and behaviour of the other functions resembled more closely the previous behaviour. The behaviour of defaults in the \s-1ENGINE API\s0 now transparently overrides the behaviour of defaults in the \s-1DH API\s0 without requiring changing these function prototypes. deps/libressl-pnacl-sys-2.1.6/libressl/man/d2i_X509_REQ.30000644000175000017500000001136412360020727017515 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "d2i_X509_REQ 3" .TH d2i_X509_REQ 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" d2i_X509_REQ, i2d_X509_REQ, d2i_X509_REQ_bio, d2i_X509_REQ_fp, i2d_X509_REQ_bio, i2d_X509_REQ_fp \- PKCS#10 certificate request functions. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& X509_REQ *d2i_X509_REQ(X509_REQ **a, const unsigned char **pp, long length); \& int i2d_X509_REQ(X509_REQ *a, unsigned char **pp); \& \& X509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **x); \& X509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **x); \& \& int i2d_X509_REQ_bio(BIO *bp, X509_REQ *x); \& int i2d_X509_REQ_fp(FILE *fp, X509_REQ *x); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions decode and encode a PKCS#10 certificate request. .PP Othewise these behave in a similar way to \fId2i_X509()\fR and \fIi2d_X509()\fR described in the \fId2i_X509\fR\|(3) manual page. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fId2i_X509\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_mode.30000644000175000017500000001635112360020733020637 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_mode 3" .TH SSL_CTX_set_mode 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_mode, SSL_set_mode, SSL_CTX_get_mode, SSL_get_mode \- manipulate SSL engine mode .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& long SSL_CTX_set_mode(SSL_CTX *ctx, long mode); \& long SSL_set_mode(SSL *ssl, long mode); \& \& long SSL_CTX_get_mode(SSL_CTX *ctx); \& long SSL_get_mode(SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_mode()\fR adds the mode set via bitmask in \fBmode\fR to \fBctx\fR. Options already set before are not cleared. .PP \&\fISSL_set_mode()\fR adds the mode set via bitmask in \fBmode\fR to \fBssl\fR. Options already set before are not cleared. .PP \&\fISSL_CTX_get_mode()\fR returns the mode set for \fBctx\fR. .PP \&\fISSL_get_mode()\fR returns the mode set for \fBssl\fR. .SH "NOTES" .IX Header "NOTES" The following mode changes are available: .IP "\s-1SSL_MODE_ENABLE_PARTIAL_WRITE\s0" 4 .IX Item "SSL_MODE_ENABLE_PARTIAL_WRITE" Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success when just a single record has been written). When not set (the default), \&\fISSL_write()\fR will only report success once the complete chunk was written. Once \fISSL_write()\fR returns with r, r bytes have been successfully written and the next call to \fISSL_write()\fR must only send the n\-r bytes left, imitating the behaviour of \fIwrite()\fR. .IP "\s-1SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER\s0" 4 .IX Item "SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER" Make it possible to retry \fISSL_write()\fR with changed buffer location (the buffer contents must stay the same). This is not the default to avoid the misconception that non-blocking \fISSL_write()\fR behaves like non-blocking \fIwrite()\fR. .IP "\s-1SSL_MODE_AUTO_RETRY\s0" 4 .IX Item "SSL_MODE_AUTO_RETRY" Never bother the application with retries if the transport is blocking. If a renegotiation take place during normal operation, a \&\fISSL_read\fR\|(3) or \fISSL_write\fR\|(3) would return with \-1 and indicate the need to retry with \s-1SSL_ERROR_WANT_READ.\s0 In a non-blocking environment applications must be prepared to handle incomplete read/write operations. In a blocking environment, applications are not always prepared to deal with read/write operations returning without success report. The flag \s-1SSL_MODE_AUTO_RETRY\s0 will cause read/write operations to only return after the handshake and successful completion. .IP "\s-1SSL_MODE_RELEASE_BUFFERS\s0" 4 .IX Item "SSL_MODE_RELEASE_BUFFERS" When we no longer need a read buffer or a write buffer for a given \s-1SSL,\s0 then release the memory we were using to hold it. Released memory is either appended to a list of unused \s-1RAM\s0 chunks on the \s-1SSL_CTX,\s0 or simply freed if the list of unused chunks would become longer than \&\s-1SSL_CTX\-\s0>freelist_max_len, which defaults to 32. Using this flag can save around 34k per idle \s-1SSL\s0 connection. This flag has no effect on \s-1SSL\s0 v2 connections, or on \s-1DTLS\s0 connections. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_set_mode()\fR and \fISSL_set_mode()\fR return the new mode bitmask after adding \fBmode\fR. .PP \&\fISSL_CTX_get_mode()\fR and \fISSL_get_mode()\fR return the current bitmask. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_read\fR\|(3), \fISSL_write\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\s-1SSL_MODE_AUTO_RETRY\s0 as been added in OpenSSL 0.9.6. deps/libressl-pnacl-sys-2.1.6/libressl/man/CMS_sign_receipt.30000644000175000017500000001261212360020714020751 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CMS_sign_receipt 3" .TH CMS_sign_receipt 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CMS_sign_receipt \- create a CMS signed receipt .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si, X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, unsigned int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fICMS_sign_receipt()\fR creates and returns a \s-1CMS\s0 signed receipt structure. \fBsi\fR is the \fBCMS_SignerInfo\fR structure containing the signed receipt request. \&\fBsigncert\fR is the certificate to sign with, \fBpkey\fR is the corresponding private key. \fBcerts\fR is an optional additional set of certificates to include in the \s-1CMS\s0 structure (for example any intermediate CAs in the chain). .PP \&\fBflags\fR is an optional set of flags. .SH "NOTES" .IX Header "NOTES" This functions behaves in a similar way to \fICMS_sign()\fR except the flag values \&\fB\s-1CMS_DETACHED\s0\fR, \fB\s-1CMS_BINARY\s0\fR, \fB\s-1CMS_NOATTR\s0\fR, \fB\s-1CMS_TEXT\s0\fR and \fB\s-1CMS_STREAM\s0\fR are not supported since they do not make sense in the context of signed receipts. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICMS_sign_receipt()\fR returns either a valid CMS_ContentInfo structure or \s-1NULL\s0 if an error occurred. The error can be obtained from \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \&\fICMS_verify_receipt\fR\|(3), \&\fICMS_sign\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fICMS_sign_receipt()\fR was added to OpenSSL 0.9.8 deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_get_psk_identity.30000644000175000017500000001174112360020735021667 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_get_psk_identity 3" .TH SSL_get_psk_identity 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_get_psk_identity, SSL_get_psk_identity_hint \- get PSK client identity and hint .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& const char *SSL_get_psk_identity_hint(const SSL *ssl); \& const char *SSL_get_psk_identity(const SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_get_psk_identity_hint()\fR is used to retrieve the \s-1PSK\s0 identity hint used during the connection setup related to \s-1SSL\s0 object \&\fBssl\fR. Similarly, \fISSL_get_psk_identity()\fR is used to retrieve the \s-1PSK\s0 identity used during the connection setup. .SH "RETURN VALUES" .IX Header "RETURN VALUES" If non\-\fB\s-1NULL\s0\fR, \fISSL_get_psk_identity_hint()\fR returns the \s-1PSK\s0 identity hint and \fISSL_get_psk_identity()\fR returns the \s-1PSK\s0 identity. Both are \&\fB\s-1NULL\s0\fR\-terminated. \fISSL_get_psk_identity_hint()\fR may return \fB\s-1NULL\s0\fR if no \s-1PSK\s0 identity hint was used during the connection setup. .PP Note that the return value is valid only during the lifetime of the \&\s-1SSL\s0 object \fBssl\fR. deps/libressl-pnacl-sys-2.1.6/libressl/man/x509.10000644000175000017500000010525212360020744016305 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "x509 1" .TH x509 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" x509 \- Certificate display and signing utility .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBx509\fR [\fB\-inform DER|PEM|NET\fR] [\fB\-outform DER|PEM|NET\fR] [\fB\-keyform DER|PEM\fR] [\fB\-CAform DER|PEM\fR] [\fB\-CAkeyform DER|PEM\fR] [\fB\-in filename\fR] [\fB\-out filename\fR] [\fB\-serial\fR] [\fB\-hash\fR] [\fB\-subject_hash\fR] [\fB\-issuer_hash\fR] [\fB\-subject\fR] [\fB\-issuer\fR] [\fB\-nameopt option\fR] [\fB\-email\fR] [\fB\-ocsp_uri\fR] [\fB\-startdate\fR] [\fB\-enddate\fR] [\fB\-purpose\fR] [\fB\-dates\fR] [\fB\-modulus\fR] [\fB\-pubkey\fR] [\fB\-fingerprint\fR] [\fB\-alias\fR] [\fB\-noout\fR] [\fB\-trustout\fR] [\fB\-clrtrust\fR] [\fB\-clrreject\fR] [\fB\-addtrust arg\fR] [\fB\-addreject arg\fR] [\fB\-setalias arg\fR] [\fB\-days arg\fR] [\fB\-set_serial n\fR] [\fB\-signkey filename\fR] [\fB\-x509toreq\fR] [\fB\-req\fR] [\fB\-CA filename\fR] [\fB\-CAkey filename\fR] [\fB\-CAcreateserial\fR] [\fB\-CAserial filename\fR] [\fB\-text\fR] [\fB\-C\fR] [\fB\-md2|\-md5|\-sha1|\-mdc2\fR] [\fB\-clrext\fR] [\fB\-extfile filename\fR] [\fB\-extensions section\fR] [\fB\-engine id\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBx509\fR command is a multi purpose certificate utility. It can be used to display certificate information, convert certificates to various forms, sign certificate requests like a \*(L"mini \s-1CA\*(R"\s0 or edit certificate trust settings. .PP Since there are a large number of options they will split up into various sections. .SH "OPTIONS" .IX Header "OPTIONS" .SS "\s-1INPUT, OUTPUT AND GENERAL PURPOSE OPTIONS\s0" .IX Subsection "INPUT, OUTPUT AND GENERAL PURPOSE OPTIONS" .IP "\fB\-inform DER|PEM|NET\fR" 4 .IX Item "-inform DER|PEM|NET" This specifies the input format normally the command will expect an X509 certificate but this can change if other options such as \fB\-req\fR are present. The \s-1DER\s0 format is the \s-1DER\s0 encoding of the certificate and \s-1PEM\s0 is the base64 encoding of the \s-1DER\s0 encoding with header and footer lines added. The \s-1NET\s0 option is an obscure Netscape server format that is now obsolete. .IP "\fB\-outform DER|PEM|NET\fR" 4 .IX Item "-outform DER|PEM|NET" This specifies the output format, the options have the same meaning as the \&\fB\-inform\fR option. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read a certificate from or standard input if this option is not specified. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" This specifies the output filename to write to or standard output by default. .IP "\fB\-md2|\-md5|\-sha1|\-mdc2\fR" 4 .IX Item "-md2|-md5|-sha1|-mdc2" the digest to use. This affects any signing or display option that uses a message digest, such as the \fB\-fingerprint\fR, \fB\-signkey\fR and \fB\-CA\fR options. If not specified then \s-1SHA1\s0 is used. If the key being used to sign with is a \s-1DSA\s0 key then this option has no effect: \s-1SHA1\s0 is always used with \s-1DSA\s0 keys. .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBx509\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .SS "\s-1DISPLAY OPTIONS\s0" .IX Subsection "DISPLAY OPTIONS" Note: the \fB\-alias\fR and \fB\-purpose\fR options are also display options but are described in the \fB\s-1TRUST SETTINGS\s0\fR section. .IP "\fB\-text\fR" 4 .IX Item "-text" prints out the certificate in text form. Full details are output including the public key, signature algorithms, issuer and subject names, serial number any extensions present and any trust settings. .IP "\fB\-certopt option\fR" 4 .IX Item "-certopt option" customise the output format used with \fB\-text\fR. The \fBoption\fR argument can be a single option or multiple options separated by commas. The \fB\-certopt\fR switch may be also be used more than once to set multiple options. See the \fB\s-1TEXT OPTIONS\s0\fR section for more information. .IP "\fB\-noout\fR" 4 .IX Item "-noout" this option prevents output of the encoded version of the request. .IP "\fB\-pubkey\fR" 4 .IX Item "-pubkey" outputs the the certificate's SubjectPublicKeyInfo block in \s-1PEM\s0 format. .IP "\fB\-modulus\fR" 4 .IX Item "-modulus" this option prints out the value of the modulus of the public key contained in the certificate. .IP "\fB\-serial\fR" 4 .IX Item "-serial" outputs the certificate serial number. .IP "\fB\-subject_hash\fR" 4 .IX Item "-subject_hash" outputs the \*(L"hash\*(R" of the certificate subject name. This is used in OpenSSL to form an index to allow certificates in a directory to be looked up by subject name. .IP "\fB\-issuer_hash\fR" 4 .IX Item "-issuer_hash" outputs the \*(L"hash\*(R" of the certificate issuer name. .IP "\fB\-hash\fR" 4 .IX Item "-hash" synonym for \*(L"\-subject_hash\*(R" for backward compatibility reasons. .IP "\fB\-subject_hash_old\fR" 4 .IX Item "-subject_hash_old" outputs the \*(L"hash\*(R" of the certificate subject name using the older algorithm as used by OpenSSL versions before 1.0.0. .IP "\fB\-issuer_hash_old\fR" 4 .IX Item "-issuer_hash_old" outputs the \*(L"hash\*(R" of the certificate issuer name using the older algorithm as used by OpenSSL versions before 1.0.0. .IP "\fB\-subject\fR" 4 .IX Item "-subject" outputs the subject name. .IP "\fB\-issuer\fR" 4 .IX Item "-issuer" outputs the issuer name. .IP "\fB\-nameopt option\fR" 4 .IX Item "-nameopt option" option which determines how the subject or issuer names are displayed. The \&\fBoption\fR argument can be a single option or multiple options separated by commas. Alternatively the \fB\-nameopt\fR switch may be used more than once to set multiple options. See the \fB\s-1NAME OPTIONS\s0\fR section for more information. .IP "\fB\-email\fR" 4 .IX Item "-email" outputs the email address(es) if any. .IP "\fB\-ocsp_uri\fR" 4 .IX Item "-ocsp_uri" outputs the \s-1OCSP\s0 responder address(es) if any. .IP "\fB\-startdate\fR" 4 .IX Item "-startdate" prints out the start date of the certificate, that is the notBefore date. .IP "\fB\-enddate\fR" 4 .IX Item "-enddate" prints out the expiry date of the certificate, that is the notAfter date. .IP "\fB\-dates\fR" 4 .IX Item "-dates" prints out the start and expiry dates of a certificate. .IP "\fB\-fingerprint\fR" 4 .IX Item "-fingerprint" prints out the digest of the \s-1DER\s0 encoded version of the whole certificate (see digest options). .IP "\fB\-C\fR" 4 .IX Item "-C" this outputs the certificate in the form of a C source file. .SS "\s-1TRUST SETTINGS\s0" .IX Subsection "TRUST SETTINGS" Please note these options are currently experimental and may well change. .PP A \fBtrusted certificate\fR is an ordinary certificate which has several additional pieces of information attached to it such as the permitted and prohibited uses of the certificate and an \*(L"alias\*(R". .PP Normally when a certificate is being verified at least one certificate must be \*(L"trusted\*(R". By default a trusted certificate must be stored locally and must be a root \s-1CA:\s0 any certificate chain ending in this \s-1CA\s0 is then usable for any purpose. .PP Trust settings currently are only used with a root \s-1CA.\s0 They allow a finer control over the purposes the root \s-1CA\s0 can be used for. For example a \s-1CA\s0 may be trusted for \s-1SSL\s0 client but not \s-1SSL\s0 server use. .PP See the description of the \fBverify\fR utility for more information on the meaning of trust settings. .PP Future versions of OpenSSL will recognize trust settings on any certificate: not just root CAs. .IP "\fB\-trustout\fR" 4 .IX Item "-trustout" this causes \fBx509\fR to output a \fBtrusted\fR certificate. An ordinary or trusted certificate can be input but by default an ordinary certificate is output and any trust settings are discarded. With the \&\fB\-trustout\fR option a trusted certificate is output. A trusted certificate is automatically output if any trust settings are modified. .IP "\fB\-setalias arg\fR" 4 .IX Item "-setalias arg" sets the alias of the certificate. This will allow the certificate to be referred to using a nickname for example \*(L"Steve's Certificate\*(R". .IP "\fB\-alias\fR" 4 .IX Item "-alias" outputs the certificate alias, if any. .IP "\fB\-clrtrust\fR" 4 .IX Item "-clrtrust" clears all the permitted or trusted uses of the certificate. .IP "\fB\-clrreject\fR" 4 .IX Item "-clrreject" clears all the prohibited or rejected uses of the certificate. .IP "\fB\-addtrust arg\fR" 4 .IX Item "-addtrust arg" adds a trusted certificate use. Any object name can be used here but currently only \fBclientAuth\fR (\s-1SSL\s0 client use), \fBserverAuth\fR (\s-1SSL\s0 server use) and \fBemailProtection\fR (S/MIME email) are used. Other OpenSSL applications may define additional uses. .IP "\fB\-addreject arg\fR" 4 .IX Item "-addreject arg" adds a prohibited use. It accepts the same values as the \fB\-addtrust\fR option. .IP "\fB\-purpose\fR" 4 .IX Item "-purpose" this option performs tests on the certificate extensions and outputs the results. For a more complete description see the \fB\s-1CERTIFICATE EXTENSIONS\s0\fR section. .SS "\s-1SIGNING OPTIONS\s0" .IX Subsection "SIGNING OPTIONS" The \fBx509\fR utility can be used to sign certificates and requests: it can thus behave like a \*(L"mini \s-1CA\*(R".\s0 .IP "\fB\-signkey filename\fR" 4 .IX Item "-signkey filename" this option causes the input file to be self signed using the supplied private key. .Sp If the input file is a certificate it sets the issuer name to the subject name (i.e. makes it self signed) changes the public key to the supplied value and changes the start and end dates. The start date is set to the current time and the end date is set to a value determined by the \fB\-days\fR option. Any certificate extensions are retained unless the \fB\-clrext\fR option is supplied. .Sp If the input is a certificate request then a self signed certificate is created using the supplied private key using the subject name in the request. .IP "\fB\-clrext\fR" 4 .IX Item "-clrext" delete any extensions from a certificate. This option is used when a certificate is being created from another certificate (for example with the \fB\-signkey\fR or the \fB\-CA\fR options). Normally all extensions are retained. .IP "\fB\-keyform PEM|DER\fR" 4 .IX Item "-keyform PEM|DER" specifies the format (\s-1DER\s0 or \s-1PEM\s0) of the private key file used in the \&\fB\-signkey\fR option. .IP "\fB\-days arg\fR" 4 .IX Item "-days arg" specifies the number of days to make a certificate valid for. The default is 30 days. .IP "\fB\-x509toreq\fR" 4 .IX Item "-x509toreq" converts a certificate into a certificate request. The \fB\-signkey\fR option is used to pass the required private key. .IP "\fB\-req\fR" 4 .IX Item "-req" by default a certificate is expected on input. With this option a certificate request is expected instead. .IP "\fB\-set_serial n\fR" 4 .IX Item "-set_serial n" specifies the serial number to use. This option can be used with either the \fB\-signkey\fR or \fB\-CA\fR options. If used in conjunction with the \fB\-CA\fR option the serial number file (as specified by the \fB\-CAserial\fR or \&\fB\-CAcreateserial\fR options) is not used. .Sp The serial number can be decimal or hex (if preceded by \fB0x\fR). Negative serial numbers can also be specified but their use is not recommended. .IP "\fB\-CA filename\fR" 4 .IX Item "-CA filename" specifies the \s-1CA\s0 certificate to be used for signing. When this option is present \fBx509\fR behaves like a \*(L"mini \s-1CA\*(R".\s0 The input file is signed by this \&\s-1CA\s0 using this option: that is its issuer name is set to the subject name of the \s-1CA\s0 and it is digitally signed using the CAs private key. .Sp This option is normally combined with the \fB\-req\fR option. Without the \&\fB\-req\fR option the input is a certificate which must be self signed. .IP "\fB\-CAkey filename\fR" 4 .IX Item "-CAkey filename" sets the \s-1CA\s0 private key to sign a certificate with. If this option is not specified then it is assumed that the \s-1CA\s0 private key is present in the \s-1CA\s0 certificate file. .IP "\fB\-CAserial filename\fR" 4 .IX Item "-CAserial filename" sets the \s-1CA\s0 serial number file to use. .Sp When the \fB\-CA\fR option is used to sign a certificate it uses a serial number specified in a file. This file consist of one line containing an even number of hex digits with the serial number to use. After each use the serial number is incremented and written out to the file again. .Sp The default filename consists of the \s-1CA\s0 certificate file base name with \&\*(L".srl\*(R" appended. For example if the \s-1CA\s0 certificate file is called \&\*(L"mycacert.pem\*(R" it expects to find a serial number file called \*(L"mycacert.srl\*(R". .IP "\fB\-CAcreateserial\fR" 4 .IX Item "-CAcreateserial" with this option the \s-1CA\s0 serial number file is created if it does not exist: it will contain the serial number \*(L"02\*(R" and the certificate being signed will have the 1 as its serial number. Normally if the \fB\-CA\fR option is specified and the serial number file does not exist it is an error. .IP "\fB\-extfile filename\fR" 4 .IX Item "-extfile filename" file containing certificate extensions to use. If not specified then no extensions are added to the certificate. .IP "\fB\-extensions section\fR" 4 .IX Item "-extensions section" the section to add certificate extensions from. If this option is not specified then the extensions should either be contained in the unnamed (default) section or the default section should contain a variable called \&\*(L"extensions\*(R" which contains the section to use. See the \&\fIx509v3_config\fR\|(5) manual page for details of the extension section format. .SS "\s-1NAME OPTIONS\s0" .IX Subsection "NAME OPTIONS" The \fBnameopt\fR command line switch determines how the subject and issuer names are displayed. If no \fBnameopt\fR switch is present the default \*(L"oneline\*(R" format is used which is compatible with previous versions of OpenSSL. Each option is described in detail below, all options can be preceded by a \fB\-\fR to turn the option off. Only the first four will normally be used. .IP "\fBcompat\fR" 4 .IX Item "compat" use the old format. This is equivalent to specifying no name options at all. .IP "\fB\s-1RFC2253\s0\fR" 4 .IX Item "RFC2253" displays names compatible with \s-1RFC2253\s0 equivalent to \fBesc_2253\fR, \fBesc_ctrl\fR, \&\fBesc_msb\fR, \fButf8\fR, \fBdump_nostr\fR, \fBdump_unknown\fR, \fBdump_der\fR, \&\fBsep_comma_plus\fR, \fBdn_rev\fR and \fBsname\fR. .IP "\fBoneline\fR" 4 .IX Item "oneline" a oneline format which is more readable than \s-1RFC2253.\s0 It is equivalent to specifying the \fBesc_2253\fR, \fBesc_ctrl\fR, \fBesc_msb\fR, \fButf8\fR, \fBdump_nostr\fR, \&\fBdump_der\fR, \fBuse_quote\fR, \fBsep_comma_plus_space\fR, \fBspace_eq\fR and \fBsname\fR options. .IP "\fBmultiline\fR" 4 .IX Item "multiline" a multiline format. It is equivalent \fBesc_ctrl\fR, \fBesc_msb\fR, \fBsep_multiline\fR, \&\fBspace_eq\fR, \fBlname\fR and \fBalign\fR. .IP "\fBesc_2253\fR" 4 .IX Item "esc_2253" escape the \*(L"special\*(R" characters required by \s-1RFC2253\s0 in a field That is \&\fB,+"<>;\fR. Additionally \fB#\fR is escaped at the beginning of a string and a space character at the beginning or end of a string. .IP "\fBesc_ctrl\fR" 4 .IX Item "esc_ctrl" escape control characters. That is those with \s-1ASCII\s0 values less than 0x20 (space) and the delete (0x7f) character. They are escaped using the \&\s-1RFC2253\s0 \eXX notation (where \s-1XX\s0 are two hex digits representing the character value). .IP "\fBesc_msb\fR" 4 .IX Item "esc_msb" escape characters with the \s-1MSB\s0 set, that is with \s-1ASCII\s0 values larger than 127. .IP "\fBuse_quote\fR" 4 .IX Item "use_quote" escapes some characters by surrounding the whole string with \fB"\fR characters, without the option all escaping is done with the \fB\e\fR character. .IP "\fButf8\fR" 4 .IX Item "utf8" convert all strings to \s-1UTF8\s0 format first. This is required by \s-1RFC2253.\s0 If you are lucky enough to have a \s-1UTF8\s0 compatible terminal then the use of this option (and \fBnot\fR setting \fBesc_msb\fR) may result in the correct display of multibyte (international) characters. Is this option is not present then multibyte characters larger than 0xff will be represented using the format \eUXXXX for 16 bits and \eWXXXXXXXX for 32 bits. Also if this option is off any UTF8Strings will be converted to their character form first. .IP "\fBno_type\fR" 4 .IX Item "no_type" this option does not attempt to interpret multibyte characters in any way. That is their content octets are merely dumped as though one octet represents each character. This is useful for diagnostic purposes but will result in rather odd looking output. .IP "\fBshow_type\fR" 4 .IX Item "show_type" show the type of the \s-1ASN1\s0 character string. The type precedes the field contents. For example \*(L"\s-1BMPSTRING:\s0 Hello World\*(R". .IP "\fBdump_der\fR" 4 .IX Item "dump_der" when this option is set any fields that need to be hexdumped will be dumped using the \s-1DER\s0 encoding of the field. Otherwise just the content octets will be displayed. Both options use the \s-1RFC2253 \&\s0\fB#XXXX...\fR format. .IP "\fBdump_nostr\fR" 4 .IX Item "dump_nostr" dump non character string types (for example \s-1OCTET STRING\s0) if this option is not set then non character string types will be displayed as though each content octet represents a single character. .IP "\fBdump_all\fR" 4 .IX Item "dump_all" dump all fields. This option when used with \fBdump_der\fR allows the \&\s-1DER\s0 encoding of the structure to be unambiguously determined. .IP "\fBdump_unknown\fR" 4 .IX Item "dump_unknown" dump any field whose \s-1OID\s0 is not recognised by OpenSSL. .IP "\fBsep_comma_plus\fR, \fBsep_comma_plus_space\fR, \fBsep_semi_plus_space\fR, \fBsep_multiline\fR" 4 .IX Item "sep_comma_plus, sep_comma_plus_space, sep_semi_plus_space, sep_multiline" these options determine the field separators. The first character is between RDNs and the second between multiple AVAs (multiple AVAs are very rare and their use is discouraged). The options ending in \&\*(L"space\*(R" additionally place a space after the separator to make it more readable. The \fBsep_multiline\fR uses a linefeed character for the \s-1RDN\s0 separator and a spaced \fB+\fR for the \s-1AVA\s0 separator. It also indents the fields by four characters. .IP "\fBdn_rev\fR" 4 .IX Item "dn_rev" reverse the fields of the \s-1DN.\s0 This is required by \s-1RFC2253.\s0 As a side effect this also reverses the order of multiple AVAs but this is permissible. .IP "\fBnofname\fR, \fBsname\fR, \fBlname\fR, \fBoid\fR" 4 .IX Item "nofname, sname, lname, oid" these options alter how the field name is displayed. \fBnofname\fR does not display the field at all. \fBsname\fR uses the \*(L"short name\*(R" form (\s-1CN\s0 for commonName for example). \fBlname\fR uses the long form. \&\fBoid\fR represents the \s-1OID\s0 in numerical form and is useful for diagnostic purpose. .IP "\fBalign\fR" 4 .IX Item "align" align field values for a more readable output. Only usable with \&\fBsep_multiline\fR. .IP "\fBspace_eq\fR" 4 .IX Item "space_eq" places spaces round the \fB=\fR character which follows the field name. .SS "\s-1TEXT OPTIONS\s0" .IX Subsection "TEXT OPTIONS" As well as customising the name output format, it is also possible to customise the actual fields printed using the \fBcertopt\fR options when the \fBtext\fR option is present. The default behaviour is to print all fields. .IP "\fBcompatible\fR" 4 .IX Item "compatible" use the old format. This is equivalent to specifying no output options at all. .IP "\fBno_header\fR" 4 .IX Item "no_header" don't print header information: that is the lines saying \*(L"Certificate\*(R" and \*(L"Data\*(R". .IP "\fBno_version\fR" 4 .IX Item "no_version" don't print out the version number. .IP "\fBno_serial\fR" 4 .IX Item "no_serial" don't print out the serial number. .IP "\fBno_signame\fR" 4 .IX Item "no_signame" don't print out the signature algorithm used. .IP "\fBno_validity\fR" 4 .IX Item "no_validity" don't print the validity, that is the \fBnotBefore\fR and \fBnotAfter\fR fields. .IP "\fBno_subject\fR" 4 .IX Item "no_subject" don't print out the subject name. .IP "\fBno_issuer\fR" 4 .IX Item "no_issuer" don't print out the issuer name. .IP "\fBno_pubkey\fR" 4 .IX Item "no_pubkey" don't print out the public key. .IP "\fBno_sigdump\fR" 4 .IX Item "no_sigdump" don't give a hexadecimal dump of the certificate signature. .IP "\fBno_aux\fR" 4 .IX Item "no_aux" don't print out certificate trust information. .IP "\fBno_extensions\fR" 4 .IX Item "no_extensions" don't print out any X509V3 extensions. .IP "\fBext_default\fR" 4 .IX Item "ext_default" retain default extension behaviour: attempt to print out unsupported certificate extensions. .IP "\fBext_error\fR" 4 .IX Item "ext_error" print an error message for unsupported certificate extensions. .IP "\fBext_parse\fR" 4 .IX Item "ext_parse" \&\s-1ASN1\s0 parse unsupported extensions. .IP "\fBext_dump\fR" 4 .IX Item "ext_dump" hex dump unsupported extensions. .IP "\fBca_default\fR" 4 .IX Item "ca_default" the value used by the \fBca\fR utility, equivalent to \fBno_issuer\fR, \fBno_pubkey\fR, \fBno_header\fR, \&\fBno_version\fR, \fBno_sigdump\fR and \fBno_signame\fR. .SH "EXAMPLES" .IX Header "EXAMPLES" Note: in these examples the '\e' means the example should be all on one line. .PP Display the contents of a certificate: .PP .Vb 1 \& openssl x509 \-in cert.pem \-noout \-text .Ve .PP Display the certificate serial number: .PP .Vb 1 \& openssl x509 \-in cert.pem \-noout \-serial .Ve .PP Display the certificate subject name: .PP .Vb 1 \& openssl x509 \-in cert.pem \-noout \-subject .Ve .PP Display the certificate subject name in \s-1RFC2253\s0 form: .PP .Vb 1 \& openssl x509 \-in cert.pem \-noout \-subject \-nameopt RFC2253 .Ve .PP Display the certificate subject name in oneline form on a terminal supporting \s-1UTF8:\s0 .PP .Vb 1 \& openssl x509 \-in cert.pem \-noout \-subject \-nameopt oneline,\-esc_msb .Ve .PP Display the certificate \s-1MD5\s0 fingerprint: .PP .Vb 1 \& openssl x509 \-in cert.pem \-noout \-fingerprint .Ve .PP Display the certificate \s-1SHA1\s0 fingerprint: .PP .Vb 1 \& openssl x509 \-sha1 \-in cert.pem \-noout \-fingerprint .Ve .PP Convert a certificate from \s-1PEM\s0 to \s-1DER\s0 format: .PP .Vb 1 \& openssl x509 \-in cert.pem \-inform PEM \-out cert.der \-outform DER .Ve .PP Convert a certificate to a certificate request: .PP .Vb 1 \& openssl x509 \-x509toreq \-in cert.pem \-out req.pem \-signkey key.pem .Ve .PP Convert a certificate request into a self signed certificate using extensions for a \s-1CA:\s0 .PP .Vb 2 \& openssl x509 \-req \-in careq.pem \-extfile openssl.cnf \-extensions v3_ca \e \& \-signkey key.pem \-out cacert.pem .Ve .PP Sign a certificate request using the \s-1CA\s0 certificate above and add user certificate extensions: .PP .Vb 2 \& openssl x509 \-req \-in req.pem \-extfile openssl.cnf \-extensions v3_usr \e \& \-CA cacert.pem \-CAkey key.pem \-CAcreateserial .Ve .PP Set a certificate to be trusted for \s-1SSL\s0 client use and change set its alias to \&\*(L"Steve's Class 1 \s-1CA\*(R"\s0 .PP .Vb 2 \& openssl x509 \-in cert.pem \-addtrust clientAuth \e \& \-setalias "Steve\*(Aqs Class 1 CA" \-out trust.pem .Ve .SH "NOTES" .IX Header "NOTES" The \s-1PEM\s0 format uses the header and footer lines: .PP .Vb 2 \& \-\-\-\-\-BEGIN CERTIFICATE\-\-\-\-\- \& \-\-\-\-\-END CERTIFICATE\-\-\-\-\- .Ve .PP it will also handle files containing: .PP .Vb 2 \& \-\-\-\-\-BEGIN X509 CERTIFICATE\-\-\-\-\- \& \-\-\-\-\-END X509 CERTIFICATE\-\-\-\-\- .Ve .PP Trusted certificates have the lines .PP .Vb 2 \& \-\-\-\-\-BEGIN TRUSTED CERTIFICATE\-\-\-\-\- \& \-\-\-\-\-END TRUSTED CERTIFICATE\-\-\-\-\- .Ve .PP The conversion to \s-1UTF8\s0 format used with the name options assumes that T61Strings use the \s-1ISO8859\-1\s0 character set. This is wrong but Netscape and \s-1MSIE\s0 do this as do many certificates. So although this is incorrect it is more likely to display the majority of certificates correctly. .PP The \fB\-fingerprint\fR option takes the digest of the \s-1DER\s0 encoded certificate. This is commonly called a \*(L"fingerprint\*(R". Because of the nature of message digests the fingerprint of a certificate is unique to that certificate and two certificates with the same fingerprint can be considered to be the same. .PP The Netscape fingerprint uses \s-1MD5\s0 whereas \s-1MSIE\s0 uses \s-1SHA1.\s0 .PP The \fB\-email\fR option searches the subject name and the subject alternative name extension. Only unique email addresses will be printed out: it will not print the same address more than once. .SH "CERTIFICATE EXTENSIONS" .IX Header "CERTIFICATE EXTENSIONS" The \fB\-purpose\fR option checks the certificate extensions and determines what the certificate can be used for. The actual checks done are rather complex and include various hacks and workarounds to handle broken certificates and software. .PP The same code is used when verifying untrusted certificates in chains so this section is useful if a chain is rejected by the verify code. .PP The basicConstraints extension \s-1CA\s0 flag is used to determine whether the certificate can be used as a \s-1CA.\s0 If the \s-1CA\s0 flag is true then it is a \s-1CA,\s0 if the \s-1CA\s0 flag is false then it is not a \s-1CA. \s0\fBAll\fR CAs should have the \&\s-1CA\s0 flag set to true. .PP If the basicConstraints extension is absent then the certificate is considered to be a \*(L"possible \s-1CA\*(R"\s0 other extensions are checked according to the intended use of the certificate. A warning is given in this case because the certificate should really not be regarded as a \s-1CA:\s0 however it is allowed to be a \s-1CA\s0 to work around some broken software. .PP If the certificate is a V1 certificate (and thus has no extensions) and it is self signed it is also assumed to be a \s-1CA\s0 but a warning is again given: this is to work around the problem of Verisign roots which are V1 self signed certificates. .PP If the keyUsage extension is present then additional restraints are made on the uses of the certificate. A \s-1CA\s0 certificate \fBmust\fR have the keyCertSign bit set if the keyUsage extension is present. .PP The extended key usage extension places additional restrictions on the certificate uses. If this extension is present (whether critical or not) the key can only be used for the purposes specified. .PP A complete description of each test is given below. The comments about basicConstraints and keyUsage and V1 certificates above apply to \fBall\fR \&\s-1CA\s0 certificates. .IP "\fB\s-1SSL\s0 Client\fR" 4 .IX Item "SSL Client" The extended key usage extension must be absent or include the \*(L"web client authentication\*(R" \s-1OID. \s0 keyUsage must be absent or it must have the digitalSignature bit set. Netscape certificate type must be absent or it must have the \s-1SSL\s0 client bit set. .IP "\fB\s-1SSL\s0 Client \s-1CA\s0\fR" 4 .IX Item "SSL Client CA" The extended key usage extension must be absent or include the \*(L"web client authentication\*(R" \s-1OID.\s0 Netscape certificate type must be absent or it must have the \s-1SSL CA\s0 bit set: this is used as a work around if the basicConstraints extension is absent. .IP "\fB\s-1SSL\s0 Server\fR" 4 .IX Item "SSL Server" The extended key usage extension must be absent or include the \*(L"web server authentication\*(R" and/or one of the \s-1SGC\s0 OIDs. keyUsage must be absent or it must have the digitalSignature, the keyEncipherment set or both bits set. Netscape certificate type must be absent or have the \s-1SSL\s0 server bit set. .IP "\fB\s-1SSL\s0 Server \s-1CA\s0\fR" 4 .IX Item "SSL Server CA" The extended key usage extension must be absent or include the \*(L"web server authentication\*(R" and/or one of the \s-1SGC\s0 OIDs. Netscape certificate type must be absent or the \s-1SSL CA\s0 bit must be set: this is used as a work around if the basicConstraints extension is absent. .IP "\fBNetscape \s-1SSL\s0 Server\fR" 4 .IX Item "Netscape SSL Server" For Netscape \s-1SSL\s0 clients to connect to an \s-1SSL\s0 server it must have the keyEncipherment bit set if the keyUsage extension is present. This isn't always valid because some cipher suites use the key for digital signing. Otherwise it is the same as a normal \s-1SSL\s0 server. .IP "\fBCommon S/MIME Client Tests\fR" 4 .IX Item "Common S/MIME Client Tests" The extended key usage extension must be absent or include the \*(L"email protection\*(R" \s-1OID.\s0 Netscape certificate type must be absent or should have the S/MIME bit set. If the S/MIME bit is not set in netscape certificate type then the \s-1SSL\s0 client bit is tolerated as an alternative but a warning is shown: this is because some Verisign certificates don't set the S/MIME bit. .IP "\fBS/MIME Signing\fR" 4 .IX Item "S/MIME Signing" In addition to the common S/MIME client tests the digitalSignature bit must be set if the keyUsage extension is present. .IP "\fBS/MIME Encryption\fR" 4 .IX Item "S/MIME Encryption" In addition to the common S/MIME tests the keyEncipherment bit must be set if the keyUsage extension is present. .IP "\fBS/MIME \s-1CA\s0\fR" 4 .IX Item "S/MIME CA" The extended key usage extension must be absent or include the \*(L"email protection\*(R" \s-1OID.\s0 Netscape certificate type must be absent or must have the S/MIME \s-1CA\s0 bit set: this is used as a work around if the basicConstraints extension is absent. .IP "\fB\s-1CRL\s0 Signing\fR" 4 .IX Item "CRL Signing" The keyUsage extension must be absent or it must have the \s-1CRL\s0 signing bit set. .IP "\fB\s-1CRL\s0 Signing \s-1CA\s0\fR" 4 .IX Item "CRL Signing CA" The normal \s-1CA\s0 tests apply. Except in this case the basicConstraints extension must be present. .SH "BUGS" .IX Header "BUGS" Extensions in certificates are not transferred to certificate requests and vice versa. .PP It is possible to produce invalid certificates or requests by specifying the wrong private key or using inconsistent options in some cases: these should be checked. .PP There should be options to explicitly set such things as start and end dates rather than an offset from the current time. .PP The code to implement the verify behaviour described in the \fB\s-1TRUST SETTINGS\s0\fR is currently being developed. It thus describes the intended behaviour rather than the current behaviour. It is hoped that it will represent reality in OpenSSL 0.9.5 and later. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIreq\fR\|(1), \fIca\fR\|(1), \fIgenrsa\fR\|(1), \&\fIgendsa\fR\|(1), \fIverify\fR\|(1), \&\fIx509v3_config\fR\|(5) .SH "HISTORY" .IX Header "HISTORY" Before OpenSSL 0.9.8, the default digest for \s-1RSA\s0 keys was \s-1MD5.\s0 .PP The hash algorithm used in the \fB\-subject_hash\fR and \fB\-issuer_hash\fR options before OpenSSL 1.0.0 was based on the deprecated \s-1MD5\s0 algorithm and the encoding of the distinguished name. In OpenSSL 1.0.0 and later it is based on a canonical version of the \s-1DN\s0 using \s-1SHA1.\s0 This means that any directories using the old form must have their links rebuilt. deps/libressl-pnacl-sys-2.1.6/libressl/man/CMS_get0_RecipientInfos.30000644000175000017500000002247112360020713022141 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CMS_get0_RecipientInfos 3" .TH CMS_get0_RecipientInfos 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CMS_get0_RecipientInfos, CMS_RecipientInfo_type, CMS_RecipientInfo_ktri_get0_signer_id,CMS_RecipientInfo_ktri_cert_cmp, CMS_RecipientInfo_set0_pkey, CMS_RecipientInfo_kekri_get0_id, CMS_RecipientInfo_kekri_id_cmp, CMS_RecipientInfo_set0_key, CMS_RecipientInfo_decrypt, CMS_RecipientInfo_encrypt \- CMS envelopedData RecipientInfo routines .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& STACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms); \& int CMS_RecipientInfo_type(CMS_RecipientInfo *ri); \& \& int CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri, ASN1_OCTET_STRING **keyid, X509_NAME **issuer, ASN1_INTEGER **sno); \& int CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert); \& int CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey); \& \& int CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri, X509_ALGOR **palg, ASN1_OCTET_STRING **pid, ASN1_GENERALIZEDTIME **pdate, ASN1_OBJECT **potherid, ASN1_TYPE **pothertype); \& int CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri, const unsigned char *id, size_t idlen); \& int CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri, unsigned char *key, size_t keylen); \& \& int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The function \fICMS_get0_RecipientInfos()\fR returns all the CMS_RecipientInfo structures associated with a \s-1CMS\s0 EnvelopedData structure. .PP \&\fICMS_RecipientInfo_type()\fR returns the type of CMS_RecipientInfo structure \fBri\fR. It will currently return \s-1CMS_RECIPINFO_TRANS, CMS_RECIPINFO_AGREE, CMS_RECIPINFO_KEK, CMS_RECIPINFO_PASS,\s0 or \s-1CMS_RECIPINFO_OTHER.\s0 .PP \&\fICMS_RecipientInfo_ktri_get0_signer_id()\fR retrieves the certificate recipient identifier associated with a specific CMS_RecipientInfo structure \fBri\fR, which must be of type \s-1CMS_RECIPINFO_TRANS.\s0 Either the keyidentifier will be set in \&\fBkeyid\fR or \fBboth\fR issuer name and serial number in \fBissuer\fR and \fBsno\fR. .PP \&\fICMS_RecipientInfo_ktri_cert_cmp()\fR compares the certificate \fBcert\fR against the CMS_RecipientInfo structure \fBri\fR, which must be of type \s-1CMS_RECIPINFO_TRANS.\s0 It returns zero if the comparison is successful and non zero if not. .PP \&\fICMS_RecipientInfo_set0_pkey()\fR associates the private key \fBpkey\fR with the CMS_RecipientInfo structure \fBri\fR, which must be of type \&\s-1CMS_RECIPINFO_TRANS.\s0 .PP \&\fICMS_RecipientInfo_kekri_get0_id()\fR retrieves the key information from the CMS_RecipientInfo structure \fBri\fR which must be of type \s-1CMS_RECIPINFO_KEK. \s0 Any of the remaining parameters can be \s-1NULL\s0 if the application is not interested in the value of a field. Where a field is optional and absent \s-1NULL\s0 will be written to the corresponding parameter. The keyEncryptionAlgorithm field is written to \&\fBpalg\fR, the \fBkeyIdentifier\fR field is written to \fBpid\fR, the \fBdate\fR field if present is written to \fBpdate\fR, if the \fBother\fR field is present the components \&\fBkeyAttrId\fR and \fBkeyAttr\fR are written to parameters \fBpotherid\fR and \&\fBpothertype\fR. .PP \&\fICMS_RecipientInfo_kekri_id_cmp()\fR compares the \s-1ID\s0 in the \fBid\fR and \fBidlen\fR parameters against the \fBkeyIdentifier\fR CMS_RecipientInfo structure \fBri\fR, which must be of type \s-1CMS_RECIPINFO_KEK. \s0 It returns zero if the comparison is successful and non zero if not. .PP \&\fICMS_RecipientInfo_set0_key()\fR associates the symmetric key \fBkey\fR of length \&\fBkeylen\fR with the CMS_RecipientInfo structure \fBri\fR, which must be of type \&\s-1CMS_RECIPINFO_KEK.\s0 .PP \&\fICMS_RecipientInfo_decrypt()\fR attempts to decrypt CMS_RecipientInfo structure \&\fBri\fR in structure \fBcms\fR. A key must have been associated with the structure first. .SH "NOTES" .IX Header "NOTES" The main purpose of these functions is to enable an application to lookup recipient keys using any appropriate technique when the simpler method of \fICMS_decrypt()\fR is not appropriate. .PP In typical usage and application will retrieve all CMS_RecipientInfo structures using \fICMS_get0_RecipientInfos()\fR and check the type of each using \&\fICMS_RecpientInfo_type()\fR. Depending on the type the CMS_RecipientInfo structure can be ignored or its key identifier data retrieved using an appropriate function. Then if the corresponding secret or private key can be obtained by any appropriate means it can then associated with the structure and \&\fICMS_RecpientInfo_decrypt()\fR called. If successful \fICMS_decrypt()\fR can be called with a \s-1NULL\s0 key to decrypt the enveloped content. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICMS_get0_RecipientInfos()\fR returns all CMS_RecipientInfo structures, or \s-1NULL\s0 if an error occurs. .PP \&\fICMS_RecipientInfo_ktri_get0_signer_id()\fR, \fICMS_RecipientInfo_set0_pkey()\fR, \&\fICMS_RecipientInfo_kekri_get0_id()\fR, \fICMS_RecipientInfo_set0_key()\fR and \&\fICMS_RecipientInfo_decrypt()\fR return 1 for success or 0 if an error occurs. .PP \&\fICMS_RecipientInfo_ktri_cert_cmp()\fR and \fICMS_RecipientInfo_kekri_cmp()\fR return 0 for a successful comparison and non zero otherwise. .PP Any error can be obtained from \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_decrypt\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" These functions were first was added to OpenSSL 0.9.8 deps/libressl-pnacl-sys-2.1.6/libressl/man/bn.30000644000175000017500000002625112360020726016202 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "bn 3" .TH bn 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" bn \- multiprecision integer arithmetics .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIGNUM *BN_new(void); \& void BN_free(BIGNUM *a); \& void BN_init(BIGNUM *); \& void BN_clear(BIGNUM *a); \& void BN_clear_free(BIGNUM *a); \& \& BN_CTX *BN_CTX_new(void); \& void BN_CTX_init(BN_CTX *c); \& void BN_CTX_free(BN_CTX *c); \& \& BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); \& BIGNUM *BN_dup(const BIGNUM *a); \& \& BIGNUM *BN_swap(BIGNUM *a, BIGNUM *b); \& \& int BN_num_bytes(const BIGNUM *a); \& int BN_num_bits(const BIGNUM *a); \& int BN_num_bits_word(BN_ULONG w); \& \& void BN_set_negative(BIGNUM *a, int n); \& int BN_is_negative(const BIGNUM *a); \& \& int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); \& int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); \& int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); \& int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx); \& int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d, \& BN_CTX *ctx); \& int BN_mod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); \& int BN_nnmod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); \& int BN_mod_add(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, \& BN_CTX *ctx); \& int BN_mod_sub(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, \& BN_CTX *ctx); \& int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, \& BN_CTX *ctx); \& int BN_mod_sqr(BIGNUM *ret, BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); \& int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx); \& int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, \& const BIGNUM *m, BN_CTX *ctx); \& int BN_gcd(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); \& \& int BN_add_word(BIGNUM *a, BN_ULONG w); \& int BN_sub_word(BIGNUM *a, BN_ULONG w); \& int BN_mul_word(BIGNUM *a, BN_ULONG w); \& BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); \& BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); \& \& int BN_cmp(BIGNUM *a, BIGNUM *b); \& int BN_ucmp(BIGNUM *a, BIGNUM *b); \& int BN_is_zero(BIGNUM *a); \& int BN_is_one(BIGNUM *a); \& int BN_is_word(BIGNUM *a, BN_ULONG w); \& int BN_is_odd(BIGNUM *a); \& \& int BN_zero(BIGNUM *a); \& int BN_one(BIGNUM *a); \& const BIGNUM *BN_value_one(void); \& int BN_set_word(BIGNUM *a, unsigned long w); \& unsigned long BN_get_word(BIGNUM *a); \& \& int BN_rand(BIGNUM *rnd, int bits, int top, int bottom); \& int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom); \& int BN_rand_range(BIGNUM *rnd, BIGNUM *range); \& int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range); \& \& BIGNUM *BN_generate_prime(BIGNUM *ret, int bits,int safe, BIGNUM *add, \& BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg); \& int BN_is_prime(const BIGNUM *p, int nchecks, \& void (*callback)(int, int, void *), BN_CTX *ctx, void *cb_arg); \& \& int BN_set_bit(BIGNUM *a, int n); \& int BN_clear_bit(BIGNUM *a, int n); \& int BN_is_bit_set(const BIGNUM *a, int n); \& int BN_mask_bits(BIGNUM *a, int n); \& int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); \& int BN_lshift1(BIGNUM *r, BIGNUM *a); \& int BN_rshift(BIGNUM *r, BIGNUM *a, int n); \& int BN_rshift1(BIGNUM *r, BIGNUM *a); \& \& int BN_bn2bin(const BIGNUM *a, unsigned char *to); \& BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret); \& char *BN_bn2hex(const BIGNUM *a); \& char *BN_bn2dec(const BIGNUM *a); \& int BN_hex2bn(BIGNUM **a, const char *str); \& int BN_dec2bn(BIGNUM **a, const char *str); \& int BN_print(BIO *fp, const BIGNUM *a); \& int BN_print_fp(FILE *fp, const BIGNUM *a); \& int BN_bn2mpi(const BIGNUM *a, unsigned char *to); \& BIGNUM *BN_mpi2bn(unsigned char *s, int len, BIGNUM *ret); \& \& BIGNUM *BN_mod_inverse(BIGNUM *r, BIGNUM *a, const BIGNUM *n, \& BN_CTX *ctx); \& \& BN_RECP_CTX *BN_RECP_CTX_new(void); \& void BN_RECP_CTX_init(BN_RECP_CTX *recp); \& void BN_RECP_CTX_free(BN_RECP_CTX *recp); \& int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *m, BN_CTX *ctx); \& int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *a, BIGNUM *b, \& BN_RECP_CTX *recp, BN_CTX *ctx); \& \& BN_MONT_CTX *BN_MONT_CTX_new(void); \& void BN_MONT_CTX_init(BN_MONT_CTX *ctx); \& void BN_MONT_CTX_free(BN_MONT_CTX *mont); \& int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *m, BN_CTX *ctx); \& BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from); \& int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b, \& BN_MONT_CTX *mont, BN_CTX *ctx); \& int BN_from_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont, \& BN_CTX *ctx); \& int BN_to_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont, \& BN_CTX *ctx); \& \& BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, \& BIGNUM *mod); \& void BN_BLINDING_free(BN_BLINDING *b); \& int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx); \& int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); \& int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); \& int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, \& BN_CTX *ctx); \& int BN_BLINDING_invert_ex(BIGNUM *n,const BIGNUM *r,BN_BLINDING *b, \& BN_CTX *ctx); \& unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *); \& void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long); \& unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); \& void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); \& BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, \& const BIGNUM *e, BIGNUM *m, BN_CTX *ctx, \& int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, \& const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), \& BN_MONT_CTX *m_ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This library performs arithmetic operations on integers of arbitrary size. It was written for use in public key cryptography, such as \s-1RSA\s0 and Diffie-Hellman. .PP It uses dynamic memory allocation for storing its data structures. That means that there is no limit on the size of the numbers manipulated by these functions, but return values must always be checked in case a memory allocation error has occurred. .PP The basic object in this library is a \fB\s-1BIGNUM\s0\fR. It is used to hold a single large integer. This type should be considered opaque and fields should not be modified or accessed directly. .PP The creation of \fB\s-1BIGNUM\s0\fR objects is described in \fIBN_new\fR\|(3); \&\fIBN_add\fR\|(3) describes most of the arithmetic operations. Comparison is described in \fIBN_cmp\fR\|(3); \fIBN_zero\fR\|(3) describes certain assignments, \fIBN_rand\fR\|(3) the generation of random numbers, \fIBN_generate_prime\fR\|(3) deals with prime numbers and \fIBN_set_bit\fR\|(3) with bit operations. The conversion of \fB\s-1BIGNUM\s0\fRs to external formats is described in \fIBN_bn2bin\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn_internal\fR\|(3), \fIdh\fR\|(3), \fIerr\fR\|(3), \&\fIrand\fR\|(3), \fIrsa\fR\|(3), \fIBN_new\fR\|(3), \&\fIBN_CTX_new\fR\|(3), \fIBN_copy\fR\|(3), \&\fIBN_swap\fR\|(3), \fIBN_num_bytes\fR\|(3), \&\fIBN_add\fR\|(3), \fIBN_add_word\fR\|(3), \&\fIBN_cmp\fR\|(3), \fIBN_zero\fR\|(3), \fIBN_rand\fR\|(3), \&\fIBN_generate_prime\fR\|(3), \fIBN_set_bit\fR\|(3), \&\fIBN_bn2bin\fR\|(3), \fIBN_mod_inverse\fR\|(3), \&\fIBN_mod_mul_reciprocal\fR\|(3), \&\fIBN_mod_mul_montgomery\fR\|(3), \&\fIBN_BLINDING_new\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/pkeyutl.10000644000175000017500000002522012360020742017267 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "pkeyutl 1" .TH pkeyutl 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" pkeyutl \- public key algorithm utility .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBpkeyutl\fR [\fB\-in file\fR] [\fB\-out file\fR] [\fB\-sigfile file\fR] [\fB\-inkey file\fR] [\fB\-keyform PEM|DER\fR] [\fB\-passin arg\fR] [\fB\-peerkey file\fR] [\fB\-peerform PEM|DER\fR] [\fB\-pubin\fR] [\fB\-certin\fR] [\fB\-rev\fR] [\fB\-sign\fR] [\fB\-verify\fR] [\fB\-verifyrecover\fR] [\fB\-encrypt\fR] [\fB\-decrypt\fR] [\fB\-derive\fR] [\fB\-pkeyopt opt:value\fR] [\fB\-hexdump\fR] [\fB\-asn1parse\fR] [\fB\-engine id\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBpkeyutl\fR command can be used to perform public key operations using any supported algorithm. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read data from or standard input if this option is not specified. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" specifies the output filename to write to or standard output by default. .IP "\fB\-inkey file\fR" 4 .IX Item "-inkey file" the input key file, by default it should be a private key. .IP "\fB\-keyform PEM|DER\fR" 4 .IX Item "-keyform PEM|DER" the key format \s-1PEM, DER\s0 or \s-1ENGINE.\s0 .IP "\fB\-passin arg\fR" 4 .IX Item "-passin arg" the input key password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-peerkey file\fR" 4 .IX Item "-peerkey file" the peer key file, used by key derivation (agreement) operations. .IP "\fB\-peerform PEM|DER\fR" 4 .IX Item "-peerform PEM|DER" the peer key format \s-1PEM, DER\s0 or \s-1ENGINE.\s0 .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBpkeyutl\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .IP "\fB\-pubin\fR" 4 .IX Item "-pubin" the input file is a public key. .IP "\fB\-certin\fR" 4 .IX Item "-certin" the input is a certificate containing a public key. .IP "\fB\-rev\fR" 4 .IX Item "-rev" reverse the order of the input buffer. This is useful for some libraries (such as CryptoAPI) which represent the buffer in little endian format. .IP "\fB\-sign\fR" 4 .IX Item "-sign" sign the input data and output the signed result. This requires a private key. .IP "\fB\-verify\fR" 4 .IX Item "-verify" verify the input data against the signature file and indicate if the verification succeeded or failed. .IP "\fB\-verifyrecover\fR" 4 .IX Item "-verifyrecover" verify the input data and output the recovered data. .IP "\fB\-encrypt\fR" 4 .IX Item "-encrypt" encrypt the input data using a public key. .IP "\fB\-decrypt\fR" 4 .IX Item "-decrypt" decrypt the input data using a private key. .IP "\fB\-derive\fR" 4 .IX Item "-derive" derive a shared secret using the peer key. .IP "\fB\-hexdump\fR" 4 .IX Item "-hexdump" hex dump the output data. .IP "\fB\-asn1parse\fR" 4 .IX Item "-asn1parse" asn1parse the output data, this is useful when combined with the \&\fB\-verifyrecover\fR option when an \s-1ASN1\s0 structure is signed. .SH "NOTES" .IX Header "NOTES" The operations and options supported vary according to the key algorithm and its implementation. The OpenSSL operations and options are indicated below. .PP Unless otherwise mentioned all algorithms support the \fBdigest:alg\fR option which specifies the digest in use for sign, verify and verifyrecover operations. The value \fBalg\fR should represent a digest name as used in the \&\fIEVP_get_digestbyname()\fR function for example \fBsha1\fR. .SH "RSA ALGORITHM" .IX Header "RSA ALGORITHM" The \s-1RSA\s0 algorithm supports encrypt, decrypt, sign, verify and verifyrecover operations in general. Some padding modes only support some of these operations however. .IP "\-\fBrsa_padding_mode:mode\fR" 4 .IX Item "-rsa_padding_mode:mode" This sets the \s-1RSA\s0 padding mode. Acceptable values for \fBmode\fR are \fBpkcs1\fR for PKCS#1 padding, \fBsslv23\fR for SSLv23 padding, \fBnone\fR for no padding, \fBoaep\fR for \fB\s-1OAEP\s0\fR mode, \fBx931\fR for X9.31 mode and \fBpss\fR for \s-1PSS.\s0 .Sp In PKCS#1 padding if the message digest is not set then the supplied data is signed or verified directly instead of using a \fBDigestInfo\fR structure. If a digest is set then the a \fBDigestInfo\fR structure is used and its the length must correspond to the digest type. .Sp For \fBoeap\fR mode only encryption and decryption is supported. .Sp For \fBx931\fR if the digest type is set it is used to format the block data otherwise the first byte is used to specify the X9.31 digest \s-1ID.\s0 Sign, verify and verifyrecover are can be performed in this mode. .Sp For \fBpss\fR mode only sign and verify are supported and the digest type must be specified. .IP "\fBrsa_pss_saltlen:len\fR" 4 .IX Item "rsa_pss_saltlen:len" For \fBpss\fR mode only this option specifies the salt length. Two special values are supported: \-1 sets the salt length to the digest length. When signing \-2 sets the salt length to the maximum permissible value. When verifying \-2 causes the salt length to be automatically determined based on the \fB\s-1PSS\s0\fR block structure. .SH "DSA ALGORITHM" .IX Header "DSA ALGORITHM" The \s-1DSA\s0 algorithm supports signing and verification operations only. Currently there are no additional options other than \fBdigest\fR. Only the \s-1SHA1\s0 digest can be used and this digest is assumed by default. .SH "DH ALGORITHM" .IX Header "DH ALGORITHM" The \s-1DH\s0 algorithm only supports the derivation operation and no additional options. .SH "EC ALGORITHM" .IX Header "EC ALGORITHM" The \s-1EC\s0 algorithm supports sign, verify and derive operations. The sign and verify operations use \s-1ECDSA\s0 and derive uses \s-1ECDH.\s0 Currently there are no additional options other than \fBdigest\fR. Only the \s-1SHA1\s0 digest can be used and this digest is assumed by default. .SH "EXAMPLES" .IX Header "EXAMPLES" Sign some data using a private key: .PP .Vb 1 \& openssl pkeyutl \-sign \-in file \-inkey key.pem \-out sig .Ve .PP Recover the signed data (e.g. if an \s-1RSA\s0 key is used): .PP .Vb 1 \& openssl pkeyutl \-verifyrecover \-in sig \-inkey key.pem .Ve .PP Verify the signature (e.g. a \s-1DSA\s0 key): .PP .Vb 1 \& openssl pkeyutl \-verify \-in file \-sigfile sig \-inkey key.pem .Ve .PP Sign data using a message digest value (this is currently only valid for \s-1RSA\s0): .PP .Vb 1 \& openssl pkeyutl \-sign \-in file \-inkey key.pem \-out sig \-pkeyopt digest:sha256 .Ve .PP Derive a shared secret value: .PP .Vb 1 \& openssl pkeyutl \-derive \-inkey key.pem \-peerkey pubkey.pem \-out secret .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIgenpkey\fR\|(1), \fIpkey\fR\|(1), \fIrsautl\fR\|(1) \&\fIdgst\fR\|(1), \fIrsa\fR\|(1), \fIgenrsa\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/SMIME_write_PKCS7.30000644000175000017500000001421312360020725020570 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SMIME_write_PKCS7 3" .TH SMIME_write_PKCS7 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SMIME_write_PKCS7 \- convert PKCS#7 structure to S/MIME format. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SMIME_write_PKCS7(BIO *out, PKCS7 *p7, BIO *data, int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISMIME_write_PKCS7()\fR adds the appropriate \s-1MIME\s0 headers to a PKCS#7 structure to produce an S/MIME message. .PP \&\fBout\fR is the \s-1BIO\s0 to write the data to. \fBp7\fR is the appropriate \fB\s-1PKCS7\s0\fR structure. If streaming is enabled then the content must be supplied in the \&\fBdata\fR argument. \fBflags\fR is an optional set of flags. .SH "NOTES" .IX Header "NOTES" The following flags can be passed in the \fBflags\fR parameter. .PP If \fB\s-1PKCS7_DETACHED\s0\fR is set then cleartext signing will be used, this option only makes sense for signedData where \fB\s-1PKCS7_DETACHED\s0\fR is also set when \fIPKCS7_sign()\fR is also called. .PP If the \fB\s-1PKCS7_TEXT\s0\fR flag is set \s-1MIME\s0 headers for type \fBtext/plain\fR are added to the content, this only makes sense if \fB\s-1PKCS7_DETACHED\s0\fR is also set. .PP If the \fB\s-1PKCS7_STREAM\s0\fR flag is set streaming is performed. This flag should only be set if \fB\s-1PKCS7_STREAM\s0\fR was also set in the previous call to \&\fIPKCS7_sign()\fR or \fB\f(BIPKCS7_encrypt()\fB\fR. .PP If cleartext signing is being used and \fB\s-1PKCS7_STREAM\s0\fR not set then the data must be read twice: once to compute the signature in \fIPKCS7_sign()\fR and once to output the S/MIME message. .PP If streaming is performed the content is output in \s-1BER\s0 format using indefinite length constructuted encoding except in the case of signed data with detached content where the content is absent and \s-1DER\s0 format is used. .SH "BUGS" .IX Header "BUGS" \&\fISMIME_write_PKCS7()\fR always base64 encodes PKCS#7 structures, there should be an option to disable this. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISMIME_write_PKCS7()\fR returns 1 for success or 0 for failure. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fIPKCS7_sign\fR\|(3), \&\fIPKCS7_verify\fR\|(3), \fIPKCS7_encrypt\fR\|(3) \&\fIPKCS7_decrypt\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fISMIME_write_PKCS7()\fR was added to OpenSSL 0.9.5 deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_PKEY_set1_RSA.30000644000175000017500000001556012360020721020522 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_PKEY_set1_RSA 3" .TH EVP_PKEY_set1_RSA 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_PKEY_set1_RSA, EVP_PKEY_set1_DSA, EVP_PKEY_set1_DH, EVP_PKEY_set1_EC_KEY, EVP_PKEY_get1_RSA, EVP_PKEY_get1_DSA, EVP_PKEY_get1_DH, EVP_PKEY_get1_EC_KEY, EVP_PKEY_assign_RSA, EVP_PKEY_assign_DSA, EVP_PKEY_assign_DH, EVP_PKEY_assign_EC_KEY, EVP_PKEY_type \- EVP_PKEY assignment functions. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,RSA *key); \& int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,DSA *key); \& int EVP_PKEY_set1_DH(EVP_PKEY *pkey,DH *key); \& int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey,EC_KEY *key); \& \& RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey); \& DSA *EVP_PKEY_get1_DSA(EVP_PKEY *pkey); \& DH *EVP_PKEY_get1_DH(EVP_PKEY *pkey); \& EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey); \& \& int EVP_PKEY_assign_RSA(EVP_PKEY *pkey,RSA *key); \& int EVP_PKEY_assign_DSA(EVP_PKEY *pkey,DSA *key); \& int EVP_PKEY_assign_DH(EVP_PKEY *pkey,DH *key); \& int EVP_PKEY_assign_EC_KEY(EVP_PKEY *pkey,EC_KEY *key); \& \& int EVP_PKEY_type(int type); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIEVP_PKEY_set1_RSA()\fR, \fIEVP_PKEY_set1_DSA()\fR, \fIEVP_PKEY_set1_DH()\fR and \&\fIEVP_PKEY_set1_EC_KEY()\fR set the key referenced by \fBpkey\fR to \fBkey\fR. .PP \&\fIEVP_PKEY_get1_RSA()\fR, \fIEVP_PKEY_get1_DSA()\fR, \fIEVP_PKEY_get1_DH()\fR and \&\fIEVP_PKEY_get1_EC_KEY()\fR return the referenced key in \fBpkey\fR or \&\fB\s-1NULL\s0\fR if the key is not of the correct type. .PP \&\fIEVP_PKEY_assign_RSA()\fR \fIEVP_PKEY_assign_DSA()\fR, \fIEVP_PKEY_assign_DH()\fR and \fIEVP_PKEY_assign_EC_KEY()\fR also set the referenced key to \fBkey\fR however these use the supplied \fBkey\fR internally and so \fBkey\fR will be freed when the parent \fBpkey\fR is freed. .PP \&\fIEVP_PKEY_type()\fR returns the type of key corresponding to the value \&\fBtype\fR. The type of a key can be obtained with EVP_PKEY_type(pkey\->type). The return value will be \s-1EVP_PKEY_RSA, EVP_PKEY_DSA, EVP_PKEY_DH\s0 or \s-1EVP_PKEY_EC\s0 for the corresponding key types or NID_undef if the key type is unassigned. .SH "NOTES" .IX Header "NOTES" In accordance with the OpenSSL naming convention the key obtained from or assigned to the \fBpkey\fR using the \fB1\fR functions must be freed as well as \fBpkey\fR. .PP \&\fIEVP_PKEY_assign_RSA()\fR \fIEVP_PKEY_assign_DSA()\fR, \fIEVP_PKEY_assign_DH()\fR \&\fIEVP_PKEY_assign_EC_KEY()\fR are implemented as macros. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_PKEY_set1_RSA()\fR, \fIEVP_PKEY_set1_DSA()\fR, \fIEVP_PKEY_set1_DH()\fR and \&\fIEVP_PKEY_set1_EC_KEY()\fR return 1 for success or 0 for failure. .PP \&\fIEVP_PKEY_get1_RSA()\fR, \fIEVP_PKEY_get1_DSA()\fR, \fIEVP_PKEY_get1_DH()\fR and \&\fIEVP_PKEY_get1_EC_KEY()\fR return the referenced key or \fB\s-1NULL\s0\fR if an error occurred. .PP \&\fIEVP_PKEY_assign_RSA()\fR \fIEVP_PKEY_assign_DSA()\fR, \fIEVP_PKEY_assign_DH()\fR and \fIEVP_PKEY_assign_EC_KEY()\fR return 1 for success and 0 for failure. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_PKEY_new\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/ec.10000644000175000017500000002406612360020741016167 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ec 1" .TH ec 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ec \- EC key processing .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBec\fR [\fB\-inform PEM|DER\fR] [\fB\-outform PEM|DER\fR] [\fB\-in filename\fR] [\fB\-passin arg\fR] [\fB\-out filename\fR] [\fB\-passout arg\fR] [\fB\-des\fR] [\fB\-des3\fR] [\fB\-idea\fR] [\fB\-text\fR] [\fB\-noout\fR] [\fB\-param_out\fR] [\fB\-pubin\fR] [\fB\-pubout\fR] [\fB\-conv_form arg\fR] [\fB\-param_enc arg\fR] [\fB\-engine id\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBec\fR command processes \s-1EC\s0 keys. They can be converted between various forms and their components printed out. \fBNote\fR OpenSSL uses the private key format specified in '\s-1SEC 1:\s0 Elliptic Curve Cryptography' (http://www.secg.org/). To convert a OpenSSL \s-1EC\s0 private key into the PKCS#8 private key format use the \fBpkcs8\fR command. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" .IP "\fB\-inform DER|PEM\fR" 4 .IX Item "-inform DER|PEM" This specifies the input format. The \fB\s-1DER\s0\fR option with a private key uses an \s-1ASN.1 DER\s0 encoded \s-1SEC1\s0 private key. When used with a public key it uses the SubjectPublicKeyInfo structure as specified in \s-1RFC 3280.\s0 The \fB\s-1PEM\s0\fR form is the default format: it consists of the \fB\s-1DER\s0\fR format base64 encoded with additional header and footer lines. In the case of a private key PKCS#8 format is also accepted. .IP "\fB\-outform DER|PEM\fR" 4 .IX Item "-outform DER|PEM" This specifies the output format, the options have the same meaning as the \&\fB\-inform\fR option. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read a key from or standard input if this option is not specified. If the key is encrypted a pass phrase will be prompted for. .IP "\fB\-passin arg\fR" 4 .IX Item "-passin arg" the input file password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" This specifies the output filename to write a key to or standard output by is not specified. If any encryption options are set then a pass phrase will be prompted for. The output filename should \fBnot\fR be the same as the input filename. .IP "\fB\-passout arg\fR" 4 .IX Item "-passout arg" the output file password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-des|\-des3|\-idea\fR" 4 .IX Item "-des|-des3|-idea" These options encrypt the private key with the \s-1DES,\s0 triple \s-1DES, IDEA\s0 or any other cipher supported by OpenSSL before outputting it. A pass phrase is prompted for. If none of these options is specified the key is written in plain text. This means that using the \fBec\fR utility to read in an encrypted key with no encryption option can be used to remove the pass phrase from a key, or by setting the encryption options it can be use to add or change the pass phrase. These options can only be used with \s-1PEM\s0 format output files. .IP "\fB\-text\fR" 4 .IX Item "-text" prints out the public, private key components and parameters. .IP "\fB\-noout\fR" 4 .IX Item "-noout" this option prevents output of the encoded version of the key. .IP "\fB\-modulus\fR" 4 .IX Item "-modulus" this option prints out the value of the public key component of the key. .IP "\fB\-pubin\fR" 4 .IX Item "-pubin" by default a private key is read from the input file: with this option a public key is read instead. .IP "\fB\-pubout\fR" 4 .IX Item "-pubout" by default a private key is output. With this option a public key will be output instead. This option is automatically set if the input is a public key. .IP "\fB\-conv_form\fR" 4 .IX Item "-conv_form" This specifies how the points on the elliptic curve are converted into octet strings. Possible values are: \fBcompressed\fR (the default value), \fBuncompressed\fR and \fBhybrid\fR. For more information regarding the point conversion forms please read the X9.62 standard. .IP "\fB\-param_enc arg\fR" 4 .IX Item "-param_enc arg" This specifies how the elliptic curve parameters are encoded. Possible value are: \fBnamed_curve\fR, i.e. the ec parameters are specified by a \s-1OID,\s0 or \fBexplicit\fR where the ec parameters are explicitly given (see \s-1RFC 3279\s0 for the definition of the \&\s-1EC\s0 parameters structures). The default value is \fBnamed_curve\fR. \&\fBNote\fR the \fBimplicitlyCA\fR alternative ,as specified in \s-1RFC 3279,\s0 is currently not implemented in OpenSSL. .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBec\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .SH "NOTES" .IX Header "NOTES" The \s-1PEM\s0 private key format uses the header and footer lines: .PP .Vb 2 \& \-\-\-\-\-BEGIN EC PRIVATE KEY\-\-\-\-\- \& \-\-\-\-\-END EC PRIVATE KEY\-\-\-\-\- .Ve .PP The \s-1PEM\s0 public key format uses the header and footer lines: .PP .Vb 2 \& \-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\- \& \-\-\-\-\-END PUBLIC KEY\-\-\-\-\- .Ve .SH "EXAMPLES" .IX Header "EXAMPLES" To encrypt a private key using triple \s-1DES:\s0 .PP .Vb 1 \& openssl ec \-in key.pem \-des3 \-out keyout.pem .Ve .PP To convert a private key from \s-1PEM\s0 to \s-1DER\s0 format: .PP .Vb 1 \& openssl ec \-in key.pem \-outform DER \-out keyout.der .Ve .PP To print out the components of a private key to standard output: .PP .Vb 1 \& openssl ec \-in key.pem \-text \-noout .Ve .PP To just output the public part of a private key: .PP .Vb 1 \& openssl ec \-in key.pem \-pubout \-out pubkey.pem .Ve .PP To change the parameters encoding to \fBexplicit\fR: .PP .Vb 1 \& openssl ec \-in key.pem \-param_enc explicit \-out keyout.pem .Ve .PP To change the point conversion form to \fBcompressed\fR: .PP .Vb 1 \& openssl ec \-in key.pem \-conv_form compressed \-out keyout.pem .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIecparam\fR\|(1), \fIdsa\fR\|(1), \fIrsa\fR\|(1) .SH "HISTORY" .IX Header "HISTORY" The ec command was first introduced in OpenSSL 0.9.8. .SH "AUTHOR" .IX Header "AUTHOR" Nils Larsch for the OpenSSL project (http://www.openssl.org). deps/libressl-pnacl-sys-2.1.6/libressl/man/X509_verify_cert.30000644000175000017500000001304012360020726020641 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "X509_verify_cert 3" .TH X509_verify_cert 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" X509_verify_cert \- discover and verify X509 certificte chain .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int X509_verify_cert(X509_STORE_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fIX509_verify_cert()\fR function attempts to discover and validate a certificate chain based on parameters in \fBctx\fR. A complete description of the process is contained in the \fIverify\fR\|(1) manual page. .SH "RETURN VALUES" .IX Header "RETURN VALUES" If a complete chain can be built and validated this function returns 1, otherwise it return zero, in exceptional circumstances it can also return a negative code. .PP If the function fails additional error information can be obtained by examining \fBctx\fR using, for example \fIX509_STORE_CTX_get_error()\fR. .SH "NOTES" .IX Header "NOTES" Applications rarely call this function directly but it is used by OpenSSL internally for certificate validation, in both the S/MIME and \&\s-1SSL/TLS\s0 code. .PP The negative return value from \fIX509_verify_cert()\fR can only occur if no certificate is set in \fBctx\fR (due to a programming error) or if a retry operation is requested during internal lookups (which never happens with standard lookup methods). It is however recommended that application check for <= 0 return value on error. .SH "BUGS" .IX Header "BUGS" This function uses the header \fBx509.h\fR as opposed to most chain verification functiosn which use \fBx509_vfy.h\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIX509_STORE_CTX_get_error\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIX509_verify_cert()\fR is available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_get_version.30000644000175000017500000001151212360020736020643 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_get_version 3" .TH SSL_get_version 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_get_version \- get the protocol version of a connection. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& const char *SSL_get_version(const SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_get_version()\fR returns the name of the protocol used for the connection \fBssl\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following strings can be returned: .IP "SSLv2" 4 .IX Item "SSLv2" The connection uses the SSLv2 protocol. .IP "SSLv3" 4 .IX Item "SSLv3" The connection uses the SSLv3 protocol. .IP "TLSv1" 4 .IX Item "TLSv1" The connection uses the TLSv1.0 protocol. .IP "TLSv1.1" 4 .IX Item "TLSv1.1" The connection uses the TLSv1.1 protocol. .IP "TLSv1.2" 4 .IX Item "TLSv1.2" The connection uses the TLSv1.2 protocol. .IP "unknown" 4 .IX Item "unknown" This indicates that no version has been set (no connection established). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/pkeyparam.10000644000175000017500000001320212360020742017560 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "pkeyparam 1" .TH pkeyparam 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" pkeyparam \- public key algorithm parameter processing tool .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBpkeyparam\fR [\fB\-in filename\fR] [\fB\-out filename\fR] [\fB\-text\fR] [\fB\-noout\fR] [\fB\-engine id\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBpkey\fR command processes public or private keys. They can be converted between various forms and their components printed out. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read parameters from or standard input if this option is not specified. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" This specifies the output filename to write parameters to or standard output if this option is not specified. .IP "\fB\-text\fR" 4 .IX Item "-text" prints out the parameters in plain text in addition to the encoded version. .IP "\fB\-noout\fR" 4 .IX Item "-noout" do not output the encoded version of the parameters. .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBpkeyparam\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .SH "EXAMPLE" .IX Header "EXAMPLE" Print out text version of parameters: .PP .Vb 1 \& openssl pkeyparam \-in param.pem \-text .Ve .SH "NOTES" .IX Header "NOTES" There are no \fB\-inform\fR or \fB\-outform\fR options for this command because only \&\s-1PEM\s0 format is supported because the key type is determined by the \s-1PEM\s0 headers. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIgenpkey\fR\|(1), \fIrsa\fR\|(1), \fIpkcs8\fR\|(1), \&\fIdsa\fR\|(1), \fIgenrsa\fR\|(1), \fIgendsa\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/ts.10000644000175000017500000006423712360020743016234 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ts 1" .TH ts 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ts \- Time Stamping Authority tool (client/server) .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBts\fR \&\fB\-query\fR [\fB\-rand\fR file:file...] [\fB\-config\fR configfile] [\fB\-data\fR file_to_hash] [\fB\-digest\fR digest_bytes] [\fB\-md2\fR|\fB\-md4\fR|\fB\-md5\fR|\fB\-sha\fR|\fB\-sha1\fR|\fB\-mdc2\fR|\fB\-ripemd160\fR|\fB...\fR] [\fB\-policy\fR object_id] [\fB\-no_nonce\fR] [\fB\-cert\fR] [\fB\-in\fR request.tsq] [\fB\-out\fR request.tsq] [\fB\-text\fR] .PP \&\fBopenssl\fR \fBts\fR \&\fB\-reply\fR [\fB\-config\fR configfile] [\fB\-section\fR tsa_section] [\fB\-queryfile\fR request.tsq] [\fB\-passin\fR password_src] [\fB\-signer\fR tsa_cert.pem] [\fB\-inkey\fR private.pem] [\fB\-chain\fR certs_file.pem] [\fB\-policy\fR object_id] [\fB\-in\fR response.tsr] [\fB\-token_in\fR] [\fB\-out\fR response.tsr] [\fB\-token_out\fR] [\fB\-text\fR] [\fB\-engine\fR id] .PP \&\fBopenssl\fR \fBts\fR \&\fB\-verify\fR [\fB\-data\fR file_to_hash] [\fB\-digest\fR digest_bytes] [\fB\-queryfile\fR request.tsq] [\fB\-in\fR response.tsr] [\fB\-token_in\fR] [\fB\-CApath\fR trusted_cert_path] [\fB\-CAfile\fR trusted_certs.pem] [\fB\-untrusted\fR cert_file.pem] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBts\fR command is a basic Time Stamping Authority (\s-1TSA\s0) client and server application as specified in \s-1RFC 3161 \s0(Time-Stamp Protocol, \s-1TSP\s0). A \&\s-1TSA\s0 can be part of a \s-1PKI\s0 deployment and its role is to provide long term proof of the existence of a certain datum before a particular time. Here is a brief description of the protocol: .IP "1." 4 The \s-1TSA\s0 client computes a one-way hash value for a data file and sends the hash to the \s-1TSA.\s0 .IP "2." 4 The \s-1TSA\s0 attaches the current date and time to the received hash value, signs them and sends the time stamp token back to the client. By creating this token the \s-1TSA\s0 certifies the existence of the original data file at the time of response generation. .IP "3." 4 The \s-1TSA\s0 client receives the time stamp token and verifies the signature on it. It also checks if the token contains the same hash value that it had sent to the \s-1TSA.\s0 .PP There is one \s-1DER\s0 encoded protocol data unit defined for transporting a time stamp request to the \s-1TSA\s0 and one for sending the time stamp response back to the client. The \fBts\fR command has three main functions: creating a time stamp request based on a data file, creating a time stamp response based on a request, verifying if a response corresponds to a particular request or a data file. .PP There is no support for sending the requests/responses automatically over \s-1HTTP\s0 or \s-1TCP\s0 yet as suggested in \s-1RFC 3161.\s0 The users must send the requests either by ftp or e\-mail. .SH "OPTIONS" .IX Header "OPTIONS" .SS "Time Stamp Request generation" .IX Subsection "Time Stamp Request generation" The \fB\-query\fR switch can be used for creating and printing a time stamp request with the following options: .IP "\fB\-rand\fR file:file..." 4 .IX Item "-rand file:file..." The files containing random data for seeding the random number generator. Multiple files can be specified, the separator is \fB;\fR for MS-Windows, \fB,\fR for \s-1VMS\s0 and \fB:\fR for all other platforms. (Optional) .IP "\fB\-config\fR configfile" 4 .IX Item "-config configfile" The configuration file to use, this option overrides the \&\fB\s-1OPENSSL_CONF\s0\fR environment variable. Only the \s-1OID\s0 section of the config file is used with the \fB\-query\fR command. (Optional) .IP "\fB\-data\fR file_to_hash" 4 .IX Item "-data file_to_hash" The data file for which the time stamp request needs to be created. stdin is the default if neither the \fB\-data\fR nor the \fB\-digest\fR parameter is specified. (Optional) .IP "\fB\-digest\fR digest_bytes" 4 .IX Item "-digest digest_bytes" It is possible to specify the message imprint explicitly without the data file. The imprint must be specified in a hexadecimal format, two characters per byte, the bytes optionally separated by colons (e.g. 1A:F6:01:... or 1AF601...). The number of bytes must match the message digest algorithm in use. (Optional) .IP "\fB\-md2\fR|\fB\-md4\fR|\fB\-md5\fR|\fB\-sha\fR|\fB\-sha1\fR|\fB\-mdc2\fR|\fB\-ripemd160\fR|\fB...\fR" 4 .IX Item "-md2|-md4|-md5|-sha|-sha1|-mdc2|-ripemd160|..." The message digest to apply to the data file, it supports all the message digest algorithms that are supported by the openssl \fBdgst\fR command. The default is \s-1SHA\-1. \s0(Optional) .IP "\fB\-policy\fR object_id" 4 .IX Item "-policy object_id" The policy that the client expects the \s-1TSA\s0 to use for creating the time stamp token. Either the dotted \s-1OID\s0 notation or \s-1OID\s0 names defined in the config file can be used. If no policy is requested the \s-1TSA\s0 will use its own default policy. (Optional) .IP "\fB\-no_nonce\fR" 4 .IX Item "-no_nonce" No nonce is specified in the request if this option is given. Otherwise a 64 bit long pseudo-random none is included in the request. It is recommended to use nonce to protect against replay-attacks. (Optional) .IP "\fB\-cert\fR" 4 .IX Item "-cert" The \s-1TSA\s0 is expected to include its signing certificate in the response. (Optional) .IP "\fB\-in\fR request.tsq" 4 .IX Item "-in request.tsq" This option specifies a previously created time stamp request in \s-1DER\s0 format that will be printed into the output file. Useful when you need to examine the content of a request in human-readable .Sp format. (Optional) .IP "\fB\-out\fR request.tsq" 4 .IX Item "-out request.tsq" Name of the output file to which the request will be written. Default is stdout. (Optional) .IP "\fB\-text\fR" 4 .IX Item "-text" If this option is specified the output is human-readable text format instead of \s-1DER. \s0(Optional) .SS "Time Stamp Response generation" .IX Subsection "Time Stamp Response generation" A time stamp response (TimeStampResp) consists of a response status and the time stamp token itself (ContentInfo), if the token generation was successful. The \fB\-reply\fR command is for creating a time stamp response or time stamp token based on a request and printing the response/token in human-readable format. If \fB\-token_out\fR is not specified the output is always a time stamp response (TimeStampResp), otherwise it is a time stamp token (ContentInfo). .IP "\fB\-config\fR configfile" 4 .IX Item "-config configfile" The configuration file to use, this option overrides the \&\fB\s-1OPENSSL_CONF\s0\fR environment variable. See \fB\s-1CONFIGURATION FILE OPTIONS\s0\fR for configurable variables. (Optional) .IP "\fB\-section\fR tsa_section" 4 .IX Item "-section tsa_section" The name of the config file section conatining the settings for the response generation. If not specified the default \s-1TSA\s0 section is used, see \fB\s-1CONFIGURATION FILE OPTIONS\s0\fR for details. (Optional) .IP "\fB\-queryfile\fR request.tsq" 4 .IX Item "-queryfile request.tsq" The name of the file containing a \s-1DER\s0 encoded time stamp request. (Optional) .IP "\fB\-passin\fR password_src" 4 .IX Item "-passin password_src" Specifies the password source for the private key of the \s-1TSA.\s0 See \&\fB\s-1PASS PHRASE ARGUMENTS\s0\fR in \fIopenssl\fR\|(1). (Optional) .IP "\fB\-signer\fR tsa_cert.pem" 4 .IX Item "-signer tsa_cert.pem" The signer certificate of the \s-1TSA\s0 in \s-1PEM\s0 format. The \s-1TSA\s0 signing certificate must have exactly one extended key usage assigned to it: timeStamping. The extended key usage must also be critical, otherwise the certificate is going to be refused. Overrides the \fBsigner_cert\fR variable of the config file. (Optional) .IP "\fB\-inkey\fR private.pem" 4 .IX Item "-inkey private.pem" The signer private key of the \s-1TSA\s0 in \s-1PEM\s0 format. Overrides the \&\fBsigner_key\fR config file option. (Optional) .IP "\fB\-chain\fR certs_file.pem" 4 .IX Item "-chain certs_file.pem" The collection of certificates in \s-1PEM\s0 format that will all be included in the response in addition to the signer certificate if the \fB\-cert\fR option was used for the request. This file is supposed to contain the certificate chain for the signer certificate from its issuer upwards. The \fB\-reply\fR command does not build a certificate chain automatically. (Optional) .IP "\fB\-policy\fR object_id" 4 .IX Item "-policy object_id" The default policy to use for the response unless the client explicitly requires a particular \s-1TSA\s0 policy. The \s-1OID\s0 can be specified either in dotted notation or with its name. Overrides the \&\fBdefault_policy\fR config file option. (Optional) .IP "\fB\-in\fR response.tsr" 4 .IX Item "-in response.tsr" Specifies a previously created time stamp response or time stamp token (if \fB\-token_in\fR is also specified) in \s-1DER\s0 format that will be written to the output file. This option does not require a request, it is useful e.g. when you need to examine the content of a response or token or you want to extract the time stamp token from a response. If the input is a token and the output is a time stamp response a default \&'granted' status info is added to the token. (Optional) .IP "\fB\-token_in\fR" 4 .IX Item "-token_in" This flag can be used together with the \fB\-in\fR option and indicates that the input is a \s-1DER\s0 encoded time stamp token (ContentInfo) instead of a time stamp response (TimeStampResp). (Optional) .IP "\fB\-out\fR response.tsr" 4 .IX Item "-out response.tsr" The response is written to this file. The format and content of the file depends on other options (see \fB\-text\fR, \fB\-token_out\fR). The default is stdout. (Optional) .IP "\fB\-token_out\fR" 4 .IX Item "-token_out" The output is a time stamp token (ContentInfo) instead of time stamp response (TimeStampResp). (Optional) .IP "\fB\-text\fR" 4 .IX Item "-text" If this option is specified the output is human-readable text format instead of \s-1DER. \s0(Optional) .IP "\fB\-engine\fR id" 4 .IX Item "-engine id" Specifying an engine (by its unique \fBid\fR string) will cause \fBts\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. Default is builtin. (Optional) .SS "Time Stamp Response verification" .IX Subsection "Time Stamp Response verification" The \fB\-verify\fR command is for verifying if a time stamp response or time stamp token is valid and matches a particular time stamp request or data file. The \fB\-verify\fR command does not use the configuration file. .IP "\fB\-data\fR file_to_hash" 4 .IX Item "-data file_to_hash" The response or token must be verified against file_to_hash. The file is hashed with the message digest algorithm specified in the token. The \fB\-digest\fR and \fB\-queryfile\fR options must not be specified with this one. (Optional) .IP "\fB\-digest\fR digest_bytes" 4 .IX Item "-digest digest_bytes" The response or token must be verified against the message digest specified with this option. The number of bytes must match the message digest algorithm specified in the token. The \fB\-data\fR and \fB\-queryfile\fR options must not be specified with this one. (Optional) .IP "\fB\-queryfile\fR request.tsq" 4 .IX Item "-queryfile request.tsq" The original time stamp request in \s-1DER\s0 format. The \fB\-data\fR and \fB\-digest\fR options must not be specified with this one. (Optional) .IP "\fB\-in\fR response.tsr" 4 .IX Item "-in response.tsr" The time stamp response that needs to be verified in \s-1DER\s0 format. (Mandatory) .IP "\fB\-token_in\fR" 4 .IX Item "-token_in" This flag can be used together with the \fB\-in\fR option and indicates that the input is a \s-1DER\s0 encoded time stamp token (ContentInfo) instead of a time stamp response (TimeStampResp). (Optional) .IP "\fB\-CApath\fR trusted_cert_path" 4 .IX Item "-CApath trusted_cert_path" The name of the directory containing the trused \s-1CA\s0 certificates of the client. See the similar option of \fIverify\fR\|(1) for additional details. Either this option or \fB\-CAfile\fR must be specified. (Optional) .IP "\fB\-CAfile\fR trusted_certs.pem" 4 .IX Item "-CAfile trusted_certs.pem" The name of the file containing a set of trusted self-signed \s-1CA\s0 certificates in \s-1PEM\s0 format. See the similar option of \&\fIverify\fR\|(1) for additional details. Either this option or \fB\-CApath\fR must be specified. (Optional) .IP "\fB\-untrusted\fR cert_file.pem" 4 .IX Item "-untrusted cert_file.pem" Set of additional untrusted certificates in \s-1PEM\s0 format which may be needed when building the certificate chain for the \s-1TSA\s0's signing certificate. This file must contain the \s-1TSA\s0 signing certificate and all intermediate \s-1CA\s0 certificates unless the response includes them. (Optional) .SH "CONFIGURATION FILE OPTIONS" .IX Header "CONFIGURATION FILE OPTIONS" The \fB\-query\fR and \fB\-reply\fR commands make use of a configuration file defined by the \fB\s-1OPENSSL_CONF\s0\fR environment variable. See \fIconfig\fR\|(5) for a general description of the syntax of the config file. The \&\fB\-query\fR command uses only the symbolic \s-1OID\s0 names section and it can work without it. However, the \fB\-reply\fR command needs the config file for its operation. .PP When there is a command line switch equivalent of a variable the switch always overrides the settings in the config file. .IP "\fBtsa\fR section, \fBdefault_tsa\fR" 4 .IX Item "tsa section, default_tsa" This is the main section and it specifies the name of another section that contains all the options for the \fB\-reply\fR command. This default section can be overridden with the \fB\-section\fR command line switch. (Optional) .IP "\fBoid_file\fR" 4 .IX Item "oid_file" See \fIca\fR\|(1) for description. (Optional) .IP "\fBoid_section\fR" 4 .IX Item "oid_section" See \fIca\fR\|(1) for description. (Optional) .IP "\fB\s-1RANDFILE\s0\fR" 4 .IX Item "RANDFILE" See \fIca\fR\|(1) for description. (Optional) .IP "\fBserial\fR" 4 .IX Item "serial" The name of the file containing the hexadecimal serial number of the last time stamp response created. This number is incremented by 1 for each response. If the file does not exist at the time of response generation a new file is created with serial number 1. (Mandatory) .IP "\fBcrypto_device\fR" 4 .IX Item "crypto_device" Specifies the OpenSSL engine that will be set as the default for all available algorithms. The default value is builtin, you can specify any other engines supported by OpenSSL (e.g. use chil for the NCipher \s-1HSM\s0). (Optional) .IP "\fBsigner_cert\fR" 4 .IX Item "signer_cert" \&\s-1TSA\s0 signing certificate in \s-1PEM\s0 format. The same as the \fB\-signer\fR command line option. (Optional) .IP "\fBcerts\fR" 4 .IX Item "certs" A file containing a set of \s-1PEM\s0 encoded certificates that need to be included in the response. The same as the \fB\-chain\fR command line option. (Optional) .IP "\fBsigner_key\fR" 4 .IX Item "signer_key" The private key of the \s-1TSA\s0 in \s-1PEM\s0 format. The same as the \fB\-inkey\fR command line option. (Optional) .IP "\fBdefault_policy\fR" 4 .IX Item "default_policy" The default policy to use when the request does not mandate any policy. The same as the \fB\-policy\fR command line option. (Optional) .IP "\fBother_policies\fR" 4 .IX Item "other_policies" Comma separated list of policies that are also acceptable by the \s-1TSA\s0 and used only if the request explicitly specifies one of them. (Optional) .IP "\fBdigests\fR" 4 .IX Item "digests" The list of message digest algorithms that the \s-1TSA\s0 accepts. At least one algorithm must be specified. (Mandatory) .IP "\fBaccuracy\fR" 4 .IX Item "accuracy" The accuracy of the time source of the \s-1TSA\s0 in seconds, milliseconds and microseconds. E.g. secs:1, millisecs:500, microsecs:100. If any of the components is missing zero is assumed for that field. (Optional) .IP "\fBclock_precision_digits\fR" 4 .IX Item "clock_precision_digits" Specifies the maximum number of digits, which represent the fraction of seconds, that need to be included in the time field. The trailing zeroes must be removed from the time, so there might actually be fewer digits, or no fraction of seconds at all. Supported only on \s-1UNIX\s0 platforms. The maximum value is 6, default is 0. (Optional) .IP "\fBordering\fR" 4 .IX Item "ordering" If this option is yes the responses generated by this \s-1TSA\s0 can always be ordered, even if the time difference between two responses is less than the sum of their accuracies. Default is no. (Optional) .IP "\fBtsa_name\fR" 4 .IX Item "tsa_name" Set this option to yes if the subject name of the \s-1TSA\s0 must be included in the \s-1TSA\s0 name field of the response. Default is no. (Optional) .IP "\fBess_cert_id_chain\fR" 4 .IX Item "ess_cert_id_chain" The SignedData objects created by the \s-1TSA\s0 always contain the certificate identifier of the signing certificate in a signed attribute (see \s-1RFC 2634,\s0 Enhanced Security Services). If this option is set to yes and either the \fBcerts\fR variable or the \fB\-chain\fR option is specified then the certificate identifiers of the chain will also be included in the SigningCertificate signed attribute. If this variable is set to no, only the signing certificate identifier is included. Default is no. (Optional) .SH "ENVIRONMENT VARIABLES" .IX Header "ENVIRONMENT VARIABLES" \&\fB\s-1OPENSSL_CONF\s0\fR contains the path of the configuration file and can be overridden by the \fB\-config\fR command line option. .SH "EXAMPLES" .IX Header "EXAMPLES" All the examples below presume that \fB\s-1OPENSSL_CONF\s0\fR is set to a proper configuration file, e.g. the example configuration file openssl/apps/openssl.cnf will do. .SS "Time Stamp Request" .IX Subsection "Time Stamp Request" To create a time stamp request for design1.txt with \s-1SHA\-1\s0 without nonce and policy and no certificate is required in the response: .PP .Vb 2 \& openssl ts \-query \-data design1.txt \-no_nonce \e \& \-out design1.tsq .Ve .PP To create a similar time stamp request with specifying the message imprint explicitly: .PP .Vb 2 \& openssl ts \-query \-digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \e \& \-no_nonce \-out design1.tsq .Ve .PP To print the content of the previous request in human readable format: .PP .Vb 1 \& openssl ts \-query \-in design1.tsq \-text .Ve .PP To create a time stamp request which includes the \s-1MD\-5\s0 digest of design2.txt, requests the signer certificate and nonce, specifies a policy id (assuming the tsa_policy1 name is defined in the \&\s-1OID\s0 section of the config file): .PP .Vb 2 \& openssl ts \-query \-data design2.txt \-md5 \e \& \-policy tsa_policy1 \-cert \-out design2.tsq .Ve .SS "Time Stamp Response" .IX Subsection "Time Stamp Response" Before generating a response a signing certificate must be created for the \s-1TSA\s0 that contains the \fBtimeStamping\fR critical extended key usage extension without any other key usage extensions. You can add the \&'extendedKeyUsage = critical,timeStamping' line to the user certificate section of the config file to generate a proper certificate. See \fIreq\fR\|(1), \&\fIca\fR\|(1), \fIx509\fR\|(1) for instructions. The examples below assume that cacert.pem contains the certificate of the \s-1CA,\s0 tsacert.pem is the signing certificate issued by cacert.pem and tsakey.pem is the private key of the \s-1TSA.\s0 .PP To create a time stamp response for a request: .PP .Vb 2 \& openssl ts \-reply \-queryfile design1.tsq \-inkey tsakey.pem \e \& \-signer tsacert.pem \-out design1.tsr .Ve .PP If you want to use the settings in the config file you could just write: .PP .Vb 1 \& openssl ts \-reply \-queryfile design1.tsq \-out design1.tsr .Ve .PP To print a time stamp reply to stdout in human readable format: .PP .Vb 1 \& openssl ts \-reply \-in design1.tsr \-text .Ve .PP To create a time stamp token instead of time stamp response: .PP .Vb 1 \& openssl ts \-reply \-queryfile design1.tsq \-out design1_token.der \-token_out .Ve .PP To print a time stamp token to stdout in human readable format: .PP .Vb 1 \& openssl ts \-reply \-in design1_token.der \-token_in \-text \-token_out .Ve .PP To extract the time stamp token from a response: .PP .Vb 1 \& openssl ts \-reply \-in design1.tsr \-out design1_token.der \-token_out .Ve .PP To add 'granted' status info to a time stamp token thereby creating a valid response: .PP .Vb 1 \& openssl ts \-reply \-in design1_token.der \-token_in \-out design1.tsr .Ve .SS "Time Stamp Verification" .IX Subsection "Time Stamp Verification" To verify a time stamp reply against a request: .PP .Vb 2 \& openssl ts \-verify \-queryfile design1.tsq \-in design1.tsr \e \& \-CAfile cacert.pem \-untrusted tsacert.pem .Ve .PP To verify a time stamp reply that includes the certificate chain: .PP .Vb 2 \& openssl ts \-verify \-queryfile design2.tsq \-in design2.tsr \e \& \-CAfile cacert.pem .Ve .PP To verify a time stamp token against the original data file: openssl ts \-verify \-data design2.txt \-in design2.tsr \e \-CAfile cacert.pem .PP To verify a time stamp token against a message imprint: openssl ts \-verify \-digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \e \-in design2.tsr \-CAfile cacert.pem .PP You could also look at the 'test' directory for more examples. .SH "BUGS" .IX Header "BUGS" If you find any bugs or you have suggestions please write to Zoltan Glozik . Known issues: .IP "\(bu" 4 No support for time stamps over \s-1SMTP,\s0 though it is quite easy to implement an automatic e\-mail based \s-1TSA\s0 with \fIprocmail\fR\|(1) and \fIperl\fR\|(1). \s-1HTTP\s0 server support is provided in the form of a separate apache module. \s-1HTTP\s0 client support is provided by \&\fItsget\fR\|(1). Pure \s-1TCP/IP\s0 protocol is not supported. .IP "\(bu" 4 The file containing the last serial number of the \s-1TSA\s0 is not locked when being read or written. This is a problem if more than one instance of \fIopenssl\fR\|(1) is trying to create a time stamp response at the same time. This is not an issue when using the apache server module, it does proper locking. .IP "\(bu" 4 Look for the \s-1FIXME\s0 word in the source files. .IP "\(bu" 4 The source code should really be reviewed by somebody else, too. .IP "\(bu" 4 More testing is needed, I have done only some basic tests (see test/testtsa). .SH "AUTHOR" .IX Header "AUTHOR" Zoltan Glozik , OpenTSA project (http://www.opentsa.org) .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fItsget\fR\|(1), \fIopenssl\fR\|(1), \fIreq\fR\|(1), \&\fIx509\fR\|(1), \fIca\fR\|(1), \fIgenrsa\fR\|(1), \&\fIconfig\fR\|(5) deps/libressl-pnacl-sys-2.1.6/libressl/man/BUF_MEM_new.30000644000175000017500000001370512360020713017562 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BUF_MEM_new 3" .TH BUF_MEM_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BUF_MEM_new, BUF_MEM_free, BUF_MEM_grow, BUF_strdup \- simple character arrays structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BUF_MEM *BUF_MEM_new(void); \& \& void BUF_MEM_free(BUF_MEM *a); \& \& int BUF_MEM_grow(BUF_MEM *str, size_t len); \& \& char * BUF_strdup(const char *str); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The buffer library handles simple character arrays. Buffers are used for various purposes in the library, most notably memory BIOs. .PP The library uses the \s-1BUF_MEM\s0 structure defined in buffer.h: .PP .Vb 6 \& typedef struct buf_mem_st \& { \& size_t length; /* current number of bytes */ \& char *data; \& size_t max; /* size of buffer */ \& } BUF_MEM; .Ve .PP \&\fBlength\fR is the current size of the buffer in bytes, \fBmax\fR is the amount of memory allocated to the buffer. There are three functions which handle these and one \*(L"miscellaneous\*(R" function. .PP \&\fIBUF_MEM_new()\fR allocates a new buffer of zero size. .PP \&\fIBUF_MEM_free()\fR frees up an already existing buffer. The data is zeroed before freeing up in case the buffer contains sensitive data. .PP \&\fIBUF_MEM_grow()\fR changes the size of an already existing buffer to \&\fBlen\fR. Any data already in the buffer is preserved if it increases in size. .PP \&\fIBUF_strdup()\fR copies a null terminated string into a block of allocated memory and returns a pointer to the allocated block. .PP The memory allocated from \fIBUF_strdup()\fR should be freed up using the \&\fIOPENSSL_free()\fR function. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBUF_MEM_new()\fR returns the buffer or \s-1NULL\s0 on error. .PP \&\fIBUF_MEM_free()\fR has no return value. .PP \&\fIBUF_MEM_grow()\fR returns zero on error or the new size (i.e. \fBlen\fR). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbio\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIBUF_MEM_new()\fR, \fIBUF_MEM_free()\fR and \fIBUF_MEM_grow()\fR are available in all versions of SSLeay and OpenSSL. \fIBUF_strdup()\fR was added in SSLeay 0.8. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_cert_verify_callback.30000644000175000017500000001572412360020732024052 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_cert_verify_callback 3" .TH SSL_CTX_set_cert_verify_callback 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_cert_verify_callback \- set peer certificate verification procedure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*callback)(X509_STORE_CTX *,void *), void *arg); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_cert_verify_callback()\fR sets the verification callback function for \&\fIctx\fR. \s-1SSL\s0 objects that are created from \fIctx\fR inherit the setting valid at the time when \fISSL_new\fR\|(3) is called. .SH "NOTES" .IX Header "NOTES" Whenever a certificate is verified during a \s-1SSL/TLS\s0 handshake, a verification function is called. If the application does not explicitly specify a verification callback function, the built-in verification function is used. If a verification callback \fIcallback\fR is specified via \&\fISSL_CTX_set_cert_verify_callback()\fR, the supplied callback function is called instead. By setting \fIcallback\fR to \s-1NULL,\s0 the default behaviour is restored. .PP When the verification must be performed, \fIcallback\fR will be called with the arguments callback(X509_STORE_CTX *x509_store_ctx, void *arg). The argument \fIarg\fR is specified by the application when setting \fIcallback\fR. .PP \&\fIcallback\fR should return 1 to indicate verification success and 0 to indicate verification failure. If \s-1SSL_VERIFY_PEER\s0 is set and \fIcallback\fR returns 0, the handshake will fail. As the verification procedure may allow to continue the connection in case of failure (by always returning 1) the verification result must be set in any case using the \fBerror\fR member of \fIx509_store_ctx\fR so that the calling application will be informed about the detailed result of the verification procedure! .PP Within \fIx509_store_ctx\fR, \fIcallback\fR has access to the \fIverify_callback\fR function set using \fISSL_CTX_set_verify\fR\|(3). .SH "WARNINGS" .IX Header "WARNINGS" Do not mix the verification callback described in this function with the \&\fBverify_callback\fR function called during the verification process. The latter is set using the \fISSL_CTX_set_verify\fR\|(3) family of functions. .PP Providing a complete verification procedure including certificate purpose settings etc is a complex task. The built-in procedure is quite powerful and in most cases it should be sufficient to modify its behaviour using the \fBverify_callback\fR function. .SH "BUGS" .IX Header "BUGS" .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_set_cert_verify_callback()\fR does not provide diagnostic information. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_CTX_set_verify\fR\|(3), \&\fISSL_get_verify_result\fR\|(3), \&\fISSL_CTX_load_verify_locations\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" Previous to OpenSSL 0.9.7, the \fIarg\fR argument to \&\fBSSL_CTX_set_cert_verify_callback\fR was ignored, and \fIcallback\fR was called simply as int (*callback)(X509_STORE_CTX *) To compile software written for previous versions of OpenSSL, a dummy argument will have to be added to \&\fIcallback\fR. deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_s_fd.30000644000175000017500000001570612360020710017203 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_s_fd 3" .TH BIO_s_fd 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_s_fd, BIO_set_fd, BIO_get_fd, BIO_new_fd \- file descriptor BIO .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIO_METHOD * BIO_s_fd(void); \& \& #define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd) \& #define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c) \& \& BIO *BIO_new_fd(int fd, int close_flag); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_s_fd()\fR returns the file descriptor \s-1BIO\s0 method. This is a wrapper round the platforms file descriptor routines such as \fIread()\fR and \fIwrite()\fR. .PP \&\fIBIO_read()\fR and \fIBIO_write()\fR read or write the underlying descriptor. \&\fIBIO_puts()\fR is supported but \fIBIO_gets()\fR is not. .PP If the close flag is set then then \fIclose()\fR is called on the underlying file descriptor when the \s-1BIO\s0 is freed. .PP \&\fIBIO_reset()\fR attempts to change the file pointer to the start of file using lseek(fd, 0, 0). .PP \&\fIBIO_seek()\fR sets the file pointer to position \fBofs\fR from start of file using lseek(fd, ofs, 0). .PP \&\fIBIO_tell()\fR returns the current file position by calling lseek(fd, 0, 1). .PP \&\fIBIO_set_fd()\fR sets the file descriptor of \s-1BIO \s0\fBb\fR to \fBfd\fR and the close flag to \fBc\fR. .PP \&\fIBIO_get_fd()\fR places the file descriptor in \fBc\fR if it is not \s-1NULL,\s0 it also returns the file descriptor. If \fBc\fR is not \s-1NULL\s0 it should be of type (int *). .PP \&\fIBIO_new_fd()\fR returns a file descriptor \s-1BIO\s0 using \fBfd\fR and \fBclose_flag\fR. .SH "NOTES" .IX Header "NOTES" The behaviour of \fIBIO_read()\fR and \fIBIO_write()\fR depends on the behavior of the platforms \fIread()\fR and \fIwrite()\fR calls on the descriptor. If the underlying file descriptor is in a non blocking mode then the \s-1BIO\s0 will behave in the manner described in the \fIBIO_read\fR\|(3) and \&\fIBIO_should_retry\fR\|(3) manual pages. .PP File descriptor BIOs should not be used for socket I/O. Use socket BIOs instead. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBIO_s_fd()\fR returns the file descriptor \s-1BIO\s0 method. .PP \&\fIBIO_reset()\fR returns zero for success and \-1 if an error occurred. \&\fIBIO_seek()\fR and \fIBIO_tell()\fR return the current file position or \-1 is an error occurred. These values reflect the underlying \fIlseek()\fR behaviour. .PP \&\fIBIO_set_fd()\fR always returns 1. .PP \&\fIBIO_get_fd()\fR returns the file descriptor or \-1 if the \s-1BIO\s0 has not been initialized. .PP \&\fIBIO_new_fd()\fR returns the newly allocated \s-1BIO\s0 or \s-1NULL\s0 is an error occurred. .SH "EXAMPLE" .IX Header "EXAMPLE" This is a file descriptor \s-1BIO\s0 version of \*(L"Hello World\*(R": .PP .Vb 4 \& BIO *out; \& out = BIO_new_fd(fileno(stdout), BIO_NOCLOSE); \& BIO_printf(out, "Hello World\en"); \& BIO_free(out); .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIBIO_seek\fR\|(3), \fIBIO_tell\fR\|(3), \&\fIBIO_reset\fR\|(3), \fIBIO_read\fR\|(3), \&\fIBIO_write\fR\|(3), \fIBIO_puts\fR\|(3), \&\fIBIO_gets\fR\|(3), \fIBIO_printf\fR\|(3), \&\fIBIO_set_close\fR\|(3), \fIBIO_get_close\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/CMS_encrypt.30000644000175000017500000001747412360020713017774 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CMS_encrypt 3" .TH CMS_encrypt 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CMS_encrypt \- create a CMS envelopedData structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, unsigned int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fICMS_encrypt()\fR creates and returns a \s-1CMS\s0 EnvelopedData structure. \fBcerts\fR is a list of recipient certificates. \fBin\fR is the content to be encrypted. \&\fBcipher\fR is the symmetric cipher to use. \fBflags\fR is an optional set of flags. .SH "NOTES" .IX Header "NOTES" Only certificates carrying \s-1RSA\s0 keys are supported so the recipient certificates supplied to this function must all contain \s-1RSA\s0 public keys, though they do not have to be signed using the \s-1RSA\s0 algorithm. .PP The algorithm passed in the \fBcipher\fR parameter must support \s-1ASN1\s0 encoding of its parameters. .PP Many browsers implement a \*(L"sign and encrypt\*(R" option which is simply an S/MIME envelopedData containing an S/MIME signed message. This can be readily produced by storing the S/MIME signed message in a memory \s-1BIO\s0 and passing it to \&\fICMS_encrypt()\fR. .PP The following flags can be passed in the \fBflags\fR parameter. .PP If the \fB\s-1CMS_TEXT\s0\fR flag is set \s-1MIME\s0 headers for type \fBtext/plain\fR are prepended to the data. .PP Normally the supplied content is translated into \s-1MIME\s0 canonical format (as required by the S/MIME specifications) if \fB\s-1CMS_BINARY\s0\fR is set no translation occurs. This option should be used if the supplied data is in binary format otherwise the translation will corrupt it. If \fB\s-1CMS_BINARY\s0\fR is set then \&\fB\s-1CMS_TEXT\s0\fR is ignored. .PP OpenSSL will by default identify recipient certificates using issuer name and serial number. If \fB\s-1CMS_USE_KEYID\s0\fR is set it will use the subject key identifier value instead. An error occurs if all recipient certificates do not have a subject key identifier extension. .PP If the \fB\s-1CMS_STREAM\s0\fR flag is set a partial \fBCMS_ContentInfo\fR structure is returned suitable for streaming I/O: no data is read from the \s-1BIO \s0\fBin\fR. .PP If the \fB\s-1CMS_PARTIAL\s0\fR flag is set a partial \fBCMS_ContentInfo\fR structure is returned to which additional recipients and attributes can be added before finalization. .PP The data being encrypted is included in the CMS_ContentInfo structure, unless \&\fB\s-1CMS_DETACHED\s0\fR is set in which case it is omitted. This is rarely used in practice and is not supported by \fISMIME_write_CMS()\fR. .SH "NOTES" .IX Header "NOTES" If the flag \fB\s-1CMS_STREAM\s0\fR is set the returned \fBCMS_ContentInfo\fR structure is \&\fBnot\fR complete and outputting its contents via a function that does not properly finalize the \fBCMS_ContentInfo\fR structure will give unpredictable results. .PP Several functions including \fISMIME_write_CMS()\fR, \fIi2d_CMS_bio_stream()\fR, \&\fIPEM_write_bio_CMS_stream()\fR finalize the structure. Alternatively finalization can be performed by obtaining the streaming \s-1ASN1 \s0\fB\s-1BIO\s0\fR directly using \&\fIBIO_new_CMS()\fR. .PP The recipients specified in \fBcerts\fR use a \s-1CMS\s0 KeyTransRecipientInfo info structure. KEKRecipientInfo is also supported using the flag \fB\s-1CMS_PARTIAL\s0\fR and \fICMS_add0_recipient_key()\fR. .PP The parameter \fBcerts\fR may be \s-1NULL\s0 if \fB\s-1CMS_PARTIAL\s0\fR is set and recipients added later using \fICMS_add1_recipient_cert()\fR or \fICMS_add0_recipient_key()\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICMS_encrypt()\fR returns either a CMS_ContentInfo structure or \s-1NULL\s0 if an error occurred. The error can be obtained from \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_decrypt\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fICMS_decrypt()\fR was added to OpenSSL 0.9.8 The \fB\s-1CMS_STREAM\s0\fR flag was first supported in OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/RSA_generate_key.30000644000175000017500000001425012360020724020744 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RSA_generate_key 3" .TH RSA_generate_key 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RSA_generate_key_ex, RSA_generate_key \- generate RSA key pair .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); .Ve .PP Deprecated: .PP .Vb 2 \& RSA *RSA_generate_key(int num, unsigned long e, \& void (*callback)(int,int,void *), void *cb_arg); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIRSA_generate_key_ex()\fR generates a key pair and stores it in the \fB\s-1RSA\s0\fR structure provided in \fBrsa\fR. .PP The modulus size will be of length \fBbits\fR, and the public exponent will be \&\fBe\fR. Key sizes with \fBnum\fR < 1024 should be considered insecure. The exponent is an odd number, typically 3, 17 or 65537. .PP A callback function may be used to provide feedback about the progress of the key generation. If \fBcb\fR is not \fB\s-1NULL\s0\fR, it will be called as follows using the \fIBN_GENCB_call()\fR function described on the \fIBN_generate_prime\fR\|(3) page: .IP "\(bu" 4 While a random prime number is generated, it is called as described in \fIBN_generate_prime\fR\|(3). .IP "\(bu" 4 When the n\-th randomly generated prime is rejected as not suitable for the key, \fBBN_GENCB_call(cb, 2, n)\fR is called. .IP "\(bu" 4 When a random p has been found with p\-1 relatively prime to \fBe\fR, it is called as \fBBN_GENCB_call(cb, 3, 0)\fR. .PP The process is then repeated for prime q with \fBBN_GENCB_call(cb, 3, 1)\fR. .PP RSA_generate_key is deprecated (new applications should use RSA_generate_key_ex instead). RSA_generate_key works in the same was as RSA_generate_key_ex except it uses \*(L"old style\*(R" call backs. See \&\fIBN_generate_prime\fR\|(3) for further details. .SH "RETURN VALUE" .IX Header "RETURN VALUE" If key generation fails, \fIRSA_generate_key()\fR returns \fB\s-1NULL\s0\fR. .PP The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "BUGS" .IX Header "BUGS" \&\fBBN_GENCB_call(cb, 2, x)\fR is used with two different meanings. .PP \&\fIRSA_generate_key()\fR goes into an infinite loop for illegal input values. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fIrand\fR\|(3), \fIrsa\fR\|(3), \&\fIRSA_free\fR\|(3), \fIBN_generate_prime\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" The \fBcb_arg\fR argument was added in SSLeay 0.9.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/d2i_DHparams.30000644000175000017500000001075612360020726020043 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "d2i_DHparams 3" .TH d2i_DHparams 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" d2i_DHparams, i2d_DHparams \- PKCS#3 DH parameter functions. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& DH *d2i_DHparams(DH **a, unsigned char **pp, long length); \& int i2d_DHparams(DH *a, unsigned char **pp); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions decode and encode PKCS#3 \s-1DH\s0 parameters using the DHparameter structure described in PKCS#3. .PP Othewise these behave in a similar way to \fId2i_X509()\fR and \fIi2d_X509()\fR described in the \fId2i_X509\fR\|(3) manual page. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fId2i_X509\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/EC_GROUP_copy.30000644000175000017500000003424512360020716020101 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EC_GROUP_copy 3" .TH EC_GROUP_copy 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EC_GROUP_copy, EC_GROUP_dup, EC_GROUP_method_of, EC_GROUP_set_generator, EC_GROUP_get0_generator, EC_GROUP_get_order, EC_GROUP_get_cofactor, EC_GROUP_set_curve_name, EC_GROUP_get_curve_name, EC_GROUP_set_asn1_flag, EC_GROUP_get_asn1_flag, EC_GROUP_set_point_conversion_form, EC_GROUP_get_point_conversion_form, EC_GROUP_get0_seed, EC_GROUP_get_seed_len, EC_GROUP_set_seed, EC_GROUP_get_degree, EC_GROUP_check, EC_GROUP_check_discriminant, EC_GROUP_cmp, EC_GROUP_get_basis_type, EC_GROUP_get_trinomial_basis, EC_GROUP_get_pentanomial_basis \- Functions for manipulating EC_GROUP objects. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src); \& EC_GROUP *EC_GROUP_dup(const EC_GROUP *src); \& \& const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group); \& \& int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor); \& const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group); \& \& int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx); \& int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx); \& \& void EC_GROUP_set_curve_name(EC_GROUP *group, int nid); \& int EC_GROUP_get_curve_name(const EC_GROUP *group); \& \& void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag); \& int EC_GROUP_get_asn1_flag(const EC_GROUP *group); \& \& void EC_GROUP_set_point_conversion_form(EC_GROUP *group, point_conversion_form_t form); \& point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); \& \& unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x); \& size_t EC_GROUP_get_seed_len(const EC_GROUP *); \& size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); \& \& int EC_GROUP_get_degree(const EC_GROUP *group); \& \& int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); \& \& int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx); \& \& int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx); \& \& int EC_GROUP_get_basis_type(const EC_GROUP *); \& int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); \& int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, \& unsigned int *k2, unsigned int *k3); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" EC_GROUP_copy copies the curve \fBsrc\fR into \fBdst\fR. Both \fBsrc\fR and \fBdst\fR must use the same \s-1EC_METHOD.\s0 .PP EC_GROUP_dup creates a new \s-1EC_GROUP\s0 object and copies the content from \fBsrc\fR to the newly created \&\s-1EC_GROUP\s0 object. .PP EC_GROUP_method_of obtains the \s-1EC_METHOD\s0 of \fBgroup\fR. .PP EC_GROUP_set_generator sets curve paramaters that must be agreed by all participants using the curve. These paramaters include the \fBgenerator\fR, the \fBorder\fR and the \fBcofactor\fR. The \fBgenerator\fR is a well defined point on the curve chosen for cryptographic operations. Integers used for point multiplications will be between 0 and n\-1 where n is the \fBorder\fR. The \fBorder\fR multipied by the \fBcofactor\fR gives the number of points on the curve. .PP EC_GROUP_get0_generator returns the generator for the identified \fBgroup\fR. .PP The functions EC_GROUP_get_order and EC_GROUP_get_cofactor populate the provided \fBorder\fR and \fBcofactor\fR parameters with the respective order and cofactors for the \fBgroup\fR. .PP The functions EC_GROUP_set_curve_name and EC_GROUP_get_curve_name, set and get the \s-1NID\s0 for the curve respectively (see \fIEC_GROUP_new\fR\|(3)). If a curve does not have a \s-1NID\s0 associated with it, then EC_GROUP_get_curve_name will return 0. .PP The asn1_flag value on a curve is used to determine whether there is a specific \s-1ASN1 OID\s0 to describe the curve or not. If the asn1_flag is 1 then this is a named curve with an associated \s-1ASN1 OID.\s0 If not then asn1_flag is 0. The functions EC_GROUP_get_asn1_flag and EC_GROUP_set_asn1_flag get and set the status of the asn1_flag for the curve. If set then the curve_name must also be set. .PP The point_coversion_form for a curve controls how \s-1EC_POINT\s0 data is encoded as \s-1ASN1\s0 as defined in X9.62 (\s-1ECDSA\s0). point_conversion_form_t is an enum defined as follows: .PP .Vb 10 \& typedef enum { \& /** the point is encoded as z||x, where the octet z specifies \& * which solution of the quadratic equation y is */ \& POINT_CONVERSION_COMPRESSED = 2, \& /** the point is encoded as z||x||y, where z is the octet 0x02 */ \& POINT_CONVERSION_UNCOMPRESSED = 4, \& /** the point is encoded as z||x||y, where the octet z specifies \& * which solution of the quadratic equation y is */ \& POINT_CONVERSION_HYBRID = 6 \& } point_conversion_form_t; .Ve .PP For \s-1POINT_CONVERSION_UNCOMPRESSED\s0 the point is encoded as an octet signifying the \s-1UNCOMPRESSED\s0 form has been used followed by the octets for x, followed by the octets for y. .PP For any given x co-ordinate for a point on a curve it is possible to derive two possible y values. For \&\s-1POINT_CONVERSION_COMPRESSED\s0 the point is encoded as an octet signifying that the \s-1COMPRESSED\s0 form has been used \s-1AND\s0 which of the two possible solutions for y has been used, followed by the octets for x. .PP For \s-1POINT_CONVERSION_HYBRID\s0 the point is encoded as an octet signifying the \s-1HYBRID\s0 form has been used \s-1AND\s0 which of the two possible solutions for y has been used, followed by the octets for x, followed by the octets for y. .PP The functions EC_GROUP_set_point_conversion_form and EC_GROUP_get_point_conversion_form set and get the point_conversion_form for the curve respectively. .PP \&\s-1ANSI X9.62 \s0(\s-1ECDSA\s0 standard) defines a method of generating the curve parameter b from a random number. This provides advantages in that a parameter obtained in this way is highly unlikely to be susceptible to special purpose attacks, or have any trapdoors in it. If the seed is present for a curve then the b parameter was generated in a verifiable fashion using that seed. The OpenSSL \s-1EC\s0 library does not use this seed value but does enable you to inspect it using EC_GROUP_get0_seed. This returns a pointer to a memory block containing the seed that was used. The length of the memory block can be obtained using EC_GROUP_get_seed_len. A number of the builtin curves within the library provide seed values that can be obtained. It is also possible to set a custom seed using EC_GROUP_set_seed and passing a pointer to a memory block, along with the length of the seed. Again, the \s-1EC\s0 library will not use this seed value, although it will be preserved in any \s-1ASN1\s0 based communications. .PP EC_GROUP_get_degree gets the degree of the field. For Fp fields this will be the number of bits in p. For F2^m fields this will be the value m. .PP The function EC_GROUP_check_discriminant calculates the discriminant for the curve and verifies that it is valid. For a curve defined over Fp the discriminant is given by the formula 4*a^3 + 27*b^2 whilst for F2^m curves the discriminant is simply b. In either case for the curve to be valid the discriminant must be non zero. .PP The function EC_GROUP_check performs a number of checks on a curve to verify that it is valid. Checks performed include verifying that the discriminant is non zero; that a generator has been defined; that the generator is on the curve and has the correct order. .PP EC_GROUP_cmp compares \fBa\fR and \fBb\fR to determine whether they represent the same curve or not. .PP The functions EC_GROUP_get_basis_type, EC_GROUP_get_trinomial_basis and EC_GROUP_get_pentanomial_basis should only be called for curves defined over an F2^m field. Addition and multiplication operations within an F2^m field are performed using an irreducible polynomial function f(x). This function is either a trinomial of the form: .PP f(x) = x^m + x^k + 1 with m > k >= 1 .PP or a pentanomial of the form: .PP f(x) = x^m + x^k3 + x^k2 + x^k1 + 1 with m > k3 > k2 > k1 >= 1 .PP The function EC_GROUP_get_basis_type returns a \s-1NID\s0 identifying whether a trinomial or pentanomial is in use for the field. The function EC_GROUP_get_trinomial_basis must only be called where f(x) is of the trinomial form, and returns the value of \fBk\fR. Similary the function EC_GROUP_get_pentanomial_basis must only be called where f(x) is of the pentanomial form, and returns the values of \fBk1\fR, \&\fBk2\fR and \fBk3\fR respectively. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following functions return 1 on success or 0 on error: EC_GROUP_copy, EC_GROUP_set_generator, EC_GROUP_check, EC_GROUP_check_discriminant, EC_GROUP_get_trinomial_basis and EC_GROUP_get_pentanomial_basis. .PP EC_GROUP_dup returns a pointer to the duplicated curve, or \s-1NULL\s0 on error. .PP EC_GROUP_method_of returns the \s-1EC_METHOD\s0 implementation in use for the given curve or \s-1NULL\s0 on error. .PP EC_GROUP_get0_generator returns the generator for the given curve or \s-1NULL\s0 on error. .PP EC_GROUP_get_order, EC_GROUP_get_cofactor, EC_GROUP_get_curve_name, EC_GROUP_get_asn1_flag, EC_GROUP_get_point_conversion_form and EC_GROUP_get_degree return the order, cofactor, curve name (\s-1NID\s0), \s-1ASN1\s0 flag, point_conversion_form and degree for the specified curve respectively. If there is no curve name associated with a curve then EC_GROUP_get_curve_name will return 0. .PP EC_GROUP_get0_seed returns a pointer to the seed that was used to generate the parameter b, or \s-1NULL\s0 if the seed is not specified. EC_GROUP_get_seed_len returns the length of the seed or 0 if the seed is not specified. .PP EC_GROUP_set_seed returns the length of the seed that has been set. If the supplied seed is \s-1NULL,\s0 or the supplied seed length is 0, the the return value will be 1. On error 0 is returned. .PP EC_GROUP_cmp returns 0 if the curves are equal, 1 if they are not equal, or \-1 on error. .PP EC_GROUP_get_basis_type returns the values NID_X9_62_tpBasis or NID_X9_62_ppBasis (as defined in ) for a trinomial or pentanomial respectively. Alternatively in the event of an error a 0 is returned. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIcrypto\fR\|(3), \fIec\fR\|(3), \fIEC_GROUP_new\fR\|(3), \&\fIEC_POINT_new\fR\|(3), \fIEC_POINT_add\fR\|(3), \fIEC_KEY_new\fR\|(3), \&\fIEC_GFp_simple_method\fR\|(3), \fId2i_ECPKParameters\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_mod_mul_reciprocal.30000644000175000017500000001530012360020712022005 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_mod_mul_reciprocal 3" .TH BN_mod_mul_reciprocal 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_mod_mul_reciprocal, BN_div_recp, BN_RECP_CTX_new, BN_RECP_CTX_init, BN_RECP_CTX_free, BN_RECP_CTX_set \- modular multiplication using reciprocal .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BN_RECP_CTX *BN_RECP_CTX_new(void); \& void BN_RECP_CTX_init(BN_RECP_CTX *recp); \& void BN_RECP_CTX_free(BN_RECP_CTX *recp); \& \& int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *m, BN_CTX *ctx); \& \& int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *a, BN_RECP_CTX *recp, \& BN_CTX *ctx); \& \& int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *a, BIGNUM *b, \& BN_RECP_CTX *recp, BN_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBN_mod_mul_reciprocal()\fR can be used to perform an efficient \&\fIBN_mod_mul\fR\|(3) operation when the operation will be performed repeatedly with the same modulus. It computes \fBr\fR=(\fBa\fR*\fBb\fR)%\fBm\fR using \fBrecp\fR=1/\fBm\fR, which is set as described below. \fBctx\fR is a previously allocated \fB\s-1BN_CTX\s0\fR used for temporary variables. .PP \&\fIBN_RECP_CTX_new()\fR allocates and initializes a \fB\s-1BN_RECP\s0\fR structure. \&\fIBN_RECP_CTX_init()\fR initializes an existing uninitialized \fB\s-1BN_RECP\s0\fR. .PP \&\fIBN_RECP_CTX_free()\fR frees the components of the \fB\s-1BN_RECP\s0\fR, and, if it was created by \fIBN_RECP_CTX_new()\fR, also the structure itself. .PP \&\fIBN_RECP_CTX_set()\fR stores \fBm\fR in \fBrecp\fR and sets it up for computing 1/\fBm\fR and shifting it left by BN_num_bits(\fBm\fR)+1 to make it an integer. The result and the number of bits it was shifted left will later be stored in \fBrecp\fR. .PP \&\fIBN_div_recp()\fR divides \fBa\fR by \fBm\fR using \fBrecp\fR. It places the quotient in \fBdv\fR and the remainder in \fBrem\fR. .PP The \fB\s-1BN_RECP_CTX\s0\fR structure is defined as follows: .PP .Vb 8 \& typedef struct bn_recp_ctx_st \& { \& BIGNUM N; /* the divisor */ \& BIGNUM Nr; /* the reciprocal */ \& int num_bits; \& int shift; \& int flags; \& } BN_RECP_CTX; .Ve .PP It cannot be shared between threads. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBN_RECP_CTX_new()\fR returns the newly allocated \fB\s-1BN_RECP_CTX\s0\fR, and \s-1NULL\s0 on error. .PP \&\fIBN_RECP_CTX_init()\fR and \fIBN_RECP_CTX_free()\fR have no return values. .PP For the other functions, 1 is returned for success, 0 on error. The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3), \fIERR_get_error\fR\|(3), \fIBN_add\fR\|(3), \&\fIBN_CTX_new\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fB\s-1BN_RECP_CTX\s0\fR was added in SSLeay 0.9.0. Before that, the function \&\fIBN_reciprocal()\fR was used instead, and the \fIBN_mod_mul_reciprocal()\fR arguments were different. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_set_fd.30000644000175000017500000001274512360020737017575 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_set_fd 3" .TH SSL_set_fd 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_set_fd, SSL_set_rfd, SSL_set_wfd \- connect the SSL object with a file descriptor .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_set_fd(SSL *ssl, int fd); \& int SSL_set_rfd(SSL *ssl, int fd); \& int SSL_set_wfd(SSL *ssl, int fd); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_set_fd()\fR sets the file descriptor \fBfd\fR as the input/output facility for the \s-1TLS/SSL \s0(encrypted) side of \fBssl\fR. \fBfd\fR will typically be the socket file descriptor of a network connection. .PP When performing the operation, a \fBsocket \s-1BIO\s0\fR is automatically created to interface between the \fBssl\fR and \fBfd\fR. The \s-1BIO\s0 and hence the \s-1SSL\s0 engine inherit the behaviour of \fBfd\fR. If \fBfd\fR is non-blocking, the \fBssl\fR will also have non-blocking behaviour. .PP If there was already a \s-1BIO\s0 connected to \fBssl\fR, \fIBIO_free()\fR will be called (for both the reading and writing side, if different). .PP \&\fISSL_set_rfd()\fR and \fISSL_set_wfd()\fR perform the respective action, but only for the read channel or the write channel, which can be set independently. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" The operation failed. Check the error stack to find out why. .ie n .IP "1" 4 .el .IP "\f(CW1\fR" 4 .IX Item "1" The operation succeeded. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_get_fd\fR\|(3), \fISSL_set_bio\fR\|(3), \&\fISSL_connect\fR\|(3), \fISSL_accept\fR\|(3), \&\fISSL_shutdown\fR\|(3), \fIssl\fR\|(3) , \fIbio\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_session_id_context.30000644000175000017500000001563712360020733023624 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_session_id_context 3" .TH SSL_CTX_set_session_id_context 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_session_id_context, SSL_set_session_id_context \- set context within which session can be reused (server side only) .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx, \& unsigned int sid_ctx_len); \& int SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx, \& unsigned int sid_ctx_len); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_session_id_context()\fR sets the context \fBsid_ctx\fR of length \&\fBsid_ctx_len\fR within which a session can be reused for the \fBctx\fR object. .PP \&\fISSL_set_session_id_context()\fR sets the context \fBsid_ctx\fR of length \&\fBsid_ctx_len\fR within which a session can be reused for the \fBssl\fR object. .SH "NOTES" .IX Header "NOTES" Sessions are generated within a certain context. When exporting/importing sessions with \fBi2d_SSL_SESSION\fR/\fBd2i_SSL_SESSION\fR it would be possible, to re-import a session generated from another context (e.g. another application), which might lead to malfunctions. Therefore each application must set its own session id context \fBsid_ctx\fR which is used to distinguish the contexts and is stored in exported sessions. The \fBsid_ctx\fR can be any kind of binary data with a given length, it is therefore possible to use e.g. the name of the application and/or the hostname and/or service name ... .PP The session id context becomes part of the session. The session id context is set by the \s-1SSL/TLS\s0 server. The \fISSL_CTX_set_session_id_context()\fR and \&\fISSL_set_session_id_context()\fR functions are therefore only useful on the server side. .PP OpenSSL clients will check the session id context returned by the server when reusing a session. .PP The maximum length of the \fBsid_ctx\fR is limited to \&\fB\s-1SSL_MAX_SSL_SESSION_ID_LENGTH\s0\fR. .SH "WARNINGS" .IX Header "WARNINGS" If the session id context is not set on an \s-1SSL/TLS\s0 server and client certificates are used, stored sessions will not be reused but a fatal error will be flagged and the handshake will fail. .PP If a server returns a different session id context to an OpenSSL client when reusing a session, an error will be flagged and the handshake will fail. OpenSSL servers will always return the correct session id context, as an OpenSSL server checks the session id context itself before reusing a session as described above. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_set_session_id_context()\fR and \fISSL_set_session_id_context()\fR return the following values: .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" The length \fBsid_ctx_len\fR of the session id context \fBsid_ctx\fR exceeded the maximum allowed length of \fB\s-1SSL_MAX_SSL_SESSION_ID_LENGTH\s0\fR. The error is logged to the error stack. .ie n .IP "1" 4 .el .IP "\f(CW1\fR" 4 .IX Item "1" The operation succeeded. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_do_handshake.30000644000175000017500000001544412360020734020735 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_do_handshake 3" .TH SSL_do_handshake 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_do_handshake \- perform a TLS/SSL handshake .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_do_handshake(SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_do_handshake()\fR will wait for a \s-1SSL/TLS\s0 handshake to take place. If the connection is in client mode, the handshake will be started. The handshake routines may have to be explicitly set in advance using either \&\fISSL_set_connect_state\fR\|(3) or \&\fISSL_set_accept_state\fR\|(3). .SH "NOTES" .IX Header "NOTES" The behaviour of \fISSL_do_handshake()\fR depends on the underlying \s-1BIO.\s0 .PP If the underlying \s-1BIO\s0 is \fBblocking\fR, \fISSL_do_handshake()\fR will only return once the handshake has been finished or an error occurred, except for \s-1SGC \&\s0(Server Gated Cryptography). For \s-1SGC,\s0 \fISSL_do_handshake()\fR may return with \-1, but \fISSL_get_error()\fR will yield \fB\s-1SSL_ERROR_WANT_READ/WRITE\s0\fR and \&\fISSL_do_handshake()\fR should be called again. .PP If the underlying \s-1BIO\s0 is \fBnon-blocking\fR, \fISSL_do_handshake()\fR will also return when the underlying \s-1BIO\s0 could not satisfy the needs of \fISSL_do_handshake()\fR to continue the handshake. In this case a call to \fISSL_get_error()\fR with the return value of \fISSL_do_handshake()\fR will yield \fB\s-1SSL_ERROR_WANT_READ\s0\fR or \&\fB\s-1SSL_ERROR_WANT_WRITE\s0\fR. The calling process then must repeat the call after taking appropriate action to satisfy the needs of \fISSL_do_handshake()\fR. The action depends on the underlying \s-1BIO.\s0 When using a non-blocking socket, nothing is to be done, but \fIselect()\fR can be used to check for the required condition. When using a buffering \s-1BIO,\s0 like a \s-1BIO\s0 pair, data must be written into or retrieved out of the \s-1BIO\s0 before being able to continue. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" The \s-1TLS/SSL\s0 handshake was not successful but was shut down controlled and by the specifications of the \s-1TLS/SSL\s0 protocol. Call \fISSL_get_error()\fR with the return value \fBret\fR to find out the reason. .ie n .IP "1" 4 .el .IP "\f(CW1\fR" 4 .IX Item "1" The \s-1TLS/SSL\s0 handshake was successfully completed, a \s-1TLS/SSL\s0 connection has been established. .ie n .IP """<0""" 4 .el .IP "\f(CW<0\fR" 4 .IX Item "<0" The \s-1TLS/SSL\s0 handshake was not successful because a fatal error occurred either at the protocol level or a connection failure occurred. The shutdown was not clean. It can also occur of action is need to continue the operation for non-blocking BIOs. Call \fISSL_get_error()\fR with the return value \fBret\fR to find out the reason. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_get_error\fR\|(3), \fISSL_connect\fR\|(3), \&\fISSL_accept\fR\|(3), \fIssl\fR\|(3), \fIbio\fR\|(3), \&\fISSL_set_connect_state\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_f_buffer.30000644000175000017500000001570412360020707020052 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_f_buffer 3" .TH BIO_f_buffer 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_f_buffer \- buffering BIO .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIO_METHOD * BIO_f_buffer(void); \& \& #define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL) \& #define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0) \& #define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1) \& #define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL) \& #define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf) .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_f_buffer()\fR returns the buffering \s-1BIO\s0 method. .PP Data written to a buffering \s-1BIO\s0 is buffered and periodically written to the next \s-1BIO\s0 in the chain. Data read from a buffering \s-1BIO\s0 comes from an internal buffer which is filled from the next \s-1BIO\s0 in the chain. Both \fIBIO_gets()\fR and \fIBIO_puts()\fR are supported. .PP Calling \fIBIO_reset()\fR on a buffering \s-1BIO\s0 clears any buffered data. .PP \&\fIBIO_get_buffer_num_lines()\fR returns the number of lines currently buffered. .PP \&\fIBIO_set_read_buffer_size()\fR, \fIBIO_set_write_buffer_size()\fR and \&\fIBIO_set_buffer_size()\fR set the read, write or both read and write buffer sizes to \fBsize\fR. The initial buffer size is \s-1DEFAULT_BUFFER_SIZE,\s0 currently 4096. Any attempt to reduce the buffer size below \s-1DEFAULT_BUFFER_SIZE\s0 is ignored. Any buffered data is cleared when the buffer is resized. .PP \&\fIBIO_set_buffer_read_data()\fR clears the read buffer and fills it with \fBnum\fR bytes of \fBbuf\fR. If \fBnum\fR is larger than the current buffer size the buffer is expanded. .SH "NOTES" .IX Header "NOTES" Buffering BIOs implement \fIBIO_gets()\fR by using \fIBIO_read()\fR operations on the next \s-1BIO\s0 in the chain. By prepending a buffering \s-1BIO\s0 to a chain it is therefore possible to provide \fIBIO_gets()\fR functionality if the following BIOs do not support it (for example \s-1SSL\s0 BIOs). .PP Data is only written to the next \s-1BIO\s0 in the chain when the write buffer fills or when \fIBIO_flush()\fR is called. It is therefore important to call \fIBIO_flush()\fR whenever any pending data should be written such as when removing a buffering \&\s-1BIO\s0 using \fIBIO_pop()\fR. \fIBIO_flush()\fR may need to be retried if the ultimate source/sink \s-1BIO\s0 is non blocking. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBIO_f_buffer()\fR returns the buffering \s-1BIO\s0 method. .PP \&\fIBIO_get_buffer_num_lines()\fR returns the number of lines buffered (may be 0). .PP \&\fIBIO_set_read_buffer_size()\fR, \fIBIO_set_write_buffer_size()\fR and \&\fIBIO_set_buffer_size()\fR return 1 if the buffer was successfully resized or 0 for failure. .PP \&\fIBIO_set_buffer_read_data()\fR returns 1 if the data was set correctly or 0 if there was an error. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\s-1\fIBIO\s0\fR\|(3), \&\fIBIO_reset\fR\|(3), \&\fIBIO_flush\fR\|(3), \&\fIBIO_pop\fR\|(3), \&\fIBIO_ctrl\fR\|(3), \&\fIBIO_int_ctrl\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_set_connect_state.30000644000175000017500000001337312360020737022033 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_set_connect_state 3" .TH SSL_set_connect_state 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_set_connect_state, SSL_get_accept_state \- prepare SSL object to work in client or server mode .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_set_connect_state(SSL *ssl); \& \& void SSL_set_accept_state(SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_set_connect_state()\fR sets \fBssl\fR to work in client mode. .PP \&\fISSL_set_accept_state()\fR sets \fBssl\fR to work in server mode. .SH "NOTES" .IX Header "NOTES" When the \s-1SSL_CTX\s0 object was created with \fISSL_CTX_new\fR\|(3), it was either assigned a dedicated client method, a dedicated server method, or a generic method, that can be used for both client and server connections. (The method might have been changed with \&\fISSL_CTX_set_ssl_version\fR\|(3) or \&\fISSL_set_ssl_method()\fR.) .PP When beginning a new handshake, the \s-1SSL\s0 engine must know whether it must call the connect (client) or accept (server) routines. Even though it may be clear from the method chosen, whether client or server mode was requested, the handshake routines must be explicitly set. .PP When using the \fISSL_connect\fR\|(3) or \&\fISSL_accept\fR\|(3) routines, the correct handshake routines are automatically set. When performing a transparent negotiation using \fISSL_write\fR\|(3) or \fISSL_read\fR\|(3), the handshake routines must be explicitly set in advance using either \&\fISSL_set_connect_state()\fR or \fISSL_set_accept_state()\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_set_connect_state()\fR and \fISSL_set_accept_state()\fR do not return diagnostic information. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_new\fR\|(3), \fISSL_CTX_new\fR\|(3), \&\fISSL_connect\fR\|(3), \fISSL_accept\fR\|(3), \&\fISSL_write\fR\|(3), \fISSL_read\fR\|(3), \&\fISSL_do_handshake\fR\|(3), \&\fISSL_CTX_set_ssl_version\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/EC_GROUP_new.30000644000175000017500000002204412360020716017712 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EC_GROUP_new 3" .TH EC_GROUP_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EC_GROUP_new, EC_GROUP_free, EC_GROUP_clear_free, EC_GROUP_new_curve_GFp, EC_GROUP_new_curve_GF2m, EC_GROUP_new_by_curve_name, EC_GROUP_set_curve_GFp, EC_GROUP_get_curve_GFp, EC_GROUP_set_curve_GF2m, EC_GROUP_get_curve_GF2m, EC_get_builtin_curves \- Functions for creating and destroying EC_GROUP objects. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& EC_GROUP *EC_GROUP_new(const EC_METHOD *meth); \& void EC_GROUP_free(EC_GROUP *group); \& void EC_GROUP_clear_free(EC_GROUP *group); \& \& EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); \& EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); \& EC_GROUP *EC_GROUP_new_by_curve_name(int nid); \& \& int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); \& int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); \& int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); \& int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); \& \& size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Within the library there are two forms of elliptic curve that are of interest. The first form is those defined over the prime field Fp. The elements of Fp are the integers 0 to p\-1, where p is a prime number. This gives us a revised elliptic curve equation as follows: .PP y^2 mod p = x^3 +ax + b mod p .PP The second form is those defined over a binary field F2^m where the elements of the field are integers of length at most m bits. For this form the elliptic curve equation is modified to: .PP y^2 + xy = x^3 + ax^2 + b (where b != 0) .PP Operations in a binary field are performed relative to an \fBirreducible polynomial\fR. All such curves with OpenSSL use a trinomial or a pentanomial for this parameter. .PP A new curve can be constructed by calling EC_GROUP_new, using the implementation provided by \fBmeth\fR (see \&\fIEC_GFp_simple_method\fR\|(3)). It is then necessary to call either EC_GROUP_set_curve_GFp or EC_GROUP_set_curve_GF2m as appropriate to create a curve defined over Fp or over F2^m respectively. .PP EC_GROUP_set_curve_GFp sets the curve parameters \fBp\fR, \fBa\fR and \fBb\fR for a curve over Fp stored in \fBgroup\fR. EC_group_get_curve_GFp obtains the previously set curve parameters. .PP EC_GROUP_set_curve_GF2m sets the equivalent curve parameters for a curve over F2^m. In this case \fBp\fR represents the irreducible polybnomial \- each bit represents a term in the polynomial. Therefore there will either be three or five bits set dependant on whether the polynomial is a trinomial or a pentanomial. EC_group_get_curve_GF2m obtains the previously set curve parameters. .PP The functions EC_GROUP_new_curve_GFp and EC_GROUP_new_curve_GF2m are shortcuts for calling EC_GROUP_new and the appropriate EC_group_set_curve function. An appropriate default implementation method will be used. .PP Whilst the library can be used to create any curve using the functions described above, there are also a number of predefined curves that are available. In order to obtain a list of all of the predefined curves, call the function EC_get_builtin_curves. The parameter \fBr\fR should be an array of EC_builtin_curve structures of size \fBnitems\fR. The function will populate the \fBr\fR array with information about the builtin curves. If \fBnitems\fR is less than the total number of curves available, then the first \fBnitems\fR curves will be returned. Otherwise the total number of curves will be provided. The return value is the total number of curves available (whether that number has been populated in \fBr\fR or not). Passing a \s-1NULL \s0\fBr\fR, or setting \fBnitems\fR to 0 will do nothing other than return the total number of curves available. The EC_builtin_curve structure is defined as follows: .PP .Vb 4 \& typedef struct { \& int nid; \& const char *comment; \& } EC_builtin_curve; .Ve .PP Each EC_builtin_curve item has a unique integer id (\fBnid\fR), and a human readable comment string describing the curve. .PP In order to construct a builtin curve use the function EC_GROUP_new_by_curve_name and provide the \fBnid\fR of the curve to be constructed. .PP EC_GROUP_free frees the memory associated with the \s-1EC_GROUP.\s0 .PP EC_GROUP_clear_free destroys any sensitive data held within the \s-1EC_GROUP\s0 and then frees its memory. .SH "RETURN VALUES" .IX Header "RETURN VALUES" All EC_GROUP_new* functions return a pointer to the newly constructed group, or \s-1NULL\s0 on error. .PP EC_get_builtin_curves returns the number of builtin curves that are available. .PP EC_GROUP_set_curve_GFp, EC_GROUP_get_curve_GFp, EC_GROUP_set_curve_GF2m, EC_GROUP_get_curve_GF2m return 1 on success or 0 on error. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIcrypto\fR\|(3), \fIec\fR\|(3), \fIEC_GROUP_copy\fR\|(3), \&\fIEC_POINT_new\fR\|(3), \fIEC_POINT_add\fR\|(3), \fIEC_KEY_new\fR\|(3), \&\fIEC_GFp_simple_method\fR\|(3), \fId2i_ECPKParameters\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/pkcs7.10000644000175000017500000001524512360020742016627 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "pkcs7 1" .TH pkcs7 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" pkcs7 \- PKCS#7 utility .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBpkcs7\fR [\fB\-inform PEM|DER\fR] [\fB\-outform PEM|DER\fR] [\fB\-in filename\fR] [\fB\-out filename\fR] [\fB\-print_certs\fR] [\fB\-text\fR] [\fB\-noout\fR] [\fB\-engine id\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBpkcs7\fR command processes PKCS#7 files in \s-1DER\s0 or \s-1PEM\s0 format. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" .IP "\fB\-inform DER|PEM\fR" 4 .IX Item "-inform DER|PEM" This specifies the input format. \fB\s-1DER\s0\fR format is \s-1DER\s0 encoded PKCS#7 v1.5 structure.\fB\s-1PEM\s0\fR (the default) is a base64 encoded version of the \s-1DER\s0 form with header and footer lines. .IP "\fB\-outform DER|PEM\fR" 4 .IX Item "-outform DER|PEM" This specifies the output format, the options have the same meaning as the \&\fB\-inform\fR option. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read from or standard input if this option is not specified. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" specifies the output filename to write to or standard output by default. .IP "\fB\-print_certs\fR" 4 .IX Item "-print_certs" prints out any certificates or CRLs contained in the file. They are preceded by their subject and issuer names in one line format. .IP "\fB\-text\fR" 4 .IX Item "-text" prints out certificates details in full rather than just subject and issuer names. .IP "\fB\-noout\fR" 4 .IX Item "-noout" don't output the encoded version of the PKCS#7 structure (or certificates is \fB\-print_certs\fR is set). .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBpkcs7\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .SH "EXAMPLES" .IX Header "EXAMPLES" Convert a PKCS#7 file from \s-1PEM\s0 to \s-1DER:\s0 .PP .Vb 1 \& openssl pkcs7 \-in file.pem \-outform DER \-out file.der .Ve .PP Output all certificates in a file: .PP .Vb 1 \& openssl pkcs7 \-in file.pem \-print_certs \-out certs.pem .Ve .SH "NOTES" .IX Header "NOTES" The \s-1PEM\s0 PKCS#7 format uses the header and footer lines: .PP .Vb 2 \& \-\-\-\-\-BEGIN PKCS7\-\-\-\-\- \& \-\-\-\-\-END PKCS7\-\-\-\-\- .Ve .PP For compatibility with some CAs it will also accept: .PP .Vb 2 \& \-\-\-\-\-BEGIN CERTIFICATE\-\-\-\-\- \& \-\-\-\-\-END CERTIFICATE\-\-\-\-\- .Ve .SH "RESTRICTIONS" .IX Header "RESTRICTIONS" There is no option to print out all the fields of a PKCS#7 file. .PP This PKCS#7 routines only understand PKCS#7 v 1.5 as specified in \s-1RFC2315\s0 they cannot currently parse, for example, the new \s-1CMS\s0 as described in \s-1RFC2630.\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIcrl2pkcs7\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/ERR_GET_LIB.30000644000175000017500000001272412360020716017417 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ERR_GET_LIB 3" .TH ERR_GET_LIB 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ERR_GET_LIB, ERR_GET_FUNC, ERR_GET_REASON \- get library, function and reason code .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int ERR_GET_LIB(unsigned long e); \& \& int ERR_GET_FUNC(unsigned long e); \& \& int ERR_GET_REASON(unsigned long e); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The error code returned by \fIERR_get_error()\fR consists of a library number, function code and reason code. \s-1\fIERR_GET_LIB\s0()\fR, \s-1\fIERR_GET_FUNC\s0()\fR and \s-1\fIERR_GET_REASON\s0()\fR can be used to extract these. .PP The library number and function code describe where the error occurred, the reason code is the information about what went wrong. .PP Each sub-library of OpenSSL has a unique library number; function and reason codes are unique within each sub-library. Note that different libraries may use the same value to signal different functions and reasons. .PP \&\fB\s-1ERR_R_...\s0\fR reason codes such as \fB\s-1ERR_R_MALLOC_FAILURE\s0\fR are globally unique. However, when checking for sub-library specific reason codes, be sure to also compare the library number. .PP \&\s-1\fIERR_GET_LIB\s0()\fR, \s-1\fIERR_GET_FUNC\s0()\fR and \s-1\fIERR_GET_REASON\s0()\fR are macros. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The library number, function code and reason code respectively. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIerr\fR\|(3), \fIERR_get_error\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\s-1\fIERR_GET_LIB\s0()\fR, \s-1\fIERR_GET_FUNC\s0()\fR and \s-1\fIERR_GET_REASON\s0()\fR are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_want.30000644000175000017500000001457312360020737017303 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_want 3" .TH SSL_want 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_want, SSL_want_nothing, SSL_want_read, SSL_want_write, SSL_want_x509_lookup \&\- obtain state information TLS/SSL I/O operation .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_want(const SSL *ssl); \& int SSL_want_nothing(const SSL *ssl); \& int SSL_want_read(const SSL *ssl); \& int SSL_want_write(const SSL *ssl); \& int SSL_want_x509_lookup(const SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_want()\fR returns state information for the \s-1SSL\s0 object \fBssl\fR. .PP The other SSL_want_*() calls are shortcuts for the possible states returned by \fISSL_want()\fR. .SH "NOTES" .IX Header "NOTES" \&\fISSL_want()\fR examines the internal state information of the \s-1SSL\s0 object. Its return values are similar to that of \fISSL_get_error\fR\|(3). Unlike \fISSL_get_error\fR\|(3), which also evaluates the error queue, the results are obtained by examining an internal state flag only. The information must therefore only be used for normal operation under non-blocking I/O. Error conditions are not handled and must be treated using \fISSL_get_error\fR\|(3). .PP The result returned by \fISSL_want()\fR should always be consistent with the result of \fISSL_get_error\fR\|(3). .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can currently occur for \fISSL_want()\fR: .IP "\s-1SSL_NOTHING\s0" 4 .IX Item "SSL_NOTHING" There is no data to be written or to be read. .IP "\s-1SSL_WRITING\s0" 4 .IX Item "SSL_WRITING" There are data in the \s-1SSL\s0 buffer that must be written to the underlying \&\fB\s-1BIO\s0\fR layer in order to complete the actual SSL_*() operation. A call to \fISSL_get_error\fR\|(3) should return \&\s-1SSL_ERROR_WANT_WRITE.\s0 .IP "\s-1SSL_READING\s0" 4 .IX Item "SSL_READING" More data must be read from the underlying \fB\s-1BIO\s0\fR layer in order to complete the actual SSL_*() operation. A call to \fISSL_get_error\fR\|(3) should return \&\s-1SSL_ERROR_WANT_READ.\s0 .IP "\s-1SSL_X509_LOOKUP\s0" 4 .IX Item "SSL_X509_LOOKUP" The operation did not complete because an application callback set by \&\fISSL_CTX_set_client_cert_cb()\fR has asked to be called again. A call to \fISSL_get_error\fR\|(3) should return \&\s-1SSL_ERROR_WANT_X509_LOOKUP.\s0 .PP \&\fISSL_want_nothing()\fR, \fISSL_want_read()\fR, \fISSL_want_write()\fR, \fISSL_want_x509_lookup()\fR return 1, when the corresponding condition is true or 0 otherwise. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fIerr\fR\|(3), \fISSL_get_error\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_get_error.30000644000175000017500000002164412360020735020315 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_get_error 3" .TH SSL_get_error 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_get_error \- obtain result code for TLS/SSL I/O operation .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_get_error(const SSL *ssl, int ret); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_get_error()\fR returns a result code (suitable for the C \*(L"switch\*(R" statement) for a preceding call to \fISSL_connect()\fR, \fISSL_accept()\fR, \fISSL_do_handshake()\fR, \&\fISSL_read()\fR, \fISSL_peek()\fR, or \fISSL_write()\fR on \fBssl\fR. The value returned by that \&\s-1TLS/SSL I/O\s0 function must be passed to \fISSL_get_error()\fR in parameter \fBret\fR. .PP In addition to \fBssl\fR and \fBret\fR, \fISSL_get_error()\fR inspects the current thread's OpenSSL error queue. Thus, \fISSL_get_error()\fR must be used in the same thread that performed the \s-1TLS/SSL I/O\s0 operation, and no other OpenSSL function calls should appear in between. The current thread's error queue must be empty before the \s-1TLS/SSL I/O\s0 operation is attempted, or \fISSL_get_error()\fR will not work reliably. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can currently occur: .IP "\s-1SSL_ERROR_NONE\s0" 4 .IX Item "SSL_ERROR_NONE" The \s-1TLS/SSL I/O\s0 operation completed. This result code is returned if and only if \fBret > 0\fR. .IP "\s-1SSL_ERROR_ZERO_RETURN\s0" 4 .IX Item "SSL_ERROR_ZERO_RETURN" The \s-1TLS/SSL\s0 connection has been closed. If the protocol version is \s-1SSL 3.0\s0 or \s-1TLS 1.0,\s0 this result code is returned only if a closure alert has occurred in the protocol, i.e. if the connection has been closed cleanly. Note that in this case \fB\s-1SSL_ERROR_ZERO_RETURN\s0\fR does not necessarily indicate that the underlying transport has been closed. .IP "\s-1SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE\s0" 4 .IX Item "SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE" The operation did not complete; the same \s-1TLS/SSL I/O\s0 function should be called again later. If, by then, the underlying \fB\s-1BIO\s0\fR has data available for reading (if the result code is \fB\s-1SSL_ERROR_WANT_READ\s0\fR) or allows writing data (\fB\s-1SSL_ERROR_WANT_WRITE\s0\fR), then some \s-1TLS/SSL\s0 protocol progress will take place, i.e. at least part of an \s-1TLS/SSL\s0 record will be read or written. Note that the retry may again lead to a \fB\s-1SSL_ERROR_WANT_READ\s0\fR or \fB\s-1SSL_ERROR_WANT_WRITE\s0\fR condition. There is no fixed upper limit for the number of iterations that may be necessary until progress becomes visible at application protocol level. .Sp For socket \fB\s-1BIO\s0\fRs (e.g. when \fISSL_set_fd()\fR was used), \fIselect()\fR or \&\fIpoll()\fR on the underlying socket can be used to find out when the \&\s-1TLS/SSL I/O\s0 function should be retried. .Sp Caveat: Any \s-1TLS/SSL I/O\s0 function can lead to either of \&\fB\s-1SSL_ERROR_WANT_READ\s0\fR and \fB\s-1SSL_ERROR_WANT_WRITE\s0\fR. In particular, \&\fISSL_read()\fR or \fISSL_peek()\fR may want to write data and \fISSL_write()\fR may want to read data. This is mainly because \s-1TLS/SSL\s0 handshakes may occur at any time during the protocol (initiated by either the client or the server); \&\fISSL_read()\fR, \fISSL_peek()\fR, and \fISSL_write()\fR will handle any pending handshakes. .IP "\s-1SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT\s0" 4 .IX Item "SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT" The operation did not complete; the same \s-1TLS/SSL I/O\s0 function should be called again later. The underlying \s-1BIO\s0 was not connected yet to the peer and the call would block in \fIconnect()\fR/\fIaccept()\fR. The \s-1SSL\s0 function should be called again when the connection is established. These messages can only appear with a \fIBIO_s_connect()\fR or \fIBIO_s_accept()\fR \s-1BIO,\s0 respectively. In order to find out, when the connection has been successfully established, on many platforms \fIselect()\fR or \fIpoll()\fR for writing on the socket file descriptor can be used. .IP "\s-1SSL_ERROR_WANT_X509_LOOKUP\s0" 4 .IX Item "SSL_ERROR_WANT_X509_LOOKUP" The operation did not complete because an application callback set by \&\fISSL_CTX_set_client_cert_cb()\fR has asked to be called again. The \s-1TLS/SSL I/O\s0 function should be called again later. Details depend on the application. .IP "\s-1SSL_ERROR_SYSCALL\s0" 4 .IX Item "SSL_ERROR_SYSCALL" Some I/O error occurred. The OpenSSL error queue may contain more information on the error. If the error queue is empty (i.e. \fIERR_get_error()\fR returns 0), \fBret\fR can be used to find out more about the error: If \fBret == 0\fR, an \s-1EOF\s0 was observed that violates the protocol. If \fBret == \-1\fR, the underlying \fB\s-1BIO\s0\fR reported an I/O error (for socket I/O on Unix systems, consult \fBerrno\fR for details). .IP "\s-1SSL_ERROR_SSL\s0" 4 .IX Item "SSL_ERROR_SSL" A failure in the \s-1SSL\s0 library occurred, usually a protocol error. The OpenSSL error queue contains more information on the error. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fIerr\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fISSL_get_error()\fR was added in SSLeay 0.8. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_new.30000644000175000017500000001161212360020736017111 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_new 3" .TH SSL_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_new \- create a new SSL structure for a connection .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& SSL *SSL_new(SSL_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_new()\fR creates a new \fB\s-1SSL\s0\fR structure which is needed to hold the data for a \s-1TLS/SSL\s0 connection. The new structure inherits the settings of the underlying context \fBctx\fR: connection method (SSLv2/v3/TLSv1), options, verification settings, timeout settings. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .IP "\s-1NULL\s0" 4 .IX Item "NULL" The creation of a new \s-1SSL\s0 structure failed. Check the error stack to find out the reason. .IP "Pointer to an \s-1SSL\s0 structure" 4 .IX Item "Pointer to an SSL structure" The return value points to an allocated \s-1SSL\s0 structure. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_free\fR\|(3), \fISSL_clear\fR\|(3), \&\fISSL_CTX_set_options\fR\|(3), \&\fISSL_get_SSL_CTX\fR\|(3), \&\fIssl\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/i2d_PKCS7_bio_stream.30000644000175000017500000001177312360020730021372 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "i2d_PKCS7_bio_stream 3" .TH i2d_PKCS7_bio_stream 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" i2d_PKCS7_bio_stream \- output PKCS7 structure in BER format. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *data, int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIi2d_PKCS7_bio_stream()\fR outputs a \s-1PKCS7\s0 structure in \s-1BER\s0 format. .PP It is otherwise identical to the function \fISMIME_write_PKCS7()\fR. .SH "NOTES" .IX Header "NOTES" This function is effectively a version of the \fId2i_PKCS7_bio()\fR supporting streaming. .SH "BUGS" .IX Header "BUGS" The prefix \*(L"i2d\*(R" is arguably wrong because the function outputs \s-1BER\s0 format. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIi2d_PKCS7_bio_stream()\fR returns 1 for success or 0 for failure. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fIPKCS7_sign\fR\|(3), \&\fIPKCS7_verify\fR\|(3), \fIPKCS7_encrypt\fR\|(3) \&\fIPKCS7_decrypt\fR\|(3), \&\fISMIME_write_PKCS7\fR\|(3), \&\fIPEM_write_bio_PKCS7_stream\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIi2d_PKCS7_bio_stream()\fR was added to OpenSSL 1.0.0 deps/libressl-pnacl-sys-2.1.6/libressl/man/X509_STORE_CTX_set_verify_cb.30000644000175000017500000002326512360020725022646 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "X509_STORE_CTX_set_verify_cb 3" .TH X509_STORE_CTX_set_verify_cb 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" X509_STORE_CTX_set_verify_cb \- set verification callback .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, \& int (*verify_cb)(int ok, X509_STORE_CTX *ctx)); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIX509_STORE_CTX_set_verify_cb()\fR sets the verification callback of \fBctx\fR to \&\fBverify_cb\fR overwriting any existing callback. .PP The verification callback can be used to customise the operation of certificate verification, either by overriding error conditions or logging errors for debugging purposes. .PP However a verification callback is \fBnot\fR essential and the default operation is often sufficient. .PP The \fBok\fR parameter to the callback indicates the value the callback should return to retain the default behaviour. If it is zero then and error condition is indicated. If it is 1 then no error occurred. If the flag \&\fBX509_V_FLAG_NOTIFY_POLICY\fR is set then \fBok\fR is set to 2 to indicate the policy checking is complete. .PP The \fBctx\fR parameter to the callback is the \fBX509_STORE_CTX\fR structure that is performing the verification operation. A callback can examine this structure and receive additional information about the error, for example by calling \fIX509_STORE_CTX_get_current_cert()\fR. Additional application data can be passed to the callback via the \fBex_data\fR mechanism. .SH "WARNING" .IX Header "WARNING" In general a verification callback should \fB\s-1NOT\s0\fR unconditionally return 1 in all circumstances because this will allow verification to succeed no matter what the error. This effectively removes all security from the application because \fBany\fR certificate (including untrusted generated ones) will be accepted. .SH "NOTES" .IX Header "NOTES" The verification callback can be set and inherited from the parent structure performing the operation. In some cases (such as S/MIME verification) the \&\fBX509_STORE_CTX\fR structure is created and destroyed internally and the only way to set a custom verification callback is by inheriting it from the associated \fBX509_STORE\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIX509_STORE_CTX_set_verify_cb()\fR does not return a value. .SH "EXAMPLES" .IX Header "EXAMPLES" Default callback operation: .PP .Vb 5 \& int \& verify_callback(int ok, X509_STORE_CTX *ctx) \& { \& return ok; \& } .Ve .PP Simple example, suppose a certificate in the chain is expired and we wish to continue after this error: .PP .Vb 9 \& int \& verify_callback(int ok, X509_STORE_CTX *ctx) \& { \& /* Tolerate certificate expiration */ \& if (X509_STORE_CTX_get_error(ctx) == X509_V_ERR_CERT_HAS_EXPIRED) \& return 1; \& /* Otherwise don\*(Aqt override */ \& return ok; \& } .Ve .PP More complex example, we don't wish to continue after \fBany\fR certificate has expired just one specific case: .PP .Vb 5 \& int \& verify_callback(int ok, X509_STORE_CTX *ctx) \& { \& int err = X509_STORE_CTX_get_error(ctx); \& X509 *err_cert = X509_STORE_CTX_get_current_cert(ctx); \& \& if (err == X509_V_ERR_CERT_HAS_EXPIRED) { \& if (check_is_acceptable_expired_cert(err_cert) \& return 1; \& } \& return ok; \& } .Ve .PP Full featured logging callback. In this case the \fBbio_err\fR is assumed to be a global logging \fB\s-1BIO\s0\fR, an alternative would to store a \s-1BIO\s0 in \fBctx\fR using \&\fBex_data\fR. .PP .Vb 5 \& int \& verify_callback(int ok, X509_STORE_CTX *ctx) \& { \& X509 *err_cert; \& int err,depth; \& \& err_cert = X509_STORE_CTX_get_current_cert(ctx); \& err = X509_STORE_CTX_get_error(ctx); \& depth = X509_STORE_CTX_get_error_depth(ctx); \& \& BIO_printf(bio_err,"depth=%d ",depth); \& if (err_cert) { \& X509_NAME_print_ex(bio_err, \& X509_get_subject_name(err_cert), 0, \& XN_FLAG_ONELINE); \& BIO_puts(bio_err, "\en"); \& } else \& BIO_puts(bio_err, "\en"); \& if (!ok) \& BIO_printf(bio_err, "verify error:num=%d:%s\en", \& err, X509_verify_cert_error_string(err)); \& switch (err) { \& case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: \& BIO_puts(bio_err, "issuer= "); \& X509_NAME_print_ex(bio_err, \& X509_get_issuer_name(err_cert), 0, \& XN_FLAG_ONELINE); \& BIO_puts(bio_err, "\en"); \& break; \& case X509_V_ERR_CERT_NOT_YET_VALID: \& case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: \& BIO_printf(bio_err, "notBefore="); \& ASN1_TIME_print(bio_err, \& X509_get_notBefore(err_cert)); \& BIO_printf(bio_err, "\en"); \& break; \& case X509_V_ERR_CERT_HAS_EXPIRED: \& case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: \& BIO_printf(bio_err, "notAfter="); \& ASN1_TIME_print(bio_err, X509_get_notAfter(err_cert)); \& BIO_printf(bio_err, "\en"); \& break; \& case X509_V_ERR_NO_EXPLICIT_POLICY: \& policies_print(bio_err, ctx); \& break; \& } \& if (err == X509_V_OK && ok == 2) \& /* print out policies */ \& \& BIO_printf(bio_err,"verify return:%d\en",ok); \& return(ok); \& } .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIX509_STORE_CTX_get_error\fR\|(3) \&\fIX509_STORE_set_verify_cb_func\fR\|(3) \&\fIX509_STORE_CTX_get_ex_new_index\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIX509_STORE_CTX_set_verify_cb()\fR is available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/ui_compat.30000644000175000017500000001410112360020730017545 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ui_compat 3" .TH ui_compat 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" des_read_password, des_read_2passwords, des_read_pw_string, des_read_pw \- Compatibility user interface functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int des_read_password(DES_cblock *key,const char *prompt,int verify); \& int des_read_2passwords(DES_cblock *key1,DES_cblock *key2, \& const char *prompt,int verify); \& \& int des_read_pw_string(char *buf,int length,const char *prompt,int verify); \& int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \s-1DES\s0 library contained a few routines to prompt for passwords. These aren't necessarely dependent on \s-1DES,\s0 and have therefore become part of the \&\s-1UI\s0 compatibility library. .PP \&\fIdes_read_pw()\fR writes the string specified by \fIprompt\fR to standard output turns echo off and reads an input string from the terminal. The string is returned in \fIbuf\fR, which must have spac for at least \fIsize\fR bytes. If \fIverify\fR is set, the user is asked for the password twice and unless the two copies match, an error is returned. The second password is stored in \fIbuff\fR, which must therefore also be at least \fIsize\fR bytes. A return code of \-1 indicates a system error, 1 failure due to use interaction, and 0 is success. All other functions described here use \fIdes_read_pw()\fR to do the work. .PP \&\fIdes_read_pw_string()\fR is a variant of \fIdes_read_pw()\fR that provides a buffer for you if \fIverify\fR is set. .PP \&\fIdes_read_password()\fR calls \fIdes_read_pw()\fR and converts the password to a \&\s-1DES\s0 key by calling \fIDES_string_to_key()\fR; \fIdes_read_2password()\fR operates in the same way as \fIdes_read_password()\fR except that it generates two keys by using the \fIDES_string_to_2key()\fR function. .SH "NOTES" .IX Header "NOTES" \&\fIdes_read_pw_string()\fR is available in the \s-1MIT\s0 Kerberos library as well, and is also available under the name \fIEVP_read_pw_string()\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIui\fR\|(3), \fIui_create\fR\|(3) .SH "AUTHOR" .IX Header "AUTHOR" Richard Levitte (richard@levitte.org) for the OpenSSL project (http://www.openssl.org). deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_tmp_rsa_callback.30000644000175000017500000002561712360020733023201 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_tmp_rsa_callback 3" .TH SSL_CTX_set_tmp_rsa_callback 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_tmp_rsa_callback, SSL_CTX_set_tmp_rsa, SSL_CTX_need_tmp_rsa, SSL_set_tmp_rsa_callback, SSL_set_tmp_rsa, SSL_need_tmp_rsa \- handle RSA keys for ephemeral key exchange .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx, \& RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength)); \& long SSL_CTX_set_tmp_rsa(SSL_CTX *ctx, RSA *rsa); \& long SSL_CTX_need_tmp_rsa(SSL_CTX *ctx); \& \& void SSL_set_tmp_rsa_callback(SSL_CTX *ctx, \& RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength)); \& long SSL_set_tmp_rsa(SSL *ssl, RSA *rsa) \& long SSL_need_tmp_rsa(SSL *ssl) \& \& RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_tmp_rsa_callback()\fR sets the callback function for \fBctx\fR to be used when a temporary/ephemeral \s-1RSA\s0 key is required to \fBtmp_rsa_callback\fR. The callback is inherited by all \s-1SSL\s0 objects newly created from \fBctx\fR with <\fISSL_new\fR\|(3)|\fISSL_new\fR\|(3)>. Already created \s-1SSL\s0 objects are not affected. .PP \&\fISSL_CTX_set_tmp_rsa()\fR sets the temporary/ephemeral \s-1RSA\s0 key to be used to be \&\fBrsa\fR. The key is inherited by all \s-1SSL\s0 objects newly created from \fBctx\fR with <\fISSL_new\fR\|(3)|\fISSL_new\fR\|(3)>. Already created \s-1SSL\s0 objects are not affected. .PP \&\fISSL_CTX_need_tmp_rsa()\fR returns 1, if a temporary/ephemeral \s-1RSA\s0 key is needed for RSA-based strength-limited 'exportable' ciphersuites because a \s-1RSA\s0 key with a keysize larger than 512 bits is installed. .PP \&\fISSL_set_tmp_rsa_callback()\fR sets the callback only for \fBssl\fR. .PP \&\fISSL_set_tmp_rsa()\fR sets the key only for \fBssl\fR. .PP \&\fISSL_need_tmp_rsa()\fR returns 1, if a temporary/ephemeral \s-1RSA\s0 key is needed, for RSA-based strength-limited 'exportable' ciphersuites because a \s-1RSA\s0 key with a keysize larger than 512 bits is installed. .PP These functions apply to \s-1SSL/TLS\s0 servers only. .SH "NOTES" .IX Header "NOTES" When using a cipher with \s-1RSA\s0 authentication, an ephemeral \s-1RSA\s0 key exchange can take place. In this case the session data are negotiated using the ephemeral/temporary \s-1RSA\s0 key and the \s-1RSA\s0 key supplied and certified by the certificate chain is only used for signing. .PP Under previous export restrictions, ciphers with \s-1RSA\s0 keys shorter (512 bits) than the usual key length of 1024 bits were created. To use these ciphers with \s-1RSA\s0 keys of usual length, an ephemeral key exchange must be performed, as the normal (certified) key cannot be directly used. .PP Using ephemeral \s-1RSA\s0 key exchange yields forward secrecy, as the connection can only be decrypted, when the \s-1RSA\s0 key is known. By generating a temporary \&\s-1RSA\s0 key inside the server application that is lost when the application is left, it becomes impossible for an attacker to decrypt past sessions, even if he gets hold of the normal (certified) \s-1RSA\s0 key, as this key was used for signing only. The downside is that creating a \s-1RSA\s0 key is computationally expensive. .PP Additionally, the use of ephemeral \s-1RSA\s0 key exchange is only allowed in the \s-1TLS\s0 standard, when the \s-1RSA\s0 key can be used for signing only, that is for export ciphers. Using ephemeral \s-1RSA\s0 key exchange for other purposes violates the standard and can break interoperability with clients. It is therefore strongly recommended to not use ephemeral \s-1RSA\s0 key exchange and use \s-1EDH \s0(Ephemeral Diffie-Hellman) key exchange instead in order to achieve forward secrecy (see \&\fISSL_CTX_set_tmp_dh_callback\fR\|(3)). .PP On OpenSSL servers ephemeral \s-1RSA\s0 key exchange is therefore disabled by default and must be explicitly enabled using the \s-1SSL_OP_EPHEMERAL_RSA\s0 option of \&\fISSL_CTX_set_options\fR\|(3), violating the \s-1TLS/SSL\s0 standard. When ephemeral \s-1RSA\s0 key exchange is required for export ciphers, it will automatically be used without this option! .PP An application may either directly specify the key or can supply the key via a callback function. The callback approach has the advantage, that the callback may generate the key only in case it is actually needed. As the generation of a \s-1RSA\s0 key is however costly, it will lead to a significant delay in the handshake procedure. Another advantage of the callback function is that it can supply keys of different size (e.g. for \s-1SSL_OP_EPHEMERAL_RSA\s0 usage) while the explicit setting of the key is only useful for key size of 512 bits to satisfy the export restricted ciphers and does give away key length if a longer key would be allowed. .PP The \fBtmp_rsa_callback\fR is called with the \fBkeylength\fR needed and the \fBis_export\fR information. The \fBis_export\fR flag is set, when the ephemeral \s-1RSA\s0 key exchange is performed with an export cipher. .SH "EXAMPLES" .IX Header "EXAMPLES" Generate temporary \s-1RSA\s0 keys to prepare ephemeral \s-1RSA\s0 key exchange. As the generation of a \s-1RSA\s0 key costs a lot of computer time, they saved for later reuse. For demonstration purposes, two keys for 512 bits and 1024 bits respectively are generated. .PP .Vb 4 \& ... \& /* Set up ephemeral RSA stuff */ \& RSA *rsa_512 = NULL; \& RSA *rsa_1024 = NULL; \& \& rsa_512 = RSA_generate_key(512,RSA_F4,NULL,NULL); \& if (rsa_512 == NULL) \& evaluate_error_queue(); \& \& rsa_1024 = RSA_generate_key(1024,RSA_F4,NULL,NULL); \& if (rsa_1024 == NULL) \& evaluate_error_queue(); \& \& ... \& \& RSA *tmp_rsa_callback(SSL *s, int is_export, int keylength) \& { \& RSA *rsa_tmp=NULL; \& \& switch (keylength) { \& case 512: \& if (rsa_512) \& rsa_tmp = rsa_512; \& else { /* generate on the fly, should not happen in this example */ \& rsa_tmp = RSA_generate_key(keylength,RSA_F4,NULL,NULL); \& rsa_512 = rsa_tmp; /* Remember for later reuse */ \& } \& break; \& case 1024: \& if (rsa_1024) \& rsa_tmp=rsa_1024; \& else \& should_not_happen_in_this_example(); \& break; \& default: \& /* Generating a key on the fly is very costly, so use what is there */ \& if (rsa_1024) \& rsa_tmp=rsa_1024; \& else \& rsa_tmp=rsa_512; /* Use at least a shorter key */ \& } \& return(rsa_tmp); \& } .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_set_tmp_rsa_callback()\fR and \fISSL_set_tmp_rsa_callback()\fR do not return diagnostic output. .PP \&\fISSL_CTX_set_tmp_rsa()\fR and \fISSL_set_tmp_rsa()\fR do return 1 on success and 0 on failure. Check the error queue to find out the reason of failure. .PP \&\fISSL_CTX_need_tmp_rsa()\fR and \fISSL_need_tmp_rsa()\fR return 1 if a temporary \&\s-1RSA\s0 key is needed and 0 otherwise. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_CTX_set_cipher_list\fR\|(3), \&\fISSL_CTX_set_options\fR\|(3), \&\fISSL_CTX_set_tmp_dh_callback\fR\|(3), \&\fISSL_new\fR\|(3), \fIciphers\fR\|(1) deps/libressl-pnacl-sys-2.1.6/libressl/man/DH_size.30000644000175000017500000001104312360020715017117 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DH_size 3" .TH DH_size 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DH_size \- get Diffie\-Hellman prime size .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int DH_size(DH *dh); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This function returns the Diffie-Hellman size in bytes. It can be used to determine how much memory must be allocated for the shared secret computed by \fIDH_compute_key()\fR. .PP \&\fBdh\->p\fR must not be \fB\s-1NULL\s0\fR. .SH "RETURN VALUE" .IX Header "RETURN VALUE" The size in bytes. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdh\fR\|(3), \fIDH_generate_key\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIDH_size()\fR is available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/d2i_X509_SIG.30000644000175000017500000001102212360020727017477 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "d2i_X509_SIG 3" .TH d2i_X509_SIG 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" d2i_X509_SIG, i2d_X509_SIG \- DigestInfo functions. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& X509_SIG *d2i_X509_SIG(X509_SIG **a, unsigned char **pp, long length); \& int i2d_X509_SIG(X509_SIG *a, unsigned char **pp); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions decode and encode an X509_SIG structure which is equivalent to the \fBDigestInfo\fR structure defined in PKCS#1 and PKCS#7. .PP Othewise these behave in a similar way to \fId2i_X509()\fR and \fIi2d_X509()\fR described in the \fId2i_X509\fR\|(3) manual page. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fId2i_X509\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_s_connect.30000644000175000017500000002671212360020710020242 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_s_connect 3" .TH BIO_s_connect 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_s_connect, BIO_new_connect, BIO_set_conn_hostname, BIO_set_conn_port, BIO_set_conn_ip, BIO_set_conn_int_port, BIO_get_conn_hostname, BIO_get_conn_port, BIO_get_conn_ip, BIO_get_conn_int_port, BIO_set_nbio, BIO_do_connect \- connect BIO .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIO_METHOD * BIO_s_connect(void); \& \& BIO *BIO_new_connect(char *name); \& \& long BIO_set_conn_hostname(BIO *b, char *name); \& long BIO_set_conn_port(BIO *b, char *port); \& long BIO_set_conn_ip(BIO *b, char *ip); \& long BIO_set_conn_int_port(BIO *b, char *port); \& char *BIO_get_conn_hostname(BIO *b); \& char *BIO_get_conn_port(BIO *b); \& char *BIO_get_conn_ip(BIO *b, dummy); \& long BIO_get_conn_int_port(BIO *b, int port); \& \& long BIO_set_nbio(BIO *b, long n); \& \& int BIO_do_connect(BIO *b); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_s_connect()\fR returns the connect \s-1BIO\s0 method. This is a wrapper round the platform's \s-1TCP/IP\s0 socket connection routines. .PP Using connect BIOs, \s-1TCP/IP\s0 connections can be made and data transferred using only \s-1BIO\s0 routines. In this way any platform specific operations are hidden by the \s-1BIO\s0 abstraction. .PP Read and write operations on a connect \s-1BIO\s0 will perform I/O on the underlying connection. If no connection is established and the port and hostname (see below) is set up properly then a connection is established first. .PP Connect BIOs support \fIBIO_puts()\fR but not \fIBIO_gets()\fR. .PP If the close flag is set on a connect \s-1BIO\s0 then any active connection is shutdown and the socket closed when the \s-1BIO\s0 is freed. .PP Calling \fIBIO_reset()\fR on a connect \s-1BIO\s0 will close any active connection and reset the \s-1BIO\s0 into a state where it can connect to the same host again. .PP \&\fIBIO_get_fd()\fR places the underlying socket in \fBc\fR if it is not \s-1NULL,\s0 it also returns the socket . If \fBc\fR is not \s-1NULL\s0 it should be of type (int *). .PP \&\fIBIO_set_conn_hostname()\fR uses the string \fBname\fR to set the hostname. The hostname can be an \s-1IP\s0 address. The hostname can also include the port in the form hostname:port . It is also acceptable to use the form \*(L"hostname/any/other/path\*(R" or \*(L"hostname:port/any/other/path\*(R". .PP \&\fIBIO_set_conn_port()\fR sets the port to \fBport\fR. \fBport\fR can be the numerical form or a string such as \*(L"http\*(R". A string will be looked up first using \fIgetservbyname()\fR on the host platform but if that fails a standard table of port names will be used. Currently the list is http, telnet, socks, https, ssl, ftp, gopher and wais. .PP \&\fIBIO_set_conn_ip()\fR sets the \s-1IP\s0 address to \fBip\fR using binary form, that is four bytes specifying the \s-1IP\s0 address in big-endian form. .PP \&\fIBIO_set_conn_int_port()\fR sets the port using \fBport\fR. \fBport\fR should be of type (int *). .PP \&\fIBIO_get_conn_hostname()\fR returns the hostname of the connect \s-1BIO\s0 or \&\s-1NULL\s0 if the \s-1BIO\s0 is initialized but no hostname is set. This return value is an internal pointer which should not be modified. .PP \&\fIBIO_get_conn_port()\fR returns the port as a string. .PP \&\fIBIO_get_conn_ip()\fR returns the \s-1IP\s0 address in binary form. .PP \&\fIBIO_get_conn_int_port()\fR returns the port as an int. .PP \&\fIBIO_set_nbio()\fR sets the non blocking I/O flag to \fBn\fR. If \fBn\fR is zero then blocking I/O is set. If \fBn\fR is 1 then non blocking I/O is set. Blocking I/O is the default. The call to \fIBIO_set_nbio()\fR should be made before the connection is established because non blocking I/O is set during the connect process. .PP \&\fIBIO_new_connect()\fR combines \fIBIO_new()\fR and \fIBIO_set_conn_hostname()\fR into a single call: that is it creates a new connect \s-1BIO\s0 with \fBname\fR. .PP \&\fIBIO_do_connect()\fR attempts to connect the supplied \s-1BIO.\s0 It returns 1 if the connection was established successfully. A zero or negative value is returned if the connection could not be established, the call \fIBIO_should_retry()\fR should be used for non blocking connect BIOs to determine if the call should be retried. .SH "NOTES" .IX Header "NOTES" If blocking I/O is set then a non positive return value from any I/O call is caused by an error condition, although a zero return will normally mean that the connection was closed. .PP If the port name is supplied as part of the host name then this will override any value set with \fIBIO_set_conn_port()\fR. This may be undesirable if the application does not wish to allow connection to arbitrary ports. This can be avoided by checking for the presence of the ':' character in the passed hostname and either indicating an error or truncating the string at that point. .PP The values returned by \fIBIO_get_conn_hostname()\fR, \fIBIO_get_conn_port()\fR, \&\fIBIO_get_conn_ip()\fR and \fIBIO_get_conn_int_port()\fR are updated when a connection attempt is made. Before any connection attempt the values returned are those set by the application itself. .PP Applications do not have to call \fIBIO_do_connect()\fR but may wish to do so to separate the connection process from other I/O processing. .PP If non blocking I/O is set then retries will be requested as appropriate. .PP It addition to \fIBIO_should_read()\fR and \fIBIO_should_write()\fR it is also possible for \fIBIO_should_io_special()\fR to be true during the initial connection process with the reason \s-1BIO_RR_CONNECT.\s0 If this is returned then this is an indication that a connection attempt would block, the application should then take appropriate action to wait until the underlying socket has connected and retry the call. .PP \&\fIBIO_set_conn_hostname()\fR, \fIBIO_set_conn_port()\fR, \fIBIO_set_conn_ip()\fR, \&\fIBIO_set_conn_int_port()\fR, \fIBIO_get_conn_hostname()\fR, \fIBIO_get_conn_port()\fR, \&\fIBIO_get_conn_ip()\fR, \fIBIO_get_conn_int_port()\fR, \fIBIO_set_nbio()\fR and \&\fIBIO_do_connect()\fR are macros. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBIO_s_connect()\fR returns the connect \s-1BIO\s0 method. .PP \&\fIBIO_get_fd()\fR returns the socket or \-1 if the \s-1BIO\s0 has not been initialized. .PP \&\fIBIO_set_conn_hostname()\fR, \fIBIO_set_conn_port()\fR, \fIBIO_set_conn_ip()\fR and \&\fIBIO_set_conn_int_port()\fR always return 1. .PP \&\fIBIO_get_conn_hostname()\fR returns the connected hostname or \s-1NULL\s0 is none was set. .PP \&\fIBIO_get_conn_port()\fR returns a string representing the connected port or \s-1NULL\s0 if not set. .PP \&\fIBIO_get_conn_ip()\fR returns a pointer to the connected \s-1IP\s0 address in binary form or all zeros if not set. .PP \&\fIBIO_get_conn_int_port()\fR returns the connected port or 0 if none was set. .PP \&\fIBIO_set_nbio()\fR always returns 1. .PP \&\fIBIO_do_connect()\fR returns 1 if the connection was successfully established and 0 or \-1 if the connection failed. .SH "EXAMPLE" .IX Header "EXAMPLE" This is example connects to a webserver on the local host and attempts to retrieve a page and copy the result to standard output. .PP .Vb 3 \& BIO *cbio, *out; \& int len; \& char tmpbuf[1024]; \& \& ERR_load_crypto_strings(); \& cbio = BIO_new_connect("localhost:http"); \& out = BIO_new_fp(stdout, BIO_NOCLOSE); \& if (BIO_do_connect(cbio) <= 0) { \& fprintf(stderr, "Error connecting to server\en"); \& ERR_print_errors_fp(stderr); \& /* whatever ... */ \& } \& BIO_puts(cbio, "GET / HTTP/1.0\en\en"); \& for(;;) { \& len = BIO_read(cbio, tmpbuf, 1024); \& if (len <= 0) \& break; \& BIO_write(out, tmpbuf, len); \& } \& BIO_free(cbio); \& BIO_free(out); .Ve deps/libressl-pnacl-sys-2.1.6/libressl/man/cms.10000644000175000017500000006506012360020740016360 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "cms 1" .TH cms 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" cms \- CMS utility .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl\fR \fBcms\fR [\fB\-encrypt\fR] [\fB\-decrypt\fR] [\fB\-sign\fR] [\fB\-verify\fR] [\fB\-cmsout\fR] [\fB\-resign\fR] [\fB\-data_create\fR] [\fB\-data_out\fR] [\fB\-digest_create\fR] [\fB\-digest_verify\fR] [\fB\-compress\fR] [\fB\-uncompress\fR] [\fB\-EncryptedData_encrypt\fR] [\fB\-sign_receipt\fR] [\fB\-verify_receipt receipt\fR] [\fB\-in filename\fR] [\fB\-inform SMIME|PEM|DER\fR] [\fB\-rctform SMIME|PEM|DER\fR] [\fB\-out filename\fR] [\fB\-outform SMIME|PEM|DER\fR] [\fB\-stream \-indef \-noindef\fR] [\fB\-noindef\fR] [\fB\-content filename\fR] [\fB\-text\fR] [\fB\-noout\fR] [\fB\-print\fR] [\fB\-CAfile file\fR] [\fB\-CApath dir\fR] [\fB\-md digest\fR] [\fB\-[cipher]\fR] [\fB\-nointern\fR] [\fB\-no_signer_cert_verify\fR] [\fB\-nocerts\fR] [\fB\-noattr\fR] [\fB\-nosmimecap\fR] [\fB\-binary\fR] [\fB\-nodetach\fR] [\fB\-certfile file\fR] [\fB\-certsout file\fR] [\fB\-signer file\fR] [\fB\-recip file\fR] [\fB\-keyid\fR] [\fB\-receipt_request_all \-receipt_request_first\fR] [\fB\-receipt_request_from emailaddress\fR] [\fB\-receipt_request_to emailaddress\fR] [\fB\-receipt_request_print\fR] [\fB\-secretkey key\fR] [\fB\-secretkeyid id\fR] [\fB\-econtent_type type\fR] [\fB\-inkey file\fR] [\fB\-passin arg\fR] [\fB\-rand file(s)\fR] [\fBcert.pem...\fR] [\fB\-to addr\fR] [\fB\-from addr\fR] [\fB\-subject subj\fR] [cert.pem]... .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBcms\fR command handles S/MIME v3.1 mail. It can encrypt, decrypt, sign and verify, compress and uncompress S/MIME messages. .SH "COMMAND OPTIONS" .IX Header "COMMAND OPTIONS" There are fourteen operation options that set the type of operation to be performed. The meaning of the other options varies according to the operation type. .IP "\fB\-encrypt\fR" 4 .IX Item "-encrypt" encrypt mail for the given recipient certificates. Input file is the message to be encrypted. The output file is the encrypted mail in \s-1MIME\s0 format. The actual \s-1CMS\s0 type is EnvelopedData. .IP "\fB\-decrypt\fR" 4 .IX Item "-decrypt" decrypt mail using the supplied certificate and private key. Expects an encrypted mail message in \s-1MIME\s0 format for the input file. The decrypted mail is written to the output file. .IP "\fB\-sign\fR" 4 .IX Item "-sign" sign mail using the supplied certificate and private key. Input file is the message to be signed. The signed message in \s-1MIME\s0 format is written to the output file. .IP "\fB\-verify\fR" 4 .IX Item "-verify" verify signed mail. Expects a signed mail message on input and outputs the signed data. Both clear text and opaque signing is supported. .IP "\fB\-cmsout\fR" 4 .IX Item "-cmsout" takes an input message and writes out a \s-1PEM\s0 encoded \s-1CMS\s0 structure. .IP "\fB\-resign\fR" 4 .IX Item "-resign" resign a message: take an existing message and one or more new signers. .IP "\fB\-data_create\fR" 4 .IX Item "-data_create" Create a \s-1CMS \s0\fBData\fR type. .IP "\fB\-data_out\fR" 4 .IX Item "-data_out" \&\fBData\fR type and output the content. .IP "\fB\-digest_create\fR" 4 .IX Item "-digest_create" Create a \s-1CMS \s0\fBDigestedData\fR type. .IP "\fB\-digest_verify\fR" 4 .IX Item "-digest_verify" Verify a \s-1CMS \s0\fBDigestedData\fR type and output the content. .IP "\fB\-compress\fR" 4 .IX Item "-compress" Create a \s-1CMS \s0\fBCompressedData\fR type. OpenSSL must be compiled with \fBzlib\fR support for this option to work, otherwise it will output an error. .IP "\fB\-uncompress\fR" 4 .IX Item "-uncompress" Uncompress a \s-1CMS \s0\fBCompressedData\fR type and output the content. OpenSSL must be compiled with \fBzlib\fR support for this option to work, otherwise it will output an error. .IP "\fB\-EncryptedData_encrypt\fR" 4 .IX Item "-EncryptedData_encrypt" Encrypt suppled content using supplied symmetric key and algorithm using a \s-1CMS \&\s0\fBEncrytedData\fR type and output the content. .IP "\fB\-sign_receipt\fR" 4 .IX Item "-sign_receipt" Generate and output a signed receipt for the supplied message. The input message \fBmust\fR contain a signed receipt request. Functionality is otherwise similar to the \fB\-sign\fR operation. .IP "\fB\-verify_receipt receipt\fR" 4 .IX Item "-verify_receipt receipt" Verify a signed receipt in filename \fBreceipt\fR. The input message \fBmust\fR contain the original receipt request. Functionality is otherwise similar to the \fB\-verify\fR operation. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" the input message to be encrypted or signed or the message to be decrypted or verified. .IP "\fB\-inform SMIME|PEM|DER\fR" 4 .IX Item "-inform SMIME|PEM|DER" this specifies the input format for the \s-1CMS\s0 structure. The default is \fB\s-1SMIME\s0\fR which reads an S/MIME format message. \fB\s-1PEM\s0\fR and \fB\s-1DER\s0\fR format change this to expect \s-1PEM\s0 and \s-1DER\s0 format \s-1CMS\s0 structures instead. This currently only affects the input format of the \s-1CMS\s0 structure, if no \s-1CMS\s0 structure is being input (for example with \&\fB\-encrypt\fR or \fB\-sign\fR) this option has no effect. .IP "\fB\-rctform SMIME|PEM|DER\fR" 4 .IX Item "-rctform SMIME|PEM|DER" specify the format for a signed receipt for use with the \fB\-receipt_verify\fR operation. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" the message text that has been decrypted or verified or the output \s-1MIME\s0 format message that has been signed or verified. .IP "\fB\-outform SMIME|PEM|DER\fR" 4 .IX Item "-outform SMIME|PEM|DER" this specifies the output format for the \s-1CMS\s0 structure. The default is \fB\s-1SMIME\s0\fR which writes an S/MIME format message. \fB\s-1PEM\s0\fR and \fB\s-1DER\s0\fR format change this to write \s-1PEM\s0 and \s-1DER\s0 format \s-1CMS\s0 structures instead. This currently only affects the output format of the \s-1CMS\s0 structure, if no \s-1CMS\s0 structure is being output (for example with \&\fB\-verify\fR or \fB\-decrypt\fR) this option has no effect. .IP "\fB\-stream \-indef \-noindef\fR" 4 .IX Item "-stream -indef -noindef" the \fB\-stream\fR and \fB\-indef\fR options are equivalent and enable streaming I/O for encoding operations. This permits single pass processing of data without the need to hold the entire contents in memory, potentially supporting very large files. Streaming is automatically set for S/MIME signing with detached data if the output format is \fB\s-1SMIME\s0\fR it is currently off by default for all other operations. .IP "\fB\-noindef\fR" 4 .IX Item "-noindef" disable streaming I/O where it would produce and indefinite length constructed encoding. This option currently has no effect. In future streaming will be enabled by default on all relevant operations and this option will disable it. .IP "\fB\-content filename\fR" 4 .IX Item "-content filename" This specifies a file containing the detached content, this is only useful with the \fB\-verify\fR command. This is only usable if the \s-1CMS\s0 structure is using the detached signature form where the content is not included. This option will override any content if the input format is S/MIME and it uses the multipart/signed \s-1MIME\s0 content type. .IP "\fB\-text\fR" 4 .IX Item "-text" this option adds plain text (text/plain) \s-1MIME\s0 headers to the supplied message if encrypting or signing. If decrypting or verifying it strips off text headers: if the decrypted or verified message is not of \s-1MIME\s0 type text/plain then an error occurs. .IP "\fB\-noout\fR" 4 .IX Item "-noout" for the \fB\-cmsout\fR operation do not output the parsed \s-1CMS\s0 structure. This is useful when combined with the \fB\-print\fR option or if the syntax of the \s-1CMS\s0 structure is being checked. .IP "\fB\-print\fR" 4 .IX Item "-print" for the \fB\-cmsout\fR operation print out all fields of the \s-1CMS\s0 structure. This is mainly useful for testing purposes. .IP "\fB\-CAfile file\fR" 4 .IX Item "-CAfile file" a file containing trusted \s-1CA\s0 certificates, only used with \fB\-verify\fR. .IP "\fB\-CApath dir\fR" 4 .IX Item "-CApath dir" a directory containing trusted \s-1CA\s0 certificates, only used with \&\fB\-verify\fR. This directory must be a standard certificate directory: that is a hash of each subject name (using \fBx509 \-hash\fR) should be linked to each certificate. .IP "\fB\-md digest\fR" 4 .IX Item "-md digest" digest algorithm to use when signing or resigning. If not present then the default digest algorithm for the signing key will be used (usually \s-1SHA1\s0). .IP "\fB\-[cipher]\fR" 4 .IX Item "-[cipher]" the encryption algorithm to use. For example triple \s-1DES \s0(168 bits) \- \fB\-des3\fR or 256 bit \s-1AES \- \s0\fB\-aes256\fR. Any standard algorithm name (as used by the \&\fIEVP_get_cipherbyname()\fR function) can also be used preceded by a dash, for example \fB\-aes_128_cbc\fR. See \fBenc\fR for a list of ciphers supported by your version of OpenSSL. .Sp If not specified triple \s-1DES\s0 is used. Only used with \fB\-encrypt\fR and \&\fB\-EncryptedData_create\fR commands. .IP "\fB\-nointern\fR" 4 .IX Item "-nointern" when verifying a message normally certificates (if any) included in the message are searched for the signing certificate. With this option only the certificates specified in the \fB\-certfile\fR option are used. The supplied certificates can still be used as untrusted CAs however. .IP "\fB\-no_signer_cert_verify\fR" 4 .IX Item "-no_signer_cert_verify" do not verify the signers certificate of a signed message. .IP "\fB\-nocerts\fR" 4 .IX Item "-nocerts" when signing a message the signer's certificate is normally included with this option it is excluded. This will reduce the size of the signed message but the verifier must have a copy of the signers certificate available locally (passed using the \fB\-certfile\fR option for example). .IP "\fB\-noattr\fR" 4 .IX Item "-noattr" normally when a message is signed a set of attributes are included which include the signing time and supported symmetric algorithms. With this option they are not included. .IP "\fB\-nosmimecap\fR" 4 .IX Item "-nosmimecap" exclude the list of supported algorithms from signed attributes, other options such as signing time and content type are still included. .IP "\fB\-binary\fR" 4 .IX Item "-binary" normally the input message is converted to \*(L"canonical\*(R" format which is effectively using \s-1CR\s0 and \s-1LF\s0 as end of line: as required by the S/MIME specification. When this option is present no translation occurs. This is useful when handling binary data which may not be in \s-1MIME\s0 format. .IP "\fB\-nodetach\fR" 4 .IX Item "-nodetach" when signing a message use opaque signing: this form is more resistant to translation by mail relays but it cannot be read by mail agents that do not support S/MIME. Without this option cleartext signing with the \s-1MIME\s0 type multipart/signed is used. .IP "\fB\-certfile file\fR" 4 .IX Item "-certfile file" allows additional certificates to be specified. When signing these will be included with the message. When verifying these will be searched for the signers certificates. The certificates should be in \s-1PEM\s0 format. .IP "\fB\-certsout file\fR" 4 .IX Item "-certsout file" any certificates contained in the message are written to \fBfile\fR. .IP "\fB\-signer file\fR" 4 .IX Item "-signer file" a signing certificate when signing or resigning a message, this option can be used multiple times if more than one signer is required. If a message is being verified then the signers certificates will be written to this file if the verification was successful. .IP "\fB\-recip file\fR" 4 .IX Item "-recip file" the recipients certificate when decrypting a message. This certificate must match one of the recipients of the message or an error occurs. .IP "\fB\-keyid\fR" 4 .IX Item "-keyid" use subject key identifier to identify certificates instead of issuer name and serial number. The supplied certificate \fBmust\fR include a subject key identifier extension. Supported by \fB\-sign\fR and \fB\-encrypt\fR options. .IP "\fB\-receipt_request_all \-receipt_request_first\fR" 4 .IX Item "-receipt_request_all -receipt_request_first" for \fB\-sign\fR option include a signed receipt request. Indicate requests should be provided by all receipient or first tier recipients (those mailed directly and not from a mailing list). Ignored it \fB\-receipt_request_from\fR is included. .IP "\fB\-receipt_request_from emailaddress\fR" 4 .IX Item "-receipt_request_from emailaddress" for \fB\-sign\fR option include a signed receipt request. Add an explicit email address where receipts should be supplied. .IP "\fB\-receipt_request_to emailaddress\fR" 4 .IX Item "-receipt_request_to emailaddress" Add an explicit email address where signed receipts should be sent to. This option \fBmust\fR but supplied if a signed receipt it requested. .IP "\fB\-receipt_request_print\fR" 4 .IX Item "-receipt_request_print" For the \fB\-verify\fR operation print out the contents of any signed receipt requests. .IP "\fB\-secretkey key\fR" 4 .IX Item "-secretkey key" specify symmetric key to use. The key must be supplied in hex format and be consistent with the algorithm used. Supported by the \fB\-EncryptedData_encrypt\fR \&\fB\-EncrryptedData_decrypt\fR, \fB\-encrypt\fR and \fB\-decrypt\fR options. When used with \fB\-encrypt\fR or \fB\-decrypt\fR the supplied key is used to wrap or unwrap the content encryption key using an \s-1AES\s0 key in the \fBKEKRecipientInfo\fR type. .IP "\fB\-secretkeyid id\fR" 4 .IX Item "-secretkeyid id" the key identifier for the supplied symmetric key for \fBKEKRecipientInfo\fR type. This option \fBmust\fR be present if the \fB\-secretkey\fR option is used with \&\fB\-encrypt\fR. With \fB\-decrypt\fR operations the \fBid\fR is used to locate the relevant key if it is not supplied then an attempt is used to decrypt any \&\fBKEKRecipientInfo\fR structures. .IP "\fB\-econtent_type type\fR" 4 .IX Item "-econtent_type type" set the encapsulated content type to \fBtype\fR if not supplied the \fBData\fR type is used. The \fBtype\fR argument can be any valid \s-1OID\s0 name in either text or numerical format. .IP "\fB\-inkey file\fR" 4 .IX Item "-inkey file" the private key to use when signing or decrypting. This must match the corresponding certificate. If this option is not specified then the private key must be included in the certificate file specified with the \fB\-recip\fR or \fB\-signer\fR file. When signing this option can be used multiple times to specify successive keys. .IP "\fB\-passin arg\fR" 4 .IX Item "-passin arg" the private key password source. For more information about the format of \fBarg\fR see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1). .IP "\fB\-rand file(s)\fR" 4 .IX Item "-rand file(s)" a file or files containing random data used to seed the random number generator, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)). Multiple files can be specified separated by a OS-dependent character. The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for all others. .IP "\fBcert.pem...\fR" 4 .IX Item "cert.pem..." one or more certificates of message recipients: used when encrypting a message. .IP "\fB\-to, \-from, \-subject\fR" 4 .IX Item "-to, -from, -subject" the relevant mail headers. These are included outside the signed portion of a message so they may be included manually. If signing then many S/MIME mail clients check the signers certificate's email address matches that specified in the From: address. .IP "\fB\-purpose, \-ignore_critical, \-issuer_checks, \-crl_check, \-crl_check_all, \-policy_check, \-extended_crl, \-x509_strict, \-policy \-check_ss_sig\fR" 4 .IX Item "-purpose, -ignore_critical, -issuer_checks, -crl_check, -crl_check_all, -policy_check, -extended_crl, -x509_strict, -policy -check_ss_sig" Set various certificate chain valiadition option. See the \&\fBverify\fR manual page for details. .SH "NOTES" .IX Header "NOTES" The \s-1MIME\s0 message must be sent without any blank lines between the headers and the output. Some mail programs will automatically add a blank line. Piping the mail directly to sendmail is one way to achieve the correct format. .PP The supplied message to be signed or encrypted must include the necessary \s-1MIME\s0 headers or many S/MIME clients wont display it properly (if at all). You can use the \fB\-text\fR option to automatically add plain text headers. .PP A \*(L"signed and encrypted\*(R" message is one where a signed message is then encrypted. This can be produced by encrypting an already signed message: see the examples section. .PP This version of the program only allows one signer per message but it will verify multiple signers on received messages. Some S/MIME clients choke if a message contains multiple signers. It is possible to sign messages \*(L"in parallel\*(R" by signing an already signed message. .PP The options \fB\-encrypt\fR and \fB\-decrypt\fR reflect common usage in S/MIME clients. Strictly speaking these process \s-1CMS\s0 enveloped data: \s-1CMS\s0 encrypted data is used for other purposes. .PP The \fB\-resign\fR option uses an existing message digest when adding a new signer. This means that attributes must be present in at least one existing signer using the same message digest or this operation will fail. .PP The \fB\-stream\fR and \fB\-indef\fR options enable experimental streaming I/O support. As a result the encoding is \s-1BER\s0 using indefinite length constructed encoding and no longer \s-1DER.\s0 Streaming is supported for the \fB\-encrypt\fR operation and the \&\fB\-sign\fR operation if the content is not detached. .PP Streaming is always used for the \fB\-sign\fR operation with detached data but since the content is no longer part of the \s-1CMS\s0 structure the encoding remains \s-1DER.\s0 .SH "EXIT CODES" .IX Header "EXIT CODES" .ie n .IP """0""" 4 .el .IP "``0''" 4 .IX Item "0" the operation was completely successfully. .ie n .IP """1""" 4 .el .IP "``1''" 4 .IX Item "1" an error occurred parsing the command options. .ie n .IP """2""" 4 .el .IP "``2''" 4 .IX Item "2" one of the input files could not be read. .ie n .IP """3""" 4 .el .IP "``3''" 4 .IX Item "3" an error occurred creating the \s-1CMS\s0 file or when reading the \s-1MIME\s0 message. .ie n .IP """4""" 4 .el .IP "``4''" 4 .IX Item "4" an error occurred decrypting or verifying the message. .ie n .IP """5""" 4 .el .IP "``5''" 4 .IX Item "5" the message was verified correctly but an error occurred writing out the signers certificates. .SH "COMPATIBILITY WITH PKCS#7 format." .IX Header "COMPATIBILITY WITH PKCS#7 format." The \fBsmime\fR utility can only process the older \fBPKCS#7\fR format. The \fBcms\fR utility supports Cryptographic Message Syntax format. Use of some features will result in messages which cannot be processed by applications which only support the older format. These are detailed below. .PP The use of the \fB\-keyid\fR option with \fB\-sign\fR or \fB\-encrypt\fR. .PP The \fB\-outform \s-1PEM\s0\fR option uses different headers. .PP The \fB\-compress\fR option. .PP The \fB\-secretkey\fR option when used with \fB\-encrypt\fR. .PP Additionally the \fB\-EncryptedData_create\fR and \fB\-data_create\fR type cannot be processed by the older \fBsmime\fR command. .SH "EXAMPLES" .IX Header "EXAMPLES" Create a cleartext signed message: .PP .Vb 2 \& openssl cms \-sign \-in message.txt \-text \-out mail.msg \e \& \-signer mycert.pem .Ve .PP Create an opaque signed message .PP .Vb 2 \& openssl cms \-sign \-in message.txt \-text \-out mail.msg \-nodetach \e \& \-signer mycert.pem .Ve .PP Create a signed message, include some additional certificates and read the private key from another file: .PP .Vb 2 \& openssl cms \-sign \-in in.txt \-text \-out mail.msg \e \& \-signer mycert.pem \-inkey mykey.pem \-certfile mycerts.pem .Ve .PP Create a signed message with two signers, use key identifier: .PP .Vb 2 \& openssl cms \-sign \-in message.txt \-text \-out mail.msg \e \& \-signer mycert.pem \-signer othercert.pem \-keyid .Ve .PP Send a signed message under Unix directly to sendmail, including headers: .PP .Vb 3 \& openssl cms \-sign \-in in.txt \-text \-signer mycert.pem \e \& \-from steve@openssl.org \-to someone@somewhere \e \& \-subject "Signed message" | sendmail someone@somewhere .Ve .PP Verify a message and extract the signer's certificate if successful: .PP .Vb 1 \& openssl cms \-verify \-in mail.msg \-signer user.pem \-out signedtext.txt .Ve .PP Send encrypted mail using triple \s-1DES:\s0 .PP .Vb 3 \& openssl cms \-encrypt \-in in.txt \-from steve@openssl.org \e \& \-to someone@somewhere \-subject "Encrypted message" \e \& \-des3 user.pem \-out mail.msg .Ve .PP Sign and encrypt mail: .PP .Vb 4 \& openssl cms \-sign \-in ml.txt \-signer my.pem \-text \e \& | openssl cms \-encrypt \-out mail.msg \e \& \-from steve@openssl.org \-to someone@somewhere \e \& \-subject "Signed and Encrypted message" \-des3 user.pem .Ve .PP Note: the encryption command does not include the \fB\-text\fR option because the message being encrypted already has \s-1MIME\s0 headers. .PP Decrypt mail: .PP .Vb 1 \& openssl cms \-decrypt \-in mail.msg \-recip mycert.pem \-inkey key.pem .Ve .PP The output from Netscape form signing is a PKCS#7 structure with the detached signature format. You can use this program to verify the signature by line wrapping the base64 encoded structure and surrounding it with: .PP .Vb 2 \& \-\-\-\-\-BEGIN PKCS7\-\-\-\-\- \& \-\-\-\-\-END PKCS7\-\-\-\-\- .Ve .PP and using the command, .PP .Vb 1 \& openssl cms \-verify \-inform PEM \-in signature.pem \-content content.txt .Ve .PP alternatively you can base64 decode the signature and use .PP .Vb 1 \& openssl cms \-verify \-inform DER \-in signature.der \-content content.txt .Ve .PP Create an encrypted message using 128 bit Camellia: .PP .Vb 1 \& openssl cms \-encrypt \-in plain.txt \-camellia128 \-out mail.msg cert.pem .Ve .PP Add a signer to an existing message: .PP .Vb 1 \& openssl cms \-resign \-in mail.msg \-signer newsign.pem \-out mail2.msg .Ve .SH "BUGS" .IX Header "BUGS" The \s-1MIME\s0 parser isn't very clever: it seems to handle most messages that I've thrown at it but it may choke on others. .PP The code currently will only write out the signer's certificate to a file: if the signer has a separate encryption certificate this must be manually extracted. There should be some heuristic that determines the correct encryption certificate. .PP Ideally a database should be maintained of a certificates for each email address. .PP The code doesn't currently take note of the permitted symmetric encryption algorithms as supplied in the SMIMECapabilities signed attribute. this means the user has to manually include the correct encryption algorithm. It should store the list of permitted ciphers in a database and only use those. .PP No revocation checking is done on the signer's certificate. .SH "HISTORY" .IX Header "HISTORY" The use of multiple \fB\-signer\fR options and the \fB\-resign\fR command were first added in OpenSSL 1.0.0 deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_cert_store.30000644000175000017500000001366612360020732022071 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_cert_store 3" .TH SSL_CTX_set_cert_store 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_cert_store, SSL_CTX_get_cert_store \- manipulate X509 certificate verification storage .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_CTX_set_cert_store(SSL_CTX *ctx, X509_STORE *store); \& X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_cert_store()\fR sets/replaces the certificate verification storage of \fBctx\fR to/with \fBstore\fR. If another X509_STORE object is currently set in \fBctx\fR, it will be \fIX509_STORE_free()\fRed. .PP \&\fISSL_CTX_get_cert_store()\fR returns a pointer to the current certificate verification storage. .SH "NOTES" .IX Header "NOTES" In order to verify the certificates presented by the peer, trusted \s-1CA\s0 certificates must be accessed. These \s-1CA\s0 certificates are made available via lookup methods, handled inside the X509_STORE. From the X509_STORE the X509_STORE_CTX used when verifying certificates is created. .PP Typically the trusted certificate store is handled indirectly via using \&\fISSL_CTX_load_verify_locations\fR\|(3). Using the \fISSL_CTX_set_cert_store()\fR and \fISSL_CTX_get_cert_store()\fR functions it is possible to manipulate the X509_STORE object beyond the \&\fISSL_CTX_load_verify_locations\fR\|(3) call. .PP Currently no detailed documentation on how to use the X509_STORE object is available. Not all members of the X509_STORE are used when the verification takes place. So will e.g. the \fIverify_callback()\fR be overridden with the \fIverify_callback()\fR set via the \&\fISSL_CTX_set_verify\fR\|(3) family of functions. This document must therefore be updated when documentation about the X509_STORE object and its handling becomes available. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_set_cert_store()\fR does not return diagnostic output. .PP \&\fISSL_CTX_get_cert_store()\fR returns the current setting. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \&\fISSL_CTX_load_verify_locations\fR\|(3), \&\fISSL_CTX_set_verify\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_max_cert_list.30000644000175000017500000001560012360020732022543 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_max_cert_list 3" .TH SSL_CTX_set_max_cert_list 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_max_cert_list, SSL_CTX_get_max_cert_list, SSL_set_max_cert_list, SSL_get_max_cert_list, \- manipulate allowed for the peer's certificate chain .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& long SSL_CTX_set_max_cert_list(SSL_CTX *ctx, long size); \& long SSL_CTX_get_max_cert_list(SSL_CTX *ctx); \& \& long SSL_set_max_cert_list(SSL *ssl, long size); \& long SSL_get_max_cert_list(SSL *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_max_cert_list()\fR sets the maximum size allowed for the peer's certificate chain for all \s-1SSL\s0 objects created from \fBctx\fR to be bytes. The \s-1SSL\s0 objects inherit the setting valid for \fBctx\fR at the time \&\fISSL_new\fR\|(3) is being called. .PP \&\fISSL_CTX_get_max_cert_list()\fR returns the currently set maximum size for \fBctx\fR. .PP \&\fISSL_set_max_cert_list()\fR sets the maximum size allowed for the peer's certificate chain for \fBssl\fR to be bytes. This setting stays valid until a new value is set. .PP \&\fISSL_get_max_cert_list()\fR returns the currently set maximum size for \fBssl\fR. .SH "NOTES" .IX Header "NOTES" During the handshake process, the peer may send a certificate chain. The \s-1TLS/SSL\s0 standard does not give any maximum size of the certificate chain. The OpenSSL library handles incoming data by a dynamically allocated buffer. In order to prevent this buffer from growing without bounds due to data received from a faulty or malicious peer, a maximum size for the certificate chain is set. .PP The default value for the maximum certificate chain size is 100kB (30kB on the 16bit \s-1DOS\s0 platform). This should be sufficient for usual certificate chains (OpenSSL's default maximum chain length is 10, see \&\fISSL_CTX_set_verify\fR\|(3), and certificates without special extensions have a typical size of 1\-2kB). .PP For special applications it can be necessary to extend the maximum certificate chain size allowed to be sent by the peer, see e.g. the work on \&\*(L"Internet X.509 Public Key Infrastructure Proxy Certificate Profile\*(R" and \*(L"\s-1TLS\s0 Delegation Protocol\*(R" at http://www.ietf.org/ and http://www.globus.org/ . .PP Under normal conditions it should never be necessary to set a value smaller than the default, as the buffer is handled dynamically and only uses the memory actually required by the data sent by the peer. .PP If the maximum certificate chain size allowed is exceeded, the handshake will fail with a \s-1SSL_R_EXCESSIVE_MESSAGE_SIZE\s0 error. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_set_max_cert_list()\fR and \fISSL_set_max_cert_list()\fR return the previously set value. .PP \&\fISSL_CTX_get_max_cert_list()\fR and \fISSL_get_max_cert_list()\fR return the currently set value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_new\fR\|(3), \&\fISSL_CTX_set_verify\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" SSL*_set/\fIget_max_cert_list()\fR have been introduced in OpenSSL 0.9.7. deps/libressl-pnacl-sys-2.1.6/libressl/man/OPENSSL_config.30000644000175000017500000001645612360020721020254 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "OPENSSL_config 3" .TH OPENSSL_config 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" OPENSSL_config, OPENSSL_no_config \- simple OpenSSL configuration functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void OPENSSL_config(const char *config_name); \& void OPENSSL_no_config(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIOPENSSL_config()\fR configures OpenSSL using the standard \fBopenssl.cnf\fR configuration file name using \fBconfig_name\fR. If \fBconfig_name\fR is \s-1NULL\s0 then the default name \fBopenssl_conf\fR will be used. Any errors are ignored. Further calls to \fIOPENSSL_config()\fR will have no effect. The configuration file format is documented in the \fIconf\fR\|(5) manual page. .PP \&\fIOPENSSL_no_config()\fR disables configuration. If called before \fIOPENSSL_config()\fR no configuration takes place. .SH "NOTES" .IX Header "NOTES" It is \fBstrongly\fR recommended that \fBall\fR new applications call \fIOPENSSL_config()\fR or the more sophisticated functions such as \fICONF_modules_load()\fR during initialization (that is before starting any threads). By doing this an application does not need to keep track of all configuration options and some new functionality can be supported automatically. .PP It is also possible to automatically call \fIOPENSSL_config()\fR when an application calls \fIOPENSSL_add_all_algorithms()\fR by compiling an application with the preprocessor symbol \fB\s-1OPENSSL_LOAD_CONF\s0\fR #define'd. In this way configuration can be added without source changes. .PP The environment variable \fB\s-1OPENSSL_CONF\s0\fR can be set to specify the location of the configuration file. .PP Currently \s-1ASN1\s0 OBJECTs and \s-1ENGINE\s0 configuration can be performed future versions of OpenSSL will add new configuration options. .PP There are several reasons why calling the OpenSSL configuration routines is advisable. For example new \s-1ENGINE\s0 functionality was added to OpenSSL 0.9.7. In OpenSSL 0.9.7 control functions can be supported by ENGINEs, this can be used (among other things) to load dynamic ENGINEs from shared libraries (DSOs). However very few applications currently support the control interface and so very few can load and use dynamic ENGINEs. Equally in future more sophisticated ENGINEs will require certain control operations to customize them. If an application calls \fIOPENSSL_config()\fR it doesn't need to know or care about \&\s-1ENGINE\s0 control operations because they can be performed by editing a configuration file. .PP Applications should free up configuration at application closedown by calling \&\fICONF_modules_free()\fR. .SH "RESTRICTIONS" .IX Header "RESTRICTIONS" The \fIOPENSSL_config()\fR function is designed to be a very simple \*(L"call it and forget it\*(R" function. As a result its behaviour is somewhat limited. It ignores all errors silently and it can only load from the standard configuration file location for example. .PP It is however \fBmuch\fR better than nothing. Applications which need finer control over their configuration functionality should use the configuration functions such as \fICONF_load_modules()\fR directly. .SH "RETURN VALUES" .IX Header "RETURN VALUES" Neither \fIOPENSSL_config()\fR nor \fIOPENSSL_no_config()\fR return a value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIconf\fR\|(5), \fICONF_load_modules_file\fR\|(3), \&\fICONF_modules_free\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIOPENSSL_config()\fR and \fIOPENSSL_no_config()\fR first appeared in OpenSSL 0.9.7 deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_msg_callback.30000644000175000017500000001741512360020733022317 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_msg_callback 3" .TH SSL_CTX_set_msg_callback 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_msg_callback, SSL_CTX_set_msg_callback_arg, SSL_set_msg_callback, SSL_get_msg_callback_arg \- install callback for observing protocol messages .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); \& void SSL_CTX_set_msg_callback_arg(SSL_CTX *ctx, void *arg); \& \& void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); \& void SSL_set_msg_callback_arg(SSL *ssl, void *arg); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_msg_callback()\fR or \fISSL_set_msg_callback()\fR can be used to define a message callback function \fIcb\fR for observing all \s-1SSL/TLS\s0 protocol messages (such as handshake messages) that are received or sent. \fISSL_CTX_set_msg_callback_arg()\fR and \fISSL_set_msg_callback_arg()\fR can be used to set argument \fIarg\fR to the callback function, which is available for arbitrary application use. .PP \&\fISSL_CTX_set_msg_callback()\fR and \fISSL_CTX_set_msg_callback_arg()\fR specify default settings that will be copied to new \fB\s-1SSL\s0\fR objects by \&\fISSL_new\fR\|(3). \fISSL_set_msg_callback()\fR and \&\fISSL_set_msg_callback_arg()\fR modify the actual settings of an \fB\s-1SSL\s0\fR object. Using a \fB0\fR pointer for \fIcb\fR disables the message callback. .PP When \fIcb\fR is called by the \s-1SSL/TLS\s0 library for a protocol message, the function arguments have the following meaning: .IP "\fIwrite_p\fR" 4 .IX Item "write_p" This flag is \fB0\fR when a protocol message has been received and \fB1\fR when a protocol message has been sent. .IP "\fIversion\fR" 4 .IX Item "version" The protocol version according to which the protocol message is interpreted by the library. Currently, this is one of \&\fB\s-1SSL2_VERSION\s0\fR, \fB\s-1SSL3_VERSION\s0\fR and \fB\s-1TLS1_VERSION\s0\fR (for \s-1SSL 2.0, SSL 3.0\s0 and \s-1TLS 1.0,\s0 respectively). .IP "\fIcontent_type\fR" 4 .IX Item "content_type" In the case of \s-1SSL 2.0,\s0 this is always \fB0\fR. In the case of \s-1SSL 3.0\s0 or \s-1TLS 1.0,\s0 this is one of the \fBContentType\fR values defined in the protocol specification (\fBchange_cipher_spec(20)\fR, \fBalert(21)\fR, \&\fBhandshake(22)\fR; but never \fBapplication_data(23)\fR because the callback will only be called for protocol messages). .IP "\fIbuf\fR, \fIlen\fR" 4 .IX Item "buf, len" \&\fIbuf\fR points to a buffer containing the protocol message, which consists of \fIlen\fR bytes. The buffer is no longer valid after the callback function has returned. .IP "\fIssl\fR" 4 .IX Item "ssl" The \fB\s-1SSL\s0\fR object that received or sent the message. .IP "\fIarg\fR" 4 .IX Item "arg" The user-defined argument optionally defined by \&\fISSL_CTX_set_msg_callback_arg()\fR or \fISSL_set_msg_callback_arg()\fR. .SH "NOTES" .IX Header "NOTES" Protocol messages are passed to the callback function after decryption and fragment collection where applicable. (Thus record boundaries are not visible.) .PP If processing a received protocol message results in an error, the callback function may not be called. For example, the callback function will never see messages that are considered too large to be processed. .PP Due to automatic protocol version negotiation, \fIversion\fR is not necessarily the protocol version used by the sender of the message: If a \s-1TLS 1.0\s0 ClientHello message is received by an \s-1SSL 3\s0.0\-only server, \&\fIversion\fR will be \fB\s-1SSL3_VERSION\s0\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_new\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fISSL_CTX_set_msg_callback()\fR, \fISSL_CTX_set_msg_callback_arg()\fR, \&\fISSL_set_msg_callback()\fR and \fISSL_get_msg_callback_arg()\fR were added in OpenSSL 0.9.7. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_set_session.30000644000175000017500000001324312360020737020661 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_set_session 3" .TH SSL_set_session 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_set_session \- set a TLS/SSL session to be used during TLS/SSL connect .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_set_session(SSL *ssl, SSL_SESSION *session); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_set_session()\fR sets \fBsession\fR to be used when the \s-1TLS/SSL\s0 connection is to be established. \fISSL_set_session()\fR is only useful for \s-1TLS/SSL\s0 clients. When the session is set, the reference count of \fBsession\fR is incremented by 1. If the session is not reused, the reference count is decremented again during \fISSL_connect()\fR. Whether the session was reused can be queried with the \fISSL_session_reused\fR\|(3) call. .PP If there is already a session set inside \fBssl\fR (because it was set with \&\fISSL_set_session()\fR before or because the same \fBssl\fR was already used for a connection), \fISSL_SESSION_free()\fR will be called for that session. .SH "NOTES" .IX Header "NOTES" \&\s-1SSL_SESSION\s0 objects keep internal link information about the session cache list, when being inserted into one \s-1SSL_CTX\s0 object's session cache. One \s-1SSL_SESSION\s0 object, regardless of its reference count, must therefore only be used with one \s-1SSL_CTX\s0 object (and the \s-1SSL\s0 objects created from this \s-1SSL_CTX\s0 object). .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" The operation failed; check the error stack to find out the reason. .ie n .IP "1" 4 .el .IP "\f(CW1\fR" 4 .IX Item "1" The operation succeeded. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_SESSION_free\fR\|(3), \&\fISSL_get_session\fR\|(3), \&\fISSL_session_reused\fR\|(3), \&\fISSL_CTX_set_session_cache_mode\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_get_ex_new_index.30000644000175000017500000001333612360020731022351 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_get_ex_new_index 3" .TH SSL_CTX_get_ex_new_index 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_get_ex_new_index, SSL_CTX_set_ex_data, SSL_CTX_get_ex_data \- internal application specific data functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_CTX_get_ex_new_index(long argl, void *argp, \& CRYPTO_EX_new *new_func, \& CRYPTO_EX_dup *dup_func, \& CRYPTO_EX_free *free_func); \& \& int SSL_CTX_set_ex_data(SSL_CTX *ctx, int idx, void *arg); \& \& void *SSL_CTX_get_ex_data(const SSL_CTX *ctx, int idx); \& \& typedef int new_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad, \& int idx, long argl, void *argp); \& typedef void free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad, \& int idx, long argl, void *argp); \& typedef int dup_func(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, \& int idx, long argl, void *argp); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Several OpenSSL structures can have application specific data attached to them. These functions are used internally by OpenSSL to manipulate application specific data attached to a specific structure. .PP \&\fISSL_CTX_get_ex_new_index()\fR is used to register a new index for application specific data. .PP \&\fISSL_CTX_set_ex_data()\fR is used to store application data at \fBarg\fR for \fBidx\fR into the \fBctx\fR object. .PP \&\fISSL_CTX_get_ex_data()\fR is used to retrieve the information for \fBidx\fR from \&\fBctx\fR. .PP A detailed description for the \fB*\f(BI_get_ex_new_index()\fB\fR functionality can be found in \fIRSA_get_ex_new_index\fR\|(3). The \fB*\f(BI_get_ex_data()\fB\fR and \fB*\f(BI_set_ex_data()\fB\fR functionality is described in \&\fICRYPTO_set_ex_data\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \&\fIRSA_get_ex_new_index\fR\|(3), \&\fICRYPTO_set_ex_data\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/ERR_print_errors.30000644000175000017500000001260612360020717021042 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ERR_print_errors 3" .TH ERR_print_errors 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ERR_print_errors, ERR_print_errors_fp \- print error messages .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void ERR_print_errors(BIO *bp); \& void ERR_print_errors_fp(FILE *fp); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIERR_print_errors()\fR is a convenience function that prints the error strings for all errors that OpenSSL has recorded to \fBbp\fR, thus emptying the error queue. .PP \&\fIERR_print_errors_fp()\fR is the same, except that the output goes to a \&\fB\s-1FILE\s0\fR. .PP The error strings will have the following format: .PP .Vb 1 \& [pid]:error:[error code]:[library name]:[function name]:[reason string]:[file name]:[line]:[optional text message] .Ve .PP \&\fIerror code\fR is an 8 digit hexadecimal number. \fIlibrary name\fR, \&\fIfunction name\fR and \fIreason string\fR are \s-1ASCII\s0 text, as is \fIoptional text message\fR if one was set for the respective error code. .PP If there is no text string registered for the given error code, the error string will contain the numeric code. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIERR_print_errors()\fR and \fIERR_print_errors_fp()\fR return no values. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIerr\fR\|(3), \fIERR_error_string\fR\|(3), \&\fIERR_get_error\fR\|(3), \&\fIERR_load_crypto_strings\fR\|(3), \&\fISSL_load_error_strings\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIERR_print_errors()\fR and \fIERR_print_errors_fp()\fR are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/PEM_write_bio_PKCS7_stream.30000644000175000017500000001171112360020722022540 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PEM_write_bio_PKCS7_stream 3" .TH PEM_write_bio_PKCS7_stream 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PEM_write_bio_PKCS7_stream \- output PKCS7 structure in PEM format. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& int PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *data, int flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIPEM_write_bio_PKCS7_stream()\fR outputs a \s-1PKCS7\s0 structure in \s-1PEM\s0 format. .PP It is otherwise identical to the function \fISMIME_write_PKCS7()\fR. .SH "NOTES" .IX Header "NOTES" This function is effectively a version of the \fIPEM_write_bio_PKCS7()\fR supporting streaming. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIPEM_write_bio_PKCS7_stream()\fR returns 1 for success or 0 for failure. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fIPKCS7_sign\fR\|(3), \&\fIPKCS7_verify\fR\|(3), \fIPKCS7_encrypt\fR\|(3) \&\fIPKCS7_decrypt\fR\|(3), \&\fISMIME_write_PKCS7\fR\|(3), \&\fIi2d_PKCS7_bio_stream\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIPEM_write_bio_PKCS7_stream()\fR was added to OpenSSL 1.0.0 deps/libressl-pnacl-sys-2.1.6/libressl/man/EC_KEY_new.30000644000175000017500000002755012360020716017455 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EC_KEY_new 3" .TH EC_KEY_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EC_KEY_new, EC_KEY_get_flags, EC_KEY_set_flags, EC_KEY_clear_flags, EC_KEY_new_by_curve_name, EC_KEY_free, EC_KEY_copy, EC_KEY_dup, EC_KEY_up_ref, EC_KEY_get0_group, EC_KEY_set_group, EC_KEY_get0_private_key, EC_KEY_set_private_key, EC_KEY_get0_public_key, EC_KEY_set_public_key, EC_KEY_get_enc_flags, EC_KEY_set_enc_flags, EC_KEY_get_conv_form, EC_KEY_set_conv_form, EC_KEY_get_key_method_data, EC_KEY_insert_key_method_data, EC_KEY_set_asn1_flag, EC_KEY_precompute_mult, EC_KEY_generate_key, EC_KEY_check_key, EC_KEY_set_public_key_affine_coordinates \- Functions for creating, destroying and manipulating EC_KEY objects. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& EC_KEY *EC_KEY_new(void); \& int EC_KEY_get_flags(const EC_KEY *key); \& void EC_KEY_set_flags(EC_KEY *key, int flags); \& void EC_KEY_clear_flags(EC_KEY *key, int flags); \& EC_KEY *EC_KEY_new_by_curve_name(int nid); \& void EC_KEY_free(EC_KEY *key); \& EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src); \& EC_KEY *EC_KEY_dup(const EC_KEY *src); \& int EC_KEY_up_ref(EC_KEY *key); \& const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key); \& int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group); \& const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key); \& int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv); \& const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key); \& int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub); \& unsigned int EC_KEY_get_enc_flags(const EC_KEY *key); \& void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags); \& point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key); \& void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform); \& void *EC_KEY_get_key_method_data(EC_KEY *key, \& void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); \& void EC_KEY_insert_key_method_data(EC_KEY *key, void *data, \& void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); \& void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag); \& int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx); \& int EC_KEY_generate_key(EC_KEY *key); \& int EC_KEY_check_key(const EC_KEY *key); \& int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" An \s-1EC_KEY\s0 represents a public key and (optionaly) an associated private key. A new \s-1EC_KEY \s0(with no associated curve) can be constructed by calling EC_KEY_new. The reference count for the newly created \s-1EC_KEY\s0 is initially set to 1. A curve can be associated with the \s-1EC_KEY\s0 by calling EC_KEY_set_group. .PP Alternatively a new \s-1EC_KEY\s0 can be constructed by calling EC_KEY_new_by_curve_name and supplying the nid of the associated curve. Refer to \fIEC_GROUP_new\fR\|(3) for a description of curve names. This function simply wraps calls to EC_KEY_new and EC_GROUP_new_by_curve_name. .PP Calling EC_KEY_free decrements the reference count for the \s-1EC_KEY\s0 object, and if it has dropped to zero then frees the memory associated with it. .PP EC_KEY_copy copies the contents of the \s-1EC_KEY\s0 in \fBsrc\fR into \fBdest\fR. .PP EC_KEY_dup creates a new \s-1EC_KEY\s0 object and copies \fBec_key\fR into it. .PP EC_KEY_up_ref increments the reference count associated with the \s-1EC_KEY\s0 object. .PP EC_KEY_generate_key generates a new public and private key for the supplied \fBeckey\fR object. \fBeckey\fR must have an \s-1EC_GROUP\s0 object associated with it before calling this function. The private key is a random integer (0 < priv_key < order, where order is the order of the \s-1EC_GROUP\s0 object). The public key is an \s-1EC_POINT\s0 on the curve calculated by multiplying the generator for the curve by the private key. .PP EC_KEY_check_key performs various sanity checks on the \s-1EC_KEY\s0 object to confirm that it is valid. .PP EC_KEY_set_public_key_affine_coordinates sets the public key for \fBkey\fR based on its affine co-ordinates, i.e. it constructs an \s-1EC_POINT\s0 object based on the supplied \fBx\fR and \fBy\fR values and sets the public key to be this \s-1EC_POINT.\s0 It will also performs certain sanity checks on the key to confirm that it is valid. .PP The functions EC_KEY_get0_group, EC_KEY_set_group, EC_KEY_get0_private_key, EC_KEY_set_private_key, EC_KEY_get0_public_key, and EC_KEY_set_public_key get and set the \s-1EC_GROUP\s0 object, the private key and the \s-1EC_POINT\s0 public key for the \fBkey\fR respectively. .PP The functions EC_KEY_get_enc_flags and EC_KEY_set_enc_flags get and set the value of the encoding flags for the \fBkey\fR. There are two encoding flags currently defined \- \s-1EC_PKEY_NO_PARAMETERS\s0 and \s-1EC_PKEY_NO_PUBKEY. \s0 These flags define the behaviour of how the \fBkey\fR is converted into \s-1ASN1\s0 in a call to i2d_ECPrivateKey. If \s-1EC_PKEY_NO_PARAMETERS\s0 is set then the public parameters for the curve are not encoded along with the private key. If \s-1EC_PKEY_NO_PUBKEY\s0 is set then the public key is not encoded along with the private key. .PP The functions EC_KEY_get_conv_form and EC_KEY_set_conv_form get and set the point_conversion_form for the \fBkey\fR. For a description of point_conversion_forms please refer to \fIEC_POINT_new\fR\|(3). .PP EC_KEY_insert_key_method_data and EC_KEY_get_key_method_data enable the caller to associate arbitary additional data specific to the elliptic curve scheme being used with the \s-1EC_KEY\s0 object. This data is treated as a \*(L"black box\*(R" by the ec library. The data to be stored by EC_KEY_insert_key_method_data is provided in the \fBdata\fR parameter, which must have have associated functions for duplicating, freeing and \*(L"clear_freeing\*(R" the data item. If a subsequent EC_KEY_get_key_method_data call is issued, the functions for duplicating, freeing and \*(L"clear_freeing\*(R" the data item must be provided again, and they must be the same as they were when the data item was inserted. .PP EC_KEY_set_flags sets the flags in the \fBflags\fR parameter on the \s-1EC_KEY\s0 object. Any flags that are already set are left set. The currently defined standard flags are \s-1EC_FLAG_NON_FIPS_ALLOW\s0 and \s-1EC_FLAG_FIPS_CHECKED.\s0 In addition there is the flag \s-1EC_FLAG_COFACTOR_ECDH\s0 which is specific to \s-1ECDH\s0 and is defined in ecdh.h. EC_KEY_get_flags returns the current flags that are set for this \s-1EC_KEY.\s0 EC_KEY_clear_flags clears the flags indicated by the \fBflags\fR parameter. All other flags are left in their existing state. .PP EC_KEY_set_asn1_flag sets the asn1_flag on the underlying \s-1EC_GROUP\s0 object (if set). Refer to \fIEC_GROUP_copy\fR\|(3) for further information on the asn1_flag. .PP EC_KEY_precompute_mult stores multiples of the underlying \s-1EC_GROUP\s0 generator for faster point multiplication. See also \fIEC_POINT_add\fR\|(3). .SH "RETURN VALUES" .IX Header "RETURN VALUES" EC_KEY_new, EC_KEY_new_by_curve_name and EC_KEY_dup return a pointer to the newly created \s-1EC_KEY\s0 object, or \s-1NULL\s0 on error. .PP EC_KEY_get_flags returns the flags associated with the \s-1EC_KEY\s0 object as an integer. .PP EC_KEY_copy returns a pointer to the destination key, or \s-1NULL\s0 on error. .PP EC_KEY_up_ref, EC_KEY_set_group, EC_KEY_set_private_key, EC_KEY_set_public_key, EC_KEY_precompute_mult, EC_KEY_generate_key, EC_KEY_check_key and EC_KEY_set_public_key_affine_coordinates return 1 on success or 0 on error. .PP EC_KEY_get0_group returns the \s-1EC_GROUP\s0 associated with the \s-1EC_KEY.\s0 .PP EC_KEY_get0_private_key returns the private key associated with the \s-1EC_KEY.\s0 .PP EC_KEY_get_enc_flags returns the value of the current encoding flags for the \s-1EC_KEY.\s0 .PP EC_KEY_get_conv_form return the point_conversion_form for the \s-1EC_KEY.\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIcrypto\fR\|(3), \fIec\fR\|(3), \fIEC_GROUP_new\fR\|(3), \fIEC_GROUP_copy\fR\|(3), \&\fIEC_POINT_new\fR\|(3), \fIEC_POINT_add\fR\|(3), \&\fIEC_GFp_simple_method\fR\|(3), \fId2i_ECPKParameters\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/x509v3_config.10000644000175000017500000005414112360020744020103 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "x509v3_config 1" .TH x509v3_config 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" x509v3_config \- X509 V3 certificate extension configuration format .SH "DESCRIPTION" .IX Header "DESCRIPTION" Several of the OpenSSL utilities can add extensions to a certificate or certificate request based on the contents of a configuration file. .PP Typically the application will contain an option to point to an extension section. Each line of the extension section takes the form: .PP .Vb 1 \& extension_name=[critical,] extension_options .Ve .PP If \fBcritical\fR is present then the extension will be critical. .PP The format of \fBextension_options\fR depends on the value of \fBextension_name\fR. .PP There are four main types of extension: \fIstring\fR extensions, \fImulti-valued\fR extensions, \fIraw\fR and \fIarbitrary\fR extensions. .PP String extensions simply have a string which contains either the value itself or how it is obtained. .PP For example: .PP .Vb 1 \& nsComment="This is a Comment" .Ve .PP Multi-valued extensions have a short form and a long form. The short form is a list of names and values: .PP .Vb 1 \& basicConstraints=critical,CA:true,pathlen:1 .Ve .PP The long form allows the values to be placed in a separate section: .PP .Vb 1 \& basicConstraints=critical,@bs_section \& \& [bs_section] \& \& CA=true \& pathlen=1 .Ve .PP Both forms are equivalent. .PP The syntax of raw extensions is governed by the extension code: it can for example contain data in multiple sections. The correct syntax to use is defined by the extension code itself: check out the certificate policies extension for an example. .PP If an extension type is unsupported then the \fIarbitrary\fR extension syntax must be used, see the \s-1ARBITRARY EXTENSIONS\s0 section for more details. .SH "STANDARD EXTENSIONS" .IX Header "STANDARD EXTENSIONS" The following sections describe each supported extension in detail. .SS "Basic Constraints." .IX Subsection "Basic Constraints." This is a multi valued extension which indicates whether a certificate is a \s-1CA\s0 certificate. The first (mandatory) name is \fB\s-1CA\s0\fR followed by \fB\s-1TRUE\s0\fR or \&\fB\s-1FALSE\s0\fR. If \fB\s-1CA\s0\fR is \fB\s-1TRUE\s0\fR then an optional \fBpathlen\fR name followed by an non-negative value can be included. .PP For example: .PP .Vb 1 \& basicConstraints=CA:TRUE \& \& basicConstraints=CA:FALSE \& \& basicConstraints=critical,CA:TRUE, pathlen:0 .Ve .PP A \s-1CA\s0 certificate \fBmust\fR include the basicConstraints value with the \s-1CA\s0 field set to \s-1TRUE.\s0 An end user certificate must either set \s-1CA\s0 to \s-1FALSE\s0 or exclude the extension entirely. Some software may require the inclusion of basicConstraints with \s-1CA\s0 set to \s-1FALSE\s0 for end entity certificates. .PP The pathlen parameter indicates the maximum number of CAs that can appear below this one in a chain. So if you have a \s-1CA\s0 with a pathlen of zero it can only be used to sign end user certificates and not further CAs. .SS "Key Usage." .IX Subsection "Key Usage." Key usage is a multi valued extension consisting of a list of names of the permitted key usages. .PP The supporte names are: digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment, keyAgreement, keyCertSign, cRLSign, encipherOnly and decipherOnly. .PP Examples: .PP .Vb 1 \& keyUsage=digitalSignature, nonRepudiation \& \& keyUsage=critical, keyCertSign .Ve .SS "Extended Key Usage." .IX Subsection "Extended Key Usage." This extensions consists of a list of usages indicating purposes for which the certificate public key can be used for, .PP These can either be object short names of the dotted numerical form of OIDs. While any \s-1OID\s0 can be used only certain values make sense. In particular the following \s-1PKIX, NS\s0 and \s-1MS\s0 values are meaningful: .PP .Vb 10 \& Value Meaning \& \-\-\-\-\- \-\-\-\-\-\-\- \& serverAuth SSL/TLS Web Server Authentication. \& clientAuth SSL/TLS Web Client Authentication. \& codeSigning Code signing. \& emailProtection E\-mail Protection (S/MIME). \& timeStamping Trusted Timestamping \& msCodeInd Microsoft Individual Code Signing (authenticode) \& msCodeCom Microsoft Commercial Code Signing (authenticode) \& msCTLSign Microsoft Trust List Signing \& msSGC Microsoft Server Gated Crypto \& msEFS Microsoft Encrypted File System \& nsSGC Netscape Server Gated Crypto .Ve .PP Examples: .PP .Vb 2 \& extendedKeyUsage=critical,codeSigning,1.2.3.4 \& extendedKeyUsage=nsSGC,msSGC .Ve .SS "Subject Key Identifier." .IX Subsection "Subject Key Identifier." This is really a string extension and can take two possible values. Either the word \fBhash\fR which will automatically follow the guidelines in \s-1RFC3280\s0 or a hex string giving the extension value to include. The use of the hex string is strongly discouraged. .PP Example: .PP .Vb 1 \& subjectKeyIdentifier=hash .Ve .SS "Authority Key Identifier." .IX Subsection "Authority Key Identifier." The authority key identifier extension permits two options. keyid and issuer: both can take the optional value \*(L"always\*(R". .PP If the keyid option is present an attempt is made to copy the subject key identifier from the parent certificate. If the value \*(L"always\*(R" is present then an error is returned if the option fails. .PP The issuer option copies the issuer and serial number from the issuer certificate. This will only be done if the keyid option fails or is not included unless the \*(L"always\*(R" flag will always include the value. .PP Example: .PP .Vb 1 \& authorityKeyIdentifier=keyid,issuer .Ve .SS "Subject Alternative Name." .IX Subsection "Subject Alternative Name." The subject alternative name extension allows various literal values to be included in the configuration file. These include \fBemail\fR (an email address) \&\fB\s-1URI\s0\fR a uniform resource indicator, \fB\s-1DNS\s0\fR (a \s-1DNS\s0 domain name), \fB\s-1RID\s0\fR (a registered \s-1ID: OBJECT IDENTIFIER\s0), \fB\s-1IP\s0\fR (an \s-1IP\s0 address), \fBdirName\fR (a distinguished name) and otherName. .PP The email option include a special 'copy' value. This will automatically include and email addresses contained in the certificate subject name in the extension. .PP The \s-1IP\s0 address used in the \fB\s-1IP\s0\fR options can be in either IPv4 or IPv6 format. .PP The value of \fBdirName\fR should point to a section containing the distinguished name to use as a set of name value pairs. Multi values AVAs can be formed by preceeding the name with a \fB+\fR character. .PP otherName can include arbitrary data associated with an \s-1OID:\s0 the value should be the \s-1OID\s0 followed by a semicolon and the content in standard \&\fIASN1_generate_nconf\fR\|(3) format. .PP Examples: .PP .Vb 5 \& subjectAltName=email:copy,email:my@other.address,URI:http://my.url.here/ \& subjectAltName=IP:192.168.7.1 \& subjectAltName=IP:13::17 \& subjectAltName=email:my@other.address,RID:1.2.3.4 \& subjectAltName=otherName:1.2.3.4;UTF8:some other identifier \& \& subjectAltName=dirName:dir_sect \& \& [dir_sect] \& C=UK \& O=My Organization \& OU=My Unit \& CN=My Name .Ve .SS "Issuer Alternative Name." .IX Subsection "Issuer Alternative Name." The issuer alternative name option supports all the literal options of subject alternative name. It does \fBnot\fR support the email:copy option because that would not make sense. It does support an additional issuer:copy option that will copy all the subject alternative name values from the issuer certificate (if possible). .PP Example: .PP .Vb 1 \& issuserAltName = issuer:copy .Ve .SS "Authority Info Access." .IX Subsection "Authority Info Access." The authority information access extension gives details about how to access certain information relating to the \s-1CA.\s0 Its syntax is accessOID;location where \fIlocation\fR has the same syntax as subject alternative name (except that email:copy is not supported). accessOID can be any valid \s-1OID\s0 but only certain values are meaningful, for example \s-1OCSP\s0 and caIssuers. .PP Example: .PP .Vb 2 \& authorityInfoAccess = OCSP;URI:http://ocsp.my.host/ \& authorityInfoAccess = caIssuers;URI:http://my.ca/ca.html .Ve .SS "\s-1CRL\s0 distribution points." .IX Subsection "CRL distribution points." This is a multi-valued extension whose options can be either in name:value pair using the same form as subject alternative name or a single value representing a section name containing all the distribution point fields. .PP For a name:value pair a new DistributionPoint with the fullName field set to the given value both the cRLissuer and reasons fields are omitted in this case. .PP In the single option case the section indicated contains values for each field. In this section: .PP If the name is \*(L"fullname\*(R" the value field should contain the full name of the distribution point in the same format as subject alternative name. .PP If the name is \*(L"relativename\*(R" then the value field should contain a section name whose contents represent a \s-1DN\s0 fragment to be placed in this field. .PP The name \*(L"CRLIssuer\*(R" if present should contain a value for this field in subject alternative name format. .PP If the name is \*(L"reasons\*(R" the value field should consist of a comma separated field containing the reasons. Valid reasons are: \*(L"keyCompromise\*(R", \&\*(L"CACompromise\*(R", \*(L"affiliationChanged\*(R", \*(L"superseded\*(R", \*(L"cessationOfOperation\*(R", \&\*(L"certificateHold\*(R", \*(L"privilegeWithdrawn\*(R" and \*(L"AACompromise\*(R". .PP Simple examples: .PP .Vb 2 \& crlDistributionPoints=URI:http://myhost.com/myca.crl \& crlDistributionPoints=URI:http://my.com/my.crl,URI:http://oth.com/my.crl .Ve .PP Full distribution point example: .PP .Vb 1 \& crlDistributionPoints=crldp1_section \& \& [crldp1_section] \& \& fullname=URI:http://myhost.com/myca.crl \& CRLissuer=dirName:issuer_sect \& reasons=keyCompromise, CACompromise \& \& [issuer_sect] \& C=UK \& O=Organisation \& CN=Some Name .Ve .SS "Issuing Distribution Point" .IX Subsection "Issuing Distribution Point" This extension should only appear in CRLs. It is a multi valued extension whose syntax is similar to the \*(L"section\*(R" pointed to by the \s-1CRL\s0 distribution points extension with a few differences. .PP The names \*(L"reasons\*(R" and \*(L"CRLissuer\*(R" are not recognized. .PP The name \*(L"onlysomereasons\*(R" is accepted which sets this field. The value is in the same format as the \s-1CRL\s0 distribution point \*(L"reasons\*(R" field. .PP The names \*(L"onlyuser\*(R", \*(L"onlyCA\*(R", \*(L"onlyAA\*(R" and \*(L"indirectCRL\*(R" are also accepted the values should be a boolean value (\s-1TRUE\s0 or \s-1FALSE\s0) to indicate the value of the corresponding field. .PP Example: .PP .Vb 1 \& issuingDistributionPoint=critical, @idp_section \& \& [idp_section] \& \& fullname=URI:http://myhost.com/myca.crl \& indirectCRL=TRUE \& onlysomereasons=keyCompromise, CACompromise \& \& [issuer_sect] \& C=UK \& O=Organisation \& CN=Some Name .Ve .SS "Certificate Policies." .IX Subsection "Certificate Policies." This is a \fIraw\fR extension. All the fields of this extension can be set by using the appropriate syntax. .PP If you follow the \s-1PKIX\s0 recommendations and just using one \s-1OID\s0 then you just include the value of that \s-1OID.\s0 Multiple OIDs can be set separated by commas, for example: .PP .Vb 1 \& certificatePolicies= 1.2.4.5, 1.1.3.4 .Ve .PP If you wish to include qualifiers then the policy \s-1OID\s0 and qualifiers need to be specified in a separate section: this is done by using the \f(CW@section\fR syntax instead of a literal \s-1OID\s0 value. .PP The section referred to must include the policy \s-1OID\s0 using the name policyIdentifier, cPSuri qualifiers can be included using the syntax: .PP .Vb 1 \& CPS.nnn=value .Ve .PP userNotice qualifiers can be set using the syntax: .PP .Vb 1 \& userNotice.nnn=@notice .Ve .PP The value of the userNotice qualifier is specified in the relevant section. This section can include explicitText, organization and noticeNumbers options. explicitText and organization are text strings, noticeNumbers is a comma separated list of numbers. The organization and noticeNumbers options (if included) must \s-1BOTH\s0 be present. If you use the userNotice option with \s-1IE5\s0 then you need the 'ia5org' option at the top level to modify the encoding: otherwise it will not be interpreted properly. .PP Example: .PP .Vb 1 \& certificatePolicies=ia5org,1.2.3.4,1.5.6.7.8,@polsect \& \& [polsect] \& \& policyIdentifier = 1.3.5.8 \& CPS.1="http://my.host.name/" \& CPS.2="http://my.your.name/" \& userNotice.1=@notice \& \& [notice] \& \& explicitText="Explicit Text Here" \& organization="Organisation Name" \& noticeNumbers=1,2,3,4 .Ve .PP The \fBia5org\fR option changes the type of the \fIorganization\fR field. In \s-1RFC2459\s0 it can only be of type DisplayText. In \s-1RFC3280\s0 IA5Strring is also permissible. Some software (for example some versions of \s-1MSIE\s0) may require ia5org. .SS "Policy Constraints" .IX Subsection "Policy Constraints" This is a multi-valued extension which consisting of the names \&\fBrequireExplicitPolicy\fR or \fBinhibitPolicyMapping\fR and a non negative intger value. At least one component must be present. .PP Example: .PP .Vb 1 \& policyConstraints = requireExplicitPolicy:3 .Ve .SS "Inhibit Any Policy" .IX Subsection "Inhibit Any Policy" This is a string extension whose value must be a non negative integer. .PP Example: .PP .Vb 1 \& inhibitAnyPolicy = 2 .Ve .SS "Name Constraints" .IX Subsection "Name Constraints" The name constraints extension is a multi-valued extension. The name should begin with the word \fBpermitted\fR or \fBexcluded\fR followed by a \fB;\fR. The rest of the name and the value follows the syntax of subjectAltName except email:copy is not supported and the \fB\s-1IP\s0\fR form should consist of an \s-1IP\s0 addresses and subnet mask separated by a \fB/\fR. .PP Examples: .PP .Vb 1 \& nameConstraints=permitted;IP:192.168.0.0/255.255.0.0 \& \& nameConstraints=permitted;email:.somedomain.com \& \& nameConstraints=excluded;email:.com \&issuingDistributionPoint = idp_section .Ve .SS "\s-1OCSP\s0 No Check" .IX Subsection "OCSP No Check" The \s-1OCSP\s0 No Check extension is a string extension but its value is ignored. .PP Example: .PP .Vb 1 \& noCheck = ignored .Ve .SH "DEPRECATED EXTENSIONS" .IX Header "DEPRECATED EXTENSIONS" The following extensions are non standard, Netscape specific and largely obsolete. Their use in new applications is discouraged. .SS "Netscape String extensions." .IX Subsection "Netscape String extensions." Netscape Comment (\fBnsComment\fR) is a string extension containing a comment which will be displayed when the certificate is viewed in some browsers. .PP Example: .PP .Vb 1 \& nsComment = "Some Random Comment" .Ve .PP Other supported extensions in this category are: \fBnsBaseUrl\fR, \&\fBnsRevocationUrl\fR, \fBnsCaRevocationUrl\fR, \fBnsRenewalUrl\fR, \fBnsCaPolicyUrl\fR and \fBnsSslServerName\fR. .SS "Netscape Certificate Type" .IX Subsection "Netscape Certificate Type" This is a multi-valued extensions which consists of a list of flags to be included. It was used to indicate the purposes for which a certificate could be used. The basicConstraints, keyUsage and extended key usage extensions are now used instead. .PP Acceptable values for nsCertType are: \fBclient\fR, \fBserver\fR, \fBemail\fR, \&\fBobjsign\fR, \fBreserved\fR, \fBsslCA\fR, \fBemailCA\fR, \fBobjCA\fR. .SH "ARBITRARY EXTENSIONS" .IX Header "ARBITRARY EXTENSIONS" If an extension is not supported by the OpenSSL code then it must be encoded using the arbitrary extension format. It is also possible to use the arbitrary format for supported extensions. Extreme care should be taken to ensure that the data is formatted correctly for the given extension type. .PP There are two ways to encode arbitrary extensions. .PP The first way is to use the word \s-1ASN1\s0 followed by the extension content using the same syntax as \fIASN1_generate_nconf\fR\|(3). For example: .PP .Vb 1 \& 1.2.3.4=critical,ASN1:UTF8String:Some random data \& \& 1.2.3.4=ASN1:SEQUENCE:seq_sect \& \& [seq_sect] \& \& field1 = UTF8:field1 \& field2 = UTF8:field2 .Ve .PP It is also possible to use the word \s-1DER\s0 to include the raw encoded data in any extension. .PP .Vb 2 \& 1.2.3.4=critical,DER:01:02:03:04 \& 1.2.3.4=DER:01020304 .Ve .PP The value following \s-1DER\s0 is a hex dump of the \s-1DER\s0 encoding of the extension Any extension can be placed in this form to override the default behaviour. For example: .PP .Vb 1 \& basicConstraints=critical,DER:00:01:02:03 .Ve .SH "WARNING" .IX Header "WARNING" There is no guarantee that a specific implementation will process a given extension. It may therefore be sometimes possible to use certificates for purposes prohibited by their extensions because a specific application does not recognize or honour the values of the relevant extensions. .PP The \s-1DER\s0 and \s-1ASN1\s0 options should be used with caution. It is possible to create totally invalid extensions if they are not used carefully. .SH "NOTES" .IX Header "NOTES" If an extension is multi-value and a field value must contain a comma the long form must be used otherwise the comma would be misinterpreted as a field separator. For example: .PP .Vb 1 \& subjectAltName=URI:ldap://somehost.com/CN=foo,OU=bar .Ve .PP will produce an error but the equivalent form: .PP .Vb 1 \& subjectAltName=@subject_alt_section \& \& [subject_alt_section] \& subjectAltName=URI:ldap://somehost.com/CN=foo,OU=bar .Ve .PP is valid. .PP Due to the behaviour of the OpenSSL \fBconf\fR library the same field name can only occur once in a section. This means that: .PP .Vb 1 \& subjectAltName=@alt_section \& \& [alt_section] \& \& email=steve@here \& email=steve@there .Ve .PP will only recognize the last value. This can be worked around by using the form: .PP .Vb 1 \& [alt_section] \& \& email.1=steve@here \& email.2=steve@there .Ve .SH "HISTORY" .IX Header "HISTORY" The X509v3 extension code was first added to OpenSSL 0.9.2. .PP Policy mappings, inhibit any policy and name constraints support was added in OpenSSL 0.9.8 .PP The \fBdirectoryName\fR and \fBotherName\fR option as well as the \fB\s-1ASN1\s0\fR option for arbitrary extensions was added in OpenSSL 0.9.8 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIreq\fR\|(1), \fIca\fR\|(1), \fIx509\fR\|(1), \&\fIASN1_generate_nconf\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/CONF_modules_free.30000644000175000017500000001232712360020714021055 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CONF_modules_free 3" .TH CONF_modules_free 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CONF_modules_free, CONF_modules_finish, CONF_modules_unload \- OpenSSL configuration cleanup functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void CONF_modules_free(void); \& void CONF_modules_finish(void); \& void CONF_modules_unload(int all); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fICONF_modules_free()\fR closes down and frees up all memory allocated by all configuration modules. .PP \&\fICONF_modules_finish()\fR calls each configuration modules \fBfinish\fR handler to free up any configuration that module may have performed. .PP \&\fICONF_modules_unload()\fR finishes and unloads configuration modules. If \&\fBall\fR is set to \fB0\fR only modules loaded from DSOs will be unloads. If \&\fBall\fR is \fB1\fR all modules, including builtin modules will be unloaded. .SH "NOTES" .IX Header "NOTES" Normally applications will only call \fICONF_modules_free()\fR at application to tidy up any configuration performed. .SH "RETURN VALUE" .IX Header "RETURN VALUE" None of the functions return a value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIconf\fR\|(5), \fIOPENSSL_config\fR\|(3), \&\fICONF_modules_load_file\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fICONF_modules_free()\fR, \fICONF_modules_unload()\fR, and \fICONF_modules_finish()\fR first appeared in OpenSSL 0.9.7. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_load_verify_locations.30000644000175000017500000002162612360020731023415 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_load_verify_locations 3" .TH SSL_CTX_load_verify_locations 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_load_verify_locations \- set default locations for trusted CA certificates .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, \& const char *CApath); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_load_verify_locations()\fR specifies the locations for \fBctx\fR, at which \s-1CA\s0 certificates for verification purposes are located. The certificates available via \fBCAfile\fR and \fBCApath\fR are trusted. .SH "NOTES" .IX Header "NOTES" If \fBCAfile\fR is not \s-1NULL,\s0 it points to a file of \s-1CA\s0 certificates in \s-1PEM\s0 format. The file can contain several \s-1CA\s0 certificates identified by .PP .Vb 3 \& \-\-\-\-\-BEGIN CERTIFICATE\-\-\-\-\- \& ... (CA certificate in base64 encoding) ... \& \-\-\-\-\-END CERTIFICATE\-\-\-\-\- .Ve .PP sequences. Before, between, and after the certificates text is allowed which can be used e.g. for descriptions of the certificates. .PP The \fBCAfile\fR is processed on execution of the \fISSL_CTX_load_verify_locations()\fR function. .PP If \fBCApath\fR is not \s-1NULL,\s0 it points to a directory containing \s-1CA\s0 certificates in \s-1PEM\s0 format. The files each contain one \s-1CA\s0 certificate. The files are looked up by the \s-1CA\s0 subject name hash value, which must hence be available. If more than one \s-1CA\s0 certificate with the same name hash value exist, the extension must be different (e.g. 9d66eef0.0, 9d66eef0.1 etc). The search is performed in the ordering of the extension number, regardless of other properties of the certificates. .PP The certificates in \fBCApath\fR are only looked up when required, e.g. when building the certificate chain or when actually performing the verification of a peer certificate. .PP When looking up \s-1CA\s0 certificates, the OpenSSL library will first search the certificates in \fBCAfile\fR, then those in \fBCApath\fR. Certificate matching is done based on the subject name, the key identifier (if present), and the serial number as taken from the certificate to be verified. If these data do not match, the next certificate will be tried. If a first certificate matching the parameters is found, the verification process will be performed; no other certificates for the same parameters will be searched in case of failure. .PP In server mode, when requesting a client certificate, the server must send the list of CAs of which it will accept client certificates. This list is not influenced by the contents of \fBCAfile\fR or \fBCApath\fR and must explicitly be set using the \&\fISSL_CTX_set_client_CA_list\fR\|(3) family of functions. .PP When building its own certificate chain, an OpenSSL client/server will try to fill in missing certificates from \fBCAfile\fR/\fBCApath\fR, if the certificate chain was not explicitly specified (see \&\fISSL_CTX_add_extra_chain_cert\fR\|(3), \&\fISSL_CTX_use_certificate\fR\|(3). .SH "WARNINGS" .IX Header "WARNINGS" If several \s-1CA\s0 certificates matching the name, key identifier, and serial number condition are available, only the first one will be examined. This may lead to unexpected results if the same \s-1CA\s0 certificate is available with different expiration dates. If a \*(L"certificate expired\*(R" verification error occurs, no other certificate will be searched. Make sure to not have expired certificates mixed with valid ones. .SH "EXAMPLES" .IX Header "EXAMPLES" Generate a \s-1CA\s0 certificate file with descriptive text from the \s-1CA\s0 certificates ca1.pem ca2.pem ca3.pem: .PP .Vb 5 \& #!/bin/sh \& rm CAfile.pem \& for i in ca1.pem ca2.pem ca3.pem ; do \& openssl x509 \-in $i \-text >> CAfile.pem \& done .Ve .PP Prepare the directory /some/where/certs containing several \s-1CA\s0 certificates for use as \fBCApath\fR: .PP .Vb 10 \& cd /some/where/certs \& rm \-f *.[0\-9]* *.r[0\-9]* \& for c in *.pem; do \& [ "$c" = "*.pem" ] && continue \& hash=$(openssl x509 \-noout \-hash \-in "$c") \& if egrep \-q \-\- \*(Aq\-BEGIN( X509 | TRUSTED | )CERTIFICATE\-\*(Aq "$c"; then \& suf=0 \& while [ \-e $hash.$suf ]; do suf=$(( $suf + 1 )); done \& ln \-s "$c" $hash.$suf \& fi \& if egrep \-q \-\- \*(Aq\-BEGIN X509 CRL\-\*(Aq "$c"; then \& suf=0 \& while [ \-e $hash.r$suf ]; do suf=$(( $suf + 1 )); done \& ln \-s "$c" $hash.r$suf \& fi \& done .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" The operation failed because \fBCAfile\fR and \fBCApath\fR are \s-1NULL\s0 or the processing at one of the locations specified failed. Check the error stack to find out the reason. .ie n .IP "1" 4 .el .IP "\f(CW1\fR" 4 .IX Item "1" The operation succeeded. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \&\fISSL_CTX_set_client_CA_list\fR\|(3), \&\fISSL_get_client_CA_list\fR\|(3), \&\fISSL_CTX_use_certificate\fR\|(3), \&\fISSL_CTX_add_extra_chain_cert\fR\|(3), \&\fISSL_CTX_set_cert_store\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_get_default_timeout.30000644000175000017500000001201112360020735022342 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_get_default_timeout 3" .TH SSL_get_default_timeout 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_get_default_timeout \- get default session timeout value .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& long SSL_get_default_timeout(const SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_get_default_timeout()\fR returns the default timeout value assigned to \&\s-1SSL_SESSION\s0 objects negotiated for the protocol valid for \fBssl\fR. .SH "NOTES" .IX Header "NOTES" Whenever a new session is negotiated, it is assigned a timeout value, after which it will not be accepted for session reuse. If the timeout value was not explicitly set using \&\fISSL_CTX_set_timeout\fR\|(3), the hardcoded default timeout for the protocol will be used. .PP \&\fISSL_get_default_timeout()\fR return this hardcoded value, which is 300 seconds for all currently supported protocols (SSLv2, SSLv3, and TLSv1). .SH "RETURN VALUES" .IX Header "RETURN VALUES" See description. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \&\fISSL_CTX_set_session_cache_mode\fR\|(3), \&\fISSL_SESSION_get_time\fR\|(3), \&\fISSL_CTX_flush_sessions\fR\|(3), \&\fISSL_get_default_timeout\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_use_certificate.30000644000175000017500000003157712360020734022206 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_use_certificate 3" .TH SSL_CTX_use_certificate 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_use_certificate, SSL_CTX_use_certificate_ASN1, SSL_CTX_use_certificate_file, SSL_use_certificate, SSL_use_certificate_ASN1, SSL_use_certificate_file, SSL_CTX_use_certificate_chain_file, SSL_CTX_use_PrivateKey, SSL_CTX_use_PrivateKey_ASN1, SSL_CTX_use_PrivateKey_file, SSL_CTX_use_RSAPrivateKey, SSL_CTX_use_RSAPrivateKey_ASN1, SSL_CTX_use_RSAPrivateKey_file, SSL_use_PrivateKey_file, SSL_use_PrivateKey_ASN1, SSL_use_PrivateKey, SSL_use_RSAPrivateKey, SSL_use_RSAPrivateKey_ASN1, SSL_use_RSAPrivateKey_file, SSL_CTX_check_private_key, SSL_check_private_key \- load certificate and key data .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x); \& int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, unsigned char *d); \& int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type); \& int SSL_use_certificate(SSL *ssl, X509 *x); \& int SSL_use_certificate_ASN1(SSL *ssl, unsigned char *d, int len); \& int SSL_use_certificate_file(SSL *ssl, const char *file, int type); \& \& int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); \& \& int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey); \& int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx, unsigned char *d, \& long len); \& int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type); \& int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); \& int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len); \& int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type); \& int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); \& int SSL_use_PrivateKey_ASN1(int pk,SSL *ssl, unsigned char *d, long len); \& int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type); \& int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); \& int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len); \& int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type); \& \& int SSL_CTX_check_private_key(const SSL_CTX *ctx); \& int SSL_check_private_key(const SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions load the certificates and private keys into the \s-1SSL_CTX\s0 or \s-1SSL\s0 object, respectively. .PP The SSL_CTX_* class of functions loads the certificates and keys into the \&\s-1SSL_CTX\s0 object \fBctx\fR. The information is passed to \s-1SSL\s0 objects \fBssl\fR created from \fBctx\fR with \fISSL_new\fR\|(3) by copying, so that changes applied to \fBctx\fR do not propagate to already existing \s-1SSL\s0 objects. .PP The SSL_* class of functions only loads certificates and keys into a specific \s-1SSL\s0 object. The specific information is kept, when \&\fISSL_clear\fR\|(3) is called for this \s-1SSL\s0 object. .PP \&\fISSL_CTX_use_certificate()\fR loads the certificate \fBx\fR into \fBctx\fR, \&\fISSL_use_certificate()\fR loads \fBx\fR into \fBssl\fR. The rest of the certificates needed to form the complete certificate chain can be specified using the \&\fISSL_CTX_add_extra_chain_cert\fR\|(3) function. .PP \&\fISSL_CTX_use_certificate_ASN1()\fR loads the \s-1ASN1\s0 encoded certificate from the memory location \fBd\fR (with length \fBlen\fR) into \fBctx\fR, \&\fISSL_use_certificate_ASN1()\fR loads the \s-1ASN1\s0 encoded certificate into \fBssl\fR. .PP \&\fISSL_CTX_use_certificate_file()\fR loads the first certificate stored in \fBfile\fR into \fBctx\fR. The formatting \fBtype\fR of the certificate must be specified from the known types \s-1SSL_FILETYPE_PEM, SSL_FILETYPE_ASN1.\s0 \&\fISSL_use_certificate_file()\fR loads the certificate from \fBfile\fR into \fBssl\fR. See the \s-1NOTES\s0 section on why \fISSL_CTX_use_certificate_chain_file()\fR should be preferred. .PP \&\fISSL_CTX_use_certificate_chain_file()\fR loads a certificate chain from \&\fBfile\fR into \fBctx\fR. The certificates must be in \s-1PEM\s0 format and must be sorted starting with the subject's certificate (actual client or server certificate), followed by intermediate \s-1CA\s0 certificates if applicable, and ending at the highest level (root) \s-1CA.\s0 There is no corresponding function working on a single \s-1SSL\s0 object. .PP \&\fISSL_CTX_use_PrivateKey()\fR adds \fBpkey\fR as private key to \fBctx\fR. \&\fISSL_CTX_use_RSAPrivateKey()\fR adds the private key \fBrsa\fR of type \s-1RSA\s0 to \fBctx\fR. \fISSL_use_PrivateKey()\fR adds \fBpkey\fR as private key to \fBssl\fR; \&\fISSL_use_RSAPrivateKey()\fR adds \fBrsa\fR as private key of type \s-1RSA\s0 to \fBssl\fR. If a certificate has already been set and the private does not belong to the certificate an error is returned. To change a certificate, private key pair the new certificate needs to be set with \fISSL_use_certificate()\fR or \fISSL_CTX_use_certificate()\fR before setting the private key with \&\fISSL_CTX_use_PrivateKey()\fR or \fISSL_use_PrivateKey()\fR. .PP \&\fISSL_CTX_use_PrivateKey_ASN1()\fR adds the private key of type \fBpk\fR stored at memory location \fBd\fR (length \fBlen\fR) to \fBctx\fR. \&\fISSL_CTX_use_RSAPrivateKey_ASN1()\fR adds the private key of type \s-1RSA\s0 stored at memory location \fBd\fR (length \fBlen\fR) to \fBctx\fR. \&\fISSL_use_PrivateKey_ASN1()\fR and \fISSL_use_RSAPrivateKey_ASN1()\fR add the private key to \fBssl\fR. .PP \&\fISSL_CTX_use_PrivateKey_file()\fR adds the first private key found in \&\fBfile\fR to \fBctx\fR. The formatting \fBtype\fR of the certificate must be specified from the known types \s-1SSL_FILETYPE_PEM, SSL_FILETYPE_ASN1.\s0 \&\fISSL_CTX_use_RSAPrivateKey_file()\fR adds the first private \s-1RSA\s0 key found in \&\fBfile\fR to \fBctx\fR. \fISSL_use_PrivateKey_file()\fR adds the first private key found in \fBfile\fR to \fBssl\fR; \fISSL_use_RSAPrivateKey_file()\fR adds the first private \&\s-1RSA\s0 key found to \fBssl\fR. .PP \&\fISSL_CTX_check_private_key()\fR checks the consistency of a private key with the corresponding certificate loaded into \fBctx\fR. If more than one key/certificate pair (\s-1RSA/DSA\s0) is installed, the last item installed will be checked. If e.g. the last item was a \s-1RSA\s0 certificate or key, the \s-1RSA\s0 key/certificate pair will be checked. \fISSL_check_private_key()\fR performs the same check for \fBssl\fR. If no key/certificate was explicitly added for this \fBssl\fR, the last item added into \fBctx\fR will be checked. .SH "NOTES" .IX Header "NOTES" The internal certificate store of OpenSSL can hold two private key/certificate pairs at a time: one key/certificate of type \s-1RSA\s0 and one key/certificate of type \s-1DSA.\s0 The certificate used depends on the cipher select, see also \fISSL_CTX_set_cipher_list\fR\|(3). .PP When reading certificates and private keys from file, files of type \&\s-1SSL_FILETYPE_ASN1 \s0(also known as \fB\s-1DER\s0\fR, binary encoding) can only contain one certificate or private key, consequently \&\fISSL_CTX_use_certificate_chain_file()\fR is only applicable to \s-1PEM\s0 formatting. Files of type \s-1SSL_FILETYPE_PEM\s0 can contain more than one item. .PP \&\fISSL_CTX_use_certificate_chain_file()\fR adds the first certificate found in the file to the certificate store. The other certificates are added to the store of chain certificates using \&\fISSL_CTX_add_extra_chain_cert\fR\|(3). There exists only one extra chain store, so that the same chain is appended to both types of certificates, \s-1RSA\s0 and \s-1DSA\s0! If it is not intended to use both type of certificate at the same time, it is recommended to use the \&\fISSL_CTX_use_certificate_chain_file()\fR instead of the \&\fISSL_CTX_use_certificate_file()\fR function in order to allow the use of complete certificate chains even when no trusted \s-1CA\s0 storage is used or when the \s-1CA\s0 issuing the certificate shall not be added to the trusted \&\s-1CA\s0 storage. .PP If additional certificates are needed to complete the chain during the \&\s-1TLS\s0 negotiation, \s-1CA\s0 certificates are additionally looked up in the locations of trusted \s-1CA\s0 certificates, see \&\fISSL_CTX_load_verify_locations\fR\|(3). .PP The private keys loaded from file can be encrypted. In order to successfully load encrypted keys, a function returning the passphrase must have been supplied, see \&\fISSL_CTX_set_default_passwd_cb\fR\|(3). (Certificate files might be encrypted as well from the technical point of view, it however does not make sense as the data in the certificate is considered public anyway.) .SH "RETURN VALUES" .IX Header "RETURN VALUES" On success, the functions return 1. Otherwise check out the error stack to find out the reason. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_new\fR\|(3), \fISSL_clear\fR\|(3), \&\fISSL_CTX_load_verify_locations\fR\|(3), \&\fISSL_CTX_set_default_passwd_cb\fR\|(3), \&\fISSL_CTX_set_cipher_list\fR\|(3), \&\fISSL_CTX_set_client_cert_cb\fR\|(3), \&\fISSL_CTX_add_extra_chain_cert\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" Support for \s-1DER\s0 encoded private keys (\s-1SSL_FILETYPE_ASN1\s0) in \&\fISSL_CTX_use_PrivateKey_file()\fR and \fISSL_use_PrivateKey_file()\fR was added in 0.9.8 . deps/libressl-pnacl-sys-2.1.6/libressl/man/CMS_get0_type.30000644000175000017500000001377512360020713020210 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CMS_get0_type 3" .TH CMS_get0_type 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CMS_get0_type, CMS_set1_eContentType, CMS_get0_eContentType \- get and set CMS content types .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& const ASN1_OBJECT *CMS_get0_type(CMS_ContentInfo *cms); \& int CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid); \& const ASN1_OBJECT *CMS_get0_eContentType(CMS_ContentInfo *cms); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fICMS_get0_type()\fR returns the content type of a CMS_ContentInfo structure as and \s-1ASN1_OBJECT\s0 pointer. An application can then decide how to process the CMS_ContentInfo structure based on this value. .PP \&\fICMS_set1_eContentType()\fR sets the embedded content type of a CMS_ContentInfo structure. It should be called with \s-1CMS\s0 functions with the \fB\s-1CMS_PARTIAL\s0\fR flag and \fBbefore\fR the structure is finalised, otherwise the results are undefined. .PP \&\s-1ASN1_OBJECT\s0 *\fICMS_get0_eContentType()\fR returns a pointer to the embedded content type. .SH "NOTES" .IX Header "NOTES" As the \fB0\fR implies \fICMS_get0_type()\fR and \fICMS_get0_eContentType()\fR return internal pointers which should \fBnot\fR be freed up. \fICMS_set1_eContentType()\fR copies the supplied \s-1OID\s0 and it \fBshould\fR be freed up after use. .PP The \fB\s-1ASN1_OBJECT\s0\fR values returned can be converted to an integer \fB\s-1NID\s0\fR value using \fIOBJ_obj2nid()\fR. For the currently supported content types the following values are returned: .PP .Vb 6 \& NID_pkcs7_data \& NID_pkcs7_signed \& NID_pkcs7_digest \& NID_id_smime_ct_compressedData: \& NID_pkcs7_encrypted \& NID_pkcs7_enveloped .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fICMS_get0_type()\fR and \fICMS_get0_eContentType()\fR return and \s-1ASN1_OBJECT\s0 structure. .PP \&\fICMS_set1_eContentType()\fR returns 1 for success or 0 if an error occurred. The error can be obtained from \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fICMS_get0_type()\fR, \fICMS_set1_eContentType()\fR and \fICMS_get0_eContentType()\fR were all first added to OpenSSL 0.9.8 deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_clear.30000644000175000017500000001467112360020734017414 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_clear 3" .TH SSL_clear 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_clear \- reset SSL object to allow another connection .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_clear(SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Reset \fBssl\fR to allow another connection. All settings (method, ciphers, BIOs) are kept. .SH "NOTES" .IX Header "NOTES" SSL_clear is used to prepare an \s-1SSL\s0 object for a new connection. While all settings are kept, a side effect is the handling of the current \s-1SSL\s0 session. If a session is still \fBopen\fR, it is considered bad and will be removed from the session cache, as required by \s-1RFC2246. A\s0 session is considered open, if \fISSL_shutdown\fR\|(3) was not called for the connection or at least \fISSL_set_shutdown\fR\|(3) was used to set the \s-1SSL_SENT_SHUTDOWN\s0 state. .PP If a session was closed cleanly, the session object will be kept and all settings corresponding. This explicitly means, that e.g. the special method used during the session will be kept for the next handshake. So if the session was a TLSv1 session, a \s-1SSL\s0 client object will use a TLSv1 client method for the next handshake and a \s-1SSL\s0 server object will use a TLSv1 server method, even if SSLv23_*_methods were chosen on startup. This will might lead to connection failures (see \fISSL_new\fR\|(3)) for a description of the method's properties. .SH "WARNINGS" .IX Header "WARNINGS" \&\fISSL_clear()\fR resets the \s-1SSL\s0 object to allow for another connection. The reset operation however keeps several settings of the last sessions (some of these settings were made automatically during the last handshake). It only makes sense for a new connection with the exact same peer that shares these settings, and may fail if that peer changes its settings between connections. Use the sequence \&\fISSL_get_session\fR\|(3); \&\fISSL_new\fR\|(3); \&\fISSL_set_session\fR\|(3); \&\fISSL_free\fR\|(3) instead to avoid such failures (or simply \fISSL_free\fR\|(3); \fISSL_new\fR\|(3) if session reuse is not desired). .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" The \fISSL_clear()\fR operation could not be performed. Check the error stack to find out the reason. .ie n .IP "1" 4 .el .IP "\f(CW1\fR" 4 .IX Item "1" The \fISSL_clear()\fR operation was successful. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_new\fR\|(3), \fISSL_free\fR\|(3), \&\fISSL_shutdown\fR\|(3), \fISSL_set_shutdown\fR\|(3), \&\fISSL_CTX_set_options\fR\|(3), \fIssl\fR\|(3), \&\fISSL_CTX_set_client_cert_cb\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/DH_generate_key.30000644000175000017500000001274512360020714020620 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DH_generate_key 3" .TH DH_generate_key 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DH_generate_key, DH_compute_key \- perform Diffie\-Hellman key exchange .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int DH_generate_key(DH *dh); \& \& int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIDH_generate_key()\fR performs the first step of a Diffie-Hellman key exchange by generating private and public \s-1DH\s0 values. By calling \&\fIDH_compute_key()\fR, these are combined with the other party's public value to compute the shared key. .PP \&\fIDH_generate_key()\fR expects \fBdh\fR to contain the shared parameters \&\fBdh\->p\fR and \fBdh\->g\fR. It generates a random private \s-1DH\s0 value unless \fBdh\->priv_key\fR is already set, and computes the corresponding public value \fBdh\->pub_key\fR, which can then be published. .PP \&\fIDH_compute_key()\fR computes the shared secret from the private \s-1DH\s0 value in \fBdh\fR and the other party's public value in \fBpub_key\fR and stores it in \fBkey\fR. \fBkey\fR must point to \fBDH_size(dh)\fR bytes of memory. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIDH_generate_key()\fR returns 1 on success, 0 otherwise. .PP \&\fIDH_compute_key()\fR returns the size of the shared secret on success, \-1 on error. .PP The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdh\fR\|(3), \fIERR_get_error\fR\|(3), \fIrand\fR\|(3), \&\fIDH_size\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIDH_generate_key()\fR and \fIDH_compute_key()\fR are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/openssl.10000644000175000017500000107063212360020744017267 0ustar .\" $OpenBSD: openssl.1,v 1.96 2014/06/02 17:06:28 jsing Exp $ .\" ==================================================================== .\" Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" .\" 2. 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. .\" .\" 3. All advertising materials mentioning features or use of this .\" software must display the following acknowledgment: .\" "This product includes software developed by the OpenSSL Project .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" .\" .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to .\" endorse or promote products derived from this software without .\" prior written permission. For written permission, please contact .\" openssl-core@openssl.org. .\" .\" 5. Products derived from this software may not be called "OpenSSL" .\" nor may "OpenSSL" appear in their names without prior written .\" permission of the OpenSSL Project. .\" .\" 6. Redistributions of any form whatsoever must retain the following .\" acknowledgment: .\" "This product includes software developed by the OpenSSL Project .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" .\" .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY .\" EXPRESSED 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 THE OpenSSL PROJECT OR .\" ITS CONTRIBUTORS 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. .\" ==================================================================== .\" .\" This product includes cryptographic software written by Eric Young .\" (eay@cryptsoft.com). This product includes software written by Tim .\" Hudson (tjh@cryptsoft.com). .\" .\" .\" Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) .\" All rights reserved. .\" .\" This package is an SSL implementation written .\" by Eric Young (eay@cryptsoft.com). .\" The implementation was written so as to conform with Netscapes SSL. .\" .\" This library is free for commercial and non-commercial use as long as .\" the following conditions are aheared to. The following conditions .\" apply to all code found in this distribution, be it the RC4, RSA, .\" lhash, DES, etc., code; not just the SSL code. The SSL documentation .\" included with this distribution is covered by the same copyright terms .\" except that the holder is Tim Hudson (tjh@cryptsoft.com). .\" .\" Copyright remains Eric Young's, and as such any Copyright notices in .\" the code are not to be removed. .\" If this package is used in a product, Eric Young should be given attribution .\" as the author of the parts of the library used. .\" This can be in the form of a textual message at program startup or .\" in documentation (online or textual) provided with the package. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. 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. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" "This product includes cryptographic software written by .\" Eric Young (eay@cryptsoft.com)" .\" The word 'cryptographic' can be left out if the rouines from the library .\" being used are not cryptographic related :-). .\" 4. If you include any Windows specific code (or a derivative thereof) from .\" the apps directory (application code) you must include an .\" acknowledgement: .\" "This product includes software written by Tim Hudson .\" (tjh@cryptsoft.com)" .\" .\" THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. .\" .\" The licence and distribution terms for any publically available version or .\" derivative of this code cannot be changed. i.e. this code cannot simply be .\" copied and put under another distribution licence .\" [including the GNU Public Licence.] .\" .\" OPENSSL .\" .Dd $Mdocdate: June 2 2014 $ .Dt OPENSSL 1 .Os .Sh NAME .Nm openssl .Nd OpenSSL command line tool .Sh SYNOPSIS .Nm .Cm command .Op Ar command_opts .Op Ar command_args .Pp .Nm .Cm list-standard-commands \*(Ba .Cm list-message-digest-commands \*(Ba .Cm list-cipher-commands \*(Ba .Cm list-cipher-algorithms \*(Ba .Cm list-message-digest-algorithms \*(Ba .Cm list-public-key-algorithms .Pp .Nm .Cm no- Ns Ar XXX .Op Ar arbitrary options .Sh DESCRIPTION .Nm OpenSSL is a cryptography toolkit implementing the Secure Sockets Layer .Pq SSL v3 and Transport Layer Security .Pq TLS v1 network protocols and related cryptography standards required by them. .Pp The .Nm program is a command line tool for using the various cryptography functions of .Nm OpenSSL Ns Li 's .Em crypto library from the shell. It can be used for .Pp .Bl -bullet -offset indent -compact .It Creation and management of private keys, public keys, and parameters .It Public key cryptographic operations .It Creation of X.509 certificates, CSRs and CRLs .It Calculation of Message Digests .It Encryption and Decryption with Ciphers .It SSL/TLS Client and Server Tests .It Handling of S/MIME signed or encrypted mail .It Time stamp requests, generation, and verification .El .Sh COMMAND SUMMARY The .Nm program provides a rich variety of commands .Pf ( Cm command in the .Sx SYNOPSIS above), each of which often has a wealth of options and arguments .Pf ( Ar command_opts and .Ar command_args in the .Sx SYNOPSIS ) . .Pp The pseudo-commands .Cm list-standard-commands , list-message-digest-commands , and .Cm list-cipher-commands output a list .Pq one entry per line of the names of all standard commands, message digest commands, or cipher commands, respectively, that are available in the present .Nm utility. .Pp The pseudo-commands .Cm list-cipher-algorithms and .Cm list-message-digest-algorithms list all cipher and message digest names, one entry per line. Aliases are listed as: .Pp .D1 from =\*(Gt to .Pp The pseudo-command .Cm list-public-key-algorithms lists all supported public key algorithms. .Pp The pseudo-command .Cm no- Ns Ar XXX tests whether a command of the specified name is available. If no command named .Ar XXX exists, it returns 0 .Pq success and prints .Cm no- Ns Ar XXX ; otherwise it returns 1 and prints .Ar XXX . In both cases, the output goes to .Em stdout and nothing is printed to .Em stderr . Additional command line arguments are always ignored. Since for each cipher there is a command of the same name, this provides an easy way for shell scripts to test for the availability of ciphers in the .Nm program. .Pp .Sy Note : .Cm no- Ns Ar XXX is not able to detect pseudo-commands such as .Cm quit , .Cm list- Ns Ar ... Ns Cm -commands , or .Cm no- Ns Ar XXX itself. .Sh STANDARD COMMANDS .Bl -tag -width "asn1parse" .It Cm asn1parse Parse an ASN.1 sequence. .It Cm ca Certificate Authority .Pq CA management. .It Cm ciphers Cipher suite description determination. .It Cm crl Certificate Revocation List .Pq CRL management. .It Cm crl2pkcs7 CRL to PKCS#7 conversion. .It Cm dgst Message digest calculation. .It Cm dh Diffie-Hellman parameter management. Obsoleted by .Cm dhparam . .It Cm dhparam Generation and management of Diffie-Hellman parameters. Superseded by .Cm genpkey and .Cm pkeyparam . .It Cm dsa DSA data management. .It Cm dsaparam DSA parameter generation and management. Superseded by .Cm genpkey and .Cm pkeyparam . .It Cm ec Elliptic curve (EC) key processing. .It Cm ecparam EC parameter manipulation and generation. .It Cm enc Encoding with ciphers. .It Cm engine Engine (loadable module) information and manipulation. .It Cm errstr Error number to error string conversion. .It Cm gendh Generation of Diffie-Hellman parameters. Obsoleted by .Cm dhparam . .It Cm gendsa Generation of DSA private key from parameters. Superseded by .Cm genpkey and .Cm pkey . .It Cm genpkey Generation of private keys or parameters. .It Cm genrsa Generation of RSA private key. Superseded by .Cm genpkey . .It Cm nseq Create or examine a Netscape certificate sequence. .It Cm ocsp Online Certificate Status Protocol utility. .It Cm passwd Generation of hashed passwords. .It Cm pkcs7 PKCS#7 data management. .It Cm pkcs8 PKCS#8 data management. .It Cm pkcs12 PKCS#12 data management. .It Cm pkey Public and private key management. .It Cm pkeyparam Public key algorithm parameter management. .It Cm pkeyutl Public key algorithm cryptographic operation utility. .It Cm prime Generate prime numbers or test numbers for primality. .It Cm rand Generate pseudo-random bytes. .It Cm req PKCS#10 X.509 Certificate Signing Request .Pq CSR management. .It Cm rsa RSA key management. .It Cm rsautl RSA utility for signing, verification, encryption, and decryption. Superseded by .Cm pkeyutl . .It Cm s_client This implements a generic SSL/TLS client which can establish a transparent connection to a remote server speaking SSL/TLS. It's intended for testing purposes only and provides only rudimentary interface functionality but internally uses mostly all functionality of the .Nm OpenSSL .Em ssl library. .It Cm s_server This implements a generic SSL/TLS server which accepts connections from remote clients speaking SSL/TLS. It's intended for testing purposes only and provides only rudimentary interface functionality but internally uses mostly all functionality of the .Nm OpenSSL .Em ssl library. It provides both an own command line oriented protocol for testing SSL functions and a simple HTTP response facility to emulate an SSL/TLS-aware webserver. .It Cm s_time SSL connection timer. .It Cm sess_id SSL session data management. .It Cm smime S/MIME mail processing. .It Cm speed Algorithm speed measurement. .It Cm spkac SPKAC printing and generating utility. .It Cm ts Time stamping authority tool (client/server). .It Cm verify X.509 certificate verification. .It Cm version .Nm OpenSSL version information. .It Cm x509 X.509 certificate data management. .El .Sh MESSAGE DIGEST COMMANDS .Bl -tag -width "asn1parse" .It Cm md2 MD2 digest. .It Cm md4 MD4 digest. .It Cm md5 MD5 digest. .It Cm ripemd160 RIPEMD-160 digest. .It Cm sha SHA digest. .It Cm sha1 SHA-1 digest. .El .Sh ENCODING AND CIPHER COMMANDS .Bl -tag -width Ds -compact .It Cm aes-128-cbc | aes-128-ecb | aes-192-cbc | aes-192-ecb .It Cm aes-256-cbc | aes-256-ecb AES cipher. .Pp .It Cm base64 Base64 encoding. .Pp .It Xo .Cm bf | bf-cbc | bf-cfb | .Cm bf-ecb | bf-ofb .Xc Blowfish cipher. .Pp .It Cm cast | cast-cbc CAST cipher. .Pp .It Cm cast5-cbc | cast5-cfb | cast5-ecb | cast5-ofb CAST5 cipher. .Pp .It Xo .Cm des | des-cbc | des-cfb | des-ecb | .Cm des-ede | des-ede-cbc .Xc .It Cm des-ede-cfb | des-ede-ofb | des-ofb DES cipher. .Pp .It Xo .Cm des3 | desx | des-ede3 | .Cm des-ede3-cbc | des-ede3-cfb | des-ede3-ofb .Xc Triple DES cipher. .Pp .It Xo .Cm rc2 | rc2-40-cbc | rc2-64-cbc | rc2-cbc | .Cm rc2-cfb | rc2-ecb | rc2-ofb .Xc RC2 cipher. .Pp .It Cm rc4 | rc4-40 RC4 cipher. .El .Sh PASS PHRASE ARGUMENTS Several commands accept password arguments, typically using .Fl passin and .Fl passout for input and output passwords, respectively. These allow the password to be obtained from a variety of sources. Both of these options take a single argument whose format is described below. If no password argument is given and a password is required, then the user is prompted to enter one: this will typically be read from the current terminal with echoing turned off. .Bl -tag -width "fd:number" .It Ar pass : Ns Ar password The actual password is .Ar password . Since the password is visible to utilities (like .Xr ps 1 under .Ux ) this form should only be used where security is not important. .It Ar env : Ns Ar var Obtain the password from the environment variable .Ar var . Since the environment of other processes is visible on certain platforms (e.g.\& .Xr ps 1 under certain .Ux OSes) this option should be used with caution. .It Ar file : Ns Ar path The first line of .Ar path is the password. If the same .Ar path argument is supplied to .Fl passin and .Fl passout , then the first line will be used for the input password and the next line for the output password. .Ar path need not refer to a regular file: it could, for example, refer to a device or named pipe. .It Ar fd : Ns Ar number Read the password from the file descriptor .Ar number . This can be used to send the data via a pipe for example. .It Ar stdin Read the password from standard input. .El .\" .\" ASN1PARSE .\" .Sh ASN1PARSE .nr nS 1 .Nm "openssl asn1parse" .Bk -words .Op Fl i .Op Fl dlimit Ar number .Op Fl dump .Op Fl genconf Ar file .Op Fl genstr Ar str .Op Fl in Ar file .Op Fl inform Ar DER | PEM | TXT .Op Fl length Ar number .Op Fl noout .Op Fl offset Ar number .Op Fl oid Ar file .Op Fl out Ar file .Op Fl strparse Ar offset .Ek .nr nS 0 .Pp The .Nm asn1parse command is a diagnostic utility that can parse ASN.1 structures. It can also be used to extract data from ASN.1 formatted data. .Pp The options are as follows: .Bl -tag -width Ds .It Fl dlimit Ar number Dump the first .Ar number bytes of unknown data in hex form. .It Fl dump Dump unknown data in hex form. .It Fl genconf Ar file , Fl genstr Ar str Generate encoded data based on string .Ar str , file .Ar file , or both using .Xr ASN1_generate_nconf 3 format. If only .Ar file is present then the string is obtained from the default section using the name .Dq asn1 . The encoded data is passed through the ASN1 parser and printed out as though it came from a file; the contents can thus be examined and written to a file using the .Fl out option. .It Fl i Indents the output according to the .Qq depth of the structures. .It Fl in Ar file The input file; default is standard input. .It Fl inform Ar DER | PEM | TXT The input format. .Ar DER .Pq Distinguished Encoding Rules is binary format and .Ar PEM .Pq Privacy Enhanced Mail , the default, is base64-encoded. .Ar TXT is plain text. .It Fl length Ar number Number of bytes to parse; default is until end of file. .It Fl noout Don't output the parsed version of the input file. .It Fl offset Ar number Starting offset to begin parsing; default is start of file. .It Fl oid Ar file A file containing additional object identifiers .Pq OIDs . The format of this file is described in the .Sx ASN1PARSE NOTES section below. .It Fl out Ar file Output file to place the DER-encoded data into. If this option is not present, no encoded data will be output. This is most useful when combined with the .Fl strparse option. .It Fl strparse Ar offset Parse the content octets of the ASN.1 object starting at .Ar offset . This option can be used multiple times to .Qq drill down into a nested structure. .El .Sh ASN1PARSE OUTPUT The output will typically contain lines like this: .Bd -literal -offset 2n 0:d=0 hl=4 l= 681 cons: SEQUENCE \&..... 229:d=3 hl=3 l= 141 prim: BIT STRING 373:d=2 hl=3 l= 162 cons: cont [ 3 ] 376:d=3 hl=3 l= 159 cons: SEQUENCE 379:d=4 hl=2 l= 29 cons: SEQUENCE 381:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Subject Key Identifier 386:d=5 hl=2 l= 22 prim: OCTET STRING 410:d=4 hl=2 l= 112 cons: SEQUENCE 412:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Authority Key Identifier 417:d=5 hl=2 l= 105 prim: OCTET STRING 524:d=4 hl=2 l= 12 cons: SEQUENCE \&..... .Ed .Pp This example is part of a self-signed certificate. Each line starts with the offset in decimal. .Cm d=XX specifies the current depth. The depth is increased within the scope of any SET or SEQUENCE. .Cm hl=XX gives the header length .Pq tag and length octets of the current type. .Cm l=XX gives the length of the content octets. .Pp The .Fl i option can be used to make the output more readable. .Pp Some knowledge of the ASN.1 structure is needed to interpret the output. .Pp In this example, the BIT STRING at offset 229 is the certificate public key. The content octets of this will contain the public key information. This can be examined using the option .Fl strparse Cm 229 to yield: .Bd -literal 0:d=0 hl=3 l= 137 cons: SEQUENCE 3:d=1 hl=3 l= 129 prim: INTEGER :E5D21E1F5C8D208EA7A2166C7FA F9F6BDF2059669C60876DDB70840F1A5AAFA59699FE471F379F1DD6A487E7D5409AB6A88D4A 9746E24B91D8CF55DB3521015460C8EDE44EE8A4189F7A7BE77D6CD3A9AF2696F486855CF58 BF0EDF2B4068058C7A947F52548DDF7E15E96B385F86422BEA9064A3EE9 135:d=1 hl=2 l= 3 prim: INTEGER :010001 .Ed .Sh ASN1PARSE NOTES If an OID .Pq object identifier is not part of .Nm OpenSSL Ns Li 's internal table it will be represented in numerical form .Pq for example 1.2.3.4 . The file passed to the .Fl oid option allows additional OIDs to be included. Each line consists of three columns: the first column is the OID in numerical format and should be followed by whitespace. The second column is the .Qq short name which is a single word followed by whitespace. The final column is the rest of the line and is the .Qq long name . .Nm asn1parse displays the long name. Example: .Pp .Dl \&"1.2.3.4 shortname A long name\&" .Sh ASN1 EXAMPLES Parse a file: .Pp .Dl $ openssl asn1parse -in file.pem .Pp Parse a DER file: .Pp .Dl $ openssl asn1parse -inform DER -in file.der .Sh ASN1PARSE BUGS There should be options to change the format of output lines. The output of some ASN.1 types is not well handled .Pq if at all . .\" .\" CA .\" .Sh CA .nr nS 1 .Nm "openssl ca" .Bk -words .Op Fl batch .Op Fl cert Ar file .Op Fl config Ar file .Op Fl crl_CA_compromise Ar time .Op Fl crl_compromise Ar time .Op Fl crl_hold Ar instruction .Op Fl crl_reason Ar reason .Op Fl crldays Ar days .Op Fl crlexts Ar section .Op Fl crlhours Ar hours .Op Fl days Ar arg .Op Fl enddate Ar date .Op Fl engine Ar id .Op Fl extensions Ar section .Op Fl extfile Ar section .Op Fl gencrl .Op Fl in Ar file .Op Fl infiles .Op Fl key Ar keyfile .Op Fl keyfile Ar arg .Op Fl keyform Ar ENGINE | PEM .Op Fl md Ar arg .Op Fl msie_hack .Op Fl name Ar section .Op Fl noemailDN .Op Fl notext .Op Fl out Ar file .Op Fl outdir Ar dir .Op Fl passin Ar arg .Op Fl policy Ar arg .Op Fl preserveDN .Op Fl revoke Ar file .Op Fl spkac Ar file .Op Fl ss_cert Ar file .Op Fl startdate Ar date .Op Fl status Ar serial .Op Fl subj Ar arg .Op Fl updatedb .Op Fl verbose .Ek .nr nS 0 .Pp The .Nm ca command is a minimal CA application. It can be used to sign certificate requests in a variety of forms and generate CRLs. It also maintains a text database of issued certificates and their status. .Pp The options descriptions will be divided into each purpose. .Sh CA OPTIONS .Bl -tag -width "XXXX" .It Fl batch This sets the batch mode. In this mode no questions will be asked and all certificates will be certified automatically. .It Fl cert Ar file The CA certificate file. .It Fl config Ar file Specifies the configuration file to use. .It Fl days Ar arg The number of days to certify the certificate for. .It Fl enddate Ar date This allows the expiry date to be explicitly set. The format of the date is YYMMDDHHMMSSZ .Pq the same as an ASN1 UTCTime structure . .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm ca to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl extensions Ar section The section of the configuration file containing certificate extensions to be added when a certificate is issued (defaults to .Em x509_extensions unless the .Fl extfile option is used). If no extension section is present, a V1 certificate is created. If the extension section is present .Pq even if it is empty , then a V3 certificate is created. .It Fl extfile Ar file An additional configuration .Ar file to read certificate extensions from (using the default section unless the .Fl extensions option is also used). .It Fl in Ar file An input .Ar file containing a single certificate request to be signed by the CA. .It Fl infiles If present, this should be the last option; all subsequent arguments are assumed to be the names of files containing certificate requests. .It Fl key Ar keyfile The password used to encrypt the private key. Since on some systems the command line arguments are visible (e.g.\& .Ux with the .Xr ps 1 utility) this option should be used with caution. .It Fl keyfile Ar file The private key to sign requests with. .It Fl keyform Ar ENGINE | PEM Private key file format. .It Fl md Ar alg The message digest to use. Possible values include .Ar md5 and .Ar sha1 . This option also applies to CRLs. .It Fl msie_hack This is a legacy option to make .Nm ca work with very old versions of the IE certificate enrollment control .Qq certenr3 . It used UniversalStrings for almost everything. Since the old control has various security bugs, its use is strongly discouraged. The newer control .Qq Xenroll does not need this option. .It Fl name Ar section Specifies the configuration file .Ar section to use (overrides .Cm default_ca in the .Cm ca section). .It Fl noemailDN The DN of a certificate can contain the EMAIL field if present in the request DN, however it is good policy just having the e-mail set into the .Em altName extension of the certificate. When this option is set, the EMAIL field is removed from the certificate's subject and set only in the, eventually present, extensions. The .Ar email_in_dn keyword can be used in the configuration file to enable this behaviour. .It Fl notext Don't output the text form of a certificate to the output file. .It Fl out Ar file The output file to output certificates to. The default is standard output. The certificate details will also be printed out to this file. .It Fl outdir Ar directory The .Ar directory to output certificates to. The certificate will be written to a file consisting of the serial number in hex with .Qq .pem appended. .It Fl passin Ar arg The key password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl policy Ar arg This option defines the CA .Qq policy to use. This is a section in the configuration file which decides which fields should be mandatory or match the CA certificate. Check out the .Sx CA POLICY FORMAT section for more information. .It Fl preserveDN Normally, the DN order of a certificate is the same as the order of the fields in the relevant policy section. When this option is set, the order is the same as the request. This is largely for compatibility with the older IE enrollment control which would only accept certificates if their DNs matched the order of the request. This is not needed for Xenroll. .It Fl spkac Ar file A file containing a single Netscape signed public key and challenge, and additional field values to be signed by the CA. See the .Sx SPKAC FORMAT section for information on the required format. .It Fl ss_cert Ar file A single self-signed certificate to be signed by the CA. .It Fl startdate Ar date This allows the start date to be explicitly set. The format of the date is YYMMDDHHMMSSZ .Pq the same as an ASN1 UTCTime structure . .It Fl status Ar serial Show status of certificate with serial number .Ar serial . .It Fl updatedb Update database for expired certificates. .It Fl verbose This prints extra details about the operations being performed. .El .Sh CRL OPTIONS .Bl -tag -width "XXXX" .It Fl crl_CA_compromise Ar time This is the same as .Fl crl_compromise , except the revocation reason is set to CACompromise. .It Fl crl_compromise Ar time This sets the revocation reason to keyCompromise and the compromise time to .Ar time . .Ar time should be in GeneralizedTime format, i.e. YYYYMMDDHHMMSSZ. .It Fl crl_hold Ar instruction This sets the CRL revocation reason code to certificateHold and the hold instruction to .Ar instruction which must be an OID. Although any OID can be used, only holdInstructionNone (the use of which is discouraged by RFC 2459), holdInstructionCallIssuer or holdInstructionReject will normally be used. .It Fl crl_reason Ar reason Revocation reason, where .Ar reason is one of: unspecified, keyCompromise, CACompromise, affiliationChanged, superseded, cessationOfOperation, certificateHold or removeFromCRL. The matching of .Ar reason is case insensitive. Setting any revocation reason will make the CRL v2. In practice, removeFromCRL is not particularly useful because it is only used in delta CRLs which are not currently implemented. .It Fl crldays Ar num The number of days before the next CRL is due. This is the days from now to place in the CRL .Em nextUpdate field. .It Fl crlexts Ar section The .Ar section of the configuration file containing CRL extensions to include. If no CRL extension section is present then a V1 CRL is created; if the CRL extension section is present .Pq even if it is empty then a V2 CRL is created. The CRL extensions specified are CRL extensions and .Em not CRL entry extensions. It should be noted that some software .Pq for example Netscape can't handle V2 CRLs. .It Fl crlhours Ar num The number of hours before the next CRL is due. .It Fl gencrl This option generates a CRL based on information in the index file. .It Fl revoke Ar file A .Ar file containing a certificate to revoke. .It Fl subj Ar arg Supersedes the subject name given in the request. The .Ar arg must be formatted as .Ar /type0=value0/type1=value1/type2=... ; characters may be escaped by .Sq \e .Pq backslash , no spaces are skipped. .El .Sh CA CONFIGURATION FILE OPTIONS The section of the configuration file containing options for .Nm ca is found as follows: If the .Fl name command line option is used, then it names the section to be used. Otherwise the section to be used must be named in the .Em default_ca option of the .Em ca section of the configuration file (or in the default section of the configuration file). Besides .Em default_ca , the following options are read directly from the .Em ca section: .Pp .Bl -tag -width Ds -offset indent -compact .It preserve .It msie_hack .El .Pp This is probably a bug and may change in future releases. .Pp Many of the configuration file options are identical to command line options. Where the option is present in the configuration file and the command line, the command line value is used. Where an option is described as mandatory, then it must be present in the configuration file or the command line equivalent .Pq if any used. .Bl -tag -width "XXXX" .It Ar certificate The same as .Fl cert . It gives the file containing the CA certificate. Mandatory. .It Ar copy_extensions Determines how extensions in certificate requests should be handled. If set to .Ar none or this option is not present, then extensions are ignored and not copied to the certificate. If set to .Ar copy , then any extensions present in the request that are not already present are copied to the certificate. If set to .Ar copyall , then all extensions in the request are copied to the certificate: if the extension is already present in the certificate it is deleted first. See the .Sx CA WARNINGS section before using this option. .Pp The main use of this option is to allow a certificate request to supply values for certain extensions such as .Em subjectAltName . .It Ar crl_extensions The same as .Fl crlexts . .It Ar crlnumber A text file containing the next CRL number to use in hex. The CRL number will be inserted in the CRLs only if this file exists. If this file is present, it must contain a valid CRL number. .It Ar database The text database file to use. Mandatory. This file must be present, though initially it will be empty. .It Ar default_crl_hours , default_crl_days The same as the .Fl crlhours and .Fl crldays options. These will only be used if neither command line option is present. At least one of these must be present to generate a CRL. .It Ar default_days The same as the .Fl days option. The number of days to certify a certificate for. .It Ar default_enddate The same as the .Fl enddate option. Either this option or .Ar default_days .Pq or the command line equivalents must be present. .It Ar default_md The same as the .Fl md option. The message digest to use. Mandatory. .It Ar default_startdate The same as the .Fl startdate option. The start date to certify a certificate for. If not set, the current time is used. .It Ar email_in_dn The same as .Fl noemailDN . If the EMAIL field is to be removed from the DN of the certificate, simply set this to .Qq no . If not present, the default is to allow for the EMAIL field in the certificate's DN. .It Ar msie_hack The same as .Fl msie_hack . .It Ar name_opt , cert_opt These options allow the format used to display the certificate details when asking the user to confirm signing. All the options supported by the .Nm x509 utilities' .Fl nameopt and .Fl certopt switches can be used here, except that .Ar no_signame and .Ar no_sigdump are permanently set and cannot be disabled (this is because the certificate signature cannot be displayed because the certificate has not been signed at this point). .Pp For convenience, the value .Em ca_default is accepted by both to produce a reasonable output. .Pp If neither option is present, the format used in earlier versions of .Nm OpenSSL is used. Use of the old format is .Em strongly discouraged because it only displays fields mentioned in the .Ar policy section, mishandles multicharacter string types and does not display extensions. .It Ar new_certs_dir The same as the .Fl outdir command line option. It specifies the directory where new certificates will be placed. Mandatory. .It Ar oid_file This specifies a file containing additional object identifiers. Each line of the file should consist of the numerical form of the object identifier followed by whitespace, then the short name followed by whitespace and finally the long name. .It Ar oid_section This specifies a section in the configuration file containing extra object identifiers. Each line should consist of the short name of the object identifier followed by .Sq = and the numerical form. The short and long names are the same when this option is used. .It Ar policy The same as .Fl policy . Mandatory. See the .Sx CA POLICY FORMAT section for more information. .It Ar preserve The same as .Fl preserveDN . .It Ar private_key Same as the .Fl keyfile option. The file containing the CA private key. Mandatory. .It Ar serial A text file containing the next serial number to use in hex. Mandatory. This file must be present and contain a valid serial number. .It Ar unique_subject If the value .Ar yes is given, the valid certificate entries in the database must have unique subjects. If the value .Ar no is given, several valid certificate entries may have the exact same subject. The default value is .Ar yes . .It Ar x509_extensions The same as .Fl extensions . .El .Sh CA POLICY FORMAT The policy section consists of a set of variables corresponding to certificate DN fields. If the value is .Qq match , then the field value must match the same field in the CA certificate. If the value is .Qq supplied , then it must be present. If the value is .Qq optional , then it may be present. Any fields not mentioned in the policy section are silently deleted, unless the .Fl preserveDN option is set, but this can be regarded more of a quirk than intended behaviour. .Sh SPKAC FORMAT The input to the .Fl spkac command line option is a Netscape signed public key and challenge. This will usually come from the .Em KEYGEN tag in an HTML form to create a new private key. It is, however, possible to create SPKACs using the .Nm spkac utility. .Pp The file should contain the variable SPKAC set to the value of the SPKAC and also the required DN components as name value pairs. If it's necessary to include the same component twice, then it can be preceded by a number and a .Sq \&. . .Sh CA EXAMPLES .Sy Note : these examples assume that the .Nm ca directory structure is already set up and the relevant files already exist. This usually involves creating a CA certificate and private key with .Cm req , a serial number file and an empty index file and placing them in the relevant directories. .Pp To use the sample configuration file below, the directories .Pa demoCA , .Pa demoCA/private and .Pa demoCA/newcerts would be created. The CA certificate would be copied to .Pa demoCA/cacert.pem and its private key to .Pa demoCA/private/cakey.pem . A file .Pa demoCA/serial would be created containing, for example, .Qq 01 and the empty index file .Pa demoCA/index.txt . .Pp Sign a certificate request: .Pp .Dl $ openssl ca -in req.pem -out newcert.pem .Pp Sign a certificate request, using CA extensions: .Pp .Dl $ openssl ca -in req.pem -extensions v3_ca -out newcert.pem .Pp Generate a CRL: .Pp .Dl $ openssl ca -gencrl -out crl.pem .Pp Sign several requests: .Pp .Dl $ openssl ca -infiles req1.pem req2.pem req3.pem .Pp Certify a Netscape SPKAC: .Pp .Dl $ openssl ca -spkac spkac.txt .Pp A sample SPKAC file .Pq the SPKAC line has been truncated for clarity : .Bd -literal -offset indent SPKAC=MIG0MGAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAn7PDhCeV/xIxUg8V70YRxK CN=Steve Test emailAddress=steve@openssl.org 0.OU=OpenSSL Group 1.OU=Another Group .Ed .Pp A sample configuration file with the relevant sections for .Nm ca : .Bd -literal \& [ ca ] \& default_ca = CA_default # The default ca section \& [ CA_default ] \& dir = ./demoCA # top dir \& database = $dir/index.txt # index file \& new_certs_dir = $dir/newcerts # new certs dir \& certificate = $dir/cacert.pem # The CA cert \& serial = $dir/serial # serial no file \& private_key = $dir/private/cakey.pem# CA private key \& default_days = 365 # how long to certify for \& default_crl_days= 30 # how long before next CRL \& default_md = md5 # md to use \& policy = policy_any # default policy \& email_in_dn = no # Don't add the email into cert DN \& name_opt = ca_default # Subject name display option \& cert_opt = ca_default # Certificate display option \& copy_extensions = none #Don't copy extensions from request \& [ policy_any ] \& countryName = supplied \& stateOrProvinceName = optional \& organizationName = optional \& organizationalUnitName = optional \& commonName = supplied \& emailAddress = optional .Ed .Sh CA FILES .Sy Note : the location of all files can change either by compile time options, configuration file entries, environment variables, or command line options. The values below reflect the default values. .Bd -literal -offset indent /etc/ssl/openssl.cnf - master configuration file \&./demoCA - main CA directory \&./demoCA/cacert.pem - CA certificate \&./demoCA/private/cakey.pem - CA private key \&./demoCA/serial - CA serial number file \&./demoCA/serial.old - CA serial number backup file \&./demoCA/index.txt - CA text database file \&./demoCA/index.txt.old - CA text database backup file \&./demoCA/certs - certificate output file \&./demoCA/.rnd - CA random seed information .Ed .Sh CA ENVIRONMENT VARIABLES .Ev OPENSSL_CONF reflects the location of the master configuration file; it can be overridden by the .Fl config command line option. .Sh CA RESTRICTIONS The text database index file is a critical part of the process, and if corrupted it can be difficult to fix. It is theoretically possible to rebuild the index file from all the issued certificates and a current CRL; however there is no option to do this. .Pp V2 CRL features like delta CRLs are not currently supported. .Pp Although several requests can be input and handled at once, it is only possible to include one SPKAC or self-signed certificate. .Sh CA BUGS The use of an in-memory text database can cause problems when large numbers of certificates are present because, as the name implies, the database has to be kept in memory. .Pp It is not possible to certify two certificates with the same DN; this is a side effect of how the text database is indexed and it cannot easily be fixed without introducing other problems. Some S/MIME clients can use two certificates with the same DN for separate signing and encryption keys. .Pp The .Nm ca command really needs rewriting or the required functionality exposed at either a command or interface level so a more friendly utility .Pq perl script or GUI can handle things properly. The scripts .Nm CA.sh and .Nm CA.pl help a little but not very much. .Pp Any fields in a request that are not present in a policy are silently deleted. This does not happen if the .Fl preserveDN option is used. To enforce the absence of the EMAIL field within the DN, as suggested by RFCs, regardless of the contents of the request's subject the .Fl noemailDN option can be used. The behaviour should be more friendly and configurable. .Pp Cancelling some commands by refusing to certify a certificate can create an empty file. .Sh CA WARNINGS The .Nm ca command is quirky and at times downright unfriendly. .Pp The .Nm ca utility was originally meant as an example of how to do things in a CA. It was not supposed to be used as a full blown CA itself: nevertheless some people are using it for this purpose. .Pp The .Nm ca command is effectively a single user command: no locking is done on the various files, and attempts to run more than one .Nm ca command on the same database can have unpredictable results. .Pp The .Ar copy_extensions option should be used with caution. If care is not taken, it can be a security risk. For example, if a certificate request contains a .Em basicConstraints extension with CA:TRUE and the .Ar copy_extensions value is set to .Ar copyall and the user does not spot this when the certificate is displayed, then this will hand the requestor a valid CA certificate. .Pp This situation can be avoided by setting .Ar copy_extensions to .Ar copy and including .Em basicConstraints with CA:FALSE in the configuration file. Then if the request contains a .Em basicConstraints extension, it will be ignored. .Pp It is advisable to also include values for other extensions such as .Ar keyUsage to prevent a request supplying its own values. .Pp Additional restrictions can be placed on the CA certificate itself. For example if the CA certificate has: .Pp .D1 basicConstraints = CA:TRUE, pathlen:0 .Pp then even if a certificate is issued with CA:TRUE it will not be valid. .\" .\" CIPHERS .\" .Sh CIPHERS .Nm openssl ciphers .Op Fl hVv .Op Fl ssl3 | tls1 .Op Ar cipherlist .Pp The .Nm ciphers command converts .Nm OpenSSL cipher lists into ordered SSL cipher preference lists. It can be used as a test tool to determine the appropriate cipherlist. .Pp The options are as follows: .Bl -tag -width Ds .It Fl h , \&? Print a brief usage message. .It Fl ssl3 Only include SSL v3 ciphers. .It Fl tls1 Only include TLS v1 ciphers. .It Fl V Like .Fl v , but include cipher suite codes in output (hex format). .It Fl v Verbose option. List ciphers with a complete description of protocol version .Pq SSLv3, which includes TLS , key exchange, authentication, encryption and mac algorithms used along with any key size restrictions and whether the algorithm is classed as an .Em export cipher. Note that without the .Fl v option, ciphers may seem to appear twice in a cipher list; this is when similar ciphers are available for SSL v3/TLS v1. .It Ar cipherlist A cipher list to convert to a cipher preference list. If it is not included, the default cipher list will be used. The format is described below. .El .Sh CIPHERS LIST FORMAT The cipher list consists of one or more .Em cipher strings separated by colons. Commas or spaces are also acceptable separators, but colons are normally used. .Pp The actual .Em cipher string can take several different forms: .Pp It can consist of a single cipher suite such as .Em RC4-SHA . .Pp It can represent a list of cipher suites containing a certain algorithm, or cipher suites of a certain type. For example .Em SHA1 represents all cipher suites using the digest algorithm SHA1, and .Em SSLv3 represents all SSL v3 algorithms. .Pp Lists of cipher suites can be combined in a single .Em cipher string using the .Sq + character. This is used as a logical .Em and operation. For example, .Em SHA1+DES represents all cipher suites containing the SHA1 and the DES algorithms. .Pp Each cipher string can be optionally preceded by the characters .Sq \&! , .Sq - , or .Sq + . .Pp If .Sq !\& is used, then the ciphers are permanently deleted from the list. The ciphers deleted can never reappear in the list even if they are explicitly stated. .Pp If .Sq - is used, then the ciphers are deleted from the list, but some or all of the ciphers can be added again by later options. .Pp If .Sq + is used, then the ciphers are moved to the end of the list. This option doesn't add any new ciphers, it just moves matching existing ones. .Pp If none of these characters is present, the string is just interpreted as a list of ciphers to be appended to the current preference list. If the list includes any ciphers already present, they will be ignored; that is, they will not be moved to the end of the list. .Pp Additionally, the cipher string .Em @STRENGTH can be used at any point to sort the current cipher list in order of encryption algorithm key length. .Sh CIPHERS STRINGS The following is a list of all permitted cipher strings and their meanings. .Bl -tag -width "XXXX" .It Ar DEFAULT The default cipher list. This is determined at compile time and is currently .Ar ALL:!aNULL:!eNULL:!SSLv2 . This must be the first .Ar cipher string specified. .It Ar COMPLEMENTOFDEFAULT The ciphers included in .Ar ALL , but not enabled by default. Currently this is .Ar ADH . Note that this rule does not cover .Ar eNULL , which is not included by .Ar ALL (use .Ar COMPLEMENTOFALL if necessary). .It Ar ALL All cipher suites except the .Ar eNULL ciphers which must be explicitly enabled. .It Ar COMPLEMENTOFALL The cipher suites not enabled by .Ar ALL , currently being .Ar eNULL . .It Ar HIGH .Qq High encryption cipher suites. This currently means those with key lengths larger than 128 bits. .It Ar MEDIUM .Qq Medium encryption cipher suites, currently those using 128-bit encryption. .It Ar LOW .Qq Low encryption cipher suites, currently those using 64- or 56-bit encryption algorithms, but excluding export cipher suites. .It Ar EXP , EXPORT Export encryption algorithms. Including 40- and 56-bit algorithms. .It Ar EXPORT40 40-bit export encryption algorithms. .It Ar eNULL , NULL The .Qq NULL ciphers; that is, those offering no encryption. Because these offer no encryption at all and are a security risk, they are disabled unless explicitly included. .It Ar aNULL The cipher suites offering no authentication. This is currently the anonymous DH algorithms. These cipher suites are vulnerable to a .Qq man in the middle attack, so their use is normally discouraged. .It Ar kRSA , RSA Cipher suites using RSA key exchange. .It Ar kEDH Cipher suites using ephemeral DH key agreement. .It Ar aRSA Cipher suites using RSA authentication, i.e. the certificates carry RSA keys. .It Ar aDSS , DSS Cipher suites using DSS authentication, i.e. the certificates carry DSS keys. .It Ar TLSv1 , SSLv3 TLS v1.0 or SSL v3.0 cipher suites, respectively. .It Ar DH Cipher suites using DH, including anonymous DH. .It Ar ADH Anonymous DH cipher suites. .It Ar AES Cipher suites using AES. .It Ar 3DES Cipher suites using triple DES. .It Ar DES Cipher suites using DES .Pq not triple DES . .It Ar RC4 Cipher suites using RC4. .It Ar RC2 Cipher suites using RC2. .It Ar MD5 Cipher suites using MD5. .It Ar SHA1 , SHA Cipher suites using SHA1. .El .Sh CIPHERS SUITE NAMES The following lists give the SSL or TLS cipher suites names from the relevant specification and their .Nm OpenSSL equivalents. It should be noted that several cipher suite names do not include the authentication used, e.g. DES-CBC3-SHA. In these cases, RSA authentication is used. .Ss SSL v3.0 cipher suites .Bd -unfilled -offset indent SSL_RSA_WITH_NULL_MD5 NULL-MD5 SSL_RSA_WITH_NULL_SHA NULL-SHA SSL_RSA_EXPORT_WITH_RC4_40_MD5 EXP-RC4-MD5 SSL_RSA_WITH_RC4_128_MD5 RC4-MD5 SSL_RSA_WITH_RC4_128_SHA RC4-SHA SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5 EXP-RC2-CBC-MD5 SSL_RSA_WITH_IDEA_CBC_SHA IDEA-CBC-SHA SSL_RSA_EXPORT_WITH_DES40_CBC_SHA EXP-DES-CBC-SHA SSL_RSA_WITH_DES_CBC_SHA DES-CBC-SHA SSL_RSA_WITH_3DES_EDE_CBC_SHA DES-CBC3-SHA SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA Not implemented. SSL_DH_DSS_WITH_DES_CBC_SHA Not implemented. SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA Not implemented. SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA Not implemented. SSL_DH_RSA_WITH_DES_CBC_SHA Not implemented. SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA Not implemented. SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA EXP-EDH-DSS-DES-CBC-SHA SSL_DHE_DSS_WITH_DES_CBC_SHA EDH-DSS-CBC-SHA SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA EDH-DSS-DES-CBC3-SHA SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA EXP-EDH-RSA-DES-CBC-SHA SSL_DHE_RSA_WITH_DES_CBC_SHA EDH-RSA-DES-CBC-SHA SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA EDH-RSA-DES-CBC3-SHA SSL_DH_anon_EXPORT_WITH_RC4_40_MD5 EXP-ADH-RC4-MD5 SSL_DH_anon_WITH_RC4_128_MD5 ADH-RC4-MD5 SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA EXP-ADH-DES-CBC-SHA SSL_DH_anon_WITH_DES_CBC_SHA ADH-DES-CBC-SHA SSL_DH_anon_WITH_3DES_EDE_CBC_SHA ADH-DES-CBC3-SHA SSL_FORTEZZA_KEA_WITH_NULL_SHA Not implemented. SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA Not implemented. SSL_FORTEZZA_KEA_WITH_RC4_128_SHA Not implemented. .Ed .Ss TLS v1.0 cipher suites .Bd -unfilled -offset indent TLS_RSA_WITH_NULL_MD5 NULL-MD5 TLS_RSA_WITH_NULL_SHA NULL-SHA TLS_RSA_EXPORT_WITH_RC4_40_MD5 EXP-RC4-MD5 TLS_RSA_WITH_RC4_128_MD5 RC4-MD5 TLS_RSA_WITH_RC4_128_SHA RC4-SHA TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 EXP-RC2-CBC-MD5 TLS_RSA_WITH_IDEA_CBC_SHA IDEA-CBC-SHA TLS_RSA_EXPORT_WITH_DES40_CBC_SHA EXP-DES-CBC-SHA TLS_RSA_WITH_DES_CBC_SHA DES-CBC-SHA TLS_RSA_WITH_3DES_EDE_CBC_SHA DES-CBC3-SHA TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA Not implemented. TLS_DH_DSS_WITH_DES_CBC_SHA Not implemented. TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA Not implemented. TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA Not implemented. TLS_DH_RSA_WITH_DES_CBC_SHA Not implemented. TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA Not implemented. TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA EXP-EDH-DSS-DES-CBC-SHA TLS_DHE_DSS_WITH_DES_CBC_SHA EDH-DSS-CBC-SHA TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA EDH-DSS-DES-CBC3-SHA TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA EXP-EDH-RSA-DES-CBC-SHA TLS_DHE_RSA_WITH_DES_CBC_SHA EDH-RSA-DES-CBC-SHA TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA EDH-RSA-DES-CBC3-SHA TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 EXP-ADH-RC4-MD5 TLS_DH_anon_WITH_RC4_128_MD5 ADH-RC4-MD5 TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA EXP-ADH-DES-CBC-SHA TLS_DH_anon_WITH_DES_CBC_SHA ADH-DES-CBC-SHA TLS_DH_anon_WITH_3DES_EDE_CBC_SHA ADH-DES-CBC3-SHA .Ed .Ss AES ciphersuites from RFC 3268, extending TLS v1.0 .Bd -unfilled -offset indent TLS_RSA_WITH_AES_128_CBC_SHA AES128-SHA TLS_RSA_WITH_AES_256_CBC_SHA AES256-SHA TLS_DH_DSS_WITH_AES_128_CBC_SHA Not implemented. TLS_DH_DSS_WITH_AES_256_CBC_SHA Not implemented. TLS_DH_RSA_WITH_AES_128_CBC_SHA Not implemented. TLS_DH_RSA_WITH_AES_256_CBC_SHA Not implemented. TLS_DHE_DSS_WITH_AES_128_CBC_SHA DHE-DSS-AES128-SHA TLS_DHE_DSS_WITH_AES_256_CBC_SHA DHE-DSS-AES256-SHA TLS_DHE_RSA_WITH_AES_128_CBC_SHA DHE-RSA-AES128-SHA TLS_DHE_RSA_WITH_AES_256_CBC_SHA DHE-RSA-AES256-SHA TLS_DH_anon_WITH_AES_128_CBC_SHA ADH-AES128-SHA TLS_DH_anon_WITH_AES_256_CBC_SHA ADH-AES256-SHA .Ed .Ss GOST ciphersuites from draft-chudov-cryptopro-cptls, extending TLS v1.0 .Sy Note : These ciphers require an engine which includes GOST cryptographic algorithms, such as the .Dq ccgost engine, included in the OpenSSL distribution. .Bd -unfilled -offset indent TLS_GOSTR341094_WITH_28147_CNT_IMIT GOST94-GOST89-GOST89 TLS_GOSTR341001_WITH_28147_CNT_IMIT GOST2001-GOST89-GOST89 TLS_GOSTR341094_WITH_NULL_GOSTR3411 GOST94-NULL-GOST94 TLS_GOSTR341001_WITH_NULL_GOSTR3411 GOST2001-NULL-GOST94 .Ed .Ss Additional Export 1024 and other cipher suites .Sy Note : These ciphers can also be used in SSL v3. .Bd -unfilled -offset indent TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA EXP1024-DES-CBC-SHA TLS_RSA_EXPORT1024_WITH_RC4_56_SHA EXP1024-RC4-SHA TLS_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA EXP1024-DHE-DSS-DES-CBC-SHA TLS_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA EXP1024-DHE-DSS-RC4-SHA TLS_DHE_DSS_WITH_RC4_128_SHA DHE-DSS-RC4-SHA .Ed .Sh CIPHERS NOTES The non-ephemeral DH modes are currently unimplemented in .Nm OpenSSL because there is no support for DH certificates. .Pp Some compiled versions of .Nm OpenSSL may not include all the ciphers listed here because some ciphers were excluded at compile time. .Sh CIPHERS EXAMPLES Verbose listing of all .Nm OpenSSL ciphers including NULL ciphers: .Pp .Dl $ openssl ciphers -v 'ALL:eNULL' .Pp Include all ciphers except NULL and anonymous DH then sort by strength: .Pp .Dl $ openssl ciphers -v 'ALL:!ADH:@STRENGTH' .Pp Include only 3DES ciphers and then place RSA ciphers last: .Pp .Dl $ openssl ciphers -v '3DES:+RSA' .Pp Include all RC4 ciphers but leave out those without authentication: .Pp .Dl $ openssl ciphers -v 'RC4:!COMPLEMENTOFDEFAULT' .Pp Include all ciphers with RSA authentication but leave out ciphers without encryption: .Pp .Dl $ openssl ciphers -v 'RSA:!COMPLEMENTOFALL' .Sh CIPHERS HISTORY The .Ar COMPLEMENTOFALL and .Ar COMPLEMENTOFDEFAULT selection options were added in .Nm OpenSSL 0.9.7. .Pp The .Fl V option of the .Nm ciphers command was added in .Nm OpenSSL 1.0.0. .\" .\" CRL .\" .Sh CRL .nr nS 1 .Nm "openssl crl" .Bk -words .Op Fl CAfile Ar file .Op Fl CApath Ar dir .Op Fl fingerprint .Op Fl hash .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl issuer .Op Fl lastupdate .Op Fl nextupdate .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl text .Ek .nr nS 0 .Pp The .Nm crl command processes CRL files in DER or PEM format. .Pp The options are as follows: .Bl -tag -width Ds .It Fl CAfile Ar file Verify the signature on a CRL by looking up the issuing certificate in .Ar file . .It Fl CApath Ar directory Verify the signature on a CRL by looking up the issuing certificate in .Ar dir . This directory must be a standard certificate directory, i.e. a hash of each subject name (using .Cm x509 Fl hash ) should be linked to each certificate. .It Fl fingerprint Print the CRL fingerprint. .It Fl hash Output a hash of the issuer name. This can be used to look up CRLs in a directory by issuer name. .It Fl in Ar file This specifies the input file to read from, or standard input if this option is not specified. .It Fl inform Ar DER | PEM This specifies the input format. .Ar DER format is a DER-encoded CRL structure. .Ar PEM .Pq the default is a base64-encoded version of the DER form with header and footer lines. .It Fl issuer Output the issuer name. .It Fl lastupdate Output the .Ar lastUpdate field. .It Fl nextupdate Output the .Ar nextUpdate field. .It Fl noout Don't output the encoded version of the CRL. .It Fl out Ar file Specifies the output file to write to, or standard output by default. .It Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. .It Fl text Print out the CRL in text form. .El .Sh CRL NOTES The PEM CRL format uses the header and footer lines: .Bd -unfilled -offset indent -----BEGIN X509 CRL----- -----END X509 CRL----- .Ed .Sh CRL EXAMPLES Convert a CRL file from PEM to DER: .Pp .Dl $ openssl crl -in crl.pem -outform DER -out crl.der .Pp Output the text form of a DER-encoded certificate: .Pp .Dl $ openssl crl -in crl.der -inform DER -text -noout .Sh CRL BUGS Ideally, it should be possible to create a CRL using appropriate options and files too. .\" .\" CRL2PKCS7 .\" .Sh CRL2PKCS7 .nr nS 1 .Nm "openssl crl2pkcs7" .Bk -words .Op Fl certfile Ar file .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl nocrl .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Ek .nr nS 0 .Pp The .Nm crl2pkcs7 command takes an optional CRL and one or more certificates and converts them into a PKCS#7 degenerate .Qq certificates only structure. .Pp The options are as follows: .Bl -tag -width Ds .It Fl certfile Ar file Specifies a .Ar file containing one or more certificates in PEM format. All certificates in the file will be added to the PKCS#7 structure. This option can be used more than once to read certificates from multiple files. .It Fl in Ar file This specifies the input .Ar file to read a CRL from, or standard input if this option is not specified. .It Fl inform Ar DER | PEM This specifies the CRL input format. .Ar DER format is a DER-encoded CRL structure. .Ar PEM .Pq the default is a base64-encoded version of the DER form with header and footer lines. .It Fl nocrl Normally, a CRL is included in the output file. With this option, no CRL is included in the output file and a CRL is not read from the input file. .It Fl out Ar file Specifies the output .Ar file to write the PKCS#7 structure to, or standard output by default. .It Fl outform Ar DER | PEM This specifies the PKCS#7 structure output format. .Ar DER format is a DER-encoded PKCS#7 structure. .Ar PEM .Pq the default is a base64-encoded version of the DER form with header and footer lines. .El .Sh CRL2PKCS7 EXAMPLES Create a PKCS#7 structure from a certificate and CRL: .Pp .Dl $ openssl crl2pkcs7 -in crl.pem -certfile cert.pem -out p7.pem .Pp Create a PKCS#7 structure in DER format with no CRL from several different certificates: .Bd -literal -offset indent $ openssl crl2pkcs7 -nocrl -certfile newcert.pem \e -certfile demoCA/cacert.pem -outform DER -out p7.der .Ed .Sh CRL2PKCS7 NOTES The output file is a PKCS#7 signed data structure containing no signers and just certificates and an optional CRL. .Pp This utility can be used to send certificates and CAs to Netscape as part of the certificate enrollment process. This involves sending the DER-encoded output as MIME type .Em application/x-x509-user-cert . .Pp The PEM-encoded form with the header and footer lines removed can be used to install user certificates and CAs in MSIE using the Xenroll control. .\" .\" DGST .\" .Sh DGST .nr nS 1 .Nm "openssl dgst" .Bk -words .Oo .Fl dss1 | md2 | md4 | md5 | .Fl ripemd160 | sha | sha1 .Oc .Op Fl binary .Op Fl cd .Op Fl engine Ar id .Op Fl hex .Op Fl hmac Ar key .Op Fl keyform Ar ENGINE | PEM .Op Fl mac Ar algorithm .Op Fl macopt Ar nm : Ns Ar v .Op Fl out Ar file .Op Fl passin Ar arg .Op Fl prverify Ar file .Op Fl sign Ar file .Op Fl signature Ar file .Op Fl sigopt Ar nm : Ns Ar v .Op Fl verify Ar file .Op Ar .Ek .nr nS 0 .Pp .Nm openssl .Cm md2 | md4 | md5 | .Cm ripemd160 | sha | sha1 .Op Fl c .Op Fl d .Op Ar .Pp The digest functions output the message digest of a supplied .Ar file or .Ar files in hexadecimal form. They can also be used for digital signing and verification. .Pp The options are as follows: .Bl -tag -width Ds .It Fl binary Output the digest or signature in binary form. .It Fl c Print out the digest in two-digit groups separated by colons; only relevant if .Em hex format output is used. .It Fl d Print out BIO debugging information. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm dgst to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. This engine is not used as a source for digest algorithms unless it is also specified in the configuration file. .It Fl hex Digest is to be output as a hex dump. This is the default case for a .Qq normal digest as opposed to a digital signature. .It Fl hmac Ar key Create a hashed MAC using .Ar key . .It Fl keyform Ar ENGINE | PEM Specifies the key format to sign the digest with. .It Fl mac Ar algorithm Create a keyed Message Authentication Code (MAC). The most popular MAC algorithm is HMAC (hash-based MAC), but there are other MAC algorithms which are not based on hash. MAC keys and other options should be set via the .Fl macopt parameter. .It Fl macopt Ar nm : Ns Ar v Passes options to the MAC algorithm, specified by .Fl mac . The following options are supported by HMAC: .Bl -tag -width Ds .It Ar key : Ns Ar string Specifies the MAC key as an alphanumeric string (use if the key contain printable characters only). String length must conform to any restrictions of the MAC algorithm. .It Ar hexkey : Ns Ar string Specifies the MAC key in hexadecimal form (two hex digits per byte). Key length must conform to any restrictions of the MAC algorithm. .El .It Fl out Ar file The file to output to, or standard output by default. .It Fl passin Ar arg The key password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl prverify Ar file Verify the signature using the private key in .Ar file . The output is either .Qq Verification OK or .Qq Verification Failure . .It Fl sign Ar file Digitally sign the digest using the private key in .Ar file . .It Fl signature Ar file The actual signature to verify. .It Fl sigopt Ar nm : Ns Ar v Pass options to the signature algorithm during sign or verify operations. The names and values of these options are algorithm-specific. .It Fl verify Ar file Verify the signature using the public key in .Ar file . The output is either .Qq Verification OK or .Qq Verification Failure . .It Ar File or files to digest. If no files are specified then standard input is used. .El .Sh DGST NOTES The digest of choice for all new applications is SHA1. Other digests are, however, still widely used. .Pp If you wish to sign or verify data using the DSA algorithm, the dss1 digest must be used. .Pp A source of random numbers is required for certain signing algorithms, in particular DSA. .Pp The signing and verify options should only be used if a single file is being signed or verified. .\" .\" DH .\" .Sh DH Diffie-Hellman Parameter Management. The .Nm dh command has been replaced by .Nm dhparam . See .Sx DHPARAM below. .\" .\" DHPARAM .\" .Sh DHPARAM .nr nS 1 .Nm "openssl dhparam" .Bk -words .Op Fl 2 | 5 .Op Fl C .Op Fl check .Op Fl dsaparam .Op Fl engine Ar id .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl text .Op Ar numbits .Ek .nr nS 0 .Pp The .Nm dhparam command is used to manipulate DH parameter files. .Pp The options are as follows: .Bl -tag -width Ds .It Fl 2 , 5 The generator to use, either 2 or 5. 2 is the default. If present, the input file is ignored and parameters are generated instead. .It Fl C This option converts the parameters into C code. The parameters can then be loaded by calling the .Cm get_dh Ns Ar numbits Ns Li () function. .It Fl check Check the DH parameters. .It Fl dsaparam If this option is used, DSA rather than DH parameters are read or created; they are converted to DH format. Otherwise, .Qq strong primes .Pq such that (p-1)/2 is also prime will be used for DH parameter generation. .Pp DH parameter generation with the .Fl dsaparam option is much faster, and the recommended exponent length is shorter, which makes DH key exchange more efficient. Beware that with such DSA-style DH parameters, a fresh DH key should be created for each use to avoid small-subgroup attacks that may be possible otherwise. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm dhparam to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl in Ar file This specifies the input .Ar file to read parameters from, or standard input if this option is not specified. .It Fl inform Ar DER | PEM This specifies the input format. The argument .Ar DER uses an ASN1 DER-encoded form compatible with the PKCS#3 DHparameter structure. The .Ar PEM form is the default format: it consists of the DER format base64-encoded with additional header and footer lines. .It Fl noout This option inhibits the output of the encoded version of the parameters. .It Ar numbits This argument specifies that a parameter set should be generated of size .Ar numbits . It must be the last option. If not present, a value of 512 is used. If this value is present, the input file is ignored and parameters are generated instead. .It Fl out Ar file This specifies the output .Ar file to write parameters to. Standard output is used if this option is not present. The output filename should .Em not be the same as the input filename. .It Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. .It Fl text This option prints out the DH parameters in human readable form. .El .Sh DHPARAM WARNINGS The program .Nm dhparam combines the functionality of the programs .Nm dh and .Nm gendh in previous versions of .Nm OpenSSL and .Nm SSLeay . The .Nm dh and .Nm gendh programs are retained for now, but may have different purposes in future versions of .Nm OpenSSL . .Sh DHPARAM NOTES PEM format DH parameters use the header and footer lines: .Bd -unfilled -offset indent -----BEGIN DH PARAMETERS----- -----END DH PARAMETERS----- .Ed .Pp .Nm OpenSSL currently only supports the older PKCS#3 DH, not the newer X9.42 DH. .Pp This program manipulates DH parameters not keys. .Sh DHPARAM BUGS There should be a way to generate and manipulate DH keys. .Sh DHPARAM HISTORY The .Nm dhparam command was added in .Nm OpenSSL 0.9.5. The .Fl dsaparam option was added in .Nm OpenSSL 0.9.6. .\" .\" DSA .\" .Sh DSA .nr nS 1 .Nm "openssl dsa" .Bk -words .Oo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Oc .Op Fl engine Ar id .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl modulus .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl passin Ar arg .Op Fl passout Ar arg .Op Fl pubin .Op Fl pubout .Op Fl text .Ek .nr nS 0 .Pp The .Nm dsa command processes DSA keys. They can be converted between various forms and their components printed out. .Pp .Sy Note : This command uses the traditional .Nm SSLeay compatible format for private key encryption: newer applications should use the more secure PKCS#8 format using the .Nm pkcs8 command. .Pp The options are as follows: .Bl -tag -width Ds .It Xo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Xc These options encrypt the private key with the AES, DES, or the triple DES ciphers, respectively, before outputting it. A pass phrase is prompted for. If none of these options is specified, the key is written in plain text. This means that using the .Nm dsa utility to read in an encrypted key with no encryption option can be used to remove the pass phrase from a key, or by setting the encryption options it can be use to add or change the pass phrase. These options can only be used with PEM format output files. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm dsa to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl in Ar file This specifies the input .Ar file to read a key from, or standard input if this option is not specified. If the key is encrypted, a pass phrase will be prompted for. .It Fl inform Ar DER | PEM This specifies the input format. The .Ar DER argument with a private key uses an ASN1 DER-encoded form of an ASN.1 SEQUENCE consisting of the values of version .Pq currently zero , P, Q, G, and the public and private key components, respectively, as ASN.1 INTEGERs. When used with a public key it uses a .Em SubjectPublicKeyInfo structure: it is an error if the key is not DSA. .Pp The .Ar PEM form is the default format: it consists of the DER format base64-encoded with additional header and footer lines. In the case of a private key, PKCS#8 format is also accepted. .It Fl modulus This option prints out the value of the public key component of the key. .It Fl noout This option prevents output of the encoded version of the key. .It Fl out Ar file This specifies the output .Ar file to write a key to, or standard output if not specified. If any encryption options are set then a pass phrase will be prompted for. The output filename should .Em not be the same as the input filename. .It Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. .It Fl passin Ar arg The key password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl passout Ar arg The output file password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl pubin By default, a private key is read from the input file. With this option a public key is read instead. .It Fl pubout By default, a private key is output. With this option a public key will be output instead. This option is automatically set if the input is a public key. .It Fl text Prints out the public/private key components and parameters. .El .Sh DSA NOTES The PEM private key format uses the header and footer lines: .Bd -unfilled -offset indent -----BEGIN DSA PRIVATE KEY----- -----END DSA PRIVATE KEY----- .Ed .Pp The PEM public key format uses the header and footer lines: .Bd -unfilled -offset indent -----BEGIN PUBLIC KEY----- -----END PUBLIC KEY----- .Ed .Sh DSA EXAMPLES To remove the pass phrase on a DSA private key: .Pp .Dl $ openssl dsa -in key.pem -out keyout.pem .Pp To encrypt a private key using triple DES: .Pp .Dl $ openssl dsa -in key.pem -des3 -out keyout.pem .Pp To convert a private key from PEM to DER format: .Pp .Dl $ openssl dsa -in key.pem -outform DER -out keyout.der .Pp To print out the components of a private key to standard output: .Pp .Dl $ openssl dsa -in key.pem -text -noout .Pp To just output the public part of a private key: .Pp .Dl $ openssl dsa -in key.pem -pubout -out pubkey.pem .\" .\" DSAPARAM .\" .Sh DSAPARAM .nr nS 1 .Nm "openssl dsaparam" .Bk -words .Op Fl C .Op Fl engine Ar id .Op Fl genkey .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl text .Op Ar numbits .Ek .nr nS 0 .Pp The .Nm dsaparam command is used to manipulate or generate DSA parameter files. .Pp The options are as follows: .Bl -tag -width Ds .It Fl C This option converts the parameters into C code. The parameters can then be loaded by calling the .Cm get_dsa Ns Ar XXX Ns Li () function. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm dsaparam to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl genkey This option will generate a DSA either using the specified or generated parameters. .It Fl in Ar file This specifies the input .Ar file to read parameters from, or standard input if this option is not specified. If the .Ar numbits parameter is included, then this option will be ignored. .It Fl inform Ar DER | PEM This specifies the input format. The .Ar DER argument uses an ASN1 DER-encoded form compatible with RFC 2459 .Pq PKIX DSS-Parms that is a SEQUENCE consisting of p, q and g, respectively. The .Ar PEM form is the default format: it consists of the DER format base64-encoded with additional header and footer lines. .It Fl noout This option inhibits the output of the encoded version of the parameters. .It Ar numbits This option specifies that a parameter set should be generated of size .Ar numbits . If this option is included, the input file .Pq if any is ignored. .It Fl out Ar file This specifies the output .Ar file to write parameters to. Standard output is used if this option is not present. The output filename should .Em not be the same as the input filename. .It Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. .It Fl text This option prints out the DSA parameters in human readable form. .El .Sh DSAPARAM NOTES PEM format DSA parameters use the header and footer lines: .Bd -unfilled -offset indent -----BEGIN DSA PARAMETERS----- -----END DSA PARAMETERS----- .Ed .Pp DSA parameter generation is a slow process and as a result the same set of DSA parameters is often used to generate several distinct keys. .\" .\" EC .\" .Sh EC .nr nS 1 .Nm "openssl ec" .Bk -words .Op Fl conv_form Ar arg .Op Fl des .Op Fl des3 .Op Fl engine Ar id .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl param_enc Ar arg .Op Fl param_out .Op Fl passin Ar arg .Op Fl passout Ar arg .Op Fl pubin .Op Fl pubout .Op Fl text .Ek .nr nS 0 .Pp The .Nm ec command processes EC keys. They can be converted between various forms and their components printed out. Note: .Nm OpenSSL uses the private key format specified in .Dq SEC 1: Elliptic Curve Cryptography .Pq Lk http://www.secg.org/ . To convert an .Nm OpenSSL EC private key into the PKCS#8 private key format use the .Nm pkcs8 command. .Pp The options are as follows: .Bl -tag -width Ds .It Fl conv_form Ar arg This specifies how the points on the elliptic curve are converted into octet strings. Possible values are: .Cm compressed (the default value), .Cm uncompressed , and .Cm hybrid . For more information regarding the point conversion forms please read the X9.62 standard. Note: Due to patent issues the .Cm compressed option is disabled by default for binary curves and can be enabled by defining the preprocessor macro .Ar OPENSSL_EC_BIN_PT_COMP at compile time. .It Fl des | des3 These options encrypt the private key with the DES, triple DES, or any other cipher supported by .Nm OpenSSL before outputting it. A pass phrase is prompted for. If none of these options is specified the key is written in plain text. This means that using the .Nm ec utility to read in an encrypted key with no encryption option can be used to remove the pass phrase from a key, or by setting the encryption options it can be use to add or change the pass phrase. These options can only be used with PEM format output files. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm ec to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl in Ar file This specifies the input filename to read a key from, or standard input if this option is not specified. If the key is encrypted a pass phrase will be prompted for. .It Fl inform Ar DER | PEM This specifies the input format. DER with a private key uses an ASN.1 DER-encoded SEC1 private key. When used with a public key it uses the SubjectPublicKeyInfo structure as specified in RFC 3280. PEM is the default format: it consists of the DER format base64 encoded with additional header and footer lines. In the case of a private key PKCS#8 format is also accepted. .It Fl noout Prevents output of the encoded version of the key. .It Fl out Ar file Specifies the output filename to write a key to, or standard output if none is specified. If any encryption options are set then a pass phrase will be prompted for. The output filename should .Em not be the same as the input filename. .It Fl outform Ar DER | PEM This specifies the output format. The options have the same meaning as the .Fl inform option. .It Fl param_enc Ar arg This specifies how the elliptic curve parameters are encoded. Possible value are: .Cm named_curve , i.e. the EC parameters are specified by an OID; or .Cm explicit , where the EC parameters are explicitly given (see RFC 3279 for the definition of the EC parameter structures). The default value is .Cm named_curve . Note: the .Cm implicitlyCA alternative, as specified in RFC 3279, is currently not implemented in .Nm OpenSSL . .It Fl passin Ar arg The key password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl passout Ar arg The output file password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl pubin By default a private key is read from the input file; with this option a public key is read instead. .It Fl pubout By default a private key is output; with this option a public key is output instead. This option is automatically set if the input is a public key. .It Fl text Prints out the public/private key components and parameters. .El .Sh EC NOTES The PEM private key format uses the header and footer lines: .Bd -literal -offset indent -----BEGIN EC PRIVATE KEY----- -----END EC PRIVATE KEY----- .Ed .Pp The PEM public key format uses the header and footer lines: .Bd -literal -offset indent -----BEGIN PUBLIC KEY----- -----END PUBLIC KEY----- .Ed .Sh EC EXAMPLES To encrypt a private key using triple DES: .Bd -literal -offset indent $ openssl ec -in key.pem -des3 -out keyout.pem .Ed .Pp To convert a private key from PEM to DER format: .Bd -literal -offset indent $ openssl ec -in key.pem -outform DER -out keyout.der .Ed .Pp To print out the components of a private key to standard output: .Bd -literal -offset indent $ openssl ec -in key.pem -text -noout .Ed .Pp To just output the public part of a private key: .Bd -literal -offset indent $ openssl ec -in key.pem -pubout -out pubkey.pem .Ed .Pp To change the parameter encoding to .Cm explicit : .Bd -literal -offset indent $ openssl ec -in key.pem -param_enc explicit -out keyout.pem .Ed .Pp To change the point conversion form to .Cm compressed : .Bd -literal -offset indent $ openssl ec -in key.pem -conv_form compressed -out keyout.pem .Ed .Sh EC HISTORY The .Nm ec command was first introduced in .Nm OpenSSL 0.9.8. .Sh EC AUTHORS .An Nils Larsch . .\" .\" ECPARAM .\" .Sh ECPARAM .nr nS 1 .Nm "openssl ecparam" .Bk -words .Op Fl C .Op Fl check .Op Fl conv_form Ar arg .Op Fl engine Ar id .Op Fl genkey .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl list_curves .Op Fl name Ar arg .Op Fl no_seed .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl param_enc Ar arg .Op Fl text .Ek .nr nS 0 .Pp This command is used to manipulate or generate EC parameter files. .Pp The options are as follows: .Bl -tag -width Ds .It Fl C Convert the EC parameters into C code. The parameters can then be loaded by calling the .Fn get_ec_group_XXX function. .It Fl check Validate the elliptic curve parameters. .It Fl conv_form Ar arg Specify how the points on the elliptic curve are converted into octet strings. Possible values are: .Cm compressed (the default value), .Cm uncompressed , and .Cm hybrid . For more information regarding the point conversion forms please read the X9.62 standard. Note: Due to patent issues the .Cm compressed option is disabled by default for binary curves and can be enabled by defining the preprocessor macro .Ar OPENSSL_EC_BIN_PT_COMP at compile time. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm ecparam to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl genkey Generate an EC private key using the specified parameters. .It Fl in Ar file Specify the input filename to read parameters from or standard input if this option is not specified. .It Fl inform Ar DER | PEM Specify the input format. DER uses an ASN.1 DER-encoded form compatible with RFC 3279 EcpkParameters. PEM is the default format: it consists of the DER format base64 encoded with additional header and footer lines. .It Fl list_curves Print out a list of all currently implemented EC parameter names and exit. .It Fl name Ar arg Use the EC parameters with the specified 'short' name. Use .Fl list_curves to get a list of all currently implemented EC parameters. .It Fl no_seed Inhibit that the 'seed' for the parameter generation is included in the ECParameters structure (see RFC 3279). .It Fl noout Inhibit the output of the encoded version of the parameters. .It Fl out Ar file Specify the output filename parameters are written to. Standard output is used if this option is not present. The output filename should .Em not be the same as the input filename. .It Fl outform Ar DER | PEM Specify the output format; the parameters have the same meaning as the .Fl inform option. .It Fl param_enc Ar arg This specifies how the elliptic curve parameters are encoded. Possible value are: .Cm named_curve , i.e. the EC parameters are specified by an OID, or .Cm explicit , where the EC parameters are explicitly given (see RFC 3279 for the definition of the EC parameter structures). The default value is .Cm named_curve . Note: the .Cm implicitlyCA alternative, as specified in RFC 3279, is currently not implemented in .Nm OpenSSL . .It Fl text Print out the EC parameters in human readable form. .El .Sh ECPARAM NOTES PEM format EC parameters use the header and footer lines: .Bd -literal -offset indent -----BEGIN EC PARAMETERS----- -----END EC PARAMETERS----- .Ed .Pp .Nm OpenSSL is currently not able to generate new groups and therefore .Nm ecparam can only create EC parameters from known (named) curves. .Sh ECPARAM EXAMPLES To create EC parameters with the group 'prime192v1': .Bd -literal -offset indent $ openssl ecparam -out ec_param.pem -name prime192v1 .Ed .Pp To create EC parameters with explicit parameters: .Bd -literal -offset indent $ openssl ecparam -out ec_param.pem -name prime192v1 \e -param_enc explicit .Ed .Pp To validate given EC parameters: .Bd -literal -offset indent $ openssl ecparam -in ec_param.pem -check .Ed .Pp To create EC parameters and a private key: .Bd -literal -offset indent $ openssl ecparam -out ec_key.pem -name prime192v1 -genkey .Ed .Pp To change the point encoding to 'compressed': .Bd -literal -offset indent $ openssl ecparam -in ec_in.pem -out ec_out.pem \e -conv_form compressed .Ed .Pp To print out the EC parameters to standard output: .Bd -literal -offset indent $ openssl ecparam -in ec_param.pem -noout -text .Ed .Sh ECPARAM HISTORY The .Nm ecparam command was first introduced in .Nm OpenSSL 0.9.8. .Sh ECPARAM AUTHORS .An Nils Larsch . .\" .\" ENC .\" .Sh ENC .nr nS 1 .Nm "openssl enc" .Bk -words .Fl ciphername .Op Fl AadePp .Op Fl base64 .Op Fl bufsize Ar number .Op Fl debug .Op Fl engine Ar id .Op Fl in Ar file .Op Fl iv Ar IV .Op Fl K Ar key .Op Fl k Ar password .Op Fl kfile Ar file .Op Fl md Ar digest .Op Fl none .Op Fl nopad .Op Fl nosalt .Op Fl out Ar file .Op Fl pass Ar arg .Op Fl S Ar salt .Op Fl salt .Ek .nr nS 0 .Pp The symmetric cipher commands allow data to be encrypted or decrypted using various block and stream ciphers using keys based on passwords or explicitly provided. Base64 encoding or decoding can also be performed either by itself or in addition to the encryption or decryption. .Pp The options are as follows: .Bl -tag -width Ds .It Fl A If the .Fl a option is set, then base64 process the data on one line. .It Fl a , base64 Base64 process the data. This means that if encryption is taking place, the data is base64-encoded after encryption. If decryption is set, the input data is base64 decoded before being decrypted. .It Fl bufsize Ar number Set the buffer size for I/O. .It Fl d Decrypt the input data. .It Fl debug Debug the BIOs used for I/O. .It Fl e Encrypt the input data: this is the default. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm enc to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl in Ar file The input .Ar file ; standard input by default. .It Fl iv Ar IV The actual .Ar IV .Pq initialisation vector to use: this must be represented as a string comprised only of hex digits. When only the .Ar key is specified using the .Fl K option, the .Ar IV must explicitly be defined. When a password is being specified using one of the other options, the .Ar IV is generated from this password. .It Fl K Ar key The actual .Ar key to use: this must be represented as a string comprised only of hex digits. If only the key is specified, the .Ar IV must be additionally specified using the .Fl iv option. When both a .Ar key and a .Ar password are specified, the .Ar key given with the .Fl K option will be used and the .Ar IV generated from the password will be taken. It probably does not make much sense to specify both .Ar key and .Ar password . .It Fl k Ar password The .Ar password to derive the key from. This is for compatibility with previous versions of .Nm OpenSSL . Superseded by the .Fl pass option. .It Fl kfile Ar file Read the password to derive the key from the first line of .Ar file . This is for compatibility with previous versions of .Nm OpenSSL . Superseded by the .Fl pass option. .It Fl md Ar digest Use .Ar digest to create a key from a pass phrase. .Ar digest may be one of .Dq md2 , .Dq md5 , .Dq sha , or .Dq sha1 . .It Fl none Use NULL cipher (no encryption or decryption of input). .It Fl nopad Disable standard block padding. .It Fl nosalt Don't use a .Ar salt in the key derivation routines. This option should .Em NEVER be used unless compatibility with previous versions of .Nm OpenSSL or .Nm SSLeay is required. .It Fl out Ar file The output .Ar file , standard output by default. .It Fl P Print out the .Ar salt , .Ar key , and .Ar IV used, then immediately exit; don't do any encryption or decryption. .It Fl p Print out the .Ar salt , .Ar key , and .Ar IV used. .It Fl pass Ar arg The password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl S Ar salt The actual .Ar salt to use: this must be represented as a string comprised only of hex digits. .It Fl salt Use a .Ar salt in the key derivation routines. This is the default. .El .Sh ENC NOTES The program can be called either as .Nm openssl ciphername or .Nm openssl enc -ciphername . But the first form doesn't work with engine-provided ciphers, because this form is processed before the configuration file is read and any engines loaded. .Pp Engines which provide entirely new encryption algorithms should be configured in the configuration file. Engines, specified on the command line using the .Fl engine option, can only be used for hardware-assisted implementations of ciphers, supported by .Nm OpenSSL core, or by other engines specified in the configuration file. .Pp When .Nm enc lists supported ciphers, ciphers provided by engines specified in the configuration files are listed too. .Pp A password will be prompted for to derive the .Ar key and .Ar IV if necessary. .Pp The .Fl nosalt option should .Em NEVER be used unless compatibility with previous versions of .Nm OpenSSL or .Nm SSLeay is required. .Pp With the .Fl nosalt option it is possible to perform efficient dictionary attacks on the password and to attack stream cipher encrypted data. The reason for this is that without the salt the same password always generates the same encryption key. When the salt is being used the first eight bytes of the encrypted data are reserved for the salt: it is generated at random when encrypting a file and read from the encrypted file when it is decrypted. .Pp Some of the ciphers do not have large keys and others have security implications if not used correctly. A beginner is advised to just use a strong block cipher in CBC mode such as bf or des3. .Pp All the block ciphers normally use PKCS#5 padding also known as standard block padding: this allows a rudimentary integrity or password check to be performed. However, since the chance of random data passing the test is better than 1 in 256, it isn't a very good test. .Pp If padding is disabled, the input data must be a multiple of the cipher block length. .Pp All RC2 ciphers have the same key and effective key length. .Pp Blowfish and RC5 algorithms use a 128-bit key. .Sh ENC SUPPORTED CIPHERS .Bd -unfilled -offset indent aes-[128|192|256]-cbc 128/192/256 bit AES in CBC mode aes-[128|192|256] Alias for aes-[128|192|256]-cbc aes-[128|192|256]-cfb 128/192/256 bit AES in 128 bit CFB mode aes-[128|192|256]-cfb1 128/192/256 bit AES in 1 bit CFB mode aes-[128|192|256]-cfb8 128/192/256 bit AES in 8 bit CFB mode aes-[128|192|256]-ecb 128/192/256 bit AES in ECB mode aes-[128|192|256]-ofb 128/192/256 bit AES in OFB mode base64 Base 64 bf Alias for bf-cbc bf-cbc Blowfish in CBC mode bf-cfb Blowfish in CFB mode bf-ecb Blowfish in ECB mode bf-ofb Blowfish in OFB mode cast Alias for cast-cbc cast-cbc CAST in CBC mode cast5-cbc CAST5 in CBC mode cast5-cfb CAST5 in CFB mode cast5-ecb CAST5 in ECB mode cast5-ofb CAST5 in OFB mode des Alias for des-cbc des-cbc DES in CBC mode des-cfb DES in CBC mode des-ecb DES in ECB mode des-ofb DES in OFB mode des-ede Two key triple DES EDE in ECB mode des-ede-cbc Two key triple DES EDE in CBC mode des-ede-cfb Two key triple DES EDE in CFB mode des-ede-ofb Two key triple DES EDE in OFB mode des3 Alias for des-ede3-cbc des-ede3 Three key triple DES EDE in ECB mode des-ede3-cbc Three key triple DES EDE in CBC mode des-ede3-cfb Three key triple DES EDE CFB mode des-ede3-ofb Three key triple DES EDE in OFB mode desx DESX algorithm rc2 Alias for rc2-cbc rc2-cbc 128-bit RC2 in CBC mode rc2-cfb 128-bit RC2 in CFB mode rc2-ecb 128-bit RC2 in ECB mode rc2-ofb 128-bit RC2 in OFB mode rc2-64-cbc 64-bit RC2 in CBC mode rc2-40-cbc 40-bit RC2 in CBC mode rc4 128-bit RC4 rc4-40 40-bit RC4 .Ed .Sh ENC EXAMPLES Just base64 encode a binary file: .Pp .Dl $ openssl base64 -in file.bin -out file.b64 .Pp Decode the same file: .Pp .Dl $ openssl base64 -d -in file.b64 -out file.bin .Pp Encrypt a file using triple DES in CBC mode using a prompted password: .Pp .Dl $ openssl des3 -salt -in file.txt -out file.des3 .Pp Decrypt a file using a supplied password: .Pp .Dl "$ openssl des3 -d -in file.des3 -out file.txt -k mypassword" .Pp Encrypt a file then base64 encode it (so it can be sent via mail for example) using Blowfish in CBC mode: .Pp .Dl $ openssl bf -a -salt -in file.txt -out file.bf .Pp Base64 decode a file then decrypt it: .Pp .Dl "$ openssl bf -d -a -in file.bf -out file.txt" .Sh ENC BUGS The .Fl A option when used with large files doesn't work properly. .Pp There should be an option to allow an iteration count to be included. .Pp The .Nm enc program only supports a fixed number of algorithms with certain parameters. Therefore it is not possible to use RC2 with a 76-bit key or RC4 with an 84-bit key with this program. .\" .\" ENGINE .\" .Sh ENGINE .Nm openssl engine .Op Fl ctv .Op Fl post Ar cmd .Op Fl pre Ar cmd .Op Ar engine ... .Pp The .Nm engine command provides loadable module information and manipulation of various engines. Any options are applied to all engines supplied on the command line, or all supported engines if none are specified. .Pp The options are as follows: .Bl -tag -width Ds .It Fl c For each engine, also list the capabilities. .It Fl post Ar cmd Run command .Ar cmd against the engine after loading it (only used if .Fl t is also provided). .It Fl pre Ar cmd Run command .Ar cmd against the engine before any attempts to load it (only used if .Fl t is also provided). .It Fl t For each engine, check that they are really available. .Fl tt will display an error trace for unavailable engines. .It Fl v Verbose mode. For each engine, list its 'control commands'. .Fl vv will additionally display each command's description. .Fl vvv will also add the input flags for each command. .Fl vvvv will also show internal input flags. .El .\" .\" ERRSTR .\" .Sh ERRSTR .Nm openssl errstr .Op Fl stats .Ar errno ... .Pp The .Nm errstr command performs error number to error string conversion, generating a human-readable string representing the error code .Ar errno . The string is obtained through the .Xr ERR_error_string_n 3 function and has the following format: .Pp .Dl error:[error code]:[library name]:[function name]:[reason string] .Pp .Bq error code is an 8-digit hexadecimal number. The remaining fields .Bq library name , .Bq function name , and .Bq reason string are all ASCII text. .Pp The options are as follows: .Bl -tag -width Ds .It Fl stats Print debugging statistics about various aspects of the hash table. .El .Sh ERRSTR EXAMPLES The following error code: .Pp .Dl 27594:error:2006D080:lib(32):func(109):reason(128):bss_file.c:107: .Pp \&...can be displayed with: .Pp .Dl $ openssl errstr 2006D080 .Pp \&...to produce the error message: .Pp .Dl error:2006D080:BIO routines:BIO_new_file:no such file .\" .\" GENDH .\" .Sh GENDH Generation of Diffie-Hellman Parameters. Replaced by .Nm dhparam . See .Sx DHPARAM above. .\" .\" GENDSA .\" .Sh GENDSA .nr nS 1 .Nm "openssl gendsa" .Bk -words .Oo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Oc .Op Fl engine Ar id .Op Fl out Ar file .Op Ar paramfile .Ek .nr nS 0 .Pp The .Nm gendsa command generates a DSA private key from a DSA parameter file (which will typically be generated by the .Nm openssl dsaparam command). .Pp The options are as follows: .Bl -tag -width Ds .It Xo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Xc These options encrypt the private key with the AES, DES, or the triple DES ciphers, respectively, before outputting it. A pass phrase is prompted for. If none of these options are specified, no encryption is used. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm gendsa to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl out Ar file The output .Ar file . If this argument is not specified, standard output is used. .It Ar paramfile This option specifies the DSA parameter file to use. The parameters in this file determine the size of the private key. DSA parameters can be generated and examined using the .Nm openssl dsaparam command. .El .Sh GENDSA NOTES DSA key generation is little more than random number generation so it is much quicker than RSA key generation, for example. .\" .\" GENPKEY .\" .Sh GENPKEY .nr nS 1 .Nm "openssl genpkey" .Bk -words .Op Fl algorithm Ar alg .Op Ar cipher .Op Fl engine Ar id .Op Fl genparam .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl paramfile Ar file .Op Fl pass Ar arg .Op Fl pkeyopt Ar opt : Ns Ar value .Op Fl text .Ek .nr nS 0 .Pp The .Nm genpkey command generates private keys. The use of this program is encouraged over the algorithm specific utilities because additional algorithm options and engine-provided algorithms can be used. .Pp The options are as follows: .Bl -tag -width Ds .It Fl algorithm Ar alg The public key algorithm to use, such as RSA, DSA, or DH. If used this option must precede any .Fl pkeyopt options. The options .Fl paramfile and .Fl algorithm are mutually exclusive. .It Ar cipher Encrypt the private key with the supplied cipher. Any algorithm name accepted by .Fn EVP_get_cipherbyname is acceptable, such as .Cm des3 . .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm genpkey to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl genparam Generate a set of parameters instead of a private key. If used this option must precede any .Fl algorithm , .Fl paramfile , or .Fl pkeyopt options. .It Fl out Ar file The output filename. If this argument is not specified then standard output is used. .It Fl outform Ar DER | PEM This specifies the output format, DER or PEM. .It Fl paramfile Ar file Some public key algorithms generate a private key based on a set of parameters. They can be supplied using this option. If this option is used the public key algorithm used is determined by the parameters. If used this option must precede any .Fl pkeyopt options. The options .Fl paramfile and .Fl algorithm are mutually exclusive. .It Fl pass Ar arg The output file password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl pkeyopt Ar opt : Ns Ar value Set the public key algorithm option .Ar opt to .Ar value . The precise set of options supported depends on the public key algorithm used and its implementation. See .Sx GENPKEY KEY GENERATION OPTIONS below for more details. .It Fl text Print an (unencrypted) text representation of private and public keys and parameters along with the DER or PEM structure. .El .Sh GENPKEY KEY GENERATION OPTIONS The options supported by each algorithm and indeed each implementation of an algorithm can vary. The options for the .Nm OpenSSL implementations are detailed below. .Bl -tag -width Ds -offset indent .It rsa_keygen_bits : Ns Ar numbits (RSA) The number of bits in the generated key. If not specified 2048 is used. .It rsa_keygen_pubexp : Ns Ar value (RSA) The RSA public exponent value. This can be a large decimal or hexadecimal value if preceded by 0x. The default value is 65537. .It dsa_paramgen_bits : Ns Ar numbits (DSA) The number of bits in the generated parameters. If not specified 1024 is used. .It dh_paramgen_prime_len : Ns Ar numbits (DH) The number of bits in the prime parameter .Ar p . .It dh_paramgen_generator : Ns Ar value (DH) The value to use for the generator .Ar g . .It ec_paramgen_curve : Ns Ar curve (EC) The EC curve to use. .El .Sh GENPKEY EXAMPLES Generate an RSA private key using default parameters: .Bd -literal -offset indent $ openssl genpkey -algorithm RSA -out key.pem .Ed .Pp Encrypt and output a private key using 128-bit AES and the passphrase "hello": .Bd -literal -offset indent $ openssl genpkey -algorithm RSA -out key.pem \e -aes-128-cbc -pass pass:hello .Ed .Pp Generate a 2048-bit RSA key using 3 as the public exponent: .Bd -literal -offset indent $ openssl genpkey -algorithm RSA -out key.pem \e -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:3 .Ed .Pp Generate 1024-bit DSA parameters: .Bd -literal -offset indent $ openssl genpkey -genparam -algorithm DSA \e -out dsap.pem -pkeyopt dsa_paramgen_bits:1024 .Ed .Pp Generate a DSA key from parameters: .Bd -literal -offset indent $ openssl genpkey -paramfile dsap.pem -out dsakey.pem .Ed .Pp Generate 1024-bit DH parameters: .Bd -literal -offset indent $ openssl genpkey -genparam -algorithm DH \e -out dhp.pem -pkeyopt dh_paramgen_prime_len:1024 .Ed .Pp Generate a DH key from parameters: .Bd -literal -offset indent $ openssl genpkey -paramfile dhp.pem -out dhkey.pem .Ed .\" .\" GENRSA .\" .Sh GENRSA .nr nS 1 .Nm "openssl genrsa" .Bk -words .Op Fl 3 | f4 .Oo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Oc .Op Fl engine Ar id .Op Fl out Ar file .Op Fl passout Ar arg .Op Ar numbits .Ek .nr nS 0 .Pp The .Nm genrsa command generates an RSA private key. .Pp The options are as follows: .Bl -tag -width Ds .It Fl 3 | f4 The public exponent to use, either 3 or 65537. The default is 65537. .It Xo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Xc These options encrypt the private key with the AES, DES, or the triple DES ciphers, respectively, before outputting it. If none of these options are specified, no encryption is used. If encryption is used, a pass phrase is prompted for, if it is not supplied via the .Fl passout option. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm genrsa to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl out Ar file The output .Ar file . If this argument is not specified, standard output is used. .It Fl passout Ar arg The output file password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Ar numbits The size of the private key to generate in bits. This must be the last option specified. The default is 2048. .El .Sh GENRSA NOTES RSA private key generation essentially involves the generation of two prime numbers. When generating a private key, various symbols will be output to indicate the progress of the generation. A .Sq \&. represents each number which has passed an initial sieve test; .Sq + means a number has passed a single round of the Miller-Rabin primality test. A newline means that the number has passed all the prime tests .Pq the actual number depends on the key size . .Pp Because key generation is a random process, the time taken to generate a key may vary somewhat. .Sh GENRSA BUGS A quirk of the prime generation algorithm is that it cannot generate small primes. Therefore the number of bits should not be less that 64. For typical private keys this will not matter because for security reasons they will be much larger .Pq typically 2048 bits . .\" .\" NSEQ .\" .Sh NSEQ .Nm openssl nseq .Op Fl in Ar file .Op Fl out Ar file .Op Fl toseq .Pp The .Nm nseq command takes a file containing a Netscape certificate sequence and prints out the certificates contained in it or takes a file of certificates and converts it into a Netscape certificate sequence. .Pp The options are as follows: .Bl -tag -width Ds .It Fl in Ar file This specifies the input .Ar file to read, or standard input if this option is not specified. .It Fl out Ar file Specifies the output .Ar file , or standard output by default. .It Fl toseq Normally, a Netscape certificate sequence will be input and the output is the certificates contained in it. With the .Fl toseq option the situation is reversed: a Netscape certificate sequence is created from a file of certificates. .El .Sh NSEQ EXAMPLES Output the certificates in a Netscape certificate sequence: .Bd -literal -offset indent $ openssl nseq -in nseq.pem -out certs.pem .Ed .Pp Create a Netscape certificate sequence: .Bd -literal -offset indent $ openssl nseq -in certs.pem -toseq -out nseq.pem .Ed .Sh NSEQ NOTES The PEM-encoded form uses the same headers and footers as a certificate: .Bd -unfilled -offset indent -----BEGIN CERTIFICATE----- -----END CERTIFICATE----- .Ed .Pp A Netscape certificate sequence is a Netscape specific form that can be sent to browsers as an alternative to the standard PKCS#7 format when several certificates are sent to the browser: for example during certificate enrollment. It is used by the Netscape certificate server, for example. .Sh NSEQ BUGS This program needs a few more options, like allowing DER or PEM input and output files and allowing multiple certificate files to be used. .\" .\" OCSP .\" .Sh OCSP .nr nS 1 .Nm "openssl ocsp" .Bk -words .Op Fl CA Ar file .Op Fl CAfile Ar file .Op Fl CApath Ar directory .Op Fl cert Ar file .Op Fl dgst Ar alg .Oo .Fl host .Ar hostname : Ns Ar port .Oc .Op Fl index Ar indexfile .Op Fl issuer Ar file .Op Fl ndays Ar days .Op Fl nmin Ar minutes .Op Fl no_cert_checks .Op Fl no_cert_verify .Op Fl no_certs .Op Fl no_chain .Op Fl no_intern .Op Fl no_nonce .Op Fl no_signature_verify .Op Fl nonce .Op Fl noverify .Op Fl nrequest Ar number .Op Fl out Ar file .Op Fl path Ar path .Op Fl port Ar portnum .Op Fl req_text .Op Fl reqin Ar file .Op Fl reqout Ar file .Op Fl resp_key_id .Op Fl resp_no_certs .Op Fl resp_text .Op Fl respin Ar file .Op Fl respout Ar file .Op Fl rkey Ar file .Op Fl rother Ar file .Op Fl rsigner Ar file .Op Fl serial Ar number .Op Fl sign_other Ar file .Op Fl signer Ar file .Op Fl signkey Ar file .Op Fl status_age Ar age .Op Fl text .Op Fl trust_other .Op Fl url Ar responder_url .Op Fl VAfile Ar file .Op Fl validity_period Ar nsec .Op Fl verify_other Ar file .Ek .nr nS 0 .Pp The Online Certificate Status Protocol .Pq OCSP enables applications to determine the .Pq revocation state of an identified certificate .Pq RFC 2560 . .Pp The .Nm ocsp command performs many common OCSP tasks. It can be used to print out requests and responses, create requests and send queries to an OCSP responder, and behave like a mini OCSP server itself. .Pp The options are as follows: .Bl -tag -width Ds .It Fl CAfile Ar file , Fl CApath Ar directory .Ar file or .Ar path containing trusted CA certificates. These are used to verify the signature on the OCSP response. .It Fl cert Ar file Add the certificate .Ar file to the request. The issuer certificate is taken from the previous .Fl issuer option, or an error occurs if no issuer certificate is specified. .It Fl dgst Ar alg Sets the digest algorithm to use for certificate identification in the OCSP request. By default SHA-1 is used. .It Xo .Fl host Ar hostname : Ns Ar port , .Fl path Ar path .Xc If the .Fl host option is present, then the OCSP request is sent to the host .Ar hostname on port .Ar port . .Fl path specifies the HTTP path name to use, or .Sq / by default. .It Fl issuer Ar file This specifies the current issuer certificate. This option can be used multiple times. The certificate specified in .Ar file must be in PEM format. This option .Em must come before any .Fl cert options. .It Fl no_cert_checks Don't perform any additional checks on the OCSP response signer's certificate. That is, do not make any checks to see if the signer's certificate is authorised to provide the necessary status information: as a result this option should only be used for testing purposes. .It Fl no_cert_verify Don't verify the OCSP response signer's certificate at all. Since this option allows the OCSP response to be signed by any certificate, it should only be used for testing purposes. .It Fl no_certs Don't include any certificates in signed request. .It Fl no_chain Do not use certificates in the response as additional untrusted CA certificates. .It Fl no_intern Ignore certificates contained in the OCSP response when searching for the signer's certificate. With this option, the signer's certificate must be specified with either the .Fl verify_other or .Fl VAfile options. .It Fl no_signature_verify Don't check the signature on the OCSP response. Since this option tolerates invalid signatures on OCSP responses, it will normally only be used for testing purposes. .It Fl nonce , no_nonce Add an OCSP .Em nonce extension to a request or disable an OCSP .Em nonce addition. Normally, if an OCSP request is input using the .Fl respin option no .Em nonce is added: using the .Fl nonce option will force addition of a .Em nonce . If an OCSP request is being created (using the .Fl cert and .Fl serial options) a .Em nonce is automatically added; specifying .Fl no_nonce overrides this. .It Fl noverify Don't attempt to verify the OCSP response signature or the .Em nonce values. This option will normally only be used for debugging since it disables all verification of the responder's certificate. .It Fl out Ar file Specify output .Ar file ; default is standard output. .It Fl req_text , resp_text , text Print out the text form of the OCSP request, response, or both, respectively. .It Fl reqin Ar file , Fl respin Ar file Read an OCSP request or response file from .Ar file . These options are ignored if an OCSP request or response creation is implied by other options (for example with the .Fl serial , cert , and .Fl host options). .It Fl reqout Ar file , Fl respout Ar file Write out the DER-encoded certificate request or response to .Ar file . .It Fl serial Ar num Same as the .Fl cert option except the certificate with serial number .Ar num is added to the request. The serial number is interpreted as a decimal integer unless preceded by .Sq 0x . Negative integers can also be specified by preceding the value with a .Sq - sign. .It Fl sign_other Ar file Additional certificates to include in the signed request. .It Fl signer Ar file , Fl signkey Ar file Sign the OCSP request using the certificate specified in the .Fl signer option and the private key specified by the .Fl signkey option. If the .Fl signkey option is not present, then the private key is read from the same file as the certificate. If neither option is specified, the OCSP request is not signed. .It Fl trust_other The certificates specified by the .Fl verify_other option should be explicitly trusted and no additional checks will be performed on them. This is useful when the complete responder certificate chain is not available or trusting a root CA is not appropriate. .It Fl url Ar responder_url Specify the responder URL. Both HTTP and HTTPS .Pq SSL/TLS URLs can be specified. .It Fl VAfile Ar file .Ar file containing explicitly trusted responder certificates. Equivalent to the .Fl verify_other and .Fl trust_other options. .It Fl validity_period Ar nsec , Fl status_age Ar age These options specify the range of times, in seconds, which will be tolerated in an OCSP response. Each certificate status response includes a .Em notBefore time and an optional .Em notAfter time. The current time should fall between these two values, but the interval between the two times may be only a few seconds. In practice the OCSP responder and clients' clocks may not be precisely synchronised and so such a check may fail. To avoid this the .Fl validity_period option can be used to specify an acceptable error range in seconds, the default value is 5 minutes. .Pp If the .Em notAfter time is omitted from a response, then this means that new status information is immediately available. In this case the age of the .Em notBefore field is checked to see it is not older than .Ar age seconds old. By default, this additional check is not performed. .It Fl verify_other Ar file .Ar file containing additional certificates to search when attempting to locate the OCSP response signing certificate. Some responders omit the actual signer's certificate from the response; this option can be used to supply the necessary certificate in such cases. .El .Sh OCSP SERVER OPTIONS .Bl -tag -width "XXXX" .It Fl CA Ar file CA certificate corresponding to the revocation information in .Ar indexfile . .It Fl index Ar indexfile .Ar indexfile is a text index file in .Nm ca format containing certificate revocation information. .Pp If the .Fl index option is specified, the .Nm ocsp utility is in .Em responder mode, otherwise it is in .Em client mode. The request(s) the responder processes can be either specified on the command line (using the .Fl issuer and .Fl serial options), supplied in a file (using the .Fl respin option) or via external OCSP clients (if .Ar port or .Ar url is specified). .Pp If the .Fl index option is present, then the .Fl CA and .Fl rsigner options must also be present. .It Fl nmin Ar minutes , Fl ndays Ar days Number of .Ar minutes or .Ar days when fresh revocation information is available: used in the .Ar nextUpdate field. If neither option is present, the .Em nextUpdate field is omitted, meaning fresh revocation information is immediately available. .It Fl nrequest Ar number The OCSP server will exit after receiving .Ar number requests, default unlimited. .It Fl port Ar portnum Port to listen for OCSP requests on. The port may also be specified using the .Fl url option. .It Fl resp_key_id Identify the signer certificate using the key ID; default is to use the subject name. .It Fl resp_no_certs Don't include any certificates in the OCSP response. .It Fl rkey Ar file The private key to sign OCSP responses with; if not present, the file specified in the .Fl rsigner option is used. .It Fl rother Ar file Additional certificates to include in the OCSP response. .It Fl rsigner Ar file The certificate to sign OCSP responses with. .El .Sh OCSP RESPONSE VERIFICATION OCSP Response follows the rules specified in RFC 2560. .Pp Initially the OCSP responder certificate is located and the signature on the OCSP request checked using the responder certificate's public key. .Pp Then a normal certificate verify is performed on the OCSP responder certificate building up a certificate chain in the process. The locations of the trusted certificates used to build the chain can be specified by the .Fl CAfile and .Fl CApath options or they will be looked for in the standard .Nm OpenSSL certificates directory. .Pp If the initial verify fails, the OCSP verify process halts with an error. .Pp Otherwise the issuing CA certificate in the request is compared to the OCSP responder certificate: if there is a match then the OCSP verify succeeds. .Pp Otherwise the OCSP responder certificate's CA is checked against the issuing CA certificate in the request. If there is a match and the OCSPSigning extended key usage is present in the OCSP responder certificate, then the OCSP verify succeeds. .Pp Otherwise the root CA of the OCSP responder's CA is checked to see if it is trusted for OCSP signing. If it is, the OCSP verify succeeds. .Pp If none of these checks is successful, the OCSP verify fails. .Pp What this effectively means is that if the OCSP responder certificate is authorised directly by the CA it is issuing revocation information about .Pq and it is correctly configured , then verification will succeed. .Pp If the OCSP responder is a .Em global responder which can give details about multiple CAs and has its own separate certificate chain, then its root CA can be trusted for OCSP signing. For example: .Bd -literal -offset indent $ openssl x509 -in ocspCA.pem -addtrust OCSPSigning \e -out trustedCA.pem .Ed .Pp Alternatively, the responder certificate itself can be explicitly trusted with the .Fl VAfile option. .Sh OCSP NOTES As noted, most of the verify options are for testing or debugging purposes. Normally, only the .Fl CApath , CAfile and .Pq if the responder is a `global VA' .Fl VAfile options need to be used. .Pp The OCSP server is only useful for test and demonstration purposes: it is not really usable as a full OCSP responder. It contains only a very simple HTTP request handling and can only handle the POST form of OCSP queries. It also handles requests serially, meaning it cannot respond to new requests until it has processed the current one. The text index file format of revocation is also inefficient for large quantities of revocation data. .Pp It is possible to run the .Nm ocsp application in .Em responder mode via a CGI script using the .Fl respin and .Fl respout options. .Sh OCSP EXAMPLES Create an OCSP request and write it to a file: .Bd -literal -offset indent $ openssl ocsp -issuer issuer.pem -cert c1.pem -cert c2.pem \e -reqout req.der .Ed .Pp Send a query to an OCSP responder with URL .Pa http://ocsp.myhost.com/ , save the response to a file and print it out in text form: .Bd -literal -offset indent $ openssl ocsp -issuer issuer.pem -cert c1.pem -cert c2.pem \e -url http://ocsp.myhost.com/ -resp_text -respout resp.der .Ed .Pp Read in an OCSP response and print out in text form: .Pp .Dl $ openssl ocsp -respin resp.der -text .Pp OCSP server on port 8888 using a standard .Nm ca configuration, and a separate responder certificate. All requests and responses are printed to a file: .Bd -literal -offset indent $ openssl ocsp -index demoCA/index.txt -port 8888 -rsigner \e rcert.pem -CA demoCA/cacert.pem -text -out log.txt .Ed .Pp As above, but exit after processing one request: .Bd -literal -offset indent $ openssl ocsp -index demoCA/index.txt -port 8888 -rsigner \e rcert.pem -CA demoCA/cacert.pem -nrequest 1 .Ed .Pp Query status information using internally generated request: .Bd -literal -offset indent $ openssl ocsp -index demoCA/index.txt -rsigner rcert.pem -CA \e demoCA/cacert.pem -issuer demoCA/cacert.pem -serial 1 .Ed .Pp Query status information using request read from a file and write the response to a second file: .Bd -literal -offset indent $ openssl ocsp -index demoCA/index.txt -rsigner rcert.pem -CA \e demoCA/cacert.pem -reqin req.der -respout resp.der .Ed .\" .\" PASSWD .\" .Sh PASSWD .nr nS 1 .Nm "openssl passwd" .Op Fl 1 | apr1 | crypt .Op Fl in Ar file .Op Fl noverify .Op Fl quiet .Op Fl reverse .Op Fl salt Ar string .Op Fl stdin .Op Fl table .Op Ar password .nr nS 0 .Pp The .Nm passwd command computes the hash of a password typed at run-time or the hash of each password in a list. The password list is taken from the named .Ar file for option .Fl in , from stdin for option .Fl stdin , or from the command line, or from the terminal otherwise. The .Ux standard algorithm .Em crypt and the MD5-based .Bx password algorithm .Em 1 and its Apache variant .Em apr1 are available. .Pp The options are as follows: .Bl -tag -width Ds .It Fl 1 Use the MD5 based .Bx password algorithm .Em 1 . .It Fl apr1 Use the .Em apr1 algorithm .Pq Apache variant of the .Bx algorithm. .It Fl crypt Use the .Em crypt algorithm .Pq default . .It Fl in Ar file Read passwords from .Ar file . .It Fl noverify Don't verify when reading a password from the terminal. .It Fl quiet Don't output warnings when passwords given on the command line are truncated. .It Fl reverse Switch table columns. This only makes sense in conjunction with the .Fl table option. .It Fl salt Ar string Use the specified .Ar salt . When reading a password from the terminal, this implies .Fl noverify . .It Fl stdin Read passwords from .Em stdin . .It Fl table In the output list, prepend the cleartext password and a TAB character to each password hash. .El .Sh PASSWD EXAMPLES .Dl $ openssl passwd -crypt -salt xx password prints .Qq xxj31ZMTZzkVA . .Pp .Dl $ openssl passwd -1 -salt xxxxxxxx password prints .Qq $1$xxxxxxxx$UYCIxa628.9qXjpQCjM4a. . .Pp .Dl $ openssl passwd -apr1 -salt xxxxxxxx password prints .Qq $apr1$xxxxxxxx$dxHfLAsjHkDRmG83UXe8K0 . .\" .\" PKCS7 .\" .Sh PKCS7 .nr nS 1 .Nm "openssl pkcs7" .Bk -words .Op Fl engine Ar id .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl print_certs .Op Fl text .Ek .nr nS 0 .Pp The .Nm pkcs7 command processes PKCS#7 files in DER or PEM format. .Pp The options are as follows: .Bl -tag -width Ds .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm pkcs7 to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl in Ar file This specifies the input .Ar file to read from, or standard input if this option is not specified. .It Fl inform Ar DER | PEM This specifies the input format. .Ar DER format is a DER-encoded PKCS#7 v1.5 structure. .Ar PEM .Pq the default is a base64-encoded version of the DER form with header and footer lines. .It Fl noout Don't output the encoded version of the PKCS#7 structure (or certificates if .Fl print_certs is set). .It Fl out Ar file Specifies the output .Ar file to write to, or standard output by default. .It Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. .It Fl print_certs Prints out any certificates or CRLs contained in the file. They are preceded by their subject and issuer names in a one-line format. .It Fl text Prints out certificate details in full rather than just subject and issuer names. .El .Sh PKCS7 EXAMPLES Convert a PKCS#7 file from PEM to DER: .Pp .Dl $ openssl pkcs7 -in file.pem -outform DER -out file.der .Pp Output all certificates in a file: .Pp .Dl $ openssl pkcs7 -in file.pem -print_certs -out certs.pem .Sh PKCS7 NOTES The PEM PKCS#7 format uses the header and footer lines: .Bd -unfilled -offset indent -----BEGIN PKCS7----- -----END PKCS7----- .Ed .Pp For compatibility with some CAs it will also accept: .Bd -unfilled -offset indent -----BEGIN CERTIFICATE----- -----END CERTIFICATE----- .Ed .Sh PKCS7 RESTRICTIONS There is no option to print out all the fields of a PKCS#7 file. .Pp The PKCS#7 routines only understand PKCS#7 v 1.5 as specified in RFC 2315. They cannot currently parse, for example, the new CMS as described in RFC 2630. .\" .\" PKCS8 .\" .Sh PKCS8 .nr nS 1 .Nm "openssl pkcs8" .Bk -words .Op Fl embed .Op Fl engine Ar id .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl nocrypt .Op Fl noiter .Op Fl nooct .Op Fl nsdb .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl passin Ar arg .Op Fl passout Ar arg .Op Fl topk8 .Op Fl v1 Ar alg .Op Fl v2 Ar alg .Ek .nr nS 0 .Pp The .Nm pkcs8 command processes private keys in PKCS#8 format. It can handle both unencrypted PKCS#8 PrivateKeyInfo format and EncryptedPrivateKeyInfo format with a variety of PKCS#5 .Pq v1.5 and v2.0 and PKCS#12 algorithms. .Pp The options are as follows: .Bl -tag -width Ds .It Fl embed This option generates DSA keys in a broken format. The DSA parameters are embedded inside the .Em PrivateKey structure. In this form the OCTET STRING contains an ASN1 SEQUENCE consisting of two structures: a SEQUENCE containing the parameters and an ASN1 INTEGER containing the private key. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm pkcs8 to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl in Ar file This specifies the input .Ar file to read a key from, or standard input if this option is not specified. If the key is encrypted, a pass phrase will be prompted for. .It Fl inform Ar DER | PEM This specifies the input format. If a PKCS#8 format key is expected on input, then either a DER- or PEM-encoded version of a PKCS#8 key will be expected. Otherwise the DER or PEM format of the traditional format private key is used. .It Fl nocrypt PKCS#8 keys generated or input are normally PKCS#8 .Em EncryptedPrivateKeyInfo structures using an appropriate password-based encryption algorithm. With this option, an unencrypted .Em PrivateKeyInfo structure is expected or output. This option does not encrypt private keys at all and should only be used when absolutely necessary. Certain software such as some versions of Java code signing software use unencrypted private keys. .It Fl noiter Use an iteration count of 1. See the .Sx PKCS12 section below for a detailed explanation of this option. .It Fl nooct This option generates RSA private keys in a broken format that some software uses. Specifically the private key should be enclosed in an OCTET STRING, but some software just includes the structure itself without the surrounding OCTET STRING. .It Fl nsdb This option generates DSA keys in a broken format compatible with Netscape private key databases. The .Em PrivateKey contains a SEQUENCE consisting of the public and private keys, respectively. .It Fl out Ar file This specifies the output .Ar file to write a key to, or standard output by default. If any encryption options are set, a pass phrase will be prompted for. The output filename should .Em not be the same as the input filename. .It Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. .It Fl passin Ar arg The key password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl passout Ar arg The output file password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl topk8 Normally, a PKCS#8 private key is expected on input and a traditional format private key will be written. With the .Fl topk8 option the situation is reversed: it reads a traditional format private key and writes a PKCS#8 format key. .It Fl v1 Ar alg This option specifies a PKCS#5 v1.5 or PKCS#12 algorithm to use. A complete list of possible algorithms is included below. .It Fl v2 Ar alg This option enables the use of PKCS#5 v2.0 algorithms. Normally, PKCS#8 private keys are encrypted with the password-based encryption algorithm called .Em pbeWithMD5AndDES-CBC ; this uses 56-bit DES encryption but it was the strongest encryption algorithm supported in PKCS#5 v1.5. Using the .Fl v2 option PKCS#5 v2.0 algorithms are used which can use any encryption algorithm such as 168-bit triple DES or 128-bit RC2, however not many implementations support PKCS#5 v2.0 yet. If using private keys with .Nm OpenSSL then this doesn't matter. .Pp The .Ar alg argument is the encryption algorithm to use; valid values include .Ar des , des3 , and .Ar rc2 . It is recommended that .Ar des3 is used. .El .Sh PKCS8 NOTES The encrypted form of a PEM-encoded PKCS#8 file uses the following headers and footers: .Bd -unfilled -offset indent -----BEGIN ENCRYPTED PRIVATE KEY----- -----END ENCRYPTED PRIVATE KEY----- .Ed .Pp The unencrypted form uses: .Bd -unfilled -offset indent -----BEGIN PRIVATE KEY----- -----END PRIVATE KEY----- .Ed .Pp Private keys encrypted using PKCS#5 v2.0 algorithms and high iteration counts are more secure than those encrypted using the traditional .Nm SSLeay compatible formats. So if additional security is considered important, the keys should be converted. .Pp The default encryption is only 56 bits because this is the encryption that most current implementations of PKCS#8 support. .Pp Some software may use PKCS#12 password-based encryption algorithms with PKCS#8 format private keys: these are handled automatically but there is no option to produce them. .Pp It is possible to write out DER-encoded encrypted private keys in PKCS#8 format because the encryption details are included at an ASN1 level whereas the traditional format includes them at a PEM level. .Sh PKCS#5 V1.5 AND PKCS#12 ALGORITHMS Various algorithms can be used with the .Fl v1 command line option, including PKCS#5 v1.5 and PKCS#12. These are described in more detail below. .Pp .Bl -tag -width "XXXX" -compact .It Ar PBE-MD2-DES | PBE-MD5-DES These algorithms were included in the original PKCS#5 v1.5 specification. They only offer 56 bits of protection since they both use DES. .Pp .It Ar PBE-SHA1-RC2-64 | PBE-MD2-RC2-64 | PBE-MD5-RC2-64 | PBE-SHA1-DES These algorithms are not mentioned in the original PKCS#5 v1.5 specification but they use the same key derivation algorithm and are supported by some software. They are mentioned in PKCS#5 v2.0. They use either 64-bit RC2 or 56-bit DES. .Pp .It Ar PBE-SHA1-RC4-128 | PBE-SHA1-RC4-40 | PBE-SHA1-3DES | PBE-SHA1-2DES .It Ar PBE-SHA1-RC2-128 | PBE-SHA1-RC2-40 These algorithms use the PKCS#12 password-based encryption algorithm and allow strong encryption algorithms like triple DES or 128-bit RC2 to be used. .El .Sh PKCS8 EXAMPLES Convert a private key from traditional to PKCS#5 v2.0 format using triple DES: .Pp .Dl "$ openssl pkcs8 -in key.pem -topk8 -v2 des3 -out enckey.pem" .Pp Convert a private key to PKCS#8 using a PKCS#5 1.5 compatible algorithm .Pq DES : .Pp .Dl $ openssl pkcs8 -in key.pem -topk8 -out enckey.pem .Pp Convert a private key to PKCS#8 using a PKCS#12 compatible algorithm .Pq 3DES : .Bd -literal -offset indent $ openssl pkcs8 -in key.pem -topk8 -out enckey.pem \e -v1 PBE-SHA1-3DES .Ed .Pp Read a DER-unencrypted PKCS#8 format private key: .Pp .Dl "$ openssl pkcs8 -inform DER -nocrypt -in key.der -out key.pem" .Pp Convert a private key from any PKCS#8 format to traditional format: .Pp .Dl $ openssl pkcs8 -in pk8.pem -out key.pem .Sh PKCS8 STANDARDS Test vectors from this PKCS#5 v2.0 implementation were posted to the pkcs-tng mailing list using triple DES, DES and RC2 with high iteration counts; several people confirmed that they could decrypt the private keys produced and therefore it can be assumed that the PKCS#5 v2.0 implementation is reasonably accurate at least as far as these algorithms are concerned. .Pp The format of PKCS#8 DSA .Pq and other private keys is not well documented: it is hidden away in PKCS#11 v2.01, section 11.9; .Nm OpenSSL Ns Li 's default DSA PKCS#8 private key format complies with this standard. .Sh PKCS8 BUGS There should be an option that prints out the encryption algorithm in use and other details such as the iteration count. .Pp PKCS#8 using triple DES and PKCS#5 v2.0 should be the default private key format; for .Nm OpenSSL compatibility, several of the utilities use the old format at present. .\" .\" PKCS12 .\" .Sh PKCS12 .nr nS 1 .Nm "openssl pkcs12" .Bk -words .Oo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Oc .Op Fl cacerts .Op Fl CAfile Ar file .Op Fl caname Ar name .Op Fl CApath Ar directory .Op Fl certfile Ar file .Op Fl certpbe Ar alg .Op Fl chain .Op Fl clcerts .Op Fl CSP Ar name .Op Fl descert .Op Fl engine Ar id .Op Fl export .Op Fl in Ar file .Op Fl info .Op Fl inkey Ar file .Op Fl keyex .Op Fl keypbe Ar alg .Op Fl keysig .Op Fl macalg Ar alg .Op Fl maciter .Op Fl name Ar name .Op Fl nocerts .Op Fl nodes .Op Fl noiter .Op Fl nokeys .Op Fl nomac .Op Fl nomaciter .Op Fl nomacver .Op Fl noout .Op Fl out Ar file .Op Fl passin Ar arg .Op Fl passout Ar arg .Op Fl twopass .Ek .nr nS 0 .Pp The .Nm pkcs12 command allows PKCS#12 files .Pq sometimes referred to as PFX files to be created and parsed. PKCS#12 files are used by several programs including Netscape, MSIE and MS Outlook. .Pp There are a lot of options; the meaning of some depends on whether a PKCS#12 file is being created or parsed. By default, a PKCS#12 file is parsed; a PKCS#12 file can be created by using the .Fl export option .Pq see below . .Sh PKCS12 PARSING OPTIONS .Bl -tag -width "XXXX" .It Xo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Xc Use AES, DES, or triple DES, respectively, to encrypt private keys before outputting. The default is triple DES. .It Fl cacerts Only output CA certificates .Pq not client certificates . .It Fl clcerts Only output client certificates .Pq not CA certificates . .It Fl in Ar file This specifies the .Ar file of the PKCS#12 file to be parsed. Standard input is used by default. .It Fl info Output additional information about the PKCS#12 file structure, algorithms used, and iteration counts. .It Fl nocerts No certificates at all will be output. .It Fl nodes Don't encrypt the private keys at all. .It Fl nokeys No private keys will be output. .It Fl nomacver Don't attempt to verify the integrity MAC before reading the file. .It Fl noout This option inhibits output of the keys and certificates to the output file version of the PKCS#12 file. .It Fl out Ar file The .Ar file to write certificates and private keys to, standard output by default. They are all written in PEM format. .It Fl passin Ar arg The key password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl passout Ar arg The output file password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl twopass Prompt for separate integrity and encryption passwords: most software always assumes these are the same so this option will render such PKCS#12 files unreadable. .El .Sh PKCS12 FILE CREATION OPTIONS .Bl -tag -width "XXXX" .It Fl CAfile Ar file CA storage as a file. .It Fl CApath Ar directory CA storage as a directory. This directory must be a standard certificate directory: that is, a hash of each subject name (using .Cm x509 -hash ) should be linked to each certificate. .It Fl caname Ar name This specifies the .Qq friendly name for other certificates. This option may be used multiple times to specify names for all certificates in the order they appear. Netscape ignores friendly names on other certificates, whereas MSIE displays them. .It Fl certfile Ar file A file to read additional certificates from. .It Fl certpbe Ar alg , Fl keypbe Ar alg These options allow the algorithm used to encrypt the private key and certificates to be selected. Any PKCS#5 v1.5 or PKCS#12 PBE algorithm name can be used (see the .Sx PKCS12 NOTES section for more information). If a cipher name (as output by the .Cm list-cipher-algorithms command) is specified then it is used with PKCS#5 v2.0. For interoperability reasons it is advisable to only use PKCS#12 algorithms. .It Fl chain If this option is present, an attempt is made to include the entire certificate chain of the user certificate. The standard CA store is used for this search. If the search fails, it is considered a fatal error. .It Fl CSP Ar name Write .Ar name as a Microsoft CSP name. .It Fl descert Encrypt the certificate using triple DES; this may render the PKCS#12 file unreadable by some .Qq export grade software. By default, the private key is encrypted using triple DES and the certificate using 40-bit RC2. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm pkcs12 to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl export This option specifies that a PKCS#12 file will be created rather than parsed. .It Fl in Ar file The .Ar file to read certificates and private keys from, standard input by default. They must all be in PEM format. The order doesn't matter but one private key and its corresponding certificate should be present. If additional certificates are present, they will also be included in the PKCS#12 file. .It Fl inkey Ar file File to read private key from. If not present, a private key must be present in the input file. .It Fl keyex | keysig Specifies that the private key is to be used for key exchange or just signing. This option is only interpreted by MSIE and similar MS software. Normally, .Qq export grade software will only allow 512-bit RSA keys to be used for encryption purposes, but arbitrary length keys for signing. The .Fl keysig option marks the key for signing only. Signing only keys can be used for S/MIME signing, authenticode .Pq ActiveX control signing and SSL client authentication; however, due to a bug only MSIE 5.0 and later support the use of signing only keys for SSL client authentication. .It Fl macalg Ar alg Specify the MAC digest algorithm. If not included then SHA1 is used. .It Fl maciter This option is included for compatibility with previous versions; it used to be needed to use MAC iterations counts but they are now used by default. .It Fl name Ar name This specifies the .Qq friendly name for the certificate and private key. This name is typically displayed in list boxes by software importing the file. .It Fl nomac Don't attempt to provide the MAC integrity. .It Fl nomaciter , noiter These options affect the iteration counts on the MAC and key algorithms. Unless you wish to produce files compatible with MSIE 4.0, you should leave these options alone. .Pp To discourage attacks by using large dictionaries of common passwords, the algorithm that derives keys from passwords can have an iteration count applied to it: this causes a certain part of the algorithm to be repeated and slows it down. The MAC is used to check the file integrity but since it will normally have the same password as the keys and certificates it could also be attacked. By default, both MAC and encryption iteration counts are set to 2048; using these options the MAC and encryption iteration counts can be set to 1. Since this reduces the file security you should not use these options unless you really have to. Most software supports both MAC and key iteration counts. MSIE 4.0 doesn't support MAC iteration counts, so it needs the .Fl nomaciter option. .It Fl out Ar file This specifies .Ar file to write the PKCS#12 file to. Standard output is used by default. .It Fl passin Ar arg The key password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl passout Ar arg The output file password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .El .Sh PKCS12 NOTES Although there are a large number of options, most of them are very rarely used. For PKCS#12 file parsing, only .Fl in and .Fl out need to be used for PKCS#12 file creation. .Fl export and .Fl name are also used. .Pp If none of the .Fl clcerts , cacerts , or .Fl nocerts options are present, then all certificates will be output in the order they appear in the input PKCS#12 files. There is no guarantee that the first certificate present is the one corresponding to the private key. Certain software which requires a private key and certificate and assumes the first certificate in the file is the one corresponding to the private key: this may not always be the case. Using the .Fl clcerts option will solve this problem by only outputting the certificate corresponding to the private key. If the CA certificates are required, they can be output to a separate file using the .Fl nokeys and .Fl cacerts options to just output CA certificates. .Pp The .Fl keypbe and .Fl certpbe algorithms allow the precise encryption algorithms for private keys and certificates to be specified. Normally, the defaults are fine but occasionally software can't handle triple DES encrypted private keys; then the option .Fl keypbe Ar PBE-SHA1-RC2-40 can be used to reduce the private key encryption to 40-bit RC2. A complete description of all algorithms is contained in the .Sx PKCS8 section above. .Sh PKCS12 EXAMPLES Parse a PKCS#12 file and output it to a file: .Pp .Dl $ openssl pkcs12 -in file.p12 -out file.pem .Pp Output only client certificates to a file: .Pp .Dl $ openssl pkcs12 -in file.p12 -clcerts -out file.pem .Pp Don't encrypt the private key: .Pp .Dl $ openssl pkcs12 -in file.p12 -out file.pem -nodes .Pp Print some info about a PKCS#12 file: .Pp .Dl $ openssl pkcs12 -in file.p12 -info -noout .Pp Create a PKCS#12 file: .Bd -literal -offset indent $ openssl pkcs12 -export -in file.pem -out file.p12 \e -name "My Certificate" .Ed .Pp Include some extra certificates: .Bd -literal -offset indent $ openssl pkcs12 -export -in file.pem -out file.p12 \e -name "My Certificate" -certfile othercerts.pem .Ed .Sh PKCS12 BUGS Some would argue that the PKCS#12 standard is one big bug :\-) .Pp Versions of .Nm OpenSSL before 0.9.6a had a bug in the PKCS#12 key generation routines. Under rare circumstances this could produce a PKCS#12 file encrypted with an invalid key. As a result some PKCS#12 files which triggered this bug from other implementations .Pq MSIE or Netscape could not be decrypted by .Nm OpenSSL and similarly .Nm OpenSSL could produce PKCS#12 files which could not be decrypted by other implementations. The chances of producing such a file are relatively small: less than 1 in 256. .Pp A side effect of fixing this bug is that any old invalidly encrypted PKCS#12 files can no longer be parsed by the fixed version. Under such circumstances the .Nm pkcs12 utility will report that the MAC is OK but fail with a decryption error when extracting private keys. .Pp This problem can be resolved by extracting the private keys and certificates from the PKCS#12 file using an older version of .Nm OpenSSL and recreating the PKCS#12 file from the keys and certificates using a newer version of .Nm OpenSSL . For example: .Bd -literal -offset indent $ old-openssl -in bad.p12 -out keycerts.pem $ openssl -in keycerts.pem -export -name "My PKCS#12 file" \e -out fixed.p12 .Ed .\" .\" PKEY .\" .Sh PKEY .nr nS 1 .Nm "openssl pkey" .Bk -words .Op Ar cipher .Op Fl engine Ar id .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl passin Ar arg .Op Fl passout Ar arg .Op Fl pubin .Op Fl pubout .Op Fl text .Op Fl text_pub .Ek .nr nS 0 .Pp The .Nm pkey command processes public or private keys. They can be converted between various forms and their components printed out. .Pp The options are as follows: .Bl -tag -width Ds .It Ar cipher These options encrypt the private key with the supplied cipher. Any algorithm name accepted by .Fn EVP_get_cipherbyname is acceptable, such as .Cm des3 . .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm pkey to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl in Ar file This specifies the input filename to read a key from, or standard input if this option is not specified. If the key is encrypted a pass phrase will be prompted for. .It Fl inform Ar DER | PEM This specifies the input format, DER or PEM. .It Fl noout Do not output the encoded version of the key. .It Fl out Ar file This specifies the output filename to write a key to, or standard output if this option is not specified. If any encryption options are set then a pass phrase will be prompted for. The output filename should .Em not be the same as the input filename. .It Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. .It Fl passin Ar arg The key password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl passout Ar arg The output file password source. For more information about the format of .Ar arg see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl pubin By default a private key is read from the input file: with this option a public key is read instead. .It Fl pubout By default a private key is output: with this option a public key will be output instead. This option is automatically set if the input is a public key. .It Fl text Print out the various public or private key components in plain text in addition to the encoded version. .It Fl text_pub Print out only public key components even if a private key is being processed. .El .Sh PKEY EXAMPLES To remove the pass phrase on an RSA private key: .Bd -literal -offset indent $ openssl pkey -in key.pem -out keyout.pem .Ed .Pp To encrypt a private key using triple DES: .Bd -literal -offset indent $ openssl pkey -in key.pem -des3 -out keyout.pem .Ed .Pp To convert a private key from PEM to DER format: .Bd -literal -offset indent $ openssl pkey -in key.pem -outform DER -out keyout.der .Ed .Pp To print the components of a private key to standard output: .Bd -literal -offset indent $ openssl pkey -in key.pem -text -noout .Ed .Pp To print the public components of a private key to standard output: .Bd -literal -offset indent $ openssl pkey -in key.pem -text_pub -noout .Ed .Pp To just output the public part of a private key: .Bd -literal -offset indent $ openssl pkey -in key.pem -pubout -out pubkey.pem .Ed .\" .\" PKEYPARAM .\" .Sh PKEYPARAM .Cm openssl pkeyparam .Op Fl engine Ar id .Op Fl in Ar file .Op Fl noout .Op Fl out Ar file .Op Fl text .Pp The .Nm pkey command processes public or private keys. They can be converted between various forms and their components printed out. .Pp The options are as follows: .Bl -tag -width Ds .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm pkeyparam to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl in Ar file This specifies the input filename to read parameters from, or standard input if this option is not specified. .It Fl noout Do not output the encoded version of the parameters. .It Fl out Ar file This specifies the output filename to write parameters to, or standard output if this option is not specified. .It Fl text Prints out the parameters in plain text in addition to the encoded version. .El .Sh PKEYPARAM EXAMPLES Print out text version of parameters: .Bd -literal -offset indent $ openssl pkeyparam -in param.pem -text .Ed .Sh PKEYPARAM NOTES There are no .Fl inform or .Fl outform options for this command because only PEM format is supported because the key type is determined by the PEM headers. .\" .\" PKEYUTL .\" .Sh PKEYUTL .nr nS 1 .Nm "openssl pkeyutl" .Bk -words .Op Fl asn1parse .Op Fl certin .Op Fl decrypt .Op Fl derive .Op Fl encrypt .Op Fl engine Ar id .Op Fl hexdump .Op Fl in Ar file .Op Fl inkey Ar file .Op Fl keyform Ar DER | ENGINE | PEM .Op Fl out Ar file .Op Fl passin Ar arg .Op Fl peerform Ar DER | ENGINE | PEM .Op Fl peerkey Ar file .Op Fl pkeyopt Ar opt : Ns Ar value .Op Fl pubin .Op Fl rev .Op Fl sigfile Ar file .Op Fl sign .Op Fl verify .Op Fl verifyrecover .Ek .nr nS 0 .Pp The .Nm pkeyutl command can be used to perform public key operations using any supported algorithm. .Pp The options are as follows: .Bl -tag -width Ds .It Fl asn1parse ASN1parse the output data. This is useful when combined with the .Fl verifyrecover option when an ASN1 structure is signed. .It Fl certin The input is a certificate containing a public key. .It Fl decrypt Decrypt the input data using a private key. .It Fl derive Derive a shared secret using the peer key. .It Fl encrypt Encrypt the input data using a public key. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm pkeyutl to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl hexdump Hex dump the output data. .It Fl in Ar file Specify the input filename to read data from, or standard input if this option is not specified. .It Fl inkey Ar file The input key file. By default it should be a private key. .It Fl keyform Ar DER | ENGINE | PEM The key format DER, ENGINE, or PEM. .It Fl out Ar file Specify the output filename to write to, or standard output by default. .It Fl passin Ar arg The key password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl peerform Ar DER | ENGINE | PEM The peer key format DER, ENGINE, or PEM. .It Fl peerkey Ar file The peer key file, used by key derivation (agreement) operations. .It Fl pkeyopt Ar opt : Ns Ar value Public key options. .It Fl pubin The input file is a public key. .It Fl rev Reverse the order of the input buffer. This is useful for some libraries (such as CryptoAPI) which represent the buffer in little endian format. .It Fl sigfile Ar file Signature file (verify operation only). .It Fl sign Sign the input data and output the signed result. This requires a private key. .It Fl verify Verify the input data against the signature file and indicate if the verification succeeded or failed. .It Fl verifyrecover Verify the input data and output the recovered data. .El .Sh PKEYUTL NOTES The operations and options supported vary according to the key algorithm and its implementation. The .Nm OpenSSL operations and options are indicated below. .Pp Unless otherwise mentioned all algorithms support the .Ar digest : Ns Ar alg option which specifies the digest in use for sign, verify, and verifyrecover operations. The value .Ar alg should represent a digest name as used in the .Fn EVP_get_digestbyname function, for example .Cm sha1 . .Ss RSA algorithm The RSA algorithm supports the encrypt, decrypt, sign, verify, and verifyrecover operations in general. Some padding modes only support some of these operations however. .Bl -tag -width Ds .It rsa_padding_mode : Ns Ar mode This sets the RSA padding mode. Acceptable values for .Ar mode are .Cm pkcs1 for PKCS#1 padding; .Cm sslv3 for SSLv3 padding; .Cm none for no padding; .Cm oaep for OAEP mode; .Cm x931 for X9.31 mode; and .Cm pss for PSS. .Pp In PKCS#1 padding if the message digest is not set then the supplied data is signed or verified directly instead of using a DigestInfo structure. If a digest is set then a DigestInfo structure is used and its length must correspond to the digest type. .Pp For oeap mode only encryption and decryption is supported. .Pp For x931 if the digest type is set it is used to format the block data; otherwise the first byte is used to specify the X9.31 digest ID. Sign, verify, and verifyrecover can be performed in this mode. .Pp For pss mode only sign and verify are supported and the digest type must be specified. .It rsa_pss_saltlen : Ns Ar len For pss mode only this option specifies the salt length. Two special values are supported: -1 sets the salt length to the digest length. When signing -2 sets the salt length to the maximum permissible value. When verifying -2 causes the salt length to be automatically determined based on the PSS block structure. .El .Ss DSA algorithm The DSA algorithm supports the sign and verify operations. Currently there are no additional options other than .Ar digest . Only the SHA1 digest can be used and this digest is assumed by default. .Ss DH algorithm The DH algorithm supports the derive operation and no additional options. .Ss EC algorithm The EC algorithm supports the sign, verify, and derive operations. The sign and verify operations use ECDSA and derive uses ECDH. Currently there are no additional options other than .Ar digest . Only the SHA1 digest can be used and this digest is assumed by default. .Sh PKEYUTL EXAMPLES Sign some data using a private key: .Bd -literal -offset indent $ openssl pkeyutl -sign -in file -inkey key.pem -out sig .Ed .Pp Recover the signed data (e.g. if an RSA key is used): .Bd -literal -offset indent $ openssl pkeyutl -verifyrecover -in sig -inkey key.pem .Ed .Pp Verify the signature (e.g. a DSA key): .Bd -literal -offset indent $ openssl pkeyutl -verify -in file -sigfile sig \e -inkey key.pem .Ed .Pp Sign data using a message digest value (this is currently only valid for RSA): .Bd -literal -offset indent $ openssl pkeyutl -sign -in file -inkey key.pem \e -out sig -pkeyopt digest:sha256 .Ed .Pp Derive a shared secret value: .Bd -literal -offset indent $ openssl pkeyutl -derive -inkey key.pem \e -peerkey pubkey.pem -out secret .Ed .\" .\" PRIME .\" .Sh PRIME .Cm openssl prime .Op Fl bits Ar n .Op Fl checks Ar n .Op Fl generate .Op Fl hex .Op Fl safe .Ar p .Pp The .Nm prime command is used to generate prime numbers, or to check numbers for primality. Results are probabilistic: they have an exceedingly high likelihood of being correct, but are not guaranteed. .Pp The options are as follows: .Bl -tag -width Ds .It Fl bits Ar n Specify the number of bits in the generated prime number. Must be used in conjunction with .Fl generate . .It Fl checks Ar n Perform a Miller-Rabin probabilistic primality test with .Ar n iterations. The default is 20. .It Fl generate Generate a pseudo-random prime number. Must be used in conjunction with .Fl bits . .It Fl hex Output in hex format. .It Fl safe Generate only .Qq safe prime numbers (i.e. a prime p so that (p-1)/2 is also prime). .It Ar p Test if number .Ar p is prime. .El .\" .\" RAND .\" .Sh RAND .nr nS 1 .Nm "openssl rand" .Op Fl base64 .Op Fl engine Ar id .Op Fl hex .Op Fl out Ar file .Ar num .nr nS 0 .Pp The .Nm rand command outputs .Ar num pseudo-random bytes. .Pp The options are as follows: .Bl -tag -width Ds .It Fl base64 Perform .Em base64 encoding on the output. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm rand to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl hex Specify hexadecimal output. .It Fl out Ar file Write to .Ar file instead of standard output. .El .\" .\" REQ .\" .Sh REQ .nr nS 1 .Nm "openssl req" .Bk -words .Op Fl asn1-kludge .Op Fl batch .Op Fl config Ar file .Op Fl days Ar n .Op Fl engine Ar id .Op Fl extensions Ar section .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl key Ar keyfile .Op Fl keyform Ar DER | PEM .Op Fl keyout Ar file .Op Fl md4 | md5 | sha1 .Op Fl modulus .Op Fl nameopt Ar option .Op Fl new .Op Fl newhdr .Op Fl newkey Ar arg .Op Fl no-asn1-kludge .Op Fl nodes .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl passin Ar arg .Op Fl passout Ar arg .Op Fl pubkey .Op Fl reqexts Ar section .Op Fl reqopt Ar option .Op Fl set_serial Ar n .Op Fl subj Ar arg .Op Fl subject .Op Fl text .Op Fl utf8 .Op Fl verbose .Op Fl verify .Op Fl x509 .Ek .nr nS 0 .Pp The .Nm req command primarily creates and processes certificate requests in PKCS#10 format. It can additionally create self-signed certificates, for use as root CAs, for example. .Pp The options are as follows: .Bl -tag -width Ds .It Fl asn1-kludge By default, the .Nm req command outputs certificate requests containing no attributes in the correct PKCS#10 format. However certain CAs will only accept requests containing no attributes in an invalid form: this option produces this invalid format. .Pp More precisely, the .Em Attributes in a PKCS#10 certificate request are defined as a SET OF Attribute. They are .Em not optional, so if no attributes are present then they should be encoded as an empty SET OF. The invalid form does not include the empty SET OF, whereas the correct form does. .Pp It should be noted that very few CAs still require the use of this option. .It Fl batch Non-interactive mode. .It Fl config Ar file This allows an alternative configuration file to be specified; this overrides the compile time filename or any specified in the .Ev OPENSSL_CONF environment variable. .It Fl days Ar n When the .Fl x509 option is being used, this specifies the number of days to certify the certificate for. The default is 30 days. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm req to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl extensions Ar section , Fl reqexts Ar section These options specify alternative sections to include certificate extensions (if the .Fl x509 option is present) or certificate request extensions. This allows several different sections to be used in the same configuration file to specify requests for a variety of purposes. .It Fl in Ar file This specifies the input .Ar file to read a request from, or standard input if this option is not specified. A request is only read if the creation options .Fl new and .Fl newkey are not specified. .It Fl inform Ar DER | PEM This specifies the input format. The .Ar DER argument uses an ASN1 DER-encoded form compatible with the PKCS#10. The .Ar PEM form is the default format: it consists of the DER format base64-encoded with additional header and footer lines. .It Fl key Ar keyfile This specifies the file to read the private key from. It also accepts PKCS#8 format private keys for PEM format files. .It Fl keyform Ar DER | PEM The format of the private key file specified in the .Fl key argument. .Ar PEM is the default. .It Fl keyout Ar file This gives the .Ar file to write the newly created private key to. If this option is not specified, the filename present in the configuration file is used. .It Fl md4 | md5 | sha1 This specifies the message digest to sign the request with. This overrides the digest algorithm specified in the configuration file. .Pp Some public key algorithms may override this choice. For instance, DSA signatures always use SHA1. .It Fl modulus This option prints out the value of the modulus of the public key contained in the request. .It Fl nameopt Ar option , Fl reqopt Ar option These options determine how the subject or issuer names are displayed. The .Ar option argument can be a single option or multiple options separated by commas. Alternatively, these options may be used more than once to set multiple options. See the .Sx X509 section below for details. .It Fl new This option generates a new certificate request. It will prompt the user for the relevant field values. The actual fields prompted for and their maximum and minimum sizes are specified in the configuration file and any requested extensions. .Pp If the .Fl key option is not used, it will generate a new RSA private key using information specified in the configuration file. .It Fl newhdr Adds the word NEW to the PEM file header and footer lines on the outputed request. Some software .Pq Netscape certificate server and some CAs need this. .It Fl newkey Ar arg This option creates a new certificate request and a new private key. The argument takes one of several forms. .Ar rsa : Ns Ar nbits , where .Ar nbits is the number of bits, generates an RSA key .Ar nbits in size. If .Ar nbits is omitted, i.e.\& .Cm -newkey rsa specified, the default key size, specified in the configuration file, is used. .Pp All other algorithms support the .Ar alg : Ns Ar file form, where file may be an algorithm parameter file, created by the .Cm genpkey -genparam command or an X.509 certificate for a key with approriate algorithm. .Pp .Ar param : Ns Ar file generates a key using the parameter file or certificate .Ar file ; the algorithm is determined by the parameters. .Ar algname : Ns Ar file use algorithm .Ar algname and parameter file .Ar file : the two algorithms must match or an error occurs. .Ar algname just uses algorithm .Ar algname , and parameters, if necessary, should be specified via the .Fl pkeyopt option. .Pp .Ar dsa : Ns Ar file generates a DSA key using the parameters in the file .Ar file . .It Fl no-asn1-kludge Reverses the effect of .Fl asn1-kludge . .It Fl nodes If this option is specified and a private key is created, it will not be encrypted. .It Fl noout This option prevents output of the encoded version of the request. .It Fl out Ar file This specifies the output .Ar file to write to, or standard output by default. .It Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. .It Fl passin Ar arg The key password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl passout Ar arg The output file password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl pubkey Outputs the public key. .It Fl reqopt Ar option Customise the output format used with .Fl text . The .Ar option argument can be a single option or multiple options separated by commas. .Pp See the discussion of the .Fl certopt option in the .Nm x509 command. .It Fl set_serial Ar n Serial number to use when outputting a self-signed certificate. This may be specified as a decimal value or a hex value if preceded by .Sq 0x . It is possible to use negative serial numbers but this is not recommended. .It Fl subj Ar arg Replaces subject field of input request with specified data and outputs modified request. The arg must be formatted as .Em /type0=value0/type1=value1/type2=... ; characters may be escaped by .Sq \e .Pq backslash ; no spaces are skipped. .It Fl subject Prints out the request subject (or certificate subject if .Fl x509 is specified. .It Fl text Prints out the certificate request in text form. .It Fl utf8 This option causes field values to be interpreted as UTF8 strings; by default they are interpreted as ASCII. This means that the field values, whether prompted from a terminal or obtained from a configuration file, must be valid UTF8 strings. .It Fl verbose Print extra details about the operations being performed. .It Fl verify Verifies the signature on the request. .It Fl x509 This option outputs a self-signed certificate instead of a certificate request. This is typically used to generate a test certificate or a self-signed root CA. The extensions added to the certificate .Pq if any are specified in the configuration file. Unless specified using the .Fl set_serial option, 0 will be used for the serial number. .El .Sh REQ CONFIGURATION FILE FORMAT The configuration options are specified in the .Em req section of the configuration file. As with all configuration files, if no value is specified in the specific section (i.e.\& .Em req ) then the initial unnamed or .Em default section is searched too. .Pp The options available are described in detail below. .Bl -tag -width "XXXX" .It Ar attributes This specifies the section containing any request attributes: its format is the same as .Ar distinguished_name . Typically these may contain the .Em challengePassword or .Em unstructuredName types. They are currently ignored by .Nm OpenSSL Ns Li 's request signing utilities, but some CAs might want them. .It Ar default_bits This specifies the default key size in bits. If not specified, 512 is used. It is used if the .Fl new option is used. It can be overridden by using the .Fl newkey option. .It Ar default_keyfile This is the default file to write a private key to. If not specified, the key is written to standard output. This can be overridden by the .Fl keyout option. .It Ar default_md This option specifies the digest algorithm to use. Possible values include .Ar md5 and .Ar sha1 . If not present, MD5 is used. This option can be overridden on the command line. .It Ar distinguished_name This specifies the section containing the distinguished name fields to prompt for when generating a certificate or certificate request. The format is described in the next section. .It Ar encrypt_key If this is set to .Em no and a private key is generated, it is .Em not encrypted. This is equivalent to the .Fl nodes command line option. For compatibility, .Ar encrypt_rsa_key is an equivalent option. .It Ar input_password | output_password The passwords for the input private key file .Pq if present and the output private key file .Pq if one will be created . The command line options .Fl passin and .Fl passout override the configuration file values. .It Ar oid_file This specifies a file containing additional OBJECT IDENTIFIERS. Each line of the file should consist of the numerical form of the object identifier, followed by whitespace, then the short name followed by whitespace and finally the long name. .It Ar oid_section This specifies a section in the configuration file containing extra object identifiers. Each line should consist of the short name of the object identifier followed by .Sq = and the numerical form. The short and long names are the same when this option is used. .It Ar prompt If set to the value .Em no , this disables prompting of certificate fields and just takes values from the config file directly. It also changes the expected format of the .Em distinguished_name and .Em attributes sections. .It Ar req_extensions This specifies the configuration file section containing a list of extensions to add to the certificate request. It can be overridden by the .Fl reqexts command line switch. .It Ar string_mask This option masks out the use of certain string types in certain fields. Most users will not need to change this option. .Pp It can be set to several values: .Ar default , which is also the default option, uses .Em PrintableStrings , T61Strings and .Em BMPStrings ; if the .Ar pkix value is used, then only .Em PrintableStrings and .Em BMPStrings will be used. This follows the PKIX recommendation in RFC 2459. If the .Fl utf8only option is used, then only .Em UTF8Strings will be used: this is the PKIX recommendation in RFC 2459 after 2003. Finally, the .Ar nombstr option just uses .Em PrintableStrings and .Em T61Strings : certain software has problems with .Em BMPStrings and .Em UTF8Strings : in particular Netscape. .It Ar utf8 If set to the value .Em yes , then field values are interpreted as UTF8 strings; by default they are interpreted as ASCII. This means that the field values, whether prompted from a terminal or obtained from a configuration file, must be valid UTF8 strings. .It Ar x509_extensions This specifies the configuration file section containing a list of extensions to add to a certificate generated when the .Fl x509 switch is used. It can be overridden by the .Fl extensions command line switch. .El .Sh REQ DISTINGUISHED NAME AND ATTRIBUTE SECTION FORMAT There are two separate formats for the distinguished name and attribute sections. If the .Fl prompt option is set to .Em no , then these sections just consist of field names and values: for example, .Bd -unfilled -offset indent CN=My Name OU=My Organization emailAddress=someone@somewhere.org .Ed .Pp This allows external programs .Pq e.g. GUI based to generate a template file with all the field names and values and just pass it to .Nm req . An example of this kind of configuration file is contained in the .Sx REQ EXAMPLES section. .Pp Alternatively if the .Fl prompt option is absent or not set to .Em no , then the file contains field prompting information. It consists of lines of the form: .Bd -unfilled -offset indent fieldName="prompt" fieldName_default="default field value" fieldName_min= 2 fieldName_max= 4 .Ed .Pp .Qq fieldName is the field name being used, for example .Em commonName .Pq or CN . The .Qq prompt string is used to ask the user to enter the relevant details. If the user enters nothing, the default value is used; if no default value is present, the field is omitted. A field can still be omitted if a default value is present, if the user just enters the .Sq \&. character. .Pp The number of characters entered must be between the .Em fieldName_min and .Em fieldName_max limits: there may be additional restrictions based on the field being used (for example .Em countryName can only ever be two characters long and must fit in a .Em PrintableString ) . .Pp Some fields (such as .Em organizationName ) can be used more than once in a DN. This presents a problem because configuration files will not recognize the same name occurring twice. To avoid this problem, if the .Em fieldName contains some characters followed by a full stop, they will be ignored. So, for example, a second .Em organizationName can be input by calling it .Qq 1.organizationName . .Pp The actual permitted field names are any object identifier short or long names. These are compiled into .Nm OpenSSL and include the usual values such as .Em commonName , countryName , localityName , organizationName , .Em organizationUnitName , stateOrProvinceName . Additionally, .Em emailAddress is included as well as .Em name , surname , givenName initials and .Em dnQualifier . .Pp Additional object identifiers can be defined with the .Ar oid_file or .Ar oid_section options in the configuration file. Any additional fields will be treated as though they were a .Em DirectoryString . .Sh REQ EXAMPLES Examine and verify a certificate request: .Pp .Dl $ openssl req -in req.pem -text -verify -noout .Pp Create a private key and then generate a certificate request from it: .Bd -literal -offset indent $ openssl genrsa -out key.pem 2048 $ openssl req -new -key key.pem -out req.pem .Ed .Pp The same but just using req: .Pp .Dl $ openssl req -newkey rsa:2048 -keyout key.pem -out req.pem .Pp Generate a self-signed root certificate: .Pp .Dl "$ openssl req -x509 -newkey rsa:2048 -keyout key.pem -out req.pem" .Pp Example of a file pointed to by the .Ar oid_file option: .Bd -unfilled -offset indent 1.2.3.4 shortName A longer Name 1.2.3.6 otherName Other longer Name .Ed .Pp Example of a section pointed to by .Ar oid_section making use of variable expansion: .Bd -unfilled -offset indent testoid1=1.2.3.5 testoid2=${testoid1}.6 .Ed .Pp Sample configuration file prompting for field values: .Bd -literal \& [ req ] \& default_bits = 1024 \& default_keyfile = privkey.pem \& distinguished_name = req_distinguished_name \& attributes = req_attributes \& x509_extensions = v3_ca \& dirstring_type = nobmp \& [ req_distinguished_name ] \& countryName = Country Name (2 letter code) \& countryName_default = AU \& countryName_min = 2 \& countryName_max = 2 \& localityName = Locality Name (eg, city) \& organizationalUnitName = Organizational Unit Name (eg, section) \& commonName = Common Name (eg, YOUR name) \& commonName_max = 64 \& emailAddress = Email Address \& emailAddress_max = 40 \& [ req_attributes ] \& challengePassword = A challenge password \& challengePassword_min = 4 \& challengePassword_max = 20 \& [ v3_ca ] \& subjectKeyIdentifier=hash \& authorityKeyIdentifier=keyid:always,issuer:always \& basicConstraints = CA:true .Ed .Pp Sample configuration containing all field values: .Bd -literal \& [ req ] \& default_bits = 1024 \& default_keyfile = keyfile.pem \& distinguished_name = req_distinguished_name \& attributes = req_attributes \& prompt = no \& output_password = mypass \& [ req_distinguished_name ] \& C = GB \& ST = Test State or Province \& L = Test Locality \& O = Organization Name \& OU = Organizational Unit Name \& CN = Common Name \& emailAddress = test@email.address \& [ req_attributes ] \& challengePassword = A challenge password .Ed .Sh REQ NOTES The header and footer lines in the PEM format are normally: .Bd -unfilled -offset indent -----BEGIN CERTIFICATE REQUEST----- -----END CERTIFICATE REQUEST----- .Ed .Pp Some software .Pq some versions of Netscape certificate server instead needs: .Bd -unfilled -offset indent -----BEGIN NEW CERTIFICATE REQUEST----- -----END NEW CERTIFICATE REQUEST----- .Ed .Pp which is produced with the .Fl newhdr option but is otherwise compatible. Either form is accepted transparently on input. .Pp The certificate requests generated by Xenroll with MSIE have extensions added. It includes the .Em keyUsage extension which determines the type of key .Pq signature only or general purpose and any additional OIDs entered by the script in an .Em extendedKeyUsage extension. .Sh REQ DIAGNOSTICS The following messages are frequently asked about: .Bd -unfilled -offset indent Using configuration from /some/path/openssl.cnf Unable to load config info .Ed .Pp This is followed some time later by... .Bd -unfilled -offset indent unable to find 'distinguished_name' in config problems making Certificate Request .Ed .Pp The first error message is the clue: it can't find the configuration file! Certain operations .Pq like examining a certificate request don't need a configuration file so its use isn't enforced. Generation of certificates or requests, however, do need a configuration file. This could be regarded as a bug. .Pp Another puzzling message is this: .Bd -unfilled -offset indent Attributes: a0:00 .Ed .Pp This is displayed when no attributes are present and the request includes the correct empty SET OF structure .Pq the DER encoding of which is 0xa0 0x00 . If you just see: .Pp .D1 Attributes: .Pp then the SET OF is missing and the encoding is technically invalid .Pq but it is tolerated . See the description of the command line option .Fl asn1-kludge for more information. .Sh REQ ENVIRONMENT VARIABLES The variable .Ev OPENSSL_CONF , if defined, allows an alternative configuration file location to be specified; it will be overridden by the .Fl config command line switch if it is present. For compatibility reasons the .Ev SSLEAY_CONF environment variable serves the same purpose but its use is discouraged. .Sh REQ BUGS .Nm OpenSSL Ns Li 's handling of T61Strings .Pq aka TeletexStrings is broken: it effectively treats them as ISO 8859-1 .Pq Latin 1 ; Netscape and MSIE have similar behaviour. This can cause problems if you need characters that aren't available in .Em PrintableStrings and you don't want to or can't use .Em BMPStrings . .Pp As a consequence of the T61String handling, the only correct way to represent accented characters in .Nm OpenSSL is to use a .Em BMPString : unfortunately Netscape currently chokes on these. If you have to use accented characters with Netscape and MSIE then you currently need to use the invalid T61String form. .Pp The current prompting is not very friendly. It doesn't allow you to confirm what you've just entered. Other things, like extensions in certificate requests, are statically defined in the configuration file. Some of these, like an email address in .Em subjectAltName , should be input by the user. .\" .\" RSA .\" .Sh RSA .nr nS 1 .Nm "openssl rsa" .Bk -words .Oo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Oc .Op Fl check .Op Fl engine Ar id .Op Fl in Ar file .Op Fl inform Ar DER | NET | PEM .Op Fl modulus .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar DER | NET | PEM .Op Fl passin Ar arg .Op Fl passout Ar arg .Op Fl pubin .Op Fl pubout .Op Fl sgckey .Op Fl text .nr nS 0 .Ek .Pp The .Nm rsa command processes RSA keys. They can be converted between various forms and their components printed out. .Pp .Sy Note : this command uses the traditional .Nm SSLeay compatible format for private key encryption: newer applications should use the more secure PKCS#8 format using the .Nm pkcs8 utility. .Pp The options are as follows: .Bl -tag -width Ds .It Xo .Fl aes128 | aes192 | aes256 | .Fl des | des3 .Xc These options encrypt the private key with the AES, DES, or the triple DES ciphers, respectively, before outputting it. A pass phrase is prompted for. If none of these options are specified, the key is written in plain text. This means that using the .Nm rsa utility to read in an encrypted key with no encryption option can be used to remove the pass phrase from a key, or by setting the encryption options it can be used to add or change the pass phrase. These options can only be used with PEM format output files. .It Fl check This option checks the consistency of an RSA private key. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm rsa to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl in Ar file This specifies the input .Ar file to read a key from, or standard input if this option is not specified. If the key is encrypted, a pass phrase will be prompted for. .It Fl inform Ar DER | NET | PEM This specifies the input format. The .Ar DER argument uses an ASN1 DER-encoded form compatible with the PKCS#1 RSAPrivateKey or SubjectPublicKeyInfo format. The .Ar PEM form is the default format: it consists of the DER format base64-encoded with additional header and footer lines. On input PKCS#8 format private keys are also accepted. The .Ar NET form is a format described in the .Sx RSA NOTES section. .It Fl noout This option prevents output of the encoded version of the key. .It Fl modulus This option prints out the value of the modulus of the key. .It Fl out Ar file This specifies the output .Ar file to write a key to, or standard output if this option is not specified. If any encryption options are set, a pass phrase will be prompted for. The output filename should .Em not be the same as the input filename. .It Fl outform Ar DER | NET | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. .It Fl passin Ar arg The key password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl passout Ar arg The output file password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl pubin By default, a private key is read from the input file; with this option a public key is read instead. .It Fl pubout By default, a private key is output; with this option a public key will be output instead. This option is automatically set if the input is a public key. .It Fl sgckey Use the modified .Em NET algorithm used with some versions of Microsoft IIS and SGC keys. .It Fl text Prints out the various public or private key components in plain text, in addition to the encoded version. .El .Sh RSA NOTES The PEM private key format uses the header and footer lines: .Bd -unfilled -offset indent -----BEGIN RSA PRIVATE KEY----- -----END RSA PRIVATE KEY----- .Ed .Pp The PEM public key format uses the header and footer lines: .Bd -unfilled -offset indent -----BEGIN PUBLIC KEY----- -----END PUBLIC KEY----- .Ed .Pp The .Em NET form is a format compatible with older Netscape servers and Microsoft IIS .key files; this uses unsalted RC4 for its encryption. It is not very secure and so should only be used when necessary. .Pp Some newer version of IIS have additional data in the exported .key files. To use these with the .Nm rsa utility, view the file with a binary editor and look for the string .Qq private-key , then trace back to the byte sequence 0x30, 0x82 .Pq this is an ASN1 SEQUENCE . Copy all the data from this point onwards to another file and use that as the input to the .Nm rsa utility with the .Fl inform Ar NET option. If there is an error after entering the password, try the .Fl sgckey option. .Sh RSA EXAMPLES To remove the pass phrase on an RSA private key: .Pp .Dl $ openssl rsa -in key.pem -out keyout.pem .Pp To encrypt a private key using triple DES: .Pp .Dl $ openssl rsa -in key.pem -des3 -out keyout.pem .Pp To convert a private key from PEM to DER format: .Pp .Dl $ openssl rsa -in key.pem -outform DER -out keyout.der .Pp To print out the components of a private key to standard output: .Pp .Dl $ openssl rsa -in key.pem -text -noout .Pp To just output the public part of a private key: .Pp .Dl $ openssl rsa -in key.pem -pubout -out pubkey.pem .Sh RSA BUGS The command line password arguments don't currently work with .Em NET format. .Pp There should be an option that automatically handles .key files, without having to manually edit them. .\" .\" RSAUTL .\" .Sh RSAUTL .nr nS 1 .Nm "openssl rsautl" .Bk -words .Op Fl asn1parse .Op Fl certin .Op Fl decrypt .Op Fl encrypt .Op Fl engine Ar id .Op Fl hexdump .Op Fl in Ar file .Op Fl inkey Ar file .Op Fl keyform Ar DER | PEM .Op Fl oaep | pkcs | raw | ssl .Op Fl out Ar file .Op Fl pubin .Op Fl sign .Op Fl verify .Ek .nr nS 0 .Pp The .Nm rsautl command can be used to sign, verify, encrypt and decrypt data using the RSA algorithm. .Pp The options are as follows: .Bl -tag -width Ds .It Fl asn1parse Asn1parse the output data; this is useful when combined with the .Fl verify option. .It Fl certin The input is a certificate containing an RSA public key. .It Fl decrypt Decrypt the input data using an RSA private key. .It Fl encrypt Encrypt the input data using an RSA public key. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm rsautl to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl hexdump Hex dump the output data. .It Fl in Ar file This specifies the input .Ar file to read data from, or standard input if this option is not specified. .It Fl inkey Ar file The input key file, by default it should be an RSA private key. .It Fl keyform Ar DER | PEM Private ket format. Default is .Ar PEM . .It Fl oaep | pkcs | raw | ssl The padding to use: PKCS#1 OAEP, PKCS#1 v1.5 .Pq the default , or no padding, respectively. For signatures, only .Fl pkcs and .Fl raw can be used. .It Fl out Ar file Specifies the output .Ar file to write to, or standard output by default. .It Fl pubin The input file is an RSA public key. .It Fl sign Sign the input data and output the signed result. This requires an RSA private key. .It Fl verify Verify the input data and output the recovered data. .El .Sh RSAUTL NOTES .Nm rsautl , because it uses the RSA algorithm directly, can only be used to sign or verify small pieces of data. .Sh RSAUTL EXAMPLES Sign some data using a private key: .Pp .Dl "$ openssl rsautl -sign -in file -inkey key.pem -out sig" .Pp Recover the signed data: .Pp .Dl $ openssl rsautl -verify -in sig -inkey key.pem .Pp Examine the raw signed data: .Pp .Li "\ \&$ openssl rsautl -verify -in file -inkey key.pem -raw -hexdump" .Bd -unfilled \& 0000 - 00 01 ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................ \& 0010 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................ \& 0020 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................ \& 0030 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................ \& 0040 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................ \& 0050 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................ \& 0060 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................ \& 0070 - ff ff ff ff 00 68 65 6c-6c 6f 20 77 6f 72 6c 64 .....hello world .Ed .Pp The PKCS#1 block formatting is evident from this. If this was done using encrypt and decrypt, the block would have been of type 2 .Pq the second byte and random padding data visible instead of the 0xff bytes. .Pp It is possible to analyse the signature of certificates using this utility in conjunction with .Nm asn1parse . Consider the self-signed example in .Pa certs/pca-cert.pem : running .Nm asn1parse as follows yields: .Pp .Li "\ \&$ openssl asn1parse -in pca-cert.pem" .Bd -unfilled \& 0:d=0 hl=4 l= 742 cons: SEQUENCE \& 4:d=1 hl=4 l= 591 cons: SEQUENCE \& 8:d=2 hl=2 l= 3 cons: cont [ 0 ] \& 10:d=3 hl=2 l= 1 prim: INTEGER :02 \& 13:d=2 hl=2 l= 1 prim: INTEGER :00 \& 16:d=2 hl=2 l= 13 cons: SEQUENCE \& 18:d=3 hl=2 l= 9 prim: OBJECT :md5WithRSAEncryption \& 29:d=3 hl=2 l= 0 prim: NULL \& 31:d=2 hl=2 l= 92 cons: SEQUENCE \& 33:d=3 hl=2 l= 11 cons: SET \& 35:d=4 hl=2 l= 9 cons: SEQUENCE \& 37:d=5 hl=2 l= 3 prim: OBJECT :countryName \& 42:d=5 hl=2 l= 2 prim: PRINTABLESTRING :AU \& .... \& 599:d=1 hl=2 l= 13 cons: SEQUENCE \& 601:d=2 hl=2 l= 9 prim: OBJECT :md5WithRSAEncryption \& 612:d=2 hl=2 l= 0 prim: NULL \& 614:d=1 hl=3 l= 129 prim: BIT STRING .Ed .Pp The final BIT STRING contains the actual signature. It can be extracted with: .Pp .Dl "$ openssl asn1parse -in pca-cert.pem -out sig -noout -strparse 614" .Pp The certificate public key can be extracted with: .Pp .Dl $ openssl x509 -in test/testx509.pem -pubkey -noout \*(Gtpubkey.pem .Pp The signature can be analysed with: .Pp .Li "\ \&$ openssl rsautl -in sig -verify -asn1parse -inkey pubkey.pem -pubin" .Bd -unfilled \& 0:d=0 hl=2 l= 32 cons: SEQUENCE \& 2:d=1 hl=2 l= 12 cons: SEQUENCE \& 4:d=2 hl=2 l= 8 prim: OBJECT :md5 \& 14:d=2 hl=2 l= 0 prim: NULL \& 16:d=1 hl=2 l= 16 prim: OCTET STRING \& 0000 - f3 46 9e aa 1a 4a 73 c9-37 ea 93 00 48 25 08 b5 .F...Js.7...H%.. .Ed .Pp This is the parsed version of an ASN1 .Em DigestInfo structure. It can be seen that the digest used was MD5. The actual part of the certificate that was signed can be extracted with: .Pp .Dl "$ openssl asn1parse -in pca-cert.pem -out tbs -noout -strparse 4" .Pp and its digest computed with: .Pp .Dl $ openssl md5 -c tbs .D1 MD5(tbs)= f3:46:9e:aa:1a:4a:73:c9:37:ea:93:00:48:25:08:b5 .Pp which it can be seen agrees with the recovered value above. .\" .\" S_CLIENT .\" .Sh S_CLIENT .nr nS 1 .Nm "openssl s_client" .Bk -words .Op Fl 4 | 6 .Op Fl bugs .Op Fl CAfile Ar file .Op Fl CApath Ar directory .Op Fl cert Ar file .Op Fl check_ss_sig .Op Fl cipher Ar cipherlist .Oo .Fl connect Ar host : Ns Ar port | .Ar host Ns / Ns Ar port .Oc .Op Fl crl_check .Op Fl crl_check_all .Op Fl crlf .Op Fl debug .Op Fl engine Ar id .Op Fl extended_crl .Op Fl ign_eof .Op Fl ignore_critical .Op Fl issuer_checks .Op Fl key Ar keyfile .Op Fl msg .Op Fl nbio .Op Fl nbio_test .Op Fl no_ssl3 .Op Fl no_ticket .Op Fl no_tls1 .Op Fl pause .Op Fl policy_check .Op Fl prexit .Op Fl psk Ar key .Op Fl psk_identity Ar identity .Op Fl quiet .Op Fl reconnect .Op Fl showcerts .Op Fl ssl3 .Op Fl starttls Ar protocol .Op Fl state .Op Fl tls1 .Op Fl tlsextdebug .Op Fl verify Ar depth .Op Fl x509_strict .Ek .nr nS 0 .Pp The .Nm s_client command implements a generic SSL/TLS client which connects to a remote host using SSL/TLS. It is a .Em very useful diagnostic tool for SSL servers. .Pp The options are as follows: .Bl -tag -width Ds .It Fl 4 Specify that .Nm s_client should attempt connections using IPv4 only. .It Fl 6 Specify that .Nm s_client should attempt connections using IPv6 only. .It Fl bugs There are several known bugs in SSL and TLS implementations. Adding this option enables various workarounds. .It Fl CAfile Ar file A .Ar file containing trusted certificates to use during server authentication and to use when attempting to build the client certificate chain. .It Fl CApath Ar directory The .Ar directory to use for server certificate verification. This directory must be in .Qq hash format ; see .Fl verify for more information. These are also used when building the client certificate chain. .It Fl cert Ar file The certificate to use, if one is requested by the server. The default is not to use a certificate. .It Xo .Fl check_ss_sig , .Fl crl_check , .Fl crl_check_all , .Fl extended_crl , .Fl ignore_critical , .Fl issuer_checks , .Fl policy_check , .Fl x509_strict .Xc Set various certificate chain validation options. See the .Nm VERIFY command for details. .It Fl cipher Ar cipherlist This allows the cipher list sent by the client to be modified. Although the server determines which cipher suite is used, it should take the first supported cipher in the list sent by the client. See the .Sx CIPHERS section above for more information. .It Xo .Fl connect Ar host : Ns Ar port | .Ar host Ns / Ns Ar port .Xc This specifies the .Ar host and optional .Ar port to connect to. If not specified, an attempt is made to connect to the local host on port 4433. Alternatively, the host and port pair may be separated using a forward-slash character. This form is useful for numeric IPv6 addresses. .It Fl crlf This option translates a line feed from the terminal into CR+LF as required by some servers. .It Fl debug Print extensive debugging information including a hex dump of all traffic. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm s_client to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl ign_eof Inhibit shutting down the connection when end of file is reached in the input. .It Fl key Ar keyfile The private key to use. If not specified, the certificate file will be used. .It Fl msg Show all protocol messages with hex dump. .It Fl nbio Turns on non-blocking I/O. .It Fl nbio_test Tests non-blocking I/O. .It Xo .Fl no_ssl3 | no_tls1 | .Fl ssl3 | tls1 .Xc These options disable the use of certain SSL or TLS protocols. By default, the initial handshake uses a method which should be compatible with all servers and permit them to use SSL v3 or TLS as appropriate. .Pp Unfortunately there are a lot of ancient and broken servers in use which cannot handle this technique and will fail to connect. Some servers only work if TLS is turned off with the .Fl no_tls option. .It Fl no_ticket Disable RFC 4507 session ticket support. .It Fl pause Pauses 1 second between each read and write call. .It Fl prexit Print session information when the program exits. This will always attempt to print out information even if the connection fails. Normally, information will only be printed out once if the connection succeeds. This option is useful because the cipher in use may be renegotiated or the connection may fail because a client certificate is required or is requested only after an attempt is made to access a certain URL. .Sy Note : the output produced by this option is not always accurate because a connection might never have been established. .It Fl psk Ar key Use the PSK key .Ar key when using a PSK cipher suite. The key is given as a hexadecimal number without the leading 0x, for example -psk 1a2b3c4d. .It Fl psk_identity Ar identity Use the PSK identity .Ar identity when using a PSK cipher suite. .It Fl quiet Inhibit printing of session and certificate information. This implicitly turns on .Fl ign_eof as well. .It Fl reconnect Reconnects to the same server 5 times using the same session ID; this can be used as a test that session caching is working. .It Fl showcerts Display the whole server certificate chain: normally only the server certificate itself is displayed. .It Fl starttls Ar protocol Send the protocol-specific message(s) to switch to TLS for communication. .Ar protocol is a keyword for the intended protocol. Currently, the supported keywords are .Qq ftp , .Qq imap , .Qq smtp , .Qq pop3 , and .Qq xmpp . .It Fl state Prints out the SSL session states. .It Fl tlsextdebug Print out a hex dump of any TLS extensions received from the server. .It Fl verify Ar depth The verify .Ar depth to use. This specifies the maximum length of the server certificate chain and turns on server certificate verification. Currently the verify operation continues after errors so all the problems with a certificate chain can be seen. As a side effect the connection will never fail due to a server certificate verify failure. .El .Sh S_CLIENT CONNECTED COMMANDS If a connection is established with an SSL server, any data received from the server is displayed and any key presses will be sent to the server. When used interactively (which means neither .Fl quiet nor .Fl ign_eof have been given), the session will be renegotiated if the line begins with an .Em R ; if the line begins with a .Em Q or if end of file is reached, the connection will be closed down. .Sh S_CLIENT NOTES .Nm s_client can be used to debug SSL servers. To connect to an SSL HTTP server the command: .Pp .Dl $ openssl s_client -connect servername:443 .Pp would typically be used .Pq HTTPS uses port 443 . If the connection succeeds, an HTTP command can be given such as .Qq GET to retrieve a web page. .Pp If the handshake fails, there are several possible causes; if it is nothing obvious like no client certificate, then the .Fl bugs , ssl3 , tls1 , no_ssl3 , and .Fl no_tls1 options can be tried in case it is a buggy server. In particular these options should be tried .Em before submitting a bug report to an .Nm OpenSSL mailing list. .Pp A frequent problem when attempting to get client certificates working is that a web client complains it has no certificates or gives an empty list to choose from. This is normally because the server is not sending the client's certificate authority in its .Qq acceptable CA list when it requests a certificate. By using .Nm s_client the CA list can be viewed and checked. However some servers only request client authentication after a specific URL is requested. To obtain the list in this case it is necessary to use the .Fl prexit option and send an HTTP request for an appropriate page. .Pp If a certificate is specified on the command line using the .Fl cert option, it will not be used unless the server specifically requests a client certificate. Therefore merely including a client certificate on the command line is no guarantee that the certificate works. .Pp If there are problems verifying a server certificate, the .Fl showcerts option can be used to show the whole chain. .Pp Compression methods are only supported for .Fl tls1 . .Sh S_CLIENT BUGS Because this program has a lot of options and also because some of the techniques used are rather old, the C source of .Nm s_client is rather hard to read and not a model of how things should be done. A typical SSL client program would be much simpler. .Pp The .Fl verify option should really exit if the server verification fails. .Pp The .Fl prexit option is a bit of a hack. We should really report information whenever a session is renegotiated. .\" .\" S_SERVER .\" .Sh S_SERVER .nr nS 1 .Nm "openssl s_server" .Bk -words .Op Fl accept Ar port .Op Fl bugs .Op Fl CAfile Ar file .Op Fl CApath Ar directory .Op Fl cert Ar file .Op Fl cipher Ar cipherlist .Op Fl context Ar id .Op Fl crl_check .Op Fl crl_check_all .Op Fl crlf .Op Fl dcert Ar file .Op Fl debug .Op Fl dhparam Ar file .Op Fl dkey Ar file .Op Fl engine Ar id .Op Fl hack .Op Fl HTTP .Op Fl id_prefix Ar arg .Op Fl key Ar keyfile .Op Fl msg .Op Fl nbio .Op Fl nbio_test .Op Fl no_dhe .Op Fl no_ssl3 .Op Fl no_tls1 .Op Fl no_tmp_rsa .Op Fl nocert .Op Fl psk Ar key .Op Fl psk_hint Ar hint .Op Fl quiet .Op Fl serverpref .Op Fl ssl3 .Op Fl state .Op Fl tls1 .Op Fl Verify Ar depth .Op Fl verify Ar depth .Op Fl WWW .Op Fl www .Ek .nr nS 0 .Pp The .Nm s_server command implements a generic SSL/TLS server which listens for connections on a given port using SSL/TLS. .Pp The options are as follows: .Bl -tag -width Ds .It Fl accept Ar port The TCP .Ar port to listen on for connections. If not specified, 4433 is used. .It Fl bugs There are several known bugs in SSL and TLS implementations. Adding this option enables various workarounds. .It Fl CAfile Ar file A file containing trusted certificates to use during client authentication and to use when attempting to build the server certificate chain. The list is also used in the list of acceptable client CAs passed to the client when a certificate is requested. .It Fl CApath Ar directory The .Ar directory to use for client certificate verification. This directory must be in .Qq hash format ; see .Fl verify for more information. These are also used when building the server certificate chain. .It Fl cert Ar file The certificate to use; most server's cipher suites require the use of a certificate and some require a certificate with a certain public key type: for example the DSS cipher suites require a certificate containing a DSS .Pq DSA key. If not specified, the file .Pa server.pem will be used. .It Fl cipher Ar cipherlist This allows the cipher list used by the server to be modified. When the client sends a list of supported ciphers, the first client cipher also included in the server list is used. Because the client specifies the preference order, the order of the server cipherlist is irrelevant. See the .Sx CIPHERS section for more information. .It Fl context Ar id Sets the SSL context ID. It can be given any string value. If this option is not present, a default value will be used. .It Fl crl_check , crl_check_all Check the peer certificate has not been revoked by its CA. The CRLs are appended to the certificate file. With the .Fl crl_check_all option, all CRLs of all CAs in the chain are checked. .It Fl crlf This option translates a line feed from the terminal into CR+LF. .It Fl dcert Ar file , Fl dkey Ar file Specify an additional certificate and private key; these behave in the same manner as the .Fl cert and .Fl key options except there is no default if they are not specified .Pq no additional certificate or key is used . As noted above some cipher suites require a certificate containing a key of a certain type. Some cipher suites need a certificate carrying an RSA key and some a DSS .Pq DSA key. By using RSA and DSS certificates and keys, a server can support clients which only support RSA or DSS cipher suites by using an appropriate certificate. .It Fl debug Print extensive debugging information including a hex dump of all traffic. .It Fl dhparam Ar file The DH parameter file to use. The ephemeral DH cipher suites generate keys using a set of DH parameters. If not specified, an attempt is made to load the parameters from the server certificate file. If this fails, a static set of parameters hard coded into the .Nm s_server program will be used. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm s_server to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl hack This option enables a further workaround for some early Netscape SSL code .Pq \&? . .It Fl HTTP Emulates a simple web server. Pages will be resolved relative to the current directory; for example if the URL .Pa https://myhost/page.html is requested, the file .Pa ./page.html will be loaded. The files loaded are assumed to contain a complete and correct HTTP response (lines that are part of the HTTP response line and headers must end with CRLF). .It Fl id_prefix Ar arg Generate SSL/TLS session IDs prefixed by .Ar arg . This is mostly useful for testing any SSL/TLS code .Pq e.g. proxies that wish to deal with multiple servers, when each of which might be generating a unique range of session IDs .Pq e.g. with a certain prefix . .It Fl key Ar keyfile The private key to use. If not specified, the certificate file will be used. .It Fl msg Show all protocol messages with hex dump. .It Fl nbio Turns on non-blocking I/O. .It Fl nbio_test Tests non-blocking I/O. .It Fl no_dhe If this option is set, no DH parameters will be loaded, effectively disabling the ephemeral DH cipher suites. .It Xo .Fl no_ssl3 | no_tls1 | .Fl ssl3 | tls1 .Xc These options disable the use of certain SSL or TLS protocols. By default, the initial handshake uses a method which should be compatible with all servers and permit them to use SSL v3 or TLS as appropriate. .It Fl no_tmp_rsa Certain export cipher suites sometimes use a temporary RSA key; this option disables temporary RSA key generation. .It Fl nocert If this option is set, no certificate is used. This restricts the cipher suites available to the anonymous ones .Pq currently just anonymous DH . .It Fl psk Ar key Use the PSK key .Ar key when using a PSK cipher suite. The key is given as a hexadecimal number without the leading 0x, for example -psk 1a2b3c4d. .It Fl psk_hint Ar hint Use the PSK identity hint .Ar hint when using a PSK cipher suite. .It Fl quiet Inhibit printing of session and certificate information. .It Fl serverpref Use server's cipher preferences. .It Fl state Prints out the SSL session states. .It Fl WWW Emulates a simple web server. Pages will be resolved relative to the current directory; for example if the URL .Pa https://myhost/page.html is requested, the file .Pa ./page.html will be loaded. .It Fl www Sends a status message back to the client when it connects. This includes lots of information about the ciphers used and various session parameters. The output is in HTML format so this option will normally be used with a web browser. .It Fl Verify Ar depth , Fl verify Ar depth The verify .Ar depth to use. This specifies the maximum length of the client certificate chain and makes the server request a certificate from the client. With the .Fl Verify option, the client must supply a certificate or an error occurs. With the .Fl verify option, a certificate is requested but the client does not have to send one. .El .Sh S_SERVER CONNECTED COMMANDS If a connection request is established with an SSL client and neither the .Fl www nor the .Fl WWW option has been used, then normally any data received from the client is displayed and any key presses will be sent to the client. .Pp Certain single letter commands are also recognized which perform special operations: these are listed below. .Bl -tag -width "XXXX" .It Ar P Send some plain text down the underlying TCP connection: this should cause the client to disconnect due to a protocol violation. .It Ar Q End the current SSL connection and exit. .It Ar q End the current SSL connection, but still accept new connections. .It Ar R Renegotiate the SSL session and request a client certificate. .It Ar r Renegotiate the SSL session. .It Ar S Print out some session cache status information. .El .Sh S_SERVER NOTES .Nm s_server can be used to debug SSL clients. To accept connections from a web browser the command: .Pp .Dl $ openssl s_server -accept 443 -www .Pp can be used, for example. .Pp Most web browsers .Pq in particular Netscape and MSIE only support RSA cipher suites, so they cannot connect to servers which don't use a certificate carrying an RSA key or a version of .Nm OpenSSL with RSA disabled. .Pp Although specifying an empty list of CAs when requesting a client certificate is strictly speaking a protocol violation, some SSL clients interpret this to mean any CA is acceptable. This is useful for debugging purposes. .Pp The session parameters can printed out using the .Nm sess_id program. .Sh S_SERVER BUGS Because this program has a lot of options and also because some of the techniques used are rather old, the C source of .Nm s_server is rather hard to read and not a model of how things should be done. A typical SSL server program would be much simpler. .Pp The output of common ciphers is wrong: it just gives the list of ciphers that .Nm OpenSSL recognizes and the client supports. .Pp There should be a way for the .Nm s_server program to print out details of any unknown cipher suites a client says it supports. .\" .\" S_TIME .\" .Sh S_TIME .nr nS 1 .Nm "openssl s_time" .Bk -words .Op Fl bugs .Op Fl CAfile Ar file .Op Fl CApath Ar directory .Op Fl cert Ar file .Op Fl cipher Ar cipherlist .Op Fl connect Ar host : Ns Ar port .Op Fl key Ar keyfile .Op Fl nbio .Op Fl new .Op Fl reuse .Op Fl ssl3 .Op Fl time Ar seconds .Op Fl verify Ar depth .Op Fl www Ar page .Ek .nr nS 0 .Pp The .Nm s_client command implements a generic SSL/TLS client which connects to a remote host using SSL/TLS. It can request a page from the server and includes the time to transfer the payload data in its timing measurements. It measures the number of connections within a given timeframe, the amount of data transferred .Pq if any , and calculates the average time spent for one connection. .Pp The options are as follows: .Bl -tag -width Ds .It Fl bugs There are several known bugs in SSL and TLS implementations. Adding this option enables various workarounds. .It Fl CAfile Ar file A file containing trusted certificates to use during server authentication and to use when attempting to build the client certificate chain. .It Fl CApath Ar directory The directory to use for server certificate verification. This directory must be in .Qq hash format ; see .Nm verify for more information. These are also used when building the client certificate chain. .It Fl cert Ar file The certificate to use, if one is requested by the server. The default is not to use a certificate. The file is in PEM format. .It Fl cipher Ar cipherlist This allows the cipher list sent by the client to be modified. Although the server determines which cipher suite is used, it should take the first supported cipher in the list sent by the client. See the .Nm ciphers command for more information. .It Fl connect Ar host : Ns Ar port This specifies the host and optional port to connect to. .It Fl key Ar keyfile The private key to use. If not specified, the certificate file will be used. The file is in PEM format. .It Fl nbio Turns on non-blocking I/O. .It Fl new Performs the timing test using a new session ID for each connection. If neither .Fl new nor .Fl reuse are specified, they are both on by default and executed in sequence. .It Fl reuse Performs the timing test using the same session ID; this can be used as a test that session caching is working. If neither .Fl new nor .Fl reuse are specified, they are both on by default and executed in sequence. .It Fl ssl3 This option disables the use of certain SSL or TLS protocols. By default, the initial handshake uses a method which should be compatible with all servers and permit them to use SSL v3 or TLS as appropriate. The timing program is not as rich in options to turn protocols on and off as the .Nm s_client program and may not connect to all servers. .Pp Unfortunately there are a lot of ancient and broken servers in use which cannot handle this technique and will fail to connect. Some servers only work if TLS is turned off with the .Fl ssl3 option. .It Fl time Ar seconds Specifies how long .Pq in seconds .Nm s_time should establish connections and optionally transfer payload data from a server. The default is 30 seconds. Server and client performance and the link speed determine how many connections .Nm s_time can establish. .It Fl verify Ar depth The verify depth to use. This specifies the maximum length of the server certificate chain and turns on server certificate verification. Currently the verify operation continues after errors, so all the problems with a certificate chain can be seen. As a side effect, the connection will never fail due to a server certificate verify failure. .It Fl www Ar page This specifies the page to GET from the server. A value of .Sq / gets the index.htm[l] page. If this parameter is not specified, .Nm s_time will only perform the handshake to establish SSL connections but not transfer any payload data. .El .Sh S_TIME NOTES .Nm s_client can be used to measure the performance of an SSL connection. To connect to an SSL HTTP server and get the default page the command .Bd -literal -offset indent $ openssl s_time -connect servername:443 -www / -CApath yourdir \e -CAfile yourfile.pem -cipher commoncipher [-ssl3] .Ed .Pp would typically be used .Pq HTTPS uses port 443 . .Dq commoncipher is a cipher to which both client and server can agree; see the .Nm ciphers command for details. .Pp If the handshake fails, there are several possible causes: if it is nothing obvious like no client certificate, the .Fl bugs and .Fl ssl3 options can be tried in case it is a buggy server. In particular you should play with these options .Em before submitting a bug report to an OpenSSL mailing list. .Pp A frequent problem when attempting to get client certificates working is that a web client complains it has no certificates or gives an empty list to choose from. This is normally because the server is not sending the clients certificate authority in its .Qq acceptable CA list when it requests a certificate. By using .Nm s_client , the CA list can be viewed and checked. However some servers only request client authentication after a specific URL is requested. To obtain the list in this case, it is necessary to use the .Fl prexit option of .Nm s_client and send an HTTP request for an appropriate page. .Pp If a certificate is specified on the command line using the .Fl cert option, it will not be used unless the server specifically requests a client certificate. Therefore merely including a client certificate on the command line is no guarantee that the certificate works. .Sh S_TIME BUGS Because this program does not have all the options of the .Nm s_client program to turn protocols on and off, you may not be able to measure the performance of all protocols with all servers. .Pp The .Fl verify option should really exit if the server verification fails. .\" .\" SESS_ID .\" .Sh SESS_ID .nr nS 1 .Nm "openssl sess_id" .Bk -words .Op Fl cert .Op Fl context Ar ID .Op Fl in Ar file .Op Fl inform Ar DER | PEM .Op Fl noout .Op Fl out Ar file .Op Fl outform Ar DER | PEM .Op Fl text .Ek .nr nS 0 .Pp The .Nm sess_id program processes the encoded version of the SSL session structure and optionally prints out SSL session details .Pq for example the SSL session master key in human readable format. Since this is a diagnostic tool that needs some knowledge of the SSL protocol to use properly, most users will not need to use it. .Pp The options are as follows: .Bl -tag -width Ds .It Fl cert If a certificate is present in the session, it will be output using this option; if the .Fl text option is also present, then it will be printed out in text form. .It Fl context Ar ID This option can set the session ID so the output session information uses the supplied .Ar ID . The .Ar ID can be any string of characters. This option won't normally be used. .It Fl in Ar file This specifies the input .Ar file to read session information from, or standard input by default. .It Fl inform Ar DER | PEM This specifies the input format. The .Ar DER argument uses an ASN1 DER-encoded format containing session details. The precise format can vary from one version to the next. The .Ar PEM form is the default format: it consists of the DER format base64-encoded with additional header and footer lines. .It Fl noout This option prevents output of the encoded version of the session. .It Fl out Ar file This specifies the output .Ar file to write session information to, or standard output if this option is not specified. .It Fl outform Ar DER | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. .It Fl text Prints out the various public or private key components in plain text in addition to the encoded version. .El .Sh SESS_ID OUTPUT Typical output: .Bd -literal SSL-Session: Protocol : TLSv1 Cipher : 0016 Session-ID: 871E62626C554CE95488823752CBD5F3673A3EF3DCE9C67BD916C809914B40ED Session-ID-ctx: 01000000 Master-Key: A7CEFC571974BE02CAC305269DC59F76EA9F0B180CB6642697A68251F2D2BB57E51DBBB4C7885573192AE9AEE220FACD Key-Arg : None Start Time: 948459261 Timeout : 300 (sec) Verify return code 0 (ok) .Ed .Pp These are described below in more detail. .Pp .Bl -tag -width "Verify return code " -compact .It Ar Protocol This is the protocol in use: TLSv1 or SSLv3. .It Ar Cipher The cipher used is the actual raw SSL or TLS cipher code; see the SSL or TLS specifications for more information. .It Ar Session-ID The SSL session ID in hex format. .It Ar Session-ID-ctx The session ID context in hex format. .It Ar Master-Key This is the SSL session master key. .It Ar Key-Arg The key argument; this is only used in SSL v2. .It Ar Start Time This is the session start time, represented as an integer in standard .Ux format. .It Ar Timeout The timeout in seconds. .It Ar Verify return code This is the return code when an SSL client certificate is verified. .El .Sh SESS_ID NOTES The PEM-encoded session format uses the header and footer lines: .Bd -unfilled -offset indent -----BEGIN SSL SESSION PARAMETERS----- -----END SSL SESSION PARAMETERS----- .Ed .Pp Since the SSL session output contains the master key, it is possible to read the contents of an encrypted session using this information. Therefore appropriate security precautions should be taken if the information is being output by a .Qq real application. This is, however, strongly discouraged and should only be used for debugging purposes. .Sh SESS_ID BUGS The cipher and start time should be printed out in human readable form. .\" .\" SMIME .\" .Sh SMIME .nr nS 1 .Nm "openssl smime" .Bk -words .Oo .Fl aes128 | aes192 | aes256 | des | .Fl des3 | rc2-40 | rc2-64 | rc2-128 .Oc .Op Fl binary .Op Fl CAfile Ar file .Op Fl CApath Ar directory .Op Fl certfile Ar file .Op Fl check_ss_sig .Op Fl content Ar file .Op Fl crl_check .Op Fl crl_check_all .Op Fl decrypt .Op Fl encrypt .Op Fl engine Ar id .Op Fl extended_crl .Op Fl from Ar addr .Op Fl ignore_critical .Op Fl in Ar file .Op Fl indef .Op Fl inform Ar DER | PEM | SMIME .Op Fl inkey Ar file .Op Fl issuer_checks .Op Fl keyform Ar ENGINE | PEM .Op Fl md Ar digest .Op Fl noattr .Op Fl nocerts .Op Fl nochain .Op Fl nodetach .Op Fl noindef .Op Fl nointern .Op Fl nosigs .Op Fl noverify .Op Fl out Ar file .Op Fl outform Ar DER | PEM | SMIME .Op Fl passin Ar arg .Op Fl pk7out .Op Fl policy_check .Op Fl recip Ar file .Op Fl resign .Op Fl sign .Op Fl signer Ar file .Op Fl stream .Op Fl subject Ar s .Op Fl text .Op Fl to Ar addr .Op Fl verify .Op Fl x509_strict .Op Ar cert.pem ... .Ek .nr nS 0 .Pp The .Nm smime command handles .Em S/MIME mail. It can encrypt, decrypt, sign, and verify .Em S/MIME messages. .Pp There are six operation options that set the type of operation to be performed. The meaning of the other options varies according to the operation type. .Pp The six operation options are as follows: .Bl -tag -width "XXXX" .It Fl decrypt Decrypt mail using the supplied certificate and private key. Expects an encrypted mail message in .Em MIME format for the input file. The decrypted mail is written to the output file. .It Fl encrypt Encrypt mail for the given recipient certificates. Input file is the message to be encrypted. The output file is the encrypted mail in .Em MIME format. .It Fl pk7out Takes an input message and writes out a PEM-encoded PKCS#7 structure. .It Fl resign Resign a message: take an existing message and one or more new signers. .It Fl sign Sign mail using the supplied certificate and private key. Input file is the message to be signed. The signed message in .Em MIME format is written to the output file. .It Fl verify Verify signed mail. Expects a signed mail message on input and outputs the signed data. Both clear text and opaque signing is supported. .El .Pp The reamaining options are as follows: .Bl -tag -width "XXXX" .It Xo .Fl aes128 | aes192 | aes256 | des | .Fl des3 | rc2-40 | rc2-64 | rc2-128 .Xc The encryption algorithm to use. 128-, 192-, or 256-bit AES, DES .Pq 56 bits , triple DES .Pq 168 bits , or 40-, 64-, or 128-bit RC2, respectively; if not specified, 40-bit RC2 is used. Only used with .Fl encrypt . .It Fl binary Normally, the input message is converted to .Qq canonical format which is effectively using CR and LF as end of line \- as required by the .Em S/MIME specification. When this option is present no translation occurs. This is useful when handling binary data which may not be in .Em MIME format. .It Fl CAfile Ar file A .Ar file containing trusted CA certificates; only used with .Fl verify . .It Fl CApath Ar directory A .Ar directory containing trusted CA certificates; only used with .Fl verify . This directory must be a standard certificate directory: that is, a hash of each subject name (using .Nm x509 -hash ) should be linked to each certificate. .It Ar cert.pem ... One or more certificates of message recipients: used when encrypting a message. .It Fl certfile Ar file Allows additional certificates to be specified. When signing, these will be included with the message. When verifying, these will be searched for the signers' certificates. The certificates should be in PEM format. .It Xo .Fl check_ss_sig , .Fl crl_check , .Fl crl_check_all , .Fl extended_crl , .Fl ignore_critical , .Fl issuer_checks , .Fl policy_check , .Fl x509_strict .Xc Set various certificate chain validation options. See the .Nm VERIFY command for details. .It Fl content Ar file This specifies a file containing the detached content. This is only useful with the .Fl verify command. This is only usable if the PKCS#7 structure is using the detached signature form where the content is not included. This option will override any content if the input format is .Em S/MIME and it uses the multipart/signed .Em MIME content type. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm smime to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Xo .Fl from Ar addr , .Fl subject Ar s , .Fl to Ar addr .Xc The relevant mail headers. These are included outside the signed portion of a message so they may be included manually. When signing, many .Em S/MIME mail clients check that the signer's certificate email address matches the From: address. .It Fl in Ar file The input message to be encrypted or signed or the .Em MIME message to be decrypted or verified. .It Fl indef Enable streaming I/O for encoding operations. This permits single pass processing of data without the need to hold the entire contents in memory, potentially supporting very large files. Streaming is automatically set for S/MIME signing with detached data if the output format is SMIME; it is currently off by default for all other operations. .It Fl inform Ar DER | PEM | SMIME This specifies the input format for the PKCS#7 structure. The default is .Em SMIME , which reads an .Em S/MIME format message. .Ar PEM and .Ar DER format change this to expect PEM and DER format PKCS#7 structures instead. This currently only affects the input format of the PKCS#7 structure; if no PKCS#7 structure is being input (for example with .Fl encrypt or .Fl sign ) , this option has no effect. .It Fl inkey Ar file The private key to use when signing or decrypting. This must match the corresponding certificate. If this option is not specified, the private key must be included in the certificate file specified with the .Fl recip or .Fl signer file. When signing, this option can be used multiple times to specify successive keys. .It Fl keyform Ar ENGINE | PEM Input private key format. .It Fl md Ar digest The digest algorithm to use when signing or resigning. If not present then the default digest algorithm for the signing key is used (usually SHA1). .It Fl noattr Normally, when a message is signed a set of attributes are included which include the signing time and supported symmetric algorithms. With this option they are not included. .It Fl nocerts When signing a message, the signer's certificate is normally included; with this option it is excluded. This will reduce the size of the signed message but the verifier must have a copy of the signer's certificate available locally (passed using the .Fl certfile option, for example). .It Fl nochain Do not do chain verification of signers' certificates: that is, don't use the certificates in the signed message as untrusted CAs. .It Fl nodetach When signing a message use opaque signing: this form is more resistant to translation by mail relays but it cannot be read by mail agents that do not support .Em S/MIME . Without this option cleartext signing with the .Em MIME type multipart/signed is used. .It Fl noindef Disable streaming I/O where it would produce an encoding of indefinite length. This option currently has no effect. In future streaming will be enabled by default on all relevant operations and this option will disable it. .It Fl nointern When verifying a message, normally certificates .Pq if any included in the message are searched for the signing certificate. With this option, only the certificates specified in the .Fl certfile option are used. The supplied certificates can still be used as untrusted CAs however. .It Fl nosigs Don't try to verify the signatures on the message. .It Fl noverify Do not verify the signer's certificate of a signed message. .It Fl out Ar file The message text that has been decrypted or verified, or the output .Em MIME format message that has been signed or verified. .It Fl outform Ar DER | PEM | SMIME This specifies the output format for the PKCS#7 structure. The default is .Em SMIME , which writes an .Em S/MIME format message. .Ar PEM and .Ar DER format change this to write PEM and DER format PKCS#7 structures instead. This currently only affects the output format of the PKCS#7 structure; if no PKCS#7 structure is being output (for example with .Fl verify or .Fl decrypt ) this option has no effect. .It Fl passin Ar arg The key password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl recip Ar file The recipients certificate when decrypting a message. This certificate must match one of the recipients of the message or an error occurs. .It Fl signer Ar file A signing certificate when signing or resigning a message; this option can be used multiple times if more than one signer is required. If a message is being verified, the signer's certificates will be written to this file if the verification was successful. .It Fl stream The same as .Fl indef . .It Fl text This option adds plain text .Pq text/plain .Em MIME headers to the supplied message if encrypting or signing. If decrypting or verifying, it strips off text headers: if the decrypted or verified message is not of .Em MIME type text/plain then an error occurs. .El .Sh SMIME NOTES The .Em MIME message must be sent without any blank lines between the headers and the output. Some mail programs will automatically add a blank line. Piping the mail directly to sendmail is one way to achieve the correct format. .Pp The supplied message to be signed or encrypted must include the necessary .Em MIME headers or many .Em S/MIME clients won't display it properly .Pq if at all . You can use the .Fl text option to automatically add plain text headers. .Pp A .Qq signed and encrypted message is one where a signed message is then encrypted. This can be produced by encrypting an already signed message: see the .Sx SMIME EXAMPLES section. .Pp This version of the program only allows one signer per message, but it will verify multiple signers on received messages. Some .Em S/MIME clients choke if a message contains multiple signers. It is possible to sign messages .Qq in parallel by signing an already signed message. .Pp The options .Fl encrypt and .Fl decrypt reflect common usage in .Em S/MIME clients. Strictly speaking these process PKCS#7 enveloped data: PKCS#7 encrypted data is used for other purposes. .Pp The .Fl resign option uses an existing message digest when adding a new signer. This means that attributes must be present in at least one existing signer using the same message digest or this operation will fail. .Pp The .Fl stream and .Fl indef options enable experimental streaming I/O support. As a result the encoding is BER using indefinite length constructed encoding and no longer DER. Streaming is supported for the .Fl encrypt and .Fl sign operations if the content is not detached. .Pp Streaming is always used for the .Fl sign operation with detached data but since the content is no longer part of the PKCS#7 structure the encoding remains DER. .Sh SMIME EXIT CODES .Bl -tag -width "XXXX" .It Ar 0 The operation was completely successful. .It Ar 1 An error occurred parsing the command options. .It Ar 2 One of the input files could not be read. .It Ar 3 An error occurred creating the PKCS#7 file or when reading the .Em MIME message. .It Ar 4 An error occurred decrypting or verifying the message. .It Ar 5 The message was verified correctly, but an error occurred writing out the signer's certificates. .El .Sh SMIME EXAMPLES Create a cleartext signed message: .Bd -literal -offset indent $ openssl smime -sign -in message.txt -text -out mail.msg \e -signer mycert.pem .Ed .Pp Create an opaque signed message: .Bd -literal -offset indent $ openssl smime -sign -in message.txt -text -out mail.msg \e -nodetach -signer mycert.pem .Ed .Pp Create a signed message, include some additional certificates and read the private key from another file: .Bd -literal -offset indent $ openssl smime -sign -in in.txt -text -out mail.msg \e -signer mycert.pem -inkey mykey.pem -certfile mycerts.pem .Ed .Pp Create a signed message with two signers: .Bd -literal -offset indent openssl smime -sign -in message.txt -text -out mail.msg \e -signer mycert.pem -signer othercert.pem .Ed .Pp Send a signed message under .Ux directly to .Xr sendmail 8 , including headers: .Bd -literal -offset indent $ openssl smime -sign -in in.txt -text -signer mycert.pem \e -from steve@openssl.org -to someone@somewhere \e -subject "Signed message" | sendmail someone@somewhere .Ed .Pp Verify a message and extract the signer's certificate if successful: .Bd -literal -offset indent $ openssl smime -verify -in mail.msg -signer user.pem \e -out signedtext.txt .Ed .Pp Send encrypted mail using triple DES: .Bd -literal -offset indent $ openssl smime -encrypt -in in.txt -from steve@openssl.org \e -to someone@somewhere -subject "Encrypted message" \e -des3 -out mail.msg user.pem .Ed .Pp Sign and encrypt mail: .Bd -literal -offset indent $ openssl smime -sign -in ml.txt -signer my.pem -text | \e openssl smime -encrypt -out mail.msg \e -from steve@openssl.org -to someone@somewhere \e -subject "Signed and Encrypted message" -des3 user.pem .Ed .Pp .Sy Note : The encryption command does not include the .Fl text option because the message being encrypted already has .Em MIME headers. .Pp Decrypt mail: .Bd -literal -offset indent $ openssl smime -decrypt -in mail.msg -recip mycert.pem \e -inkey key.pem" .Ed .Pp The output from Netscape form signing is a PKCS#7 structure with the detached signature format. You can use this program to verify the signature by line wrapping the base64-encoded structure and surrounding it with: .Bd -unfilled -offset indent -----BEGIN PKCS7----- -----END PKCS7----- .Ed .Pp and using the command: .Bd -literal -offset indent $ openssl smime -verify -inform PEM -in signature.pem \e -content content.txt .Ed .Pp Alternatively, you can base64 decode the signature and use: .Bd -literal -offset indent $ openssl smime -verify -inform DER -in signature.der \e -content content.txt .Ed .Pp Create an encrypted message using 128-bit AES: .Bd -literal -offset indent openssl smime -encrypt -in plain.txt -aes128 \e -out mail.msg cert.pem .Ed .Pp Add a signer to an existing message: .Bd -literal -offset indent openssl smime -resign -in mail.msg -signer newsign.pem \e -out mail2.msg .Ed .Sh SMIME BUGS The .Em MIME parser isn't very clever: it seems to handle most messages that I've thrown at it, but it may choke on others. .Pp The code currently will only write out the signer's certificate to a file: if the signer has a separate encryption certificate this must be manually extracted. There should be some heuristic that determines the correct encryption certificate. .Pp Ideally, a database should be maintained of a certificate for each email address. .Pp The code doesn't currently take note of the permitted symmetric encryption algorithms as supplied in the .Em SMIMECapabilities signed attribute. This means the user has to manually include the correct encryption algorithm. It should store the list of permitted ciphers in a database and only use those. .Pp No revocation checking is done on the signer's certificate. .Pp The current code can only handle .Em S/MIME v2 messages; the more complex .Em S/MIME v3 structures may cause parsing errors. .Sh SMIME HISTORY The use of multiple .Fl signer options and the .Fl resign command were first added in .Nm OpenSSL 1.0.0. .\" .\" SPEED .\" .Sh SPEED .nr nS 1 .Nm "openssl speed" .Bk -words .Op Cm aes .Op Cm aes-128-cbc .Op Cm aes-192-cbc .Op Cm aes-256-cbc .Op Cm blowfish .Op Cm bf-cbc .Op Cm cast .Op Cm cast-cbc .Op Cm des .Op Cm des-cbc .Op Cm des-ede3 .Op Cm dsa .Op Cm dsa512 .Op Cm dsa1024 .Op Cm dsa2048 .Op Cm hmac .Op Cm md2 .Op Cm md4 .Op Cm md5 .Op Cm rc2 .Op Cm rc2-cbc .Op Cm rc4 .Op Cm rmd160 .Op Cm rsa .Op Cm rsa512 .Op Cm rsa1024 .Op Cm rsa2048 .Op Cm rsa4096 .Op Cm sha1 .Op Fl decrypt .Op Fl elapsed .Op Fl engine Ar id .Op Fl evp Ar e .Op Fl mr .Op Fl multi Ar number .Ek .nr nS 0 .Pp The .Nm speed command is used to test the performance of cryptographic algorithms. .Bl -tag -width "XXXX" .It Bq Cm zero or more test algorithms If any options are given, .Nm speed tests those algorithms, otherwise all of the above are tested. .It Fl decrypt Time decryption instead of encryption .Pq only EVP . .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm speed to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl elapsed Measure time in real time instead of CPU user time. .It Fl evp Ar e Use EVP .Ar e . .It Fl mr Produce machine readable output. .It Fl multi Ar number Run .Ar number benchmarks in parallel. .El .\" .\" TS .\" .Sh TS .nr nS 1 .Nm "openssl ts" .Bk -words .Fl query .Op Fl md4 | md5 | ripemd160 | sha | sha1 .Op Fl cert .Op Fl config Ar configfile .Op Fl data Ar file_to_hash .Op Fl digest Ar digest_bytes .Op Fl in Ar request.tsq .Op Fl no_nonce .Op Fl out Ar request.tsq .Op Fl policy Ar object_id .Op Fl text .Ek .nr nS 0 .Pp .nr nS 1 .Nm "openssl ts" .Bk -words .Fl reply .Op Fl chain Ar certs_file.pem .Op Fl config Ar configfile .Op Fl engine Ar id .Op Fl in Ar response.tsr .Op Fl inkey Ar private.pem .Op Fl out Ar response.tsr .Op Fl passin Ar arg .Op Fl policy Ar object_id .Op Fl queryfile Ar request.tsq .Op Fl section Ar tsa_section .Op Fl signer Ar tsa_cert.pem .Op Fl text .Op Fl token_in .Op Fl token_out .Ek .nr nS 0 .Pp .nr nS 1 .Nm "openssl ts" .Bk -words .Fl verify .Op Fl CAfile Ar trusted_certs.pem .Op Fl CApath Ar trusted_cert_path .Op Fl data Ar file_to_hash .Op Fl digest Ar digest_bytes .Op Fl in Ar response.tsr .Op Fl queryfile Ar request.tsq .Op Fl token_in .Op Fl untrusted Ar cert_file.pem .Ek .nr nS 0 .Pp The .Nm ts command is a basic Time Stamping Authority (TSA) client and server application as specified in RFC 3161 (Time-Stamp Protocol, TSP). A TSA can be part of a PKI deployment and its role is to provide long term proof of the existence of a certain datum before a particular time. Here is a brief description of the protocol: .Bl -enum .It The TSA client computes a one-way hash value for a data file and sends the hash to the TSA. .It The TSA attaches the current date and time to the received hash value, signs them and sends the time stamp token back to the client. By creating this token the TSA certifies the existence of the original data file at the time of response generation. .It The TSA client receives the time stamp token and verifies the signature on it. It also checks if the token contains the same hash value that it had sent to the TSA. .El .Pp There is one DER-encoded protocol data unit defined for transporting a time stamp request to the TSA and one for sending the time stamp response back to the client. The .Nm ts command has three main functions: creating a time stamp request based on a data file; creating a time stamp response based on a request; and verifying if a response corresponds to a particular request or a data file. .Pp There is no support for sending the requests/responses automatically over HTTP or TCP yet as suggested in RFC 3161. Users must send the requests either by FTP or email. .Pp The .Fl query switch can be used for creating and printing a time stamp request with the following options: .Bl -tag -width Ds .It Fl cert The TSA is expected to include its signing certificate in the response. .It Fl config Ar configfile The configuration file to use. This option overrides the .Ev OPENSSL_CONF environment variable. Only the OID section of the config file is used with the .Fl query command. .It Fl data Ar file_to_hash The data file for which the time stamp request needs to be created. stdin is the default if neither the .Fl data nor the .Fl digest option is specified. .It Fl digest Ar digest_bytes It is possible to specify the message imprint explicitly without the data file. The imprint must be specified in a hexadecimal format, two characters per byte, the bytes optionally separated by colons (e.g. 1A:F6:01:... or 1AF601...). The number of bytes must match the message digest algorithm in use. .It Fl in Ar request.tsq This option specifies a previously created time stamp request in DER format that will be printed into the output file. Useful when you need to examine the content of a request in human-readable format. .It Fl md4|md5|ripemd160|sha|sha1 The message digest to apply to the data file. It supports all the message digest algorithms that are supported by the .Nm dgst command. The default is SHA-1. .It Fl no_nonce No nonce is specified in the request if this option is given. Otherwise a 64-bit long pseudo-random none is included in the request. It is recommended to use nonce to protect against replay-attacks. .It Fl out Ar request.tsq Name of the output file to which the request will be written. The default is stdout. .It Fl policy Ar object_id The policy that the client expects the TSA to use for creating the time stamp token. Either the dotted OID notation or OID names defined in the config file can be used. If no policy is requested the TSA will use its own default policy. .It Fl text If this option is specified the output is in human-readable text format instead of DER. .El .Pp A time stamp response (TimeStampResp) consists of a response status and the time stamp token itself (ContentInfo), if the token generation was successful. The .Fl reply command is for creating a time stamp response or time stamp token based on a request and printing the response/token in human-readable format. If .Fl token_out is not specified the output is always a time stamp response (TimeStampResp), otherwise it is a time stamp token (ContentInfo). .Bl -tag -width Ds .It Fl chain Ar certs_file.pem The collection of certificates, in PEM format, that will be included in the response in addition to the signer certificate if the .Fl cert option was used for the request. This file is supposed to contain the certificate chain for the signer certificate from its issuer upwards. The .Fl reply command does not build a certificate chain automatically. .It Fl config Ar configfile The configuration file to use. This option overrides the .Ev OPENSSL_CONF environment variable. See .Sx TS CONFIGURATION FILE OPTIONS for configurable variables. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm ts to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl in Ar response.tsr Specifies a previously created time stamp response or time stamp token, if .Fl token_in is also specified, in DER format that will be written to the output file. This option does not require a request; it is useful, for example, when you need to examine the content of a response or token or you want to extract the time stamp token from a response. If the input is a token and the output is a time stamp response a default .Dq granted status info is added to the token. .It Fl inkey Ar private.pem The signer private key of the TSA in PEM format. Overrides the .Cm signer_key config file option. .It Fl out Ar response.tsr The response is written to this file. The format and content of the file depends on other options (see .Fl text and .Fl token_out ) . The default is stdout. .It Fl passin Ar arg The key password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl policy Ar object_id The default policy to use for the response unless the client explicitly requires a particular TSA policy. The OID can be specified either in dotted notation or with its name. Overrides the .Cm default_policy config file option. .It Fl queryfile Ar request.tsq The name of the file containing a DER-encoded time stamp request. .It Fl section Ar tsa_section The name of the config file section containing the settings for the response generation. If not specified the default TSA section is used; see .Sx TS CONFIGURATION FILE OPTIONS for details. .It Fl signer Ar tsa_cert.pem The signer certificate of the TSA in PEM format. The TSA signing certificate must have exactly one extended key usage assigned to it: timeStamping. The extended key usage must also be critical, otherwise the certificate is going to be refused. Overrides the .Cm signer_cert variable of the config file. .It Fl text If this option is specified the output is human-readable text format instead of DER. .It Fl token_in This flag can be used together with the .Fl in option and indicates that the input is a DER-encoded time stamp token (ContentInfo) instead of a time stamp response (TimeStampResp). .It Fl token_out The output is a time stamp token (ContentInfo) instead of time stamp response (TimeStampResp). .El .Pp The .Fl verify command is for verifying if a time stamp response or time stamp token is valid and matches a particular time stamp request or data file. The .Fl verify command does not use the configuration file. .Bl -tag -width Ds .It Fl CAfile Ar trusted_certs.pem The name of the file containing a set of trusted self-signed CA certificates in PEM format. See the similar option of .Nm verify for additional details. Either this option or .Fl CApath must be specified. .It Fl CApath Ar trusted_cert_path The name of the directory containing the trused CA certificates of the client. See the similar option of .Nm verify for additional details. Either this option or .Fl CAfile must be specified. .It Fl data Ar file_to_hash The response or token must be verified against .Ar file_to_hash . The file is hashed with the message digest algorithm specified in the token. The .Fl digest and .Fl queryfile options must not be specified with this one. .It Fl digest Ar digest_bytes The response or token must be verified against the message digest specified with this option. The number of bytes must match the message digest algorithm specified in the token. The .Fl data and .Fl queryfile options must not be specified with this one. .It Fl in Ar response.tsr The time stamp response that needs to be verified, in DER format. This option in mandatory. .It Fl queryfile Ar request.tsq The original time stamp request, in DER format. The .Fl data and .Fl digest options must not be specified with this one. .It Fl token_in This flag can be used together with the .Fl in option and indicates that the input is a DER-encoded time stamp token (ContentInfo) instead of a time stamp response (TimeStampResp). .It Fl untrusted Ar cert_file.pem Set of additional untrusted certificates in PEM format which may be needed when building the certificate chain for the TSA's signing certificate. This file must contain the TSA signing certificate and all intermediate CA certificates unless the response includes them. .El .Sh TS CONFIGURATION FILE OPTIONS The .Fl query and .Fl reply options make use of a configuration file defined by the .Ev OPENSSL_CONF environment variable. The .Fl query option uses only the symbolic OID names section and it can work without it. However, the .Fl reply option needs the config file for its operation. .Pp When there is a command line switch equivalent of a variable the switch always overrides the settings in the config file. .Bl -tag -width Ds .It Cm tsa Ar section , Cm default_tsa This is the main section and it specifies the name of another section that contains all the options for the .Fl reply option. This default section can be overridden with the .Fl section command line switch. .It Cm oid_file See .Nm ca for a description. .It Cm oid_section See .Nm ca for a description. .It Cm serial The name of the file containing the hexadecimal serial number of the last time stamp response created. This number is incremented by 1 for each response. If the file does not exist at the time of response generation a new file is created with serial number 1. This parameter is mandatory. .It Cm crypto_device Specifies the .Nm OpenSSL engine that will be set as the default for all available algorithms. .It Cm signer_cert TSA signing certificate, in PEM format. The same as the .Fl signer command line option. .It Cm certs A file containing a set of PEM-encoded certificates that need to be included in the response. The same as the .Fl chain command line option. .It Cm signer_key The private key of the TSA, in PEM format. The same as the .Fl inkey command line option. .It Cm default_policy The default policy to use when the request does not mandate any policy. The same as the .Fl policy command line option. .It Cm other_policies Comma separated list of policies that are also acceptable by the TSA and used only if the request explicitly specifies one of them. .It Cm digests The list of message digest algorithms that the TSA accepts. At least one algorithm must be specified. This parameter is mandatory. .It Cm accuracy The accuracy of the time source of the TSA in seconds, milliseconds and microseconds. For example, secs:1, millisecs:500, microsecs:100. If any of the components is missing, zero is assumed for that field. .It Cm clock_precision_digits Specifies the maximum number of digits, which represent the fraction of seconds, that need to be included in the time field. The trailing zeroes must be removed from the time, so there might actually be fewer digits, or no fraction of seconds at all. The maximum value is 6; the default is 0. .It Cm ordering If this option is yes, the responses generated by this TSA can always be ordered, even if the time difference between two responses is less than the sum of their accuracies. The default is no. .It Cm tsa_name Set this option to yes if the subject name of the TSA must be included in the TSA name field of the response. The default is no. .It Cm ess_cert_id_chain The SignedData objects created by the TSA always contain the certificate identifier of the signing certificate in a signed attribute (see RFC 2634, Enhanced Security Services). If this option is set to yes and either the .Cm certs variable or the .Fl chain option is specified then the certificate identifiers of the chain will also be included in the SigningCertificate signed attribute. If this variable is set to no, only the signing certificate identifier is included. The default is no. .El .Sh TS ENVIRONMENT VARIABLES .Ev OPENSSL_CONF contains the path of the configuration file and can be overridden by the .Fl config command line option. .Sh TS EXAMPLES All the examples below presume that .Ev OPENSSL_CONF is set to a proper configuration file, e.g. the example configuration file .Pa openssl/apps/openssl.cnf will do. .Pp To create a time stamp request for design1.txt with SHA-1 without nonce and policy and no certificate is required in the response: .Bd -literal -offset indent $ openssl ts -query -data design1.txt -no_nonce \e -out design1.tsq .Ed .Pp To create a similar time stamp request but specifying the message imprint explicitly: .Bd -literal -offset indent $ openssl ts -query \e -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \e -no_nonce -out design1.tsq .Ed .Pp To print the content of the previous request in human readable format: .Bd -literal -offset indent $ openssl ts -query -in design1.tsq -text .Ed .Pp To create a time stamp request which includes the MD5 digest of design2.txt, requests the signer certificate and nonce, specifies a policy ID (assuming the tsa_policy1 name is defined in the OID section of the config file): .Bd -literal -offset indent $ openssl ts -query -data design2.txt -md5 \e -policy tsa_policy1 -cert -out design2.tsq .Ed .Pp Before generating a response, a signing certificate must be created for the TSA that contains the .Cm timeStamping critical extended key usage extension without any other key usage extensions. You can add the .Dq extendedKeyUsage = critical,timeStamping line to the user certificate section of the config file to generate a proper certificate. See the .Nm req , .Nm ca , and .Nm x509 commands for instructions. The examples below assume that cacert.pem contains the certificate of the CA, tsacert.pem is the signing certificate issued by cacert.pem and tsakey.pem is the private key of the TSA. .Pp To create a time stamp response for a request: .Bd -literal -offset indent $ openssl ts -reply -queryfile design1.tsq -inkey tsakey.pem \e -signer tsacert.pem -out design1.tsr .Ed .Pp If you want to use the settings in the config file you could just write: .Bd -literal -offset indent $ openssl ts -reply -queryfile design1.tsq -out design1.tsr .Ed .Pp To print a time stamp reply to stdout in human readable format: .Bd -literal -offset indent $ openssl ts -reply -in design1.tsr -text .Ed .Pp To create a time stamp token instead of time stamp response: .Bd -literal -offset indent $ openssl ts -reply -queryfile design1.tsq \e -out design1_token.der -token_out .Ed .Pp To print a time stamp token to stdout in human readable format: .Bd -literal -offset indent $ openssl ts -reply -in design1_token.der -token_in \e -text -token_out .Ed .Pp To extract the time stamp token from a response: .Bd -literal -offset indent $ openssl ts -reply -in design1.tsr -out design1_token.der \e -token_out .Ed .Pp To add .Dq granted status info to a time stamp token thereby creating a valid response: .Bd -literal -offset indent $ openssl ts -reply -in design1_token.der \e -token_in -out design1.tsr .Ed .Pp To verify a time stamp reply against a request: .Bd -literal -offset indent $ openssl ts -verify -queryfile design1.tsq -in design1.tsr \e -CAfile cacert.pem -untrusted tsacert.pem .Ed .Pp To verify a time stamp reply that includes the certificate chain: .Bd -literal -offset indent $ openssl ts -verify -queryfile design2.tsq -in design2.tsr \e -CAfile cacert.pem .Ed .Pp To verify a time stamp token against the original data file: .Bd -literal -offset indent $ openssl ts -verify -data design2.txt -in design2.tsr \e -CAfile cacert.pem .Ed .Pp To verify a time stamp token against a message imprint: .Bd -literal -offset indent $ openssl ts -verify \e -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \e -in design2.tsr -CAfile cacert.pem .Ed .Sh TS BUGS No support for time stamps over SMTP, though it is quite easy to implement an automatic email-based TSA with .Xr procmail and .Xr perl 1 . Pure TCP/IP is not supported. .Pp The file containing the last serial number of the TSA is not locked when being read or written. This is a problem if more than one instance of .Nm OpenSSL is trying to create a time stamp response at the same time. .Pp Look for the FIXME word in the source files. .Pp The source code should really be reviewed by somebody else, too. .Pp More testing is needed. .Sh TS AUTHORS .An Zoltan Glozik Aq Mt zglozik@opentsa.org , OpenTSA project .Pq Lk http://www.opentsa.org . .\" .\" SPKAC .\" .Sh SPKAC .nr nS 1 .Nm "openssl spkac" .Bk -words .Op Fl challenge Ar string .Op Fl engine Ar id .Op Fl in Ar file .Op Fl key Ar keyfile .Op Fl noout .Op Fl out Ar file .Op Fl passin Ar arg .Op Fl pubkey .Op Fl spkac Ar spkacname .Op Fl spksect Ar section .Op Fl verify .Ek .nr nS 0 .Pp The .Nm spkac command processes Netscape signed public key and challenge .Pq SPKAC files. It can print out their contents, verify the signature, and produce its own SPKACs from a supplied private key. .Pp The options are as follows: .Bl -tag -width Ds .It Fl challenge Ar string Specifies the challenge string if an SPKAC is being created. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm spkac to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl in Ar file This specifies the input .Ar file to read from, or standard input if this option is not specified. Ignored if the .Fl key option is used. .It Fl key Ar keyfile Create an SPKAC file using the private key in .Ar keyfile . The .Fl in , noout , spksect , and .Fl verify options are ignored if present. .It Fl noout Don't output the text version of the SPKAC .Pq not used if an SPKAC is being created . .It Fl out Ar file Specifies the output .Ar file to write to, or standard output by default. .It Fl passin Ar arg The key password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .It Fl pubkey Output the public key of an SPKAC .Pq not used if an SPKAC is being created . .It Fl spkac Ar spkacname Allows an alternative name for the variable containing the SPKAC. The default is "SPKAC". This option affects both generated and input SPKAC files. .It Fl spksect Ar section Allows an alternative name for the .Ar section containing the SPKAC. The default is the default section. .It Fl verify Verifies the digital signature on the supplied SPKAC. .El .Sh SPKAC EXAMPLES Print out the contents of an SPKAC: .Pp .Dl $ openssl spkac -in spkac.cnf .Pp Verify the signature of an SPKAC: .Pp .Dl $ openssl spkac -in spkac.cnf -noout -verify .Pp Create an SPKAC using the challenge string .Qq hello : .Pp .Dl $ openssl spkac -key key.pem -challenge hello -out spkac.cnf .Pp Example of an SPKAC, .Pq long lines split up for clarity : .Bd -unfilled -offset indent SPKAC=MIG5MGUwXDANBgkqhkiG9w0BAQEFAANLADBIAkEA1cCoq2Wa3Ixs47uI7F\e PVwHVIPDx5yso105Y6zpozam135a8R0CpoRvkkigIyXfcCjiVi5oWk+6FfPaD03u\e PFoQIDAQABFgVoZWxsbzANBgkqhkiG9w0BAQQFAANBAFpQtY/FojdwkJh1bEIYuc\e 2EeM2KHTWPEepWYeawvHD0gQ3DngSC75YCWnnDdq+NQ3F+X4deMx9AaEglZtULwV\e 4= .Ed .Sh SPKAC NOTES A created SPKAC with suitable DN components appended can be fed into the .Nm ca utility. .Pp SPKACs are typically generated by Netscape when a form is submitted containing the .Em KEYGEN tag as part of the certificate enrollment process. .Pp The challenge string permits a primitive form of proof of possession of private key. By checking the SPKAC signature and a random challenge string, some guarantee is given that the user knows the private key corresponding to the public key being certified. This is important in some applications. Without this it is possible for a previous SPKAC to be used in a .Qq replay attack . .\" .\" VERIFY .\" .Sh VERIFY .nr nS 1 .Nm "openssl verify" .Bk -words .Op Fl CAfile Ar file .Op Fl CApath Ar directory .Op Fl check_ss_sig .Op Fl crl_check .Op Fl crl_check_all .Op Fl engine Ar id .Op Fl explicit_policy .Op Fl extended_crl .Op Fl help .Op Fl ignore_critical .Op Fl inhibit_any .Op Fl inhibit_map .Op Fl issuer_checks .Op Fl policy_check .Op Fl purpose Ar purpose .Op Fl untrusted Ar file .Op Fl verbose .Op Fl x509_strict .Op Fl .Op Ar certificates .Ek .nr nS 0 .Pp The .Nm verify command verifies certificate chains. .Pp The options are as follows: .Bl -tag -width Ds .It Fl check_ss_sig Verify the signature on the self-signed root CA. This is disabled by default because it doesn't add any security. .It Fl CAfile Ar file A .Ar file of trusted certificates. The .Ar file should contain multiple certificates in PEM format, concatenated together. .It Fl CApath Ar directory A .Ar directory of trusted certificates. The certificates should have names of the form .Em hash.0 , or have symbolic links to them of this form ("hash" is the hashed certificate subject name: see the .Fl hash option of the .Nm x509 utility). The .Nm c_rehash script distributed with OpenSSL will automatically create symbolic links to a directory of certificates. .It Fl crl_check Checks end entity certificate validity by attempting to look up a valid CRL. If a valid CRL cannot be found an error occurs. .It Fl crl_check_all Checks the validity of all certificates in the chain by attempting to look up valid CRLs. .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm verify to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl explicit_policy Set policy variable require-explicit-policy (see RFC 3280 et al). .It Fl extended_crl Enable extended CRL features such as indirect CRLs and alternate CRL signing keys. .It Fl help Prints out a usage message. .It Fl ignore_critical Normally if an unhandled critical extension is present which is not supported by .Nm OpenSSL , the certificate is rejected (as required by RFC 3280 et al). If this option is set, critical extensions are ignored. .It Fl inhibit_any Set policy variable inhibit-any-policy (see RFC 3280 et al). .It Fl inhibit_map Set policy variable inhibit-policy-mapping (see RFC 3280 et al). .It Fl issuer_checks Print out diagnostics relating to searches for the issuer certificate of the current certificate. This shows why each candidate issuer certificate was rejected. However the presence of rejection messages does not itself imply that anything is wrong: during the normal verify process several rejections may take place. .It Fl policy_check Enables certificate policy processing. .It Fl purpose Ar purpose The intended use for the certificate. Without this option no chain verification will be done. Currently accepted uses are .Ar sslclient , sslserver , .Ar nssslserver , smimesign , .Ar smimeencrypt , crlsign , .Ar any , and .Ar ocsphelper . See the .Sx VERIFY OPERATION section for more information. .It Fl untrusted Ar file A .Ar file of untrusted certificates. The .Ar file should contain multiple certificates. .It Fl verbose Print extra information about the operations being performed. .It Fl x509_strict Disable workarounds for broken certificates which have to be disabled for strict X.509 compliance. .It Fl Marks the last option. All arguments following this are assumed to be certificate files. This is useful if the first certificate filename begins with a .Sq - . .It Ar certificates One or more .Ar certificates to verify. If no certificate files are included, an attempt is made to read a certificate from standard input. They should all be in PEM format. .El .Sh VERIFY OPERATION The .Nm verify program uses the same functions as the internal SSL and S/MIME verification, therefore this description applies to these verify operations too. .Pp There is one crucial difference between the verify operations performed by the .Nm verify program: wherever possible an attempt is made to continue after an error, whereas normally the verify operation would halt on the first error. This allows all the problems with a certificate chain to be determined. .Pp The verify operation consists of a number of separate steps: .Pp Firstly a certificate chain is built up starting from the supplied certificate and ending in the root CA. It is an error if the whole chain cannot be built up. The chain is built up by looking up the issuer's certificate of the current certificate. If a certificate is found which is its own issuer, it is assumed to be the root CA. .Pp The process of .Qq looking up the issuer's certificate itself involves a number of steps. In versions of .Nm OpenSSL before 0.9.5a the first certificate whose subject name matched the issuer of the current certificate was assumed to be the issuer's certificate. In .Nm OpenSSL 0.9.6 and later all certificates whose subject name matches the issuer name of the current certificate are subject to further tests. The relevant authority key identifier components of the current certificate .Pq if present must match the subject key identifier .Pq if present and issuer and serial number of the candidate issuer; in addition the .Em keyUsage extension of the candidate issuer .Pq if present must permit certificate signing. .Pp The lookup first looks in the list of untrusted certificates and if no match is found the remaining lookups are from the trusted certificates. The root CA is always looked up in the trusted certificate list: if the certificate to verify is a root certificate, then an exact match must be found in the trusted list. .Pp The second operation is to check every untrusted certificate's extensions for consistency with the supplied purpose. If the .Fl purpose option is not included, then no checks are done. The supplied or .Qq leaf certificate must have extensions compatible with the supplied purpose and all other certificates must also be valid CA certificates. The precise extensions required are described in more detail in the .Sx X.509 CERTIFICATE EXTENSIONS section below. .Pp The third operation is to check the trust settings on the root CA. The root CA should be trusted for the supplied purpose. For compatibility with previous versions of .Nm SSLeay and .Nm OpenSSL , a certificate with no trust settings is considered to be valid for all purposes. .Pp The final operation is to check the validity of the certificate chain. The validity period is checked against the current system time and the .Em notBefore and .Em notAfter dates in the certificate. The certificate signatures are also checked at this point. .Pp If all operations complete successfully, the certificate is considered valid. If any operation fails then the certificate is not valid. .Sh VERIFY DIAGNOSTICS When a verify operation fails, the output messages can be somewhat cryptic. The general form of the error message is: .Bd -unfilled \& server.pem: /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024-bit) \& error 24 at 1 depth lookup:invalid CA certificate .Ed .Pp The first line contains the name of the certificate being verified, followed by the subject name of the certificate. The second line contains the error number and the depth. The depth is the number of the certificate being verified when a problem was detected starting with zero for the certificate being verified itself, then 1 for the CA that signed the certificate and so on. Finally a text version of the error number is presented. .Pp An exhaustive list of the error codes and messages is shown below; this also includes the name of the error code as defined in the header file .Aq Pa openssl/x509_vfy.h . Some of the error codes are defined but never returned: these are described as .Qq unused . .Bl -tag -width "XXXX" .It Ar "0 X509_V_OK: ok" The operation was successful. .It Ar 2 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate The issuer certificate could not be found: this occurs if the issuer certificate of an untrusted certificate cannot be found. .It Ar 3 X509_V_ERR_UNABLE_TO_GET_CRL: unable to get certificate CRL The CRL of a certificate could not be found. .It Ar 4 X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate's signature The certificate signature could not be decrypted. This means that the actual signature value could not be determined rather than it not matching the expected value. This is only meaningful for RSA keys. .It Ar 5 X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt CRL's signature The CRL signature could not be decrypted: this means that the actual signature value could not be determined rather than it not matching the expected value. Unused. .It Ar 6 X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key The public key in the certificate .Em SubjectPublicKeyInfo could not be read. .It Ar 7 X509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure The signature of the certificate is invalid. .It Ar 8 X509_V_ERR_CRL_SIGNATURE_FAILURE: CRL signature failure The signature of the certificate is invalid. .It Ar 9 X509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid The certificate is not yet valid: the .Em notBefore date is after the current time. .It Ar 10 X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired The certificate has expired; that is, the .Em notAfter date is before the current time. .It Ar 11 X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid The CRL is not yet valid. .It Ar 12 X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired The CRL has expired. .It Ar 13 X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate's notBefore field The certificate .Em notBefore field contains an invalid time. .It Ar 14 X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate's notAfter field The certificate .Em notAfter field contains an invalid time. .It Ar 15 X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in CRL's lastUpdate field The CRL .Em lastUpdate field contains an invalid time. .It Ar 16 X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in CRL's nextUpdate field The CRL .Em nextUpdate field contains an invalid time. .It Ar 17 X509_V_ERR_OUT_OF_MEM: out of memory An error occurred trying to allocate memory. This should never happen. .It Ar 18 X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate The passed certificate is self-signed and the same certificate cannot be found in the list of trusted certificates. .It Ar 19 X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain The certificate chain could be built up using the untrusted certificates but the root could not be found locally. .It Ar 20 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate The issuer certificate of a locally looked up certificate could not be found. This normally means the list of trusted certificates is not complete. .It Ar 21 X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate No signatures could be verified because the chain contains only one certificate and it is not self-signed. .It Ar 22 X509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long The certificate chain length is greater than the supplied maximum depth. Unused. .It Ar 23 X509_V_ERR_CERT_REVOKED: certificate revoked The certificate has been revoked. .It Ar 24 X509_V_ERR_INVALID_CA: invalid CA certificate A CA certificate is invalid. Either it is not a CA or its extensions are not consistent with the supplied purpose. .It Ar 25 X509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded The .Em basicConstraints pathlength parameter has been exceeded. .It Ar 26 X509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose The supplied certificate cannot be used for the specified purpose. .It Ar 27 X509_V_ERR_CERT_UNTRUSTED: certificate not trusted The root CA is not marked as trusted for the specified purpose. .It Ar 28 X509_V_ERR_CERT_REJECTED: certificate rejected The root CA is marked to reject the specified purpose. .It Ar 29 X509_V_ERR_SUBJECT_ISSUER_MISMATCH: subject issuer mismatch The current candidate issuer certificate was rejected because its subject name did not match the issuer name of the current certificate. Only displayed when the .Fl issuer_checks option is set. .It Ar 30 X509_V_ERR_AKID_SKID_MISMATCH: authority and subject key identifier mismatch The current candidate issuer certificate was rejected because its subject key identifier was present and did not match the authority key identifier current certificate. Only displayed when the .Fl issuer_checks option is set. .It Ar 31 X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: authority and issuer serial number mismatch The current candidate issuer certificate was rejected because its issuer name and serial number were present and did not match the authority key identifier of the current certificate. Only displayed when the .Fl issuer_checks option is set. .It Ar 32 X509_V_ERR_KEYUSAGE_NO_CERTSIGN:key usage does not include certificate signing The current candidate issuer certificate was rejected because its .Em keyUsage extension does not permit certificate signing. .It Ar 50 X509_V_ERR_APPLICATION_VERIFICATION: application verification failure An application specific error. Unused. .El .Sh VERIFY BUGS Although the issuer checks are a considerable improvement over the old technique, they still suffer from limitations in the underlying X509_LOOKUP API. One consequence of this is that trusted certificates with matching subject name must either appear in a file (as specified by the .Fl CAfile option) or a directory (as specified by .Fl CApath ) . If they occur in both, only the certificates in the file will be recognised. .Pp Previous versions of .Nm OpenSSL assumed certificates with matching subject name were identical and mishandled them. .\" .\" VERSION .\" .Sh VERSION .Nm openssl version .Op Fl abdfopv .Pp The .Nm version command is used to print out version information about .Nm OpenSSL . .Pp The options are as follows: .Bl -tag -width Ds .It Fl a All information: this is the same as setting all the other flags. .It Fl b The date the current version of .Nm OpenSSL was built. .It Fl d .Ev OPENSSLDIR setting. .It Fl f Compilation flags. .It Fl o Option information: various options set when the library was built. .It Fl p Platform setting. .It Fl v The current .Nm OpenSSL version. .El .Sh VERSION NOTES The output of .Nm openssl version -a would typically be used when sending in a bug report. .Sh VERSION HISTORY The .Fl d option was added in .Nm OpenSSL 0.9.7. .\" .\" X509 .\" .Sh X509 .nr nS 1 .Nm "openssl x509" .Bk -words .Op Fl C .Op Fl addreject Ar arg .Op Fl addtrust Ar arg .Op Fl alias .Op Fl CA Ar file .Op Fl CAcreateserial .Op Fl CAform Ar DER | PEM .Op Fl CAkey Ar file .Op Fl CAkeyform Ar DER | PEM .Op Fl CAserial Ar file .Op Fl certopt Ar option .Op Fl checkend Ar arg .Op Fl clrext .Op Fl clrreject .Op Fl clrtrust .Op Fl dates .Op Fl days Ar arg .Op Fl email .Op Fl enddate .Op Fl engine Ar id .Op Fl extensions Ar section .Op Fl extfile Ar file .Op Fl fingerprint .Op Fl hash .Op Fl in Ar file .Op Fl inform Ar DER | NET | PEM .Op Fl issuer .Op Fl issuer_hash .Op Fl issuer_hash_old .Op Fl keyform Ar DER | PEM .Op Fl md2 | md5 | sha1 .Op Fl modulus .Op Fl nameopt Ar option .Op Fl noout .Op Fl ocsp_uri .Op Fl ocspid .Op Fl out Ar file .Op Fl outform Ar DER | NET | PEM .Op Fl passin Ar arg .Op Fl pubkey .Op Fl purpose .Op Fl req .Op Fl serial .Op Fl set_serial Ar n .Op Fl setalias Ar arg .Op Fl signkey Ar file .Op Fl startdate .Op Fl subject .Op Fl subject_hash .Op Fl subject_hash_old .Op Fl text .Op Fl trustout .Op Fl x509toreq .Ek .nr nS 0 .Pp The .Nm x509 command is a multi-purpose certificate utility. It can be used to display certificate information, convert certificates to various forms, sign certificate requests like a .Qq mini CA , or edit certificate trust settings. .Pp Since there are a large number of options, they are split up into various sections. .Sh X509 INPUT, OUTPUT, AND GENERAL PURPOSE OPTIONS .Bl -tag -width "XXXX" .It Fl engine Ar id Specifying an engine (by its unique .Ar id string) will cause .Nm x509 to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .It Fl in Ar file This specifies the input .Ar file to read a certificate from, or standard input if this option is not specified. .It Fl inform Ar DER | NET | PEM This specifies the input format. Normally, the command will expect an X.509 certificate, but this can change if other options such as .Fl req are present. The .Ar DER format is the DER encoding of the certificate and .Ar PEM is the base64 encoding of the DER encoding with header and footer lines added. The .Ar NET option is an obscure Netscape server format that is now obsolete. .It Fl md2 | md5 | sha1 The digest to use. This affects any signing or display option that uses a message digest, such as the .Fl fingerprint , signkey , and .Fl CA options. If not specified, MD5 is used. If the key being used to sign with is a DSA key, this option has no effect: SHA1 is always used with DSA keys. .It Fl out Ar file This specifies the output .Ar file to write to, or standard output by default. .It Fl outform Ar DER | NET | PEM This specifies the output format; the options have the same meaning as the .Fl inform option. .It Fl passin Ar arg The key password source. For more information about the format of .Ar arg , see the .Sx PASS PHRASE ARGUMENTS section above. .El .Sh X509 DISPLAY OPTIONS .Sy Note : The .Fl alias and .Fl purpose options are also display options but are described in the .Sx X509 TRUST SETTINGS section. .Bl -tag -width "XXXX" .It Fl C This outputs the certificate in the form of a C source file. .It Fl certopt Ar option Customise the output format used with .Fl text . The .Ar option argument can be a single option or multiple options separated by commas. The .Fl certopt switch may also be used more than once to set multiple options. See the .Sx X509 TEXT OPTIONS section for more information. .It Fl dates Prints out the start and expiry dates of a certificate. .It Fl email Outputs the email address(es), if any. .It Fl enddate Prints out the expiry date of the certificate; that is, the .Em notAfter date. .It Fl fingerprint Prints out the digest of the DER-encoded version of the whole certificate (see .Sx DIGEST OPTIONS ) . .It Fl hash A synonym for .Fl subject_hash , for backwards compatibility. .It Fl issuer Outputs the issuer name. .It Fl issuer_hash Outputs the .Qq hash of the certificate issuer name. .It Fl issuer_hash_old Outputs the .Qq hash of the certificate issuer name using the older algorithm as used by .Nm OpenSSL versions before 1.0.0. .It Fl modulus This option prints out the value of the modulus of the public key contained in the certificate. .It Fl nameopt Ar option Option which determines how the subject or issuer names are displayed. The .Ar option argument can be a single option or multiple options separated by commas. Alternatively, the .Fl nameopt switch may be used more than once to set multiple options. See the .Sx X509 NAME OPTIONS section for more information. .It Fl noout This option prevents output of the encoded version of the request. .It Fl ocsp_uri Outputs the OCSP responder addresses, if any. .It Fl ocspid Print OCSP hash values for the subject name and public key. .It Fl pubkey Output the public key. .It Fl serial Outputs the certificate serial number. .It Fl startdate Prints out the start date of the certificate; that is, the .Em notBefore date. .It Fl subject Outputs the subject name. .It Fl subject_hash Outputs the .Qq hash of the certificate subject name. This is used in .Nm OpenSSL to form an index to allow certificates in a directory to be looked up by subject name. .It Fl subject_hash_old Outputs the .Qq hash of the certificate subject name using the older algorithm as used by .Nm OpenSSL versions before 1.0.0. .It Fl text Prints out the certificate in text form. Full details are output including the public key, signature algorithms, issuer and subject names, serial number, any extensions present, and any trust settings. .El .Sh X509 TRUST SETTINGS Please note these options are currently experimental and may well change. .Pp A .Em trusted certificate is an ordinary certificate which has several additional pieces of information attached to it such as the permitted and prohibited uses of the certificate and an .Qq alias . .Pp Normally, when a certificate is being verified at least one certificate must be .Qq trusted . By default, a trusted certificate must be stored locally and must be a root CA: any certificate chain ending in this CA is then usable for any purpose. .Pp Trust settings currently are only used with a root CA. They allow a finer control over the purposes the root CA can be used for. For example, a CA may be trusted for an SSL client but not for SSL server use. .Pp See the description of the .Nm verify utility for more information on the meaning of trust settings. .Pp Future versions of .Nm OpenSSL will recognize trust settings on any certificate: not just root CAs. .Bl -tag -width "XXXX" .It Fl addreject Ar arg Adds a prohibited use. It accepts the same values as the .Fl addtrust option. .It Fl addtrust Ar arg Adds a trusted certificate use. Any object name can be used here, but currently only .Ar clientAuth .Pq SSL client use , .Ar serverAuth .Pq SSL server use , and .Ar emailProtection .Pq S/MIME email are used. Other .Nm OpenSSL applications may define additional uses. .It Fl alias Outputs the certificate alias, if any. .It Fl clrreject Clears all the prohibited or rejected uses of the certificate. .It Fl clrtrust Clears all the permitted or trusted uses of the certificate. .It Fl purpose This option performs tests on the certificate extensions and outputs the results. For a more complete description, see the .Sx X.509 CERTIFICATE EXTENSIONS section. .It Fl setalias Ar arg Sets the alias of the certificate. This will allow the certificate to be referred to using a nickname, for example .Qq Steve's Certificate . .It Fl trustout This causes .Nm x509 to output a .Em trusted certificate . An ordinary or trusted certificate can be input, but by default an ordinary certificate is output and any trust settings are discarded. With the .Fl trustout option a trusted certificate is output. A trusted certificate is automatically output if any trust settings are modified. .El .Sh X509 SIGNING OPTIONS The .Nm x509 utility can be used to sign certificates and requests: it can thus behave like a .Qq mini CA . .Bl -tag -width "XXXX" .It Fl CA Ar file Specifies the CA certificate to be used for signing. When this option is present, .Nm x509 behaves like a .Qq mini CA . The input file is signed by the CA using this option; that is, its issuer name is set to the subject name of the CA and it is digitally signed using the CA's private key. .Pp This option is normally combined with the .Fl req option. Without the .Fl req option, the input is a certificate which must be self-signed. .It Fl CAcreateserial With this option the CA serial number file is created if it does not exist: it will contain the serial number .Sq 02 and the certificate being signed will have .Sq 1 as its serial number. Normally, if the .Fl CA option is specified and the serial number file does not exist, it is an error. .It Fl CAform Ar DER | PEM The format of the CA certificate file. The default is .Ar PEM . .It Fl CAkey Ar file Sets the CA private key to sign a certificate with. If this option is not specified, it is assumed that the CA private key is present in the CA certificate file. .It Fl CAkeyform Ar DER | PEM The format of the CA private key. The default is .Ar PEM . .It Fl CAserial Ar file Sets the CA serial number file to use. .Pp When the .Fl CA option is used to sign a certificate, it uses a serial number specified in a file. This file consists of one line containing an even number of hex digits with the serial number to use. After each use the serial number is incremented and written out to the file again. .Pp The default filename consists of the CA certificate file base name with .Pa .srl appended. For example, if the CA certificate file is called .Pa mycacert.pem , it expects to find a serial number file called .Pa mycacert.srl . .It Fl checkend Ar arg Check whether the certificate expires in the next .Ar arg seconds. If so, exit with return value 1; otherwise exit with return value 0. .It Fl clrext Delete any extensions from a certificate. This option is used when a certificate is being created from another certificate (for example with the .Fl signkey or the .Fl CA options). Normally, all extensions are retained. .It Fl days Ar arg Specifies the number of days to make a certificate valid for. The default is 30 days. .It Fl extensions Ar section The section to add certificate extensions from. If this option is not specified, the extensions should either be contained in the unnamed .Pq default section or the default section should contain a variable called .Qq extensions which contains the section to use. .It Fl extfile Ar file File containing certificate extensions to use. If not specified, no extensions are added to the certificate. .It Fl keyform Ar DER | PEM Specifies the format .Pq DER or PEM of the private key file used in the .Fl signkey option. .It Fl req By default, a certificate is expected on input. With this option a certificate request is expected instead. .It Fl set_serial Ar n Specifies the serial number to use. This option can be used with either the .Fl signkey or .Fl CA options. If used in conjunction with the .Fl CA option, the serial number file (as specified by the .Fl CAserial or .Fl CAcreateserial options) is not used. .Pp The serial number can be decimal or hex (if preceded by .Sq 0x ) . Negative serial numbers can also be specified but their use is not recommended. .It Fl signkey Ar file This option causes the input file to be self-signed using the supplied private key. .Pp If the input file is a certificate, it sets the issuer name to the subject name .Pq i.e. makes it self-signed , changes the public key to the supplied value, and changes the start and end dates. The start date is set to the current time and the end date is set to a value determined by the .Fl days option. Any certificate extensions are retained unless the .Fl clrext option is supplied. .Pp If the input is a certificate request, a self-signed certificate is created using the supplied private key using the subject name in the request. .It Fl x509toreq Converts a certificate into a certificate request. The .Fl signkey option is used to pass the required private key. .El .Sh X509 NAME OPTIONS The .Fl nameopt command line switch determines how the subject and issuer names are displayed. If no .Fl nameopt switch is present, the default .Qq oneline format is used which is compatible with previous versions of .Nm OpenSSL . Each option is described in detail below; all options can be preceded by a .Sq - to turn the option off. Only .Ar compat , .Ar RFC2253 , .Ar oneline , and .Ar multiline will normally be used. .Bl -tag -width "XXXX" .It Ar align Align field values for a more readable output. Only usable with .Ar sep_multiline . .It Ar compat Use the old format. This is equivalent to specifying no name options at all. .It Ar dn_rev Reverse the fields of the DN. This is required by RFC 2253. As a side effect, this also reverses the order of multiple AVAs but this is permissible. .It Ar dump_all Dump all fields. This option, when used with .Ar dump_der , allows the DER encoding of the structure to be unambiguously determined. .It Ar dump_der When this option is set, any fields that need to be hexdumped will be dumped using the DER encoding of the field. Otherwise just the content octets will be displayed. Both options use the RFC 2253 #XXXX... format. .It Ar dump_nostr Dump non-character string types .Pq for example OCTET STRING ; if this option is not set, non-character string types will be displayed as though each content octet represents a single character. .It Ar dump_unknown Dump any field whose OID is not recognised by .Nm OpenSSL . .It Ar esc_2253 Escape the .Qq special characters required by RFC 2253 in a field that is .Dq \& ,+"\*(Lt\*(Gt; . Additionally, .Sq # is escaped at the beginning of a string and a space character at the beginning or end of a string. .It Ar esc_ctrl Escape control characters. That is, those with ASCII values less than 0x20 .Pq space and the delete .Pq 0x7f character. They are escaped using the RFC 2253 \eXX notation (where XX are two hex digits representing the character value). .It Ar esc_msb Escape characters with the MSB set; that is, with ASCII values larger than 127. .It Ar multiline A multiline format. It is equivalent to .Ar esc_ctrl , esc_msb , sep_multiline , .Ar space_eq , lname , and .Ar align . .It Ar no_type This option does not attempt to interpret multibyte characters in any way. That is, their content octets are merely dumped as though one octet represents each character. This is useful for diagnostic purposes but will result in rather odd looking output. .It Ar nofname , sname , lname , oid These options alter how the field name is displayed. .Ar nofname does not display the field at all. .Ar sname uses the .Qq short name form (CN for .Ar commonName , for example). .Ar lname uses the long form. .Ar oid represents the OID in numerical form and is useful for diagnostic purpose. .It Ar oneline A oneline format which is more readable than .Ar RFC2253 . It is equivalent to specifying the .Ar esc_2253 , esc_ctrl , esc_msb , utf8 , .Ar dump_nostr , dump_der , use_quote , sep_comma_plus_spc , .Ar space_eq , and .Ar sname options. .It Ar RFC2253 Displays names compatible with RFC 2253; equivalent to .Ar esc_2253 , esc_ctrl , .Ar esc_msb , utf8 , dump_nostr , dump_unknown , .Ar dump_der , sep_comma_plus , dn_rev , and .Ar sname . .It Ar sep_comma_plus , sep_comma_plus_space , sep_semi_plus_space , sep_multiline These options determine the field separators. The first character is between RDNs and the second between multiple AVAs (multiple AVAs are very rare and their use is discouraged). The options ending in .Qq space additionally place a space after the separator to make it more readable. The .Ar sep_multiline uses a linefeed character for the RDN separator and a spaced .Sq + for the AVA separator. It also indents the fields by four characters. .It Ar show_type Show the type of the ASN1 character string. The type precedes the field contents. For example .Qq BMPSTRING: Hello World . .It Ar space_eq Places spaces round the .Sq = character which follows the field name. .It Ar use_quote Escapes some characters by surrounding the whole string with .Sq \&" characters. Without the option, all escaping is done with the .Sq \e character. .It Ar utf8 Convert all strings to UTF8 format first. This is required by RFC 2253. If you are lucky enough to have a UTF8 compatible terminal, the use of this option (and .Em not setting .Ar esc_msb ) may result in the correct display of multibyte .Pq international characters. If this option is not present, multibyte characters larger than 0xff will be represented using the format \eUXXXX for 16 bits and \eWXXXXXXXX for 32 bits. Also, if this option is off, any UTF8Strings will be converted to their character form first. .El .Sh X509 TEXT OPTIONS As well as customising the name output format, it is also possible to customise the actual fields printed using the .Fl certopt options when the .Fl text option is present. The default behaviour is to print all fields. .Bl -tag -width "XXXX" .It Ar ca_default The value used by the .Nm ca utility; equivalent to .Ar no_issuer , no_pubkey , no_header , .Ar no_version , no_sigdump , and .Ar no_signame . .It Ar compatible Use the old format. This is equivalent to specifying no output options at all. .It Ar ext_default Retain default extension behaviour: attempt to print out unsupported certificate extensions. .It Ar ext_dump Hex dump unsupported extensions. .It Ar ext_error Print an error message for unsupported certificate extensions. .It Ar ext_parse ASN1 parse unsupported extensions. .It Ar no_aux Don't print out certificate trust information. .It Ar no_extensions Don't print out any X509V3 extensions. .It Ar no_header Don't print header information: that is, the lines saying .Qq Certificate and .Qq Data . .It Ar no_issuer Don't print out the issuer name. .It Ar no_pubkey Don't print out the public key. .It Ar no_serial Don't print out the serial number. .It Ar no_sigdump Don't give a hexadecimal dump of the certificate signature. .It Ar no_signame Don't print out the signature algorithm used. .It Ar no_subject Don't print out the subject name. .It Ar no_validity Don't print the validity; that is, the .Em notBefore and .Em notAfter fields. .It Ar no_version Don't print out the version number. .El .Sh X509 EXAMPLES Display the contents of a certificate: .Pp .Dl $ openssl x509 -in cert.pem -noout -text .Pp Display the certificate serial number: .Pp .Dl $ openssl x509 -in cert.pem -noout -serial .Pp Display the certificate subject name: .Pp .Dl $ openssl x509 -in cert.pem -noout -subject .Pp Display the certificate subject name in RFC 2253 form: .Pp .Dl $ openssl x509 -in cert.pem -noout -subject -nameopt RFC2253 .Pp Display the certificate subject name in oneline form on a terminal supporting UTF8: .Bd -literal -offset indent $ openssl x509 -in cert.pem -noout -subject \e -nameopt oneline,-esc_msb .Ed .Pp Display the certificate MD5 fingerprint: .Pp .Dl $ openssl x509 -in cert.pem -noout -fingerprint .Pp Display the certificate SHA1 fingerprint: .Pp .Dl $ openssl x509 -sha1 -in cert.pem -noout -fingerprint .Pp Convert a certificate from PEM to DER format: .Pp .Dl "$ openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER" .Pp Convert a certificate to a certificate request: .Bd -literal -offset indent $ openssl x509 -x509toreq -in cert.pem -out req.pem \e -signkey key.pem .Ed .Pp Convert a certificate request into a self-signed certificate using extensions for a CA: .Bd -literal -offset indent $ openssl x509 -req -in careq.pem -extfile openssl.cnf -extensions \e v3_ca -signkey key.pem -out cacert.pem .Ed .Pp Sign a certificate request using the CA certificate above and add user certificate extensions: .Bd -literal -offset indent $ openssl x509 -req -in req.pem -extfile openssl.cnf -extensions \e v3_usr -CA cacert.pem -CAkey key.pem -CAcreateserial .Ed .Pp Set a certificate to be trusted for SSL client use and set its alias to .Qq Steve's Class 1 CA : .Bd -literal -offset indent $ openssl x509 -in cert.pem -addtrust clientAuth \e -setalias "Steve's Class 1 CA" -out trust.pem .Ed .Sh X509 NOTES The PEM format uses the header and footer lines: .Bd -unfilled -offset indent -----BEGIN CERTIFICATE----- -----END CERTIFICATE----- .Ed .Pp It will also handle files containing: .Bd -unfilled -offset indent -----BEGIN X509 CERTIFICATE----- -----END X509 CERTIFICATE----- .Ed .Pp Trusted certificates have the lines: .Bd -unfilled -offset indent -----BEGIN TRUSTED CERTIFICATE----- -----END TRUSTED CERTIFICATE----- .Ed .Pp The conversion to UTF8 format used with the name options assumes that T61Strings use the ISO 8859-1 character set. This is wrong, but Netscape and MSIE do this, as do many certificates. So although this is incorrect it is more likely to display the majority of certificates correctly. .Pp The .Fl fingerprint option takes the digest of the DER-encoded certificate. This is commonly called a .Qq fingerprint . Because of the nature of message digests, the fingerprint of a certificate is unique to that certificate and two certificates with the same fingerprint can be considered to be the same. .Pp The Netscape fingerprint uses MD5, whereas MSIE uses SHA1. .Pp The .Fl email option searches the subject name and the subject alternative name extension. Only unique email addresses will be printed out: it will not print the same address more than once. .Sh X.509 CERTIFICATE EXTENSIONS The .Fl purpose option checks the certificate extensions and determines what the certificate can be used for. The actual checks done are rather complex and include various hacks and workarounds to handle broken certificates and software. .Pp The same code is used when verifying untrusted certificates in chains, so this section is useful if a chain is rejected by the verify code. .Pp The .Em basicConstraints extension CA flag is used to determine whether the certificate can be used as a CA. If the CA flag is true, it is a CA; if the CA flag is false, it is not a CA. .Em All CAs should have the CA flag set to true. .Pp If the .Em basicConstraints extension is absent, then the certificate is considered to be a .Qq possible CA ; other extensions are checked according to the intended use of the certificate. A warning is given in this case because the certificate should really not be regarded as a CA: however, it is allowed to be a CA to work around some broken software. .Pp If the certificate is a V1 certificate .Pq and thus has no extensions and it is self-signed, it is also assumed to be a CA but a warning is again given: this is to work around the problem of Verisign roots which are V1 self-signed certificates. .Pp If the .Em keyUsage extension is present, then additional restraints are made on the uses of the certificate. A CA certificate .Em must have the .Em keyCertSign bit set if the .Em keyUsage extension is present. .Pp The extended key usage extension places additional restrictions on the certificate uses. If this extension is present .Pq whether critical or not , the key can only be used for the purposes specified. .Pp A complete description of each test is given below. The comments about .Em basicConstraints and .Em keyUsage and V1 certificates above apply to .Em all CA certificates. .Bl -tag -width "XXXX" .It Ar SSL Client The extended key usage extension must be absent or include the .Qq web client authentication OID. .Ar keyUsage must be absent or it must have the .Em digitalSignature bit set. Netscape certificate type must be absent or it must have the SSL client bit set. .It Ar SSL Client CA The extended key usage extension must be absent or include the .Qq web client authentication OID. Netscape certificate type must be absent or it must have the SSL CA bit set: this is used as a work around if the .Em basicConstraints extension is absent. .It Ar SSL Server The extended key usage extension must be absent or include the .Qq web server authentication and/or one of the SGC OIDs. .Em keyUsage must be absent or it must have the .Em digitalSignature set, the .Em keyEncipherment set, or both bits set. Netscape certificate type must be absent or have the SSL server bit set. .It Ar SSL Server CA The extended key usage extension must be absent or include the .Qq web server authentication and/or one of the SGC OIDs. Netscape certificate type must be absent or the SSL CA bit must be set: this is used as a work around if the .Em basicConstraints extension is absent. .It Ar Netscape SSL Server For Netscape SSL clients to connect to an SSL server; it must have the .Em keyEncipherment bit set if the .Em keyUsage extension is present. This isn't always valid because some cipher suites use the key for digital signing. Otherwise it is the same as a normal SSL server. .It Ar Common S/MIME Client Tests The extended key usage extension must be absent or include the .Qq email protection OID. Netscape certificate type must be absent or should have the .Em S/MIME bit set. If the .Em S/MIME bit is not set in Netscape certificate type, then the SSL client bit is tolerated as an alternative but a warning is shown: this is because some Verisign certificates don't set the .Em S/MIME bit. .It Ar S/MIME Signing In addition to the common .Em S/MIME client tests, the .Em digitalSignature bit must be set if the .Em keyUsage extension is present. .It Ar S/MIME Encryption In addition to the common .Em S/MIME tests, the .Em keyEncipherment bit must be set if the .Em keyUsage extension is present. .It Ar S/MIME CA The extended key usage extension must be absent or include the .Qq email protection OID. Netscape certificate type must be absent or must have the .Em S/MIME CA bit set: this is used as a work around if the .Em basicConstraints extension is absent. .It Ar CRL Signing The .Em keyUsage extension must be absent or it must have the .Em CRL signing bit set. .It Ar CRL Signing CA The normal CA tests apply. Except in this case the .Em basicConstraints extension must be present. .El .Sh X509 BUGS Extensions in certificates are not transferred to certificate requests and vice versa. .Pp It is possible to produce invalid certificates or requests by specifying the wrong private key or using inconsistent options in some cases: these should be checked. .Pp There should be options to explicitly set such things as start and end dates, rather than an offset from the current time. .Pp The code to implement the verify behaviour described in the .Sx X509 TRUST SETTINGS is currently being developed. It thus describes the intended behaviour rather than the current behaviour. It is hoped that it will represent reality in .Nm OpenSSL 0.9.5 and later. .Sh X509 HISTORY Before .Nm OpenSSL 0.9.8, the default digest for RSA keys was MD5. .Pp The hash algorithm used in the .Fl subject_hash and .Fl issuer_hash options before .Nm OpenSSL 1.0.0 was based on the deprecated MD5 algorithm and the encoding of the distinguished name. In .Nm OpenSSL 1.0.0 and later it is based on a canonical version of the DN using SHA1. This means that any directories using the old form must have their links rebuilt using .Ar c_rehash or similar. .\" .\" FILES .\" .Sh FILES .Bl -tag -width "/etc/ssl/openssl.cnf" -compact .It /etc/ssl/ Default config directory for .Nm openssl . .It /etc/ssl/lib/ Unused. .It /etc/ssl/private/ Default private key directory. .It /etc/ssl/openssl.cnf Default configuration file for .Nm openssl . .It /etc/ssl/x509v3.cnf Default configuration file for .Nm x509 certificates. .El .\" .\" SEE ALSO .\" .Sh SEE ALSO .Xr nginx 8 , .Xr sendmail 8 , .Xr ssl 8 , .Xr starttls 8 .Sh STANDARDS .Rs .%D February 1995 .%Q Netscape Communications Corp. .%T The SSL Protocol .Re .Pp .Rs .%D November 1996 .%Q Netscape Communications Corp. .%T The SSL 3.0 Protocol .Re .Pp .Rs .%A T. Dierks .%A C. Allen .%D January 1999 .%R RFC 2246 .%T The TLS Protocol Version 1.0 .Re .Pp .Rs .%A M. Wahl .%A S. Killie .%A T. Howes .%D December 1997 .%R RFC 2253 .%T Lightweight Directory Access Protocol (v3): UTF-8 String Representation of Distinguished Names .Re .Pp .Rs .%A B. Kaliski .%D March 1998 .%R RFC 2315 .%T PKCS #7: Cryptographic Message Syntax Version 1.5 .Re .Pp .Rs .%A R. Housley .%A W. Ford .%A W. Polk .%A D. Solo .%D January 1999 .%R RFC 2459 .%T Internet X.509 Public Key Infrastructure Certificate and CRL Profile .Re .Pp .Rs .%A M. Myers .%A R. Ankney .%A A. Malpani .%A S. Galperin .%A C. Adams .%D June 1999 .%R RFC 2560 .%T X.509 Internet Public Key Infrastructure Online Certificate Status Protocol \(en OCSP .Re .Pp .Rs .%A R. Housley .%D June 1999 .%R RFC 2630 .%T Cryptographic Message Syntax .Re .Pp .Rs .%A P. Chown .%D June 2002 .%R RFC 3268 .%T Advanced Encryption Standard (AES) Ciphersuites for Transport Layer Security(TLS) .Re .\" .\" OPENSSL HISTORY .\" .Sh HISTORY The .Xr openssl 1 document appeared in .Nm OpenSSL 0.9.2. The .Cm list- Ns XXX Ns Cm -commands pseudo-commands were added in .Nm OpenSSL 0.9.3; the .Cm no- Ns XXX pseudo-commands were added in .Nm OpenSSL 0.9.5a; the .Cm list- Ns XXX Ns Cm -algorithms pseudo-commands were added in .Nm OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_sess_number.30000644000175000017500000001564112360020731021364 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_sess_number 3" .TH SSL_CTX_sess_number 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_sess_number, SSL_CTX_sess_connect, SSL_CTX_sess_connect_good, SSL_CTX_sess_connect_renegotiate, SSL_CTX_sess_accept, SSL_CTX_sess_accept_good, SSL_CTX_sess_accept_renegotiate, SSL_CTX_sess_hits, SSL_CTX_sess_cb_hits, SSL_CTX_sess_misses, SSL_CTX_sess_timeouts, SSL_CTX_sess_cache_full \- obtain session cache statistics .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& long SSL_CTX_sess_number(SSL_CTX *ctx); \& long SSL_CTX_sess_connect(SSL_CTX *ctx); \& long SSL_CTX_sess_connect_good(SSL_CTX *ctx); \& long SSL_CTX_sess_connect_renegotiate(SSL_CTX *ctx); \& long SSL_CTX_sess_accept(SSL_CTX *ctx); \& long SSL_CTX_sess_accept_good(SSL_CTX *ctx); \& long SSL_CTX_sess_accept_renegotiate(SSL_CTX *ctx); \& long SSL_CTX_sess_hits(SSL_CTX *ctx); \& long SSL_CTX_sess_cb_hits(SSL_CTX *ctx); \& long SSL_CTX_sess_misses(SSL_CTX *ctx); \& long SSL_CTX_sess_timeouts(SSL_CTX *ctx); \& long SSL_CTX_sess_cache_full(SSL_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_sess_number()\fR returns the current number of sessions in the internal session cache. .PP \&\fISSL_CTX_sess_connect()\fR returns the number of started \s-1SSL/TLS\s0 handshakes in client mode. .PP \&\fISSL_CTX_sess_connect_good()\fR returns the number of successfully established \&\s-1SSL/TLS\s0 sessions in client mode. .PP \&\fISSL_CTX_sess_connect_renegotiate()\fR returns the number of start renegotiations in client mode. .PP \&\fISSL_CTX_sess_accept()\fR returns the number of started \s-1SSL/TLS\s0 handshakes in server mode. .PP \&\fISSL_CTX_sess_accept_good()\fR returns the number of successfully established \&\s-1SSL/TLS\s0 sessions in server mode. .PP \&\fISSL_CTX_sess_accept_renegotiate()\fR returns the number of start renegotiations in server mode. .PP \&\fISSL_CTX_sess_hits()\fR returns the number of successfully reused sessions. In client mode a session set with \fISSL_set_session\fR\|(3) successfully reused is counted as a hit. In server mode a session successfully retrieved from internal or external cache is counted as a hit. .PP \&\fISSL_CTX_sess_cb_hits()\fR returns the number of successfully retrieved sessions from the external session cache in server mode. .PP \&\fISSL_CTX_sess_misses()\fR returns the number of sessions proposed by clients that were not found in the internal session cache in server mode. .PP \&\fISSL_CTX_sess_timeouts()\fR returns the number of sessions proposed by clients and either found in the internal or external session cache in server mode, but that were invalid due to timeout. These sessions are not included in the \fISSL_CTX_sess_hits()\fR count. .PP \&\fISSL_CTX_sess_cache_full()\fR returns the number of sessions that were removed because the maximum session cache size was exceeded. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The functions return the values indicated in the \s-1DESCRIPTION\s0 section. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_set_session\fR\|(3), \&\fISSL_CTX_set_session_cache_mode\fR\|(3) \&\fISSL_CTX_sess_set_cache_size\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/OPENSSL_VERSION_NUMBER.30000644000175000017500000001555312360020721021201 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "OPENSSL_VERSION_NUMBER 3" .TH OPENSSL_VERSION_NUMBER 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" OPENSSL_VERSION_NUMBER, SSLeay, SSLeay_version \- get OpenSSL version number .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #define OPENSSL_VERSION_NUMBER 0xnnnnnnnnnL \& \& #include \& long SSLeay(void); \& const char *SSLeay_version(int t); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\s-1OPENSSL_VERSION_NUMBER\s0 is a numeric release version identifier: .PP .Vb 1 \& MMNNFFPPS: major minor fix patch status .Ve .PP The status nibble has one of the values 0 for development, 1 to e for betas 1 to 14, and f for release. .PP for example .PP .Vb 3 \& 0x000906000 == 0.9.6 dev \& 0x000906023 == 0.9.6b beta 3 \& 0x00090605f == 0.9.6e release .Ve .PP Versions prior to 0.9.3 have identifiers < 0x0930. Versions between 0.9.3 and 0.9.5 had a version identifier with this interpretation: .PP .Vb 1 \& MMNNFFRBB major minor fix final beta/patch .Ve .PP for example .PP .Vb 2 \& 0x000904100 == 0.9.4 release \& 0x000905000 == 0.9.5 dev .Ve .PP Version 0.9.5a had an interim interpretation that is like the current one, except the patch level got the highest bit set, to keep continuity. The number was therefore 0x0090581f. .PP For backward compatibility, \s-1SSLEAY_VERSION_NUMBER\s0 is also defined. .PP \&\fISSLeay()\fR returns this number. The return value can be compared to the macro to make sure that the correct version of the library has been loaded, especially when using DLLs on Windows systems. .PP \&\fISSLeay_version()\fR returns different strings depending on \fBt\fR: .IP "\s-1SSLEAY_VERSION\s0" 4 .IX Item "SSLEAY_VERSION" The text variant of the version number and the release date. For example, \&\*(L"OpenSSL 0.9.5a 1 Apr 2000\*(R". .IP "\s-1SSLEAY_CFLAGS\s0" 4 .IX Item "SSLEAY_CFLAGS" The compiler flags set for the compilation process in the form \&\*(L"compiler: ...\*(R" if available or \*(L"compiler: information not available\*(R" otherwise. .IP "\s-1SSLEAY_BUILT_ON\s0" 4 .IX Item "SSLEAY_BUILT_ON" The date of the build process in the form \*(L"built on: ...\*(R" if available or \*(L"built on: date not available\*(R" otherwise. .IP "\s-1SSLEAY_PLATFORM\s0" 4 .IX Item "SSLEAY_PLATFORM" The \*(L"Configure\*(R" target of the library build in the form \*(L"platform: ...\*(R" if available or \*(L"platform: information not available\*(R" otherwise. .IP "\s-1SSLEAY_DIR\s0" 4 .IX Item "SSLEAY_DIR" The \*(L"\s-1OPENSSLDIR\*(R"\s0 setting of the library build in the form \*(L"\s-1OPENSSLDIR: \*(R"..."\*(L"\s0 if available or \*(R"\s-1OPENSSLDIR: N/A"\s0 otherwise. .PP For an unknown \fBt\fR, the text \*(L"not available\*(R" is returned. .SH "RETURN VALUE" .IX Header "RETURN VALUE" The version number. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIcrypto\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fISSLeay()\fR and \s-1SSLEAY_VERSION_NUMBER\s0 are available in all versions of SSLeay and OpenSSL. \s-1OPENSSL_VERSION_NUMBER\s0 is available in all versions of OpenSSL. \&\fB\s-1SSLEAY_DIR\s0\fR was added in OpenSSL 0.9.7. deps/libressl-pnacl-sys-2.1.6/libressl/man/d2i_X509_NAME.30000644000175000017500000001116212360020727017602 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "d2i_X509_NAME 3" .TH d2i_X509_NAME 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" d2i_X509_NAME, i2d_X509_NAME \- X509_NAME encoding functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& X509_NAME *d2i_X509_NAME(X509_NAME **a, unsigned char **pp, long length); \& int i2d_X509_NAME(X509_NAME *a, unsigned char **pp); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions decode and encode an \fBX509_NAME\fR structure which is the the same as the \fBName\fR type defined in \s-1RFC2459 \s0(and elsewhere) and used for example in certificate subject and issuer names. .PP Othewise the functions behave in a similar way to \fId2i_X509()\fR and \fIi2d_X509()\fR described in the \fId2i_X509\fR\|(3) manual page. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fId2i_X509\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_get_current_cipher.30000644000175000017500000001262412360020735022176 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_get_current_cipher 3" .TH SSL_get_current_cipher 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_get_current_cipher, SSL_get_cipher, SSL_get_cipher_name, SSL_get_cipher_bits, SSL_get_cipher_version \- get SSL_CIPHER of a connection .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& SSL_CIPHER *SSL_get_current_cipher(const SSL *ssl); \& #define SSL_get_cipher(s) \e \& SSL_CIPHER_get_name(SSL_get_current_cipher(s)) \& #define SSL_get_cipher_name(s) \e \& SSL_CIPHER_get_name(SSL_get_current_cipher(s)) \& #define SSL_get_cipher_bits(s,np) \e \& SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np) \& #define SSL_get_cipher_version(s) \e \& SSL_CIPHER_get_version(SSL_get_current_cipher(s)) .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_get_current_cipher()\fR returns a pointer to an \s-1SSL_CIPHER\s0 object containing the description of the actually used cipher of a connection established with the \fBssl\fR object. .PP \&\fISSL_get_cipher()\fR and \fISSL_get_cipher_name()\fR are identical macros to obtain the name of the currently used cipher. \fISSL_get_cipher_bits()\fR is a macro to obtain the number of secret/algorithm bits used and \&\fISSL_get_cipher_version()\fR returns the protocol name. See \fISSL_CIPHER_get_name\fR\|(3) for more details. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_get_current_cipher()\fR returns the cipher actually used or \s-1NULL,\s0 when no session has been established. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_CIPHER_get_name\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_alert_type_string.30000644000175000017500000003352412360020734022062 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_alert_type_string 3" .TH SSL_alert_type_string 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_alert_type_string, SSL_alert_type_string_long, SSL_alert_desc_string, SSL_alert_desc_string_long \- get textual description of alert information .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& const char *SSL_alert_type_string(int value); \& const char *SSL_alert_type_string_long(int value); \& \& const char *SSL_alert_desc_string(int value); \& const char *SSL_alert_desc_string_long(int value); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_alert_type_string()\fR returns a one letter string indicating the type of the alert specified by \fBvalue\fR. .PP \&\fISSL_alert_type_string_long()\fR returns a string indicating the type of the alert specified by \fBvalue\fR. .PP \&\fISSL_alert_desc_string()\fR returns a two letter string as a short form describing the reason of the alert specified by \fBvalue\fR. .PP \&\fISSL_alert_desc_string_long()\fR returns a string describing the reason of the alert specified by \fBvalue\fR. .SH "NOTES" .IX Header "NOTES" When one side of an \s-1SSL/TLS\s0 communication wants to inform the peer about a special situation, it sends an alert. The alert is sent as a special message and does not influence the normal data stream (unless its contents results in the communication being canceled). .PP A warning alert is sent, when a non-fatal error condition occurs. The \&\*(L"close notify\*(R" alert is sent as a warning alert. Other examples for non-fatal errors are certificate errors (\*(L"certificate expired\*(R", \&\*(L"unsupported certificate\*(R"), for which a warning alert may be sent. (The sending party may however decide to send a fatal error.) The receiving side may cancel the connection on reception of a warning alert on it discretion. .PP Several alert messages must be sent as fatal alert messages as specified by the \s-1TLS RFC. A\s0 fatal alert always leads to a connection abort. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following strings can occur for \fISSL_alert_type_string()\fR or \&\fISSL_alert_type_string_long()\fR: .ie n .IP """W""/""warning""" 4 .el .IP "``W''/``warning''" 4 .IX Item "W/warning" .PD 0 .ie n .IP """F""/""fatal""" 4 .el .IP "``F''/``fatal''" 4 .IX Item "F/fatal" .ie n .IP """U""/""unknown""" 4 .el .IP "``U''/``unknown''" 4 .IX Item "U/unknown" .PD This indicates that no support is available for this alert type. Probably \fBvalue\fR does not contain a correct alert message. .PP The following strings can occur for \fISSL_alert_desc_string()\fR or \&\fISSL_alert_desc_string_long()\fR: .ie n .IP """\s-1CN""/\s0""close notify""" 4 .el .IP "``\s-1CN''/\s0``close notify''" 4 .IX Item "CN/close notify" The connection shall be closed. This is a warning alert. .ie n .IP """\s-1UM""/\s0""unexpected message""" 4 .el .IP "``\s-1UM''/\s0``unexpected message''" 4 .IX Item "UM/unexpected message" An inappropriate message was received. This alert is always fatal and should never be observed in communication between proper implementations. .ie n .IP """\s-1BM""/\s0""bad record mac""" 4 .el .IP "``\s-1BM''/\s0``bad record mac''" 4 .IX Item "BM/bad record mac" This alert is returned if a record is received with an incorrect \&\s-1MAC.\s0 This message is always fatal. .ie n .IP """\s-1DF""/\s0""decompression failure""" 4 .el .IP "``\s-1DF''/\s0``decompression failure''" 4 .IX Item "DF/decompression failure" The decompression function received improper input (e.g. data that would expand to excessive length). This message is always fatal. .ie n .IP """\s-1HF""/\s0""handshake failure""" 4 .el .IP "``\s-1HF''/\s0``handshake failure''" 4 .IX Item "HF/handshake failure" Reception of a handshake_failure alert message indicates that the sender was unable to negotiate an acceptable set of security parameters given the options available. This is a fatal error. .ie n .IP """\s-1NC""/\s0""no certificate""" 4 .el .IP "``\s-1NC''/\s0``no certificate''" 4 .IX Item "NC/no certificate" A client, that was asked to send a certificate, does not send a certificate (SSLv3 only). .ie n .IP """\s-1BC""/\s0""bad certificate""" 4 .el .IP "``\s-1BC''/\s0``bad certificate''" 4 .IX Item "BC/bad certificate" A certificate was corrupt, contained signatures that did not verify correctly, etc .ie n .IP """\s-1UC""/\s0""unsupported certificate""" 4 .el .IP "``\s-1UC''/\s0``unsupported certificate''" 4 .IX Item "UC/unsupported certificate" A certificate was of an unsupported type. .ie n .IP """\s-1CR""/\s0""certificate revoked""" 4 .el .IP "``\s-1CR''/\s0``certificate revoked''" 4 .IX Item "CR/certificate revoked" A certificate was revoked by its signer. .ie n .IP """\s-1CE""/\s0""certificate expired""" 4 .el .IP "``\s-1CE''/\s0``certificate expired''" 4 .IX Item "CE/certificate expired" A certificate has expired or is not currently valid. .ie n .IP """\s-1CU""/\s0""certificate unknown""" 4 .el .IP "``\s-1CU''/\s0``certificate unknown''" 4 .IX Item "CU/certificate unknown" Some other (unspecified) issue arose in processing the certificate, rendering it unacceptable. .ie n .IP """\s-1IP""/\s0""illegal parameter""" 4 .el .IP "``\s-1IP''/\s0``illegal parameter''" 4 .IX Item "IP/illegal parameter" A field in the handshake was out of range or inconsistent with other fields. This is always fatal. .ie n .IP """\s-1DC""/\s0""decryption failed""" 4 .el .IP "``\s-1DC''/\s0``decryption failed''" 4 .IX Item "DC/decryption failed" A TLSCiphertext decrypted in an invalid way: either it wasn't an even multiple of the block length or its padding values, when checked, weren't correct. This message is always fatal. .ie n .IP """\s-1RO""/\s0""record overflow""" 4 .el .IP "``\s-1RO''/\s0``record overflow''" 4 .IX Item "RO/record overflow" A TLSCiphertext record was received which had a length more than 2^14+2048 bytes, or a record decrypted to a TLSCompressed record with more than 2^14+1024 bytes. This message is always fatal. .ie n .IP """\s-1CA""/\s0""unknown \s-1CA""\s0" 4 .el .IP "``\s-1CA''/\s0``unknown \s-1CA''\s0" 4 .IX Item "CA/unknown CA" A valid certificate chain or partial chain was received, but the certificate was not accepted because the \s-1CA\s0 certificate could not be located or couldn't be matched with a known, trusted \s-1CA. \s0 This message is always fatal. .ie n .IP """\s-1AD""/\s0""access denied""" 4 .el .IP "``\s-1AD''/\s0``access denied''" 4 .IX Item "AD/access denied" A valid certificate was received, but when access control was applied, the sender decided not to proceed with negotiation. This message is always fatal. .ie n .IP """\s-1DE""/\s0""decode error""" 4 .el .IP "``\s-1DE''/\s0``decode error''" 4 .IX Item "DE/decode error" A message could not be decoded because some field was out of the specified range or the length of the message was incorrect. This message is always fatal. .ie n .IP """\s-1CY""/\s0""decrypt error""" 4 .el .IP "``\s-1CY''/\s0``decrypt error''" 4 .IX Item "CY/decrypt error" A handshake cryptographic operation failed, including being unable to correctly verify a signature, decrypt a key exchange, or validate a finished message. .ie n .IP """\s-1ER""/\s0""export restriction""" 4 .el .IP "``\s-1ER''/\s0``export restriction''" 4 .IX Item "ER/export restriction" A negotiation not in compliance with export restrictions was detected; for example, attempting to transfer a 1024 bit ephemeral \s-1RSA\s0 key for the \s-1RSA_EXPORT\s0 handshake method. This message is always fatal. .ie n .IP """\s-1PV""/\s0""protocol version""" 4 .el .IP "``\s-1PV''/\s0``protocol version''" 4 .IX Item "PV/protocol version" The protocol version the client has attempted to negotiate is recognized, but not supported. (For example, old protocol versions might be avoided for security reasons). This message is always fatal. .ie n .IP """\s-1IS""/\s0""insufficient security""" 4 .el .IP "``\s-1IS''/\s0``insufficient security''" 4 .IX Item "IS/insufficient security" Returned instead of handshake_failure when a negotiation has failed specifically because the server requires ciphers more secure than those supported by the client. This message is always fatal. .ie n .IP """\s-1IE""/\s0""internal error""" 4 .el .IP "``\s-1IE''/\s0``internal error''" 4 .IX Item "IE/internal error" An internal error unrelated to the peer or the correctness of the protocol makes it impossible to continue (such as a memory allocation failure). This message is always fatal. .ie n .IP """\s-1US""/\s0""user canceled""" 4 .el .IP "``\s-1US''/\s0``user canceled''" 4 .IX Item "US/user canceled" This handshake is being canceled for some reason unrelated to a protocol failure. If the user cancels an operation after the handshake is complete, just closing the connection by sending a close_notify is more appropriate. This alert should be followed by a close_notify. This message is generally a warning. .ie n .IP """\s-1NR""/\s0""no renegotiation""" 4 .el .IP "``\s-1NR''/\s0``no renegotiation''" 4 .IX Item "NR/no renegotiation" Sent by the client in response to a hello request or by the server in response to a client hello after initial handshaking. Either of these would normally lead to renegotiation; when that is not appropriate, the recipient should respond with this alert; at that point, the original requester can decide whether to proceed with the connection. One case where this would be appropriate would be where a server has spawned a process to satisfy a request; the process might receive security parameters (key length, authentication, etc.) at startup and it might be difficult to communicate changes to these parameters after that point. This message is always a warning. .ie n .IP """\s-1UP""/\s0""unknown \s-1PSK\s0 identity""" 4 .el .IP "``\s-1UP''/\s0``unknown \s-1PSK\s0 identity''" 4 .IX Item "UP/unknown PSK identity" Sent by the server to indicate that it does not recognize a \s-1PSK\s0 identity or an \s-1SRP\s0 identity. .ie n .IP """\s-1UK""/\s0""unknown""" 4 .el .IP "``\s-1UK''/\s0``unknown''" 4 .IX Item "UK/unknown" This indicates that no description is available for this alert type. Probably \fBvalue\fR does not contain a correct alert message. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_CTX_set_info_callback\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/speed.10000644000175000017500000001174612360020743016703 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "speed 1" .TH speed 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" speed \- test library performance .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl speed\fR [\fB\-engine id\fR] [\fBmd2\fR] [\fBmdc2\fR] [\fBmd5\fR] [\fBhmac\fR] [\fBsha1\fR] [\fBrmd160\fR] [\fBidea-cbc\fR] [\fBrc2\-cbc\fR] [\fBrc5\-cbc\fR] [\fBbf-cbc\fR] [\fBdes-cbc\fR] [\fBdes\-ede3\fR] [\fBrc4\fR] [\fBrsa512\fR] [\fBrsa1024\fR] [\fBrsa2048\fR] [\fBrsa4096\fR] [\fBdsa512\fR] [\fBdsa1024\fR] [\fBdsa2048\fR] [\fBidea\fR] [\fBrc2\fR] [\fBdes\fR] [\fBrsa\fR] [\fBblowfish\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" This command is used to test the performance of cryptographic algorithms. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBspeed\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .IP "\fB[zero or more test algorithms]\fR" 4 .IX Item "[zero or more test algorithms]" If any options are given, \fBspeed\fR tests those algorithms, otherwise all of the above are tested. deps/libressl-pnacl-sys-2.1.6/libressl/man/lh_stats.30000644000175000017500000001366112360020730017420 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "lh_stats 3" .TH lh_stats 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" lh_stats, lh_node_stats, lh_node_usage_stats, lh_stats_bio, lh_node_stats_bio, lh_node_usage_stats_bio \- LHASH statistics .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void lh_stats(LHASH *table, FILE *out); \& void lh_node_stats(LHASH *table, FILE *out); \& void lh_node_usage_stats(LHASH *table, FILE *out); \& \& void lh_stats_bio(LHASH *table, BIO *out); \& void lh_node_stats_bio(LHASH *table, BIO *out); \& void lh_node_usage_stats_bio(LHASH *table, BIO *out); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fB\s-1LHASH\s0\fR structure records statistics about most aspects of accessing the hash table. This is mostly a legacy of Eric Young writing this library for the reasons of implementing what looked like a nice algorithm rather than for a particular software product. .PP \&\fIlh_stats()\fR prints out statistics on the size of the hash table, how many entries are in it, and the number and result of calls to the routines in this library. .PP \&\fIlh_node_stats()\fR prints the number of entries for each 'bucket' in the hash table. .PP \&\fIlh_node_usage_stats()\fR prints out a short summary of the state of the hash table. It prints the 'load' and the 'actual load'. The load is the average number of data items per 'bucket' in the hash table. The \&'actual load' is the average number of items per 'bucket', but only for buckets which contain entries. So the 'actual load' is the average number of searches that will need to find an item in the hash table, while the 'load' is the average number that will be done to record a miss. .PP \&\fIlh_stats_bio()\fR, \fIlh_node_stats_bio()\fR and \fIlh_node_usage_stats_bio()\fR are the same as the above, except that the output goes to a \fB\s-1BIO\s0\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" These functions do not return values. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbio\fR\|(3), \fIlhash\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" These functions are available in all versions of SSLeay and OpenSSL. .PP This manpage is derived from the SSLeay documentation. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_flush_sessions.30000644000175000017500000001300412360020731022075 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_flush_sessions 3" .TH SSL_CTX_flush_sessions 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_flush_sessions, SSL_flush_sessions \- remove expired sessions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm); \& void SSL_flush_sessions(SSL_CTX *ctx, long tm); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_flush_sessions()\fR causes a run through the session cache of \&\fBctx\fR to remove sessions expired at time \fBtm\fR. .PP \&\fISSL_flush_sessions()\fR is a synonym for \fISSL_CTX_flush_sessions()\fR. .SH "NOTES" .IX Header "NOTES" If enabled, the internal session cache will collect all sessions established up to the specified maximum number (see \fISSL_CTX_sess_set_cache_size()\fR). As sessions will not be reused ones they are expired, they should be removed from the cache to save resources. This can either be done automatically whenever 255 new sessions were established (see \&\fISSL_CTX_set_session_cache_mode\fR\|(3)) or manually by calling \fISSL_CTX_flush_sessions()\fR. .PP The parameter \fBtm\fR specifies the time which should be used for the expiration test, in most cases the actual time given by \fItime\fR\|(0) will be used. .PP \&\fISSL_CTX_flush_sessions()\fR will only check sessions stored in the internal cache. When a session is found and removed, the remove_session_cb is however called to synchronize with the external cache (see \&\fISSL_CTX_sess_set_get_cb\fR\|(3)). .SH "RETURN VALUES" .IX Header "RETURN VALUES" .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \&\fISSL_CTX_set_session_cache_mode\fR\|(3), \&\fISSL_CTX_set_timeout\fR\|(3), \&\fISSL_CTX_sess_set_get_cb\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/RSA_private_encrypt.30000644000175000017500000001420512360020724021520 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RSA_private_encrypt 3" .TH RSA_private_encrypt 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RSA_private_encrypt, RSA_public_decrypt \- low level signature operations .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int RSA_private_encrypt(int flen, unsigned char *from, \& unsigned char *to, RSA *rsa, int padding); \& \& int RSA_public_decrypt(int flen, unsigned char *from, \& unsigned char *to, RSA *rsa, int padding); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions handle \s-1RSA\s0 signatures at a low level. .PP \&\fIRSA_private_encrypt()\fR signs the \fBflen\fR bytes at \fBfrom\fR (usually a message digest with an algorithm identifier) using the private key \&\fBrsa\fR and stores the signature in \fBto\fR. \fBto\fR must point to \&\fBRSA_size(rsa)\fR bytes of memory. .PP \&\fBpadding\fR denotes one of the following modes: .IP "\s-1RSA_PKCS1_PADDING\s0" 4 .IX Item "RSA_PKCS1_PADDING" \&\s-1PKCS\s0 #1 v1.5 padding. This function does not handle the \fBalgorithmIdentifier\fR specified in \s-1PKCS\s0 #1. When generating or verifying \s-1PKCS\s0 #1 signatures, \&\fIRSA_sign\fR\|(3) and \fIRSA_verify\fR\|(3) should be used. .IP "\s-1RSA_NO_PADDING\s0" 4 .IX Item "RSA_NO_PADDING" Raw \s-1RSA\s0 signature. This mode should \fIonly\fR be used to implement cryptographically sound padding modes in the application code. Signing user data directly with \s-1RSA\s0 is insecure. .PP \&\fIRSA_public_decrypt()\fR recovers the message digest from the \fBflen\fR bytes long signature at \fBfrom\fR using the signer's public key \&\fBrsa\fR. \fBto\fR must point to a memory section large enough to hold the message digest (which is smaller than \fBRSA_size(rsa) \- 11\fR). \fBpadding\fR is the padding mode that was used to sign the data. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIRSA_private_encrypt()\fR returns the size of the signature (i.e., RSA_size(rsa)). \fIRSA_public_decrypt()\fR returns the size of the recovered message digest. .PP On error, \-1 is returned; the error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fIrsa\fR\|(3), \&\fIRSA_sign\fR\|(3), \fIRSA_verify\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" The \fBpadding\fR argument was added in SSLeay 0.8. \s-1RSA_NO_PADDING\s0 is available since SSLeay 0.9.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/X509_new.30000644000175000017500000001157012360020726017117 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "X509_new 3" .TH X509_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" X509_new, X509_free \- X509 certificate ASN1 allocation functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& X509 *X509_new(void); \& void X509_free(X509 *a); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The X509 \s-1ASN1\s0 allocation routines, allocate and free an X509 structure, which represents an X509 certificate. .PP \&\fIX509_new()\fR allocates and initializes a X509 structure. .PP \&\fIX509_free()\fR frees up the \fBX509\fR structure \fBa\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" If the allocation fails, \fIX509_new()\fR returns \fB\s-1NULL\s0\fR and sets an error code that can be obtained by \fIERR_get_error\fR\|(3). Otherwise it returns a pointer to the newly allocated structure. .PP \&\fIX509_free()\fR returns no value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fId2i_X509\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIX509_new()\fR and \fIX509_free()\fR are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_push.30000644000175000017500000001412512360020710017241 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_push 3" .TH BIO_push 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_push, BIO_pop \- add and remove BIOs from a chain. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIO * BIO_push(BIO *b,BIO *append); \& BIO * BIO_pop(BIO *b); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fIBIO_push()\fR function appends the \s-1BIO \s0\fBappend\fR to \fBb\fR, and returns \&\fBb\fR. .PP \&\fIBIO_pop()\fR removes the \s-1BIO \s0\fBb\fR from a chain and returns the next \s-1BIO\s0 in the chain, or \s-1NULL\s0 if there is no next \s-1BIO.\s0 The removed \s-1BIO\s0 then becomes a single \s-1BIO\s0 with no association with the original chain, it can thus be freed or attached to a different chain. .SH "NOTES" .IX Header "NOTES" The names of these functions are perhaps a little misleading. \fIBIO_push()\fR joins two \s-1BIO\s0 chains whereas \fIBIO_pop()\fR deletes a single \s-1BIO\s0 from a chain, the deleted \s-1BIO\s0 does not need to be at the end of a chain. .PP The process of calling \fIBIO_push()\fR and \fIBIO_pop()\fR on a \s-1BIO\s0 may have additional consequences (a control call is made to the affected BIOs) any effects will be noted in the descriptions of individual BIOs. .SH "EXAMPLES" .IX Header "EXAMPLES" For these examples suppose \fBmd1\fR and \fBmd2\fR are digest BIOs, \fBb64\fR is a base64 \s-1BIO\s0 and \fBf\fR is a file \s-1BIO.\s0 .PP If the call: .PP .Vb 1 \& BIO_push(b64, f); .Ve .PP is made then the new chain will be \fBb64\-f\fR. After making the calls .PP .Vb 2 \& BIO_push(md2, b64); \& BIO_push(md1, md2); .Ve .PP the new chain is \fBmd1\-md2\-b64\-f\fR. Data written to \fBmd1\fR will be digested by \fBmd1\fR and \fBmd2\fR, \fBbase64\fR encoded and written to \fBf\fR. .PP It should be noted that reading causes data to pass in the reverse direction, that is data is read from \fBf\fR, base64 \fBdecoded\fR and digested by \fBmd1\fR and \fBmd2\fR. If the call: .PP .Vb 1 \& BIO_pop(md2); .Ve .PP The call will return \fBb64\fR and the new chain will be \fBmd1\-b64\-f\fR; data can be written to \fBmd1\fR as before. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBIO_push()\fR returns the beginning of the chain, \fBb\fR. .PP \&\fIBIO_pop()\fR returns the next \s-1BIO\s0 in the chain, or \s-1NULL\s0 if there is no next \&\s-1BIO.\s0 deps/libressl-pnacl-sys-2.1.6/libressl/man/ERR_load_crypto_strings.30000644000175000017500000001214412360020717022377 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ERR_load_crypto_strings 3" .TH ERR_load_crypto_strings 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ERR_load_crypto_strings, SSL_load_error_strings, ERR_free_strings \- load and free error strings .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void ERR_load_crypto_strings(void); \& void ERR_free_strings(void); \& \& #include \& \& void SSL_load_error_strings(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIERR_load_crypto_strings()\fR registers the error strings for all \&\fBlibcrypto\fR functions. \fISSL_load_error_strings()\fR does the same, but also registers the \fBlibssl\fR error strings. .PP One of these functions should be called before generating textual error messages. However, this is not required when memory usage is an issue. .PP \&\fIERR_free_strings()\fR frees all previously loaded error strings. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIERR_load_crypto_strings()\fR, \fISSL_load_error_strings()\fR and \&\fIERR_free_strings()\fR return no values. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIerr\fR\|(3), \fIERR_error_string\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIERR_load_error_strings()\fR, \fISSL_load_error_strings()\fR and \&\fIERR_free_strings()\fR are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_set_quiet_shutdown.30000644000175000017500000001441112360020733022770 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_set_quiet_shutdown 3" .TH SSL_CTX_set_quiet_shutdown 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_set_quiet_shutdown, SSL_CTX_get_quiet_shutdown, SSL_set_quiet_shutdown, SSL_get_quiet_shutdown \- manipulate shutdown behaviour .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode); \& int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx); \& \& void SSL_set_quiet_shutdown(SSL *ssl, int mode); \& int SSL_get_quiet_shutdown(const SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_set_quiet_shutdown()\fR sets the \*(L"quiet shutdown\*(R" flag for \fBctx\fR to be \&\fBmode\fR. \s-1SSL\s0 objects created from \fBctx\fR inherit the \fBmode\fR valid at the time \&\fISSL_new\fR\|(3) is called. \fBmode\fR may be 0 or 1. .PP \&\fISSL_CTX_get_quiet_shutdown()\fR returns the \*(L"quiet shutdown\*(R" setting of \fBctx\fR. .PP \&\fISSL_set_quiet_shutdown()\fR sets the \*(L"quiet shutdown\*(R" flag for \fBssl\fR to be \&\fBmode\fR. The setting stays valid until \fBssl\fR is removed with \&\fISSL_free\fR\|(3) or \fISSL_set_quiet_shutdown()\fR is called again. It is not changed when \fISSL_clear\fR\|(3) is called. \&\fBmode\fR may be 0 or 1. .PP \&\fISSL_get_quiet_shutdown()\fR returns the \*(L"quiet shutdown\*(R" setting of \fBssl\fR. .SH "NOTES" .IX Header "NOTES" Normally when a \s-1SSL\s0 connection is finished, the parties must send out \&\*(L"close notify\*(R" alert messages using \fISSL_shutdown\fR\|(3) for a clean shutdown. .PP When setting the \*(L"quiet shutdown\*(R" flag to 1, \fISSL_shutdown\fR\|(3) will set the internal flags to SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN. (\fISSL_shutdown\fR\|(3) then behaves like \&\fISSL_set_shutdown\fR\|(3) called with SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN.) The session is thus considered to be shutdown, but no \*(L"close notify\*(R" alert is sent to the peer. This behaviour violates the \s-1TLS\s0 standard. .PP The default is normal shutdown behaviour as described by the \s-1TLS\s0 standard. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_set_quiet_shutdown()\fR and \fISSL_set_quiet_shutdown()\fR do not return diagnostic information. .PP \&\fISSL_CTX_get_quiet_shutdown()\fR and SSL_get_quiet_shutdown return the current setting. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_shutdown\fR\|(3), \&\fISSL_set_shutdown\fR\|(3), \fISSL_new\fR\|(3), \&\fISSL_clear\fR\|(3), \fISSL_free\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/SMIME_read_CMS.30000644000175000017500000001406212360020725020146 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SMIME_read_CMS 3" .TH SMIME_read_CMS 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" .Vb 1 \& SMIME_read_CMS \- parse S/MIME message. .Ve .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& CMS_ContentInfo *SMIME_read_CMS(BIO *in, BIO **bcont); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISMIME_read_CMS()\fR parses a message in S/MIME format. .PP \&\fBin\fR is a \s-1BIO\s0 to read the message from. .PP If cleartext signing is used then the content is saved in a memory bio which is written to \fB*bcont\fR, otherwise \fB*bcont\fR is set to \s-1NULL.\s0 .PP The parsed CMS_ContentInfo structure is returned or \s-1NULL\s0 if an error occurred. .SH "NOTES" .IX Header "NOTES" If \fB*bcont\fR is not \s-1NULL\s0 then the message is clear text signed. \fB*bcont\fR can then be passed to \fICMS_verify()\fR with the \fB\s-1CMS_DETACHED\s0\fR flag set. .PP Otherwise the type of the returned structure can be determined using \fICMS_get0_type()\fR. .PP To support future functionality if \fBbcont\fR is not \s-1NULL \s0\fB*bcont\fR should be initialized to \s-1NULL.\s0 For example: .PP .Vb 2 \& BIO *cont = NULL; \& CMS_ContentInfo *cms; \& \& cms = SMIME_read_CMS(in, &cont); .Ve .SH "BUGS" .IX Header "BUGS" The \s-1MIME\s0 parser used by \fISMIME_read_CMS()\fR is somewhat primitive. While it will handle most S/MIME messages more complex compound formats may not work. .PP The parser assumes that the CMS_ContentInfo structure is always base64 encoded and will not handle the case where it is in binary format or uses quoted printable format. .PP The use of a memory \s-1BIO\s0 to hold the signed content limits the size of message which can be processed due to memory restraints: a streaming single pass option should be available. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISMIME_read_CMS()\fR returns a valid \fBCMS_ContentInfo\fR structure or \fB\s-1NULL\s0\fR if an error occurred. The error can be obtained from \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3), \fICMS_type\fR\|(3) \&\fISMIME_read_CMS\fR\|(3), \fICMS_sign\fR\|(3), \&\fICMS_verify\fR\|(3), \fICMS_encrypt\fR\|(3) \&\fICMS_decrypt\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fISMIME_read_CMS()\fR was added to OpenSSL 0.9.8 deps/libressl-pnacl-sys-2.1.6/libressl/man/X509_NAME_print_ex.30000644000175000017500000002153012360020725020752 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "X509_NAME_print_ex 3" .TH X509_NAME_print_ex 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" X509_NAME_print_ex, X509_NAME_print_ex_fp, X509_NAME_print, X509_NAME_oneline \- X509_NAME printing routines. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags); \& int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags); \& char * X509_NAME_oneline(X509_NAME *a,char *buf,int size); \& int X509_NAME_print(BIO *bp, X509_NAME *name, int obase); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIX509_NAME_print_ex()\fR prints a human readable version of \fBnm\fR to \s-1BIO \s0\fBout\fR. Each line (for multiline formats) is indented by \fBindent\fR spaces. The output format can be extensively customised by use of the \fBflags\fR parameter. .PP \&\fIX509_NAME_print_ex_fp()\fR is identical to \fIX509_NAME_print_ex()\fR except the output is written to \s-1FILE\s0 pointer \fBfp\fR. .PP \&\fIX509_NAME_oneline()\fR prints an \s-1ASCII\s0 version of \fBa\fR to \fBbuf\fR. At most \fBsize\fR bytes will be written. If \fBbuf\fR is \fB\s-1NULL\s0\fR then a buffer is dynamically allocated and returned, otherwise \fBbuf\fR is returned. .PP \&\fIX509_NAME_print()\fR prints out \fBname\fR to \fBbp\fR indenting each line by \fBobase\fR characters. Multiple lines are used if the output (including indent) exceeds 80 characters. .SH "NOTES" .IX Header "NOTES" The functions \fIX509_NAME_oneline()\fR and \fIX509_NAME_print()\fR are legacy functions which produce a non standard output form, they don't handle multi character fields and have various quirks and inconsistencies. Their use is strongly discouraged in new applications. .PP Although there are a large number of possible flags for most purposes \&\fB\s-1XN_FLAG_ONELINE\s0\fR, \fB\s-1XN_FLAG_MULTILINE\s0\fR or \fB\s-1XN_FLAG_RFC2253\s0\fR will suffice. As noted on the \fIASN1_STRING_print_ex\fR\|(3) manual page for \s-1UTF8\s0 terminals the \fB\s-1ASN1_STRFLGS_ESC_MSB\s0\fR should be unset: so for example \&\fB\s-1XN_FLAG_ONELINE &\s0 ~ASN1_STRFLGS_ESC_MSB\fR would be used. .PP The complete set of the flags supported by \fIX509_NAME_print_ex()\fR is listed below. .PP Several options can be ored together. .PP The options \fB\s-1XN_FLAG_SEP_COMMA_PLUS\s0\fR, \fB\s-1XN_FLAG_SEP_CPLUS_SPC\s0\fR, \&\fB\s-1XN_FLAG_SEP_SPLUS_SPC\s0\fR and \fB\s-1XN_FLAG_SEP_MULTILINE\s0\fR determine the field separators to use. Two distinct separators are used between distinct RelativeDistinguishedName components and separate values in the same \s-1RDN\s0 for a multi-valued \s-1RDN.\s0 Multi-valued RDNs are currently very rare so the second separator will hardly ever be used. .PP \&\fB\s-1XN_FLAG_SEP_COMMA_PLUS\s0\fR uses comma and plus as separators. \&\fB\s-1XN_FLAG_SEP_CPLUS_SPC\s0\fR uses comma and plus with spaces: this is more readable that plain comma and plus. \fB\s-1XN_FLAG_SEP_SPLUS_SPC\s0\fR uses spaced semicolon and plus. \fB\s-1XN_FLAG_SEP_MULTILINE\s0\fR uses spaced newline and plus respectively. .PP If \fB\s-1XN_FLAG_DN_REV\s0\fR is set the whole \s-1DN\s0 is printed in reversed order. .PP The fields \fB\s-1XN_FLAG_FN_SN\s0\fR, \fB\s-1XN_FLAG_FN_LN\s0\fR, \fB\s-1XN_FLAG_FN_OID\s0\fR, \&\fB\s-1XN_FLAG_FN_NONE\s0\fR determine how a field name is displayed. It will use the short name (e.g. \s-1CN\s0) the long name (e.g. commonName) always use \s-1OID\s0 numerical form (normally OIDs are only used if the field name is not recognised) and no field name respectively. .PP If \fB\s-1XN_FLAG_SPC_EQ\s0\fR is set then spaces will be placed around the '=' character separating field names and values. .PP If \fB\s-1XN_FLAG_DUMP_UNKNOWN_FIELDS\s0\fR is set then the encoding of unknown fields is printed instead of the values. .PP If \fB\s-1XN_FLAG_FN_ALIGN\s0\fR is set then field names are padded to 20 characters: this is only of use for multiline format. .PP Additionally all the options supported by \fIASN1_STRING_print_ex()\fR can be used to control how each field value is displayed. .PP In addition a number options can be set for commonly used formats. .PP \&\fB\s-1XN_FLAG_RFC2253\s0\fR sets options which produce an output compatible with \s-1RFC2253\s0 it is equivalent to: \fB\s-1ASN1_STRFLGS_RFC2253\s0 | \s-1XN_FLAG_SEP_COMMA_PLUS\s0 | \s-1XN_FLAG_DN_REV\s0 | \s-1XN_FLAG_FN_SN\s0 | \s-1XN_FLAG_DUMP_UNKNOWN_FIELDS\s0\fR .PP \&\fB\s-1XN_FLAG_ONELINE\s0\fR is a more readable one line format which is the same as: \fB\s-1ASN1_STRFLGS_RFC2253\s0 | \s-1ASN1_STRFLGS_ESC_QUOTE\s0 | \s-1XN_FLAG_SEP_CPLUS_SPC\s0 | \s-1XN_FLAG_SPC_EQ\s0 | \s-1XN_FLAG_FN_SN\s0\fR .PP \&\fB\s-1XN_FLAG_MULTILINE\s0\fR is a multiline format which is the same as: \fB\s-1ASN1_STRFLGS_ESC_CTRL\s0 | \s-1ASN1_STRFLGS_ESC_MSB\s0 | \s-1XN_FLAG_SEP_MULTILINE\s0 | \s-1XN_FLAG_SPC_EQ\s0 | \s-1XN_FLAG_FN_LN\s0 | \s-1XN_FLAG_FN_ALIGN\s0\fR .PP \&\fB\s-1XN_FLAG_COMPAT\s0\fR uses a format identical to \fIX509_NAME_print()\fR: in fact it calls \fIX509_NAME_print()\fR internally. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIASN1_STRING_print_ex\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/ecparam.10000644000175000017500000002253012360020741017202 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ecparam 1" .TH ecparam 1 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ecparam \- EC parameter manipulation and generation .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBopenssl ecparam\fR [\fB\-inform DER|PEM\fR] [\fB\-outform DER|PEM\fR] [\fB\-in filename\fR] [\fB\-out filename\fR] [\fB\-noout\fR] [\fB\-text\fR] [\fB\-C\fR] [\fB\-check\fR] [\fB\-name arg\fR] [\fB\-list_curve\fR] [\fB\-conv_form arg\fR] [\fB\-param_enc arg\fR] [\fB\-no_seed\fR] [\fB\-rand file(s)\fR] [\fB\-genkey\fR] [\fB\-engine id\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" This command is used to manipulate or generate \s-1EC\s0 parameter files. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-inform DER|PEM\fR" 4 .IX Item "-inform DER|PEM" This specifies the input format. The \fB\s-1DER\s0\fR option uses an \s-1ASN.1 DER\s0 encoded form compatible with \s-1RFC 3279\s0 EcpkParameters. The \s-1PEM\s0 form is the default format: it consists of the \fB\s-1DER\s0\fR format base64 encoded with additional header and footer lines. .IP "\fB\-outform DER|PEM\fR" 4 .IX Item "-outform DER|PEM" This specifies the output format, the options have the same meaning as the \&\fB\-inform\fR option. .IP "\fB\-in filename\fR" 4 .IX Item "-in filename" This specifies the input filename to read parameters from or standard input if this option is not specified. .IP "\fB\-out filename\fR" 4 .IX Item "-out filename" This specifies the output filename parameters to. Standard output is used if this option is not present. The output filename should \fBnot\fR be the same as the input filename. .IP "\fB\-noout\fR" 4 .IX Item "-noout" This option inhibits the output of the encoded version of the parameters. .IP "\fB\-text\fR" 4 .IX Item "-text" This option prints out the \s-1EC\s0 parameters in human readable form. .IP "\fB\-C\fR" 4 .IX Item "-C" This option converts the \s-1EC\s0 parameters into C code. The parameters can then be loaded by calling the \fB\f(BIget_ec_group_XXX()\fB\fR function. .IP "\fB\-check\fR" 4 .IX Item "-check" Validate the elliptic curve parameters. .IP "\fB\-name arg\fR" 4 .IX Item "-name arg" Use the \s-1EC\s0 parameters with the specified 'short' name. Use \fB\-list_curves\fR to get a list of all currently implemented \s-1EC\s0 parameters. .IP "\fB\-list_curves\fR" 4 .IX Item "-list_curves" If this options is specified \fBecparam\fR will print out a list of all currently implemented \s-1EC\s0 parameters names and exit. .IP "\fB\-conv_form\fR" 4 .IX Item "-conv_form" This specifies how the points on the elliptic curve are converted into octet strings. Possible values are: \fBcompressed\fR (the default value), \fBuncompressed\fR and \fBhybrid\fR. For more information regarding the point conversion forms please read the X9.62 standard. .IP "\fB\-param_enc arg\fR" 4 .IX Item "-param_enc arg" This specifies how the elliptic curve parameters are encoded. Possible value are: \fBnamed_curve\fR, i.e. the ec parameters are specified by a \s-1OID,\s0 or \fBexplicit\fR where the ec parameters are explicitly given (see \s-1RFC 3279\s0 for the definition of the \&\s-1EC\s0 parameters structures). The default value is \fBnamed_curve\fR. \&\fBNote\fR the \fBimplicitlyCA\fR alternative ,as specified in \s-1RFC 3279,\s0 is currently not implemented in OpenSSL. .IP "\fB\-no_seed\fR" 4 .IX Item "-no_seed" This option inhibits that the 'seed' for the parameter generation is included in the ECParameters structure (see \s-1RFC 3279\s0). .IP "\fB\-genkey\fR" 4 .IX Item "-genkey" This option will generate a \s-1EC\s0 private key using the specified parameters. .IP "\fB\-rand file(s)\fR" 4 .IX Item "-rand file(s)" a file or files containing random data used to seed the random number generator, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)). Multiple files can be specified separated by a OS-dependent character. The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for all others. .IP "\fB\-engine id\fR" 4 .IX Item "-engine id" specifying an engine (by its unique \fBid\fR string) will cause \fBecparam\fR to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. .SH "NOTES" .IX Header "NOTES" \&\s-1PEM\s0 format \s-1EC\s0 parameters use the header and footer lines: .PP .Vb 2 \& \-\-\-\-\-BEGIN EC PARAMETERS\-\-\-\-\- \& \-\-\-\-\-END EC PARAMETERS\-\-\-\-\- .Ve .PP OpenSSL is currently not able to generate new groups and therefore \&\fBecparam\fR can only create \s-1EC\s0 parameters from known (named) curves. .SH "EXAMPLES" .IX Header "EXAMPLES" To create \s-1EC\s0 parameters with the group 'prime192v1': .PP .Vb 1 \& openssl ecparam \-out ec_param.pem \-name prime192v1 .Ve .PP To create \s-1EC\s0 parameters with explicit parameters: .PP .Vb 1 \& openssl ecparam \-out ec_param.pem \-name prime192v1 \-param_enc explicit .Ve .PP To validate given \s-1EC\s0 parameters: .PP .Vb 1 \& openssl ecparam \-in ec_param.pem \-check .Ve .PP To create \s-1EC\s0 parameters and a private key: .PP .Vb 1 \& openssl ecparam \-out ec_key.pem \-name prime192v1 \-genkey .Ve .PP To change the point encoding to 'compressed': .PP .Vb 1 \& openssl ecparam \-in ec_in.pem \-out ec_out.pem \-conv_form compressed .Ve .PP To print out the \s-1EC\s0 parameters to standard output: .PP .Vb 1 \& openssl ecparam \-in ec_param.pem \-noout \-text .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIec\fR\|(1), \fIdsaparam\fR\|(1) .SH "HISTORY" .IX Header "HISTORY" The ecparam command was first introduced in OpenSSL 0.9.8. .SH "AUTHOR" .IX Header "AUTHOR" Nils Larsch for the OpenSSL project (http://www.openssl.org) deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_get_fd.30000644000175000017500000001163612360020735017555 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_get_fd 3" .TH SSL_get_fd 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_get_fd, SSL_get_rfd, SSL_get_wfd \- get file descriptor linked to an SSL object .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_get_fd(const SSL *ssl); \& int SSL_get_rfd(const SSL *ssl); \& int SSL_get_wfd(const SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_get_fd()\fR returns the file descriptor which is linked to \fBssl\fR. \&\fISSL_get_rfd()\fR and \fISSL_get_wfd()\fR return the file descriptors for the read or the write channel, which can be different. If the read and the write channel are different, \fISSL_get_fd()\fR will return the file descriptor of the read channel. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .IP "\-1" 4 .IX Item "-1" The operation failed, because the underlying \s-1BIO\s0 is not of the correct type (suitable for file descriptors). .IP ">=0" 4 .IX Item ">=0" The file descriptor linked to \fBssl\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_set_fd\fR\|(3), \fIssl\fR\|(3) , \fIbio\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/HMAC.30000644000175000017500000001756712360020721016320 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "HMAC 3" .TH HMAC 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" HMAC, HMAC_Init, HMAC_Update, HMAC_Final, HMAC_cleanup \- HMAC message authentication code .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& unsigned char *HMAC(const EVP_MD *evp_md, const void *key, \& int key_len, const unsigned char *d, int n, \& unsigned char *md, unsigned int *md_len); \& \& void HMAC_CTX_init(HMAC_CTX *ctx); \& \& int HMAC_Init(HMAC_CTX *ctx, const void *key, int key_len, \& const EVP_MD *md); \& int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int key_len, \& const EVP_MD *md, ENGINE *impl); \& int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len); \& int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); \& \& void HMAC_CTX_cleanup(HMAC_CTX *ctx); \& void HMAC_cleanup(HMAC_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\s-1HMAC\s0 is a \s-1MAC \s0(message authentication code), i.e. a keyed hash function used for message authentication, which is based on a hash function. .PP \&\s-1\fIHMAC\s0()\fR computes the message authentication code of the \fBn\fR bytes at \&\fBd\fR using the hash function \fBevp_md\fR and the key \fBkey\fR which is \&\fBkey_len\fR bytes long. .PP It places the result in \fBmd\fR (which must have space for the output of the hash function, which is no more than \fB\s-1EVP_MAX_MD_SIZE\s0\fR bytes). If \fBmd\fR is \s-1NULL,\s0 the digest is placed in a static array. The size of the output is placed in \fBmd_len\fR, unless it is \fB\s-1NULL\s0\fR. .PP \&\fBevp_md\fR can be \fIEVP_sha1()\fR, \fIEVP_ripemd160()\fR etc. .PP \&\fIHMAC_CTX_init()\fR initialises a \fB\s-1HMAC_CTX\s0\fR before first use. It must be called. .PP \&\fIHMAC_CTX_cleanup()\fR erases the key and other data from the \fB\s-1HMAC_CTX\s0\fR and releases any associated resources. It must be called when an \&\fB\s-1HMAC_CTX\s0\fR is no longer required. .PP \&\fIHMAC_cleanup()\fR is an alias for \fIHMAC_CTX_cleanup()\fR included for back compatibility with 0.9.6b, it is deprecated. .PP The following functions may be used if the message is not completely stored in memory: .PP \&\fIHMAC_Init()\fR initializes a \fB\s-1HMAC_CTX\s0\fR structure to use the hash function \fBevp_md\fR and the key \fBkey\fR which is \fBkey_len\fR bytes long. It is deprecated and only included for backward compatibility with OpenSSL 0.9.6b. .PP \&\fIHMAC_Init_ex()\fR initializes or reuses a \fB\s-1HMAC_CTX\s0\fR structure to use the function \fBevp_md\fR and key \fBkey\fR. Either can be \s-1NULL,\s0 in which case the existing one will be reused. \fIHMAC_CTX_init()\fR must have been called before the first use of an \fB\s-1HMAC_CTX\s0\fR in this function. \fBN.B. \f(BIHMAC_Init()\fB had this undocumented behaviour in previous versions of OpenSSL \- failure to switch to \f(BIHMAC_Init_ex()\fB in programs that expect it will cause them to stop working\fR. .PP \&\fIHMAC_Update()\fR can be called repeatedly with chunks of the message to be authenticated (\fBlen\fR bytes at \fBdata\fR). .PP \&\fIHMAC_Final()\fR places the message authentication code in \fBmd\fR, which must have space for the hash function output. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\s-1\fIHMAC\s0()\fR returns a pointer to the message authentication code or \s-1NULL\s0 if an error occurred. .PP \&\fIHMAC_Init_ex()\fR, \fIHMAC_Update()\fR and \fIHMAC_Final()\fR return 1 for success or 0 if an error occurred. .PP \&\fIHMAC_CTX_init()\fR and \fIHMAC_CTX_cleanup()\fR do not return values. .SH "CONFORMING TO" .IX Header "CONFORMING TO" \&\s-1RFC 2104\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIsha\fR\|(3), \fIevp\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\s-1\fIHMAC\s0()\fR, \fIHMAC_Init()\fR, \fIHMAC_Update()\fR, \fIHMAC_Final()\fR and \fIHMAC_cleanup()\fR are available since SSLeay 0.9.0. .PP \&\fIHMAC_CTX_init()\fR, \fIHMAC_Init_ex()\fR and \fIHMAC_CTX_cleanup()\fR are available since OpenSSL 0.9.7. .PP \&\fIHMAC_Init_ex()\fR, \fIHMAC_Update()\fR and \fIHMAC_Final()\fR did not return values in versions of OpenSSL before 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/ERR_get_error.30000644000175000017500000001566412360020717020311 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ERR_get_error 3" .TH ERR_get_error 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ERR_get_error, ERR_peek_error, ERR_peek_last_error, ERR_get_error_line, ERR_peek_error_line, ERR_peek_last_error_line, ERR_get_error_line_data, ERR_peek_error_line_data, ERR_peek_last_error_line_data \- obtain error code and data .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& unsigned long ERR_get_error(void); \& unsigned long ERR_peek_error(void); \& unsigned long ERR_peek_last_error(void); \& \& unsigned long ERR_get_error_line(const char **file, int *line); \& unsigned long ERR_peek_error_line(const char **file, int *line); \& unsigned long ERR_peek_last_error_line(const char **file, int *line); \& \& unsigned long ERR_get_error_line_data(const char **file, int *line, \& const char **data, int *flags); \& unsigned long ERR_peek_error_line_data(const char **file, int *line, \& const char **data, int *flags); \& unsigned long ERR_peek_last_error_line_data(const char **file, int *line, \& const char **data, int *flags); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIERR_get_error()\fR returns the earliest error code from the thread's error queue and removes the entry. This function can be called repeatedly until there are no more error codes to return. .PP \&\fIERR_peek_error()\fR returns the earliest error code from the thread's error queue without modifying it. .PP \&\fIERR_peek_last_error()\fR returns the latest error code from the thread's error queue without modifying it. .PP See \s-1\fIERR_GET_LIB\s0\fR\|(3) for obtaining information about location and reason of the error, and \&\fIERR_error_string\fR\|(3) for human-readable error messages. .PP \&\fIERR_get_error_line()\fR, \fIERR_peek_error_line()\fR and \&\fIERR_peek_last_error_line()\fR are the same as the above, but they additionally store the file name and line number where the error occurred in *\fBfile\fR and *\fBline\fR, unless these are \fB\s-1NULL\s0\fR. .PP \&\fIERR_get_error_line_data()\fR, \fIERR_peek_error_line_data()\fR and \&\fIERR_peek_last_error_line_data()\fR store additional data and flags associated with the error code in *\fBdata\fR and *\fBflags\fR, unless these are \fB\s-1NULL\s0\fR. *\fBdata\fR contains a string if *\fBflags\fR&\fB\s-1ERR_TXT_STRING\s0\fR is true. .PP An application \fB\s-1MUST NOT\s0\fR free the *\fBdata\fR pointer (or any other pointers returned by these functions) with \fIOPENSSL_free()\fR as freeing is handled automatically by the error library. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The error code, or 0 if there is no error in the queue. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIerr\fR\|(3), \fIERR_error_string\fR\|(3), \&\s-1\fIERR_GET_LIB\s0\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIERR_get_error()\fR, \fIERR_peek_error()\fR, \fIERR_get_error_line()\fR and \&\fIERR_peek_error_line()\fR are available in all versions of SSLeay and OpenSSL. \fIERR_get_error_line_data()\fR and \fIERR_peek_error_line_data()\fR were added in SSLeay 0.9.0. \&\fIERR_peek_last_error()\fR, \fIERR_peek_last_error_line()\fR and \&\fIERR_peek_last_error_line_data()\fR were added in OpenSSL 0.9.7. deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_mod_inverse.30000644000175000017500000001165012360020712020464 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_mod_inverse 3" .TH BN_mod_inverse 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_mod_inverse \- compute inverse modulo n .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIGNUM *BN_mod_inverse(BIGNUM *r, BIGNUM *a, const BIGNUM *n, \& BN_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBN_mod_inverse()\fR computes the inverse of \fBa\fR modulo \fBn\fR places the result in \fBr\fR (\f(CW\*(C`(a*r)%n==1\*(C'\fR). If \fBr\fR is \s-1NULL,\s0 a new \fB\s-1BIGNUM\s0\fR is created. .PP \&\fBctx\fR is a previously allocated \fB\s-1BN_CTX\s0\fR used for temporary variables. \fBr\fR may be the same \fB\s-1BIGNUM\s0\fR as \fBa\fR or \fBn\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBN_mod_inverse()\fR returns the \fB\s-1BIGNUM\s0\fR containing the inverse, and \s-1NULL\s0 on error. The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3), \fIERR_get_error\fR\|(3), \fIBN_add\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIBN_mod_inverse()\fR is available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/RSA_blinding_on.30000644000175000017500000001205012360020723020557 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RSA_blinding_on 3" .TH RSA_blinding_on 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RSA_blinding_on, RSA_blinding_off \- protect the RSA operation from timing attacks .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); \& \& void RSA_blinding_off(RSA *rsa); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\s-1RSA\s0 is vulnerable to timing attacks. In a setup where attackers can measure the time of \s-1RSA\s0 decryption or signature operations, blinding must be used to protect the \s-1RSA\s0 operation from that attack. .PP \&\fIRSA_blinding_on()\fR turns blinding on for key \fBrsa\fR and generates a random blinding factor. \fBctx\fR is \fB\s-1NULL\s0\fR or a pre-allocated and initialized \fB\s-1BN_CTX\s0\fR. .PP \&\fIRSA_blinding_off()\fR turns blinding off and frees the memory used for the blinding factor. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIRSA_blinding_on()\fR returns 1 on success, and 0 if an error occurred. .PP \&\fIRSA_blinding_off()\fR returns no value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIrsa\fR\|(3), \fIrand\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIRSA_blinding_on()\fR and \fIRSA_blinding_off()\fR appeared in SSLeay 0.9.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_BLINDING_new.30000644000175000017500000002213712360020711020212 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_BLINDING_new 3" .TH BN_BLINDING_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_BLINDING_new, BN_BLINDING_free, BN_BLINDING_update, BN_BLINDING_convert, BN_BLINDING_invert, BN_BLINDING_convert_ex, BN_BLINDING_invert_ex, BN_BLINDING_get_thread_id, BN_BLINDING_set_thread_id, BN_BLINDING_thread_id, BN_BLINDING_get_flags, BN_BLINDING_set_flags, BN_BLINDING_create_param \- blinding related BIGNUM functions. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, \& BIGNUM *mod); \& void BN_BLINDING_free(BN_BLINDING *b); \& int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx); \& int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); \& int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); \& int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, \& BN_CTX *ctx); \& int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, \& BN_CTX *ctx); \& #ifndef OPENSSL_NO_DEPRECATED \& unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *); \& void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long); \& #endif \& CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *); \& unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); \& void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); \& BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, \& const BIGNUM *e, BIGNUM *m, BN_CTX *ctx, \& int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, \& const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), \& BN_MONT_CTX *m_ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBN_BLINDING_new()\fR allocates a new \fB\s-1BN_BLINDING\s0\fR structure and copies the \fBA\fR and \fBAi\fR values into the newly created \fB\s-1BN_BLINDING\s0\fR object. .PP \&\fIBN_BLINDING_free()\fR frees the \fB\s-1BN_BLINDING\s0\fR structure. .PP \&\fIBN_BLINDING_update()\fR updates the \fB\s-1BN_BLINDING\s0\fR parameters by squaring the \fBA\fR and \fBAi\fR or, after specific number of uses and if the necessary parameters are set, by re-creating the blinding parameters. .PP \&\fIBN_BLINDING_convert_ex()\fR multiplies \fBn\fR with the blinding factor \fBA\fR. If \fBr\fR is not \s-1NULL\s0 a copy the inverse blinding factor \fBAi\fR will be returned in \fBr\fR (this is useful if a \fB\s-1RSA\s0\fR object is shared among several threads). \fIBN_BLINDING_invert_ex()\fR multiplies \fBn\fR with the inverse blinding factor \fBAi\fR. If \fBr\fR is not \s-1NULL\s0 it will be used as the inverse blinding. .PP \&\fIBN_BLINDING_convert()\fR and \fIBN_BLINDING_invert()\fR are wrapper functions for \fIBN_BLINDING_convert_ex()\fR and \fIBN_BLINDING_invert_ex()\fR with \fBr\fR set to \s-1NULL.\s0 .PP \&\fIBN_BLINDING_thread_id()\fR provides access to the \fB\s-1CRYPTO_THREADID\s0\fR object within the \fB\s-1BN_BLINDING\s0\fR structure. This is to help users provide proper locking if needed for multi-threaded use. The \*(L"thread id\*(R" object of a newly allocated \fB\s-1BN_BLINDING\s0\fR structure is initialised to the thread id in which \fIBN_BLINDING_new()\fR was called. .PP \&\fIBN_BLINDING_get_flags()\fR returns the \s-1BN_BLINDING\s0 flags. Currently there are two supported flags: \fB\s-1BN_BLINDING_NO_UPDATE\s0\fR and \&\fB\s-1BN_BLINDING_NO_RECREATE\s0\fR. \fB\s-1BN_BLINDING_NO_UPDATE\s0\fR inhibits the automatic update of the \fB\s-1BN_BLINDING\s0\fR parameters after each use and \fB\s-1BN_BLINDING_NO_RECREATE\s0\fR inhibits the automatic re-creation of the \fB\s-1BN_BLINDING\s0\fR parameters after a fixed number of uses (currently 32). In newly allocated \fB\s-1BN_BLINDING\s0\fR objects no flags are set. \&\fIBN_BLINDING_set_flags()\fR sets the \fB\s-1BN_BLINDING\s0\fR parameters flags. .PP \&\fIBN_BLINDING_create_param()\fR creates new \fB\s-1BN_BLINDING\s0\fR parameters using the exponent \fBe\fR and the modulus \fBm\fR. \fBbn_mod_exp\fR and \&\fBm_ctx\fR can be used to pass special functions for exponentiation (normally \fIBN_mod_exp_mont()\fR and \fB\s-1BN_MONT_CTX\s0\fR). .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBN_BLINDING_new()\fR returns the newly allocated \fB\s-1BN_BLINDING\s0\fR structure or \s-1NULL\s0 in case of an error. .PP \&\fIBN_BLINDING_update()\fR, \fIBN_BLINDING_convert()\fR, \fIBN_BLINDING_invert()\fR, \&\fIBN_BLINDING_convert_ex()\fR and \fIBN_BLINDING_invert_ex()\fR return 1 on success and 0 if an error occured. .PP \&\fIBN_BLINDING_thread_id()\fR returns a pointer to the thread id object within a \fB\s-1BN_BLINDING\s0\fR object. .PP \&\fIBN_BLINDING_get_flags()\fR returns the currently set \fB\s-1BN_BLINDING\s0\fR flags (a \fBunsigned long\fR value). .PP \&\fIBN_BLINDING_create_param()\fR returns the newly created \fB\s-1BN_BLINDING\s0\fR parameters or \s-1NULL\s0 on error. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" BN_BLINDING_thread_id was first introduced in OpenSSL 1.0.0, and it deprecates BN_BLINDING_set_thread_id and BN_BLINDING_get_thread_id. .PP BN_BLINDING_convert_ex, BN_BLINDIND_invert_ex, BN_BLINDING_get_thread_id, BN_BLINDING_set_thread_id, BN_BLINDING_set_flags, BN_BLINDING_get_flags and BN_BLINDING_create_param were first introduced in OpenSSL 0.9.8 .SH "AUTHOR" .IX Header "AUTHOR" Nils Larsch for the OpenSSL project (http://www.openssl.org). deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_CTX_use_psk_identity_hint.30000644000175000017500000001554612360020734023452 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_CTX_use_psk_identity_hint 3" .TH SSL_CTX_use_psk_identity_hint 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_CTX_use_psk_identity_hint, SSL_use_psk_identity_hint, SSL_CTX_set_psk_server_callback, SSL_set_psk_server_callback \- set PSK identity hint to use .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *hint); \& int SSL_use_psk_identity_hint(SSL *ssl, const char *hint); \& \& void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, \& unsigned int (*callback)(SSL *ssl, const char *identity, \& unsigned char *psk, int max_psk_len)); \& void SSL_set_psk_server_callback(SSL *ssl, \& unsigned int (*callback)(SSL *ssl, const char *identity, \& unsigned char *psk, int max_psk_len)); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_CTX_use_psk_identity_hint()\fR sets the given \fB\s-1NULL\s0\fR\-terminated \s-1PSK\s0 identity hint \fBhint\fR to \s-1SSL\s0 context object \&\fBctx\fR. \fISSL_use_psk_identity_hint()\fR sets the given \fB\s-1NULL\s0\fR\-terminated \&\s-1PSK\s0 identity hint \fBhint\fR to \s-1SSL\s0 connection object \fBssl\fR. If \fBhint\fR is \fB\s-1NULL\s0\fR the current hint from \fBctx\fR or \fBssl\fR is deleted. .PP In the case where \s-1PSK\s0 identity hint is \fB\s-1NULL\s0\fR, the server does not send the ServerKeyExchange message to the client. .PP A server application must provide a callback function which is called when the server receives the ClientKeyExchange message from the client. The purpose of the callback function is to validate the received \s-1PSK\s0 identity and to fetch the pre-shared key used during the connection setup phase. The callback is set using functions \&\fISSL_CTX_set_psk_server_callback()\fR or \&\fISSL_set_psk_server_callback()\fR. The callback function is given the connection in parameter \fBssl\fR, \fB\s-1NULL\s0\fR\-terminated \s-1PSK\s0 identity sent by the client in parameter \fBidentity\fR, and a buffer \fBpsk\fR of length \&\fBmax_psk_len\fR bytes where the pre-shared key is to be stored. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_CTX_use_psk_identity_hint()\fR and \fISSL_use_psk_identity_hint()\fR return 1 on success, 0 otherwise. .PP Return values from the server callback are interpreted as follows: .ie n .IP """> 0""" 4 .el .IP "\f(CW> 0\fR" 4 .IX Item "> 0" \&\s-1PSK\s0 identity was found and the server callback has provided the \s-1PSK\s0 successfully in parameter \fBpsk\fR. Return value is the length of \&\fBpsk\fR in bytes. It is an error to return a value greater than \&\fBmax_psk_len\fR. .Sp If the \s-1PSK\s0 identity was not found but the callback instructs the protocol to continue anyway, the callback must provide some random data to \fBpsk\fR and return the length of the random data, so the connection will fail with decryption_error before it will be finished completely. .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" \&\s-1PSK\s0 identity was not found. An \*(L"unknown_psk_identity\*(R" alert message will be sent and the connection setup fails. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_connect.30000644000175000017500000001503612360020734017753 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_connect 3" .TH SSL_connect 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_connect \- initiate the TLS/SSL handshake with an TLS/SSL server .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_connect(SSL *ssl); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_connect()\fR initiates the \s-1TLS/SSL\s0 handshake with a server. The communication channel must already have been set and assigned to the \fBssl\fR by setting an underlying \fB\s-1BIO\s0\fR. .SH "NOTES" .IX Header "NOTES" The behaviour of \fISSL_connect()\fR depends on the underlying \s-1BIO.\s0 .PP If the underlying \s-1BIO\s0 is \fBblocking\fR, \fISSL_connect()\fR will only return once the handshake has been finished or an error occurred. .PP If the underlying \s-1BIO\s0 is \fBnon-blocking\fR, \fISSL_connect()\fR will also return when the underlying \s-1BIO\s0 could not satisfy the needs of \fISSL_connect()\fR to continue the handshake, indicating the problem by the return value \-1. In this case a call to \fISSL_get_error()\fR with the return value of \fISSL_connect()\fR will yield \fB\s-1SSL_ERROR_WANT_READ\s0\fR or \&\fB\s-1SSL_ERROR_WANT_WRITE\s0\fR. The calling process then must repeat the call after taking appropriate action to satisfy the needs of \fISSL_connect()\fR. The action depends on the underlying \s-1BIO.\s0 When using a non-blocking socket, nothing is to be done, but \fIselect()\fR can be used to check for the required condition. When using a buffering \s-1BIO,\s0 like a \s-1BIO\s0 pair, data must be written into or retrieved out of the \s-1BIO\s0 before being able to continue. .SH "RETURN VALUES" .IX Header "RETURN VALUES" The following return values can occur: .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" The \s-1TLS/SSL\s0 handshake was not successful but was shut down controlled and by the specifications of the \s-1TLS/SSL\s0 protocol. Call \fISSL_get_error()\fR with the return value \fBret\fR to find out the reason. .ie n .IP "1" 4 .el .IP "\f(CW1\fR" 4 .IX Item "1" The \s-1TLS/SSL\s0 handshake was successfully completed, a \s-1TLS/SSL\s0 connection has been established. .ie n .IP """<0""" 4 .el .IP "\f(CW<0\fR" 4 .IX Item "<0" The \s-1TLS/SSL\s0 handshake was not successful, because a fatal error occurred either at the protocol level or a connection failure occurred. The shutdown was not clean. It can also occur of action is need to continue the operation for non-blocking BIOs. Call \fISSL_get_error()\fR with the return value \fBret\fR to find out the reason. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fISSL_get_error\fR\|(3), \fISSL_accept\fR\|(3), \&\fISSL_shutdown\fR\|(3), \fIssl\fR\|(3), \fIbio\fR\|(3), \&\fISSL_set_connect_state\fR\|(3), \&\fISSL_do_handshake\fR\|(3), \&\fISSL_CTX_new\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/ASN1_generate_nconf.30000644000175000017500000003267112360020707021344 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ASN1_generate_nconf 3" .TH ASN1_generate_nconf 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ASN1_generate_nconf, ASN1_generate_v3 \- ASN1 generation functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf); \& ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions generate the \s-1ASN1\s0 encoding of a string in an \fB\s-1ASN1_TYPE\s0\fR structure. .PP \&\fBstr\fR contains the string to encode \fBnconf\fR or \fBcnf\fR contains the optional configuration information where additional strings will be read from. \fBnconf\fR will typically come from a config file wherease \fBcnf\fR is obtained from an \fBX509V3_CTX\fR structure which will typically be used by X509 v3 certificate extension functions. \fBcnf\fR or \fBnconf\fR can be set to \fB\s-1NULL\s0\fR if no additional configuration will be used. .SH "GENERATION STRING FORMAT" .IX Header "GENERATION STRING FORMAT" The actual data encoded is determined by the string \fBstr\fR and the configuration information. The general format of the string is: .IP "\fB[modifier,]type[:value]\fR" 2 .IX Item "[modifier,]type[:value]" .PP That is zero or more comma separated modifiers followed by a type followed by an optional colon and a value. The formats of \fBtype\fR, \&\fBvalue\fR and \fBmodifier\fR are explained below. .SS "\s-1SUPPORTED TYPES\s0" .IX Subsection "SUPPORTED TYPES" The supported types are listed below. Unless otherwise specified only the \fB\s-1ASCII\s0\fR format is permissible. .IP "\fB\s-1BOOLEAN\s0\fR, \fB\s-1BOOL\s0\fR" 2 .IX Item "BOOLEAN, BOOL" This encodes a boolean type. The \fBvalue\fR string is mandatory and should be \fB\s-1TRUE\s0\fR or \fB\s-1FALSE\s0\fR. Additionally \fB\s-1TRUE\s0\fR, \fBtrue\fR, \fBY\fR, \&\fBy\fR, \fB\s-1YES\s0\fR, \fByes\fR, \fB\s-1FALSE\s0\fR, \fBfalse\fR, \fBN\fR, \fBn\fR, \fB\s-1NO\s0\fR and \fBno\fR are acceptable. .IP "\fB\s-1NULL\s0\fR" 2 .IX Item "NULL" Encode the \fB\s-1NULL\s0\fR type, the \fBvalue\fR string must not be present. .IP "\fB\s-1INTEGER\s0\fR, \fB\s-1INT\s0\fR" 2 .IX Item "INTEGER, INT" Encodes an \s-1ASN1 \s0\fB\s-1INTEGER\s0\fR type. The \fBvalue\fR string represents the value of the integer, it can be prefaced by a minus sign and is normally interpreted as a decimal value unless the prefix \fB0x\fR is included. .IP "\fB\s-1ENUMERATED\s0\fR, \fB\s-1ENUM\s0\fR" 2 .IX Item "ENUMERATED, ENUM" Encodes the \s-1ASN1 \s0\fB\s-1ENUMERATED\s0\fR type, it is otherwise identical to \&\fB\s-1INTEGER\s0\fR. .IP "\fB\s-1OBJECT\s0\fR, \fB\s-1OID\s0\fR" 2 .IX Item "OBJECT, OID" Encodes an \s-1ASN1 \s0\fB\s-1OBJECT IDENTIFIER\s0\fR, the \fBvalue\fR string can be a short name, a long name or numerical format. .IP "\fB\s-1UTCTIME\s0\fR, \fB\s-1UTC\s0\fR" 2 .IX Item "UTCTIME, UTC" Encodes an \s-1ASN1 \s0\fBUTCTime\fR structure, the value should be in the format \fB\s-1YYMMDDHHMMSSZ\s0\fR. .IP "\fB\s-1GENERALIZEDTIME\s0\fR, \fB\s-1GENTIME\s0\fR" 2 .IX Item "GENERALIZEDTIME, GENTIME" Encodes an \s-1ASN1 \s0\fBGeneralizedTime\fR structure, the value should be in the format \fB\s-1YYYYMMDDHHMMSSZ\s0\fR. .IP "\fB\s-1OCTETSTRING\s0\fR, \fB\s-1OCT\s0\fR" 2 .IX Item "OCTETSTRING, OCT" Encodes an \s-1ASN1 \s0\fB\s-1OCTET STRING\s0\fR. \fBvalue\fR represents the contents of this structure, the format strings \fB\s-1ASCII\s0\fR and \fB\s-1HEX\s0\fR can be used to specify the format of \fBvalue\fR. .IP "\fB\s-1BITSTRING\s0\fR, \fB\s-1BITSTR\s0\fR" 2 .IX Item "BITSTRING, BITSTR" Encodes an \s-1ASN1 \s0\fB\s-1BIT STRING\s0\fR. \fBvalue\fR represents the contents of this structure, the format strings \fB\s-1ASCII\s0\fR, \fB\s-1HEX\s0\fR and \fB\s-1BITLIST\s0\fR can be used to specify the format of \fBvalue\fR. .Sp If the format is anything other than \fB\s-1BITLIST\s0\fR the number of unused bits is set to zero. .IP "\fB\s-1UNIVERSALSTRING\s0\fR, \fB\s-1UNIV\s0\fR, \fB\s-1IA5\s0\fR, \fB\s-1IA5STRING\s0\fR, \fB\s-1UTF8\s0\fR, \fBUTF8String\fR, \fB\s-1BMP\s0\fR, \fB\s-1BMPSTRING\s0\fR, \fB\s-1VISIBLESTRING\s0\fR, \fB\s-1VISIBLE\s0\fR, \fB\s-1PRINTABLESTRING\s0\fR, \fB\s-1PRINTABLE\s0\fR, \fBT61\fR, \fBT61STRING\fR, \fB\s-1TELETEXSTRING\s0\fR, \fBGeneralString\fR, \fB\s-1NUMERICSTRING\s0\fR, \fB\s-1NUMERIC\s0\fR" 2 .IX Item "UNIVERSALSTRING, UNIV, IA5, IA5STRING, UTF8, UTF8String, BMP, BMPSTRING, VISIBLESTRING, VISIBLE, PRINTABLESTRING, PRINTABLE, T61, T61STRING, TELETEXSTRING, GeneralString, NUMERICSTRING, NUMERIC" These encode the corresponding string types. \fBvalue\fR represents the contents of this structure. The format can be \fB\s-1ASCII\s0\fR or \fB\s-1UTF8\s0\fR. .IP "\fB\s-1SEQUENCE\s0\fR, \fB\s-1SEQ\s0\fR, \fB\s-1SET\s0\fR" 2 .IX Item "SEQUENCE, SEQ, SET" Formats the result as an \s-1ASN1 \s0\fB\s-1SEQUENCE\s0\fR or \fB\s-1SET\s0\fR type. \fBvalue\fR should be a section name which will contain the contents. The field names in the section are ignored and the values are in the generated string format. If \fBvalue\fR is absent then an empty \s-1SEQUENCE\s0 will be encoded. .SS "\s-1MODIFIERS\s0" .IX Subsection "MODIFIERS" Modifiers affect the following structure, they can be used to add \s-1EXPLICIT\s0 or \s-1IMPLICIT\s0 tagging, add wrappers or to change the string format of the final type and value. The supported formats are documented below. .IP "\fB\s-1EXPLICIT\s0\fR, \fB\s-1EXP\s0\fR" 2 .IX Item "EXPLICIT, EXP" Add an explicit tag to the following structure. This string should be followed by a colon and the tag value to use as a decimal value. .Sp By following the number with \fBU\fR, \fBA\fR, \fBP\fR or \fBC\fR \s-1UNIVERSAL, APPLICATION, PRIVATE\s0 or \s-1CONTEXT SPECIFIC\s0 tagging can be used, the default is \s-1CONTEXT SPECIFIC.\s0 .IP "\fB\s-1IMPLICIT\s0\fR, \fB\s-1IMP\s0\fR" 2 .IX Item "IMPLICIT, IMP" This is the same as \fB\s-1EXPLICIT\s0\fR except \s-1IMPLICIT\s0 tagging is used instead. .IP "\fB\s-1OCTWRAP\s0\fR, \fB\s-1SEQWRAP\s0\fR, \fB\s-1SETWRAP\s0\fR, \fB\s-1BITWRAP\s0\fR" 2 .IX Item "OCTWRAP, SEQWRAP, SETWRAP, BITWRAP" The following structure is surrounded by an \s-1OCTET STRING,\s0 a \s-1SEQUENCE,\s0 a \s-1SET\s0 or a \s-1BIT STRING\s0 respectively. For a \s-1BIT STRING\s0 the number of unused bits is set to zero. .IP "\fB\s-1FORMAT\s0\fR" 2 .IX Item "FORMAT" This specifies the format of the ultimate value. It should be followed by a colon and one of the strings \fB\s-1ASCII\s0\fR, \fB\s-1UTF8\s0\fR, \fB\s-1HEX\s0\fR or \fB\s-1BITLIST\s0\fR. .Sp If no format specifier is included then \fB\s-1ASCII\s0\fR is used. If \fB\s-1UTF8\s0\fR is specified then the value string must be a valid \fB\s-1UTF8\s0\fR string. For \fB\s-1HEX\s0\fR the output must be a set of hex digits. \fB\s-1BITLIST\s0\fR (which is only valid for a \s-1BIT STRING\s0) is a comma separated list of the indices of the set bits, all other bits are zero. .SH "EXAMPLES" .IX Header "EXAMPLES" A simple IA5String: .PP .Vb 1 \& IA5STRING:Hello World .Ve .PP An IA5String explicitly tagged: .PP .Vb 1 \& EXPLICIT:0,IA5STRING:Hello World .Ve .PP An IA5String explicitly tagged using \s-1APPLICATION\s0 tagging: .PP .Vb 1 \& EXPLICIT:0A,IA5STRING:Hello World .Ve .PP A \s-1BITSTRING\s0 with bits 1 and 5 set and all others zero: .PP .Vb 1 \& FORMAT:BITLIST,BITSTRING:1,5 .Ve .PP A more complex example using a config file to produce a \&\s-1SEQUENCE\s0 consiting of a \s-1BOOL\s0 an \s-1OID\s0 and a UTF8String: .PP .Vb 1 \& asn1 = SEQUENCE:seq_section \& \& [seq_section] \& \& field1 = BOOLEAN:TRUE \& field2 = OID:commonName \& field3 = UTF8:Third field .Ve .PP This example produces an RSAPrivateKey structure, this is the key contained in the file client.pem in all OpenSSL distributions (note: the field names such as 'coeff' are ignored and are present just for clarity): .PP .Vb 3 \& asn1=SEQUENCE:private_key \& [private_key] \& version=INTEGER:0 \& \& n=INTEGER:0xBB6FE79432CC6EA2D8F970675A5A87BFBE1AFF0BE63E879F2AFFB93644\e \& D4D2C6D000430DEC66ABF47829E74B8C5108623A1C0EE8BE217B3AD8D36D5EB4FCA1D9 \& \& e=INTEGER:0x010001 \& \& d=INTEGER:0x6F05EAD2F27FFAEC84BEC360C4B928FD5F3A9865D0FCAAD291E2A52F4A\e \& F810DC6373278C006A0ABBA27DC8C63BF97F7E666E27C5284D7D3B1FFFE16B7A87B51D \& \& p=INTEGER:0xF3929B9435608F8A22C208D86795271D54EBDFB09DDEF539AB083DA912\e \& D4BD57 \& \& q=INTEGER:0xC50016F89DFF2561347ED1186A46E150E28BF2D0F539A1594BBD7FE467\e \& 46EC4F \& \& exp1=INTEGER:0x9E7D4326C924AFC1DEA40B45650134966D6F9DFA3A7F9D698CD4ABEA\e \& 9C0A39B9 \& \& exp2=INTEGER:0xBA84003BB95355AFB7C50DF140C60513D0BA51D637272E355E397779\e \& E7B2458F \& \& coeff=INTEGER:0x30B9E4F2AFA5AC679F920FC83F1F2DF1BAF1779CF989447FABC2F5\e \& 628657053A .Ve .PP This example is the corresponding public key in a SubjectPublicKeyInfo structure: .PP .Vb 2 \& # Start with a SEQUENCE \& asn1=SEQUENCE:pubkeyinfo \& \& # pubkeyinfo contains an algorithm identifier and the public key wrapped \& # in a BIT STRING \& [pubkeyinfo] \& algorithm=SEQUENCE:rsa_alg \& pubkey=BITWRAP,SEQUENCE:rsapubkey \& \& # algorithm ID for RSA is just an OID and a NULL \& [rsa_alg] \& algorithm=OID:rsaEncryption \& parameter=NULL \& \& # Actual public key: modulus and exponent \& [rsapubkey] \& n=INTEGER:0xBB6FE79432CC6EA2D8F970675A5A87BFBE1AFF0BE63E879F2AFFB93644\e \& D4D2C6D000430DEC66ABF47829E74B8C5108623A1C0EE8BE217B3AD8D36D5EB4FCA1D9 \& \& e=INTEGER:0x010001 .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIASN1_generate_nconf()\fR and \fIASN1_generate_v3()\fR return the encoded data as an \fB\s-1ASN1_TYPE\s0\fR structure or \fB\s-1NULL\s0\fR if an error occurred. .PP The error codes that can be obtained by \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIASN1_generate_nconf()\fR and \fIASN1_generate_v3()\fR were added to OpenSSL 0.9.8 deps/libressl-pnacl-sys-2.1.6/libressl/man/BN_copy.30000644000175000017500000001132112360020712017117 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BN_copy 3" .TH BN_copy 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BN_copy, BN_dup \- copy BIGNUMs .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& BIGNUM *BN_copy(BIGNUM *to, const BIGNUM *from); \& \& BIGNUM *BN_dup(const BIGNUM *from); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBN_copy()\fR copies \fBfrom\fR to \fBto\fR. \fIBN_dup()\fR creates a new \fB\s-1BIGNUM\s0\fR containing the value \fBfrom\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBN_copy()\fR returns \fBto\fR on success, \s-1NULL\s0 on error. \fIBN_dup()\fR returns the new \fB\s-1BIGNUM\s0\fR, and \s-1NULL\s0 on error. The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIbn\fR\|(3), \fIERR_get_error\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIBN_copy()\fR and \fIBN_dup()\fR are available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/RSA_size.30000644000175000017500000001077212360020724017261 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RSA_size 3" .TH RSA_size 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" RSA_size \- get RSA modulus size .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int RSA_size(const RSA *rsa); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This function returns the \s-1RSA\s0 modulus size in bytes. It can be used to determine how much memory must be allocated for an \s-1RSA\s0 encrypted value. .PP \&\fBrsa\->n\fR must not be \fB\s-1NULL\s0\fR. .SH "RETURN VALUE" .IX Header "RETURN VALUE" The size in bytes. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIrsa\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIRSA_size()\fR is available in all versions of SSLeay and OpenSSL. deps/libressl-pnacl-sys-2.1.6/libressl/man/ERR_load_strings.30000644000175000017500000001254512360020717021004 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ERR_load_strings 3" .TH ERR_load_strings 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ERR_load_strings, ERR_PACK, ERR_get_next_error_library \- load arbitrary error strings .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void ERR_load_strings(int lib, ERR_STRING_DATA str[]); \& \& int ERR_get_next_error_library(void); \& \& unsigned long ERR_PACK(int lib, int func, int reason); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIERR_load_strings()\fR registers error strings for library number \fBlib\fR. .PP \&\fBstr\fR is an array of error string data: .PP .Vb 5 \& typedef struct ERR_string_data_st \& { \& unsigned long error; \& char *string; \& } ERR_STRING_DATA; .Ve .PP The error code is generated from the library number and a function and reason code: \fBerror\fR = \s-1ERR_PACK\s0(\fBlib\fR, \fBfunc\fR, \fBreason\fR). \&\s-1\fIERR_PACK\s0()\fR is a macro. .PP The last entry in the array is {0,0}. .PP \&\fIERR_get_next_error_library()\fR can be used to assign library numbers to user libraries at runtime. .SH "RETURN VALUE" .IX Header "RETURN VALUE" \&\fIERR_load_strings()\fR returns no value. \s-1\fIERR_PACK\s0()\fR return the error code. \&\fIERR_get_next_error_library()\fR returns a new library number. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIerr\fR\|(3), \fIERR_load_strings\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIERR_load_error_strings()\fR and \s-1\fIERR_PACK\s0()\fR are available in all versions of SSLeay and OpenSSL. \fIERR_get_next_error_library()\fR was added in SSLeay 0.9.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/ec.30000644000175000017500000003645212360020727016177 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ec 3" .TH ec 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ec \- Elliptic Curve functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& const EC_METHOD *EC_GFp_simple_method(void); \& const EC_METHOD *EC_GFp_mont_method(void); \& const EC_METHOD *EC_GFp_nist_method(void); \& const EC_METHOD *EC_GFp_nistp224_method(void); \& const EC_METHOD *EC_GFp_nistp256_method(void); \& const EC_METHOD *EC_GFp_nistp521_method(void); \& \& const EC_METHOD *EC_GF2m_simple_method(void); \& \& EC_GROUP *EC_GROUP_new(const EC_METHOD *meth); \& void EC_GROUP_free(EC_GROUP *group); \& void EC_GROUP_clear_free(EC_GROUP *group); \& int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src); \& EC_GROUP *EC_GROUP_dup(const EC_GROUP *src); \& const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group); \& int EC_METHOD_get_field_type(const EC_METHOD *meth); \& int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor); \& const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group); \& int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx); \& int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx); \& void EC_GROUP_set_curve_name(EC_GROUP *group, int nid); \& int EC_GROUP_get_curve_name(const EC_GROUP *group); \& void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag); \& int EC_GROUP_get_asn1_flag(const EC_GROUP *group); \& void EC_GROUP_set_point_conversion_form(EC_GROUP *group, point_conversion_form_t form); \& point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); \& unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x); \& size_t EC_GROUP_get_seed_len(const EC_GROUP *); \& size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); \& int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); \& int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); \& int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); \& int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); \& int EC_GROUP_get_degree(const EC_GROUP *group); \& int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); \& int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx); \& int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx); \& EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); \& EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); \& EC_GROUP *EC_GROUP_new_by_curve_name(int nid); \& \& size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); \& \& EC_POINT *EC_POINT_new(const EC_GROUP *group); \& void EC_POINT_free(EC_POINT *point); \& void EC_POINT_clear_free(EC_POINT *point); \& int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src); \& EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group); \& const EC_METHOD *EC_POINT_method_of(const EC_POINT *point); \& int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point); \& int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, \& const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx); \& int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, \& const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx); \& int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, \& const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx); \& int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, \& const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); \& int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, \& const BIGNUM *x, int y_bit, BN_CTX *ctx); \& int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, \& const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx); \& int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, \& const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); \& int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, \& const BIGNUM *x, int y_bit, BN_CTX *ctx); \& size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, \& point_conversion_form_t form, \& unsigned char *buf, size_t len, BN_CTX *ctx); \& int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, \& const unsigned char *buf, size_t len, BN_CTX *ctx); \& BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, \& point_conversion_form_t form, BIGNUM *, BN_CTX *); \& EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *, \& EC_POINT *, BN_CTX *); \& char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, \& point_conversion_form_t form, BN_CTX *); \& EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, \& EC_POINT *, BN_CTX *); \& \& int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx); \& int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx); \& int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx); \& int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p); \& int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx); \& int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx); \& int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx); \& int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx); \& int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, size_t num, const EC_POINT *p[], const BIGNUM *m[], BN_CTX *ctx); \& int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); \& int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx); \& int EC_GROUP_have_precompute_mult(const EC_GROUP *group); \& \& int EC_GROUP_get_basis_type(const EC_GROUP *); \& int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); \& int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, \& unsigned int *k2, unsigned int *k3); \& EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); \& int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); \& #define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x) \& #define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x) \& #define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \e \& (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x)) \& #define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \e \& (unsigned char *)(x)) \& int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off); \& int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); \& \& EC_KEY *EC_KEY_new(void); \& int EC_KEY_get_flags(const EC_KEY *key); \& void EC_KEY_set_flags(EC_KEY *key, int flags); \& void EC_KEY_clear_flags(EC_KEY *key, int flags); \& EC_KEY *EC_KEY_new_by_curve_name(int nid); \& void EC_KEY_free(EC_KEY *key); \& EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src); \& EC_KEY *EC_KEY_dup(const EC_KEY *src); \& int EC_KEY_up_ref(EC_KEY *key); \& const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key); \& int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group); \& const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key); \& int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv); \& const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key); \& int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub); \& unsigned EC_KEY_get_enc_flags(const EC_KEY *key); \& void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags); \& point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key); \& void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform); \& void *EC_KEY_get_key_method_data(EC_KEY *key, \& void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); \& void EC_KEY_insert_key_method_data(EC_KEY *key, void *data, \& void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *)); \& void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag); \& int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx); \& int EC_KEY_generate_key(EC_KEY *key); \& int EC_KEY_check_key(const EC_KEY *key); \& int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y); \& \& EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len); \& int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out); \& \& EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len); \& int i2d_ECParameters(EC_KEY *key, unsigned char **out); \& \& EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len); \& int i2o_ECPublicKey(EC_KEY *key, unsigned char **out); \& int ECParameters_print(BIO *bp, const EC_KEY *key); \& int EC_KEY_print(BIO *bp, const EC_KEY *key, int off); \& int ECParameters_print_fp(FILE *fp, const EC_KEY *key); \& int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); \& #define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) \& #define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \e \& EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \e \& EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL) .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This library provides an extensive set of functions for performing operations on elliptic curves over finite fields. In general an elliptic curve is one with an equation of the form: .PP y^2 = x^3 + ax + b .PP An \fB\s-1EC_GROUP\s0\fR structure is used to represent the definition of an elliptic curve. Points on a curve are stored using an \&\fB\s-1EC_POINT\s0\fR structure. An \fB\s-1EC_KEY\s0\fR is used to hold a private/public key pair, where a private key is simply a \s-1BIGNUM\s0 and a public key is a point on a curve (represented by an \fB\s-1EC_POINT\s0\fR). .PP The library contains a number of alternative implementations of the different functions. Each implementation is optimised for different scenarios. No matter which implementation is being used, the interface remains the same. The library handles calling the correct implementation when an interface function is invoked. An implementation is represented by an \fB\s-1EC_METHOD\s0\fR structure. .PP The creation and destruction of \fB\s-1EC_GROUP\s0\fR objects is described in \fIEC_GROUP_new\fR\|(3). Functions for manipulating \fB\s-1EC_GROUP\s0\fR objects are described in \fIEC_GROUP_copy\fR\|(3). .PP Functions for creating, destroying and manipulating \fB\s-1EC_POINT\s0\fR objects are explained in \fIEC_POINT_new\fR\|(3), whilst functions for performing mathematical operations and tests on \fBEC_POINTs\fR are coverd in \fIEC_POINT_add\fR\|(3). .PP For working with private and public keys refer to \fIEC_KEY_new\fR\|(3). Implementations are covered in \&\fIEC_GFp_simple_method\fR\|(3). .PP For information on encoding and decoding curve parameters to and from \s-1ASN1\s0 see \fId2i_ECPKParameters\fR\|(3). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIcrypto\fR\|(3), \fIEC_GROUP_new\fR\|(3), \fIEC_GROUP_copy\fR\|(3), \&\fIEC_POINT_new\fR\|(3), \fIEC_POINT_add\fR\|(3), \fIEC_KEY_new\fR\|(3), \&\fIEC_GFp_simple_method\fR\|(3), \fId2i_ECPKParameters\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/OPENSSL_load_builtin_modules.30000644000175000017500000001263512360020722023200 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "OPENSSL_load_builtin_modules 3" .TH OPENSSL_load_builtin_modules 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" OPENSSL_load_builtin_modules, ASN1_add_oid_module, ENGINE_add_conf_module \- add standard configuration modules .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void OPENSSL_load_builtin_modules(void); \& void ASN1_add_oid_module(void); \& ENGINE_add_conf_module(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The function \fIOPENSSL_load_builtin_modules()\fR adds all the standard OpenSSL configuration modules to the internal list. They can then be used by the OpenSSL configuration code. .PP \&\fIASN1_add_oid_module()\fR adds just the \s-1ASN1 OBJECT\s0 module. .PP \&\fIENGINE_add_conf_module()\fR adds just the \s-1ENGINE\s0 configuration module. .SH "NOTES" .IX Header "NOTES" If the simple configuration function \fIOPENSSL_config()\fR is called then \&\fIOPENSSL_load_builtin_modules()\fR is called automatically. .PP Applications which use the configuration functions directly will need to call \fIOPENSSL_load_builtin_modules()\fR themselves \fIbefore\fR any other configuration code. .PP Applications should call \fIOPENSSL_load_builtin_modules()\fR to load all configuration modules instead of adding modules selectively: otherwise functionality may be missing from the application if an when new modules are added. .SH "RETURN VALUE" .IX Header "RETURN VALUE" None of the functions return a value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIconf\fR\|(3), \fIOPENSSL_config\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" These functions first appeared in OpenSSL 0.9.7. deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_VerifyInit.30000644000175000017500000001674312360020721020405 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_VerifyInit 3" .TH EVP_VerifyInit 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_VerifyInit, EVP_VerifyUpdate, EVP_VerifyFinal \- EVP signature verification functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_VerifyInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); \& int EVP_VerifyUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); \& int EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf, unsigned int siglen,EVP_PKEY *pkey); \& \& int EVP_VerifyInit(EVP_MD_CTX *ctx, const EVP_MD *type); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \s-1EVP\s0 signature verification routines are a high level interface to digital signatures. .PP \&\fIEVP_VerifyInit_ex()\fR sets up verification context \fBctx\fR to use digest \&\fBtype\fR from \s-1ENGINE \s0\fBimpl\fR. \fBctx\fR must be initialized by calling \&\fIEVP_MD_CTX_init()\fR before calling this function. .PP \&\fIEVP_VerifyUpdate()\fR hashes \fBcnt\fR bytes of data at \fBd\fR into the verification context \fBctx\fR. This function can be called several times on the same \fBctx\fR to include additional data. .PP \&\fIEVP_VerifyFinal()\fR verifies the data in \fBctx\fR using the public key \fBpkey\fR and against the \fBsiglen\fR bytes at \fBsigbuf\fR. .PP \&\fIEVP_VerifyInit()\fR initializes verification context \fBctx\fR to use the default implementation of digest \fBtype\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_VerifyInit_ex()\fR and \fIEVP_VerifyUpdate()\fR return 1 for success and 0 for failure. .PP \&\fIEVP_VerifyFinal()\fR returns 1 for a correct signature, 0 for failure and \-1 if some other error occurred. .PP The error codes can be obtained by \fIERR_get_error\fR\|(3). .SH "NOTES" .IX Header "NOTES" The \fB\s-1EVP\s0\fR interface to digital signatures should almost always be used in preference to the low level interfaces. This is because the code then becomes transparent to the algorithm used and much more flexible. .PP Due to the link between message digests and public key algorithms the correct digest algorithm must be used with the correct public key type. A list of algorithms and associated public key algorithms appears in \&\fIEVP_DigestInit\fR\|(3). .PP The call to \fIEVP_VerifyFinal()\fR internally finalizes a copy of the digest context. This means that calls to \fIEVP_VerifyUpdate()\fR and \fIEVP_VerifyFinal()\fR can be called later to digest and verify additional data. .PP Since only a copy of the digest context is ever finalized the context must be cleaned up after use by calling \fIEVP_MD_CTX_cleanup()\fR or a memory leak will occur. .SH "BUGS" .IX Header "BUGS" Older versions of this documentation wrongly stated that calls to \&\fIEVP_VerifyUpdate()\fR could not be made after calling \fIEVP_VerifyFinal()\fR. .PP Since the public key is passed in the call to \fIEVP_SignFinal()\fR any error relating to the private key (for example an unsuitable key and digest combination) will not be indicated until after potentially large amounts of data have been passed through \fIEVP_SignUpdate()\fR. .PP It is not possible to change the signing parameters using these function. .PP The previous two bugs are fixed in the newer EVP_VerifyDigest*() function. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIevp\fR\|(3), \&\fIEVP_SignInit\fR\|(3), \&\fIEVP_DigestInit\fR\|(3), \fIerr\fR\|(3), \&\fIevp\fR\|(3), \fIhmac\fR\|(3), \fImd2\fR\|(3), \&\fImd5\fR\|(3), \fImdc2\fR\|(3), \fIripemd\fR\|(3), \&\fIsha\fR\|(3), \fIdgst\fR\|(1) .SH "HISTORY" .IX Header "HISTORY" \&\fIEVP_VerifyInit()\fR, \fIEVP_VerifyUpdate()\fR and \fIEVP_VerifyFinal()\fR are available in all versions of SSLeay and OpenSSL. .PP \&\fIEVP_VerifyInit_ex()\fR was added in OpenSSL 0.9.7 deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_BytesToKey.30000644000175000017500000001457012360020717020360 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_BytesToKey 3" .TH EVP_BytesToKey 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_BytesToKey \- password based encryption routine .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md, \& const unsigned char *salt, \& const unsigned char *data, int datal, int count, \& unsigned char *key,unsigned char *iv); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIEVP_BytesToKey()\fR derives a key and \s-1IV\s0 from various parameters. \fBtype\fR is the cipher to derive the key and \s-1IV\s0 for. \fBmd\fR is the message digest to use. The \fBsalt\fR parameter is used as a salt in the derivation: it should point to an 8 byte buffer or \s-1NULL\s0 if no salt is used. \fBdata\fR is a buffer containing \&\fBdatal\fR bytes which is used to derive the keying data. \fBcount\fR is the iteration count to use. The derived key and \s-1IV\s0 will be written to \fBkey\fR and \fBiv\fR respectively. .SH "NOTES" .IX Header "NOTES" A typical application of this function is to derive keying material for an encryption algorithm from a password in the \fBdata\fR parameter. .PP Increasing the \fBcount\fR parameter slows down the algorithm which makes it harder for an attacker to peform a brute force attack using a large number of candidate passwords. .PP If the total key and \s-1IV\s0 length is less than the digest length and \&\fB\s-1MD5\s0\fR is used then the derivation algorithm is compatible with PKCS#5 v1.5 otherwise a non standard extension is used to derive the extra data. .PP Newer applications should use more standard algorithms such as \s-1PBKDF2\s0 as defined in PKCS#5v2.1 for key derivation. .SH "KEY DERIVATION ALGORITHM" .IX Header "KEY DERIVATION ALGORITHM" The key and \s-1IV\s0 is derived by concatenating D_1, D_2, etc until enough data is available for the key and \s-1IV.\s0 D_i is defined as: .PP .Vb 1 \& D_i = HASH^count(D_(i\-1) || data || salt) .Ve .PP where || denotes concatentaion, D_0 is empty, \s-1HASH\s0 is the digest algorithm in use, HASH^1(data) is simply \s-1HASH\s0(data), HASH^2(data) is \s-1HASH\s0(\s-1HASH\s0(data)) and so on. .PP The initial bytes are used for the key and the subsequent bytes for the \s-1IV.\s0 .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_BytesToKey()\fR returns the size of the derived key in bytes. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIevp\fR\|(3), \fIrand\fR\|(3), \&\s-1\fIPKCS5_PBKDF2_HMAC\s0\fR\|(3), \&\fIEVP_EncryptInit\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" deps/libressl-pnacl-sys-2.1.6/libressl/man/BIO_ctrl.30000644000175000017500000002261612360020707017240 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "BIO_ctrl 3" .TH BIO_ctrl 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" BIO_ctrl, BIO_callback_ctrl, BIO_ptr_ctrl, BIO_int_ctrl, BIO_reset, BIO_seek, BIO_tell, BIO_flush, BIO_eof, BIO_set_close, BIO_get_close, BIO_pending, BIO_wpending, BIO_ctrl_pending, BIO_ctrl_wpending, BIO_get_info_callback, BIO_set_info_callback \- BIO control operations .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); \& long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, \& const char *, int, long, long)); \& char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg); \& long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg); \& \& int BIO_reset(BIO *b); \& int BIO_seek(BIO *b, int ofs); \& int BIO_tell(BIO *b); \& int BIO_flush(BIO *b); \& int BIO_eof(BIO *b); \& int BIO_set_close(BIO *b,long flag); \& int BIO_get_close(BIO *b); \& int BIO_pending(BIO *b); \& int BIO_wpending(BIO *b); \& size_t BIO_ctrl_pending(BIO *b); \& size_t BIO_ctrl_wpending(BIO *b); \& \& int BIO_get_info_callback(BIO *b,bio_info_cb **cbp); \& int BIO_set_info_callback(BIO *b,bio_info_cb *cb); \& \& typedef void bio_info_cb(BIO *b, int oper, const char *ptr, int arg1, \& long arg2, long arg3); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIBIO_ctrl()\fR, \fIBIO_callback_ctrl()\fR, \fIBIO_ptr_ctrl()\fR and \fIBIO_int_ctrl()\fR are \s-1BIO \s0\*(L"control\*(R" operations taking arguments of various types. These functions are not normally called directly, various macros are used instead. The standard macros are described below, macros specific to a particular type of \s-1BIO\s0 are described in the specific BIOs manual page as well as any special features of the standard calls. .PP \&\fIBIO_reset()\fR typically resets a \s-1BIO\s0 to some initial state, in the case of file related BIOs for example it rewinds the file pointer to the start of the file. .PP \&\fIBIO_seek()\fR resets a file related \s-1BIO\s0's (that is file descriptor and \&\s-1FILE\s0 BIOs) file position pointer to \fBofs\fR bytes from start of file. .PP \&\fIBIO_tell()\fR returns the current file position of a file related \s-1BIO.\s0 .PP \&\fIBIO_flush()\fR normally writes out any internally buffered data, in some cases it is used to signal \s-1EOF\s0 and that no more data will be written. .PP \&\fIBIO_eof()\fR returns 1 if the \s-1BIO\s0 has read \s-1EOF,\s0 the precise meaning of \&\*(L"\s-1EOF\*(R"\s0 varies according to the \s-1BIO\s0 type. .PP \&\fIBIO_set_close()\fR sets the \s-1BIO \s0\fBb\fR close flag to \fBflag\fR. \fBflag\fR can take the value \s-1BIO_CLOSE\s0 or \s-1BIO_NOCLOSE.\s0 Typically \s-1BIO_CLOSE\s0 is used in a source/sink \s-1BIO\s0 to indicate that the underlying I/O stream should be closed when the \s-1BIO\s0 is freed. .PP \&\fIBIO_get_close()\fR returns the BIOs close flag. .PP \&\fIBIO_pending()\fR, \fIBIO_ctrl_pending()\fR, \fIBIO_wpending()\fR and \fIBIO_ctrl_wpending()\fR return the number of pending characters in the BIOs read and write buffers. Not all BIOs support these calls. \fIBIO_ctrl_pending()\fR and \fIBIO_ctrl_wpending()\fR return a size_t type and are functions, \fIBIO_pending()\fR and \fIBIO_wpending()\fR are macros which call \fIBIO_ctrl()\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIBIO_reset()\fR normally returns 1 for success and 0 or \-1 for failure. File BIOs are an exception, they return 0 for success and \-1 for failure. .PP \&\fIBIO_seek()\fR and \fIBIO_tell()\fR both return the current file position on success and \-1 for failure, except file BIOs which for \fIBIO_seek()\fR always return 0 for success and \-1 for failure. .PP \&\fIBIO_flush()\fR returns 1 for success and 0 or \-1 for failure. .PP \&\fIBIO_eof()\fR returns 1 if \s-1EOF\s0 has been reached 0 otherwise. .PP \&\fIBIO_set_close()\fR always returns 1. .PP \&\fIBIO_get_close()\fR returns the close flag value: \s-1BIO_CLOSE\s0 or \s-1BIO_NOCLOSE.\s0 .PP \&\fIBIO_pending()\fR, \fIBIO_ctrl_pending()\fR, \fIBIO_wpending()\fR and \fIBIO_ctrl_wpending()\fR return the amount of pending data. .SH "NOTES" .IX Header "NOTES" \&\fIBIO_flush()\fR, because it can write data may return 0 or \-1 indicating that the call should be retried later in a similar manner to \fIBIO_write()\fR. The \fIBIO_should_retry()\fR call should be used and appropriate action taken is the call fails. .PP The return values of \fIBIO_pending()\fR and \fIBIO_wpending()\fR may not reliably determine the amount of pending data in all cases. For example in the case of a file \s-1BIO\s0 some data may be available in the \s-1FILE\s0 structures internal buffers but it is not possible to determine this in a portably way. For other types of \s-1BIO\s0 they may not be supported. .PP Filter BIOs if they do not internally handle a particular \fIBIO_ctrl()\fR operation usually pass the operation to the next \s-1BIO\s0 in the chain. This often means there is no need to locate the required \s-1BIO\s0 for a particular operation, it can be called on a chain and it will be automatically passed to the relevant \s-1BIO.\s0 However this can cause unexpected results: for example no current filter BIOs implement \&\fIBIO_seek()\fR, but this may still succeed if the chain ends in a \s-1FILE\s0 or file descriptor \s-1BIO.\s0 .PP Source/sink BIOs return an 0 if they do not recognize the \fIBIO_ctrl()\fR operation. .SH "BUGS" .IX Header "BUGS" Some of the return values are ambiguous and care should be taken. In particular a return value of 0 can be returned if an operation is not supported, if an error occurred, if \s-1EOF\s0 has not been reached and in the case of \fIBIO_seek()\fR on a file \s-1BIO\s0 for a successful operation. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_SESSION_free.30000644000175000017500000001416512360020734020450 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_SESSION_free 3" .TH SSL_SESSION_free 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_SESSION_free \- free an allocated SSL_SESSION structure .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& void SSL_SESSION_free(SSL_SESSION *session); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_SESSION_free()\fR decrements the reference count of \fBsession\fR and removes the \fB\s-1SSL_SESSION\s0\fR structure pointed to by \fBsession\fR and frees up the allocated memory, if the reference count has reached 0. .SH "NOTES" .IX Header "NOTES" \&\s-1SSL_SESSION\s0 objects are allocated, when a \s-1TLS/SSL\s0 handshake operation is successfully completed. Depending on the settings, see \&\fISSL_CTX_set_session_cache_mode\fR\|(3), the \s-1SSL_SESSION\s0 objects are internally referenced by the \s-1SSL_CTX\s0 and linked into its session cache. \s-1SSL\s0 objects may be using the \s-1SSL_SESSION\s0 object; as a session may be reused, several \s-1SSL\s0 objects may be using one \s-1SSL_SESSION\s0 object at the same time. It is therefore crucial to keep the reference count (usage information) correct and not delete a \s-1SSL_SESSION\s0 object that is still used, as this may lead to program failures due to dangling pointers. These failures may also appear delayed, e.g. when an \s-1SSL_SESSION\s0 object was completely freed as the reference count incorrectly became 0, but it is still referenced in the internal session cache and the cache list is processed during a \&\fISSL_CTX_flush_sessions\fR\|(3) operation. .PP \&\fISSL_SESSION_free()\fR must only be called for \s-1SSL_SESSION\s0 objects, for which the reference count was explicitly incremented (e.g. by calling \fISSL_get1_session()\fR, see \fISSL_get_session\fR\|(3)) or when the \s-1SSL_SESSION\s0 object was generated outside a \s-1TLS\s0 handshake operation, e.g. by using \fId2i_SSL_SESSION\fR\|(3). It must not be called on other \s-1SSL_SESSION\s0 objects, as this would cause incorrect reference counts and therefore program failures. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_SESSION_free()\fR does not provide diagnostic information. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3), \fISSL_get_session\fR\|(3), \&\fISSL_CTX_set_session_cache_mode\fR\|(3), \&\fISSL_CTX_flush_sessions\fR\|(3), \fId2i_SSL_SESSION\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/ERR_set_mark.30000644000175000017500000001147212360020717020117 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ERR_set_mark 3" .TH ERR_set_mark 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ERR_set_mark, ERR_pop_to_mark \- set marks and pop errors until mark .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int ERR_set_mark(void); \& \& int ERR_pop_to_mark(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIERR_set_mark()\fR sets a mark on the current topmost error record if there is one. .PP \&\fIERR_pop_to_mark()\fR will pop the top of the error stack until a mark is found. The mark is then removed. If there is no mark, the whole stack is removed. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIERR_set_mark()\fR returns 0 if the error stack is empty, otherwise 1. .PP \&\fIERR_pop_to_mark()\fR returns 0 if there was no mark in the error stack, which implies that the stack became empty, otherwise 1. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIerr\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIERR_set_mark()\fR and \fIERR_pop_to_mark()\fR were added in OpenSSL 0.9.8. deps/libressl-pnacl-sys-2.1.6/libressl/man/SSL_COMP_add_compression_method.30000644000175000017500000001473212360020731023650 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SSL_COMP_add_compression_method 3" .TH SSL_COMP_add_compression_method 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SSL_COMP_add_compression_method \- handle SSL/TLS integrated compression methods .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fISSL_COMP_add_compression_method()\fR adds the compression method \fBcm\fR with the identifier \fBid\fR to the list of available compression methods. This list is globally maintained for all \s-1SSL\s0 operations within this application. It cannot be set for specific \s-1SSL_CTX\s0 or \s-1SSL\s0 objects. .SH "NOTES" .IX Header "NOTES" The \s-1TLS\s0 standard (or SSLv3) allows the integration of compression methods into the communication. The \s-1TLS RFC\s0 does however not specify compression methods or their corresponding identifiers, so there is currently no compatible way to integrate compression with unknown peers. It is therefore currently not recommended to integrate compression into applications. Applications for non-public use may agree on certain compression methods. Using different compression methods with the same identifier will lead to connection failure. .PP An OpenSSL client speaking a protocol that allows compression (SSLv3, TLSv1) will unconditionally send the list of all compression methods enabled with \&\fISSL_COMP_add_compression_method()\fR to the server during the handshake. Unlike the mechanisms to set a cipher list, there is no method available to restrict the list of compression method on a per connection basis. .PP An OpenSSL server will match the identifiers listed by a client against its own compression methods and will unconditionally activate compression when a matching identifier is found. There is no way to restrict the list of compression methods supported on a per connection basis. .PP The OpenSSL library has the compression methods \fB\f(BICOMP_rle()\fB\fR and (when especially enabled during compilation) \fB\f(BICOMP_zlib()\fB\fR available. .SH "WARNINGS" .IX Header "WARNINGS" Once the identities of the compression methods for the \s-1TLS\s0 protocol have been standardized, the compression \s-1API\s0 will most likely be changed. Using it in the current state is not recommended. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fISSL_COMP_add_compression_method()\fR may return the following values: .ie n .IP "0" 4 .el .IP "\f(CW0\fR" 4 .IX Item "0" The operation succeeded. .ie n .IP "1" 4 .el .IP "\f(CW1\fR" 4 .IX Item "1" The operation failed. Check the error queue to find out the reason. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIssl\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/ASN1_STRING_new.30000644000175000017500000001176312360020707020245 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ASN1_STRING_new 3" .TH ASN1_STRING_new 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ASN1_STRING_new, ASN1_STRING_type_new, ASN1_STRING_free \- ASN1_STRING allocation functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& ASN1_STRING * ASN1_STRING_new(void); \& ASN1_STRING * ASN1_STRING_type_new(int type); \& void ASN1_STRING_free(ASN1_STRING *a); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIASN1_STRING_new()\fR returns an allocated \fB\s-1ASN1_STRING\s0\fR structure. Its type is undefined. .PP \&\fIASN1_STRING_type_new()\fR returns an allocated \fB\s-1ASN1_STRING\s0\fR structure of type \fBtype\fR. .PP \&\fIASN1_STRING_free()\fR frees up \fBa\fR. .SH "NOTES" .IX Header "NOTES" Other string types call the \fB\s-1ASN1_STRING\s0\fR functions. For example \&\fIASN1_OCTET_STRING_new()\fR calls ASN1_STRING_type(V_ASN1_OCTET_STRING). .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIASN1_STRING_new()\fR and \fIASN1_STRING_type_new()\fR return a valid \&\s-1ASN1_STRING\s0 structure or \fB\s-1NULL\s0\fR if an error occurred. .PP \&\fIASN1_STRING_free()\fR does not return a value. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3) deps/libressl-pnacl-sys-2.1.6/libressl/man/DSA_set_method.30000644000175000017500000002366012360020715020424 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DSA_set_method 3" .TH DSA_set_method 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DSA_set_default_method, DSA_get_default_method, DSA_set_method, DSA_new_method, DSA_OpenSSL \- select DSA method .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #include \& #include \& \& void DSA_set_default_method(const DSA_METHOD *meth); \& \& const DSA_METHOD *DSA_get_default_method(void); \& \& int DSA_set_method(DSA *dsa, const DSA_METHOD *meth); \& \& DSA *DSA_new_method(ENGINE *engine); \& \& DSA_METHOD *DSA_OpenSSL(void); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" A \fB\s-1DSA_METHOD\s0\fR specifies the functions that OpenSSL uses for \s-1DSA\s0 operations. By modifying the method, alternative implementations such as hardware accelerators may be used. \s-1IMPORTANT:\s0 See the \s-1NOTES\s0 section for important information about how these \s-1DSA API\s0 functions are affected by the use of \fB\s-1ENGINE\s0\fR \s-1API\s0 calls. .PP Initially, the default \s-1DSA_METHOD\s0 is the OpenSSL internal implementation, as returned by \fIDSA_OpenSSL()\fR. .PP \&\fIDSA_set_default_method()\fR makes \fBmeth\fR the default method for all \s-1DSA\s0 structures created later. \fB\s-1NB\s0\fR: This is true only whilst no \s-1ENGINE\s0 has been set as a default for \s-1DSA,\s0 so this function is no longer recommended. .PP \&\fIDSA_get_default_method()\fR returns a pointer to the current default \&\s-1DSA_METHOD.\s0 However, the meaningfulness of this result is dependent on whether the \s-1ENGINE API\s0 is being used, so this function is no longer recommended. .PP \&\fIDSA_set_method()\fR selects \fBmeth\fR to perform all operations using the key \&\fBrsa\fR. This will replace the \s-1DSA_METHOD\s0 used by the \s-1DSA\s0 key and if the previous method was supplied by an \s-1ENGINE,\s0 the handle to that \s-1ENGINE\s0 will be released during the change. It is possible to have \s-1DSA\s0 keys that only work with certain \s-1DSA_METHOD\s0 implementations (eg. from an \s-1ENGINE\s0 module that supports embedded hardware-protected keys), and in such cases attempting to change the \s-1DSA_METHOD\s0 for the key can have unexpected results. .PP \&\fIDSA_new_method()\fR allocates and initializes a \s-1DSA\s0 structure so that \fBengine\fR will be used for the \s-1DSA\s0 operations. If \fBengine\fR is \s-1NULL,\s0 the default engine for \s-1DSA\s0 operations is used, and if no default \s-1ENGINE\s0 is set, the \s-1DSA_METHOD\s0 controlled by \fIDSA_set_default_method()\fR is used. .SH "THE DSA_METHOD STRUCTURE" .IX Header "THE DSA_METHOD STRUCTURE" struct { /* name of the implementation */ const char *name; .PP .Vb 3 \& /* sign */ \& DSA_SIG *(*dsa_do_sign)(const unsigned char *dgst, int dlen, \& DSA *dsa); \& \& /* pre\-compute k^\-1 and r */ \& int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, \& BIGNUM **rp); \& \& /* verify */ \& int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len, \& DSA_SIG *sig, DSA *dsa); \& \& /* compute rr = a1^p1 * a2^p2 mod m (May be NULL for some \& implementations) */ \& int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, \& BIGNUM *a2, BIGNUM *p2, BIGNUM *m, \& BN_CTX *ctx, BN_MONT_CTX *in_mont); \& \& /* compute r = a ^ p mod m (May be NULL for some implementations) */ \& int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a, \& const BIGNUM *p, const BIGNUM *m, \& BN_CTX *ctx, BN_MONT_CTX *m_ctx); \& \& /* called at DSA_new */ \& int (*init)(DSA *DSA); \& \& /* called at DSA_free */ \& int (*finish)(DSA *DSA); \& \& int flags; \& \& char *app_data; /* ?? */ \& \& } DSA_METHOD; .Ve .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIDSA_OpenSSL()\fR and \fIDSA_get_default_method()\fR return pointers to the respective \&\fB\s-1DSA_METHOD\s0\fRs. .PP \&\fIDSA_set_default_method()\fR returns no value. .PP \&\fIDSA_set_method()\fR returns non-zero if the provided \fBmeth\fR was successfully set as the method for \fBdsa\fR (including unloading the \s-1ENGINE\s0 handle if the previous method was supplied by an \s-1ENGINE\s0). .PP \&\fIDSA_new_method()\fR returns \s-1NULL\s0 and sets an error code that can be obtained by \fIERR_get_error\fR\|(3) if the allocation fails. Otherwise it returns a pointer to the newly allocated structure. .SH "NOTES" .IX Header "NOTES" As of version 0.9.7, \s-1DSA_METHOD\s0 implementations are grouped together with other algorithmic APIs (eg. \s-1RSA_METHOD, EVP_CIPHER,\s0 etc) in \fB\s-1ENGINE\s0\fR modules. If a default \s-1ENGINE\s0 is specified for \s-1DSA\s0 functionality using an \s-1ENGINE API\s0 function, that will override any \s-1DSA\s0 defaults set using the \s-1DSA API \s0(ie. \&\fIDSA_set_default_method()\fR). For this reason, the \s-1ENGINE API\s0 is the recommended way to control default implementations for use in \s-1DSA\s0 and other cryptographic algorithms. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdsa\fR\|(3), \fIDSA_new\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" \&\fIDSA_set_default_method()\fR, \fIDSA_get_default_method()\fR, \fIDSA_set_method()\fR, \&\fIDSA_new_method()\fR and \fIDSA_OpenSSL()\fR were added in OpenSSL 0.9.4. .PP \&\fIDSA_set_default_openssl_method()\fR and \fIDSA_get_default_openssl_method()\fR replaced \&\fIDSA_set_default_method()\fR and \fIDSA_get_default_method()\fR respectively, and \&\fIDSA_set_method()\fR and \fIDSA_new_method()\fR were altered to use \fB\s-1ENGINE\s0\fRs rather than \&\fB\s-1DSA_METHOD\s0\fRs during development of the engine version of OpenSSL 0.9.6. For 0.9.7, the handling of defaults in the \s-1ENGINE API\s0 was restructured so that this change was reversed, and behaviour of the other functions resembled more closely the previous behaviour. The behaviour of defaults in the \s-1ENGINE API\s0 now transparently overrides the behaviour of defaults in the \s-1DSA API\s0 without requiring changing these function prototypes. deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_PKEY_print_private.30000644000175000017500000001344112360020720022022 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_PKEY_print_private 3" .TH EVP_PKEY_print_private 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_PKEY_print_public, EVP_PKEY_print_private, EVP_PKEY_print_params \- public key algorithm printing routines. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey, \& int indent, ASN1_PCTX *pctx); \& int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey, \& int indent, ASN1_PCTX *pctx); \& int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey, \& int indent, ASN1_PCTX *pctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The functions \fIEVP_PKEY_print_public()\fR, \fIEVP_PKEY_print_private()\fR and \&\fIEVP_PKEY_print_params()\fR print out the public, private or parameter components of key \fBpkey\fR respectively. The key is sent to \s-1BIO \s0\fBout\fR in human readable form. The parameter \fBindent\fR indicated how far the printout should be indented. .PP The \fBpctx\fR parameter allows the print output to be finely tuned by using \&\s-1ASN1\s0 printing options. If \fBpctx\fR is set to \s-1NULL\s0 then default values will be used. .SH "NOTES" .IX Header "NOTES" Currently no public key algorithms include any options in the \fBpctx\fR parameter parameter. .PP If the key does not include all the components indicated by the function then only those contained in the key will be printed. For example passing a public key to \fIEVP_PKEY_print_private()\fR will only print the public components. .SH "RETURN VALUES" .IX Header "RETURN VALUES" These functions all return 1 for success and 0 or a negative value for failure. In particular a return value of \-2 indicates the operation is not supported by the public key algorithm. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_PKEY_CTX_new\fR\|(3), \&\fIEVP_PKEY_keygen\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" These functions were first added to OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/man/ASN1_STRING_length.30000644000175000017500000001602212360020707020726 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ASN1_STRING_length 3" .TH ASN1_STRING_length 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ASN1_STRING_dup, ASN1_STRING_cmp, ASN1_STRING_set, ASN1_STRING_length, ASN1_STRING_length_set, ASN1_STRING_type, ASN1_STRING_data, ASN1_STRING_to_UTF8 \- ASN1_STRING utility functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int ASN1_STRING_length(ASN1_STRING *x); \& unsigned char * ASN1_STRING_data(ASN1_STRING *x); \& \& ASN1_STRING * ASN1_STRING_dup(ASN1_STRING *a); \& \& int ASN1_STRING_cmp(ASN1_STRING *a, ASN1_STRING *b); \& \& int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); \& \& int ASN1_STRING_type(ASN1_STRING *x); \& \& int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These functions allow an \fB\s-1ASN1_STRING\s0\fR structure to be manipulated. .PP \&\fIASN1_STRING_length()\fR returns the length of the content of \fBx\fR. .PP \&\fIASN1_STRING_data()\fR returns an internal pointer to the data of \fBx\fR. Since this is an internal pointer it should \fBnot\fR be freed or modified in any way. .PP \&\fIASN1_STRING_dup()\fR returns a copy of the structure \fBa\fR. .PP \&\fIASN1_STRING_cmp()\fR compares \fBa\fR and \fBb\fR returning 0 if the two are identical. The string types and content are compared. .PP \&\fIASN1_STRING_set()\fR sets the data of string \fBstr\fR to the buffer \&\fBdata\fR or length \fBlen\fR. The supplied data is copied. If \fBlen\fR is \-1 then the length is determined by strlen(data). .PP \&\fIASN1_STRING_type()\fR returns the type of \fBx\fR, using standard constants such as \fBV_ASN1_OCTET_STRING\fR. .PP \&\fIASN1_STRING_to_UTF8()\fR converts the string \fBin\fR to \s-1UTF8\s0 format, the converted data is allocated in a buffer in \fB*out\fR. The length of \&\fBout\fR is returned or a negative error code. The buffer \fB*out\fR should be free using \fIOPENSSL_free()\fR. .SH "NOTES" .IX Header "NOTES" Almost all \s-1ASN1\s0 types in OpenSSL are represented as an \fB\s-1ASN1_STRING\s0\fR structure. Other types such as \fB\s-1ASN1_OCTET_STRING\s0\fR are simply typedefed to \fB\s-1ASN1_STRING\s0\fR and the functions call the \fB\s-1ASN1_STRING\s0\fR equivalents. \&\fB\s-1ASN1_STRING\s0\fR is also used for some \fB\s-1CHOICE\s0\fR types which consist entirely of primitive string types such as \fBDirectoryString\fR and \&\fBTime\fR. .PP These functions should \fBnot\fR be used to examine or modify \fB\s-1ASN1_INTEGER\s0\fR or \fB\s-1ASN1_ENUMERATED\s0\fR types: the relevant \fB\s-1INTEGER\s0\fR or \fB\s-1ENUMERATED\s0\fR utility functions should be used instead. .PP In general it cannot be assumed that the data returned by \fIASN1_STRING_data()\fR is null terminated or does not contain embedded nulls. The actual format of the data will depend on the actual string type itself: for example for and IA5String the data will be \s-1ASCII,\s0 for a BMPString two bytes per character in big endian format, UTF8String will be in \s-1UTF8\s0 format. .PP Similar care should be take to ensure the data is in the correct format when calling \fIASN1_STRING_set()\fR. .SH "RETURN VALUES" .IX Header "RETURN VALUES" .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIERR_get_error\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" deps/libressl-pnacl-sys-2.1.6/libressl/man/EVP_PKEY_keygen.30000644000175000017500000002341112360020720020414 0ustar .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "EVP_PKEY_keygen 3" .TH EVP_PKEY_keygen 3 "2014-07-11" "LibreSSL" "LibreSSL" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" EVP_PKEY_keygen_init, EVP_PKEY_keygen, EVP_PKEY_paramgen_init, EVP_PKEY_paramgen, EVP_PKEY_CTX_set_cb, EVP_PKEY_CTX_get_cb, EVP_PKEY_CTX_get_keygen_info, EVP_PKEVP_PKEY_CTX_set_app_data, EVP_PKEY_CTX_get_app_data \- key and parameter generation functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx); \& int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey); \& int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx); \& int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey); \& \& typedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx); \& \& void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb); \& EVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx); \& \& int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx); \& \& void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data); \& void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fIEVP_PKEY_keygen_init()\fR function initializes a public key algorithm context using key \fBpkey\fR for a key genration operation. .PP The \fIEVP_PKEY_keygen()\fR function performs a key generation operation, the generated key is written to \fBppkey\fR. .PP The functions \fIEVP_PKEY_paramgen_init()\fR and \fIEVP_PKEY_paramgen()\fR are similar except parameters are generated. .PP The function \fIEVP_PKEY_set_cb()\fR sets the key or parameter generation callback to \fBcb\fR. The function \fIEVP_PKEY_CTX_get_cb()\fR returns the key or parameter generation callback. .PP The function \fIEVP_PKEY_CTX_get_keygen_info()\fR returns parameters associated with the generation operation. If \fBidx\fR is \-1 the total number of parameters available is returned. Any non negative value returns the value of that parameter. \fIEVP_PKEY_CTX_gen_keygen_info()\fR with a non-negative value for \&\fBidx\fR should only be called within the generation callback. .PP If the callback returns 0 then the key genration operation is aborted and an error occurs. This might occur during a time consuming operation where a user clicks on a \*(L"cancel\*(R" button. .PP The functions \fIEVP_PKEY_CTX_set_app_data()\fR and \fIEVP_PKEY_CTX_get_app_data()\fR set and retrieve an opaque pointer. This can be used to set some application defined value which can be retrieved in the callback: for example a handle which is used to update a \*(L"progress dialog\*(R". .SH "NOTES" .IX Header "NOTES" After the call to \fIEVP_PKEY_keygen_init()\fR or \fIEVP_PKEY_paramgen_init()\fR algorithm specific control operations can be performed to set any appropriate parameters for the operation. .PP The functions \fIEVP_PKEY_keygen()\fR and \fIEVP_PKEY_paramgen()\fR can be called more than once on the same context if several operations are performed using the same parameters. .PP The meaning of the parameters passed to the callback will depend on the algorithm and the specifiic implementation of the algorithm. Some might not give any useful information at all during key or parameter generation. Others might not even call the callback. .PP The operation performed by key or parameter generation depends on the algorithm used. In some cases (e.g. \s-1EC\s0 with a supplied named curve) the \*(L"generation\*(R" option merely sets the appropriate fields in an \s-1EVP_PKEY\s0 structure. .PP In OpenSSL an \s-1EVP_PKEY\s0 structure containing a private key also contains the public key components and parameters (if any). An OpenSSL private key is equivalent to what some libraries call a \*(L"key pair\*(R". A private key can be used in functions which require the use of a public key or parameters. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fIEVP_PKEY_keygen_init()\fR, \fIEVP_PKEY_paramgen_init()\fR, \fIEVP_PKEY_keygen()\fR and \&\fIEVP_PKEY_paramgen()\fR return 1 for success and 0 or a negative value for failure. In particular a return value of \-2 indicates the operation is not supported by the public key algorithm. .SH "EXAMPLES" .IX Header "EXAMPLES" Generate a 2048 bit \s-1RSA\s0 key: .PP .Vb 2 \& #include \& #include \& \& EVP_PKEY_CTX *ctx; \& EVP_PKEY *pkey = NULL; \& ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, NULL); \& if (!ctx) \& /* Error occurred */ \& if (EVP_PKEY_keygen_init(ctx) <= 0) \& /* Error */ \& if (EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, 2048) <= 0) \& /* Error */ \& \& /* Generate key */ \& if (EVP_PKEY_keygen(ctx, &pkey) <= 0) \& /* Error */ .Ve .PP Generate a key from a set of parameters: .PP .Vb 2 \& #include \& #include \& \& EVP_PKEY_CTX *ctx; \& EVP_PKEY *pkey = NULL, *param; \& /* Assumed param is set up already */ \& ctx = EVP_PKEY_CTX_new(param); \& if (!ctx) \& /* Error occurred */ \& if (EVP_PKEY_keygen_init(ctx) <= 0) \& /* Error */ \& \& /* Generate key */ \& if (EVP_PKEY_keygen(ctx, &pkey) <= 0) \& /* Error */ .Ve .PP Example of generation callback for OpenSSL public key implementations: .PP .Vb 1 \& /* Application data is a BIO to output status to */ \& \& EVP_PKEY_CTX_set_app_data(ctx, status_bio); \& \& static int \& genpkey_cb(EVP_PKEY_CTX *ctx) \& { \& char c = \*(Aq*\*(Aq; \& BIO *b = EVP_PKEY_CTX_get_app_data(ctx); \& int p; \& \& p = EVP_PKEY_CTX_get_keygen_info(ctx, 0); \& if (p == 0) \& c=\*(Aq.\*(Aq; \& if (p == 1) \& c=\*(Aq+\*(Aq; \& if (p == 2) \& c=\*(Aq*\*(Aq; \& if (p == 3) \& c=\*(Aq\en\*(Aq; \& BIO_write(b,&c,1); \& (void)BIO_flush(b); \& return 1; \& } .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIEVP_PKEY_CTX_new\fR\|(3), \&\fIEVP_PKEY_encrypt\fR\|(3), \&\fIEVP_PKEY_decrypt\fR\|(3), \&\fIEVP_PKEY_sign\fR\|(3), \&\fIEVP_PKEY_verify\fR\|(3), \&\fIEVP_PKEY_verify_recover\fR\|(3), \&\fIEVP_PKEY_derive\fR\|(3) .SH "HISTORY" .IX Header "HISTORY" These functions were first added to OpenSSL 1.0.0. deps/libressl-pnacl-sys-2.1.6/libressl/ltmain.sh0000444000175000017500000104772312360020747016575 0ustar # libtool (GNU libtool) 2.4.2 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, # 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, # or obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: $progname [OPTION]... [MODE-ARG]... # # Provide generalized library-building support services. # # --config show all configuration variables # --debug enable verbose shell tracing # -n, --dry-run display commands without modifying any files # --features display basic configuration information and exit # --mode=MODE use operation mode MODE # --preserve-dup-deps don't remove duplicate dependency libraries # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) # --no-warn don't display warning messages # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages # --version print version information # -h, --help, --help-all print short, long, or detailed help message # # MODE must be one of the following: # # clean remove files from the build directory # compile compile a source file into a libtool object # execute automatically set library path, then run a program # finish complete the installation of libtool libraries # install install libraries or executables # link create a library or an executable # uninstall remove libraries from an installed directory # # MODE-ARGS vary depending on the MODE. When passed as first option, # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # # host-triplet: $host # shell: $SHELL # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) # $progname: (GNU libtool) 2.4.2 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . # GNU libtool home page: . # General help using GNU software: . PROGRAM=libtool PACKAGE=libtool VERSION=2.4.2 TIMESTAMP="" package_revision=1.3337 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # NLS nuisances: We save the old values to restore during execute mode. lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done LC_ALL=C LANGUAGE=C export LANGUAGE LC_ALL $lt_unset CDPATH # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_dirname may be replaced by extended shell implementation # func_basename file func_basename () { func_basename_result=`$ECHO "${1}" | $SED "$basename"` } # func_basename may be replaced by extended shell implementation # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` } # func_dirname_and_basename may be replaced by extended shell implementation # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname may be replaced by extended shell implementation # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' pathcdr='s,^/[^/]*,,' removedotparts=':dotsl s@/\./@/@g t dotsl s,/\.$,/,' collapseslashes='s@/\{1,\}@/@g' finalslash='s,/*$,/,' # func_normal_abspath PATH # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. # value returned in "$func_normal_abspath_result" func_normal_abspath () { # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` while :; do # Processed it all yet? if test "$func_normal_abspath_tpath" = / ; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result" ; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_relative_path SRCDIR DSTDIR # generates a relative path from SRCDIR to DSTDIR, with a trailing # slash if non-empty, suitable for immediately appending a filename # without needing to append a separator. # value returned in "$func_relative_path_result" func_relative_path () { func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=${func_dirname_result} if test "x$func_relative_path_tlibdir" = x ; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test "x$func_stripname_result" != x ; then func_relative_path_result=${func_relative_path_result}/${func_stripname_result} fi # Normalisation. If bindir is libdir, return empty string, # else relative path ending with a slash; either way, target # file name can be directly appended. if test ! -z "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result/" func_relative_path_result=$func_stripname_result fi } # The name of this program: func_dirname_and_basename "$progpath" progname=$func_basename_result # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # Sed substitution that converts a w32 file name or path # which contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. # Since each input `\' is now two `\'s, look for any number of runs of # four `\'s followed by two `\'s and then a '$'. `\' that '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname: ${opt_mode+$opt_mode: }$*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` done my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_mkdir_p_IFS" # mkdir can fail with a `File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "$my_tmpdir" } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # func_quote_for_expand arg # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "$1" | $SED \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_tr_sh # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_version # Echo version message to standard output and exit. func_version () { $opt_debug $SED -n '/(C)/!b go :more /\./!{ N s/\n# / / b more } :go /^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $opt_debug $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" echo $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help [NOEXIT] # Echo long help message to standard output and exit, # unless 'noexit' is passed as argument. func_help () { $opt_debug $SED -n '/^# Usage:/,/# Report bugs to/ { :print s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ p d } /^# .* home page:/b print /^# General help using/b print ' < "$progpath" ret=$? if test -z "$1"; then exit $ret fi } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $opt_debug func_error "missing argument for $1." exit_cmd=exit } # func_split_short_opt shortopt # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. func_split_short_opt () { my_sed_short_opt='1s/^\(..\).*$/\1/;q' my_sed_short_rest='1s/^..\(.*\)$/\1/;q' func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` } # func_split_short_opt may be replaced by extended shell implementation # func_split_long_opt longopt # Set func_split_long_opt_name and func_split_long_opt_arg shell # variables after splitting LONGOPT at the `=' sign. func_split_long_opt () { my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^--[^=]*=//' func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` } # func_split_long_opt may be replaced by extended shell implementation exit_cmd=: magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. nonopt= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "${1}=\$${1}\${2}" } # func_append may be replaced by extended shell implementation # func_append_quoted var value # Quote VALUE and append to the end of shell variable VAR, separated # by a space. func_append_quoted () { func_quote_for_eval "${2}" eval "${1}=\$${1}\\ \$func_quote_for_eval_result" } # func_append_quoted may be replaced by extended shell implementation # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "${@}"` } # func_arith may be replaced by extended shell implementation # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` } # func_len may be replaced by extended shell implementation # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` } # func_lo2o may be replaced by extended shell implementation # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_xform may be replaced by extended shell implementation # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func_error ${1+"$@"} func_error "See the $PACKAGE documentation for more information." func_fatal_error "Fatal configuration error." } # func_config # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # Display the features supported by this script. func_features () { echo "host: $host" if test "$build_libtool_libs" = yes; then echo "enable shared libraries" else echo "disable shared libraries" fi if test "$build_old_libs" = yes; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag tagname # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname="$1" re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf="/$re_begincf/,/$re_endcf/p" # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Option defaults: opt_debug=: opt_dry_run=false opt_config=false opt_preserve_dup_deps=false opt_features=false opt_finish=false opt_help=false opt_help_all=false opt_silent=: opt_warning=: opt_verbose=: opt_silent=false opt_verbose=false # Parse options once, thoroughly. This comes as soon as possible in the # script to make things like `--version' happen as quickly as we can. { # this just eases exit handling while test $# -gt 0; do opt="$1" shift case $opt in --debug|-x) opt_debug='set -x' func_echo "enabling shell trace mode" $opt_debug ;; --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) opt_config=: func_config ;; --dlopen|-dlopen) optarg="$1" opt_dlopen="${opt_dlopen+$opt_dlopen }$optarg" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) opt_features=: func_features ;; --finish) opt_finish=: set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help_all=: opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_mode="$optarg" case $optarg in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_silent=false func_append preserve_args " $opt" ;; --no-warning|--no-warn) opt_warning=false func_append preserve_args " $opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" ;; --silent|--quiet) opt_silent=: func_append preserve_args " $opt" opt_verbose=false ;; --verbose|-v) opt_verbose=: func_append preserve_args " $opt" opt_silent=false ;; --tag) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_tag="$optarg" func_append preserve_args " $opt $optarg" func_enable_tag "$optarg" shift ;; -\?|-h) func_usage ;; --help) func_help ;; --version) func_version ;; # Separate optargs to long options: --*=*) func_split_long_opt "$opt" set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-n*|-v*) func_split_short_opt "$opt" set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) set dummy "$opt" ${1+"$@"}; shift; break ;; esac done # Validate options: # save first non-option argument if test "$#" -gt 0; then nonopt="$opt" shift fi # preserve --debug test "$opt_debug" = : || func_append preserve_args " --debug" case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test "$opt_mode" != execute; then func_error "unrecognized option \`-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$progname --help --mode=$opt_mode' for more information." } # Bail if the options were screwed $exit_cmd $EXIT_FAILURE } ## ----------- ## ## Main. ## ## ----------- ## # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if `file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case "$lalib_p_line" in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test "$lalib_p" = yes } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. func_source () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case "$lt_sysroot:$1" in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result="=$func_stripname_result" ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with \`--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=${1} if test "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$lt_sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $opt_debug # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result="" if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result" ; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $opt_debug if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $opt_debug # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $opt_debug if test -z "$2" && test -n "$1" ; then func_error "Could not determine host file name corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result="$1" fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $opt_debug if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " \`$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result="$3" fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $opt_debug case $4 in $1 ) func_to_host_path_result="$3$func_to_host_path_result" ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via `$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $opt_debug $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $opt_debug case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result="$1" } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result="$func_convert_core_msys_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via `$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $opt_debug if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd="func_convert_path_${func_stripname_result}" fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $opt_debug func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result="$1" } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_msys_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_mode_compile arg... func_mode_compile () { $opt_debug # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify \`-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" func_append_quoted lastarg "$arg" done IFS="$save_ifs" func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with \`-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj="$func_basename_result" } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from \`$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name \`$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname="$func_basename_result" xdir="$func_dirname_result" lobj=${xdir}$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$opt_mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode \`$opt_mode'" ;; esac echo $ECHO "Try \`$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test "$opt_help" = :; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $opt_debug # The first argument is the command name. cmd="$nonopt" test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "\`$file' was not linked with \`-export-dynamic'" continue fi func_dirname "$file" "" "." dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir="$func_dirname_result" ;; *) func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file="$progdir/$program" elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if test "X$opt_dry_run" = Xfalse; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } test "$opt_mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "\`$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument \`$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and \`=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS exit $EXIT_SUCCESS } test "$opt_mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test "x$prev" = x-m && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done case " $install_prog " in *[\\\ /]cp\ *) extra_mode=;; *) extra_mode='-m 644';; esac test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else func_dirname_and_basename "$dest" "" "." destdir="$func_dirname_result" destname="$func_basename_result" # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "\`$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "\`$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname="$1" shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $extra_mode $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme="" ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib="$destdir/$realname" func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name="$func_basename_result" instname="$dir/$name"i func_show_eval "$install_prog $extra_mode $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest="$destfile" destfile= ;; *) func_fatal_help "cannot copy a libtool object to \`$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $extra_mode $file $destfile" 'exit $?' # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog $extra_mode \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script \`$wrapper'" finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink \`$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file="$outputname" else func_warning "cannot relink \`$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name="$func_basename_result" # Set up the ranlib parameters. oldlib="$destdir/$name" func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run \`$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test "$opt_mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms="${my_outputname}S.c" else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${my_outputname}.nm" func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then func_verbose "generating symbol list for \`$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $opt_dry_run || { $RM $export_symbols eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename="" if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname" ; then func_basename "$dlprefile_dlname" dlprefile_dlbasename="$func_basename_result" else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename" ; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $opt_debug win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $opt_debug sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $opt_debug match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive which possess that section. Heuristic: eliminate # all those which have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $opt_debug if func_cygming_gnu_implib_p "$1" ; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1" ; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result="" fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" if test "$lock_old_archive_extraction" = yes; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test "$lock_old_archive_extraction" = yes; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $opt_debug my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib="$func_basename_result" my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`basename "$darwin_archive"` darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include /* declarations of non-ANSI functions */ #if defined(__MINGW32__) # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined(__CYGWIN__) # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined (other platforms) ... */ #endif /* portability defines, excluding path handling macros */ #if defined(_MSC_VER) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC # ifndef _INTPTR_T_DEFINED # define _INTPTR_T_DEFINED # define intptr_t int # endif #elif defined(__MINGW32__) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined(__CYGWIN__) # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined (other platforms) ... */ #endif #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (strcmp (str, pat) == 0) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $opt_debug case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_mode_link arg... func_mode_link () { $opt_debug case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module="${wl}-single_module" func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir="$arg" prev= continue ;; dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" test -f "$arg" \ || func_fatal_error "symbol file \`$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file \`$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "\`-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of \`$dir'" dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" func_append deplibs " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module="${wl}-multi_module" continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "\`-no-install' is ignored for $host" func_warning "assuming \`-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-flto*|-fwhopr*|-fuse-linker-plugin) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test "$prev" = dlfiles; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument" if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname="$func_basename_result" libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps ; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test "$linkmode,$pass" = "lib,link"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs="$tmp_deplibs" fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." else echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "\`$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir="$func_dirname_result" dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test "$prefer_static_libs" = yes || test "$prefer_static_libs,$installed" = "built,no"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib="$l" done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of \`$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir="$ladir" fi ;; esac func_basename "$lib" laname="$func_basename_result" # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$lt_sysroot$libdir" absdir="$lt_sysroot$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later func_append notinst_path " $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi case "$host" in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test "$installed" = no; then func_append notinst_deplibs " $lib" test -z "$DESTDIR" && need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule="" for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule="$dlpremoduletest" break fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then echo if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname="$1" shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" func_basename "$soroot" soname="$func_basename_result" func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from \`$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for \`$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$opt_mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we can not # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null ; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add="$dir/$old_library" fi elif test -n "$old_library"; then add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$absdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$opt_mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs="$temp_deplibs" fi func_append newlib_search_path " $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path="$deplib" ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of \`$dir'" absdir="$dir" fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl" ; then depdepl="$absdir/$objdir/$depdepl" darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi ;; *) path="-L$absdir/$objdir" ;; esac else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "\`$deplib' seems to be moved" path="-L$absdir" fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "\`-R' is ignored for archives" test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "\`-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "\`-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "\`-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 shift IFS="$save_ifs" test -n "$7" && \ func_fatal_help "too many parameters to \`-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$1" number_minor="$2" number_revision="$3" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|qnx|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_minor" lt_irix_increment=no ;; esac ;; no) current="$1" revision="$2" age="$3" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT \`$current' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION \`$revision' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE \`$age' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE \`$age' is greater than the current interface number \`$current'" func_fatal_error "\`$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring:${iface}.0" done # Make executables depend on our current version. func_append verstring ":${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; *) func_fatal_configuration "unknown library version type \`$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" else # XXX tmp=`echo $libname|sed -e 's,+,_,g' -e 's,-,_,g' -e 's,\.,_,g'` eval tmp2=\$${tmp}_ltversion if ! test -z "${SHARED_LIBS_LOG}"; then if ! test -f ${SHARED_LIBS_LOG}; then echo "# SHARED_LIBS+= # " >${SHARED_LIBS_LOG} fi tmp4=`echo $libname|sed -e 's/^lib//'` printf "SHARED_LIBS +=\t%-20s %-8s # %s\n" "$tmp4" "$tmp2" "$versuffix" >>${SHARED_LIBS_LOG} fi if test -n "$versuffix" && test -n "$tmp2"; then versuffix=".$tmp2" fi fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" func_append libobjs " $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$opt_mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then # Remove ${wl} instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$opt_mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname="$1" shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols="$export_symbols" export_symbols= always_export_symbols=yes fi fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd1 in $cmds; do IFS="$save_ifs" # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test "$try_normal_branch" = yes \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=${output_objdir}/${output_la}.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-${k}.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test "X$objlist" = X || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\${concat_cmds}$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi if ${skipped_export-false}; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi fi test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi if ${skipped_export-false}; then if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi fi libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "\`-R' is ignored for objects" test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for objects" test -n "$release" && \ func_warning "\`-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object \`$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for programs" test -n "$release" && \ func_warning "\`-release' is ignored for programs" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " ${wl}-bind_at_load" func_append finalize_command " ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs="$new_libs" func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=no ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi exit $exit_status fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" func_warning "this platform does not like uninstalled shared libraries" func_warning "\`$output' will be relinked during installation" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host" ; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then func_append oldobjs " $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase="$func_basename_result" case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name="$func_basename_result" func_resolve_sysroot "$deplib" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test "x$bindir" != x ; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that can not go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } { test "$opt_mode" = link || test "$opt_mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) func_append RM " $arg"; rmforce=yes ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then odir="$objdir" else odir="$dir/$objdir" fi func_basename "$file" name="$func_basename_result" test "$opt_mode" = uninstall && odir="$dir" # Remember odir for removal later, being careful to avoid duplicates if test "$opt_mode" = clean; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case "$opt_mode" in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test "$opt_mode" = clean ; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name" ; then func_append rmfiles " $odir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$opt_mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # vi:sw=2 deps/libressl-pnacl-sys-2.1.6/libressl/test-driver0000555000175000017500000001027712360020755017143 0ustar #! /bin/sh # test-driver - basic testsuite driver script. scriptversion=2013-07-13.22; # UTC # Copyright (C) 2011-2013 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . # Make unconditional expansion of undefined variables an error. This # helps a lot in preventing typo-related bugs. set -u usage_error () { echo "$0: $*" >&2 print_usage >&2 exit 2 } print_usage () { cat <$log_file 2>&1 estatus=$? if test $enable_hard_errors = no && test $estatus -eq 99; then estatus=1 fi case $estatus:$expect_failure in 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; 0:*) col=$grn res=PASS recheck=no gcopy=no;; 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; *:*) col=$red res=FAIL recheck=yes gcopy=yes;; esac # Report outcome to console. echo "${col}${res}${std}: $test_name" # Register the test result, and other relevant metadata. echo ":test-result: $res" > $trs_file echo ":global-test-result: $res" >> $trs_file echo ":recheck: $recheck" >> $trs_file echo ":copy-in-global-log: $gcopy" >> $trs_file # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: deps/libressl-pnacl-sys-2.1.6/libressl/configure.ac0000644000175000017500000000673412430034550017234 0ustar AC_INIT([libressl], [2.0.0]) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE([subdir-objects]) AC_CONFIG_MACRO_DIR([m4]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AC_SUBST([USER_CFLAGS], "-O2 $CFLAGS") CFLAGS="$CFLAGS -Wall -Werror -g -Wno-pointer-sign" case $target_os in *darwin*) TARGET_OS=darwin; LDFLAGS="$LDFLAGS -Qunused-arguments" CFLAGS="$CFLAGS -std=c99" ;; *linux*) TARGET_OS=linux; CFLAGS="$CFLAGS -D_BSD_SOURCE -D_POSIX_SOURCE -D_GNU_SOURCE -std=c99" ;; *solaris*) TARGET_OS=solaris; CFLAGS="$CFLAGS -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 -DBSD_COMP -std=c99" AC_SUBST([PLATFORM_LDADD], ['-lnsl -lsocket']) ;; *openbsd*) CFLAGS="$CFLAGS -std=c99" AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD gcc has bounded]) ;; *nacl*) TARGET_OS=nacl; ;; *) ;; esac AM_CONDITIONAL(TARGET_DARWIN, test x$TARGET_OS = xdarwin) AM_CONDITIONAL(TARGET_LINUX, test x$TARGET_OS = xlinux) AM_CONDITIONAL(TARGET_SOLARIS, test x$TARGET_OS = xsolaris) AM_CONDITIONAL(TARGET_NACL, test x$TARGET_OS = xnacl) AC_PROG_CC AC_PROG_LIBTOOL AC_PROG_CC_STDC AM_PROG_CC_C_O AC_CHECK_FUNC(strlcpy,[AC_SEARCH_LIBS(strlcpy,, [NO_STRLCPY=], [NO_STRLCPY=yes])], [NO_STRLCPY=yes]) AC_SUBST(NO_STRLCPY) AM_CONDITIONAL(NO_STRLCPY, test "x$NO_STRLCPY" = "xyes") AC_CHECK_FUNC(strlcat,[AC_SEARCH_LIBS(strlcat,, [NO_STRLCAT=], [NO_STRLCAT=yes])], [NO_STRLCAT=yes]) AC_SUBST(NO_STRLCAT) AM_CONDITIONAL(NO_STRLCAT, test "x$NO_STRLCAT" = "xyes") AC_CHECK_FUNC(reallocarray,[AC_SEARCH_LIBS(reallocarray,, [NO_REALLOCARRAY=], [NO_REALLOCARRAY=yes])], [NO_REALLOCARRAY=yes]) AC_SUBST(NO_REALLOCARRAY) AM_CONDITIONAL(NO_REALLOCARRAY, test "x$NO_REALLOCARRAY" = "xyes") AC_CHECK_FUNC(timingsafe_bcmp,[AC_SEARCH_LIBS(timingsafe_bcmp,, [NO_TIMINGSAFE_BCMP=], [NO_TIMINGSAFE_BCMP=yes])], [NO_TIMINGSAFE_BCMP=yes]) AC_SUBST(NO_TIMINGSAFE_BCMP) AM_CONDITIONAL(NO_TIMINGSAFE_BCMP, test "x$NO_TIMINGSAFE_BCMP" = "xyes") AC_CHECK_FUNC(timingsafe_memcmp,[AC_SEARCH_LIBS(timingsafe_memcmp,, [NO_TIMINGSAFE_MEMCMP=], [NO_TIMINGSAFE_MEMCMP=yes])], [NO_TIMINGSAFE_MEMCMP=yes]) AC_SUBST(NO_TIMINGSAFE_MEMCMP) AM_CONDITIONAL(NO_TIMINGSAFE_MEMCMP, test "x$NO_TIMINGSAFE_MEMCMP" = "xyes") AC_CHECK_FUNC(arc4random_buf,[AC_SEARCH_LIBS(write,, [NO_ARC4RANDOM_BUF=], [NO_ARC4RANDOM_BUF=yes])], [NO_ARC4RANDOM_BUF=yes]) AC_SUBST(NO_ARC4RANDOM_BUF) AM_CONDITIONAL(NO_ARC4RANDOM_BUF, test "x$NO_ARC4RANDOM_BUF" = "xyes") # overrides for arc4random_buf implementations with known issues AM_CONDITIONAL(NO_ARC4RANDOM_BUF, test x$TARGET_OS = xdarwin \ -o x$TARGET_OS = xsolaris \ -o x$NO_ARC4RANDOM_BUF = xyes) AC_CHECK_FUNC(getentropy,[AC_SEARCH_LIBS(write,, [NO_GETENTROPY=], [NO_GETENTROPY=yes])], [NO_GETENTROPY=yes]) AC_SUBST(NO_GETENTROPY) AM_CONDITIONAL(NO_GETENTROPY, test "x$NO_GETENTROPY" = "xyes") AC_CHECK_FUNC(issetugid,[AC_SEARCH_LIBS(write,, [NO_ISSETUGID=], [NO_ISSETUGID=yes])], [NO_ISSETUGID=yes]) AC_SUBST(NO_ISSETUGID) AM_CONDITIONAL(NO_ISSETUGID, test "x$NO_ISSETUGID" = "xyes") AC_CHECK_FUNC(strtonum,[AC_SEARCH_LIBS(write,, [NO_STRTONUM=], [NO_STRTONUM=yes])], [NO_STRTONUM=yes]) AC_SUBST(NO_STRTONUM) AM_CONDITIONAL(NO_STRTONUM, test "x$NO_STRTONUM" = "xyes") AC_CHECK_FUNC(getauxval, AC_DEFINE(HAVE_GETAUXVAL)) AC_CHECK_FUNC(funopen, AC_DEFINE(HAVE_FUNOPEN)) LT_INIT AC_OUTPUT(Makefile include/Makefile include/openssl/Makefile ssl/Makefile crypto/Makefile tests/Makefile apps/Makefile man/Makefile) deps/libressl-pnacl-sys-2.1.6/libressl/depcomp0000555000175000017500000005601612360020754016322 0ustar #! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2013-05-30.07; # UTC # Copyright (C) 1999-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by 'PROGRAMS ARGS'. object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac # Get the directory component of the given path, and save it in the # global variables '$dir'. Note that this directory component will # be either empty or ending with a '/' character. This is deliberate. set_dir_from () { case $1 in */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; *) dir=;; esac } # Get the suffix-stripped basename of the given path, and save it the # global variable '$base'. set_base_from () { base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` } # If no dependency file was actually created by the compiler invocation, # we still have to create a dummy depfile, to avoid errors with the # Makefile "include basename.Plo" scheme. make_dummy_depfile () { echo "#dummy" > "$depfile" } # Factor out some common post-processing of the generated depfile. # Requires the auxiliary global variable '$tmpdepfile' to be set. aix_post_process_depfile () { # If the compiler actually managed to produce a dependency file, # post-process it. if test -f "$tmpdepfile"; then # Each line is of the form 'foo.o: dependency.h'. # Do two passes, one to just change these to # $object: dependency.h # and one to simply output # dependency.h: # which is needed to avoid the deleted-header problem. { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" } > "$depfile" rm -f "$tmpdepfile" else make_dummy_depfile fi } # A tabulation character. tab=' ' # A newline character. nl=' ' # Character ranges might be problematic outside the C locale. # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz digits=0123456789 alpha=${upper}${lower} if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Avoid interferences from the environment. gccflag= dashmflag= # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi if test "$depmode" = xlc; then # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. gccflag=-qmakedep=gcc,-MF depmode=gcc fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). Also, it might not be ## supported by the other compilers which use the 'gcc' depmode. ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The second -e expression handles DOS-style file names with drive # letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. ## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ | tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" ;; xlc) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done aix_post_process_depfile ;; tcc) # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 # FIXME: That version still under development at the moment of writing. # Make that this statement remains true also for stable, released # versions. # It will wrap lines (doesn't matter whether long or short) with a # trailing '\', as in: # # foo.o : \ # foo.c \ # foo.h \ # # It will put a trailing '\' even on the last line, and will use leading # spaces rather than leading tabs (at least since its commit 0394caf7 # "Emit spaces for -MD"). "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. # We have to change lines of the first kind to '$object: \'. sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" # And for each line of the second kind, we have to emit a 'dep.h:' # dummy dependency, to avoid the deleted-header problem. sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; ## The order of this option in the case statement is important, since the ## shell code in configure will try each of these formats in the order ## listed in this file. A plain '-MD' option would be understood by many ## compilers, so we must ensure this comes after the gcc and icc options. pgcc) # Portland's C compiler understands '-MD'. # Will always output deps to 'file.d' where file is the root name of the # source file under compilation, even if file resides in a subdirectory. # The object file name does not affect the name of the '.d' file. # pgcc 10.2 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\' : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... set_dir_from "$object" # Use the source, not the object, to determine the base name, since # that's sadly what pgcc will do too. set_base_from "$source" tmpdepfile=$base.d # For projects that build the same source file twice into different object # files, the pgcc approach of using the *source* file root name can cause # problems in parallel builds. Use a locking strategy to avoid stomping on # the same $tmpdepfile. lockdir=$base.d-lock trap " echo '$0: caught signal, cleaning up...' >&2 rmdir '$lockdir' exit 1 " 1 2 13 15 numtries=100 i=$numtries while test $i -gt 0; do # mkdir is a portable test-and-set. if mkdir "$lockdir" 2>/dev/null; then # This process acquired the lock. "$@" -MD stat=$? # Release the lock. rmdir "$lockdir" break else # If the lock is being held by a different process, wait # until the winning process is done or we timeout. while test -d "$lockdir" && test $i -gt 0; do sleep 1 i=`expr $i - 1` done fi i=`expr $i - 1` done trap - 1 2 13 15 if test $i -le 0; then echo "$0: failed to acquire lock after $numtries attempts" >&2 echo "$0: check lockdir '$lockdir'" >&2 exit 1 fi if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in 'foo.d' instead, so we check for that too. # Subdirectories are respected. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then # Libtool generates 2 separate objects for the 2 libraries. These # two compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir$base.o.d # libtool 1.5 tmpdepfile2=$dir.libs/$base.o.d # Likewise. tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d "$@" -MD fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done # Same post-processing that is required for AIX mode. aix_post_process_depfile ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/'"$tab"'/ G p }' >> "$depfile" echo >> "$depfile" # make sure the fragment doesn't end with a backslash rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this sed invocation # correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process the last invocation # correctly. Breaking it into two sed invocations is a workaround. sed '1,2d' "$tmpdepfile" \ | tr ' ' "$nl" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E \ | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" echo "$tab" >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: deps/libressl-pnacl-sys-2.1.6/libressl/apps/0000755000000000000000000000000012666635521017475 5ustar rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/apps/ciphers.c0000644000175000017500000001401012360020706017474 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include "apps.h" #include #include static const char *ciphers_usage[] = { "usage: ciphers args\n", " -v - verbose mode, a textual listing of the SSL/TLS ciphers in OpenSSL\n", " -V - even more verbose\n", " -ssl3 - SSL3 mode\n", " -tls1 - TLS1 mode\n", NULL }; int ciphers_main(int, char **); int ciphers_main(int argc, char **argv) { int ret = 1, i; int verbose = 0, Verbose = 0; const char **pp; const char *p; int badops = 0; SSL_CTX *ctx = NULL; SSL *ssl = NULL; char *ciphers = NULL; const SSL_METHOD *meth = NULL; STACK_OF(SSL_CIPHER) * sk; char buf[512]; BIO *STDout = NULL; meth = SSLv3_server_method(); STDout = BIO_new_fp(stdout, BIO_NOCLOSE); if (!load_config(bio_err, NULL)) goto end; argc--; argv++; while (argc >= 1) { if (strcmp(*argv, "-v") == 0) verbose = 1; else if (strcmp(*argv, "-V") == 0) verbose = Verbose = 1; else if (strcmp(*argv, "-ssl3") == 0) meth = SSLv3_client_method(); else if (strcmp(*argv, "-tls1") == 0) meth = TLSv1_client_method(); else if ((strncmp(*argv, "-h", 2) == 0) || (strcmp(*argv, "-?") == 0)) { badops = 1; break; } else { ciphers = *argv; } argc--; argv++; } if (badops) { for (pp = ciphers_usage; (*pp != NULL); pp++) BIO_printf(bio_err, "%s", *pp); goto end; } OpenSSL_add_ssl_algorithms(); ctx = SSL_CTX_new(meth); if (ctx == NULL) goto err; if (ciphers != NULL) { if (!SSL_CTX_set_cipher_list(ctx, ciphers)) { BIO_printf(bio_err, "Error in cipher list\n"); goto err; } } ssl = SSL_new(ctx); if (ssl == NULL) goto err; if (!verbose) { for (i = 0; ; i++) { p = SSL_get_cipher_list(ssl, i); if (p == NULL) break; if (i != 0) BIO_printf(STDout, ":"); BIO_printf(STDout, "%s", p); } BIO_printf(STDout, "\n"); } else { /* verbose */ sk = SSL_get_ciphers(ssl); for (i = 0; i < sk_SSL_CIPHER_num(sk); i++) { SSL_CIPHER *c; c = sk_SSL_CIPHER_value(sk, i); if (Verbose) { unsigned long id = SSL_CIPHER_get_id(c); int id0 = (int) (id >> 24); int id1 = (int) ((id >> 16) & 0xffL); int id2 = (int) ((id >> 8) & 0xffL); int id3 = (int) (id & 0xffL); if ((id & 0xff000000L) == 0x02000000L) BIO_printf(STDout, " 0x%02X,0x%02X,0x%02X - ", id1, id2, id3); /* SSL2 cipher */ else if ((id & 0xff000000L) == 0x03000000L) BIO_printf(STDout, " 0x%02X,0x%02X - ", id2, id3); /* SSL3 cipher */ else BIO_printf(STDout, "0x%02X,0x%02X,0x%02X,0x%02X - ", id0, id1, id2, id3); /* whatever */ } BIO_puts(STDout, SSL_CIPHER_description(c, buf, sizeof buf)); } } ret = 0; if (0) { err: SSL_load_error_strings(); ERR_print_errors(bio_err); } end: if (ctx != NULL) SSL_CTX_free(ctx); if (ssl != NULL) SSL_free(ssl); if (STDout != NULL) BIO_free_all(STDout); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/apps/pkey.c0000644000175000017500000001525412360020706017022 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006 */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "apps.h" #include #include #include int pkey_main(int, char **); int pkey_main(int argc, char **argv) { ENGINE *e = NULL; char **args, *infile = NULL, *outfile = NULL; char *passargin = NULL, *passargout = NULL; BIO *in = NULL, *out = NULL; const EVP_CIPHER *cipher = NULL; int informat, outformat; int pubin = 0, pubout = 0, pubtext = 0, text = 0, noout = 0; EVP_PKEY *pkey = NULL; char *passin = NULL, *passout = NULL; int badarg = 0; #ifndef OPENSSL_NO_ENGINE char *engine = NULL; #endif int ret = 1; if (!load_config(bio_err, NULL)) goto end; informat = FORMAT_PEM; outformat = FORMAT_PEM; ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); args = argv + 1; while (!badarg && *args && *args[0] == '-') { if (!strcmp(*args, "-inform")) { if (args[1]) { args++; informat = str2fmt(*args); } else badarg = 1; } else if (!strcmp(*args, "-outform")) { if (args[1]) { args++; outformat = str2fmt(*args); } else badarg = 1; } else if (!strcmp(*args, "-passin")) { if (!args[1]) goto bad; passargin = *(++args); } else if (!strcmp(*args, "-passout")) { if (!args[1]) goto bad; passargout = *(++args); } #ifndef OPENSSL_NO_ENGINE else if (strcmp(*args, "-engine") == 0) { if (!args[1]) goto bad; engine = *(++args); } #endif else if (!strcmp(*args, "-in")) { if (args[1]) { args++; infile = *args; } else badarg = 1; } else if (!strcmp(*args, "-out")) { if (args[1]) { args++; outfile = *args; } else badarg = 1; } else if (strcmp(*args, "-pubin") == 0) { pubin = 1; pubout = 1; pubtext = 1; } else if (strcmp(*args, "-pubout") == 0) pubout = 1; else if (strcmp(*args, "-text_pub") == 0) { pubtext = 1; text = 1; } else if (strcmp(*args, "-text") == 0) text = 1; else if (strcmp(*args, "-noout") == 0) noout = 1; else { cipher = EVP_get_cipherbyname(*args + 1); if (!cipher) { BIO_printf(bio_err, "Unknown cipher %s\n", *args + 1); badarg = 1; } } args++; } if (badarg) { bad: BIO_printf(bio_err, "Usage pkey [options]\n"); BIO_printf(bio_err, "where options are\n"); BIO_printf(bio_err, "-in file input file\n"); BIO_printf(bio_err, "-inform X input format (DER or PEM)\n"); BIO_printf(bio_err, "-passin arg input file pass phrase source\n"); BIO_printf(bio_err, "-outform X output format (DER or PEM)\n"); BIO_printf(bio_err, "-out file output file\n"); BIO_printf(bio_err, "-passout arg output file pass phrase source\n"); #ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err, "-engine e use engine e, possibly a hardware device.\n"); #endif return 1; } #ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); #endif if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) { BIO_printf(bio_err, "Error getting passwords\n"); goto end; } if (outfile) { if (!(out = BIO_new_file(outfile, "wb"))) { BIO_printf(bio_err, "Can't open output file %s\n", outfile); goto end; } } else { out = BIO_new_fp(stdout, BIO_NOCLOSE); } if (pubin) pkey = load_pubkey(bio_err, infile, informat, 1, passin, e, "Public Key"); else pkey = load_key(bio_err, infile, informat, 1, passin, e, "key"); if (!pkey) goto end; if (!noout) { if (outformat == FORMAT_PEM) { if (pubout) PEM_write_bio_PUBKEY(out, pkey); else PEM_write_bio_PrivateKey(out, pkey, cipher, NULL, 0, NULL, passout); } else if (outformat == FORMAT_ASN1) { if (pubout) i2d_PUBKEY_bio(out, pkey); else i2d_PrivateKey_bio(out, pkey); } else { BIO_printf(bio_err, "Bad format specified for key\n"); goto end; } } if (text) { if (pubtext) EVP_PKEY_print_public(out, pkey, 0, NULL); else EVP_PKEY_print_private(out, pkey, 0, NULL); } ret = 0; end: EVP_PKEY_free(pkey); BIO_free_all(out); BIO_free(in); free(passin); free(passout); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/apps/spkac.c0000644000175000017500000001761212360020706017153 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. Based on an original idea by Massimiliano Pala * (madwolf@openca.org). */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include "apps.h" #include #include #include #include #include #include #include /* -in arg - input file - default stdin * -out arg - output file - default stdout */ int spkac_main(int, char **); int spkac_main(int argc, char **argv) { ENGINE *e = NULL; int i, badops = 0, ret = 1; BIO *in = NULL, *out = NULL; int verify = 0, noout = 0, pubkey = 0; char *infile = NULL, *outfile = NULL, *prog; char *passargin = NULL, *passin = NULL; const char *spkac = "SPKAC", *spksect = "default"; char *spkstr = NULL; char *challenge = NULL, *keyfile = NULL; CONF *conf = NULL; NETSCAPE_SPKI *spki = NULL; EVP_PKEY *pkey = NULL; #ifndef OPENSSL_NO_ENGINE char *engine = NULL; #endif if (!load_config(bio_err, NULL)) goto end; prog = argv[0]; argc--; argv++; while (argc >= 1) { if (strcmp(*argv, "-in") == 0) { if (--argc < 1) goto bad; infile = *(++argv); } else if (strcmp(*argv, "-out") == 0) { if (--argc < 1) goto bad; outfile = *(++argv); } else if (strcmp(*argv, "-passin") == 0) { if (--argc < 1) goto bad; passargin = *(++argv); } else if (strcmp(*argv, "-key") == 0) { if (--argc < 1) goto bad; keyfile = *(++argv); } else if (strcmp(*argv, "-challenge") == 0) { if (--argc < 1) goto bad; challenge = *(++argv); } else if (strcmp(*argv, "-spkac") == 0) { if (--argc < 1) goto bad; spkac = *(++argv); } else if (strcmp(*argv, "-spksect") == 0) { if (--argc < 1) goto bad; spksect = *(++argv); } #ifndef OPENSSL_NO_ENGINE else if (strcmp(*argv, "-engine") == 0) { if (--argc < 1) goto bad; engine = *(++argv); } #endif else if (strcmp(*argv, "-noout") == 0) noout = 1; else if (strcmp(*argv, "-pubkey") == 0) pubkey = 1; else if (strcmp(*argv, "-verify") == 0) verify = 1; else badops = 1; argc--; argv++; } if (badops) { bad: BIO_printf(bio_err, "%s [options]\n", prog); BIO_printf(bio_err, "where options are\n"); BIO_printf(bio_err, " -in arg input file\n"); BIO_printf(bio_err, " -out arg output file\n"); BIO_printf(bio_err, " -key arg create SPKAC using private key\n"); BIO_printf(bio_err, " -passin arg input file pass phrase source\n"); BIO_printf(bio_err, " -challenge arg challenge string\n"); BIO_printf(bio_err, " -spkac arg alternative SPKAC name\n"); BIO_printf(bio_err, " -noout don't print SPKAC\n"); BIO_printf(bio_err, " -pubkey output public key\n"); BIO_printf(bio_err, " -verify verify SPKAC signature\n"); #ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err, " -engine e use engine e, possibly a hardware device.\n"); #endif goto end; } ERR_load_crypto_strings(); if (!app_passwd(bio_err, passargin, NULL, &passin, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } #ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); #endif if (keyfile) { pkey = load_key(bio_err, strcmp(keyfile, "-") ? keyfile : NULL, FORMAT_PEM, 1, passin, e, "private key"); if (!pkey) { goto end; } spki = NETSCAPE_SPKI_new(); if (challenge) ASN1_STRING_set(spki->spkac->challenge, challenge, (int) strlen(challenge)); NETSCAPE_SPKI_set_pubkey(spki, pkey); NETSCAPE_SPKI_sign(spki, pkey, EVP_md5()); spkstr = NETSCAPE_SPKI_b64_encode(spki); if (outfile) out = BIO_new_file(outfile, "w"); else { out = BIO_new_fp(stdout, BIO_NOCLOSE); } if (!out) { BIO_printf(bio_err, "Error opening output file\n"); ERR_print_errors(bio_err); goto end; } BIO_printf(out, "SPKAC=%s\n", spkstr); free(spkstr); ret = 0; goto end; } if (infile) in = BIO_new_file(infile, "r"); else in = BIO_new_fp(stdin, BIO_NOCLOSE); if (!in) { BIO_printf(bio_err, "Error opening input file\n"); ERR_print_errors(bio_err); goto end; } conf = NCONF_new(NULL); i = NCONF_load_bio(conf, in, NULL); if (!i) { BIO_printf(bio_err, "Error parsing config file\n"); ERR_print_errors(bio_err); goto end; } spkstr = NCONF_get_string(conf, spksect, spkac); if (!spkstr) { BIO_printf(bio_err, "Can't find SPKAC called \"%s\"\n", spkac); ERR_print_errors(bio_err); goto end; } spki = NETSCAPE_SPKI_b64_decode(spkstr, -1); if (!spki) { BIO_printf(bio_err, "Error loading SPKAC\n"); ERR_print_errors(bio_err); goto end; } if (outfile) out = BIO_new_file(outfile, "w"); else { out = BIO_new_fp(stdout, BIO_NOCLOSE); } if (!out) { BIO_printf(bio_err, "Error opening output file\n"); ERR_print_errors(bio_err); goto end; } if (!noout) NETSCAPE_SPKI_print(out, spki); pkey = NETSCAPE_SPKI_get_pubkey(spki); if (verify) { i = NETSCAPE_SPKI_verify(spki, pkey); if (i > 0) BIO_printf(bio_err, "Signature OK\n"); else { BIO_printf(bio_err, "Signature Failure\n"); ERR_print_errors(bio_err); goto end; } } if (pubkey) PEM_write_bio_PUBKEY(out, pkey); ret = 0; end: NCONF_free(conf); NETSCAPE_SPKI_free(spki); BIO_free(in); BIO_free_all(out); EVP_PKEY_free(pkey); free(passin); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/apps/pkeyparam.c0000644000175000017500000001207212360020706020036 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006 */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "apps.h" #include #include #include int pkeyparam_main(int, char **); int pkeyparam_main(int argc, char **argv) { char **args, *infile = NULL, *outfile = NULL; BIO *in = NULL, *out = NULL; int text = 0, noout = 0; EVP_PKEY *pkey = NULL; int badarg = 0; #ifndef OPENSSL_NO_ENGINE char *engine = NULL; #endif int ret = 1; if (!load_config(bio_err, NULL)) goto end; ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); args = argv + 1; while (!badarg && *args && *args[0] == '-') { if (!strcmp(*args, "-in")) { if (args[1]) { args++; infile = *args; } else badarg = 1; } else if (!strcmp(*args, "-out")) { if (args[1]) { args++; outfile = *args; } else badarg = 1; } #ifndef OPENSSL_NO_ENGINE else if (strcmp(*args, "-engine") == 0) { if (!args[1]) goto bad; engine = *(++args); } #endif else if (strcmp(*args, "-text") == 0) text = 1; else if (strcmp(*args, "-noout") == 0) noout = 1; args++; } if (badarg) { #ifndef OPENSSL_NO_ENGINE bad: #endif BIO_printf(bio_err, "Usage pkeyparam [options]\n"); BIO_printf(bio_err, "where options are\n"); BIO_printf(bio_err, "-in file input file\n"); BIO_printf(bio_err, "-out file output file\n"); BIO_printf(bio_err, "-text print parameters as text\n"); BIO_printf(bio_err, "-noout don't output encoded parameters\n"); #ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err, "-engine e use engine e, possibly a hardware device.\n"); #endif return 1; } #ifndef OPENSSL_NO_ENGINE setup_engine(bio_err, engine, 0); #endif if (infile) { if (!(in = BIO_new_file(infile, "r"))) { BIO_printf(bio_err, "Can't open input file %s\n", infile); goto end; } } else in = BIO_new_fp(stdin, BIO_NOCLOSE); if (outfile) { if (!(out = BIO_new_file(outfile, "w"))) { BIO_printf(bio_err, "Can't open output file %s\n", outfile); goto end; } } else { out = BIO_new_fp(stdout, BIO_NOCLOSE); } pkey = PEM_read_bio_Parameters(in, NULL); if (!pkey) { BIO_printf(bio_err, "Error reading parameters\n"); ERR_print_errors(bio_err); goto end; } if (!noout) PEM_write_bio_Parameters(out, pkey); if (text) EVP_PKEY_print_params(out, pkey, 0, NULL); ret = 0; end: EVP_PKEY_free(pkey); BIO_free_all(out); BIO_free(in); return ret; } deps/libressl-pnacl-sys-2.1.6/libressl/apps/ec.c0000644000175000017500000002406612360020706016442 0ustar /* $OpenBSD$ */ /* * Written by Nils Larsch for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #ifndef OPENSSL_NO_EC #include #include #include #include "apps.h" #include #include #include #include /* -inform arg - input format - default PEM (one of DER, NET or PEM) * -outform arg - output format - default PEM * -in arg - input file - default stdin * -out arg - output file - default stdout * -des - encrypt output if PEM format with DES in cbc mode * -text - print a text version * -param_out - print the elliptic curve parameters * -conv_form arg - specifies the point encoding form * -param_enc arg - specifies the parameter encoding */ int ec_main(int, char **); int ec_main(int argc, char **argv) { int ret = 1; EC_KEY *eckey = NULL; const EC_GROUP *group; int i, badops = 0; const EVP_CIPHER *enc = NULL; BIO *in = NULL, *out = NULL; int informat, outformat, text = 0, noout = 0; int pubin = 0, pubout = 0, param_out = 0; char *infile, *outfile, *prog, *engine; char *passargin = NULL, *passargout = NULL; char *passin = NULL, *passout = NULL; point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED; int new_form = 0; int asn1_flag = OPENSSL_EC_NAMED_CURVE; int new_asn1_flag = 0; if (!load_config(bio_err, NULL)) goto end; engine = NULL; infile = NULL; outfile = NULL; informat = FORMAT_PEM; outformat = FORMAT_PEM; prog = argv[0]; argc--; argv++; while (argc >= 1) { if (strcmp(*argv, "-inform") == 0) { if (--argc < 1) goto bad; informat = str2fmt(*(++argv)); } else if (strcmp(*argv, "-outform") == 0) { if (--argc < 1) goto bad; outformat = str2fmt(*(++argv)); } else if (strcmp(*argv, "-in") == 0) { if (--argc < 1) goto bad; infile = *(++argv); } else if (strcmp(*argv, "-out") == 0) { if (--argc < 1) goto bad; outfile = *(++argv); } else if (strcmp(*argv, "-passin") == 0) { if (--argc < 1) goto bad; passargin = *(++argv); } else if (strcmp(*argv, "-passout") == 0) { if (--argc < 1) goto bad; passargout = *(++argv); } else if (strcmp(*argv, "-engine") == 0) { if (--argc < 1) goto bad; engine = *(++argv); } else if (strcmp(*argv, "-noout") == 0) noout = 1; else if (strcmp(*argv, "-text") == 0) text = 1; else if (strcmp(*argv, "-conv_form") == 0) { if (--argc < 1) goto bad; ++argv; new_form = 1; if (strcmp(*argv, "compressed") == 0) form = POINT_CONVERSION_COMPRESSED; else if (strcmp(*argv, "uncompressed") == 0) form = POINT_CONVERSION_UNCOMPRESSED; else if (strcmp(*argv, "hybrid") == 0) form = POINT_CONVERSION_HYBRID; else goto bad; } else if (strcmp(*argv, "-param_enc") == 0) { if (--argc < 1) goto bad; ++argv; new_asn1_flag = 1; if (strcmp(*argv, "named_curve") == 0) asn1_flag = OPENSSL_EC_NAMED_CURVE; else if (strcmp(*argv, "explicit") == 0) asn1_flag = 0; else goto bad; } else if (strcmp(*argv, "-param_out") == 0) param_out = 1; else if (strcmp(*argv, "-pubin") == 0) pubin = 1; else if (strcmp(*argv, "-pubout") == 0) pubout = 1; else if ((enc = EVP_get_cipherbyname(&(argv[0][1]))) == NULL) { BIO_printf(bio_err, "unknown option %s\n", *argv); badops = 1; break; } argc--; argv++; } if (badops) { bad: BIO_printf(bio_err, "%s [options] outfile\n", prog); BIO_printf(bio_err, "where options are\n"); BIO_printf(bio_err, " -inform arg input format - " "DER or PEM\n"); BIO_printf(bio_err, " -outform arg output format - " "DER or PEM\n"); BIO_printf(bio_err, " -in arg input file\n"); BIO_printf(bio_err, " -passin arg input file pass " "phrase source\n"); BIO_printf(bio_err, " -out arg output file\n"); BIO_printf(bio_err, " -passout arg output file pass " "phrase source\n"); BIO_printf(bio_err, " -engine e use engine e, " "possibly a hardware device.\n"); BIO_printf(bio_err, " -des encrypt PEM output, " "instead of 'des' every other \n" " cipher " "supported by OpenSSL can be used\n"); BIO_printf(bio_err, " -text print the key\n"); BIO_printf(bio_err, " -noout don't print key out\n"); BIO_printf(bio_err, " -param_out print the elliptic " "curve parameters\n"); BIO_printf(bio_err, " -conv_form arg specifies the " "point conversion form \n"); BIO_printf(bio_err, " possible values:" " compressed\n"); BIO_printf(bio_err, " " " uncompressed (default)\n"); BIO_printf(bio_err, " " " hybrid\n"); BIO_printf(bio_err, " -param_enc arg specifies the way" " the ec parameters are encoded\n"); BIO_printf(bio_err, " in the asn1 der " "encoding\n"); BIO_printf(bio_err, " possible values:" " named_curve (default)\n"); BIO_printf(bio_err, " " "explicit\n"); goto end; } ERR_load_crypto_strings(); #ifndef OPENSSL_NO_ENGINE setup_engine(bio_err, engine, 0); #endif if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) { BIO_printf(bio_err, "Error getting passwords\n"); goto end; } in = BIO_new(BIO_s_file()); out = BIO_new(BIO_s_file()); if ((in == NULL) || (out == NULL)) { ERR_print_errors(bio_err); goto end; } if (infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { if (BIO_read_filename(in, infile) <= 0) { perror(infile); goto end; } } BIO_printf(bio_err, "read EC key\n"); if (informat == FORMAT_ASN1) { if (pubin) eckey = d2i_EC_PUBKEY_bio(in, NULL); else eckey = d2i_ECPrivateKey_bio(in, NULL); } else if (informat == FORMAT_PEM) { if (pubin) eckey = PEM_read_bio_EC_PUBKEY(in, NULL, NULL, NULL); else eckey = PEM_read_bio_ECPrivateKey(in, NULL, NULL, passin); } else { BIO_printf(bio_err, "bad input format specified for key\n"); goto end; } if (eckey == NULL) { BIO_printf(bio_err, "unable to load Key\n"); ERR_print_errors(bio_err); goto end; } if (outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { if (BIO_write_filename(out, outfile) <= 0) { perror(outfile); goto end; } } group = EC_KEY_get0_group(eckey); if (new_form) EC_KEY_set_conv_form(eckey, form); if (new_asn1_flag) EC_KEY_set_asn1_flag(eckey, asn1_flag); if (text) if (!EC_KEY_print(out, eckey, 0)) { perror(outfile); ERR_print_errors(bio_err); goto end; } if (noout) { ret = 0; goto end; } BIO_printf(bio_err, "writing EC key\n"); if (outformat == FORMAT_ASN1) { if (param_out) i = i2d_ECPKParameters_bio(out, group); else if (pubin || pubout) i = i2d_EC_PUBKEY_bio(out, eckey); else i = i2d_ECPrivateKey_bio(out, eckey); } else if (outformat == FORMAT_PEM) { if (param_out) i = PEM_write_bio_ECPKParameters(out, group); else if (pubin || pubout) i = PEM_write_bio_EC_PUBKEY(out, eckey); else i = PEM_write_bio_ECPrivateKey(out, eckey, enc, NULL, 0, NULL, passout); } else { BIO_printf(bio_err, "bad output format specified for " "outfile\n"); goto end; } if (!i) { BIO_printf(bio_err, "unable to write private key\n"); ERR_print_errors(bio_err); } else ret = 0; end: if (in) BIO_free(in); if (out) BIO_free_all(out); if (eckey) EC_KEY_free(eckey); free(passin); free(passout); return (ret); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/apps/openssl.c0000644000175000017500000004204312360020706017531 0ustar /* $OpenBSD: openssl.c,v 1.38 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include "apps.h" #include #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif #include "progs.h" #include "s_apps.h" static void openssl_startup(void); static void openssl_shutdown(void); /* The LHASH callbacks ("hash" & "cmp") have been replaced by functions with the * base prototypes (we cast each variable inside the function to the required * type of "FUNCTION*"). This removes the necessity for macro-generated wrapper * functions. */ static LHASH_OF(FUNCTION) *prog_init(void); static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[]); static void list_pkey(BIO * out); static void list_cipher(BIO * out); static void list_md(BIO * out); char *default_config_file = NULL; CONF *config = NULL; BIO *bio_err = NULL; static void lock_dbg_cb(int mode, int type, const char *file, int line) { static int modes[CRYPTO_NUM_LOCKS]; /* = {0, 0, ... } */ const char *errstr = NULL; int rw; rw = mode & (CRYPTO_READ | CRYPTO_WRITE); if (!((rw == CRYPTO_READ) || (rw == CRYPTO_WRITE))) { errstr = "invalid mode"; goto err; } if (type < 0 || type >= CRYPTO_NUM_LOCKS) { errstr = "type out of bounds"; goto err; } if (mode & CRYPTO_LOCK) { if (modes[type]) { errstr = "already locked"; /* * must not happen in a single-threaded program * (would deadlock) */ goto err; } modes[type] = rw; } else if (mode & CRYPTO_UNLOCK) { if (!modes[type]) { errstr = "not locked"; goto err; } if (modes[type] != rw) { errstr = (rw == CRYPTO_READ) ? "CRYPTO_r_unlock on write lock" : "CRYPTO_w_unlock on read lock"; } modes[type] = 0; } else { errstr = "invalid mode"; goto err; } err: if (errstr) { /* we cannot use bio_err here */ fprintf(stderr, "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n", errstr, mode, type, file, line); } } static void openssl_startup(void) { signal(SIGPIPE, SIG_IGN); CRYPTO_malloc_init(); ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); #ifndef OPENSSL_NO_ENGINE ENGINE_load_builtin_engines(); #endif setup_ui_method(); } static void openssl_shutdown(void) { CONF_modules_unload(1); destroy_ui_method(); OBJ_cleanup(); EVP_cleanup(); #ifndef OPENSSL_NO_ENGINE ENGINE_cleanup(); #endif CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); RAND_cleanup(); ERR_free_strings(); } int main(int argc, char **argv) { ARGS arg; #define PROG_NAME_SIZE 39 char pname[PROG_NAME_SIZE + 1]; FUNCTION f, *fp; const char *prompt; char buf[1024]; char *to_free = NULL; int n, i, ret = 0; char *p; LHASH_OF(FUNCTION) * prog = NULL; long errline; arg.data = NULL; arg.count = 0; bio_err = BIO_new_fp(stderr, BIO_NOCLOSE); if (bio_err == NULL) errx(1, "failed to initialise bio_err"); CRYPTO_set_locking_callback(lock_dbg_cb); openssl_startup(); /* Lets load up our environment a little */ p = getenv("OPENSSL_CONF"); if (p == NULL) p = getenv("SSLEAY_CONF"); if (p == NULL) { p = to_free = make_config_name(); if (p == NULL) { BIO_printf(bio_err, "error making config file name\n"); goto end; } } default_config_file = p; config = NCONF_new(NULL); i = NCONF_load(config, p, &errline); if (i == 0) { if (ERR_GET_REASON(ERR_peek_last_error()) == CONF_R_NO_SUCH_FILE) { BIO_printf(bio_err, "WARNING: can't open config file: %s\n", p); ERR_clear_error(); NCONF_free(config); config = NULL; } else { ERR_print_errors(bio_err); NCONF_free(config); exit(1); } } prog = prog_init(); /* first check the program name */ program_name(argv[0], pname, sizeof pname); f.name = pname; fp = lh_FUNCTION_retrieve(prog, &f); if (fp != NULL) { argv[0] = pname; ret = fp->func(argc, argv); goto end; } /* * ok, now check that there are not arguments, if there are, run with * them, shifting the ssleay off the front */ if (argc != 1) { argc--; argv++; ret = do_cmd(prog, argc, argv); if (ret < 0) ret = 0; goto end; } /* ok, lets enter the old 'OpenSSL>' mode */ for (;;) { ret = 0; p = buf; n = sizeof buf; i = 0; for (;;) { p[0] = '\0'; if (i++) prompt = ">"; else prompt = "OpenSSL> "; fputs(prompt, stdout); fflush(stdout); if (!fgets(p, n, stdin)) goto end; if (p[0] == '\0') goto end; i = strlen(p); if (i <= 1) break; if (p[i - 2] != '\\') break; i -= 2; p += i; n -= i; } if (!chopup_args(&arg, buf, &argc, &argv)) break; ret = do_cmd(prog, argc, argv); if (ret < 0) { ret = 0; goto end; } if (ret != 0) BIO_printf(bio_err, "error in %s\n", argv[0]); (void) BIO_flush(bio_err); } BIO_printf(bio_err, "bad exit\n"); ret = 1; end: free(to_free); if (config != NULL) { NCONF_free(config); config = NULL; } if (prog != NULL) lh_FUNCTION_free(prog); free(arg.data); openssl_shutdown(); if (bio_err != NULL) { BIO_free(bio_err); bio_err = NULL; } return (ret); } #define LIST_STANDARD_COMMANDS "list-standard-commands" #define LIST_MESSAGE_DIGEST_COMMANDS "list-message-digest-commands" #define LIST_MESSAGE_DIGEST_ALGORITHMS "list-message-digest-algorithms" #define LIST_CIPHER_COMMANDS "list-cipher-commands" #define LIST_CIPHER_ALGORITHMS "list-cipher-algorithms" #define LIST_PUBLIC_KEY_ALGORITHMS "list-public-key-algorithms" static int do_cmd(LHASH_OF(FUNCTION) * prog, int argc, char *argv[]) { FUNCTION f, *fp; int i, ret = 1, tp, nl; if ((argc <= 0) || (argv[0] == NULL)) { ret = 0; goto end; } f.name = argv[0]; fp = lh_FUNCTION_retrieve(prog, &f); if (fp == NULL) { if (EVP_get_digestbyname(argv[0])) { f.type = FUNC_TYPE_MD; f.func = dgst_main; fp = &f; } else if (EVP_get_cipherbyname(argv[0])) { f.type = FUNC_TYPE_CIPHER; f.func = enc_main; fp = &f; } } if (fp != NULL) { ret = fp->func(argc, argv); } else if ((strncmp(argv[0], "no-", 3)) == 0) { BIO *bio_stdout = BIO_new_fp(stdout, BIO_NOCLOSE); f.name = argv[0] + 3; ret = (lh_FUNCTION_retrieve(prog, &f) != NULL); if (!ret) BIO_printf(bio_stdout, "%s\n", argv[0]); else BIO_printf(bio_stdout, "%s\n", argv[0] + 3); BIO_free_all(bio_stdout); goto end; } else if ((strcmp(argv[0], "quit") == 0) || (strcmp(argv[0], "q") == 0) || (strcmp(argv[0], "exit") == 0) || (strcmp(argv[0], "bye") == 0)) { ret = -1; goto end; } else if ((strcmp(argv[0], LIST_STANDARD_COMMANDS) == 0) || (strcmp(argv[0], LIST_MESSAGE_DIGEST_COMMANDS) == 0) || (strcmp(argv[0], LIST_MESSAGE_DIGEST_ALGORITHMS) == 0) || (strcmp(argv[0], LIST_CIPHER_COMMANDS) == 0) || (strcmp(argv[0], LIST_CIPHER_ALGORITHMS) == 0) || (strcmp(argv[0], LIST_PUBLIC_KEY_ALGORITHMS) == 0)) { int list_type; BIO *bio_stdout; if (strcmp(argv[0], LIST_STANDARD_COMMANDS) == 0) list_type = FUNC_TYPE_GENERAL; else if (strcmp(argv[0], LIST_MESSAGE_DIGEST_COMMANDS) == 0) list_type = FUNC_TYPE_MD; else if (strcmp(argv[0], LIST_MESSAGE_DIGEST_ALGORITHMS) == 0) list_type = FUNC_TYPE_MD_ALG; else if (strcmp(argv[0], LIST_PUBLIC_KEY_ALGORITHMS) == 0) list_type = FUNC_TYPE_PKEY; else if (strcmp(argv[0], LIST_CIPHER_ALGORITHMS) == 0) list_type = FUNC_TYPE_CIPHER_ALG; else /* strcmp(argv[0],LIST_CIPHER_COMMANDS) == 0 */ list_type = FUNC_TYPE_CIPHER; bio_stdout = BIO_new_fp(stdout, BIO_NOCLOSE); if (!load_config(bio_err, NULL)) goto end; if (list_type == FUNC_TYPE_PKEY) list_pkey(bio_stdout); if (list_type == FUNC_TYPE_MD_ALG) list_md(bio_stdout); if (list_type == FUNC_TYPE_CIPHER_ALG) list_cipher(bio_stdout); else { for (fp = functions; fp->name != NULL; fp++) if (fp->type == list_type) BIO_printf(bio_stdout, "%s\n", fp->name); } BIO_free_all(bio_stdout); ret = 0; goto end; } else { BIO_printf(bio_err, "openssl:Error: '%s' is an invalid command.\n", argv[0]); BIO_printf(bio_err, "\nStandard commands"); i = 0; tp = 0; for (fp = functions; fp->name != NULL; fp++) { nl = 0; #ifdef OPENSSL_NO_CAMELLIA if (((i++) % 5) == 0) #else if (((i++) % 4) == 0) #endif { BIO_printf(bio_err, "\n"); nl = 1; } if (fp->type != tp) { tp = fp->type; if (!nl) BIO_printf(bio_err, "\n"); if (tp == FUNC_TYPE_MD) { i = 1; BIO_printf(bio_err, "\nMessage Digest commands (see the `dgst' command for more details)\n"); } else if (tp == FUNC_TYPE_CIPHER) { i = 1; BIO_printf(bio_err, "\nCipher commands (see the `enc' command for more details)\n"); } } #ifdef OPENSSL_NO_CAMELLIA BIO_printf(bio_err, "%-15s", fp->name); #else BIO_printf(bio_err, "%-18s", fp->name); #endif } BIO_printf(bio_err, "\n\n"); ret = 0; } end: return (ret); } static int SortFnByName(const void *_f1, const void *_f2) { const FUNCTION *f1 = _f1; const FUNCTION *f2 = _f2; if (f1->type != f2->type) return f1->type - f2->type; return strcmp(f1->name, f2->name); } static void list_pkey(BIO * out) { int i; for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) { const EVP_PKEY_ASN1_METHOD *ameth; int pkey_id, pkey_base_id, pkey_flags; const char *pinfo, *pem_str; ameth = EVP_PKEY_asn1_get0(i); EVP_PKEY_asn1_get0_info(&pkey_id, &pkey_base_id, &pkey_flags, &pinfo, &pem_str, ameth); if (pkey_flags & ASN1_PKEY_ALIAS) { BIO_printf(out, "Name: %s\n", OBJ_nid2ln(pkey_id)); BIO_printf(out, "\tType: Alias to %s\n", OBJ_nid2ln(pkey_base_id)); } else { BIO_printf(out, "Name: %s\n", pinfo); BIO_printf(out, "\tType: %s Algorithm\n", pkey_flags & ASN1_PKEY_DYNAMIC ? "External" : "Builtin"); BIO_printf(out, "\tOID: %s\n", OBJ_nid2ln(pkey_id)); if (pem_str == NULL) pem_str = "(none)"; BIO_printf(out, "\tPEM string: %s\n", pem_str); } } } static void list_cipher_fn(const EVP_CIPHER * c, const char *from, const char *to, void *arg) { if (c) BIO_printf(arg, "%s\n", EVP_CIPHER_name(c)); else { if (!from) from = ""; if (!to) to = ""; BIO_printf(arg, "%s => %s\n", from, to); } } static void list_cipher(BIO * out) { EVP_CIPHER_do_all_sorted(list_cipher_fn, out); } static void list_md_fn(const EVP_MD * m, const char *from, const char *to, void *arg) { if (m) BIO_printf(arg, "%s\n", EVP_MD_name(m)); else { if (!from) from = ""; if (!to) to = ""; BIO_printf(arg, "%s => %s\n", from, to); } } static void list_md(BIO * out) { EVP_MD_do_all_sorted(list_md_fn, out); } static int function_cmp(const FUNCTION * a, const FUNCTION * b) { return strncmp(a->name, b->name, 8); } static IMPLEMENT_LHASH_COMP_FN(function, FUNCTION) static unsigned long function_hash(const FUNCTION * a) { return lh_strhash(a->name); } static IMPLEMENT_LHASH_HASH_FN(function, FUNCTION) static LHASH_OF(FUNCTION) * prog_init(void) { LHASH_OF(FUNCTION) * ret; FUNCTION *f; size_t i; /* Purely so it looks nice when the user hits ? */ for (i = 0, f = functions; f->name != NULL; ++f, ++i) ; qsort(functions, i, sizeof *functions, SortFnByName); if ((ret = lh_FUNCTION_new()) == NULL) return (NULL); for (f = functions; f->name != NULL; f++) (void) lh_FUNCTION_insert(ret, f); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/apps/s_time.c0000644000175000017500000003627212360020706017335 0ustar /* $OpenBSD: s_time.c,v 1.31 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #define NO_SHUTDOWN /*----------------------------------------- s_time - SSL client connection timer program Written and donated by Larry Streepy -----------------------------------------*/ #include #include #include #include #include #include #include "apps.h" #include #include #include #include #include "s_apps.h" #define SSL_CONNECT_NAME "localhost:4433" /*#define TEST_CERT "client.pem" *//* no default cert. */ #define BUFSIZZ 1024*10 #define MYBUFSIZ 1024*8 #undef min #undef max #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) #define SECONDS 30 extern int verify_depth; extern int verify_error; static void s_time_usage(void); static int parseArgs(int argc, char **argv); static SSL *doConnection(SSL * scon); static void s_time_init(void); /*********************************************************************** * Static data declarations */ /* static char *port=PORT_STR;*/ static char *host = SSL_CONNECT_NAME; static char *t_cert_file = NULL; static char *t_key_file = NULL; static char *CApath = NULL; static char *CAfile = NULL; static char *tm_cipher = NULL; static int tm_verify = SSL_VERIFY_NONE; static int maxTime = SECONDS; static SSL_CTX *tm_ctx = NULL; static const SSL_METHOD *s_time_meth = NULL; static char *s_www_path = NULL; static long bytes_read = 0; static int st_bugs = 0; static int perform = 0; static int t_nbio = 0; static void s_time_init(void) { host = SSL_CONNECT_NAME; t_cert_file = NULL; t_key_file = NULL; CApath = NULL; CAfile = NULL; tm_cipher = NULL; tm_verify = SSL_VERIFY_NONE; maxTime = SECONDS; tm_ctx = NULL; s_time_meth = NULL; s_www_path = NULL; bytes_read = 0; st_bugs = 0; perform = 0; t_nbio = 0; } /*********************************************************************** * usage - display usage message */ static void s_time_usage(void) { static const char umsg[] = "\ -time arg - max number of seconds to collect data, default %d\n\ -verify arg - turn on peer certificate verification, arg == depth\n\ -cert arg - certificate file to use, PEM format assumed\n\ -key arg - RSA file to use, PEM format assumed, key is in cert file\n\ file if not specified by this option\n\ -CApath arg - PEM format directory of CA's\n\ -CAfile arg - PEM format file of CA's\n\ -cipher - preferred cipher to use, play with 'openssl ciphers'\n\n"; printf("usage: s_time \n\n"); printf("-connect host:port - host:port to connect to (default is %s)\n", SSL_CONNECT_NAME); printf("-nbio - Run with non-blocking IO\n"); printf("-ssl2 - Just use SSLv2\n"); printf("-ssl3 - Just use SSLv3\n"); printf("-bugs - Turn on SSL bug compatibility\n"); printf("-new - Just time new connections\n"); printf("-reuse - Just time connection reuse\n"); printf("-www page - Retrieve 'page' from the site\n"); printf(umsg, SECONDS); } /*********************************************************************** * parseArgs - Parse command line arguments and initialize data * * Returns 0 if ok, -1 on bad args */ static int parseArgs(int argc, char **argv) { int badop = 0; const char *errstr; verify_depth = 0; verify_error = X509_V_OK; argc--; argv++; while (argc >= 1) { if (strcmp(*argv, "-connect") == 0) { if (--argc < 1) goto bad; host = *(++argv); } #if 0 else if (strcmp(*argv, "-host") == 0) { if (--argc < 1) goto bad; host = *(++argv); } else if (strcmp(*argv, "-port") == 0) { if (--argc < 1) goto bad; port = *(++argv); } #endif else if (strcmp(*argv, "-reuse") == 0) perform = 2; else if (strcmp(*argv, "-new") == 0) perform = 1; else if (strcmp(*argv, "-verify") == 0) { const char *errstr; tm_verify = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE; if (--argc < 1) goto bad; verify_depth = strtonum(*(++argv), 0, INT_MAX, &errstr); if (errstr) goto bad; BIO_printf(bio_err, "verify depth is %d\n", verify_depth); } else if (strcmp(*argv, "-cert") == 0) { if (--argc < 1) goto bad; t_cert_file = *(++argv); } else if (strcmp(*argv, "-key") == 0) { if (--argc < 1) goto bad; t_key_file = *(++argv); } else if (strcmp(*argv, "-CApath") == 0) { if (--argc < 1) goto bad; CApath = *(++argv); } else if (strcmp(*argv, "-CAfile") == 0) { if (--argc < 1) goto bad; CAfile = *(++argv); } else if (strcmp(*argv, "-cipher") == 0) { if (--argc < 1) goto bad; tm_cipher = *(++argv); } else if (strcmp(*argv, "-nbio") == 0) { t_nbio = 1; } else if (strcmp(*argv, "-www") == 0) { if (--argc < 1) goto bad; s_www_path = *(++argv); if (strlen(s_www_path) > MYBUFSIZ - 100) { BIO_printf(bio_err, "-www option too long\n"); badop = 1; } } else if (strcmp(*argv, "-bugs") == 0) st_bugs = 1; else if (strcmp(*argv, "-ssl3") == 0) s_time_meth = SSLv3_client_method(); else if (strcmp(*argv, "-time") == 0) { if (--argc < 1) goto bad; maxTime = strtonum(*(++argv), 0, INT_MAX, &errstr); if (errstr) goto bad; } else { BIO_printf(bio_err, "unknown option %s\n", *argv); badop = 1; break; } argc--; argv++; } if (perform == 0) perform = 3; if (badop) { bad: s_time_usage(); return -1; } return 0; /* Valid args */ } /*********************************************************************** * TIME - time functions */ #define START 0 #define STOP 1 static double tm_Time_F(int s) { return app_tminterval(s, 1); } /*********************************************************************** * MAIN - main processing area for client * real name depends on MONOLITH */ int s_time_main(int, char **); int s_time_main(int argc, char **argv) { double totalTime = 0.0; int nConn = 0; SSL *scon = NULL; long finishtime = 0; int ret = 1, i; char buf[1024 * 8]; int ver; s_time_init(); s_time_meth = SSLv23_client_method(); /* parse the command line arguments */ if (parseArgs(argc, argv) < 0) goto end; OpenSSL_add_ssl_algorithms(); if ((tm_ctx = SSL_CTX_new(s_time_meth)) == NULL) return (1); SSL_CTX_set_quiet_shutdown(tm_ctx, 1); if (st_bugs) SSL_CTX_set_options(tm_ctx, SSL_OP_ALL); SSL_CTX_set_cipher_list(tm_ctx, tm_cipher); if (!set_cert_stuff(tm_ctx, t_cert_file, t_key_file)) goto end; SSL_load_error_strings(); if ((!SSL_CTX_load_verify_locations(tm_ctx, CAfile, CApath)) || (!SSL_CTX_set_default_verify_paths(tm_ctx))) { /* * BIO_printf(bio_err,"error setting default verify * locations\n"); */ ERR_print_errors(bio_err); /* goto end; */ } if (tm_cipher == NULL) tm_cipher = getenv("SSL_CIPHER"); if (tm_cipher == NULL) { fprintf(stderr, "No CIPHER specified\n"); } if (!(perform & 1)) goto next; printf("Collecting connection statistics for %d seconds\n", maxTime); /* Loop and time how long it takes to make connections */ bytes_read = 0; finishtime = (long) time(NULL) + maxTime; tm_Time_F(START); for (;;) { if (finishtime < (long) time(NULL)) break; if ((scon = doConnection(NULL)) == NULL) goto end; if (s_www_path != NULL) { int ret = snprintf(buf, sizeof buf, "GET %s HTTP/1.0\r\n\r\n", s_www_path); if (ret == -1 || ret >= sizeof buf) { fprintf(stderr, "URL too long\n"); goto end; } SSL_write(scon, buf, strlen(buf)); while ((i = SSL_read(scon, buf, sizeof(buf))) > 0) bytes_read += i; } #ifdef NO_SHUTDOWN SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN); #else SSL_shutdown(scon); #endif shutdown(SSL_get_fd(scon), SHUT_RDWR); close(SSL_get_fd(scon)); nConn += 1; if (SSL_session_reused(scon)) ver = 'r'; else { ver = SSL_version(scon); if (ver == TLS1_VERSION) ver = 't'; else if (ver == SSL3_VERSION) ver = '3'; else if (ver == SSL2_VERSION) ver = '2'; else ver = '*'; } fputc(ver, stdout); fflush(stdout); SSL_free(scon); scon = NULL; } totalTime += tm_Time_F(STOP); /* Add the time for this iteration */ i = (int) ((long) time(NULL) - finishtime + maxTime); printf("\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", nConn, totalTime, ((double) nConn / totalTime), bytes_read); printf("%d connections in %ld real seconds, %ld bytes read per connection\n", nConn, (long) time(NULL) - finishtime + maxTime, bytes_read / nConn); /* * Now loop and time connections using the same session id over and * over */ next: if (!(perform & 2)) goto end; printf("\n\nNow timing with session id reuse.\n"); /* Get an SSL object so we can reuse the session id */ if ((scon = doConnection(NULL)) == NULL) { fprintf(stderr, "Unable to get connection\n"); goto end; } if (s_www_path != NULL) { int ret = snprintf(buf, sizeof buf, "GET %s HTTP/1.0\r\n\r\n", s_www_path); if (ret == -1 || ret >= sizeof buf) { fprintf(stderr, "URL too long\n"); goto end; } SSL_write(scon, buf, strlen(buf)); while (SSL_read(scon, buf, sizeof(buf)) > 0); } #ifdef NO_SHUTDOWN SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN); #else SSL_shutdown(scon); #endif shutdown(SSL_get_fd(scon), SHUT_RDWR); close(SSL_get_fd(scon)); nConn = 0; totalTime = 0.0; finishtime = (long) time(NULL) + maxTime; printf("starting\n"); bytes_read = 0; tm_Time_F(START); for (;;) { if (finishtime < (long) time(NULL)) break; if ((doConnection(scon)) == NULL) goto end; if (s_www_path) { int ret = snprintf(buf, sizeof buf, "GET %s HTTP/1.0\r\n\r\n", s_www_path); if (ret == -1 || ret >= sizeof buf) { fprintf(stderr, "URL too long\n"); goto end; } SSL_write(scon, buf, strlen(buf)); while ((i = SSL_read(scon, buf, sizeof(buf))) > 0) bytes_read += i; } #ifdef NO_SHUTDOWN SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN); #else SSL_shutdown(scon); #endif shutdown(SSL_get_fd(scon), SHUT_RDWR); close(SSL_get_fd(scon)); nConn += 1; if (SSL_session_reused(scon)) ver = 'r'; else { ver = SSL_version(scon); if (ver == TLS1_VERSION) ver = 't'; else if (ver == SSL3_VERSION) ver = '3'; else if (ver == SSL2_VERSION) ver = '2'; else ver = '*'; } fputc(ver, stdout); fflush(stdout); } totalTime += tm_Time_F(STOP); /* Add the time for this iteration */ printf("\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", nConn, totalTime, ((double) nConn / totalTime), bytes_read); printf("%d connections in %ld real seconds, %ld bytes read per connection\n", nConn, (long) time(NULL) - finishtime + maxTime, bytes_read / nConn); ret = 0; end: if (scon != NULL) SSL_free(scon); if (tm_ctx != NULL) { SSL_CTX_free(tm_ctx); tm_ctx = NULL; } return (ret); } /*********************************************************************** * doConnection - make a connection * Args: * scon = earlier ssl connection for session id, or NULL * Returns: * SSL * = the connection pointer. */ static SSL * doConnection(SSL * scon) { BIO *conn; SSL *serverCon; int width, i; fd_set readfds; if ((conn = BIO_new(BIO_s_connect())) == NULL) return (NULL); /* BIO_set_conn_port(conn,port);*/ BIO_set_conn_hostname(conn, host); if (scon == NULL) serverCon = SSL_new(tm_ctx); else { serverCon = scon; SSL_set_connect_state(serverCon); } SSL_set_bio(serverCon, conn, conn); #if 0 if (scon != NULL) SSL_set_session(serverCon, SSL_get_session(scon)); #endif /* ok, lets connect */ for (;;) { i = SSL_connect(serverCon); if (BIO_sock_should_retry(i)) { BIO_printf(bio_err, "DELAY\n"); i = SSL_get_fd(serverCon); width = i + 1; FD_ZERO(&readfds); FD_SET(i, &readfds); select(width, &readfds, NULL, NULL, NULL); continue; } break; } if (i <= 0) { BIO_printf(bio_err, "ERROR\n"); if (verify_error != X509_V_OK) BIO_printf(bio_err, "verify error:%s\n", X509_verify_cert_error_string(verify_error)); else ERR_print_errors(bio_err); if (scon == NULL) SSL_free(serverCon); return NULL; } return serverCon; } deps/libressl-pnacl-sys-2.1.6/libressl/apps/ecparam.c0000644000175000017500000004465312360020706017467 0ustar /* $OpenBSD: ecparam.c,v 1.20 2014/06/12 15:49:27 deraadt Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ /* ==================================================================== * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * Portions of the attached software ("Contribution") are developed by * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. * * The Contribution is licensed pursuant to the OpenSSL open source * license provided above. * * The elliptic curve binary polynomial software is originally written by * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. * */ #include #ifndef OPENSSL_NO_EC #include #include #include #include #include "apps.h" #include #include #include #include #include #include /* -inform arg - input format - default PEM (DER or PEM) * -outform arg - output format - default PEM * -in arg - input file - default stdin * -out arg - output file - default stdout * -noout - do not print the ec parameter * -text - print the ec parameters in text form * -check - validate the ec parameters * -C - print a 'C' function creating the parameters * -name arg - use the ec parameters with 'short name' name * -list_curves - prints a list of all currently available curve 'short names' * -conv_form arg - specifies the point conversion form * - possible values: compressed * uncompressed (default) * hybrid * -param_enc arg - specifies the way the ec parameters are encoded * in the asn1 der encoding * possible values: named_curve (default) * explicit * -no_seed - if 'explicit' parameters are chosen do not use the seed * -genkey - generate ec key * -engine e - use engine e, possibly a hardware device */ static int ecparam_print_var(BIO *, BIGNUM *, const char *, int, unsigned char *); int ecparam_main(int, char **); int ecparam_main(int argc, char **argv) { EC_GROUP *group = NULL; point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED; int new_form = 0; int asn1_flag = OPENSSL_EC_NAMED_CURVE; int new_asn1_flag = 0; char *curve_name = NULL; int list_curves = 0, no_seed = 0, check = 0, badops = 0, text = 0, i, genkey = 0; char *infile = NULL, *outfile = NULL, *prog; BIO *in = NULL, *out = NULL; int informat, outformat, noout = 0, C = 0, ret = 1; char *engine = NULL; BIGNUM *ec_p = NULL, *ec_a = NULL, *ec_b = NULL, *ec_gen = NULL, *ec_order = NULL, *ec_cofactor = NULL; unsigned char *buffer = NULL; if (!load_config(bio_err, NULL)) goto end; informat = FORMAT_PEM; outformat = FORMAT_PEM; prog = argv[0]; argc--; argv++; while (argc >= 1) { if (strcmp(*argv, "-inform") == 0) { if (--argc < 1) goto bad; informat = str2fmt(*(++argv)); } else if (strcmp(*argv, "-outform") == 0) { if (--argc < 1) goto bad; outformat = str2fmt(*(++argv)); } else if (strcmp(*argv, "-in") == 0) { if (--argc < 1) goto bad; infile = *(++argv); } else if (strcmp(*argv, "-out") == 0) { if (--argc < 1) goto bad; outfile = *(++argv); } else if (strcmp(*argv, "-text") == 0) text = 1; else if (strcmp(*argv, "-C") == 0) C = 1; else if (strcmp(*argv, "-check") == 0) check = 1; else if (strcmp(*argv, "-name") == 0) { if (--argc < 1) goto bad; curve_name = *(++argv); } else if (strcmp(*argv, "-list_curves") == 0) list_curves = 1; else if (strcmp(*argv, "-conv_form") == 0) { if (--argc < 1) goto bad; ++argv; new_form = 1; if (strcmp(*argv, "compressed") == 0) form = POINT_CONVERSION_COMPRESSED; else if (strcmp(*argv, "uncompressed") == 0) form = POINT_CONVERSION_UNCOMPRESSED; else if (strcmp(*argv, "hybrid") == 0) form = POINT_CONVERSION_HYBRID; else goto bad; } else if (strcmp(*argv, "-param_enc") == 0) { if (--argc < 1) goto bad; ++argv; new_asn1_flag = 1; if (strcmp(*argv, "named_curve") == 0) asn1_flag = OPENSSL_EC_NAMED_CURVE; else if (strcmp(*argv, "explicit") == 0) asn1_flag = 0; else goto bad; } else if (strcmp(*argv, "-no_seed") == 0) no_seed = 1; else if (strcmp(*argv, "-noout") == 0) noout = 1; else if (strcmp(*argv, "-genkey") == 0) { genkey = 1; } else if (strcmp(*argv, "-engine") == 0) { if (--argc < 1) goto bad; engine = *(++argv); } else { BIO_printf(bio_err, "unknown option %s\n", *argv); badops = 1; break; } argc--; argv++; } if (badops) { bad: BIO_printf(bio_err, "%s [options] outfile\n", prog); BIO_printf(bio_err, "where options are\n"); BIO_printf(bio_err, " -inform arg input format - " "default PEM (DER or PEM)\n"); BIO_printf(bio_err, " -outform arg output format - " "default PEM\n"); BIO_printf(bio_err, " -in arg input file - " "default stdin\n"); BIO_printf(bio_err, " -out arg output file - " "default stdout\n"); BIO_printf(bio_err, " -noout do not print the " "ec parameter\n"); BIO_printf(bio_err, " -text print the ec " "parameters in text form\n"); BIO_printf(bio_err, " -check validate the ec " "parameters\n"); BIO_printf(bio_err, " -C print a 'C' " "function creating the parameters\n"); BIO_printf(bio_err, " -name arg use the " "ec parameters with 'short name' name\n"); BIO_printf(bio_err, " -list_curves prints a list of " "all currently available curve 'short names'\n"); BIO_printf(bio_err, " -conv_form arg specifies the " "point conversion form \n"); BIO_printf(bio_err, " possible values:" " compressed\n"); BIO_printf(bio_err, " " " uncompressed (default)\n"); BIO_printf(bio_err, " " " hybrid\n"); BIO_printf(bio_err, " -param_enc arg specifies the way" " the ec parameters are encoded\n"); BIO_printf(bio_err, " in the asn1 der " "encoding\n"); BIO_printf(bio_err, " possible values:" " named_curve (default)\n"); BIO_printf(bio_err, " " " explicit\n"); BIO_printf(bio_err, " -no_seed if 'explicit'" " parameters are chosen do not" " use the seed\n"); BIO_printf(bio_err, " -genkey generate ec" " key\n"); BIO_printf(bio_err, " -engine e use engine e, " "possibly a hardware device\n"); goto end; } ERR_load_crypto_strings(); in = BIO_new(BIO_s_file()); out = BIO_new(BIO_s_file()); if ((in == NULL) || (out == NULL)) { ERR_print_errors(bio_err); goto end; } if (infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { if (BIO_read_filename(in, infile) <= 0) { perror(infile); goto end; } } if (outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { if (BIO_write_filename(out, outfile) <= 0) { perror(outfile); goto end; } } #ifndef OPENSSL_NO_ENGINE setup_engine(bio_err, engine, 0); #endif if (list_curves) { EC_builtin_curve *curves = NULL; size_t crv_len = 0; size_t n = 0; crv_len = EC_get_builtin_curves(NULL, 0); curves = reallocarray(NULL, crv_len, sizeof(EC_builtin_curve)); if (curves == NULL) goto end; if (!EC_get_builtin_curves(curves, crv_len)) { free(curves); goto end; } for (n = 0; n < crv_len; n++) { const char *comment; const char *sname; comment = curves[n].comment; sname = OBJ_nid2sn(curves[n].nid); if (comment == NULL) comment = "CURVE DESCRIPTION NOT AVAILABLE"; if (sname == NULL) sname = ""; BIO_printf(out, " %-10s: ", sname); BIO_printf(out, "%s\n", comment); } free(curves); ret = 0; goto end; } if (curve_name != NULL) { int nid; /* * workaround for the SECG curve names secp192r1 and * secp256r1 (which are the same as the curves prime192v1 and * prime256v1 defined in X9.62) */ if (!strcmp(curve_name, "secp192r1")) { BIO_printf(bio_err, "using curve name prime192v1 " "instead of secp192r1\n"); nid = NID_X9_62_prime192v1; } else if (!strcmp(curve_name, "secp256r1")) { BIO_printf(bio_err, "using curve name prime256v1 " "instead of secp256r1\n"); nid = NID_X9_62_prime256v1; } else nid = OBJ_sn2nid(curve_name); if (nid == 0) { BIO_printf(bio_err, "unknown curve name (%s)\n", curve_name); goto end; } group = EC_GROUP_new_by_curve_name(nid); if (group == NULL) { BIO_printf(bio_err, "unable to create curve (%s)\n", curve_name); goto end; } EC_GROUP_set_asn1_flag(group, asn1_flag); EC_GROUP_set_point_conversion_form(group, form); } else if (informat == FORMAT_ASN1) { group = d2i_ECPKParameters_bio(in, NULL); } else if (informat == FORMAT_PEM) { group = PEM_read_bio_ECPKParameters(in, NULL, NULL, NULL); } else { BIO_printf(bio_err, "bad input format specified\n"); goto end; } if (group == NULL) { BIO_printf(bio_err, "unable to load elliptic curve parameters\n"); ERR_print_errors(bio_err); goto end; } if (new_form) EC_GROUP_set_point_conversion_form(group, form); if (new_asn1_flag) EC_GROUP_set_asn1_flag(group, asn1_flag); if (no_seed) { EC_GROUP_set_seed(group, NULL, 0); } if (text) { if (!ECPKParameters_print(out, group, 0)) goto end; } if (check) { if (group == NULL) BIO_printf(bio_err, "no elliptic curve parameters\n"); BIO_printf(bio_err, "checking elliptic curve parameters: "); if (!EC_GROUP_check(group, NULL)) { BIO_printf(bio_err, "failed\n"); ERR_print_errors(bio_err); } else BIO_printf(bio_err, "ok\n"); } if (C) { size_t buf_len = 0, tmp_len = 0; const EC_POINT *point; int is_prime, len = 0; const EC_METHOD *meth = EC_GROUP_method_of(group); if ((ec_p = BN_new()) == NULL || (ec_a = BN_new()) == NULL || (ec_b = BN_new()) == NULL || (ec_gen = BN_new()) == NULL || (ec_order = BN_new()) == NULL || (ec_cofactor = BN_new()) == NULL) { perror("malloc"); goto end; } is_prime = (EC_METHOD_get_field_type(meth) == NID_X9_62_prime_field); if (is_prime) { if (!EC_GROUP_get_curve_GFp(group, ec_p, ec_a, ec_b, NULL)) goto end; } else { /* TODO */ goto end; } if ((point = EC_GROUP_get0_generator(group)) == NULL) goto end; if (!EC_POINT_point2bn(group, point, EC_GROUP_get_point_conversion_form(group), ec_gen, NULL)) goto end; if (!EC_GROUP_get_order(group, ec_order, NULL)) goto end; if (!EC_GROUP_get_cofactor(group, ec_cofactor, NULL)) goto end; if (!ec_p || !ec_a || !ec_b || !ec_gen || !ec_order || !ec_cofactor) goto end; len = BN_num_bits(ec_order); if ((tmp_len = (size_t) BN_num_bytes(ec_p)) > buf_len) buf_len = tmp_len; if ((tmp_len = (size_t) BN_num_bytes(ec_a)) > buf_len) buf_len = tmp_len; if ((tmp_len = (size_t) BN_num_bytes(ec_b)) > buf_len) buf_len = tmp_len; if ((tmp_len = (size_t) BN_num_bytes(ec_gen)) > buf_len) buf_len = tmp_len; if ((tmp_len = (size_t) BN_num_bytes(ec_order)) > buf_len) buf_len = tmp_len; if ((tmp_len = (size_t) BN_num_bytes(ec_cofactor)) > buf_len) buf_len = tmp_len; buffer = malloc(buf_len); if (buffer == NULL) { perror("malloc"); goto end; } ecparam_print_var(out, ec_p, "ec_p", len, buffer); ecparam_print_var(out, ec_a, "ec_a", len, buffer); ecparam_print_var(out, ec_b, "ec_b", len, buffer); ecparam_print_var(out, ec_gen, "ec_gen", len, buffer); ecparam_print_var(out, ec_order, "ec_order", len, buffer); ecparam_print_var(out, ec_cofactor, "ec_cofactor", len, buffer); BIO_printf(out, "\n\n"); BIO_printf(out, "EC_GROUP *get_ec_group_%d(void)\n\t{\n", len); BIO_printf(out, "\tint ok=0;\n"); BIO_printf(out, "\tEC_GROUP *group = NULL;\n"); BIO_printf(out, "\tEC_POINT *point = NULL;\n"); BIO_printf(out, "\tBIGNUM *tmp_1 = NULL, *tmp_2 = NULL, " "*tmp_3 = NULL;\n\n"); BIO_printf(out, "\tif ((tmp_1 = BN_bin2bn(ec_p_%d, " "sizeof(ec_p_%d), NULL)) == NULL)\n\t\t" "goto err;\n", len, len); BIO_printf(out, "\tif ((tmp_2 = BN_bin2bn(ec_a_%d, " "sizeof(ec_a_%d), NULL)) == NULL)\n\t\t" "goto err;\n", len, len); BIO_printf(out, "\tif ((tmp_3 = BN_bin2bn(ec_b_%d, " "sizeof(ec_b_%d), NULL)) == NULL)\n\t\t" "goto err;\n", len, len); if (is_prime) { BIO_printf(out, "\tif ((group = EC_GROUP_new_curve_" "GFp(tmp_1, tmp_2, tmp_3, NULL)) == NULL)" "\n\t\tgoto err;\n\n"); } else { /* TODO */ goto end; } BIO_printf(out, "\t/* build generator */\n"); BIO_printf(out, "\tif ((tmp_1 = BN_bin2bn(ec_gen_%d, " "sizeof(ec_gen_%d), tmp_1)) == NULL)" "\n\t\tgoto err;\n", len, len); BIO_printf(out, "\tpoint = EC_POINT_bn2point(group, tmp_1, " "NULL, NULL);\n"); BIO_printf(out, "\tif (point == NULL)\n\t\tgoto err;\n"); BIO_printf(out, "\tif ((tmp_2 = BN_bin2bn(ec_order_%d, " "sizeof(ec_order_%d), tmp_2)) == NULL)" "\n\t\tgoto err;\n", len, len); BIO_printf(out, "\tif ((tmp_3 = BN_bin2bn(ec_cofactor_%d, " "sizeof(ec_cofactor_%d), tmp_3)) == NULL)" "\n\t\tgoto err;\n", len, len); BIO_printf(out, "\tif (!EC_GROUP_set_generator(group, point," " tmp_2, tmp_3))\n\t\tgoto err;\n"); BIO_printf(out, "\n\tok=1;\n"); BIO_printf(out, "err:\n"); BIO_printf(out, "\tif (tmp_1)\n\t\tBN_free(tmp_1);\n"); BIO_printf(out, "\tif (tmp_2)\n\t\tBN_free(tmp_2);\n"); BIO_printf(out, "\tif (tmp_3)\n\t\tBN_free(tmp_3);\n"); BIO_printf(out, "\tif (point)\n\t\tEC_POINT_free(point);\n"); BIO_printf(out, "\tif (!ok)\n"); BIO_printf(out, "\t\t{\n"); BIO_printf(out, "\t\tEC_GROUP_free(group);\n"); BIO_printf(out, "\t\tgroup = NULL;\n"); BIO_printf(out, "\t\t}\n"); BIO_printf(out, "\treturn(group);\n\t}\n"); } if (!noout) { if (outformat == FORMAT_ASN1) i = i2d_ECPKParameters_bio(out, group); else if (outformat == FORMAT_PEM) i = PEM_write_bio_ECPKParameters(out, group); else { BIO_printf(bio_err, "bad output format specified for" " outfile\n"); goto end; } if (!i) { BIO_printf(bio_err, "unable to write elliptic " "curve parameters\n"); ERR_print_errors(bio_err); goto end; } } if (genkey) { EC_KEY *eckey = EC_KEY_new(); if (eckey == NULL) goto end; if (EC_KEY_set_group(eckey, group) == 0) { EC_KEY_free(eckey); goto end; } if (!EC_KEY_generate_key(eckey)) { EC_KEY_free(eckey); goto end; } if (outformat == FORMAT_ASN1) i = i2d_ECPrivateKey_bio(out, eckey); else if (outformat == FORMAT_PEM) i = PEM_write_bio_ECPrivateKey(out, eckey, NULL, NULL, 0, NULL, NULL); else { BIO_printf(bio_err, "bad output format specified " "for outfile\n"); EC_KEY_free(eckey); goto end; } EC_KEY_free(eckey); } ret = 0; end: if (ec_p) BN_free(ec_p); if (ec_a) BN_free(ec_a); if (ec_b) BN_free(ec_b); if (ec_gen) BN_free(ec_gen); if (ec_order) BN_free(ec_order); if (ec_cofactor) BN_free(ec_cofactor); free(buffer); if (in != NULL) BIO_free(in); if (out != NULL) BIO_free_all(out); if (group != NULL) EC_GROUP_free(group); return (ret); } static int ecparam_print_var(BIO * out, BIGNUM * in, const char *var, int len, unsigned char *buffer) { BIO_printf(out, "static unsigned char %s_%d[] = {", var, len); if (BN_is_zero(in)) BIO_printf(out, "\n\t0x00"); else { int i, l; l = BN_bn2bin(in, buffer); for (i = 0; i < l - 1; i++) { if ((i % 12) == 0) BIO_printf(out, "\n\t"); BIO_printf(out, "0x%02X,", buffer[i]); } if ((i % 12) == 0) BIO_printf(out, "\n\t"); BIO_printf(out, "0x%02X", buffer[i]); } BIO_printf(out, "\n\t};\n\n"); return 1; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/apps/enc.c0000644000175000017500000004271412360020706016620 0ustar /* $OpenBSD: enc.c,v 1.35 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include "apps.h" #include #include #include #include #include #include #include #include int set_hex(char *in, unsigned char *out, int size); #define SIZE (512) #define BSIZE (8*1024) #define PROG enc_main static void show_ciphers(const OBJ_NAME * name, void *bio_) { BIO *bio = bio_; static int n; if (!islower((unsigned char) *name->name)) return; BIO_printf(bio, "-%-25s", name->name); if (++n == 3) { BIO_printf(bio, "\n"); n = 0; } else BIO_printf(bio, " "); } int enc_main(int, char **); int enc_main(int argc, char **argv) { static const char magic[] = "Salted__"; char mbuf[sizeof magic - 1]; char *strbuf = NULL; unsigned char *buff = NULL, *bufsize = NULL; int bsize = BSIZE, verbose = 0; int ret = 1, inl; int nopad = 0; unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH]; unsigned char salt[PKCS5_SALT_LEN]; char *str = NULL, *passarg = NULL, *pass = NULL; char *hkey = NULL, *hiv = NULL, *hsalt = NULL; char *md = NULL; int enc = 1, printkey = 0, i, base64 = 0; #ifdef ZLIB int do_zlib = 0; BIO *bzl = NULL; #endif int debug = 0, olb64 = 0, nosalt = 0; const EVP_CIPHER *cipher = NULL, *c; EVP_CIPHER_CTX *ctx = NULL; char *inf = NULL, *outf = NULL; BIO *in = NULL, *out = NULL, *b64 = NULL, *benc = NULL, *rbio = NULL, *wbio = NULL; #define PROG_NAME_SIZE 39 char pname[PROG_NAME_SIZE + 1]; #ifndef OPENSSL_NO_ENGINE char *engine = NULL; #endif const EVP_MD *dgst = NULL; if (!load_config(bio_err, NULL)) goto end; /* first check the program name */ program_name(argv[0], pname, sizeof pname); if (strcmp(pname, "base64") == 0) base64 = 1; #ifdef ZLIB if (strcmp(pname, "zlib") == 0) do_zlib = 1; #endif cipher = EVP_get_cipherbyname(pname); #ifdef ZLIB if (!do_zlib && !base64 && (cipher == NULL) && (strcmp(pname, "enc") != 0)) #else if (!base64 && (cipher == NULL) && (strcmp(pname, "enc") != 0)) #endif { BIO_printf(bio_err, "%s is an unknown cipher\n", pname); goto bad; } argc--; argv++; while (argc >= 1) { if (strcmp(*argv, "-e") == 0) enc = 1; else if (strcmp(*argv, "-in") == 0) { if (--argc < 1) goto bad; inf = *(++argv); } else if (strcmp(*argv, "-out") == 0) { if (--argc < 1) goto bad; outf = *(++argv); } else if (strcmp(*argv, "-pass") == 0) { if (--argc < 1) goto bad; passarg = *(++argv); } #ifndef OPENSSL_NO_ENGINE else if (strcmp(*argv, "-engine") == 0) { if (--argc < 1) goto bad; engine = *(++argv); } #endif else if (strcmp(*argv, "-d") == 0) enc = 0; else if (strcmp(*argv, "-p") == 0) printkey = 1; else if (strcmp(*argv, "-v") == 0) verbose = 1; else if (strcmp(*argv, "-nopad") == 0) nopad = 1; else if (strcmp(*argv, "-salt") == 0) nosalt = 0; else if (strcmp(*argv, "-nosalt") == 0) nosalt = 1; else if (strcmp(*argv, "-debug") == 0) debug = 1; else if (strcmp(*argv, "-P") == 0) printkey = 2; else if (strcmp(*argv, "-A") == 0) olb64 = 1; else if (strcmp(*argv, "-a") == 0) base64 = 1; else if (strcmp(*argv, "-base64") == 0) base64 = 1; #ifdef ZLIB else if (strcmp(*argv, "-z") == 0) do_zlib = 1; #endif else if (strcmp(*argv, "-bufsize") == 0) { if (--argc < 1) goto bad; bufsize = (unsigned char *) *(++argv); } else if (strcmp(*argv, "-k") == 0) { if (--argc < 1) goto bad; str = *(++argv); } else if (strcmp(*argv, "-kfile") == 0) { static char buf[128]; FILE *infile; char *file; if (--argc < 1) goto bad; file = *(++argv); infile = fopen(file, "r"); if (infile == NULL) { BIO_printf(bio_err, "unable to read key from '%s'\n", file); goto bad; } buf[0] = '\0'; if (!fgets(buf, sizeof buf, infile)) { BIO_printf(bio_err, "unable to read key from '%s'\n", file); fclose(infile); goto bad; } fclose(infile); i = strlen(buf); if ((i > 0) && ((buf[i - 1] == '\n') || (buf[i - 1] == '\r'))) buf[--i] = '\0'; if ((i > 0) && ((buf[i - 1] == '\n') || (buf[i - 1] == '\r'))) buf[--i] = '\0'; if (i < 1) { BIO_printf(bio_err, "zero length password\n"); goto bad; } str = buf; } else if (strcmp(*argv, "-K") == 0) { if (--argc < 1) goto bad; hkey = *(++argv); } else if (strcmp(*argv, "-S") == 0) { if (--argc < 1) goto bad; hsalt = *(++argv); } else if (strcmp(*argv, "-iv") == 0) { if (--argc < 1) goto bad; hiv = *(++argv); } else if (strcmp(*argv, "-md") == 0) { if (--argc < 1) goto bad; md = *(++argv); } else if ((argv[0][0] == '-') && ((c = EVP_get_cipherbyname(&(argv[0][1]))) != NULL)) { cipher = c; } else if (strcmp(*argv, "-none") == 0) cipher = NULL; else { BIO_printf(bio_err, "unknown option '%s'\n", *argv); bad: BIO_printf(bio_err, "options are\n"); BIO_printf(bio_err, "%-14s input file\n", "-in "); BIO_printf(bio_err, "%-14s output file\n", "-out "); BIO_printf(bio_err, "%-14s pass phrase source\n", "-pass "); BIO_printf(bio_err, "%-14s encrypt\n", "-e"); BIO_printf(bio_err, "%-14s decrypt\n", "-d"); BIO_printf(bio_err, "%-14s base64 encode/decode, depending on encryption flag\n", "-a/-base64"); BIO_printf(bio_err, "%-14s passphrase is the next argument\n", "-k"); BIO_printf(bio_err, "%-14s passphrase is the first line of the file argument\n", "-kfile"); BIO_printf(bio_err, "%-14s the next argument is the md to use to create a key\n", "-md"); BIO_printf(bio_err, "%-14s from a passphrase. One of md2, md5, sha or sha1\n", ""); BIO_printf(bio_err, "%-14s salt in hex is the next argument\n", "-S"); BIO_printf(bio_err, "%-14s key/iv in hex is the next argument\n", "-K/-iv"); BIO_printf(bio_err, "%-14s print the iv/key (then exit if -P)\n", "-[pP]"); BIO_printf(bio_err, "%-14s buffer size\n", "-bufsize "); BIO_printf(bio_err, "%-14s disable standard block padding\n", "-nopad"); #ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err, "%-14s use engine e, possibly a hardware device.\n", "-engine e"); #endif BIO_printf(bio_err, "Cipher Types\n"); OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH, show_ciphers, bio_err); BIO_printf(bio_err, "\n"); goto end; } argc--; argv++; } #ifndef OPENSSL_NO_ENGINE setup_engine(bio_err, engine, 0); #endif if (md && (dgst = EVP_get_digestbyname(md)) == NULL) { BIO_printf(bio_err, "%s is an unsupported message digest type\n", md); goto end; } if (dgst == NULL) { dgst = EVP_md5(); } if (bufsize != NULL) { unsigned long n; for (n = 0; *bufsize; bufsize++) { i = *bufsize; if ((i <= '9') && (i >= '0')) n = n * 10 + i - '0'; else if (i == 'k') { n *= 1024; bufsize++; break; } } if (*bufsize != '\0') { BIO_printf(bio_err, "invalid 'bufsize' specified.\n"); goto end; } /* It must be large enough for a base64 encoded line */ if (base64 && n < 80) n = 80; bsize = (int) n; if (verbose) BIO_printf(bio_err, "bufsize=%d\n", bsize); } strbuf = malloc(SIZE); buff = malloc(EVP_ENCODE_LENGTH(bsize)); if ((buff == NULL) || (strbuf == NULL)) { BIO_printf(bio_err, "malloc failure %ld\n", (long) EVP_ENCODE_LENGTH(bsize)); goto end; } in = BIO_new(BIO_s_file()); out = BIO_new(BIO_s_file()); if ((in == NULL) || (out == NULL)) { ERR_print_errors(bio_err); goto end; } if (debug) { BIO_set_callback(in, BIO_debug_callback); BIO_set_callback(out, BIO_debug_callback); BIO_set_callback_arg(in, (char *) bio_err); BIO_set_callback_arg(out, (char *) bio_err); } if (inf == NULL) { if (bufsize != NULL) setvbuf(stdin, (char *) NULL, _IONBF, 0); BIO_set_fp(in, stdin, BIO_NOCLOSE); } else { if (BIO_read_filename(in, inf) <= 0) { perror(inf); goto end; } } if (!str && passarg) { if (!app_passwd(bio_err, passarg, NULL, &pass, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } str = pass; } if ((str == NULL) && (cipher != NULL) && (hkey == NULL)) { for (;;) { char buf[200]; int ret; ret = snprintf(buf, sizeof buf, "enter %s %s password:", OBJ_nid2ln(EVP_CIPHER_nid(cipher)), (enc) ? "encryption" : "decryption"); if (ret == -1 || ret >= sizeof buf) { BIO_printf(bio_err, "Password prompt too long\n"); goto end; } strbuf[0] = '\0'; i = EVP_read_pw_string((char *) strbuf, SIZE, buf, enc); if (i == 0) { if (strbuf[0] == '\0') { ret = 1; goto end; } str = strbuf; break; } if (i < 0) { BIO_printf(bio_err, "bad password read\n"); goto end; } } } if (outf == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); if (bufsize != NULL) setvbuf(stdout, (char *) NULL, _IONBF, 0); } else { if (BIO_write_filename(out, outf) <= 0) { perror(outf); goto end; } } rbio = in; wbio = out; #ifdef ZLIB if (do_zlib) { if ((bzl = BIO_new(BIO_f_zlib())) == NULL) goto end; if (enc) wbio = BIO_push(bzl, wbio); else rbio = BIO_push(bzl, rbio); } #endif if (base64) { if ((b64 = BIO_new(BIO_f_base64())) == NULL) goto end; if (debug) { BIO_set_callback(b64, BIO_debug_callback); BIO_set_callback_arg(b64, (char *) bio_err); } if (olb64) BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); if (enc) wbio = BIO_push(b64, wbio); else rbio = BIO_push(b64, rbio); } if (cipher != NULL) { /* * Note that str is NULL if a key was passed on the command * line, so we get no salt in that case. Is this a bug? */ if (str != NULL) { /* * Salt handling: if encrypting generate a salt and * write to output BIO. If decrypting read salt from * input BIO. */ unsigned char *sptr; if (nosalt) sptr = NULL; else { if (enc) { if (hsalt) { if (!set_hex(hsalt, salt, sizeof salt)) { BIO_printf(bio_err, "invalid hex salt value\n"); goto end; } } else if (RAND_pseudo_bytes(salt, sizeof salt) < 0) goto end; /* * If -P option then don't bother * writing */ if ((printkey != 2) && (BIO_write(wbio, magic, sizeof magic - 1) != sizeof magic - 1 || BIO_write(wbio, (char *) salt, sizeof salt) != sizeof salt)) { BIO_printf(bio_err, "error writing output file\n"); goto end; } } else if (BIO_read(rbio, mbuf, sizeof mbuf) != sizeof mbuf || BIO_read(rbio, (unsigned char *) salt, sizeof salt) != sizeof salt) { BIO_printf(bio_err, "error reading input file\n"); goto end; } else if (memcmp(mbuf, magic, sizeof magic - 1)) { BIO_printf(bio_err, "bad magic number\n"); goto end; } sptr = salt; } EVP_BytesToKey(cipher, dgst, sptr, (unsigned char *) str, strlen(str), 1, key, iv); /* * zero the complete buffer or the string passed from * the command line bug picked up by Larry J. Hughes * Jr. */ if (str == strbuf) OPENSSL_cleanse(str, SIZE); else OPENSSL_cleanse(str, strlen(str)); } if ((hiv != NULL) && !set_hex(hiv, iv, sizeof iv)) { BIO_printf(bio_err, "invalid hex iv value\n"); goto end; } if ((hiv == NULL) && (str == NULL) && EVP_CIPHER_iv_length(cipher) != 0) { /* * No IV was explicitly set and no IV was generated * during EVP_BytesToKey. Hence the IV is undefined, * making correct decryption impossible. */ BIO_printf(bio_err, "iv undefined\n"); goto end; } if ((hkey != NULL) && !set_hex(hkey, key, sizeof key)) { BIO_printf(bio_err, "invalid hex key value\n"); goto end; } if ((benc = BIO_new(BIO_f_cipher())) == NULL) goto end; /* * Since we may be changing parameters work on the encryption * context rather than calling BIO_set_cipher(). */ BIO_get_cipher_ctx(benc, &ctx); if (!EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, enc)) { BIO_printf(bio_err, "Error setting cipher %s\n", EVP_CIPHER_name(cipher)); ERR_print_errors(bio_err); goto end; } if (nopad) EVP_CIPHER_CTX_set_padding(ctx, 0); if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, enc)) { BIO_printf(bio_err, "Error setting cipher %s\n", EVP_CIPHER_name(cipher)); ERR_print_errors(bio_err); goto end; } if (debug) { BIO_set_callback(benc, BIO_debug_callback); BIO_set_callback_arg(benc, (char *) bio_err); } if (printkey) { if (!nosalt) { printf("salt="); for (i = 0; i < (int) sizeof(salt); i++) printf("%02X", salt[i]); printf("\n"); } if (cipher->key_len > 0) { printf("key="); for (i = 0; i < cipher->key_len; i++) printf("%02X", key[i]); printf("\n"); } if (cipher->iv_len > 0) { printf("iv ="); for (i = 0; i < cipher->iv_len; i++) printf("%02X", iv[i]); printf("\n"); } if (printkey == 2) { ret = 0; goto end; } } } /* Only encrypt/decrypt as we write the file */ if (benc != NULL) wbio = BIO_push(benc, wbio); for (;;) { inl = BIO_read(rbio, (char *) buff, bsize); if (inl <= 0) break; if (BIO_write(wbio, (char *) buff, inl) != inl) { BIO_printf(bio_err, "error writing output file\n"); goto end; } } if (!BIO_flush(wbio)) { BIO_printf(bio_err, "bad decrypt\n"); goto end; } ret = 0; if (verbose) { BIO_printf(bio_err, "bytes read :%8ld\n", BIO_number_read(in)); BIO_printf(bio_err, "bytes written:%8ld\n", BIO_number_written(out)); } end: ERR_print_errors(bio_err); free(strbuf); free(buff); if (in != NULL) BIO_free(in); if (out != NULL) BIO_free_all(out); if (benc != NULL) BIO_free(benc); if (b64 != NULL) BIO_free(b64); #ifdef ZLIB if (bzl != NULL) BIO_free(bzl); #endif free(pass); return (ret); } int set_hex(char *in, unsigned char *out, int size) { int i, n; unsigned char j; n = strlen(in); if (n > (size * 2)) { BIO_printf(bio_err, "hex string is too long\n"); return (0); } memset(out, 0, size); for (i = 0; i < n; i++) { j = (unsigned char) *in; *(in++) = '\0'; if (j == 0) break; if ((j >= '0') && (j <= '9')) j -= '0'; else if ((j >= 'A') && (j <= 'F')) j = j - 'A' + 10; else if ((j >= 'a') && (j <= 'f')) j = j - 'a' + 10; else { BIO_printf(bio_err, "non-hex digit\n"); return (0); } if (i & 1) out[i / 2] |= j; else out[i / 2] = (j << 4); } return (1); } deps/libressl-pnacl-sys-2.1.6/libressl/apps/engine.c0000644000175000017500000003377012360020706017322 0ustar /* $OpenBSD$ */ /* Written by Richard Levitte for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 2000 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include "apps.h" #ifndef OPENSSL_NO_ENGINE #include #include #include static const char *engine_usage[] = { "usage: engine opts [engine ...]\n", " -v[v[v[v]]] - verbose mode, for each engine, list its 'control commands'\n", " -vv will additionally display each command's description\n", " -vvv will also add the input flags for each command\n", " -vvvv will also show internal input flags\n", " -c - for each engine, also list the capabilities\n", " -t[t] - for each engine, check that they are really available\n", " -tt will display error trace for unavailable engines\n", " -pre - runs command 'cmd' against the ENGINE before any attempts\n", " to load it (if -t is used)\n", " -post - runs command 'cmd' against the ENGINE after loading it\n", " (only used if -t is also provided)\n", " NB: -pre and -post will be applied to all ENGINEs supplied on the command\n", " line, or all supported ENGINEs if none are specified.\n", " Eg. '-pre \"SO_PATH:/lib/libdriver.so\"' calls command \"SO_PATH\" with\n", " argument \"/lib/libdriver.so\".\n", NULL }; static void identity(char *ptr) { return; } static int append_buf(char **buf, const char *s, int *size, int step) { int l = strlen(s); if (*buf == NULL) { *size = step; *buf = malloc(*size); if (*buf == NULL) return 0; **buf = '\0'; } if (**buf != '\0') l += 2; /* ", " */ if (strlen(*buf) + strlen(s) >= (unsigned int) *size) { *size += step; *buf = realloc(*buf, *size); } if (*buf == NULL) return 0; if (**buf != '\0') strlcat(*buf, ", ", *size); strlcat(*buf, s, *size); return 1; } static int util_flags(BIO * bio_out, unsigned int flags, const char *indent) { int started = 0, err = 0; /* Indent before displaying input flags */ BIO_printf(bio_out, "%s%s(input flags): ", indent, indent); if (flags == 0) { BIO_printf(bio_out, "\n"); return 1; } /* * If the object is internal, mark it in a way that shows instead of * having it part of all the other flags, even if it really is. */ if (flags & ENGINE_CMD_FLAG_INTERNAL) { BIO_printf(bio_out, "[Internal] "); } if (flags & ENGINE_CMD_FLAG_NUMERIC) { BIO_printf(bio_out, "NUMERIC"); started = 1; } /* * Now we check that no combinations of the mutually exclusive * NUMERIC, STRING, and NO_INPUT flags have been used. Future flags * that can be OR'd together with these would need to added after * these to preserve the testing logic. */ if (flags & ENGINE_CMD_FLAG_STRING) { if (started) { BIO_printf(bio_out, "|"); err = 1; } BIO_printf(bio_out, "STRING"); started = 1; } if (flags & ENGINE_CMD_FLAG_NO_INPUT) { if (started) { BIO_printf(bio_out, "|"); err = 1; } BIO_printf(bio_out, "NO_INPUT"); started = 1; } /* Check for unknown flags */ flags = flags & ~ENGINE_CMD_FLAG_NUMERIC & ~ENGINE_CMD_FLAG_STRING & ~ENGINE_CMD_FLAG_NO_INPUT & ~ENGINE_CMD_FLAG_INTERNAL; if (flags) { if (started) BIO_printf(bio_out, "|"); BIO_printf(bio_out, "<0x%04X>", flags); } if (err) BIO_printf(bio_out, " "); BIO_printf(bio_out, "\n"); return 1; } static int util_verbose(ENGINE * e, int verbose, BIO * bio_out, const char *indent) { static const int line_wrap = 78; int num; int ret = 0; char *name = NULL; char *desc = NULL; int flags; int xpos = 0; STACK_OF(OPENSSL_STRING) * cmds = NULL; if (!ENGINE_ctrl(e, ENGINE_CTRL_HAS_CTRL_FUNCTION, 0, NULL, NULL) || ((num = ENGINE_ctrl(e, ENGINE_CTRL_GET_FIRST_CMD_TYPE, 0, NULL, NULL)) <= 0)) { #if 0 BIO_printf(bio_out, "%s\n", indent); #endif return 1; } cmds = sk_OPENSSL_STRING_new_null(); if (!cmds) goto err; do { int len; /* Get the command input flags */ if ((flags = ENGINE_ctrl(e, ENGINE_CTRL_GET_CMD_FLAGS, num, NULL, NULL)) < 0) goto err; if (!(flags & ENGINE_CMD_FLAG_INTERNAL) || verbose >= 4) { /* Get the command name */ if ((len = ENGINE_ctrl(e, ENGINE_CTRL_GET_NAME_LEN_FROM_CMD, num, NULL, NULL)) <= 0) goto err; if ((name = malloc(len + 1)) == NULL) goto err; if (ENGINE_ctrl(e, ENGINE_CTRL_GET_NAME_FROM_CMD, num, name, NULL) <= 0) goto err; /* Get the command description */ if ((len = ENGINE_ctrl(e, ENGINE_CTRL_GET_DESC_LEN_FROM_CMD, num, NULL, NULL)) < 0) goto err; if (len > 0) { if ((desc = malloc(len + 1)) == NULL) goto err; if (ENGINE_ctrl(e, ENGINE_CTRL_GET_DESC_FROM_CMD, num, desc, NULL) <= 0) goto err; } /* Now decide on the output */ if (xpos == 0) /* Do an indent */ xpos = BIO_puts(bio_out, indent); else /* Otherwise prepend a ", " */ xpos += BIO_printf(bio_out, ", "); if (verbose == 1) { /* We're just listing names, comma-delimited */ if ((xpos > (int) strlen(indent)) && (xpos + (int) strlen(name) > line_wrap)) { BIO_printf(bio_out, "\n"); xpos = BIO_puts(bio_out, indent); } xpos += BIO_printf(bio_out, "%s", name); } else { /* We're listing names plus descriptions */ BIO_printf(bio_out, "%s: %s\n", name, (desc == NULL) ? "" : desc); /* ... and sometimes input flags */ if ((verbose >= 3) && !util_flags(bio_out, flags, indent)) goto err; xpos = 0; } } free(name); name = NULL; free(desc); desc = NULL; /* Move to the next command */ num = ENGINE_ctrl(e, ENGINE_CTRL_GET_NEXT_CMD_TYPE, num, NULL, NULL); } while (num > 0); if (xpos > 0) BIO_printf(bio_out, "\n"); ret = 1; err: if (cmds) sk_OPENSSL_STRING_pop_free(cmds, identity); free(name); free(desc); return ret; } static void util_do_cmds(ENGINE * e, STACK_OF(OPENSSL_STRING) * cmds, BIO * bio_out, const char *indent) { int loop, res, num = sk_OPENSSL_STRING_num(cmds); if (num < 0) { BIO_printf(bio_out, "[Error]: internal stack error\n"); return; } for (loop = 0; loop < num; loop++) { char buf[256]; const char *cmd, *arg; cmd = sk_OPENSSL_STRING_value(cmds, loop); res = 1; /* assume success */ /* Check if this command has no ":arg" */ if ((arg = strstr(cmd, ":")) == NULL) { if (!ENGINE_ctrl_cmd_string(e, cmd, NULL, 0)) res = 0; } else { if ((int) (arg - cmd) > 254) { BIO_printf(bio_out, "[Error]: command name too long\n"); return; } memcpy(buf, cmd, (int) (arg - cmd)); buf[arg - cmd] = '\0'; arg++; /* Move past the ":" */ /* Call the command with the argument */ if (!ENGINE_ctrl_cmd_string(e, buf, arg, 0)) res = 0; } if (res) BIO_printf(bio_out, "[Success]: %s\n", cmd); else { BIO_printf(bio_out, "[Failure]: %s\n", cmd); ERR_print_errors(bio_out); } } } int engine_main(int, char **); int engine_main(int argc, char **argv) { int ret = 1, i; const char **pp; int verbose = 0, list_cap = 0, test_avail = 0, test_avail_noise = 0; ENGINE *e; STACK_OF(OPENSSL_STRING) * engines = sk_OPENSSL_STRING_new_null(); STACK_OF(OPENSSL_STRING) * pre_cmds = sk_OPENSSL_STRING_new_null(); STACK_OF(OPENSSL_STRING) * post_cmds = sk_OPENSSL_STRING_new_null(); int badops = 1; BIO *bio_out = NULL; const char *indent = " "; SSL_load_error_strings(); if (!load_config(bio_err, NULL)) goto end; bio_out = BIO_new_fp(stdout, BIO_NOCLOSE); argc--; argv++; while (argc >= 1) { if (strncmp(*argv, "-v", 2) == 0) { if (strspn(*argv + 1, "v") < strlen(*argv + 1)) goto skip_arg_loop; if ((verbose = strlen(*argv + 1)) > 4) goto skip_arg_loop; } else if (strcmp(*argv, "-c") == 0) list_cap = 1; else if (strncmp(*argv, "-t", 2) == 0) { test_avail = 1; if (strspn(*argv + 1, "t") < strlen(*argv + 1)) goto skip_arg_loop; if ((test_avail_noise = strlen(*argv + 1) - 1) > 1) goto skip_arg_loop; } else if (strcmp(*argv, "-pre") == 0) { argc--; argv++; if (argc == 0) goto skip_arg_loop; sk_OPENSSL_STRING_push(pre_cmds, *argv); } else if (strcmp(*argv, "-post") == 0) { argc--; argv++; if (argc == 0) goto skip_arg_loop; sk_OPENSSL_STRING_push(post_cmds, *argv); } else if ((strncmp(*argv, "-h", 2) == 0) || (strcmp(*argv, "-?") == 0)) goto skip_arg_loop; else sk_OPENSSL_STRING_push(engines, *argv); argc--; argv++; } /* Looks like everything went OK */ badops = 0; skip_arg_loop: if (badops) { for (pp = engine_usage; (*pp != NULL); pp++) BIO_printf(bio_err, "%s", *pp); goto end; } if (sk_OPENSSL_STRING_num(engines) == 0) { for (e = ENGINE_get_first(); e != NULL; e = ENGINE_get_next(e)) { sk_OPENSSL_STRING_push(engines, (char *) ENGINE_get_id(e)); } } for (i = 0; i < sk_OPENSSL_STRING_num(engines); i++) { const char *id = sk_OPENSSL_STRING_value(engines, i); if ((e = ENGINE_by_id(id)) != NULL) { const char *name = ENGINE_get_name(e); /* Do "id" first, then "name". Easier to auto-parse. */ BIO_printf(bio_out, "(%s) %s\n", id, name); util_do_cmds(e, pre_cmds, bio_out, indent); if (strcmp(ENGINE_get_id(e), id) != 0) { BIO_printf(bio_out, "Loaded: (%s) %s\n", ENGINE_get_id(e), ENGINE_get_name(e)); } if (list_cap) { int cap_size = 256; char *cap_buf = NULL; int k, n; const int *nids; ENGINE_CIPHERS_PTR fn_c; ENGINE_DIGESTS_PTR fn_d; ENGINE_PKEY_METHS_PTR fn_pk; if (ENGINE_get_RSA(e) != NULL && !append_buf(&cap_buf, "RSA", &cap_size, 256)) goto end; if (ENGINE_get_DSA(e) != NULL && !append_buf(&cap_buf, "DSA", &cap_size, 256)) goto end; if (ENGINE_get_DH(e) != NULL && !append_buf(&cap_buf, "DH", &cap_size, 256)) goto end; if (ENGINE_get_RAND(e) != NULL && !append_buf(&cap_buf, "RAND", &cap_size, 256)) goto end; fn_c = ENGINE_get_ciphers(e); if (!fn_c) goto skip_ciphers; n = fn_c(e, NULL, &nids, 0); for (k = 0; k < n; ++k) if (!append_buf(&cap_buf, OBJ_nid2sn(nids[k]), &cap_size, 256)) goto end; skip_ciphers: fn_d = ENGINE_get_digests(e); if (!fn_d) goto skip_digests; n = fn_d(e, NULL, &nids, 0); for (k = 0; k < n; ++k) if (!append_buf(&cap_buf, OBJ_nid2sn(nids[k]), &cap_size, 256)) goto end; skip_digests: fn_pk = ENGINE_get_pkey_meths(e); if (!fn_pk) goto skip_pmeths; n = fn_pk(e, NULL, &nids, 0); for (k = 0; k < n; ++k) if (!append_buf(&cap_buf, OBJ_nid2sn(nids[k]), &cap_size, 256)) goto end; skip_pmeths: if (cap_buf && (*cap_buf != '\0')) BIO_printf(bio_out, " [%s]\n", cap_buf); free(cap_buf); } if (test_avail) { BIO_printf(bio_out, "%s", indent); if (ENGINE_init(e)) { BIO_printf(bio_out, "[ available ]\n"); util_do_cmds(e, post_cmds, bio_out, indent); ENGINE_finish(e); } else { BIO_printf(bio_out, "[ unavailable ]\n"); if (test_avail_noise) ERR_print_errors_fp(stdout); ERR_clear_error(); } } if ((verbose > 0) && !util_verbose(e, verbose, bio_out, indent)) goto end; ENGINE_free(e); } else ERR_print_errors(bio_err); } ret = 0; end: ERR_print_errors(bio_err); sk_OPENSSL_STRING_pop_free(engines, identity); sk_OPENSSL_STRING_pop_free(pre_cmds, identity); sk_OPENSSL_STRING_pop_free(post_cmds, identity); if (bio_out != NULL) BIO_free_all(bio_out); return (ret); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/apps/apps.h0000644000175000017500000002670512360020706017025 0ustar /* $OpenBSD: apps.h,v 1.34 2014/07/09 09:06:58 bcook Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #ifndef HEADER_APPS_H #define HEADER_APPS_H #include #include #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif #ifndef OPENSSL_NO_OCSP #include #endif extern CONF *config; extern char *default_config_file; extern BIO *bio_err; typedef struct args_st { char **data; int count; } ARGS; #define PW_MIN_LENGTH 4 typedef struct pw_cb_data { const void *password; const char *prompt_info; } PW_CB_DATA; int password_callback(char *buf, int bufsiz, int verify, void *cb_data); int setup_ui_method(void); void destroy_ui_method(void); int should_retry(int i); int args_from_file(char *file, int *argc, char **argv[]); int str2fmt(char *s); void program_name(char *in, char *out, int size); int chopup_args(ARGS *arg, char *buf, int *argc, char **argv[]); #ifdef HEADER_X509_H int dump_cert_text(BIO *out, X509 *x); void print_name(BIO *out, const char *title, X509_NAME *nm, unsigned long lflags); #endif int set_cert_ex(unsigned long *flags, const char *arg); int set_name_ex(unsigned long *flags, const char *arg); int set_ext_copy(int *copy_type, const char *arg); int copy_extensions(X509 *x, X509_REQ *req, int copy_type); int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2); int add_oid_section(BIO *err, CONF *conf); X509 *load_cert(BIO *err, const char *file, int format, const char *pass, ENGINE *e, const char *cert_descrip); EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin, const char *pass, ENGINE *e, const char *key_descrip); EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, int maybe_stdin, const char *pass, ENGINE *e, const char *key_descrip); STACK_OF(X509) *load_certs(BIO *err, const char *file, int format, const char *pass, ENGINE *e, const char *cert_descrip); STACK_OF(X509_CRL) *load_crls(BIO *err, const char *file, int format, const char *pass, ENGINE *e, const char *cert_descrip); X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath); #ifndef OPENSSL_NO_ENGINE ENGINE *setup_engine(BIO *err, const char *engine, int debug); #endif #ifndef OPENSSL_NO_OCSP OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req, char *host, char *path, char *port, int use_ssl, STACK_OF(CONF_VALUE) *headers, int req_timeout); #endif int load_config(BIO *err, CONF *cnf); char *make_config_name(void); /* Functions defined in ca.c and also used in ocsp.c */ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold, ASN1_GENERALIZEDTIME **pinvtm, const char *str); #define DB_type 0 #define DB_exp_date 1 #define DB_rev_date 2 #define DB_serial 3 /* index - unique */ #define DB_file 4 #define DB_name 5 /* index - unique when active and not disabled */ #define DB_NUMBER 6 #define DB_TYPE_REV 'R' #define DB_TYPE_EXP 'E' #define DB_TYPE_VAL 'V' typedef struct db_attr_st { int unique_subject; } DB_ATTR; typedef struct ca_db_st { DB_ATTR attributes; TXT_DB *db; } CA_DB; BIGNUM *load_serial(char *serialfile, int create, ASN1_INTEGER **retai); int save_serial(char *serialfile, char *suffix, BIGNUM *serial, ASN1_INTEGER **retai); int rotate_serial(char *serialfile, char *new_suffix, char *old_suffix); int rand_serial(BIGNUM *b, ASN1_INTEGER *ai); CA_DB *load_index(char *dbfile, DB_ATTR *dbattr); int index_index(CA_DB *db); int save_index(const char *dbfile, const char *suffix, CA_DB *db); int rotate_index(const char *dbfile, const char *new_suffix, const char *old_suffix); void free_index(CA_DB *db); #define index_name_cmp_noconst(a, b) \ index_name_cmp((const OPENSSL_CSTRING *)CHECKED_PTR_OF(OPENSSL_STRING, a), \ (const OPENSSL_CSTRING *)CHECKED_PTR_OF(OPENSSL_STRING, b)) int index_name_cmp(const OPENSSL_CSTRING *a, const OPENSSL_CSTRING *b); int parse_yesno(const char *str, int def); X509_NAME *parse_name(char *str, long chtype, int multirdn); int args_verify(char ***pargs, int *pargc, int *badarg, BIO *err, X509_VERIFY_PARAM **pm); void policies_print(BIO *out, X509_STORE_CTX *ctx); int bio_to_mem(unsigned char **out, int maxlen, BIO *in); int pkey_ctrl_string(EVP_PKEY_CTX *ctx, char *value); int init_gen_str(BIO *err, EVP_PKEY_CTX **pctx, const char *algname, ENGINE *e, int do_param); int do_X509_sign(BIO *err, X509 *x, EVP_PKEY *pkey, const EVP_MD *md, STACK_OF(OPENSSL_STRING) *sigopts); int do_X509_REQ_sign(BIO *err, X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md, STACK_OF(OPENSSL_STRING) *sigopts); int do_X509_CRL_sign(BIO *err, X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md, STACK_OF(OPENSSL_STRING) *sigopts); #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) unsigned char *next_protos_parse(unsigned short *outlen, const char *in); #endif /* !OPENSSL_NO_TLSEXT && !OPENSSL_NO_NEXTPROTONEG */ #define FORMAT_UNDEF 0 #define FORMAT_ASN1 1 #define FORMAT_TEXT 2 #define FORMAT_PEM 3 #define FORMAT_NETSCAPE 4 #define FORMAT_PKCS12 5 #define FORMAT_SMIME 6 #define FORMAT_ENGINE 7 #define FORMAT_IISSGC 8 /* XXX this stupid macro helps us to avoid * adding yet another param to load_*key() */ #define FORMAT_PEMRSA 9 /* PEM RSAPubicKey format */ #define FORMAT_ASN1RSA 10 /* DER RSAPubicKey format */ #define FORMAT_MSBLOB 11 /* MS Key blob format */ #define FORMAT_PVK 12 /* MS PVK file format */ #define EXT_COPY_NONE 0 #define EXT_COPY_ADD 1 #define EXT_COPY_ALL 2 #define NETSCAPE_CERT_HDR "certificate" #define APP_PASS_LEN 1024 #define SERIAL_RAND_BITS 64 int app_isdir(const char *); #define TM_START 0 #define TM_STOP 1 double app_tminterval (int stop, int usertime); #define OPENSSL_NO_SSL_INTERN #endif deps/libressl-pnacl-sys-2.1.6/libressl/apps/s_client.c0000644000175000017500000012713212360020706017651 0ustar /* $OpenBSD: s_client.c,v 1.65 2014/07/10 09:30:53 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2005 Nokia. All rights reserved. * * The portions of the attached software ("Contribution") is developed by * Nokia Corporation and is licensed pursuant to the OpenSSL open source * license. * * The Contribution, originally written by Mika Kousa and Pasi Eronen of * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites * support (see RFC 4279) to OpenSSL. * * No patent licenses or other rights except those expressly stated in * the OpenSSL open source license shall be deemed granted or received * expressly, by implication, estoppel, or otherwise. * * No assurances are provided by Nokia that the Contribution does not * infringe the patent or other intellectual property rights of any third * party or that the license provides you with all the necessary rights * to make use of the Contribution. * * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR * OTHERWISE. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "apps.h" #include #include #include #include #include #include #include #include "s_apps.h" #include "timeouts.h" /*#define SSL_HOST_NAME "www.netscape.com" */ /*#define SSL_HOST_NAME "193.118.187.102" */ #define SSL_HOST_NAME "localhost" /*#define TEST_CERT "client.pem" *//* no default cert. */ #define BUFSIZZ 1024*8 extern int verify_depth; extern int verify_error; extern int verify_return_error; static int c_nbio = 0; static int c_Pause = 0; static int c_debug = 0; #ifndef OPENSSL_NO_TLSEXT static int c_tlsextdebug = 0; static int c_status_req = 0; #endif static int c_msg = 0; static int c_showcerts = 0; static char *keymatexportlabel = NULL; static int keymatexportlen = 20; static void sc_usage(void); static void print_stuff(BIO * berr, SSL * con, int full); #ifndef OPENSSL_NO_TLSEXT static int ocsp_resp_cb(SSL * s, void *arg); #endif static BIO *bio_c_out = NULL; static int c_quiet = 0; static int c_ign_eof = 0; static void sc_usage(void) { BIO_printf(bio_err, "usage: s_client args\n"); BIO_printf(bio_err, "\n"); BIO_printf(bio_err, " -4 - Force IPv4\n"); BIO_printf(bio_err, " -6 - Force IPv6\n"); BIO_printf(bio_err, " -host host - use -connect instead\n"); BIO_printf(bio_err, " -port port - use -connect instead\n"); BIO_printf(bio_err, " -connect host:port - who to connect to (default is %s:%s)\n", SSL_HOST_NAME, PORT_STR); BIO_printf(bio_err, " -verify arg - turn on peer certificate verification\n"); BIO_printf(bio_err, " -cert arg - certificate file to use, PEM format assumed\n"); BIO_printf(bio_err, " -certform arg - certificate format (PEM or DER) PEM default\n"); BIO_printf(bio_err, " -key arg - Private key file to use, in cert file if\n"); BIO_printf(bio_err, " not specified but cert file is.\n"); BIO_printf(bio_err, " -keyform arg - key format (PEM or DER) PEM default\n"); BIO_printf(bio_err, " -pass arg - private key file pass phrase source\n"); BIO_printf(bio_err, " -CApath arg - PEM format directory of CA's\n"); BIO_printf(bio_err, " -CAfile arg - PEM format file of CA's\n"); BIO_printf(bio_err, " -reconnect - Drop and re-make the connection with the same Session-ID\n"); BIO_printf(bio_err, " -pause - sleep(1) after each read(2) and write(2) system call\n"); BIO_printf(bio_err, " -showcerts - show all certificates in the chain\n"); BIO_printf(bio_err, " -debug - extra output\n"); BIO_printf(bio_err, " -msg - Show protocol messages\n"); BIO_printf(bio_err, " -nbio_test - more ssl protocol testing\n"); BIO_printf(bio_err, " -state - print the 'ssl' states\n"); BIO_printf(bio_err, " -nbio - Run with non-blocking IO\n"); BIO_printf(bio_err, " -crlf - convert LF from terminal into CRLF\n"); BIO_printf(bio_err, " -quiet - no s_client output\n"); BIO_printf(bio_err, " -ign_eof - ignore input eof (default when -quiet)\n"); BIO_printf(bio_err, " -no_ign_eof - don't ignore input eof\n"); BIO_printf(bio_err, " -ssl3 - just use SSLv3\n"); BIO_printf(bio_err, " -tls1_2 - just use TLSv1.2\n"); BIO_printf(bio_err, " -tls1_1 - just use TLSv1.1\n"); BIO_printf(bio_err, " -tls1 - just use TLSv1\n"); BIO_printf(bio_err, " -dtls1 - just use DTLSv1\n"); BIO_printf(bio_err, " -mtu - set the link layer MTU\n"); BIO_printf(bio_err, " -no_tls1_2/-no_tls1_1/-no_tls1/-no_ssl3/-no_ssl2 - turn off that protocol\n"); BIO_printf(bio_err, " -bugs - Switch on all SSL implementation bug workarounds\n"); BIO_printf(bio_err, " -cipher - preferred cipher to use, use the 'openssl ciphers'\n"); BIO_printf(bio_err, " command to see what is available\n"); BIO_printf(bio_err, " -starttls prot - use the STARTTLS command before starting TLS\n"); BIO_printf(bio_err, " for those protocols that support it, where\n"); BIO_printf(bio_err, " 'prot' defines which one to assume. Currently,\n"); BIO_printf(bio_err, " only \"smtp\", \"lmtp\", \"pop3\", \"imap\", \"ftp\" and \"xmpp\"\n"); BIO_printf(bio_err, " are supported.\n"); #ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err, " -engine id - Initialise and use the specified engine\n"); #endif BIO_printf(bio_err, " -sess_out arg - file to write SSL session to\n"); BIO_printf(bio_err, " -sess_in arg - file to read SSL session from\n"); #ifndef OPENSSL_NO_TLSEXT BIO_printf(bio_err, " -servername host - Set TLS extension servername in ClientHello\n"); BIO_printf(bio_err, " -tlsextdebug - hex dump of all TLS extensions received\n"); BIO_printf(bio_err, " -status - request certificate status from server\n"); BIO_printf(bio_err, " -no_ticket - disable use of RFC4507bis session tickets\n"); #ifndef OPENSSL_NO_NEXTPROTONEG BIO_printf(bio_err, " -nextprotoneg arg - enable NPN extension, considering named protocols supported (comma-separated list)\n"); #endif #endif #ifndef OPENSSL_NO_SRTP BIO_printf(bio_err, " -use_srtp profiles - Offer SRTP key management with a colon-separated profile list\n"); #endif BIO_printf(bio_err, " -keymatexport label - Export keying material using label\n"); BIO_printf(bio_err, " -keymatexportlen len - Export len bytes of keying material (default 20)\n"); } #ifndef OPENSSL_NO_TLSEXT /* This is a context that we pass to callbacks */ typedef struct tlsextctx_st { BIO *biodebug; int ack; } tlsextctx; static int ssl_servername_cb(SSL * s, int *ad, void *arg) { tlsextctx *p = (tlsextctx *) arg; const char *hn = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name); if (SSL_get_servername_type(s) != -1) p->ack = !SSL_session_reused(s) && hn != NULL; else BIO_printf(bio_err, "Can't use SSL_get_servername\n"); return SSL_TLSEXT_ERR_OK; } #ifndef OPENSSL_NO_SRTP char *srtp_profiles = NULL; #endif #ifndef OPENSSL_NO_NEXTPROTONEG /* This the context that we pass to next_proto_cb */ typedef struct tlsextnextprotoctx_st { unsigned char *data; unsigned short len; int status; } tlsextnextprotoctx; static tlsextnextprotoctx next_proto; static int next_proto_cb(SSL * s, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg) { tlsextnextprotoctx *ctx = arg; if (!c_quiet) { /* We can assume that |in| is syntactically valid. */ unsigned i; BIO_printf(bio_c_out, "Protocols advertised by server: "); for (i = 0; i < inlen;) { if (i) BIO_write(bio_c_out, ", ", 2); BIO_write(bio_c_out, &in[i + 1], in[i]); i += in[i] + 1; } BIO_write(bio_c_out, "\n", 1); } ctx->status = SSL_select_next_proto(out, outlen, in, inlen, ctx->data, ctx->len); return SSL_TLSEXT_ERR_OK; } #endif /* ndef OPENSSL_NO_NEXTPROTONEG */ #endif enum { PROTO_OFF = 0, PROTO_SMTP, PROTO_LMTP, PROTO_POP3, PROTO_IMAP, PROTO_FTP, PROTO_XMPP }; int s_client_main(int, char **); int s_client_main(int argc, char **argv) { unsigned int off = 0, clr = 0; SSL *con = NULL; int s, k, width, state = 0, af = AF_UNSPEC; char *cbuf = NULL, *sbuf = NULL, *mbuf = NULL; int cbuf_len, cbuf_off; int sbuf_len, sbuf_off; fd_set readfds, writefds; char *port = PORT_STR; int full_log = 1; char *host = SSL_HOST_NAME; char *cert_file = NULL, *key_file = NULL; int cert_format = FORMAT_PEM, key_format = FORMAT_PEM; char *passarg = NULL, *pass = NULL; X509 *cert = NULL; EVP_PKEY *key = NULL; char *CApath = NULL, *CAfile = NULL, *cipher = NULL; int reconnect = 0, badop = 0, verify = SSL_VERIFY_NONE, bugs = 0; int crlf = 0; int write_tty, read_tty, write_ssl, read_ssl, tty_on, ssl_pending; SSL_CTX *ctx = NULL; int ret = 1, in_init = 1, i, nbio_test = 0; int starttls_proto = PROTO_OFF; int prexit = 0; X509_VERIFY_PARAM *vpm = NULL; int badarg = 0; const SSL_METHOD *meth = NULL; int socket_type = SOCK_STREAM; BIO *sbio; int mbuf_len = 0; struct timeval timeout, *timeoutp; const char *errstr = NULL; #ifndef OPENSSL_NO_ENGINE char *engine_id = NULL; char *ssl_client_engine_id = NULL; ENGINE *ssl_client_engine = NULL; #endif ENGINE *e = NULL; #ifndef OPENSSL_NO_TLSEXT char *servername = NULL; tlsextctx tlsextcbp = {NULL, 0}; #ifndef OPENSSL_NO_NEXTPROTONEG const char *next_proto_neg_in = NULL; #endif #endif char *sess_in = NULL; char *sess_out = NULL; struct sockaddr peer; int peerlen = sizeof(peer); int enable_timeouts = 0; long socket_mtu = 0; meth = SSLv23_client_method(); c_Pause = 0; c_quiet = 0; c_ign_eof = 0; c_debug = 0; c_msg = 0; c_showcerts = 0; if (!load_config(bio_err, NULL)) goto end; if (((cbuf = malloc(BUFSIZZ)) == NULL) || ((sbuf = malloc(BUFSIZZ)) == NULL) || ((mbuf = malloc(BUFSIZZ + 1)) == NULL)) { /* NUL byte */ BIO_printf(bio_err, "out of memory\n"); goto end; } verify_depth = 0; verify_error = X509_V_OK; c_nbio = 0; argc--; argv++; while (argc >= 1) { if (strcmp(*argv, "-host") == 0) { if (--argc < 1) goto bad; host = *(++argv); } else if (strcmp(*argv, "-port") == 0) { if (--argc < 1) goto bad; port = *(++argv); if (port == NULL || *port == '\0') goto bad; } else if (strcmp(*argv, "-connect") == 0) { if (--argc < 1) goto bad; if (!extract_host_port(*(++argv), &host, NULL, &port)) goto bad; } else if (strcmp(*argv, "-verify") == 0) { verify = SSL_VERIFY_PEER; if (--argc < 1) goto bad; verify_depth = strtonum(*(++argv), 0, INT_MAX, &errstr); if (errstr) goto bad; BIO_printf(bio_err, "verify depth is %d\n", verify_depth); } else if (strcmp(*argv, "-cert") == 0) { if (--argc < 1) goto bad; cert_file = *(++argv); } else if (strcmp(*argv, "-sess_out") == 0) { if (--argc < 1) goto bad; sess_out = *(++argv); } else if (strcmp(*argv, "-sess_in") == 0) { if (--argc < 1) goto bad; sess_in = *(++argv); } else if (strcmp(*argv, "-certform") == 0) { if (--argc < 1) goto bad; cert_format = str2fmt(*(++argv)); } else if (args_verify(&argv, &argc, &badarg, bio_err, &vpm)) { if (badarg) goto bad; continue; } else if (strcmp(*argv, "-verify_return_error") == 0) verify_return_error = 1; else if (strcmp(*argv, "-prexit") == 0) prexit = 1; else if (strcmp(*argv, "-crlf") == 0) crlf = 1; else if (strcmp(*argv, "-quiet") == 0) { c_quiet = 1; c_ign_eof = 1; } else if (strcmp(*argv, "-ign_eof") == 0) c_ign_eof = 1; else if (strcmp(*argv, "-no_ign_eof") == 0) c_ign_eof = 0; else if (strcmp(*argv, "-pause") == 0) c_Pause = 1; else if (strcmp(*argv, "-debug") == 0) c_debug = 1; #ifndef OPENSSL_NO_TLSEXT else if (strcmp(*argv, "-tlsextdebug") == 0) c_tlsextdebug = 1; else if (strcmp(*argv, "-status") == 0) c_status_req = 1; #endif else if (strcmp(*argv, "-msg") == 0) c_msg = 1; else if (strcmp(*argv, "-showcerts") == 0) c_showcerts = 1; else if (strcmp(*argv, "-nbio_test") == 0) nbio_test = 1; else if (strcmp(*argv, "-state") == 0) state = 1; else if (strcmp(*argv, "-ssl3") == 0) meth = SSLv3_client_method(); else if (strcmp(*argv, "-tls1_2") == 0) meth = TLSv1_2_client_method(); else if (strcmp(*argv, "-tls1_1") == 0) meth = TLSv1_1_client_method(); else if (strcmp(*argv, "-tls1") == 0) meth = TLSv1_client_method(); #ifndef OPENSSL_NO_DTLS1 else if (strcmp(*argv, "-dtls1") == 0) { meth = DTLSv1_client_method(); socket_type = SOCK_DGRAM; } else if (strcmp(*argv, "-timeout") == 0) enable_timeouts = 1; else if (strcmp(*argv, "-mtu") == 0) { if (--argc < 1) goto bad; socket_mtu = strtonum(*(++argv), 0, LONG_MAX, &errstr); if (errstr) goto bad; } #endif else if (strcmp(*argv, "-bugs") == 0) bugs = 1; else if (strcmp(*argv, "-keyform") == 0) { if (--argc < 1) goto bad; key_format = str2fmt(*(++argv)); } else if (strcmp(*argv, "-pass") == 0) { if (--argc < 1) goto bad; passarg = *(++argv); } else if (strcmp(*argv, "-key") == 0) { if (--argc < 1) goto bad; key_file = *(++argv); } else if (strcmp(*argv, "-reconnect") == 0) { reconnect = 5; } else if (strcmp(*argv, "-CApath") == 0) { if (--argc < 1) goto bad; CApath = *(++argv); } else if (strcmp(*argv, "-CAfile") == 0) { if (--argc < 1) goto bad; CAfile = *(++argv); } else if (strcmp(*argv, "-no_tls1_2") == 0) off |= SSL_OP_NO_TLSv1_2; else if (strcmp(*argv, "-no_tls1_1") == 0) off |= SSL_OP_NO_TLSv1_1; else if (strcmp(*argv, "-no_tls1") == 0) off |= SSL_OP_NO_TLSv1; else if (strcmp(*argv, "-no_ssl3") == 0) off |= SSL_OP_NO_SSLv3; else if (strcmp(*argv, "-no_ssl2") == 0) off |= SSL_OP_NO_SSLv2; else if (strcmp(*argv, "-no_comp") == 0) { off |= SSL_OP_NO_COMPRESSION; } #ifndef OPENSSL_NO_TLSEXT else if (strcmp(*argv, "-no_ticket") == 0) { off |= SSL_OP_NO_TICKET; } #ifndef OPENSSL_NO_NEXTPROTONEG else if (strcmp(*argv, "-nextprotoneg") == 0) { if (--argc < 1) goto bad; next_proto_neg_in = *(++argv); } #endif #endif else if (strcmp(*argv, "-serverpref") == 0) off |= SSL_OP_CIPHER_SERVER_PREFERENCE; else if (strcmp(*argv, "-legacy_renegotiation") == 0) ; /* no-op */ else if (strcmp(*argv, "-legacy_server_connect") == 0) { off |= SSL_OP_LEGACY_SERVER_CONNECT; } else if (strcmp(*argv, "-no_legacy_server_connect") == 0) { clr |= SSL_OP_LEGACY_SERVER_CONNECT; } else if (strcmp(*argv, "-cipher") == 0) { if (--argc < 1) goto bad; cipher = *(++argv); } else if (strcmp(*argv, "-nbio") == 0) { c_nbio = 1; } else if (strcmp(*argv, "-starttls") == 0) { if (--argc < 1) goto bad; ++argv; if (strcmp(*argv, "smtp") == 0) starttls_proto = PROTO_SMTP; else if (strcmp(*argv, "lmtp") == 0) starttls_proto = PROTO_LMTP; else if (strcmp(*argv, "pop3") == 0) starttls_proto = PROTO_POP3; else if (strcmp(*argv, "imap") == 0) starttls_proto = PROTO_IMAP; else if (strcmp(*argv, "ftp") == 0) starttls_proto = PROTO_FTP; else if (strcmp(*argv, "xmpp") == 0) starttls_proto = PROTO_XMPP; else goto bad; } #ifndef OPENSSL_NO_ENGINE else if (strcmp(*argv, "-engine") == 0) { if (--argc < 1) goto bad; engine_id = *(++argv); } else if (strcmp(*argv, "-ssl_client_engine") == 0) { if (--argc < 1) goto bad; ssl_client_engine_id = *(++argv); } #endif else if (strcmp(*argv, "-4") == 0) { af = AF_INET; } else if (strcmp(*argv, "-6") == 0) { af = AF_INET6; } #ifndef OPENSSL_NO_TLSEXT else if (strcmp(*argv, "-servername") == 0) { if (--argc < 1) goto bad; servername = *(++argv); /* meth=TLSv1_client_method(); */ } #endif #ifndef OPENSSL_NO_SRTP else if (strcmp(*argv, "-use_srtp") == 0) { if (--argc < 1) goto bad; srtp_profiles = *(++argv); } #endif else if (strcmp(*argv, "-keymatexport") == 0) { if (--argc < 1) goto bad; keymatexportlabel = *(++argv); } else if (strcmp(*argv, "-keymatexportlen") == 0) { const char *errstr; if (--argc < 1) goto bad; keymatexportlen = strtonum(*(++argv), 1, INT_MAX, &errstr); if (errstr) goto bad; } else { BIO_printf(bio_err, "unknown option %s\n", *argv); badop = 1; break; } argc--; argv++; } if (badop) { bad: if (errstr) BIO_printf(bio_err, "invalid argument %s: %s\n", *argv, errstr); else sc_usage(); goto end; } OpenSSL_add_ssl_algorithms(); SSL_load_error_strings(); #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) next_proto.status = -1; if (next_proto_neg_in) { next_proto.data = next_protos_parse(&next_proto.len, next_proto_neg_in); if (next_proto.data == NULL) { BIO_printf(bio_err, "Error parsing -nextprotoneg argument\n"); goto end; } } else next_proto.data = NULL; #endif #ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine_id, 1); if (ssl_client_engine_id) { ssl_client_engine = ENGINE_by_id(ssl_client_engine_id); if (!ssl_client_engine) { BIO_printf(bio_err, "Error getting client auth engine\n"); goto end; } } #endif if (!app_passwd(bio_err, passarg, NULL, &pass, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } if (key_file == NULL) key_file = cert_file; if (key_file) { key = load_key(bio_err, key_file, key_format, 0, pass, e, "client certificate private key file"); if (!key) { ERR_print_errors(bio_err); goto end; } } if (cert_file) { cert = load_cert(bio_err, cert_file, cert_format, NULL, e, "client certificate file"); if (!cert) { ERR_print_errors(bio_err); goto end; } } if (bio_c_out == NULL) { if (c_quiet && !c_debug && !c_msg) { bio_c_out = BIO_new(BIO_s_null()); } else { if (bio_c_out == NULL) bio_c_out = BIO_new_fp(stdout, BIO_NOCLOSE); } } ctx = SSL_CTX_new(meth); if (ctx == NULL) { ERR_print_errors(bio_err); goto end; } if (vpm) SSL_CTX_set1_param(ctx, vpm); #ifndef OPENSSL_NO_ENGINE if (ssl_client_engine) { if (!SSL_CTX_set_client_cert_engine(ctx, ssl_client_engine)) { BIO_puts(bio_err, "Error setting client auth engine\n"); ERR_print_errors(bio_err); ENGINE_free(ssl_client_engine); goto end; } ENGINE_free(ssl_client_engine); } #endif #ifndef OPENSSL_NO_SRTP if (srtp_profiles != NULL) SSL_CTX_set_tlsext_use_srtp(ctx, srtp_profiles); #endif if (bugs) SSL_CTX_set_options(ctx, SSL_OP_ALL | off); else SSL_CTX_set_options(ctx, off); if (clr) SSL_CTX_clear_options(ctx, clr); /* * DTLS: partial reads end up discarding unread UDP bytes :-( Setting * read ahead solves this problem. */ if (socket_type == SOCK_DGRAM) SSL_CTX_set_read_ahead(ctx, 1); #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) if (next_proto.data) SSL_CTX_set_next_proto_select_cb(ctx, next_proto_cb, &next_proto); #endif if (state) SSL_CTX_set_info_callback(ctx, apps_ssl_info_callback); if (cipher != NULL) if (!SSL_CTX_set_cipher_list(ctx, cipher)) { BIO_printf(bio_err, "error setting cipher list\n"); ERR_print_errors(bio_err); goto end; } SSL_CTX_set_verify(ctx, verify, verify_callback); if (!set_cert_key_stuff(ctx, cert, key)) goto end; if ((!SSL_CTX_load_verify_locations(ctx, CAfile, CApath)) || (!SSL_CTX_set_default_verify_paths(ctx))) { /* * BIO_printf(bio_err,"error setting default verify * locations\n"); */ ERR_print_errors(bio_err); /* goto end; */ } #ifndef OPENSSL_NO_TLSEXT if (servername != NULL) { tlsextcbp.biodebug = bio_err; SSL_CTX_set_tlsext_servername_callback(ctx, ssl_servername_cb); SSL_CTX_set_tlsext_servername_arg(ctx, &tlsextcbp); } #endif con = SSL_new(ctx); if (sess_in) { SSL_SESSION *sess; BIO *stmp = BIO_new_file(sess_in, "r"); if (!stmp) { BIO_printf(bio_err, "Can't open session file %s\n", sess_in); ERR_print_errors(bio_err); goto end; } sess = PEM_read_bio_SSL_SESSION(stmp, NULL, 0, NULL); BIO_free(stmp); if (!sess) { BIO_printf(bio_err, "Can't open session file %s\n", sess_in); ERR_print_errors(bio_err); goto end; } SSL_set_session(con, sess); SSL_SESSION_free(sess); } #ifndef OPENSSL_NO_TLSEXT if (servername != NULL) { if (!SSL_set_tlsext_host_name(con, servername)) { BIO_printf(bio_err, "Unable to set TLS servername extension.\n"); ERR_print_errors(bio_err); goto end; } } #endif /* SSL_set_cipher_list(con,"RC4-MD5"); */ re_start: if (init_client(&s, host, port, socket_type, af) == 0) { BIO_printf(bio_err, "connect:errno=%d\n", errno); shutdown(s, SHUT_RD); close(s); goto end; } BIO_printf(bio_c_out, "CONNECTED(%08X)\n", s); if (c_nbio) { unsigned long l = 1; BIO_printf(bio_c_out, "turning on non blocking io\n"); if (BIO_socket_ioctl(s, FIONBIO, &l) < 0) { ERR_print_errors(bio_err); goto end; } } if (c_Pause & 0x01) SSL_set_debug(con, 1); if (SSL_version(con) == DTLS1_VERSION) { sbio = BIO_new_dgram(s, BIO_NOCLOSE); if (getsockname(s, &peer, (void *) &peerlen) < 0) { BIO_printf(bio_err, "getsockname:errno=%d\n", errno); shutdown(s, SHUT_RD); close(s); goto end; } (void) BIO_ctrl_set_connected(sbio, 1, &peer); if (enable_timeouts) { timeout.tv_sec = 0; timeout.tv_usec = DGRAM_RCV_TIMEOUT; BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_RECV_TIMEOUT, 0, &timeout); timeout.tv_sec = 0; timeout.tv_usec = DGRAM_SND_TIMEOUT; BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_SEND_TIMEOUT, 0, &timeout); } if (socket_mtu > 28) { SSL_set_options(con, SSL_OP_NO_QUERY_MTU); SSL_set_mtu(con, socket_mtu - 28); } else /* want to do MTU discovery */ BIO_ctrl(sbio, BIO_CTRL_DGRAM_MTU_DISCOVER, 0, NULL); } else sbio = BIO_new_socket(s, BIO_NOCLOSE); if (nbio_test) { BIO *test; test = BIO_new(BIO_f_nbio_test()); sbio = BIO_push(test, sbio); } if (c_debug) { SSL_set_debug(con, 1); BIO_set_callback(sbio, bio_dump_callback); BIO_set_callback_arg(sbio, (char *) bio_c_out); } if (c_msg) { SSL_set_msg_callback(con, msg_cb); SSL_set_msg_callback_arg(con, bio_c_out); } #ifndef OPENSSL_NO_TLSEXT if (c_tlsextdebug) { SSL_set_tlsext_debug_callback(con, tlsext_cb); SSL_set_tlsext_debug_arg(con, bio_c_out); } if (c_status_req) { SSL_set_tlsext_status_type(con, TLSEXT_STATUSTYPE_ocsp); SSL_CTX_set_tlsext_status_cb(ctx, ocsp_resp_cb); SSL_CTX_set_tlsext_status_arg(ctx, bio_c_out); } #endif SSL_set_bio(con, sbio, sbio); SSL_set_connect_state(con); /* ok, lets connect */ width = SSL_get_fd(con) + 1; read_tty = 1; write_tty = 0; tty_on = 0; read_ssl = 1; write_ssl = 1; cbuf_len = 0; cbuf_off = 0; sbuf_len = 0; sbuf_off = 0; /* This is an ugly hack that does a lot of assumptions */ /* * We do have to handle multi-line responses which may come in a * single packet or not. We therefore have to use BIO_gets() which * does need a buffering BIO. So during the initial chitchat we do * push a buffering BIO into the chain that is removed again later on * to not disturb the rest of the s_client operation. */ if (starttls_proto == PROTO_SMTP || starttls_proto == PROTO_LMTP) { int foundit = 0; BIO *fbio = BIO_new(BIO_f_buffer()); BIO_push(fbio, sbio); /* wait for multi-line response to end from SMTP */ do { mbuf_len = BIO_gets(fbio, mbuf, BUFSIZZ); } while (mbuf_len > 3 && mbuf[3] == '-'); /* STARTTLS command requires EHLO... */ BIO_printf(fbio, "%cHLO openssl.client.net\r\n", starttls_proto == PROTO_SMTP ? 'E' : 'L'); (void) BIO_flush(fbio); /* wait for multi-line response to end EHLO SMTP response */ do { mbuf_len = BIO_gets(fbio, mbuf, BUFSIZZ); if (strstr(mbuf, "STARTTLS")) foundit = 1; } while (mbuf_len > 3 && mbuf[3] == '-'); (void) BIO_flush(fbio); BIO_pop(fbio); BIO_free(fbio); if (!foundit) BIO_printf(bio_err, "didn't found starttls in server response," " try anyway...\n"); BIO_printf(sbio, "STARTTLS\r\n"); BIO_read(sbio, sbuf, BUFSIZZ); } else if (starttls_proto == PROTO_POP3) { mbuf_len = BIO_read(sbio, mbuf, BUFSIZZ); if (mbuf_len == -1) { BIO_printf(bio_err, "BIO_read failed\n"); goto end; } BIO_printf(sbio, "STLS\r\n"); BIO_read(sbio, sbuf, BUFSIZZ); } else if (starttls_proto == PROTO_IMAP) { int foundit = 0; BIO *fbio = BIO_new(BIO_f_buffer()); BIO_push(fbio, sbio); BIO_gets(fbio, mbuf, BUFSIZZ); /* STARTTLS command requires CAPABILITY... */ BIO_printf(fbio, ". CAPABILITY\r\n"); (void) BIO_flush(fbio); /* wait for multi-line CAPABILITY response */ do { mbuf_len = BIO_gets(fbio, mbuf, BUFSIZZ); if (strstr(mbuf, "STARTTLS")) foundit = 1; } while (mbuf_len > 3 && mbuf[0] != '.'); (void) BIO_flush(fbio); BIO_pop(fbio); BIO_free(fbio); if (!foundit) BIO_printf(bio_err, "didn't found STARTTLS in server response," " try anyway...\n"); BIO_printf(sbio, ". STARTTLS\r\n"); BIO_read(sbio, sbuf, BUFSIZZ); } else if (starttls_proto == PROTO_FTP) { BIO *fbio = BIO_new(BIO_f_buffer()); BIO_push(fbio, sbio); /* wait for multi-line response to end from FTP */ do { mbuf_len = BIO_gets(fbio, mbuf, BUFSIZZ); } while (mbuf_len > 3 && mbuf[3] == '-'); (void) BIO_flush(fbio); BIO_pop(fbio); BIO_free(fbio); BIO_printf(sbio, "AUTH TLS\r\n"); BIO_read(sbio, sbuf, BUFSIZZ); } if (starttls_proto == PROTO_XMPP) { int seen = 0; BIO_printf(sbio, "", host); seen = BIO_read(sbio, mbuf, BUFSIZZ); mbuf[seen] = 0; while (!strstr(mbuf, "")) goto shut; seen = BIO_read(sbio, mbuf, BUFSIZZ); mbuf[seen] = 0; } BIO_printf(sbio, ""); seen = BIO_read(sbio, sbuf, BUFSIZZ); sbuf[seen] = 0; if (!strstr(sbuf, " 0) full_log--; if (starttls_proto) { BIO_write(bio_err, mbuf, mbuf_len); /* We don't need to know any more */ starttls_proto = PROTO_OFF; } if (reconnect) { reconnect--; BIO_printf(bio_c_out, "drop connection and then reconnect\n"); SSL_shutdown(con); SSL_set_connect_state(con); shutdown(SSL_get_fd(con), SHUT_RD); close(SSL_get_fd(con)); goto re_start; } } } ssl_pending = read_ssl && SSL_pending(con); /* XXX should add tests for fd_set overflow */ if (!ssl_pending) { if (tty_on) { if (read_tty) FD_SET(fileno(stdin), &readfds); if (write_tty) FD_SET(fileno(stdout), &writefds); } if (read_ssl) FD_SET(SSL_get_fd(con), &readfds); if (write_ssl) FD_SET(SSL_get_fd(con), &writefds); /* printf("mode tty(%d %d%d) ssl(%d%d)\n", tty_on,read_tty,write_tty,read_ssl,write_ssl);*/ i = select(width, &readfds, &writefds, NULL, timeoutp); if (i < 0) { BIO_printf(bio_err, "bad select %d\n", errno); goto shut; /* goto end; */ } } if ((SSL_version(con) == DTLS1_VERSION) && DTLSv1_handle_timeout(con) > 0) { BIO_printf(bio_err, "TIMEOUT occured\n"); } if (!ssl_pending && FD_ISSET(SSL_get_fd(con), &writefds)) { k = SSL_write(con, &(cbuf[cbuf_off]), (unsigned int) cbuf_len); switch (SSL_get_error(con, k)) { case SSL_ERROR_NONE: cbuf_off += k; cbuf_len -= k; if (k <= 0) goto end; /* we have done a write(con,NULL,0); */ if (cbuf_len <= 0) { read_tty = 1; write_ssl = 0; } else { /* if (cbuf_len > 0) */ read_tty = 0; write_ssl = 1; } break; case SSL_ERROR_WANT_WRITE: BIO_printf(bio_c_out, "write W BLOCK\n"); write_ssl = 1; read_tty = 0; break; case SSL_ERROR_WANT_READ: BIO_printf(bio_c_out, "write R BLOCK\n"); write_tty = 0; read_ssl = 1; write_ssl = 0; break; case SSL_ERROR_WANT_X509_LOOKUP: BIO_printf(bio_c_out, "write X BLOCK\n"); break; case SSL_ERROR_ZERO_RETURN: if (cbuf_len != 0) { BIO_printf(bio_c_out, "shutdown\n"); ret = 0; goto shut; } else { read_tty = 1; write_ssl = 0; break; } case SSL_ERROR_SYSCALL: if ((k != 0) || (cbuf_len != 0)) { BIO_printf(bio_err, "write:errno=%d\n", errno); goto shut; } else { read_tty = 1; write_ssl = 0; } break; case SSL_ERROR_SSL: ERR_print_errors(bio_err); goto shut; } } else if (!ssl_pending && FD_ISSET(fileno(stdout), &writefds)) { i = write(fileno(stdout), &(sbuf[sbuf_off]), sbuf_len); if (i <= 0) { BIO_printf(bio_c_out, "DONE\n"); ret = 0; goto shut; /* goto end; */ } sbuf_len -= i; sbuf_off += i; if (sbuf_len <= 0) { read_ssl = 1; write_tty = 0; } } else if (ssl_pending || FD_ISSET(SSL_get_fd(con), &readfds)) { #ifdef RENEG { static int iiii; if (++iiii == 52) { SSL_renegotiate(con); iiii = 0; } } #endif k = SSL_read(con, sbuf, 1024 /* BUFSIZZ */ ); switch (SSL_get_error(con, k)) { case SSL_ERROR_NONE: if (k <= 0) goto end; sbuf_off = 0; sbuf_len = k; read_ssl = 0; write_tty = 1; break; case SSL_ERROR_WANT_WRITE: BIO_printf(bio_c_out, "read W BLOCK\n"); write_ssl = 1; read_tty = 0; break; case SSL_ERROR_WANT_READ: BIO_printf(bio_c_out, "read R BLOCK\n"); write_tty = 0; read_ssl = 1; if ((read_tty == 0) && (write_ssl == 0)) write_ssl = 1; break; case SSL_ERROR_WANT_X509_LOOKUP: BIO_printf(bio_c_out, "read X BLOCK\n"); break; case SSL_ERROR_SYSCALL: ret = errno; BIO_printf(bio_err, "read:errno=%d\n", ret); goto shut; case SSL_ERROR_ZERO_RETURN: BIO_printf(bio_c_out, "closed\n"); ret = 0; goto shut; case SSL_ERROR_SSL: ERR_print_errors(bio_err); goto shut; /* break; */ } } else if (FD_ISSET(fileno(stdin), &readfds)) { if (crlf) { int j, lf_num; i = read(fileno(stdin), cbuf, BUFSIZZ / 2); lf_num = 0; /* both loops are skipped when i <= 0 */ for (j = 0; j < i; j++) if (cbuf[j] == '\n') lf_num++; for (j = i - 1; j >= 0; j--) { cbuf[j + lf_num] = cbuf[j]; if (cbuf[j] == '\n') { lf_num--; i++; cbuf[j + lf_num] = '\r'; } } assert(lf_num == 0); } else i = read(fileno(stdin), cbuf, BUFSIZZ); if ((!c_ign_eof) && ((i <= 0) || (cbuf[0] == 'Q'))) { BIO_printf(bio_err, "DONE\n"); ret = 0; goto shut; } if ((!c_ign_eof) && (cbuf[0] == 'R')) { BIO_printf(bio_err, "RENEGOTIATING\n"); SSL_renegotiate(con); cbuf_len = 0; } else { cbuf_len = i; cbuf_off = 0; } write_ssl = 1; read_tty = 0; } } ret = 0; shut: if (in_init) print_stuff(bio_c_out, con, full_log); SSL_shutdown(con); shutdown(SSL_get_fd(con), SHUT_RD); close(SSL_get_fd(con)); end: if (con != NULL) { if (prexit != 0) print_stuff(bio_c_out, con, 1); SSL_free(con); } #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) free(next_proto.data); #endif if (ctx != NULL) SSL_CTX_free(ctx); if (cert) X509_free(cert); if (key) EVP_PKEY_free(key); free(pass); if (vpm) X509_VERIFY_PARAM_free(vpm); if (cbuf != NULL) { OPENSSL_cleanse(cbuf, BUFSIZZ); free(cbuf); } if (sbuf != NULL) { OPENSSL_cleanse(sbuf, BUFSIZZ); free(sbuf); } if (mbuf != NULL) { OPENSSL_cleanse(mbuf, BUFSIZZ); free(mbuf); } if (bio_c_out != NULL) { BIO_free(bio_c_out); bio_c_out = NULL; } return (ret); } static void print_stuff(BIO * bio, SSL * s, int full) { X509 *peer = NULL; char *p; static const char *space = " "; char buf[BUFSIZ]; STACK_OF(X509) * sk; STACK_OF(X509_NAME) * sk2; const SSL_CIPHER *c; X509_NAME *xn; int j, i; unsigned char *exportedkeymat; if (full) { int got_a_chain = 0; sk = SSL_get_peer_cert_chain(s); if (sk != NULL) { got_a_chain = 1; /* we don't have it for SSL2 * (yet) */ BIO_printf(bio, "---\nCertificate chain\n"); for (i = 0; i < sk_X509_num(sk); i++) { X509_NAME_oneline(X509_get_subject_name( sk_X509_value(sk, i)), buf, sizeof buf); BIO_printf(bio, "%2d s:%s\n", i, buf); X509_NAME_oneline(X509_get_issuer_name( sk_X509_value(sk, i)), buf, sizeof buf); BIO_printf(bio, " i:%s\n", buf); if (c_showcerts) PEM_write_bio_X509(bio, sk_X509_value(sk, i)); } } BIO_printf(bio, "---\n"); peer = SSL_get_peer_certificate(s); if (peer != NULL) { BIO_printf(bio, "Server certificate\n"); if (!(c_showcerts && got_a_chain)) /* Redundant if we * showed the whole * chain */ PEM_write_bio_X509(bio, peer); X509_NAME_oneline(X509_get_subject_name(peer), buf, sizeof buf); BIO_printf(bio, "subject=%s\n", buf); X509_NAME_oneline(X509_get_issuer_name(peer), buf, sizeof buf); BIO_printf(bio, "issuer=%s\n", buf); } else BIO_printf(bio, "no peer certificate available\n"); sk2 = SSL_get_client_CA_list(s); if ((sk2 != NULL) && (sk_X509_NAME_num(sk2) > 0)) { BIO_printf(bio, "---\nAcceptable client certificate CA names\n"); for (i = 0; i < sk_X509_NAME_num(sk2); i++) { xn = sk_X509_NAME_value(sk2, i); X509_NAME_oneline(xn, buf, sizeof(buf)); BIO_write(bio, buf, strlen(buf)); BIO_write(bio, "\n", 1); } } else { BIO_printf(bio, "---\nNo client certificate CA names sent\n"); } p = SSL_get_shared_ciphers(s, buf, sizeof buf); if (p != NULL) { /* * This works only for SSL 2. In later protocol * versions, the client does not know what other * ciphers (in addition to the one to be used in the * current connection) the server supports. */ BIO_printf(bio, "---\nCiphers common between both SSL endpoints:\n"); j = i = 0; while (*p) { if (*p == ':') { BIO_write(bio, space, 15 - j % 25); i++; j = 0; BIO_write(bio, ((i % 3) ? " " : "\n"), 1); } else { BIO_write(bio, p, 1); j++; } p++; } BIO_write(bio, "\n", 1); } BIO_printf(bio, "---\nSSL handshake has read %ld bytes and written %ld bytes\n", BIO_number_read(SSL_get_rbio(s)), BIO_number_written(SSL_get_wbio(s))); } BIO_printf(bio, (SSL_cache_hit(s) ? "---\nReused, " : "---\nNew, ")); c = SSL_get_current_cipher(s); BIO_printf(bio, "%s, Cipher is %s\n", SSL_CIPHER_get_version(c), SSL_CIPHER_get_name(c)); if (peer != NULL) { EVP_PKEY *pktmp; pktmp = X509_get_pubkey(peer); BIO_printf(bio, "Server public key is %d bit\n", EVP_PKEY_bits(pktmp)); EVP_PKEY_free(pktmp); } BIO_printf(bio, "Secure Renegotiation IS%s supported\n", SSL_get_secure_renegotiation_support(s) ? "" : " NOT"); /* Compression is not supported and will always be none. */ BIO_printf(bio, "Compression: NONE\n"); BIO_printf(bio, "Expansion: NONE\n"); #ifdef SSL_DEBUG { /* Print out local port of connection: useful for debugging */ int sock; struct sockaddr_in ladd; socklen_t ladd_size = sizeof(ladd); sock = SSL_get_fd(s); getsockname(sock, (struct sockaddr *) & ladd, &ladd_size); BIO_printf(bio_c_out, "LOCAL PORT is %u\n", ntohs(ladd.sin_port)); } #endif #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) if (next_proto.status != -1) { const unsigned char *proto; unsigned int proto_len; SSL_get0_next_proto_negotiated(s, &proto, &proto_len); BIO_printf(bio, "Next protocol: (%d) ", next_proto.status); BIO_write(bio, proto, proto_len); BIO_write(bio, "\n", 1); } #endif #ifndef OPENSSL_NO_SRTP { SRTP_PROTECTION_PROFILE *srtp_profile = SSL_get_selected_srtp_profile(s); if (srtp_profile) BIO_printf(bio, "SRTP Extension negotiated, profile=%s\n", srtp_profile->name); } #endif SSL_SESSION_print(bio, SSL_get_session(s)); if (keymatexportlabel != NULL) { BIO_printf(bio, "Keying material exporter:\n"); BIO_printf(bio, " Label: '%s'\n", keymatexportlabel); BIO_printf(bio, " Length: %i bytes\n", keymatexportlen); exportedkeymat = malloc(keymatexportlen); if (exportedkeymat != NULL) { if (!SSL_export_keying_material(s, exportedkeymat, keymatexportlen, keymatexportlabel, strlen(keymatexportlabel), NULL, 0, 0)) { BIO_printf(bio, " Error\n"); } else { BIO_printf(bio, " Keying material: "); for (i = 0; i < keymatexportlen; i++) BIO_printf(bio, "%02X", exportedkeymat[i]); BIO_printf(bio, "\n"); } free(exportedkeymat); } } BIO_printf(bio, "---\n"); if (peer != NULL) X509_free(peer); /* flush, or debugging output gets mixed with http response */ (void) BIO_flush(bio); } #ifndef OPENSSL_NO_TLSEXT static int ocsp_resp_cb(SSL * s, void *arg) { const unsigned char *p; int len; OCSP_RESPONSE *rsp; len = SSL_get_tlsext_status_ocsp_resp(s, &p); BIO_puts(arg, "OCSP response: "); if (!p) { BIO_puts(arg, "no response sent\n"); return 1; } rsp = d2i_OCSP_RESPONSE(NULL, &p, len); if (!rsp) { BIO_puts(arg, "response parse error\n"); BIO_dump_indent(arg, (char *) p, len, 4); return 0; } BIO_puts(arg, "\n======================================\n"); OCSP_RESPONSE_print(arg, rsp, 0); BIO_puts(arg, "======================================\n"); OCSP_RESPONSE_free(rsp); return 1; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/apps/dsa.c0000644000175000017500000002434312360020706016620 0ustar /* $OpenBSD: dsa.c,v 1.25 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include /* for OPENSSL_NO_DSA */ #include #include #include #include #include "apps.h" #include #include #include #include #include #include #include /* -inform arg - input format - default PEM (one of DER, NET or PEM) * -outform arg - output format - default PEM * -in arg - input file - default stdin * -out arg - output file - default stdout * -des - encrypt output if PEM format with DES in cbc mode * -des3 - encrypt output if PEM format * -idea - encrypt output if PEM format * -aes128 - encrypt output if PEM format * -aes192 - encrypt output if PEM format * -aes256 - encrypt output if PEM format * -camellia128 - encrypt output if PEM format * -camellia192 - encrypt output if PEM format * -camellia256 - encrypt output if PEM format * -seed - encrypt output if PEM format * -text - print a text version * -modulus - print the DSA public key */ int dsa_main(int, char **); int dsa_main(int argc, char **argv) { ENGINE *e = NULL; int ret = 1; DSA *dsa = NULL; int i, badops = 0; const EVP_CIPHER *enc = NULL; BIO *in = NULL, *out = NULL; int informat, outformat, text = 0, noout = 0; int pubin = 0, pubout = 0; char *infile, *outfile, *prog; #ifndef OPENSSL_NO_ENGINE char *engine; #endif char *passargin = NULL, *passargout = NULL; char *passin = NULL, *passout = NULL; int modulus = 0; int pvk_encr = 2; if (!load_config(bio_err, NULL)) goto end; #ifndef OPENSSL_NO_ENGINE engine = NULL; #endif infile = NULL; outfile = NULL; informat = FORMAT_PEM; outformat = FORMAT_PEM; prog = argv[0]; argc--; argv++; while (argc >= 1) { if (strcmp(*argv, "-inform") == 0) { if (--argc < 1) goto bad; informat = str2fmt(*(++argv)); } else if (strcmp(*argv, "-outform") == 0) { if (--argc < 1) goto bad; outformat = str2fmt(*(++argv)); } else if (strcmp(*argv, "-in") == 0) { if (--argc < 1) goto bad; infile = *(++argv); } else if (strcmp(*argv, "-out") == 0) { if (--argc < 1) goto bad; outfile = *(++argv); } else if (strcmp(*argv, "-passin") == 0) { if (--argc < 1) goto bad; passargin = *(++argv); } else if (strcmp(*argv, "-passout") == 0) { if (--argc < 1) goto bad; passargout = *(++argv); } #ifndef OPENSSL_NO_ENGINE else if (strcmp(*argv, "-engine") == 0) { if (--argc < 1) goto bad; engine = *(++argv); } #endif else if (strcmp(*argv, "-pvk-strong") == 0) pvk_encr = 2; else if (strcmp(*argv, "-pvk-weak") == 0) pvk_encr = 1; else if (strcmp(*argv, "-pvk-none") == 0) pvk_encr = 0; else if (strcmp(*argv, "-noout") == 0) noout = 1; else if (strcmp(*argv, "-text") == 0) text = 1; else if (strcmp(*argv, "-modulus") == 0) modulus = 1; else if (strcmp(*argv, "-pubin") == 0) pubin = 1; else if (strcmp(*argv, "-pubout") == 0) pubout = 1; else if ((enc = EVP_get_cipherbyname(&(argv[0][1]))) == NULL) { BIO_printf(bio_err, "unknown option %s\n", *argv); badops = 1; break; } argc--; argv++; } if (badops) { bad: BIO_printf(bio_err, "%s [options] outfile\n", prog); BIO_printf(bio_err, "where options are\n"); BIO_printf(bio_err, " -inform arg input format - DER or PEM\n"); BIO_printf(bio_err, " -outform arg output format - DER or PEM\n"); BIO_printf(bio_err, " -in arg input file\n"); BIO_printf(bio_err, " -passin arg input file pass phrase source\n"); BIO_printf(bio_err, " -out arg output file\n"); BIO_printf(bio_err, " -passout arg output file pass phrase source\n"); #ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err, " -engine e use engine e, possibly a hardware device.\n"); #endif BIO_printf(bio_err, " -des encrypt PEM output with cbc des\n"); BIO_printf(bio_err, " -des3 encrypt PEM output with ede cbc des using 168 bit key\n"); #ifndef OPENSSL_NO_IDEA BIO_printf(bio_err, " -idea encrypt PEM output with cbc idea\n"); #endif #ifndef OPENSSL_NO_AES BIO_printf(bio_err, " -aes128, -aes192, -aes256\n"); BIO_printf(bio_err, " encrypt PEM output with cbc aes\n"); #endif #ifndef OPENSSL_NO_CAMELLIA BIO_printf(bio_err, " -camellia128, -camellia192, -camellia256\n"); BIO_printf(bio_err, " encrypt PEM output with cbc camellia\n"); #endif BIO_printf(bio_err, " -text print the key in text\n"); BIO_printf(bio_err, " -noout don't print key out\n"); BIO_printf(bio_err, " -modulus print the DSA public value\n"); goto end; } ERR_load_crypto_strings(); #ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); #endif if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) { BIO_printf(bio_err, "Error getting passwords\n"); goto end; } in = BIO_new(BIO_s_file()); out = BIO_new(BIO_s_file()); if ((in == NULL) || (out == NULL)) { ERR_print_errors(bio_err); goto end; } if (infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { if (BIO_read_filename(in, infile) <= 0) { perror(infile); goto end; } } BIO_printf(bio_err, "read DSA key\n"); { EVP_PKEY *pkey; if (pubin) pkey = load_pubkey(bio_err, infile, informat, 1, passin, e, "Public Key"); else pkey = load_key(bio_err, infile, informat, 1, passin, e, "Private Key"); if (pkey) { dsa = EVP_PKEY_get1_DSA(pkey); EVP_PKEY_free(pkey); } } if (dsa == NULL) { BIO_printf(bio_err, "unable to load Key\n"); ERR_print_errors(bio_err); goto end; } if (outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { if (BIO_write_filename(out, outfile) <= 0) { perror(outfile); goto end; } } if (text) { if (!DSA_print(out, dsa, 0)) { perror(outfile); ERR_print_errors(bio_err); goto end; } } if (modulus) { fprintf(stdout, "Public Key="); BN_print(out, dsa->pub_key); fprintf(stdout, "\n"); } if (noout) goto end; BIO_printf(bio_err, "writing DSA key\n"); if (outformat == FORMAT_ASN1) { if (pubin || pubout) i = i2d_DSA_PUBKEY_bio(out, dsa); else i = i2d_DSAPrivateKey_bio(out, dsa); } else if (outformat == FORMAT_PEM) { if (pubin || pubout) i = PEM_write_bio_DSA_PUBKEY(out, dsa); else i = PEM_write_bio_DSAPrivateKey(out, dsa, enc, NULL, 0, NULL, passout); #if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_RC4) } else if (outformat == FORMAT_MSBLOB || outformat == FORMAT_PVK) { EVP_PKEY *pk; pk = EVP_PKEY_new(); EVP_PKEY_set1_DSA(pk, dsa); if (outformat == FORMAT_PVK) i = i2b_PVK_bio(out, pk, pvk_encr, 0, passout); else if (pubin || pubout) i = i2b_PublicKey_bio(out, pk); else i = i2b_PrivateKey_bio(out, pk); EVP_PKEY_free(pk); #endif } else { BIO_printf(bio_err, "bad output format specified for outfile\n"); goto end; } if (i <= 0) { BIO_printf(bio_err, "unable to write private key\n"); ERR_print_errors(bio_err); } else ret = 0; end: if (in != NULL) BIO_free(in); if (out != NULL) BIO_free_all(out); if (dsa != NULL) DSA_free(dsa); free(passin); free(passout); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/apps/testdsa.h0000644000175000017500000002576112360020706017532 0ustar /* $OpenBSD$ */ DSA *get_dsa512(void); DSA *get_dsa1024(void); DSA *get_dsa2048(void); static unsigned char dsa512_priv[] = { 0x65, 0xe5, 0xc7, 0x38, 0x60, 0x24, 0xb5, 0x89, 0xd4, 0x9c, 0xeb, 0x4c, 0x9c, 0x1d, 0x7a, 0x22, 0xbd, 0xd1, 0xc2, 0xd2, }; static unsigned char dsa512_pub[] = { 0x00, 0x95, 0xa7, 0x0d, 0xec, 0x93, 0x68, 0xba, 0x5f, 0xf7, 0x5f, 0x07, 0xf2, 0x3b, 0xad, 0x6b, 0x01, 0xdc, 0xbe, 0xec, 0xde, 0x04, 0x7a, 0x3a, 0x27, 0xb3, 0xec, 0x49, 0xfd, 0x08, 0x43, 0x3d, 0x7e, 0xa8, 0x2c, 0x5e, 0x7b, 0xbb, 0xfc, 0xf4, 0x6e, 0xeb, 0x6c, 0xb0, 0x6e, 0xf8, 0x02, 0x12, 0x8c, 0x38, 0x5d, 0x83, 0x56, 0x7d, 0xee, 0x53, 0x05, 0x3e, 0x24, 0x84, 0xbe, 0xba, 0x0a, 0x6b, 0xc8, }; static unsigned char dsa512_p[] = { 0x9D, 0x1B, 0x69, 0x8E, 0x26, 0xDB, 0xF2, 0x2B, 0x11, 0x70, 0x19, 0x86, 0xF6, 0x19, 0xC8, 0xF8, 0x19, 0xF2, 0x18, 0x53, 0x94, 0x46, 0x06, 0xD0, 0x62, 0x50, 0x33, 0x4B, 0x02, 0x3C, 0x52, 0x30, 0x03, 0x8B, 0x3B, 0xF9, 0x5F, 0xD1, 0x24, 0x06, 0x4F, 0x7B, 0x4C, 0xBA, 0xAA, 0x40, 0x9B, 0xFD, 0x96, 0xE4, 0x37, 0x33, 0xBB, 0x2D, 0x5A, 0xD7, 0x5A, 0x11, 0x40, 0x66, 0xA2, 0x76, 0x7D, 0x31, }; static unsigned char dsa512_q[] = { 0xFB, 0x53, 0xEF, 0x50, 0xB4, 0x40, 0x92, 0x31, 0x56, 0x86, 0x53, 0x7A, 0xE8, 0x8B, 0x22, 0x9A, 0x49, 0xFB, 0x71, 0x8F, }; static unsigned char dsa512_g[] = { 0x83, 0x3E, 0x88, 0xE5, 0xC5, 0x89, 0x73, 0xCE, 0x3B, 0x6C, 0x01, 0x49, 0xBF, 0xB3, 0xC7, 0x9F, 0x0A, 0xEA, 0x44, 0x91, 0xE5, 0x30, 0xAA, 0xD9, 0xBE, 0x5B, 0x5F, 0xB7, 0x10, 0xD7, 0x89, 0xB7, 0x8E, 0x74, 0xFB, 0xCF, 0x29, 0x1E, 0xEB, 0xA8, 0x2C, 0x54, 0x51, 0xB8, 0x10, 0xDE, 0xA0, 0xCE, 0x2F, 0xCC, 0x24, 0x6B, 0x90, 0x77, 0xDE, 0xA2, 0x68, 0xA6, 0x52, 0x12, 0xA2, 0x03, 0x9D, 0x20, }; DSA * get_dsa512() { DSA *dsa; if ((dsa = DSA_new()) == NULL) return (NULL); dsa->priv_key = BN_bin2bn(dsa512_priv, sizeof(dsa512_priv), NULL); dsa->pub_key = BN_bin2bn(dsa512_pub, sizeof(dsa512_pub), NULL); dsa->p = BN_bin2bn(dsa512_p, sizeof(dsa512_p), NULL); dsa->q = BN_bin2bn(dsa512_q, sizeof(dsa512_q), NULL); dsa->g = BN_bin2bn(dsa512_g, sizeof(dsa512_g), NULL); if ((dsa->priv_key == NULL) || (dsa->pub_key == NULL) || (dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL)) return (NULL); return (dsa); } static unsigned char dsa1024_priv[] = { 0x7d, 0x21, 0xda, 0xbb, 0x62, 0x15, 0x47, 0x36, 0x07, 0x67, 0x12, 0xe8, 0x8c, 0xaa, 0x1c, 0xcd, 0x38, 0x12, 0x61, 0x18, }; static unsigned char dsa1024_pub[] = { 0x3c, 0x4e, 0x9c, 0x2a, 0x7f, 0x16, 0xc1, 0x25, 0xeb, 0xac, 0x78, 0x63, 0x90, 0x14, 0x8c, 0x8b, 0xf4, 0x68, 0x43, 0x3c, 0x2d, 0xee, 0x65, 0x50, 0x7d, 0x9c, 0x8f, 0x8c, 0x8a, 0x51, 0xd6, 0x11, 0x2b, 0x99, 0xaf, 0x1e, 0x90, 0x97, 0xb5, 0xd3, 0xa6, 0x20, 0x25, 0xd6, 0xfe, 0x43, 0x02, 0xd5, 0x91, 0x7d, 0xa7, 0x8c, 0xdb, 0xc9, 0x85, 0xa3, 0x36, 0x48, 0xf7, 0x68, 0xaa, 0x60, 0xb1, 0xf7, 0x05, 0x68, 0x3a, 0xa3, 0x3f, 0xd3, 0x19, 0x82, 0xd8, 0x82, 0x7a, 0x77, 0xfb, 0xef, 0xf4, 0x15, 0x0a, 0xeb, 0x06, 0x04, 0x7f, 0x53, 0x07, 0x0c, 0xbc, 0xcb, 0x2d, 0x83, 0xdb, 0x3e, 0xd1, 0x28, 0xa5, 0xa1, 0x31, 0xe0, 0x67, 0xfa, 0x50, 0xde, 0x9b, 0x07, 0x83, 0x7e, 0x2c, 0x0b, 0xc3, 0x13, 0x50, 0x61, 0xe5, 0xad, 0xbd, 0x36, 0xb8, 0x97, 0x4e, 0x40, 0x7d, 0xe8, 0x83, 0x0d, 0xbc, 0x4b }; static unsigned char dsa1024_p[] = { 0xA7, 0x3F, 0x6E, 0x85, 0xBF, 0x41, 0x6A, 0x29, 0x7D, 0xF0, 0x9F, 0x47, 0x19, 0x30, 0x90, 0x9A, 0x09, 0x1D, 0xDA, 0x6A, 0x33, 0x1E, 0xC5, 0x3D, 0x86, 0x96, 0xB3, 0x15, 0xE0, 0x53, 0x2E, 0x8F, 0xE0, 0x59, 0x82, 0x73, 0x90, 0x3E, 0x75, 0x31, 0x99, 0x47, 0x7A, 0x52, 0xFB, 0x85, 0xE4, 0xD9, 0xA6, 0x7B, 0x38, 0x9B, 0x68, 0x8A, 0x84, 0x9B, 0x87, 0xC6, 0x1E, 0xB5, 0x7E, 0x86, 0x4B, 0x53, 0x5B, 0x59, 0xCF, 0x71, 0x65, 0x19, 0x88, 0x6E, 0xCE, 0x66, 0xAE, 0x6B, 0x88, 0x36, 0xFB, 0xEC, 0x28, 0xDC, 0xC2, 0xD7, 0xA5, 0xBB, 0xE5, 0x2C, 0x39, 0x26, 0x4B, 0xDA, 0x9A, 0x70, 0x18, 0x95, 0x37, 0x95, 0x10, 0x56, 0x23, 0xF6, 0x15, 0xED, 0xBA, 0x04, 0x5E, 0xDE, 0x39, 0x4F, 0xFD, 0xB7, 0x43, 0x1F, 0xB5, 0xA4, 0x65, 0x6F, 0xCD, 0x80, 0x11, 0xE4, 0x70, 0x95, 0x5B, 0x50, 0xCD, 0x49, }; static unsigned char dsa1024_q[] = { 0xF7, 0x07, 0x31, 0xED, 0xFA, 0x6C, 0x06, 0x03, 0xD5, 0x85, 0x8A, 0x1C, 0xAC, 0x9C, 0x65, 0xE7, 0x50, 0x66, 0x65, 0x6F, }; static unsigned char dsa1024_g[] = { 0x4D, 0xDF, 0x4C, 0x03, 0xA6, 0x91, 0x8A, 0xF5, 0x19, 0x6F, 0x50, 0x46, 0x25, 0x99, 0xE5, 0x68, 0x6F, 0x30, 0xE3, 0x69, 0xE1, 0xE5, 0xB3, 0x5D, 0x98, 0xBB, 0x28, 0x86, 0x48, 0xFC, 0xDE, 0x99, 0x04, 0x3F, 0x5F, 0x88, 0x0C, 0x9C, 0x73, 0x24, 0x0D, 0x20, 0x5D, 0xB9, 0x2A, 0x9A, 0x3F, 0x18, 0x96, 0x27, 0xE4, 0x62, 0x87, 0xC1, 0x7B, 0x74, 0x62, 0x53, 0xFC, 0x61, 0x27, 0xA8, 0x7A, 0x91, 0x09, 0x9D, 0xB6, 0xF1, 0x4D, 0x9C, 0x54, 0x0F, 0x58, 0x06, 0xEE, 0x49, 0x74, 0x07, 0xCE, 0x55, 0x7E, 0x23, 0xCE, 0x16, 0xF6, 0xCA, 0xDC, 0x5A, 0x61, 0x01, 0x7E, 0xC9, 0x71, 0xB5, 0x4D, 0xF6, 0xDC, 0x34, 0x29, 0x87, 0x68, 0xF6, 0x5E, 0x20, 0x93, 0xB3, 0xDB, 0xF5, 0xE4, 0x09, 0x6C, 0x41, 0x17, 0x95, 0x92, 0xEB, 0x01, 0xB5, 0x73, 0xA5, 0x6A, 0x7E, 0xD8, 0x32, 0xED, 0x0E, 0x02, 0xB8, }; DSA * get_dsa1024() { DSA *dsa; if ((dsa = DSA_new()) == NULL) return (NULL); dsa->priv_key = BN_bin2bn(dsa1024_priv, sizeof(dsa1024_priv), NULL); dsa->pub_key = BN_bin2bn(dsa1024_pub, sizeof(dsa1024_pub), NULL); dsa->p = BN_bin2bn(dsa1024_p, sizeof(dsa1024_p), NULL); dsa->q = BN_bin2bn(dsa1024_q, sizeof(dsa1024_q), NULL); dsa->g = BN_bin2bn(dsa1024_g, sizeof(dsa1024_g), NULL); if ((dsa->priv_key == NULL) || (dsa->pub_key == NULL) || (dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL)) return (NULL); return (dsa); } static unsigned char dsa2048_priv[] = { 0x32, 0x67, 0x92, 0xf6, 0xc4, 0xe2, 0xe2, 0xe8, 0xa0, 0x8b, 0x6b, 0x45, 0x0c, 0x8a, 0x76, 0xb0, 0xee, 0xcf, 0x91, 0xa7, }; static unsigned char dsa2048_pub[] = { 0x17, 0x8f, 0xa8, 0x11, 0x84, 0x92, 0xec, 0x83, 0x47, 0xc7, 0x6a, 0xb0, 0x92, 0xaf, 0x5a, 0x20, 0x37, 0xa3, 0x64, 0x79, 0xd2, 0xd0, 0x3d, 0xcd, 0xe0, 0x61, 0x88, 0x88, 0x21, 0xcc, 0x74, 0x5d, 0xce, 0x4c, 0x51, 0x47, 0xf0, 0xc5, 0x5c, 0x4c, 0x82, 0x7a, 0xaf, 0x72, 0xad, 0xb9, 0xe0, 0x53, 0xf2, 0x78, 0xb7, 0xf0, 0xb5, 0x48, 0x7f, 0x8a, 0x3a, 0x18, 0xd1, 0x9f, 0x8b, 0x7d, 0xa5, 0x47, 0xb7, 0x95, 0xab, 0x98, 0xf8, 0x7b, 0x74, 0x50, 0x56, 0x8e, 0x57, 0xf0, 0xee, 0xf5, 0xb7, 0xba, 0xab, 0x85, 0x86, 0xf9, 0x2b, 0xef, 0x41, 0x56, 0xa0, 0xa4, 0x9f, 0xb7, 0x38, 0x00, 0x46, 0x0a, 0xa6, 0xf1, 0xfc, 0x1f, 0xd8, 0x4e, 0x85, 0x44, 0x92, 0x43, 0x21, 0x5d, 0x6e, 0xcc, 0xc2, 0xcb, 0x26, 0x31, 0x0d, 0x21, 0xc4, 0xbd, 0x8d, 0x24, 0xbc, 0xd9, 0x18, 0x19, 0xd7, 0xdc, 0xf1, 0xe7, 0x93, 0x50, 0x48, 0x03, 0x2c, 0xae, 0x2e, 0xe7, 0x49, 0x88, 0x5f, 0x93, 0x57, 0x27, 0x99, 0x36, 0xb4, 0x20, 0xab, 0xfc, 0xa7, 0x2b, 0xf2, 0xd9, 0x98, 0xd7, 0xd4, 0x34, 0x9d, 0x96, 0x50, 0x58, 0x9a, 0xea, 0x54, 0xf3, 0xee, 0xf5, 0x63, 0x14, 0xee, 0x85, 0x83, 0x74, 0x76, 0xe1, 0x52, 0x95, 0xc3, 0xf7, 0xeb, 0x04, 0x04, 0x7b, 0xa7, 0x28, 0x1b, 0xcc, 0xea, 0x4a, 0x4e, 0x84, 0xda, 0xd8, 0x9c, 0x79, 0xd8, 0x9b, 0x66, 0x89, 0x2f, 0xcf, 0xac, 0xd7, 0x79, 0xf9, 0xa9, 0xd8, 0x45, 0x13, 0x78, 0xb9, 0x00, 0x14, 0xc9, 0x7e, 0x22, 0x51, 0x86, 0x67, 0xb0, 0x9f, 0x26, 0x11, 0x23, 0xc8, 0x38, 0xd7, 0x70, 0x1d, 0x15, 0x8e, 0x4d, 0x4f, 0x95, 0x97, 0x40, 0xa1, 0xc2, 0x7e, 0x01, 0x18, 0x72, 0xf4, 0x10, 0xe6, 0x8d, 0x52, 0x16, 0x7f, 0xf2, 0xc9, 0xf8, 0x33, 0x8b, 0x33, 0xb7, 0xce, }; static unsigned char dsa2048_p[] = { 0xA0, 0x25, 0xFA, 0xAD, 0xF4, 0x8E, 0xB9, 0xE5, 0x99, 0xF3, 0x5D, 0x6F, 0x4F, 0x83, 0x34, 0xE2, 0x7E, 0xCF, 0x6F, 0xBF, 0x30, 0xAF, 0x6F, 0x81, 0xEB, 0xF8, 0xC4, 0x13, 0xD9, 0xA0, 0x5D, 0x8B, 0x5C, 0x8E, 0xDC, 0xC2, 0x1D, 0x0B, 0x41, 0x32, 0xB0, 0x1F, 0xFE, 0xEF, 0x0C, 0xC2, 0xA2, 0x7E, 0x68, 0x5C, 0x28, 0x21, 0xE9, 0xF5, 0xB1, 0x58, 0x12, 0x63, 0x4C, 0x19, 0x4E, 0xFF, 0x02, 0x4B, 0x92, 0xED, 0xD2, 0x07, 0x11, 0x4D, 0x8C, 0x58, 0x16, 0x5C, 0x55, 0x8E, 0xAD, 0xA3, 0x67, 0x7D, 0xB9, 0x86, 0x6E, 0x0B, 0xE6, 0x54, 0x6F, 0x40, 0xAE, 0x0E, 0x67, 0x4C, 0xF9, 0x12, 0x5B, 0x3C, 0x08, 0x7A, 0xF7, 0xFC, 0x67, 0x86, 0x69, 0xE7, 0x0A, 0x94, 0x40, 0xBF, 0x8B, 0x76, 0xFE, 0x26, 0xD1, 0xF2, 0xA1, 0x1A, 0x84, 0xA1, 0x43, 0x56, 0x28, 0xBC, 0x9A, 0x5F, 0xD7, 0x3B, 0x69, 0x89, 0x8A, 0x36, 0x2C, 0x51, 0xDF, 0x12, 0x77, 0x2F, 0x57, 0x7B, 0xA0, 0xAA, 0xDD, 0x7F, 0xA1, 0x62, 0x3B, 0x40, 0x7B, 0x68, 0x1A, 0x8F, 0x0D, 0x38, 0xBB, 0x21, 0x5D, 0x18, 0xFC, 0x0F, 0x46, 0xF7, 0xA3, 0xB0, 0x1D, 0x23, 0xC3, 0xD2, 0xC7, 0x72, 0x51, 0x18, 0xDF, 0x46, 0x95, 0x79, 0xD9, 0xBD, 0xB5, 0x19, 0x02, 0x2C, 0x87, 0xDC, 0xE7, 0x57, 0x82, 0x7E, 0xF1, 0x8B, 0x06, 0x3D, 0x00, 0xA5, 0x7B, 0x6B, 0x26, 0x27, 0x91, 0x0F, 0x6A, 0x77, 0xE4, 0xD5, 0x04, 0xE4, 0x12, 0x2C, 0x42, 0xFF, 0xD2, 0x88, 0xBB, 0xD3, 0x92, 0xA0, 0xF9, 0xC8, 0x51, 0x64, 0x14, 0x5C, 0xD8, 0xF9, 0x6C, 0x47, 0x82, 0xB4, 0x1C, 0x7F, 0x09, 0xB8, 0xF0, 0x25, 0x83, 0x1D, 0x3F, 0x3F, 0x05, 0xB3, 0x21, 0x0A, 0x5D, 0xA7, 0xD8, 0x54, 0xC3, 0x65, 0x7D, 0xC3, 0xB0, 0x1D, 0xBF, 0xAE, 0xF8, 0x68, 0xCF, 0x9B, }; static unsigned char dsa2048_q[] = { 0x97, 0xE7, 0x33, 0x4D, 0xD3, 0x94, 0x3E, 0x0B, 0xDB, 0x62, 0x74, 0xC6, 0xA1, 0x08, 0xDD, 0x19, 0xA3, 0x75, 0x17, 0x1B, }; static unsigned char dsa2048_g[] = { 0x2C, 0x78, 0x16, 0x59, 0x34, 0x63, 0xF4, 0xF3, 0x92, 0xFC, 0xB5, 0xA5, 0x4F, 0x13, 0xDE, 0x2F, 0x1C, 0xA4, 0x3C, 0xAE, 0xAD, 0x38, 0x3F, 0x7E, 0x90, 0xBF, 0x96, 0xA6, 0xAE, 0x25, 0x90, 0x72, 0xF5, 0x8E, 0x80, 0x0C, 0x39, 0x1C, 0xD9, 0xEC, 0xBA, 0x90, 0x5B, 0x3A, 0xE8, 0x58, 0x6C, 0x9E, 0x30, 0x42, 0x37, 0x02, 0x31, 0x82, 0xBC, 0x6A, 0xDF, 0x6A, 0x09, 0x29, 0xE3, 0xC0, 0x46, 0xD1, 0xCB, 0x85, 0xEC, 0x0C, 0x30, 0x5E, 0xEA, 0xC8, 0x39, 0x8E, 0x22, 0x9F, 0x22, 0x10, 0xD2, 0x34, 0x61, 0x68, 0x37, 0x3D, 0x2E, 0x4A, 0x5B, 0x9A, 0xF5, 0xC1, 0x48, 0xC6, 0xF6, 0xDC, 0x63, 0x1A, 0xD3, 0x96, 0x64, 0xBA, 0x34, 0xC9, 0xD1, 0xA0, 0xD1, 0xAE, 0x6C, 0x2F, 0x48, 0x17, 0x93, 0x14, 0x43, 0xED, 0xF0, 0x21, 0x30, 0x19, 0xC3, 0x1B, 0x5F, 0xDE, 0xA3, 0xF0, 0x70, 0x78, 0x18, 0xE1, 0xA8, 0xE4, 0xEE, 0x2E, 0x00, 0xA5, 0xE4, 0xB3, 0x17, 0xC8, 0x0C, 0x7D, 0x6E, 0x42, 0xDC, 0xB7, 0x46, 0x00, 0x36, 0x4D, 0xD4, 0x46, 0xAA, 0x3D, 0x3C, 0x46, 0x89, 0x40, 0xBF, 0x1D, 0x84, 0x77, 0x0A, 0x75, 0xF3, 0x87, 0x1D, 0x08, 0x4C, 0xA6, 0xD1, 0xA9, 0x1C, 0x1E, 0x12, 0x1E, 0xE1, 0xC7, 0x30, 0x28, 0x76, 0xA5, 0x7F, 0x6C, 0x85, 0x96, 0x2B, 0x6F, 0xDB, 0x80, 0x66, 0x26, 0xAE, 0xF5, 0x93, 0xC7, 0x8E, 0xAE, 0x9A, 0xED, 0xE4, 0xCA, 0x04, 0xEA, 0x3B, 0x72, 0xEF, 0xDC, 0x87, 0xED, 0x0D, 0xA5, 0x4C, 0x4A, 0xDD, 0x71, 0x22, 0x64, 0x59, 0x69, 0x4E, 0x8E, 0xBF, 0x43, 0xDC, 0xAB, 0x8E, 0x66, 0xBB, 0x01, 0xB6, 0xF4, 0xE7, 0xFD, 0xD2, 0xAD, 0x9F, 0x36, 0xC1, 0xA0, 0x29, 0x99, 0xD1, 0x96, 0x70, 0x59, 0x06, 0x78, 0x35, 0xBD, 0x65, 0x55, 0x52, 0x9E, 0xF8, 0xB2, 0xE5, 0x38, }; DSA * get_dsa2048() { DSA *dsa; if ((dsa = DSA_new()) == NULL) return (NULL); dsa->priv_key = BN_bin2bn(dsa2048_priv, sizeof(dsa2048_priv), NULL); dsa->pub_key = BN_bin2bn(dsa2048_pub, sizeof(dsa2048_pub), NULL); dsa->p = BN_bin2bn(dsa2048_p, sizeof(dsa2048_p), NULL); dsa->q = BN_bin2bn(dsa2048_q, sizeof(dsa2048_q), NULL); dsa->g = BN_bin2bn(dsa2048_g, sizeof(dsa2048_g), NULL); if ((dsa->priv_key == NULL) || (dsa->pub_key == NULL) || (dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL)) return (NULL); return (dsa); } deps/libressl-pnacl-sys-2.1.6/libressl/apps/Makefile.am0000644000175000017500000000343312360020707017737 0ustar include $(top_srcdir)/Makefile.am.common bin_PROGRAMS = openssl openssl_CFLAGS = $(USER_CFLAGS) openssl_LDADD = $(PLATFORM_LDADD) openssl_LDADD += $(top_builddir)/crypto/libcrypto.la openssl_LDADD += $(top_builddir)/ssl/libssl.la openssl_SOURCES = noinst_HEADERS = if NO_STRTONUM openssl_SOURCES += strtonum.c endif openssl_SOURCES += apps.c openssl_SOURCES += asn1pars.c openssl_SOURCES += ca.c openssl_SOURCES += ciphers.c openssl_SOURCES += cms.c openssl_SOURCES += crl.c openssl_SOURCES += crl2p7.c openssl_SOURCES += dgst.c openssl_SOURCES += dh.c openssl_SOURCES += dhparam.c openssl_SOURCES += dsa.c openssl_SOURCES += dsaparam.c openssl_SOURCES += ec.c openssl_SOURCES += ecparam.c openssl_SOURCES += enc.c openssl_SOURCES += engine.c openssl_SOURCES += errstr.c openssl_SOURCES += gendh.c openssl_SOURCES += gendsa.c openssl_SOURCES += genpkey.c openssl_SOURCES += genrsa.c openssl_SOURCES += nseq.c openssl_SOURCES += ocsp.c openssl_SOURCES += openssl.c openssl_SOURCES += passwd.c openssl_SOURCES += pkcs12.c openssl_SOURCES += pkcs7.c openssl_SOURCES += pkcs8.c openssl_SOURCES += pkey.c openssl_SOURCES += pkeyparam.c openssl_SOURCES += pkeyutl.c openssl_SOURCES += prime.c openssl_SOURCES += rand.c openssl_SOURCES += req.c openssl_SOURCES += rsa.c openssl_SOURCES += rsautl.c openssl_SOURCES += s_cb.c openssl_SOURCES += s_client.c openssl_SOURCES += s_server.c openssl_SOURCES += s_socket.c openssl_SOURCES += s_time.c openssl_SOURCES += sess_id.c openssl_SOURCES += smime.c openssl_SOURCES += speed.c openssl_SOURCES += spkac.c openssl_SOURCES += ts.c openssl_SOURCES += verify.c openssl_SOURCES += version.c openssl_SOURCES += x509.c noinst_HEADERS += apps.h noinst_HEADERS += progs.h noinst_HEADERS += s_apps.h noinst_HEADERS += testdsa.h noinst_HEADERS += testrsa.h noinst_HEADERS += timeouts.h deps/libressl-pnacl-sys-2.1.6/libressl/apps/crl.c0000644000175000017500000002673112360020706016634 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include "apps.h" #include #include #include #include #include #define POSTFIX ".rvk" static const char *crl_usage[] = { "usage: crl args\n", "\n", " -inform arg - input format - default PEM (DER or PEM)\n", " -outform arg - output format - default PEM\n", " -text - print out a text format version\n", " -in arg - input file - default stdin\n", " -out arg - output file - default stdout\n", " -hash - print hash value\n", #ifndef OPENSSL_NO_MD5 " -hash_old - print old-style (MD5) hash value\n", #endif " -fingerprint - print the crl fingerprint\n", " -issuer - print issuer DN\n", " -lastupdate - lastUpdate field\n", " -nextupdate - nextUpdate field\n", " -crlnumber - print CRL number\n", " -noout - no CRL output\n", " -CAfile name - verify CRL using certificates in file \"name\"\n", " -CApath dir - verify CRL using certificates in \"dir\"\n", " -nameopt arg - various certificate name options\n", NULL }; static X509_CRL *load_crl(char *file, int format); static BIO *bio_out = NULL; int crl_main(int, char **); int crl_main(int argc, char **argv) { unsigned long nmflag = 0; X509_CRL *x = NULL; char *CAfile = NULL, *CApath = NULL; int ret = 1, i, num, badops = 0; BIO *out = NULL; int informat, outformat; char *infile = NULL, *outfile = NULL; int hash = 0, issuer = 0, lastupdate = 0, nextupdate = 0, noout = 0, text = 0; #ifndef OPENSSL_NO_MD5 int hash_old = 0; #endif int fingerprint = 0, crlnumber = 0; const char **pp; X509_STORE *store = NULL; X509_STORE_CTX ctx; X509_LOOKUP *lookup = NULL; X509_OBJECT xobj; EVP_PKEY *pkey; int do_ver = 0; const EVP_MD *md_alg, *digest = EVP_sha1(); if (!load_config(bio_err, NULL)) goto end; if (bio_out == NULL) if ((bio_out = BIO_new(BIO_s_file())) != NULL) { BIO_set_fp(bio_out, stdout, BIO_NOCLOSE); } informat = FORMAT_PEM; outformat = FORMAT_PEM; argc--; argv++; num = 0; while (argc >= 1) { #ifdef undef if (strcmp(*argv, "-p") == 0) { if (--argc < 1) goto bad; if (!args_from_file(++argv, Nargc, Nargv)) { goto end; } } #endif if (strcmp(*argv, "-inform") == 0) { if (--argc < 1) goto bad; informat = str2fmt(*(++argv)); } else if (strcmp(*argv, "-outform") == 0) { if (--argc < 1) goto bad; outformat = str2fmt(*(++argv)); } else if (strcmp(*argv, "-in") == 0) { if (--argc < 1) goto bad; infile = *(++argv); } else if (strcmp(*argv, "-out") == 0) { if (--argc < 1) goto bad; outfile = *(++argv); } else if (strcmp(*argv, "-CApath") == 0) { if (--argc < 1) goto bad; CApath = *(++argv); do_ver = 1; } else if (strcmp(*argv, "-CAfile") == 0) { if (--argc < 1) goto bad; CAfile = *(++argv); do_ver = 1; } else if (strcmp(*argv, "-verify") == 0) do_ver = 1; else if (strcmp(*argv, "-text") == 0) text = 1; else if (strcmp(*argv, "-hash") == 0) hash = ++num; #ifndef OPENSSL_NO_MD5 else if (strcmp(*argv, "-hash_old") == 0) hash_old = ++num; #endif else if (strcmp(*argv, "-nameopt") == 0) { if (--argc < 1) goto bad; if (!set_name_ex(&nmflag, *(++argv))) goto bad; } else if (strcmp(*argv, "-issuer") == 0) issuer = ++num; else if (strcmp(*argv, "-lastupdate") == 0) lastupdate = ++num; else if (strcmp(*argv, "-nextupdate") == 0) nextupdate = ++num; else if (strcmp(*argv, "-noout") == 0) noout = ++num; else if (strcmp(*argv, "-fingerprint") == 0) fingerprint = ++num; else if (strcmp(*argv, "-crlnumber") == 0) crlnumber = ++num; else if ((md_alg = EVP_get_digestbyname(*argv + 1))) { /* ok */ digest = md_alg; } else { BIO_printf(bio_err, "unknown option %s\n", *argv); badops = 1; break; } argc--; argv++; } if (badops) { bad: for (pp = crl_usage; (*pp != NULL); pp++) BIO_printf(bio_err, "%s", *pp); goto end; } ERR_load_crypto_strings(); x = load_crl(infile, informat); if (x == NULL) { goto end; } if (do_ver) { store = X509_STORE_new(); lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file()); if (lookup == NULL) goto end; if (!X509_LOOKUP_load_file(lookup, CAfile, X509_FILETYPE_PEM)) X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT); lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir()); if (lookup == NULL) goto end; if (!X509_LOOKUP_add_dir(lookup, CApath, X509_FILETYPE_PEM)) X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT); ERR_clear_error(); if (!X509_STORE_CTX_init(&ctx, store, NULL, NULL)) { BIO_printf(bio_err, "Error initialising X509 store\n"); goto end; } i = X509_STORE_get_by_subject(&ctx, X509_LU_X509, X509_CRL_get_issuer(x), &xobj); if (i <= 0) { BIO_printf(bio_err, "Error getting CRL issuer certificate\n"); goto end; } pkey = X509_get_pubkey(xobj.data.x509); X509_OBJECT_free_contents(&xobj); if (!pkey) { BIO_printf(bio_err, "Error getting CRL issuer public key\n"); goto end; } i = X509_CRL_verify(x, pkey); EVP_PKEY_free(pkey); if (i < 0) goto end; if (i == 0) BIO_printf(bio_err, "verify failure\n"); else BIO_printf(bio_err, "verify OK\n"); } if (num) { for (i = 1; i <= num; i++) { if (issuer == i) { print_name(bio_out, "issuer=", X509_CRL_get_issuer(x), nmflag); } if (crlnumber == i) { ASN1_INTEGER *crlnum; crlnum = X509_CRL_get_ext_d2i(x, NID_crl_number, NULL, NULL); BIO_printf(bio_out, "crlNumber="); if (crlnum) { i2a_ASN1_INTEGER(bio_out, crlnum); ASN1_INTEGER_free(crlnum); } else BIO_puts(bio_out, ""); BIO_printf(bio_out, "\n"); } if (hash == i) { BIO_printf(bio_out, "%08lx\n", X509_NAME_hash(X509_CRL_get_issuer(x))); } #ifndef OPENSSL_NO_MD5 if (hash_old == i) { BIO_printf(bio_out, "%08lx\n", X509_NAME_hash_old(X509_CRL_get_issuer(x))); } #endif if (lastupdate == i) { BIO_printf(bio_out, "lastUpdate="); ASN1_TIME_print(bio_out, X509_CRL_get_lastUpdate(x)); BIO_printf(bio_out, "\n"); } if (nextupdate == i) { BIO_printf(bio_out, "nextUpdate="); if (X509_CRL_get_nextUpdate(x)) ASN1_TIME_print(bio_out, X509_CRL_get_nextUpdate(x)); else BIO_printf(bio_out, "NONE"); BIO_printf(bio_out, "\n"); } if (fingerprint == i) { int j; unsigned int n; unsigned char md[EVP_MAX_MD_SIZE]; if (!X509_CRL_digest(x, digest, md, &n)) { BIO_printf(bio_err, "out of memory\n"); goto end; } BIO_printf(bio_out, "%s Fingerprint=", OBJ_nid2sn(EVP_MD_type(digest))); for (j = 0; j < (int) n; j++) { BIO_printf(bio_out, "%02X%c", md[j], (j + 1 == (int)n) ? '\n' : ':'); } } } } out = BIO_new(BIO_s_file()); if (out == NULL) { ERR_print_errors(bio_err); goto end; } if (outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { if (BIO_write_filename(out, outfile) <= 0) { perror(outfile); goto end; } } if (text) X509_CRL_print(out, x); if (noout) { ret = 0; goto end; } if (outformat == FORMAT_ASN1) i = (int) i2d_X509_CRL_bio(out, x); else if (outformat == FORMAT_PEM) i = PEM_write_bio_X509_CRL(out, x); else { BIO_printf(bio_err, "bad output format specified for outfile\n"); goto end; } if (!i) { BIO_printf(bio_err, "unable to write CRL\n"); goto end; } ret = 0; end: BIO_free_all(out); BIO_free_all(bio_out); bio_out = NULL; X509_CRL_free(x); if (store) { X509_STORE_CTX_cleanup(&ctx); X509_STORE_free(store); } return (ret); } static X509_CRL * load_crl(char *infile, int format) { X509_CRL *x = NULL; BIO *in = NULL; in = BIO_new(BIO_s_file()); if (in == NULL) { ERR_print_errors(bio_err); goto end; } if (infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { if (BIO_read_filename(in, infile) <= 0) { perror(infile); goto end; } } if (format == FORMAT_ASN1) x = d2i_X509_CRL_bio(in, NULL); else if (format == FORMAT_PEM) x = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL); else { BIO_printf(bio_err, "bad input format specified for input crl\n"); goto end; } if (x == NULL) { BIO_printf(bio_err, "unable to load CRL\n"); ERR_print_errors(bio_err); goto end; } end: BIO_free(in); return (x); } deps/libressl-pnacl-sys-2.1.6/libressl/apps/ocsp.c0000644000175000017500000010154112360020706017011 0ustar /* $OpenBSD: ocsp.c,v 1.26 2014/06/12 15:49:27 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #ifndef OPENSSL_NO_OCSP #include #include #include #include #include /* Needs to be included before the openssl headers! */ #include "apps.h" #include #include #include #include #include #include /* Maximum leeway in validity period: default 5 minutes */ #define MAX_VALIDITY_PERIOD (5 * 60) static int add_ocsp_cert(OCSP_REQUEST ** req, X509 * cert, const EVP_MD * cert_id_md, X509 * issuer, STACK_OF(OCSP_CERTID) * ids); static int add_ocsp_serial(OCSP_REQUEST ** req, char *serial, const EVP_MD * cert_id_md, X509 * issuer, STACK_OF(OCSP_CERTID) * ids); static int print_ocsp_summary(BIO * out, OCSP_BASICRESP * bs, OCSP_REQUEST * req, STACK_OF(OPENSSL_STRING) * names, STACK_OF(OCSP_CERTID) * ids, long nsec, long maxage); static int make_ocsp_response(OCSP_RESPONSE ** resp, OCSP_REQUEST * req, CA_DB * db, X509 * ca, X509 * rcert, EVP_PKEY * rkey, STACK_OF(X509) * rother, unsigned long flags, int nmin, int ndays); static char **lookup_serial(CA_DB * db, ASN1_INTEGER * ser); static BIO *init_responder(char *port); static int do_responder(OCSP_REQUEST ** preq, BIO ** pcbio, BIO * acbio, char *port); static int send_ocsp_response(BIO * cbio, OCSP_RESPONSE * resp); static OCSP_RESPONSE *query_responder(BIO * err, BIO * cbio, char *path, STACK_OF(CONF_VALUE) * headers, OCSP_REQUEST * req, int req_timeout); int ocsp_main(int, char **); int ocsp_main(int argc, char **argv) { ENGINE *e = NULL; char **args; char *host = NULL, *port = NULL, *path = "/"; char *reqin = NULL, *respin = NULL; char *reqout = NULL, *respout = NULL; char *signfile = NULL, *keyfile = NULL; char *rsignfile = NULL, *rkeyfile = NULL; char *outfile = NULL; int add_nonce = 1, noverify = 0, use_ssl = -1; STACK_OF(CONF_VALUE) * headers = NULL; OCSP_REQUEST *req = NULL; OCSP_RESPONSE *resp = NULL; OCSP_BASICRESP *bs = NULL; X509 *issuer = NULL, *cert = NULL; X509 *signer = NULL, *rsigner = NULL; EVP_PKEY *key = NULL, *rkey = NULL; BIO *acbio = NULL, *cbio = NULL; BIO *derbio = NULL; BIO *out = NULL; int req_timeout = -1; int req_text = 0, resp_text = 0; long nsec = MAX_VALIDITY_PERIOD, maxage = -1; char *CAfile = NULL, *CApath = NULL; X509_STORE *store = NULL; STACK_OF(X509) * sign_other = NULL, *verify_other = NULL, *rother = NULL; char *sign_certfile = NULL, *verify_certfile = NULL, *rcertfile = NULL; unsigned long sign_flags = 0, verify_flags = 0, rflags = 0; int ret = 1; int accept_count = -1; int badarg = 0; int i; int ignore_err = 0; STACK_OF(OPENSSL_STRING) * reqnames = NULL; STACK_OF(OCSP_CERTID) * ids = NULL; X509 *rca_cert = NULL; char *ridx_filename = NULL; char *rca_filename = NULL; CA_DB *rdb = NULL; int nmin = 0, ndays = -1; const EVP_MD *cert_id_md = NULL; const char *errstr = NULL; if (!load_config(bio_err, NULL)) goto end; SSL_load_error_strings(); OpenSSL_add_ssl_algorithms(); args = argv + 1; reqnames = sk_OPENSSL_STRING_new_null(); ids = sk_OCSP_CERTID_new_null(); while (!badarg && *args && *args[0] == '-') { if (!strcmp(*args, "-out")) { if (args[1]) { args++; outfile = *args; } else badarg = 1; } else if (!strcmp(*args, "-timeout")) { if (args[1]) { args++; req_timeout = strtonum(*args, 0, INT_MAX, &errstr); if (errstr) { BIO_printf(bio_err, "Illegal timeout value %s: %s\n", *args, errstr); badarg = 1; } } else badarg = 1; } else if (!strcmp(*args, "-url")) { if (args[1]) { args++; if (!OCSP_parse_url(*args, &host, &port, &path, &use_ssl)) { BIO_printf(bio_err, "Error parsing URL\n"); badarg = 1; } } else badarg = 1; } else if (!strcmp(*args, "-host")) { if (args[1]) { args++; host = *args; } else badarg = 1; } else if (!strcmp(*args, "-port")) { if (args[1]) { args++; port = *args; } else badarg = 1; } else if (!strcmp(*args, "-header")) { if (args[1] && args[2]) { if (!X509V3_add_value(args[1], args[2], &headers)) goto end; args += 2; } else badarg = 1; } else if (!strcmp(*args, "-ignore_err")) ignore_err = 1; else if (!strcmp(*args, "-noverify")) noverify = 1; else if (!strcmp(*args, "-nonce")) add_nonce = 2; else if (!strcmp(*args, "-no_nonce")) add_nonce = 0; else if (!strcmp(*args, "-resp_no_certs")) rflags |= OCSP_NOCERTS; else if (!strcmp(*args, "-resp_key_id")) rflags |= OCSP_RESPID_KEY; else if (!strcmp(*args, "-no_certs")) sign_flags |= OCSP_NOCERTS; else if (!strcmp(*args, "-no_signature_verify")) verify_flags |= OCSP_NOSIGS; else if (!strcmp(*args, "-no_cert_verify")) verify_flags |= OCSP_NOVERIFY; else if (!strcmp(*args, "-no_chain")) verify_flags |= OCSP_NOCHAIN; else if (!strcmp(*args, "-no_cert_checks")) verify_flags |= OCSP_NOCHECKS; else if (!strcmp(*args, "-no_explicit")) verify_flags |= OCSP_NOEXPLICIT; else if (!strcmp(*args, "-trust_other")) verify_flags |= OCSP_TRUSTOTHER; else if (!strcmp(*args, "-no_intern")) verify_flags |= OCSP_NOINTERN; else if (!strcmp(*args, "-text")) { req_text = 1; resp_text = 1; } else if (!strcmp(*args, "-req_text")) req_text = 1; else if (!strcmp(*args, "-resp_text")) resp_text = 1; else if (!strcmp(*args, "-reqin")) { if (args[1]) { args++; reqin = *args; } else badarg = 1; } else if (!strcmp(*args, "-respin")) { if (args[1]) { args++; respin = *args; } else badarg = 1; } else if (!strcmp(*args, "-signer")) { if (args[1]) { args++; signfile = *args; } else badarg = 1; } else if (!strcmp(*args, "-VAfile")) { if (args[1]) { args++; verify_certfile = *args; verify_flags |= OCSP_TRUSTOTHER; } else badarg = 1; } else if (!strcmp(*args, "-sign_other")) { if (args[1]) { args++; sign_certfile = *args; } else badarg = 1; } else if (!strcmp(*args, "-verify_other")) { if (args[1]) { args++; verify_certfile = *args; } else badarg = 1; } else if (!strcmp(*args, "-CAfile")) { if (args[1]) { args++; CAfile = *args; } else badarg = 1; } else if (!strcmp(*args, "-CApath")) { if (args[1]) { args++; CApath = *args; } else badarg = 1; } else if (!strcmp(*args, "-validity_period")) { if (args[1]) { args++; nsec = strtonum(*args, 0, LONG_MAX, &errstr); if (errstr) { BIO_printf(bio_err, "Illegal validity period %s: %s\n", *args, errstr); badarg = 1; } } else badarg = 1; } else if (!strcmp(*args, "-status_age")) { if (args[1]) { args++; maxage = strtonum(*args, 0, LONG_MAX, &errstr); if (errstr) { BIO_printf(bio_err, "Illegal validity age %s: %s\n", *args, errstr); badarg = 1; } } else badarg = 1; } else if (!strcmp(*args, "-signkey")) { if (args[1]) { args++; keyfile = *args; } else badarg = 1; } else if (!strcmp(*args, "-reqout")) { if (args[1]) { args++; reqout = *args; } else badarg = 1; } else if (!strcmp(*args, "-respout")) { if (args[1]) { args++; respout = *args; } else badarg = 1; } else if (!strcmp(*args, "-path")) { if (args[1]) { args++; path = *args; } else badarg = 1; } else if (!strcmp(*args, "-issuer")) { if (args[1]) { args++; X509_free(issuer); issuer = load_cert(bio_err, *args, FORMAT_PEM, NULL, e, "issuer certificate"); if (!issuer) goto end; } else badarg = 1; } else if (!strcmp(*args, "-cert")) { if (args[1]) { args++; X509_free(cert); cert = load_cert(bio_err, *args, FORMAT_PEM, NULL, e, "certificate"); if (!cert) goto end; if (!cert_id_md) cert_id_md = EVP_sha1(); if (!add_ocsp_cert(&req, cert, cert_id_md, issuer, ids)) goto end; if (!sk_OPENSSL_STRING_push(reqnames, *args)) goto end; } else badarg = 1; } else if (!strcmp(*args, "-serial")) { if (args[1]) { args++; if (!cert_id_md) cert_id_md = EVP_sha1(); if (!add_ocsp_serial(&req, *args, cert_id_md, issuer, ids)) goto end; if (!sk_OPENSSL_STRING_push(reqnames, *args)) goto end; } else badarg = 1; } else if (!strcmp(*args, "-index")) { if (args[1]) { args++; ridx_filename = *args; } else badarg = 1; } else if (!strcmp(*args, "-CA")) { if (args[1]) { args++; rca_filename = *args; } else badarg = 1; } else if (!strcmp(*args, "-nmin")) { if (args[1]) { args++; nmin = strtonum(*args, 0, INT_MAX, &errstr); if (errstr) { BIO_printf(bio_err, "Illegal update period %s: %s\n", *args, errstr); badarg = 1; } } if (ndays == -1) ndays = 0; else badarg = 1; } else if (!strcmp(*args, "-nrequest")) { if (args[1]) { args++; accept_count = strtonum(*args, 0, INT_MAX, &errstr); if (errstr) { BIO_printf(bio_err, "Illegal accept count %s: %s\n", *args, errstr); badarg = 1; } } else badarg = 1; } else if (!strcmp(*args, "-ndays")) { if (args[1]) { args++; ndays = strtonum(*args, 0, INT_MAX, &errstr); if (errstr) { BIO_printf(bio_err, "Illegal update period %s: %s\n", *args, errstr); badarg = 1; } } else badarg = 1; } else if (!strcmp(*args, "-rsigner")) { if (args[1]) { args++; rsignfile = *args; } else badarg = 1; } else if (!strcmp(*args, "-rkey")) { if (args[1]) { args++; rkeyfile = *args; } else badarg = 1; } else if (!strcmp(*args, "-rother")) { if (args[1]) { args++; rcertfile = *args; } else badarg = 1; } else if ((cert_id_md = EVP_get_digestbyname((*args) + 1)) == NULL) { badarg = 1; } args++; } /* Have we anything to do? */ if (!req && !reqin && !respin && !(port && ridx_filename)) badarg = 1; if (badarg) { BIO_printf(bio_err, "OCSP utility\n"); BIO_printf(bio_err, "Usage ocsp [options]\n"); BIO_printf(bio_err, "where options are\n"); BIO_printf(bio_err, "-out file output filename\n"); BIO_printf(bio_err, "-issuer file issuer certificate\n"); BIO_printf(bio_err, "-cert file certificate to check\n"); BIO_printf(bio_err, "-serial n serial number to check\n"); BIO_printf(bio_err, "-signer file certificate to sign OCSP request with\n"); BIO_printf(bio_err, "-signkey file private key to sign OCSP request with\n"); BIO_printf(bio_err, "-sign_other file additional certificates to include in signed request\n"); BIO_printf(bio_err, "-no_certs don't include any certificates in signed request\n"); BIO_printf(bio_err, "-req_text print text form of request\n"); BIO_printf(bio_err, "-resp_text print text form of response\n"); BIO_printf(bio_err, "-text print text form of request and response\n"); BIO_printf(bio_err, "-reqout file write DER encoded OCSP request to \"file\"\n"); BIO_printf(bio_err, "-respout file write DER encoded OCSP reponse to \"file\"\n"); BIO_printf(bio_err, "-reqin file read DER encoded OCSP request from \"file\"\n"); BIO_printf(bio_err, "-respin file read DER encoded OCSP reponse from \"file\"\n"); BIO_printf(bio_err, "-nonce add OCSP nonce to request\n"); BIO_printf(bio_err, "-no_nonce don't add OCSP nonce to request\n"); BIO_printf(bio_err, "-url URL OCSP responder URL\n"); BIO_printf(bio_err, "-host host:n send OCSP request to host on port n\n"); BIO_printf(bio_err, "-path path to use in OCSP request\n"); BIO_printf(bio_err, "-CApath dir trusted certificates directory\n"); BIO_printf(bio_err, "-CAfile file trusted certificates file\n"); BIO_printf(bio_err, "-VAfile file validator certificates file\n"); BIO_printf(bio_err, "-validity_period n maximum validity discrepancy in seconds\n"); BIO_printf(bio_err, "-status_age n maximum status age in seconds\n"); BIO_printf(bio_err, "-noverify don't verify response at all\n"); BIO_printf(bio_err, "-verify_other file additional certificates to search for signer\n"); BIO_printf(bio_err, "-trust_other don't verify additional certificates\n"); BIO_printf(bio_err, "-no_intern don't search certificates contained in response for signer\n"); BIO_printf(bio_err, "-no_signature_verify don't check signature on response\n"); BIO_printf(bio_err, "-no_cert_verify don't check signing certificate\n"); BIO_printf(bio_err, "-no_chain don't chain verify response\n"); BIO_printf(bio_err, "-no_cert_checks don't do additional checks on signing certificate\n"); BIO_printf(bio_err, "-port num port to run responder on\n"); BIO_printf(bio_err, "-index file certificate status index file\n"); BIO_printf(bio_err, "-CA file CA certificate\n"); BIO_printf(bio_err, "-rsigner file responder certificate to sign responses with\n"); BIO_printf(bio_err, "-rkey file responder key to sign responses with\n"); BIO_printf(bio_err, "-rother file other certificates to include in response\n"); BIO_printf(bio_err, "-resp_no_certs don't include any certificates in response\n"); BIO_printf(bio_err, "-nmin n number of minutes before next update\n"); BIO_printf(bio_err, "-ndays n number of days before next update\n"); BIO_printf(bio_err, "-resp_key_id identify reponse by signing certificate key ID\n"); BIO_printf(bio_err, "-nrequest n number of requests to accept (default unlimited)\n"); BIO_printf(bio_err, "- use specified digest in the request\n"); goto end; } if (outfile) out = BIO_new_file(outfile, "w"); else out = BIO_new_fp(stdout, BIO_NOCLOSE); if (!out) { BIO_printf(bio_err, "Error opening output file\n"); goto end; } if (!req && (add_nonce != 2)) add_nonce = 0; if (!req && reqin) { derbio = BIO_new_file(reqin, "rb"); if (!derbio) { BIO_printf(bio_err, "Error Opening OCSP request file\n"); goto end; } req = d2i_OCSP_REQUEST_bio(derbio, NULL); BIO_free(derbio); if (!req) { BIO_printf(bio_err, "Error reading OCSP request\n"); goto end; } } if (!req && port) { acbio = init_responder(port); if (!acbio) goto end; } if (rsignfile && !rdb) { if (!rkeyfile) rkeyfile = rsignfile; rsigner = load_cert(bio_err, rsignfile, FORMAT_PEM, NULL, e, "responder certificate"); if (!rsigner) { BIO_printf(bio_err, "Error loading responder certificate\n"); goto end; } rca_cert = load_cert(bio_err, rca_filename, FORMAT_PEM, NULL, e, "CA certificate"); if (rcertfile) { rother = load_certs(bio_err, rcertfile, FORMAT_PEM, NULL, e, "responder other certificates"); if (!rother) goto end; } rkey = load_key(bio_err, rkeyfile, FORMAT_PEM, 0, NULL, NULL, "responder private key"); if (!rkey) goto end; } if (acbio) BIO_printf(bio_err, "Waiting for OCSP client connections...\n"); redo_accept: if (acbio) { if (!do_responder(&req, &cbio, acbio, port)) goto end; if (!req) { resp = OCSP_response_create(OCSP_RESPONSE_STATUS_MALFORMEDREQUEST, NULL); send_ocsp_response(cbio, resp); goto done_resp; } } if (!req && (signfile || reqout || host || add_nonce || ridx_filename)) { BIO_printf(bio_err, "Need an OCSP request for this operation!\n"); goto end; } if (req && add_nonce) OCSP_request_add1_nonce(req, NULL, -1); if (signfile) { if (!keyfile) keyfile = signfile; signer = load_cert(bio_err, signfile, FORMAT_PEM, NULL, e, "signer certificate"); if (!signer) { BIO_printf(bio_err, "Error loading signer certificate\n"); goto end; } if (sign_certfile) { sign_other = load_certs(bio_err, sign_certfile, FORMAT_PEM, NULL, e, "signer certificates"); if (!sign_other) goto end; } key = load_key(bio_err, keyfile, FORMAT_PEM, 0, NULL, NULL, "signer private key"); if (!key) goto end; if (!OCSP_request_sign(req, signer, key, NULL, sign_other, sign_flags)) { BIO_printf(bio_err, "Error signing OCSP request\n"); goto end; } } if (req_text && req) OCSP_REQUEST_print(out, req, 0); if (reqout) { derbio = BIO_new_file(reqout, "wb"); if (!derbio) { BIO_printf(bio_err, "Error opening file %s\n", reqout); goto end; } i2d_OCSP_REQUEST_bio(derbio, req); BIO_free(derbio); } if (ridx_filename && (!rkey || !rsigner || !rca_cert)) { BIO_printf(bio_err, "Need a responder certificate, key and CA for this operation!\n"); goto end; } if (ridx_filename && !rdb) { rdb = load_index(ridx_filename, NULL); if (!rdb) goto end; if (!index_index(rdb)) goto end; } if (rdb) { i = make_ocsp_response(&resp, req, rdb, rca_cert, rsigner, rkey, rother, rflags, nmin, ndays); if (cbio) send_ocsp_response(cbio, resp); } else if (host) { resp = process_responder(bio_err, req, host, path, port, use_ssl, headers, req_timeout); if (!resp) goto end; } else if (respin) { derbio = BIO_new_file(respin, "rb"); if (!derbio) { BIO_printf(bio_err, "Error Opening OCSP response file\n"); goto end; } resp = d2i_OCSP_RESPONSE_bio(derbio, NULL); BIO_free(derbio); if (!resp) { BIO_printf(bio_err, "Error reading OCSP response\n"); goto end; } } else { ret = 0; goto end; } done_resp: if (respout) { derbio = BIO_new_file(respout, "wb"); if (!derbio) { BIO_printf(bio_err, "Error opening file %s\n", respout); goto end; } i2d_OCSP_RESPONSE_bio(derbio, resp); BIO_free(derbio); } i = OCSP_response_status(resp); if (i != OCSP_RESPONSE_STATUS_SUCCESSFUL) { BIO_printf(out, "Responder Error: %s (%d)\n", OCSP_response_status_str(i), i); if (ignore_err) goto redo_accept; ret = 0; goto end; } if (resp_text) OCSP_RESPONSE_print(out, resp, 0); /* If running as responder don't verify our own response */ if (cbio) { if (accept_count > 0) accept_count--; /* Redo if more connections needed */ if (accept_count) { BIO_free_all(cbio); cbio = NULL; OCSP_REQUEST_free(req); req = NULL; OCSP_RESPONSE_free(resp); resp = NULL; goto redo_accept; } goto end; } if (!store) store = setup_verify(bio_err, CAfile, CApath); if (!store) goto end; if (verify_certfile) { verify_other = load_certs(bio_err, verify_certfile, FORMAT_PEM, NULL, e, "validator certificate"); if (!verify_other) goto end; } bs = OCSP_response_get1_basic(resp); if (!bs) { BIO_printf(bio_err, "Error parsing response\n"); goto end; } if (!noverify) { if (req && ((i = OCSP_check_nonce(req, bs)) <= 0)) { if (i == -1) BIO_printf(bio_err, "WARNING: no nonce in response\n"); else { BIO_printf(bio_err, "Nonce Verify error\n"); goto end; } } i = OCSP_basic_verify(bs, verify_other, store, verify_flags); if (i < 0) i = OCSP_basic_verify(bs, NULL, store, 0); if (i <= 0) { BIO_printf(bio_err, "Response Verify Failure\n"); ERR_print_errors(bio_err); } else BIO_printf(bio_err, "Response verify OK\n"); } if (!print_ocsp_summary(out, bs, req, reqnames, ids, nsec, maxage)) goto end; ret = 0; end: ERR_print_errors(bio_err); X509_free(signer); X509_STORE_free(store); EVP_PKEY_free(key); EVP_PKEY_free(rkey); X509_free(issuer); X509_free(cert); X509_free(rsigner); X509_free(rca_cert); free_index(rdb); BIO_free_all(cbio); BIO_free_all(acbio); BIO_free(out); OCSP_REQUEST_free(req); OCSP_RESPONSE_free(resp); OCSP_BASICRESP_free(bs); sk_OPENSSL_STRING_free(reqnames); sk_OCSP_CERTID_free(ids); sk_X509_pop_free(sign_other, X509_free); sk_X509_pop_free(verify_other, X509_free); sk_CONF_VALUE_pop_free(headers, X509V3_conf_free); if (use_ssl != -1) { free(host); free(port); free(path); } return (ret); } static int add_ocsp_cert(OCSP_REQUEST ** req, X509 * cert, const EVP_MD * cert_id_md, X509 * issuer, STACK_OF(OCSP_CERTID) * ids) { OCSP_CERTID *id; if (!issuer) { BIO_printf(bio_err, "No issuer certificate specified\n"); return 0; } if (!*req) *req = OCSP_REQUEST_new(); if (!*req) goto err; id = OCSP_cert_to_id(cert_id_md, cert, issuer); if (!id || !sk_OCSP_CERTID_push(ids, id)) goto err; if (!OCSP_request_add0_id(*req, id)) goto err; return 1; err: BIO_printf(bio_err, "Error Creating OCSP request\n"); return 0; } static int add_ocsp_serial(OCSP_REQUEST ** req, char *serial, const EVP_MD * cert_id_md, X509 * issuer, STACK_OF(OCSP_CERTID) * ids) { OCSP_CERTID *id; X509_NAME *iname; ASN1_BIT_STRING *ikey; ASN1_INTEGER *sno; if (!issuer) { BIO_printf(bio_err, "No issuer certificate specified\n"); return 0; } if (!*req) *req = OCSP_REQUEST_new(); if (!*req) goto err; iname = X509_get_subject_name(issuer); ikey = X509_get0_pubkey_bitstr(issuer); sno = s2i_ASN1_INTEGER(NULL, serial); if (!sno) { BIO_printf(bio_err, "Error converting serial number %s\n", serial); return 0; } id = OCSP_cert_id_new(cert_id_md, iname, ikey, sno); ASN1_INTEGER_free(sno); if (!id || !sk_OCSP_CERTID_push(ids, id)) goto err; if (!OCSP_request_add0_id(*req, id)) goto err; return 1; err: BIO_printf(bio_err, "Error Creating OCSP request\n"); return 0; } static int print_ocsp_summary(BIO * out, OCSP_BASICRESP * bs, OCSP_REQUEST * req, STACK_OF(OPENSSL_STRING) * names, STACK_OF(OCSP_CERTID) * ids, long nsec, long maxage) { OCSP_CERTID *id; char *name; int i; int status, reason; ASN1_GENERALIZEDTIME *rev, *thisupd, *nextupd; if (!bs || !req || !sk_OPENSSL_STRING_num(names) || !sk_OCSP_CERTID_num(ids)) return 1; for (i = 0; i < sk_OCSP_CERTID_num(ids); i++) { id = sk_OCSP_CERTID_value(ids, i); name = sk_OPENSSL_STRING_value(names, i); BIO_printf(out, "%s: ", name); if (!OCSP_resp_find_status(bs, id, &status, &reason, &rev, &thisupd, &nextupd)) { BIO_puts(out, "ERROR: No Status found.\n"); continue; } /* * Check validity: if invalid write to output BIO so we know * which response this refers to. */ if (!OCSP_check_validity(thisupd, nextupd, nsec, maxage)) { BIO_puts(out, "WARNING: Status times invalid.\n"); ERR_print_errors(out); } BIO_printf(out, "%s\n", OCSP_cert_status_str(status)); BIO_puts(out, "\tThis Update: "); ASN1_GENERALIZEDTIME_print(out, thisupd); BIO_puts(out, "\n"); if (nextupd) { BIO_puts(out, "\tNext Update: "); ASN1_GENERALIZEDTIME_print(out, nextupd); BIO_puts(out, "\n"); } if (status != V_OCSP_CERTSTATUS_REVOKED) continue; if (reason != -1) BIO_printf(out, "\tReason: %s\n", OCSP_crl_reason_str(reason)); BIO_puts(out, "\tRevocation Time: "); ASN1_GENERALIZEDTIME_print(out, rev); BIO_puts(out, "\n"); } return 1; } static int make_ocsp_response(OCSP_RESPONSE ** resp, OCSP_REQUEST * req, CA_DB * db, X509 * ca, X509 * rcert, EVP_PKEY * rkey, STACK_OF(X509) * rother, unsigned long flags, int nmin, int ndays) { ASN1_TIME *thisupd = NULL, *nextupd = NULL; OCSP_CERTID *cid, *ca_id = NULL; OCSP_BASICRESP *bs = NULL; int i, id_count, ret = 1; id_count = OCSP_request_onereq_count(req); if (id_count <= 0) { *resp = OCSP_response_create(OCSP_RESPONSE_STATUS_MALFORMEDREQUEST, NULL); goto end; } bs = OCSP_BASICRESP_new(); thisupd = X509_gmtime_adj(NULL, 0); if (ndays != -1) nextupd = X509_gmtime_adj(NULL, nmin * 60 + ndays * 3600 * 24); /* Examine each certificate id in the request */ for (i = 0; i < id_count; i++) { OCSP_ONEREQ *one; ASN1_INTEGER *serial; char **inf; ASN1_OBJECT *cert_id_md_oid; const EVP_MD *cert_id_md; one = OCSP_request_onereq_get0(req, i); cid = OCSP_onereq_get0_id(one); OCSP_id_get0_info(NULL, &cert_id_md_oid, NULL, NULL, cid); cert_id_md = EVP_get_digestbyobj(cert_id_md_oid); if (!cert_id_md) { *resp = OCSP_response_create(OCSP_RESPONSE_STATUS_INTERNALERROR, NULL); goto end; } if (ca_id) OCSP_CERTID_free(ca_id); ca_id = OCSP_cert_to_id(cert_id_md, NULL, ca); /* Is this request about our CA? */ if (OCSP_id_issuer_cmp(ca_id, cid)) { OCSP_basic_add1_status(bs, cid, V_OCSP_CERTSTATUS_UNKNOWN, 0, NULL, thisupd, nextupd); continue; } OCSP_id_get0_info(NULL, NULL, NULL, &serial, cid); inf = lookup_serial(db, serial); if (!inf) OCSP_basic_add1_status(bs, cid, V_OCSP_CERTSTATUS_UNKNOWN, 0, NULL, thisupd, nextupd); else if (inf[DB_type][0] == DB_TYPE_VAL) OCSP_basic_add1_status(bs, cid, V_OCSP_CERTSTATUS_GOOD, 0, NULL, thisupd, nextupd); else if (inf[DB_type][0] == DB_TYPE_REV) { ASN1_OBJECT *inst = NULL; ASN1_TIME *revtm = NULL; ASN1_GENERALIZEDTIME *invtm = NULL; OCSP_SINGLERESP *single; int reason = -1; unpack_revinfo(&revtm, &reason, &inst, &invtm, inf[DB_rev_date]); single = OCSP_basic_add1_status(bs, cid, V_OCSP_CERTSTATUS_REVOKED, reason, revtm, thisupd, nextupd); if (invtm) OCSP_SINGLERESP_add1_ext_i2d(single, NID_invalidity_date, invtm, 0, 0); else if (inst) OCSP_SINGLERESP_add1_ext_i2d(single, NID_hold_instruction_code, inst, 0, 0); ASN1_OBJECT_free(inst); ASN1_TIME_free(revtm); ASN1_GENERALIZEDTIME_free(invtm); } } OCSP_copy_nonce(bs, req); OCSP_basic_sign(bs, rcert, rkey, NULL, rother, flags); *resp = OCSP_response_create(OCSP_RESPONSE_STATUS_SUCCESSFUL, bs); end: ASN1_TIME_free(thisupd); ASN1_TIME_free(nextupd); OCSP_CERTID_free(ca_id); OCSP_BASICRESP_free(bs); return ret; } static char ** lookup_serial(CA_DB * db, ASN1_INTEGER * ser) { int i; BIGNUM *bn = NULL; char *itmp, *row[DB_NUMBER], **rrow; for (i = 0; i < DB_NUMBER; i++) row[i] = NULL; bn = ASN1_INTEGER_to_BN(ser, NULL); OPENSSL_assert(bn); /* FIXME: should report an error at this * point and abort */ if (BN_is_zero(bn)) itmp = BUF_strdup("00"); else itmp = BN_bn2hex(bn); row[DB_serial] = itmp; BN_free(bn); rrow = TXT_DB_get_by_index(db->db, DB_serial, row); free(itmp); return rrow; } /* Quick and dirty OCSP server: read in and parse input request */ static BIO * init_responder(char *port) { BIO *acbio = NULL, *bufbio = NULL; bufbio = BIO_new(BIO_f_buffer()); if (!bufbio) goto err; acbio = BIO_new_accept(port); if (!acbio) goto err; BIO_set_accept_bios(acbio, bufbio); bufbio = NULL; if (BIO_do_accept(acbio) <= 0) { BIO_printf(bio_err, "Error setting up accept BIO\n"); ERR_print_errors(bio_err); goto err; } return acbio; err: BIO_free_all(acbio); BIO_free(bufbio); return NULL; } static int do_responder(OCSP_REQUEST ** preq, BIO ** pcbio, BIO * acbio, char *port) { int have_post = 0, len; OCSP_REQUEST *req = NULL; char inbuf[1024]; BIO *cbio = NULL; if (BIO_do_accept(acbio) <= 0) { BIO_printf(bio_err, "Error accepting connection\n"); ERR_print_errors(bio_err); return 0; } cbio = BIO_pop(acbio); *pcbio = cbio; for (;;) { len = BIO_gets(cbio, inbuf, sizeof inbuf); if (len <= 0) return 1; /* Look for "POST" signalling start of query */ if (!have_post) { if (strncmp(inbuf, "POST", 4)) { BIO_printf(bio_err, "Invalid request\n"); return 1; } have_post = 1; } /* Look for end of headers */ if ((inbuf[0] == '\r') || (inbuf[0] == '\n')) break; } /* Try to read OCSP request */ req = d2i_OCSP_REQUEST_bio(cbio, NULL); if (!req) { BIO_printf(bio_err, "Error parsing OCSP request\n"); ERR_print_errors(bio_err); } *preq = req; return 1; } static int send_ocsp_response(BIO * cbio, OCSP_RESPONSE * resp) { static const char http_resp[] = "HTTP/1.0 200 OK\r\nContent-type: application/ocsp-response\r\n" "Content-Length: %d\r\n\r\n"; if (!cbio) return 0; BIO_printf(cbio, http_resp, i2d_OCSP_RESPONSE(resp, NULL)); i2d_OCSP_RESPONSE_bio(cbio, resp); (void) BIO_flush(cbio); return 1; } static OCSP_RESPONSE * query_responder(BIO * err, BIO * cbio, char *path, STACK_OF(CONF_VALUE) * headers, OCSP_REQUEST * req, int req_timeout) { int fd; int rv; int i; OCSP_REQ_CTX *ctx = NULL; OCSP_RESPONSE *rsp = NULL; fd_set confds; struct timeval tv; if (req_timeout != -1) BIO_set_nbio(cbio, 1); rv = BIO_do_connect(cbio); if ((rv <= 0) && ((req_timeout == -1) || !BIO_should_retry(cbio))) { BIO_puts(err, "Error connecting BIO\n"); return NULL; } if (BIO_get_fd(cbio, &fd) <= 0) { BIO_puts(err, "Can't get connection fd\n"); goto err; } if (req_timeout != -1 && rv <= 0) { FD_ZERO(&confds); FD_SET(fd, &confds); tv.tv_usec = 0; tv.tv_sec = req_timeout; rv = select(fd + 1, NULL, &confds, NULL, &tv); if (rv == 0) { BIO_puts(err, "Timeout on connect\n"); return NULL; } } ctx = OCSP_sendreq_new(cbio, path, NULL, -1); if (!ctx) return NULL; for (i = 0; i < sk_CONF_VALUE_num(headers); i++) { CONF_VALUE *hdr = sk_CONF_VALUE_value(headers, i); if (!OCSP_REQ_CTX_add1_header(ctx, hdr->name, hdr->value)) goto err; } if (!OCSP_REQ_CTX_set1_req(ctx, req)) goto err; for (;;) { rv = OCSP_sendreq_nbio(&rsp, ctx); if (rv != -1) break; if (req_timeout == -1) continue; FD_ZERO(&confds); FD_SET(fd, &confds); tv.tv_usec = 0; tv.tv_sec = req_timeout; if (BIO_should_read(cbio)) rv = select(fd + 1, &confds, NULL, NULL, &tv); else if (BIO_should_write(cbio)) rv = select(fd + 1, NULL, &confds, NULL, &tv); else { BIO_puts(err, "Unexpected retry condition\n"); goto err; } if (rv == 0) { BIO_puts(err, "Timeout on request\n"); break; } if (rv == -1) { BIO_puts(err, "Select error\n"); break; } } err: if (ctx) OCSP_REQ_CTX_free(ctx); return rsp; } OCSP_RESPONSE * process_responder(BIO * err, OCSP_REQUEST * req, char *host, char *path, char *port, int use_ssl, STACK_OF(CONF_VALUE) * headers, int req_timeout) { BIO *cbio = NULL; SSL_CTX *ctx = NULL; OCSP_RESPONSE *resp = NULL; cbio = BIO_new_connect(host); if (!cbio) { BIO_printf(err, "Error creating connect BIO\n"); goto end; } if (port) BIO_set_conn_port(cbio, port); if (use_ssl == 1) { BIO *sbio; ctx = SSL_CTX_new(SSLv23_client_method()); if (ctx == NULL) { BIO_printf(err, "Error creating SSL context.\n"); goto end; } SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY); sbio = BIO_new_ssl(ctx, 1); cbio = BIO_push(sbio, cbio); } resp = query_responder(err, cbio, path, headers, req, req_timeout); if (!resp) BIO_printf(bio_err, "Error querying OCSP responder\n"); end: if (cbio) BIO_free_all(cbio); if (ctx) SSL_CTX_free(ctx); return resp; } #endif deps/libressl-pnacl-sys-2.1.6/libressl/apps/nseq.c0000644000175000017500000001175312360020706017020 0ustar /* $OpenBSD$ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include "apps.h" #include #include int nseq_main(int, char **); int nseq_main(int argc, char **argv) { char **args, *infile = NULL, *outfile = NULL; BIO *in = NULL, *out = NULL; int toseq = 0; X509 *x509 = NULL; NETSCAPE_CERT_SEQUENCE *seq = NULL; int i, ret = 1; int badarg = 0; ERR_load_crypto_strings(); args = argv + 1; while (!badarg && *args && *args[0] == '-') { if (!strcmp(*args, "-toseq")) toseq = 1; else if (!strcmp(*args, "-in")) { if (args[1]) { args++; infile = *args; } else badarg = 1; } else if (!strcmp(*args, "-out")) { if (args[1]) { args++; outfile = *args; } else badarg = 1; } else badarg = 1; args++; } if (badarg) { BIO_printf(bio_err, "Netscape certificate sequence utility\n"); BIO_printf(bio_err, "Usage nseq [options]\n"); BIO_printf(bio_err, "where options are\n"); BIO_printf(bio_err, "-in file input file\n"); BIO_printf(bio_err, "-out file output file\n"); BIO_printf(bio_err, "-toseq output NS Sequence file\n"); return (1); } if (infile) { if (!(in = BIO_new_file(infile, "r"))) { BIO_printf(bio_err, "Can't open input file %s\n", infile); goto end; } } else in = BIO_new_fp(stdin, BIO_NOCLOSE); if (outfile) { if (!(out = BIO_new_file(outfile, "w"))) { BIO_printf(bio_err, "Can't open output file %s\n", outfile); goto end; } } else { out = BIO_new_fp(stdout, BIO_NOCLOSE); } if (toseq) { seq = NETSCAPE_CERT_SEQUENCE_new(); seq->certs = sk_X509_new_null(); while ((x509 = PEM_read_bio_X509(in, NULL, NULL, NULL))) sk_X509_push(seq->certs, x509); if (!sk_X509_num(seq->certs)) { BIO_printf(bio_err, "Error reading certs file %s\n", infile); ERR_print_errors(bio_err); goto end; } PEM_write_bio_NETSCAPE_CERT_SEQUENCE(out, seq); ret = 0; goto end; } if (!(seq = PEM_read_bio_NETSCAPE_CERT_SEQUENCE(in, NULL, NULL, NULL))) { BIO_printf(bio_err, "Error reading sequence file %s\n", infile); ERR_print_errors(bio_err); goto end; } for (i = 0; i < sk_X509_num(seq->certs); i++) { x509 = sk_X509_value(seq->certs, i); dump_cert_text(out, x509); PEM_write_bio_X509(out, x509); } ret = 0; end: BIO_free(in); BIO_free_all(out); NETSCAPE_CERT_SEQUENCE_free(seq); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/apps/strtonum.c0000644000175000017500000000335312360020707017743 0ustar /* $OpenBSD: strtonum.c,v 1.6 2004/08/03 19:38:01 millert Exp $ */ /* * Copyright (c) 2004 Ted Unangst and Todd Miller * All rights reserved. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #define INVALID 1 #define TOOSMALL 2 #define TOOLARGE 3 long long strtonum(const char *numstr, long long minval, long long maxval, const char **errstrp) { long long ll = 0; int error = 0; char *ep; struct errval { const char *errstr; int err; } ev[4] = { { NULL, 0 }, { "invalid", EINVAL }, { "too small", ERANGE }, { "too large", ERANGE }, }; ev[0].err = errno; errno = 0; if (minval > maxval) { error = INVALID; } else { ll = strtoll(numstr, &ep, 10); if (numstr == ep || *ep != '\0') error = INVALID; else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval) error = TOOSMALL; else if ((ll == LLONG_MAX && errno == ERANGE) || ll > maxval) error = TOOLARGE; } if (errstrp != NULL) *errstrp = ev[error].errstr; errno = ev[error].err; if (error) ll = 0; return (ll); } deps/libressl-pnacl-sys-2.1.6/libressl/apps/verify.c0000644000175000017500000002326112360020706017353 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include "apps.h" #include #include #include #include #include static int cb(int ok, X509_STORE_CTX * ctx); static int check(X509_STORE * ctx, char *file, STACK_OF(X509) * uchain, STACK_OF(X509) * tchain, STACK_OF(X509_CRL) * crls, ENGINE * e); static int v_verbose = 0, vflags = 0; int verify_main(int, char **); int verify_main(int argc, char **argv) { ENGINE *e = NULL; int i, ret = 1, badarg = 0; char *CApath = NULL, *CAfile = NULL; char *untfile = NULL, *trustfile = NULL, *crlfile = NULL; STACK_OF(X509) * untrusted = NULL, *trusted = NULL; STACK_OF(X509_CRL) * crls = NULL; X509_STORE *cert_ctx = NULL; X509_LOOKUP *lookup = NULL; X509_VERIFY_PARAM *vpm = NULL; #ifndef OPENSSL_NO_ENGINE char *engine = NULL; #endif cert_ctx = X509_STORE_new(); if (cert_ctx == NULL) goto end; X509_STORE_set_verify_cb(cert_ctx, cb); ERR_load_crypto_strings(); if (!load_config(bio_err, NULL)) goto end; argc--; argv++; for (;;) { if (argc >= 1) { if (strcmp(*argv, "-CApath") == 0) { if (argc-- < 1) goto end; CApath = *(++argv); } else if (strcmp(*argv, "-CAfile") == 0) { if (argc-- < 1) goto end; CAfile = *(++argv); } else if (args_verify(&argv, &argc, &badarg, bio_err, &vpm)) { if (badarg) goto end; continue; } else if (strcmp(*argv, "-untrusted") == 0) { if (argc-- < 1) goto end; untfile = *(++argv); } else if (strcmp(*argv, "-trusted") == 0) { if (argc-- < 1) goto end; trustfile = *(++argv); } else if (strcmp(*argv, "-CRLfile") == 0) { if (argc-- < 1) goto end; crlfile = *(++argv); } #ifndef OPENSSL_NO_ENGINE else if (strcmp(*argv, "-engine") == 0) { if (--argc < 1) goto end; engine = *(++argv); } #endif else if (strcmp(*argv, "-help") == 0) goto end; else if (strcmp(*argv, "-verbose") == 0) v_verbose = 1; else if (argv[0][0] == '-') goto end; else break; argc--; argv++; } else break; } #ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); #endif if (vpm) X509_STORE_set1_param(cert_ctx, vpm); lookup = X509_STORE_add_lookup(cert_ctx, X509_LOOKUP_file()); if (lookup == NULL) abort(); if (CAfile) { i = X509_LOOKUP_load_file(lookup, CAfile, X509_FILETYPE_PEM); if (!i) { BIO_printf(bio_err, "Error loading file %s\n", CAfile); ERR_print_errors(bio_err); goto end; } } else X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT); lookup = X509_STORE_add_lookup(cert_ctx, X509_LOOKUP_hash_dir()); if (lookup == NULL) abort(); if (CApath) { i = X509_LOOKUP_add_dir(lookup, CApath, X509_FILETYPE_PEM); if (!i) { BIO_printf(bio_err, "Error loading directory %s\n", CApath); ERR_print_errors(bio_err); goto end; } } else X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT); ERR_clear_error(); if (untfile) { untrusted = load_certs(bio_err, untfile, FORMAT_PEM, NULL, e, "untrusted certificates"); if (!untrusted) goto end; } if (trustfile) { trusted = load_certs(bio_err, trustfile, FORMAT_PEM, NULL, e, "trusted certificates"); if (!trusted) goto end; } if (crlfile) { crls = load_crls(bio_err, crlfile, FORMAT_PEM, NULL, e, "other CRLs"); if (!crls) goto end; } ret = 0; if (argc < 1) { if (1 != check(cert_ctx, NULL, untrusted, trusted, crls, e)) ret = -1; } else { for (i = 0; i < argc; i++) if (1 != check(cert_ctx, argv[i], untrusted, trusted, crls, e)) ret = -1; } end: if (ret == 1) { BIO_printf(bio_err, "usage: verify [-verbose] [-CApath path] [-CAfile file] [-purpose purpose] [-crl_check]"); BIO_printf(bio_err, " [-attime timestamp]"); #ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err, " [-engine e]"); #endif BIO_printf(bio_err, " cert1 cert2 ...\n"); BIO_printf(bio_err, "recognized usages:\n"); for (i = 0; i < X509_PURPOSE_get_count(); i++) { X509_PURPOSE *ptmp; ptmp = X509_PURPOSE_get0(i); BIO_printf(bio_err, "\t%-10s\t%s\n", X509_PURPOSE_get0_sname(ptmp), X509_PURPOSE_get0_name(ptmp)); } } if (vpm) X509_VERIFY_PARAM_free(vpm); if (cert_ctx != NULL) X509_STORE_free(cert_ctx); sk_X509_pop_free(untrusted, X509_free); sk_X509_pop_free(trusted, X509_free); sk_X509_CRL_pop_free(crls, X509_CRL_free); return (ret < 0 ? 2 : ret); } static int check(X509_STORE * ctx, char *file, STACK_OF(X509) * uchain, STACK_OF(X509) * tchain, STACK_OF(X509_CRL) * crls, ENGINE * e) { X509 *x = NULL; int i = 0, ret = 0; X509_STORE_CTX *csc; x = load_cert(bio_err, file, FORMAT_PEM, NULL, e, "certificate file"); if (x == NULL) goto end; fprintf(stdout, "%s: ", (file == NULL) ? "stdin" : file); csc = X509_STORE_CTX_new(); if (csc == NULL) { ERR_print_errors(bio_err); goto end; } X509_STORE_set_flags(ctx, vflags); if (!X509_STORE_CTX_init(csc, ctx, x, uchain)) { ERR_print_errors(bio_err); goto end; } if (tchain) X509_STORE_CTX_trusted_stack(csc, tchain); if (crls) X509_STORE_CTX_set0_crls(csc, crls); i = X509_verify_cert(csc); X509_STORE_CTX_free(csc); ret = 0; end: if (i > 0) { fprintf(stdout, "OK\n"); ret = 1; } else ERR_print_errors(bio_err); if (x != NULL) X509_free(x); return (ret); } static int cb(int ok, X509_STORE_CTX * ctx) { int cert_error = X509_STORE_CTX_get_error(ctx); X509 *current_cert = X509_STORE_CTX_get_current_cert(ctx); if (!ok) { if (current_cert) { X509_NAME_print_ex_fp(stdout, X509_get_subject_name(current_cert), 0, XN_FLAG_ONELINE); printf("\n"); } printf("%serror %d at %d depth lookup:%s\n", X509_STORE_CTX_get0_parent_ctx(ctx) ? "[CRL path]" : "", cert_error, X509_STORE_CTX_get_error_depth(ctx), X509_verify_cert_error_string(cert_error)); switch (cert_error) { case X509_V_ERR_NO_EXPLICIT_POLICY: policies_print(NULL, ctx); case X509_V_ERR_CERT_HAS_EXPIRED: /* * since we are just checking the certificates, it is * ok if they are self signed. But we should still * warn the user. */ case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: /* Continue after extension errors too */ case X509_V_ERR_INVALID_CA: case X509_V_ERR_INVALID_NON_CA: case X509_V_ERR_PATH_LENGTH_EXCEEDED: case X509_V_ERR_INVALID_PURPOSE: case X509_V_ERR_CRL_HAS_EXPIRED: case X509_V_ERR_CRL_NOT_YET_VALID: case X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION: ok = 1; } return ok; } if (cert_error == X509_V_OK && ok == 2) policies_print(NULL, ctx); if (!v_verbose) ERR_clear_error(); return (ok); } deps/libressl-pnacl-sys-2.1.6/libressl/apps/x509.c0000644000175000017500000010126612360020706016556 0ustar /* $OpenBSD: x509.c,v 1.46 2014/06/28 04:39:41 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include #include #include "apps.h" #include #include #include #include #include #include #include #include #include #include #include #define POSTFIX ".srl" #define DEF_DAYS 30 static const char *x509_usage[] = { "usage: x509 args\n", " -inform arg - input format - default PEM (one of DER, NET or PEM)\n", " -outform arg - output format - default PEM (one of DER, NET or PEM)\n", " -keyform arg - private key format - default PEM\n", " -CAform arg - CA format - default PEM\n", " -CAkeyform arg - CA key format - default PEM\n", " -in arg - input file - default stdin\n", " -out arg - output file - default stdout\n", " -passin arg - private key password source\n", " -serial - print serial number value\n", " -subject_hash - print subject hash value\n", #ifndef OPENSSL_NO_MD5 " -subject_hash_old - print old-style (MD5) subject hash value\n", #endif " -issuer_hash - print issuer hash value\n", #ifndef OPENSSL_NO_MD5 " -issuer_hash_old - print old-style (MD5) issuer hash value\n", #endif " -hash - synonym for -subject_hash\n", " -subject - print subject DN\n", " -issuer - print issuer DN\n", " -email - print email address(es)\n", " -startdate - notBefore field\n", " -enddate - notAfter field\n", " -purpose - print out certificate purposes\n", " -dates - both Before and After dates\n", " -modulus - print the RSA key modulus\n", " -pubkey - output the public key\n", " -fingerprint - print the certificate fingerprint\n", " -alias - output certificate alias\n", " -noout - no certificate output\n", " -ocspid - print OCSP hash values for the subject name and public key\n", " -ocsp_uri - print OCSP Responder URL(s)\n", " -trustout - output a \"trusted\" certificate\n", " -clrtrust - clear all trusted purposes\n", " -clrreject - clear all rejected purposes\n", " -addtrust arg - trust certificate for a given purpose\n", " -addreject arg - reject certificate for a given purpose\n", " -setalias arg - set certificate alias\n", " -days arg - How long till expiry of a signed certificate - def 30 days\n", " -checkend arg - check whether the cert expires in the next arg seconds\n", " exit 1 if so, 0 if not\n", " -signkey arg - self sign cert with arg\n", " -x509toreq - output a certification request object\n", " -req - input is a certificate request, sign and output.\n", " -CA arg - set the CA certificate, must be PEM format.\n", " -CAkey arg - set the CA key, must be PEM format\n", " missing, it is assumed to be in the CA file.\n", " -CAcreateserial - create serial number file if it does not exist\n", " -CAserial arg - serial file\n", " -set_serial - serial number to use\n", " -text - print the certificate in text form\n", " -C - print out C code forms\n", " -md2/-md5/-sha1/-mdc2 - digest to use\n", " -extfile - configuration file with X509V3 extensions to add\n", " -extensions - section from config file with X509V3 extensions to add\n", " -clrext - delete extensions before signing and input certificate\n", " -nameopt arg - various certificate name options\n", #ifndef OPENSSL_NO_ENGINE " -engine e - use engine e, possibly a hardware device.\n", #endif " -certopt arg - various certificate text options\n", NULL }; static int callb(int ok, X509_STORE_CTX *ctx); static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext, const EVP_MD *digest, CONF *conf, char *section); static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest, X509 *x, X509 *xca, EVP_PKEY *pkey, STACK_OF(OPENSSL_STRING) *sigopts, char *serial, int create, int days, int clrext, CONF *conf, char *section, ASN1_INTEGER *sno); static int purpose_print(BIO *bio, X509 *cert, X509_PURPOSE *pt); static int reqfile = 0; int x509_main(int, char **); int x509_main(int argc, char **argv) { ENGINE *e = NULL; int ret = 1; X509_REQ *req = NULL; X509 *x = NULL, *xca = NULL; ASN1_OBJECT *objtmp; STACK_OF(OPENSSL_STRING) *sigopts = NULL; EVP_PKEY *Upkey = NULL, *CApkey = NULL; ASN1_INTEGER *sno = NULL; int i, num, badops = 0; BIO *out = NULL; BIO *STDout = NULL; STACK_OF(ASN1_OBJECT) *trust = NULL, *reject = NULL; int informat, outformat, keyformat, CAformat, CAkeyformat; char *infile = NULL, *outfile = NULL, *keyfile = NULL, *CAfile = NULL; char *CAkeyfile = NULL, *CAserial = NULL; char *alias = NULL; int text = 0, serial = 0, subject = 0, issuer = 0, startdate = 0, enddate = 0; int next_serial = 0; int subject_hash = 0, issuer_hash = 0, ocspid = 0; #ifndef OPENSSL_NO_MD5 int subject_hash_old = 0, issuer_hash_old = 0; #endif int noout = 0, sign_flag = 0, CA_flag = 0, CA_createserial = 0, email = 0; int ocsp_uri = 0; int trustout = 0, clrtrust = 0, clrreject = 0, aliasout = 0, clrext = 0; int C = 0; int x509req = 0, days = DEF_DAYS, modulus = 0, pubkey = 0; int pprint = 0; const char **pp; X509_STORE *ctx = NULL; X509_REQ *rq = NULL; int fingerprint = 0; char buf[256]; const EVP_MD *md_alg, *digest = NULL; CONF *extconf = NULL; char *extsect = NULL, *extfile = NULL, *passin = NULL, *passargin = NULL; int checkend = 0, checkoffset = 0; unsigned long nmflag = 0, certflag = 0; #ifndef OPENSSL_NO_ENGINE char *engine = NULL; #endif const char *errstr = NULL; reqfile = 0; if (!load_config(bio_err, NULL)) goto end; STDout = BIO_new_fp(stdout, BIO_NOCLOSE); informat = FORMAT_PEM; outformat = FORMAT_PEM; keyformat = FORMAT_PEM; CAformat = FORMAT_PEM; CAkeyformat = FORMAT_PEM; ctx = X509_STORE_new(); if (ctx == NULL) goto end; X509_STORE_set_verify_cb(ctx, callb); argc--; argv++; num = 0; while (argc >= 1) { if (strcmp(*argv, "-inform") == 0) { if (--argc < 1) goto bad; informat = str2fmt(*(++argv)); } else if (strcmp(*argv, "-outform") == 0) { if (--argc < 1) goto bad; outformat = str2fmt(*(++argv)); } else if (strcmp(*argv, "-keyform") == 0) { if (--argc < 1) goto bad; keyformat = str2fmt(*(++argv)); } else if (strcmp(*argv, "-req") == 0) { reqfile = 1; } else if (strcmp(*argv, "-CAform") == 0) { if (--argc < 1) goto bad; CAformat = str2fmt(*(++argv)); } else if (strcmp(*argv, "-CAkeyform") == 0) { if (--argc < 1) goto bad; CAkeyformat = str2fmt(*(++argv)); } else if (strcmp(*argv, "-sigopt") == 0) { if (--argc < 1) goto bad; if (!sigopts) sigopts = sk_OPENSSL_STRING_new_null(); if (!sigopts || !sk_OPENSSL_STRING_push(sigopts, *(++argv))) goto bad; } else if (strcmp(*argv, "-days") == 0) { if (--argc < 1) goto bad; days = strtonum(*(++argv), 1, INT_MAX, &errstr); if (errstr) { BIO_printf(bio_err, "bad number of days: %s\n", errstr); goto bad; } } else if (strcmp(*argv, "-passin") == 0) { if (--argc < 1) goto bad; passargin = *(++argv); } else if (strcmp(*argv, "-extfile") == 0) { if (--argc < 1) goto bad; extfile = *(++argv); } else if (strcmp(*argv, "-extensions") == 0) { if (--argc < 1) goto bad; extsect = *(++argv); } else if (strcmp(*argv, "-in") == 0) { if (--argc < 1) goto bad; infile = *(++argv); } else if (strcmp(*argv, "-out") == 0) { if (--argc < 1) goto bad; outfile = *(++argv); } else if (strcmp(*argv, "-signkey") == 0) { if (--argc < 1) goto bad; keyfile = *(++argv); sign_flag = ++num; } else if (strcmp(*argv, "-CA") == 0) { if (--argc < 1) goto bad; CAfile = *(++argv); CA_flag = ++num; } else if (strcmp(*argv, "-CAkey") == 0) { if (--argc < 1) goto bad; CAkeyfile = *(++argv); } else if (strcmp(*argv, "-CAserial") == 0) { if (--argc < 1) goto bad; CAserial = *(++argv); } else if (strcmp(*argv, "-set_serial") == 0) { if (--argc < 1) goto bad; if (!(sno = s2i_ASN1_INTEGER(NULL, *(++argv)))) goto bad; } else if (strcmp(*argv, "-addtrust") == 0) { if (--argc < 1) goto bad; if (!(objtmp = OBJ_txt2obj(*(++argv), 0))) { BIO_printf(bio_err, "Invalid trust object value %s\n", *argv); goto bad; } if (!trust) trust = sk_ASN1_OBJECT_new_null(); sk_ASN1_OBJECT_push(trust, objtmp); trustout = 1; } else if (strcmp(*argv, "-addreject") == 0) { if (--argc < 1) goto bad; if (!(objtmp = OBJ_txt2obj(*(++argv), 0))) { BIO_printf(bio_err, "Invalid reject object value %s\n", *argv); goto bad; } if (!reject) reject = sk_ASN1_OBJECT_new_null(); sk_ASN1_OBJECT_push(reject, objtmp); trustout = 1; } else if (strcmp(*argv, "-setalias") == 0) { if (--argc < 1) goto bad; alias = *(++argv); trustout = 1; } else if (strcmp(*argv, "-certopt") == 0) { if (--argc < 1) goto bad; if (!set_cert_ex(&certflag, *(++argv))) goto bad; } else if (strcmp(*argv, "-nameopt") == 0) { if (--argc < 1) goto bad; if (!set_name_ex(&nmflag, *(++argv))) goto bad; } #ifndef OPENSSL_NO_ENGINE else if (strcmp(*argv, "-engine") == 0) { if (--argc < 1) goto bad; engine = *(++argv); } #endif else if (strcmp(*argv, "-C") == 0) C = ++num; else if (strcmp(*argv, "-email") == 0) email = ++num; else if (strcmp(*argv, "-ocsp_uri") == 0) ocsp_uri = ++num; else if (strcmp(*argv, "-serial") == 0) serial = ++num; else if (strcmp(*argv, "-next_serial") == 0) next_serial = ++num; else if (strcmp(*argv, "-modulus") == 0) modulus = ++num; else if (strcmp(*argv, "-pubkey") == 0) pubkey = ++num; else if (strcmp(*argv, "-x509toreq") == 0) x509req = ++num; else if (strcmp(*argv, "-text") == 0) text = ++num; else if (strcmp(*argv, "-hash") == 0 || strcmp(*argv, "-subject_hash") == 0) subject_hash = ++num; #ifndef OPENSSL_NO_MD5 else if (strcmp(*argv, "-subject_hash_old") == 0) subject_hash_old = ++num; #endif else if (strcmp(*argv, "-issuer_hash") == 0) issuer_hash = ++num; #ifndef OPENSSL_NO_MD5 else if (strcmp(*argv, "-issuer_hash_old") == 0) issuer_hash_old = ++num; #endif else if (strcmp(*argv, "-subject") == 0) subject = ++num; else if (strcmp(*argv, "-issuer") == 0) issuer = ++num; else if (strcmp(*argv, "-fingerprint") == 0) fingerprint = ++num; else if (strcmp(*argv, "-dates") == 0) { startdate = ++num; enddate = ++num; } else if (strcmp(*argv, "-purpose") == 0) pprint = ++num; else if (strcmp(*argv, "-startdate") == 0) startdate = ++num; else if (strcmp(*argv, "-enddate") == 0) enddate = ++num; else if (strcmp(*argv, "-checkend") == 0) { if (--argc < 1) goto bad; checkoffset = strtonum(*(++argv), 0, INT_MAX, &errstr); if (errstr) { BIO_printf(bio_err, "checkend unusable: %s\n", errstr); goto bad; } checkend = 1; } else if (strcmp(*argv, "-noout") == 0) noout = ++num; else if (strcmp(*argv, "-trustout") == 0) trustout = 1; else if (strcmp(*argv, "-clrtrust") == 0) clrtrust = ++num; else if (strcmp(*argv, "-clrreject") == 0) clrreject = ++num; else if (strcmp(*argv, "-alias") == 0) aliasout = ++num; else if (strcmp(*argv, "-CAcreateserial") == 0) CA_createserial = ++num; else if (strcmp(*argv, "-clrext") == 0) clrext = 1; else if (strcmp(*argv, "-ocspid") == 0) ocspid = ++num; else if ((md_alg = EVP_get_digestbyname(*argv + 1))) { /* ok */ digest = md_alg; } else { BIO_printf(bio_err, "unknown option %s\n", *argv); badops = 1; break; } argc--; argv++; } if (badops) { bad: for (pp = x509_usage; (*pp != NULL); pp++) BIO_printf(bio_err, "%s", *pp); goto end; } #ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); #endif ERR_load_crypto_strings(); if (!app_passwd(bio_err, passargin, NULL, &passin, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } if (!X509_STORE_set_default_paths(ctx)) { ERR_print_errors(bio_err); goto end; } if ((CAkeyfile == NULL) && (CA_flag) && (CAformat == FORMAT_PEM)) { CAkeyfile = CAfile; } else if ((CA_flag) && (CAkeyfile == NULL)) { BIO_printf(bio_err, "need to specify a CAkey if using the CA command\n"); goto end; } if (extfile) { long errorline = -1; X509V3_CTX ctx2; extconf = NCONF_new(NULL); if (!NCONF_load(extconf, extfile, &errorline)) { if (errorline <= 0) BIO_printf(bio_err, "error loading the config file '%s'\n", extfile); else BIO_printf(bio_err, "error on line %ld of config file '%s'\n", errorline, extfile); goto end; } if (!extsect) { extsect = NCONF_get_string(extconf, "default", "extensions"); if (!extsect) { ERR_clear_error(); extsect = "default"; } } X509V3_set_ctx_test(&ctx2); X509V3_set_nconf(&ctx2, extconf); if (!X509V3_EXT_add_nconf(extconf, &ctx2, extsect, NULL)) { BIO_printf(bio_err, "Error Loading extension section %s\n", extsect); ERR_print_errors(bio_err); goto end; } } if (reqfile) { EVP_PKEY *pkey; BIO *in; if (!sign_flag && !CA_flag) { BIO_printf(bio_err, "We need a private key to sign with\n"); goto end; } in = BIO_new(BIO_s_file()); if (in == NULL) { ERR_print_errors(bio_err); goto end; } if (infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE | BIO_FP_TEXT); else { if (BIO_read_filename(in, infile) <= 0) { perror(infile); BIO_free(in); goto end; } } req = PEM_read_bio_X509_REQ(in, NULL, NULL, NULL); BIO_free(in); if (req == NULL) { ERR_print_errors(bio_err); goto end; } if ((req->req_info == NULL) || (req->req_info->pubkey == NULL) || (req->req_info->pubkey->public_key == NULL) || (req->req_info->pubkey->public_key->data == NULL)) { BIO_printf(bio_err, "The certificate request appears to corrupted\n"); BIO_printf(bio_err, "It does not contain a public key\n"); goto end; } if ((pkey = X509_REQ_get_pubkey(req)) == NULL) { BIO_printf(bio_err, "error unpacking public key\n"); goto end; } i = X509_REQ_verify(req, pkey); EVP_PKEY_free(pkey); if (i < 0) { BIO_printf(bio_err, "Signature verification error\n"); ERR_print_errors(bio_err); goto end; } if (i == 0) { BIO_printf(bio_err, "Signature did not match the certificate request\n"); goto end; } else BIO_printf(bio_err, "Signature ok\n"); print_name(bio_err, "subject=", X509_REQ_get_subject_name(req), nmflag); if ((x = X509_new()) == NULL) goto end; if (sno == NULL) { sno = ASN1_INTEGER_new(); if (!sno || !rand_serial(NULL, sno)) goto end; if (!X509_set_serialNumber(x, sno)) goto end; ASN1_INTEGER_free(sno); sno = NULL; } else if (!X509_set_serialNumber(x, sno)) goto end; if (!X509_set_issuer_name(x, req->req_info->subject)) goto end; if (!X509_set_subject_name(x, req->req_info->subject)) goto end; X509_gmtime_adj(X509_get_notBefore(x), 0); X509_time_adj_ex(X509_get_notAfter(x), days, 0, NULL); pkey = X509_REQ_get_pubkey(req); X509_set_pubkey(x, pkey); EVP_PKEY_free(pkey); } else x = load_cert(bio_err, infile, informat, NULL, e, "Certificate"); if (x == NULL) goto end; if (CA_flag) { xca = load_cert(bio_err, CAfile, CAformat, NULL, e, "CA Certificate"); if (xca == NULL) goto end; } if (!noout || text || next_serial) { OBJ_create("2.99999.3", "SET.ex3", "SET x509v3 extension 3"); out = BIO_new(BIO_s_file()); if (out == NULL) { ERR_print_errors(bio_err); goto end; } if (outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { if (BIO_write_filename(out, outfile) <= 0) { perror(outfile); goto end; } } } if (alias) X509_alias_set1(x, (unsigned char *) alias, -1); if (clrtrust) X509_trust_clear(x); if (clrreject) X509_reject_clear(x); if (trust) { for (i = 0; i < sk_ASN1_OBJECT_num(trust); i++) { objtmp = sk_ASN1_OBJECT_value(trust, i); X509_add1_trust_object(x, objtmp); } } if (reject) { for (i = 0; i < sk_ASN1_OBJECT_num(reject); i++) { objtmp = sk_ASN1_OBJECT_value(reject, i); X509_add1_reject_object(x, objtmp); } } if (num) { for (i = 1; i <= num; i++) { if (issuer == i) { print_name(STDout, "issuer= ", X509_get_issuer_name(x), nmflag); } else if (subject == i) { print_name(STDout, "subject= ", X509_get_subject_name(x), nmflag); } else if (serial == i) { BIO_printf(STDout, "serial="); i2a_ASN1_INTEGER(STDout, X509_get_serialNumber(x)); BIO_printf(STDout, "\n"); } else if (next_serial == i) { BIGNUM *bnser; ASN1_INTEGER *ser; ser = X509_get_serialNumber(x); bnser = ASN1_INTEGER_to_BN(ser, NULL); if (!bnser) goto end; if (!BN_add_word(bnser, 1)) goto end; ser = BN_to_ASN1_INTEGER(bnser, NULL); if (!ser) goto end; BN_free(bnser); i2a_ASN1_INTEGER(out, ser); ASN1_INTEGER_free(ser); BIO_puts(out, "\n"); } else if ((email == i) || (ocsp_uri == i)) { int j; STACK_OF(OPENSSL_STRING) *emlst; if (email == i) emlst = X509_get1_email(x); else emlst = X509_get1_ocsp(x); for (j = 0; j < sk_OPENSSL_STRING_num(emlst); j++) BIO_printf(STDout, "%s\n", sk_OPENSSL_STRING_value(emlst, j)); X509_email_free(emlst); } else if (aliasout == i) { unsigned char *alstr; alstr = X509_alias_get0(x, NULL); if (alstr) BIO_printf(STDout, "%s\n", alstr); else BIO_puts(STDout, "\n"); } else if (subject_hash == i) { BIO_printf(STDout, "%08lx\n", X509_subject_name_hash(x)); } #ifndef OPENSSL_NO_MD5 else if (subject_hash_old == i) { BIO_printf(STDout, "%08lx\n", X509_subject_name_hash_old(x)); } #endif else if (issuer_hash == i) { BIO_printf(STDout, "%08lx\n", X509_issuer_name_hash(x)); } #ifndef OPENSSL_NO_MD5 else if (issuer_hash_old == i) { BIO_printf(STDout, "%08lx\n", X509_issuer_name_hash_old(x)); } #endif else if (pprint == i) { X509_PURPOSE *ptmp; int j; BIO_printf(STDout, "Certificate purposes:\n"); for (j = 0; j < X509_PURPOSE_get_count(); j++) { ptmp = X509_PURPOSE_get0(j); purpose_print(STDout, x, ptmp); } } else if (modulus == i) { EVP_PKEY *pkey; pkey = X509_get_pubkey(x); if (pkey == NULL) { BIO_printf(bio_err, "Modulus=unavailable\n"); ERR_print_errors(bio_err); goto end; } BIO_printf(STDout, "Modulus="); if (pkey->type == EVP_PKEY_RSA) BN_print(STDout, pkey->pkey.rsa->n); else if (pkey->type == EVP_PKEY_DSA) BN_print(STDout, pkey->pkey.dsa->pub_key); else BIO_printf(STDout, "Wrong Algorithm type"); BIO_printf(STDout, "\n"); EVP_PKEY_free(pkey); } else if (pubkey == i) { EVP_PKEY *pkey; pkey = X509_get_pubkey(x); if (pkey == NULL) { BIO_printf(bio_err, "Error getting public key\n"); ERR_print_errors(bio_err); goto end; } PEM_write_bio_PUBKEY(STDout, pkey); EVP_PKEY_free(pkey); } else if (C == i) { unsigned char *d; char *m; int y, z; X509_NAME_oneline(X509_get_subject_name(x), buf, sizeof buf); BIO_printf(STDout, "/* subject:%s */\n", buf); m = X509_NAME_oneline( X509_get_issuer_name(x), buf, sizeof buf); BIO_printf(STDout, "/* issuer :%s */\n", buf); z = i2d_X509(x, NULL); m = malloc(z); d = (unsigned char *) m; z = i2d_X509_NAME(X509_get_subject_name(x), &d); BIO_printf(STDout, "unsigned char XXX_subject_name[%d]={\n", z); d = (unsigned char *) m; for (y = 0; y < z; y++) { BIO_printf(STDout, "0x%02X,", d[y]); if ((y & 0x0f) == 0x0f) BIO_printf(STDout, "\n"); } if (y % 16 != 0) BIO_printf(STDout, "\n"); BIO_printf(STDout, "};\n"); z = i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x), &d); BIO_printf(STDout, "unsigned char XXX_public_key[%d]={\n", z); d = (unsigned char *) m; for (y = 0; y < z; y++) { BIO_printf(STDout, "0x%02X,", d[y]); if ((y & 0x0f) == 0x0f) BIO_printf(STDout, "\n"); } if (y % 16 != 0) BIO_printf(STDout, "\n"); BIO_printf(STDout, "};\n"); z = i2d_X509(x, &d); BIO_printf(STDout, "unsigned char XXX_certificate[%d]={\n", z); d = (unsigned char *) m; for (y = 0; y < z; y++) { BIO_printf(STDout, "0x%02X,", d[y]); if ((y & 0x0f) == 0x0f) BIO_printf(STDout, "\n"); } if (y % 16 != 0) BIO_printf(STDout, "\n"); BIO_printf(STDout, "};\n"); free(m); } else if (text == i) { X509_print_ex(STDout, x, nmflag, certflag); } else if (startdate == i) { BIO_puts(STDout, "notBefore="); ASN1_TIME_print(STDout, X509_get_notBefore(x)); BIO_puts(STDout, "\n"); } else if (enddate == i) { BIO_puts(STDout, "notAfter="); ASN1_TIME_print(STDout, X509_get_notAfter(x)); BIO_puts(STDout, "\n"); } else if (fingerprint == i) { int j; unsigned int n; unsigned char md[EVP_MAX_MD_SIZE]; const EVP_MD *fdig = digest; if (!fdig) fdig = EVP_sha1(); if (!X509_digest(x, fdig, md, &n)) { BIO_printf(bio_err, "out of memory\n"); goto end; } BIO_printf(STDout, "%s Fingerprint=", OBJ_nid2sn(EVP_MD_type(fdig))); for (j = 0; j < (int) n; j++) { BIO_printf(STDout, "%02X%c", md[j], (j + 1 == (int)n) ? '\n' : ':'); } } /* should be in the library */ else if ((sign_flag == i) && (x509req == 0)) { BIO_printf(bio_err, "Getting Private key\n"); if (Upkey == NULL) { Upkey = load_key(bio_err, keyfile, keyformat, 0, passin, e, "Private key"); if (Upkey == NULL) goto end; } if (!sign(x, Upkey, days, clrext, digest, extconf, extsect)) goto end; } else if (CA_flag == i) { BIO_printf(bio_err, "Getting CA Private Key\n"); if (CAkeyfile != NULL) { CApkey = load_key(bio_err, CAkeyfile, CAkeyformat, 0, passin, e, "CA Private Key"); if (CApkey == NULL) goto end; } if (!x509_certify(ctx, CAfile, digest, x, xca, CApkey, sigopts, CAserial, CA_createserial, days, clrext, extconf, extsect, sno)) goto end; } else if (x509req == i) { EVP_PKEY *pk; BIO_printf(bio_err, "Getting request Private Key\n"); if (keyfile == NULL) { BIO_printf(bio_err, "no request key file specified\n"); goto end; } else { pk = load_key(bio_err, keyfile, keyformat, 0, passin, e, "request key"); if (pk == NULL) goto end; } BIO_printf(bio_err, "Generating certificate request\n"); rq = X509_to_X509_REQ(x, pk, digest); EVP_PKEY_free(pk); if (rq == NULL) { ERR_print_errors(bio_err); goto end; } if (!noout) { X509_REQ_print(out, rq); PEM_write_bio_X509_REQ(out, rq); } noout = 1; } else if (ocspid == i) { X509_ocspid_print(out, x); } } } if (checkend) { time_t tcheck = time(NULL) + checkoffset; if (X509_cmp_time(X509_get_notAfter(x), &tcheck) < 0) { BIO_printf(out, "Certificate will expire\n"); ret = 1; } else { BIO_printf(out, "Certificate will not expire\n"); ret = 0; } goto end; } if (noout) { ret = 0; goto end; } if (outformat == FORMAT_ASN1) i = i2d_X509_bio(out, x); else if (outformat == FORMAT_PEM) { if (trustout) i = PEM_write_bio_X509_AUX(out, x); else i = PEM_write_bio_X509(out, x); } else if (outformat == FORMAT_NETSCAPE) { NETSCAPE_X509 nx; ASN1_OCTET_STRING hdr; hdr.data = (unsigned char *) NETSCAPE_CERT_HDR; hdr.length = strlen(NETSCAPE_CERT_HDR); nx.header = &hdr; nx.cert = x; i = ASN1_item_i2d_bio(ASN1_ITEM_rptr(NETSCAPE_X509), out, &nx); } else { BIO_printf(bio_err, "bad output format specified for outfile\n"); goto end; } if (!i) { BIO_printf(bio_err, "unable to write certificate\n"); ERR_print_errors(bio_err); goto end; } ret = 0; end: OBJ_cleanup(); NCONF_free(extconf); BIO_free_all(out); BIO_free_all(STDout); X509_STORE_free(ctx); X509_REQ_free(req); X509_free(x); X509_free(xca); EVP_PKEY_free(Upkey); EVP_PKEY_free(CApkey); if (sigopts) sk_OPENSSL_STRING_free(sigopts); X509_REQ_free(rq); ASN1_INTEGER_free(sno); sk_ASN1_OBJECT_pop_free(trust, ASN1_OBJECT_free); sk_ASN1_OBJECT_pop_free(reject, ASN1_OBJECT_free); free(passin); return (ret); } static ASN1_INTEGER * x509_load_serial(char *CAfile, char *serialfile, int create) { char *buf = NULL, *p; ASN1_INTEGER *bs = NULL; BIGNUM *serial = NULL; size_t len; len = ((serialfile == NULL) ? (strlen(CAfile) + strlen(POSTFIX) + 1) : (strlen(serialfile))) + 1; buf = malloc(len); if (buf == NULL) { BIO_printf(bio_err, "out of mem\n"); goto end; } if (serialfile == NULL) { strlcpy(buf, CAfile, len); for (p = buf; *p; p++) if (*p == '.') { *p = '\0'; break; } strlcat(buf, POSTFIX, len); } else strlcpy(buf, serialfile, len); serial = load_serial(buf, create, NULL); if (serial == NULL) goto end; if (!BN_add_word(serial, 1)) { BIO_printf(bio_err, "add_word failure\n"); goto end; } if (!save_serial(buf, NULL, serial, &bs)) goto end; end: free(buf); BN_free(serial); return bs; } static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest, X509 *x, X509 *xca, EVP_PKEY *pkey, STACK_OF(OPENSSL_STRING) *sigopts, char *serialfile, int create, int days, int clrext, CONF *conf, char *section, ASN1_INTEGER *sno) { int ret = 0; ASN1_INTEGER *bs = NULL; X509_STORE_CTX xsc; EVP_PKEY *upkey; upkey = X509_get_pubkey(xca); EVP_PKEY_copy_parameters(upkey, pkey); EVP_PKEY_free(upkey); if (!X509_STORE_CTX_init(&xsc, ctx, x, NULL)) { BIO_printf(bio_err, "Error initialising X509 store\n"); goto end; } if (sno) bs = sno; else if (!(bs = x509_load_serial(CAfile, serialfile, create))) goto end; /* if (!X509_STORE_add_cert(ctx,x)) goto end;*/ /* * NOTE: this certificate can/should be self signed, unless it was a * certificate request in which case it is not. */ X509_STORE_CTX_set_cert(&xsc, x); X509_STORE_CTX_set_flags(&xsc, X509_V_FLAG_CHECK_SS_SIGNATURE); if (!reqfile && X509_verify_cert(&xsc) <= 0) goto end; if (!X509_check_private_key(xca, pkey)) { BIO_printf(bio_err, "CA certificate and CA private key do not match\n"); goto end; } if (!X509_set_issuer_name(x, X509_get_subject_name(xca))) goto end; if (!X509_set_serialNumber(x, bs)) goto end; if (X509_gmtime_adj(X509_get_notBefore(x), 0L) == NULL) goto end; /* hardwired expired */ if (X509_time_adj_ex(X509_get_notAfter(x), days, 0, NULL) == NULL) goto end; if (clrext) { while (X509_get_ext_count(x) > 0) X509_delete_ext(x, 0); } if (conf) { X509V3_CTX ctx2; X509_set_version(x, 2); /* version 3 certificate */ X509V3_set_ctx(&ctx2, xca, x, NULL, NULL, 0); X509V3_set_nconf(&ctx2, conf); if (!X509V3_EXT_add_nconf(conf, &ctx2, section, x)) goto end; } if (!do_X509_sign(bio_err, x, pkey, digest, sigopts)) goto end; ret = 1; end: X509_STORE_CTX_cleanup(&xsc); if (!ret) ERR_print_errors(bio_err); if (!sno) ASN1_INTEGER_free(bs); return ret; } static int callb(int ok, X509_STORE_CTX *ctx) { int err; X509 *err_cert; /* * it is ok to use a self signed certificate This case will catch * both the initial ok == 0 and the final ok == 1 calls to this * function */ err = X509_STORE_CTX_get_error(ctx); if (err == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) return 1; /* * BAD we should have gotten an error. Normally if everything worked * X509_STORE_CTX_get_error(ctx) will still be set to * DEPTH_ZERO_SELF_.... */ if (ok) { BIO_printf(bio_err, "error with certificate to be certified - should be self signed\n"); return 0; } else { err_cert = X509_STORE_CTX_get_current_cert(ctx); print_name(bio_err, NULL, X509_get_subject_name(err_cert), 0); BIO_printf(bio_err, "error with certificate - error %d at depth %d\n%s\n", err, X509_STORE_CTX_get_error_depth(ctx), X509_verify_cert_error_string(err)); return 1; } } /* self sign */ static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext, const EVP_MD *digest, CONF *conf, char *section) { EVP_PKEY *pktmp; pktmp = X509_get_pubkey(x); EVP_PKEY_copy_parameters(pktmp, pkey); EVP_PKEY_save_parameters(pktmp, 1); EVP_PKEY_free(pktmp); if (!X509_set_issuer_name(x, X509_get_subject_name(x))) goto err; if (X509_gmtime_adj(X509_get_notBefore(x), 0) == NULL) goto err; /* Lets just make it 12:00am GMT, Jan 1 1970 */ /* memcpy(x->cert_info->validity->notBefore,"700101120000Z",13); */ /* 28 days to be certified */ if (X509_gmtime_adj(X509_get_notAfter(x), (long) 60 * 60 * 24 * days) == NULL) goto err; if (!X509_set_pubkey(x, pkey)) goto err; if (clrext) { while (X509_get_ext_count(x) > 0) X509_delete_ext(x, 0); } if (conf) { X509V3_CTX ctx; X509_set_version(x, 2); /* version 3 certificate */ X509V3_set_ctx(&ctx, x, x, NULL, NULL, 0); X509V3_set_nconf(&ctx, conf); if (!X509V3_EXT_add_nconf(conf, &ctx, section, x)) goto err; } if (!X509_sign(x, pkey, digest)) goto err; return 1; err: ERR_print_errors(bio_err); return 0; } static int purpose_print(BIO *bio, X509 *cert, X509_PURPOSE *pt) { int id, i, idret; char *pname; id = X509_PURPOSE_get_id(pt); pname = X509_PURPOSE_get0_name(pt); for (i = 0; i < 2; i++) { idret = X509_check_purpose(cert, id, i); BIO_printf(bio, "%s%s : ", pname, i ? " CA" : ""); if (idret == 1) BIO_printf(bio, "Yes\n"); else if (idret == 0) BIO_printf(bio, "No\n"); else BIO_printf(bio, "Yes (WARNING code=%d)\n", idret); } return 1; } deps/libressl-pnacl-sys-2.1.6/libressl/apps/Makefile.in0000664000175000017500000033351412437255267020000 0ustar # Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ DIST_COMMON = $(top_srcdir)/Makefile.am.common $(srcdir)/Makefile.in \ $(srcdir)/Makefile.am $(top_srcdir)/depcomp $(noinst_HEADERS) bin_PROGRAMS = openssl$(EXEEXT) @NO_STRTONUM_TRUE@am__append_1 = strtonum.c subdir = apps ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am__openssl_SOURCES_DIST = strtonum.c apps.c asn1pars.c ca.c ciphers.c \ cms.c crl.c crl2p7.c dgst.c dh.c dhparam.c dsa.c dsaparam.c \ ec.c ecparam.c enc.c engine.c errstr.c gendh.c gendsa.c \ genpkey.c genrsa.c nseq.c ocsp.c openssl.c passwd.c pkcs12.c \ pkcs7.c pkcs8.c pkey.c pkeyparam.c pkeyutl.c prime.c rand.c \ req.c rsa.c rsautl.c s_cb.c s_client.c s_server.c s_socket.c \ s_time.c sess_id.c smime.c speed.c spkac.c ts.c verify.c \ version.c x509.c @NO_STRTONUM_TRUE@am__objects_1 = openssl-strtonum.$(OBJEXT) am_openssl_OBJECTS = $(am__objects_1) openssl-apps.$(OBJEXT) \ openssl-asn1pars.$(OBJEXT) openssl-ca.$(OBJEXT) \ openssl-ciphers.$(OBJEXT) openssl-cms.$(OBJEXT) \ openssl-crl.$(OBJEXT) openssl-crl2p7.$(OBJEXT) \ openssl-dgst.$(OBJEXT) openssl-dh.$(OBJEXT) \ openssl-dhparam.$(OBJEXT) openssl-dsa.$(OBJEXT) \ openssl-dsaparam.$(OBJEXT) openssl-ec.$(OBJEXT) \ openssl-ecparam.$(OBJEXT) openssl-enc.$(OBJEXT) \ openssl-engine.$(OBJEXT) openssl-errstr.$(OBJEXT) \ openssl-gendh.$(OBJEXT) openssl-gendsa.$(OBJEXT) \ openssl-genpkey.$(OBJEXT) openssl-genrsa.$(OBJEXT) \ openssl-nseq.$(OBJEXT) openssl-ocsp.$(OBJEXT) \ openssl-openssl.$(OBJEXT) openssl-passwd.$(OBJEXT) \ openssl-pkcs12.$(OBJEXT) openssl-pkcs7.$(OBJEXT) \ openssl-pkcs8.$(OBJEXT) openssl-pkey.$(OBJEXT) \ openssl-pkeyparam.$(OBJEXT) openssl-pkeyutl.$(OBJEXT) \ openssl-prime.$(OBJEXT) openssl-rand.$(OBJEXT) \ openssl-req.$(OBJEXT) openssl-rsa.$(OBJEXT) \ openssl-rsautl.$(OBJEXT) openssl-s_cb.$(OBJEXT) \ openssl-s_client.$(OBJEXT) openssl-s_server.$(OBJEXT) \ openssl-s_socket.$(OBJEXT) openssl-s_time.$(OBJEXT) \ openssl-sess_id.$(OBJEXT) openssl-smime.$(OBJEXT) \ openssl-speed.$(OBJEXT) openssl-spkac.$(OBJEXT) \ openssl-ts.$(OBJEXT) openssl-verify.$(OBJEXT) \ openssl-version.$(OBJEXT) openssl-x509.$(OBJEXT) openssl_OBJECTS = $(am_openssl_OBJECTS) am__DEPENDENCIES_1 = openssl_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(top_builddir)/crypto/libcrypto.la \ $(top_builddir)/ssl/libssl.la AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = openssl_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(openssl_CFLAGS) \ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(openssl_SOURCES) DIST_SOURCES = $(am__openssl_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac HEADERS = $(noinst_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ NO_ARC4RANDOM_BUF = @NO_ARC4RANDOM_BUF@ NO_GETENTROPY = @NO_GETENTROPY@ NO_ISSETUGID = @NO_ISSETUGID@ NO_REALLOCARRAY = @NO_REALLOCARRAY@ NO_STRLCAT = @NO_STRLCAT@ NO_STRLCPY = @NO_STRLCPY@ NO_STRTONUM = @NO_STRTONUM@ NO_TIMINGSAFE_BCMP = @NO_TIMINGSAFE_BCMP@ NO_TIMINGSAFE_MEMCMP = @NO_TIMINGSAFE_MEMCMP@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PLATFORM_LDADD = @PLATFORM_LDADD@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ USER_CFLAGS = @USER_CFLAGS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = -I$(top_srcdir)/include -DOPENSSL_NO_ASM \ -DHAVE_CRYPTODEV -DLIBRESSL_INTERNAL openssl_CFLAGS = $(USER_CFLAGS) openssl_LDADD = $(PLATFORM_LDADD) $(top_builddir)/crypto/libcrypto.la \ $(top_builddir)/ssl/libssl.la openssl_SOURCES = $(am__append_1) apps.c asn1pars.c ca.c ciphers.c \ cms.c crl.c crl2p7.c dgst.c dh.c dhparam.c dsa.c dsaparam.c \ ec.c ecparam.c enc.c engine.c errstr.c gendh.c gendsa.c \ genpkey.c genrsa.c nseq.c ocsp.c openssl.c passwd.c pkcs12.c \ pkcs7.c pkcs8.c pkey.c pkeyparam.c pkeyutl.c prime.c rand.c \ req.c rsa.c rsautl.c s_cb.c s_client.c s_server.c s_socket.c \ s_time.c sess_id.c smime.c speed.c spkac.c ts.c verify.c \ version.c x509.c noinst_HEADERS = apps.h progs.h s_apps.h testdsa.h testrsa.h \ timeouts.h all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.am.common $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu apps/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu apps/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_srcdir)/Makefile.am.common: $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p \ || test -f $$p1 \ ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' \ -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' \ `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list openssl$(EXEEXT): $(openssl_OBJECTS) $(openssl_DEPENDENCIES) $(EXTRA_openssl_DEPENDENCIES) @rm -f openssl$(EXEEXT) $(AM_V_CCLD)$(openssl_LINK) $(openssl_OBJECTS) $(openssl_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-apps.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-asn1pars.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-ca.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-ciphers.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-cms.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-crl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-crl2p7.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-dgst.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-dh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-dhparam.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-dsa.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-dsaparam.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-ec.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-ecparam.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-enc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-engine.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-errstr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-gendh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-gendsa.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-genpkey.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-genrsa.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-nseq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-ocsp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-openssl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-passwd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-pkcs12.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-pkcs7.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-pkcs8.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-pkey.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-pkeyparam.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-pkeyutl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-prime.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-rand.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-req.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-rsa.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-rsautl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-s_cb.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-s_client.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-s_server.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-s_socket.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-s_time.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-sess_id.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-smime.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-speed.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-spkac.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-strtonum.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-ts.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-verify.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-version.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openssl-x509.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< openssl-strtonum.o: strtonum.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-strtonum.o -MD -MP -MF $(DEPDIR)/openssl-strtonum.Tpo -c -o openssl-strtonum.o `test -f 'strtonum.c' || echo '$(srcdir)/'`strtonum.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-strtonum.Tpo $(DEPDIR)/openssl-strtonum.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='strtonum.c' object='openssl-strtonum.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-strtonum.o `test -f 'strtonum.c' || echo '$(srcdir)/'`strtonum.c openssl-strtonum.obj: strtonum.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-strtonum.obj -MD -MP -MF $(DEPDIR)/openssl-strtonum.Tpo -c -o openssl-strtonum.obj `if test -f 'strtonum.c'; then $(CYGPATH_W) 'strtonum.c'; else $(CYGPATH_W) '$(srcdir)/strtonum.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-strtonum.Tpo $(DEPDIR)/openssl-strtonum.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='strtonum.c' object='openssl-strtonum.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-strtonum.obj `if test -f 'strtonum.c'; then $(CYGPATH_W) 'strtonum.c'; else $(CYGPATH_W) '$(srcdir)/strtonum.c'; fi` openssl-apps.o: apps.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-apps.o -MD -MP -MF $(DEPDIR)/openssl-apps.Tpo -c -o openssl-apps.o `test -f 'apps.c' || echo '$(srcdir)/'`apps.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-apps.Tpo $(DEPDIR)/openssl-apps.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='apps.c' object='openssl-apps.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-apps.o `test -f 'apps.c' || echo '$(srcdir)/'`apps.c openssl-apps.obj: apps.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-apps.obj -MD -MP -MF $(DEPDIR)/openssl-apps.Tpo -c -o openssl-apps.obj `if test -f 'apps.c'; then $(CYGPATH_W) 'apps.c'; else $(CYGPATH_W) '$(srcdir)/apps.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-apps.Tpo $(DEPDIR)/openssl-apps.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='apps.c' object='openssl-apps.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-apps.obj `if test -f 'apps.c'; then $(CYGPATH_W) 'apps.c'; else $(CYGPATH_W) '$(srcdir)/apps.c'; fi` openssl-asn1pars.o: asn1pars.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-asn1pars.o -MD -MP -MF $(DEPDIR)/openssl-asn1pars.Tpo -c -o openssl-asn1pars.o `test -f 'asn1pars.c' || echo '$(srcdir)/'`asn1pars.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-asn1pars.Tpo $(DEPDIR)/openssl-asn1pars.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1pars.c' object='openssl-asn1pars.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-asn1pars.o `test -f 'asn1pars.c' || echo '$(srcdir)/'`asn1pars.c openssl-asn1pars.obj: asn1pars.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-asn1pars.obj -MD -MP -MF $(DEPDIR)/openssl-asn1pars.Tpo -c -o openssl-asn1pars.obj `if test -f 'asn1pars.c'; then $(CYGPATH_W) 'asn1pars.c'; else $(CYGPATH_W) '$(srcdir)/asn1pars.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-asn1pars.Tpo $(DEPDIR)/openssl-asn1pars.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1pars.c' object='openssl-asn1pars.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-asn1pars.obj `if test -f 'asn1pars.c'; then $(CYGPATH_W) 'asn1pars.c'; else $(CYGPATH_W) '$(srcdir)/asn1pars.c'; fi` openssl-ca.o: ca.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-ca.o -MD -MP -MF $(DEPDIR)/openssl-ca.Tpo -c -o openssl-ca.o `test -f 'ca.c' || echo '$(srcdir)/'`ca.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-ca.Tpo $(DEPDIR)/openssl-ca.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ca.c' object='openssl-ca.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-ca.o `test -f 'ca.c' || echo '$(srcdir)/'`ca.c openssl-ca.obj: ca.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-ca.obj -MD -MP -MF $(DEPDIR)/openssl-ca.Tpo -c -o openssl-ca.obj `if test -f 'ca.c'; then $(CYGPATH_W) 'ca.c'; else $(CYGPATH_W) '$(srcdir)/ca.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-ca.Tpo $(DEPDIR)/openssl-ca.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ca.c' object='openssl-ca.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-ca.obj `if test -f 'ca.c'; then $(CYGPATH_W) 'ca.c'; else $(CYGPATH_W) '$(srcdir)/ca.c'; fi` openssl-ciphers.o: ciphers.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-ciphers.o -MD -MP -MF $(DEPDIR)/openssl-ciphers.Tpo -c -o openssl-ciphers.o `test -f 'ciphers.c' || echo '$(srcdir)/'`ciphers.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-ciphers.Tpo $(DEPDIR)/openssl-ciphers.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ciphers.c' object='openssl-ciphers.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-ciphers.o `test -f 'ciphers.c' || echo '$(srcdir)/'`ciphers.c openssl-ciphers.obj: ciphers.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-ciphers.obj -MD -MP -MF $(DEPDIR)/openssl-ciphers.Tpo -c -o openssl-ciphers.obj `if test -f 'ciphers.c'; then $(CYGPATH_W) 'ciphers.c'; else $(CYGPATH_W) '$(srcdir)/ciphers.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-ciphers.Tpo $(DEPDIR)/openssl-ciphers.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ciphers.c' object='openssl-ciphers.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-ciphers.obj `if test -f 'ciphers.c'; then $(CYGPATH_W) 'ciphers.c'; else $(CYGPATH_W) '$(srcdir)/ciphers.c'; fi` openssl-cms.o: cms.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-cms.o -MD -MP -MF $(DEPDIR)/openssl-cms.Tpo -c -o openssl-cms.o `test -f 'cms.c' || echo '$(srcdir)/'`cms.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-cms.Tpo $(DEPDIR)/openssl-cms.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cms.c' object='openssl-cms.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-cms.o `test -f 'cms.c' || echo '$(srcdir)/'`cms.c openssl-cms.obj: cms.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-cms.obj -MD -MP -MF $(DEPDIR)/openssl-cms.Tpo -c -o openssl-cms.obj `if test -f 'cms.c'; then $(CYGPATH_W) 'cms.c'; else $(CYGPATH_W) '$(srcdir)/cms.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-cms.Tpo $(DEPDIR)/openssl-cms.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cms.c' object='openssl-cms.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-cms.obj `if test -f 'cms.c'; then $(CYGPATH_W) 'cms.c'; else $(CYGPATH_W) '$(srcdir)/cms.c'; fi` openssl-crl.o: crl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-crl.o -MD -MP -MF $(DEPDIR)/openssl-crl.Tpo -c -o openssl-crl.o `test -f 'crl.c' || echo '$(srcdir)/'`crl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-crl.Tpo $(DEPDIR)/openssl-crl.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='crl.c' object='openssl-crl.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-crl.o `test -f 'crl.c' || echo '$(srcdir)/'`crl.c openssl-crl.obj: crl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-crl.obj -MD -MP -MF $(DEPDIR)/openssl-crl.Tpo -c -o openssl-crl.obj `if test -f 'crl.c'; then $(CYGPATH_W) 'crl.c'; else $(CYGPATH_W) '$(srcdir)/crl.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-crl.Tpo $(DEPDIR)/openssl-crl.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='crl.c' object='openssl-crl.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-crl.obj `if test -f 'crl.c'; then $(CYGPATH_W) 'crl.c'; else $(CYGPATH_W) '$(srcdir)/crl.c'; fi` openssl-crl2p7.o: crl2p7.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-crl2p7.o -MD -MP -MF $(DEPDIR)/openssl-crl2p7.Tpo -c -o openssl-crl2p7.o `test -f 'crl2p7.c' || echo '$(srcdir)/'`crl2p7.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-crl2p7.Tpo $(DEPDIR)/openssl-crl2p7.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='crl2p7.c' object='openssl-crl2p7.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-crl2p7.o `test -f 'crl2p7.c' || echo '$(srcdir)/'`crl2p7.c openssl-crl2p7.obj: crl2p7.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-crl2p7.obj -MD -MP -MF $(DEPDIR)/openssl-crl2p7.Tpo -c -o openssl-crl2p7.obj `if test -f 'crl2p7.c'; then $(CYGPATH_W) 'crl2p7.c'; else $(CYGPATH_W) '$(srcdir)/crl2p7.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-crl2p7.Tpo $(DEPDIR)/openssl-crl2p7.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='crl2p7.c' object='openssl-crl2p7.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-crl2p7.obj `if test -f 'crl2p7.c'; then $(CYGPATH_W) 'crl2p7.c'; else $(CYGPATH_W) '$(srcdir)/crl2p7.c'; fi` openssl-dgst.o: dgst.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-dgst.o -MD -MP -MF $(DEPDIR)/openssl-dgst.Tpo -c -o openssl-dgst.o `test -f 'dgst.c' || echo '$(srcdir)/'`dgst.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-dgst.Tpo $(DEPDIR)/openssl-dgst.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dgst.c' object='openssl-dgst.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-dgst.o `test -f 'dgst.c' || echo '$(srcdir)/'`dgst.c openssl-dgst.obj: dgst.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-dgst.obj -MD -MP -MF $(DEPDIR)/openssl-dgst.Tpo -c -o openssl-dgst.obj `if test -f 'dgst.c'; then $(CYGPATH_W) 'dgst.c'; else $(CYGPATH_W) '$(srcdir)/dgst.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-dgst.Tpo $(DEPDIR)/openssl-dgst.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dgst.c' object='openssl-dgst.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-dgst.obj `if test -f 'dgst.c'; then $(CYGPATH_W) 'dgst.c'; else $(CYGPATH_W) '$(srcdir)/dgst.c'; fi` openssl-dh.o: dh.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-dh.o -MD -MP -MF $(DEPDIR)/openssl-dh.Tpo -c -o openssl-dh.o `test -f 'dh.c' || echo '$(srcdir)/'`dh.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-dh.Tpo $(DEPDIR)/openssl-dh.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dh.c' object='openssl-dh.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-dh.o `test -f 'dh.c' || echo '$(srcdir)/'`dh.c openssl-dh.obj: dh.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-dh.obj -MD -MP -MF $(DEPDIR)/openssl-dh.Tpo -c -o openssl-dh.obj `if test -f 'dh.c'; then $(CYGPATH_W) 'dh.c'; else $(CYGPATH_W) '$(srcdir)/dh.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-dh.Tpo $(DEPDIR)/openssl-dh.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dh.c' object='openssl-dh.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-dh.obj `if test -f 'dh.c'; then $(CYGPATH_W) 'dh.c'; else $(CYGPATH_W) '$(srcdir)/dh.c'; fi` openssl-dhparam.o: dhparam.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-dhparam.o -MD -MP -MF $(DEPDIR)/openssl-dhparam.Tpo -c -o openssl-dhparam.o `test -f 'dhparam.c' || echo '$(srcdir)/'`dhparam.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-dhparam.Tpo $(DEPDIR)/openssl-dhparam.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dhparam.c' object='openssl-dhparam.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-dhparam.o `test -f 'dhparam.c' || echo '$(srcdir)/'`dhparam.c openssl-dhparam.obj: dhparam.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-dhparam.obj -MD -MP -MF $(DEPDIR)/openssl-dhparam.Tpo -c -o openssl-dhparam.obj `if test -f 'dhparam.c'; then $(CYGPATH_W) 'dhparam.c'; else $(CYGPATH_W) '$(srcdir)/dhparam.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-dhparam.Tpo $(DEPDIR)/openssl-dhparam.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dhparam.c' object='openssl-dhparam.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-dhparam.obj `if test -f 'dhparam.c'; then $(CYGPATH_W) 'dhparam.c'; else $(CYGPATH_W) '$(srcdir)/dhparam.c'; fi` openssl-dsa.o: dsa.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-dsa.o -MD -MP -MF $(DEPDIR)/openssl-dsa.Tpo -c -o openssl-dsa.o `test -f 'dsa.c' || echo '$(srcdir)/'`dsa.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-dsa.Tpo $(DEPDIR)/openssl-dsa.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa.c' object='openssl-dsa.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-dsa.o `test -f 'dsa.c' || echo '$(srcdir)/'`dsa.c openssl-dsa.obj: dsa.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-dsa.obj -MD -MP -MF $(DEPDIR)/openssl-dsa.Tpo -c -o openssl-dsa.obj `if test -f 'dsa.c'; then $(CYGPATH_W) 'dsa.c'; else $(CYGPATH_W) '$(srcdir)/dsa.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-dsa.Tpo $(DEPDIR)/openssl-dsa.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa.c' object='openssl-dsa.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-dsa.obj `if test -f 'dsa.c'; then $(CYGPATH_W) 'dsa.c'; else $(CYGPATH_W) '$(srcdir)/dsa.c'; fi` openssl-dsaparam.o: dsaparam.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-dsaparam.o -MD -MP -MF $(DEPDIR)/openssl-dsaparam.Tpo -c -o openssl-dsaparam.o `test -f 'dsaparam.c' || echo '$(srcdir)/'`dsaparam.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-dsaparam.Tpo $(DEPDIR)/openssl-dsaparam.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsaparam.c' object='openssl-dsaparam.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-dsaparam.o `test -f 'dsaparam.c' || echo '$(srcdir)/'`dsaparam.c openssl-dsaparam.obj: dsaparam.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-dsaparam.obj -MD -MP -MF $(DEPDIR)/openssl-dsaparam.Tpo -c -o openssl-dsaparam.obj `if test -f 'dsaparam.c'; then $(CYGPATH_W) 'dsaparam.c'; else $(CYGPATH_W) '$(srcdir)/dsaparam.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-dsaparam.Tpo $(DEPDIR)/openssl-dsaparam.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsaparam.c' object='openssl-dsaparam.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-dsaparam.obj `if test -f 'dsaparam.c'; then $(CYGPATH_W) 'dsaparam.c'; else $(CYGPATH_W) '$(srcdir)/dsaparam.c'; fi` openssl-ec.o: ec.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-ec.o -MD -MP -MF $(DEPDIR)/openssl-ec.Tpo -c -o openssl-ec.o `test -f 'ec.c' || echo '$(srcdir)/'`ec.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-ec.Tpo $(DEPDIR)/openssl-ec.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec.c' object='openssl-ec.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-ec.o `test -f 'ec.c' || echo '$(srcdir)/'`ec.c openssl-ec.obj: ec.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-ec.obj -MD -MP -MF $(DEPDIR)/openssl-ec.Tpo -c -o openssl-ec.obj `if test -f 'ec.c'; then $(CYGPATH_W) 'ec.c'; else $(CYGPATH_W) '$(srcdir)/ec.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-ec.Tpo $(DEPDIR)/openssl-ec.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec.c' object='openssl-ec.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-ec.obj `if test -f 'ec.c'; then $(CYGPATH_W) 'ec.c'; else $(CYGPATH_W) '$(srcdir)/ec.c'; fi` openssl-ecparam.o: ecparam.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-ecparam.o -MD -MP -MF $(DEPDIR)/openssl-ecparam.Tpo -c -o openssl-ecparam.o `test -f 'ecparam.c' || echo '$(srcdir)/'`ecparam.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-ecparam.Tpo $(DEPDIR)/openssl-ecparam.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ecparam.c' object='openssl-ecparam.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-ecparam.o `test -f 'ecparam.c' || echo '$(srcdir)/'`ecparam.c openssl-ecparam.obj: ecparam.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-ecparam.obj -MD -MP -MF $(DEPDIR)/openssl-ecparam.Tpo -c -o openssl-ecparam.obj `if test -f 'ecparam.c'; then $(CYGPATH_W) 'ecparam.c'; else $(CYGPATH_W) '$(srcdir)/ecparam.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-ecparam.Tpo $(DEPDIR)/openssl-ecparam.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ecparam.c' object='openssl-ecparam.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-ecparam.obj `if test -f 'ecparam.c'; then $(CYGPATH_W) 'ecparam.c'; else $(CYGPATH_W) '$(srcdir)/ecparam.c'; fi` openssl-enc.o: enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-enc.o -MD -MP -MF $(DEPDIR)/openssl-enc.Tpo -c -o openssl-enc.o `test -f 'enc.c' || echo '$(srcdir)/'`enc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-enc.Tpo $(DEPDIR)/openssl-enc.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='enc.c' object='openssl-enc.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-enc.o `test -f 'enc.c' || echo '$(srcdir)/'`enc.c openssl-enc.obj: enc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-enc.obj -MD -MP -MF $(DEPDIR)/openssl-enc.Tpo -c -o openssl-enc.obj `if test -f 'enc.c'; then $(CYGPATH_W) 'enc.c'; else $(CYGPATH_W) '$(srcdir)/enc.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-enc.Tpo $(DEPDIR)/openssl-enc.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='enc.c' object='openssl-enc.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-enc.obj `if test -f 'enc.c'; then $(CYGPATH_W) 'enc.c'; else $(CYGPATH_W) '$(srcdir)/enc.c'; fi` openssl-engine.o: engine.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-engine.o -MD -MP -MF $(DEPDIR)/openssl-engine.Tpo -c -o openssl-engine.o `test -f 'engine.c' || echo '$(srcdir)/'`engine.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-engine.Tpo $(DEPDIR)/openssl-engine.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine.c' object='openssl-engine.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-engine.o `test -f 'engine.c' || echo '$(srcdir)/'`engine.c openssl-engine.obj: engine.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-engine.obj -MD -MP -MF $(DEPDIR)/openssl-engine.Tpo -c -o openssl-engine.obj `if test -f 'engine.c'; then $(CYGPATH_W) 'engine.c'; else $(CYGPATH_W) '$(srcdir)/engine.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-engine.Tpo $(DEPDIR)/openssl-engine.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='engine.c' object='openssl-engine.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-engine.obj `if test -f 'engine.c'; then $(CYGPATH_W) 'engine.c'; else $(CYGPATH_W) '$(srcdir)/engine.c'; fi` openssl-errstr.o: errstr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-errstr.o -MD -MP -MF $(DEPDIR)/openssl-errstr.Tpo -c -o openssl-errstr.o `test -f 'errstr.c' || echo '$(srcdir)/'`errstr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-errstr.Tpo $(DEPDIR)/openssl-errstr.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='errstr.c' object='openssl-errstr.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-errstr.o `test -f 'errstr.c' || echo '$(srcdir)/'`errstr.c openssl-errstr.obj: errstr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-errstr.obj -MD -MP -MF $(DEPDIR)/openssl-errstr.Tpo -c -o openssl-errstr.obj `if test -f 'errstr.c'; then $(CYGPATH_W) 'errstr.c'; else $(CYGPATH_W) '$(srcdir)/errstr.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-errstr.Tpo $(DEPDIR)/openssl-errstr.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='errstr.c' object='openssl-errstr.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-errstr.obj `if test -f 'errstr.c'; then $(CYGPATH_W) 'errstr.c'; else $(CYGPATH_W) '$(srcdir)/errstr.c'; fi` openssl-gendh.o: gendh.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-gendh.o -MD -MP -MF $(DEPDIR)/openssl-gendh.Tpo -c -o openssl-gendh.o `test -f 'gendh.c' || echo '$(srcdir)/'`gendh.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-gendh.Tpo $(DEPDIR)/openssl-gendh.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gendh.c' object='openssl-gendh.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-gendh.o `test -f 'gendh.c' || echo '$(srcdir)/'`gendh.c openssl-gendh.obj: gendh.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-gendh.obj -MD -MP -MF $(DEPDIR)/openssl-gendh.Tpo -c -o openssl-gendh.obj `if test -f 'gendh.c'; then $(CYGPATH_W) 'gendh.c'; else $(CYGPATH_W) '$(srcdir)/gendh.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-gendh.Tpo $(DEPDIR)/openssl-gendh.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gendh.c' object='openssl-gendh.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-gendh.obj `if test -f 'gendh.c'; then $(CYGPATH_W) 'gendh.c'; else $(CYGPATH_W) '$(srcdir)/gendh.c'; fi` openssl-gendsa.o: gendsa.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-gendsa.o -MD -MP -MF $(DEPDIR)/openssl-gendsa.Tpo -c -o openssl-gendsa.o `test -f 'gendsa.c' || echo '$(srcdir)/'`gendsa.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-gendsa.Tpo $(DEPDIR)/openssl-gendsa.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gendsa.c' object='openssl-gendsa.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-gendsa.o `test -f 'gendsa.c' || echo '$(srcdir)/'`gendsa.c openssl-gendsa.obj: gendsa.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-gendsa.obj -MD -MP -MF $(DEPDIR)/openssl-gendsa.Tpo -c -o openssl-gendsa.obj `if test -f 'gendsa.c'; then $(CYGPATH_W) 'gendsa.c'; else $(CYGPATH_W) '$(srcdir)/gendsa.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-gendsa.Tpo $(DEPDIR)/openssl-gendsa.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gendsa.c' object='openssl-gendsa.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-gendsa.obj `if test -f 'gendsa.c'; then $(CYGPATH_W) 'gendsa.c'; else $(CYGPATH_W) '$(srcdir)/gendsa.c'; fi` openssl-genpkey.o: genpkey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-genpkey.o -MD -MP -MF $(DEPDIR)/openssl-genpkey.Tpo -c -o openssl-genpkey.o `test -f 'genpkey.c' || echo '$(srcdir)/'`genpkey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-genpkey.Tpo $(DEPDIR)/openssl-genpkey.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='genpkey.c' object='openssl-genpkey.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-genpkey.o `test -f 'genpkey.c' || echo '$(srcdir)/'`genpkey.c openssl-genpkey.obj: genpkey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-genpkey.obj -MD -MP -MF $(DEPDIR)/openssl-genpkey.Tpo -c -o openssl-genpkey.obj `if test -f 'genpkey.c'; then $(CYGPATH_W) 'genpkey.c'; else $(CYGPATH_W) '$(srcdir)/genpkey.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-genpkey.Tpo $(DEPDIR)/openssl-genpkey.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='genpkey.c' object='openssl-genpkey.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-genpkey.obj `if test -f 'genpkey.c'; then $(CYGPATH_W) 'genpkey.c'; else $(CYGPATH_W) '$(srcdir)/genpkey.c'; fi` openssl-genrsa.o: genrsa.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-genrsa.o -MD -MP -MF $(DEPDIR)/openssl-genrsa.Tpo -c -o openssl-genrsa.o `test -f 'genrsa.c' || echo '$(srcdir)/'`genrsa.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-genrsa.Tpo $(DEPDIR)/openssl-genrsa.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='genrsa.c' object='openssl-genrsa.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-genrsa.o `test -f 'genrsa.c' || echo '$(srcdir)/'`genrsa.c openssl-genrsa.obj: genrsa.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-genrsa.obj -MD -MP -MF $(DEPDIR)/openssl-genrsa.Tpo -c -o openssl-genrsa.obj `if test -f 'genrsa.c'; then $(CYGPATH_W) 'genrsa.c'; else $(CYGPATH_W) '$(srcdir)/genrsa.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-genrsa.Tpo $(DEPDIR)/openssl-genrsa.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='genrsa.c' object='openssl-genrsa.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-genrsa.obj `if test -f 'genrsa.c'; then $(CYGPATH_W) 'genrsa.c'; else $(CYGPATH_W) '$(srcdir)/genrsa.c'; fi` openssl-nseq.o: nseq.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-nseq.o -MD -MP -MF $(DEPDIR)/openssl-nseq.Tpo -c -o openssl-nseq.o `test -f 'nseq.c' || echo '$(srcdir)/'`nseq.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-nseq.Tpo $(DEPDIR)/openssl-nseq.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='nseq.c' object='openssl-nseq.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-nseq.o `test -f 'nseq.c' || echo '$(srcdir)/'`nseq.c openssl-nseq.obj: nseq.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-nseq.obj -MD -MP -MF $(DEPDIR)/openssl-nseq.Tpo -c -o openssl-nseq.obj `if test -f 'nseq.c'; then $(CYGPATH_W) 'nseq.c'; else $(CYGPATH_W) '$(srcdir)/nseq.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-nseq.Tpo $(DEPDIR)/openssl-nseq.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='nseq.c' object='openssl-nseq.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-nseq.obj `if test -f 'nseq.c'; then $(CYGPATH_W) 'nseq.c'; else $(CYGPATH_W) '$(srcdir)/nseq.c'; fi` openssl-ocsp.o: ocsp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-ocsp.o -MD -MP -MF $(DEPDIR)/openssl-ocsp.Tpo -c -o openssl-ocsp.o `test -f 'ocsp.c' || echo '$(srcdir)/'`ocsp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-ocsp.Tpo $(DEPDIR)/openssl-ocsp.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ocsp.c' object='openssl-ocsp.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-ocsp.o `test -f 'ocsp.c' || echo '$(srcdir)/'`ocsp.c openssl-ocsp.obj: ocsp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-ocsp.obj -MD -MP -MF $(DEPDIR)/openssl-ocsp.Tpo -c -o openssl-ocsp.obj `if test -f 'ocsp.c'; then $(CYGPATH_W) 'ocsp.c'; else $(CYGPATH_W) '$(srcdir)/ocsp.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-ocsp.Tpo $(DEPDIR)/openssl-ocsp.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ocsp.c' object='openssl-ocsp.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-ocsp.obj `if test -f 'ocsp.c'; then $(CYGPATH_W) 'ocsp.c'; else $(CYGPATH_W) '$(srcdir)/ocsp.c'; fi` openssl-openssl.o: openssl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-openssl.o -MD -MP -MF $(DEPDIR)/openssl-openssl.Tpo -c -o openssl-openssl.o `test -f 'openssl.c' || echo '$(srcdir)/'`openssl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-openssl.Tpo $(DEPDIR)/openssl-openssl.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='openssl.c' object='openssl-openssl.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-openssl.o `test -f 'openssl.c' || echo '$(srcdir)/'`openssl.c openssl-openssl.obj: openssl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-openssl.obj -MD -MP -MF $(DEPDIR)/openssl-openssl.Tpo -c -o openssl-openssl.obj `if test -f 'openssl.c'; then $(CYGPATH_W) 'openssl.c'; else $(CYGPATH_W) '$(srcdir)/openssl.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-openssl.Tpo $(DEPDIR)/openssl-openssl.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='openssl.c' object='openssl-openssl.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-openssl.obj `if test -f 'openssl.c'; then $(CYGPATH_W) 'openssl.c'; else $(CYGPATH_W) '$(srcdir)/openssl.c'; fi` openssl-passwd.o: passwd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-passwd.o -MD -MP -MF $(DEPDIR)/openssl-passwd.Tpo -c -o openssl-passwd.o `test -f 'passwd.c' || echo '$(srcdir)/'`passwd.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-passwd.Tpo $(DEPDIR)/openssl-passwd.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='passwd.c' object='openssl-passwd.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-passwd.o `test -f 'passwd.c' || echo '$(srcdir)/'`passwd.c openssl-passwd.obj: passwd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-passwd.obj -MD -MP -MF $(DEPDIR)/openssl-passwd.Tpo -c -o openssl-passwd.obj `if test -f 'passwd.c'; then $(CYGPATH_W) 'passwd.c'; else $(CYGPATH_W) '$(srcdir)/passwd.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-passwd.Tpo $(DEPDIR)/openssl-passwd.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='passwd.c' object='openssl-passwd.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-passwd.obj `if test -f 'passwd.c'; then $(CYGPATH_W) 'passwd.c'; else $(CYGPATH_W) '$(srcdir)/passwd.c'; fi` openssl-pkcs12.o: pkcs12.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-pkcs12.o -MD -MP -MF $(DEPDIR)/openssl-pkcs12.Tpo -c -o openssl-pkcs12.o `test -f 'pkcs12.c' || echo '$(srcdir)/'`pkcs12.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-pkcs12.Tpo $(DEPDIR)/openssl-pkcs12.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12.c' object='openssl-pkcs12.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-pkcs12.o `test -f 'pkcs12.c' || echo '$(srcdir)/'`pkcs12.c openssl-pkcs12.obj: pkcs12.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-pkcs12.obj -MD -MP -MF $(DEPDIR)/openssl-pkcs12.Tpo -c -o openssl-pkcs12.obj `if test -f 'pkcs12.c'; then $(CYGPATH_W) 'pkcs12.c'; else $(CYGPATH_W) '$(srcdir)/pkcs12.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-pkcs12.Tpo $(DEPDIR)/openssl-pkcs12.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs12.c' object='openssl-pkcs12.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-pkcs12.obj `if test -f 'pkcs12.c'; then $(CYGPATH_W) 'pkcs12.c'; else $(CYGPATH_W) '$(srcdir)/pkcs12.c'; fi` openssl-pkcs7.o: pkcs7.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-pkcs7.o -MD -MP -MF $(DEPDIR)/openssl-pkcs7.Tpo -c -o openssl-pkcs7.o `test -f 'pkcs7.c' || echo '$(srcdir)/'`pkcs7.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-pkcs7.Tpo $(DEPDIR)/openssl-pkcs7.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs7.c' object='openssl-pkcs7.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-pkcs7.o `test -f 'pkcs7.c' || echo '$(srcdir)/'`pkcs7.c openssl-pkcs7.obj: pkcs7.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-pkcs7.obj -MD -MP -MF $(DEPDIR)/openssl-pkcs7.Tpo -c -o openssl-pkcs7.obj `if test -f 'pkcs7.c'; then $(CYGPATH_W) 'pkcs7.c'; else $(CYGPATH_W) '$(srcdir)/pkcs7.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-pkcs7.Tpo $(DEPDIR)/openssl-pkcs7.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs7.c' object='openssl-pkcs7.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-pkcs7.obj `if test -f 'pkcs7.c'; then $(CYGPATH_W) 'pkcs7.c'; else $(CYGPATH_W) '$(srcdir)/pkcs7.c'; fi` openssl-pkcs8.o: pkcs8.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-pkcs8.o -MD -MP -MF $(DEPDIR)/openssl-pkcs8.Tpo -c -o openssl-pkcs8.o `test -f 'pkcs8.c' || echo '$(srcdir)/'`pkcs8.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-pkcs8.Tpo $(DEPDIR)/openssl-pkcs8.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs8.c' object='openssl-pkcs8.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-pkcs8.o `test -f 'pkcs8.c' || echo '$(srcdir)/'`pkcs8.c openssl-pkcs8.obj: pkcs8.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-pkcs8.obj -MD -MP -MF $(DEPDIR)/openssl-pkcs8.Tpo -c -o openssl-pkcs8.obj `if test -f 'pkcs8.c'; then $(CYGPATH_W) 'pkcs8.c'; else $(CYGPATH_W) '$(srcdir)/pkcs8.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-pkcs8.Tpo $(DEPDIR)/openssl-pkcs8.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkcs8.c' object='openssl-pkcs8.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-pkcs8.obj `if test -f 'pkcs8.c'; then $(CYGPATH_W) 'pkcs8.c'; else $(CYGPATH_W) '$(srcdir)/pkcs8.c'; fi` openssl-pkey.o: pkey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-pkey.o -MD -MP -MF $(DEPDIR)/openssl-pkey.Tpo -c -o openssl-pkey.o `test -f 'pkey.c' || echo '$(srcdir)/'`pkey.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-pkey.Tpo $(DEPDIR)/openssl-pkey.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkey.c' object='openssl-pkey.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-pkey.o `test -f 'pkey.c' || echo '$(srcdir)/'`pkey.c openssl-pkey.obj: pkey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-pkey.obj -MD -MP -MF $(DEPDIR)/openssl-pkey.Tpo -c -o openssl-pkey.obj `if test -f 'pkey.c'; then $(CYGPATH_W) 'pkey.c'; else $(CYGPATH_W) '$(srcdir)/pkey.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-pkey.Tpo $(DEPDIR)/openssl-pkey.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkey.c' object='openssl-pkey.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-pkey.obj `if test -f 'pkey.c'; then $(CYGPATH_W) 'pkey.c'; else $(CYGPATH_W) '$(srcdir)/pkey.c'; fi` openssl-pkeyparam.o: pkeyparam.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-pkeyparam.o -MD -MP -MF $(DEPDIR)/openssl-pkeyparam.Tpo -c -o openssl-pkeyparam.o `test -f 'pkeyparam.c' || echo '$(srcdir)/'`pkeyparam.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-pkeyparam.Tpo $(DEPDIR)/openssl-pkeyparam.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkeyparam.c' object='openssl-pkeyparam.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-pkeyparam.o `test -f 'pkeyparam.c' || echo '$(srcdir)/'`pkeyparam.c openssl-pkeyparam.obj: pkeyparam.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-pkeyparam.obj -MD -MP -MF $(DEPDIR)/openssl-pkeyparam.Tpo -c -o openssl-pkeyparam.obj `if test -f 'pkeyparam.c'; then $(CYGPATH_W) 'pkeyparam.c'; else $(CYGPATH_W) '$(srcdir)/pkeyparam.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-pkeyparam.Tpo $(DEPDIR)/openssl-pkeyparam.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkeyparam.c' object='openssl-pkeyparam.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-pkeyparam.obj `if test -f 'pkeyparam.c'; then $(CYGPATH_W) 'pkeyparam.c'; else $(CYGPATH_W) '$(srcdir)/pkeyparam.c'; fi` openssl-pkeyutl.o: pkeyutl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-pkeyutl.o -MD -MP -MF $(DEPDIR)/openssl-pkeyutl.Tpo -c -o openssl-pkeyutl.o `test -f 'pkeyutl.c' || echo '$(srcdir)/'`pkeyutl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-pkeyutl.Tpo $(DEPDIR)/openssl-pkeyutl.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkeyutl.c' object='openssl-pkeyutl.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-pkeyutl.o `test -f 'pkeyutl.c' || echo '$(srcdir)/'`pkeyutl.c openssl-pkeyutl.obj: pkeyutl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-pkeyutl.obj -MD -MP -MF $(DEPDIR)/openssl-pkeyutl.Tpo -c -o openssl-pkeyutl.obj `if test -f 'pkeyutl.c'; then $(CYGPATH_W) 'pkeyutl.c'; else $(CYGPATH_W) '$(srcdir)/pkeyutl.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-pkeyutl.Tpo $(DEPDIR)/openssl-pkeyutl.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pkeyutl.c' object='openssl-pkeyutl.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-pkeyutl.obj `if test -f 'pkeyutl.c'; then $(CYGPATH_W) 'pkeyutl.c'; else $(CYGPATH_W) '$(srcdir)/pkeyutl.c'; fi` openssl-prime.o: prime.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-prime.o -MD -MP -MF $(DEPDIR)/openssl-prime.Tpo -c -o openssl-prime.o `test -f 'prime.c' || echo '$(srcdir)/'`prime.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-prime.Tpo $(DEPDIR)/openssl-prime.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='prime.c' object='openssl-prime.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-prime.o `test -f 'prime.c' || echo '$(srcdir)/'`prime.c openssl-prime.obj: prime.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-prime.obj -MD -MP -MF $(DEPDIR)/openssl-prime.Tpo -c -o openssl-prime.obj `if test -f 'prime.c'; then $(CYGPATH_W) 'prime.c'; else $(CYGPATH_W) '$(srcdir)/prime.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-prime.Tpo $(DEPDIR)/openssl-prime.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='prime.c' object='openssl-prime.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-prime.obj `if test -f 'prime.c'; then $(CYGPATH_W) 'prime.c'; else $(CYGPATH_W) '$(srcdir)/prime.c'; fi` openssl-rand.o: rand.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-rand.o -MD -MP -MF $(DEPDIR)/openssl-rand.Tpo -c -o openssl-rand.o `test -f 'rand.c' || echo '$(srcdir)/'`rand.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-rand.Tpo $(DEPDIR)/openssl-rand.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rand.c' object='openssl-rand.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-rand.o `test -f 'rand.c' || echo '$(srcdir)/'`rand.c openssl-rand.obj: rand.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-rand.obj -MD -MP -MF $(DEPDIR)/openssl-rand.Tpo -c -o openssl-rand.obj `if test -f 'rand.c'; then $(CYGPATH_W) 'rand.c'; else $(CYGPATH_W) '$(srcdir)/rand.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-rand.Tpo $(DEPDIR)/openssl-rand.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rand.c' object='openssl-rand.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-rand.obj `if test -f 'rand.c'; then $(CYGPATH_W) 'rand.c'; else $(CYGPATH_W) '$(srcdir)/rand.c'; fi` openssl-req.o: req.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-req.o -MD -MP -MF $(DEPDIR)/openssl-req.Tpo -c -o openssl-req.o `test -f 'req.c' || echo '$(srcdir)/'`req.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-req.Tpo $(DEPDIR)/openssl-req.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='req.c' object='openssl-req.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-req.o `test -f 'req.c' || echo '$(srcdir)/'`req.c openssl-req.obj: req.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-req.obj -MD -MP -MF $(DEPDIR)/openssl-req.Tpo -c -o openssl-req.obj `if test -f 'req.c'; then $(CYGPATH_W) 'req.c'; else $(CYGPATH_W) '$(srcdir)/req.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-req.Tpo $(DEPDIR)/openssl-req.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='req.c' object='openssl-req.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-req.obj `if test -f 'req.c'; then $(CYGPATH_W) 'req.c'; else $(CYGPATH_W) '$(srcdir)/req.c'; fi` openssl-rsa.o: rsa.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-rsa.o -MD -MP -MF $(DEPDIR)/openssl-rsa.Tpo -c -o openssl-rsa.o `test -f 'rsa.c' || echo '$(srcdir)/'`rsa.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-rsa.Tpo $(DEPDIR)/openssl-rsa.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa.c' object='openssl-rsa.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-rsa.o `test -f 'rsa.c' || echo '$(srcdir)/'`rsa.c openssl-rsa.obj: rsa.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-rsa.obj -MD -MP -MF $(DEPDIR)/openssl-rsa.Tpo -c -o openssl-rsa.obj `if test -f 'rsa.c'; then $(CYGPATH_W) 'rsa.c'; else $(CYGPATH_W) '$(srcdir)/rsa.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-rsa.Tpo $(DEPDIR)/openssl-rsa.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsa.c' object='openssl-rsa.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-rsa.obj `if test -f 'rsa.c'; then $(CYGPATH_W) 'rsa.c'; else $(CYGPATH_W) '$(srcdir)/rsa.c'; fi` openssl-rsautl.o: rsautl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-rsautl.o -MD -MP -MF $(DEPDIR)/openssl-rsautl.Tpo -c -o openssl-rsautl.o `test -f 'rsautl.c' || echo '$(srcdir)/'`rsautl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-rsautl.Tpo $(DEPDIR)/openssl-rsautl.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsautl.c' object='openssl-rsautl.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-rsautl.o `test -f 'rsautl.c' || echo '$(srcdir)/'`rsautl.c openssl-rsautl.obj: rsautl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-rsautl.obj -MD -MP -MF $(DEPDIR)/openssl-rsautl.Tpo -c -o openssl-rsautl.obj `if test -f 'rsautl.c'; then $(CYGPATH_W) 'rsautl.c'; else $(CYGPATH_W) '$(srcdir)/rsautl.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-rsautl.Tpo $(DEPDIR)/openssl-rsautl.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rsautl.c' object='openssl-rsautl.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-rsautl.obj `if test -f 'rsautl.c'; then $(CYGPATH_W) 'rsautl.c'; else $(CYGPATH_W) '$(srcdir)/rsautl.c'; fi` openssl-s_cb.o: s_cb.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-s_cb.o -MD -MP -MF $(DEPDIR)/openssl-s_cb.Tpo -c -o openssl-s_cb.o `test -f 's_cb.c' || echo '$(srcdir)/'`s_cb.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-s_cb.Tpo $(DEPDIR)/openssl-s_cb.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s_cb.c' object='openssl-s_cb.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-s_cb.o `test -f 's_cb.c' || echo '$(srcdir)/'`s_cb.c openssl-s_cb.obj: s_cb.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-s_cb.obj -MD -MP -MF $(DEPDIR)/openssl-s_cb.Tpo -c -o openssl-s_cb.obj `if test -f 's_cb.c'; then $(CYGPATH_W) 's_cb.c'; else $(CYGPATH_W) '$(srcdir)/s_cb.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-s_cb.Tpo $(DEPDIR)/openssl-s_cb.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s_cb.c' object='openssl-s_cb.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-s_cb.obj `if test -f 's_cb.c'; then $(CYGPATH_W) 's_cb.c'; else $(CYGPATH_W) '$(srcdir)/s_cb.c'; fi` openssl-s_client.o: s_client.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-s_client.o -MD -MP -MF $(DEPDIR)/openssl-s_client.Tpo -c -o openssl-s_client.o `test -f 's_client.c' || echo '$(srcdir)/'`s_client.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-s_client.Tpo $(DEPDIR)/openssl-s_client.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s_client.c' object='openssl-s_client.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-s_client.o `test -f 's_client.c' || echo '$(srcdir)/'`s_client.c openssl-s_client.obj: s_client.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-s_client.obj -MD -MP -MF $(DEPDIR)/openssl-s_client.Tpo -c -o openssl-s_client.obj `if test -f 's_client.c'; then $(CYGPATH_W) 's_client.c'; else $(CYGPATH_W) '$(srcdir)/s_client.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-s_client.Tpo $(DEPDIR)/openssl-s_client.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s_client.c' object='openssl-s_client.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-s_client.obj `if test -f 's_client.c'; then $(CYGPATH_W) 's_client.c'; else $(CYGPATH_W) '$(srcdir)/s_client.c'; fi` openssl-s_server.o: s_server.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-s_server.o -MD -MP -MF $(DEPDIR)/openssl-s_server.Tpo -c -o openssl-s_server.o `test -f 's_server.c' || echo '$(srcdir)/'`s_server.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-s_server.Tpo $(DEPDIR)/openssl-s_server.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s_server.c' object='openssl-s_server.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-s_server.o `test -f 's_server.c' || echo '$(srcdir)/'`s_server.c openssl-s_server.obj: s_server.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-s_server.obj -MD -MP -MF $(DEPDIR)/openssl-s_server.Tpo -c -o openssl-s_server.obj `if test -f 's_server.c'; then $(CYGPATH_W) 's_server.c'; else $(CYGPATH_W) '$(srcdir)/s_server.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-s_server.Tpo $(DEPDIR)/openssl-s_server.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s_server.c' object='openssl-s_server.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-s_server.obj `if test -f 's_server.c'; then $(CYGPATH_W) 's_server.c'; else $(CYGPATH_W) '$(srcdir)/s_server.c'; fi` openssl-s_socket.o: s_socket.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-s_socket.o -MD -MP -MF $(DEPDIR)/openssl-s_socket.Tpo -c -o openssl-s_socket.o `test -f 's_socket.c' || echo '$(srcdir)/'`s_socket.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-s_socket.Tpo $(DEPDIR)/openssl-s_socket.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s_socket.c' object='openssl-s_socket.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-s_socket.o `test -f 's_socket.c' || echo '$(srcdir)/'`s_socket.c openssl-s_socket.obj: s_socket.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-s_socket.obj -MD -MP -MF $(DEPDIR)/openssl-s_socket.Tpo -c -o openssl-s_socket.obj `if test -f 's_socket.c'; then $(CYGPATH_W) 's_socket.c'; else $(CYGPATH_W) '$(srcdir)/s_socket.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-s_socket.Tpo $(DEPDIR)/openssl-s_socket.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s_socket.c' object='openssl-s_socket.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-s_socket.obj `if test -f 's_socket.c'; then $(CYGPATH_W) 's_socket.c'; else $(CYGPATH_W) '$(srcdir)/s_socket.c'; fi` openssl-s_time.o: s_time.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-s_time.o -MD -MP -MF $(DEPDIR)/openssl-s_time.Tpo -c -o openssl-s_time.o `test -f 's_time.c' || echo '$(srcdir)/'`s_time.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-s_time.Tpo $(DEPDIR)/openssl-s_time.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s_time.c' object='openssl-s_time.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-s_time.o `test -f 's_time.c' || echo '$(srcdir)/'`s_time.c openssl-s_time.obj: s_time.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-s_time.obj -MD -MP -MF $(DEPDIR)/openssl-s_time.Tpo -c -o openssl-s_time.obj `if test -f 's_time.c'; then $(CYGPATH_W) 's_time.c'; else $(CYGPATH_W) '$(srcdir)/s_time.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-s_time.Tpo $(DEPDIR)/openssl-s_time.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s_time.c' object='openssl-s_time.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-s_time.obj `if test -f 's_time.c'; then $(CYGPATH_W) 's_time.c'; else $(CYGPATH_W) '$(srcdir)/s_time.c'; fi` openssl-sess_id.o: sess_id.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-sess_id.o -MD -MP -MF $(DEPDIR)/openssl-sess_id.Tpo -c -o openssl-sess_id.o `test -f 'sess_id.c' || echo '$(srcdir)/'`sess_id.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-sess_id.Tpo $(DEPDIR)/openssl-sess_id.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sess_id.c' object='openssl-sess_id.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-sess_id.o `test -f 'sess_id.c' || echo '$(srcdir)/'`sess_id.c openssl-sess_id.obj: sess_id.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-sess_id.obj -MD -MP -MF $(DEPDIR)/openssl-sess_id.Tpo -c -o openssl-sess_id.obj `if test -f 'sess_id.c'; then $(CYGPATH_W) 'sess_id.c'; else $(CYGPATH_W) '$(srcdir)/sess_id.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-sess_id.Tpo $(DEPDIR)/openssl-sess_id.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sess_id.c' object='openssl-sess_id.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-sess_id.obj `if test -f 'sess_id.c'; then $(CYGPATH_W) 'sess_id.c'; else $(CYGPATH_W) '$(srcdir)/sess_id.c'; fi` openssl-smime.o: smime.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-smime.o -MD -MP -MF $(DEPDIR)/openssl-smime.Tpo -c -o openssl-smime.o `test -f 'smime.c' || echo '$(srcdir)/'`smime.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-smime.Tpo $(DEPDIR)/openssl-smime.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='smime.c' object='openssl-smime.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-smime.o `test -f 'smime.c' || echo '$(srcdir)/'`smime.c openssl-smime.obj: smime.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-smime.obj -MD -MP -MF $(DEPDIR)/openssl-smime.Tpo -c -o openssl-smime.obj `if test -f 'smime.c'; then $(CYGPATH_W) 'smime.c'; else $(CYGPATH_W) '$(srcdir)/smime.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-smime.Tpo $(DEPDIR)/openssl-smime.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='smime.c' object='openssl-smime.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-smime.obj `if test -f 'smime.c'; then $(CYGPATH_W) 'smime.c'; else $(CYGPATH_W) '$(srcdir)/smime.c'; fi` openssl-speed.o: speed.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-speed.o -MD -MP -MF $(DEPDIR)/openssl-speed.Tpo -c -o openssl-speed.o `test -f 'speed.c' || echo '$(srcdir)/'`speed.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-speed.Tpo $(DEPDIR)/openssl-speed.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='speed.c' object='openssl-speed.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-speed.o `test -f 'speed.c' || echo '$(srcdir)/'`speed.c openssl-speed.obj: speed.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-speed.obj -MD -MP -MF $(DEPDIR)/openssl-speed.Tpo -c -o openssl-speed.obj `if test -f 'speed.c'; then $(CYGPATH_W) 'speed.c'; else $(CYGPATH_W) '$(srcdir)/speed.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-speed.Tpo $(DEPDIR)/openssl-speed.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='speed.c' object='openssl-speed.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-speed.obj `if test -f 'speed.c'; then $(CYGPATH_W) 'speed.c'; else $(CYGPATH_W) '$(srcdir)/speed.c'; fi` openssl-spkac.o: spkac.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-spkac.o -MD -MP -MF $(DEPDIR)/openssl-spkac.Tpo -c -o openssl-spkac.o `test -f 'spkac.c' || echo '$(srcdir)/'`spkac.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-spkac.Tpo $(DEPDIR)/openssl-spkac.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='spkac.c' object='openssl-spkac.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-spkac.o `test -f 'spkac.c' || echo '$(srcdir)/'`spkac.c openssl-spkac.obj: spkac.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-spkac.obj -MD -MP -MF $(DEPDIR)/openssl-spkac.Tpo -c -o openssl-spkac.obj `if test -f 'spkac.c'; then $(CYGPATH_W) 'spkac.c'; else $(CYGPATH_W) '$(srcdir)/spkac.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-spkac.Tpo $(DEPDIR)/openssl-spkac.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='spkac.c' object='openssl-spkac.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-spkac.obj `if test -f 'spkac.c'; then $(CYGPATH_W) 'spkac.c'; else $(CYGPATH_W) '$(srcdir)/spkac.c'; fi` openssl-ts.o: ts.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-ts.o -MD -MP -MF $(DEPDIR)/openssl-ts.Tpo -c -o openssl-ts.o `test -f 'ts.c' || echo '$(srcdir)/'`ts.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-ts.Tpo $(DEPDIR)/openssl-ts.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ts.c' object='openssl-ts.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-ts.o `test -f 'ts.c' || echo '$(srcdir)/'`ts.c openssl-ts.obj: ts.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-ts.obj -MD -MP -MF $(DEPDIR)/openssl-ts.Tpo -c -o openssl-ts.obj `if test -f 'ts.c'; then $(CYGPATH_W) 'ts.c'; else $(CYGPATH_W) '$(srcdir)/ts.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-ts.Tpo $(DEPDIR)/openssl-ts.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ts.c' object='openssl-ts.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-ts.obj `if test -f 'ts.c'; then $(CYGPATH_W) 'ts.c'; else $(CYGPATH_W) '$(srcdir)/ts.c'; fi` openssl-verify.o: verify.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-verify.o -MD -MP -MF $(DEPDIR)/openssl-verify.Tpo -c -o openssl-verify.o `test -f 'verify.c' || echo '$(srcdir)/'`verify.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-verify.Tpo $(DEPDIR)/openssl-verify.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='verify.c' object='openssl-verify.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-verify.o `test -f 'verify.c' || echo '$(srcdir)/'`verify.c openssl-verify.obj: verify.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-verify.obj -MD -MP -MF $(DEPDIR)/openssl-verify.Tpo -c -o openssl-verify.obj `if test -f 'verify.c'; then $(CYGPATH_W) 'verify.c'; else $(CYGPATH_W) '$(srcdir)/verify.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-verify.Tpo $(DEPDIR)/openssl-verify.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='verify.c' object='openssl-verify.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-verify.obj `if test -f 'verify.c'; then $(CYGPATH_W) 'verify.c'; else $(CYGPATH_W) '$(srcdir)/verify.c'; fi` openssl-version.o: version.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-version.o -MD -MP -MF $(DEPDIR)/openssl-version.Tpo -c -o openssl-version.o `test -f 'version.c' || echo '$(srcdir)/'`version.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-version.Tpo $(DEPDIR)/openssl-version.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='version.c' object='openssl-version.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-version.o `test -f 'version.c' || echo '$(srcdir)/'`version.c openssl-version.obj: version.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-version.obj -MD -MP -MF $(DEPDIR)/openssl-version.Tpo -c -o openssl-version.obj `if test -f 'version.c'; then $(CYGPATH_W) 'version.c'; else $(CYGPATH_W) '$(srcdir)/version.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-version.Tpo $(DEPDIR)/openssl-version.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='version.c' object='openssl-version.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-version.obj `if test -f 'version.c'; then $(CYGPATH_W) 'version.c'; else $(CYGPATH_W) '$(srcdir)/version.c'; fi` openssl-x509.o: x509.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-x509.o -MD -MP -MF $(DEPDIR)/openssl-x509.Tpo -c -o openssl-x509.o `test -f 'x509.c' || echo '$(srcdir)/'`x509.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-x509.Tpo $(DEPDIR)/openssl-x509.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509.c' object='openssl-x509.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-x509.o `test -f 'x509.c' || echo '$(srcdir)/'`x509.c openssl-x509.obj: x509.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -MT openssl-x509.obj -MD -MP -MF $(DEPDIR)/openssl-x509.Tpo -c -o openssl-x509.obj `if test -f 'x509.c'; then $(CYGPATH_W) 'x509.c'; else $(CYGPATH_W) '$(srcdir)/x509.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/openssl-x509.Tpo $(DEPDIR)/openssl-x509.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='x509.c' object='openssl-x509.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(openssl_CFLAGS) $(CFLAGS) -c -o openssl-x509.obj `if test -f 'x509.c'; then $(CYGPATH_W) 'x509.c'; else $(CYGPATH_W) '$(srcdir)/x509.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ clean-binPROGRAMS clean-generic clean-libtool cscopelist-am \ ctags ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-binPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: deps/libressl-pnacl-sys-2.1.6/libressl/apps/dgst.c0000644000175000017500000003576412360020706017023 0ustar /* $OpenBSD$ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include #include #include #include "apps.h" #include #include #include #include #include #include #include #define BUFSIZE 1024*8 int do_fp(BIO * out, unsigned char *buf, BIO * bp, int sep, int binout, EVP_PKEY * key, unsigned char *sigin, int siglen, const char *sig_name, const char *md_name, const char *file, BIO * bmd); static void list_md_fn(const EVP_MD * m, const char *from, const char *to, void *arg) { const char *mname; /* Skip aliases */ if (!m) return; mname = OBJ_nid2ln(EVP_MD_type(m)); /* Skip shortnames */ if (strcmp(from, mname)) return; /* Skip clones */ if (EVP_MD_flags(m) & EVP_MD_FLAG_PKEY_DIGEST) return; if (strchr(mname, ' ')) mname = EVP_MD_name(m); BIO_printf(arg, "-%-14s to use the %s message digest algorithm\n", mname, mname); } int dgst_main(int, char **); int dgst_main(int argc, char **argv) { ENGINE *e = NULL; unsigned char *buf = NULL; int i, err = 1; const EVP_MD *md = NULL, *m; BIO *in = NULL, *inp; BIO *bmd = NULL; BIO *out = NULL; #define PROG_NAME_SIZE 39 char pname[PROG_NAME_SIZE + 1]; int separator = 0; int debug = 0; int keyform = FORMAT_PEM; const char *outfile = NULL, *keyfile = NULL; const char *sigfile = NULL; int out_bin = -1, want_pub = 0, do_verify = 0; EVP_PKEY *sigkey = NULL; unsigned char *sigbuf = NULL; int siglen = 0; char *passargin = NULL, *passin = NULL; #ifndef OPENSSL_NO_ENGINE char *engine = NULL; #endif char *hmac_key = NULL; char *mac_name = NULL; STACK_OF(OPENSSL_STRING) * sigopts = NULL, *macopts = NULL; if ((buf = malloc(BUFSIZE)) == NULL) { BIO_printf(bio_err, "out of memory\n"); goto end; } if (!load_config(bio_err, NULL)) goto end; /* first check the program name */ program_name(argv[0], pname, sizeof pname); md = EVP_get_digestbyname(pname); argc--; argv++; while (argc > 0) { if ((*argv)[0] != '-') break; if (strcmp(*argv, "-c") == 0) separator = 1; else if (strcmp(*argv, "-r") == 0) separator = 2; else if (strcmp(*argv, "-out") == 0) { if (--argc < 1) break; outfile = *(++argv); } else if (strcmp(*argv, "-sign") == 0) { if (--argc < 1) break; keyfile = *(++argv); } else if (!strcmp(*argv, "-passin")) { if (--argc < 1) break; passargin = *++argv; } else if (strcmp(*argv, "-verify") == 0) { if (--argc < 1) break; keyfile = *(++argv); want_pub = 1; do_verify = 1; } else if (strcmp(*argv, "-prverify") == 0) { if (--argc < 1) break; keyfile = *(++argv); do_verify = 1; } else if (strcmp(*argv, "-signature") == 0) { if (--argc < 1) break; sigfile = *(++argv); } else if (strcmp(*argv, "-keyform") == 0) { if (--argc < 1) break; keyform = str2fmt(*(++argv)); } #ifndef OPENSSL_NO_ENGINE else if (strcmp(*argv, "-engine") == 0) { if (--argc < 1) break; engine = *(++argv); e = setup_engine(bio_err, engine, 0); } #endif else if (strcmp(*argv, "-hex") == 0) out_bin = 0; else if (strcmp(*argv, "-binary") == 0) out_bin = 1; else if (strcmp(*argv, "-d") == 0) debug = 1; else if (!strcmp(*argv, "-hmac")) { if (--argc < 1) break; hmac_key = *++argv; } else if (!strcmp(*argv, "-mac")) { if (--argc < 1) break; mac_name = *++argv; } else if (strcmp(*argv, "-sigopt") == 0) { if (--argc < 1) break; if (!sigopts) sigopts = sk_OPENSSL_STRING_new_null(); if (!sigopts || !sk_OPENSSL_STRING_push(sigopts, *(++argv))) break; } else if (strcmp(*argv, "-macopt") == 0) { if (--argc < 1) break; if (!macopts) macopts = sk_OPENSSL_STRING_new_null(); if (!macopts || !sk_OPENSSL_STRING_push(macopts, *(++argv))) break; } else if ((m = EVP_get_digestbyname(&((*argv)[1]))) != NULL) md = m; else break; argc--; argv++; } if (do_verify && !sigfile) { BIO_printf(bio_err, "No signature to verify: use the -signature option\n"); goto end; } if ((argc > 0) && (argv[0][0] == '-')) { /* bad option */ BIO_printf(bio_err, "unknown option '%s'\n", *argv); BIO_printf(bio_err, "options are\n"); BIO_printf(bio_err, "-c to output the digest with separating colons\n"); BIO_printf(bio_err, "-r to output the digest in coreutils format\n"); BIO_printf(bio_err, "-d to output debug info\n"); BIO_printf(bio_err, "-hex output as hex dump\n"); BIO_printf(bio_err, "-binary output in binary form\n"); BIO_printf(bio_err, "-sign file sign digest using private key in file\n"); BIO_printf(bio_err, "-verify file verify a signature using public key in file\n"); BIO_printf(bio_err, "-prverify file verify a signature using private key in file\n"); BIO_printf(bio_err, "-keyform arg key file format (PEM or ENGINE)\n"); BIO_printf(bio_err, "-out filename output to filename rather than stdout\n"); BIO_printf(bio_err, "-signature file signature to verify\n"); BIO_printf(bio_err, "-sigopt nm:v signature parameter\n"); BIO_printf(bio_err, "-hmac key create hashed MAC with key\n"); BIO_printf(bio_err, "-mac algorithm create MAC (not neccessarily HMAC)\n"); BIO_printf(bio_err, "-macopt nm:v MAC algorithm parameters or key\n"); #ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err, "-engine e use engine e, possibly a hardware device.\n"); #endif EVP_MD_do_all_sorted(list_md_fn, bio_err); goto end; } in = BIO_new(BIO_s_file()); bmd = BIO_new(BIO_f_md()); if (debug) { BIO_set_callback(in, BIO_debug_callback); /* needed for windows 3.1 */ BIO_set_callback_arg(in, (char *) bio_err); } if (!app_passwd(bio_err, passargin, NULL, &passin, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } if ((in == NULL) || (bmd == NULL)) { ERR_print_errors(bio_err); goto end; } if (out_bin == -1) { if (keyfile) out_bin = 1; else out_bin = 0; } if (outfile) { if (out_bin) out = BIO_new_file(outfile, "wb"); else out = BIO_new_file(outfile, "w"); } else { out = BIO_new_fp(stdout, BIO_NOCLOSE); } if (!out) { BIO_printf(bio_err, "Error opening output file %s\n", outfile ? outfile : "(stdout)"); ERR_print_errors(bio_err); goto end; } if ((!!mac_name + !!keyfile + !!hmac_key) > 1) { BIO_printf(bio_err, "MAC and Signing key cannot both be specified\n"); goto end; } if (keyfile) { if (want_pub) sigkey = load_pubkey(bio_err, keyfile, keyform, 0, NULL, e, "key file"); else sigkey = load_key(bio_err, keyfile, keyform, 0, passin, e, "key file"); if (!sigkey) { /* * load_[pub]key() has already printed an appropriate * message */ goto end; } } if (mac_name) { EVP_PKEY_CTX *mac_ctx = NULL; int r = 0; if (!init_gen_str(bio_err, &mac_ctx, mac_name, e, 0)) goto mac_end; if (macopts) { char *macopt; for (i = 0; i < sk_OPENSSL_STRING_num(macopts); i++) { macopt = sk_OPENSSL_STRING_value(macopts, i); if (pkey_ctrl_string(mac_ctx, macopt) <= 0) { BIO_printf(bio_err, "MAC parameter error \"%s\"\n", macopt); ERR_print_errors(bio_err); goto mac_end; } } } if (EVP_PKEY_keygen(mac_ctx, &sigkey) <= 0) { BIO_puts(bio_err, "Error generating key\n"); ERR_print_errors(bio_err); goto mac_end; } r = 1; mac_end: if (mac_ctx) EVP_PKEY_CTX_free(mac_ctx); if (r == 0) goto end; } if (hmac_key) { sigkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, e, (unsigned char *) hmac_key, -1); if (!sigkey) goto end; } if (sigkey) { EVP_MD_CTX *mctx = NULL; EVP_PKEY_CTX *pctx = NULL; int r; if (!BIO_get_md_ctx(bmd, &mctx)) { BIO_printf(bio_err, "Error getting context\n"); ERR_print_errors(bio_err); goto end; } if (do_verify) r = EVP_DigestVerifyInit(mctx, &pctx, md, NULL, sigkey); else r = EVP_DigestSignInit(mctx, &pctx, md, NULL, sigkey); if (!r) { BIO_printf(bio_err, "Error setting context\n"); ERR_print_errors(bio_err); goto end; } if (sigopts) { char *sigopt; for (i = 0; i < sk_OPENSSL_STRING_num(sigopts); i++) { sigopt = sk_OPENSSL_STRING_value(sigopts, i); if (pkey_ctrl_string(pctx, sigopt) <= 0) { BIO_printf(bio_err, "parameter error \"%s\"\n", sigopt); ERR_print_errors(bio_err); goto end; } } } } /* we use md as a filter, reading from 'in' */ else { if (md == NULL) md = EVP_md5(); if (!BIO_set_md(bmd, md)) { BIO_printf(bio_err, "Error setting digest %s\n", pname); ERR_print_errors(bio_err); goto end; } } if (sigfile && sigkey) { BIO *sigbio; sigbio = BIO_new_file(sigfile, "rb"); siglen = EVP_PKEY_size(sigkey); sigbuf = malloc(siglen); if (!sigbio) { BIO_printf(bio_err, "Error opening signature file %s\n", sigfile); ERR_print_errors(bio_err); goto end; } siglen = BIO_read(sigbio, sigbuf, siglen); BIO_free(sigbio); if (siglen <= 0) { BIO_printf(bio_err, "Error reading signature file %s\n", sigfile); ERR_print_errors(bio_err); goto end; } } inp = BIO_push(bmd, in); if (md == NULL) { EVP_MD_CTX *tctx; BIO_get_md_ctx(bmd, &tctx); md = EVP_MD_CTX_md(tctx); } if (argc == 0) { BIO_set_fp(in, stdin, BIO_NOCLOSE); err = do_fp(out, buf, inp, separator, out_bin, sigkey, sigbuf, siglen, NULL, NULL, "stdin", bmd); } else { const char *md_name = NULL, *sig_name = NULL; if (!out_bin) { if (sigkey) { const EVP_PKEY_ASN1_METHOD *ameth; ameth = EVP_PKEY_get0_asn1(sigkey); if (ameth) EVP_PKEY_asn1_get0_info(NULL, NULL, NULL, NULL, &sig_name, ameth); } md_name = EVP_MD_name(md); } err = 0; for (i = 0; i < argc; i++) { int r; if (BIO_read_filename(in, argv[i]) <= 0) { perror(argv[i]); err++; continue; } else { r = do_fp(out, buf, inp, separator, out_bin, sigkey, sigbuf, siglen, sig_name, md_name, argv[i], bmd); } if (r) err = r; (void) BIO_reset(bmd); } } end: if (buf != NULL) { OPENSSL_cleanse(buf, BUFSIZE); free(buf); } if (in != NULL) BIO_free(in); free(passin); BIO_free_all(out); EVP_PKEY_free(sigkey); if (sigopts) sk_OPENSSL_STRING_free(sigopts); if (macopts) sk_OPENSSL_STRING_free(macopts); free(sigbuf); if (bmd != NULL) BIO_free(bmd); return (err); } int do_fp(BIO * out, unsigned char *buf, BIO * bp, int sep, int binout, EVP_PKEY * key, unsigned char *sigin, int siglen, const char *sig_name, const char *md_name, const char *file, BIO * bmd) { size_t len; int i; for (;;) { i = BIO_read(bp, (char *) buf, BUFSIZE); if (i < 0) { BIO_printf(bio_err, "Read Error in %s\n", file); ERR_print_errors(bio_err); return 1; } if (i == 0) break; } if (sigin) { EVP_MD_CTX *ctx; BIO_get_md_ctx(bp, &ctx); i = EVP_DigestVerifyFinal(ctx, sigin, (unsigned int) siglen); if (i > 0) BIO_printf(out, "Verified OK\n"); else if (i == 0) { BIO_printf(out, "Verification Failure\n"); return 1; } else { BIO_printf(bio_err, "Error Verifying Data\n"); ERR_print_errors(bio_err); return 1; } return 0; } if (key) { EVP_MD_CTX *ctx; BIO_get_md_ctx(bp, &ctx); len = BUFSIZE; if (!EVP_DigestSignFinal(ctx, buf, &len)) { BIO_printf(bio_err, "Error Signing Data\n"); ERR_print_errors(bio_err); return 1; } } else { len = BIO_gets(bp, (char *) buf, BUFSIZE); if ((int) len < 0) { ERR_print_errors(bio_err); return 1; } } if (binout) BIO_write(out, buf, len); else if (sep == 2) { for (i = 0; i < (int) len; i++) BIO_printf(out, "%02x", buf[i]); BIO_printf(out, " *%s\n", file); } else { if (sig_name) BIO_printf(out, "%s-%s(%s)= ", sig_name, md_name, file); else if (md_name) BIO_printf(out, "%s(%s)= ", md_name, file); else BIO_printf(out, "(%s)= ", file); for (i = 0; i < (int) len; i++) { if (sep && (i != 0)) BIO_printf(out, ":"); BIO_printf(out, "%02x", buf[i]); } BIO_printf(out, "\n"); } return 0; } deps/libressl-pnacl-sys-2.1.6/libressl/apps/passwd.c0000644000175000017500000003013512360020706017346 0ustar /* $OpenBSD$ */ #if defined OPENSSL_NO_MD5 #define NO_MD5CRYPT_1 #endif #if !defined(OPENSSL_NO_DES) || !defined(NO_MD5CRYPT_1) #include #include #include "apps.h" #include #include #include #include #ifndef OPENSSL_NO_DES #include #endif #ifndef NO_MD5CRYPT_1 #include #endif static unsigned const char cov_2char[64] = { /* from crypto/des/fcrypt.c */ 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A }; static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p, char *passwd, BIO * out, int quiet, int table, int reverse, size_t pw_maxlen, int usecrypt, int use1, int useapr1); /* -crypt - standard Unix password algorithm (default) * -1 - MD5-based password algorithm * -apr1 - MD5-based password algorithm, Apache variant * -salt string - salt * -in file - read passwords from file * -stdin - read passwords from stdin * -noverify - never verify when reading password from terminal * -quiet - no warnings * -table - format output as table * -reverse - switch table columns */ int passwd_main(int, char **); int passwd_main(int argc, char **argv) { int ret = 1; char *infile = NULL; int in_stdin = 0; int in_noverify = 0; char *salt = NULL, *passwd = NULL, **passwds = NULL; char *salt_malloc = NULL, *passwd_malloc = NULL; size_t passwd_malloc_size = 0; int pw_source_defined = 0; BIO *in = NULL, *out = NULL; int i, badopt, opt_done; int passed_salt = 0, quiet = 0, table = 0, reverse = 0; int usecrypt = 0, use1 = 0, useapr1 = 0; size_t pw_maxlen = 0; if (!load_config(bio_err, NULL)) goto err; out = BIO_new(BIO_s_file()); if (out == NULL) goto err; BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT); badopt = 0, opt_done = 0; i = 0; while (!badopt && !opt_done && argv[++i] != NULL) { if (strcmp(argv[i], "-crypt") == 0) usecrypt = 1; else if (strcmp(argv[i], "-1") == 0) use1 = 1; else if (strcmp(argv[i], "-apr1") == 0) useapr1 = 1; else if (strcmp(argv[i], "-salt") == 0) { if ((argv[i + 1] != NULL) && (salt == NULL)) { passed_salt = 1; salt = argv[++i]; } else badopt = 1; } else if (strcmp(argv[i], "-in") == 0) { if ((argv[i + 1] != NULL) && !pw_source_defined) { pw_source_defined = 1; infile = argv[++i]; } else badopt = 1; } else if (strcmp(argv[i], "-stdin") == 0) { if (!pw_source_defined) { pw_source_defined = 1; in_stdin = 1; } else badopt = 1; } else if (strcmp(argv[i], "-noverify") == 0) in_noverify = 1; else if (strcmp(argv[i], "-quiet") == 0) quiet = 1; else if (strcmp(argv[i], "-table") == 0) table = 1; else if (strcmp(argv[i], "-reverse") == 0) reverse = 1; else if (argv[i][0] == '-') badopt = 1; else if (!pw_source_defined) /* non-option arguments, use as passwords */ { pw_source_defined = 1; passwds = &argv[i]; opt_done = 1; } else badopt = 1; } if (!usecrypt && !use1 && !useapr1) /* use default */ usecrypt = 1; if (usecrypt + use1 + useapr1 > 1) /* conflict */ badopt = 1; /* reject unsupported algorithms */ #ifdef OPENSSL_NO_DES if (usecrypt) badopt = 1; #endif #ifdef NO_MD5CRYPT_1 if (use1 || useapr1) badopt = 1; #endif if (badopt) { BIO_printf(bio_err, "Usage: passwd [options] [passwords]\n"); BIO_printf(bio_err, "where options are\n"); #ifndef OPENSSL_NO_DES BIO_printf(bio_err, "-crypt standard Unix password algorithm (default)\n"); #endif #ifndef NO_MD5CRYPT_1 BIO_printf(bio_err, "-1 MD5-based password algorithm\n"); BIO_printf(bio_err, "-apr1 MD5-based password algorithm, Apache variant\n"); #endif BIO_printf(bio_err, "-salt string use provided salt\n"); BIO_printf(bio_err, "-in file read passwords from file\n"); BIO_printf(bio_err, "-stdin read passwords from stdin\n"); BIO_printf(bio_err, "-noverify never verify when reading password from terminal\n"); BIO_printf(bio_err, "-quiet no warnings\n"); BIO_printf(bio_err, "-table format output as table\n"); BIO_printf(bio_err, "-reverse switch table columns\n"); goto err; } if ((infile != NULL) || in_stdin) { in = BIO_new(BIO_s_file()); if (in == NULL) goto err; if (infile != NULL) { assert(in_stdin == 0); if (BIO_read_filename(in, infile) <= 0) goto err; } else { assert(in_stdin); BIO_set_fp(in, stdin, BIO_NOCLOSE); } } if (usecrypt) pw_maxlen = 8; else if (use1 || useapr1) pw_maxlen = 256;/* arbitrary limit, should be enough for most * passwords */ if (passwds == NULL) { /* no passwords on the command line */ passwd_malloc_size = pw_maxlen + 2; /* longer than necessary so that we can warn about truncation */ passwd = passwd_malloc = malloc(passwd_malloc_size); if (passwd_malloc == NULL) goto err; } if ((in == NULL) && (passwds == NULL)) { /* build a null-terminated list */ static char *passwds_static[2] = {NULL, NULL}; passwds = passwds_static; if (in == NULL) if (EVP_read_pw_string(passwd_malloc, passwd_malloc_size, "Password: ", !(passed_salt || in_noverify)) != 0) goto err; passwds[0] = passwd_malloc; } if (in == NULL) { assert(passwds != NULL); assert(*passwds != NULL); do { /* loop over list of passwords */ passwd = *passwds++; if (!do_passwd(passed_salt, &salt, &salt_malloc, passwd, out, quiet, table, reverse, pw_maxlen, usecrypt, use1, useapr1)) goto err; } while (*passwds != NULL); } else /* in != NULL */ { int done; assert(passwd != NULL); do { int r = BIO_gets(in, passwd, pw_maxlen + 1); if (r > 0) { char *c = (strchr(passwd, '\n')); if (c != NULL) *c = 0; /* truncate at newline */ else { /* ignore rest of line */ char trash[BUFSIZ]; do r = BIO_gets(in, trash, sizeof trash); while ((r > 0) && (!strchr(trash, '\n'))); } if (!do_passwd(passed_salt, &salt, &salt_malloc, passwd, out, quiet, table, reverse, pw_maxlen, usecrypt, use1, useapr1)) goto err; } done = (r <= 0); } while (!done); } ret = 0; err: ERR_print_errors(bio_err); free(salt_malloc); free(passwd_malloc); if (in) BIO_free(in); if (out) BIO_free_all(out); return (ret); } #ifndef NO_MD5CRYPT_1 /* MD5-based password algorithm (should probably be available as a library * function; then the static buffer would not be acceptable). * For magic string "1", this should be compatible to the MD5-based BSD * password algorithm. * For 'magic' string "apr1", this is compatible to the MD5-based Apache * password algorithm. * (Apparently, the Apache password algorithm is identical except that the * 'magic' string was changed -- the laziest application of the NIH principle * I've ever encountered.) */ static char * md5crypt(const char *passwd, const char *magic, const char *salt) { static char out_buf[6 + 9 + 24 + 2]; /* "$apr1$..salt..$.......md5h * ash..........\0" */ unsigned char buf[MD5_DIGEST_LENGTH]; char *salt_out; int n; unsigned int i; EVP_MD_CTX md, md2; size_t passwd_len, salt_len; passwd_len = strlen(passwd); out_buf[0] = '$'; out_buf[1] = 0; assert(strlen(magic) <= 4); /* "1" or "apr1" */ strlcat(out_buf, magic, sizeof(out_buf)); strlcat(out_buf, "$", sizeof(out_buf)); strlcat(out_buf, salt, sizeof(out_buf)); assert(strlen(out_buf) <= 6 + 8); /* "$apr1$..salt.." */ salt_out = out_buf + 2 + strlen(magic); salt_len = strlen(salt_out); assert(salt_len <= 8); EVP_MD_CTX_init(&md); EVP_DigestInit_ex(&md, EVP_md5(), NULL); EVP_DigestUpdate(&md, passwd, passwd_len); EVP_DigestUpdate(&md, "$", 1); EVP_DigestUpdate(&md, magic, strlen(magic)); EVP_DigestUpdate(&md, "$", 1); EVP_DigestUpdate(&md, salt_out, salt_len); EVP_MD_CTX_init(&md2); EVP_DigestInit_ex(&md2, EVP_md5(), NULL); EVP_DigestUpdate(&md2, passwd, passwd_len); EVP_DigestUpdate(&md2, salt_out, salt_len); EVP_DigestUpdate(&md2, passwd, passwd_len); EVP_DigestFinal_ex(&md2, buf, NULL); for (i = passwd_len; i > sizeof buf; i -= sizeof buf) EVP_DigestUpdate(&md, buf, sizeof buf); EVP_DigestUpdate(&md, buf, i); n = passwd_len; while (n) { EVP_DigestUpdate(&md, (n & 1) ? "\0" : passwd, 1); n >>= 1; } EVP_DigestFinal_ex(&md, buf, NULL); for (i = 0; i < 1000; i++) { EVP_DigestInit_ex(&md2, EVP_md5(), NULL); EVP_DigestUpdate(&md2, (i & 1) ? (unsigned const char *) passwd : buf, (i & 1) ? passwd_len : sizeof buf); if (i % 3) EVP_DigestUpdate(&md2, salt_out, salt_len); if (i % 7) EVP_DigestUpdate(&md2, passwd, passwd_len); EVP_DigestUpdate(&md2, (i & 1) ? buf : (unsigned const char *) passwd, (i & 1) ? sizeof buf : passwd_len); EVP_DigestFinal_ex(&md2, buf, NULL); } EVP_MD_CTX_cleanup(&md2); { /* transform buf into output string */ unsigned char buf_perm[sizeof buf]; int dest, source; char *output; /* silly output permutation */ for (dest = 0, source = 0; dest < 14; dest++, source = (source + 6) % 17) buf_perm[dest] = buf[source]; buf_perm[14] = buf[5]; buf_perm[15] = buf[11]; assert(16 == sizeof buf_perm); output = salt_out + salt_len; assert(output == out_buf + strlen(out_buf)); *output++ = '$'; for (i = 0; i < 15; i += 3) { *output++ = cov_2char[buf_perm[i + 2] & 0x3f]; *output++ = cov_2char[((buf_perm[i + 1] & 0xf) << 2) | (buf_perm[i + 2] >> 6)]; *output++ = cov_2char[((buf_perm[i] & 3) << 4) | (buf_perm[i + 1] >> 4)]; *output++ = cov_2char[buf_perm[i] >> 2]; } assert(i == 15); *output++ = cov_2char[buf_perm[i] & 0x3f]; *output++ = cov_2char[buf_perm[i] >> 6]; *output = 0; assert(strlen(out_buf) < sizeof(out_buf)); } EVP_MD_CTX_cleanup(&md); return out_buf; } #endif static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p, char *passwd, BIO * out, int quiet, int table, int reverse, size_t pw_maxlen, int usecrypt, int use1, int useapr1) { char *hash = NULL; assert(salt_p != NULL); assert(salt_malloc_p != NULL); /* first make sure we have a salt */ if (!passed_salt) { #ifndef OPENSSL_NO_DES if (usecrypt) { if (*salt_malloc_p == NULL) { *salt_p = *salt_malloc_p = malloc(3); if (*salt_malloc_p == NULL) goto err; } if (RAND_pseudo_bytes((unsigned char *) *salt_p, 2) < 0) goto err; (*salt_p)[0] = cov_2char[(*salt_p)[0] & 0x3f]; /* 6 bits */ (*salt_p)[1] = cov_2char[(*salt_p)[1] & 0x3f]; /* 6 bits */ (*salt_p)[2] = 0; } #endif /* !OPENSSL_NO_DES */ #ifndef NO_MD5CRYPT_1 if (use1 || useapr1) { int i; if (*salt_malloc_p == NULL) { *salt_p = *salt_malloc_p = malloc(9); if (*salt_malloc_p == NULL) goto err; } if (RAND_pseudo_bytes((unsigned char *) *salt_p, 8) < 0) goto err; for (i = 0; i < 8; i++) (*salt_p)[i] = cov_2char[(*salt_p)[i] & 0x3f]; /* 6 bits */ (*salt_p)[8] = 0; } #endif /* !NO_MD5CRYPT_1 */ } assert(*salt_p != NULL); /* truncate password if necessary */ if ((strlen(passwd) > pw_maxlen)) { if (!quiet) /* * XXX: really we should know how to print a size_t, * not cast it */ BIO_printf(bio_err, "Warning: truncating password to %u characters\n", (unsigned) pw_maxlen); passwd[pw_maxlen] = 0; } assert(strlen(passwd) <= pw_maxlen); /* now compute password hash */ #ifndef OPENSSL_NO_DES if (usecrypt) hash = DES_crypt(passwd, *salt_p); #endif #ifndef NO_MD5CRYPT_1 if (use1 || useapr1) hash = md5crypt(passwd, (use1 ? "1" : "apr1"), *salt_p); #endif assert(hash != NULL); if (table && !reverse) BIO_printf(out, "%s\t%s\n", passwd, hash); else if (table && reverse) BIO_printf(out, "%s\t%s\n", hash, passwd); else BIO_printf(out, "%s\n", hash); return 1; err: return 0; } #else int passwd_main(int argc, char **argv) { fputs("Program not available.\n", stderr) return (1); } #endif deps/libressl-pnacl-sys-2.1.6/libressl/apps/apps.c0000644000175000017500000014601712360020706017017 0ustar /* $OpenBSD: apps.c,v 1.63 2014/07/09 21:02:35 tedu Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include #include #include #include #include #include #include #include #include #include #include #include "apps.h" #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_ENGINE #include #endif #include typedef struct { const char *name; unsigned long flag; unsigned long mask; } NAME_EX_TBL; static UI_METHOD *ui_method = NULL; static int set_table_opts(unsigned long *flags, const char *arg, const NAME_EX_TBL *in_tbl); static int set_multi_opts(unsigned long *flags, const char *arg, const NAME_EX_TBL *in_tbl); #if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_RSA) /* Looks like this stuff is worth moving into separate function */ static EVP_PKEY *load_netscape_key(BIO *err, BIO *key, const char *file, const char *key_descrip, int format); #endif int str2fmt(char *s) { if (s == NULL) return FORMAT_UNDEF; if ((*s == 'D') || (*s == 'd')) return (FORMAT_ASN1); else if ((*s == 'T') || (*s == 't')) return (FORMAT_TEXT); else if ((*s == 'N') || (*s == 'n')) return (FORMAT_NETSCAPE); else if ((*s == 'S') || (*s == 's')) return (FORMAT_SMIME); else if ((*s == 'M') || (*s == 'm')) return (FORMAT_MSBLOB); else if ((*s == '1') || (strcmp(s, "PKCS12") == 0) || (strcmp(s, "pkcs12") == 0) || (strcmp(s, "P12") == 0) || (strcmp(s, "p12") == 0)) return (FORMAT_PKCS12); else if ((*s == 'E') || (*s == 'e')) return (FORMAT_ENGINE); else if ((*s == 'P') || (*s == 'p')) { if (s[1] == 'V' || s[1] == 'v') return FORMAT_PVK; else return (FORMAT_PEM); } else return (FORMAT_UNDEF); } void program_name(char *in, char *out, int size) { char *p; p = strrchr(in, '/'); if (p != NULL) p++; else p = in; strlcpy(out, p, size); } int chopup_args(ARGS *arg, char *buf, int *argc, char **argv[]) { int num, i; char *p; *argc = 0; *argv = NULL; i = 0; if (arg->count == 0) { arg->count = 20; arg->data = reallocarray(NULL, arg->count, sizeof(char *)); } for (i = 0; i < arg->count; i++) arg->data[i] = NULL; num = 0; p = buf; for (;;) { /* first scan over white space */ if (!*p) break; while (*p && ((*p == ' ') || (*p == '\t') || (*p == '\n'))) p++; if (!*p) break; /* The start of something good :-) */ if (num >= arg->count) { char **tmp_p; int tlen = arg->count + 20; tmp_p = reallocarray(arg->data, tlen, sizeof(char *)); if (tmp_p == NULL) return 0; arg->data = tmp_p; arg->count = tlen; /* initialize newly allocated data */ for (i = num; i < arg->count; i++) arg->data[i] = NULL; } arg->data[num++] = p; /* now look for the end of this */ if ((*p == '\'') || (*p == '\"')) { /* scan for closing * quote */ i = *(p++); arg->data[num - 1]++; /* jump over quote */ while (*p && (*p != i)) p++; *p = '\0'; } else { while (*p && ((*p != ' ') && (*p != '\t') && (*p != '\n'))) p++; if (*p == '\0') p--; else *p = '\0'; } p++; } *argc = num; *argv = arg->data; return (1); } int dump_cert_text(BIO *out, X509 *x) { char *p; p = X509_NAME_oneline(X509_get_subject_name(x), NULL, 0); BIO_puts(out, "subject="); BIO_puts(out, p); free(p); p = X509_NAME_oneline(X509_get_issuer_name(x), NULL, 0); BIO_puts(out, "\nissuer="); BIO_puts(out, p); BIO_puts(out, "\n"); free(p); return 0; } static int ui_open(UI *ui) { return UI_method_get_opener(UI_OpenSSL()) (ui); } static int ui_read(UI *ui, UI_STRING *uis) { if (UI_get_input_flags(uis) & UI_INPUT_FLAG_DEFAULT_PWD && UI_get0_user_data(ui)) { switch (UI_get_string_type(uis)) { case UIT_PROMPT: case UIT_VERIFY: { const char *password = ((PW_CB_DATA *)UI_get0_user_data(ui))->password; if (password && password[0] != '\0') { UI_set_result(ui, uis, password); return 1; } } break; default: break; } } return UI_method_get_reader(UI_OpenSSL()) (ui, uis); } static int ui_write(UI *ui, UI_STRING *uis) { if (UI_get_input_flags(uis) & UI_INPUT_FLAG_DEFAULT_PWD && UI_get0_user_data(ui)) { switch (UI_get_string_type(uis)) { case UIT_PROMPT: case UIT_VERIFY: { const char *password = ((PW_CB_DATA *)UI_get0_user_data(ui))->password; if (password && password[0] != '\0') return 1; } break; default: break; } } return UI_method_get_writer(UI_OpenSSL()) (ui, uis); } static int ui_close(UI *ui) { return UI_method_get_closer(UI_OpenSSL()) (ui); } int setup_ui_method(void) { ui_method = UI_create_method("OpenSSL application user interface"); UI_method_set_opener(ui_method, ui_open); UI_method_set_reader(ui_method, ui_read); UI_method_set_writer(ui_method, ui_write); UI_method_set_closer(ui_method, ui_close); return 0; } void destroy_ui_method(void) { if (ui_method) { UI_destroy_method(ui_method); ui_method = NULL; } } int password_callback(char *buf, int bufsiz, int verify, void *arg) { PW_CB_DATA *cb_tmp = arg; UI *ui = NULL; int res = 0; const char *prompt_info = NULL; const char *password = NULL; PW_CB_DATA *cb_data = (PW_CB_DATA *) cb_tmp; if (cb_data) { if (cb_data->password) password = cb_data->password; if (cb_data->prompt_info) prompt_info = cb_data->prompt_info; } if (password) { res = strlen(password); if (res > bufsiz) res = bufsiz; memcpy(buf, password, res); return res; } ui = UI_new_method(ui_method); if (ui) { int ok = 0; char *buff = NULL; int ui_flags = 0; char *prompt = NULL; prompt = UI_construct_prompt(ui, "pass phrase", prompt_info); ui_flags |= UI_INPUT_FLAG_DEFAULT_PWD; UI_ctrl(ui, UI_CTRL_PRINT_ERRORS, 1, 0, 0); if (ok >= 0) ok = UI_add_input_string(ui, prompt, ui_flags, buf, PW_MIN_LENGTH, bufsiz - 1); if (ok >= 0 && verify) { buff = malloc(bufsiz); ok = UI_add_verify_string(ui, prompt, ui_flags, buff, PW_MIN_LENGTH, bufsiz - 1, buf); } if (ok >= 0) do { ok = UI_process(ui); } while (ok < 0 && UI_ctrl(ui, UI_CTRL_IS_REDOABLE, 0, 0, 0)); if (buff) { OPENSSL_cleanse(buff, (unsigned int) bufsiz); free(buff); } if (ok >= 0) res = strlen(buf); if (ok == -1) { BIO_printf(bio_err, "User interface error\n"); ERR_print_errors(bio_err); OPENSSL_cleanse(buf, (unsigned int) bufsiz); res = 0; } if (ok == -2) { BIO_printf(bio_err, "aborted!\n"); OPENSSL_cleanse(buf, (unsigned int) bufsiz); res = 0; } UI_free(ui); free(prompt); } return res; } static char *app_get_pass(BIO *err, char *arg, int keepbio); int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2) { int same; if (!arg2 || !arg1 || strcmp(arg1, arg2)) same = 0; else same = 1; if (arg1) { *pass1 = app_get_pass(err, arg1, same); if (!*pass1) return 0; } else if (pass1) *pass1 = NULL; if (arg2) { *pass2 = app_get_pass(err, arg2, same ? 2 : 0); if (!*pass2) return 0; } else if (pass2) *pass2 = NULL; return 1; } static char * app_get_pass(BIO *err, char *arg, int keepbio) { char *tmp, tpass[APP_PASS_LEN]; static BIO *pwdbio = NULL; const char *errstr = NULL; int i; if (!strncmp(arg, "pass:", 5)) return BUF_strdup(arg + 5); if (!strncmp(arg, "env:", 4)) { tmp = getenv(arg + 4); if (!tmp) { BIO_printf(err, "Can't read environment variable %s\n", arg + 4); return NULL; } return BUF_strdup(tmp); } if (!keepbio || !pwdbio) { if (!strncmp(arg, "file:", 5)) { pwdbio = BIO_new_file(arg + 5, "r"); if (!pwdbio) { BIO_printf(err, "Can't open file %s\n", arg + 5); return NULL; } } else if (!strncmp(arg, "fd:", 3)) { BIO *btmp; i = strtonum(arg + 3, 1, INT_MAX, &errstr); if (errstr) { BIO_printf(err, "Invalid file descriptor %s: %s\n", arg, errstr); return NULL; } pwdbio = BIO_new_fd(i, BIO_NOCLOSE); if (!pwdbio) { BIO_printf(err, "Can't access file descriptor %s\n", arg + 3); return NULL; } /* * Can't do BIO_gets on an fd BIO so add a buffering * BIO */ btmp = BIO_new(BIO_f_buffer()); pwdbio = BIO_push(btmp, pwdbio); } else if (!strcmp(arg, "stdin")) { pwdbio = BIO_new_fp(stdin, BIO_NOCLOSE); if (!pwdbio) { BIO_printf(err, "Can't open BIO for stdin\n"); return NULL; } } else { BIO_printf(err, "Invalid password argument \"%s\"\n", arg); return NULL; } } i = BIO_gets(pwdbio, tpass, APP_PASS_LEN); if (keepbio != 1) { BIO_free_all(pwdbio); pwdbio = NULL; } if (i <= 0) { BIO_printf(err, "Error reading password from BIO\n"); return NULL; } tmp = strchr(tpass, '\n'); if (tmp) *tmp = 0; return BUF_strdup(tpass); } int add_oid_section(BIO *err, CONF *conf) { char *p; STACK_OF(CONF_VALUE) *sktmp; CONF_VALUE *cnf; int i; if (!(p = NCONF_get_string(conf, NULL, "oid_section"))) { ERR_clear_error(); return 1; } if (!(sktmp = NCONF_get_section(conf, p))) { BIO_printf(err, "problem loading oid section %s\n", p); return 0; } for (i = 0; i < sk_CONF_VALUE_num(sktmp); i++) { cnf = sk_CONF_VALUE_value(sktmp, i); if (OBJ_create(cnf->value, cnf->name, cnf->name) == NID_undef) { BIO_printf(err, "problem creating object %s=%s\n", cnf->name, cnf->value); return 0; } } return 1; } static int load_pkcs12(BIO *err, BIO *in, const char *desc, pem_password_cb *pem_cb, void *cb_data, EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) **ca) { const char *pass; char tpass[PEM_BUFSIZE]; int len, ret = 0; PKCS12 *p12; p12 = d2i_PKCS12_bio(in, NULL); if (p12 == NULL) { BIO_printf(err, "Error loading PKCS12 file for %s\n", desc); goto die; } /* See if an empty password will do */ if (PKCS12_verify_mac(p12, "", 0) || PKCS12_verify_mac(p12, NULL, 0)) pass = ""; else { if (!pem_cb) pem_cb = password_callback; len = pem_cb(tpass, PEM_BUFSIZE, 0, cb_data); if (len < 0) { BIO_printf(err, "Passpharse callback error for %s\n", desc); goto die; } if (len < PEM_BUFSIZE) tpass[len] = 0; if (!PKCS12_verify_mac(p12, tpass, len)) { BIO_printf(err, "Mac verify error (wrong password?) in PKCS12 file for %s\n", desc); goto die; } pass = tpass; } ret = PKCS12_parse(p12, pass, pkey, cert, ca); die: if (p12) PKCS12_free(p12); return ret; } X509 * load_cert(BIO *err, const char *file, int format, const char *pass, ENGINE *e, const char *cert_descrip) { X509 *x = NULL; BIO *cert; if ((cert = BIO_new(BIO_s_file())) == NULL) { ERR_print_errors(err); goto end; } if (file == NULL) { setvbuf(stdin, NULL, _IONBF, 0); BIO_set_fp(cert, stdin, BIO_NOCLOSE); } else { if (BIO_read_filename(cert, file) <= 0) { BIO_printf(err, "Error opening %s %s\n", cert_descrip, file); ERR_print_errors(err); goto end; } } if (format == FORMAT_ASN1) x = d2i_X509_bio(cert, NULL); else if (format == FORMAT_NETSCAPE) { NETSCAPE_X509 *nx; nx = ASN1_item_d2i_bio(ASN1_ITEM_rptr(NETSCAPE_X509), cert, NULL); if (nx == NULL) goto end; if ((strncmp(NETSCAPE_CERT_HDR, (char *) nx->header->data, nx->header->length) != 0)) { NETSCAPE_X509_free(nx); BIO_printf(err, "Error reading header on certificate\n"); goto end; } x = nx->cert; nx->cert = NULL; NETSCAPE_X509_free(nx); } else if (format == FORMAT_PEM) x = PEM_read_bio_X509_AUX(cert, NULL, password_callback, NULL); else if (format == FORMAT_PKCS12) { if (!load_pkcs12(err, cert, cert_descrip, NULL, NULL, NULL, &x, NULL)) goto end; } else { BIO_printf(err, "bad input format specified for %s\n", cert_descrip); goto end; } end: if (x == NULL) { BIO_printf(err, "unable to load certificate\n"); ERR_print_errors(err); } if (cert != NULL) BIO_free(cert); return (x); } EVP_PKEY * load_key(BIO *err, const char *file, int format, int maybe_stdin, const char *pass, ENGINE *e, const char *key_descrip) { BIO *key = NULL; EVP_PKEY *pkey = NULL; PW_CB_DATA cb_data; cb_data.password = pass; cb_data.prompt_info = file; if (file == NULL && (!maybe_stdin || format == FORMAT_ENGINE)) { BIO_printf(err, "no keyfile specified\n"); goto end; } #ifndef OPENSSL_NO_ENGINE if (format == FORMAT_ENGINE) { if (!e) BIO_printf(err, "no engine specified\n"); else { pkey = ENGINE_load_private_key(e, file, ui_method, &cb_data); if (!pkey) { BIO_printf(err, "cannot load %s from engine\n", key_descrip); ERR_print_errors(err); } } goto end; } #endif key = BIO_new(BIO_s_file()); if (key == NULL) { ERR_print_errors(err); goto end; } if (file == NULL && maybe_stdin) { setvbuf(stdin, NULL, _IONBF, 0); BIO_set_fp(key, stdin, BIO_NOCLOSE); } else if (BIO_read_filename(key, file) <= 0) { BIO_printf(err, "Error opening %s %s\n", key_descrip, file); ERR_print_errors(err); goto end; } if (format == FORMAT_ASN1) { pkey = d2i_PrivateKey_bio(key, NULL); } else if (format == FORMAT_PEM) { pkey = PEM_read_bio_PrivateKey(key, NULL, password_callback, &cb_data); } #if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_RSA) else if (format == FORMAT_NETSCAPE || format == FORMAT_IISSGC) pkey = load_netscape_key(err, key, file, key_descrip, format); #endif else if (format == FORMAT_PKCS12) { if (!load_pkcs12(err, key, key_descrip, password_callback, &cb_data, &pkey, NULL, NULL)) goto end; } #if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DSA) && !defined (OPENSSL_NO_RC4) else if (format == FORMAT_MSBLOB) pkey = b2i_PrivateKey_bio(key); else if (format == FORMAT_PVK) pkey = b2i_PVK_bio(key, password_callback, &cb_data); #endif else { BIO_printf(err, "bad input format specified for key file\n"); goto end; } end: if (key != NULL) BIO_free(key); if (pkey == NULL) { BIO_printf(err, "unable to load %s\n", key_descrip); ERR_print_errors(err); } return (pkey); } EVP_PKEY * load_pubkey(BIO *err, const char *file, int format, int maybe_stdin, const char *pass, ENGINE *e, const char *key_descrip) { BIO *key = NULL; EVP_PKEY *pkey = NULL; PW_CB_DATA cb_data; cb_data.password = pass; cb_data.prompt_info = file; if (file == NULL && (!maybe_stdin || format == FORMAT_ENGINE)) { BIO_printf(err, "no keyfile specified\n"); goto end; } #ifndef OPENSSL_NO_ENGINE if (format == FORMAT_ENGINE) { if (!e) BIO_printf(bio_err, "no engine specified\n"); else pkey = ENGINE_load_public_key(e, file, ui_method, &cb_data); goto end; } #endif key = BIO_new(BIO_s_file()); if (key == NULL) { ERR_print_errors(err); goto end; } if (file == NULL && maybe_stdin) { setvbuf(stdin, NULL, _IONBF, 0); BIO_set_fp(key, stdin, BIO_NOCLOSE); } else if (BIO_read_filename(key, file) <= 0) { BIO_printf(err, "Error opening %s %s\n", key_descrip, file); ERR_print_errors(err); goto end; } if (format == FORMAT_ASN1) { pkey = d2i_PUBKEY_bio(key, NULL); } else if (format == FORMAT_ASN1RSA) { RSA *rsa; rsa = d2i_RSAPublicKey_bio(key, NULL); if (rsa) { pkey = EVP_PKEY_new(); if (pkey) EVP_PKEY_set1_RSA(pkey, rsa); RSA_free(rsa); } else pkey = NULL; } else if (format == FORMAT_PEMRSA) { RSA *rsa; rsa = PEM_read_bio_RSAPublicKey(key, NULL, password_callback, &cb_data); if (rsa) { pkey = EVP_PKEY_new(); if (pkey) EVP_PKEY_set1_RSA(pkey, rsa); RSA_free(rsa); } else pkey = NULL; } else if (format == FORMAT_PEM) { pkey = PEM_read_bio_PUBKEY(key, NULL, password_callback, &cb_data); } #if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_RSA) else if (format == FORMAT_NETSCAPE || format == FORMAT_IISSGC) pkey = load_netscape_key(err, key, file, key_descrip, format); #endif #if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DSA) else if (format == FORMAT_MSBLOB) pkey = b2i_PublicKey_bio(key); #endif else { BIO_printf(err, "bad input format specified for key file\n"); goto end; } end: if (key != NULL) BIO_free(key); if (pkey == NULL) BIO_printf(err, "unable to load %s\n", key_descrip); return (pkey); } #if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_RSA) static EVP_PKEY * load_netscape_key(BIO *err, BIO *key, const char *file, const char *key_descrip, int format) { EVP_PKEY *pkey; BUF_MEM *buf; RSA *rsa; const unsigned char *p; int size, i; buf = BUF_MEM_new(); pkey = EVP_PKEY_new(); size = 0; if (buf == NULL || pkey == NULL) goto error; for (;;) { if (!BUF_MEM_grow_clean(buf, size + 1024 * 10)) goto error; i = BIO_read(key, &(buf->data[size]), 1024 * 10); size += i; if (i == 0) break; if (i < 0) { BIO_printf(err, "Error reading %s %s", key_descrip, file); goto error; } } p = (unsigned char *) buf->data; rsa = d2i_RSA_NET(NULL, &p, (long) size, NULL, (format == FORMAT_IISSGC ? 1 : 0)); if (rsa == NULL) goto error; BUF_MEM_free(buf); EVP_PKEY_set1_RSA(pkey, rsa); return pkey; error: BUF_MEM_free(buf); EVP_PKEY_free(pkey); return NULL; } #endif /* ndef OPENSSL_NO_RC4 */ static int load_certs_crls(BIO *err, const char *file, int format, const char *pass, ENGINE *e, const char *desc, STACK_OF(X509) **pcerts, STACK_OF(X509_CRL) **pcrls) { int i; BIO *bio; STACK_OF(X509_INFO) *xis = NULL; X509_INFO *xi; PW_CB_DATA cb_data; int rv = 0; cb_data.password = pass; cb_data.prompt_info = file; if (format != FORMAT_PEM) { BIO_printf(err, "bad input format specified for %s\n", desc); return 0; } if (file == NULL) bio = BIO_new_fp(stdin, BIO_NOCLOSE); else bio = BIO_new_file(file, "r"); if (bio == NULL) { BIO_printf(err, "Error opening %s %s\n", desc, file ? file : "stdin"); ERR_print_errors(err); return 0; } xis = PEM_X509_INFO_read_bio(bio, NULL, password_callback, &cb_data); BIO_free(bio); if (pcerts) { *pcerts = sk_X509_new_null(); if (!*pcerts) goto end; } if (pcrls) { *pcrls = sk_X509_CRL_new_null(); if (!*pcrls) goto end; } for (i = 0; i < sk_X509_INFO_num(xis); i++) { xi = sk_X509_INFO_value(xis, i); if (xi->x509 && pcerts) { if (!sk_X509_push(*pcerts, xi->x509)) goto end; xi->x509 = NULL; } if (xi->crl && pcrls) { if (!sk_X509_CRL_push(*pcrls, xi->crl)) goto end; xi->crl = NULL; } } if (pcerts && sk_X509_num(*pcerts) > 0) rv = 1; if (pcrls && sk_X509_CRL_num(*pcrls) > 0) rv = 1; end: if (xis) sk_X509_INFO_pop_free(xis, X509_INFO_free); if (rv == 0) { if (pcerts) { sk_X509_pop_free(*pcerts, X509_free); *pcerts = NULL; } if (pcrls) { sk_X509_CRL_pop_free(*pcrls, X509_CRL_free); *pcrls = NULL; } BIO_printf(err, "unable to load %s\n", pcerts ? "certificates" : "CRLs"); ERR_print_errors(err); } return rv; } STACK_OF(X509) * load_certs(BIO *err, const char *file, int format, const char *pass, ENGINE *e, const char *desc) { STACK_OF(X509) *certs; if (!load_certs_crls(err, file, format, pass, e, desc, &certs, NULL)) return NULL; return certs; } STACK_OF(X509_CRL) * load_crls(BIO *err, const char *file, int format, const char *pass, ENGINE *e, const char *desc) { STACK_OF(X509_CRL) *crls; if (!load_certs_crls(err, file, format, pass, e, desc, NULL, &crls)) return NULL; return crls; } #define X509V3_EXT_UNKNOWN_MASK (0xfL << 16) /* Return error for unknown extensions */ #define X509V3_EXT_DEFAULT 0 /* Print error for unknown extensions */ #define X509V3_EXT_ERROR_UNKNOWN (1L << 16) /* ASN1 parse unknown extensions */ #define X509V3_EXT_PARSE_UNKNOWN (2L << 16) /* BIO_dump unknown extensions */ #define X509V3_EXT_DUMP_UNKNOWN (3L << 16) #define X509_FLAG_CA (X509_FLAG_NO_ISSUER | X509_FLAG_NO_PUBKEY | \ X509_FLAG_NO_HEADER | X509_FLAG_NO_VERSION) int set_cert_ex(unsigned long *flags, const char *arg) { static const NAME_EX_TBL cert_tbl[] = { {"compatible", X509_FLAG_COMPAT, 0xffffffffl}, {"ca_default", X509_FLAG_CA, 0xffffffffl}, {"no_header", X509_FLAG_NO_HEADER, 0}, {"no_version", X509_FLAG_NO_VERSION, 0}, {"no_serial", X509_FLAG_NO_SERIAL, 0}, {"no_signame", X509_FLAG_NO_SIGNAME, 0}, {"no_validity", X509_FLAG_NO_VALIDITY, 0}, {"no_subject", X509_FLAG_NO_SUBJECT, 0}, {"no_issuer", X509_FLAG_NO_ISSUER, 0}, {"no_pubkey", X509_FLAG_NO_PUBKEY, 0}, {"no_extensions", X509_FLAG_NO_EXTENSIONS, 0}, {"no_sigdump", X509_FLAG_NO_SIGDUMP, 0}, {"no_aux", X509_FLAG_NO_AUX, 0}, {"no_attributes", X509_FLAG_NO_ATTRIBUTES, 0}, {"ext_default", X509V3_EXT_DEFAULT, X509V3_EXT_UNKNOWN_MASK}, {"ext_error", X509V3_EXT_ERROR_UNKNOWN, X509V3_EXT_UNKNOWN_MASK}, {"ext_parse", X509V3_EXT_PARSE_UNKNOWN, X509V3_EXT_UNKNOWN_MASK}, {"ext_dump", X509V3_EXT_DUMP_UNKNOWN, X509V3_EXT_UNKNOWN_MASK}, {NULL, 0, 0} }; return set_multi_opts(flags, arg, cert_tbl); } int set_name_ex(unsigned long *flags, const char *arg) { static const NAME_EX_TBL ex_tbl[] = { {"esc_2253", ASN1_STRFLGS_ESC_2253, 0}, {"esc_ctrl", ASN1_STRFLGS_ESC_CTRL, 0}, {"esc_msb", ASN1_STRFLGS_ESC_MSB, 0}, {"use_quote", ASN1_STRFLGS_ESC_QUOTE, 0}, {"utf8", ASN1_STRFLGS_UTF8_CONVERT, 0}, {"ignore_type", ASN1_STRFLGS_IGNORE_TYPE, 0}, {"show_type", ASN1_STRFLGS_SHOW_TYPE, 0}, {"dump_all", ASN1_STRFLGS_DUMP_ALL, 0}, {"dump_nostr", ASN1_STRFLGS_DUMP_UNKNOWN, 0}, {"dump_der", ASN1_STRFLGS_DUMP_DER, 0}, {"compat", XN_FLAG_COMPAT, 0xffffffffL}, {"sep_comma_plus", XN_FLAG_SEP_COMMA_PLUS, XN_FLAG_SEP_MASK}, {"sep_comma_plus_space", XN_FLAG_SEP_CPLUS_SPC, XN_FLAG_SEP_MASK}, {"sep_semi_plus_space", XN_FLAG_SEP_SPLUS_SPC, XN_FLAG_SEP_MASK}, {"sep_multiline", XN_FLAG_SEP_MULTILINE, XN_FLAG_SEP_MASK}, {"dn_rev", XN_FLAG_DN_REV, 0}, {"nofname", XN_FLAG_FN_NONE, XN_FLAG_FN_MASK}, {"sname", XN_FLAG_FN_SN, XN_FLAG_FN_MASK}, {"lname", XN_FLAG_FN_LN, XN_FLAG_FN_MASK}, {"align", XN_FLAG_FN_ALIGN, 0}, {"oid", XN_FLAG_FN_OID, XN_FLAG_FN_MASK}, {"space_eq", XN_FLAG_SPC_EQ, 0}, {"dump_unknown", XN_FLAG_DUMP_UNKNOWN_FIELDS, 0}, {"RFC2253", XN_FLAG_RFC2253, 0xffffffffL}, {"oneline", XN_FLAG_ONELINE, 0xffffffffL}, {"multiline", XN_FLAG_MULTILINE, 0xffffffffL}, {"ca_default", XN_FLAG_MULTILINE, 0xffffffffL}, {NULL, 0, 0} }; return set_multi_opts(flags, arg, ex_tbl); } int set_ext_copy(int *copy_type, const char *arg) { if (!strcasecmp(arg, "none")) *copy_type = EXT_COPY_NONE; else if (!strcasecmp(arg, "copy")) *copy_type = EXT_COPY_ADD; else if (!strcasecmp(arg, "copyall")) *copy_type = EXT_COPY_ALL; else return 0; return 1; } int copy_extensions(X509 *x, X509_REQ *req, int copy_type) { STACK_OF(X509_EXTENSION) *exts = NULL; X509_EXTENSION *ext, *tmpext; ASN1_OBJECT *obj; int i, idx, ret = 0; if (!x || !req || (copy_type == EXT_COPY_NONE)) return 1; exts = X509_REQ_get_extensions(req); for (i = 0; i < sk_X509_EXTENSION_num(exts); i++) { ext = sk_X509_EXTENSION_value(exts, i); obj = X509_EXTENSION_get_object(ext); idx = X509_get_ext_by_OBJ(x, obj, -1); /* Does extension exist? */ if (idx != -1) { /* If normal copy don't override existing extension */ if (copy_type == EXT_COPY_ADD) continue; /* Delete all extensions of same type */ do { tmpext = X509_get_ext(x, idx); X509_delete_ext(x, idx); X509_EXTENSION_free(tmpext); idx = X509_get_ext_by_OBJ(x, obj, -1); } while (idx != -1); } if (!X509_add_ext(x, ext, -1)) goto end; } ret = 1; end: sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free); return ret; } static int set_multi_opts(unsigned long *flags, const char *arg, const NAME_EX_TBL *in_tbl) { STACK_OF(CONF_VALUE) *vals; CONF_VALUE *val; int i, ret = 1; if (!arg) return 0; vals = X509V3_parse_list(arg); for (i = 0; i < sk_CONF_VALUE_num(vals); i++) { val = sk_CONF_VALUE_value(vals, i); if (!set_table_opts(flags, val->name, in_tbl)) ret = 0; } sk_CONF_VALUE_pop_free(vals, X509V3_conf_free); return ret; } static int set_table_opts(unsigned long *flags, const char *arg, const NAME_EX_TBL *in_tbl) { char c; const NAME_EX_TBL *ptbl; c = arg[0]; if (c == '-') { c = 0; arg++; } else if (c == '+') { c = 1; arg++; } else c = 1; for (ptbl = in_tbl; ptbl->name; ptbl++) { if (!strcasecmp(arg, ptbl->name)) { *flags &= ~ptbl->mask; if (c) *flags |= ptbl->flag; else *flags &= ~ptbl->flag; return 1; } } return 0; } void print_name(BIO *out, const char *title, X509_NAME *nm, unsigned long lflags) { char *buf; char mline = 0; int indent = 0; if (title) BIO_puts(out, title); if ((lflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { mline = 1; indent = 4; } if (lflags == XN_FLAG_COMPAT) { buf = X509_NAME_oneline(nm, 0, 0); BIO_puts(out, buf); BIO_puts(out, "\n"); free(buf); } else { if (mline) BIO_puts(out, "\n"); X509_NAME_print_ex(out, nm, indent, lflags); BIO_puts(out, "\n"); } } X509_STORE * setup_verify(BIO *bp, char *CAfile, char *CApath) { X509_STORE *store; X509_LOOKUP *lookup; if (!(store = X509_STORE_new())) goto end; lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file()); if (lookup == NULL) goto end; if (CAfile) { if (!X509_LOOKUP_load_file(lookup, CAfile, X509_FILETYPE_PEM)) { BIO_printf(bp, "Error loading file %s\n", CAfile); goto end; } } else X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT); lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir()); if (lookup == NULL) goto end; if (CApath) { if (!X509_LOOKUP_add_dir(lookup, CApath, X509_FILETYPE_PEM)) { BIO_printf(bp, "Error loading directory %s\n", CApath); goto end; } } else X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT); ERR_clear_error(); return store; end: X509_STORE_free(store); return NULL; } #ifndef OPENSSL_NO_ENGINE /* Try to load an engine in a shareable library */ static ENGINE * try_load_engine(BIO *err, const char *engine, int debug) { ENGINE *e = ENGINE_by_id("dynamic"); if (e) { if (!ENGINE_ctrl_cmd_string(e, "SO_PATH", engine, 0) || !ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0)) { ENGINE_free(e); e = NULL; } } return e; } ENGINE * setup_engine(BIO *err, const char *engine, int debug) { ENGINE *e = NULL; if (engine) { if (strcmp(engine, "auto") == 0) { BIO_printf(err, "enabling auto ENGINE support\n"); ENGINE_register_all_complete(); return NULL; } if ((e = ENGINE_by_id(engine)) == NULL && (e = try_load_engine(err, engine, debug)) == NULL) { BIO_printf(err, "invalid engine \"%s\"\n", engine); ERR_print_errors(err); return NULL; } if (debug) { ENGINE_ctrl(e, ENGINE_CTRL_SET_LOGSTREAM, 0, err, 0); } ENGINE_ctrl_cmd(e, "SET_USER_INTERFACE", 0, ui_method, 0, 1); if (!ENGINE_set_default(e, ENGINE_METHOD_ALL)) { BIO_printf(err, "can't use that engine\n"); ERR_print_errors(err); ENGINE_free(e); return NULL; } BIO_printf(err, "engine \"%s\" set.\n", ENGINE_get_id(e)); /* Free our "structural" reference. */ ENGINE_free(e); } return e; } #endif int load_config(BIO *err, CONF *cnf) { static int load_config_called = 0; if (load_config_called) return 1; load_config_called = 1; if (!cnf) cnf = config; if (!cnf) return 1; OPENSSL_load_builtin_modules(); if (CONF_modules_load(cnf, NULL, 0) <= 0) { BIO_printf(err, "Error configuring OpenSSL\n"); ERR_print_errors(err); return 0; } return 1; } char * make_config_name() { const char *t = X509_get_default_cert_area(); char *p; if (asprintf(&p, "%s/openssl.cnf", t) == -1) return NULL; return p; } static unsigned long index_serial_hash(const OPENSSL_CSTRING *a) { const char *n; n = a[DB_serial]; while (*n == '0') n++; return (lh_strhash(n)); } static int index_serial_cmp(const OPENSSL_CSTRING *a, const OPENSSL_CSTRING *b) { const char *aa, *bb; for (aa = a[DB_serial]; *aa == '0'; aa++) ; for (bb = b[DB_serial]; *bb == '0'; bb++) ; return (strcmp(aa, bb)); } static int index_name_qual(char **a) { return (a[0][0] == 'V'); } static unsigned long index_name_hash(const OPENSSL_CSTRING *a) { return (lh_strhash(a[DB_name])); } int index_name_cmp(const OPENSSL_CSTRING *a, const OPENSSL_CSTRING *b) { return (strcmp(a[DB_name], b[DB_name])); } static IMPLEMENT_LHASH_HASH_FN(index_serial, OPENSSL_CSTRING) static IMPLEMENT_LHASH_COMP_FN(index_serial, OPENSSL_CSTRING) static IMPLEMENT_LHASH_HASH_FN(index_name, OPENSSL_CSTRING) static IMPLEMENT_LHASH_COMP_FN(index_name, OPENSSL_CSTRING) #define BSIZE 256 BIGNUM * load_serial(char *serialfile, int create, ASN1_INTEGER **retai) { BIO *in = NULL; BIGNUM *ret = NULL; char buf[1024]; ASN1_INTEGER *ai = NULL; ai = ASN1_INTEGER_new(); if (ai == NULL) goto err; if ((in = BIO_new(BIO_s_file())) == NULL) { ERR_print_errors(bio_err); goto err; } if (BIO_read_filename(in, serialfile) <= 0) { if (!create) { perror(serialfile); goto err; } else { ret = BN_new(); if (ret == NULL || !rand_serial(ret, ai)) BIO_printf(bio_err, "Out of memory\n"); } } else { if (!a2i_ASN1_INTEGER(in, ai, buf, 1024)) { BIO_printf(bio_err, "unable to load number from %s\n", serialfile); goto err; } ret = ASN1_INTEGER_to_BN(ai, NULL); if (ret == NULL) { BIO_printf(bio_err, "error converting number from bin to BIGNUM\n"); goto err; } } if (ret && retai) { *retai = ai; ai = NULL; } err: if (in != NULL) BIO_free(in); if (ai != NULL) ASN1_INTEGER_free(ai); return (ret); } int save_serial(char *serialfile, char *suffix, BIGNUM *serial, ASN1_INTEGER **retai) { char buf[1][BSIZE]; BIO *out = NULL; int ret = 0, n; ASN1_INTEGER *ai = NULL; int j; if (suffix == NULL) j = strlen(serialfile); else j = strlen(serialfile) + strlen(suffix) + 1; if (j >= BSIZE) { BIO_printf(bio_err, "file name too long\n"); goto err; } if (suffix == NULL) n = strlcpy(buf[0], serialfile, BSIZE); else n = snprintf(buf[0], sizeof buf[0], "%s.%s", serialfile, suffix); if (n == -1 || n >= sizeof(buf[0])) { BIO_printf(bio_err, "serial too long\n"); goto err; } out = BIO_new(BIO_s_file()); if (out == NULL) { ERR_print_errors(bio_err); goto err; } if (BIO_write_filename(out, buf[0]) <= 0) { perror(serialfile); goto err; } if ((ai = BN_to_ASN1_INTEGER(serial, NULL)) == NULL) { BIO_printf(bio_err, "error converting serial to ASN.1 format\n"); goto err; } i2a_ASN1_INTEGER(out, ai); BIO_puts(out, "\n"); ret = 1; if (retai) { *retai = ai; ai = NULL; } err: if (out != NULL) BIO_free_all(out); if (ai != NULL) ASN1_INTEGER_free(ai); return (ret); } int rotate_serial(char *serialfile, char *new_suffix, char *old_suffix) { char buf[5][BSIZE]; int i, j; i = strlen(serialfile) + strlen(old_suffix); j = strlen(serialfile) + strlen(new_suffix); if (i > j) j = i; if (j + 1 >= BSIZE) { BIO_printf(bio_err, "file name too long\n"); goto err; } snprintf(buf[0], sizeof buf[0], "%s.%s", serialfile, new_suffix); snprintf(buf[1], sizeof buf[1], "%s.%s", serialfile, old_suffix); if (rename(serialfile, buf[1]) < 0 && errno != ENOENT && errno != ENOTDIR) { BIO_printf(bio_err, "unable to rename %s to %s\n", serialfile, buf[1]); perror("reason"); goto err; } if (rename(buf[0], serialfile) < 0) { BIO_printf(bio_err, "unable to rename %s to %s\n", buf[0], serialfile); perror("reason"); rename(buf[1], serialfile); goto err; } return 1; err: return 0; } int rand_serial(BIGNUM *b, ASN1_INTEGER *ai) { BIGNUM *btmp; int ret = 0; if (b) btmp = b; else btmp = BN_new(); if (!btmp) return 0; if (!BN_pseudo_rand(btmp, SERIAL_RAND_BITS, 0, 0)) goto error; if (ai && !BN_to_ASN1_INTEGER(btmp, ai)) goto error; ret = 1; error: if (!b) BN_free(btmp); return ret; } CA_DB * load_index(char *dbfile, DB_ATTR *db_attr) { CA_DB *retdb = NULL; TXT_DB *tmpdb = NULL; BIO *in = BIO_new(BIO_s_file()); CONF *dbattr_conf = NULL; char buf[1][BSIZE]; long errorline = -1; if (in == NULL) { ERR_print_errors(bio_err); goto err; } if (BIO_read_filename(in, dbfile) <= 0) { perror(dbfile); BIO_printf(bio_err, "unable to open '%s'\n", dbfile); goto err; } if ((tmpdb = TXT_DB_read(in, DB_NUMBER)) == NULL) goto err; snprintf(buf[0], sizeof buf[0], "%s.attr", dbfile); dbattr_conf = NCONF_new(NULL); if (NCONF_load(dbattr_conf, buf[0], &errorline) <= 0) { if (errorline > 0) { BIO_printf(bio_err, "error on line %ld of db attribute file '%s'\n", errorline, buf[0]); goto err; } else { NCONF_free(dbattr_conf); dbattr_conf = NULL; } } if ((retdb = malloc(sizeof(CA_DB))) == NULL) { fprintf(stderr, "Out of memory\n"); goto err; } retdb->db = tmpdb; tmpdb = NULL; if (db_attr) retdb->attributes = *db_attr; else { retdb->attributes.unique_subject = 1; } if (dbattr_conf) { char *p = NCONF_get_string(dbattr_conf, NULL, "unique_subject"); if (p) { retdb->attributes.unique_subject = parse_yesno(p, 1); } } err: if (dbattr_conf) NCONF_free(dbattr_conf); if (tmpdb) TXT_DB_free(tmpdb); if (in) BIO_free_all(in); return retdb; } int index_index(CA_DB *db) { if (!TXT_DB_create_index(db->db, DB_serial, NULL, LHASH_HASH_FN(index_serial), LHASH_COMP_FN(index_serial))) { BIO_printf(bio_err, "error creating serial number index:(%ld,%ld,%ld)\n", db->db->error, db->db->arg1, db->db->arg2); return 0; } if (db->attributes.unique_subject && !TXT_DB_create_index(db->db, DB_name, index_name_qual, LHASH_HASH_FN(index_name), LHASH_COMP_FN(index_name))) { BIO_printf(bio_err, "error creating name index:(%ld,%ld,%ld)\n", db->db->error, db->db->arg1, db->db->arg2); return 0; } return 1; } int save_index(const char *dbfile, const char *suffix, CA_DB *db) { char buf[3][BSIZE]; BIO *out = BIO_new(BIO_s_file()); int j; if (out == NULL) { ERR_print_errors(bio_err); goto err; } j = strlen(dbfile) + strlen(suffix); if (j + 6 >= BSIZE) { BIO_printf(bio_err, "file name too long\n"); goto err; } snprintf(buf[2], sizeof buf[2], "%s.attr", dbfile); snprintf(buf[1], sizeof buf[1], "%s.attr.%s", dbfile, suffix); snprintf(buf[0], sizeof buf[0], "%s.%s", dbfile, suffix); if (BIO_write_filename(out, buf[0]) <= 0) { perror(dbfile); BIO_printf(bio_err, "unable to open '%s'\n", dbfile); goto err; } j = TXT_DB_write(out, db->db); if (j <= 0) goto err; BIO_free(out); out = BIO_new(BIO_s_file()); if (BIO_write_filename(out, buf[1]) <= 0) { perror(buf[2]); BIO_printf(bio_err, "unable to open '%s'\n", buf[2]); goto err; } BIO_printf(out, "unique_subject = %s\n", db->attributes.unique_subject ? "yes" : "no"); BIO_free(out); return 1; err: return 0; } int rotate_index(const char *dbfile, const char *new_suffix, const char *old_suffix) { char buf[5][BSIZE]; int i, j; i = strlen(dbfile) + strlen(old_suffix); j = strlen(dbfile) + strlen(new_suffix); if (i > j) j = i; if (j + 6 >= BSIZE) { BIO_printf(bio_err, "file name too long\n"); goto err; } snprintf(buf[4], sizeof buf[4], "%s.attr", dbfile); snprintf(buf[2], sizeof buf[2], "%s.attr.%s", dbfile, new_suffix); snprintf(buf[0], sizeof buf[0], "%s.%s", dbfile, new_suffix); snprintf(buf[1], sizeof buf[1], "%s.%s", dbfile, old_suffix); snprintf(buf[3], sizeof buf[3], "%s.attr.%s", dbfile, old_suffix); if (rename(dbfile, buf[1]) < 0 && errno != ENOENT && errno != ENOTDIR) { BIO_printf(bio_err, "unable to rename %s to %s\n", dbfile, buf[1]); perror("reason"); goto err; } if (rename(buf[0], dbfile) < 0) { BIO_printf(bio_err, "unable to rename %s to %s\n", buf[0], dbfile); perror("reason"); rename(buf[1], dbfile); goto err; } if (rename(buf[4], buf[3]) < 0 && errno != ENOENT && errno != ENOTDIR) { BIO_printf(bio_err, "unable to rename %s to %s\n", buf[4], buf[3]); perror("reason"); rename(dbfile, buf[0]); rename(buf[1], dbfile); goto err; } if (rename(buf[2], buf[4]) < 0) { BIO_printf(bio_err, "unable to rename %s to %s\n", buf[2], buf[4]); perror("reason"); rename(buf[3], buf[4]); rename(dbfile, buf[0]); rename(buf[1], dbfile); goto err; } return 1; err: return 0; } void free_index(CA_DB *db) { if (db) { if (db->db) TXT_DB_free(db->db); free(db); } } int parse_yesno(const char *str, int def) { int ret = def; if (str) { switch (*str) { case 'f': /* false */ case 'F': /* FALSE */ case 'n': /* no */ case 'N': /* NO */ case '0': /* 0 */ ret = 0; break; case 't': /* true */ case 'T': /* TRUE */ case 'y': /* yes */ case 'Y': /* YES */ case '1': /* 1 */ ret = 1; break; default: ret = def; break; } } return ret; } /* * subject is expected to be in the format /type0=value0/type1=value1/type2=... * where characters may be escaped by \ */ X509_NAME * parse_name(char *subject, long chtype, int multirdn) { X509_NAME *name = NULL; size_t buflen, max_ne; char **ne_types, **ne_values; char *buf, *bp, *sp; int i, nid, ne_num = 0; int *mval; /* * Buffer to copy the types and values into. Due to escaping the * copy can only become shorter. */ buflen = strlen(subject) + 1; buf = malloc(buflen); /* Maximum number of name elements. */ max_ne = buflen / 2 + 1; ne_types = reallocarray(NULL, max_ne, sizeof(char *)); ne_values = reallocarray(NULL, max_ne, sizeof(char *)); mval = reallocarray(NULL, max_ne, sizeof(int)); if (buf == NULL || ne_types == NULL || ne_values == NULL || mval == NULL) { BIO_printf(bio_err, "malloc error\n"); goto error; } bp = buf; sp = subject; if (*subject != '/') { BIO_printf(bio_err, "Subject does not start with '/'.\n"); goto error; } /* Skip leading '/'. */ sp++; /* No multivalued RDN by default. */ mval[ne_num] = 0; while (*sp) { /* Collect type. */ ne_types[ne_num] = bp; while (*sp) { /* is there anything to escape in the type...? */ if (*sp == '\\') { if (*++sp) *bp++ = *sp++; else { BIO_printf(bio_err, "escape character " "at end of string\n"); goto error; } } else if (*sp == '=') { sp++; *bp++ = '\0'; break; } else *bp++ = *sp++; } if (!*sp) { BIO_printf(bio_err, "end of string encountered while " "processing type of subject name element #%d\n", ne_num); goto error; } ne_values[ne_num] = bp; while (*sp) { if (*sp == '\\') { if (*++sp) *bp++ = *sp++; else { BIO_printf(bio_err, "escape character " "at end of string\n"); goto error; } } else if (*sp == '/') { sp++; /* no multivalued RDN by default */ mval[ne_num + 1] = 0; break; } else if (*sp == '+' && multirdn) { /* a not escaped + signals a mutlivalued RDN */ sp++; mval[ne_num + 1] = -1; break; } else *bp++ = *sp++; } *bp++ = '\0'; ne_num++; } if ((name = X509_NAME_new()) == NULL) goto error; for (i = 0; i < ne_num; i++) { if ((nid = OBJ_txt2nid(ne_types[i])) == NID_undef) { BIO_printf(bio_err, "Subject Attribute %s has no known NID, skipped\n", ne_types[i]); continue; } if (!*ne_values[i]) { BIO_printf(bio_err, "No value provided for Subject " "Attribute %s, skipped\n", ne_types[i]); continue; } if (!X509_NAME_add_entry_by_NID(name, nid, chtype, (unsigned char *) ne_values[i], -1, -1, mval[i])) goto error; } goto done; error: X509_NAME_free(name); name = NULL; done: free(ne_values); free(ne_types); free(mval); free(buf); return name; } int args_verify(char ***pargs, int *pargc, int *badarg, BIO *err, X509_VERIFY_PARAM **pm) { ASN1_OBJECT *otmp = NULL; unsigned long flags = 0; int i; int purpose = 0, depth = -1; char **oldargs = *pargs; char *arg = **pargs, *argn = (*pargs)[1]; time_t at_time = 0; const char *errstr = NULL; if (!strcmp(arg, "-policy")) { if (!argn) *badarg = 1; else { otmp = OBJ_txt2obj(argn, 0); if (!otmp) { BIO_printf(err, "Invalid Policy \"%s\"\n", argn); *badarg = 1; } } (*pargs)++; } else if (strcmp(arg, "-purpose") == 0) { X509_PURPOSE *xptmp; if (!argn) *badarg = 1; else { i = X509_PURPOSE_get_by_sname(argn); if (i < 0) { BIO_printf(err, "unrecognized purpose\n"); *badarg = 1; } else { xptmp = X509_PURPOSE_get0(i); purpose = X509_PURPOSE_get_id(xptmp); } } (*pargs)++; } else if (strcmp(arg, "-verify_depth") == 0) { if (!argn) *badarg = 1; else { depth = strtonum(argn, 1, INT_MAX, &errstr); if (errstr) { BIO_printf(err, "invalid depth %s: %s\n", argn, errstr); *badarg = 1; } } (*pargs)++; } else if (strcmp(arg, "-attime") == 0) { if (!argn) *badarg = 1; else { long long timestamp; /* * interpret the -attime argument as seconds since * Epoch */ if (sscanf(argn, "%lli", ×tamp) != 1) { BIO_printf(bio_err, "Error parsing timestamp %s\n", argn); *badarg = 1; } /* XXX 2038 truncation */ at_time = (time_t) timestamp; } (*pargs)++; } else if (!strcmp(arg, "-ignore_critical")) flags |= X509_V_FLAG_IGNORE_CRITICAL; else if (!strcmp(arg, "-issuer_checks")) flags |= X509_V_FLAG_CB_ISSUER_CHECK; else if (!strcmp(arg, "-crl_check")) flags |= X509_V_FLAG_CRL_CHECK; else if (!strcmp(arg, "-crl_check_all")) flags |= X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL; else if (!strcmp(arg, "-policy_check")) flags |= X509_V_FLAG_POLICY_CHECK; else if (!strcmp(arg, "-explicit_policy")) flags |= X509_V_FLAG_EXPLICIT_POLICY; else if (!strcmp(arg, "-inhibit_any")) flags |= X509_V_FLAG_INHIBIT_ANY; else if (!strcmp(arg, "-inhibit_map")) flags |= X509_V_FLAG_INHIBIT_MAP; else if (!strcmp(arg, "-x509_strict")) flags |= X509_V_FLAG_X509_STRICT; else if (!strcmp(arg, "-extended_crl")) flags |= X509_V_FLAG_EXTENDED_CRL_SUPPORT; else if (!strcmp(arg, "-use_deltas")) flags |= X509_V_FLAG_USE_DELTAS; else if (!strcmp(arg, "-policy_print")) flags |= X509_V_FLAG_NOTIFY_POLICY; else if (!strcmp(arg, "-check_ss_sig")) flags |= X509_V_FLAG_CHECK_SS_SIGNATURE; else return 0; if (*badarg) { if (*pm) X509_VERIFY_PARAM_free(*pm); *pm = NULL; goto end; } if (!*pm && !(*pm = X509_VERIFY_PARAM_new())) { *badarg = 1; goto end; } if (otmp) X509_VERIFY_PARAM_add0_policy(*pm, otmp); if (flags) X509_VERIFY_PARAM_set_flags(*pm, flags); if (purpose) X509_VERIFY_PARAM_set_purpose(*pm, purpose); if (depth >= 0) X509_VERIFY_PARAM_set_depth(*pm, depth); if (at_time) X509_VERIFY_PARAM_set_time(*pm, at_time); end: (*pargs)++; if (pargc) *pargc -= *pargs - oldargs; return 1; } /* Read whole contents of a BIO into an allocated memory buffer and * return it. */ int bio_to_mem(unsigned char **out, int maxlen, BIO *in) { BIO *mem; int len, ret; unsigned char tbuf[1024]; mem = BIO_new(BIO_s_mem()); if (!mem) return -1; for (;;) { if ((maxlen != -1) && maxlen < 1024) len = maxlen; else len = 1024; len = BIO_read(in, tbuf, len); if (len <= 0) break; if (BIO_write(mem, tbuf, len) != len) { BIO_free(mem); return -1; } maxlen -= len; if (maxlen == 0) break; } ret = BIO_get_mem_data(mem, (char **) out); BIO_set_flags(mem, BIO_FLAGS_MEM_RDONLY); BIO_free(mem); return ret; } int pkey_ctrl_string(EVP_PKEY_CTX *ctx, char *value) { int rv; char *stmp, *vtmp = NULL; stmp = BUF_strdup(value); if (!stmp) return -1; vtmp = strchr(stmp, ':'); if (vtmp) { *vtmp = 0; vtmp++; } rv = EVP_PKEY_CTX_ctrl_str(ctx, stmp, vtmp); free(stmp); return rv; } static void nodes_print(BIO *out, const char *name, STACK_OF(X509_POLICY_NODE) *nodes) { X509_POLICY_NODE *node; int i; BIO_printf(out, "%s Policies:", name); if (nodes) { BIO_puts(out, "\n"); for (i = 0; i < sk_X509_POLICY_NODE_num(nodes); i++) { node = sk_X509_POLICY_NODE_value(nodes, i); X509_POLICY_NODE_print(out, node, 2); } } else BIO_puts(out, " \n"); } void policies_print(BIO *out, X509_STORE_CTX *ctx) { X509_POLICY_TREE *tree; int explicit_policy; int free_out = 0; if (out == NULL) { out = BIO_new_fp(stderr, BIO_NOCLOSE); free_out = 1; } tree = X509_STORE_CTX_get0_policy_tree(ctx); explicit_policy = X509_STORE_CTX_get_explicit_policy(ctx); BIO_printf(out, "Require explicit Policy: %s\n", explicit_policy ? "True" : "False"); nodes_print(out, "Authority", X509_policy_tree_get0_policies(tree)); nodes_print(out, "User", X509_policy_tree_get0_user_policies(tree)); if (free_out) BIO_free(out); } #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) /* next_protos_parse parses a comma separated list of strings into a string * in a format suitable for passing to SSL_CTX_set_next_protos_advertised. * outlen: (output) set to the length of the resulting buffer on success. * err: (maybe NULL) on failure, an error message line is written to this BIO. * in: a NUL termianted string like "abc,def,ghi" * * returns: a malloced buffer or NULL on failure. */ unsigned char * next_protos_parse(unsigned short *outlen, const char *in) { size_t len; unsigned char *out; size_t i, start = 0; len = strlen(in); if (len >= 65535) return NULL; out = malloc(strlen(in) + 1); if (!out) return NULL; for (i = 0; i <= len; ++i) { if (i == len || in[i] == ',') { if (i - start > 255) { free(out); return NULL; } out[start] = i - start; start = i + 1; } else out[i + 1] = in[i]; } *outlen = len + 1; return out; } #endif /* !OPENSSL_NO_TLSEXT && !OPENSSL_NO_NEXTPROTONEG */ double app_tminterval(int stop, int usertime) { double ret = 0; struct tms rus; clock_t now = times(&rus); static clock_t tmstart; if (usertime) now = rus.tms_utime; if (stop == TM_START) tmstart = now; else { long int tck = sysconf(_SC_CLK_TCK); ret = (now - tmstart) / (double) tck; } return (ret); } int app_isdir(const char *name) { struct stat st; if (stat(name, &st) == 0) return S_ISDIR(st.st_mode); return -1; } deps/libressl-pnacl-sys-2.1.6/libressl/apps/gendsa.c0000644000175000017500000001652012360020706017310 0ustar /* $OpenBSD: gendsa.c,v 1.27 2014/06/12 15:49:27 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include /* for OPENSSL_NO_DSA */ #include #include #include #include #include "apps.h" #include #include #include #include #include #include #define DEFBITS 512 int gendsa_main(int, char **); int gendsa_main(int argc, char **argv) { DSA *dsa = NULL; int ret = 1; char *outfile = NULL; char *dsaparams = NULL; char *passargout = NULL, *passout = NULL; BIO *out = NULL, *in = NULL; const EVP_CIPHER *enc = NULL; #ifndef OPENSSL_NO_ENGINE char *engine = NULL; #endif if (!load_config(bio_err, NULL)) goto end; argv++; argc--; for (;;) { if (argc <= 0) break; if (strcmp(*argv, "-out") == 0) { if (--argc < 1) goto bad; outfile = *(++argv); } else if (strcmp(*argv, "-passout") == 0) { if (--argc < 1) goto bad; passargout = *(++argv); } #ifndef OPENSSL_NO_ENGINE else if (strcmp(*argv, "-engine") == 0) { if (--argc < 1) goto bad; engine = *(++argv); } #endif else if (strcmp(*argv, "-") == 0) goto bad; #ifndef OPENSSL_NO_DES else if (strcmp(*argv, "-des") == 0) enc = EVP_des_cbc(); else if (strcmp(*argv, "-des3") == 0) enc = EVP_des_ede3_cbc(); #endif #ifndef OPENSSL_NO_IDEA else if (strcmp(*argv, "-idea") == 0) enc = EVP_idea_cbc(); #endif #ifndef OPENSSL_NO_AES else if (strcmp(*argv, "-aes128") == 0) enc = EVP_aes_128_cbc(); else if (strcmp(*argv, "-aes192") == 0) enc = EVP_aes_192_cbc(); else if (strcmp(*argv, "-aes256") == 0) enc = EVP_aes_256_cbc(); #endif #ifndef OPENSSL_NO_CAMELLIA else if (strcmp(*argv, "-camellia128") == 0) enc = EVP_camellia_128_cbc(); else if (strcmp(*argv, "-camellia192") == 0) enc = EVP_camellia_192_cbc(); else if (strcmp(*argv, "-camellia256") == 0) enc = EVP_camellia_256_cbc(); #endif else if (**argv != '-' && dsaparams == NULL) { dsaparams = *argv; } else goto bad; argv++; argc--; } if (dsaparams == NULL) { bad: BIO_printf(bio_err, "usage: gendsa [args] dsaparam-file\n"); BIO_printf(bio_err, " -out file - output the key to 'file'\n"); #ifndef OPENSSL_NO_DES BIO_printf(bio_err, " -des - encrypt the generated key with DES in cbc mode\n"); BIO_printf(bio_err, " -des3 - encrypt the generated key with DES in ede cbc mode (168 bit key)\n"); #endif #ifndef OPENSSL_NO_IDEA BIO_printf(bio_err, " -idea - encrypt the generated key with IDEA in cbc mode\n"); #endif #ifndef OPENSSL_NO_AES BIO_printf(bio_err, " -aes128, -aes192, -aes256\n"); BIO_printf(bio_err, " encrypt PEM output with cbc aes\n"); #endif #ifndef OPENSSL_NO_CAMELLIA BIO_printf(bio_err, " -camellia128, -camellia192, -camellia256\n"); BIO_printf(bio_err, " encrypt PEM output with cbc camellia\n"); #endif #ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err, " -engine e - use engine e, possibly a hardware device.\n"); #endif BIO_printf(bio_err, " dsaparam-file\n"); BIO_printf(bio_err, " - a DSA parameter file as generated by the dsaparam command\n"); goto end; } #ifndef OPENSSL_NO_ENGINE setup_engine(bio_err, engine, 0); #endif if (!app_passwd(bio_err, NULL, passargout, NULL, &passout)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } in = BIO_new(BIO_s_file()); if (!(BIO_read_filename(in, dsaparams))) { perror(dsaparams); goto end; } if ((dsa = PEM_read_bio_DSAparams(in, NULL, NULL, NULL)) == NULL) { BIO_printf(bio_err, "unable to load DSA parameter file\n"); goto end; } BIO_free(in); in = NULL; out = BIO_new(BIO_s_file()); if (out == NULL) goto end; if (outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { if (BIO_write_filename(out, outfile) <= 0) { perror(outfile); goto end; } } BIO_printf(bio_err, "Generating DSA key, %d bits\n", BN_num_bits(dsa->p)); if (!DSA_generate_key(dsa)) goto end; if (!PEM_write_bio_DSAPrivateKey(out, dsa, enc, NULL, 0, NULL, passout)) goto end; ret = 0; end: if (ret != 0) ERR_print_errors(bio_err); if (in != NULL) BIO_free(in); if (out != NULL) BIO_free_all(out); if (dsa != NULL) DSA_free(dsa); free(passout); return (ret); } deps/libressl-pnacl-sys-2.1.6/libressl/apps/s_server.c0000644000175000017500000017107012360020706017701 0ustar /* $OpenBSD: s_server.c,v 1.57 2014/07/10 08:59:15 bcook Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 THE OpenSSL PROJECT OR * ITS CONTRIBUTORS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * ECC cipher suite support in OpenSSL originally developed by * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. */ /* ==================================================================== * Copyright 2005 Nokia. All rights reserved. * * The portions of the attached software ("Contribution") is developed by * Nokia Corporation and is licensed pursuant to the OpenSSL open source * license. * * The Contribution, originally written by Mika Kousa and Pasi Eronen of * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites * support (see RFC 4279) to OpenSSL. * * No patent licenses or other rights except those expressly stated in * the OpenSSL open source license shall be deemed granted or received * expressly, by implication, estoppel, or otherwise. * * No assurances are provided by Nokia that the Contribution does not * infringe the patent or other intellectual property rights of any third * party or that the license provides you with all the necessary rights * to make use of the Contribution. * * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR * OTHERWISE. */ /* Until the key-gen callbacks are modified to use newer prototypes, we allow * deprecated functions for openssl-internal code */ #ifdef OPENSSL_NO_DEPRECATED #undef OPENSSL_NO_DEPRECATED #endif #include #include #include #include #include #include #include #include #include #include #include "apps.h" #include #include #include #include #include #include #include #include #ifndef OPENSSL_NO_DH #include #endif #include #include "s_apps.h" #include "timeouts.h" static RSA *tmp_rsa_cb(SSL * s, int is_export, int keylength); static int sv_body(char *hostname, int s, unsigned char *context); static int www_body(char *hostname, int s, unsigned char *context); static void close_accept_socket(void); static void sv_usage(void); static int init_ssl_connection(SSL * s); static void print_stats(BIO * bp, SSL_CTX * ctx); static int generate_session_id(const SSL * ssl, unsigned char *id, unsigned int *id_len); #ifndef OPENSSL_NO_DH static DH *load_dh_param(const char *dhfile); static DH *get_dh512(void); #endif static void s_server_init(void); #ifndef OPENSSL_NO_DH static unsigned char dh512_p[] = { 0xDA, 0x58, 0x3C, 0x16, 0xD9, 0x85, 0x22, 0x89, 0xD0, 0xE4, 0xAF, 0x75, 0x6F, 0x4C, 0xCA, 0x92, 0xDD, 0x4B, 0xE5, 0x33, 0xB8, 0x04, 0xFB, 0x0F, 0xED, 0x94, 0xEF, 0x9C, 0x8A, 0x44, 0x03, 0xED, 0x57, 0x46, 0x50, 0xD3, 0x69, 0x99, 0xDB, 0x29, 0xD7, 0x76, 0x27, 0x6B, 0xA2, 0xD3, 0xD4, 0x12, 0xE2, 0x18, 0xF4, 0xDD, 0x1E, 0x08, 0x4C, 0xF6, 0xD8, 0x00, 0x3E, 0x7C, 0x47, 0x74, 0xE8, 0x33, }; static unsigned char dh512_g[] = { 0x02, }; static DH * get_dh512(void) { DH *dh = NULL; if ((dh = DH_new()) == NULL) return (NULL); dh->p = BN_bin2bn(dh512_p, sizeof(dh512_p), NULL); dh->g = BN_bin2bn(dh512_g, sizeof(dh512_g), NULL); if ((dh->p == NULL) || (dh->g == NULL)) return (NULL); return (dh); } #endif /* static int load_CA(SSL_CTX *ctx, char *file);*/ #define BUFSIZZ 16*1024 static int bufsize = BUFSIZZ; static int accept_socket = -1; #define TEST_CERT "server.pem" #ifndef OPENSSL_NO_TLSEXT #define TEST_CERT2 "server2.pem" #endif extern int verify_depth, verify_return_error; static char *cipher = NULL; static int s_server_verify = SSL_VERIFY_NONE; static int s_server_session_id_context = 1; /* anything will do */ static const char *s_cert_file = TEST_CERT, *s_key_file = NULL; #ifndef OPENSSL_NO_TLSEXT static const char *s_cert_file2 = TEST_CERT2, *s_key_file2 = NULL; #endif static char *s_dcert_file = NULL, *s_dkey_file = NULL; static int s_nbio = 0; static int s_nbio_test = 0; int s_crlf = 0; static SSL_CTX *ctx = NULL; #ifndef OPENSSL_NO_TLSEXT static SSL_CTX *ctx2 = NULL; #endif static int www = 0; static BIO *bio_s_out = NULL; static int s_debug = 0; #ifndef OPENSSL_NO_TLSEXT static int s_tlsextdebug = 0; static int s_tlsextstatus = 0; static int cert_status_cb(SSL * s, void *arg); #endif static int s_msg = 0; static int s_quiet = 0; static char *keymatexportlabel = NULL; static int keymatexportlen = 20; static int hack = 0; #ifndef OPENSSL_NO_ENGINE static char *engine_id = NULL; #endif static const char *session_id_prefix = NULL; static int enable_timeouts = 0; static long socket_mtu; #ifndef OPENSSL_NO_DTLS1 static int cert_chain = 0; #endif static void s_server_init(void) { accept_socket = -1; cipher = NULL; s_server_verify = SSL_VERIFY_NONE; s_dcert_file = NULL; s_dkey_file = NULL; s_cert_file = TEST_CERT; s_key_file = NULL; #ifndef OPENSSL_NO_TLSEXT s_cert_file2 = TEST_CERT2; s_key_file2 = NULL; ctx2 = NULL; #endif s_nbio = 0; s_nbio_test = 0; ctx = NULL; www = 0; bio_s_out = NULL; s_debug = 0; s_msg = 0; s_quiet = 0; hack = 0; #ifndef OPENSSL_NO_ENGINE engine_id = NULL; #endif } static void sv_usage(void) { BIO_printf(bio_err, "usage: s_server [args ...]\n"); BIO_printf(bio_err, "\n"); BIO_printf(bio_err, " -accept arg - port to accept on (default is %d)\n", PORT); BIO_printf(bio_err, " -context arg - set session ID context\n"); BIO_printf(bio_err, " -verify arg - turn on peer certificate verification\n"); BIO_printf(bio_err, " -Verify arg - turn on peer certificate verification, must have a cert.\n"); BIO_printf(bio_err, " -cert arg - certificate file to use\n"); BIO_printf(bio_err, " (default is %s)\n", TEST_CERT); BIO_printf(bio_err, " -crl_check - check the peer certificate has not been revoked by its CA.\n" \ " The CRL(s) are appended to the certificate file\n"); BIO_printf(bio_err, " -crl_check_all - check the peer certificate has not been revoked by its CA\n" \ " or any other CRL in the CA chain. CRL(s) are appended to the\n" \ " the certificate file.\n"); BIO_printf(bio_err, " -certform arg - certificate format (PEM or DER) PEM default\n"); BIO_printf(bio_err, " -key arg - Private Key file to use, in cert file if\n"); BIO_printf(bio_err, " not specified (default is %s)\n", TEST_CERT); BIO_printf(bio_err, " -keyform arg - key format (PEM, DER or ENGINE) PEM default\n"); BIO_printf(bio_err, " -pass arg - private key file pass phrase source\n"); BIO_printf(bio_err, " -dcert arg - second certificate file to use (usually for DSA)\n"); BIO_printf(bio_err, " -dcertform x - second certificate format (PEM or DER) PEM default\n"); BIO_printf(bio_err, " -dkey arg - second private key file to use (usually for DSA)\n"); BIO_printf(bio_err, " -dkeyform arg - second key format (PEM, DER or ENGINE) PEM default\n"); BIO_printf(bio_err, " -dpass arg - second private key file pass phrase source\n"); BIO_printf(bio_err, " -dhparam arg - DH parameter file to use, in cert file if not specified\n"); BIO_printf(bio_err, " or a default set of parameters is used\n"); BIO_printf(bio_err, " -named_curve arg - Elliptic curve name to use for ephemeral ECDH keys.\n" \ " Use \"openssl ecparam -list_curves\" for all names\n" \ " (default is nistp256).\n"); BIO_printf(bio_err, " -nbio - Run with non-blocking IO\n"); BIO_printf(bio_err, " -nbio_test - test with the non-blocking test bio\n"); BIO_printf(bio_err, " -crlf - convert LF from terminal into CRLF\n"); BIO_printf(bio_err, " -debug - Print more output\n"); BIO_printf(bio_err, " -msg - Show protocol messages\n"); BIO_printf(bio_err, " -state - Print the SSL states\n"); BIO_printf(bio_err, " -CApath arg - PEM format directory of CA's\n"); BIO_printf(bio_err, " -CAfile arg - PEM format file of CA's\n"); BIO_printf(bio_err, " -nocert - Don't use any certificates (Anon-DH)\n"); BIO_printf(bio_err, " -cipher arg - play with 'openssl ciphers' to see what goes here\n"); BIO_printf(bio_err, " -serverpref - Use server's cipher preferences\n"); BIO_printf(bio_err, " -quiet - Inhibit printing of session and certificate information\n"); BIO_printf(bio_err, " -no_tmp_rsa - Do not generate a tmp RSA key\n"); BIO_printf(bio_err, " -ssl3 - Just talk SSLv3\n"); BIO_printf(bio_err, " -tls1_2 - Just talk TLSv1.2\n"); BIO_printf(bio_err, " -tls1_1 - Just talk TLSv1.1\n"); BIO_printf(bio_err, " -tls1 - Just talk TLSv1\n"); BIO_printf(bio_err, " -dtls1 - Just talk DTLSv1\n"); BIO_printf(bio_err, " -timeout - Enable timeouts\n"); BIO_printf(bio_err, " -mtu - Set link layer MTU\n"); BIO_printf(bio_err, " -chain - Read a certificate chain\n"); BIO_printf(bio_err, " -no_ssl2 - Just disable SSLv2\n"); BIO_printf(bio_err, " -no_ssl3 - Just disable SSLv3\n"); BIO_printf(bio_err, " -no_tls1 - Just disable TLSv1\n"); BIO_printf(bio_err, " -no_tls1_1 - Just disable TLSv1.1\n"); BIO_printf(bio_err, " -no_tls1_2 - Just disable TLSv1.2\n"); #ifndef OPENSSL_NO_DH BIO_printf(bio_err, " -no_dhe - Disable ephemeral DH\n"); #endif BIO_printf(bio_err, " -no_ecdhe - Disable ephemeral ECDH\n"); BIO_printf(bio_err, " -bugs - Turn on SSL bug compatibility\n"); BIO_printf(bio_err, " -www - Respond to a 'GET /' with a status page\n"); BIO_printf(bio_err, " -WWW - Respond to a 'GET / HTTP/1.0' with file ./\n"); BIO_printf(bio_err, " -HTTP - Respond to a 'GET / HTTP/1.0' with file ./\n"); BIO_printf(bio_err, " with the assumption it contains a complete HTTP response.\n"); #ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err, " -engine id - Initialise and use the specified engine\n"); #endif BIO_printf(bio_err, " -id_prefix arg - Generate SSL/TLS session IDs prefixed by 'arg'\n"); #ifndef OPENSSL_NO_TLSEXT BIO_printf(bio_err, " -servername host - servername for HostName TLS extension\n"); BIO_printf(bio_err, " -servername_fatal - on mismatch send fatal alert (default warning alert)\n"); BIO_printf(bio_err, " -cert2 arg - certificate file to use for servername\n"); BIO_printf(bio_err, " (default is %s)\n", TEST_CERT2); BIO_printf(bio_err, " -key2 arg - Private Key file to use for servername, in cert file if\n"); BIO_printf(bio_err, " not specified (default is %s)\n", TEST_CERT2); BIO_printf(bio_err, " -tlsextdebug - hex dump of all TLS extensions received\n"); BIO_printf(bio_err, " -no_ticket - disable use of RFC4507bis session tickets\n"); #ifndef OPENSSL_NO_NEXTPROTONEG BIO_printf(bio_err, " -nextprotoneg arg - set the advertised protocols for the NPN extension (comma-separated list)\n"); #endif #ifndef OPENSSL_NO_SRTP BIO_printf(bio_err, " -use_srtp profiles - Offer SRTP key management with a colon-separated profile list\n"); #endif #endif BIO_printf(bio_err, " -keymatexport label - Export keying material using label\n"); BIO_printf(bio_err, " -keymatexportlen len - Export len bytes of keying material (default 20)\n"); } static int local_argc = 0; static char **local_argv; #ifndef OPENSSL_NO_TLSEXT /* This is a context that we pass to callbacks */ typedef struct tlsextctx_st { char *servername; BIO *biodebug; int extension_error; } tlsextctx; static int ssl_servername_cb(SSL * s, int *ad, void *arg) { tlsextctx *p = (tlsextctx *) arg; const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name); if (servername && p->biodebug) BIO_printf(p->biodebug, "Hostname in TLS extension: \"%s\"\n", servername); if (!p->servername) return SSL_TLSEXT_ERR_NOACK; if (servername) { if (strcmp(servername, p->servername)) return p->extension_error; if (ctx2) { BIO_printf(p->biodebug, "Switching server context.\n"); SSL_set_SSL_CTX(s, ctx2); } } return SSL_TLSEXT_ERR_OK; } /* Structure passed to cert status callback */ typedef struct tlsextstatusctx_st { /* Default responder to use */ char *host, *path, *port; int use_ssl; int timeout; BIO *err; int verbose; } tlsextstatusctx; static tlsextstatusctx tlscstatp = {NULL, NULL, NULL, 0, -1, NULL, 0}; /* Certificate Status callback. This is called when a client includes a * certificate status request extension. * * This is a simplified version. It examines certificates each time and * makes one OCSP responder query for each request. * * A full version would store details such as the OCSP certificate IDs and * minimise the number of OCSP responses by caching them until they were * considered "expired". */ static int cert_status_cb(SSL * s, void *arg) { tlsextstatusctx *srctx = arg; BIO *err = srctx->err; char *host, *port, *path; int use_ssl; unsigned char *rspder = NULL; int rspderlen; STACK_OF(OPENSSL_STRING) * aia = NULL; X509 *x = NULL; X509_STORE_CTX inctx; X509_OBJECT obj; OCSP_REQUEST *req = NULL; OCSP_RESPONSE *resp = NULL; OCSP_CERTID *id = NULL; STACK_OF(X509_EXTENSION) * exts; int ret = SSL_TLSEXT_ERR_NOACK; int i; if (srctx->verbose) BIO_puts(err, "cert_status: callback called\n"); /* Build up OCSP query from server certificate */ x = SSL_get_certificate(s); aia = X509_get1_ocsp(x); if (aia) { if (!OCSP_parse_url(sk_OPENSSL_STRING_value(aia, 0), &host, &port, &path, &use_ssl)) { BIO_puts(err, "cert_status: can't parse AIA URL\n"); goto err; } if (srctx->verbose) BIO_printf(err, "cert_status: AIA URL: %s\n", sk_OPENSSL_STRING_value(aia, 0)); } else { if (!srctx->host) { BIO_puts(srctx->err, "cert_status: no AIA and no default responder URL\n"); goto done; } host = srctx->host; path = srctx->path; port = srctx->port; use_ssl = srctx->use_ssl; } if (!X509_STORE_CTX_init(&inctx, SSL_CTX_get_cert_store(SSL_get_SSL_CTX(s)), NULL, NULL)) goto err; if (X509_STORE_get_by_subject(&inctx, X509_LU_X509, X509_get_issuer_name(x), &obj) <= 0) { BIO_puts(err, "cert_status: Can't retrieve issuer certificate.\n"); X509_STORE_CTX_cleanup(&inctx); goto done; } req = OCSP_REQUEST_new(); if (!req) goto err; id = OCSP_cert_to_id(NULL, x, obj.data.x509); X509_free(obj.data.x509); X509_STORE_CTX_cleanup(&inctx); if (!id) goto err; if (!OCSP_request_add0_id(req, id)) goto err; id = NULL; /* Add any extensions to the request */ SSL_get_tlsext_status_exts(s, &exts); for (i = 0; i < sk_X509_EXTENSION_num(exts); i++) { X509_EXTENSION *ext = sk_X509_EXTENSION_value(exts, i); if (!OCSP_REQUEST_add_ext(req, ext, -1)) goto err; } resp = process_responder(err, req, host, path, port, use_ssl, NULL, srctx->timeout); if (!resp) { BIO_puts(err, "cert_status: error querying responder\n"); goto done; } rspderlen = i2d_OCSP_RESPONSE(resp, &rspder); if (rspderlen <= 0) goto err; SSL_set_tlsext_status_ocsp_resp(s, rspder, rspderlen); if (srctx->verbose) { BIO_puts(err, "cert_status: ocsp response sent:\n"); OCSP_RESPONSE_print(err, resp, 2); } ret = SSL_TLSEXT_ERR_OK; done: if (ret != SSL_TLSEXT_ERR_OK) ERR_print_errors(err); if (aia) { free(host); free(path); free(port); X509_email_free(aia); } if (id) OCSP_CERTID_free(id); if (req) OCSP_REQUEST_free(req); if (resp) OCSP_RESPONSE_free(resp); return ret; err: ret = SSL_TLSEXT_ERR_ALERT_FATAL; goto done; } #ifndef OPENSSL_NO_NEXTPROTONEG /* This is the context that we pass to next_proto_cb */ typedef struct tlsextnextprotoctx_st { unsigned char *data; unsigned int len; } tlsextnextprotoctx; static int next_proto_cb(SSL * s, const unsigned char **data, unsigned int *len, void *arg) { tlsextnextprotoctx *next_proto = arg; *data = next_proto->data; *len = next_proto->len; return SSL_TLSEXT_ERR_OK; } #endif /* ndef OPENSSL_NO_NEXTPROTONEG */ #endif int s_server_main(int, char **); #ifndef OPENSSL_NO_SRTP static char *srtp_profiles = NULL; #endif int s_server_main(int argc, char *argv[]) { X509_VERIFY_PARAM *vpm = NULL; int badarg = 0; short port = PORT; char *CApath = NULL, *CAfile = NULL; unsigned char *context = NULL; char *dhfile = NULL; char *named_curve = NULL; int badop = 0, bugs = 0; int ret = 1; int off = 0; int no_tmp_rsa = 0, no_dhe = 0, no_ecdhe = 0, nocert = 0; int state = 0; const SSL_METHOD *meth = NULL; int socket_type = SOCK_STREAM; ENGINE *e = NULL; int s_cert_format = FORMAT_PEM, s_key_format = FORMAT_PEM; char *passarg = NULL, *pass = NULL; char *dpassarg = NULL, *dpass = NULL; int s_dcert_format = FORMAT_PEM, s_dkey_format = FORMAT_PEM; X509 *s_cert = NULL, *s_dcert = NULL; EVP_PKEY *s_key = NULL, *s_dkey = NULL; int no_cache = 0; const char *errstr = NULL; #ifndef OPENSSL_NO_TLSEXT EVP_PKEY *s_key2 = NULL; X509 *s_cert2 = NULL; tlsextctx tlsextcbp = {NULL, NULL, SSL_TLSEXT_ERR_ALERT_WARNING}; #ifndef OPENSSL_NO_NEXTPROTONEG const char *next_proto_neg_in = NULL; tlsextnextprotoctx next_proto; #endif #endif meth = SSLv23_server_method(); local_argc = argc; local_argv = argv; s_server_init(); if (!load_config(bio_err, NULL)) goto end; verify_depth = 0; s_nbio = 0; s_nbio_test = 0; argc--; argv++; while (argc >= 1) { if ((strcmp(*argv, "-port") == 0) || (strcmp(*argv, "-accept") == 0)) { if (--argc < 1) goto bad; if (!extract_port(*(++argv), &port)) goto bad; } else if (strcmp(*argv, "-verify") == 0) { s_server_verify = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE; if (--argc < 1) goto bad; verify_depth = strtonum(*(++argv), 0, INT_MAX, &errstr); if (errstr) goto bad; BIO_printf(bio_err, "verify depth is %d\n", verify_depth); } else if (strcmp(*argv, "-Verify") == 0) { s_server_verify = SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT | SSL_VERIFY_CLIENT_ONCE; if (--argc < 1) goto bad; verify_depth = strtonum(*(++argv), 0, INT_MAX, &errstr); if (errstr) goto bad; BIO_printf(bio_err, "verify depth is %d, must return a certificate\n", verify_depth); } else if (strcmp(*argv, "-context") == 0) { if (--argc < 1) goto bad; context = (unsigned char *) *(++argv); } else if (strcmp(*argv, "-cert") == 0) { if (--argc < 1) goto bad; s_cert_file = *(++argv); } else if (strcmp(*argv, "-certform") == 0) { if (--argc < 1) goto bad; s_cert_format = str2fmt(*(++argv)); } else if (strcmp(*argv, "-key") == 0) { if (--argc < 1) goto bad; s_key_file = *(++argv); } else if (strcmp(*argv, "-keyform") == 0) { if (--argc < 1) goto bad; s_key_format = str2fmt(*(++argv)); } else if (strcmp(*argv, "-pass") == 0) { if (--argc < 1) goto bad; passarg = *(++argv); } else if (strcmp(*argv, "-dhparam") == 0) { if (--argc < 1) goto bad; dhfile = *(++argv); } else if (strcmp(*argv, "-named_curve") == 0) { if (--argc < 1) goto bad; named_curve = *(++argv); } else if (strcmp(*argv, "-dcertform") == 0) { if (--argc < 1) goto bad; s_dcert_format = str2fmt(*(++argv)); } else if (strcmp(*argv, "-dcert") == 0) { if (--argc < 1) goto bad; s_dcert_file = *(++argv); } else if (strcmp(*argv, "-dkeyform") == 0) { if (--argc < 1) goto bad; s_dkey_format = str2fmt(*(++argv)); } else if (strcmp(*argv, "-dpass") == 0) { if (--argc < 1) goto bad; dpassarg = *(++argv); } else if (strcmp(*argv, "-dkey") == 0) { if (--argc < 1) goto bad; s_dkey_file = *(++argv); } else if (strcmp(*argv, "-nocert") == 0) { nocert = 1; } else if (strcmp(*argv, "-CApath") == 0) { if (--argc < 1) goto bad; CApath = *(++argv); } else if (strcmp(*argv, "-no_cache") == 0) no_cache = 1; else if (args_verify(&argv, &argc, &badarg, bio_err, &vpm)) { if (badarg) goto bad; continue; } else if (strcmp(*argv, "-verify_return_error") == 0) verify_return_error = 1; else if (strcmp(*argv, "-serverpref") == 0) { off |= SSL_OP_CIPHER_SERVER_PREFERENCE; } else if (strcmp(*argv, "-legacy_renegotiation") == 0) ; /* no-op */ else if (strcmp(*argv, "-cipher") == 0) { if (--argc < 1) goto bad; cipher = *(++argv); } else if (strcmp(*argv, "-CAfile") == 0) { if (--argc < 1) goto bad; CAfile = *(++argv); } else if (strcmp(*argv, "-nbio") == 0) { s_nbio = 1; } else if (strcmp(*argv, "-nbio_test") == 0) { s_nbio = 1; s_nbio_test = 1; } else if (strcmp(*argv, "-debug") == 0) { s_debug = 1; } #ifndef OPENSSL_NO_TLSEXT else if (strcmp(*argv, "-tlsextdebug") == 0) s_tlsextdebug = 1; else if (strcmp(*argv, "-status") == 0) s_tlsextstatus = 1; else if (strcmp(*argv, "-status_verbose") == 0) { s_tlsextstatus = 1; tlscstatp.verbose = 1; } else if (!strcmp(*argv, "-status_timeout")) { s_tlsextstatus = 1; if (--argc < 1) goto bad; tlscstatp.timeout = strtonum(*(++argv), 0, INT_MAX, &errstr); if (errstr) goto bad; } else if (!strcmp(*argv, "-status_url")) { s_tlsextstatus = 1; if (--argc < 1) goto bad; if (!OCSP_parse_url(*(++argv), &tlscstatp.host, &tlscstatp.port, &tlscstatp.path, &tlscstatp.use_ssl)) { BIO_printf(bio_err, "Error parsing URL\n"); goto bad; } } #endif else if (strcmp(*argv, "-msg") == 0) { s_msg = 1; } else if (strcmp(*argv, "-hack") == 0) { hack = 1; } else if (strcmp(*argv, "-state") == 0) { state = 1; } else if (strcmp(*argv, "-crlf") == 0) { s_crlf = 1; } else if (strcmp(*argv, "-quiet") == 0) { s_quiet = 1; } else if (strcmp(*argv, "-bugs") == 0) { bugs = 1; } else if (strcmp(*argv, "-no_tmp_rsa") == 0) { no_tmp_rsa = 1; } else if (strcmp(*argv, "-no_dhe") == 0) { no_dhe = 1; } else if (strcmp(*argv, "-no_ecdhe") == 0) { no_ecdhe = 1; } else if (strcmp(*argv, "-www") == 0) { www = 1; } else if (strcmp(*argv, "-WWW") == 0) { www = 2; } else if (strcmp(*argv, "-HTTP") == 0) { www = 3; } else if (strcmp(*argv, "-no_ssl2") == 0) { off |= SSL_OP_NO_SSLv2; } else if (strcmp(*argv, "-no_ssl3") == 0) { off |= SSL_OP_NO_SSLv3; } else if (strcmp(*argv, "-no_tls1") == 0) { off |= SSL_OP_NO_TLSv1; } else if (strcmp(*argv, "-no_tls1_1") == 0) { off |= SSL_OP_NO_TLSv1_1; } else if (strcmp(*argv, "-no_tls1_2") == 0) { off |= SSL_OP_NO_TLSv1_2; } else if (strcmp(*argv, "-no_comp") == 0) { off |= SSL_OP_NO_COMPRESSION; } #ifndef OPENSSL_NO_TLSEXT else if (strcmp(*argv, "-no_ticket") == 0) { off |= SSL_OP_NO_TICKET; } #endif else if (strcmp(*argv, "-ssl3") == 0) { meth = SSLv3_server_method(); } else if (strcmp(*argv, "-tls1") == 0) { meth = TLSv1_server_method(); } else if (strcmp(*argv, "-tls1_1") == 0) { meth = TLSv1_1_server_method(); } else if (strcmp(*argv, "-tls1_2") == 0) { meth = TLSv1_2_server_method(); } #ifndef OPENSSL_NO_DTLS1 else if (strcmp(*argv, "-dtls1") == 0) { meth = DTLSv1_server_method(); socket_type = SOCK_DGRAM; } else if (strcmp(*argv, "-timeout") == 0) enable_timeouts = 1; else if (strcmp(*argv, "-mtu") == 0) { if (--argc < 1) goto bad; socket_mtu = strtonum(*(++argv), 0, LONG_MAX, &errstr); if (errstr) goto bad; } else if (strcmp(*argv, "-chain") == 0) cert_chain = 1; #endif else if (strcmp(*argv, "-id_prefix") == 0) { if (--argc < 1) goto bad; session_id_prefix = *(++argv); } #ifndef OPENSSL_NO_ENGINE else if (strcmp(*argv, "-engine") == 0) { if (--argc < 1) goto bad; engine_id = *(++argv); } #endif #ifndef OPENSSL_NO_TLSEXT else if (strcmp(*argv, "-servername") == 0) { if (--argc < 1) goto bad; tlsextcbp.servername = *(++argv); } else if (strcmp(*argv, "-servername_fatal") == 0) { tlsextcbp.extension_error = SSL_TLSEXT_ERR_ALERT_FATAL; } else if (strcmp(*argv, "-cert2") == 0) { if (--argc < 1) goto bad; s_cert_file2 = *(++argv); } else if (strcmp(*argv, "-key2") == 0) { if (--argc < 1) goto bad; s_key_file2 = *(++argv); } #ifndef OPENSSL_NO_NEXTPROTONEG else if (strcmp(*argv, "-nextprotoneg") == 0) { if (--argc < 1) goto bad; next_proto_neg_in = *(++argv); } #endif #endif #ifndef OPENSSL_NO_SRTP else if (strcmp(*argv, "-use_srtp") == 0) { if (--argc < 1) goto bad; srtp_profiles = *(++argv); } #endif else if (strcmp(*argv, "-keymatexport") == 0) { if (--argc < 1) goto bad; keymatexportlabel = *(++argv); } else if (strcmp(*argv, "-keymatexportlen") == 0) { if (--argc < 1) goto bad; keymatexportlen = strtonum(*(++argv), 1, INT_MAX, &errstr); if (errstr) goto bad; } else { BIO_printf(bio_err, "unknown option %s\n", *argv); badop = 1; break; } argc--; argv++; } if (badop) { bad: if (errstr) BIO_printf(bio_err, "invalid argument %s: %s\n", *argv, errstr); else sv_usage(); goto end; } SSL_load_error_strings(); OpenSSL_add_ssl_algorithms(); #ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine_id, 1); #endif if (!app_passwd(bio_err, passarg, dpassarg, &pass, &dpass)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } if (s_key_file == NULL) s_key_file = s_cert_file; #ifndef OPENSSL_NO_TLSEXT if (s_key_file2 == NULL) s_key_file2 = s_cert_file2; #endif if (nocert == 0) { s_key = load_key(bio_err, s_key_file, s_key_format, 0, pass, e, "server certificate private key file"); if (!s_key) { ERR_print_errors(bio_err); goto end; } s_cert = load_cert(bio_err, s_cert_file, s_cert_format, NULL, e, "server certificate file"); if (!s_cert) { ERR_print_errors(bio_err); goto end; } #ifndef OPENSSL_NO_TLSEXT if (tlsextcbp.servername) { s_key2 = load_key(bio_err, s_key_file2, s_key_format, 0, pass, e, "second server certificate private key file"); if (!s_key2) { ERR_print_errors(bio_err); goto end; } s_cert2 = load_cert(bio_err, s_cert_file2, s_cert_format, NULL, e, "second server certificate file"); if (!s_cert2) { ERR_print_errors(bio_err); goto end; } } #endif } #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) if (next_proto_neg_in) { unsigned short len; next_proto.data = next_protos_parse(&len, next_proto_neg_in); if (next_proto.data == NULL) goto end; next_proto.len = len; } else { next_proto.data = NULL; } #endif if (s_dcert_file) { if (s_dkey_file == NULL) s_dkey_file = s_dcert_file; s_dkey = load_key(bio_err, s_dkey_file, s_dkey_format, 0, dpass, e, "second certificate private key file"); if (!s_dkey) { ERR_print_errors(bio_err); goto end; } s_dcert = load_cert(bio_err, s_dcert_file, s_dcert_format, NULL, e, "second server certificate file"); if (!s_dcert) { ERR_print_errors(bio_err); goto end; } } if (bio_s_out == NULL) { if (s_quiet && !s_debug && !s_msg) { bio_s_out = BIO_new(BIO_s_null()); } else { if (bio_s_out == NULL) bio_s_out = BIO_new_fp(stdout, BIO_NOCLOSE); } } if (nocert) { s_cert_file = NULL; s_key_file = NULL; s_dcert_file = NULL; s_dkey_file = NULL; #ifndef OPENSSL_NO_TLSEXT s_cert_file2 = NULL; s_key_file2 = NULL; #endif } ctx = SSL_CTX_new(meth); if (ctx == NULL) { ERR_print_errors(bio_err); goto end; } if (session_id_prefix) { if (strlen(session_id_prefix) >= 32) BIO_printf(bio_err, "warning: id_prefix is too long, only one new session will be possible\n"); else if (strlen(session_id_prefix) >= 16) BIO_printf(bio_err, "warning: id_prefix is too long if you use SSLv2\n"); if (!SSL_CTX_set_generate_session_id(ctx, generate_session_id)) { BIO_printf(bio_err, "error setting 'id_prefix'\n"); ERR_print_errors(bio_err); goto end; } BIO_printf(bio_err, "id_prefix '%s' set.\n", session_id_prefix); } SSL_CTX_set_quiet_shutdown(ctx, 1); if (bugs) SSL_CTX_set_options(ctx, SSL_OP_ALL); if (hack) SSL_CTX_set_options(ctx, SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG); SSL_CTX_set_options(ctx, off); /* * DTLS: partial reads end up discarding unread UDP bytes :-( Setting * read ahead solves this problem. */ if (socket_type == SOCK_DGRAM) SSL_CTX_set_read_ahead(ctx, 1); if (state) SSL_CTX_set_info_callback(ctx, apps_ssl_info_callback); if (no_cache) SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF); else SSL_CTX_sess_set_cache_size(ctx, 128); #ifndef OPENSSL_NO_SRTP if (srtp_profiles != NULL) SSL_CTX_set_tlsext_use_srtp(ctx, srtp_profiles); #endif if ((!SSL_CTX_load_verify_locations(ctx, CAfile, CApath)) || (!SSL_CTX_set_default_verify_paths(ctx))) { /* BIO_printf(bio_err,"X509_load_verify_locations\n"); */ ERR_print_errors(bio_err); /* goto end; */ } if (vpm) SSL_CTX_set1_param(ctx, vpm); #ifndef OPENSSL_NO_TLSEXT if (s_cert2) { ctx2 = SSL_CTX_new(meth); if (ctx2 == NULL) { ERR_print_errors(bio_err); goto end; } } if (ctx2) { BIO_printf(bio_s_out, "Setting secondary ctx parameters\n"); if (session_id_prefix) { if (strlen(session_id_prefix) >= 32) BIO_printf(bio_err, "warning: id_prefix is too long, only one new session will be possible\n"); else if (strlen(session_id_prefix) >= 16) BIO_printf(bio_err, "warning: id_prefix is too long if you use SSLv2\n"); if (!SSL_CTX_set_generate_session_id(ctx2, generate_session_id)) { BIO_printf(bio_err, "error setting 'id_prefix'\n"); ERR_print_errors(bio_err); goto end; } BIO_printf(bio_err, "id_prefix '%s' set.\n", session_id_prefix); } SSL_CTX_set_quiet_shutdown(ctx2, 1); if (bugs) SSL_CTX_set_options(ctx2, SSL_OP_ALL); if (hack) SSL_CTX_set_options(ctx2, SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG); SSL_CTX_set_options(ctx2, off); /* * DTLS: partial reads end up discarding unread UDP bytes :-( * Setting read ahead solves this problem. */ if (socket_type == SOCK_DGRAM) SSL_CTX_set_read_ahead(ctx2, 1); if (state) SSL_CTX_set_info_callback(ctx2, apps_ssl_info_callback); if (no_cache) SSL_CTX_set_session_cache_mode(ctx2, SSL_SESS_CACHE_OFF); else SSL_CTX_sess_set_cache_size(ctx2, 128); if ((!SSL_CTX_load_verify_locations(ctx2, CAfile, CApath)) || (!SSL_CTX_set_default_verify_paths(ctx2))) { ERR_print_errors(bio_err); } if (vpm) SSL_CTX_set1_param(ctx2, vpm); } #ifndef OPENSSL_NO_NEXTPROTONEG if (next_proto.data) SSL_CTX_set_next_protos_advertised_cb(ctx, next_proto_cb, &next_proto); #endif #endif #ifndef OPENSSL_NO_DH if (!no_dhe) { DH *dh = NULL; if (dhfile) dh = load_dh_param(dhfile); else if (s_cert_file) dh = load_dh_param(s_cert_file); if (dh != NULL) { BIO_printf(bio_s_out, "Setting temp DH parameters\n"); } else { BIO_printf(bio_s_out, "Using default temp DH parameters\n"); dh = get_dh512(); } (void) BIO_flush(bio_s_out); SSL_CTX_set_tmp_dh(ctx, dh); #ifndef OPENSSL_NO_TLSEXT if (ctx2) { if (!dhfile) { DH *dh2 = load_dh_param(s_cert_file2); if (dh2 != NULL) { BIO_printf(bio_s_out, "Setting temp DH parameters\n"); (void) BIO_flush(bio_s_out); DH_free(dh); dh = dh2; } } SSL_CTX_set_tmp_dh(ctx2, dh); } #endif DH_free(dh); } #endif if (!no_ecdhe) { EC_KEY *ecdh = NULL; if (named_curve) { int nid = OBJ_sn2nid(named_curve); if (nid == 0) { BIO_printf(bio_err, "unknown curve name (%s)\n", named_curve); goto end; } ecdh = EC_KEY_new_by_curve_name(nid); if (ecdh == NULL) { BIO_printf(bio_err, "unable to create curve (%s)\n", named_curve); goto end; } } if (ecdh != NULL) { BIO_printf(bio_s_out, "Setting temp ECDH parameters\n"); } else { BIO_printf(bio_s_out, "Using default temp ECDH parameters\n"); ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); if (ecdh == NULL) { BIO_printf(bio_err, "unable to create curve (nistp256)\n"); goto end; } } (void) BIO_flush(bio_s_out); SSL_CTX_set_tmp_ecdh(ctx, ecdh); #ifndef OPENSSL_NO_TLSEXT if (ctx2) SSL_CTX_set_tmp_ecdh(ctx2, ecdh); #endif EC_KEY_free(ecdh); } if (!set_cert_key_stuff(ctx, s_cert, s_key)) goto end; #ifndef OPENSSL_NO_TLSEXT if (ctx2 && !set_cert_key_stuff(ctx2, s_cert2, s_key2)) goto end; #endif if (s_dcert != NULL) { if (!set_cert_key_stuff(ctx, s_dcert, s_dkey)) goto end; } if (!no_tmp_rsa) { SSL_CTX_set_tmp_rsa_callback(ctx, tmp_rsa_cb); #ifndef OPENSSL_NO_TLSEXT if (ctx2) SSL_CTX_set_tmp_rsa_callback(ctx2, tmp_rsa_cb); #endif } if (cipher != NULL) { if (!SSL_CTX_set_cipher_list(ctx, cipher)) { BIO_printf(bio_err, "error setting cipher list\n"); ERR_print_errors(bio_err); goto end; } #ifndef OPENSSL_NO_TLSEXT if (ctx2 && !SSL_CTX_set_cipher_list(ctx2, cipher)) { BIO_printf(bio_err, "error setting cipher list\n"); ERR_print_errors(bio_err); goto end; } #endif } SSL_CTX_set_verify(ctx, s_server_verify, verify_callback); SSL_CTX_set_session_id_context(ctx, (void *) &s_server_session_id_context, sizeof s_server_session_id_context); /* Set DTLS cookie generation and verification callbacks */ SSL_CTX_set_cookie_generate_cb(ctx, generate_cookie_callback); SSL_CTX_set_cookie_verify_cb(ctx, verify_cookie_callback); #ifndef OPENSSL_NO_TLSEXT if (ctx2) { SSL_CTX_set_verify(ctx2, s_server_verify, verify_callback); SSL_CTX_set_session_id_context(ctx2, (void *) &s_server_session_id_context, sizeof s_server_session_id_context); tlsextcbp.biodebug = bio_s_out; SSL_CTX_set_tlsext_servername_callback(ctx2, ssl_servername_cb); SSL_CTX_set_tlsext_servername_arg(ctx2, &tlsextcbp); SSL_CTX_set_tlsext_servername_callback(ctx, ssl_servername_cb); SSL_CTX_set_tlsext_servername_arg(ctx, &tlsextcbp); } #endif if (CAfile != NULL) { SSL_CTX_set_client_CA_list(ctx, SSL_load_client_CA_file(CAfile)); #ifndef OPENSSL_NO_TLSEXT if (ctx2) SSL_CTX_set_client_CA_list(ctx2, SSL_load_client_CA_file(CAfile)); #endif } BIO_printf(bio_s_out, "ACCEPT\n"); (void) BIO_flush(bio_s_out); if (www) do_server(port, socket_type, &accept_socket, www_body, context); else do_server(port, socket_type, &accept_socket, sv_body, context); print_stats(bio_s_out, ctx); ret = 0; end: if (ctx != NULL) SSL_CTX_free(ctx); if (s_cert) X509_free(s_cert); if (s_dcert) X509_free(s_dcert); if (s_key) EVP_PKEY_free(s_key); if (s_dkey) EVP_PKEY_free(s_dkey); free(pass); free(dpass); if (vpm) X509_VERIFY_PARAM_free(vpm); #ifndef OPENSSL_NO_TLSEXT free(tlscstatp.host); free(tlscstatp.port); free(tlscstatp.path); if (ctx2 != NULL) SSL_CTX_free(ctx2); if (s_cert2) X509_free(s_cert2); if (s_key2) EVP_PKEY_free(s_key2); #endif if (bio_s_out != NULL) { BIO_free(bio_s_out); bio_s_out = NULL; } return (ret); } static void print_stats(BIO * bio, SSL_CTX * ssl_ctx) { BIO_printf(bio, "%4ld items in the session cache\n", SSL_CTX_sess_number(ssl_ctx)); BIO_printf(bio, "%4ld client connects (SSL_connect())\n", SSL_CTX_sess_connect(ssl_ctx)); BIO_printf(bio, "%4ld client renegotiates (SSL_connect())\n", SSL_CTX_sess_connect_renegotiate(ssl_ctx)); BIO_printf(bio, "%4ld client connects that finished\n", SSL_CTX_sess_connect_good(ssl_ctx)); BIO_printf(bio, "%4ld server accepts (SSL_accept())\n", SSL_CTX_sess_accept(ssl_ctx)); BIO_printf(bio, "%4ld server renegotiates (SSL_accept())\n", SSL_CTX_sess_accept_renegotiate(ssl_ctx)); BIO_printf(bio, "%4ld server accepts that finished\n", SSL_CTX_sess_accept_good(ssl_ctx)); BIO_printf(bio, "%4ld session cache hits\n", SSL_CTX_sess_hits(ssl_ctx)); BIO_printf(bio, "%4ld session cache misses\n", SSL_CTX_sess_misses(ssl_ctx)); BIO_printf(bio, "%4ld session cache timeouts\n", SSL_CTX_sess_timeouts(ssl_ctx)); BIO_printf(bio, "%4ld callback cache hits\n", SSL_CTX_sess_cb_hits(ssl_ctx)); BIO_printf(bio, "%4ld cache full overflows (%ld allowed)\n", SSL_CTX_sess_cache_full(ssl_ctx), SSL_CTX_sess_get_cache_size(ssl_ctx)); } static int sv_body(char *hostname, int s, unsigned char *context) { char *buf = NULL; fd_set readfds; int ret = 1, width; int k, i; unsigned long l; SSL *con = NULL; BIO *sbio; struct timeval timeout; struct timeval *timeoutp; if ((buf = malloc(bufsize)) == NULL) { BIO_printf(bio_err, "out of memory\n"); goto err; } if (s_nbio) { unsigned long sl = 1; if (!s_quiet) BIO_printf(bio_err, "turning on non blocking io\n"); if (BIO_socket_ioctl(s, FIONBIO, &sl) < 0) ERR_print_errors(bio_err); } if (con == NULL) { con = SSL_new(ctx); #ifndef OPENSSL_NO_TLSEXT if (s_tlsextdebug) { SSL_set_tlsext_debug_callback(con, tlsext_cb); SSL_set_tlsext_debug_arg(con, bio_s_out); } if (s_tlsextstatus) { SSL_CTX_set_tlsext_status_cb(ctx, cert_status_cb); tlscstatp.err = bio_err; SSL_CTX_set_tlsext_status_arg(ctx, &tlscstatp); } #endif if (context) SSL_set_session_id_context(con, context, strlen((char *) context)); } SSL_clear(con); if (SSL_version(con) == DTLS1_VERSION) { sbio = BIO_new_dgram(s, BIO_NOCLOSE); if (enable_timeouts) { timeout.tv_sec = 0; timeout.tv_usec = DGRAM_RCV_TIMEOUT; BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_RECV_TIMEOUT, 0, &timeout); timeout.tv_sec = 0; timeout.tv_usec = DGRAM_SND_TIMEOUT; BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_SEND_TIMEOUT, 0, &timeout); } if (socket_mtu > 28) { SSL_set_options(con, SSL_OP_NO_QUERY_MTU); SSL_set_mtu(con, socket_mtu - 28); } else /* want to do MTU discovery */ BIO_ctrl(sbio, BIO_CTRL_DGRAM_MTU_DISCOVER, 0, NULL); /* turn on cookie exchange */ SSL_set_options(con, SSL_OP_COOKIE_EXCHANGE); } else sbio = BIO_new_socket(s, BIO_NOCLOSE); if (s_nbio_test) { BIO *test; test = BIO_new(BIO_f_nbio_test()); sbio = BIO_push(test, sbio); } SSL_set_bio(con, sbio, sbio); SSL_set_accept_state(con); /* SSL_set_fd(con,s); */ if (s_debug) { SSL_set_debug(con, 1); BIO_set_callback(SSL_get_rbio(con), bio_dump_callback); BIO_set_callback_arg(SSL_get_rbio(con), (char *) bio_s_out); } if (s_msg) { SSL_set_msg_callback(con, msg_cb); SSL_set_msg_callback_arg(con, bio_s_out); } #ifndef OPENSSL_NO_TLSEXT if (s_tlsextdebug) { SSL_set_tlsext_debug_callback(con, tlsext_cb); SSL_set_tlsext_debug_arg(con, bio_s_out); } #endif width = s + 1; for (;;) { int read_from_terminal; int read_from_sslcon; read_from_terminal = 0; read_from_sslcon = SSL_pending(con); if (!read_from_sslcon) { FD_ZERO(&readfds); FD_SET(fileno(stdin), &readfds); FD_SET(s, &readfds); if ((SSL_version(con) == DTLS1_VERSION) && DTLSv1_get_timeout(con, &timeout)) timeoutp = &timeout; else timeoutp = NULL; i = select(width, &readfds, NULL, NULL, timeoutp); if ((SSL_version(con) == DTLS1_VERSION) && DTLSv1_handle_timeout(con) > 0) { BIO_printf(bio_err, "TIMEOUT occured\n"); } if (i <= 0) continue; if (FD_ISSET(fileno(stdin), &readfds)) read_from_terminal = 1; if (FD_ISSET(s, &readfds)) read_from_sslcon = 1; } if (read_from_terminal) { if (s_crlf) { int j, lf_num; i = read(fileno(stdin), buf, bufsize / 2); lf_num = 0; /* both loops are skipped when i <= 0 */ for (j = 0; j < i; j++) if (buf[j] == '\n') lf_num++; for (j = i - 1; j >= 0; j--) { buf[j + lf_num] = buf[j]; if (buf[j] == '\n') { lf_num--; i++; buf[j + lf_num] = '\r'; } } assert(lf_num == 0); } else i = read(fileno(stdin), buf, bufsize); if (!s_quiet) { if ((i <= 0) || (buf[0] == 'Q')) { BIO_printf(bio_s_out, "DONE\n"); shutdown(s, SHUT_RD); close(s); close_accept_socket(); ret = -11; goto err; } if ((i <= 0) || (buf[0] == 'q')) { BIO_printf(bio_s_out, "DONE\n"); if (SSL_version(con) != DTLS1_VERSION) { shutdown(s, SHUT_RD); close(s); } /* * close_accept_socket(); ret= -11; */ goto err; } if ((buf[0] == 'r') && ((buf[1] == '\n') || (buf[1] == '\r'))) { SSL_renegotiate(con); i = SSL_do_handshake(con); printf("SSL_do_handshake -> %d\n", i); i = 0; /* 13; */ continue; /* * strcpy(buf,"server side * RE-NEGOTIATE\n"); */ } if ((buf[0] == 'R') && ((buf[1] == '\n') || (buf[1] == '\r'))) { SSL_set_verify(con, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, NULL); SSL_renegotiate(con); i = SSL_do_handshake(con); printf("SSL_do_handshake -> %d\n", i); i = 0; /* 13; */ continue; /* * strcpy(buf,"server side * RE-NEGOTIATE asking for client * cert\n"); */ } if (buf[0] == 'P') { static const char *str = "Lets print some clear text\n"; BIO_write(SSL_get_wbio(con), str, strlen(str)); } if (buf[0] == 'S') { print_stats(bio_s_out, SSL_get_SSL_CTX(con)); } } l = k = 0; for (;;) { /* should do a select for the write */ #ifdef RENEG { static count = 0; if (++count == 100) { count = 0; SSL_renegotiate(con); } } #endif k = SSL_write(con, &(buf[l]), (unsigned int) i); switch (SSL_get_error(con, k)) { case SSL_ERROR_NONE: break; case SSL_ERROR_WANT_WRITE: case SSL_ERROR_WANT_READ: case SSL_ERROR_WANT_X509_LOOKUP: BIO_printf(bio_s_out, "Write BLOCK\n"); break; case SSL_ERROR_SYSCALL: case SSL_ERROR_SSL: BIO_printf(bio_s_out, "ERROR\n"); ERR_print_errors(bio_err); ret = 1; goto err; /* break; */ case SSL_ERROR_ZERO_RETURN: BIO_printf(bio_s_out, "DONE\n"); ret = 1; goto err; } l += k; i -= k; if (i <= 0) break; } } if (read_from_sslcon) { if (!SSL_is_init_finished(con)) { i = init_ssl_connection(con); if (i < 0) { ret = 0; goto err; } else if (i == 0) { ret = 1; goto err; } } else { again: i = SSL_read(con, (char *) buf, bufsize); switch (SSL_get_error(con, i)) { case SSL_ERROR_NONE: { int len, n; for (len = 0; len < i;) { do { n = write(fileno(stdout), buf + len, i - len); } while (n == -1 && errno == EINTR); if (n < 0) { BIO_printf(bio_s_out, "ERROR\n"); goto err; } len += n; } } if (SSL_pending(con)) goto again; break; case SSL_ERROR_WANT_WRITE: case SSL_ERROR_WANT_READ: BIO_printf(bio_s_out, "Read BLOCK\n"); break; case SSL_ERROR_SYSCALL: case SSL_ERROR_SSL: BIO_printf(bio_s_out, "ERROR\n"); ERR_print_errors(bio_err); ret = 1; goto err; case SSL_ERROR_ZERO_RETURN: BIO_printf(bio_s_out, "DONE\n"); ret = 1; goto err; } } } } err: if (con != NULL) { BIO_printf(bio_s_out, "shutting down SSL\n"); SSL_set_shutdown(con, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN); SSL_free(con); } BIO_printf(bio_s_out, "CONNECTION CLOSED\n"); if (buf != NULL) { OPENSSL_cleanse(buf, bufsize); free(buf); } if (ret >= 0) BIO_printf(bio_s_out, "ACCEPT\n"); return (ret); } static void close_accept_socket(void) { BIO_printf(bio_err, "shutdown accept socket\n"); if (accept_socket >= 0) { shutdown(accept_socket, SHUT_RDWR); close(accept_socket); } } static int init_ssl_connection(SSL * con) { int i; const char *str; X509 *peer; long verify_error; char buf[BUFSIZ]; #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) const unsigned char *next_proto_neg; unsigned next_proto_neg_len; #endif unsigned char *exportedkeymat; i = SSL_accept(con); if (i <= 0) { if (BIO_sock_should_retry(i)) { BIO_printf(bio_s_out, "DELAY\n"); return (1); } BIO_printf(bio_err, "ERROR\n"); verify_error = SSL_get_verify_result(con); if (verify_error != X509_V_OK) { BIO_printf(bio_err, "verify error:%s\n", X509_verify_cert_error_string(verify_error)); } else ERR_print_errors(bio_err); return (0); } PEM_write_bio_SSL_SESSION(bio_s_out, SSL_get_session(con)); peer = SSL_get_peer_certificate(con); if (peer != NULL) { BIO_printf(bio_s_out, "Client certificate\n"); PEM_write_bio_X509(bio_s_out, peer); X509_NAME_oneline(X509_get_subject_name(peer), buf, sizeof buf); BIO_printf(bio_s_out, "subject=%s\n", buf); X509_NAME_oneline(X509_get_issuer_name(peer), buf, sizeof buf); BIO_printf(bio_s_out, "issuer=%s\n", buf); X509_free(peer); } if (SSL_get_shared_ciphers(con, buf, sizeof buf) != NULL) BIO_printf(bio_s_out, "Shared ciphers:%s\n", buf); str = SSL_CIPHER_get_name(SSL_get_current_cipher(con)); BIO_printf(bio_s_out, "CIPHER is %s\n", (str != NULL) ? str : "(NONE)"); #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) SSL_get0_next_proto_negotiated(con, &next_proto_neg, &next_proto_neg_len); if (next_proto_neg) { BIO_printf(bio_s_out, "NEXTPROTO is "); BIO_write(bio_s_out, next_proto_neg, next_proto_neg_len); BIO_printf(bio_s_out, "\n"); } #endif #ifndef OPENSSL_NO_SRTP { SRTP_PROTECTION_PROFILE *srtp_profile = SSL_get_selected_srtp_profile(con); if (srtp_profile) BIO_printf(bio_s_out, "SRTP Extension negotiated, profile=%s\n", srtp_profile->name); } #endif if (SSL_cache_hit(con)) BIO_printf(bio_s_out, "Reused session-id\n"); if (SSL_ctrl(con, SSL_CTRL_GET_FLAGS, 0, NULL) & TLS1_FLAGS_TLS_PADDING_BUG) BIO_printf(bio_s_out, "Peer has incorrect TLSv1 block padding\n"); BIO_printf(bio_s_out, "Secure Renegotiation IS%s supported\n", SSL_get_secure_renegotiation_support(con) ? "" : " NOT"); if (keymatexportlabel != NULL) { BIO_printf(bio_s_out, "Keying material exporter:\n"); BIO_printf(bio_s_out, " Label: '%s'\n", keymatexportlabel); BIO_printf(bio_s_out, " Length: %i bytes\n", keymatexportlen); exportedkeymat = malloc(keymatexportlen); if (exportedkeymat != NULL) { if (!SSL_export_keying_material(con, exportedkeymat, keymatexportlen, keymatexportlabel, strlen(keymatexportlabel), NULL, 0, 0)) { BIO_printf(bio_s_out, " Error\n"); } else { BIO_printf(bio_s_out, " Keying material: "); for (i = 0; i < keymatexportlen; i++) BIO_printf(bio_s_out, "%02X", exportedkeymat[i]); BIO_printf(bio_s_out, "\n"); } free(exportedkeymat); } } return (1); } #ifndef OPENSSL_NO_DH static DH * load_dh_param(const char *dhfile) { DH *ret = NULL; BIO *bio; if ((bio = BIO_new_file(dhfile, "r")) == NULL) goto err; ret = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); err: if (bio != NULL) BIO_free(bio); return (ret); } #endif static int www_body(char *hostname, int s, unsigned char *context) { char *buf = NULL; int ret = 1; int i, j, k, dot; SSL *con; const SSL_CIPHER *c; BIO *io, *ssl_bio, *sbio; buf = malloc(bufsize); if (buf == NULL) return (0); io = BIO_new(BIO_f_buffer()); ssl_bio = BIO_new(BIO_f_ssl()); if ((io == NULL) || (ssl_bio == NULL)) goto err; if (s_nbio) { unsigned long sl = 1; if (!s_quiet) BIO_printf(bio_err, "turning on non blocking io\n"); if (BIO_socket_ioctl(s, FIONBIO, &sl) < 0) ERR_print_errors(bio_err); } /* lets make the output buffer a reasonable size */ if (!BIO_set_write_buffer_size(io, bufsize)) goto err; if ((con = SSL_new(ctx)) == NULL) goto err; #ifndef OPENSSL_NO_TLSEXT if (s_tlsextdebug) { SSL_set_tlsext_debug_callback(con, tlsext_cb); SSL_set_tlsext_debug_arg(con, bio_s_out); } #endif if (context) SSL_set_session_id_context(con, context, strlen((char *) context)); sbio = BIO_new_socket(s, BIO_NOCLOSE); if (s_nbio_test) { BIO *test; test = BIO_new(BIO_f_nbio_test()); sbio = BIO_push(test, sbio); } SSL_set_bio(con, sbio, sbio); SSL_set_accept_state(con); /* SSL_set_fd(con,s); */ BIO_set_ssl(ssl_bio, con, BIO_CLOSE); BIO_push(io, ssl_bio); if (s_debug) { SSL_set_debug(con, 1); BIO_set_callback(SSL_get_rbio(con), bio_dump_callback); BIO_set_callback_arg(SSL_get_rbio(con), (char *) bio_s_out); } if (s_msg) { SSL_set_msg_callback(con, msg_cb); SSL_set_msg_callback_arg(con, bio_s_out); } for (;;) { if (hack) { i = SSL_accept(con); switch (SSL_get_error(con, i)) { case SSL_ERROR_NONE: break; case SSL_ERROR_WANT_WRITE: case SSL_ERROR_WANT_READ: case SSL_ERROR_WANT_X509_LOOKUP: continue; case SSL_ERROR_SYSCALL: case SSL_ERROR_SSL: case SSL_ERROR_ZERO_RETURN: ret = 1; goto err; /* break; */ } SSL_renegotiate(con); SSL_write(con, NULL, 0); } i = BIO_gets(io, buf, bufsize - 1); if (i < 0) { /* error */ if (!BIO_should_retry(io)) { if (!s_quiet) ERR_print_errors(bio_err); goto err; } else { BIO_printf(bio_s_out, "read R BLOCK\n"); sleep(1); continue; } } else if (i == 0) { /* end of input */ ret = 1; goto end; } /* else we have data */ if (((www == 1) && (strncmp("GET ", buf, 4) == 0)) || ((www == 2) && (strncmp("GET /stats ", buf, 11) == 0))) { char *p; X509 *peer; STACK_OF(SSL_CIPHER) * sk; static const char *space = " "; BIO_puts(io, "HTTP/1.0 200 ok\r\nContent-type: text/html\r\n\r\n"); BIO_puts(io, "\n"); BIO_puts(io, "

\n");
/*			BIO_puts(io,SSLeay_version(SSLEAY_VERSION));*/
			BIO_puts(io, "\n");
			for (i = 0; i < local_argc; i++) {
				BIO_puts(io, local_argv[i]);
				BIO_write(io, " ", 1);
			}
			BIO_puts(io, "\n");

			BIO_printf(io,
			    "Secure Renegotiation IS%s supported\n",
			    SSL_get_secure_renegotiation_support(con) ?
			    "" : " NOT");

			/*
			 * The following is evil and should not really be
			 * done
			 */
			BIO_printf(io, "Ciphers supported in s_server binary\n");
			sk = SSL_get_ciphers(con);
			j = sk_SSL_CIPHER_num(sk);
			for (i = 0; i < j; i++) {
				c = sk_SSL_CIPHER_value(sk, i);
				BIO_printf(io, "%-11s:%-25s",
				    SSL_CIPHER_get_version(c),
				    SSL_CIPHER_get_name(c));
				if ((((i + 1) % 2) == 0) && (i + 1 != j))
					BIO_puts(io, "\n");
			}
			BIO_puts(io, "\n");
			p = SSL_get_shared_ciphers(con, buf, bufsize);
			if (p != NULL) {
				BIO_printf(io, "---\nCiphers common between both SSL end points:\n");
				j = i = 0;
				while (*p) {
					if (*p == ':') {
						BIO_write(io, space, 26 - j);
						i++;
						j = 0;
						BIO_write(io, ((i % 3) ? " " : "\n"), 1);
					} else {
						BIO_write(io, p, 1);
						j++;
					}
					p++;
				}
				BIO_puts(io, "\n");
			}
			BIO_printf(io, (SSL_cache_hit(con)
				? "---\nReused, "
				: "---\nNew, "));
			c = SSL_get_current_cipher(con);
			BIO_printf(io, "%s, Cipher is %s\n",
			    SSL_CIPHER_get_version(c),
			    SSL_CIPHER_get_name(c));
			SSL_SESSION_print(io, SSL_get_session(con));
			BIO_printf(io, "---\n");
			print_stats(io, SSL_get_SSL_CTX(con));
			BIO_printf(io, "---\n");
			peer = SSL_get_peer_certificate(con);
			if (peer != NULL) {
				BIO_printf(io, "Client certificate\n");
				X509_print(io, peer);
				PEM_write_bio_X509(io, peer);
			} else
				BIO_puts(io, "no client certificate available\n");
			BIO_puts(io, "\r\n\r\n");
			break;
		} else if ((www == 2 || www == 3)
		    && (strncmp("GET /", buf, 5) == 0)) {
			BIO *file;
			char *p, *e;
			static const char *text = "HTTP/1.0 200 ok\r\nContent-type: text/plain\r\n\r\n";

			/* skip the '/' */
			p = &(buf[5]);

			dot = 1;
			for (e = p; *e != '\0'; e++) {
				if (e[0] == ' ')
					break;

				switch (dot) {
				case 1:
					dot = (e[0] == '.') ? 2 : 0;
					break;
				case 2:
					dot = (e[0] == '.') ? 3 : 0;
					break;
				case 3:
					dot = (e[0] == '/') ? -1 : 0;
					break;
				}
				if (dot == 0)
					dot = (e[0] == '/') ? 1 : 0;
			}
			dot = (dot == 3) || (dot == -1);	/* filename contains
								 * ".." component */

			if (*e == '\0') {
				BIO_puts(io, text);
				BIO_printf(io, "'%s' is an invalid file name\r\n", p);
				break;
			}
			*e = '\0';

			if (dot) {
				BIO_puts(io, text);
				BIO_printf(io, "'%s' contains '..' reference\r\n", p);
				break;
			}
			if (*p == '/') {
				BIO_puts(io, text);
				BIO_printf(io, "'%s' is an invalid path\r\n", p);
				break;
			}
			/* if a directory, do the index thang */
			if (app_isdir(p) > 0) {
				BIO_puts(io, text);
				BIO_printf(io, "'%s' is a directory\r\n", p);
				break;
			}
			if ((file = BIO_new_file(p, "r")) == NULL) {
				BIO_puts(io, text);
				BIO_printf(io, "Error opening '%s'\r\n", p);
				ERR_print_errors(io);
				break;
			}
			if (!s_quiet)
				BIO_printf(bio_err, "FILE:%s\n", p);

			if (www == 2) {
				i = strlen(p);
				if (((i > 5) && (strcmp(&(p[i - 5]), ".html") == 0)) ||
				    ((i > 4) && (strcmp(&(p[i - 4]), ".php") == 0)) ||
				    ((i > 4) && (strcmp(&(p[i - 4]), ".htm") == 0)))
					BIO_puts(io, "HTTP/1.0 200 ok\r\nContent-type: text/html\r\n\r\n");
				else
					BIO_puts(io, "HTTP/1.0 200 ok\r\nContent-type: text/plain\r\n\r\n");
			}
			/* send the file */
			for (;;) {
				i = BIO_read(file, buf, bufsize);
				if (i <= 0)
					break;

#ifdef RENEG
				total_bytes += i;
				fprintf(stderr, "%d\n", i);
				if (total_bytes > 3 * 1024) {
					total_bytes = 0;
					fprintf(stderr, "RENEGOTIATE\n");
					SSL_renegotiate(con);
				}
#endif

				for (j = 0; j < i;) {
#ifdef RENEG
					{
						static count = 0;
						if (++count == 13) {
							SSL_renegotiate(con);
						}
					}
#endif
					k = BIO_write(io, &(buf[j]), i - j);
					if (k <= 0) {
						if (!BIO_should_retry(io))
							goto write_error;
						else {
							BIO_printf(bio_s_out, "rwrite W BLOCK\n");
						}
					} else {
						j += k;
					}
				}
			}
	write_error:
			BIO_free(file);
			break;
		}
	}

	for (;;) {
		i = (int) BIO_flush(io);
		if (i <= 0) {
			if (!BIO_should_retry(io))
				break;
		} else
			break;
	}
end:
	/* make sure we re-use sessions */
	SSL_set_shutdown(con, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);

err:

	if (ret >= 0)
		BIO_printf(bio_s_out, "ACCEPT\n");

	if (buf != NULL)
		free(buf);
	if (io != NULL)
		BIO_free_all(io);
/*	if (ssl_bio != NULL) BIO_free(ssl_bio);*/
	return (ret);
}

static RSA *
tmp_rsa_cb(SSL * s, int is_export, int keylength)
{
	BIGNUM *bn = NULL;
	static RSA *rsa_tmp = NULL;

	if (!rsa_tmp && ((bn = BN_new()) == NULL))
		BIO_printf(bio_err, "Allocation error in generating RSA key\n");
	if (!rsa_tmp && bn) {
		if (!s_quiet) {
			BIO_printf(bio_err, "Generating temp (%d bit) RSA key...", keylength);
			(void) BIO_flush(bio_err);
		}
		if (!BN_set_word(bn, RSA_F4) || ((rsa_tmp = RSA_new()) == NULL) ||
		    !RSA_generate_key_ex(rsa_tmp, keylength, bn, NULL)) {
			if (rsa_tmp)
				RSA_free(rsa_tmp);
			rsa_tmp = NULL;
		}
		if (!s_quiet) {
			BIO_printf(bio_err, "\n");
			(void) BIO_flush(bio_err);
		}
		BN_free(bn);
	}
	return (rsa_tmp);
}

#define MAX_SESSION_ID_ATTEMPTS 10
static int 
generate_session_id(const SSL * ssl, unsigned char *id,
    unsigned int *id_len)
{
	unsigned int count = 0;
	do {
		RAND_pseudo_bytes(id, *id_len);
		/*
		 * Prefix the session_id with the required prefix. NB: If our
		 * prefix is too long, clip it - but there will be worse
		 * effects anyway, eg. the server could only possibly create
		 * 1 session ID (ie. the prefix!) so all future session
		 * negotiations will fail due to conflicts.
		 */
		memcpy(id, session_id_prefix,
		    (strlen(session_id_prefix) < *id_len) ?
		    strlen(session_id_prefix) : *id_len);
	}
	while (SSL_has_matching_session_id(ssl, id, *id_len) &&
	    (++count < MAX_SESSION_ID_ATTEMPTS));
	if (count >= MAX_SESSION_ID_ATTEMPTS)
		return 0;
	return 1;
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/progs.h0000644000175000017500000002026712360020706017211 0ustar  /* $OpenBSD$ */
/* Public domain */

extern int asn1parse_main(int argc, char *argv[]);
extern int ca_main(int argc, char *argv[]);
extern int ciphers_main(int argc, char *argv[]);
extern int cms_main(int argc, char *argv[]);
extern int crl2pkcs7_main(int argc, char *argv[]);
extern int crl_main(int argc, char *argv[]);
extern int dgst_main(int argc, char *argv[]);
extern int dh_main(int argc, char *argv[]);
extern int dhparam_main(int argc, char *argv[]);
extern int dsa_main(int argc, char *argv[]);
extern int dsaparam_main(int argc, char *argv[]);
extern int ec_main(int argc, char *argv[]);
extern int ecparam_main(int argc, char *argv[]);
extern int enc_main(int argc, char *argv[]);
extern int engine_main(int argc, char *argv[]);
extern int errstr_main(int argc, char *argv[]);
extern int gendh_main(int argc, char *argv[]);
extern int gendsa_main(int argc, char *argv[]);
extern int genpkey_main(int argc, char *argv[]);
extern int genrsa_main(int argc, char *argv[]);
extern int nseq_main(int argc, char *argv[]);
extern int ocsp_main(int argc, char *argv[]);
extern int passwd_main(int argc, char *argv[]);
extern int pkcs7_main(int argc, char *argv[]);
extern int pkcs8_main(int argc, char *argv[]);
extern int pkcs12_main(int argc, char *argv[]);
extern int pkey_main(int argc, char *argv[]);
extern int pkeyparam_main(int argc, char *argv[]);
extern int pkeyutl_main(int argc, char *argv[]);
extern int prime_main(int argc, char *argv[]);
extern int rand_main(int argc, char *argv[]);
extern int req_main(int argc, char *argv[]);
extern int rsa_main(int argc, char *argv[]);
extern int rsautl_main(int argc, char *argv[]);
extern int s_client_main(int argc, char *argv[]);
extern int s_server_main(int argc, char *argv[]);
extern int s_time_main(int argc, char *argv[]);
extern int sess_id_main(int argc, char *argv[]);
extern int smime_main(int argc, char *argv[]);
extern int speed_main(int argc, char *argv[]);
extern int spkac_main(int argc, char *argv[]);
extern int srp_main(int argc, char *argv[]);
extern int ts_main(int argc, char *argv[]);
extern int verify_main(int argc, char *argv[]);
extern int version_main(int argc, char *argv[]);
extern int x509_main(int argc, char *argv[]);

#define FUNC_TYPE_GENERAL	1
#define FUNC_TYPE_MD		2
#define FUNC_TYPE_CIPHER	3
#define FUNC_TYPE_PKEY		4
#define FUNC_TYPE_MD_ALG	5
#define FUNC_TYPE_CIPHER_ALG	6

typedef struct {
	int type;
	const char *name;
	int (*func)(int argc, char *argv[]);
} FUNCTION;
DECLARE_LHASH_OF(FUNCTION);

FUNCTION functions[] = {

	/* General functions. */
	{ FUNC_TYPE_GENERAL, "asn1parse", asn1parse_main },
	{ FUNC_TYPE_GENERAL, "ca", ca_main },
	{ FUNC_TYPE_GENERAL, "ciphers", ciphers_main },
#ifndef OPENSSL_NO_CMS
	{ FUNC_TYPE_GENERAL, "cms", cms_main },
#endif
	{ FUNC_TYPE_GENERAL, "crl2pkcs7", crl2pkcs7_main },
	{ FUNC_TYPE_GENERAL, "crl", crl_main },
	{ FUNC_TYPE_GENERAL, "dgst", dgst_main },
	{ FUNC_TYPE_GENERAL, "enc", enc_main },
#ifndef OPENSSL_NO_ENGINE
	{ FUNC_TYPE_GENERAL, "engine", engine_main },
#endif
	{ FUNC_TYPE_GENERAL, "errstr", errstr_main },
	{ FUNC_TYPE_GENERAL, "genpkey", genpkey_main },
	{ FUNC_TYPE_GENERAL, "nseq", nseq_main },
#ifndef OPENSSL_NO_OCSP
	{ FUNC_TYPE_GENERAL, "ocsp", ocsp_main },
#endif
	{ FUNC_TYPE_GENERAL, "passwd", passwd_main },
	{ FUNC_TYPE_GENERAL, "pkcs7", pkcs7_main },
	{ FUNC_TYPE_GENERAL, "pkcs8", pkcs8_main },
#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_SHA1)
	{ FUNC_TYPE_GENERAL, "pkcs12", pkcs12_main },
#endif
	{ FUNC_TYPE_GENERAL, "pkey", pkey_main },
	{ FUNC_TYPE_GENERAL, "pkeyparam", pkeyparam_main },
	{ FUNC_TYPE_GENERAL, "pkeyutl", pkeyutl_main },
	{ FUNC_TYPE_GENERAL, "prime", prime_main },
	{ FUNC_TYPE_GENERAL, "rand", rand_main },
	{ FUNC_TYPE_GENERAL, "req", req_main },
	{ FUNC_TYPE_GENERAL, "s_client", s_client_main },
	{ FUNC_TYPE_GENERAL, "s_server", s_server_main },
	{ FUNC_TYPE_GENERAL, "s_time", s_time_main },
	{ FUNC_TYPE_GENERAL, "sess_id", sess_id_main },
	{ FUNC_TYPE_GENERAL, "smime", smime_main },
#ifndef OPENSSL_NO_SPEED
	{ FUNC_TYPE_GENERAL, "speed", speed_main },
#endif
	{ FUNC_TYPE_GENERAL, "spkac", spkac_main },
	{ FUNC_TYPE_GENERAL, "ts", ts_main },
	{ FUNC_TYPE_GENERAL, "verify", verify_main },
	{ FUNC_TYPE_GENERAL, "version", version_main },
	{ FUNC_TYPE_GENERAL, "x509", x509_main },

#ifndef OPENSSL_NO_DH
	{ FUNC_TYPE_GENERAL, "dh", dh_main },
	{ FUNC_TYPE_GENERAL, "dhparam", dhparam_main },
	{ FUNC_TYPE_GENERAL, "gendh", gendh_main },
#endif
#ifndef OPENSSL_NO_DSA
	{ FUNC_TYPE_GENERAL, "dsa", dsa_main },
	{ FUNC_TYPE_GENERAL, "dsaparam", dsaparam_main },
	{ FUNC_TYPE_GENERAL, "gendsa", gendsa_main },
#endif
#ifndef OPENSSL_NO_EC
	{ FUNC_TYPE_GENERAL, "ec", ec_main },
	{ FUNC_TYPE_GENERAL, "ecparam", ecparam_main },
#endif
#ifndef OPENSSL_NO_RSA
	{ FUNC_TYPE_GENERAL, "genrsa", genrsa_main },
	{ FUNC_TYPE_GENERAL, "rsa", rsa_main },
	{ FUNC_TYPE_GENERAL, "rsautl", rsautl_main },
#endif

	/* Message Digests. */
#ifndef OPENSSL_NO_MD4
	{ FUNC_TYPE_MD, "md4", dgst_main },
#endif
#ifndef OPENSSL_NO_MD5
	{ FUNC_TYPE_MD, "md5", dgst_main },
#endif
#ifndef OPENSSL_NO_RMD160
	{ FUNC_TYPE_MD, "rmd160", dgst_main },
#endif
#ifndef OPENSSL_NO_SHA
	{ FUNC_TYPE_MD, "sha", dgst_main },
#endif
#ifndef OPENSSL_NO_SHA1
	{ FUNC_TYPE_MD, "sha1", dgst_main },
#endif

	/* Ciphers. */
	{ FUNC_TYPE_CIPHER, "base64", enc_main },
#ifndef OPENSSL_NO_AES
	{ FUNC_TYPE_CIPHER, "aes-128-cbc", enc_main },
	{ FUNC_TYPE_CIPHER, "aes-128-ecb", enc_main },
	{ FUNC_TYPE_CIPHER, "aes-192-cbc", enc_main },
	{ FUNC_TYPE_CIPHER, "aes-192-ecb", enc_main },
	{ FUNC_TYPE_CIPHER, "aes-256-cbc", enc_main },
	{ FUNC_TYPE_CIPHER, "aes-256-ecb", enc_main },
#endif
#ifndef OPENSSL_NO_BF
	{ FUNC_TYPE_CIPHER, "bf", enc_main },
	{ FUNC_TYPE_CIPHER, "bf-cbc", enc_main },
	{ FUNC_TYPE_CIPHER, "bf-ecb", enc_main },
	{ FUNC_TYPE_CIPHER, "bf-cfb", enc_main },
	{ FUNC_TYPE_CIPHER, "bf-ofb", enc_main },
#endif
#ifndef OPENSSL_NO_CAMELLIA
	{ FUNC_TYPE_CIPHER, "camellia-128-cbc", enc_main },
	{ FUNC_TYPE_CIPHER, "camellia-128-ecb", enc_main },
	{ FUNC_TYPE_CIPHER, "camellia-192-cbc", enc_main },
	{ FUNC_TYPE_CIPHER, "camellia-192-ecb", enc_main },
	{ FUNC_TYPE_CIPHER, "camellia-256-cbc", enc_main },
	{ FUNC_TYPE_CIPHER, "camellia-256-ecb", enc_main },
#endif
#ifndef OPENSSL_NO_CAST
	{ FUNC_TYPE_CIPHER, "cast", enc_main },
	{ FUNC_TYPE_CIPHER, "cast5-cbc", enc_main },
	{ FUNC_TYPE_CIPHER, "cast5-ecb", enc_main },
	{ FUNC_TYPE_CIPHER, "cast5-cfb", enc_main },
	{ FUNC_TYPE_CIPHER, "cast5-ofb", enc_main },
	{ FUNC_TYPE_CIPHER, "cast-cbc", enc_main },
#endif
#ifndef OPENSSL_NO_CHACHA
	{ FUNC_TYPE_CIPHER, "chacha", enc_main },
#endif
#ifndef OPENSSL_NO_DES
	{ FUNC_TYPE_CIPHER, "des", enc_main },
	{ FUNC_TYPE_CIPHER, "des3", enc_main },
	{ FUNC_TYPE_CIPHER, "desx", enc_main },
	{ FUNC_TYPE_CIPHER, "des-ecb", enc_main },
	{ FUNC_TYPE_CIPHER, "des-ede", enc_main },
	{ FUNC_TYPE_CIPHER, "des-ede3", enc_main },
	{ FUNC_TYPE_CIPHER, "des-cbc", enc_main },
	{ FUNC_TYPE_CIPHER, "des-ede-cbc", enc_main },
	{ FUNC_TYPE_CIPHER, "des-ede3-cbc", enc_main },
	{ FUNC_TYPE_CIPHER, "des-cfb", enc_main },
	{ FUNC_TYPE_CIPHER, "des-ede-cfb", enc_main },
	{ FUNC_TYPE_CIPHER, "des-ede3-cfb", enc_main },
	{ FUNC_TYPE_CIPHER, "des-ofb", enc_main },
	{ FUNC_TYPE_CIPHER, "des-ede-ofb", enc_main },
	{ FUNC_TYPE_CIPHER, "des-ede3-ofb", enc_main },
#endif
#ifndef OPENSSL_NO_IDEA
	{ FUNC_TYPE_CIPHER, "idea", enc_main },
	{ FUNC_TYPE_CIPHER, "idea-cbc", enc_main },
	{ FUNC_TYPE_CIPHER, "idea-ecb", enc_main },
	{ FUNC_TYPE_CIPHER, "idea-cfb", enc_main },
	{ FUNC_TYPE_CIPHER, "idea-ofb", enc_main },
#endif
#ifndef OPENSSL_NO_RC2
	{ FUNC_TYPE_CIPHER, "rc2", enc_main },
	{ FUNC_TYPE_CIPHER, "rc2-cbc", enc_main },
	{ FUNC_TYPE_CIPHER, "rc2-ecb", enc_main },
	{ FUNC_TYPE_CIPHER, "rc2-cfb", enc_main },
	{ FUNC_TYPE_CIPHER, "rc2-ofb", enc_main },
	{ FUNC_TYPE_CIPHER, "rc2-64-cbc", enc_main },
	{ FUNC_TYPE_CIPHER, "rc2-40-cbc", enc_main },
#endif
#ifndef OPENSSL_NO_RC4
	{ FUNC_TYPE_CIPHER, "rc4", enc_main },
	{ FUNC_TYPE_CIPHER, "rc4-40", enc_main },
#endif
#ifndef OPENSSL_NO_RC5
	{ FUNC_TYPE_CIPHER, "rc5", enc_main },
	{ FUNC_TYPE_CIPHER, "rc5-cbc", enc_main },
	{ FUNC_TYPE_CIPHER, "rc5-ecb", enc_main },
	{ FUNC_TYPE_CIPHER, "rc5-cfb", enc_main },
	{ FUNC_TYPE_CIPHER, "rc5-ofb", enc_main },
#endif
#ifdef ZLIB
	{ FUNC_TYPE_CIPHER, "zlib", enc_main },
#endif

	{ 0, NULL, NULL }
};
deps/libressl-pnacl-sys-2.1.6/libressl/apps/rand.c0000644000175000017500000001253312360020706016773 0ustar  /* $OpenBSD$ */
/* ====================================================================
 * Copyright (c) 1998-2001 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#include 
#include 
#include 

#include "apps.h"

#include 
#include 
#include 

/* -out file         - write to file
 * -base64           - base64 encode output
 * -hex              - hex encode output
 * num               - write 'num' bytes
 */

int rand_main(int, char **);

int 
rand_main(int argc, char **argv)
{
	int i, r, ret = 1;
	int badopt;
	char *outfile = NULL;
	int base64 = 0;
	int hex = 0;
	BIO *out = NULL;
	int num = -1;
#ifndef OPENSSL_NO_ENGINE
	char *engine = NULL;
#endif

	if (!load_config(bio_err, NULL))
		goto err;

	badopt = 0;
	i = 0;
	while (!badopt && argv[++i] != NULL) {
		if (strcmp(argv[i], "-out") == 0) {
			if ((argv[i + 1] != NULL) && (outfile == NULL))
				outfile = argv[++i];
			else
				badopt = 1;
		}
#ifndef OPENSSL_NO_ENGINE
		else if (strcmp(argv[i], "-engine") == 0) {
			if ((argv[i + 1] != NULL) && (engine == NULL))
				engine = argv[++i];
			else
				badopt = 1;
		}
#endif
		else if (strcmp(argv[i], "-base64") == 0) {
			if (!base64)
				base64 = 1;
			else
				badopt = 1;
		} else if (strcmp(argv[i], "-hex") == 0) {
			if (!hex)
				hex = 1;
			else
				badopt = 1;
		} else if (isdigit((unsigned char) argv[i][0])) {
			if (num < 0) {
				r = sscanf(argv[i], "%d", &num);
				if (r == 0 || num < 0)
					badopt = 1;
			} else
				badopt = 1;
		} else
			badopt = 1;
	}

	if (hex && base64)
		badopt = 1;

	if (num < 0)
		badopt = 1;

	if (badopt) {
		BIO_printf(bio_err, "Usage: rand [options] num\n");
		BIO_printf(bio_err, "where options are\n");
		BIO_printf(bio_err, "-out file             - write to file\n");
#ifndef OPENSSL_NO_ENGINE
		BIO_printf(bio_err, "-engine e             - use engine e, possibly a hardware device.\n");
#endif
		BIO_printf(bio_err, "-base64               - base64 encode output\n");
		BIO_printf(bio_err, "-hex                  - hex encode output\n");
		goto err;
	}
#ifndef OPENSSL_NO_ENGINE
	setup_engine(bio_err, engine, 0);
#endif

	out = BIO_new(BIO_s_file());
	if (out == NULL)
		goto err;
	if (outfile != NULL)
		r = BIO_write_filename(out, outfile);
	else {
		r = BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT);
	}
	if (r <= 0)
		goto err;

	if (base64) {
		BIO *b64 = BIO_new(BIO_f_base64());
		if (b64 == NULL)
			goto err;
		out = BIO_push(b64, out);
	}
	while (num > 0) {
		unsigned char buf[4096];
		int chunk;

		chunk = num;
		if (chunk > (int) sizeof(buf))
			chunk = sizeof buf;
		r = RAND_bytes(buf, chunk);
		if (r <= 0)
			goto err;
		if (!hex)
			BIO_write(out, buf, chunk);
		else {
			for (i = 0; i < chunk; i++)
				BIO_printf(out, "%02x", buf[i]);
		}
		num -= chunk;
	}
	if (hex)
		BIO_puts(out, "\n");
	(void) BIO_flush(out);

	ret = 0;

err:
	ERR_print_errors(bio_err);
	if (out)
		BIO_free_all(out);
	
	return (ret);
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/errstr.c0000644000175000017500000001023412360020706017364 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#include 
#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 

int errstr_main(int, char **);

int
errstr_main(int argc, char **argv)
{
	int i, ret = 0;
	char buf[256];
	unsigned long l;

	SSL_load_error_strings();

	if ((argc > 1) && (strcmp(argv[1], "-stats") == 0)) {
		BIO *out = NULL;

		out = BIO_new(BIO_s_file());
		if ((out != NULL) && BIO_set_fp(out, stdout, BIO_NOCLOSE)) {
			lh_ERR_STRING_DATA_node_stats_bio(
			    ERR_get_string_table(), out);
			lh_ERR_STRING_DATA_stats_bio(ERR_get_string_table(),
			    out);
			lh_ERR_STRING_DATA_node_usage_stats_bio(
			    ERR_get_string_table(), out);
		}
		if (out != NULL)
			BIO_free_all(out);
		argc--;
		argv++;
	}
	for (i = 1; i < argc; i++) {
		if (sscanf(argv[i], "%lx", &l)) {
			ERR_error_string_n(l, buf, sizeof buf);
			printf("%s\n", buf);
		} else {
			printf("%s: bad error code\n", argv[i]);
			printf("usage: errstr [-stats]  ...\n");
			ret++;
		}
	}
	
	return (ret);
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/rsautl.c0000644000175000017500000002250312360020706017357 0ustar  /* $OpenBSD: rsautl.c,v 1.21 2014/06/12 15:49:27 deraadt Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
 * project 2000.
 */
/* ====================================================================
 * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#include 


#include 

#include "apps.h"

#include 
#include 
#include 

#define RSA_SIGN 	1
#define RSA_VERIFY 	2
#define RSA_ENCRYPT 	3
#define RSA_DECRYPT 	4

#define KEY_PRIVKEY	1
#define KEY_PUBKEY	2
#define KEY_CERT	3

static void usage(void);

int rsautl_main(int argc, char **);

int 
rsautl_main(int argc, char **argv)
{
	ENGINE *e = NULL;
	BIO *in = NULL, *out = NULL;
	char *infile = NULL, *outfile = NULL;
#ifndef OPENSSL_NO_ENGINE
	char *engine = NULL;
#endif
	char *keyfile = NULL;
	char rsa_mode = RSA_VERIFY, key_type = KEY_PRIVKEY;
	int keyform = FORMAT_PEM;
	char need_priv = 0, badarg = 0, rev = 0;
	char hexdump = 0, asn1parse = 0;
	X509 *x;
	EVP_PKEY *pkey = NULL;
	RSA *rsa = NULL;
	unsigned char *rsa_in = NULL, *rsa_out = NULL, pad;
	char *passargin = NULL, *passin = NULL;
	int rsa_inlen, rsa_outlen = 0;
	int keysize;

	int ret = 1;

	argc--;
	argv++;

	if (!load_config(bio_err, NULL))
		goto end;

	ERR_load_crypto_strings();
	OpenSSL_add_all_algorithms();
	pad = RSA_PKCS1_PADDING;

	while (argc >= 1) {
		if (!strcmp(*argv, "-in")) {
			if (--argc < 1)
				badarg = 1;
			else
				infile = *(++argv);
		} else if (!strcmp(*argv, "-out")) {
			if (--argc < 1)
				badarg = 1;
			else
				outfile = *(++argv);
		} else if (!strcmp(*argv, "-inkey")) {
			if (--argc < 1)
				badarg = 1;
			else
				keyfile = *(++argv);
		} else if (!strcmp(*argv, "-passin")) {
			if (--argc < 1)
				badarg = 1;
			else
				passargin = *(++argv);
		} else if (strcmp(*argv, "-keyform") == 0) {
			if (--argc < 1)
				badarg = 1;
			else
				keyform = str2fmt(*(++argv));
#ifndef OPENSSL_NO_ENGINE
		} else if (!strcmp(*argv, "-engine")) {
			if (--argc < 1)
				badarg = 1;
			else
				engine = *(++argv);
#endif
		} else if (!strcmp(*argv, "-pubin")) {
			key_type = KEY_PUBKEY;
		} else if (!strcmp(*argv, "-certin")) {
			key_type = KEY_CERT;
		} else if (!strcmp(*argv, "-asn1parse"))
			asn1parse = 1;
		else if (!strcmp(*argv, "-hexdump"))
			hexdump = 1;
		else if (!strcmp(*argv, "-raw"))
			pad = RSA_NO_PADDING;
		else if (!strcmp(*argv, "-oaep"))
			pad = RSA_PKCS1_OAEP_PADDING;
		else if (!strcmp(*argv, "-ssl"))
			pad = RSA_SSLV23_PADDING;
		else if (!strcmp(*argv, "-pkcs"))
			pad = RSA_PKCS1_PADDING;
		else if (!strcmp(*argv, "-x931"))
			pad = RSA_X931_PADDING;
		else if (!strcmp(*argv, "-sign")) {
			rsa_mode = RSA_SIGN;
			need_priv = 1;
		} else if (!strcmp(*argv, "-verify"))
			rsa_mode = RSA_VERIFY;
		else if (!strcmp(*argv, "-rev"))
			rev = 1;
		else if (!strcmp(*argv, "-encrypt"))
			rsa_mode = RSA_ENCRYPT;
		else if (!strcmp(*argv, "-decrypt")) {
			rsa_mode = RSA_DECRYPT;
			need_priv = 1;
		} else
			badarg = 1;
		if (badarg) {
			usage();
			goto end;
		}
		argc--;
		argv++;
	}

	if (need_priv && (key_type != KEY_PRIVKEY)) {
		BIO_printf(bio_err, "A private key is needed for this operation\n");
		goto end;
	}
#ifndef OPENSSL_NO_ENGINE
	e = setup_engine(bio_err, engine, 0);
#endif
	if (!app_passwd(bio_err, passargin, NULL, &passin, NULL)) {
		BIO_printf(bio_err, "Error getting password\n");
		goto end;
	}

	switch (key_type) {
	case KEY_PRIVKEY:
		pkey = load_key(bio_err, keyfile, keyform, 0,
		    passin, e, "Private Key");
		break;

	case KEY_PUBKEY:
		pkey = load_pubkey(bio_err, keyfile, keyform, 0,
		    NULL, e, "Public Key");
		break;

	case KEY_CERT:
		x = load_cert(bio_err, keyfile, keyform,
		    NULL, e, "Certificate");
		if (x) {
			pkey = X509_get_pubkey(x);
			X509_free(x);
		}
		break;
	}

	if (!pkey) {
		return 1;
	}
	rsa = EVP_PKEY_get1_RSA(pkey);
	EVP_PKEY_free(pkey);

	if (!rsa) {
		BIO_printf(bio_err, "Error getting RSA key\n");
		ERR_print_errors(bio_err);
		goto end;
	}
	if (infile) {
		if (!(in = BIO_new_file(infile, "rb"))) {
			BIO_printf(bio_err, "Error Reading Input File\n");
			ERR_print_errors(bio_err);
			goto end;
		}
	} else
		in = BIO_new_fp(stdin, BIO_NOCLOSE);

	if (outfile) {
		if (!(out = BIO_new_file(outfile, "wb"))) {
			BIO_printf(bio_err, "Error Reading Output File\n");
			ERR_print_errors(bio_err);
			goto end;
		}
	} else {
		out = BIO_new_fp(stdout, BIO_NOCLOSE);
	}

	keysize = RSA_size(rsa);

	rsa_in = reallocarray(NULL, keysize, 2);
	rsa_out = malloc(keysize);

	/* Read the input data */
	rsa_inlen = BIO_read(in, rsa_in, keysize * 2);
	if (rsa_inlen <= 0) {
		BIO_printf(bio_err, "Error reading input Data\n");
		exit(1);
	}
	if (rev) {
		int i;
		unsigned char ctmp;
		for (i = 0; i < rsa_inlen / 2; i++) {
			ctmp = rsa_in[i];
			rsa_in[i] = rsa_in[rsa_inlen - 1 - i];
			rsa_in[rsa_inlen - 1 - i] = ctmp;
		}
	}
	switch (rsa_mode) {

	case RSA_VERIFY:
		rsa_outlen = RSA_public_decrypt(rsa_inlen, rsa_in, rsa_out, rsa, pad);
		break;

	case RSA_SIGN:
		rsa_outlen = RSA_private_encrypt(rsa_inlen, rsa_in, rsa_out, rsa, pad);
		break;

	case RSA_ENCRYPT:
		rsa_outlen = RSA_public_encrypt(rsa_inlen, rsa_in, rsa_out, rsa, pad);
		break;

	case RSA_DECRYPT:
		rsa_outlen = RSA_private_decrypt(rsa_inlen, rsa_in, rsa_out, rsa, pad);
		break;

	}

	if (rsa_outlen <= 0) {
		BIO_printf(bio_err, "RSA operation error\n");
		ERR_print_errors(bio_err);
		goto end;
	}
	ret = 0;
	if (asn1parse) {
		if (!ASN1_parse_dump(out, rsa_out, rsa_outlen, 1, -1)) {
			ERR_print_errors(bio_err);
		}
	} else if (hexdump)
		BIO_dump(out, (char *) rsa_out, rsa_outlen);
	else
		BIO_write(out, rsa_out, rsa_outlen);

end:
	RSA_free(rsa);
	BIO_free(in);
	BIO_free_all(out);
	free(rsa_in);
	free(rsa_out);
	free(passin);

	return ret;
}

static void 
usage()
{
	BIO_printf(bio_err, "Usage: rsautl [options]\n");
	BIO_printf(bio_err, "-in file        input file\n");
	BIO_printf(bio_err, "-out file       output file\n");
	BIO_printf(bio_err, "-inkey file     input key\n");
	BIO_printf(bio_err, "-keyform arg    private key format - default PEM\n");
	BIO_printf(bio_err, "-pubin          input is an RSA public\n");
	BIO_printf(bio_err, "-certin         input is a certificate carrying an RSA public key\n");
	BIO_printf(bio_err, "-ssl            use SSL v2 padding\n");
	BIO_printf(bio_err, "-raw            use no padding\n");
	BIO_printf(bio_err, "-pkcs           use PKCS#1 v1.5 padding (default)\n");
	BIO_printf(bio_err, "-oaep           use PKCS#1 OAEP\n");
	BIO_printf(bio_err, "-sign           sign with private key\n");
	BIO_printf(bio_err, "-verify         verify with public key\n");
	BIO_printf(bio_err, "-encrypt        encrypt with public key\n");
	BIO_printf(bio_err, "-decrypt        decrypt with private key\n");
	BIO_printf(bio_err, "-hexdump        hex dump output\n");
#ifndef OPENSSL_NO_ENGINE
	BIO_printf(bio_err, "-engine e       use engine e, possibly a hardware device.\n");
	BIO_printf(bio_err, "-passin arg    pass phrase source\n");
#endif

}

deps/libressl-pnacl-sys-2.1.6/libressl/apps/ts.c0000644000175000017500000006767412360020706016515 0ustar  /* $OpenBSD$ */
/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
 * project 2002.
 */
/* ====================================================================
 * Copyright (c) 2001 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#include 
#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 
#include 
#include 

/* Length of the nonce of the request in bits (must be a multiple of 8). */
#define	NONCE_LENGTH		64

/* Macro definitions for the configuration file. */
#define	ENV_OID_FILE		"oid_file"

/* Local function declarations. */

static ASN1_OBJECT *txt2obj(const char *oid);
static CONF *load_config_file(const char *configfile);

/* Query related functions. */
static int query_command(const char *data, char *digest,
    const EVP_MD * md, const char *policy, int no_nonce,
    int cert, const char *in, const char *out, int text);
static BIO *BIO_open_with_default(const char *file, const char *mode,
    FILE * default_fp);
static TS_REQ *create_query(BIO * data_bio, char *digest, const EVP_MD * md,
    const char *policy, int no_nonce, int cert);
static int create_digest(BIO * input, char *digest,
    const EVP_MD * md, unsigned char **md_value);
static ASN1_INTEGER *create_nonce(int bits);

/* Reply related functions. */
static int reply_command(CONF * conf, char *section, char *engine,
    char *queryfile, char *passin, char *inkey,
    char *signer, char *chain, const char *policy,
    char *in, int token_in, char *out, int token_out,
    int text);
static TS_RESP *read_PKCS7(BIO * in_bio);
static TS_RESP *create_response(CONF * conf, const char *section, char *engine,
    char *queryfile, char *passin, char *inkey,
    char *signer, char *chain, const char *policy);
static ASN1_INTEGER *serial_cb(TS_RESP_CTX * ctx, void *data);
static ASN1_INTEGER *next_serial(const char *serialfile);
static int save_ts_serial(const char *serialfile, ASN1_INTEGER * serial);

/* Verify related functions. */
static int verify_command(char *data, char *digest, char *queryfile,
    char *in, int token_in,
    char *ca_path, char *ca_file, char *untrusted);
static TS_VERIFY_CTX *create_verify_ctx(char *data, char *digest,
    char *queryfile,
    char *ca_path, char *ca_file,
    char *untrusted);
static X509_STORE *create_cert_store(char *ca_path, char *ca_file);
static int verify_cb(int ok, X509_STORE_CTX * ctx);

/* Main function definition. */
int ts_main(int, char **);

int
ts_main(int argc, char **argv)
{
	int ret = 1;
	char *configfile = NULL;
	char *section = NULL;
	CONF *conf = NULL;
	enum mode {
		CMD_NONE, CMD_QUERY, CMD_REPLY, CMD_VERIFY
	} mode = CMD_NONE;
	char *data = NULL;
	char *digest = NULL;
	const EVP_MD *md = NULL;
	char *policy = NULL;
	int no_nonce = 0;
	int cert = 0;
	char *in = NULL;
	char *out = NULL;
	int text = 0;
	char *queryfile = NULL;
	char *passin = NULL;	/* Password source. */
	char *password = NULL;	/* Password itself. */
	char *inkey = NULL;
	char *signer = NULL;
	char *chain = NULL;
	char *ca_path = NULL;
	char *ca_file = NULL;
	char *untrusted = NULL;
	char *engine = NULL;
	/* Input is ContentInfo instead of TimeStampResp. */
	int token_in = 0;
	/* Output is ContentInfo instead of TimeStampResp. */
	int token_out = 0;

	ERR_load_crypto_strings();

	if (!load_config(bio_err, NULL))
		goto cleanup;

	for (argc--, argv++; argc > 0; argc--, argv++) {
		if (strcmp(*argv, "-config") == 0) {
			if (argc-- < 1)
				goto usage;
			configfile = *++argv;
		} else if (strcmp(*argv, "-section") == 0) {
			if (argc-- < 1)
				goto usage;
			section = *++argv;
		} else if (strcmp(*argv, "-query") == 0) {
			if (mode != CMD_NONE)
				goto usage;
			mode = CMD_QUERY;
		} else if (strcmp(*argv, "-data") == 0) {
			if (argc-- < 1)
				goto usage;
			data = *++argv;
		} else if (strcmp(*argv, "-digest") == 0) {
			if (argc-- < 1)
				goto usage;
			digest = *++argv;
		} else if (strcmp(*argv, "-policy") == 0) {
			if (argc-- < 1)
				goto usage;
			policy = *++argv;
		} else if (strcmp(*argv, "-no_nonce") == 0) {
			no_nonce = 1;
		} else if (strcmp(*argv, "-cert") == 0) {
			cert = 1;
		} else if (strcmp(*argv, "-in") == 0) {
			if (argc-- < 1)
				goto usage;
			in = *++argv;
		} else if (strcmp(*argv, "-token_in") == 0) {
			token_in = 1;
		} else if (strcmp(*argv, "-out") == 0) {
			if (argc-- < 1)
				goto usage;
			out = *++argv;
		} else if (strcmp(*argv, "-token_out") == 0) {
			token_out = 1;
		} else if (strcmp(*argv, "-text") == 0) {
			text = 1;
		} else if (strcmp(*argv, "-reply") == 0) {
			if (mode != CMD_NONE)
				goto usage;
			mode = CMD_REPLY;
		} else if (strcmp(*argv, "-queryfile") == 0) {
			if (argc-- < 1)
				goto usage;
			queryfile = *++argv;
		} else if (strcmp(*argv, "-passin") == 0) {
			if (argc-- < 1)
				goto usage;
			passin = *++argv;
		} else if (strcmp(*argv, "-inkey") == 0) {
			if (argc-- < 1)
				goto usage;
			inkey = *++argv;
		} else if (strcmp(*argv, "-signer") == 0) {
			if (argc-- < 1)
				goto usage;
			signer = *++argv;
		} else if (strcmp(*argv, "-chain") == 0) {
			if (argc-- < 1)
				goto usage;
			chain = *++argv;
		} else if (strcmp(*argv, "-verify") == 0) {
			if (mode != CMD_NONE)
				goto usage;
			mode = CMD_VERIFY;
		} else if (strcmp(*argv, "-CApath") == 0) {
			if (argc-- < 1)
				goto usage;
			ca_path = *++argv;
		} else if (strcmp(*argv, "-CAfile") == 0) {
			if (argc-- < 1)
				goto usage;
			ca_file = *++argv;
		} else if (strcmp(*argv, "-untrusted") == 0) {
			if (argc-- < 1)
				goto usage;
			untrusted = *++argv;
		} else if (strcmp(*argv, "-engine") == 0) {
			if (argc-- < 1)
				goto usage;
			engine = *++argv;
		} else if ((md = EVP_get_digestbyname(*argv + 1)) != NULL) {
			/* empty. */
		} else
			goto usage;
	}

	/* Get the password if required. */
	if (mode == CMD_REPLY && passin &&
	    !app_passwd(bio_err, passin, NULL, &password, NULL)) {
		BIO_printf(bio_err, "Error getting password.\n");
		goto cleanup;
	}
	/*
	 * Check consistency of parameters and execute the appropriate
	 * function.
	 */
	switch (mode) {
	case CMD_NONE:
		goto usage;
	case CMD_QUERY:
		/*
		 * Data file and message imprint cannot be specified at the
		 * same time.
		 */
		ret = data != NULL && digest != NULL;
		if (ret)
			goto usage;
		/* Load the config file for possible policy OIDs. */
		conf = load_config_file(configfile);
		ret = !query_command(data, digest, md, policy, no_nonce, cert,
		    in, out, text);
		break;
	case CMD_REPLY:
		conf = load_config_file(configfile);
		if (in == NULL) {
			ret = !(queryfile != NULL && conf != NULL && !token_in);
			if (ret)
				goto usage;
		} else {
			/* 'in' and 'queryfile' are exclusive. */
			ret = !(queryfile == NULL);
			if (ret)
				goto usage;
		}

		ret = !reply_command(conf, section, engine, queryfile,
		    password, inkey, signer, chain, policy,
		    in, token_in, out, token_out, text);
		break;
	case CMD_VERIFY:
		ret = !(((queryfile && !data && !digest) ||
		    (!queryfile && data && !digest) ||
		    (!queryfile && !data && digest)) && in != NULL);
		if (ret)
			goto usage;

		ret = !verify_command(data, digest, queryfile, in, token_in,
		    ca_path, ca_file, untrusted);
	}

	goto cleanup;

usage:
	BIO_printf(bio_err, "usage:\n"
	    "ts -query [-config configfile] "
	    "[-data file_to_hash] [-digest digest_bytes]"
	    "[-md2|-md4|-md5|-sha|-sha1|-mdc2|-ripemd160] "
	    "[-policy object_id] [-no_nonce] [-cert] "
	    "[-in request.tsq] [-out request.tsq] [-text]\n");
	BIO_printf(bio_err, "or\n"
	    "ts -reply [-config configfile] [-section tsa_section] "
	    "[-queryfile request.tsq] [-passin password] "
	    "[-signer tsa_cert.pem] [-inkey private_key.pem] "
	    "[-chain certs_file.pem] [-policy object_id] "
	    "[-in response.tsr] [-token_in] "
	    "[-out response.tsr] [-token_out] [-text] [-engine id]\n");
	BIO_printf(bio_err, "or\n"
	    "ts -verify [-data file_to_hash] [-digest digest_bytes] "
	    "[-queryfile request.tsq] "
	    "-in response.tsr [-token_in] "
	    "-CApath ca_path -CAfile ca_file.pem "
	    "-untrusted cert_file.pem\n");

cleanup:
	/* Clean up. */
	NCONF_free(conf);
	free(password);
	OBJ_cleanup();

	return (ret);
}

/*
 * Configuration file-related function definitions.
 */

static ASN1_OBJECT *
txt2obj(const char *oid)
{
	ASN1_OBJECT *oid_obj = NULL;

	if (!(oid_obj = OBJ_txt2obj(oid, 0)))
		BIO_printf(bio_err, "cannot convert %s to OID\n", oid);

	return oid_obj;
}

static CONF *
load_config_file(const char *configfile)
{
	CONF *conf = NULL;
	long errorline = -1;

	if (!configfile)
		configfile = getenv("OPENSSL_CONF");
	if (!configfile)
		configfile = getenv("SSLEAY_CONF");

	if (configfile &&
	    (!(conf = NCONF_new(NULL)) ||
	    NCONF_load(conf, configfile, &errorline) <= 0)) {
		if (errorline <= 0)
			BIO_printf(bio_err, "error loading the config file "
			    "'%s'\n", configfile);
		else
			BIO_printf(bio_err, "error on line %ld of config file "
			    "'%s'\n", errorline, configfile);
	}
	if (conf != NULL) {
		const char *p;

		BIO_printf(bio_err, "Using configuration from %s\n",
		    configfile);
		p = NCONF_get_string(conf, NULL, ENV_OID_FILE);
		if (p != NULL) {
			BIO *oid_bio = BIO_new_file(p, "r");
			if (!oid_bio)
				ERR_print_errors(bio_err);
			else {
				OBJ_create_objects(oid_bio);
				BIO_free_all(oid_bio);
			}
		} else
			ERR_clear_error();
		if (!add_oid_section(bio_err, conf))
			ERR_print_errors(bio_err);
	}
	return conf;
}

/*
 * Query-related method definitions.
 */

static int
query_command(const char *data, char *digest, const EVP_MD * md,
    const char *policy, int no_nonce, int cert, const char *in,
    const char *out, int text)
{
	int ret = 0;
	TS_REQ *query = NULL;
	BIO *in_bio = NULL;
	BIO *data_bio = NULL;
	BIO *out_bio = NULL;

	/* Build query object either from file or from scratch. */
	if (in != NULL) {
		if ((in_bio = BIO_new_file(in, "rb")) == NULL)
			goto end;
		query = d2i_TS_REQ_bio(in_bio, NULL);
	} else {
		/* Open the file if no explicit digest bytes were specified. */
		if (!digest &&
		    !(data_bio = BIO_open_with_default(data, "rb", stdin)))
			goto end;
		/* Creating the query object. */
		query = create_query(data_bio, digest, md,
		    policy, no_nonce, cert);
		/* Saving the random number generator state. */
	}
	if (query == NULL)
		goto end;

	/* Write query either in ASN.1 or in text format. */
	if ((out_bio = BIO_open_with_default(out, "wb", stdout)) == NULL)
		goto end;
	if (text) {
		/* Text output. */
		if (!TS_REQ_print_bio(out_bio, query))
			goto end;
	} else {
		/* ASN.1 output. */
		if (!i2d_TS_REQ_bio(out_bio, query))
			goto end;
	}

	ret = 1;

end:
	ERR_print_errors(bio_err);

	/* Clean up. */
	BIO_free_all(in_bio);
	BIO_free_all(data_bio);
	BIO_free_all(out_bio);
	TS_REQ_free(query);

	return ret;
}

static BIO *
BIO_open_with_default(const char *file, const char *mode, FILE * default_fp)
{
	return file == NULL ? BIO_new_fp(default_fp, BIO_NOCLOSE) :
	    BIO_new_file(file, mode);
}

static TS_REQ *
create_query(BIO * data_bio, char *digest, const EVP_MD * md,
    const char *policy, int no_nonce, int cert)
{
	int ret = 0;
	TS_REQ *ts_req = NULL;
	int len;
	TS_MSG_IMPRINT *msg_imprint = NULL;
	X509_ALGOR *algo = NULL;
	unsigned char *data = NULL;
	ASN1_OBJECT *policy_obj = NULL;
	ASN1_INTEGER *nonce_asn1 = NULL;

	/* Setting default message digest. */
	if (!md && !(md = EVP_get_digestbyname("sha1")))
		goto err;

	/* Creating request object. */
	if (!(ts_req = TS_REQ_new()))
		goto err;

	/* Setting version. */
	if (!TS_REQ_set_version(ts_req, 1))
		goto err;

	/* Creating and adding MSG_IMPRINT object. */
	if (!(msg_imprint = TS_MSG_IMPRINT_new()))
		goto err;

	/* Adding algorithm. */
	if (!(algo = X509_ALGOR_new()))
		goto err;
	if (!(algo->algorithm = OBJ_nid2obj(EVP_MD_type(md))))
		goto err;
	if (!(algo->parameter = ASN1_TYPE_new()))
		goto err;
	algo->parameter->type = V_ASN1_NULL;
	if (!TS_MSG_IMPRINT_set_algo(msg_imprint, algo))
		goto err;

	/* Adding message digest. */
	if ((len = create_digest(data_bio, digest, md, &data)) == 0)
		goto err;
	if (!TS_MSG_IMPRINT_set_msg(msg_imprint, data, len))
		goto err;

	if (!TS_REQ_set_msg_imprint(ts_req, msg_imprint))
		goto err;

	/* Setting policy if requested. */
	if (policy && !(policy_obj = txt2obj(policy)))
		goto err;
	if (policy_obj && !TS_REQ_set_policy_id(ts_req, policy_obj))
		goto err;

	/* Setting nonce if requested. */
	if (!no_nonce && !(nonce_asn1 = create_nonce(NONCE_LENGTH)))
		goto err;
	if (nonce_asn1 && !TS_REQ_set_nonce(ts_req, nonce_asn1))
		goto err;

	/* Setting certificate request flag if requested. */
	if (!TS_REQ_set_cert_req(ts_req, cert))
		goto err;

	ret = 1;

err:
	if (!ret) {
		TS_REQ_free(ts_req);
		ts_req = NULL;
		BIO_printf(bio_err, "could not create query\n");
	}
	TS_MSG_IMPRINT_free(msg_imprint);
	X509_ALGOR_free(algo);
	free(data);
	ASN1_OBJECT_free(policy_obj);
	ASN1_INTEGER_free(nonce_asn1);

	return ts_req;
}

static int
create_digest(BIO * input, char *digest, const EVP_MD * md,
    unsigned char **md_value)
{
	int md_value_len;

	md_value_len = EVP_MD_size(md);
	if (md_value_len < 0)
		goto err;
	if (input) {
		/* Digest must be computed from an input file. */
		EVP_MD_CTX md_ctx;
		unsigned char buffer[4096];
		int length;

		*md_value = malloc(md_value_len);
		if (*md_value == 0)
			goto err;

		EVP_DigestInit(&md_ctx, md);
		while ((length = BIO_read(input, buffer, sizeof(buffer))) > 0) {
			EVP_DigestUpdate(&md_ctx, buffer, length);
		}
		EVP_DigestFinal(&md_ctx, *md_value, NULL);
	} else {
		/* Digest bytes are specified with digest. */
		long digest_len;
		*md_value = string_to_hex(digest, &digest_len);
		if (!*md_value || md_value_len != digest_len) {
			free(*md_value);
			*md_value = NULL;
			BIO_printf(bio_err, "bad digest, %d bytes "
			    "must be specified\n", md_value_len);
			goto err;
		}
	}

	return md_value_len;
err:
	return 0;
}

static ASN1_INTEGER *
create_nonce(int bits)
{
	unsigned char buf[20];
	ASN1_INTEGER *nonce = NULL;
	int len = (bits - 1) / 8 + 1;
	int i;

	/* Generating random byte sequence. */
	if (len > (int) sizeof(buf))
		goto err;
	if (RAND_bytes(buf, len) <= 0)
		goto err;

	/* Find the first non-zero byte and creating ASN1_INTEGER object. */
	for (i = 0; i < len && !buf[i]; ++i)
		;
	if (!(nonce = ASN1_INTEGER_new()))
		goto err;
	free(nonce->data);
	/* Allocate at least one byte. */
	nonce->length = len - i;
	if (!(nonce->data = malloc(nonce->length + 1)))
		goto err;
	memcpy(nonce->data, buf + i, nonce->length);

	return nonce;

err:
	BIO_printf(bio_err, "could not create nonce\n");
	ASN1_INTEGER_free(nonce);
	return NULL;
}
/*
 * Reply-related method definitions.
 */

static int
reply_command(CONF * conf, char *section, char *engine, char *queryfile,
    char *passin, char *inkey, char *signer, char *chain, const char *policy,
    char *in, int token_in, char *out, int token_out, int text)
{
	int ret = 0;
	TS_RESP *response = NULL;
	BIO *in_bio = NULL;
	BIO *query_bio = NULL;
	BIO *inkey_bio = NULL;
	BIO *signer_bio = NULL;
	BIO *out_bio = NULL;

	/* Build response object either from response or query. */
	if (in != NULL) {
		if ((in_bio = BIO_new_file(in, "rb")) == NULL)
			goto end;
		if (token_in) {
			/*
			 * We have a ContentInfo (PKCS7) object, add
			 * 'granted' status info around it.
			 */
			response = read_PKCS7(in_bio);
		} else {
			/* We have a ready-made TS_RESP object. */
			response = d2i_TS_RESP_bio(in_bio, NULL);
		}
	} else {
		response = create_response(conf, section, engine, queryfile,
		    passin, inkey, signer, chain,
		    policy);
		if (response)
			BIO_printf(bio_err, "Response has been generated.\n");
		else
			BIO_printf(bio_err, "Response is not generated.\n");
	}
	if (response == NULL)
		goto end;

	/* Write response either in ASN.1 or text format. */
	if ((out_bio = BIO_open_with_default(out, "wb", stdout)) == NULL)
		goto end;
	if (text) {
		/* Text output. */
		if (token_out) {
			TS_TST_INFO *tst_info = TS_RESP_get_tst_info(response);
			if (!TS_TST_INFO_print_bio(out_bio, tst_info))
				goto end;
		} else {
			if (!TS_RESP_print_bio(out_bio, response))
				goto end;
		}
	} else {
		/* ASN.1 DER output. */
		if (token_out) {
			PKCS7 *token = TS_RESP_get_token(response);
			if (!i2d_PKCS7_bio(out_bio, token))
				goto end;
		} else {
			if (!i2d_TS_RESP_bio(out_bio, response))
				goto end;
		}
	}

	ret = 1;

end:
	ERR_print_errors(bio_err);

	/* Clean up. */
	BIO_free_all(in_bio);
	BIO_free_all(query_bio);
	BIO_free_all(inkey_bio);
	BIO_free_all(signer_bio);
	BIO_free_all(out_bio);
	TS_RESP_free(response);

	return ret;
}

/* Reads a PKCS7 token and adds default 'granted' status info to it. */
static TS_RESP *
read_PKCS7(BIO * in_bio)
{
	int ret = 0;
	PKCS7 *token = NULL;
	TS_TST_INFO *tst_info = NULL;
	TS_RESP *resp = NULL;
	TS_STATUS_INFO *si = NULL;

	/* Read PKCS7 object and extract the signed time stamp info. */
	if (!(token = d2i_PKCS7_bio(in_bio, NULL)))
		goto end;
	if (!(tst_info = PKCS7_to_TS_TST_INFO(token)))
		goto end;

	/* Creating response object. */
	if (!(resp = TS_RESP_new()))
		goto end;

	/* Create granted status info. */
	if (!(si = TS_STATUS_INFO_new()))
		goto end;
	if (!(ASN1_INTEGER_set(si->status, TS_STATUS_GRANTED)))
		goto end;
	if (!TS_RESP_set_status_info(resp, si))
		goto end;

	/* Setting encapsulated token. */
	TS_RESP_set_tst_info(resp, token, tst_info);
	token = NULL;		/* Ownership is lost. */
	tst_info = NULL;	/* Ownership is lost. */

	ret = 1;
end:
	PKCS7_free(token);
	TS_TST_INFO_free(tst_info);
	if (!ret) {
		TS_RESP_free(resp);
		resp = NULL;
	}
	TS_STATUS_INFO_free(si);
	return resp;
}

static TS_RESP *
create_response(CONF * conf, const char *section, char *engine,
    char *queryfile, char *passin, char *inkey,
    char *signer, char *chain, const char *policy)
{
	int ret = 0;
	TS_RESP *response = NULL;
	BIO *query_bio = NULL;
	TS_RESP_CTX *resp_ctx = NULL;

	if (!(query_bio = BIO_new_file(queryfile, "rb")))
		goto end;

	/* Getting TSA configuration section. */
	if (!(section = TS_CONF_get_tsa_section(conf, section)))
		goto end;

	/* Setting up response generation context. */
	if (!(resp_ctx = TS_RESP_CTX_new()))
		goto end;

	/* Setting serial number provider callback. */
	if (!TS_CONF_set_serial(conf, section, serial_cb, resp_ctx))
		goto end;
#ifndef OPENSSL_NO_ENGINE
	/* Setting default OpenSSL engine. */
	if (!TS_CONF_set_crypto_device(conf, section, engine))
		goto end;
#endif

	/* Setting TSA signer certificate. */
	if (!TS_CONF_set_signer_cert(conf, section, signer, resp_ctx))
		goto end;

	/* Setting TSA signer certificate chain. */
	if (!TS_CONF_set_certs(conf, section, chain, resp_ctx))
		goto end;

	/* Setting TSA signer private key. */
	if (!TS_CONF_set_signer_key(conf, section, inkey, passin, resp_ctx))
		goto end;

	/* Setting default policy OID. */
	if (!TS_CONF_set_def_policy(conf, section, policy, resp_ctx))
		goto end;

	/* Setting acceptable policy OIDs. */
	if (!TS_CONF_set_policies(conf, section, resp_ctx))
		goto end;

	/* Setting the acceptable one-way hash algorithms. */
	if (!TS_CONF_set_digests(conf, section, resp_ctx))
		goto end;

	/* Setting guaranteed time stamp accuracy. */
	if (!TS_CONF_set_accuracy(conf, section, resp_ctx))
		goto end;

	/* Setting the precision of the time. */
	if (!TS_CONF_set_clock_precision_digits(conf, section, resp_ctx))
		goto end;

	/* Setting the ordering flaf if requested. */
	if (!TS_CONF_set_ordering(conf, section, resp_ctx))
		goto end;

	/* Setting the TSA name required flag if requested. */
	if (!TS_CONF_set_tsa_name(conf, section, resp_ctx))
		goto end;

	/* Setting the ESS cert id chain flag if requested. */
	if (!TS_CONF_set_ess_cert_id_chain(conf, section, resp_ctx))
		goto end;

	/* Creating the response. */
	if (!(response = TS_RESP_create_response(resp_ctx, query_bio)))
		goto end;

	ret = 1;
end:
	if (!ret) {
		TS_RESP_free(response);
		response = NULL;
	}
	TS_RESP_CTX_free(resp_ctx);
	BIO_free_all(query_bio);

	return response;
}

static ASN1_INTEGER *
serial_cb(TS_RESP_CTX * ctx, void *data)
{
	const char *serial_file = (const char *) data;
	ASN1_INTEGER *serial = next_serial(serial_file);

	if (!serial) {
		TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION,
		    "Error during serial number "
		    "generation.");
		TS_RESP_CTX_add_failure_info(ctx,
		    TS_INFO_ADD_INFO_NOT_AVAILABLE);
	} else
		save_ts_serial(serial_file, serial);

	return serial;
}

static ASN1_INTEGER *
next_serial(const char *serialfile)
{
	int ret = 0;
	BIO *in = NULL;
	ASN1_INTEGER *serial = NULL;
	BIGNUM *bn = NULL;

	if (!(serial = ASN1_INTEGER_new()))
		goto err;

	if (!(in = BIO_new_file(serialfile, "r"))) {
		ERR_clear_error();
		BIO_printf(bio_err, "Warning: could not open file %s for "
		    "reading, using serial number: 1\n", serialfile);
		if (!ASN1_INTEGER_set(serial, 1))
			goto err;
	} else {
		char buf[1024];
		if (!a2i_ASN1_INTEGER(in, serial, buf, sizeof(buf))) {
			BIO_printf(bio_err, "unable to load number from %s\n",
			    serialfile);
			goto err;
		}
		if (!(bn = ASN1_INTEGER_to_BN(serial, NULL)))
			goto err;
		ASN1_INTEGER_free(serial);
		serial = NULL;
		if (!BN_add_word(bn, 1))
			goto err;
		if (!(serial = BN_to_ASN1_INTEGER(bn, NULL)))
			goto err;
	}
	ret = 1;
err:
	if (!ret) {
		ASN1_INTEGER_free(serial);
		serial = NULL;
	}
	BIO_free_all(in);
	BN_free(bn);
	return serial;
}

static int
save_ts_serial(const char *serialfile, ASN1_INTEGER * serial)
{
	int ret = 0;
	BIO *out = NULL;

	if (!(out = BIO_new_file(serialfile, "w")))
		goto err;
	if (i2a_ASN1_INTEGER(out, serial) <= 0)
		goto err;
	if (BIO_puts(out, "\n") <= 0)
		goto err;
	ret = 1;
err:
	if (!ret)
		BIO_printf(bio_err, "could not save serial number to %s\n",
		    serialfile);
	BIO_free_all(out);
	return ret;
}

/*
 * Verify-related method definitions.
 */

static int
verify_command(char *data, char *digest, char *queryfile, char *in,
    int token_in, char *ca_path, char *ca_file, char *untrusted)
{
	BIO *in_bio = NULL;
	PKCS7 *token = NULL;
	TS_RESP *response = NULL;
	TS_VERIFY_CTX *verify_ctx = NULL;
	int ret = 0;

	/* Decode the token (PKCS7) or response (TS_RESP) files. */
	if (!(in_bio = BIO_new_file(in, "rb")))
		goto end;
	if (token_in) {
		if (!(token = d2i_PKCS7_bio(in_bio, NULL)))
			goto end;
	} else {
		if (!(response = d2i_TS_RESP_bio(in_bio, NULL)))
			goto end;
	}

	if (!(verify_ctx = create_verify_ctx(data, digest, queryfile,
	    ca_path, ca_file, untrusted)))
		goto end;

	/* Checking the token or response against the request. */
	ret = token_in ?
	    TS_RESP_verify_token(verify_ctx, token) :
	    TS_RESP_verify_response(verify_ctx, response);

end:
	printf("Verification: ");
	if (ret)
		printf("OK\n");
	else {
		printf("FAILED\n");
		/* Print errors, if there are any. */
		ERR_print_errors(bio_err);
	}

	/* Clean up. */
	BIO_free_all(in_bio);
	PKCS7_free(token);
	TS_RESP_free(response);
	TS_VERIFY_CTX_free(verify_ctx);
	return ret;
}

static TS_VERIFY_CTX *
create_verify_ctx(char *data, char *digest, char *queryfile, char *ca_path,
    char *ca_file, char *untrusted)
{
	TS_VERIFY_CTX *ctx = NULL;
	BIO *input = NULL;
	TS_REQ *request = NULL;
	int ret = 0;

	if (data != NULL || digest != NULL) {
		if (!(ctx = TS_VERIFY_CTX_new()))
			goto err;
		ctx->flags = TS_VFY_VERSION | TS_VFY_SIGNER;
		if (data != NULL) {
			ctx->flags |= TS_VFY_DATA;
			if (!(ctx->data = BIO_new_file(data, "rb")))
				goto err;
		} else if (digest != NULL) {
			long imprint_len;
			ctx->flags |= TS_VFY_IMPRINT;
			if (!(ctx->imprint = string_to_hex(digest,
				    &imprint_len))) {
				BIO_printf(bio_err, "invalid digest string\n");
				goto err;
			}
			ctx->imprint_len = imprint_len;
		}
	} else if (queryfile != NULL) {
		/*
		 * The request has just to be read, decoded and converted to
		 * a verify context object.
		 */
		if (!(input = BIO_new_file(queryfile, "rb")))
			goto err;
		if (!(request = d2i_TS_REQ_bio(input, NULL)))
			goto err;
		if (!(ctx = TS_REQ_to_TS_VERIFY_CTX(request, NULL)))
			goto err;
	} else
		return NULL;

	/* Add the signature verification flag and arguments. */
	ctx->flags |= TS_VFY_SIGNATURE;

	/* Initialising the X509_STORE object. */
	if (!(ctx->store = create_cert_store(ca_path, ca_file)))
		goto err;

	/* Loading untrusted certificates. */
	if (untrusted && !(ctx->certs = TS_CONF_load_certs(untrusted)))
		goto err;

	ret = 1;
err:
	if (!ret) {
		TS_VERIFY_CTX_free(ctx);
		ctx = NULL;
	}
	BIO_free_all(input);
	TS_REQ_free(request);
	return ctx;
}

static X509_STORE *
create_cert_store(char *ca_path, char *ca_file)
{
	X509_STORE *cert_ctx = NULL;
	X509_LOOKUP *lookup = NULL;
	int i;

	/* Creating the X509_STORE object. */
	cert_ctx = X509_STORE_new();

	/* Setting the callback for certificate chain verification. */
	X509_STORE_set_verify_cb(cert_ctx, verify_cb);

	/* Adding a trusted certificate directory source. */
	if (ca_path) {
		lookup = X509_STORE_add_lookup(cert_ctx,
		    X509_LOOKUP_hash_dir());
		if (lookup == NULL) {
			BIO_printf(bio_err, "memory allocation failure\n");
			goto err;
		}
		i = X509_LOOKUP_add_dir(lookup, ca_path, X509_FILETYPE_PEM);
		if (!i) {
			BIO_printf(bio_err, "Error loading directory %s\n",
			    ca_path);
			goto err;
		}
	}
	/* Adding a trusted certificate file source. */
	if (ca_file) {
		lookup = X509_STORE_add_lookup(cert_ctx, X509_LOOKUP_file());
		if (lookup == NULL) {
			BIO_printf(bio_err, "memory allocation failure\n");
			goto err;
		}
		i = X509_LOOKUP_load_file(lookup, ca_file, X509_FILETYPE_PEM);
		if (!i) {
			BIO_printf(bio_err, "Error loading file %s\n", ca_file);
			goto err;
		}
	}
	return cert_ctx;
err:
	X509_STORE_free(cert_ctx);
	return NULL;
}

static int
verify_cb(int ok, X509_STORE_CTX * ctx)
{
	/*
	char buf[256];

	if (!ok)
		{
		X509_NAME_oneline(X509_get_subject_name(ctx->current_cert),
				  buf, sizeof(buf));
		printf("%s\n", buf);
		printf("error %d at %d depth lookup: %s\n",
		       ctx->error, ctx->error_depth,
			X509_verify_cert_error_string(ctx->error));
		}
	*/

	return ok;
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/gendh.c0000644000175000017500000001401612360020706017132 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#include 

/* Until the key-gen callbacks are modified to use newer prototypes, we allow
 * deprecated functions for openssl-internal code */
#ifdef OPENSSL_NO_DEPRECATED
#undef OPENSSL_NO_DEPRECATED
#endif

#ifndef OPENSSL_NO_DH

#include 
#include 

#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define DEFBITS	512

static int dh_cb(int p, int n, BN_GENCB * cb);

int gendh_main(int, char **);

int
gendh_main(int argc, char **argv)
{
	BN_GENCB cb;
	DH *dh = NULL;
	int ret = 1, num = DEFBITS;
	int g = 2;
	char *outfile = NULL;
#ifndef OPENSSL_NO_ENGINE
	char *engine = NULL;
#endif
	BIO *out = NULL;

	BN_GENCB_set(&cb, dh_cb, bio_err);

	if (!load_config(bio_err, NULL))
		goto end;

	argv++;
	argc--;
	for (;;) {
		if (argc <= 0)
			break;
		if (strcmp(*argv, "-out") == 0) {
			if (--argc < 1)
				goto bad;
			outfile = *(++argv);
		} else if (strcmp(*argv, "-2") == 0)
			g = 2;
		/*
		 * else if (strcmp(*argv,"-3") == 0) g=3;
		 */
		else if (strcmp(*argv, "-5") == 0)
			g = 5;
#ifndef OPENSSL_NO_ENGINE
		else if (strcmp(*argv, "-engine") == 0) {
			if (--argc < 1)
				goto bad;
			engine = *(++argv);
		}
#endif
		else
			break;
		argv++;
		argc--;
	}
	if ((argc >= 1) && ((sscanf(*argv, "%d", &num) == 0) || (num < 0))) {
bad:
		BIO_printf(bio_err, "usage: gendh [args] [numbits]\n");
		BIO_printf(bio_err, " -out file - output the key to 'file\n");
		BIO_printf(bio_err, " -2        - use 2 as the generator value\n");
		/*
		 * BIO_printf(bio_err," -3        - use 3 as the generator
		 * value\n");
		 */
		BIO_printf(bio_err, " -5        - use 5 as the generator value\n");
#ifndef OPENSSL_NO_ENGINE
		BIO_printf(bio_err, " -engine e - use engine e, possibly a hardware device.\n");
#endif
		goto end;
	}
#ifndef OPENSSL_NO_ENGINE
	setup_engine(bio_err, engine, 0);
#endif

	out = BIO_new(BIO_s_file());
	if (out == NULL) {
		ERR_print_errors(bio_err);
		goto end;
	}
	if (outfile == NULL) {
		BIO_set_fp(out, stdout, BIO_NOCLOSE);
	} else {
		if (BIO_write_filename(out, outfile) <= 0) {
			perror(outfile);
			goto end;
		}
	}

	BIO_printf(bio_err, "Generating DH parameters, %d bit long safe prime, generator %d\n", num, g);
	BIO_printf(bio_err, "This is going to take a long time\n");

	if (((dh = DH_new()) == NULL) || !DH_generate_parameters_ex(dh, num, g, &cb))
		goto end;

	if (!PEM_write_bio_DHparams(out, dh))
		goto end;
	ret = 0;
end:
	if (ret != 0)
		ERR_print_errors(bio_err);
	if (out != NULL)
		BIO_free_all(out);
	if (dh != NULL)
		DH_free(dh);
	
	return (ret);
}

static int
dh_cb(int p, int n, BN_GENCB * cb)
{
	char c = '*';

	if (p == 0)
		c = '.';
	if (p == 1)
		c = '+';
	if (p == 2)
		c = '*';
	if (p == 3)
		c = '\n';
	BIO_write(cb->arg, &c, 1);
	(void) BIO_flush(cb->arg);
	return 1;
}
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/apps/s_apps.h0000644000175000017500000001574012360020706017344 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */
/* ====================================================================
 * Copyright (c) 1998-2001 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */
#include 
#include 

#define PORT            4433
#define PORT_STR        "4433"
#define PROTOCOL        "tcp"

int do_server(int port, int type, int *ret,
    int (*cb)(char *hostname, int s, unsigned char *context),
    unsigned char *context);
#ifdef HEADER_X509_H
int verify_callback(int ok, X509_STORE_CTX *ctx);
#endif
#ifdef HEADER_SSL_H
int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file);
int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key);
#endif
int init_client(int *sock, char *server, char *port, int type, int af);
int should_retry(int i);
int extract_port(char *str, short *port_ptr);
int extract_host_port(char *str, char **host_ptr, unsigned char *ip, char **p);

long bio_dump_callback(BIO *bio, int cmd, const char *argp, int argi,
    long argl, long ret);

#ifdef HEADER_SSL_H
void apps_ssl_info_callback(const SSL *s, int where, int ret);
void msg_cb(int write_p, int version, int content_type, const void *buf,
    size_t len, SSL *ssl, void *arg);
void tlsext_cb(SSL *s, int client_server, int type, unsigned char *data,
    int len, void *arg);
#endif

int generate_cookie_callback(SSL *ssl, unsigned char *cookie,
    unsigned int *cookie_len);
int verify_cookie_callback(SSL *ssl, unsigned char *cookie,
    unsigned int cookie_len);
deps/libressl-pnacl-sys-2.1.6/libressl/apps/dsaparam.c0000644000175000017500000002673412360020706017647 0ustar  /* $OpenBSD: dsaparam.c,v 1.31 2014/06/29 18:26:26 logan Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#include 	/* for OPENSSL_NO_DSA */

/* Until the key-gen callbacks are modified to use newer prototypes, we allow
 * deprecated functions for openssl-internal code */
#ifdef OPENSSL_NO_DEPRECATED
#undef OPENSSL_NO_DEPRECATED
#endif


#include 
#include 
#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 
#include 
#include 

/* -inform arg	- input format - default PEM (DER or PEM)
 * -outform arg - output format - default PEM
 * -in arg	- input file - default stdin
 * -out arg	- output file - default stdout
 * -noout
 * -text
 * -C
 * -noout
 * -genkey
 *  #ifdef GENCB_TEST
 * -timebomb n  - interrupt keygen after  seconds
 *  #endif
 */

#ifdef GENCB_TEST

static int stop_keygen_flag = 0;

static void
timebomb_sigalarm(int foo)
{
	stop_keygen_flag = 1;
}

#endif

static int dsa_cb(int p, int n, BN_GENCB * cb);

int dsaparam_main(int, char **);

int
dsaparam_main(int argc, char **argv)
{
	DSA *dsa = NULL;
	int i, badops = 0, text = 0;
	BIO *in = NULL, *out = NULL;
	int informat, outformat, noout = 0, C = 0, ret = 1;
	char *infile, *outfile, *prog;
	int numbits = -1, num, genkey = 0;
#ifndef OPENSSL_NO_ENGINE
	char *engine = NULL;
#endif
#ifdef GENCB_TEST
	const char *errstr = NULL;
	int timebomb = 0;
#endif

	if (!load_config(bio_err, NULL))
		goto end;

	infile = NULL;
	outfile = NULL;
	informat = FORMAT_PEM;
	outformat = FORMAT_PEM;

	prog = argv[0];
	argc--;
	argv++;
	while (argc >= 1) {
		if (strcmp(*argv, "-inform") == 0) {
			if (--argc < 1)
				goto bad;
			informat = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-outform") == 0) {
			if (--argc < 1)
				goto bad;
			outformat = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-in") == 0) {
			if (--argc < 1)
				goto bad;
			infile = *(++argv);
		} else if (strcmp(*argv, "-out") == 0) {
			if (--argc < 1)
				goto bad;
			outfile = *(++argv);
		}
#ifndef OPENSSL_NO_ENGINE
		else if (strcmp(*argv, "-engine") == 0) {
			if (--argc < 1)
				goto bad;
			engine = *(++argv);
		}
#endif
#ifdef GENCB_TEST
		else if (strcmp(*argv, "-timebomb") == 0) {
			if (--argc < 1)
				goto bad;
			timebomb = strtonum(*(++argv), 0, INT_MAX, &errstr);
			if (errstr)
				goto bad;
		}
#endif
		else if (strcmp(*argv, "-text") == 0)
			text = 1;
		else if (strcmp(*argv, "-C") == 0)
			C = 1;
		else if (strcmp(*argv, "-genkey") == 0) {
			genkey = 1;
		} else if (strcmp(*argv, "-noout") == 0)
			noout = 1;
		else if (sscanf(*argv, "%d", &num) == 1) {
			/* generate a key */
			numbits = num;
		} else {
			BIO_printf(bio_err, "unknown option %s\n", *argv);
			badops = 1;
			break;
		}
		argc--;
		argv++;
	}

	if (badops) {
bad:
		BIO_printf(bio_err, "%s [options] [bits] outfile\n", prog);
		BIO_printf(bio_err, "where options are\n");
		BIO_printf(bio_err, " -inform arg   input format - DER or PEM\n");
		BIO_printf(bio_err, " -outform arg  output format - DER or PEM\n");
		BIO_printf(bio_err, " -in arg       input file\n");
		BIO_printf(bio_err, " -out arg      output file\n");
		BIO_printf(bio_err, " -text         print as text\n");
		BIO_printf(bio_err, " -C            Output C code\n");
		BIO_printf(bio_err, " -noout        no output\n");
		BIO_printf(bio_err, " -genkey       generate a DSA key\n");
#ifndef OPENSSL_NO_ENGINE
		BIO_printf(bio_err, " -engine e     use engine e, possibly a hardware device.\n");
#endif
#ifdef GENCB_TEST
		BIO_printf(bio_err, " -timebomb n   interrupt keygen after  seconds\n");
#endif
		BIO_printf(bio_err, " number        number of bits to use for generating private key\n");
		goto end;
	}
	ERR_load_crypto_strings();

	in = BIO_new(BIO_s_file());
	out = BIO_new(BIO_s_file());
	if ((in == NULL) || (out == NULL)) {
		ERR_print_errors(bio_err);
		goto end;
	}
	if (infile == NULL)
		BIO_set_fp(in, stdin, BIO_NOCLOSE);
	else {
		if (BIO_read_filename(in, infile) <= 0) {
			perror(infile);
			goto end;
		}
	}
	if (outfile == NULL) {
		BIO_set_fp(out, stdout, BIO_NOCLOSE);
	} else {
		if (BIO_write_filename(out, outfile) <= 0) {
			perror(outfile);
			goto end;
		}
	}

#ifndef OPENSSL_NO_ENGINE
	setup_engine(bio_err, engine, 0);
#endif

	if (numbits > 0) {
		BN_GENCB cb;
		BN_GENCB_set(&cb, dsa_cb, bio_err);
		dsa = DSA_new();
		if (!dsa) {
			BIO_printf(bio_err, "Error allocating DSA object\n");
			goto end;
		}
		BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n", num);
		BIO_printf(bio_err, "This could take some time\n");
#ifdef GENCB_TEST
		if (timebomb > 0) {
			struct sigaction act;
			act.sa_handler = timebomb_sigalarm;
			act.sa_flags = 0;
			BIO_printf(bio_err, "(though I'll stop it if not done within %d secs)\n",
			    timebomb);
			if (sigaction(SIGALRM, &act, NULL) != 0) {
				BIO_printf(bio_err, "Error, couldn't set SIGALRM handler\n");
				goto end;
			}
			alarm(timebomb);
		}
#endif
		if (!DSA_generate_parameters_ex(dsa, num, NULL, 0, NULL, NULL, &cb)) {
#ifdef GENCB_TEST
			if (stop_keygen_flag) {
				BIO_printf(bio_err, "DSA key generation time-stopped\n");
				/* This is an asked-for behaviour! */
				ret = 0;
				goto end;
			}
#endif
			ERR_print_errors(bio_err);
			BIO_printf(bio_err, "Error, DSA key generation failed\n");
			goto end;
		}
	} else if (informat == FORMAT_ASN1)
		dsa = d2i_DSAparams_bio(in, NULL);
	else if (informat == FORMAT_PEM)
		dsa = PEM_read_bio_DSAparams(in, NULL, NULL, NULL);
	else {
		BIO_printf(bio_err, "bad input format specified\n");
		goto end;
	}
	if (dsa == NULL) {
		BIO_printf(bio_err, "unable to load DSA parameters\n");
		ERR_print_errors(bio_err);
		goto end;
	}
	if (text) {
		DSAparams_print(out, dsa);
	}
	if (C) {
		unsigned char *data;
		int l, len, bits_p;

		len = BN_num_bytes(dsa->p);
		bits_p = BN_num_bits(dsa->p);
		data = malloc(len + 20);
		if (data == NULL) {
			perror("malloc");
			goto end;
		}
		l = BN_bn2bin(dsa->p, data);
		printf("static unsigned char dsa%d_p[] = {", bits_p);
		for (i = 0; i < l; i++) {
			if ((i % 12) == 0)
				printf("\n\t");
			printf("0x%02X, ", data[i]);
		}
		printf("\n\t};\n");

		l = BN_bn2bin(dsa->q, data);
		printf("static unsigned char dsa%d_q[] = {", bits_p);
		for (i = 0; i < l; i++) {
			if ((i % 12) == 0)
				printf("\n\t");
			printf("0x%02X, ", data[i]);
		}
		printf("\n\t};\n");

		l = BN_bn2bin(dsa->g, data);
		printf("static unsigned char dsa%d_g[] = {", bits_p);
		for (i = 0; i < l; i++) {
			if ((i % 12) == 0)
				printf("\n\t");
			printf("0x%02X, ", data[i]);
		}
		free(data);
		printf("\n\t};\n\n");

		printf("DSA *get_dsa%d()\n\t{\n", bits_p);
		printf("\tDSA *dsa;\n\n");
		printf("\tif ((dsa = DSA_new()) == NULL) return(NULL);\n");
		printf("\tdsa->p = BN_bin2bn(dsa%d_p, sizeof(dsa%d_p), NULL);\n",
		    bits_p, bits_p);
		printf("\tdsa->q = BN_bin2bn(dsa%d_q, sizeof(dsa%d_q), NULL);\n",
		    bits_p, bits_p);
		printf("\tdsa->g = BN_bin2bn(dsa%d_g, sizeof(dsa%d_g), NULL);\n",
		    bits_p, bits_p);
		printf("\tif ((dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL))\n");
		printf("\t\t{ DSA_free(dsa); return(NULL); }\n");
		printf("\treturn(dsa);\n\t}\n");
	}
	if (!noout) {
		if (outformat == FORMAT_ASN1)
			i = i2d_DSAparams_bio(out, dsa);
		else if (outformat == FORMAT_PEM)
			i = PEM_write_bio_DSAparams(out, dsa);
		else {
			BIO_printf(bio_err, "bad output format specified for outfile\n");
			goto end;
		}
		if (!i) {
			BIO_printf(bio_err, "unable to write DSA parameters\n");
			ERR_print_errors(bio_err);
			goto end;
		}
	}
	if (genkey) {
		DSA *dsakey;

		if ((dsakey = DSAparams_dup(dsa)) == NULL)
			goto end;
		if (!DSA_generate_key(dsakey)) {
			ERR_print_errors(bio_err);
			DSA_free(dsakey);
			goto end;
		}
		if (outformat == FORMAT_ASN1)
			i = i2d_DSAPrivateKey_bio(out, dsakey);
		else if (outformat == FORMAT_PEM)
			i = PEM_write_bio_DSAPrivateKey(out, dsakey, NULL, NULL, 0, NULL, NULL);
		else {
			BIO_printf(bio_err, "bad output format specified for outfile\n");
			DSA_free(dsakey);
			goto end;
		}
		DSA_free(dsakey);
	}
	ret = 0;

end:
	if (in != NULL)
		BIO_free(in);
	if (out != NULL)
		BIO_free_all(out);
	if (dsa != NULL)
		DSA_free(dsa);
	
	return (ret);
}

static int
dsa_cb(int p, int n, BN_GENCB * cb)
{
	char c = '*';

	if (p == 0)
		c = '.';
	if (p == 1)
		c = '+';
	if (p == 2)
		c = '*';
	if (p == 3)
		c = '\n';
	BIO_write(cb->arg, &c, 1);
	(void) BIO_flush(cb->arg);
#ifdef GENCB_TEST
	if (stop_keygen_flag)
		return 0;
#endif
	return 1;
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/timeouts.h0000644000175000017500000000562412360020706017730 0ustar  /* $OpenBSD$ */
/*
 * DTLS implementation written by Nagendra Modadugu
 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
 */
/* ====================================================================
 * Copyright (c) 1999-2005 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#ifndef INCLUDED_TIMEOUTS_H
#define INCLUDED_TIMEOUTS_H

/* numbers in us */
#define DGRAM_RCV_TIMEOUT         250000
#define DGRAM_SND_TIMEOUT         250000

#endif /* ! INCLUDED_TIMEOUTS_H */
deps/libressl-pnacl-sys-2.1.6/libressl/apps/s_cb.c0000644000175000017500000005363512360020706016765 0ustar  /* $OpenBSD: s_cb.c,v 1.21 2014/06/12 15:49:27 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */
/* ====================================================================
 * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#include 

#include 

#include 
#include 
#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 

#include "s_apps.h"

#define	COOKIE_SECRET_LENGTH	16

int verify_depth = 0;
int verify_error = X509_V_OK;
int verify_return_error = 0;
unsigned char cookie_secret[COOKIE_SECRET_LENGTH];
int cookie_initialized = 0;

int
verify_callback(int ok, X509_STORE_CTX * ctx)
{
	X509 *err_cert;
	int err, depth;

	err_cert = X509_STORE_CTX_get_current_cert(ctx);
	err = X509_STORE_CTX_get_error(ctx);
	depth = X509_STORE_CTX_get_error_depth(ctx);

	BIO_printf(bio_err, "depth=%d ", depth);
	if (err_cert) {
		X509_NAME_print_ex(bio_err, X509_get_subject_name(err_cert),
		    0, XN_FLAG_ONELINE);
		BIO_puts(bio_err, "\n");
	} else
		BIO_puts(bio_err, "\n");
	if (!ok) {
		BIO_printf(bio_err, "verify error:num=%d:%s\n", err,
		    X509_verify_cert_error_string(err));
		if (verify_depth >= depth) {
			if (!verify_return_error)
				ok = 1;
			verify_error = X509_V_OK;
		} else {
			ok = 0;
			verify_error = X509_V_ERR_CERT_CHAIN_TOO_LONG;
		}
	}
	switch (err) {
	case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
		BIO_puts(bio_err, "issuer= ");
		X509_NAME_print_ex(bio_err, X509_get_issuer_name(err_cert),
		    0, XN_FLAG_ONELINE);
		BIO_puts(bio_err, "\n");
		break;
	case X509_V_ERR_CERT_NOT_YET_VALID:
	case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
		BIO_printf(bio_err, "notBefore=");
		ASN1_TIME_print(bio_err, X509_get_notBefore(err_cert));
		BIO_printf(bio_err, "\n");
		break;
	case X509_V_ERR_CERT_HAS_EXPIRED:
	case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
		BIO_printf(bio_err, "notAfter=");
		ASN1_TIME_print(bio_err, X509_get_notAfter(err_cert));
		BIO_printf(bio_err, "\n");
		break;
	case X509_V_ERR_NO_EXPLICIT_POLICY:
		policies_print(bio_err, ctx);
		break;
	}
	if (err == X509_V_OK && ok == 2)
		policies_print(bio_err, ctx);

	BIO_printf(bio_err, "verify return:%d\n", ok);
	return (ok);
}

int
set_cert_stuff(SSL_CTX * ctx, char *cert_file, char *key_file)
{
	if (cert_file != NULL) {
		/*
		SSL *ssl;
		X509 *x509;
		*/

		if (SSL_CTX_use_certificate_file(ctx, cert_file,
		    SSL_FILETYPE_PEM) <= 0) {
			BIO_printf(bio_err,
			    "unable to get certificate from '%s'\n", cert_file);
			ERR_print_errors(bio_err);
			return (0);
		}
		if (key_file == NULL)
			key_file = cert_file;
		if (SSL_CTX_use_PrivateKey_file(ctx, key_file,
		    SSL_FILETYPE_PEM) <= 0) {
			BIO_printf(bio_err,
			    "unable to get private key from '%s'\n", key_file);
			ERR_print_errors(bio_err);
			return (0);
		}
		/*
		In theory this is no longer needed
		ssl=SSL_new(ctx);
		x509=SSL_get_certificate(ssl);

		if (x509 != NULL) {
			EVP_PKEY *pktmp;
			pktmp = X509_get_pubkey(x509);
			EVP_PKEY_copy_parameters(pktmp,
						SSL_get_privatekey(ssl));
			EVP_PKEY_free(pktmp);
		}
		SSL_free(ssl);
		*/

		/*
		 * If we are using DSA, we can copy the parameters from the
		 * private key
		 */


		/*
		 * Now we know that a key and cert have been set against the
		 * SSL context
		 */
		if (!SSL_CTX_check_private_key(ctx)) {
			BIO_printf(bio_err,
			    "Private key does not match the certificate public key\n");
			return (0);
		}
	}
	return (1);
}

int
set_cert_key_stuff(SSL_CTX * ctx, X509 * cert, EVP_PKEY * key)
{
	if (cert == NULL)
		return 1;
	if (SSL_CTX_use_certificate(ctx, cert) <= 0) {
		BIO_printf(bio_err, "error setting certificate\n");
		ERR_print_errors(bio_err);
		return 0;
	}
	if (SSL_CTX_use_PrivateKey(ctx, key) <= 0) {
		BIO_printf(bio_err, "error setting private key\n");
		ERR_print_errors(bio_err);
		return 0;
	}
	/*
	 * Now we know that a key and cert have been set against the SSL
	 * context
	 */
	if (!SSL_CTX_check_private_key(ctx)) {
		BIO_printf(bio_err,
		    "Private key does not match the certificate public key\n");
		return 0;
	}
	return 1;
}

long
bio_dump_callback(BIO * bio, int cmd, const char *argp,
    int argi, long argl, long ret)
{
	BIO *out;

	out = (BIO *) BIO_get_callback_arg(bio);
	if (out == NULL)
		return (ret);

	if (cmd == (BIO_CB_READ | BIO_CB_RETURN)) {
		BIO_printf(out,
		    "read from %p [%p] (%lu bytes => %ld (0x%lX))\n",
		    (void *) bio, argp, (unsigned long) argi, ret, ret);
		BIO_dump(out, argp, (int) ret);
		return (ret);
	} else if (cmd == (BIO_CB_WRITE | BIO_CB_RETURN)) {
		BIO_printf(out,
		    "write to %p [%p] (%lu bytes => %ld (0x%lX))\n",
		    (void *) bio, argp, (unsigned long) argi, ret, ret);
		BIO_dump(out, argp, (int) ret);
	}
	return (ret);
}

void
apps_ssl_info_callback(const SSL * s, int where, int ret)
{
	const char *str;
	int w;

	w = where & ~SSL_ST_MASK;

	if (w & SSL_ST_CONNECT)
		str = "SSL_connect";
	else if (w & SSL_ST_ACCEPT)
		str = "SSL_accept";
	else
		str = "undefined";

	if (where & SSL_CB_LOOP) {
		BIO_printf(bio_err, "%s:%s\n", str, SSL_state_string_long(s));
	} else if (where & SSL_CB_ALERT) {
		str = (where & SSL_CB_READ) ? "read" : "write";
		BIO_printf(bio_err, "SSL3 alert %s:%s:%s\n", str,
		    SSL_alert_type_string_long(ret),
		    SSL_alert_desc_string_long(ret));
	} else if (where & SSL_CB_EXIT) {
		if (ret == 0)
			BIO_printf(bio_err, "%s:failed in %s\n",
			    str, SSL_state_string_long(s));
		else if (ret < 0) {
			BIO_printf(bio_err, "%s:error in %s\n",
			    str, SSL_state_string_long(s));
		}
	}
}


void
msg_cb(int write_p, int version, int content_type, const void *buf, size_t len, SSL * ssl, void *arg)
{
	BIO *bio = arg;
	const char *str_write_p, *str_version, *str_content_type = "",
	    *str_details1 = "", *str_details2 = "";

	str_write_p = write_p ? ">>>" : "<<<";

	switch (version) {
	case SSL2_VERSION:
		str_version = "SSL 2.0";
		break;
	case SSL3_VERSION:
		str_version = "SSL 3.0 ";
		break;
	case TLS1_VERSION:
		str_version = "TLS 1.0 ";
		break;
	case TLS1_1_VERSION:
		str_version = "TLS 1.1 ";
		break;
	case TLS1_2_VERSION:
		str_version = "TLS 1.2 ";
		break;
	case DTLS1_VERSION:
		str_version = "DTLS 1.0 ";
		break;
	case DTLS1_BAD_VER:
		str_version = "DTLS 1.0 (bad) ";
		break;
	default:
		str_version = "???";
	}

	if (version == SSL2_VERSION) {
		str_details1 = "???";

		if (len > 0) {
			switch (((const unsigned char *) buf)[0]) {
			case 0:
				str_details1 = ", ERROR:";
				str_details2 = " ???";
				if (len >= 3) {
					unsigned err = (((const unsigned char *) buf)[1] << 8) + ((const unsigned char *) buf)[2];

					switch (err) {
					case 0x0001:
						str_details2 = " NO-CIPHER-ERROR";
						break;
					case 0x0002:
						str_details2 = " NO-CERTIFICATE-ERROR";
						break;
					case 0x0004:
						str_details2 = " BAD-CERTIFICATE-ERROR";
						break;
					case 0x0006:
						str_details2 = " UNSUPPORTED-CERTIFICATE-TYPE-ERROR";
						break;
					}
				}
				break;
			case 1:
				str_details1 = ", CLIENT-HELLO";
				break;
			case 2:
				str_details1 = ", CLIENT-MASTER-KEY";
				break;
			case 3:
				str_details1 = ", CLIENT-FINISHED";
				break;
			case 4:
				str_details1 = ", SERVER-HELLO";
				break;
			case 5:
				str_details1 = ", SERVER-VERIFY";
				break;
			case 6:
				str_details1 = ", SERVER-FINISHED";
				break;
			case 7:
				str_details1 = ", REQUEST-CERTIFICATE";
				break;
			case 8:
				str_details1 = ", CLIENT-CERTIFICATE";
				break;
			}
		}
	}
	if (version == SSL3_VERSION || version == TLS1_VERSION ||
	    version == TLS1_1_VERSION || version == TLS1_2_VERSION ||
	    version == DTLS1_VERSION || version == DTLS1_BAD_VER) {
		switch (content_type) {
		case 20:
			str_content_type = "ChangeCipherSpec";
			break;
		case 21:
			str_content_type = "Alert";
			break;
		case 22:
			str_content_type = "Handshake";
			break;
		}

		if (content_type == 21) {	/* Alert */
			str_details1 = ", ???";

			if (len == 2) {
				switch (((const unsigned char *) buf)[0]) {
				case 1:
					str_details1 = ", warning";
					break;
				case 2:
					str_details1 = ", fatal";
					break;
				}

				str_details2 = " ???";
				switch (((const unsigned char *) buf)[1]) {
				case 0:
					str_details2 = " close_notify";
					break;
				case 10:
					str_details2 = " unexpected_message";
					break;
				case 20:
					str_details2 = " bad_record_mac";
					break;
				case 21:
					str_details2 = " decryption_failed";
					break;
				case 22:
					str_details2 = " record_overflow";
					break;
				case 30:
					str_details2 = " decompression_failure";
					break;
				case 40:
					str_details2 = " handshake_failure";
					break;
				case 42:
					str_details2 = " bad_certificate";
					break;
				case 43:
					str_details2 = " unsupported_certificate";
					break;
				case 44:
					str_details2 = " certificate_revoked";
					break;
				case 45:
					str_details2 = " certificate_expired";
					break;
				case 46:
					str_details2 = " certificate_unknown";
					break;
				case 47:
					str_details2 = " illegal_parameter";
					break;
				case 48:
					str_details2 = " unknown_ca";
					break;
				case 49:
					str_details2 = " access_denied";
					break;
				case 50:
					str_details2 = " decode_error";
					break;
				case 51:
					str_details2 = " decrypt_error";
					break;
				case 60:
					str_details2 = " export_restriction";
					break;
				case 70:
					str_details2 = " protocol_version";
					break;
				case 71:
					str_details2 = " insufficient_security";
					break;
				case 80:
					str_details2 = " internal_error";
					break;
				case 90:
					str_details2 = " user_canceled";
					break;
				case 100:
					str_details2 = " no_renegotiation";
					break;
				case 110:
					str_details2 = " unsupported_extension";
					break;
				case 111:
					str_details2 = " certificate_unobtainable";
					break;
				case 112:
					str_details2 = " unrecognized_name";
					break;
				case 113:
					str_details2 = " bad_certificate_status_response";
					break;
				case 114:
					str_details2 = " bad_certificate_hash_value";
					break;
				case 115:
					str_details2 = " unknown_psk_identity";
					break;
				}
			}
		}
		if (content_type == 22) {	/* Handshake */
			str_details1 = "???";

			if (len > 0) {
				switch (((const unsigned char *) buf)[0]) {
				case 0:
					str_details1 = ", HelloRequest";
					break;
				case 1:
					str_details1 = ", ClientHello";
					break;
				case 2:
					str_details1 = ", ServerHello";
					break;
				case 3:
					str_details1 = ", HelloVerifyRequest";
					break;
				case 11:
					str_details1 = ", Certificate";
					break;
				case 12:
					str_details1 = ", ServerKeyExchange";
					break;
				case 13:
					str_details1 = ", CertificateRequest";
					break;
				case 14:
					str_details1 = ", ServerHelloDone";
					break;
				case 15:
					str_details1 = ", CertificateVerify";
					break;
				case 16:
					str_details1 = ", ClientKeyExchange";
					break;
				case 20:
					str_details1 = ", Finished";
					break;
				}
			}
		}
	}
	BIO_printf(bio, "%s %s%s [length %04lx]%s%s\n", str_write_p,
	    str_version, str_content_type, (unsigned long) len,
	    str_details1, str_details2);

	if (len > 0) {
		size_t num, i;

		BIO_printf(bio, "   ");
		num = len;
#if 0
		if (num > 16)
			num = 16;
#endif
		for (i = 0; i < num; i++) {
			if (i % 16 == 0 && i > 0)
				BIO_printf(bio, "\n   ");
			BIO_printf(bio, " %02x",
			    ((const unsigned char *) buf)[i]);
		}
		if (i < len)
			BIO_printf(bio, " ...");
		BIO_printf(bio, "\n");
	}
	(void) BIO_flush(bio);
}

void
tlsext_cb(SSL * s, int client_server, int type, unsigned char *data, int len,
    void *arg)
{
	BIO *bio = arg;
	char *extname;

	switch (type) {
	case TLSEXT_TYPE_server_name:
		extname = "server name";
		break;

	case TLSEXT_TYPE_max_fragment_length:
		extname = "max fragment length";
		break;

	case TLSEXT_TYPE_client_certificate_url:
		extname = "client certificate URL";
		break;

	case TLSEXT_TYPE_trusted_ca_keys:
		extname = "trusted CA keys";
		break;

	case TLSEXT_TYPE_truncated_hmac:
		extname = "truncated HMAC";
		break;

	case TLSEXT_TYPE_status_request:
		extname = "status request";
		break;

	case TLSEXT_TYPE_user_mapping:
		extname = "user mapping";
		break;

	case TLSEXT_TYPE_client_authz:
		extname = "client authz";
		break;

	case TLSEXT_TYPE_server_authz:
		extname = "server authz";
		break;

	case TLSEXT_TYPE_cert_type:
		extname = "cert type";
		break;

	case TLSEXT_TYPE_elliptic_curves:
		extname = "elliptic curves";
		break;

	case TLSEXT_TYPE_ec_point_formats:
		extname = "EC point formats";
		break;

	case TLSEXT_TYPE_srp:
		extname = "SRP";
		break;

	case TLSEXT_TYPE_signature_algorithms:
		extname = "signature algorithms";
		break;

	case TLSEXT_TYPE_use_srtp:
		extname = "use SRTP";
		break;

	case TLSEXT_TYPE_heartbeat:
		extname = "heartbeat";
		break;

	case TLSEXT_TYPE_session_ticket:
		extname = "session ticket";
		break;

	case TLSEXT_TYPE_renegotiate:
		extname = "renegotiation info";
		break;

#ifdef TLSEXT_TYPE_next_proto_neg
	case TLSEXT_TYPE_next_proto_neg:
		extname = "next protocol";
		break;
#endif

	default:
		extname = "unknown";
		break;

	}

	BIO_printf(bio, "TLS %s extension \"%s\" (id=%d), len=%d\n",
	    client_server ? "server" : "client", extname, type, len);
	BIO_dump(bio, (char *) data, len);
	(void) BIO_flush(bio);
}

int
generate_cookie_callback(SSL * ssl, unsigned char *cookie,
    unsigned int *cookie_len)
{
	unsigned char *buffer, result[EVP_MAX_MD_SIZE];
	unsigned int length, resultlength;
	union {
		struct sockaddr sa;
		struct sockaddr_in s4;
		struct sockaddr_in6 s6;
	} peer;

	/* Initialize a random secret */
	if (!cookie_initialized) {
		if (!RAND_bytes(cookie_secret, COOKIE_SECRET_LENGTH)) {
			BIO_printf(bio_err,
			    "error setting random cookie secret\n");
			return 0;
		}
		cookie_initialized = 1;
	}
	/* Read peer information */
	(void) BIO_dgram_get_peer(SSL_get_rbio(ssl), &peer);

	/* Create buffer with peer's address and port */
	length = 0;
	switch (peer.sa.sa_family) {
	case AF_INET:
		length += sizeof(struct in_addr);
		length += sizeof(peer.s4.sin_port);
		break;
	case AF_INET6:
		length += sizeof(struct in6_addr);
		length += sizeof(peer.s6.sin6_port);
		break;
	default:
		OPENSSL_assert(0);
		break;
	}
	buffer = malloc(length);

	if (buffer == NULL) {
		BIO_printf(bio_err, "out of memory\n");
		return 0;
	}
	switch (peer.sa.sa_family) {
	case AF_INET:
		memcpy(buffer, &peer.s4.sin_port, sizeof(peer.s4.sin_port));
		memcpy(buffer + sizeof(peer.s4.sin_port),
		    &peer.s4.sin_addr, sizeof(struct in_addr));
		break;
	case AF_INET6:
		memcpy(buffer, &peer.s6.sin6_port, sizeof(peer.s6.sin6_port));
		memcpy(buffer + sizeof(peer.s6.sin6_port),
		    &peer.s6.sin6_addr, sizeof(struct in6_addr));
		break;
	default:
		OPENSSL_assert(0);
		break;
	}

	/* Calculate HMAC of buffer using the secret */
	HMAC(EVP_sha1(), cookie_secret, COOKIE_SECRET_LENGTH,
	    buffer, length, result, &resultlength);
	free(buffer);

	memcpy(cookie, result, resultlength);
	*cookie_len = resultlength;

	return 1;
}

int
verify_cookie_callback(SSL * ssl, unsigned char *cookie, unsigned int cookie_len)
{
	unsigned char *buffer, result[EVP_MAX_MD_SIZE];
	unsigned int length, resultlength;
	union {
		struct sockaddr sa;
		struct sockaddr_in s4;
		struct sockaddr_in6 s6;
	} peer;

	/* If secret isn't initialized yet, the cookie can't be valid */
	if (!cookie_initialized)
		return 0;

	/* Read peer information */
	(void) BIO_dgram_get_peer(SSL_get_rbio(ssl), &peer);

	/* Create buffer with peer's address and port */
	length = 0;
	switch (peer.sa.sa_family) {
	case AF_INET:
		length += sizeof(struct in_addr);
		length += sizeof(peer.s4.sin_port);
		break;
	case AF_INET6:
		length += sizeof(struct in6_addr);
		length += sizeof(peer.s6.sin6_port);
		break;
	default:
		OPENSSL_assert(0);
		break;
	}
	buffer = malloc(length);

	if (buffer == NULL) {
		BIO_printf(bio_err, "out of memory\n");
		return 0;
	}
	switch (peer.sa.sa_family) {
	case AF_INET:
		memcpy(buffer, &peer.s4.sin_port, sizeof(peer.s4.sin_port));
		memcpy(buffer + sizeof(peer.s4.sin_port),
		    &peer.s4.sin_addr, sizeof(struct in_addr));
		break;
	case AF_INET6:
		memcpy(buffer, &peer.s6.sin6_port, sizeof(peer.s6.sin6_port));
		memcpy(buffer + sizeof(peer.s6.sin6_port),
		    &peer.s6.sin6_addr, sizeof(struct in6_addr));
		break;
	default:
		OPENSSL_assert(0);
		break;
	}

	/* Calculate HMAC of buffer using the secret */
	HMAC(EVP_sha1(), cookie_secret, COOKIE_SECRET_LENGTH,
	    buffer, length, result, &resultlength);
	free(buffer);

	if (cookie_len == resultlength &&
	    memcmp(result, cookie, resultlength) == 0)
		return 1;

	return 0;
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/genpkey.c0000644000175000017500000002336012360020706017511 0ustar  /* $OpenBSD$ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
 * project 2006
 */
/* ====================================================================
 * Copyright (c) 2006 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#include 
#include 

#include "apps.h"

#include 
#include 
#include 

#ifndef OPENSSL_NO_ENGINE
#include 
#endif

static int 
init_keygen_file(BIO * err, EVP_PKEY_CTX ** pctx, const char *file,
    ENGINE * e);
static int genpkey_cb(EVP_PKEY_CTX * ctx);


int genpkey_main(int, char **);

int
genpkey_main(int argc, char **argv)
{
	ENGINE *e = NULL;
	char **args, *outfile = NULL;
	char *passarg = NULL;
	BIO *in = NULL, *out = NULL;
	const EVP_CIPHER *cipher = NULL;
	int outformat;
	int text = 0;
	EVP_PKEY *pkey = NULL;
	EVP_PKEY_CTX *ctx = NULL;
	char *pass = NULL;
	int badarg = 0;
	int ret = 1, rv;

	int do_param = 0;

	if (!load_config(bio_err, NULL))
		goto end;

	outformat = FORMAT_PEM;

	ERR_load_crypto_strings();
	OpenSSL_add_all_algorithms();
	args = argv + 1;
	while (!badarg && *args && *args[0] == '-') {
		if (!strcmp(*args, "-outform")) {
			if (args[1]) {
				args++;
				outformat = str2fmt(*args);
			} else
				badarg = 1;
		} else if (!strcmp(*args, "-pass")) {
			if (!args[1])
				goto bad;
			passarg = *(++args);
		}
#ifndef OPENSSL_NO_ENGINE
		else if (strcmp(*args, "-engine") == 0) {
			if (!args[1])
				goto bad;
			e = setup_engine(bio_err, *(++args), 0);
		}
#endif
		else if (!strcmp(*args, "-paramfile")) {
			if (!args[1])
				goto bad;
			args++;
			if (do_param == 1)
				goto bad;
			if (!init_keygen_file(bio_err, &ctx, *args, e))
				goto end;
		} else if (!strcmp(*args, "-out")) {
			if (args[1]) {
				args++;
				outfile = *args;
			} else
				badarg = 1;
		} else if (strcmp(*args, "-algorithm") == 0) {
			if (!args[1])
				goto bad;
			if (!init_gen_str(bio_err, &ctx, *(++args), e, do_param))
				goto end;
		} else if (strcmp(*args, "-pkeyopt") == 0) {
			if (!args[1])
				goto bad;
			if (!ctx) {
				BIO_puts(bio_err, "No keytype specified\n");
				goto bad;
			} else if (pkey_ctrl_string(ctx, *(++args)) <= 0) {
				BIO_puts(bio_err, "parameter setting error\n");
				ERR_print_errors(bio_err);
				goto end;
			}
		} else if (strcmp(*args, "-genparam") == 0) {
			if (ctx)
				goto bad;
			do_param = 1;
		} else if (strcmp(*args, "-text") == 0)
			text = 1;
		else {
			cipher = EVP_get_cipherbyname(*args + 1);
			if (!cipher) {
				BIO_printf(bio_err, "Unknown cipher %s\n",
				    *args + 1);
				badarg = 1;
			}
			if (do_param == 1)
				badarg = 1;
		}
		args++;
	}

	if (!ctx)
		badarg = 1;

	if (badarg) {
bad:
		BIO_printf(bio_err, "Usage: genpkey [options]\n");
		BIO_printf(bio_err, "where options may be\n");
		BIO_printf(bio_err, "-out file          output file\n");
		BIO_printf(bio_err, "-outform X         output format (DER or PEM)\n");
		BIO_printf(bio_err, "-pass arg          output file pass phrase source\n");
		BIO_printf(bio_err, "-          use cipher  to encrypt the key\n");
#ifndef OPENSSL_NO_ENGINE
		BIO_printf(bio_err, "-engine e          use engine e, possibly a hardware device.\n");
#endif
		BIO_printf(bio_err, "-paramfile file    parameters file\n");
		BIO_printf(bio_err, "-algorithm alg     the public key algorithm\n");
		BIO_printf(bio_err, "-pkeyopt opt:value set the public key algorithm option \n"
		    "                   to value \n");
		BIO_printf(bio_err, "-genparam          generate parameters, not key\n");
		BIO_printf(bio_err, "-text              print the in text\n");
		BIO_printf(bio_err, "NB: options order may be important!  See the manual page.\n");
		goto end;
	}
	if (!app_passwd(bio_err, passarg, NULL, &pass, NULL)) {
		BIO_puts(bio_err, "Error getting password\n");
		goto end;
	}
	if (outfile) {
		if (!(out = BIO_new_file(outfile, "wb"))) {
			BIO_printf(bio_err,
			    "Can't open output file %s\n", outfile);
			goto end;
		}
	} else {
		out = BIO_new_fp(stdout, BIO_NOCLOSE);
	}

	EVP_PKEY_CTX_set_cb(ctx, genpkey_cb);
	EVP_PKEY_CTX_set_app_data(ctx, bio_err);

	if (do_param) {
		if (EVP_PKEY_paramgen(ctx, &pkey) <= 0) {
			BIO_puts(bio_err, "Error generating parameters\n");
			ERR_print_errors(bio_err);
			goto end;
		}
	} else {
		if (EVP_PKEY_keygen(ctx, &pkey) <= 0) {
			BIO_puts(bio_err, "Error generating key\n");
			ERR_print_errors(bio_err);
			goto end;
		}
	}

	if (do_param)
		rv = PEM_write_bio_Parameters(out, pkey);
	else if (outformat == FORMAT_PEM)
		rv = PEM_write_bio_PrivateKey(out, pkey, cipher, NULL, 0,
		    NULL, pass);
	else if (outformat == FORMAT_ASN1)
		rv = i2d_PrivateKey_bio(out, pkey);
	else {
		BIO_printf(bio_err, "Bad format specified for key\n");
		goto end;
	}

	if (rv <= 0) {
		BIO_puts(bio_err, "Error writing key\n");
		ERR_print_errors(bio_err);
	}
	if (text) {
		if (do_param)
			rv = EVP_PKEY_print_params(out, pkey, 0, NULL);
		else
			rv = EVP_PKEY_print_private(out, pkey, 0, NULL);

		if (rv <= 0) {
			BIO_puts(bio_err, "Error printing key\n");
			ERR_print_errors(bio_err);
		}
	}
	ret = 0;

end:
	if (pkey)
		EVP_PKEY_free(pkey);
	if (ctx)
		EVP_PKEY_CTX_free(ctx);
	if (out)
		BIO_free_all(out);
	BIO_free(in);
	free(pass);

	return ret;
}

static int
init_keygen_file(BIO * err, EVP_PKEY_CTX ** pctx,
    const char *file, ENGINE * e)
{
	BIO *pbio;
	EVP_PKEY *pkey = NULL;
	EVP_PKEY_CTX *ctx = NULL;
	if (*pctx) {
		BIO_puts(err, "Parameters already set!\n");
		return 0;
	}
	pbio = BIO_new_file(file, "r");
	if (!pbio) {
		BIO_printf(err, "Can't open parameter file %s\n", file);
		return 0;
	}
	pkey = PEM_read_bio_Parameters(pbio, NULL);
	BIO_free(pbio);

	if (!pkey) {
		BIO_printf(bio_err, "Error reading parameter file %s\n", file);
		return 0;
	}
	ctx = EVP_PKEY_CTX_new(pkey, e);
	if (!ctx)
		goto err;
	if (EVP_PKEY_keygen_init(ctx) <= 0)
		goto err;
	EVP_PKEY_free(pkey);
	*pctx = ctx;
	return 1;

err:
	BIO_puts(err, "Error initializing context\n");
	ERR_print_errors(err);
	if (ctx)
		EVP_PKEY_CTX_free(ctx);
	if (pkey)
		EVP_PKEY_free(pkey);
	return 0;

}

int
init_gen_str(BIO * err, EVP_PKEY_CTX ** pctx,
    const char *algname, ENGINE * e, int do_param)
{
	EVP_PKEY_CTX *ctx = NULL;
	const EVP_PKEY_ASN1_METHOD *ameth;
	ENGINE *tmpeng = NULL;
	int pkey_id;

	if (*pctx) {
		BIO_puts(err, "Algorithm already set!\n");
		return 0;
	}
	ameth = EVP_PKEY_asn1_find_str(&tmpeng, algname, -1);

#ifndef OPENSSL_NO_ENGINE
	if (!ameth && e)
		ameth = ENGINE_get_pkey_asn1_meth_str(e, algname, -1);
#endif

	if (!ameth) {
		BIO_printf(bio_err, "Algorithm %s not found\n", algname);
		return 0;
	}
	ERR_clear_error();

	EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL, ameth);
#ifndef OPENSSL_NO_ENGINE
	if (tmpeng)
		ENGINE_finish(tmpeng);
#endif
	ctx = EVP_PKEY_CTX_new_id(pkey_id, e);

	if (!ctx)
		goto err;
	if (do_param) {
		if (EVP_PKEY_paramgen_init(ctx) <= 0)
			goto err;
	} else {
		if (EVP_PKEY_keygen_init(ctx) <= 0)
			goto err;
	}

	*pctx = ctx;
	return 1;

err:
	BIO_printf(err, "Error initializing %s context\n", algname);
	ERR_print_errors(err);
	if (ctx)
		EVP_PKEY_CTX_free(ctx);
	return 0;

}

static int
genpkey_cb(EVP_PKEY_CTX * ctx)
{
	char c = '*';
	BIO *b = EVP_PKEY_CTX_get_app_data(ctx);
	int p;
	p = EVP_PKEY_CTX_get_keygen_info(ctx, 0);
	if (p == 0)
		c = '.';
	if (p == 1)
		c = '+';
	if (p == 2)
		c = '*';
	if (p == 3)
		c = '\n';
	BIO_write(b, &c, 1);
	(void) BIO_flush(b);
	return 1;
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/speed.c0000644000175000017500000016313012360020706017147 0ustar  /* $OpenBSD: speed.c,v 1.49 2014/06/28 04:39:41 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */
/* ====================================================================
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 *
 * Portions of the attached software ("Contribution") are developed by
 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
 *
 * The Contribution is licensed pursuant to the OpenSSL open source
 * license provided above.
 *
 * The ECDH and ECDSA speed test software is originally written by
 * Sumit Gupta of Sun Microsystems Laboratories.
 *
 */

/* most of this code has been pilfered from my libdes speed.c program */

#ifndef OPENSSL_NO_SPEED

#define SECONDS		3
#define RSA_SECONDS	10
#define DSA_SECONDS	10
#define ECDSA_SECONDS   10
#define ECDH_SECONDS    10

/* 11-Sep-92 Andrew Daviel   Support for Silicon Graphics IRIX added */
/* 06-Apr-92 Luke Brennan    Support for VMS and add extra signal calls */

#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#ifndef OPENSSL_NO_AES
#include 
#endif
#ifndef OPENSSL_NO_BF
#include 
#endif
#ifndef OPENSSL_NO_CAST
#include 
#endif
#ifndef OPENSSL_NO_CAMELLIA
#include 
#endif
#ifndef OPENSSL_NO_DES
#include 
#endif
#include 
#include 
#include 
#ifndef OPENSSL_NO_HMAC
#include 
#endif
#ifndef OPENSSL_NO_IDEA
#include 
#endif
#ifndef OPENSSL_NO_MDC2
#include 
#endif
#ifndef OPENSSL_NO_MD4
#include 
#endif
#ifndef OPENSSL_NO_MD5
#include 
#endif
#ifndef OPENSSL_NO_RC2
#include 
#endif
#ifndef OPENSSL_NO_RC4
#include 
#endif
#ifndef OPENSSL_NO_RC5
#include 
#endif
#include 
#ifndef OPENSSL_NO_RIPEMD
#include 
#endif
#ifndef OPENSSL_NO_SHA
#include 
#endif
#ifndef OPENSSL_NO_WHIRLPOOL
#include 
#endif

#include "./testdsa.h"
#include "./testrsa.h"

#define BUFSIZE	((long)1024*8+1)
int run = 0;

static int mr = 0;
static int usertime = 1;

static double Time_F(int s);
static void print_message(const char *s, long num, int length);
static void 
pkey_print_message(const char *str, const char *str2,
    long num, int bits, int sec);
static void print_result(int alg, int run_no, int count, double time_used);
static int do_multi(int multi);

#define ALGOR_NUM	30
#define SIZE_NUM	5
#define RSA_NUM		4
#define DSA_NUM		3

#define EC_NUM       16
#define MAX_ECDH_SIZE 256

static const char *names[ALGOR_NUM] = {
	"md2", "mdc2", "md4", "md5", "hmac(md5)", "sha1", "rmd160", "rc4",
	"des cbc", "des ede3", "idea cbc", "seed cbc",
	"rc2 cbc", "rc5-32/12 cbc", "blowfish cbc", "cast cbc",
	"aes-128 cbc", "aes-192 cbc", "aes-256 cbc",
	"camellia-128 cbc", "camellia-192 cbc", "camellia-256 cbc",
	"evp", "sha256", "sha512", "whirlpool",
"aes-128 ige", "aes-192 ige", "aes-256 ige", "ghash"};
static double results[ALGOR_NUM][SIZE_NUM];
static int lengths[SIZE_NUM] = {16, 64, 256, 1024, 8 * 1024};
static double rsa_results[RSA_NUM][2];
static double dsa_results[DSA_NUM][2];
static double ecdsa_results[EC_NUM][2];
static double ecdh_results[EC_NUM][1];

static void sig_done(int sig);

static void
sig_done(int sig)
{
	signal(SIGALRM, sig_done);
	run = 0;
}

#define START	0
#define STOP	1


static double 
Time_F(int s)
{
	return app_tminterval(s, usertime);
}


static const int KDF1_SHA1_len = 20;
static void *
KDF1_SHA1(const void *in, size_t inlen, void *out, size_t * outlen)
{
#ifndef OPENSSL_NO_SHA
	if (*outlen < SHA_DIGEST_LENGTH)
		return NULL;
	else
		*outlen = SHA_DIGEST_LENGTH;
	return SHA1(in, inlen, out);
#else
	return NULL;
#endif				/* OPENSSL_NO_SHA */
}


int speed_main(int, char **);

int 
speed_main(int argc, char **argv)
{
	unsigned char *buf = NULL, *buf2 = NULL;
	int mret = 1;
	long count = 0, save_count = 0;
	int i, j, k;
	long rsa_count;
	unsigned rsa_num;
	unsigned char md[EVP_MAX_MD_SIZE];
#ifndef OPENSSL_NO_MDC2
	unsigned char mdc2[MDC2_DIGEST_LENGTH];
#endif
#ifndef OPENSSL_NO_MD4
	unsigned char md4[MD4_DIGEST_LENGTH];
#endif
#ifndef OPENSSL_NO_MD5
	unsigned char md5[MD5_DIGEST_LENGTH];
	unsigned char hmac[MD5_DIGEST_LENGTH];
#endif
#ifndef OPENSSL_NO_SHA
	unsigned char sha[SHA_DIGEST_LENGTH];
#ifndef OPENSSL_NO_SHA256
	unsigned char sha256[SHA256_DIGEST_LENGTH];
#endif
#ifndef OPENSSL_NO_SHA512
	unsigned char sha512[SHA512_DIGEST_LENGTH];
#endif
#endif
#ifndef OPENSSL_NO_WHIRLPOOL
	unsigned char whirlpool[WHIRLPOOL_DIGEST_LENGTH];
#endif
#ifndef OPENSSL_NO_RIPEMD
	unsigned char rmd160[RIPEMD160_DIGEST_LENGTH];
#endif
#ifndef OPENSSL_NO_RC4
	RC4_KEY rc4_ks;
#endif
#ifndef OPENSSL_NO_RC5
	RC5_32_KEY rc5_ks;
#endif
#ifndef OPENSSL_NO_RC2
	RC2_KEY rc2_ks;
#endif
#ifndef OPENSSL_NO_IDEA
	IDEA_KEY_SCHEDULE idea_ks;
#endif
#ifndef OPENSSL_NO_BF
	BF_KEY bf_ks;
#endif
#ifndef OPENSSL_NO_CAST
	CAST_KEY cast_ks;
#endif
	static const unsigned char key16[16] =
	{0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
	0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12};
#ifndef OPENSSL_NO_AES
	static const unsigned char key24[24] =
	{0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
		0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
	0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34};
	static const unsigned char key32[32] =
	{0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
		0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
		0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34,
	0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56};
#endif
#ifndef OPENSSL_NO_CAMELLIA
	static const unsigned char ckey24[24] =
	{0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
		0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
	0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34};
	static const unsigned char ckey32[32] =
	{0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
		0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
		0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34,
	0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56};
#endif
#ifndef OPENSSL_NO_AES
#define MAX_BLOCK_SIZE 128
#else
#define MAX_BLOCK_SIZE 64
#endif
	unsigned char DES_iv[8];
	unsigned char iv[2 * MAX_BLOCK_SIZE / 8];
#ifndef OPENSSL_NO_DES
	static DES_cblock key = {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0};
	static DES_cblock key2 = {0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12};
	static DES_cblock key3 = {0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34};
	DES_key_schedule sch;
	DES_key_schedule sch2;
	DES_key_schedule sch3;
#endif
#ifndef OPENSSL_NO_AES
	AES_KEY aes_ks1, aes_ks2, aes_ks3;
#endif
#ifndef OPENSSL_NO_CAMELLIA
	CAMELLIA_KEY camellia_ks1, camellia_ks2, camellia_ks3;
#endif
#define	D_MD2		0
#define	D_MDC2		1
#define	D_MD4		2
#define	D_MD5		3
#define	D_HMAC		4
#define	D_SHA1		5
#define D_RMD160	6
#define	D_RC4		7
#define	D_CBC_DES	8
#define	D_EDE3_DES	9
#define	D_CBC_IDEA	10
#define	D_CBC_SEED	11
#define	D_CBC_RC2	12
#define	D_CBC_RC5	13
#define	D_CBC_BF	14
#define	D_CBC_CAST	15
#define D_CBC_128_AES	16
#define D_CBC_192_AES	17
#define D_CBC_256_AES	18
#define D_CBC_128_CML   19
#define D_CBC_192_CML   20
#define D_CBC_256_CML   21
#define D_EVP		22
#define D_SHA256	23
#define D_SHA512	24
#define D_WHIRLPOOL	25
#define D_IGE_128_AES   26
#define D_IGE_192_AES   27
#define D_IGE_256_AES   28
#define D_GHASH		29
	double d = 0.0;
	long c[ALGOR_NUM][SIZE_NUM];
#define	R_DSA_512	0
#define	R_DSA_1024	1
#define	R_DSA_2048	2
#define	R_RSA_512	0
#define	R_RSA_1024	1
#define	R_RSA_2048	2
#define	R_RSA_4096	3

#define R_EC_P160    0
#define R_EC_P192    1
#define R_EC_P224    2
#define R_EC_P256    3
#define R_EC_P384    4
#define R_EC_P521    5
#define R_EC_K163    6
#define R_EC_K233    7
#define R_EC_K283    8
#define R_EC_K409    9
#define R_EC_K571    10
#define R_EC_B163    11
#define R_EC_B233    12
#define R_EC_B283    13
#define R_EC_B409    14
#define R_EC_B571    15

	RSA *rsa_key[RSA_NUM];
	long rsa_c[RSA_NUM][2];
	static unsigned int rsa_bits[RSA_NUM] = {512, 1024, 2048, 4096};
	static unsigned char *rsa_data[RSA_NUM] =
	{test512, test1024, test2048, test4096};
	static int rsa_data_length[RSA_NUM] = {
		sizeof(test512), sizeof(test1024),
	sizeof(test2048), sizeof(test4096)};
	DSA *dsa_key[DSA_NUM];
	long dsa_c[DSA_NUM][2];
	static unsigned int dsa_bits[DSA_NUM] = {512, 1024, 2048};
#ifndef OPENSSL_NO_EC
	/*
	 * We only test over the following curves as they are representative,
	 * To add tests over more curves, simply add the curve NID and curve
	 * name to the following arrays and increase the EC_NUM value
	 * accordingly.
	 */
	static unsigned int test_curves[EC_NUM] =
	{
		/* Prime Curves */
		NID_secp160r1,
		NID_X9_62_prime192v1,
		NID_secp224r1,
		NID_X9_62_prime256v1,
		NID_secp384r1,
		NID_secp521r1,
		/* Binary Curves */
		NID_sect163k1,
		NID_sect233k1,
		NID_sect283k1,
		NID_sect409k1,
		NID_sect571k1,
		NID_sect163r2,
		NID_sect233r1,
		NID_sect283r1,
		NID_sect409r1,
		NID_sect571r1
	};
	static const char *test_curves_names[EC_NUM] =
	{
		/* Prime Curves */
		"secp160r1",
		"nistp192",
		"nistp224",
		"nistp256",
		"nistp384",
		"nistp521",
		/* Binary Curves */
		"nistk163",
		"nistk233",
		"nistk283",
		"nistk409",
		"nistk571",
		"nistb163",
		"nistb233",
		"nistb283",
		"nistb409",
		"nistb571"
	};
	static int test_curves_bits[EC_NUM] =
	{
		160, 192, 224, 256, 384, 521,
		163, 233, 283, 409, 571,
		163, 233, 283, 409, 571
	};

#endif

	unsigned char ecdsasig[256];
	unsigned int ecdsasiglen;
	EC_KEY *ecdsa[EC_NUM];
	long ecdsa_c[EC_NUM][2];

	EC_KEY *ecdh_a[EC_NUM], *ecdh_b[EC_NUM];
	unsigned char secret_a[MAX_ECDH_SIZE], secret_b[MAX_ECDH_SIZE];
	int secret_size_a, secret_size_b;
	int ecdh_checks = 0;
	int secret_idx = 0;
	long ecdh_c[EC_NUM][2];

	int rsa_doit[RSA_NUM];
	int dsa_doit[DSA_NUM];
	int ecdsa_doit[EC_NUM];
	int ecdh_doit[EC_NUM];
	int doit[ALGOR_NUM];
	int pr_header = 0;
	const EVP_CIPHER *evp_cipher = NULL;
	const EVP_MD *evp_md = NULL;
	int decrypt = 0;
	int multi = 0;
	const char *errstr = NULL;

#ifndef TIMES
	usertime = -1;
#endif

	memset(results, 0, sizeof(results));
	memset(dsa_key, 0, sizeof(dsa_key));
	for (i = 0; i < EC_NUM; i++)
		ecdsa[i] = NULL;
	for (i = 0; i < EC_NUM; i++) {
		ecdh_a[i] = NULL;
		ecdh_b[i] = NULL;
	}

	if (!load_config(bio_err, NULL))
		goto end;

	memset(rsa_key, 0, sizeof(rsa_key));
	for (i = 0; i < RSA_NUM; i++)
		rsa_key[i] = NULL;

	if ((buf = malloc((int) BUFSIZE)) == NULL) {
		BIO_printf(bio_err, "out of memory\n");
		goto end;
	}
	if ((buf2 = malloc((int) BUFSIZE)) == NULL) {
		BIO_printf(bio_err, "out of memory\n");
		goto end;
	}
	memset(c, 0, sizeof(c));
	memset(DES_iv, 0, sizeof(DES_iv));
	memset(iv, 0, sizeof(iv));

	for (i = 0; i < ALGOR_NUM; i++)
		doit[i] = 0;
	for (i = 0; i < RSA_NUM; i++)
		rsa_doit[i] = 0;
	for (i = 0; i < DSA_NUM; i++)
		dsa_doit[i] = 0;
	for (i = 0; i < EC_NUM; i++)
		ecdsa_doit[i] = 0;
	for (i = 0; i < EC_NUM; i++)
		ecdh_doit[i] = 0;


	j = 0;
	argc--;
	argv++;
	while (argc) {
		if ((argc > 0) && (strcmp(*argv, "-elapsed") == 0)) {
			usertime = 0;
			j--;	/* Otherwise, -elapsed gets confused with an
				 * algorithm. */
		} else if ((argc > 0) && (strcmp(*argv, "-evp") == 0)) {
			argc--;
			argv++;
			if (argc == 0) {
				BIO_printf(bio_err, "no EVP given\n");
				goto end;
			}
			evp_cipher = EVP_get_cipherbyname(*argv);
			if (!evp_cipher) {
				evp_md = EVP_get_digestbyname(*argv);
			}
			if (!evp_cipher && !evp_md) {
				BIO_printf(bio_err, "%s is an unknown cipher or digest\n", *argv);
				goto end;
			}
			doit[D_EVP] = 1;
		} else if (argc > 0 && !strcmp(*argv, "-decrypt")) {
			decrypt = 1;
			j--;	/* Otherwise, -elapsed gets confused with an
				 * algorithm. */
		}
#ifndef OPENSSL_NO_ENGINE
		else if ((argc > 0) && (strcmp(*argv, "-engine") == 0)) {
			argc--;
			argv++;
			if (argc == 0) {
				BIO_printf(bio_err, "no engine given\n");
				goto end;
			}
			setup_engine(bio_err, *argv, 0);
			/*
			 * j will be increased again further down.  We just
			 * don't want speed to confuse an engine with an
			 * algorithm, especially when none is given (which
			 * means all of them should be run)
			 */
			j--;
		}
#endif
		else if ((argc > 0) && (strcmp(*argv, "-multi") == 0)) {
			argc--;
			argv++;
			if (argc == 0) {
				BIO_printf(bio_err, "no multi count given\n");
				goto end;
			}
			multi = strtonum(argv[0], 1, INT_MAX, &errstr);
			if (errstr) {
				BIO_printf(bio_err, "bad multi count: %s", errstr);
				goto end;
			}
			j--;	/* Otherwise, -mr gets confused with an
				 * algorithm. */
		}
		else if (argc > 0 && !strcmp(*argv, "-mr")) {
			mr = 1;
			j--;	/* Otherwise, -mr gets confused with an
				 * algorithm. */
		} else
#ifndef OPENSSL_NO_MDC2
		if (strcmp(*argv, "mdc2") == 0)
			doit[D_MDC2] = 1;
		else
#endif
#ifndef OPENSSL_NO_MD4
		if (strcmp(*argv, "md4") == 0)
			doit[D_MD4] = 1;
		else
#endif
#ifndef OPENSSL_NO_MD5
		if (strcmp(*argv, "md5") == 0)
			doit[D_MD5] = 1;
		else
#endif
#ifndef OPENSSL_NO_MD5
		if (strcmp(*argv, "hmac") == 0)
			doit[D_HMAC] = 1;
		else
#endif
#ifndef OPENSSL_NO_SHA
		if (strcmp(*argv, "sha1") == 0)
			doit[D_SHA1] = 1;
		else if (strcmp(*argv, "sha") == 0)
			doit[D_SHA1] = 1,
			    doit[D_SHA256] = 1,
			    doit[D_SHA512] = 1;
		else
#ifndef OPENSSL_NO_SHA256
		if (strcmp(*argv, "sha256") == 0)
			doit[D_SHA256] = 1;
		else
#endif
#ifndef OPENSSL_NO_SHA512
		if (strcmp(*argv, "sha512") == 0)
			doit[D_SHA512] = 1;
		else
#endif
#endif
#ifndef OPENSSL_NO_WHIRLPOOL
		if (strcmp(*argv, "whirlpool") == 0)
			doit[D_WHIRLPOOL] = 1;
		else
#endif
#ifndef OPENSSL_NO_RIPEMD
		if (strcmp(*argv, "ripemd") == 0)
			doit[D_RMD160] = 1;
		else if (strcmp(*argv, "rmd160") == 0)
			doit[D_RMD160] = 1;
		else if (strcmp(*argv, "ripemd160") == 0)
			doit[D_RMD160] = 1;
		else
#endif
#ifndef OPENSSL_NO_RC4
		if (strcmp(*argv, "rc4") == 0)
			doit[D_RC4] = 1;
		else
#endif
#ifndef OPENSSL_NO_DES
		if (strcmp(*argv, "des-cbc") == 0)
			doit[D_CBC_DES] = 1;
		else if (strcmp(*argv, "des-ede3") == 0)
			doit[D_EDE3_DES] = 1;
		else
#endif
#ifndef OPENSSL_NO_AES
		if (strcmp(*argv, "aes-128-cbc") == 0)
			doit[D_CBC_128_AES] = 1;
		else if (strcmp(*argv, "aes-192-cbc") == 0)
			doit[D_CBC_192_AES] = 1;
		else if (strcmp(*argv, "aes-256-cbc") == 0)
			doit[D_CBC_256_AES] = 1;
		else if (strcmp(*argv, "aes-128-ige") == 0)
			doit[D_IGE_128_AES] = 1;
		else if (strcmp(*argv, "aes-192-ige") == 0)
			doit[D_IGE_192_AES] = 1;
		else if (strcmp(*argv, "aes-256-ige") == 0)
			doit[D_IGE_256_AES] = 1;
		else
#endif
#ifndef OPENSSL_NO_CAMELLIA
		if (strcmp(*argv, "camellia-128-cbc") == 0)
			doit[D_CBC_128_CML] = 1;
		else if (strcmp(*argv, "camellia-192-cbc") == 0)
			doit[D_CBC_192_CML] = 1;
		else if (strcmp(*argv, "camellia-256-cbc") == 0)
			doit[D_CBC_256_CML] = 1;
		else
#endif
#if 0				/* was: #ifdef RSAref */
		if (strcmp(*argv, "rsaref") == 0) {
			RSA_set_default_openssl_method(RSA_PKCS1_RSAref());
			j--;
		} else
#endif
#ifndef RSA_NULL
		if (strcmp(*argv, "openssl") == 0) {
			RSA_set_default_method(RSA_PKCS1_SSLeay());
			j--;
		} else
#endif
		if (strcmp(*argv, "dsa512") == 0)
			dsa_doit[R_DSA_512] = 2;
		else if (strcmp(*argv, "dsa1024") == 0)
			dsa_doit[R_DSA_1024] = 2;
		else if (strcmp(*argv, "dsa2048") == 0)
			dsa_doit[R_DSA_2048] = 2;
		else if (strcmp(*argv, "rsa512") == 0)
			rsa_doit[R_RSA_512] = 2;
		else if (strcmp(*argv, "rsa1024") == 0)
			rsa_doit[R_RSA_1024] = 2;
		else if (strcmp(*argv, "rsa2048") == 0)
			rsa_doit[R_RSA_2048] = 2;
		else if (strcmp(*argv, "rsa4096") == 0)
			rsa_doit[R_RSA_4096] = 2;
		else
#ifndef OPENSSL_NO_RC2
		if (strcmp(*argv, "rc2-cbc") == 0)
			doit[D_CBC_RC2] = 1;
		else if (strcmp(*argv, "rc2") == 0)
			doit[D_CBC_RC2] = 1;
		else
#endif
#ifndef OPENSSL_NO_RC5
		if (strcmp(*argv, "rc5-cbc") == 0)
			doit[D_CBC_RC5] = 1;
		else if (strcmp(*argv, "rc5") == 0)
			doit[D_CBC_RC5] = 1;
		else
#endif
#ifndef OPENSSL_NO_IDEA
		if (strcmp(*argv, "idea-cbc") == 0)
			doit[D_CBC_IDEA] = 1;
		else if (strcmp(*argv, "idea") == 0)
			doit[D_CBC_IDEA] = 1;
		else
#endif
#ifndef OPENSSL_NO_BF
		if (strcmp(*argv, "bf-cbc") == 0)
			doit[D_CBC_BF] = 1;
		else if (strcmp(*argv, "blowfish") == 0)
			doit[D_CBC_BF] = 1;
		else if (strcmp(*argv, "bf") == 0)
			doit[D_CBC_BF] = 1;
		else
#endif
#ifndef OPENSSL_NO_CAST
		if (strcmp(*argv, "cast-cbc") == 0)
			doit[D_CBC_CAST] = 1;
		else if (strcmp(*argv, "cast") == 0)
			doit[D_CBC_CAST] = 1;
		else if (strcmp(*argv, "cast5") == 0)
			doit[D_CBC_CAST] = 1;
		else
#endif
#ifndef OPENSSL_NO_DES
		if (strcmp(*argv, "des") == 0) {
			doit[D_CBC_DES] = 1;
			doit[D_EDE3_DES] = 1;
		} else
#endif
#ifndef OPENSSL_NO_AES
		if (strcmp(*argv, "aes") == 0) {
			doit[D_CBC_128_AES] = 1;
			doit[D_CBC_192_AES] = 1;
			doit[D_CBC_256_AES] = 1;
		} else if (strcmp(*argv, "ghash") == 0) {
			doit[D_GHASH] = 1;
		} else
#endif
#ifndef OPENSSL_NO_CAMELLIA
		if (strcmp(*argv, "camellia") == 0) {
			doit[D_CBC_128_CML] = 1;
			doit[D_CBC_192_CML] = 1;
			doit[D_CBC_256_CML] = 1;
		} else
#endif
		if (strcmp(*argv, "rsa") == 0) {
			rsa_doit[R_RSA_512] = 1;
			rsa_doit[R_RSA_1024] = 1;
			rsa_doit[R_RSA_2048] = 1;
			rsa_doit[R_RSA_4096] = 1;
		} else
		if (strcmp(*argv, "dsa") == 0) {
			dsa_doit[R_DSA_512] = 1;
			dsa_doit[R_DSA_1024] = 1;
			dsa_doit[R_DSA_2048] = 1;
		} else
		if (strcmp(*argv, "ecdsap160") == 0)
			ecdsa_doit[R_EC_P160] = 2;
		else if (strcmp(*argv, "ecdsap192") == 0)
			ecdsa_doit[R_EC_P192] = 2;
		else if (strcmp(*argv, "ecdsap224") == 0)
			ecdsa_doit[R_EC_P224] = 2;
		else if (strcmp(*argv, "ecdsap256") == 0)
			ecdsa_doit[R_EC_P256] = 2;
		else if (strcmp(*argv, "ecdsap384") == 0)
			ecdsa_doit[R_EC_P384] = 2;
		else if (strcmp(*argv, "ecdsap521") == 0)
			ecdsa_doit[R_EC_P521] = 2;
		else if (strcmp(*argv, "ecdsak163") == 0)
			ecdsa_doit[R_EC_K163] = 2;
		else if (strcmp(*argv, "ecdsak233") == 0)
			ecdsa_doit[R_EC_K233] = 2;
		else if (strcmp(*argv, "ecdsak283") == 0)
			ecdsa_doit[R_EC_K283] = 2;
		else if (strcmp(*argv, "ecdsak409") == 0)
			ecdsa_doit[R_EC_K409] = 2;
		else if (strcmp(*argv, "ecdsak571") == 0)
			ecdsa_doit[R_EC_K571] = 2;
		else if (strcmp(*argv, "ecdsab163") == 0)
			ecdsa_doit[R_EC_B163] = 2;
		else if (strcmp(*argv, "ecdsab233") == 0)
			ecdsa_doit[R_EC_B233] = 2;
		else if (strcmp(*argv, "ecdsab283") == 0)
			ecdsa_doit[R_EC_B283] = 2;
		else if (strcmp(*argv, "ecdsab409") == 0)
			ecdsa_doit[R_EC_B409] = 2;
		else if (strcmp(*argv, "ecdsab571") == 0)
			ecdsa_doit[R_EC_B571] = 2;
		else if (strcmp(*argv, "ecdsa") == 0) {
			for (i = 0; i < EC_NUM; i++)
				ecdsa_doit[i] = 1;
		} else
		if (strcmp(*argv, "ecdhp160") == 0)
			ecdh_doit[R_EC_P160] = 2;
		else if (strcmp(*argv, "ecdhp192") == 0)
			ecdh_doit[R_EC_P192] = 2;
		else if (strcmp(*argv, "ecdhp224") == 0)
			ecdh_doit[R_EC_P224] = 2;
		else if (strcmp(*argv, "ecdhp256") == 0)
			ecdh_doit[R_EC_P256] = 2;
		else if (strcmp(*argv, "ecdhp384") == 0)
			ecdh_doit[R_EC_P384] = 2;
		else if (strcmp(*argv, "ecdhp521") == 0)
			ecdh_doit[R_EC_P521] = 2;
		else if (strcmp(*argv, "ecdhk163") == 0)
			ecdh_doit[R_EC_K163] = 2;
		else if (strcmp(*argv, "ecdhk233") == 0)
			ecdh_doit[R_EC_K233] = 2;
		else if (strcmp(*argv, "ecdhk283") == 0)
			ecdh_doit[R_EC_K283] = 2;
		else if (strcmp(*argv, "ecdhk409") == 0)
			ecdh_doit[R_EC_K409] = 2;
		else if (strcmp(*argv, "ecdhk571") == 0)
			ecdh_doit[R_EC_K571] = 2;
		else if (strcmp(*argv, "ecdhb163") == 0)
			ecdh_doit[R_EC_B163] = 2;
		else if (strcmp(*argv, "ecdhb233") == 0)
			ecdh_doit[R_EC_B233] = 2;
		else if (strcmp(*argv, "ecdhb283") == 0)
			ecdh_doit[R_EC_B283] = 2;
		else if (strcmp(*argv, "ecdhb409") == 0)
			ecdh_doit[R_EC_B409] = 2;
		else if (strcmp(*argv, "ecdhb571") == 0)
			ecdh_doit[R_EC_B571] = 2;
		else if (strcmp(*argv, "ecdh") == 0) {
			for (i = 0; i < EC_NUM; i++)
				ecdh_doit[i] = 1;
		} else
		{
			BIO_printf(bio_err, "Error: bad option or value\n");
			BIO_printf(bio_err, "\n");
			BIO_printf(bio_err, "Available values:\n");
#ifndef OPENSSL_NO_MDC2
			BIO_printf(bio_err, "mdc2     ");
#endif
#ifndef OPENSSL_NO_MD4
			BIO_printf(bio_err, "md4      ");
#endif
#ifndef OPENSSL_NO_MD5
			BIO_printf(bio_err, "md5      ");
#ifndef OPENSSL_NO_HMAC
			BIO_printf(bio_err, "hmac     ");
#endif
#endif
#ifndef OPENSSL_NO_SHA1
			BIO_printf(bio_err, "sha1     ");
#endif
#ifndef OPENSSL_NO_SHA256
			BIO_printf(bio_err, "sha256   ");
#endif
#ifndef OPENSSL_NO_SHA512
			BIO_printf(bio_err, "sha512   ");
#endif
#ifndef OPENSSL_NO_WHIRLPOOL
			BIO_printf(bio_err, "whirlpool");
#endif
#ifndef OPENSSL_NO_RIPEMD160
			BIO_printf(bio_err, "rmd160");
#endif
#if !defined(OPENSSL_NO_MD2) || !defined(OPENSSL_NO_MDC2) || \
    !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \
    !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160) || \
    !defined(OPENSSL_NO_WHIRLPOOL)
			BIO_printf(bio_err, "\n");
#endif

#ifndef OPENSSL_NO_IDEA
			BIO_printf(bio_err, "idea-cbc ");
#endif
#ifndef OPENSSL_NO_RC2
			BIO_printf(bio_err, "rc2-cbc  ");
#endif
#ifndef OPENSSL_NO_RC5
			BIO_printf(bio_err, "rc5-cbc  ");
#endif
#ifndef OPENSSL_NO_BF
			BIO_printf(bio_err, "bf-cbc");
#endif
#if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_SEED) || !defined(OPENSSL_NO_RC2) || \
    !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_RC5)
			BIO_printf(bio_err, "\n");
#endif
#ifndef OPENSSL_NO_DES
			BIO_printf(bio_err, "des-cbc  des-ede3 ");
#endif
#ifndef OPENSSL_NO_AES
			BIO_printf(bio_err, "aes-128-cbc aes-192-cbc aes-256-cbc ");
			BIO_printf(bio_err, "aes-128-ige aes-192-ige aes-256-ige ");
#endif
#ifndef OPENSSL_NO_CAMELLIA
			BIO_printf(bio_err, "\n");
			BIO_printf(bio_err, "camellia-128-cbc camellia-192-cbc camellia-256-cbc ");
#endif
#ifndef OPENSSL_NO_RC4
			BIO_printf(bio_err, "rc4");
#endif
			BIO_printf(bio_err, "\n");

			BIO_printf(bio_err, "rsa512   rsa1024  rsa2048  rsa4096\n");

			BIO_printf(bio_err, "dsa512   dsa1024  dsa2048\n");
			BIO_printf(bio_err, "ecdsap160 ecdsap192 ecdsap224 ecdsap256 ecdsap384 ecdsap521\n");
			BIO_printf(bio_err, "ecdsak163 ecdsak233 ecdsak283 ecdsak409 ecdsak571\n");
			BIO_printf(bio_err, "ecdsab163 ecdsab233 ecdsab283 ecdsab409 ecdsab571\n");
			BIO_printf(bio_err, "ecdsa\n");
			BIO_printf(bio_err, "ecdhp160  ecdhp192  ecdhp224  ecdhp256  ecdhp384  ecdhp521\n");
			BIO_printf(bio_err, "ecdhk163  ecdhk233  ecdhk283  ecdhk409  ecdhk571\n");
			BIO_printf(bio_err, "ecdhb163  ecdhb233  ecdhb283  ecdhb409  ecdhb571\n");
			BIO_printf(bio_err, "ecdh\n");

#ifndef OPENSSL_NO_IDEA
			BIO_printf(bio_err, "idea     ");
#endif
#ifndef OPENSSL_NO_RC2
			BIO_printf(bio_err, "rc2      ");
#endif
#ifndef OPENSSL_NO_DES
			BIO_printf(bio_err, "des      ");
#endif
#ifndef OPENSSL_NO_AES
			BIO_printf(bio_err, "aes      ");
#endif
#ifndef OPENSSL_NO_CAMELLIA
			BIO_printf(bio_err, "camellia ");
#endif
			BIO_printf(bio_err, "rsa      ");
#ifndef OPENSSL_NO_BF
			BIO_printf(bio_err, "blowfish");
#endif
#if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_SEED) || \
    !defined(OPENSSL_NO_RC2) || !defined(OPENSSL_NO_DES) || \
    !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_BF) || \
    !defined(OPENSSL_NO_AES) || !defined(OPENSSL_NO_CAMELLIA)
			BIO_printf(bio_err, "\n");
#endif

			BIO_printf(bio_err, "\n");
			BIO_printf(bio_err, "Available options:\n");
#if defined(TIMES) || defined(USE_TOD)
			BIO_printf(bio_err, "-elapsed        measure time in real time instead of CPU user time.\n");
#endif
#ifndef OPENSSL_NO_ENGINE
			BIO_printf(bio_err, "-engine e       use engine e, possibly a hardware device.\n");
#endif
			BIO_printf(bio_err, "-evp e          use EVP e.\n");
			BIO_printf(bio_err, "-decrypt        time decryption instead of encryption (only EVP).\n");
			BIO_printf(bio_err, "-mr             produce machine readable output.\n");
			BIO_printf(bio_err, "-multi n        run n benchmarks in parallel.\n");
			goto end;
		}
		argc--;
		argv++;
		j++;
	}

	if (multi && do_multi(multi))
		goto show_res;

	if (j == 0) {
		for (i = 0; i < ALGOR_NUM; i++) {
			if (i != D_EVP)
				doit[i] = 1;
		}
		for (i = 0; i < RSA_NUM; i++)
			rsa_doit[i] = 1;
		for (i = 0; i < DSA_NUM; i++)
			dsa_doit[i] = 1;
		for (i = 0; i < EC_NUM; i++)
			ecdsa_doit[i] = 1;
		for (i = 0; i < EC_NUM; i++)
			ecdh_doit[i] = 1;
	}
	for (i = 0; i < ALGOR_NUM; i++)
		if (doit[i])
			pr_header++;

	if (usertime == 0 && !mr)
		BIO_printf(bio_err, "You have chosen to measure elapsed time instead of user CPU time.\n");

	for (i = 0; i < RSA_NUM; i++) {
		const unsigned char *p;

		p = rsa_data[i];
		rsa_key[i] = d2i_RSAPrivateKey(NULL, &p, rsa_data_length[i]);
		if (rsa_key[i] == NULL) {
			BIO_printf(bio_err, "internal error loading RSA key number %d\n", i);
			goto end;
		}
#if 0
		else {
			BIO_printf(bio_err, mr ? "+RK:%d:"
			    : "Loaded RSA key, %d bit modulus and e= 0x",
			    BN_num_bits(rsa_key[i]->n));
			BN_print(bio_err, rsa_key[i]->e);
			BIO_printf(bio_err, "\n");
		}
#endif
	}

	dsa_key[0] = get_dsa512();
	dsa_key[1] = get_dsa1024();
	dsa_key[2] = get_dsa2048();

#ifndef OPENSSL_NO_DES
	DES_set_key_unchecked(&key, &sch);
	DES_set_key_unchecked(&key2, &sch2);
	DES_set_key_unchecked(&key3, &sch3);
#endif
#ifndef OPENSSL_NO_AES
	AES_set_encrypt_key(key16, 128, &aes_ks1);
	AES_set_encrypt_key(key24, 192, &aes_ks2);
	AES_set_encrypt_key(key32, 256, &aes_ks3);
#endif
#ifndef OPENSSL_NO_CAMELLIA
	Camellia_set_key(key16, 128, &camellia_ks1);
	Camellia_set_key(ckey24, 192, &camellia_ks2);
	Camellia_set_key(ckey32, 256, &camellia_ks3);
#endif
#ifndef OPENSSL_NO_IDEA
	idea_set_encrypt_key(key16, &idea_ks);
#endif
#ifndef OPENSSL_NO_RC4
	RC4_set_key(&rc4_ks, 16, key16);
#endif
#ifndef OPENSSL_NO_RC2
	RC2_set_key(&rc2_ks, 16, key16, 128);
#endif
#ifndef OPENSSL_NO_RC5
	RC5_32_set_key(&rc5_ks, 16, key16, 12);
#endif
#ifndef OPENSSL_NO_BF
	BF_set_key(&bf_ks, 16, key16);
#endif
#ifndef OPENSSL_NO_CAST
	CAST_set_key(&cast_ks, 16, key16);
#endif
	memset(rsa_c, 0, sizeof(rsa_c));
#define COND(c)	(run && count<0x7fffffff)
#define COUNT(d) (count)
	signal(SIGALRM, sig_done);

#ifndef OPENSSL_NO_MDC2
	if (doit[D_MDC2]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_MDC2], c[D_MDC2][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_MDC2][j]); count++)
				EVP_Digest(buf, (unsigned long) lengths[j], &(mdc2[0]), NULL, EVP_mdc2(), NULL);
			d = Time_F(STOP);
			print_result(D_MDC2, j, count, d);
		}
	}
#endif

#ifndef OPENSSL_NO_MD4
	if (doit[D_MD4]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_MD4], c[D_MD4][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_MD4][j]); count++)
				EVP_Digest(&(buf[0]), (unsigned long) lengths[j], &(md4[0]), NULL, EVP_md4(), NULL);
			d = Time_F(STOP);
			print_result(D_MD4, j, count, d);
		}
	}
#endif

#ifndef OPENSSL_NO_MD5
	if (doit[D_MD5]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_MD5], c[D_MD5][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_MD5][j]); count++)
				EVP_Digest(&(buf[0]), (unsigned long) lengths[j], &(md5[0]), NULL, EVP_get_digestbyname("md5"), NULL);
			d = Time_F(STOP);
			print_result(D_MD5, j, count, d);
		}
	}
#endif

#if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_HMAC)
	if (doit[D_HMAC]) {
		HMAC_CTX hctx;

		HMAC_CTX_init(&hctx);
		HMAC_Init_ex(&hctx, (unsigned char *) "This is a key...",
		    16, EVP_md5(), NULL);

		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_HMAC], c[D_HMAC][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_HMAC][j]); count++) {
				HMAC_Init_ex(&hctx, NULL, 0, NULL, NULL);
				HMAC_Update(&hctx, buf, lengths[j]);
				HMAC_Final(&hctx, &(hmac[0]), NULL);
			}
			d = Time_F(STOP);
			print_result(D_HMAC, j, count, d);
		}
		HMAC_CTX_cleanup(&hctx);
	}
#endif
#ifndef OPENSSL_NO_SHA
	if (doit[D_SHA1]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_SHA1], c[D_SHA1][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_SHA1][j]); count++)
				EVP_Digest(buf, (unsigned long) lengths[j], &(sha[0]), NULL, EVP_sha1(), NULL);
			d = Time_F(STOP);
			print_result(D_SHA1, j, count, d);
		}
	}
#ifndef OPENSSL_NO_SHA256
	if (doit[D_SHA256]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_SHA256], c[D_SHA256][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_SHA256][j]); count++)
				SHA256(buf, lengths[j], sha256);
			d = Time_F(STOP);
			print_result(D_SHA256, j, count, d);
		}
	}
#endif

#ifndef OPENSSL_NO_SHA512
	if (doit[D_SHA512]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_SHA512], c[D_SHA512][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_SHA512][j]); count++)
				SHA512(buf, lengths[j], sha512);
			d = Time_F(STOP);
			print_result(D_SHA512, j, count, d);
		}
	}
#endif
#endif

#ifndef OPENSSL_NO_WHIRLPOOL
	if (doit[D_WHIRLPOOL]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_WHIRLPOOL], c[D_WHIRLPOOL][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_WHIRLPOOL][j]); count++)
				WHIRLPOOL(buf, lengths[j], whirlpool);
			d = Time_F(STOP);
			print_result(D_WHIRLPOOL, j, count, d);
		}
	}
#endif

#ifndef OPENSSL_NO_RIPEMD
	if (doit[D_RMD160]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_RMD160], c[D_RMD160][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_RMD160][j]); count++)
				EVP_Digest(buf, (unsigned long) lengths[j], &(rmd160[0]), NULL, EVP_ripemd160(), NULL);
			d = Time_F(STOP);
			print_result(D_RMD160, j, count, d);
		}
	}
#endif
#ifndef OPENSSL_NO_RC4
	if (doit[D_RC4]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_RC4], c[D_RC4][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_RC4][j]); count++)
				RC4(&rc4_ks, (unsigned int) lengths[j],
				    buf, buf);
			d = Time_F(STOP);
			print_result(D_RC4, j, count, d);
		}
	}
#endif
#ifndef OPENSSL_NO_DES
	if (doit[D_CBC_DES]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_CBC_DES], c[D_CBC_DES][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_CBC_DES][j]); count++)
				DES_ncbc_encrypt(buf, buf, lengths[j], &sch,
				    &DES_iv, DES_ENCRYPT);
			d = Time_F(STOP);
			print_result(D_CBC_DES, j, count, d);
		}
	}
	if (doit[D_EDE3_DES]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_EDE3_DES], c[D_EDE3_DES][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_EDE3_DES][j]); count++)
				DES_ede3_cbc_encrypt(buf, buf, lengths[j],
				    &sch, &sch2, &sch3,
				    &DES_iv, DES_ENCRYPT);
			d = Time_F(STOP);
			print_result(D_EDE3_DES, j, count, d);
		}
	}
#endif
#ifndef OPENSSL_NO_AES
	if (doit[D_CBC_128_AES]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_CBC_128_AES], c[D_CBC_128_AES][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_CBC_128_AES][j]); count++)
				AES_cbc_encrypt(buf, buf,
				    (unsigned long) lengths[j], &aes_ks1,
				    iv, AES_ENCRYPT);
			d = Time_F(STOP);
			print_result(D_CBC_128_AES, j, count, d);
		}
	}
	if (doit[D_CBC_192_AES]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_CBC_192_AES], c[D_CBC_192_AES][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_CBC_192_AES][j]); count++)
				AES_cbc_encrypt(buf, buf,
				    (unsigned long) lengths[j], &aes_ks2,
				    iv, AES_ENCRYPT);
			d = Time_F(STOP);
			print_result(D_CBC_192_AES, j, count, d);
		}
	}
	if (doit[D_CBC_256_AES]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_CBC_256_AES], c[D_CBC_256_AES][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_CBC_256_AES][j]); count++)
				AES_cbc_encrypt(buf, buf,
				    (unsigned long) lengths[j], &aes_ks3,
				    iv, AES_ENCRYPT);
			d = Time_F(STOP);
			print_result(D_CBC_256_AES, j, count, d);
		}
	}
	if (doit[D_IGE_128_AES]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_IGE_128_AES], c[D_IGE_128_AES][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_IGE_128_AES][j]); count++)
				AES_ige_encrypt(buf, buf2,
				    (unsigned long) lengths[j], &aes_ks1,
				    iv, AES_ENCRYPT);
			d = Time_F(STOP);
			print_result(D_IGE_128_AES, j, count, d);
		}
	}
	if (doit[D_IGE_192_AES]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_IGE_192_AES], c[D_IGE_192_AES][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_IGE_192_AES][j]); count++)
				AES_ige_encrypt(buf, buf2,
				    (unsigned long) lengths[j], &aes_ks2,
				    iv, AES_ENCRYPT);
			d = Time_F(STOP);
			print_result(D_IGE_192_AES, j, count, d);
		}
	}
	if (doit[D_IGE_256_AES]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_IGE_256_AES], c[D_IGE_256_AES][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_IGE_256_AES][j]); count++)
				AES_ige_encrypt(buf, buf2,
				    (unsigned long) lengths[j], &aes_ks3,
				    iv, AES_ENCRYPT);
			d = Time_F(STOP);
			print_result(D_IGE_256_AES, j, count, d);
		}
	}
	if (doit[D_GHASH]) {
		GCM128_CONTEXT *ctx = CRYPTO_gcm128_new(&aes_ks1, (block128_f) AES_encrypt);
		CRYPTO_gcm128_setiv(ctx, (unsigned char *) "0123456789ab", 12);

		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_GHASH], c[D_GHASH][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_GHASH][j]); count++)
				CRYPTO_gcm128_aad(ctx, buf, lengths[j]);
			d = Time_F(STOP);
			print_result(D_GHASH, j, count, d);
		}
		CRYPTO_gcm128_release(ctx);
	}
#endif
#ifndef OPENSSL_NO_CAMELLIA
	if (doit[D_CBC_128_CML]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_CBC_128_CML], c[D_CBC_128_CML][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_CBC_128_CML][j]); count++)
				Camellia_cbc_encrypt(buf, buf,
				    (unsigned long) lengths[j], &camellia_ks1,
				    iv, CAMELLIA_ENCRYPT);
			d = Time_F(STOP);
			print_result(D_CBC_128_CML, j, count, d);
		}
	}
	if (doit[D_CBC_192_CML]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_CBC_192_CML], c[D_CBC_192_CML][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_CBC_192_CML][j]); count++)
				Camellia_cbc_encrypt(buf, buf,
				    (unsigned long) lengths[j], &camellia_ks2,
				    iv, CAMELLIA_ENCRYPT);
			d = Time_F(STOP);
			print_result(D_CBC_192_CML, j, count, d);
		}
	}
	if (doit[D_CBC_256_CML]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_CBC_256_CML], c[D_CBC_256_CML][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_CBC_256_CML][j]); count++)
				Camellia_cbc_encrypt(buf, buf,
				    (unsigned long) lengths[j], &camellia_ks3,
				    iv, CAMELLIA_ENCRYPT);
			d = Time_F(STOP);
			print_result(D_CBC_256_CML, j, count, d);
		}
	}
#endif
#ifndef OPENSSL_NO_IDEA
	if (doit[D_CBC_IDEA]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_CBC_IDEA], c[D_CBC_IDEA][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_CBC_IDEA][j]); count++)
				idea_cbc_encrypt(buf, buf,
				    (unsigned long) lengths[j], &idea_ks,
				    iv, IDEA_ENCRYPT);
			d = Time_F(STOP);
			print_result(D_CBC_IDEA, j, count, d);
		}
	}
#endif
#ifndef OPENSSL_NO_RC2
	if (doit[D_CBC_RC2]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_CBC_RC2], c[D_CBC_RC2][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_CBC_RC2][j]); count++)
				RC2_cbc_encrypt(buf, buf,
				    (unsigned long) lengths[j], &rc2_ks,
				    iv, RC2_ENCRYPT);
			d = Time_F(STOP);
			print_result(D_CBC_RC2, j, count, d);
		}
	}
#endif
#ifndef OPENSSL_NO_RC5
	if (doit[D_CBC_RC5]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_CBC_RC5], c[D_CBC_RC5][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_CBC_RC5][j]); count++)
				RC5_32_cbc_encrypt(buf, buf,
				    (unsigned long) lengths[j], &rc5_ks,
				    iv, RC5_ENCRYPT);
			d = Time_F(STOP);
			print_result(D_CBC_RC5, j, count, d);
		}
	}
#endif
#ifndef OPENSSL_NO_BF
	if (doit[D_CBC_BF]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_CBC_BF], c[D_CBC_BF][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_CBC_BF][j]); count++)
				BF_cbc_encrypt(buf, buf,
				    (unsigned long) lengths[j], &bf_ks,
				    iv, BF_ENCRYPT);
			d = Time_F(STOP);
			print_result(D_CBC_BF, j, count, d);
		}
	}
#endif
#ifndef OPENSSL_NO_CAST
	if (doit[D_CBC_CAST]) {
		for (j = 0; j < SIZE_NUM; j++) {
			print_message(names[D_CBC_CAST], c[D_CBC_CAST][j], lengths[j]);
			Time_F(START);
			for (count = 0, run = 1; COND(c[D_CBC_CAST][j]); count++)
				CAST_cbc_encrypt(buf, buf,
				    (unsigned long) lengths[j], &cast_ks,
				    iv, CAST_ENCRYPT);
			d = Time_F(STOP);
			print_result(D_CBC_CAST, j, count, d);
		}
	}
#endif

	if (doit[D_EVP]) {
		for (j = 0; j < SIZE_NUM; j++) {
			if (evp_cipher) {
				EVP_CIPHER_CTX ctx;
				int outl;

				names[D_EVP] = OBJ_nid2ln(evp_cipher->nid);
				/*
				 * -O3 -fschedule-insns messes up an
				 * optimization here!  names[D_EVP] somehow
				 * becomes NULL
				 */
				print_message(names[D_EVP], save_count,
				    lengths[j]);

				EVP_CIPHER_CTX_init(&ctx);
				if (decrypt)
					EVP_DecryptInit_ex(&ctx, evp_cipher, NULL, key16, iv);
				else
					EVP_EncryptInit_ex(&ctx, evp_cipher, NULL, key16, iv);
				EVP_CIPHER_CTX_set_padding(&ctx, 0);

				Time_F(START);
				if (decrypt)
					for (count = 0, run = 1; COND(save_count * 4 * lengths[0] / lengths[j]); count++)
						EVP_DecryptUpdate(&ctx, buf, &outl, buf, lengths[j]);
				else
					for (count = 0, run = 1; COND(save_count * 4 * lengths[0] / lengths[j]); count++)
						EVP_EncryptUpdate(&ctx, buf, &outl, buf, lengths[j]);
				if (decrypt)
					EVP_DecryptFinal_ex(&ctx, buf, &outl);
				else
					EVP_EncryptFinal_ex(&ctx, buf, &outl);
				d = Time_F(STOP);
				EVP_CIPHER_CTX_cleanup(&ctx);
			}
			if (evp_md) {
				names[D_EVP] = OBJ_nid2ln(evp_md->type);
				print_message(names[D_EVP], save_count,
				    lengths[j]);

				Time_F(START);
				for (count = 0, run = 1; COND(save_count * 4 * lengths[0] / lengths[j]); count++)
					EVP_Digest(buf, lengths[j], &(md[0]), NULL, evp_md, NULL);

				d = Time_F(STOP);
			}
			print_result(D_EVP, j, count, d);
		}
	}
	RAND_pseudo_bytes(buf, 36);
	for (j = 0; j < RSA_NUM; j++) {
		int ret;
		if (!rsa_doit[j])
			continue;
		ret = RSA_sign(NID_md5_sha1, buf, 36, buf2, &rsa_num, rsa_key[j]);
		if (ret == 0) {
			BIO_printf(bio_err, "RSA sign failure.  No RSA sign will be done.\n");
			ERR_print_errors(bio_err);
			rsa_count = 1;
		} else {
			pkey_print_message("private", "rsa",
			    rsa_c[j][0], rsa_bits[j],
			    RSA_SECONDS);
/*			RSA_blinding_on(rsa_key[j],NULL); */
			Time_F(START);
			for (count = 0, run = 1; COND(rsa_c[j][0]); count++) {
				ret = RSA_sign(NID_md5_sha1, buf, 36, buf2,
				    &rsa_num, rsa_key[j]);
				if (ret == 0) {
					BIO_printf(bio_err,
					    "RSA sign failure\n");
					ERR_print_errors(bio_err);
					count = 1;
					break;
				}
			}
			d = Time_F(STOP);
			BIO_printf(bio_err, mr ? "+R1:%ld:%d:%.2f\n"
			    : "%ld %d bit private RSA's in %.2fs\n",
			    count, rsa_bits[j], d);
			rsa_results[j][0] = d / (double) count;
			rsa_count = count;
		}

#if 1
		ret = RSA_verify(NID_md5_sha1, buf, 36, buf2, rsa_num, rsa_key[j]);
		if (ret <= 0) {
			BIO_printf(bio_err, "RSA verify failure.  No RSA verify will be done.\n");
			ERR_print_errors(bio_err);
			rsa_doit[j] = 0;
		} else {
			pkey_print_message("public", "rsa",
			    rsa_c[j][1], rsa_bits[j],
			    RSA_SECONDS);
			Time_F(START);
			for (count = 0, run = 1; COND(rsa_c[j][1]); count++) {
				ret = RSA_verify(NID_md5_sha1, buf, 36, buf2,
				    rsa_num, rsa_key[j]);
				if (ret <= 0) {
					BIO_printf(bio_err,
					    "RSA verify failure\n");
					ERR_print_errors(bio_err);
					count = 1;
					break;
				}
			}
			d = Time_F(STOP);
			BIO_printf(bio_err, mr ? "+R2:%ld:%d:%.2f\n"
			    : "%ld %d bit public RSA's in %.2fs\n",
			    count, rsa_bits[j], d);
			rsa_results[j][1] = d / (double) count;
		}
#endif

		if (rsa_count <= 1) {
			/* if longer than 10s, don't do any more */
			for (j++; j < RSA_NUM; j++)
				rsa_doit[j] = 0;
		}
	}

	RAND_pseudo_bytes(buf, 20);
	for (j = 0; j < DSA_NUM; j++) {
		unsigned int kk;
		int ret;

		if (!dsa_doit[j])
			continue;
/*		DSA_generate_key(dsa_key[j]); */
/*		DSA_sign_setup(dsa_key[j],NULL); */
		ret = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2,
		    &kk, dsa_key[j]);
		if (ret == 0) {
			BIO_printf(bio_err, "DSA sign failure.  No DSA sign will be done.\n");
			ERR_print_errors(bio_err);
			rsa_count = 1;
		} else {
			pkey_print_message("sign", "dsa",
			    dsa_c[j][0], dsa_bits[j],
			    DSA_SECONDS);
			Time_F(START);
			for (count = 0, run = 1; COND(dsa_c[j][0]); count++) {
				ret = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2,
				    &kk, dsa_key[j]);
				if (ret == 0) {
					BIO_printf(bio_err,
					    "DSA sign failure\n");
					ERR_print_errors(bio_err);
					count = 1;
					break;
				}
			}
			d = Time_F(STOP);
			BIO_printf(bio_err, mr ? "+R3:%ld:%d:%.2f\n"
			    : "%ld %d bit DSA signs in %.2fs\n",
			    count, dsa_bits[j], d);
			dsa_results[j][0] = d / (double) count;
			rsa_count = count;
		}

		ret = DSA_verify(EVP_PKEY_DSA, buf, 20, buf2,
		    kk, dsa_key[j]);
		if (ret <= 0) {
			BIO_printf(bio_err, "DSA verify failure.  No DSA verify will be done.\n");
			ERR_print_errors(bio_err);
			dsa_doit[j] = 0;
		} else {
			pkey_print_message("verify", "dsa",
			    dsa_c[j][1], dsa_bits[j],
			    DSA_SECONDS);
			Time_F(START);
			for (count = 0, run = 1; COND(dsa_c[j][1]); count++) {
				ret = DSA_verify(EVP_PKEY_DSA, buf, 20, buf2,
				    kk, dsa_key[j]);
				if (ret <= 0) {
					BIO_printf(bio_err,
					    "DSA verify failure\n");
					ERR_print_errors(bio_err);
					count = 1;
					break;
				}
			}
			d = Time_F(STOP);
			BIO_printf(bio_err, mr ? "+R4:%ld:%d:%.2f\n"
			    : "%ld %d bit DSA verify in %.2fs\n",
			    count, dsa_bits[j], d);
			dsa_results[j][1] = d / (double) count;
		}

		if (rsa_count <= 1) {
			/* if longer than 10s, don't do any more */
			for (j++; j < DSA_NUM; j++)
				dsa_doit[j] = 0;
		}
	}

	for (j = 0; j < EC_NUM; j++) {
		int ret;

		if (!ecdsa_doit[j])
			continue;	/* Ignore Curve */
		ecdsa[j] = EC_KEY_new_by_curve_name(test_curves[j]);
		if (ecdsa[j] == NULL) {
			BIO_printf(bio_err, "ECDSA failure.\n");
			ERR_print_errors(bio_err);
			rsa_count = 1;
		} else {
#if 1
			EC_KEY_precompute_mult(ecdsa[j], NULL);
#endif
			/* Perform ECDSA signature test */
			EC_KEY_generate_key(ecdsa[j]);
			ret = ECDSA_sign(0, buf, 20, ecdsasig,
			    &ecdsasiglen, ecdsa[j]);
			if (ret == 0) {
				BIO_printf(bio_err, "ECDSA sign failure.  No ECDSA sign will be done.\n");
				ERR_print_errors(bio_err);
				rsa_count = 1;
			} else {
				pkey_print_message("sign", "ecdsa",
				    ecdsa_c[j][0],
				    test_curves_bits[j],
				    ECDSA_SECONDS);

				Time_F(START);
				for (count = 0, run = 1; COND(ecdsa_c[j][0]);
				    count++) {
					ret = ECDSA_sign(0, buf, 20,
					    ecdsasig, &ecdsasiglen,
					    ecdsa[j]);
					if (ret == 0) {
						BIO_printf(bio_err, "ECDSA sign failure\n");
						ERR_print_errors(bio_err);
						count = 1;
						break;
					}
				}
				d = Time_F(STOP);

				BIO_printf(bio_err, mr ? "+R5:%ld:%d:%.2f\n" :
				    "%ld %d bit ECDSA signs in %.2fs \n",
				    count, test_curves_bits[j], d);
				ecdsa_results[j][0] = d / (double) count;
				rsa_count = count;
			}

			/* Perform ECDSA verification test */
			ret = ECDSA_verify(0, buf, 20, ecdsasig,
			    ecdsasiglen, ecdsa[j]);
			if (ret != 1) {
				BIO_printf(bio_err, "ECDSA verify failure.  No ECDSA verify will be done.\n");
				ERR_print_errors(bio_err);
				ecdsa_doit[j] = 0;
			} else {
				pkey_print_message("verify", "ecdsa",
				    ecdsa_c[j][1],
				    test_curves_bits[j],
				    ECDSA_SECONDS);
				Time_F(START);
				for (count = 0, run = 1; COND(ecdsa_c[j][1]); count++) {
					ret = ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]);
					if (ret != 1) {
						BIO_printf(bio_err, "ECDSA verify failure\n");
						ERR_print_errors(bio_err);
						count = 1;
						break;
					}
				}
				d = Time_F(STOP);
				BIO_printf(bio_err, mr ? "+R6:%ld:%d:%.2f\n"
				    : "%ld %d bit ECDSA verify in %.2fs\n",
				    count, test_curves_bits[j], d);
				ecdsa_results[j][1] = d / (double) count;
			}

			if (rsa_count <= 1) {
				/* if longer than 10s, don't do any more */
				for (j++; j < EC_NUM; j++)
					ecdsa_doit[j] = 0;
			}
		}
	}

	for (j = 0; j < EC_NUM; j++) {
		if (!ecdh_doit[j])
			continue;
		ecdh_a[j] = EC_KEY_new_by_curve_name(test_curves[j]);
		ecdh_b[j] = EC_KEY_new_by_curve_name(test_curves[j]);
		if ((ecdh_a[j] == NULL) || (ecdh_b[j] == NULL)) {
			BIO_printf(bio_err, "ECDH failure.\n");
			ERR_print_errors(bio_err);
			rsa_count = 1;
		} else {
			/* generate two ECDH key pairs */
			if (!EC_KEY_generate_key(ecdh_a[j]) ||
			    !EC_KEY_generate_key(ecdh_b[j])) {
				BIO_printf(bio_err, "ECDH key generation failure.\n");
				ERR_print_errors(bio_err);
				rsa_count = 1;
			} else {
				/*
				 * If field size is not more than 24 octets,
				 * then use SHA-1 hash of result; otherwise,
				 * use result (see section 4.8 of
				 * draft-ietf-tls-ecc-03.txt).
				 */
				int field_size, outlen;
				void *(*kdf) (const void *in, size_t inlen, void *out, size_t * xoutlen);
				field_size = EC_GROUP_get_degree(EC_KEY_get0_group(ecdh_a[j]));
				if (field_size <= 24 * 8) {
					outlen = KDF1_SHA1_len;
					kdf = KDF1_SHA1;
				} else {
					outlen = (field_size + 7) / 8;
					kdf = NULL;
				}
				secret_size_a = ECDH_compute_key(secret_a, outlen,
				    EC_KEY_get0_public_key(ecdh_b[j]),
				    ecdh_a[j], kdf);
				secret_size_b = ECDH_compute_key(secret_b, outlen,
				    EC_KEY_get0_public_key(ecdh_a[j]),
				    ecdh_b[j], kdf);
				if (secret_size_a != secret_size_b)
					ecdh_checks = 0;
				else
					ecdh_checks = 1;

				for (secret_idx = 0;
				    (secret_idx < secret_size_a)
				    && (ecdh_checks == 1);
				    secret_idx++) {
					if (secret_a[secret_idx] != secret_b[secret_idx])
						ecdh_checks = 0;
				}

				if (ecdh_checks == 0) {
					BIO_printf(bio_err, "ECDH computations don't match.\n");
					ERR_print_errors(bio_err);
					rsa_count = 1;
				}
				pkey_print_message("", "ecdh",
				    ecdh_c[j][0],
				    test_curves_bits[j],
				    ECDH_SECONDS);
				Time_F(START);
				for (count = 0, run = 1; COND(ecdh_c[j][0]); count++) {
					ECDH_compute_key(secret_a, outlen,
					    EC_KEY_get0_public_key(ecdh_b[j]),
					    ecdh_a[j], kdf);
				}
				d = Time_F(STOP);
				BIO_printf(bio_err, mr ? "+R7:%ld:%d:%.2f\n" : "%ld %d-bit ECDH ops in %.2fs\n",
				    count, test_curves_bits[j], d);
				ecdh_results[j][0] = d / (double) count;
				rsa_count = count;
			}
		}


		if (rsa_count <= 1) {
			/* if longer than 10s, don't do any more */
			for (j++; j < EC_NUM; j++)
				ecdh_doit[j] = 0;
		}
	}
show_res:
	if (!mr) {
		fprintf(stdout, "%s\n", SSLeay_version(SSLEAY_VERSION));
		fprintf(stdout, "%s\n", SSLeay_version(SSLEAY_BUILT_ON));
		printf("options:");
		printf("%s ", BN_options());
#ifndef OPENSSL_NO_RC4
		printf("%s ", RC4_options());
#endif
#ifndef OPENSSL_NO_DES
		printf("%s ", DES_options());
#endif
#ifndef OPENSSL_NO_AES
		printf("%s ", AES_options());
#endif
#ifndef OPENSSL_NO_IDEA
		printf("%s ", idea_options());
#endif
#ifndef OPENSSL_NO_BF
		printf("%s ", BF_options());
#endif
		fprintf(stdout, "\n%s\n", SSLeay_version(SSLEAY_CFLAGS));
	}
	if (pr_header) {
		if (mr)
			fprintf(stdout, "+H");
		else {
			fprintf(stdout, "The 'numbers' are in 1000s of bytes per second processed.\n");
			fprintf(stdout, "type        ");
		}
		for (j = 0; j < SIZE_NUM; j++)
			fprintf(stdout, mr ? ":%d" : "%7d bytes", lengths[j]);
		fprintf(stdout, "\n");
	}
	for (k = 0; k < ALGOR_NUM; k++) {
		if (!doit[k])
			continue;
		if (mr)
			fprintf(stdout, "+F:%d:%s", k, names[k]);
		else
			fprintf(stdout, "%-13s", names[k]);
		for (j = 0; j < SIZE_NUM; j++) {
			if (results[k][j] > 10000 && !mr)
				fprintf(stdout, " %11.2fk", results[k][j] / 1e3);
			else
				fprintf(stdout, mr ? ":%.2f" : " %11.2f ", results[k][j]);
		}
		fprintf(stdout, "\n");
	}
	j = 1;
	for (k = 0; k < RSA_NUM; k++) {
		if (!rsa_doit[k])
			continue;
		if (j && !mr) {
			printf("%18ssign    verify    sign/s verify/s\n", " ");
			j = 0;
		}
		if (mr)
			fprintf(stdout, "+F2:%u:%u:%f:%f\n",
			    k, rsa_bits[k], rsa_results[k][0],
			    rsa_results[k][1]);
		else
			fprintf(stdout, "rsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
			    rsa_bits[k], rsa_results[k][0], rsa_results[k][1],
			    1.0 / rsa_results[k][0], 1.0 / rsa_results[k][1]);
	}
	j = 1;
	for (k = 0; k < DSA_NUM; k++) {
		if (!dsa_doit[k])
			continue;
		if (j && !mr) {
			printf("%18ssign    verify    sign/s verify/s\n", " ");
			j = 0;
		}
		if (mr)
			fprintf(stdout, "+F3:%u:%u:%f:%f\n",
			    k, dsa_bits[k], dsa_results[k][0], dsa_results[k][1]);
		else
			fprintf(stdout, "dsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
			    dsa_bits[k], dsa_results[k][0], dsa_results[k][1],
			    1.0 / dsa_results[k][0], 1.0 / dsa_results[k][1]);
	}
	j = 1;
	for (k = 0; k < EC_NUM; k++) {
		if (!ecdsa_doit[k])
			continue;
		if (j && !mr) {
			printf("%30ssign    verify    sign/s verify/s\n", " ");
			j = 0;
		}
		if (mr)
			fprintf(stdout, "+F4:%u:%u:%f:%f\n",
			    k, test_curves_bits[k],
			    ecdsa_results[k][0], ecdsa_results[k][1]);
		else
			fprintf(stdout,
			    "%4u bit ecdsa (%s) %8.4fs %8.4fs %8.1f %8.1f\n",
			    test_curves_bits[k],
			    test_curves_names[k],
			    ecdsa_results[k][0], ecdsa_results[k][1],
			    1.0 / ecdsa_results[k][0], 1.0 / ecdsa_results[k][1]);
	}


	j = 1;
	for (k = 0; k < EC_NUM; k++) {
		if (!ecdh_doit[k])
			continue;
		if (j && !mr) {
			printf("%30sop      op/s\n", " ");
			j = 0;
		}
		if (mr)
			fprintf(stdout, "+F5:%u:%u:%f:%f\n",
			    k, test_curves_bits[k],
			    ecdh_results[k][0], 1.0 / ecdh_results[k][0]);

		else
			fprintf(stdout, "%4u bit ecdh (%s) %8.4fs %8.1f\n",
			    test_curves_bits[k],
			    test_curves_names[k],
			    ecdh_results[k][0], 1.0 / ecdh_results[k][0]);
	}

	mret = 0;

end:
	ERR_print_errors(bio_err);
	free(buf);
	free(buf2);
	for (i = 0; i < RSA_NUM; i++)
		if (rsa_key[i] != NULL)
			RSA_free(rsa_key[i]);
	for (i = 0; i < DSA_NUM; i++)
		if (dsa_key[i] != NULL)
			DSA_free(dsa_key[i]);

	for (i = 0; i < EC_NUM; i++)
		if (ecdsa[i] != NULL)
			EC_KEY_free(ecdsa[i]);
	for (i = 0; i < EC_NUM; i++) {
		if (ecdh_a[i] != NULL)
			EC_KEY_free(ecdh_a[i]);
		if (ecdh_b[i] != NULL)
			EC_KEY_free(ecdh_b[i]);
	}

	
	return (mret);
}

static void 
print_message(const char *s, long num, int length)
{
	BIO_printf(bio_err, mr ? "+DT:%s:%d:%d\n"
	    : "Doing %s for %ds on %d size blocks: ", s, SECONDS, length);
	(void) BIO_flush(bio_err);
	alarm(SECONDS);
}

static void 
pkey_print_message(const char *str, const char *str2, long num,
    int bits, int tm)
{
	BIO_printf(bio_err, mr ? "+DTP:%d:%s:%s:%d\n"
	    : "Doing %d bit %s %s's for %ds: ", bits, str, str2, tm);
	(void) BIO_flush(bio_err);
	alarm(tm);
}

static void 
print_result(int alg, int run_no, int count, double time_used)
{
	BIO_printf(bio_err, mr ? "+R:%d:%s:%f\n"
	    : "%d %s's in %.2fs\n", count, names[alg], time_used);
	results[alg][run_no] = ((double) count) / time_used * lengths[run_no];
}

static char *
sstrsep(char **string, const char *delim)
{
	char isdelim[256];
	char *token = *string;

	if (**string == 0)
		return NULL;

	memset(isdelim, 0, sizeof isdelim);
	isdelim[0] = 1;

	while (*delim) {
		isdelim[(unsigned char) (*delim)] = 1;
		delim++;
	}

	while (!isdelim[(unsigned char) (**string)]) {
		(*string)++;
	}

	if (**string) {
		**string = 0;
		(*string)++;
	}
	return token;
}

static int 
do_multi(int multi)
{
	int n;
	int fd[2];
	int *fds;
	static char sep[] = ":";
	const char *errstr = NULL;

	fds = reallocarray(NULL, multi, sizeof *fds);
	for (n = 0; n < multi; ++n) {
		if (pipe(fd) == -1) {
			fprintf(stderr, "pipe failure\n");
			exit(1);
		}
		fflush(stdout);
		fflush(stderr);
		if (fork()) {
			close(fd[1]);
			fds[n] = fd[0];
		} else {
			close(fd[0]);
			close(1);
			if (dup(fd[1]) == -1) {
				fprintf(stderr, "dup failed\n");
				exit(1);
			}
			close(fd[1]);
			mr = 1;
			usertime = 0;
			free(fds);
			return 0;
		}
		printf("Forked child %d\n", n);
	}

	/* for now, assume the pipe is long enough to take all the output */
	for (n = 0; n < multi; ++n) {
		FILE *f;
		char buf[1024];
		char *p;

		f = fdopen(fds[n], "r");
		while (fgets(buf, sizeof buf, f)) {
			p = strchr(buf, '\n');
			if (p)
				*p = '\0';
			if (buf[0] != '+') {
				fprintf(stderr, "Don't understand line '%s' from child %d\n",
				    buf, n);
				continue;
			}
			printf("Got: %s from %d\n", buf, n);
			if (!strncmp(buf, "+F:", 3)) {
				int alg;
				int j;

				p = buf + 3;
				alg = strtonum(sstrsep(&p, sep),
				    0, ALGOR_NUM - 1, &errstr);
				sstrsep(&p, sep);
				for (j = 0; j < SIZE_NUM; ++j)
					results[alg][j] += atof(sstrsep(&p, sep));
			} else if (!strncmp(buf, "+F2:", 4)) {
				int k;
				double d;

				p = buf + 4;
				k = strtonum(sstrsep(&p, sep),
				    0, ALGOR_NUM - 1, &errstr);
				sstrsep(&p, sep);

				d = atof(sstrsep(&p, sep));
				if (n)
					rsa_results[k][0] = 1 / (1 / rsa_results[k][0] + 1 / d);
				else
					rsa_results[k][0] = d;

				d = atof(sstrsep(&p, sep));
				if (n)
					rsa_results[k][1] = 1 / (1 / rsa_results[k][1] + 1 / d);
				else
					rsa_results[k][1] = d;
			} else if (!strncmp(buf, "+F2:", 4)) {
				int k;
				double d;

				p = buf + 4;
				k = strtonum(sstrsep(&p, sep),
				    0, ALGOR_NUM - 1, &errstr);
				sstrsep(&p, sep);

				d = atof(sstrsep(&p, sep));
				if (n)
					rsa_results[k][0] = 1 / (1 / rsa_results[k][0] + 1 / d);
				else
					rsa_results[k][0] = d;

				d = atof(sstrsep(&p, sep));
				if (n)
					rsa_results[k][1] = 1 / (1 / rsa_results[k][1] + 1 / d);
				else
					rsa_results[k][1] = d;
			}
			else if (!strncmp(buf, "+F3:", 4)) {
				int k;
				double d;

				p = buf + 4;
				k = strtonum(sstrsep(&p, sep),
				    0, ALGOR_NUM - 1, &errstr);
				sstrsep(&p, sep);

				d = atof(sstrsep(&p, sep));
				if (n)
					dsa_results[k][0] = 1 / (1 / dsa_results[k][0] + 1 / d);
				else
					dsa_results[k][0] = d;

				d = atof(sstrsep(&p, sep));
				if (n)
					dsa_results[k][1] = 1 / (1 / dsa_results[k][1] + 1 / d);
				else
					dsa_results[k][1] = d;
			}
			else if (!strncmp(buf, "+F4:", 4)) {
				int k;
				double d;

				p = buf + 4;
				k = strtonum(sstrsep(&p, sep),
				    0, ALGOR_NUM - 1, &errstr);
				sstrsep(&p, sep);

				d = atof(sstrsep(&p, sep));
				if (n)
					ecdsa_results[k][0] = 1 / (1 / ecdsa_results[k][0] + 1 / d);
				else
					ecdsa_results[k][0] = d;

				d = atof(sstrsep(&p, sep));
				if (n)
					ecdsa_results[k][1] = 1 / (1 / ecdsa_results[k][1] + 1 / d);
				else
					ecdsa_results[k][1] = d;
			}

			else if (!strncmp(buf, "+F5:", 4)) {
				int k;
				double d;

				p = buf + 4;
				k = strtonum(sstrsep(&p, sep),
				    0, ALGOR_NUM - 1, &errstr);
				sstrsep(&p, sep);

				d = atof(sstrsep(&p, sep));
				if (n)
					ecdh_results[k][0] = 1 / (1 / ecdh_results[k][0] + 1 / d);
				else
					ecdh_results[k][0] = d;

			}

			else if (!strncmp(buf, "+H:", 3)) {
			} else
				fprintf(stderr, "Unknown type '%s' from child %d\n", buf, n);
		}

		fclose(f);
	}
	free(fds);
	return 1;
}
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/apps/req.c0000644000175000017500000012546612360020706016650 0ustar  /* $OpenBSD: req.c,v 1.44 2014/06/28 04:39:41 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

/* Until the key-gen callbacks are modified to use newer prototypes, we allow
 * deprecated functions for openssl-internal code */
#ifdef OPENSSL_NO_DEPRECATED
#undef OPENSSL_NO_DEPRECATED
#endif

#include 
#include 
#include 
#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 

#include 

#define SECTION		"req"

#define BITS		"default_bits"
#define KEYFILE		"default_keyfile"
#define PROMPT		"prompt"
#define DISTINGUISHED_NAME	"distinguished_name"
#define ATTRIBUTES	"attributes"
#define V3_EXTENSIONS	"x509_extensions"
#define REQ_EXTENSIONS	"req_extensions"
#define STRING_MASK	"string_mask"
#define UTF8_IN		"utf8"

#define DEFAULT_KEY_LENGTH	512
#define MIN_KEY_LENGTH		384


/* -inform arg	- input format - default PEM (DER or PEM)
 * -outform arg - output format - default PEM
 * -in arg	- input file - default stdin
 * -out arg	- output file - default stdout
 * -verify	- check request signature
 * -noout	- don't print stuff out.
 * -text	- print out human readable text.
 * -nodes	- no des encryption
 * -config file	- Load configuration file.
 * -key file	- make a request using key in file (or use it for verification).
 * -keyform arg	- key file format.
 * -newkey	- make a key and a request.
 * -modulus	- print RSA modulus.
 * -pubkey	- output Public Key.
 * -x509	- output a self signed X509 structure instead.
 * -asn1-kludge	- output new certificate request in a format that some CA's
 *		  require.  This format is wrong
 */

static int make_REQ(X509_REQ * req, EVP_PKEY * pkey, char *dn, int mutlirdn,
    int attribs, unsigned long chtype);
static int build_subject(X509_REQ * req, char *subj, unsigned long chtype,
    int multirdn);
static int prompt_info(X509_REQ * req,
    STACK_OF(CONF_VALUE) * dn_sk, char *dn_sect,
    STACK_OF(CONF_VALUE) * attr_sk, char *attr_sect, int attribs,
    unsigned long chtype);
static int auto_info(X509_REQ * req, STACK_OF(CONF_VALUE) * sk,
    STACK_OF(CONF_VALUE) * attr, int attribs,
    unsigned long chtype);
static int add_attribute_object(X509_REQ * req, char *text, const char *def,
    char *value, int nid, int n_min,
    int n_max, unsigned long chtype);
static int add_DN_object(X509_NAME * n, char *text, const char *def, char *value,
    int nid, int n_min, int n_max, unsigned long chtype, int mval);
static int genpkey_cb(EVP_PKEY_CTX * ctx);
static int req_check_len(int len, int n_min, int n_max);
static int check_end(const char *str, const char *end);
static EVP_PKEY_CTX *set_keygen_ctx(BIO * err, const char *gstr, int *pkey_type,
    long *pkeylen, char **palgnam,
    ENGINE * keygen_engine);
static CONF *req_conf = NULL;
static int batch = 0;

int req_main(int, char **);

int
req_main(int argc, char **argv)
{
	ENGINE *e = NULL, *gen_eng = NULL;
	unsigned long nmflag = 0, reqflag = 0;
	int ex = 1, x509 = 0, days = 30;
	X509 *x509ss = NULL;
	X509_REQ *req = NULL;
	EVP_PKEY_CTX *genctx = NULL;
	const char *keyalg = NULL;
	char *keyalgstr = NULL;
	STACK_OF(OPENSSL_STRING) * pkeyopts = NULL, *sigopts = NULL;
	EVP_PKEY *pkey = NULL;
	int i = 0, badops = 0, newreq = 0, verbose = 0, pkey_type = -1;
	long newkey = -1;
	BIO *in = NULL, *out = NULL;
	int informat, outformat, verify = 0, noout = 0, text = 0, keyform = FORMAT_PEM;
	int nodes = 0, kludge = 0, newhdr = 0, subject = 0, pubkey = 0;
	char *infile, *outfile, *prog, *keyfile = NULL, *template = NULL,
	*keyout = NULL;
#ifndef OPENSSL_NO_ENGINE
	char *engine = NULL;
#endif
	char *extensions = NULL;
	char *req_exts = NULL;
	const EVP_CIPHER *cipher = NULL;
	ASN1_INTEGER *serial = NULL;
	int modulus = 0;
	char *passargin = NULL, *passargout = NULL;
	char *passin = NULL, *passout = NULL;
	char *p;
	char *subj = NULL;
	int multirdn = 0;
	const EVP_MD *md_alg = NULL, *digest = NULL;
	unsigned long chtype = MBSTRING_ASC;

	req_conf = NULL;
#ifndef OPENSSL_NO_DES
	cipher = EVP_des_ede3_cbc();
#endif

	infile = NULL;
	outfile = NULL;
	informat = FORMAT_PEM;
	outformat = FORMAT_PEM;

	prog = argv[0];
	argc--;
	argv++;
	while (argc >= 1) {
		if (strcmp(*argv, "-inform") == 0) {
			if (--argc < 1)
				goto bad;
			informat = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-outform") == 0) {
			if (--argc < 1)
				goto bad;
			outformat = str2fmt(*(++argv));
		}
#ifndef OPENSSL_NO_ENGINE
		else if (strcmp(*argv, "-engine") == 0) {
			if (--argc < 1)
				goto bad;
			engine = *(++argv);
		} else if (strcmp(*argv, "-keygen_engine") == 0) {
			if (--argc < 1)
				goto bad;
			gen_eng = ENGINE_by_id(*(++argv));
			if (gen_eng == NULL) {
				BIO_printf(bio_err, "Can't find keygen engine %s\n", *argv);
				goto end;
			}
		}
#endif
		else if (strcmp(*argv, "-key") == 0) {
			if (--argc < 1)
				goto bad;
			keyfile = *(++argv);
		} else if (strcmp(*argv, "-pubkey") == 0) {
			pubkey = 1;
		} else if (strcmp(*argv, "-new") == 0) {
			newreq = 1;
		} else if (strcmp(*argv, "-config") == 0) {
			if (--argc < 1)
				goto bad;
			template = *(++argv);
		} else if (strcmp(*argv, "-keyform") == 0) {
			if (--argc < 1)
				goto bad;
			keyform = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-in") == 0) {
			if (--argc < 1)
				goto bad;
			infile = *(++argv);
		} else if (strcmp(*argv, "-out") == 0) {
			if (--argc < 1)
				goto bad;
			outfile = *(++argv);
		} else if (strcmp(*argv, "-keyout") == 0) {
			if (--argc < 1)
				goto bad;
			keyout = *(++argv);
		} else if (strcmp(*argv, "-passin") == 0) {
			if (--argc < 1)
				goto bad;
			passargin = *(++argv);
		} else if (strcmp(*argv, "-passout") == 0) {
			if (--argc < 1)
				goto bad;
			passargout = *(++argv);
		} else if (strcmp(*argv, "-newkey") == 0) {
			if (--argc < 1)
				goto bad;
			keyalg = *(++argv);
			newreq = 1;
		} else if (strcmp(*argv, "-pkeyopt") == 0) {
			if (--argc < 1)
				goto bad;
			if (!pkeyopts)
				pkeyopts = sk_OPENSSL_STRING_new_null();
			if (!pkeyopts || !sk_OPENSSL_STRING_push(pkeyopts, *(++argv)))
				goto bad;
		} else if (strcmp(*argv, "-sigopt") == 0) {
			if (--argc < 1)
				goto bad;
			if (!sigopts)
				sigopts = sk_OPENSSL_STRING_new_null();
			if (!sigopts || !sk_OPENSSL_STRING_push(sigopts, *(++argv)))
				goto bad;
		} else if (strcmp(*argv, "-batch") == 0)
			batch = 1;
		else if (strcmp(*argv, "-newhdr") == 0)
			newhdr = 1;
		else if (strcmp(*argv, "-modulus") == 0)
			modulus = 1;
		else if (strcmp(*argv, "-verify") == 0)
			verify = 1;
		else if (strcmp(*argv, "-nodes") == 0)
			nodes = 1;
		else if (strcmp(*argv, "-noout") == 0)
			noout = 1;
		else if (strcmp(*argv, "-verbose") == 0)
			verbose = 1;
		else if (strcmp(*argv, "-utf8") == 0)
			chtype = MBSTRING_UTF8;
		else if (strcmp(*argv, "-nameopt") == 0) {
			if (--argc < 1)
				goto bad;
			if (!set_name_ex(&nmflag, *(++argv)))
				goto bad;
		} else if (strcmp(*argv, "-reqopt") == 0) {
			if (--argc < 1)
				goto bad;
			if (!set_cert_ex(&reqflag, *(++argv)))
				goto bad;
		} else if (strcmp(*argv, "-subject") == 0)
			subject = 1;
		else if (strcmp(*argv, "-text") == 0)
			text = 1;
		else if (strcmp(*argv, "-x509") == 0)
			x509 = 1;
		else if (strcmp(*argv, "-asn1-kludge") == 0)
			kludge = 1;
		else if (strcmp(*argv, "-no-asn1-kludge") == 0)
			kludge = 0;
		else if (strcmp(*argv, "-subj") == 0) {
			if (--argc < 1)
				goto bad;
			subj = *(++argv);
		} else if (strcmp(*argv, "-multivalue-rdn") == 0)
			multirdn = 1;
		else if (strcmp(*argv, "-days") == 0) {
			const char *errstr;

			if (--argc < 1)
				goto bad;
			days = strtonum(*(++argv), 1, INT_MAX, &errstr);
			if (errstr) {
				BIO_printf(bio_err, "bad -days %s, using 0: %s\n",
				    *argv, errstr);
				days = 30;
			}
		} else if (strcmp(*argv, "-set_serial") == 0) {
			if (--argc < 1)
				goto bad;
			serial = s2i_ASN1_INTEGER(NULL, *(++argv));
			if (!serial)
				goto bad;
		} else if (strcmp(*argv, "-extensions") == 0) {
			if (--argc < 1)
				goto bad;
			extensions = *(++argv);
		} else if (strcmp(*argv, "-reqexts") == 0) {
			if (--argc < 1)
				goto bad;
			req_exts = *(++argv);
		} else if ((md_alg = EVP_get_digestbyname(&((*argv)[1]))) != NULL) {
			/* ok */
			digest = md_alg;
		} else {
			BIO_printf(bio_err, "unknown option %s\n", *argv);
			badops = 1;
			break;
		}
		argc--;
		argv++;
	}

	if (badops) {
bad:
		BIO_printf(bio_err, "%s [options] outfile\n", prog);
		BIO_printf(bio_err, "where options  are\n");
		BIO_printf(bio_err, " -inform arg    input format - DER or PEM\n");
		BIO_printf(bio_err, " -outform arg   output format - DER or PEM\n");
		BIO_printf(bio_err, " -in arg        input file\n");
		BIO_printf(bio_err, " -out arg       output file\n");
		BIO_printf(bio_err, " -text          text form of request\n");
		BIO_printf(bio_err, " -pubkey        output public key\n");
		BIO_printf(bio_err, " -noout         do not output REQ\n");
		BIO_printf(bio_err, " -verify        verify signature on REQ\n");
		BIO_printf(bio_err, " -modulus       RSA modulus\n");
		BIO_printf(bio_err, " -nodes         don't encrypt the output key\n");
#ifndef OPENSSL_NO_ENGINE
		BIO_printf(bio_err, " -engine e      use engine e, possibly a hardware device\n");
#endif
		BIO_printf(bio_err, " -subject       output the request's subject\n");
		BIO_printf(bio_err, " -passin        private key password source\n");
		BIO_printf(bio_err, " -key file      use the private key contained in file\n");
		BIO_printf(bio_err, " -keyform arg   key file format\n");
		BIO_printf(bio_err, " -keyout arg    file to send the key to\n");
		BIO_printf(bio_err, " -newkey rsa:bits generate a new RSA key of 'bits' in size\n");
		BIO_printf(bio_err, " -newkey dsa:file generate a new DSA key, parameters taken from CA in 'file'\n");
		BIO_printf(bio_err, " -newkey ec:file generate a new EC key, parameters taken from CA in 'file'\n");
		BIO_printf(bio_err, " -[digest]      Digest to sign with (md5, sha1, md2, mdc2, md4)\n");
		BIO_printf(bio_err, " -config file   request template file.\n");
		BIO_printf(bio_err, " -subj arg      set or modify request subject\n");
		BIO_printf(bio_err, " -multivalue-rdn enable support for multivalued RDNs\n");
		BIO_printf(bio_err, " -new           new request.\n");
		BIO_printf(bio_err, " -batch         do not ask anything during request generation\n");
		BIO_printf(bio_err, " -x509          output a x509 structure instead of a cert. req.\n");
		BIO_printf(bio_err, " -days          number of days a certificate generated by -x509 is valid for.\n");
		BIO_printf(bio_err, " -set_serial    serial number to use for a certificate generated by -x509.\n");
		BIO_printf(bio_err, " -newhdr        output \"NEW\" in the header lines\n");
		BIO_printf(bio_err, " -asn1-kludge   Output the 'request' in a format that is wrong but some CA's\n");
		BIO_printf(bio_err, "                have been reported as requiring\n");
		BIO_printf(bio_err, " -extensions .. specify certificate extension section (override value in config file)\n");
		BIO_printf(bio_err, " -reqexts ..    specify request extension section (override value in config file)\n");
		BIO_printf(bio_err, " -utf8          input characters are UTF8 (default ASCII)\n");
		BIO_printf(bio_err, " -nameopt arg    - various certificate name options\n");
		BIO_printf(bio_err, " -reqopt arg    - various request text options\n\n");
		goto end;
	}
	ERR_load_crypto_strings();
	if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
		BIO_printf(bio_err, "Error getting passwords\n");
		goto end;
	}
	if (template != NULL) {
		long errline = -1;

		if (verbose)
			BIO_printf(bio_err, "Using configuration from %s\n", template);
		req_conf = NCONF_new(NULL);
		i = NCONF_load(req_conf, template, &errline);
		if (i == 0) {
			BIO_printf(bio_err, "error on line %ld of %s\n", errline, template);
			goto end;
		}
	} else {
		req_conf = config;

		if (req_conf == NULL) {
			BIO_printf(bio_err, "Unable to load config info from %s\n", default_config_file);
			if (newreq)
				goto end;
		} else if (verbose)
			BIO_printf(bio_err, "Using configuration from %s\n",
			    default_config_file);
	}

	if (req_conf != NULL) {
		if (!load_config(bio_err, req_conf))
			goto end;
		p = NCONF_get_string(req_conf, NULL, "oid_file");
		if (p == NULL)
			ERR_clear_error();
		if (p != NULL) {
			BIO *oid_bio;

			oid_bio = BIO_new_file(p, "r");
			if (oid_bio == NULL) {
				/*
				BIO_printf(bio_err,"problems opening %s for extra oid's\n",p);
				ERR_print_errors(bio_err);
				*/
			} else {
				OBJ_create_objects(oid_bio);
				BIO_free(oid_bio);
			}
		}
	}
	if (!add_oid_section(bio_err, req_conf))
		goto end;

	if (md_alg == NULL) {
		p = NCONF_get_string(req_conf, SECTION, "default_md");
		if (p == NULL)
			ERR_clear_error();
		if (p != NULL) {
			if ((md_alg = EVP_get_digestbyname(p)) != NULL)
				digest = md_alg;
		}
	}
	if (!extensions) {
		extensions = NCONF_get_string(req_conf, SECTION, V3_EXTENSIONS);
		if (!extensions)
			ERR_clear_error();
	}
	if (extensions) {
		/* Check syntax of file */
		X509V3_CTX ctx;
		X509V3_set_ctx_test(&ctx);
		X509V3_set_nconf(&ctx, req_conf);
		if (!X509V3_EXT_add_nconf(req_conf, &ctx, extensions, NULL)) {
			BIO_printf(bio_err,
			    "Error Loading extension section %s\n", extensions);
			goto end;
		}
	}
	if (!passin) {
		passin = NCONF_get_string(req_conf, SECTION, "input_password");
		if (!passin)
			ERR_clear_error();
	}
	if (!passout) {
		passout = NCONF_get_string(req_conf, SECTION, "output_password");
		if (!passout)
			ERR_clear_error();
	}
	p = NCONF_get_string(req_conf, SECTION, STRING_MASK);
	if (!p)
		ERR_clear_error();

	if (p && !ASN1_STRING_set_default_mask_asc(p)) {
		BIO_printf(bio_err, "Invalid global string mask setting %s\n", p);
		goto end;
	}
	if (chtype != MBSTRING_UTF8) {
		p = NCONF_get_string(req_conf, SECTION, UTF8_IN);
		if (!p)
			ERR_clear_error();
		else if (!strcmp(p, "yes"))
			chtype = MBSTRING_UTF8;
	}
	if (!req_exts) {
		req_exts = NCONF_get_string(req_conf, SECTION, REQ_EXTENSIONS);
		if (!req_exts)
			ERR_clear_error();
	}
	if (req_exts) {
		/* Check syntax of file */
		X509V3_CTX ctx;
		X509V3_set_ctx_test(&ctx);
		X509V3_set_nconf(&ctx, req_conf);
		if (!X509V3_EXT_add_nconf(req_conf, &ctx, req_exts, NULL)) {
			BIO_printf(bio_err,
			    "Error Loading request extension section %s\n",
			    req_exts);
			goto end;
		}
	}
	in = BIO_new(BIO_s_file());
	out = BIO_new(BIO_s_file());
	if ((in == NULL) || (out == NULL))
		goto end;

#ifndef OPENSSL_NO_ENGINE
	e = setup_engine(bio_err, engine, 0);
#endif

	if (keyfile != NULL) {
		pkey = load_key(bio_err, keyfile, keyform, 0, passin, e,
		    "Private Key");
		if (!pkey) {
			/*
			 * load_key() has already printed an appropriate
			 * message
			 */
			goto end;
		}
	}
	if (newreq && (pkey == NULL)) {
		if (!NCONF_get_number(req_conf, SECTION, BITS, &newkey)) {
			newkey = DEFAULT_KEY_LENGTH;
		}
		if (keyalg) {
			genctx = set_keygen_ctx(bio_err, keyalg, &pkey_type, &newkey,
			    &keyalgstr, gen_eng);
			if (!genctx)
				goto end;
		}
		if (newkey < MIN_KEY_LENGTH && (pkey_type == EVP_PKEY_RSA || pkey_type == EVP_PKEY_DSA)) {
			BIO_printf(bio_err, "private key length is too short,\n");
			BIO_printf(bio_err, "it needs to be at least %d bits, not %ld\n", MIN_KEY_LENGTH, newkey);
			goto end;
		}
		if (!genctx) {
			genctx = set_keygen_ctx(bio_err, NULL, &pkey_type, &newkey,
			    &keyalgstr, gen_eng);
			if (!genctx)
				goto end;
		}
		if (pkeyopts) {
			char *genopt;
			for (i = 0; i < sk_OPENSSL_STRING_num(pkeyopts); i++) {
				genopt = sk_OPENSSL_STRING_value(pkeyopts, i);
				if (pkey_ctrl_string(genctx, genopt) <= 0) {
					BIO_printf(bio_err,
					    "parameter error \"%s\"\n",
					    genopt);
					ERR_print_errors(bio_err);
					goto end;
				}
			}
		}
		BIO_printf(bio_err, "Generating a %ld bit %s private key\n",
		    newkey, keyalgstr);

		EVP_PKEY_CTX_set_cb(genctx, genpkey_cb);
		EVP_PKEY_CTX_set_app_data(genctx, bio_err);

		if (EVP_PKEY_keygen(genctx, &pkey) <= 0) {
			BIO_puts(bio_err, "Error Generating Key\n");
			goto end;
		}
		EVP_PKEY_CTX_free(genctx);
		genctx = NULL;

		if (keyout == NULL) {
			keyout = NCONF_get_string(req_conf, SECTION, KEYFILE);
			if (keyout == NULL)
				ERR_clear_error();
		}
		if (keyout == NULL) {
			BIO_printf(bio_err, "writing new private key to stdout\n");
			BIO_set_fp(out, stdout, BIO_NOCLOSE);
		} else {
			BIO_printf(bio_err, "writing new private key to '%s'\n", keyout);
			if (BIO_write_filename(out, keyout) <= 0) {
				perror(keyout);
				goto end;
			}
		}

		p = NCONF_get_string(req_conf, SECTION, "encrypt_rsa_key");
		if (p == NULL) {
			ERR_clear_error();
			p = NCONF_get_string(req_conf, SECTION, "encrypt_key");
			if (p == NULL)
				ERR_clear_error();
		}
		if ((p != NULL) && (strcmp(p, "no") == 0))
			cipher = NULL;
		if (nodes)
			cipher = NULL;

		i = 0;
loop:
		if (!PEM_write_bio_PrivateKey(out, pkey, cipher,
			NULL, 0, NULL, passout)) {
			if ((ERR_GET_REASON(ERR_peek_error()) ==
				PEM_R_PROBLEMS_GETTING_PASSWORD) && (i < 3)) {
				ERR_clear_error();
				i++;
				goto loop;
			}
			goto end;
		}
		BIO_printf(bio_err, "-----\n");
	}
	if (!newreq) {
		/*
		 * Since we are using a pre-existing certificate request, the
		 * kludge 'format' info should not be changed.
		 */
		kludge = -1;
		if (infile == NULL)
			BIO_set_fp(in, stdin, BIO_NOCLOSE);
		else {
			if (BIO_read_filename(in, infile) <= 0) {
				perror(infile);
				goto end;
			}
		}

		if (informat == FORMAT_ASN1)
			req = d2i_X509_REQ_bio(in, NULL);
		else if (informat == FORMAT_PEM)
			req = PEM_read_bio_X509_REQ(in, NULL, NULL, NULL);
		else {
			BIO_printf(bio_err, "bad input format specified for X509 request\n");
			goto end;
		}
		if (req == NULL) {
			BIO_printf(bio_err, "unable to load X509 request\n");
			goto end;
		}
	}
	if (newreq || x509) {
		if (pkey == NULL) {
			BIO_printf(bio_err, "you need to specify a private key\n");
			goto end;
		}
		if (req == NULL) {
			req = X509_REQ_new();
			if (req == NULL) {
				goto end;
			}
			i = make_REQ(req, pkey, subj, multirdn, !x509, chtype);
			subj = NULL;	/* done processing '-subj' option */
			if ((kludge > 0) && !sk_X509_ATTRIBUTE_num(req->req_info->attributes)) {
				sk_X509_ATTRIBUTE_free(req->req_info->attributes);
				req->req_info->attributes = NULL;
			}
			if (!i) {
				BIO_printf(bio_err, "problems making Certificate Request\n");
				goto end;
			}
		}
		if (x509) {
			EVP_PKEY *tmppkey;
			X509V3_CTX ext_ctx;
			if ((x509ss = X509_new()) == NULL)
				goto end;

			/* Set version to V3 */
			if (extensions && !X509_set_version(x509ss, 2))
				goto end;
			if (serial) {
				if (!X509_set_serialNumber(x509ss, serial))
					goto end;
			} else {
				if (!rand_serial(NULL,
					X509_get_serialNumber(x509ss)))
					goto end;
			}

			if (!X509_set_issuer_name(x509ss, X509_REQ_get_subject_name(req)))
				goto end;
			if (!X509_gmtime_adj(X509_get_notBefore(x509ss), 0))
				goto end;
			if (!X509_time_adj_ex(X509_get_notAfter(x509ss), days, 0, NULL))
				goto end;
			if (!X509_set_subject_name(x509ss, X509_REQ_get_subject_name(req)))
				goto end;
			tmppkey = X509_REQ_get_pubkey(req);
			if (!tmppkey || !X509_set_pubkey(x509ss, tmppkey))
				goto end;
			EVP_PKEY_free(tmppkey);

			/* Set up V3 context struct */

			X509V3_set_ctx(&ext_ctx, x509ss, x509ss, NULL, NULL, 0);
			X509V3_set_nconf(&ext_ctx, req_conf);

			/* Add extensions */
			if (extensions && !X509V3_EXT_add_nconf(req_conf,
				&ext_ctx, extensions, x509ss)) {
				BIO_printf(bio_err,
				    "Error Loading extension section %s\n",
				    extensions);
				goto end;
			}
			i = do_X509_sign(bio_err, x509ss, pkey, digest, sigopts);
			if (!i) {
				ERR_print_errors(bio_err);
				goto end;
			}
		} else {
			X509V3_CTX ext_ctx;

			/* Set up V3 context struct */

			X509V3_set_ctx(&ext_ctx, NULL, NULL, req, NULL, 0);
			X509V3_set_nconf(&ext_ctx, req_conf);

			/* Add extensions */
			if (req_exts && !X509V3_EXT_REQ_add_nconf(req_conf,
				&ext_ctx, req_exts, req)) {
				BIO_printf(bio_err,
				    "Error Loading extension section %s\n",
				    req_exts);
				goto end;
			}
			i = do_X509_REQ_sign(bio_err, req, pkey, digest, sigopts);
			if (!i) {
				ERR_print_errors(bio_err);
				goto end;
			}
		}
	}
	if (subj && x509) {
		BIO_printf(bio_err, "Cannot modifiy certificate subject\n");
		goto end;
	}
	if (subj && !x509) {
		if (verbose) {
			BIO_printf(bio_err, "Modifying Request's Subject\n");
			print_name(bio_err, "old subject=", X509_REQ_get_subject_name(req), nmflag);
		}
		if (build_subject(req, subj, chtype, multirdn) == 0) {
			BIO_printf(bio_err, "ERROR: cannot modify subject\n");
			ex = 1;
			goto end;
		}
		req->req_info->enc.modified = 1;

		if (verbose) {
			print_name(bio_err, "new subject=", X509_REQ_get_subject_name(req), nmflag);
		}
	}
	if (verify && !x509) {
		int tmp = 0;

		if (pkey == NULL) {
			pkey = X509_REQ_get_pubkey(req);
			tmp = 1;
			if (pkey == NULL)
				goto end;
		}
		i = X509_REQ_verify(req, pkey);
		if (tmp) {
			EVP_PKEY_free(pkey);
			pkey = NULL;
		}
		if (i < 0) {
			goto end;
		} else if (i == 0) {
			BIO_printf(bio_err, "verify failure\n");
			ERR_print_errors(bio_err);
		} else		/* if (i > 0) */
			BIO_printf(bio_err, "verify OK\n");
	}
	if (noout && !text && !modulus && !subject && !pubkey) {
		ex = 0;
		goto end;
	}
	if (outfile == NULL) {
		BIO_set_fp(out, stdout, BIO_NOCLOSE);
	} else {
		if ((keyout != NULL) && (strcmp(outfile, keyout) == 0))
			i = (int) BIO_append_filename(out, outfile);
		else
			i = (int) BIO_write_filename(out, outfile);
		if (!i) {
			perror(outfile);
			goto end;
		}
	}

	if (pubkey) {
		EVP_PKEY *tpubkey;
		tpubkey = X509_REQ_get_pubkey(req);
		if (tpubkey == NULL) {
			BIO_printf(bio_err, "Error getting public key\n");
			ERR_print_errors(bio_err);
			goto end;
		}
		PEM_write_bio_PUBKEY(out, tpubkey);
		EVP_PKEY_free(tpubkey);
	}
	if (text) {
		if (x509)
			X509_print_ex(out, x509ss, nmflag, reqflag);
		else
			X509_REQ_print_ex(out, req, nmflag, reqflag);
	}
	if (subject) {
		if (x509)
			print_name(out, "subject=", X509_get_subject_name(x509ss), nmflag);
		else
			print_name(out, "subject=", X509_REQ_get_subject_name(req), nmflag);
	}
	if (modulus) {
		EVP_PKEY *tpubkey;

		if (x509)
			tpubkey = X509_get_pubkey(x509ss);
		else
			tpubkey = X509_REQ_get_pubkey(req);
		if (tpubkey == NULL) {
			fprintf(stdout, "Modulus=unavailable\n");
			goto end;
		}
		fprintf(stdout, "Modulus=");
		if (EVP_PKEY_base_id(tpubkey) == EVP_PKEY_RSA)
			BN_print(out, tpubkey->pkey.rsa->n);
		else
			fprintf(stdout, "Wrong Algorithm type");
		EVP_PKEY_free(tpubkey);
		fprintf(stdout, "\n");
	}
	if (!noout && !x509) {
		if (outformat == FORMAT_ASN1)
			i = i2d_X509_REQ_bio(out, req);
		else if (outformat == FORMAT_PEM) {
			if (newhdr)
				i = PEM_write_bio_X509_REQ_NEW(out, req);
			else
				i = PEM_write_bio_X509_REQ(out, req);
		} else {
			BIO_printf(bio_err, "bad output format specified for outfile\n");
			goto end;
		}
		if (!i) {
			BIO_printf(bio_err, "unable to write X509 request\n");
			goto end;
		}
	}
	if (!noout && x509 && (x509ss != NULL)) {
		if (outformat == FORMAT_ASN1)
			i = i2d_X509_bio(out, x509ss);
		else if (outformat == FORMAT_PEM)
			i = PEM_write_bio_X509(out, x509ss);
		else {
			BIO_printf(bio_err, "bad output format specified for outfile\n");
			goto end;
		}
		if (!i) {
			BIO_printf(bio_err, "unable to write X509 certificate\n");
			goto end;
		}
	}
	ex = 0;
end:
	if (ex) {
		ERR_print_errors(bio_err);
	}
	if ((req_conf != NULL) && (req_conf != config))
		NCONF_free(req_conf);
	BIO_free(in);
	BIO_free_all(out);
	EVP_PKEY_free(pkey);
	if (genctx)
		EVP_PKEY_CTX_free(genctx);
	if (pkeyopts)
		sk_OPENSSL_STRING_free(pkeyopts);
	if (sigopts)
		sk_OPENSSL_STRING_free(sigopts);
#ifndef OPENSSL_NO_ENGINE
	if (gen_eng)
		ENGINE_free(gen_eng);
#endif
	free(keyalgstr);
	X509_REQ_free(req);
	X509_free(x509ss);
	ASN1_INTEGER_free(serial);
	if (passargin && passin)
		free(passin);
	if (passargout && passout)
		free(passout);
	OBJ_cleanup();
	
	return (ex);
}

static int 
make_REQ(X509_REQ * req, EVP_PKEY * pkey, char *subj, int multirdn,
    int attribs, unsigned long chtype)
{
	int ret = 0, i;
	char no_prompt = 0;
	STACK_OF(CONF_VALUE) * dn_sk, *attr_sk = NULL;
	char *tmp, *dn_sect, *attr_sect;

	tmp = NCONF_get_string(req_conf, SECTION, PROMPT);
	if (tmp == NULL)
		ERR_clear_error();
	if ((tmp != NULL) && !strcmp(tmp, "no"))
		no_prompt = 1;

	dn_sect = NCONF_get_string(req_conf, SECTION, DISTINGUISHED_NAME);
	if (dn_sect == NULL) {
		BIO_printf(bio_err, "unable to find '%s' in config\n",
		    DISTINGUISHED_NAME);
		goto err;
	}
	dn_sk = NCONF_get_section(req_conf, dn_sect);
	if (dn_sk == NULL) {
		BIO_printf(bio_err, "unable to get '%s' section\n", dn_sect);
		goto err;
	}
	attr_sect = NCONF_get_string(req_conf, SECTION, ATTRIBUTES);
	if (attr_sect == NULL) {
		ERR_clear_error();
		attr_sk = NULL;
	} else {
		attr_sk = NCONF_get_section(req_conf, attr_sect);
		if (attr_sk == NULL) {
			BIO_printf(bio_err, "unable to get '%s' section\n", attr_sect);
			goto err;
		}
	}

	/* setup version number */
	if (!X509_REQ_set_version(req, 0L))
		goto err;	/* version 1 */

	if (no_prompt)
		i = auto_info(req, dn_sk, attr_sk, attribs, chtype);
	else {
		if (subj)
			i = build_subject(req, subj, chtype, multirdn);
		else
			i = prompt_info(req, dn_sk, dn_sect, attr_sk, attr_sect, attribs, chtype);
	}
	if (!i)
		goto err;

	if (!X509_REQ_set_pubkey(req, pkey))
		goto err;

	ret = 1;
err:
	return (ret);
}

/*
 * subject is expected to be in the format /type0=value0/type1=value1/type2=...
 * where characters may be escaped by \
 */
static int 
build_subject(X509_REQ * req, char *subject, unsigned long chtype, int multirdn)
{
	X509_NAME *n;

	if (!(n = parse_name(subject, chtype, multirdn)))
		return 0;

	if (!X509_REQ_set_subject_name(req, n)) {
		X509_NAME_free(n);
		return 0;
	}
	X509_NAME_free(n);
	return 1;
}


static int 
prompt_info(X509_REQ * req,
    STACK_OF(CONF_VALUE) * dn_sk, char *dn_sect,
    STACK_OF(CONF_VALUE) * attr_sk, char *attr_sect, int attribs,
    unsigned long chtype)
{
	int i;
	char *p, *q;
	char buf[100];
	int nid, mval;
	long n_min, n_max;
	char *type, *value;
	const char *def;
	CONF_VALUE *v;
	X509_NAME *subj;
	subj = X509_REQ_get_subject_name(req);

	if (!batch) {
		BIO_printf(bio_err, "You are about to be asked to enter information that will be incorporated\n");
		BIO_printf(bio_err, "into your certificate request.\n");
		BIO_printf(bio_err, "What you are about to enter is what is called a Distinguished Name or a DN.\n");
		BIO_printf(bio_err, "There are quite a few fields but you can leave some blank\n");
		BIO_printf(bio_err, "For some fields there will be a default value,\n");
		BIO_printf(bio_err, "If you enter '.', the field will be left blank.\n");
		BIO_printf(bio_err, "-----\n");
	}
	if (sk_CONF_VALUE_num(dn_sk)) {
		i = -1;
start:		for (;;) {
			int ret;
			i++;
			if (sk_CONF_VALUE_num(dn_sk) <= i)
				break;

			v = sk_CONF_VALUE_value(dn_sk, i);
			p = q = NULL;
			type = v->name;
			if (!check_end(type, "_min") || !check_end(type, "_max") ||
			    !check_end(type, "_default") ||
			    !check_end(type, "_value"))
				continue;
			/*
			 * Skip past any leading X. X: X, etc to allow for
			 * multiple instances
			 */
			for (p = v->name; *p; p++)
				if ((*p == ':') || (*p == ',') ||
				    (*p == '.')) {
					p++;
					if (*p)
						type = p;
					break;
				}
			if (*type == '+') {
				mval = -1;
				type++;
			} else
				mval = 0;
			/* If OBJ not recognised ignore it */
			if ((nid = OBJ_txt2nid(type)) == NID_undef)
				goto start;
			ret = snprintf(buf, sizeof buf, "%s_default", v->name);
			if (ret == -1 || ret >= sizeof(buf)) {
				BIO_printf(bio_err, "Name '%s' too long for default\n",
				    v->name);
				return 0;
			}
			if ((def = NCONF_get_string(req_conf, dn_sect, buf)) == NULL) {
				ERR_clear_error();
				def = "";
			}
			ret = snprintf(buf, sizeof buf, "%s_value", v->name);
			if (ret == -1 || ret >= sizeof(buf)) {
				BIO_printf(bio_err, "Name '%s' too long for value\n",
				    v->name);
				return 0;
			}
			if ((value = NCONF_get_string(req_conf, dn_sect, buf)) == NULL) {
				ERR_clear_error();
				value = NULL;
			}
			ret = snprintf(buf, sizeof buf, "%s_min", v->name);
			if (ret == -1 || ret >= sizeof(buf)) {
				BIO_printf(bio_err, "Name '%s' too long for min\n",
				    v->name);
				return 0;
			}
			if (!NCONF_get_number(req_conf, dn_sect, buf, &n_min)) {
				ERR_clear_error();
				n_min = -1;
			}
			ret = snprintf(buf, sizeof buf, "%s_max", v->name);
			if (ret == -1 || ret >= sizeof(buf)) {
				BIO_printf(bio_err, "Name '%s' too long for max\n",
				    v->name);
				return 0;
			}
			if (!NCONF_get_number(req_conf, dn_sect, buf, &n_max)) {
				ERR_clear_error();
				n_max = -1;
			}
			if (!add_DN_object(subj, v->value, def, value, nid,
				n_min, n_max, chtype, mval))
				return 0;
		}
		if (X509_NAME_entry_count(subj) == 0) {
			BIO_printf(bio_err, "error, no objects specified in config file\n");
			return 0;
		}
		if (attribs) {
			if ((attr_sk != NULL) && (sk_CONF_VALUE_num(attr_sk) > 0) &&
			    (!batch)) {
				BIO_printf(bio_err,
				    "\nPlease enter the following 'extra' attributes\n");
				BIO_printf(bio_err,
				    "to be sent with your certificate request\n");
			}
			i = -1;
start2:			for (;;) {
				int ret;
				i++;
				if ((attr_sk == NULL) ||
				    (sk_CONF_VALUE_num(attr_sk) <= i))
					break;

				v = sk_CONF_VALUE_value(attr_sk, i);
				type = v->name;
				if ((nid = OBJ_txt2nid(type)) == NID_undef)
					goto start2;
				ret = snprintf(buf, sizeof buf, "%s_default", type);
				if (ret == -1 || ret >= sizeof(buf)) {
					BIO_printf(bio_err, "Name '%s' too long for default\n",
					    v->name);
					return 0;
				}
				if ((def = NCONF_get_string(req_conf, attr_sect, buf))
				    == NULL) {
					ERR_clear_error();
					def = "";
				}
				ret = snprintf(buf, sizeof buf, "%s_value", type);
				if (ret == -1 || ret >= sizeof(buf)) {
					BIO_printf(bio_err, "Name '%s' too long for value\n",
					    v->name);
					return 0;
				}
				if ((value = NCONF_get_string(req_conf, attr_sect, buf))
				    == NULL) {
					ERR_clear_error();
					value = NULL;
				}
				ret = snprintf(buf, sizeof buf, "%s_min", type);
				if (ret == -1 || ret >= sizeof(buf)) {
					BIO_printf(bio_err, "Name '%s' too long for min\n",
					    v->name);
					return 0;
				}
				if (!NCONF_get_number(req_conf, attr_sect, buf, &n_min)) {
					ERR_clear_error();
					n_min = -1;
				}
				ret = snprintf(buf, sizeof buf, "%s_max", type);
				if (ret == -1 || ret >= sizeof(buf)) {
					BIO_printf(bio_err, "Name '%s' too long for max\n",
					    v->name);
					return 0;
				}
				if (!NCONF_get_number(req_conf, attr_sect, buf, &n_max)) {
					ERR_clear_error();
					n_max = -1;
				}
				if (!add_attribute_object(req,
					v->value, def, value, nid, n_min, n_max, chtype))
					return 0;
			}
		}
	} else {
		BIO_printf(bio_err, "No template, please set one up.\n");
		return 0;
	}

	return 1;

}

static int 
auto_info(X509_REQ * req, STACK_OF(CONF_VALUE) * dn_sk,
    STACK_OF(CONF_VALUE) * attr_sk, int attribs, unsigned long chtype)
{
	int i;
	char *p, *q;
	char *type;
	CONF_VALUE *v;
	X509_NAME *subj;

	subj = X509_REQ_get_subject_name(req);

	for (i = 0; i < sk_CONF_VALUE_num(dn_sk); i++) {
		int mval;
		v = sk_CONF_VALUE_value(dn_sk, i);
		p = q = NULL;
		type = v->name;
		/*
		 * Skip past any leading X. X: X, etc to allow for multiple
		 * instances
		 */
		for (p = v->name; *p; p++)
			if ((*p == ':') || (*p == ',') || (*p == '.')) {
				p++;
				if (*p)
					type = p;
				break;
			}
		if (*p == '+') {
			p++;
			mval = -1;
		} else
			mval = 0;
		if (!X509_NAME_add_entry_by_txt(subj, type, chtype,
			(unsigned char *) v->value, -1, -1, mval))
			return 0;

	}

	if (!X509_NAME_entry_count(subj)) {
		BIO_printf(bio_err, "error, no objects specified in config file\n");
		return 0;
	}
	if (attribs) {
		for (i = 0; i < sk_CONF_VALUE_num(attr_sk); i++) {
			v = sk_CONF_VALUE_value(attr_sk, i);
			if (!X509_REQ_add1_attr_by_txt(req, v->name, chtype,
				(unsigned char *) v->value, -1))
				return 0;
		}
	}
	return 1;
}


static int 
add_DN_object(X509_NAME * n, char *text, const char *def, char *value,
    int nid, int n_min, int n_max, unsigned long chtype, int mval)
{
	int i, ret = 0;
	char buf[1024];
start:
	if (!batch)
		BIO_printf(bio_err, "%s [%s]:", text, def);
	(void) BIO_flush(bio_err);
	if (value != NULL) {
		strlcpy(buf, value, sizeof buf);
		strlcat(buf, "\n", sizeof buf);
		BIO_printf(bio_err, "%s\n", value);
	} else {
		buf[0] = '\0';
		if (!batch) {
			if (!fgets(buf, sizeof buf, stdin))
				return 0;
		} else {
			buf[0] = '\n';
			buf[1] = '\0';
		}
	}

	if (buf[0] == '\0')
		return (0);
	else if (buf[0] == '\n') {
		if ((def == NULL) || (def[0] == '\0'))
			return (1);
		strlcpy(buf, def, sizeof buf);
		strlcat(buf, "\n", sizeof buf);
	} else if ((buf[0] == '.') && (buf[1] == '\n'))
		return (1);

	i = strlen(buf);
	if (buf[i - 1] != '\n') {
		BIO_printf(bio_err, "weird input :-(\n");
		return (0);
	}
	buf[--i] = '\0';
	if (!req_check_len(i, n_min, n_max))
		goto start;
	if (!X509_NAME_add_entry_by_NID(n, nid, chtype,
		(unsigned char *) buf, -1, -1, mval))
		goto err;
	ret = 1;
err:
	return (ret);
}

static int 
add_attribute_object(X509_REQ * req, char *text, const char *def,
    char *value, int nid, int n_min,
    int n_max, unsigned long chtype)
{
	int i;
	static char buf[1024];

start:
	if (!batch)
		BIO_printf(bio_err, "%s [%s]:", text, def);
	(void) BIO_flush(bio_err);
	if (value != NULL) {
		strlcpy(buf, value, sizeof buf);
		strlcat(buf, "\n", sizeof buf);
		BIO_printf(bio_err, "%s\n", value);
	} else {
		buf[0] = '\0';
		if (!batch) {
			if (!fgets(buf, sizeof buf, stdin))
				return 0;
		} else {
			buf[0] = '\n';
			buf[1] = '\0';
		}
	}

	if (buf[0] == '\0')
		return (0);
	else if (buf[0] == '\n') {
		if ((def == NULL) || (def[0] == '\0'))
			return (1);
		strlcpy(buf, def, sizeof buf);
		strlcat(buf, "\n", sizeof buf);
	} else if ((buf[0] == '.') && (buf[1] == '\n'))
		return (1);

	i = strlen(buf);
	if (buf[i - 1] != '\n') {
		BIO_printf(bio_err, "weird input :-(\n");
		return (0);
	}
	buf[--i] = '\0';
	if (!req_check_len(i, n_min, n_max))
		goto start;

	if (!X509_REQ_add1_attr_by_NID(req, nid, chtype,
		(unsigned char *) buf, -1)) {
		BIO_printf(bio_err, "Error adding attribute\n");
		ERR_print_errors(bio_err);
		goto err;
	}
	return (1);
err:
	return (0);
}

static int 
req_check_len(int len, int n_min, int n_max)
{
	if ((n_min > 0) && (len < n_min)) {
		BIO_printf(bio_err, "string is too short, it needs to be at least %d bytes long\n", n_min);
		return (0);
	}
	if ((n_max >= 0) && (len > n_max)) {
		BIO_printf(bio_err, "string is too long, it needs to be less than  %d bytes long\n", n_max);
		return (0);
	}
	return (1);
}

/* Check if the end of a string matches 'end' */
static int 
check_end(const char *str, const char *end)
{
	int elen, slen;
	const char *tmp;
	elen = strlen(end);
	slen = strlen(str);
	if (elen > slen)
		return 1;
	tmp = str + slen - elen;
	return strcmp(tmp, end);
}

static EVP_PKEY_CTX *
set_keygen_ctx(BIO * err, const char *gstr, int *pkey_type,
    long *pkeylen, char **palgnam,
    ENGINE * keygen_engine)
{
	EVP_PKEY_CTX *gctx = NULL;
	EVP_PKEY *param = NULL;
	long keylen = -1;
	BIO *pbio = NULL;
	const char *paramfile = NULL;
	const char *errstr;

	if (gstr == NULL) {
		*pkey_type = EVP_PKEY_RSA;
		keylen = *pkeylen;
	} else if (gstr[0] >= '0' && gstr[0] <= '9') {
		*pkey_type = EVP_PKEY_RSA;
		keylen = strtonum(gstr, 0, LONG_MAX, &errstr);
		if (errstr) {
			BIO_printf(err, "bad algorithm %s: %s\n", gstr, errstr);
			return NULL;
		} 
		*pkeylen = keylen;
	} else if (!strncmp(gstr, "param:", 6))
		paramfile = gstr + 6;
	else {
		const char *p = strchr(gstr, ':');
		int len;
		ENGINE *tmpeng;
		const EVP_PKEY_ASN1_METHOD *ameth;

		if (p)
			len = p - gstr;
		else
			len = strlen(gstr);
		/*
		 * The lookup of a the string will cover all engines so keep
		 * a note of the implementation.
		 */

		ameth = EVP_PKEY_asn1_find_str(&tmpeng, gstr, len);

		if (!ameth) {
			BIO_printf(err, "Unknown algorithm %.*s\n", len, gstr);
			return NULL;
		}
		EVP_PKEY_asn1_get0_info(NULL, pkey_type, NULL, NULL, NULL,
		    ameth);
#ifndef OPENSSL_NO_ENGINE
		if (tmpeng)
			ENGINE_finish(tmpeng);
#endif
		if (*pkey_type == EVP_PKEY_RSA) {
			if (p) {
				keylen = strtonum(p + 1, 0, LONG_MAX, &errstr);
				if (errstr) {
					BIO_printf(err, "bad algorithm %s: %s\n",
					    p + 1, errstr);
					return NULL;					
				}
				*pkeylen = keylen;
			} else
				keylen = *pkeylen;
		} else if (p)
			paramfile = p + 1;
	}

	if (paramfile) {
		pbio = BIO_new_file(paramfile, "r");
		if (!pbio) {
			BIO_printf(err, "Can't open parameter file %s\n",
			    paramfile);
			return NULL;
		}
		param = PEM_read_bio_Parameters(pbio, NULL);

		if (!param) {
			X509 *x;
			(void) BIO_reset(pbio);
			x = PEM_read_bio_X509(pbio, NULL, NULL, NULL);
			if (x) {
				param = X509_get_pubkey(x);
				X509_free(x);
			}
		}
		BIO_free(pbio);

		if (!param) {
			BIO_printf(err, "Error reading parameter file %s\n",
			    paramfile);
			return NULL;
		}
		if (*pkey_type == -1)
			*pkey_type = EVP_PKEY_id(param);
		else if (*pkey_type != EVP_PKEY_base_id(param)) {
			BIO_printf(err, "Key Type does not match parameters\n");
			EVP_PKEY_free(param);
			return NULL;
		}
	}
	if (palgnam) {
		const EVP_PKEY_ASN1_METHOD *ameth;
		ENGINE *tmpeng;
		const char *anam;
		ameth = EVP_PKEY_asn1_find(&tmpeng, *pkey_type);
		if (!ameth) {
			BIO_puts(err, "Internal error: can't find key algorithm\n");
			return NULL;
		}
		EVP_PKEY_asn1_get0_info(NULL, NULL, NULL, NULL, &anam, ameth);
		*palgnam = BUF_strdup(anam);
#ifndef OPENSSL_NO_ENGINE
		if (tmpeng)
			ENGINE_finish(tmpeng);
#endif
	}
	if (param) {
		gctx = EVP_PKEY_CTX_new(param, keygen_engine);
		*pkeylen = EVP_PKEY_bits(param);
		EVP_PKEY_free(param);
	} else
		gctx = EVP_PKEY_CTX_new_id(*pkey_type, keygen_engine);

	if (!gctx) {
		BIO_puts(err, "Error allocating keygen context\n");
		ERR_print_errors(err);
		return NULL;
	}
	if (EVP_PKEY_keygen_init(gctx) <= 0) {
		BIO_puts(err, "Error initializing keygen context\n");
		ERR_print_errors(err);
		return NULL;
	}
	if ((*pkey_type == EVP_PKEY_RSA) && (keylen != -1)) {
		if (EVP_PKEY_CTX_set_rsa_keygen_bits(gctx, keylen) <= 0) {
			BIO_puts(err, "Error setting RSA keysize\n");
			ERR_print_errors(err);
			EVP_PKEY_CTX_free(gctx);
			return NULL;
		}
	}

	return gctx;
}

static int 
genpkey_cb(EVP_PKEY_CTX * ctx)
{
	char c = '*';
	BIO *b = EVP_PKEY_CTX_get_app_data(ctx);
	int p;
	p = EVP_PKEY_CTX_get_keygen_info(ctx, 0);
	if (p == 0)
		c = '.';
	if (p == 1)
		c = '+';
	if (p == 2)
		c = '*';
	if (p == 3)
		c = '\n';
	BIO_write(b, &c, 1);
	(void) BIO_flush(b);
	return 1;
}

static int 
do_sign_init(BIO * err, EVP_MD_CTX * ctx, EVP_PKEY * pkey,
    const EVP_MD * md, STACK_OF(OPENSSL_STRING) * sigopts)
{
	EVP_PKEY_CTX *pkctx = NULL;
	int i;
	EVP_MD_CTX_init(ctx);
	if (!EVP_DigestSignInit(ctx, &pkctx, md, NULL, pkey))
		return 0;
	for (i = 0; i < sk_OPENSSL_STRING_num(sigopts); i++) {
		char *sigopt = sk_OPENSSL_STRING_value(sigopts, i);
		if (pkey_ctrl_string(pkctx, sigopt) <= 0) {
			BIO_printf(err, "parameter error \"%s\"\n", sigopt);
			ERR_print_errors(bio_err);
			return 0;
		}
	}
	return 1;
}

int 
do_X509_sign(BIO * err, X509 * x, EVP_PKEY * pkey, const EVP_MD * md,
    STACK_OF(OPENSSL_STRING) * sigopts)
{
	int rv;
	EVP_MD_CTX mctx;
	EVP_MD_CTX_init(&mctx);
	rv = do_sign_init(err, &mctx, pkey, md, sigopts);
	if (rv > 0)
		rv = X509_sign_ctx(x, &mctx);
	EVP_MD_CTX_cleanup(&mctx);
	return rv > 0 ? 1 : 0;
}


int 
do_X509_REQ_sign(BIO * err, X509_REQ * x, EVP_PKEY * pkey, const EVP_MD * md,
    STACK_OF(OPENSSL_STRING) * sigopts)
{
	int rv;
	EVP_MD_CTX mctx;
	EVP_MD_CTX_init(&mctx);
	rv = do_sign_init(err, &mctx, pkey, md, sigopts);
	if (rv > 0)
		rv = X509_REQ_sign_ctx(x, &mctx);
	EVP_MD_CTX_cleanup(&mctx);
	return rv > 0 ? 1 : 0;
}



int 
do_X509_CRL_sign(BIO * err, X509_CRL * x, EVP_PKEY * pkey, const EVP_MD * md,
    STACK_OF(OPENSSL_STRING) * sigopts)
{
	int rv;
	EVP_MD_CTX mctx;
	EVP_MD_CTX_init(&mctx);
	rv = do_sign_init(err, &mctx, pkey, md, sigopts);
	if (rv > 0)
		rv = X509_CRL_sign_ctx(x, &mctx);
	EVP_MD_CTX_cleanup(&mctx);
	return rv > 0 ? 1 : 0;
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/s_socket.c0000644000175000017500000002154412360020706017663 0ustar  /* $OpenBSD: s_socket.c,v 1.41 2014/06/12 15:49:27 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#include 

#include 

#include 
#include 
#include 
#include 
#include 
#include 

#include "apps.h"

#include 

#include "s_apps.h"

static int ssl_sock_init(void);
static int init_server(int *sock, int port, int type);
static int init_server_long(int *sock, int port, char *ip, int type);
static int do_accept(int acc_sock, int *sock, char **host);

#define SOCKET_PROTOCOL	IPPROTO_TCP

static int
ssl_sock_init(void)
{
	return (1);
}

int
init_client(int *sock, char *host, char *port, int type, int af)
{
	struct addrinfo hints, *ai_top, *ai;
	int i, s;

	if (!ssl_sock_init())
		return (0);

	memset(&hints, '\0', sizeof(hints));
	hints.ai_family = af;
	hints.ai_socktype = type;

	if ((i = getaddrinfo(host, port, &hints, &ai_top)) != 0) {
		BIO_printf(bio_err, "getaddrinfo: %s\n", gai_strerror(i));
		return (0);
	}
	if (ai_top == NULL || ai_top->ai_addr == NULL) {
		BIO_printf(bio_err, "getaddrinfo returned no addresses\n");
		if (ai_top != NULL) {
			freeaddrinfo(ai_top);
		}
		return (0);
	}
	for (ai = ai_top; ai != NULL; ai = ai->ai_next) {
		s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
		if (s == -1) {
			continue;
		}
		if (type == SOCK_STREAM) {
			i = 0;
			i = setsockopt(s, SOL_SOCKET, SO_KEEPALIVE,
			    (char *) &i, sizeof(i));
			if (i < 0) {
				perror("keepalive");
				close(s);
				return (0);
			}
		}
		if ((i = connect(s, ai->ai_addr, ai->ai_addrlen)) == 0) {
			*sock = s;
			freeaddrinfo(ai_top);
			return (1);
		}
		close(s);
	}

	perror("connect");
	close(s);
	freeaddrinfo(ai_top);
	return (0);
}

int
do_server(int port, int type, int *ret,
    int (*cb) (char *hostname, int s, unsigned char *context),
    unsigned char *context)
{
	int sock;
	char *name = NULL;
	int accept_socket = 0;
	int i;

	if (!init_server(&accept_socket, port, type))
		return (0);

	if (ret != NULL) {
		*ret = accept_socket;
		/* return(1); */
	}
	for (;;) {
		if (type == SOCK_STREAM) {
			if (do_accept(accept_socket, &sock, &name) == 0) {
				shutdown(accept_socket, SHUT_RD);
				close(accept_socket);
				return (0);
			}
		} else
			sock = accept_socket;
		i = (*cb) (name, sock, context);
		free(name);
		if (type == SOCK_STREAM) {
			shutdown(sock, SHUT_RDWR);
			close(sock);
		}
		if (i < 0) {
			shutdown(accept_socket, SHUT_RDWR);
			close(accept_socket);
			return (i);
		}
	}
}

static int
init_server_long(int *sock, int port, char *ip, int type)
{
	int ret = 0;
	struct sockaddr_in server;
	int s = -1;

	if (!ssl_sock_init())
		return (0);

	memset((char *) &server, 0, sizeof(server));
	server.sin_family = AF_INET;
	server.sin_port = htons((unsigned short) port);
	if (ip == NULL)
		server.sin_addr.s_addr = INADDR_ANY;
	else
		memcpy(&server.sin_addr.s_addr, ip, 4);

	if (type == SOCK_STREAM)
		s = socket(AF_INET, SOCK_STREAM, SOCKET_PROTOCOL);
	else			/* type == SOCK_DGRAM */
		s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);

	if (s == -1)
		goto err;
#if defined SOL_SOCKET && defined SO_REUSEADDR
	{
		int j = 1;
		setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
		    (void *) &j, sizeof j);
	}
#endif
	if (bind(s, (struct sockaddr *) & server, sizeof(server)) == -1) {
		perror("bind");
		goto err;
	}
	/* Make it 128 for linux */
	if (type == SOCK_STREAM && listen(s, 128) == -1)
		goto err;
	*sock = s;
	ret = 1;
err:
	if ((ret == 0) && (s != -1)) {
		shutdown(s, SHUT_RD);
		close(s);
	}
	return (ret);
}

static int
init_server(int *sock, int port, int type)
{
	return (init_server_long(sock, port, NULL, type));
}

static int
do_accept(int acc_sock, int *sock, char **host)
{
	int ret;
	struct hostent *h1, *h2;
	static struct sockaddr_in from;
	socklen_t len;
/*	struct linger ling; */

	if (!ssl_sock_init())
		return (0);

redoit:

	memset((char *) &from, 0, sizeof(from));
	len = sizeof(from);
	ret = accept(acc_sock, (struct sockaddr *) & from, &len);
	if (ret == -1) {
		if (errno == EINTR) {
			/* check_timeout(); */
			goto redoit;
		}
		fprintf(stderr, "errno=%d ", errno);
		perror("accept");
		return (0);
	}
/*
	ling.l_onoff=1;
	ling.l_linger=0;
	i=setsockopt(ret,SOL_SOCKET,SO_LINGER,(char *)&ling,sizeof(ling));
	if (i < 0) { perror("linger"); return(0); }
	i=0;
	i=setsockopt(ret,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
	if (i < 0) { perror("keepalive"); return(0); }
*/

	if (host == NULL)
		goto end;
	h1 = gethostbyaddr((char *) &from.sin_addr.s_addr,
	    sizeof(from.sin_addr.s_addr), AF_INET);
	if (h1 == NULL) {
		BIO_printf(bio_err, "bad gethostbyaddr\n");
		*host = NULL;
		/* return(0); */
	} else {
		if ((*host = strdup(h1->h_name)) == NULL) {
			perror("strdup");
			close(ret);
			return (0);
		}

		h2 = gethostbyname(*host);
		if (h2 == NULL) {
			BIO_printf(bio_err, "gethostbyname failure\n");
			close(ret);
			return (0);
		}
		if (h2->h_addrtype != AF_INET) {
			BIO_printf(bio_err, "gethostbyname addr is not AF_INET\n");
			close(ret);
			return (0);
		}
	}

end:
	*sock = ret;
	return (1);
}

int
extract_host_port(char *str, char **host_ptr, unsigned char *ip,
    char **port_ptr)
{
	char *h, *p;

	h = str;
	p = strrchr(str, '/');	/* IPv6 host/port */
	if (p == NULL) {
		p = strrchr(str, ':');
	}
	if (p == NULL) {
		BIO_printf(bio_err, "no port defined\n");
		return (0);
	}
	*(p++) = '\0';

	if (host_ptr != NULL)
		*host_ptr = h;

	if (port_ptr != NULL && p != NULL && *p != '\0')
		*port_ptr = p;

	return (1);
}

int
extract_port(char *str, short *port_ptr)
{
	int i;
	const char *errstr;
	struct servent *s;

	i = strtonum(str, 1, 65535, &errstr);
	if (!errstr) {
		*port_ptr = (unsigned short) i;
	} else {
		s = getservbyname(str, "tcp");
		if (s == NULL) {
			BIO_printf(bio_err, "getservbyname failure for %s\n", str);
			return (0);
		}
		*port_ptr = ntohs((unsigned short) s->s_port);
	}
	return (1);
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/smime.c0000644000175000017500000005117312360020706017164 0ustar  /* $OpenBSD$ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
 * project.
 */
/* ====================================================================
 * Copyright (c) 1999-2004 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

/* S/MIME utility function */

#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 
#include 

static int save_certs(char *signerfile, STACK_OF(X509) * signers);
static int smime_cb(int ok, X509_STORE_CTX * ctx);

#define SMIME_OP	0x10
#define SMIME_IP	0x20
#define SMIME_SIGNERS	0x40
#define SMIME_ENCRYPT	(1 | SMIME_OP)
#define SMIME_DECRYPT	(2 | SMIME_IP)
#define SMIME_SIGN	(3 | SMIME_OP | SMIME_SIGNERS)
#define SMIME_VERIFY	(4 | SMIME_IP)
#define SMIME_PK7OUT	(5 | SMIME_IP | SMIME_OP)
#define SMIME_RESIGN	(6 | SMIME_IP | SMIME_OP | SMIME_SIGNERS)

int smime_main(int, char **);

int 
smime_main(int argc, char **argv)
{
	ENGINE *e = NULL;
	int operation = 0;
	int ret = 0;
	char **args;
	const char *inmode = "r", *outmode = "w";
	char *infile = NULL, *outfile = NULL;
	char *signerfile = NULL, *recipfile = NULL;
	STACK_OF(OPENSSL_STRING) * sksigners = NULL, *skkeys = NULL;
	char *certfile = NULL, *keyfile = NULL, *contfile = NULL;
	const EVP_CIPHER *cipher = NULL;
	PKCS7 *p7 = NULL;
	X509_STORE *store = NULL;
	X509 *cert = NULL, *recip = NULL, *signer = NULL;
	EVP_PKEY *key = NULL;
	STACK_OF(X509) * encerts = NULL, *other = NULL;
	BIO *in = NULL, *out = NULL, *indata = NULL;
	int badarg = 0;
	int flags = PKCS7_DETACHED;
	char *to = NULL, *from = NULL, *subject = NULL;
	char *CAfile = NULL, *CApath = NULL;
	char *passargin = NULL, *passin = NULL;
	int indef = 0;
	const EVP_MD *sign_md = NULL;
	int informat = FORMAT_SMIME, outformat = FORMAT_SMIME;
	int keyform = FORMAT_PEM;
#ifndef OPENSSL_NO_ENGINE
	char *engine = NULL;
#endif

	X509_VERIFY_PARAM *vpm = NULL;

	args = argv + 1;
	ret = 1;

	if (!load_config(bio_err, NULL))
		goto end;

	while (!badarg && *args && *args[0] == '-') {
		if (!strcmp(*args, "-encrypt"))
			operation = SMIME_ENCRYPT;
		else if (!strcmp(*args, "-decrypt"))
			operation = SMIME_DECRYPT;
		else if (!strcmp(*args, "-sign"))
			operation = SMIME_SIGN;
		else if (!strcmp(*args, "-resign"))
			operation = SMIME_RESIGN;
		else if (!strcmp(*args, "-verify"))
			operation = SMIME_VERIFY;
		else if (!strcmp(*args, "-pk7out"))
			operation = SMIME_PK7OUT;
#ifndef OPENSSL_NO_DES
		else if (!strcmp(*args, "-des3"))
			cipher = EVP_des_ede3_cbc();
		else if (!strcmp(*args, "-des"))
			cipher = EVP_des_cbc();
#endif
#ifndef OPENSSL_NO_RC2
		else if (!strcmp(*args, "-rc2-40"))
			cipher = EVP_rc2_40_cbc();
		else if (!strcmp(*args, "-rc2-128"))
			cipher = EVP_rc2_cbc();
		else if (!strcmp(*args, "-rc2-64"))
			cipher = EVP_rc2_64_cbc();
#endif
#ifndef OPENSSL_NO_AES
		else if (!strcmp(*args, "-aes128"))
			cipher = EVP_aes_128_cbc();
		else if (!strcmp(*args, "-aes192"))
			cipher = EVP_aes_192_cbc();
		else if (!strcmp(*args, "-aes256"))
			cipher = EVP_aes_256_cbc();
#endif
#ifndef OPENSSL_NO_CAMELLIA
		else if (!strcmp(*args, "-camellia128"))
			cipher = EVP_camellia_128_cbc();
		else if (!strcmp(*args, "-camellia192"))
			cipher = EVP_camellia_192_cbc();
		else if (!strcmp(*args, "-camellia256"))
			cipher = EVP_camellia_256_cbc();
#endif
		else if (!strcmp(*args, "-text"))
			flags |= PKCS7_TEXT;
		else if (!strcmp(*args, "-nointern"))
			flags |= PKCS7_NOINTERN;
		else if (!strcmp(*args, "-noverify"))
			flags |= PKCS7_NOVERIFY;
		else if (!strcmp(*args, "-nochain"))
			flags |= PKCS7_NOCHAIN;
		else if (!strcmp(*args, "-nocerts"))
			flags |= PKCS7_NOCERTS;
		else if (!strcmp(*args, "-noattr"))
			flags |= PKCS7_NOATTR;
		else if (!strcmp(*args, "-nodetach"))
			flags &= ~PKCS7_DETACHED;
		else if (!strcmp(*args, "-nosmimecap"))
			flags |= PKCS7_NOSMIMECAP;
		else if (!strcmp(*args, "-binary"))
			flags |= PKCS7_BINARY;
		else if (!strcmp(*args, "-nosigs"))
			flags |= PKCS7_NOSIGS;
		else if (!strcmp(*args, "-stream"))
			indef = 1;
		else if (!strcmp(*args, "-indef"))
			indef = 1;
		else if (!strcmp(*args, "-noindef"))
			indef = 0;
		else if (!strcmp(*args, "-nooldmime"))
			flags |= PKCS7_NOOLDMIMETYPE;
		else if (!strcmp(*args, "-crlfeol"))
			flags |= PKCS7_CRLFEOL;
#ifndef OPENSSL_NO_ENGINE
		else if (!strcmp(*args, "-engine")) {
			if (!args[1])
				goto argerr;
			engine = *++args;
		}
#endif
		else if (!strcmp(*args, "-passin")) {
			if (!args[1])
				goto argerr;
			passargin = *++args;
		} else if (!strcmp(*args, "-to")) {
			if (!args[1])
				goto argerr;
			to = *++args;
		} else if (!strcmp(*args, "-from")) {
			if (!args[1])
				goto argerr;
			from = *++args;
		} else if (!strcmp(*args, "-subject")) {
			if (!args[1])
				goto argerr;
			subject = *++args;
		} else if (!strcmp(*args, "-signer")) {
			if (!args[1])
				goto argerr;
			/* If previous -signer argument add signer to list */

			if (signerfile) {
				if (!sksigners)
					sksigners = sk_OPENSSL_STRING_new_null();
				sk_OPENSSL_STRING_push(sksigners, signerfile);
				if (!keyfile)
					keyfile = signerfile;
				if (!skkeys)
					skkeys = sk_OPENSSL_STRING_new_null();
				sk_OPENSSL_STRING_push(skkeys, keyfile);
				keyfile = NULL;
			}
			signerfile = *++args;
		} else if (!strcmp(*args, "-recip")) {
			if (!args[1])
				goto argerr;
			recipfile = *++args;
		} else if (!strcmp(*args, "-md")) {
			if (!args[1])
				goto argerr;
			sign_md = EVP_get_digestbyname(*++args);
			if (sign_md == NULL) {
				BIO_printf(bio_err, "Unknown digest %s\n",
				    *args);
				goto argerr;
			}
		} else if (!strcmp(*args, "-inkey")) {
			if (!args[1])
				goto argerr;
			/* If previous -inkey arument add signer to list */
			if (keyfile) {
				if (!signerfile) {
					BIO_puts(bio_err, "Illegal -inkey without -signer\n");
					goto argerr;
				}
				if (!sksigners)
					sksigners = sk_OPENSSL_STRING_new_null();
				sk_OPENSSL_STRING_push(sksigners, signerfile);
				signerfile = NULL;
				if (!skkeys)
					skkeys = sk_OPENSSL_STRING_new_null();
				sk_OPENSSL_STRING_push(skkeys, keyfile);
			}
			keyfile = *++args;
		} else if (!strcmp(*args, "-keyform")) {
			if (!args[1])
				goto argerr;
			keyform = str2fmt(*++args);
		} else if (!strcmp(*args, "-certfile")) {
			if (!args[1])
				goto argerr;
			certfile = *++args;
		} else if (!strcmp(*args, "-CAfile")) {
			if (!args[1])
				goto argerr;
			CAfile = *++args;
		} else if (!strcmp(*args, "-CApath")) {
			if (!args[1])
				goto argerr;
			CApath = *++args;
		} else if (!strcmp(*args, "-in")) {
			if (!args[1])
				goto argerr;
			infile = *++args;
		} else if (!strcmp(*args, "-inform")) {
			if (!args[1])
				goto argerr;
			informat = str2fmt(*++args);
		} else if (!strcmp(*args, "-outform")) {
			if (!args[1])
				goto argerr;
			outformat = str2fmt(*++args);
		} else if (!strcmp(*args, "-out")) {
			if (!args[1])
				goto argerr;
			outfile = *++args;
		} else if (!strcmp(*args, "-content")) {
			if (!args[1])
				goto argerr;
			contfile = *++args;
		} else if (args_verify(&args, NULL, &badarg, bio_err, &vpm))
			continue;
		else if ((cipher = EVP_get_cipherbyname(*args + 1)) == NULL)
			badarg = 1;
		args++;
	}

	if (!(operation & SMIME_SIGNERS) && (skkeys || sksigners)) {
		BIO_puts(bio_err, "Multiple signers or keys not allowed\n");
		goto argerr;
	}
	if (operation & SMIME_SIGNERS) {
		/* Check to see if any final signer needs to be appended */
		if (keyfile && !signerfile) {
			BIO_puts(bio_err, "Illegal -inkey without -signer\n");
			goto argerr;
		}
		if (signerfile) {
			if (!sksigners)
				sksigners = sk_OPENSSL_STRING_new_null();
			sk_OPENSSL_STRING_push(sksigners, signerfile);
			if (!skkeys)
				skkeys = sk_OPENSSL_STRING_new_null();
			if (!keyfile)
				keyfile = signerfile;
			sk_OPENSSL_STRING_push(skkeys, keyfile);
		}
		if (!sksigners) {
			BIO_printf(bio_err, "No signer certificate specified\n");
			badarg = 1;
		}
		signerfile = NULL;
		keyfile = NULL;
	} else if (operation == SMIME_DECRYPT) {
		if (!recipfile && !keyfile) {
			BIO_printf(bio_err, "No recipient certificate or key specified\n");
			badarg = 1;
		}
	} else if (operation == SMIME_ENCRYPT) {
		if (!*args) {
			BIO_printf(bio_err, "No recipient(s) certificate(s) specified\n");
			badarg = 1;
		}
	} else if (!operation)
		badarg = 1;

	if (badarg) {
argerr:
		BIO_printf(bio_err, "Usage smime [options] cert.pem ...\n");
		BIO_printf(bio_err, "where options are\n");
		BIO_printf(bio_err, "-encrypt       encrypt message\n");
		BIO_printf(bio_err, "-decrypt       decrypt encrypted message\n");
		BIO_printf(bio_err, "-sign          sign message\n");
		BIO_printf(bio_err, "-verify        verify signed message\n");
		BIO_printf(bio_err, "-pk7out        output PKCS#7 structure\n");
#ifndef OPENSSL_NO_DES
		BIO_printf(bio_err, "-des3          encrypt with triple DES\n");
		BIO_printf(bio_err, "-des           encrypt with DES\n");
#endif
#ifndef OPENSSL_NO_RC2
		BIO_printf(bio_err, "-rc2-40        encrypt with RC2-40 (default)\n");
		BIO_printf(bio_err, "-rc2-64        encrypt with RC2-64\n");
		BIO_printf(bio_err, "-rc2-128       encrypt with RC2-128\n");
#endif
#ifndef OPENSSL_NO_AES
		BIO_printf(bio_err, "-aes128, -aes192, -aes256\n");
		BIO_printf(bio_err, "               encrypt PEM output with cbc aes\n");
#endif
#ifndef OPENSSL_NO_CAMELLIA
		BIO_printf(bio_err, "-camellia128, -camellia192, -camellia256\n");
		BIO_printf(bio_err, "               encrypt PEM output with cbc camellia\n");
#endif
		BIO_printf(bio_err, "-nointern      don't search certificates in message for signer\n");
		BIO_printf(bio_err, "-nosigs        don't verify message signature\n");
		BIO_printf(bio_err, "-noverify      don't verify signers certificate\n");
		BIO_printf(bio_err, "-nocerts       don't include signers certificate when signing\n");
		BIO_printf(bio_err, "-nodetach      use opaque signing\n");
		BIO_printf(bio_err, "-noattr        don't include any signed attributes\n");
		BIO_printf(bio_err, "-binary        don't translate message to text\n");
		BIO_printf(bio_err, "-certfile file other certificates file\n");
		BIO_printf(bio_err, "-signer file   signer certificate file\n");
		BIO_printf(bio_err, "-recip  file   recipient certificate file for decryption\n");
		BIO_printf(bio_err, "-in file       input file\n");
		BIO_printf(bio_err, "-inform arg    input format SMIME (default), PEM or DER\n");
		BIO_printf(bio_err, "-inkey file    input private key (if not signer or recipient)\n");
		BIO_printf(bio_err, "-keyform arg   input private key format (PEM or ENGINE)\n");
		BIO_printf(bio_err, "-out file      output file\n");
		BIO_printf(bio_err, "-outform arg   output format SMIME (default), PEM or DER\n");
		BIO_printf(bio_err, "-content file  supply or override content for detached signature\n");
		BIO_printf(bio_err, "-to addr       to address\n");
		BIO_printf(bio_err, "-from ad       from address\n");
		BIO_printf(bio_err, "-subject s     subject\n");
		BIO_printf(bio_err, "-text          include or delete text MIME headers\n");
		BIO_printf(bio_err, "-CApath dir    trusted certificates directory\n");
		BIO_printf(bio_err, "-CAfile file   trusted certificates file\n");
		BIO_printf(bio_err, "-crl_check     check revocation status of signer's certificate using CRLs\n");
		BIO_printf(bio_err, "-crl_check_all check revocation status of signer's certificate chain using CRLs\n");
#ifndef OPENSSL_NO_ENGINE
		BIO_printf(bio_err, "-engine e      use engine e, possibly a hardware device.\n");
#endif
		BIO_printf(bio_err, "-passin arg    input file pass phrase source\n");
		BIO_printf(bio_err, "cert.pem       recipient certificate(s) for encryption\n");
		goto end;
	}
#ifndef OPENSSL_NO_ENGINE
	e = setup_engine(bio_err, engine, 0);
#endif

	if (!app_passwd(bio_err, passargin, NULL, &passin, NULL)) {
		BIO_printf(bio_err, "Error getting password\n");
		goto end;
	}
	ret = 2;

	if (!(operation & SMIME_SIGNERS))
		flags &= ~PKCS7_DETACHED;

	if (operation & SMIME_OP) {
		if (outformat == FORMAT_ASN1)
			outmode = "wb";
	} else {
		if (flags & PKCS7_BINARY)
			outmode = "wb";
	}

	if (operation & SMIME_IP) {
		if (informat == FORMAT_ASN1)
			inmode = "rb";
	} else {
		if (flags & PKCS7_BINARY)
			inmode = "rb";
	}

	if (operation == SMIME_ENCRYPT) {
		if (!cipher) {
#ifndef OPENSSL_NO_RC2
			cipher = EVP_rc2_40_cbc();
#else
			BIO_printf(bio_err, "No cipher selected\n");
			goto end;
#endif
		}
		encerts = sk_X509_new_null();
		while (*args) {
			if (!(cert = load_cert(bio_err, *args, FORMAT_PEM,
				    NULL, e, "recipient certificate file"))) {
#if 0				/* An appropriate message is already printed */
				BIO_printf(bio_err, "Can't read recipient certificate file %s\n", *args);
#endif
				goto end;
			}
			sk_X509_push(encerts, cert);
			cert = NULL;
			args++;
		}
	}
	if (certfile) {
		if (!(other = load_certs(bio_err, certfile, FORMAT_PEM, NULL,
			    e, "certificate file"))) {
			ERR_print_errors(bio_err);
			goto end;
		}
	}
	if (recipfile && (operation == SMIME_DECRYPT)) {
		if (!(recip = load_cert(bio_err, recipfile, FORMAT_PEM, NULL,
			    e, "recipient certificate file"))) {
			ERR_print_errors(bio_err);
			goto end;
		}
	}
	if (operation == SMIME_DECRYPT) {
		if (!keyfile)
			keyfile = recipfile;
	} else if (operation == SMIME_SIGN) {
		if (!keyfile)
			keyfile = signerfile;
	} else
		keyfile = NULL;

	if (keyfile) {
		key = load_key(bio_err, keyfile, keyform, 0, passin, e,
		    "signing key file");
		if (!key)
			goto end;
	}
	if (infile) {
		if (!(in = BIO_new_file(infile, inmode))) {
			BIO_printf(bio_err,
			    "Can't open input file %s\n", infile);
			goto end;
		}
	} else
		in = BIO_new_fp(stdin, BIO_NOCLOSE);

	if (operation & SMIME_IP) {
		if (informat == FORMAT_SMIME)
			p7 = SMIME_read_PKCS7(in, &indata);
		else if (informat == FORMAT_PEM)
			p7 = PEM_read_bio_PKCS7(in, NULL, NULL, NULL);
		else if (informat == FORMAT_ASN1)
			p7 = d2i_PKCS7_bio(in, NULL);
		else {
			BIO_printf(bio_err, "Bad input format for PKCS#7 file\n");
			goto end;
		}

		if (!p7) {
			BIO_printf(bio_err, "Error reading S/MIME message\n");
			goto end;
		}
		if (contfile) {
			BIO_free(indata);
			if (!(indata = BIO_new_file(contfile, "rb"))) {
				BIO_printf(bio_err, "Can't read content file %s\n", contfile);
				goto end;
			}
		}
	}
	if (outfile) {
		if (!(out = BIO_new_file(outfile, outmode))) {
			BIO_printf(bio_err,
			    "Can't open output file %s\n", outfile);
			goto end;
		}
	} else {
		out = BIO_new_fp(stdout, BIO_NOCLOSE);
	}

	if (operation == SMIME_VERIFY) {
		if (!(store = setup_verify(bio_err, CAfile, CApath)))
			goto end;
		X509_STORE_set_verify_cb(store, smime_cb);
		if (vpm)
			X509_STORE_set1_param(store, vpm);
	}
	ret = 3;

	if (operation == SMIME_ENCRYPT) {
		if (indef)
			flags |= PKCS7_STREAM;
		p7 = PKCS7_encrypt(encerts, in, cipher, flags);
	} else if (operation & SMIME_SIGNERS) {
		int i;
		/*
		 * If detached data content we only enable streaming if
		 * S/MIME output format.
		 */
		if (operation == SMIME_SIGN) {
			if (flags & PKCS7_DETACHED) {
				if (outformat == FORMAT_SMIME)
					flags |= PKCS7_STREAM;
			} else if (indef)
				flags |= PKCS7_STREAM;
			flags |= PKCS7_PARTIAL;
			p7 = PKCS7_sign(NULL, NULL, other, in, flags);
			if (!p7)
				goto end;
		} else
			flags |= PKCS7_REUSE_DIGEST;
		for (i = 0; i < sk_OPENSSL_STRING_num(sksigners); i++) {
			signerfile = sk_OPENSSL_STRING_value(sksigners, i);
			keyfile = sk_OPENSSL_STRING_value(skkeys, i);
			signer = load_cert(bio_err, signerfile, FORMAT_PEM, NULL,
			    e, "signer certificate");
			if (!signer)
				goto end;
			key = load_key(bio_err, keyfile, keyform, 0, passin, e,
			    "signing key file");
			if (!key)
				goto end;
			if (!PKCS7_sign_add_signer(p7, signer, key,
				sign_md, flags))
				goto end;
			X509_free(signer);
			signer = NULL;
			EVP_PKEY_free(key);
			key = NULL;
		}
		/* If not streaming or resigning finalize structure */
		if ((operation == SMIME_SIGN) && !(flags & PKCS7_STREAM)) {
			if (!PKCS7_final(p7, in, flags))
				goto end;
		}
	}
	if (!p7) {
		BIO_printf(bio_err, "Error creating PKCS#7 structure\n");
		goto end;
	}
	ret = 4;
	if (operation == SMIME_DECRYPT) {
		if (!PKCS7_decrypt(p7, key, recip, out, flags)) {
			BIO_printf(bio_err, "Error decrypting PKCS#7 structure\n");
			goto end;
		}
	} else if (operation == SMIME_VERIFY) {
		STACK_OF(X509) * signers;
		if (PKCS7_verify(p7, other, store, indata, out, flags))
			BIO_printf(bio_err, "Verification successful\n");
		else {
			BIO_printf(bio_err, "Verification failure\n");
			goto end;
		}
		signers = PKCS7_get0_signers(p7, other, flags);
		if (!save_certs(signerfile, signers)) {
			BIO_printf(bio_err, "Error writing signers to %s\n",
			    signerfile);
			ret = 5;
			goto end;
		}
		sk_X509_free(signers);
	} else if (operation == SMIME_PK7OUT)
		PEM_write_bio_PKCS7(out, p7);
	else {
		if (to)
			BIO_printf(out, "To: %s\n", to);
		if (from)
			BIO_printf(out, "From: %s\n", from);
		if (subject)
			BIO_printf(out, "Subject: %s\n", subject);
		if (outformat == FORMAT_SMIME) {
			if (operation == SMIME_RESIGN)
				SMIME_write_PKCS7(out, p7, indata, flags);
			else
				SMIME_write_PKCS7(out, p7, in, flags);
		} else if (outformat == FORMAT_PEM)
			PEM_write_bio_PKCS7_stream(out, p7, in, flags);
		else if (outformat == FORMAT_ASN1)
			i2d_PKCS7_bio_stream(out, p7, in, flags);
		else {
			BIO_printf(bio_err, "Bad output format for PKCS#7 file\n");
			goto end;
		}
	}
	ret = 0;
end:
	if (ret)
		ERR_print_errors(bio_err);
	sk_X509_pop_free(encerts, X509_free);
	sk_X509_pop_free(other, X509_free);
	if (vpm)
		X509_VERIFY_PARAM_free(vpm);
	if (sksigners)
		sk_OPENSSL_STRING_free(sksigners);
	if (skkeys)
		sk_OPENSSL_STRING_free(skkeys);
	X509_STORE_free(store);
	X509_free(cert);
	X509_free(recip);
	X509_free(signer);
	EVP_PKEY_free(key);
	PKCS7_free(p7);
	BIO_free(in);
	BIO_free(indata);
	BIO_free_all(out);
	free(passin);

	return (ret);
}

static int 
save_certs(char *signerfile, STACK_OF(X509) * signers)
{
	int i;
	BIO *tmp;
	if (!signerfile)
		return 1;
	tmp = BIO_new_file(signerfile, "w");
	if (!tmp)
		return 0;
	for (i = 0; i < sk_X509_num(signers); i++)
		PEM_write_bio_X509(tmp, sk_X509_value(signers, i));
	BIO_free(tmp);
	return 1;
}


/* Minimal callback just to output policy info (if any) */

static int 
smime_cb(int ok, X509_STORE_CTX * ctx)
{
	int error;

	error = X509_STORE_CTX_get_error(ctx);

	if ((error != X509_V_ERR_NO_EXPLICIT_POLICY)
	    && ((error != X509_V_OK) || (ok != 2)))
		return ok;

	policies_print(NULL, ctx);

	return ok;

}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/version.c0000644000175000017500000001715012360020706017534 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */
/* ====================================================================
 * Copyright (c) 1998-2001 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#include 
#include 
#include 

#include "apps.h"

#include 
#include 
#include 

#ifndef OPENSSL_NO_BF
#include 
#endif

#ifndef OPENSSL_NO_DES
#include 
#endif

#ifndef OPENSSL_NO_IDEA
#include 
#endif

#ifndef OPENSSL_NO_RC4
#include 
#endif

int version_main(int, char **);

int
version_main(int argc, char **argv)
{
	int i, ret = 0;
	int cflags = 0, version = 0, date = 0, options = 0, platform = 0,
	    dir = 0;

	if (argc == 1)
		version = 1;
	for (i = 1; i < argc; i++) {
		if (strcmp(argv[i], "-v") == 0)
			version = 1;
		else if (strcmp(argv[i], "-b") == 0)
			date = 1;
		else if (strcmp(argv[i], "-f") == 0)
			cflags = 1;
		else if (strcmp(argv[i], "-o") == 0)
			options = 1;
		else if (strcmp(argv[i], "-p") == 0)
			platform = 1;
		else if (strcmp(argv[i], "-d") == 0)
			dir = 1;
		else if (strcmp(argv[i], "-a") == 0)
			date = version = cflags = options = platform = dir = 1;
		else {
			BIO_printf(bio_err, "usage:version -[avbofpd]\n");
			ret = 1;
			goto end;
		}
	}

	if (version) {
		if (SSLeay() == SSLEAY_VERSION_NUMBER) {
			printf("%s\n", SSLeay_version(SSLEAY_VERSION));
		} else {
			printf("%s (Library: %s)\n",
			    OPENSSL_VERSION_TEXT,
			    SSLeay_version(SSLEAY_VERSION));
		}
	}
	if (date)
		printf("%s\n", SSLeay_version(SSLEAY_BUILT_ON));
	if (platform)
		printf("%s\n", SSLeay_version(SSLEAY_PLATFORM));
	if (options) {
		printf("options:  ");
		printf("%s ", BN_options());
#ifndef OPENSSL_NO_RC4
		printf("%s ", RC4_options());
#endif
#ifndef OPENSSL_NO_DES
		printf("%s ", DES_options());
#endif
#ifndef OPENSSL_NO_IDEA
		printf("%s ", idea_options());
#endif
#ifndef OPENSSL_NO_BF
		printf("%s ", BF_options());
#endif
		printf("\n");
	}
	if (cflags)
		printf("%s\n", SSLeay_version(SSLEAY_CFLAGS));
	if (dir)
		printf("%s\n", SSLeay_version(SSLEAY_DIR));
end:
	
	return (ret);
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/pkeyutl.c0000644000175000017500000003167212360020706017551 0ustar  /* $OpenBSD$ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
 * project 2006.
 */
/* ====================================================================
 * Copyright (c) 2006 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#include 

#include "apps.h"

#include 
#include 
#include 

#define KEY_PRIVKEY	1
#define KEY_PUBKEY	2
#define KEY_CERT	3

static void usage(void);

static EVP_PKEY_CTX *init_ctx(int *pkeysize,
    char *keyfile, int keyform, int key_type,
    char *passargin, int pkey_op, ENGINE * e);

static int setup_peer(BIO * err, EVP_PKEY_CTX * ctx, int peerform,
    const char *file);

static int do_keyop(EVP_PKEY_CTX * ctx, int pkey_op,
    unsigned char *out, size_t * poutlen,
    unsigned char *in, size_t inlen);

int pkeyutl_main(int argc, char **);

int 
pkeyutl_main(int argc, char **argv)
{
	BIO *in = NULL, *out = NULL;
	char *infile = NULL, *outfile = NULL, *sigfile = NULL;
	ENGINE *e = NULL;
	int pkey_op = EVP_PKEY_OP_SIGN, key_type = KEY_PRIVKEY;
	int keyform = FORMAT_PEM, peerform = FORMAT_PEM;
	char badarg = 0, rev = 0;
	char hexdump = 0, asn1parse = 0;
	EVP_PKEY_CTX *ctx = NULL;
	char *passargin = NULL;
	int keysize = -1;

	unsigned char *buf_in = NULL, *buf_out = NULL, *sig = NULL;
	size_t buf_outlen;
	int buf_inlen = 0, siglen = -1;

	int ret = 1, rv = -1;

	argc--;
	argv++;

	if (!load_config(bio_err, NULL))
		goto end;

	ERR_load_crypto_strings();
	OpenSSL_add_all_algorithms();

	while (argc >= 1) {
		if (!strcmp(*argv, "-in")) {
			if (--argc < 1)
				badarg = 1;
			else
				infile = *(++argv);
		} else if (!strcmp(*argv, "-out")) {
			if (--argc < 1)
				badarg = 1;
			else
				outfile = *(++argv);
		} else if (!strcmp(*argv, "-sigfile")) {
			if (--argc < 1)
				badarg = 1;
			else
				sigfile = *(++argv);
		} else if (!strcmp(*argv, "-inkey")) {
			if (--argc < 1)
				badarg = 1;
			else {
				ctx = init_ctx(&keysize,
				    *(++argv), keyform, key_type,
				    passargin, pkey_op, e);
				if (!ctx) {
					BIO_puts(bio_err,
					    "Error initializing context\n");
					ERR_print_errors(bio_err);
					badarg = 1;
				}
			}
		} else if (!strcmp(*argv, "-peerkey")) {
			if (--argc < 1)
				badarg = 1;
			else if (!setup_peer(bio_err, ctx, peerform, *(++argv)))
				badarg = 1;
		} else if (!strcmp(*argv, "-passin")) {
			if (--argc < 1)
				badarg = 1;
			else
				passargin = *(++argv);
		} else if (strcmp(*argv, "-peerform") == 0) {
			if (--argc < 1)
				badarg = 1;
			else
				peerform = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-keyform") == 0) {
			if (--argc < 1)
				badarg = 1;
			else
				keyform = str2fmt(*(++argv));
		}
#ifndef OPENSSL_NO_ENGINE
		else if (!strcmp(*argv, "-engine")) {
			if (--argc < 1)
				badarg = 1;
			else
				e = setup_engine(bio_err, *(++argv), 0);
		}
#endif
		else if (!strcmp(*argv, "-pubin"))
			key_type = KEY_PUBKEY;
		else if (!strcmp(*argv, "-certin"))
			key_type = KEY_CERT;
		else if (!strcmp(*argv, "-asn1parse"))
			asn1parse = 1;
		else if (!strcmp(*argv, "-hexdump"))
			hexdump = 1;
		else if (!strcmp(*argv, "-sign"))
			pkey_op = EVP_PKEY_OP_SIGN;
		else if (!strcmp(*argv, "-verify"))
			pkey_op = EVP_PKEY_OP_VERIFY;
		else if (!strcmp(*argv, "-verifyrecover"))
			pkey_op = EVP_PKEY_OP_VERIFYRECOVER;
		else if (!strcmp(*argv, "-rev"))
			rev = 1;
		else if (!strcmp(*argv, "-encrypt"))
			pkey_op = EVP_PKEY_OP_ENCRYPT;
		else if (!strcmp(*argv, "-decrypt"))
			pkey_op = EVP_PKEY_OP_DECRYPT;
		else if (!strcmp(*argv, "-derive"))
			pkey_op = EVP_PKEY_OP_DERIVE;
		else if (strcmp(*argv, "-pkeyopt") == 0) {
			if (--argc < 1)
				badarg = 1;
			else if (!ctx) {
				BIO_puts(bio_err,
				    "-pkeyopt command before -inkey\n");
				badarg = 1;
			} else if (pkey_ctrl_string(ctx, *(++argv)) <= 0) {
				BIO_puts(bio_err, "parameter setting error\n");
				ERR_print_errors(bio_err);
				goto end;
			}
		} else
			badarg = 1;
		if (badarg) {
			usage();
			goto end;
		}
		argc--;
		argv++;
	}

	if (!ctx) {
		usage();
		goto end;
	}
	if (sigfile && (pkey_op != EVP_PKEY_OP_VERIFY)) {
		BIO_puts(bio_err, "Signature file specified for non verify\n");
		goto end;
	}
	if (!sigfile && (pkey_op == EVP_PKEY_OP_VERIFY)) {
		BIO_puts(bio_err, "No signature file specified for verify\n");
		goto end;
	}

	if (pkey_op != EVP_PKEY_OP_DERIVE) {
		if (infile) {
			if (!(in = BIO_new_file(infile, "rb"))) {
				BIO_puts(bio_err,
				    "Error Opening Input File\n");
				ERR_print_errors(bio_err);
				goto end;
			}
		} else
			in = BIO_new_fp(stdin, BIO_NOCLOSE);
	}
	if (outfile) {
		if (!(out = BIO_new_file(outfile, "wb"))) {
			BIO_printf(bio_err, "Error Creating Output File\n");
			ERR_print_errors(bio_err);
			goto end;
		}
	} else {
		out = BIO_new_fp(stdout, BIO_NOCLOSE);
	}

	if (sigfile) {
		BIO *sigbio = BIO_new_file(sigfile, "rb");
		if (!sigbio) {
			BIO_printf(bio_err, "Can't open signature file %s\n",
			    sigfile);
			goto end;
		}
		siglen = bio_to_mem(&sig, keysize * 10, sigbio);
		BIO_free(sigbio);
		if (siglen <= 0) {
			BIO_printf(bio_err, "Error reading signature data\n");
			goto end;
		}
	}
	if (in) {
		/* Read the input data */
		buf_inlen = bio_to_mem(&buf_in, keysize * 10, in);
		if (buf_inlen <= 0) {
			BIO_printf(bio_err, "Error reading input Data\n");
			exit(1);
		}
		if (rev) {
			size_t i;
			unsigned char ctmp;
			size_t l = (size_t) buf_inlen;
			for (i = 0; i < l / 2; i++) {
				ctmp = buf_in[i];
				buf_in[i] = buf_in[l - 1 - i];
				buf_in[l - 1 - i] = ctmp;
			}
		}
	}
	if (pkey_op == EVP_PKEY_OP_VERIFY) {
		rv = EVP_PKEY_verify(ctx, sig, (size_t) siglen,
		    buf_in, (size_t) buf_inlen);
		if (rv == 0)
			BIO_puts(out, "Signature Verification Failure\n");
		else if (rv == 1)
			BIO_puts(out, "Signature Verified Successfully\n");
		if (rv >= 0)
			goto end;
	} else {
		rv = do_keyop(ctx, pkey_op, NULL, (size_t *) & buf_outlen,
		    buf_in, (size_t) buf_inlen);
		if (rv > 0) {
			buf_out = malloc(buf_outlen);
			if (!buf_out)
				rv = -1;
			else
				rv = do_keyop(ctx, pkey_op,
				    buf_out, (size_t *) & buf_outlen,
				    buf_in, (size_t) buf_inlen);
		}
	}

	if (rv <= 0) {
		BIO_printf(bio_err, "Public Key operation error\n");
		ERR_print_errors(bio_err);
		goto end;
	}
	ret = 0;
	if (asn1parse) {
		if (!ASN1_parse_dump(out, buf_out, buf_outlen, 1, -1))
			ERR_print_errors(bio_err);
	} else if (hexdump)
		BIO_dump(out, (char *) buf_out, buf_outlen);
	else
		BIO_write(out, buf_out, buf_outlen);

end:
	if (ctx)
		EVP_PKEY_CTX_free(ctx);
	BIO_free(in);
	BIO_free_all(out);
	free(buf_in);
	free(buf_out);
	free(sig);

	return ret;
}

static void 
usage()
{
	BIO_printf(bio_err, "Usage: pkeyutl [options]\n");
	BIO_printf(bio_err, "-in file        input file\n");
	BIO_printf(bio_err, "-out file       output file\n");
	BIO_printf(bio_err, "-sigfile file signature file (verify operation only)\n");
	BIO_printf(bio_err, "-inkey file     input key\n");
	BIO_printf(bio_err, "-keyform arg    private key format - default PEM\n");
	BIO_printf(bio_err, "-pubin          input is a public key\n");
	BIO_printf(bio_err, "-certin         input is a certificate carrying a public key\n");
	BIO_printf(bio_err, "-pkeyopt X:Y    public key options\n");
	BIO_printf(bio_err, "-sign           sign with private key\n");
	BIO_printf(bio_err, "-verify         verify with public key\n");
	BIO_printf(bio_err, "-verifyrecover  verify with public key, recover original data\n");
	BIO_printf(bio_err, "-encrypt        encrypt with public key\n");
	BIO_printf(bio_err, "-decrypt        decrypt with private key\n");
	BIO_printf(bio_err, "-derive         derive shared secret\n");
	BIO_printf(bio_err, "-hexdump        hex dump output\n");
#ifndef OPENSSL_NO_ENGINE
	BIO_printf(bio_err, "-engine e       use engine e, possibly a hardware device.\n");
#endif
	BIO_printf(bio_err, "-passin arg     pass phrase source\n");

}

static EVP_PKEY_CTX *
init_ctx(int *pkeysize,
    char *keyfile, int keyform, int key_type,
    char *passargin, int pkey_op, ENGINE * e)
{
	EVP_PKEY *pkey = NULL;
	EVP_PKEY_CTX *ctx = NULL;
	char *passin = NULL;
	int rv = -1;
	X509 *x;
	if (((pkey_op == EVP_PKEY_OP_SIGN) || (pkey_op == EVP_PKEY_OP_DECRYPT)
		|| (pkey_op == EVP_PKEY_OP_DERIVE))
	    && (key_type != KEY_PRIVKEY)) {
		BIO_printf(bio_err, "A private key is needed for this operation\n");
		goto end;
	}
	if (!app_passwd(bio_err, passargin, NULL, &passin, NULL)) {
		BIO_printf(bio_err, "Error getting password\n");
		goto end;
	}
	switch (key_type) {
	case KEY_PRIVKEY:
		pkey = load_key(bio_err, keyfile, keyform, 0,
		    passin, e, "Private Key");
		break;

	case KEY_PUBKEY:
		pkey = load_pubkey(bio_err, keyfile, keyform, 0,
		    NULL, e, "Public Key");
		break;

	case KEY_CERT:
		x = load_cert(bio_err, keyfile, keyform,
		    NULL, e, "Certificate");
		if (x) {
			pkey = X509_get_pubkey(x);
			X509_free(x);
		}
		break;

	}

	*pkeysize = EVP_PKEY_size(pkey);

	if (!pkey)
		goto end;

	ctx = EVP_PKEY_CTX_new(pkey, e);

	EVP_PKEY_free(pkey);

	if (!ctx)
		goto end;

	switch (pkey_op) {
	case EVP_PKEY_OP_SIGN:
		rv = EVP_PKEY_sign_init(ctx);
		break;

	case EVP_PKEY_OP_VERIFY:
		rv = EVP_PKEY_verify_init(ctx);
		break;

	case EVP_PKEY_OP_VERIFYRECOVER:
		rv = EVP_PKEY_verify_recover_init(ctx);
		break;

	case EVP_PKEY_OP_ENCRYPT:
		rv = EVP_PKEY_encrypt_init(ctx);
		break;

	case EVP_PKEY_OP_DECRYPT:
		rv = EVP_PKEY_decrypt_init(ctx);
		break;

	case EVP_PKEY_OP_DERIVE:
		rv = EVP_PKEY_derive_init(ctx);
		break;
	}

	if (rv <= 0) {
		EVP_PKEY_CTX_free(ctx);
		ctx = NULL;
	}
end:

	free(passin);

	return ctx;


}

static int 
setup_peer(BIO * err, EVP_PKEY_CTX * ctx, int peerform,
    const char *file)
{
	EVP_PKEY *peer = NULL;
	int ret;
	if (!ctx) {
		BIO_puts(err, "-peerkey command before -inkey\n");
		return 0;
	}
	peer = load_pubkey(bio_err, file, peerform, 0, NULL, NULL, "Peer Key");

	if (!peer) {
		BIO_printf(bio_err, "Error reading peer key %s\n", file);
		ERR_print_errors(err);
		return 0;
	}
	ret = EVP_PKEY_derive_set_peer(ctx, peer);

	EVP_PKEY_free(peer);
	if (ret <= 0)
		ERR_print_errors(err);
	return ret;
}

static int 
do_keyop(EVP_PKEY_CTX * ctx, int pkey_op,
    unsigned char *out, size_t * poutlen,
    unsigned char *in, size_t inlen)
{
	int rv = 0;
	switch (pkey_op) {
	case EVP_PKEY_OP_VERIFYRECOVER:
		rv = EVP_PKEY_verify_recover(ctx, out, poutlen, in, inlen);
		break;

	case EVP_PKEY_OP_SIGN:
		rv = EVP_PKEY_sign(ctx, out, poutlen, in, inlen);
		break;

	case EVP_PKEY_OP_ENCRYPT:
		rv = EVP_PKEY_encrypt(ctx, out, poutlen, in, inlen);
		break;

	case EVP_PKEY_OP_DECRYPT:
		rv = EVP_PKEY_decrypt(ctx, out, poutlen, in, inlen);
		break;

	case EVP_PKEY_OP_DERIVE:
		rv = EVP_PKEY_derive(ctx, out, poutlen);
		break;

	}
	return rv;
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/pkcs8.c0000644000175000017500000002465012360020706017102 0ustar  /* $OpenBSD$ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
 * project 1999-2004.
 */
/* ====================================================================
 * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 

int pkcs8_main(int, char **);

int 
pkcs8_main(int argc, char **argv)
{
	ENGINE *e = NULL;
	char **args, *infile = NULL, *outfile = NULL;
	char *passargin = NULL, *passargout = NULL;
	BIO *in = NULL, *out = NULL;
	int topk8 = 0;
	int pbe_nid = -1;
	const EVP_CIPHER *cipher = NULL;
	int iter = PKCS12_DEFAULT_ITER;
	int informat, outformat;
	int p8_broken = PKCS8_OK;
	int nocrypt = 0;
	X509_SIG *p8 = NULL;
	PKCS8_PRIV_KEY_INFO *p8inf = NULL;
	EVP_PKEY *pkey = NULL;
	char pass[50], *passin = NULL, *passout = NULL, *p8pass = NULL;
	int badarg = 0;
	int ret = 1;
#ifndef OPENSSL_NO_ENGINE
	char *engine = NULL;
#endif

	if (!load_config(bio_err, NULL))
		goto end;

	informat = FORMAT_PEM;
	outformat = FORMAT_PEM;

	ERR_load_crypto_strings();
	OpenSSL_add_all_algorithms();
	args = argv + 1;
	while (!badarg && *args && *args[0] == '-') {
		if (!strcmp(*args, "-v2")) {
			if (args[1]) {
				args++;
				cipher = EVP_get_cipherbyname(*args);
				if (!cipher) {
					BIO_printf(bio_err,
					    "Unknown cipher %s\n", *args);
					badarg = 1;
				}
			} else
				badarg = 1;
		} else if (!strcmp(*args, "-v1")) {
			if (args[1]) {
				args++;
				pbe_nid = OBJ_txt2nid(*args);
				if (pbe_nid == NID_undef) {
					BIO_printf(bio_err,
					    "Unknown PBE algorithm %s\n", *args);
					badarg = 1;
				}
			} else
				badarg = 1;
		} else if (!strcmp(*args, "-inform")) {
			if (args[1]) {
				args++;
				informat = str2fmt(*args);
			} else
				badarg = 1;
		} else if (!strcmp(*args, "-outform")) {
			if (args[1]) {
				args++;
				outformat = str2fmt(*args);
			} else
				badarg = 1;
		} else if (!strcmp(*args, "-topk8"))
			topk8 = 1;
		else if (!strcmp(*args, "-noiter"))
			iter = 1;
		else if (!strcmp(*args, "-nocrypt"))
			nocrypt = 1;
		else if (!strcmp(*args, "-nooct"))
			p8_broken = PKCS8_NO_OCTET;
		else if (!strcmp(*args, "-nsdb"))
			p8_broken = PKCS8_NS_DB;
		else if (!strcmp(*args, "-embed"))
			p8_broken = PKCS8_EMBEDDED_PARAM;
		else if (!strcmp(*args, "-passin")) {
			if (!args[1])
				goto bad;
			passargin = *(++args);
		} else if (!strcmp(*args, "-passout")) {
			if (!args[1])
				goto bad;
			passargout = *(++args);
		}
#ifndef OPENSSL_NO_ENGINE
		else if (strcmp(*args, "-engine") == 0) {
			if (!args[1])
				goto bad;
			engine = *(++args);
		}
#endif
		else if (!strcmp(*args, "-in")) {
			if (args[1]) {
				args++;
				infile = *args;
			} else
				badarg = 1;
		} else if (!strcmp(*args, "-out")) {
			if (args[1]) {
				args++;
				outfile = *args;
			} else
				badarg = 1;
		} else
			badarg = 1;
		args++;
	}

	if (badarg) {
bad:
		BIO_printf(bio_err, "Usage pkcs8 [options]\n");
		BIO_printf(bio_err, "where options are\n");
		BIO_printf(bio_err, "-in file        input file\n");
		BIO_printf(bio_err, "-inform X       input format (DER or PEM)\n");
		BIO_printf(bio_err, "-passin arg     input file pass phrase source\n");
		BIO_printf(bio_err, "-outform X      output format (DER or PEM)\n");
		BIO_printf(bio_err, "-out file       output file\n");
		BIO_printf(bio_err, "-passout arg    output file pass phrase source\n");
		BIO_printf(bio_err, "-topk8          output PKCS8 file\n");
		BIO_printf(bio_err, "-nooct          use (nonstandard) no octet format\n");
		BIO_printf(bio_err, "-embed          use (nonstandard) embedded DSA parameters format\n");
		BIO_printf(bio_err, "-nsdb           use (nonstandard) DSA Netscape DB format\n");
		BIO_printf(bio_err, "-noiter         use 1 as iteration count\n");
		BIO_printf(bio_err, "-nocrypt        use or expect unencrypted private key\n");
		BIO_printf(bio_err, "-v2 alg         use PKCS#5 v2.0 and cipher \"alg\"\n");
		BIO_printf(bio_err, "-v1 obj         use PKCS#5 v1.5 and cipher \"alg\"\n");
#ifndef OPENSSL_NO_ENGINE
		BIO_printf(bio_err, " -engine e       use engine e, possibly a hardware device.\n");
#endif
		goto end;
	}
#ifndef OPENSSL_NO_ENGINE
	e = setup_engine(bio_err, engine, 0);
#endif

	if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
		BIO_printf(bio_err, "Error getting passwords\n");
		goto end;
	}
	if ((pbe_nid == -1) && !cipher)
		pbe_nid = NID_pbeWithMD5AndDES_CBC;

	if (infile) {
		if (!(in = BIO_new_file(infile, "rb"))) {
			BIO_printf(bio_err,
			    "Can't open input file %s\n", infile);
			goto end;
		}
	} else
		in = BIO_new_fp(stdin, BIO_NOCLOSE);

	if (outfile) {
		if (!(out = BIO_new_file(outfile, "wb"))) {
			BIO_printf(bio_err,
			    "Can't open output file %s\n", outfile);
			goto end;
		}
	} else {
		out = BIO_new_fp(stdout, BIO_NOCLOSE);
	}
	if (topk8) {
		pkey = load_key(bio_err, infile, informat, 1,
		    passin, e, "key");
		if (!pkey)
			goto end;
		if (!(p8inf = EVP_PKEY2PKCS8_broken(pkey, p8_broken))) {
			BIO_printf(bio_err, "Error converting key\n");
			ERR_print_errors(bio_err);
			goto end;
		}
		if (nocrypt) {
			if (outformat == FORMAT_PEM)
				PEM_write_bio_PKCS8_PRIV_KEY_INFO(out, p8inf);
			else if (outformat == FORMAT_ASN1)
				i2d_PKCS8_PRIV_KEY_INFO_bio(out, p8inf);
			else {
				BIO_printf(bio_err, "Bad format specified for key\n");
				goto end;
			}
		} else {
			if (passout)
				p8pass = passout;
			else {
				p8pass = pass;
				if (EVP_read_pw_string(pass, sizeof pass, "Enter Encryption Password:", 1))
					goto end;
			}
			if (!(p8 = PKCS8_encrypt(pbe_nid, cipher,
				    p8pass, strlen(p8pass),
				    NULL, 0, iter, p8inf))) {
				BIO_printf(bio_err, "Error encrypting key\n");
				ERR_print_errors(bio_err);
				goto end;
			}
			if (outformat == FORMAT_PEM)
				PEM_write_bio_PKCS8(out, p8);
			else if (outformat == FORMAT_ASN1)
				i2d_PKCS8_bio(out, p8);
			else {
				BIO_printf(bio_err, "Bad format specified for key\n");
				goto end;
			}
		}

		ret = 0;
		goto end;
	}
	if (nocrypt) {
		if (informat == FORMAT_PEM)
			p8inf = PEM_read_bio_PKCS8_PRIV_KEY_INFO(in, NULL, NULL, NULL);
		else if (informat == FORMAT_ASN1)
			p8inf = d2i_PKCS8_PRIV_KEY_INFO_bio(in, NULL);
		else {
			BIO_printf(bio_err, "Bad format specified for key\n");
			goto end;
		}
	} else {
		if (informat == FORMAT_PEM)
			p8 = PEM_read_bio_PKCS8(in, NULL, NULL, NULL);
		else if (informat == FORMAT_ASN1)
			p8 = d2i_PKCS8_bio(in, NULL);
		else {
			BIO_printf(bio_err, "Bad format specified for key\n");
			goto end;
		}

		if (!p8) {
			BIO_printf(bio_err, "Error reading key\n");
			ERR_print_errors(bio_err);
			goto end;
		}
		if (passin)
			p8pass = passin;
		else {
			p8pass = pass;
			EVP_read_pw_string(pass, sizeof pass, "Enter Password:", 0);
		}
		p8inf = PKCS8_decrypt(p8, p8pass, strlen(p8pass));
	}

	if (!p8inf) {
		BIO_printf(bio_err, "Error decrypting key\n");
		ERR_print_errors(bio_err);
		goto end;
	}
	if (!(pkey = EVP_PKCS82PKEY(p8inf))) {
		BIO_printf(bio_err, "Error converting key\n");
		ERR_print_errors(bio_err);
		goto end;
	}
	if (p8inf->broken) {
		BIO_printf(bio_err, "Warning: broken key encoding: ");
		switch (p8inf->broken) {
		case PKCS8_NO_OCTET:
			BIO_printf(bio_err, "No Octet String in PrivateKey\n");
			break;

		case PKCS8_EMBEDDED_PARAM:
			BIO_printf(bio_err, "DSA parameters included in PrivateKey\n");
			break;

		case PKCS8_NS_DB:
			BIO_printf(bio_err, "DSA public key include in PrivateKey\n");
			break;

		case PKCS8_NEG_PRIVKEY:
			BIO_printf(bio_err, "DSA private key value is negative\n");
			break;

		default:
			BIO_printf(bio_err, "Unknown broken type\n");
			break;
		}
	}
	if (outformat == FORMAT_PEM)
		PEM_write_bio_PrivateKey(out, pkey, NULL, NULL, 0, NULL, passout);
	else if (outformat == FORMAT_ASN1)
		i2d_PrivateKey_bio(out, pkey);
	else {
		BIO_printf(bio_err, "Bad format specified for key\n");
		goto end;
	}
	ret = 0;

end:
	X509_SIG_free(p8);
	PKCS8_PRIV_KEY_INFO_free(p8inf);
	EVP_PKEY_free(pkey);
	BIO_free_all(out);
	BIO_free(in);
	free(passin);
	free(passout);

	return ret;
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/asn1pars.c0000644000175000017500000002704112360020706017577 0ustar  /* $OpenBSD: asn1pars.c,v 1.24 2014/06/12 15:49:27 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

/* A nice addition from Dr Stephen Henson  to
 * add the -strparse option which parses nested binary structures
 */

#include 
#include 
#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 

/* -inform arg	- input format - default PEM (DER or PEM)
 * -in arg	- input file - default stdin
 * -i		- indent the details by depth
 * -offset	- where in the file to start
 * -length	- how many bytes to use
 * -oid file	- extra oid description file
 */

int asn1parse_main(int, char **);

static int do_generate(BIO * bio, char *genstr, char *genconf, BUF_MEM * buf);

int
asn1parse_main(int argc, char **argv)
{
	int i, badops = 0, offset = 0, ret = 1, j;
	unsigned int length = 0;
	long num, tmplen;
	BIO *in = NULL, *out = NULL, *b64 = NULL, *derout = NULL;
	int informat, indent = 0, noout = 0, dump = 0;
	char *infile = NULL, *str = NULL, *prog, *oidfile = NULL, *derfile = NULL;
	char *genstr = NULL, *genconf = NULL;
	const char *errstr = NULL;
	unsigned char *tmpbuf;
	const unsigned char *ctmpbuf;
	BUF_MEM *buf = NULL;
	STACK_OF(OPENSSL_STRING) * osk = NULL;
	ASN1_TYPE *at = NULL;

	informat = FORMAT_PEM;

	if (!load_config(bio_err, NULL))
		goto end;

	prog = argv[0];
	argc--;
	argv++;
	if ((osk = sk_OPENSSL_STRING_new_null()) == NULL) {
		BIO_printf(bio_err, "Memory allocation failure\n");
		goto end;
	}
	while (argc >= 1) {
		if (strcmp(*argv, "-inform") == 0) {
			if (--argc < 1)
				goto bad;
			informat = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-in") == 0) {
			if (--argc < 1)
				goto bad;
			infile = *(++argv);
		} else if (strcmp(*argv, "-out") == 0) {
			if (--argc < 1)
				goto bad;
			derfile = *(++argv);
		} else if (strcmp(*argv, "-i") == 0) {
			indent = 1;
		} else if (strcmp(*argv, "-noout") == 0)
			noout = 1;
		else if (strcmp(*argv, "-oid") == 0) {
			if (--argc < 1)
				goto bad;
			oidfile = *(++argv);
		} else if (strcmp(*argv, "-offset") == 0) {
			if (--argc < 1)
				goto bad;
			offset = strtonum(*(++argv), 0, INT_MAX, &errstr);
			if (errstr)
				goto bad;
		} else if (strcmp(*argv, "-length") == 0) {
			if (--argc < 1)
				goto bad;
			length = strtonum(*(++argv), 1, UINT_MAX, &errstr);
			if (errstr)
				goto bad;
		} else if (strcmp(*argv, "-dump") == 0) {
			dump = -1;
		} else if (strcmp(*argv, "-dlimit") == 0) {
			if (--argc < 1)
				goto bad;
			dump = strtonum(*(++argv), 1, INT_MAX, &errstr);
			if (errstr)
				goto bad;
		} else if (strcmp(*argv, "-strparse") == 0) {
			if (--argc < 1)
				goto bad;
			sk_OPENSSL_STRING_push(osk, *(++argv));
		} else if (strcmp(*argv, "-genstr") == 0) {
			if (--argc < 1)
				goto bad;
			genstr = *(++argv);
		} else if (strcmp(*argv, "-genconf") == 0) {
			if (--argc < 1)
				goto bad;
			genconf = *(++argv);
		} else {
			BIO_printf(bio_err, "unknown option %s\n", *argv);
			badops = 1;
			break;
		}
		argc--;
		argv++;
	}

	if (badops) {
bad:
		BIO_printf(bio_err, "%s [options] data[num]), BUFSIZ);
			if (i <= 0)
				break;
			num += i;
		}
	}
	str = buf->data;

	/* If any structs to parse go through in sequence */

	if (sk_OPENSSL_STRING_num(osk)) {
		tmpbuf = (unsigned char *) str;
		tmplen = num;
		for (i = 0; i < sk_OPENSSL_STRING_num(osk); i++) {
			ASN1_TYPE *atmp;
			int typ;
			j = strtonum(sk_OPENSSL_STRING_value(osk, i),
			    1, INT_MAX, &errstr);
			if (errstr) {
				BIO_printf(bio_err,
				    "'%s' is an invalid number: %s\n",
				    sk_OPENSSL_STRING_value(osk, i), errstr);
				continue;
			}
			tmpbuf += j;
			tmplen -= j;
			atmp = at;
			ctmpbuf = tmpbuf;
			at = d2i_ASN1_TYPE(NULL, &ctmpbuf, tmplen);
			ASN1_TYPE_free(atmp);
			if (!at) {
				BIO_printf(bio_err, "Error parsing structure\n");
				ERR_print_errors(bio_err);
				goto end;
			}
			typ = ASN1_TYPE_get(at);
			if ((typ == V_ASN1_OBJECT) ||
			    (typ == V_ASN1_NULL)) {
				BIO_printf(bio_err, "Can't parse %s type\n",
				    typ == V_ASN1_NULL ? "NULL" : "OBJECT");
				ERR_print_errors(bio_err);
				goto end;
			}
			/* hmm... this is a little evil but it works */
			tmpbuf = at->value.asn1_string->data;
			tmplen = at->value.asn1_string->length;
		}
		str = (char *) tmpbuf;
		num = tmplen;
	}
	if (offset >= num) {
		BIO_printf(bio_err, "Error: offset too large\n");
		goto end;
	}
	num -= offset;

	if ((length == 0) || ((long) length > num))
		length = (unsigned int) num;
	if (derout) {
		if (BIO_write(derout, str + offset, length) != (int) length) {
			BIO_printf(bio_err, "Error writing output\n");
			ERR_print_errors(bio_err);
			goto end;
		}
	}
	if (!noout &&
	    !ASN1_parse_dump(out, (unsigned char *) &(str[offset]), length,
		indent, dump)) {
		ERR_print_errors(bio_err);
		goto end;
	}
	ret = 0;
end:
	BIO_free(derout);
	if (in != NULL)
		BIO_free(in);
	if (out != NULL)
		BIO_free_all(out);
	if (b64 != NULL)
		BIO_free(b64);
	if (ret != 0)
		ERR_print_errors(bio_err);
	if (buf != NULL)
		BUF_MEM_free(buf);
	if (at != NULL)
		ASN1_TYPE_free(at);
	if (osk != NULL)
		sk_OPENSSL_STRING_free(osk);
	OBJ_cleanup();
	
	return (ret);
}

static int
do_generate(BIO * bio, char *genstr, char *genconf, BUF_MEM * buf)
{
	CONF *cnf = NULL;
	int len;
	long errline;
	unsigned char *p;
	ASN1_TYPE *atyp = NULL;

	if (genconf) {
		cnf = NCONF_new(NULL);
		if (!NCONF_load(cnf, genconf, &errline))
			goto conferr;
		if (!genstr)
			genstr = NCONF_get_string(cnf, "default", "asn1");
		if (!genstr) {
			BIO_printf(bio, "Can't find 'asn1' in '%s'\n", genconf);
			goto err;
		}
	}
	atyp = ASN1_generate_nconf(genstr, cnf);
	NCONF_free(cnf);
	cnf = NULL;

	if (!atyp)
		return -1;

	len = i2d_ASN1_TYPE(atyp, NULL);

	if (len <= 0)
		goto err;

	if (!BUF_MEM_grow(buf, len))
		goto err;

	p = (unsigned char *) buf->data;

	i2d_ASN1_TYPE(atyp, &p);

	ASN1_TYPE_free(atyp);
	return len;

conferr:

	if (errline > 0)
		BIO_printf(bio, "Error on line %ld of config file '%s'\n",
		    errline, genconf);
	else
		BIO_printf(bio, "Error loading config file '%s'\n", genconf);

err:
	NCONF_free(cnf);
	ASN1_TYPE_free(atyp);

	return -1;

}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/rsa.c0000644000175000017500000002777612360020706016653 0ustar  /* $OpenBSD: rsa.c,v 1.24 2014/06/12 15:49:27 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#include 


#include 
#include 
#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 
#include 
#include 
#include 

/* -inform arg	- input format - default PEM (one of DER, NET or PEM)
 * -outform arg - output format - default PEM
 * -in arg	- input file - default stdin
 * -out arg	- output file - default stdout
 * -des		- encrypt output if PEM format with DES in cbc mode
 * -des3	- encrypt output if PEM format
 * -idea	- encrypt output if PEM format
 * -seed	- encrypt output if PEM format
 * -aes128	- encrypt output if PEM format
 * -aes192	- encrypt output if PEM format
 * -aes256	- encrypt output if PEM format
 * -camellia128 - encrypt output if PEM format
 * -camellia192 - encrypt output if PEM format
 * -camellia256 - encrypt output if PEM format
 * -text	- print a text version
 * -modulus	- print the RSA key modulus
 * -check	- verify key consistency
 * -pubin	- Expect a public key in input file.
 * -pubout	- Output a public key.
 */

int rsa_main(int, char **);

int 
rsa_main(int argc, char **argv)
{
	ENGINE *e = NULL;
	int ret = 1;
	RSA *rsa = NULL;
	int i, badops = 0, sgckey = 0;
	const EVP_CIPHER *enc = NULL;
	BIO *out = NULL;
	int informat, outformat, text = 0, check = 0, noout = 0;
	int pubin = 0, pubout = 0;
	char *infile, *outfile, *prog;
	char *passargin = NULL, *passargout = NULL;
	char *passin = NULL, *passout = NULL;
#ifndef OPENSSL_NO_ENGINE
	char *engine = NULL;
#endif
	int modulus = 0;

	int pvk_encr = 2;

	if (!load_config(bio_err, NULL))
		goto end;

	infile = NULL;
	outfile = NULL;
	informat = FORMAT_PEM;
	outformat = FORMAT_PEM;

	prog = argv[0];
	argc--;
	argv++;
	while (argc >= 1) {
		if (strcmp(*argv, "-inform") == 0) {
			if (--argc < 1)
				goto bad;
			informat = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-outform") == 0) {
			if (--argc < 1)
				goto bad;
			outformat = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-in") == 0) {
			if (--argc < 1)
				goto bad;
			infile = *(++argv);
		} else if (strcmp(*argv, "-out") == 0) {
			if (--argc < 1)
				goto bad;
			outfile = *(++argv);
		} else if (strcmp(*argv, "-passin") == 0) {
			if (--argc < 1)
				goto bad;
			passargin = *(++argv);
		} else if (strcmp(*argv, "-passout") == 0) {
			if (--argc < 1)
				goto bad;
			passargout = *(++argv);
		}
#ifndef OPENSSL_NO_ENGINE
		else if (strcmp(*argv, "-engine") == 0) {
			if (--argc < 1)
				goto bad;
			engine = *(++argv);
		}
#endif
		else if (strcmp(*argv, "-sgckey") == 0)
			sgckey = 1;
		else if (strcmp(*argv, "-pubin") == 0)
			pubin = 1;
		else if (strcmp(*argv, "-pubout") == 0)
			pubout = 1;
		else if (strcmp(*argv, "-RSAPublicKey_in") == 0)
			pubin = 2;
		else if (strcmp(*argv, "-RSAPublicKey_out") == 0)
			pubout = 2;
		else if (strcmp(*argv, "-pvk-strong") == 0)
			pvk_encr = 2;
		else if (strcmp(*argv, "-pvk-weak") == 0)
			pvk_encr = 1;
		else if (strcmp(*argv, "-pvk-none") == 0)
			pvk_encr = 0;
		else if (strcmp(*argv, "-noout") == 0)
			noout = 1;
		else if (strcmp(*argv, "-text") == 0)
			text = 1;
		else if (strcmp(*argv, "-modulus") == 0)
			modulus = 1;
		else if (strcmp(*argv, "-check") == 0)
			check = 1;
		else if ((enc = EVP_get_cipherbyname(&(argv[0][1]))) == NULL) {
			BIO_printf(bio_err, "unknown option %s\n", *argv);
			badops = 1;
			break;
		}
		argc--;
		argv++;
	}

	if (badops) {
bad:
		BIO_printf(bio_err, "%s [options] outfile\n", prog);
		BIO_printf(bio_err, "where options are\n");
		BIO_printf(bio_err, " -inform arg     input format - one of DER NET PEM\n");
		BIO_printf(bio_err, " -outform arg    output format - one of DER NET PEM\n");
		BIO_printf(bio_err, " -in arg         input file\n");
		BIO_printf(bio_err, " -sgckey         Use IIS SGC key format\n");
		BIO_printf(bio_err, " -passin arg     input file pass phrase source\n");
		BIO_printf(bio_err, " -out arg        output file\n");
		BIO_printf(bio_err, " -passout arg    output file pass phrase source\n");
		BIO_printf(bio_err, " -des            encrypt PEM output with cbc des\n");
		BIO_printf(bio_err, " -des3           encrypt PEM output with ede cbc des using 168 bit key\n");
#ifndef OPENSSL_NO_IDEA
		BIO_printf(bio_err, " -idea           encrypt PEM output with cbc idea\n");
#endif
#ifndef OPENSSL_NO_AES
		BIO_printf(bio_err, " -aes128, -aes192, -aes256\n");
		BIO_printf(bio_err, "                 encrypt PEM output with cbc aes\n");
#endif
#ifndef OPENSSL_NO_CAMELLIA
		BIO_printf(bio_err, " -camellia128, -camellia192, -camellia256\n");
		BIO_printf(bio_err, "                 encrypt PEM output with cbc camellia\n");
#endif
		BIO_printf(bio_err, " -text           print the key in text\n");
		BIO_printf(bio_err, " -noout          don't print key out\n");
		BIO_printf(bio_err, " -modulus        print the RSA key modulus\n");
		BIO_printf(bio_err, " -check          verify key consistency\n");
		BIO_printf(bio_err, " -pubin          expect a public key in input file\n");
		BIO_printf(bio_err, " -pubout         output a public key\n");
#ifndef OPENSSL_NO_ENGINE
		BIO_printf(bio_err, " -engine e       use engine e, possibly a hardware device.\n");
#endif
		goto end;
	}
	ERR_load_crypto_strings();

#ifndef OPENSSL_NO_ENGINE
	e = setup_engine(bio_err, engine, 0);
#endif

	if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
		BIO_printf(bio_err, "Error getting passwords\n");
		goto end;
	}
	if (check && pubin) {
		BIO_printf(bio_err, "Only private keys can be checked\n");
		goto end;
	}
	out = BIO_new(BIO_s_file());

	{
		EVP_PKEY *pkey;

		if (pubin) {
			int tmpformat = -1;
			if (pubin == 2) {
				if (informat == FORMAT_PEM)
					tmpformat = FORMAT_PEMRSA;
				else if (informat == FORMAT_ASN1)
					tmpformat = FORMAT_ASN1RSA;
			} else if (informat == FORMAT_NETSCAPE && sgckey)
				tmpformat = FORMAT_IISSGC;
			else
				tmpformat = informat;

			pkey = load_pubkey(bio_err, infile, tmpformat, 1,
			    passin, e, "Public Key");
		} else
			pkey = load_key(bio_err, infile,
			    (informat == FORMAT_NETSCAPE && sgckey ?
				FORMAT_IISSGC : informat), 1,
			    passin, e, "Private Key");

		if (pkey != NULL)
			rsa = EVP_PKEY_get1_RSA(pkey);
		EVP_PKEY_free(pkey);
	}

	if (rsa == NULL) {
		ERR_print_errors(bio_err);
		goto end;
	}
	if (outfile == NULL) {
		BIO_set_fp(out, stdout, BIO_NOCLOSE);
	} else {
		if (BIO_write_filename(out, outfile) <= 0) {
			perror(outfile);
			goto end;
		}
	}

	if (text)
		if (!RSA_print(out, rsa, 0)) {
			perror(outfile);
			ERR_print_errors(bio_err);
			goto end;
		}
	if (modulus) {
		BIO_printf(out, "Modulus=");
		BN_print(out, rsa->n);
		BIO_printf(out, "\n");
	}
	if (check) {
		int r = RSA_check_key(rsa);

		if (r == 1)
			BIO_printf(out, "RSA key ok\n");
		else if (r == 0) {
			unsigned long err;

			while ((err = ERR_peek_error()) != 0 &&
			    ERR_GET_LIB(err) == ERR_LIB_RSA &&
			    ERR_GET_FUNC(err) == RSA_F_RSA_CHECK_KEY &&
			    ERR_GET_REASON(err) != ERR_R_MALLOC_FAILURE) {
				BIO_printf(out, "RSA key error: %s\n", ERR_reason_error_string(err));
				ERR_get_error();	/* remove e from error
							 * stack */
			}
		}
		if (r == -1 || ERR_peek_error() != 0) {	/* should happen only if
							 * r == -1 */
			ERR_print_errors(bio_err);
			goto end;
		}
	}
	if (noout) {
		ret = 0;
		goto end;
	}
	BIO_printf(bio_err, "writing RSA key\n");
	if (outformat == FORMAT_ASN1) {
		if (pubout || pubin) {
			if (pubout == 2)
				i = i2d_RSAPublicKey_bio(out, rsa);
			else
				i = i2d_RSA_PUBKEY_bio(out, rsa);
		} else
			i = i2d_RSAPrivateKey_bio(out, rsa);
	}
#ifndef OPENSSL_NO_RC4
	else if (outformat == FORMAT_NETSCAPE) {
		unsigned char *p, *pp;
		int size;

		i = 1;
		size = i2d_RSA_NET(rsa, NULL, NULL, sgckey);
		if ((p = malloc(size)) == NULL) {
			BIO_printf(bio_err, "Memory allocation failure\n");
			goto end;
		}
		pp = p;
		i2d_RSA_NET(rsa, &p, NULL, sgckey);
		BIO_write(out, (char *) pp, size);
		free(pp);
	}
#endif
	else if (outformat == FORMAT_PEM) {
		if (pubout || pubin) {
			if (pubout == 2)
				i = PEM_write_bio_RSAPublicKey(out, rsa);
			else
				i = PEM_write_bio_RSA_PUBKEY(out, rsa);
		} else
			i = PEM_write_bio_RSAPrivateKey(out, rsa,
			    enc, NULL, 0, NULL, passout);
#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4)
	} else if (outformat == FORMAT_MSBLOB || outformat == FORMAT_PVK) {
		EVP_PKEY *pk;
		pk = EVP_PKEY_new();
		EVP_PKEY_set1_RSA(pk, rsa);
		if (outformat == FORMAT_PVK)
			i = i2b_PVK_bio(out, pk, pvk_encr, 0, passout);
		else if (pubin || pubout)
			i = i2b_PublicKey_bio(out, pk);
		else
			i = i2b_PrivateKey_bio(out, pk);
		EVP_PKEY_free(pk);
#endif
	} else {
		BIO_printf(bio_err, "bad output format specified for outfile\n");
		goto end;
	}
	if (i <= 0) {
		BIO_printf(bio_err, "unable to write key\n");
		ERR_print_errors(bio_err);
	} else
		ret = 0;
end:
	if (out != NULL)
		BIO_free_all(out);
	if (rsa != NULL)
		RSA_free(rsa);
	free(passin);
	free(passout);
	
	return (ret);
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/crl2p7.c0000644000175000017500000002223212360020706017155 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

/* This was written by Gordon Chaffee 
 * and donated 'to the cause' along with lots and lots of other fixes to
 * the library. */

#include 

#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 
#include 
#include 

static int add_certs_from_file(STACK_OF(X509) * stack, char *certfile);

/* -inform arg	- input format - default PEM (DER or PEM)
 * -outform arg - output format - default PEM
 * -in arg	- input file - default stdin
 * -out arg	- output file - default stdout
 */

int crl2pkcs7_main(int, char **);

int
crl2pkcs7_main(int argc, char **argv)
{
	int i, badops = 0;
	BIO *in = NULL, *out = NULL;
	int informat, outformat;
	char *infile, *outfile, *prog, *certfile;
	PKCS7 *p7 = NULL;
	PKCS7_SIGNED *p7s = NULL;
	X509_CRL *crl = NULL;
	STACK_OF(OPENSSL_STRING) * certflst = NULL;
	STACK_OF(X509_CRL) * crl_stack = NULL;
	STACK_OF(X509) * cert_stack = NULL;
	int ret = 1, nocrl = 0;

	infile = NULL;
	outfile = NULL;
	informat = FORMAT_PEM;
	outformat = FORMAT_PEM;

	prog = argv[0];
	argc--;
	argv++;
	while (argc >= 1) {
		if (strcmp(*argv, "-inform") == 0) {
			if (--argc < 1)
				goto bad;
			informat = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-outform") == 0) {
			if (--argc < 1)
				goto bad;
			outformat = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-in") == 0) {
			if (--argc < 1)
				goto bad;
			infile = *(++argv);
		} else if (strcmp(*argv, "-nocrl") == 0) {
			nocrl = 1;
		} else if (strcmp(*argv, "-out") == 0) {
			if (--argc < 1)
				goto bad;
			outfile = *(++argv);
		} else if (strcmp(*argv, "-certfile") == 0) {
			if (--argc < 1)
				goto bad;
			if (!certflst)
				certflst = sk_OPENSSL_STRING_new_null();
			sk_OPENSSL_STRING_push(certflst, *(++argv));
		} else {
			BIO_printf(bio_err, "unknown option %s\n", *argv);
			badops = 1;
			break;
		}
		argc--;
		argv++;
	}

	if (badops) {
bad:
		BIO_printf(bio_err, "%s [options] outfile\n", prog);
		BIO_printf(bio_err, "where options are\n");
		BIO_printf(bio_err, " -inform arg    input format - DER or PEM\n");
		BIO_printf(bio_err, " -outform arg   output format - DER or PEM\n");
		BIO_printf(bio_err, " -in arg        input file\n");
		BIO_printf(bio_err, " -out arg       output file\n");
		BIO_printf(bio_err, " -certfile arg  certificates file of chain to a trusted CA\n");
		BIO_printf(bio_err, "                (can be used more than once)\n");
		BIO_printf(bio_err, " -nocrl         no crl to load, just certs from '-certfile'\n");
		ret = 1;
		goto end;
	}
	ERR_load_crypto_strings();

	in = BIO_new(BIO_s_file());
	out = BIO_new(BIO_s_file());
	if ((in == NULL) || (out == NULL)) {
		ERR_print_errors(bio_err);
		goto end;
	}
	if (!nocrl) {
		if (infile == NULL)
			BIO_set_fp(in, stdin, BIO_NOCLOSE);
		else {
			if (BIO_read_filename(in, infile) <= 0) {
				perror(infile);
				goto end;
			}
		}

		if (informat == FORMAT_ASN1)
			crl = d2i_X509_CRL_bio(in, NULL);
		else if (informat == FORMAT_PEM)
			crl = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL);
		else {
			BIO_printf(bio_err,
			    "bad input format specified for input crl\n");
			goto end;
		}
		if (crl == NULL) {
			BIO_printf(bio_err, "unable to load CRL\n");
			ERR_print_errors(bio_err);
			goto end;
		}
	}
	if ((p7 = PKCS7_new()) == NULL)
		goto end;
	if ((p7s = PKCS7_SIGNED_new()) == NULL)
		goto end;
	p7->type = OBJ_nid2obj(NID_pkcs7_signed);
	p7->d.sign = p7s;
	p7s->contents->type = OBJ_nid2obj(NID_pkcs7_data);

	if (!ASN1_INTEGER_set(p7s->version, 1))
		goto end;
	if ((crl_stack = sk_X509_CRL_new_null()) == NULL)
		goto end;
	p7s->crl = crl_stack;
	if (crl != NULL) {
		sk_X509_CRL_push(crl_stack, crl);
		crl = NULL;	/* now part of p7 for freeing */
	}
	if ((cert_stack = sk_X509_new_null()) == NULL)
		goto end;
	p7s->cert = cert_stack;

	if (certflst)
		for (i = 0; i < sk_OPENSSL_STRING_num(certflst); i++) {
			certfile = sk_OPENSSL_STRING_value(certflst, i);
			if (add_certs_from_file(cert_stack, certfile) < 0) {
				BIO_printf(bio_err,
				    "error loading certificates\n");
				ERR_print_errors(bio_err);
				goto end;
			}
		}

	sk_OPENSSL_STRING_free(certflst);

	if (outfile == NULL) {
		BIO_set_fp(out, stdout, BIO_NOCLOSE);
	} else {
		if (BIO_write_filename(out, outfile) <= 0) {
			perror(outfile);
			goto end;
		}
	}

	if (outformat == FORMAT_ASN1)
		i = i2d_PKCS7_bio(out, p7);
	else if (outformat == FORMAT_PEM)
		i = PEM_write_bio_PKCS7(out, p7);
	else {
		BIO_printf(bio_err,
		    "bad output format specified for outfile\n");
		goto end;
	}
	if (!i) {
		BIO_printf(bio_err, "unable to write pkcs7 object\n");
		ERR_print_errors(bio_err);
		goto end;
	}
	ret = 0;

end:
	if (in != NULL)
		BIO_free(in);
	if (out != NULL)
		BIO_free_all(out);
	if (p7 != NULL)
		PKCS7_free(p7);
	if (crl != NULL)
		X509_CRL_free(crl);

	
	return (ret);
}

/*
 *----------------------------------------------------------------------
 * int add_certs_from_file
 *
 *	Read a list of certificates to be checked from a file.
 *
 * Results:
 *	number of certs added if successful, -1 if not.
 *----------------------------------------------------------------------
 */
static int
add_certs_from_file(STACK_OF(X509) * stack, char *certfile)
{
	BIO *in = NULL;
	int count = 0;
	int ret = -1;
	STACK_OF(X509_INFO) * sk = NULL;
	X509_INFO *xi;

	in = BIO_new(BIO_s_file());
	if ((in == NULL) || (BIO_read_filename(in, certfile) <= 0)) {
		BIO_printf(bio_err, "error opening the file, %s\n", certfile);
		goto end;
	}
	/* This loads from a file, a stack of x509/crl/pkey sets */
	sk = PEM_X509_INFO_read_bio(in, NULL, NULL, NULL);
	if (sk == NULL) {
		BIO_printf(bio_err, "error reading the file, %s\n", certfile);
		goto end;
	}
	/* scan over it and pull out the CRL's */
	while (sk_X509_INFO_num(sk)) {
		xi = sk_X509_INFO_shift(sk);
		if (xi->x509 != NULL) {
			sk_X509_push(stack, xi->x509);
			xi->x509 = NULL;
			count++;
		}
		X509_INFO_free(xi);
	}

	ret = count;

end:
	/* never need to free x */
	if (in != NULL)
		BIO_free(in);
	if (sk != NULL)
		sk_X509_INFO_free(sk);
	return (ret);
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/dhparam.c0000644000175000017500000003406312360020706017465 0ustar  /* $OpenBSD: dhparam.c,v 1.30 2014/06/12 15:49:27 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */
/* ====================================================================
 * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#include 	/* for OPENSSL_NO_DH */

#ifndef OPENSSL_NO_DH

#include 
#include 
#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 
#include 
#include 

#include 

#define DEFBITS	512

/* -inform arg	- input format - default PEM (DER or PEM)
 * -outform arg - output format - default PEM
 * -in arg	- input file - default stdin
 * -out arg	- output file - default stdout
 * -dsaparam  - read or generate DSA parameters, convert to DH
 * -check	- check the parameters are ok
 * -noout
 * -text
 * -C
 */

static int dh_cb(int p, int n, BN_GENCB * cb);

int dhparam_main(int, char **);

int
dhparam_main(int argc, char **argv)
{
	DH *dh = NULL;
	int i, badops = 0, text = 0;
	int dsaparam = 0;
	BIO *in = NULL, *out = NULL;
	int informat, outformat, check = 0, noout = 0, C = 0, ret = 1;
	char *infile, *outfile, *prog;
#ifndef OPENSSL_NO_ENGINE
	char *engine = NULL;
#endif
	int num = 0, g = 0;

	if (!load_config(bio_err, NULL))
		goto end;

	infile = NULL;
	outfile = NULL;
	informat = FORMAT_PEM;
	outformat = FORMAT_PEM;

	prog = argv[0];
	argc--;
	argv++;
	while (argc >= 1) {
		if (strcmp(*argv, "-inform") == 0) {
			if (--argc < 1)
				goto bad;
			informat = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-outform") == 0) {
			if (--argc < 1)
				goto bad;
			outformat = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-in") == 0) {
			if (--argc < 1)
				goto bad;
			infile = *(++argv);
		} else if (strcmp(*argv, "-out") == 0) {
			if (--argc < 1)
				goto bad;
			outfile = *(++argv);
		}
#ifndef OPENSSL_NO_ENGINE
		else if (strcmp(*argv, "-engine") == 0) {
			if (--argc < 1)
				goto bad;
			engine = *(++argv);
		}
#endif
		else if (strcmp(*argv, "-check") == 0)
			check = 1;
		else if (strcmp(*argv, "-text") == 0)
			text = 1;
		else if (strcmp(*argv, "-dsaparam") == 0)
			dsaparam = 1;
		else if (strcmp(*argv, "-C") == 0)
			C = 1;
		else if (strcmp(*argv, "-noout") == 0)
			noout = 1;
		else if (strcmp(*argv, "-2") == 0)
			g = 2;
		else if (strcmp(*argv, "-5") == 0)
			g = 5;
		else if (((sscanf(*argv, "%d", &num) == 0) || (num <= 0)))
			goto bad;
		argv++;
		argc--;
	}

	if (badops) {
bad:
		BIO_printf(bio_err, "%s [options] [numbits]\n", prog);
		BIO_printf(bio_err, "where options are\n");
		BIO_printf(bio_err, " -inform arg   input format - one of DER PEM\n");
		BIO_printf(bio_err, " -outform arg  output format - one of DER PEM\n");
		BIO_printf(bio_err, " -in arg       input file\n");
		BIO_printf(bio_err, " -out arg      output file\n");
		BIO_printf(bio_err, " -dsaparam     read or generate DSA parameters, convert to DH\n");
		BIO_printf(bio_err, " -check        check the DH parameters\n");
		BIO_printf(bio_err, " -text         print a text form of the DH parameters\n");
		BIO_printf(bio_err, " -C            Output C code\n");
		BIO_printf(bio_err, " -2            generate parameters using  2 as the generator value\n");
		BIO_printf(bio_err, " -5            generate parameters using  5 as the generator value\n");
		BIO_printf(bio_err, " numbits       number of bits in to generate (default 512)\n");
#ifndef OPENSSL_NO_ENGINE
		BIO_printf(bio_err, " -engine e     use engine e, possibly a hardware device.\n");
#endif
		BIO_printf(bio_err, " -noout        no output\n");
		goto end;
	}
	ERR_load_crypto_strings();

#ifndef OPENSSL_NO_ENGINE
	setup_engine(bio_err, engine, 0);
#endif

	if (g && !num)
		num = DEFBITS;

	if (dsaparam) {
		if (g) {
			BIO_printf(bio_err, "generator may not be chosen for DSA parameters\n");
			goto end;
		}
	} else
	{
		/* DH parameters */
		if (num && !g)
			g = 2;
	}

	if (num) {

		BN_GENCB cb;
		BN_GENCB_set(&cb, dh_cb, bio_err);
		if (dsaparam) {
			DSA *dsa = DSA_new();

			BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n", num);
			if (!dsa || !DSA_generate_parameters_ex(dsa, num,
				NULL, 0, NULL, NULL, &cb)) {
				if (dsa)
					DSA_free(dsa);
				ERR_print_errors(bio_err);
				goto end;
			}
			dh = DSA_dup_DH(dsa);
			DSA_free(dsa);
			if (dh == NULL) {
				ERR_print_errors(bio_err);
				goto end;
			}
		} else
		{
			dh = DH_new();
			BIO_printf(bio_err, "Generating DH parameters, %d bit long safe prime, generator %d\n", num, g);
			BIO_printf(bio_err, "This is going to take a long time\n");
			if (!dh || !DH_generate_parameters_ex(dh, num, g, &cb)) {
				ERR_print_errors(bio_err);
				goto end;
			}
		}
	} else {

		in = BIO_new(BIO_s_file());
		if (in == NULL) {
			ERR_print_errors(bio_err);
			goto end;
		}
		if (infile == NULL)
			BIO_set_fp(in, stdin, BIO_NOCLOSE);
		else {
			if (BIO_read_filename(in, infile) <= 0) {
				perror(infile);
				goto end;
			}
		}

		if (informat != FORMAT_ASN1 && informat != FORMAT_PEM) {
			BIO_printf(bio_err, "bad input format specified\n");
			goto end;
		}
		if (dsaparam) {
			DSA *dsa;

			if (informat == FORMAT_ASN1)
				dsa = d2i_DSAparams_bio(in, NULL);
			else	/* informat == FORMAT_PEM */
				dsa = PEM_read_bio_DSAparams(in, NULL, NULL, NULL);

			if (dsa == NULL) {
				BIO_printf(bio_err, "unable to load DSA parameters\n");
				ERR_print_errors(bio_err);
				goto end;
			}
			dh = DSA_dup_DH(dsa);
			DSA_free(dsa);
			if (dh == NULL) {
				ERR_print_errors(bio_err);
				goto end;
			}
		} else
		{
			if (informat == FORMAT_ASN1)
				dh = d2i_DHparams_bio(in, NULL);
			else	/* informat == FORMAT_PEM */
				dh = PEM_read_bio_DHparams(in, NULL, NULL, NULL);

			if (dh == NULL) {
				BIO_printf(bio_err, "unable to load DH parameters\n");
				ERR_print_errors(bio_err);
				goto end;
			}
		}

		/* dh != NULL */
	}

	out = BIO_new(BIO_s_file());
	if (out == NULL) {
		ERR_print_errors(bio_err);
		goto end;
	}
	if (outfile == NULL) {
		BIO_set_fp(out, stdout, BIO_NOCLOSE);
	} else {
		if (BIO_write_filename(out, outfile) <= 0) {
			perror(outfile);
			goto end;
		}
	}


	if (text) {
		DHparams_print(out, dh);
	}
	if (check) {
		if (!DH_check(dh, &i)) {
			ERR_print_errors(bio_err);
			goto end;
		}
		if (i & DH_CHECK_P_NOT_PRIME)
			printf("p value is not prime\n");
		if (i & DH_CHECK_P_NOT_SAFE_PRIME)
			printf("p value is not a safe prime\n");
		if (i & DH_UNABLE_TO_CHECK_GENERATOR)
			printf("unable to check the generator value\n");
		if (i & DH_NOT_SUITABLE_GENERATOR)
			printf("the g value is not a generator\n");
		if (i == 0)
			printf("DH parameters appear to be ok.\n");
	}
	if (C) {
		unsigned char *data;
		int len, l, bits;

		len = BN_num_bytes(dh->p);
		bits = BN_num_bits(dh->p);
		data = malloc(len);
		if (data == NULL) {
			perror("malloc");
			goto end;
		}
		printf("#ifndef HEADER_DH_H\n"
		    "#include \n"
		    "#endif\n");
		printf("DH *get_dh%d()\n\t{\n", bits);

		l = BN_bn2bin(dh->p, data);
		printf("\tstatic unsigned char dh%d_p[] = {", bits);
		for (i = 0; i < l; i++) {
			if ((i % 12) == 0)
				printf("\n\t\t");
			printf("0x%02X, ", data[i]);
		}
		printf("\n\t\t};\n");

		l = BN_bn2bin(dh->g, data);
		printf("\tstatic unsigned char dh%d_g[] = {", bits);
		for (i = 0; i < l; i++) {
			if ((i % 12) == 0)
				printf("\n\t\t");
			printf("0x%02X, ", data[i]);
		}
		printf("\n\t\t};\n");

		printf("\tDH *dh;\n\n");
		printf("\tif ((dh = DH_new()) == NULL) return(NULL);\n");
		printf("\tdh->p = BN_bin2bn(dh%d_p, sizeof(dh%d_p), NULL);\n",
		    bits, bits);
		printf("\tdh->g = BN_bin2bn(dh%d_g, sizeof(dh%d_g), NULL);\n",
		    bits, bits);
		printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n");
		printf("\t\t{ DH_free(dh); return(NULL); }\n");
		if (dh->length)
			printf("\tdh->length = %ld;\n", dh->length);
		printf("\treturn(dh);\n\t}\n");
		free(data);
	}
	if (!noout) {
		if (outformat == FORMAT_ASN1)
			i = i2d_DHparams_bio(out, dh);
		else if (outformat == FORMAT_PEM)
			i = PEM_write_bio_DHparams(out, dh);
		else {
			BIO_printf(bio_err, "bad output format specified for outfile\n");
			goto end;
		}
		if (!i) {
			BIO_printf(bio_err, "unable to write DH parameters\n");
			ERR_print_errors(bio_err);
			goto end;
		}
	}
	ret = 0;

end:
	if (in != NULL)
		BIO_free(in);
	if (out != NULL)
		BIO_free_all(out);
	if (dh != NULL)
		DH_free(dh);
	
	return (ret);
}

/* dh_cb is identical to dsa_cb in apps/dsaparam.c */
static int
dh_cb(int p, int n, BN_GENCB * cb)
{
	char c = '*';

	if (p == 0)
		c = '.';
	if (p == 1)
		c = '+';
	if (p == 2)
		c = '*';
	if (p == 3)
		c = '\n';
	BIO_write(cb->arg, &c, 1);
	(void) BIO_flush(cb->arg);
	return 1;
}

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/apps/pkcs12.c0000644000175000017500000006175012360020706017157 0ustar  /* $OpenBSD: pkcs12.c,v 1.35 2014/06/12 15:49:27 deraadt Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
 * project.
 */
/* ====================================================================
 * Copyright (c) 1999-2006 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#include 

#if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_SHA1)

#include 
#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 

const EVP_CIPHER *enc;

#define NOKEYS		0x1
#define NOCERTS 	0x2
#define INFO		0x4
#define CLCERTS		0x8
#define CACERTS		0x10

int get_cert_chain(X509 * cert, X509_STORE * store, STACK_OF(X509) ** chain);
int dump_certs_keys_p12(BIO * out, PKCS12 * p12, char *pass, int passlen,
    int options, char *pempass);
int dump_certs_pkeys_bags(BIO * out, STACK_OF(PKCS12_SAFEBAG) * bags, char *pass,
    int passlen, int options, char *pempass);
int dump_certs_pkeys_bag(BIO * out, PKCS12_SAFEBAG * bags, char *pass, int passlen,
    int options, char *pempass);
int print_attribs(BIO * out, STACK_OF(X509_ATTRIBUTE) * attrlst, const char *name);
void hex_prin(BIO * out, unsigned char *buf, int len);
int alg_print(BIO * x, X509_ALGOR * alg);
int cert_load(BIO * in, STACK_OF(X509) * sk);
static int set_pbe(BIO * err, int *ppbe, const char *str);

int pkcs12_main(int, char **);

int
pkcs12_main(int argc, char **argv)
{
	ENGINE *e = NULL;
	char *infile = NULL, *outfile = NULL, *keyname = NULL;
	char *certfile = NULL;
	BIO *in = NULL, *out = NULL;
	char **args;
	char *name = NULL;
	char *csp_name = NULL;
	int add_lmk = 0;
	PKCS12 *p12 = NULL;
	char pass[50], macpass[50];
	int export_cert = 0;
	int options = 0;
	int chain = 0;
	int badarg = 0;
	int iter = PKCS12_DEFAULT_ITER;
	int maciter = PKCS12_DEFAULT_ITER;
	int twopass = 0;
	int keytype = 0;
	int cert_pbe;
	int key_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
	int ret = 1;
	int macver = 1;
	int noprompt = 0;
	STACK_OF(OPENSSL_STRING) * canames = NULL;
	char *cpass = NULL, *mpass = NULL;
	char *passargin = NULL, *passargout = NULL, *passarg = NULL;
	char *passin = NULL, *passout = NULL;
	char *macalg = NULL;
	char *CApath = NULL, *CAfile = NULL;
#ifndef OPENSSL_NO_ENGINE
	char *engine = NULL;
#endif

	cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC;

	enc = EVP_des_ede3_cbc();

	if (!load_config(bio_err, NULL))
		goto end;

	args = argv + 1;

	while (*args) {
		if (*args[0] == '-') {
			if (!strcmp(*args, "-nokeys"))
				options |= NOKEYS;
			else if (!strcmp(*args, "-keyex"))
				keytype = KEY_EX;
			else if (!strcmp(*args, "-keysig"))
				keytype = KEY_SIG;
			else if (!strcmp(*args, "-nocerts"))
				options |= NOCERTS;
			else if (!strcmp(*args, "-clcerts"))
				options |= CLCERTS;
			else if (!strcmp(*args, "-cacerts"))
				options |= CACERTS;
			else if (!strcmp(*args, "-noout"))
				options |= (NOKEYS | NOCERTS);
			else if (!strcmp(*args, "-info"))
				options |= INFO;
			else if (!strcmp(*args, "-chain"))
				chain = 1;
			else if (!strcmp(*args, "-twopass"))
				twopass = 1;
			else if (!strcmp(*args, "-nomacver"))
				macver = 0;
			else if (!strcmp(*args, "-descert"))
				cert_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
			else if (!strcmp(*args, "-export"))
				export_cert = 1;
			else if (!strcmp(*args, "-des"))
				enc = EVP_des_cbc();
			else if (!strcmp(*args, "-des3"))
				enc = EVP_des_ede3_cbc();
#ifndef OPENSSL_NO_IDEA
			else if (!strcmp(*args, "-idea"))
				enc = EVP_idea_cbc();
#endif
#ifndef OPENSSL_NO_AES
			else if (!strcmp(*args, "-aes128"))
				enc = EVP_aes_128_cbc();
			else if (!strcmp(*args, "-aes192"))
				enc = EVP_aes_192_cbc();
			else if (!strcmp(*args, "-aes256"))
				enc = EVP_aes_256_cbc();
#endif
#ifndef OPENSSL_NO_CAMELLIA
			else if (!strcmp(*args, "-camellia128"))
				enc = EVP_camellia_128_cbc();
			else if (!strcmp(*args, "-camellia192"))
				enc = EVP_camellia_192_cbc();
			else if (!strcmp(*args, "-camellia256"))
				enc = EVP_camellia_256_cbc();
#endif
			else if (!strcmp(*args, "-noiter"))
				iter = 1;
			else if (!strcmp(*args, "-maciter"))
				maciter = PKCS12_DEFAULT_ITER;
			else if (!strcmp(*args, "-nomaciter"))
				maciter = 1;
			else if (!strcmp(*args, "-nomac"))
				maciter = -1;
			else if (!strcmp(*args, "-macalg"))
				if (args[1]) {
					args++;
					macalg = *args;
				} else
					badarg = 1;
			else if (!strcmp(*args, "-nodes"))
				enc = NULL;
			else if (!strcmp(*args, "-certpbe")) {
				if (!set_pbe(bio_err, &cert_pbe, *++args))
					badarg = 1;
			} else if (!strcmp(*args, "-keypbe")) {
				if (!set_pbe(bio_err, &key_pbe, *++args))
					badarg = 1;
			} else if (!strcmp(*args, "-inkey")) {
				if (args[1]) {
					args++;
					keyname = *args;
				} else
					badarg = 1;
			} else if (!strcmp(*args, "-certfile")) {
				if (args[1]) {
					args++;
					certfile = *args;
				} else
					badarg = 1;
			} else if (!strcmp(*args, "-name")) {
				if (args[1]) {
					args++;
					name = *args;
				} else
					badarg = 1;
			} else if (!strcmp(*args, "-LMK"))
				add_lmk = 1;
			else if (!strcmp(*args, "-CSP")) {
				if (args[1]) {
					args++;
					csp_name = *args;
				} else
					badarg = 1;
			} else if (!strcmp(*args, "-caname")) {
				if (args[1]) {
					args++;
					if (!canames)
						canames = sk_OPENSSL_STRING_new_null();
					sk_OPENSSL_STRING_push(canames, *args);
				} else
					badarg = 1;
			} else if (!strcmp(*args, "-in")) {
				if (args[1]) {
					args++;
					infile = *args;
				} else
					badarg = 1;
			} else if (!strcmp(*args, "-out")) {
				if (args[1]) {
					args++;
					outfile = *args;
				} else
					badarg = 1;
			} else if (!strcmp(*args, "-passin")) {
				if (args[1]) {
					args++;
					passargin = *args;
				} else
					badarg = 1;
			} else if (!strcmp(*args, "-passout")) {
				if (args[1]) {
					args++;
					passargout = *args;
				} else
					badarg = 1;
			} else if (!strcmp(*args, "-password")) {
				if (args[1]) {
					args++;
					passarg = *args;
					noprompt = 1;
				} else
					badarg = 1;
			} else if (!strcmp(*args, "-CApath")) {
				if (args[1]) {
					args++;
					CApath = *args;
				} else
					badarg = 1;
			} else if (!strcmp(*args, "-CAfile")) {
				if (args[1]) {
					args++;
					CAfile = *args;
				} else
					badarg = 1;
#ifndef OPENSSL_NO_ENGINE
			} else if (!strcmp(*args, "-engine")) {
				if (args[1]) {
					args++;
					engine = *args;
				} else
					badarg = 1;
#endif
			} else
				badarg = 1;

		} else
			badarg = 1;
		args++;
	}

	if (badarg) {
		BIO_printf(bio_err, "Usage: pkcs12 [options]\n");
		BIO_printf(bio_err, "where options are\n");
		BIO_printf(bio_err, "-export       output PKCS12 file\n");
		BIO_printf(bio_err, "-chain        add certificate chain\n");
		BIO_printf(bio_err, "-inkey file   private key if not infile\n");
		BIO_printf(bio_err, "-certfile f   add all certs in f\n");
		BIO_printf(bio_err, "-CApath arg   - PEM format directory of CA's\n");
		BIO_printf(bio_err, "-CAfile arg   - PEM format file of CA's\n");
		BIO_printf(bio_err, "-name \"name\"  use name as friendly name\n");
		BIO_printf(bio_err, "-caname \"nm\"  use nm as CA friendly name (can be used more than once).\n");
		BIO_printf(bio_err, "-in  infile   input filename\n");
		BIO_printf(bio_err, "-out outfile  output filename\n");
		BIO_printf(bio_err, "-noout        don't output anything, just verify.\n");
		BIO_printf(bio_err, "-nomacver     don't verify MAC.\n");
		BIO_printf(bio_err, "-nocerts      don't output certificates.\n");
		BIO_printf(bio_err, "-clcerts      only output client certificates.\n");
		BIO_printf(bio_err, "-cacerts      only output CA certificates.\n");
		BIO_printf(bio_err, "-nokeys       don't output private keys.\n");
		BIO_printf(bio_err, "-info         give info about PKCS#12 structure.\n");
		BIO_printf(bio_err, "-des          encrypt private keys with DES\n");
		BIO_printf(bio_err, "-des3         encrypt private keys with triple DES (default)\n");
#ifndef OPENSSL_NO_IDEA
		BIO_printf(bio_err, "-idea         encrypt private keys with idea\n");
#endif
#ifndef OPENSSL_NO_AES
		BIO_printf(bio_err, "-aes128, -aes192, -aes256\n");
		BIO_printf(bio_err, "              encrypt PEM output with cbc aes\n");
#endif
#ifndef OPENSSL_NO_CAMELLIA
		BIO_printf(bio_err, "-camellia128, -camellia192, -camellia256\n");
		BIO_printf(bio_err, "              encrypt PEM output with cbc camellia\n");
#endif
		BIO_printf(bio_err, "-nodes        don't encrypt private keys\n");
		BIO_printf(bio_err, "-noiter       don't use encryption iteration\n");
		BIO_printf(bio_err, "-nomaciter    don't use MAC iteration\n");
		BIO_printf(bio_err, "-maciter      use MAC iteration\n");
		BIO_printf(bio_err, "-nomac        don't generate MAC\n");
		BIO_printf(bio_err, "-twopass      separate MAC, encryption passwords\n");
		BIO_printf(bio_err, "-descert      encrypt PKCS#12 certificates with triple DES (default RC2-40)\n");
		BIO_printf(bio_err, "-certpbe alg  specify certificate PBE algorithm (default RC2-40)\n");
		BIO_printf(bio_err, "-keypbe alg   specify private key PBE algorithm (default 3DES)\n");
		BIO_printf(bio_err, "-macalg alg   digest algorithm used in MAC (default SHA1)\n");
		BIO_printf(bio_err, "-keyex        set MS key exchange type\n");
		BIO_printf(bio_err, "-keysig       set MS key signature type\n");
		BIO_printf(bio_err, "-password p   set import/export password source\n");
		BIO_printf(bio_err, "-passin p     input file pass phrase source\n");
		BIO_printf(bio_err, "-passout p    output file pass phrase source\n");
#ifndef OPENSSL_NO_ENGINE
		BIO_printf(bio_err, "-engine e     use engine e, possibly a hardware device.\n");
#endif
		BIO_printf(bio_err, "-CSP name     Microsoft CSP name\n");
		BIO_printf(bio_err, "-LMK          Add local machine keyset attribute to private key\n");
		goto end;
	}
#ifndef OPENSSL_NO_ENGINE
	e = setup_engine(bio_err, engine, 0);
#endif

	if (passarg) {
		if (export_cert)
			passargout = passarg;
		else
			passargin = passarg;
	}
	if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
		BIO_printf(bio_err, "Error getting passwords\n");
		goto end;
	}
	if (!cpass) {
		if (export_cert)
			cpass = passout;
		else
			cpass = passin;
	}
	if (cpass) {
		mpass = cpass;
		noprompt = 1;
	} else {
		cpass = pass;
		mpass = macpass;
	}

	ERR_load_crypto_strings();


	if (!infile)
		in = BIO_new_fp(stdin, BIO_NOCLOSE);
	else
		in = BIO_new_file(infile, "rb");
	if (!in) {
		BIO_printf(bio_err, "Error opening input file %s\n",
		    infile ? infile : "");
		perror(infile);
		goto end;
	}

	if (!outfile) {
		out = BIO_new_fp(stdout, BIO_NOCLOSE);
	} else
		out = BIO_new_file(outfile, "wb");
	if (!out) {
		BIO_printf(bio_err, "Error opening output file %s\n",
		    outfile ? outfile : "");
		perror(outfile);
		goto end;
	}
	if (twopass) {
		if (EVP_read_pw_string(macpass, sizeof macpass, "Enter MAC Password:", export_cert)) {
			BIO_printf(bio_err, "Can't read Password\n");
			goto end;
		}
	}
	if (export_cert) {
		EVP_PKEY *key = NULL;
		X509 *ucert = NULL, *x = NULL;
		STACK_OF(X509) * certs = NULL;
		const EVP_MD *macmd = NULL;
		unsigned char *catmp = NULL;
		int i;

		if ((options & (NOCERTS | NOKEYS)) == (NOCERTS | NOKEYS)) {
			BIO_printf(bio_err, "Nothing to do!\n");
			goto export_end;
		}
		if (options & NOCERTS)
			chain = 0;

		if (!(options & NOKEYS)) {
			key = load_key(bio_err, keyname ? keyname : infile,
			    FORMAT_PEM, 1, passin, e, "private key");
			if (!key)
				goto export_end;
		}

		/* Load in all certs in input file */
		if (!(options & NOCERTS)) {
			certs = load_certs(bio_err, infile, FORMAT_PEM, NULL, e,
			    "certificates");
			if (!certs)
				goto export_end;

			if (key) {
				/* Look for matching private key */
				for (i = 0; i < sk_X509_num(certs); i++) {
					x = sk_X509_value(certs, i);
					if (X509_check_private_key(x, key)) {
						ucert = x;
						/* Zero keyid and alias */
						X509_keyid_set1(ucert, NULL, 0);
						X509_alias_set1(ucert, NULL, 0);
						/* Remove from list */
						(void) sk_X509_delete(certs, i);
						break;
					}
				}
				if (!ucert) {
					BIO_printf(bio_err, "No certificate matches private key\n");
					goto export_end;
				}
			}
		}

		/* Add any more certificates asked for */
		if (certfile) {
			STACK_OF(X509) * morecerts = NULL;
			if (!(morecerts = load_certs(bio_err, certfile, FORMAT_PEM,
				    NULL, e,
				    "certificates from certfile")))
				goto export_end;
			while (sk_X509_num(morecerts) > 0)
				sk_X509_push(certs, sk_X509_shift(morecerts));
			sk_X509_free(morecerts);
		}


		/* If chaining get chain from user cert */
		if (chain) {
			int vret;
			STACK_OF(X509) * chain2;
			X509_STORE *store = X509_STORE_new();
			if (!store) {
				BIO_printf(bio_err, "Memory allocation error\n");
				goto export_end;
			}
			if (!X509_STORE_load_locations(store, CAfile, CApath))
				X509_STORE_set_default_paths(store);

			vret = get_cert_chain(ucert, store, &chain2);
			X509_STORE_free(store);

			if (!vret) {
				/* Exclude verified certificate */
				for (i = 1; i < sk_X509_num(chain2); i++)
					sk_X509_push(certs, sk_X509_value(chain2, i));
				/* Free first certificate */
				X509_free(sk_X509_value(chain2, 0));
				sk_X509_free(chain2);
			} else {
				if (vret >= 0)
					BIO_printf(bio_err, "Error %s getting chain.\n",
					    X509_verify_cert_error_string(vret));
				else
					ERR_print_errors(bio_err);
				goto export_end;
			}
		}
		/* Add any CA names */

		for (i = 0; i < sk_OPENSSL_STRING_num(canames); i++) {
			catmp = (unsigned char *) sk_OPENSSL_STRING_value(canames, i);
			X509_alias_set1(sk_X509_value(certs, i), catmp, -1);
		}

		if (csp_name && key)
			EVP_PKEY_add1_attr_by_NID(key, NID_ms_csp_name,
			    MBSTRING_ASC, (unsigned char *) csp_name, -1);

		if (add_lmk && key)
			EVP_PKEY_add1_attr_by_NID(key, NID_LocalKeySet, 0, NULL, -1);


		if (!noprompt &&
		    EVP_read_pw_string(pass, sizeof pass, "Enter Export Password:", 1)) {
			BIO_printf(bio_err, "Can't read Password\n");
			goto export_end;
		}
		if (!twopass)
			strlcpy(macpass, pass, sizeof macpass);


		p12 = PKCS12_create(cpass, name, key, ucert, certs,
		    key_pbe, cert_pbe, iter, -1, keytype);

		if (!p12) {
			ERR_print_errors(bio_err);
			goto export_end;
		}
		if (macalg) {
			macmd = EVP_get_digestbyname(macalg);
			if (!macmd) {
				BIO_printf(bio_err, "Unknown digest algorithm %s\n",
				    macalg);
			}
		}
		if (maciter != -1)
			PKCS12_set_mac(p12, mpass, -1, NULL, 0, maciter, macmd);


		i2d_PKCS12_bio(out, p12);

		ret = 0;

export_end:

		if (key)
			EVP_PKEY_free(key);
		if (certs)
			sk_X509_pop_free(certs, X509_free);
		if (ucert)
			X509_free(ucert);

		goto end;

	}
	if (!(p12 = d2i_PKCS12_bio(in, NULL))) {
		ERR_print_errors(bio_err);
		goto end;
	}
	if (!noprompt && EVP_read_pw_string(pass, sizeof pass, "Enter Import Password:", 0)) {
		BIO_printf(bio_err, "Can't read Password\n");
		goto end;
	}

	if (!twopass)
		strlcpy(macpass, pass, sizeof macpass);

	if ((options & INFO) && p12->mac)
		BIO_printf(bio_err, "MAC Iteration %ld\n", p12->mac->iter ? ASN1_INTEGER_get(p12->mac->iter) : 1);
	if (macver) {
		/* If we enter empty password try no password first */
		if (!mpass[0] && PKCS12_verify_mac(p12, NULL, 0)) {
			/* If mac and crypto pass the same set it to NULL too */
			if (!twopass)
				cpass = NULL;
		} else if (!PKCS12_verify_mac(p12, mpass, -1)) {
			BIO_printf(bio_err, "Mac verify error: invalid password?\n");
			ERR_print_errors(bio_err);
			goto end;
		}
		BIO_printf(bio_err, "MAC verified OK\n");
	}
	if (!dump_certs_keys_p12(out, p12, cpass, -1, options, passout)) {
		BIO_printf(bio_err, "Error outputting keys and certificates\n");
		ERR_print_errors(bio_err);
		goto end;
	}
	ret = 0;
end:
	if (p12)
		PKCS12_free(p12);
	BIO_free(in);
	BIO_free_all(out);
	if (canames)
		sk_OPENSSL_STRING_free(canames);
	free(passin);
	free(passout);
	
	return (ret);
}

int 
dump_certs_keys_p12(BIO * out, PKCS12 * p12, char *pass,
    int passlen, int options, char *pempass)
{
	STACK_OF(PKCS7) * asafes = NULL;
	STACK_OF(PKCS12_SAFEBAG) * bags;
	int i, bagnid;
	int ret = 0;
	PKCS7 *p7;

	if (!(asafes = PKCS12_unpack_authsafes(p12)))
		return 0;
	for (i = 0; i < sk_PKCS7_num(asafes); i++) {
		p7 = sk_PKCS7_value(asafes, i);
		bagnid = OBJ_obj2nid(p7->type);
		if (bagnid == NID_pkcs7_data) {
			bags = PKCS12_unpack_p7data(p7);
			if (options & INFO)
				BIO_printf(bio_err, "PKCS7 Data\n");
		} else if (bagnid == NID_pkcs7_encrypted) {
			if (options & INFO) {
				BIO_printf(bio_err, "PKCS7 Encrypted data: ");
				alg_print(bio_err,
				    p7->d.encrypted->enc_data->algorithm);
			}
			bags = PKCS12_unpack_p7encdata(p7, pass, passlen);
		} else
			continue;
		if (!bags)
			goto err;
		if (!dump_certs_pkeys_bags(out, bags, pass, passlen,
			options, pempass)) {
			sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free);
			goto err;
		}
		sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free);
		bags = NULL;
	}
	ret = 1;

err:

	if (asafes)
		sk_PKCS7_pop_free(asafes, PKCS7_free);
	return ret;
}

int 
dump_certs_pkeys_bags(BIO * out, STACK_OF(PKCS12_SAFEBAG) * bags,
    char *pass, int passlen, int options, char *pempass)
{
	int i;
	for (i = 0; i < sk_PKCS12_SAFEBAG_num(bags); i++) {
		if (!dump_certs_pkeys_bag(out,
			sk_PKCS12_SAFEBAG_value(bags, i),
			pass, passlen,
			options, pempass))
			return 0;
	}
	return 1;
}

int 
dump_certs_pkeys_bag(BIO * out, PKCS12_SAFEBAG * bag, char *pass,
    int passlen, int options, char *pempass)
{
	EVP_PKEY *pkey;
	PKCS8_PRIV_KEY_INFO *p8;
	X509 *x509;

	switch (M_PKCS12_bag_type(bag)) {
	case NID_keyBag:
		if (options & INFO)
			BIO_printf(bio_err, "Key bag\n");
		if (options & NOKEYS)
			return 1;
		print_attribs(out, bag->attrib, "Bag Attributes");
		p8 = bag->value.keybag;
		if (!(pkey = EVP_PKCS82PKEY(p8)))
			return 0;
		print_attribs(out, p8->attributes, "Key Attributes");
		PEM_write_bio_PrivateKey(out, pkey, enc, NULL, 0, NULL, pempass);
		EVP_PKEY_free(pkey);
		break;

	case NID_pkcs8ShroudedKeyBag:
		if (options & INFO) {
			BIO_printf(bio_err, "Shrouded Keybag: ");
			alg_print(bio_err, bag->value.shkeybag->algor);
		}
		if (options & NOKEYS)
			return 1;
		print_attribs(out, bag->attrib, "Bag Attributes");
		if (!(p8 = PKCS12_decrypt_skey(bag, pass, passlen)))
			return 0;
		if (!(pkey = EVP_PKCS82PKEY(p8))) {
			PKCS8_PRIV_KEY_INFO_free(p8);
			return 0;
		}
		print_attribs(out, p8->attributes, "Key Attributes");
		PKCS8_PRIV_KEY_INFO_free(p8);
		PEM_write_bio_PrivateKey(out, pkey, enc, NULL, 0, NULL, pempass);
		EVP_PKEY_free(pkey);
		break;

	case NID_certBag:
		if (options & INFO)
			BIO_printf(bio_err, "Certificate bag\n");
		if (options & NOCERTS)
			return 1;
		if (PKCS12_get_attr(bag, NID_localKeyID)) {
			if (options & CACERTS)
				return 1;
		} else if (options & CLCERTS)
			return 1;
		print_attribs(out, bag->attrib, "Bag Attributes");
		if (M_PKCS12_cert_bag_type(bag) != NID_x509Certificate)
			return 1;
		if (!(x509 = PKCS12_certbag2x509(bag)))
			return 0;
		dump_cert_text(out, x509);
		PEM_write_bio_X509(out, x509);
		X509_free(x509);
		break;

	case NID_safeContentsBag:
		if (options & INFO)
			BIO_printf(bio_err, "Safe Contents bag\n");
		print_attribs(out, bag->attrib, "Bag Attributes");
		return dump_certs_pkeys_bags(out, bag->value.safes, pass,
		    passlen, options, pempass);

	default:
		BIO_printf(bio_err, "Warning unsupported bag type: ");
		i2a_ASN1_OBJECT(bio_err, bag->type);
		BIO_printf(bio_err, "\n");
		return 1;
		break;
	}
	return 1;
}

/* Given a single certificate return a verified chain or NULL if error */

/* Hope this is OK .... */

int 
get_cert_chain(X509 * cert, X509_STORE * store, STACK_OF(X509) ** chain)
{
	X509_STORE_CTX store_ctx;
	STACK_OF(X509) * chn;
	int i = 0;

	/*
	 * FIXME: Should really check the return status of
	 * X509_STORE_CTX_init for an error, but how that fits into the
	 * return value of this function is less obvious.
	 */
	X509_STORE_CTX_init(&store_ctx, store, cert, NULL);
	if (X509_verify_cert(&store_ctx) <= 0) {
		i = X509_STORE_CTX_get_error(&store_ctx);
		if (i == 0)
			/*
			 * avoid returning 0 if X509_verify_cert() did not
			 * set an appropriate error value in the context
			 */
			i = -1;
		chn = NULL;
		goto err;
	} else
		chn = X509_STORE_CTX_get1_chain(&store_ctx);
err:
	X509_STORE_CTX_cleanup(&store_ctx);
	*chain = chn;

	return i;
}

int 
alg_print(BIO * x, X509_ALGOR * alg)
{
	PBEPARAM *pbe;
	const unsigned char *p;
	p = alg->parameter->value.sequence->data;
	pbe = d2i_PBEPARAM(NULL, &p, alg->parameter->value.sequence->length);
	if (!pbe)
		return 1;
	BIO_printf(bio_err, "%s, Iteration %ld\n",
	    OBJ_nid2ln(OBJ_obj2nid(alg->algorithm)),
	    ASN1_INTEGER_get(pbe->iter));
	PBEPARAM_free(pbe);
	return 1;
}

/* Load all certificates from a given file */

int 
cert_load(BIO * in, STACK_OF(X509) * sk)
{
	int ret;
	X509 *cert;
	ret = 0;
	while ((cert = PEM_read_bio_X509(in, NULL, NULL, NULL))) {
		ret = 1;
		sk_X509_push(sk, cert);
	}
	if (ret)
		ERR_clear_error();
	return ret;
}

/* Generalised attribute print: handle PKCS#8 and bag attributes */

int 
print_attribs(BIO * out, STACK_OF(X509_ATTRIBUTE) * attrlst, const char *name)
{
	X509_ATTRIBUTE *attr;
	ASN1_TYPE *av;
	char *value;
	int i, attr_nid;
	if (!attrlst) {
		BIO_printf(out, "%s: \n", name);
		return 1;
	}
	if (!sk_X509_ATTRIBUTE_num(attrlst)) {
		BIO_printf(out, "%s: \n", name);
		return 1;
	}
	BIO_printf(out, "%s\n", name);
	for (i = 0; i < sk_X509_ATTRIBUTE_num(attrlst); i++) {
		attr = sk_X509_ATTRIBUTE_value(attrlst, i);
		attr_nid = OBJ_obj2nid(attr->object);
		BIO_printf(out, "    ");
		if (attr_nid == NID_undef) {
			i2a_ASN1_OBJECT(out, attr->object);
			BIO_printf(out, ": ");
		} else
			BIO_printf(out, "%s: ", OBJ_nid2ln(attr_nid));

		if (sk_ASN1_TYPE_num(attr->value.set)) {
			av = sk_ASN1_TYPE_value(attr->value.set, 0);
			switch (av->type) {
			case V_ASN1_BMPSTRING:
				value = OPENSSL_uni2asc(av->value.bmpstring->data,
				    av->value.bmpstring->length);
				BIO_printf(out, "%s\n", value);
				free(value);
				break;

			case V_ASN1_OCTET_STRING:
				hex_prin(out, av->value.octet_string->data,
				    av->value.octet_string->length);
				BIO_printf(out, "\n");
				break;

			case V_ASN1_BIT_STRING:
				hex_prin(out, av->value.bit_string->data,
				    av->value.bit_string->length);
				BIO_printf(out, "\n");
				break;

			default:
				BIO_printf(out, "\n", av->type);
				break;
			}
		} else
			BIO_printf(out, "\n");
	}
	return 1;
}

void 
hex_prin(BIO * out, unsigned char *buf, int len)
{
	int i;
	for (i = 0; i < len; i++)
		BIO_printf(out, "%02X ", buf[i]);
}

static int 
set_pbe(BIO * err, int *ppbe, const char *str)
{
	if (!str)
		return 0;
	if (!strcmp(str, "NONE")) {
		*ppbe = -1;
		return 1;
	}
	*ppbe = OBJ_txt2nid(str);
	if (*ppbe == NID_undef) {
		BIO_printf(bio_err, "Unknown PBE algorithm %s\n", str);
		return 0;
	}
	return 1;
}

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/apps/sess_id.c0000644000175000017500000001764512360020706017511 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#include 
#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 
#include 

static const char *sess_id_usage[] = {
	"usage: sess_id args\n",
	"\n",
	" -inform arg     - input format - default PEM (DER or PEM)\n",
	" -outform arg    - output format - default PEM\n",
	" -in arg         - input file - default stdin\n",
	" -out arg        - output file - default stdout\n",
	" -text           - print ssl session id details\n",
	" -cert           - output certificate \n",
	" -noout          - no output of encoded session info\n",
	" -context arg    - set the session ID context\n",
	NULL
};

static SSL_SESSION *load_sess_id(char *file, int format);

int sess_id_main(int, char **);

int 
sess_id_main(int argc, char **argv)
{
	SSL_SESSION *x = NULL;
	X509 *peer = NULL;
	int ret = 1, i, num, badops = 0;
	BIO *out = NULL;
	int informat, outformat;
	char *infile = NULL, *outfile = NULL, *context = NULL;
	int cert = 0, noout = 0, text = 0;
	const char **pp;

	informat = FORMAT_PEM;
	outformat = FORMAT_PEM;

	argc--;
	argv++;
	num = 0;
	while (argc >= 1) {
		if (strcmp(*argv, "-inform") == 0) {
			if (--argc < 1)
				goto bad;
			informat = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-outform") == 0) {
			if (--argc < 1)
				goto bad;
			outformat = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-in") == 0) {
			if (--argc < 1)
				goto bad;
			infile = *(++argv);
		} else if (strcmp(*argv, "-out") == 0) {
			if (--argc < 1)
				goto bad;
			outfile = *(++argv);
		} else if (strcmp(*argv, "-text") == 0)
			text = ++num;
		else if (strcmp(*argv, "-cert") == 0)
			cert = ++num;
		else if (strcmp(*argv, "-noout") == 0)
			noout = ++num;
		else if (strcmp(*argv, "-context") == 0) {
			if (--argc < 1)
				goto bad;
			context = *++argv;
		} else {
			BIO_printf(bio_err, "unknown option %s\n", *argv);
			badops = 1;
			break;
		}
		argc--;
		argv++;
	}

	if (badops) {
bad:
		for (pp = sess_id_usage; (*pp != NULL); pp++)
			BIO_printf(bio_err, "%s", *pp);
		goto end;
	}
	ERR_load_crypto_strings();
	x = load_sess_id(infile, informat);
	if (x == NULL) {
		goto end;
	}
	peer = SSL_SESSION_get0_peer(x);

	if (context) {
		size_t ctx_len = strlen(context);
		if (ctx_len > SSL_MAX_SID_CTX_LENGTH) {
			BIO_printf(bio_err, "Context too long\n");
			goto end;
		}
		SSL_SESSION_set1_id_context(x, (unsigned char *) context, ctx_len);
	}
#ifdef undef
	/* just testing for memory leaks :-) */
	{
		SSL_SESSION *s;
		char buf[1024 * 10], *p;
		int i;

		s = SSL_SESSION_new();

		p = &buf;
		i = i2d_SSL_SESSION(x, &p);
		p = &buf;
		d2i_SSL_SESSION(&s, &p, (long) i);
		p = &buf;
		d2i_SSL_SESSION(&s, &p, (long) i);
		p = &buf;
		d2i_SSL_SESSION(&s, &p, (long) i);
		SSL_SESSION_free(s);
	}
#endif

	if (!noout || text) {
		out = BIO_new(BIO_s_file());
		if (out == NULL) {
			ERR_print_errors(bio_err);
			goto end;
		}
		if (outfile == NULL) {
			BIO_set_fp(out, stdout, BIO_NOCLOSE);
		} else {
			if (BIO_write_filename(out, outfile) <= 0) {
				perror(outfile);
				goto end;
			}
		}
	}
	if (text) {
		SSL_SESSION_print(out, x);

		if (cert) {
			if (peer == NULL)
				BIO_puts(out, "No certificate present\n");
			else
				X509_print(out, peer);
		}
	}
	if (!noout && !cert) {
		if (outformat == FORMAT_ASN1)
			i = i2d_SSL_SESSION_bio(out, x);
		else if (outformat == FORMAT_PEM)
			i = PEM_write_bio_SSL_SESSION(out, x);
		else {
			BIO_printf(bio_err, "bad output format specified for outfile\n");
			goto end;
		}
		if (!i) {
			BIO_printf(bio_err, "unable to write SSL_SESSION\n");
			goto end;
		}
	} else if (!noout && (peer != NULL)) {	/* just print the certificate */
		if (outformat == FORMAT_ASN1)
			i = (int) i2d_X509_bio(out, peer);
		else if (outformat == FORMAT_PEM)
			i = PEM_write_bio_X509(out, peer);
		else {
			BIO_printf(bio_err, "bad output format specified for outfile\n");
			goto end;
		}
		if (!i) {
			BIO_printf(bio_err, "unable to write X509\n");
			goto end;
		}
	}
	ret = 0;
end:
	if (out != NULL)
		BIO_free_all(out);
	if (x != NULL)
		SSL_SESSION_free(x);
	
	return (ret);
}

static SSL_SESSION *
load_sess_id(char *infile, int format)
{
	SSL_SESSION *x = NULL;
	BIO *in = NULL;

	in = BIO_new(BIO_s_file());
	if (in == NULL) {
		ERR_print_errors(bio_err);
		goto end;
	}
	if (infile == NULL)
		BIO_set_fp(in, stdin, BIO_NOCLOSE);
	else {
		if (BIO_read_filename(in, infile) <= 0) {
			perror(infile);
			goto end;
		}
	}
	if (format == FORMAT_ASN1)
		x = d2i_SSL_SESSION_bio(in, NULL);
	else if (format == FORMAT_PEM)
		x = PEM_read_bio_SSL_SESSION(in, NULL, NULL, NULL);
	else {
		BIO_printf(bio_err, "bad input format specified for input crl\n");
		goto end;
	}
	if (x == NULL) {
		BIO_printf(bio_err, "unable to load SSL_SESSION\n");
		ERR_print_errors(bio_err);
		goto end;
	}
end:
	if (in != NULL)
		BIO_free(in);
	return (x);
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/ca.c0000644000175000017500000022115612360020706016435 0ustar  /* $OpenBSD: ca.c,v 1.60 2014/06/28 04:39:41 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

/* The PPKI stuff has been donated by Jeff Barber  */

#include 

#include 
#include 
#include 
#include 
#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define BASE_SECTION		"ca"

#define ENV_DEFAULT_CA		"default_ca"

#define STRING_MASK		"string_mask"
#define UTF8_IN			"utf8"

#define ENV_DIR			"dir"
#define ENV_CERTS		"certs"
#define ENV_CRL_DIR		"crl_dir"
#define ENV_CA_DB		"CA_DB"
#define ENV_NEW_CERTS_DIR	"new_certs_dir"
#define ENV_CERTIFICATE 	"certificate"
#define ENV_SERIAL		"serial"
#define ENV_CRLNUMBER		"crlnumber"
#define ENV_CRL			"crl"
#define ENV_PRIVATE_KEY		"private_key"
#define ENV_DEFAULT_DAYS 	"default_days"
#define ENV_DEFAULT_STARTDATE 	"default_startdate"
#define ENV_DEFAULT_ENDDATE 	"default_enddate"
#define ENV_DEFAULT_CRL_DAYS 	"default_crl_days"
#define ENV_DEFAULT_CRL_HOURS 	"default_crl_hours"
#define ENV_DEFAULT_MD		"default_md"
#define ENV_DEFAULT_EMAIL_DN	"email_in_dn"
#define ENV_PRESERVE		"preserve"
#define ENV_POLICY      	"policy"
#define ENV_EXTENSIONS      	"x509_extensions"
#define ENV_CRLEXT      	"crl_extensions"
#define ENV_MSIE_HACK		"msie_hack"
#define ENV_NAMEOPT		"name_opt"
#define ENV_CERTOPT		"cert_opt"
#define ENV_EXTCOPY		"copy_extensions"
#define ENV_UNIQUE_SUBJECT	"unique_subject"

#define ENV_DATABASE		"database"

/* Additional revocation information types */

#define REV_NONE		0	/* No addditional information */
#define REV_CRL_REASON		1	/* Value is CRL reason code */
#define REV_HOLD		2	/* Value is hold instruction */
#define REV_KEY_COMPROMISE	3	/* Value is cert key compromise time */
#define REV_CA_COMPROMISE	4	/* Value is CA key compromise time */

static const char *ca_usage[] = {
	"usage: ca args\n",
	"\n",
	" -verbose        - Talk alot while doing things\n",
	" -config file    - A config file\n",
	" -name arg       - The particular CA definition to use\n",
	" -gencrl         - Generate a new CRL\n",
	" -crldays days   - Days is when the next CRL is due\n",
	" -crlhours hours - Hours is when the next CRL is due\n",
	" -startdate YYMMDDHHMMSSZ  - certificate validity notBefore\n",
	" -enddate YYMMDDHHMMSSZ    - certificate validity notAfter (overrides -days)\n",
	" -days arg       - number of days to certify the certificate for\n",
	" -md arg         - md to use, one of md2, md5, sha or sha1\n",
	" -policy arg     - The CA 'policy' to support\n",
	" -keyfile arg    - private key file\n",
	" -keyform arg    - private key file format (PEM or ENGINE)\n",
	" -key arg        - key to decode the private key if it is encrypted\n",
	" -cert file      - The CA certificate\n",
	" -selfsign       - sign a certificate with the key associated with it\n",
	" -in file        - The input PEM encoded certificate request(s)\n",
	" -out file       - Where to put the output file(s)\n",
	" -outdir dir     - Where to put output certificates\n",
	" -infiles ....   - The last argument, requests to process\n",
	" -spkac file     - File contains DN and signed public key and challenge\n",
	" -ss_cert file   - File contains a self signed cert to sign\n",
	" -preserveDN     - Don't re-order the DN\n",
	" -noemailDN      - Don't add the EMAIL field into certificate' subject\n",
	" -batch          - Don't ask questions\n",
	" -msie_hack      - msie modifications to handle all those universal strings\n",
	" -revoke file    - Revoke a certificate (given in file)\n",
	" -subj arg       - Use arg instead of request's subject\n",
	" -utf8           - input characters are UTF8 (default ASCII)\n",
	" -multivalue-rdn - enable support for multivalued RDNs\n",
	" -extensions ..  - Extension section (override value in config file)\n",
	" -extfile file   - Configuration file with X509v3 extentions to add\n",
	" -crlexts ..     - CRL extension section (override value in config file)\n",
#ifndef OPENSSL_NO_ENGINE
	" -engine e       - use engine e, possibly a hardware device.\n",
#endif
	" -status serial  - Shows certificate status given the serial number\n",
	" -updatedb       - Updates db for expired certificates\n",
	NULL
};

static void lookup_fail(const char *name, const char *tag);
static int certify(X509 ** xret, char *infile, EVP_PKEY * pkey, X509 * x509,
    const EVP_MD * dgst, STACK_OF(OPENSSL_STRING) * sigopts,
    STACK_OF(CONF_VALUE) * policy, CA_DB * db, BIGNUM * serial, char *subj,
    unsigned long chtype, int multirdn, int email_dn, char *startdate,
    char *enddate, long days, int batch, char *ext_sect, CONF * conf,
    int verbose, unsigned long certopt, unsigned long nameopt,
    int default_op, int ext_copy, int selfsign);
static int certify_cert(X509 ** xret, char *infile, EVP_PKEY * pkey,
    X509 * x509, const EVP_MD * dgst, STACK_OF(OPENSSL_STRING) * sigopts,
    STACK_OF(CONF_VALUE) * policy, CA_DB * db, BIGNUM * serial, char *subj,
    unsigned long chtype, int multirdn, int email_dn, char *startdate,
    char *enddate, long days, int batch, char *ext_sect, CONF * conf,
    int verbose, unsigned long certopt, unsigned long nameopt, int default_op,
    int ext_copy, ENGINE * e);
static int certify_spkac(X509 ** xret, char *infile, EVP_PKEY * pkey,
    X509 * x509, const EVP_MD * dgst, STACK_OF(OPENSSL_STRING) * sigopts,
    STACK_OF(CONF_VALUE) * policy, CA_DB * db, BIGNUM * serial, char *subj,
    unsigned long chtype, int multirdn, int email_dn, char *startdate,
    char *enddate, long days, char *ext_sect, CONF * conf, int verbose,
    unsigned long certopt, unsigned long nameopt, int default_op, int ext_copy);
static void write_new_certificate(BIO * bp, X509 * x, int output_der,
    int notext);
static int do_body(X509 ** xret, EVP_PKEY * pkey, X509 * x509,
    const EVP_MD * dgst, STACK_OF(OPENSSL_STRING) * sigopts,
    STACK_OF(CONF_VALUE) * policy, CA_DB * db, BIGNUM * serial, char *subj,
    unsigned long chtype, int multirdn, int email_dn, char *startdate,
    char *enddate, long days, int batch, int verbose, X509_REQ * req,
    char *ext_sect, CONF * conf, unsigned long certopt, unsigned long nameopt,
    int default_op, int ext_copy, int selfsign);
static int do_revoke(X509 * x509, CA_DB * db, int ext, char *extval);
static int get_certificate_status(const char *ser_status, CA_DB * db);
static int do_updatedb(CA_DB * db);
static int check_time_format(const char *str);
static char * bin2hex(unsigned char *, size_t);
char *make_revocation_str(int rev_type, char *rev_arg);
int make_revoked(X509_REVOKED * rev, const char *str);
int old_entry_print(BIO * bp, ASN1_OBJECT * obj, ASN1_STRING * str);
static CONF *conf = NULL;
static CONF *extconf = NULL;
static char *section = NULL;

static int preserve = 0;
static int msie_hack = 0;


int ca_main(int, char **);

int
ca_main(int argc, char **argv)
{
	ENGINE *e = NULL;
	char *key = NULL, *passargin = NULL;
	int create_ser = 0;
	int free_key = 0;
	int total = 0;
	int total_done = 0;
	int badops = 0;
	int ret = 1;
	int email_dn = 1;
	int req = 0;
	int verbose = 0;
	int gencrl = 0;
	int dorevoke = 0;
	int doupdatedb = 0;
	long crldays = 0;
	long crlhours = 0;
	long crlsec = 0;
	long errorline = -1;
	char *configfile = NULL;
	char *md = NULL;
	char *policy = NULL;
	char *keyfile = NULL;
	char *certfile = NULL;
	int keyform = FORMAT_PEM;
	char *infile = NULL;
	char *spkac_file = NULL;
	char *ss_cert_file = NULL;
	char *ser_status = NULL;
	EVP_PKEY *pkey = NULL;
	int output_der = 0;
	char *outfile = NULL;
	char *outdir = NULL;
	char *serialfile = NULL;
	char *crlnumberfile = NULL;
	char *extensions = NULL;
	char *extfile = NULL;
	char *subj = NULL;
	unsigned long chtype = MBSTRING_ASC;
	int multirdn = 0;
	char *tmp_email_dn = NULL;
	char *crl_ext = NULL;
	int rev_type = REV_NONE;
	char *rev_arg = NULL;
	BIGNUM *serial = NULL;
	BIGNUM *crlnumber = NULL;
	char *startdate = NULL;
	char *enddate = NULL;
	long days = 0;
	int batch = 0;
	int notext = 0;
	unsigned long nameopt = 0, certopt = 0;
	int default_op = 1;
	int ext_copy = EXT_COPY_NONE;
	int selfsign = 0;
	X509 *x509 = NULL, *x509p = NULL;
	X509 *x = NULL;
	BIO *in = NULL, *out = NULL, *Sout = NULL, *Cout = NULL;
	char *dbfile = NULL;
	CA_DB *db = NULL;
	X509_CRL *crl = NULL;
	X509_REVOKED *r = NULL;
	ASN1_TIME *tmptm;
	ASN1_INTEGER *tmpser;
	char *f;
	const char *p;
	char *const * pp;
	int i, j;
	const EVP_MD *dgst = NULL;
	STACK_OF(CONF_VALUE) * attribs = NULL;
	STACK_OF(X509) * cert_sk = NULL;
	STACK_OF(OPENSSL_STRING) * sigopts = NULL;
#define BSIZE 256
	char buf[3][BSIZE];
#ifndef OPENSSL_NO_ENGINE
	char *engine = NULL;
#endif
	char *tofree = NULL;
	const char *errstr = NULL;
	DB_ATTR db_attr;

	conf = NULL;
	key = NULL;
	section = NULL;

	preserve = 0;
	msie_hack = 0;

	argc--;
	argv++;
	while (argc >= 1) {
		if (strcmp(*argv, "-verbose") == 0)
			verbose = 1;
		else if (strcmp(*argv, "-config") == 0) {
			if (--argc < 1)
				goto bad;
			configfile = *(++argv);
		} else if (strcmp(*argv, "-name") == 0) {
			if (--argc < 1)
				goto bad;
			section = *(++argv);
		} else if (strcmp(*argv, "-subj") == 0) {
			if (--argc < 1)
				goto bad;
			subj = *(++argv);
			/* preserve=1; */
		} else if (strcmp(*argv, "-utf8") == 0)
			chtype = MBSTRING_UTF8;
		else if (strcmp(*argv, "-create_serial") == 0)
			create_ser = 1;
		else if (strcmp(*argv, "-multivalue-rdn") == 0)
			multirdn = 1;
		else if (strcmp(*argv, "-startdate") == 0) {
			if (--argc < 1)
				goto bad;
			startdate = *(++argv);
		} else if (strcmp(*argv, "-enddate") == 0) {
			if (--argc < 1)
				goto bad;
			enddate = *(++argv);
		} else if (strcmp(*argv, "-days") == 0) {
			if (--argc < 1)
				goto bad;
			days = strtonum(*(++argv), 0, LONG_MAX, &errstr);
			if (errstr)
				goto bad;
		} else if (strcmp(*argv, "-md") == 0) {
			if (--argc < 1)
				goto bad;
			md = *(++argv);
		} else if (strcmp(*argv, "-policy") == 0) {
			if (--argc < 1)
				goto bad;
			policy = *(++argv);
		} else if (strcmp(*argv, "-keyfile") == 0) {
			if (--argc < 1)
				goto bad;
			keyfile = *(++argv);
		} else if (strcmp(*argv, "-keyform") == 0) {
			if (--argc < 1)
				goto bad;
			keyform = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-passin") == 0) {
			if (--argc < 1)
				goto bad;
			passargin = *(++argv);
		} else if (strcmp(*argv, "-key") == 0) {
			if (--argc < 1)
				goto bad;
			key = *(++argv);
		} else if (strcmp(*argv, "-cert") == 0) {
			if (--argc < 1)
				goto bad;
			certfile = *(++argv);
		} else if (strcmp(*argv, "-selfsign") == 0)
			selfsign = 1;
		else if (strcmp(*argv, "-in") == 0) {
			if (--argc < 1)
				goto bad;
			infile = *(++argv);
			req = 1;
		} else if (strcmp(*argv, "-out") == 0) {
			if (--argc < 1)
				goto bad;
			outfile = *(++argv);
		} else if (strcmp(*argv, "-outdir") == 0) {
			if (--argc < 1)
				goto bad;
			outdir = *(++argv);
		} else if (strcmp(*argv, "-sigopt") == 0) {
			if (--argc < 1)
				goto bad;
			if (!sigopts)
				sigopts = sk_OPENSSL_STRING_new_null();
			if (!sigopts ||
			    !sk_OPENSSL_STRING_push(sigopts, *(++argv)))
				goto bad;
		} else if (strcmp(*argv, "-notext") == 0)
			notext = 1;
		else if (strcmp(*argv, "-batch") == 0)
			batch = 1;
		else if (strcmp(*argv, "-preserveDN") == 0)
			preserve = 1;
		else if (strcmp(*argv, "-noemailDN") == 0)
			email_dn = 0;
		else if (strcmp(*argv, "-gencrl") == 0)
			gencrl = 1;
		else if (strcmp(*argv, "-msie_hack") == 0)
			msie_hack = 1;
		else if (strcmp(*argv, "-crldays") == 0) {
			if (--argc < 1)
				goto bad;
			crldays = strtonum(*(++argv), 0, LONG_MAX, &errstr);
			if (errstr)
				goto bad;
		} else if (strcmp(*argv, "-crlhours") == 0) {
			if (--argc < 1)
				goto bad;
			crlhours = strtonum(*(++argv), 0, LONG_MAX, &errstr);
			if (errstr)
				goto bad;
		} else if (strcmp(*argv, "-crlsec") == 0) {
			if (--argc < 1)
				goto bad;
			crlsec = strtonum(*(++argv), 0, LONG_MAX, &errstr);
			if (errstr)
				goto bad;
		} else if (strcmp(*argv, "-infiles") == 0) {
			argc--;
			argv++;
			req = 1;
			break;
		} else if (strcmp(*argv, "-ss_cert") == 0) {
			if (--argc < 1)
				goto bad;
			ss_cert_file = *(++argv);
			req = 1;
		} else if (strcmp(*argv, "-spkac") == 0) {
			if (--argc < 1)
				goto bad;
			spkac_file = *(++argv);
			req = 1;
		} else if (strcmp(*argv, "-revoke") == 0) {
			if (--argc < 1)
				goto bad;
			infile = *(++argv);
			dorevoke = 1;
		} else if (strcmp(*argv, "-extensions") == 0) {
			if (--argc < 1)
				goto bad;
			extensions = *(++argv);
		} else if (strcmp(*argv, "-extfile") == 0) {
			if (--argc < 1)
				goto bad;
			extfile = *(++argv);
		} else if (strcmp(*argv, "-status") == 0) {
			if (--argc < 1)
				goto bad;
			ser_status = *(++argv);
		} else if (strcmp(*argv, "-updatedb") == 0) {
			doupdatedb = 1;
		} else if (strcmp(*argv, "-crlexts") == 0) {
			if (--argc < 1)
				goto bad;
			crl_ext = *(++argv);
		} else if (strcmp(*argv, "-crl_reason") == 0) {
			if (--argc < 1)
				goto bad;
			rev_arg = *(++argv);
			rev_type = REV_CRL_REASON;
		} else if (strcmp(*argv, "-crl_hold") == 0) {
			if (--argc < 1)
				goto bad;
			rev_arg = *(++argv);
			rev_type = REV_HOLD;
		} else if (strcmp(*argv, "-crl_compromise") == 0) {
			if (--argc < 1)
				goto bad;
			rev_arg = *(++argv);
			rev_type = REV_KEY_COMPROMISE;
		} else if (strcmp(*argv, "-crl_CA_compromise") == 0) {
			if (--argc < 1)
				goto bad;
			rev_arg = *(++argv);
			rev_type = REV_CA_COMPROMISE;
		}
#ifndef OPENSSL_NO_ENGINE
		else if (strcmp(*argv, "-engine") == 0) {
			if (--argc < 1)
				goto bad;
			engine = *(++argv);
		}
#endif
		else {
bad:
			if (errstr)
				BIO_printf(bio_err, "invalid argument %s: %s\n",
				    *argv, errstr);
			else
				BIO_printf(bio_err, "unknown option %s\n", *argv);
			badops = 1;
			break;
		}
		argc--;
		argv++;
	}

	if (badops) {
		const char **pp2;

		for (pp2 = ca_usage; (*pp2 != NULL); pp2++)
			BIO_printf(bio_err, "%s", *pp2);
		goto err;
	}
	ERR_load_crypto_strings();

	/*****************************************************************/
	tofree = NULL;
	if (configfile == NULL)
		configfile = getenv("OPENSSL_CONF");
	if (configfile == NULL)
		configfile = getenv("SSLEAY_CONF");
	if (configfile == NULL) {
		if ((tofree = make_config_name()) == NULL) {
			BIO_printf(bio_err, "error making config file name\n");
			goto err;
		}
		configfile = tofree;
	}
	BIO_printf(bio_err, "Using configuration from %s\n", configfile);
	conf = NCONF_new(NULL);
	if (NCONF_load(conf, configfile, &errorline) <= 0) {
		if (errorline <= 0)
			BIO_printf(bio_err,
			    "error loading the config file '%s'\n",
			    configfile);
		else
			BIO_printf(bio_err,
			    "error on line %ld of config file '%s'\n",
			    errorline, configfile);
		goto err;
	}
	free(tofree);
	tofree = NULL;

	if (!load_config(bio_err, conf))
		goto err;

#ifndef OPENSSL_NO_ENGINE
	e = setup_engine(bio_err, engine, 0);
#endif

	/* Lets get the config section we are using */
	if (section == NULL) {
		section = NCONF_get_string(conf, BASE_SECTION, ENV_DEFAULT_CA);
		if (section == NULL) {
			lookup_fail(BASE_SECTION, ENV_DEFAULT_CA);
			goto err;
		}
	}
	if (conf != NULL) {
		p = NCONF_get_string(conf, NULL, "oid_file");
		if (p == NULL)
			ERR_clear_error();
		if (p != NULL) {
			BIO *oid_bio;

			oid_bio = BIO_new_file(p, "r");
			if (oid_bio == NULL) {
				/*
				BIO_printf(bio_err,
				    "problems opening %s for extra oid's\n", p);
				ERR_print_errors(bio_err);
				*/
				ERR_clear_error();
			} else {
				OBJ_create_objects(oid_bio);
				BIO_free(oid_bio);
			}
		}
		if (!add_oid_section(bio_err, conf)) {
			ERR_print_errors(bio_err);
			goto err;
		}
	}
	f = NCONF_get_string(conf, section, STRING_MASK);
	if (!f)
		ERR_clear_error();

	if (f && !ASN1_STRING_set_default_mask_asc(f)) {
		BIO_printf(bio_err,
		    "Invalid global string mask setting %s\n", f);
		goto err;
	}
	if (chtype != MBSTRING_UTF8) {
		f = NCONF_get_string(conf, section, UTF8_IN);
		if (!f)
			ERR_clear_error();
		else if (!strcmp(f, "yes"))
			chtype = MBSTRING_UTF8;
	}
	db_attr.unique_subject = 1;
	p = NCONF_get_string(conf, section, ENV_UNIQUE_SUBJECT);
	if (p) {
		db_attr.unique_subject = parse_yesno(p, 1);
	} else
		ERR_clear_error();

	in = BIO_new(BIO_s_file());
	out = BIO_new(BIO_s_file());
	Sout = BIO_new(BIO_s_file());
	Cout = BIO_new(BIO_s_file());
	if ((in == NULL) || (out == NULL) || (Sout == NULL) || (Cout == NULL)) {
		ERR_print_errors(bio_err);
		goto err;
	}
	/*****************************************************************/
	/* report status of cert with serial number given on command line */
	if (ser_status) {
		if ((dbfile = NCONF_get_string(conf, section,
		    ENV_DATABASE)) == NULL) {
			lookup_fail(section, ENV_DATABASE);
			goto err;
		}
		db = load_index(dbfile, &db_attr);
		if (db == NULL)
			goto err;

		if (!index_index(db))
			goto err;

		if (get_certificate_status(ser_status, db) != 1)
			BIO_printf(bio_err, "Error verifying serial %s!\n",
			    ser_status);
		goto err;
	}
	/*****************************************************************/
	/* we definitely need a private key, so let's get it */

	if ((keyfile == NULL) && ((keyfile = NCONF_get_string(conf,
	    section, ENV_PRIVATE_KEY)) == NULL)) {
		lookup_fail(section, ENV_PRIVATE_KEY);
		goto err;
	}
	if (!key) {
		free_key = 1;
		if (!app_passwd(bio_err, passargin, NULL, &key, NULL)) {
			BIO_printf(bio_err, "Error getting password\n");
			goto err;
		}
	}
	pkey = load_key(bio_err, keyfile, keyform, 0, key, e, "CA private key");
	if (key)
		OPENSSL_cleanse(key, strlen(key));
	if (pkey == NULL) {
		/* load_key() has already printed an appropriate message */
		goto err;
	}
	/*****************************************************************/
	/* we need a certificate */
	if (!selfsign || spkac_file || ss_cert_file || gencrl) {
		if ((certfile == NULL) &&
		    ((certfile = NCONF_get_string(conf,
		    section, ENV_CERTIFICATE)) == NULL)) {
			lookup_fail(section, ENV_CERTIFICATE);
			goto err;
		}
		x509 = load_cert(bio_err, certfile, FORMAT_PEM, NULL, e,
		    "CA certificate");
		if (x509 == NULL)
			goto err;

		if (!X509_check_private_key(x509, pkey)) {
			BIO_printf(bio_err,
			    "CA certificate and CA private key do not match\n");
			goto err;
		}
	}
	if (!selfsign)
		x509p = x509;

	f = NCONF_get_string(conf, BASE_SECTION, ENV_PRESERVE);
	if (f == NULL)
		ERR_clear_error();
	if ((f != NULL) && ((*f == 'y') || (*f == 'Y')))
		preserve = 1;
	f = NCONF_get_string(conf, BASE_SECTION, ENV_MSIE_HACK);
	if (f == NULL)
		ERR_clear_error();
	if ((f != NULL) && ((*f == 'y') || (*f == 'Y')))
		msie_hack = 1;

	f = NCONF_get_string(conf, section, ENV_NAMEOPT);

	if (f) {
		if (!set_name_ex(&nameopt, f)) {
			BIO_printf(bio_err,
			    "Invalid name options: \"%s\"\n", f);
			goto err;
		}
		default_op = 0;
	} else
		ERR_clear_error();

	f = NCONF_get_string(conf, section, ENV_CERTOPT);

	if (f) {
		if (!set_cert_ex(&certopt, f)) {
			BIO_printf(bio_err,
			    "Invalid certificate options: \"%s\"\n", f);
			goto err;
		}
		default_op = 0;
	} else
		ERR_clear_error();

	f = NCONF_get_string(conf, section, ENV_EXTCOPY);

	if (f) {
		if (!set_ext_copy(&ext_copy, f)) {
			BIO_printf(bio_err,
			    "Invalid extension copy option: \"%s\"\n", f);
			goto err;
		}
	} else
		ERR_clear_error();

	/*****************************************************************/
	/* lookup where to write new certificates */
	if ((outdir == NULL) && (req)) {

		if ((outdir = NCONF_get_string(conf, section,
		    ENV_NEW_CERTS_DIR)) == NULL) {
			BIO_printf(bio_err, "there needs to be defined a directory for new certificate to be placed in\n");
			goto err;
		}
		/*
		 * outdir is a directory spec, but access() for VMS demands a
		 * filename.  In any case, stat(), below, will catch the
		 * problem if outdir is not a directory spec, and the fopen()
		 * or open() will catch an error if there is no write access.
		 *
		 * Presumably, this problem could also be solved by using the
		 * DEC C routines to convert the directory syntax to Unixly,
		 * and give that to access().  However, time's too short to
		 * do that just now.
		 */
		if (access(outdir, R_OK | W_OK | X_OK) != 0) {
			BIO_printf(bio_err,
			    "I am unable to access the %s directory\n", outdir);
			perror(outdir);
			goto err;
		}
		if (app_isdir(outdir) <= 0) {
			BIO_printf(bio_err,
			    "%s need to be a directory\n", outdir);
			perror(outdir);
			goto err;
		}
	}
	/*****************************************************************/
	/* we need to load the database file */
	if ((dbfile = NCONF_get_string(conf, section, ENV_DATABASE)) == NULL) {
		lookup_fail(section, ENV_DATABASE);
		goto err;
	}
	db = load_index(dbfile, &db_attr);
	if (db == NULL)
		goto err;

	/* Lets check some fields */
	for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) {
		pp = sk_OPENSSL_PSTRING_value(db->db->data, i);
		if ((pp[DB_type][0] != DB_TYPE_REV) &&
		    (pp[DB_rev_date][0] != '\0')) {
			BIO_printf(bio_err, "entry %d: not revoked yet, but has a revocation date\n", i + 1);
			goto err;
		}
		if ((pp[DB_type][0] == DB_TYPE_REV) &&
		    !make_revoked(NULL, pp[DB_rev_date])) {
			BIO_printf(bio_err, " in entry %d\n", i + 1);
			goto err;
		}
		if (!check_time_format((char *) pp[DB_exp_date])) {
			BIO_printf(bio_err, "entry %d: invalid expiry date\n",
			    i + 1);
			goto err;
		}
		p = pp[DB_serial];
		j = strlen(p);
		if (*p == '-') {
			p++;
			j--;
		}
		if ((j & 1) || (j < 2)) {
			BIO_printf(bio_err,
			    "entry %d: bad serial number length (%d)\n",
			    i + 1, j);
			goto err;
		}
		while (*p) {
			if (!(((*p >= '0') && (*p <= '9')) ||
			    ((*p >= 'A') && (*p <= 'F')) ||
			    ((*p >= 'a') && (*p <= 'f')))) {
				BIO_printf(bio_err, "entry %d: bad serial number characters, char pos %ld, char is '%c'\n", i + 1, (long) (p - pp[DB_serial]), *p);
				goto err;
			}
			p++;
		}
	}
	if (verbose) {
		BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT);	/* cannot fail */
		TXT_DB_write(out, db->db);
		BIO_printf(bio_err, "%d entries loaded from the database\n",
		    sk_OPENSSL_PSTRING_num(db->db->data));
		BIO_printf(bio_err, "generating index\n");
	}
	if (!index_index(db))
		goto err;

	/*****************************************************************/
	/* Update the db file for expired certificates */
	if (doupdatedb) {
		if (verbose)
			BIO_printf(bio_err, "Updating %s ...\n", dbfile);

		i = do_updatedb(db);
		if (i == -1) {
			BIO_printf(bio_err, "Malloc failure\n");
			goto err;
		} else if (i == 0) {
			if (verbose)
				BIO_printf(bio_err,
				    "No entries found to mark expired\n");
		} else {
			if (!save_index(dbfile, "new", db))
				goto err;

			if (!rotate_index(dbfile, "new", "old"))
				goto err;

			if (verbose)
				BIO_printf(bio_err,
				    "Done. %d entries marked as expired\n", i);
		}
	}
	/*****************************************************************/
	/* Read extentions config file                                   */
	if (extfile) {
		extconf = NCONF_new(NULL);
		if (NCONF_load(extconf, extfile, &errorline) <= 0) {
			if (errorline <= 0)
				BIO_printf(bio_err,
				    "ERROR: loading the config file '%s'\n",
				    extfile);
			else
				BIO_printf(bio_err,
				    "ERROR: on line %ld of config file '%s'\n",
				    errorline, extfile);
			ret = 1;
			goto err;
		}
		if (verbose)
			BIO_printf(bio_err,
			    "Successfully loaded extensions file %s\n",
			    extfile);

		/* We can have sections in the ext file */
		if (!extensions && !(extensions = NCONF_get_string(extconf,
		    "default", "extensions")))
			extensions = "default";
	}
	/*****************************************************************/
	if (req || gencrl) {
		if (outfile != NULL) {
			if (BIO_write_filename(Sout, outfile) <= 0) {
				perror(outfile);
				goto err;
			}
		} else {
			BIO_set_fp(Sout, stdout, BIO_NOCLOSE | BIO_FP_TEXT);
		}
	}
	if ((md == NULL) && ((md = NCONF_get_string(conf, section,
	    ENV_DEFAULT_MD)) == NULL)) {
		lookup_fail(section, ENV_DEFAULT_MD);
		goto err;
	}
	if (!strcmp(md, "default")) {
		int def_nid;
		if (EVP_PKEY_get_default_digest_nid(pkey, &def_nid) <= 0) {
			BIO_puts(bio_err, "no default digest\n");
			goto err;
		}
		md = (char *) OBJ_nid2sn(def_nid);
	}
	if ((dgst = EVP_get_digestbyname(md)) == NULL) {
		BIO_printf(bio_err,
		    "%s is an unsupported message digest type\n", md);
		goto err;
	}
	if (req) {
		if ((email_dn == 1) && ((tmp_email_dn = NCONF_get_string(conf,
		    section, ENV_DEFAULT_EMAIL_DN)) != NULL)) {
			if (strcmp(tmp_email_dn, "no") == 0)
				email_dn = 0;
		}
		if (verbose)
			BIO_printf(bio_err, "message digest is %s\n",
			    OBJ_nid2ln(dgst->type));
		if ((policy == NULL) && ((policy = NCONF_get_string(conf,
		    section, ENV_POLICY)) == NULL)) {
			lookup_fail(section, ENV_POLICY);
			goto err;
		}
		if (verbose)
			BIO_printf(bio_err, "policy is %s\n", policy);

		if ((serialfile = NCONF_get_string(conf, section,
		    ENV_SERIAL)) == NULL) {
			lookup_fail(section, ENV_SERIAL);
			goto err;
		}
		if (!extconf) {
			/*
			 * no '-extfile' option, so we look for extensions in
			 * the main configuration file
			 */
			if (!extensions) {
				extensions = NCONF_get_string(conf, section,
				    ENV_EXTENSIONS);
				if (!extensions)
					ERR_clear_error();
			}
			if (extensions) {
				/* Check syntax of file */
				X509V3_CTX ctx;
				X509V3_set_ctx_test(&ctx);
				X509V3_set_nconf(&ctx, conf);
				if (!X509V3_EXT_add_nconf(conf, &ctx,
				    extensions, NULL)) {
					BIO_printf(bio_err,
					    "Error Loading extension section %s\n",
					    extensions);
					ret = 1;
					goto err;
				}
			}
		}
		if (startdate == NULL) {
			startdate = NCONF_get_string(conf, section,
			    ENV_DEFAULT_STARTDATE);
			if (startdate == NULL)
				ERR_clear_error();
		}
		if (startdate && !ASN1_TIME_set_string(NULL, startdate)) {
			BIO_printf(bio_err, "start date is invalid, it should be YYMMDDHHMMSSZ or YYYYMMDDHHMMSSZ\n");
			goto err;
		}
		if (startdate == NULL)
			startdate = "today";

		if (enddate == NULL) {
			enddate = NCONF_get_string(conf, section,
			    ENV_DEFAULT_ENDDATE);
			if (enddate == NULL)
				ERR_clear_error();
		}
		if (enddate && !ASN1_TIME_set_string(NULL, enddate)) {
			BIO_printf(bio_err, "end date is invalid, it should be YYMMDDHHMMSSZ or YYYYMMDDHHMMSSZ\n");
			goto err;
		}
		if (days == 0) {
			if (!NCONF_get_number(conf, section,
			    ENV_DEFAULT_DAYS, &days))
				days = 0;
		}
		if (!enddate && (days == 0)) {
			BIO_printf(bio_err,
			    "cannot lookup how many days to certify for\n");
			goto err;
		}
		if ((serial = load_serial(serialfile, create_ser, NULL)) ==
		    NULL) {
			BIO_printf(bio_err,
			    "error while loading serial number\n");
			goto err;
		}
		if (verbose) {
			if (BN_is_zero(serial))
				BIO_printf(bio_err,
				    "next serial number is 00\n");
			else {
				if ((f = BN_bn2hex(serial)) == NULL)
					goto err;
				BIO_printf(bio_err,
				    "next serial number is %s\n", f);
				free(f);
			}
		}
		if ((attribs = NCONF_get_section(conf, policy)) == NULL) {
			BIO_printf(bio_err,
			    "unable to find 'section' for %s\n", policy);
			goto err;
		}
		if ((cert_sk = sk_X509_new_null()) == NULL) {
			BIO_printf(bio_err, "Memory allocation failure\n");
			goto err;
		}
		if (spkac_file != NULL) {
			total++;
			j = certify_spkac(&x, spkac_file, pkey, x509, dgst,
			    sigopts, attribs, db, serial, subj, chtype,
			    multirdn, email_dn, startdate, enddate, days,
			    extensions, conf, verbose, certopt, nameopt,
			    default_op, ext_copy);
			if (j < 0)
				goto err;
			if (j > 0) {
				total_done++;
				BIO_printf(bio_err, "\n");
				if (!BN_add_word(serial, 1))
					goto err;
				if (!sk_X509_push(cert_sk, x)) {
					BIO_printf(bio_err,
					    "Memory allocation failure\n");
					goto err;
				}
				if (outfile) {
					output_der = 1;
					batch = 1;
				}
			}
		}
		if (ss_cert_file != NULL) {
			total++;
			j = certify_cert(&x, ss_cert_file, pkey, x509, dgst,
			    sigopts, attribs, db, serial, subj, chtype,
			    multirdn, email_dn, startdate, enddate, days, batch,
			    extensions, conf, verbose, certopt, nameopt,
			    default_op, ext_copy, e);
			if (j < 0)
				goto err;
			if (j > 0) {
				total_done++;
				BIO_printf(bio_err, "\n");
				if (!BN_add_word(serial, 1))
					goto err;
				if (!sk_X509_push(cert_sk, x)) {
					BIO_printf(bio_err,
					    "Memory allocation failure\n");
					goto err;
				}
			}
		}
		if (infile != NULL) {
			total++;
			j = certify(&x, infile, pkey, x509p, dgst, sigopts,
			    attribs, db, serial, subj, chtype, multirdn,
			    email_dn, startdate, enddate, days, batch,
			    extensions, conf, verbose, certopt, nameopt,
			    default_op, ext_copy, selfsign);
			if (j < 0)
				goto err;
			if (j > 0) {
				total_done++;
				BIO_printf(bio_err, "\n");
				if (!BN_add_word(serial, 1))
					goto err;
				if (!sk_X509_push(cert_sk, x)) {
					BIO_printf(bio_err,
					    "Memory allocation failure\n");
					goto err;
				}
			}
		}
		for (i = 0; i < argc; i++) {
			total++;
			j = certify(&x, argv[i], pkey, x509p, dgst, sigopts,
			    attribs, db, serial, subj, chtype, multirdn,
			    email_dn, startdate, enddate, days, batch,
			    extensions, conf, verbose, certopt, nameopt,
			    default_op, ext_copy, selfsign);
			if (j < 0)
				goto err;
			if (j > 0) {
				total_done++;
				BIO_printf(bio_err, "\n");
				if (!BN_add_word(serial, 1))
					goto err;
				if (!sk_X509_push(cert_sk, x)) {
					BIO_printf(bio_err,
					    "Memory allocation failure\n");
					goto err;
				}
			}
		}
		/*
		 * we have a stack of newly certified certificates and a data
		 * base and serial number that need updating
		 */

		if (sk_X509_num(cert_sk) > 0) {
			if (!batch) {
				BIO_printf(bio_err, "\n%d out of %d certificate requests certified, commit? [y/n]", total_done, total);
				(void) BIO_flush(bio_err);
				buf[0][0] = '\0';
				if (!fgets(buf[0], 10, stdin)) {
					BIO_printf(bio_err, "CERTIFICATION CANCELED: I/O error\n");
					ret = 0;
					goto err;
				}
				if ((buf[0][0] != 'y') && (buf[0][0] != 'Y')) {
					BIO_printf(bio_err, "CERTIFICATION CANCELED\n");
					ret = 0;
					goto err;
				}
			}
			BIO_printf(bio_err, "Write out database with %d new entries\n", sk_X509_num(cert_sk));

			if (!save_serial(serialfile, "new", serial, NULL))
				goto err;

			if (!save_index(dbfile, "new", db))
				goto err;
		}
		if (verbose)
			BIO_printf(bio_err, "writing new certificates\n");
		for (i = 0; i < sk_X509_num(cert_sk); i++) {
			int k;
			char *serial;
			unsigned char *data;

			x = sk_X509_value(cert_sk, i);

			j = x->cert_info->serialNumber->length;
			data = (unsigned char *)x->cert_info->serialNumber->data;
			if (j > 0)
				serial = bin2hex(data, j);
			else
				serial = strdup("00");
			if (serial) {
				k = snprintf(buf[2], sizeof(buf[2]),
				    "%s/%s.pem", outdir, serial);
				free(serial);
				if (k == -1 || k >= sizeof(buf[2])) {
					BIO_printf(bio_err,
					    "certificate file name too long\n");
					goto err;
				}
			} else {
				BIO_printf(bio_err,
				    "memory allocation failed\n");
				goto err;
			}
			if (verbose)
				BIO_printf(bio_err, "writing %s\n", buf[2]);

			if (BIO_write_filename(Cout, buf[2]) <= 0) {
				perror(buf[2]);
				goto err;
			}
			write_new_certificate(Cout, x, 0, notext);
			write_new_certificate(Sout, x, output_der, notext);
		}

		if (sk_X509_num(cert_sk)) {
			/* Rename the database and the serial file */
			if (!rotate_serial(serialfile, "new", "old"))
				goto err;

			if (!rotate_index(dbfile, "new", "old"))
				goto err;

			BIO_printf(bio_err, "Data Base Updated\n");
		}
	}
	/*****************************************************************/
	if (gencrl) {
		int crl_v2 = 0;
		if (!crl_ext) {
			crl_ext = NCONF_get_string(conf, section, ENV_CRLEXT);
			if (!crl_ext)
				ERR_clear_error();
		}
		if (crl_ext) {
			/* Check syntax of file */
			X509V3_CTX ctx;
			X509V3_set_ctx_test(&ctx);
			X509V3_set_nconf(&ctx, conf);
			if (!X509V3_EXT_add_nconf(conf, &ctx, crl_ext, NULL)) {
				BIO_printf(bio_err,
				    "Error Loading CRL extension section %s\n",
				    crl_ext);
				ret = 1;
				goto err;
			}
		}
		if ((crlnumberfile = NCONF_get_string(conf, section,
		    ENV_CRLNUMBER)) != NULL)
			if ((crlnumber = load_serial(crlnumberfile, 0,
			    NULL)) == NULL) {
				BIO_printf(bio_err,
				    "error while loading CRL number\n");
				goto err;
			}
		if (!crldays && !crlhours && !crlsec) {
			if (!NCONF_get_number(conf, section,
			    ENV_DEFAULT_CRL_DAYS, &crldays))
				crldays = 0;
			if (!NCONF_get_number(conf, section,
			    ENV_DEFAULT_CRL_HOURS, &crlhours))
				crlhours = 0;
			ERR_clear_error();
		}
		if ((crldays == 0) && (crlhours == 0) && (crlsec == 0)) {
			BIO_printf(bio_err, "cannot lookup how long until the next CRL is issued\n");
			goto err;
		}
		if (verbose)
			BIO_printf(bio_err, "making CRL\n");
		if ((crl = X509_CRL_new()) == NULL)
			goto err;
		if (!X509_CRL_set_issuer_name(crl, X509_get_subject_name(x509)))
			goto err;

		tmptm = ASN1_TIME_new();
		if (!tmptm)
			goto err;
		X509_gmtime_adj(tmptm, 0);
		X509_CRL_set_lastUpdate(crl, tmptm);
		if (!X509_time_adj_ex(tmptm, crldays,
		    crlhours * 60 * 60 + crlsec, NULL)) {
			BIO_puts(bio_err, "error setting CRL nextUpdate\n");
			goto err;
		}
		X509_CRL_set_nextUpdate(crl, tmptm);

		ASN1_TIME_free(tmptm);

		for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) {
			pp = sk_OPENSSL_PSTRING_value(db->db->data, i);
			if (pp[DB_type][0] == DB_TYPE_REV) {
				if ((r = X509_REVOKED_new()) == NULL)
					goto err;
				j = make_revoked(r, pp[DB_rev_date]);
				if (!j)
					goto err;
				if (j == 2)
					crl_v2 = 1;
				if (!BN_hex2bn(&serial, pp[DB_serial]))
					goto err;
				tmpser = BN_to_ASN1_INTEGER(serial, NULL);
				BN_free(serial);
				serial = NULL;
				if (!tmpser)
					goto err;
				X509_REVOKED_set_serialNumber(r, tmpser);
				ASN1_INTEGER_free(tmpser);
				X509_CRL_add0_revoked(crl, r);
			}
		}

		/*
		 * sort the data so it will be written in serial number order
		 */
		X509_CRL_sort(crl);

		/* we now have a CRL */
		if (verbose)
			BIO_printf(bio_err, "signing CRL\n");

		/* Add any extensions asked for */

		if (crl_ext || crlnumberfile != NULL) {
			X509V3_CTX crlctx;
			X509V3_set_ctx(&crlctx, x509, NULL, NULL, crl, 0);
			X509V3_set_nconf(&crlctx, conf);

			if (crl_ext)
				if (!X509V3_EXT_CRL_add_nconf(conf, &crlctx,
				    crl_ext, crl))
					goto err;
			if (crlnumberfile != NULL) {
				tmpser = BN_to_ASN1_INTEGER(crlnumber, NULL);
				if (!tmpser)
					goto err;
				X509_CRL_add1_ext_i2d(crl, NID_crl_number,
				    tmpser, 0, 0);
				ASN1_INTEGER_free(tmpser);
				crl_v2 = 1;
				if (!BN_add_word(crlnumber, 1))
					goto err;
			}
		}
		if (crl_ext || crl_v2) {
			if (!X509_CRL_set_version(crl, 1))
				goto err;	/* version 2 CRL */
		}
		if (crlnumberfile != NULL)	/* we have a CRL number that
						 * need updating */
			if (!save_serial(crlnumberfile, "new", crlnumber, NULL))
				goto err;

		if (crlnumber) {
			BN_free(crlnumber);
			crlnumber = NULL;
		}
		if (!do_X509_CRL_sign(bio_err, crl, pkey, dgst, sigopts))
			goto err;

		PEM_write_bio_X509_CRL(Sout, crl);

		if (crlnumberfile != NULL)	/* Rename the crlnumber file */
			if (!rotate_serial(crlnumberfile, "new", "old"))
				goto err;

	}
	/*****************************************************************/
	if (dorevoke) {
		if (infile == NULL) {
			BIO_printf(bio_err, "no input files\n");
			goto err;
		} else {
			X509 *revcert;
			revcert = load_cert(bio_err, infile, FORMAT_PEM,
			    NULL, e, infile);
			if (revcert == NULL)
				goto err;
			j = do_revoke(revcert, db, rev_type, rev_arg);
			if (j <= 0)
				goto err;
			X509_free(revcert);

			if (!save_index(dbfile, "new", db))
				goto err;

			if (!rotate_index(dbfile, "new", "old"))
				goto err;

			BIO_printf(bio_err, "Data Base Updated\n");
		}
	}
	/*****************************************************************/
	ret = 0;

err:
	free(tofree);

	BIO_free_all(Cout);
	BIO_free_all(Sout);
	BIO_free_all(out);
	BIO_free_all(in);

	if (cert_sk)
		sk_X509_pop_free(cert_sk, X509_free);

	if (ret)
		ERR_print_errors(bio_err);
	if (free_key && key)
		free(key);
	BN_free(serial);
	BN_free(crlnumber);
	free_index(db);
	if (sigopts)
		sk_OPENSSL_STRING_free(sigopts);
	EVP_PKEY_free(pkey);
	if (x509)
		X509_free(x509);
	X509_CRL_free(crl);
	NCONF_free(conf);
	NCONF_free(extconf);
	OBJ_cleanup();
	
	return (ret);
}

static void
lookup_fail(const char *name, const char *tag)
{
	BIO_printf(bio_err, "variable lookup failed for %s::%s\n", name, tag);
}

static int
certify(X509 ** xret, char *infile, EVP_PKEY * pkey, X509 * x509,
    const EVP_MD * dgst, STACK_OF(OPENSSL_STRING) * sigopts,
    STACK_OF(CONF_VALUE) * policy, CA_DB * db, BIGNUM * serial, char *subj,
    unsigned long chtype, int multirdn, int email_dn, char *startdate,
    char *enddate, long days, int batch, char *ext_sect, CONF * lconf,
    int verbose, unsigned long certopt, unsigned long nameopt, int default_op,
    int ext_copy, int selfsign)
{
	X509_REQ *req = NULL;
	BIO *in = NULL;
	EVP_PKEY *pktmp = NULL;
	int ok = -1, i;

	in = BIO_new(BIO_s_file());

	if (BIO_read_filename(in, infile) <= 0) {
		perror(infile);
		goto err;
	}
	if ((req = PEM_read_bio_X509_REQ(in, NULL, NULL, NULL)) == NULL) {
		BIO_printf(bio_err, "Error reading certificate request in %s\n",
		    infile);
		goto err;
	}
	if (verbose)
		X509_REQ_print(bio_err, req);

	BIO_printf(bio_err, "Check that the request matches the signature\n");

	if (selfsign && !X509_REQ_check_private_key(req, pkey)) {
		BIO_printf(bio_err,
		    "Certificate request and CA private key do not match\n");
		ok = 0;
		goto err;
	}
	if ((pktmp = X509_REQ_get_pubkey(req)) == NULL) {
		BIO_printf(bio_err, "error unpacking public key\n");
		goto err;
	}
	i = X509_REQ_verify(req, pktmp);
	EVP_PKEY_free(pktmp);
	if (i < 0) {
		ok = 0;
		BIO_printf(bio_err, "Signature verification problems....\n");
		goto err;
	}
	if (i == 0) {
		ok = 0;
		BIO_printf(bio_err,
		    "Signature did not match the certificate request\n");
		goto err;
	} else
		BIO_printf(bio_err, "Signature ok\n");

	ok = do_body(xret, pkey, x509, dgst, sigopts, policy, db, serial,
	    subj, chtype, multirdn, email_dn, startdate, enddate, days, batch,
	    verbose, req, ext_sect, lconf, certopt, nameopt, default_op,
	    ext_copy, selfsign);

err:
	if (req != NULL)
		X509_REQ_free(req);
	if (in != NULL)
		BIO_free(in);
	return (ok);
}

static int
certify_cert(X509 ** xret, char *infile, EVP_PKEY * pkey, X509 * x509,
    const EVP_MD * dgst, STACK_OF(OPENSSL_STRING) * sigopts,
    STACK_OF(CONF_VALUE) * policy, CA_DB * db, BIGNUM * serial, char *subj,
    unsigned long chtype, int multirdn, int email_dn, char *startdate,
    char *enddate, long days, int batch, char *ext_sect, CONF * lconf,
    int verbose, unsigned long certopt, unsigned long nameopt, int default_op,
    int ext_copy, ENGINE * e)
{
	X509 *req = NULL;
	X509_REQ *rreq = NULL;
	EVP_PKEY *pktmp = NULL;
	int ok = -1, i;

	if ((req = load_cert(bio_err, infile, FORMAT_PEM, NULL, e,
	    infile)) == NULL)
		goto err;
	if (verbose)
		X509_print(bio_err, req);

	BIO_printf(bio_err, "Check that the request matches the signature\n");

	if ((pktmp = X509_get_pubkey(req)) == NULL) {
		BIO_printf(bio_err, "error unpacking public key\n");
		goto err;
	}
	i = X509_verify(req, pktmp);
	EVP_PKEY_free(pktmp);
	if (i < 0) {
		ok = 0;
		BIO_printf(bio_err, "Signature verification problems....\n");
		goto err;
	}
	if (i == 0) {
		ok = 0;
		BIO_printf(bio_err,
		    "Signature did not match the certificate\n");
		goto err;
	} else
		BIO_printf(bio_err, "Signature ok\n");

	if ((rreq = X509_to_X509_REQ(req, NULL, EVP_md5())) == NULL)
		goto err;

	ok = do_body(xret, pkey, x509, dgst, sigopts, policy, db, serial,
	    subj, chtype, multirdn, email_dn, startdate, enddate, days, batch,
	    verbose, rreq, ext_sect, lconf, certopt, nameopt, default_op,
	    ext_copy, 0);

err:
	if (rreq != NULL)
		X509_REQ_free(rreq);
	if (req != NULL)
		X509_free(req);
	return (ok);
}

static int
do_body(X509 ** xret, EVP_PKEY * pkey, X509 * x509, const EVP_MD * dgst,
    STACK_OF(OPENSSL_STRING) * sigopts, STACK_OF(CONF_VALUE) * policy,
    CA_DB * db, BIGNUM * serial, char *subj, unsigned long chtype, int multirdn,
    int email_dn, char *startdate, char *enddate, long days, int batch,
    int verbose, X509_REQ * req, char *ext_sect, CONF * lconf,
    unsigned long certopt, unsigned long nameopt, int default_op,
    int ext_copy, int selfsign)
{
	X509_NAME *name = NULL, *CAname = NULL, *subject = NULL, *dn_subject = NULL;
	ASN1_UTCTIME *tm, *tmptm;
	ASN1_STRING *str, *str2;
	ASN1_OBJECT *obj;
	X509 *ret = NULL;
	X509_CINF *ci;
	X509_NAME_ENTRY *ne;
	X509_NAME_ENTRY *tne, *push;
	EVP_PKEY *pktmp;
	int ok = -1, i, j, last, nid;
	const char *p;
	CONF_VALUE *cv;
	OPENSSL_STRING row[DB_NUMBER];
	OPENSSL_STRING *irow = NULL;
	OPENSSL_STRING *rrow = NULL;
	char buf[25];

	tmptm = ASN1_UTCTIME_new();
	if (tmptm == NULL) {
		BIO_printf(bio_err, "malloc error\n");
		return (0);
	}
	for (i = 0; i < DB_NUMBER; i++)
		row[i] = NULL;

	if (subj) {
		X509_NAME *n = parse_name(subj, chtype, multirdn);

		if (!n) {
			ERR_print_errors(bio_err);
			goto err;
		}
		X509_REQ_set_subject_name(req, n);
		req->req_info->enc.modified = 1;
		X509_NAME_free(n);
	}
	if (default_op)
		BIO_printf(bio_err,
		    "The Subject's Distinguished Name is as follows\n");

	name = X509_REQ_get_subject_name(req);
	for (i = 0; i < X509_NAME_entry_count(name); i++) {
		ne = X509_NAME_get_entry(name, i);
		str = X509_NAME_ENTRY_get_data(ne);
		obj = X509_NAME_ENTRY_get_object(ne);

		if (msie_hack) {
			/* assume all type should be strings */
			nid = OBJ_obj2nid(ne->object);

			if (str->type == V_ASN1_UNIVERSALSTRING)
				ASN1_UNIVERSALSTRING_to_string(str);

			if ((str->type == V_ASN1_IA5STRING) &&
			    (nid != NID_pkcs9_emailAddress))
				str->type = V_ASN1_T61STRING;

			if ((nid == NID_pkcs9_emailAddress) &&
			    (str->type == V_ASN1_PRINTABLESTRING))
				str->type = V_ASN1_IA5STRING;
		}
		/* If no EMAIL is wanted in the subject */
		if ((OBJ_obj2nid(obj) == NID_pkcs9_emailAddress) && (!email_dn))
			continue;

		/* check some things */
		if ((OBJ_obj2nid(obj) == NID_pkcs9_emailAddress) &&
		    (str->type != V_ASN1_IA5STRING)) {
			BIO_printf(bio_err, "\nemailAddress type needs to be of type IA5STRING\n");
			goto err;
		}
		if ((str->type != V_ASN1_BMPSTRING) &&
		    (str->type != V_ASN1_UTF8STRING)) {
			j = ASN1_PRINTABLE_type(str->data, str->length);
			if (((j == V_ASN1_T61STRING) &&
			    (str->type != V_ASN1_T61STRING)) ||
			    ((j == V_ASN1_IA5STRING) &&
			    (str->type == V_ASN1_PRINTABLESTRING))) {
				BIO_printf(bio_err, "\nThe string contains characters that are illegal for the ASN.1 type\n");
				goto err;
			}
		}
		if (default_op)
			old_entry_print(bio_err, obj, str);
	}

	/* Ok, now we check the 'policy' stuff. */
	if ((subject = X509_NAME_new()) == NULL) {
		BIO_printf(bio_err, "Memory allocation failure\n");
		goto err;
	}
	/* take a copy of the issuer name before we mess with it. */
	if (selfsign)
		CAname = X509_NAME_dup(name);
	else
		CAname = X509_NAME_dup(x509->cert_info->subject);
	if (CAname == NULL)
		goto err;
	str = str2 = NULL;

	for (i = 0; i < sk_CONF_VALUE_num(policy); i++) {
		cv = sk_CONF_VALUE_value(policy, i);	/* get the object id */
		if ((j = OBJ_txt2nid(cv->name)) == NID_undef) {
			BIO_printf(bio_err, "%s:unknown object type in 'policy' configuration\n", cv->name);
			goto err;
		}
		obj = OBJ_nid2obj(j);

		last = -1;
		for (;;) {
			/* lookup the object in the supplied name list */
			j = X509_NAME_get_index_by_OBJ(name, obj, last);
			if (j < 0) {
				if (last != -1)
					break;
				tne = NULL;
			} else {
				tne = X509_NAME_get_entry(name, j);
			}
			last = j;

			/* depending on the 'policy', decide what to do. */
			push = NULL;
			if (strcmp(cv->value, "optional") == 0) {
				if (tne != NULL)
					push = tne;
			} else if (strcmp(cv->value, "supplied") == 0) {
				if (tne == NULL) {
					BIO_printf(bio_err, "The %s field needed to be supplied and was missing\n", cv->name);
					goto err;
				} else
					push = tne;
			} else if (strcmp(cv->value, "match") == 0) {
				int last2;

				if (tne == NULL) {
					BIO_printf(bio_err, "The mandatory %s field was missing\n", cv->name);
					goto err;
				}
				last2 = -1;

again2:
				j = X509_NAME_get_index_by_OBJ(CAname, obj, last2);
				if ((j < 0) && (last2 == -1)) {
					BIO_printf(bio_err, "The %s field does not exist in the CA certificate,\nthe 'policy' is misconfigured\n", cv->name);
					goto err;
				}
				if (j >= 0) {
					push = X509_NAME_get_entry(CAname, j);
					str = X509_NAME_ENTRY_get_data(tne);
					str2 = X509_NAME_ENTRY_get_data(push);
					last2 = j;
					if (ASN1_STRING_cmp(str, str2) != 0)
						goto again2;
				}
				if (j < 0) {
					BIO_printf(bio_err, "The %s field needed to be the same in the\nCA certificate (%s) and the request (%s)\n", cv->name, ((str2 == NULL) ? "NULL" : (char *) str2->data), ((str == NULL) ? "NULL" : (char *) str->data));
					goto err;
				}
			} else {
				BIO_printf(bio_err, "%s:invalid type in 'policy' configuration\n", cv->value);
				goto err;
			}

			if (push != NULL) {
				if (!X509_NAME_add_entry(subject, push,
				    -1, 0)) {
					if (push != NULL)
						X509_NAME_ENTRY_free(push);
					BIO_printf(bio_err,
					    "Memory allocation failure\n");
					goto err;
				}
			}
			if (j < 0)
				break;
		}
	}

	if (preserve) {
		X509_NAME_free(subject);
		/* subject=X509_NAME_dup(X509_REQ_get_subject_name(req)); */
		subject = X509_NAME_dup(name);
		if (subject == NULL)
			goto err;
	}
	if (verbose)
		BIO_printf(bio_err, "The subject name appears to be ok, checking data base for clashes\n");

	/* Build the correct Subject if no e-mail is wanted in the subject */
	/*
	 * and add it later on because of the method extensions are added
	 * (altName)
	 */

	if (email_dn)
		dn_subject = subject;
	else {
		X509_NAME_ENTRY *tmpne;
		/*
		 * Its best to dup the subject DN and then delete any email
		 * addresses because this retains its structure.
		 */
		if (!(dn_subject = X509_NAME_dup(subject))) {
			BIO_printf(bio_err, "Memory allocation failure\n");
			goto err;
		}
		while ((i = X509_NAME_get_index_by_NID(dn_subject,
		    NID_pkcs9_emailAddress, -1)) >= 0) {
			tmpne = X509_NAME_get_entry(dn_subject, i);
			X509_NAME_delete_entry(dn_subject, i);
			X509_NAME_ENTRY_free(tmpne);
		}
	}

	if (BN_is_zero(serial))
		row[DB_serial] = BUF_strdup("00");
	else
		row[DB_serial] = BN_bn2hex(serial);
	if (row[DB_serial] == NULL) {
		BIO_printf(bio_err, "Memory allocation failure\n");
		goto err;
	}
	if (db->attributes.unique_subject) {
		OPENSSL_STRING *crow = row;

		rrow = TXT_DB_get_by_index(db->db, DB_name, crow);
		if (rrow != NULL) {
			BIO_printf(bio_err,
			    "ERROR:There is already a certificate for %s\n",
			    row[DB_name]);
		}
	}
	if (rrow == NULL) {
		rrow = TXT_DB_get_by_index(db->db, DB_serial, row);
		if (rrow != NULL) {
			BIO_printf(bio_err,
			    "ERROR:Serial number %s has already been issued,\n",
			    row[DB_serial]);
			BIO_printf(bio_err, "      check the database/serial_file for corruption\n");
		}
	}
	if (rrow != NULL) {
		BIO_printf(bio_err,
		    "The matching entry has the following details\n");
		if (rrow[DB_type][0] == 'E')
			p = "Expired";
		else if (rrow[DB_type][0] == 'R')
			p = "Revoked";
		else if (rrow[DB_type][0] == 'V')
			p = "Valid";
		else
			p = "\ninvalid type, Data base error\n";
		BIO_printf(bio_err, "Type	  :%s\n", p);
		if (rrow[DB_type][0] == 'R') {
			p = rrow[DB_exp_date];
			if (p == NULL)
				p = "undef";
			BIO_printf(bio_err, "Was revoked on:%s\n", p);
		}
		p = rrow[DB_exp_date];
		if (p == NULL)
			p = "undef";
		BIO_printf(bio_err, "Expires on    :%s\n", p);
		p = rrow[DB_serial];
		if (p == NULL)
			p = "undef";
		BIO_printf(bio_err, "Serial Number :%s\n", p);
		p = rrow[DB_file];
		if (p == NULL)
			p = "undef";
		BIO_printf(bio_err, "File name     :%s\n", p);
		p = rrow[DB_name];
		if (p == NULL)
			p = "undef";
		BIO_printf(bio_err, "Subject Name  :%s\n", p);
		ok = -1;	/* This is now a 'bad' error. */
		goto err;
	}
	/* We are now totally happy, lets make and sign the certificate */
	if (verbose)
		BIO_printf(bio_err, "Everything appears to be ok, creating and signing the certificate\n");

	if ((ret = X509_new()) == NULL)
		goto err;
	ci = ret->cert_info;

#ifdef X509_V3
	/* Make it an X509 v3 certificate. */
	if (!X509_set_version(ret, 2))
		goto err;
#endif

	if (BN_to_ASN1_INTEGER(serial, ci->serialNumber) == NULL)
		goto err;
	if (selfsign) {
		if (!X509_set_issuer_name(ret, subject))
			goto err;
	} else {
		if (!X509_set_issuer_name(ret, X509_get_subject_name(x509)))
			goto err;
	}

	if (strcmp(startdate, "today") == 0)
		X509_gmtime_adj(X509_get_notBefore(ret), 0);
	else
		ASN1_TIME_set_string(X509_get_notBefore(ret), startdate);

	if (enddate == NULL)
		X509_time_adj_ex(X509_get_notAfter(ret), days, 0, NULL);
	else
		ASN1_TIME_set_string(X509_get_notAfter(ret), enddate);

	if (!X509_set_subject_name(ret, subject))
		goto err;

	pktmp = X509_REQ_get_pubkey(req);
	i = X509_set_pubkey(ret, pktmp);
	EVP_PKEY_free(pktmp);
	if (!i)
		goto err;

	/* Lets add the extensions, if there are any */
	if (ext_sect) {
		X509V3_CTX ctx;
		if (ci->version == NULL)
			if ((ci->version = ASN1_INTEGER_new()) == NULL)
				goto err;
		ASN1_INTEGER_set(ci->version, 2);	/* version 3 certificate */

		/*
		 * Free the current entries if any, there should not be any I
		 * believe
		 */
		if (ci->extensions != NULL)
			sk_X509_EXTENSION_pop_free(ci->extensions,
			    X509_EXTENSION_free);

		ci->extensions = NULL;

		/* Initialize the context structure */
		if (selfsign)
			X509V3_set_ctx(&ctx, ret, ret, req, NULL, 0);
		else
			X509V3_set_ctx(&ctx, x509, ret, req, NULL, 0);

		if (extconf) {
			if (verbose)
				BIO_printf(bio_err,
				    "Extra configuration file found\n");

			/* Use the extconf configuration db LHASH */
			X509V3_set_nconf(&ctx, extconf);

			/* Test the structure (needed?) */
			/* X509V3_set_ctx_test(&ctx); */

			/* Adds exts contained in the configuration file */
			if (!X509V3_EXT_add_nconf(extconf, &ctx,
			    ext_sect, ret)) {
				BIO_printf(bio_err,
				    "ERROR: adding extensions in section %s\n",
				    ext_sect);
				ERR_print_errors(bio_err);
				goto err;
			}
			if (verbose)
				BIO_printf(bio_err, "Successfully added extensions from file.\n");
		} else if (ext_sect) {
			/* We found extensions to be set from config file */
			X509V3_set_nconf(&ctx, lconf);

			if (!X509V3_EXT_add_nconf(lconf, &ctx, ext_sect, ret)) {
				BIO_printf(bio_err,
				    "ERROR: adding extensions in section %s\n",
				    ext_sect);
				ERR_print_errors(bio_err);
				goto err;
			}
			if (verbose)
				BIO_printf(bio_err, "Successfully added extensions from config\n");
		}
	}
	/* Copy extensions from request (if any) */

	if (!copy_extensions(ret, req, ext_copy)) {
		BIO_printf(bio_err, "ERROR: adding extensions from request\n");
		ERR_print_errors(bio_err);
		goto err;
	}
	/* Set the right value for the noemailDN option */
	if (email_dn == 0) {
		if (!X509_set_subject_name(ret, dn_subject))
			goto err;
	}
	if (!default_op) {
		BIO_printf(bio_err, "Certificate Details:\n");
		/*
		 * Never print signature details because signature not
		 * present
		 */
		certopt |= X509_FLAG_NO_SIGDUMP | X509_FLAG_NO_SIGNAME;
		X509_print_ex(bio_err, ret, nameopt, certopt);
	}
	BIO_printf(bio_err, "Certificate is to be certified until ");
	ASN1_TIME_print(bio_err, X509_get_notAfter(ret));
	if (days)
		BIO_printf(bio_err, " (%ld days)", days);
	BIO_printf(bio_err, "\n");

	if (!batch) {

		BIO_printf(bio_err, "Sign the certificate? [y/n]:");
		(void) BIO_flush(bio_err);
		buf[0] = '\0';
		if (!fgets(buf, sizeof(buf) - 1, stdin)) {
			BIO_printf(bio_err,
			    "CERTIFICATE WILL NOT BE CERTIFIED: I/O error\n");
			ok = 0;
			goto err;
		}
		if (!((buf[0] == 'y') || (buf[0] == 'Y'))) {
			BIO_printf(bio_err,
			    "CERTIFICATE WILL NOT BE CERTIFIED\n");
			ok = 0;
			goto err;
		}
	}
	pktmp = X509_get_pubkey(ret);
	if (EVP_PKEY_missing_parameters(pktmp) &&
	    !EVP_PKEY_missing_parameters(pkey))
		EVP_PKEY_copy_parameters(pktmp, pkey);
	EVP_PKEY_free(pktmp);

	if (!do_X509_sign(bio_err, ret, pkey, dgst, sigopts))
		goto err;

	/* We now just add it to the database */
	row[DB_type] = malloc(2);

	tm = X509_get_notAfter(ret);
	row[DB_exp_date] = malloc(tm->length + 1);
	memcpy(row[DB_exp_date], tm->data, tm->length);
	row[DB_exp_date][tm->length] = '\0';

	row[DB_rev_date] = NULL;

	/* row[DB_serial] done already */
	row[DB_file] = malloc(8);
	row[DB_name] = X509_NAME_oneline(X509_get_subject_name(ret), NULL, 0);

	if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||
	    (row[DB_file] == NULL) || (row[DB_name] == NULL)) {
		BIO_printf(bio_err, "Memory allocation failure\n");
		goto err;
	}
	(void) strlcpy(row[DB_file], "unknown", 8);
	row[DB_type][0] = 'V';
	row[DB_type][1] = '\0';

	if ((irow = reallocarray(NULL, DB_NUMBER + 1, sizeof(char *))) ==
	    NULL) {
		BIO_printf(bio_err, "Memory allocation failure\n");
		goto err;
	}
	for (i = 0; i < DB_NUMBER; i++) {
		irow[i] = row[i];
		row[i] = NULL;
	}
	irow[DB_NUMBER] = NULL;

	if (!TXT_DB_insert(db->db, irow)) {
		BIO_printf(bio_err, "failed to update database\n");
		BIO_printf(bio_err, "TXT_DB error number %ld\n", db->db->error);
		goto err;
	}
	ok = 1;
err:
	for (i = 0; i < DB_NUMBER; i++)
		free(row[i]);

	if (CAname != NULL)
		X509_NAME_free(CAname);
	if (subject != NULL)
		X509_NAME_free(subject);
	if ((dn_subject != NULL) && !email_dn)
		X509_NAME_free(dn_subject);
	if (tmptm != NULL)
		ASN1_UTCTIME_free(tmptm);
	if (ok <= 0) {
		if (ret != NULL)
			X509_free(ret);
		ret = NULL;
	} else
		*xret = ret;
	return (ok);
}

static void
write_new_certificate(BIO * bp, X509 * x, int output_der, int notext)
{
	if (output_der) {
		(void) i2d_X509_bio(bp, x);
		return;
	}
#if 0
	/* ??? Not needed since X509_print prints all this stuff anyway */
	f = X509_NAME_oneline(X509_get_issuer_name(x), buf, 256);
	BIO_printf(bp, "issuer :%s\n", f);

	f = X509_NAME_oneline(X509_get_subject_name(x), buf, 256);
	BIO_printf(bp, "subject:%s\n", f);

	BIO_puts(bp, "serial :");
	i2a_ASN1_INTEGER(bp, x->cert_info->serialNumber);
	BIO_puts(bp, "\n\n");
#endif
	if (!notext)
		X509_print(bp, x);
	PEM_write_bio_X509(bp, x);
}

static int
certify_spkac(X509 ** xret, char *infile, EVP_PKEY * pkey, X509 * x509,
    const EVP_MD * dgst, STACK_OF(OPENSSL_STRING) * sigopts,
    STACK_OF(CONF_VALUE) * policy, CA_DB * db, BIGNUM * serial, char *subj,
    unsigned long chtype, int multirdn, int email_dn, char *startdate,
    char *enddate, long days, char *ext_sect, CONF * lconf, int verbose,
    unsigned long certopt, unsigned long nameopt, int default_op, int ext_copy)
{
	STACK_OF(CONF_VALUE) * sk = NULL;
	LHASH_OF(CONF_VALUE) * parms = NULL;
	X509_REQ *req = NULL;
	CONF_VALUE *cv = NULL;
	NETSCAPE_SPKI *spki = NULL;
	X509_REQ_INFO *ri;
	char *type, *buf;
	EVP_PKEY *pktmp = NULL;
	X509_NAME *n = NULL;
	X509_NAME_ENTRY *ne = NULL;
	int ok = -1, i, j;
	long errline;
	int nid;

	/*
	 * Load input file into a hash table.  (This is just an easy
	 * way to read and parse the file, then put it into a convenient
	 * STACK format).
	 */
	parms = CONF_load(NULL, infile, &errline);
	if (parms == NULL) {
		BIO_printf(bio_err, "error on line %ld of %s\n",
		    errline, infile);
		ERR_print_errors(bio_err);
		goto err;
	}
	sk = CONF_get_section(parms, "default");
	if (sk_CONF_VALUE_num(sk) == 0) {
		BIO_printf(bio_err, "no name/value pairs found in %s\n",
		    infile);
		CONF_free(parms);
		goto err;
	}
	/*
	 * Now create a dummy X509 request structure.  We don't actually
	 * have an X509 request, but we have many of the components
	 * (a public key, various DN components).  The idea is that we
	 * put these components into the right X509 request structure
	 * and we can use the same code as if you had a real X509 request.
	 */
	req = X509_REQ_new();
	if (req == NULL) {
		ERR_print_errors(bio_err);
		goto err;
	}
	/*
	 * Build up the subject name set.
	 */
	ri = req->req_info;
	n = ri->subject;

	for (i = 0;; i++) {
		if (sk_CONF_VALUE_num(sk) <= i)
			break;

		cv = sk_CONF_VALUE_value(sk, i);
		type = cv->name;
		/*
		 * Skip past any leading X. X: X, etc to allow for multiple
		 * instances
		 */
		for (buf = cv->name; *buf; buf++) {
			if ((*buf == ':') || (*buf == ',') || (*buf == '.')) {
				buf++;
				if (*buf)
					type = buf;
				break;
			}
		}

		buf = cv->value;
		if ((nid = OBJ_txt2nid(type)) == NID_undef) {
			if (strcmp(type, "SPKAC") == 0) {
				spki = NETSCAPE_SPKI_b64_decode(cv->value, -1);
				if (spki == NULL) {
					BIO_printf(bio_err, "unable to load Netscape SPKAC structure\n");
					ERR_print_errors(bio_err);
					goto err;
				}
			}
			continue;
		}
		if (!X509_NAME_add_entry_by_NID(n, nid, chtype,
		    (unsigned char *)buf, -1, -1, 0))
			goto err;
	}
	if (spki == NULL) {
		BIO_printf(bio_err,
		    "Netscape SPKAC structure not found in %s\n", infile);
		goto err;
	}
	/*
	 * Now extract the key from the SPKI structure.
	 */

	BIO_printf(bio_err,
	    "Check that the SPKAC request matches the signature\n");

	if ((pktmp = NETSCAPE_SPKI_get_pubkey(spki)) == NULL) {
		BIO_printf(bio_err, "error unpacking SPKAC public key\n");
		goto err;
	}
	j = NETSCAPE_SPKI_verify(spki, pktmp);
	if (j <= 0) {
		BIO_printf(bio_err,
		    "signature verification failed on SPKAC public key\n");
		goto err;
	}
	BIO_printf(bio_err, "Signature ok\n");

	X509_REQ_set_pubkey(req, pktmp);
	EVP_PKEY_free(pktmp);
	ok = do_body(xret, pkey, x509, dgst, sigopts, policy, db, serial,
	    subj, chtype, multirdn, email_dn, startdate, enddate, days, 1,
	    verbose, req, ext_sect, lconf, certopt, nameopt, default_op,
	    ext_copy, 0);

err:
	if (req != NULL)
		X509_REQ_free(req);
	if (parms != NULL)
		CONF_free(parms);
	if (spki != NULL)
		NETSCAPE_SPKI_free(spki);
	if (ne != NULL)
		X509_NAME_ENTRY_free(ne);

	return (ok);
}

static int
check_time_format(const char *str)
{
	return ASN1_TIME_set_string(NULL, str);
}

static int
do_revoke(X509 * x509, CA_DB * db, int type, char *value)
{
	ASN1_UTCTIME *tm = NULL;
	char *row[DB_NUMBER], **rrow, **irow;
	char *rev_str = NULL;
	BIGNUM *bn = NULL;
	int ok = -1, i;

	for (i = 0; i < DB_NUMBER; i++)
		row[i] = NULL;
	row[DB_name] = X509_NAME_oneline(X509_get_subject_name(x509), NULL, 0);
	bn = ASN1_INTEGER_to_BN(X509_get_serialNumber(x509), NULL);
	if (!bn)
		goto err;
	if (BN_is_zero(bn))
		row[DB_serial] = BUF_strdup("00");
	else
		row[DB_serial] = BN_bn2hex(bn);
	BN_free(bn);
	if ((row[DB_name] == NULL) || (row[DB_serial] == NULL)) {
		BIO_printf(bio_err, "Memory allocation failure\n");
		goto err;
	}
	/*
	 * We have to lookup by serial number because name lookup skips
	 * revoked certs
	 */
	rrow = TXT_DB_get_by_index(db->db, DB_serial, row);
	if (rrow == NULL) {
		BIO_printf(bio_err,
		    "Adding Entry with serial number %s to DB for %s\n",
		    row[DB_serial], row[DB_name]);

		/* We now just add it to the database */
		row[DB_type] = malloc(2);

		tm = X509_get_notAfter(x509);
		row[DB_exp_date] = malloc(tm->length + 1);
		memcpy(row[DB_exp_date], tm->data, tm->length);
		row[DB_exp_date][tm->length] = '\0';

		row[DB_rev_date] = NULL;

		/* row[DB_serial] done already */
		row[DB_file] = malloc(8);

		/* row[DB_name] done already */

		if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||
		    (row[DB_file] == NULL)) {
			BIO_printf(bio_err, "Memory allocation failure\n");
			goto err;
		}
		(void) strlcpy(row[DB_file], "unknown", 8);
		row[DB_type][0] = 'V';
		row[DB_type][1] = '\0';

		if ((irow = reallocarray(NULL, sizeof(char *),
		    (DB_NUMBER + 1))) == NULL) {
			BIO_printf(bio_err, "Memory allocation failure\n");
			goto err;
		}
		for (i = 0; i < DB_NUMBER; i++) {
			irow[i] = row[i];
			row[i] = NULL;
		}
		irow[DB_NUMBER] = NULL;

		if (!TXT_DB_insert(db->db, irow)) {
			BIO_printf(bio_err, "failed to update database\n");
			BIO_printf(bio_err, "TXT_DB error number %ld\n",
			    db->db->error);
			goto err;
		}
		/* Revoke Certificate */
		ok = do_revoke(x509, db, type, value);

		goto err;

	} else if (index_name_cmp_noconst(row, rrow)) {
		BIO_printf(bio_err, "ERROR:name does not match %s\n",
		    row[DB_name]);
		goto err;
	} else if (rrow[DB_type][0] == 'R') {
		BIO_printf(bio_err, "ERROR:Already revoked, serial number %s\n",
		    row[DB_serial]);
		goto err;
	} else {
		BIO_printf(bio_err, "Revoking Certificate %s.\n",
		    rrow[DB_serial]);
		rev_str = make_revocation_str(type, value);
		if (!rev_str) {
			BIO_printf(bio_err, "Error in revocation arguments\n");
			goto err;
		}
		rrow[DB_type][0] = 'R';
		rrow[DB_type][1] = '\0';
		rrow[DB_rev_date] = rev_str;
	}
	ok = 1;

err:
	for (i = 0; i < DB_NUMBER; i++)
		free(row[i]);

	return (ok);
}

static int
get_certificate_status(const char *serial, CA_DB * db)
{
	char *row[DB_NUMBER], **rrow;
	int ok = -1, i;

	/* Free Resources */
	for (i = 0; i < DB_NUMBER; i++)
		row[i] = NULL;

	/* Malloc needed char spaces */
	row[DB_serial] = malloc(strlen(serial) + 2);
	if (row[DB_serial] == NULL) {
		BIO_printf(bio_err, "Malloc failure\n");
		goto err;
	}
	if (strlen(serial) % 2) {
		/* Set the first char to 0 */ ;
		row[DB_serial][0] = '0';

		/* Copy String from serial to row[DB_serial] */
		memcpy(row[DB_serial] + 1, serial, strlen(serial));
		row[DB_serial][strlen(serial) + 1] = '\0';
	} else {
		/* Copy String from serial to row[DB_serial] */
		memcpy(row[DB_serial], serial, strlen(serial));
		row[DB_serial][strlen(serial)] = '\0';
	}

	/* Make it Upper Case */
	for (i = 0; row[DB_serial][i] != '\0'; i++)
		row[DB_serial][i] = toupper((unsigned char) row[DB_serial][i]);


	ok = 1;

	/* Search for the certificate */
	rrow = TXT_DB_get_by_index(db->db, DB_serial, row);
	if (rrow == NULL) {
		BIO_printf(bio_err, "Serial %s not present in db.\n",
		    row[DB_serial]);
		ok = -1;
		goto err;
	} else if (rrow[DB_type][0] == 'V') {
		BIO_printf(bio_err, "%s=Valid (%c)\n",
		    row[DB_serial], rrow[DB_type][0]);
		goto err;
	} else if (rrow[DB_type][0] == 'R') {
		BIO_printf(bio_err, "%s=Revoked (%c)\n",
		    row[DB_serial], rrow[DB_type][0]);
		goto err;
	} else if (rrow[DB_type][0] == 'E') {
		BIO_printf(bio_err, "%s=Expired (%c)\n",
		    row[DB_serial], rrow[DB_type][0]);
		goto err;
	} else if (rrow[DB_type][0] == 'S') {
		BIO_printf(bio_err, "%s=Suspended (%c)\n",
		    row[DB_serial], rrow[DB_type][0]);
		goto err;
	} else {
		BIO_printf(bio_err, "%s=Unknown (%c).\n",
		    row[DB_serial], rrow[DB_type][0]);
		ok = -1;
	}

err:
	for (i = 0; i < DB_NUMBER; i++)
		free(row[i]);

	return (ok);
}

static int
do_updatedb(CA_DB * db)
{
	ASN1_UTCTIME *a_tm = NULL;
	int i, cnt = 0;
	int db_y2k, a_y2k;	/* flags = 1 if y >= 2000 */
	char **rrow, *a_tm_s;

	a_tm = ASN1_UTCTIME_new();

	/* get actual time and make a string */
	a_tm = X509_gmtime_adj(a_tm, 0);
	a_tm_s = malloc(a_tm->length + 1);
	if (a_tm_s == NULL) {
		cnt = -1;
		goto err;
	}
	memcpy(a_tm_s, a_tm->data, a_tm->length);
	a_tm_s[a_tm->length] = '\0';

	if (strncmp(a_tm_s, "49", 2) <= 0)
		a_y2k = 1;
	else
		a_y2k = 0;

	for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) {
		rrow = sk_OPENSSL_PSTRING_value(db->db->data, i);

		if (rrow[DB_type][0] == 'V') {
			/* ignore entries that are not valid */
			if (strncmp(rrow[DB_exp_date], "49", 2) <= 0)
				db_y2k = 1;
			else
				db_y2k = 0;

			if (db_y2k == a_y2k) {
				/* all on the same y2k side */
				if (strcmp(rrow[DB_exp_date], a_tm_s) <= 0) {
					rrow[DB_type][0] = 'E';
					rrow[DB_type][1] = '\0';
					cnt++;

					BIO_printf(bio_err, "%s=Expired\n",
					    rrow[DB_serial]);
				}
			} else if (db_y2k < a_y2k) {
				rrow[DB_type][0] = 'E';
				rrow[DB_type][1] = '\0';
				cnt++;

				BIO_printf(bio_err, "%s=Expired\n",
				    rrow[DB_serial]);
			}
		}
	}

err:
	ASN1_UTCTIME_free(a_tm);
	free(a_tm_s);

	return (cnt);
}

static const char *crl_reasons[] = {
	/* CRL reason strings */
	"unspecified",
	"keyCompromise",
	"CACompromise",
	"affiliationChanged",
	"superseded",
	"cessationOfOperation",
	"certificateHold",
	"removeFromCRL",
	/* Additional pseudo reasons */
	"holdInstruction",
	"keyTime",
	"CAkeyTime"
};

#define NUM_REASONS (sizeof(crl_reasons) / sizeof(char *))

/* Given revocation information convert to a DB string.
 * The format of the string is:
 * revtime[,reason,extra]. Where 'revtime' is the
 * revocation time (the current time). 'reason' is the
 * optional CRL reason and 'extra' is any additional
 * argument
 */

char *
make_revocation_str(int rev_type, char *rev_arg)
{
	char *other = NULL, *str;
	const char *reason = NULL;
	ASN1_OBJECT *otmp;
	ASN1_UTCTIME *revtm = NULL;
	int i;
	switch (rev_type) {
	case REV_NONE:
		break;

	case REV_CRL_REASON:
		for (i = 0; i < 8; i++) {
			if (!strcasecmp(rev_arg, crl_reasons[i])) {
				reason = crl_reasons[i];
				break;
			}
		}
		if (reason == NULL) {
			BIO_printf(bio_err, "Unknown CRL reason %s\n", rev_arg);
			return NULL;
		}
		break;

	case REV_HOLD:
		/* Argument is an OID */

		otmp = OBJ_txt2obj(rev_arg, 0);
		ASN1_OBJECT_free(otmp);

		if (otmp == NULL) {
			BIO_printf(bio_err,
			    "Invalid object identifier %s\n", rev_arg);
			return NULL;
		}
		reason = "holdInstruction";
		other = rev_arg;
		break;

	case REV_KEY_COMPROMISE:
	case REV_CA_COMPROMISE:

		/* Argument is the key compromise time  */
		if (!ASN1_GENERALIZEDTIME_set_string(NULL, rev_arg)) {
			BIO_printf(bio_err,
			    "Invalid time format %s. Need YYYYMMDDHHMMSSZ\n",
			    rev_arg);
			return NULL;
		}
		other = rev_arg;
		if (rev_type == REV_KEY_COMPROMISE)
			reason = "keyTime";
		else
			reason = "CAkeyTime";

		break;

	}

	revtm = X509_gmtime_adj(NULL, 0);
	if (asprintf(&str, "%s%s%s%s%s", revtm->data,
	    reason ? "," : "", reason ? reason : "",
	    other ? "," : "", other ? other : "") == -1)
		str = NULL;
	ASN1_UTCTIME_free(revtm);
	return str;
}

/* Convert revocation field to X509_REVOKED entry
 * return code:
 * 0 error
 * 1 OK
 * 2 OK and some extensions added (i.e. V2 CRL)
 */

int
make_revoked(X509_REVOKED * rev, const char *str)
{
	char *tmp = NULL;
	int reason_code = -1;
	int i, ret = 0;
	ASN1_OBJECT *hold = NULL;
	ASN1_GENERALIZEDTIME *comp_time = NULL;
	ASN1_ENUMERATED *rtmp = NULL;

	ASN1_TIME *revDate = NULL;

	i = unpack_revinfo(&revDate, &reason_code, &hold, &comp_time, str);

	if (i == 0)
		goto err;

	if (rev && !X509_REVOKED_set_revocationDate(rev, revDate))
		goto err;

	if (rev && (reason_code != OCSP_REVOKED_STATUS_NOSTATUS)) {
		rtmp = ASN1_ENUMERATED_new();
		if (!rtmp || !ASN1_ENUMERATED_set(rtmp, reason_code))
			goto err;
		if (!X509_REVOKED_add1_ext_i2d(rev, NID_crl_reason, rtmp, 0, 0))
			goto err;
	}
	if (rev && comp_time) {
		if (!X509_REVOKED_add1_ext_i2d(rev, NID_invalidity_date,
		    comp_time, 0, 0))
			goto err;
	}
	if (rev && hold) {
		if (!X509_REVOKED_add1_ext_i2d(rev, NID_hold_instruction_code,
		    hold, 0, 0))
			goto err;
	}
	if (reason_code != OCSP_REVOKED_STATUS_NOSTATUS)
		ret = 2;
	else
		ret = 1;

err:
	free(tmp);

	ASN1_OBJECT_free(hold);
	ASN1_GENERALIZEDTIME_free(comp_time);
	ASN1_ENUMERATED_free(rtmp);
	ASN1_TIME_free(revDate);

	return ret;
}

int
old_entry_print(BIO * bp, ASN1_OBJECT * obj, ASN1_STRING * str)
{
	char buf[25], *pbuf, *p;
	int j;

	j = i2a_ASN1_OBJECT(bp, obj);
	pbuf = buf;
	for (j = 22 - j; j > 0; j--)
		*(pbuf++) = ' ';
	*(pbuf++) = ':';
	*(pbuf++) = '\0';
	BIO_puts(bp, buf);

	if (str->type == V_ASN1_PRINTABLESTRING)
		BIO_printf(bp, "PRINTABLE:'");
	else if (str->type == V_ASN1_T61STRING)
		BIO_printf(bp, "T61STRING:'");
	else if (str->type == V_ASN1_IA5STRING)
		BIO_printf(bp, "IA5STRING:'");
	else if (str->type == V_ASN1_UNIVERSALSTRING)
		BIO_printf(bp, "UNIVERSALSTRING:'");
	else
		BIO_printf(bp, "ASN.1 %2d:'", str->type);

	p = (char *) str->data;
	for (j = str->length; j > 0; j--) {
		if ((*p >= ' ') && (*p <= '~'))
			BIO_printf(bp, "%c", *p);
		else if (*p & 0x80)
			BIO_printf(bp, "\\0x%02X", *p);
		else if ((unsigned char) *p == 0xf7)
			BIO_printf(bp, "^?");
		else
			BIO_printf(bp, "^%c", *p + '@');
		p++;
	}
	BIO_printf(bp, "'\n");
	return 1;
}

int
unpack_revinfo(ASN1_TIME ** prevtm, int *preason, ASN1_OBJECT ** phold,
    ASN1_GENERALIZEDTIME ** pinvtm, const char *str)
{
	char *tmp = NULL;
	char *rtime_str, *reason_str = NULL, *arg_str = NULL, *p;
	int reason_code = -1;
	int ret = 0;
	unsigned int i;
	ASN1_OBJECT *hold = NULL;
	ASN1_GENERALIZEDTIME *comp_time = NULL;

	tmp = BUF_strdup(str);
	p = strchr(tmp, ',');
	rtime_str = tmp;

	if (p) {
		*p = '\0';
		p++;
		reason_str = p;
		p = strchr(p, ',');
		if (p) {
			*p = '\0';
			arg_str = p + 1;
		}
	}
	if (prevtm) {
		*prevtm = ASN1_UTCTIME_new();
		if (!ASN1_UTCTIME_set_string(*prevtm, rtime_str)) {
			BIO_printf(bio_err, "invalid revocation date %s\n",
			    rtime_str);
			goto err;
		}
	}
	if (reason_str) {
		for (i = 0; i < NUM_REASONS; i++) {
			if (!strcasecmp(reason_str, crl_reasons[i])) {
				reason_code = i;
				break;
			}
		}
		if (reason_code == OCSP_REVOKED_STATUS_NOSTATUS) {
			BIO_printf(bio_err, "invalid reason code %s\n",
			    reason_str);
			goto err;
		}
		if (reason_code == 7)
			reason_code = OCSP_REVOKED_STATUS_REMOVEFROMCRL;
		else if (reason_code == 8) {	/* Hold instruction */
			if (!arg_str) {
				BIO_printf(bio_err,
				    "missing hold instruction\n");
				goto err;
			}
			reason_code = OCSP_REVOKED_STATUS_CERTIFICATEHOLD;
			hold = OBJ_txt2obj(arg_str, 0);

			if (!hold) {
				BIO_printf(bio_err,
				    "invalid object identifier %s\n", arg_str);
				goto err;
			}
			if (phold)
				*phold = hold;
		} else if ((reason_code == 9) || (reason_code == 10)) {
			if (!arg_str) {
				BIO_printf(bio_err,
				    "missing compromised time\n");
				goto err;
			}
			comp_time = ASN1_GENERALIZEDTIME_new();
			if (!ASN1_GENERALIZEDTIME_set_string(comp_time,
			    arg_str)) {
				BIO_printf(bio_err,
				    "invalid compromised time %s\n", arg_str);
				goto err;
			}
			if (reason_code == 9)
				reason_code = OCSP_REVOKED_STATUS_KEYCOMPROMISE;
			else
				reason_code = OCSP_REVOKED_STATUS_CACOMPROMISE;
		}
	}
	if (preason)
		*preason = reason_code;
	if (pinvtm)
		*pinvtm = comp_time;
	else
		ASN1_GENERALIZEDTIME_free(comp_time);

	ret = 1;

err:
	free(tmp);

	if (!phold)
		ASN1_OBJECT_free(hold);
	if (!pinvtm)
		ASN1_GENERALIZEDTIME_free(comp_time);

	return ret;
}

static char *
bin2hex(unsigned char * data, size_t len)
{
	char *ret = NULL;
	char hex[] = "0123456789ABCDEF";
	int i;

	if ((ret = malloc(len * 2 + 1))) {
		for (i = 0; i < len; i++) {
			ret[i * 2 + 0] = hex[data[i] >> 4];
			ret[i * 2 + 1] = hex[data[i] & 0x0F];
		}
		ret[len * 2] = '\0';
	}
	return ret;
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/testrsa.h0000644000175000017500000007356612360020706017556 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

static unsigned char test512[] = {
	0x30, 0x82, 0x01, 0x3a, 0x02, 0x01, 0x00, 0x02, 0x41, 0x00,
	0xd6, 0x33, 0xb9, 0xc8, 0xfb, 0x4f, 0x3c, 0x7d, 0xc0, 0x01,
	0x86, 0xd0, 0xe7, 0xa0, 0x55, 0xf2, 0x95, 0x93, 0xcc, 0x4f,
	0xb7, 0x5b, 0x67, 0x5b, 0x94, 0x68, 0xc9, 0x34, 0x15, 0xde,
	0xa5, 0x2e, 0x1c, 0x33, 0xc2, 0x6e, 0xfc, 0x34, 0x5e, 0x71,
	0x13, 0xb7, 0xd6, 0xee, 0xd8, 0xa5, 0x65, 0x05, 0x72, 0x87,
	0xa8, 0xb0, 0x77, 0xfe, 0x57, 0xf5, 0xfc, 0x5f, 0x55, 0x83,
	0x87, 0xdd, 0x57, 0x49, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02,
	0x41, 0x00, 0xa7, 0xf7, 0x91, 0xc5, 0x0f, 0x84, 0x57, 0xdc,
	0x07, 0xf7, 0x6a, 0x7f, 0x60, 0x52, 0xb3, 0x72, 0xf1, 0x66,
	0x1f, 0x7d, 0x97, 0x3b, 0x9e, 0xb6, 0x0a, 0x8f, 0x8c, 0xcf,
	0x42, 0x23, 0x00, 0x04, 0xd4, 0x28, 0x0e, 0x1c, 0x90, 0xc4,
	0x11, 0x25, 0x25, 0xa5, 0x93, 0xa5, 0x2f, 0x70, 0x02, 0xdf,
	0x81, 0x9c, 0x49, 0x03, 0xa0, 0xf8, 0x6d, 0x54, 0x2e, 0x26,
	0xde, 0xaa, 0x85, 0x59, 0xa8, 0x31, 0x02, 0x21, 0x00, 0xeb,
	0x47, 0xd7, 0x3b, 0xf6, 0xc3, 0xdd, 0x5a, 0x46, 0xc5, 0xb9,
	0x2b, 0x9a, 0xa0, 0x09, 0x8f, 0xa6, 0xfb, 0xf3, 0x78, 0x7a,
	0x33, 0x70, 0x9d, 0x0f, 0x42, 0x6b, 0x13, 0x68, 0x24, 0xd3,
	0x15, 0x02, 0x21, 0x00, 0xe9, 0x10, 0xb0, 0xb3, 0x0d, 0xe2,
	0x82, 0x68, 0x77, 0x8a, 0x6e, 0x7c, 0xda, 0xbc, 0x3e, 0x53,
	0x83, 0xfb, 0xd6, 0x22, 0xe7, 0xb5, 0xae, 0x6e, 0x80, 0xda,
	0x00, 0x55, 0x97, 0xc1, 0xd0, 0x65, 0x02, 0x20, 0x4c, 0xf8,
	0x73, 0xb1, 0x6a, 0x49, 0x29, 0x61, 0x1f, 0x46, 0x10, 0x0d,
	0xf3, 0xc7, 0xe7, 0x58, 0xd7, 0x88, 0x15, 0x5e, 0x94, 0x9b,
	0xbf, 0x7b, 0xa2, 0x42, 0x58, 0x45, 0x41, 0x0c, 0xcb, 0x01,
	0x02, 0x20, 0x12, 0x11, 0xba, 0x31, 0x57, 0x9d, 0x3d, 0x11,
	0x0e, 0x5b, 0x8c, 0x2f, 0x5f, 0xe2, 0x02, 0x4f, 0x05, 0x47,
	0x8c, 0x15, 0x8e, 0xb3, 0x56, 0x3f, 0xb8, 0xfb, 0xad, 0xd4,
	0xf4, 0xfc, 0x10, 0xc5, 0x02, 0x20, 0x18, 0xa1, 0x29, 0x99,
	0x5b, 0xd9, 0xc8, 0xd4, 0xfc, 0x49, 0x7a, 0x2a, 0x21, 0x2c,
	0x49, 0xe4, 0x4f, 0xeb, 0xef, 0x51, 0xf1, 0xab, 0x6d, 0xfb,
	0x4b, 0x14, 0xe9, 0x4b, 0x52, 0xb5, 0x82, 0x2c,
};

static unsigned char test1024[] = {
	0x30, 0x82, 0x02, 0x5c, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81,
	0x00, 0xdc, 0x98, 0x43, 0xe8, 0x3d, 0x43, 0x5b, 0xe4, 0x05,
	0xcd, 0xd0, 0xa9, 0x3e, 0xcb, 0x83, 0x75, 0xf6, 0xb5, 0xa5,
	0x9f, 0x6b, 0xe9, 0x34, 0x41, 0x29, 0x18, 0xfa, 0x6a, 0x55,
	0x4d, 0x70, 0xfc, 0xec, 0xae, 0x87, 0x38, 0x0a, 0x20, 0xa9,
	0xc0, 0x45, 0x77, 0x6e, 0x57, 0x60, 0x57, 0xf4, 0xed, 0x96,
	0x22, 0xcb, 0x8f, 0xe1, 0x33, 0x3a, 0x17, 0x1f, 0xed, 0x37,
	0xa5, 0x6f, 0xeb, 0xa6, 0xbc, 0x12, 0x80, 0x1d, 0x53, 0xbd,
	0x70, 0xeb, 0x21, 0x76, 0x3e, 0xc9, 0x2f, 0x1a, 0x45, 0x24,
	0x82, 0xff, 0xcd, 0x59, 0x32, 0x06, 0x2e, 0x12, 0x3b, 0x23,
	0x78, 0xed, 0x12, 0x3d, 0xe0, 0x8d, 0xf9, 0x67, 0x4f, 0x37,
	0x4e, 0x47, 0x02, 0x4c, 0x2d, 0xc0, 0x4f, 0x1f, 0xb3, 0x94,
	0xe1, 0x41, 0x2e, 0x2d, 0x90, 0x10, 0xfc, 0x82, 0x91, 0x8b,
	0x0f, 0x22, 0xd4, 0xf2, 0xfc, 0x2c, 0xab, 0x53, 0x55, 0x02,
	0x03, 0x01, 0x00, 0x01, 0x02, 0x81, 0x80, 0x2b, 0xcc, 0x3f,
	0x8f, 0x58, 0xba, 0x8b, 0x00, 0x16, 0xf6, 0xea, 0x3a, 0xf0,
	0x30, 0xd0, 0x05, 0x17, 0xda, 0xb0, 0xeb, 0x9a, 0x2d, 0x4f,
	0x26, 0xb0, 0xd6, 0x38, 0xc1, 0xeb, 0xf5, 0xd8, 0x3d, 0x1f,
	0x70, 0xf7, 0x7f, 0xf4, 0xe2, 0xcf, 0x51, 0x51, 0x79, 0x88,
	0xfa, 0xe8, 0x32, 0x0e, 0x7b, 0x2d, 0x97, 0xf2, 0xfa, 0xba,
	0x27, 0xc5, 0x9c, 0xd9, 0xc5, 0xeb, 0x8a, 0x79, 0x52, 0x3c,
	0x64, 0x34, 0x7d, 0xc2, 0xcf, 0x28, 0xc7, 0x4e, 0xd5, 0x43,
	0x0b, 0xd1, 0xa6, 0xca, 0x6d, 0x03, 0x2d, 0x72, 0x23, 0xbc,
	0x6d, 0x05, 0xfa, 0x16, 0x09, 0x2f, 0x2e, 0x5c, 0xb6, 0xee,
	0x74, 0xdd, 0xd2, 0x48, 0x8e, 0x36, 0x0c, 0x06, 0x3d, 0x4d,
	0xe5, 0x10, 0x82, 0xeb, 0x6a, 0xf3, 0x4b, 0x9f, 0xd6, 0xed,
	0x11, 0xb1, 0x6e, 0xec, 0xf4, 0xfe, 0x8e, 0x75, 0x94, 0x20,
	0x2f, 0xcb, 0xac, 0x46, 0xf1, 0x02, 0x41, 0x00, 0xf9, 0x8c,
	0xa3, 0x85, 0xb1, 0xdd, 0x29, 0xaf, 0x65, 0xc1, 0x33, 0xf3,
	0x95, 0xc5, 0x52, 0x68, 0x0b, 0xd4, 0xf1, 0xe5, 0x0e, 0x02,
	0x9f, 0x4f, 0xfa, 0x77, 0xdc, 0x46, 0x9e, 0xc7, 0xa6, 0xe4,
	0x16, 0x29, 0xda, 0xb0, 0x07, 0xcf, 0x5b, 0xa9, 0x12, 0x8a,
	0xdd, 0x63, 0x0a, 0xde, 0x2e, 0x8c, 0x66, 0x8b, 0x8c, 0xdc,
	0x19, 0xa3, 0x7e, 0xf4, 0x3b, 0xd0, 0x1a, 0x8c, 0xa4, 0xc2,
	0xe1, 0xd3, 0x02, 0x41, 0x00, 0xe2, 0x4c, 0x05, 0xf2, 0x04,
	0x86, 0x4e, 0x61, 0x43, 0xdb, 0xb0, 0xb9, 0x96, 0x86, 0x52,
	0x2c, 0xca, 0x8d, 0x7b, 0xab, 0x0b, 0x13, 0x0d, 0x7e, 0x38,
	0x5b, 0xe2, 0x2e, 0x7b, 0x0e, 0xe7, 0x19, 0x99, 0x38, 0xe7,
	0xf2, 0x21, 0xbd, 0x85, 0x85, 0xe3, 0xfd, 0x28, 0x77, 0x20,
	0x31, 0x71, 0x2c, 0xd0, 0xff, 0xfb, 0x2e, 0xaf, 0x85, 0xb4,
	0x86, 0xca, 0xf3, 0xbb, 0xca, 0xaa, 0x0f, 0x95, 0x37, 0x02,
	0x40, 0x0e, 0x41, 0x9a, 0x95, 0xe8, 0xb3, 0x59, 0xce, 0x4b,
	0x61, 0xde, 0x35, 0xec, 0x38, 0x79, 0x9c, 0xb8, 0x10, 0x52,
	0x41, 0x63, 0xab, 0x82, 0xae, 0x6f, 0x00, 0xa9, 0xf4, 0xde,
	0xdd, 0x49, 0x0b, 0x7e, 0xb8, 0xa5, 0x65, 0xa9, 0x0c, 0x8f,
	0x8f, 0xf9, 0x1f, 0x35, 0xc6, 0x92, 0xb8, 0x5e, 0xb0, 0x66,
	0xab, 0x52, 0x40, 0xc0, 0xb6, 0x36, 0x6a, 0x7d, 0x80, 0x46,
	0x04, 0x02, 0xe5, 0x9f, 0x41, 0x02, 0x41, 0x00, 0xc0, 0xad,
	0xcc, 0x4e, 0x21, 0xee, 0x1d, 0x24, 0x91, 0xfb, 0xa7, 0x80,
	0x8d, 0x9a, 0xb6, 0xb3, 0x2e, 0x8f, 0xc2, 0xe1, 0x82, 0xdf,
	0x69, 0x18, 0xb4, 0x71, 0xff, 0xa6, 0x65, 0xde, 0xed, 0x84,
	0x8d, 0x42, 0xb7, 0xb3, 0x21, 0x69, 0x56, 0x1c, 0x07, 0x60,
	0x51, 0x29, 0x04, 0xff, 0x34, 0x06, 0xdd, 0xb9, 0x67, 0x2c,
	0x7c, 0x04, 0x93, 0x0e, 0x46, 0x15, 0xbb, 0x2a, 0xb7, 0x1b,
	0xe7, 0x87, 0x02, 0x40, 0x78, 0xda, 0x5d, 0x07, 0x51, 0x0c,
	0x16, 0x7a, 0x9f, 0x29, 0x20, 0x84, 0x0d, 0x42, 0xfa, 0xd7,
	0x00, 0xd8, 0x77, 0x7e, 0xb0, 0xb0, 0x6b, 0xd6, 0x5b, 0x53,
	0xb8, 0x9b, 0x7a, 0xcd, 0xc7, 0x2b, 0xb8, 0x6a, 0x63, 0xa9,
	0xfb, 0x6f, 0xa4, 0x72, 0xbf, 0x4c, 0x5d, 0x00, 0x14, 0xba,
	0xfa, 0x59, 0x88, 0xed, 0xe4, 0xe0, 0x8c, 0xa2, 0xec, 0x14,
	0x7e, 0x2d, 0xe2, 0xf0, 0x46, 0x49, 0x95, 0x45,
};

static unsigned char test2048[] = {
	0x30, 0x82, 0x04, 0xa3, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01,
	0x01, 0x00, 0xc0, 0xc0, 0xce, 0x3e, 0x3c, 0x53, 0x67, 0x3f,
	0x4f, 0xc5, 0x2f, 0xa4, 0xc2, 0x5a, 0x2f, 0x58, 0xfd, 0x27,
	0x52, 0x6a, 0xe8, 0xcf, 0x4a, 0x73, 0x47, 0x8d, 0x25, 0x0f,
	0x5f, 0x03, 0x26, 0x78, 0xef, 0xf0, 0x22, 0x12, 0xd3, 0xde,
	0x47, 0xb2, 0x1c, 0x0b, 0x38, 0x63, 0x1a, 0x6c, 0x85, 0x7a,
	0x80, 0xc6, 0x8f, 0xa0, 0x41, 0xaf, 0x62, 0xc4, 0x67, 0x32,
	0x88, 0xf8, 0xa6, 0x9c, 0xf5, 0x23, 0x1d, 0xe4, 0xac, 0x3f,
	0x29, 0xf9, 0xec, 0xe1, 0x8b, 0x26, 0x03, 0x2c, 0xb2, 0xab,
	0xf3, 0x7d, 0xb5, 0xca, 0x49, 0xc0, 0x8f, 0x1c, 0xdf, 0x33,
	0x3a, 0x60, 0xda, 0x3c, 0xb0, 0x16, 0xf8, 0xa9, 0x12, 0x8f,
	0x64, 0xac, 0x23, 0x0c, 0x69, 0x64, 0x97, 0x5d, 0x99, 0xd4,
	0x09, 0x83, 0x9b, 0x61, 0xd3, 0xac, 0xf0, 0xde, 0xdd, 0x5e,
	0x9f, 0x44, 0x94, 0xdb, 0x3a, 0x4d, 0x97, 0xe8, 0x52, 0x29,
	0xf7, 0xdb, 0x94, 0x07, 0x45, 0x90, 0x78, 0x1e, 0x31, 0x0b,
	0x80, 0xf7, 0x57, 0xad, 0x1c, 0x79, 0xc5, 0xcb, 0x32, 0xb0,
	0xce, 0xcd, 0x74, 0xb3, 0xe2, 0x94, 0xc5, 0x78, 0x2f, 0x34,
	0x1a, 0x45, 0xf7, 0x8c, 0x52, 0xa5, 0xbc, 0x8d, 0xec, 0xd1,
	0x2f, 0x31, 0x3b, 0xf0, 0x49, 0x59, 0x5e, 0x88, 0x9d, 0x15,
	0x92, 0x35, 0x32, 0xc1, 0xe7, 0x61, 0xec, 0x50, 0x48, 0x7c,
	0xba, 0x05, 0xf9, 0xf8, 0xf8, 0xa7, 0x8c, 0x83, 0xe8, 0x66,
	0x5b, 0xeb, 0xfe, 0xd8, 0x4f, 0xdd, 0x6d, 0x36, 0xc0, 0xb2,
	0x90, 0x0f, 0xb8, 0x52, 0xf9, 0x04, 0x9b, 0x40, 0x2c, 0x27,
	0xd6, 0x36, 0x8e, 0xc2, 0x1b, 0x44, 0xf3, 0x92, 0xd5, 0x15,
	0x9e, 0x9a, 0xbc, 0xf3, 0x7d, 0x03, 0xd7, 0x02, 0x14, 0x20,
	0xe9, 0x10, 0x92, 0xfd, 0xf9, 0xfc, 0x8f, 0xe5, 0x18, 0xe1,
	0x95, 0xcc, 0x9e, 0x60, 0xa6, 0xfa, 0x38, 0x4d, 0x02, 0x03,
	0x01, 0x00, 0x01, 0x02, 0x82, 0x01, 0x00, 0x00, 0xc3, 0xc3,
	0x0d, 0xb4, 0x27, 0x90, 0x8d, 0x4b, 0xbf, 0xb8, 0x84, 0xaa,
	0xd0, 0xb8, 0xc7, 0x5d, 0x99, 0xbe, 0x55, 0xf6, 0x3e, 0x7c,
	0x49, 0x20, 0xcb, 0x8a, 0x8e, 0x19, 0x0e, 0x66, 0x24, 0xac,
	0xaf, 0x03, 0x33, 0x97, 0xeb, 0x95, 0xd5, 0x3b, 0x0f, 0x40,
	0x56, 0x04, 0x50, 0xd1, 0xe6, 0xbe, 0x84, 0x0b, 0x25, 0xd3,
	0x9c, 0xe2, 0x83, 0x6c, 0xf5, 0x62, 0x5d, 0xba, 0x2b, 0x7d,
	0x3d, 0x7a, 0x6c, 0xe1, 0xd2, 0x0e, 0x54, 0x93, 0x80, 0x01,
	0x91, 0x51, 0x09, 0xe8, 0x5b, 0x8e, 0x47, 0xbd, 0x64, 0xe4,
	0x0e, 0x03, 0x83, 0x55, 0xcf, 0x5a, 0x37, 0xf0, 0x25, 0xb5,
	0x7d, 0x21, 0xd7, 0x69, 0xdf, 0x6f, 0xc2, 0xcf, 0x10, 0xc9,
	0x8a, 0x40, 0x9f, 0x7a, 0x70, 0xc0, 0xe8, 0xe8, 0xc0, 0xe6,
	0x9a, 0x15, 0x0a, 0x8d, 0x4e, 0x46, 0xcb, 0x7a, 0xdb, 0xb3,
	0xcb, 0x83, 0x02, 0xc4, 0xf0, 0xab, 0xeb, 0x02, 0x01, 0x0e,
	0x23, 0xfc, 0x1d, 0xc4, 0xbd, 0xd4, 0xaa, 0x5d, 0x31, 0x46,
	0x99, 0xce, 0x9e, 0xf8, 0x04, 0x75, 0x10, 0x67, 0xc4, 0x53,
	0x47, 0x44, 0xfa, 0xc2, 0x25, 0x73, 0x7e, 0xd0, 0x8e, 0x59,
	0xd1, 0xb2, 0x5a, 0xf4, 0xc7, 0x18, 0x92, 0x2f, 0x39, 0xab,
	0xcd, 0xa3, 0xb5, 0xc2, 0xb9, 0xc7, 0xb9, 0x1b, 0x9f, 0x48,
	0xfa, 0x13, 0xc6, 0x98, 0x4d, 0xca, 0x84, 0x9c, 0x06, 0xca,
	0xe7, 0x89, 0x01, 0x04, 0xc4, 0x6c, 0xfd, 0x29, 0x59, 0x35,
	0xe7, 0xf3, 0xdd, 0xce, 0x64, 0x59, 0xbf, 0x21, 0x13, 0xa9,
	0x9f, 0x0e, 0xc5, 0xff, 0xbd, 0x33, 0x00, 0xec, 0xac, 0x6b,
	0x11, 0xef, 0x51, 0x5e, 0xad, 0x07, 0x15, 0xde, 0xb8, 0x5f,
	0xc6, 0xb9, 0xa3, 0x22, 0x65, 0x46, 0x83, 0x14, 0xdf, 0xd0,
	0xf1, 0x44, 0x8a, 0xe1, 0x9c, 0x23, 0x33, 0xb4, 0x97, 0x33,
	0xe6, 0x6b, 0x81, 0x02, 0x81, 0x81, 0x00, 0xec, 0x12, 0xa7,
	0x59, 0x74, 0x6a, 0xde, 0x3e, 0xad, 0xd8, 0x36, 0x80, 0x50,
	0xa2, 0xd5, 0x21, 0x81, 0x07, 0xf1, 0xd0, 0x91, 0xf2, 0x6c,
	0x12, 0x2f, 0x9d, 0x1a, 0x26, 0xf8, 0x30, 0x65, 0xdf, 0xe8,
	0xc0, 0x9b, 0x6a, 0x30, 0x98, 0x82, 0x87, 0xec, 0xa2, 0x56,
	0x87, 0x62, 0x6f, 0xe7, 0x9f, 0xf6, 0x56, 0xe6, 0x71, 0x8f,
	0x49, 0x86, 0x93, 0x5a, 0x4d, 0x34, 0x58, 0xfe, 0xd9, 0x04,
	0x13, 0xaf, 0x79, 0xb7, 0xad, 0x11, 0xd1, 0x30, 0x9a, 0x14,
	0x06, 0xa0, 0xfa, 0xb7, 0x55, 0xdc, 0x6c, 0x5a, 0x4c, 0x2c,
	0x59, 0x56, 0xf6, 0xe8, 0x9d, 0xaf, 0x0a, 0x78, 0x99, 0x06,
	0x06, 0x9e, 0xe7, 0x9c, 0x51, 0x55, 0x43, 0xfc, 0x3b, 0x6c,
	0x0b, 0xbf, 0x2d, 0x41, 0xa7, 0xaf, 0xb7, 0xe0, 0xe8, 0x28,
	0x18, 0xb4, 0x13, 0xd1, 0xe6, 0x97, 0xd0, 0x9f, 0x6a, 0x80,
	0xca, 0xdd, 0x1a, 0x7e, 0x15, 0x02, 0x81, 0x81, 0x00, 0xd1,
	0x06, 0x0c, 0x1f, 0xe3, 0xd0, 0xab, 0xd6, 0xca, 0x7c, 0xbc,
	0x7d, 0x13, 0x35, 0xce, 0x27, 0xcd, 0xd8, 0x49, 0x51, 0x63,
	0x64, 0x0f, 0xca, 0x06, 0x12, 0xfc, 0x07, 0x3e, 0xaf, 0x61,
	0x6d, 0xe2, 0x53, 0x39, 0x27, 0xae, 0xc3, 0x11, 0x9e, 0x94,
	0x01, 0x4f, 0xe3, 0xf3, 0x67, 0xf9, 0x77, 0xf9, 0xe7, 0x95,
	0x3a, 0x6f, 0xe2, 0x20, 0x73, 0x3e, 0xa4, 0x7a, 0x28, 0xd4,
	0x61, 0x97, 0xf6, 0x17, 0xa0, 0x23, 0x10, 0x2b, 0xce, 0x84,
	0x57, 0x7e, 0x25, 0x1f, 0xf4, 0xa8, 0x54, 0xd2, 0x65, 0x94,
	0xcc, 0x95, 0x0a, 0xab, 0x30, 0xc1, 0x59, 0x1f, 0x61, 0x8e,
	0xb9, 0x6b, 0xd7, 0x4e, 0xb9, 0x83, 0x43, 0x79, 0x85, 0x11,
	0xbc, 0x0f, 0xae, 0x25, 0x20, 0x05, 0xbc, 0xd2, 0x48, 0xa1,
	0x68, 0x09, 0x84, 0xf6, 0x12, 0x9a, 0x66, 0xb9, 0x2b, 0xbb,
	0x76, 0x03, 0x17, 0x46, 0x4e, 0x97, 0x59, 0x02, 0x81, 0x80,
	0x09, 0x4c, 0xfa, 0xd6, 0xe5, 0x65, 0x48, 0x78, 0x43, 0xb5,
	0x1f, 0x00, 0x93, 0x2c, 0xb7, 0x24, 0xe8, 0xc6, 0x7d, 0x5a,
	0x70, 0x45, 0x92, 0xc8, 0x6c, 0xa3, 0xcd, 0xe1, 0xf7, 0x29,
	0x40, 0xfa, 0x3f, 0x5b, 0x47, 0x44, 0x39, 0xc1, 0xe8, 0x72,
	0x9e, 0x7a, 0x0e, 0xda, 0xaa, 0xa0, 0x2a, 0x09, 0xfd, 0x54,
	0x93, 0x23, 0xaa, 0x37, 0x85, 0x5b, 0xcc, 0xd4, 0xf9, 0xd8,
	0xff, 0xc1, 0x61, 0x0d, 0xbd, 0x7e, 0x18, 0x24, 0x73, 0x6d,
	0x40, 0x72, 0xf1, 0x93, 0x09, 0x48, 0x97, 0x6c, 0x84, 0x90,
	0xa8, 0x46, 0x14, 0x01, 0x39, 0x11, 0xe5, 0x3c, 0x41, 0x27,
	0x32, 0x75, 0x24, 0xed, 0xa1, 0xd9, 0x12, 0x29, 0x8a, 0x28,
	0x71, 0x89, 0x8d, 0xca, 0x30, 0xb0, 0x01, 0xc4, 0x2f, 0x82,
	0x19, 0x14, 0x4c, 0x70, 0x1c, 0xb8, 0x23, 0x2e, 0xe8, 0x90,
	0x49, 0x97, 0x92, 0x97, 0x6b, 0x7a, 0x9d, 0xb9, 0x02, 0x81,
	0x80, 0x0f, 0x0e, 0xa1, 0x76, 0xf6, 0xa1, 0x44, 0x8f, 0xaf,
	0x7c, 0x76, 0xd3, 0x87, 0xbb, 0xbb, 0x83, 0x10, 0x88, 0x01,
	0x18, 0x14, 0xd1, 0xd3, 0x75, 0x59, 0x24, 0xaa, 0xf5, 0x16,
	0xa5, 0xe9, 0x9d, 0xd1, 0xcc, 0xee, 0xf4, 0x15, 0xd9, 0xc5,
	0x7e, 0x27, 0xe9, 0x44, 0x49, 0x06, 0x72, 0xb9, 0xfc, 0xd3,
	0x8a, 0xc4, 0x2c, 0x36, 0x7d, 0x12, 0x9b, 0x5a, 0xaa, 0xdc,
	0x85, 0xee, 0x6e, 0xad, 0x54, 0xb3, 0xf4, 0xfc, 0x31, 0xa1,
	0x06, 0x3a, 0x70, 0x57, 0x0c, 0xf3, 0x95, 0x5b, 0x3e, 0xe8,
	0xfd, 0x1a, 0x4f, 0xf6, 0x78, 0x93, 0x46, 0x6a, 0xd7, 0x31,
	0xb4, 0x84, 0x64, 0x85, 0x09, 0x38, 0x89, 0x92, 0x94, 0x1c,
	0xbf, 0xe2, 0x3c, 0x2a, 0xe0, 0xff, 0x99, 0xa3, 0xf0, 0x2b,
	0x31, 0xc2, 0x36, 0xcd, 0x60, 0xbf, 0x9d, 0x2d, 0x74, 0x32,
	0xe8, 0x9c, 0x93, 0x6e, 0xbb, 0x91, 0x7b, 0xfd, 0xd9, 0x02,
	0x81, 0x81, 0x00, 0xa2, 0x71, 0x25, 0x38, 0xeb, 0x2a, 0xe9,
	0x37, 0xcd, 0xfe, 0x44, 0xce, 0x90, 0x3f, 0x52, 0x87, 0x84,
	0x52, 0x1b, 0xae, 0x8d, 0x22, 0x94, 0xce, 0x38, 0xe6, 0x04,
	0x88, 0x76, 0x85, 0x9a, 0xd3, 0x14, 0x09, 0xe5, 0x69, 0x9a,
	0xff, 0x58, 0x92, 0x02, 0x6a, 0x7d, 0x7c, 0x1e, 0x2c, 0xfd,
	0xa8, 0xca, 0x32, 0x14, 0x4f, 0x0d, 0x84, 0x0d, 0x37, 0x43,
	0xbf, 0xe4, 0x5d, 0x12, 0xc8, 0x24, 0x91, 0x27, 0x8d, 0x46,
	0xd9, 0x54, 0x53, 0xe7, 0x62, 0x71, 0xa8, 0x2b, 0x71, 0x41,
	0x8d, 0x75, 0xf8, 0x3a, 0xa0, 0x61, 0x29, 0x46, 0xa6, 0xe5,
	0x82, 0xfa, 0x3a, 0xd9, 0x08, 0xfa, 0xfc, 0x63, 0xfd, 0x6b,
	0x30, 0xbc, 0xf4, 0x4e, 0x9e, 0x8c, 0x25, 0x0c, 0xb6, 0x55,
	0xe7, 0x3c, 0xd4, 0x4e, 0x0b, 0xfd, 0x8b, 0xc3, 0x0e, 0x1d,
	0x9c, 0x44, 0x57, 0x8f, 0x1f, 0x86, 0xf7, 0xd5, 0x1b, 0xe4,
	0x95,
};

static unsigned char test4096[] = {
	0x30, 0x82, 0x09, 0x29, 0x02, 0x01, 0x00, 0x02, 0x82, 0x02,
	0x01, 0x00, 0xc0, 0x71, 0xac, 0x1a, 0x13, 0x88, 0x82, 0x43,
	0x3b, 0x51, 0x57, 0x71, 0x8d, 0xb6, 0x2b, 0x82, 0x65, 0x21,
	0x53, 0x5f, 0x28, 0x29, 0x4f, 0x8d, 0x7c, 0x8a, 0xb9, 0x44,
	0xb3, 0x28, 0x41, 0x4f, 0xd3, 0xfa, 0x6a, 0xf8, 0xb9, 0x28,
	0x50, 0x39, 0x67, 0x53, 0x2c, 0x3c, 0xd7, 0xcb, 0x96, 0x41,
	0x40, 0x32, 0xbb, 0xeb, 0x70, 0xae, 0x1f, 0xb0, 0x65, 0xf7,
	0x3a, 0xd9, 0x22, 0xfd, 0x10, 0xae, 0xbd, 0x02, 0xe2, 0xdd,
	0xf3, 0xc2, 0x79, 0x3c, 0xc6, 0xfc, 0x75, 0xbb, 0xaf, 0x4e,
	0x3a, 0x36, 0xc2, 0x4f, 0xea, 0x25, 0xdf, 0x13, 0x16, 0x4b,
	0x20, 0xfe, 0x4b, 0x69, 0x16, 0xc4, 0x7f, 0x1a, 0x43, 0xa6,
	0x17, 0x1b, 0xb9, 0x0a, 0xf3, 0x09, 0x86, 0x28, 0x89, 0xcf,
	0x2c, 0xd0, 0xd4, 0x81, 0xaf, 0xc6, 0x6d, 0xe6, 0x21, 0x8d,
	0xee, 0xef, 0xea, 0xdc, 0xb7, 0xc6, 0x3b, 0x63, 0x9f, 0x0e,
	0xad, 0x89, 0x78, 0x23, 0x18, 0xbf, 0x70, 0x7e, 0x84, 0xe0,
	0x37, 0xec, 0xdb, 0x8e, 0x9c, 0x3e, 0x6a, 0x19, 0xcc, 0x99,
	0x72, 0xe6, 0xb5, 0x7d, 0x6d, 0xfa, 0xe5, 0xd3, 0xe4, 0x90,
	0xb5, 0xb2, 0xb2, 0x12, 0x70, 0x4e, 0xca, 0xf8, 0x10, 0xf8,
	0xa3, 0x14, 0xc2, 0x48, 0x19, 0xeb, 0x60, 0x99, 0xbb, 0x2a,
	0x1f, 0xb1, 0x7a, 0xb1, 0x3d, 0x24, 0xfb, 0xa0, 0x29, 0xda,
	0xbd, 0x1b, 0xd7, 0xa4, 0xbf, 0xef, 0x60, 0x2d, 0x22, 0xca,
	0x65, 0x98, 0xf1, 0xc4, 0xe1, 0xc9, 0x02, 0x6b, 0x16, 0x28,
	0x2f, 0xa1, 0xaa, 0x79, 0x00, 0xda, 0xdc, 0x7c, 0x43, 0xf7,
	0x42, 0x3c, 0xa0, 0xef, 0x68, 0xf7, 0xdf, 0xb9, 0x69, 0xfb,
	0x8e, 0x01, 0xed, 0x01, 0x42, 0xb5, 0x4e, 0x57, 0xa6, 0x26,
	0xb8, 0xd0, 0x7b, 0x56, 0x6d, 0x03, 0xc6, 0x40, 0x8c, 0x8c,
	0x2a, 0x55, 0xd7, 0x9c, 0x35, 0x00, 0x94, 0x93, 0xec, 0x03,
	0xeb, 0x22, 0xef, 0x77, 0xbb, 0x79, 0x13, 0x3f, 0x15, 0xa1,
	0x8f, 0xca, 0xdf, 0xfd, 0xd3, 0xb8, 0xe1, 0xd4, 0xcc, 0x09,
	0x3f, 0x3c, 0x2c, 0xdb, 0xd1, 0x49, 0x7f, 0x38, 0x07, 0x83,
	0x6d, 0xeb, 0x08, 0x66, 0xe9, 0x06, 0x44, 0x12, 0xac, 0x95,
	0x22, 0x90, 0x23, 0x67, 0xd4, 0x08, 0xcc, 0xf4, 0xb7, 0xdc,
	0xcc, 0x87, 0xd4, 0xac, 0x69, 0x35, 0x4c, 0xb5, 0x39, 0x36,
	0xcd, 0xa4, 0xd2, 0x95, 0xca, 0x0d, 0xc5, 0xda, 0xc2, 0xc5,
	0x22, 0x32, 0x28, 0x08, 0xe3, 0xd2, 0x8b, 0x38, 0x30, 0xdc,
	0x8c, 0x75, 0x4f, 0x6a, 0xec, 0x7a, 0xac, 0x16, 0x3e, 0xa8,
	0xd4, 0x6a, 0x45, 0xe1, 0xa8, 0x4f, 0x2e, 0x80, 0x34, 0xaa,
	0x54, 0x1b, 0x02, 0x95, 0x7d, 0x8a, 0x6d, 0xcc, 0x79, 0xca,
	0xf2, 0xa4, 0x2e, 0x8d, 0xfb, 0xfe, 0x15, 0x51, 0x10, 0x0e,
	0x4d, 0x88, 0xb1, 0xc7, 0xf4, 0x79, 0xdb, 0xf0, 0xb4, 0x56,
	0x44, 0x37, 0xca, 0x5a, 0xc1, 0x8c, 0x48, 0xac, 0xae, 0x48,
	0x80, 0x83, 0x01, 0x3f, 0xde, 0xd9, 0xd3, 0x2c, 0x51, 0x46,
	0xb1, 0x41, 0xb6, 0xc6, 0x91, 0x72, 0xf9, 0x83, 0x55, 0x1b,
	0x8c, 0xba, 0xf3, 0x73, 0xe5, 0x2c, 0x74, 0x50, 0x3a, 0xbe,
	0xc5, 0x2f, 0xa7, 0xb2, 0x6d, 0x8c, 0x9e, 0x13, 0x77, 0xa3,
	0x13, 0xcd, 0x6d, 0x8c, 0x45, 0xe1, 0xfc, 0x0b, 0xb7, 0x69,
	0xe9, 0x27, 0xbc, 0x65, 0xc3, 0xfa, 0x9b, 0xd0, 0xef, 0xfe,
	0xe8, 0x1f, 0xb3, 0x5e, 0x34, 0xf4, 0x8c, 0xea, 0xfc, 0xd3,
	0x81, 0xbf, 0x3d, 0x30, 0xb2, 0xb4, 0x01, 0xe8, 0x43, 0x0f,
	0xba, 0x02, 0x23, 0x42, 0x76, 0x82, 0x31, 0x73, 0x91, 0xed,
	0x07, 0x46, 0x61, 0x0d, 0x39, 0x83, 0x40, 0xce, 0x7a, 0xd4,
	0xdb, 0x80, 0x2c, 0x1f, 0x0d, 0xd1, 0x34, 0xd4, 0x92, 0xe3,
	0xd4, 0xf1, 0xc2, 0x01, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02,
	0x82, 0x02, 0x01, 0x00, 0x97, 0x6c, 0xda, 0x6e, 0xea, 0x4f,
	0xcf, 0xaf, 0xf7, 0x4c, 0xd9, 0xf1, 0x90, 0x00, 0x77, 0xdb,
	0xf2, 0x97, 0x76, 0x72, 0xb9, 0xb7, 0x47, 0xd1, 0x9c, 0xdd,
	0xcb, 0x4a, 0x33, 0x6e, 0xc9, 0x75, 0x76, 0xe6, 0xe4, 0xa5,
	0x31, 0x8c, 0x77, 0x13, 0xb4, 0x29, 0xcd, 0xf5, 0x52, 0x17,
	0xef, 0xf3, 0x08, 0x00, 0xe3, 0xbd, 0x2e, 0xbc, 0xd4, 0x52,
	0x88, 0xe9, 0x30, 0x75, 0x0b, 0x02, 0xf5, 0xcd, 0x89, 0x0c,
	0x6c, 0x57, 0x19, 0x27, 0x3d, 0x1e, 0x85, 0xb4, 0xc1, 0x2f,
	0x1d, 0x92, 0x00, 0x5c, 0x76, 0x29, 0x4b, 0xa4, 0xe1, 0x12,
	0xb3, 0xc8, 0x09, 0xfe, 0x0e, 0x78, 0x72, 0x61, 0xcb, 0x61,
	0x6f, 0x39, 0x91, 0x95, 0x4e, 0xd5, 0x3e, 0xc7, 0x8f, 0xb8,
	0xf6, 0x36, 0xfe, 0x9c, 0x93, 0x9a, 0x38, 0x25, 0x7a, 0xf4,
	0x4a, 0x12, 0xd4, 0xa0, 0x13, 0xbd, 0xf9, 0x1d, 0x12, 0x3e,
	0x21, 0x39, 0xfb, 0x72, 0xe0, 0x05, 0x3d, 0xc3, 0xe5, 0x50,
	0xa8, 0x5d, 0x85, 0xa3, 0xea, 0x5f, 0x1c, 0xb2, 0x3f, 0xea,
	0x6d, 0x03, 0x91, 0x55, 0xd8, 0x19, 0x0a, 0x21, 0x12, 0x16,
	0xd9, 0x12, 0xc4, 0xe6, 0x07, 0x18, 0x5b, 0x26, 0xa4, 0xae,
	0xed, 0x2b, 0xb7, 0xa6, 0xed, 0xf8, 0xad, 0xec, 0x77, 0xe6,
	0x7f, 0x4f, 0x76, 0x00, 0xc0, 0xfa, 0x15, 0x92, 0xb4, 0x2c,
	0x22, 0xc2, 0xeb, 0x6a, 0xad, 0x14, 0x05, 0xb2, 0xe5, 0x8a,
	0x9e, 0x85, 0x83, 0xcc, 0x04, 0xf1, 0x56, 0x78, 0x44, 0x5e,
	0xde, 0xe0, 0x60, 0x1a, 0x65, 0x79, 0x31, 0x23, 0x05, 0xbb,
	0x01, 0xff, 0xdd, 0x2e, 0xb7, 0xb3, 0xaa, 0x74, 0xe0, 0xa5,
	0x94, 0xaf, 0x4b, 0xde, 0x58, 0x0f, 0x55, 0xde, 0x33, 0xf6,
	0xe3, 0xd6, 0x34, 0x36, 0x57, 0xd6, 0x79, 0x91, 0x2e, 0xbe,
	0x3b, 0xd9, 0x4e, 0xb6, 0x9d, 0x21, 0x5c, 0xd3, 0x48, 0x14,
	0x7f, 0x4a, 0xc4, 0x60, 0xa9, 0x29, 0xf8, 0x53, 0x7f, 0x88,
	0x11, 0x2d, 0xb5, 0xc5, 0x2d, 0x6f, 0xee, 0x85, 0x0b, 0xf7,
	0x8d, 0x9a, 0xbe, 0xb0, 0x42, 0xf2, 0x2e, 0x71, 0xaf, 0x19,
	0x31, 0x6d, 0xec, 0xcd, 0x6f, 0x2b, 0x23, 0xdf, 0xb4, 0x40,
	0xaf, 0x2c, 0x0a, 0xc3, 0x1b, 0x7d, 0x7d, 0x03, 0x1d, 0x4b,
	0xf3, 0xb5, 0xe0, 0x85, 0xd8, 0xdf, 0x91, 0x6b, 0x0a, 0x69,
	0xf7, 0xf2, 0x69, 0x66, 0x5b, 0xf1, 0xcf, 0x46, 0x7d, 0xe9,
	0x70, 0xfa, 0x6d, 0x7e, 0x75, 0x4e, 0xa9, 0x77, 0xe6, 0x8c,
	0x02, 0xf7, 0x14, 0x4d, 0xa5, 0x41, 0x8f, 0x3f, 0xc1, 0x62,
	0x1e, 0x71, 0x5e, 0x38, 0xb4, 0xd6, 0xe6, 0xe1, 0x4b, 0xc2,
	0x2c, 0x30, 0x83, 0x81, 0x6f, 0x49, 0x2e, 0x96, 0xe6, 0xc9,
	0x9a, 0xf7, 0x5d, 0x09, 0xa0, 0x55, 0x02, 0xa5, 0x3a, 0x25,
	0x23, 0xd0, 0x92, 0xc3, 0xa3, 0xe3, 0x0e, 0x12, 0x2f, 0x4d,
	0xef, 0xf3, 0x55, 0x5a, 0xbe, 0xe6, 0x19, 0x86, 0x31, 0xab,
	0x75, 0x9a, 0xd3, 0xf0, 0x2c, 0xc5, 0x41, 0x92, 0xd9, 0x1f,
	0x5f, 0x11, 0x8c, 0x75, 0x1c, 0x63, 0xd0, 0x02, 0x80, 0x2c,
	0x68, 0xcb, 0x93, 0xfb, 0x51, 0x73, 0x49, 0xb4, 0x60, 0xda,
	0xe2, 0x26, 0xaf, 0xa9, 0x46, 0x12, 0xb8, 0xec, 0x50, 0xdd,
	0x12, 0x06, 0x5f, 0xce, 0x59, 0xe6, 0xf6, 0x1c, 0xe0, 0x54,
	0x10, 0xad, 0xf6, 0xcd, 0x98, 0xcc, 0x0f, 0xfb, 0xcb, 0x41,
	0x14, 0x9d, 0xed, 0xe4, 0xb4, 0x74, 0x5f, 0x09, 0x60, 0xc7,
	0x12, 0xf6, 0x7b, 0x3c, 0x8f, 0xa7, 0x20, 0xbc, 0xe4, 0xb1,
	0xef, 0xeb, 0xa4, 0x93, 0xc5, 0x06, 0xca, 0x9a, 0x27, 0x9d,
	0x87, 0xf3, 0xde, 0xca, 0xe5, 0xe7, 0xf6, 0x1c, 0x01, 0x65,
	0x5b, 0xfb, 0x19, 0x79, 0x6e, 0x08, 0x26, 0xc5, 0xc8, 0x28,
	0x0e, 0xb6, 0x3b, 0x07, 0x08, 0xc1, 0x02, 0x82, 0x01, 0x01,
	0x00, 0xe8, 0x1c, 0x73, 0xa6, 0xb8, 0xe0, 0x0e, 0x6d, 0x8d,
	0x1b, 0xb9, 0x53, 0xed, 0x58, 0x94, 0xe6, 0x1d, 0x60, 0x14,
	0x5c, 0x76, 0x43, 0xc4, 0x58, 0x19, 0xc4, 0x24, 0xe8, 0xbc,
	0x1b, 0x3b, 0x0b, 0x13, 0x24, 0x45, 0x54, 0x0e, 0xcc, 0x37,
	0xf0, 0xe0, 0x63, 0x7d, 0xc3, 0xf7, 0xfb, 0x81, 0x74, 0x81,
	0xc4, 0x0f, 0x1a, 0x21, 0x48, 0xaf, 0xce, 0xc1, 0xc4, 0x94,
	0x18, 0x06, 0x44, 0x8d, 0xd3, 0xd2, 0x22, 0x2d, 0x2d, 0x3e,
	0x5a, 0x31, 0xdc, 0x95, 0x8e, 0xf4, 0x41, 0xfc, 0x58, 0xc9,
	0x40, 0x92, 0x17, 0x5f, 0xe3, 0xda, 0xac, 0x9e, 0x3f, 0x1c,
	0x2a, 0x6b, 0x58, 0x5f, 0x48, 0x78, 0x20, 0xb1, 0xaf, 0x24,
	0x9b, 0x3c, 0x20, 0x8b, 0x93, 0x25, 0x9e, 0xe6, 0x6b, 0xbc,
	0x13, 0x42, 0x14, 0x6c, 0x36, 0x31, 0xff, 0x7a, 0xd1, 0xc1,
	0x1a, 0x26, 0x14, 0x7f, 0xa9, 0x76, 0xa7, 0x0c, 0xf8, 0xcc,
	0xed, 0x07, 0x6a, 0xd2, 0xdf, 0x62, 0xee, 0x0a, 0x7c, 0x84,
	0xcb, 0x49, 0x90, 0xb2, 0x03, 0x0d, 0xa2, 0x82, 0x06, 0x77,
	0xf1, 0xcd, 0x67, 0xf2, 0x47, 0x21, 0x02, 0x3f, 0x43, 0x21,
	0xf0, 0x46, 0x30, 0x62, 0x51, 0x72, 0xb1, 0xe7, 0x48, 0xc6,
	0x67, 0x12, 0xcd, 0x9e, 0xd6, 0x15, 0xe5, 0x21, 0xed, 0xfa,
	0x8f, 0x30, 0xa6, 0x41, 0xfe, 0xb6, 0xfa, 0x8f, 0x34, 0x14,
	0x19, 0xe8, 0x11, 0xf7, 0xa5, 0x77, 0x3e, 0xb7, 0xf9, 0x39,
	0x07, 0x8c, 0x67, 0x2a, 0xab, 0x7b, 0x08, 0xf8, 0xb0, 0x06,
	0xa8, 0xea, 0x2f, 0x8f, 0xfa, 0xcc, 0xcc, 0x40, 0xce, 0xf3,
	0x70, 0x4f, 0x3f, 0x7f, 0xe2, 0x0c, 0xea, 0x76, 0x4a, 0x35,
	0x4e, 0x47, 0xad, 0x2b, 0xa7, 0x97, 0x5d, 0x74, 0x43, 0x97,
	0x90, 0xd2, 0xfb, 0xd9, 0xf9, 0x96, 0x01, 0x33, 0x05, 0xed,
	0x7b, 0x03, 0x05, 0xad, 0xf8, 0x49, 0x03, 0x02, 0x82, 0x01,
	0x01, 0x00, 0xd4, 0x40, 0x17, 0x66, 0x10, 0x92, 0x95, 0xc8,
	0xec, 0x62, 0xa9, 0x7a, 0xcb, 0x93, 0x8e, 0xe6, 0x53, 0xd4,
	0x80, 0x48, 0x27, 0x4b, 0x41, 0xce, 0x61, 0xdf, 0xbf, 0x94,
	0xa4, 0x3d, 0x71, 0x03, 0x0b, 0xed, 0x25, 0x71, 0x98, 0xa4,
	0xd6, 0xd5, 0x4a, 0x57, 0xf5, 0x6c, 0x1b, 0xda, 0x21, 0x7d,
	0x35, 0x45, 0xb3, 0xf3, 0x6a, 0xd9, 0xd3, 0x43, 0xe8, 0x5c,
	0x54, 0x1c, 0x83, 0x1b, 0xb4, 0x5f, 0xf2, 0x97, 0x24, 0x2e,
	0xdc, 0x40, 0xde, 0x92, 0x23, 0x59, 0x8e, 0xbc, 0xd2, 0xa1,
	0xf2, 0xe0, 0x4c, 0xdd, 0x0b, 0xd1, 0xe7, 0xae, 0x65, 0xbc,
	0xb5, 0xf5, 0x5b, 0x98, 0xe9, 0xd7, 0xc2, 0xb7, 0x0e, 0x55,
	0x71, 0x0e, 0x3c, 0x0a, 0x24, 0x6b, 0xa6, 0xe6, 0x14, 0x61,
	0x11, 0xfd, 0x33, 0x42, 0x99, 0x2b, 0x84, 0x77, 0x74, 0x92,
	0x91, 0xf5, 0x79, 0x79, 0xcf, 0xad, 0x8e, 0x04, 0xef, 0x80,
	0x1e, 0x57, 0xf4, 0x14, 0xf5, 0x35, 0x09, 0x74, 0xb2, 0x13,
	0x71, 0x58, 0x6b, 0xea, 0x32, 0x5d, 0xf3, 0xd3, 0x76, 0x48,
	0x39, 0x10, 0x23, 0x84, 0x9d, 0xbe, 0x92, 0x77, 0x4a, 0xed,
	0x70, 0x3e, 0x1a, 0xa2, 0x6c, 0xb3, 0x81, 0x00, 0xc3, 0xc9,
	0xe4, 0x52, 0xc8, 0x24, 0x88, 0x0c, 0x41, 0xad, 0x87, 0x5a,
	0xea, 0xa3, 0x7a, 0x85, 0x1c, 0x5e, 0x31, 0x7f, 0xc3, 0x35,
	0xc6, 0xfa, 0x10, 0xc8, 0x75, 0x10, 0xc4, 0x96, 0x99, 0xe7,
	0xfe, 0x01, 0xb4, 0x74, 0xdb, 0xb4, 0x11, 0xc3, 0xc8, 0x8c,
	0xf6, 0xf7, 0x3b, 0x66, 0x50, 0xfc, 0xdb, 0xeb, 0xca, 0x47,
	0x85, 0x89, 0xe1, 0x65, 0xd9, 0x62, 0x34, 0x3c, 0x70, 0xd8,
	0x2e, 0xb4, 0x2f, 0x65, 0x3c, 0x4a, 0xa6, 0x2a, 0xe7, 0xc7,
	0xd8, 0x41, 0x8f, 0x8a, 0x43, 0xbf, 0x42, 0xf2, 0x4d, 0xbc,
	0xfc, 0x9e, 0x27, 0x95, 0xfb, 0x75, 0xff, 0xab, 0x02, 0x82,
	0x01, 0x00, 0x41, 0x2f, 0x44, 0x57, 0x6d, 0x12, 0x17, 0x5b,
	0x32, 0xc6, 0xb7, 0x6c, 0x57, 0x7a, 0x8a, 0x0e, 0x79, 0xef,
	0x72, 0xa8, 0x68, 0xda, 0x2d, 0x38, 0xe4, 0xbb, 0x8d, 0xf6,
	0x02, 0x65, 0xcf, 0x56, 0x13, 0xe1, 0x1a, 0xcb, 0x39, 0x80,
	0xa6, 0xb1, 0x32, 0x03, 0x1e, 0xdd, 0xbb, 0x35, 0xd9, 0xac,
	0x43, 0x89, 0x31, 0x08, 0x90, 0x92, 0x5e, 0x35, 0x3d, 0x7b,
	0x9c, 0x6f, 0x86, 0xcb, 0x17, 0xdd, 0x85, 0xe4, 0xed, 0x35,
	0x08, 0x8e, 0xc1, 0xf4, 0x05, 0xd8, 0x68, 0xc6, 0x63, 0x3c,
	0xf7, 0xff, 0xf7, 0x47, 0x33, 0x39, 0xc5, 0x3e, 0xb7, 0x0e,
	0x58, 0x35, 0x9d, 0x81, 0xea, 0xf8, 0x6a, 0x2c, 0x1c, 0x5a,
	0x68, 0x78, 0x64, 0x11, 0x6b, 0xc1, 0x3e, 0x4e, 0x7a, 0xbd,
	0x84, 0xcb, 0x0f, 0xc2, 0xb6, 0x85, 0x1d, 0xd3, 0x76, 0xc5,
	0x93, 0x6a, 0x69, 0x89, 0x56, 0x34, 0xdc, 0x4a, 0x9b, 0xbc,
	0xff, 0xa8, 0x0d, 0x6e, 0x35, 0x9c, 0x60, 0xa7, 0x23, 0x30,
	0xc7, 0x06, 0x64, 0x39, 0x8b, 0x94, 0x89, 0xee, 0xba, 0x7f,
	0x60, 0x8d, 0xfa, 0xb6, 0x97, 0x76, 0xdc, 0x51, 0x4a, 0x3c,
	0xeb, 0x3a, 0x14, 0x2c, 0x20, 0x60, 0x69, 0x4a, 0x86, 0xfe,
	0x8c, 0x21, 0x84, 0x49, 0x54, 0xb3, 0x20, 0xe1, 0x01, 0x7f,
	0x58, 0xdf, 0x7f, 0xb5, 0x21, 0x51, 0x8c, 0x47, 0x9f, 0x91,
	0xeb, 0x97, 0x3e, 0xf2, 0x54, 0xcf, 0x16, 0x46, 0xf9, 0xd9,
	0xb6, 0xe7, 0x64, 0xc9, 0xd0, 0x54, 0xea, 0x2f, 0xa1, 0xcf,
	0xa5, 0x7f, 0x28, 0x8d, 0x84, 0xec, 0xd5, 0x39, 0x03, 0x76,
	0x5b, 0x2d, 0x8e, 0x43, 0xf2, 0x01, 0x24, 0xc9, 0x6f, 0xc0,
	0xf5, 0x69, 0x6f, 0x7d, 0xb5, 0x85, 0xd2, 0x5f, 0x7f, 0x78,
	0x40, 0x07, 0x7f, 0x09, 0x15, 0xb5, 0x1f, 0x28, 0x65, 0x10,
	0xe4, 0x19, 0xa8, 0xc6, 0x9e, 0x8d, 0xdc, 0xcb, 0x02, 0x82,
	0x01, 0x00, 0x13, 0x01, 0xee, 0x56, 0x80, 0x93, 0x70, 0x00,
	0x7f, 0x52, 0xd2, 0x94, 0xa1, 0x98, 0x84, 0x4a, 0x92, 0x25,
	0x4c, 0x9b, 0xa9, 0x91, 0x2e, 0xc2, 0x79, 0xb7, 0x5c, 0xe3,
	0xc5, 0xd5, 0x8e, 0xc2, 0x54, 0x16, 0x17, 0xad, 0x55, 0x9b,
	0x25, 0x76, 0x12, 0x63, 0x50, 0x22, 0x2f, 0x58, 0x58, 0x79,
	0x6b, 0x04, 0xe3, 0xf9, 0x9f, 0x8f, 0x04, 0x41, 0x67, 0x94,
	0xa5, 0x1f, 0xac, 0x8a, 0x15, 0x9c, 0x26, 0x10, 0x6c, 0xf8,
	0x19, 0x57, 0x61, 0xd7, 0x3a, 0x7d, 0x31, 0xb0, 0x2d, 0x38,
	0xbd, 0x94, 0x62, 0xad, 0xc4, 0xfa, 0x36, 0x42, 0x42, 0xf0,
	0x24, 0x67, 0x65, 0x9d, 0x8b, 0x0b, 0x7c, 0x6f, 0x82, 0x44,
	0x1a, 0x8c, 0xc8, 0xc9, 0xab, 0xbb, 0x4c, 0x45, 0xfc, 0x7b,
	0x38, 0xee, 0x30, 0xe1, 0xfc, 0xef, 0x8d, 0xbc, 0x58, 0xdf,
	0x2b, 0x5d, 0x0d, 0x54, 0xe0, 0x49, 0x4d, 0x97, 0x99, 0x8f,
	0x22, 0xa8, 0x83, 0xbe, 0x40, 0xbb, 0x50, 0x2e, 0x78, 0x28,
	0x0f, 0x95, 0x78, 0x8c, 0x8f, 0x98, 0x24, 0x56, 0xc2, 0x97,
	0xf3, 0x2c, 0x43, 0xd2, 0x03, 0x82, 0x66, 0x81, 0x72, 0x5f,
	0x53, 0x16, 0xec, 0xb1, 0xb1, 0x04, 0x5e, 0x40, 0x20, 0x48,
	0x7b, 0x3f, 0x02, 0x97, 0x6a, 0xeb, 0x96, 0x12, 0x21, 0x35,
	0xfe, 0x1f, 0x47, 0xc0, 0x95, 0xea, 0xc5, 0x8a, 0x08, 0x84,
	0x4f, 0x5e, 0x63, 0x94, 0x60, 0x0f, 0x71, 0x5b, 0x7f, 0x4a,
	0xec, 0x4f, 0x60, 0xc6, 0xba, 0x4a, 0x24, 0xf1, 0x20, 0x8b,
	0xa7, 0x2e, 0x3a, 0xce, 0x8d, 0xe0, 0x27, 0x1d, 0xb5, 0x8e,
	0xb4, 0x21, 0xc5, 0xe2, 0xa6, 0x16, 0x0a, 0x51, 0x83, 0x55,
	0x88, 0xd1, 0x30, 0x11, 0x63, 0xd5, 0xd7, 0x8d, 0xae, 0x16,
	0x12, 0x82, 0xc4, 0x85, 0x00, 0x4e, 0x27, 0x83, 0xa5, 0x7c,
	0x90, 0x2e, 0xe5, 0xa2, 0xa3, 0xd3, 0x4c, 0x63, 0x02, 0x82,
	0x01, 0x01, 0x00, 0x86, 0x08, 0x98, 0x98, 0xa5, 0x00, 0x05,
	0x39, 0x77, 0xd9, 0x66, 0xb3, 0xcf, 0xca, 0xa0, 0x71, 0xb3,
	0x50, 0xce, 0x3d, 0xb1, 0x93, 0x95, 0x35, 0xc4, 0xd4, 0x2e,
	0x90, 0xdf, 0x0f, 0xfc, 0x60, 0xc1, 0x94, 0x68, 0x61, 0x43,
	0xca, 0x9a, 0x23, 0x4a, 0x1e, 0x45, 0x72, 0x99, 0xb5, 0x1e,
	0x61, 0x8d, 0x77, 0x0f, 0xa0, 0xbb, 0xd7, 0x77, 0xb4, 0x2a,
	0x15, 0x11, 0x88, 0x2d, 0xb3, 0x56, 0x61, 0x5e, 0x6a, 0xed,
	0xa4, 0x46, 0x4a, 0x3f, 0x50, 0x11, 0xd6, 0xba, 0xb6, 0xd7,
	0x95, 0x65, 0x53, 0xc3, 0xa1, 0x8f, 0xe0, 0xa3, 0xf5, 0x1c,
	0xfd, 0xaf, 0x6e, 0x43, 0xd7, 0x17, 0xa7, 0xd3, 0x81, 0x1b,
	0xa4, 0xdf, 0xe0, 0x97, 0x8a, 0x46, 0x03, 0xd3, 0x46, 0x0e,
	0x83, 0x48, 0x4e, 0xd2, 0x02, 0xcb, 0xc0, 0xad, 0x79, 0x95,
	0x8c, 0x96, 0xba, 0x40, 0x34, 0x11, 0x71, 0x5e, 0xe9, 0x11,
	0xf9, 0xc5, 0x4a, 0x5e, 0x91, 0x9d, 0xf5, 0x92, 0x4f, 0xeb,
	0xc6, 0x70, 0x02, 0x2d, 0x3d, 0x04, 0xaa, 0xe9, 0x3a, 0x8e,
	0xd5, 0xa8, 0xad, 0xf7, 0xce, 0x0d, 0x16, 0xb2, 0xec, 0x0a,
	0x9c, 0xf5, 0x94, 0x39, 0xb9, 0x8a, 0xfc, 0x1e, 0xf9, 0xcc,
	0xf2, 0x5f, 0x21, 0x31, 0x74, 0x72, 0x6b, 0x64, 0xae, 0x35,
	0x61, 0x8d, 0x0d, 0xcb, 0xe7, 0xda, 0x39, 0xca, 0xf3, 0x21,
	0x66, 0x0b, 0x95, 0xd7, 0x0a, 0x7c, 0xca, 0xa1, 0xa9, 0x5a,
	0xe8, 0xac, 0xe0, 0x71, 0x54, 0xaf, 0x28, 0xcf, 0xd5, 0x70,
	0x89, 0xe0, 0xf3, 0x9e, 0x43, 0x6c, 0x8d, 0x7b, 0x99, 0x01,
	0x68, 0x4d, 0xa1, 0x45, 0x46, 0x0c, 0x43, 0xbc, 0xcc, 0x2c,
	0xdd, 0xc5, 0x46, 0xc8, 0x4e, 0x0e, 0xbe, 0xed, 0xb9, 0x26,
	0xab, 0x2e, 0xdb, 0xeb, 0x8f, 0xff, 0xdb, 0xb0, 0xc6, 0x55,
	0xaf, 0xf8, 0x2a, 0x91, 0x9d, 0x50, 0x44, 0x21, 0x17,
};
deps/libressl-pnacl-sys-2.1.6/libressl/apps/prime.c0000644000175000017500000001045112360020706017160 0ustar  /* $OpenBSD: prime.c,v 1.10 2014/06/12 15:49:27 deraadt Exp $ */
/* ====================================================================
 * Copyright (c) 2004 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 *
 */

#include 
#include 

#include "apps.h"

#include 

int prime_main(int, char **);

int 
prime_main(int argc, char **argv)
{
	int hex = 0;
	int checks = 20;
	int generate = 0;
	int bits = 0;
	int safe = 0;
	BIGNUM *bn = NULL;
	const char *errstr = NULL;
	BIO *bio_out;

	--argc;
	++argv;
	while (argc >= 1 && **argv == '-') {
		if (!strcmp(*argv, "-hex"))
			hex = 1;
		else if (!strcmp(*argv, "-generate"))
			generate = 1;
		else if (!strcmp(*argv, "-bits")) {
			if (--argc < 1)
				goto bad;
			else
				bits = strtonum(*(++argv), 0, INT_MAX, &errstr);
			if (errstr)
				goto bad;
		} else if (!strcmp(*argv, "-safe"))
			safe = 1;
		else if (!strcmp(*argv, "-checks")) {
			if (--argc < 1)
				goto bad;
			else
				checks = strtonum(*(++argv), 0, INT_MAX, &errstr);
			if (errstr)
				goto bad;
		} else {
			BIO_printf(bio_err, "Unknown option '%s'\n", *argv);
			goto bad;
		}
		--argc;
		++argv;
	}

	if (argv[0] == NULL && !generate) {
		BIO_printf(bio_err, "No prime specified\n");
		goto bad;
	}
	if ((bio_out = BIO_new(BIO_s_file())) != NULL) {
		BIO_set_fp(bio_out, stdout, BIO_NOCLOSE);
	}
	if (generate) {
		char *s;

		if (!bits) {
			BIO_printf(bio_err, "Specifiy the number of bits.\n");
			return 1;
		}
		bn = BN_new();
		BN_generate_prime_ex(bn, bits, safe, NULL, NULL, NULL);
		s = hex ? BN_bn2hex(bn) : BN_bn2dec(bn);
		BIO_printf(bio_out, "%s\n", s);
		free(s);
	} else {
		if (hex)
			BN_hex2bn(&bn, argv[0]);
		else
			BN_dec2bn(&bn, argv[0]);

		BN_print(bio_out, bn);
		BIO_printf(bio_out, " is %sprime\n",
		    BN_is_prime_ex(bn, checks, NULL, NULL) ? "" : "not ");
	}

	BN_free(bn);
	BIO_free_all(bio_out);

	return 0;

bad:
	if (errstr)
		BIO_printf(bio_err, "invalid argument %s: %s\n", *argv, errstr);
	else {
		BIO_printf(bio_err, "options are\n");
		BIO_printf(bio_err, "%-14s hex\n", "-hex");
		BIO_printf(bio_err, "%-14s number of checks\n", "-checks ");
	}
	return 1;
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/dh.c0000644000175000017500000002170012360020706016436 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#include 	/* for OPENSSL_NO_DH */

#ifndef OPENSSL_NO_DH

#include 
#include 
#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 
#include 
#include 

/* -inform arg	- input format - default PEM (DER or PEM)
 * -outform arg - output format - default PEM
 * -in arg	- input file - default stdin
 * -out arg	- output file - default stdout
 * -check	- check the parameters are ok
 * -noout
 * -text
 * -C
 */

int dh_main(int, char **);

int
dh_main(int argc, char **argv)
{
	DH *dh = NULL;
	int i, badops = 0, text = 0;
	BIO *in = NULL, *out = NULL;
	int informat, outformat, check = 0, noout = 0, C = 0, ret = 1;
	char *infile, *outfile, *prog;
#ifndef OPENSSL_NO_ENGINE
	char *engine;
#endif

	if (!load_config(bio_err, NULL))
		goto end;

#ifndef OPENSSL_NO_ENGINE
	engine = NULL;
#endif
	infile = NULL;
	outfile = NULL;
	informat = FORMAT_PEM;
	outformat = FORMAT_PEM;

	prog = argv[0];
	argc--;
	argv++;
	while (argc >= 1) {
		if (strcmp(*argv, "-inform") == 0) {
			if (--argc < 1)
				goto bad;
			informat = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-outform") == 0) {
			if (--argc < 1)
				goto bad;
			outformat = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-in") == 0) {
			if (--argc < 1)
				goto bad;
			infile = *(++argv);
		} else if (strcmp(*argv, "-out") == 0) {
			if (--argc < 1)
				goto bad;
			outfile = *(++argv);
		}
#ifndef OPENSSL_NO_ENGINE
		else if (strcmp(*argv, "-engine") == 0) {
			if (--argc < 1)
				goto bad;
			engine = *(++argv);
		}
#endif
		else if (strcmp(*argv, "-check") == 0)
			check = 1;
		else if (strcmp(*argv, "-text") == 0)
			text = 1;
		else if (strcmp(*argv, "-C") == 0)
			C = 1;
		else if (strcmp(*argv, "-noout") == 0)
			noout = 1;
		else {
			BIO_printf(bio_err, "unknown option %s\n", *argv);
			badops = 1;
			break;
		}
		argc--;
		argv++;
	}

	if (badops) {
bad:
		BIO_printf(bio_err, "%s [options] outfile\n", prog);
		BIO_printf(bio_err, "where options are\n");
		BIO_printf(bio_err, " -inform arg   input format - one of DER PEM\n");
		BIO_printf(bio_err, " -outform arg  output format - one of DER PEM\n");
		BIO_printf(bio_err, " -in arg       input file\n");
		BIO_printf(bio_err, " -out arg      output file\n");
		BIO_printf(bio_err, " -check        check the DH parameters\n");
		BIO_printf(bio_err, " -text         print a text form of the DH parameters\n");
		BIO_printf(bio_err, " -C            Output C code\n");
		BIO_printf(bio_err, " -noout        no output\n");
#ifndef OPENSSL_NO_ENGINE
		BIO_printf(bio_err, " -engine e     use engine e, possibly a hardware device.\n");
#endif
		goto end;
	}
	ERR_load_crypto_strings();

#ifndef OPENSSL_NO_ENGINE
	setup_engine(bio_err, engine, 0);
#endif

	in = BIO_new(BIO_s_file());
	out = BIO_new(BIO_s_file());
	if ((in == NULL) || (out == NULL)) {
		ERR_print_errors(bio_err);
		goto end;
	}
	if (infile == NULL)
		BIO_set_fp(in, stdin, BIO_NOCLOSE);
	else {
		if (BIO_read_filename(in, infile) <= 0) {
			perror(infile);
			goto end;
		}
	}
	if (outfile == NULL) {
		BIO_set_fp(out, stdout, BIO_NOCLOSE);
	} else {
		if (BIO_write_filename(out, outfile) <= 0) {
			perror(outfile);
			goto end;
		}
	}

	if (informat == FORMAT_ASN1)
		dh = d2i_DHparams_bio(in, NULL);
	else if (informat == FORMAT_PEM)
		dh = PEM_read_bio_DHparams(in, NULL, NULL, NULL);
	else {
		BIO_printf(bio_err, "bad input format specified\n");
		goto end;
	}
	if (dh == NULL) {
		BIO_printf(bio_err, "unable to load DH parameters\n");
		ERR_print_errors(bio_err);
		goto end;
	}
	if (text) {
		DHparams_print(out, dh);
#ifdef undef
		printf("p=");
		BN_print(stdout, dh->p);
		printf("\ng=");
		BN_print(stdout, dh->g);
		printf("\n");
		if (dh->length != 0)
			printf("recommended private length=%ld\n", dh->length);
#endif
	}
	if (check) {
		if (!DH_check(dh, &i)) {
			ERR_print_errors(bio_err);
			goto end;
		}
		if (i & DH_CHECK_P_NOT_PRIME)
			printf("p value is not prime\n");
		if (i & DH_CHECK_P_NOT_SAFE_PRIME)
			printf("p value is not a safe prime\n");
		if (i & DH_UNABLE_TO_CHECK_GENERATOR)
			printf("unable to check the generator value\n");
		if (i & DH_NOT_SUITABLE_GENERATOR)
			printf("the g value is not a generator\n");
		if (i == 0)
			printf("DH parameters appear to be ok.\n");
	}
	if (C) {
		unsigned char *data;
		int len, l, bits;

		len = BN_num_bytes(dh->p);
		bits = BN_num_bits(dh->p);
		data = malloc(len);
		if (data == NULL) {
			perror("malloc");
			goto end;
		}
		l = BN_bn2bin(dh->p, data);
		printf("static unsigned char dh%d_p[] = {", bits);
		for (i = 0; i < l; i++) {
			if ((i % 12) == 0)
				printf("\n\t");
			printf("0x%02X, ", data[i]);
		}
		printf("\n\t};\n");

		l = BN_bn2bin(dh->g, data);
		printf("static unsigned char dh%d_g[] = {", bits);
		for (i = 0; i < l; i++) {
			if ((i % 12) == 0)
				printf("\n\t");
			printf("0x%02X, ", data[i]);
		}
		printf("\n\t};\n\n");

		printf("DH *get_dh%d()\n\t{\n", bits);
		printf("\tDH *dh;\n\n");
		printf("\tif ((dh = DH_new()) == NULL) return(NULL);\n");
		printf("\tdh->p = BN_bin2bn(dh%d_p, sizeof(dh%d_p), NULL);\n",
		    bits, bits);
		printf("\tdh->g = BN_bin2bn(dh%d_g, sizeof(dh%d_g), NULL);\n",
		    bits, bits);
		printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n");
		printf("\t\treturn(NULL);\n");
		printf("\treturn(dh);\n\t}\n");
		free(data);
	}
	if (!noout) {
		if (outformat == FORMAT_ASN1)
			i = i2d_DHparams_bio(out, dh);
		else if (outformat == FORMAT_PEM)
			i = PEM_write_bio_DHparams(out, dh);
		else {
			BIO_printf(bio_err, "bad output format specified for outfile\n");
			goto end;
		}
		if (!i) {
			BIO_printf(bio_err, "unable to write DH parameters\n");
			ERR_print_errors(bio_err);
			goto end;
		}
	}
	ret = 0;

end:
	if (in != NULL)
		BIO_free(in);
	if (out != NULL)
		BIO_free_all(out);
	if (dh != NULL)
		DH_free(dh);
	
	return (ret);
}
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/apps/cms.c0000644000175000017500000010165012360020706016630 0ustar  /* $OpenBSD$ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
 * project.
 */
/* ====================================================================
 * Copyright (c) 2008 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 */

/* CMS utility function */

#include 
#include 

#include "apps.h"

#ifndef OPENSSL_NO_CMS

#include 
#include 
#include 
#include 
#include 
#include 

static int save_certs(char *signerfile, STACK_OF(X509) * signers);
static int cms_cb(int ok, X509_STORE_CTX * ctx);
static void receipt_request_print(BIO * out, CMS_ContentInfo * cms);
static CMS_ReceiptRequest * make_receipt_request(
    STACK_OF(OPENSSL_STRING) * rr_to, int rr_allorfirst,
    STACK_OF(OPENSSL_STRING) * rr_from);

#define SMIME_OP	0x10
#define SMIME_IP	0x20
#define SMIME_SIGNERS	0x40
#define SMIME_ENCRYPT		(1 | SMIME_OP)
#define SMIME_DECRYPT		(2 | SMIME_IP)
#define SMIME_SIGN		(3 | SMIME_OP | SMIME_SIGNERS)
#define SMIME_VERIFY		(4 | SMIME_IP)
#define SMIME_CMSOUT		(5 | SMIME_IP | SMIME_OP)
#define SMIME_RESIGN		(6 | SMIME_IP | SMIME_OP | SMIME_SIGNERS)
#define SMIME_DATAOUT		(7 | SMIME_IP)
#define SMIME_DATA_CREATE	(8 | SMIME_OP)
#define SMIME_DIGEST_VERIFY	(9 | SMIME_IP)
#define SMIME_DIGEST_CREATE	(10 | SMIME_OP)
#define SMIME_UNCOMPRESS	(11 | SMIME_IP)
#define SMIME_COMPRESS		(12 | SMIME_OP)
#define SMIME_ENCRYPTED_DECRYPT	(13 | SMIME_IP)
#define SMIME_ENCRYPTED_ENCRYPT	(14 | SMIME_OP)
#define SMIME_SIGN_RECEIPT	(15 | SMIME_IP | SMIME_OP)
#define SMIME_VERIFY_RECEIPT	(16 | SMIME_IP)

int verify_err = 0;

int cms_main(int, char **);

int
cms_main(int argc, char **argv)
{
	ENGINE *e = NULL;
	int operation = 0;
	int ret = 0;
	char **args;
	const char *inmode = "r", *outmode = "w";
	char *infile = NULL, *outfile = NULL, *rctfile = NULL;
	char *signerfile = NULL, *recipfile = NULL;
	STACK_OF(OPENSSL_STRING) * sksigners = NULL, *skkeys = NULL;
	char *certfile = NULL, *keyfile = NULL, *contfile = NULL;
	char *certsoutfile = NULL;
	const EVP_CIPHER *cipher = NULL;
	CMS_ContentInfo *cms = NULL, *rcms = NULL;
	X509_STORE *store = NULL;
	X509 *cert = NULL, *recip = NULL, *signer = NULL;
	EVP_PKEY *key = NULL;
	STACK_OF(X509) * encerts = NULL, *other = NULL;
	BIO *in = NULL, *out = NULL, *indata = NULL, *rctin = NULL;
	int badarg = 0;
	int flags = CMS_DETACHED, noout = 0, print = 0;
	int verify_retcode = 0;
	int rr_print = 0, rr_allorfirst = -1;
	STACK_OF(OPENSSL_STRING) * rr_to = NULL, *rr_from = NULL;
	CMS_ReceiptRequest *rr = NULL;
	char *to = NULL, *from = NULL, *subject = NULL;
	char *CAfile = NULL, *CApath = NULL;
	char *passargin = NULL, *passin = NULL;
	const EVP_MD *sign_md = NULL;
	int informat = FORMAT_SMIME, outformat = FORMAT_SMIME;
	int rctformat = FORMAT_SMIME, keyform = FORMAT_PEM;
#ifndef OPENSSL_NO_ENGINE
	char *engine = NULL;
#endif
	unsigned char *secret_key = NULL, *secret_keyid = NULL;
	unsigned char *pwri_pass = NULL, *pwri_tmp = NULL;
	size_t secret_keylen = 0, secret_keyidlen = 0;

	ASN1_OBJECT *econtent_type = NULL;

	X509_VERIFY_PARAM *vpm = NULL;

	args = argv + 1;
	ret = 1;

	if (!load_config(bio_err, NULL))
		goto end;

	while (!badarg && *args && *args[0] == '-') {
		if (!strcmp(*args, "-encrypt"))
			operation = SMIME_ENCRYPT;
		else if (!strcmp(*args, "-decrypt"))
			operation = SMIME_DECRYPT;
		else if (!strcmp(*args, "-sign"))
			operation = SMIME_SIGN;
		else if (!strcmp(*args, "-sign_receipt"))
			operation = SMIME_SIGN_RECEIPT;
		else if (!strcmp(*args, "-resign"))
			operation = SMIME_RESIGN;
		else if (!strcmp(*args, "-verify"))
			operation = SMIME_VERIFY;
		else if (!strcmp(*args, "-verify_retcode"))
			verify_retcode = 1;
		else if (!strcmp(*args, "-verify_receipt")) {
			operation = SMIME_VERIFY_RECEIPT;
			if (!args[1])
				goto argerr;
			args++;
			rctfile = *args;
		} else if (!strcmp(*args, "-cmsout"))
			operation = SMIME_CMSOUT;
		else if (!strcmp(*args, "-data_out"))
			operation = SMIME_DATAOUT;
		else if (!strcmp(*args, "-data_create"))
			operation = SMIME_DATA_CREATE;
		else if (!strcmp(*args, "-digest_verify"))
			operation = SMIME_DIGEST_VERIFY;
		else if (!strcmp(*args, "-digest_create"))
			operation = SMIME_DIGEST_CREATE;
		else if (!strcmp(*args, "-compress"))
			operation = SMIME_COMPRESS;
		else if (!strcmp(*args, "-uncompress"))
			operation = SMIME_UNCOMPRESS;
		else if (!strcmp(*args, "-EncryptedData_decrypt"))
			operation = SMIME_ENCRYPTED_DECRYPT;
		else if (!strcmp(*args, "-EncryptedData_encrypt"))
			operation = SMIME_ENCRYPTED_ENCRYPT;
#ifndef OPENSSL_NO_DES
		else if (!strcmp(*args, "-des3"))
			cipher = EVP_des_ede3_cbc();
		else if (!strcmp(*args, "-des"))
			cipher = EVP_des_cbc();
#endif
#ifndef OPENSSL_NO_RC2
		else if (!strcmp(*args, "-rc2-40"))
			cipher = EVP_rc2_40_cbc();
		else if (!strcmp(*args, "-rc2-128"))
			cipher = EVP_rc2_cbc();
		else if (!strcmp(*args, "-rc2-64"))
			cipher = EVP_rc2_64_cbc();
#endif
#ifndef OPENSSL_NO_AES
		else if (!strcmp(*args, "-aes128"))
			cipher = EVP_aes_128_cbc();
		else if (!strcmp(*args, "-aes192"))
			cipher = EVP_aes_192_cbc();
		else if (!strcmp(*args, "-aes256"))
			cipher = EVP_aes_256_cbc();
#endif
#ifndef OPENSSL_NO_CAMELLIA
		else if (!strcmp(*args, "-camellia128"))
			cipher = EVP_camellia_128_cbc();
		else if (!strcmp(*args, "-camellia192"))
			cipher = EVP_camellia_192_cbc();
		else if (!strcmp(*args, "-camellia256"))
			cipher = EVP_camellia_256_cbc();
#endif
		else if (!strcmp(*args, "-debug_decrypt"))
			flags |= CMS_DEBUG_DECRYPT;
		else if (!strcmp(*args, "-text"))
			flags |= CMS_TEXT;
		else if (!strcmp(*args, "-nointern"))
			flags |= CMS_NOINTERN;
		else if (!strcmp(*args, "-noverify") ||
		    !strcmp(*args, "-no_signer_cert_verify"))
			flags |= CMS_NO_SIGNER_CERT_VERIFY;
		else if (!strcmp(*args, "-nocerts"))
			flags |= CMS_NOCERTS;
		else if (!strcmp(*args, "-noattr"))
			flags |= CMS_NOATTR;
		else if (!strcmp(*args, "-nodetach"))
			flags &= ~CMS_DETACHED;
		else if (!strcmp(*args, "-nosmimecap"))
			flags |= CMS_NOSMIMECAP;
		else if (!strcmp(*args, "-binary"))
			flags |= CMS_BINARY;
		else if (!strcmp(*args, "-keyid"))
			flags |= CMS_USE_KEYID;
		else if (!strcmp(*args, "-nosigs"))
			flags |= CMS_NOSIGS;
		else if (!strcmp(*args, "-no_content_verify"))
			flags |= CMS_NO_CONTENT_VERIFY;
		else if (!strcmp(*args, "-no_attr_verify"))
			flags |= CMS_NO_ATTR_VERIFY;
		else if (!strcmp(*args, "-stream"))
			flags |= CMS_STREAM;
		else if (!strcmp(*args, "-indef"))
			flags |= CMS_STREAM;
		else if (!strcmp(*args, "-noindef"))
			flags &= ~CMS_STREAM;
		else if (!strcmp(*args, "-nooldmime"))
			flags |= CMS_NOOLDMIMETYPE;
		else if (!strcmp(*args, "-crlfeol"))
			flags |= CMS_CRLFEOL;
		else if (!strcmp(*args, "-noout"))
			noout = 1;
		else if (!strcmp(*args, "-receipt_request_print"))
			rr_print = 1;
		else if (!strcmp(*args, "-receipt_request_all"))
			rr_allorfirst = 0;
		else if (!strcmp(*args, "-receipt_request_first"))
			rr_allorfirst = 1;
		else if (!strcmp(*args, "-receipt_request_from")) {
			if (!args[1])
				goto argerr;
			args++;
			if (!rr_from)
				rr_from = sk_OPENSSL_STRING_new_null();
			sk_OPENSSL_STRING_push(rr_from, *args);
		} else if (!strcmp(*args, "-receipt_request_to")) {
			if (!args[1])
				goto argerr;
			args++;
			if (!rr_to)
				rr_to = sk_OPENSSL_STRING_new_null();
			sk_OPENSSL_STRING_push(rr_to, *args);
		} else if (!strcmp(*args, "-print")) {
			noout = 1;
			print = 1;
		} else if (!strcmp(*args, "-secretkey")) {
			long ltmp;
			if (!args[1])
				goto argerr;
			args++;
			secret_key = string_to_hex(*args, <mp);
			if (!secret_key) {
				BIO_printf(bio_err, "Invalid key %s\n", *args);
				goto argerr;
			}
			secret_keylen = (size_t) ltmp;
		} else if (!strcmp(*args, "-secretkeyid")) {
			long ltmp;
			if (!args[1])
				goto argerr;
			args++;
			secret_keyid = string_to_hex(*args, <mp);
			if (!secret_keyid) {
				BIO_printf(bio_err, "Invalid id %s\n", *args);
				goto argerr;
			}
			secret_keyidlen = (size_t) ltmp;
		} else if (!strcmp(*args, "-pwri_password")) {
			if (!args[1])
				goto argerr;
			args++;
			pwri_pass = (unsigned char *) *args;
		} else if (!strcmp(*args, "-econtent_type")) {
			if (!args[1])
				goto argerr;
			args++;
			econtent_type = OBJ_txt2obj(*args, 0);
			if (!econtent_type) {
				BIO_printf(bio_err, "Invalid OID %s\n", *args);
				goto argerr;
			}
		}
#ifndef OPENSSL_NO_ENGINE
		else if (!strcmp(*args, "-engine")) {
			if (!args[1])
				goto argerr;
			engine = *++args;
		}
#endif
		else if (!strcmp(*args, "-passin")) {
			if (!args[1])
				goto argerr;
			passargin = *++args;
		} else if (!strcmp(*args, "-to")) {
			if (!args[1])
				goto argerr;
			to = *++args;
		} else if (!strcmp(*args, "-from")) {
			if (!args[1])
				goto argerr;
			from = *++args;
		} else if (!strcmp(*args, "-subject")) {
			if (!args[1])
				goto argerr;
			subject = *++args;
		} else if (!strcmp(*args, "-signer")) {
			if (!args[1])
				goto argerr;
			/* If previous -signer argument add signer to list */

			if (signerfile) {
				if (!sksigners)
					sksigners =
					    sk_OPENSSL_STRING_new_null();
				sk_OPENSSL_STRING_push(sksigners, signerfile);
				if (!keyfile)
					keyfile = signerfile;
				if (!skkeys)
					skkeys = sk_OPENSSL_STRING_new_null();
				sk_OPENSSL_STRING_push(skkeys, keyfile);
				keyfile = NULL;
			}
			signerfile = *++args;
		} else if (!strcmp(*args, "-recip")) {
			if (!args[1])
				goto argerr;
			recipfile = *++args;
		} else if (!strcmp(*args, "-certsout")) {
			if (!args[1])
				goto argerr;
			certsoutfile = *++args;
		} else if (!strcmp(*args, "-md")) {
			if (!args[1])
				goto argerr;
			sign_md = EVP_get_digestbyname(*++args);
			if (sign_md == NULL) {
				BIO_printf(bio_err, "Unknown digest %s\n",
				    *args);
				goto argerr;
			}
		} else if (!strcmp(*args, "-inkey")) {
			if (!args[1])
				goto argerr;
			/* If previous -inkey arument add signer to list */
			if (keyfile) {
				if (!signerfile) {
					BIO_puts(bio_err,
					    "Illegal -inkey without -signer\n");
					goto argerr;
				}
				if (!sksigners)
					sksigners =
					    sk_OPENSSL_STRING_new_null();
				sk_OPENSSL_STRING_push(sksigners, signerfile);
				signerfile = NULL;
				if (!skkeys)
					skkeys = sk_OPENSSL_STRING_new_null();
				sk_OPENSSL_STRING_push(skkeys, keyfile);
			}
			keyfile = *++args;
		} else if (!strcmp(*args, "-keyform")) {
			if (!args[1])
				goto argerr;
			keyform = str2fmt(*++args);
		} else if (!strcmp(*args, "-rctform")) {
			if (!args[1])
				goto argerr;
			rctformat = str2fmt(*++args);
		} else if (!strcmp(*args, "-certfile")) {
			if (!args[1])
				goto argerr;
			certfile = *++args;
		} else if (!strcmp(*args, "-CAfile")) {
			if (!args[1])
				goto argerr;
			CAfile = *++args;
		} else if (!strcmp(*args, "-CApath")) {
			if (!args[1])
				goto argerr;
			CApath = *++args;
		} else if (!strcmp(*args, "-in")) {
			if (!args[1])
				goto argerr;
			infile = *++args;
		} else if (!strcmp(*args, "-inform")) {
			if (!args[1])
				goto argerr;
			informat = str2fmt(*++args);
		} else if (!strcmp(*args, "-outform")) {
			if (!args[1])
				goto argerr;
			outformat = str2fmt(*++args);
		} else if (!strcmp(*args, "-out")) {
			if (!args[1])
				goto argerr;
			outfile = *++args;
		} else if (!strcmp(*args, "-content")) {
			if (!args[1])
				goto argerr;
			contfile = *++args;
		} else if (args_verify(&args, NULL, &badarg, bio_err, &vpm))
			continue;
		else if ((cipher = EVP_get_cipherbyname(*args + 1)) == NULL)
			badarg = 1;
		args++;
	}

	if (((rr_allorfirst != -1) || rr_from) && !rr_to) {
		BIO_puts(bio_err, "No Signed Receipts Recipients\n");
		goto argerr;
	}
	if (!(operation & SMIME_SIGNERS) && (rr_to || rr_from)) {
		BIO_puts(bio_err, "Signed receipts only allowed with -sign\n");
		goto argerr;
	}
	if (!(operation & SMIME_SIGNERS) && (skkeys || sksigners)) {
		BIO_puts(bio_err, "Multiple signers or keys not allowed\n");
		goto argerr;
	}
	if (operation & SMIME_SIGNERS) {
		if (keyfile && !signerfile) {
			BIO_puts(bio_err, "Illegal -inkey without -signer\n");
			goto argerr;
		}
		/* Check to see if any final signer needs to be appended */
		if (signerfile) {
			if (!sksigners)
				sksigners = sk_OPENSSL_STRING_new_null();
			sk_OPENSSL_STRING_push(sksigners, signerfile);
			if (!skkeys)
				skkeys = sk_OPENSSL_STRING_new_null();
			if (!keyfile)
				keyfile = signerfile;
			sk_OPENSSL_STRING_push(skkeys, keyfile);
		}
		if (!sksigners) {
			BIO_printf(bio_err,
			    "No signer certificate specified\n");
			badarg = 1;
		}
		signerfile = NULL;
		keyfile = NULL;
	} else if (operation == SMIME_DECRYPT) {
		if (!recipfile && !keyfile && !secret_key && !pwri_pass) {
			BIO_printf(bio_err,
			    "No recipient certificate or key specified\n");
			badarg = 1;
		}
	} else if (operation == SMIME_ENCRYPT) {
		if (!*args && !secret_key && !pwri_pass) {
			BIO_printf(bio_err,
			    "No recipient(s) certificate(s) specified\n");
			badarg = 1;
		}
	} else if (!operation)
		badarg = 1;

	if (badarg) {
argerr:
		BIO_printf(bio_err, "Usage cms [options] cert.pem ...\n");
		BIO_printf(bio_err, "where options are\n");
		BIO_printf(bio_err, "-encrypt       encrypt message\n");
		BIO_printf(bio_err, "-decrypt       decrypt encrypted message\n");
		BIO_printf(bio_err, "-sign          sign message\n");
		BIO_printf(bio_err, "-verify        verify signed message\n");
		BIO_printf(bio_err, "-cmsout        output CMS structure\n");
#ifndef OPENSSL_NO_DES
		BIO_printf(bio_err, "-des3          encrypt with triple DES\n");
		BIO_printf(bio_err, "-des           encrypt with DES\n");
#endif
#ifndef OPENSSL_NO_RC2
		BIO_printf(bio_err, "-rc2-40        encrypt with RC2-40 (default)\n");
		BIO_printf(bio_err, "-rc2-64        encrypt with RC2-64\n");
		BIO_printf(bio_err, "-rc2-128       encrypt with RC2-128\n");
#endif
#ifndef OPENSSL_NO_AES
		BIO_printf(bio_err, "-aes128, -aes192, -aes256\n");
		BIO_printf(bio_err, "               encrypt PEM output with cbc aes\n");
#endif
#ifndef OPENSSL_NO_CAMELLIA
		BIO_printf(bio_err, "-camellia128, -camellia192, -camellia256\n");
		BIO_printf(bio_err, "               encrypt PEM output with cbc camellia\n");
#endif
		BIO_printf(bio_err, "-nointern      don't search certificates in message for signer\n");
		BIO_printf(bio_err, "-nosigs        don't verify message signature\n");
		BIO_printf(bio_err, "-noverify      don't verify signers certificate\n");
		BIO_printf(bio_err, "-nocerts       don't include signers certificate when signing\n");
		BIO_printf(bio_err, "-nodetach      use opaque signing\n");
		BIO_printf(bio_err, "-noattr        don't include any signed attributes\n");
		BIO_printf(bio_err, "-binary        don't translate message to text\n");
		BIO_printf(bio_err, "-certfile file other certificates file\n");
		BIO_printf(bio_err, "-certsout file certificate output file\n");
		BIO_printf(bio_err, "-signer file   signer certificate file\n");
		BIO_printf(bio_err, "-recip  file   recipient certificate file for decryption\n");
		BIO_printf(bio_err, "-keyid         use subject key identifier\n");
		BIO_printf(bio_err, "-in file       input file\n");
		BIO_printf(bio_err, "-inform arg    input format SMIME (default), PEM or DER\n");
		BIO_printf(bio_err, "-inkey file    input private key (if not signer or recipient)\n");
		BIO_printf(bio_err, "-keyform arg   input private key format (PEM or ENGINE)\n");
		BIO_printf(bio_err, "-out file      output file\n");
		BIO_printf(bio_err, "-outform arg   output format SMIME (default), PEM or DER\n");
		BIO_printf(bio_err, "-content file  supply or override content for detached signature\n");
		BIO_printf(bio_err, "-to addr       to address\n");
		BIO_printf(bio_err, "-from ad       from address\n");
		BIO_printf(bio_err, "-subject s     subject\n");
		BIO_printf(bio_err, "-text          include or delete text MIME headers\n");
		BIO_printf(bio_err, "-CApath dir    trusted certificates directory\n");
		BIO_printf(bio_err, "-CAfile file   trusted certificates file\n");
		BIO_printf(bio_err, "-crl_check     check revocation status of signer's certificate using CRLs\n");
		BIO_printf(bio_err, "-crl_check_all check revocation status of signer's certificate chain using CRLs\n");
#ifndef OPENSSL_NO_ENGINE
		BIO_printf(bio_err, "-engine e      use engine e, possibly a hardware device.\n");
#endif
		BIO_printf(bio_err, "-passin arg    input file pass phrase source\n");
		BIO_printf(bio_err, "cert.pem       recipient certificate(s) for encryption\n");
		goto end;
	}
#ifndef OPENSSL_NO_ENGINE
	e = setup_engine(bio_err, engine, 0);
#endif

	if (!app_passwd(bio_err, passargin, NULL, &passin, NULL)) {
		BIO_printf(bio_err, "Error getting password\n");
		goto end;
	}
	ret = 2;

	if (!(operation & SMIME_SIGNERS))
		flags &= ~CMS_DETACHED;

	if (operation & SMIME_OP) {
		if (outformat == FORMAT_ASN1)
			outmode = "wb";
	} else {
		if (flags & CMS_BINARY)
			outmode = "wb";
	}

	if (operation & SMIME_IP) {
		if (informat == FORMAT_ASN1)
			inmode = "rb";
	} else {
		if (flags & CMS_BINARY)
			inmode = "rb";
	}

	if (operation == SMIME_ENCRYPT) {
		if (!cipher) {
#ifndef OPENSSL_NO_DES
			cipher = EVP_des_ede3_cbc();
#else
			BIO_printf(bio_err, "No cipher selected\n");
			goto end;
#endif
		}
		if (secret_key && !secret_keyid) {
			BIO_printf(bio_err, "No secret key id\n");
			goto end;
		}
		if (*args)
			encerts = sk_X509_new_null();
		while (*args) {
			if (!(cert = load_cert(bio_err, *args, FORMAT_PEM,
			    NULL, e, "recipient certificate file")))
				goto end;
			sk_X509_push(encerts, cert);
			cert = NULL;
			args++;
		}
	}
	if (certfile) {
		if (!(other = load_certs(bio_err, certfile, FORMAT_PEM, NULL,
		    e, "certificate file"))) {
			ERR_print_errors(bio_err);
			goto end;
		}
	}
	if (recipfile && (operation == SMIME_DECRYPT)) {
		if (!(recip = load_cert(bio_err, recipfile, FORMAT_PEM, NULL,
		    e, "recipient certificate file"))) {
			ERR_print_errors(bio_err);
			goto end;
		}
	}
	if (operation == SMIME_SIGN_RECEIPT) {
		if (!(signer = load_cert(bio_err, signerfile, FORMAT_PEM, NULL,
		    e, "receipt signer certificate file"))) {
			ERR_print_errors(bio_err);
			goto end;
		}
	}
	if (operation == SMIME_DECRYPT) {
		if (!keyfile)
			keyfile = recipfile;
	} else if ((operation == SMIME_SIGN) ||
	    (operation == SMIME_SIGN_RECEIPT)) {
		if (!keyfile)
			keyfile = signerfile;
	} else
		keyfile = NULL;

	if (keyfile) {
		key = load_key(bio_err, keyfile, keyform, 0, passin, e,
		    "signing key file");
		if (!key)
			goto end;
	}
	if (infile) {
		if (!(in = BIO_new_file(infile, inmode))) {
			BIO_printf(bio_err,
			    "Can't open input file %s\n", infile);
			goto end;
		}
	} else
		in = BIO_new_fp(stdin, BIO_NOCLOSE);

	if (operation & SMIME_IP) {
		if (informat == FORMAT_SMIME)
			cms = SMIME_read_CMS(in, &indata);
		else if (informat == FORMAT_PEM)
			cms = PEM_read_bio_CMS(in, NULL, NULL, NULL);
		else if (informat == FORMAT_ASN1)
			cms = d2i_CMS_bio(in, NULL);
		else {
			BIO_printf(bio_err, "Bad input format for CMS file\n");
			goto end;
		}

		if (!cms) {
			BIO_printf(bio_err, "Error reading S/MIME message\n");
			goto end;
		}
		if (contfile) {
			BIO_free(indata);
			if (!(indata = BIO_new_file(contfile, "rb"))) {
				BIO_printf(bio_err,
				    "Can't read content file %s\n", contfile);
				goto end;
			}
		}
		if (certsoutfile) {
			STACK_OF(X509) * allcerts;
			allcerts = CMS_get1_certs(cms);
			if (!save_certs(certsoutfile, allcerts)) {
				BIO_printf(bio_err,
				    "Error writing certs to %s\n",
				    certsoutfile);
				ret = 5;
				goto end;
			}
			sk_X509_pop_free(allcerts, X509_free);
		}
	}
	if (rctfile) {
		char *rctmode = (rctformat == FORMAT_ASN1) ? "rb" : "r";
		if (!(rctin = BIO_new_file(rctfile, rctmode))) {
			BIO_printf(bio_err,
			    "Can't open receipt file %s\n", rctfile);
			goto end;
		}
		if (rctformat == FORMAT_SMIME)
			rcms = SMIME_read_CMS(rctin, NULL);
		else if (rctformat == FORMAT_PEM)
			rcms = PEM_read_bio_CMS(rctin, NULL, NULL, NULL);
		else if (rctformat == FORMAT_ASN1)
			rcms = d2i_CMS_bio(rctin, NULL);
		else {
			BIO_printf(bio_err, "Bad input format for receipt\n");
			goto end;
		}

		if (!rcms) {
			BIO_printf(bio_err, "Error reading receipt\n");
			goto end;
		}
	}
	if (outfile) {
		if (!(out = BIO_new_file(outfile, outmode))) {
			BIO_printf(bio_err,
			    "Can't open output file %s\n", outfile);
			goto end;
		}
	} else {
		out = BIO_new_fp(stdout, BIO_NOCLOSE);
	}

	if ((operation == SMIME_VERIFY) ||
	    (operation == SMIME_VERIFY_RECEIPT)) {
		if (!(store = setup_verify(bio_err, CAfile, CApath)))
			goto end;
		X509_STORE_set_verify_cb(store, cms_cb);
		if (vpm)
			X509_STORE_set1_param(store, vpm);
	}
	ret = 3;

	if (operation == SMIME_DATA_CREATE) {
		cms = CMS_data_create(in, flags);
	} else if (operation == SMIME_DIGEST_CREATE) {
		cms = CMS_digest_create(in, sign_md, flags);
	} else if (operation == SMIME_COMPRESS) {
		cms = CMS_compress(in, -1, flags);
	} else if (operation == SMIME_ENCRYPT) {
		flags |= CMS_PARTIAL;
		cms = CMS_encrypt(encerts, in, cipher, flags);
		if (!cms)
			goto end;
		if (secret_key) {
			if (!CMS_add0_recipient_key(cms, NID_undef, secret_key,
			    secret_keylen, secret_keyid, secret_keyidlen,
			    NULL, NULL, NULL))
				goto end;
			/* NULL these because call absorbs them */
			secret_key = NULL;
			secret_keyid = NULL;
		}
		if (pwri_pass) {
			pwri_tmp =
			    (unsigned char *)BUF_strdup((char *)pwri_pass);
			if (!pwri_tmp)
				goto end;
			if (!CMS_add0_recipient_password(cms, -1, NID_undef,
			    NID_undef, pwri_tmp, -1, NULL))
				goto end;
			pwri_tmp = NULL;
		}
		if (!(flags & CMS_STREAM)) {
			if (!CMS_final(cms, in, NULL, flags))
				goto end;
		}
	} else if (operation == SMIME_ENCRYPTED_ENCRYPT) {
		cms = CMS_EncryptedData_encrypt(in, cipher, secret_key,
		    secret_keylen, flags);

	} else if (operation == SMIME_SIGN_RECEIPT) {
		CMS_ContentInfo *srcms = NULL;
		STACK_OF(CMS_SignerInfo) * sis;
		CMS_SignerInfo *si;
		sis = CMS_get0_SignerInfos(cms);
		if (!sis)
			goto end;
		si = sk_CMS_SignerInfo_value(sis, 0);
		srcms = CMS_sign_receipt(si, signer, key, other, flags);
		if (!srcms)
			goto end;
		CMS_ContentInfo_free(cms);
		cms = srcms;
	} else if (operation & SMIME_SIGNERS) {
		int i;
		/*
		 * If detached data content we enable streaming if S/MIME
		 * output format.
		 */
		if (operation == SMIME_SIGN) {

			if (flags & CMS_DETACHED) {
				if (outformat == FORMAT_SMIME)
					flags |= CMS_STREAM;
			}
			flags |= CMS_PARTIAL;
			cms = CMS_sign(NULL, NULL, other, in, flags);
			if (!cms)
				goto end;
			if (econtent_type)
				CMS_set1_eContentType(cms, econtent_type);

			if (rr_to) {
				rr = make_receipt_request(rr_to, rr_allorfirst,
				    rr_from);
				if (!rr) {
					BIO_puts(bio_err,
					    "Signed Receipt Request Creation Error\n");
					goto end;
				}
			}
		} else
			flags |= CMS_REUSE_DIGEST;
		for (i = 0; i < sk_OPENSSL_STRING_num(sksigners); i++) {
			CMS_SignerInfo *si;
			signerfile = sk_OPENSSL_STRING_value(sksigners, i);
			keyfile = sk_OPENSSL_STRING_value(skkeys, i);
			signer = load_cert(bio_err, signerfile, FORMAT_PEM,
			    NULL, e, "signer certificate");
			if (!signer)
				goto end;
			key = load_key(bio_err, keyfile, keyform, 0, passin, e,
			    "signing key file");
			if (!key)
				goto end;
			si = CMS_add1_signer(cms, signer, key, sign_md, flags);
			if (!si)
				goto end;
			if (rr && !CMS_add1_ReceiptRequest(si, rr))
				goto end;
			X509_free(signer);
			signer = NULL;
			EVP_PKEY_free(key);
			key = NULL;
		}
		/* If not streaming or resigning finalize structure */
		if ((operation == SMIME_SIGN) && !(flags & CMS_STREAM)) {
			if (!CMS_final(cms, in, NULL, flags))
				goto end;
		}
	}
	if (!cms) {
		BIO_printf(bio_err, "Error creating CMS structure\n");
		goto end;
	}
	ret = 4;
	if (operation == SMIME_DECRYPT) {
		if (flags & CMS_DEBUG_DECRYPT)
			CMS_decrypt(cms, NULL, NULL, NULL, NULL, flags);

		if (secret_key) {
			if (!CMS_decrypt_set1_key(cms, secret_key,
			    secret_keylen, secret_keyid, secret_keyidlen)) {
				BIO_puts(bio_err,
				    "Error decrypting CMS using secret key\n");
				goto end;
			}
		}
		if (key) {
			if (!CMS_decrypt_set1_pkey(cms, key, recip)) {
				BIO_puts(bio_err,
				    "Error decrypting CMS using private key\n");
				goto end;
			}
		}
		if (pwri_pass) {
			if (!CMS_decrypt_set1_password(cms, pwri_pass, -1)) {
				BIO_puts(bio_err,
				    "Error decrypting CMS using password\n");
				goto end;
			}
		}
		if (!CMS_decrypt(cms, NULL, NULL, indata, out, flags)) {
			BIO_printf(bio_err, "Error decrypting CMS structure\n");
			goto end;
		}
	} else if (operation == SMIME_DATAOUT) {
		if (!CMS_data(cms, out, flags))
			goto end;
	} else if (operation == SMIME_UNCOMPRESS) {
		if (!CMS_uncompress(cms, indata, out, flags))
			goto end;
	} else if (operation == SMIME_DIGEST_VERIFY) {
		if (CMS_digest_verify(cms, indata, out, flags) > 0)
			BIO_printf(bio_err, "Verification successful\n");
		else {
			BIO_printf(bio_err, "Verification failure\n");
			goto end;
		}
	} else if (operation == SMIME_ENCRYPTED_DECRYPT) {
		if (!CMS_EncryptedData_decrypt(cms, secret_key, secret_keylen,
		    indata, out, flags))
			goto end;
	} else if (operation == SMIME_VERIFY) {
		if (CMS_verify(cms, other, store, indata, out, flags) > 0)
			BIO_printf(bio_err, "Verification successful\n");
		else {
			BIO_printf(bio_err, "Verification failure\n");
			if (verify_retcode)
				ret = verify_err + 32;
			goto end;
		}
		if (signerfile) {
			STACK_OF(X509) * signers;
			signers = CMS_get0_signers(cms);
			if (!save_certs(signerfile, signers)) {
				BIO_printf(bio_err,
				    "Error writing signers to %s\n",
				    signerfile);
				ret = 5;
				goto end;
			}
			sk_X509_free(signers);
		}
		if (rr_print)
			receipt_request_print(bio_err, cms);

	} else if (operation == SMIME_VERIFY_RECEIPT) {
		if (CMS_verify_receipt(rcms, cms, other, store, flags) > 0)
			BIO_printf(bio_err, "Verification successful\n");
		else {
			BIO_printf(bio_err, "Verification failure\n");
			goto end;
		}
	} else {
		if (noout) {
			if (print)
				CMS_ContentInfo_print_ctx(out, cms, 0, NULL);
		} else if (outformat == FORMAT_SMIME) {
			if (to)
				BIO_printf(out, "To: %s\n", to);
			if (from)
				BIO_printf(out, "From: %s\n", from);
			if (subject)
				BIO_printf(out, "Subject: %s\n", subject);
			if (operation == SMIME_RESIGN)
				ret = SMIME_write_CMS(out, cms, indata, flags);
			else
				ret = SMIME_write_CMS(out, cms, in, flags);
		} else if (outformat == FORMAT_PEM)
			ret = PEM_write_bio_CMS_stream(out, cms, in, flags);
		else if (outformat == FORMAT_ASN1)
			ret = i2d_CMS_bio_stream(out, cms, in, flags);
		else {
			BIO_printf(bio_err, "Bad output format for CMS file\n");
			goto end;
		}
		if (ret <= 0) {
			ret = 6;
			goto end;
		}
	}
	ret = 0;

end:
	if (ret)
		ERR_print_errors(bio_err);
	sk_X509_pop_free(encerts, X509_free);
	sk_X509_pop_free(other, X509_free);
	if (vpm)
		X509_VERIFY_PARAM_free(vpm);
	if (sksigners)
		sk_OPENSSL_STRING_free(sksigners);
	if (skkeys)
		sk_OPENSSL_STRING_free(skkeys);
	free(secret_key);
	free(secret_keyid);
	free(pwri_tmp);
	if (econtent_type)
		ASN1_OBJECT_free(econtent_type);
	if (rr)
		CMS_ReceiptRequest_free(rr);
	if (rr_to)
		sk_OPENSSL_STRING_free(rr_to);
	if (rr_from)
		sk_OPENSSL_STRING_free(rr_from);
	X509_STORE_free(store);
	X509_free(cert);
	X509_free(recip);
	X509_free(signer);
	EVP_PKEY_free(key);
	CMS_ContentInfo_free(cms);
	CMS_ContentInfo_free(rcms);
	BIO_free(rctin);
	BIO_free(in);
	BIO_free(indata);
	BIO_free_all(out);
	free(passin);
	return (ret);
}

static int
save_certs(char *signerfile, STACK_OF(X509) * signers)
{
	int i;
	BIO *tmp;

	if (!signerfile)
		return 1;
	tmp = BIO_new_file(signerfile, "w");
	if (!tmp)
		return 0;
	for (i = 0; i < sk_X509_num(signers); i++)
		PEM_write_bio_X509(tmp, sk_X509_value(signers, i));
	BIO_free(tmp);
	return 1;
}

/* Minimal callback just to output policy info (if any) */

static int
cms_cb(int ok, X509_STORE_CTX * ctx)
{
	int error;

	error = X509_STORE_CTX_get_error(ctx);

	verify_err = error;

	if ((error != X509_V_ERR_NO_EXPLICIT_POLICY) &&
	    ((error != X509_V_OK) || (ok != 2)))
		return ok;

	policies_print(NULL, ctx);

	return ok;
}

static void
gnames_stack_print(BIO * out, STACK_OF(GENERAL_NAMES) * gns)
{
	STACK_OF(GENERAL_NAME) * gens;
	GENERAL_NAME *gen;
	int i, j;

	for (i = 0; i < sk_GENERAL_NAMES_num(gns); i++) {
		gens = sk_GENERAL_NAMES_value(gns, i);
		for (j = 0; j < sk_GENERAL_NAME_num(gens); j++) {
			gen = sk_GENERAL_NAME_value(gens, j);
			BIO_puts(out, "    ");
			GENERAL_NAME_print(out, gen);
			BIO_puts(out, "\n");
		}
	}
	return;
}

static void
receipt_request_print(BIO * out, CMS_ContentInfo * cms)
{
	STACK_OF(CMS_SignerInfo) * sis;
	CMS_SignerInfo *si;
	CMS_ReceiptRequest *rr;
	int allorfirst;
	STACK_OF(GENERAL_NAMES) * rto, *rlist;
	ASN1_STRING *scid;
	int i, rv;

	sis = CMS_get0_SignerInfos(cms);
	for (i = 0; i < sk_CMS_SignerInfo_num(sis); i++) {
		si = sk_CMS_SignerInfo_value(sis, i);
		rv = CMS_get1_ReceiptRequest(si, &rr);
		BIO_printf(bio_err, "Signer %d:\n", i + 1);
		if (rv == 0)
			BIO_puts(bio_err, "  No Receipt Request\n");
		else if (rv < 0) {
			BIO_puts(bio_err, "  Receipt Request Parse Error\n");
			ERR_print_errors(bio_err);
		} else {
			char *id;
			int idlen;
			CMS_ReceiptRequest_get0_values(rr, &scid, &allorfirst,
			    &rlist, &rto);
			BIO_puts(out, "  Signed Content ID:\n");
			idlen = ASN1_STRING_length(scid);
			id = (char *) ASN1_STRING_data(scid);
			BIO_dump_indent(out, id, idlen, 4);
			BIO_puts(out, "  Receipts From");
			if (rlist) {
				BIO_puts(out, " List:\n");
				gnames_stack_print(out, rlist);
			} else if (allorfirst == 1)
				BIO_puts(out, ": First Tier\n");
			else if (allorfirst == 0)
				BIO_puts(out, ": All\n");
			else
				BIO_printf(out, " Unknown (%d)\n", allorfirst);
			BIO_puts(out, "  Receipts To:\n");
			gnames_stack_print(out, rto);
		}
		if (rr)
			CMS_ReceiptRequest_free(rr);
	}
}

static STACK_OF(GENERAL_NAMES) *
make_names_stack(STACK_OF(OPENSSL_STRING) * ns)
{
	int i;
	STACK_OF(GENERAL_NAMES) * ret;
	GENERAL_NAMES *gens = NULL;
	GENERAL_NAME *gen = NULL;
	ret = sk_GENERAL_NAMES_new_null();
	if (!ret)
		goto err;
	for (i = 0; i < sk_OPENSSL_STRING_num(ns); i++) {
		char *str = sk_OPENSSL_STRING_value(ns, i);
		gen = a2i_GENERAL_NAME(NULL, NULL, NULL, GEN_EMAIL, str, 0);
		if (!gen)
			goto err;
		gens = GENERAL_NAMES_new();
		if (!gens)
			goto err;
		if (!sk_GENERAL_NAME_push(gens, gen))
			goto err;
		gen = NULL;
		if (!sk_GENERAL_NAMES_push(ret, gens))
			goto err;
		gens = NULL;
	}

	return ret;

err:
	if (ret)
		sk_GENERAL_NAMES_pop_free(ret, GENERAL_NAMES_free);
	if (gens)
		GENERAL_NAMES_free(gens);
	if (gen)
		GENERAL_NAME_free(gen);
	return NULL;
}


static CMS_ReceiptRequest *
make_receipt_request(STACK_OF(OPENSSL_STRING) * rr_to, int rr_allorfirst,
    STACK_OF(OPENSSL_STRING) * rr_from)
{
	STACK_OF(GENERAL_NAMES) * rct_to, *rct_from;
	CMS_ReceiptRequest *rr;

	rct_to = make_names_stack(rr_to);
	if (!rct_to)
		goto err;
	if (rr_from) {
		rct_from = make_names_stack(rr_from);
		if (!rct_from)
			goto err;
	} else
		rct_from = NULL;
	rr = CMS_ReceiptRequest_create0(NULL, -1, rr_allorfirst, rct_from,
	    rct_to);
	return rr;

err:
	return NULL;
}

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/apps/genrsa.c0000644000175000017500000002067112360020706017330 0ustar  /* $OpenBSD: genrsa.c,v 1.34 2014/07/09 09:06:58 bcook Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#include 

/* Until the key-gen callbacks are modified to use newer prototypes, we allow
 * deprecated functions for openssl-internal code */
#ifdef OPENSSL_NO_DEPRECATED
#undef OPENSSL_NO_DEPRECATED
#endif


#include 
#include 

#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define DEFBITS	2048

static int genrsa_cb(int p, int n, BN_GENCB * cb);

int genrsa_main(int, char **);

int
genrsa_main(int argc, char **argv)
{
	BN_GENCB cb;
#ifndef OPENSSL_NO_ENGINE
	ENGINE *e = NULL;
#endif
	int ret = 1;
	int i, num = DEFBITS;
	long l;
	const EVP_CIPHER *enc = NULL;
	unsigned long f4 = RSA_F4;
	char *outfile = NULL;
	char *passargout = NULL, *passout = NULL;
#ifndef OPENSSL_NO_ENGINE
	char *engine = NULL;
#endif
	BIO *out = NULL;
	BIGNUM *bn = BN_new();
	RSA *rsa = NULL;

	if (!bn)
		goto err;

	BN_GENCB_set(&cb, genrsa_cb, bio_err);

	if (!load_config(bio_err, NULL))
		goto err;

	if ((out = BIO_new(BIO_s_file())) == NULL) {
		BIO_printf(bio_err, "unable to create BIO for output\n");
		goto err;
	}
	argv++;
	argc--;
	for (;;) {
		if (argc <= 0)
			break;
		if (strcmp(*argv, "-out") == 0) {
			if (--argc < 1)
				goto bad;
			outfile = *(++argv);
		} else if (strcmp(*argv, "-3") == 0)
			f4 = 3;
		else if (strcmp(*argv, "-F4") == 0 || strcmp(*argv, "-f4") == 0)
			f4 = RSA_F4;
#ifndef OPENSSL_NO_ENGINE
		else if (strcmp(*argv, "-engine") == 0) {
			if (--argc < 1)
				goto bad;
			engine = *(++argv);
		}
#endif
#ifndef OPENSSL_NO_DES
		else if (strcmp(*argv, "-des") == 0)
			enc = EVP_des_cbc();
		else if (strcmp(*argv, "-des3") == 0)
			enc = EVP_des_ede3_cbc();
#endif
#ifndef OPENSSL_NO_IDEA
		else if (strcmp(*argv, "-idea") == 0)
			enc = EVP_idea_cbc();
#endif
#ifndef OPENSSL_NO_AES
		else if (strcmp(*argv, "-aes128") == 0)
			enc = EVP_aes_128_cbc();
		else if (strcmp(*argv, "-aes192") == 0)
			enc = EVP_aes_192_cbc();
		else if (strcmp(*argv, "-aes256") == 0)
			enc = EVP_aes_256_cbc();
#endif
#ifndef OPENSSL_NO_CAMELLIA
		else if (strcmp(*argv, "-camellia128") == 0)
			enc = EVP_camellia_128_cbc();
		else if (strcmp(*argv, "-camellia192") == 0)
			enc = EVP_camellia_192_cbc();
		else if (strcmp(*argv, "-camellia256") == 0)
			enc = EVP_camellia_256_cbc();
#endif
		else if (strcmp(*argv, "-passout") == 0) {
			if (--argc < 1)
				goto bad;
			passargout = *(++argv);
		} else
			break;
		argv++;
		argc--;
	}
	if ((argc >= 1) && ((sscanf(*argv, "%d", &num) == 0) || (num < 0))) {
bad:
		BIO_printf(bio_err, "usage: genrsa [args] [numbits]\n");
		BIO_printf(bio_err, " -des            encrypt the generated key with DES in cbc mode\n");
		BIO_printf(bio_err, " -des3           encrypt the generated key with DES in ede cbc mode (168 bit key)\n");
#ifndef OPENSSL_NO_IDEA
		BIO_printf(bio_err, " -idea           encrypt the generated key with IDEA in cbc mode\n");
#endif
#ifndef OPENSSL_NO_AES
		BIO_printf(bio_err, " -aes128, -aes192, -aes256\n");
		BIO_printf(bio_err, "                 encrypt PEM output with cbc aes\n");
#endif
#ifndef OPENSSL_NO_CAMELLIA
		BIO_printf(bio_err, " -camellia128, -camellia192, -camellia256\n");
		BIO_printf(bio_err, "                 encrypt PEM output with cbc camellia\n");
#endif
		BIO_printf(bio_err, " -out file       output the key to 'file\n");
		BIO_printf(bio_err, " -passout arg    output file pass phrase source\n");
		BIO_printf(bio_err, " -f4             use F4 (0x10001) for the E value\n");
		BIO_printf(bio_err, " -3              use 3 for the E value\n");
#ifndef OPENSSL_NO_ENGINE
		BIO_printf(bio_err, " -engine e       use engine e, possibly a hardware device.\n");
#endif
		goto err;
	}
	ERR_load_crypto_strings();

	if (!app_passwd(bio_err, NULL, passargout, NULL, &passout)) {
		BIO_printf(bio_err, "Error getting password\n");
		goto err;
	}
#ifndef OPENSSL_NO_ENGINE
	e = setup_engine(bio_err, engine, 0);
#endif

	if (outfile == NULL) {
		BIO_set_fp(out, stdout, BIO_NOCLOSE);
	} else {
		if (BIO_write_filename(out, outfile) <= 0) {
			perror(outfile);
			goto err;
		}
	}

	BIO_printf(bio_err, "Generating RSA private key, %d bit long modulus\n",
	    num);
#ifdef OPENSSL_NO_ENGINE
	rsa = RSA_new();
#else
	rsa = RSA_new_method(e);
#endif
	if (!rsa)
		goto err;

	if (!BN_set_word(bn, f4) || !RSA_generate_key_ex(rsa, num, bn, &cb))
		goto err;

	/*
	 * We need to do the following for when the base number size is <
	 * long, esp windows 3.1 :-(.
	 */
	l = 0L;
	for (i = 0; i < rsa->e->top; i++) {
#ifndef _LP64
		l <<= BN_BITS4;
		l <<= BN_BITS4;
#endif
		l += rsa->e->d[i];
	}
	BIO_printf(bio_err, "e is %ld (0x%lX)\n", l, l);
	{
		PW_CB_DATA cb_data;
		cb_data.password = passout;
		cb_data.prompt_info = outfile;
		if (!PEM_write_bio_RSAPrivateKey(out, rsa, enc, NULL, 0,
			password_callback, &cb_data))
			goto err;
	}

	ret = 0;
err:
	if (bn)
		BN_free(bn);
	if (rsa)
		RSA_free(rsa);
	if (out)
		BIO_free_all(out);
	free(passout);
	if (ret != 0)
		ERR_print_errors(bio_err);
	
	return (ret);
}

static int
genrsa_cb(int p, int n, BN_GENCB * cb)
{
	char c = '*';

	if (p == 0)
		c = '.';
	if (p == 1)
		c = '+';
	if (p == 2)
		c = '*';
	if (p == 3)
		c = '\n';
	BIO_write(cb->arg, &c, 1);
	(void) BIO_flush(cb->arg);
	return 1;
}
deps/libressl-pnacl-sys-2.1.6/libressl/apps/pkcs7.c0000644000175000017500000002006012360020706017070 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#include 
#include 
#include 
#include 

#include "apps.h"

#include 
#include 
#include 
#include 
#include 
#include 

/* -inform arg	- input format - default PEM (DER or PEM)
 * -outform arg - output format - default PEM
 * -in arg	- input file - default stdin
 * -out arg	- output file - default stdout
 * -print_certs
 */

int pkcs7_main(int, char **);

int 
pkcs7_main(int argc, char **argv)
{
	PKCS7 *p7 = NULL;
	int i, badops = 0;
	BIO *in = NULL, *out = NULL;
	int informat, outformat;
	char *infile, *outfile, *prog;
	int print_certs = 0, text = 0, noout = 0, p7_print = 0;
	int ret = 1;
#ifndef OPENSSL_NO_ENGINE
	char *engine = NULL;
#endif

	if (!load_config(bio_err, NULL))
		goto end;

	infile = NULL;
	outfile = NULL;
	informat = FORMAT_PEM;
	outformat = FORMAT_PEM;

	prog = argv[0];
	argc--;
	argv++;
	while (argc >= 1) {
		if (strcmp(*argv, "-inform") == 0) {
			if (--argc < 1)
				goto bad;
			informat = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-outform") == 0) {
			if (--argc < 1)
				goto bad;
			outformat = str2fmt(*(++argv));
		} else if (strcmp(*argv, "-in") == 0) {
			if (--argc < 1)
				goto bad;
			infile = *(++argv);
		} else if (strcmp(*argv, "-out") == 0) {
			if (--argc < 1)
				goto bad;
			outfile = *(++argv);
		} else if (strcmp(*argv, "-noout") == 0)
			noout = 1;
		else if (strcmp(*argv, "-text") == 0)
			text = 1;
		else if (strcmp(*argv, "-print") == 0)
			p7_print = 1;
		else if (strcmp(*argv, "-print_certs") == 0)
			print_certs = 1;
#ifndef OPENSSL_NO_ENGINE
		else if (strcmp(*argv, "-engine") == 0) {
			if (--argc < 1)
				goto bad;
			engine = *(++argv);
		}
#endif
		else {
			BIO_printf(bio_err, "unknown option %s\n", *argv);
			badops = 1;
			break;
		}
		argc--;
		argv++;
	}

	if (badops) {
bad:
		BIO_printf(bio_err, "%s [options] outfile\n", prog);
		BIO_printf(bio_err, "where options are\n");
		BIO_printf(bio_err, " -inform arg   input format - DER or PEM\n");
		BIO_printf(bio_err, " -outform arg  output format - DER or PEM\n");
		BIO_printf(bio_err, " -in arg       input file\n");
		BIO_printf(bio_err, " -out arg      output file\n");
		BIO_printf(bio_err, " -print_certs  print any certs or crl in the input\n");
		BIO_printf(bio_err, " -text         print full details of certificates\n");
		BIO_printf(bio_err, " -noout        don't output encoded data\n");
#ifndef OPENSSL_NO_ENGINE
		BIO_printf(bio_err, " -engine e     use engine e, possibly a hardware device.\n");
#endif
		ret = 1;
		goto end;
	}
	ERR_load_crypto_strings();

#ifndef OPENSSL_NO_ENGINE
	setup_engine(bio_err, engine, 0);
#endif

	in = BIO_new(BIO_s_file());
	out = BIO_new(BIO_s_file());
	if ((in == NULL) || (out == NULL)) {
		ERR_print_errors(bio_err);
		goto end;
	}
	if (infile == NULL)
		BIO_set_fp(in, stdin, BIO_NOCLOSE);
	else {
		if (BIO_read_filename(in, infile) <= 0)
			if (in == NULL) {
				perror(infile);
				goto end;
			}
	}

	if (informat == FORMAT_ASN1)
		p7 = d2i_PKCS7_bio(in, NULL);
	else if (informat == FORMAT_PEM)
		p7 = PEM_read_bio_PKCS7(in, NULL, NULL, NULL);
	else {
		BIO_printf(bio_err, "bad input format specified for pkcs7 object\n");
		goto end;
	}
	if (p7 == NULL) {
		BIO_printf(bio_err, "unable to load PKCS7 object\n");
		ERR_print_errors(bio_err);
		goto end;
	}
	if (outfile == NULL) {
		BIO_set_fp(out, stdout, BIO_NOCLOSE);
	} else {
		if (BIO_write_filename(out, outfile) <= 0) {
			perror(outfile);
			goto end;
		}
	}

	if (p7_print)
		PKCS7_print_ctx(out, p7, 0, NULL);

	if (print_certs) {
		STACK_OF(X509) * certs = NULL;
		STACK_OF(X509_CRL) * crls = NULL;

		i = OBJ_obj2nid(p7->type);
		switch (i) {
		case NID_pkcs7_signed:
			certs = p7->d.sign->cert;
			crls = p7->d.sign->crl;
			break;
		case NID_pkcs7_signedAndEnveloped:
			certs = p7->d.signed_and_enveloped->cert;
			crls = p7->d.signed_and_enveloped->crl;
			break;
		default:
			break;
		}

		if (certs != NULL) {
			X509 *x;

			for (i = 0; i < sk_X509_num(certs); i++) {
				x = sk_X509_value(certs, i);
				if (text)
					X509_print(out, x);
				else
					dump_cert_text(out, x);

				if (!noout)
					PEM_write_bio_X509(out, x);
				BIO_puts(out, "\n");
			}
		}
		if (crls != NULL) {
			X509_CRL *crl;

			for (i = 0; i < sk_X509_CRL_num(crls); i++) {
				crl = sk_X509_CRL_value(crls, i);

				X509_CRL_print(out, crl);

				if (!noout)
					PEM_write_bio_X509_CRL(out, crl);
				BIO_puts(out, "\n");
			}
		}
		ret = 0;
		goto end;
	}
	if (!noout) {
		if (outformat == FORMAT_ASN1)
			i = i2d_PKCS7_bio(out, p7);
		else if (outformat == FORMAT_PEM)
			i = PEM_write_bio_PKCS7(out, p7);
		else {
			BIO_printf(bio_err, "bad output format specified for outfile\n");
			goto end;
		}

		if (!i) {
			BIO_printf(bio_err, "unable to write pkcs7 object\n");
			ERR_print_errors(bio_err);
			goto end;
		}
	}
	ret = 0;
end:
	if (p7 != NULL)
		PKCS7_free(p7);
	if (in != NULL)
		BIO_free(in);
	if (out != NULL)
		BIO_free_all(out);
	
	return (ret);
}
deps/libressl-pnacl-sys-2.1.6/libressl/AUTHORS0000644000175000017500000000000012357514212016000 0ustar  deps/libressl-pnacl-sys-2.1.6/libressl/configure0000775000175000017500000152356012433547746016704 0ustar  #! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for libressl 2.0.0.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
#
#
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
## -------------------- ##
## M4sh Initialization. ##
## -------------------- ##

# Be more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
  emulate sh
  NULLCMD=:
  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
  # is contrary to our usage.  Disable this feature.
  alias -g '${1+"$@"}'='"$@"'
  setopt NO_GLOB_SUBST
else
  case `(set -o) 2>/dev/null` in #(
  *posix*) :
    set -o posix ;; #(
  *) :
     ;;
esac
fi


as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
# Prefer a ksh shell builtin over an external printf program on Solaris,
# but without wasting forks for bash or zsh.
if test -z "$BASH_VERSION$ZSH_VERSION" \
    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
  as_echo='print -r --'
  as_echo_n='print -rn --'
elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
  as_echo='printf %s\n'
  as_echo_n='printf %s'
else
  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
    as_echo_n='/usr/ucb/echo -n'
  else
    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
    as_echo_n_body='eval
      arg=$1;
      case $arg in #(
      *"$as_nl"*)
	expr "X$arg" : "X\\(.*\\)$as_nl";
	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
      esac;
      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
    '
    export as_echo_n_body
    as_echo_n='sh -c $as_echo_n_body as_echo'
  fi
  export as_echo_body
  as_echo='sh -c $as_echo_body as_echo'
fi

# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
  PATH_SEPARATOR=:
  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
      PATH_SEPARATOR=';'
  }
fi


# IFS
# We need space, tab and new line, in precisely that order.  Quoting is
# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
IFS=" ""	$as_nl"

# Find who we are.  Look in the path if we contain no directory separator.
as_myself=
case $0 in #((
  *[\\/]* ) as_myself=$0 ;;
  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
  done
IFS=$as_save_IFS

     ;;
esac
# We did not find ourselves, most probably we were run as `sh COMMAND'
# in which case we are not to be found in the path.
if test "x$as_myself" = x; then
  as_myself=$0
fi
if test ! -f "$as_myself"; then
  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
  exit 1
fi

# Unset variables that we do not need and which cause bugs (e.g. in
# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
# suppresses any "Segmentation fault" message there.  '((' could
# trigger a bug in pdksh 5.2.14.
for as_var in BASH_ENV ENV MAIL MAILPATH
do eval test x\${$as_var+set} = xset \
  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
done
PS1='$ '
PS2='> '
PS4='+ '

# NLS nuisances.
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE

# CDPATH.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH

# Use a proper internal environment variable to ensure we don't fall
  # into an infinite loop, continuously re-executing ourselves.
  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
    _as_can_reexec=no; export _as_can_reexec;
    # We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
# Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
case $- in # ((((
  *v*x* | *x*v* ) as_opts=-vx ;;
  *v* ) as_opts=-v ;;
  *x* ) as_opts=-x ;;
  * ) as_opts= ;;
esac
exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
# Admittedly, this is quite paranoid, since all the known shells bail
# out after a failed `exec'.
$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
as_fn_exit 255
  fi
  # We don't want this to propagate to other subprocesses.
          { _as_can_reexec=; unset _as_can_reexec;}
if test "x$CONFIG_SHELL" = x; then
  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
  emulate sh
  NULLCMD=:
  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
  # is contrary to our usage.  Disable this feature.
  alias -g '\${1+\"\$@\"}'='\"\$@\"'
  setopt NO_GLOB_SUBST
else
  case \`(set -o) 2>/dev/null\` in #(
  *posix*) :
    set -o posix ;; #(
  *) :
     ;;
esac
fi
"
  as_required="as_fn_return () { (exit \$1); }
as_fn_success () { as_fn_return 0; }
as_fn_failure () { as_fn_return 1; }
as_fn_ret_success () { return 0; }
as_fn_ret_failure () { return 1; }

exitcode=0
as_fn_success || { exitcode=1; echo as_fn_success failed.; }
as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :

else
  exitcode=1; echo positional parameters were not saved.
fi
test x\$exitcode = x0 || exit 1
test -x / || exit 1"
  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1

  test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || (
    ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
    ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
    ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
    PATH=/empty FPATH=/empty; export PATH FPATH
    test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\
      || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1
test \$(( 1 + 1 )) = 2 || exit 1"
  if (eval "$as_required") 2>/dev/null; then :
  as_have_required=yes
else
  as_have_required=no
fi
  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :

else
  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
as_found=false
for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
  as_found=:
  case $as_dir in #(
	 /*)
	   for as_base in sh bash ksh sh5; do
	     # Try only shells that exist, to save several forks.
	     as_shell=$as_dir/$as_base
	     if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
		    { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
  CONFIG_SHELL=$as_shell as_have_required=yes
		   if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
  break 2
fi
fi
	   done;;
       esac
  as_found=false
done
$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
	      { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
  CONFIG_SHELL=$SHELL as_have_required=yes
fi; }
IFS=$as_save_IFS


      if test "x$CONFIG_SHELL" != x; then :
  export CONFIG_SHELL
             # We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
# Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
case $- in # ((((
  *v*x* | *x*v* ) as_opts=-vx ;;
  *v* ) as_opts=-v ;;
  *x* ) as_opts=-x ;;
  * ) as_opts= ;;
esac
exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
# Admittedly, this is quite paranoid, since all the known shells bail
# out after a failed `exec'.
$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
exit 255
fi

    if test x$as_have_required = xno; then :
  $as_echo "$0: This script requires a shell more modern than all"
  $as_echo "$0: the shells that I found on your system."
  if test x${ZSH_VERSION+set} = xset ; then
    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
  else
    $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
$0: including any error possibly output before this
$0: message. Then install a modern shell, or manually run
$0: the script under such a shell if you do have one."
  fi
  exit 1
fi
fi
fi
SHELL=${CONFIG_SHELL-/bin/sh}
export SHELL
# Unset more variables known to interfere with behavior of common tools.
CLICOLOR_FORCE= GREP_OPTIONS=
unset CLICOLOR_FORCE GREP_OPTIONS

## --------------------- ##
## M4sh Shell Functions. ##
## --------------------- ##
# as_fn_unset VAR
# ---------------
# Portably unset VAR.
as_fn_unset ()
{
  { eval $1=; unset $1;}
}
as_unset=as_fn_unset

# as_fn_set_status STATUS
# -----------------------
# Set $? to STATUS, without forking.
as_fn_set_status ()
{
  return $1
} # as_fn_set_status

# as_fn_exit STATUS
# -----------------
# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
as_fn_exit ()
{
  set +e
  as_fn_set_status $1
  exit $1
} # as_fn_exit

# as_fn_mkdir_p
# -------------
# Create "$as_dir" as a directory, including parents if necessary.
as_fn_mkdir_p ()
{

  case $as_dir in #(
  -*) as_dir=./$as_dir;;
  esac
  test -d "$as_dir" || eval $as_mkdir_p || {
    as_dirs=
    while :; do
      case $as_dir in #(
      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
      *) as_qdir=$as_dir;;
      esac
      as_dirs="'$as_qdir' $as_dirs"
      as_dir=`$as_dirname -- "$as_dir" ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
	 X"$as_dir" : 'X\(//\)[^/]' \| \
	 X"$as_dir" : 'X\(//\)$' \| \
	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_dir" |
    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)[^/].*/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`
      test -d "$as_dir" && break
    done
    test -z "$as_dirs" || eval "mkdir $as_dirs"
  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"


} # as_fn_mkdir_p

# as_fn_executable_p FILE
# -----------------------
# Test if FILE is an executable regular file.
as_fn_executable_p ()
{
  test -f "$1" && test -x "$1"
} # as_fn_executable_p
# as_fn_append VAR VALUE
# ----------------------
# Append the text in VALUE to the end of the definition contained in VAR. Take
# advantage of any shell optimizations that allow amortized linear growth over
# repeated appends, instead of the typical quadratic growth present in naive
# implementations.
if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
  eval 'as_fn_append ()
  {
    eval $1+=\$2
  }'
else
  as_fn_append ()
  {
    eval $1=\$$1\$2
  }
fi # as_fn_append

# as_fn_arith ARG...
# ------------------
# Perform arithmetic evaluation on the ARGs, and store the result in the
# global $as_val. Take advantage of shells that can avoid forks. The arguments
# must be portable across $(()) and expr.
if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
  eval 'as_fn_arith ()
  {
    as_val=$(( $* ))
  }'
else
  as_fn_arith ()
  {
    as_val=`expr "$@" || test $? -eq 1`
  }
fi # as_fn_arith


# as_fn_error STATUS ERROR [LINENO LOG_FD]
# ----------------------------------------
# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
# script with STATUS, using 1 if that was 0.
as_fn_error ()
{
  as_status=$1; test $as_status -eq 0 && as_status=1
  if test "$4"; then
    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
  fi
  $as_echo "$as_me: error: $2" >&2
  as_fn_exit $as_status
} # as_fn_error

if expr a : '\(a\)' >/dev/null 2>&1 &&
   test "X`expr 00001 : '.*\(...\)'`" = X001; then
  as_expr=expr
else
  as_expr=false
fi

if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
  as_basename=basename
else
  as_basename=false
fi

if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
  as_dirname=dirname
else
  as_dirname=false
fi

as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
	 X"$0" : 'X\(//\)$' \| \
	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X/"$0" |
    sed '/^.*\/\([^/][^/]*\)\/*$/{
	    s//\1/
	    q
	  }
	  /^X\/\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\/\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`

# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits


  as_lineno_1=$LINENO as_lineno_1a=$LINENO
  as_lineno_2=$LINENO as_lineno_2a=$LINENO
  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
  sed -n '
    p
    /[$]LINENO/=
  ' <$as_myself |
    sed '
      s/[$]LINENO.*/&-/
      t lineno
      b
      :lineno
      N
      :loop
      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
      t loop
      s/-\n.*//
    ' >$as_me.lineno &&
  chmod +x "$as_me.lineno" ||
    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }

  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
  # already done that, so ensure we don't try to do so again and fall
  # in an infinite loop.  This has already happened in practice.
  _as_can_reexec=no; export _as_can_reexec
  # Don't try to exec as it changes $[0], causing all sort of problems
  # (the dirname of $[0] is not the place where we might find the
  # original and so on.  Autoconf is especially sensitive to this).
  . "./$as_me.lineno"
  # Exit status is that of the last command.
  exit
}

ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in #(((((
-n*)
  case `echo 'xy\c'` in
  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
  xy)  ECHO_C='\c';;
  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
       ECHO_T='	';;
  esac;;
*)
  ECHO_N='-n';;
esac

rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
  rm -f conf$$.dir/conf$$.file
else
  rm -f conf$$.dir
  mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
  if ln -s conf$$.file conf$$ 2>/dev/null; then
    as_ln_s='ln -s'
    # ... but there are two gotchas:
    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
    # In both cases, we have to default to `cp -pR'.
    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
      as_ln_s='cp -pR'
  elif ln conf$$.file conf$$ 2>/dev/null; then
    as_ln_s=ln
  else
    as_ln_s='cp -pR'
  fi
else
  as_ln_s='cp -pR'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null

if mkdir -p . 2>/dev/null; then
  as_mkdir_p='mkdir -p "$as_dir"'
else
  test -d ./-p && rmdir ./-p
  as_mkdir_p=false
fi

as_test_x='test -x'
as_executable_p=as_fn_executable_p

# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"

# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"

SHELL=${CONFIG_SHELL-/bin/sh}


test -n "$DJDIR" || exec 7<&0 &1

# Name of the host.
# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
# so uname gets run too.
ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`

#
# Initializations.
#
ac_default_prefix=/usr/local
ac_clean_files=
ac_config_libobj_dir=.
LIBOBJS=
cross_compiling=no
subdirs=
MFLAGS=
MAKEFLAGS=

# Identity of this package.
PACKAGE_NAME='libressl'
PACKAGE_TARNAME='libressl'
PACKAGE_VERSION='2.0.0'
PACKAGE_STRING='libressl 2.0.0'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''

# Factoring default headers for most tests.
ac_includes_default="\
#include 
#ifdef HAVE_SYS_TYPES_H
# include 
#endif
#ifdef HAVE_SYS_STAT_H
# include 
#endif
#ifdef STDC_HEADERS
# include 
# include 
#else
# ifdef HAVE_STDLIB_H
#  include 
# endif
#endif
#ifdef HAVE_STRING_H
# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
#  include 
# endif
# include 
#endif
#ifdef HAVE_STRINGS_H
# include 
#endif
#ifdef HAVE_INTTYPES_H
# include 
#endif
#ifdef HAVE_STDINT_H
# include 
#endif
#ifdef HAVE_UNISTD_H
# include 
#endif"

ac_subst_vars='am__EXEEXT_FALSE
am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
NO_STRTONUM_FALSE
NO_STRTONUM_TRUE
NO_STRTONUM
NO_ISSETUGID_FALSE
NO_ISSETUGID_TRUE
NO_ISSETUGID
NO_GETENTROPY_FALSE
NO_GETENTROPY_TRUE
NO_GETENTROPY
NO_ARC4RANDOM_BUF_FALSE
NO_ARC4RANDOM_BUF_TRUE
NO_ARC4RANDOM_BUF
NO_TIMINGSAFE_MEMCMP_FALSE
NO_TIMINGSAFE_MEMCMP_TRUE
NO_TIMINGSAFE_MEMCMP
NO_TIMINGSAFE_BCMP_FALSE
NO_TIMINGSAFE_BCMP_TRUE
NO_TIMINGSAFE_BCMP
NO_REALLOCARRAY_FALSE
NO_REALLOCARRAY_TRUE
NO_REALLOCARRAY
NO_STRLCAT_FALSE
NO_STRLCAT_TRUE
NO_STRLCAT
NO_STRLCPY_FALSE
NO_STRLCPY_TRUE
NO_STRLCPY
CPP
OTOOL64
OTOOL
LIPO
NMEDIT
DSYMUTIL
MANIFEST_TOOL
RANLIB
ac_ct_AR
AR
DLLTOOL
OBJDUMP
LN_S
NM
ac_ct_DUMPBIN
DUMPBIN
LD
FGREP
EGREP
GREP
SED
LIBTOOL
am__fastdepCC_FALSE
am__fastdepCC_TRUE
CCDEPMODE
am__nodep
AMDEPBACKSLASH
AMDEP_FALSE
AMDEP_TRUE
am__quote
am__include
DEPDIR
OBJEXT
EXEEXT
ac_ct_CC
CPPFLAGS
LDFLAGS
CFLAGS
CC
TARGET_NACL_FALSE
TARGET_NACL_TRUE
TARGET_SOLARIS_FALSE
TARGET_SOLARIS_TRUE
TARGET_LINUX_FALSE
TARGET_LINUX_TRUE
TARGET_DARWIN_FALSE
TARGET_DARWIN_TRUE
PLATFORM_LDADD
USER_CFLAGS
AM_BACKSLASH
AM_DEFAULT_VERBOSITY
AM_DEFAULT_V
AM_V
am__untar
am__tar
AMTAR
am__leading_dot
SET_MAKE
AWK
mkdir_p
MKDIR_P
INSTALL_STRIP_PROGRAM
STRIP
install_sh
MAKEINFO
AUTOHEADER
AUTOMAKE
AUTOCONF
ACLOCAL
VERSION
PACKAGE
CYGPATH_W
am__isrc
INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
target_os
target_vendor
target_cpu
target
host_os
host_vendor
host_cpu
host
build_os
build_vendor
build_cpu
build
target_alias
host_alias
build_alias
LIBS
ECHO_T
ECHO_N
ECHO_C
DEFS
mandir
localedir
libdir
psdir
pdfdir
dvidir
htmldir
infodir
docdir
oldincludedir
includedir
localstatedir
sharedstatedir
sysconfdir
datadir
datarootdir
libexecdir
sbindir
bindir
program_transform_name
prefix
exec_prefix
PACKAGE_URL
PACKAGE_BUGREPORT
PACKAGE_STRING
PACKAGE_VERSION
PACKAGE_TARNAME
PACKAGE_NAME
PATH_SEPARATOR
SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_silent_rules
enable_dependency_tracking
enable_shared
enable_static
with_pic
enable_fast_install
with_gnu_ld
with_sysroot
enable_libtool_lock
'
      ac_precious_vars='build_alias
host_alias
target_alias
CC
CFLAGS
LDFLAGS
LIBS
CPPFLAGS
CPP'


# Initialize some variables set by options.
ac_init_help=
ac_init_version=false
ac_unrecognized_opts=
ac_unrecognized_sep=
# The variables have the same names as the options, with
# dashes changed to underlines.
cache_file=/dev/null
exec_prefix=NONE
no_create=
no_recursion=
prefix=NONE
program_prefix=NONE
program_suffix=NONE
program_transform_name=s,x,x,
silent=
site=
srcdir=
verbose=
x_includes=NONE
x_libraries=NONE

# Installation directory options.
# These are left unexpanded so users can "make install exec_prefix=/foo"
# and all the variables that are supposed to be based on exec_prefix
# by default will actually change.
# Use braces instead of parens because sh, perl, etc. also accept them.
# (The list follows the same order as the GNU Coding Standards.)
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datarootdir='${prefix}/share'
datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
infodir='${datarootdir}/info'
htmldir='${docdir}'
dvidir='${docdir}'
pdfdir='${docdir}'
psdir='${docdir}'
libdir='${exec_prefix}/lib'
localedir='${datarootdir}/locale'
mandir='${datarootdir}/man'

ac_prev=
ac_dashdash=
for ac_option
do
  # If the previous option needs an argument, assign it.
  if test -n "$ac_prev"; then
    eval $ac_prev=\$ac_option
    ac_prev=
    continue
  fi

  case $ac_option in
  *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
  *=)   ac_optarg= ;;
  *)    ac_optarg=yes ;;
  esac

  # Accept the important Cygnus configure options, so we can diagnose typos.

  case $ac_dashdash$ac_option in
  --)
    ac_dashdash=yes ;;

  -bindir | --bindir | --bindi | --bind | --bin | --bi)
    ac_prev=bindir ;;
  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
    bindir=$ac_optarg ;;

  -build | --build | --buil | --bui | --bu)
    ac_prev=build_alias ;;
  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
    build_alias=$ac_optarg ;;

  -cache-file | --cache-file | --cache-fil | --cache-fi \
  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
    ac_prev=cache_file ;;
  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
    cache_file=$ac_optarg ;;

  --config-cache | -C)
    cache_file=config.cache ;;

  -datadir | --datadir | --datadi | --datad)
    ac_prev=datadir ;;
  -datadir=* | --datadir=* | --datadi=* | --datad=*)
    datadir=$ac_optarg ;;

  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
  | --dataroo | --dataro | --datar)
    ac_prev=datarootdir ;;
  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
    datarootdir=$ac_optarg ;;

  -disable-* | --disable-*)
    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
    # Reject names that are not valid shell variable names.
    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
      as_fn_error $? "invalid feature name: $ac_useropt"
    ac_useropt_orig=$ac_useropt
    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
    case $ac_user_opts in
      *"
"enable_$ac_useropt"
"*) ;;
      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
	 ac_unrecognized_sep=', ';;
    esac
    eval enable_$ac_useropt=no ;;

  -docdir | --docdir | --docdi | --doc | --do)
    ac_prev=docdir ;;
  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
    docdir=$ac_optarg ;;

  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
    ac_prev=dvidir ;;
  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
    dvidir=$ac_optarg ;;

  -enable-* | --enable-*)
    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
    # Reject names that are not valid shell variable names.
    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
      as_fn_error $? "invalid feature name: $ac_useropt"
    ac_useropt_orig=$ac_useropt
    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
    case $ac_user_opts in
      *"
"enable_$ac_useropt"
"*) ;;
      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
	 ac_unrecognized_sep=', ';;
    esac
    eval enable_$ac_useropt=\$ac_optarg ;;

  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
  | --exec | --exe | --ex)
    ac_prev=exec_prefix ;;
  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
  | --exec=* | --exe=* | --ex=*)
    exec_prefix=$ac_optarg ;;

  -gas | --gas | --ga | --g)
    # Obsolete; use --with-gas.
    with_gas=yes ;;

  -help | --help | --hel | --he | -h)
    ac_init_help=long ;;
  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
    ac_init_help=recursive ;;
  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
    ac_init_help=short ;;

  -host | --host | --hos | --ho)
    ac_prev=host_alias ;;
  -host=* | --host=* | --hos=* | --ho=*)
    host_alias=$ac_optarg ;;

  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
    ac_prev=htmldir ;;
  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
  | --ht=*)
    htmldir=$ac_optarg ;;

  -includedir | --includedir | --includedi | --included | --include \
  | --includ | --inclu | --incl | --inc)
    ac_prev=includedir ;;
  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
  | --includ=* | --inclu=* | --incl=* | --inc=*)
    includedir=$ac_optarg ;;

  -infodir | --infodir | --infodi | --infod | --info | --inf)
    ac_prev=infodir ;;
  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
    infodir=$ac_optarg ;;

  -libdir | --libdir | --libdi | --libd)
    ac_prev=libdir ;;
  -libdir=* | --libdir=* | --libdi=* | --libd=*)
    libdir=$ac_optarg ;;

  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
  | --libexe | --libex | --libe)
    ac_prev=libexecdir ;;
  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
  | --libexe=* | --libex=* | --libe=*)
    libexecdir=$ac_optarg ;;

  -localedir | --localedir | --localedi | --localed | --locale)
    ac_prev=localedir ;;
  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
    localedir=$ac_optarg ;;

  -localstatedir | --localstatedir | --localstatedi | --localstated \
  | --localstate | --localstat | --localsta | --localst | --locals)
    ac_prev=localstatedir ;;
  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
    localstatedir=$ac_optarg ;;

  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
    ac_prev=mandir ;;
  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
    mandir=$ac_optarg ;;

  -nfp | --nfp | --nf)
    # Obsolete; use --without-fp.
    with_fp=no ;;

  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
  | --no-cr | --no-c | -n)
    no_create=yes ;;

  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
    no_recursion=yes ;;

  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
  | --oldin | --oldi | --old | --ol | --o)
    ac_prev=oldincludedir ;;
  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
    oldincludedir=$ac_optarg ;;

  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
    ac_prev=prefix ;;
  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
    prefix=$ac_optarg ;;

  -program-prefix | --program-prefix | --program-prefi | --program-pref \
  | --program-pre | --program-pr | --program-p)
    ac_prev=program_prefix ;;
  -program-prefix=* | --program-prefix=* | --program-prefi=* \
  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
    program_prefix=$ac_optarg ;;

  -program-suffix | --program-suffix | --program-suffi | --program-suff \
  | --program-suf | --program-su | --program-s)
    ac_prev=program_suffix ;;
  -program-suffix=* | --program-suffix=* | --program-suffi=* \
  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
    program_suffix=$ac_optarg ;;

  -program-transform-name | --program-transform-name \
  | --program-transform-nam | --program-transform-na \
  | --program-transform-n | --program-transform- \
  | --program-transform | --program-transfor \
  | --program-transfo | --program-transf \
  | --program-trans | --program-tran \
  | --progr-tra | --program-tr | --program-t)
    ac_prev=program_transform_name ;;
  -program-transform-name=* | --program-transform-name=* \
  | --program-transform-nam=* | --program-transform-na=* \
  | --program-transform-n=* | --program-transform-=* \
  | --program-transform=* | --program-transfor=* \
  | --program-transfo=* | --program-transf=* \
  | --program-trans=* | --program-tran=* \
  | --progr-tra=* | --program-tr=* | --program-t=*)
    program_transform_name=$ac_optarg ;;

  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
    ac_prev=pdfdir ;;
  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
    pdfdir=$ac_optarg ;;

  -psdir | --psdir | --psdi | --psd | --ps)
    ac_prev=psdir ;;
  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
    psdir=$ac_optarg ;;

  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
  | -silent | --silent | --silen | --sile | --sil)
    silent=yes ;;

  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
    ac_prev=sbindir ;;
  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
  | --sbi=* | --sb=*)
    sbindir=$ac_optarg ;;

  -sharedstatedir | --sharedstatedir | --sharedstatedi \
  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
  | --sharedst | --shareds | --shared | --share | --shar \
  | --sha | --sh)
    ac_prev=sharedstatedir ;;
  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
  | --sha=* | --sh=*)
    sharedstatedir=$ac_optarg ;;

  -site | --site | --sit)
    ac_prev=site ;;
  -site=* | --site=* | --sit=*)
    site=$ac_optarg ;;

  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
    ac_prev=srcdir ;;
  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
    srcdir=$ac_optarg ;;

  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
  | --syscon | --sysco | --sysc | --sys | --sy)
    ac_prev=sysconfdir ;;
  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
    sysconfdir=$ac_optarg ;;

  -target | --target | --targe | --targ | --tar | --ta | --t)
    ac_prev=target_alias ;;
  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
    target_alias=$ac_optarg ;;

  -v | -verbose | --verbose | --verbos | --verbo | --verb)
    verbose=yes ;;

  -version | --version | --versio | --versi | --vers | -V)
    ac_init_version=: ;;

  -with-* | --with-*)
    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
    # Reject names that are not valid shell variable names.
    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
      as_fn_error $? "invalid package name: $ac_useropt"
    ac_useropt_orig=$ac_useropt
    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
    case $ac_user_opts in
      *"
"with_$ac_useropt"
"*) ;;
      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
	 ac_unrecognized_sep=', ';;
    esac
    eval with_$ac_useropt=\$ac_optarg ;;

  -without-* | --without-*)
    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
    # Reject names that are not valid shell variable names.
    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
      as_fn_error $? "invalid package name: $ac_useropt"
    ac_useropt_orig=$ac_useropt
    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
    case $ac_user_opts in
      *"
"with_$ac_useropt"
"*) ;;
      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
	 ac_unrecognized_sep=', ';;
    esac
    eval with_$ac_useropt=no ;;

  --x)
    # Obsolete; use --with-x.
    with_x=yes ;;

  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
  | --x-incl | --x-inc | --x-in | --x-i)
    ac_prev=x_includes ;;
  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
    x_includes=$ac_optarg ;;

  -x-libraries | --x-libraries | --x-librarie | --x-librari \
  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
    ac_prev=x_libraries ;;
  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
    x_libraries=$ac_optarg ;;

  -*) as_fn_error $? "unrecognized option: \`$ac_option'
Try \`$0 --help' for more information"
    ;;

  *=*)
    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
    # Reject names that are not valid shell variable names.
    case $ac_envvar in #(
      '' | [0-9]* | *[!_$as_cr_alnum]* )
      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
    esac
    eval $ac_envvar=\$ac_optarg
    export $ac_envvar ;;

  *)
    # FIXME: should be removed in autoconf 3.0.
    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
    : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
    ;;

  esac
done

if test -n "$ac_prev"; then
  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
  as_fn_error $? "missing argument to $ac_option"
fi

if test -n "$ac_unrecognized_opts"; then
  case $enable_option_checking in
    no) ;;
    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
  esac
fi

# Check all directory arguments for consistency.
for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
		datadir sysconfdir sharedstatedir localstatedir includedir \
		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
		libdir localedir mandir
do
  eval ac_val=\$$ac_var
  # Remove trailing slashes.
  case $ac_val in
    */ )
      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
      eval $ac_var=\$ac_val;;
  esac
  # Be sure to have absolute directory names.
  case $ac_val in
    [\\/$]* | ?:[\\/]* )  continue;;
    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
  esac
  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
done

# There might be people who depend on the old broken behavior: `$host'
# used to hold the argument of --host etc.
# FIXME: To remove some day.
build=$build_alias
host=$host_alias
target=$target_alias

# FIXME: To remove some day.
if test "x$host_alias" != x; then
  if test "x$build_alias" = x; then
    cross_compiling=maybe
  elif test "x$build_alias" != "x$host_alias"; then
    cross_compiling=yes
  fi
fi

ac_tool_prefix=
test -n "$host_alias" && ac_tool_prefix=$host_alias-

test "$silent" = yes && exec 6>/dev/null


ac_pwd=`pwd` && test -n "$ac_pwd" &&
ac_ls_di=`ls -di .` &&
ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
  as_fn_error $? "working directory cannot be determined"
test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
  as_fn_error $? "pwd does not report name of working directory"


# Find the source files, if location was not specified.
if test -z "$srcdir"; then
  ac_srcdir_defaulted=yes
  # Try the directory containing this script, then the parent directory.
  ac_confdir=`$as_dirname -- "$as_myself" ||
$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
	 X"$as_myself" : 'X\(//\)[^/]' \| \
	 X"$as_myself" : 'X\(//\)$' \| \
	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_myself" |
    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)[^/].*/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`
  srcdir=$ac_confdir
  if test ! -r "$srcdir/$ac_unique_file"; then
    srcdir=..
  fi
else
  ac_srcdir_defaulted=no
fi
if test ! -r "$srcdir/$ac_unique_file"; then
  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
fi
ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
ac_abs_confdir=`(
	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
	pwd)`
# When building in place, set srcdir=.
if test "$ac_abs_confdir" = "$ac_pwd"; then
  srcdir=.
fi
# Remove unnecessary trailing slashes from srcdir.
# Double slashes in file names in object file debugging info
# mess up M-x gdb in Emacs.
case $srcdir in
*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
esac
for ac_var in $ac_precious_vars; do
  eval ac_env_${ac_var}_set=\${${ac_var}+set}
  eval ac_env_${ac_var}_value=\$${ac_var}
  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
  eval ac_cv_env_${ac_var}_value=\$${ac_var}
done

#
# Report the --help message.
#
if test "$ac_init_help" = "long"; then
  # Omit some internal or obsolete options to make the list less imposing.
  # This message is too long to be a string in the A/UX 3.1 sh.
  cat <<_ACEOF
\`configure' configures libressl 2.0.0 to adapt to many kinds of systems.

Usage: $0 [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print \`checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for \`--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or \`..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [$ac_default_prefix]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, \`make install' will install all the files in
\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
an installation prefix other than \`$ac_default_prefix' using \`--prefix',
for instance \`--prefix=\$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/libressl]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]
_ACEOF

  cat <<\_ACEOF

Program names:
  --program-prefix=PREFIX            prepend PREFIX to installed program names
  --program-suffix=SUFFIX            append SUFFIX to installed program names
  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  --target=TARGET   configure for building compilers for TARGET [HOST]
_ACEOF
fi

if test -n "$ac_init_help"; then
  case $ac_init_help in
     short | recursive ) echo "Configuration of libressl 2.0.0:";;
   esac
  cat <<\_ACEOF

Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --enable-silent-rules   less verbose build output (undo: "make V=1")
  --disable-silent-rules  verbose build output (undo: "make V=0")
  --enable-dependency-tracking
                          do not reject slow dependency extractors
  --disable-dependency-tracking
                          speeds up one-time build
  --enable-shared[=PKGS]  build shared libraries [default=yes]
  --enable-static[=PKGS]  build static libraries [default=yes]
  --enable-fast-install[=PKGS]
                          optimize for fast installation [default=yes]
  --disable-libtool-lock  avoid locking (might break parallel builds)

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
                          both]
  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
  --with-sysroot=DIR Search for dependent libraries within DIR
                        (or the compiler's sysroot if not specified).

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L if you have libraries in a
              nonstandard directory 
  LIBS        libraries to pass to the linker, e.g. -l
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I if
              you have headers in a nonstandard directory 
  CPP         C preprocessor

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Report bugs to the package provider.
_ACEOF
ac_status=$?
fi

if test "$ac_init_help" = "recursive"; then
  # If there are subdirs, report their specific --help.
  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
    test -d "$ac_dir" ||
      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
      continue
    ac_builddir=.

case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
  # A ".." for each directory in $ac_dir_suffix.
  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
  case $ac_top_builddir_sub in
  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
  esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix

case $srcdir in
  .)  # We are building in place.
    ac_srcdir=.
    ac_top_srcdir=$ac_top_builddir_sub
    ac_abs_top_srcdir=$ac_pwd ;;
  [\\/]* | ?:[\\/]* )  # Absolute name.
    ac_srcdir=$srcdir$ac_dir_suffix;
    ac_top_srcdir=$srcdir
    ac_abs_top_srcdir=$srcdir ;;
  *) # Relative name.
    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
    ac_top_srcdir=$ac_top_build_prefix$srcdir
    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix

    cd "$ac_dir" || { ac_status=$?; continue; }
    # Check for guested configure.
    if test -f "$ac_srcdir/configure.gnu"; then
      echo &&
      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
    elif test -f "$ac_srcdir/configure"; then
      echo &&
      $SHELL "$ac_srcdir/configure" --help=recursive
    else
      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
    fi || ac_status=$?
    cd "$ac_pwd" || { ac_status=$?; break; }
  done
fi

test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
  cat <<\_ACEOF
libressl configure 2.0.0
generated by GNU Autoconf 2.69

Copyright (C) 2012 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
_ACEOF
  exit
fi

## ------------------------ ##
## Autoconf initialization. ##
## ------------------------ ##

# ac_fn_c_try_compile LINENO
# --------------------------
# Try to compile conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_compile ()
{
  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
  rm -f conftest.$ac_objext
  if { { ac_try="$ac_compile"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_compile") 2>conftest.err
  ac_status=$?
  if test -s conftest.err; then
    grep -v '^ *+' conftest.err >conftest.er1
    cat conftest.er1 >&5
    mv -f conftest.er1 conftest.err
  fi
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; } && {
	 test -z "$ac_c_werror_flag" ||
	 test ! -s conftest.err
       } && test -s conftest.$ac_objext; then :
  ac_retval=0
else
  $as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

	ac_retval=1
fi
  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
  as_fn_set_status $ac_retval

} # ac_fn_c_try_compile

# ac_fn_c_try_link LINENO
# -----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_link ()
{
  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
  rm -f conftest.$ac_objext conftest$ac_exeext
  if { { ac_try="$ac_link"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_link") 2>conftest.err
  ac_status=$?
  if test -s conftest.err; then
    grep -v '^ *+' conftest.err >conftest.er1
    cat conftest.er1 >&5
    mv -f conftest.er1 conftest.err
  fi
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; } && {
	 test -z "$ac_c_werror_flag" ||
	 test ! -s conftest.err
       } && test -s conftest$ac_exeext && {
	 test "$cross_compiling" = yes ||
	 test -x conftest$ac_exeext
       }; then :
  ac_retval=0
else
  $as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

	ac_retval=1
fi
  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
  # interfere with the next link command; also delete a directory that is
  # left behind by Apple's compiler.  We do this before executing the actions.
  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
  as_fn_set_status $ac_retval

} # ac_fn_c_try_link

# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
# -------------------------------------------------------
# Tests whether HEADER exists and can be compiled using the include files in
# INCLUDES, setting the cache variable VAR accordingly.
ac_fn_c_check_header_compile ()
{
  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
$4
#include <$2>
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  eval "$3=yes"
else
  eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$3
	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno

} # ac_fn_c_check_header_compile

# ac_fn_c_try_cpp LINENO
# ----------------------
# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_cpp ()
{
  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
  if { { ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
  ac_status=$?
  if test -s conftest.err; then
    grep -v '^ *+' conftest.err >conftest.er1
    cat conftest.er1 >&5
    mv -f conftest.er1 conftest.err
  fi
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; } > conftest.i && {
	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
	 test ! -s conftest.err
       }; then :
  ac_retval=0
else
  $as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

    ac_retval=1
fi
  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
  as_fn_set_status $ac_retval

} # ac_fn_c_try_cpp

# ac_fn_c_try_run LINENO
# ----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
# that executables *can* be run.
ac_fn_c_try_run ()
{
  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
  if { { ac_try="$ac_link"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_link") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
  { { case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_try") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; }; then :
  ac_retval=0
else
  $as_echo "$as_me: program exited with status $ac_status" >&5
       $as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

       ac_retval=$ac_status
fi
  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
  as_fn_set_status $ac_retval

} # ac_fn_c_try_run

# ac_fn_c_check_func LINENO FUNC VAR
# ----------------------------------
# Tests whether FUNC exists, setting the cache variable VAR accordingly
ac_fn_c_check_func ()
{
  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
/* Define $2 to an innocuous variant, in case  declares $2.
   For example, HP-UX 11i  declares gettimeofday.  */
#define $2 innocuous_$2

/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char $2 (); below.
    Prefer  to  if __STDC__ is defined, since
     exists even on freestanding compilers.  */

#ifdef __STDC__
# include 
#else
# include 
#endif

#undef $2

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char $2 ();
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined __stub_$2 || defined __stub___$2
choke me
#endif

int
main ()
{
return $2 ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  eval "$3=yes"
else
  eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
fi
eval ac_res=\$$3
	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno

} # ac_fn_c_check_func
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by libressl $as_me 2.0.0, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  $ $0 $@

_ACEOF
exec 5>>config.log
{
cat <<_ASUNAME
## --------- ##
## Platform. ##
## --------- ##

hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`

/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`

/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`

_ASUNAME

as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    $as_echo "PATH: $as_dir"
  done
IFS=$as_save_IFS

} >&5

cat >&5 <<_ACEOF


## ----------- ##
## Core tests. ##
## ----------- ##

_ACEOF


# Keep a trace of the command line.
# Strip out --no-create and --no-recursion so they do not pile up.
# Strip out --silent because we don't want to record it for future runs.
# Also quote any args containing shell meta-characters.
# Make two passes to allow for proper duplicate-argument suppression.
ac_configure_args=
ac_configure_args0=
ac_configure_args1=
ac_must_keep_next=false
for ac_pass in 1 2
do
  for ac_arg
  do
    case $ac_arg in
    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
    | -silent | --silent | --silen | --sile | --sil)
      continue ;;
    *\'*)
      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
    esac
    case $ac_pass in
    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
    2)
      as_fn_append ac_configure_args1 " '$ac_arg'"
      if test $ac_must_keep_next = true; then
	ac_must_keep_next=false # Got value, back to normal.
      else
	case $ac_arg in
	  *=* | --config-cache | -C | -disable-* | --disable-* \
	  | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
	  | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
	  | -with-* | --with-* | -without-* | --without-* | --x)
	    case "$ac_configure_args0 " in
	      "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
	    esac
	    ;;
	  -* ) ac_must_keep_next=true ;;
	esac
      fi
      as_fn_append ac_configure_args " '$ac_arg'"
      ;;
    esac
  done
done
{ ac_configure_args0=; unset ac_configure_args0;}
{ ac_configure_args1=; unset ac_configure_args1;}

# When interrupted or exit'd, cleanup temporary files, and complete
# config.log.  We remove comments because anyway the quotes in there
# would cause problems or look ugly.
# WARNING: Use '\'' to represent an apostrophe within the trap.
# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
trap 'exit_status=$?
  # Save into config.log some information that might help in debugging.
  {
    echo

    $as_echo "## ---------------- ##
## Cache variables. ##
## ---------------- ##"
    echo
    # The following way of writing the cache mishandles newlines in values,
(
  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
    eval ac_val=\$$ac_var
    case $ac_val in #(
    *${as_nl}*)
      case $ac_var in #(
      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
      esac
      case $ac_var in #(
      _ | IFS | as_nl) ;; #(
      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
      *) { eval $ac_var=; unset $ac_var;} ;;
      esac ;;
    esac
  done
  (set) 2>&1 |
    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
    *${as_nl}ac_space=\ *)
      sed -n \
	"s/'\''/'\''\\\\'\'''\''/g;
	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
      ;; #(
    *)
      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
      ;;
    esac |
    sort
)
    echo

    $as_echo "## ----------------- ##
## Output variables. ##
## ----------------- ##"
    echo
    for ac_var in $ac_subst_vars
    do
      eval ac_val=\$$ac_var
      case $ac_val in
      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
      esac
      $as_echo "$ac_var='\''$ac_val'\''"
    done | sort
    echo

    if test -n "$ac_subst_files"; then
      $as_echo "## ------------------- ##
## File substitutions. ##
## ------------------- ##"
      echo
      for ac_var in $ac_subst_files
      do
	eval ac_val=\$$ac_var
	case $ac_val in
	*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
	esac
	$as_echo "$ac_var='\''$ac_val'\''"
      done | sort
      echo
    fi

    if test -s confdefs.h; then
      $as_echo "## ----------- ##
## confdefs.h. ##
## ----------- ##"
      echo
      cat confdefs.h
      echo
    fi
    test "$ac_signal" != 0 &&
      $as_echo "$as_me: caught signal $ac_signal"
    $as_echo "$as_me: exit $exit_status"
  } >&5
  rm -f core *.core core.conftest.* &&
    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
    exit $exit_status
' 0
for ac_signal in 1 2 13 15; do
  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
done
ac_signal=0

# confdefs.h avoids OS command line length limits that DEFS can exceed.
rm -f -r conftest* confdefs.h

$as_echo "/* confdefs.h */" > confdefs.h

# Predefined preprocessor variables.

cat >>confdefs.h <<_ACEOF
#define PACKAGE_NAME "$PACKAGE_NAME"
_ACEOF

cat >>confdefs.h <<_ACEOF
#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
_ACEOF

cat >>confdefs.h <<_ACEOF
#define PACKAGE_VERSION "$PACKAGE_VERSION"
_ACEOF

cat >>confdefs.h <<_ACEOF
#define PACKAGE_STRING "$PACKAGE_STRING"
_ACEOF

cat >>confdefs.h <<_ACEOF
#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
_ACEOF

cat >>confdefs.h <<_ACEOF
#define PACKAGE_URL "$PACKAGE_URL"
_ACEOF


# Let the site file select an alternate cache file if it wants to.
# Prefer an explicitly selected file to automatically selected ones.
ac_site_file1=NONE
ac_site_file2=NONE
if test -n "$CONFIG_SITE"; then
  # We do not want a PATH search for config.site.
  case $CONFIG_SITE in #((
    -*)  ac_site_file1=./$CONFIG_SITE;;
    */*) ac_site_file1=$CONFIG_SITE;;
    *)   ac_site_file1=./$CONFIG_SITE;;
  esac
elif test "x$prefix" != xNONE; then
  ac_site_file1=$prefix/share/config.site
  ac_site_file2=$prefix/etc/config.site
else
  ac_site_file1=$ac_default_prefix/share/config.site
  ac_site_file2=$ac_default_prefix/etc/config.site
fi
for ac_site_file in "$ac_site_file1" "$ac_site_file2"
do
  test "x$ac_site_file" = xNONE && continue
  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
$as_echo "$as_me: loading site script $ac_site_file" >&6;}
    sed 's/^/| /' "$ac_site_file" >&5
    . "$ac_site_file" \
      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "failed to load site script $ac_site_file
See \`config.log' for more details" "$LINENO" 5; }
  fi
done

if test -r "$cache_file"; then
  # Some versions of bash will fail to source /dev/null (special files
  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
$as_echo "$as_me: loading cache $cache_file" >&6;}
    case $cache_file in
      [\\/]* | ?:[\\/]* ) . "$cache_file";;
      *)                      . "./$cache_file";;
    esac
  fi
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
$as_echo "$as_me: creating cache $cache_file" >&6;}
  >$cache_file
fi

# Check that the precious variables saved in the cache have kept the same
# value.
ac_cache_corrupted=false
for ac_var in $ac_precious_vars; do
  eval ac_old_set=\$ac_cv_env_${ac_var}_set
  eval ac_new_set=\$ac_env_${ac_var}_set
  eval ac_old_val=\$ac_cv_env_${ac_var}_value
  eval ac_new_val=\$ac_env_${ac_var}_value
  case $ac_old_set,$ac_new_set in
    set,)
      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
      ac_cache_corrupted=: ;;
    ,set)
      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
      ac_cache_corrupted=: ;;
    ,);;
    *)
      if test "x$ac_old_val" != "x$ac_new_val"; then
	# differences in whitespace do not lead to failure.
	ac_old_val_w=`echo x $ac_old_val`
	ac_new_val_w=`echo x $ac_new_val`
	if test "$ac_old_val_w" != "$ac_new_val_w"; then
	  { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
	  ac_cache_corrupted=:
	else
	  { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
	  eval $ac_var=\$ac_old_val
	fi
	{ $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
	{ $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
      fi;;
  esac
  # Pass precious variables to config.status.
  if test "$ac_new_set" = set; then
    case $ac_new_val in
    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
    *) ac_arg=$ac_var=$ac_new_val ;;
    esac
    case " $ac_configure_args " in
      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
    esac
  fi
done
if $ac_cache_corrupted; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
fi
## -------------------- ##
## Main body of script. ##
## -------------------- ##

ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu


ac_aux_dir=
for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
  if test -f "$ac_dir/install-sh"; then
    ac_aux_dir=$ac_dir
    ac_install_sh="$ac_aux_dir/install-sh -c"
    break
  elif test -f "$ac_dir/install.sh"; then
    ac_aux_dir=$ac_dir
    ac_install_sh="$ac_aux_dir/install.sh -c"
    break
  elif test -f "$ac_dir/shtool"; then
    ac_aux_dir=$ac_dir
    ac_install_sh="$ac_aux_dir/shtool install -c"
    break
  fi
done
if test -z "$ac_aux_dir"; then
  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
fi

# These three variables are undocumented and unsupported,
# and are intended to be withdrawn in a future Autoconf release.
# They can cause serious problems if a builder's source tree is in a directory
# whose full name contains unusual characters.
ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.


# Make sure we can run config.sub.
$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
$as_echo_n "checking build system type... " >&6; }
if ${ac_cv_build+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_build_alias=$build_alias
test "x$ac_build_alias" = x &&
  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
test "x$ac_build_alias" = x &&
  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
$as_echo "$ac_cv_build" >&6; }
case $ac_cv_build in
*-*-*) ;;
*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
esac
build=$ac_cv_build
ac_save_IFS=$IFS; IFS='-'
set x $ac_cv_build
shift
build_cpu=$1
build_vendor=$2
shift; shift
# Remember, the first character of IFS is used to create $*,
# except with old shells:
build_os=$*
IFS=$ac_save_IFS
case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
$as_echo_n "checking host system type... " >&6; }
if ${ac_cv_host+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test "x$host_alias" = x; then
  ac_cv_host=$ac_cv_build
else
  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
fi

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
$as_echo "$ac_cv_host" >&6; }
case $ac_cv_host in
*-*-*) ;;
*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
esac
host=$ac_cv_host
ac_save_IFS=$IFS; IFS='-'
set x $ac_cv_host
shift
host_cpu=$1
host_vendor=$2
shift; shift
# Remember, the first character of IFS is used to create $*,
# except with old shells:
host_os=$*
IFS=$ac_save_IFS
case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5
$as_echo_n "checking target system type... " >&6; }
if ${ac_cv_target+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test "x$target_alias" = x; then
  ac_cv_target=$ac_cv_host
else
  ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
fi

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5
$as_echo "$ac_cv_target" >&6; }
case $ac_cv_target in
*-*-*) ;;
*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;;
esac
target=$ac_cv_target
ac_save_IFS=$IFS; IFS='-'
set x $ac_cv_target
shift
target_cpu=$1
target_vendor=$2
shift; shift
# Remember, the first character of IFS is used to create $*,
# except with old shells:
target_os=$*
IFS=$ac_save_IFS
case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac


# The aliases save the names the user supplied, while $host etc.
# will get canonicalized.
test -n "$target_alias" &&
  test "$program_prefix$program_suffix$program_transform_name" = \
    NONENONEs,x,x, &&
  program_prefix=${target_alias}-
am__api_version='1.14'

# Find a good install program.  We prefer a C program (faster),
# so one script is as good as another.  But avoid the broken or
# incompatible versions:
# SysV /etc/install, /usr/sbin/install
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
# AmigaOS /C/install, which installs bootblocks on floppy discs
# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# OS/2's system install, which has a completely different semantic
# ./install, which can be erroneously created by make from ./install.sh.
# Reject install programs that cannot install multiple files.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
$as_echo_n "checking for a BSD-compatible install... " >&6; }
if test -z "$INSTALL"; then
if ${ac_cv_path_install+:} false; then :
  $as_echo_n "(cached) " >&6
else
  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    # Account for people who put trailing slashes in PATH elements.
case $as_dir/ in #((
  ./ | .// | /[cC]/* | \
  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
  ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
  /usr/ucb/* ) ;;
  *)
    # OSF1 and SCO ODT 3.0 have their own names for install.
    # Don't use installbsd from OSF since it installs stuff as root
    # by default.
    for ac_prog in ginstall scoinst install; do
      for ac_exec_ext in '' $ac_executable_extensions; do
	if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
	  if test $ac_prog = install &&
	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
	    # AIX install.  It has an incompatible calling convention.
	    :
	  elif test $ac_prog = install &&
	    grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
	    # program-specific install script used by HP pwplus--don't use.
	    :
	  else
	    rm -rf conftest.one conftest.two conftest.dir
	    echo one > conftest.one
	    echo two > conftest.two
	    mkdir conftest.dir
	    if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
	      test -s conftest.one && test -s conftest.two &&
	      test -s conftest.dir/conftest.one &&
	      test -s conftest.dir/conftest.two
	    then
	      ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
	      break 3
	    fi
	  fi
	fi
      done
    done
    ;;
esac

  done
IFS=$as_save_IFS

rm -rf conftest.one conftest.two conftest.dir

fi
  if test "${ac_cv_path_install+set}" = set; then
    INSTALL=$ac_cv_path_install
  else
    # As a last resort, use the slow shell script.  Don't cache a
    # value for INSTALL within a source directory, because that will
    # break other packages using the cache if that directory is
    # removed, or if the value is a relative name.
    INSTALL=$ac_install_sh
  fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
$as_echo "$INSTALL" >&6; }

# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'

test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'

test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
$as_echo_n "checking whether build environment is sane... " >&6; }
# Reject unsafe characters in $srcdir or the absolute working directory
# name.  Accept space and tab only in the latter.
am_lf='
'
case `pwd` in
  *[\\\"\#\$\&\'\`$am_lf]*)
    as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;;
esac
case $srcdir in
  *[\\\"\#\$\&\'\`$am_lf\ \	]*)
    as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;;
esac

# Do 'set' in a subshell so we don't clobber the current shell's
# arguments.  Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
   am_has_slept=no
   for am_try in 1 2; do
     echo "timestamp, slept: $am_has_slept" > conftest.file
     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
     if test "$*" = "X"; then
	# -L didn't work.
	set X `ls -t "$srcdir/configure" conftest.file`
     fi
     if test "$*" != "X $srcdir/configure conftest.file" \
	&& test "$*" != "X conftest.file $srcdir/configure"; then

	# If neither matched, then we have a broken ls.  This can happen
	# if, for instance, CONFIG_SHELL is bash and it inherits a
	# broken ls alias from the environment.  This has actually
	# happened.  Such a system could not be considered "sane".
	as_fn_error $? "ls -t appears to fail.  Make sure there is not a broken
  alias in your environment" "$LINENO" 5
     fi
     if test "$2" = conftest.file || test $am_try -eq 2; then
       break
     fi
     # Just in case.
     sleep 1
     am_has_slept=yes
   done
   test "$2" = conftest.file
   )
then
   # Ok.
   :
else
   as_fn_error $? "newly created file is older than distributed files!
Check your system clock" "$LINENO" 5
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
# If we didn't sleep, we still need to ensure time stamps of config.status and
# generated files are strictly newer.
am_sleep_pid=
if grep 'slept: no' conftest.file >/dev/null 2>&1; then
  ( sleep 1 ) &
  am_sleep_pid=$!
fi

rm -f conftest.file

test "$program_prefix" != NONE &&
  program_transform_name="s&^&$program_prefix&;$program_transform_name"
# Use a double $ so make ignores it.
test "$program_suffix" != NONE &&
  program_transform_name="s&\$&$program_suffix&;$program_transform_name"
# Double any \ or $.
# By default was `s,x,x', remove it if useless.
ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`

# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`

if test x"${MISSING+set}" != xset; then
  case $am_aux_dir in
  *\ * | *\	*)
    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
  *)
    MISSING="\${SHELL} $am_aux_dir/missing" ;;
  esac
fi
# Use eval to expand $SHELL
if eval "$MISSING --is-lightweight"; then
  am_missing_run="$MISSING "
else
  am_missing_run=
  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5
$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
fi

if test x"${install_sh}" != xset; then
  case $am_aux_dir in
  *\ * | *\	*)
    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
  *)
    install_sh="\${SHELL} $am_aux_dir/install-sh"
  esac
fi

# Installed binaries are usually stripped using 'strip' when the user
# run "make install-strip".  However 'strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake
# will honor the 'STRIP' environment variable to overrule this program.
if test "$cross_compiling" != no; then
  if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
set dummy ${ac_tool_prefix}strip; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_STRIP+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$STRIP"; then
  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
STRIP=$ac_cv_prog_STRIP
if test -n "$STRIP"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
$as_echo "$STRIP" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_prog_STRIP"; then
  ac_ct_STRIP=$STRIP
  # Extract the first word of "strip", so it can be a program name with args.
set dummy strip; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_STRIP"; then
  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_STRIP="strip"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
if test -n "$ac_ct_STRIP"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
$as_echo "$ac_ct_STRIP" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

  if test "x$ac_ct_STRIP" = x; then
    STRIP=":"
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    STRIP=$ac_ct_STRIP
  fi
else
  STRIP="$ac_cv_prog_STRIP"
fi

fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
if test -z "$MKDIR_P"; then
  if ${ac_cv_path_mkdir+:} false; then :
  $as_echo_n "(cached) " >&6
else
  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_prog in mkdir gmkdir; do
	 for ac_exec_ext in '' $ac_executable_extensions; do
	   as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue
	   case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
	     'mkdir (GNU coreutils) '* | \
	     'mkdir (coreutils) '* | \
	     'mkdir (fileutils) '4.1*)
	       ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
	       break 3;;
	   esac
	 done
       done
  done
IFS=$as_save_IFS

fi

  test -d ./--version && rmdir ./--version
  if test "${ac_cv_path_mkdir+set}" = set; then
    MKDIR_P="$ac_cv_path_mkdir -p"
  else
    # As a last resort, use the slow shell script.  Don't cache a
    # value for MKDIR_P within a source directory, because that will
    # break other packages using the cache if that directory is
    # removed, or if the value is a relative name.
    MKDIR_P="$ac_install_sh -d"
  fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
$as_echo "$MKDIR_P" >&6; }

for ac_prog in gawk mawk nawk awk
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_AWK+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$AWK"; then
  ac_cv_prog_AWK="$AWK" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_AWK="$ac_prog"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
AWK=$ac_cv_prog_AWK
if test -n "$AWK"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
$as_echo "$AWK" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


  test -n "$AWK" && break
done

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
set x ${MAKE-make}
ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat >conftest.make <<\_ACEOF
SHELL = /bin/sh
all:
	@echo '@@@%%%=$(MAKE)=@@@%%%'
_ACEOF
# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
case `${MAKE-make} -f conftest.make 2>/dev/null` in
  *@@@%%%=?*=@@@%%%*)
    eval ac_cv_prog_make_${ac_make}_set=yes;;
  *)
    eval ac_cv_prog_make_${ac_make}_set=no;;
esac
rm -f conftest.make
fi
if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
  SET_MAKE=
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
  SET_MAKE="MAKE=${MAKE-make}"
fi

rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
if test -d .tst; then
  am__leading_dot=.
else
  am__leading_dot=_
fi
rmdir .tst 2>/dev/null

# Check whether --enable-silent-rules was given.
if test "${enable_silent_rules+set}" = set; then :
  enableval=$enable_silent_rules;
fi

case $enable_silent_rules in # (((
  yes) AM_DEFAULT_VERBOSITY=0;;
   no) AM_DEFAULT_VERBOSITY=1;;
    *) AM_DEFAULT_VERBOSITY=1;;
esac
am_make=${MAKE-make}
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
if ${am_cv_make_support_nested_variables+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if $as_echo 'TRUE=$(BAR$(V))
BAR0=false
BAR1=true
V=1
am__doit:
	@$(TRUE)
.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
  am_cv_make_support_nested_variables=yes
else
  am_cv_make_support_nested_variables=no
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
$as_echo "$am_cv_make_support_nested_variables" >&6; }
if test $am_cv_make_support_nested_variables = yes; then
    AM_V='$(V)'
  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
else
  AM_V=$AM_DEFAULT_VERBOSITY
  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
fi
AM_BACKSLASH='\'

if test "`cd $srcdir && pwd`" != "`pwd`"; then
  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
  # is not polluted with repeated "-I."
  am__isrc=' -I$(srcdir)'
  # test to see if srcdir already configured
  if test -f $srcdir/config.status; then
    as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
  fi
fi

# test whether we have cygpath
if test -z "$CYGPATH_W"; then
  if (cygpath --version) >/dev/null 2>/dev/null; then
    CYGPATH_W='cygpath -w'
  else
    CYGPATH_W=echo
  fi
fi


# Define the identity of the package.
 PACKAGE='libressl'
 VERSION='2.0.0'


cat >>confdefs.h <<_ACEOF
#define PACKAGE "$PACKAGE"
_ACEOF


cat >>confdefs.h <<_ACEOF
#define VERSION "$VERSION"
_ACEOF

# Some tools Automake needs.

ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}


AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}


AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}


AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}


MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}

# For better backward compatibility.  To be removed once Automake 1.9.x
# dies out for good.  For more background, see:
# 
# 
mkdir_p='$(MKDIR_P)'

# We need awk for the "check" target.  The system "awk" is bad on
# some platforms.
# Always define AMTAR for backward compatibility.  Yes, it's still used
# in the wild :-(  We should find a proper way to deprecate it ...
AMTAR='$${TAR-tar}'


# We'll loop over all known methods to create a tar archive until one works.
_am_tools='gnutar  pax cpio none'

am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'






# POSIX will say in a future version that running "rm -f" with no argument
# is OK; and we want to be able to make that assumption in our Makefile
# recipes.  So use an aggressive probe to check that the usage we want is
# actually supported "in the wild" to an acceptable degree.
# See automake bug#10828.
# To make any issue more visible, cause the running configure to be aborted
# by default if the 'rm' program in use doesn't match our expectations; the
# user can still override this though.
if rm -f && rm -fr && rm -rf; then : OK; else
  cat >&2 <<'END'
Oops!

Your 'rm' program seems unable to run without file operands specified
on the command line, even when the '-f' option is present.  This is contrary
to the behaviour of most rm programs out there, and not conforming with
the upcoming POSIX standard: 

Please tell bug-automake@gnu.org about your system, including the value
of your $PATH and any error possibly output before this message.  This
can help us improve future automake versions.

END
  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
    echo 'Configuration will proceed anyway, since you have set the' >&2
    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
    echo >&2
  else
    cat >&2 <<'END'
Aborting the configuration process, to ensure you take notice of the issue.

You can download and install GNU coreutils to get an 'rm' implementation
that behaves properly: .

If you want to complete the configuration process using your problematic
'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
to "yes", and re-run configure.

END
    as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5
  fi
fi



# Check whether --enable-silent-rules was given.
if test "${enable_silent_rules+set}" = set; then :
  enableval=$enable_silent_rules;
fi

case $enable_silent_rules in # (((
  yes) AM_DEFAULT_VERBOSITY=0;;
   no) AM_DEFAULT_VERBOSITY=1;;
    *) AM_DEFAULT_VERBOSITY=0;;
esac
am_make=${MAKE-make}
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
if ${am_cv_make_support_nested_variables+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if $as_echo 'TRUE=$(BAR$(V))
BAR0=false
BAR1=true
V=1
am__doit:
	@$(TRUE)
.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
  am_cv_make_support_nested_variables=yes
else
  am_cv_make_support_nested_variables=no
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
$as_echo "$am_cv_make_support_nested_variables" >&6; }
if test $am_cv_make_support_nested_variables = yes; then
    AM_V='$(V)'
  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
else
  AM_V=$AM_DEFAULT_VERBOSITY
  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
fi
AM_BACKSLASH='\'


USER_CFLAGS="-O2 $CFLAGS"

CFLAGS="$CFLAGS -Wall -Werror -g -Wno-pointer-sign"

case $target_os in
	*darwin*)
		TARGET_OS=darwin;
		LDFLAGS="$LDFLAGS -Qunused-arguments"
                CFLAGS="$CFLAGS -std=c99"
		;;
	*linux*)
		TARGET_OS=linux;
		CFLAGS="$CFLAGS -D_BSD_SOURCE -D_POSIX_SOURCE -D_GNU_SOURCE -std=c99"
		;;
	*solaris*)
		TARGET_OS=solaris;
		CFLAGS="$CFLAGS -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 -DBSD_COMP -std=c99"
		PLATFORM_LDADD='-lnsl -lsocket'

		;;
	*openbsd*)
                CFLAGS="$CFLAGS -std=c99"

$as_echo "#define HAVE_ATTRIBUTE__BOUNDED__ 1" >>confdefs.h

		;;
        *nacl*)
                TARGET_OS=nacl;
                ;;
	*) ;;
esac

 if test x$TARGET_OS = xdarwin; then
  TARGET_DARWIN_TRUE=
  TARGET_DARWIN_FALSE='#'
else
  TARGET_DARWIN_TRUE='#'
  TARGET_DARWIN_FALSE=
fi

 if test x$TARGET_OS = xlinux; then
  TARGET_LINUX_TRUE=
  TARGET_LINUX_FALSE='#'
else
  TARGET_LINUX_TRUE='#'
  TARGET_LINUX_FALSE=
fi

 if test x$TARGET_OS = xsolaris; then
  TARGET_SOLARIS_TRUE=
  TARGET_SOLARIS_FALSE='#'
else
  TARGET_SOLARIS_TRUE='#'
  TARGET_SOLARIS_FALSE=
fi

 if test x$TARGET_OS = xnacl; then
  TARGET_NACL_TRUE=
  TARGET_NACL_FALSE='#'
else
  TARGET_NACL_TRUE='#'
  TARGET_NACL_FALSE=
fi


ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
set dummy ${ac_tool_prefix}gcc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CC+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$CC"; then
  ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_CC="${ac_tool_prefix}gcc"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_prog_CC"; then
  ac_ct_CC=$CC
  # Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_CC+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_CC"; then
  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_CC="gcc"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
$as_echo "$ac_ct_CC" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

  if test "x$ac_ct_CC" = x; then
    CC=""
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    CC=$ac_ct_CC
  fi
else
  CC="$ac_cv_prog_CC"
fi

if test -z "$CC"; then
          if test -n "$ac_tool_prefix"; then
    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
set dummy ${ac_tool_prefix}cc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CC+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$CC"; then
  ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_CC="${ac_tool_prefix}cc"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


  fi
fi
if test -z "$CC"; then
  # Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CC+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$CC"; then
  ac_cv_prog_CC="$CC" # Let the user override the test.
else
  ac_prog_rejected=no
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
       ac_prog_rejected=yes
       continue
     fi
    ac_cv_prog_CC="cc"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

if test $ac_prog_rejected = yes; then
  # We found a bogon in the path, so make sure we never use it.
  set dummy $ac_cv_prog_CC
  shift
  if test $# != 0; then
    # We chose a different compiler from the bogus one.
    # However, it has the same basename, so the bogon will be chosen
    # first if we set CC to just the basename; use the full file name.
    shift
    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
  fi
fi
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$CC"; then
  if test -n "$ac_tool_prefix"; then
  for ac_prog in cl.exe
  do
    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CC+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$CC"; then
  ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


    test -n "$CC" && break
  done
fi
if test -z "$CC"; then
  ac_ct_CC=$CC
  for ac_prog in cl.exe
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_CC+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_CC"; then
  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_CC="$ac_prog"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
$as_echo "$ac_ct_CC" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


  test -n "$ac_ct_CC" && break
done

  if test "x$ac_ct_CC" = x; then
    CC=""
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    CC=$ac_ct_CC
  fi
fi

fi


test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "no acceptable C compiler found in \$PATH
See \`config.log' for more details" "$LINENO" 5; }

# Provide some information about the compiler.
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
set X $ac_compile
ac_compiler=$2
for ac_option in --version -v -V -qversion; do
  { { ac_try="$ac_compiler $ac_option >&5"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
  ac_status=$?
  if test -s conftest.err; then
    sed '10a\
... rest of stderr output deleted ...
         10q' conftest.err >conftest.er1
    cat conftest.er1 >&5
  fi
  rm -f conftest.er1 conftest.err
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }
done

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
# Try to create an executable without -o first, disregard a.out.
# It will help us diagnose broken compilers, and finding out an intuition
# of exeext.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
$as_echo_n "checking whether the C compiler works... " >&6; }
ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`

# The possible output files:
ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"

ac_rmfiles=
for ac_file in $ac_files
do
  case $ac_file in
    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
  esac
done
rm -f $ac_rmfiles

if { { ac_try="$ac_link_default"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_link_default") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; then :
  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
# in a Makefile.  We should not override ac_cv_exeext if it was cached,
# so that the user can short-circuit this test for compilers unknown to
# Autoconf.
for ac_file in $ac_files ''
do
  test -f "$ac_file" || continue
  case $ac_file in
    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
	;;
    [ab].out )
	# We found the default executable, but exeext='' is most
	# certainly right.
	break;;
    *.* )
	if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
	then :; else
	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
	fi
	# We set ac_cv_exeext here because the later test for it is not
	# safe: cross compilers may not add the suffix if given an `-o'
	# argument, so we may need to know it at that point already.
	# Even if this section looks crufty: it has the advantage of
	# actually working.
	break;;
    * )
	break;;
  esac
done
test "$ac_cv_exeext" = no && ac_cv_exeext=

else
  ac_file=''
fi
if test -z "$ac_file"; then :
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "C compiler cannot create executables
See \`config.log' for more details" "$LINENO" 5; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
$as_echo_n "checking for C compiler default output file name... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
$as_echo "$ac_file" >&6; }
ac_exeext=$ac_cv_exeext

rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
ac_clean_files=$ac_clean_files_save
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
$as_echo_n "checking for suffix of executables... " >&6; }
if { { ac_try="$ac_link"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_link") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; then :
  # If both `conftest.exe' and `conftest' are `present' (well, observable)
# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
# work properly (i.e., refer to `conftest.exe'), while it won't with
# `rm'.
for ac_file in conftest.exe conftest conftest.*; do
  test -f "$ac_file" || continue
  case $ac_file in
    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
	  break;;
    * ) break;;
  esac
done
else
  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot compute suffix of executables: cannot compile and link
See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest conftest$ac_cv_exeext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
$as_echo "$ac_cv_exeext" >&6; }

rm -f conftest.$ac_ext
EXEEXT=$ac_cv_exeext
ac_exeext=$EXEEXT
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 
int
main ()
{
FILE *f = fopen ("conftest.out", "w");
 return ferror (f) || fclose (f) != 0;

  ;
  return 0;
}
_ACEOF
ac_clean_files="$ac_clean_files conftest.out"
# Check that the compiler produces executables we can run.  If not, either
# the compiler is broken, or we cross compile.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
$as_echo_n "checking whether we are cross compiling... " >&6; }
if test "$cross_compiling" != yes; then
  { { ac_try="$ac_link"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_link") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }
  if { ac_try='./conftest$ac_cv_exeext'
  { { case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_try") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; }; then
    cross_compiling=no
  else
    if test "$cross_compiling" = maybe; then
	cross_compiling=yes
    else
	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
See \`config.log' for more details" "$LINENO" 5; }
    fi
  fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
$as_echo "$cross_compiling" >&6; }

rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
ac_clean_files=$ac_clean_files_save
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
$as_echo_n "checking for suffix of object files... " >&6; }
if ${ac_cv_objext+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
rm -f conftest.o conftest.obj
if { { ac_try="$ac_compile"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_compile") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; then :
  for ac_file in conftest.o conftest.obj conftest.*; do
  test -f "$ac_file" || continue;
  case $ac_file in
    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
       break;;
  esac
done
else
  $as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot compute suffix of object files: cannot compile
See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest.$ac_cv_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
$as_echo "$ac_cv_objext" >&6; }
OBJEXT=$ac_cv_objext
ac_objext=$OBJEXT
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
if ${ac_cv_c_compiler_gnu+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{
#ifndef __GNUC__
       choke me
#endif

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  ac_compiler_gnu=yes
else
  ac_compiler_gnu=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_cv_c_compiler_gnu=$ac_compiler_gnu

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
$as_echo "$ac_cv_c_compiler_gnu" >&6; }
if test $ac_compiler_gnu = yes; then
  GCC=yes
else
  GCC=
fi
ac_test_CFLAGS=${CFLAGS+set}
ac_save_CFLAGS=$CFLAGS
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
$as_echo_n "checking whether $CC accepts -g... " >&6; }
if ${ac_cv_prog_cc_g+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_save_c_werror_flag=$ac_c_werror_flag
   ac_c_werror_flag=yes
   ac_cv_prog_cc_g=no
   CFLAGS="-g"
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  ac_cv_prog_cc_g=yes
else
  CFLAGS=""
      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :

else
  ac_c_werror_flag=$ac_save_c_werror_flag
	 CFLAGS="-g"
	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  ac_cv_prog_cc_g=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
   ac_c_werror_flag=$ac_save_c_werror_flag
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
$as_echo "$ac_cv_prog_cc_g" >&6; }
if test "$ac_test_CFLAGS" = set; then
  CFLAGS=$ac_save_CFLAGS
elif test $ac_cv_prog_cc_g = yes; then
  if test "$GCC" = yes; then
    CFLAGS="-g -O2"
  else
    CFLAGS="-g"
  fi
else
  if test "$GCC" = yes; then
    CFLAGS="-O2"
  else
    CFLAGS=
  fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
if ${ac_cv_prog_cc_c89+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_cv_prog_cc_c89=no
ac_save_CC=$CC
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 
#include 
struct stat;
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
static char *e (p, i)
     char **p;
     int i;
{
  return p[i];
}
static char *f (char * (*g) (char **, int), char **p, ...)
{
  char *s;
  va_list v;
  va_start (v,p);
  s = g (p, va_arg (v,int));
  va_end (v);
  return s;
}

/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
   function prototypes and stuff, but not '\xHH' hex character constants.
   These don't provoke an error unfortunately, instead are silently treated
   as 'x'.  The following induces an error, until -std is added to get
   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
   array size at least.  It's necessary to write '\x00'==0 to get something
   that's true only with -std.  */
int osf4_cc_array ['\x00' == 0 ? 1 : -1];

/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
   inside strings and character constants.  */
#define FOO(x) 'x'
int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];

int test (int i, double x);
struct s1 {int (*f) (int a);};
struct s2 {int (*f) (double a);};
int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
int argc;
char **argv;
int
main ()
{
return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
  ;
  return 0;
}
_ACEOF
for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
do
  CC="$ac_save_CC $ac_arg"
  if ac_fn_c_try_compile "$LINENO"; then :
  ac_cv_prog_cc_c89=$ac_arg
fi
rm -f core conftest.err conftest.$ac_objext
  test "x$ac_cv_prog_cc_c89" != "xno" && break
done
rm -f conftest.$ac_ext
CC=$ac_save_CC

fi
# AC_CACHE_VAL
case "x$ac_cv_prog_cc_c89" in
  x)
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
$as_echo "none needed" >&6; } ;;
  xno)
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
$as_echo "unsupported" >&6; } ;;
  *)
    CC="$CC $ac_cv_prog_cc_c89"
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
esac
if test "x$ac_cv_prog_cc_c89" != xno; then :

fi

ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5
$as_echo_n "checking whether $CC understands -c and -o together... " >&6; }
if ${am_cv_prog_cc_c_o+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
  # Make sure it works both with $CC and with simple cc.
  # Following AC_PROG_CC_C_O, we do the test twice because some
  # compilers refuse to overwrite an existing .o file with -o,
  # though they will create one.
  am_cv_prog_cc_c_o=yes
  for am_i in 1 2; do
    if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5
   ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } \
         && test -f conftest2.$ac_objext; then
      : OK
    else
      am_cv_prog_cc_c_o=no
      break
    fi
  done
  rm -f core conftest*
  unset am_i
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5
$as_echo "$am_cv_prog_cc_c_o" >&6; }
if test "$am_cv_prog_cc_c_o" != yes; then
   # Losing compiler, so override with the script.
   # FIXME: It is wrong to rewrite CC.
   # But if we don't then we get into trouble of one sort or another.
   # A longer-term fix would be to have automake use am__CC in this case,
   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
   CC="$am_aux_dir/compile $CC"
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

DEPDIR="${am__leading_dot}deps"

ac_config_commands="$ac_config_commands depfiles"


am_make=${MAKE-make}
cat > confinc << 'END'
am__doit:
	@echo this is the am__doit target
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
$as_echo_n "checking for style of include used by $am_make... " >&6; }
am__include="#"
am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# Ignore all kinds of additional output from 'make'.
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
  am__include=include
  am__quote=
  _am_result=GNU
  ;;
esac
# Now try BSD make style include.
if test "$am__include" = "#"; then
   echo '.include "confinc"' > confmf
   case `$am_make -s -f confmf 2> /dev/null` in #(
   *the\ am__doit\ target*)
     am__include=.include
     am__quote="\""
     _am_result=BSD
     ;;
   esac
fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
$as_echo "$_am_result" >&6; }
rm -f confinc confmf

# Check whether --enable-dependency-tracking was given.
if test "${enable_dependency_tracking+set}" = set; then :
  enableval=$enable_dependency_tracking;
fi

if test "x$enable_dependency_tracking" != xno; then
  am_depcomp="$ac_aux_dir/depcomp"
  AMDEPBACKSLASH='\'
  am__nodep='_no'
fi
 if test "x$enable_dependency_tracking" != xno; then
  AMDEP_TRUE=
  AMDEP_FALSE='#'
else
  AMDEP_TRUE='#'
  AMDEP_FALSE=
fi



depcc="$CC"   am_compiler_list=

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
$as_echo_n "checking dependency style of $depcc... " >&6; }
if ${am_cv_CC_dependencies_compiler_type+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
  # We make a subdir and do the tests there.  Otherwise we can end up
  # making bogus files that we don't know about and never remove.  For
  # instance it was reported that on HP-UX the gcc test will end up
  # making a dummy file named 'D' -- because '-MD' means "put the output
  # in D".
  rm -rf conftest.dir
  mkdir conftest.dir
  # Copy depcomp to subdir because otherwise we won't find it if we're
  # using a relative directory.
  cp "$am_depcomp" conftest.dir
  cd conftest.dir
  # We will build objects and dependencies in a subdirectory because
  # it helps to detect inapplicable dependency modes.  For instance
  # both Tru64's cc and ICC support -MD to output dependencies as a
  # side effect of compilation, but ICC will put the dependencies in
  # the current directory while Tru64 will put them in the object
  # directory.
  mkdir sub

  am_cv_CC_dependencies_compiler_type=none
  if test "$am_compiler_list" = ""; then
     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
  fi
  am__universal=false
  case " $depcc " in #(
     *\ -arch\ *\ -arch\ *) am__universal=true ;;
     esac

  for depmode in $am_compiler_list; do
    # Setup a source with many dependencies, because some compilers
    # like to wrap large dependency lists on column 80 (with \), and
    # we should not choose a depcomp mode which is confused by this.
    #
    # We need to recreate these files for each test, as the compiler may
    # overwrite some of them when testing with obscure command lines.
    # This happens at least with the AIX C compiler.
    : > sub/conftest.c
    for i in 1 2 3 4 5 6; do
      echo '#include "conftst'$i'.h"' >> sub/conftest.c
      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
      # Solaris 10 /bin/sh.
      echo '/* dummy */' > sub/conftst$i.h
    done
    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf

    # We check with '-c' and '-o' for the sake of the "dashmstdout"
    # mode.  It turns out that the SunPro C++ compiler does not properly
    # handle '-M -o', and we need to detect this.  Also, some Intel
    # versions had trouble with output in subdirs.
    am__obj=sub/conftest.${OBJEXT-o}
    am__minus_obj="-o $am__obj"
    case $depmode in
    gcc)
      # This depmode causes a compiler race in universal mode.
      test "$am__universal" = false || continue
      ;;
    nosideeffect)
      # After this tag, mechanisms are not by side-effect, so they'll
      # only be used when explicitly requested.
      if test "x$enable_dependency_tracking" = xyes; then
	continue
      else
	break
      fi
      ;;
    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
      # This compiler won't grok '-c -o', but also, the minuso test has
      # not run yet.  These depmodes are late enough in the game, and
      # so weak that their functioning should not be impacted.
      am__obj=conftest.${OBJEXT-o}
      am__minus_obj=
      ;;
    none) break ;;
    esac
    if depmode=$depmode \
       source=sub/conftest.c object=$am__obj \
       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
         >/dev/null 2>conftest.err &&
       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
      # icc doesn't choke on unknown options, it will just issue warnings
      # or remarks (even with -Werror).  So we grep stderr for any message
      # that says an option was ignored or not supported.
      # When given -MP, icc 7.0 and 7.1 complain thusly:
      #   icc: Command line warning: ignoring option '-M'; no argument required
      # The diagnosis changed in icc 8.0:
      #   icc: Command line remark: option '-MP' not supported
      if (grep 'ignoring option' conftest.err ||
          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
        am_cv_CC_dependencies_compiler_type=$depmode
        break
      fi
    fi
  done

  cd ..
  rm -rf conftest.dir
else
  am_cv_CC_dependencies_compiler_type=none
fi

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type

 if
  test "x$enable_dependency_tracking" != xno \
  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
  am__fastdepCC_TRUE=
  am__fastdepCC_FALSE='#'
else
  am__fastdepCC_TRUE='#'
  am__fastdepCC_FALSE=
fi


case `pwd` in
  *\ * | *\	*)
    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
esac



macro_version='2.4.2'
macro_revision='1.3337'













ltmain="$ac_aux_dir/ltmain.sh"

# Backslashify metacharacters that are still active within
# double-quoted strings.
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'

# Same as above, but do not quote variable references.
double_quote_subst='s/\(["`\\]\)/\\\1/g'

# Sed substitution to delay expansion of an escaped shell variable in a
# double_quote_subst'ed string.
delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'

# Sed substitution to delay expansion of an escaped single quote.
delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'

# Sed substitution to avoid accidental globbing in evaled expressions
no_glob_subst='s/\*/\\\*/g'

ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5
$as_echo_n "checking how to print strings... " >&6; }
# Test print first, because it will be a builtin if present.
if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
   test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
  ECHO='print -r --'
elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
  ECHO='printf %s\n'
else
  # Use this function as a fallback that always works.
  func_fallback_echo ()
  {
    eval 'cat <<_LTECHO_EOF
$1
_LTECHO_EOF'
  }
  ECHO='func_fallback_echo'
fi

# func_echo_all arg...
# Invoke $ECHO with all args, space-separated.
func_echo_all ()
{
    $ECHO ""
}

case "$ECHO" in
  printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
$as_echo "printf" >&6; } ;;
  print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
$as_echo "print -r" >&6; } ;;
  *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5
$as_echo "cat" >&6; } ;;
esac














{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
$as_echo_n "checking for a sed that does not truncate output... " >&6; }
if ${ac_cv_path_SED+:} false; then :
  $as_echo_n "(cached) " >&6
else
            ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
     for ac_i in 1 2 3 4 5 6 7; do
       ac_script="$ac_script$as_nl$ac_script"
     done
     echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
     { ac_script=; unset ac_script;}
     if test -z "$SED"; then
  ac_path_SED_found=false
  # Loop through the user's path and test for each of PROGNAME-LIST
  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_prog in sed gsed; do
    for ac_exec_ext in '' $ac_executable_extensions; do
      ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
      as_fn_executable_p "$ac_path_SED" || continue
# Check for GNU ac_path_SED and select it if it is found.
  # Check for GNU $ac_path_SED
case `"$ac_path_SED" --version 2>&1` in
*GNU*)
  ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
*)
  ac_count=0
  $as_echo_n 0123456789 >"conftest.in"
  while :
  do
    cat "conftest.in" "conftest.in" >"conftest.tmp"
    mv "conftest.tmp" "conftest.in"
    cp "conftest.in" "conftest.nl"
    $as_echo '' >> "conftest.nl"
    "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
    as_fn_arith $ac_count + 1 && ac_count=$as_val
    if test $ac_count -gt ${ac_path_SED_max-0}; then
      # Best one so far, save it but keep looking for a better one
      ac_cv_path_SED="$ac_path_SED"
      ac_path_SED_max=$ac_count
    fi
    # 10*(2^10) chars as input seems more than enough
    test $ac_count -gt 10 && break
  done
  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac

      $ac_path_SED_found && break 3
    done
  done
  done
IFS=$as_save_IFS
  if test -z "$ac_cv_path_SED"; then
    as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
  fi
else
  ac_cv_path_SED=$SED
fi

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
$as_echo "$ac_cv_path_SED" >&6; }
 SED="$ac_cv_path_SED"
  rm -f conftest.sed

test -z "$SED" && SED=sed
Xsed="$SED -e 1s/^X//"











{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
if ${ac_cv_path_GREP+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -z "$GREP"; then
  ac_path_GREP_found=false
  # Loop through the user's path and test for each of PROGNAME-LIST
  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_prog in grep ggrep; do
    for ac_exec_ext in '' $ac_executable_extensions; do
      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
      as_fn_executable_p "$ac_path_GREP" || continue
# Check for GNU ac_path_GREP and select it if it is found.
  # Check for GNU $ac_path_GREP
case `"$ac_path_GREP" --version 2>&1` in
*GNU*)
  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
*)
  ac_count=0
  $as_echo_n 0123456789 >"conftest.in"
  while :
  do
    cat "conftest.in" "conftest.in" >"conftest.tmp"
    mv "conftest.tmp" "conftest.in"
    cp "conftest.in" "conftest.nl"
    $as_echo 'GREP' >> "conftest.nl"
    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
    as_fn_arith $ac_count + 1 && ac_count=$as_val
    if test $ac_count -gt ${ac_path_GREP_max-0}; then
      # Best one so far, save it but keep looking for a better one
      ac_cv_path_GREP="$ac_path_GREP"
      ac_path_GREP_max=$ac_count
    fi
    # 10*(2^10) chars as input seems more than enough
    test $ac_count -gt 10 && break
  done
  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac

      $ac_path_GREP_found && break 3
    done
  done
  done
IFS=$as_save_IFS
  if test -z "$ac_cv_path_GREP"; then
    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
  fi
else
  ac_cv_path_GREP=$GREP
fi

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
$as_echo "$ac_cv_path_GREP" >&6; }
 GREP="$ac_cv_path_GREP"


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
$as_echo_n "checking for egrep... " >&6; }
if ${ac_cv_path_EGREP+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
   then ac_cv_path_EGREP="$GREP -E"
   else
     if test -z "$EGREP"; then
  ac_path_EGREP_found=false
  # Loop through the user's path and test for each of PROGNAME-LIST
  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_prog in egrep; do
    for ac_exec_ext in '' $ac_executable_extensions; do
      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
      as_fn_executable_p "$ac_path_EGREP" || continue
# Check for GNU ac_path_EGREP and select it if it is found.
  # Check for GNU $ac_path_EGREP
case `"$ac_path_EGREP" --version 2>&1` in
*GNU*)
  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
*)
  ac_count=0
  $as_echo_n 0123456789 >"conftest.in"
  while :
  do
    cat "conftest.in" "conftest.in" >"conftest.tmp"
    mv "conftest.tmp" "conftest.in"
    cp "conftest.in" "conftest.nl"
    $as_echo 'EGREP' >> "conftest.nl"
    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
    as_fn_arith $ac_count + 1 && ac_count=$as_val
    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
      # Best one so far, save it but keep looking for a better one
      ac_cv_path_EGREP="$ac_path_EGREP"
      ac_path_EGREP_max=$ac_count
    fi
    # 10*(2^10) chars as input seems more than enough
    test $ac_count -gt 10 && break
  done
  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac

      $ac_path_EGREP_found && break 3
    done
  done
  done
IFS=$as_save_IFS
  if test -z "$ac_cv_path_EGREP"; then
    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
  fi
else
  ac_cv_path_EGREP=$EGREP
fi

   fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
$as_echo "$ac_cv_path_EGREP" >&6; }
 EGREP="$ac_cv_path_EGREP"


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
$as_echo_n "checking for fgrep... " >&6; }
if ${ac_cv_path_FGREP+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
   then ac_cv_path_FGREP="$GREP -F"
   else
     if test -z "$FGREP"; then
  ac_path_FGREP_found=false
  # Loop through the user's path and test for each of PROGNAME-LIST
  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_prog in fgrep; do
    for ac_exec_ext in '' $ac_executable_extensions; do
      ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
      as_fn_executable_p "$ac_path_FGREP" || continue
# Check for GNU ac_path_FGREP and select it if it is found.
  # Check for GNU $ac_path_FGREP
case `"$ac_path_FGREP" --version 2>&1` in
*GNU*)
  ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
*)
  ac_count=0
  $as_echo_n 0123456789 >"conftest.in"
  while :
  do
    cat "conftest.in" "conftest.in" >"conftest.tmp"
    mv "conftest.tmp" "conftest.in"
    cp "conftest.in" "conftest.nl"
    $as_echo 'FGREP' >> "conftest.nl"
    "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
    as_fn_arith $ac_count + 1 && ac_count=$as_val
    if test $ac_count -gt ${ac_path_FGREP_max-0}; then
      # Best one so far, save it but keep looking for a better one
      ac_cv_path_FGREP="$ac_path_FGREP"
      ac_path_FGREP_max=$ac_count
    fi
    # 10*(2^10) chars as input seems more than enough
    test $ac_count -gt 10 && break
  done
  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac

      $ac_path_FGREP_found && break 3
    done
  done
  done
IFS=$as_save_IFS
  if test -z "$ac_cv_path_FGREP"; then
    as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
  fi
else
  ac_cv_path_FGREP=$FGREP
fi

   fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
$as_echo "$ac_cv_path_FGREP" >&6; }
 FGREP="$ac_cv_path_FGREP"


test -z "$GREP" && GREP=grep



















# Check whether --with-gnu-ld was given.
if test "${with_gnu_ld+set}" = set; then :
  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
else
  with_gnu_ld=no
fi

ac_prog=ld
if test "$GCC" = yes; then
  # Check if gcc -print-prog-name=ld gives a path.
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
$as_echo_n "checking for ld used by $CC... " >&6; }
  case $host in
  *-*-mingw*)
    # gcc leaves a trailing carriage return which upsets mingw
    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
  *)
    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
  esac
  case $ac_prog in
    # Accept absolute paths.
    [\\/]* | ?:[\\/]*)
      re_direlt='/[^/][^/]*/\.\./'
      # Canonicalize the pathname of ld
      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
      done
      test -z "$LD" && LD="$ac_prog"
      ;;
  "")
    # If it fails, then pretend we aren't using GCC.
    ac_prog=ld
    ;;
  *)
    # If it is relative, then search for the first ld in PATH.
    with_gnu_ld=unknown
    ;;
  esac
elif test "$with_gnu_ld" = yes; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
$as_echo_n "checking for GNU ld... " >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
$as_echo_n "checking for non-GNU ld... " >&6; }
fi
if ${lt_cv_path_LD+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -z "$LD"; then
  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
  for ac_dir in $PATH; do
    IFS="$lt_save_ifs"
    test -z "$ac_dir" && ac_dir=.
    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
      lt_cv_path_LD="$ac_dir/$ac_prog"
      # Check to see if the program is GNU ld.  I'd rather use --version,
      # but apparently some variants of GNU ld only accept -v.
      # Break only if it was the GNU/non-GNU ld that we prefer.
      case `"$lt_cv_path_LD" -v 2>&1 &5
$as_echo "$LD" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
if ${lt_cv_prog_gnu_ld+:} false; then :
  $as_echo_n "(cached) " >&6
else
  # I'd rather use --version here, but apparently some GNU lds only accept -v.
case `$LD -v 2>&1 &5
$as_echo "$lt_cv_prog_gnu_ld" >&6; }
with_gnu_ld=$lt_cv_prog_gnu_ld









{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
if ${lt_cv_path_NM+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$NM"; then
  # Let the user override the test.
  lt_cv_path_NM="$NM"
else
  lt_nm_to_check="${ac_tool_prefix}nm"
  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
    lt_nm_to_check="$lt_nm_to_check nm"
  fi
  for lt_tmp_nm in $lt_nm_to_check; do
    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
      IFS="$lt_save_ifs"
      test -z "$ac_dir" && ac_dir=.
      tmp_nm="$ac_dir/$lt_tmp_nm"
      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
	# Check to see if the nm accepts a BSD-compat flag.
	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
	#   nm: unknown option "B" ignored
	# Tru64's nm complains that /dev/null is an invalid object file
	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
	*/dev/null* | *'Invalid file or object type'*)
	  lt_cv_path_NM="$tmp_nm -B"
	  break
	  ;;
	*)
	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
	  */dev/null*)
	    lt_cv_path_NM="$tmp_nm -p"
	    break
	    ;;
	  *)
	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
	    continue # so that we can try to find one that supports BSD flags
	    ;;
	  esac
	  ;;
	esac
      fi
    done
    IFS="$lt_save_ifs"
  done
  : ${lt_cv_path_NM=no}
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
$as_echo "$lt_cv_path_NM" >&6; }
if test "$lt_cv_path_NM" != "no"; then
  NM="$lt_cv_path_NM"
else
  # Didn't find any BSD compatible name lister, look for dumpbin.
  if test -n "$DUMPBIN"; then :
    # Let the user override the test.
  else
    if test -n "$ac_tool_prefix"; then
  for ac_prog in dumpbin "link -dump"
  do
    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_DUMPBIN+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$DUMPBIN"; then
  ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
DUMPBIN=$ac_cv_prog_DUMPBIN
if test -n "$DUMPBIN"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
$as_echo "$DUMPBIN" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


    test -n "$DUMPBIN" && break
  done
fi
if test -z "$DUMPBIN"; then
  ac_ct_DUMPBIN=$DUMPBIN
  for ac_prog in dumpbin "link -dump"
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_DUMPBIN"; then
  ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
if test -n "$ac_ct_DUMPBIN"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
$as_echo "$ac_ct_DUMPBIN" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


  test -n "$ac_ct_DUMPBIN" && break
done

  if test "x$ac_ct_DUMPBIN" = x; then
    DUMPBIN=":"
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    DUMPBIN=$ac_ct_DUMPBIN
  fi
fi

    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
    *COFF*)
      DUMPBIN="$DUMPBIN -symbols"
      ;;
    *)
      DUMPBIN=:
      ;;
    esac
  fi

  if test "$DUMPBIN" != ":"; then
    NM="$DUMPBIN"
  fi
fi
test -z "$NM" && NM=nm






{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
$as_echo_n "checking the name lister ($NM) interface... " >&6; }
if ${lt_cv_nm_interface+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_nm_interface="BSD nm"
  echo "int some_variable = 0;" > conftest.$ac_ext
  (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5)
  (eval "$ac_compile" 2>conftest.err)
  cat conftest.err >&5
  (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
  cat conftest.err >&5
  (eval echo "\"\$as_me:$LINENO: output\"" >&5)
  cat conftest.out >&5
  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
    lt_cv_nm_interface="MS dumpbin"
  fi
  rm -f conftest*
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
$as_echo "$lt_cv_nm_interface" >&6; }

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
$as_echo_n "checking whether ln -s works... " >&6; }
LN_S=$as_ln_s
if test "$LN_S" = "ln -s"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
$as_echo "no, using $LN_S" >&6; }
fi

# find the maximum length of command line arguments
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
$as_echo_n "checking the maximum length of command line arguments... " >&6; }
if ${lt_cv_sys_max_cmd_len+:} false; then :
  $as_echo_n "(cached) " >&6
else
    i=0
  teststring="ABCD"

  case $build_os in
  msdosdjgpp*)
    # On DJGPP, this test can blow up pretty badly due to problems in libc
    # (any single argument exceeding 2000 bytes causes a buffer overrun
    # during glob expansion).  Even if it were fixed, the result of this
    # check would be larger than it should be.
    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
    ;;

  gnu*)
    # Under GNU Hurd, this test is not required because there is
    # no limit to the length of command line arguments.
    # Libtool will interpret -1 as no limit whatsoever
    lt_cv_sys_max_cmd_len=-1;
    ;;

  cygwin* | mingw* | cegcc*)
    # On Win9x/ME, this test blows up -- it succeeds, but takes
    # about 5 minutes as the teststring grows exponentially.
    # Worse, since 9x/ME are not pre-emptively multitasking,
    # you end up with a "frozen" computer, even though with patience
    # the test eventually succeeds (with a max line length of 256k).
    # Instead, let's just punt: use the minimum linelength reported by
    # all of the supported platforms: 8192 (on NT/2K/XP).
    lt_cv_sys_max_cmd_len=8192;
    ;;

  mint*)
    # On MiNT this can take a long time and run out of memory.
    lt_cv_sys_max_cmd_len=8192;
    ;;

  amigaos*)
    # On AmigaOS with pdksh, this test takes hours, literally.
    # So we just punt and use a minimum line length of 8192.
    lt_cv_sys_max_cmd_len=8192;
    ;;

  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
    # This has been around since 386BSD, at least.  Likely further.
    if test -x /sbin/sysctl; then
      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
    elif test -x /usr/sbin/sysctl; then
      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
    else
      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
    fi
    # And add a safety zone
    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
    ;;

  interix*)
    # We know the value 262144 and hardcode it with a safety zone (like BSD)
    lt_cv_sys_max_cmd_len=196608
    ;;

  os2*)
    # The test takes a long time on OS/2.
    lt_cv_sys_max_cmd_len=8192
    ;;

  osf*)
    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
    # nice to cause kernel panics so lets avoid the loop below.
    # First set a reasonable default.
    lt_cv_sys_max_cmd_len=16384
    #
    if test -x /sbin/sysconfig; then
      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
        *1*) lt_cv_sys_max_cmd_len=-1 ;;
      esac
    fi
    ;;
  sco3.2v5*)
    lt_cv_sys_max_cmd_len=102400
    ;;
  sysv5* | sco5v6* | sysv4.2uw2*)
    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
    if test -n "$kargmax"; then
      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[	 ]//'`
    else
      lt_cv_sys_max_cmd_len=32768
    fi
    ;;
  *)
    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
    if test -n "$lt_cv_sys_max_cmd_len"; then
      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
    else
      # Make teststring a little bigger before we do anything with it.
      # a 1K string should be a reasonable start.
      for i in 1 2 3 4 5 6 7 8 ; do
        teststring=$teststring$teststring
      done
      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
      # If test is not a shell built-in, we'll probably end up computing a
      # maximum length that is only half of the actual maximum length, but
      # we can't tell.
      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
	      test $i != 17 # 1/2 MB should be enough
      do
        i=`expr $i + 1`
        teststring=$teststring$teststring
      done
      # Only check the string length outside the loop.
      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
      teststring=
      # Add a significant safety factor because C++ compilers can tack on
      # massive amounts of additional arguments before passing them to the
      # linker.  It appears as though 1/2 is a usable value.
      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
    fi
    ;;
  esac

fi

if test -n $lt_cv_sys_max_cmd_len ; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
$as_echo "$lt_cv_sys_max_cmd_len" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
$as_echo "none" >&6; }
fi
max_cmd_len=$lt_cv_sys_max_cmd_len






: ${CP="cp -f"}
: ${MV="mv -f"}
: ${RM="rm -f"}

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
# Try some XSI features
xsi_shell=no
( _lt_dummy="a/b/c"
  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
      = c,a/b,b/c, \
    && eval 'test $(( 1 + 1 )) -eq 2 \
    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
  && xsi_shell=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
$as_echo "$xsi_shell" >&6; }


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
lt_shell_append=no
( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
    >/dev/null 2>&1 \
  && lt_shell_append=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
$as_echo "$lt_shell_append" >&6; }


if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
  lt_unset=unset
else
  lt_unset=false
fi





# test EBCDIC or ASCII
case `echo X|tr X '\101'` in
 A) # ASCII based system
    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
  lt_SP2NL='tr \040 \012'
  lt_NL2SP='tr \015\012 \040\040'
  ;;
 *) # EBCDIC based system
  lt_SP2NL='tr \100 \n'
  lt_NL2SP='tr \r\n \100\100'
  ;;
esac









{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5
$as_echo_n "checking how to convert $build file names to $host format... " >&6; }
if ${lt_cv_to_host_file_cmd+:} false; then :
  $as_echo_n "(cached) " >&6
else
  case $host in
  *-*-mingw* )
    case $build in
      *-*-mingw* ) # actually msys
        lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
        ;;
      *-*-cygwin* )
        lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
        ;;
      * ) # otherwise, assume *nix
        lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
        ;;
    esac
    ;;
  *-*-cygwin* )
    case $build in
      *-*-mingw* ) # actually msys
        lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
        ;;
      *-*-cygwin* )
        lt_cv_to_host_file_cmd=func_convert_file_noop
        ;;
      * ) # otherwise, assume *nix
        lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
        ;;
    esac
    ;;
  * ) # unhandled hosts (and "normal" native builds)
    lt_cv_to_host_file_cmd=func_convert_file_noop
    ;;
esac

fi

to_host_file_cmd=$lt_cv_to_host_file_cmd
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5
$as_echo "$lt_cv_to_host_file_cmd" >&6; }





{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5
$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; }
if ${lt_cv_to_tool_file_cmd+:} false; then :
  $as_echo_n "(cached) " >&6
else
  #assume ordinary cross tools, or native build.
lt_cv_to_tool_file_cmd=func_convert_file_noop
case $host in
  *-*-mingw* )
    case $build in
      *-*-mingw* ) # actually msys
        lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
        ;;
    esac
    ;;
esac

fi

to_tool_file_cmd=$lt_cv_to_tool_file_cmd
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5
$as_echo "$lt_cv_to_tool_file_cmd" >&6; }





{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
$as_echo_n "checking for $LD option to reload object files... " >&6; }
if ${lt_cv_ld_reload_flag+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_ld_reload_flag='-r'
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
$as_echo "$lt_cv_ld_reload_flag" >&6; }
reload_flag=$lt_cv_ld_reload_flag
case $reload_flag in
"" | " "*) ;;
*) reload_flag=" $reload_flag" ;;
esac
reload_cmds='$LD$reload_flag -o $output$reload_objs'
case $host_os in
  cygwin* | mingw* | pw32* | cegcc*)
    if test "$GCC" != yes; then
      reload_cmds=false
    fi
    ;;
  darwin*)
    if test "$GCC" = yes; then
      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
    else
      reload_cmds='$LD$reload_flag -o $output$reload_objs'
    fi
    ;;
esac









if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
set dummy ${ac_tool_prefix}objdump; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_OBJDUMP+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$OBJDUMP"; then
  ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
OBJDUMP=$ac_cv_prog_OBJDUMP
if test -n "$OBJDUMP"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
$as_echo "$OBJDUMP" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_prog_OBJDUMP"; then
  ac_ct_OBJDUMP=$OBJDUMP
  # Extract the first word of "objdump", so it can be a program name with args.
set dummy objdump; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_OBJDUMP"; then
  ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_OBJDUMP="objdump"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
if test -n "$ac_ct_OBJDUMP"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
$as_echo "$ac_ct_OBJDUMP" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

  if test "x$ac_ct_OBJDUMP" = x; then
    OBJDUMP="false"
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    OBJDUMP=$ac_ct_OBJDUMP
  fi
else
  OBJDUMP="$ac_cv_prog_OBJDUMP"
fi

test -z "$OBJDUMP" && OBJDUMP=objdump









{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
$as_echo_n "checking how to recognize dependent libraries... " >&6; }
if ${lt_cv_deplibs_check_method+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_file_magic_cmd='$MAGIC_CMD'
lt_cv_file_magic_test_file=
lt_cv_deplibs_check_method='unknown'
# Need to set the preceding variable on all platforms that support
# interlibrary dependencies.
# 'none' -- dependencies not supported.
# `unknown' -- same as none, but documents that we really don't know.
# 'pass_all' -- all dependencies passed with no checks.
# 'test_compile' -- check by making test program.
# 'file_magic [[regex]]' -- check by looking for files in library path
# which responds to the $file_magic_cmd with a given extended regex.
# If you have `file' or equivalent on your system and you're not sure
# whether `pass_all' will *always* work, you probably want this one.

case $host_os in
aix[4-9]*)
  lt_cv_deplibs_check_method=pass_all
  ;;

beos*)
  lt_cv_deplibs_check_method=pass_all
  ;;

bsdi[45]*)
  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
  lt_cv_file_magic_cmd='/usr/bin/file -L'
  lt_cv_file_magic_test_file=/shlib/libc.so
  ;;

cygwin*)
  # func_win32_libid is a shell function defined in ltmain.sh
  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
  lt_cv_file_magic_cmd='func_win32_libid'
  ;;

mingw* | pw32*)
  # Base MSYS/MinGW do not provide the 'file' command needed by
  # func_win32_libid shell function, so use a weaker test based on 'objdump',
  # unless we find 'file', for example because we are cross-compiling.
  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
    lt_cv_file_magic_cmd='func_win32_libid'
  else
    # Keep this pattern in sync with the one in func_win32_libid.
    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
    lt_cv_file_magic_cmd='$OBJDUMP -f'
  fi
  ;;

cegcc*)
  # use the weaker test based on 'objdump'. See mingw*.
  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
  lt_cv_file_magic_cmd='$OBJDUMP -f'
  ;;

darwin* | rhapsody*)
  lt_cv_deplibs_check_method=pass_all
  ;;

freebsd* | dragonfly*)
  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
    case $host_cpu in
    i*86 )
      # Not sure whether the presence of OpenBSD here was a mistake.
      # Let's accept both of them until this is cleared up.
      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
      lt_cv_file_magic_cmd=/usr/bin/file
      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
      ;;
    esac
  else
    lt_cv_deplibs_check_method=pass_all
  fi
  ;;

gnu*)
  lt_cv_deplibs_check_method=pass_all
  ;;

haiku*)
  lt_cv_deplibs_check_method=pass_all
  ;;

hpux10.20* | hpux11*)
  lt_cv_file_magic_cmd=/usr/bin/file
  case $host_cpu in
  ia64*)
    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
    ;;
  hppa*64*)
    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'
    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
    ;;
  *)
    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library'
    lt_cv_file_magic_test_file=/usr/lib/libc.sl
    ;;
  esac
  ;;

interix[3-9]*)
  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
  ;;

irix5* | irix6* | nonstopux*)
  case $LD in
  *-32|*"-32 ") libmagic=32-bit;;
  *-n32|*"-n32 ") libmagic=N32;;
  *-64|*"-64 ") libmagic=64-bit;;
  *) libmagic=never-match;;
  esac
  lt_cv_deplibs_check_method=pass_all
  ;;

# This must be glibc/ELF.
linux* | k*bsd*-gnu | kopensolaris*-gnu)
  lt_cv_deplibs_check_method=pass_all
  ;;

netbsd*)
  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
  else
    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
  fi
  ;;

newos6*)
  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
  lt_cv_file_magic_cmd=/usr/bin/file
  lt_cv_file_magic_test_file=/usr/lib/libnls.so
  ;;

*nto* | *qnx*)
  lt_cv_deplibs_check_method=pass_all
  ;;

openbsd*)
  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
  else
    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
  fi
  ;;

osf3* | osf4* | osf5*)
  lt_cv_deplibs_check_method=pass_all
  ;;

rdos*)
  lt_cv_deplibs_check_method=pass_all
  ;;

solaris*)
  lt_cv_deplibs_check_method=pass_all
  ;;

sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
  lt_cv_deplibs_check_method=pass_all
  ;;

sysv4 | sysv4.3*)
  case $host_vendor in
  motorola)
    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
    ;;
  ncr)
    lt_cv_deplibs_check_method=pass_all
    ;;
  sequent)
    lt_cv_file_magic_cmd='/bin/file'
    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
    ;;
  sni)
    lt_cv_file_magic_cmd='/bin/file'
    lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
    lt_cv_file_magic_test_file=/lib/libc.so
    ;;
  siemens)
    lt_cv_deplibs_check_method=pass_all
    ;;
  pc)
    lt_cv_deplibs_check_method=pass_all
    ;;
  esac
  ;;

tpf*)
  lt_cv_deplibs_check_method=pass_all
  ;;
esac

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
$as_echo "$lt_cv_deplibs_check_method" >&6; }

file_magic_glob=
want_nocaseglob=no
if test "$build" = "$host"; then
  case $host_os in
  mingw* | pw32*)
    if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
      want_nocaseglob=yes
    else
      file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"`
    fi
    ;;
  esac
fi

file_magic_cmd=$lt_cv_file_magic_cmd
deplibs_check_method=$lt_cv_deplibs_check_method
test -z "$deplibs_check_method" && deplibs_check_method=unknown






















if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
set dummy ${ac_tool_prefix}dlltool; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_DLLTOOL+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$DLLTOOL"; then
  ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
DLLTOOL=$ac_cv_prog_DLLTOOL
if test -n "$DLLTOOL"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
$as_echo "$DLLTOOL" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_prog_DLLTOOL"; then
  ac_ct_DLLTOOL=$DLLTOOL
  # Extract the first word of "dlltool", so it can be a program name with args.
set dummy dlltool; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_DLLTOOL"; then
  ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_DLLTOOL="dlltool"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
if test -n "$ac_ct_DLLTOOL"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
$as_echo "$ac_ct_DLLTOOL" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

  if test "x$ac_ct_DLLTOOL" = x; then
    DLLTOOL="false"
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    DLLTOOL=$ac_ct_DLLTOOL
  fi
else
  DLLTOOL="$ac_cv_prog_DLLTOOL"
fi

test -z "$DLLTOOL" && DLLTOOL=dlltool










{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5
$as_echo_n "checking how to associate runtime and link libraries... " >&6; }
if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_sharedlib_from_linklib_cmd='unknown'

case $host_os in
cygwin* | mingw* | pw32* | cegcc*)
  # two different shell functions defined in ltmain.sh
  # decide which to use based on capabilities of $DLLTOOL
  case `$DLLTOOL --help 2>&1` in
  *--identify-strict*)
    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
    ;;
  *)
    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
    ;;
  esac
  ;;
*)
  # fallback: assume linklib IS sharedlib
  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
  ;;
esac

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5
$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; }
sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO








if test -n "$ac_tool_prefix"; then
  for ac_prog in ar
  do
    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_AR+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$AR"; then
  ac_cv_prog_AR="$AR" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
AR=$ac_cv_prog_AR
if test -n "$AR"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
$as_echo "$AR" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


    test -n "$AR" && break
  done
fi
if test -z "$AR"; then
  ac_ct_AR=$AR
  for ac_prog in ar
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_AR+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_AR"; then
  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_AR="$ac_prog"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_AR=$ac_cv_prog_ac_ct_AR
if test -n "$ac_ct_AR"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
$as_echo "$ac_ct_AR" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


  test -n "$ac_ct_AR" && break
done

  if test "x$ac_ct_AR" = x; then
    AR="false"
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    AR=$ac_ct_AR
  fi
fi

: ${AR=ar}
: ${AR_FLAGS=cru}











{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5
$as_echo_n "checking for archiver @FILE support... " >&6; }
if ${lt_cv_ar_at_file+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_ar_at_file=no
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  echo conftest.$ac_objext > conftest.lst
      lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5'
      { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
  (eval $lt_ar_try) 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }
      if test "$ac_status" -eq 0; then
	# Ensure the archiver fails upon bogus file names.
	rm -f conftest.$ac_objext libconftest.a
	{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
  (eval $lt_ar_try) 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }
	if test "$ac_status" -ne 0; then
          lt_cv_ar_at_file=@
        fi
      fi
      rm -f conftest.* libconftest.a

fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
$as_echo "$lt_cv_ar_at_file" >&6; }

if test "x$lt_cv_ar_at_file" = xno; then
  archiver_list_spec=
else
  archiver_list_spec=$lt_cv_ar_at_file
fi







if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
set dummy ${ac_tool_prefix}strip; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_STRIP+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$STRIP"; then
  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
STRIP=$ac_cv_prog_STRIP
if test -n "$STRIP"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
$as_echo "$STRIP" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_prog_STRIP"; then
  ac_ct_STRIP=$STRIP
  # Extract the first word of "strip", so it can be a program name with args.
set dummy strip; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_STRIP"; then
  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_STRIP="strip"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
if test -n "$ac_ct_STRIP"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
$as_echo "$ac_ct_STRIP" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

  if test "x$ac_ct_STRIP" = x; then
    STRIP=":"
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    STRIP=$ac_ct_STRIP
  fi
else
  STRIP="$ac_cv_prog_STRIP"
fi

test -z "$STRIP" && STRIP=:






if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_RANLIB+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$RANLIB"; then
  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
RANLIB=$ac_cv_prog_RANLIB
if test -n "$RANLIB"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
$as_echo "$RANLIB" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_prog_RANLIB"; then
  ac_ct_RANLIB=$RANLIB
  # Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_RANLIB"; then
  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_RANLIB="ranlib"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
if test -n "$ac_ct_RANLIB"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
$as_echo "$ac_ct_RANLIB" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

  if test "x$ac_ct_RANLIB" = x; then
    RANLIB=":"
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    RANLIB=$ac_ct_RANLIB
  fi
else
  RANLIB="$ac_cv_prog_RANLIB"
fi

test -z "$RANLIB" && RANLIB=:






# Determine commands to create old-style static archives.
old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
old_postinstall_cmds='chmod 644 $oldlib'
old_postuninstall_cmds=

if test -n "$RANLIB"; then
  case $host_os in
  openbsd*)
    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
    ;;
  *)
    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
    ;;
  esac
  old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
fi

case $host_os in
  darwin*)
    lock_old_archive_extraction=yes ;;
  *)
    lock_old_archive_extraction=no ;;
esac







































# If no C compiler was specified, use CC.
LTCC=${LTCC-"$CC"}

# If no C compiler flags were specified, use CFLAGS.
LTCFLAGS=${LTCFLAGS-"$CFLAGS"}

# Allow CC to be a program name with arguments.
compiler=$CC


# Check for command to grab the raw symbol name followed by C symbol from nm.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
if ${lt_cv_sys_global_symbol_pipe+:} false; then :
  $as_echo_n "(cached) " >&6
else

# These are sane defaults that work on at least a few old systems.
# [They come from Ultrix.  What could be older than Ultrix?!! ;)]

# Character class describing NM global symbol codes.
symcode='[BCDEGRST]'

# Regexp to match symbols that can be accessed directly from C.
sympat='\([_A-Za-z][_A-Za-z0-9]*\)'

# Define system-specific variables.
case $host_os in
aix*)
  symcode='[BCDT]'
  ;;
cygwin* | mingw* | pw32* | cegcc*)
  symcode='[ABCDGISTW]'
  ;;
hpux*)
  if test "$host_cpu" = ia64; then
    symcode='[ABCDEGRST]'
  fi
  ;;
irix* | nonstopux*)
  symcode='[BCDEGRST]'
  ;;
osf*)
  symcode='[BCDEGQRST]'
  ;;
solaris*)
  symcode='[BDRT]'
  ;;
sco3.2v5*)
  symcode='[DT]'
  ;;
sysv4.2uw2*)
  symcode='[DT]'
  ;;
sysv5* | sco5v6* | unixware* | OpenUNIX*)
  symcode='[ABDT]'
  ;;
sysv4)
  symcode='[DFNSTU]'
  ;;
esac

# If we're using GNU nm, then use its standard symbol codes.
case `$NM -V 2>&1` in
*GNU* | *'with BFD'*)
  symcode='[ABCDGIRSTW]' ;;
esac

# Transform an extracted symbol line into a proper C declaration.
# Some systems (esp. on ia64) link data and code symbols differently,
# so use this general approach.
lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"

# Transform an extracted symbol line into symbol name and symbol address
lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (void *) \&\2},/p'"
lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"lib\2\", (void *) \&\2},/p'"

# Handle CRLF in mingw tool chain
opt_cr=
case $build_os in
mingw*)
  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
  ;;
esac

# Try without a prefix underscore, then with it.
for ac_symprfx in "" "_"; do

  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
  symxfrm="\\1 $ac_symprfx\\2 \\2"

  # Write the raw and C identifiers.
  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
    # Fake it for dumpbin and say T for any non-static function
    # and D for any global variable.
    # Also find C++ and __fastcall symbols from MSVC++,
    # which start with @ or ?.
    lt_cv_sys_global_symbol_pipe="$AWK '"\
"     {last_section=section; section=\$ 3};"\
"     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
"     \$ 0!~/External *\|/{next};"\
"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
"     {if(hide[section]) next};"\
"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
"     ' prfx=^$ac_symprfx"
  else
    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[	 ]\($symcode$symcode*\)[	 ][	 ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
  fi
  lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"

  # Check to see that the pipe works correctly.
  pipe_works=no

  rm -f conftest*
  cat > conftest.$ac_ext <<_LT_EOF
#ifdef __cplusplus
extern "C" {
#endif
char nm_test_var;
void nm_test_func(void);
void nm_test_func(void){}
#ifdef __cplusplus
}
#endif
int main(){nm_test_var='a';nm_test_func();return(0);}
_LT_EOF

  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; then
    # Now try to grab the symbols.
    nlist=conftest.nm
    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
  (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; } && test -s "$nlist"; then
      # Try sorting and uniquifying the output.
      if sort "$nlist" | uniq > "$nlist"T; then
	mv -f "$nlist"T "$nlist"
      else
	rm -f "$nlist"T
      fi

      # Make sure that we snagged all the symbols we need.
      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
	  cat <<_LT_EOF > conftest.$ac_ext
/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
/* DATA imports from DLLs on WIN32 con't be const, because runtime
   relocations are performed -- see ld's documentation on pseudo-relocs.  */
# define LT_DLSYM_CONST
#elif defined(__osf__)
/* This system does not cope well with relocations in const data.  */
# define LT_DLSYM_CONST
#else
# define LT_DLSYM_CONST const
#endif

#ifdef __cplusplus
extern "C" {
#endif

_LT_EOF
	  # Now generate the symbol file.
	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'

	  cat <<_LT_EOF >> conftest.$ac_ext

/* The mapping between symbol names and symbols.  */
LT_DLSYM_CONST struct {
  const char *name;
  void       *address;
}
lt__PROGRAM__LTX_preloaded_symbols[] =
{
  { "@PROGRAM@", (void *) 0 },
_LT_EOF
	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
	  cat <<\_LT_EOF >> conftest.$ac_ext
  {0, (void *) 0}
};

/* This works around a problem in FreeBSD linker */
#ifdef FREEBSD_WORKAROUND
static const void *lt_preloaded_setup() {
  return lt__PROGRAM__LTX_preloaded_symbols;
}
#endif

#ifdef __cplusplus
}
#endif
_LT_EOF
	  # Now try linking the two files.
	  mv conftest.$ac_objext conftstm.$ac_objext
	  lt_globsym_save_LIBS=$LIBS
	  lt_globsym_save_CFLAGS=$CFLAGS
	  LIBS="conftstm.$ac_objext"
	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; } && test -s conftest${ac_exeext}; then
	    pipe_works=yes
	  fi
	  LIBS=$lt_globsym_save_LIBS
	  CFLAGS=$lt_globsym_save_CFLAGS
	else
	  echo "cannot find nm_test_func in $nlist" >&5
	fi
      else
	echo "cannot find nm_test_var in $nlist" >&5
      fi
    else
      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
    fi
  else
    echo "$progname: failed program was:" >&5
    cat conftest.$ac_ext >&5
  fi
  rm -rf conftest* conftst*

  # Do not use the global_symbol_pipe unless it works.
  if test "$pipe_works" = yes; then
    break
  else
    lt_cv_sys_global_symbol_pipe=
  fi
done

fi

if test -z "$lt_cv_sys_global_symbol_pipe"; then
  lt_cv_sys_global_symbol_to_cdecl=
fi
if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
$as_echo "failed" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
$as_echo "ok" >&6; }
fi

# Response file support.
if test "$lt_cv_nm_interface" = "MS dumpbin"; then
  nm_file_list_spec='@'
elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then
  nm_file_list_spec='@'
fi



























{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
$as_echo_n "checking for sysroot... " >&6; }

# Check whether --with-sysroot was given.
if test "${with_sysroot+set}" = set; then :
  withval=$with_sysroot;
else
  with_sysroot=no
fi


lt_sysroot=
case ${with_sysroot} in #(
 yes)
   if test "$GCC" = yes; then
     lt_sysroot=`$CC --print-sysroot 2>/dev/null`
   fi
   ;; #(
 /*)
   lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
   ;; #(
 no|'')
   ;; #(
 *)
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5
$as_echo "${with_sysroot}" >&6; }
   as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5
   ;;
esac

 { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5
$as_echo "${lt_sysroot:-no}" >&6; }





# Check whether --enable-libtool-lock was given.
if test "${enable_libtool_lock+set}" = set; then :
  enableval=$enable_libtool_lock;
fi

test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes

# Some flags need to be propagated to the compiler or linker for good
# libtool support.
case $host in
ia64-*-hpux*)
  # Find out which ABI we are using.
  echo 'int i;' > conftest.$ac_ext
  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; then
    case `/usr/bin/file conftest.$ac_objext` in
      *ELF-32*)
	HPUX_IA64_MODE="32"
	;;
      *ELF-64*)
	HPUX_IA64_MODE="64"
	;;
    esac
  fi
  rm -rf conftest*
  ;;
*-*-irix6*)
  # Find out which ABI we are using.
  echo '#line '$LINENO' "configure"' > conftest.$ac_ext
  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; then
    if test "$lt_cv_prog_gnu_ld" = yes; then
      case `/usr/bin/file conftest.$ac_objext` in
	*32-bit*)
	  LD="${LD-ld} -melf32bsmip"
	  ;;
	*N32*)
	  LD="${LD-ld} -melf32bmipn32"
	  ;;
	*64-bit*)
	  LD="${LD-ld} -melf64bmip"
	;;
      esac
    else
      case `/usr/bin/file conftest.$ac_objext` in
	*32-bit*)
	  LD="${LD-ld} -32"
	  ;;
	*N32*)
	  LD="${LD-ld} -n32"
	  ;;
	*64-bit*)
	  LD="${LD-ld} -64"
	  ;;
      esac
    fi
  fi
  rm -rf conftest*
  ;;

x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
  # Find out which ABI we are using.
  echo 'int i;' > conftest.$ac_ext
  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; then
    case `/usr/bin/file conftest.o` in
      *32-bit*)
	case $host in
	  x86_64-*kfreebsd*-gnu)
	    LD="${LD-ld} -m elf_i386_fbsd"
	    ;;
	  x86_64-*linux*)
	    LD="${LD-ld} -m elf_i386"
	    ;;
	  ppc64-*linux*|powerpc64-*linux*)
	    LD="${LD-ld} -m elf32ppclinux"
	    ;;
	  s390x-*linux*)
	    LD="${LD-ld} -m elf_s390"
	    ;;
	  sparc64-*linux*)
	    LD="${LD-ld} -m elf32_sparc"
	    ;;
	esac
	;;
      *64-bit*)
	case $host in
	  x86_64-*kfreebsd*-gnu)
	    LD="${LD-ld} -m elf_x86_64_fbsd"
	    ;;
	  x86_64-*linux*)
	    LD="${LD-ld} -m elf_x86_64"
	    ;;
	  ppc*-*linux*|powerpc*-*linux*)
	    LD="${LD-ld} -m elf64ppc"
	    ;;
	  s390*-*linux*|s390*-*tpf*)
	    LD="${LD-ld} -m elf64_s390"
	    ;;
	  sparc*-*linux*)
	    LD="${LD-ld} -m elf64_sparc"
	    ;;
	esac
	;;
    esac
  fi
  rm -rf conftest*
  ;;

*-*-sco3.2v5*)
  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
  SAVE_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS -belf"
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
$as_echo_n "checking whether the C compiler needs -belf... " >&6; }
if ${lt_cv_cc_needs_belf+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  lt_cv_cc_needs_belf=yes
else
  lt_cv_cc_needs_belf=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
     ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
$as_echo "$lt_cv_cc_needs_belf" >&6; }
  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
    CFLAGS="$SAVE_CFLAGS"
  fi
  ;;
*-*solaris*)
  # Find out which ABI we are using.
  echo 'int i;' > conftest.$ac_ext
  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; then
    case `/usr/bin/file conftest.o` in
    *64-bit*)
      case $lt_cv_prog_gnu_ld in
      yes*)
        case $host in
        i?86-*-solaris*)
          LD="${LD-ld} -m elf_x86_64"
          ;;
        sparc*-*-solaris*)
          LD="${LD-ld} -m elf64_sparc"
          ;;
        esac
        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
          LD="${LD-ld}_sol2"
        fi
        ;;
      *)
	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
	  LD="${LD-ld} -64"
	fi
	;;
      esac
      ;;
    esac
  fi
  rm -rf conftest*
  ;;
esac

need_locks="$enable_libtool_lock"

if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.
set dummy ${ac_tool_prefix}mt; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_MANIFEST_TOOL+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$MANIFEST_TOOL"; then
  ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL
if test -n "$MANIFEST_TOOL"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5
$as_echo "$MANIFEST_TOOL" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_prog_MANIFEST_TOOL"; then
  ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL
  # Extract the first word of "mt", so it can be a program name with args.
set dummy mt; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_MANIFEST_TOOL"; then
  ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_MANIFEST_TOOL="mt"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL
if test -n "$ac_ct_MANIFEST_TOOL"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5
$as_echo "$ac_ct_MANIFEST_TOOL" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

  if test "x$ac_ct_MANIFEST_TOOL" = x; then
    MANIFEST_TOOL=":"
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL
  fi
else
  MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL"
fi

test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5
$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; }
if ${lt_cv_path_mainfest_tool+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_path_mainfest_tool=no
  echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5
  $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
  cat conftest.err >&5
  if $GREP 'Manifest Tool' conftest.out > /dev/null; then
    lt_cv_path_mainfest_tool=yes
  fi
  rm -f conftest*
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
$as_echo "$lt_cv_path_mainfest_tool" >&6; }
if test "x$lt_cv_path_mainfest_tool" != xyes; then
  MANIFEST_TOOL=:
fi






  case $host_os in
    rhapsody* | darwin*)
    if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_DSYMUTIL+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$DSYMUTIL"; then
  ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
DSYMUTIL=$ac_cv_prog_DSYMUTIL
if test -n "$DSYMUTIL"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
$as_echo "$DSYMUTIL" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_prog_DSYMUTIL"; then
  ac_ct_DSYMUTIL=$DSYMUTIL
  # Extract the first word of "dsymutil", so it can be a program name with args.
set dummy dsymutil; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_DSYMUTIL"; then
  ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
if test -n "$ac_ct_DSYMUTIL"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
$as_echo "$ac_ct_DSYMUTIL" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

  if test "x$ac_ct_DSYMUTIL" = x; then
    DSYMUTIL=":"
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    DSYMUTIL=$ac_ct_DSYMUTIL
  fi
else
  DSYMUTIL="$ac_cv_prog_DSYMUTIL"
fi

    if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
set dummy ${ac_tool_prefix}nmedit; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_NMEDIT+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$NMEDIT"; then
  ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
NMEDIT=$ac_cv_prog_NMEDIT
if test -n "$NMEDIT"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
$as_echo "$NMEDIT" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_prog_NMEDIT"; then
  ac_ct_NMEDIT=$NMEDIT
  # Extract the first word of "nmedit", so it can be a program name with args.
set dummy nmedit; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_NMEDIT"; then
  ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_NMEDIT="nmedit"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
if test -n "$ac_ct_NMEDIT"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
$as_echo "$ac_ct_NMEDIT" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

  if test "x$ac_ct_NMEDIT" = x; then
    NMEDIT=":"
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    NMEDIT=$ac_ct_NMEDIT
  fi
else
  NMEDIT="$ac_cv_prog_NMEDIT"
fi

    if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
set dummy ${ac_tool_prefix}lipo; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_LIPO+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$LIPO"; then
  ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
LIPO=$ac_cv_prog_LIPO
if test -n "$LIPO"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
$as_echo "$LIPO" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_prog_LIPO"; then
  ac_ct_LIPO=$LIPO
  # Extract the first word of "lipo", so it can be a program name with args.
set dummy lipo; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_LIPO+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_LIPO"; then
  ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_LIPO="lipo"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
if test -n "$ac_ct_LIPO"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
$as_echo "$ac_ct_LIPO" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

  if test "x$ac_ct_LIPO" = x; then
    LIPO=":"
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    LIPO=$ac_ct_LIPO
  fi
else
  LIPO="$ac_cv_prog_LIPO"
fi

    if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
set dummy ${ac_tool_prefix}otool; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_OTOOL+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$OTOOL"; then
  ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
OTOOL=$ac_cv_prog_OTOOL
if test -n "$OTOOL"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
$as_echo "$OTOOL" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_prog_OTOOL"; then
  ac_ct_OTOOL=$OTOOL
  # Extract the first word of "otool", so it can be a program name with args.
set dummy otool; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_OTOOL+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_OTOOL"; then
  ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_OTOOL="otool"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
if test -n "$ac_ct_OTOOL"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
$as_echo "$ac_ct_OTOOL" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

  if test "x$ac_ct_OTOOL" = x; then
    OTOOL=":"
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    OTOOL=$ac_ct_OTOOL
  fi
else
  OTOOL="$ac_cv_prog_OTOOL"
fi

    if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
set dummy ${ac_tool_prefix}otool64; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_OTOOL64+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$OTOOL64"; then
  ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
OTOOL64=$ac_cv_prog_OTOOL64
if test -n "$OTOOL64"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
$as_echo "$OTOOL64" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_prog_OTOOL64"; then
  ac_ct_OTOOL64=$OTOOL64
  # Extract the first word of "otool64", so it can be a program name with args.
set dummy otool64; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_OTOOL64"; then
  ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_OTOOL64="otool64"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
if test -n "$ac_ct_OTOOL64"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
$as_echo "$ac_ct_OTOOL64" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

  if test "x$ac_ct_OTOOL64" = x; then
    OTOOL64=":"
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    OTOOL64=$ac_ct_OTOOL64
  fi
else
  OTOOL64="$ac_cv_prog_OTOOL64"
fi



























    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
$as_echo_n "checking for -single_module linker flag... " >&6; }
if ${lt_cv_apple_cc_single_mod+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_apple_cc_single_mod=no
      if test -z "${LT_MULTI_MODULE}"; then
	# By default we will add the -single_module flag. You can override
	# by either setting the environment variable LT_MULTI_MODULE
	# non-empty at configure time, or by adding -multi_module to the
	# link flags.
	rm -rf libconftest.dylib*
	echo "int foo(void){return 1;}" > conftest.c
	echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
-dynamiclib -Wl,-single_module conftest.c" >&5
	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
        _lt_result=$?
	# If there is a non-empty error log, and "single_module"
	# appears in it, assume the flag caused a linker warning
        if test -s conftest.err && $GREP single_module conftest.err; then
	  cat conftest.err >&5
	# Otherwise, if the output was created with a 0 exit code from
	# the compiler, it worked.
	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
	  lt_cv_apple_cc_single_mod=yes
	else
	  cat conftest.err >&5
	fi
	rm -rf libconftest.dylib*
	rm -f conftest.*
      fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
$as_echo "$lt_cv_apple_cc_single_mod" >&6; }

    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
if ${lt_cv_ld_exported_symbols_list+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_ld_exported_symbols_list=no
      save_LDFLAGS=$LDFLAGS
      echo "_main" > conftest.sym
      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  lt_cv_ld_exported_symbols_list=yes
else
  lt_cv_ld_exported_symbols_list=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
	LDFLAGS="$save_LDFLAGS"

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
$as_echo "$lt_cv_ld_exported_symbols_list" >&6; }

    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
$as_echo_n "checking for -force_load linker flag... " >&6; }
if ${lt_cv_ld_force_load+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_ld_force_load=no
      cat > conftest.c << _LT_EOF
int forced_loaded() { return 2;}
_LT_EOF
      echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5
      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5
      echo "$AR cru libconftest.a conftest.o" >&5
      $AR cru libconftest.a conftest.o 2>&5
      echo "$RANLIB libconftest.a" >&5
      $RANLIB libconftest.a 2>&5
      cat > conftest.c << _LT_EOF
int main() { return 0;}
_LT_EOF
      echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5
      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
      _lt_result=$?
      if test -s conftest.err && $GREP force_load conftest.err; then
	cat conftest.err >&5
      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
	lt_cv_ld_force_load=yes
      else
	cat conftest.err >&5
      fi
        rm -f conftest.err libconftest.a conftest conftest.c
        rm -rf conftest.dSYM

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5
$as_echo "$lt_cv_ld_force_load" >&6; }
    case $host_os in
    rhapsody* | darwin1.[012])
      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
    darwin1.*)
      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
    darwin*) # darwin 5.x on
      # if running on 10.5 or later, the deployment target defaults
      # to the OS version, if on x86, and 10.4, the deployment
      # target defaults to 10.4. Don't you love it?
      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
	10.0,*86*-darwin8*|10.0,*-darwin[91]*)
	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
	10.[012]*)
	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
	10.*)
	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
      esac
    ;;
  esac
    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
      _lt_dar_single_mod='$single_module'
    fi
    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
    else
      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
    fi
    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
      _lt_dsymutil='~$DSYMUTIL $lib || :'
    else
      _lt_dsymutil=
    fi
    ;;
  esac

ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
$as_echo_n "checking how to run the C preprocessor... " >&6; }
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
  CPP=
fi
if test -z "$CPP"; then
  if ${ac_cv_prog_CPP+:} false; then :
  $as_echo_n "(cached) " >&6
else
      # Double quotes because CPP needs to be expanded
    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
    do
      ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
  # Use a header file that comes with gcc, so configuring glibc
  # with a fresh cross-compiler works.
  # Prefer  to  if __STDC__ is defined, since
  #  exists even on freestanding compilers.
  # On the NeXT, cc -E runs the code through the compiler's parser,
  # not just through cpp. "Syntax error" is here to catch this case.
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#ifdef __STDC__
# include 
#else
# include 
#endif
		     Syntax error
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :

else
  # Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.i conftest.$ac_ext

  # OK, works on sane cases.  Now check whether nonexistent headers
  # can be detected and how.
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
  # Broken: success on invalid input.
continue
else
  # Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.i conftest.$ac_ext

done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.i conftest.err conftest.$ac_ext
if $ac_preproc_ok; then :
  break
fi

    done
    ac_cv_prog_CPP=$CPP

fi
  CPP=$ac_cv_prog_CPP
else
  ac_cv_prog_CPP=$CPP
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
$as_echo "$CPP" >&6; }
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
  # Use a header file that comes with gcc, so configuring glibc
  # with a fresh cross-compiler works.
  # Prefer  to  if __STDC__ is defined, since
  #  exists even on freestanding compilers.
  # On the NeXT, cc -E runs the code through the compiler's parser,
  # not just through cpp. "Syntax error" is here to catch this case.
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#ifdef __STDC__
# include 
#else
# include 
#endif
		     Syntax error
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :

else
  # Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.i conftest.$ac_ext

  # OK, works on sane cases.  Now check whether nonexistent headers
  # can be detected and how.
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
  # Broken: success on invalid input.
continue
else
  # Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.i conftest.$ac_ext

done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.i conftest.err conftest.$ac_ext
if $ac_preproc_ok; then :

else
  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
See \`config.log' for more details" "$LINENO" 5; }
fi

ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
if ${ac_cv_header_stdc+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 
#include 
#include 
#include 

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  ac_cv_header_stdc=yes
else
  ac_cv_header_stdc=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

if test $ac_cv_header_stdc = yes; then
  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 

_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
  $EGREP "memchr" >/dev/null 2>&1; then :

else
  ac_cv_header_stdc=no
fi
rm -f conftest*

fi

if test $ac_cv_header_stdc = yes; then
  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 

_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
  $EGREP "free" >/dev/null 2>&1; then :

else
  ac_cv_header_stdc=no
fi
rm -f conftest*

fi

if test $ac_cv_header_stdc = yes; then
  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
  if test "$cross_compiling" = yes; then :
  :
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 
#include 
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) \
		   (('a' <= (c) && (c) <= 'i') \
		     || ('j' <= (c) && (c) <= 'r') \
		     || ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif

#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main ()
{
  int i;
  for (i = 0; i < 256; i++)
    if (XOR (islower (i), ISLOWER (i))
	|| toupper (i) != TOUPPER (i))
      return 2;
  return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :

else
  ac_cv_header_stdc=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
  conftest.$ac_objext conftest.beam conftest.$ac_ext
fi

fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
$as_echo "$ac_cv_header_stdc" >&6; }
if test $ac_cv_header_stdc = yes; then

$as_echo "#define STDC_HEADERS 1" >>confdefs.h

fi

# On IRIX 5.3, sys/types and inttypes.h are conflicting.
for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
		  inttypes.h stdint.h unistd.h
do :
  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
  cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF

fi

done


for ac_header in dlfcn.h
do :
  ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
"
if test "x$ac_cv_header_dlfcn_h" = xyes; then :
  cat >>confdefs.h <<_ACEOF
#define HAVE_DLFCN_H 1
_ACEOF

fi

done





# Set options



        enable_dlopen=no


  enable_win32_dll=no


            # Check whether --enable-shared was given.
if test "${enable_shared+set}" = set; then :
  enableval=$enable_shared; p=${PACKAGE-default}
    case $enableval in
    yes) enable_shared=yes ;;
    no) enable_shared=no ;;
    *)
      enable_shared=no
      # Look at the argument we got.  We use all the common list separators.
      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
      for pkg in $enableval; do
	IFS="$lt_save_ifs"
	if test "X$pkg" = "X$p"; then
	  enable_shared=yes
	fi
      done
      IFS="$lt_save_ifs"
      ;;
    esac
else
  enable_shared=yes
fi









  # Check whether --enable-static was given.
if test "${enable_static+set}" = set; then :
  enableval=$enable_static; p=${PACKAGE-default}
    case $enableval in
    yes) enable_static=yes ;;
    no) enable_static=no ;;
    *)
     enable_static=no
      # Look at the argument we got.  We use all the common list separators.
      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
      for pkg in $enableval; do
	IFS="$lt_save_ifs"
	if test "X$pkg" = "X$p"; then
	  enable_static=yes
	fi
      done
      IFS="$lt_save_ifs"
      ;;
    esac
else
  enable_static=yes
fi










# Check whether --with-pic was given.
if test "${with_pic+set}" = set; then :
  withval=$with_pic; lt_p=${PACKAGE-default}
    case $withval in
    yes|no) pic_mode=$withval ;;
    *)
      pic_mode=default
      # Look at the argument we got.  We use all the common list separators.
      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
      for lt_pkg in $withval; do
	IFS="$lt_save_ifs"
	if test "X$lt_pkg" = "X$lt_p"; then
	  pic_mode=yes
	fi
      done
      IFS="$lt_save_ifs"
      ;;
    esac
else
  pic_mode=default
fi


test -z "$pic_mode" && pic_mode=default







  # Check whether --enable-fast-install was given.
if test "${enable_fast_install+set}" = set; then :
  enableval=$enable_fast_install; p=${PACKAGE-default}
    case $enableval in
    yes) enable_fast_install=yes ;;
    no) enable_fast_install=no ;;
    *)
      enable_fast_install=no
      # Look at the argument we got.  We use all the common list separators.
      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
      for pkg in $enableval; do
	IFS="$lt_save_ifs"
	if test "X$pkg" = "X$p"; then
	  enable_fast_install=yes
	fi
      done
      IFS="$lt_save_ifs"
      ;;
    esac
else
  enable_fast_install=yes
fi











# This can be used to rebuild libtool when needed
LIBTOOL_DEPS="$ltmain"

# Always use our own libtool.
LIBTOOL='$(SHELL) $(top_builddir)/libtool'






























test -z "$LN_S" && LN_S="ln -s"














if test -n "${ZSH_VERSION+set}" ; then
   setopt NO_GLOB_SUBST
fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
$as_echo_n "checking for objdir... " >&6; }
if ${lt_cv_objdir+:} false; then :
  $as_echo_n "(cached) " >&6
else
  rm -f .libs 2>/dev/null
mkdir .libs 2>/dev/null
if test -d .libs; then
  lt_cv_objdir=.libs
else
  # MS-DOS does not allow filenames that begin with a dot.
  lt_cv_objdir=_libs
fi
rmdir .libs 2>/dev/null
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
$as_echo "$lt_cv_objdir" >&6; }
objdir=$lt_cv_objdir





cat >>confdefs.h <<_ACEOF
#define LT_OBJDIR "$lt_cv_objdir/"
_ACEOF




case $host_os in
aix3*)
  # AIX sometimes has problems with the GCC collect2 program.  For some
  # reason, if we set the COLLECT_NAMES environment variable, the problems
  # vanish in a puff of smoke.
  if test "X${COLLECT_NAMES+set}" != Xset; then
    COLLECT_NAMES=
    export COLLECT_NAMES
  fi
  ;;
esac

# Global variables:
ofile=libtool
can_build_shared=yes

# All known linkers require a `.a' archive for static linking (except MSVC,
# which needs '.lib').
libext=a

with_gnu_ld="$lt_cv_prog_gnu_ld"

old_CC="$CC"
old_CFLAGS="$CFLAGS"

# Set sane defaults for various variables
test -z "$CC" && CC=cc
test -z "$LTCC" && LTCC=$CC
test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
test -z "$LD" && LD=ld
test -z "$ac_objext" && ac_objext=o

for cc_temp in $compiler""; do
  case $cc_temp in
    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
    \-*) ;;
    *) break;;
  esac
done
cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`


# Only perform the check for file, if the check method requires it
test -z "$MAGIC_CMD" && MAGIC_CMD=file
case $deplibs_check_method in
file_magic*)
  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
if ${lt_cv_path_MAGIC_CMD+:} false; then :
  $as_echo_n "(cached) " >&6
else
  case $MAGIC_CMD in
[\\/*] |  ?:[\\/]*)
  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
  ;;
*)
  lt_save_MAGIC_CMD="$MAGIC_CMD"
  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
  for ac_dir in $ac_dummy; do
    IFS="$lt_save_ifs"
    test -z "$ac_dir" && ac_dir=.
    if test -f $ac_dir/${ac_tool_prefix}file; then
      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
      if test -n "$file_magic_test_file"; then
	case $deplibs_check_method in
	"file_magic "*)
	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
	    $EGREP "$file_magic_regex" > /dev/null; then
	    :
	  else
	    cat <<_LT_EOF 1>&2

*** Warning: the command libtool uses to detect shared libraries,
*** $file_magic_cmd, produces output that libtool cannot recognize.
*** The result is that libtool may fail to recognize shared libraries
*** as such.  This will affect the creation of libtool libraries that
*** depend on shared libraries, but programs linked with such libtool
*** libraries will work regardless of this problem.  Nevertheless, you
*** may want to report the problem to your system manager and/or to
*** bug-libtool@gnu.org

_LT_EOF
	  fi ;;
	esac
      fi
      break
    fi
  done
  IFS="$lt_save_ifs"
  MAGIC_CMD="$lt_save_MAGIC_CMD"
  ;;
esac
fi

MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
if test -n "$MAGIC_CMD"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
$as_echo "$MAGIC_CMD" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi





if test -z "$lt_cv_path_MAGIC_CMD"; then
  if test -n "$ac_tool_prefix"; then
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
$as_echo_n "checking for file... " >&6; }
if ${lt_cv_path_MAGIC_CMD+:} false; then :
  $as_echo_n "(cached) " >&6
else
  case $MAGIC_CMD in
[\\/*] |  ?:[\\/]*)
  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
  ;;
*)
  lt_save_MAGIC_CMD="$MAGIC_CMD"
  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
  for ac_dir in $ac_dummy; do
    IFS="$lt_save_ifs"
    test -z "$ac_dir" && ac_dir=.
    if test -f $ac_dir/file; then
      lt_cv_path_MAGIC_CMD="$ac_dir/file"
      if test -n "$file_magic_test_file"; then
	case $deplibs_check_method in
	"file_magic "*)
	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
	    $EGREP "$file_magic_regex" > /dev/null; then
	    :
	  else
	    cat <<_LT_EOF 1>&2

*** Warning: the command libtool uses to detect shared libraries,
*** $file_magic_cmd, produces output that libtool cannot recognize.
*** The result is that libtool may fail to recognize shared libraries
*** as such.  This will affect the creation of libtool libraries that
*** depend on shared libraries, but programs linked with such libtool
*** libraries will work regardless of this problem.  Nevertheless, you
*** may want to report the problem to your system manager and/or to
*** bug-libtool@gnu.org

_LT_EOF
	  fi ;;
	esac
      fi
      break
    fi
  done
  IFS="$lt_save_ifs"
  MAGIC_CMD="$lt_save_MAGIC_CMD"
  ;;
esac
fi

MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
if test -n "$MAGIC_CMD"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
$as_echo "$MAGIC_CMD" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


  else
    MAGIC_CMD=:
  fi
fi

  fi
  ;;
esac

# Use C for the default configuration in the libtool script

lt_save_CC="$CC"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu


# Source file extension for C test sources.
ac_ext=c

# Object file extension for compiled C test sources.
objext=o
objext=$objext

# Code to be used in simple compile tests
lt_simple_compile_test_code="int some_variable = 0;"

# Code to be used in simple link tests
lt_simple_link_test_code='int main(){return(0);}'







# If no C compiler was specified, use CC.
LTCC=${LTCC-"$CC"}

# If no C compiler flags were specified, use CFLAGS.
LTCFLAGS=${LTCFLAGS-"$CFLAGS"}

# Allow CC to be a program name with arguments.
compiler=$CC

# Save the default compiler, since it gets overwritten when the other
# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
compiler_DEFAULT=$CC

# save warnings/boilerplate of simple test code
ac_outfile=conftest.$ac_objext
echo "$lt_simple_compile_test_code" >conftest.$ac_ext
eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
_lt_compiler_boilerplate=`cat conftest.err`
$RM conftest*

ac_outfile=conftest.$ac_objext
echo "$lt_simple_link_test_code" >conftest.$ac_ext
eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
_lt_linker_boilerplate=`cat conftest.err`
$RM -r conftest*


## CAVEAT EMPTOR:
## There is no encapsulation within the following macros, do not change
## the running order or otherwise move them around unless you know exactly
## what you are doing...
if test -n "$compiler"; then

lt_prog_compiler_no_builtin_flag=

if test "$GCC" = yes; then
  case $cc_basename in
  nvcc*)
    lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;
  *)
    lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;;
  esac

  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_prog_compiler_rtti_exceptions=no
   ac_outfile=conftest.$ac_objext
   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
   lt_compiler_flag="-fno-rtti -fno-exceptions"
   # Insert the option either (1) after the last *FLAGS variable, or
   # (2) before a word containing "conftest.", or (3) at the end.
   # Note that $ac_compile itself does not contain backslashes and begins
   # with a dollar sign (not a hyphen), so the echo should work correctly.
   # The option is referenced via a variable to avoid confusing sed.
   lt_compile=`echo "$ac_compile" | $SED \
   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   -e 's:$: $lt_compiler_flag:'`
   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
   (eval "$lt_compile" 2>conftest.err)
   ac_status=$?
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   if (exit $ac_status) && test -s "$ac_outfile"; then
     # The compiler can only warn and ignore the option if not recognized
     # So say no if there are warnings other than the usual output.
     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
       lt_cv_prog_compiler_rtti_exceptions=yes
     fi
   fi
   $RM conftest*

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }

if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
    lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
else
    :
fi

fi






  lt_prog_compiler_wl=
lt_prog_compiler_pic=
lt_prog_compiler_static=


  if test "$GCC" = yes; then
    lt_prog_compiler_wl='-Wl,'
    lt_prog_compiler_static='-static'

    case $host_os in
      aix*)
      # All AIX code is PIC.
      if test "$host_cpu" = ia64; then
	# AIX 5 now supports IA64 processor
	lt_prog_compiler_static='-Bstatic'
      fi
      ;;

    amigaos*)
      case $host_cpu in
      powerpc)
            # see comment about AmigaOS4 .so support
            lt_prog_compiler_pic='-fPIC'
        ;;
      m68k)
            # FIXME: we need at least 68020 code to build shared libraries, but
            # adding the `-m68020' flag to GCC prevents building anything better,
            # like `-m68040'.
            lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
        ;;
      esac
      ;;

    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
      # PIC is the default for these OSes.
      ;;

    mingw* | cygwin* | pw32* | os2* | cegcc*)
      # This hack is so that the source file can tell whether it is being
      # built for inclusion in a dll (and should export symbols for example).
      # Although the cygwin gcc ignores -fPIC, still need this for old-style
      # (--disable-auto-import) libraries
      lt_prog_compiler_pic='-DDLL_EXPORT'
      ;;

    darwin* | rhapsody*)
      # PIC is the default on this platform
      # Common symbols not allowed in MH_DYLIB files
      lt_prog_compiler_pic='-fno-common'
      ;;

    haiku*)
      # PIC is the default for Haiku.
      # The "-static" flag exists, but is broken.
      lt_prog_compiler_static=
      ;;

    hpux*)
      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
      # sets the default TLS model and affects inlining.
      case $host_cpu in
      hppa*64*)
	# +Z the default
	;;
      *)
	lt_prog_compiler_pic='-fPIC'
	;;
      esac
      ;;

    interix[3-9]*)
      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
      # Instead, we relocate shared libraries at runtime.
      ;;

    msdosdjgpp*)
      # Just because we use GCC doesn't mean we suddenly get shared libraries
      # on systems that don't support them.
      lt_prog_compiler_can_build_shared=no
      enable_shared=no
      ;;

    *nto* | *qnx*)
      # QNX uses GNU C++, but need to define -shared option too, otherwise
      # it will coredump.
      lt_prog_compiler_pic='-fPIC -shared'
      ;;

    sysv4*MP*)
      if test -d /usr/nec; then
	lt_prog_compiler_pic=-Kconform_pic
      fi
      ;;

    *)
      lt_prog_compiler_pic='-fPIC'
      ;;
    esac

    case $cc_basename in
    nvcc*) # Cuda Compiler Driver 2.2
      lt_prog_compiler_wl='-Xlinker '
      if test -n "$lt_prog_compiler_pic"; then
        lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic"
      fi
      ;;
    esac
  else
    # PORTME Check for flag to pass linker flags through the system compiler.
    case $host_os in
    aix*)
      lt_prog_compiler_wl='-Wl,'
      if test "$host_cpu" = ia64; then
	# AIX 5 now supports IA64 processor
	lt_prog_compiler_static='-Bstatic'
      else
	lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
      fi
      ;;

    mingw* | cygwin* | pw32* | os2* | cegcc*)
      # This hack is so that the source file can tell whether it is being
      # built for inclusion in a dll (and should export symbols for example).
      lt_prog_compiler_pic='-DDLL_EXPORT'
      ;;

    hpux9* | hpux10* | hpux11*)
      lt_prog_compiler_wl='-Wl,'
      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
      # not for PA HP-UX.
      case $host_cpu in
      hppa*64*|ia64*)
	# +Z the default
	;;
      *)
	lt_prog_compiler_pic='+Z'
	;;
      esac
      # Is there a better lt_prog_compiler_static that works with the bundled CC?
      lt_prog_compiler_static='${wl}-a ${wl}archive'
      ;;

    irix5* | irix6* | nonstopux*)
      lt_prog_compiler_wl='-Wl,'
      # PIC (with -KPIC) is the default.
      lt_prog_compiler_static='-non_shared'
      ;;

    linux* | k*bsd*-gnu | kopensolaris*-gnu)
      case $cc_basename in
      # old Intel for x86_64 which still supported -KPIC.
      ecc*)
	lt_prog_compiler_wl='-Wl,'
	lt_prog_compiler_pic='-KPIC'
	lt_prog_compiler_static='-static'
        ;;
      # icc used to be incompatible with GCC.
      # ICC 10 doesn't accept -KPIC any more.
      icc* | ifort*)
	lt_prog_compiler_wl='-Wl,'
	lt_prog_compiler_pic='-fPIC'
	lt_prog_compiler_static='-static'
        ;;
      # Lahey Fortran 8.1.
      lf95*)
	lt_prog_compiler_wl='-Wl,'
	lt_prog_compiler_pic='--shared'
	lt_prog_compiler_static='--static'
	;;
      nagfor*)
	# NAG Fortran compiler
	lt_prog_compiler_wl='-Wl,-Wl,,'
	lt_prog_compiler_pic='-PIC'
	lt_prog_compiler_static='-Bstatic'
	;;
      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
        # Portland Group compilers (*not* the Pentium gcc compiler,
	# which looks to be a dead project)
	lt_prog_compiler_wl='-Wl,'
	lt_prog_compiler_pic='-fpic'
	lt_prog_compiler_static='-Bstatic'
        ;;
      ccc*)
        lt_prog_compiler_wl='-Wl,'
        # All Alpha code is PIC.
        lt_prog_compiler_static='-non_shared'
        ;;
      xl* | bgxl* | bgf* | mpixl*)
	# IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
	lt_prog_compiler_wl='-Wl,'
	lt_prog_compiler_pic='-qpic'
	lt_prog_compiler_static='-qstaticlink'
	;;
      *)
	case `$CC -V 2>&1 | sed 5q` in
	*Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*)
	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
	  lt_prog_compiler_pic='-KPIC'
	  lt_prog_compiler_static='-Bstatic'
	  lt_prog_compiler_wl=''
	  ;;
	*Sun\ F* | *Sun*Fortran*)
	  lt_prog_compiler_pic='-KPIC'
	  lt_prog_compiler_static='-Bstatic'
	  lt_prog_compiler_wl='-Qoption ld '
	  ;;
	*Sun\ C*)
	  # Sun C 5.9
	  lt_prog_compiler_pic='-KPIC'
	  lt_prog_compiler_static='-Bstatic'
	  lt_prog_compiler_wl='-Wl,'
	  ;;
        *Intel*\ [CF]*Compiler*)
	  lt_prog_compiler_wl='-Wl,'
	  lt_prog_compiler_pic='-fPIC'
	  lt_prog_compiler_static='-static'
	  ;;
	*Portland\ Group*)
	  lt_prog_compiler_wl='-Wl,'
	  lt_prog_compiler_pic='-fpic'
	  lt_prog_compiler_static='-Bstatic'
	  ;;
	esac
	;;
      esac
      ;;

    newsos6)
      lt_prog_compiler_pic='-KPIC'
      lt_prog_compiler_static='-Bstatic'
      ;;

    *nto* | *qnx*)
      # QNX uses GNU C++, but need to define -shared option too, otherwise
      # it will coredump.
      lt_prog_compiler_pic='-fPIC -shared'
      ;;

    osf3* | osf4* | osf5*)
      lt_prog_compiler_wl='-Wl,'
      # All OSF/1 code is PIC.
      lt_prog_compiler_static='-non_shared'
      ;;

    rdos*)
      lt_prog_compiler_static='-non_shared'
      ;;

    solaris*)
      lt_prog_compiler_pic='-KPIC'
      lt_prog_compiler_static='-Bstatic'
      case $cc_basename in
      f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
	lt_prog_compiler_wl='-Qoption ld ';;
      *)
	lt_prog_compiler_wl='-Wl,';;
      esac
      ;;

    sunos4*)
      lt_prog_compiler_wl='-Qoption ld '
      lt_prog_compiler_pic='-PIC'
      lt_prog_compiler_static='-Bstatic'
      ;;

    sysv4 | sysv4.2uw2* | sysv4.3*)
      lt_prog_compiler_wl='-Wl,'
      lt_prog_compiler_pic='-KPIC'
      lt_prog_compiler_static='-Bstatic'
      ;;

    sysv4*MP*)
      if test -d /usr/nec ;then
	lt_prog_compiler_pic='-Kconform_pic'
	lt_prog_compiler_static='-Bstatic'
      fi
      ;;

    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
      lt_prog_compiler_wl='-Wl,'
      lt_prog_compiler_pic='-KPIC'
      lt_prog_compiler_static='-Bstatic'
      ;;

    unicos*)
      lt_prog_compiler_wl='-Wl,'
      lt_prog_compiler_can_build_shared=no
      ;;

    uts4*)
      lt_prog_compiler_pic='-pic'
      lt_prog_compiler_static='-Bstatic'
      ;;

    *)
      lt_prog_compiler_can_build_shared=no
      ;;
    esac
  fi

case $host_os in
  # For platforms which do not support PIC, -DPIC is meaningless:
  *djgpp*)
    lt_prog_compiler_pic=
    ;;
  *)
    lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
    ;;
esac

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
if ${lt_cv_prog_compiler_pic+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_prog_compiler_pic=$lt_prog_compiler_pic
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5
$as_echo "$lt_cv_prog_compiler_pic" >&6; }
lt_prog_compiler_pic=$lt_cv_prog_compiler_pic

#
# Check to make sure the PIC flag actually works.
#
if test -n "$lt_prog_compiler_pic"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
if ${lt_cv_prog_compiler_pic_works+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_prog_compiler_pic_works=no
   ac_outfile=conftest.$ac_objext
   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
   # Insert the option either (1) after the last *FLAGS variable, or
   # (2) before a word containing "conftest.", or (3) at the end.
   # Note that $ac_compile itself does not contain backslashes and begins
   # with a dollar sign (not a hyphen), so the echo should work correctly.
   # The option is referenced via a variable to avoid confusing sed.
   lt_compile=`echo "$ac_compile" | $SED \
   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   -e 's:$: $lt_compiler_flag:'`
   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
   (eval "$lt_compile" 2>conftest.err)
   ac_status=$?
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   if (exit $ac_status) && test -s "$ac_outfile"; then
     # The compiler can only warn and ignore the option if not recognized
     # So say no if there are warnings other than the usual output.
     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
       lt_cv_prog_compiler_pic_works=yes
     fi
   fi
   $RM conftest*

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
$as_echo "$lt_cv_prog_compiler_pic_works" >&6; }

if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
    case $lt_prog_compiler_pic in
     "" | " "*) ;;
     *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
     esac
else
    lt_prog_compiler_pic=
     lt_prog_compiler_can_build_shared=no
fi

fi











#
# Check to make sure the static flag actually works.
#
wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
if ${lt_cv_prog_compiler_static_works+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_prog_compiler_static_works=no
   save_LDFLAGS="$LDFLAGS"
   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
   echo "$lt_simple_link_test_code" > conftest.$ac_ext
   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
     # The linker can only warn and ignore the option if not recognized
     # So say no if there are warnings
     if test -s conftest.err; then
       # Append any errors to the config.log.
       cat conftest.err 1>&5
       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
       if diff conftest.exp conftest.er2 >/dev/null; then
         lt_cv_prog_compiler_static_works=yes
       fi
     else
       lt_cv_prog_compiler_static_works=yes
     fi
   fi
   $RM -r conftest*
   LDFLAGS="$save_LDFLAGS"

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
$as_echo "$lt_cv_prog_compiler_static_works" >&6; }

if test x"$lt_cv_prog_compiler_static_works" = xyes; then
    :
else
    lt_prog_compiler_static=
fi







  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
if ${lt_cv_prog_compiler_c_o+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_prog_compiler_c_o=no
   $RM -r conftest 2>/dev/null
   mkdir conftest
   cd conftest
   mkdir out
   echo "$lt_simple_compile_test_code" > conftest.$ac_ext

   lt_compiler_flag="-o out/conftest2.$ac_objext"
   # Insert the option either (1) after the last *FLAGS variable, or
   # (2) before a word containing "conftest.", or (3) at the end.
   # Note that $ac_compile itself does not contain backslashes and begins
   # with a dollar sign (not a hyphen), so the echo should work correctly.
   lt_compile=`echo "$ac_compile" | $SED \
   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   -e 's:$: $lt_compiler_flag:'`
   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
   (eval "$lt_compile" 2>out/conftest.err)
   ac_status=$?
   cat out/conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   if (exit $ac_status) && test -s out/conftest2.$ac_objext
   then
     # The compiler can only warn and ignore the option if not recognized
     # So say no if there are warnings
     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
       lt_cv_prog_compiler_c_o=yes
     fi
   fi
   chmod u+w . 2>&5
   $RM conftest*
   # SGI C++ compiler will create directory out/ii_files/ for
   # template instantiation
   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
   $RM out/* && rmdir out
   cd ..
   $RM -r conftest
   $RM conftest*

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
$as_echo "$lt_cv_prog_compiler_c_o" >&6; }






  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
if ${lt_cv_prog_compiler_c_o+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_prog_compiler_c_o=no
   $RM -r conftest 2>/dev/null
   mkdir conftest
   cd conftest
   mkdir out
   echo "$lt_simple_compile_test_code" > conftest.$ac_ext

   lt_compiler_flag="-o out/conftest2.$ac_objext"
   # Insert the option either (1) after the last *FLAGS variable, or
   # (2) before a word containing "conftest.", or (3) at the end.
   # Note that $ac_compile itself does not contain backslashes and begins
   # with a dollar sign (not a hyphen), so the echo should work correctly.
   lt_compile=`echo "$ac_compile" | $SED \
   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   -e 's:$: $lt_compiler_flag:'`
   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
   (eval "$lt_compile" 2>out/conftest.err)
   ac_status=$?
   cat out/conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   if (exit $ac_status) && test -s out/conftest2.$ac_objext
   then
     # The compiler can only warn and ignore the option if not recognized
     # So say no if there are warnings
     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
       lt_cv_prog_compiler_c_o=yes
     fi
   fi
   chmod u+w . 2>&5
   $RM conftest*
   # SGI C++ compiler will create directory out/ii_files/ for
   # template instantiation
   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
   $RM out/* && rmdir out
   cd ..
   $RM -r conftest
   $RM conftest*

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
$as_echo "$lt_cv_prog_compiler_c_o" >&6; }




hard_links="nottested"
if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
  # do not overwrite the value of need_locks provided by the user
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
$as_echo_n "checking if we can lock with hard links... " >&6; }
  hard_links=yes
  $RM conftest*
  ln conftest.a conftest.b 2>/dev/null && hard_links=no
  touch conftest.a
  ln conftest.a conftest.b 2>&5 || hard_links=no
  ln conftest.a conftest.b 2>/dev/null && hard_links=no
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
$as_echo "$hard_links" >&6; }
  if test "$hard_links" = no; then
    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
    need_locks=warn
  fi
else
  need_locks=no
fi






  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }

  runpath_var=
  allow_undefined_flag=
  always_export_symbols=no
  archive_cmds=
  archive_expsym_cmds=
  compiler_needs_object=no
  enable_shared_with_static_runtimes=no
  export_dynamic_flag_spec=
  export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
  hardcode_automatic=no
  hardcode_direct=no
  hardcode_direct_absolute=no
  hardcode_libdir_flag_spec=
  hardcode_libdir_separator=
  hardcode_minus_L=no
  hardcode_shlibpath_var=unsupported
  inherit_rpath=no
  link_all_deplibs=unknown
  module_cmds=
  module_expsym_cmds=
  old_archive_from_new_cmds=
  old_archive_from_expsyms_cmds=
  thread_safe_flag_spec=
  whole_archive_flag_spec=
  # include_expsyms should be a list of space-separated symbols to be *always*
  # included in the symbol list
  include_expsyms=
  # exclude_expsyms can be an extended regexp of symbols to exclude
  # it will be wrapped by ` (' and `)$', so one must not match beginning or
  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
  # as well as any symbol that contains `d'.
  exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
  # platforms (ab)use it in PIC code, but their linkers get confused if
  # the symbol is explicitly referenced.  Since portable code cannot
  # rely on this symbol name, it's probably fine to never include it in
  # preloaded symbol tables.
  # Exclude shared library initialization/finalization symbols.
  extract_expsyms_cmds=

  case $host_os in
  cygwin* | mingw* | pw32* | cegcc*)
    # FIXME: the MSVC++ port hasn't been tested in a loooong time
    # When not using gcc, we currently assume that we are using
    # Microsoft Visual C++.
    if test "$GCC" != yes; then
      with_gnu_ld=no
    fi
    ;;
  interix*)
    # we just hope/assume this is gcc and not c89 (= MSVC++)
    with_gnu_ld=yes
    ;;
  openbsd*)
    with_gnu_ld=no
    ;;
  esac

  ld_shlibs=yes

  # On some targets, GNU ld is compatible enough with the native linker
  # that we're better off using the native interface for both.
  lt_use_gnu_ld_interface=no
  if test "$with_gnu_ld" = yes; then
    case $host_os in
      aix*)
	# The AIX port of GNU ld has always aspired to compatibility
	# with the native linker.  However, as the warning in the GNU ld
	# block says, versions before 2.19.5* couldn't really create working
	# shared libraries, regardless of the interface used.
	case `$LD -v 2>&1` in
	  *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
	  *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;;
	  *\ \(GNU\ Binutils\)\ [3-9]*) ;;
	  *)
	    lt_use_gnu_ld_interface=yes
	    ;;
	esac
	;;
      *)
	lt_use_gnu_ld_interface=yes
	;;
    esac
  fi

  if test "$lt_use_gnu_ld_interface" = yes; then
    # If archive_cmds runs LD, not CC, wlarc should be empty
    wlarc='${wl}'

    # Set some defaults for GNU ld with shared library support. These
    # are reset later if shared libraries are not supported. Putting them
    # here allows them to be overridden if necessary.
    runpath_var=LD_RUN_PATH
    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
    export_dynamic_flag_spec='${wl}--export-dynamic'
    # ancient GNU ld didn't support --whole-archive et. al.
    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
      whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
    else
      whole_archive_flag_spec=
    fi
    supports_anon_versioning=no
    case `$LD -v 2>&1` in
      *GNU\ gold*) supports_anon_versioning=yes ;;
      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
      *\ 2.11.*) ;; # other 2.11 versions
      *) supports_anon_versioning=yes ;;
    esac

    # See if GNU ld supports shared libraries.
    case $host_os in
    aix[3-9]*)
      # On AIX/PPC, the GNU linker is very broken
      if test "$host_cpu" != ia64; then
	ld_shlibs=no
	cat <<_LT_EOF 1>&2

*** Warning: the GNU linker, at least up to release 2.19, is reported
*** to be unable to reliably create shared libraries on AIX.
*** Therefore, libtool is disabling shared libraries support.  If you
*** really care for shared libraries, you may want to install binutils
*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
*** You will then need to restart the configuration process.

_LT_EOF
      fi
      ;;

    amigaos*)
      case $host_cpu in
      powerpc)
            # see comment about AmigaOS4 .so support
            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
            archive_expsym_cmds=''
        ;;
      m68k)
            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
            hardcode_libdir_flag_spec='-L$libdir'
            hardcode_minus_L=yes
        ;;
      esac
      ;;

    beos*)
      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
	allow_undefined_flag=unsupported
	# Joseph Beckenbach  says some releases of gcc
	# support --undefined.  This deserves some investigation.  FIXME
	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
      else
	ld_shlibs=no
      fi
      ;;

    cygwin* | mingw* | pw32* | cegcc*)
      # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
      # as there is no search path for DLLs.
      hardcode_libdir_flag_spec='-L$libdir'
      export_dynamic_flag_spec='${wl}--export-all-symbols'
      allow_undefined_flag=unsupported
      always_export_symbols=no
      enable_shared_with_static_runtimes=yes
      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
      exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'

      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
	# If the export-symbols file already is a .def file (1st line
	# is EXPORTS), use it as is; otherwise, prepend...
	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
	  cp $export_symbols $output_objdir/$soname.def;
	else
	  echo EXPORTS > $output_objdir/$soname.def;
	  cat $export_symbols >> $output_objdir/$soname.def;
	fi~
	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
      else
	ld_shlibs=no
      fi
      ;;

    haiku*)
      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
      link_all_deplibs=yes
      ;;

    interix[3-9]*)
      hardcode_direct=no
      hardcode_shlibpath_var=no
      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
      export_dynamic_flag_spec='${wl}-E'
      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
      # Instead, shared libraries are loaded at an image base (0x10000000 by
      # default) and relocated if they conflict, which is a slow very memory
      # consuming and fragmenting process.  To avoid this, we pick a random,
      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
      ;;

    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
      tmp_diet=no
      if test "$host_os" = linux-dietlibc; then
	case $cc_basename in
	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
	esac
      fi
      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
	 && test "$tmp_diet" = no
      then
	tmp_addflag=' $pic_flag'
	tmp_sharedflag='-shared'
	case $cc_basename,$host_cpu in
        pgcc*)				# Portland Group C compiler
	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
	  tmp_addflag=' $pic_flag'
	  ;;
	pgf77* | pgf90* | pgf95* | pgfortran*)
					# Portland Group f77 and f90 compilers
	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
	  tmp_addflag=' $pic_flag -Mnomain' ;;
	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
	  tmp_addflag=' -i_dynamic' ;;
	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
	  tmp_addflag=' -i_dynamic -nofor_main' ;;
	ifc* | ifort*)			# Intel Fortran compiler
	  tmp_addflag=' -nofor_main' ;;
	lf95*)				# Lahey Fortran 8.1
	  whole_archive_flag_spec=
	  tmp_sharedflag='--shared' ;;
	xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
	  tmp_sharedflag='-qmkshrobj'
	  tmp_addflag= ;;
	nvcc*)	# Cuda Compiler Driver 2.2
	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
	  compiler_needs_object=yes
	  ;;
	esac
	case `$CC -V 2>&1 | sed 5q` in
	*Sun\ C*)			# Sun C 5.9
	  whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
	  compiler_needs_object=yes
	  tmp_sharedflag='-G' ;;
	*Sun\ F*)			# Sun Fortran 8.3
	  tmp_sharedflag='-G' ;;
	esac
	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'

        if test "x$supports_anon_versioning" = xyes; then
          archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
	    echo "local: *; };" >> $output_objdir/$libname.ver~
	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
        fi

	case $cc_basename in
	xlf* | bgf* | bgxlf* | mpixlf*)
	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
	  whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
	  hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
	  archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
	  if test "x$supports_anon_versioning" = xyes; then
	    archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
	      echo "local: *; };" >> $output_objdir/$libname.ver~
	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
	  fi
	  ;;
	esac
      else
        ld_shlibs=no
      fi
      ;;

    netbsd*)
      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
	wlarc=
      else
	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
      fi
      ;;

    solaris*)
      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
	ld_shlibs=no
	cat <<_LT_EOF 1>&2

*** Warning: The releases 2.8.* of the GNU linker cannot reliably
*** create shared libraries on Solaris systems.  Therefore, libtool
*** is disabling shared libraries support.  We urge you to upgrade GNU
*** binutils to release 2.9.1 or newer.  Another option is to modify
*** your PATH or compiler configuration so that the native linker is
*** used, and then restart.

_LT_EOF
      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
      else
	ld_shlibs=no
      fi
      ;;

    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
      case `$LD -v 2>&1` in
        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
	ld_shlibs=no
	cat <<_LT_EOF 1>&2

*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
*** reliably create shared libraries on SCO systems.  Therefore, libtool
*** is disabling shared libraries support.  We urge you to upgrade GNU
*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
*** your PATH or compiler configuration so that the native linker is
*** used, and then restart.

_LT_EOF
	;;
	*)
	  # For security reasons, it is highly recommended that you always
	  # use absolute paths for naming shared libraries, and exclude the
	  # DT_RUNPATH tag from executables and libraries.  But doing so
	  # requires that you compile everything twice, which is a pain.
	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
	    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
	  else
	    ld_shlibs=no
	  fi
	;;
      esac
      ;;

    sunos4*)
      archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
      wlarc=
      hardcode_direct=yes
      hardcode_shlibpath_var=no
      ;;

    *)
      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
      else
	ld_shlibs=no
      fi
      ;;
    esac

    if test "$ld_shlibs" = no; then
      runpath_var=
      hardcode_libdir_flag_spec=
      export_dynamic_flag_spec=
      whole_archive_flag_spec=
    fi
  else
    # PORTME fill in a description of your system's linker (not GNU ld)
    case $host_os in
    aix3*)
      allow_undefined_flag=unsupported
      always_export_symbols=yes
      archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
      # Note: this linker hardcodes the directories in LIBPATH if there
      # are no directories specified by -L.
      hardcode_minus_L=yes
      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
	# Neither direct hardcoding nor static linking is supported with a
	# broken collect2.
	hardcode_direct=unsupported
      fi
      ;;

    aix[4-9]*)
      if test "$host_cpu" = ia64; then
	# On IA64, the linker does run time linking by default, so we don't
	# have to do anything special.
	aix_use_runtimelinking=no
	exp_sym_flag='-Bexport'
	no_entry_flag=""
      else
	# If we're using GNU nm, then we don't want the "-C" option.
	# -C means demangle to AIX nm, but means don't demangle with GNU nm
	# Also, AIX nm treats weak defined symbols like other global
	# defined symbols, whereas GNU nm marks them as "W".
	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
	else
	  export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
	fi
	aix_use_runtimelinking=no

	# Test if we are trying to use run time linking or normal
	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
	# need to do runtime linking.
	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
	  for ld_flag in $LDFLAGS; do
	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
	    aix_use_runtimelinking=yes
	    break
	  fi
	  done
	  ;;
	esac

	exp_sym_flag='-bexport'
	no_entry_flag='-bnoentry'
      fi

      # When large executables or shared objects are built, AIX ld can
      # have problems creating the table of contents.  If linking a library
      # or program results in "error TOC overflow" add -mminimal-toc to
      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.

      archive_cmds=''
      hardcode_direct=yes
      hardcode_direct_absolute=yes
      hardcode_libdir_separator=':'
      link_all_deplibs=yes
      file_list_spec='${wl}-f,'

      if test "$GCC" = yes; then
	case $host_os in aix4.[012]|aix4.[012].*)
	# We only want to do this on AIX 4.2 and lower, the check
	# below for broken collect2 doesn't work under 4.3+
	  collect2name=`${CC} -print-prog-name=collect2`
	  if test -f "$collect2name" &&
	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
	  then
	  # We have reworked collect2
	  :
	  else
	  # We have old collect2
	  hardcode_direct=unsupported
	  # It fails to find uninstalled libraries when the uninstalled
	  # path is not listed in the libpath.  Setting hardcode_minus_L
	  # to unsupported forces relinking
	  hardcode_minus_L=yes
	  hardcode_libdir_flag_spec='-L$libdir'
	  hardcode_libdir_separator=
	  fi
	  ;;
	esac
	shared_flag='-shared'
	if test "$aix_use_runtimelinking" = yes; then
	  shared_flag="$shared_flag "'${wl}-G'
	fi
      else
	# not using gcc
	if test "$host_cpu" = ia64; then
	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
	# chokes on -Wl,-G. The following line is correct:
	  shared_flag='-G'
	else
	  if test "$aix_use_runtimelinking" = yes; then
	    shared_flag='${wl}-G'
	  else
	    shared_flag='${wl}-bM:SRE'
	  fi
	fi
      fi

      export_dynamic_flag_spec='${wl}-bexpall'
      # It seems that -bexpall does not export symbols beginning with
      # underscore (_), so it is better to generate a list of symbols to export.
      always_export_symbols=yes
      if test "$aix_use_runtimelinking" = yes; then
	# Warning - without using the other runtime loading flags (-brtl),
	# -berok will link without error, but may produce a broken library.
	allow_undefined_flag='-berok'
        # Determine the default libpath from the value encoded in an
        # empty executable.
        if test "${lt_cv_aix_libpath+set}" = set; then
  aix_libpath=$lt_cv_aix_libpath
else
  if ${lt_cv_aix_libpath_+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :

  lt_aix_libpath_sed='
      /Import File Strings/,/^$/ {
	  /^0/ {
	      s/^0  *\([^ ]*\) *$/\1/
	      p
	  }
      }'
  lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
  # Check for a 64-bit object if we didn't find anything.
  if test -z "$lt_cv_aix_libpath_"; then
    lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
  fi
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
  if test -z "$lt_cv_aix_libpath_"; then
    lt_cv_aix_libpath_="/usr/lib:/lib"
  fi

fi

  aix_libpath=$lt_cv_aix_libpath_
fi

        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
      else
	if test "$host_cpu" = ia64; then
	  hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
	  allow_undefined_flag="-z nodefs"
	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
	else
	 # Determine the default libpath from the value encoded in an
	 # empty executable.
	 if test "${lt_cv_aix_libpath+set}" = set; then
  aix_libpath=$lt_cv_aix_libpath
else
  if ${lt_cv_aix_libpath_+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :

  lt_aix_libpath_sed='
      /Import File Strings/,/^$/ {
	  /^0/ {
	      s/^0  *\([^ ]*\) *$/\1/
	      p
	  }
      }'
  lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
  # Check for a 64-bit object if we didn't find anything.
  if test -z "$lt_cv_aix_libpath_"; then
    lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
  fi
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
  if test -z "$lt_cv_aix_libpath_"; then
    lt_cv_aix_libpath_="/usr/lib:/lib"
  fi

fi

  aix_libpath=$lt_cv_aix_libpath_
fi

	 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
	  # Warning - without using the other run time loading flags,
	  # -berok will link without error, but may produce a broken library.
	  no_undefined_flag=' ${wl}-bernotok'
	  allow_undefined_flag=' ${wl}-berok'
	  if test "$with_gnu_ld" = yes; then
	    # We only use this code for GNU lds that support --whole-archive.
	    whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
	  else
	    # Exported symbols can be pulled into shared objects from archives
	    whole_archive_flag_spec='$convenience'
	  fi
	  archive_cmds_need_lc=yes
	  # This is similar to how AIX traditionally builds its shared libraries.
	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
	fi
      fi
      ;;

    amigaos*)
      case $host_cpu in
      powerpc)
            # see comment about AmigaOS4 .so support
            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
            archive_expsym_cmds=''
        ;;
      m68k)
            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
            hardcode_libdir_flag_spec='-L$libdir'
            hardcode_minus_L=yes
        ;;
      esac
      ;;

    bsdi[45]*)
      export_dynamic_flag_spec=-rdynamic
      ;;

    cygwin* | mingw* | pw32* | cegcc*)
      # When not using gcc, we currently assume that we are using
      # Microsoft Visual C++.
      # hardcode_libdir_flag_spec is actually meaningless, as there is
      # no search path for DLLs.
      case $cc_basename in
      cl*)
	# Native MSVC
	hardcode_libdir_flag_spec=' '
	allow_undefined_flag=unsupported
	always_export_symbols=yes
	file_list_spec='@'
	# Tell ltmain to make .lib files, not .a files.
	libext=lib
	# Tell ltmain to make .dll files, not .so files.
	shrext_cmds=".dll"
	# FIXME: Setting linknames here is a bad hack.
	archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
	  else
	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
	  fi~
	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
	  linknames='
	# The linker will not automatically build a static lib if we build a DLL.
	# _LT_TAGVAR(old_archive_from_new_cmds, )='true'
	enable_shared_with_static_runtimes=yes
	exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
	export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
	# Don't use ranlib
	old_postinstall_cmds='chmod 644 $oldlib'
	postlink_cmds='lt_outputfile="@OUTPUT@"~
	  lt_tool_outputfile="@TOOL_OUTPUT@"~
	  case $lt_outputfile in
	    *.exe|*.EXE) ;;
	    *)
	      lt_outputfile="$lt_outputfile.exe"
	      lt_tool_outputfile="$lt_tool_outputfile.exe"
	      ;;
	  esac~
	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
	    $RM "$lt_outputfile.manifest";
	  fi'
	;;
      *)
	# Assume MSVC wrapper
	hardcode_libdir_flag_spec=' '
	allow_undefined_flag=unsupported
	# Tell ltmain to make .lib files, not .a files.
	libext=lib
	# Tell ltmain to make .dll files, not .so files.
	shrext_cmds=".dll"
	# FIXME: Setting linknames here is a bad hack.
	archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
	# The linker will automatically build a .lib file if we build a DLL.
	old_archive_from_new_cmds='true'
	# FIXME: Should let the user specify the lib program.
	old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
	enable_shared_with_static_runtimes=yes
	;;
      esac
      ;;

    darwin* | rhapsody*)


  archive_cmds_need_lc=no
  hardcode_direct=no
  hardcode_automatic=yes
  hardcode_shlibpath_var=unsupported
  if test "$lt_cv_ld_force_load" = "yes"; then
    whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'

  else
    whole_archive_flag_spec=''
  fi
  link_all_deplibs=yes
  allow_undefined_flag="$_lt_dar_allow_undefined"
  case $cc_basename in
     ifort*) _lt_dar_can_shared=yes ;;
     *) _lt_dar_can_shared=$GCC ;;
  esac
  if test "$_lt_dar_can_shared" = "yes"; then
    output_verbose_link_cmd=func_echo_all
    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"

  else
  ld_shlibs=no
  fi

      ;;

    dgux*)
      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
      hardcode_libdir_flag_spec='-L$libdir'
      hardcode_shlibpath_var=no
      ;;

    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
    # support.  Future versions do this automatically, but an explicit c++rt0.o
    # does not break anything, and helps significantly (at the cost of a little
    # extra space).
    freebsd2.2*)
      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
      hardcode_libdir_flag_spec='-R$libdir'
      hardcode_direct=yes
      hardcode_shlibpath_var=no
      ;;

    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
    freebsd2.*)
      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
      hardcode_direct=yes
      hardcode_minus_L=yes
      hardcode_shlibpath_var=no
      ;;

    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
    freebsd* | dragonfly*)
      archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
      hardcode_libdir_flag_spec='-R$libdir'
      hardcode_direct=yes
      hardcode_shlibpath_var=no
      ;;

    hpux9*)
      if test "$GCC" = yes; then
	archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
      else
	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
      fi
      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
      hardcode_libdir_separator=:
      hardcode_direct=yes

      # hardcode_minus_L: Not really in the search PATH,
      # but as the default location of the library.
      hardcode_minus_L=yes
      export_dynamic_flag_spec='${wl}-E'
      ;;

    hpux10*)
      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
	archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
      else
	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
      fi
      if test "$with_gnu_ld" = no; then
	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
	hardcode_libdir_separator=:
	hardcode_direct=yes
	hardcode_direct_absolute=yes
	export_dynamic_flag_spec='${wl}-E'
	# hardcode_minus_L: Not really in the search PATH,
	# but as the default location of the library.
	hardcode_minus_L=yes
      fi
      ;;

    hpux11*)
      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
	case $host_cpu in
	hppa*64*)
	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
	  ;;
	ia64*)
	  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
	  ;;
	*)
	  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
	  ;;
	esac
      else
	case $host_cpu in
	hppa*64*)
	  archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
	  ;;
	ia64*)
	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
	  ;;
	*)

	  # Older versions of the 11.00 compiler do not understand -b yet
	  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
	  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5
$as_echo_n "checking if $CC understands -b... " >&6; }
if ${lt_cv_prog_compiler__b+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_prog_compiler__b=no
   save_LDFLAGS="$LDFLAGS"
   LDFLAGS="$LDFLAGS -b"
   echo "$lt_simple_link_test_code" > conftest.$ac_ext
   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
     # The linker can only warn and ignore the option if not recognized
     # So say no if there are warnings
     if test -s conftest.err; then
       # Append any errors to the config.log.
       cat conftest.err 1>&5
       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
       if diff conftest.exp conftest.er2 >/dev/null; then
         lt_cv_prog_compiler__b=yes
       fi
     else
       lt_cv_prog_compiler__b=yes
     fi
   fi
   $RM -r conftest*
   LDFLAGS="$save_LDFLAGS"

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
$as_echo "$lt_cv_prog_compiler__b" >&6; }

if test x"$lt_cv_prog_compiler__b" = xyes; then
    archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
else
    archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
fi

	  ;;
	esac
      fi
      if test "$with_gnu_ld" = no; then
	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
	hardcode_libdir_separator=:

	case $host_cpu in
	hppa*64*|ia64*)
	  hardcode_direct=no
	  hardcode_shlibpath_var=no
	  ;;
	*)
	  hardcode_direct=yes
	  hardcode_direct_absolute=yes
	  export_dynamic_flag_spec='${wl}-E'

	  # hardcode_minus_L: Not really in the search PATH,
	  # but as the default location of the library.
	  hardcode_minus_L=yes
	  ;;
	esac
      fi
      ;;

    irix5* | irix6* | nonstopux*)
      if test "$GCC" = yes; then
	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
	# Try to use the -exported_symbol ld option, if it does not
	# work, assume that -exports_file does not work either and
	# implicitly export all symbols.
	# This should be the same for all languages, so no per-tag cache variable.
	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5
$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; }
if ${lt_cv_irix_exported_symbol+:} false; then :
  $as_echo_n "(cached) " >&6
else
  save_LDFLAGS="$LDFLAGS"
	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
	   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
int foo (void) { return 0; }
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  lt_cv_irix_exported_symbol=yes
else
  lt_cv_irix_exported_symbol=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
           LDFLAGS="$save_LDFLAGS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
$as_echo "$lt_cv_irix_exported_symbol" >&6; }
	if test "$lt_cv_irix_exported_symbol" = yes; then
          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
	fi
      else
	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
      fi
      archive_cmds_need_lc='no'
      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
      hardcode_libdir_separator=:
      inherit_rpath=yes
      link_all_deplibs=yes
      ;;

    netbsd*)
      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
      else
	archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
      fi
      hardcode_libdir_flag_spec='-R$libdir'
      hardcode_direct=yes
      hardcode_shlibpath_var=no
      ;;

    newsos6)
      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
      hardcode_direct=yes
      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
      hardcode_libdir_separator=:
      hardcode_shlibpath_var=no
      ;;

    *nto* | *qnx*)
      ;;

    openbsd*)
      if test -f /usr/libexec/ld.so; then
	hardcode_direct=yes
	hardcode_shlibpath_var=no
	hardcode_direct_absolute=yes
	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
	  hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
	  export_dynamic_flag_spec='${wl}-E'
	else
	  case $host_os in
	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
	     archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
	     hardcode_libdir_flag_spec='-R$libdir'
	     ;;
	   *)
	     archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
	     hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
	     ;;
	  esac
	fi
      else
	ld_shlibs=no
      fi
      ;;

    os2*)
      hardcode_libdir_flag_spec='-L$libdir'
      hardcode_minus_L=yes
      allow_undefined_flag=unsupported
      archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
      old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
      ;;

    osf3*)
      if test "$GCC" = yes; then
	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
      else
	allow_undefined_flag=' -expect_unresolved \*'
	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
      fi
      archive_cmds_need_lc='no'
      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
      hardcode_libdir_separator=:
      ;;

    osf4* | osf5*)	# as osf3* with the addition of -msym flag
      if test "$GCC" = yes; then
	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
	archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
	hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
      else
	allow_undefined_flag=' -expect_unresolved \*'
	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'

	# Both c and cxx compiler support -rpath directly
	hardcode_libdir_flag_spec='-rpath $libdir'
      fi
      archive_cmds_need_lc='no'
      hardcode_libdir_separator=:
      ;;

    solaris*)
      no_undefined_flag=' -z defs'
      if test "$GCC" = yes; then
	wlarc='${wl}'
	archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
	archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
      else
	case `$CC -V 2>&1` in
	*"Compilers 5.0"*)
	  wlarc=''
	  archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
	  ;;
	*)
	  wlarc='${wl}'
	  archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
	  ;;
	esac
      fi
      hardcode_libdir_flag_spec='-R$libdir'
      hardcode_shlibpath_var=no
      case $host_os in
      solaris2.[0-5] | solaris2.[0-5].*) ;;
      *)
	# The compiler driver will combine and reorder linker options,
	# but understands `-z linker_flag'.  GCC discards it without `$wl',
	# but is careful enough not to reorder.
	# Supported since Solaris 2.6 (maybe 2.5.1?)
	if test "$GCC" = yes; then
	  whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
	else
	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
	fi
	;;
      esac
      link_all_deplibs=yes
      ;;

    sunos4*)
      if test "x$host_vendor" = xsequent; then
	# Use $CC to link under sequent, because it throws in some extra .o
	# files that make .init and .fini sections work.
	archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
      else
	archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
      fi
      hardcode_libdir_flag_spec='-L$libdir'
      hardcode_direct=yes
      hardcode_minus_L=yes
      hardcode_shlibpath_var=no
      ;;

    sysv4)
      case $host_vendor in
	sni)
	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
	  hardcode_direct=yes # is this really true???
	;;
	siemens)
	  ## LD is ld it makes a PLAMLIB
	  ## CC just makes a GrossModule.
	  archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
	  reload_cmds='$CC -r -o $output$reload_objs'
	  hardcode_direct=no
        ;;
	motorola)
	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
	  hardcode_direct=no #Motorola manual says yes, but my tests say they lie
	;;
      esac
      runpath_var='LD_RUN_PATH'
      hardcode_shlibpath_var=no
      ;;

    sysv4.3*)
      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
      hardcode_shlibpath_var=no
      export_dynamic_flag_spec='-Bexport'
      ;;

    sysv4*MP*)
      if test -d /usr/nec; then
	archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
	hardcode_shlibpath_var=no
	runpath_var=LD_RUN_PATH
	hardcode_runpath_var=yes
	ld_shlibs=yes
      fi
      ;;

    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
      no_undefined_flag='${wl}-z,text'
      archive_cmds_need_lc=no
      hardcode_shlibpath_var=no
      runpath_var='LD_RUN_PATH'

      if test "$GCC" = yes; then
	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
      else
	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
      fi
      ;;

    sysv5* | sco3.2v5* | sco5v6*)
      # Note: We can NOT use -z defs as we might desire, because we do not
      # link with -lc, and that would cause any symbols used from libc to
      # always be unresolved, which means just about no library would
      # ever link correctly.  If we're not using GNU ld we use -z text
      # though, which does catch some bad symbols but isn't as heavy-handed
      # as -z defs.
      no_undefined_flag='${wl}-z,text'
      allow_undefined_flag='${wl}-z,nodefs'
      archive_cmds_need_lc=no
      hardcode_shlibpath_var=no
      hardcode_libdir_flag_spec='${wl}-R,$libdir'
      hardcode_libdir_separator=':'
      link_all_deplibs=yes
      export_dynamic_flag_spec='${wl}-Bexport'
      runpath_var='LD_RUN_PATH'

      if test "$GCC" = yes; then
	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
      else
	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
      fi
      ;;

    uts4*)
      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
      hardcode_libdir_flag_spec='-L$libdir'
      hardcode_shlibpath_var=no
      ;;

    *)
      ld_shlibs=no
      ;;
    esac

    if test x$host_vendor = xsni; then
      case $host in
      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
	export_dynamic_flag_spec='${wl}-Blargedynsym'
	;;
      esac
    fi
  fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
$as_echo "$ld_shlibs" >&6; }
test "$ld_shlibs" = no && can_build_shared=no

with_gnu_ld=$with_gnu_ld















#
# Do we need to explicitly link libc?
#
case "x$archive_cmds_need_lc" in
x|xyes)
  # Assume -lc should be added
  archive_cmds_need_lc=yes

  if test "$enable_shared" = yes && test "$GCC" = yes; then
    case $archive_cmds in
    *'~'*)
      # FIXME: we may have to deal with multi-command sequences.
      ;;
    '$CC '*)
      # Test whether the compiler implicitly links with -lc since on some
      # systems, -lgcc has to come before -lc. If gcc already passes -lc
      # to ld, don't add -lc before -lgcc.
      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
if ${lt_cv_archive_cmds_need_lc+:} false; then :
  $as_echo_n "(cached) " >&6
else
  $RM conftest*
	echo "$lt_simple_compile_test_code" > conftest.$ac_ext

	if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; } 2>conftest.err; then
	  soname=conftest
	  lib=conftest
	  libobjs=conftest.$ac_objext
	  deplibs=
	  wl=$lt_prog_compiler_wl
	  pic_flag=$lt_prog_compiler_pic
	  compiler_flags=-v
	  linker_flags=-v
	  verstring=
	  output_objdir=.
	  libname=conftest
	  lt_save_allow_undefined_flag=$allow_undefined_flag
	  allow_undefined_flag=
	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
  (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }
	  then
	    lt_cv_archive_cmds_need_lc=no
	  else
	    lt_cv_archive_cmds_need_lc=yes
	  fi
	  allow_undefined_flag=$lt_save_allow_undefined_flag
	else
	  cat conftest.err 1>&5
	fi
	$RM conftest*

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5
$as_echo "$lt_cv_archive_cmds_need_lc" >&6; }
      archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc
      ;;
    esac
  fi
  ;;
esac
























































































































































  { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
$as_echo_n "checking dynamic linker characteristics... " >&6; }

if test "$GCC" = yes; then
  case $host_os in
    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
    *) lt_awk_arg="/^libraries:/" ;;
  esac
  case $host_os in
    mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;;
    *) lt_sed_strip_eq="s,=/,/,g" ;;
  esac
  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
  case $lt_search_path_spec in
  *\;*)
    # if the path contains ";" then we assume it to be the separator
    # otherwise default to the standard path separator (i.e. ":") - it is
    # assumed that no part of a normal pathname contains ";" but that should
    # okay in the real world where ";" in dirpaths is itself problematic.
    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
    ;;
  *)
    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
    ;;
  esac
  # Ok, now we have the path, separated by spaces, we can step through it
  # and add multilib dir if necessary.
  lt_tmp_lt_search_path_spec=
  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
  for lt_sys_path in $lt_search_path_spec; do
    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
    else
      test -d "$lt_sys_path" && \
	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
    fi
  done
  lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
BEGIN {RS=" "; FS="/|\n";} {
  lt_foo="";
  lt_count=0;
  for (lt_i = NF; lt_i > 0; lt_i--) {
    if ($lt_i != "" && $lt_i != ".") {
      if ($lt_i == "..") {
        lt_count++;
      } else {
        if (lt_count == 0) {
          lt_foo="/" $lt_i lt_foo;
        } else {
          lt_count--;
        }
      }
    }
  }
  if (lt_foo != "") { lt_freq[lt_foo]++; }
  if (lt_freq[lt_foo] == 1) { print lt_foo; }
}'`
  # AWK program above erroneously prepends '/' to C:/dos/paths
  # for these hosts.
  case $host_os in
    mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
      $SED 's,/\([A-Za-z]:\),\1,g'` ;;
  esac
  sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
else
  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
fi
library_names_spec=
libname_spec='lib$name'
soname_spec=
shrext_cmds=".so"
postinstall_cmds=
postuninstall_cmds=
finish_cmds=
finish_eval=
shlibpath_var=
shlibpath_overrides_runpath=unknown
version_type=none
dynamic_linker="$host_os ld.so"
sys_lib_dlsearch_path_spec="/lib /usr/lib"
need_lib_prefix=unknown
hardcode_into_libs=no

# when you set need_version to no, make sure it does not cause -set_version
# flags to be left without arguments
need_version=unknown

case $host_os in
aix3*)
  version_type=linux # correct to gnu/linux during the next big refactor
  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
  shlibpath_var=LIBPATH

  # AIX 3 has no versioning support, so we append a major version to the name.
  soname_spec='${libname}${release}${shared_ext}$major'
  ;;

aix[4-9]*)
  version_type=linux # correct to gnu/linux during the next big refactor
  need_lib_prefix=no
  need_version=no
  hardcode_into_libs=yes
  if test "$host_cpu" = ia64; then
    # AIX 5 supports IA64
    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
    shlibpath_var=LD_LIBRARY_PATH
  else
    # With GCC up to 2.95.x, collect2 would create an import file
    # for dependence libraries.  The import file would start with
    # the line `#! .'.  This would cause the generated library to
    # depend on `.', always an invalid library.  This was fixed in
    # development snapshots of GCC prior to 3.0.
    case $host_os in
      aix4 | aix4.[01] | aix4.[01].*)
      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
	   echo ' yes '
	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
	:
      else
	can_build_shared=no
      fi
      ;;
    esac
    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
    # soname into executable. Probably we can add versioning support to
    # collect2, so additional links can be useful in future.
    if test "$aix_use_runtimelinking" = yes; then
      # If using run time linking (on AIX 4.2 or later) use lib.so
      # instead of lib.a to let people know that these are not
      # typical AIX shared libraries.
      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
    else
      # We preserve .a as extension for shared libraries through AIX4.2
      # and later when we are not doing run time linking.
      library_names_spec='${libname}${release}.a $libname.a'
      soname_spec='${libname}${release}${shared_ext}$major'
    fi
    shlibpath_var=LIBPATH
  fi
  ;;

amigaos*)
  case $host_cpu in
  powerpc)
    # Since July 2007 AmigaOS4 officially supports .so libraries.
    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
    ;;
  m68k)
    library_names_spec='$libname.ixlibrary $libname.a'
    # Create ${libname}_ixlibrary.a entries in /sys/libs.
    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
    ;;
  esac
  ;;

beos*)
  library_names_spec='${libname}${shared_ext}'
  dynamic_linker="$host_os ld.so"
  shlibpath_var=LIBRARY_PATH
  ;;

bsdi[45]*)
  version_type=linux # correct to gnu/linux during the next big refactor
  need_version=no
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
  soname_spec='${libname}${release}${shared_ext}$major'
  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
  shlibpath_var=LD_LIBRARY_PATH
  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
  # the default ld.so.conf also contains /usr/contrib/lib and
  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
  # libtool to hard-code these into programs
  ;;

cygwin* | mingw* | pw32* | cegcc*)
  version_type=windows
  shrext_cmds=".dll"
  need_version=no
  need_lib_prefix=no

  case $GCC,$cc_basename in
  yes,*)
    # gcc
    library_names_spec='$libname.dll.a'
    # DLL is installed to $(libdir)/../bin by postinstall_cmds
    postinstall_cmds='base_file=`basename \${file}`~
      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
      dldir=$destdir/`dirname \$dlpath`~
      test -d \$dldir || mkdir -p \$dldir~
      $install_prog $dir/$dlname \$dldir/$dlname~
      chmod a+x \$dldir/$dlname~
      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
      fi'
    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
      dlpath=$dir/\$dldll~
       $RM \$dlpath'
    shlibpath_overrides_runpath=yes

    case $host_os in
    cygwin*)
      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'

      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
      ;;
    mingw* | cegcc*)
      # MinGW DLLs use traditional 'lib' prefix
      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
      ;;
    pw32*)
      # pw32 DLLs use 'pw' prefix rather than 'lib'
      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
      ;;
    esac
    dynamic_linker='Win32 ld.exe'
    ;;

  *,cl*)
    # Native MSVC
    libname_spec='$name'
    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
    library_names_spec='${libname}.dll.lib'

    case $build_os in
    mingw*)
      sys_lib_search_path_spec=
      lt_save_ifs=$IFS
      IFS=';'
      for lt_path in $LIB
      do
        IFS=$lt_save_ifs
        # Let DOS variable expansion print the short 8.3 style file name.
        lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
        sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
      done
      IFS=$lt_save_ifs
      # Convert to MSYS style.
      sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
      ;;
    cygwin*)
      # Convert to unix form, then to dos form, then back to unix form
      # but this time dos style (no spaces!) so that the unix form looks
      # like /cygdrive/c/PROGRA~1:/cygdr...
      sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
      sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
      sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
      ;;
    *)
      sys_lib_search_path_spec="$LIB"
      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
        # It is most probably a Windows format PATH.
        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
      else
        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
      fi
      # FIXME: find the short name or the path components, as spaces are
      # common. (e.g. "Program Files" -> "PROGRA~1")
      ;;
    esac

    # DLL is installed to $(libdir)/../bin by postinstall_cmds
    postinstall_cmds='base_file=`basename \${file}`~
      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
      dldir=$destdir/`dirname \$dlpath`~
      test -d \$dldir || mkdir -p \$dldir~
      $install_prog $dir/$dlname \$dldir/$dlname'
    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
      dlpath=$dir/\$dldll~
       $RM \$dlpath'
    shlibpath_overrides_runpath=yes
    dynamic_linker='Win32 link.exe'
    ;;

  *)
    # Assume MSVC wrapper
    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
    dynamic_linker='Win32 ld.exe'
    ;;
  esac
  # FIXME: first we should search . and the directory the executable is in
  shlibpath_var=PATH
  ;;

darwin* | rhapsody*)
  dynamic_linker="$host_os dyld"
  version_type=darwin
  need_lib_prefix=no
  need_version=no
  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
  soname_spec='${libname}${release}${major}$shared_ext'
  shlibpath_overrides_runpath=yes
  shlibpath_var=DYLD_LIBRARY_PATH
  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'

  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
  ;;

dgux*)
  version_type=linux # correct to gnu/linux during the next big refactor
  need_lib_prefix=no
  need_version=no
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
  soname_spec='${libname}${release}${shared_ext}$major'
  shlibpath_var=LD_LIBRARY_PATH
  ;;

freebsd* | dragonfly*)
  # DragonFly does not have aout.  When/if they implement a new
  # versioning mechanism, adjust this.
  if test -x /usr/bin/objformat; then
    objformat=`/usr/bin/objformat`
  else
    case $host_os in
    freebsd[23].*) objformat=aout ;;
    *) objformat=elf ;;
    esac
  fi
  version_type=freebsd-$objformat
  case $version_type in
    freebsd-elf*)
      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
      need_version=no
      need_lib_prefix=no
      ;;
    freebsd-*)
      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
      need_version=yes
      ;;
  esac
  shlibpath_var=LD_LIBRARY_PATH
  case $host_os in
  freebsd2.*)
    shlibpath_overrides_runpath=yes
    ;;
  freebsd3.[01]* | freebsdelf3.[01]*)
    shlibpath_overrides_runpath=yes
    hardcode_into_libs=yes
    ;;
  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
    shlibpath_overrides_runpath=no
    hardcode_into_libs=yes
    ;;
  *) # from 4.6 on, and DragonFly
    shlibpath_overrides_runpath=yes
    hardcode_into_libs=yes
    ;;
  esac
  ;;

gnu*)
  version_type=linux # correct to gnu/linux during the next big refactor
  need_lib_prefix=no
  need_version=no
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
  soname_spec='${libname}${release}${shared_ext}$major'
  shlibpath_var=LD_LIBRARY_PATH
  shlibpath_overrides_runpath=no
  hardcode_into_libs=yes
  ;;

haiku*)
  version_type=linux # correct to gnu/linux during the next big refactor
  need_lib_prefix=no
  need_version=no
  dynamic_linker="$host_os runtime_loader"
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
  soname_spec='${libname}${release}${shared_ext}$major'
  shlibpath_var=LIBRARY_PATH
  shlibpath_overrides_runpath=yes
  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
  hardcode_into_libs=yes
  ;;

hpux9* | hpux10* | hpux11*)
  # Give a soname corresponding to the major version so that dld.sl refuses to
  # link against other versions.
  version_type=sunos
  need_lib_prefix=no
  need_version=no
  case $host_cpu in
  ia64*)
    shrext_cmds='.so'
    hardcode_into_libs=yes
    dynamic_linker="$host_os dld.so"
    shlibpath_var=LD_LIBRARY_PATH
    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
    soname_spec='${libname}${release}${shared_ext}$major'
    if test "X$HPUX_IA64_MODE" = X32; then
      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
    else
      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
    fi
    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
    ;;
  hppa*64*)
    shrext_cmds='.sl'
    hardcode_into_libs=yes
    dynamic_linker="$host_os dld.sl"
    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
    soname_spec='${libname}${release}${shared_ext}$major'
    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
    ;;
  *)
    shrext_cmds='.sl'
    dynamic_linker="$host_os dld.sl"
    shlibpath_var=SHLIB_PATH
    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
    soname_spec='${libname}${release}${shared_ext}$major'
    ;;
  esac
  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
  postinstall_cmds='chmod 555 $lib'
  # or fails outright, so override atomically:
  install_override_mode=555
  ;;

interix[3-9]*)
  version_type=linux # correct to gnu/linux during the next big refactor
  need_lib_prefix=no
  need_version=no
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
  soname_spec='${libname}${release}${shared_ext}$major'
  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
  shlibpath_var=LD_LIBRARY_PATH
  shlibpath_overrides_runpath=no
  hardcode_into_libs=yes
  ;;

irix5* | irix6* | nonstopux*)
  case $host_os in
    nonstopux*) version_type=nonstopux ;;
    *)
	if test "$lt_cv_prog_gnu_ld" = yes; then
		version_type=linux # correct to gnu/linux during the next big refactor
	else
		version_type=irix
	fi ;;
  esac
  need_lib_prefix=no
  need_version=no
  soname_spec='${libname}${release}${shared_ext}$major'
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
  case $host_os in
  irix5* | nonstopux*)
    libsuff= shlibsuff=
    ;;
  *)
    case $LD in # libtool.m4 will add one of these switches to LD
    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
      libsuff= shlibsuff= libmagic=32-bit;;
    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
      libsuff=32 shlibsuff=N32 libmagic=N32;;
    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
      libsuff=64 shlibsuff=64 libmagic=64-bit;;
    *) libsuff= shlibsuff= libmagic=never-match;;
    esac
    ;;
  esac
  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
  shlibpath_overrides_runpath=no
  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
  hardcode_into_libs=yes
  ;;

# No shared lib support for Linux oldld, aout, or coff.
linux*oldld* | linux*aout* | linux*coff*)
  dynamic_linker=no
  ;;

# This must be glibc/ELF.
linux* | k*bsd*-gnu | kopensolaris*-gnu)
  version_type=linux # correct to gnu/linux during the next big refactor
  need_lib_prefix=no
  need_version=no
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
  soname_spec='${libname}${release}${shared_ext}$major'
  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
  shlibpath_var=LD_LIBRARY_PATH
  shlibpath_overrides_runpath=no

  # Some binutils ld are patched to set DT_RUNPATH
  if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
  $as_echo_n "(cached) " >&6
else
  lt_cv_shlibpath_overrides_runpath=no
    save_LDFLAGS=$LDFLAGS
    save_libdir=$libdir
    eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
	 LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
  lt_cv_shlibpath_overrides_runpath=yes
fi
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
    LDFLAGS=$save_LDFLAGS
    libdir=$save_libdir

fi

  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath

  # This implies no fast_install, which is unacceptable.
  # Some rework will be needed to allow for fast_install
  # before this can be enabled.
  hardcode_into_libs=yes

  # Append ld.so.conf contents to the search path
  if test -f /etc/ld.so.conf; then
    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
  fi

  # We used to test for /lib/ld.so.1 and disable shared libraries on
  # powerpc, because MkLinux only supported shared libraries with the
  # GNU dynamic linker.  Since this was broken with cross compilers,
  # most powerpc-linux boxes support dynamic linking these days and
  # people can always --disable-shared, the test was removed, and we
  # assume the GNU/Linux dynamic linker is in use.
  dynamic_linker='GNU/Linux ld.so'
  ;;

netbsd*)
  version_type=sunos
  need_lib_prefix=no
  need_version=no
  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
    dynamic_linker='NetBSD (a.out) ld.so'
  else
    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
    soname_spec='${libname}${release}${shared_ext}$major'
    dynamic_linker='NetBSD ld.elf_so'
  fi
  shlibpath_var=LD_LIBRARY_PATH
  shlibpath_overrides_runpath=yes
  hardcode_into_libs=yes
  ;;

newsos6)
  version_type=linux # correct to gnu/linux during the next big refactor
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
  shlibpath_var=LD_LIBRARY_PATH
  shlibpath_overrides_runpath=yes
  ;;

*nto* | *qnx*)
  version_type=qnx
  need_lib_prefix=no
  need_version=no
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
  soname_spec='${libname}${release}${shared_ext}$major'
  shlibpath_var=LD_LIBRARY_PATH
  shlibpath_overrides_runpath=no
  hardcode_into_libs=yes
  dynamic_linker='ldqnx.so'
  ;;

openbsd*)
  version_type=sunos
  sys_lib_dlsearch_path_spec="/usr/lib"
  need_lib_prefix=no
  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
  case $host_os in
    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
    *)				need_version=no  ;;
  esac
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
  shlibpath_var=LD_LIBRARY_PATH
  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
    case $host_os in
      openbsd2.[89] | openbsd2.[89].*)
	shlibpath_overrides_runpath=no
	;;
      *)
	shlibpath_overrides_runpath=yes
	;;
      esac
  else
    shlibpath_overrides_runpath=yes
  fi
  ;;

os2*)
  libname_spec='$name'
  shrext_cmds=".dll"
  need_lib_prefix=no
  library_names_spec='$libname${shared_ext} $libname.a'
  dynamic_linker='OS/2 ld.exe'
  shlibpath_var=LIBPATH
  ;;

osf3* | osf4* | osf5*)
  version_type=osf
  need_lib_prefix=no
  need_version=no
  soname_spec='${libname}${release}${shared_ext}$major'
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
  shlibpath_var=LD_LIBRARY_PATH
  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
  ;;

rdos*)
  dynamic_linker=no
  ;;

solaris*)
  version_type=linux # correct to gnu/linux during the next big refactor
  need_lib_prefix=no
  need_version=no
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
  soname_spec='${libname}${release}${shared_ext}$major'
  shlibpath_var=LD_LIBRARY_PATH
  shlibpath_overrides_runpath=yes
  hardcode_into_libs=yes
  # ldd complains unless libraries are executable
  postinstall_cmds='chmod +x $lib'
  ;;

sunos4*)
  version_type=sunos
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
  shlibpath_var=LD_LIBRARY_PATH
  shlibpath_overrides_runpath=yes
  if test "$with_gnu_ld" = yes; then
    need_lib_prefix=no
  fi
  need_version=yes
  ;;

sysv4 | sysv4.3*)
  version_type=linux # correct to gnu/linux during the next big refactor
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
  soname_spec='${libname}${release}${shared_ext}$major'
  shlibpath_var=LD_LIBRARY_PATH
  case $host_vendor in
    sni)
      shlibpath_overrides_runpath=no
      need_lib_prefix=no
      runpath_var=LD_RUN_PATH
      ;;
    siemens)
      need_lib_prefix=no
      ;;
    motorola)
      need_lib_prefix=no
      need_version=no
      shlibpath_overrides_runpath=no
      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
      ;;
  esac
  ;;

sysv4*MP*)
  if test -d /usr/nec ;then
    version_type=linux # correct to gnu/linux during the next big refactor
    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
    soname_spec='$libname${shared_ext}.$major'
    shlibpath_var=LD_LIBRARY_PATH
  fi
  ;;

sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
  version_type=freebsd-elf
  need_lib_prefix=no
  need_version=no
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
  soname_spec='${libname}${release}${shared_ext}$major'
  shlibpath_var=LD_LIBRARY_PATH
  shlibpath_overrides_runpath=yes
  hardcode_into_libs=yes
  if test "$with_gnu_ld" = yes; then
    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
  else
    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
    case $host_os in
      sco3.2v5*)
        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
	;;
    esac
  fi
  sys_lib_dlsearch_path_spec='/usr/lib'
  ;;

tpf*)
  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
  version_type=linux # correct to gnu/linux during the next big refactor
  need_lib_prefix=no
  need_version=no
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
  shlibpath_var=LD_LIBRARY_PATH
  shlibpath_overrides_runpath=no
  hardcode_into_libs=yes
  ;;

uts4*)
  version_type=linux # correct to gnu/linux during the next big refactor
  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
  soname_spec='${libname}${release}${shared_ext}$major'
  shlibpath_var=LD_LIBRARY_PATH
  ;;

*)
  dynamic_linker=no
  ;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
$as_echo "$dynamic_linker" >&6; }
test "$dynamic_linker" = no && can_build_shared=no

variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
if test "$GCC" = yes; then
  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
fi

if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
fi
if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
fi




























































































  { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
hardcode_action=
if test -n "$hardcode_libdir_flag_spec" ||
   test -n "$runpath_var" ||
   test "X$hardcode_automatic" = "Xyes" ; then

  # We can hardcode non-existent directories.
  if test "$hardcode_direct" != no &&
     # If the only mechanism to avoid hardcoding is shlibpath_var, we
     # have to relink, otherwise we might link with an installed library
     # when we should be linking with a yet-to-be-installed one
     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
     test "$hardcode_minus_L" != no; then
    # Linking always hardcodes the temporary library directory.
    hardcode_action=relink
  else
    # We can link without hardcoding, and we can hardcode nonexisting dirs.
    hardcode_action=immediate
  fi
else
  # We cannot hardcode anything, or else we can only hardcode existing
  # directories.
  hardcode_action=unsupported
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
$as_echo "$hardcode_action" >&6; }

if test "$hardcode_action" = relink ||
   test "$inherit_rpath" = yes; then
  # Fast installation is not supported
  enable_fast_install=no
elif test "$shlibpath_overrides_runpath" = yes ||
     test "$enable_shared" = no; then
  # Fast installation is not necessary
  enable_fast_install=needless
fi






  if test "x$enable_dlopen" != xyes; then
  enable_dlopen=unknown
  enable_dlopen_self=unknown
  enable_dlopen_self_static=unknown
else
  lt_cv_dlopen=no
  lt_cv_dlopen_libs=

  case $host_os in
  beos*)
    lt_cv_dlopen="load_add_on"
    lt_cv_dlopen_libs=
    lt_cv_dlopen_self=yes
    ;;

  mingw* | pw32* | cegcc*)
    lt_cv_dlopen="LoadLibrary"
    lt_cv_dlopen_libs=
    ;;

  cygwin*)
    lt_cv_dlopen="dlopen"
    lt_cv_dlopen_libs=
    ;;

  darwin*)
  # if libdl is installed we need to link against it
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
$as_echo_n "checking for dlopen in -ldl... " >&6; }
if ${ac_cv_lib_dl_dlopen+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-ldl  $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char dlopen ();
int
main ()
{
return dlopen ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_dl_dlopen=yes
else
  ac_cv_lib_dl_dlopen=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
else

    lt_cv_dlopen="dyld"
    lt_cv_dlopen_libs=
    lt_cv_dlopen_self=yes

fi

    ;;

  *)
    ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
if test "x$ac_cv_func_shl_load" = xyes; then :
  lt_cv_dlopen="shl_load"
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
$as_echo_n "checking for shl_load in -ldld... " >&6; }
if ${ac_cv_lib_dld_shl_load+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-ldld  $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char shl_load ();
int
main ()
{
return shl_load ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_dld_shl_load=yes
else
  ac_cv_lib_dld_shl_load=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
else
  ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
if test "x$ac_cv_func_dlopen" = xyes; then :
  lt_cv_dlopen="dlopen"
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
$as_echo_n "checking for dlopen in -ldl... " >&6; }
if ${ac_cv_lib_dl_dlopen+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-ldl  $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char dlopen ();
int
main ()
{
return dlopen ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_dl_dlopen=yes
else
  ac_cv_lib_dl_dlopen=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
$as_echo_n "checking for dlopen in -lsvld... " >&6; }
if ${ac_cv_lib_svld_dlopen+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lsvld  $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char dlopen ();
int
main ()
{
return dlopen ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_svld_dlopen=yes
else
  ac_cv_lib_svld_dlopen=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
$as_echo "$ac_cv_lib_svld_dlopen" >&6; }
if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
$as_echo_n "checking for dld_link in -ldld... " >&6; }
if ${ac_cv_lib_dld_dld_link+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-ldld  $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char dld_link ();
int
main ()
{
return dld_link ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_dld_dld_link=yes
else
  ac_cv_lib_dld_dld_link=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
fi


fi


fi


fi


fi


fi

    ;;
  esac

  if test "x$lt_cv_dlopen" != xno; then
    enable_dlopen=yes
  else
    enable_dlopen=no
  fi

  case $lt_cv_dlopen in
  dlopen)
    save_CPPFLAGS="$CPPFLAGS"
    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"

    save_LDFLAGS="$LDFLAGS"
    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"

    save_LIBS="$LIBS"
    LIBS="$lt_cv_dlopen_libs $LIBS"

    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
$as_echo_n "checking whether a program can dlopen itself... " >&6; }
if ${lt_cv_dlopen_self+:} false; then :
  $as_echo_n "(cached) " >&6
else
  	  if test "$cross_compiling" = yes; then :
  lt_cv_dlopen_self=cross
else
  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
  lt_status=$lt_dlunknown
  cat > conftest.$ac_ext <<_LT_EOF
#line $LINENO "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
#include 
#endif

#include 

#ifdef RTLD_GLOBAL
#  define LT_DLGLOBAL		RTLD_GLOBAL
#else
#  ifdef DL_GLOBAL
#    define LT_DLGLOBAL		DL_GLOBAL
#  else
#    define LT_DLGLOBAL		0
#  endif
#endif

/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
   find out it does not work in some platform. */
#ifndef LT_DLLAZY_OR_NOW
#  ifdef RTLD_LAZY
#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
#  else
#    ifdef DL_LAZY
#      define LT_DLLAZY_OR_NOW		DL_LAZY
#    else
#      ifdef RTLD_NOW
#        define LT_DLLAZY_OR_NOW	RTLD_NOW
#      else
#        ifdef DL_NOW
#          define LT_DLLAZY_OR_NOW	DL_NOW
#        else
#          define LT_DLLAZY_OR_NOW	0
#        endif
#      endif
#    endif
#  endif
#endif

/* When -fvisbility=hidden is used, assume the code has been annotated
   correspondingly for the symbols needed.  */
#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
int fnord () __attribute__((visibility("default")));
#endif

int fnord () { return 42; }
int main ()
{
  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
  int status = $lt_dlunknown;

  if (self)
    {
      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
      else
        {
	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
          else puts (dlerror ());
	}
      /* dlclose (self); */
    }
  else
    puts (dlerror ());

  return status;
}
_LT_EOF
  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
    (./conftest; exit; ) >&5 2>/dev/null
    lt_status=$?
    case x$lt_status in
      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
      x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
    esac
  else :
    # compilation failed
    lt_cv_dlopen_self=no
  fi
fi
rm -fr conftest*


fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
$as_echo "$lt_cv_dlopen_self" >&6; }

    if test "x$lt_cv_dlopen_self" = xyes; then
      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
if ${lt_cv_dlopen_self_static+:} false; then :
  $as_echo_n "(cached) " >&6
else
  	  if test "$cross_compiling" = yes; then :
  lt_cv_dlopen_self_static=cross
else
  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
  lt_status=$lt_dlunknown
  cat > conftest.$ac_ext <<_LT_EOF
#line $LINENO "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
#include 
#endif

#include 

#ifdef RTLD_GLOBAL
#  define LT_DLGLOBAL		RTLD_GLOBAL
#else
#  ifdef DL_GLOBAL
#    define LT_DLGLOBAL		DL_GLOBAL
#  else
#    define LT_DLGLOBAL		0
#  endif
#endif

/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
   find out it does not work in some platform. */
#ifndef LT_DLLAZY_OR_NOW
#  ifdef RTLD_LAZY
#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
#  else
#    ifdef DL_LAZY
#      define LT_DLLAZY_OR_NOW		DL_LAZY
#    else
#      ifdef RTLD_NOW
#        define LT_DLLAZY_OR_NOW	RTLD_NOW
#      else
#        ifdef DL_NOW
#          define LT_DLLAZY_OR_NOW	DL_NOW
#        else
#          define LT_DLLAZY_OR_NOW	0
#        endif
#      endif
#    endif
#  endif
#endif

/* When -fvisbility=hidden is used, assume the code has been annotated
   correspondingly for the symbols needed.  */
#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
int fnord () __attribute__((visibility("default")));
#endif

int fnord () { return 42; }
int main ()
{
  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
  int status = $lt_dlunknown;

  if (self)
    {
      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
      else
        {
	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
          else puts (dlerror ());
	}
      /* dlclose (self); */
    }
  else
    puts (dlerror ());

  return status;
}
_LT_EOF
  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
    (./conftest; exit; ) >&5 2>/dev/null
    lt_status=$?
    case x$lt_status in
      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
      x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
    esac
  else :
    # compilation failed
    lt_cv_dlopen_self_static=no
  fi
fi
rm -fr conftest*


fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
$as_echo "$lt_cv_dlopen_self_static" >&6; }
    fi

    CPPFLAGS="$save_CPPFLAGS"
    LDFLAGS="$save_LDFLAGS"
    LIBS="$save_LIBS"
    ;;
  esac

  case $lt_cv_dlopen_self in
  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
  *) enable_dlopen_self=unknown ;;
  esac

  case $lt_cv_dlopen_self_static in
  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
  *) enable_dlopen_self_static=unknown ;;
  esac
fi

















striplib=
old_striplib=
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
$as_echo_n "checking whether stripping libraries is possible... " >&6; }
if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
# FIXME - insert some real tests, host_os isn't really good enough
  case $host_os in
  darwin*)
    if test -n "$STRIP" ; then
      striplib="$STRIP -x"
      old_striplib="$STRIP -S"
      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
    else
      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
    fi
    ;;
  *)
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
    ;;
  esac
fi












  # Report which library types will actually be built
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
$as_echo_n "checking if libtool supports shared libraries... " >&6; }
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
$as_echo "$can_build_shared" >&6; }

  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
$as_echo_n "checking whether to build shared libraries... " >&6; }
  test "$can_build_shared" = "no" && enable_shared=no

  # On AIX, shared libraries and static libraries use the same namespace, and
  # are all built from PIC.
  case $host_os in
  aix3*)
    test "$enable_shared" = yes && enable_static=no
    if test -n "$RANLIB"; then
      archive_cmds="$archive_cmds~\$RANLIB \$lib"
      postinstall_cmds='$RANLIB $lib'
    fi
    ;;

  aix[4-9]*)
    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
      test "$enable_shared" = yes && enable_static=no
    fi
    ;;
  esac
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
$as_echo "$enable_shared" >&6; }

  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
$as_echo_n "checking whether to build static libraries... " >&6; }
  # Make sure either enable_shared or enable_static is yes.
  test "$enable_shared" = yes || enable_static=yes
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
$as_echo "$enable_static" >&6; }




fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

CC="$lt_save_CC"















        ac_config_commands="$ac_config_commands libtool"




# Only expand once:


   case $ac_cv_prog_cc_stdc in #(
  no) :
    ac_cv_prog_cc_c99=no; ac_cv_prog_cc_c89=no ;; #(
  *) :
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5
$as_echo_n "checking for $CC option to accept ISO C99... " >&6; }
if ${ac_cv_prog_cc_c99+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_cv_prog_cc_c99=no
ac_save_CC=$CC
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 
#include 
#include 
#include 
#include 

// Check varargs macros.  These examples are taken from C99 6.10.3.5.
#define debug(...) fprintf (stderr, __VA_ARGS__)
#define showlist(...) puts (#__VA_ARGS__)
#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
static void
test_varargs_macros (void)
{
  int x = 1234;
  int y = 5678;
  debug ("Flag");
  debug ("X = %d\n", x);
  showlist (The first, second, and third items.);
  report (x>y, "x is %d but y is %d", x, y);
}

// Check long long types.
#define BIG64 18446744073709551615ull
#define BIG32 4294967295ul
#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
#if !BIG_OK
  your preprocessor is broken;
#endif
#if BIG_OK
#else
  your preprocessor is broken;
#endif
static long long int bignum = -9223372036854775807LL;
static unsigned long long int ubignum = BIG64;

struct incomplete_array
{
  int datasize;
  double data[];
};

struct named_init {
  int number;
  const wchar_t *name;
  double average;
};

typedef const char *ccp;

static inline int
test_restrict (ccp restrict text)
{
  // See if C++-style comments work.
  // Iterate through items via the restricted pointer.
  // Also check for declarations in for loops.
  for (unsigned int i = 0; *(text+i) != '\0'; ++i)
    continue;
  return 0;
}

// Check varargs and va_copy.
static void
test_varargs (const char *format, ...)
{
  va_list args;
  va_start (args, format);
  va_list args_copy;
  va_copy (args_copy, args);

  const char *str;
  int number;
  float fnumber;

  while (*format)
    {
      switch (*format++)
	{
	case 's': // string
	  str = va_arg (args_copy, const char *);
	  break;
	case 'd': // int
	  number = va_arg (args_copy, int);
	  break;
	case 'f': // float
	  fnumber = va_arg (args_copy, double);
	  break;
	default:
	  break;
	}
    }
  va_end (args_copy);
  va_end (args);
}

int
main ()
{

  // Check bool.
  _Bool success = false;

  // Check restrict.
  if (test_restrict ("String literal") == 0)
    success = true;
  char *restrict newvar = "Another string";

  // Check varargs.
  test_varargs ("s, d' f .", "string", 65, 34.234);
  test_varargs_macros ();

  // Check flexible array members.
  struct incomplete_array *ia =
    malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
  ia->datasize = 10;
  for (int i = 0; i < ia->datasize; ++i)
    ia->data[i] = i * 1.234;

  // Check named initializers.
  struct named_init ni = {
    .number = 34,
    .name = L"Test wide string",
    .average = 543.34343,
  };

  ni.number = 58;

  int dynamic_array[ni.number];
  dynamic_array[ni.number - 1] = 543;

  // work around unused variable warnings
  return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
	  || dynamic_array[ni.number - 1] != 543);

  ;
  return 0;
}
_ACEOF
for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99
do
  CC="$ac_save_CC $ac_arg"
  if ac_fn_c_try_compile "$LINENO"; then :
  ac_cv_prog_cc_c99=$ac_arg
fi
rm -f core conftest.err conftest.$ac_objext
  test "x$ac_cv_prog_cc_c99" != "xno" && break
done
rm -f conftest.$ac_ext
CC=$ac_save_CC

fi
# AC_CACHE_VAL
case "x$ac_cv_prog_cc_c99" in
  x)
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
$as_echo "none needed" >&6; } ;;
  xno)
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
$as_echo "unsupported" >&6; } ;;
  *)
    CC="$CC $ac_cv_prog_cc_c99"
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
$as_echo "$ac_cv_prog_cc_c99" >&6; } ;;
esac
if test "x$ac_cv_prog_cc_c99" != xno; then :
  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
if ${ac_cv_prog_cc_c89+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_cv_prog_cc_c89=no
ac_save_CC=$CC
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 
#include 
struct stat;
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
static char *e (p, i)
     char **p;
     int i;
{
  return p[i];
}
static char *f (char * (*g) (char **, int), char **p, ...)
{
  char *s;
  va_list v;
  va_start (v,p);
  s = g (p, va_arg (v,int));
  va_end (v);
  return s;
}

/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
   function prototypes and stuff, but not '\xHH' hex character constants.
   These don't provoke an error unfortunately, instead are silently treated
   as 'x'.  The following induces an error, until -std is added to get
   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
   array size at least.  It's necessary to write '\x00'==0 to get something
   that's true only with -std.  */
int osf4_cc_array ['\x00' == 0 ? 1 : -1];

/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
   inside strings and character constants.  */
#define FOO(x) 'x'
int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];

int test (int i, double x);
struct s1 {int (*f) (int a);};
struct s2 {int (*f) (double a);};
int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
int argc;
char **argv;
int
main ()
{
return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
  ;
  return 0;
}
_ACEOF
for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
do
  CC="$ac_save_CC $ac_arg"
  if ac_fn_c_try_compile "$LINENO"; then :
  ac_cv_prog_cc_c89=$ac_arg
fi
rm -f core conftest.err conftest.$ac_objext
  test "x$ac_cv_prog_cc_c89" != "xno" && break
done
rm -f conftest.$ac_ext
CC=$ac_save_CC

fi
# AC_CACHE_VAL
case "x$ac_cv_prog_cc_c89" in
  x)
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
$as_echo "none needed" >&6; } ;;
  xno)
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
$as_echo "unsupported" >&6; } ;;
  *)
    CC="$CC $ac_cv_prog_cc_c89"
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
esac
if test "x$ac_cv_prog_cc_c89" != xno; then :
  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89
else
  ac_cv_prog_cc_stdc=no
fi

fi
 ;;
esac
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO Standard C" >&5
$as_echo_n "checking for $CC option to accept ISO Standard C... " >&6; }
  if ${ac_cv_prog_cc_stdc+:} false; then :
  $as_echo_n "(cached) " >&6
fi

  case $ac_cv_prog_cc_stdc in #(
  no) :
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
$as_echo "unsupported" >&6; } ;; #(
  '') :
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
$as_echo "none needed" >&6; } ;; #(
  *) :
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_stdc" >&5
$as_echo "$ac_cv_prog_cc_stdc" >&6; } ;;
esac



ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy"
if test "x$ac_cv_func_strlcpy" = xyes; then :
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strlcpy" >&5
$as_echo_n "checking for library containing strlcpy... " >&6; }
if ${ac_cv_search_strlcpy+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char strlcpy ();
int
main ()
{
return strlcpy ();
  ;
  return 0;
}
_ACEOF
for ac_lib in '' ; do
  if test -z "$ac_lib"; then
    ac_res="none required"
  else
    ac_res=-l$ac_lib
    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
  fi
  if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_search_strlcpy=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext
  if ${ac_cv_search_strlcpy+:} false; then :
  break
fi
done
if ${ac_cv_search_strlcpy+:} false; then :

else
  ac_cv_search_strlcpy=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_strlcpy" >&5
$as_echo "$ac_cv_search_strlcpy" >&6; }
ac_res=$ac_cv_search_strlcpy
if test "$ac_res" != no; then :
  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
  NO_STRLCPY=
else
  NO_STRLCPY=yes
fi

else
  NO_STRLCPY=yes
fi


 if test "x$NO_STRLCPY" = "xyes"; then
  NO_STRLCPY_TRUE=
  NO_STRLCPY_FALSE='#'
else
  NO_STRLCPY_TRUE='#'
  NO_STRLCPY_FALSE=
fi


ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat"
if test "x$ac_cv_func_strlcat" = xyes; then :
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strlcat" >&5
$as_echo_n "checking for library containing strlcat... " >&6; }
if ${ac_cv_search_strlcat+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char strlcat ();
int
main ()
{
return strlcat ();
  ;
  return 0;
}
_ACEOF
for ac_lib in '' ; do
  if test -z "$ac_lib"; then
    ac_res="none required"
  else
    ac_res=-l$ac_lib
    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
  fi
  if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_search_strlcat=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext
  if ${ac_cv_search_strlcat+:} false; then :
  break
fi
done
if ${ac_cv_search_strlcat+:} false; then :

else
  ac_cv_search_strlcat=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_strlcat" >&5
$as_echo "$ac_cv_search_strlcat" >&6; }
ac_res=$ac_cv_search_strlcat
if test "$ac_res" != no; then :
  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
  NO_STRLCAT=
else
  NO_STRLCAT=yes
fi

else
  NO_STRLCAT=yes
fi


 if test "x$NO_STRLCAT" = "xyes"; then
  NO_STRLCAT_TRUE=
  NO_STRLCAT_FALSE='#'
else
  NO_STRLCAT_TRUE='#'
  NO_STRLCAT_FALSE=
fi


ac_fn_c_check_func "$LINENO" "reallocarray" "ac_cv_func_reallocarray"
if test "x$ac_cv_func_reallocarray" = xyes; then :
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing reallocarray" >&5
$as_echo_n "checking for library containing reallocarray... " >&6; }
if ${ac_cv_search_reallocarray+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char reallocarray ();
int
main ()
{
return reallocarray ();
  ;
  return 0;
}
_ACEOF
for ac_lib in '' ; do
  if test -z "$ac_lib"; then
    ac_res="none required"
  else
    ac_res=-l$ac_lib
    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
  fi
  if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_search_reallocarray=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext
  if ${ac_cv_search_reallocarray+:} false; then :
  break
fi
done
if ${ac_cv_search_reallocarray+:} false; then :

else
  ac_cv_search_reallocarray=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_reallocarray" >&5
$as_echo "$ac_cv_search_reallocarray" >&6; }
ac_res=$ac_cv_search_reallocarray
if test "$ac_res" != no; then :
  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
  NO_REALLOCARRAY=
else
  NO_REALLOCARRAY=yes
fi

else
  NO_REALLOCARRAY=yes
fi


 if test "x$NO_REALLOCARRAY" = "xyes"; then
  NO_REALLOCARRAY_TRUE=
  NO_REALLOCARRAY_FALSE='#'
else
  NO_REALLOCARRAY_TRUE='#'
  NO_REALLOCARRAY_FALSE=
fi


ac_fn_c_check_func "$LINENO" "timingsafe_bcmp" "ac_cv_func_timingsafe_bcmp"
if test "x$ac_cv_func_timingsafe_bcmp" = xyes; then :
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing timingsafe_bcmp" >&5
$as_echo_n "checking for library containing timingsafe_bcmp... " >&6; }
if ${ac_cv_search_timingsafe_bcmp+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char timingsafe_bcmp ();
int
main ()
{
return timingsafe_bcmp ();
  ;
  return 0;
}
_ACEOF
for ac_lib in '' ; do
  if test -z "$ac_lib"; then
    ac_res="none required"
  else
    ac_res=-l$ac_lib
    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
  fi
  if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_search_timingsafe_bcmp=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext
  if ${ac_cv_search_timingsafe_bcmp+:} false; then :
  break
fi
done
if ${ac_cv_search_timingsafe_bcmp+:} false; then :

else
  ac_cv_search_timingsafe_bcmp=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_timingsafe_bcmp" >&5
$as_echo "$ac_cv_search_timingsafe_bcmp" >&6; }
ac_res=$ac_cv_search_timingsafe_bcmp
if test "$ac_res" != no; then :
  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
  NO_TIMINGSAFE_BCMP=
else
  NO_TIMINGSAFE_BCMP=yes
fi

else
  NO_TIMINGSAFE_BCMP=yes
fi


 if test "x$NO_TIMINGSAFE_BCMP" = "xyes"; then
  NO_TIMINGSAFE_BCMP_TRUE=
  NO_TIMINGSAFE_BCMP_FALSE='#'
else
  NO_TIMINGSAFE_BCMP_TRUE='#'
  NO_TIMINGSAFE_BCMP_FALSE=
fi


ac_fn_c_check_func "$LINENO" "timingsafe_memcmp" "ac_cv_func_timingsafe_memcmp"
if test "x$ac_cv_func_timingsafe_memcmp" = xyes; then :
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing timingsafe_memcmp" >&5
$as_echo_n "checking for library containing timingsafe_memcmp... " >&6; }
if ${ac_cv_search_timingsafe_memcmp+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char timingsafe_memcmp ();
int
main ()
{
return timingsafe_memcmp ();
  ;
  return 0;
}
_ACEOF
for ac_lib in '' ; do
  if test -z "$ac_lib"; then
    ac_res="none required"
  else
    ac_res=-l$ac_lib
    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
  fi
  if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_search_timingsafe_memcmp=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext
  if ${ac_cv_search_timingsafe_memcmp+:} false; then :
  break
fi
done
if ${ac_cv_search_timingsafe_memcmp+:} false; then :

else
  ac_cv_search_timingsafe_memcmp=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_timingsafe_memcmp" >&5
$as_echo "$ac_cv_search_timingsafe_memcmp" >&6; }
ac_res=$ac_cv_search_timingsafe_memcmp
if test "$ac_res" != no; then :
  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
  NO_TIMINGSAFE_MEMCMP=
else
  NO_TIMINGSAFE_MEMCMP=yes
fi

else
  NO_TIMINGSAFE_MEMCMP=yes
fi


 if test "x$NO_TIMINGSAFE_MEMCMP" = "xyes"; then
  NO_TIMINGSAFE_MEMCMP_TRUE=
  NO_TIMINGSAFE_MEMCMP_FALSE='#'
else
  NO_TIMINGSAFE_MEMCMP_TRUE='#'
  NO_TIMINGSAFE_MEMCMP_FALSE=
fi


ac_fn_c_check_func "$LINENO" "arc4random_buf" "ac_cv_func_arc4random_buf"
if test "x$ac_cv_func_arc4random_buf" = xyes; then :
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing write" >&5
$as_echo_n "checking for library containing write... " >&6; }
if ${ac_cv_search_write+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char write ();
int
main ()
{
return write ();
  ;
  return 0;
}
_ACEOF
for ac_lib in '' ; do
  if test -z "$ac_lib"; then
    ac_res="none required"
  else
    ac_res=-l$ac_lib
    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
  fi
  if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_search_write=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext
  if ${ac_cv_search_write+:} false; then :
  break
fi
done
if ${ac_cv_search_write+:} false; then :

else
  ac_cv_search_write=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_write" >&5
$as_echo "$ac_cv_search_write" >&6; }
ac_res=$ac_cv_search_write
if test "$ac_res" != no; then :
  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
  NO_ARC4RANDOM_BUF=
else
  NO_ARC4RANDOM_BUF=yes
fi

else
  NO_ARC4RANDOM_BUF=yes
fi


 if test "x$NO_ARC4RANDOM_BUF" = "xyes"; then
  NO_ARC4RANDOM_BUF_TRUE=
  NO_ARC4RANDOM_BUF_FALSE='#'
else
  NO_ARC4RANDOM_BUF_TRUE='#'
  NO_ARC4RANDOM_BUF_FALSE=
fi


# overrides for arc4random_buf implementations with known issues
 if test x$TARGET_OS = xdarwin \
     -o x$TARGET_OS = xsolaris \
	 -o x$NO_ARC4RANDOM_BUF = xyes; then
  NO_ARC4RANDOM_BUF_TRUE=
  NO_ARC4RANDOM_BUF_FALSE='#'
else
  NO_ARC4RANDOM_BUF_TRUE='#'
  NO_ARC4RANDOM_BUF_FALSE=
fi


ac_fn_c_check_func "$LINENO" "getentropy" "ac_cv_func_getentropy"
if test "x$ac_cv_func_getentropy" = xyes; then :
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing write" >&5
$as_echo_n "checking for library containing write... " >&6; }
if ${ac_cv_search_write+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char write ();
int
main ()
{
return write ();
  ;
  return 0;
}
_ACEOF
for ac_lib in '' ; do
  if test -z "$ac_lib"; then
    ac_res="none required"
  else
    ac_res=-l$ac_lib
    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
  fi
  if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_search_write=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext
  if ${ac_cv_search_write+:} false; then :
  break
fi
done
if ${ac_cv_search_write+:} false; then :

else
  ac_cv_search_write=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_write" >&5
$as_echo "$ac_cv_search_write" >&6; }
ac_res=$ac_cv_search_write
if test "$ac_res" != no; then :
  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
  NO_GETENTROPY=
else
  NO_GETENTROPY=yes
fi

else
  NO_GETENTROPY=yes
fi


 if test "x$NO_GETENTROPY" = "xyes"; then
  NO_GETENTROPY_TRUE=
  NO_GETENTROPY_FALSE='#'
else
  NO_GETENTROPY_TRUE='#'
  NO_GETENTROPY_FALSE=
fi


ac_fn_c_check_func "$LINENO" "issetugid" "ac_cv_func_issetugid"
if test "x$ac_cv_func_issetugid" = xyes; then :
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing write" >&5
$as_echo_n "checking for library containing write... " >&6; }
if ${ac_cv_search_write+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char write ();
int
main ()
{
return write ();
  ;
  return 0;
}
_ACEOF
for ac_lib in '' ; do
  if test -z "$ac_lib"; then
    ac_res="none required"
  else
    ac_res=-l$ac_lib
    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
  fi
  if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_search_write=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext
  if ${ac_cv_search_write+:} false; then :
  break
fi
done
if ${ac_cv_search_write+:} false; then :

else
  ac_cv_search_write=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_write" >&5
$as_echo "$ac_cv_search_write" >&6; }
ac_res=$ac_cv_search_write
if test "$ac_res" != no; then :
  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
  NO_ISSETUGID=
else
  NO_ISSETUGID=yes
fi

else
  NO_ISSETUGID=yes
fi


 if test "x$NO_ISSETUGID" = "xyes"; then
  NO_ISSETUGID_TRUE=
  NO_ISSETUGID_FALSE='#'
else
  NO_ISSETUGID_TRUE='#'
  NO_ISSETUGID_FALSE=
fi


ac_fn_c_check_func "$LINENO" "strtonum" "ac_cv_func_strtonum"
if test "x$ac_cv_func_strtonum" = xyes; then :
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing write" >&5
$as_echo_n "checking for library containing write... " >&6; }
if ${ac_cv_search_write+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char write ();
int
main ()
{
return write ();
  ;
  return 0;
}
_ACEOF
for ac_lib in '' ; do
  if test -z "$ac_lib"; then
    ac_res="none required"
  else
    ac_res=-l$ac_lib
    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
  fi
  if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_search_write=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext
  if ${ac_cv_search_write+:} false; then :
  break
fi
done
if ${ac_cv_search_write+:} false; then :

else
  ac_cv_search_write=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_write" >&5
$as_echo "$ac_cv_search_write" >&6; }
ac_res=$ac_cv_search_write
if test "$ac_res" != no; then :
  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
  NO_STRTONUM=
else
  NO_STRTONUM=yes
fi

else
  NO_STRTONUM=yes
fi


 if test "x$NO_STRTONUM" = "xyes"; then
  NO_STRTONUM_TRUE=
  NO_STRTONUM_FALSE='#'
else
  NO_STRTONUM_TRUE='#'
  NO_STRTONUM_FALSE=
fi


ac_fn_c_check_func "$LINENO" "getauxval" "ac_cv_func_getauxval"
if test "x$ac_cv_func_getauxval" = xyes; then :
  $as_echo "#define HAVE_GETAUXVAL 1" >>confdefs.h

fi


ac_fn_c_check_func "$LINENO" "funopen" "ac_cv_func_funopen"
if test "x$ac_cv_func_funopen" = xyes; then :
  $as_echo "#define HAVE_FUNOPEN 1" >>confdefs.h

fi




ac_config_files="$ac_config_files Makefile include/Makefile include/openssl/Makefile ssl/Makefile crypto/Makefile tests/Makefile apps/Makefile man/Makefile"

cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs, see configure's option --config-cache.
# It is not useful on other systems.  If it contains results you don't
# want to keep, you may remove or edit it.
#
# config.status only pays attention to the cache file if you give it
# the --recheck option to rerun configure.
#
# `ac_cv_env_foo' variables (set or unset) will be overridden when
# loading this file, other *unset* `ac_cv_foo' will be assigned the
# following values.

_ACEOF

# The following way of writing the cache mishandles newlines in values,
# but we know of no workaround that is simple, portable, and efficient.
# So, we kill variables containing newlines.
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
(
  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
    eval ac_val=\$$ac_var
    case $ac_val in #(
    *${as_nl}*)
      case $ac_var in #(
      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
      esac
      case $ac_var in #(
      _ | IFS | as_nl) ;; #(
      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
      *) { eval $ac_var=; unset $ac_var;} ;;
      esac ;;
    esac
  done

  (set) 2>&1 |
    case $as_nl`(ac_space=' '; set) 2>&1` in #(
    *${as_nl}ac_space=\ *)
      # `set' does not quote correctly, so add quotes: double-quote
      # substitution turns \\\\ into \\, and sed turns \\ into \.
      sed -n \
	"s/'/'\\\\''/g;
	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
      ;; #(
    *)
      # `set' quotes correctly as required by POSIX, so do not add quotes.
      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
      ;;
    esac |
    sort
) |
  sed '
     /^ac_cv_env_/b end
     t clear
     :clear
     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
     t end
     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
     :end' >>confcache
if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
  if test -w "$cache_file"; then
    if test "x$cache_file" != "x/dev/null"; then
      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
$as_echo "$as_me: updating cache $cache_file" >&6;}
      if test ! -f "$cache_file" || test -h "$cache_file"; then
	cat confcache >"$cache_file"
      else
        case $cache_file in #(
        */* | ?:*)
	  mv -f confcache "$cache_file"$$ &&
	  mv -f "$cache_file"$$ "$cache_file" ;; #(
        *)
	  mv -f confcache "$cache_file" ;;
	esac
      fi
    fi
  else
    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
  fi
fi
rm -f confcache

test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'

# Transform confdefs.h into DEFS.
# Protect against shell expansion while executing Makefile rules.
# Protect against Makefile macro expansion.
#
# If the first sed substitution is executed (which looks for macros that
# take arguments), then branch to the quote section.  Otherwise,
# look for a macro that doesn't take arguments.
ac_script='
:mline
/\\$/{
 N
 s,\\\n,,
 b mline
}
t clear
:clear
s/^[	 ]*#[	 ]*define[	 ][	 ]*\([^	 (][^	 (]*([^)]*)\)[	 ]*\(.*\)/-D\1=\2/g
t quote
s/^[	 ]*#[	 ]*define[	 ][	 ]*\([^	 ][^	 ]*\)[	 ]*\(.*\)/-D\1=\2/g
t quote
b any
:quote
s/[	 `~#$^&*(){}\\|;'\''"<>?]/\\&/g
s/\[/\\&/g
s/\]/\\&/g
s/\$/$$/g
H
:any
${
	g
	s/^\n//
	s/\n/ /g
	p
}
'
DEFS=`sed -n "$ac_script" confdefs.h`


ac_libobjs=
ac_ltlibobjs=
U=
for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
  # 1. Remove the extension, and $U if already installed.
  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
  #    will be set to the directory where LIBOBJS objects are built.
  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
done
LIBOBJS=$ac_libobjs

LTLIBOBJS=$ac_ltlibobjs


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5
$as_echo_n "checking that generated files are newer than configure... " >&6; }
   if test -n "$am_sleep_pid"; then
     # Hide warnings about reused PIDs.
     wait $am_sleep_pid 2>/dev/null
   fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5
$as_echo "done" >&6; }
 if test -n "$EXEEXT"; then
  am__EXEEXT_TRUE=
  am__EXEEXT_FALSE='#'
else
  am__EXEEXT_TRUE='#'
  am__EXEEXT_FALSE=
fi

if test -z "${TARGET_DARWIN_TRUE}" && test -z "${TARGET_DARWIN_FALSE}"; then
  as_fn_error $? "conditional \"TARGET_DARWIN\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${TARGET_LINUX_TRUE}" && test -z "${TARGET_LINUX_FALSE}"; then
  as_fn_error $? "conditional \"TARGET_LINUX\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${TARGET_SOLARIS_TRUE}" && test -z "${TARGET_SOLARIS_FALSE}"; then
  as_fn_error $? "conditional \"TARGET_SOLARIS\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${TARGET_NACL_TRUE}" && test -z "${TARGET_NACL_FALSE}"; then
  as_fn_error $? "conditional \"TARGET_NACL\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
  as_fn_error $? "conditional \"AMDEP\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
  as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${NO_STRLCPY_TRUE}" && test -z "${NO_STRLCPY_FALSE}"; then
  as_fn_error $? "conditional \"NO_STRLCPY\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${NO_STRLCAT_TRUE}" && test -z "${NO_STRLCAT_FALSE}"; then
  as_fn_error $? "conditional \"NO_STRLCAT\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${NO_REALLOCARRAY_TRUE}" && test -z "${NO_REALLOCARRAY_FALSE}"; then
  as_fn_error $? "conditional \"NO_REALLOCARRAY\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${NO_TIMINGSAFE_BCMP_TRUE}" && test -z "${NO_TIMINGSAFE_BCMP_FALSE}"; then
  as_fn_error $? "conditional \"NO_TIMINGSAFE_BCMP\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${NO_TIMINGSAFE_MEMCMP_TRUE}" && test -z "${NO_TIMINGSAFE_MEMCMP_FALSE}"; then
  as_fn_error $? "conditional \"NO_TIMINGSAFE_MEMCMP\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${NO_ARC4RANDOM_BUF_TRUE}" && test -z "${NO_ARC4RANDOM_BUF_FALSE}"; then
  as_fn_error $? "conditional \"NO_ARC4RANDOM_BUF\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${NO_ARC4RANDOM_BUF_TRUE}" && test -z "${NO_ARC4RANDOM_BUF_FALSE}"; then
  as_fn_error $? "conditional \"NO_ARC4RANDOM_BUF\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${NO_GETENTROPY_TRUE}" && test -z "${NO_GETENTROPY_FALSE}"; then
  as_fn_error $? "conditional \"NO_GETENTROPY\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${NO_ISSETUGID_TRUE}" && test -z "${NO_ISSETUGID_FALSE}"; then
  as_fn_error $? "conditional \"NO_ISSETUGID\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${NO_STRTONUM_TRUE}" && test -z "${NO_STRTONUM_FALSE}"; then
  as_fn_error $? "conditional \"NO_STRTONUM\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi

: "${CONFIG_STATUS=./config.status}"
ac_write_fail=0
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
as_write_fail=0
cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
#! $SHELL
# Generated by $as_me.
# Run this file to recreate the current configuration.
# Compiler output produced by configure, useful for debugging
# configure, is in config.log if it exists.

debug=false
ac_cs_recheck=false
ac_cs_silent=false

SHELL=\${CONFIG_SHELL-$SHELL}
export SHELL
_ASEOF
cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
## -------------------- ##
## M4sh Initialization. ##
## -------------------- ##

# Be more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
  emulate sh
  NULLCMD=:
  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
  # is contrary to our usage.  Disable this feature.
  alias -g '${1+"$@"}'='"$@"'
  setopt NO_GLOB_SUBST
else
  case `(set -o) 2>/dev/null` in #(
  *posix*) :
    set -o posix ;; #(
  *) :
     ;;
esac
fi


as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
# Prefer a ksh shell builtin over an external printf program on Solaris,
# but without wasting forks for bash or zsh.
if test -z "$BASH_VERSION$ZSH_VERSION" \
    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
  as_echo='print -r --'
  as_echo_n='print -rn --'
elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
  as_echo='printf %s\n'
  as_echo_n='printf %s'
else
  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
    as_echo_n='/usr/ucb/echo -n'
  else
    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
    as_echo_n_body='eval
      arg=$1;
      case $arg in #(
      *"$as_nl"*)
	expr "X$arg" : "X\\(.*\\)$as_nl";
	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
      esac;
      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
    '
    export as_echo_n_body
    as_echo_n='sh -c $as_echo_n_body as_echo'
  fi
  export as_echo_body
  as_echo='sh -c $as_echo_body as_echo'
fi

# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
  PATH_SEPARATOR=:
  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
      PATH_SEPARATOR=';'
  }
fi


# IFS
# We need space, tab and new line, in precisely that order.  Quoting is
# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
IFS=" ""	$as_nl"

# Find who we are.  Look in the path if we contain no directory separator.
as_myself=
case $0 in #((
  *[\\/]* ) as_myself=$0 ;;
  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
  done
IFS=$as_save_IFS

     ;;
esac
# We did not find ourselves, most probably we were run as `sh COMMAND'
# in which case we are not to be found in the path.
if test "x$as_myself" = x; then
  as_myself=$0
fi
if test ! -f "$as_myself"; then
  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
  exit 1
fi

# Unset variables that we do not need and which cause bugs (e.g. in
# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
# suppresses any "Segmentation fault" message there.  '((' could
# trigger a bug in pdksh 5.2.14.
for as_var in BASH_ENV ENV MAIL MAILPATH
do eval test x\${$as_var+set} = xset \
  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
done
PS1='$ '
PS2='> '
PS4='+ '

# NLS nuisances.
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE

# CDPATH.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH


# as_fn_error STATUS ERROR [LINENO LOG_FD]
# ----------------------------------------
# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
# script with STATUS, using 1 if that was 0.
as_fn_error ()
{
  as_status=$1; test $as_status -eq 0 && as_status=1
  if test "$4"; then
    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
  fi
  $as_echo "$as_me: error: $2" >&2
  as_fn_exit $as_status
} # as_fn_error


# as_fn_set_status STATUS
# -----------------------
# Set $? to STATUS, without forking.
as_fn_set_status ()
{
  return $1
} # as_fn_set_status

# as_fn_exit STATUS
# -----------------
# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
as_fn_exit ()
{
  set +e
  as_fn_set_status $1
  exit $1
} # as_fn_exit

# as_fn_unset VAR
# ---------------
# Portably unset VAR.
as_fn_unset ()
{
  { eval $1=; unset $1;}
}
as_unset=as_fn_unset
# as_fn_append VAR VALUE
# ----------------------
# Append the text in VALUE to the end of the definition contained in VAR. Take
# advantage of any shell optimizations that allow amortized linear growth over
# repeated appends, instead of the typical quadratic growth present in naive
# implementations.
if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
  eval 'as_fn_append ()
  {
    eval $1+=\$2
  }'
else
  as_fn_append ()
  {
    eval $1=\$$1\$2
  }
fi # as_fn_append

# as_fn_arith ARG...
# ------------------
# Perform arithmetic evaluation on the ARGs, and store the result in the
# global $as_val. Take advantage of shells that can avoid forks. The arguments
# must be portable across $(()) and expr.
if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
  eval 'as_fn_arith ()
  {
    as_val=$(( $* ))
  }'
else
  as_fn_arith ()
  {
    as_val=`expr "$@" || test $? -eq 1`
  }
fi # as_fn_arith


if expr a : '\(a\)' >/dev/null 2>&1 &&
   test "X`expr 00001 : '.*\(...\)'`" = X001; then
  as_expr=expr
else
  as_expr=false
fi

if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
  as_basename=basename
else
  as_basename=false
fi

if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
  as_dirname=dirname
else
  as_dirname=false
fi

as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
	 X"$0" : 'X\(//\)$' \| \
	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X/"$0" |
    sed '/^.*\/\([^/][^/]*\)\/*$/{
	    s//\1/
	    q
	  }
	  /^X\/\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\/\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`

# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits

ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in #(((((
-n*)
  case `echo 'xy\c'` in
  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
  xy)  ECHO_C='\c';;
  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
       ECHO_T='	';;
  esac;;
*)
  ECHO_N='-n';;
esac

rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
  rm -f conf$$.dir/conf$$.file
else
  rm -f conf$$.dir
  mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
  if ln -s conf$$.file conf$$ 2>/dev/null; then
    as_ln_s='ln -s'
    # ... but there are two gotchas:
    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
    # In both cases, we have to default to `cp -pR'.
    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
      as_ln_s='cp -pR'
  elif ln conf$$.file conf$$ 2>/dev/null; then
    as_ln_s=ln
  else
    as_ln_s='cp -pR'
  fi
else
  as_ln_s='cp -pR'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null


# as_fn_mkdir_p
# -------------
# Create "$as_dir" as a directory, including parents if necessary.
as_fn_mkdir_p ()
{

  case $as_dir in #(
  -*) as_dir=./$as_dir;;
  esac
  test -d "$as_dir" || eval $as_mkdir_p || {
    as_dirs=
    while :; do
      case $as_dir in #(
      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
      *) as_qdir=$as_dir;;
      esac
      as_dirs="'$as_qdir' $as_dirs"
      as_dir=`$as_dirname -- "$as_dir" ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
	 X"$as_dir" : 'X\(//\)[^/]' \| \
	 X"$as_dir" : 'X\(//\)$' \| \
	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_dir" |
    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)[^/].*/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`
      test -d "$as_dir" && break
    done
    test -z "$as_dirs" || eval "mkdir $as_dirs"
  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"


} # as_fn_mkdir_p
if mkdir -p . 2>/dev/null; then
  as_mkdir_p='mkdir -p "$as_dir"'
else
  test -d ./-p && rmdir ./-p
  as_mkdir_p=false
fi


# as_fn_executable_p FILE
# -----------------------
# Test if FILE is an executable regular file.
as_fn_executable_p ()
{
  test -f "$1" && test -x "$1"
} # as_fn_executable_p
as_test_x='test -x'
as_executable_p=as_fn_executable_p

# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"

# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"


exec 6>&1
## ----------------------------------- ##
## Main body of $CONFIG_STATUS script. ##
## ----------------------------------- ##
_ASEOF
test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1

cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# Save the log message, to keep $0 and so on meaningful, and to
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by libressl $as_me 2.0.0, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  CONFIG_FILES    = $CONFIG_FILES
  CONFIG_HEADERS  = $CONFIG_HEADERS
  CONFIG_LINKS    = $CONFIG_LINKS
  CONFIG_COMMANDS = $CONFIG_COMMANDS
  $ $0 $@

on `(hostname || uname -n) 2>/dev/null | sed 1q`
"

_ACEOF

case $ac_config_files in *"
"*) set x $ac_config_files; shift; ac_config_files=$*;;
esac



cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
# Files that config.status was made for.
config_files="$ac_config_files"
config_commands="$ac_config_commands"

_ACEOF

cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
ac_cs_usage="\
\`$as_me' instantiates files and other configuration actions
from templates according to the current configuration.  Unless the files
and actions are specified as TAGs, all are instantiated by default.

Usage: $0 [OPTION]... [TAG]...

  -h, --help       print this help, then exit
  -V, --version    print version number and configuration settings, then exit
      --config     print configuration, then exit
  -q, --quiet, --silent
                   do not print progress messages
  -d, --debug      don't remove temporary files
      --recheck    update $as_me by reconfiguring in the same conditions
      --file=FILE[:TEMPLATE]
                   instantiate the configuration file FILE

Configuration files:
$config_files

Configuration commands:
$config_commands

Report bugs to the package provider."

_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
libressl config.status 2.0.0
configured by $0, generated by GNU Autoconf 2.69,
  with options \\"\$ac_cs_config\\"

Copyright (C) 2012 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."

ac_pwd='$ac_pwd'
srcdir='$srcdir'
INSTALL='$INSTALL'
MKDIR_P='$MKDIR_P'
AWK='$AWK'
test -n "\$AWK" || AWK=awk
_ACEOF

cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# The default lists apply if the user does not specify any file.
ac_need_defaults=:
while test $# != 0
do
  case $1 in
  --*=?*)
    ac_option=`expr "X$1" : 'X\([^=]*\)='`
    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
    ac_shift=:
    ;;
  --*=)
    ac_option=`expr "X$1" : 'X\([^=]*\)='`
    ac_optarg=
    ac_shift=:
    ;;
  *)
    ac_option=$1
    ac_optarg=$2
    ac_shift=shift
    ;;
  esac

  case $ac_option in
  # Handling of the options.
  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
    ac_cs_recheck=: ;;
  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
    $as_echo "$ac_cs_version"; exit ;;
  --config | --confi | --conf | --con | --co | --c )
    $as_echo "$ac_cs_config"; exit ;;
  --debug | --debu | --deb | --de | --d | -d )
    debug=: ;;
  --file | --fil | --fi | --f )
    $ac_shift
    case $ac_optarg in
    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
    '') as_fn_error $? "missing file argument" ;;
    esac
    as_fn_append CONFIG_FILES " '$ac_optarg'"
    ac_need_defaults=false;;
  --he | --h |  --help | --hel | -h )
    $as_echo "$ac_cs_usage"; exit ;;
  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
  | -silent | --silent | --silen | --sile | --sil | --si | --s)
    ac_cs_silent=: ;;

  # This is an error.
  -*) as_fn_error $? "unrecognized option: \`$1'
Try \`$0 --help' for more information." ;;

  *) as_fn_append ac_config_targets " $1"
     ac_need_defaults=false ;;

  esac
  shift
done

ac_configure_extra_args=

if $ac_cs_silent; then
  exec 6>/dev/null
  ac_configure_extra_args="$ac_configure_extra_args --silent"
fi

_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
if \$ac_cs_recheck; then
  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
  shift
  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
  CONFIG_SHELL='$SHELL'
  export CONFIG_SHELL
  exec "\$@"
fi

_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
exec 5>>config.log
{
  echo
  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## Running $as_me. ##
_ASBOX
  $as_echo "$ac_log"
} >&5

_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
#
# INIT-COMMANDS
#
AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"


# The HP-UX ksh and POSIX shell print the target directory to stdout
# if CDPATH is set.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH

sed_quote_subst='$sed_quote_subst'
double_quote_subst='$double_quote_subst'
delay_variable_subst='$delay_variable_subst'
macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`'
macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`'
enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`'
ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`'
PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`'
host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`'
host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`'
host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`'
build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`'
build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`'
build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`'
SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`'
Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`'
GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`'
EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`'
FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`'
LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`'
NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`'
LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`'
max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`'
ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`'
exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`'
lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`'
lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`'
lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`'
lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`'
lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`'
reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`'
reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`'
OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`'
deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`'
file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`'
file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`'
want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`'
DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`'
sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`'
AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`'
AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`'
archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`'
STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`'
RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`'
old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`'
old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`'
lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`'
CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`'
CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`'
compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`'
GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`'
lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`'
lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`'
lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`'
lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`'
nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`'
lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`'
objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`'
MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`'
lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`'
lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`'
lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`'
lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`'
lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`'
need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`'
MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`'
DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`'
NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`'
LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`'
OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`'
OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`'
libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`'
shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`'
extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`'
enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`'
export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`'
whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`'
compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`'
old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`'
old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`'
archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`'
module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`'
module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`'
with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`'
allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`'
no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`'
hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`'
hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`'
hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`'
hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`'
hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`'
hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`'
hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`'
inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`'
link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`'
always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`'
export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`'
exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`'
include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`'
prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`'
postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`'
file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`'
variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`'
need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`'
need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`'
version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`'
runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`'
shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`'
shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`'
libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`'
library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`'
soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`'
install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`'
postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`'
postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`'
finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`'
hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`'
sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`'
sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`'
hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`'
enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`'
enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`'
enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`'
old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`'
striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`'

LTCC='$LTCC'
LTCFLAGS='$LTCFLAGS'
compiler='$compiler_DEFAULT'

# A function that is used when there is no print builtin or printf.
func_fallback_echo ()
{
  eval 'cat <<_LTECHO_EOF
\$1
_LTECHO_EOF'
}

# Quote evaled strings.
for var in SHELL \
ECHO \
PATH_SEPARATOR \
SED \
GREP \
EGREP \
FGREP \
LD \
NM \
LN_S \
lt_SP2NL \
lt_NL2SP \
reload_flag \
OBJDUMP \
deplibs_check_method \
file_magic_cmd \
file_magic_glob \
want_nocaseglob \
DLLTOOL \
sharedlib_from_linklib_cmd \
AR \
AR_FLAGS \
archiver_list_spec \
STRIP \
RANLIB \
CC \
CFLAGS \
compiler \
lt_cv_sys_global_symbol_pipe \
lt_cv_sys_global_symbol_to_cdecl \
lt_cv_sys_global_symbol_to_c_name_address \
lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
nm_file_list_spec \
lt_prog_compiler_no_builtin_flag \
lt_prog_compiler_pic \
lt_prog_compiler_wl \
lt_prog_compiler_static \
lt_cv_prog_compiler_c_o \
need_locks \
MANIFEST_TOOL \
DSYMUTIL \
NMEDIT \
LIPO \
OTOOL \
OTOOL64 \
shrext_cmds \
export_dynamic_flag_spec \
whole_archive_flag_spec \
compiler_needs_object \
with_gnu_ld \
allow_undefined_flag \
no_undefined_flag \
hardcode_libdir_flag_spec \
hardcode_libdir_separator \
exclude_expsyms \
include_expsyms \
file_list_spec \
variables_saved_for_relink \
libname_spec \
library_names_spec \
soname_spec \
install_override_mode \
finish_eval \
old_striplib \
striplib; do
    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
    *[\\\\\\\`\\"\\\$]*)
      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
      ;;
    *)
      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
      ;;
    esac
done

# Double-quote double-evaled strings.
for var in reload_cmds \
old_postinstall_cmds \
old_postuninstall_cmds \
old_archive_cmds \
extract_expsyms_cmds \
old_archive_from_new_cmds \
old_archive_from_expsyms_cmds \
archive_cmds \
archive_expsym_cmds \
module_cmds \
module_expsym_cmds \
export_symbols_cmds \
prelink_cmds \
postlink_cmds \
postinstall_cmds \
postuninstall_cmds \
finish_cmds \
sys_lib_search_path_spec \
sys_lib_dlsearch_path_spec; do
    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
    *[\\\\\\\`\\"\\\$]*)
      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
      ;;
    *)
      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
      ;;
    esac
done

ac_aux_dir='$ac_aux_dir'
xsi_shell='$xsi_shell'
lt_shell_append='$lt_shell_append'

# See if we are running on zsh, and set the options which allow our
# commands through without removal of \ escapes INIT.
if test -n "\${ZSH_VERSION+set}" ; then
   setopt NO_GLOB_SUBST
fi


    PACKAGE='$PACKAGE'
    VERSION='$VERSION'
    TIMESTAMP='$TIMESTAMP'
    RM='$RM'
    ofile='$ofile'




_ACEOF

cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1

# Handling of arguments.
for ac_config_target in $ac_config_targets
do
  case $ac_config_target in
    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
    "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
    "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
    "include/openssl/Makefile") CONFIG_FILES="$CONFIG_FILES include/openssl/Makefile" ;;
    "ssl/Makefile") CONFIG_FILES="$CONFIG_FILES ssl/Makefile" ;;
    "crypto/Makefile") CONFIG_FILES="$CONFIG_FILES crypto/Makefile" ;;
    "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
    "apps/Makefile") CONFIG_FILES="$CONFIG_FILES apps/Makefile" ;;
    "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;;

  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
  esac
done


# If the user did not use the arguments to specify the items to instantiate,
# then the envvar interface is used.  Set only those that are not.
# We use the long form for the default assignment because of an extremely
# bizarre bug on SunOS 4.1.3.
if $ac_need_defaults; then
  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
fi

# Have a temporary directory for convenience.  Make it in the build tree
# simply because there is no reason against having it here, and in addition,
# creating and moving files from /tmp can sometimes cause problems.
# Hook for its removal unless debugging.
# Note that there is a small window in which the directory will not be cleaned:
# after its creation but before its name has been assigned to `$tmp'.
$debug ||
{
  tmp= ac_tmp=
  trap 'exit_status=$?
  : "${ac_tmp:=$tmp}"
  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
' 0
  trap 'as_fn_exit 1' 1 2 13 15
}
# Create a (secure) tmp directory for tmp files.

{
  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
  test -d "$tmp"
}  ||
{
  tmp=./conf$$-$RANDOM
  (umask 077 && mkdir "$tmp")
} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
ac_tmp=$tmp

# Set up the scripts for CONFIG_FILES section.
# No need to generate them if there are no CONFIG_FILES.
# This happens for instance with `./config.status config.h'.
if test -n "$CONFIG_FILES"; then


ac_cr=`echo X | tr X '\015'`
# On cygwin, bash can eat \r inside `` if the user requested igncr.
# But we know of no other shell where ac_cr would be empty at this
# point, so we can use a bashism as a fallback.
if test "x$ac_cr" = x; then
  eval ac_cr=\$\'\\r\'
fi
ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null`
if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
  ac_cs_awk_cr='\\r'
else
  ac_cs_awk_cr=$ac_cr
fi

echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
_ACEOF


{
  echo "cat >conf$$subs.awk <<_ACEOF" &&
  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
  echo "_ACEOF"
} >conf$$subs.sh ||
  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
  . ./conf$$subs.sh ||
    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5

  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
  if test $ac_delim_n = $ac_delim_num; then
    break
  elif $ac_last_try; then
    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
  else
    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
  fi
done
rm -f conf$$subs.sh

cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
_ACEOF
sed -n '
h
s/^/S["/; s/!.*/"]=/
p
g
s/^[^!]*!//
:repl
t repl
s/'"$ac_delim"'$//
t delim
:nl
h
s/\(.\{148\}\)..*/\1/
t more1
s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
p
n
b repl
:more1
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{148\}//
t nl
:delim
h
s/\(.\{148\}\)..*/\1/
t more2
s/["\\]/\\&/g; s/^/"/; s/$/"/
p
b
:more2
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{148\}//
t delim
' >$CONFIG_STATUS || ac_write_fail=1
rm -f conf$$subs.awk
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
_ACAWK
cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
  for (key in S) S_is_set[key] = 1
  FS = ""

}
{
  line = $ 0
  nfields = split(line, field, "@")
  substed = 0
  len = length(field[1])
  for (i = 2; i < nfields; i++) {
    key = field[i]
    keylen = length(key)
    if (S_is_set[key]) {
      value = S[key]
      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
      len += length(value) + length(field[++i])
      substed = 1
    } else
      len += 1 + keylen
  }

  print line
}

_ACAWK
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
else
  cat
fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
_ACEOF

# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
# trailing colons and then remove the whole line if VPATH becomes empty
# (actually we leave an empty line to preserve line numbers).
if test "x$srcdir" = x.; then
  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
h
s///
s/^/:/
s/[	 ]*$/:/
s/:\$(srcdir):/:/g
s/:\${srcdir}:/:/g
s/:@srcdir@:/:/g
s/^:*//
s/:*$//
x
s/\(=[	 ]*\).*/\1/
G
s/\n//
s/^[^=]*=[	 ]*$//
}'
fi

cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
fi # test -n "$CONFIG_FILES"


eval set X "  :F $CONFIG_FILES      :C $CONFIG_COMMANDS"
shift
for ac_tag
do
  case $ac_tag in
  :[FHLC]) ac_mode=$ac_tag; continue;;
  esac
  case $ac_mode$ac_tag in
  :[FHL]*:*);;
  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
  :[FH]-) ac_tag=-:-;;
  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
  esac
  ac_save_IFS=$IFS
  IFS=:
  set x $ac_tag
  IFS=$ac_save_IFS
  shift
  ac_file=$1
  shift

  case $ac_mode in
  :L) ac_source=$1;;
  :[FH])
    ac_file_inputs=
    for ac_f
    do
      case $ac_f in
      -) ac_f="$ac_tmp/stdin";;
      *) # Look for the file first in the build tree, then in the source tree
	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
	 # because $ac_f cannot contain `:'.
	 test -f "$ac_f" ||
	   case $ac_f in
	   [\\/$]*) false;;
	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
	   esac ||
	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
      esac
      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
      as_fn_append ac_file_inputs " '$ac_f'"
    done

    # Let's still pretend it is `configure' which instantiates (i.e., don't
    # use $as_me), people would be surprised to read:
    #    /* config.h.  Generated by config.status.  */
    configure_input='Generated from '`
	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
	`' by configure.'
    if test x"$ac_file" != x-; then
      configure_input="$ac_file.  $configure_input"
      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
$as_echo "$as_me: creating $ac_file" >&6;}
    fi
    # Neutralize special characters interpreted by sed in replacement strings.
    case $configure_input in #(
    *\&* | *\|* | *\\* )
       ac_sed_conf_input=`$as_echo "$configure_input" |
       sed 's/[\\\\&|]/\\\\&/g'`;; #(
    *) ac_sed_conf_input=$configure_input;;
    esac

    case $ac_tag in
    *:-:* | *:-) cat >"$ac_tmp/stdin" \
      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
    esac
    ;;
  esac

  ac_dir=`$as_dirname -- "$ac_file" ||
$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
	 X"$ac_file" : 'X\(//\)[^/]' \| \
	 X"$ac_file" : 'X\(//\)$' \| \
	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$ac_file" |
    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)[^/].*/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`
  as_dir="$ac_dir"; as_fn_mkdir_p
  ac_builddir=.

case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
  # A ".." for each directory in $ac_dir_suffix.
  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
  case $ac_top_builddir_sub in
  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
  esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix

case $srcdir in
  .)  # We are building in place.
    ac_srcdir=.
    ac_top_srcdir=$ac_top_builddir_sub
    ac_abs_top_srcdir=$ac_pwd ;;
  [\\/]* | ?:[\\/]* )  # Absolute name.
    ac_srcdir=$srcdir$ac_dir_suffix;
    ac_top_srcdir=$srcdir
    ac_abs_top_srcdir=$srcdir ;;
  *) # Relative name.
    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
    ac_top_srcdir=$ac_top_build_prefix$srcdir
    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix


  case $ac_mode in
  :F)
  #
  # CONFIG_FILE
  #

  case $INSTALL in
  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
  esac
  ac_MKDIR_P=$MKDIR_P
  case $MKDIR_P in
  [\\/$]* | ?:[\\/]* ) ;;
  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
  esac
_ACEOF

cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# If the template does not know about datarootdir, expand it.
# FIXME: This hack should be removed a few years after 2.60.
ac_datarootdir_hack=; ac_datarootdir_seen=
ac_sed_dataroot='
/datarootdir/ {
  p
  q
}
/@datadir@/p
/@docdir@/p
/@infodir@/p
/@localedir@/p
/@mandir@/p'
case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
*datarootdir*) ac_datarootdir_seen=yes;;
*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
  ac_datarootdir_hack='
  s&@datadir@&$datadir&g
  s&@docdir@&$docdir&g
  s&@infodir@&$infodir&g
  s&@localedir@&$localedir&g
  s&@mandir@&$mandir&g
  s&\\\${datarootdir}&$datarootdir&g' ;;
esac
_ACEOF

# Neutralize VPATH when `$srcdir' = `.'.
# Shell code in configure.ac might set extrasub.
# FIXME: do we really want to maintain this feature?
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_sed_extra="$ac_vpsub
$extrasub
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
:t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
s|@configure_input@|$ac_sed_conf_input|;t t
s&@top_builddir@&$ac_top_builddir_sub&;t t
s&@top_build_prefix@&$ac_top_build_prefix&;t t
s&@srcdir@&$ac_srcdir&;t t
s&@abs_srcdir@&$ac_abs_srcdir&;t t
s&@top_srcdir@&$ac_top_srcdir&;t t
s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
s&@builddir@&$ac_builddir&;t t
s&@abs_builddir@&$ac_abs_builddir&;t t
s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
s&@INSTALL@&$ac_INSTALL&;t t
s&@MKDIR_P@&$ac_MKDIR_P&;t t
$ac_datarootdir_hack
"
eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5

test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
  { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \
      "$ac_tmp/out"`; test -z "$ac_out"; } &&
  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined.  Please make sure it is defined" >&5
$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined.  Please make sure it is defined" >&2;}

  rm -f "$ac_tmp/stdin"
  case $ac_file in
  -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
  *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
  esac \
  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
 ;;


  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
$as_echo "$as_me: executing $ac_file commands" >&6;}
 ;;
  esac


  case $ac_file$ac_mode in
    "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
  # Older Autoconf quotes --file arguments for eval, but not when files
  # are listed without --file.  Let's play safe and only enable the eval
  # if we detect the quoting.
  case $CONFIG_FILES in
  *\'*) eval set x "$CONFIG_FILES" ;;
  *)   set x $CONFIG_FILES ;;
  esac
  shift
  for mf
  do
    # Strip MF so we end up with the name of the file.
    mf=`echo "$mf" | sed -e 's/:.*$//'`
    # Check whether this is an Automake generated Makefile or not.
    # We used to match only the files named 'Makefile.in', but
    # some people rename them; so instead we look at the file content.
    # Grep'ing the first line is not enough: some people post-process
    # each Makefile.in and add a new line on top of each file to say so.
    # Grep'ing the whole file is not good either: AIX grep has a line
    # limit of 2048, but all sed's we know have understand at least 4000.
    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
      dirpart=`$as_dirname -- "$mf" ||
$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
	 X"$mf" : 'X\(//\)[^/]' \| \
	 X"$mf" : 'X\(//\)$' \| \
	 X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$mf" |
    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)[^/].*/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`
    else
      continue
    fi
    # Extract the definition of DEPDIR, am__include, and am__quote
    # from the Makefile without running 'make'.
    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
    test -z "$DEPDIR" && continue
    am__include=`sed -n 's/^am__include = //p' < "$mf"`
    test -z "$am__include" && continue
    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
    # Find all dependency output files, they are included files with
    # $(DEPDIR) in their names.  We invoke sed twice because it is the
    # simplest approach to changing $(DEPDIR) to its actual value in the
    # expansion.
    for file in `sed -n "
      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
      # Make sure the directory exists.
      test -f "$dirpart/$file" && continue
      fdir=`$as_dirname -- "$file" ||
$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
	 X"$file" : 'X\(//\)[^/]' \| \
	 X"$file" : 'X\(//\)$' \| \
	 X"$file" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$file" |
    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)[^/].*/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`
      as_dir=$dirpart/$fdir; as_fn_mkdir_p
      # echo "creating $dirpart/$file"
      echo '# dummy' > "$dirpart/$file"
    done
  done
}
 ;;
    "libtool":C)

    # See if we are running on zsh, and set the options which allow our
    # commands through without removal of \ escapes.
    if test -n "${ZSH_VERSION+set}" ; then
      setopt NO_GLOB_SUBST
    fi

    cfgfile="${ofile}T"
    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
    $RM "$cfgfile"

    cat <<_LT_EOF >> "$cfgfile"
#! $SHELL

# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
#
#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
#                 Foundation, Inc.
#   Written by Gordon Matzigkeit, 1996
#
#   This file is part of GNU Libtool.
#
# GNU Libtool is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# As a special exception to the GNU General Public License,
# if you distribute this file as part of a program or library that
# is built using GNU Libtool, you may include this file under the
# same distribution terms that you use for the rest of that program.
#
# GNU Libtool is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Libtool; see the file COPYING.  If not, a copy
# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
# obtained by writing to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.


# The names of the tagged configurations supported by this script.
available_tags=""

# ### BEGIN LIBTOOL CONFIG

# Which release of libtool.m4 was used?
macro_version=$macro_version
macro_revision=$macro_revision

# Whether or not to build shared libraries.
build_libtool_libs=$enable_shared

# Whether or not to build static libraries.
build_old_libs=$enable_static

# What type of objects to build.
pic_mode=$pic_mode

# Whether or not to optimize for fast installation.
fast_install=$enable_fast_install

# Shell to use when invoking shell scripts.
SHELL=$lt_SHELL

# An echo program that protects backslashes.
ECHO=$lt_ECHO

# The PATH separator for the build system.
PATH_SEPARATOR=$lt_PATH_SEPARATOR

# The host system.
host_alias=$host_alias
host=$host
host_os=$host_os

# The build system.
build_alias=$build_alias
build=$build
build_os=$build_os

# A sed program that does not truncate output.
SED=$lt_SED

# Sed that helps us avoid accidentally triggering echo(1) options like -n.
Xsed="\$SED -e 1s/^X//"

# A grep program that handles long lines.
GREP=$lt_GREP

# An ERE matcher.
EGREP=$lt_EGREP

# A literal string matcher.
FGREP=$lt_FGREP

# A BSD- or MS-compatible name lister.
NM=$lt_NM

# Whether we need soft or hard links.
LN_S=$lt_LN_S

# What is the maximum length of a command?
max_cmd_len=$max_cmd_len

# Object file suffix (normally "o").
objext=$ac_objext

# Executable file suffix (normally "").
exeext=$exeext

# whether the shell understands "unset".
lt_unset=$lt_unset

# turn spaces into newlines.
SP2NL=$lt_lt_SP2NL

# turn newlines into spaces.
NL2SP=$lt_lt_NL2SP

# convert \$build file names to \$host format.
to_host_file_cmd=$lt_cv_to_host_file_cmd

# convert \$build files to toolchain format.
to_tool_file_cmd=$lt_cv_to_tool_file_cmd

# An object symbol dumper.
OBJDUMP=$lt_OBJDUMP

# Method to check whether dependent libraries are shared objects.
deplibs_check_method=$lt_deplibs_check_method

# Command to use when deplibs_check_method = "file_magic".
file_magic_cmd=$lt_file_magic_cmd

# How to find potential files when deplibs_check_method = "file_magic".
file_magic_glob=$lt_file_magic_glob

# Find potential files using nocaseglob when deplibs_check_method = "file_magic".
want_nocaseglob=$lt_want_nocaseglob

# DLL creation program.
DLLTOOL=$lt_DLLTOOL

# Command to associate shared and link libraries.
sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd

# The archiver.
AR=$lt_AR

# Flags to create an archive.
AR_FLAGS=$lt_AR_FLAGS

# How to feed a file listing to the archiver.
archiver_list_spec=$lt_archiver_list_spec

# A symbol stripping program.
STRIP=$lt_STRIP

# Commands used to install an old-style archive.
RANLIB=$lt_RANLIB
old_postinstall_cmds=$lt_old_postinstall_cmds
old_postuninstall_cmds=$lt_old_postuninstall_cmds

# Whether to use a lock for old archive extraction.
lock_old_archive_extraction=$lock_old_archive_extraction

# A C compiler.
LTCC=$lt_CC

# LTCC compiler flags.
LTCFLAGS=$lt_CFLAGS

# Take the output of nm and produce a listing of raw symbols and C names.
global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe

# Transform the output of nm in a proper C declaration.
global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl

# Transform the output of nm in a C name address pair.
global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address

# Transform the output of nm in a C name address pair when lib prefix is needed.
global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix

# Specify filename containing input files for \$NM.
nm_file_list_spec=$lt_nm_file_list_spec

# The root where to search for dependent libraries,and in which our libraries should be installed.
lt_sysroot=$lt_sysroot

# The name of the directory that contains temporary libtool files.
objdir=$objdir

# Used to examine libraries when file_magic_cmd begins with "file".
MAGIC_CMD=$MAGIC_CMD

# Must we lock files when doing compilation?
need_locks=$lt_need_locks

# Manifest tool.
MANIFEST_TOOL=$lt_MANIFEST_TOOL

# Tool to manipulate archived DWARF debug symbol files on Mac OS X.
DSYMUTIL=$lt_DSYMUTIL

# Tool to change global to local symbols on Mac OS X.
NMEDIT=$lt_NMEDIT

# Tool to manipulate fat objects and archives on Mac OS X.
LIPO=$lt_LIPO

# ldd/readelf like tool for Mach-O binaries on Mac OS X.
OTOOL=$lt_OTOOL

# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
OTOOL64=$lt_OTOOL64

# Old archive suffix (normally "a").
libext=$libext

# Shared library suffix (normally ".so").
shrext_cmds=$lt_shrext_cmds

# The commands to extract the exported symbol list from a shared archive.
extract_expsyms_cmds=$lt_extract_expsyms_cmds

# Variables whose values should be saved in libtool wrapper scripts and
# restored at link time.
variables_saved_for_relink=$lt_variables_saved_for_relink

# Do we need the "lib" prefix for modules?
need_lib_prefix=$need_lib_prefix

# Do we need a version for libraries?
need_version=$need_version

# Library versioning type.
version_type=$version_type

# Shared library runtime path variable.
runpath_var=$runpath_var

# Shared library path variable.
shlibpath_var=$shlibpath_var

# Is shlibpath searched before the hard-coded library search path?
shlibpath_overrides_runpath=$shlibpath_overrides_runpath

# Format of library name prefix.
libname_spec=$lt_libname_spec

# List of archive names.  First name is the real one, the rest are links.
# The last name is the one that the linker finds with -lNAME
library_names_spec=$lt_library_names_spec

# The coded name of the library, if different from the real name.
soname_spec=$lt_soname_spec

# Permission mode override for installation of shared libraries.
install_override_mode=$lt_install_override_mode

# Command to use after installation of a shared archive.
postinstall_cmds=$lt_postinstall_cmds

# Command to use after uninstallation of a shared archive.
postuninstall_cmds=$lt_postuninstall_cmds

# Commands used to finish a libtool library installation in a directory.
finish_cmds=$lt_finish_cmds

# As "finish_cmds", except a single script fragment to be evaled but
# not shown.
finish_eval=$lt_finish_eval

# Whether we should hardcode library paths into libraries.
hardcode_into_libs=$hardcode_into_libs

# Compile-time system search path for libraries.
sys_lib_search_path_spec=$lt_sys_lib_search_path_spec

# Run-time system search path for libraries.
sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec

# Whether dlopen is supported.
dlopen_support=$enable_dlopen

# Whether dlopen of programs is supported.
dlopen_self=$enable_dlopen_self

# Whether dlopen of statically linked programs is supported.
dlopen_self_static=$enable_dlopen_self_static

# Commands to strip libraries.
old_striplib=$lt_old_striplib
striplib=$lt_striplib


# The linker used to build libraries.
LD=$lt_LD

# How to create reloadable object files.
reload_flag=$lt_reload_flag
reload_cmds=$lt_reload_cmds

# Commands used to build an old-style archive.
old_archive_cmds=$lt_old_archive_cmds

# A language specific compiler.
CC=$lt_compiler

# Is the compiler the GNU compiler?
with_gcc=$GCC

# Compiler flag to turn off builtin functions.
no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag

# Additional compiler flags for building library objects.
pic_flag=$lt_lt_prog_compiler_pic

# How to pass a linker flag through the compiler.
wl=$lt_lt_prog_compiler_wl

# Compiler flag to prevent dynamic linking.
link_static_flag=$lt_lt_prog_compiler_static

# Does compiler simultaneously support -c and -o options?
compiler_c_o=$lt_lt_cv_prog_compiler_c_o

# Whether or not to add -lc for building shared libraries.
build_libtool_need_lc=$archive_cmds_need_lc

# Whether or not to disallow shared libs when runtime libs are static.
allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes

# Compiler flag to allow reflexive dlopens.
export_dynamic_flag_spec=$lt_export_dynamic_flag_spec

# Compiler flag to generate shared objects directly from archives.
whole_archive_flag_spec=$lt_whole_archive_flag_spec

# Whether the compiler copes with passing no objects directly.
compiler_needs_object=$lt_compiler_needs_object

# Create an old-style archive from a shared archive.
old_archive_from_new_cmds=$lt_old_archive_from_new_cmds

# Create a temporary old-style archive to link instead of a shared archive.
old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds

# Commands used to build a shared archive.
archive_cmds=$lt_archive_cmds
archive_expsym_cmds=$lt_archive_expsym_cmds

# Commands used to build a loadable module if different from building
# a shared archive.
module_cmds=$lt_module_cmds
module_expsym_cmds=$lt_module_expsym_cmds

# Whether we are building with GNU ld or not.
with_gnu_ld=$lt_with_gnu_ld

# Flag that allows shared libraries with undefined symbols to be built.
allow_undefined_flag=$lt_allow_undefined_flag

# Flag that enforces no undefined symbols.
no_undefined_flag=$lt_no_undefined_flag

# Flag to hardcode \$libdir into a binary during linking.
# This must work even if \$libdir does not exist
hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec

# Whether we need a single "-rpath" flag with a separated argument.
hardcode_libdir_separator=$lt_hardcode_libdir_separator

# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
# DIR into the resulting binary.
hardcode_direct=$hardcode_direct

# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
# DIR into the resulting binary and the resulting library dependency is
# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
# library is relocated.
hardcode_direct_absolute=$hardcode_direct_absolute

# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
# into the resulting binary.
hardcode_minus_L=$hardcode_minus_L

# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
# into the resulting binary.
hardcode_shlibpath_var=$hardcode_shlibpath_var

# Set to "yes" if building a shared library automatically hardcodes DIR
# into the library and all subsequent libraries and executables linked
# against it.
hardcode_automatic=$hardcode_automatic

# Set to yes if linker adds runtime paths of dependent libraries
# to runtime path list.
inherit_rpath=$inherit_rpath

# Whether libtool must link a program against all its dependency libraries.
link_all_deplibs=$link_all_deplibs

# Set to "yes" if exported symbols are required.
always_export_symbols=$always_export_symbols

# The commands to list exported symbols.
export_symbols_cmds=$lt_export_symbols_cmds

# Symbols that should not be listed in the preloaded symbols.
exclude_expsyms=$lt_exclude_expsyms

# Symbols that must always be exported.
include_expsyms=$lt_include_expsyms

# Commands necessary for linking programs (against libraries) with templates.
prelink_cmds=$lt_prelink_cmds

# Commands necessary for finishing linking programs.
postlink_cmds=$lt_postlink_cmds

# Specify filename containing input files.
file_list_spec=$lt_file_list_spec

# How to hardcode a shared library path into an executable.
hardcode_action=$hardcode_action

# ### END LIBTOOL CONFIG

_LT_EOF

  case $host_os in
  aix3*)
    cat <<\_LT_EOF >> "$cfgfile"
# AIX sometimes has problems with the GCC collect2 program.  For some
# reason, if we set the COLLECT_NAMES environment variable, the problems
# vanish in a puff of smoke.
if test "X${COLLECT_NAMES+set}" != Xset; then
  COLLECT_NAMES=
  export COLLECT_NAMES
fi
_LT_EOF
    ;;
  esac


ltmain="$ac_aux_dir/ltmain.sh"


  # We use sed instead of cat because bash on DJGPP gets confused if
  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
  # text mode, it properly converts lines to CR/LF.  This bash problem
  # is reportedly fixed, but why not run on old versions too?
  sed '$q' "$ltmain" >> "$cfgfile" \
     || (rm -f "$cfgfile"; exit 1)

  if test x"$xsi_shell" = xyes; then
  sed -e '/^func_dirname ()$/,/^} # func_dirname /c\
func_dirname ()\
{\
\    case ${1} in\
\      */*) func_dirname_result="${1%/*}${2}" ;;\
\      *  ) func_dirname_result="${3}" ;;\
\    esac\
} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \
  && mv -f "$cfgfile.tmp" "$cfgfile" \
    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
test 0 -eq $? || _lt_function_replace_fail=:


  sed -e '/^func_basename ()$/,/^} # func_basename /c\
func_basename ()\
{\
\    func_basename_result="${1##*/}"\
} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \
  && mv -f "$cfgfile.tmp" "$cfgfile" \
    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
test 0 -eq $? || _lt_function_replace_fail=:


  sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\
func_dirname_and_basename ()\
{\
\    case ${1} in\
\      */*) func_dirname_result="${1%/*}${2}" ;;\
\      *  ) func_dirname_result="${3}" ;;\
\    esac\
\    func_basename_result="${1##*/}"\
} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \
  && mv -f "$cfgfile.tmp" "$cfgfile" \
    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
test 0 -eq $? || _lt_function_replace_fail=:


  sed -e '/^func_stripname ()$/,/^} # func_stripname /c\
func_stripname ()\
{\
\    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\
\    # positional parameters, so assign one to ordinary parameter first.\
\    func_stripname_result=${3}\
\    func_stripname_result=${func_stripname_result#"${1}"}\
\    func_stripname_result=${func_stripname_result%"${2}"}\
} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \
  && mv -f "$cfgfile.tmp" "$cfgfile" \
    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
test 0 -eq $? || _lt_function_replace_fail=:


  sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\
func_split_long_opt ()\
{\
\    func_split_long_opt_name=${1%%=*}\
\    func_split_long_opt_arg=${1#*=}\
} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \
  && mv -f "$cfgfile.tmp" "$cfgfile" \
    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
test 0 -eq $? || _lt_function_replace_fail=:


  sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\
func_split_short_opt ()\
{\
\    func_split_short_opt_arg=${1#??}\
\    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\
} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \
  && mv -f "$cfgfile.tmp" "$cfgfile" \
    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
test 0 -eq $? || _lt_function_replace_fail=:


  sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\
func_lo2o ()\
{\
\    case ${1} in\
\      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\
\      *)    func_lo2o_result=${1} ;;\
\    esac\
} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \
  && mv -f "$cfgfile.tmp" "$cfgfile" \
    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
test 0 -eq $? || _lt_function_replace_fail=:


  sed -e '/^func_xform ()$/,/^} # func_xform /c\
func_xform ()\
{\
    func_xform_result=${1%.*}.lo\
} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \
  && mv -f "$cfgfile.tmp" "$cfgfile" \
    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
test 0 -eq $? || _lt_function_replace_fail=:


  sed -e '/^func_arith ()$/,/^} # func_arith /c\
func_arith ()\
{\
    func_arith_result=$(( $* ))\
} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \
  && mv -f "$cfgfile.tmp" "$cfgfile" \
    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
test 0 -eq $? || _lt_function_replace_fail=:


  sed -e '/^func_len ()$/,/^} # func_len /c\
func_len ()\
{\
    func_len_result=${#1}\
} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \
  && mv -f "$cfgfile.tmp" "$cfgfile" \
    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
test 0 -eq $? || _lt_function_replace_fail=:

fi

if test x"$lt_shell_append" = xyes; then
  sed -e '/^func_append ()$/,/^} # func_append /c\
func_append ()\
{\
    eval "${1}+=\\${2}"\
} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \
  && mv -f "$cfgfile.tmp" "$cfgfile" \
    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
test 0 -eq $? || _lt_function_replace_fail=:


  sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\
func_append_quoted ()\
{\
\    func_quote_for_eval "${2}"\
\    eval "${1}+=\\\\ \\$func_quote_for_eval_result"\
} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \
  && mv -f "$cfgfile.tmp" "$cfgfile" \
    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
test 0 -eq $? || _lt_function_replace_fail=:


  # Save a `func_append' function call where possible by direct use of '+='
  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
    && mv -f "$cfgfile.tmp" "$cfgfile" \
      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
  test 0 -eq $? || _lt_function_replace_fail=:
else
  # Save a `func_append' function call even when '+=' is not available
  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
    && mv -f "$cfgfile.tmp" "$cfgfile" \
      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
  test 0 -eq $? || _lt_function_replace_fail=:
fi

if test x"$_lt_function_replace_fail" = x":"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5
$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;}
fi


   mv -f "$cfgfile" "$ofile" ||
    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
  chmod +x "$ofile"

 ;;

  esac
done # for ac_tag


as_fn_exit 0
_ACEOF
ac_clean_files=$ac_clean_files_save

test $ac_write_fail = 0 ||
  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5


# configure is writing to config.log, and then calls config.status.
# config.status does its own redirection, appending to config.log.
# Unfortunately, on DOS this fails, as config.log is still kept open
# by configure, so config.status won't be able to write to it; its
# output is simply discarded.  So we exec the FD to /dev/null,
# effectively closing config.log, so it can be properly (re)opened and
# appended to by config.status.  When coming back to configure, we
# need to make the FD available again.
if test "$no_create" != yes; then
  ac_cs_success=:
  ac_config_status_args=
  test "$silent" = yes &&
    ac_config_status_args="$ac_config_status_args --quiet"
  exec 5>/dev/null
  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
  exec 5>>config.log
  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
  # would make configure fail if this is the last instruction.
  $ac_cs_success || as_fn_exit 1
fi
if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi

deps/libressl-pnacl-sys-2.1.6/libressl/config.sub0000555000175000017500000010541212360020752016721 0ustar  #! /bin/sh
# Configuration validation subroutine script.
#   Copyright 1992-2013 Free Software Foundation, Inc.

timestamp='2013-10-01'

# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see .
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that
# program.  This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").


# Please send patches with a ChangeLog entry to config-patches@gnu.org.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
# Otherwise, we print the canonical config type on stdout and succeed.

# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD

# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
# that are meaningful with *any* GNU software.
# Each package is responsible for reporting which valid configurations
# it does not support.  The user should be able to distinguish
# a failure to support a valid configuration from a meaningless
# configuration.

# The goal of this file is to map all the various variations of a given
# machine specification into a single specification in the form:
#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or in some cases, the newer four-part form:
#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# It is wrong to echo any other type of specification.

me=`echo "$0" | sed -e 's,.*/,,'`

usage="\
Usage: $0 [OPTION] CPU-MFR-OPSYS
       $0 [OPTION] ALIAS

Canonicalize a configuration name.

Operation modes:
  -h, --help         print this help, then exit
  -t, --time-stamp   print date of last modification, then exit
  -v, --version      print version number, then exit

Report bugs and patches to ."

version="\
GNU config.sub ($timestamp)

Copyright 1992-2013 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."

help="
Try \`$me --help' for more information."

# Parse command line
while test $# -gt 0 ; do
  case $1 in
    --time-stamp | --time* | -t )
       echo "$timestamp" ; exit ;;
    --version | -v )
       echo "$version" ; exit ;;
    --help | --h* | -h )
       echo "$usage"; exit ;;
    -- )     # Stop option processing
       shift; break ;;
    - )	# Use stdin as input.
       break ;;
    -* )
       echo "$me: invalid option $1$help"
       exit 1 ;;

    *local*)
       # First pass through any local machine types.
       echo $1
       exit ;;

    * )
       break ;;
  esac
done

case $# in
 0) echo "$me: missing argument$help" >&2
    exit 1;;
 1) ;;
 *) echo "$me: too many arguments$help" >&2
    exit 1;;
esac

# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
  nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
  linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
  knetbsd*-gnu* | netbsd*-gnu* | \
  kopensolaris*-gnu* | \
  storm-chaos* | os2-emx* | rtmk-nova*)
    os=-$maybe_os
    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
    ;;
  android-linux)
    os=-linux-android
    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
    ;;
  *)
    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
    if [ $basic_machine != $1 ]
    then os=`echo $1 | sed 's/.*-/-/'`
    else os=; fi
    ;;
esac

### Let's recognize common machines as not being operating systems so
### that things like config.sub decstation-3100 work.  We also
### recognize some manufacturers as not being operating systems, so we
### can provide default operating systems below.
case $os in
	-sun*os*)
		# Prevent following clause from handling this invalid input.
		;;
	-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
	-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
	-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
	-apple | -axis | -knuth | -cray | -microblaze*)
		os=
		basic_machine=$1
		;;
	-bluegene*)
		os=-cnk
		;;
	-sim | -cisco | -oki | -wec | -winbond)
		os=
		basic_machine=$1
		;;
	-scout)
		;;
	-wrs)
		os=-vxworks
		basic_machine=$1
		;;
	-chorusos*)
		os=-chorusos
		basic_machine=$1
		;;
	-chorusrdb)
		os=-chorusrdb
		basic_machine=$1
		;;
	-hiux*)
		os=-hiuxwe2
		;;
	-sco6)
		os=-sco5v6
		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
		;;
	-sco5)
		os=-sco3.2v5
		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
		;;
	-sco4)
		os=-sco3.2v4
		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
		;;
	-sco3.2.[4-9]*)
		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
		;;
	-sco3.2v[4-9]*)
		# Don't forget version if it is 3.2v4 or newer.
		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
		;;
	-sco5v6*)
		# Don't forget version if it is 3.2v4 or newer.
		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
		;;
	-sco*)
		os=-sco3.2v2
		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
		;;
	-udk*)
		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
		;;
	-isc)
		os=-isc2.2
		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
		;;
	-clix*)
		basic_machine=clipper-intergraph
		;;
	-isc*)
		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
		;;
	-lynx*178)
		os=-lynxos178
		;;
	-lynx*5)
		os=-lynxos5
		;;
	-lynx*)
		os=-lynxos
		;;
	-ptx*)
		basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
		;;
	-windowsnt*)
		os=`echo $os | sed -e 's/windowsnt/winnt/'`
		;;
	-psos*)
		os=-psos
		;;
	-mint | -mint[0-9]*)
		basic_machine=m68k-atari
		os=-mint
		;;
esac

# Decode aliases for certain CPU-COMPANY combinations.
case $basic_machine in
	# Recognize the basic CPU types without company name.
	# Some are omitted here because they have special meanings below.
	1750a | 580 \
	| a29k \
	| aarch64 | aarch64_be \
	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
	| am33_2.0 \
	| arc | arceb \
	| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
	| avr | avr32 \
	| be32 | be64 \
	| bfin \
	| c4x | c8051 | clipper \
	| d10v | d30v | dlx | dsp16xx \
	| epiphany \
	| fido | fr30 | frv \
	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
	| hexagon \
	| i370 | i860 | i960 | ia64 \
	| ip2k | iq2000 \
	| k1om \
	| le32 | le64 \
	| lm32 \
	| m32c | m32r | m32rle | m68000 | m68k | m88k \
	| maxq | mb | microblaze | microblazeel | mcore | mep | metag \
	| mips | mipsbe | mipseb | mipsel | mipsle \
	| mips16 \
	| mips64 | mips64el \
	| mips64octeon | mips64octeonel \
	| mips64orion | mips64orionel \
	| mips64r5900 | mips64r5900el \
	| mips64vr | mips64vrel \
	| mips64vr4100 | mips64vr4100el \
	| mips64vr4300 | mips64vr4300el \
	| mips64vr5000 | mips64vr5000el \
	| mips64vr5900 | mips64vr5900el \
	| mipsisa32 | mipsisa32el \
	| mipsisa32r2 | mipsisa32r2el \
	| mipsisa64 | mipsisa64el \
	| mipsisa64r2 | mipsisa64r2el \
	| mipsisa64sb1 | mipsisa64sb1el \
	| mipsisa64sr71k | mipsisa64sr71kel \
	| mipsr5900 | mipsr5900el \
	| mipstx39 | mipstx39el \
	| mn10200 | mn10300 \
	| moxie \
	| mt \
	| msp430 \
	| nds32 | nds32le | nds32be \
	| nios | nios2 | nios2eb | nios2el \
	| ns16k | ns32k \
	| open8 \
	| or1k | or32 \
	| pdp10 | pdp11 | pj | pjl \
	| powerpc | powerpc64 | powerpc64le | powerpcle \
	| pyramid \
	| rl78 | rx \
	| score \
	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
	| sh64 | sh64le \
	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
	| spu \
	| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
	| ubicom32 \
	| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
	| we32k \
	| x86 | xc16x | xstormy16 | xtensa \
	| z8k | z80)
		basic_machine=$basic_machine-unknown
		;;
	c54x)
		basic_machine=tic54x-unknown
		;;
	c55x)
		basic_machine=tic55x-unknown
		;;
	c6x)
		basic_machine=tic6x-unknown
		;;
	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
		basic_machine=$basic_machine-unknown
		os=-none
		;;
	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
		;;
	ms1)
		basic_machine=mt-unknown
		;;

	strongarm | thumb | xscale)
		basic_machine=arm-unknown
		;;
	xgate)
		basic_machine=$basic_machine-unknown
		os=-none
		;;
	xscaleeb)
		basic_machine=armeb-unknown
		;;

	xscaleel)
		basic_machine=armel-unknown
		;;

	# We use `pc' rather than `unknown'
	# because (1) that's what they normally are, and
	# (2) the word "unknown" tends to confuse beginning users.
	i*86 | x86_64)
	  basic_machine=$basic_machine-pc
	  ;;
	# Object if more than one company name word.
	*-*-*)
		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
		exit 1
		;;
	# Recognize the basic CPU types with company name.
	580-* \
	| a29k-* \
	| aarch64-* | aarch64_be-* \
	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
	| avr-* | avr32-* \
	| be32-* | be64-* \
	| bfin-* | bs2000-* \
	| c[123]* | c30-* | [cjt]90-* | c4x-* \
	| c8051-* | clipper-* | craynv-* | cydra-* \
	| d10v-* | d30v-* | dlx-* \
	| elxsi-* \
	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
	| h8300-* | h8500-* \
	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
	| hexagon-* \
	| i*86-* | i860-* | i960-* | ia64-* \
	| ip2k-* | iq2000-* \
	| k1om-* \
	| le32-* | le64-* \
	| lm32-* \
	| m32c-* | m32r-* | m32rle-* \
	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
	| microblaze-* | microblazeel-* \
	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
	| mips16-* \
	| mips64-* | mips64el-* \
	| mips64octeon-* | mips64octeonel-* \
	| mips64orion-* | mips64orionel-* \
	| mips64r5900-* | mips64r5900el-* \
	| mips64vr-* | mips64vrel-* \
	| mips64vr4100-* | mips64vr4100el-* \
	| mips64vr4300-* | mips64vr4300el-* \
	| mips64vr5000-* | mips64vr5000el-* \
	| mips64vr5900-* | mips64vr5900el-* \
	| mipsisa32-* | mipsisa32el-* \
	| mipsisa32r2-* | mipsisa32r2el-* \
	| mipsisa64-* | mipsisa64el-* \
	| mipsisa64r2-* | mipsisa64r2el-* \
	| mipsisa64sb1-* | mipsisa64sb1el-* \
	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
	| mipsr5900-* | mipsr5900el-* \
	| mipstx39-* | mipstx39el-* \
	| mmix-* \
	| mt-* \
	| msp430-* \
	| nds32-* | nds32le-* | nds32be-* \
	| nios-* | nios2-* | nios2eb-* | nios2el-* \
	| none-* | np1-* | ns16k-* | ns32k-* \
	| open8-* \
	| orion-* \
	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
	| pyramid-* \
	| rl78-* | romp-* | rs6000-* | rx-* \
	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
	| sparclite-* \
	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
	| tahoe-* \
	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
	| tile*-* \
	| tron-* \
	| ubicom32-* \
	| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
	| vax-* \
	| we32k-* \
	| x86-* | x86_64-* | xc16x-* | xps100-* \
	| xstormy16-* | xtensa*-* \
	| ymp-* \
	| z8k-* | z80-*)
		;;
	# Recognize the basic CPU types without company name, with glob match.
	xtensa*)
		basic_machine=$basic_machine-unknown
		;;
	# Recognize the various machine names and aliases which stand
	# for a CPU type and a company and sometimes even an OS.
	386bsd)
		basic_machine=i386-unknown
		os=-bsd
		;;
	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
		basic_machine=m68000-att
		;;
	3b*)
		basic_machine=we32k-att
		;;
	a29khif)
		basic_machine=a29k-amd
		os=-udi
		;;
	abacus)
		basic_machine=abacus-unknown
		;;
	adobe68k)
		basic_machine=m68010-adobe
		os=-scout
		;;
	alliant | fx80)
		basic_machine=fx80-alliant
		;;
	altos | altos3068)
		basic_machine=m68k-altos
		;;
	am29k)
		basic_machine=a29k-none
		os=-bsd
		;;
	amd64)
		basic_machine=x86_64-pc
		;;
	amd64-*)
		basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
		;;
	amdahl)
		basic_machine=580-amdahl
		os=-sysv
		;;
	amiga | amiga-*)
		basic_machine=m68k-unknown
		;;
	amigaos | amigados)
		basic_machine=m68k-unknown
		os=-amigaos
		;;
	amigaunix | amix)
		basic_machine=m68k-unknown
		os=-sysv4
		;;
	apollo68)
		basic_machine=m68k-apollo
		os=-sysv
		;;
	apollo68bsd)
		basic_machine=m68k-apollo
		os=-bsd
		;;
	aros)
		basic_machine=i386-pc
		os=-aros
		;;
	aux)
		basic_machine=m68k-apple
		os=-aux
		;;
	balance)
		basic_machine=ns32k-sequent
		os=-dynix
		;;
	blackfin)
		basic_machine=bfin-unknown
		os=-linux
		;;
	blackfin-*)
		basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
		os=-linux
		;;
	bluegene*)
		basic_machine=powerpc-ibm
		os=-cnk
		;;
	c54x-*)
		basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
		;;
	c55x-*)
		basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
		;;
	c6x-*)
		basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
		;;
	c90)
		basic_machine=c90-cray
		os=-unicos
		;;
	cegcc)
		basic_machine=arm-unknown
		os=-cegcc
		;;
	convex-c1)
		basic_machine=c1-convex
		os=-bsd
		;;
	convex-c2)
		basic_machine=c2-convex
		os=-bsd
		;;
	convex-c32)
		basic_machine=c32-convex
		os=-bsd
		;;
	convex-c34)
		basic_machine=c34-convex
		os=-bsd
		;;
	convex-c38)
		basic_machine=c38-convex
		os=-bsd
		;;
	cray | j90)
		basic_machine=j90-cray
		os=-unicos
		;;
	craynv)
		basic_machine=craynv-cray
		os=-unicosmp
		;;
	cr16 | cr16-*)
		basic_machine=cr16-unknown
		os=-elf
		;;
	crds | unos)
		basic_machine=m68k-crds
		;;
	crisv32 | crisv32-* | etraxfs*)
		basic_machine=crisv32-axis
		;;
	cris | cris-* | etrax*)
		basic_machine=cris-axis
		;;
	crx)
		basic_machine=crx-unknown
		os=-elf
		;;
	da30 | da30-*)
		basic_machine=m68k-da30
		;;
	decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
		basic_machine=mips-dec
		;;
	decsystem10* | dec10*)
		basic_machine=pdp10-dec
		os=-tops10
		;;
	decsystem20* | dec20*)
		basic_machine=pdp10-dec
		os=-tops20
		;;
	delta | 3300 | motorola-3300 | motorola-delta \
	      | 3300-motorola | delta-motorola)
		basic_machine=m68k-motorola
		;;
	delta88)
		basic_machine=m88k-motorola
		os=-sysv3
		;;
	dicos)
		basic_machine=i686-pc
		os=-dicos
		;;
	djgpp)
		basic_machine=i586-pc
		os=-msdosdjgpp
		;;
	dpx20 | dpx20-*)
		basic_machine=rs6000-bull
		os=-bosx
		;;
	dpx2* | dpx2*-bull)
		basic_machine=m68k-bull
		os=-sysv3
		;;
	ebmon29k)
		basic_machine=a29k-amd
		os=-ebmon
		;;
	elxsi)
		basic_machine=elxsi-elxsi
		os=-bsd
		;;
	encore | umax | mmax)
		basic_machine=ns32k-encore
		;;
	es1800 | OSE68k | ose68k | ose | OSE)
		basic_machine=m68k-ericsson
		os=-ose
		;;
	fx2800)
		basic_machine=i860-alliant
		;;
	genix)
		basic_machine=ns32k-ns
		;;
	gmicro)
		basic_machine=tron-gmicro
		os=-sysv
		;;
	go32)
		basic_machine=i386-pc
		os=-go32
		;;
	h3050r* | hiux*)
		basic_machine=hppa1.1-hitachi
		os=-hiuxwe2
		;;
	h8300hms)
		basic_machine=h8300-hitachi
		os=-hms
		;;
	h8300xray)
		basic_machine=h8300-hitachi
		os=-xray
		;;
	h8500hms)
		basic_machine=h8500-hitachi
		os=-hms
		;;
	harris)
		basic_machine=m88k-harris
		os=-sysv3
		;;
	hp300-*)
		basic_machine=m68k-hp
		;;
	hp300bsd)
		basic_machine=m68k-hp
		os=-bsd
		;;
	hp300hpux)
		basic_machine=m68k-hp
		os=-hpux
		;;
	hp3k9[0-9][0-9] | hp9[0-9][0-9])
		basic_machine=hppa1.0-hp
		;;
	hp9k2[0-9][0-9] | hp9k31[0-9])
		basic_machine=m68000-hp
		;;
	hp9k3[2-9][0-9])
		basic_machine=m68k-hp
		;;
	hp9k6[0-9][0-9] | hp6[0-9][0-9])
		basic_machine=hppa1.0-hp
		;;
	hp9k7[0-79][0-9] | hp7[0-79][0-9])
		basic_machine=hppa1.1-hp
		;;
	hp9k78[0-9] | hp78[0-9])
		# FIXME: really hppa2.0-hp
		basic_machine=hppa1.1-hp
		;;
	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
		# FIXME: really hppa2.0-hp
		basic_machine=hppa1.1-hp
		;;
	hp9k8[0-9][13679] | hp8[0-9][13679])
		basic_machine=hppa1.1-hp
		;;
	hp9k8[0-9][0-9] | hp8[0-9][0-9])
		basic_machine=hppa1.0-hp
		;;
	hppa-next)
		os=-nextstep3
		;;
	hppaosf)
		basic_machine=hppa1.1-hp
		os=-osf
		;;
	hppro)
		basic_machine=hppa1.1-hp
		os=-proelf
		;;
	i370-ibm* | ibm*)
		basic_machine=i370-ibm
		;;
	i*86v32)
		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
		os=-sysv32
		;;
	i*86v4*)
		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
		os=-sysv4
		;;
	i*86v)
		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
		os=-sysv
		;;
	i*86sol2)
		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
		os=-solaris2
		;;
	i386mach)
		basic_machine=i386-mach
		os=-mach
		;;
	i386-vsta | vsta)
		basic_machine=i386-unknown
		os=-vsta
		;;
	iris | iris4d)
		basic_machine=mips-sgi
		case $os in
		    -irix*)
			;;
		    *)
			os=-irix4
			;;
		esac
		;;
	isi68 | isi)
		basic_machine=m68k-isi
		os=-sysv
		;;
	m68knommu)
		basic_machine=m68k-unknown
		os=-linux
		;;
	m68knommu-*)
		basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
		os=-linux
		;;
	m88k-omron*)
		basic_machine=m88k-omron
		;;
	magnum | m3230)
		basic_machine=mips-mips
		os=-sysv
		;;
	merlin)
		basic_machine=ns32k-utek
		os=-sysv
		;;
	microblaze*)
		basic_machine=microblaze-xilinx
		;;
	mingw64)
		basic_machine=x86_64-pc
		os=-mingw64
		;;
	mingw32)
		basic_machine=i686-pc
		os=-mingw32
		;;
	mingw32ce)
		basic_machine=arm-unknown
		os=-mingw32ce
		;;
	miniframe)
		basic_machine=m68000-convergent
		;;
	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
		basic_machine=m68k-atari
		os=-mint
		;;
	mips3*-*)
		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
		;;
	mips3*)
		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
		;;
	monitor)
		basic_machine=m68k-rom68k
		os=-coff
		;;
	morphos)
		basic_machine=powerpc-unknown
		os=-morphos
		;;
	msdos)
		basic_machine=i386-pc
		os=-msdos
		;;
	ms1-*)
		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
		;;
	msys)
		basic_machine=i686-pc
		os=-msys
		;;
	mvs)
		basic_machine=i370-ibm
		os=-mvs
		;;
	nacl)
		basic_machine=le32-unknown
		os=-nacl
		;;
	ncr3000)
		basic_machine=i486-ncr
		os=-sysv4
		;;
	netbsd386)
		basic_machine=i386-unknown
		os=-netbsd
		;;
	netwinder)
		basic_machine=armv4l-rebel
		os=-linux
		;;
	news | news700 | news800 | news900)
		basic_machine=m68k-sony
		os=-newsos
		;;
	news1000)
		basic_machine=m68030-sony
		os=-newsos
		;;
	news-3600 | risc-news)
		basic_machine=mips-sony
		os=-newsos
		;;
	necv70)
		basic_machine=v70-nec
		os=-sysv
		;;
	next | m*-next )
		basic_machine=m68k-next
		case $os in
		    -nextstep* )
			;;
		    -ns2*)
		      os=-nextstep2
			;;
		    *)
		      os=-nextstep3
			;;
		esac
		;;
	nh3000)
		basic_machine=m68k-harris
		os=-cxux
		;;
	nh[45]000)
		basic_machine=m88k-harris
		os=-cxux
		;;
	nindy960)
		basic_machine=i960-intel
		os=-nindy
		;;
	mon960)
		basic_machine=i960-intel
		os=-mon960
		;;
	nonstopux)
		basic_machine=mips-compaq
		os=-nonstopux
		;;
	np1)
		basic_machine=np1-gould
		;;
	neo-tandem)
		basic_machine=neo-tandem
		;;
	nse-tandem)
		basic_machine=nse-tandem
		;;
	nsr-tandem)
		basic_machine=nsr-tandem
		;;
	op50n-* | op60c-*)
		basic_machine=hppa1.1-oki
		os=-proelf
		;;
	openrisc | openrisc-*)
		basic_machine=or32-unknown
		;;
	os400)
		basic_machine=powerpc-ibm
		os=-os400
		;;
	OSE68000 | ose68000)
		basic_machine=m68000-ericsson
		os=-ose
		;;
	os68k)
		basic_machine=m68k-none
		os=-os68k
		;;
	pa-hitachi)
		basic_machine=hppa1.1-hitachi
		os=-hiuxwe2
		;;
	paragon)
		basic_machine=i860-intel
		os=-osf
		;;
	parisc)
		basic_machine=hppa-unknown
		os=-linux
		;;
	parisc-*)
		basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
		os=-linux
		;;
	pbd)
		basic_machine=sparc-tti
		;;
	pbb)
		basic_machine=m68k-tti
		;;
	pc532 | pc532-*)
		basic_machine=ns32k-pc532
		;;
	pc98)
		basic_machine=i386-pc
		;;
	pc98-*)
		basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
		;;
	pentium | p5 | k5 | k6 | nexgen | viac3)
		basic_machine=i586-pc
		;;
	pentiumpro | p6 | 6x86 | athlon | athlon_*)
		basic_machine=i686-pc
		;;
	pentiumii | pentium2 | pentiumiii | pentium3)
		basic_machine=i686-pc
		;;
	pentium4)
		basic_machine=i786-pc
		;;
	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
		;;
	pentiumpro-* | p6-* | 6x86-* | athlon-*)
		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
		;;
	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
		;;
	pentium4-*)
		basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
		;;
	pn)
		basic_machine=pn-gould
		;;
	power)	basic_machine=power-ibm
		;;
	ppc | ppcbe)	basic_machine=powerpc-unknown
		;;
	ppc-* | ppcbe-*)
		basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
		;;
	ppcle | powerpclittle | ppc-le | powerpc-little)
		basic_machine=powerpcle-unknown
		;;
	ppcle-* | powerpclittle-*)
		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
		;;
	ppc64)	basic_machine=powerpc64-unknown
		;;
	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
		;;
	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
		basic_machine=powerpc64le-unknown
		;;
	ppc64le-* | powerpc64little-*)
		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
		;;
	ps2)
		basic_machine=i386-ibm
		;;
	pw32)
		basic_machine=i586-unknown
		os=-pw32
		;;
	rdos | rdos64)
		basic_machine=x86_64-pc
		os=-rdos
		;;
	rdos32)
		basic_machine=i386-pc
		os=-rdos
		;;
	rom68k)
		basic_machine=m68k-rom68k
		os=-coff
		;;
	rm[46]00)
		basic_machine=mips-siemens
		;;
	rtpc | rtpc-*)
		basic_machine=romp-ibm
		;;
	s390 | s390-*)
		basic_machine=s390-ibm
		;;
	s390x | s390x-*)
		basic_machine=s390x-ibm
		;;
	sa29200)
		basic_machine=a29k-amd
		os=-udi
		;;
	sb1)
		basic_machine=mipsisa64sb1-unknown
		;;
	sb1el)
		basic_machine=mipsisa64sb1el-unknown
		;;
	sde)
		basic_machine=mipsisa32-sde
		os=-elf
		;;
	sei)
		basic_machine=mips-sei
		os=-seiux
		;;
	sequent)
		basic_machine=i386-sequent
		;;
	sh)
		basic_machine=sh-hitachi
		os=-hms
		;;
	sh5el)
		basic_machine=sh5le-unknown
		;;
	sh64)
		basic_machine=sh64-unknown
		;;
	sparclite-wrs | simso-wrs)
		basic_machine=sparclite-wrs
		os=-vxworks
		;;
	sps7)
		basic_machine=m68k-bull
		os=-sysv2
		;;
	spur)
		basic_machine=spur-unknown
		;;
	st2000)
		basic_machine=m68k-tandem
		;;
	stratus)
		basic_machine=i860-stratus
		os=-sysv4
		;;
	strongarm-* | thumb-*)
		basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
		;;
	sun2)
		basic_machine=m68000-sun
		;;
	sun2os3)
		basic_machine=m68000-sun
		os=-sunos3
		;;
	sun2os4)
		basic_machine=m68000-sun
		os=-sunos4
		;;
	sun3os3)
		basic_machine=m68k-sun
		os=-sunos3
		;;
	sun3os4)
		basic_machine=m68k-sun
		os=-sunos4
		;;
	sun4os3)
		basic_machine=sparc-sun
		os=-sunos3
		;;
	sun4os4)
		basic_machine=sparc-sun
		os=-sunos4
		;;
	sun4sol2)
		basic_machine=sparc-sun
		os=-solaris2
		;;
	sun3 | sun3-*)
		basic_machine=m68k-sun
		;;
	sun4)
		basic_machine=sparc-sun
		;;
	sun386 | sun386i | roadrunner)
		basic_machine=i386-sun
		;;
	sv1)
		basic_machine=sv1-cray
		os=-unicos
		;;
	symmetry)
		basic_machine=i386-sequent
		os=-dynix
		;;
	t3e)
		basic_machine=alphaev5-cray
		os=-unicos
		;;
	t90)
		basic_machine=t90-cray
		os=-unicos
		;;
	tile*)
		basic_machine=$basic_machine-unknown
		os=-linux-gnu
		;;
	tx39)
		basic_machine=mipstx39-unknown
		;;
	tx39el)
		basic_machine=mipstx39el-unknown
		;;
	toad1)
		basic_machine=pdp10-xkl
		os=-tops20
		;;
	tower | tower-32)
		basic_machine=m68k-ncr
		;;
	tpf)
		basic_machine=s390x-ibm
		os=-tpf
		;;
	udi29k)
		basic_machine=a29k-amd
		os=-udi
		;;
	ultra3)
		basic_machine=a29k-nyu
		os=-sym1
		;;
	v810 | necv810)
		basic_machine=v810-nec
		os=-none
		;;
	vaxv)
		basic_machine=vax-dec
		os=-sysv
		;;
	vms)
		basic_machine=vax-dec
		os=-vms
		;;
	vpp*|vx|vx-*)
		basic_machine=f301-fujitsu
		;;
	vxworks960)
		basic_machine=i960-wrs
		os=-vxworks
		;;
	vxworks68)
		basic_machine=m68k-wrs
		os=-vxworks
		;;
	vxworks29k)
		basic_machine=a29k-wrs
		os=-vxworks
		;;
	w65*)
		basic_machine=w65-wdc
		os=-none
		;;
	w89k-*)
		basic_machine=hppa1.1-winbond
		os=-proelf
		;;
	xbox)
		basic_machine=i686-pc
		os=-mingw32
		;;
	xps | xps100)
		basic_machine=xps100-honeywell
		;;
	xscale-* | xscalee[bl]-*)
		basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
		;;
	ymp)
		basic_machine=ymp-cray
		os=-unicos
		;;
	z8k-*-coff)
		basic_machine=z8k-unknown
		os=-sim
		;;
	z80-*-coff)
		basic_machine=z80-unknown
		os=-sim
		;;
	none)
		basic_machine=none-none
		os=-none
		;;

# Here we handle the default manufacturer of certain CPU types.  It is in
# some cases the only manufacturer, in others, it is the most popular.
	w89k)
		basic_machine=hppa1.1-winbond
		;;
	op50n)
		basic_machine=hppa1.1-oki
		;;
	op60c)
		basic_machine=hppa1.1-oki
		;;
	romp)
		basic_machine=romp-ibm
		;;
	mmix)
		basic_machine=mmix-knuth
		;;
	rs6000)
		basic_machine=rs6000-ibm
		;;
	vax)
		basic_machine=vax-dec
		;;
	pdp10)
		# there are many clones, so DEC is not a safe bet
		basic_machine=pdp10-unknown
		;;
	pdp11)
		basic_machine=pdp11-dec
		;;
	we32k)
		basic_machine=we32k-att
		;;
	sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
		basic_machine=sh-unknown
		;;
	sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
		basic_machine=sparc-sun
		;;
	cydra)
		basic_machine=cydra-cydrome
		;;
	orion)
		basic_machine=orion-highlevel
		;;
	orion105)
		basic_machine=clipper-highlevel
		;;
	mac | mpw | mac-mpw)
		basic_machine=m68k-apple
		;;
	pmac | pmac-mpw)
		basic_machine=powerpc-apple
		;;
	*-unknown)
		# Make sure to match an already-canonicalized machine name.
		;;
	*)
		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
		exit 1
		;;
esac

# Here we canonicalize certain aliases for manufacturers.
case $basic_machine in
	*-digital*)
		basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
		;;
	*-commodore*)
		basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
		;;
	*)
		;;
esac

# Decode manufacturer-specific aliases for certain operating systems.

if [ x"$os" != x"" ]
then
case $os in
	# First match some system type aliases
	# that might get confused with valid system types.
	# -solaris* is a basic system type, with this one exception.
	-auroraux)
		os=-auroraux
		;;
	-solaris1 | -solaris1.*)
		os=`echo $os | sed -e 's|solaris1|sunos4|'`
		;;
	-solaris)
		os=-solaris2
		;;
	-svr4*)
		os=-sysv4
		;;
	-unixware*)
		os=-sysv4.2uw
		;;
	-gnu/linux*)
		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
		;;
	# First accept the basic system types.
	# The portable systems comes first.
	# Each alternative MUST END IN A *, to match a version number.
	# -sysv* is not here because it comes later, after sysvr4.
	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
	      | -sym* | -kopensolaris* | -plan9* \
	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
	      | -aos* | -aros* \
	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
	      | -bitrig* | -openbsd* | -solidbsd* \
	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
	      | -chorusos* | -chorusrdb* | -cegcc* \
	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
	      | -uxpv* | -beos* | -mpeix* | -udk* \
	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
	# Remember, each alternative MUST END IN *, to match a version number.
		;;
	-qnx*)
		case $basic_machine in
		    x86-* | i*86-*)
			;;
		    *)
			os=-nto$os
			;;
		esac
		;;
	-nto-qnx*)
		;;
	-nto*)
		os=`echo $os | sed -e 's|nto|nto-qnx|'`
		;;
	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
		;;
	-mac*)
		os=`echo $os | sed -e 's|mac|macos|'`
		;;
	-linux-dietlibc)
		os=-linux-dietlibc
		;;
	-linux*)
		os=`echo $os | sed -e 's|linux|linux-gnu|'`
		;;
	-sunos5*)
		os=`echo $os | sed -e 's|sunos5|solaris2|'`
		;;
	-sunos6*)
		os=`echo $os | sed -e 's|sunos6|solaris3|'`
		;;
	-opened*)
		os=-openedition
		;;
	-os400*)
		os=-os400
		;;
	-wince*)
		os=-wince
		;;
	-osfrose*)
		os=-osfrose
		;;
	-osf*)
		os=-osf
		;;
	-utek*)
		os=-bsd
		;;
	-dynix*)
		os=-bsd
		;;
	-acis*)
		os=-aos
		;;
	-atheos*)
		os=-atheos
		;;
	-syllable*)
		os=-syllable
		;;
	-386bsd)
		os=-bsd
		;;
	-ctix* | -uts*)
		os=-sysv
		;;
	-nova*)
		os=-rtmk-nova
		;;
	-ns2 )
		os=-nextstep2
		;;
	-nsk*)
		os=-nsk
		;;
	# Preserve the version number of sinix5.
	-sinix5.*)
		os=`echo $os | sed -e 's|sinix|sysv|'`
		;;
	-sinix*)
		os=-sysv4
		;;
	-tpf*)
		os=-tpf
		;;
	-triton*)
		os=-sysv3
		;;
	-oss*)
		os=-sysv3
		;;
	-svr4)
		os=-sysv4
		;;
	-svr3)
		os=-sysv3
		;;
	-sysvr4)
		os=-sysv4
		;;
	# This must come after -sysvr4.
	-sysv*)
		;;
	-ose*)
		os=-ose
		;;
	-es1800*)
		os=-ose
		;;
	-xenix)
		os=-xenix
		;;
	-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
		os=-mint
		;;
	-aros*)
		os=-aros
		;;
	-zvmoe)
		os=-zvmoe
		;;
	-dicos*)
		os=-dicos
		;;
	-nacl*)
		;;
	-none)
		;;
	*)
		# Get rid of the `-' at the beginning of $os.
		os=`echo $os | sed 's/[^-]*-//'`
		echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
		exit 1
		;;
esac
else

# Here we handle the default operating systems that come with various machines.
# The value should be what the vendor currently ships out the door with their
# machine or put another way, the most popular os provided with the machine.

# Note that if you're going to try to match "-MANUFACTURER" here (say,
# "-sun"), then you have to tell the case statement up towards the top
# that MANUFACTURER isn't an operating system.  Otherwise, code above
# will signal an error saying that MANUFACTURER isn't an operating
# system, and we'll never get to this point.

case $basic_machine in
	score-*)
		os=-elf
		;;
	spu-*)
		os=-elf
		;;
	*-acorn)
		os=-riscix1.2
		;;
	arm*-rebel)
		os=-linux
		;;
	arm*-semi)
		os=-aout
		;;
	c4x-* | tic4x-*)
		os=-coff
		;;
	c8051-*)
		os=-elf
		;;
	hexagon-*)
		os=-elf
		;;
	tic54x-*)
		os=-coff
		;;
	tic55x-*)
		os=-coff
		;;
	tic6x-*)
		os=-coff
		;;
	# This must come before the *-dec entry.
	pdp10-*)
		os=-tops20
		;;
	pdp11-*)
		os=-none
		;;
	*-dec | vax-*)
		os=-ultrix4.2
		;;
	m68*-apollo)
		os=-domain
		;;
	i386-sun)
		os=-sunos4.0.2
		;;
	m68000-sun)
		os=-sunos3
		;;
	m68*-cisco)
		os=-aout
		;;
	mep-*)
		os=-elf
		;;
	mips*-cisco)
		os=-elf
		;;
	mips*-*)
		os=-elf
		;;
	or1k-*)
		os=-elf
		;;
	or32-*)
		os=-coff
		;;
	*-tti)	# must be before sparc entry or we get the wrong os.
		os=-sysv3
		;;
	sparc-* | *-sun)
		os=-sunos4.1.1
		;;
	*-be)
		os=-beos
		;;
	*-haiku)
		os=-haiku
		;;
	*-ibm)
		os=-aix
		;;
	*-knuth)
		os=-mmixware
		;;
	*-wec)
		os=-proelf
		;;
	*-winbond)
		os=-proelf
		;;
	*-oki)
		os=-proelf
		;;
	*-hp)
		os=-hpux
		;;
	*-hitachi)
		os=-hiux
		;;
	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
		os=-sysv
		;;
	*-cbm)
		os=-amigaos
		;;
	*-dg)
		os=-dgux
		;;
	*-dolphin)
		os=-sysv3
		;;
	m68k-ccur)
		os=-rtu
		;;
	m88k-omron*)
		os=-luna
		;;
	*-next )
		os=-nextstep
		;;
	*-sequent)
		os=-ptx
		;;
	*-crds)
		os=-unos
		;;
	*-ns)
		os=-genix
		;;
	i370-*)
		os=-mvs
		;;
	*-next)
		os=-nextstep3
		;;
	*-gould)
		os=-sysv
		;;
	*-highlevel)
		os=-bsd
		;;
	*-encore)
		os=-bsd
		;;
	*-sgi)
		os=-irix
		;;
	*-siemens)
		os=-sysv4
		;;
	*-masscomp)
		os=-rtu
		;;
	f30[01]-fujitsu | f700-fujitsu)
		os=-uxpv
		;;
	*-rom68k)
		os=-coff
		;;
	*-*bug)
		os=-coff
		;;
	*-apple)
		os=-macos
		;;
	*-atari*)
		os=-mint
		;;
	*)
		os=-none
		;;
esac
fi

# Here we handle the case where we know the os, and the CPU type, but not the
# manufacturer.  We pick the logical manufacturer.
vendor=unknown
case $basic_machine in
	*-unknown)
		case $os in
			-riscix*)
				vendor=acorn
				;;
			-sunos*)
				vendor=sun
				;;
			-cnk*|-aix*)
				vendor=ibm
				;;
			-beos*)
				vendor=be
				;;
			-hpux*)
				vendor=hp
				;;
			-mpeix*)
				vendor=hp
				;;
			-hiux*)
				vendor=hitachi
				;;
			-unos*)
				vendor=crds
				;;
			-dgux*)
				vendor=dg
				;;
			-luna*)
				vendor=omron
				;;
			-genix*)
				vendor=ns
				;;
			-mvs* | -opened*)
				vendor=ibm
				;;
			-os400*)
				vendor=ibm
				;;
			-ptx*)
				vendor=sequent
				;;
			-tpf*)
				vendor=ibm
				;;
			-vxsim* | -vxworks* | -windiss*)
				vendor=wrs
				;;
			-aux*)
				vendor=apple
				;;
			-hms*)
				vendor=hitachi
				;;
			-mpw* | -macos*)
				vendor=apple
				;;
			-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
				vendor=atari
				;;
			-vos*)
				vendor=stratus
				;;
		esac
		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
		;;
esac

echo $basic_machine$os
exit

# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
deps/libressl-pnacl-sys-2.1.6/libressl/install-sh0000555000175000017500000003325512360020752016747 0ustar  #!/bin/sh
# install - install a program, script, or datafile

scriptversion=2011-11-20.07; # UTC

# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.

nl='
'
IFS=" ""	$nl"

# set DOITPROG to echo to test this script

# Don't use :- since 4.3BSD and earlier shells don't like it.
doit=${DOITPROG-}
if test -z "$doit"; then
  doit_exec=exec
else
  doit_exec=$doit
fi

# Put in absolute file names if you don't have them in your path;
# or use environment vars.

chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}

posix_glob='?'
initialize_posix_glob='
  test "$posix_glob" != "?" || {
    if (set -f) 2>/dev/null; then
      posix_glob=
    else
      posix_glob=:
    fi
  }
'

posix_mkdir=

# Desired mode of installed file.
mode=0755

chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=

src=
dst=
dir_arg=
dst_arg=

copy_on_change=false
no_target_directory=

usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
   or: $0 [OPTION]... SRCFILES... DIRECTORY
   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
   or: $0 [OPTION]... -d DIRECTORIES...

In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.

Options:
     --help     display this help and exit.
     --version  display version info and exit.

  -c            (ignored)
  -C            install only if different (preserve the last data modification time)
  -d            create directories instead of installing files.
  -g GROUP      $chgrpprog installed files to GROUP.
  -m MODE       $chmodprog installed files to MODE.
  -o USER       $chownprog installed files to USER.
  -s            $stripprog installed files.
  -t DIRECTORY  install into DIRECTORY.
  -T            report an error if DSTFILE is a directory.

Environment variables override the default commands:
  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
  RMPROG STRIPPROG
"

while test $# -ne 0; do
  case $1 in
    -c) ;;

    -C) copy_on_change=true;;

    -d) dir_arg=true;;

    -g) chgrpcmd="$chgrpprog $2"
	shift;;

    --help) echo "$usage"; exit $?;;

    -m) mode=$2
	case $mode in
	  *' '* | *'	'* | *'
'*	  | *'*'* | *'?'* | *'['*)
	    echo "$0: invalid mode: $mode" >&2
	    exit 1;;
	esac
	shift;;

    -o) chowncmd="$chownprog $2"
	shift;;

    -s) stripcmd=$stripprog;;

    -t) dst_arg=$2
	# Protect names problematic for 'test' and other utilities.
	case $dst_arg in
	  -* | [=\(\)!]) dst_arg=./$dst_arg;;
	esac
	shift;;

    -T) no_target_directory=true;;

    --version) echo "$0 $scriptversion"; exit $?;;

    --)	shift
	break;;

    -*)	echo "$0: invalid option: $1" >&2
	exit 1;;

    *)  break;;
  esac
  shift
done

if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
  # When -d is used, all remaining arguments are directories to create.
  # When -t is used, the destination is already specified.
  # Otherwise, the last argument is the destination.  Remove it from $@.
  for arg
  do
    if test -n "$dst_arg"; then
      # $@ is not empty: it contains at least $arg.
      set fnord "$@" "$dst_arg"
      shift # fnord
    fi
    shift # arg
    dst_arg=$arg
    # Protect names problematic for 'test' and other utilities.
    case $dst_arg in
      -* | [=\(\)!]) dst_arg=./$dst_arg;;
    esac
  done
fi

if test $# -eq 0; then
  if test -z "$dir_arg"; then
    echo "$0: no input file specified." >&2
    exit 1
  fi
  # It's OK to call 'install-sh -d' without argument.
  # This can happen when creating conditional directories.
  exit 0
fi

if test -z "$dir_arg"; then
  do_exit='(exit $ret); exit $ret'
  trap "ret=129; $do_exit" 1
  trap "ret=130; $do_exit" 2
  trap "ret=141; $do_exit" 13
  trap "ret=143; $do_exit" 15

  # Set umask so as not to create temps with too-generous modes.
  # However, 'strip' requires both read and write access to temps.
  case $mode in
    # Optimize common cases.
    *644) cp_umask=133;;
    *755) cp_umask=22;;

    *[0-7])
      if test -z "$stripcmd"; then
	u_plus_rw=
      else
	u_plus_rw='% 200'
      fi
      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
    *)
      if test -z "$stripcmd"; then
	u_plus_rw=
      else
	u_plus_rw=,u+rw
      fi
      cp_umask=$mode$u_plus_rw;;
  esac
fi

for src
do
  # Protect names problematic for 'test' and other utilities.
  case $src in
    -* | [=\(\)!]) src=./$src;;
  esac

  if test -n "$dir_arg"; then
    dst=$src
    dstdir=$dst
    test -d "$dstdir"
    dstdir_status=$?
  else

    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
    # might cause directories to be created, which would be especially bad
    # if $src (and thus $dsttmp) contains '*'.
    if test ! -f "$src" && test ! -d "$src"; then
      echo "$0: $src does not exist." >&2
      exit 1
    fi

    if test -z "$dst_arg"; then
      echo "$0: no destination specified." >&2
      exit 1
    fi
    dst=$dst_arg

    # If destination is a directory, append the input filename; won't work
    # if double slashes aren't ignored.
    if test -d "$dst"; then
      if test -n "$no_target_directory"; then
	echo "$0: $dst_arg: Is a directory" >&2
	exit 1
      fi
      dstdir=$dst
      dst=$dstdir/`basename "$src"`
      dstdir_status=0
    else
      # Prefer dirname, but fall back on a substitute if dirname fails.
      dstdir=`
	(dirname "$dst") 2>/dev/null ||
	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
	     X"$dst" : 'X\(//\)[^/]' \| \
	     X"$dst" : 'X\(//\)$' \| \
	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
	echo X"$dst" |
	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
		   s//\1/
		   q
		 }
		 /^X\(\/\/\)[^/].*/{
		   s//\1/
		   q
		 }
		 /^X\(\/\/\)$/{
		   s//\1/
		   q
		 }
		 /^X\(\/\).*/{
		   s//\1/
		   q
		 }
		 s/.*/./; q'
      `

      test -d "$dstdir"
      dstdir_status=$?
    fi
  fi

  obsolete_mkdir_used=false

  if test $dstdir_status != 0; then
    case $posix_mkdir in
      '')
	# Create intermediate dirs using mode 755 as modified by the umask.
	# This is like FreeBSD 'install' as of 1997-10-28.
	umask=`umask`
	case $stripcmd.$umask in
	  # Optimize common cases.
	  *[2367][2367]) mkdir_umask=$umask;;
	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;

	  *[0-7])
	    mkdir_umask=`expr $umask + 22 \
	      - $umask % 100 % 40 + $umask % 20 \
	      - $umask % 10 % 4 + $umask % 2
	    `;;
	  *) mkdir_umask=$umask,go-w;;
	esac

	# With -d, create the new directory with the user-specified mode.
	# Otherwise, rely on $mkdir_umask.
	if test -n "$dir_arg"; then
	  mkdir_mode=-m$mode
	else
	  mkdir_mode=
	fi

	posix_mkdir=false
	case $umask in
	  *[123567][0-7][0-7])
	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
	    ;;
	  *)
	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0

	    if (umask $mkdir_umask &&
		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
	    then
	      if test -z "$dir_arg" || {
		   # Check for POSIX incompatibilities with -m.
		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
		   # other-writable bit of parent directory when it shouldn't.
		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
		   case $ls_ld_tmpdir in
		     d????-?r-*) different_mode=700;;
		     d????-?--*) different_mode=755;;
		     *) false;;
		   esac &&
		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
		   }
		 }
	      then posix_mkdir=:
	      fi
	      rmdir "$tmpdir/d" "$tmpdir"
	    else
	      # Remove any dirs left behind by ancient mkdir implementations.
	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
	    fi
	    trap '' 0;;
	esac;;
    esac

    if
      $posix_mkdir && (
	umask $mkdir_umask &&
	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
      )
    then :
    else

      # The umask is ridiculous, or mkdir does not conform to POSIX,
      # or it failed possibly due to a race condition.  Create the
      # directory the slow way, step by step, checking for races as we go.

      case $dstdir in
	/*) prefix='/';;
	[-=\(\)!]*) prefix='./';;
	*)  prefix='';;
      esac

      eval "$initialize_posix_glob"

      oIFS=$IFS
      IFS=/
      $posix_glob set -f
      set fnord $dstdir
      shift
      $posix_glob set +f
      IFS=$oIFS

      prefixes=

      for d
      do
	test X"$d" = X && continue

	prefix=$prefix$d
	if test -d "$prefix"; then
	  prefixes=
	else
	  if $posix_mkdir; then
	    (umask=$mkdir_umask &&
	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
	    # Don't fail if two instances are running concurrently.
	    test -d "$prefix" || exit 1
	  else
	    case $prefix in
	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
	      *) qprefix=$prefix;;
	    esac
	    prefixes="$prefixes '$qprefix'"
	  fi
	fi
	prefix=$prefix/
      done

      if test -n "$prefixes"; then
	# Don't fail if two instances are running concurrently.
	(umask $mkdir_umask &&
	 eval "\$doit_exec \$mkdirprog $prefixes") ||
	  test -d "$dstdir" || exit 1
	obsolete_mkdir_used=true
      fi
    fi
  fi

  if test -n "$dir_arg"; then
    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
  else

    # Make a couple of temp file names in the proper directory.
    dsttmp=$dstdir/_inst.$$_
    rmtmp=$dstdir/_rm.$$_

    # Trap to clean up those temp files at exit.
    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0

    # Copy the file name to the temp name.
    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&

    # and set any options; do chmod last to preserve setuid bits.
    #
    # If any of these fail, we abort the whole thing.  If we want to
    # ignore errors from any of these, just make sure not to ignore
    # errors from the above "$doit $cpprog $src $dsttmp" command.
    #
    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&

    # If -C, don't bother to copy if it wouldn't change the file.
    if $copy_on_change &&
       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&

       eval "$initialize_posix_glob" &&
       $posix_glob set -f &&
       set X $old && old=:$2:$4:$5:$6 &&
       set X $new && new=:$2:$4:$5:$6 &&
       $posix_glob set +f &&

       test "$old" = "$new" &&
       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
    then
      rm -f "$dsttmp"
    else
      # Rename the file to the real destination.
      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||

      # The rename failed, perhaps because mv can't rename something else
      # to itself, or perhaps because mv is so ancient that it does not
      # support -f.
      {
	# Now remove or move aside any old file at destination location.
	# We try this two ways since rm can't unlink itself on some
	# systems and the destination file might be busy for other
	# reasons.  In this case, the final cleanup might fail but the new
	# file should still install successfully.
	{
	  test ! -f "$dst" ||
	  $doit $rmcmd -f "$dst" 2>/dev/null ||
	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
	  } ||
	  { echo "$0: cannot unlink or rename $dst" >&2
	    (exit 1); exit 1
	  }
	} &&

	# Now rename the file to the real destination.
	$doit $mvcmd "$dsttmp" "$dst"
      }
    fi || exit 1

    trap '' 0
  fi
done

# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
deps/libressl-pnacl-sys-2.1.6/libressl/COPYING0000644000175000017500000001454412360020705015776 0ustar  
  LibReSSL files are retained under the copyright of the authors. New
  additions are ISC licensed as per OpenBSD's normal licensing policy,
  or are placed in the public domain. 

  The OpenSSL code is distributed under the terms of the original OpenSSL
  licenses which follow:

  LICENSE ISSUES
  ==============

  The OpenSSL toolkit stays under a dual license, i.e. both the conditions of
  the OpenSSL License and the original SSLeay license apply to the toolkit.
  See below for the actual license texts.  In case of any license issues
  related to OpenSSL please contact openssl-core@openssl.org.

  OpenSSL License
  ---------------

/* ====================================================================
 * Copyright (c) 1998-2011 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

 Original SSLeay License
 -----------------------

/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

deps/libressl-pnacl-sys-2.1.6/libressl/compile0000555000175000017500000001624512360020752016321 0ustar  #! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.

scriptversion=2012-10-14.11; # UTC

# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Written by Tom Tromey .
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see .

# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.

# This file is maintained in Automake, please report
# bugs to  or send patches to
# .

nl='
'

# We need space, tab and new line, in precisely that order.  Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" ""	$nl"

file_conv=

# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
  file=$1
  case $file in
    / | /[!/]*) # absolute file, and not a UNC file
      if test -z "$file_conv"; then
	# lazily determine how to convert abs files
	case `uname -s` in
	  MINGW*)
	    file_conv=mingw
	    ;;
	  CYGWIN*)
	    file_conv=cygwin
	    ;;
	  *)
	    file_conv=wine
	    ;;
	esac
      fi
      case $file_conv/,$2, in
	*,$file_conv,*)
	  ;;
	mingw/*)
	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
	  ;;
	cygwin/*)
	  file=`cygpath -m "$file" || echo "$file"`
	  ;;
	wine/*)
	  file=`winepath -w "$file" || echo "$file"`
	  ;;
      esac
      ;;
  esac
}

# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
  func_file_conv "$1"
  if test -z "$lib_path"; then
    lib_path=$file
  else
    lib_path="$lib_path;$file"
  fi
  linker_opts="$linker_opts -LIBPATH:$file"
}

# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
  lib=$1
  found=no
  save_IFS=$IFS
  IFS=';'
  for dir in $lib_path $LIB
  do
    IFS=$save_IFS
    if $shared && test -f "$dir/$lib.dll.lib"; then
      found=yes
      lib=$dir/$lib.dll.lib
      break
    fi
    if test -f "$dir/$lib.lib"; then
      found=yes
      lib=$dir/$lib.lib
      break
    fi
    if test -f "$dir/lib$lib.a"; then
      found=yes
      lib=$dir/lib$lib.a
      break
    fi
  done
  IFS=$save_IFS

  if test "$found" != yes; then
    lib=$lib.lib
  fi
}

# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
  # Assume a capable shell
  lib_path=
  shared=:
  linker_opts=
  for arg
  do
    if test -n "$eat"; then
      eat=
    else
      case $1 in
	-o)
	  # configure might choose to run compile as 'compile cc -o foo foo.c'.
	  eat=1
	  case $2 in
	    *.o | *.[oO][bB][jJ])
	      func_file_conv "$2"
	      set x "$@" -Fo"$file"
	      shift
	      ;;
	    *)
	      func_file_conv "$2"
	      set x "$@" -Fe"$file"
	      shift
	      ;;
	  esac
	  ;;
	-I)
	  eat=1
	  func_file_conv "$2" mingw
	  set x "$@" -I"$file"
	  shift
	  ;;
	-I*)
	  func_file_conv "${1#-I}" mingw
	  set x "$@" -I"$file"
	  shift
	  ;;
	-l)
	  eat=1
	  func_cl_dashl "$2"
	  set x "$@" "$lib"
	  shift
	  ;;
	-l*)
	  func_cl_dashl "${1#-l}"
	  set x "$@" "$lib"
	  shift
	  ;;
	-L)
	  eat=1
	  func_cl_dashL "$2"
	  ;;
	-L*)
	  func_cl_dashL "${1#-L}"
	  ;;
	-static)
	  shared=false
	  ;;
	-Wl,*)
	  arg=${1#-Wl,}
	  save_ifs="$IFS"; IFS=','
	  for flag in $arg; do
	    IFS="$save_ifs"
	    linker_opts="$linker_opts $flag"
	  done
	  IFS="$save_ifs"
	  ;;
	-Xlinker)
	  eat=1
	  linker_opts="$linker_opts $2"
	  ;;
	-*)
	  set x "$@" "$1"
	  shift
	  ;;
	*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
	  func_file_conv "$1"
	  set x "$@" -Tp"$file"
	  shift
	  ;;
	*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
	  func_file_conv "$1" mingw
	  set x "$@" "$file"
	  shift
	  ;;
	*)
	  set x "$@" "$1"
	  shift
	  ;;
      esac
    fi
    shift
  done
  if test -n "$linker_opts"; then
    linker_opts="-link$linker_opts"
  fi
  exec "$@" $linker_opts
  exit 1
}

eat=

case $1 in
  '')
     echo "$0: No command.  Try '$0 --help' for more information." 1>&2
     exit 1;
     ;;
  -h | --h*)
    cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]

Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.

If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.

Report bugs to .
EOF
    exit $?
    ;;
  -v | --v*)
    echo "compile $scriptversion"
    exit $?
    ;;
  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
    func_cl_wrapper "$@"      # Doesn't return...
    ;;
esac

ofile=
cfile=

for arg
do
  if test -n "$eat"; then
    eat=
  else
    case $1 in
      -o)
	# configure might choose to run compile as 'compile cc -o foo foo.c'.
	# So we strip '-o arg' only if arg is an object.
	eat=1
	case $2 in
	  *.o | *.obj)
	    ofile=$2
	    ;;
	  *)
	    set x "$@" -o "$2"
	    shift
	    ;;
	esac
	;;
      *.c)
	cfile=$1
	set x "$@" "$1"
	shift
	;;
      *)
	set x "$@" "$1"
	shift
	;;
    esac
  fi
  shift
done

if test -z "$ofile" || test -z "$cfile"; then
  # If no '-o' option was seen then we might have been invoked from a
  # pattern rule where we don't need one.  That is ok -- this is a
  # normal compilation that the losing compiler can handle.  If no
  # '.c' file was seen then we are probably linking.  That is also
  # ok.
  exec "$@"
fi

# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`

# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file.  Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
  if mkdir "$lockdir" >/dev/null 2>&1; then
    break
  fi
  sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15

# Run the compile.
"$@"
ret=$?

if test -f "$cofile"; then
  test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
  test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi

rmdir "$lockdir"
exit $ret

# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
deps/libressl-pnacl-sys-2.1.6/libressl/missing0000555000175000017500000001533012360020752016334 0ustar  #! /bin/sh
# Common wrapper for a few potentially missing GNU programs.

scriptversion=2013-10-28.13; # UTC

# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard , 1996.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see .

# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.

if test $# -eq 0; then
  echo 1>&2 "Try '$0 --help' for more information"
  exit 1
fi

case $1 in

  --is-lightweight)
    # Used by our autoconf macros to check whether the available missing
    # script is modern enough.
    exit 0
    ;;

  --run)
    # Back-compat with the calling convention used by older automake.
    shift
    ;;

  -h|--h|--he|--hel|--help)
    echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...

Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
to PROGRAM being missing or too old.

Options:
  -h, --help      display this help and exit
  -v, --version   output version information and exit

Supported PROGRAM values:
  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
  bison     yacc      flex         lex       help2man

Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
'g' are ignored when checking the name.

Send bug reports to ."
    exit $?
    ;;

  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
    echo "missing $scriptversion (GNU Automake)"
    exit $?
    ;;

  -*)
    echo 1>&2 "$0: unknown '$1' option"
    echo 1>&2 "Try '$0 --help' for more information"
    exit 1
    ;;

esac

# Run the given program, remember its exit status.
"$@"; st=$?

# If it succeeded, we are done.
test $st -eq 0 && exit 0

# Also exit now if we it failed (or wasn't found), and '--version' was
# passed; such an option is passed most likely to detect whether the
# program is present and works.
case $2 in --version|--help) exit $st;; esac

# Exit code 63 means version mismatch.  This often happens when the user
# tries to use an ancient version of a tool on a file that requires a
# minimum version.
if test $st -eq 63; then
  msg="probably too old"
elif test $st -eq 127; then
  # Program was missing.
  msg="missing on your system"
else
  # Program was found and executed, but failed.  Give up.
  exit $st
fi

perl_URL=http://www.perl.org/
flex_URL=http://flex.sourceforge.net/
gnu_software_URL=http://www.gnu.org/software

program_details ()
{
  case $1 in
    aclocal|automake)
      echo "The '$1' program is part of the GNU Automake package:"
      echo "<$gnu_software_URL/automake>"
      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
      echo "<$gnu_software_URL/autoconf>"
      echo "<$gnu_software_URL/m4/>"
      echo "<$perl_URL>"
      ;;
    autoconf|autom4te|autoheader)
      echo "The '$1' program is part of the GNU Autoconf package:"
      echo "<$gnu_software_URL/autoconf/>"
      echo "It also requires GNU m4 and Perl in order to run:"
      echo "<$gnu_software_URL/m4/>"
      echo "<$perl_URL>"
      ;;
  esac
}

give_advice ()
{
  # Normalize program name to check for.
  normalized_program=`echo "$1" | sed '
    s/^gnu-//; t
    s/^gnu//; t
    s/^g//; t'`

  printf '%s\n' "'$1' is $msg."

  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
  case $normalized_program in
    autoconf*)
      echo "You should only need it if you modified 'configure.ac',"
      echo "or m4 files included by it."
      program_details 'autoconf'
      ;;
    autoheader*)
      echo "You should only need it if you modified 'acconfig.h' or"
      echo "$configure_deps."
      program_details 'autoheader'
      ;;
    automake*)
      echo "You should only need it if you modified 'Makefile.am' or"
      echo "$configure_deps."
      program_details 'automake'
      ;;
    aclocal*)
      echo "You should only need it if you modified 'acinclude.m4' or"
      echo "$configure_deps."
      program_details 'aclocal'
      ;;
   autom4te*)
      echo "You might have modified some maintainer files that require"
      echo "the 'autom4te' program to be rebuilt."
      program_details 'autom4te'
      ;;
    bison*|yacc*)
      echo "You should only need it if you modified a '.y' file."
      echo "You may want to install the GNU Bison package:"
      echo "<$gnu_software_URL/bison/>"
      ;;
    lex*|flex*)
      echo "You should only need it if you modified a '.l' file."
      echo "You may want to install the Fast Lexical Analyzer package:"
      echo "<$flex_URL>"
      ;;
    help2man*)
      echo "You should only need it if you modified a dependency" \
           "of a man page."
      echo "You may want to install the GNU Help2man package:"
      echo "<$gnu_software_URL/help2man/>"
    ;;
    makeinfo*)
      echo "You should only need it if you modified a '.texi' file, or"
      echo "any other file indirectly affecting the aspect of the manual."
      echo "You might want to install the Texinfo package:"
      echo "<$gnu_software_URL/texinfo/>"
      echo "The spurious makeinfo call might also be the consequence of"
      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
      echo "want to install GNU make:"
      echo "<$gnu_software_URL/make/>"
      ;;
    *)
      echo "You might have modified some files without having the proper"
      echo "tools for further handling them.  Check the 'README' file, it"
      echo "often tells you about the needed prerequisites for installing"
      echo "this package.  You may also peek at any GNU archive site, in"
      echo "case some other package contains this missing '$1' program."
      ;;
  esac
}

give_advice "$1" | sed -e '1s/^/WARNING: /' \
                       -e '2,$s/^/         /' >&2

# Propagate the correct exit status (expected to be 127 for a program
# not found, 63 for a program that failed due to version mismatch).
exit $st

# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
deps/libressl-pnacl-sys-2.1.6/libressl/Makefile.am.common0000644000175000017500000000021112360006750020254 0ustar  AM_CPPFLAGS = -I$(top_srcdir)/include
AM_CPPFLAGS += -DOPENSSL_NO_ASM
AM_CPPFLAGS += -DHAVE_CRYPTODEV
AM_CPPFLAGS += -DLIBRESSL_INTERNAL
deps/libressl-pnacl-sys-2.1.6/libressl/INSTALL0000444000175000017500000003661012360020752015772 0ustar  Installation Instructions
*************************

Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
Inc.

   Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.  This file is offered as-is,
without warranty of any kind.

Basic Installation
==================

   Briefly, the shell command `./configure && make && make install'
should configure, build, and install this package.  The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package.  Some packages provide this
`INSTALL' file but do not implement all of the features documented
below.  The lack of an optional feature in a given package is not
necessarily a bug.  More recommendations for GNU packages can be found
in *note Makefile Conventions: (standards)Makefile Conventions.

   The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation.  It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions.  Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').

   It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring.  Caching is
disabled by default to prevent problems with accidental use of stale
cache files.

   If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release.  If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.

   The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'.  You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.

   The simplest way to compile this package is:

  1. `cd' to the directory containing the package's source code and type
     `./configure' to configure the package for your system.

     Running `configure' might take a while.  While running, it prints
     some messages telling which features it is checking for.

  2. Type `make' to compile the package.

  3. Optionally, type `make check' to run any self-tests that come with
     the package, generally using the just-built uninstalled binaries.

  4. Type `make install' to install the programs and any data files and
     documentation.  When installing into a prefix owned by root, it is
     recommended that the package be configured and built as a regular
     user, and only the `make install' phase executed with root
     privileges.

  5. Optionally, type `make installcheck' to repeat any self-tests, but
     this time using the binaries in their final installed location.
     This target does not install anything.  Running this target as a
     regular user, particularly if the prior `make install' required
     root privileges, verifies that the installation completed
     correctly.

  6. You can remove the program binaries and object files from the
     source code directory by typing `make clean'.  To also remove the
     files that `configure' created (so you can compile the package for
     a different kind of computer), type `make distclean'.  There is
     also a `make maintainer-clean' target, but that is intended mainly
     for the package's developers.  If you use it, you may have to get
     all sorts of other programs in order to regenerate files that came
     with the distribution.

  7. Often, you can also type `make uninstall' to remove the installed
     files again.  In practice, not all packages have tested that
     uninstallation works correctly, even though it is required by the
     GNU Coding Standards.

  8. Some packages, particularly those that use Automake, provide `make
     distcheck', which can by used by developers to test that all other
     targets like `make install' and `make uninstall' work correctly.
     This target is generally not run by end users.

Compilers and Options
=====================

   Some systems require unusual options for compilation or linking that
the `configure' script does not know about.  Run `./configure --help'
for details on some of the pertinent environment variables.

   You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment.  Here
is an example:

     ./configure CC=c99 CFLAGS=-g LIBS=-lposix

   *Note Defining Variables::, for more details.

Compiling For Multiple Architectures
====================================

   You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory.  To do this, you can use GNU `make'.  `cd' to the
directory where you want the object files and executables to go and run
the `configure' script.  `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.  This
is known as a "VPATH" build.

   With a non-GNU `make', it is safer to compile the package for one
architecture at a time in the source code directory.  After you have
installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture.

   On MacOS X 10.5 and later systems, you can create libraries and
executables that work on multiple system types--known as "fat" or
"universal" binaries--by specifying multiple `-arch' options to the
compiler but only a single `-arch' option to the preprocessor.  Like
this:

     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
                 CPP="gcc -E" CXXCPP="g++ -E"

   This is not guaranteed to produce working output in all cases, you
may have to build one architecture at a time and combine the results
using the `lipo' tool if you have problems.

Installation Names
==================

   By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc.  You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX', where PREFIX must be an
absolute file name.

   You can specify separate installation prefixes for
architecture-specific files and architecture-independent files.  If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.

   In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files.  Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.  In general, the
default for these options is expressed in terms of `${prefix}', so that
specifying just `--prefix' will affect all of the other directory
specifications that were not explicitly provided.

   The most portable way to affect installation locations is to pass the
correct locations to `configure'; however, many packages provide one or
both of the following shortcuts of passing variable assignments to the
`make install' command line to change installation locations without
having to reconfigure or recompile.

   The first method involves providing an override variable for each
affected directory.  For example, `make install
prefix=/alternate/directory' will choose an alternate location for all
directory configuration variables that were expressed in terms of
`${prefix}'.  Any directories that were specified during `configure',
but not in terms of `${prefix}', must each be overridden at install
time for the entire installation to be relocated.  The approach of
makefile variable overrides for each directory variable is required by
the GNU Coding Standards, and ideally causes no recompilation.
However, some platforms have known limitations with the semantics of
shared libraries that end up requiring recompilation when using this
method, particularly noticeable in packages that use GNU Libtool.

   The second method involves providing the `DESTDIR' variable.  For
example, `make install DESTDIR=/alternate/directory' will prepend
`/alternate/directory' before all installation names.  The approach of
`DESTDIR' overrides is not required by the GNU Coding Standards, and
does not work on platforms that have drive letters.  On the other hand,
it does better at avoiding recompilation issues, and works well even
when some directory options were not specified in terms of `${prefix}'
at `configure' time.

Optional Features
=================

   If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.

   Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System).  The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.

   For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.

   Some packages offer the ability to configure how verbose the
execution of `make' will be.  For these packages, running `./configure
--enable-silent-rules' sets the default to minimal output, which can be
overridden with `make V=1'; while running `./configure
--disable-silent-rules' sets the default to verbose, which can be
overridden with `make V=0'.

Particular systems
==================

   On HP-UX, the default C compiler is not ANSI C compatible.  If GNU
CC is not installed, it is recommended to use the following options in
order to use an ANSI C compiler:

     ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"

and if that doesn't work, install pre-built binaries of GCC for HP-UX.

   HP-UX `make' updates targets which have the same time stamps as
their prerequisites, which makes it generally unusable when shipped
generated files such as `configure' are involved.  Use GNU `make'
instead.

   On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its `' header file.  The option `-nodtk' can be used as
a workaround.  If GNU CC is not installed, it is therefore recommended
to try

     ./configure CC="cc"

and if that doesn't work, try

     ./configure CC="cc -nodtk"

   On Solaris, don't put `/usr/ucb' early in your `PATH'.  This
directory contains several dysfunctional programs; working variants of
these programs are available in `/usr/bin'.  So, if you need `/usr/ucb'
in your `PATH', put it _after_ `/usr/bin'.

   On Haiku, software installed for all users goes in `/boot/common',
not `/usr/local'.  It is recommended to use the following options:

     ./configure --prefix=/boot/common

Specifying the System Type
==========================

   There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on.  Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option.  TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:

     CPU-COMPANY-SYSTEM

where SYSTEM can have one of these forms:

     OS
     KERNEL-OS

   See the file `config.sub' for the possible values of each field.  If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.

   If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.

   If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.

Sharing Defaults
================

   If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists.  Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.

Defining Variables
==================

   Variables not defined in a site shell script can be set in the
environment passed to `configure'.  However, some packages may run
configure again during the build, and the customized values of these
variables may be lost.  In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'.  For example:

     ./configure CC=/usr/local2/bin/gcc

causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).

Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf limitation.  Until the limitation is lifted, you can use
this workaround:

     CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash

`configure' Invocation
======================

   `configure' recognizes the following options to control how it
operates.

`--help'
`-h'
     Print a summary of all of the options to `configure', and exit.

`--help=short'
`--help=recursive'
     Print a summary of the options unique to this package's
     `configure', and exit.  The `short' variant lists options used
     only in the top level, while the `recursive' variant lists options
     also present in any nested packages.

`--version'
`-V'
     Print the version of Autoconf used to generate the `configure'
     script, and exit.

`--cache-file=FILE'
     Enable the cache: use and save the results of the tests in FILE,
     traditionally `config.cache'.  FILE defaults to `/dev/null' to
     disable caching.

`--config-cache'
`-C'
     Alias for `--cache-file=config.cache'.

`--quiet'
`--silent'
`-q'
     Do not print messages saying which checks are being made.  To
     suppress all normal output, redirect it to `/dev/null' (any error
     messages will still be shown).

`--srcdir=DIR'
     Look for the package's source code in directory DIR.  Usually
     `configure' can determine that directory automatically.

`--prefix=DIR'
     Use DIR as the installation prefix.  *note Installation Names::
     for more details, including other options available for fine-tuning
     the installation locations.

`--no-create'
`-n'
     Run the configure checks, but stop before creating any output
     files.

`configure' also accepts some other, not widely useful, options.  Run
`configure --help' for more details.
deps/libressl-pnacl-sys-2.1.6/libressl/include/0000755000000000000000000000000012666635521020155 5ustar  rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/include/Makefile.am0000644000175000017500000000027712357521735020437 0ustar  SUBDIRS = openssl

noinst_HEADERS = pqueue.h
noinst_HEADERS += stdlib.h
noinst_HEADERS += string.h
noinst_HEADERS += unistd.h
noinst_HEADERS += machine/endian.h
noinst_HEADERS += sys/types.h
deps/libressl-pnacl-sys-2.1.6/libressl/include/Makefile.in0000664000175000017500000004432612437255271020453 0ustar  # Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@

# Copyright (C) 1994-2013 Free Software Foundation, Inc.

# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.

@SET_MAKE@

VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
  case $${target_option-} in \
      ?) ;; \
      *) echo "am__make_running_with_option: internal error: invalid" \
              "target option '$${target_option-}' specified" >&2; \
         exit 1;; \
  esac; \
  has_opt=no; \
  sane_makeflags=$$MAKEFLAGS; \
  if $(am__is_gnu_make); then \
    sane_makeflags=$$MFLAGS; \
  else \
    case $$MAKEFLAGS in \
      *\\[\ \	]*) \
        bs=\\; \
        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
    esac; \
  fi; \
  skip_next=no; \
  strip_trailopt () \
  { \
    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
  }; \
  for flg in $$sane_makeflags; do \
    test $$skip_next = yes && { skip_next=no; continue; }; \
    case $$flg in \
      *=*|--*) continue;; \
        -*I) strip_trailopt 'I'; skip_next=yes;; \
      -*I?*) strip_trailopt 'I';; \
        -*O) strip_trailopt 'O'; skip_next=yes;; \
      -*O?*) strip_trailopt 'O';; \
        -*l) strip_trailopt 'l'; skip_next=yes;; \
      -*l?*) strip_trailopt 'l';; \
      -[dEDm]) skip_next=yes;; \
      -[JT]) skip_next=yes;; \
    esac; \
    case $$flg in \
      *$$target_option*) has_opt=yes; break;; \
    esac; \
  done; \
  test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = include
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
	$(noinst_HEADERS)
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
	$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
	$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo "  GEN     " $@;
am__v_GEN_1 = 
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 = 
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
	ctags-recursive dvi-recursive html-recursive info-recursive \
	install-data-recursive install-dvi-recursive \
	install-exec-recursive install-html-recursive \
	install-info-recursive install-pdf-recursive \
	install-ps-recursive install-recursive installcheck-recursive \
	installdirs-recursive pdf-recursive ps-recursive \
	tags-recursive uninstall-recursive
am__can_run_installinfo = \
  case $$AM_UPDATE_INFO_DIR in \
    n|no|NO) false;; \
    *) (install-info --version) >/dev/null 2>&1;; \
  esac
HEADERS = $(noinst_HEADERS)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
  distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
  $(RECURSIVE_TARGETS) \
  $(RECURSIVE_CLEAN_TARGETS) \
  $(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
	distdir
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates.  Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
  BEGIN { nonempty = 0; } \
  { items[$$0] = 1; nonempty = 1; } \
  END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique.  This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
  list='$(am__tagged_files)'; \
  unique=`for i in $$list; do \
    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
  done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
am__relativize = \
  dir0=`pwd`; \
  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
  sed_rest='s,^[^/]*/*,,'; \
  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
  sed_butlast='s,/*[^/]*$$,,'; \
  while test -n "$$dir1"; do \
    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
    if test "$$first" != "."; then \
      if test "$$first" = ".."; then \
        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
      else \
        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
        if test "$$first2" = "$$first"; then \
          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
        else \
          dir2="../$$dir2"; \
        fi; \
        dir0="$$dir0"/"$$first"; \
      fi; \
    fi; \
    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
  done; \
  reldir="$$dir2"
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
NO_ARC4RANDOM_BUF = @NO_ARC4RANDOM_BUF@
NO_GETENTROPY = @NO_GETENTROPY@
NO_ISSETUGID = @NO_ISSETUGID@
NO_REALLOCARRAY = @NO_REALLOCARRAY@
NO_STRLCAT = @NO_STRLCAT@
NO_STRLCPY = @NO_STRLCPY@
NO_STRTONUM = @NO_STRTONUM@
NO_TIMINGSAFE_BCMP = @NO_TIMINGSAFE_BCMP@
NO_TIMINGSAFE_MEMCMP = @NO_TIMINGSAFE_MEMCMP@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PLATFORM_LDADD = @PLATFORM_LDADD@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
USER_CFLAGS = @USER_CFLAGS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = openssl
noinst_HEADERS = pqueue.h stdlib.h string.h unistd.h machine/endian.h \
	sys/types.h
all: all-recursive

.SUFFIXES:
$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
	@for dep in $?; do \
	  case '$(am__configure_deps)' in \
	    *$$dep*) \
	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
	        && { if test -f $@; then exit 0; else break; fi; }; \
	      exit 1;; \
	  esac; \
	done; \
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/Makefile'; \
	$(am__cd) $(top_srcdir) && \
	  $(AUTOMAKE) --gnu include/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
	@case '$?' in \
	  *config.status*) \
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
	  *) \
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
	esac;

$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh

$(top_srcdir)/configure:  $(am__configure_deps)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):

mostlyclean-libtool:
	-rm -f *.lo

clean-libtool:
	-rm -rf .libs _libs

# This directory's subdirectories are mostly independent; you can cd
# into them and run 'make' without going through this Makefile.
# To change the values of 'make' variables: instead of editing Makefiles,
# (1) if the variable is set in 'config.status', edit 'config.status'
#     (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
$(am__recursive_targets):
	@fail=; \
	if $(am__make_keepgoing); then \
	  failcom='fail=yes'; \
	else \
	  failcom='exit 1'; \
	fi; \
	dot_seen=no; \
	target=`echo $@ | sed s/-recursive//`; \
	case "$@" in \
	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
	  *) list='$(SUBDIRS)' ;; \
	esac; \
	for subdir in $$list; do \
	  echo "Making $$target in $$subdir"; \
	  if test "$$subdir" = "."; then \
	    dot_seen=yes; \
	    local_target="$$target-am"; \
	  else \
	    local_target="$$target"; \
	  fi; \
	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
	  || eval $$failcom; \
	done; \
	if test "$$dot_seen" = "no"; then \
	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
	fi; test -z "$$fail"

ID: $(am__tagged_files)
	$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-recursive
TAGS: tags

tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
	set x; \
	here=`pwd`; \
	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
	  include_option=--etags-include; \
	  empty_fix=.; \
	else \
	  include_option=--include; \
	  empty_fix=; \
	fi; \
	list='$(SUBDIRS)'; for subdir in $$list; do \
	  if test "$$subdir" = .; then :; else \
	    test ! -f $$subdir/TAGS || \
	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
	  fi; \
	done; \
	$(am__define_uniq_tagged_files); \
	shift; \
	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
	  test -n "$$unique" || unique=$$empty_fix; \
	  if test $$# -gt 0; then \
	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
	      "$$@" $$unique; \
	  else \
	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
	      $$unique; \
	  fi; \
	fi
ctags: ctags-recursive

CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
	$(am__define_uniq_tagged_files); \
	test -z "$(CTAGS_ARGS)$$unique" \
	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
	     $$unique

GTAGS:
	here=`$(am__cd) $(top_builddir) && pwd` \
	  && $(am__cd) $(top_srcdir) \
	  && gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-recursive

cscopelist-am: $(am__tagged_files)
	list='$(am__tagged_files)'; \
	case "$(srcdir)" in \
	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
	  *) sdir=$(subdir)/$(srcdir) ;; \
	esac; \
	for i in $$list; do \
	  if test -f "$$i"; then \
	    echo "$(subdir)/$$i"; \
	  else \
	    echo "$$sdir/$$i"; \
	  fi; \
	done >> $(top_builddir)/cscope.files

distclean-tags:
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags

distdir: $(DISTFILES)
	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
	list='$(DISTFILES)'; \
	  dist_files=`for file in $$list; do echo $$file; done | \
	  sed -e "s|^$$srcdirstrip/||;t" \
	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
	case $$dist_files in \
	  */*) $(MKDIR_P) `echo "$$dist_files" | \
			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
			   sort -u` ;; \
	esac; \
	for file in $$dist_files; do \
	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
	  if test -d $$d/$$file; then \
	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
	    if test -d "$(distdir)/$$file"; then \
	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
	    fi; \
	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
	    fi; \
	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
	  else \
	    test -f "$(distdir)/$$file" \
	    || cp -p $$d/$$file "$(distdir)/$$file" \
	    || exit 1; \
	  fi; \
	done
	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
	  if test "$$subdir" = .; then :; else \
	    $(am__make_dryrun) \
	      || test -d "$(distdir)/$$subdir" \
	      || $(MKDIR_P) "$(distdir)/$$subdir" \
	      || exit 1; \
	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
	    $(am__relativize); \
	    new_distdir=$$reldir; \
	    dir1=$$subdir; dir2="$(top_distdir)"; \
	    $(am__relativize); \
	    new_top_distdir=$$reldir; \
	    echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
	    echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
	    ($(am__cd) $$subdir && \
	      $(MAKE) $(AM_MAKEFLAGS) \
	        top_distdir="$$new_top_distdir" \
	        distdir="$$new_distdir" \
		am__remove_distdir=: \
		am__skip_length_check=: \
		am__skip_mode_fix=: \
	        distdir) \
	      || exit 1; \
	  fi; \
	done
check-am: all-am
check: check-recursive
all-am: Makefile $(HEADERS)
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive

install-am: all-am
	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am

installcheck: installcheck-recursive
install-strip:
	if test -z '$(STRIP)'; then \
	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
	      install; \
	else \
	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
	fi
mostlyclean-generic:

clean-generic:

distclean-generic:
	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)

maintainer-clean-generic:
	@echo "This command is intended for maintainers to use"
	@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive

clean-am: clean-generic clean-libtool mostlyclean-am

distclean: distclean-recursive
	-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags

dvi: dvi-recursive

dvi-am:

html: html-recursive

html-am:

info: info-recursive

info-am:

install-data-am:

install-dvi: install-dvi-recursive

install-dvi-am:

install-exec-am:

install-html: install-html-recursive

install-html-am:

install-info: install-info-recursive

install-info-am:

install-man:

install-pdf: install-pdf-recursive

install-pdf-am:

install-ps: install-ps-recursive

install-ps-am:

installcheck-am:

maintainer-clean: maintainer-clean-recursive
	-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic

mostlyclean: mostlyclean-recursive

mostlyclean-am: mostlyclean-generic mostlyclean-libtool

pdf: pdf-recursive

pdf-am:

ps: ps-recursive

ps-am:

uninstall-am:

.MAKE: $(am__recursive_targets) install-am install-strip

.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
	check-am clean clean-generic clean-libtool cscopelist-am ctags \
	ctags-am distclean distclean-generic distclean-libtool \
	distclean-tags distdir dvi dvi-am html html-am info info-am \
	install install-am install-data install-data-am install-dvi \
	install-dvi-am install-exec install-exec-am install-html \
	install-html-am install-info install-info-am install-man \
	install-pdf install-pdf-am install-ps install-ps-am \
	install-strip installcheck installcheck-am installdirs \
	installdirs-am maintainer-clean maintainer-clean-generic \
	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
	ps ps-am tags tags-am uninstall uninstall-am


# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/0000755000000000000000000000000012666635521021640 5ustar  rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/ecdsa.h0000644000175000017500000002440312360020705021274 0ustar  /* $OpenBSD$ */
/**
 * \file   crypto/ecdsa/ecdsa.h Include file for the OpenSSL ECDSA functions
 * \author Written by Nils Larsch for the OpenSSL project
 */
/* ====================================================================
 * Copyright (c) 2000-2005 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */
#ifndef HEADER_ECDSA_H
#define HEADER_ECDSA_H

#include 

#ifdef OPENSSL_NO_ECDSA
#error ECDSA is disabled.
#endif

#include 
#include 
#ifndef OPENSSL_NO_DEPRECATED
#include 
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef struct ECDSA_SIG_st
	{
	BIGNUM *r;
	BIGNUM *s;
	} ECDSA_SIG;

/** Allocates and initialize a ECDSA_SIG structure
 *  \return pointer to a ECDSA_SIG structure or NULL if an error occurred
 */
ECDSA_SIG *ECDSA_SIG_new(void);

/** frees a ECDSA_SIG structure
 *  \param  sig  pointer to the ECDSA_SIG structure
 */
void	  ECDSA_SIG_free(ECDSA_SIG *sig);

/** DER encode content of ECDSA_SIG object (note: this function modifies *pp
 *  (*pp += length of the DER encoded signature)).
 *  \param  sig  pointer to the ECDSA_SIG object
 *  \param  pp   pointer to a unsigned char pointer for the output or NULL
 *  \return the length of the DER encoded ECDSA_SIG object or 0 
 */
int	  i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp);

/** Decodes a DER encoded ECDSA signature (note: this function changes *pp
 *  (*pp += len)). 
 *  \param  sig  pointer to ECDSA_SIG pointer (may be NULL)
 *  \param  pp   memory buffer with the DER encoded signature
 *  \param  len  length of the buffer
 *  \return pointer to the decoded ECDSA_SIG structure (or NULL)
 */
ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len);

/** Computes the ECDSA signature of the given hash value using
 *  the supplied private key and returns the created signature.
 *  \param  dgst      pointer to the hash value
 *  \param  dgst_len  length of the hash value
 *  \param  eckey     EC_KEY object containing a private EC key
 *  \return pointer to a ECDSA_SIG structure or NULL if an error occurred
 */
ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,int dgst_len,EC_KEY *eckey);

/** Computes ECDSA signature of a given hash value using the supplied
 *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
 *  \param  dgst     pointer to the hash value to sign
 *  \param  dgstlen  length of the hash value
 *  \param  kinv     BIGNUM with a pre-computed inverse k (optional)
 *  \param  rp       BIGNUM with a pre-computed rp value (optioanl), 
 *                   see ECDSA_sign_setup
 *  \param  eckey    EC_KEY object containing a private EC key
 *  \return pointer to a ECDSA_SIG structure or NULL if an error occurred
 */
ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, 
		const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey);

/** Verifies that the supplied signature is a valid ECDSA
 *  signature of the supplied hash value using the supplied public key.
 *  \param  dgst      pointer to the hash value
 *  \param  dgst_len  length of the hash value
 *  \param  sig       ECDSA_SIG structure
 *  \param  eckey     EC_KEY object containing a public EC key
 *  \return 1 if the signature is valid, 0 if the signature is invalid
 *          and -1 on error
 */
int	  ECDSA_do_verify(const unsigned char *dgst, int dgst_len,
		const ECDSA_SIG *sig, EC_KEY* eckey);

const ECDSA_METHOD *ECDSA_OpenSSL(void);

/** Sets the default ECDSA method
 *  \param  meth  new default ECDSA_METHOD
 */
void	  ECDSA_set_default_method(const ECDSA_METHOD *meth);

/** Returns the default ECDSA method
 *  \return pointer to ECDSA_METHOD structure containing the default method
 */
const ECDSA_METHOD *ECDSA_get_default_method(void);

/** Sets method to be used for the ECDSA operations
 *  \param  eckey  EC_KEY object
 *  \param  meth   new method
 *  \return 1 on success and 0 otherwise 
 */
int 	  ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth);

/** Returns the maximum length of the DER encoded signature
 *  \param  eckey  EC_KEY object
 *  \return numbers of bytes required for the DER encoded signature
 */
int	  ECDSA_size(const EC_KEY *eckey);

/** Precompute parts of the signing operation
 *  \param  eckey  EC_KEY object containing a private EC key
 *  \param  ctx    BN_CTX object (optional)
 *  \param  kinv   BIGNUM pointer for the inverse of k
 *  \param  rp     BIGNUM pointer for x coordinate of k * generator
 *  \return 1 on success and 0 otherwise
 */
int 	  ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, 
		BIGNUM **rp);

/** Computes ECDSA signature of a given hash value using the supplied
 *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
 *  \param  type     this parameter is ignored
 *  \param  dgst     pointer to the hash value to sign
 *  \param  dgstlen  length of the hash value
 *  \param  sig      memory for the DER encoded created signature
 *  \param  siglen   pointer to the length of the returned signature
 *  \param  eckey    EC_KEY object containing a private EC key
 *  \return 1 on success and 0 otherwise
 */
int	  ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, 
		unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);


/** Computes ECDSA signature of a given hash value using the supplied
 *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).
 *  \param  type     this parameter is ignored
 *  \param  dgst     pointer to the hash value to sign
 *  \param  dgstlen  length of the hash value
 *  \param  sig      buffer to hold the DER encoded signature
 *  \param  siglen   pointer to the length of the returned signature
 *  \param  kinv     BIGNUM with a pre-computed inverse k (optional)
 *  \param  rp       BIGNUM with a pre-computed rp value (optioanl), 
 *                   see ECDSA_sign_setup
 *  \param  eckey    EC_KEY object containing a private EC key
 *  \return 1 on success and 0 otherwise
 */
int	  ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen, 
		unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv,
		const BIGNUM *rp, EC_KEY *eckey);

/** Verifies that the given signature is valid ECDSA signature
 *  of the supplied hash value using the specified public key.
 *  \param  type     this parameter is ignored
 *  \param  dgst     pointer to the hash value 
 *  \param  dgstlen  length of the hash value
 *  \param  sig      pointer to the DER encoded signature
 *  \param  siglen   length of the DER encoded signature
 *  \param  eckey    EC_KEY object containing a public EC key
 *  \return 1 if the signature is valid, 0 if the signature is invalid
 *          and -1 on error
 */
int 	  ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, 
		const unsigned char *sig, int siglen, EC_KEY *eckey);

/* the standard ex_data functions */
int 	  ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new 
		*new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
int 	  ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg);
void 	  *ECDSA_get_ex_data(EC_KEY *d, int idx);


/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_ECDSA_strings(void);

/* Error codes for the ECDSA functions. */

/* Function codes. */
#define ECDSA_F_ECDSA_CHECK				 104
#define ECDSA_F_ECDSA_DATA_NEW_METHOD			 100
#define ECDSA_F_ECDSA_DO_SIGN				 101
#define ECDSA_F_ECDSA_DO_VERIFY				 102
#define ECDSA_F_ECDSA_SIGN_SETUP			 103

/* Reason codes. */
#define ECDSA_R_BAD_SIGNATURE				 100
#define ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE		 101
#define ECDSA_R_ERR_EC_LIB				 102
#define ECDSA_R_MISSING_PARAMETERS			 103
#define ECDSA_R_NEED_NEW_SETUP_VALUES			 106
#define ECDSA_R_NON_FIPS_METHOD				 107
#define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED		 104
#define ECDSA_R_SIGNATURE_MALLOC_FAILED			 105

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/whrlpool.h0000644000175000017500000000177512360020705022072 0ustar  /* $OpenBSD: whrlpool.h,v 1.4 2014/06/12 15:49:31 deraadt Exp $ */

#include 

#ifndef HEADER_WHRLPOOL_H
#define HEADER_WHRLPOOL_H

#include 

#ifdef __cplusplus
extern "C" {
#endif

#define WHIRLPOOL_DIGEST_LENGTH	(512/8)
#define WHIRLPOOL_BBLOCK	512
#define WHIRLPOOL_COUNTER	(256/8)

typedef struct	{
	union	{
		unsigned char	c[WHIRLPOOL_DIGEST_LENGTH];
		/* double q is here to ensure 64-bit alignment */
		double		q[WHIRLPOOL_DIGEST_LENGTH/sizeof(double)];
		}	H;
	unsigned char	data[WHIRLPOOL_BBLOCK/8];
	unsigned int	bitoff;
	size_t		bitlen[WHIRLPOOL_COUNTER/sizeof(size_t)];
	} WHIRLPOOL_CTX;

#ifndef OPENSSL_NO_WHIRLPOOL
int WHIRLPOOL_Init	(WHIRLPOOL_CTX *c);
int WHIRLPOOL_Update	(WHIRLPOOL_CTX *c,const void *inp,size_t bytes);
void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c,const void *inp,size_t bits);
int WHIRLPOOL_Final	(unsigned char *md,WHIRLPOOL_CTX *c);
unsigned char *WHIRLPOOL(const void *inp,size_t bytes,unsigned char *md);
#endif

#ifdef __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/md5.h0000644000175000017500000001034212360020705020677 0ustar  /* $OpenBSD: md5.h,v 1.16 2014/07/10 09:01:04 miod Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#include 

#ifndef HEADER_MD5_H
#define HEADER_MD5_H

#include 

#ifdef  __cplusplus
extern "C" {
#endif

#ifdef OPENSSL_NO_MD5
#error MD5 is disabled.
#endif

/*
 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 * ! MD5_LONG has to be at least 32 bits wide. If it's wider, then !
 * ! MD5_LONG_LOG2 has to be defined along.			   !
 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 */

#define MD5_LONG unsigned int

#define MD5_CBLOCK	64
#define MD5_LBLOCK	(MD5_CBLOCK/4)
#define MD5_DIGEST_LENGTH 16

typedef struct MD5state_st
	{
	MD5_LONG A,B,C,D;
	MD5_LONG Nl,Nh;
	MD5_LONG data[MD5_LBLOCK];
	unsigned int num;
	} MD5_CTX;

int MD5_Init(MD5_CTX *c);
int MD5_Update(MD5_CTX *c, const void *data, size_t len)
	__attribute__ ((__bounded__(__buffer__,2,3)));
int MD5_Final(unsigned char *md, MD5_CTX *c);
unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md)
	__attribute__ ((__bounded__(__buffer__,1,2)));
void MD5_Transform(MD5_CTX *c, const unsigned char *b);
#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/bio.h0000644000175000017500000007715212360020705020777 0ustar  /* $OpenBSD: bio.h,v 1.23 2014/06/12 15:49:28 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_BIO_H
#define HEADER_BIO_H

#include 

# include 
#include 

#include 

#ifndef OPENSSL_NO_SCTP
# include 
#endif

#ifdef  __cplusplus
extern "C" {
#endif

/* These are the 'types' of BIOs */
#define BIO_TYPE_NONE		0
#define BIO_TYPE_MEM		(1|0x0400)
#define BIO_TYPE_FILE		(2|0x0400)

#define BIO_TYPE_FD		(4|0x0400|0x0100)
#define BIO_TYPE_SOCKET		(5|0x0400|0x0100)
#define BIO_TYPE_NULL		(6|0x0400)
#define BIO_TYPE_SSL		(7|0x0200)
#define BIO_TYPE_MD		(8|0x0200)		/* passive filter */
#define BIO_TYPE_BUFFER		(9|0x0200)		/* filter */
#define BIO_TYPE_CIPHER		(10|0x0200)		/* filter */
#define BIO_TYPE_BASE64		(11|0x0200)		/* filter */
#define BIO_TYPE_CONNECT	(12|0x0400|0x0100)	/* socket - connect */
#define BIO_TYPE_ACCEPT		(13|0x0400|0x0100)	/* socket for accept */
#define BIO_TYPE_PROXY_CLIENT	(14|0x0200)		/* client proxy BIO */
#define BIO_TYPE_PROXY_SERVER	(15|0x0200)		/* server proxy BIO */
#define BIO_TYPE_NBIO_TEST	(16|0x0200)		/* server proxy BIO */
#define BIO_TYPE_NULL_FILTER	(17|0x0200)
#define BIO_TYPE_BER		(18|0x0200)		/* BER -> bin filter */
#define BIO_TYPE_BIO		(19|0x0400)		/* (half a) BIO pair */
#define BIO_TYPE_LINEBUFFER	(20|0x0200)		/* filter */
#define BIO_TYPE_DGRAM		(21|0x0400|0x0100)
#ifndef OPENSSL_NO_SCTP
#define BIO_TYPE_DGRAM_SCTP	(24|0x0400|0x0100)
#endif
#define BIO_TYPE_ASN1 		(22|0x0200)		/* filter */
#define BIO_TYPE_COMP 		(23|0x0200)		/* filter */

#define BIO_TYPE_DESCRIPTOR	0x0100	/* socket, fd, connect or accept */
#define BIO_TYPE_FILTER		0x0200
#define BIO_TYPE_SOURCE_SINK	0x0400

/* BIO_FILENAME_READ|BIO_CLOSE to open or close on free.
 * BIO_set_fp(in,stdin,BIO_NOCLOSE); */
#define BIO_NOCLOSE		0x00
#define BIO_CLOSE		0x01

/* These are used in the following macros and are passed to
 * BIO_ctrl() */
#define BIO_CTRL_RESET		1  /* opt - rewind/zero etc */
#define BIO_CTRL_EOF		2  /* opt - are we at the eof */
#define BIO_CTRL_INFO		3  /* opt - extra tit-bits */
#define BIO_CTRL_SET		4  /* man - set the 'IO' type */
#define BIO_CTRL_GET		5  /* man - get the 'IO' type */
#define BIO_CTRL_PUSH		6  /* opt - internal, used to signify change */
#define BIO_CTRL_POP		7  /* opt - internal, used to signify change */
#define BIO_CTRL_GET_CLOSE	8  /* man - set the 'close' on free */
#define BIO_CTRL_SET_CLOSE	9  /* man - set the 'close' on free */
#define BIO_CTRL_PENDING	10  /* opt - is their more data buffered */
#define BIO_CTRL_FLUSH		11  /* opt - 'flush' buffered output */
#define BIO_CTRL_DUP		12  /* man - extra stuff for 'duped' BIO */
#define BIO_CTRL_WPENDING	13  /* opt - number of bytes still to write */
/* callback is int cb(BIO *bio,state,ret); */
#define BIO_CTRL_SET_CALLBACK	14  /* opt - set callback function */
#define BIO_CTRL_GET_CALLBACK	15  /* opt - set callback function */

#define BIO_CTRL_SET_FILENAME	30	/* BIO_s_file special */

/* dgram BIO stuff */
#define BIO_CTRL_DGRAM_CONNECT       31  /* BIO dgram special */
#define BIO_CTRL_DGRAM_SET_CONNECTED 32  /* allow for an externally
					  * connected socket to be
					  * passed in */ 
#define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33 /* setsockopt, essentially */
#define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34 /* getsockopt, essentially */
#define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35 /* setsockopt, essentially */
#define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36 /* getsockopt, essentially */

#define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37 /* flag whether the last */
#define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38 /* I/O operation tiemd out */

/* #ifdef IP_MTU_DISCOVER */
#define BIO_CTRL_DGRAM_MTU_DISCOVER       39 /* set DF bit on egress packets */
/* #endif */

#define BIO_CTRL_DGRAM_QUERY_MTU          40 /* as kernel for current MTU */
#define BIO_CTRL_DGRAM_GET_FALLBACK_MTU   47
#define BIO_CTRL_DGRAM_GET_MTU            41 /* get cached value for MTU */
#define BIO_CTRL_DGRAM_SET_MTU            42 /* set cached value for
					      * MTU. want to use this
					      * if asking the kernel
					      * fails */

#define BIO_CTRL_DGRAM_MTU_EXCEEDED       43 /* check whether the MTU
					      * was exceed in the
					      * previous write
					      * operation */

#define BIO_CTRL_DGRAM_GET_PEER           46
#define BIO_CTRL_DGRAM_SET_PEER           44 /* Destination for the data */

#define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT   45 /* Next DTLS handshake timeout to
                                              * adjust socket timeouts */

#ifndef OPENSSL_NO_SCTP
/* SCTP stuff */
#define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE	50
#define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY		51
#define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY		52
#define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD		53
#define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO		60
#define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO		61
#define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO		62
#define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO		63
#define BIO_CTRL_DGRAM_SCTP_GET_PRINFO			64
#define BIO_CTRL_DGRAM_SCTP_SET_PRINFO			65
#define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN		70
#endif

/* modifiers */
#define BIO_FP_READ		0x02
#define BIO_FP_WRITE		0x04
#define BIO_FP_APPEND		0x08
#define BIO_FP_TEXT		0x10

#define BIO_FLAGS_READ		0x01
#define BIO_FLAGS_WRITE		0x02
#define BIO_FLAGS_IO_SPECIAL	0x04
#define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
#define BIO_FLAGS_SHOULD_RETRY	0x08

/* Used in BIO_gethostbyname() */
#define BIO_GHBN_CTRL_HITS		1
#define BIO_GHBN_CTRL_MISSES		2
#define BIO_GHBN_CTRL_CACHE_SIZE	3
#define BIO_GHBN_CTRL_GET_ENTRY		4
#define BIO_GHBN_CTRL_FLUSH		5

/* Mostly used in the SSL BIO */
/* Not used anymore
 * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10
 * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20
 * #define BIO_FLAGS_PROTOCOL_STARTUP	0x40
 */

#define BIO_FLAGS_BASE64_NO_NL	0x100

/* This is used with memory BIOs: it means we shouldn't free up or change the
 * data in any way.
 */
#define BIO_FLAGS_MEM_RDONLY	0x200

typedef struct bio_st BIO;

void BIO_set_flags(BIO *b, int flags);
int  BIO_test_flags(const BIO *b, int flags);
void BIO_clear_flags(BIO *b, int flags);

#define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))
#define BIO_set_retry_special(b) \
		BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))
#define BIO_set_retry_read(b) \
		BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
#define BIO_set_retry_write(b) \
		BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))

/* These are normally used internally in BIOs */
#define BIO_clear_retry_flags(b) \
		BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
#define BIO_get_retry_flags(b) \
		BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))

/* These should be used by the application to tell why we should retry */
#define BIO_should_read(a)		BIO_test_flags(a, BIO_FLAGS_READ)
#define BIO_should_write(a)		BIO_test_flags(a, BIO_FLAGS_WRITE)
#define BIO_should_io_special(a)	BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)
#define BIO_retry_type(a)		BIO_test_flags(a, BIO_FLAGS_RWS)
#define BIO_should_retry(a)		BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)

/* The next three are used in conjunction with the
 * BIO_should_io_special() condition.  After this returns true,
 * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO 
 * stack and return the 'reason' for the special and the offending BIO.
 * Given a BIO, BIO_get_retry_reason(bio) will return the code. */
/* Returned from the SSL bio when the certificate retrieval code had an error */
#define BIO_RR_SSL_X509_LOOKUP		0x01
/* Returned from the connect BIO when a connect would have blocked */
#define BIO_RR_CONNECT			0x02
/* Returned from the accept BIO when an accept would have blocked */
#define BIO_RR_ACCEPT			0x03

/* These are passed by the BIO callback */
#define BIO_CB_FREE	0x01
#define BIO_CB_READ	0x02
#define BIO_CB_WRITE	0x03
#define BIO_CB_PUTS	0x04
#define BIO_CB_GETS	0x05
#define BIO_CB_CTRL	0x06

/* The callback is called before and after the underling operation,
 * The BIO_CB_RETURN flag indicates if it is after the call */
#define BIO_CB_RETURN	0x80
#define BIO_CB_return(a) ((a)|BIO_CB_RETURN))
#define BIO_cb_pre(a)	(!((a)&BIO_CB_RETURN))
#define BIO_cb_post(a)	((a)&BIO_CB_RETURN)

long (*BIO_get_callback(const BIO *b))(struct bio_st *, int, const char *,
    int, long, long);
void BIO_set_callback(BIO *b,
    long (*callback)(struct bio_st *, int, const char *, int, long, long));
char *BIO_get_callback_arg(const BIO *b);
void BIO_set_callback_arg(BIO *b, char *arg);

const char * BIO_method_name(const BIO *b);
int BIO_method_type(const BIO *b);

typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long);

typedef struct bio_method_st {
	int type;
	const char *name;
	int (*bwrite)(BIO *, const char *, int);
	int (*bread)(BIO *, char *, int);
	int (*bputs)(BIO *, const char *);
	int (*bgets)(BIO *, char *, int);
	long (*ctrl)(BIO *, int, long, void *);
	int (*create)(BIO *);
	int (*destroy)(BIO *);
	long (*callback_ctrl)(BIO *, int, bio_info_cb *);
} BIO_METHOD;

struct bio_st {
	BIO_METHOD *method;
	/* bio, mode, argp, argi, argl, ret */
	long (*callback)(struct bio_st *, int, const char *, int, long, long);
	char *cb_arg; /* first argument for the callback */

	int init;
	int shutdown;
	int flags;	/* extra storage */
	int retry_reason;
	int num;
	void *ptr;
	struct bio_st *next_bio;	/* used by filter BIOs */
	struct bio_st *prev_bio;	/* used by filter BIOs */
	int references;
	unsigned long num_read;
	unsigned long num_write;

	CRYPTO_EX_DATA ex_data;
};

DECLARE_STACK_OF(BIO)

typedef struct bio_f_buffer_ctx_struct {
	/* Buffers are setup like this:
	 *
	 * <---------------------- size ----------------------->
	 * +---------------------------------------------------+
	 * | consumed | remaining          | free space        |
	 * +---------------------------------------------------+
	 * <-- off --><------- len ------->
	 */

	/* BIO *bio; */ /* this is now in the BIO struct */
	int ibuf_size;	/* how big is the input buffer */
	int obuf_size;	/* how big is the output buffer */

	char *ibuf;	/* the char array */
	int ibuf_len;	/* how many bytes are in it */
	int ibuf_off;	/* write/read offset */

	char *obuf;	/* the char array */
	int obuf_len;	/* how many bytes are in it */
	int obuf_off;	/* write/read offset */
} BIO_F_BUFFER_CTX;

/* Prefix and suffix callback in ASN1 BIO */
typedef int asn1_ps_func(BIO *b, unsigned char **pbuf, int *plen, void *parg);

#ifndef OPENSSL_NO_SCTP
/* SCTP parameter structs */
struct bio_dgram_sctp_sndinfo {
	uint16_t snd_sid;
	uint16_t snd_flags;
	uint32_t snd_ppid;
	uint32_t snd_context;
};

struct bio_dgram_sctp_rcvinfo {
	uint16_t rcv_sid;
	uint16_t rcv_ssn;
	uint16_t rcv_flags;
	uint32_t rcv_ppid;
	uint32_t rcv_tsn;
	uint32_t rcv_cumtsn;
	uint32_t rcv_context;
};

struct bio_dgram_sctp_prinfo {
	uint16_t pr_policy;
	uint32_t pr_value;
};
#endif

/* connect BIO stuff */
#define BIO_CONN_S_BEFORE		1
#define BIO_CONN_S_GET_IP		2
#define BIO_CONN_S_GET_PORT		3
#define BIO_CONN_S_CREATE_SOCKET	4
#define BIO_CONN_S_CONNECT		5
#define BIO_CONN_S_OK			6
#define BIO_CONN_S_BLOCKED_CONNECT	7
#define BIO_CONN_S_NBIO			8
/*#define BIO_CONN_get_param_hostname	BIO_ctrl */

#define BIO_C_SET_CONNECT			100
#define BIO_C_DO_STATE_MACHINE			101
#define BIO_C_SET_NBIO				102
#define BIO_C_SET_PROXY_PARAM			103
#define BIO_C_SET_FD				104
#define BIO_C_GET_FD				105
#define BIO_C_SET_FILE_PTR			106
#define BIO_C_GET_FILE_PTR			107
#define BIO_C_SET_FILENAME			108
#define BIO_C_SET_SSL				109
#define BIO_C_GET_SSL				110
#define BIO_C_SET_MD				111
#define BIO_C_GET_MD				112
#define BIO_C_GET_CIPHER_STATUS			113
#define BIO_C_SET_BUF_MEM			114
#define BIO_C_GET_BUF_MEM_PTR			115
#define BIO_C_GET_BUFF_NUM_LINES		116
#define BIO_C_SET_BUFF_SIZE			117
#define BIO_C_SET_ACCEPT			118
#define BIO_C_SSL_MODE				119
#define BIO_C_GET_MD_CTX			120
#define BIO_C_GET_PROXY_PARAM			121
#define BIO_C_SET_BUFF_READ_DATA		122 /* data to read first */
#define BIO_C_GET_CONNECT			123
#define BIO_C_GET_ACCEPT			124
#define BIO_C_SET_SSL_RENEGOTIATE_BYTES		125
#define BIO_C_GET_SSL_NUM_RENEGOTIATES		126
#define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT	127
#define BIO_C_FILE_SEEK				128
#define BIO_C_GET_CIPHER_CTX			129
#define BIO_C_SET_BUF_MEM_EOF_RETURN		130/*return end of input value*/
#define BIO_C_SET_BIND_MODE			131
#define BIO_C_GET_BIND_MODE			132
#define BIO_C_FILE_TELL				133
#define BIO_C_GET_SOCKS				134
#define BIO_C_SET_SOCKS				135

#define BIO_C_SET_WRITE_BUF_SIZE		136/* for BIO_s_bio */
#define BIO_C_GET_WRITE_BUF_SIZE		137
#define BIO_C_MAKE_BIO_PAIR			138
#define BIO_C_DESTROY_BIO_PAIR			139
#define BIO_C_GET_WRITE_GUARANTEE		140
#define BIO_C_GET_READ_REQUEST			141
#define BIO_C_SHUTDOWN_WR			142
#define BIO_C_NREAD0				143
#define BIO_C_NREAD				144
#define BIO_C_NWRITE0				145
#define BIO_C_NWRITE				146
#define BIO_C_RESET_READ_REQUEST		147
#define BIO_C_SET_MD_CTX			148

#define BIO_C_SET_PREFIX			149
#define BIO_C_GET_PREFIX			150
#define BIO_C_SET_SUFFIX			151
#define BIO_C_GET_SUFFIX			152

#define BIO_C_SET_EX_ARG			153
#define BIO_C_GET_EX_ARG			154

#define BIO_set_app_data(s,arg)		BIO_set_ex_data(s,0,arg)
#define BIO_get_app_data(s)		BIO_get_ex_data(s,0)

/* BIO_s_connect() and BIO_s_socks4a_connect() */
#define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name)
#define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port)
#define BIO_set_conn_ip(b,ip)	  BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip)
#define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)
#define BIO_get_conn_hostname(b)  BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
#define BIO_get_conn_port(b)      BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
#define BIO_get_conn_ip(b) 		 BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)
#define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3,0)


#define BIO_set_nbio(b,n)	BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)

/* BIO_s_accept_socket() */
#define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name)
#define BIO_get_accept_port(b)	BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)
/* #define BIO_set_nbio(b,n)	BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */
#define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?(void *)"a":NULL)
#define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio)

#define BIO_BIND_NORMAL			0
#define BIO_BIND_REUSEADDR_IF_UNUSED	1
#define BIO_BIND_REUSEADDR		2
#define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)
#define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)

#define BIO_do_connect(b)	BIO_do_handshake(b)
#define BIO_do_accept(b)	BIO_do_handshake(b)
#define BIO_do_handshake(b)	BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)

/* BIO_s_proxy_client() */
#define BIO_set_url(b,url)	BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url))
#define BIO_set_proxies(b,p)	BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p))
/* BIO_set_nbio(b,n) */
#define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s))
/* BIO *BIO_get_filter_bio(BIO *bio); */
#define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)()))
#define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk)
#define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool)

#define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp)
#define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p))
#define BIO_get_url(b,url)	BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url))
#define BIO_get_no_connect_return(b)	BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL)

#define BIO_set_fd(b,fd,c)	BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
#define BIO_get_fd(b,c)		BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)

#define BIO_set_fp(b,fp,c)	BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp)
#define BIO_get_fp(b,fpp)	BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp)

#define BIO_seek(b,ofs)	(int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)
#define BIO_tell(b)	(int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)

/* name is cast to lose const, but might be better to route through a function
   so we can do it safely */
#define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
		BIO_CLOSE|BIO_FP_READ,(char *)name)
#define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
		BIO_CLOSE|BIO_FP_WRITE,name)
#define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
		BIO_CLOSE|BIO_FP_APPEND,name)
#define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
		BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)

/* WARNING WARNING, this ups the reference count on the read bio of the
 * SSL structure.  This is because the ssl read BIO is now pointed to by
 * the next_bio field in the bio.  So when you free the BIO, make sure
 * you are doing a BIO_free_all() to catch the underlying BIO. */
#define BIO_set_ssl(b,ssl,c)	BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl)
#define BIO_get_ssl(b,sslp)	BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp)
#define BIO_set_ssl_mode(b,client)	BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)
#define BIO_set_ssl_renegotiate_bytes(b,num) \
	BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL);
#define BIO_get_num_renegotiates(b) \
	BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL);
#define BIO_set_ssl_renegotiate_timeout(b,seconds) \
	BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL);

/* defined in evp.h */
/* #define BIO_set_md(b,md)	BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */

#define BIO_get_mem_data(b,pp)	BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)
#define BIO_set_mem_buf(b,bm,c)	BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm)
#define BIO_get_mem_ptr(b,pp)	BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp)
#define BIO_set_mem_eof_return(b,v) \
				BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)

/* For the BIO_f_buffer() type */
#define BIO_get_buffer_num_lines(b)	BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)
#define BIO_set_buffer_size(b,size)	BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)
#define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)
#define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)
#define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)

/* Don't use the next one unless you know what you are doing :-) */
#define BIO_dup_state(b,ret)	BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))

#define BIO_reset(b)		(int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)
#define BIO_eof(b)		(int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)
#define BIO_set_close(b,c)	(int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)
#define BIO_get_close(b)	(int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)
#define BIO_pending(b)		(int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)
#define BIO_wpending(b)		(int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)
/* ...pending macros have inappropriate return type */
size_t BIO_ctrl_pending(BIO *b);
size_t BIO_ctrl_wpending(BIO *b);
#define BIO_flush(b)		(int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \
						   cbp)
#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)

/* For the BIO_f_buffer() type */
#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)

/* For BIO_s_bio() */
#define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)
#define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)
#define BIO_make_bio_pair(b1,b2)   (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)
#define BIO_destroy_bio_pair(b)    (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)
#define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
/* macros with inappropriate type -- but ...pending macros use int too: */
#define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)
#define BIO_get_read_request(b)    (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
size_t BIO_ctrl_get_write_guarantee(BIO *b);
size_t BIO_ctrl_get_read_request(BIO *b);
int BIO_ctrl_reset_read_request(BIO *b);

/* ctrl macros for dgram */
#define BIO_ctrl_dgram_connect(b,peer)  \
                     (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer)
#define BIO_ctrl_set_connected(b, state, peer) \
         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer)
#define BIO_dgram_recv_timedout(b) \
         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)
#define BIO_dgram_send_timedout(b) \
         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)
#define BIO_dgram_get_peer(b,peer) \
         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer)
#define BIO_dgram_set_peer(b,peer) \
         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer)

/* These two aren't currently implemented */
/* int BIO_get_ex_num(BIO *bio); */
/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */
int BIO_set_ex_data(BIO *bio, int idx, void *data);
void *BIO_get_ex_data(BIO *bio, int idx);
int
BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
unsigned long BIO_number_read(BIO *bio);
unsigned long BIO_number_written(BIO *bio);

/* For BIO_f_asn1() */
int
BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,
asn1_ps_func *prefix_free);
int
BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,
asn1_ps_func **pprefix_free);
int
BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,
asn1_ps_func *suffix_free);
int
BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,
asn1_ps_func **psuffix_free);

BIO_METHOD *BIO_s_file(void );
BIO *BIO_new_file(const char *filename, const char *mode);
BIO *BIO_new_fp(FILE *stream, int close_flag);
# define BIO_s_file_internal	BIO_s_file
BIO *	BIO_new(BIO_METHOD *type);
int	BIO_set(BIO *a, BIO_METHOD *type);
int	BIO_free(BIO *a);
void	BIO_vfree(BIO *a);
int	BIO_read(BIO *b, void *data, int len)
		__attribute__((__bounded__(__buffer__,2,3)));
int	BIO_gets(BIO *bp, char *buf, int size)
		__attribute__((__bounded__ (__string__,2,3)));
int	BIO_write(BIO *b, const void *data, int len)
		__attribute__((__bounded__(__buffer__,2,3)));
int	BIO_puts(BIO *bp, const char *buf);
int	BIO_indent(BIO *b, int indent, int max);
long	BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);
long	BIO_callback_ctrl(BIO *b, int cmd,
	    void (*fp)(struct bio_st *, int, const char *, int, long, long));
char *	BIO_ptr_ctrl(BIO *bp, int cmd, long larg);
long	BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);
BIO *	BIO_push(BIO *b, BIO *append);
BIO *	BIO_pop(BIO *b);
void	BIO_free_all(BIO *a);
BIO *	BIO_find_type(BIO *b, int bio_type);
BIO *	BIO_next(BIO *b);
BIO *	BIO_get_retry_BIO(BIO *bio, int *reason);
int	BIO_get_retry_reason(BIO *bio);
BIO *	BIO_dup_chain(BIO *in);

int BIO_nread0(BIO *bio, char **buf);
int BIO_nread(BIO *bio, char **buf, int num);
int BIO_nwrite0(BIO *bio, char **buf);
int BIO_nwrite(BIO *bio, char **buf, int num);

long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi,
    long argl, long ret);

BIO_METHOD *BIO_s_mem(void);
BIO *BIO_new_mem_buf(void *buf, int len);
BIO_METHOD *BIO_s_socket(void);
BIO_METHOD *BIO_s_connect(void);
BIO_METHOD *BIO_s_accept(void);
BIO_METHOD *BIO_s_fd(void);
BIO_METHOD *BIO_s_log(void);
BIO_METHOD *BIO_s_bio(void);
BIO_METHOD *BIO_s_null(void);
BIO_METHOD *BIO_f_null(void);
BIO_METHOD *BIO_f_buffer(void);
BIO_METHOD *BIO_f_nbio_test(void);
#ifndef OPENSSL_NO_DGRAM
BIO_METHOD *BIO_s_datagram(void);
#ifndef OPENSSL_NO_SCTP
BIO_METHOD *BIO_s_datagram_sctp(void);
#endif
#endif

/* BIO_METHOD *BIO_f_ber(void); */

int BIO_sock_should_retry(int i);
int BIO_sock_non_fatal_error(int error);
int BIO_dgram_non_fatal_error(int error);

int BIO_fd_should_retry(int i);
int BIO_fd_non_fatal_error(int error);
int
BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u),
void *u, const char *s, int len);
int
BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u),
void *u, const char *s, int len, int indent);
int BIO_dump(BIO *b, const char *bytes, int len);
int BIO_dump_indent(BIO *b, const char *bytes, int len, int indent);
int BIO_dump_fp(FILE *fp, const char *s, int len);
int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);
struct hostent *BIO_gethostbyname(const char *name);
/* We might want a thread-safe interface too:
 * struct hostent *BIO_gethostbyname_r(const char *name,
 *     struct hostent *result, void *buffer, size_t buflen);
 * or something similar (caller allocates a struct hostent,
 * pointed to by "result", and additional buffer space for the various
 * substructures; if the buffer does not suffice, NULL is returned
 * and an appropriate error code is set).
 */
int BIO_sock_error(int sock);
int BIO_socket_ioctl(int fd, long type, void *arg);
int BIO_socket_nbio(int fd, int mode);
int BIO_get_port(const char *str, unsigned short *port_ptr);
int BIO_get_host_ip(const char *str, unsigned char *ip);
int BIO_get_accept_socket(char *host_port, int mode);
int BIO_accept(int sock, char **ip_port);
int BIO_sock_init(void );
void BIO_sock_cleanup(void);
int BIO_set_tcp_ndelay(int sock, int turn_on);

BIO *BIO_new_socket(int sock, int close_flag);
BIO *BIO_new_dgram(int fd, int close_flag);
#ifndef OPENSSL_NO_SCTP
BIO *BIO_new_dgram_sctp(int fd, int close_flag);
int BIO_dgram_is_sctp(BIO *bio);
int
BIO_dgram_sctp_notification_cb(BIO *b,
    void (*handle_notifications)(BIO *bio, void *context, void *buf),
void *context);
int BIO_dgram_sctp_wait_for_dry(BIO *b);
int BIO_dgram_sctp_msg_waiting(BIO *b);
#endif
BIO *BIO_new_fd(int fd, int close_flag);
BIO *BIO_new_connect(char *host_port);
BIO *BIO_new_accept(char *host_port);

int
BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
BIO **bio2, size_t writebuf2);
/* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.
 * Otherwise returns 0 and sets *bio1 and *bio2 to NULL.
 * Size 0 uses default value.
 */

void BIO_copy_next_retry(BIO *b);

/*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/

int
BIO_printf(BIO *bio, const char *format, ...)
	__attribute__((__format__(__printf__, 2, 3)));
int
BIO_vprintf(BIO *bio, const char *format, va_list args)
	__attribute__((__format__(__printf__, 2, 0)));
int
BIO_snprintf(char *buf, size_t n, const char *format, ...)
	__attribute__((deprecated, __format__(__printf__, 3, 4)));
int
BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
	__attribute__((deprecated, __format__(__printf__, 3, 0)));

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_BIO_strings(void);

/* Error codes for the BIO functions. */

/* Function codes. */
#define BIO_F_ACPT_STATE				 100
#define BIO_F_BIO_ACCEPT				 101
#define BIO_F_BIO_BER_GET_HEADER			 102
#define BIO_F_BIO_CALLBACK_CTRL				 131
#define BIO_F_BIO_CTRL					 103
#define BIO_F_BIO_GETHOSTBYNAME				 120
#define BIO_F_BIO_GETS					 104
#define BIO_F_BIO_GET_ACCEPT_SOCKET			 105
#define BIO_F_BIO_GET_HOST_IP				 106
#define BIO_F_BIO_GET_PORT				 107
#define BIO_F_BIO_MAKE_PAIR				 121
#define BIO_F_BIO_NEW					 108
#define BIO_F_BIO_NEW_FILE				 109
#define BIO_F_BIO_NEW_MEM_BUF				 126
#define BIO_F_BIO_NREAD					 123
#define BIO_F_BIO_NREAD0				 124
#define BIO_F_BIO_NWRITE				 125
#define BIO_F_BIO_NWRITE0				 122
#define BIO_F_BIO_PUTS					 110
#define BIO_F_BIO_READ					 111
#define BIO_F_BIO_SOCK_INIT				 112
#define BIO_F_BIO_WRITE					 113
#define BIO_F_BUFFER_CTRL				 114
#define BIO_F_CONN_CTRL					 127
#define BIO_F_CONN_STATE				 115
#define BIO_F_DGRAM_SCTP_READ				 132
#define BIO_F_FILE_CTRL					 116
#define BIO_F_FILE_READ					 130
#define BIO_F_LINEBUFFER_CTRL				 129
#define BIO_F_MEM_READ					 128
#define BIO_F_MEM_WRITE					 117
#define BIO_F_SSL_NEW					 118
#define BIO_F_WSASTARTUP				 119

/* Reason codes. */
#define BIO_R_ACCEPT_ERROR				 100
#define BIO_R_BAD_FOPEN_MODE				 101
#define BIO_R_BAD_HOSTNAME_LOOKUP			 102
#define BIO_R_BROKEN_PIPE				 124
#define BIO_R_CONNECT_ERROR				 103
#define BIO_R_EOF_ON_MEMORY_BIO				 127
#define BIO_R_ERROR_SETTING_NBIO			 104
#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET	 105
#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET	 106
#define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET		 107
#define BIO_R_INVALID_ARGUMENT				 125
#define BIO_R_INVALID_IP_ADDRESS			 108
#define BIO_R_INVALID_PORT_NUMBER			 129
#define BIO_R_IN_USE					 123
#define BIO_R_KEEPALIVE					 109
#define BIO_R_NBIO_CONNECT_ERROR			 110
#define BIO_R_NO_ACCEPT_PORT_SPECIFIED			 111
#define BIO_R_NO_HOSTNAME_SPECIFIED			 112
#define BIO_R_NO_PORT_DEFINED				 113
#define BIO_R_NO_PORT_SPECIFIED				 114
#define BIO_R_NO_SUCH_FILE				 128
#define BIO_R_NULL_PARAMETER				 115
#define BIO_R_TAG_MISMATCH				 116
#define BIO_R_UNABLE_TO_BIND_SOCKET			 117
#define BIO_R_UNABLE_TO_CREATE_SOCKET			 118
#define BIO_R_UNABLE_TO_LISTEN_SOCKET			 119
#define BIO_R_UNINITIALIZED				 120
#define BIO_R_UNSUPPORTED_METHOD			 121
#define BIO_R_WRITE_TO_READ_ONLY_BIO			 126
#define BIO_R_WSASTARTUP				 122

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/cms.h0000644000175000017500000004656412360020705021013 0ustar  /* $OpenBSD: cms.h,v 1.4 2014/06/12 15:49:28 deraadt Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
 * project.
 */
/* ====================================================================
 * Copyright (c) 2008 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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 HEADER_CMS_H
#define HEADER_CMS_H

#include 

#include 

#ifdef OPENSSL_NO_CMS
#error CMS is disabled.
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef struct CMS_ContentInfo_st CMS_ContentInfo;
typedef struct CMS_SignerInfo_st CMS_SignerInfo;
typedef struct CMS_CertificateChoices CMS_CertificateChoices;
typedef struct CMS_RevocationInfoChoice_st CMS_RevocationInfoChoice;
typedef struct CMS_RecipientInfo_st CMS_RecipientInfo;
typedef struct CMS_ReceiptRequest_st CMS_ReceiptRequest;
typedef struct CMS_Receipt_st CMS_Receipt;

DECLARE_STACK_OF(CMS_SignerInfo)
DECLARE_STACK_OF(GENERAL_NAMES)
DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)
DECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest)
DECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo)

#define CMS_SIGNERINFO_ISSUER_SERIAL	0
#define CMS_SIGNERINFO_KEYIDENTIFIER	1

#define CMS_RECIPINFO_TRANS		0
#define CMS_RECIPINFO_AGREE		1
#define CMS_RECIPINFO_KEK		2
#define CMS_RECIPINFO_PASS		3
#define CMS_RECIPINFO_OTHER		4

/* S/MIME related flags */

#define CMS_TEXT			0x1
#define CMS_NOCERTS			0x2
#define CMS_NO_CONTENT_VERIFY		0x4
#define CMS_NO_ATTR_VERIFY		0x8
#define CMS_NOSIGS			\
			(CMS_NO_CONTENT_VERIFY|CMS_NO_ATTR_VERIFY)
#define CMS_NOINTERN			0x10
#define CMS_NO_SIGNER_CERT_VERIFY	0x20
#define CMS_NOVERIFY			0x20
#define CMS_DETACHED			0x40
#define CMS_BINARY			0x80
#define CMS_NOATTR			0x100
#define	CMS_NOSMIMECAP			0x200
#define CMS_NOOLDMIMETYPE		0x400
#define CMS_CRLFEOL			0x800
#define CMS_STREAM			0x1000
#define CMS_NOCRL			0x2000
#define CMS_PARTIAL			0x4000
#define CMS_REUSE_DIGEST		0x8000
#define CMS_USE_KEYID			0x10000
#define CMS_DEBUG_DECRYPT		0x20000

const ASN1_OBJECT *CMS_get0_type(CMS_ContentInfo *cms);

BIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont);
int CMS_dataFinal(CMS_ContentInfo *cms, BIO *bio);

ASN1_OCTET_STRING **CMS_get0_content(CMS_ContentInfo *cms);
int CMS_is_detached(CMS_ContentInfo *cms);
int CMS_set_detached(CMS_ContentInfo *cms, int detached);

#ifdef HEADER_PEM_H
DECLARE_PEM_rw_const(CMS, CMS_ContentInfo)
#endif

int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms);
CMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms);
int i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms);

BIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms);
int i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags);
int PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in,
    int flags);
CMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont);
int SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags);

int CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont, unsigned int flags);

CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey,
    STACK_OF(X509) *certs, BIO *data, unsigned int flags);

CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si, X509 *signcert,
    EVP_PKEY *pkey, STACK_OF(X509) *certs, unsigned int flags);

int CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags);
CMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags);

int CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out,
    unsigned int flags);
CMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md,
    unsigned int flags);

int CMS_EncryptedData_decrypt(CMS_ContentInfo *cms, const unsigned char *key,
    size_t keylen, BIO *dcont, BIO *out, unsigned int flags);

CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher,
    const unsigned char *key, size_t keylen, unsigned int flags);

int CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph,
    const unsigned char *key, size_t keylen);

int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs,
    X509_STORE *store, BIO *dcont, BIO *out, unsigned int flags);

int CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms,
    STACK_OF(X509) *certs, X509_STORE *store, unsigned int flags);

STACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);

CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in,
    const EVP_CIPHER *cipher, unsigned int flags);

int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert, BIO *dcont,
    BIO *out, unsigned int flags);

int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert);
int CMS_decrypt_set1_key(CMS_ContentInfo *cms, unsigned char *key,
    size_t keylen, unsigned char *id, size_t idlen);
int CMS_decrypt_set1_password(CMS_ContentInfo *cms, unsigned char *pass,
    ssize_t passlen);

STACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms);
int CMS_RecipientInfo_type(CMS_RecipientInfo *ri);
CMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher);
CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms, X509 *recip,
    unsigned int flags);
int CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey);
int CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert);
int CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri, EVP_PKEY **pk,
    X509 **recip, X509_ALGOR **palg);
int CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri,
    ASN1_OCTET_STRING **keyid, X509_NAME **issuer, ASN1_INTEGER **sno);

CMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid,
    unsigned char *key, size_t keylen, unsigned char *id, size_t idlen,
    ASN1_GENERALIZEDTIME *date, ASN1_OBJECT *otherTypeId,
    ASN1_TYPE *otherType);

int CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri, X509_ALGOR **palg,
    ASN1_OCTET_STRING **pid, ASN1_GENERALIZEDTIME **pdate,
    ASN1_OBJECT **potherid, ASN1_TYPE **pothertype);

int CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri, unsigned char *key,
    size_t keylen);

int CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri,
    const unsigned char *id, size_t idlen);

int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri, unsigned char *pass,
    ssize_t passlen);

CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms, int iter,
    int wrap_nid, int pbe_nid, unsigned char *pass, ssize_t passlen,
    const EVP_CIPHER *kekciph);

int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);

int CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out,
    unsigned int flags);
CMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags);

int CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid);
const ASN1_OBJECT *CMS_get0_eContentType(CMS_ContentInfo *cms);

CMS_CertificateChoices *CMS_add0_CertificateChoices(CMS_ContentInfo *cms);
int CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert);
int CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert);
STACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms);

CMS_RevocationInfoChoice *CMS_add0_RevocationInfoChoice(CMS_ContentInfo *cms);
int CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl);
int CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl);
STACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms);

int CMS_SignedData_init(CMS_ContentInfo *cms);
CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, X509 *signer,
    EVP_PKEY *pk, const EVP_MD *md, unsigned int flags);
STACK_OF(CMS_SignerInfo) *CMS_get0_SignerInfos(CMS_ContentInfo *cms);

void CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer);
int CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si,
    ASN1_OCTET_STRING **keyid, X509_NAME **issuer, ASN1_INTEGER **sno);
int CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert);
int CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) *certs,
    unsigned int flags);
void CMS_SignerInfo_get0_algs(CMS_SignerInfo *si, EVP_PKEY **pk, X509 **signer,
    X509_ALGOR **pdig, X509_ALGOR **psig);
int CMS_SignerInfo_sign(CMS_SignerInfo *si);
int CMS_SignerInfo_verify(CMS_SignerInfo *si);
int CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain);

int CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) *algs);
int CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs, int algnid,
    int keysize);
int CMS_add_standard_smimecap(STACK_OF(X509_ALGOR) **smcap);

int CMS_signed_get_attr_count(const CMS_SignerInfo *si);
int CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid, int lastpos);
int CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, ASN1_OBJECT *obj,
    int lastpos);
X509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc);
X509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc);
int CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);
int CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *obj,
    int type, const void *bytes, int len);
int CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si, int nid, int type,
    const void *bytes, int len);
int CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si, const char *attrname,
    int type, const void *bytes, int len);
void *CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,
    int lastpos, int type);

int CMS_unsigned_get_attr_count(const CMS_SignerInfo *si);
int CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid,
    int lastpos);
int CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si, ASN1_OBJECT *obj,
    int lastpos);
X509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc);
X509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc);
int CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);
int CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *obj,
    int type, const void *bytes, int len);
int CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si, int nid, int type,
    const void *bytes, int len);
int CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si, const char *attrname,
    int type, const void *bytes, int len);
void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,
    int lastpos, int type);

#ifdef HEADER_X509V3_H

int CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr);
CMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen,
    int allorfirst, STACK_OF(GENERAL_NAMES) *receiptList,
    STACK_OF(GENERAL_NAMES) *receiptsTo);
int CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr);
void CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr, ASN1_STRING **pcid,
    int *pallorfirst, STACK_OF(GENERAL_NAMES) **plist,
    STACK_OF(GENERAL_NAMES) **prto);

#endif

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_CMS_strings(void);

/* Error codes for the CMS functions. */

/* Function codes. */
#define CMS_F_CHECK_CONTENT				 99
#define CMS_F_CMS_ADD0_CERT				 164
#define CMS_F_CMS_ADD0_RECIPIENT_KEY			 100
#define CMS_F_CMS_ADD0_RECIPIENT_PASSWORD		 165
#define CMS_F_CMS_ADD1_RECEIPTREQUEST			 158
#define CMS_F_CMS_ADD1_RECIPIENT_CERT			 101
#define CMS_F_CMS_ADD1_SIGNER				 102
#define CMS_F_CMS_ADD1_SIGNINGTIME			 103
#define CMS_F_CMS_COMPRESS				 104
#define CMS_F_CMS_COMPRESSEDDATA_CREATE			 105
#define CMS_F_CMS_COMPRESSEDDATA_INIT_BIO		 106
#define CMS_F_CMS_COPY_CONTENT				 107
#define CMS_F_CMS_COPY_MESSAGEDIGEST			 108
#define CMS_F_CMS_DATA					 109
#define CMS_F_CMS_DATAFINAL				 110
#define CMS_F_CMS_DATAINIT				 111
#define CMS_F_CMS_DECRYPT				 112
#define CMS_F_CMS_DECRYPT_SET1_KEY			 113
#define CMS_F_CMS_DECRYPT_SET1_PASSWORD			 166
#define CMS_F_CMS_DECRYPT_SET1_PKEY			 114
#define CMS_F_CMS_DIGESTALGORITHM_FIND_CTX		 115
#define CMS_F_CMS_DIGESTALGORITHM_INIT_BIO		 116
#define CMS_F_CMS_DIGESTEDDATA_DO_FINAL			 117
#define CMS_F_CMS_DIGEST_VERIFY				 118
#define CMS_F_CMS_ENCODE_RECEIPT			 161
#define CMS_F_CMS_ENCRYPT				 119
#define CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO		 120
#define CMS_F_CMS_ENCRYPTEDDATA_DECRYPT			 121
#define CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT			 122
#define CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY		 123
#define CMS_F_CMS_ENVELOPEDDATA_CREATE			 124
#define CMS_F_CMS_ENVELOPEDDATA_INIT_BIO		 125
#define CMS_F_CMS_ENVELOPED_DATA_INIT			 126
#define CMS_F_CMS_FINAL					 127
#define CMS_F_CMS_GET0_CERTIFICATE_CHOICES		 128
#define CMS_F_CMS_GET0_CONTENT				 129
#define CMS_F_CMS_GET0_ECONTENT_TYPE			 130
#define CMS_F_CMS_GET0_ENVELOPED			 131
#define CMS_F_CMS_GET0_REVOCATION_CHOICES		 132
#define CMS_F_CMS_GET0_SIGNED				 133
#define CMS_F_CMS_MSGSIGDIGEST_ADD1			 162
#define CMS_F_CMS_RECEIPTREQUEST_CREATE0		 159
#define CMS_F_CMS_RECEIPT_VERIFY			 160
#define CMS_F_CMS_RECIPIENTINFO_DECRYPT			 134
#define CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT		 135
#define CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT		 136
#define CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID		 137
#define CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP		 138
#define CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP		 139
#define CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT		 140
#define CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT		 141
#define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_ALGS		 142
#define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID	 143
#define CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT		 167
#define CMS_F_CMS_RECIPIENTINFO_SET0_KEY		 144
#define CMS_F_CMS_RECIPIENTINFO_SET0_PASSWORD		 168
#define CMS_F_CMS_RECIPIENTINFO_SET0_PKEY		 145
#define CMS_F_CMS_SET1_SIGNERIDENTIFIER			 146
#define CMS_F_CMS_SET_DETACHED				 147
#define CMS_F_CMS_SIGN					 148
#define CMS_F_CMS_SIGNED_DATA_INIT			 149
#define CMS_F_CMS_SIGNERINFO_CONTENT_SIGN		 150
#define CMS_F_CMS_SIGNERINFO_SIGN			 151
#define CMS_F_CMS_SIGNERINFO_VERIFY			 152
#define CMS_F_CMS_SIGNERINFO_VERIFY_CERT		 153
#define CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT		 154
#define CMS_F_CMS_SIGN_RECEIPT				 163
#define CMS_F_CMS_STREAM				 155
#define CMS_F_CMS_UNCOMPRESS				 156
#define CMS_F_CMS_VERIFY				 157

/* Reason codes. */
#define CMS_R_ADD_SIGNER_ERROR				 99
#define CMS_R_CERTIFICATE_ALREADY_PRESENT		 175
#define CMS_R_CERTIFICATE_HAS_NO_KEYID			 160
#define CMS_R_CERTIFICATE_VERIFY_ERROR			 100
#define CMS_R_CIPHER_INITIALISATION_ERROR		 101
#define CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR	 102
#define CMS_R_CMS_DATAFINAL_ERROR			 103
#define CMS_R_CMS_LIB					 104
#define CMS_R_CONTENTIDENTIFIER_MISMATCH		 170
#define CMS_R_CONTENT_NOT_FOUND				 105
#define CMS_R_CONTENT_TYPE_MISMATCH			 171
#define CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA		 106
#define CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA		 107
#define CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA		 108
#define CMS_R_CONTENT_VERIFY_ERROR			 109
#define CMS_R_CTRL_ERROR				 110
#define CMS_R_CTRL_FAILURE				 111
#define CMS_R_DECRYPT_ERROR				 112
#define CMS_R_DIGEST_ERROR				 161
#define CMS_R_ERROR_GETTING_PUBLIC_KEY			 113
#define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE	 114
#define CMS_R_ERROR_SETTING_KEY				 115
#define CMS_R_ERROR_SETTING_RECIPIENTINFO		 116
#define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH		 117
#define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER		 176
#define CMS_R_INVALID_KEY_LENGTH			 118
#define CMS_R_MD_BIO_INIT_ERROR				 119
#define CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH	 120
#define CMS_R_MESSAGEDIGEST_WRONG_LENGTH		 121
#define CMS_R_MSGSIGDIGEST_ERROR			 172
#define CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE		 162
#define CMS_R_MSGSIGDIGEST_WRONG_LENGTH			 163
#define CMS_R_NEED_ONE_SIGNER				 164
#define CMS_R_NOT_A_SIGNED_RECEIPT			 165
#define CMS_R_NOT_ENCRYPTED_DATA			 122
#define CMS_R_NOT_KEK					 123
#define CMS_R_NOT_KEY_TRANSPORT				 124
#define CMS_R_NOT_PWRI					 177
#define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE		 125
#define CMS_R_NO_CIPHER					 126
#define CMS_R_NO_CONTENT				 127
#define CMS_R_NO_CONTENT_TYPE				 173
#define CMS_R_NO_DEFAULT_DIGEST				 128
#define CMS_R_NO_DIGEST_SET				 129
#define CMS_R_NO_KEY					 130
#define CMS_R_NO_KEY_OR_CERT				 174
#define CMS_R_NO_MATCHING_DIGEST			 131
#define CMS_R_NO_MATCHING_RECIPIENT			 132
#define CMS_R_NO_MATCHING_SIGNATURE			 166
#define CMS_R_NO_MSGSIGDIGEST				 167
#define CMS_R_NO_PASSWORD				 178
#define CMS_R_NO_PRIVATE_KEY				 133
#define CMS_R_NO_PUBLIC_KEY				 134
#define CMS_R_NO_RECEIPT_REQUEST			 168
#define CMS_R_NO_SIGNERS				 135
#define CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE	 136
#define CMS_R_RECEIPT_DECODE_ERROR			 169
#define CMS_R_RECIPIENT_ERROR				 137
#define CMS_R_SIGNER_CERTIFICATE_NOT_FOUND		 138
#define CMS_R_SIGNFINAL_ERROR				 139
#define CMS_R_SMIME_TEXT_ERROR				 140
#define CMS_R_STORE_INIT_ERROR				 141
#define CMS_R_TYPE_NOT_COMPRESSED_DATA			 142
#define CMS_R_TYPE_NOT_DATA				 143
#define CMS_R_TYPE_NOT_DIGESTED_DATA			 144
#define CMS_R_TYPE_NOT_ENCRYPTED_DATA			 145
#define CMS_R_TYPE_NOT_ENVELOPED_DATA			 146
#define CMS_R_UNABLE_TO_FINALIZE_CONTEXT		 147
#define CMS_R_UNKNOWN_CIPHER				 148
#define CMS_R_UNKNOWN_DIGEST_ALGORIHM			 149
#define CMS_R_UNKNOWN_ID				 150
#define CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM		 151
#define CMS_R_UNSUPPORTED_CONTENT_TYPE			 152
#define CMS_R_UNSUPPORTED_KEK_ALGORITHM			 153
#define CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM	 179
#define CMS_R_UNSUPPORTED_RECIPIENT_TYPE		 154
#define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE		 155
#define CMS_R_UNSUPPORTED_TYPE				 156
#define CMS_R_UNWRAP_ERROR				 157
#define CMS_R_UNWRAP_FAILURE				 180
#define CMS_R_VERIFICATION_FAILURE			 158
#define CMS_R_WRAP_ERROR				 159

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/opensslv.h0000644000175000017500000000056612360020705022072 0ustar  /* $OpenBSD: opensslv.h,v 1.25 2014/06/12 15:49:27 deraadt Exp $ */
#ifndef HEADER_OPENSSLV_H
#define HEADER_OPENSSLV_H

#define OPENSSL_VERSION_NUMBER	0x20000000L
#define OPENSSL_VERSION_TEXT	"LibreSSL 2.0"
#define OPENSSL_VERSION_PTEXT	" part of " OPENSSL_VERSION_TEXT

#define SHLIB_VERSION_HISTORY ""
#define SHLIB_VERSION_NUMBER "1.0.0"

#endif /* HEADER_OPENSSLV_H */
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/bn.h0000644000175000017500000010326612360020705020621 0ustar  /* $OpenBSD: bn.h,v 1.23 2014/06/12 15:49:28 deraadt Exp $ */
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */
/* ====================================================================
 * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */
/* ====================================================================
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 *
 * Portions of the attached software ("Contribution") are developed by
 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
 *
 * The Contribution is licensed pursuant to the Eric Young open source
 * license provided above.
 *
 * The binary polynomial arithmetic software is originally written by
 * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
 *
 */

#ifndef HEADER_BN_H
#define HEADER_BN_H

#include 

#include  /* FILE */
#include 
#include 

#ifdef  __cplusplus
extern "C" {
#endif

/* These preprocessor symbols control various aspects of the bignum headers and
 * library code. They're not defined by any "normal" configuration, as they are
 * intended for development and testing purposes. NB: defining all three can be
 * useful for debugging application code as well as openssl itself.
 *
 * BN_DEBUG - turn on various debugging alterations to the bignum code
 * BN_DEBUG_RAND - uses random poisoning of unused words to trip up
 * mismanagement of bignum internals. You must also define BN_DEBUG.
 */
/* #define BN_DEBUG */
/* #define BN_DEBUG_RAND */

#ifndef OPENSSL_SMALL_FOOTPRINT
#define BN_MUL_COMBA
#define BN_SQR_COMBA
#define BN_RECURSION
#endif

/* This next option uses the C libraries (2 word)/(1 word) function.
 * If it is not defined, I use my C version (which is slower).
 * The reason for this flag is that when the particular C compiler
 * library routine is used, and the library is linked with a different
 * compiler, the library is missing.  This mostly happens when the
 * library is built with gcc and then linked using normal cc.  This would
 * be a common occurrence because gcc normally produces code that is
 * 2 times faster than system compilers for the big number stuff.
 * For machines with only one compiler (or shared libraries), this should
 * be on.  Again this in only really a problem on machines
 * using "long long's", are 32bit, and are not using my assembler code. */
/* #define BN_DIV2W */

#ifdef _LP64
#undef	BN_LLONG
#define BN_ULONG	unsigned long
#define BN_LONG		long
#define BN_BITS		128
#define BN_BYTES	8
#define BN_BITS2	64
#define BN_BITS4	32
#define BN_MASK2	(0xffffffffffffffffL)
#define BN_MASK2l	(0xffffffffL)
#define BN_MASK2h	(0xffffffff00000000L)
#define BN_MASK2h1	(0xffffffff80000000L)
#define BN_TBIT		(0x8000000000000000L)
#define BN_DEC_CONV	(10000000000000000000UL)
#define BN_DEC_FMT1	"%lu"
#define BN_DEC_FMT2	"%019lu"
#define BN_DEC_NUM	19
#define BN_HEX_FMT1	"%lX"
#define BN_HEX_FMT2	"%016lX"
#else
#define BN_ULLONG	unsigned long long
#define	BN_LLONG
#define BN_ULONG	unsigned int
#define BN_LONG		int
#define BN_BITS		64
#define BN_BYTES	4
#define BN_BITS2	32
#define BN_BITS4	16
#define BN_MASK		(0xffffffffffffffffLL)
#define BN_MASK2	(0xffffffffL)
#define BN_MASK2l	(0xffff)
#define BN_MASK2h1	(0xffff8000L)
#define BN_MASK2h	(0xffff0000L)
#define BN_TBIT		(0x80000000L)
#define BN_DEC_CONV	(1000000000L)
#define BN_DEC_FMT1	"%u"
#define BN_DEC_FMT2	"%09u"
#define BN_DEC_NUM	9
#define BN_HEX_FMT1	"%X"
#define BN_HEX_FMT2	"%08X"
#endif

#define BN_FLG_MALLOCED		0x01
#define BN_FLG_STATIC_DATA	0x02
#define BN_FLG_CONSTTIME	0x04 /* avoid leaking exponent information through timing,
                                      * BN_mod_exp_mont() will call BN_mod_exp_mont_consttime,
                                      * BN_div() will call BN_div_no_branch,
                                      * BN_mod_inverse() will call BN_mod_inverse_no_branch.
                                      */

#ifndef OPENSSL_NO_DEPRECATED
#define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME /* deprecated name for the flag */
                                      /* avoid leaking exponent information through timings
                                      * (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime) */
#endif

#ifndef OPENSSL_NO_DEPRECATED
#define BN_FLG_FREE		0x8000	/* used for debuging */
#endif
#define BN_set_flags(b,n)	((b)->flags|=(n))
#define BN_get_flags(b,n)	((b)->flags&(n))

/* get a clone of a BIGNUM with changed flags, for *temporary* use only
 * (the two BIGNUMs cannot not be used in parallel!) */
#define BN_with_flags(dest,b,n)  ((dest)->d=(b)->d, \
                                  (dest)->top=(b)->top, \
                                  (dest)->dmax=(b)->dmax, \
                                  (dest)->neg=(b)->neg, \
                                  (dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \
                                                 |  ((b)->flags & ~BN_FLG_MALLOCED) \
                                                 |  BN_FLG_STATIC_DATA \
                                                 |  (n)))

/* Already declared in ossl_typ.h */
#if 0
typedef struct bignum_st BIGNUM;
/* Used for temp variables (declaration hidden in bn_lcl.h) */
typedef struct bignum_ctx BN_CTX;
typedef struct bn_blinding_st BN_BLINDING;
typedef struct bn_mont_ctx_st BN_MONT_CTX;
typedef struct bn_recp_ctx_st BN_RECP_CTX;
typedef struct bn_gencb_st BN_GENCB;
#endif

struct bignum_st {
	BN_ULONG *d;	/* Pointer to an array of 'BN_BITS2' bit chunks. */
	int top;	/* Index of last used d +1. */
	/* The next are internal book keeping for bn_expand. */
	int dmax;	/* Size of the d array. */
	int neg;	/* one if the number is negative */
	int flags;
};

/* Used for montgomery multiplication */
struct bn_mont_ctx_st {
	int ri;        /* number of bits in R */
	BIGNUM RR;     /* used to convert to montgomery form */
	BIGNUM N;      /* The modulus */
	BIGNUM Ni;     /* R*(1/R mod N) - N*Ni = 1
	                * (Ni is only stored for bignum algorithm) */
	BN_ULONG n0[2];/* least significant word(s) of Ni;
	                  (type changed with 0.9.9, was "BN_ULONG n0;" before) */
	int flags;
};

/* Used for reciprocal division/mod functions
 * It cannot be shared between threads
 */
struct bn_recp_ctx_st {
	BIGNUM N;	/* the divisor */
	BIGNUM Nr;	/* the reciprocal */
	int num_bits;
	int shift;
	int flags;
};

/* Used for slow "generation" functions. */
struct bn_gencb_st {
	unsigned int ver;	/* To handle binary (in)compatibility */
	void *arg;		/* callback-specific data */
	union {
		/* if(ver==1) - handles old style callbacks */
		void (*cb_1)(int, int, void *);
		/* if(ver==2) - new callback style */
		int (*cb_2)(int, int, BN_GENCB *);
	} cb;
};
/* Wrapper function to make using BN_GENCB easier,  */
int BN_GENCB_call(BN_GENCB *cb, int a, int b);
/* Macro to populate a BN_GENCB structure with an "old"-style callback */
#define BN_GENCB_set_old(gencb, callback, cb_arg) { \
		BN_GENCB *tmp_gencb = (gencb); \
		tmp_gencb->ver = 1; \
		tmp_gencb->arg = (cb_arg); \
		tmp_gencb->cb.cb_1 = (callback); }
/* Macro to populate a BN_GENCB structure with a "new"-style callback */
#define BN_GENCB_set(gencb, callback, cb_arg) { \
		BN_GENCB *tmp_gencb = (gencb); \
		tmp_gencb->ver = 2; \
		tmp_gencb->arg = (cb_arg); \
		tmp_gencb->cb.cb_2 = (callback); }

#define BN_prime_checks 0 /* default: select number of iterations
			     based on the size of the number */

/* number of Miller-Rabin iterations for an error rate  of less than 2^-80
 * for random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook
 * of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];
 * original paper: Damgaard, Landrock, Pomerance: Average case error estimates
 * for the strong probable prime test. -- Math. Comp. 61 (1993) 177-194) */
#define BN_prime_checks_for_size(b) ((b) >= 1300 ?  2 : \
                                (b) >=  850 ?  3 : \
                                (b) >=  650 ?  4 : \
                                (b) >=  550 ?  5 : \
                                (b) >=  450 ?  6 : \
                                (b) >=  400 ?  7 : \
                                (b) >=  350 ?  8 : \
                                (b) >=  300 ?  9 : \
                                (b) >=  250 ? 12 : \
                                (b) >=  200 ? 15 : \
                                (b) >=  150 ? 18 : \
                                /* b >= 100 */ 27)

#define BN_num_bytes(a)	((BN_num_bits(a)+7)/8)

/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */
#define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \
				(((w) == 0) && ((a)->top == 0)))
#define BN_is_zero(a)       ((a)->top == 0)
#define BN_is_one(a)        (BN_abs_is_word((a),1) && !(a)->neg)
#define BN_is_word(a,w)     (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg))
#define BN_is_odd(a)	    (((a)->top > 0) && ((a)->d[0] & 1))

#define BN_one(a)	(BN_set_word((a),1))
#define BN_zero_ex(a) \
	do { \
		BIGNUM *_tmp_bn = (a); \
		_tmp_bn->top = 0; \
		_tmp_bn->neg = 0; \
	} while(0)

#ifdef OPENSSL_NO_DEPRECATED
#define BN_zero(a)	BN_zero_ex(a)
#else
#define BN_zero(a)	(BN_set_word((a),0))
#endif

const BIGNUM *BN_value_one(void);
char *	BN_options(void);
BN_CTX *BN_CTX_new(void);
#ifndef OPENSSL_NO_DEPRECATED
void	BN_CTX_init(BN_CTX *c);
#endif
void	BN_CTX_free(BN_CTX *c);
void	BN_CTX_start(BN_CTX *ctx);
BIGNUM *BN_CTX_get(BN_CTX *ctx);
void	BN_CTX_end(BN_CTX *ctx);
int     BN_rand(BIGNUM *rnd, int bits, int top, int bottom);
int     BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);
int	BN_rand_range(BIGNUM *rnd, const BIGNUM *range);
int	BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);
int	BN_num_bits(const BIGNUM *a);
int	BN_num_bits_word(BN_ULONG);
BIGNUM *BN_new(void);
void	BN_init(BIGNUM *);
void	BN_clear_free(BIGNUM *a);
BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
void	BN_swap(BIGNUM *a, BIGNUM *b);
BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
int	BN_bn2bin(const BIGNUM *a, unsigned char *to);
BIGNUM *BN_mpi2bn(const unsigned char *s, int len, BIGNUM *ret);
int	BN_bn2mpi(const BIGNUM *a, unsigned char *to);
int	BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
int	BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
int	BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
int	BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
int	BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
int	BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);
/** BN_set_negative sets sign of a BIGNUM
 * \param  b  pointer to the BIGNUM object
 * \param  n  0 if the BIGNUM b should be positive and a value != 0 otherwise
 */
void	BN_set_negative(BIGNUM *b, int n);
/** BN_is_negative returns 1 if the BIGNUM is negative
 * \param  a  pointer to the BIGNUM object
 * \return 1 if a < 0 and 0 otherwise
 */
#define BN_is_negative(a) ((a)->neg != 0)

int	BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
    BN_CTX *ctx);
#define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx))
int	BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
int	BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
int	BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m);
int	BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
int	BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m);
int	BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
    const BIGNUM *m, BN_CTX *ctx);
int	BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
int	BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
int	BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);
int	BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx);
int	BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);

BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
int	BN_mul_word(BIGNUM *a, BN_ULONG w);
int	BN_add_word(BIGNUM *a, BN_ULONG w);
int	BN_sub_word(BIGNUM *a, BN_ULONG w);
int	BN_set_word(BIGNUM *a, BN_ULONG w);
BN_ULONG BN_get_word(const BIGNUM *a);

int	BN_cmp(const BIGNUM *a, const BIGNUM *b);
void	BN_free(BIGNUM *a);
int	BN_is_bit_set(const BIGNUM *a, int n);
int	BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
int	BN_lshift1(BIGNUM *r, const BIGNUM *a);
int	BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);

int	BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
    const BIGNUM *m, BN_CTX *ctx);
int	BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
    const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
    const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont);
int	BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,
    const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
int	BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1,
    const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m,
    BN_CTX *ctx, BN_MONT_CTX *m_ctx);
int	BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
    const BIGNUM *m, BN_CTX *ctx);

int	BN_mask_bits(BIGNUM *a, int n);
int	BN_print_fp(FILE *fp, const BIGNUM *a);
#ifdef HEADER_BIO_H
int	BN_print(BIO *fp, const BIGNUM *a);
#else
int	BN_print(void *fp, const BIGNUM *a);
#endif
int	BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);
int	BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
int	BN_rshift1(BIGNUM *r, const BIGNUM *a);
void	BN_clear(BIGNUM *a);
BIGNUM *BN_dup(const BIGNUM *a);
int	BN_ucmp(const BIGNUM *a, const BIGNUM *b);
int	BN_set_bit(BIGNUM *a, int n);
int	BN_clear_bit(BIGNUM *a, int n);
char *	BN_bn2hex(const BIGNUM *a);
char *	BN_bn2dec(const BIGNUM *a);
int 	BN_hex2bn(BIGNUM **a, const char *str);
int 	BN_dec2bn(BIGNUM **a, const char *str);
int	BN_asc2bn(BIGNUM **a, const char *str);
int	BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
int	BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */
BIGNUM *BN_mod_inverse(BIGNUM *ret,
    const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);
BIGNUM *BN_mod_sqrt(BIGNUM *ret,
    const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);

void	BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords);

/* Deprecated versions */
#ifndef OPENSSL_NO_DEPRECATED
BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
    const BIGNUM *add, const BIGNUM *rem,
    void (*callback)(int, int, void *), void *cb_arg);
int	BN_is_prime(const BIGNUM *p, int nchecks,
    void (*callback)(int, int, void *),
    BN_CTX *ctx, void *cb_arg);
int	BN_is_prime_fasttest(const BIGNUM *p, int nchecks,
    void (*callback)(int, int, void *), BN_CTX *ctx, void *cb_arg,
    int do_trial_division);
#endif /* !defined(OPENSSL_NO_DEPRECATED) */

/* Newer versions */
int	BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add,
    const BIGNUM *rem, BN_GENCB *cb);
int	BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb);
int	BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx,
    int do_trial_division, BN_GENCB *cb);

int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);

int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
    const BIGNUM *Xp, const BIGNUM *Xp1, const BIGNUM *Xp2,
    const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb);
int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
    BIGNUM *Xp1, BIGNUM *Xp2,
    const BIGNUM *Xp,
    const BIGNUM *e, BN_CTX *ctx,
    BN_GENCB *cb);

BN_MONT_CTX *BN_MONT_CTX_new(void );
void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
    BN_MONT_CTX *mont, BN_CTX *ctx);
#define BN_to_montgomery(r,a,mont,ctx)	BN_mod_mul_montgomery(\
	(r),(a),&((mont)->RR),(mont),(ctx))
int BN_from_montgomery(BIGNUM *r, const BIGNUM *a,
    BN_MONT_CTX *mont, BN_CTX *ctx);
void BN_MONT_CTX_free(BN_MONT_CTX *mont);
int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx);
BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);
BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,
    const BIGNUM *mod, BN_CTX *ctx);

/* BN_BLINDING flags */
#define	BN_BLINDING_NO_UPDATE	0x00000001
#define	BN_BLINDING_NO_RECREATE	0x00000002

BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod);
void BN_BLINDING_free(BN_BLINDING *b);
int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx);
int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);
int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *);
#ifndef OPENSSL_NO_DEPRECATED
unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);
void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);
#endif
CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *);
unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);
BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
    const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
    int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
    const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx),
    BN_MONT_CTX *m_ctx);

#ifndef OPENSSL_NO_DEPRECATED
void BN_set_params(int mul, int high, int low, int mont);
int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */
#endif

void	BN_RECP_CTX_init(BN_RECP_CTX *recp);
BN_RECP_CTX *BN_RECP_CTX_new(void);
void	BN_RECP_CTX_free(BN_RECP_CTX *recp);
int	BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *rdiv, BN_CTX *ctx);
int	BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
    BN_RECP_CTX *recp, BN_CTX *ctx);
int	BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
    const BIGNUM *m, BN_CTX *ctx);
int	BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
    BN_RECP_CTX *recp, BN_CTX *ctx);

#ifndef OPENSSL_NO_EC2M

/* Functions for arithmetic over binary polynomials represented by BIGNUMs.
 *
 * The BIGNUM::neg property of BIGNUMs representing binary polynomials is
 * ignored.
 *
 * Note that input arguments are not const so that their bit arrays can
 * be expanded to the appropriate size if needed.
 */

int	BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); /*r = a + b*/
#define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b)
int	BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); /*r=a mod p*/
int
BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
	const BIGNUM *p, BN_CTX *ctx); /* r = (a * b) mod p */
int
BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
	BN_CTX *ctx); /* r = (a * a) mod p */
int
BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p,
	BN_CTX *ctx); /* r = (1 / b) mod p */
int
BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
	const BIGNUM *p, BN_CTX *ctx); /* r = (a / b) mod p */
int
BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
	const BIGNUM *p, BN_CTX *ctx); /* r = (a ^ b) mod p */
int
BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
	BN_CTX *ctx); /* r = sqrt(a) mod p */
int	BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
	BN_CTX *ctx); /* r^2 + r = a mod p */
#define BN_GF2m_cmp(a, b) BN_ucmp((a), (b))
/* Some functions allow for representation of the irreducible polynomials
 * as an unsigned int[], say p.  The irreducible f(t) is then of the form:
 *     t^p[0] + t^p[1] + ... + t^p[k]
 * where m = p[0] > p[1] > ... > p[k] = 0.
 */
int	BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]);
/* r = a mod p */
int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
	const int p[], BN_CTX *ctx); /* r = (a * b) mod p */
int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],
	BN_CTX *ctx); /* r = (a * a) mod p */
int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[],
	BN_CTX *ctx); /* r = (1 / b) mod p */
int	BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
	const int p[], BN_CTX *ctx); /* r = (a / b) mod p */
int	BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
	const int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */
int	BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,
	const int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */
int	BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,
	const int p[], BN_CTX *ctx); /* r^2 + r = a mod p */
int	BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);
int	BN_GF2m_arr2poly(const int p[], BIGNUM *a);

#endif

/* faster mod functions for the 'NIST primes'
 * 0 <= a < p^2 */
int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);

const BIGNUM *BN_get0_nist_prime_192(void);
const BIGNUM *BN_get0_nist_prime_224(void);
const BIGNUM *BN_get0_nist_prime_256(void);
const BIGNUM *BN_get0_nist_prime_384(void);
const BIGNUM *BN_get0_nist_prime_521(void);

/* library internal functions */

#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\
	(a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2))
#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))
BIGNUM *bn_expand2(BIGNUM *a, int words);
#ifndef OPENSSL_NO_DEPRECATED
BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */
#endif

/* Bignum consistency macros
 * There is one "API" macro, bn_fix_top(), for stripping leading zeroes from
 * bignum data after direct manipulations on the data. There is also an
 * "internal" macro, bn_check_top(), for verifying that there are no leading
 * zeroes. Unfortunately, some auditing is required due to the fact that
 * bn_fix_top() has become an overabused duct-tape because bignum data is
 * occasionally passed around in an inconsistent state. So the following
 * changes have been made to sort this out;
 * - bn_fix_top()s implementation has been moved to bn_correct_top()
 * - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and
 *   bn_check_top() is as before.
 * - if BN_DEBUG *is* defined;
 *   - bn_check_top() tries to pollute unused words even if the bignum 'top' is
 *     consistent. (ed: only if BN_DEBUG_RAND is defined)
 *   - bn_fix_top() maps to bn_check_top() rather than "fixing" anything.
 * The idea is to have debug builds flag up inconsistent bignums when they
 * occur. If that occurs in a bn_fix_top(), we examine the code in question; if
 * the use of bn_fix_top() was appropriate (ie. it follows directly after code
 * that manipulates the bignum) it is converted to bn_correct_top(), and if it
 * was not appropriate, we convert it permanently to bn_check_top() and track
 * down the cause of the bug. Eventually, no internal code should be using the
 * bn_fix_top() macro. External applications and libraries should try this with
 * their own code too, both in terms of building against the openssl headers
 * with BN_DEBUG defined *and* linking with a version of OpenSSL built with it
 * defined. This not only improves external code, it provides more test
 * coverage for openssl's own code.
 */

#ifdef BN_DEBUG

/* We only need assert() when debugging */
#include 

#ifdef BN_DEBUG_RAND
/* To avoid "make update" cvs wars due to BN_DEBUG, use some tricks */
#ifndef RAND_pseudo_bytes
int RAND_pseudo_bytes(unsigned char *buf, int num);
#define BN_DEBUG_TRIX
#endif
#define bn_pollute(a) \
	do { \
		const BIGNUM *_bnum1 = (a); \
		if(_bnum1->top < _bnum1->dmax) { \
			unsigned char _tmp_char; \
			/* We cast away const without the compiler knowing, any \
			 * *genuinely* constant variables that aren't mutable \
			 * wouldn't be constructed with top!=dmax. */ \
			BN_ULONG *_not_const; \
			memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \
			RAND_pseudo_bytes(&_tmp_char, 1); \
			memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \
				(_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \
		} \
	} while(0)
#ifdef BN_DEBUG_TRIX
#undef RAND_pseudo_bytes
#endif
#else
#define bn_pollute(a)
#endif
#define bn_check_top(a) \
	do { \
		const BIGNUM *_bnum2 = (a); \
		if (_bnum2 != NULL) { \
			assert((_bnum2->top == 0) || \
				(_bnum2->d[_bnum2->top - 1] != 0)); \
			bn_pollute(_bnum2); \
		} \
	} while(0)

#define bn_fix_top(a)		bn_check_top(a)

#define bn_check_size(bn, bits) bn_wcheck_size(bn, ((bits+BN_BITS2-1))/BN_BITS2)
#define bn_wcheck_size(bn, words) \
	do { \
		const BIGNUM *_bnum2 = (bn); \
		assert(words <= (_bnum2)->dmax && words >= (_bnum2)->top); \
	} while(0)

#else /* !BN_DEBUG */

#define bn_pollute(a)
#define bn_check_top(a)
#define bn_fix_top(a)		bn_correct_top(a)
#define bn_check_size(bn, bits)
#define bn_wcheck_size(bn, words)

#endif

#define bn_correct_top(a) \
        { \
        BN_ULONG *ftl; \
	int tmp_top = (a)->top; \
	if (tmp_top > 0) \
		{ \
		for (ftl= &((a)->d[tmp_top-1]); tmp_top > 0; tmp_top--) \
			if (*(ftl--)) break; \
		(a)->top = tmp_top; \
		} \
	bn_pollute(a); \
	}

			BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
void     bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);
BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, int num);
BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, int num);

/* Primes from RFC 2409 */
BIGNUM *get_rfc2409_prime_768(BIGNUM *bn);
BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn);

/* Primes from RFC 3526 */
BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn);
BIGNUM *get_rfc3526_prime_2048(BIGNUM *bn);
BIGNUM *get_rfc3526_prime_3072(BIGNUM *bn);
BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn);
BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn);
BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn);

int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom);

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_BN_strings(void);

/* Error codes for the BN functions. */

/* Function codes. */
#define BN_F_BNRAND					 127
#define BN_F_BN_BLINDING_CONVERT_EX			 100
#define BN_F_BN_BLINDING_CREATE_PARAM			 128
#define BN_F_BN_BLINDING_INVERT_EX			 101
#define BN_F_BN_BLINDING_NEW				 102
#define BN_F_BN_BLINDING_UPDATE				 103
#define BN_F_BN_BN2DEC					 104
#define BN_F_BN_BN2HEX					 105
#define BN_F_BN_CTX_GET					 116
#define BN_F_BN_CTX_NEW					 106
#define BN_F_BN_CTX_START				 129
#define BN_F_BN_DIV					 107
#define BN_F_BN_DIV_NO_BRANCH				 138
#define BN_F_BN_DIV_RECP				 130
#define BN_F_BN_EXP					 123
#define BN_F_BN_EXPAND2					 108
#define BN_F_BN_EXPAND_INTERNAL				 120
#define BN_F_BN_GF2M_MOD				 131
#define BN_F_BN_GF2M_MOD_EXP				 132
#define BN_F_BN_GF2M_MOD_MUL				 133
#define BN_F_BN_GF2M_MOD_SOLVE_QUAD			 134
#define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR			 135
#define BN_F_BN_GF2M_MOD_SQR				 136
#define BN_F_BN_GF2M_MOD_SQRT				 137
#define BN_F_BN_MOD_EXP2_MONT				 118
#define BN_F_BN_MOD_EXP_MONT				 109
#define BN_F_BN_MOD_EXP_MONT_CONSTTIME			 124
#define BN_F_BN_MOD_EXP_MONT_WORD			 117
#define BN_F_BN_MOD_EXP_RECP				 125
#define BN_F_BN_MOD_EXP_SIMPLE				 126
#define BN_F_BN_MOD_INVERSE				 110
#define BN_F_BN_MOD_INVERSE_NO_BRANCH			 139
#define BN_F_BN_MOD_LSHIFT_QUICK			 119
#define BN_F_BN_MOD_MUL_RECIPROCAL			 111
#define BN_F_BN_MOD_SQRT				 121
#define BN_F_BN_MPI2BN					 112
#define BN_F_BN_NEW					 113
#define BN_F_BN_RAND					 114
#define BN_F_BN_RAND_RANGE				 122
#define BN_F_BN_USUB					 115

/* Reason codes. */
#define BN_R_ARG2_LT_ARG3				 100
#define BN_R_BAD_RECIPROCAL				 101
#define BN_R_BIGNUM_TOO_LONG				 114
#define BN_R_CALLED_WITH_EVEN_MODULUS			 102
#define BN_R_DIV_BY_ZERO				 103
#define BN_R_ENCODING_ERROR				 104
#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA		 105
#define BN_R_INPUT_NOT_REDUCED				 110
#define BN_R_INVALID_LENGTH				 106
#define BN_R_INVALID_RANGE				 115
#define BN_R_NOT_A_SQUARE				 111
#define BN_R_NOT_INITIALIZED				 107
#define BN_R_NO_INVERSE					 108
#define BN_R_NO_SOLUTION				 116
#define BN_R_P_IS_NOT_PRIME				 112
#define BN_R_TOO_MANY_ITERATIONS			 113
#define BN_R_TOO_MANY_TEMPORARY_VARIABLES		 109

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/pkcs12.h0000644000175000017500000003056512360020705021326 0ustar  /* $OpenBSD: pkcs12.h,v 1.12 2014/06/12 15:49:30 deraadt Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
 * project 1999.
 */
/* ====================================================================
 * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#ifndef HEADER_PKCS12_H
#define HEADER_PKCS12_H

#include 
#include 

#ifdef __cplusplus
extern "C" {
#endif

#define PKCS12_KEY_ID	1
#define PKCS12_IV_ID	2
#define PKCS12_MAC_ID	3

/* Default iteration count */
#ifndef PKCS12_DEFAULT_ITER
#define PKCS12_DEFAULT_ITER	PKCS5_DEFAULT_ITER
#endif

#define PKCS12_MAC_KEY_LENGTH 20

#define PKCS12_SALT_LEN	8

/* Uncomment out next line for unicode password and names, otherwise ASCII */

/*#define PBE_UNICODE*/

#ifdef PBE_UNICODE
#define PKCS12_key_gen PKCS12_key_gen_uni
#define PKCS12_add_friendlyname PKCS12_add_friendlyname_uni
#else
#define PKCS12_key_gen PKCS12_key_gen_asc
#define PKCS12_add_friendlyname PKCS12_add_friendlyname_asc
#endif

/* MS key usage constants */

#define KEY_EX	0x10
#define KEY_SIG 0x80

typedef struct {
	X509_SIG *dinfo;
	ASN1_OCTET_STRING *salt;
	ASN1_INTEGER *iter;	/* defaults to 1 */
} PKCS12_MAC_DATA;

typedef struct {
	ASN1_INTEGER *version;
	PKCS12_MAC_DATA *mac;
	PKCS7 *authsafes;
} PKCS12;

typedef struct {
	ASN1_OBJECT *type;
	union {
	struct pkcs12_bag_st *bag; /* secret, crl and certbag */
	struct pkcs8_priv_key_info_st	*keybag; /* keybag */
	X509_SIG *shkeybag; /* shrouded key bag */
		STACK_OF(PKCS12_SAFEBAG) *safes;
		ASN1_TYPE *other;
	} value;
	STACK_OF(X509_ATTRIBUTE) *attrib;
} PKCS12_SAFEBAG;

DECLARE_STACK_OF(PKCS12_SAFEBAG)
DECLARE_ASN1_SET_OF(PKCS12_SAFEBAG)
DECLARE_PKCS12_STACK_OF(PKCS12_SAFEBAG)

typedef struct pkcs12_bag_st {
	ASN1_OBJECT *type;
	union {
		ASN1_OCTET_STRING *x509cert;
		ASN1_OCTET_STRING *x509crl;
		ASN1_OCTET_STRING *octet;
		ASN1_IA5STRING *sdsicert;
		ASN1_TYPE *other; /* Secret or other bag */
	} value;
} PKCS12_BAGS;

#define PKCS12_ERROR	0
#define PKCS12_OK	1

/* Compatibility macros */

#define M_PKCS12_x5092certbag PKCS12_x5092certbag
#define M_PKCS12_x509crl2certbag PKCS12_x509crl2certbag

#define M_PKCS12_certbag2x509 PKCS12_certbag2x509
#define M_PKCS12_certbag2x509crl PKCS12_certbag2x509crl

#define M_PKCS12_unpack_p7data PKCS12_unpack_p7data
#define M_PKCS12_pack_authsafes PKCS12_pack_authsafes
#define M_PKCS12_unpack_authsafes PKCS12_unpack_authsafes
#define M_PKCS12_unpack_p7encdata PKCS12_unpack_p7encdata

#define M_PKCS12_decrypt_skey PKCS12_decrypt_skey
#define M_PKCS8_decrypt PKCS8_decrypt

#define M_PKCS12_bag_type(bg) OBJ_obj2nid((bg)->type)
#define M_PKCS12_cert_bag_type(bg) OBJ_obj2nid((bg)->value.bag->type)
#define M_PKCS12_crl_bag_type M_PKCS12_cert_bag_type

#define PKCS12_get_attr(bag, attr_nid) \
			 PKCS12_get_attr_gen(bag->attrib, attr_nid)

#define PKCS8_get_attr(p8, attr_nid) \
		PKCS12_get_attr_gen(p8->attributes, attr_nid)

#define PKCS12_mac_present(p12) ((p12)->mac ? 1 : 0)


PKCS12_SAFEBAG *PKCS12_x5092certbag(X509 *x509);
PKCS12_SAFEBAG *PKCS12_x509crl2certbag(X509_CRL *crl);
X509 *PKCS12_certbag2x509(PKCS12_SAFEBAG *bag);
X509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag);

PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it,
    int nid1, int nid2);
PKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8);
PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass, int passlen);
PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag, const char *pass,
    int passlen);
X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,
    const char *pass, int passlen, unsigned char *salt, int saltlen, int iter,
    PKCS8_PRIV_KEY_INFO *p8);
PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass,
    int passlen, unsigned char *salt, int saltlen, int iter,
    PKCS8_PRIV_KEY_INFO *p8);
PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk);
STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7);
PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen,
    unsigned char *salt, int saltlen, int iter, STACK_OF(PKCS12_SAFEBAG) *bags);
STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass,
    int passlen);

int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes);
STACK_OF(PKCS7) *PKCS12_unpack_authsafes(PKCS12 *p12);

int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name,
    int namelen);
int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name,
    int namelen);
int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name,
    int namelen);
int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, const unsigned char *name,
    int namelen);
int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage);
ASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid);
char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag);
unsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass,
    int passlen, unsigned char *in, int inlen, unsigned char **data,
    int *datalen, int en_de);
void * PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it,
    const char *pass, int passlen, ASN1_OCTET_STRING *oct, int zbuf);
ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor,
    const ASN1_ITEM *it, const char *pass, int passlen, void *obj, int zbuf);
PKCS12 *PKCS12_init(int mode);
int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,
    int saltlen, int id, int iter, int n, unsigned char *out,
    const EVP_MD *md_type);
int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
    int saltlen, int id, int iter, int n, unsigned char *out,
    const EVP_MD *md_type);
int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
    ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md_type,
    int en_de);
int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,
    unsigned char *mac, unsigned int *maclen);
int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen);
int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen,
    unsigned char *salt, int saltlen, int iter,
    const EVP_MD *md_type);
int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt,
    int saltlen, const EVP_MD *md_type);
unsigned char *OPENSSL_asc2uni(const char *asc, int asclen,
    unsigned char **uni, int *unilen);
char *OPENSSL_uni2asc(unsigned char *uni, int unilen);

DECLARE_ASN1_FUNCTIONS(PKCS12)
DECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA)
DECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG)
DECLARE_ASN1_FUNCTIONS(PKCS12_BAGS)

DECLARE_ASN1_ITEM(PKCS12_SAFEBAGS)
DECLARE_ASN1_ITEM(PKCS12_AUTHSAFES)

void PKCS12_PBE_add(void);
int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
    STACK_OF(X509) **ca);
PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,
    STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter,
    int mac_iter, int keytype);

PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert);
PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, EVP_PKEY *key,
    int key_usage, int iter, int key_nid, char *pass);
int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,
    int safe_nid, int iter, char *pass);
PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid);

int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12);
int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12);
PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12);
PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);
int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass);

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_PKCS12_strings(void);

/* Error codes for the PKCS12 functions. */

/* Function codes. */
#define PKCS12_F_PARSE_BAG				 129
#define PKCS12_F_PARSE_BAGS				 103
#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME		 100
#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_ASC		 127
#define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI		 102
#define PKCS12_F_PKCS12_ADD_LOCALKEYID			 104
#define PKCS12_F_PKCS12_CREATE				 105
#define PKCS12_F_PKCS12_GEN_MAC				 107
#define PKCS12_F_PKCS12_INIT				 109
#define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I		 106
#define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT		 108
#define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG		 117
#define PKCS12_F_PKCS12_KEY_GEN_ASC			 110
#define PKCS12_F_PKCS12_KEY_GEN_UNI			 111
#define PKCS12_F_PKCS12_MAKE_KEYBAG			 112
#define PKCS12_F_PKCS12_MAKE_SHKEYBAG			 113
#define PKCS12_F_PKCS12_NEWPASS				 128
#define PKCS12_F_PKCS12_PACK_P7DATA			 114
#define PKCS12_F_PKCS12_PACK_P7ENCDATA			 115
#define PKCS12_F_PKCS12_PARSE				 118
#define PKCS12_F_PKCS12_PBE_CRYPT			 119
#define PKCS12_F_PKCS12_PBE_KEYIVGEN			 120
#define PKCS12_F_PKCS12_SETUP_MAC			 122
#define PKCS12_F_PKCS12_SET_MAC				 123
#define PKCS12_F_PKCS12_UNPACK_AUTHSAFES		 130
#define PKCS12_F_PKCS12_UNPACK_P7DATA			 131
#define PKCS12_F_PKCS12_VERIFY_MAC			 126
#define PKCS12_F_PKCS8_ADD_KEYUSAGE			 124
#define PKCS12_F_PKCS8_ENCRYPT				 125

/* Reason codes. */
#define PKCS12_R_CANT_PACK_STRUCTURE			 100
#define PKCS12_R_CONTENT_TYPE_NOT_DATA			 121
#define PKCS12_R_DECODE_ERROR				 101
#define PKCS12_R_ENCODE_ERROR				 102
#define PKCS12_R_ENCRYPT_ERROR				 103
#define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE	 120
#define PKCS12_R_INVALID_NULL_ARGUMENT			 104
#define PKCS12_R_INVALID_NULL_PKCS12_POINTER		 105
#define PKCS12_R_IV_GEN_ERROR				 106
#define PKCS12_R_KEY_GEN_ERROR				 107
#define PKCS12_R_MAC_ABSENT				 108
#define PKCS12_R_MAC_GENERATION_ERROR			 109
#define PKCS12_R_MAC_SETUP_ERROR			 110
#define PKCS12_R_MAC_STRING_SET_ERROR			 111
#define PKCS12_R_MAC_VERIFY_ERROR			 112
#define PKCS12_R_MAC_VERIFY_FAILURE			 113
#define PKCS12_R_PARSE_ERROR				 114
#define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR		 115
#define PKCS12_R_PKCS12_CIPHERFINAL_ERROR		 116
#define PKCS12_R_PKCS12_PBE_CRYPT_ERROR			 117
#define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM		 118
#define PKCS12_R_UNSUPPORTED_PKCS12_MODE		 119

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/conf.h0000644000175000017500000002303312360020705021140 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef  HEADER_CONF_H
#define HEADER_CONF_H

#include 

#include 
#include 
#include 
#include 

#include 

#ifdef  __cplusplus
extern "C" {
#endif

typedef struct {
	char *section;
	char *name;
	char *value;
} CONF_VALUE;

DECLARE_STACK_OF(CONF_VALUE)
DECLARE_LHASH_OF(CONF_VALUE);

struct conf_st;
struct conf_method_st;
typedef struct conf_method_st CONF_METHOD;

struct conf_method_st {
	const char *name;
	CONF *(*create)(CONF_METHOD *meth);
	int (*init)(CONF *conf);
	int (*destroy)(CONF *conf);
	int (*destroy_data)(CONF *conf);
	int (*load_bio)(CONF *conf, BIO *bp, long *eline);
	int (*dump)(const CONF *conf, BIO *bp);
	int (*is_number)(const CONF *conf, char c);
	int (*to_int)(const CONF *conf, char c);
	int (*load)(CONF *conf, const char *name, long *eline);
};

/* Module definitions */

typedef struct conf_imodule_st CONF_IMODULE;
typedef struct conf_module_st CONF_MODULE;

DECLARE_STACK_OF(CONF_MODULE)
DECLARE_STACK_OF(CONF_IMODULE)

/* DSO module function typedefs */
typedef int conf_init_func(CONF_IMODULE *md, const CONF *cnf);
typedef void conf_finish_func(CONF_IMODULE *md);

#define	CONF_MFLAGS_IGNORE_ERRORS	0x1
#define CONF_MFLAGS_IGNORE_RETURN_CODES	0x2
#define CONF_MFLAGS_SILENT		0x4
#define CONF_MFLAGS_NO_DSO		0x8
#define CONF_MFLAGS_IGNORE_MISSING_FILE	0x10
#define CONF_MFLAGS_DEFAULT_SECTION	0x20

int CONF_set_default_method(CONF_METHOD *meth);
void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash);
LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
    long *eline);
LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
    long *eline);
LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp, long *eline);
STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,
    const char *section);
char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group,
    const char *name);
long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group,
    const char *name);
void CONF_free(LHASH_OF(CONF_VALUE) *conf);
int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);
int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);

void OPENSSL_config(const char *config_name);
void OPENSSL_no_config(void);

/* New conf code.  The semantics are different from the functions above.
   If that wasn't the case, the above functions would have been replaced */

struct conf_st {
	CONF_METHOD *meth;
	void *meth_data;
	LHASH_OF(CONF_VALUE) *data;
};

CONF *NCONF_new(CONF_METHOD *meth);
CONF_METHOD *NCONF_default(void);
CONF_METHOD *NCONF_WIN32(void);
#if 0 /* Just to give you an idea of what I have in mind */
CONF_METHOD *NCONF_XML(void);
#endif
void NCONF_free(CONF *conf);
void NCONF_free_data(CONF *conf);

int NCONF_load(CONF *conf, const char *file, long *eline);
int NCONF_load_fp(CONF *conf, FILE *fp, long *eline);
int NCONF_load_bio(CONF *conf, BIO *bp, long *eline);
STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, const char *section);
char *NCONF_get_string(const CONF *conf, const char *group, const char *name);
int NCONF_get_number_e(const CONF *conf, const char *group, const char *name,
    long *result);
int NCONF_dump_fp(const CONF *conf, FILE *out);
int NCONF_dump_bio(const CONF *conf, BIO *out);

#if 0 /* The following function has no error checking,
	 and should therefore be avoided */
long NCONF_get_number(CONF *conf, char *group, char *name);
#else
#define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r)
#endif

/* Module functions */

int CONF_modules_load(const CONF *cnf, const char *appname,
    unsigned long flags);
int CONF_modules_load_file(const char *filename, const char *appname,
    unsigned long flags);
void CONF_modules_unload(int all);
void CONF_modules_finish(void);
void CONF_modules_free(void);
int CONF_module_add(const char *name, conf_init_func *ifunc,
    conf_finish_func *ffunc);

const char *CONF_imodule_get_name(const CONF_IMODULE *md);
const char *CONF_imodule_get_value(const CONF_IMODULE *md);
void *CONF_imodule_get_usr_data(const CONF_IMODULE *md);
void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data);
CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md);
unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md);
void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags);
void *CONF_module_get_usr_data(CONF_MODULE *pmod);
void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data);

char *CONF_get1_default_config_file(void);

int CONF_parse_list(const char *list, int sep, int nospc,
    int (*list_cb)(const char *elem, int len, void *usr), void *arg);

void OPENSSL_load_builtin_modules(void);

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_CONF_strings(void);

/* Error codes for the CONF functions. */

/* Function codes. */
#define CONF_F_CONF_DUMP_FP				 104
#define CONF_F_CONF_LOAD				 100
#define CONF_F_CONF_LOAD_BIO				 102
#define CONF_F_CONF_LOAD_FP				 103
#define CONF_F_CONF_MODULES_LOAD			 116
#define CONF_F_CONF_PARSE_LIST				 119
#define CONF_F_DEF_LOAD					 120
#define CONF_F_DEF_LOAD_BIO				 121
#define CONF_F_MODULE_INIT				 115
#define CONF_F_MODULE_LOAD_DSO				 117
#define CONF_F_MODULE_RUN				 118
#define CONF_F_NCONF_DUMP_BIO				 105
#define CONF_F_NCONF_DUMP_FP				 106
#define CONF_F_NCONF_GET_NUMBER				 107
#define CONF_F_NCONF_GET_NUMBER_E			 112
#define CONF_F_NCONF_GET_SECTION			 108
#define CONF_F_NCONF_GET_STRING				 109
#define CONF_F_NCONF_LOAD				 113
#define CONF_F_NCONF_LOAD_BIO				 110
#define CONF_F_NCONF_LOAD_FP				 114
#define CONF_F_NCONF_NEW				 111
#define CONF_F_STR_COPY					 101

/* Reason codes. */
#define CONF_R_ERROR_LOADING_DSO			 110
#define CONF_R_LIST_CANNOT_BE_NULL			 115
#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET		 100
#define CONF_R_MISSING_EQUAL_SIGN			 101
#define CONF_R_MISSING_FINISH_FUNCTION			 111
#define CONF_R_MISSING_INIT_FUNCTION			 112
#define CONF_R_MODULE_INITIALIZATION_ERROR		 109
#define CONF_R_NO_CLOSE_BRACE				 102
#define CONF_R_NO_CONF					 105
#define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE		 106
#define CONF_R_NO_SECTION				 107
#define CONF_R_NO_SUCH_FILE				 114
#define CONF_R_NO_VALUE					 108
#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION		 103
#define CONF_R_UNKNOWN_MODULE_NAME			 113
#define CONF_R_VARIABLE_HAS_NO_VALUE			 104

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/crypto.h0000644000175000017500000005522212360020705021540 0ustar  /* $OpenBSD: crypto.h,v 1.31 2014/06/24 19:33:10 miod Exp $ */
/* ====================================================================
 * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */
/* ====================================================================
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 * ECDH support in OpenSSL originally developed by
 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
 */

#include 
#include 

#ifndef HEADER_CRYPTO_H
#define HEADER_CRYPTO_H

#include 

#include 
#include 
#include 
#include 

#ifdef  __cplusplus
extern "C" {
#endif

/* Backward compatibility to SSLeay */
/* This is more to be used to check the correct DLL is being used
 * in the MS world. */
#define SSLEAY_VERSION_NUMBER	OPENSSL_VERSION_NUMBER
#define SSLEAY_VERSION		0
/* #define SSLEAY_OPTIONS	1 no longer supported */
#define SSLEAY_CFLAGS		2
#define SSLEAY_BUILT_ON		3
#define SSLEAY_PLATFORM		4
#define SSLEAY_DIR		5

/* Already declared in ossl_typ.h */
#if 0
typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
/* Called when a new object is created */
typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
    int idx, long argl, void *argp);
/* Called when an object is free()ed */
typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
    int idx, long argl, void *argp);
/* Called when we need to dup an object */
typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from,
    void *from_d, int idx, long argl, void *argp);
#endif

/* A generic structure to pass assorted data in a expandable way */
typedef struct openssl_item_st {
	int code;
	void *value;		/* Not used for flag attributes */
	size_t value_size;	/* Max size of value for output, length for input */
	size_t *value_length;	/* Returned length of value for output */
} OPENSSL_ITEM;


/* When changing the CRYPTO_LOCK_* list, be sure to maintain the text lock
 * names in cryptlib.c
 */

#define	CRYPTO_LOCK_ERR			1
#define	CRYPTO_LOCK_EX_DATA		2
#define	CRYPTO_LOCK_X509		3
#define	CRYPTO_LOCK_X509_INFO		4
#define	CRYPTO_LOCK_X509_PKEY		5
#define CRYPTO_LOCK_X509_CRL		6
#define CRYPTO_LOCK_X509_REQ		7
#define CRYPTO_LOCK_DSA			8
#define CRYPTO_LOCK_RSA			9
#define CRYPTO_LOCK_EVP_PKEY		10
#define CRYPTO_LOCK_X509_STORE		11
#define CRYPTO_LOCK_SSL_CTX		12
#define CRYPTO_LOCK_SSL_CERT		13
#define CRYPTO_LOCK_SSL_SESSION		14
#define CRYPTO_LOCK_SSL_SESS_CERT	15
#define CRYPTO_LOCK_SSL			16
#define CRYPTO_LOCK_SSL_METHOD		17
#define CRYPTO_LOCK_RAND		18
#define CRYPTO_LOCK_RAND2		19
#define CRYPTO_LOCK_MALLOC		20
#define CRYPTO_LOCK_BIO			21
#define CRYPTO_LOCK_GETHOSTBYNAME	22
#define CRYPTO_LOCK_GETSERVBYNAME	23
#define CRYPTO_LOCK_READDIR		24
#define CRYPTO_LOCK_RSA_BLINDING	25
#define CRYPTO_LOCK_DH			26
#define CRYPTO_LOCK_MALLOC2		27
#define CRYPTO_LOCK_DSO			28
#define CRYPTO_LOCK_DYNLOCK		29
#define CRYPTO_LOCK_ENGINE		30
#define CRYPTO_LOCK_UI			31
#define CRYPTO_LOCK_ECDSA               32
#define CRYPTO_LOCK_EC			33
#define CRYPTO_LOCK_ECDH		34
#define CRYPTO_LOCK_BN  		35
#define CRYPTO_LOCK_EC_PRE_COMP		36
#define CRYPTO_LOCK_STORE		37
#define CRYPTO_LOCK_COMP		38
#define CRYPTO_LOCK_FIPS		39
#define CRYPTO_LOCK_FIPS2		40
#define CRYPTO_NUM_LOCKS		41

#define CRYPTO_LOCK		1
#define CRYPTO_UNLOCK		2
#define CRYPTO_READ		4
#define CRYPTO_WRITE		8

#ifndef OPENSSL_NO_LOCKING
#ifndef CRYPTO_w_lock
#define CRYPTO_w_lock(type)	\
	CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
#define CRYPTO_w_unlock(type)	\
	CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
#define CRYPTO_r_lock(type)	\
	CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)
#define CRYPTO_r_unlock(type)	\
	CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)
#define CRYPTO_add(addr,amount,type)	\
	CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)
#endif
#else
#define CRYPTO_w_lock(a)
#define CRYPTO_w_unlock(a)
#define CRYPTO_r_lock(a)
#define CRYPTO_r_unlock(a)
#define CRYPTO_add(a,b,c)	((*(a))+=(b))
#endif

/* Some applications as well as some parts of OpenSSL need to allocate
   and deallocate locks in a dynamic fashion.  The following typedef
   makes this possible in a type-safe manner.  */
/* struct CRYPTO_dynlock_value has to be defined by the application. */
typedef struct {
	int references;
	struct CRYPTO_dynlock_value *data;
} CRYPTO_dynlock;


/* The following can be used to detect memory leaks in the SSLeay library.
 * It used, it turns on malloc checking */

#define CRYPTO_MEM_CHECK_OFF	0x0	/* an enume */
#define CRYPTO_MEM_CHECK_ON	0x1	/* a bit */
#define CRYPTO_MEM_CHECK_ENABLE	0x2	/* a bit */
#define CRYPTO_MEM_CHECK_DISABLE 0x3	/* an enume */

/* The following are bit values to turn on or off options connected to the
 * malloc checking functionality */

/* Adds time to the memory checking information */
#define V_CRYPTO_MDEBUG_TIME	0x1 /* a bit */
/* Adds thread number to the memory checking information */
#define V_CRYPTO_MDEBUG_THREAD	0x2 /* a bit */

#define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD)


/* predec of the BIO type */
typedef struct bio_st BIO_dummy;

struct crypto_ex_data_st {
	STACK_OF(void) *sk;
};
DECLARE_STACK_OF(void)

/* This stuff is basically class callback functions
 * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */

typedef struct crypto_ex_data_func_st {
	long argl;	/* Arbitary long */
	void *argp;	/* Arbitary void * */
	CRYPTO_EX_new *new_func;
	CRYPTO_EX_free *free_func;
	CRYPTO_EX_dup *dup_func;
} CRYPTO_EX_DATA_FUNCS;

DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)

/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA
 * entry.
 */

#define CRYPTO_EX_INDEX_BIO		0
#define CRYPTO_EX_INDEX_SSL		1
#define CRYPTO_EX_INDEX_SSL_CTX		2
#define CRYPTO_EX_INDEX_SSL_SESSION	3
#define CRYPTO_EX_INDEX_X509_STORE	4
#define CRYPTO_EX_INDEX_X509_STORE_CTX	5
#define CRYPTO_EX_INDEX_RSA		6
#define CRYPTO_EX_INDEX_DSA		7
#define CRYPTO_EX_INDEX_DH		8
#define CRYPTO_EX_INDEX_ENGINE		9
#define CRYPTO_EX_INDEX_X509		10
#define CRYPTO_EX_INDEX_UI		11
#define CRYPTO_EX_INDEX_ECDSA		12
#define CRYPTO_EX_INDEX_ECDH		13
#define CRYPTO_EX_INDEX_COMP		14
#define CRYPTO_EX_INDEX_STORE		15

/* Dynamically assigned indexes start from this value (don't use directly, use
 * via CRYPTO_ex_data_new_class). */
#define CRYPTO_EX_INDEX_USER		100

/* This is the default callbacks, but we can have others as well:
 * this is needed in Win32 where the application malloc and the
 * library malloc may not be the same.
 */
#define CRYPTO_malloc_init()	CRYPTO_set_mem_functions(\
	malloc, realloc, free)

#if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD
# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */
#  define CRYPTO_MDEBUG
# endif
#endif

/* Set standard debugging functions (not done by default
 * unless CRYPTO_MDEBUG is defined) */
#define CRYPTO_malloc_debug_init()	do {\
	CRYPTO_set_mem_debug_functions(\
		CRYPTO_dbg_malloc,\
		CRYPTO_dbg_realloc,\
		CRYPTO_dbg_free,\
		CRYPTO_dbg_set_options,\
		CRYPTO_dbg_get_options);\
	} while(0)

int CRYPTO_mem_ctrl(int mode);
int CRYPTO_is_mem_check_on(void);

/* for applications */
#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)
#define MemCheck_stop()	CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)

#define OPENSSL_malloc(num)	CRYPTO_malloc((int)num,__FILE__,__LINE__)
#define OPENSSL_strdup(str)	CRYPTO_strdup((str),__FILE__,__LINE__)
#define OPENSSL_realloc(addr,num) \
	CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
#define OPENSSL_realloc_clean(addr,old_num,num) \
	CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)
#define OPENSSL_remalloc(addr,num) \
	CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
#define OPENSSL_freeFunc	CRYPTO_free
#define OPENSSL_free(addr)	CRYPTO_free(addr)

#define OPENSSL_malloc_locked(num) \
	CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
#define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)


const char *SSLeay_version(int type);
unsigned long SSLeay(void);

int OPENSSL_issetugid(void);

/* An opaque type representing an implementation of "ex_data" support */
typedef struct st_CRYPTO_EX_DATA_IMPL	CRYPTO_EX_DATA_IMPL;
/* Return an opaque pointer to the current "ex_data" implementation */
const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);
/* Sets the "ex_data" implementation to be used (if it's not too late) */
int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);
/* Get a new "ex_data" class, and return the corresponding "class_index" */
int CRYPTO_ex_data_new_class(void);
/* Within a given class, get/register a new index */
int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
    CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
    CRYPTO_EX_free *free_func);
/* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given
 * class (invokes whatever per-class callbacks are applicable) */
int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
    CRYPTO_EX_DATA *from);
void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
/* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index
 * (relative to the class type involved) */
int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx);
/* This function cleans up all "ex_data" state. It mustn't be called under
 * potential race-conditions. */
void CRYPTO_cleanup_all_ex_data(void);

int CRYPTO_get_new_lockid(char *name);

int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */
void CRYPTO_lock(int mode, int type, const char *file, int line);
void CRYPTO_set_locking_callback(void (*func)(int mode, int type,
    const char *file, int line));
void (*CRYPTO_get_locking_callback(void))(int mode, int type,
    const char *file, int line);
void CRYPTO_set_add_lock_callback(int (*func)(int *num, int mount, int type,
    const char *file, int line));
int (*CRYPTO_get_add_lock_callback(void))(int *num, int mount, int type,
    const char *file, int line);

/* Don't use this structure directly. */
typedef struct crypto_threadid_st {
	void *ptr;
	unsigned long val;
} CRYPTO_THREADID;
/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */
void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val);
void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr);
int CRYPTO_THREADID_set_callback(void (*threadid_func)(CRYPTO_THREADID *));
void (*CRYPTO_THREADID_get_callback(void))(CRYPTO_THREADID *);
void CRYPTO_THREADID_current(CRYPTO_THREADID *id);
int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b);
void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src);
unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id);
#ifndef OPENSSL_NO_DEPRECATED
void CRYPTO_set_id_callback(unsigned long (*func)(void));
unsigned long (*CRYPTO_get_id_callback(void))(void);
unsigned long CRYPTO_thread_id(void);
#endif

const char *CRYPTO_get_lock_name(int type);
int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
    int line);

int CRYPTO_get_new_dynlockid(void);
void CRYPTO_destroy_dynlockid(int i);
struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);
void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line));
void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line));
void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line));
struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file, int line);
void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line);
void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file, int line);

/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions --
 * call the latter last if you need different functions */
int CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t), void (*f)(void *));
int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
int CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int),
    void *(*r)(void *, size_t, const char *, int), void (*f)(void *));
int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int),
    void (*free_func)(void *));
int CRYPTO_set_mem_debug_functions(
    void (*m)(void *, int, const char *, int, int),
    void (*r)(void *, void *, int, const char *, int, int),
    void (*f)(void *, int), void (*so)(long), long (*go)(void));
void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
    void (**f)(void *));
void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
void CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int),
    void *(**r)(void *, size_t, const char *, int), void (**f)(void *));
void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int),
    void (**f)(void *));
void CRYPTO_get_mem_debug_functions(
    void (**m)(void *, int, const char *, int, int),
    void (**r)(void *, void *, int, const char *, int, int),
    void (**f)(void *, int), void (**so)(long), long (**go)(void));

#ifndef LIBRESSL_INTERNAL
void *CRYPTO_malloc_locked(int num, const char *file, int line);
void CRYPTO_free_locked(void *ptr);
void *CRYPTO_malloc(int num, const char *file, int line);
char *CRYPTO_strdup(const char *str, const char *file, int line);
void CRYPTO_free(void *ptr);
void *CRYPTO_realloc(void *addr, int num, const char *file, int line);
#endif
void *CRYPTO_realloc_clean(void *addr, int old_num, int num,
    const char *file, int line);
void *CRYPTO_remalloc(void *addr, int num, const char *file, int line);

void OPENSSL_cleanse(void *ptr, size_t len);

void CRYPTO_set_mem_debug_options(long bits);
long CRYPTO_get_mem_debug_options(void);

#define CRYPTO_push_info(info) \
        CRYPTO_push_info_(info, __FILE__, __LINE__);
int CRYPTO_push_info_(const char *info, const char *file, int line);
int CRYPTO_pop_info(void);
int CRYPTO_remove_all_info(void);


/* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro;
 * used as default in CRYPTO_MDEBUG compilations): */
/* The last argument has the following significance:
 *
 * 0:	called before the actual memory allocation has taken place
 * 1:	called after the actual memory allocation has taken place
 */
void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line, int before_p)
	__attribute__ ((deprecated));
void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, const char *file, int line, int before_p)
	__attribute__ ((deprecated));
void CRYPTO_dbg_free(void *addr, int before_p)
	__attribute__ ((deprecated));
/* Tell the debugging code about options.  By default, the following values
 * apply:
 *
 * 0:                           Clear all options.
 * V_CRYPTO_MDEBUG_TIME (1):    Set the "Show Time" option.
 * V_CRYPTO_MDEBUG_THREAD (2):  Set the "Show Thread Number" option.
 * V_CRYPTO_MDEBUG_ALL (3):     1 + 2
 */
void CRYPTO_dbg_set_options(long bits)
	__attribute__ ((deprecated));
long CRYPTO_dbg_get_options(void)
	__attribute__ ((deprecated));


void CRYPTO_mem_leaks_fp(FILE *);
void CRYPTO_mem_leaks(struct bio_st *bio);
/* unsigned long order, char *file, int line, int num_bytes, char *addr */
typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);

/* die if we have to */
void OpenSSLDie(const char *file, int line, const char *assertion);
#define OPENSSL_assert(e)       (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))

unsigned long *OPENSSL_ia32cap_loc(void);
#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))
int OPENSSL_isservice(void);

void OPENSSL_init(void);

/* CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal. It
 * takes an amount of time dependent on |len|, but independent of the contents
 * of |a| and |b|. Unlike memcmp, it cannot be used to put elements into a
 * defined order as the return value when a != b is undefined, other than to be
 * non-zero. */
int CRYPTO_memcmp(const void *a, const void *b, size_t len);

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_CRYPTO_strings(void);

/* Error codes for the CRYPTO functions. */

/* Function codes. */
#define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX		 100
#define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID		 103
#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID			 101
#define CRYPTO_F_CRYPTO_SET_EX_DATA			 102
#define CRYPTO_F_DEF_ADD_INDEX				 104
#define CRYPTO_F_DEF_GET_CLASS				 105
#define CRYPTO_F_FIPS_MODE_SET				 109
#define CRYPTO_F_INT_DUP_EX_DATA			 106
#define CRYPTO_F_INT_FREE_EX_DATA			 107
#define CRYPTO_F_INT_NEW_EX_DATA			 108

/* Reason codes. */
#define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED		 101
#define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK		 100

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/x509v3.h0000644000175000017500000010004712360020705021172 0ustar  /* $OpenBSD: x509v3.h,v 1.14 2014/06/12 15:49:31 deraadt Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
 * project 1999.
 */
/* ====================================================================
 * Copyright (c) 1999-2004 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */
#ifndef HEADER_X509V3_H
#define HEADER_X509V3_H

#include 

#include 
#include 
#include 

#ifdef __cplusplus
extern "C" {
#endif

/* Forward reference */
struct v3_ext_method;
struct v3_ext_ctx;

/* Useful typedefs */

typedef void * (*X509V3_EXT_NEW)(void);
typedef void (*X509V3_EXT_FREE)(void *);
typedef void * (*X509V3_EXT_D2I)(void *, const unsigned char ** , long);
typedef int (*X509V3_EXT_I2D)(void *, unsigned char **);
typedef STACK_OF(CONF_VALUE) *
  (*X509V3_EXT_I2V)(const struct v3_ext_method *method, void *ext,
		    STACK_OF(CONF_VALUE) *extlist);
typedef void * (*X509V3_EXT_V2I)(const struct v3_ext_method *method,
				 struct v3_ext_ctx *ctx,
				 STACK_OF(CONF_VALUE) *values);
typedef char * (*X509V3_EXT_I2S)(const struct v3_ext_method *method, void *ext);
typedef void * (*X509V3_EXT_S2I)(const struct v3_ext_method *method,
				 struct v3_ext_ctx *ctx, const char *str);
typedef int (*X509V3_EXT_I2R)(const struct v3_ext_method *method, void *ext,
			      BIO *out, int indent);
typedef void * (*X509V3_EXT_R2I)(const struct v3_ext_method *method,
				 struct v3_ext_ctx *ctx, const char *str);

/* V3 extension structure */

struct v3_ext_method {
int ext_nid;
int ext_flags;
/* If this is set the following four fields are ignored */
ASN1_ITEM_EXP *it;
/* Old style ASN1 calls */
X509V3_EXT_NEW ext_new;
X509V3_EXT_FREE ext_free;
X509V3_EXT_D2I d2i;
X509V3_EXT_I2D i2d;

/* The following pair is used for string extensions */
X509V3_EXT_I2S i2s;
X509V3_EXT_S2I s2i;

/* The following pair is used for multi-valued extensions */
X509V3_EXT_I2V i2v;
X509V3_EXT_V2I v2i;

/* The following are used for raw extensions */
X509V3_EXT_I2R i2r;
X509V3_EXT_R2I r2i;

void *usr_data;	/* Any extension specific data */
};

typedef struct X509V3_CONF_METHOD_st {
char * (*get_string)(void *db, char *section, char *value);
STACK_OF(CONF_VALUE) * (*get_section)(void *db, char *section);
void (*free_string)(void *db, char * string);
void (*free_section)(void *db, STACK_OF(CONF_VALUE) *section);
} X509V3_CONF_METHOD;

/* Context specific info */
struct v3_ext_ctx {
#define CTX_TEST 0x1
int flags;
X509 *issuer_cert;
X509 *subject_cert;
X509_REQ *subject_req;
X509_CRL *crl;
X509V3_CONF_METHOD *db_meth;
void *db;
/* Maybe more here */
};

typedef struct v3_ext_method X509V3_EXT_METHOD;

DECLARE_STACK_OF(X509V3_EXT_METHOD)

/* ext_flags values */
#define X509V3_EXT_DYNAMIC	0x1
#define X509V3_EXT_CTX_DEP	0x2
#define X509V3_EXT_MULTILINE	0x4

typedef BIT_STRING_BITNAME ENUMERATED_NAMES;

typedef struct BASIC_CONSTRAINTS_st {
int ca;
ASN1_INTEGER *pathlen;
} BASIC_CONSTRAINTS;


typedef struct PKEY_USAGE_PERIOD_st {
ASN1_GENERALIZEDTIME *notBefore;
ASN1_GENERALIZEDTIME *notAfter;
} PKEY_USAGE_PERIOD;

typedef struct otherName_st {
ASN1_OBJECT *type_id;
ASN1_TYPE *value;
} OTHERNAME;

typedef struct EDIPartyName_st {
	ASN1_STRING *nameAssigner;
	ASN1_STRING *partyName;
} EDIPARTYNAME;

typedef struct GENERAL_NAME_st {

#define GEN_OTHERNAME	0
#define GEN_EMAIL	1
#define GEN_DNS		2
#define GEN_X400	3
#define GEN_DIRNAME	4
#define GEN_EDIPARTY	5
#define GEN_URI		6
#define GEN_IPADD	7
#define GEN_RID		8

int type;
union {
	char *ptr;
	OTHERNAME *otherName; /* otherName */
	ASN1_IA5STRING *rfc822Name;
	ASN1_IA5STRING *dNSName;
	ASN1_TYPE *x400Address;
	X509_NAME *directoryName;
	EDIPARTYNAME *ediPartyName;
	ASN1_IA5STRING *uniformResourceIdentifier;
	ASN1_OCTET_STRING *iPAddress;
	ASN1_OBJECT *registeredID;

	/* Old names */
	ASN1_OCTET_STRING *ip; /* iPAddress */
	X509_NAME *dirn;		/* dirn */
	ASN1_IA5STRING *ia5;/* rfc822Name, dNSName, uniformResourceIdentifier */
	ASN1_OBJECT *rid; /* registeredID */
	ASN1_TYPE *other; /* x400Address */
} d;
} GENERAL_NAME;

typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;

typedef struct ACCESS_DESCRIPTION_st {
	ASN1_OBJECT *method;
	GENERAL_NAME *location;
} ACCESS_DESCRIPTION;

typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;

typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE;

DECLARE_STACK_OF(GENERAL_NAME)
DECLARE_ASN1_SET_OF(GENERAL_NAME)

DECLARE_STACK_OF(ACCESS_DESCRIPTION)
DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION)

typedef struct DIST_POINT_NAME_st {
int type;
union {
	GENERAL_NAMES *fullname;
	STACK_OF(X509_NAME_ENTRY) *relativename;
} name;
/* If relativename then this contains the full distribution point name */
X509_NAME *dpname;
} DIST_POINT_NAME;
/* All existing reasons */
#define CRLDP_ALL_REASONS	0x807f

#define CRL_REASON_NONE				-1
#define CRL_REASON_UNSPECIFIED			0
#define CRL_REASON_KEY_COMPROMISE		1
#define CRL_REASON_CA_COMPROMISE		2
#define CRL_REASON_AFFILIATION_CHANGED		3
#define CRL_REASON_SUPERSEDED			4
#define CRL_REASON_CESSATION_OF_OPERATION	5
#define CRL_REASON_CERTIFICATE_HOLD		6
#define CRL_REASON_REMOVE_FROM_CRL		8
#define CRL_REASON_PRIVILEGE_WITHDRAWN		9
#define CRL_REASON_AA_COMPROMISE		10

struct DIST_POINT_st {
DIST_POINT_NAME	*distpoint;
ASN1_BIT_STRING *reasons;
GENERAL_NAMES *CRLissuer;
int dp_reasons;
};

typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS;

DECLARE_STACK_OF(DIST_POINT)
DECLARE_ASN1_SET_OF(DIST_POINT)

struct AUTHORITY_KEYID_st {
ASN1_OCTET_STRING *keyid;
GENERAL_NAMES *issuer;
ASN1_INTEGER *serial;
};

/* Strong extranet structures */

typedef struct SXNET_ID_st {
	ASN1_INTEGER *zone;
	ASN1_OCTET_STRING *user;
} SXNETID;

DECLARE_STACK_OF(SXNETID)
DECLARE_ASN1_SET_OF(SXNETID)

typedef struct SXNET_st {
	ASN1_INTEGER *version;
	STACK_OF(SXNETID) *ids;
} SXNET;

typedef struct NOTICEREF_st {
	ASN1_STRING *organization;
	STACK_OF(ASN1_INTEGER) *noticenos;
} NOTICEREF;

typedef struct USERNOTICE_st {
	NOTICEREF *noticeref;
	ASN1_STRING *exptext;
} USERNOTICE;

typedef struct POLICYQUALINFO_st {
	ASN1_OBJECT *pqualid;
	union {
		ASN1_IA5STRING *cpsuri;
		USERNOTICE *usernotice;
		ASN1_TYPE *other;
	} d;
} POLICYQUALINFO;

DECLARE_STACK_OF(POLICYQUALINFO)
DECLARE_ASN1_SET_OF(POLICYQUALINFO)

typedef struct POLICYINFO_st {
	ASN1_OBJECT *policyid;
	STACK_OF(POLICYQUALINFO) *qualifiers;
} POLICYINFO;

typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES;

DECLARE_STACK_OF(POLICYINFO)
DECLARE_ASN1_SET_OF(POLICYINFO)

typedef struct POLICY_MAPPING_st {
	ASN1_OBJECT *issuerDomainPolicy;
	ASN1_OBJECT *subjectDomainPolicy;
} POLICY_MAPPING;

DECLARE_STACK_OF(POLICY_MAPPING)

typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS;

typedef struct GENERAL_SUBTREE_st {
	GENERAL_NAME *base;
	ASN1_INTEGER *minimum;
	ASN1_INTEGER *maximum;
} GENERAL_SUBTREE;

DECLARE_STACK_OF(GENERAL_SUBTREE)

struct NAME_CONSTRAINTS_st {
	STACK_OF(GENERAL_SUBTREE) *permittedSubtrees;
	STACK_OF(GENERAL_SUBTREE) *excludedSubtrees;
};

typedef struct POLICY_CONSTRAINTS_st {
	ASN1_INTEGER *requireExplicitPolicy;
	ASN1_INTEGER *inhibitPolicyMapping;
} POLICY_CONSTRAINTS;

/* Proxy certificate structures, see RFC 3820 */
typedef struct PROXY_POLICY_st
	{
	ASN1_OBJECT *policyLanguage;
	ASN1_OCTET_STRING *policy;
	} PROXY_POLICY;

typedef struct PROXY_CERT_INFO_EXTENSION_st
	{
	ASN1_INTEGER *pcPathLengthConstraint;
	PROXY_POLICY *proxyPolicy;
	} PROXY_CERT_INFO_EXTENSION;

DECLARE_ASN1_FUNCTIONS(PROXY_POLICY)
DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION)

struct ISSUING_DIST_POINT_st
	{
	DIST_POINT_NAME *distpoint;
	int onlyuser;
	int onlyCA;
	ASN1_BIT_STRING *onlysomereasons;
	int indirectCRL;
	int onlyattr;
	};

/* Values in idp_flags field */
/* IDP present */
#define	IDP_PRESENT	0x1
/* IDP values inconsistent */
#define IDP_INVALID	0x2
/* onlyuser true */
#define	IDP_ONLYUSER	0x4
/* onlyCA true */
#define	IDP_ONLYCA	0x8
/* onlyattr true */
#define IDP_ONLYATTR	0x10
/* indirectCRL true */
#define IDP_INDIRECT	0x20
/* onlysomereasons present */
#define IDP_REASONS	0x40

#define X509V3_conf_err(val) ERR_asprintf_error_data( \
			"section:%s,name:%s,value:%s", val->section, \
			val->name, val->value);

#define X509V3_set_ctx_test(ctx) \
			X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST)
#define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL;

#define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \
			0,0,0,0, \
			0,0, \
			(X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \
			(X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \
			NULL, NULL, \
			table}

#define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \
			0,0,0,0, \
			(X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \
			(X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \
			0,0,0,0, \
			NULL}

#define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}


/* X509_PURPOSE stuff */

#define EXFLAG_BCONS		0x1
#define EXFLAG_KUSAGE		0x2
#define EXFLAG_XKUSAGE		0x4
#define EXFLAG_NSCERT		0x8

#define EXFLAG_CA		0x10
/* Really self issued not necessarily self signed */
#define EXFLAG_SI		0x20
#define EXFLAG_SS		0x20
#define EXFLAG_V1		0x40
#define EXFLAG_INVALID		0x80
#define EXFLAG_SET		0x100
#define EXFLAG_CRITICAL		0x200
#define EXFLAG_PROXY		0x400

#define EXFLAG_INVALID_POLICY	0x800
#define EXFLAG_FRESHEST		0x1000

#define KU_DIGITAL_SIGNATURE	0x0080
#define KU_NON_REPUDIATION	0x0040
#define KU_KEY_ENCIPHERMENT	0x0020
#define KU_DATA_ENCIPHERMENT	0x0010
#define KU_KEY_AGREEMENT	0x0008
#define KU_KEY_CERT_SIGN	0x0004
#define KU_CRL_SIGN		0x0002
#define KU_ENCIPHER_ONLY	0x0001
#define KU_DECIPHER_ONLY	0x8000

#define NS_SSL_CLIENT		0x80
#define NS_SSL_SERVER		0x40
#define NS_SMIME		0x20
#define NS_OBJSIGN		0x10
#define NS_SSL_CA		0x04
#define NS_SMIME_CA		0x02
#define NS_OBJSIGN_CA		0x01
#define NS_ANY_CA		(NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA)

#define XKU_SSL_SERVER		0x1	
#define XKU_SSL_CLIENT		0x2
#define XKU_SMIME		0x4
#define XKU_CODE_SIGN		0x8
#define XKU_SGC			0x10
#define XKU_OCSP_SIGN		0x20
#define XKU_TIMESTAMP		0x40
#define XKU_DVCS		0x80

#define X509_PURPOSE_DYNAMIC	0x1
#define X509_PURPOSE_DYNAMIC_NAME	0x2

typedef struct x509_purpose_st {
	int purpose;
	int trust;		/* Default trust ID */
	int flags;
	int (*check_purpose)(const struct x509_purpose_st *,
				const X509 *, int);
	char *name;
	char *sname;
	void *usr_data;
} X509_PURPOSE;

#define X509_PURPOSE_SSL_CLIENT		1
#define X509_PURPOSE_SSL_SERVER		2
#define X509_PURPOSE_NS_SSL_SERVER	3
#define X509_PURPOSE_SMIME_SIGN		4
#define X509_PURPOSE_SMIME_ENCRYPT	5
#define X509_PURPOSE_CRL_SIGN		6
#define X509_PURPOSE_ANY		7
#define X509_PURPOSE_OCSP_HELPER	8
#define X509_PURPOSE_TIMESTAMP_SIGN	9

#define X509_PURPOSE_MIN		1
#define X509_PURPOSE_MAX		9

/* Flags for X509V3_EXT_print() */

#define X509V3_EXT_UNKNOWN_MASK		(0xfL << 16)
/* Return error for unknown extensions */
#define X509V3_EXT_DEFAULT		0
/* Print error for unknown extensions */
#define X509V3_EXT_ERROR_UNKNOWN	(1L << 16)
/* ASN1 parse unknown extensions */
#define X509V3_EXT_PARSE_UNKNOWN	(2L << 16)
/* BIO_dump unknown extensions */
#define X509V3_EXT_DUMP_UNKNOWN		(3L << 16)

/* Flags for X509V3_add1_i2d */

#define X509V3_ADD_OP_MASK		0xfL
#define X509V3_ADD_DEFAULT		0L
#define X509V3_ADD_APPEND		1L
#define X509V3_ADD_REPLACE		2L
#define X509V3_ADD_REPLACE_EXISTING	3L
#define X509V3_ADD_KEEP_EXISTING	4L
#define X509V3_ADD_DELETE		5L
#define X509V3_ADD_SILENT		0x10

DECLARE_STACK_OF(X509_PURPOSE)

DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)

DECLARE_ASN1_FUNCTIONS(SXNET)
DECLARE_ASN1_FUNCTIONS(SXNETID)

int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen); 
int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen); 
int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user, int userlen); 

ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone);
ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone);
ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone);

DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID)

DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)

DECLARE_ASN1_FUNCTIONS(GENERAL_NAME)
GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a);
int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b);



ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
				X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
				ASN1_BIT_STRING *bits,
				STACK_OF(CONF_VALUE) *extlist);

STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret);
int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen);

DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES)

STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,
		GENERAL_NAMES *gen, STACK_OF(CONF_VALUE) *extlist);
GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method,
				 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);

DECLARE_ASN1_FUNCTIONS(OTHERNAME)
DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME)
int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b);
void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value);
void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype);
int GENERAL_NAME_set0_othername(GENERAL_NAME *gen,
				ASN1_OBJECT *oid, ASN1_TYPE *value);
int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, 
				ASN1_OBJECT **poid, ASN1_TYPE **pvalue);

char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5);
ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str);

DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE)
int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a);

DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES)
DECLARE_ASN1_FUNCTIONS(POLICYINFO)
DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO)
DECLARE_ASN1_FUNCTIONS(USERNOTICE)
DECLARE_ASN1_FUNCTIONS(NOTICEREF)

DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS)
DECLARE_ASN1_FUNCTIONS(DIST_POINT)
DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME)
DECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT)

int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname);

int NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc);

DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)
DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)

DECLARE_ASN1_ITEM(POLICY_MAPPING)
DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING)
DECLARE_ASN1_ITEM(POLICY_MAPPINGS)

DECLARE_ASN1_ITEM(GENERAL_SUBTREE)
DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE)

DECLARE_ASN1_ITEM(NAME_CONSTRAINTS)
DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS)

DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS)
DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS)

GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,
			       const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
			       int gen_type, char *value, int is_nc);

#ifdef HEADER_CONF_H
GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
			       CONF_VALUE *cnf);
GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,
				  const X509V3_EXT_METHOD *method,
				  X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc);
void X509V3_conf_free(CONF_VALUE *val);

X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value);
X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, char *value);
int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, STACK_OF(X509_EXTENSION) **sk);
int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert);
int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req);
int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl);

X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
				    int ext_nid, char *value);
X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
				char *name, char *value);
int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
			char *section, X509 *cert);
int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
			    char *section, X509_REQ *req);
int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,
			    char *section, X509_CRL *crl);

int X509V3_add_value_bool_nf(char *name, int asn1_bool,
			     STACK_OF(CONF_VALUE) **extlist);
int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool);
int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint);
void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf);
void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash);
#endif

char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section);
STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section);
void X509V3_string_free(X509V3_CTX *ctx, char *str);
void X509V3_section_free( X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section);
void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject,
				 X509_REQ *req, X509_CRL *crl, int flags);

int X509V3_add_value(const char *name, const char *value,
						STACK_OF(CONF_VALUE) **extlist);
int X509V3_add_value_uchar(const char *name, const unsigned char *value,
						STACK_OF(CONF_VALUE) **extlist);
int X509V3_add_value_bool(const char *name, int asn1_bool,
						STACK_OF(CONF_VALUE) **extlist);
int X509V3_add_value_int(const char *name, ASN1_INTEGER *aint,
						STACK_OF(CONF_VALUE) **extlist);
char * i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint);
ASN1_INTEGER * s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, char *value);
char * i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint);
char * i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint);
int X509V3_EXT_add(X509V3_EXT_METHOD *ext);
int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist);
int X509V3_EXT_add_alias(int nid_to, int nid_from);
void X509V3_EXT_cleanup(void);

const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext);
const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);
int X509V3_add_standard_extensions(void);
STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line);
void *X509V3_EXT_d2i(X509_EXTENSION *ext);
void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx);


X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);
int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, int crit, unsigned long flags);

char *hex_to_string(const unsigned char *buffer, long len);
unsigned char *string_to_hex(const char *str, long *len);
int name_cmp(const char *name, const char *cmp);

void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,
								 int ml);
int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent);
int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);

int X509V3_extensions_print(BIO *out, char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent);

int X509_check_ca(X509 *x);
int X509_check_purpose(X509 *x, int id, int ca);
int X509_supported_extension(X509_EXTENSION *ex);
int X509_PURPOSE_set(int *p, int purpose);
int X509_check_issued(X509 *issuer, X509 *subject);
int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid);
int X509_PURPOSE_get_count(void);
X509_PURPOSE * X509_PURPOSE_get0(int idx);
int X509_PURPOSE_get_by_sname(char *sname);
int X509_PURPOSE_get_by_id(int id);
int X509_PURPOSE_add(int id, int trust, int flags,
			int (*ck)(const X509_PURPOSE *, const X509 *, int),
				char *name, char *sname, void *arg);
char *X509_PURPOSE_get0_name(X509_PURPOSE *xp);
char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp);
int X509_PURPOSE_get_trust(X509_PURPOSE *xp);
void X509_PURPOSE_cleanup(void);
int X509_PURPOSE_get_id(X509_PURPOSE *);

STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x);
STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x);
void X509_email_free(STACK_OF(OPENSSL_STRING) *sk);
STACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x);

ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc);
ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc);
int a2i_ipadd(unsigned char *ipout, const char *ipasc);
int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE)*dn_sk,
						unsigned long chtype);

void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent);
DECLARE_STACK_OF(X509_POLICY_NODE)

#ifndef OPENSSL_NO_RFC3779

typedef struct ASRange_st {
  ASN1_INTEGER *min, *max;
} ASRange;

#define	ASIdOrRange_id		0
#define	ASIdOrRange_range	1

typedef struct ASIdOrRange_st {
  int type;
  union {
    ASN1_INTEGER *id;
    ASRange      *range;
  } u;
} ASIdOrRange;

typedef STACK_OF(ASIdOrRange) ASIdOrRanges;
DECLARE_STACK_OF(ASIdOrRange)

#define	ASIdentifierChoice_inherit		0
#define	ASIdentifierChoice_asIdsOrRanges	1

typedef struct ASIdentifierChoice_st {
  int type;
  union {
    ASN1_NULL    *inherit;
    ASIdOrRanges *asIdsOrRanges;
  } u;
} ASIdentifierChoice;

typedef struct ASIdentifiers_st {
  ASIdentifierChoice *asnum, *rdi;
} ASIdentifiers;

DECLARE_ASN1_FUNCTIONS(ASRange)
DECLARE_ASN1_FUNCTIONS(ASIdOrRange)
DECLARE_ASN1_FUNCTIONS(ASIdentifierChoice)
DECLARE_ASN1_FUNCTIONS(ASIdentifiers)


typedef struct IPAddressRange_st {
  ASN1_BIT_STRING	*min, *max;
} IPAddressRange;

#define	IPAddressOrRange_addressPrefix	0
#define	IPAddressOrRange_addressRange	1

typedef struct IPAddressOrRange_st {
  int type;
  union {
    ASN1_BIT_STRING	*addressPrefix;
    IPAddressRange	*addressRange;
  } u;
} IPAddressOrRange;

typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges;
DECLARE_STACK_OF(IPAddressOrRange)

#define	IPAddressChoice_inherit			0
#define	IPAddressChoice_addressesOrRanges	1

typedef struct IPAddressChoice_st {
  int type;
  union {
    ASN1_NULL		*inherit;
    IPAddressOrRanges	*addressesOrRanges;
  } u;
} IPAddressChoice;

typedef struct IPAddressFamily_st {
  ASN1_OCTET_STRING	*addressFamily;
  IPAddressChoice	*ipAddressChoice;
} IPAddressFamily;

typedef STACK_OF(IPAddressFamily) IPAddrBlocks;
DECLARE_STACK_OF(IPAddressFamily)

DECLARE_ASN1_FUNCTIONS(IPAddressRange)
DECLARE_ASN1_FUNCTIONS(IPAddressOrRange)
DECLARE_ASN1_FUNCTIONS(IPAddressChoice)
DECLARE_ASN1_FUNCTIONS(IPAddressFamily)

/*
 * API tag for elements of the ASIdentifer SEQUENCE.
 */
#define	V3_ASID_ASNUM	0
#define	V3_ASID_RDI	1

/*
 * AFI values, assigned by IANA.  It'd be nice to make the AFI
 * handling code totally generic, but there are too many little things
 * that would need to be defined for other address families for it to
 * be worth the trouble.
 */
#define	IANA_AFI_IPV4	1
#define	IANA_AFI_IPV6	2

/*
 * Utilities to construct and extract values from RFC3779 extensions,
 * since some of the encodings (particularly for IP address prefixes
 * and ranges) are a bit tedious to work with directly.
 */
int v3_asid_add_inherit(ASIdentifiers *asid, int which);
int v3_asid_add_id_or_range(ASIdentifiers *asid, int which,
			    ASN1_INTEGER *min, ASN1_INTEGER *max);
int v3_addr_add_inherit(IPAddrBlocks *addr,
			const unsigned afi, const unsigned *safi);
int v3_addr_add_prefix(IPAddrBlocks *addr,
		       const unsigned afi, const unsigned *safi,
		       unsigned char *a, const int prefixlen);
int v3_addr_add_range(IPAddrBlocks *addr,
		      const unsigned afi, const unsigned *safi,
		      unsigned char *min, unsigned char *max);
unsigned v3_addr_get_afi(const IPAddressFamily *f);
int v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi,
		      unsigned char *min, unsigned char *max,
		      const int length);

/*
 * Canonical forms.
 */
int v3_asid_is_canonical(ASIdentifiers *asid);
int v3_addr_is_canonical(IPAddrBlocks *addr);
int v3_asid_canonize(ASIdentifiers *asid);
int v3_addr_canonize(IPAddrBlocks *addr);

/*
 * Tests for inheritance and containment.
 */
int v3_asid_inherits(ASIdentifiers *asid);
int v3_addr_inherits(IPAddrBlocks *addr);
int v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b);
int v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b);

/*
 * Check whether RFC 3779 extensions nest properly in chains.
 */
int v3_asid_validate_path(X509_STORE_CTX *);
int v3_addr_validate_path(X509_STORE_CTX *);
int v3_asid_validate_resource_set(STACK_OF(X509) *chain,
				  ASIdentifiers *ext,
				  int allow_inheritance);
int v3_addr_validate_resource_set(STACK_OF(X509) *chain,
				  IPAddrBlocks *ext,
				  int allow_inheritance);

#endif /* OPENSSL_NO_RFC3779 */

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_X509V3_strings(void);

/* Error codes for the X509V3 functions. */

/* Function codes. */
#define X509V3_F_A2I_GENERAL_NAME			 164
#define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE		 161
#define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL	 162
#define X509V3_F_COPY_EMAIL				 122
#define X509V3_F_COPY_ISSUER				 123
#define X509V3_F_DO_DIRNAME				 144
#define X509V3_F_DO_EXT_CONF				 124
#define X509V3_F_DO_EXT_I2D				 135
#define X509V3_F_DO_EXT_NCONF				 151
#define X509V3_F_DO_I2V_NAME_CONSTRAINTS		 148
#define X509V3_F_GNAMES_FROM_SECTNAME			 156
#define X509V3_F_HEX_TO_STRING				 111
#define X509V3_F_I2S_ASN1_ENUMERATED			 121
#define X509V3_F_I2S_ASN1_IA5STRING			 149
#define X509V3_F_I2S_ASN1_INTEGER			 120
#define X509V3_F_I2V_AUTHORITY_INFO_ACCESS		 138
#define X509V3_F_NOTICE_SECTION				 132
#define X509V3_F_NREF_NOS				 133
#define X509V3_F_POLICY_SECTION				 131
#define X509V3_F_PROCESS_PCI_VALUE			 150
#define X509V3_F_R2I_CERTPOL				 130
#define X509V3_F_R2I_PCI				 155
#define X509V3_F_S2I_ASN1_IA5STRING			 100
#define X509V3_F_S2I_ASN1_INTEGER			 108
#define X509V3_F_S2I_ASN1_OCTET_STRING			 112
#define X509V3_F_S2I_ASN1_SKEY_ID			 114
#define X509V3_F_S2I_SKEY_ID				 115
#define X509V3_F_SET_DIST_POINT_NAME			 158
#define X509V3_F_STRING_TO_HEX				 113
#define X509V3_F_SXNET_ADD_ID_ASC			 125
#define X509V3_F_SXNET_ADD_ID_INTEGER			 126
#define X509V3_F_SXNET_ADD_ID_ULONG			 127
#define X509V3_F_SXNET_GET_ID_ASC			 128
#define X509V3_F_SXNET_GET_ID_ULONG			 129
#define X509V3_F_V2I_ASIDENTIFIERS			 163
#define X509V3_F_V2I_ASN1_BIT_STRING			 101
#define X509V3_F_V2I_AUTHORITY_INFO_ACCESS		 139
#define X509V3_F_V2I_AUTHORITY_KEYID			 119
#define X509V3_F_V2I_BASIC_CONSTRAINTS			 102
#define X509V3_F_V2I_CRLD				 134
#define X509V3_F_V2I_EXTENDED_KEY_USAGE			 103
#define X509V3_F_V2I_GENERAL_NAMES			 118
#define X509V3_F_V2I_GENERAL_NAME_EX			 117
#define X509V3_F_V2I_IDP				 157
#define X509V3_F_V2I_IPADDRBLOCKS			 159
#define X509V3_F_V2I_ISSUER_ALT				 153
#define X509V3_F_V2I_NAME_CONSTRAINTS			 147
#define X509V3_F_V2I_POLICY_CONSTRAINTS			 146
#define X509V3_F_V2I_POLICY_MAPPINGS			 145
#define X509V3_F_V2I_SUBJECT_ALT			 154
#define X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL		 160
#define X509V3_F_V3_GENERIC_EXTENSION			 116
#define X509V3_F_X509V3_ADD1_I2D			 140
#define X509V3_F_X509V3_ADD_VALUE			 105
#define X509V3_F_X509V3_EXT_ADD				 104
#define X509V3_F_X509V3_EXT_ADD_ALIAS			 106
#define X509V3_F_X509V3_EXT_CONF			 107
#define X509V3_F_X509V3_EXT_I2D				 136
#define X509V3_F_X509V3_EXT_NCONF			 152
#define X509V3_F_X509V3_GET_SECTION			 142
#define X509V3_F_X509V3_GET_STRING			 143
#define X509V3_F_X509V3_GET_VALUE_BOOL			 110
#define X509V3_F_X509V3_PARSE_LIST			 109
#define X509V3_F_X509_PURPOSE_ADD			 137
#define X509V3_F_X509_PURPOSE_SET			 141

/* Reason codes. */
#define X509V3_R_BAD_IP_ADDRESS				 118
#define X509V3_R_BAD_OBJECT				 119
#define X509V3_R_BN_DEC2BN_ERROR			 100
#define X509V3_R_BN_TO_ASN1_INTEGER_ERROR		 101
#define X509V3_R_DIRNAME_ERROR				 149
#define X509V3_R_DISTPOINT_ALREADY_SET			 160
#define X509V3_R_DUPLICATE_ZONE_ID			 133
#define X509V3_R_ERROR_CONVERTING_ZONE			 131
#define X509V3_R_ERROR_CREATING_EXTENSION		 144
#define X509V3_R_ERROR_IN_EXTENSION			 128
#define X509V3_R_EXPECTED_A_SECTION_NAME		 137
#define X509V3_R_EXTENSION_EXISTS			 145
#define X509V3_R_EXTENSION_NAME_ERROR			 115
#define X509V3_R_EXTENSION_NOT_FOUND			 102
#define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED	 103
#define X509V3_R_EXTENSION_VALUE_ERROR			 116
#define X509V3_R_ILLEGAL_EMPTY_EXTENSION		 151
#define X509V3_R_ILLEGAL_HEX_DIGIT			 113
#define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG		 152
#define X509V3_R_INVALID_MULTIPLE_RDNS			 161
#define X509V3_R_INVALID_ASNUMBER			 162
#define X509V3_R_INVALID_ASRANGE			 163
#define X509V3_R_INVALID_BOOLEAN_STRING			 104
#define X509V3_R_INVALID_EXTENSION_STRING		 105
#define X509V3_R_INVALID_INHERITANCE			 165
#define X509V3_R_INVALID_IPADDRESS			 166
#define X509V3_R_INVALID_NAME				 106
#define X509V3_R_INVALID_NULL_ARGUMENT			 107
#define X509V3_R_INVALID_NULL_NAME			 108
#define X509V3_R_INVALID_NULL_VALUE			 109
#define X509V3_R_INVALID_NUMBER				 140
#define X509V3_R_INVALID_NUMBERS			 141
#define X509V3_R_INVALID_OBJECT_IDENTIFIER		 110
#define X509V3_R_INVALID_OPTION				 138
#define X509V3_R_INVALID_POLICY_IDENTIFIER		 134
#define X509V3_R_INVALID_PROXY_POLICY_SETTING		 153
#define X509V3_R_INVALID_PURPOSE			 146
#define X509V3_R_INVALID_SAFI				 164
#define X509V3_R_INVALID_SECTION			 135
#define X509V3_R_INVALID_SYNTAX				 143
#define X509V3_R_ISSUER_DECODE_ERROR			 126
#define X509V3_R_MISSING_VALUE				 124
#define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS		 142
#define X509V3_R_NO_CONFIG_DATABASE			 136
#define X509V3_R_NO_ISSUER_CERTIFICATE			 121
#define X509V3_R_NO_ISSUER_DETAILS			 127
#define X509V3_R_NO_POLICY_IDENTIFIER			 139
#define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED	 154
#define X509V3_R_NO_PUBLIC_KEY				 114
#define X509V3_R_NO_SUBJECT_DETAILS			 125
#define X509V3_R_ODD_NUMBER_OF_DIGITS			 112
#define X509V3_R_OPERATION_NOT_DEFINED			 148
#define X509V3_R_OTHERNAME_ERROR			 147
#define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED	 155
#define X509V3_R_POLICY_PATH_LENGTH			 156
#define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED	 157
#define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED	 158
#define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159
#define X509V3_R_SECTION_NOT_FOUND			 150
#define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS		 122
#define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID		 123
#define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT		 111
#define X509V3_R_UNKNOWN_EXTENSION			 129
#define X509V3_R_UNKNOWN_EXTENSION_NAME			 130
#define X509V3_R_UNKNOWN_OPTION				 120
#define X509V3_R_UNSUPPORTED_OPTION			 117
#define X509V3_R_UNSUPPORTED_TYPE			 167
#define X509V3_R_USER_TOO_LONG				 132

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/ossl_typ.h0000644000175000017500000001611512360020705022072 0ustar  /* $OpenBSD$ */
/* ====================================================================
 * Copyright (c) 1998-2001 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#ifndef HEADER_OPENSSL_TYPES_H
#define HEADER_OPENSSL_TYPES_H

#include 

#ifdef NO_ASN1_TYPEDEFS
#define ASN1_INTEGER		ASN1_STRING
#define ASN1_ENUMERATED		ASN1_STRING
#define ASN1_BIT_STRING		ASN1_STRING
#define ASN1_OCTET_STRING	ASN1_STRING
#define ASN1_PRINTABLESTRING	ASN1_STRING
#define ASN1_T61STRING		ASN1_STRING
#define ASN1_IA5STRING		ASN1_STRING
#define ASN1_UTCTIME		ASN1_STRING
#define ASN1_GENERALIZEDTIME	ASN1_STRING
#define ASN1_TIME		ASN1_STRING
#define ASN1_GENERALSTRING	ASN1_STRING
#define ASN1_UNIVERSALSTRING	ASN1_STRING
#define ASN1_BMPSTRING		ASN1_STRING
#define ASN1_VISIBLESTRING	ASN1_STRING
#define ASN1_UTF8STRING		ASN1_STRING
#define ASN1_BOOLEAN		int
#define ASN1_NULL		int
#else
typedef struct asn1_string_st ASN1_INTEGER;
typedef struct asn1_string_st ASN1_ENUMERATED;
typedef struct asn1_string_st ASN1_BIT_STRING;
typedef struct asn1_string_st ASN1_OCTET_STRING;
typedef struct asn1_string_st ASN1_PRINTABLESTRING;
typedef struct asn1_string_st ASN1_T61STRING;
typedef struct asn1_string_st ASN1_IA5STRING;
typedef struct asn1_string_st ASN1_GENERALSTRING;
typedef struct asn1_string_st ASN1_UNIVERSALSTRING;
typedef struct asn1_string_st ASN1_BMPSTRING;
typedef struct asn1_string_st ASN1_UTCTIME;
typedef struct asn1_string_st ASN1_TIME;
typedef struct asn1_string_st ASN1_GENERALIZEDTIME;
typedef struct asn1_string_st ASN1_VISIBLESTRING;
typedef struct asn1_string_st ASN1_UTF8STRING;
typedef struct asn1_string_st ASN1_STRING;
typedef int ASN1_BOOLEAN;
typedef int ASN1_NULL;
#endif

typedef struct ASN1_ITEM_st ASN1_ITEM;
typedef struct asn1_pctx_st ASN1_PCTX;

#ifdef BIGNUM
#undef BIGNUM
#endif
typedef struct bignum_st BIGNUM;
typedef struct bignum_ctx BN_CTX;
typedef struct bn_blinding_st BN_BLINDING;
typedef struct bn_mont_ctx_st BN_MONT_CTX;
typedef struct bn_recp_ctx_st BN_RECP_CTX;
typedef struct bn_gencb_st BN_GENCB;

typedef struct buf_mem_st BUF_MEM;

typedef struct evp_cipher_st EVP_CIPHER;
typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
typedef struct env_md_st EVP_MD;
typedef struct env_md_ctx_st EVP_MD_CTX;
typedef struct evp_pkey_st EVP_PKEY;

typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;

typedef struct evp_pkey_method_st EVP_PKEY_METHOD;
typedef struct evp_pkey_ctx_st EVP_PKEY_CTX;

typedef struct dh_st DH;
typedef struct dh_method DH_METHOD;

typedef struct dsa_st DSA;
typedef struct dsa_method DSA_METHOD;

typedef struct rsa_st RSA;
typedef struct rsa_meth_st RSA_METHOD;

typedef struct rand_meth_st RAND_METHOD;

typedef struct ecdh_method ECDH_METHOD;
typedef struct ecdsa_method ECDSA_METHOD;

typedef struct x509_st X509;
typedef struct X509_algor_st X509_ALGOR;
typedef struct X509_crl_st X509_CRL;
typedef struct x509_crl_method_st X509_CRL_METHOD;
typedef struct x509_revoked_st X509_REVOKED;
typedef struct X509_name_st X509_NAME;
typedef struct X509_pubkey_st X509_PUBKEY;
typedef struct x509_store_st X509_STORE;
typedef struct x509_store_ctx_st X509_STORE_CTX;

typedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO;

typedef struct v3_ext_ctx X509V3_CTX;
typedef struct conf_st CONF;

typedef struct store_st STORE;
typedef struct store_method_st STORE_METHOD;

typedef struct ui_st UI;
typedef struct ui_method_st UI_METHOD;

typedef struct st_ERR_FNS ERR_FNS;

typedef struct engine_st ENGINE;
typedef struct ssl_st SSL;
typedef struct ssl_ctx_st SSL_CTX;

typedef struct X509_POLICY_NODE_st X509_POLICY_NODE;
typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;
typedef struct X509_POLICY_TREE_st X509_POLICY_TREE;
typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE;

typedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID;
typedef struct DIST_POINT_st DIST_POINT;
typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT;
typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS;

/* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */
#define DECLARE_PKCS12_STACK_OF(type) /* Nothing */
#define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */

typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
/* Callback types for crypto.h */
typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
    int idx, long argl, void *argp);
typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
    int idx, long argl, void *argp);
typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from,
    void *from_d, int idx, long argl, void *argp);

typedef struct ocsp_req_ctx_st OCSP_REQ_CTX;
typedef struct ocsp_response_st OCSP_RESPONSE;
typedef struct ocsp_responder_id_st OCSP_RESPID;

#endif /* def HEADER_OPENSSL_TYPES_H */
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/ssl.h0000644000175000017500000027171712360020705021032 0ustar  /* $OpenBSD: ssl.h,v 1.60 2014/07/10 11:58:08 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */
/* ====================================================================
 * Copyright (c) 1998-2007 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */
/* ====================================================================
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 * ECC cipher suite support in OpenSSL originally developed by 
 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
 */
/* ====================================================================
 * Copyright 2005 Nokia. All rights reserved.
 *
 * The portions of the attached software ("Contribution") is developed by
 * Nokia Corporation and is licensed pursuant to the OpenSSL open source
 * license.
 *
 * The Contribution, originally written by Mika Kousa and Pasi Eronen of
 * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
 * support (see RFC 4279) to OpenSSL.
 *
 * No patent licenses or other rights except those expressly stated in
 * the OpenSSL open source license shall be deemed granted or received
 * expressly, by implication, estoppel, or otherwise.
 *
 * No assurances are provided by Nokia that the Contribution does not
 * infringe the patent or other intellectual property rights of any third
 * party or that the license provides you with all the necessary rights
 * to make use of the Contribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
 * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
 * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
 * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
 * OTHERWISE.
 */

#ifndef HEADER_SSL_H 
#define HEADER_SSL_H 

#include 

#ifndef OPENSSL_NO_BIO
#include 
#endif
#ifndef OPENSSL_NO_DEPRECATED
#ifndef OPENSSL_NO_X509
#include 
#endif
#include 
#include 
#include 
#endif
#include 
#include 

#include 

#ifdef  __cplusplus
extern "C" {
#endif

/* SSLeay version number for ASN.1 encoding of the session information */
/* Version 0 - initial version
 * Version 1 - added the optional peer certificate
 */
#define SSL_SESSION_ASN1_VERSION 0x0001

/* text strings for the ciphers */
#define SSL_TXT_NULL_WITH_MD5		SSL2_TXT_NULL_WITH_MD5			
#define SSL_TXT_RC4_128_WITH_MD5	SSL2_TXT_RC4_128_WITH_MD5		
#define SSL_TXT_RC4_128_EXPORT40_WITH_MD5 SSL2_TXT_RC4_128_EXPORT40_WITH_MD5	
#define SSL_TXT_RC2_128_CBC_WITH_MD5	SSL2_TXT_RC2_128_CBC_WITH_MD5		
#define SSL_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5	
#define SSL_TXT_IDEA_128_CBC_WITH_MD5	SSL2_TXT_IDEA_128_CBC_WITH_MD5		
#define SSL_TXT_DES_64_CBC_WITH_MD5	SSL2_TXT_DES_64_CBC_WITH_MD5		
#define SSL_TXT_DES_64_CBC_WITH_SHA	SSL2_TXT_DES_64_CBC_WITH_SHA		
#define SSL_TXT_DES_192_EDE3_CBC_WITH_MD5 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5	
#define SSL_TXT_DES_192_EDE3_CBC_WITH_SHA SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA	

/*    VRS Additional Kerberos5 entries
 */
#define SSL_TXT_KRB5_DES_64_CBC_SHA   SSL3_TXT_KRB5_DES_64_CBC_SHA
#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA
#define SSL_TXT_KRB5_RC4_128_SHA      SSL3_TXT_KRB5_RC4_128_SHA
#define SSL_TXT_KRB5_IDEA_128_CBC_SHA SSL3_TXT_KRB5_IDEA_128_CBC_SHA
#define SSL_TXT_KRB5_DES_64_CBC_MD5   SSL3_TXT_KRB5_DES_64_CBC_MD5       
#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5       
#define SSL_TXT_KRB5_RC4_128_MD5      SSL3_TXT_KRB5_RC4_128_MD5
#define SSL_TXT_KRB5_IDEA_128_CBC_MD5 SSL3_TXT_KRB5_IDEA_128_CBC_MD5 

#define SSL_TXT_KRB5_DES_40_CBC_SHA   SSL3_TXT_KRB5_DES_40_CBC_SHA 
#define SSL_TXT_KRB5_RC2_40_CBC_SHA   SSL3_TXT_KRB5_RC2_40_CBC_SHA 
#define SSL_TXT_KRB5_RC4_40_SHA	      SSL3_TXT_KRB5_RC4_40_SHA
#define SSL_TXT_KRB5_DES_40_CBC_MD5   SSL3_TXT_KRB5_DES_40_CBC_MD5 
#define SSL_TXT_KRB5_RC2_40_CBC_MD5   SSL3_TXT_KRB5_RC2_40_CBC_MD5 
#define SSL_TXT_KRB5_RC4_40_MD5	      SSL3_TXT_KRB5_RC4_40_MD5

#define SSL_TXT_KRB5_DES_40_CBC_SHA   SSL3_TXT_KRB5_DES_40_CBC_SHA
#define SSL_TXT_KRB5_DES_40_CBC_MD5   SSL3_TXT_KRB5_DES_40_CBC_MD5
#define SSL_TXT_KRB5_DES_64_CBC_SHA   SSL3_TXT_KRB5_DES_64_CBC_SHA
#define SSL_TXT_KRB5_DES_64_CBC_MD5   SSL3_TXT_KRB5_DES_64_CBC_MD5
#define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA
#define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5
#define SSL_MAX_KRB5_PRINCIPAL_LENGTH  256

#define SSL_MAX_SSL_SESSION_ID_LENGTH		32
#define SSL_MAX_SID_CTX_LENGTH			32

#define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES	(512/8)
#define SSL_MAX_KEY_ARG_LENGTH			8
#define SSL_MAX_MASTER_KEY_LENGTH		48


/* These are used to specify which ciphers to use and not to use */

#define SSL_TXT_LOW		"LOW"
#define SSL_TXT_MEDIUM		"MEDIUM"
#define SSL_TXT_HIGH		"HIGH"

#define SSL_TXT_kFZA		"kFZA" /* unused! */
#define	SSL_TXT_aFZA		"aFZA" /* unused! */
#define SSL_TXT_eFZA		"eFZA" /* unused! */
#define SSL_TXT_FZA		"FZA"  /* unused! */

#define	SSL_TXT_aNULL		"aNULL"
#define	SSL_TXT_eNULL		"eNULL"
#define	SSL_TXT_NULL		"NULL"

#define SSL_TXT_kRSA		"kRSA"
#define SSL_TXT_kDHr		"kDHr" /* no such ciphersuites supported! */
#define SSL_TXT_kDHd		"kDHd" /* no such ciphersuites supported! */
#define SSL_TXT_kDH 		"kDH"  /* no such ciphersuites supported! */
#define SSL_TXT_kEDH		"kEDH"
#define SSL_TXT_kKRB5     	"kKRB5"
#define SSL_TXT_kECDHr		"kECDHr"
#define SSL_TXT_kECDHe		"kECDHe"
#define SSL_TXT_kECDH		"kECDH"
#define SSL_TXT_kEECDH		"kEECDH"
#define SSL_TXT_kPSK            "kPSK"
#define SSL_TXT_kGOST		"kGOST"
#define SSL_TXT_kSRP		"kSRP"

#define	SSL_TXT_aRSA		"aRSA"
#define	SSL_TXT_aDSS		"aDSS"
#define	SSL_TXT_aDH		"aDH" /* no such ciphersuites supported! */
#define	SSL_TXT_aECDH		"aECDH"
#define SSL_TXT_aKRB5     	"aKRB5"
#define SSL_TXT_aECDSA		"aECDSA"
#define SSL_TXT_aPSK            "aPSK"
#define SSL_TXT_aGOST94		"aGOST94"
#define SSL_TXT_aGOST01		"aGOST01"
#define SSL_TXT_aGOST		"aGOST"

#define	SSL_TXT_DSS		"DSS"
#define SSL_TXT_DH		"DH"
#define SSL_TXT_EDH		"EDH" /* same as "kEDH:-ADH" */
#define SSL_TXT_ADH		"ADH"
#define SSL_TXT_RSA		"RSA"
#define SSL_TXT_ECDH		"ECDH"
#define SSL_TXT_EECDH		"EECDH" /* same as "kEECDH:-AECDH" */
#define SSL_TXT_AECDH		"AECDH"
#define SSL_TXT_ECDSA		"ECDSA"
#define SSL_TXT_KRB5      	"KRB5"
#define SSL_TXT_PSK             "PSK"
#define SSL_TXT_SRP		"SRP"

#define SSL_TXT_DES		"DES"
#define SSL_TXT_3DES		"3DES"
#define SSL_TXT_RC4		"RC4"
#define SSL_TXT_RC2		"RC2"
#define SSL_TXT_IDEA		"IDEA"
#define SSL_TXT_SEED		"SEED"
#define SSL_TXT_AES128		"AES128"
#define SSL_TXT_AES256		"AES256"
#define SSL_TXT_AES		"AES"
#define SSL_TXT_AES_GCM		"AESGCM"
#define SSL_TXT_CAMELLIA128	"CAMELLIA128"
#define SSL_TXT_CAMELLIA256	"CAMELLIA256"
#define SSL_TXT_CAMELLIA	"CAMELLIA"
#define SSL_TXT_CHACHA20	"CHACHA20"

#define SSL_TXT_MD5		"MD5"
#define SSL_TXT_SHA1		"SHA1"
#define SSL_TXT_SHA		"SHA" /* same as "SHA1" */
#define SSL_TXT_GOST94		"GOST94" 
#define SSL_TXT_GOST89MAC		"GOST89MAC" 
#define SSL_TXT_SHA256		"SHA256"
#define SSL_TXT_SHA384		"SHA384"

#define SSL_TXT_SSLV2		"SSLv2"
#define SSL_TXT_SSLV3		"SSLv3"
#define SSL_TXT_TLSV1		"TLSv1"
#define SSL_TXT_TLSV1_1		"TLSv1.1"
#define SSL_TXT_TLSV1_2		"TLSv1.2"

#define SSL_TXT_EXP		"EXP"
#define SSL_TXT_EXPORT		"EXPORT"

#define SSL_TXT_ALL		"ALL"

/*
 * COMPLEMENTOF* definitions. These identifiers are used to (de-select)
 * ciphers normally not being used.
 * Example: "RC4" will activate all ciphers using RC4 including ciphers
 * without authentication, which would normally disabled by DEFAULT (due
 * the "!ADH" being part of default). Therefore "RC4:!COMPLEMENTOFDEFAULT"
 * will make sure that it is also disabled in the specific selection.
 * COMPLEMENTOF* identifiers are portable between version, as adjustments
 * to the default cipher setup will also be included here.
 *
 * COMPLEMENTOFDEFAULT does not experience the same special treatment that
 * DEFAULT gets, as only selection is being done and no sorting as needed
 * for DEFAULT.
 */
#define SSL_TXT_CMPALL		"COMPLEMENTOFALL"
#define SSL_TXT_CMPDEF		"COMPLEMENTOFDEFAULT"

/* The following cipher list is used by default.
 * It also is substituted when an application-defined cipher list string
 * starts with 'DEFAULT'. */
#define SSL_DEFAULT_CIPHER_LIST	"ALL:!aNULL:!eNULL:!SSLv2"
/* As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always
 * starts with a reasonable order, and all we have to do for DEFAULT is
 * throwing out anonymous and unencrypted ciphersuites!
 * (The latter are not actually enabled by ALL, but "ALL:RSA" would enable
 * some of them.)
 */

/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */
#define SSL_SENT_SHUTDOWN	1
#define SSL_RECEIVED_SHUTDOWN	2


#define SSL_FILETYPE_ASN1	X509_FILETYPE_ASN1
#define SSL_FILETYPE_PEM	X509_FILETYPE_PEM

/* This is needed to stop compilers complaining about the
 * 'struct ssl_st *' function parameters used to prototype callbacks
 * in SSL_CTX. */
typedef struct ssl_st *ssl_crock_st;
typedef struct tls_session_ticket_ext_st TLS_SESSION_TICKET_EXT;
typedef struct ssl_method_st SSL_METHOD;
typedef struct ssl_cipher_st SSL_CIPHER;
typedef struct ssl_session_st SSL_SESSION;

DECLARE_STACK_OF(SSL_CIPHER)

/* SRTP protection profiles for use with the use_srtp extension (RFC 5764)*/
typedef struct srtp_protection_profile_st {
	const char *name;
	unsigned long id;
} SRTP_PROTECTION_PROFILE;

DECLARE_STACK_OF(SRTP_PROTECTION_PROFILE)

typedef int (*tls_session_ticket_ext_cb_fn)(SSL *s, const unsigned char *data,
    int len, void *arg);
typedef int (*tls_session_secret_cb_fn)(SSL *s, void *secret, int *secret_len,
    STACK_OF(SSL_CIPHER) *peer_ciphers, SSL_CIPHER **cipher, void *arg);

#ifndef OPENSSL_NO_SSL_INTERN

/* used to hold info on the particular ciphers used */
struct ssl_cipher_st {
	int valid;
	const char *name;		/* text name */
	unsigned long id;		/* id, 4 bytes, first is version */

	/* changed in 0.9.9: these four used to be portions of a single value 'algorithms' */
	unsigned long algorithm_mkey;	/* key exchange algorithm */
	unsigned long algorithm_auth;	/* server authentication */
	unsigned long algorithm_enc;	/* symmetric encryption */
	unsigned long algorithm_mac;	/* symmetric authentication */
	unsigned long algorithm_ssl;	/* (major) protocol version */

	unsigned long algo_strength;	/* strength and export flags */
	unsigned long algorithm2;	/* Extra flags */
	int strength_bits;		/* Number of bits really used */
	int alg_bits;			/* Number of bits for algorithm */
};


/* Used to hold functions for SSLv3/TLSv1 functions */
struct ssl_method_st {
	int version;
	int (*ssl_new)(SSL *s);
	void (*ssl_clear)(SSL *s);
	void (*ssl_free)(SSL *s);
	int (*ssl_accept)(SSL *s);
	int (*ssl_connect)(SSL *s);
	int (*ssl_read)(SSL *s, void *buf, int len);
	int (*ssl_peek)(SSL *s, void *buf, int len);
	int (*ssl_write)(SSL *s, const void *buf, int len);
	int (*ssl_shutdown)(SSL *s);
	int (*ssl_renegotiate)(SSL *s);
	int (*ssl_renegotiate_check)(SSL *s);
	long (*ssl_get_message)(SSL *s, int st1, int stn, int mt,
	    long max, int *ok);
	int (*ssl_read_bytes)(SSL *s, int type, unsigned char *buf,
	    int len, int peek);
	int (*ssl_write_bytes)(SSL *s, int type, const void *buf_, int len);
	int (*ssl_dispatch_alert)(SSL *s);
	long (*ssl_ctrl)(SSL *s, int cmd, long larg, void *parg);
	long (*ssl_ctx_ctrl)(SSL_CTX *ctx, int cmd, long larg, void *parg);
	const SSL_CIPHER *(*get_cipher_by_char)(const unsigned char *ptr);
	int (*put_cipher_by_char)(const SSL_CIPHER *cipher, unsigned char *ptr);
	int (*ssl_pending)(const SSL *s);
	int (*num_ciphers)(void);
	const SSL_CIPHER *(*get_cipher)(unsigned ncipher);
	const struct ssl_method_st *(*get_ssl_method)(int version);
	long (*get_timeout)(void);
	struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */
	int (*ssl_version)(void);
	long (*ssl_callback_ctrl)(SSL *s, int cb_id, void (*fp)(void));
	long (*ssl_ctx_callback_ctrl)(SSL_CTX *s, int cb_id, void (*fp)(void));
};

/* Lets make this into an ASN.1 type structure as follows
 * SSL_SESSION_ID ::= SEQUENCE {
 *	version 		INTEGER,	-- structure version number
 *	SSLversion 		INTEGER,	-- SSL version number
 *	Cipher 			OCTET STRING,	-- the 3 byte cipher ID
 *	Session_ID 		OCTET STRING,	-- the Session ID
 *	Master_key 		OCTET STRING,	-- the master key
 *	KRB5_principal		OCTET STRING	-- optional Kerberos principal
 *	Time [ 1 ] EXPLICIT	INTEGER,	-- optional Start Time
 *	Timeout [ 2 ] EXPLICIT	INTEGER,	-- optional Timeout ins seconds
 *	Peer [ 3 ] EXPLICIT	X509,		-- optional Peer Certificate
 *	Session_ID_context [ 4 ] EXPLICIT OCTET STRING,   -- the Session ID context
 *	Verify_result [ 5 ] EXPLICIT INTEGER,   -- X509_V_... code for `Peer'
 *	HostName [ 6 ] EXPLICIT OCTET STRING,   -- optional HostName from servername TLS extension 
 *	PSK_identity_hint [ 7 ] EXPLICIT OCTET STRING, -- optional PSK identity hint
 *	PSK_identity [ 8 ] EXPLICIT OCTET STRING,  -- optional PSK identity
 *	Ticket_lifetime_hint [9] EXPLICIT INTEGER, -- server's lifetime hint for session ticket
 *	Ticket [10]             EXPLICIT OCTET STRING, -- session ticket (clients only)
 *	Compression_meth [11]   EXPLICIT OCTET STRING, -- optional compression method
 *	SRP_username [ 12 ] EXPLICIT OCTET STRING -- optional SRP username
 *	}
 * Look in ssl/ssl_asn1.c for more details
 * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-).
 */
struct ssl_session_st {
	int ssl_version;	/* what ssl version session info is
				 * being kept in here? */

	int master_key_length;
	unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH];
	/* session_id - valid? */
	unsigned int session_id_length;
	unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];
	/* this is used to determine whether the session is being reused in
	 * the appropriate context. It is up to the application to set this,
	 * via SSL_new */
	unsigned int sid_ctx_length;
	unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];

	/* Used to indicate that session resumption is not allowed.
	 * Applications can also set this bit for a new session via
	 * not_resumable_session_cb to disable session caching and tickets. */
	int not_resumable;

	/* The cert is the certificate used to establish this connection */
	struct sess_cert_st /* SESS_CERT */ *sess_cert;

	/* This is the cert for the other end.
	 * On clients, it will be the same as sess_cert->peer_key->x509
	 * (the latter is not enough as sess_cert is not retained
	 * in the external representation of sessions, see ssl_asn1.c). */
	X509 *peer;
	/* when app_verify_callback accepts a session where the peer's certificate
	 * is not ok, we must remember the error for session reuse: */
	long verify_result; /* only for servers */

	long timeout;
	time_t time;
	int references;

	const SSL_CIPHER *cipher;
	unsigned long cipher_id;	/* when ASN.1 loaded, this
					 * needs to be used to load
					 * the 'cipher' structure */

	STACK_OF(SSL_CIPHER) *ciphers; /* shared ciphers? */

	CRYPTO_EX_DATA ex_data; /* application specific data */

	/* These are used to make removal of session-ids more
	 * efficient and to implement a maximum cache size. */
	struct ssl_session_st *prev, *next;
	char *tlsext_hostname;
	size_t tlsext_ecpointformatlist_length;
	unsigned char *tlsext_ecpointformatlist; /* peer's list */
	size_t tlsext_ellipticcurvelist_length;
	unsigned char *tlsext_ellipticcurvelist; /* peer's list */
	/* RFC4507 info */
	unsigned char *tlsext_tick;	/* Session ticket */
	size_t tlsext_ticklen;		/* Session ticket length */
	long tlsext_tick_lifetime_hint;	/* Session lifetime hint in seconds */
};

#endif

#define SSL_OP_MICROSOFT_SESS_ID_BUG			0x00000001L
#define SSL_OP_NETSCAPE_CHALLENGE_BUG			0x00000002L
/* Allow initial connection to servers that don't support RI */
#define SSL_OP_LEGACY_SERVER_CONNECT			0x00000004L
#define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG		0x00000008L
#define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG		0x00000010L
#define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER		0x00000020L
#define SSL_OP_SAFARI_ECDHE_ECDSA_BUG			0x00000040L
#define SSL_OP_SSLEAY_080_CLIENT_DH_BUG			0x00000080L
#define SSL_OP_TLS_D5_BUG				0x00000100L
#define SSL_OP_TLS_BLOCK_PADDING_BUG			0x00000200L

/* Hasn't done anything since OpenSSL 0.9.7h, retained for compatibility */
#define SSL_OP_MSIE_SSLV2_RSA_PADDING			0x0

/* Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added
 * in OpenSSL 0.9.6d.  Usually (depending on the application protocol)
 * the workaround is not needed.
 * Unfortunately some broken SSL/TLS implementations cannot handle it
 * at all, which is why it was previously included in SSL_OP_ALL.
 * Now it's not.
 */
#define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS              0x00000800L /* added in 0.9.6e */

/* SSL_OP_ALL: various bug workarounds that should be rather harmless.
 *             This used to be 0x000FFFFFL before 0.9.7. */
#define SSL_OP_ALL					0x800003FFL

/* DTLS options */
#define SSL_OP_NO_QUERY_MTU                 0x00001000L
/* Turn on Cookie Exchange (on relevant for servers) */
#define SSL_OP_COOKIE_EXCHANGE              0x00002000L
/* Don't use RFC4507 ticket extension */
#define SSL_OP_NO_TICKET	            0x00004000L
/* Use Cisco's "speshul" version of DTLS_BAD_VER (as client)  */
#define SSL_OP_CISCO_ANYCONNECT		    0x00008000L

/* As server, disallow session resumption on renegotiation */
#define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION	0x00010000L
/* Don't use compression even if supported */
#define SSL_OP_NO_COMPRESSION				0x00020000L
/* Permit unsafe legacy renegotiation */
#define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION	0x00040000L
/* If set, always create a new key when using tmp_ecdh parameters */
#define SSL_OP_SINGLE_ECDH_USE				0x00080000L
/* If set, always create a new key when using tmp_dh parameters */
#define SSL_OP_SINGLE_DH_USE				0x00100000L
/* Set to always use the tmp_rsa key when doing RSA operations,
 * even when this violates protocol specs */
#define SSL_OP_EPHEMERAL_RSA				0x00200000L
/* Set on servers to choose the cipher according to the server's
 * preferences */
#define SSL_OP_CIPHER_SERVER_PREFERENCE			0x00400000L
/* If set, a server will allow a client to issue a SSLv3.0 version number
 * as latest version supported in the premaster secret, even when TLSv1.0
 * (version 3.1) was announced in the client hello. Normally this is
 * forbidden to prevent version rollback attacks. */
#define SSL_OP_TLS_ROLLBACK_BUG				0x00800000L

#define SSL_OP_NO_SSLv2					0x01000000L
#define SSL_OP_NO_SSLv3					0x02000000L
#define SSL_OP_NO_TLSv1					0x04000000L
#define SSL_OP_NO_TLSv1_2				0x08000000L
#define SSL_OP_NO_TLSv1_1				0x10000000L

/* Obsolete flags kept for compatibility. No sane code should use them. */
#define SSL_OP_PKCS1_CHECK_1				0x0
#define SSL_OP_PKCS1_CHECK_2				0x0

#define SSL_OP_NETSCAPE_CA_DN_BUG			0x20000000L
#define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG		0x40000000L
/* Make server add server-hello extension from early version of
 * cryptopro draft, when GOST ciphersuite is negotiated. 
 * Required for interoperability with CryptoPro CSP 3.x 
 */
#define SSL_OP_CRYPTOPRO_TLSEXT_BUG			0x80000000L

/* Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success
 * when just a single record has been written): */
#define SSL_MODE_ENABLE_PARTIAL_WRITE       0x00000001L
/* Make it possible to retry SSL_write() with changed buffer location
 * (buffer contents must stay the same!); this is not the default to avoid
 * the misconception that non-blocking SSL_write() behaves like
 * non-blocking write(): */
#define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002L
/* Never bother the application with retries if the transport
 * is blocking: */
#define SSL_MODE_AUTO_RETRY 0x00000004L
/* Don't attempt to automatically build certificate chain */
#define SSL_MODE_NO_AUTO_CHAIN 0x00000008L
/* Save RAM by releasing read and write buffers when they're empty. (SSL3 and
 * TLS only.)  "Released" buffers are put onto a free-list in the context
 * or just freed (depending on the context's setting for freelist_max_len). */
#define SSL_MODE_RELEASE_BUFFERS 0x00000010L

/* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value,
 * they cannot be used to clear bits. */

#define SSL_CTX_set_options(ctx,op) \
	SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL)
#define SSL_CTX_clear_options(ctx,op) \
	SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_OPTIONS,(op),NULL)
#define SSL_CTX_get_options(ctx) \
	SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,0,NULL)
#define SSL_set_options(ssl,op) \
	SSL_ctrl((ssl),SSL_CTRL_OPTIONS,(op),NULL)
#define SSL_clear_options(ssl,op) \
	SSL_ctrl((ssl),SSL_CTRL_CLEAR_OPTIONS,(op),NULL)
#define SSL_get_options(ssl) \
        SSL_ctrl((ssl),SSL_CTRL_OPTIONS,0,NULL)

#define SSL_CTX_set_mode(ctx,op) \
	SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)
#define SSL_CTX_clear_mode(ctx,op) \
	SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_MODE,(op),NULL)
#define SSL_CTX_get_mode(ctx) \
	SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL)
#define SSL_clear_mode(ssl,op) \
	SSL_ctrl((ssl),SSL_CTRL_CLEAR_MODE,(op),NULL)
#define SSL_set_mode(ssl,op) \
	SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL)
#define SSL_get_mode(ssl) \
        SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL)
#define SSL_set_mtu(ssl, mtu) \
        SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL)

#define SSL_get_secure_renegotiation_support(ssl) \
	SSL_ctrl((ssl), SSL_CTRL_GET_RI_SUPPORT, 0, NULL)

void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p,
    int version, int content_type, const void *buf, size_t len, SSL *ssl,
    void *arg));
void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version,
    int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
#define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))
#define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))

struct ssl_aead_ctx_st;
typedef struct ssl_aead_ctx_st SSL_AEAD_CTX;

#define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list :-) */

#define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT	(1024*20)

/* This callback type is used inside SSL_CTX, SSL, and in the functions that set
 * them. It is used to override the generation of SSL/TLS session IDs in a
 * server. Return value should be zero on an error, non-zero to proceed. Also,
 * callbacks should themselves check if the id they generate is unique otherwise
 * the SSL handshake will fail with an error - callbacks can do this using the
 * 'ssl' value they're passed by;
 *      SSL_has_matching_session_id(ssl, id, *id_len)
 * The length value passed in is set at the maximum size the session ID can be.
 * In SSLv2 this is 16 bytes, whereas SSLv3/TLSv1 it is 32 bytes. The callback
 * can alter this length to be less if desired, but under SSLv2 session IDs are
 * supposed to be fixed at 16 bytes so the id will be padded after the callback
 * returns in this case. It is also an error for the callback to set the size to
 * zero. */
typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id,
    unsigned int *id_len);

typedef struct ssl_comp_st SSL_COMP;

#ifndef OPENSSL_NO_SSL_INTERN

struct ssl_comp_st {
	int id;
	const char *name;
};

DECLARE_STACK_OF(SSL_COMP)
DECLARE_LHASH_OF(SSL_SESSION);

struct ssl_ctx_st {
	const SSL_METHOD *method;

	STACK_OF(SSL_CIPHER) *cipher_list;
	/* same as above but sorted for lookup */
	STACK_OF(SSL_CIPHER) *cipher_list_by_id;

	struct x509_store_st /* X509_STORE */ *cert_store;
	LHASH_OF(SSL_SESSION) *sessions;
	/* Most session-ids that will be cached, default is
	 * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited. */
	unsigned long session_cache_size;
	struct ssl_session_st *session_cache_head;
	struct ssl_session_st *session_cache_tail;

	/* This can have one of 2 values, ored together,
	 * SSL_SESS_CACHE_CLIENT,
	 * SSL_SESS_CACHE_SERVER,
	 * Default is SSL_SESSION_CACHE_SERVER, which means only
	 * SSL_accept which cache SSL_SESSIONS. */
	int session_cache_mode;

	/* If timeout is not 0, it is the default timeout value set
	 * when SSL_new() is called.  This has been put in to make
	 * life easier to set things up */
	long session_timeout;

	/* If this callback is not null, it will be called each
	 * time a session id is added to the cache.  If this function
	 * returns 1, it means that the callback will do a
	 * SSL_SESSION_free() when it has finished using it.  Otherwise,
	 * on 0, it means the callback has finished with it.
	 * If remove_session_cb is not null, it will be called when
	 * a session-id is removed from the cache.  After the call,
	 * OpenSSL will SSL_SESSION_free() it. */
	int (*new_session_cb)(struct ssl_st *ssl, SSL_SESSION *sess);
	void (*remove_session_cb)(struct ssl_ctx_st *ctx, SSL_SESSION *sess);
	SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl,
	unsigned char *data, int len, int *copy);

	struct {
		int sess_connect;	/* SSL new conn - started */
		int sess_connect_renegotiate;/* SSL reneg - requested */
		int sess_connect_good;	/* SSL new conne/reneg - finished */
		int sess_accept;	/* SSL new accept - started */
		int sess_accept_renegotiate;/* SSL reneg - requested */
		int sess_accept_good;	/* SSL accept/reneg - finished */
		int sess_miss;		/* session lookup misses  */
		int sess_timeout;	/* reuse attempt on timeouted session */
		int sess_cache_full;	/* session removed due to full cache */
		int sess_hit;		/* session reuse actually done */
		int sess_cb_hit;	/* session-id that was not
					 * in the cache was
					 * passed back via the callback.  This
					 * indicates that the application is
					 * supplying session-id's from other
					 * processes - spooky :-) */
	} stats;

	int references;

	/* if defined, these override the X509_verify_cert() calls */
	int (*app_verify_callback)(X509_STORE_CTX *, void *);
	void *app_verify_arg;
	/* before OpenSSL 0.9.7, 'app_verify_arg' was ignored
	 * ('app_verify_callback' was called with just one argument) */

	/* Default password callback. */
	pem_password_cb *default_passwd_callback;

	/* Default password callback user data. */
	void *default_passwd_callback_userdata;

	/* get client cert callback */
	int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey);

	/* cookie generate callback */
	int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie,
	unsigned int *cookie_len);

	/* verify cookie callback */
	int (*app_verify_cookie_cb)(SSL *ssl, unsigned char *cookie,
	unsigned int cookie_len);

	CRYPTO_EX_DATA ex_data;

	const EVP_MD *md5;	/* For SSLv3/TLSv1 'ssl3-md5' */
	const EVP_MD *sha1;	/* For SSLv3/TLSv1 'ssl3-sha1' */

	STACK_OF(X509) *extra_certs;

	/* Default values used when no per-SSL value is defined follow */

	void (*info_callback)(const SSL *ssl,int type,int val); /* used if SSL's info_callback is NULL */

	/* what we put in client cert requests */
	STACK_OF(X509_NAME) *client_CA;


	/* Default values to use in SSL structures follow (these are copied by SSL_new) */

	unsigned long options;
	unsigned long mode;
	long max_cert_list;

	struct cert_st /* CERT */ *cert;
	int read_ahead;

	/* callback that allows applications to peek at protocol messages */
	void (*msg_callback)(int write_p, int version, int content_type,
	    const void *buf, size_t len, SSL *ssl, void *arg);
	void *msg_callback_arg;

	int verify_mode;
	unsigned int sid_ctx_length;
	unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
	int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx); /* called 'verify_callback' in the SSL */

	/* Default generate session ID callback. */
	GEN_SESSION_CB generate_session_id;

	X509_VERIFY_PARAM *param;

	int quiet_shutdown;

	/* Maximum amount of data to send in one fragment.
	 * actual record size can be more than this due to
	 * padding and MAC overheads.
	 */
	unsigned int max_send_fragment;

#ifndef OPENSSL_NO_ENGINE
	/* Engine to pass requests for client certs to
	 */
	ENGINE *client_cert_engine;
#endif

	/* TLS extensions servername callback */
	int (*tlsext_servername_callback)(SSL*, int *, void *);
	void *tlsext_servername_arg;
	/* RFC 4507 session ticket keys */
	unsigned char tlsext_tick_key_name[16];
	unsigned char tlsext_tick_hmac_key[16];
	unsigned char tlsext_tick_aes_key[16];
	/* Callback to support customisation of ticket key setting */
	int (*tlsext_ticket_key_cb)(SSL *ssl, unsigned char *name,
	    unsigned char *iv, EVP_CIPHER_CTX *ectx, HMAC_CTX *hctx, int enc);

	/* certificate status request info */
	/* Callback for status request */
	int (*tlsext_status_cb)(SSL *ssl, void *arg);
	void *tlsext_status_arg;




# ifndef OPENSSL_NO_NEXTPROTONEG
	/* Next protocol negotiation information */
	/* (for experimental NPN extension). */

	/* For a server, this contains a callback function by which the set of
	 * advertised protocols can be provided. */
	int (*next_protos_advertised_cb)(SSL *s, const unsigned char **buf,
	    unsigned int *len, void *arg);
	void *next_protos_advertised_cb_arg;
	/* For a client, this contains a callback function that selects the
	 * next protocol from the list provided by the server. */
	int (*next_proto_select_cb)(SSL *s, unsigned char **out,
	    unsigned char *outlen, const unsigned char *in,
	    unsigned int inlen, void *arg);
	void *next_proto_select_cb_arg;
# endif
	/* SRTP profiles we are willing to do from RFC 5764 */
	STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles;

};

#endif

#define SSL_SESS_CACHE_OFF			0x0000
#define SSL_SESS_CACHE_CLIENT			0x0001
#define SSL_SESS_CACHE_SERVER			0x0002
#define SSL_SESS_CACHE_BOTH	(SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER)
#define SSL_SESS_CACHE_NO_AUTO_CLEAR		0x0080
/* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */
#define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP	0x0100
#define SSL_SESS_CACHE_NO_INTERNAL_STORE	0x0200
#define SSL_SESS_CACHE_NO_INTERNAL \
	(SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE)

LHASH_OF(SSL_SESSION) *SSL_CTX_sessions(SSL_CTX *ctx);
#define SSL_CTX_sess_number(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL)
#define SSL_CTX_sess_connect(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL)
#define SSL_CTX_sess_connect_good(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL)
#define SSL_CTX_sess_connect_renegotiate(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL)
#define SSL_CTX_sess_accept(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL)
#define SSL_CTX_sess_accept_renegotiate(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL)
#define SSL_CTX_sess_accept_good(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL)
#define SSL_CTX_sess_hits(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL)
#define SSL_CTX_sess_cb_hits(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL)
#define SSL_CTX_sess_misses(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL)
#define SSL_CTX_sess_timeouts(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL)
#define SSL_CTX_sess_cache_full(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL)

void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx,
    int (*new_session_cb)(struct ssl_st *ssl, SSL_SESSION *sess));
int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))(struct ssl_st *ssl,
    SSL_SESSION *sess);
void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx,
    void (*remove_session_cb)(struct ssl_ctx_st *ctx, SSL_SESSION *sess));
void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))(struct ssl_ctx_st *ctx,
    SSL_SESSION *sess);
void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx,
    SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, unsigned char *data,
    int len, int *copy));
SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(struct ssl_st *ssl,
    unsigned char *Data, int len, int *copy);
void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*cb)(const SSL *ssl,
    int type, int val));
void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(const SSL *ssl, int type,
    int val);
void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx,
    int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey));
int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL *ssl, X509 **x509,
    EVP_PKEY **pkey);
#ifndef OPENSSL_NO_ENGINE
int SSL_CTX_set_client_cert_engine(SSL_CTX *ctx, ENGINE *e);
#endif
void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx,
    int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie,
    unsigned int *cookie_len));
void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx,
    int (*app_verify_cookie_cb)(SSL *ssl, unsigned char *cookie,
    unsigned int cookie_len));
#ifndef OPENSSL_NO_NEXTPROTONEG
void
SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *s, int (*cb)(SSL *ssl,
    const unsigned char **out, unsigned int *outlen, void *arg), void *arg);
void SSL_CTX_set_next_proto_select_cb(SSL_CTX *s, int (*cb)(SSL *ssl,
    unsigned char **out, unsigned char *outlen, const unsigned char *in,
    unsigned int inlen, void *arg), void *arg);

int SSL_select_next_proto(unsigned char **out, unsigned char *outlen,
    const unsigned char *in, unsigned int inlen, const unsigned char *client,
    unsigned int client_len);
void SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data,
    unsigned *len);

#define OPENSSL_NPN_UNSUPPORTED	0
#define OPENSSL_NPN_NEGOTIATED	1
#define OPENSSL_NPN_NO_OVERLAP	2
#endif


#define SSL_NOTHING	1
#define SSL_WRITING	2
#define SSL_READING	3
#define SSL_X509_LOOKUP	4

/* These will only be used when doing non-blocking IO */
#define SSL_want_nothing(s)	(SSL_want(s) == SSL_NOTHING)
#define SSL_want_read(s)	(SSL_want(s) == SSL_READING)
#define SSL_want_write(s)	(SSL_want(s) == SSL_WRITING)
#define SSL_want_x509_lookup(s)	(SSL_want(s) == SSL_X509_LOOKUP)

#define SSL_MAC_FLAG_READ_MAC_STREAM 1
#define SSL_MAC_FLAG_WRITE_MAC_STREAM 2

#ifndef OPENSSL_NO_SSL_INTERN

struct ssl_st {
	/* protocol version
	 * (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION, DTLS1_VERSION)
	 */
	int version;
	int type; /* SSL_ST_CONNECT or SSL_ST_ACCEPT */

	const SSL_METHOD *method; /* SSLv3 */

	/* There are 2 BIO's even though they are normally both the
	 * same.  This is so data can be read and written to different
	 * handlers */

#ifndef OPENSSL_NO_BIO
	BIO *rbio; /* used by SSL_read */
	BIO *wbio; /* used by SSL_write */
	BIO *bbio; /* used during session-id reuse to concatenate
		    * messages */
#else
	char *rbio; /* used by SSL_read */
	char *wbio; /* used by SSL_write */
	char *bbio;
#endif
	/* This holds a variable that indicates what we were doing
	 * when a 0 or -1 is returned.  This is needed for
	 * non-blocking IO so we know what request needs re-doing when
	 * in SSL_accept or SSL_connect */
	int rwstate;

	/* true when we are actually in SSL_accept() or SSL_connect() */
	int in_handshake;
	int (*handshake_func)(SSL *);

	/* Imagine that here's a boolean member "init" that is
	 * switched as soon as SSL_set_{accept/connect}_state
	 * is called for the first time, so that "state" and
	 * "handshake_func" are properly initialized.  But as
	 * handshake_func is == 0 until then, we use this
	 * test instead of an "init" member.
	 */

	int server;	/* are we the server side? - mostly used by SSL_clear*/

	int new_session;/* Generate a new session or reuse an old one.
			 * NB: For servers, the 'new' session may actually be a previously
			 * cached session or even the previous session unless
			 * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set */
	int quiet_shutdown;/* don't send shutdown packets */
	int shutdown;	/* we have shut things down, 0x01 sent, 0x02
			 * for received */
	int state;	/* where we are */
	int rstate;	/* where we are when reading */

	BUF_MEM *init_buf;	/* buffer used during init */
	void *init_msg;		/* pointer to handshake message body, set by ssl3_get_message() */
	int init_num;		/* amount read/written */
	int init_off;		/* amount read/written */

	/* used internally to point at a raw packet */
	unsigned char *packet;
	unsigned int packet_length;

	struct ssl3_state_st *s3; /* SSLv3 variables */
	struct dtls1_state_st *d1; /* DTLSv1 variables */

	int read_ahead;		/* Read as many input bytes as possible
				 * (for non-blocking reads) */

	/* callback that allows applications to peek at protocol messages */
	void (*msg_callback)(int write_p, int version, int content_type,
	    const void *buf, size_t len, SSL *ssl, void *arg);
	void *msg_callback_arg;

	int hit;		/* reusing a previous session */

	X509_VERIFY_PARAM *param;

	/* crypto */
	STACK_OF(SSL_CIPHER) *cipher_list;
	STACK_OF(SSL_CIPHER) *cipher_list_by_id;

	/* These are the ones being used, the ones in SSL_SESSION are
	 * the ones to be 'copied' into these ones */
	int mac_flags;

	SSL_AEAD_CTX *aead_read_ctx;	/* AEAD context. If non-NULL, then
					   enc_read_ctx and read_hash are
					   ignored. */

	EVP_CIPHER_CTX *enc_read_ctx;		/* cryptographic state */
	EVP_MD_CTX *read_hash;			/* used for mac generation */

	SSL_AEAD_CTX *aead_write_ctx;	/* AEAD context. If non-NULL, then
					   enc_write_ctx and write_hash are
					   ignored. */

	EVP_CIPHER_CTX *enc_write_ctx;		/* cryptographic state */
	EVP_MD_CTX *write_hash;			/* used for mac generation */

	/* session info */

	/* client cert? */
	/* This is used to hold the server certificate used */
	struct cert_st /* CERT */ *cert;

	/* the session_id_context is used to ensure sessions are only reused
	 * in the appropriate context */
	unsigned int sid_ctx_length;
	unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];

	/* This can also be in the session once a session is established */
	SSL_SESSION *session;

	/* Default generate session ID callback. */
	GEN_SESSION_CB generate_session_id;

	/* Used in SSL2 and SSL3 */
	int verify_mode;	/* 0 don't care about verify failure.
				 * 1 fail if verify fails */
	int (*verify_callback)(int ok,X509_STORE_CTX *ctx); /* fail if callback returns 0 */

	void (*info_callback)(const SSL *ssl,int type,int val); /* optional informational callback */

	int error;		/* error bytes to be written */
	int error_code;		/* actual code */



	SSL_CTX *ctx;
	/* set this flag to 1 and a sleep(1) is put into all SSL_read()
	 * and SSL_write() calls, good for nbio debuging :-) */
	int debug;


	/* extra application data */
	long verify_result;
	CRYPTO_EX_DATA ex_data;

	/* for server side, keep the list of CA_dn we can use */
	STACK_OF(X509_NAME) *client_CA;

	int references;
	unsigned long options; /* protocol behaviour */
	unsigned long mode; /* API behaviour */
	long max_cert_list;
	int first_packet;
	int client_version;	/* what was passed, used for
				 * SSLv3/TLS rollback check */
	unsigned int max_send_fragment;
	/* TLS extension debug callback */
	void (*tlsext_debug_cb)(SSL *s, int client_server, int type,
	    unsigned char *data, int len, void *arg);
	void *tlsext_debug_arg;
	char *tlsext_hostname;
	int servername_done;	/* no further mod of servername 
				   0 : call the servername extension callback.
				   1 : prepare 2, allow last ack just after in server callback.
				   2 : don't call servername callback, no ack in server hello
				   */
	/* certificate status request info */
	/* Status type or -1 if no status type */
	int tlsext_status_type;
	/* Expect OCSP CertificateStatus message */
	int tlsext_status_expected;
	/* OCSP status request only */
	STACK_OF(OCSP_RESPID) *tlsext_ocsp_ids;
	X509_EXTENSIONS *tlsext_ocsp_exts;
	/* OCSP response received or to be sent */
	unsigned char *tlsext_ocsp_resp;
	int tlsext_ocsp_resplen;

	/* RFC4507 session ticket expected to be received or sent */
	int tlsext_ticket_expected;
	size_t tlsext_ecpointformatlist_length;
	unsigned char *tlsext_ecpointformatlist; /* our list */
	size_t tlsext_ellipticcurvelist_length;
	unsigned char *tlsext_ellipticcurvelist; /* our list */

	/* TLS Session Ticket extension override */
	TLS_SESSION_TICKET_EXT *tlsext_session_ticket;

	/* TLS Session Ticket extension callback */
	tls_session_ticket_ext_cb_fn tls_session_ticket_ext_cb;
	void *tls_session_ticket_ext_cb_arg;

	/* TLS pre-shared secret session resumption */
	tls_session_secret_cb_fn tls_session_secret_cb;
	void *tls_session_secret_cb_arg;

	SSL_CTX * initial_ctx; /* initial ctx, used to store sessions */

#ifndef OPENSSL_NO_NEXTPROTONEG
	/* Next protocol negotiation. For the client, this is the protocol that
	 * we sent in NextProtocol and is set when handling ServerHello
	 * extensions.
	 *
	 * For a server, this is the client's selected_protocol from
	 * NextProtocol and is set when handling the NextProtocol message,
	 * before the Finished message. */
	unsigned char *next_proto_negotiated;
	unsigned char next_proto_negotiated_len;
#endif

#define session_ctx initial_ctx

	STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles;	/* What we'll do */
	SRTP_PROTECTION_PROFILE *srtp_profile;			/* What's been chosen */

	unsigned int tlsext_heartbeat;	/* Is use of the Heartbeat extension negotiated?
					   0: disabled
					   1: enabled
					   2: enabled, but not allowed to send Requests
					   */
	unsigned int tlsext_hb_pending; /* Indicates if a HeartbeatRequest is in flight */
	unsigned int tlsext_hb_seq;	/* HeartbeatRequest sequence number */

	int renegotiate;/* 1 if we are renegotiating.
		 	 * 2 if we are a server and are inside a handshake
	                 * (i.e. not just sending a HelloRequest) */

};

#endif

#ifdef __cplusplus
}
#endif

#include 
#include 
#include 	/* This is mostly sslv3 with a few tweaks */
#include 	/* Datagram TLS */
#include 
#include 	/* Support for the use_srtp extension */

#ifdef  __cplusplus
extern "C" {
#endif

/* compatibility */
#define SSL_set_app_data(s,arg)		(SSL_set_ex_data(s,0,(char *)arg))
#define SSL_get_app_data(s)		(SSL_get_ex_data(s,0))
#define SSL_SESSION_set_app_data(s,a)	(SSL_SESSION_set_ex_data(s,0,(char *)a))
#define SSL_SESSION_get_app_data(s)	(SSL_SESSION_get_ex_data(s,0))
#define SSL_CTX_get_app_data(ctx)	(SSL_CTX_get_ex_data(ctx,0))
#define SSL_CTX_set_app_data(ctx,arg)	(SSL_CTX_set_ex_data(ctx,0,(char *)arg))

/* The following are the possible values for ssl->state are are
 * used to indicate where we are up to in the SSL connection establishment.
 * The macros that follow are about the only things you should need to use
 * and even then, only when using non-blocking IO.
 * It can also be useful to work out where you were when the connection
 * failed */

#define SSL_ST_CONNECT			0x1000
#define SSL_ST_ACCEPT			0x2000
#define SSL_ST_MASK			0x0FFF
#define SSL_ST_INIT			(SSL_ST_CONNECT|SSL_ST_ACCEPT)
#define SSL_ST_BEFORE			0x4000
#define SSL_ST_OK			0x03
#define SSL_ST_RENEGOTIATE		(0x04|SSL_ST_INIT)

#define SSL_CB_LOOP			0x01
#define SSL_CB_EXIT			0x02
#define SSL_CB_READ			0x04
#define SSL_CB_WRITE			0x08
#define SSL_CB_ALERT			0x4000 /* used in callback */
#define SSL_CB_READ_ALERT		(SSL_CB_ALERT|SSL_CB_READ)
#define SSL_CB_WRITE_ALERT		(SSL_CB_ALERT|SSL_CB_WRITE)
#define SSL_CB_ACCEPT_LOOP		(SSL_ST_ACCEPT|SSL_CB_LOOP)
#define SSL_CB_ACCEPT_EXIT		(SSL_ST_ACCEPT|SSL_CB_EXIT)
#define SSL_CB_CONNECT_LOOP		(SSL_ST_CONNECT|SSL_CB_LOOP)
#define SSL_CB_CONNECT_EXIT		(SSL_ST_CONNECT|SSL_CB_EXIT)
#define SSL_CB_HANDSHAKE_START		0x10
#define SSL_CB_HANDSHAKE_DONE		0x20

/* Is the SSL_connection established? */
#define SSL_get_state(a)		SSL_state(a)
#define SSL_is_init_finished(a)		(SSL_state(a) == SSL_ST_OK)
#define SSL_in_init(a)			(SSL_state(a)&SSL_ST_INIT)
#define SSL_in_before(a)		(SSL_state(a)&SSL_ST_BEFORE)
#define SSL_in_connect_init(a)		(SSL_state(a)&SSL_ST_CONNECT)
#define SSL_in_accept_init(a)		(SSL_state(a)&SSL_ST_ACCEPT)

/* The following 2 states are kept in ssl->rstate when reads fail,
 * you should not need these */
#define SSL_ST_READ_HEADER		0xF0
#define SSL_ST_READ_BODY		0xF1
#define SSL_ST_READ_DONE		0xF2

/* Obtain latest Finished message
 *   -- that we sent (SSL_get_finished)
 *   -- that we expected from peer (SSL_get_peer_finished).
 * Returns length (0 == no Finished so far), copies up to 'count' bytes. */
size_t SSL_get_finished(const SSL *s, void *buf, size_t count);
size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count);

/* use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options
 * are 'ored' with SSL_VERIFY_PEER if they are desired */
#define SSL_VERIFY_NONE			0x00
#define SSL_VERIFY_PEER			0x01
#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT	0x02
#define SSL_VERIFY_CLIENT_ONCE		0x04

#define OpenSSL_add_ssl_algorithms()	SSL_library_init()
#define SSLeay_add_ssl_algorithms()	SSL_library_init()

/* More backward compatibility */
#define SSL_get_cipher(s) \
		SSL_CIPHER_get_name(SSL_get_current_cipher(s))
#define SSL_get_cipher_bits(s,np) \
		SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np)
#define SSL_get_cipher_version(s) \
		SSL_CIPHER_get_version(SSL_get_current_cipher(s))
#define SSL_get_cipher_name(s) \
		SSL_CIPHER_get_name(SSL_get_current_cipher(s))
#define SSL_get_time(a)		SSL_SESSION_get_time(a)
#define SSL_set_time(a,b)	SSL_SESSION_set_time((a),(b))
#define SSL_get_timeout(a)	SSL_SESSION_get_timeout(a)
#define SSL_set_timeout(a,b)	SSL_SESSION_set_timeout((a),(b))

#define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id)
#define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id)

DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION)

#define SSL_AD_REASON_OFFSET		1000 /* offset to get SSL_R_... value from SSL_AD_... */

/* These alert types are for SSLv3 and TLSv1 */
#define SSL_AD_CLOSE_NOTIFY		SSL3_AD_CLOSE_NOTIFY
#define SSL_AD_UNEXPECTED_MESSAGE	SSL3_AD_UNEXPECTED_MESSAGE /* fatal */
#define SSL_AD_BAD_RECORD_MAC		SSL3_AD_BAD_RECORD_MAC     /* fatal */
#define SSL_AD_DECRYPTION_FAILED	TLS1_AD_DECRYPTION_FAILED
#define SSL_AD_RECORD_OVERFLOW		TLS1_AD_RECORD_OVERFLOW
#define SSL_AD_DECOMPRESSION_FAILURE	SSL3_AD_DECOMPRESSION_FAILURE/* fatal */
#define SSL_AD_HANDSHAKE_FAILURE	SSL3_AD_HANDSHAKE_FAILURE/* fatal */
#define SSL_AD_NO_CERTIFICATE		SSL3_AD_NO_CERTIFICATE /* Not for TLS */
#define SSL_AD_BAD_CERTIFICATE		SSL3_AD_BAD_CERTIFICATE
#define SSL_AD_UNSUPPORTED_CERTIFICATE	SSL3_AD_UNSUPPORTED_CERTIFICATE
#define SSL_AD_CERTIFICATE_REVOKED	SSL3_AD_CERTIFICATE_REVOKED
#define SSL_AD_CERTIFICATE_EXPIRED	SSL3_AD_CERTIFICATE_EXPIRED
#define SSL_AD_CERTIFICATE_UNKNOWN	SSL3_AD_CERTIFICATE_UNKNOWN
#define SSL_AD_ILLEGAL_PARAMETER	SSL3_AD_ILLEGAL_PARAMETER   /* fatal */
#define SSL_AD_UNKNOWN_CA		TLS1_AD_UNKNOWN_CA	/* fatal */
#define SSL_AD_ACCESS_DENIED		TLS1_AD_ACCESS_DENIED	/* fatal */
#define SSL_AD_DECODE_ERROR		TLS1_AD_DECODE_ERROR	/* fatal */
#define SSL_AD_DECRYPT_ERROR		TLS1_AD_DECRYPT_ERROR
#define SSL_AD_EXPORT_RESTRICTION	TLS1_AD_EXPORT_RESTRICTION/* fatal */
#define SSL_AD_PROTOCOL_VERSION		TLS1_AD_PROTOCOL_VERSION /* fatal */
#define SSL_AD_INSUFFICIENT_SECURITY	TLS1_AD_INSUFFICIENT_SECURITY/* fatal */
#define SSL_AD_INTERNAL_ERROR		TLS1_AD_INTERNAL_ERROR	/* fatal */
#define SSL_AD_USER_CANCELLED		TLS1_AD_USER_CANCELLED
#define SSL_AD_NO_RENEGOTIATION		TLS1_AD_NO_RENEGOTIATION
#define SSL_AD_UNSUPPORTED_EXTENSION	TLS1_AD_UNSUPPORTED_EXTENSION
#define SSL_AD_CERTIFICATE_UNOBTAINABLE TLS1_AD_CERTIFICATE_UNOBTAINABLE
#define SSL_AD_UNRECOGNIZED_NAME	TLS1_AD_UNRECOGNIZED_NAME
#define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE
#define SSL_AD_BAD_CERTIFICATE_HASH_VALUE TLS1_AD_BAD_CERTIFICATE_HASH_VALUE
#define SSL_AD_UNKNOWN_PSK_IDENTITY     TLS1_AD_UNKNOWN_PSK_IDENTITY /* fatal */

#define SSL_ERROR_NONE			0
#define SSL_ERROR_SSL			1
#define SSL_ERROR_WANT_READ		2
#define SSL_ERROR_WANT_WRITE		3
#define SSL_ERROR_WANT_X509_LOOKUP	4
#define SSL_ERROR_SYSCALL		5 /* look at error stack/return value/errno */
#define SSL_ERROR_ZERO_RETURN		6
#define SSL_ERROR_WANT_CONNECT		7
#define SSL_ERROR_WANT_ACCEPT		8

#define SSL_CTRL_NEED_TMP_RSA			1
#define SSL_CTRL_SET_TMP_RSA			2
#define SSL_CTRL_SET_TMP_DH			3
#define SSL_CTRL_SET_TMP_ECDH			4
#define SSL_CTRL_SET_TMP_RSA_CB			5
#define SSL_CTRL_SET_TMP_DH_CB			6
#define SSL_CTRL_SET_TMP_ECDH_CB		7

#define SSL_CTRL_GET_SESSION_REUSED		8
#define SSL_CTRL_GET_CLIENT_CERT_REQUEST	9
#define SSL_CTRL_GET_NUM_RENEGOTIATIONS		10
#define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS	11
#define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS	12
#define SSL_CTRL_GET_FLAGS			13
#define SSL_CTRL_EXTRA_CHAIN_CERT		14

#define SSL_CTRL_SET_MSG_CALLBACK               15
#define SSL_CTRL_SET_MSG_CALLBACK_ARG           16

/* only applies to datagram connections */
#define SSL_CTRL_SET_MTU                17
/* Stats */
#define SSL_CTRL_SESS_NUMBER			20
#define SSL_CTRL_SESS_CONNECT			21
#define SSL_CTRL_SESS_CONNECT_GOOD		22
#define SSL_CTRL_SESS_CONNECT_RENEGOTIATE	23
#define SSL_CTRL_SESS_ACCEPT			24
#define SSL_CTRL_SESS_ACCEPT_GOOD		25
#define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE	26
#define SSL_CTRL_SESS_HIT			27
#define SSL_CTRL_SESS_CB_HIT			28
#define SSL_CTRL_SESS_MISSES			29
#define SSL_CTRL_SESS_TIMEOUTS			30
#define SSL_CTRL_SESS_CACHE_FULL		31
#define SSL_CTRL_OPTIONS			32
#define SSL_CTRL_MODE				33

#define SSL_CTRL_GET_READ_AHEAD			40
#define SSL_CTRL_SET_READ_AHEAD			41
#define SSL_CTRL_SET_SESS_CACHE_SIZE		42
#define SSL_CTRL_GET_SESS_CACHE_SIZE		43
#define SSL_CTRL_SET_SESS_CACHE_MODE		44
#define SSL_CTRL_GET_SESS_CACHE_MODE		45

#define SSL_CTRL_GET_MAX_CERT_LIST		50
#define SSL_CTRL_SET_MAX_CERT_LIST		51

#define SSL_CTRL_SET_MAX_SEND_FRAGMENT		52

/* see tls1.h for macros based on these */
#define SSL_CTRL_SET_TLSEXT_SERVERNAME_CB	53
#define SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG	54
#define SSL_CTRL_SET_TLSEXT_HOSTNAME		55
#define SSL_CTRL_SET_TLSEXT_DEBUG_CB		56
#define SSL_CTRL_SET_TLSEXT_DEBUG_ARG		57
#define SSL_CTRL_GET_TLSEXT_TICKET_KEYS		58
#define SSL_CTRL_SET_TLSEXT_TICKET_KEYS		59
#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB	63
#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG	64
#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE	65
#define SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS	66
#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS	67
#define SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS	68
#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS	69
#define SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP	70
#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP	71

#define SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB	72

#define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB	75
#define SSL_CTRL_SET_SRP_VERIFY_PARAM_CB		76
#define SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB		77

#define SSL_CTRL_SET_SRP_ARG		78
#define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME		79
#define SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH		80
#define SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD		81

#define DTLS_CTRL_GET_TIMEOUT		73
#define DTLS_CTRL_HANDLE_TIMEOUT	74
#define DTLS_CTRL_LISTEN			75

#define SSL_CTRL_GET_RI_SUPPORT			76
#define SSL_CTRL_CLEAR_OPTIONS			77
#define SSL_CTRL_CLEAR_MODE			78

#define SSL_CTRL_GET_EXTRA_CHAIN_CERTS		82
#define SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS	83

#define DTLSv1_get_timeout(ssl, arg) \
	SSL_ctrl(ssl,DTLS_CTRL_GET_TIMEOUT,0, (void *)arg)
#define DTLSv1_handle_timeout(ssl) \
	SSL_ctrl(ssl,DTLS_CTRL_HANDLE_TIMEOUT,0, NULL)
#define DTLSv1_listen(ssl, peer) \
	SSL_ctrl(ssl,DTLS_CTRL_LISTEN,0, (void *)peer)

#define SSL_session_reused(ssl) \
	SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL)
#define SSL_num_renegotiations(ssl) \
	SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL)
#define SSL_clear_num_renegotiations(ssl) \
	SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL)
#define SSL_total_renegotiations(ssl) \
	SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL)

#define SSL_CTX_need_tmp_RSA(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_NEED_TMP_RSA,0,NULL)
#define SSL_CTX_set_tmp_rsa(ctx,rsa) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa)
#define SSL_CTX_set_tmp_dh(ctx,dh) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)dh)
#define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh)

#define SSL_need_tmp_RSA(ssl) \
	SSL_ctrl(ssl,SSL_CTRL_NEED_TMP_RSA,0,NULL)
#define SSL_set_tmp_rsa(ssl,rsa) \
	SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa)
#define SSL_set_tmp_dh(ssl,dh) \
	SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)dh)
#define SSL_set_tmp_ecdh(ssl,ecdh) \
	SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh)

#define SSL_CTX_add_extra_chain_cert(ctx,x509) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509)
#define SSL_CTX_get_extra_chain_certs(ctx,px509) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,0,px509)
#define SSL_CTX_clear_extra_chain_certs(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS,0,NULL)

#ifndef OPENSSL_NO_BIO
BIO_METHOD *BIO_f_ssl(void);
BIO *BIO_new_ssl(SSL_CTX *ctx, int client);
BIO *BIO_new_ssl_connect(SSL_CTX *ctx);
BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx);
int BIO_ssl_copy_session_id(BIO *to, BIO *from);
void BIO_ssl_shutdown(BIO *ssl_bio);
#endif

int	SSL_CTX_set_cipher_list(SSL_CTX *, const char *str);
SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth);
void	SSL_CTX_free(SSL_CTX *);
long SSL_CTX_set_timeout(SSL_CTX *ctx, long t);
long SSL_CTX_get_timeout(const SSL_CTX *ctx);
X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *);
void SSL_CTX_set_cert_store(SSL_CTX *, X509_STORE *);
int SSL_want(const SSL *s);
int	SSL_clear(SSL *s);

void	SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm);

const SSL_CIPHER *SSL_get_current_cipher(const SSL *s);
int	SSL_CIPHER_get_bits(const SSL_CIPHER *c, int *alg_bits);
char *	SSL_CIPHER_get_version(const SSL_CIPHER *c);
const char *	SSL_CIPHER_get_name(const SSL_CIPHER *c);
unsigned long 	SSL_CIPHER_get_id(const SSL_CIPHER *c);

int	SSL_get_fd(const SSL *s);
int	SSL_get_rfd(const SSL *s);
int	SSL_get_wfd(const SSL *s);
const char  * SSL_get_cipher_list(const SSL *s, int n);
char *	SSL_get_shared_ciphers(const SSL *s, char *buf, int len);
int	SSL_get_read_ahead(const SSL * s);
int	SSL_pending(const SSL *s);
int	SSL_set_fd(SSL *s, int fd);
int	SSL_set_rfd(SSL *s, int fd);
int	SSL_set_wfd(SSL *s, int fd);
#ifndef OPENSSL_NO_BIO
void	SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio);
BIO *	SSL_get_rbio(const SSL *s);
BIO *	SSL_get_wbio(const SSL *s);
#endif
int	SSL_set_cipher_list(SSL *s, const char *str);
void	SSL_set_read_ahead(SSL *s, int yes);
int	SSL_get_verify_mode(const SSL *s);
int	SSL_get_verify_depth(const SSL *s);
int	(*SSL_get_verify_callback(const SSL *s))(int, X509_STORE_CTX *);
void	SSL_set_verify(SSL *s, int mode,
	    int (*callback)(int ok, X509_STORE_CTX *ctx));
void	SSL_set_verify_depth(SSL *s, int depth);
int	SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa);
int	SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len);
int	SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey);
int	SSL_use_PrivateKey_ASN1(int pk, SSL *ssl, const unsigned char *d, long len);
int	SSL_use_certificate(SSL *ssl, X509 *x);
int	SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len);

int	SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type);
int	SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type);
int	SSL_use_certificate_file(SSL *ssl, const char *file, int type);
int	SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type);
int	SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type);
int	SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type);
int	SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); /* PEM type */
STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file);
int	SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,
	    const char *file);
int	SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,
	    const char *dir);

void	SSL_load_error_strings(void );
const char *SSL_state_string(const SSL *s);
const char *SSL_rstate_string(const SSL *s);
const char *SSL_state_string_long(const SSL *s);
const char *SSL_rstate_string_long(const SSL *s);
long	SSL_SESSION_get_time(const SSL_SESSION *s);
long	SSL_SESSION_set_time(SSL_SESSION *s, long t);
long	SSL_SESSION_get_timeout(const SSL_SESSION *s);
long	SSL_SESSION_set_timeout(SSL_SESSION *s, long t);
void	SSL_copy_session_id(SSL *to, const SSL *from);
X509 *SSL_SESSION_get0_peer(SSL_SESSION *s);
int
SSL_SESSION_set1_id_context(SSL_SESSION *s, const unsigned char *sid_ctx,
unsigned int sid_ctx_len);

SSL_SESSION *SSL_SESSION_new(void);
const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s,
	    unsigned int *len);
unsigned int SSL_SESSION_get_compress_id(const SSL_SESSION *s);
int	SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *ses);
#ifndef OPENSSL_NO_BIO
int	SSL_SESSION_print(BIO *fp, const SSL_SESSION *ses);
#endif
void	SSL_SESSION_free(SSL_SESSION *ses);
int	i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp);
int	SSL_set_session(SSL *to, SSL_SESSION *session);
int	SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c);
int	SSL_CTX_remove_session(SSL_CTX *, SSL_SESSION *c);
int	SSL_CTX_set_generate_session_id(SSL_CTX *, GEN_SESSION_CB);
int	SSL_set_generate_session_id(SSL *, GEN_SESSION_CB);
int	SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id,
	    unsigned int id_len);
SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,
	    long length);

#ifdef HEADER_X509_H
X509 *	SSL_get_peer_certificate(const SSL *s);
#endif

STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s);

int SSL_CTX_get_verify_mode(const SSL_CTX *ctx);
int SSL_CTX_get_verify_depth(const SSL_CTX *ctx);
int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(int, X509_STORE_CTX *);
void SSL_CTX_set_verify(SSL_CTX *ctx, int mode,
    int (*callback)(int, X509_STORE_CTX *));
void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth);
void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *, void *), void *arg);
int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa);
int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, long len);
int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey);
int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx, const unsigned char *d, long len);
int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x);
int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, const unsigned char *d);

void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb);
void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u);

int SSL_CTX_check_private_key(const SSL_CTX *ctx);
int SSL_check_private_key(const SSL *ctx);

int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx, unsigned int sid_ctx_len);

SSL *SSL_new(SSL_CTX *ctx);
int SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx, unsigned int sid_ctx_len);

int SSL_CTX_set_purpose(SSL_CTX *s, int purpose);
int SSL_set_purpose(SSL *s, int purpose);
int SSL_CTX_set_trust(SSL_CTX *s, int trust);
int SSL_set_trust(SSL *s, int trust);

int SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm);
int SSL_set1_param(SSL *ssl, X509_VERIFY_PARAM *vpm);


void	SSL_free(SSL *ssl);
int 	SSL_accept(SSL *ssl);
int 	SSL_connect(SSL *ssl);
int 	SSL_read(SSL *ssl, void *buf, int num);
int 	SSL_peek(SSL *ssl, void *buf, int num);
int 	SSL_write(SSL *ssl, const void *buf, int num);
long	SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg);
long	SSL_callback_ctrl(SSL *, int, void (*)(void));
long	SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);
long	SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void));

int	SSL_get_error(const SSL *s, int ret_code);
const char *SSL_get_version(const SSL *s);

/* This sets the 'default' SSL version that SSL_new() will create */
int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth);

const SSL_METHOD *SSLv3_method(void);		/* SSLv3 */
const SSL_METHOD *SSLv3_server_method(void);	/* SSLv3 */
const SSL_METHOD *SSLv3_client_method(void);	/* SSLv3 */

const SSL_METHOD *SSLv23_method(void);		/* SSLv3 or TLSv1.* */
const SSL_METHOD *SSLv23_server_method(void);	/* SSLv3 or TLSv1.* */
const SSL_METHOD *SSLv23_client_method(void);	/* SSLv3 or TLSv1.* */

const SSL_METHOD *TLSv1_method(void);		/* TLSv1.0 */
const SSL_METHOD *TLSv1_server_method(void);	/* TLSv1.0 */
const SSL_METHOD *TLSv1_client_method(void);	/* TLSv1.0 */

const SSL_METHOD *TLSv1_1_method(void);		/* TLSv1.1 */
const SSL_METHOD *TLSv1_1_server_method(void);	/* TLSv1.1 */
const SSL_METHOD *TLSv1_1_client_method(void);	/* TLSv1.1 */

const SSL_METHOD *TLSv1_2_method(void);		/* TLSv1.2 */
const SSL_METHOD *TLSv1_2_server_method(void);	/* TLSv1.2 */
const SSL_METHOD *TLSv1_2_client_method(void);	/* TLSv1.2 */


const SSL_METHOD *DTLSv1_method(void);		/* DTLSv1.0 */
const SSL_METHOD *DTLSv1_server_method(void);	/* DTLSv1.0 */
const SSL_METHOD *DTLSv1_client_method(void);	/* DTLSv1.0 */

STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s);

int SSL_do_handshake(SSL *s);
int SSL_renegotiate(SSL *s);
int SSL_renegotiate_abbreviated(SSL *s);
int SSL_renegotiate_pending(SSL *s);
int SSL_shutdown(SSL *s);

const SSL_METHOD *SSL_get_ssl_method(SSL *s);
int SSL_set_ssl_method(SSL *s, const SSL_METHOD *method);
const char *SSL_alert_type_string_long(int value);
const char *SSL_alert_type_string(int value);
const char *SSL_alert_desc_string_long(int value);
const char *SSL_alert_desc_string(int value);

void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list);
void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list);
STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s);
STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *s);
int SSL_add_client_CA(SSL *ssl, X509 *x);
int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x);

void SSL_set_connect_state(SSL *s);
void SSL_set_accept_state(SSL *s);

long SSL_get_default_timeout(const SSL *s);

int SSL_library_init(void );

char *SSL_CIPHER_description(const SSL_CIPHER *, char *buf, int size);
STACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *sk);

SSL *SSL_dup(SSL *ssl);

X509 *SSL_get_certificate(const SSL *ssl);
/* EVP_PKEY */ struct evp_pkey_st *SSL_get_privatekey(SSL *ssl);

void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx,int mode);
int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx);
void SSL_set_quiet_shutdown(SSL *ssl,int mode);
int SSL_get_quiet_shutdown(const SSL *ssl);
void SSL_set_shutdown(SSL *ssl,int mode);
int SSL_get_shutdown(const SSL *ssl);
int SSL_version(const SSL *ssl);
int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);
int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
    const char *CApath);
#define SSL_get0_session SSL_get_session /* just peek at pointer */
SSL_SESSION *SSL_get_session(const SSL *ssl);
SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */
SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl);
SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX* ctx);
void SSL_set_info_callback(SSL *ssl,
    void (*cb)(const SSL *ssl, int type, int val));
void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl, int type, int val);
int SSL_state(const SSL *ssl);
void SSL_set_state(SSL *ssl, int state);

void SSL_set_verify_result(SSL *ssl, long v);
long SSL_get_verify_result(const SSL *ssl);

int SSL_set_ex_data(SSL *ssl, int idx, void *data);
void *SSL_get_ex_data(const SSL *ssl, int idx);
int SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
    CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);

int SSL_SESSION_set_ex_data(SSL_SESSION *ss, int idx, void *data);
void *SSL_SESSION_get_ex_data(const SSL_SESSION *ss, int idx);
int SSL_SESSION_get_ex_new_index(long argl, void *argp,
    CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
    CRYPTO_EX_free *free_func);

int SSL_CTX_set_ex_data(SSL_CTX *ssl, int idx, void *data);
void *SSL_CTX_get_ex_data(const SSL_CTX *ssl, int idx);
int SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
    CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);

int SSL_get_ex_data_X509_STORE_CTX_idx(void );

#define SSL_CTX_sess_set_cache_size(ctx,t) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL)
#define SSL_CTX_sess_get_cache_size(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL)
#define SSL_CTX_set_session_cache_mode(ctx,m) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL)
#define SSL_CTX_get_session_cache_mode(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL)

#define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx)
#define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m)
#define SSL_CTX_get_read_ahead(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL)
#define SSL_CTX_set_read_ahead(ctx,m) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL)
#define SSL_CTX_get_max_cert_list(ctx) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)
#define SSL_CTX_set_max_cert_list(ctx,m) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)
#define SSL_get_max_cert_list(ssl) \
	SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)
#define SSL_set_max_cert_list(ssl,m) \
	SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)

#define SSL_CTX_set_max_send_fragment(ctx,m) \
	SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL)
#define SSL_set_max_send_fragment(ssl,m) \
	SSL_ctrl(ssl,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL)

/* NB: the keylength is only applicable when is_export is true */
void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,
    RSA *(*cb)(SSL *ssl, int is_export, int keylength));

void SSL_set_tmp_rsa_callback(SSL *ssl,
    RSA *(*cb)(SSL *ssl, int is_export, int keylength));
void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,
    DH *(*dh)(SSL *ssl, int is_export, int keylength));
void SSL_set_tmp_dh_callback(SSL *ssl,
    DH *(*dh)(SSL *ssl, int is_export, int keylength));
void SSL_CTX_set_tmp_ecdh_callback(SSL_CTX *ctx,
    EC_KEY *(*ecdh)(SSL *ssl, int is_export, int keylength));
void SSL_set_tmp_ecdh_callback(SSL *ssl,
    EC_KEY *(*ecdh)(SSL *ssl, int is_export, int keylength));

const void *SSL_get_current_compression(SSL *s);
const void *SSL_get_current_expansion(SSL *s);

const char *SSL_COMP_get_name(const void *comp);
void *SSL_COMP_get_compression_methods(void);
int SSL_COMP_add_compression_method(int id, void *cm);

/* TLS extensions functions */
int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len);

int SSL_set_session_ticket_ext_cb(SSL *s,
    tls_session_ticket_ext_cb_fn cb, void *arg);

/* Pre-shared secret session resumption functions */
int SSL_set_session_secret_cb(SSL *s,
    tls_session_secret_cb_fn tls_session_secret_cb, void *arg);

void SSL_set_debug(SSL *s, int debug);
int SSL_cache_hit(SSL *s);

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_SSL_strings(void);

/* Error codes for the SSL functions. */

/* Function codes. */
#define SSL_F_CLIENT_CERTIFICATE			 100
#define SSL_F_CLIENT_FINISHED				 167
#define SSL_F_CLIENT_HELLO				 101
#define SSL_F_CLIENT_MASTER_KEY				 102
#define SSL_F_D2I_SSL_SESSION				 103
#define SSL_F_DO_DTLS1_WRITE				 245
#define SSL_F_DO_SSL3_WRITE				 104
#define SSL_F_DTLS1_ACCEPT				 246
#define SSL_F_DTLS1_ADD_CERT_TO_BUF			 295
#define SSL_F_DTLS1_BUFFER_RECORD			 247
#define SSL_F_DTLS1_CHECK_TIMEOUT_NUM			 316
#define SSL_F_DTLS1_CLIENT_HELLO			 248
#define SSL_F_DTLS1_CONNECT				 249
#define SSL_F_DTLS1_ENC					 250
#define SSL_F_DTLS1_GET_HELLO_VERIFY			 251
#define SSL_F_DTLS1_GET_MESSAGE				 252
#define SSL_F_DTLS1_GET_MESSAGE_FRAGMENT		 253
#define SSL_F_DTLS1_GET_RECORD				 254
#define SSL_F_DTLS1_HANDLE_TIMEOUT			 297
#define SSL_F_DTLS1_HEARTBEAT				 305
#define SSL_F_DTLS1_OUTPUT_CERT_CHAIN			 255
#define SSL_F_DTLS1_PREPROCESS_FRAGMENT			 288
#define SSL_F_DTLS1_PROCESS_OUT_OF_SEQ_MESSAGE		 256
#define SSL_F_DTLS1_PROCESS_RECORD			 257
#define SSL_F_DTLS1_READ_BYTES				 258
#define SSL_F_DTLS1_READ_FAILED				 259
#define SSL_F_DTLS1_SEND_CERTIFICATE_REQUEST		 260
#define SSL_F_DTLS1_SEND_CLIENT_CERTIFICATE		 261
#define SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE		 262
#define SSL_F_DTLS1_SEND_CLIENT_VERIFY			 263
#define SSL_F_DTLS1_SEND_HELLO_VERIFY_REQUEST		 264
#define SSL_F_DTLS1_SEND_SERVER_CERTIFICATE		 265
#define SSL_F_DTLS1_SEND_SERVER_HELLO			 266
#define SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE		 267
#define SSL_F_DTLS1_WRITE_APP_DATA_BYTES		 268
#define SSL_F_GET_CLIENT_FINISHED			 105
#define SSL_F_GET_CLIENT_HELLO				 106
#define SSL_F_GET_CLIENT_MASTER_KEY			 107
#define SSL_F_GET_SERVER_FINISHED			 108
#define SSL_F_GET_SERVER_HELLO				 109
#define SSL_F_GET_SERVER_VERIFY				 110
#define SSL_F_I2D_SSL_SESSION				 111
#define SSL_F_READ_N					 112
#define SSL_F_REQUEST_CERTIFICATE			 113
#define SSL_F_SERVER_FINISH				 239
#define SSL_F_SERVER_HELLO				 114
#define SSL_F_SERVER_VERIFY				 240
#define SSL_F_SSL23_ACCEPT				 115
#define SSL_F_SSL23_CLIENT_HELLO			 116
#define SSL_F_SSL23_CONNECT				 117
#define SSL_F_SSL23_GET_CLIENT_HELLO			 118
#define SSL_F_SSL23_GET_SERVER_HELLO			 119
#define SSL_F_SSL23_PEEK				 237
#define SSL_F_SSL23_READ				 120
#define SSL_F_SSL23_WRITE				 121
#define SSL_F_SSL2_ACCEPT				 122
#define SSL_F_SSL2_CONNECT				 123
#define SSL_F_SSL2_ENC_INIT				 124
#define SSL_F_SSL2_GENERATE_KEY_MATERIAL		 241
#define SSL_F_SSL2_PEEK					 234
#define SSL_F_SSL2_READ					 125
#define SSL_F_SSL2_READ_INTERNAL			 236
#define SSL_F_SSL2_SET_CERTIFICATE			 126
#define SSL_F_SSL2_WRITE				 127
#define SSL_F_SSL3_ACCEPT				 128
#define SSL_F_SSL3_ADD_CERT_TO_BUF			 296
#define SSL_F_SSL3_CALLBACK_CTRL			 233
#define SSL_F_SSL3_CHANGE_CIPHER_STATE			 129
#define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM		 130
#define SSL_F_SSL3_CHECK_CLIENT_HELLO			 304
#define SSL_F_SSL3_CLIENT_HELLO				 131
#define SSL_F_SSL3_CONNECT				 132
#define SSL_F_SSL3_CTRL					 213
#define SSL_F_SSL3_CTX_CTRL				 133
#define SSL_F_SSL3_DIGEST_CACHED_RECORDS		 293
#define SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC		 292
#define SSL_F_SSL3_ENC					 134
#define SSL_F_SSL3_GENERATE_KEY_BLOCK			 238
#define SSL_F_SSL3_GET_CERTIFICATE_REQUEST		 135
#define SSL_F_SSL3_GET_CERT_STATUS			 289
#define SSL_F_SSL3_GET_CERT_VERIFY			 136
#define SSL_F_SSL3_GET_CLIENT_CERTIFICATE		 137
#define SSL_F_SSL3_GET_CLIENT_HELLO			 138
#define SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE		 139
#define SSL_F_SSL3_GET_FINISHED				 140
#define SSL_F_SSL3_GET_KEY_EXCHANGE			 141
#define SSL_F_SSL3_GET_MESSAGE				 142
#define SSL_F_SSL3_GET_NEW_SESSION_TICKET		 283
#define SSL_F_SSL3_GET_NEXT_PROTO			 306
#define SSL_F_SSL3_GET_RECORD				 143
#define SSL_F_SSL3_GET_SERVER_CERTIFICATE		 144
#define SSL_F_SSL3_GET_SERVER_DONE			 145
#define SSL_F_SSL3_GET_SERVER_HELLO			 146
#define SSL_F_SSL3_HANDSHAKE_MAC			 285
#define SSL_F_SSL3_NEW_SESSION_TICKET			 287
#define SSL_F_SSL3_OUTPUT_CERT_CHAIN			 147
#define SSL_F_SSL3_PEEK					 235
#define SSL_F_SSL3_READ_BYTES				 148
#define SSL_F_SSL3_READ_N				 149
#define SSL_F_SSL3_SEND_CERTIFICATE_REQUEST		 150
#define SSL_F_SSL3_SEND_CLIENT_CERTIFICATE		 151
#define SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE		 152
#define SSL_F_SSL3_SEND_CLIENT_VERIFY			 153
#define SSL_F_SSL3_SEND_SERVER_CERTIFICATE		 154
#define SSL_F_SSL3_SEND_SERVER_HELLO			 242
#define SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE		 155
#define SSL_F_SSL3_SETUP_KEY_BLOCK			 157
#define SSL_F_SSL3_SETUP_READ_BUFFER			 156
#define SSL_F_SSL3_SETUP_WRITE_BUFFER			 291
#define SSL_F_SSL3_WRITE_BYTES				 158
#define SSL_F_SSL3_WRITE_PENDING			 159
#define SSL_F_SSL_ADD_CLIENTHELLO_RENEGOTIATE_EXT	 298
#define SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT		 277
#define SSL_F_SSL_ADD_CLIENTHELLO_USE_SRTP_EXT		 307
#define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK	 215
#define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK	 216
#define SSL_F_SSL_ADD_SERVERHELLO_RENEGOTIATE_EXT	 299
#define SSL_F_SSL_ADD_SERVERHELLO_TLSEXT		 278
#define SSL_F_SSL_ADD_SERVERHELLO_USE_SRTP_EXT		 308
#define SSL_F_SSL_BAD_METHOD				 160
#define SSL_F_SSL_BYTES_TO_CIPHER_LIST			 161
#define SSL_F_SSL_CERT_DUP				 221
#define SSL_F_SSL_CERT_INST				 222
#define SSL_F_SSL_CERT_INSTANTIATE			 214
#define SSL_F_SSL_CERT_NEW				 162
#define SSL_F_SSL_CHECK_PRIVATE_KEY			 163
#define SSL_F_SSL_CHECK_SERVERHELLO_TLSEXT		 280
#define SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG		 279
#define SSL_F_SSL_CIPHER_PROCESS_RULESTR		 230
#define SSL_F_SSL_CIPHER_STRENGTH_SORT			 231
#define SSL_F_SSL_CLEAR					 164
#define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD		 165
#define SSL_F_SSL_CREATE_CIPHER_LIST			 166
#define SSL_F_SSL_CTRL					 232
#define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY			 168
#define SSL_F_SSL_CTX_MAKE_PROFILES			 309
#define SSL_F_SSL_CTX_NEW				 169
#define SSL_F_SSL_CTX_SET_CIPHER_LIST			 269
#define SSL_F_SSL_CTX_SET_CLIENT_CERT_ENGINE		 290
#define SSL_F_SSL_CTX_SET_PURPOSE			 226
#define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT		 219
#define SSL_F_SSL_CTX_SET_SSL_VERSION			 170
#define SSL_F_SSL_CTX_SET_TRUST				 229
#define SSL_F_SSL_CTX_USE_CERTIFICATE			 171
#define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1		 172
#define SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE	 220
#define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE		 173
#define SSL_F_SSL_CTX_USE_PRIVATEKEY			 174
#define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1		 175
#define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE		 176
#define SSL_F_SSL_CTX_USE_PSK_IDENTITY_HINT		 272
#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY			 177
#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1		 178
#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE		 179
#define SSL_F_SSL_DO_HANDSHAKE				 180
#define SSL_F_SSL_GET_NEW_SESSION			 181
#define SSL_F_SSL_GET_PREV_SESSION			 217
#define SSL_F_SSL_GET_SERVER_SEND_CERT			 182
#define SSL_F_SSL_GET_SERVER_SEND_PKEY			 317
#define SSL_F_SSL_GET_SIGN_PKEY				 183
#define SSL_F_SSL_INIT_WBIO_BUFFER			 184
#define SSL_F_SSL_LOAD_CLIENT_CA_FILE			 185
#define SSL_F_SSL_NEW					 186
#define SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT	 300
#define SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT		 302
#define SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT	 310
#define SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT	 301
#define SSL_F_SSL_PARSE_SERVERHELLO_TLSEXT		 303
#define SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT	 311
#define SSL_F_SSL_PEEK					 270
#define SSL_F_SSL_PREPARE_CLIENTHELLO_TLSEXT		 281
#define SSL_F_SSL_PREPARE_SERVERHELLO_TLSEXT		 282
#define SSL_F_SSL_READ					 223
#define SSL_F_SSL_RSA_PRIVATE_DECRYPT			 187
#define SSL_F_SSL_RSA_PUBLIC_ENCRYPT			 188
#define SSL_F_SSL_SESSION_NEW				 189
#define SSL_F_SSL_SESSION_PRINT_FP			 190
#define SSL_F_SSL_SESSION_SET1_ID_CONTEXT		 312
#define SSL_F_SSL_SESS_CERT_NEW				 225
#define SSL_F_SSL_SET_CERT				 191
#define SSL_F_SSL_SET_CIPHER_LIST			 271
#define SSL_F_SSL_SET_FD				 192
#define SSL_F_SSL_SET_PKEY				 193
#define SSL_F_SSL_SET_PURPOSE				 227
#define SSL_F_SSL_SET_RFD				 194
#define SSL_F_SSL_SET_SESSION				 195
#define SSL_F_SSL_SET_SESSION_ID_CONTEXT		 218
#define SSL_F_SSL_SET_SESSION_TICKET_EXT		 294
#define SSL_F_SSL_SET_TRUST				 228
#define SSL_F_SSL_SET_WFD				 196
#define SSL_F_SSL_SHUTDOWN				 224
#define SSL_F_SSL_SRP_CTX_INIT				 313
#define SSL_F_SSL_UNDEFINED_CONST_FUNCTION		 243
#define SSL_F_SSL_UNDEFINED_FUNCTION			 197
#define SSL_F_SSL_UNDEFINED_VOID_FUNCTION		 244
#define SSL_F_SSL_USE_CERTIFICATE			 198
#define SSL_F_SSL_USE_CERTIFICATE_ASN1			 199
#define SSL_F_SSL_USE_CERTIFICATE_FILE			 200
#define SSL_F_SSL_USE_PRIVATEKEY			 201
#define SSL_F_SSL_USE_PRIVATEKEY_ASN1			 202
#define SSL_F_SSL_USE_PRIVATEKEY_FILE			 203
#define SSL_F_SSL_USE_PSK_IDENTITY_HINT			 273
#define SSL_F_SSL_USE_RSAPRIVATEKEY			 204
#define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1		 205
#define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE		 206
#define SSL_F_SSL_VERIFY_CERT_CHAIN			 207
#define SSL_F_SSL_WRITE					 208
#define SSL_F_TLS1_AEAD_CTX_INIT			 339
#define SSL_F_TLS1_CERT_VERIFY_MAC			 286
#define SSL_F_TLS1_CHANGE_CIPHER_STATE			 209
#define SSL_F_TLS1_CHANGE_CIPHER_STATE_AEAD		 340
#define SSL_F_TLS1_CHANGE_CIPHER_STATE_CIPHER		 338
#define SSL_F_TLS1_CHECK_SERVERHELLO_TLSEXT		 274
#define SSL_F_TLS1_ENC					 210
#define SSL_F_TLS1_EXPORT_KEYING_MATERIAL		 314
#define SSL_F_TLS1_HEARTBEAT				 315
#define SSL_F_TLS1_PREPARE_CLIENTHELLO_TLSEXT		 275
#define SSL_F_TLS1_PREPARE_SERVERHELLO_TLSEXT		 276
#define SSL_F_TLS1_PRF					 284
#define SSL_F_TLS1_SETUP_KEY_BLOCK			 211
#define SSL_F_WRITE_PENDING				 212

/* Reason codes. */
#define SSL_R_APP_DATA_IN_HANDSHAKE			 100
#define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 272
#define SSL_R_BAD_ALERT_RECORD				 101
#define SSL_R_BAD_AUTHENTICATION_TYPE			 102
#define SSL_R_BAD_CHANGE_CIPHER_SPEC			 103
#define SSL_R_BAD_CHECKSUM				 104
#define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK		 106
#define SSL_R_BAD_DECOMPRESSION				 107
#define SSL_R_BAD_DH_G_LENGTH				 108
#define SSL_R_BAD_DH_PUB_KEY_LENGTH			 109
#define SSL_R_BAD_DH_P_LENGTH				 110
#define SSL_R_BAD_DIGEST_LENGTH				 111
#define SSL_R_BAD_DSA_SIGNATURE				 112
#define SSL_R_BAD_ECC_CERT				 304
#define SSL_R_BAD_ECDSA_SIGNATURE			 305
#define SSL_R_BAD_ECPOINT				 306
#define SSL_R_BAD_HANDSHAKE_LENGTH			 332
#define SSL_R_BAD_HELLO_REQUEST				 105
#define SSL_R_BAD_LENGTH				 271
#define SSL_R_BAD_MAC_DECODE				 113
#define SSL_R_BAD_MAC_LENGTH				 333
#define SSL_R_BAD_MESSAGE_TYPE				 114
#define SSL_R_BAD_PACKET_LENGTH				 115
#define SSL_R_BAD_PROTOCOL_VERSION_NUMBER		 116
#define SSL_R_BAD_PSK_IDENTITY_HINT_LENGTH		 316
#define SSL_R_BAD_RESPONSE_ARGUMENT			 117
#define SSL_R_BAD_RSA_DECRYPT				 118
#define SSL_R_BAD_RSA_ENCRYPT				 119
#define SSL_R_BAD_RSA_E_LENGTH				 120
#define SSL_R_BAD_RSA_MODULUS_LENGTH			 121
#define SSL_R_BAD_RSA_SIGNATURE				 122
#define SSL_R_BAD_SIGNATURE				 123
#define SSL_R_BAD_SRP_A_LENGTH				 347
#define SSL_R_BAD_SRP_B_LENGTH				 348
#define SSL_R_BAD_SRP_G_LENGTH				 349
#define SSL_R_BAD_SRP_N_LENGTH				 350
#define SSL_R_BAD_SRP_S_LENGTH				 351
#define SSL_R_BAD_SRTP_MKI_VALUE			 352
#define SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST		 353
#define SSL_R_BAD_SSL_FILETYPE				 124
#define SSL_R_BAD_SSL_SESSION_ID_LENGTH			 125
#define SSL_R_BAD_STATE					 126
#define SSL_R_BAD_WRITE_RETRY				 127
#define SSL_R_BIO_NOT_SET				 128
#define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG			 129
#define SSL_R_BN_LIB					 130
#define SSL_R_CA_DN_LENGTH_MISMATCH			 131
#define SSL_R_CA_DN_TOO_LONG				 132
#define SSL_R_CCS_RECEIVED_EARLY			 133
#define SSL_R_CERTIFICATE_VERIFY_FAILED			 134
#define SSL_R_CERT_LENGTH_MISMATCH			 135
#define SSL_R_CHALLENGE_IS_DIFFERENT			 136
#define SSL_R_CIPHER_CODE_WRONG_LENGTH			 137
#define SSL_R_CIPHER_COMPRESSION_UNAVAILABLE		 371
#define SSL_R_CIPHER_OR_HASH_UNAVAILABLE		 138
#define SSL_R_CIPHER_TABLE_SRC_ERROR			 139
#define SSL_R_CLIENTHELLO_TLSEXT			 226
#define SSL_R_COMPRESSED_LENGTH_TOO_LONG		 140
#define SSL_R_COMPRESSION_DISABLED			 343
#define SSL_R_COMPRESSION_FAILURE			 141
#define SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE	 307
#define SSL_R_COMPRESSION_LIBRARY_ERROR			 142
#define SSL_R_CONNECTION_ID_IS_DIFFERENT		 143
#define SSL_R_CONNECTION_TYPE_NOT_SET			 144
#define SSL_R_COOKIE_MISMATCH				 308
#define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED		 145
#define SSL_R_DATA_LENGTH_TOO_LONG			 146
#define SSL_R_DECRYPTION_FAILED				 147
#define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC	 281
#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG		 148
#define SSL_R_DIGEST_CHECK_FAILED			 149
#define SSL_R_DTLS_MESSAGE_TOO_BIG			 334
#define SSL_R_DUPLICATE_COMPRESSION_ID			 309
#define SSL_R_ECC_CERT_NOT_FOR_KEY_AGREEMENT		 317
#define SSL_R_ECC_CERT_NOT_FOR_SIGNING			 318
#define SSL_R_ECC_CERT_SHOULD_HAVE_RSA_SIGNATURE	 322
#define SSL_R_ECC_CERT_SHOULD_HAVE_SHA1_SIGNATURE	 323
#define SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER		 310
#define SSL_R_EMPTY_SRTP_PROTECTION_PROFILE_LIST	 354
#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG			 150
#define SSL_R_ERROR_GENERATING_TMP_RSA_KEY		 282
#define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST		 151
#define SSL_R_EXCESSIVE_MESSAGE_SIZE			 152
#define SSL_R_EXTRA_DATA_IN_MESSAGE			 153
#define SSL_R_GOT_A_FIN_BEFORE_A_CCS			 154
#define SSL_R_GOT_NEXT_PROTO_BEFORE_A_CCS		 355
#define SSL_R_GOT_NEXT_PROTO_WITHOUT_EXTENSION		 356
#define SSL_R_HTTPS_PROXY_REQUEST			 155
#define SSL_R_HTTP_REQUEST				 156
#define SSL_R_ILLEGAL_PADDING				 283
#define SSL_R_INCONSISTENT_COMPRESSION			 340
#define SSL_R_INVALID_CHALLENGE_LENGTH			 158
#define SSL_R_INVALID_COMMAND				 280
#define SSL_R_INVALID_COMPRESSION_ALGORITHM		 341
#define SSL_R_INVALID_PURPOSE				 278
#define SSL_R_INVALID_SRP_USERNAME			 357
#define SSL_R_INVALID_STATUS_RESPONSE			 328
#define SSL_R_INVALID_TICKET_KEYS_LENGTH		 325
#define SSL_R_INVALID_TRUST				 279
#define SSL_R_KEY_ARG_TOO_LONG				 284
#define SSL_R_KRB5					 285
#define SSL_R_KRB5_C_CC_PRINC				 286
#define SSL_R_KRB5_C_GET_CRED				 287
#define SSL_R_KRB5_C_INIT				 288
#define SSL_R_KRB5_C_MK_REQ				 289
#define SSL_R_KRB5_S_BAD_TICKET				 290
#define SSL_R_KRB5_S_INIT				 291
#define SSL_R_KRB5_S_RD_REQ				 292
#define SSL_R_KRB5_S_TKT_EXPIRED			 293
#define SSL_R_KRB5_S_TKT_NYV				 294
#define SSL_R_KRB5_S_TKT_SKEW				 295
#define SSL_R_LENGTH_MISMATCH				 159
#define SSL_R_LENGTH_TOO_SHORT				 160
#define SSL_R_LIBRARY_BUG				 274
#define SSL_R_LIBRARY_HAS_NO_CIPHERS			 161
#define SSL_R_MESSAGE_TOO_LONG				 296
#define SSL_R_MISSING_DH_DSA_CERT			 162
#define SSL_R_MISSING_DH_KEY				 163
#define SSL_R_MISSING_DH_RSA_CERT			 164
#define SSL_R_MISSING_DSA_SIGNING_CERT			 165
#define SSL_R_MISSING_EXPORT_TMP_DH_KEY			 166
#define SSL_R_MISSING_EXPORT_TMP_RSA_KEY		 167
#define SSL_R_MISSING_RSA_CERTIFICATE			 168
#define SSL_R_MISSING_RSA_ENCRYPTING_CERT		 169
#define SSL_R_MISSING_RSA_SIGNING_CERT			 170
#define SSL_R_MISSING_SRP_PARAM				 358
#define SSL_R_MISSING_TMP_DH_KEY			 171
#define SSL_R_MISSING_TMP_ECDH_KEY			 311
#define SSL_R_MISSING_TMP_RSA_KEY			 172
#define SSL_R_MISSING_TMP_RSA_PKEY			 173
#define SSL_R_MISSING_VERIFY_MESSAGE			 174
#define SSL_R_MULTIPLE_SGC_RESTARTS			 346
#define SSL_R_NON_SSLV2_INITIAL_PACKET			 175
#define SSL_R_NO_CERTIFICATES_RETURNED			 176
#define SSL_R_NO_CERTIFICATE_ASSIGNED			 177
#define SSL_R_NO_CERTIFICATE_RETURNED			 178
#define SSL_R_NO_CERTIFICATE_SET			 179
#define SSL_R_NO_CERTIFICATE_SPECIFIED			 180
#define SSL_R_NO_CIPHERS_AVAILABLE			 181
#define SSL_R_NO_CIPHERS_PASSED				 182
#define SSL_R_NO_CIPHERS_SPECIFIED			 183
#define SSL_R_NO_CIPHER_LIST				 184
#define SSL_R_NO_CIPHER_MATCH				 185
#define SSL_R_NO_CLIENT_CERT_METHOD			 331
#define SSL_R_NO_CLIENT_CERT_RECEIVED			 186
#define SSL_R_NO_COMPRESSION_SPECIFIED			 187
#define SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER		 330
#define SSL_R_NO_METHOD_SPECIFIED			 188
#define SSL_R_NO_PRIVATEKEY				 189
#define SSL_R_NO_PRIVATE_KEY_ASSIGNED			 190
#define SSL_R_NO_PROTOCOLS_AVAILABLE			 191
#define SSL_R_NO_PUBLICKEY				 192
#define SSL_R_NO_RENEGOTIATION				 339
#define SSL_R_NO_REQUIRED_DIGEST			 324
#define SSL_R_NO_SHARED_CIPHER				 193
#define SSL_R_NO_SRTP_PROFILES				 359
#define SSL_R_NO_VERIFY_CALLBACK			 194
#define SSL_R_NULL_SSL_CTX				 195
#define SSL_R_NULL_SSL_METHOD_PASSED			 196
#define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED		 197
#define SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED 344
#define SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE		 297
#define SSL_R_PACKET_LENGTH_TOO_LONG			 198
#define SSL_R_PARSE_TLSEXT				 227
#define SSL_R_PATH_TOO_LONG				 270
#define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE		 199
#define SSL_R_PEER_ERROR				 200
#define SSL_R_PEER_ERROR_CERTIFICATE			 201
#define SSL_R_PEER_ERROR_NO_CERTIFICATE			 202
#define SSL_R_PEER_ERROR_NO_CIPHER			 203
#define SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE	 204
#define SSL_R_PRE_MAC_LENGTH_TOO_LONG			 205
#define SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS		 206
#define SSL_R_PROTOCOL_IS_SHUTDOWN			 207
#define SSL_R_PSK_IDENTITY_NOT_FOUND			 223
#define SSL_R_PSK_NO_CLIENT_CB				 224
#define SSL_R_PSK_NO_SERVER_CB				 225
#define SSL_R_PUBLIC_KEY_ENCRYPT_ERROR			 208
#define SSL_R_PUBLIC_KEY_IS_NOT_RSA			 209
#define SSL_R_PUBLIC_KEY_NOT_RSA			 210
#define SSL_R_READ_BIO_NOT_SET				 211
#define SSL_R_READ_TIMEOUT_EXPIRED			 312
#define SSL_R_READ_WRONG_PACKET_TYPE			 212
#define SSL_R_RECORD_LENGTH_MISMATCH			 213
#define SSL_R_RECORD_TOO_LARGE				 214
#define SSL_R_RECORD_TOO_SMALL				 298
#define SSL_R_RENEGOTIATE_EXT_TOO_LONG			 335
#define SSL_R_RENEGOTIATION_ENCODING_ERR		 336
#define SSL_R_RENEGOTIATION_MISMATCH			 337
#define SSL_R_REQUIRED_CIPHER_MISSING			 215
#define SSL_R_REQUIRED_COMPRESSSION_ALGORITHM_MISSING	 342
#define SSL_R_REUSE_CERT_LENGTH_NOT_ZERO		 216
#define SSL_R_REUSE_CERT_TYPE_NOT_ZERO			 217
#define SSL_R_REUSE_CIPHER_LIST_NOT_ZERO		 218
#define SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING		 345
#define SSL_R_SERVERHELLO_TLSEXT			 275
#define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED		 277
#define SSL_R_SHORT_READ				 219
#define SSL_R_SIGNATURE_ALGORITHMS_ERROR		 360
#define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE	 220
#define SSL_R_SRP_A_CALC				 361
#define SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES		 362
#define SSL_R_SRTP_PROTECTION_PROFILE_LIST_TOO_LONG	 363
#define SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE		 364
#define SSL_R_SSL23_DOING_SESSION_ID_REUSE		 221
#define SSL_R_SSL2_CONNECTION_ID_TOO_LONG		 299
#define SSL_R_SSL3_EXT_INVALID_ECPOINTFORMAT		 321
#define SSL_R_SSL3_EXT_INVALID_SERVERNAME		 319
#define SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE		 320
#define SSL_R_SSL3_SESSION_ID_TOO_LONG			 300
#define SSL_R_SSL3_SESSION_ID_TOO_SHORT			 222
#define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE		 1042
#define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC		 1020
#define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED		 1045
#define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED		 1044
#define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN		 1046
#define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE		 1030
#define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE		 1040
#define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER		 1047
#define SSL_R_SSLV3_ALERT_NO_CERTIFICATE		 1041
#define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE		 1010
#define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE	 1043
#define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION	 228
#define SSL_R_SSL_HANDSHAKE_FAILURE			 229
#define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS		 230
#define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED		 301
#define SSL_R_SSL_SESSION_ID_CONFLICT			 302
#define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG		 273
#define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH		 303
#define SSL_R_SSL_SESSION_ID_IS_DIFFERENT		 231
#define SSL_R_TLSV1_ALERT_ACCESS_DENIED			 1049
#define SSL_R_TLSV1_ALERT_DECODE_ERROR			 1050
#define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED		 1021
#define SSL_R_TLSV1_ALERT_DECRYPT_ERROR			 1051
#define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION		 1060
#define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY		 1071
#define SSL_R_TLSV1_ALERT_INTERNAL_ERROR		 1080
#define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION		 1100
#define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION		 1070
#define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW		 1022
#define SSL_R_TLSV1_ALERT_UNKNOWN_CA			 1048
#define SSL_R_TLSV1_ALERT_USER_CANCELLED		 1090
#define SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE		 1114
#define SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE	 1113
#define SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE		 1111
#define SSL_R_TLSV1_UNRECOGNIZED_NAME			 1112
#define SSL_R_TLSV1_UNSUPPORTED_EXTENSION		 1110
#define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER	 232
#define SSL_R_TLS_HEARTBEAT_PEER_DOESNT_ACCEPT		 365
#define SSL_R_TLS_HEARTBEAT_PENDING			 366
#define SSL_R_TLS_ILLEGAL_EXPORTER_LABEL		 367
#define SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST		 157
#define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 233
#define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG	 234
#define SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER		 235
#define SSL_R_UNABLE_TO_DECODE_DH_CERTS			 236
#define SSL_R_UNABLE_TO_DECODE_ECDH_CERTS		 313
#define SSL_R_UNABLE_TO_EXTRACT_PUBLIC_KEY		 237
#define SSL_R_UNABLE_TO_FIND_DH_PARAMETERS		 238
#define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS		 314
#define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS	 239
#define SSL_R_UNABLE_TO_FIND_SSL_METHOD			 240
#define SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES		 241
#define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES		 242
#define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES		 243
#define SSL_R_UNEXPECTED_MESSAGE			 244
#define SSL_R_UNEXPECTED_RECORD				 245
#define SSL_R_UNINITIALIZED				 276
#define SSL_R_UNKNOWN_ALERT_TYPE			 246
#define SSL_R_UNKNOWN_CERTIFICATE_TYPE			 247
#define SSL_R_UNKNOWN_CIPHER_RETURNED			 248
#define SSL_R_UNKNOWN_CIPHER_TYPE			 249
#define SSL_R_UNKNOWN_DIGEST				 368
#define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE			 250
#define SSL_R_UNKNOWN_PKEY_TYPE				 251
#define SSL_R_UNKNOWN_PROTOCOL				 252
#define SSL_R_UNKNOWN_REMOTE_ERROR_TYPE			 253
#define SSL_R_UNKNOWN_SSL_VERSION			 254
#define SSL_R_UNKNOWN_STATE				 255
#define SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED	 338
#define SSL_R_UNSUPPORTED_CIPHER			 256
#define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM		 257
#define SSL_R_UNSUPPORTED_DIGEST_TYPE			 326
#define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE		 315
#define SSL_R_UNSUPPORTED_PROTOCOL			 258
#define SSL_R_UNSUPPORTED_SSL_VERSION			 259
#define SSL_R_UNSUPPORTED_STATUS_TYPE			 329
#define SSL_R_USE_SRTP_NOT_NEGOTIATED			 369
#define SSL_R_WRITE_BIO_NOT_SET				 260
#define SSL_R_WRONG_CIPHER_RETURNED			 261
#define SSL_R_WRONG_MESSAGE_TYPE			 262
#define SSL_R_WRONG_NUMBER_OF_KEY_BITS			 263
#define SSL_R_WRONG_SIGNATURE_LENGTH			 264
#define SSL_R_WRONG_SIGNATURE_SIZE			 265
#define SSL_R_WRONG_SIGNATURE_TYPE			 370
#define SSL_R_WRONG_SSL_VERSION				 266
#define SSL_R_WRONG_VERSION_NUMBER			 267
#define SSL_R_X509_LIB					 268
#define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS		 269

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/blowfish.h0000644000175000017500000001104412360020705022027 0ustar  /* $OpenBSD: blowfish.h,v 1.13 2014/06/12 15:49:28 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_BLOWFISH_H
#define HEADER_BLOWFISH_H

#include 

#ifdef  __cplusplus
extern "C" {
#endif

#ifdef OPENSSL_NO_BF
#error BF is disabled.
#endif

#define BF_ENCRYPT	1
#define BF_DECRYPT	0

/*
 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 * ! BF_LONG has to be at least 32 bits wide. If it's wider, then !
 * ! BF_LONG_LOG2 has to be defined along.                        !
 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 */

#define BF_LONG unsigned int

#define BF_ROUNDS	16
#define BF_BLOCK	8

typedef struct bf_key_st
	{
	BF_LONG P[BF_ROUNDS+2];
	BF_LONG S[4*256];
	} BF_KEY;

void BF_set_key(BF_KEY *key, int len, const unsigned char *data);

void BF_encrypt(BF_LONG *data,const BF_KEY *key);
void BF_decrypt(BF_LONG *data,const BF_KEY *key);

void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
	const BF_KEY *key, int enc);
void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
	const BF_KEY *schedule, unsigned char *ivec, int enc);
void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length,
	const BF_KEY *schedule, unsigned char *ivec, int *num, int enc);
void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length,
	const BF_KEY *schedule, unsigned char *ivec, int *num);
const char *BF_options(void);

#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/ec.h0000644000175000017500000013235012360020705020605 0ustar  /* $OpenBSD$ */
/*
 * Originally written by Bodo Moeller for the OpenSSL project.
 */
/**
 * \file crypto/ec/ec.h Include file for the OpenSSL EC functions
 * \author Originally written by Bodo Moeller for the OpenSSL project
 */
/* ====================================================================
 * Copyright (c) 1998-2005 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */
/* ====================================================================
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 *
 * Portions of the attached software ("Contribution") are developed by 
 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
 *
 * The Contribution is licensed pursuant to the OpenSSL open source
 * license provided above.
 *
 * The elliptic curve binary polynomial software is originally written by 
 * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
 *
 */

#ifndef HEADER_EC_H
#define HEADER_EC_H

#include 

#ifdef OPENSSL_NO_EC
#error EC is disabled.
#endif

#include 
#ifndef OPENSSL_NO_DEPRECATED
#include 
#endif

#ifdef  __cplusplus
extern "C" {
#elif defined(__SUNPRO_C)
# if __SUNPRO_C >= 0x520
# pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
# endif
#endif

  
#ifndef OPENSSL_ECC_MAX_FIELD_BITS
# define OPENSSL_ECC_MAX_FIELD_BITS 661
#endif

/** Enum for the point conversion form as defined in X9.62 (ECDSA)
 *  for the encoding of a elliptic curve point (x,y) */
typedef enum {
	/** the point is encoded as z||x, where the octet z specifies 
	 *  which solution of the quadratic equation y is  */
	POINT_CONVERSION_COMPRESSED = 2,
	/** the point is encoded as z||x||y, where z is the octet 0x02  */
	POINT_CONVERSION_UNCOMPRESSED = 4,
	/** the point is encoded as z||x||y, where the octet z specifies
         *  which solution of the quadratic equation y is  */
	POINT_CONVERSION_HYBRID = 6
} point_conversion_form_t;


typedef struct ec_method_st EC_METHOD;

typedef struct ec_group_st
	/*
	 EC_METHOD *meth;
	 -- field definition
	 -- curve coefficients
	 -- optional generator with associated information (order, cofactor)
	 -- optional extra data (precomputed table for fast computation of multiples of generator)
	 -- ASN1 stuff
	*/
	EC_GROUP;

typedef struct ec_point_st EC_POINT;


/********************************************************************/
/*               EC_METHODs for curves over GF(p)                   */       
/********************************************************************/

/** Returns the basic GFp ec methods which provides the basis for the
 *  optimized methods. 
 *  \return  EC_METHOD object
 */
const EC_METHOD *EC_GFp_simple_method(void);

/** Returns GFp methods using montgomery multiplication.
 *  \return  EC_METHOD object
 */
const EC_METHOD *EC_GFp_mont_method(void);

/** Returns GFp methods using optimized methods for NIST recommended curves
 *  \return  EC_METHOD object
 */
const EC_METHOD *EC_GFp_nist_method(void);

#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
/** Returns 64-bit optimized methods for nistp224
 *  \return  EC_METHOD object
 */
const EC_METHOD *EC_GFp_nistp224_method(void);

/** Returns 64-bit optimized methods for nistp256
 *  \return  EC_METHOD object
 */
const EC_METHOD *EC_GFp_nistp256_method(void);

/** Returns 64-bit optimized methods for nistp521
 *  \return  EC_METHOD object
 */
const EC_METHOD *EC_GFp_nistp521_method(void);
#endif

#ifndef OPENSSL_NO_EC2M
/********************************************************************/ 
/*           EC_METHOD for curves over GF(2^m)                      */
/********************************************************************/

/** Returns the basic GF2m ec method 
 *  \return  EC_METHOD object
 */
const EC_METHOD *EC_GF2m_simple_method(void);

#endif


/********************************************************************/
/*                   EC_GROUP functions                             */
/********************************************************************/

/** Creates a new EC_GROUP object
 *  \param   meth  EC_METHOD to use
 *  \return  newly created EC_GROUP object or NULL in case of an error.
 */
EC_GROUP *EC_GROUP_new(const EC_METHOD *meth);

/** Frees a EC_GROUP object
 *  \param  group  EC_GROUP object to be freed.
 */
void EC_GROUP_free(EC_GROUP *group);

/** Clears and frees a EC_GROUP object
 *  \param  group  EC_GROUP object to be cleared and freed.
 */
void EC_GROUP_clear_free(EC_GROUP *group);

/** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.
 *  \param  dst  destination EC_GROUP object
 *  \param  src  source EC_GROUP object
 *  \return 1 on success and 0 if an error occurred.
 */
int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);

/** Creates a new EC_GROUP object and copies the copies the content
 *  form src to the newly created EC_KEY object
 *  \param  src  source EC_GROUP object
 *  \return newly created EC_GROUP object or NULL in case of an error.
 */
EC_GROUP *EC_GROUP_dup(const EC_GROUP *src);

/** Returns the EC_METHOD of the EC_GROUP object.
 *  \param  group  EC_GROUP object 
 *  \return EC_METHOD used in this EC_GROUP object.
 */
const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);

/** Returns the field type of the EC_METHOD.
 *  \param  meth  EC_METHOD object
 *  \return NID of the underlying field type OID.
 */
int EC_METHOD_get_field_type(const EC_METHOD *meth);

/** Sets the generator and it's order/cofactor of a EC_GROUP object.
 *  \param  group      EC_GROUP object 
 *  \param  generator  EC_POINT object with the generator.
 *  \param  order      the order of the group generated by the generator.
 *  \param  cofactor   the index of the sub-group generated by the generator
 *                     in the group of all points on the elliptic curve.
 *  \return 1 on success and 0 if an error occured
 */
int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor);

/** Returns the generator of a EC_GROUP object.
 *  \param  group  EC_GROUP object
 *  \return the currently used generator (possibly NULL).
 */
const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);

/** Gets the order of a EC_GROUP
 *  \param  group  EC_GROUP object
 *  \param  order  BIGNUM to which the order is copied
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);

/** Gets the cofactor of a EC_GROUP
 *  \param  group     EC_GROUP object
 *  \param  cofactor  BIGNUM to which the cofactor is copied
 *  \param  ctx       BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx);

/** Sets the name of a EC_GROUP object
 *  \param  group  EC_GROUP object
 *  \param  nid    NID of the curve name OID
 */
void EC_GROUP_set_curve_name(EC_GROUP *group, int nid);

/** Returns the curve name of a EC_GROUP object
 *  \param  group  EC_GROUP object
 *  \return NID of the curve name OID or 0 if not set.
 */
int EC_GROUP_get_curve_name(const EC_GROUP *group);

void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
int EC_GROUP_get_asn1_flag(const EC_GROUP *group);

void EC_GROUP_set_point_conversion_form(EC_GROUP *group, point_conversion_form_t form);
point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);

unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x);
size_t EC_GROUP_get_seed_len(const EC_GROUP *);
size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);

/** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b
 *  \param  group  EC_GROUP object
 *  \param  p      BIGNUM with the prime number
 *  \param  a      BIGNUM with parameter a of the equation
 *  \param  b      BIGNUM with parameter b of the equation
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);

/** Gets the parameter of the ec over GFp defined by y^2 = x^3 + a*x + b
 *  \param  group  EC_GROUP object
 *  \param  p      BIGNUM for the prime number
 *  \param  a      BIGNUM for parameter a of the equation
 *  \param  b      BIGNUM for parameter b of the equation
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);

#ifndef OPENSSL_NO_EC2M
/** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
 *  \param  group  EC_GROUP object
 *  \param  p      BIGNUM with the polynomial defining the underlying field
 *  \param  a      BIGNUM with parameter a of the equation
 *  \param  b      BIGNUM with parameter b of the equation
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);

/** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b
 *  \param  group  EC_GROUP object
 *  \param  p      BIGNUM for the polynomial defining the underlying field
 *  \param  a      BIGNUM for parameter a of the equation
 *  \param  b      BIGNUM for parameter b of the equation
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
#endif
/** Returns the number of bits needed to represent a field element 
 *  \param  group  EC_GROUP object
 *  \return number of bits needed to represent a field element
 */
int EC_GROUP_get_degree(const EC_GROUP *group);

/** Checks whether the parameter in the EC_GROUP define a valid ec group
 *  \param  group  EC_GROUP object
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 if group is a valid ec group and 0 otherwise
 */
int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);

/** Checks whether the discriminant of the elliptic curve is zero or not
 *  \param  group  EC_GROUP object
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 if the discriminant is not zero and 0 otherwise
 */
int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);

/** Compares two EC_GROUP objects
 *  \param  a    first EC_GROUP object
 *  \param  b    second EC_GROUP object
 *  \param  ctx  BN_CTX object (optional)
 *  \return 0 if both groups are equal and 1 otherwise
 */
int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);

/* EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*()
 * after choosing an appropriate EC_METHOD */

/** Creates a new EC_GROUP object with the specified parameters defined
 *  over GFp (defined by the equation y^2 = x^3 + a*x + b)
 *  \param  p    BIGNUM with the prime number
 *  \param  a    BIGNUM with the parameter a of the equation
 *  \param  b    BIGNUM with the parameter b of the equation
 *  \param  ctx  BN_CTX object (optional)
 *  \return newly created EC_GROUP object with the specified parameters
 */
EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
#ifndef OPENSSL_NO_EC2M
/** Creates a new EC_GROUP object with the specified parameters defined
 *  over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)
 *  \param  p    BIGNUM with the polynomial defining the underlying field
 *  \param  a    BIGNUM with the parameter a of the equation
 *  \param  b    BIGNUM with the parameter b of the equation
 *  \param  ctx  BN_CTX object (optional)
 *  \return newly created EC_GROUP object with the specified parameters
 */
EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
#endif
/** Creates a EC_GROUP object with a curve specified by a NID
 *  \param  nid  NID of the OID of the curve name
 *  \return newly created EC_GROUP object with specified curve or NULL
 *          if an error occurred
 */
EC_GROUP *EC_GROUP_new_by_curve_name(int nid);


/********************************************************************/
/*               handling of internal curves                        */
/********************************************************************/

typedef struct { 
	int nid;
	const char *comment;
	} EC_builtin_curve;

/* EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number 
 * of all available curves or zero if a error occurred. 
 * In case r ist not zero nitems EC_builtin_curve structures 
 * are filled with the data of the first nitems internal groups */
size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);


/********************************************************************/
/*                    EC_POINT functions                            */
/********************************************************************/

/** Creates a new EC_POINT object for the specified EC_GROUP
 *  \param  group  EC_GROUP the underlying EC_GROUP object
 *  \return newly created EC_POINT object or NULL if an error occurred
 */
EC_POINT *EC_POINT_new(const EC_GROUP *group);

/** Frees a EC_POINT object
 *  \param  point  EC_POINT object to be freed
 */
void EC_POINT_free(EC_POINT *point);

/** Clears and frees a EC_POINT object
 *  \param  point  EC_POINT object to be cleared and freed
 */
void EC_POINT_clear_free(EC_POINT *point);

/** Copies EC_POINT object
 *  \param  dst  destination EC_POINT object
 *  \param  src  source EC_POINT object
 *  \return 1 on success and 0 if an error occured
 */
int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);

/** Creates a new EC_POINT object and copies the content of the supplied
 *  EC_POINT
 *  \param  src    source EC_POINT object
 *  \param  group  underlying the EC_GROUP object
 *  \return newly created EC_POINT object or NULL if an error occurred 
 */
EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);
 
/** Returns the EC_METHOD used in EC_POINT object 
 *  \param  point  EC_POINT object
 *  \return the EC_METHOD used
 */
const EC_METHOD *EC_POINT_method_of(const EC_POINT *point);

/** Sets a point to infinity (neutral element)
 *  \param  group  underlying EC_GROUP object
 *  \param  point  EC_POINT to set to infinity
 *  \return 1 on success and 0 if an error occured
 */
int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);

/** Sets the jacobian projective coordinates of a EC_POINT over GFp
 *  \param  group  underlying EC_GROUP object
 *  \param  p      EC_POINT object
 *  \param  x      BIGNUM with the x-coordinate
 *  \param  y      BIGNUM with the y-coordinate
 *  \param  z      BIGNUM with the z-coordinate
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
	const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx);

/** Gets the jacobian projective coordinates of a EC_POINT over GFp
 *  \param  group  underlying EC_GROUP object
 *  \param  p      EC_POINT object
 *  \param  x      BIGNUM for the x-coordinate
 *  \param  y      BIGNUM for the y-coordinate
 *  \param  z      BIGNUM for the z-coordinate
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
	const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx);

/** Sets the affine coordinates of a EC_POINT over GFp
 *  \param  group  underlying EC_GROUP object
 *  \param  p      EC_POINT object
 *  \param  x      BIGNUM with the x-coordinate
 *  \param  y      BIGNUM with the y-coordinate
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
	const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);

/** Gets the affine coordinates of a EC_POINT over GFp
 *  \param  group  underlying EC_GROUP object
 *  \param  p      EC_POINT object
 *  \param  x      BIGNUM for the x-coordinate
 *  \param  y      BIGNUM for the y-coordinate
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
	const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);

/** Sets the x9.62 compressed coordinates of a EC_POINT over GFp
 *  \param  group  underlying EC_GROUP object
 *  \param  p      EC_POINT object
 *  \param  x      BIGNUM with x-coordinate
 *  \param  y_bit  integer with the y-Bit (either 0 or 1)
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
	const BIGNUM *x, int y_bit, BN_CTX *ctx);
#ifndef OPENSSL_NO_EC2M
/** Sets the affine coordinates of a EC_POINT over GF2m
 *  \param  group  underlying EC_GROUP object
 *  \param  p      EC_POINT object
 *  \param  x      BIGNUM with the x-coordinate
 *  \param  y      BIGNUM with the y-coordinate
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
	const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);

/** Gets the affine coordinates of a EC_POINT over GF2m
 *  \param  group  underlying EC_GROUP object
 *  \param  p      EC_POINT object
 *  \param  x      BIGNUM for the x-coordinate
 *  \param  y      BIGNUM for the y-coordinate
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
	const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);

/** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m
 *  \param  group  underlying EC_GROUP object
 *  \param  p      EC_POINT object
 *  \param  x      BIGNUM with x-coordinate
 *  \param  y_bit  integer with the y-Bit (either 0 or 1)
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
	const BIGNUM *x, int y_bit, BN_CTX *ctx);
#endif
/** Encodes a EC_POINT object to a octet string
 *  \param  group  underlying EC_GROUP object
 *  \param  p      EC_POINT object
 *  \param  form   point conversion form
 *  \param  buf    memory buffer for the result. If NULL the function returns
 *                 required buffer size.
 *  \param  len    length of the memory buffer
 *  \param  ctx    BN_CTX object (optional)
 *  \return the length of the encoded octet string or 0 if an error occurred
 */
size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,
	point_conversion_form_t form,
        unsigned char *buf, size_t len, BN_CTX *ctx);

/** Decodes a EC_POINT from a octet string
 *  \param  group  underlying EC_GROUP object
 *  \param  p      EC_POINT object
 *  \param  buf    memory buffer with the encoded ec point
 *  \param  len    length of the encoded ec point
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,
        const unsigned char *buf, size_t len, BN_CTX *ctx);

/* other interfaces to point2oct/oct2point: */
BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,
	point_conversion_form_t form, BIGNUM *, BN_CTX *);
EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,
	EC_POINT *, BN_CTX *);
char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,
	point_conversion_form_t form, BN_CTX *);
EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,
	EC_POINT *, BN_CTX *);


/********************************************************************/
/*         functions for doing EC_POINT arithmetic                  */
/********************************************************************/

/** Computes the sum of two EC_POINT 
 *  \param  group  underlying EC_GROUP object
 *  \param  r      EC_POINT object for the result (r = a + b)
 *  \param  a      EC_POINT object with the first summand
 *  \param  b      EC_POINT object with the second summand
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);

/** Computes the double of a EC_POINT
 *  \param  group  underlying EC_GROUP object
 *  \param  r      EC_POINT object for the result (r = 2 * a)
 *  \param  a      EC_POINT object 
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx);

/** Computes the inverse of a EC_POINT
 *  \param  group  underlying EC_GROUP object
 *  \param  a      EC_POINT object to be inverted (it's used for the result as well)
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);

/** Checks whether the point is the neutral element of the group
 *  \param  group  the underlying EC_GROUP object
 *  \param  p      EC_POINT object
 *  \return 1 if the point is the neutral element and 0 otherwise
 */
int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);

/** Checks whether the point is on the curve 
 *  \param  group  underlying EC_GROUP object
 *  \param  point  EC_POINT object to check
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 if point if on the curve and 0 otherwise
 */
int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx);

/** Compares two EC_POINTs 
 *  \param  group  underlying EC_GROUP object
 *  \param  a      first EC_POINT object
 *  \param  b      second EC_POINT object
 *  \param  ctx    BN_CTX object (optional)
 *  \return 0 if both points are equal and a value != 0 otherwise
 */
int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);

int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx);
int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx);

/** Computes r = generator * n sum_{i=0}^num p[i] * m[i]
 *  \param  group  underlying EC_GROUP object
 *  \param  r      EC_POINT object for the result
 *  \param  n      BIGNUM with the multiplier for the group generator (optional)
 *  \param  num    number futher summands
 *  \param  p      array of size num of EC_POINT objects
 *  \param  m      array of size num of BIGNUM objects
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, size_t num, const EC_POINT *p[], const BIGNUM *m[], BN_CTX *ctx);

/** Computes r = generator * n + q * m
 *  \param  group  underlying EC_GROUP object
 *  \param  r      EC_POINT object for the result
 *  \param  n      BIGNUM with the multiplier for the group generator (optional)
 *  \param  q      EC_POINT object with the first factor of the second summand
 *  \param  m      BIGNUM with the second factor of the second summand
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);

/** Stores multiples of generator for faster point multiplication
 *  \param  group  EC_GROUP object
 *  \param  ctx    BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occured
 */
int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);

/** Reports whether a precomputation has been done
 *  \param  group  EC_GROUP object
 *  \return 1 if a pre-computation has been done and 0 otherwise
 */
int EC_GROUP_have_precompute_mult(const EC_GROUP *group);


/********************************************************************/
/*                       ASN1 stuff                                 */
/********************************************************************/

/* EC_GROUP_get_basis_type() returns the NID of the basis type
 * used to represent the field elements */
int EC_GROUP_get_basis_type(const EC_GROUP *);
#ifndef OPENSSL_NO_EC2M
int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);
int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, 
	unsigned int *k2, unsigned int *k3);
#endif

#define OPENSSL_EC_NAMED_CURVE	0x001

typedef struct ecpk_parameters_st ECPKPARAMETERS;

EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);
int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);

#define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)
#define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)
#define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \
                (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))
#define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \
		(unsigned char *)(x))

#ifndef OPENSSL_NO_BIO
int     ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);
#endif
int     ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);


/********************************************************************/
/*                      EC_KEY functions                            */
/********************************************************************/

typedef struct ec_key_st EC_KEY;

/* some values for the encoding_flag */
#define EC_PKEY_NO_PARAMETERS	0x001
#define EC_PKEY_NO_PUBKEY	0x002

/* some values for the flags field */
#define EC_FLAG_NON_FIPS_ALLOW	0x1
#define EC_FLAG_FIPS_CHECKED	0x2

/** Creates a new EC_KEY object.
 *  \return EC_KEY object or NULL if an error occurred.
 */
EC_KEY *EC_KEY_new(void);

int EC_KEY_get_flags(const EC_KEY *key);

void EC_KEY_set_flags(EC_KEY *key, int flags);

void EC_KEY_clear_flags(EC_KEY *key, int flags);

/** Creates a new EC_KEY object using a named curve as underlying
 *  EC_GROUP object.
 *  \param  nid  NID of the named curve.
 *  \return EC_KEY object or NULL if an error occurred. 
 */
EC_KEY *EC_KEY_new_by_curve_name(int nid);

/** Frees a EC_KEY object.
 *  \param  key  EC_KEY object to be freed.
 */
void EC_KEY_free(EC_KEY *key);

/** Copies a EC_KEY object.
 *  \param  dst  destination EC_KEY object
 *  \param  src  src EC_KEY object
 *  \return dst or NULL if an error occurred.
 */
EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);

/** Creates a new EC_KEY object and copies the content from src to it.
 *  \param  src  the source EC_KEY object
 *  \return newly created EC_KEY object or NULL if an error occurred.
 */
EC_KEY *EC_KEY_dup(const EC_KEY *src);

/** Increases the internal reference count of a EC_KEY object.
 *  \param  key  EC_KEY object
 *  \return 1 on success and 0 if an error occurred.
 */
int EC_KEY_up_ref(EC_KEY *key);

/** Returns the EC_GROUP object of a EC_KEY object
 *  \param  key  EC_KEY object
 *  \return the EC_GROUP object (possibly NULL).
 */
const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);

/** Sets the EC_GROUP of a EC_KEY object.
 *  \param  key    EC_KEY object
 *  \param  group  EC_GROUP to use in the EC_KEY object (note: the EC_KEY
 *                 object will use an own copy of the EC_GROUP).
 *  \return 1 on success and 0 if an error occurred.
 */
int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);

/** Returns the private key of a EC_KEY object.
 *  \param  key  EC_KEY object
 *  \return a BIGNUM with the private key (possibly NULL).
 */
const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);

/** Sets the private key of a EC_KEY object.
 *  \param  key  EC_KEY object
 *  \param  prv  BIGNUM with the private key (note: the EC_KEY object
 *               will use an own copy of the BIGNUM).
 *  \return 1 on success and 0 if an error occurred.
 */
int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);

/** Returns the public key of a EC_KEY object.
 *  \param  key  the EC_KEY object
 *  \return a EC_POINT object with the public key (possibly NULL)
 */
const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);

/** Sets the public key of a EC_KEY object.
 *  \param  key  EC_KEY object
 *  \param  pub  EC_POINT object with the public key (note: the EC_KEY object
 *               will use an own copy of the EC_POINT object).
 *  \return 1 on success and 0 if an error occurred.
 */
int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);

unsigned EC_KEY_get_enc_flags(const EC_KEY *key);
void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags);
point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key);
void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform);
/* functions to set/get method specific data  */
void *EC_KEY_get_key_method_data(EC_KEY *key, 
	void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
/** Sets the key method data of an EC_KEY object, if none has yet been set.
 *  \param  key              EC_KEY object
 *  \param  data             opaque data to install.
 *  \param  dup_func         a function that duplicates |data|.
 *  \param  free_func        a function that frees |data|.
 *  \param  clear_free_func  a function that wipes and frees |data|.
 *  \return the previously set data pointer, or NULL if |data| was inserted.
 */
void *EC_KEY_insert_key_method_data(EC_KEY *key, void *data,
	void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
/* wrapper functions for the underlying EC_GROUP object */
void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);

/** Creates a table of pre-computed multiples of the generator to 
 *  accelerate further EC_KEY operations.
 *  \param  key  EC_KEY object
 *  \param  ctx  BN_CTX object (optional)
 *  \return 1 on success and 0 if an error occurred.
 */
int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);

/** Creates a new ec private (and optional a new public) key.
 *  \param  key  EC_KEY object
 *  \return 1 on success and 0 if an error occurred.
 */
int EC_KEY_generate_key(EC_KEY *key);

/** Verifies that a private and/or public key is valid.
 *  \param  key  the EC_KEY object
 *  \return 1 on success and 0 otherwise.
 */
int EC_KEY_check_key(const EC_KEY *key);

/** Sets a public key from affine coordindates performing
 *  neccessary NIST PKV tests.
 *  \param  key  the EC_KEY object
 *  \param  x    public key x coordinate
 *  \param  y    public key y coordinate
 *  \return 1 on success and 0 otherwise.
 */
int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y);


/********************************************************************/
/*        de- and encoding functions for SEC1 ECPrivateKey          */
/********************************************************************/

/** Decodes a private key from a memory buffer.
 *  \param  key  a pointer to a EC_KEY object which should be used (or NULL)
 *  \param  in   pointer to memory with the DER encoded private key
 *  \param  len  length of the DER encoded private key
 *  \return the decoded private key or NULL if an error occurred.
 */
EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);

/** Encodes a private key object and stores the result in a buffer.
 *  \param  key  the EC_KEY object to encode
 *  \param  out  the buffer for the result (if NULL the function returns number
 *               of bytes needed).
 *  \return 1 on success and 0 if an error occurred.
 */
int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);


/********************************************************************/
/*        de- and encoding functions for EC parameters              */
/********************************************************************/

/** Decodes ec parameter from a memory buffer.
 *  \param  key  a pointer to a EC_KEY object which should be used (or NULL)
 *  \param  in   pointer to memory with the DER encoded ec parameters
 *  \param  len  length of the DER encoded ec parameters
 *  \return a EC_KEY object with the decoded parameters or NULL if an error
 *          occurred.
 */
EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);

/** Encodes ec parameter and stores the result in a buffer.
 *  \param  key  the EC_KEY object with ec paramters to encode
 *  \param  out  the buffer for the result (if NULL the function returns number
 *               of bytes needed).
 *  \return 1 on success and 0 if an error occurred.
 */
int i2d_ECParameters(EC_KEY *key, unsigned char **out);


/********************************************************************/
/*         de- and encoding functions for EC public key             */
/*         (octet string, not DER -- hence 'o2i' and 'i2o')         */
/********************************************************************/

/** Decodes a ec public key from a octet string.
 *  \param  key  a pointer to a EC_KEY object which should be used
 *  \param  in   memory buffer with the encoded public key
 *  \param  len  length of the encoded public key
 *  \return EC_KEY object with decoded public key or NULL if an error
 *          occurred.
 */
EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);

/** Encodes a ec public key in an octet string.
 *  \param  key  the EC_KEY object with the public key
 *  \param  out  the buffer for the result (if NULL the function returns number
 *               of bytes needed).
 *  \return 1 on success and 0 if an error occurred
 */
int i2o_ECPublicKey(EC_KEY *key, unsigned char **out);

#ifndef OPENSSL_NO_BIO
/** Prints out the ec parameters on human readable form.
 *  \param  bp   BIO object to which the information is printed
 *  \param  key  EC_KEY object
 *  \return 1 on success and 0 if an error occurred
 */
int	ECParameters_print(BIO *bp, const EC_KEY *key);

/** Prints out the contents of a EC_KEY object
 *  \param  bp   BIO object to which the information is printed
 *  \param  key  EC_KEY object
 *  \param  off  line offset 
 *  \return 1 on success and 0 if an error occurred
 */
int	EC_KEY_print(BIO *bp, const EC_KEY *key, int off);

#endif
/** Prints out the ec parameters on human readable form.
 *  \param  fp   file descriptor to which the information is printed
 *  \param  key  EC_KEY object
 *  \return 1 on success and 0 if an error occurred
 */
int	ECParameters_print_fp(FILE *fp, const EC_KEY *key);

/** Prints out the contents of a EC_KEY object
 *  \param  fp   file descriptor to which the information is printed
 *  \param  key  EC_KEY object
 *  \param  off  line offset 
 *  \return 1 on success and 0 if an error occurred
 */
int	EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);


#define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)

#ifndef __cplusplus
#if defined(__SUNPRO_C)
#  if __SUNPRO_C >= 0x520
# pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)
#  endif
# endif
#endif

#define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \
	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \
				EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)


#define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID		(EVP_PKEY_ALG_CTRL + 1)

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_EC_strings(void);

/* Error codes for the EC functions. */

/* Function codes. */
#define EC_F_BN_TO_FELEM				 224
#define EC_F_COMPUTE_WNAF				 143
#define EC_F_D2I_ECPARAMETERS				 144
#define EC_F_D2I_ECPKPARAMETERS				 145
#define EC_F_D2I_ECPRIVATEKEY				 146
#define EC_F_DO_EC_KEY_PRINT				 221
#define EC_F_ECKEY_PARAM2TYPE				 223
#define EC_F_ECKEY_PARAM_DECODE				 212
#define EC_F_ECKEY_PRIV_DECODE				 213
#define EC_F_ECKEY_PRIV_ENCODE				 214
#define EC_F_ECKEY_PUB_DECODE				 215
#define EC_F_ECKEY_PUB_ENCODE				 216
#define EC_F_ECKEY_TYPE2PARAM				 220
#define EC_F_ECPARAMETERS_PRINT				 147
#define EC_F_ECPARAMETERS_PRINT_FP			 148
#define EC_F_ECPKPARAMETERS_PRINT			 149
#define EC_F_ECPKPARAMETERS_PRINT_FP			 150
#define EC_F_ECP_NIST_MOD_192				 203
#define EC_F_ECP_NIST_MOD_224				 204
#define EC_F_ECP_NIST_MOD_256				 205
#define EC_F_ECP_NIST_MOD_521				 206
#define EC_F_EC_ASN1_GROUP2CURVE			 153
#define EC_F_EC_ASN1_GROUP2FIELDID			 154
#define EC_F_EC_ASN1_GROUP2PARAMETERS			 155
#define EC_F_EC_ASN1_GROUP2PKPARAMETERS			 156
#define EC_F_EC_ASN1_PARAMETERS2GROUP			 157
#define EC_F_EC_ASN1_PKPARAMETERS2GROUP			 158
#define EC_F_EC_EX_DATA_SET_DATA			 211
#define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY		 208
#define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT	 159
#define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE		 195
#define EC_F_EC_GF2M_SIMPLE_OCT2POINT			 160
#define EC_F_EC_GF2M_SIMPLE_POINT2OCT			 161
#define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162
#define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163
#define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES	 164
#define EC_F_EC_GFP_MONT_FIELD_DECODE			 133
#define EC_F_EC_GFP_MONT_FIELD_ENCODE			 134
#define EC_F_EC_GFP_MONT_FIELD_MUL			 131
#define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE		 209
#define EC_F_EC_GFP_MONT_FIELD_SQR			 132
#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE		 189
#define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP		 135
#define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE		 225
#define EC_F_EC_GFP_NISTP224_POINTS_MUL			 228
#define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226
#define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE		 230
#define EC_F_EC_GFP_NISTP256_POINTS_MUL			 231
#define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232
#define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE		 233
#define EC_F_EC_GFP_NISTP521_POINTS_MUL			 234
#define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235
#define EC_F_EC_GFP_NIST_FIELD_MUL			 200
#define EC_F_EC_GFP_NIST_FIELD_SQR			 201
#define EC_F_EC_GFP_NIST_GROUP_SET_CURVE		 202
#define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT	 165
#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE		 166
#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP		 100
#define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR		 101
#define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE			 102
#define EC_F_EC_GFP_SIMPLE_OCT2POINT			 103
#define EC_F_EC_GFP_SIMPLE_POINT2OCT			 104
#define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE		 137
#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES	 167
#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105
#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES	 168
#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128
#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES	 169
#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129
#define EC_F_EC_GROUP_CHECK				 170
#define EC_F_EC_GROUP_CHECK_DISCRIMINANT		 171
#define EC_F_EC_GROUP_COPY				 106
#define EC_F_EC_GROUP_GET0_GENERATOR			 139
#define EC_F_EC_GROUP_GET_COFACTOR			 140
#define EC_F_EC_GROUP_GET_CURVE_GF2M			 172
#define EC_F_EC_GROUP_GET_CURVE_GFP			 130
#define EC_F_EC_GROUP_GET_DEGREE			 173
#define EC_F_EC_GROUP_GET_ORDER				 141
#define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS		 193
#define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS		 194
#define EC_F_EC_GROUP_NEW				 108
#define EC_F_EC_GROUP_NEW_BY_CURVE_NAME			 174
#define EC_F_EC_GROUP_NEW_FROM_DATA			 175
#define EC_F_EC_GROUP_PRECOMPUTE_MULT			 142
#define EC_F_EC_GROUP_SET_CURVE_GF2M			 176
#define EC_F_EC_GROUP_SET_CURVE_GFP			 109
#define EC_F_EC_GROUP_SET_EXTRA_DATA			 110
#define EC_F_EC_GROUP_SET_GENERATOR			 111
#define EC_F_EC_KEY_CHECK_KEY				 177
#define EC_F_EC_KEY_COPY				 178
#define EC_F_EC_KEY_GENERATE_KEY			 179
#define EC_F_EC_KEY_NEW					 182
#define EC_F_EC_KEY_PRINT				 180
#define EC_F_EC_KEY_PRINT_FP				 181
#define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES	 229
#define EC_F_EC_POINTS_MAKE_AFFINE			 136
#define EC_F_EC_POINT_ADD				 112
#define EC_F_EC_POINT_CMP				 113
#define EC_F_EC_POINT_COPY				 114
#define EC_F_EC_POINT_DBL				 115
#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M	 183
#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP	 116
#define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP	 117
#define EC_F_EC_POINT_INVERT				 210
#define EC_F_EC_POINT_IS_AT_INFINITY			 118
#define EC_F_EC_POINT_IS_ON_CURVE			 119
#define EC_F_EC_POINT_MAKE_AFFINE			 120
#define EC_F_EC_POINT_MUL				 184
#define EC_F_EC_POINT_NEW				 121
#define EC_F_EC_POINT_OCT2POINT				 122
#define EC_F_EC_POINT_POINT2OCT				 123
#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M	 185
#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP	 124
#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M	 186
#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP	 125
#define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP	 126
#define EC_F_EC_POINT_SET_TO_INFINITY			 127
#define EC_F_EC_PRE_COMP_DUP				 207
#define EC_F_EC_PRE_COMP_NEW				 196
#define EC_F_EC_WNAF_MUL				 187
#define EC_F_EC_WNAF_PRECOMPUTE_MULT			 188
#define EC_F_I2D_ECPARAMETERS				 190
#define EC_F_I2D_ECPKPARAMETERS				 191
#define EC_F_I2D_ECPRIVATEKEY				 192
#define EC_F_I2O_ECPUBLICKEY				 151
#define EC_F_NISTP224_PRE_COMP_NEW			 227
#define EC_F_NISTP256_PRE_COMP_NEW			 236
#define EC_F_NISTP521_PRE_COMP_NEW			 237
#define EC_F_O2I_ECPUBLICKEY				 152
#define EC_F_OLD_EC_PRIV_DECODE				 222
#define EC_F_PKEY_EC_CTRL				 197
#define EC_F_PKEY_EC_CTRL_STR				 198
#define EC_F_PKEY_EC_DERIVE				 217
#define EC_F_PKEY_EC_KEYGEN				 199
#define EC_F_PKEY_EC_PARAMGEN				 219
#define EC_F_PKEY_EC_SIGN				 218

/* Reason codes. */
#define EC_R_ASN1_ERROR					 115
#define EC_R_ASN1_UNKNOWN_FIELD				 116
#define EC_R_BIGNUM_OUT_OF_RANGE			 144
#define EC_R_BUFFER_TOO_SMALL				 100
#define EC_R_COORDINATES_OUT_OF_RANGE			 146
#define EC_R_D2I_ECPKPARAMETERS_FAILURE			 117
#define EC_R_DECODE_ERROR				 142
#define EC_R_DISCRIMINANT_IS_ZERO			 118
#define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE		 119
#define EC_R_FIELD_TOO_LARGE				 143
#define EC_R_GF2M_NOT_SUPPORTED				 147
#define EC_R_GROUP2PKPARAMETERS_FAILURE			 120
#define EC_R_I2D_ECPKPARAMETERS_FAILURE			 121
#define EC_R_INCOMPATIBLE_OBJECTS			 101
#define EC_R_INVALID_ARGUMENT				 112
#define EC_R_INVALID_COMPRESSED_POINT			 110
#define EC_R_INVALID_COMPRESSION_BIT			 109
#define EC_R_INVALID_CURVE				 141
#define EC_R_INVALID_DIGEST_TYPE			 138
#define EC_R_INVALID_ENCODING				 102
#define EC_R_INVALID_FIELD				 103
#define EC_R_INVALID_FORM				 104
#define EC_R_INVALID_GROUP_ORDER			 122
#define EC_R_INVALID_PENTANOMIAL_BASIS			 132
#define EC_R_INVALID_PRIVATE_KEY			 123
#define EC_R_INVALID_TRINOMIAL_BASIS			 137
#define EC_R_KEYS_NOT_SET				 140
#define EC_R_MISSING_PARAMETERS				 124
#define EC_R_MISSING_PRIVATE_KEY			 125
#define EC_R_NOT_A_NIST_PRIME				 135
#define EC_R_NOT_A_SUPPORTED_NIST_PRIME			 136
#define EC_R_NOT_IMPLEMENTED				 126
#define EC_R_NOT_INITIALIZED				 111
#define EC_R_NO_FIELD_MOD				 133
#define EC_R_NO_PARAMETERS_SET				 139
#define EC_R_PASSED_NULL_PARAMETER			 134
#define EC_R_PKPARAMETERS2GROUP_FAILURE			 127
#define EC_R_POINT_AT_INFINITY				 106
#define EC_R_POINT_IS_NOT_ON_CURVE			 107
#define EC_R_SLOT_FULL					 108
#define EC_R_UNDEFINED_GENERATOR			 113
#define EC_R_UNDEFINED_ORDER				 128
#define EC_R_UNKNOWN_GROUP				 129
#define EC_R_UNKNOWN_ORDER				 114
#define EC_R_UNSUPPORTED_FIELD				 131
#define EC_R_WRONG_CURVE_PARAMETERS			 145
#define EC_R_WRONG_ORDER				 130

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/modes.h0000644000175000017500000001300312360020705021316 0ustar  /* $OpenBSD$ */
/* ====================================================================
 * Copyright (c) 2008 The OpenSSL Project. All rights reserved.
 *
 * Rights for redistribution and usage in source and binary
 * forms are granted according to the OpenSSL license.
 */

#include 

typedef void (*block128_f)(const unsigned char in[16],
			unsigned char out[16],
			const void *key);

typedef void (*cbc128_f)(const unsigned char *in, unsigned char *out,
			size_t len, const void *key,
			unsigned char ivec[16], int enc);

typedef void (*ctr128_f)(const unsigned char *in, unsigned char *out,
			size_t blocks, const void *key,
			const unsigned char ivec[16]);

typedef void (*ccm128_f)(const unsigned char *in, unsigned char *out,
			size_t blocks, const void *key,
			const unsigned char ivec[16],unsigned char cmac[16]);

void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,
			size_t len, const void *key,
			unsigned char ivec[16], block128_f block);
void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
			size_t len, const void *key,
			unsigned char ivec[16], block128_f block);

void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,
			size_t len, const void *key,
			unsigned char ivec[16], unsigned char ecount_buf[16],
			unsigned int *num, block128_f block);

void CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out,
			size_t len, const void *key,
			unsigned char ivec[16], unsigned char ecount_buf[16],
			unsigned int *num, ctr128_f ctr);

void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,
			size_t len, const void *key,
			unsigned char ivec[16], int *num,
			block128_f block);

void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
			size_t len, const void *key,
			unsigned char ivec[16], int *num,
			int enc, block128_f block);
void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,
			size_t length, const void *key,
			unsigned char ivec[16], int *num,
			int enc, block128_f block);
void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,
			size_t bits, const void *key,
			unsigned char ivec[16], int *num,
			int enc, block128_f block);

size_t CRYPTO_cts128_encrypt_block(const unsigned char *in, unsigned char *out,
			size_t len, const void *key,
			unsigned char ivec[16], block128_f block);
size_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out,
			size_t len, const void *key,
			unsigned char ivec[16], cbc128_f cbc);
size_t CRYPTO_cts128_decrypt_block(const unsigned char *in, unsigned char *out,
			size_t len, const void *key,
			unsigned char ivec[16], block128_f block);
size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out,
			size_t len, const void *key,
			unsigned char ivec[16], cbc128_f cbc);

size_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in, unsigned char *out,
			size_t len, const void *key,
			unsigned char ivec[16], block128_f block);
size_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out,
			size_t len, const void *key,
			unsigned char ivec[16], cbc128_f cbc);
size_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in, unsigned char *out,
			size_t len, const void *key,
			unsigned char ivec[16], block128_f block);
size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out,
			size_t len, const void *key,
			unsigned char ivec[16], cbc128_f cbc);

typedef struct gcm128_context GCM128_CONTEXT;

GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block);
void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx,void *key,block128_f block);
void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,
			size_t len);
int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad,
			size_t len);
int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
			const unsigned char *in, unsigned char *out,
			size_t len);
int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,
			const unsigned char *in, unsigned char *out,
			size_t len);
int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,
			const unsigned char *in, unsigned char *out,
			size_t len, ctr128_f stream);
int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,
			const unsigned char *in, unsigned char *out,
			size_t len, ctr128_f stream);
int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx,const unsigned char *tag,
			size_t len);
void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len);
void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx);

typedef struct ccm128_context CCM128_CONTEXT;

void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx,
	unsigned int M, unsigned int L, void *key,block128_f block);
int CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx,
	const unsigned char *nonce, size_t nlen, size_t mlen);
void CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx,
	const unsigned char *aad, size_t alen);
int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx,
	const unsigned char *inp, unsigned char *out, size_t len);
int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx,
	const unsigned char *inp, unsigned char *out, size_t len);
int CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx,
	const unsigned char *inp, unsigned char *out, size_t len,
	ccm128_f stream);
int CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx,
	const unsigned char *inp, unsigned char *out, size_t len,
	ccm128_f stream);
size_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len);

typedef struct xts128_context XTS128_CONTEXT;

int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16],
	const unsigned char *inp, unsigned char *out, size_t len, int enc);
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/Makefile.am0000644000175000017500000000472712360020706022110 0ustar  include $(top_srcdir)/Makefile.am.common

opensslincludedir=$(includedir)/openssl

opensslinclude_HEADERS =
opensslinclude_HEADERS += aes.h
opensslinclude_HEADERS += asn1.h
opensslinclude_HEADERS += asn1_mac.h
opensslinclude_HEADERS += asn1t.h
opensslinclude_HEADERS += bio.h
opensslinclude_HEADERS += blowfish.h
opensslinclude_HEADERS += bn.h
opensslinclude_HEADERS += buffer.h
opensslinclude_HEADERS += cast.h
opensslinclude_HEADERS += chacha.h
opensslinclude_HEADERS += cmac.h
opensslinclude_HEADERS += cms.h
opensslinclude_HEADERS += comp.h
opensslinclude_HEADERS += conf.h
opensslinclude_HEADERS += conf_api.h
opensslinclude_HEADERS += crypto.h
opensslinclude_HEADERS += des.h
opensslinclude_HEADERS += dh.h
opensslinclude_HEADERS += dsa.h
opensslinclude_HEADERS += dso.h
opensslinclude_HEADERS += dtls1.h
opensslinclude_HEADERS += e_os2.h
opensslinclude_HEADERS += ec.h
opensslinclude_HEADERS += ecdh.h
opensslinclude_HEADERS += ecdsa.h
opensslinclude_HEADERS += engine.h
opensslinclude_HEADERS += err.h
opensslinclude_HEADERS += evp.h
opensslinclude_HEADERS += hmac.h
opensslinclude_HEADERS += idea.h
opensslinclude_HEADERS += krb5_asn.h
opensslinclude_HEADERS += lhash.h
opensslinclude_HEADERS += md4.h
opensslinclude_HEADERS += md5.h
opensslinclude_HEADERS += mdc2.h
opensslinclude_HEADERS += modes.h
opensslinclude_HEADERS += obj_mac.h
opensslinclude_HEADERS += objects.h
opensslinclude_HEADERS += ocsp.h
opensslinclude_HEADERS += opensslconf.h
opensslinclude_HEADERS += opensslfeatures.h
opensslinclude_HEADERS += opensslv.h
opensslinclude_HEADERS += ossl_typ.h
opensslinclude_HEADERS += pem.h
opensslinclude_HEADERS += pem2.h
opensslinclude_HEADERS += pkcs12.h
opensslinclude_HEADERS += pkcs7.h
opensslinclude_HEADERS += poly1305.h
opensslinclude_HEADERS += rand.h
opensslinclude_HEADERS += rc2.h
opensslinclude_HEADERS += rc4.h
opensslinclude_HEADERS += rc5.h
opensslinclude_HEADERS += ripemd.h
opensslinclude_HEADERS += rsa.h
opensslinclude_HEADERS += safestack.h
opensslinclude_HEADERS += sha.h
opensslinclude_HEADERS += srtp.h
opensslinclude_HEADERS += ssl.h
opensslinclude_HEADERS += ssl2.h
opensslinclude_HEADERS += ssl23.h
opensslinclude_HEADERS += ssl3.h
opensslinclude_HEADERS += stack.h
opensslinclude_HEADERS += tls1.h
opensslinclude_HEADERS += ts.h
opensslinclude_HEADERS += txt_db.h
opensslinclude_HEADERS += ui.h
opensslinclude_HEADERS += ui_compat.h
opensslinclude_HEADERS += whrlpool.h
opensslinclude_HEADERS += x509.h
opensslinclude_HEADERS += x509_vfy.h
opensslinclude_HEADERS += x509v3.h
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/poly1305.h0000644000175000017500000000270512360020705021512 0ustar  /* $OpenBSD$ */
/*
 * Copyright (c) Joel Sing 
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef HEADER_POLY1305_H
#define HEADER_POLY1305_H

#include 

#if defined(OPENSSL_NO_POLY1305)
#error Poly1305 is disabled.
#endif

#include 

#ifdef  __cplusplus
extern "C" {
#endif

typedef struct poly1305_context {
	size_t aligner;
	unsigned char opaque[136];
} poly1305_context;

typedef struct poly1305_context poly1305_state;

void CRYPTO_poly1305_init(poly1305_context *ctx, const unsigned char key[32]);
void CRYPTO_poly1305_update(poly1305_context *ctx, const unsigned char *in,
    size_t len);
void CRYPTO_poly1305_finish(poly1305_context *ctx, unsigned char mac[16]);

#ifdef  __cplusplus
}
#endif

#endif /* HEADER_POLY1305_H */
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/e_os2.h0000644000175000017500000000623412360020705021226 0ustar  /* $OpenBSD: e_os2.h,v 1.18 2014/07/11 09:36:34 jsing Exp $ */
/* ====================================================================
 * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#ifndef HEADER_E_OS2_H
#define HEADER_E_OS2_H

#include 

#ifdef  __cplusplus
extern "C" {
#endif

#define OPENSSL_SYS_UNIX

#define OPENSSL_EXPORT extern
#define OPENSSL_IMPORT extern
#define OPENSSL_GLOBAL
#define OPENSSL_EXTERN OPENSSL_IMPORT

#define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) \
    OPENSSL_GLOBAL type _shadow_##name=value;
#define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name
#define OPENSSL_GLOBAL_REF(name) _shadow_##name

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/engine.h0000644000175000017500000011453012360020705021463 0ustar  /* $OpenBSD: engine.h,v 1.28 2014/06/12 15:49:29 deraadt Exp $ */
/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
 * project 2000.
 */
/* ====================================================================
 * Copyright (c) 1999-2004 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */
/* ====================================================================
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 * ECDH support in OpenSSL originally developed by
 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
 */

#ifndef HEADER_ENGINE_H
#define HEADER_ENGINE_H

#include 

#ifdef OPENSSL_NO_ENGINE
#error ENGINE is disabled.
#endif

#ifndef OPENSSL_NO_DEPRECATED
#include 
#ifndef OPENSSL_NO_RSA
#include 
#endif
#ifndef OPENSSL_NO_DSA
#include 
#endif
#ifndef OPENSSL_NO_DH
#include 
#endif
#ifndef OPENSSL_NO_ECDH
#include 
#endif
#ifndef OPENSSL_NO_ECDSA
#include 
#endif
#include 
#include 
#include 
#endif

#include 

#include 

#ifdef  __cplusplus
extern "C" {
#endif

/* These flags are used to control combinations of algorithm (methods)
 * by bitwise "OR"ing. */
#define ENGINE_METHOD_RSA		(unsigned int)0x0001
#define ENGINE_METHOD_DSA		(unsigned int)0x0002
#define ENGINE_METHOD_DH		(unsigned int)0x0004
#define ENGINE_METHOD_RAND		(unsigned int)0x0008
#define ENGINE_METHOD_ECDH		(unsigned int)0x0010
#define ENGINE_METHOD_ECDSA		(unsigned int)0x0020
#define ENGINE_METHOD_CIPHERS		(unsigned int)0x0040
#define ENGINE_METHOD_DIGESTS		(unsigned int)0x0080
#define ENGINE_METHOD_STORE		(unsigned int)0x0100
#define ENGINE_METHOD_PKEY_METHS	(unsigned int)0x0200
#define ENGINE_METHOD_PKEY_ASN1_METHS	(unsigned int)0x0400
/* Obvious all-or-nothing cases. */
#define ENGINE_METHOD_ALL		(unsigned int)0xFFFF
#define ENGINE_METHOD_NONE		(unsigned int)0x0000

/* This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used
 * internally to control registration of ENGINE implementations, and can be set
 * by ENGINE_set_table_flags(). The "NOINIT" flag prevents attempts to
 * initialise registered ENGINEs if they are not already initialised. */
#define ENGINE_TABLE_FLAG_NOINIT	(unsigned int)0x0001

/* ENGINE flags that can be set by ENGINE_set_flags(). */
/* #define ENGINE_FLAGS_MALLOCED	0x0001 */ /* Not used */

/* This flag is for ENGINEs that wish to handle the various 'CMD'-related
 * control commands on their own. Without this flag, ENGINE_ctrl() handles these
 * control commands on behalf of the ENGINE using their "cmd_defns" data. */
#define ENGINE_FLAGS_MANUAL_CMD_CTRL	(int)0x0002

/* This flag is for ENGINEs who return new duplicate structures when found via
 * "ENGINE_by_id()". When an ENGINE must store state (eg. if ENGINE_ctrl()
 * commands are called in sequence as part of some stateful process like
 * key-generation setup and execution), it can set this flag - then each attempt
 * to obtain the ENGINE will result in it being copied into a new structure.
 * Normally, ENGINEs don't declare this flag so ENGINE_by_id() just increments
 * the existing ENGINE's structural reference count. */
#define ENGINE_FLAGS_BY_ID_COPY		(int)0x0004

/* This flag if for an ENGINE that does not want its methods registered as
 * part of ENGINE_register_all_complete() for example if the methods are
 * not usable as default methods.
 */

#define ENGINE_FLAGS_NO_REGISTER_ALL	(int)0x0008

/* ENGINEs can support their own command types, and these flags are used in
 * ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input each
 * command expects. Currently only numeric and string input is supported. If a
 * control command supports none of the _NUMERIC, _STRING, or _NO_INPUT options,
 * then it is regarded as an "internal" control command - and not for use in
 * config setting situations. As such, they're not available to the
 * ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl() access. Changes to
 * this list of 'command types' should be reflected carefully in
 * ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string(). */

/* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) */
#define ENGINE_CMD_FLAG_NUMERIC		(unsigned int)0x0001
/* accepts string input (cast from 'void*' to 'const char *', 4th parameter to
 * ENGINE_ctrl) */
#define ENGINE_CMD_FLAG_STRING		(unsigned int)0x0002
/* Indicates that the control command takes *no* input. Ie. the control command
 * is unparameterised. */
#define ENGINE_CMD_FLAG_NO_INPUT	(unsigned int)0x0004
/* Indicates that the control command is internal. This control command won't
 * be shown in any output, and is only usable through the ENGINE_ctrl_cmd()
 * function. */
#define ENGINE_CMD_FLAG_INTERNAL	(unsigned int)0x0008

/* NB: These 3 control commands are deprecated and should not be used. ENGINEs
 * relying on these commands should compile conditional support for
 * compatibility (eg. if these symbols are defined) but should also migrate the
 * same functionality to their own ENGINE-specific control functions that can be
 * "discovered" by calling applications. The fact these control commands
 * wouldn't be "executable" (ie. usable by text-based config) doesn't change the
 * fact that application code can find and use them without requiring per-ENGINE
 * hacking. */

/* These flags are used to tell the ctrl function what should be done.
 * All command numbers are shared between all engines, even if some don't
 * make sense to some engines.  In such a case, they do nothing but return
 * the error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED. */
#define ENGINE_CTRL_SET_LOGSTREAM		1
#define ENGINE_CTRL_SET_PASSWORD_CALLBACK	2
#define ENGINE_CTRL_HUP				3 /* Close and reinitialise any
						     handles/connections etc. */
#define ENGINE_CTRL_SET_USER_INTERFACE          4 /* Alternative to callback */
#define ENGINE_CTRL_SET_CALLBACK_DATA           5 /* User-specific data, used
						     when calling the password
						     callback and the user
						     interface */
#define ENGINE_CTRL_LOAD_CONFIGURATION		6 /* Load a configuration, given
						     a string that represents a
						     file name or so */
#define ENGINE_CTRL_LOAD_SECTION		7 /* Load data from a given
						     section in the already loaded
						     configuration */

/* These control commands allow an application to deal with an arbitrary engine
 * in a dynamic way. Warn: Negative return values indicate errors FOR THESE
 * COMMANDS because zero is used to indicate 'end-of-list'. Other commands,
 * including ENGINE-specific command types, return zero for an error.
 *
 * An ENGINE can choose to implement these ctrl functions, and can internally
 * manage things however it chooses - it does so by setting the
 * ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise the
 * ENGINE_ctrl() code handles this on the ENGINE's behalf using the cmd_defns
 * data (set using ENGINE_set_cmd_defns()). This means an ENGINE's ctrl()
 * handler need only implement its own commands - the above "meta" commands will
 * be taken care of. */

/* Returns non-zero if the supplied ENGINE has a ctrl() handler. If "not", then
 * all the remaining control commands will return failure, so it is worth
 * checking this first if the caller is trying to "discover" the engine's
 * capabilities and doesn't want errors generated unnecessarily. */
#define ENGINE_CTRL_HAS_CTRL_FUNCTION		10
/* Returns a positive command number for the first command supported by the
 * engine. Returns zero if no ctrl commands are supported. */
#define ENGINE_CTRL_GET_FIRST_CMD_TYPE		11
/* The 'long' argument specifies a command implemented by the engine, and the
 * return value is the next command supported, or zero if there are no more. */
#define ENGINE_CTRL_GET_NEXT_CMD_TYPE		12
/* The 'void*' argument is a command name (cast from 'const char *'), and the
 * return value is the command that corresponds to it. */
#define ENGINE_CTRL_GET_CMD_FROM_NAME		13
/* The next two allow a command to be converted into its corresponding string
 * form. In each case, the 'long' argument supplies the command. In the NAME_LEN
 * case, the return value is the length of the command name (not counting a
 * trailing EOL). In the NAME case, the 'void*' argument must be a string buffer
 * large enough, and it will be populated with the name of the command (WITH a
 * trailing EOL). */
#define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD	14
#define ENGINE_CTRL_GET_NAME_FROM_CMD		15
/* The next two are similar but give a "short description" of a command. */
#define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD	16
#define ENGINE_CTRL_GET_DESC_FROM_CMD		17
/* With this command, the return value is the OR'd combination of
 * ENGINE_CMD_FLAG_*** values that indicate what kind of input a given
 * engine-specific ctrl command expects. */
#define ENGINE_CTRL_GET_CMD_FLAGS		18

/* ENGINE implementations should start the numbering of their own control
 * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc). */
#define ENGINE_CMD_BASE				200

/* If an ENGINE supports its own specific control commands and wishes the
 * framework to handle the above 'ENGINE_CMD_***'-manipulation commands on its
 * behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN entries
 * to ENGINE_set_cmd_defns(). It should also implement a ctrl() handler that
 * supports the stated commands (ie. the "cmd_num" entries as described by the
 * array). NB: The array must be ordered in increasing order of cmd_num.
 * "null-terminated" means that the last ENGINE_CMD_DEFN element has cmd_num set
 * to zero and/or cmd_name set to NULL. */
typedef struct ENGINE_CMD_DEFN_st {
	unsigned int cmd_num; /* The command number */
	const char *cmd_name; /* The command name itself */
	const char *cmd_desc; /* A short description of the command */
	unsigned int cmd_flags; /* The input the command expects */
} ENGINE_CMD_DEFN;

/* Generic function pointer */
typedef int (*ENGINE_GEN_FUNC_PTR)(void);
/* Generic function pointer taking no arguments */
typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *);
/* Specific control function pointer */
typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGINE *, int, long, void *,
    void (*f)(void));
/* Generic load_key function pointer */
typedef EVP_PKEY * (*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *,
    UI_METHOD *ui_method, void *callback_data);
typedef int (*ENGINE_SSL_CLIENT_CERT_PTR)(ENGINE *, SSL *ssl,
    STACK_OF(X509_NAME) *ca_dn, X509 **pcert, EVP_PKEY **pkey,
    STACK_OF(X509) **pother, UI_METHOD *ui_method, void *callback_data);

/* These callback types are for an ENGINE's handler for cipher and digest logic.
 * These handlers have these prototypes;
 *   int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid);
 *   int foo(ENGINE *e, const EVP_MD **digest, const int **nids, int nid);
 * Looking at how to implement these handlers in the case of cipher support, if
 * the framework wants the EVP_CIPHER for 'nid', it will call;
 *   foo(e, &p_evp_cipher, NULL, nid);    (return zero for failure)
 * If the framework wants a list of supported 'nid's, it will call;
 *   foo(e, NULL, &p_nids, 0); (returns number of 'nids' or -1 for error)
 */
/* Returns to a pointer to the array of supported cipher 'nid's. If the second
 * parameter is non-NULL it is set to the size of the returned array. */
typedef int (*ENGINE_CIPHERS_PTR)(ENGINE *, const EVP_CIPHER **,
    const int **, int);
typedef int (*ENGINE_DIGESTS_PTR)(ENGINE *, const EVP_MD **, const int **, int);
typedef int (*ENGINE_PKEY_METHS_PTR)(ENGINE *, EVP_PKEY_METHOD **,
    const int **, int);
typedef int (*ENGINE_PKEY_ASN1_METHS_PTR)(ENGINE *, EVP_PKEY_ASN1_METHOD **,
    const int **, int);

/* STRUCTURE functions ... all of these functions deal with pointers to ENGINE
 * structures where the pointers have a "structural reference". This means that
 * their reference is to allowed access to the structure but it does not imply
 * that the structure is functional. To simply increment or decrement the
 * structural reference count, use ENGINE_by_id and ENGINE_free. NB: This is not
 * required when iterating using ENGINE_get_next as it will automatically
 * decrement the structural reference count of the "current" ENGINE and
 * increment the structural reference count of the ENGINE it returns (unless it
 * is NULL). */

/* Get the first/last "ENGINE" type available. */
ENGINE *ENGINE_get_first(void);
ENGINE *ENGINE_get_last(void);
/* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */
ENGINE *ENGINE_get_next(ENGINE *e);
ENGINE *ENGINE_get_prev(ENGINE *e);
/* Add another "ENGINE" type into the array. */
int ENGINE_add(ENGINE *e);
/* Remove an existing "ENGINE" type from the array. */
int ENGINE_remove(ENGINE *e);
/* Retrieve an engine from the list by its unique "id" value. */
ENGINE *ENGINE_by_id(const char *id);
/* Add all the built-in engines. */
void ENGINE_load_openssl(void);
void ENGINE_load_dynamic(void);
#ifndef OPENSSL_NO_STATIC_ENGINE
void ENGINE_load_padlock(void);
#endif
void ENGINE_load_rsax(void);
void ENGINE_load_builtin_engines(void);

/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation
 * "registry" handling. */
unsigned int ENGINE_get_table_flags(void);
void ENGINE_set_table_flags(unsigned int flags);

/* Manage registration of ENGINEs per "table". For each type, there are 3
 * functions;
 *   ENGINE_register_***(e) - registers the implementation from 'e' (if it has one)
 *   ENGINE_unregister_***(e) - unregister the implementation from 'e'
 *   ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list
 * Cleanup is automatically registered from each table when required, so
 * ENGINE_cleanup() will reverse any "register" operations. */

int ENGINE_register_RSA(ENGINE *e);
void ENGINE_unregister_RSA(ENGINE *e);
void ENGINE_register_all_RSA(void);

int ENGINE_register_DSA(ENGINE *e);
void ENGINE_unregister_DSA(ENGINE *e);
void ENGINE_register_all_DSA(void);

int ENGINE_register_ECDH(ENGINE *e);
void ENGINE_unregister_ECDH(ENGINE *e);
void ENGINE_register_all_ECDH(void);

int ENGINE_register_ECDSA(ENGINE *e);
void ENGINE_unregister_ECDSA(ENGINE *e);
void ENGINE_register_all_ECDSA(void);

int ENGINE_register_DH(ENGINE *e);
void ENGINE_unregister_DH(ENGINE *e);
void ENGINE_register_all_DH(void);

int ENGINE_register_RAND(ENGINE *e);
void ENGINE_unregister_RAND(ENGINE *e);
void ENGINE_register_all_RAND(void);

int ENGINE_register_STORE(ENGINE *e);
void ENGINE_unregister_STORE(ENGINE *e);
void ENGINE_register_all_STORE(void);

int ENGINE_register_ciphers(ENGINE *e);
void ENGINE_unregister_ciphers(ENGINE *e);
void ENGINE_register_all_ciphers(void);

int ENGINE_register_digests(ENGINE *e);
void ENGINE_unregister_digests(ENGINE *e);
void ENGINE_register_all_digests(void);

int ENGINE_register_pkey_meths(ENGINE *e);
void ENGINE_unregister_pkey_meths(ENGINE *e);
void ENGINE_register_all_pkey_meths(void);

int ENGINE_register_pkey_asn1_meths(ENGINE *e);
void ENGINE_unregister_pkey_asn1_meths(ENGINE *e);
void ENGINE_register_all_pkey_asn1_meths(void);

/* These functions register all support from the above categories. Note, use of
 * these functions can result in static linkage of code your application may not
 * need. If you only need a subset of functionality, consider using more
 * selective initialisation. */
int ENGINE_register_complete(ENGINE *e);
int ENGINE_register_all_complete(void);

/* Send parametrised control commands to the engine. The possibilities to send
 * down an integer, a pointer to data or a function pointer are provided. Any of
 * the parameters may or may not be NULL, depending on the command number. In
 * actuality, this function only requires a structural (rather than functional)
 * reference to an engine, but many control commands may require the engine be
 * functional. The caller should be aware of trying commands that require an
 * operational ENGINE, and only use functional references in such situations. */
int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void));

/* This function tests if an ENGINE-specific command is usable as a "setting".
 * Eg. in an application's config file that gets processed through
 * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to
 * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl(). */
int ENGINE_cmd_is_executable(ENGINE *e, int cmd);

/* This function works like ENGINE_ctrl() with the exception of taking a
 * command name instead of a command number, and can handle optional commands.
 * See the comment on ENGINE_ctrl_cmd_string() for an explanation on how to
 * use the cmd_name and cmd_optional. */
int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,
    long i, void *p, void (*f)(void), int cmd_optional);

/* This function passes a command-name and argument to an ENGINE. The cmd_name
 * is converted to a command number and the control command is called using
 * 'arg' as an argument (unless the ENGINE doesn't support such a command, in
 * which case no control command is called). The command is checked for input
 * flags, and if necessary the argument will be converted to a numeric value. If
 * cmd_optional is non-zero, then if the ENGINE doesn't support the given
 * cmd_name the return value will be success anyway. This function is intended
 * for applications to use so that users (or config files) can supply
 * engine-specific config data to the ENGINE at run-time to control behaviour of
 * specific engines. As such, it shouldn't be used for calling ENGINE_ctrl()
 * functions that return data, deal with binary data, or that are otherwise
 * supposed to be used directly through ENGINE_ctrl() in application code. Any
 * "return" data from an ENGINE_ctrl() operation in this function will be lost -
 * the return value is interpreted as failure if the return value is zero,
 * success otherwise, and this function returns a boolean value as a result. In
 * other words, vendors of 'ENGINE'-enabled devices should write ENGINE
 * implementations with parameterisations that work in this scheme, so that
 * compliant ENGINE-based applications can work consistently with the same
 * configuration for the same ENGINE-enabled devices, across applications. */
int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
    int cmd_optional);

/* These functions are useful for manufacturing new ENGINE structures. They
 * don't address reference counting at all - one uses them to populate an ENGINE
 * structure with personalised implementations of things prior to using it
 * directly or adding it to the builtin ENGINE list in OpenSSL. These are also
 * here so that the ENGINE structure doesn't have to be exposed and break binary
 * compatibility! */
ENGINE *ENGINE_new(void);
int ENGINE_free(ENGINE *e);
int ENGINE_up_ref(ENGINE *e);
int ENGINE_set_id(ENGINE *e, const char *id);
int ENGINE_set_name(ENGINE *e, const char *name);
int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);
int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth);
int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth);
int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth);
int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth);
int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth);
int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth);
int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f);
int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f);
int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f);
int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f);
int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f);
int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f);
int ENGINE_set_load_ssl_client_cert_function(ENGINE *e,
    ENGINE_SSL_CLIENT_CERT_PTR loadssl_f);
int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f);
int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f);
int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f);
int ENGINE_set_pkey_asn1_meths(ENGINE *e, ENGINE_PKEY_ASN1_METHS_PTR f);
int ENGINE_set_flags(ENGINE *e, int flags);
int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns);
/* These functions allow control over any per-structure ENGINE data. */
int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
    CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg);
void *ENGINE_get_ex_data(const ENGINE *e, int idx);

/* This function cleans up anything that needs it. Eg. the ENGINE_add() function
 * automatically ensures the list cleanup function is registered to be called
 * from ENGINE_cleanup(). Similarly, all ENGINE_register_*** functions ensure
 * ENGINE_cleanup() will clean up after them. */
void ENGINE_cleanup(void);

/* These return values from within the ENGINE structure. These can be useful
 * with functional references as well as structural references - it depends
 * which you obtained. Using the result for functional purposes if you only
 * obtained a structural reference may be problematic! */
const char *ENGINE_get_id(const ENGINE *e);
const char *ENGINE_get_name(const ENGINE *e);
const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e);
const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e);
const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e);
const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e);
const DH_METHOD *ENGINE_get_DH(const ENGINE *e);
const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e);
const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e);
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e);
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e);
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e);
ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e);
ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e);
ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e);
ENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const ENGINE *e);
ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e);
ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e);
ENGINE_PKEY_METHS_PTR ENGINE_get_pkey_meths(const ENGINE *e);
ENGINE_PKEY_ASN1_METHS_PTR ENGINE_get_pkey_asn1_meths(const ENGINE *e);
const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid);
const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid);
const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid);
const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid);
const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e,
    const char *str, int len);
const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe,
    const char *str, int len);
const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e);
int ENGINE_get_flags(const ENGINE *e);

/* FUNCTIONAL functions. These functions deal with ENGINE structures
 * that have (or will) be initialised for use. Broadly speaking, the
 * structural functions are useful for iterating the list of available
 * engine types, creating new engine types, and other "list" operations.
 * These functions actually deal with ENGINEs that are to be used. As
 * such these functions can fail (if applicable) when particular
 * engines are unavailable - eg. if a hardware accelerator is not
 * attached or not functioning correctly. Each ENGINE has 2 reference
 * counts; structural and functional. Every time a functional reference
 * is obtained or released, a corresponding structural reference is
 * automatically obtained or released too. */

/* Initialise a engine type for use (or up its reference count if it's
 * already in use). This will fail if the engine is not currently
 * operational and cannot initialise. */
int ENGINE_init(ENGINE *e);
/* Free a functional reference to a engine type. This does not require
 * a corresponding call to ENGINE_free as it also releases a structural
 * reference. */
int ENGINE_finish(ENGINE *e);

/* The following functions handle keys that are stored in some secondary
 * location, handled by the engine.  The storage may be on a card or
 * whatever. */
EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id,
    UI_METHOD *ui_method, void *callback_data);
EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id,
    UI_METHOD *ui_method, void *callback_data);
int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s,
    STACK_OF(X509_NAME) *ca_dn, X509 **pcert, EVP_PKEY **ppkey,
    STACK_OF(X509) **pother,
    UI_METHOD *ui_method, void *callback_data);

/* This returns a pointer for the current ENGINE structure that
 * is (by default) performing any RSA operations. The value returned
 * is an incremented reference, so it should be free'd (ENGINE_finish)
 * before it is discarded. */
ENGINE *ENGINE_get_default_RSA(void);
/* Same for the other "methods" */
ENGINE *ENGINE_get_default_DSA(void);
ENGINE *ENGINE_get_default_ECDH(void);
ENGINE *ENGINE_get_default_ECDSA(void);
ENGINE *ENGINE_get_default_DH(void);
ENGINE *ENGINE_get_default_RAND(void);
/* These functions can be used to get a functional reference to perform
 * ciphering or digesting corresponding to "nid". */
ENGINE *ENGINE_get_cipher_engine(int nid);
ENGINE *ENGINE_get_digest_engine(int nid);
ENGINE *ENGINE_get_pkey_meth_engine(int nid);
ENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid);

/* This sets a new default ENGINE structure for performing RSA
 * operations. If the result is non-zero (success) then the ENGINE
 * structure will have had its reference count up'd so the caller
 * should still free their own reference 'e'. */
int ENGINE_set_default_RSA(ENGINE *e);
int ENGINE_set_default_string(ENGINE *e, const char *def_list);
/* Same for the other "methods" */
int ENGINE_set_default_DSA(ENGINE *e);
int ENGINE_set_default_ECDH(ENGINE *e);
int ENGINE_set_default_ECDSA(ENGINE *e);
int ENGINE_set_default_DH(ENGINE *e);
int ENGINE_set_default_RAND(ENGINE *e);
int ENGINE_set_default_ciphers(ENGINE *e);
int ENGINE_set_default_digests(ENGINE *e);
int ENGINE_set_default_pkey_meths(ENGINE *e);
int ENGINE_set_default_pkey_asn1_meths(ENGINE *e);

/* The combination "set" - the flags are bitwise "OR"d from the
 * ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()"
 * function, this function can result in unnecessary static linkage. If your
 * application requires only specific functionality, consider using more
 * selective functions. */
int ENGINE_set_default(ENGINE *e, unsigned int flags);

void ENGINE_add_conf_module(void);

/* Deprecated functions ... */
/* int ENGINE_clear_defaults(void); */

/**************************/
/* DYNAMIC ENGINE SUPPORT */
/**************************/

/* Binary/behaviour compatibility levels */
#define OSSL_DYNAMIC_VERSION		(unsigned long)0x00020000
/* Binary versions older than this are too old for us (whether we're a loader or
 * a loadee) */
#define OSSL_DYNAMIC_OLDEST		(unsigned long)0x00020000

/* When compiling an ENGINE entirely as an external shared library, loadable by
 * the "dynamic" ENGINE, these types are needed. The 'dynamic_fns' structure
 * type provides the calling application's (or library's) error functionality
 * and memory management function pointers to the loaded library. These should
 * be used/set in the loaded library code so that the loading application's
 * 'state' will be used/changed in all operations. The 'static_state' pointer
 * allows the loaded library to know if it shares the same static data as the
 * calling application (or library), and thus whether these callbacks need to be
 * set or not. */
typedef void *(*dyn_MEM_malloc_cb)(size_t);
typedef void *(*dyn_MEM_realloc_cb)(void *, size_t);
typedef void (*dyn_MEM_free_cb)(void *);
typedef struct st_dynamic_MEM_fns {
	dyn_MEM_malloc_cb			malloc_cb;
	dyn_MEM_realloc_cb			realloc_cb;
	dyn_MEM_free_cb				free_cb;
} dynamic_MEM_fns;
/* FIXME: Perhaps the memory and locking code (crypto.h) should declare and use
 * these types so we (and any other dependant code) can simplify a bit?? */
typedef void (*dyn_lock_locking_cb)(int, int, const char *, int);
typedef int (*dyn_lock_add_lock_cb)(int*, int, int, const char *, int);
typedef struct CRYPTO_dynlock_value *(*dyn_dynlock_create_cb)(
    const char *, int);
typedef void (*dyn_dynlock_lock_cb)(int, struct CRYPTO_dynlock_value *,
    const char *, int);
typedef void (*dyn_dynlock_destroy_cb)(struct CRYPTO_dynlock_value *,
    const char *, int);
typedef struct st_dynamic_LOCK_fns {
	dyn_lock_locking_cb			lock_locking_cb;
	dyn_lock_add_lock_cb			lock_add_lock_cb;
	dyn_dynlock_create_cb			dynlock_create_cb;
	dyn_dynlock_lock_cb			dynlock_lock_cb;
	dyn_dynlock_destroy_cb			dynlock_destroy_cb;
} dynamic_LOCK_fns;
/* The top-level structure */
typedef struct st_dynamic_fns {
	void 					*static_state;
	const ERR_FNS				*err_fns;
	const CRYPTO_EX_DATA_IMPL		*ex_data_fns;
	dynamic_MEM_fns				mem_fns;
	dynamic_LOCK_fns			lock_fns;
} dynamic_fns;

/* The version checking function should be of this prototype. NB: The
 * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading code.
 * If this function returns zero, it indicates a (potential) version
 * incompatibility and the loaded library doesn't believe it can proceed.
 * Otherwise, the returned value is the (latest) version supported by the
 * loading library. The loader may still decide that the loaded code's version
 * is unsatisfactory and could veto the load. The function is expected to
 * be implemented with the symbol name "v_check", and a default implementation
 * can be fully instantiated with IMPLEMENT_DYNAMIC_CHECK_FN(). */
typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version);
#define IMPLEMENT_DYNAMIC_CHECK_FN() \
	extern unsigned long v_check(unsigned long v); \
	extern unsigned long v_check(unsigned long v) { \
		if(v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \
		return 0; }

/* This function is passed the ENGINE structure to initialise with its own
 * function and command settings. It should not adjust the structural or
 * functional reference counts. If this function returns zero, (a) the load will
 * be aborted, (b) the previous ENGINE state will be memcpy'd back onto the
 * structure, and (c) the shared library will be unloaded. So implementations
 * should do their own internal cleanup in failure circumstances otherwise they
 * could leak. The 'id' parameter, if non-NULL, represents the ENGINE id that
 * the loader is looking for. If this is NULL, the shared library can choose to
 * return failure or to initialise a 'default' ENGINE. If non-NULL, the shared
 * library must initialise only an ENGINE matching the passed 'id'. The function
 * is expected to be implemented with the symbol name "bind_engine". A standard
 * implementation can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where
 * the parameter 'fn' is a callback function that populates the ENGINE structure
 * and returns an int value (zero for failure). 'fn' should have prototype;
 *    [static] int fn(ENGINE *e, const char *id); */
typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id,
    const dynamic_fns *fns);
#define IMPLEMENT_DYNAMIC_BIND_FN(fn) \
	extern \
	int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); \
	extern \
	int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \
		if(ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \
		if(!CRYPTO_set_mem_functions(fns->mem_fns.malloc_cb, \
			fns->mem_fns.realloc_cb, fns->mem_fns.free_cb)) \
			return 0; \
		CRYPTO_set_locking_callback(fns->lock_fns.lock_locking_cb); \
		CRYPTO_set_add_lock_callback(fns->lock_fns.lock_add_lock_cb); \
		CRYPTO_set_dynlock_create_callback(fns->lock_fns.dynlock_create_cb); \
		CRYPTO_set_dynlock_lock_callback(fns->lock_fns.dynlock_lock_cb); \
		CRYPTO_set_dynlock_destroy_callback(fns->lock_fns.dynlock_destroy_cb); \
		if(!CRYPTO_set_ex_data_implementation(fns->ex_data_fns)) \
			return 0; \
		if(!ERR_set_implementation(fns->err_fns)) return 0; \
	skip_cbs: \
		if(!fn(e,id)) return 0; \
		return 1; }

/* If the loading application (or library) and the loaded ENGINE library share
 * the same static data (eg. they're both dynamically linked to the same
 * libcrypto.so) we need a way to avoid trying to set system callbacks - this
 * would fail, and for the same reason that it's unnecessary to try. If the
 * loaded ENGINE has (or gets from through the loader) its own copy of the
 * libcrypto static data, we will need to set the callbacks. The easiest way to
 * detect this is to have a function that returns a pointer to some static data
 * and let the loading application and loaded ENGINE compare their respective
 * values. */
					void *ENGINE_get_static_state(void);

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_ENGINE_strings(void);

/* Error codes for the ENGINE functions. */

/* Function codes. */
#define ENGINE_F_DYNAMIC_CTRL				 180
#define ENGINE_F_DYNAMIC_GET_DATA_CTX			 181
#define ENGINE_F_DYNAMIC_LOAD				 182
#define ENGINE_F_DYNAMIC_SET_DATA_CTX			 183
#define ENGINE_F_ENGINE_ADD				 105
#define ENGINE_F_ENGINE_BY_ID				 106
#define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE		 170
#define ENGINE_F_ENGINE_CTRL				 142
#define ENGINE_F_ENGINE_CTRL_CMD			 178
#define ENGINE_F_ENGINE_CTRL_CMD_STRING			 171
#define ENGINE_F_ENGINE_FINISH				 107
#define ENGINE_F_ENGINE_FREE_UTIL			 108
#define ENGINE_F_ENGINE_GET_CIPHER			 185
#define ENGINE_F_ENGINE_GET_DEFAULT_TYPE		 177
#define ENGINE_F_ENGINE_GET_DIGEST			 186
#define ENGINE_F_ENGINE_GET_NEXT			 115
#define ENGINE_F_ENGINE_GET_PKEY_ASN1_METH		 193
#define ENGINE_F_ENGINE_GET_PKEY_METH			 192
#define ENGINE_F_ENGINE_GET_PREV			 116
#define ENGINE_F_ENGINE_INIT				 119
#define ENGINE_F_ENGINE_LIST_ADD			 120
#define ENGINE_F_ENGINE_LIST_REMOVE			 121
#define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY		 150
#define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY			 151
#define ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT		 194
#define ENGINE_F_ENGINE_NEW				 122
#define ENGINE_F_ENGINE_REMOVE				 123
#define ENGINE_F_ENGINE_SET_DEFAULT_STRING		 189
#define ENGINE_F_ENGINE_SET_DEFAULT_TYPE		 126
#define ENGINE_F_ENGINE_SET_ID				 129
#define ENGINE_F_ENGINE_SET_NAME			 130
#define ENGINE_F_ENGINE_TABLE_REGISTER			 184
#define ENGINE_F_ENGINE_UNLOAD_KEY			 152
#define ENGINE_F_ENGINE_UNLOCKED_FINISH			 191
#define ENGINE_F_ENGINE_UP_REF				 190
#define ENGINE_F_INT_CTRL_HELPER			 172
#define ENGINE_F_INT_ENGINE_CONFIGURE			 188
#define ENGINE_F_INT_ENGINE_MODULE_INIT			 187
#define ENGINE_F_LOG_MESSAGE				 141

/* Reason codes. */
#define ENGINE_R_ALREADY_LOADED				 100
#define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER		 133
#define ENGINE_R_CMD_NOT_EXECUTABLE			 134
#define ENGINE_R_COMMAND_TAKES_INPUT			 135
#define ENGINE_R_COMMAND_TAKES_NO_INPUT			 136
#define ENGINE_R_CONFLICTING_ENGINE_ID			 103
#define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED		 119
#define ENGINE_R_DH_NOT_IMPLEMENTED			 139
#define ENGINE_R_DSA_NOT_IMPLEMENTED			 140
#define ENGINE_R_DSO_FAILURE				 104
#define ENGINE_R_DSO_NOT_FOUND				 132
#define ENGINE_R_ENGINES_SECTION_ERROR			 148
#define ENGINE_R_ENGINE_CONFIGURATION_ERROR		 102
#define ENGINE_R_ENGINE_IS_NOT_IN_LIST			 105
#define ENGINE_R_ENGINE_SECTION_ERROR			 149
#define ENGINE_R_FAILED_LOADING_PRIVATE_KEY		 128
#define ENGINE_R_FAILED_LOADING_PUBLIC_KEY		 129
#define ENGINE_R_FINISH_FAILED				 106
#define ENGINE_R_GET_HANDLE_FAILED			 107
#define ENGINE_R_ID_OR_NAME_MISSING			 108
#define ENGINE_R_INIT_FAILED				 109
#define ENGINE_R_INTERNAL_LIST_ERROR			 110
#define ENGINE_R_INVALID_ARGUMENT			 143
#define ENGINE_R_INVALID_CMD_NAME			 137
#define ENGINE_R_INVALID_CMD_NUMBER			 138
#define ENGINE_R_INVALID_INIT_VALUE			 151
#define ENGINE_R_INVALID_STRING				 150
#define ENGINE_R_NOT_INITIALISED			 117
#define ENGINE_R_NOT_LOADED				 112
#define ENGINE_R_NO_CONTROL_FUNCTION			 120
#define ENGINE_R_NO_INDEX				 144
#define ENGINE_R_NO_LOAD_FUNCTION			 125
#define ENGINE_R_NO_REFERENCE				 130
#define ENGINE_R_NO_SUCH_ENGINE				 116
#define ENGINE_R_NO_UNLOAD_FUNCTION			 126
#define ENGINE_R_PROVIDE_PARAMETERS			 113
#define ENGINE_R_RSA_NOT_IMPLEMENTED			 141
#define ENGINE_R_UNIMPLEMENTED_CIPHER			 146
#define ENGINE_R_UNIMPLEMENTED_DIGEST			 147
#define ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD	 101
#define ENGINE_R_VERSION_INCOMPATIBILITY		 145

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/evp.h0000644000175000017500000015776612360020705021032 0ustar  /* $OpenBSD: evp.h,v 1.38 2014/06/24 19:31:50 miod Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_ENVELOPE_H
#define HEADER_ENVELOPE_H

#include 

#include 

#ifndef OPENSSL_NO_BIO
#include 
#endif

/*
#define EVP_RC2_KEY_SIZE		16
#define EVP_RC4_KEY_SIZE		16
#define EVP_BLOWFISH_KEY_SIZE		16
#define EVP_CAST5_KEY_SIZE		16
#define EVP_RC5_32_12_16_KEY_SIZE	16
*/
#define EVP_MAX_MD_SIZE			64	/* longest known is SHA512 */
#define EVP_MAX_KEY_LENGTH		64
#define EVP_MAX_IV_LENGTH		16
#define EVP_MAX_BLOCK_LENGTH		32

#define PKCS5_SALT_LEN			8
/* Default PKCS#5 iteration count */
#define PKCS5_DEFAULT_ITER		2048

#include 

#define EVP_PK_RSA	0x0001
#define EVP_PK_DSA	0x0002
#define EVP_PK_DH	0x0004
#define EVP_PK_EC	0x0008
#define EVP_PKT_SIGN	0x0010
#define EVP_PKT_ENC	0x0020
#define EVP_PKT_EXCH	0x0040
#define EVP_PKS_RSA	0x0100
#define EVP_PKS_DSA	0x0200
#define EVP_PKS_EC	0x0400
#define EVP_PKT_EXP	0x1000 /* <= 512 bit key */

#define EVP_PKEY_NONE	NID_undef
#define EVP_PKEY_RSA	NID_rsaEncryption
#define EVP_PKEY_RSA2	NID_rsa
#define EVP_PKEY_DSA	NID_dsa
#define EVP_PKEY_DSA1	NID_dsa_2
#define EVP_PKEY_DSA2	NID_dsaWithSHA
#define EVP_PKEY_DSA3	NID_dsaWithSHA1
#define EVP_PKEY_DSA4	NID_dsaWithSHA1_2
#define EVP_PKEY_DH	NID_dhKeyAgreement
#define EVP_PKEY_EC	NID_X9_62_id_ecPublicKey
#define EVP_PKEY_HMAC	NID_hmac
#define EVP_PKEY_CMAC	NID_cmac

#ifdef	__cplusplus
extern "C" {
#endif

/* Type needs to be a bit field
 * Sub-type needs to be for variations on the method, as in, can it do
 * arbitrary encryption.... */
struct evp_pkey_st {
	int type;
	int save_type;
	int references;
	const EVP_PKEY_ASN1_METHOD *ameth;
	ENGINE *engine;
	union	{
		char *ptr;
#ifndef OPENSSL_NO_RSA
		struct rsa_st *rsa;	/* RSA */
#endif
#ifndef OPENSSL_NO_DSA
		struct dsa_st *dsa;	/* DSA */
#endif
#ifndef OPENSSL_NO_DH
		struct dh_st *dh;	/* DH */
#endif
#ifndef OPENSSL_NO_EC
		struct ec_key_st *ec;	/* ECC */
#endif
	} pkey;
	int save_parameters;
	STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
} /* EVP_PKEY */;

#define EVP_PKEY_MO_SIGN	0x0001
#define EVP_PKEY_MO_VERIFY	0x0002
#define EVP_PKEY_MO_ENCRYPT	0x0004
#define EVP_PKEY_MO_DECRYPT	0x0008

#ifndef EVP_MD
struct env_md_st {
	int type;
	int pkey_type;
	int md_size;
	unsigned long flags;
	int (*init)(EVP_MD_CTX *ctx);
	int (*update)(EVP_MD_CTX *ctx, const void *data, size_t count);
	int (*final)(EVP_MD_CTX *ctx, unsigned char *md);
	int (*copy)(EVP_MD_CTX *to, const EVP_MD_CTX *from);
	int (*cleanup)(EVP_MD_CTX *ctx);

	/* FIXME: prototype these some day */
	int (*sign)(int type, const unsigned char *m, unsigned int m_length,
	    unsigned char *sigret, unsigned int *siglen, void *key);
	int (*verify)(int type, const unsigned char *m, unsigned int m_length,
	    const unsigned char *sigbuf, unsigned int siglen,
	    void *key);
	int required_pkey_type[5]; /*EVP_PKEY_xxx */
	int block_size;
	int ctx_size; /* how big does the ctx->md_data need to be */
	/* control function */
	int (*md_ctrl)(EVP_MD_CTX *ctx, int cmd, int p1, void *p2);
} /* EVP_MD */;

typedef int evp_sign_method(int type, const unsigned char *m,
    unsigned int m_length, unsigned char *sigret, unsigned int *siglen,
    void *key);
typedef int evp_verify_method(int type, const unsigned char *m,
    unsigned int m_length, const unsigned char *sigbuf, unsigned int siglen,
    void *key);

#define EVP_MD_FLAG_ONESHOT	0x0001 /* digest can only handle a single
					* block */

#define EVP_MD_FLAG_PKEY_DIGEST	0x0002 /* digest is a "clone" digest used
					* which is a copy of an existing
					* one for a specific public key type.
					* EVP_dss1() etc */

/* Digest uses EVP_PKEY_METHOD for signing instead of MD specific signing */

#define EVP_MD_FLAG_PKEY_METHOD_SIGNATURE	0x0004

/* DigestAlgorithmIdentifier flags... */

#define EVP_MD_FLAG_DIGALGID_MASK		0x0018

/* NULL or absent parameter accepted. Use NULL */

#define EVP_MD_FLAG_DIGALGID_NULL		0x0000

/* NULL or absent parameter accepted. Use NULL for PKCS#1 otherwise absent */

#define EVP_MD_FLAG_DIGALGID_ABSENT		0x0008

/* Custom handling via ctrl */

#define EVP_MD_FLAG_DIGALGID_CUSTOM		0x0018

#define EVP_MD_FLAG_FIPS	0x0400 /* Note if suitable for use in FIPS mode */

/* Digest ctrls */

#define	EVP_MD_CTRL_DIGALGID			0x1
#define	EVP_MD_CTRL_MICALG			0x2

/* Minimum Algorithm specific ctrl value */

#define	EVP_MD_CTRL_ALG_CTRL			0x1000

#define EVP_PKEY_NULL_method	NULL,NULL,{0,0,0,0}

#ifndef OPENSSL_NO_DSA
#define EVP_PKEY_DSA_method	(evp_sign_method *)DSA_sign, \
				(evp_verify_method *)DSA_verify, \
				{EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \
					EVP_PKEY_DSA4,0}
#else
#define EVP_PKEY_DSA_method	EVP_PKEY_NULL_method
#endif

#ifndef OPENSSL_NO_ECDSA
#define EVP_PKEY_ECDSA_method   (evp_sign_method *)ECDSA_sign, \
				(evp_verify_method *)ECDSA_verify, \
                                 {EVP_PKEY_EC,0,0,0}
#else
#define EVP_PKEY_ECDSA_method   EVP_PKEY_NULL_method
#endif

#ifndef OPENSSL_NO_RSA
#define EVP_PKEY_RSA_method	(evp_sign_method *)RSA_sign, \
				(evp_verify_method *)RSA_verify, \
				{EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}
#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \
				(evp_sign_method *)RSA_sign_ASN1_OCTET_STRING, \
				(evp_verify_method *)RSA_verify_ASN1_OCTET_STRING, \
				{EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}
#else
#define EVP_PKEY_RSA_method	EVP_PKEY_NULL_method
#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method
#endif

#endif /* !EVP_MD */

struct env_md_ctx_st {
	const EVP_MD *digest;
	ENGINE *engine; /* functional reference if 'digest' is ENGINE-provided */
	unsigned long flags;
	void *md_data;
	/* Public key context for sign/verify */
	EVP_PKEY_CTX *pctx;
	/* Update function: usually copied from EVP_MD */
	int (*update)(EVP_MD_CTX *ctx, const void *data, size_t count);
} /* EVP_MD_CTX */;

/* values for EVP_MD_CTX flags */

#define EVP_MD_CTX_FLAG_ONESHOT		0x0001 /* digest update will be called
						* once only */
#define EVP_MD_CTX_FLAG_CLEANED		0x0002 /* context has already been
						* cleaned */
#define EVP_MD_CTX_FLAG_REUSE		0x0004 /* Don't free up ctx->md_data
						* in EVP_MD_CTX_cleanup */
/* FIPS and pad options are ignored in 1.0.0, definitions are here
 * so we don't accidentally reuse the values for other purposes.
 */

#define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW	0x0008	/* Allow use of non FIPS digest
						 * in FIPS mode */

/* The following PAD options are also currently ignored in 1.0.0, digest
 * parameters are handled through EVP_DigestSign*() and EVP_DigestVerify*()
 * instead.
 */
#define EVP_MD_CTX_FLAG_PAD_MASK	0xF0	/* RSA mode to use */
#define EVP_MD_CTX_FLAG_PAD_PKCS1	0x00	/* PKCS#1 v1.5 mode */
#define EVP_MD_CTX_FLAG_PAD_X931	0x10	/* X9.31 mode */
#define EVP_MD_CTX_FLAG_PAD_PSS		0x20	/* PSS mode */

#define EVP_MD_CTX_FLAG_NO_INIT		0x0100 /* Don't initialize md_data */

struct evp_cipher_st {
	int nid;
	int block_size;
	int key_len;		/* Default value for variable length ciphers */
	int iv_len;
	unsigned long flags;	/* Various flags */
	int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key,
	    const unsigned char *iv, int enc);	/* init key */
	int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,
	    const unsigned char *in, size_t inl);/* encrypt/decrypt data */
	int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */
	int ctx_size;		/* how big ctx->cipher_data needs to be */
	int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */
	int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */
	int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */
	void *app_data;		/* Application data */
} /* EVP_CIPHER */;

/* Values for cipher flags */

/* Modes for ciphers */

#define		EVP_CIPH_STREAM_CIPHER		0x0
#define		EVP_CIPH_ECB_MODE		0x1
#define		EVP_CIPH_CBC_MODE		0x2
#define		EVP_CIPH_CFB_MODE		0x3
#define		EVP_CIPH_OFB_MODE		0x4
#define		EVP_CIPH_CTR_MODE		0x5
#define		EVP_CIPH_GCM_MODE		0x6
#define		EVP_CIPH_CCM_MODE		0x7
#define		EVP_CIPH_XTS_MODE		0x10001
#define 	EVP_CIPH_MODE			0xF0007
/* Set if variable length cipher */
#define 	EVP_CIPH_VARIABLE_LENGTH	0x8
/* Set if the iv handling should be done by the cipher itself */
#define 	EVP_CIPH_CUSTOM_IV		0x10
/* Set if the cipher's init() function should be called if key is NULL */
#define 	EVP_CIPH_ALWAYS_CALL_INIT	0x20
/* Call ctrl() to init cipher parameters */
#define 	EVP_CIPH_CTRL_INIT		0x40
/* Don't use standard key length function */
#define 	EVP_CIPH_CUSTOM_KEY_LENGTH	0x80
/* Don't use standard block padding */
#define 	EVP_CIPH_NO_PADDING		0x100
/* cipher handles random key generation */
#define 	EVP_CIPH_RAND_KEY		0x200
/* cipher has its own additional copying logic */
#define 	EVP_CIPH_CUSTOM_COPY		0x400
/* Allow use default ASN1 get/set iv */
#define		EVP_CIPH_FLAG_DEFAULT_ASN1	0x1000
/* Buffer length in bits not bytes: CFB1 mode only */
#define		EVP_CIPH_FLAG_LENGTH_BITS	0x2000
/* Note if suitable for use in FIPS mode */
#define		EVP_CIPH_FLAG_FIPS		0x4000
/* Allow non FIPS cipher in FIPS mode */
#define		EVP_CIPH_FLAG_NON_FIPS_ALLOW	0x8000
/* Cipher handles any and all padding logic as well
 * as finalisation.
 */
#define 	EVP_CIPH_FLAG_CUSTOM_CIPHER	0x100000
#define		EVP_CIPH_FLAG_AEAD_CIPHER	0x200000

/* ctrl() values */

#define		EVP_CTRL_INIT			0x0
#define 	EVP_CTRL_SET_KEY_LENGTH		0x1
#define 	EVP_CTRL_GET_RC2_KEY_BITS	0x2
#define 	EVP_CTRL_SET_RC2_KEY_BITS	0x3
#define 	EVP_CTRL_GET_RC5_ROUNDS		0x4
#define 	EVP_CTRL_SET_RC5_ROUNDS		0x5
#define 	EVP_CTRL_RAND_KEY		0x6
#define 	EVP_CTRL_PBE_PRF_NID		0x7
#define 	EVP_CTRL_COPY			0x8
#define 	EVP_CTRL_GCM_SET_IVLEN		0x9
#define 	EVP_CTRL_GCM_GET_TAG		0x10
#define 	EVP_CTRL_GCM_SET_TAG		0x11
#define		EVP_CTRL_GCM_SET_IV_FIXED	0x12
#define		EVP_CTRL_GCM_IV_GEN		0x13
#define		EVP_CTRL_CCM_SET_IVLEN		EVP_CTRL_GCM_SET_IVLEN
#define		EVP_CTRL_CCM_GET_TAG		EVP_CTRL_GCM_GET_TAG
#define		EVP_CTRL_CCM_SET_TAG		EVP_CTRL_GCM_SET_TAG
#define		EVP_CTRL_CCM_SET_L		0x14
#define		EVP_CTRL_CCM_SET_MSGLEN		0x15
/* AEAD cipher deduces payload length and returns number of bytes
 * required to store MAC and eventual padding. Subsequent call to
 * EVP_Cipher even appends/verifies MAC.
 */
#define		EVP_CTRL_AEAD_TLS1_AAD		0x16
/* Used by composite AEAD ciphers, no-op in GCM, CCM... */
#define		EVP_CTRL_AEAD_SET_MAC_KEY	0x17
/* Set the GCM invocation field, decrypt only */
#define		EVP_CTRL_GCM_SET_IV_INV		0x18

/* GCM TLS constants */
/* Length of fixed part of IV derived from PRF */
#define EVP_GCM_TLS_FIXED_IV_LEN			4
/* Length of explicit part of IV part of TLS records */
#define EVP_GCM_TLS_EXPLICIT_IV_LEN			8
/* Length of tag for TLS */
#define EVP_GCM_TLS_TAG_LEN				16

typedef struct evp_cipher_info_st {
	const EVP_CIPHER *cipher;
	unsigned char iv[EVP_MAX_IV_LENGTH];
} EVP_CIPHER_INFO;

struct evp_cipher_ctx_st {
	const EVP_CIPHER *cipher;
	ENGINE *engine;	/* functional reference if 'cipher' is ENGINE-provided */
	int encrypt;		/* encrypt or decrypt */
	int buf_len;		/* number we have left */

	unsigned char  oiv[EVP_MAX_IV_LENGTH];	/* original iv */
	unsigned char  iv[EVP_MAX_IV_LENGTH];	/* working iv */
	unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */
	int num;				/* used by cfb/ofb/ctr mode */

	void *app_data;		/* application stuff */
	int key_len;		/* May change for variable length cipher */
	unsigned long flags;	/* Various flags */
	void *cipher_data; /* per EVP data */
	int final_used;
	int block_mask;
	unsigned char final[EVP_MAX_BLOCK_LENGTH];/* possible final block */
} /* EVP_CIPHER_CTX */;

typedef struct evp_Encode_Ctx_st {
	int num;	/* number saved in a partial encode/decode */
	int length;	/* The length is either the output line length
			 * (in input bytes) or the shortest input line
			 * length that is ok.  Once decoding begins,
			 * the length is adjusted up each time a longer
			 * line is decoded */
	unsigned char enc_data[80];	/* data to encode */
	int line_num;	/* number read on current line */
	int expect_nl;
} EVP_ENCODE_CTX;

/* Password based encryption function */
typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
    ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, int en_de);

#ifndef OPENSSL_NO_RSA
#define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
					(char *)(rsa))
#endif

#ifndef OPENSSL_NO_DSA
#define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
					(char *)(dsa))
#endif

#ifndef OPENSSL_NO_DH
#define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\
					(char *)(dh))
#endif

#ifndef OPENSSL_NO_EC
#define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\
                                        (char *)(eckey))
#endif

/* Add some extra combinations */
#define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
#define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
#define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))

int EVP_MD_type(const EVP_MD *md);
#define EVP_MD_nid(e)			EVP_MD_type(e)
#define EVP_MD_name(e)			OBJ_nid2sn(EVP_MD_nid(e))
int EVP_MD_pkey_type(const EVP_MD *md);
int EVP_MD_size(const EVP_MD *md);
int EVP_MD_block_size(const EVP_MD *md);
unsigned long EVP_MD_flags(const EVP_MD *md);

const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);
#define EVP_MD_CTX_size(e)		EVP_MD_size(EVP_MD_CTX_md(e))
#define EVP_MD_CTX_block_size(e)	EVP_MD_block_size(EVP_MD_CTX_md(e))
#define EVP_MD_CTX_type(e)		EVP_MD_type(EVP_MD_CTX_md(e))

int EVP_CIPHER_nid(const EVP_CIPHER *cipher);
#define EVP_CIPHER_name(e)		OBJ_nid2sn(EVP_CIPHER_nid(e))
int EVP_CIPHER_block_size(const EVP_CIPHER *cipher);
int EVP_CIPHER_key_length(const EVP_CIPHER *cipher);
int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher);
unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher);
#define EVP_CIPHER_mode(e)		(EVP_CIPHER_flags(e) & EVP_CIPH_MODE)

const EVP_CIPHER * EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);
int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx);
int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx);
int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx);
int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx);
int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in);
void * EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);
void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);
#define EVP_CIPHER_CTX_type(c)         EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx);
#define EVP_CIPHER_CTX_mode(e)		(EVP_CIPHER_CTX_flags(e) & EVP_CIPH_MODE)

#define EVP_ENCODE_LENGTH(l)	(((l+2)/3*4)+(l/48+1)*2+80)
#define EVP_DECODE_LENGTH(l)	((l+3)/4*3+80)

#define EVP_SignInit_ex(a,b,c)		EVP_DigestInit_ex(a,b,c)
#define EVP_SignInit(a,b)		EVP_DigestInit(a,b)
#define EVP_SignUpdate(a,b,c)		EVP_DigestUpdate(a,b,c)
#define	EVP_VerifyInit_ex(a,b,c)	EVP_DigestInit_ex(a,b,c)
#define	EVP_VerifyInit(a,b)		EVP_DigestInit(a,b)
#define	EVP_VerifyUpdate(a,b,c)		EVP_DigestUpdate(a,b,c)
#define EVP_OpenUpdate(a,b,c,d,e)	EVP_DecryptUpdate(a,b,c,d,e)
#define EVP_SealUpdate(a,b,c,d,e)	EVP_EncryptUpdate(a,b,c,d,e)
#define EVP_DigestSignUpdate(a,b,c)	EVP_DigestUpdate(a,b,c)
#define EVP_DigestVerifyUpdate(a,b,c)	EVP_DigestUpdate(a,b,c)

#define BIO_set_md(b,md)		BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md)
#define BIO_get_md(b,mdp)		BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp)
#define BIO_get_md_ctx(b,mdcp)     BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp)
#define BIO_set_md_ctx(b,mdcp)     BIO_ctrl(b,BIO_C_SET_MD_CTX,0,(char *)mdcp)
#define BIO_get_cipher_status(b)	BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)
#define BIO_get_cipher_ctx(b,c_pp)	BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp)

int EVP_Cipher(EVP_CIPHER_CTX *c, unsigned char *out, const unsigned char *in,
    unsigned int inl);

#define EVP_add_cipher_alias(n,alias) \
	OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n))
#define EVP_add_digest_alias(n,alias) \
	OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n))
#define EVP_delete_cipher_alias(alias) \
	OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS);
#define EVP_delete_digest_alias(alias) \
	OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);

void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
EVP_MD_CTX *EVP_MD_CTX_create(void);
void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);
void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);
void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);
int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags);
int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt);
int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s);
int EVP_Digest(const void *data, size_t count, unsigned char *md,
    unsigned int *size, const EVP_MD *type, ENGINE *impl);

int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in);
int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s);

int EVP_read_pw_string(char *buf, int length, const char *prompt, int verify);
int EVP_read_pw_string_min(char *buf, int minlen, int maxlen,
    const char *prompt, int verify);
void EVP_set_pw_prompt(const char *prompt);
char *EVP_get_pw_prompt(void);

int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
    const unsigned char *salt, const unsigned char *data, int datal, int count,
    unsigned char *key, unsigned char *iv);

void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags);
void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags);
int EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags);

int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
    const unsigned char *key, const unsigned char *iv);
int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
    ENGINE *impl, const unsigned char *key, const unsigned char *iv);
int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
    const unsigned char *in, int inl);
int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);

int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
    const unsigned char *key, const unsigned char *iv);
int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
    ENGINE *impl, const unsigned char *key, const unsigned char *iv);
int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
    const unsigned char *in, int inl);
int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);

int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
    const unsigned char *key, const unsigned char *iv, int enc);
int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
    ENGINE *impl, const unsigned char *key, const unsigned char *iv, int enc);
int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
    const unsigned char *in, int inl);
int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);

int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s,
    EVP_PKEY *pkey);

int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf,
    unsigned int siglen, EVP_PKEY *pkey);

int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
    const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);
int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen);

int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
    const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);
int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, unsigned char *sig, size_t siglen);

int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
    const unsigned char *ek, int ekl, const unsigned char *iv, EVP_PKEY *priv);
int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);

int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
    unsigned char **ek, int *ekl, unsigned char *iv, EVP_PKEY **pubk,
    int npubk);
int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);

void EVP_EncodeInit(EVP_ENCODE_CTX *ctx);
void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
    const unsigned char *in, int inl);
void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl);
int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);

void EVP_DecodeInit(EVP_ENCODE_CTX *ctx);
int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
    const unsigned char *in, int inl);
int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl);
int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);

void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a);
int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);
int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);

#ifndef OPENSSL_NO_BIO
BIO_METHOD *BIO_f_md(void);
BIO_METHOD *BIO_f_base64(void);
BIO_METHOD *BIO_f_cipher(void);
void BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k,
    const unsigned char *i, int enc);
#endif

const EVP_MD *EVP_md_null(void);
#ifndef OPENSSL_NO_MD4
const EVP_MD *EVP_md4(void);
#endif
#ifndef OPENSSL_NO_MD5
const EVP_MD *EVP_md5(void);
#endif
#ifndef OPENSSL_NO_SHA
const EVP_MD *EVP_sha(void);
const EVP_MD *EVP_sha1(void);
const EVP_MD *EVP_dss(void);
const EVP_MD *EVP_dss1(void);
const EVP_MD *EVP_ecdsa(void);
#endif
#ifndef OPENSSL_NO_SHA256
const EVP_MD *EVP_sha224(void);
const EVP_MD *EVP_sha256(void);
#endif
#ifndef OPENSSL_NO_SHA512
const EVP_MD *EVP_sha384(void);
const EVP_MD *EVP_sha512(void);
#endif
#ifndef OPENSSL_NO_MDC2
const EVP_MD *EVP_mdc2(void);
#endif
#ifndef OPENSSL_NO_RIPEMD
const EVP_MD *EVP_ripemd160(void);
#endif
#ifndef OPENSSL_NO_WHIRLPOOL
const EVP_MD *EVP_whirlpool(void);
#endif
const EVP_CIPHER *EVP_enc_null(void);		/* does nothing :-) */
#ifndef OPENSSL_NO_DES
const EVP_CIPHER *EVP_des_ecb(void);
const EVP_CIPHER *EVP_des_ede(void);
const EVP_CIPHER *EVP_des_ede3(void);
const EVP_CIPHER *EVP_des_ede_ecb(void);
const EVP_CIPHER *EVP_des_ede3_ecb(void);
const EVP_CIPHER *EVP_des_cfb64(void);
# define EVP_des_cfb EVP_des_cfb64
const EVP_CIPHER *EVP_des_cfb1(void);
const EVP_CIPHER *EVP_des_cfb8(void);
const EVP_CIPHER *EVP_des_ede_cfb64(void);
# define EVP_des_ede_cfb EVP_des_ede_cfb64
#if 0
const EVP_CIPHER *EVP_des_ede_cfb1(void);
const EVP_CIPHER *EVP_des_ede_cfb8(void);
#endif
const EVP_CIPHER *EVP_des_ede3_cfb64(void);
# define EVP_des_ede3_cfb EVP_des_ede3_cfb64
const EVP_CIPHER *EVP_des_ede3_cfb1(void);
const EVP_CIPHER *EVP_des_ede3_cfb8(void);
const EVP_CIPHER *EVP_des_ofb(void);
const EVP_CIPHER *EVP_des_ede_ofb(void);
const EVP_CIPHER *EVP_des_ede3_ofb(void);
const EVP_CIPHER *EVP_des_cbc(void);
const EVP_CIPHER *EVP_des_ede_cbc(void);
const EVP_CIPHER *EVP_des_ede3_cbc(void);
const EVP_CIPHER *EVP_desx_cbc(void);
#endif
#ifndef OPENSSL_NO_RC4
const EVP_CIPHER *EVP_rc4(void);
const EVP_CIPHER *EVP_rc4_40(void);
#ifndef OPENSSL_NO_MD5
const EVP_CIPHER *EVP_rc4_hmac_md5(void);
#endif
#endif
#ifndef OPENSSL_NO_IDEA
const EVP_CIPHER *EVP_idea_ecb(void);
const EVP_CIPHER *EVP_idea_cfb64(void);
# define EVP_idea_cfb EVP_idea_cfb64
const EVP_CIPHER *EVP_idea_ofb(void);
const EVP_CIPHER *EVP_idea_cbc(void);
#endif
#ifndef OPENSSL_NO_RC2
const EVP_CIPHER *EVP_rc2_ecb(void);
const EVP_CIPHER *EVP_rc2_cbc(void);
const EVP_CIPHER *EVP_rc2_40_cbc(void);
const EVP_CIPHER *EVP_rc2_64_cbc(void);
const EVP_CIPHER *EVP_rc2_cfb64(void);
# define EVP_rc2_cfb EVP_rc2_cfb64
const EVP_CIPHER *EVP_rc2_ofb(void);
#endif
#ifndef OPENSSL_NO_BF
const EVP_CIPHER *EVP_bf_ecb(void);
const EVP_CIPHER *EVP_bf_cbc(void);
const EVP_CIPHER *EVP_bf_cfb64(void);
# define EVP_bf_cfb EVP_bf_cfb64
const EVP_CIPHER *EVP_bf_ofb(void);
#endif
#ifndef OPENSSL_NO_CAST
const EVP_CIPHER *EVP_cast5_ecb(void);
const EVP_CIPHER *EVP_cast5_cbc(void);
const EVP_CIPHER *EVP_cast5_cfb64(void);
# define EVP_cast5_cfb EVP_cast5_cfb64
const EVP_CIPHER *EVP_cast5_ofb(void);
#endif
#ifndef OPENSSL_NO_RC5
const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);
const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);
const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void);
# define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64
const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);
#endif
#ifndef OPENSSL_NO_AES
const EVP_CIPHER *EVP_aes_128_ecb(void);
const EVP_CIPHER *EVP_aes_128_cbc(void);
const EVP_CIPHER *EVP_aes_128_cfb1(void);
const EVP_CIPHER *EVP_aes_128_cfb8(void);
const EVP_CIPHER *EVP_aes_128_cfb128(void);
# define EVP_aes_128_cfb EVP_aes_128_cfb128
const EVP_CIPHER *EVP_aes_128_ofb(void);
const EVP_CIPHER *EVP_aes_128_ctr(void);
const EVP_CIPHER *EVP_aes_128_ccm(void);
const EVP_CIPHER *EVP_aes_128_gcm(void);
const EVP_CIPHER *EVP_aes_128_xts(void);
const EVP_CIPHER *EVP_aes_192_ecb(void);
const EVP_CIPHER *EVP_aes_192_cbc(void);
const EVP_CIPHER *EVP_aes_192_cfb1(void);
const EVP_CIPHER *EVP_aes_192_cfb8(void);
const EVP_CIPHER *EVP_aes_192_cfb128(void);
# define EVP_aes_192_cfb EVP_aes_192_cfb128
const EVP_CIPHER *EVP_aes_192_ofb(void);
const EVP_CIPHER *EVP_aes_192_ctr(void);
const EVP_CIPHER *EVP_aes_192_ccm(void);
const EVP_CIPHER *EVP_aes_192_gcm(void);
const EVP_CIPHER *EVP_aes_256_ecb(void);
const EVP_CIPHER *EVP_aes_256_cbc(void);
const EVP_CIPHER *EVP_aes_256_cfb1(void);
const EVP_CIPHER *EVP_aes_256_cfb8(void);
const EVP_CIPHER *EVP_aes_256_cfb128(void);
# define EVP_aes_256_cfb EVP_aes_256_cfb128
const EVP_CIPHER *EVP_aes_256_ofb(void);
const EVP_CIPHER *EVP_aes_256_ctr(void);
const EVP_CIPHER *EVP_aes_256_ccm(void);
const EVP_CIPHER *EVP_aes_256_gcm(void);
const EVP_CIPHER *EVP_aes_256_xts(void);
#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void);
const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void);
#endif
#endif
#ifndef OPENSSL_NO_CAMELLIA
const EVP_CIPHER *EVP_camellia_128_ecb(void);
const EVP_CIPHER *EVP_camellia_128_cbc(void);
const EVP_CIPHER *EVP_camellia_128_cfb1(void);
const EVP_CIPHER *EVP_camellia_128_cfb8(void);
const EVP_CIPHER *EVP_camellia_128_cfb128(void);
# define EVP_camellia_128_cfb EVP_camellia_128_cfb128
const EVP_CIPHER *EVP_camellia_128_ofb(void);
const EVP_CIPHER *EVP_camellia_192_ecb(void);
const EVP_CIPHER *EVP_camellia_192_cbc(void);
const EVP_CIPHER *EVP_camellia_192_cfb1(void);
const EVP_CIPHER *EVP_camellia_192_cfb8(void);
const EVP_CIPHER *EVP_camellia_192_cfb128(void);
# define EVP_camellia_192_cfb EVP_camellia_192_cfb128
const EVP_CIPHER *EVP_camellia_192_ofb(void);
const EVP_CIPHER *EVP_camellia_256_ecb(void);
const EVP_CIPHER *EVP_camellia_256_cbc(void);
const EVP_CIPHER *EVP_camellia_256_cfb1(void);
const EVP_CIPHER *EVP_camellia_256_cfb8(void);
const EVP_CIPHER *EVP_camellia_256_cfb128(void);
# define EVP_camellia_256_cfb EVP_camellia_256_cfb128
const EVP_CIPHER *EVP_camellia_256_ofb(void);
#endif

#ifndef OPENSSL_NO_CHACHA
const EVP_CIPHER *EVP_chacha20(void);
#endif

void OPENSSL_add_all_algorithms_noconf(void);
void OPENSSL_add_all_algorithms_conf(void);

#ifdef OPENSSL_LOAD_CONF
#define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_conf()
#else
#define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_noconf()
#endif

void OpenSSL_add_all_ciphers(void);
void OpenSSL_add_all_digests(void);

#define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms()
#define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers()
#define SSLeay_add_all_digests() OpenSSL_add_all_digests()

int EVP_add_cipher(const EVP_CIPHER *cipher);
int EVP_add_digest(const EVP_MD *digest);

const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
const EVP_MD *EVP_get_digestbyname(const char *name);
void EVP_cleanup(void);

void EVP_CIPHER_do_all(void (*fn)(const EVP_CIPHER *ciph, const char *from,
    const char *to, void *x), void *arg);
void EVP_CIPHER_do_all_sorted(void (*fn)(const EVP_CIPHER *ciph,
    const char *from, const char *to, void *x), void *arg);

void EVP_MD_do_all(void (*fn)(const EVP_MD *ciph, const char *from,
    const char *to, void *x), void *arg);
void EVP_MD_do_all_sorted(void (*fn)(const EVP_MD *ciph, const char *from,
    const char *to, void *x), void *arg);

int EVP_PKEY_decrypt_old(unsigned char *dec_key, const unsigned char *enc_key,
    int enc_key_len, EVP_PKEY *private_key);
int EVP_PKEY_encrypt_old(unsigned char *enc_key, const unsigned char *key,
    int key_len, EVP_PKEY *pub_key);
int EVP_PKEY_type(int type);
int EVP_PKEY_id(const EVP_PKEY *pkey);
int EVP_PKEY_base_id(const EVP_PKEY *pkey);
int EVP_PKEY_bits(EVP_PKEY *pkey);
int EVP_PKEY_size(EVP_PKEY *pkey);
int EVP_PKEY_set_type(EVP_PKEY *pkey, int type);
int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len);
int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key);
void *EVP_PKEY_get0(EVP_PKEY *pkey);

#ifndef OPENSSL_NO_RSA
struct rsa_st;
int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key);
struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
#endif
#ifndef OPENSSL_NO_DSA
struct dsa_st;
int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key);
struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
#endif
#ifndef OPENSSL_NO_DH
struct dh_st;
int EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key);
struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
#endif
#ifndef OPENSSL_NO_EC
struct ec_key_st;
int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key);
struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);
#endif

EVP_PKEY *EVP_PKEY_new(void);
void EVP_PKEY_free(EVP_PKEY *pkey);

EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
    long length);
int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);

EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
    long length);
EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,
    long length);
int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);

int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from);
int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey);
int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode);
int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);

int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);

int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey, int indent,
    ASN1_PCTX *pctx);
int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey, int indent,
    ASN1_PCTX *pctx);
int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey, int indent,
    ASN1_PCTX *pctx);

int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);

int EVP_CIPHER_type(const EVP_CIPHER *ctx);

/* calls methods */
int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);

/* These are used by EVP_CIPHER methods */
int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);

/* PKCS5 password based encryption */
int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
    ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, int en_de);
int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
    const unsigned char *salt, int saltlen, int iter, int keylen,
    unsigned char *out);
int PKCS5_PBKDF2_HMAC(const char *pass, int passlen, const unsigned char *salt,
    int saltlen, int iter, const EVP_MD *digest, int keylen,
    unsigned char *out);
int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
    ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
    int en_de);

void PKCS5_PBE_add(void);

int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
    ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);

/* PBE type */

/* Can appear as the outermost AlgorithmIdentifier */
#define EVP_PBE_TYPE_OUTER	0x0
/* Is an PRF type OID */
#define EVP_PBE_TYPE_PRF	0x1

int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, int md_nid,
    EVP_PBE_KEYGEN *keygen);
int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
    EVP_PBE_KEYGEN *keygen);
int EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid,
    EVP_PBE_KEYGEN **pkeygen);
void EVP_PBE_cleanup(void);

#define ASN1_PKEY_ALIAS		0x1
#define ASN1_PKEY_DYNAMIC	0x2
#define ASN1_PKEY_SIGPARAM_NULL	0x4

#define ASN1_PKEY_CTRL_PKCS7_SIGN	0x1
#define ASN1_PKEY_CTRL_PKCS7_ENCRYPT	0x2
#define ASN1_PKEY_CTRL_DEFAULT_MD_NID	0x3
#define ASN1_PKEY_CTRL_CMS_SIGN		0x5
#define ASN1_PKEY_CTRL_CMS_ENVELOPE	0x7

int EVP_PKEY_asn1_get_count(void);
const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx);
const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type);
const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,
    const char *str, int len);
int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth);
int EVP_PKEY_asn1_add_alias(int to, int from);
int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id, int *ppkey_flags,
    const char **pinfo, const char **ppem_str,
    const EVP_PKEY_ASN1_METHOD *ameth);

const EVP_PKEY_ASN1_METHOD* EVP_PKEY_get0_asn1(EVP_PKEY *pkey);
EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id, int flags, const char *pem_str,
    const char *info);
void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,
    const EVP_PKEY_ASN1_METHOD *src);
void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth);
void EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth,
    int (*pub_decode)(EVP_PKEY *pk, X509_PUBKEY *pub),
    int (*pub_encode)(X509_PUBKEY *pub, const EVP_PKEY *pk),
    int (*pub_cmp)(const EVP_PKEY *a, const EVP_PKEY *b),
    int (*pub_print)(BIO *out, const EVP_PKEY *pkey, int indent,
    ASN1_PCTX *pctx),
    int (*pkey_size)(const EVP_PKEY *pk),
    int (*pkey_bits)(const EVP_PKEY *pk));
void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth,
    int (*priv_decode)(EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO *p8inf),
    int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk),
    int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent,
    ASN1_PCTX *pctx));
void EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth,
    int (*param_decode)(EVP_PKEY *pkey, const unsigned char **pder, int derlen),
    int (*param_encode)(const EVP_PKEY *pkey, unsigned char **pder),
    int (*param_missing)(const EVP_PKEY *pk),
    int (*param_copy)(EVP_PKEY *to, const EVP_PKEY *from),
    int (*param_cmp)(const EVP_PKEY *a, const EVP_PKEY *b),
    int (*param_print)(BIO *out, const EVP_PKEY *pkey, int indent,
    ASN1_PCTX *pctx));

void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,
    void (*pkey_free)(EVP_PKEY *pkey));
void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
    int (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1, void *arg2));

#define EVP_PKEY_OP_UNDEFINED		0
#define EVP_PKEY_OP_PARAMGEN		(1<<1)
#define EVP_PKEY_OP_KEYGEN		(1<<2)
#define EVP_PKEY_OP_SIGN		(1<<3)
#define EVP_PKEY_OP_VERIFY		(1<<4)
#define EVP_PKEY_OP_VERIFYRECOVER	(1<<5)
#define EVP_PKEY_OP_SIGNCTX		(1<<6)
#define EVP_PKEY_OP_VERIFYCTX		(1<<7)
#define EVP_PKEY_OP_ENCRYPT		(1<<8)
#define EVP_PKEY_OP_DECRYPT		(1<<9)
#define EVP_PKEY_OP_DERIVE		(1<<10)

#define EVP_PKEY_OP_TYPE_SIG	\
	(EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER \
		| EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX)

#define EVP_PKEY_OP_TYPE_CRYPT \
	(EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT)

#define EVP_PKEY_OP_TYPE_NOGEN \
	(EVP_PKEY_OP_SIG | EVP_PKEY_OP_CRYPT | EVP_PKEY_OP_DERIVE)

#define EVP_PKEY_OP_TYPE_GEN \
		(EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN)

#define	 EVP_PKEY_CTX_set_signature_md(ctx, md)	\
		EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,  \
					EVP_PKEY_CTRL_MD, 0, (void *)md)

#define EVP_PKEY_CTRL_MD		1
#define EVP_PKEY_CTRL_PEER_KEY		2

#define EVP_PKEY_CTRL_PKCS7_ENCRYPT	3
#define EVP_PKEY_CTRL_PKCS7_DECRYPT	4

#define EVP_PKEY_CTRL_PKCS7_SIGN	5

#define EVP_PKEY_CTRL_SET_MAC_KEY	6

#define EVP_PKEY_CTRL_DIGESTINIT	7

/* Used by GOST key encryption in TLS */
#define EVP_PKEY_CTRL_SET_IV 		8

#define EVP_PKEY_CTRL_CMS_ENCRYPT	9
#define EVP_PKEY_CTRL_CMS_DECRYPT	10
#define EVP_PKEY_CTRL_CMS_SIGN		11

#define EVP_PKEY_CTRL_CIPHER		12

#define EVP_PKEY_ALG_CTRL		0x1000


#define EVP_PKEY_FLAG_AUTOARGLEN	2
/* Method handles all operations: don't assume any digest related
 * defaults.
 */
#define EVP_PKEY_FLAG_SIGCTX_CUSTOM	4

const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);
EVP_PKEY_METHOD* EVP_PKEY_meth_new(int id, int flags);
void EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags,
    const EVP_PKEY_METHOD *meth);
void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src);
void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);
int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);

EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);
EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *ctx);
void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);

int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, int cmd,
    int p1, void *p2);
int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
    const char *value);

int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx);
void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen);

EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e, const unsigned char *key,
    int keylen);

void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data);
void *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx);
EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx);

EVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx);

void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data);
void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx);

int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx);
int EVP_PKEY_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
    const unsigned char *tbs, size_t tbslen);
int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx);
int EVP_PKEY_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen,
    const unsigned char *tbs, size_t tbslen);
int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);
int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx, unsigned char *rout,
    size_t *routlen, const unsigned char *sig, size_t siglen);
int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx);
int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
    const unsigned char *in, size_t inlen);
int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx);
int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
    const unsigned char *in, size_t inlen);

int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx);
int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer);
int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);

typedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx);

int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx);
int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx);
int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);

void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb);
EVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx);

int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx);

void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,
    int (*init)(EVP_PKEY_CTX *ctx));

void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,
    int (*copy)(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src));

void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,
    void (*cleanup)(EVP_PKEY_CTX *ctx));

void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,
    int (*paramgen_init)(EVP_PKEY_CTX *ctx),
    int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey));

void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,
    int (*keygen_init)(EVP_PKEY_CTX *ctx),
    int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey));

void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,
    int (*sign_init)(EVP_PKEY_CTX *ctx),
    int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
    const unsigned char *tbs, size_t tbslen));

void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,
    int (*verify_init)(EVP_PKEY_CTX *ctx),
    int (*verify)(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen,
    const unsigned char *tbs, size_t tbslen));

void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth,
    int (*verify_recover_init)(EVP_PKEY_CTX *ctx),
    int (*verify_recover)(EVP_PKEY_CTX *ctx, unsigned char *sig,
    size_t *siglen, const unsigned char *tbs, size_t tbslen));

void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,
    int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx),
    int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
    EVP_MD_CTX *mctx));

void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,
    int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx),
    int (*verifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen,
    EVP_MD_CTX *mctx));

void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,
    int (*encrypt_init)(EVP_PKEY_CTX *ctx),
    int (*encryptfn)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
    const unsigned char *in, size_t inlen));

void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,
    int (*decrypt_init)(EVP_PKEY_CTX *ctx),
    int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
    const unsigned char *in, size_t inlen));

void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,
    int (*derive_init)(EVP_PKEY_CTX *ctx),
    int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen));

void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
    int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2),
    int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value));

/* Authenticated Encryption with Additional Data.
 *
 * AEAD couples confidentiality and integrity in a single primtive. AEAD
 * algorithms take a key and then can seal and open individual messages. Each
 * message has a unique, per-message nonce and, optionally, additional data
 * which is authenticated but not included in the output. */

struct evp_aead_st;
typedef struct evp_aead_st EVP_AEAD;

#ifndef OPENSSL_NO_AES
/* EVP_aes_128_gcm is AES-128 in Galois Counter Mode. */
const EVP_AEAD *EVP_aead_aes_128_gcm(void);
/* EVP_aes_256_gcm is AES-256 in Galois Counter Mode. */
const EVP_AEAD *EVP_aead_aes_256_gcm(void);
#endif

#if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
/* EVP_aead_chacha20_poly1305 is ChaCha20 with a Poly1305 authenticator. */
const EVP_AEAD *EVP_aead_chacha20_poly1305(void);
#endif

/* EVP_AEAD_key_length returns the length of the keys used. */
size_t EVP_AEAD_key_length(const EVP_AEAD *aead);

/* EVP_AEAD_nonce_length returns the length of the per-message nonce. */
size_t EVP_AEAD_nonce_length(const EVP_AEAD *aead);

/* EVP_AEAD_max_overhead returns the maximum number of additional bytes added
 * by the act of sealing data with the AEAD. */
size_t EVP_AEAD_max_overhead(const EVP_AEAD *aead);

/* EVP_AEAD_max_tag_len returns the maximum tag length when using this AEAD.
 * This * is the largest value that can be passed as a tag length to
 * EVP_AEAD_CTX_init. */
size_t EVP_AEAD_max_tag_len(const EVP_AEAD *aead);

/* An EVP_AEAD_CTX represents an AEAD algorithm configured with a specific key
 * and message-independent IV. */
typedef struct evp_aead_ctx_st {
	const EVP_AEAD *aead;
	/* aead_state is an opaque pointer to the AEAD specific state. */
	void *aead_state;
} EVP_AEAD_CTX;

/* EVP_AEAD_MAX_TAG_LENGTH is the maximum tag length used by any AEAD
 * defined in this header. */
#define EVP_AEAD_MAX_TAG_LENGTH 16

/* EVP_AEAD_DEFAULT_TAG_LENGTH is a magic value that can be passed to
 * EVP_AEAD_CTX_init to indicate that the default tag length for an AEAD
 * should be used. */
#define EVP_AEAD_DEFAULT_TAG_LENGTH 0

/* EVP_AEAD_init initializes the context for the given AEAD algorithm.
 * The implementation argument may be NULL to choose the default implementation.
 * Authentication tags may be truncated by passing a tag length. A tag length
 * of zero indicates the default tag length should be used. */
int EVP_AEAD_CTX_init(EVP_AEAD_CTX *ctx, const EVP_AEAD *aead,
    const unsigned char *key, size_t key_len, size_t tag_len, ENGINE *impl);

/* EVP_AEAD_CTX_cleanup frees any data allocated for this context. */
void EVP_AEAD_CTX_cleanup(EVP_AEAD_CTX *ctx);

/* EVP_AEAD_CTX_seal encrypts and authenticates the input and authenticates
 * any additional data (AD), the result being written as output. One is
 * returned on success, otherwise zero.
 *
 * This function may be called (with the same EVP_AEAD_CTX) concurrently with
 * itself or EVP_AEAD_CTX_open.
 *
 * At most max_out_len bytes are written as output and, in order to ensure
 * success, this value should be the length of the input plus the result of
 * EVP_AEAD_overhead. On successful return, out_len is set to the actual
 * number of bytes written.
 *
 * The length of the nonce is must be equal to the result of
 * EVP_AEAD_nonce_length for this AEAD.
 *
 * EVP_AEAD_CTX_seal never results in a partial output. If max_out_len is
 * insufficient, zero will be returned and out_len will be set to zero.
 *
 * If the input and output are aliased then out must be <= in. */
int EVP_AEAD_CTX_seal(const EVP_AEAD_CTX *ctx, unsigned char *out,
    size_t *out_len, size_t max_out_len, const unsigned char *nonce,
    size_t nonce_len, const unsigned char *in, size_t in_len,
    const unsigned char *ad, size_t ad_len);

/* EVP_AEAD_CTX_open authenticates the input and additional data, decrypting
 * the input and writing it as output. One is returned on success, otherwise
 * zero.
 *
 * This function may be called (with the same EVP_AEAD_CTX) concurrently with
 * itself or EVP_AEAD_CTX_seal.
 *
 * At most the number of input bytes are written as output. In order to ensure
 * success, max_out_len should be at least the same as the input length. On
 * successful return out_len is set to the actual number of bytes written.
 *
 * The length of nonce must be equal to the result of EVP_AEAD_nonce_length
 * for this AEAD.
 *
 * EVP_AEAD_CTX_open never results in a partial output. If max_out_len is
 * insufficient, zero will be returned and out_len will be set to zero.
 *
 * If the input and output are aliased then out must be <= in. */
int EVP_AEAD_CTX_open(const EVP_AEAD_CTX *ctx, unsigned char *out,
    size_t *out_len, size_t max_out_len, const unsigned char *nonce,
    size_t nonce_len, const unsigned char *in, size_t in_len,
    const unsigned char *ad, size_t ad_len);

void EVP_add_alg_module(void);

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_EVP_strings(void);

/* Error codes for the EVP functions. */

/* Function codes. */
#define EVP_F_AEAD_AES_GCM_INIT				 187
#define EVP_F_AEAD_AES_GCM_OPEN				 188
#define EVP_F_AEAD_AES_GCM_SEAL				 189
#define EVP_F_AEAD_CHACHA20_POLY1305_INIT		 192
#define EVP_F_AEAD_CHACHA20_POLY1305_OPEN		 193
#define EVP_F_AEAD_CHACHA20_POLY1305_SEAL		 194
#define EVP_F_AEAD_CTX_OPEN				 185
#define EVP_F_AEAD_CTX_SEAL				 186
#define EVP_F_AESNI_INIT_KEY				 165
#define EVP_F_AESNI_XTS_CIPHER				 176
#define EVP_F_AES_INIT_KEY				 133
#define EVP_F_AES_XTS					 172
#define EVP_F_AES_XTS_CIPHER				 175
#define EVP_F_ALG_MODULE_INIT				 177
#define EVP_F_CAMELLIA_INIT_KEY				 159
#define EVP_F_CMAC_INIT					 173
#define EVP_F_D2I_PKEY					 100
#define EVP_F_DO_SIGVER_INIT				 161
#define EVP_F_DSAPKEY2PKCS8				 134
#define EVP_F_DSA_PKEY2PKCS8				 135
#define EVP_F_ECDSA_PKEY2PKCS8				 129
#define EVP_F_ECKEY_PKEY2PKCS8				 132
#define EVP_F_EVP_AEAD_CTX_INIT				 180
#define EVP_F_EVP_AEAD_CTX_OPEN				 190
#define EVP_F_EVP_AEAD_CTX_SEAL				 191
#define EVP_F_EVP_CIPHERINIT_EX				 123
#define EVP_F_EVP_CIPHER_CTX_COPY			 163
#define EVP_F_EVP_CIPHER_CTX_CTRL			 124
#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH		 122
#define EVP_F_EVP_DECRYPTFINAL_EX			 101
#define EVP_F_EVP_DIGESTINIT_EX				 128
#define EVP_F_EVP_ENCRYPTFINAL_EX			 127
#define EVP_F_EVP_MD_CTX_COPY_EX			 110
#define EVP_F_EVP_MD_SIZE				 162
#define EVP_F_EVP_OPENINIT				 102
#define EVP_F_EVP_PBE_ALG_ADD				 115
#define EVP_F_EVP_PBE_ALG_ADD_TYPE			 160
#define EVP_F_EVP_PBE_CIPHERINIT			 116
#define EVP_F_EVP_PKCS82PKEY				 111
#define EVP_F_EVP_PKCS82PKEY_BROKEN			 136
#define EVP_F_EVP_PKEY2PKCS8_BROKEN			 113
#define EVP_F_EVP_PKEY_COPY_PARAMETERS			 103
#define EVP_F_EVP_PKEY_CTX_CTRL				 137
#define EVP_F_EVP_PKEY_CTX_CTRL_STR			 150
#define EVP_F_EVP_PKEY_CTX_DUP				 156
#define EVP_F_EVP_PKEY_DECRYPT				 104
#define EVP_F_EVP_PKEY_DECRYPT_INIT			 138
#define EVP_F_EVP_PKEY_DECRYPT_OLD			 151
#define EVP_F_EVP_PKEY_DERIVE				 153
#define EVP_F_EVP_PKEY_DERIVE_INIT			 154
#define EVP_F_EVP_PKEY_DERIVE_SET_PEER			 155
#define EVP_F_EVP_PKEY_ENCRYPT				 105
#define EVP_F_EVP_PKEY_ENCRYPT_INIT			 139
#define EVP_F_EVP_PKEY_ENCRYPT_OLD			 152
#define EVP_F_EVP_PKEY_GET1_DH				 119
#define EVP_F_EVP_PKEY_GET1_DSA				 120
#define EVP_F_EVP_PKEY_GET1_ECDSA			 130
#define EVP_F_EVP_PKEY_GET1_EC_KEY			 131
#define EVP_F_EVP_PKEY_GET1_RSA				 121
#define EVP_F_EVP_PKEY_KEYGEN				 146
#define EVP_F_EVP_PKEY_KEYGEN_INIT			 147
#define EVP_F_EVP_PKEY_NEW				 106
#define EVP_F_EVP_PKEY_PARAMGEN				 148
#define EVP_F_EVP_PKEY_PARAMGEN_INIT			 149
#define EVP_F_EVP_PKEY_SIGN				 140
#define EVP_F_EVP_PKEY_SIGN_INIT			 141
#define EVP_F_EVP_PKEY_VERIFY				 142
#define EVP_F_EVP_PKEY_VERIFY_INIT			 143
#define EVP_F_EVP_PKEY_VERIFY_RECOVER			 144
#define EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT		 145
#define EVP_F_EVP_RIJNDAEL				 126
#define EVP_F_EVP_SIGNFINAL				 107
#define EVP_F_EVP_VERIFYFINAL				 108
#define EVP_F_FIPS_CIPHERINIT				 166
#define EVP_F_FIPS_CIPHER_CTX_COPY			 170
#define EVP_F_FIPS_CIPHER_CTX_CTRL			 167
#define EVP_F_FIPS_CIPHER_CTX_SET_KEY_LENGTH		 171
#define EVP_F_FIPS_DIGESTINIT				 168
#define EVP_F_FIPS_MD_CTX_COPY				 169
#define EVP_F_HMAC_INIT_EX				 174
#define EVP_F_INT_CTX_NEW				 157
#define EVP_F_PKCS5_PBE_KEYIVGEN			 117
#define EVP_F_PKCS5_V2_PBE_KEYIVGEN			 118
#define EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN			 164
#define EVP_F_PKCS8_SET_BROKEN				 112
#define EVP_F_PKEY_SET_TYPE				 158
#define EVP_F_RC2_MAGIC_TO_METH				 109
#define EVP_F_RC5_CTRL					 125

/* Reason codes. */
#define EVP_R_AES_IV_SETUP_FAILED			 162
#define EVP_R_AES_KEY_SETUP_FAILED			 143
#define EVP_R_ASN1_LIB					 140
#define EVP_R_BAD_BLOCK_LENGTH				 136
#define EVP_R_BAD_DECRYPT				 100
#define EVP_R_BAD_KEY_LENGTH				 137
#define EVP_R_BN_DECODE_ERROR				 112
#define EVP_R_BN_PUBKEY_ERROR				 113
#define EVP_R_BUFFER_TOO_SMALL				 155
#define EVP_R_CAMELLIA_KEY_SETUP_FAILED			 157
#define EVP_R_CIPHER_PARAMETER_ERROR			 122
#define EVP_R_COMMAND_NOT_SUPPORTED			 147
#define EVP_R_CTRL_NOT_IMPLEMENTED			 132
#define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED		 133
#define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH		 138
#define EVP_R_DECODE_ERROR				 114
#define EVP_R_DIFFERENT_KEY_TYPES			 101
#define EVP_R_DIFFERENT_PARAMETERS			 153
#define EVP_R_DISABLED_FOR_FIPS				 163
#define EVP_R_ENCODE_ERROR				 115
#define EVP_R_ERROR_LOADING_SECTION			 165
#define EVP_R_ERROR_SETTING_FIPS_MODE			 166
#define EVP_R_EVP_PBE_CIPHERINIT_ERROR			 119
#define EVP_R_EXPECTING_AN_RSA_KEY			 127
#define EVP_R_EXPECTING_A_DH_KEY			 128
#define EVP_R_EXPECTING_A_DSA_KEY			 129
#define EVP_R_EXPECTING_A_ECDSA_KEY			 141
#define EVP_R_EXPECTING_A_EC_KEY			 142
#define EVP_R_FIPS_MODE_NOT_SUPPORTED			 167
#define EVP_R_INITIALIZATION_ERROR			 134
#define EVP_R_INPUT_NOT_INITIALIZED			 111
#define EVP_R_INVALID_DIGEST				 152
#define EVP_R_INVALID_FIPS_MODE				 168
#define EVP_R_INVALID_KEY_LENGTH			 130
#define EVP_R_INVALID_OPERATION				 148
#define EVP_R_IV_TOO_LARGE				 102
#define EVP_R_KEYGEN_FAILURE				 120
#define EVP_R_MESSAGE_DIGEST_IS_NULL			 159
#define EVP_R_METHOD_NOT_SUPPORTED			 144
#define EVP_R_MISSING_PARAMETERS			 103
#define EVP_R_NO_CIPHER_SET				 131
#define EVP_R_NO_DEFAULT_DIGEST				 158
#define EVP_R_NO_DIGEST_SET				 139
#define EVP_R_NO_DSA_PARAMETERS				 116
#define EVP_R_NO_KEY_SET				 154
#define EVP_R_NO_OPERATION_SET				 149
#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED		 104
#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED		 105
#define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE	 150
#define EVP_R_OPERATON_NOT_INITIALIZED			 151
#define EVP_R_OUTPUT_ALIASES_INPUT			 172
#define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE			 117
#define EVP_R_PRIVATE_KEY_DECODE_ERROR			 145
#define EVP_R_PRIVATE_KEY_ENCODE_ERROR			 146
#define EVP_R_PUBLIC_KEY_NOT_RSA			 106
#define EVP_R_TAG_TOO_LARGE				 171
#define EVP_R_TOO_LARGE					 164
#define EVP_R_UNKNOWN_CIPHER				 160
#define EVP_R_UNKNOWN_DIGEST				 161
#define EVP_R_UNKNOWN_OPTION				 169
#define EVP_R_UNKNOWN_PBE_ALGORITHM			 121
#define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS		 135
#define EVP_R_UNSUPPORTED_ALGORITHM			 156
#define EVP_R_UNSUPPORTED_CIPHER			 107
#define EVP_R_UNSUPPORTED_KEYLENGTH			 123
#define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION	 124
#define EVP_R_UNSUPPORTED_KEY_SIZE			 108
#define EVP_R_UNSUPPORTED_PRF				 125
#define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM		 118
#define EVP_R_UNSUPPORTED_SALT_TYPE			 126
#define EVP_R_WRONG_FINAL_BLOCK_LENGTH			 109
#define EVP_R_WRONG_PUBLIC_KEY_TYPE			 110

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/pem.h0000644000175000017500000005140412360020705020777 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_PEM_H
#define HEADER_PEM_H

#include 

#ifndef OPENSSL_NO_BIO
#include 
#endif
#ifndef OPENSSL_NO_STACK
#include 
#endif
#include 
#include 
#include 

#ifdef  __cplusplus
extern "C" {
#endif

#define PEM_BUFSIZE		1024

#define PEM_OBJ_UNDEF		0
#define PEM_OBJ_X509		1
#define PEM_OBJ_X509_REQ	2
#define PEM_OBJ_CRL		3
#define PEM_OBJ_SSL_SESSION	4
#define PEM_OBJ_PRIV_KEY	10
#define PEM_OBJ_PRIV_RSA	11
#define PEM_OBJ_PRIV_DSA	12
#define PEM_OBJ_PRIV_DH		13
#define PEM_OBJ_PUB_RSA		14
#define PEM_OBJ_PUB_DSA		15
#define PEM_OBJ_PUB_DH		16
#define PEM_OBJ_DHPARAMS	17
#define PEM_OBJ_DSAPARAMS	18
#define PEM_OBJ_PRIV_RSA_PUBLIC	19
#define PEM_OBJ_PRIV_ECDSA	20
#define PEM_OBJ_PUB_ECDSA	21
#define PEM_OBJ_ECPARAMETERS	22

#define PEM_ERROR		30
#define PEM_DEK_DES_CBC         40
#define PEM_DEK_IDEA_CBC        45
#define PEM_DEK_DES_EDE         50
#define PEM_DEK_DES_ECB         60
#define PEM_DEK_RSA             70
#define PEM_DEK_RSA_MD2         80
#define PEM_DEK_RSA_MD5         90

#define PEM_MD_MD2		NID_md2
#define PEM_MD_MD5		NID_md5
#define PEM_MD_SHA		NID_sha
#define PEM_MD_MD2_RSA		NID_md2WithRSAEncryption
#define PEM_MD_MD5_RSA		NID_md5WithRSAEncryption
#define PEM_MD_SHA_RSA		NID_sha1WithRSAEncryption

#define PEM_STRING_X509_OLD	"X509 CERTIFICATE"
#define PEM_STRING_X509		"CERTIFICATE"
#define PEM_STRING_X509_PAIR	"CERTIFICATE PAIR"
#define PEM_STRING_X509_TRUSTED	"TRUSTED CERTIFICATE"
#define PEM_STRING_X509_REQ_OLD	"NEW CERTIFICATE REQUEST"
#define PEM_STRING_X509_REQ	"CERTIFICATE REQUEST"
#define PEM_STRING_X509_CRL	"X509 CRL"
#define PEM_STRING_EVP_PKEY	"ANY PRIVATE KEY"
#define PEM_STRING_PUBLIC	"PUBLIC KEY"
#define PEM_STRING_RSA		"RSA PRIVATE KEY"
#define PEM_STRING_RSA_PUBLIC	"RSA PUBLIC KEY"
#define PEM_STRING_DSA		"DSA PRIVATE KEY"
#define PEM_STRING_DSA_PUBLIC	"DSA PUBLIC KEY"
#define PEM_STRING_PKCS7	"PKCS7"
#define PEM_STRING_PKCS7_SIGNED	"PKCS #7 SIGNED DATA"
#define PEM_STRING_PKCS8	"ENCRYPTED PRIVATE KEY"
#define PEM_STRING_PKCS8INF	"PRIVATE KEY"
#define PEM_STRING_DHPARAMS	"DH PARAMETERS"
#define PEM_STRING_SSL_SESSION	"SSL SESSION PARAMETERS"
#define PEM_STRING_DSAPARAMS	"DSA PARAMETERS"
#define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
#define PEM_STRING_ECPARAMETERS "EC PARAMETERS"
#define PEM_STRING_ECPRIVATEKEY	"EC PRIVATE KEY"
#define PEM_STRING_PARAMETERS	"PARAMETERS"
#define PEM_STRING_CMS		"CMS"

  /* Note that this structure is initialised by PEM_SealInit and cleaned up
     by PEM_SealFinal (at least for now) */
typedef struct PEM_Encode_Seal_st {
	EVP_ENCODE_CTX encode;
	EVP_MD_CTX md;
	EVP_CIPHER_CTX cipher;
} PEM_ENCODE_SEAL_CTX;

/* enc_type is one off */
#define PEM_TYPE_ENCRYPTED      10
#define PEM_TYPE_MIC_ONLY       20
#define PEM_TYPE_MIC_CLEAR      30
#define PEM_TYPE_CLEAR		40

typedef struct pem_recip_st {
	char *name;
	X509_NAME *dn;

	int cipher;
	int key_enc;
	/*	char iv[8]; unused and wrong size */
} PEM_USER;

typedef struct pem_ctx_st {
	int type;		/* what type of object */

	struct	{
		int version;
		int mode;
	} proc_type;

	char *domain;

	struct	{
		int cipher;
	/* unused, and wrong size
	   unsigned char iv[8]; */
	} DEK_info;

	PEM_USER *originator;

	int num_recipient;
	PEM_USER **recipient;

	/* XXX(ben): don#t think this is used!
		STACK *x509_chain;	/ * certificate chain */
	EVP_MD *md;		/* signature type */

	int md_enc;		/* is the md encrypted or not? */
	int md_len;		/* length of md_data */
	char *md_data;		/* message digest, could be pkey encrypted */

	EVP_CIPHER *dec;	/* date encryption cipher */
	int key_len;		/* key length */
	unsigned char *key;	/* key */
	/* unused, and wrong size
	   unsigned char iv[8]; */

	int  data_enc;		/* is the data encrypted */
	int data_len;
	unsigned char *data;
} PEM_CTX;

/* These macros make the PEM_read/PEM_write functions easier to maintain and
 * write. Now they are all implemented with either:
 * IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...)
 */


#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\
{ \
return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \
}

#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
int PEM_write_##name(FILE *fp, type *x) \
{ \
return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \
}

#define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
int PEM_write_##name(FILE *fp, const type *x) \
{ \
return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \
}

#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
	     unsigned char *kstr, int klen, pem_password_cb *cb, \
		  void *u) \
	{ \
	return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
	}

#define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
	     unsigned char *kstr, int klen, pem_password_cb *cb, \
		  void *u) \
	{ \
	return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
	}


#define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\
{ \
return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \
}

#define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
int PEM_write_bio_##name(BIO *bp, type *x) \
{ \
return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \
}

#define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
int PEM_write_bio_##name(BIO *bp, const type *x) \
{ \
return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \
}

#define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
	     unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
	{ \
	return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \
	}

#define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
	     unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
	{ \
	return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \
	}

#define IMPLEMENT_PEM_write(name, type, str, asn1) \
	IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
	IMPLEMENT_PEM_write_fp(name, type, str, asn1)

#define IMPLEMENT_PEM_write_const(name, type, str, asn1) \
	IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
	IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)

#define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \
	IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
	IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)

#define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \
	IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
	IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)

#define IMPLEMENT_PEM_read(name, type, str, asn1) \
	IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
	IMPLEMENT_PEM_read_fp(name, type, str, asn1)

#define IMPLEMENT_PEM_rw(name, type, str, asn1) \
	IMPLEMENT_PEM_read(name, type, str, asn1) \
	IMPLEMENT_PEM_write(name, type, str, asn1)

#define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \
	IMPLEMENT_PEM_read(name, type, str, asn1) \
	IMPLEMENT_PEM_write_const(name, type, str, asn1)

#define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \
	IMPLEMENT_PEM_read(name, type, str, asn1) \
	IMPLEMENT_PEM_write_cb(name, type, str, asn1)

/* These are the same except they are for the declarations */


#define DECLARE_PEM_read_fp(name, type) \
	type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u);

#define DECLARE_PEM_write_fp(name, type) \
	int PEM_write_##name(FILE *fp, type *x);

#define DECLARE_PEM_write_fp_const(name, type) \
	int PEM_write_##name(FILE *fp, const type *x);

#define DECLARE_PEM_write_cb_fp(name, type) \
	int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
	     unsigned char *kstr, int klen, pem_password_cb *cb, void *u);


#ifndef OPENSSL_NO_BIO
#define DECLARE_PEM_read_bio(name, type) \
	type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);

#define DECLARE_PEM_write_bio(name, type) \
	int PEM_write_bio_##name(BIO *bp, type *x);

#define DECLARE_PEM_write_bio_const(name, type) \
	int PEM_write_bio_##name(BIO *bp, const type *x);

#define DECLARE_PEM_write_cb_bio(name, type) \
	int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
	     unsigned char *kstr, int klen, pem_password_cb *cb, void *u);

#else

#define DECLARE_PEM_read_bio(name, type) /**/
#define DECLARE_PEM_write_bio(name, type) /**/
#define DECLARE_PEM_write_bio_const(name, type) /**/
#define DECLARE_PEM_write_cb_bio(name, type) /**/

#endif

#define DECLARE_PEM_write(name, type) \
	DECLARE_PEM_write_bio(name, type) \
	DECLARE_PEM_write_fp(name, type)

#define DECLARE_PEM_write_const(name, type) \
	DECLARE_PEM_write_bio_const(name, type) \
	DECLARE_PEM_write_fp_const(name, type)

#define DECLARE_PEM_write_cb(name, type) \
	DECLARE_PEM_write_cb_bio(name, type) \
	DECLARE_PEM_write_cb_fp(name, type)

#define DECLARE_PEM_read(name, type) \
	DECLARE_PEM_read_bio(name, type) \
	DECLARE_PEM_read_fp(name, type)

#define DECLARE_PEM_rw(name, type) \
	DECLARE_PEM_read(name, type) \
	DECLARE_PEM_write(name, type)

#define DECLARE_PEM_rw_const(name, type) \
	DECLARE_PEM_read(name, type) \
	DECLARE_PEM_write_const(name, type)

#define DECLARE_PEM_rw_cb(name, type) \
	DECLARE_PEM_read(name, type) \
	DECLARE_PEM_write_cb(name, type)

typedef int pem_password_cb(char *buf, int size, int rwflag, void *userdata);

int	PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
int	PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data, long *len,
	    pem_password_cb *callback, void *u);

#ifndef OPENSSL_NO_BIO
int	PEM_read_bio(BIO *bp, char **name, char **header,
	    unsigned char **data, long *len);
int	PEM_write_bio(BIO *bp, const char *name, char *hdr, unsigned char *data,
	    long len);
int	PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,
	    const char *name, BIO *bp, pem_password_cb *cb, void *u);
void *	PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp,
	    void **x, pem_password_cb *cb, void *u);
int	PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x,
	    const EVP_CIPHER *enc, unsigned char *kstr, int klen,
	    pem_password_cb *cb, void *u);

STACK_OF(X509_INFO) *	PEM_X509_INFO_read_bio(BIO *bp,
	    STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u);
int	PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
	    unsigned char *kstr, int klen, pem_password_cb *cd, void *u);
#endif

int	PEM_read(FILE *fp, char **name, char **header,
	    unsigned char **data, long *len);
int	PEM_write(FILE *fp, char *name, char *hdr, unsigned char *data,
	    long len);
void *  PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,
	    pem_password_cb *cb, void *u);
int	PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
	    void *x, const EVP_CIPHER *enc, unsigned char *kstr,
	    int klen, pem_password_cb *callback, void *u);
STACK_OF(X509_INFO) *	PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
	    pem_password_cb *cb, void *u);

int	PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
	    EVP_MD *md_type, unsigned char **ek, int *ekl,
	    unsigned char *iv, EVP_PKEY **pubk, int npubk);
void	PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,
	    unsigned char *in, int inl);
int	PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl,
	    unsigned char *out, int *outl, EVP_PKEY *priv);

void    PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
void    PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt);
int	PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
	    unsigned int *siglen, EVP_PKEY *pkey);

int	PEM_def_callback(char *buf, int num, int w, void *key);
void	PEM_proc_type(char *buf, int type);
void	PEM_dek_info(char *buf, const char *type, int len, char *str);


DECLARE_PEM_rw(X509, X509)

DECLARE_PEM_rw(X509_AUX, X509)

DECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR)

DECLARE_PEM_rw(X509_REQ, X509_REQ)
DECLARE_PEM_write(X509_REQ_NEW, X509_REQ)

DECLARE_PEM_rw(X509_CRL, X509_CRL)

DECLARE_PEM_rw(PKCS7, PKCS7)

DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)

DECLARE_PEM_rw(PKCS8, X509_SIG)

DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)

#ifndef OPENSSL_NO_RSA

DECLARE_PEM_rw_cb(RSAPrivateKey, RSA)

DECLARE_PEM_rw_const(RSAPublicKey, RSA)
DECLARE_PEM_rw(RSA_PUBKEY, RSA)

#endif

#ifndef OPENSSL_NO_DSA

DECLARE_PEM_rw_cb(DSAPrivateKey, DSA)

DECLARE_PEM_rw(DSA_PUBKEY, DSA)

DECLARE_PEM_rw_const(DSAparams, DSA)

#endif

#ifndef OPENSSL_NO_EC
DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP)
DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)
DECLARE_PEM_rw(EC_PUBKEY, EC_KEY)
#endif

#ifndef OPENSSL_NO_DH

DECLARE_PEM_rw_const(DHparams, DH)

#endif

DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)

DECLARE_PEM_rw(PUBKEY, EVP_PKEY)

int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
    char *kstr, int klen,
    pem_password_cb *cb, void *u);
int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,
    char *, int, pem_password_cb *, void *);
int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
    char *kstr, int klen,
    pem_password_cb *cb, void *u);
int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
    char *kstr, int klen,
    pem_password_cb *cb, void *u);
EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,
    void *u);

int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
    char *kstr, int klen,
    pem_password_cb *cb, void *u);
int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,
    char *kstr, int klen,
    pem_password_cb *cb, void *u);
int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
    char *kstr, int klen,
    pem_password_cb *cb, void *u);

EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,
    void *u);

int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
    char *kstr, int klen, pem_password_cb *cd, void *u);

EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);


EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);
EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);
EVP_PKEY *b2i_PrivateKey_bio(BIO *in);
EVP_PKEY *b2i_PublicKey_bio(BIO *in);
int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);
int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);
#ifndef OPENSSL_NO_RC4
EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);
int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel, pem_password_cb *cb,
    void *u);
#endif


/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_PEM_strings(void);

/* Error codes for the PEM functions. */

/* Function codes. */
#define PEM_F_B2I_DSS					 127
#define PEM_F_B2I_PVK_BIO				 128
#define PEM_F_B2I_RSA					 129
#define PEM_F_CHECK_BITLEN_DSA				 130
#define PEM_F_CHECK_BITLEN_RSA				 131
#define PEM_F_D2I_PKCS8PRIVATEKEY_BIO			 120
#define PEM_F_D2I_PKCS8PRIVATEKEY_FP			 121
#define PEM_F_DO_B2I					 132
#define PEM_F_DO_B2I_BIO				 133
#define PEM_F_DO_BLOB_HEADER				 134
#define PEM_F_DO_PK8PKEY				 126
#define PEM_F_DO_PK8PKEY_FP				 125
#define PEM_F_DO_PVK_BODY				 135
#define PEM_F_DO_PVK_HEADER				 136
#define PEM_F_I2B_PVK					 137
#define PEM_F_I2B_PVK_BIO				 138
#define PEM_F_LOAD_IV					 101
#define PEM_F_PEM_ASN1_READ				 102
#define PEM_F_PEM_ASN1_READ_BIO				 103
#define PEM_F_PEM_ASN1_WRITE				 104
#define PEM_F_PEM_ASN1_WRITE_BIO			 105
#define PEM_F_PEM_DEF_CALLBACK				 100
#define PEM_F_PEM_DO_HEADER				 106
#define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY		 118
#define PEM_F_PEM_GET_EVP_CIPHER_INFO			 107
#define PEM_F_PEM_PK8PKEY				 119
#define PEM_F_PEM_READ					 108
#define PEM_F_PEM_READ_BIO				 109
#define PEM_F_PEM_READ_BIO_PARAMETERS			 140
#define PEM_F_PEM_READ_BIO_PRIVATEKEY			 123
#define PEM_F_PEM_READ_PRIVATEKEY			 124
#define PEM_F_PEM_SEALFINAL				 110
#define PEM_F_PEM_SEALINIT				 111
#define PEM_F_PEM_SIGNFINAL				 112
#define PEM_F_PEM_WRITE					 113
#define PEM_F_PEM_WRITE_BIO				 114
#define PEM_F_PEM_WRITE_PRIVATEKEY			 139
#define PEM_F_PEM_X509_INFO_READ			 115
#define PEM_F_PEM_X509_INFO_READ_BIO			 116
#define PEM_F_PEM_X509_INFO_WRITE_BIO			 117

/* Reason codes. */
#define PEM_R_BAD_BASE64_DECODE				 100
#define PEM_R_BAD_DECRYPT				 101
#define PEM_R_BAD_END_LINE				 102
#define PEM_R_BAD_IV_CHARS				 103
#define PEM_R_BAD_MAGIC_NUMBER				 116
#define PEM_R_BAD_PASSWORD_READ				 104
#define PEM_R_BAD_VERSION_NUMBER			 117
#define PEM_R_BIO_WRITE_FAILURE				 118
#define PEM_R_CIPHER_IS_NULL				 127
#define PEM_R_ERROR_CONVERTING_PRIVATE_KEY		 115
#define PEM_R_EXPECTING_PRIVATE_KEY_BLOB		 119
#define PEM_R_EXPECTING_PUBLIC_KEY_BLOB			 120
#define PEM_R_INCONSISTENT_HEADER			 121
#define PEM_R_KEYBLOB_HEADER_PARSE_ERROR		 122
#define PEM_R_KEYBLOB_TOO_SHORT				 123
#define PEM_R_NOT_DEK_INFO				 105
#define PEM_R_NOT_ENCRYPTED				 106
#define PEM_R_NOT_PROC_TYPE				 107
#define PEM_R_NO_START_LINE				 108
#define PEM_R_PROBLEMS_GETTING_PASSWORD			 109
#define PEM_R_PUBLIC_KEY_NO_RSA				 110
#define PEM_R_PVK_DATA_TOO_SHORT			 124
#define PEM_R_PVK_TOO_SHORT				 125
#define PEM_R_READ_KEY					 111
#define PEM_R_SHORT_HEADER				 112
#define PEM_R_UNSUPPORTED_CIPHER			 113
#define PEM_R_UNSUPPORTED_ENCRYPTION			 114
#define PEM_R_UNSUPPORTED_KEY_COMPONENTS		 126

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/rc2.h0000644000175000017500000001035512360020705020704 0ustar  /* $OpenBSD: rc2.h,v 1.10 2014/06/12 15:49:30 deraadt Exp $ */
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_RC2_H
#define HEADER_RC2_H

#include  /* OPENSSL_NO_RC2, RC2_INT */

#ifdef OPENSSL_NO_RC2
#error RC2 is disabled.
#endif

#define RC2_ENCRYPT	1
#define RC2_DECRYPT	0

#define RC2_BLOCK	8
#define RC2_KEY_LENGTH	16

#ifdef  __cplusplus
extern "C" {
#endif

typedef struct rc2_key_st
	{
	RC2_INT data[64];
	} RC2_KEY;

void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,int bits);
void RC2_ecb_encrypt(const unsigned char *in,unsigned char *out,RC2_KEY *key,
		     int enc);
void RC2_encrypt(unsigned long *data,RC2_KEY *key);
void RC2_decrypt(unsigned long *data,RC2_KEY *key);
void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
	RC2_KEY *ks, unsigned char *iv, int enc);
void RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out,
		       long length, RC2_KEY *schedule, unsigned char *ivec,
		       int *num, int enc);
void RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out,
		       long length, RC2_KEY *schedule, unsigned char *ivec,
		       int *num);

#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/err.h0000644000175000017500000003663612360020705021020 0ustar  /* $OpenBSD: err.h,v 1.20 2014/07/11 08:44:48 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */
/* ====================================================================
 * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#ifndef HEADER_ERR_H
#define HEADER_ERR_H

#include 

#include 
#include 

#include 
#ifndef OPENSSL_NO_BIO
#include 
#endif
#ifndef OPENSSL_NO_LHASH
#include 
#endif

#ifdef	__cplusplus
extern "C" {
#endif

#ifndef OPENSSL_NO_ERR
#define ERR_PUT_error(a,b,c,d,e)	ERR_put_error(a,b,c,d,e)
#else
#define ERR_PUT_error(a,b,c,d,e)	ERR_put_error(a,b,c,NULL,0)
#endif

#include 

#define ERR_TXT_MALLOCED	0x01
#define ERR_TXT_STRING		0x02

#define ERR_FLAG_MARK		0x01

#define ERR_NUM_ERRORS	16
typedef struct err_state_st {
	CRYPTO_THREADID tid;
	int err_flags[ERR_NUM_ERRORS];
	unsigned long err_buffer[ERR_NUM_ERRORS];
	char *err_data[ERR_NUM_ERRORS];
	int err_data_flags[ERR_NUM_ERRORS];
	const char *err_file[ERR_NUM_ERRORS];
	int err_line[ERR_NUM_ERRORS];
	int top, bottom;
} ERR_STATE;

/* library */
#define ERR_LIB_NONE		1
#define ERR_LIB_SYS		2
#define ERR_LIB_BN		3
#define ERR_LIB_RSA		4
#define ERR_LIB_DH		5
#define ERR_LIB_EVP		6
#define ERR_LIB_BUF		7
#define ERR_LIB_OBJ		8
#define ERR_LIB_PEM		9
#define ERR_LIB_DSA		10
#define ERR_LIB_X509		11
/* #define ERR_LIB_METH         12 */
#define ERR_LIB_ASN1		13
#define ERR_LIB_CONF		14
#define ERR_LIB_CRYPTO		15
#define ERR_LIB_EC		16
#define ERR_LIB_SSL		20
/* #define ERR_LIB_SSL23        21 */
/* #define ERR_LIB_SSL2         22 */
/* #define ERR_LIB_SSL3         23 */
/* #define ERR_LIB_RSAREF       30 */
/* #define ERR_LIB_PROXY        31 */
#define ERR_LIB_BIO		32
#define ERR_LIB_PKCS7		33
#define ERR_LIB_X509V3		34
#define ERR_LIB_PKCS12		35
#define ERR_LIB_RAND		36
#define ERR_LIB_DSO		37
#define ERR_LIB_ENGINE		38
#define ERR_LIB_OCSP            39
#define ERR_LIB_UI              40
#define ERR_LIB_COMP            41
#define ERR_LIB_ECDSA		42
#define ERR_LIB_ECDH		43
#define ERR_LIB_STORE           44
#define ERR_LIB_FIPS		45
#define ERR_LIB_CMS		46
#define ERR_LIB_TS		47
#define ERR_LIB_HMAC		48
#define ERR_LIB_JPAKE		49

#define ERR_LIB_USER		128

#define SYSerr(f,r)  ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__)
#define BNerr(f,r)   ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__)
#define RSAerr(f,r)  ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__)
#define DHerr(f,r)   ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__)
#define EVPerr(f,r)  ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__)
#define BUFerr(f,r)  ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__)
#define OBJerr(f,r)  ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__)
#define PEMerr(f,r)  ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__)
#define DSAerr(f,r)  ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__)
#define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__)
#define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__)
#define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__)
#define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__)
#define ECerr(f,r)   ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__)
#define SSLerr(f,r)  ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__)
#define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__)
#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__)
#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__)
#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__)
#define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__)
#define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__)
#define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__)
#define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__)
#define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__)
#define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__)
#define ECDSAerr(f,r)  ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),__FILE__,__LINE__)
#define ECDHerr(f,r)  ERR_PUT_error(ERR_LIB_ECDH,(f),(r),__FILE__,__LINE__)
#define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__)
#define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),__FILE__,__LINE__)
#define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),__FILE__,__LINE__)
#define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),__FILE__,__LINE__)
#define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),__FILE__,__LINE__)
#define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),__FILE__,__LINE__)

#define ERR_PACK(l,f,r)		(((((unsigned long)l)&0xffL)<<24L)| \
				((((unsigned long)f)&0xfffL)<<12L)| \
				((((unsigned long)r)&0xfffL)))
#define ERR_GET_LIB(l)		(int)((((unsigned long)l)>>24L)&0xffL)
#define ERR_GET_FUNC(l)		(int)((((unsigned long)l)>>12L)&0xfffL)
#define ERR_GET_REASON(l)	(int)((l)&0xfffL)
#define ERR_FATAL_ERROR(l)	(int)((l)&ERR_R_FATAL)


/* OS functions */
#define SYS_F_FOPEN		1
#define SYS_F_CONNECT		2
#define SYS_F_GETSERVBYNAME	3
#define SYS_F_SOCKET		4
#define SYS_F_IOCTLSOCKET	5
#define SYS_F_BIND		6
#define SYS_F_LISTEN		7
#define SYS_F_ACCEPT		8
#define SYS_F_WSASTARTUP	9 /* Winsock stuff */
#define SYS_F_OPENDIR		10
#define SYS_F_FREAD		11


/* reasons */
#define ERR_R_SYS_LIB	ERR_LIB_SYS       /* 2 */
#define ERR_R_BN_LIB	ERR_LIB_BN        /* 3 */
#define ERR_R_RSA_LIB	ERR_LIB_RSA       /* 4 */
#define ERR_R_DH_LIB	ERR_LIB_DH        /* 5 */
#define ERR_R_EVP_LIB	ERR_LIB_EVP       /* 6 */
#define ERR_R_BUF_LIB	ERR_LIB_BUF       /* 7 */
#define ERR_R_OBJ_LIB	ERR_LIB_OBJ       /* 8 */
#define ERR_R_PEM_LIB	ERR_LIB_PEM       /* 9 */
#define ERR_R_DSA_LIB	ERR_LIB_DSA      /* 10 */
#define ERR_R_X509_LIB	ERR_LIB_X509     /* 11 */
#define ERR_R_ASN1_LIB	ERR_LIB_ASN1     /* 13 */
#define ERR_R_CONF_LIB	ERR_LIB_CONF     /* 14 */
#define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO  /* 15 */
#define ERR_R_EC_LIB	ERR_LIB_EC       /* 16 */
#define ERR_R_SSL_LIB	ERR_LIB_SSL      /* 20 */
#define ERR_R_BIO_LIB	ERR_LIB_BIO      /* 32 */
#define ERR_R_PKCS7_LIB	ERR_LIB_PKCS7    /* 33 */
#define ERR_R_X509V3_LIB ERR_LIB_X509V3  /* 34 */
#define ERR_R_PKCS12_LIB ERR_LIB_PKCS12  /* 35 */
#define ERR_R_RAND_LIB	ERR_LIB_RAND     /* 36 */
#define ERR_R_DSO_LIB	ERR_LIB_DSO      /* 37 */
#define ERR_R_ENGINE_LIB ERR_LIB_ENGINE  /* 38 */
#define ERR_R_OCSP_LIB  ERR_LIB_OCSP     /* 39 */
#define ERR_R_UI_LIB    ERR_LIB_UI       /* 40 */
#define ERR_R_COMP_LIB	ERR_LIB_COMP     /* 41 */
#define ERR_R_ECDSA_LIB ERR_LIB_ECDSA	 /* 42 */
#define ERR_R_ECDH_LIB  ERR_LIB_ECDH	 /* 43 */
#define ERR_R_STORE_LIB ERR_LIB_STORE    /* 44 */
#define ERR_R_TS_LIB	ERR_LIB_TS       /* 45 */

#define ERR_R_NESTED_ASN1_ERROR			58
#define ERR_R_BAD_ASN1_OBJECT_HEADER		59
#define ERR_R_BAD_GET_ASN1_OBJECT_CALL		60
#define ERR_R_EXPECTING_AN_ASN1_SEQUENCE	61
#define ERR_R_ASN1_LENGTH_MISMATCH		62
#define ERR_R_MISSING_ASN1_EOS			63

/* fatal error */
#define ERR_R_FATAL				64
#define	ERR_R_MALLOC_FAILURE			(1|ERR_R_FATAL)
#define	ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED	(2|ERR_R_FATAL)
#define	ERR_R_PASSED_NULL_PARAMETER		(3|ERR_R_FATAL)
#define	ERR_R_INTERNAL_ERROR			(4|ERR_R_FATAL)
#define	ERR_R_DISABLED				(5|ERR_R_FATAL)

/* 99 is the maximum possible ERR_R_... code, higher values
 * are reserved for the individual libraries */


typedef struct ERR_string_data_st {
	unsigned long error;
	const char *string;
} ERR_STRING_DATA;

void ERR_put_error(int lib, int func, int reason, const char *file, int line);
void ERR_set_error_data(char *data, int flags);

unsigned long ERR_get_error(void);
unsigned long ERR_get_error_line(const char **file, int *line);
unsigned long ERR_get_error_line_data(const char **file, int *line,
    const char **data, int *flags);
unsigned long ERR_peek_error(void);
unsigned long ERR_peek_error_line(const char **file, int *line);
unsigned long ERR_peek_error_line_data(const char **file, int *line,
    const char **data, int *flags);
unsigned long ERR_peek_last_error(void);
unsigned long ERR_peek_last_error_line(const char **file, int *line);
unsigned long ERR_peek_last_error_line_data(const char **file, int *line,
    const char **data, int *flags);
void ERR_clear_error(void );
char *ERR_error_string(unsigned long e, char *buf);
void ERR_error_string_n(unsigned long e, char *buf, size_t len);
const char *ERR_lib_error_string(unsigned long e);
const char *ERR_func_error_string(unsigned long e);
const char *ERR_reason_error_string(unsigned long e);
void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
    void *u);
void ERR_print_errors_fp(FILE *fp);
#ifndef OPENSSL_NO_BIO
void ERR_print_errors(BIO *bp);
#endif
void ERR_asprintf_error_data(char * format, ...);
void ERR_add_error_data(int num, ...);
void ERR_add_error_vdata(int num, va_list args);
void ERR_load_strings(int lib, ERR_STRING_DATA str[]);
void ERR_unload_strings(int lib, ERR_STRING_DATA str[]);
void ERR_load_ERR_strings(void);
void ERR_load_crypto_strings(void);
void ERR_free_strings(void);

void ERR_remove_thread_state(const CRYPTO_THREADID *tid);
#ifndef OPENSSL_NO_DEPRECATED
void ERR_remove_state(unsigned long pid); /* if zero we look it up */
#endif
ERR_STATE *ERR_get_state(void);

#ifndef OPENSSL_NO_LHASH
LHASH_OF(ERR_STRING_DATA) *ERR_get_string_table(void);
LHASH_OF(ERR_STATE) *ERR_get_err_state_table(void);
void ERR_release_err_state_table(LHASH_OF(ERR_STATE) **hash);
#endif

int ERR_get_next_error_library(void);

int ERR_set_mark(void);
int ERR_pop_to_mark(void);

/* Already defined in ossl_typ.h */
/* typedef struct st_ERR_FNS ERR_FNS; */
/* An application can use this function and provide the return value to loaded
 * modules that should use the application's ERR state/functionality */
const ERR_FNS *ERR_get_implementation(void);
/* A loaded module should call this function prior to any ERR operations using
 * the application's "ERR_FNS". */
int ERR_set_implementation(const ERR_FNS *fns);

#ifdef	__cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/conf_api.h0000644000175000017500000000773312360020705022002 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef  HEADER_CONF_API_H
#define HEADER_CONF_API_H

#include 
#include 

#ifdef  __cplusplus
extern "C" {
#endif

/* Up until OpenSSL 0.9.5a, this was new_section */
CONF_VALUE *_CONF_new_section(CONF *conf, const char *section);
/* Up until OpenSSL 0.9.5a, this was get_section */
CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section);
/* Up until OpenSSL 0.9.5a, this was CONF_get_section */
STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf,
    const char *section);

int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value);
char *_CONF_get_string(const CONF *conf, const char *section,
    const char *name);
long _CONF_get_number(const CONF *conf, const char *section, const char *name);

int _CONF_new_data(CONF *conf);
void _CONF_free_data(CONF *conf);

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/cast.h0000644000175000017500000001051112360020705021142 0ustar  /* $OpenBSD: cast.h,v 1.11 2014/06/12 15:49:28 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_CAST_H
#define HEADER_CAST_H

#include 

#ifdef  __cplusplus
extern "C" {
#endif

#ifdef OPENSSL_NO_CAST
#error CAST is disabled.
#endif

#define CAST_ENCRYPT	1
#define CAST_DECRYPT	0

#define CAST_LONG unsigned int

#define CAST_BLOCK	8
#define CAST_KEY_LENGTH	16

typedef struct cast_key_st
	{
	CAST_LONG data[32];
	int short_key;	/* Use reduced rounds for short key */
	} CAST_KEY;

void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, const CAST_KEY *key,
		      int enc);
void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key);
void CAST_decrypt(CAST_LONG *data, const CAST_KEY *key);
void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
		      const CAST_KEY *ks, unsigned char *iv, int enc);
void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
			long length, const CAST_KEY *schedule, unsigned char *ivec,
			int *num, int enc);
void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, 
			long length, const CAST_KEY *schedule, unsigned char *ivec,
			int *num);

#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/Makefile.in0000664000175000017500000004210312437255271022125 0ustar  # Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@

# Copyright (C) 1994-2013 Free Software Foundation, Inc.

# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.

@SET_MAKE@

VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
  case $${target_option-} in \
      ?) ;; \
      *) echo "am__make_running_with_option: internal error: invalid" \
              "target option '$${target_option-}' specified" >&2; \
         exit 1;; \
  esac; \
  has_opt=no; \
  sane_makeflags=$$MAKEFLAGS; \
  if $(am__is_gnu_make); then \
    sane_makeflags=$$MFLAGS; \
  else \
    case $$MAKEFLAGS in \
      *\\[\ \	]*) \
        bs=\\; \
        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
    esac; \
  fi; \
  skip_next=no; \
  strip_trailopt () \
  { \
    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
  }; \
  for flg in $$sane_makeflags; do \
    test $$skip_next = yes && { skip_next=no; continue; }; \
    case $$flg in \
      *=*|--*) continue;; \
        -*I) strip_trailopt 'I'; skip_next=yes;; \
      -*I?*) strip_trailopt 'I';; \
        -*O) strip_trailopt 'O'; skip_next=yes;; \
      -*O?*) strip_trailopt 'O';; \
        -*l) strip_trailopt 'l'; skip_next=yes;; \
      -*l?*) strip_trailopt 'l';; \
      -[dEDm]) skip_next=yes;; \
      -[JT]) skip_next=yes;; \
    esac; \
    case $$flg in \
      *$$target_option*) has_opt=yes; break;; \
    esac; \
  done; \
  test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
DIST_COMMON = $(top_srcdir)/Makefile.am.common $(srcdir)/Makefile.in \
	$(srcdir)/Makefile.am $(opensslinclude_HEADERS)
subdir = include/openssl
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
	$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
	$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo "  GEN     " $@;
am__v_GEN_1 = 
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 = 
SOURCES =
DIST_SOURCES =
am__can_run_installinfo = \
  case $$AM_UPDATE_INFO_DIR in \
    n|no|NO) false;; \
    *) (install-info --version) >/dev/null 2>&1;; \
  esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
    *) f=$$p;; \
  esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
  for p in $$list; do echo "$$p $$p"; done | \
  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
    if (++n[$$2] == $(am__install_max)) \
      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
    END { for (dir in files) print dir, files[dir] }'
am__base_list = \
  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
  test -z "$$files" \
    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
         $(am__cd) "$$dir" && rm -f $$files; }; \
  }
am__installdirs = "$(DESTDIR)$(opensslincludedir)"
HEADERS = $(opensslinclude_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates.  Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
  BEGIN { nonempty = 0; } \
  { items[$$0] = 1; nonempty = 1; } \
  END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique.  This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
  list='$(am__tagged_files)'; \
  unique=`for i in $$list; do \
    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
  done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
NO_ARC4RANDOM_BUF = @NO_ARC4RANDOM_BUF@
NO_GETENTROPY = @NO_GETENTROPY@
NO_ISSETUGID = @NO_ISSETUGID@
NO_REALLOCARRAY = @NO_REALLOCARRAY@
NO_STRLCAT = @NO_STRLCAT@
NO_STRLCPY = @NO_STRLCPY@
NO_STRTONUM = @NO_STRTONUM@
NO_TIMINGSAFE_BCMP = @NO_TIMINGSAFE_BCMP@
NO_TIMINGSAFE_MEMCMP = @NO_TIMINGSAFE_MEMCMP@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PLATFORM_LDADD = @PLATFORM_LDADD@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
USER_CFLAGS = @USER_CFLAGS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CPPFLAGS = -I$(top_srcdir)/include -DOPENSSL_NO_ASM \
	-DHAVE_CRYPTODEV -DLIBRESSL_INTERNAL
opensslincludedir = $(includedir)/openssl
opensslinclude_HEADERS = aes.h asn1.h asn1_mac.h asn1t.h bio.h \
	blowfish.h bn.h buffer.h cast.h chacha.h cmac.h cms.h comp.h \
	conf.h conf_api.h crypto.h des.h dh.h dsa.h dso.h dtls1.h \
	e_os2.h ec.h ecdh.h ecdsa.h engine.h err.h evp.h hmac.h idea.h \
	krb5_asn.h lhash.h md4.h md5.h mdc2.h modes.h obj_mac.h \
	objects.h ocsp.h opensslconf.h opensslfeatures.h opensslv.h \
	ossl_typ.h pem.h pem2.h pkcs12.h pkcs7.h poly1305.h rand.h \
	rc2.h rc4.h rc5.h ripemd.h rsa.h safestack.h sha.h srtp.h \
	ssl.h ssl2.h ssl23.h ssl3.h stack.h tls1.h ts.h txt_db.h ui.h \
	ui_compat.h whrlpool.h x509.h x509_vfy.h x509v3.h
all: all-am

.SUFFIXES:
$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(top_srcdir)/Makefile.am.common $(am__configure_deps)
	@for dep in $?; do \
	  case '$(am__configure_deps)' in \
	    *$$dep*) \
	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
	        && { if test -f $@; then exit 0; else break; fi; }; \
	      exit 1;; \
	  esac; \
	done; \
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/openssl/Makefile'; \
	$(am__cd) $(top_srcdir) && \
	  $(AUTOMAKE) --gnu include/openssl/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
	@case '$?' in \
	  *config.status*) \
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
	  *) \
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
	esac;
$(top_srcdir)/Makefile.am.common:

$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh

$(top_srcdir)/configure:  $(am__configure_deps)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):

mostlyclean-libtool:
	-rm -f *.lo

clean-libtool:
	-rm -rf .libs _libs
install-opensslincludeHEADERS: $(opensslinclude_HEADERS)
	@$(NORMAL_INSTALL)
	@list='$(opensslinclude_HEADERS)'; test -n "$(opensslincludedir)" || list=; \
	if test -n "$$list"; then \
	  echo " $(MKDIR_P) '$(DESTDIR)$(opensslincludedir)'"; \
	  $(MKDIR_P) "$(DESTDIR)$(opensslincludedir)" || exit 1; \
	fi; \
	for p in $$list; do \
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
	  echo "$$d$$p"; \
	done | $(am__base_list) | \
	while read files; do \
	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(opensslincludedir)'"; \
	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(opensslincludedir)" || exit $$?; \
	done

uninstall-opensslincludeHEADERS:
	@$(NORMAL_UNINSTALL)
	@list='$(opensslinclude_HEADERS)'; test -n "$(opensslincludedir)" || list=; \
	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
	dir='$(DESTDIR)$(opensslincludedir)'; $(am__uninstall_files_from_dir)

ID: $(am__tagged_files)
	$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags

tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
	set x; \
	here=`pwd`; \
	$(am__define_uniq_tagged_files); \
	shift; \
	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
	  test -n "$$unique" || unique=$$empty_fix; \
	  if test $$# -gt 0; then \
	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
	      "$$@" $$unique; \
	  else \
	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
	      $$unique; \
	  fi; \
	fi
ctags: ctags-am

CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
	$(am__define_uniq_tagged_files); \
	test -z "$(CTAGS_ARGS)$$unique" \
	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
	     $$unique

GTAGS:
	here=`$(am__cd) $(top_builddir) && pwd` \
	  && $(am__cd) $(top_srcdir) \
	  && gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am

cscopelist-am: $(am__tagged_files)
	list='$(am__tagged_files)'; \
	case "$(srcdir)" in \
	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
	  *) sdir=$(subdir)/$(srcdir) ;; \
	esac; \
	for i in $$list; do \
	  if test -f "$$i"; then \
	    echo "$(subdir)/$$i"; \
	  else \
	    echo "$$sdir/$$i"; \
	  fi; \
	done >> $(top_builddir)/cscope.files

distclean-tags:
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags

distdir: $(DISTFILES)
	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
	list='$(DISTFILES)'; \
	  dist_files=`for file in $$list; do echo $$file; done | \
	  sed -e "s|^$$srcdirstrip/||;t" \
	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
	case $$dist_files in \
	  */*) $(MKDIR_P) `echo "$$dist_files" | \
			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
			   sort -u` ;; \
	esac; \
	for file in $$dist_files; do \
	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
	  if test -d $$d/$$file; then \
	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
	    if test -d "$(distdir)/$$file"; then \
	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
	    fi; \
	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
	    fi; \
	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
	  else \
	    test -f "$(distdir)/$$file" \
	    || cp -p $$d/$$file "$(distdir)/$$file" \
	    || exit 1; \
	  fi; \
	done
check-am: all-am
check: check-am
all-am: Makefile $(HEADERS)
installdirs:
	for dir in "$(DESTDIR)$(opensslincludedir)"; do \
	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
	done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am

install-am: all-am
	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am

installcheck: installcheck-am
install-strip:
	if test -z '$(STRIP)'; then \
	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
	      install; \
	else \
	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
	fi
mostlyclean-generic:

clean-generic:

distclean-generic:
	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)

maintainer-clean-generic:
	@echo "This command is intended for maintainers to use"
	@echo "it deletes files that may require special tools to rebuild."
clean: clean-am

clean-am: clean-generic clean-libtool mostlyclean-am

distclean: distclean-am
	-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags

dvi: dvi-am

dvi-am:

html: html-am

html-am:

info: info-am

info-am:

install-data-am: install-opensslincludeHEADERS

install-dvi: install-dvi-am

install-dvi-am:

install-exec-am:

install-html: install-html-am

install-html-am:

install-info: install-info-am

install-info-am:

install-man:

install-pdf: install-pdf-am

install-pdf-am:

install-ps: install-ps-am

install-ps-am:

installcheck-am:

maintainer-clean: maintainer-clean-am
	-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic

mostlyclean: mostlyclean-am

mostlyclean-am: mostlyclean-generic mostlyclean-libtool

pdf: pdf-am

pdf-am:

ps: ps-am

ps-am:

uninstall-am: uninstall-opensslincludeHEADERS

.MAKE: install-am install-strip

.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
	clean-libtool cscopelist-am ctags ctags-am distclean \
	distclean-generic distclean-libtool distclean-tags distdir dvi \
	dvi-am html html-am info info-am install install-am \
	install-data install-data-am install-dvi install-dvi-am \
	install-exec install-exec-am install-html install-html-am \
	install-info install-info-am install-man \
	install-opensslincludeHEADERS install-pdf install-pdf-am \
	install-ps install-ps-am install-strip installcheck \
	installcheck-am installdirs maintainer-clean \
	maintainer-clean-generic mostlyclean mostlyclean-generic \
	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
	uninstall-am uninstall-opensslincludeHEADERS


# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/rand.h0000644000175000017500000001171112360020705021137 0ustar  /* $OpenBSD: rand.h,v 1.20 2014/06/12 15:49:30 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#include 

#ifndef HEADER_RAND_H
#define HEADER_RAND_H

#include 

#include 

#ifdef  __cplusplus
extern "C" {
#endif

/* Already defined in ossl_typ.h */
/* typedef struct rand_meth_st RAND_METHOD; */

struct rand_meth_st {
	void (*seed)(const void *buf, int num);
	int (*bytes)(unsigned char *buf, int num);
	void (*cleanup)(void);
	void (*add)(const void *buf, int num, double entropy);
	int (*pseudorand)(unsigned char *buf, int num);
	int (*status)(void);
};

int RAND_set_rand_method(const RAND_METHOD *meth);
const RAND_METHOD *RAND_get_rand_method(void);
#ifndef OPENSSL_NO_ENGINE
int RAND_set_rand_engine(ENGINE *engine);
#endif
RAND_METHOD *RAND_SSLeay(void);
void RAND_cleanup(void );
int  RAND_bytes(unsigned char *buf, int num);
int  RAND_pseudo_bytes(unsigned char *buf, int num);
void RAND_seed(const void *buf, int num);
void RAND_add(const void *buf, int num, double entropy);
int  RAND_load_file(const char *file, long max_bytes);
int  RAND_write_file(const char *file);
const char *RAND_file_name(char *file, size_t num);
int RAND_status(void);
int RAND_poll(void);

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_RAND_strings(void);

/* Error codes for the RAND functions. (no longer used) */

/* Function codes. */
#define RAND_F_RAND_GET_RAND_METHOD			 101
#define RAND_F_RAND_INIT_FIPS				 102
#define RAND_F_SSLEAY_RAND_BYTES			 100

/* Reason codes. */
#define RAND_R_DUAL_EC_DRBG_DISABLED			 104
#define RAND_R_ERROR_INITIALISING_DRBG			 102
#define RAND_R_ERROR_INSTANTIATING_DRBG			 103
#define RAND_R_NO_FIPS_RANDOM_METHOD_SET		 101
#define RAND_R_PRNG_NOT_SEEDED				 100

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/rsa.h0000644000175000017500000005210112360020705020776 0ustar  /* $OpenBSD: rsa.h,v 1.24 2014/07/10 12:08:22 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_RSA_H
#define HEADER_RSA_H

#include 

#include 

#ifndef OPENSSL_NO_BIO
#include 
#endif
#include 
#include 
#ifndef OPENSSL_NO_DEPRECATED
#include 
#endif

#ifdef OPENSSL_NO_RSA
#error RSA is disabled.
#endif

#ifdef  __cplusplus
extern "C" {
#endif

/* Declared already in ossl_typ.h */
/* typedef struct rsa_st RSA; */
/* typedef struct rsa_meth_st RSA_METHOD; */

struct rsa_meth_st {
	const char *name;
	int (*rsa_pub_enc)(int flen, const unsigned char *from,
	    unsigned char *to, RSA *rsa, int padding);
	int (*rsa_pub_dec)(int flen, const unsigned char *from,
	    unsigned char *to, RSA *rsa, int padding);
	int (*rsa_priv_enc)(int flen, const unsigned char *from,
	    unsigned char *to, RSA *rsa, int padding);
	int (*rsa_priv_dec)(int flen, const unsigned char *from,
	    unsigned char *to, RSA *rsa, int padding);
	int (*rsa_mod_exp)(BIGNUM *r0, const BIGNUM *I, RSA *rsa,
	    BN_CTX *ctx); /* Can be null */
	int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
	    const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); /* Can be null */
	int (*init)(RSA *rsa);		/* called at new */
	int (*finish)(RSA *rsa);	/* called at free */
	int flags;			/* RSA_METHOD_FLAG_* things */
	char *app_data;			/* may be needed! */
/* New sign and verify functions: some libraries don't allow arbitrary data
 * to be signed/verified: this allows them to be used. Note: for this to work
 * the RSA_public_decrypt() and RSA_private_encrypt() should *NOT* be used
 * RSA_sign(), RSA_verify() should be used instead. Note: for backwards
 * compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER
 * option is set in 'flags'.
 */
	int (*rsa_sign)(int type, const unsigned char *m, unsigned int m_length,
	    unsigned char *sigret, unsigned int *siglen, const RSA *rsa);
	int (*rsa_verify)(int dtype, const unsigned char *m,
	    unsigned int m_length, const unsigned char *sigbuf,
	    unsigned int siglen, const RSA *rsa);
/* If this callback is NULL, the builtin software RSA key-gen will be used. This
 * is for behavioural compatibility whilst the code gets rewired, but one day
 * it would be nice to assume there are no such things as "builtin software"
 * implementations. */
	int (*rsa_keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
};

struct rsa_st {
	/* The first parameter is used to pickup errors where
	 * this is passed instead of aEVP_PKEY, it is set to 0 */
	int pad;
	long version;
	const RSA_METHOD *meth;
	/* functional reference if 'meth' is ENGINE-provided */
	ENGINE *engine;
	BIGNUM *n;
	BIGNUM *e;
	BIGNUM *d;
	BIGNUM *p;
	BIGNUM *q;
	BIGNUM *dmp1;
	BIGNUM *dmq1;
	BIGNUM *iqmp;
	/* be careful using this if the RSA structure is shared */
	CRYPTO_EX_DATA ex_data;
	int references;
	int flags;

	/* Used to cache montgomery values */
	BN_MONT_CTX *_method_mod_n;
	BN_MONT_CTX *_method_mod_p;
	BN_MONT_CTX *_method_mod_q;

	/* all BIGNUM values are actually in the following data, if it is not
	 * NULL */
	BN_BLINDING *blinding;
	BN_BLINDING *mt_blinding;
};

#ifndef OPENSSL_RSA_MAX_MODULUS_BITS
# define OPENSSL_RSA_MAX_MODULUS_BITS	16384
#endif

#ifndef OPENSSL_RSA_SMALL_MODULUS_BITS
# define OPENSSL_RSA_SMALL_MODULUS_BITS	3072
#endif
#ifndef OPENSSL_RSA_MAX_PUBEXP_BITS
# define OPENSSL_RSA_MAX_PUBEXP_BITS	64 /* exponent limit enforced for "large" modulus only */
#endif

#define RSA_3	0x3L
#define RSA_F4	0x10001L

/* Don't check pub/private match. */
#define RSA_METHOD_FLAG_NO_CHECK	0x0001

#define RSA_FLAG_CACHE_PUBLIC		0x0002
#define RSA_FLAG_CACHE_PRIVATE		0x0004
#define RSA_FLAG_BLINDING		0x0008
#define RSA_FLAG_THREAD_SAFE		0x0010

/*
 * This flag means the private key operations will be handled by rsa_mod_exp
 * and that they do not depend on the private key components being present:
 * for example a key stored in external hardware. Without this flag bn_mod_exp
 * gets called when private key components are absent.
 */
#define RSA_FLAG_EXT_PKEY		0x0020

/*
 * This flag in the RSA_METHOD enables the new rsa_sign, rsa_verify functions.
 */
#define RSA_FLAG_SIGN_VER		0x0040

/*
 * The built-in RSA implementation uses blinding by default, but other engines
 * might not need it.
 */
#define RSA_FLAG_NO_BLINDING		0x0080

/*
 * The built-in RSA implementation uses constant time operations by default
 * in private key operations, e.g., constant time modular exponentiation,
 * modular inverse without leaking branches, division without leaking branches.
 * This flag disables these constant time operations and results in faster RSA
 * private key operations.
 */
#define RSA_FLAG_NO_CONSTTIME		0x0100


#define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \
	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, EVP_PKEY_CTRL_RSA_PADDING, \
				pad, NULL)

#define EVP_PKEY_CTX_get_rsa_padding(ctx, ppad) \
	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, \
				EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad)

#define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \
	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \
				(EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \
				EVP_PKEY_CTRL_RSA_PSS_SALTLEN, \
				len, NULL)

#define EVP_PKEY_CTX_get_rsa_pss_saltlen(ctx, plen) \
	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \
				(EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \
				EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN, \
				0, plen)

#define EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) \
	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN, \
				EVP_PKEY_CTRL_RSA_KEYGEN_BITS, bits, NULL)

#define EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp) \
	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN, \
				EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, pubexp)

#define	 EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, md)	\
		EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_SIG,  \
				EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)md)

#define	 EVP_PKEY_CTX_get_rsa_mgf1_md(ctx, pmd)	\
		EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_SIG,  \
				EVP_PKEY_CTRL_GET_RSA_MGF1_MD, 0, (void *)pmd)

#define EVP_PKEY_CTRL_RSA_PADDING	(EVP_PKEY_ALG_CTRL + 1)
#define EVP_PKEY_CTRL_RSA_PSS_SALTLEN	(EVP_PKEY_ALG_CTRL + 2)

#define EVP_PKEY_CTRL_RSA_KEYGEN_BITS	(EVP_PKEY_ALG_CTRL + 3)
#define EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP	(EVP_PKEY_ALG_CTRL + 4)
#define EVP_PKEY_CTRL_RSA_MGF1_MD	(EVP_PKEY_ALG_CTRL + 5)

#define EVP_PKEY_CTRL_GET_RSA_PADDING		(EVP_PKEY_ALG_CTRL + 6)
#define EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN	(EVP_PKEY_ALG_CTRL + 7)
#define EVP_PKEY_CTRL_GET_RSA_MGF1_MD		(EVP_PKEY_ALG_CTRL + 8)

#define RSA_PKCS1_PADDING	1
#define RSA_SSLV23_PADDING	2
#define RSA_NO_PADDING		3
#define RSA_PKCS1_OAEP_PADDING	4
#define RSA_X931_PADDING	5
/* EVP_PKEY_ only */
#define RSA_PKCS1_PSS_PADDING	6

#define RSA_PKCS1_PADDING_SIZE	11

#define RSA_set_app_data(s,arg)         RSA_set_ex_data(s,0,arg)
#define RSA_get_app_data(s)             RSA_get_ex_data(s,0)

RSA *RSA_new(void);
RSA *RSA_new_method(ENGINE *engine);
int RSA_size(const RSA *rsa);

/* Deprecated version */
#ifndef OPENSSL_NO_DEPRECATED
RSA *RSA_generate_key(int bits, unsigned long e,
    void (*callback)(int, int, void *), void *cb_arg);
#endif /* !defined(OPENSSL_NO_DEPRECATED) */

/* New version */
int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);

int RSA_check_key(const RSA *);
/* next 4 return -1 on error */
int RSA_public_encrypt(int flen, const unsigned char *from,
    unsigned char *to, RSA *rsa, int padding);
int RSA_private_encrypt(int flen, const unsigned char *from,
    unsigned char *to, RSA *rsa, int padding);
int RSA_public_decrypt(int flen, const unsigned char *from,
    unsigned char *to, RSA *rsa, int padding);
int RSA_private_decrypt(int flen, const unsigned char *from,
    unsigned char *to, RSA *rsa, int padding);
void RSA_free (RSA *r);
/* "up" the RSA object's reference count */
int RSA_up_ref(RSA *r);

int RSA_flags(const RSA *r);

void RSA_set_default_method(const RSA_METHOD *meth);
const RSA_METHOD *RSA_get_default_method(void);
const RSA_METHOD *RSA_get_method(const RSA *rsa);
int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);

/* these are the actual SSLeay RSA functions */
const RSA_METHOD *RSA_PKCS1_SSLeay(void);

const RSA_METHOD *RSA_null_method(void);

DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey)
DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey)

typedef struct rsa_pss_params_st {
	X509_ALGOR *hashAlgorithm;
	X509_ALGOR *maskGenAlgorithm;
	ASN1_INTEGER *saltLength;
	ASN1_INTEGER *trailerField;
} RSA_PSS_PARAMS;

DECLARE_ASN1_FUNCTIONS(RSA_PSS_PARAMS)

int RSA_print_fp(FILE *fp, const RSA *r, int offset);

#ifndef OPENSSL_NO_BIO
int RSA_print(BIO *bp, const RSA *r, int offset);
#endif

#ifndef OPENSSL_NO_RC4
int i2d_RSA_NET(const RSA *a, unsigned char **pp,
    int (*cb)(char *buf, int len, const char *prompt, int verify), int sgckey);
RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length,
    int (*cb)(char *buf, int len, const char *prompt, int verify), int sgckey);

int i2d_Netscape_RSA(const RSA *a, unsigned char **pp,
    int (*cb)(char *buf, int len, const char *prompt, int verify));
RSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length,
    int (*cb)(char *buf, int len, const char *prompt, int verify));
#endif

/* The following 2 functions sign and verify a X509_SIG ASN1 object
 * inside PKCS#1 padded RSA encryption */
int RSA_sign(int type, const unsigned char *m, unsigned int m_length,
    unsigned char *sigret, unsigned int *siglen, RSA *rsa);
int RSA_verify(int type, const unsigned char *m, unsigned int m_length,
    const unsigned char *sigbuf, unsigned int siglen, RSA *rsa);

/* The following 2 function sign and verify a ASN1_OCTET_STRING
 * object inside PKCS#1 padded RSA encryption */
int RSA_sign_ASN1_OCTET_STRING(int type, const unsigned char *m,
    unsigned int m_length, unsigned char *sigret, unsigned int *siglen,
    RSA *rsa);
int RSA_verify_ASN1_OCTET_STRING(int type, const unsigned char *m,
    unsigned int m_length, unsigned char *sigbuf, unsigned int siglen,
    RSA *rsa);

int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
void RSA_blinding_off(RSA *rsa);
BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx);

int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
    const unsigned char *f, int fl);
int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
    const unsigned char *f, int fl, int rsa_len);
int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
    const unsigned char *f, int fl);
int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
    const unsigned char *f, int fl, int rsa_len);
int PKCS1_MGF1(unsigned char *mask, long len,
    const unsigned char *seed, long seedlen, const EVP_MD *dgst);
int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
    const unsigned char *f, int fl,
    const unsigned char *p, int pl);
int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
    const unsigned char *f, int fl, int rsa_len,
    const unsigned char *p, int pl);
int RSA_padding_add_SSLv23(unsigned char *to, int tlen,
    const unsigned char *f, int fl);
int RSA_padding_check_SSLv23(unsigned char *to, int tlen,
    const unsigned char *f, int fl, int rsa_len);
int RSA_padding_add_none(unsigned char *to, int tlen,
    const unsigned char *f, int fl);
int RSA_padding_check_none(unsigned char *to, int tlen,
    const unsigned char *f, int fl, int rsa_len);
int RSA_padding_add_X931(unsigned char *to, int tlen,
    const unsigned char *f, int fl);
int RSA_padding_check_X931(unsigned char *to, int tlen,
    const unsigned char *f, int fl, int rsa_len);
int RSA_X931_hash_id(int nid);

int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash,
    const EVP_MD *Hash, const unsigned char *EM, int sLen);
int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,
    const unsigned char *mHash, const EVP_MD *Hash, int sLen);

int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash,
    const EVP_MD *Hash, const EVP_MD *mgf1Hash, const unsigned char *EM,
    int sLen);

int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM,
    const unsigned char *mHash, const EVP_MD *Hash, const EVP_MD *mgf1Hash,
    int sLen);

int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
    CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
int RSA_set_ex_data(RSA *r, int idx, void *arg);
void *RSA_get_ex_data(const RSA *r, int idx);

RSA *RSAPublicKey_dup(RSA *rsa);
RSA *RSAPrivateKey_dup(RSA *rsa);

/* If this flag is set the RSA method is FIPS compliant and can be used
 * in FIPS mode. This is set in the validated module method. If an
 * application sets this flag in its own methods it is its responsibility
 * to ensure the result is compliant.
 */

#define RSA_FLAG_FIPS_METHOD			0x0400

/* If this flag is set the operations normally disabled in FIPS mode are
 * permitted it is then the applications responsibility to ensure that the
 * usage is compliant.
 */

#define RSA_FLAG_NON_FIPS_ALLOW			0x0400
/* Application has decided PRNG is good enough to generate a key: don't
 * check.
 */
#define RSA_FLAG_CHECKED			0x0800

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_RSA_strings(void);

/* Error codes for the RSA functions. */

/* Function codes. */
#define RSA_F_CHECK_PADDING_MD				 140
#define RSA_F_DO_RSA_PRINT				 146
#define RSA_F_INT_RSA_VERIFY				 145
#define RSA_F_MEMORY_LOCK				 100
#define RSA_F_OLD_RSA_PRIV_DECODE			 147
#define RSA_F_PKEY_RSA_CTRL				 143
#define RSA_F_PKEY_RSA_CTRL_STR				 144
#define RSA_F_PKEY_RSA_SIGN				 142
#define RSA_F_PKEY_RSA_VERIFY				 154
#define RSA_F_PKEY_RSA_VERIFYRECOVER			 141
#define RSA_F_RSA_BUILTIN_KEYGEN			 129
#define RSA_F_RSA_CHECK_KEY				 123
#define RSA_F_RSA_EAY_PRIVATE_DECRYPT			 101
#define RSA_F_RSA_EAY_PRIVATE_ENCRYPT			 102
#define RSA_F_RSA_EAY_PUBLIC_DECRYPT			 103
#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT			 104
#define RSA_F_RSA_GENERATE_KEY				 105
#define RSA_F_RSA_GENERATE_KEY_EX			 155
#define RSA_F_RSA_ITEM_VERIFY				 156
#define RSA_F_RSA_MEMORY_LOCK				 130
#define RSA_F_RSA_NEW_METHOD				 106
#define RSA_F_RSA_NULL					 124
#define RSA_F_RSA_NULL_MOD_EXP				 131
#define RSA_F_RSA_NULL_PRIVATE_DECRYPT			 132
#define RSA_F_RSA_NULL_PRIVATE_ENCRYPT			 133
#define RSA_F_RSA_NULL_PUBLIC_DECRYPT			 134
#define RSA_F_RSA_NULL_PUBLIC_ENCRYPT			 135
#define RSA_F_RSA_PADDING_ADD_NONE			 107
#define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP		 121
#define RSA_F_RSA_PADDING_ADD_PKCS1_PSS			 125
#define RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1		 148
#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1		 108
#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2		 109
#define RSA_F_RSA_PADDING_ADD_SSLV23			 110
#define RSA_F_RSA_PADDING_ADD_X931			 127
#define RSA_F_RSA_PADDING_CHECK_NONE			 111
#define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP		 122
#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1		 112
#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2		 113
#define RSA_F_RSA_PADDING_CHECK_SSLV23			 114
#define RSA_F_RSA_PADDING_CHECK_X931			 128
#define RSA_F_RSA_PRINT					 115
#define RSA_F_RSA_PRINT_FP				 116
#define RSA_F_RSA_PRIVATE_DECRYPT			 150
#define RSA_F_RSA_PRIVATE_ENCRYPT			 151
#define RSA_F_RSA_PRIV_DECODE				 137
#define RSA_F_RSA_PRIV_ENCODE				 138
#define RSA_F_RSA_PUBLIC_DECRYPT			 152
#define RSA_F_RSA_PUBLIC_ENCRYPT			 153
#define RSA_F_RSA_PUB_DECODE				 139
#define RSA_F_RSA_SETUP_BLINDING			 136
#define RSA_F_RSA_SIGN					 117
#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING		 118
#define RSA_F_RSA_VERIFY				 119
#define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING		 120
#define RSA_F_RSA_VERIFY_PKCS1_PSS			 126
#define RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1			 149

/* Reason codes. */
#define RSA_R_ALGORITHM_MISMATCH			 100
#define RSA_R_BAD_E_VALUE				 101
#define RSA_R_BAD_FIXED_HEADER_DECRYPT			 102
#define RSA_R_BAD_PAD_BYTE_COUNT			 103
#define RSA_R_BAD_SIGNATURE				 104
#define RSA_R_BLOCK_TYPE_IS_NOT_01			 106
#define RSA_R_BLOCK_TYPE_IS_NOT_02			 107
#define RSA_R_DATA_GREATER_THAN_MOD_LEN			 108
#define RSA_R_DATA_TOO_LARGE				 109
#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE		 110
#define RSA_R_DATA_TOO_LARGE_FOR_MODULUS		 132
#define RSA_R_DATA_TOO_SMALL				 111
#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE		 122
#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY		 112
#define RSA_R_DMP1_NOT_CONGRUENT_TO_D			 124
#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D			 125
#define RSA_R_D_E_NOT_CONGRUENT_TO_1			 123
#define RSA_R_FIRST_OCTET_INVALID			 133
#define RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE	 144
#define RSA_R_INVALID_DIGEST_LENGTH			 143
#define RSA_R_INVALID_HEADER				 137
#define RSA_R_INVALID_KEYBITS				 145
#define RSA_R_INVALID_MESSAGE_LENGTH			 131
#define RSA_R_INVALID_MGF1_MD				 156
#define RSA_R_INVALID_PADDING				 138
#define RSA_R_INVALID_PADDING_MODE			 141
#define RSA_R_INVALID_PSS_PARAMETERS			 149
#define RSA_R_INVALID_PSS_SALTLEN			 146
#define RSA_R_INVALID_SALT_LENGTH			 150
#define RSA_R_INVALID_TRAILER				 139
#define RSA_R_INVALID_X931_DIGEST			 142
#define RSA_R_IQMP_NOT_INVERSE_OF_Q			 126
#define RSA_R_KEY_SIZE_TOO_SMALL			 120
#define RSA_R_LAST_OCTET_INVALID			 134
#define RSA_R_MODULUS_TOO_LARGE				 105
#define RSA_R_NON_FIPS_RSA_METHOD			 157
#define RSA_R_NO_PUBLIC_EXPONENT			 140
#define RSA_R_NULL_BEFORE_BLOCK_MISSING			 113
#define RSA_R_N_DOES_NOT_EQUAL_P_Q			 127
#define RSA_R_OAEP_DECODING_ERROR			 121
#define RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE	 158
#define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE	 148
#define RSA_R_PADDING_CHECK_FAILED			 114
#define RSA_R_P_NOT_PRIME				 128
#define RSA_R_Q_NOT_PRIME				 129
#define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED		 130
#define RSA_R_SLEN_CHECK_FAILED				 136
#define RSA_R_SLEN_RECOVERY_FAILED			 135
#define RSA_R_SSLV3_ROLLBACK_ATTACK			 115
#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116
#define RSA_R_UNKNOWN_ALGORITHM_TYPE			 117
#define RSA_R_UNKNOWN_MASK_DIGEST			 151
#define RSA_R_UNKNOWN_PADDING_TYPE			 118
#define RSA_R_UNKNOWN_PSS_DIGEST			 152
#define RSA_R_UNSUPPORTED_MASK_ALGORITHM		 153
#define RSA_R_UNSUPPORTED_MASK_PARAMETER		 154
#define RSA_R_UNSUPPORTED_SIGNATURE_TYPE		 155
#define RSA_R_VALUE_MISSING				 147
#define RSA_R_WRONG_SIGNATURE_LENGTH			 119

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/md4.h0000644000175000017500000001020412360020705020673 0ustar  /* $OpenBSD: md4.h,v 1.12 2014/07/10 09:01:04 miod Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#include 

#ifndef HEADER_MD4_H
#define HEADER_MD4_H

#include 

#ifdef  __cplusplus
extern "C" {
#endif

#ifdef OPENSSL_NO_MD4
#error MD4 is disabled.
#endif

/*
 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 * ! MD4_LONG has to be at least 32 bits wide. If it's wider, then !
 * ! MD4_LONG_LOG2 has to be defined along.			   !
 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 */

#define MD4_LONG unsigned int

#define MD4_CBLOCK	64
#define MD4_LBLOCK	(MD4_CBLOCK/4)
#define MD4_DIGEST_LENGTH 16

typedef struct MD4state_st
	{
	MD4_LONG A,B,C,D;
	MD4_LONG Nl,Nh;
	MD4_LONG data[MD4_LBLOCK];
	unsigned int num;
	} MD4_CTX;

int MD4_Init(MD4_CTX *c);
int MD4_Update(MD4_CTX *c, const void *data, size_t len);
int MD4_Final(unsigned char *md, MD4_CTX *c);
unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md);
void MD4_Transform(MD4_CTX *c, const unsigned char *b);
#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/ssl3.h0000644000175000017500000006237012360020705021106 0ustar  /* $OpenBSD: ssl3.h,v 1.24 2014/07/10 08:51:15 tedu Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */
/* ====================================================================
 * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */
/* ====================================================================
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 * ECC cipher suite support in OpenSSL originally developed by 
 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
 */

#ifndef HEADER_SSL3_H 
#define HEADER_SSL3_H 

#include 
#include 
#include 

#ifdef  __cplusplus
extern "C" {
#endif

/* Signalling cipher suite value: from draft-ietf-tls-renegotiation-03.txt */
#define SSL3_CK_SCSV				0x030000FF

#define SSL3_CK_RSA_NULL_MD5			0x03000001
#define SSL3_CK_RSA_NULL_SHA			0x03000002
#define SSL3_CK_RSA_RC4_40_MD5 			0x03000003
#define SSL3_CK_RSA_RC4_128_MD5			0x03000004
#define SSL3_CK_RSA_RC4_128_SHA			0x03000005
#define SSL3_CK_RSA_RC2_40_MD5			0x03000006
#define SSL3_CK_RSA_IDEA_128_SHA		0x03000007
#define SSL3_CK_RSA_DES_40_CBC_SHA		0x03000008
#define SSL3_CK_RSA_DES_64_CBC_SHA		0x03000009
#define SSL3_CK_RSA_DES_192_CBC3_SHA		0x0300000A

#define SSL3_CK_DH_DSS_DES_40_CBC_SHA		0x0300000B
#define SSL3_CK_DH_DSS_DES_64_CBC_SHA		0x0300000C
#define SSL3_CK_DH_DSS_DES_192_CBC3_SHA 	0x0300000D
#define SSL3_CK_DH_RSA_DES_40_CBC_SHA		0x0300000E
#define SSL3_CK_DH_RSA_DES_64_CBC_SHA		0x0300000F
#define SSL3_CK_DH_RSA_DES_192_CBC3_SHA 	0x03000010

#define SSL3_CK_EDH_DSS_DES_40_CBC_SHA		0x03000011
#define SSL3_CK_EDH_DSS_DES_64_CBC_SHA		0x03000012
#define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA	0x03000013
#define SSL3_CK_EDH_RSA_DES_40_CBC_SHA		0x03000014
#define SSL3_CK_EDH_RSA_DES_64_CBC_SHA		0x03000015
#define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA	0x03000016

#define SSL3_CK_ADH_RC4_40_MD5			0x03000017
#define SSL3_CK_ADH_RC4_128_MD5			0x03000018
#define SSL3_CK_ADH_DES_40_CBC_SHA		0x03000019
#define SSL3_CK_ADH_DES_64_CBC_SHA		0x0300001A
#define SSL3_CK_ADH_DES_192_CBC_SHA		0x0300001B

/*    VRS Additional Kerberos5 entries
 */
#define SSL3_CK_KRB5_DES_64_CBC_SHA		0x0300001E
#define SSL3_CK_KRB5_DES_192_CBC3_SHA		0x0300001F
#define SSL3_CK_KRB5_RC4_128_SHA		0x03000020
#define SSL3_CK_KRB5_IDEA_128_CBC_SHA	       	0x03000021
#define SSL3_CK_KRB5_DES_64_CBC_MD5       	0x03000022
#define SSL3_CK_KRB5_DES_192_CBC3_MD5       	0x03000023
#define SSL3_CK_KRB5_RC4_128_MD5	       	0x03000024
#define SSL3_CK_KRB5_IDEA_128_CBC_MD5 		0x03000025

#define SSL3_CK_KRB5_DES_40_CBC_SHA 		0x03000026
#define SSL3_CK_KRB5_RC2_40_CBC_SHA 		0x03000027
#define SSL3_CK_KRB5_RC4_40_SHA	 		0x03000028
#define SSL3_CK_KRB5_DES_40_CBC_MD5 		0x03000029
#define SSL3_CK_KRB5_RC2_40_CBC_MD5 		0x0300002A
#define SSL3_CK_KRB5_RC4_40_MD5	 		0x0300002B

#define SSL3_TXT_RSA_NULL_MD5			"NULL-MD5"
#define SSL3_TXT_RSA_NULL_SHA			"NULL-SHA"
#define SSL3_TXT_RSA_RC4_40_MD5 		"EXP-RC4-MD5"
#define SSL3_TXT_RSA_RC4_128_MD5		"RC4-MD5"
#define SSL3_TXT_RSA_RC4_128_SHA		"RC4-SHA"
#define SSL3_TXT_RSA_RC2_40_MD5			"EXP-RC2-CBC-MD5"
#define SSL3_TXT_RSA_IDEA_128_SHA		"IDEA-CBC-SHA"
#define SSL3_TXT_RSA_DES_40_CBC_SHA		"EXP-DES-CBC-SHA"
#define SSL3_TXT_RSA_DES_64_CBC_SHA		"DES-CBC-SHA"
#define SSL3_TXT_RSA_DES_192_CBC3_SHA		"DES-CBC3-SHA"

#define SSL3_TXT_DH_DSS_DES_40_CBC_SHA		"EXP-DH-DSS-DES-CBC-SHA"
#define SSL3_TXT_DH_DSS_DES_64_CBC_SHA		"DH-DSS-DES-CBC-SHA"
#define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA 	"DH-DSS-DES-CBC3-SHA"
#define SSL3_TXT_DH_RSA_DES_40_CBC_SHA		"EXP-DH-RSA-DES-CBC-SHA"
#define SSL3_TXT_DH_RSA_DES_64_CBC_SHA		"DH-RSA-DES-CBC-SHA"
#define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA 	"DH-RSA-DES-CBC3-SHA"

#define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA		"EXP-EDH-DSS-DES-CBC-SHA"
#define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA		"EDH-DSS-DES-CBC-SHA"
#define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA	"EDH-DSS-DES-CBC3-SHA"
#define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA		"EXP-EDH-RSA-DES-CBC-SHA"
#define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA		"EDH-RSA-DES-CBC-SHA"
#define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA	"EDH-RSA-DES-CBC3-SHA"

#define SSL3_TXT_ADH_RC4_40_MD5			"EXP-ADH-RC4-MD5"
#define SSL3_TXT_ADH_RC4_128_MD5		"ADH-RC4-MD5"
#define SSL3_TXT_ADH_DES_40_CBC_SHA		"EXP-ADH-DES-CBC-SHA"
#define SSL3_TXT_ADH_DES_64_CBC_SHA		"ADH-DES-CBC-SHA"
#define SSL3_TXT_ADH_DES_192_CBC_SHA		"ADH-DES-CBC3-SHA"

#define SSL3_TXT_KRB5_DES_64_CBC_SHA		"KRB5-DES-CBC-SHA"
#define SSL3_TXT_KRB5_DES_192_CBC3_SHA		"KRB5-DES-CBC3-SHA"
#define SSL3_TXT_KRB5_RC4_128_SHA		"KRB5-RC4-SHA"
#define SSL3_TXT_KRB5_IDEA_128_CBC_SHA	       	"KRB5-IDEA-CBC-SHA"
#define SSL3_TXT_KRB5_DES_64_CBC_MD5       	"KRB5-DES-CBC-MD5"
#define SSL3_TXT_KRB5_DES_192_CBC3_MD5       	"KRB5-DES-CBC3-MD5"
#define SSL3_TXT_KRB5_RC4_128_MD5		"KRB5-RC4-MD5"
#define SSL3_TXT_KRB5_IDEA_128_CBC_MD5 		"KRB5-IDEA-CBC-MD5"

#define SSL3_TXT_KRB5_DES_40_CBC_SHA 		"EXP-KRB5-DES-CBC-SHA"
#define SSL3_TXT_KRB5_RC2_40_CBC_SHA 		"EXP-KRB5-RC2-CBC-SHA"
#define SSL3_TXT_KRB5_RC4_40_SHA	 	"EXP-KRB5-RC4-SHA"
#define SSL3_TXT_KRB5_DES_40_CBC_MD5 		"EXP-KRB5-DES-CBC-MD5"
#define SSL3_TXT_KRB5_RC2_40_CBC_MD5 		"EXP-KRB5-RC2-CBC-MD5"
#define SSL3_TXT_KRB5_RC4_40_MD5	 	"EXP-KRB5-RC4-MD5"

#define SSL3_SSL_SESSION_ID_LENGTH		32
#define SSL3_MAX_SSL_SESSION_ID_LENGTH		32

#define SSL3_MASTER_SECRET_SIZE			48
#define SSL3_RANDOM_SIZE			32
#define SSL3_SEQUENCE_SIZE			8
#define SSL3_SESSION_ID_SIZE			32
#define SSL3_RT_HEADER_LENGTH			5

#ifndef SSL3_ALIGN_PAYLOAD
 /* Some will argue that this increases memory footprint, but it's
  * not actually true. Point is that malloc has to return at least
  * 64-bit aligned pointers, meaning that allocating 5 bytes wastes
  * 3 bytes in either case. Suggested pre-gaping simply moves these
  * wasted bytes from the end of allocated region to its front,
  * but makes data payload aligned, which improves performance:-) */
# define SSL3_ALIGN_PAYLOAD			8
#else
# if (SSL3_ALIGN_PAYLOAD&(SSL3_ALIGN_PAYLOAD-1))!=0
#  error "insane SSL3_ALIGN_PAYLOAD"
#  undef SSL3_ALIGN_PAYLOAD
# endif
#endif

/* This is the maximum MAC (digest) size used by the SSL library.
 * Currently maximum of 20 is used by SHA1, but we reserve for
 * future extension for 512-bit hashes.
 */

#define SSL3_RT_MAX_MD_SIZE			64

/* Maximum block size used in all ciphersuites. Currently 16 for AES.
 */

#define	SSL_RT_MAX_CIPHER_BLOCK_SIZE		16

#define SSL3_RT_MAX_EXTRA			(16384)

/* Maximum plaintext length: defined by SSL/TLS standards */
#define SSL3_RT_MAX_PLAIN_LENGTH		16384
/* Maximum compression overhead: defined by SSL/TLS standards */
#define SSL3_RT_MAX_COMPRESSED_OVERHEAD		1024

/* The standards give a maximum encryption overhead of 1024 bytes.
 * In practice the value is lower than this. The overhead is the maximum
 * number of padding bytes (256) plus the mac size.
 */
#define SSL3_RT_MAX_ENCRYPTED_OVERHEAD	(256 + SSL3_RT_MAX_MD_SIZE)

/* OpenSSL currently only uses a padding length of at most one block so
 * the send overhead is smaller.
 */

#define SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD \
			(SSL_RT_MAX_CIPHER_BLOCK_SIZE + SSL3_RT_MAX_MD_SIZE)

/* If compression isn't used don't include the compression overhead */
#define SSL3_RT_MAX_COMPRESSED_LENGTH		SSL3_RT_MAX_PLAIN_LENGTH
#define SSL3_RT_MAX_ENCRYPTED_LENGTH	\
		(SSL3_RT_MAX_ENCRYPTED_OVERHEAD+SSL3_RT_MAX_COMPRESSED_LENGTH)
#define SSL3_RT_MAX_PACKET_SIZE		\
		(SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH)

#define SSL3_MD_CLIENT_FINISHED_CONST	"\x43\x4C\x4E\x54"
#define SSL3_MD_SERVER_FINISHED_CONST	"\x53\x52\x56\x52"

#define SSL3_VERSION			0x0300
#define SSL3_VERSION_MAJOR		0x03
#define SSL3_VERSION_MINOR		0x00

#define SSL3_RT_CHANGE_CIPHER_SPEC	20
#define SSL3_RT_ALERT			21
#define SSL3_RT_HANDSHAKE		22
#define SSL3_RT_APPLICATION_DATA	23
#define TLS1_RT_HEARTBEAT		24

#define SSL3_AL_WARNING			1
#define SSL3_AL_FATAL			2

#define SSL3_AD_CLOSE_NOTIFY		 0
#define SSL3_AD_UNEXPECTED_MESSAGE	10	/* fatal */
#define SSL3_AD_BAD_RECORD_MAC		20	/* fatal */
#define SSL3_AD_DECOMPRESSION_FAILURE	30	/* fatal */
#define SSL3_AD_HANDSHAKE_FAILURE	40	/* fatal */
#define SSL3_AD_NO_CERTIFICATE		41
#define SSL3_AD_BAD_CERTIFICATE		42
#define SSL3_AD_UNSUPPORTED_CERTIFICATE	43
#define SSL3_AD_CERTIFICATE_REVOKED	44
#define SSL3_AD_CERTIFICATE_EXPIRED	45
#define SSL3_AD_CERTIFICATE_UNKNOWN	46
#define SSL3_AD_ILLEGAL_PARAMETER	47	/* fatal */

#define TLS1_HB_REQUEST		1
#define TLS1_HB_RESPONSE	2

#ifndef OPENSSL_NO_SSL_INTERN

typedef struct ssl3_record_st {
/*r */	int type;               /* type of record */
/*rw*/	unsigned int length;    /* How many bytes available */
/*r */	unsigned int off;       /* read/write offset into 'buf' */
/*rw*/	unsigned char *data;    /* pointer to the record data */
/*rw*/	unsigned char *input;   /* where the decode bytes are */
/*r */  unsigned long epoch;    /* epoch number, needed by DTLS1 */
/*r */  unsigned char seq_num[8]; /* sequence number, needed by DTLS1 */
} SSL3_RECORD;

typedef struct ssl3_buffer_st {
	unsigned char *buf;	/* at least SSL3_RT_MAX_PACKET_SIZE bytes,
	                         * see ssl3_setup_buffers() */
	size_t len;		/* buffer size */
	int offset;		/* where to 'copy from' */
	int left;		/* how many bytes left */
} SSL3_BUFFER;

#endif

#define SSL3_CT_RSA_SIGN			1
#define SSL3_CT_DSS_SIGN			2
#define SSL3_CT_RSA_FIXED_DH			3
#define SSL3_CT_DSS_FIXED_DH			4
#define SSL3_CT_RSA_EPHEMERAL_DH		5
#define SSL3_CT_DSS_EPHEMERAL_DH		6
#define SSL3_CT_FORTEZZA_DMS			20
/* SSL3_CT_NUMBER is used to size arrays and it must be large
 * enough to contain all of the cert types defined either for
 * SSLv3 and TLSv1.
 */
#define SSL3_CT_NUMBER			9


#define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS	0x0001
#define SSL3_FLAGS_DELAY_CLIENT_FINISHED	0x0002
#define SSL3_FLAGS_POP_BUFFER			0x0004
#define TLS1_FLAGS_TLS_PADDING_BUG		0x0008
#define TLS1_FLAGS_SKIP_CERT_VERIFY		0x0010
#define TLS1_FLAGS_KEEP_HANDSHAKE		0x0020
#define SSL3_FLAGS_CCS_OK			0x0080

/* SSL3_FLAGS_SGC_RESTART_DONE is set when we
 * restart a handshake because of MS SGC and so prevents us
 * from restarting the handshake in a loop. It's reset on a
 * renegotiation, so effectively limits the client to one restart
 * per negotiation. This limits the possibility of a DDoS
 * attack where the client handshakes in a loop using SGC to
 * restart. Servers which permit renegotiation can still be
 * effected, but we can't prevent that.
 */
#define SSL3_FLAGS_SGC_RESTART_DONE		0x0040

#ifndef OPENSSL_NO_SSL_INTERN

typedef struct ssl3_state_st {
	long flags;
	int delay_buf_pop_ret;

	unsigned char read_sequence[SSL3_SEQUENCE_SIZE];
	int read_mac_secret_size;
	unsigned char read_mac_secret[EVP_MAX_MD_SIZE];
	unsigned char write_sequence[SSL3_SEQUENCE_SIZE];
	int write_mac_secret_size;
	unsigned char write_mac_secret[EVP_MAX_MD_SIZE];

	unsigned char server_random[SSL3_RANDOM_SIZE];
	unsigned char client_random[SSL3_RANDOM_SIZE];

	/* flags for countermeasure against known-IV weakness */
	int need_empty_fragments;
	int empty_fragment_done;

	/* The value of 'extra' when the buffers were initialized */
	int init_extra;

	SSL3_BUFFER rbuf;	/* read IO goes into here */
	SSL3_BUFFER wbuf;	/* write IO goes into here */

	SSL3_RECORD rrec;	/* each decoded record goes in here */
	SSL3_RECORD wrec;	/* goes out from here */

	/* storage for Alert/Handshake protocol data received but not
	 * yet processed by ssl3_read_bytes: */
	unsigned char alert_fragment[2];
	unsigned int alert_fragment_len;
	unsigned char handshake_fragment[4];
	unsigned int handshake_fragment_len;

	/* partial write - check the numbers match */
	unsigned int wnum;	/* number of bytes sent so far */
	int wpend_tot;		/* number bytes written */
	int wpend_type;
	int wpend_ret;		/* number of bytes submitted */
	const unsigned char *wpend_buf;

	/* used during startup, digest all incoming/outgoing packets */
	BIO *handshake_buffer;
	/* When set of handshake digests is determined, buffer is hashed
	 * and freed and MD_CTX-es for all required digests are stored in
	 * this array */
	EVP_MD_CTX **handshake_dgst;
	/* this is set whenerver we see a change_cipher_spec message
	 * come in when we are not looking for one */
	int change_cipher_spec;

	int warn_alert;
	int fatal_alert;
	/* we allow one fatal and one warning alert to be outstanding,
	 * send close alert via the warning alert */
	int alert_dispatch;
	unsigned char send_alert[2];

	/* This flag is set when we should renegotiate ASAP, basically when
	 * there is no more data in the read or write buffers */
	int renegotiate;
	int total_renegotiations;
	int num_renegotiations;

	int in_read_app_data;

	struct	{
		/* actually only needs to be 16+20 */
		unsigned char cert_verify_md[EVP_MAX_MD_SIZE*2];

		/* actually only need to be 16+20 for SSLv3 and 12 for TLS */
		unsigned char finish_md[EVP_MAX_MD_SIZE*2];
		int finish_md_len;
		unsigned char peer_finish_md[EVP_MAX_MD_SIZE*2];
		int peer_finish_md_len;

		unsigned long message_size;
		int message_type;

		/* used to hold the new cipher we are going to use */
		const SSL_CIPHER *new_cipher;
		DH *dh;

		EC_KEY *ecdh; /* holds short lived ECDH key */

		/* used when SSL_ST_FLUSH_DATA is entered */
		int next_state;

		int reuse_message;

		/* used for certificate requests */
		int cert_req;
		int ctype_num;
		char ctype[SSL3_CT_NUMBER];
		STACK_OF(X509_NAME) *ca_names;

		int use_rsa_tmp;

		int key_block_length;
		unsigned char *key_block;

		const EVP_CIPHER *new_sym_enc;
		const EVP_AEAD *new_aead;
		const EVP_MD *new_hash;
		int new_mac_pkey_type;
		int new_mac_secret_size;
		int cert_request;
	} tmp;

	/* Connection binding to prevent renegotiation attacks */
	unsigned char previous_client_finished[EVP_MAX_MD_SIZE];
	unsigned char previous_client_finished_len;
	unsigned char previous_server_finished[EVP_MAX_MD_SIZE];
	unsigned char previous_server_finished_len;
	int send_connection_binding; /* TODOEKR */

#ifndef OPENSSL_NO_NEXTPROTONEG
	/* Set if we saw the Next Protocol Negotiation extension from our peer.
	 */
	int next_proto_neg_seen;
#endif

	/* This is set to true if we believe that this is a version of Safari
	 * running on OS X 10.6 or newer. We wish to know this because Safari
	 * on 10.8 .. 10.8.3 has broken ECDHE-ECDSA support. */
	char is_probably_safari;
} SSL3_STATE;

#endif

/* SSLv3 */
/*client */
/* extra state */
#define SSL3_ST_CW_FLUSH			(0x100|SSL_ST_CONNECT)
#ifndef OPENSSL_NO_SCTP
#define DTLS1_SCTP_ST_CW_WRITE_SOCK		(0x310|SSL_ST_CONNECT)
#define DTLS1_SCTP_ST_CR_READ_SOCK		(0x320|SSL_ST_CONNECT)
#endif	
/* write to server */
#define SSL3_ST_CW_CLNT_HELLO_A			(0x110|SSL_ST_CONNECT)
#define SSL3_ST_CW_CLNT_HELLO_B			(0x111|SSL_ST_CONNECT)
/* read from server */
#define SSL3_ST_CR_SRVR_HELLO_A			(0x120|SSL_ST_CONNECT)
#define SSL3_ST_CR_SRVR_HELLO_B			(0x121|SSL_ST_CONNECT)
#define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A	(0x126|SSL_ST_CONNECT)
#define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B	(0x127|SSL_ST_CONNECT)
#define SSL3_ST_CR_CERT_A			(0x130|SSL_ST_CONNECT)
#define SSL3_ST_CR_CERT_B			(0x131|SSL_ST_CONNECT)
#define SSL3_ST_CR_KEY_EXCH_A			(0x140|SSL_ST_CONNECT)
#define SSL3_ST_CR_KEY_EXCH_B			(0x141|SSL_ST_CONNECT)
#define SSL3_ST_CR_CERT_REQ_A			(0x150|SSL_ST_CONNECT)
#define SSL3_ST_CR_CERT_REQ_B			(0x151|SSL_ST_CONNECT)
#define SSL3_ST_CR_SRVR_DONE_A			(0x160|SSL_ST_CONNECT)
#define SSL3_ST_CR_SRVR_DONE_B			(0x161|SSL_ST_CONNECT)
/* write to server */
#define SSL3_ST_CW_CERT_A			(0x170|SSL_ST_CONNECT)
#define SSL3_ST_CW_CERT_B			(0x171|SSL_ST_CONNECT)
#define SSL3_ST_CW_CERT_C			(0x172|SSL_ST_CONNECT)
#define SSL3_ST_CW_CERT_D			(0x173|SSL_ST_CONNECT)
#define SSL3_ST_CW_KEY_EXCH_A			(0x180|SSL_ST_CONNECT)
#define SSL3_ST_CW_KEY_EXCH_B			(0x181|SSL_ST_CONNECT)
#define SSL3_ST_CW_CERT_VRFY_A			(0x190|SSL_ST_CONNECT)
#define SSL3_ST_CW_CERT_VRFY_B			(0x191|SSL_ST_CONNECT)
#define SSL3_ST_CW_CHANGE_A			(0x1A0|SSL_ST_CONNECT)
#define SSL3_ST_CW_CHANGE_B			(0x1A1|SSL_ST_CONNECT)
#ifndef OPENSSL_NO_NEXTPROTONEG
#define SSL3_ST_CW_NEXT_PROTO_A			(0x200|SSL_ST_CONNECT)
#define SSL3_ST_CW_NEXT_PROTO_B			(0x201|SSL_ST_CONNECT)
#endif
#define SSL3_ST_CW_FINISHED_A			(0x1B0|SSL_ST_CONNECT)
#define SSL3_ST_CW_FINISHED_B			(0x1B1|SSL_ST_CONNECT)
/* read from server */
#define SSL3_ST_CR_CHANGE_A			(0x1C0|SSL_ST_CONNECT)
#define SSL3_ST_CR_CHANGE_B			(0x1C1|SSL_ST_CONNECT)
#define SSL3_ST_CR_FINISHED_A			(0x1D0|SSL_ST_CONNECT)
#define SSL3_ST_CR_FINISHED_B			(0x1D1|SSL_ST_CONNECT)
#define SSL3_ST_CR_SESSION_TICKET_A		(0x1E0|SSL_ST_CONNECT)
#define SSL3_ST_CR_SESSION_TICKET_B		(0x1E1|SSL_ST_CONNECT)
#define SSL3_ST_CR_CERT_STATUS_A		(0x1F0|SSL_ST_CONNECT)
#define SSL3_ST_CR_CERT_STATUS_B		(0x1F1|SSL_ST_CONNECT)

/* server */
/* extra state */
#define SSL3_ST_SW_FLUSH			(0x100|SSL_ST_ACCEPT)
#ifndef OPENSSL_NO_SCTP
#define DTLS1_SCTP_ST_SW_WRITE_SOCK		(0x310|SSL_ST_ACCEPT)
#define DTLS1_SCTP_ST_SR_READ_SOCK		(0x320|SSL_ST_ACCEPT)
#endif	
/* read from client */
/* Do not change the number values, they do matter */
#define SSL3_ST_SR_CLNT_HELLO_A			(0x110|SSL_ST_ACCEPT)
#define SSL3_ST_SR_CLNT_HELLO_B			(0x111|SSL_ST_ACCEPT)
#define SSL3_ST_SR_CLNT_HELLO_C			(0x112|SSL_ST_ACCEPT)
/* write to client */
#define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A	(0x113|SSL_ST_ACCEPT)
#define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B	(0x114|SSL_ST_ACCEPT)
#define SSL3_ST_SW_HELLO_REQ_A			(0x120|SSL_ST_ACCEPT)
#define SSL3_ST_SW_HELLO_REQ_B			(0x121|SSL_ST_ACCEPT)
#define SSL3_ST_SW_HELLO_REQ_C			(0x122|SSL_ST_ACCEPT)
#define SSL3_ST_SW_SRVR_HELLO_A			(0x130|SSL_ST_ACCEPT)
#define SSL3_ST_SW_SRVR_HELLO_B			(0x131|SSL_ST_ACCEPT)
#define SSL3_ST_SW_CERT_A			(0x140|SSL_ST_ACCEPT)
#define SSL3_ST_SW_CERT_B			(0x141|SSL_ST_ACCEPT)
#define SSL3_ST_SW_KEY_EXCH_A			(0x150|SSL_ST_ACCEPT)
#define SSL3_ST_SW_KEY_EXCH_B			(0x151|SSL_ST_ACCEPT)
#define SSL3_ST_SW_CERT_REQ_A			(0x160|SSL_ST_ACCEPT)
#define SSL3_ST_SW_CERT_REQ_B			(0x161|SSL_ST_ACCEPT)
#define SSL3_ST_SW_SRVR_DONE_A			(0x170|SSL_ST_ACCEPT)
#define SSL3_ST_SW_SRVR_DONE_B			(0x171|SSL_ST_ACCEPT)
/* read from client */
#define SSL3_ST_SR_CERT_A			(0x180|SSL_ST_ACCEPT)
#define SSL3_ST_SR_CERT_B			(0x181|SSL_ST_ACCEPT)
#define SSL3_ST_SR_KEY_EXCH_A			(0x190|SSL_ST_ACCEPT)
#define SSL3_ST_SR_KEY_EXCH_B			(0x191|SSL_ST_ACCEPT)
#define SSL3_ST_SR_CERT_VRFY_A			(0x1A0|SSL_ST_ACCEPT)
#define SSL3_ST_SR_CERT_VRFY_B			(0x1A1|SSL_ST_ACCEPT)
#define SSL3_ST_SR_CHANGE_A			(0x1B0|SSL_ST_ACCEPT)
#define SSL3_ST_SR_CHANGE_B			(0x1B1|SSL_ST_ACCEPT)
#ifndef OPENSSL_NO_NEXTPROTONEG
#define SSL3_ST_SR_NEXT_PROTO_A			(0x210|SSL_ST_ACCEPT)
#define SSL3_ST_SR_NEXT_PROTO_B			(0x211|SSL_ST_ACCEPT)
#endif
#define SSL3_ST_SR_FINISHED_A			(0x1C0|SSL_ST_ACCEPT)
#define SSL3_ST_SR_FINISHED_B			(0x1C1|SSL_ST_ACCEPT)
/* write to client */
#define SSL3_ST_SW_CHANGE_A			(0x1D0|SSL_ST_ACCEPT)
#define SSL3_ST_SW_CHANGE_B			(0x1D1|SSL_ST_ACCEPT)
#define SSL3_ST_SW_FINISHED_A			(0x1E0|SSL_ST_ACCEPT)
#define SSL3_ST_SW_FINISHED_B			(0x1E1|SSL_ST_ACCEPT)
#define SSL3_ST_SW_SESSION_TICKET_A		(0x1F0|SSL_ST_ACCEPT)
#define SSL3_ST_SW_SESSION_TICKET_B		(0x1F1|SSL_ST_ACCEPT)
#define SSL3_ST_SW_CERT_STATUS_A		(0x200|SSL_ST_ACCEPT)
#define SSL3_ST_SW_CERT_STATUS_B		(0x201|SSL_ST_ACCEPT)

#define SSL3_MT_HELLO_REQUEST			0
#define SSL3_MT_CLIENT_HELLO			1
#define SSL3_MT_SERVER_HELLO			2
#define	SSL3_MT_NEWSESSION_TICKET		4
#define SSL3_MT_CERTIFICATE			11
#define SSL3_MT_SERVER_KEY_EXCHANGE		12
#define SSL3_MT_CERTIFICATE_REQUEST		13
#define SSL3_MT_SERVER_DONE			14
#define SSL3_MT_CERTIFICATE_VERIFY		15
#define SSL3_MT_CLIENT_KEY_EXCHANGE		16
#define SSL3_MT_FINISHED			20
#define SSL3_MT_CERTIFICATE_STATUS		22

#ifndef OPENSSL_NO_NEXTPROTONEG
#define SSL3_MT_NEXT_PROTO			67
#endif

#define DTLS1_MT_HELLO_VERIFY_REQUEST		3

#define SSL3_MT_CCS				1

/* These are used when changing over to a new cipher */
#define SSL3_CC_READ		0x01
#define SSL3_CC_WRITE		0x02
#define SSL3_CC_CLIENT		0x10
#define SSL3_CC_SERVER		0x20
#define SSL3_CHANGE_CIPHER_CLIENT_WRITE		(SSL3_CC_CLIENT|SSL3_CC_WRITE)	
#define SSL3_CHANGE_CIPHER_SERVER_READ		(SSL3_CC_SERVER|SSL3_CC_READ)
#define SSL3_CHANGE_CIPHER_CLIENT_READ		(SSL3_CC_CLIENT|SSL3_CC_READ)
#define SSL3_CHANGE_CIPHER_SERVER_WRITE		(SSL3_CC_SERVER|SSL3_CC_WRITE)

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/ocsp.h0000644000175000017500000005643012360020705021166 0ustar  /* $OpenBSD$ */
/* Written by Tom Titchener  for the OpenSSL
 * project. */

/* History:
   This file was transfered to Richard Levitte from CertCo by Kathy
   Weinhold in mid-spring 2000 to be included in OpenSSL or released
   as a patch kit. */

/* ====================================================================
 * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#ifndef HEADER_OCSP_H
#define HEADER_OCSP_H

#include 
#include 
#include 
#include 

#ifdef  __cplusplus
extern "C" {
#endif

/* Various flags and values */

#define OCSP_DEFAULT_NONCE_LENGTH	16

#define OCSP_NOCERTS			0x1
#define OCSP_NOINTERN			0x2
#define OCSP_NOSIGS			0x4
#define OCSP_NOCHAIN			0x8
#define OCSP_NOVERIFY			0x10
#define OCSP_NOEXPLICIT			0x20
#define OCSP_NOCASIGN			0x40
#define OCSP_NODELEGATED		0x80
#define OCSP_NOCHECKS			0x100
#define OCSP_TRUSTOTHER			0x200
#define OCSP_RESPID_KEY			0x400
#define OCSP_NOTIME			0x800

/*   CertID ::= SEQUENCE {
 *       hashAlgorithm            AlgorithmIdentifier,
 *       issuerNameHash     OCTET STRING, -- Hash of Issuer's DN
 *       issuerKeyHash      OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields)
 *       serialNumber       CertificateSerialNumber }
 */
typedef struct ocsp_cert_id_st {
	X509_ALGOR *hashAlgorithm;
	ASN1_OCTET_STRING *issuerNameHash;
	ASN1_OCTET_STRING *issuerKeyHash;
	ASN1_INTEGER *serialNumber;
} OCSP_CERTID;

DECLARE_STACK_OF(OCSP_CERTID)

/*   Request ::=     SEQUENCE {
 *       reqCert                    CertID,
 *       singleRequestExtensions    [0] EXPLICIT Extensions OPTIONAL }
 */
typedef struct ocsp_one_request_st {
	OCSP_CERTID *reqCert;
	STACK_OF(X509_EXTENSION) *singleRequestExtensions;
} OCSP_ONEREQ;

DECLARE_STACK_OF(OCSP_ONEREQ)
DECLARE_ASN1_SET_OF(OCSP_ONEREQ)


/*   TBSRequest      ::=     SEQUENCE {
 *       version             [0] EXPLICIT Version DEFAULT v1,
 *       requestorName       [1] EXPLICIT GeneralName OPTIONAL,
 *       requestList             SEQUENCE OF Request,
 *       requestExtensions   [2] EXPLICIT Extensions OPTIONAL }
 */
typedef struct ocsp_req_info_st {
	ASN1_INTEGER *version;
	GENERAL_NAME *requestorName;
	STACK_OF(OCSP_ONEREQ) *requestList;
	STACK_OF(X509_EXTENSION) *requestExtensions;
} OCSP_REQINFO;

/*   Signature       ::=     SEQUENCE {
 *       signatureAlgorithm   AlgorithmIdentifier,
 *       signature            BIT STRING,
 *       certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
 */
typedef struct ocsp_signature_st {
	X509_ALGOR *signatureAlgorithm;
	ASN1_BIT_STRING *signature;
	STACK_OF(X509) *certs;
} OCSP_SIGNATURE;

/*   OCSPRequest     ::=     SEQUENCE {
 *       tbsRequest                  TBSRequest,
 *       optionalSignature   [0]     EXPLICIT Signature OPTIONAL }
 */
typedef struct ocsp_request_st {
	OCSP_REQINFO *tbsRequest;
	OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */
} OCSP_REQUEST;

/*   OCSPResponseStatus ::= ENUMERATED {
 *       successful            (0),      --Response has valid confirmations
 *       malformedRequest      (1),      --Illegal confirmation request
 *       internalError         (2),      --Internal error in issuer
 *       tryLater              (3),      --Try again later
 *                                       --(4) is not used
 *       sigRequired           (5),      --Must sign the request
 *       unauthorized          (6)       --Request unauthorized
 *   }
 */
#define OCSP_RESPONSE_STATUS_SUCCESSFUL		0
#define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST	1
#define OCSP_RESPONSE_STATUS_INTERNALERROR	2
#define OCSP_RESPONSE_STATUS_TRYLATER		3
#define OCSP_RESPONSE_STATUS_SIGREQUIRED	5
#define OCSP_RESPONSE_STATUS_UNAUTHORIZED	6

/*   ResponseBytes ::=       SEQUENCE {
 *       responseType   OBJECT IDENTIFIER,
 *       response       OCTET STRING }
 */
typedef struct ocsp_resp_bytes_st {
	ASN1_OBJECT *responseType;
	ASN1_OCTET_STRING *response;
} OCSP_RESPBYTES;

/*   OCSPResponse ::= SEQUENCE {
 *      responseStatus         OCSPResponseStatus,
 *      responseBytes          [0] EXPLICIT ResponseBytes OPTIONAL }
 */
struct ocsp_response_st {
	ASN1_ENUMERATED *responseStatus;
	OCSP_RESPBYTES  *responseBytes;
};

/*   ResponderID ::= CHOICE {
 *      byName   [1] Name,
 *      byKey    [2] KeyHash }
 */
#define V_OCSP_RESPID_NAME 0
#define V_OCSP_RESPID_KEY  1
struct ocsp_responder_id_st {
	int type;
	union {
		X509_NAME* byName;
		ASN1_OCTET_STRING *byKey;
	} value;
};

DECLARE_STACK_OF(OCSP_RESPID)
DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)

/*   KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key
 *                            --(excluding the tag and length fields)
 */

/*   RevokedInfo ::= SEQUENCE {
 *       revocationTime              GeneralizedTime,
 *       revocationReason    [0]     EXPLICIT CRLReason OPTIONAL }
 */
typedef struct ocsp_revoked_info_st {
	ASN1_GENERALIZEDTIME *revocationTime;
	ASN1_ENUMERATED *revocationReason;
} OCSP_REVOKEDINFO;

/*   CertStatus ::= CHOICE {
 *       good                [0]     IMPLICIT NULL,
 *       revoked             [1]     IMPLICIT RevokedInfo,
 *       unknown             [2]     IMPLICIT UnknownInfo }
 */
#define V_OCSP_CERTSTATUS_GOOD    0
#define V_OCSP_CERTSTATUS_REVOKED 1
#define V_OCSP_CERTSTATUS_UNKNOWN 2
typedef struct ocsp_cert_status_st {
	int type;
	union {
		ASN1_NULL *good;
		OCSP_REVOKEDINFO *revoked;
		ASN1_NULL *unknown;
	} value;
} OCSP_CERTSTATUS;

/*   SingleResponse ::= SEQUENCE {
 *      certID                       CertID,
 *      certStatus                   CertStatus,
 *      thisUpdate                   GeneralizedTime,
 *      nextUpdate           [0]     EXPLICIT GeneralizedTime OPTIONAL,
 *      singleExtensions     [1]     EXPLICIT Extensions OPTIONAL }
 */
typedef struct ocsp_single_response_st {
	OCSP_CERTID *certId;
	OCSP_CERTSTATUS *certStatus;
	ASN1_GENERALIZEDTIME *thisUpdate;
	ASN1_GENERALIZEDTIME *nextUpdate;
	STACK_OF(X509_EXTENSION) *singleExtensions;
} OCSP_SINGLERESP;

DECLARE_STACK_OF(OCSP_SINGLERESP)
DECLARE_ASN1_SET_OF(OCSP_SINGLERESP)

/*   ResponseData ::= SEQUENCE {
 *      version              [0] EXPLICIT Version DEFAULT v1,
 *      responderID              ResponderID,
 *      producedAt               GeneralizedTime,
 *      responses                SEQUENCE OF SingleResponse,
 *      responseExtensions   [1] EXPLICIT Extensions OPTIONAL }
 */
typedef struct ocsp_response_data_st {
	ASN1_INTEGER *version;
	OCSP_RESPID  *responderId;
	ASN1_GENERALIZEDTIME *producedAt;
	STACK_OF(OCSP_SINGLERESP) *responses;
	STACK_OF(X509_EXTENSION) *responseExtensions;
} OCSP_RESPDATA;

/*   BasicOCSPResponse       ::= SEQUENCE {
 *      tbsResponseData      ResponseData,
 *      signatureAlgorithm   AlgorithmIdentifier,
 *      signature            BIT STRING,
 *      certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
 */
  /* Note 1:
     The value for "signature" is specified in the OCSP rfc2560 as follows:
     "The value for the signature SHALL be computed on the hash of the DER
     encoding ResponseData."  This means that you must hash the DER-encoded
     tbsResponseData, and then run it through a crypto-signing function, which
     will (at least w/RSA) do a hash-'n'-private-encrypt operation.  This seems
     a bit odd, but that's the spec.  Also note that the data structures do not
     leave anywhere to independently specify the algorithm used for the initial
     hash. So, we look at the signature-specification algorithm, and try to do
     something intelligent.	-- Kathy Weinhold, CertCo */
  /* Note 2:
     It seems that the mentioned passage from RFC 2560 (section 4.2.1) is open
     for interpretation.  I've done tests against another responder, and found
     that it doesn't do the double hashing that the RFC seems to say one
     should.  Therefore, all relevant functions take a flag saying which
     variant should be used.	-- Richard Levitte, OpenSSL team and CeloCom */
typedef struct ocsp_basic_response_st {
	OCSP_RESPDATA *tbsResponseData;
	X509_ALGOR *signatureAlgorithm;
	ASN1_BIT_STRING *signature;
	STACK_OF(X509) *certs;
} OCSP_BASICRESP;

/*
 *   CRLReason ::= ENUMERATED {
 *        unspecified             (0),
 *        keyCompromise           (1),
 *        cACompromise            (2),
 *        affiliationChanged      (3),
 *        superseded              (4),
 *        cessationOfOperation    (5),
 *        certificateHold         (6),
 *        removeFromCRL           (8) }
 */
#define OCSP_REVOKED_STATUS_NOSTATUS			-1
#define OCSP_REVOKED_STATUS_UNSPECIFIED			0
#define OCSP_REVOKED_STATUS_KEYCOMPROMISE		1
#define OCSP_REVOKED_STATUS_CACOMPROMISE		2
#define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED		3
#define OCSP_REVOKED_STATUS_SUPERSEDED			4
#define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION	5
#define OCSP_REVOKED_STATUS_CERTIFICATEHOLD		6
#define OCSP_REVOKED_STATUS_REMOVEFROMCRL		8

/* CrlID ::= SEQUENCE {
 *     crlUrl               [0]     EXPLICIT IA5String OPTIONAL,
 *     crlNum               [1]     EXPLICIT INTEGER OPTIONAL,
 *     crlTime              [2]     EXPLICIT GeneralizedTime OPTIONAL }
 */
typedef struct ocsp_crl_id_st {
	ASN1_IA5STRING *crlUrl;
	ASN1_INTEGER *crlNum;
	ASN1_GENERALIZEDTIME *crlTime;
} OCSP_CRLID;

/* ServiceLocator ::= SEQUENCE {
 *      issuer    Name,
 *      locator   AuthorityInfoAccessSyntax OPTIONAL }
 */
typedef struct ocsp_service_locator_st {
	X509_NAME* issuer;
	STACK_OF(ACCESS_DESCRIPTION) *locator;
} OCSP_SERVICELOC;

#define PEM_STRING_OCSP_REQUEST	"OCSP REQUEST"
#define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE"

#define d2i_OCSP_REQUEST_bio(bp,p) \
    ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p)

#define d2i_OCSP_RESPONSE_bio(bp,p) \
    ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p)

#define	PEM_read_bio_OCSP_REQUEST(bp,x,cb) \
    (OCSP_REQUEST *)PEM_ASN1_read_bio((char *(*)())d2i_OCSP_REQUEST, \
	PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL)

#define	PEM_read_bio_OCSP_RESPONSE(bp,x,cb) \
    (OCSP_RESPONSE *)PEM_ASN1_read_bio((char *(*)())d2i_OCSP_RESPONSE, \
	PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL)

#define PEM_write_bio_OCSP_REQUEST(bp,o) \
    PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\
	bp,(char *)o, NULL,NULL,0,NULL,NULL)

#define PEM_write_bio_OCSP_RESPONSE(bp,o) \
    PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\
	bp,(char *)o, NULL,NULL,0,NULL,NULL)

#define i2d_OCSP_RESPONSE_bio(bp,o) \
    ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o)

#define i2d_OCSP_REQUEST_bio(bp,o) \
    ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o)

#define OCSP_REQUEST_sign(o,pkey,md) \
    ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO), \
	o->optionalSignature->signatureAlgorithm,NULL, \
	o->optionalSignature->signature,o->tbsRequest,pkey,md)

#define OCSP_BASICRESP_sign(o,pkey,md,d) \
    ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL, \
	o->signature,o->tbsResponseData,pkey,md)

#define OCSP_REQUEST_verify(a,r) \
    ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO), \
	a->optionalSignature->signatureAlgorithm, \
	a->optionalSignature->signature,a->tbsRequest,r)

#define OCSP_BASICRESP_verify(a,r,d) \
    ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA), \
	a->signatureAlgorithm,a->signature,a->tbsResponseData,r)

#define ASN1_BIT_STRING_digest(data,type,md,len) \
    ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len)

#define OCSP_CERTSTATUS_dup(cs)\
    (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\
	(char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))

OCSP_CERTID *OCSP_CERTID_dup(OCSP_CERTID *id);

OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req);
OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req,
	    int maxline);
int	OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);
void	OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);
int	OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req);
int	OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx, const char *name,
	    const char *value);

OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer);

OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, X509_NAME *issuerName,
	    ASN1_BIT_STRING* issuerKey, ASN1_INTEGER *serialNumber);

OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);

int	OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);
int	OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);
int	OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);
int	OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);

int	OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm);
int	OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);

int	OCSP_request_sign(OCSP_REQUEST *req, X509 *signer, EVP_PKEY *key,
	    const EVP_MD *dgst, STACK_OF(X509) *certs, unsigned long flags);

int	OCSP_response_status(OCSP_RESPONSE *resp);
OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);

int	OCSP_resp_count(OCSP_BASICRESP *bs);
OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
int	OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
int	OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
	    ASN1_GENERALIZEDTIME **revtime, ASN1_GENERALIZEDTIME **thisupd,
	    ASN1_GENERALIZEDTIME **nextupd);
int	OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
	    int *reason, ASN1_GENERALIZEDTIME **revtime,
	    ASN1_GENERALIZEDTIME **thisupd, ASN1_GENERALIZEDTIME **nextupd);
int	OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,
	    ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec);

int	OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,
	    X509_STORE *store, unsigned long flags);

int	OCSP_parse_url(char *url, char **phost, char **pport, char **ppath,
	    int *pssl);

int	OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
int	OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);

int	OCSP_request_onereq_count(OCSP_REQUEST *req);
OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);
OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);
int	OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,
	    ASN1_OCTET_STRING **pikeyHash, ASN1_INTEGER **pserial,
	    OCSP_CERTID *cid);
int	OCSP_request_is_signed(OCSP_REQUEST *req);
OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);
OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp, OCSP_CERTID *cid,
	    int status, int reason, ASN1_TIME *revtime, ASN1_TIME *thisupd,
	    ASN1_TIME *nextupd);
int	OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);
int	OCSP_basic_sign(OCSP_BASICRESP *brsp, X509 *signer, EVP_PKEY *key,
	    const EVP_MD *dgst, STACK_OF(X509) *certs, unsigned long flags);

X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim);

X509_EXTENSION *OCSP_accept_responses_new(char **oids);

X509_EXTENSION *OCSP_archive_cutoff_new(char* tim);

X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls);

int	OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);
int	OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);
int	OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj,
	    int lastpos);
int	OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit,
	    int lastpos);
X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);
X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);
void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx);
int	OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value,
	    int crit, unsigned long flags);
int	OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);

int	OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);
int	OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);
int	OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj,
	    int lastpos);
int	OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);
X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);
X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);
void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);
int	OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,
	    unsigned long flags);
int	OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);

int	OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);
int	OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);
int	OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj,
	    int lastpos);
int	OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit,
	    int lastpos);
X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);
X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);
void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit,
	    int *idx);
int	OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value,
	    int crit, unsigned long flags);
int	OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);

int	OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);
int	OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid,
	    int lastpos);
int	OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj,
	    int lastpos);
int	OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit,
	    int lastpos);
X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);
X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);
void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit,
	    int *idx);
int	OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value,
	    int crit, unsigned long flags);
int	OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex,
	    int loc);

DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)
DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)
DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)
DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP)
DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)
DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)
DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)
DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES)
DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)
DECLARE_ASN1_FUNCTIONS(OCSP_CERTID)
DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)
DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)
DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)
DECLARE_ASN1_FUNCTIONS(OCSP_CRLID)
DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)

const char *OCSP_response_status_str(long s);
const char *OCSP_cert_status_str(long s);
const char *OCSP_crl_reason_str(long s);

int	OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags);
int	OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags);

int	OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
	    X509_STORE *st, unsigned long flags);

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_OCSP_strings(void);

/* Error codes for the OCSP functions. */

/* Function codes. */
#define OCSP_F_ASN1_STRING_ENCODE			 100
#define OCSP_F_D2I_OCSP_NONCE				 102
#define OCSP_F_OCSP_BASIC_ADD1_STATUS			 103
#define OCSP_F_OCSP_BASIC_SIGN				 104
#define OCSP_F_OCSP_BASIC_VERIFY			 105
#define OCSP_F_OCSP_CERT_ID_NEW				 101
#define OCSP_F_OCSP_CHECK_DELEGATED			 106
#define OCSP_F_OCSP_CHECK_IDS				 107
#define OCSP_F_OCSP_CHECK_ISSUER			 108
#define OCSP_F_OCSP_CHECK_VALIDITY			 115
#define OCSP_F_OCSP_MATCH_ISSUERID			 109
#define OCSP_F_OCSP_PARSE_URL				 114
#define OCSP_F_OCSP_REQUEST_SIGN			 110
#define OCSP_F_OCSP_REQUEST_VERIFY			 116
#define OCSP_F_OCSP_RESPONSE_GET1_BASIC			 111
#define OCSP_F_OCSP_SENDREQ_BIO				 112
#define OCSP_F_OCSP_SENDREQ_NBIO			 117
#define OCSP_F_PARSE_HTTP_LINE1				 118
#define OCSP_F_REQUEST_VERIFY				 113

/* Reason codes. */
#define OCSP_R_BAD_DATA					 100
#define OCSP_R_CERTIFICATE_VERIFY_ERROR			 101
#define OCSP_R_DIGEST_ERR				 102
#define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD		 122
#define OCSP_R_ERROR_IN_THISUPDATE_FIELD		 123
#define OCSP_R_ERROR_PARSING_URL			 121
#define OCSP_R_MISSING_OCSPSIGNING_USAGE		 103
#define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE		 124
#define OCSP_R_NOT_BASIC_RESPONSE			 104
#define OCSP_R_NO_CERTIFICATES_IN_CHAIN			 105
#define OCSP_R_NO_CONTENT				 106
#define OCSP_R_NO_PUBLIC_KEY				 107
#define OCSP_R_NO_RESPONSE_DATA				 108
#define OCSP_R_NO_REVOKED_TIME				 109
#define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE	 110
#define OCSP_R_REQUEST_NOT_SIGNED			 128
#define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA	 111
#define OCSP_R_ROOT_CA_NOT_TRUSTED			 112
#define OCSP_R_SERVER_READ_ERROR			 113
#define OCSP_R_SERVER_RESPONSE_ERROR			 114
#define OCSP_R_SERVER_RESPONSE_PARSE_ERROR		 115
#define OCSP_R_SERVER_WRITE_ERROR			 116
#define OCSP_R_SIGNATURE_FAILURE			 117
#define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND		 118
#define OCSP_R_STATUS_EXPIRED				 125
#define OCSP_R_STATUS_NOT_YET_VALID			 126
#define OCSP_R_STATUS_TOO_OLD				 127
#define OCSP_R_UNKNOWN_MESSAGE_DIGEST			 119
#define OCSP_R_UNKNOWN_NID				 120
#define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE		 129

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/mdc2.h0000644000175000017500000000752712360020705021052 0ustar  /* $OpenBSD: mdc2.h,v 1.12 2014/06/12 15:49:29 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_MDC2_H
#define HEADER_MDC2_H

#include 

#include 

#ifdef  __cplusplus
extern "C" {
#endif

#ifdef OPENSSL_NO_MDC2
#error MDC2 is disabled.
#endif

#define MDC2_BLOCK              8
#define MDC2_DIGEST_LENGTH      16
 
typedef struct mdc2_ctx_st
	{
	unsigned int num;
	unsigned char data[MDC2_BLOCK];
	DES_cblock h,hh;
	int pad_type; /* either 1 or 2, default 1 */
	} MDC2_CTX;


int MDC2_Init(MDC2_CTX *c);
int MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len);
int MDC2_Final(unsigned char *md, MDC2_CTX *c);
unsigned char *MDC2(const unsigned char *d, size_t n,
	unsigned char *md);

#ifdef  __cplusplus
}
#endif

#endif

deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/asn1t.h0000644000175000017500000007034112360020705021245 0ustar  /* $OpenBSD$ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
 * project 2000.
 */
/* ====================================================================
 * Copyright (c) 2000-2005 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */
#ifndef HEADER_ASN1T_H
#define HEADER_ASN1T_H

#include 

#include 

#include 

/* ASN1 template defines, structures and functions */

#ifdef  __cplusplus
extern "C" {
#endif



/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))


/* Macros for start and end of ASN1_ITEM definition */

#define ASN1_ITEM_start(itname) \
	const ASN1_ITEM itname##_it = {

#define ASN1_ITEM_end(itname) \
		};



/* Macros to aid ASN1 template writing */

#define ASN1_ITEM_TEMPLATE(tname) \
	static const ASN1_TEMPLATE tname##_item_tt 

#define ASN1_ITEM_TEMPLATE_END(tname) \
	;\
	ASN1_ITEM_start(tname) \
		ASN1_ITYPE_PRIMITIVE,\
		-1,\
		&tname##_item_tt,\
		0,\
		NULL,\
		0,\
		#tname \
	ASN1_ITEM_end(tname)


/* This is a ASN1 type which just embeds a template */
 
/* This pair helps declare a SEQUENCE. We can do:
 *
 * 	ASN1_SEQUENCE(stname) = {
 * 		... SEQUENCE components ...
 * 	} ASN1_SEQUENCE_END(stname)
 *
 * 	This will produce an ASN1_ITEM called stname_it
 *	for a structure called stname.
 *
 * 	If you want the same structure but a different
 *	name then use:
 *
 * 	ASN1_SEQUENCE(itname) = {
 * 		... SEQUENCE components ...
 * 	} ASN1_SEQUENCE_END_name(stname, itname)
 *
 *	This will create an item called itname_it using
 *	a structure called stname.
 */

#define ASN1_SEQUENCE(tname) \
	static const ASN1_TEMPLATE tname##_seq_tt[] 

#define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)

#define ASN1_SEQUENCE_END_name(stname, tname) \
	;\
	ASN1_ITEM_start(tname) \
		ASN1_ITYPE_SEQUENCE,\
		V_ASN1_SEQUENCE,\
		tname##_seq_tt,\
		sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
		NULL,\
		sizeof(stname),\
		#stname \
	ASN1_ITEM_end(tname)

#define ASN1_NDEF_SEQUENCE(tname) \
	ASN1_SEQUENCE(tname)

#define ASN1_NDEF_SEQUENCE_cb(tname, cb) \
	ASN1_SEQUENCE_cb(tname, cb)

#define ASN1_SEQUENCE_cb(tname, cb) \
	static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
	ASN1_SEQUENCE(tname)

#define ASN1_BROKEN_SEQUENCE(tname) \
	static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \
	ASN1_SEQUENCE(tname)

#define ASN1_SEQUENCE_ref(tname, cb, lck) \
	static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \
	ASN1_SEQUENCE(tname)

#define ASN1_SEQUENCE_enc(tname, enc, cb) \
	static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \
	ASN1_SEQUENCE(tname)

#define ASN1_NDEF_SEQUENCE_END(tname) \
	;\
	ASN1_ITEM_start(tname) \
		ASN1_ITYPE_NDEF_SEQUENCE,\
		V_ASN1_SEQUENCE,\
		tname##_seq_tt,\
		sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
		NULL,\
		sizeof(tname),\
		#tname \
	ASN1_ITEM_end(tname)

#define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)

#define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)

#define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)

#define ASN1_SEQUENCE_END_ref(stname, tname) \
	;\
	ASN1_ITEM_start(tname) \
		ASN1_ITYPE_SEQUENCE,\
		V_ASN1_SEQUENCE,\
		tname##_seq_tt,\
		sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
		&tname##_aux,\
		sizeof(stname),\
		#stname \
	ASN1_ITEM_end(tname)

#define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \
	;\
	ASN1_ITEM_start(tname) \
		ASN1_ITYPE_NDEF_SEQUENCE,\
		V_ASN1_SEQUENCE,\
		tname##_seq_tt,\
		sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
		&tname##_aux,\
		sizeof(stname),\
		#stname \
	ASN1_ITEM_end(tname)


/* This pair helps declare a CHOICE type. We can do:
 *
 * 	ASN1_CHOICE(chname) = {
 * 		... CHOICE options ...
 * 	ASN1_CHOICE_END(chname)
 *
 * 	This will produce an ASN1_ITEM called chname_it
 *	for a structure called chname. The structure
 *	definition must look like this:
 *	typedef struct {
 *		int type;
 *		union {
 *			ASN1_SOMETHING *opt1;
 *			ASN1_SOMEOTHER *opt2;
 *		} value;
 *	} chname;
 *	
 *	the name of the selector must be 'type'.
 * 	to use an alternative selector name use the
 *      ASN1_CHOICE_END_selector() version.
 */

#define ASN1_CHOICE(tname) \
	static const ASN1_TEMPLATE tname##_ch_tt[] 

#define ASN1_CHOICE_cb(tname, cb) \
	static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
	ASN1_CHOICE(tname)

#define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)

#define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)

#define ASN1_CHOICE_END_selector(stname, tname, selname) \
	;\
	ASN1_ITEM_start(tname) \
		ASN1_ITYPE_CHOICE,\
		offsetof(stname,selname) ,\
		tname##_ch_tt,\
		sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
		NULL,\
		sizeof(stname),\
		#stname \
	ASN1_ITEM_end(tname)

#define ASN1_CHOICE_END_cb(stname, tname, selname) \
	;\
	ASN1_ITEM_start(tname) \
		ASN1_ITYPE_CHOICE,\
		offsetof(stname,selname) ,\
		tname##_ch_tt,\
		sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
		&tname##_aux,\
		sizeof(stname),\
		#stname \
	ASN1_ITEM_end(tname)

/* This helps with the template wrapper form of ASN1_ITEM */

#define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \
	(flags), (tag), 0,\
	#name, ASN1_ITEM_ref(type) }

/* These help with SEQUENCE or CHOICE components */

/* used to declare other types */

#define ASN1_EX_TYPE(flags, tag, stname, field, type) { \
	(flags), (tag), offsetof(stname, field),\
	#field, ASN1_ITEM_ref(type) }

/* used when the structure is combined with the parent */

#define ASN1_EX_COMBINE(flags, tag, type) { \
	(flags)|ASN1_TFLG_COMBINE, (tag), 0, NULL, ASN1_ITEM_ref(type) }

/* implicit and explicit helper macros */

#define ASN1_IMP_EX(stname, field, type, tag, ex) \
		ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type)

#define ASN1_EXP_EX(stname, field, type, tag, ex) \
		ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type)

/* Any defined by macros: the field used is in the table itself */

#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
/* Plain simple type */
#define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)

/* OPTIONAL simple type */
#define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)

/* IMPLICIT tagged simple type */
#define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)

/* IMPLICIT tagged OPTIONAL simple type */
#define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)

/* Same as above but EXPLICIT */

#define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)
#define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)

/* SEQUENCE OF type */
#define ASN1_SEQUENCE_OF(stname, field, type) \
		ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)

/* OPTIONAL SEQUENCE OF */
#define ASN1_SEQUENCE_OF_OPT(stname, field, type) \
		ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)

/* Same as above but for SET OF */

#define ASN1_SET_OF(stname, field, type) \
		ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)

#define ASN1_SET_OF_OPT(stname, field, type) \
		ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)

/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */

#define ASN1_IMP_SET_OF(stname, field, type, tag) \
			ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)

#define ASN1_EXP_SET_OF(stname, field, type, tag) \
			ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)

#define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \
			ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)

#define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \
			ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)

#define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \
			ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)

#define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \
			ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)

#define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \
			ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)

#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \
			ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)

/* EXPLICIT using indefinite length constructed form */
#define ASN1_NDEF_EXP(stname, field, type, tag) \
			ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)

/* EXPLICIT OPTIONAL using indefinite length constructed form */
#define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \
			ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)

/* Macros for the ASN1_ADB structure */

#define ASN1_ADB(name) \
	static const ASN1_ADB_TABLE name##_adbtbl[] 


#define ASN1_ADB_END(name, flags, field, app_table, def, none) \
	;\
	static const ASN1_ADB name##_adb = {\
		flags,\
		offsetof(name, field),\
		app_table,\
		name##_adbtbl,\
		sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
		def,\
		none\
	}


#define ADB_ENTRY(val, template) {val, template}

#define ASN1_ADB_TEMPLATE(name) \
	static const ASN1_TEMPLATE name##_tt 

/* This is the ASN1 template structure that defines
 * a wrapper round the actual type. It determines the
 * actual position of the field in the value structure,
 * various flags such as OPTIONAL and the field name.
 */

struct ASN1_TEMPLATE_st {
unsigned long flags;		/* Various flags */
long tag;			/* tag, not used if no tagging */
unsigned long offset;		/* Offset of this field in structure */
#ifndef NO_ASN1_FIELD_NAMES
const char *field_name;		/* Field name */
#endif
ASN1_ITEM_EXP *item;		/* Relevant ASN1_ITEM or ASN1_ADB */
};

/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */

#define ASN1_TEMPLATE_item(t) (t->item_ptr)
#define ASN1_TEMPLATE_adb(t) (t->item_ptr)

typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;
typedef struct ASN1_ADB_st ASN1_ADB;

struct ASN1_ADB_st {
	unsigned long flags;	/* Various flags */
	unsigned long offset;	/* Offset of selector field */
	STACK_OF(ASN1_ADB_TABLE) **app_items; /* Application defined items */
	const ASN1_ADB_TABLE *tbl;	/* Table of possible types */
	long tblcount;		/* Number of entries in tbl */
	const ASN1_TEMPLATE *default_tt;  /* Type to use if no match */
	const ASN1_TEMPLATE *null_tt;  /* Type to use if selector is NULL */
};

struct ASN1_ADB_TABLE_st {
	long value;		/* NID for an object or value for an int */
	const ASN1_TEMPLATE tt;		/* item for this value */
};

/* template flags */

/* Field is optional */
#define ASN1_TFLG_OPTIONAL	(0x1)

/* Field is a SET OF */
#define ASN1_TFLG_SET_OF	(0x1 << 1)

/* Field is a SEQUENCE OF */
#define ASN1_TFLG_SEQUENCE_OF	(0x2 << 1)

/* Special case: this refers to a SET OF that
 * will be sorted into DER order when encoded *and*
 * the corresponding STACK will be modified to match
 * the new order.
 */
#define ASN1_TFLG_SET_ORDER	(0x3 << 1)

/* Mask for SET OF or SEQUENCE OF */
#define ASN1_TFLG_SK_MASK	(0x3 << 1)

/* These flags mean the tag should be taken from the
 * tag field. If EXPLICIT then the underlying type
 * is used for the inner tag.
 */

/* IMPLICIT tagging */
#define ASN1_TFLG_IMPTAG	(0x1 << 3)


/* EXPLICIT tagging, inner tag from underlying type */
#define ASN1_TFLG_EXPTAG	(0x2 << 3)

#define ASN1_TFLG_TAG_MASK	(0x3 << 3)

/* context specific IMPLICIT */
#define ASN1_TFLG_IMPLICIT	ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT

/* context specific EXPLICIT */
#define ASN1_TFLG_EXPLICIT	ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT

/* If tagging is in force these determine the
 * type of tag to use. Otherwise the tag is
 * determined by the underlying type. These 
 * values reflect the actual octet format.
 */

/* Universal tag */ 
#define ASN1_TFLG_UNIVERSAL	(0x0<<6)
/* Application tag */ 
#define ASN1_TFLG_APPLICATION	(0x1<<6)
/* Context specific tag */ 
#define ASN1_TFLG_CONTEXT	(0x2<<6)
/* Private tag */ 
#define ASN1_TFLG_PRIVATE	(0x3<<6)

#define ASN1_TFLG_TAG_CLASS	(0x3<<6)

/* These are for ANY DEFINED BY type. In this case
 * the 'item' field points to an ASN1_ADB structure
 * which contains a table of values to decode the
 * relevant type
 */

#define ASN1_TFLG_ADB_MASK	(0x3<<8)

#define ASN1_TFLG_ADB_OID	(0x1<<8)

#define ASN1_TFLG_ADB_INT	(0x1<<9)

/* This flag means a parent structure is passed
 * instead of the field: this is useful is a
 * SEQUENCE is being combined with a CHOICE for
 * example. Since this means the structure and
 * item name will differ we need to use the
 * ASN1_CHOICE_END_name() macro for example.
 */

#define ASN1_TFLG_COMBINE	(0x1<<10)

/* This flag when present in a SEQUENCE OF, SET OF
 * or EXPLICIT causes indefinite length constructed
 * encoding to be used if required.
 */

#define ASN1_TFLG_NDEF		(0x1<<11)

/* This is the actual ASN1 item itself */

struct ASN1_ITEM_st {
char itype;			/* The item type, primitive, SEQUENCE, CHOICE or extern */
long utype;			/* underlying type */
const ASN1_TEMPLATE *templates;	/* If SEQUENCE or CHOICE this contains the contents */
long tcount;			/* Number of templates if SEQUENCE or CHOICE */
const void *funcs;		/* functions that handle this type */
long size;			/* Structure size (usually)*/
#ifndef NO_ASN1_FIELD_NAMES
const char *sname;		/* Structure name */
#endif
};

/* These are values for the itype field and
 * determine how the type is interpreted.
 *
 * For PRIMITIVE types the underlying type
 * determines the behaviour if items is NULL.
 *
 * Otherwise templates must contain a single 
 * template and the type is treated in the
 * same way as the type specified in the template.
 *
 * For SEQUENCE types the templates field points
 * to the members, the size field is the
 * structure size.
 *
 * For CHOICE types the templates field points
 * to each possible member (typically a union)
 * and the 'size' field is the offset of the
 * selector.
 *
 * The 'funcs' field is used for application
 * specific functions. 
 *
 * For COMPAT types the funcs field gives a
 * set of functions that handle this type, this
 * supports the old d2i, i2d convention.
 *
 * The EXTERN type uses a new style d2i/i2d.
 * The new style should be used where possible
 * because it avoids things like the d2i IMPLICIT
 * hack.
 *
 * MSTRING is a multiple string type, it is used
 * for a CHOICE of character strings where the
 * actual strings all occupy an ASN1_STRING
 * structure. In this case the 'utype' field
 * has a special meaning, it is used as a mask
 * of acceptable types using the B_ASN1 constants.
 *
 * NDEF_SEQUENCE is the same as SEQUENCE except
 * that it will use indefinite length constructed
 * encoding if requested.
 *
 */

#define ASN1_ITYPE_PRIMITIVE		0x0

#define ASN1_ITYPE_SEQUENCE		0x1

#define ASN1_ITYPE_CHOICE		0x2

#define ASN1_ITYPE_COMPAT		0x3

#define ASN1_ITYPE_EXTERN		0x4

#define ASN1_ITYPE_MSTRING		0x5

#define ASN1_ITYPE_NDEF_SEQUENCE	0x6

/* Cache for ASN1 tag and length, so we
 * don't keep re-reading it for things
 * like CHOICE
 */

struct ASN1_TLC_st{
	char valid;	/* Values below are valid */
	int ret;	/* return value */
	long plen;	/* length */
	int ptag;	/* class value */
	int pclass;	/* class value */
	int hdrlen;	/* header length */
};

/* Typedefs for ASN1 function pointers */

typedef ASN1_VALUE * ASN1_new_func(void);
typedef void ASN1_free_func(ASN1_VALUE *a);
typedef ASN1_VALUE * ASN1_d2i_func(ASN1_VALUE **a, const unsigned char ** in, long length);
typedef int ASN1_i2d_func(ASN1_VALUE * a, unsigned char **in);

typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it,
					int tag, int aclass, char opt, ASN1_TLC *ctx);

typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass);
typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);

typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval, 
						int indent, const char *fname, 
						const ASN1_PCTX *pctx);

typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it);
typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it);
typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx);

typedef struct ASN1_COMPAT_FUNCS_st {
	ASN1_new_func *asn1_new;
	ASN1_free_func *asn1_free;
	ASN1_d2i_func *asn1_d2i;
	ASN1_i2d_func *asn1_i2d;
} ASN1_COMPAT_FUNCS;

typedef struct ASN1_EXTERN_FUNCS_st {
	void *app_data;
	ASN1_ex_new_func *asn1_ex_new;
	ASN1_ex_free_func *asn1_ex_free;
	ASN1_ex_free_func *asn1_ex_clear;
	ASN1_ex_d2i *asn1_ex_d2i;
	ASN1_ex_i2d *asn1_ex_i2d;
	ASN1_ex_print_func *asn1_ex_print;
} ASN1_EXTERN_FUNCS;

typedef struct ASN1_PRIMITIVE_FUNCS_st {
	void *app_data;
	unsigned long flags;
	ASN1_ex_new_func *prim_new;
	ASN1_ex_free_func *prim_free;
	ASN1_ex_free_func *prim_clear;
	ASN1_primitive_c2i *prim_c2i;
	ASN1_primitive_i2c *prim_i2c;
	ASN1_primitive_print *prim_print;
} ASN1_PRIMITIVE_FUNCS;

/* This is the ASN1_AUX structure: it handles various
 * miscellaneous requirements. For example the use of
 * reference counts and an informational callback.
 *
 * The "informational callback" is called at various
 * points during the ASN1 encoding and decoding. It can
 * be used to provide minor customisation of the structures
 * used. This is most useful where the supplied routines
 * *almost* do the right thing but need some extra help
 * at a few points. If the callback returns zero then
 * it is assumed a fatal error has occurred and the 
 * main operation should be abandoned.
 *
 * If major changes in the default behaviour are required
 * then an external type is more appropriate.
 */

typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,
				void *exarg);

typedef struct ASN1_AUX_st {
	void *app_data;
	int flags;
	int ref_offset;		/* Offset of reference value */
	int ref_lock;		/* Lock type to use */
	ASN1_aux_cb *asn1_cb;
	int enc_offset;		/* Offset of ASN1_ENCODING structure */
} ASN1_AUX;

/* For print related callbacks exarg points to this structure */
typedef struct ASN1_PRINT_ARG_st {
	BIO *out;
	int indent;
	const ASN1_PCTX *pctx;
} ASN1_PRINT_ARG;

/* For streaming related callbacks exarg points to this structure */
typedef struct ASN1_STREAM_ARG_st {
	/* BIO to stream through */
	BIO *out;
	/* BIO with filters appended */
	BIO *ndef_bio;
	/* Streaming I/O boundary */
	unsigned char **boundary;
} ASN1_STREAM_ARG;

/* Flags in ASN1_AUX */

/* Use a reference count */
#define ASN1_AFLG_REFCOUNT	1
/* Save the encoding of structure (useful for signatures) */
#define ASN1_AFLG_ENCODING	2
/* The Sequence length is invalid */
#define ASN1_AFLG_BROKEN	4

/* operation values for asn1_cb */

#define ASN1_OP_NEW_PRE		0
#define ASN1_OP_NEW_POST	1
#define ASN1_OP_FREE_PRE	2
#define ASN1_OP_FREE_POST	3
#define ASN1_OP_D2I_PRE		4
#define ASN1_OP_D2I_POST	5
#define ASN1_OP_I2D_PRE		6
#define ASN1_OP_I2D_POST	7
#define ASN1_OP_PRINT_PRE	8
#define ASN1_OP_PRINT_POST	9
#define ASN1_OP_STREAM_PRE	10
#define ASN1_OP_STREAM_POST	11
#define ASN1_OP_DETACHED_PRE	12
#define ASN1_OP_DETACHED_POST	13

/* Macro to implement a primitive type */
#define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)
#define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \
				ASN1_ITEM_start(itname) \
					ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \
				ASN1_ITEM_end(itname)

/* Macro to implement a multi string type */
#define IMPLEMENT_ASN1_MSTRING(itname, mask) \
				ASN1_ITEM_start(itname) \
					ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \
				ASN1_ITEM_end(itname)

/* Macro to implement an ASN1_ITEM in terms of old style funcs */

#define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE)

#define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \
	static const ASN1_COMPAT_FUNCS sname##_ff = { \
		(ASN1_new_func *)sname##_new, \
		(ASN1_free_func *)sname##_free, \
		(ASN1_d2i_func *)d2i_##sname, \
		(ASN1_i2d_func *)i2d_##sname, \
	}; \
	ASN1_ITEM_start(sname) \
		ASN1_ITYPE_COMPAT, \
		tag, \
		NULL, \
		0, \
		&sname##_ff, \
		0, \
		#sname \
	ASN1_ITEM_end(sname)

#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \
	ASN1_ITEM_start(sname) \
		ASN1_ITYPE_EXTERN, \
		tag, \
		NULL, \
		0, \
		&fptrs, \
		0, \
		#sname \
	ASN1_ITEM_end(sname)

/* Macro to implement standard functions in terms of ASN1_ITEM structures */

#define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)

#define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)

#define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \
			IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)

#define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \
		IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)

#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \
		IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)

#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \
	pre stname *fname##_new(void) \
	{ \
		return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
	} \
	pre void fname##_free(stname *a) \
	{ \
		ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
	}

#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \
	stname *fname##_new(void) \
	{ \
		return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
	} \
	void fname##_free(stname *a) \
	{ \
		ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
	}

#define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \
	IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
	IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)

#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
	stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
	{ \
		return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
	} \
	int i2d_##fname(stname *a, unsigned char **out) \
	{ \
		return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
	} 

#define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \
	int i2d_##stname##_NDEF(stname *a, unsigned char **out) \
	{ \
		return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\
	} 

/* This includes evil casts to remove const: they will go away when full
 * ASN1 constification is done.
 */
#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
	stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
	{ \
		return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
	} \
	int i2d_##fname(const stname *a, unsigned char **out) \
	{ \
		return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
	} 

#define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \
	stname * stname##_dup(stname *x) \
        { \
        return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \
        }

#define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \
	IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname)

#define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \
	int fname##_print_ctx(BIO *out, stname *x, int indent, \
						const ASN1_PCTX *pctx) \
	{ \
		return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \
			ASN1_ITEM_rptr(itname), pctx); \
	} 

#define IMPLEMENT_ASN1_FUNCTIONS_const(name) \
		IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)

#define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \
	IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
	IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)

/* external definitions for primitive types */

DECLARE_ASN1_ITEM(ASN1_BOOLEAN)
DECLARE_ASN1_ITEM(ASN1_TBOOLEAN)
DECLARE_ASN1_ITEM(ASN1_FBOOLEAN)
DECLARE_ASN1_ITEM(ASN1_SEQUENCE)
DECLARE_ASN1_ITEM(CBIGNUM)
DECLARE_ASN1_ITEM(BIGNUM)
DECLARE_ASN1_ITEM(LONG)
DECLARE_ASN1_ITEM(ZLONG)

DECLARE_STACK_OF(ASN1_VALUE)

/* Functions used internally by the ASN1 code */

int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it);

void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
int ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_TEMPLATE *tt);
int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it,
				int tag, int aclass, char opt, ASN1_TLC *ctx);

int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass);
int ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt);
void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it);

int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it);
int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it);

int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it);
int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it);

ASN1_VALUE ** asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);

const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, int nullerr);

int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it);

void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it);
void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, const ASN1_ITEM *it);
int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, const ASN1_ITEM *it);

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/dso.h0000644000175000017500000004227612360020705021012 0ustar  /* $OpenBSD$ */
/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
 * project 2000.
 */
/* ====================================================================
 * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#ifndef HEADER_DSO_H
#define HEADER_DSO_H

#include 

#ifdef __cplusplus
extern "C" {
#endif

/* These values are used as commands to DSO_ctrl() */
#define DSO_CTRL_GET_FLAGS	1
#define DSO_CTRL_SET_FLAGS	2
#define DSO_CTRL_OR_FLAGS	3

/* By default, DSO_load() will translate the provided filename into a form
 * typical for the platform (more specifically the DSO_METHOD) using the
 * dso_name_converter function of the method. Eg. win32 will transform "blah"
 * into "blah.dll", and dlfcn will transform it into "libblah.so". The
 * behaviour can be overriden by setting the name_converter callback in the DSO
 * object (using DSO_set_name_converter()). This callback could even utilise
 * the DSO_METHOD's converter too if it only wants to override behaviour for
 * one or two possible DSO methods. However, the following flag can be set in a
 * DSO to prevent *any* native name-translation at all - eg. if the caller has
 * prompted the user for a path to a driver library so the filename should be
 * interpreted as-is. */
#define DSO_FLAG_NO_NAME_TRANSLATION		0x01
/* An extra flag to give if only the extension should be added as
 * translation.  This is obviously only of importance on Unix and
 * other operating systems where the translation also may prefix
 * the name with something, like 'lib', and ignored everywhere else.
 * This flag is also ignored if DSO_FLAG_NO_NAME_TRANSLATION is used
 * at the same time. */
#define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY	0x02

/* The following flag controls the translation of symbol names to upper
 * case.  This is currently only being implemented for OpenVMS.
 */
#define DSO_FLAG_UPCASE_SYMBOL			0x10

/* This flag loads the library with public symbols.
 * Meaning: The exported symbols of this library are public
 * to all libraries loaded after this library.
 * At the moment only implemented in unix.
 */
#define DSO_FLAG_GLOBAL_SYMBOLS			0x20


typedef void (*DSO_FUNC_TYPE)(void);

typedef struct dso_st DSO;

/* The function prototype used for method functions (or caller-provided
 * callbacks) that transform filenames. They are passed a DSO structure pointer
 * (or NULL if they are to be used independantly of a DSO object) and a
 * filename to transform. They should either return NULL (if there is an error
 * condition) or a newly allocated string containing the transformed form that
 * the caller will need to free with free() when done. */
typedef char* (*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *);
/* The function prototype used for method functions (or caller-provided
 * callbacks) that merge two file specifications. They are passed a
 * DSO structure pointer (or NULL if they are to be used independantly of
 * a DSO object) and two file specifications to merge. They should
 * either return NULL (if there is an error condition) or a newly allocated
 * string containing the result of merging that the caller will need
 * to free with free() when done.
 * Here, merging means that bits and pieces are taken from each of the
 * file specifications and added together in whatever fashion that is
 * sensible for the DSO method in question.  The only rule that really
 * applies is that if the two specification contain pieces of the same
 * type, the copy from the first string takes priority.  One could see
 * it as the first specification is the one given by the user and the
 * second being a bunch of defaults to add on if they're missing in the
 * first. */
typedef char* (*DSO_MERGER_FUNC)(DSO *, const char *, const char *);

typedef struct dso_meth_st {
	const char *name;
	/* Loads a shared library, NB: new DSO_METHODs must ensure that a
	 * successful load populates the loaded_filename field, and likewise a
	 * successful unload frees and NULLs it out. */
	int (*dso_load)(DSO *dso);
	/* Unloads a shared library */
	int (*dso_unload)(DSO *dso);
	/* Binds a variable */
	void *(*dso_bind_var)(DSO *dso, const char *symname);
	/* Binds a function - assumes a return type of DSO_FUNC_TYPE.
	 * This should be cast to the real function prototype by the
	 * caller. Platforms that don't have compatible representations
	 * for different prototypes (this is possible within ANSI C)
	 * are highly unlikely to have shared libraries at all, let
	 * alone a DSO_METHOD implemented for them. */
	DSO_FUNC_TYPE (*dso_bind_func)(DSO *dso, const char *symname);

/* I don't think this would actually be used in any circumstances. */
#if 0
	/* Unbinds a variable */
	int (*dso_unbind_var)(DSO *dso, char *symname, void *symptr);
	/* Unbinds a function */
	int (*dso_unbind_func)(DSO *dso, char *symname, DSO_FUNC_TYPE symptr);
#endif
	/* The generic (yuck) "ctrl()" function. NB: Negative return
	 * values (rather than zero) indicate errors. */
	long (*dso_ctrl)(DSO *dso, int cmd, long larg, void *parg);
	/* The default DSO_METHOD-specific function for converting filenames to
	 * a canonical native form. */
	DSO_NAME_CONVERTER_FUNC dso_name_converter;
	/* The default DSO_METHOD-specific function for converting filenames to
	 * a canonical native form. */
	DSO_MERGER_FUNC dso_merger;

	/* [De]Initialisation handlers. */
	int (*init)(DSO *dso);
	int (*finish)(DSO *dso);

	/* Return pathname of the module containing location */
	int (*pathbyaddr)(void *addr, char *path, int sz);
	/* Perform global symbol lookup, i.e. among *all* modules */
	void *(*globallookup)(const char *symname);
} DSO_METHOD;

/**********************************************************************/
/* The low-level handle type used to refer to a loaded shared library */

struct dso_st {
	DSO_METHOD *meth;
	/* Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS
	 * doesn't use anything but will need to cache the filename
	 * for use in the dso_bind handler. All in all, let each
	 * method control its own destiny. "Handles" and such go in
	 * a STACK. */
	STACK_OF(void) *meth_data;
	int references;
	int flags;
	/* For use by applications etc ... use this for your bits'n'pieces,
	 * don't touch meth_data! */
	CRYPTO_EX_DATA ex_data;
	/* If this callback function pointer is set to non-NULL, then it will
	 * be used in DSO_load() in place of meth->dso_name_converter. NB: This
	 * should normally set using DSO_set_name_converter(). */
	DSO_NAME_CONVERTER_FUNC name_converter;
	/* If this callback function pointer is set to non-NULL, then it will
	 * be used in DSO_load() in place of meth->dso_merger. NB: This
	 * should normally set using DSO_set_merger(). */
	DSO_MERGER_FUNC merger;
	/* This is populated with (a copy of) the platform-independant
	 * filename used for this DSO. */
	char *filename;
	/* This is populated with (a copy of) the translated filename by which
	 * the DSO was actually loaded. It is NULL iff the DSO is not currently
	 * loaded. NB: This is here because the filename translation process
	 * may involve a callback being invoked more than once not only to
	 * convert to a platform-specific form, but also to try different
	 * filenames in the process of trying to perform a load. As such, this
	 * variable can be used to indicate (a) whether this DSO structure
	 * corresponds to a loaded library or not, and (b) the filename with
	 * which it was actually loaded. */
	char *loaded_filename;
};


DSO *	DSO_new(void);
DSO *	DSO_new_method(DSO_METHOD *method);
int	DSO_free(DSO *dso);
int	DSO_flags(DSO *dso);
int	DSO_up_ref(DSO *dso);
long	DSO_ctrl(DSO *dso, int cmd, long larg, void *parg);

/* This function sets the DSO's name_converter callback. If it is non-NULL,
 * then it will be used instead of the associated DSO_METHOD's function. If
 * oldcb is non-NULL then it is set to the function pointer value being
 * replaced. Return value is non-zero for success. */
int	DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb,
	    DSO_NAME_CONVERTER_FUNC *oldcb);
/* These functions can be used to get/set the platform-independant filename
 * used for a DSO. NB: set will fail if the DSO is already loaded. */
const char *DSO_get_filename(DSO *dso);
int	DSO_set_filename(DSO *dso, const char *filename);
/* This function will invoke the DSO's name_converter callback to translate a
 * filename, or if the callback isn't set it will instead use the DSO_METHOD's
 * converter. If "filename" is NULL, the "filename" in the DSO itself will be
 * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is
 * simply duplicated. NB: This function is usually called from within a
 * DSO_METHOD during the processing of a DSO_load() call, and is exposed so that
 * caller-created DSO_METHODs can do the same thing. A non-NULL return value
 * will need to be free()'d. */
char	*DSO_convert_filename(DSO *dso, const char *filename);
/* This function will invoke the DSO's merger callback to merge two file
 * specifications, or if the callback isn't set it will instead use the
 * DSO_METHOD's merger.  A non-NULL return value will need to be
 * free()'d. */
char	*DSO_merge(DSO *dso, const char *filespec1, const char *filespec2);
/* If the DSO is currently loaded, this returns the filename that it was loaded
 * under, otherwise it returns NULL. So it is also useful as a test as to
 * whether the DSO is currently loaded. NB: This will not necessarily return
 * the same value as DSO_convert_filename(dso, dso->filename), because the
 * DSO_METHOD's load function may have tried a variety of filenames (with
 * and/or without the aid of the converters) before settling on the one it
 * actually loaded. */
const char *DSO_get_loaded_filename(DSO *dso);

void	DSO_set_default_method(DSO_METHOD *meth);
DSO_METHOD *DSO_get_default_method(void);
DSO_METHOD *DSO_get_method(DSO *dso);
DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth);

/* The all-singing all-dancing load function, you normally pass NULL
 * for the first and third parameters. Use DSO_up and DSO_free for
 * subsequent reference count handling. Any flags passed in will be set
 * in the constructed DSO after its init() function but before the
 * load operation. If 'dso' is non-NULL, 'flags' is ignored. */
DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags);

/* This function binds to a variable inside a shared library. */
void *DSO_bind_var(DSO *dso, const char *symname);

/* This function binds to a function inside a shared library. */
DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname);

/* This method is the default, but will beg, borrow, or steal whatever
 * method should be the default on any particular platform (including
 * DSO_METH_null() if necessary). */
DSO_METHOD *DSO_METHOD_openssl(void);

/* This method is defined for all platforms - if a platform has no
 * DSO support then this will be the only method! */
DSO_METHOD *DSO_METHOD_null(void);

/* If DSO_DLFCN is defined, the standard dlfcn.h-style functions
 * (dlopen, dlclose, dlsym, etc) will be used and incorporated into
 * this method. If not, this method will return NULL. */
DSO_METHOD *DSO_METHOD_dlfcn(void);

/* This function writes null-terminated pathname of DSO module
 * containing 'addr' into 'sz' large caller-provided 'path' and
 * returns the number of characters [including trailing zero]
 * written to it. If 'sz' is 0 or negative, 'path' is ignored and
 * required amount of charachers [including trailing zero] to
 * accomodate pathname is returned. If 'addr' is NULL, then
 * pathname of cryptolib itself is returned. Negative or zero
 * return value denotes error.
 */
int DSO_pathbyaddr(void *addr, char *path, int sz);

/* This function should be used with caution! It looks up symbols in
 * *all* loaded modules and if module gets unloaded by somebody else
 * attempt to dereference the pointer is doomed to have fatal
 * consequences. Primary usage for this function is to probe *core*
 * system functionality, e.g. check if getnameinfo(3) is available
 * at run-time without bothering about OS-specific details such as
 * libc.so.versioning or where does it actually reside: in libc
 * itself or libsocket. */
void *DSO_global_lookup(const char *name);

/* If BeOS is defined, use shared images. If not, return NULL. */
DSO_METHOD *DSO_METHOD_beos(void);

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_DSO_strings(void);

/* Error codes for the DSO functions. */

/* Function codes. */
#define DSO_F_BEOS_BIND_FUNC				 144
#define DSO_F_BEOS_BIND_VAR				 145
#define DSO_F_BEOS_LOAD					 146
#define DSO_F_BEOS_NAME_CONVERTER			 147
#define DSO_F_BEOS_UNLOAD				 148
#define DSO_F_DLFCN_BIND_FUNC				 100
#define DSO_F_DLFCN_BIND_VAR				 101
#define DSO_F_DLFCN_LOAD				 102
#define DSO_F_DLFCN_MERGER				 130
#define DSO_F_DLFCN_NAME_CONVERTER			 123
#define DSO_F_DLFCN_UNLOAD				 103
#define DSO_F_DL_BIND_FUNC				 104
#define DSO_F_DL_BIND_VAR				 105
#define DSO_F_DL_LOAD					 106
#define DSO_F_DL_MERGER					 131
#define DSO_F_DL_NAME_CONVERTER				 124
#define DSO_F_DL_UNLOAD					 107
#define DSO_F_DSO_BIND_FUNC				 108
#define DSO_F_DSO_BIND_VAR				 109
#define DSO_F_DSO_CONVERT_FILENAME			 126
#define DSO_F_DSO_CTRL					 110
#define DSO_F_DSO_FREE					 111
#define DSO_F_DSO_GET_FILENAME				 127
#define DSO_F_DSO_GET_LOADED_FILENAME			 128
#define DSO_F_DSO_GLOBAL_LOOKUP				 139
#define DSO_F_DSO_LOAD					 112
#define DSO_F_DSO_MERGE					 132
#define DSO_F_DSO_NEW_METHOD				 113
#define DSO_F_DSO_PATHBYADDR				 140
#define DSO_F_DSO_SET_FILENAME				 129
#define DSO_F_DSO_SET_NAME_CONVERTER			 122
#define DSO_F_DSO_UP_REF				 114
#define DSO_F_GLOBAL_LOOKUP_FUNC			 138
#define DSO_F_PATHBYADDR				 137
#define DSO_F_VMS_BIND_SYM				 115
#define DSO_F_VMS_LOAD					 116
#define DSO_F_VMS_MERGER				 133
#define DSO_F_VMS_UNLOAD				 117
#define DSO_F_WIN32_BIND_FUNC				 118
#define DSO_F_WIN32_BIND_VAR				 119
#define DSO_F_WIN32_GLOBALLOOKUP			 142
#define DSO_F_WIN32_GLOBALLOOKUP_FUNC			 143
#define DSO_F_WIN32_JOINER				 135
#define DSO_F_WIN32_LOAD				 120
#define DSO_F_WIN32_MERGER				 134
#define DSO_F_WIN32_NAME_CONVERTER			 125
#define DSO_F_WIN32_PATHBYADDR				 141
#define DSO_F_WIN32_SPLITTER				 136
#define DSO_F_WIN32_UNLOAD				 121

/* Reason codes. */
#define DSO_R_CTRL_FAILED				 100
#define DSO_R_DSO_ALREADY_LOADED			 110
#define DSO_R_EMPTY_FILE_STRUCTURE			 113
#define DSO_R_FAILURE					 114
#define DSO_R_FILENAME_TOO_BIG				 101
#define DSO_R_FINISH_FAILED				 102
#define DSO_R_INCORRECT_FILE_SYNTAX			 115
#define DSO_R_LOAD_FAILED				 103
#define DSO_R_NAME_TRANSLATION_FAILED			 109
#define DSO_R_NO_FILENAME				 111
#define DSO_R_NO_FILE_SPECIFICATION			 116
#define DSO_R_NULL_HANDLE				 104
#define DSO_R_SET_FILENAME_FAILED			 112
#define DSO_R_STACK_ERROR				 105
#define DSO_R_SYM_FAILURE				 106
#define DSO_R_UNLOAD_FAILED				 107
#define DSO_R_UNSUPPORTED				 108

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/pkcs7.h0000644000175000017500000004274212360020705021252 0ustar  /* $OpenBSD: pkcs7.h,v 1.13 2014/06/12 15:49:30 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_PKCS7_H
#define HEADER_PKCS7_H

#include 

#include 
#include 
#include 

#ifdef  __cplusplus
extern "C" {
#endif

/*
Encryption_ID		DES-CBC
Digest_ID		MD5
Digest_Encryption_ID	rsaEncryption
Key_Encryption_ID	rsaEncryption
*/

typedef struct pkcs7_issuer_and_serial_st {
	X509_NAME *issuer;
	ASN1_INTEGER *serial;
} PKCS7_ISSUER_AND_SERIAL;

typedef struct pkcs7_signer_info_st {
	ASN1_INTEGER 			*version;	/* version 1 */
	PKCS7_ISSUER_AND_SERIAL		*issuer_and_serial;
	X509_ALGOR			*digest_alg;
	STACK_OF(X509_ATTRIBUTE)	*auth_attr;	/* [ 0 ] */
	X509_ALGOR			*digest_enc_alg;
	ASN1_OCTET_STRING		*enc_digest;
	STACK_OF(X509_ATTRIBUTE)	*unauth_attr;	/* [ 1 ] */

	/* The private key to sign with */
	EVP_PKEY			*pkey;
} PKCS7_SIGNER_INFO;

DECLARE_STACK_OF(PKCS7_SIGNER_INFO)
DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO)

typedef struct pkcs7_recip_info_st {
	ASN1_INTEGER			*version;	/* version 0 */
	PKCS7_ISSUER_AND_SERIAL		*issuer_and_serial;
	X509_ALGOR			*key_enc_algor;
	ASN1_OCTET_STRING		*enc_key;
	X509				*cert; /* get the pub-key from this */
} PKCS7_RECIP_INFO;

DECLARE_STACK_OF(PKCS7_RECIP_INFO)
DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO)

typedef struct pkcs7_signed_st {
	ASN1_INTEGER			*version;	/* version 1 */
	STACK_OF(X509_ALGOR)		*md_algs;	/* md used */
	STACK_OF(X509)			*cert;		/* [ 0 ] */
	STACK_OF(X509_CRL)		*crl;		/* [ 1 ] */
	STACK_OF(PKCS7_SIGNER_INFO)	*signer_info;

	struct pkcs7_st			*contents;
} PKCS7_SIGNED;
/* The above structure is very very similar to PKCS7_SIGN_ENVELOPE.
 * How about merging the two */

typedef struct pkcs7_enc_content_st {
	ASN1_OBJECT			*content_type;
	X509_ALGOR			*algorithm;
	ASN1_OCTET_STRING		*enc_data;	/* [ 0 ] */
	const EVP_CIPHER		*cipher;
} PKCS7_ENC_CONTENT;

typedef struct pkcs7_enveloped_st {
	ASN1_INTEGER			*version;	/* version 0 */
	STACK_OF(PKCS7_RECIP_INFO)	*recipientinfo;
	PKCS7_ENC_CONTENT		*enc_data;
} PKCS7_ENVELOPE;

typedef struct pkcs7_signedandenveloped_st {
	ASN1_INTEGER			*version;	/* version 1 */
	STACK_OF(X509_ALGOR)		*md_algs;	/* md used */
	STACK_OF(X509)			*cert;		/* [ 0 ] */
	STACK_OF(X509_CRL)		*crl;		/* [ 1 ] */
	STACK_OF(PKCS7_SIGNER_INFO)	*signer_info;

	PKCS7_ENC_CONTENT		*enc_data;
	STACK_OF(PKCS7_RECIP_INFO)	*recipientinfo;
} PKCS7_SIGN_ENVELOPE;

typedef struct pkcs7_digest_st {
	ASN1_INTEGER			*version;	/* version 0 */
	X509_ALGOR			*md;		/* md used */
	struct pkcs7_st 		*contents;
	ASN1_OCTET_STRING		*digest;
} PKCS7_DIGEST;

typedef struct pkcs7_encrypted_st {
	ASN1_INTEGER			*version;	/* version 0 */
	PKCS7_ENC_CONTENT		*enc_data;
} PKCS7_ENCRYPT;

typedef struct pkcs7_st {
	/* The following is non NULL if it contains ASN1 encoding of
	 * this structure */
	unsigned char *asn1;
	long length;

#define PKCS7_S_HEADER	0
#define PKCS7_S_BODY	1
#define PKCS7_S_TAIL	2
	int state; /* used during processing */

	int detached;

	ASN1_OBJECT *type;
	/* content as defined by the type */
	/* all encryption/message digests are applied to the 'contents',
	 * leaving out the 'type' field. */
	union	{
		char *ptr;

		/* NID_pkcs7_data */
		ASN1_OCTET_STRING *data;

		/* NID_pkcs7_signed */
		PKCS7_SIGNED *sign;

		/* NID_pkcs7_enveloped */
		PKCS7_ENVELOPE *enveloped;

		/* NID_pkcs7_signedAndEnveloped */
		PKCS7_SIGN_ENVELOPE *signed_and_enveloped;

		/* NID_pkcs7_digest */
		PKCS7_DIGEST *digest;

		/* NID_pkcs7_encrypted */
		PKCS7_ENCRYPT *encrypted;

		/* Anything else */
		ASN1_TYPE *other;
	} d;
} PKCS7;

DECLARE_STACK_OF(PKCS7)
DECLARE_ASN1_SET_OF(PKCS7)
DECLARE_PKCS12_STACK_OF(PKCS7)

#define PKCS7_OP_SET_DETACHED_SIGNATURE	1
#define PKCS7_OP_GET_DETACHED_SIGNATURE	2

#define PKCS7_get_signed_attributes(si)	((si)->auth_attr)
#define PKCS7_get_attributes(si)	((si)->unauth_attr)

#define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed)
#define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)
#define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped)
#define PKCS7_type_is_signedAndEnveloped(a) \
		(OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped)
#define PKCS7_type_is_data(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_data)
#define PKCS7_type_is_digest(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)
#define PKCS7_type_is_encrypted(a) \
		(OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)

#define PKCS7_type_is_digest(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)

#define PKCS7_set_detached(p,v) \
		PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL)
#define PKCS7_get_detached(p) \
		PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL)

#define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7))

/* S/MIME related flags */

#define PKCS7_TEXT		0x1
#define PKCS7_NOCERTS		0x2
#define PKCS7_NOSIGS		0x4
#define PKCS7_NOCHAIN		0x8
#define PKCS7_NOINTERN		0x10
#define PKCS7_NOVERIFY		0x20
#define PKCS7_DETACHED		0x40
#define PKCS7_BINARY		0x80
#define PKCS7_NOATTR		0x100
#define	PKCS7_NOSMIMECAP	0x200
#define PKCS7_NOOLDMIMETYPE	0x400
#define PKCS7_CRLFEOL		0x800
#define PKCS7_STREAM		0x1000
#define PKCS7_NOCRL		0x2000
#define PKCS7_PARTIAL		0x4000
#define PKCS7_REUSE_DIGEST	0x8000

/* Flags: for compatibility with older code */

#define SMIME_TEXT	PKCS7_TEXT
#define SMIME_NOCERTS	PKCS7_NOCERTS
#define SMIME_NOSIGS	PKCS7_NOSIGS
#define SMIME_NOCHAIN	PKCS7_NOCHAIN
#define SMIME_NOINTERN	PKCS7_NOINTERN
#define SMIME_NOVERIFY	PKCS7_NOVERIFY
#define SMIME_DETACHED	PKCS7_DETACHED
#define SMIME_BINARY	PKCS7_BINARY
#define SMIME_NOATTR	PKCS7_NOATTR

DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL)

int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,
    const EVP_MD *type, unsigned char *md, unsigned int *len);
PKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7);
int i2d_PKCS7_fp(FILE *fp, PKCS7 *p7);
PKCS7 *PKCS7_dup(PKCS7 *p7);
PKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7);
int i2d_PKCS7_bio(BIO *bp, PKCS7 *p7);
int i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);
int PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);

DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO)
DECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO)
DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED)
DECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT)
DECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE)
DECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE)
DECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST)
DECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT)
DECLARE_ASN1_FUNCTIONS(PKCS7)

DECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN)
DECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY)

DECLARE_ASN1_NDEF_FUNCTION(PKCS7)
DECLARE_ASN1_PRINT_FUNCTION(PKCS7)

long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg);

int PKCS7_set_type(PKCS7 *p7, int type);
int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other);
int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data);
int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
    const EVP_MD *dgst);
int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si);
int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i);
int PKCS7_add_certificate(PKCS7 *p7, X509 *x509);
int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509);
int PKCS7_content_new(PKCS7 *p7, int nid);
int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx,
    BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si);
int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,
    X509 *x509);

BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio);
int PKCS7_dataFinal(PKCS7 *p7, BIO *bio);
BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert);


PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509,
    EVP_PKEY *pkey, const EVP_MD *dgst);
X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si);
int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md);
STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7);

PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509);
void PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk,
    X509_ALGOR **pdig, X509_ALGOR **psig);
void PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc);
int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri);
int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509);
int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher);
int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7);

PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx);
ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk);
int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type,
    void *data);
int PKCS7_add_attribute (PKCS7_SIGNER_INFO *p7si, int nid, int atrtype,
    void *value);
ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid);
ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid);
int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si,
    STACK_OF(X509_ATTRIBUTE) *sk);
int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si, STACK_OF(X509_ATTRIBUTE) *sk);


PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
    BIO *data, int flags);

PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7,
    X509 *signcert, EVP_PKEY *pkey, const EVP_MD *md,
    int flags);

int PKCS7_final(PKCS7 *p7, BIO *data, int flags);
int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
    BIO *indata, BIO *out, int flags);
STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags);
PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,
    int flags);
int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags);

int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si,
    STACK_OF(X509_ALGOR) *cap);
STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si);
int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg);

int PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid);
int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t);
int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,
    const unsigned char *md, int mdlen);

int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags);
PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont);

BIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7);


/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_PKCS7_strings(void);

/* Error codes for the PKCS7 functions. */

/* Function codes. */
#define PKCS7_F_B64_READ_PKCS7				 120
#define PKCS7_F_B64_WRITE_PKCS7				 121
#define PKCS7_F_DO_PKCS7_SIGNED_ATTRIB			 136
#define PKCS7_F_I2D_PKCS7_BIO_STREAM			 140
#define PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME		 135
#define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP		 118
#define PKCS7_F_PKCS7_ADD_CERTIFICATE			 100
#define PKCS7_F_PKCS7_ADD_CRL				 101
#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO		 102
#define PKCS7_F_PKCS7_ADD_SIGNATURE			 131
#define PKCS7_F_PKCS7_ADD_SIGNER			 103
#define PKCS7_F_PKCS7_BIO_ADD_DIGEST			 125
#define PKCS7_F_PKCS7_COPY_EXISTING_DIGEST		 138
#define PKCS7_F_PKCS7_CTRL				 104
#define PKCS7_F_PKCS7_DATADECODE			 112
#define PKCS7_F_PKCS7_DATAFINAL				 128
#define PKCS7_F_PKCS7_DATAINIT				 105
#define PKCS7_F_PKCS7_DATASIGN				 106
#define PKCS7_F_PKCS7_DATAVERIFY			 107
#define PKCS7_F_PKCS7_DECRYPT				 114
#define PKCS7_F_PKCS7_DECRYPT_RINFO			 133
#define PKCS7_F_PKCS7_ENCODE_RINFO			 132
#define PKCS7_F_PKCS7_ENCRYPT				 115
#define PKCS7_F_PKCS7_FINAL				 134
#define PKCS7_F_PKCS7_FIND_DIGEST			 127
#define PKCS7_F_PKCS7_GET0_SIGNERS			 124
#define PKCS7_F_PKCS7_RECIP_INFO_SET			 130
#define PKCS7_F_PKCS7_SET_CIPHER			 108
#define PKCS7_F_PKCS7_SET_CONTENT			 109
#define PKCS7_F_PKCS7_SET_DIGEST			 126
#define PKCS7_F_PKCS7_SET_TYPE				 110
#define PKCS7_F_PKCS7_SIGN				 116
#define PKCS7_F_PKCS7_SIGNATUREVERIFY			 113
#define PKCS7_F_PKCS7_SIGNER_INFO_SET			 129
#define PKCS7_F_PKCS7_SIGNER_INFO_SIGN			 139
#define PKCS7_F_PKCS7_SIGN_ADD_SIGNER			 137
#define PKCS7_F_PKCS7_SIMPLE_SMIMECAP			 119
#define PKCS7_F_PKCS7_VERIFY				 117
#define PKCS7_F_SMIME_READ_PKCS7			 122
#define PKCS7_F_SMIME_TEXT				 123

/* Reason codes. */
#define PKCS7_R_CERTIFICATE_VERIFY_ERROR		 117
#define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER		 144
#define PKCS7_R_CIPHER_NOT_INITIALIZED			 116
#define PKCS7_R_CONTENT_AND_DATA_PRESENT		 118
#define PKCS7_R_CTRL_ERROR				 152
#define PKCS7_R_DECODE_ERROR				 130
#define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH		 100
#define PKCS7_R_DECRYPT_ERROR				 119
#define PKCS7_R_DIGEST_FAILURE				 101
#define PKCS7_R_ENCRYPTION_CTRL_FAILURE			 149
#define PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 150
#define PKCS7_R_ERROR_ADDING_RECIPIENT			 120
#define PKCS7_R_ERROR_SETTING_CIPHER			 121
#define PKCS7_R_INVALID_MIME_TYPE			 131
#define PKCS7_R_INVALID_NULL_POINTER			 143
#define PKCS7_R_MIME_NO_CONTENT_TYPE			 132
#define PKCS7_R_MIME_PARSE_ERROR			 133
#define PKCS7_R_MIME_SIG_PARSE_ERROR			 134
#define PKCS7_R_MISSING_CERIPEND_INFO			 103
#define PKCS7_R_NO_CONTENT				 122
#define PKCS7_R_NO_CONTENT_TYPE				 135
#define PKCS7_R_NO_DEFAULT_DIGEST			 151
#define PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND		 154
#define PKCS7_R_NO_MULTIPART_BODY_FAILURE		 136
#define PKCS7_R_NO_MULTIPART_BOUNDARY			 137
#define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE	 115
#define PKCS7_R_NO_RECIPIENT_MATCHES_KEY		 146
#define PKCS7_R_NO_SIGNATURES_ON_DATA			 123
#define PKCS7_R_NO_SIGNERS				 142
#define PKCS7_R_NO_SIG_CONTENT_TYPE			 138
#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE	 104
#define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR		 124
#define PKCS7_R_PKCS7_ADD_SIGNER_ERROR			 153
#define PKCS7_R_PKCS7_DATAFINAL				 126
#define PKCS7_R_PKCS7_DATAFINAL_ERROR			 125
#define PKCS7_R_PKCS7_DATASIGN				 145
#define PKCS7_R_PKCS7_PARSE_ERROR			 139
#define PKCS7_R_PKCS7_SIG_PARSE_ERROR			 140
#define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE	 127
#define PKCS7_R_SIGNATURE_FAILURE			 105
#define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND		 128
#define PKCS7_R_SIGNING_CTRL_FAILURE			 147
#define PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE	 148
#define PKCS7_R_SIG_INVALID_MIME_TYPE			 141
#define PKCS7_R_SMIME_TEXT_ERROR			 129
#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE		 106
#define PKCS7_R_UNABLE_TO_FIND_MEM_BIO			 107
#define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST		 108
#define PKCS7_R_UNKNOWN_DIGEST_TYPE			 109
#define PKCS7_R_UNKNOWN_OPERATION			 110
#define PKCS7_R_UNSUPPORTED_CIPHER_TYPE			 111
#define PKCS7_R_UNSUPPORTED_CONTENT_TYPE		 112
#define PKCS7_R_WRONG_CONTENT_TYPE			 113
#define PKCS7_R_WRONG_PKCS7_TYPE			 114

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/rc5.h0000644000175000017500000001114512360020705020705 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_RC5_H
#define HEADER_RC5_H

#include  /* OPENSSL_NO_RC5 */

#ifdef  __cplusplus
extern "C" {
#endif

#ifdef OPENSSL_NO_RC5
#error RC5 is disabled.
#endif

#define RC5_ENCRYPT	1
#define RC5_DECRYPT	0

/* 32 bit.  For Alpha, things may get weird */
#define RC5_32_INT unsigned long

#define RC5_32_BLOCK		8
#define RC5_32_KEY_LENGTH	16 /* This is a default, max is 255 */

/* This are the only values supported.  Tweak the code if you want more
 * The most supported modes will be
 * RC5-32/12/16
 * RC5-32/16/8
 */
#define RC5_8_ROUNDS	8
#define RC5_12_ROUNDS	12
#define RC5_16_ROUNDS	16

typedef struct rc5_key_st
	{
	/* Number of rounds */
	int rounds;
	RC5_32_INT data[2*(RC5_16_ROUNDS+1)];
	} RC5_32_KEY;

 
void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
	int rounds);
void RC5_32_ecb_encrypt(const unsigned char *in,unsigned char *out,RC5_32_KEY *key,
	int enc);
void RC5_32_encrypt(unsigned long *data,RC5_32_KEY *key);
void RC5_32_decrypt(unsigned long *data,RC5_32_KEY *key);
void RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out,
			long length, RC5_32_KEY *ks, unsigned char *iv,
			int enc);
void RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out,
			  long length, RC5_32_KEY *schedule,
			  unsigned char *ivec, int *num, int enc);
void RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out,
			  long length, RC5_32_KEY *schedule,
			  unsigned char *ivec, int *num);

#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/ssl23.h0000644000175000017500000000723512360020705021167 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_SSL23_H 
#define HEADER_SSL23_H 

#ifdef  __cplusplus
extern "C" {
#endif

/*client */
/* write to server */
#define SSL23_ST_CW_CLNT_HELLO_A	(0x210|SSL_ST_CONNECT)
#define SSL23_ST_CW_CLNT_HELLO_B	(0x211|SSL_ST_CONNECT)
/* read from server */
#define SSL23_ST_CR_SRVR_HELLO_A	(0x220|SSL_ST_CONNECT)
#define SSL23_ST_CR_SRVR_HELLO_B	(0x221|SSL_ST_CONNECT)

/* server */
/* read from client */
#define SSL23_ST_SR_CLNT_HELLO_A	(0x210|SSL_ST_ACCEPT)
#define SSL23_ST_SR_CLNT_HELLO_B	(0x211|SSL_ST_ACCEPT)

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/idea.h0000644000175000017500000001037512360020705021122 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_IDEA_H
#define HEADER_IDEA_H

#include  /* IDEA_INT, OPENSSL_NO_IDEA */

#ifdef OPENSSL_NO_IDEA
#error IDEA is disabled.
#endif

#define IDEA_ENCRYPT	1
#define IDEA_DECRYPT	0

#define IDEA_BLOCK	8
#define IDEA_KEY_LENGTH	16

#ifdef  __cplusplus
extern "C" {
#endif

typedef struct idea_key_st
	{
	IDEA_INT data[9][6];
	} IDEA_KEY_SCHEDULE;

const char *idea_options(void);
void idea_ecb_encrypt(const unsigned char *in, unsigned char *out,
	IDEA_KEY_SCHEDULE *ks);
void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);
void idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk);
void idea_cbc_encrypt(const unsigned char *in, unsigned char *out,
	long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,int enc);
void idea_cfb64_encrypt(const unsigned char *in, unsigned char *out,
	long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,
	int *num,int enc);
void idea_ofb64_encrypt(const unsigned char *in, unsigned char *out,
	long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int *num);
void idea_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks);
#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/dh.h0000644000175000017500000002333312360020705020611 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_DH_H
#define HEADER_DH_H

#include 

#ifdef OPENSSL_NO_DH
#error DH is disabled.
#endif

#ifndef OPENSSL_NO_BIO
#include 
#endif
#include 
#ifndef OPENSSL_NO_DEPRECATED
#include 
#endif
	
#ifndef OPENSSL_DH_MAX_MODULUS_BITS
# define OPENSSL_DH_MAX_MODULUS_BITS	10000
#endif

#define DH_FLAG_CACHE_MONT_P     0x01
#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH
                                       * implementation now uses constant time
                                       * modular exponentiation for secret exponents
                                       * by default. This flag causes the
                                       * faster variable sliding window method to
                                       * be used for all exponents.
                                       */

/* If this flag is set the DH method is FIPS compliant and can be used
 * in FIPS mode. This is set in the validated module method. If an
 * application sets this flag in its own methods it is its reposibility
 * to ensure the result is compliant.
 */

#define DH_FLAG_FIPS_METHOD			0x0400

/* If this flag is set the operations normally disabled in FIPS mode are
 * permitted it is then the applications responsibility to ensure that the
 * usage is compliant.
 */

#define DH_FLAG_NON_FIPS_ALLOW			0x0400

#ifdef  __cplusplus
extern "C" {
#endif

/* Already defined in ossl_typ.h */
/* typedef struct dh_st DH; */
/* typedef struct dh_method DH_METHOD; */

struct dh_method
	{
	const char *name;
	/* Methods here */
	int (*generate_key)(DH *dh);
	int (*compute_key)(unsigned char *key,const BIGNUM *pub_key,DH *dh);
	int (*bn_mod_exp)(const DH *dh, BIGNUM *r, const BIGNUM *a,
				const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
				BN_MONT_CTX *m_ctx); /* Can be null */

	int (*init)(DH *dh);
	int (*finish)(DH *dh);
	int flags;
	char *app_data;
	/* If this is non-NULL, it will be used to generate parameters */
	int (*generate_params)(DH *dh, int prime_len, int generator, BN_GENCB *cb);
	};

struct dh_st
	{
	/* This first argument is used to pick up errors when
	 * a DH is passed instead of a EVP_PKEY */
	int pad;
	int version;
	BIGNUM *p;
	BIGNUM *g;
	long length; /* optional */
	BIGNUM *pub_key;	/* g^x */
	BIGNUM *priv_key;	/* x */

	int flags;
	BN_MONT_CTX *method_mont_p;
	/* Place holders if we want to do X9.42 DH */
	BIGNUM *q;
	BIGNUM *j;
	unsigned char *seed;
	int seedlen;
	BIGNUM *counter;

	int references;
	CRYPTO_EX_DATA ex_data;
	const DH_METHOD *meth;
	ENGINE *engine;
	};

#define DH_GENERATOR_2		2
/* #define DH_GENERATOR_3	3 */
#define DH_GENERATOR_5		5

/* DH_check error codes */
#define DH_CHECK_P_NOT_PRIME		0x01
#define DH_CHECK_P_NOT_SAFE_PRIME	0x02
#define DH_UNABLE_TO_CHECK_GENERATOR	0x04
#define DH_NOT_SUITABLE_GENERATOR	0x08

/* DH_check_pub_key error codes */
#define DH_CHECK_PUBKEY_TOO_SMALL	0x01
#define DH_CHECK_PUBKEY_TOO_LARGE	0x02

/* primes p where (p-1)/2 is prime too are called "safe"; we define
   this for backward compatibility: */
#define DH_CHECK_P_NOT_STRONG_PRIME	DH_CHECK_P_NOT_SAFE_PRIME

#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \
		(char *(*)())d2i_DHparams,(fp),(unsigned char **)(x))
#define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \
		(unsigned char *)(x))
#define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x)
#define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x)

DH *DHparams_dup(DH *);

const DH_METHOD *DH_OpenSSL(void);

void DH_set_default_method(const DH_METHOD *meth);
const DH_METHOD *DH_get_default_method(void);
int DH_set_method(DH *dh, const DH_METHOD *meth);
DH *DH_new_method(ENGINE *engine);

DH *	DH_new(void);
void	DH_free(DH *dh);
int	DH_up_ref(DH *dh);
int	DH_size(const DH *dh);
int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
	     CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
int DH_set_ex_data(DH *d, int idx, void *arg);
void *DH_get_ex_data(DH *d, int idx);

/* Deprecated version */
#ifndef OPENSSL_NO_DEPRECATED
DH *	DH_generate_parameters(int prime_len,int generator,
		void (*callback)(int,int,void *),void *cb_arg);
#endif /* !defined(OPENSSL_NO_DEPRECATED) */

/* New version */
int	DH_generate_parameters_ex(DH *dh, int prime_len,int generator, BN_GENCB *cb);

int	DH_check(const DH *dh,int *codes);
int	DH_check_pub_key(const DH *dh,const BIGNUM *pub_key, int *codes);
int	DH_generate_key(DH *dh);
int	DH_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh);
DH *	d2i_DHparams(DH **a,const unsigned char **pp, long length);
int	i2d_DHparams(const DH *a,unsigned char **pp);
int	DHparams_print_fp(FILE *fp, const DH *x);
#ifndef OPENSSL_NO_BIO
int	DHparams_print(BIO *bp, const DH *x);
#else
int	DHparams_print(char *bp, const DH *x);
#endif

#define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \
	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
			EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, len, NULL)

#define EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, gen) \
	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
			EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL)

#define	EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN	(EVP_PKEY_ALG_CTRL + 1)
#define	EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR	(EVP_PKEY_ALG_CTRL + 2)
		

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_DH_strings(void);

/* Error codes for the DH functions. */

/* Function codes. */
#define DH_F_COMPUTE_KEY				 102
#define DH_F_DHPARAMS_PRINT_FP				 101
#define DH_F_DH_BUILTIN_GENPARAMS			 106
#define DH_F_DH_COMPUTE_KEY				 114
#define DH_F_DH_GENERATE_KEY				 115
#define DH_F_DH_GENERATE_PARAMETERS_EX			 116
#define DH_F_DH_NEW_METHOD				 105
#define DH_F_DH_PARAM_DECODE				 107
#define DH_F_DH_PRIV_DECODE				 110
#define DH_F_DH_PRIV_ENCODE				 111
#define DH_F_DH_PUB_DECODE				 108
#define DH_F_DH_PUB_ENCODE				 109
#define DH_F_DO_DH_PRINT				 100
#define DH_F_GENERATE_KEY				 103
#define DH_F_GENERATE_PARAMETERS			 104
#define DH_F_PKEY_DH_DERIVE				 112
#define DH_F_PKEY_DH_KEYGEN				 113

/* Reason codes. */
#define DH_R_BAD_GENERATOR				 101
#define DH_R_BN_DECODE_ERROR				 109
#define DH_R_BN_ERROR					 106
#define DH_R_DECODE_ERROR				 104
#define DH_R_INVALID_PUBKEY				 102
#define DH_R_KEYS_NOT_SET				 108
#define DH_R_KEY_SIZE_TOO_SMALL				 110
#define DH_R_MODULUS_TOO_LARGE				 103
#define DH_R_NON_FIPS_METHOD				 111
#define DH_R_NO_PARAMETERS_SET				 107
#define DH_R_NO_PRIVATE_VALUE				 100
#define DH_R_PARAMETER_ENCODING_ERROR			 105

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/buffer.h0000644000175000017500000001120312360020705021460 0ustar  /* $OpenBSD: buffer.h,v 1.10 2014/06/14 10:28:31 avsm Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_BUFFER_H
#define HEADER_BUFFER_H

#include 

#ifdef  __cplusplus
extern "C" {
#endif

#include 
#include 

/* Already declared in ossl_typ.h */
/* typedef struct buf_mem_st BUF_MEM; */

struct buf_mem_st {
	size_t length;	/* current number of bytes */
	char *data;
	size_t max;	/* size of buffer */
};

BUF_MEM *BUF_MEM_new(void);
void	BUF_MEM_free(BUF_MEM *a);
int	BUF_MEM_grow(BUF_MEM *str, size_t len);
int	BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
char *	BUF_strdup(const char *str);
char *	BUF_strndup(const char *str, size_t siz);
void *	BUF_memdup(const void *data, size_t siz);
void	BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz);

/* safe string functions */
size_t BUF_strlcpy(char *dst, const char *src, size_t siz)
	__attribute__ ((__bounded__(__string__,1,3)));
size_t BUF_strlcat(char *dst, const char *src, size_t siz)
	__attribute__ ((__bounded__(__string__,1,3)));


/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_BUF_strings(void);

/* Error codes for the BUF functions. */

/* Function codes. */
#define BUF_F_BUF_MEMDUP				 103
#define BUF_F_BUF_MEM_GROW				 100
#define BUF_F_BUF_MEM_GROW_CLEAN			 105
#define BUF_F_BUF_MEM_NEW				 101
#define BUF_F_BUF_STRDUP				 102
#define BUF_F_BUF_STRNDUP				 104

/* Reason codes. */

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/ts.h0000644000175000017500000007372512360020705020656 0ustar  /* $OpenBSD: ts.h,v 1.6 2014/06/12 15:49:30 deraadt Exp $ */
/* Written by Zoltan Glozik (zglozik@opentsa.org) for the OpenSSL
 * project 2002, 2003, 2004.
 */
/* ====================================================================
 * Copyright (c) 2006 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#ifndef HEADER_TS_H
#define HEADER_TS_H

#include 

#ifndef OPENSSL_NO_BUFFER
#include 
#endif
#ifndef OPENSSL_NO_EVP
#include 
#endif
#ifndef OPENSSL_NO_BIO
#include 
#endif
#include 
#include 
#include 

#ifndef OPENSSL_NO_RSA
#include 
#endif

#ifndef OPENSSL_NO_DSA
#include 
#endif

#ifndef OPENSSL_NO_DH
#include 
#endif

#ifdef  __cplusplus
extern "C" {
#endif

#include 
#include 

/*
MessageImprint ::= SEQUENCE  {
     hashAlgorithm                AlgorithmIdentifier,
     hashedMessage                OCTET STRING  }
*/

typedef struct TS_msg_imprint_st {
	X509_ALGOR *hash_algo;
	ASN1_OCTET_STRING *hashed_msg;
} TS_MSG_IMPRINT;

/*
TimeStampReq ::= SEQUENCE  {
   version                  INTEGER  { v1(1) },
   messageImprint           MessageImprint,
     --a hash algorithm OID and the hash value of the data to be
     --time-stamped
   reqPolicy                TSAPolicyId                OPTIONAL,
   nonce                    INTEGER                    OPTIONAL,
   certReq                  BOOLEAN                    DEFAULT FALSE,
   extensions               [0] IMPLICIT Extensions    OPTIONAL  }
*/

typedef struct TS_req_st {
	ASN1_INTEGER *version;
	TS_MSG_IMPRINT *msg_imprint;
	ASN1_OBJECT *policy_id;		/* OPTIONAL */
	ASN1_INTEGER *nonce;		/* OPTIONAL */
	ASN1_BOOLEAN cert_req;		/* DEFAULT FALSE */
	STACK_OF(X509_EXTENSION) *extensions;	/* [0] OPTIONAL */
} TS_REQ;

/*
Accuracy ::= SEQUENCE {
                seconds        INTEGER           OPTIONAL,
                millis     [0] INTEGER  (1..999) OPTIONAL,
                micros     [1] INTEGER  (1..999) OPTIONAL  }
*/

typedef struct TS_accuracy_st {
	ASN1_INTEGER *seconds;
	ASN1_INTEGER *millis;
	ASN1_INTEGER *micros;
} TS_ACCURACY;

/*
TSTInfo ::= SEQUENCE  {
    version                      INTEGER  { v1(1) },
    policy                       TSAPolicyId,
    messageImprint               MessageImprint,
      -- MUST have the same value as the similar field in
      -- TimeStampReq
    serialNumber                 INTEGER,
     -- Time-Stamping users MUST be ready to accommodate integers
     -- up to 160 bits.
    genTime                      GeneralizedTime,
    accuracy                     Accuracy                 OPTIONAL,
    ordering                     BOOLEAN             DEFAULT FALSE,
    nonce                        INTEGER                  OPTIONAL,
      -- MUST be present if the similar field was present
      -- in TimeStampReq.  In that case it MUST have the same value.
    tsa                          [0] GeneralName          OPTIONAL,
    extensions                   [1] IMPLICIT Extensions  OPTIONAL   }
*/

typedef struct TS_tst_info_st {
	ASN1_INTEGER *version;
	ASN1_OBJECT *policy_id;
	TS_MSG_IMPRINT *msg_imprint;
	ASN1_INTEGER *serial;
	ASN1_GENERALIZEDTIME *time;
	TS_ACCURACY *accuracy;
	ASN1_BOOLEAN ordering;
	ASN1_INTEGER *nonce;
	GENERAL_NAME *tsa;
	STACK_OF(X509_EXTENSION) *extensions;
} TS_TST_INFO;

/*
PKIStatusInfo ::= SEQUENCE {
    status        PKIStatus,
    statusString  PKIFreeText     OPTIONAL,
    failInfo      PKIFailureInfo  OPTIONAL  }

From RFC 1510 - section 3.1.1:
PKIFreeText ::= SEQUENCE SIZE (1..MAX) OF UTF8String
	-- text encoded as UTF-8 String (note:  each UTF8String SHOULD
	-- include an RFC 1766 language tag to indicate the language
	-- of the contained text)
*/

/* Possible values for status. See ts_resp_print.c && ts_resp_verify.c. */

#define	TS_STATUS_GRANTED			0
#define	TS_STATUS_GRANTED_WITH_MODS		1
#define	TS_STATUS_REJECTION			2
#define	TS_STATUS_WAITING			3
#define	TS_STATUS_REVOCATION_WARNING		4
#define	TS_STATUS_REVOCATION_NOTIFICATION	5

/* Possible values for failure_info. See ts_resp_print.c && ts_resp_verify.c */

#define	TS_INFO_BAD_ALG			0
#define	TS_INFO_BAD_REQUEST		2
#define	TS_INFO_BAD_DATA_FORMAT		5
#define	TS_INFO_TIME_NOT_AVAILABLE	14
#define	TS_INFO_UNACCEPTED_POLICY	15
#define	TS_INFO_UNACCEPTED_EXTENSION	16
#define	TS_INFO_ADD_INFO_NOT_AVAILABLE	17
#define	TS_INFO_SYSTEM_FAILURE		25

typedef struct TS_status_info_st {
	ASN1_INTEGER *status;
	STACK_OF(ASN1_UTF8STRING) *text;
	ASN1_BIT_STRING *failure_info;
} TS_STATUS_INFO;

DECLARE_STACK_OF(ASN1_UTF8STRING)
DECLARE_ASN1_SET_OF(ASN1_UTF8STRING)

/*
TimeStampResp ::= SEQUENCE  {
     status                  PKIStatusInfo,
     timeStampToken          TimeStampToken     OPTIONAL }
*/

typedef struct TS_resp_st {
	TS_STATUS_INFO *status_info;
	PKCS7 *token;
	TS_TST_INFO *tst_info;
} TS_RESP;

/* The structure below would belong to the ESS component. */

/*
IssuerSerial ::= SEQUENCE {
	issuer                   GeneralNames,
	serialNumber             CertificateSerialNumber
	}
*/

typedef struct ESS_issuer_serial {
	STACK_OF(GENERAL_NAME)	*issuer;
	ASN1_INTEGER		*serial;
} ESS_ISSUER_SERIAL;

/*
ESSCertID ::=  SEQUENCE {
        certHash                 Hash,
        issuerSerial             IssuerSerial OPTIONAL
}
*/

typedef struct ESS_cert_id {
	ASN1_OCTET_STRING *hash;	/* Always SHA-1 digest. */
	ESS_ISSUER_SERIAL *issuer_serial;
} ESS_CERT_ID;

DECLARE_STACK_OF(ESS_CERT_ID)
DECLARE_ASN1_SET_OF(ESS_CERT_ID)

/*
SigningCertificate ::=  SEQUENCE {
       certs        SEQUENCE OF ESSCertID,
       policies     SEQUENCE OF PolicyInformation OPTIONAL
}
*/

typedef struct ESS_signing_cert {
	STACK_OF(ESS_CERT_ID) *cert_ids;
	STACK_OF(POLICYINFO) *policy_info;
} ESS_SIGNING_CERT;


TS_REQ	*TS_REQ_new(void);
void	TS_REQ_free(TS_REQ *a);
int	i2d_TS_REQ(const TS_REQ *a, unsigned char **pp);
TS_REQ	*d2i_TS_REQ(TS_REQ **a, const unsigned char **pp, long length);

TS_REQ	*TS_REQ_dup(TS_REQ *a);

TS_REQ	*d2i_TS_REQ_fp(FILE *fp, TS_REQ **a);
int	i2d_TS_REQ_fp(FILE *fp, TS_REQ *a);
TS_REQ	*d2i_TS_REQ_bio(BIO *fp, TS_REQ **a);
int	i2d_TS_REQ_bio(BIO *fp, TS_REQ *a);

TS_MSG_IMPRINT	*TS_MSG_IMPRINT_new(void);
void		TS_MSG_IMPRINT_free(TS_MSG_IMPRINT *a);
int		i2d_TS_MSG_IMPRINT(const TS_MSG_IMPRINT *a, unsigned char **pp);
TS_MSG_IMPRINT	*d2i_TS_MSG_IMPRINT(TS_MSG_IMPRINT **a,
		    const unsigned char **pp, long length);

TS_MSG_IMPRINT	*TS_MSG_IMPRINT_dup(TS_MSG_IMPRINT *a);

TS_MSG_IMPRINT	*d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a);
int		i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a);
TS_MSG_IMPRINT	*d2i_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT **a);
int		i2d_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT *a);

TS_RESP	*TS_RESP_new(void);
void	TS_RESP_free(TS_RESP *a);
int	i2d_TS_RESP(const TS_RESP *a, unsigned char **pp);
TS_RESP	*d2i_TS_RESP(TS_RESP **a, const unsigned char **pp, long length);
TS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token);
TS_RESP	*TS_RESP_dup(TS_RESP *a);

TS_RESP	*d2i_TS_RESP_fp(FILE *fp, TS_RESP **a);
int	i2d_TS_RESP_fp(FILE *fp, TS_RESP *a);
TS_RESP	*d2i_TS_RESP_bio(BIO *fp, TS_RESP **a);
int	i2d_TS_RESP_bio(BIO *fp, TS_RESP *a);

TS_STATUS_INFO	*TS_STATUS_INFO_new(void);
void		TS_STATUS_INFO_free(TS_STATUS_INFO *a);
int		i2d_TS_STATUS_INFO(const TS_STATUS_INFO *a, unsigned char **pp);
TS_STATUS_INFO	*d2i_TS_STATUS_INFO(TS_STATUS_INFO **a,
		    const unsigned char **pp, long length);
TS_STATUS_INFO	*TS_STATUS_INFO_dup(TS_STATUS_INFO *a);

TS_TST_INFO	*TS_TST_INFO_new(void);
void		TS_TST_INFO_free(TS_TST_INFO *a);
int		i2d_TS_TST_INFO(const TS_TST_INFO *a, unsigned char **pp);
TS_TST_INFO	*d2i_TS_TST_INFO(TS_TST_INFO **a, const unsigned char **pp,
		    long length);
TS_TST_INFO	*TS_TST_INFO_dup(TS_TST_INFO *a);

TS_TST_INFO	*d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a);
int		i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a);
TS_TST_INFO	*d2i_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO **a);
int		i2d_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO *a);

TS_ACCURACY	*TS_ACCURACY_new(void);
void		TS_ACCURACY_free(TS_ACCURACY *a);
int		i2d_TS_ACCURACY(const TS_ACCURACY *a, unsigned char **pp);
TS_ACCURACY	*d2i_TS_ACCURACY(TS_ACCURACY **a, const unsigned char **pp,
		    long length);
TS_ACCURACY	*TS_ACCURACY_dup(TS_ACCURACY *a);

ESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_new(void);
void		  ESS_ISSUER_SERIAL_free(ESS_ISSUER_SERIAL *a);
int		  i2d_ESS_ISSUER_SERIAL(const ESS_ISSUER_SERIAL *a,
		    unsigned char **pp);
ESS_ISSUER_SERIAL *d2i_ESS_ISSUER_SERIAL(ESS_ISSUER_SERIAL **a,
		    const unsigned char **pp, long length);
ESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_dup(ESS_ISSUER_SERIAL *a);

ESS_CERT_ID	*ESS_CERT_ID_new(void);
void		ESS_CERT_ID_free(ESS_CERT_ID *a);
int		i2d_ESS_CERT_ID(const ESS_CERT_ID *a, unsigned char **pp);
ESS_CERT_ID	*d2i_ESS_CERT_ID(ESS_CERT_ID **a, const unsigned char **pp,
		    long length);
ESS_CERT_ID	*ESS_CERT_ID_dup(ESS_CERT_ID *a);

ESS_SIGNING_CERT *ESS_SIGNING_CERT_new(void);
void		 ESS_SIGNING_CERT_free(ESS_SIGNING_CERT *a);
int		 i2d_ESS_SIGNING_CERT(const ESS_SIGNING_CERT *a,
		    unsigned char **pp);
ESS_SIGNING_CERT *d2i_ESS_SIGNING_CERT(ESS_SIGNING_CERT **a,
		    const unsigned char **pp, long length);
ESS_SIGNING_CERT *ESS_SIGNING_CERT_dup(ESS_SIGNING_CERT *a);

void ERR_load_TS_strings(void);

int TS_REQ_set_version(TS_REQ *a, long version);
long TS_REQ_get_version(const TS_REQ *a);

int TS_REQ_set_msg_imprint(TS_REQ *a, TS_MSG_IMPRINT *msg_imprint);
TS_MSG_IMPRINT *TS_REQ_get_msg_imprint(TS_REQ *a);

int TS_MSG_IMPRINT_set_algo(TS_MSG_IMPRINT *a, X509_ALGOR *alg);
X509_ALGOR *TS_MSG_IMPRINT_get_algo(TS_MSG_IMPRINT *a);

int TS_MSG_IMPRINT_set_msg(TS_MSG_IMPRINT *a, unsigned char *d, int len);
ASN1_OCTET_STRING *TS_MSG_IMPRINT_get_msg(TS_MSG_IMPRINT *a);

int TS_REQ_set_policy_id(TS_REQ *a, ASN1_OBJECT *policy);
ASN1_OBJECT *TS_REQ_get_policy_id(TS_REQ *a);

int TS_REQ_set_nonce(TS_REQ *a, const ASN1_INTEGER *nonce);
const ASN1_INTEGER *TS_REQ_get_nonce(const TS_REQ *a);

int TS_REQ_set_cert_req(TS_REQ *a, int cert_req);
int TS_REQ_get_cert_req(const TS_REQ *a);

STACK_OF(X509_EXTENSION) *TS_REQ_get_exts(TS_REQ *a);
void TS_REQ_ext_free(TS_REQ *a);
int TS_REQ_get_ext_count(TS_REQ *a);
int TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos);
int TS_REQ_get_ext_by_OBJ(TS_REQ *a, ASN1_OBJECT *obj, int lastpos);
int TS_REQ_get_ext_by_critical(TS_REQ *a, int crit, int lastpos);
X509_EXTENSION *TS_REQ_get_ext(TS_REQ *a, int loc);
X509_EXTENSION *TS_REQ_delete_ext(TS_REQ *a, int loc);
int TS_REQ_add_ext(TS_REQ *a, X509_EXTENSION *ex, int loc);
void *TS_REQ_get_ext_d2i(TS_REQ *a, int nid, int *crit, int *idx);

/* Function declarations for TS_REQ defined in ts/ts_req_print.c */

int TS_REQ_print_bio(BIO *bio, TS_REQ *a);

/* Function declarations for TS_RESP defined in ts/ts_resp_utils.c */

int TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *info);
TS_STATUS_INFO *TS_RESP_get_status_info(TS_RESP *a);

/* Caller loses ownership of PKCS7 and TS_TST_INFO objects. */
void TS_RESP_set_tst_info(TS_RESP *a, PKCS7 *p7, TS_TST_INFO *tst_info);
PKCS7 *TS_RESP_get_token(TS_RESP *a);
TS_TST_INFO *TS_RESP_get_tst_info(TS_RESP *a);

int TS_TST_INFO_set_version(TS_TST_INFO *a, long version);
long TS_TST_INFO_get_version(const TS_TST_INFO *a);

int TS_TST_INFO_set_policy_id(TS_TST_INFO *a, ASN1_OBJECT *policy_id);
ASN1_OBJECT *TS_TST_INFO_get_policy_id(TS_TST_INFO *a);

int TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint);
TS_MSG_IMPRINT *TS_TST_INFO_get_msg_imprint(TS_TST_INFO *a);

int TS_TST_INFO_set_serial(TS_TST_INFO *a, const ASN1_INTEGER *serial);
const ASN1_INTEGER *TS_TST_INFO_get_serial(const TS_TST_INFO *a);

int TS_TST_INFO_set_time(TS_TST_INFO *a, const ASN1_GENERALIZEDTIME *gtime);
const ASN1_GENERALIZEDTIME *TS_TST_INFO_get_time(const TS_TST_INFO *a);

int TS_TST_INFO_set_accuracy(TS_TST_INFO *a, TS_ACCURACY *accuracy);
TS_ACCURACY *TS_TST_INFO_get_accuracy(TS_TST_INFO *a);

int TS_ACCURACY_set_seconds(TS_ACCURACY *a, const ASN1_INTEGER *seconds);
const ASN1_INTEGER *TS_ACCURACY_get_seconds(const TS_ACCURACY *a);

int TS_ACCURACY_set_millis(TS_ACCURACY *a, const ASN1_INTEGER *millis);
const ASN1_INTEGER *TS_ACCURACY_get_millis(const TS_ACCURACY *a);

int TS_ACCURACY_set_micros(TS_ACCURACY *a, const ASN1_INTEGER *micros);
const ASN1_INTEGER *TS_ACCURACY_get_micros(const TS_ACCURACY *a);

int TS_TST_INFO_set_ordering(TS_TST_INFO *a, int ordering);
int TS_TST_INFO_get_ordering(const TS_TST_INFO *a);

int TS_TST_INFO_set_nonce(TS_TST_INFO *a, const ASN1_INTEGER *nonce);
const ASN1_INTEGER *TS_TST_INFO_get_nonce(const TS_TST_INFO *a);

int TS_TST_INFO_set_tsa(TS_TST_INFO *a, GENERAL_NAME *tsa);
GENERAL_NAME *TS_TST_INFO_get_tsa(TS_TST_INFO *a);

STACK_OF(X509_EXTENSION) *TS_TST_INFO_get_exts(TS_TST_INFO *a);
void TS_TST_INFO_ext_free(TS_TST_INFO *a);
int TS_TST_INFO_get_ext_count(TS_TST_INFO *a);
int TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos);
int TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, ASN1_OBJECT *obj, int lastpos);
int TS_TST_INFO_get_ext_by_critical(TS_TST_INFO *a, int crit, int lastpos);
X509_EXTENSION *TS_TST_INFO_get_ext(TS_TST_INFO *a, int loc);
X509_EXTENSION *TS_TST_INFO_delete_ext(TS_TST_INFO *a, int loc);
int TS_TST_INFO_add_ext(TS_TST_INFO *a, X509_EXTENSION *ex, int loc);
void *TS_TST_INFO_get_ext_d2i(TS_TST_INFO *a, int nid, int *crit, int *idx);

/* Declarations related to response generation, defined in ts/ts_resp_sign.c. */

/* Optional flags for response generation. */

/* Don't include the TSA name in response. */
#define	TS_TSA_NAME		0x01

/* Set ordering to true in response. */
#define	TS_ORDERING		0x02

/*
 * Include the signer certificate and the other specified certificates in
 * the ESS signing certificate attribute beside the PKCS7 signed data.
 * Only the signer certificates is included by default.
 */
#define	TS_ESS_CERT_ID_CHAIN	0x04

/* Forward declaration. */
struct TS_resp_ctx;

/* This must return a unique number less than 160 bits long. */
typedef ASN1_INTEGER *(*TS_serial_cb)(struct TS_resp_ctx *, void *);

/* This must return the seconds and microseconds since Jan 1, 1970 in
   the sec and usec variables allocated by the caller.
   Return non-zero for success and zero for failure. */
typedef	int (*TS_time_cb)(struct TS_resp_ctx *, void *, time_t *sec, long *usec);

/* This must process the given extension.
 * It can modify the TS_TST_INFO object of the context.
 * Return values: !0 (processed), 0 (error, it must set the
 * status info/failure info of the response).
 */
typedef	int (*TS_extension_cb)(struct TS_resp_ctx *, X509_EXTENSION *, void *);

typedef struct TS_resp_ctx {
	X509		*signer_cert;
	EVP_PKEY	*signer_key;
	STACK_OF(X509)	*certs;	/* Certs to include in signed data. */
	STACK_OF(ASN1_OBJECT)	*policies;	/* Acceptable policies. */
	ASN1_OBJECT	*default_policy; /* It may appear in policies, too. */
	STACK_OF(EVP_MD)	*mds;	/* Acceptable message digests. */
	ASN1_INTEGER	*seconds;	/* accuracy, 0 means not specified. */
	ASN1_INTEGER	*millis;	/* accuracy, 0 means not specified. */
	ASN1_INTEGER	*micros;	/* accuracy, 0 means not specified. */
	unsigned	clock_precision_digits; /* fraction of seconds in
						   time stamp token. */
	unsigned	flags;		/* Optional info, see values above. */

	/* Callback functions. */
	TS_serial_cb serial_cb;
	void *serial_cb_data;	/* User data for serial_cb. */

	TS_time_cb time_cb;
	void *time_cb_data;	/* User data for time_cb. */

	TS_extension_cb extension_cb;
	void *extension_cb_data;	/* User data for extension_cb. */

	/* These members are used only while creating the response. */
	TS_REQ		*request;
	TS_RESP		*response;
	TS_TST_INFO	*tst_info;
} TS_RESP_CTX;

DECLARE_STACK_OF(EVP_MD)
DECLARE_ASN1_SET_OF(EVP_MD)

/* Creates a response context that can be used for generating responses. */
TS_RESP_CTX *TS_RESP_CTX_new(void);
void TS_RESP_CTX_free(TS_RESP_CTX *ctx);

/* This parameter must be set. */
int TS_RESP_CTX_set_signer_cert(TS_RESP_CTX *ctx, X509 *signer);

/* This parameter must be set. */
int TS_RESP_CTX_set_signer_key(TS_RESP_CTX *ctx, EVP_PKEY *key);

/* This parameter must be set. */
int TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *def_policy);

/* No additional certs are included in the response by default. */
int TS_RESP_CTX_set_certs(TS_RESP_CTX *ctx, STACK_OF(X509) *certs);

/* Adds a new acceptable policy, only the default policy
   is accepted by default. */
int TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *policy);

/* Adds a new acceptable message digest. Note that no message digests
   are accepted by default. The md argument is shared with the caller. */
int TS_RESP_CTX_add_md(TS_RESP_CTX *ctx, const EVP_MD *md);

/* Accuracy is not included by default. */
int TS_RESP_CTX_set_accuracy(TS_RESP_CTX *ctx,
    int secs, int millis, int micros);

/* Clock precision digits, i.e. the number of decimal digits:
   '0' means sec, '3' msec, '6' usec, and so on. Default is 0. */
int TS_RESP_CTX_set_clock_precision_digits(TS_RESP_CTX *ctx,
    unsigned clock_precision_digits);
/* At most we accept usec precision. */
#define TS_MAX_CLOCK_PRECISION_DIGITS	6

/* No flags are set by default. */
void TS_RESP_CTX_add_flags(TS_RESP_CTX *ctx, int flags);

/* Default callback always returns a constant. */
void TS_RESP_CTX_set_serial_cb(TS_RESP_CTX *ctx, TS_serial_cb cb, void *data);

/* Default callback rejects all extensions. The extension callback is called
 * when the TS_TST_INFO object is already set up and not signed yet. */
/* FIXME: extension handling is not tested yet. */
void TS_RESP_CTX_set_extension_cb(TS_RESP_CTX *ctx,
    TS_extension_cb cb, void *data);

/* The following methods can be used in the callbacks. */
int TS_RESP_CTX_set_status_info(TS_RESP_CTX *ctx,
    int status, const char *text);

/* Sets the status info only if it is still TS_STATUS_GRANTED. */
int TS_RESP_CTX_set_status_info_cond(TS_RESP_CTX *ctx,
    int status, const char *text);

int TS_RESP_CTX_add_failure_info(TS_RESP_CTX *ctx, int failure);

/* The get methods below can be used in the extension callback. */
TS_REQ *TS_RESP_CTX_get_request(TS_RESP_CTX *ctx);

TS_TST_INFO *TS_RESP_CTX_get_tst_info(TS_RESP_CTX *ctx);

/*
 * Creates the signed TS_TST_INFO and puts it in TS_RESP.
 * In case of errors it sets the status info properly.
 * Returns NULL only in case of memory allocation/fatal error.
 */
TS_RESP *TS_RESP_create_response(TS_RESP_CTX *ctx, BIO *req_bio);

/*
 * Declarations related to response verification,
 * they are defined in ts/ts_resp_verify.c.
 */

int TS_RESP_verify_signature(PKCS7 *token, STACK_OF(X509) *certs,
    X509_STORE *store, X509 **signer_out);

/* Context structure for the generic verify method. */

/* Verify the signer's certificate and the signature of the response. */
#define	TS_VFY_SIGNATURE	(1u << 0)
/* Verify the version number of the response. */
#define	TS_VFY_VERSION		(1u << 1)
/* Verify if the policy supplied by the user matches the policy of the TSA. */
#define	TS_VFY_POLICY		(1u << 2)
/* Verify the message imprint provided by the user. This flag should not be
   specified with TS_VFY_DATA. */
#define	TS_VFY_IMPRINT		(1u << 3)
/* Verify the message imprint computed by the verify method from the user
   provided data and the MD algorithm of the response. This flag should not be
   specified with TS_VFY_IMPRINT. */
#define	TS_VFY_DATA		(1u << 4)
/* Verify the nonce value. */
#define	TS_VFY_NONCE		(1u << 5)
/* Verify if the TSA name field matches the signer certificate. */
#define	TS_VFY_SIGNER		(1u << 6)
/* Verify if the TSA name field equals to the user provided name. */
#define	TS_VFY_TSA_NAME		(1u << 7)

/* You can use the following convenience constants. */
#define	TS_VFY_ALL_IMPRINT	(TS_VFY_SIGNATURE	\
				 | TS_VFY_VERSION	\
				 | TS_VFY_POLICY	\
				 | TS_VFY_IMPRINT	\
				 | TS_VFY_NONCE		\
				 | TS_VFY_SIGNER	\
				 | TS_VFY_TSA_NAME)
#define	TS_VFY_ALL_DATA		(TS_VFY_SIGNATURE	\
				 | TS_VFY_VERSION	\
				 | TS_VFY_POLICY	\
				 | TS_VFY_DATA		\
				 | TS_VFY_NONCE		\
				 | TS_VFY_SIGNER	\
				 | TS_VFY_TSA_NAME)

typedef struct TS_verify_ctx {
	/* Set this to the union of TS_VFY_... flags you want to carry out. */
	unsigned	flags;

	/* Must be set only with TS_VFY_SIGNATURE. certs is optional. */
	X509_STORE	*store;
	STACK_OF(X509)	*certs;

	/* Must be set only with TS_VFY_POLICY. */
	ASN1_OBJECT	*policy;

	/* Must be set only with TS_VFY_IMPRINT. If md_alg is NULL,
	   the algorithm from the response is used. */
	X509_ALGOR	*md_alg;
	unsigned char	*imprint;
	unsigned	imprint_len;

	/* Must be set only with TS_VFY_DATA. */
	BIO		*data;

	/* Must be set only with TS_VFY_TSA_NAME. */
	ASN1_INTEGER	*nonce;

	/* Must be set only with TS_VFY_TSA_NAME. */
	GENERAL_NAME	*tsa_name;
} TS_VERIFY_CTX;

int TS_RESP_verify_response(TS_VERIFY_CTX *ctx, TS_RESP *response);
int TS_RESP_verify_token(TS_VERIFY_CTX *ctx, PKCS7 *token);

/*
 * Declarations related to response verification context,
 * they are defined in ts/ts_verify_ctx.c.
 */

/* Set all fields to zero. */
TS_VERIFY_CTX *TS_VERIFY_CTX_new(void);
void TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx);
void TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx);
void TS_VERIFY_CTX_cleanup(TS_VERIFY_CTX *ctx);

/*
 * If ctx is NULL, it allocates and returns a new object, otherwise
 * it returns ctx. It initialises all the members as follows:
 * flags = TS_VFY_ALL_IMPRINT & ~(TS_VFY_TSA_NAME | TS_VFY_SIGNATURE)
 * certs = NULL
 * store = NULL
 * policy = policy from the request or NULL if absent (in this case
 *	TS_VFY_POLICY is cleared from flags as well)
 * md_alg = MD algorithm from request
 * imprint, imprint_len = imprint from request
 * data = NULL
 * nonce, nonce_len = nonce from the request or NULL if absent (in this case
 * 	TS_VFY_NONCE is cleared from flags as well)
 * tsa_name = NULL
 * Important: after calling this method TS_VFY_SIGNATURE should be added!
 */
TS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx);

/* Function declarations for TS_RESP defined in ts/ts_resp_print.c */

int TS_RESP_print_bio(BIO *bio, TS_RESP *a);
int TS_STATUS_INFO_print_bio(BIO *bio, TS_STATUS_INFO *a);
int TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a);

/* Common utility functions defined in ts/ts_lib.c */

int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num);
int TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj);
int TS_ext_print_bio(BIO *bio, const STACK_OF(X509_EXTENSION) *extensions);
int TS_X509_ALGOR_print_bio(BIO *bio, const X509_ALGOR *alg);
int TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *msg);

/* Function declarations for handling configuration options,
   defined in ts/ts_conf.c */

X509 *TS_CONF_load_cert(const char *file);
STACK_OF(X509) *TS_CONF_load_certs(const char *file);
EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass);
const char *TS_CONF_get_tsa_section(CONF *conf, const char *section);
int TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb,
    TS_RESP_CTX *ctx);
int TS_CONF_set_crypto_device(CONF *conf, const char *section,
    const char *device);
int TS_CONF_set_default_engine(const char *name);
int TS_CONF_set_signer_cert(CONF *conf, const char *section,
    const char *cert, TS_RESP_CTX *ctx);
int TS_CONF_set_certs(CONF *conf, const char *section, const char *certs,
    TS_RESP_CTX *ctx);
int TS_CONF_set_signer_key(CONF *conf, const char *section,
    const char *key, const char *pass, TS_RESP_CTX *ctx);
int TS_CONF_set_def_policy(CONF *conf, const char *section,
    const char *policy, TS_RESP_CTX *ctx);
int TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx);
int TS_CONF_set_digests(CONF *conf, const char *section, TS_RESP_CTX *ctx);
int TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx);
int TS_CONF_set_clock_precision_digits(CONF *conf, const char *section,
    TS_RESP_CTX *ctx);
int TS_CONF_set_ordering(CONF *conf, const char *section, TS_RESP_CTX *ctx);
int TS_CONF_set_tsa_name(CONF *conf, const char *section, TS_RESP_CTX *ctx);
int TS_CONF_set_ess_cert_id_chain(CONF *conf, const char *section,
    TS_RESP_CTX *ctx);

/* -------------------------------------------------- */
/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_TS_strings(void);

/* Error codes for the TS functions. */

/* Function codes. */
#define TS_F_D2I_TS_RESP				 147
#define TS_F_DEF_SERIAL_CB				 110
#define TS_F_DEF_TIME_CB				 111
#define TS_F_ESS_ADD_SIGNING_CERT			 112
#define TS_F_ESS_CERT_ID_NEW_INIT			 113
#define TS_F_ESS_SIGNING_CERT_NEW_INIT			 114
#define TS_F_INT_TS_RESP_VERIFY_TOKEN			 149
#define TS_F_PKCS7_TO_TS_TST_INFO			 148
#define TS_F_TS_ACCURACY_SET_MICROS			 115
#define TS_F_TS_ACCURACY_SET_MILLIS			 116
#define TS_F_TS_ACCURACY_SET_SECONDS			 117
#define TS_F_TS_CHECK_IMPRINTS				 100
#define TS_F_TS_CHECK_NONCES				 101
#define TS_F_TS_CHECK_POLICY				 102
#define TS_F_TS_CHECK_SIGNING_CERTS			 103
#define TS_F_TS_CHECK_STATUS_INFO			 104
#define TS_F_TS_COMPUTE_IMPRINT				 145
#define TS_F_TS_CONF_SET_DEFAULT_ENGINE			 146
#define TS_F_TS_GET_STATUS_TEXT				 105
#define TS_F_TS_MSG_IMPRINT_SET_ALGO			 118
#define TS_F_TS_REQ_SET_MSG_IMPRINT			 119
#define TS_F_TS_REQ_SET_NONCE				 120
#define TS_F_TS_REQ_SET_POLICY_ID			 121
#define TS_F_TS_RESP_CREATE_RESPONSE			 122
#define TS_F_TS_RESP_CREATE_TST_INFO			 123
#define TS_F_TS_RESP_CTX_ADD_FAILURE_INFO		 124
#define TS_F_TS_RESP_CTX_ADD_MD				 125
#define TS_F_TS_RESP_CTX_ADD_POLICY			 126
#define TS_F_TS_RESP_CTX_NEW				 127
#define TS_F_TS_RESP_CTX_SET_ACCURACY			 128
#define TS_F_TS_RESP_CTX_SET_CERTS			 129
#define TS_F_TS_RESP_CTX_SET_DEF_POLICY			 130
#define TS_F_TS_RESP_CTX_SET_SIGNER_CERT		 131
#define TS_F_TS_RESP_CTX_SET_STATUS_INFO		 132
#define TS_F_TS_RESP_GET_POLICY				 133
#define TS_F_TS_RESP_SET_GENTIME_WITH_PRECISION		 134
#define TS_F_TS_RESP_SET_STATUS_INFO			 135
#define TS_F_TS_RESP_SET_TST_INFO			 150
#define TS_F_TS_RESP_SIGN				 136
#define TS_F_TS_RESP_VERIFY_SIGNATURE			 106
#define TS_F_TS_RESP_VERIFY_TOKEN			 107
#define TS_F_TS_TST_INFO_SET_ACCURACY			 137
#define TS_F_TS_TST_INFO_SET_MSG_IMPRINT		 138
#define TS_F_TS_TST_INFO_SET_NONCE			 139
#define TS_F_TS_TST_INFO_SET_POLICY_ID			 140
#define TS_F_TS_TST_INFO_SET_SERIAL			 141
#define TS_F_TS_TST_INFO_SET_TIME			 142
#define TS_F_TS_TST_INFO_SET_TSA			 143
#define TS_F_TS_VERIFY					 108
#define TS_F_TS_VERIFY_CERT				 109
#define TS_F_TS_VERIFY_CTX_NEW				 144

/* Reason codes. */
#define TS_R_BAD_PKCS7_TYPE				 132
#define TS_R_BAD_TYPE					 133
#define TS_R_CERTIFICATE_VERIFY_ERROR			 100
#define TS_R_COULD_NOT_SET_ENGINE			 127
#define TS_R_COULD_NOT_SET_TIME				 115
#define TS_R_D2I_TS_RESP_INT_FAILED			 128
#define TS_R_DETACHED_CONTENT				 134
#define TS_R_ESS_ADD_SIGNING_CERT_ERROR			 116
#define TS_R_ESS_SIGNING_CERTIFICATE_ERROR		 101
#define TS_R_INVALID_NULL_POINTER			 102
#define TS_R_INVALID_SIGNER_CERTIFICATE_PURPOSE		 117
#define TS_R_MESSAGE_IMPRINT_MISMATCH			 103
#define TS_R_NONCE_MISMATCH				 104
#define TS_R_NONCE_NOT_RETURNED				 105
#define TS_R_NO_CONTENT					 106
#define TS_R_NO_TIME_STAMP_TOKEN			 107
#define TS_R_PKCS7_ADD_SIGNATURE_ERROR			 118
#define TS_R_PKCS7_ADD_SIGNED_ATTR_ERROR		 119
#define TS_R_PKCS7_TO_TS_TST_INFO_FAILED		 129
#define TS_R_POLICY_MISMATCH				 108
#define TS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE	 120
#define TS_R_RESPONSE_SETUP_ERROR			 121
#define TS_R_SIGNATURE_FAILURE				 109
#define TS_R_THERE_MUST_BE_ONE_SIGNER			 110
#define TS_R_TIME_SYSCALL_ERROR				 122
#define TS_R_TOKEN_NOT_PRESENT				 130
#define TS_R_TOKEN_PRESENT				 131
#define TS_R_TSA_NAME_MISMATCH				 111
#define TS_R_TSA_UNTRUSTED				 112
#define TS_R_TST_INFO_SETUP_ERROR			 123
#define TS_R_TS_DATASIGN				 124
#define TS_R_UNACCEPTABLE_POLICY			 125
#define TS_R_UNSUPPORTED_MD_ALGORITHM			 126
#define TS_R_UNSUPPORTED_VERSION			 113
#define TS_R_WRONG_CONTENT_TYPE				 114

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/chacha.h0000644000175000017500000000317112360020705021423 0ustar  /* $OpenBSD: chacha.h,v 1.4 2014/06/12 15:49:28 deraadt Exp $ */
/*
 * Copyright (c) Joel Sing 
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef HEADER_CHACHA_H
#define HEADER_CHACHA_H

#include 

#if defined(OPENSSL_NO_CHACHA)
#error ChaCha is disabled.
#endif

#include 

#ifdef  __cplusplus
extern "C" {
#endif

typedef struct {
	unsigned int input[16];
	unsigned char ks[64];
	unsigned char unused;
} ChaCha_ctx;

void ChaCha_set_key(ChaCha_ctx *ctx, const unsigned char *key,
    unsigned int keybits);
void ChaCha_set_iv(ChaCha_ctx *ctx, const unsigned char *iv,
    const unsigned char *counter);
void ChaCha(ChaCha_ctx *ctx, unsigned char *out, const unsigned char *in,
    size_t len);

void CRYPTO_chacha_20(unsigned char *out, const unsigned char *in, size_t len,
    const unsigned char key[32], const unsigned char iv[8], size_t counter);

#ifdef  __cplusplus
}
#endif

#endif /* HEADER_CHACHA_H */
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/aes.h0000644000175000017500000001170012360020705020761 0ustar  /* $OpenBSD: aes.h,v 1.13 2014/06/12 15:49:27 deraadt Exp $ */
/* ====================================================================
 * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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 HEADER_AES_H
#define HEADER_AES_H

#include 

#ifdef OPENSSL_NO_AES
#error AES is disabled.
#endif

#include 

#define AES_ENCRYPT	1
#define AES_DECRYPT	0

/* Because array size can't be a const in C, the following two are macros.
   Both sizes are in bytes. */
#define AES_MAXNR 14
#define AES_BLOCK_SIZE 16

#ifdef  __cplusplus
extern "C" {
#endif

/* This should be a hidden type, but EVP requires that the size be known */
struct aes_key_st {
	unsigned int rd_key[4 *(AES_MAXNR + 1)];
	int rounds;
};
typedef struct aes_key_st AES_KEY;

const char *AES_options(void);

int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
    AES_KEY *key);
int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
    AES_KEY *key);

void AES_encrypt(const unsigned char *in, unsigned char *out,
    const AES_KEY *key);
void AES_decrypt(const unsigned char *in, unsigned char *out,
    const AES_KEY *key);

void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
    const AES_KEY *key, const int enc);
void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
    size_t length, const AES_KEY *key, unsigned char *ivec, const int enc);
void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
    size_t length, const AES_KEY *key, unsigned char *ivec, int *num,
    const int enc);
void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
    size_t length, const AES_KEY *key, unsigned char *ivec, int *num,
    const int enc);
void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
    size_t length, const AES_KEY *key, unsigned char *ivec, int *num,
    const int enc);
void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
    size_t length, const AES_KEY *key, unsigned char *ivec, int *num);
void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
    size_t length, const AES_KEY *key, unsigned char ivec[AES_BLOCK_SIZE],
    unsigned char ecount_buf[AES_BLOCK_SIZE], unsigned int *num);
/* NB: the IV is _two_ blocks long */
void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
    size_t length, const AES_KEY *key, unsigned char *ivec, const int enc);

int AES_wrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out,
    const unsigned char *in, unsigned int inlen);
int AES_unwrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out,
    const unsigned char *in, unsigned int inlen);


#ifdef  __cplusplus
}
#endif

#endif /* !HEADER_AES_H */
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/ecdh.h0000644000175000017500000001110112360020705021107 0ustar  /* $OpenBSD$ */
/* ====================================================================
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 *
 * The Elliptic Curve Public-Key Crypto Library (ECC Code) included
 * herein is developed by SUN MICROSYSTEMS, INC., and is contributed
 * to the OpenSSL project.
 *
 * The ECC Code is licensed pursuant to the OpenSSL open source
 * license provided below.
 *
 * The ECDH software is originally written by Douglas Stebila of
 * Sun Microsystems Laboratories.
 *
 */
/* ====================================================================
 * Copyright (c) 2000-2002 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */
#ifndef HEADER_ECDH_H
#define HEADER_ECDH_H

#include 

#ifdef OPENSSL_NO_ECDH
#error ECDH is disabled.
#endif

#include 
#include 
#ifndef OPENSSL_NO_DEPRECATED
#include 
#endif

#ifdef __cplusplus
extern "C" {
#endif

const ECDH_METHOD *ECDH_OpenSSL(void);

void	  ECDH_set_default_method(const ECDH_METHOD *);
const ECDH_METHOD *ECDH_get_default_method(void);
int 	  ECDH_set_method(EC_KEY *, const ECDH_METHOD *);

int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh,
                     void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen));

int 	  ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new 
		*new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
int 	  ECDH_set_ex_data(EC_KEY *d, int idx, void *arg);
void 	  *ECDH_get_ex_data(EC_KEY *d, int idx);


/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_ECDH_strings(void);

/* Error codes for the ECDH functions. */

/* Function codes. */
#define ECDH_F_ECDH_CHECK				 102
#define ECDH_F_ECDH_COMPUTE_KEY				 100
#define ECDH_F_ECDH_DATA_NEW_METHOD			 101

/* Reason codes. */
#define ECDH_R_KDF_FAILED				 102
#define ECDH_R_NON_FIPS_METHOD				 103
#define ECDH_R_NO_PRIVATE_VALUE				 100
#define ECDH_R_POINT_ARITHMETIC_FAILURE			 101

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/dtls1.h0000644000175000017500000001664112360020705021251 0ustar  /* $OpenBSD: dtls1.h,v 1.13 2014/06/12 15:49:31 deraadt Exp $ */
/* 
 * DTLS implementation written by Nagendra Modadugu
 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.  
 */
/* ====================================================================
 * Copyright (c) 1999-2005 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#ifndef HEADER_DTLS1_H
#define HEADER_DTLS1_H

#include 
#include 
#include 
#include 
#include 

#ifdef  __cplusplus
extern "C" {
#endif

#define DTLS1_VERSION			0xFEFF
#define DTLS1_BAD_VER			0x0100

/* lengths of messages */
#define DTLS1_COOKIE_LENGTH                     256

#define DTLS1_RT_HEADER_LENGTH                  13

#define DTLS1_HM_HEADER_LENGTH                  12

#define DTLS1_HM_BAD_FRAGMENT                   -2
#define DTLS1_HM_FRAGMENT_RETRY                 -3

#define DTLS1_CCS_HEADER_LENGTH                  1

#ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE
#define DTLS1_AL_HEADER_LENGTH                   7
#else
#define DTLS1_AL_HEADER_LENGTH                   2
#endif

#ifndef OPENSSL_NO_SSL_INTERN

#ifndef OPENSSL_NO_SCTP
#define DTLS1_SCTP_AUTH_LABEL	"EXPORTER_DTLS_OVER_SCTP"
#endif

typedef struct dtls1_bitmap_st {
	unsigned long map;		/* track 32 packets on 32-bit systems
					   and 64 - on 64-bit systems */
	unsigned char max_seq_num[8];	/* max record number seen so far,
					   64-bit value in big-endian
					   encoding */
} DTLS1_BITMAP;

struct dtls1_retransmit_state {
	EVP_CIPHER_CTX *enc_write_ctx;	/* cryptographic state */
	EVP_MD_CTX *write_hash;		/* used for mac generation */
	SSL_SESSION *session;
	unsigned short epoch;
};

struct hm_header_st {
	unsigned char type;
	unsigned long msg_len;
	unsigned short seq;
	unsigned long frag_off;
	unsigned long frag_len;
	unsigned int is_ccs;
	struct dtls1_retransmit_state saved_retransmit_state;
};

struct ccs_header_st {
	unsigned char type;
	unsigned short seq;
};

struct dtls1_timeout_st {
	/* Number of read timeouts so far */
	unsigned int read_timeouts;

	/* Number of write timeouts so far */
	unsigned int write_timeouts;

	/* Number of alerts received so far */
	unsigned int num_alerts;
};

struct _pqueue;

typedef struct record_pqueue_st {
	unsigned short epoch;
	struct _pqueue *q;
} record_pqueue;

typedef struct hm_fragment_st {
	struct hm_header_st msg_header;
	unsigned char *fragment;
	unsigned char *reassembly;
} hm_fragment;

typedef struct dtls1_state_st {
	unsigned int send_cookie;
	unsigned char cookie[DTLS1_COOKIE_LENGTH];
	unsigned char rcvd_cookie[DTLS1_COOKIE_LENGTH];
	unsigned int cookie_len;

	/* 
	 * The current data and handshake epoch.  This is initially
	 * undefined, and starts at zero once the initial handshake is
	 * completed 
	 */
	unsigned short r_epoch;
	unsigned short w_epoch;

	/* records being received in the current epoch */
	DTLS1_BITMAP bitmap;

	/* renegotiation starts a new set of sequence numbers */
	DTLS1_BITMAP next_bitmap;

	/* handshake message numbers */
	unsigned short handshake_write_seq;
	unsigned short next_handshake_write_seq;

	unsigned short handshake_read_seq;

	/* save last sequence number for retransmissions */
	unsigned char last_write_sequence[8];

	/* Received handshake records (processed and unprocessed) */
	record_pqueue unprocessed_rcds;
	record_pqueue processed_rcds;

	/* Buffered handshake messages */
	struct _pqueue *buffered_messages;

	/* Buffered (sent) handshake records */
	struct _pqueue *sent_messages;

	/* Buffered application records.
	 * Only for records between CCS and Finished
	 * to prevent either protocol violation or
	 * unnecessary message loss.
	 */
	record_pqueue buffered_app_data;

	/* Is set when listening for new connections with dtls1_listen() */
	unsigned int listen;

	unsigned int mtu; /* max DTLS packet size */

	struct hm_header_st w_msg_hdr;
	struct hm_header_st r_msg_hdr;

	struct dtls1_timeout_st timeout;

	/* Indicates when the last handshake msg or heartbeat sent will timeout */
	struct timeval next_timeout;

	/* Timeout duration */
	unsigned short timeout_duration;

	/* storage for Alert/Handshake protocol data received but not
	 * yet processed by ssl3_read_bytes: */
	unsigned char alert_fragment[DTLS1_AL_HEADER_LENGTH];
	unsigned int alert_fragment_len;
	unsigned char handshake_fragment[DTLS1_HM_HEADER_LENGTH];
	unsigned int handshake_fragment_len;

	unsigned int retransmitting;
	unsigned int change_cipher_spec_ok;

#ifndef OPENSSL_NO_SCTP
	/* used when SSL_ST_XX_FLUSH is entered */
	int next_state;

	int shutdown_received;
#endif

} DTLS1_STATE;

typedef struct dtls1_record_data_st {
	unsigned char *packet;
	unsigned int   packet_length;
	SSL3_BUFFER    rbuf;
	SSL3_RECORD    rrec;
#ifndef OPENSSL_NO_SCTP
	struct bio_dgram_sctp_rcvinfo recordinfo;
#endif
} DTLS1_RECORD_DATA;

#endif

/* Timeout multipliers (timeout slice is defined in apps/timeouts.h */
#define DTLS1_TMO_READ_COUNT                      2
#define DTLS1_TMO_WRITE_COUNT                     2

#define DTLS1_TMO_ALERT_COUNT                     12

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/hmac.h0000644000175000017500000001061712360020705021127 0ustar  /* $OpenBSD: hmac.h,v 1.11 2014/06/12 15:49:29 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */
#ifndef HEADER_HMAC_H
#define HEADER_HMAC_H

#include 

#ifdef OPENSSL_NO_HMAC
#error HMAC is disabled.
#endif

#include 

#define HMAC_MAX_MD_CBLOCK	128	/* largest known is SHA512 */

#ifdef  __cplusplus
extern "C" {
#endif

typedef struct hmac_ctx_st {
	const EVP_MD *md;
	EVP_MD_CTX md_ctx;
	EVP_MD_CTX i_ctx;
	EVP_MD_CTX o_ctx;
	unsigned int key_length;
	unsigned char key[HMAC_MAX_MD_CBLOCK];
} HMAC_CTX;

#define HMAC_size(e)	(EVP_MD_size((e)->md))


void HMAC_CTX_init(HMAC_CTX *ctx);
void HMAC_CTX_cleanup(HMAC_CTX *ctx);

#define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx) /* deprecated */

int HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
    const EVP_MD *md); /* deprecated */
int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md,
    ENGINE *impl);
int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len);
int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
    const unsigned char *d, size_t n, unsigned char *md, unsigned int *md_len);
int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx);

void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags);

#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/rc4.h0000644000175000017500000000737612360020705020717 0ustar  /* $OpenBSD: rc4.h,v 1.11 2014/06/12 15:49:30 deraadt Exp $ */
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_RC4_H
#define HEADER_RC4_H

#include  /* OPENSSL_NO_RC4, RC4_INT */

#ifdef OPENSSL_NO_RC4
#error RC4 is disabled.
#endif

#include 

#ifdef  __cplusplus
extern "C" {
#endif

typedef struct rc4_key_st
	{
	RC4_INT x,y;
	RC4_INT data[256];
	} RC4_KEY;

 
const char *RC4_options(void);
void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
void private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
void RC4(RC4_KEY *key, size_t len, const unsigned char *indata,
		unsigned char *outdata);

#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/srtp.h0000644000175000017500000001476212360020705021214 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */
/* ====================================================================
 * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */
/*
 * DTLS code by Eric Rescorla 
 *
 * Copyright (C) 2006, Network Resonance, Inc.
 * Copyright (C) 2011, RTFM, Inc.
 */

#ifndef HEADER_D1_SRTP_H
#define HEADER_D1_SRTP_H

#ifdef  __cplusplus
extern "C" {
#endif

#define SRTP_AES128_CM_SHA1_80 0x0001
#define SRTP_AES128_CM_SHA1_32 0x0002
#define SRTP_AES128_F8_SHA1_80 0x0003
#define SRTP_AES128_F8_SHA1_32 0x0004
#define SRTP_NULL_SHA1_80      0x0005
#define SRTP_NULL_SHA1_32      0x0006

int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles);
int SSL_set_tlsext_use_srtp(SSL *ctx, const char *profiles);
SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s);

STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl);
SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s);

#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/stack.h0000644000175000017500000001045412360020705021323 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_STACK_H
#define HEADER_STACK_H

#ifdef  __cplusplus
extern "C" {
#endif

typedef struct stack_st {
	int num;
	char **data;
	int sorted;

	int num_alloc;
	int (*comp)(const void *, const void *);
} _STACK;  /* Use STACK_OF(...) instead */

#define M_sk_num(sk)		((sk) ? (sk)->num:-1)
#define M_sk_value(sk,n)	((sk) ? (sk)->data[n] : NULL)

int sk_num(const _STACK *);
void *sk_value(const _STACK *, int);

void *sk_set(_STACK *, int, void *);

_STACK *sk_new(int (*cmp)(const void *, const void *));
_STACK *sk_new_null(void);
void sk_free(_STACK *);
void sk_pop_free(_STACK *st, void (*func)(void *));
int sk_insert(_STACK *sk, void *data, int where);
void *sk_delete(_STACK *st, int loc);
void *sk_delete_ptr(_STACK *st, void *p);
int sk_find(_STACK *st, void *data);
int sk_find_ex(_STACK *st, void *data);
int sk_push(_STACK *st, void *data);
int sk_unshift(_STACK *st, void *data);
void *sk_shift(_STACK *st);
void *sk_pop(_STACK *st);
void sk_zero(_STACK *st);
int (*sk_set_cmp_func(_STACK *sk, int (*c)(const void *, const void *)))(
    const void *, const void *);
_STACK *sk_dup(_STACK *st);
void sk_sort(_STACK *st);
int sk_is_sorted(const _STACK *st);

#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/safestack.h0000644000175000017500000054755312360020705022201 0ustar  /* $OpenBSD$ */
/* ====================================================================
 * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#ifndef HEADER_SAFESTACK_H
#define HEADER_SAFESTACK_H

#include 

#ifndef CHECKED_PTR_OF
#define CHECKED_PTR_OF(type, p) \
    ((void*) (1 ? p : (type*)0))
#endif

/* In C++ we get problems because an explicit cast is needed from (void *)
 * we use CHECKED_STACK_OF to ensure the correct type is passed in the macros
 * below. 
 */

#define CHECKED_STACK_OF(type, p) \
    ((_STACK*) (1 ? p : (STACK_OF(type)*)0))

#define CHECKED_SK_FREE_FUNC(type, p) \
    ((void (*)(void *)) ((1 ? p : (void (*)(type *))0)))

#define CHECKED_SK_FREE_FUNC2(type, p) \
    ((void (*)(void *)) ((1 ? p : (void (*)(type))0)))

#define CHECKED_SK_CMP_FUNC(type, p) \
    ((int (*)(const void *, const void *)) \
	((1 ? p : (int (*)(const type * const *, const type * const *))0)))

#define STACK_OF(type) struct stack_st_##type
#define PREDECLARE_STACK_OF(type) STACK_OF(type);

#define DECLARE_STACK_OF(type) \
STACK_OF(type) \
    { \
    _STACK stack; \
    };
#define DECLARE_SPECIAL_STACK_OF(type, type2) \
STACK_OF(type) \
    { \
    _STACK stack; \
    };

#define IMPLEMENT_STACK_OF(type) /* nada (obsolete in new safestack approach)*/


/* Strings are special: normally an lhash entry will point to a single
 * (somewhat) mutable object. In the case of strings:
 *
 * a) Instead of a single char, there is an array of chars, NUL-terminated.
 * b) The string may have be immutable.
 *
 * So, they need their own declarations. Especially important for
 * type-checking tools, such as Deputy.
 *
o * In practice, however, it appears to be hard to have a const
 * string. For now, I'm settling for dealing with the fact it is a
 * string at all.
 */
typedef char *OPENSSL_STRING;

typedef const char *OPENSSL_CSTRING;

/* Confusingly, LHASH_OF(STRING) deals with char ** throughout, but
 * STACK_OF(STRING) is really more like STACK_OF(char), only, as
 * mentioned above, instead of a single char each entry is a
 * NUL-terminated array of chars. So, we have to implement STRING
 * specially for STACK_OF. This is dealt with in the autogenerated
 * macros below.
 */

DECLARE_SPECIAL_STACK_OF(OPENSSL_STRING, char)

/* Similarly, we sometimes use a block of characters, NOT
 * nul-terminated. These should also be distinguished from "normal"
 * stacks. */

typedef void *OPENSSL_BLOCK;
DECLARE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void)

/* SKM_sk_... stack macros are internal to safestack.h:
 * never use them directly, use sk__... instead */
#define SKM_sk_new(type, cmp) \
	((STACK_OF(type) *)sk_new(CHECKED_SK_CMP_FUNC(type, cmp)))
#define SKM_sk_new_null(type) \
	((STACK_OF(type) *)sk_new_null())
#define SKM_sk_free(type, st) \
	sk_free(CHECKED_STACK_OF(type, st))
#define SKM_sk_num(type, st) \
	sk_num(CHECKED_STACK_OF(type, st))
#define SKM_sk_value(type, st,i) \
	((type *)sk_value(CHECKED_STACK_OF(type, st), i))
#define SKM_sk_set(type, st,i,val) \
	sk_set(CHECKED_STACK_OF(type, st), i, CHECKED_PTR_OF(type, val))
#define SKM_sk_zero(type, st) \
	sk_zero(CHECKED_STACK_OF(type, st))
#define SKM_sk_push(type, st, val) \
	sk_push(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))
#define SKM_sk_unshift(type, st, val) \
	sk_unshift(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))
#define SKM_sk_find(type, st, val) \
	sk_find(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))
#define SKM_sk_find_ex(type, st, val) \
	sk_find_ex(CHECKED_STACK_OF(type, st), \
		   CHECKED_PTR_OF(type, val))
#define SKM_sk_delete(type, st, i) \
	(type *)sk_delete(CHECKED_STACK_OF(type, st), i)
#define SKM_sk_delete_ptr(type, st, ptr) \
	(type *)sk_delete_ptr(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, ptr))
#define SKM_sk_insert(type, st,val, i) \
	sk_insert(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val), i)
#define SKM_sk_set_cmp_func(type, st, cmp) \
	((int (*)(const type * const *,const type * const *)) \
	sk_set_cmp_func(CHECKED_STACK_OF(type, st), CHECKED_SK_CMP_FUNC(type, cmp)))
#define SKM_sk_dup(type, st) \
	(STACK_OF(type) *)sk_dup(CHECKED_STACK_OF(type, st))
#define SKM_sk_pop_free(type, st, free_func) \
	sk_pop_free(CHECKED_STACK_OF(type, st), CHECKED_SK_FREE_FUNC(type, free_func))
#define SKM_sk_shift(type, st) \
	(type *)sk_shift(CHECKED_STACK_OF(type, st))
#define SKM_sk_pop(type, st) \
	(type *)sk_pop(CHECKED_STACK_OF(type, st))
#define SKM_sk_sort(type, st) \
	sk_sort(CHECKED_STACK_OF(type, st))
#define SKM_sk_is_sorted(type, st) \
	sk_is_sorted(CHECKED_STACK_OF(type, st))

#define	SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
  (STACK_OF(type) *)d2i_ASN1_SET( \
				(STACK_OF(OPENSSL_BLOCK) **)CHECKED_PTR_OF(STACK_OF(type)*, st), \
				pp, length, \
				CHECKED_D2I_OF(type, d2i_func), \
				CHECKED_SK_FREE_FUNC(type, free_func), \
				ex_tag, ex_class)

#define	SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \
  i2d_ASN1_SET((STACK_OF(OPENSSL_BLOCK) *)CHECKED_STACK_OF(type, st), pp, \
				CHECKED_I2D_OF(type, i2d_func), \
				ex_tag, ex_class, is_set)

#define	SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \
	ASN1_seq_pack(CHECKED_PTR_OF(STACK_OF(type), st), \
			CHECKED_I2D_OF(type, i2d_func), buf, len)

#define	SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \
	(STACK_OF(type) *)ASN1_seq_unpack(buf, len, CHECKED_D2I_OF(type, d2i_func), CHECKED_SK_FREE_FUNC(type, free_func))

#define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \
	(STACK_OF(type) *)PKCS12_decrypt_d2i(algor, \
				CHECKED_D2I_OF(type, d2i_func), \
				CHECKED_SK_FREE_FUNC(type, free_func), \
				pass, passlen, oct, seq)

/* This block of defines is updated by util/mkstack.pl, please do not touch! */
#define sk_ACCESS_DESCRIPTION_new(cmp) SKM_sk_new(ACCESS_DESCRIPTION, (cmp))
#define sk_ACCESS_DESCRIPTION_new_null() SKM_sk_new_null(ACCESS_DESCRIPTION)
#define sk_ACCESS_DESCRIPTION_free(st) SKM_sk_free(ACCESS_DESCRIPTION, (st))
#define sk_ACCESS_DESCRIPTION_num(st) SKM_sk_num(ACCESS_DESCRIPTION, (st))
#define sk_ACCESS_DESCRIPTION_value(st, i) SKM_sk_value(ACCESS_DESCRIPTION, (st), (i))
#define sk_ACCESS_DESCRIPTION_set(st, i, val) SKM_sk_set(ACCESS_DESCRIPTION, (st), (i), (val))
#define sk_ACCESS_DESCRIPTION_zero(st) SKM_sk_zero(ACCESS_DESCRIPTION, (st))
#define sk_ACCESS_DESCRIPTION_push(st, val) SKM_sk_push(ACCESS_DESCRIPTION, (st), (val))
#define sk_ACCESS_DESCRIPTION_unshift(st, val) SKM_sk_unshift(ACCESS_DESCRIPTION, (st), (val))
#define sk_ACCESS_DESCRIPTION_find(st, val) SKM_sk_find(ACCESS_DESCRIPTION, (st), (val))
#define sk_ACCESS_DESCRIPTION_find_ex(st, val) SKM_sk_find_ex(ACCESS_DESCRIPTION, (st), (val))
#define sk_ACCESS_DESCRIPTION_delete(st, i) SKM_sk_delete(ACCESS_DESCRIPTION, (st), (i))
#define sk_ACCESS_DESCRIPTION_delete_ptr(st, ptr) SKM_sk_delete_ptr(ACCESS_DESCRIPTION, (st), (ptr))
#define sk_ACCESS_DESCRIPTION_insert(st, val, i) SKM_sk_insert(ACCESS_DESCRIPTION, (st), (val), (i))
#define sk_ACCESS_DESCRIPTION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ACCESS_DESCRIPTION, (st), (cmp))
#define sk_ACCESS_DESCRIPTION_dup(st) SKM_sk_dup(ACCESS_DESCRIPTION, st)
#define sk_ACCESS_DESCRIPTION_pop_free(st, free_func) SKM_sk_pop_free(ACCESS_DESCRIPTION, (st), (free_func))
#define sk_ACCESS_DESCRIPTION_shift(st) SKM_sk_shift(ACCESS_DESCRIPTION, (st))
#define sk_ACCESS_DESCRIPTION_pop(st) SKM_sk_pop(ACCESS_DESCRIPTION, (st))
#define sk_ACCESS_DESCRIPTION_sort(st) SKM_sk_sort(ACCESS_DESCRIPTION, (st))
#define sk_ACCESS_DESCRIPTION_is_sorted(st) SKM_sk_is_sorted(ACCESS_DESCRIPTION, (st))

#define sk_ASIdOrRange_new(cmp) SKM_sk_new(ASIdOrRange, (cmp))
#define sk_ASIdOrRange_new_null() SKM_sk_new_null(ASIdOrRange)
#define sk_ASIdOrRange_free(st) SKM_sk_free(ASIdOrRange, (st))
#define sk_ASIdOrRange_num(st) SKM_sk_num(ASIdOrRange, (st))
#define sk_ASIdOrRange_value(st, i) SKM_sk_value(ASIdOrRange, (st), (i))
#define sk_ASIdOrRange_set(st, i, val) SKM_sk_set(ASIdOrRange, (st), (i), (val))
#define sk_ASIdOrRange_zero(st) SKM_sk_zero(ASIdOrRange, (st))
#define sk_ASIdOrRange_push(st, val) SKM_sk_push(ASIdOrRange, (st), (val))
#define sk_ASIdOrRange_unshift(st, val) SKM_sk_unshift(ASIdOrRange, (st), (val))
#define sk_ASIdOrRange_find(st, val) SKM_sk_find(ASIdOrRange, (st), (val))
#define sk_ASIdOrRange_find_ex(st, val) SKM_sk_find_ex(ASIdOrRange, (st), (val))
#define sk_ASIdOrRange_delete(st, i) SKM_sk_delete(ASIdOrRange, (st), (i))
#define sk_ASIdOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASIdOrRange, (st), (ptr))
#define sk_ASIdOrRange_insert(st, val, i) SKM_sk_insert(ASIdOrRange, (st), (val), (i))
#define sk_ASIdOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASIdOrRange, (st), (cmp))
#define sk_ASIdOrRange_dup(st) SKM_sk_dup(ASIdOrRange, st)
#define sk_ASIdOrRange_pop_free(st, free_func) SKM_sk_pop_free(ASIdOrRange, (st), (free_func))
#define sk_ASIdOrRange_shift(st) SKM_sk_shift(ASIdOrRange, (st))
#define sk_ASIdOrRange_pop(st) SKM_sk_pop(ASIdOrRange, (st))
#define sk_ASIdOrRange_sort(st) SKM_sk_sort(ASIdOrRange, (st))
#define sk_ASIdOrRange_is_sorted(st) SKM_sk_is_sorted(ASIdOrRange, (st))

#define sk_ASN1_GENERALSTRING_new(cmp) SKM_sk_new(ASN1_GENERALSTRING, (cmp))
#define sk_ASN1_GENERALSTRING_new_null() SKM_sk_new_null(ASN1_GENERALSTRING)
#define sk_ASN1_GENERALSTRING_free(st) SKM_sk_free(ASN1_GENERALSTRING, (st))
#define sk_ASN1_GENERALSTRING_num(st) SKM_sk_num(ASN1_GENERALSTRING, (st))
#define sk_ASN1_GENERALSTRING_value(st, i) SKM_sk_value(ASN1_GENERALSTRING, (st), (i))
#define sk_ASN1_GENERALSTRING_set(st, i, val) SKM_sk_set(ASN1_GENERALSTRING, (st), (i), (val))
#define sk_ASN1_GENERALSTRING_zero(st) SKM_sk_zero(ASN1_GENERALSTRING, (st))
#define sk_ASN1_GENERALSTRING_push(st, val) SKM_sk_push(ASN1_GENERALSTRING, (st), (val))
#define sk_ASN1_GENERALSTRING_unshift(st, val) SKM_sk_unshift(ASN1_GENERALSTRING, (st), (val))
#define sk_ASN1_GENERALSTRING_find(st, val) SKM_sk_find(ASN1_GENERALSTRING, (st), (val))
#define sk_ASN1_GENERALSTRING_find_ex(st, val) SKM_sk_find_ex(ASN1_GENERALSTRING, (st), (val))
#define sk_ASN1_GENERALSTRING_delete(st, i) SKM_sk_delete(ASN1_GENERALSTRING, (st), (i))
#define sk_ASN1_GENERALSTRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_GENERALSTRING, (st), (ptr))
#define sk_ASN1_GENERALSTRING_insert(st, val, i) SKM_sk_insert(ASN1_GENERALSTRING, (st), (val), (i))
#define sk_ASN1_GENERALSTRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_GENERALSTRING, (st), (cmp))
#define sk_ASN1_GENERALSTRING_dup(st) SKM_sk_dup(ASN1_GENERALSTRING, st)
#define sk_ASN1_GENERALSTRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_GENERALSTRING, (st), (free_func))
#define sk_ASN1_GENERALSTRING_shift(st) SKM_sk_shift(ASN1_GENERALSTRING, (st))
#define sk_ASN1_GENERALSTRING_pop(st) SKM_sk_pop(ASN1_GENERALSTRING, (st))
#define sk_ASN1_GENERALSTRING_sort(st) SKM_sk_sort(ASN1_GENERALSTRING, (st))
#define sk_ASN1_GENERALSTRING_is_sorted(st) SKM_sk_is_sorted(ASN1_GENERALSTRING, (st))

#define sk_ASN1_INTEGER_new(cmp) SKM_sk_new(ASN1_INTEGER, (cmp))
#define sk_ASN1_INTEGER_new_null() SKM_sk_new_null(ASN1_INTEGER)
#define sk_ASN1_INTEGER_free(st) SKM_sk_free(ASN1_INTEGER, (st))
#define sk_ASN1_INTEGER_num(st) SKM_sk_num(ASN1_INTEGER, (st))
#define sk_ASN1_INTEGER_value(st, i) SKM_sk_value(ASN1_INTEGER, (st), (i))
#define sk_ASN1_INTEGER_set(st, i, val) SKM_sk_set(ASN1_INTEGER, (st), (i), (val))
#define sk_ASN1_INTEGER_zero(st) SKM_sk_zero(ASN1_INTEGER, (st))
#define sk_ASN1_INTEGER_push(st, val) SKM_sk_push(ASN1_INTEGER, (st), (val))
#define sk_ASN1_INTEGER_unshift(st, val) SKM_sk_unshift(ASN1_INTEGER, (st), (val))
#define sk_ASN1_INTEGER_find(st, val) SKM_sk_find(ASN1_INTEGER, (st), (val))
#define sk_ASN1_INTEGER_find_ex(st, val) SKM_sk_find_ex(ASN1_INTEGER, (st), (val))
#define sk_ASN1_INTEGER_delete(st, i) SKM_sk_delete(ASN1_INTEGER, (st), (i))
#define sk_ASN1_INTEGER_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_INTEGER, (st), (ptr))
#define sk_ASN1_INTEGER_insert(st, val, i) SKM_sk_insert(ASN1_INTEGER, (st), (val), (i))
#define sk_ASN1_INTEGER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_INTEGER, (st), (cmp))
#define sk_ASN1_INTEGER_dup(st) SKM_sk_dup(ASN1_INTEGER, st)
#define sk_ASN1_INTEGER_pop_free(st, free_func) SKM_sk_pop_free(ASN1_INTEGER, (st), (free_func))
#define sk_ASN1_INTEGER_shift(st) SKM_sk_shift(ASN1_INTEGER, (st))
#define sk_ASN1_INTEGER_pop(st) SKM_sk_pop(ASN1_INTEGER, (st))
#define sk_ASN1_INTEGER_sort(st) SKM_sk_sort(ASN1_INTEGER, (st))
#define sk_ASN1_INTEGER_is_sorted(st) SKM_sk_is_sorted(ASN1_INTEGER, (st))

#define sk_ASN1_OBJECT_new(cmp) SKM_sk_new(ASN1_OBJECT, (cmp))
#define sk_ASN1_OBJECT_new_null() SKM_sk_new_null(ASN1_OBJECT)
#define sk_ASN1_OBJECT_free(st) SKM_sk_free(ASN1_OBJECT, (st))
#define sk_ASN1_OBJECT_num(st) SKM_sk_num(ASN1_OBJECT, (st))
#define sk_ASN1_OBJECT_value(st, i) SKM_sk_value(ASN1_OBJECT, (st), (i))
#define sk_ASN1_OBJECT_set(st, i, val) SKM_sk_set(ASN1_OBJECT, (st), (i), (val))
#define sk_ASN1_OBJECT_zero(st) SKM_sk_zero(ASN1_OBJECT, (st))
#define sk_ASN1_OBJECT_push(st, val) SKM_sk_push(ASN1_OBJECT, (st), (val))
#define sk_ASN1_OBJECT_unshift(st, val) SKM_sk_unshift(ASN1_OBJECT, (st), (val))
#define sk_ASN1_OBJECT_find(st, val) SKM_sk_find(ASN1_OBJECT, (st), (val))
#define sk_ASN1_OBJECT_find_ex(st, val) SKM_sk_find_ex(ASN1_OBJECT, (st), (val))
#define sk_ASN1_OBJECT_delete(st, i) SKM_sk_delete(ASN1_OBJECT, (st), (i))
#define sk_ASN1_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_OBJECT, (st), (ptr))
#define sk_ASN1_OBJECT_insert(st, val, i) SKM_sk_insert(ASN1_OBJECT, (st), (val), (i))
#define sk_ASN1_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_OBJECT, (st), (cmp))
#define sk_ASN1_OBJECT_dup(st) SKM_sk_dup(ASN1_OBJECT, st)
#define sk_ASN1_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(ASN1_OBJECT, (st), (free_func))
#define sk_ASN1_OBJECT_shift(st) SKM_sk_shift(ASN1_OBJECT, (st))
#define sk_ASN1_OBJECT_pop(st) SKM_sk_pop(ASN1_OBJECT, (st))
#define sk_ASN1_OBJECT_sort(st) SKM_sk_sort(ASN1_OBJECT, (st))
#define sk_ASN1_OBJECT_is_sorted(st) SKM_sk_is_sorted(ASN1_OBJECT, (st))

#define sk_ASN1_STRING_TABLE_new(cmp) SKM_sk_new(ASN1_STRING_TABLE, (cmp))
#define sk_ASN1_STRING_TABLE_new_null() SKM_sk_new_null(ASN1_STRING_TABLE)
#define sk_ASN1_STRING_TABLE_free(st) SKM_sk_free(ASN1_STRING_TABLE, (st))
#define sk_ASN1_STRING_TABLE_num(st) SKM_sk_num(ASN1_STRING_TABLE, (st))
#define sk_ASN1_STRING_TABLE_value(st, i) SKM_sk_value(ASN1_STRING_TABLE, (st), (i))
#define sk_ASN1_STRING_TABLE_set(st, i, val) SKM_sk_set(ASN1_STRING_TABLE, (st), (i), (val))
#define sk_ASN1_STRING_TABLE_zero(st) SKM_sk_zero(ASN1_STRING_TABLE, (st))
#define sk_ASN1_STRING_TABLE_push(st, val) SKM_sk_push(ASN1_STRING_TABLE, (st), (val))
#define sk_ASN1_STRING_TABLE_unshift(st, val) SKM_sk_unshift(ASN1_STRING_TABLE, (st), (val))
#define sk_ASN1_STRING_TABLE_find(st, val) SKM_sk_find(ASN1_STRING_TABLE, (st), (val))
#define sk_ASN1_STRING_TABLE_find_ex(st, val) SKM_sk_find_ex(ASN1_STRING_TABLE, (st), (val))
#define sk_ASN1_STRING_TABLE_delete(st, i) SKM_sk_delete(ASN1_STRING_TABLE, (st), (i))
#define sk_ASN1_STRING_TABLE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_STRING_TABLE, (st), (ptr))
#define sk_ASN1_STRING_TABLE_insert(st, val, i) SKM_sk_insert(ASN1_STRING_TABLE, (st), (val), (i))
#define sk_ASN1_STRING_TABLE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_STRING_TABLE, (st), (cmp))
#define sk_ASN1_STRING_TABLE_dup(st) SKM_sk_dup(ASN1_STRING_TABLE, st)
#define sk_ASN1_STRING_TABLE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_STRING_TABLE, (st), (free_func))
#define sk_ASN1_STRING_TABLE_shift(st) SKM_sk_shift(ASN1_STRING_TABLE, (st))
#define sk_ASN1_STRING_TABLE_pop(st) SKM_sk_pop(ASN1_STRING_TABLE, (st))
#define sk_ASN1_STRING_TABLE_sort(st) SKM_sk_sort(ASN1_STRING_TABLE, (st))
#define sk_ASN1_STRING_TABLE_is_sorted(st) SKM_sk_is_sorted(ASN1_STRING_TABLE, (st))

#define sk_ASN1_TYPE_new(cmp) SKM_sk_new(ASN1_TYPE, (cmp))
#define sk_ASN1_TYPE_new_null() SKM_sk_new_null(ASN1_TYPE)
#define sk_ASN1_TYPE_free(st) SKM_sk_free(ASN1_TYPE, (st))
#define sk_ASN1_TYPE_num(st) SKM_sk_num(ASN1_TYPE, (st))
#define sk_ASN1_TYPE_value(st, i) SKM_sk_value(ASN1_TYPE, (st), (i))
#define sk_ASN1_TYPE_set(st, i, val) SKM_sk_set(ASN1_TYPE, (st), (i), (val))
#define sk_ASN1_TYPE_zero(st) SKM_sk_zero(ASN1_TYPE, (st))
#define sk_ASN1_TYPE_push(st, val) SKM_sk_push(ASN1_TYPE, (st), (val))
#define sk_ASN1_TYPE_unshift(st, val) SKM_sk_unshift(ASN1_TYPE, (st), (val))
#define sk_ASN1_TYPE_find(st, val) SKM_sk_find(ASN1_TYPE, (st), (val))
#define sk_ASN1_TYPE_find_ex(st, val) SKM_sk_find_ex(ASN1_TYPE, (st), (val))
#define sk_ASN1_TYPE_delete(st, i) SKM_sk_delete(ASN1_TYPE, (st), (i))
#define sk_ASN1_TYPE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_TYPE, (st), (ptr))
#define sk_ASN1_TYPE_insert(st, val, i) SKM_sk_insert(ASN1_TYPE, (st), (val), (i))
#define sk_ASN1_TYPE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_TYPE, (st), (cmp))
#define sk_ASN1_TYPE_dup(st) SKM_sk_dup(ASN1_TYPE, st)
#define sk_ASN1_TYPE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_TYPE, (st), (free_func))
#define sk_ASN1_TYPE_shift(st) SKM_sk_shift(ASN1_TYPE, (st))
#define sk_ASN1_TYPE_pop(st) SKM_sk_pop(ASN1_TYPE, (st))
#define sk_ASN1_TYPE_sort(st) SKM_sk_sort(ASN1_TYPE, (st))
#define sk_ASN1_TYPE_is_sorted(st) SKM_sk_is_sorted(ASN1_TYPE, (st))

#define sk_ASN1_UTF8STRING_new(cmp) SKM_sk_new(ASN1_UTF8STRING, (cmp))
#define sk_ASN1_UTF8STRING_new_null() SKM_sk_new_null(ASN1_UTF8STRING)
#define sk_ASN1_UTF8STRING_free(st) SKM_sk_free(ASN1_UTF8STRING, (st))
#define sk_ASN1_UTF8STRING_num(st) SKM_sk_num(ASN1_UTF8STRING, (st))
#define sk_ASN1_UTF8STRING_value(st, i) SKM_sk_value(ASN1_UTF8STRING, (st), (i))
#define sk_ASN1_UTF8STRING_set(st, i, val) SKM_sk_set(ASN1_UTF8STRING, (st), (i), (val))
#define sk_ASN1_UTF8STRING_zero(st) SKM_sk_zero(ASN1_UTF8STRING, (st))
#define sk_ASN1_UTF8STRING_push(st, val) SKM_sk_push(ASN1_UTF8STRING, (st), (val))
#define sk_ASN1_UTF8STRING_unshift(st, val) SKM_sk_unshift(ASN1_UTF8STRING, (st), (val))
#define sk_ASN1_UTF8STRING_find(st, val) SKM_sk_find(ASN1_UTF8STRING, (st), (val))
#define sk_ASN1_UTF8STRING_find_ex(st, val) SKM_sk_find_ex(ASN1_UTF8STRING, (st), (val))
#define sk_ASN1_UTF8STRING_delete(st, i) SKM_sk_delete(ASN1_UTF8STRING, (st), (i))
#define sk_ASN1_UTF8STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_UTF8STRING, (st), (ptr))
#define sk_ASN1_UTF8STRING_insert(st, val, i) SKM_sk_insert(ASN1_UTF8STRING, (st), (val), (i))
#define sk_ASN1_UTF8STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_UTF8STRING, (st), (cmp))
#define sk_ASN1_UTF8STRING_dup(st) SKM_sk_dup(ASN1_UTF8STRING, st)
#define sk_ASN1_UTF8STRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_UTF8STRING, (st), (free_func))
#define sk_ASN1_UTF8STRING_shift(st) SKM_sk_shift(ASN1_UTF8STRING, (st))
#define sk_ASN1_UTF8STRING_pop(st) SKM_sk_pop(ASN1_UTF8STRING, (st))
#define sk_ASN1_UTF8STRING_sort(st) SKM_sk_sort(ASN1_UTF8STRING, (st))
#define sk_ASN1_UTF8STRING_is_sorted(st) SKM_sk_is_sorted(ASN1_UTF8STRING, (st))

#define sk_ASN1_VALUE_new(cmp) SKM_sk_new(ASN1_VALUE, (cmp))
#define sk_ASN1_VALUE_new_null() SKM_sk_new_null(ASN1_VALUE)
#define sk_ASN1_VALUE_free(st) SKM_sk_free(ASN1_VALUE, (st))
#define sk_ASN1_VALUE_num(st) SKM_sk_num(ASN1_VALUE, (st))
#define sk_ASN1_VALUE_value(st, i) SKM_sk_value(ASN1_VALUE, (st), (i))
#define sk_ASN1_VALUE_set(st, i, val) SKM_sk_set(ASN1_VALUE, (st), (i), (val))
#define sk_ASN1_VALUE_zero(st) SKM_sk_zero(ASN1_VALUE, (st))
#define sk_ASN1_VALUE_push(st, val) SKM_sk_push(ASN1_VALUE, (st), (val))
#define sk_ASN1_VALUE_unshift(st, val) SKM_sk_unshift(ASN1_VALUE, (st), (val))
#define sk_ASN1_VALUE_find(st, val) SKM_sk_find(ASN1_VALUE, (st), (val))
#define sk_ASN1_VALUE_find_ex(st, val) SKM_sk_find_ex(ASN1_VALUE, (st), (val))
#define sk_ASN1_VALUE_delete(st, i) SKM_sk_delete(ASN1_VALUE, (st), (i))
#define sk_ASN1_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_VALUE, (st), (ptr))
#define sk_ASN1_VALUE_insert(st, val, i) SKM_sk_insert(ASN1_VALUE, (st), (val), (i))
#define sk_ASN1_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_VALUE, (st), (cmp))
#define sk_ASN1_VALUE_dup(st) SKM_sk_dup(ASN1_VALUE, st)
#define sk_ASN1_VALUE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_VALUE, (st), (free_func))
#define sk_ASN1_VALUE_shift(st) SKM_sk_shift(ASN1_VALUE, (st))
#define sk_ASN1_VALUE_pop(st) SKM_sk_pop(ASN1_VALUE, (st))
#define sk_ASN1_VALUE_sort(st) SKM_sk_sort(ASN1_VALUE, (st))
#define sk_ASN1_VALUE_is_sorted(st) SKM_sk_is_sorted(ASN1_VALUE, (st))

#define sk_BIO_new(cmp) SKM_sk_new(BIO, (cmp))
#define sk_BIO_new_null() SKM_sk_new_null(BIO)
#define sk_BIO_free(st) SKM_sk_free(BIO, (st))
#define sk_BIO_num(st) SKM_sk_num(BIO, (st))
#define sk_BIO_value(st, i) SKM_sk_value(BIO, (st), (i))
#define sk_BIO_set(st, i, val) SKM_sk_set(BIO, (st), (i), (val))
#define sk_BIO_zero(st) SKM_sk_zero(BIO, (st))
#define sk_BIO_push(st, val) SKM_sk_push(BIO, (st), (val))
#define sk_BIO_unshift(st, val) SKM_sk_unshift(BIO, (st), (val))
#define sk_BIO_find(st, val) SKM_sk_find(BIO, (st), (val))
#define sk_BIO_find_ex(st, val) SKM_sk_find_ex(BIO, (st), (val))
#define sk_BIO_delete(st, i) SKM_sk_delete(BIO, (st), (i))
#define sk_BIO_delete_ptr(st, ptr) SKM_sk_delete_ptr(BIO, (st), (ptr))
#define sk_BIO_insert(st, val, i) SKM_sk_insert(BIO, (st), (val), (i))
#define sk_BIO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BIO, (st), (cmp))
#define sk_BIO_dup(st) SKM_sk_dup(BIO, st)
#define sk_BIO_pop_free(st, free_func) SKM_sk_pop_free(BIO, (st), (free_func))
#define sk_BIO_shift(st) SKM_sk_shift(BIO, (st))
#define sk_BIO_pop(st) SKM_sk_pop(BIO, (st))
#define sk_BIO_sort(st) SKM_sk_sort(BIO, (st))
#define sk_BIO_is_sorted(st) SKM_sk_is_sorted(BIO, (st))

#define sk_BY_DIR_ENTRY_new(cmp) SKM_sk_new(BY_DIR_ENTRY, (cmp))
#define sk_BY_DIR_ENTRY_new_null() SKM_sk_new_null(BY_DIR_ENTRY)
#define sk_BY_DIR_ENTRY_free(st) SKM_sk_free(BY_DIR_ENTRY, (st))
#define sk_BY_DIR_ENTRY_num(st) SKM_sk_num(BY_DIR_ENTRY, (st))
#define sk_BY_DIR_ENTRY_value(st, i) SKM_sk_value(BY_DIR_ENTRY, (st), (i))
#define sk_BY_DIR_ENTRY_set(st, i, val) SKM_sk_set(BY_DIR_ENTRY, (st), (i), (val))
#define sk_BY_DIR_ENTRY_zero(st) SKM_sk_zero(BY_DIR_ENTRY, (st))
#define sk_BY_DIR_ENTRY_push(st, val) SKM_sk_push(BY_DIR_ENTRY, (st), (val))
#define sk_BY_DIR_ENTRY_unshift(st, val) SKM_sk_unshift(BY_DIR_ENTRY, (st), (val))
#define sk_BY_DIR_ENTRY_find(st, val) SKM_sk_find(BY_DIR_ENTRY, (st), (val))
#define sk_BY_DIR_ENTRY_find_ex(st, val) SKM_sk_find_ex(BY_DIR_ENTRY, (st), (val))
#define sk_BY_DIR_ENTRY_delete(st, i) SKM_sk_delete(BY_DIR_ENTRY, (st), (i))
#define sk_BY_DIR_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(BY_DIR_ENTRY, (st), (ptr))
#define sk_BY_DIR_ENTRY_insert(st, val, i) SKM_sk_insert(BY_DIR_ENTRY, (st), (val), (i))
#define sk_BY_DIR_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BY_DIR_ENTRY, (st), (cmp))
#define sk_BY_DIR_ENTRY_dup(st) SKM_sk_dup(BY_DIR_ENTRY, st)
#define sk_BY_DIR_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(BY_DIR_ENTRY, (st), (free_func))
#define sk_BY_DIR_ENTRY_shift(st) SKM_sk_shift(BY_DIR_ENTRY, (st))
#define sk_BY_DIR_ENTRY_pop(st) SKM_sk_pop(BY_DIR_ENTRY, (st))
#define sk_BY_DIR_ENTRY_sort(st) SKM_sk_sort(BY_DIR_ENTRY, (st))
#define sk_BY_DIR_ENTRY_is_sorted(st) SKM_sk_is_sorted(BY_DIR_ENTRY, (st))

#define sk_BY_DIR_HASH_new(cmp) SKM_sk_new(BY_DIR_HASH, (cmp))
#define sk_BY_DIR_HASH_new_null() SKM_sk_new_null(BY_DIR_HASH)
#define sk_BY_DIR_HASH_free(st) SKM_sk_free(BY_DIR_HASH, (st))
#define sk_BY_DIR_HASH_num(st) SKM_sk_num(BY_DIR_HASH, (st))
#define sk_BY_DIR_HASH_value(st, i) SKM_sk_value(BY_DIR_HASH, (st), (i))
#define sk_BY_DIR_HASH_set(st, i, val) SKM_sk_set(BY_DIR_HASH, (st), (i), (val))
#define sk_BY_DIR_HASH_zero(st) SKM_sk_zero(BY_DIR_HASH, (st))
#define sk_BY_DIR_HASH_push(st, val) SKM_sk_push(BY_DIR_HASH, (st), (val))
#define sk_BY_DIR_HASH_unshift(st, val) SKM_sk_unshift(BY_DIR_HASH, (st), (val))
#define sk_BY_DIR_HASH_find(st, val) SKM_sk_find(BY_DIR_HASH, (st), (val))
#define sk_BY_DIR_HASH_find_ex(st, val) SKM_sk_find_ex(BY_DIR_HASH, (st), (val))
#define sk_BY_DIR_HASH_delete(st, i) SKM_sk_delete(BY_DIR_HASH, (st), (i))
#define sk_BY_DIR_HASH_delete_ptr(st, ptr) SKM_sk_delete_ptr(BY_DIR_HASH, (st), (ptr))
#define sk_BY_DIR_HASH_insert(st, val, i) SKM_sk_insert(BY_DIR_HASH, (st), (val), (i))
#define sk_BY_DIR_HASH_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BY_DIR_HASH, (st), (cmp))
#define sk_BY_DIR_HASH_dup(st) SKM_sk_dup(BY_DIR_HASH, st)
#define sk_BY_DIR_HASH_pop_free(st, free_func) SKM_sk_pop_free(BY_DIR_HASH, (st), (free_func))
#define sk_BY_DIR_HASH_shift(st) SKM_sk_shift(BY_DIR_HASH, (st))
#define sk_BY_DIR_HASH_pop(st) SKM_sk_pop(BY_DIR_HASH, (st))
#define sk_BY_DIR_HASH_sort(st) SKM_sk_sort(BY_DIR_HASH, (st))
#define sk_BY_DIR_HASH_is_sorted(st) SKM_sk_is_sorted(BY_DIR_HASH, (st))

#define sk_CMS_CertificateChoices_new(cmp) SKM_sk_new(CMS_CertificateChoices, (cmp))
#define sk_CMS_CertificateChoices_new_null() SKM_sk_new_null(CMS_CertificateChoices)
#define sk_CMS_CertificateChoices_free(st) SKM_sk_free(CMS_CertificateChoices, (st))
#define sk_CMS_CertificateChoices_num(st) SKM_sk_num(CMS_CertificateChoices, (st))
#define sk_CMS_CertificateChoices_value(st, i) SKM_sk_value(CMS_CertificateChoices, (st), (i))
#define sk_CMS_CertificateChoices_set(st, i, val) SKM_sk_set(CMS_CertificateChoices, (st), (i), (val))
#define sk_CMS_CertificateChoices_zero(st) SKM_sk_zero(CMS_CertificateChoices, (st))
#define sk_CMS_CertificateChoices_push(st, val) SKM_sk_push(CMS_CertificateChoices, (st), (val))
#define sk_CMS_CertificateChoices_unshift(st, val) SKM_sk_unshift(CMS_CertificateChoices, (st), (val))
#define sk_CMS_CertificateChoices_find(st, val) SKM_sk_find(CMS_CertificateChoices, (st), (val))
#define sk_CMS_CertificateChoices_find_ex(st, val) SKM_sk_find_ex(CMS_CertificateChoices, (st), (val))
#define sk_CMS_CertificateChoices_delete(st, i) SKM_sk_delete(CMS_CertificateChoices, (st), (i))
#define sk_CMS_CertificateChoices_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_CertificateChoices, (st), (ptr))
#define sk_CMS_CertificateChoices_insert(st, val, i) SKM_sk_insert(CMS_CertificateChoices, (st), (val), (i))
#define sk_CMS_CertificateChoices_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_CertificateChoices, (st), (cmp))
#define sk_CMS_CertificateChoices_dup(st) SKM_sk_dup(CMS_CertificateChoices, st)
#define sk_CMS_CertificateChoices_pop_free(st, free_func) SKM_sk_pop_free(CMS_CertificateChoices, (st), (free_func))
#define sk_CMS_CertificateChoices_shift(st) SKM_sk_shift(CMS_CertificateChoices, (st))
#define sk_CMS_CertificateChoices_pop(st) SKM_sk_pop(CMS_CertificateChoices, (st))
#define sk_CMS_CertificateChoices_sort(st) SKM_sk_sort(CMS_CertificateChoices, (st))
#define sk_CMS_CertificateChoices_is_sorted(st) SKM_sk_is_sorted(CMS_CertificateChoices, (st))

#define sk_CMS_RecipientInfo_new(cmp) SKM_sk_new(CMS_RecipientInfo, (cmp))
#define sk_CMS_RecipientInfo_new_null() SKM_sk_new_null(CMS_RecipientInfo)
#define sk_CMS_RecipientInfo_free(st) SKM_sk_free(CMS_RecipientInfo, (st))
#define sk_CMS_RecipientInfo_num(st) SKM_sk_num(CMS_RecipientInfo, (st))
#define sk_CMS_RecipientInfo_value(st, i) SKM_sk_value(CMS_RecipientInfo, (st), (i))
#define sk_CMS_RecipientInfo_set(st, i, val) SKM_sk_set(CMS_RecipientInfo, (st), (i), (val))
#define sk_CMS_RecipientInfo_zero(st) SKM_sk_zero(CMS_RecipientInfo, (st))
#define sk_CMS_RecipientInfo_push(st, val) SKM_sk_push(CMS_RecipientInfo, (st), (val))
#define sk_CMS_RecipientInfo_unshift(st, val) SKM_sk_unshift(CMS_RecipientInfo, (st), (val))
#define sk_CMS_RecipientInfo_find(st, val) SKM_sk_find(CMS_RecipientInfo, (st), (val))
#define sk_CMS_RecipientInfo_find_ex(st, val) SKM_sk_find_ex(CMS_RecipientInfo, (st), (val))
#define sk_CMS_RecipientInfo_delete(st, i) SKM_sk_delete(CMS_RecipientInfo, (st), (i))
#define sk_CMS_RecipientInfo_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_RecipientInfo, (st), (ptr))
#define sk_CMS_RecipientInfo_insert(st, val, i) SKM_sk_insert(CMS_RecipientInfo, (st), (val), (i))
#define sk_CMS_RecipientInfo_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_RecipientInfo, (st), (cmp))
#define sk_CMS_RecipientInfo_dup(st) SKM_sk_dup(CMS_RecipientInfo, st)
#define sk_CMS_RecipientInfo_pop_free(st, free_func) SKM_sk_pop_free(CMS_RecipientInfo, (st), (free_func))
#define sk_CMS_RecipientInfo_shift(st) SKM_sk_shift(CMS_RecipientInfo, (st))
#define sk_CMS_RecipientInfo_pop(st) SKM_sk_pop(CMS_RecipientInfo, (st))
#define sk_CMS_RecipientInfo_sort(st) SKM_sk_sort(CMS_RecipientInfo, (st))
#define sk_CMS_RecipientInfo_is_sorted(st) SKM_sk_is_sorted(CMS_RecipientInfo, (st))

#define sk_CMS_RevocationInfoChoice_new(cmp) SKM_sk_new(CMS_RevocationInfoChoice, (cmp))
#define sk_CMS_RevocationInfoChoice_new_null() SKM_sk_new_null(CMS_RevocationInfoChoice)
#define sk_CMS_RevocationInfoChoice_free(st) SKM_sk_free(CMS_RevocationInfoChoice, (st))
#define sk_CMS_RevocationInfoChoice_num(st) SKM_sk_num(CMS_RevocationInfoChoice, (st))
#define sk_CMS_RevocationInfoChoice_value(st, i) SKM_sk_value(CMS_RevocationInfoChoice, (st), (i))
#define sk_CMS_RevocationInfoChoice_set(st, i, val) SKM_sk_set(CMS_RevocationInfoChoice, (st), (i), (val))
#define sk_CMS_RevocationInfoChoice_zero(st) SKM_sk_zero(CMS_RevocationInfoChoice, (st))
#define sk_CMS_RevocationInfoChoice_push(st, val) SKM_sk_push(CMS_RevocationInfoChoice, (st), (val))
#define sk_CMS_RevocationInfoChoice_unshift(st, val) SKM_sk_unshift(CMS_RevocationInfoChoice, (st), (val))
#define sk_CMS_RevocationInfoChoice_find(st, val) SKM_sk_find(CMS_RevocationInfoChoice, (st), (val))
#define sk_CMS_RevocationInfoChoice_find_ex(st, val) SKM_sk_find_ex(CMS_RevocationInfoChoice, (st), (val))
#define sk_CMS_RevocationInfoChoice_delete(st, i) SKM_sk_delete(CMS_RevocationInfoChoice, (st), (i))
#define sk_CMS_RevocationInfoChoice_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_RevocationInfoChoice, (st), (ptr))
#define sk_CMS_RevocationInfoChoice_insert(st, val, i) SKM_sk_insert(CMS_RevocationInfoChoice, (st), (val), (i))
#define sk_CMS_RevocationInfoChoice_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_RevocationInfoChoice, (st), (cmp))
#define sk_CMS_RevocationInfoChoice_dup(st) SKM_sk_dup(CMS_RevocationInfoChoice, st)
#define sk_CMS_RevocationInfoChoice_pop_free(st, free_func) SKM_sk_pop_free(CMS_RevocationInfoChoice, (st), (free_func))
#define sk_CMS_RevocationInfoChoice_shift(st) SKM_sk_shift(CMS_RevocationInfoChoice, (st))
#define sk_CMS_RevocationInfoChoice_pop(st) SKM_sk_pop(CMS_RevocationInfoChoice, (st))
#define sk_CMS_RevocationInfoChoice_sort(st) SKM_sk_sort(CMS_RevocationInfoChoice, (st))
#define sk_CMS_RevocationInfoChoice_is_sorted(st) SKM_sk_is_sorted(CMS_RevocationInfoChoice, (st))

#define sk_CMS_SignerInfo_new(cmp) SKM_sk_new(CMS_SignerInfo, (cmp))
#define sk_CMS_SignerInfo_new_null() SKM_sk_new_null(CMS_SignerInfo)
#define sk_CMS_SignerInfo_free(st) SKM_sk_free(CMS_SignerInfo, (st))
#define sk_CMS_SignerInfo_num(st) SKM_sk_num(CMS_SignerInfo, (st))
#define sk_CMS_SignerInfo_value(st, i) SKM_sk_value(CMS_SignerInfo, (st), (i))
#define sk_CMS_SignerInfo_set(st, i, val) SKM_sk_set(CMS_SignerInfo, (st), (i), (val))
#define sk_CMS_SignerInfo_zero(st) SKM_sk_zero(CMS_SignerInfo, (st))
#define sk_CMS_SignerInfo_push(st, val) SKM_sk_push(CMS_SignerInfo, (st), (val))
#define sk_CMS_SignerInfo_unshift(st, val) SKM_sk_unshift(CMS_SignerInfo, (st), (val))
#define sk_CMS_SignerInfo_find(st, val) SKM_sk_find(CMS_SignerInfo, (st), (val))
#define sk_CMS_SignerInfo_find_ex(st, val) SKM_sk_find_ex(CMS_SignerInfo, (st), (val))
#define sk_CMS_SignerInfo_delete(st, i) SKM_sk_delete(CMS_SignerInfo, (st), (i))
#define sk_CMS_SignerInfo_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_SignerInfo, (st), (ptr))
#define sk_CMS_SignerInfo_insert(st, val, i) SKM_sk_insert(CMS_SignerInfo, (st), (val), (i))
#define sk_CMS_SignerInfo_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_SignerInfo, (st), (cmp))
#define sk_CMS_SignerInfo_dup(st) SKM_sk_dup(CMS_SignerInfo, st)
#define sk_CMS_SignerInfo_pop_free(st, free_func) SKM_sk_pop_free(CMS_SignerInfo, (st), (free_func))
#define sk_CMS_SignerInfo_shift(st) SKM_sk_shift(CMS_SignerInfo, (st))
#define sk_CMS_SignerInfo_pop(st) SKM_sk_pop(CMS_SignerInfo, (st))
#define sk_CMS_SignerInfo_sort(st) SKM_sk_sort(CMS_SignerInfo, (st))
#define sk_CMS_SignerInfo_is_sorted(st) SKM_sk_is_sorted(CMS_SignerInfo, (st))

#define sk_CONF_IMODULE_new(cmp) SKM_sk_new(CONF_IMODULE, (cmp))
#define sk_CONF_IMODULE_new_null() SKM_sk_new_null(CONF_IMODULE)
#define sk_CONF_IMODULE_free(st) SKM_sk_free(CONF_IMODULE, (st))
#define sk_CONF_IMODULE_num(st) SKM_sk_num(CONF_IMODULE, (st))
#define sk_CONF_IMODULE_value(st, i) SKM_sk_value(CONF_IMODULE, (st), (i))
#define sk_CONF_IMODULE_set(st, i, val) SKM_sk_set(CONF_IMODULE, (st), (i), (val))
#define sk_CONF_IMODULE_zero(st) SKM_sk_zero(CONF_IMODULE, (st))
#define sk_CONF_IMODULE_push(st, val) SKM_sk_push(CONF_IMODULE, (st), (val))
#define sk_CONF_IMODULE_unshift(st, val) SKM_sk_unshift(CONF_IMODULE, (st), (val))
#define sk_CONF_IMODULE_find(st, val) SKM_sk_find(CONF_IMODULE, (st), (val))
#define sk_CONF_IMODULE_find_ex(st, val) SKM_sk_find_ex(CONF_IMODULE, (st), (val))
#define sk_CONF_IMODULE_delete(st, i) SKM_sk_delete(CONF_IMODULE, (st), (i))
#define sk_CONF_IMODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_IMODULE, (st), (ptr))
#define sk_CONF_IMODULE_insert(st, val, i) SKM_sk_insert(CONF_IMODULE, (st), (val), (i))
#define sk_CONF_IMODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_IMODULE, (st), (cmp))
#define sk_CONF_IMODULE_dup(st) SKM_sk_dup(CONF_IMODULE, st)
#define sk_CONF_IMODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_IMODULE, (st), (free_func))
#define sk_CONF_IMODULE_shift(st) SKM_sk_shift(CONF_IMODULE, (st))
#define sk_CONF_IMODULE_pop(st) SKM_sk_pop(CONF_IMODULE, (st))
#define sk_CONF_IMODULE_sort(st) SKM_sk_sort(CONF_IMODULE, (st))
#define sk_CONF_IMODULE_is_sorted(st) SKM_sk_is_sorted(CONF_IMODULE, (st))

#define sk_CONF_MODULE_new(cmp) SKM_sk_new(CONF_MODULE, (cmp))
#define sk_CONF_MODULE_new_null() SKM_sk_new_null(CONF_MODULE)
#define sk_CONF_MODULE_free(st) SKM_sk_free(CONF_MODULE, (st))
#define sk_CONF_MODULE_num(st) SKM_sk_num(CONF_MODULE, (st))
#define sk_CONF_MODULE_value(st, i) SKM_sk_value(CONF_MODULE, (st), (i))
#define sk_CONF_MODULE_set(st, i, val) SKM_sk_set(CONF_MODULE, (st), (i), (val))
#define sk_CONF_MODULE_zero(st) SKM_sk_zero(CONF_MODULE, (st))
#define sk_CONF_MODULE_push(st, val) SKM_sk_push(CONF_MODULE, (st), (val))
#define sk_CONF_MODULE_unshift(st, val) SKM_sk_unshift(CONF_MODULE, (st), (val))
#define sk_CONF_MODULE_find(st, val) SKM_sk_find(CONF_MODULE, (st), (val))
#define sk_CONF_MODULE_find_ex(st, val) SKM_sk_find_ex(CONF_MODULE, (st), (val))
#define sk_CONF_MODULE_delete(st, i) SKM_sk_delete(CONF_MODULE, (st), (i))
#define sk_CONF_MODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_MODULE, (st), (ptr))
#define sk_CONF_MODULE_insert(st, val, i) SKM_sk_insert(CONF_MODULE, (st), (val), (i))
#define sk_CONF_MODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_MODULE, (st), (cmp))
#define sk_CONF_MODULE_dup(st) SKM_sk_dup(CONF_MODULE, st)
#define sk_CONF_MODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_MODULE, (st), (free_func))
#define sk_CONF_MODULE_shift(st) SKM_sk_shift(CONF_MODULE, (st))
#define sk_CONF_MODULE_pop(st) SKM_sk_pop(CONF_MODULE, (st))
#define sk_CONF_MODULE_sort(st) SKM_sk_sort(CONF_MODULE, (st))
#define sk_CONF_MODULE_is_sorted(st) SKM_sk_is_sorted(CONF_MODULE, (st))

#define sk_CONF_VALUE_new(cmp) SKM_sk_new(CONF_VALUE, (cmp))
#define sk_CONF_VALUE_new_null() SKM_sk_new_null(CONF_VALUE)
#define sk_CONF_VALUE_free(st) SKM_sk_free(CONF_VALUE, (st))
#define sk_CONF_VALUE_num(st) SKM_sk_num(CONF_VALUE, (st))
#define sk_CONF_VALUE_value(st, i) SKM_sk_value(CONF_VALUE, (st), (i))
#define sk_CONF_VALUE_set(st, i, val) SKM_sk_set(CONF_VALUE, (st), (i), (val))
#define sk_CONF_VALUE_zero(st) SKM_sk_zero(CONF_VALUE, (st))
#define sk_CONF_VALUE_push(st, val) SKM_sk_push(CONF_VALUE, (st), (val))
#define sk_CONF_VALUE_unshift(st, val) SKM_sk_unshift(CONF_VALUE, (st), (val))
#define sk_CONF_VALUE_find(st, val) SKM_sk_find(CONF_VALUE, (st), (val))
#define sk_CONF_VALUE_find_ex(st, val) SKM_sk_find_ex(CONF_VALUE, (st), (val))
#define sk_CONF_VALUE_delete(st, i) SKM_sk_delete(CONF_VALUE, (st), (i))
#define sk_CONF_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_VALUE, (st), (ptr))
#define sk_CONF_VALUE_insert(st, val, i) SKM_sk_insert(CONF_VALUE, (st), (val), (i))
#define sk_CONF_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_VALUE, (st), (cmp))
#define sk_CONF_VALUE_dup(st) SKM_sk_dup(CONF_VALUE, st)
#define sk_CONF_VALUE_pop_free(st, free_func) SKM_sk_pop_free(CONF_VALUE, (st), (free_func))
#define sk_CONF_VALUE_shift(st) SKM_sk_shift(CONF_VALUE, (st))
#define sk_CONF_VALUE_pop(st) SKM_sk_pop(CONF_VALUE, (st))
#define sk_CONF_VALUE_sort(st) SKM_sk_sort(CONF_VALUE, (st))
#define sk_CONF_VALUE_is_sorted(st) SKM_sk_is_sorted(CONF_VALUE, (st))

#define sk_CRYPTO_EX_DATA_FUNCS_new(cmp) SKM_sk_new(CRYPTO_EX_DATA_FUNCS, (cmp))
#define sk_CRYPTO_EX_DATA_FUNCS_new_null() SKM_sk_new_null(CRYPTO_EX_DATA_FUNCS)
#define sk_CRYPTO_EX_DATA_FUNCS_free(st) SKM_sk_free(CRYPTO_EX_DATA_FUNCS, (st))
#define sk_CRYPTO_EX_DATA_FUNCS_num(st) SKM_sk_num(CRYPTO_EX_DATA_FUNCS, (st))
#define sk_CRYPTO_EX_DATA_FUNCS_value(st, i) SKM_sk_value(CRYPTO_EX_DATA_FUNCS, (st), (i))
#define sk_CRYPTO_EX_DATA_FUNCS_set(st, i, val) SKM_sk_set(CRYPTO_EX_DATA_FUNCS, (st), (i), (val))
#define sk_CRYPTO_EX_DATA_FUNCS_zero(st) SKM_sk_zero(CRYPTO_EX_DATA_FUNCS, (st))
#define sk_CRYPTO_EX_DATA_FUNCS_push(st, val) SKM_sk_push(CRYPTO_EX_DATA_FUNCS, (st), (val))
#define sk_CRYPTO_EX_DATA_FUNCS_unshift(st, val) SKM_sk_unshift(CRYPTO_EX_DATA_FUNCS, (st), (val))
#define sk_CRYPTO_EX_DATA_FUNCS_find(st, val) SKM_sk_find(CRYPTO_EX_DATA_FUNCS, (st), (val))
#define sk_CRYPTO_EX_DATA_FUNCS_find_ex(st, val) SKM_sk_find_ex(CRYPTO_EX_DATA_FUNCS, (st), (val))
#define sk_CRYPTO_EX_DATA_FUNCS_delete(st, i) SKM_sk_delete(CRYPTO_EX_DATA_FUNCS, (st), (i))
#define sk_CRYPTO_EX_DATA_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_EX_DATA_FUNCS, (st), (ptr))
#define sk_CRYPTO_EX_DATA_FUNCS_insert(st, val, i) SKM_sk_insert(CRYPTO_EX_DATA_FUNCS, (st), (val), (i))
#define sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_EX_DATA_FUNCS, (st), (cmp))
#define sk_CRYPTO_EX_DATA_FUNCS_dup(st) SKM_sk_dup(CRYPTO_EX_DATA_FUNCS, st)
#define sk_CRYPTO_EX_DATA_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_EX_DATA_FUNCS, (st), (free_func))
#define sk_CRYPTO_EX_DATA_FUNCS_shift(st) SKM_sk_shift(CRYPTO_EX_DATA_FUNCS, (st))
#define sk_CRYPTO_EX_DATA_FUNCS_pop(st) SKM_sk_pop(CRYPTO_EX_DATA_FUNCS, (st))
#define sk_CRYPTO_EX_DATA_FUNCS_sort(st) SKM_sk_sort(CRYPTO_EX_DATA_FUNCS, (st))
#define sk_CRYPTO_EX_DATA_FUNCS_is_sorted(st) SKM_sk_is_sorted(CRYPTO_EX_DATA_FUNCS, (st))

#define sk_CRYPTO_dynlock_new(cmp) SKM_sk_new(CRYPTO_dynlock, (cmp))
#define sk_CRYPTO_dynlock_new_null() SKM_sk_new_null(CRYPTO_dynlock)
#define sk_CRYPTO_dynlock_free(st) SKM_sk_free(CRYPTO_dynlock, (st))
#define sk_CRYPTO_dynlock_num(st) SKM_sk_num(CRYPTO_dynlock, (st))
#define sk_CRYPTO_dynlock_value(st, i) SKM_sk_value(CRYPTO_dynlock, (st), (i))
#define sk_CRYPTO_dynlock_set(st, i, val) SKM_sk_set(CRYPTO_dynlock, (st), (i), (val))
#define sk_CRYPTO_dynlock_zero(st) SKM_sk_zero(CRYPTO_dynlock, (st))
#define sk_CRYPTO_dynlock_push(st, val) SKM_sk_push(CRYPTO_dynlock, (st), (val))
#define sk_CRYPTO_dynlock_unshift(st, val) SKM_sk_unshift(CRYPTO_dynlock, (st), (val))
#define sk_CRYPTO_dynlock_find(st, val) SKM_sk_find(CRYPTO_dynlock, (st), (val))
#define sk_CRYPTO_dynlock_find_ex(st, val) SKM_sk_find_ex(CRYPTO_dynlock, (st), (val))
#define sk_CRYPTO_dynlock_delete(st, i) SKM_sk_delete(CRYPTO_dynlock, (st), (i))
#define sk_CRYPTO_dynlock_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_dynlock, (st), (ptr))
#define sk_CRYPTO_dynlock_insert(st, val, i) SKM_sk_insert(CRYPTO_dynlock, (st), (val), (i))
#define sk_CRYPTO_dynlock_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_dynlock, (st), (cmp))
#define sk_CRYPTO_dynlock_dup(st) SKM_sk_dup(CRYPTO_dynlock, st)
#define sk_CRYPTO_dynlock_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_dynlock, (st), (free_func))
#define sk_CRYPTO_dynlock_shift(st) SKM_sk_shift(CRYPTO_dynlock, (st))
#define sk_CRYPTO_dynlock_pop(st) SKM_sk_pop(CRYPTO_dynlock, (st))
#define sk_CRYPTO_dynlock_sort(st) SKM_sk_sort(CRYPTO_dynlock, (st))
#define sk_CRYPTO_dynlock_is_sorted(st) SKM_sk_is_sorted(CRYPTO_dynlock, (st))

#define sk_DIST_POINT_new(cmp) SKM_sk_new(DIST_POINT, (cmp))
#define sk_DIST_POINT_new_null() SKM_sk_new_null(DIST_POINT)
#define sk_DIST_POINT_free(st) SKM_sk_free(DIST_POINT, (st))
#define sk_DIST_POINT_num(st) SKM_sk_num(DIST_POINT, (st))
#define sk_DIST_POINT_value(st, i) SKM_sk_value(DIST_POINT, (st), (i))
#define sk_DIST_POINT_set(st, i, val) SKM_sk_set(DIST_POINT, (st), (i), (val))
#define sk_DIST_POINT_zero(st) SKM_sk_zero(DIST_POINT, (st))
#define sk_DIST_POINT_push(st, val) SKM_sk_push(DIST_POINT, (st), (val))
#define sk_DIST_POINT_unshift(st, val) SKM_sk_unshift(DIST_POINT, (st), (val))
#define sk_DIST_POINT_find(st, val) SKM_sk_find(DIST_POINT, (st), (val))
#define sk_DIST_POINT_find_ex(st, val) SKM_sk_find_ex(DIST_POINT, (st), (val))
#define sk_DIST_POINT_delete(st, i) SKM_sk_delete(DIST_POINT, (st), (i))
#define sk_DIST_POINT_delete_ptr(st, ptr) SKM_sk_delete_ptr(DIST_POINT, (st), (ptr))
#define sk_DIST_POINT_insert(st, val, i) SKM_sk_insert(DIST_POINT, (st), (val), (i))
#define sk_DIST_POINT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(DIST_POINT, (st), (cmp))
#define sk_DIST_POINT_dup(st) SKM_sk_dup(DIST_POINT, st)
#define sk_DIST_POINT_pop_free(st, free_func) SKM_sk_pop_free(DIST_POINT, (st), (free_func))
#define sk_DIST_POINT_shift(st) SKM_sk_shift(DIST_POINT, (st))
#define sk_DIST_POINT_pop(st) SKM_sk_pop(DIST_POINT, (st))
#define sk_DIST_POINT_sort(st) SKM_sk_sort(DIST_POINT, (st))
#define sk_DIST_POINT_is_sorted(st) SKM_sk_is_sorted(DIST_POINT, (st))

#define sk_ENGINE_new(cmp) SKM_sk_new(ENGINE, (cmp))
#define sk_ENGINE_new_null() SKM_sk_new_null(ENGINE)
#define sk_ENGINE_free(st) SKM_sk_free(ENGINE, (st))
#define sk_ENGINE_num(st) SKM_sk_num(ENGINE, (st))
#define sk_ENGINE_value(st, i) SKM_sk_value(ENGINE, (st), (i))
#define sk_ENGINE_set(st, i, val) SKM_sk_set(ENGINE, (st), (i), (val))
#define sk_ENGINE_zero(st) SKM_sk_zero(ENGINE, (st))
#define sk_ENGINE_push(st, val) SKM_sk_push(ENGINE, (st), (val))
#define sk_ENGINE_unshift(st, val) SKM_sk_unshift(ENGINE, (st), (val))
#define sk_ENGINE_find(st, val) SKM_sk_find(ENGINE, (st), (val))
#define sk_ENGINE_find_ex(st, val) SKM_sk_find_ex(ENGINE, (st), (val))
#define sk_ENGINE_delete(st, i) SKM_sk_delete(ENGINE, (st), (i))
#define sk_ENGINE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE, (st), (ptr))
#define sk_ENGINE_insert(st, val, i) SKM_sk_insert(ENGINE, (st), (val), (i))
#define sk_ENGINE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE, (st), (cmp))
#define sk_ENGINE_dup(st) SKM_sk_dup(ENGINE, st)
#define sk_ENGINE_pop_free(st, free_func) SKM_sk_pop_free(ENGINE, (st), (free_func))
#define sk_ENGINE_shift(st) SKM_sk_shift(ENGINE, (st))
#define sk_ENGINE_pop(st) SKM_sk_pop(ENGINE, (st))
#define sk_ENGINE_sort(st) SKM_sk_sort(ENGINE, (st))
#define sk_ENGINE_is_sorted(st) SKM_sk_is_sorted(ENGINE, (st))

#define sk_ENGINE_CLEANUP_ITEM_new(cmp) SKM_sk_new(ENGINE_CLEANUP_ITEM, (cmp))
#define sk_ENGINE_CLEANUP_ITEM_new_null() SKM_sk_new_null(ENGINE_CLEANUP_ITEM)
#define sk_ENGINE_CLEANUP_ITEM_free(st) SKM_sk_free(ENGINE_CLEANUP_ITEM, (st))
#define sk_ENGINE_CLEANUP_ITEM_num(st) SKM_sk_num(ENGINE_CLEANUP_ITEM, (st))
#define sk_ENGINE_CLEANUP_ITEM_value(st, i) SKM_sk_value(ENGINE_CLEANUP_ITEM, (st), (i))
#define sk_ENGINE_CLEANUP_ITEM_set(st, i, val) SKM_sk_set(ENGINE_CLEANUP_ITEM, (st), (i), (val))
#define sk_ENGINE_CLEANUP_ITEM_zero(st) SKM_sk_zero(ENGINE_CLEANUP_ITEM, (st))
#define sk_ENGINE_CLEANUP_ITEM_push(st, val) SKM_sk_push(ENGINE_CLEANUP_ITEM, (st), (val))
#define sk_ENGINE_CLEANUP_ITEM_unshift(st, val) SKM_sk_unshift(ENGINE_CLEANUP_ITEM, (st), (val))
#define sk_ENGINE_CLEANUP_ITEM_find(st, val) SKM_sk_find(ENGINE_CLEANUP_ITEM, (st), (val))
#define sk_ENGINE_CLEANUP_ITEM_find_ex(st, val) SKM_sk_find_ex(ENGINE_CLEANUP_ITEM, (st), (val))
#define sk_ENGINE_CLEANUP_ITEM_delete(st, i) SKM_sk_delete(ENGINE_CLEANUP_ITEM, (st), (i))
#define sk_ENGINE_CLEANUP_ITEM_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE_CLEANUP_ITEM, (st), (ptr))
#define sk_ENGINE_CLEANUP_ITEM_insert(st, val, i) SKM_sk_insert(ENGINE_CLEANUP_ITEM, (st), (val), (i))
#define sk_ENGINE_CLEANUP_ITEM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE_CLEANUP_ITEM, (st), (cmp))
#define sk_ENGINE_CLEANUP_ITEM_dup(st) SKM_sk_dup(ENGINE_CLEANUP_ITEM, st)
#define sk_ENGINE_CLEANUP_ITEM_pop_free(st, free_func) SKM_sk_pop_free(ENGINE_CLEANUP_ITEM, (st), (free_func))
#define sk_ENGINE_CLEANUP_ITEM_shift(st) SKM_sk_shift(ENGINE_CLEANUP_ITEM, (st))
#define sk_ENGINE_CLEANUP_ITEM_pop(st) SKM_sk_pop(ENGINE_CLEANUP_ITEM, (st))
#define sk_ENGINE_CLEANUP_ITEM_sort(st) SKM_sk_sort(ENGINE_CLEANUP_ITEM, (st))
#define sk_ENGINE_CLEANUP_ITEM_is_sorted(st) SKM_sk_is_sorted(ENGINE_CLEANUP_ITEM, (st))

#define sk_ESS_CERT_ID_new(cmp) SKM_sk_new(ESS_CERT_ID, (cmp))
#define sk_ESS_CERT_ID_new_null() SKM_sk_new_null(ESS_CERT_ID)
#define sk_ESS_CERT_ID_free(st) SKM_sk_free(ESS_CERT_ID, (st))
#define sk_ESS_CERT_ID_num(st) SKM_sk_num(ESS_CERT_ID, (st))
#define sk_ESS_CERT_ID_value(st, i) SKM_sk_value(ESS_CERT_ID, (st), (i))
#define sk_ESS_CERT_ID_set(st, i, val) SKM_sk_set(ESS_CERT_ID, (st), (i), (val))
#define sk_ESS_CERT_ID_zero(st) SKM_sk_zero(ESS_CERT_ID, (st))
#define sk_ESS_CERT_ID_push(st, val) SKM_sk_push(ESS_CERT_ID, (st), (val))
#define sk_ESS_CERT_ID_unshift(st, val) SKM_sk_unshift(ESS_CERT_ID, (st), (val))
#define sk_ESS_CERT_ID_find(st, val) SKM_sk_find(ESS_CERT_ID, (st), (val))
#define sk_ESS_CERT_ID_find_ex(st, val) SKM_sk_find_ex(ESS_CERT_ID, (st), (val))
#define sk_ESS_CERT_ID_delete(st, i) SKM_sk_delete(ESS_CERT_ID, (st), (i))
#define sk_ESS_CERT_ID_delete_ptr(st, ptr) SKM_sk_delete_ptr(ESS_CERT_ID, (st), (ptr))
#define sk_ESS_CERT_ID_insert(st, val, i) SKM_sk_insert(ESS_CERT_ID, (st), (val), (i))
#define sk_ESS_CERT_ID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ESS_CERT_ID, (st), (cmp))
#define sk_ESS_CERT_ID_dup(st) SKM_sk_dup(ESS_CERT_ID, st)
#define sk_ESS_CERT_ID_pop_free(st, free_func) SKM_sk_pop_free(ESS_CERT_ID, (st), (free_func))
#define sk_ESS_CERT_ID_shift(st) SKM_sk_shift(ESS_CERT_ID, (st))
#define sk_ESS_CERT_ID_pop(st) SKM_sk_pop(ESS_CERT_ID, (st))
#define sk_ESS_CERT_ID_sort(st) SKM_sk_sort(ESS_CERT_ID, (st))
#define sk_ESS_CERT_ID_is_sorted(st) SKM_sk_is_sorted(ESS_CERT_ID, (st))

#define sk_EVP_MD_new(cmp) SKM_sk_new(EVP_MD, (cmp))
#define sk_EVP_MD_new_null() SKM_sk_new_null(EVP_MD)
#define sk_EVP_MD_free(st) SKM_sk_free(EVP_MD, (st))
#define sk_EVP_MD_num(st) SKM_sk_num(EVP_MD, (st))
#define sk_EVP_MD_value(st, i) SKM_sk_value(EVP_MD, (st), (i))
#define sk_EVP_MD_set(st, i, val) SKM_sk_set(EVP_MD, (st), (i), (val))
#define sk_EVP_MD_zero(st) SKM_sk_zero(EVP_MD, (st))
#define sk_EVP_MD_push(st, val) SKM_sk_push(EVP_MD, (st), (val))
#define sk_EVP_MD_unshift(st, val) SKM_sk_unshift(EVP_MD, (st), (val))
#define sk_EVP_MD_find(st, val) SKM_sk_find(EVP_MD, (st), (val))
#define sk_EVP_MD_find_ex(st, val) SKM_sk_find_ex(EVP_MD, (st), (val))
#define sk_EVP_MD_delete(st, i) SKM_sk_delete(EVP_MD, (st), (i))
#define sk_EVP_MD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_MD, (st), (ptr))
#define sk_EVP_MD_insert(st, val, i) SKM_sk_insert(EVP_MD, (st), (val), (i))
#define sk_EVP_MD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_MD, (st), (cmp))
#define sk_EVP_MD_dup(st) SKM_sk_dup(EVP_MD, st)
#define sk_EVP_MD_pop_free(st, free_func) SKM_sk_pop_free(EVP_MD, (st), (free_func))
#define sk_EVP_MD_shift(st) SKM_sk_shift(EVP_MD, (st))
#define sk_EVP_MD_pop(st) SKM_sk_pop(EVP_MD, (st))
#define sk_EVP_MD_sort(st) SKM_sk_sort(EVP_MD, (st))
#define sk_EVP_MD_is_sorted(st) SKM_sk_is_sorted(EVP_MD, (st))

#define sk_EVP_PBE_CTL_new(cmp) SKM_sk_new(EVP_PBE_CTL, (cmp))
#define sk_EVP_PBE_CTL_new_null() SKM_sk_new_null(EVP_PBE_CTL)
#define sk_EVP_PBE_CTL_free(st) SKM_sk_free(EVP_PBE_CTL, (st))
#define sk_EVP_PBE_CTL_num(st) SKM_sk_num(EVP_PBE_CTL, (st))
#define sk_EVP_PBE_CTL_value(st, i) SKM_sk_value(EVP_PBE_CTL, (st), (i))
#define sk_EVP_PBE_CTL_set(st, i, val) SKM_sk_set(EVP_PBE_CTL, (st), (i), (val))
#define sk_EVP_PBE_CTL_zero(st) SKM_sk_zero(EVP_PBE_CTL, (st))
#define sk_EVP_PBE_CTL_push(st, val) SKM_sk_push(EVP_PBE_CTL, (st), (val))
#define sk_EVP_PBE_CTL_unshift(st, val) SKM_sk_unshift(EVP_PBE_CTL, (st), (val))
#define sk_EVP_PBE_CTL_find(st, val) SKM_sk_find(EVP_PBE_CTL, (st), (val))
#define sk_EVP_PBE_CTL_find_ex(st, val) SKM_sk_find_ex(EVP_PBE_CTL, (st), (val))
#define sk_EVP_PBE_CTL_delete(st, i) SKM_sk_delete(EVP_PBE_CTL, (st), (i))
#define sk_EVP_PBE_CTL_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PBE_CTL, (st), (ptr))
#define sk_EVP_PBE_CTL_insert(st, val, i) SKM_sk_insert(EVP_PBE_CTL, (st), (val), (i))
#define sk_EVP_PBE_CTL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PBE_CTL, (st), (cmp))
#define sk_EVP_PBE_CTL_dup(st) SKM_sk_dup(EVP_PBE_CTL, st)
#define sk_EVP_PBE_CTL_pop_free(st, free_func) SKM_sk_pop_free(EVP_PBE_CTL, (st), (free_func))
#define sk_EVP_PBE_CTL_shift(st) SKM_sk_shift(EVP_PBE_CTL, (st))
#define sk_EVP_PBE_CTL_pop(st) SKM_sk_pop(EVP_PBE_CTL, (st))
#define sk_EVP_PBE_CTL_sort(st) SKM_sk_sort(EVP_PBE_CTL, (st))
#define sk_EVP_PBE_CTL_is_sorted(st) SKM_sk_is_sorted(EVP_PBE_CTL, (st))

#define sk_EVP_PKEY_ASN1_METHOD_new(cmp) SKM_sk_new(EVP_PKEY_ASN1_METHOD, (cmp))
#define sk_EVP_PKEY_ASN1_METHOD_new_null() SKM_sk_new_null(EVP_PKEY_ASN1_METHOD)
#define sk_EVP_PKEY_ASN1_METHOD_free(st) SKM_sk_free(EVP_PKEY_ASN1_METHOD, (st))
#define sk_EVP_PKEY_ASN1_METHOD_num(st) SKM_sk_num(EVP_PKEY_ASN1_METHOD, (st))
#define sk_EVP_PKEY_ASN1_METHOD_value(st, i) SKM_sk_value(EVP_PKEY_ASN1_METHOD, (st), (i))
#define sk_EVP_PKEY_ASN1_METHOD_set(st, i, val) SKM_sk_set(EVP_PKEY_ASN1_METHOD, (st), (i), (val))
#define sk_EVP_PKEY_ASN1_METHOD_zero(st) SKM_sk_zero(EVP_PKEY_ASN1_METHOD, (st))
#define sk_EVP_PKEY_ASN1_METHOD_push(st, val) SKM_sk_push(EVP_PKEY_ASN1_METHOD, (st), (val))
#define sk_EVP_PKEY_ASN1_METHOD_unshift(st, val) SKM_sk_unshift(EVP_PKEY_ASN1_METHOD, (st), (val))
#define sk_EVP_PKEY_ASN1_METHOD_find(st, val) SKM_sk_find(EVP_PKEY_ASN1_METHOD, (st), (val))
#define sk_EVP_PKEY_ASN1_METHOD_find_ex(st, val) SKM_sk_find_ex(EVP_PKEY_ASN1_METHOD, (st), (val))
#define sk_EVP_PKEY_ASN1_METHOD_delete(st, i) SKM_sk_delete(EVP_PKEY_ASN1_METHOD, (st), (i))
#define sk_EVP_PKEY_ASN1_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PKEY_ASN1_METHOD, (st), (ptr))
#define sk_EVP_PKEY_ASN1_METHOD_insert(st, val, i) SKM_sk_insert(EVP_PKEY_ASN1_METHOD, (st), (val), (i))
#define sk_EVP_PKEY_ASN1_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PKEY_ASN1_METHOD, (st), (cmp))
#define sk_EVP_PKEY_ASN1_METHOD_dup(st) SKM_sk_dup(EVP_PKEY_ASN1_METHOD, st)
#define sk_EVP_PKEY_ASN1_METHOD_pop_free(st, free_func) SKM_sk_pop_free(EVP_PKEY_ASN1_METHOD, (st), (free_func))
#define sk_EVP_PKEY_ASN1_METHOD_shift(st) SKM_sk_shift(EVP_PKEY_ASN1_METHOD, (st))
#define sk_EVP_PKEY_ASN1_METHOD_pop(st) SKM_sk_pop(EVP_PKEY_ASN1_METHOD, (st))
#define sk_EVP_PKEY_ASN1_METHOD_sort(st) SKM_sk_sort(EVP_PKEY_ASN1_METHOD, (st))
#define sk_EVP_PKEY_ASN1_METHOD_is_sorted(st) SKM_sk_is_sorted(EVP_PKEY_ASN1_METHOD, (st))

#define sk_EVP_PKEY_METHOD_new(cmp) SKM_sk_new(EVP_PKEY_METHOD, (cmp))
#define sk_EVP_PKEY_METHOD_new_null() SKM_sk_new_null(EVP_PKEY_METHOD)
#define sk_EVP_PKEY_METHOD_free(st) SKM_sk_free(EVP_PKEY_METHOD, (st))
#define sk_EVP_PKEY_METHOD_num(st) SKM_sk_num(EVP_PKEY_METHOD, (st))
#define sk_EVP_PKEY_METHOD_value(st, i) SKM_sk_value(EVP_PKEY_METHOD, (st), (i))
#define sk_EVP_PKEY_METHOD_set(st, i, val) SKM_sk_set(EVP_PKEY_METHOD, (st), (i), (val))
#define sk_EVP_PKEY_METHOD_zero(st) SKM_sk_zero(EVP_PKEY_METHOD, (st))
#define sk_EVP_PKEY_METHOD_push(st, val) SKM_sk_push(EVP_PKEY_METHOD, (st), (val))
#define sk_EVP_PKEY_METHOD_unshift(st, val) SKM_sk_unshift(EVP_PKEY_METHOD, (st), (val))
#define sk_EVP_PKEY_METHOD_find(st, val) SKM_sk_find(EVP_PKEY_METHOD, (st), (val))
#define sk_EVP_PKEY_METHOD_find_ex(st, val) SKM_sk_find_ex(EVP_PKEY_METHOD, (st), (val))
#define sk_EVP_PKEY_METHOD_delete(st, i) SKM_sk_delete(EVP_PKEY_METHOD, (st), (i))
#define sk_EVP_PKEY_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PKEY_METHOD, (st), (ptr))
#define sk_EVP_PKEY_METHOD_insert(st, val, i) SKM_sk_insert(EVP_PKEY_METHOD, (st), (val), (i))
#define sk_EVP_PKEY_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PKEY_METHOD, (st), (cmp))
#define sk_EVP_PKEY_METHOD_dup(st) SKM_sk_dup(EVP_PKEY_METHOD, st)
#define sk_EVP_PKEY_METHOD_pop_free(st, free_func) SKM_sk_pop_free(EVP_PKEY_METHOD, (st), (free_func))
#define sk_EVP_PKEY_METHOD_shift(st) SKM_sk_shift(EVP_PKEY_METHOD, (st))
#define sk_EVP_PKEY_METHOD_pop(st) SKM_sk_pop(EVP_PKEY_METHOD, (st))
#define sk_EVP_PKEY_METHOD_sort(st) SKM_sk_sort(EVP_PKEY_METHOD, (st))
#define sk_EVP_PKEY_METHOD_is_sorted(st) SKM_sk_is_sorted(EVP_PKEY_METHOD, (st))

#define sk_GENERAL_NAME_new(cmp) SKM_sk_new(GENERAL_NAME, (cmp))
#define sk_GENERAL_NAME_new_null() SKM_sk_new_null(GENERAL_NAME)
#define sk_GENERAL_NAME_free(st) SKM_sk_free(GENERAL_NAME, (st))
#define sk_GENERAL_NAME_num(st) SKM_sk_num(GENERAL_NAME, (st))
#define sk_GENERAL_NAME_value(st, i) SKM_sk_value(GENERAL_NAME, (st), (i))
#define sk_GENERAL_NAME_set(st, i, val) SKM_sk_set(GENERAL_NAME, (st), (i), (val))
#define sk_GENERAL_NAME_zero(st) SKM_sk_zero(GENERAL_NAME, (st))
#define sk_GENERAL_NAME_push(st, val) SKM_sk_push(GENERAL_NAME, (st), (val))
#define sk_GENERAL_NAME_unshift(st, val) SKM_sk_unshift(GENERAL_NAME, (st), (val))
#define sk_GENERAL_NAME_find(st, val) SKM_sk_find(GENERAL_NAME, (st), (val))
#define sk_GENERAL_NAME_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAME, (st), (val))
#define sk_GENERAL_NAME_delete(st, i) SKM_sk_delete(GENERAL_NAME, (st), (i))
#define sk_GENERAL_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAME, (st), (ptr))
#define sk_GENERAL_NAME_insert(st, val, i) SKM_sk_insert(GENERAL_NAME, (st), (val), (i))
#define sk_GENERAL_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAME, (st), (cmp))
#define sk_GENERAL_NAME_dup(st) SKM_sk_dup(GENERAL_NAME, st)
#define sk_GENERAL_NAME_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAME, (st), (free_func))
#define sk_GENERAL_NAME_shift(st) SKM_sk_shift(GENERAL_NAME, (st))
#define sk_GENERAL_NAME_pop(st) SKM_sk_pop(GENERAL_NAME, (st))
#define sk_GENERAL_NAME_sort(st) SKM_sk_sort(GENERAL_NAME, (st))
#define sk_GENERAL_NAME_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAME, (st))

#define sk_GENERAL_NAMES_new(cmp) SKM_sk_new(GENERAL_NAMES, (cmp))
#define sk_GENERAL_NAMES_new_null() SKM_sk_new_null(GENERAL_NAMES)
#define sk_GENERAL_NAMES_free(st) SKM_sk_free(GENERAL_NAMES, (st))
#define sk_GENERAL_NAMES_num(st) SKM_sk_num(GENERAL_NAMES, (st))
#define sk_GENERAL_NAMES_value(st, i) SKM_sk_value(GENERAL_NAMES, (st), (i))
#define sk_GENERAL_NAMES_set(st, i, val) SKM_sk_set(GENERAL_NAMES, (st), (i), (val))
#define sk_GENERAL_NAMES_zero(st) SKM_sk_zero(GENERAL_NAMES, (st))
#define sk_GENERAL_NAMES_push(st, val) SKM_sk_push(GENERAL_NAMES, (st), (val))
#define sk_GENERAL_NAMES_unshift(st, val) SKM_sk_unshift(GENERAL_NAMES, (st), (val))
#define sk_GENERAL_NAMES_find(st, val) SKM_sk_find(GENERAL_NAMES, (st), (val))
#define sk_GENERAL_NAMES_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAMES, (st), (val))
#define sk_GENERAL_NAMES_delete(st, i) SKM_sk_delete(GENERAL_NAMES, (st), (i))
#define sk_GENERAL_NAMES_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAMES, (st), (ptr))
#define sk_GENERAL_NAMES_insert(st, val, i) SKM_sk_insert(GENERAL_NAMES, (st), (val), (i))
#define sk_GENERAL_NAMES_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAMES, (st), (cmp))
#define sk_GENERAL_NAMES_dup(st) SKM_sk_dup(GENERAL_NAMES, st)
#define sk_GENERAL_NAMES_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAMES, (st), (free_func))
#define sk_GENERAL_NAMES_shift(st) SKM_sk_shift(GENERAL_NAMES, (st))
#define sk_GENERAL_NAMES_pop(st) SKM_sk_pop(GENERAL_NAMES, (st))
#define sk_GENERAL_NAMES_sort(st) SKM_sk_sort(GENERAL_NAMES, (st))
#define sk_GENERAL_NAMES_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAMES, (st))

#define sk_GENERAL_SUBTREE_new(cmp) SKM_sk_new(GENERAL_SUBTREE, (cmp))
#define sk_GENERAL_SUBTREE_new_null() SKM_sk_new_null(GENERAL_SUBTREE)
#define sk_GENERAL_SUBTREE_free(st) SKM_sk_free(GENERAL_SUBTREE, (st))
#define sk_GENERAL_SUBTREE_num(st) SKM_sk_num(GENERAL_SUBTREE, (st))
#define sk_GENERAL_SUBTREE_value(st, i) SKM_sk_value(GENERAL_SUBTREE, (st), (i))
#define sk_GENERAL_SUBTREE_set(st, i, val) SKM_sk_set(GENERAL_SUBTREE, (st), (i), (val))
#define sk_GENERAL_SUBTREE_zero(st) SKM_sk_zero(GENERAL_SUBTREE, (st))
#define sk_GENERAL_SUBTREE_push(st, val) SKM_sk_push(GENERAL_SUBTREE, (st), (val))
#define sk_GENERAL_SUBTREE_unshift(st, val) SKM_sk_unshift(GENERAL_SUBTREE, (st), (val))
#define sk_GENERAL_SUBTREE_find(st, val) SKM_sk_find(GENERAL_SUBTREE, (st), (val))
#define sk_GENERAL_SUBTREE_find_ex(st, val) SKM_sk_find_ex(GENERAL_SUBTREE, (st), (val))
#define sk_GENERAL_SUBTREE_delete(st, i) SKM_sk_delete(GENERAL_SUBTREE, (st), (i))
#define sk_GENERAL_SUBTREE_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_SUBTREE, (st), (ptr))
#define sk_GENERAL_SUBTREE_insert(st, val, i) SKM_sk_insert(GENERAL_SUBTREE, (st), (val), (i))
#define sk_GENERAL_SUBTREE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_SUBTREE, (st), (cmp))
#define sk_GENERAL_SUBTREE_dup(st) SKM_sk_dup(GENERAL_SUBTREE, st)
#define sk_GENERAL_SUBTREE_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_SUBTREE, (st), (free_func))
#define sk_GENERAL_SUBTREE_shift(st) SKM_sk_shift(GENERAL_SUBTREE, (st))
#define sk_GENERAL_SUBTREE_pop(st) SKM_sk_pop(GENERAL_SUBTREE, (st))
#define sk_GENERAL_SUBTREE_sort(st) SKM_sk_sort(GENERAL_SUBTREE, (st))
#define sk_GENERAL_SUBTREE_is_sorted(st) SKM_sk_is_sorted(GENERAL_SUBTREE, (st))

#define sk_IPAddressFamily_new(cmp) SKM_sk_new(IPAddressFamily, (cmp))
#define sk_IPAddressFamily_new_null() SKM_sk_new_null(IPAddressFamily)
#define sk_IPAddressFamily_free(st) SKM_sk_free(IPAddressFamily, (st))
#define sk_IPAddressFamily_num(st) SKM_sk_num(IPAddressFamily, (st))
#define sk_IPAddressFamily_value(st, i) SKM_sk_value(IPAddressFamily, (st), (i))
#define sk_IPAddressFamily_set(st, i, val) SKM_sk_set(IPAddressFamily, (st), (i), (val))
#define sk_IPAddressFamily_zero(st) SKM_sk_zero(IPAddressFamily, (st))
#define sk_IPAddressFamily_push(st, val) SKM_sk_push(IPAddressFamily, (st), (val))
#define sk_IPAddressFamily_unshift(st, val) SKM_sk_unshift(IPAddressFamily, (st), (val))
#define sk_IPAddressFamily_find(st, val) SKM_sk_find(IPAddressFamily, (st), (val))
#define sk_IPAddressFamily_find_ex(st, val) SKM_sk_find_ex(IPAddressFamily, (st), (val))
#define sk_IPAddressFamily_delete(st, i) SKM_sk_delete(IPAddressFamily, (st), (i))
#define sk_IPAddressFamily_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressFamily, (st), (ptr))
#define sk_IPAddressFamily_insert(st, val, i) SKM_sk_insert(IPAddressFamily, (st), (val), (i))
#define sk_IPAddressFamily_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressFamily, (st), (cmp))
#define sk_IPAddressFamily_dup(st) SKM_sk_dup(IPAddressFamily, st)
#define sk_IPAddressFamily_pop_free(st, free_func) SKM_sk_pop_free(IPAddressFamily, (st), (free_func))
#define sk_IPAddressFamily_shift(st) SKM_sk_shift(IPAddressFamily, (st))
#define sk_IPAddressFamily_pop(st) SKM_sk_pop(IPAddressFamily, (st))
#define sk_IPAddressFamily_sort(st) SKM_sk_sort(IPAddressFamily, (st))
#define sk_IPAddressFamily_is_sorted(st) SKM_sk_is_sorted(IPAddressFamily, (st))

#define sk_IPAddressOrRange_new(cmp) SKM_sk_new(IPAddressOrRange, (cmp))
#define sk_IPAddressOrRange_new_null() SKM_sk_new_null(IPAddressOrRange)
#define sk_IPAddressOrRange_free(st) SKM_sk_free(IPAddressOrRange, (st))
#define sk_IPAddressOrRange_num(st) SKM_sk_num(IPAddressOrRange, (st))
#define sk_IPAddressOrRange_value(st, i) SKM_sk_value(IPAddressOrRange, (st), (i))
#define sk_IPAddressOrRange_set(st, i, val) SKM_sk_set(IPAddressOrRange, (st), (i), (val))
#define sk_IPAddressOrRange_zero(st) SKM_sk_zero(IPAddressOrRange, (st))
#define sk_IPAddressOrRange_push(st, val) SKM_sk_push(IPAddressOrRange, (st), (val))
#define sk_IPAddressOrRange_unshift(st, val) SKM_sk_unshift(IPAddressOrRange, (st), (val))
#define sk_IPAddressOrRange_find(st, val) SKM_sk_find(IPAddressOrRange, (st), (val))
#define sk_IPAddressOrRange_find_ex(st, val) SKM_sk_find_ex(IPAddressOrRange, (st), (val))
#define sk_IPAddressOrRange_delete(st, i) SKM_sk_delete(IPAddressOrRange, (st), (i))
#define sk_IPAddressOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressOrRange, (st), (ptr))
#define sk_IPAddressOrRange_insert(st, val, i) SKM_sk_insert(IPAddressOrRange, (st), (val), (i))
#define sk_IPAddressOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressOrRange, (st), (cmp))
#define sk_IPAddressOrRange_dup(st) SKM_sk_dup(IPAddressOrRange, st)
#define sk_IPAddressOrRange_pop_free(st, free_func) SKM_sk_pop_free(IPAddressOrRange, (st), (free_func))
#define sk_IPAddressOrRange_shift(st) SKM_sk_shift(IPAddressOrRange, (st))
#define sk_IPAddressOrRange_pop(st) SKM_sk_pop(IPAddressOrRange, (st))
#define sk_IPAddressOrRange_sort(st) SKM_sk_sort(IPAddressOrRange, (st))
#define sk_IPAddressOrRange_is_sorted(st) SKM_sk_is_sorted(IPAddressOrRange, (st))

#define sk_KRB5_APREQBODY_new(cmp) SKM_sk_new(KRB5_APREQBODY, (cmp))
#define sk_KRB5_APREQBODY_new_null() SKM_sk_new_null(KRB5_APREQBODY)
#define sk_KRB5_APREQBODY_free(st) SKM_sk_free(KRB5_APREQBODY, (st))
#define sk_KRB5_APREQBODY_num(st) SKM_sk_num(KRB5_APREQBODY, (st))
#define sk_KRB5_APREQBODY_value(st, i) SKM_sk_value(KRB5_APREQBODY, (st), (i))
#define sk_KRB5_APREQBODY_set(st, i, val) SKM_sk_set(KRB5_APREQBODY, (st), (i), (val))
#define sk_KRB5_APREQBODY_zero(st) SKM_sk_zero(KRB5_APREQBODY, (st))
#define sk_KRB5_APREQBODY_push(st, val) SKM_sk_push(KRB5_APREQBODY, (st), (val))
#define sk_KRB5_APREQBODY_unshift(st, val) SKM_sk_unshift(KRB5_APREQBODY, (st), (val))
#define sk_KRB5_APREQBODY_find(st, val) SKM_sk_find(KRB5_APREQBODY, (st), (val))
#define sk_KRB5_APREQBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_APREQBODY, (st), (val))
#define sk_KRB5_APREQBODY_delete(st, i) SKM_sk_delete(KRB5_APREQBODY, (st), (i))
#define sk_KRB5_APREQBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_APREQBODY, (st), (ptr))
#define sk_KRB5_APREQBODY_insert(st, val, i) SKM_sk_insert(KRB5_APREQBODY, (st), (val), (i))
#define sk_KRB5_APREQBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_APREQBODY, (st), (cmp))
#define sk_KRB5_APREQBODY_dup(st) SKM_sk_dup(KRB5_APREQBODY, st)
#define sk_KRB5_APREQBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_APREQBODY, (st), (free_func))
#define sk_KRB5_APREQBODY_shift(st) SKM_sk_shift(KRB5_APREQBODY, (st))
#define sk_KRB5_APREQBODY_pop(st) SKM_sk_pop(KRB5_APREQBODY, (st))
#define sk_KRB5_APREQBODY_sort(st) SKM_sk_sort(KRB5_APREQBODY, (st))
#define sk_KRB5_APREQBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_APREQBODY, (st))

#define sk_KRB5_AUTHDATA_new(cmp) SKM_sk_new(KRB5_AUTHDATA, (cmp))
#define sk_KRB5_AUTHDATA_new_null() SKM_sk_new_null(KRB5_AUTHDATA)
#define sk_KRB5_AUTHDATA_free(st) SKM_sk_free(KRB5_AUTHDATA, (st))
#define sk_KRB5_AUTHDATA_num(st) SKM_sk_num(KRB5_AUTHDATA, (st))
#define sk_KRB5_AUTHDATA_value(st, i) SKM_sk_value(KRB5_AUTHDATA, (st), (i))
#define sk_KRB5_AUTHDATA_set(st, i, val) SKM_sk_set(KRB5_AUTHDATA, (st), (i), (val))
#define sk_KRB5_AUTHDATA_zero(st) SKM_sk_zero(KRB5_AUTHDATA, (st))
#define sk_KRB5_AUTHDATA_push(st, val) SKM_sk_push(KRB5_AUTHDATA, (st), (val))
#define sk_KRB5_AUTHDATA_unshift(st, val) SKM_sk_unshift(KRB5_AUTHDATA, (st), (val))
#define sk_KRB5_AUTHDATA_find(st, val) SKM_sk_find(KRB5_AUTHDATA, (st), (val))
#define sk_KRB5_AUTHDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHDATA, (st), (val))
#define sk_KRB5_AUTHDATA_delete(st, i) SKM_sk_delete(KRB5_AUTHDATA, (st), (i))
#define sk_KRB5_AUTHDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHDATA, (st), (ptr))
#define sk_KRB5_AUTHDATA_insert(st, val, i) SKM_sk_insert(KRB5_AUTHDATA, (st), (val), (i))
#define sk_KRB5_AUTHDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHDATA, (st), (cmp))
#define sk_KRB5_AUTHDATA_dup(st) SKM_sk_dup(KRB5_AUTHDATA, st)
#define sk_KRB5_AUTHDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHDATA, (st), (free_func))
#define sk_KRB5_AUTHDATA_shift(st) SKM_sk_shift(KRB5_AUTHDATA, (st))
#define sk_KRB5_AUTHDATA_pop(st) SKM_sk_pop(KRB5_AUTHDATA, (st))
#define sk_KRB5_AUTHDATA_sort(st) SKM_sk_sort(KRB5_AUTHDATA, (st))
#define sk_KRB5_AUTHDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHDATA, (st))

#define sk_KRB5_AUTHENTBODY_new(cmp) SKM_sk_new(KRB5_AUTHENTBODY, (cmp))
#define sk_KRB5_AUTHENTBODY_new_null() SKM_sk_new_null(KRB5_AUTHENTBODY)
#define sk_KRB5_AUTHENTBODY_free(st) SKM_sk_free(KRB5_AUTHENTBODY, (st))
#define sk_KRB5_AUTHENTBODY_num(st) SKM_sk_num(KRB5_AUTHENTBODY, (st))
#define sk_KRB5_AUTHENTBODY_value(st, i) SKM_sk_value(KRB5_AUTHENTBODY, (st), (i))
#define sk_KRB5_AUTHENTBODY_set(st, i, val) SKM_sk_set(KRB5_AUTHENTBODY, (st), (i), (val))
#define sk_KRB5_AUTHENTBODY_zero(st) SKM_sk_zero(KRB5_AUTHENTBODY, (st))
#define sk_KRB5_AUTHENTBODY_push(st, val) SKM_sk_push(KRB5_AUTHENTBODY, (st), (val))
#define sk_KRB5_AUTHENTBODY_unshift(st, val) SKM_sk_unshift(KRB5_AUTHENTBODY, (st), (val))
#define sk_KRB5_AUTHENTBODY_find(st, val) SKM_sk_find(KRB5_AUTHENTBODY, (st), (val))
#define sk_KRB5_AUTHENTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHENTBODY, (st), (val))
#define sk_KRB5_AUTHENTBODY_delete(st, i) SKM_sk_delete(KRB5_AUTHENTBODY, (st), (i))
#define sk_KRB5_AUTHENTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHENTBODY, (st), (ptr))
#define sk_KRB5_AUTHENTBODY_insert(st, val, i) SKM_sk_insert(KRB5_AUTHENTBODY, (st), (val), (i))
#define sk_KRB5_AUTHENTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHENTBODY, (st), (cmp))
#define sk_KRB5_AUTHENTBODY_dup(st) SKM_sk_dup(KRB5_AUTHENTBODY, st)
#define sk_KRB5_AUTHENTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHENTBODY, (st), (free_func))
#define sk_KRB5_AUTHENTBODY_shift(st) SKM_sk_shift(KRB5_AUTHENTBODY, (st))
#define sk_KRB5_AUTHENTBODY_pop(st) SKM_sk_pop(KRB5_AUTHENTBODY, (st))
#define sk_KRB5_AUTHENTBODY_sort(st) SKM_sk_sort(KRB5_AUTHENTBODY, (st))
#define sk_KRB5_AUTHENTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHENTBODY, (st))

#define sk_KRB5_CHECKSUM_new(cmp) SKM_sk_new(KRB5_CHECKSUM, (cmp))
#define sk_KRB5_CHECKSUM_new_null() SKM_sk_new_null(KRB5_CHECKSUM)
#define sk_KRB5_CHECKSUM_free(st) SKM_sk_free(KRB5_CHECKSUM, (st))
#define sk_KRB5_CHECKSUM_num(st) SKM_sk_num(KRB5_CHECKSUM, (st))
#define sk_KRB5_CHECKSUM_value(st, i) SKM_sk_value(KRB5_CHECKSUM, (st), (i))
#define sk_KRB5_CHECKSUM_set(st, i, val) SKM_sk_set(KRB5_CHECKSUM, (st), (i), (val))
#define sk_KRB5_CHECKSUM_zero(st) SKM_sk_zero(KRB5_CHECKSUM, (st))
#define sk_KRB5_CHECKSUM_push(st, val) SKM_sk_push(KRB5_CHECKSUM, (st), (val))
#define sk_KRB5_CHECKSUM_unshift(st, val) SKM_sk_unshift(KRB5_CHECKSUM, (st), (val))
#define sk_KRB5_CHECKSUM_find(st, val) SKM_sk_find(KRB5_CHECKSUM, (st), (val))
#define sk_KRB5_CHECKSUM_find_ex(st, val) SKM_sk_find_ex(KRB5_CHECKSUM, (st), (val))
#define sk_KRB5_CHECKSUM_delete(st, i) SKM_sk_delete(KRB5_CHECKSUM, (st), (i))
#define sk_KRB5_CHECKSUM_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_CHECKSUM, (st), (ptr))
#define sk_KRB5_CHECKSUM_insert(st, val, i) SKM_sk_insert(KRB5_CHECKSUM, (st), (val), (i))
#define sk_KRB5_CHECKSUM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_CHECKSUM, (st), (cmp))
#define sk_KRB5_CHECKSUM_dup(st) SKM_sk_dup(KRB5_CHECKSUM, st)
#define sk_KRB5_CHECKSUM_pop_free(st, free_func) SKM_sk_pop_free(KRB5_CHECKSUM, (st), (free_func))
#define sk_KRB5_CHECKSUM_shift(st) SKM_sk_shift(KRB5_CHECKSUM, (st))
#define sk_KRB5_CHECKSUM_pop(st) SKM_sk_pop(KRB5_CHECKSUM, (st))
#define sk_KRB5_CHECKSUM_sort(st) SKM_sk_sort(KRB5_CHECKSUM, (st))
#define sk_KRB5_CHECKSUM_is_sorted(st) SKM_sk_is_sorted(KRB5_CHECKSUM, (st))

#define sk_KRB5_ENCDATA_new(cmp) SKM_sk_new(KRB5_ENCDATA, (cmp))
#define sk_KRB5_ENCDATA_new_null() SKM_sk_new_null(KRB5_ENCDATA)
#define sk_KRB5_ENCDATA_free(st) SKM_sk_free(KRB5_ENCDATA, (st))
#define sk_KRB5_ENCDATA_num(st) SKM_sk_num(KRB5_ENCDATA, (st))
#define sk_KRB5_ENCDATA_value(st, i) SKM_sk_value(KRB5_ENCDATA, (st), (i))
#define sk_KRB5_ENCDATA_set(st, i, val) SKM_sk_set(KRB5_ENCDATA, (st), (i), (val))
#define sk_KRB5_ENCDATA_zero(st) SKM_sk_zero(KRB5_ENCDATA, (st))
#define sk_KRB5_ENCDATA_push(st, val) SKM_sk_push(KRB5_ENCDATA, (st), (val))
#define sk_KRB5_ENCDATA_unshift(st, val) SKM_sk_unshift(KRB5_ENCDATA, (st), (val))
#define sk_KRB5_ENCDATA_find(st, val) SKM_sk_find(KRB5_ENCDATA, (st), (val))
#define sk_KRB5_ENCDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCDATA, (st), (val))
#define sk_KRB5_ENCDATA_delete(st, i) SKM_sk_delete(KRB5_ENCDATA, (st), (i))
#define sk_KRB5_ENCDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCDATA, (st), (ptr))
#define sk_KRB5_ENCDATA_insert(st, val, i) SKM_sk_insert(KRB5_ENCDATA, (st), (val), (i))
#define sk_KRB5_ENCDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCDATA, (st), (cmp))
#define sk_KRB5_ENCDATA_dup(st) SKM_sk_dup(KRB5_ENCDATA, st)
#define sk_KRB5_ENCDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCDATA, (st), (free_func))
#define sk_KRB5_ENCDATA_shift(st) SKM_sk_shift(KRB5_ENCDATA, (st))
#define sk_KRB5_ENCDATA_pop(st) SKM_sk_pop(KRB5_ENCDATA, (st))
#define sk_KRB5_ENCDATA_sort(st) SKM_sk_sort(KRB5_ENCDATA, (st))
#define sk_KRB5_ENCDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCDATA, (st))

#define sk_KRB5_ENCKEY_new(cmp) SKM_sk_new(KRB5_ENCKEY, (cmp))
#define sk_KRB5_ENCKEY_new_null() SKM_sk_new_null(KRB5_ENCKEY)
#define sk_KRB5_ENCKEY_free(st) SKM_sk_free(KRB5_ENCKEY, (st))
#define sk_KRB5_ENCKEY_num(st) SKM_sk_num(KRB5_ENCKEY, (st))
#define sk_KRB5_ENCKEY_value(st, i) SKM_sk_value(KRB5_ENCKEY, (st), (i))
#define sk_KRB5_ENCKEY_set(st, i, val) SKM_sk_set(KRB5_ENCKEY, (st), (i), (val))
#define sk_KRB5_ENCKEY_zero(st) SKM_sk_zero(KRB5_ENCKEY, (st))
#define sk_KRB5_ENCKEY_push(st, val) SKM_sk_push(KRB5_ENCKEY, (st), (val))
#define sk_KRB5_ENCKEY_unshift(st, val) SKM_sk_unshift(KRB5_ENCKEY, (st), (val))
#define sk_KRB5_ENCKEY_find(st, val) SKM_sk_find(KRB5_ENCKEY, (st), (val))
#define sk_KRB5_ENCKEY_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCKEY, (st), (val))
#define sk_KRB5_ENCKEY_delete(st, i) SKM_sk_delete(KRB5_ENCKEY, (st), (i))
#define sk_KRB5_ENCKEY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCKEY, (st), (ptr))
#define sk_KRB5_ENCKEY_insert(st, val, i) SKM_sk_insert(KRB5_ENCKEY, (st), (val), (i))
#define sk_KRB5_ENCKEY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCKEY, (st), (cmp))
#define sk_KRB5_ENCKEY_dup(st) SKM_sk_dup(KRB5_ENCKEY, st)
#define sk_KRB5_ENCKEY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCKEY, (st), (free_func))
#define sk_KRB5_ENCKEY_shift(st) SKM_sk_shift(KRB5_ENCKEY, (st))
#define sk_KRB5_ENCKEY_pop(st) SKM_sk_pop(KRB5_ENCKEY, (st))
#define sk_KRB5_ENCKEY_sort(st) SKM_sk_sort(KRB5_ENCKEY, (st))
#define sk_KRB5_ENCKEY_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCKEY, (st))

#define sk_KRB5_PRINCNAME_new(cmp) SKM_sk_new(KRB5_PRINCNAME, (cmp))
#define sk_KRB5_PRINCNAME_new_null() SKM_sk_new_null(KRB5_PRINCNAME)
#define sk_KRB5_PRINCNAME_free(st) SKM_sk_free(KRB5_PRINCNAME, (st))
#define sk_KRB5_PRINCNAME_num(st) SKM_sk_num(KRB5_PRINCNAME, (st))
#define sk_KRB5_PRINCNAME_value(st, i) SKM_sk_value(KRB5_PRINCNAME, (st), (i))
#define sk_KRB5_PRINCNAME_set(st, i, val) SKM_sk_set(KRB5_PRINCNAME, (st), (i), (val))
#define sk_KRB5_PRINCNAME_zero(st) SKM_sk_zero(KRB5_PRINCNAME, (st))
#define sk_KRB5_PRINCNAME_push(st, val) SKM_sk_push(KRB5_PRINCNAME, (st), (val))
#define sk_KRB5_PRINCNAME_unshift(st, val) SKM_sk_unshift(KRB5_PRINCNAME, (st), (val))
#define sk_KRB5_PRINCNAME_find(st, val) SKM_sk_find(KRB5_PRINCNAME, (st), (val))
#define sk_KRB5_PRINCNAME_find_ex(st, val) SKM_sk_find_ex(KRB5_PRINCNAME, (st), (val))
#define sk_KRB5_PRINCNAME_delete(st, i) SKM_sk_delete(KRB5_PRINCNAME, (st), (i))
#define sk_KRB5_PRINCNAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_PRINCNAME, (st), (ptr))
#define sk_KRB5_PRINCNAME_insert(st, val, i) SKM_sk_insert(KRB5_PRINCNAME, (st), (val), (i))
#define sk_KRB5_PRINCNAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_PRINCNAME, (st), (cmp))
#define sk_KRB5_PRINCNAME_dup(st) SKM_sk_dup(KRB5_PRINCNAME, st)
#define sk_KRB5_PRINCNAME_pop_free(st, free_func) SKM_sk_pop_free(KRB5_PRINCNAME, (st), (free_func))
#define sk_KRB5_PRINCNAME_shift(st) SKM_sk_shift(KRB5_PRINCNAME, (st))
#define sk_KRB5_PRINCNAME_pop(st) SKM_sk_pop(KRB5_PRINCNAME, (st))
#define sk_KRB5_PRINCNAME_sort(st) SKM_sk_sort(KRB5_PRINCNAME, (st))
#define sk_KRB5_PRINCNAME_is_sorted(st) SKM_sk_is_sorted(KRB5_PRINCNAME, (st))

#define sk_KRB5_TKTBODY_new(cmp) SKM_sk_new(KRB5_TKTBODY, (cmp))
#define sk_KRB5_TKTBODY_new_null() SKM_sk_new_null(KRB5_TKTBODY)
#define sk_KRB5_TKTBODY_free(st) SKM_sk_free(KRB5_TKTBODY, (st))
#define sk_KRB5_TKTBODY_num(st) SKM_sk_num(KRB5_TKTBODY, (st))
#define sk_KRB5_TKTBODY_value(st, i) SKM_sk_value(KRB5_TKTBODY, (st), (i))
#define sk_KRB5_TKTBODY_set(st, i, val) SKM_sk_set(KRB5_TKTBODY, (st), (i), (val))
#define sk_KRB5_TKTBODY_zero(st) SKM_sk_zero(KRB5_TKTBODY, (st))
#define sk_KRB5_TKTBODY_push(st, val) SKM_sk_push(KRB5_TKTBODY, (st), (val))
#define sk_KRB5_TKTBODY_unshift(st, val) SKM_sk_unshift(KRB5_TKTBODY, (st), (val))
#define sk_KRB5_TKTBODY_find(st, val) SKM_sk_find(KRB5_TKTBODY, (st), (val))
#define sk_KRB5_TKTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_TKTBODY, (st), (val))
#define sk_KRB5_TKTBODY_delete(st, i) SKM_sk_delete(KRB5_TKTBODY, (st), (i))
#define sk_KRB5_TKTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_TKTBODY, (st), (ptr))
#define sk_KRB5_TKTBODY_insert(st, val, i) SKM_sk_insert(KRB5_TKTBODY, (st), (val), (i))
#define sk_KRB5_TKTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_TKTBODY, (st), (cmp))
#define sk_KRB5_TKTBODY_dup(st) SKM_sk_dup(KRB5_TKTBODY, st)
#define sk_KRB5_TKTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_TKTBODY, (st), (free_func))
#define sk_KRB5_TKTBODY_shift(st) SKM_sk_shift(KRB5_TKTBODY, (st))
#define sk_KRB5_TKTBODY_pop(st) SKM_sk_pop(KRB5_TKTBODY, (st))
#define sk_KRB5_TKTBODY_sort(st) SKM_sk_sort(KRB5_TKTBODY, (st))
#define sk_KRB5_TKTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_TKTBODY, (st))

#define sk_MEM_OBJECT_DATA_new(cmp) SKM_sk_new(MEM_OBJECT_DATA, (cmp))
#define sk_MEM_OBJECT_DATA_new_null() SKM_sk_new_null(MEM_OBJECT_DATA)
#define sk_MEM_OBJECT_DATA_free(st) SKM_sk_free(MEM_OBJECT_DATA, (st))
#define sk_MEM_OBJECT_DATA_num(st) SKM_sk_num(MEM_OBJECT_DATA, (st))
#define sk_MEM_OBJECT_DATA_value(st, i) SKM_sk_value(MEM_OBJECT_DATA, (st), (i))
#define sk_MEM_OBJECT_DATA_set(st, i, val) SKM_sk_set(MEM_OBJECT_DATA, (st), (i), (val))
#define sk_MEM_OBJECT_DATA_zero(st) SKM_sk_zero(MEM_OBJECT_DATA, (st))
#define sk_MEM_OBJECT_DATA_push(st, val) SKM_sk_push(MEM_OBJECT_DATA, (st), (val))
#define sk_MEM_OBJECT_DATA_unshift(st, val) SKM_sk_unshift(MEM_OBJECT_DATA, (st), (val))
#define sk_MEM_OBJECT_DATA_find(st, val) SKM_sk_find(MEM_OBJECT_DATA, (st), (val))
#define sk_MEM_OBJECT_DATA_find_ex(st, val) SKM_sk_find_ex(MEM_OBJECT_DATA, (st), (val))
#define sk_MEM_OBJECT_DATA_delete(st, i) SKM_sk_delete(MEM_OBJECT_DATA, (st), (i))
#define sk_MEM_OBJECT_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(MEM_OBJECT_DATA, (st), (ptr))
#define sk_MEM_OBJECT_DATA_insert(st, val, i) SKM_sk_insert(MEM_OBJECT_DATA, (st), (val), (i))
#define sk_MEM_OBJECT_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MEM_OBJECT_DATA, (st), (cmp))
#define sk_MEM_OBJECT_DATA_dup(st) SKM_sk_dup(MEM_OBJECT_DATA, st)
#define sk_MEM_OBJECT_DATA_pop_free(st, free_func) SKM_sk_pop_free(MEM_OBJECT_DATA, (st), (free_func))
#define sk_MEM_OBJECT_DATA_shift(st) SKM_sk_shift(MEM_OBJECT_DATA, (st))
#define sk_MEM_OBJECT_DATA_pop(st) SKM_sk_pop(MEM_OBJECT_DATA, (st))
#define sk_MEM_OBJECT_DATA_sort(st) SKM_sk_sort(MEM_OBJECT_DATA, (st))
#define sk_MEM_OBJECT_DATA_is_sorted(st) SKM_sk_is_sorted(MEM_OBJECT_DATA, (st))

#define sk_MIME_HEADER_new(cmp) SKM_sk_new(MIME_HEADER, (cmp))
#define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER)
#define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st))
#define sk_MIME_HEADER_num(st) SKM_sk_num(MIME_HEADER, (st))
#define sk_MIME_HEADER_value(st, i) SKM_sk_value(MIME_HEADER, (st), (i))
#define sk_MIME_HEADER_set(st, i, val) SKM_sk_set(MIME_HEADER, (st), (i), (val))
#define sk_MIME_HEADER_zero(st) SKM_sk_zero(MIME_HEADER, (st))
#define sk_MIME_HEADER_push(st, val) SKM_sk_push(MIME_HEADER, (st), (val))
#define sk_MIME_HEADER_unshift(st, val) SKM_sk_unshift(MIME_HEADER, (st), (val))
#define sk_MIME_HEADER_find(st, val) SKM_sk_find(MIME_HEADER, (st), (val))
#define sk_MIME_HEADER_find_ex(st, val) SKM_sk_find_ex(MIME_HEADER, (st), (val))
#define sk_MIME_HEADER_delete(st, i) SKM_sk_delete(MIME_HEADER, (st), (i))
#define sk_MIME_HEADER_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_HEADER, (st), (ptr))
#define sk_MIME_HEADER_insert(st, val, i) SKM_sk_insert(MIME_HEADER, (st), (val), (i))
#define sk_MIME_HEADER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_HEADER, (st), (cmp))
#define sk_MIME_HEADER_dup(st) SKM_sk_dup(MIME_HEADER, st)
#define sk_MIME_HEADER_pop_free(st, free_func) SKM_sk_pop_free(MIME_HEADER, (st), (free_func))
#define sk_MIME_HEADER_shift(st) SKM_sk_shift(MIME_HEADER, (st))
#define sk_MIME_HEADER_pop(st) SKM_sk_pop(MIME_HEADER, (st))
#define sk_MIME_HEADER_sort(st) SKM_sk_sort(MIME_HEADER, (st))
#define sk_MIME_HEADER_is_sorted(st) SKM_sk_is_sorted(MIME_HEADER, (st))

#define sk_MIME_PARAM_new(cmp) SKM_sk_new(MIME_PARAM, (cmp))
#define sk_MIME_PARAM_new_null() SKM_sk_new_null(MIME_PARAM)
#define sk_MIME_PARAM_free(st) SKM_sk_free(MIME_PARAM, (st))
#define sk_MIME_PARAM_num(st) SKM_sk_num(MIME_PARAM, (st))
#define sk_MIME_PARAM_value(st, i) SKM_sk_value(MIME_PARAM, (st), (i))
#define sk_MIME_PARAM_set(st, i, val) SKM_sk_set(MIME_PARAM, (st), (i), (val))
#define sk_MIME_PARAM_zero(st) SKM_sk_zero(MIME_PARAM, (st))
#define sk_MIME_PARAM_push(st, val) SKM_sk_push(MIME_PARAM, (st), (val))
#define sk_MIME_PARAM_unshift(st, val) SKM_sk_unshift(MIME_PARAM, (st), (val))
#define sk_MIME_PARAM_find(st, val) SKM_sk_find(MIME_PARAM, (st), (val))
#define sk_MIME_PARAM_find_ex(st, val) SKM_sk_find_ex(MIME_PARAM, (st), (val))
#define sk_MIME_PARAM_delete(st, i) SKM_sk_delete(MIME_PARAM, (st), (i))
#define sk_MIME_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_PARAM, (st), (ptr))
#define sk_MIME_PARAM_insert(st, val, i) SKM_sk_insert(MIME_PARAM, (st), (val), (i))
#define sk_MIME_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_PARAM, (st), (cmp))
#define sk_MIME_PARAM_dup(st) SKM_sk_dup(MIME_PARAM, st)
#define sk_MIME_PARAM_pop_free(st, free_func) SKM_sk_pop_free(MIME_PARAM, (st), (free_func))
#define sk_MIME_PARAM_shift(st) SKM_sk_shift(MIME_PARAM, (st))
#define sk_MIME_PARAM_pop(st) SKM_sk_pop(MIME_PARAM, (st))
#define sk_MIME_PARAM_sort(st) SKM_sk_sort(MIME_PARAM, (st))
#define sk_MIME_PARAM_is_sorted(st) SKM_sk_is_sorted(MIME_PARAM, (st))

#define sk_NAME_FUNCS_new(cmp) SKM_sk_new(NAME_FUNCS, (cmp))
#define sk_NAME_FUNCS_new_null() SKM_sk_new_null(NAME_FUNCS)
#define sk_NAME_FUNCS_free(st) SKM_sk_free(NAME_FUNCS, (st))
#define sk_NAME_FUNCS_num(st) SKM_sk_num(NAME_FUNCS, (st))
#define sk_NAME_FUNCS_value(st, i) SKM_sk_value(NAME_FUNCS, (st), (i))
#define sk_NAME_FUNCS_set(st, i, val) SKM_sk_set(NAME_FUNCS, (st), (i), (val))
#define sk_NAME_FUNCS_zero(st) SKM_sk_zero(NAME_FUNCS, (st))
#define sk_NAME_FUNCS_push(st, val) SKM_sk_push(NAME_FUNCS, (st), (val))
#define sk_NAME_FUNCS_unshift(st, val) SKM_sk_unshift(NAME_FUNCS, (st), (val))
#define sk_NAME_FUNCS_find(st, val) SKM_sk_find(NAME_FUNCS, (st), (val))
#define sk_NAME_FUNCS_find_ex(st, val) SKM_sk_find_ex(NAME_FUNCS, (st), (val))
#define sk_NAME_FUNCS_delete(st, i) SKM_sk_delete(NAME_FUNCS, (st), (i))
#define sk_NAME_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(NAME_FUNCS, (st), (ptr))
#define sk_NAME_FUNCS_insert(st, val, i) SKM_sk_insert(NAME_FUNCS, (st), (val), (i))
#define sk_NAME_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(NAME_FUNCS, (st), (cmp))
#define sk_NAME_FUNCS_dup(st) SKM_sk_dup(NAME_FUNCS, st)
#define sk_NAME_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(NAME_FUNCS, (st), (free_func))
#define sk_NAME_FUNCS_shift(st) SKM_sk_shift(NAME_FUNCS, (st))
#define sk_NAME_FUNCS_pop(st) SKM_sk_pop(NAME_FUNCS, (st))
#define sk_NAME_FUNCS_sort(st) SKM_sk_sort(NAME_FUNCS, (st))
#define sk_NAME_FUNCS_is_sorted(st) SKM_sk_is_sorted(NAME_FUNCS, (st))

#define sk_OCSP_CERTID_new(cmp) SKM_sk_new(OCSP_CERTID, (cmp))
#define sk_OCSP_CERTID_new_null() SKM_sk_new_null(OCSP_CERTID)
#define sk_OCSP_CERTID_free(st) SKM_sk_free(OCSP_CERTID, (st))
#define sk_OCSP_CERTID_num(st) SKM_sk_num(OCSP_CERTID, (st))
#define sk_OCSP_CERTID_value(st, i) SKM_sk_value(OCSP_CERTID, (st), (i))
#define sk_OCSP_CERTID_set(st, i, val) SKM_sk_set(OCSP_CERTID, (st), (i), (val))
#define sk_OCSP_CERTID_zero(st) SKM_sk_zero(OCSP_CERTID, (st))
#define sk_OCSP_CERTID_push(st, val) SKM_sk_push(OCSP_CERTID, (st), (val))
#define sk_OCSP_CERTID_unshift(st, val) SKM_sk_unshift(OCSP_CERTID, (st), (val))
#define sk_OCSP_CERTID_find(st, val) SKM_sk_find(OCSP_CERTID, (st), (val))
#define sk_OCSP_CERTID_find_ex(st, val) SKM_sk_find_ex(OCSP_CERTID, (st), (val))
#define sk_OCSP_CERTID_delete(st, i) SKM_sk_delete(OCSP_CERTID, (st), (i))
#define sk_OCSP_CERTID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_CERTID, (st), (ptr))
#define sk_OCSP_CERTID_insert(st, val, i) SKM_sk_insert(OCSP_CERTID, (st), (val), (i))
#define sk_OCSP_CERTID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_CERTID, (st), (cmp))
#define sk_OCSP_CERTID_dup(st) SKM_sk_dup(OCSP_CERTID, st)
#define sk_OCSP_CERTID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_CERTID, (st), (free_func))
#define sk_OCSP_CERTID_shift(st) SKM_sk_shift(OCSP_CERTID, (st))
#define sk_OCSP_CERTID_pop(st) SKM_sk_pop(OCSP_CERTID, (st))
#define sk_OCSP_CERTID_sort(st) SKM_sk_sort(OCSP_CERTID, (st))
#define sk_OCSP_CERTID_is_sorted(st) SKM_sk_is_sorted(OCSP_CERTID, (st))

#define sk_OCSP_ONEREQ_new(cmp) SKM_sk_new(OCSP_ONEREQ, (cmp))
#define sk_OCSP_ONEREQ_new_null() SKM_sk_new_null(OCSP_ONEREQ)
#define sk_OCSP_ONEREQ_free(st) SKM_sk_free(OCSP_ONEREQ, (st))
#define sk_OCSP_ONEREQ_num(st) SKM_sk_num(OCSP_ONEREQ, (st))
#define sk_OCSP_ONEREQ_value(st, i) SKM_sk_value(OCSP_ONEREQ, (st), (i))
#define sk_OCSP_ONEREQ_set(st, i, val) SKM_sk_set(OCSP_ONEREQ, (st), (i), (val))
#define sk_OCSP_ONEREQ_zero(st) SKM_sk_zero(OCSP_ONEREQ, (st))
#define sk_OCSP_ONEREQ_push(st, val) SKM_sk_push(OCSP_ONEREQ, (st), (val))
#define sk_OCSP_ONEREQ_unshift(st, val) SKM_sk_unshift(OCSP_ONEREQ, (st), (val))
#define sk_OCSP_ONEREQ_find(st, val) SKM_sk_find(OCSP_ONEREQ, (st), (val))
#define sk_OCSP_ONEREQ_find_ex(st, val) SKM_sk_find_ex(OCSP_ONEREQ, (st), (val))
#define sk_OCSP_ONEREQ_delete(st, i) SKM_sk_delete(OCSP_ONEREQ, (st), (i))
#define sk_OCSP_ONEREQ_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_ONEREQ, (st), (ptr))
#define sk_OCSP_ONEREQ_insert(st, val, i) SKM_sk_insert(OCSP_ONEREQ, (st), (val), (i))
#define sk_OCSP_ONEREQ_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_ONEREQ, (st), (cmp))
#define sk_OCSP_ONEREQ_dup(st) SKM_sk_dup(OCSP_ONEREQ, st)
#define sk_OCSP_ONEREQ_pop_free(st, free_func) SKM_sk_pop_free(OCSP_ONEREQ, (st), (free_func))
#define sk_OCSP_ONEREQ_shift(st) SKM_sk_shift(OCSP_ONEREQ, (st))
#define sk_OCSP_ONEREQ_pop(st) SKM_sk_pop(OCSP_ONEREQ, (st))
#define sk_OCSP_ONEREQ_sort(st) SKM_sk_sort(OCSP_ONEREQ, (st))
#define sk_OCSP_ONEREQ_is_sorted(st) SKM_sk_is_sorted(OCSP_ONEREQ, (st))

#define sk_OCSP_RESPID_new(cmp) SKM_sk_new(OCSP_RESPID, (cmp))
#define sk_OCSP_RESPID_new_null() SKM_sk_new_null(OCSP_RESPID)
#define sk_OCSP_RESPID_free(st) SKM_sk_free(OCSP_RESPID, (st))
#define sk_OCSP_RESPID_num(st) SKM_sk_num(OCSP_RESPID, (st))
#define sk_OCSP_RESPID_value(st, i) SKM_sk_value(OCSP_RESPID, (st), (i))
#define sk_OCSP_RESPID_set(st, i, val) SKM_sk_set(OCSP_RESPID, (st), (i), (val))
#define sk_OCSP_RESPID_zero(st) SKM_sk_zero(OCSP_RESPID, (st))
#define sk_OCSP_RESPID_push(st, val) SKM_sk_push(OCSP_RESPID, (st), (val))
#define sk_OCSP_RESPID_unshift(st, val) SKM_sk_unshift(OCSP_RESPID, (st), (val))
#define sk_OCSP_RESPID_find(st, val) SKM_sk_find(OCSP_RESPID, (st), (val))
#define sk_OCSP_RESPID_find_ex(st, val) SKM_sk_find_ex(OCSP_RESPID, (st), (val))
#define sk_OCSP_RESPID_delete(st, i) SKM_sk_delete(OCSP_RESPID, (st), (i))
#define sk_OCSP_RESPID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_RESPID, (st), (ptr))
#define sk_OCSP_RESPID_insert(st, val, i) SKM_sk_insert(OCSP_RESPID, (st), (val), (i))
#define sk_OCSP_RESPID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_RESPID, (st), (cmp))
#define sk_OCSP_RESPID_dup(st) SKM_sk_dup(OCSP_RESPID, st)
#define sk_OCSP_RESPID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_RESPID, (st), (free_func))
#define sk_OCSP_RESPID_shift(st) SKM_sk_shift(OCSP_RESPID, (st))
#define sk_OCSP_RESPID_pop(st) SKM_sk_pop(OCSP_RESPID, (st))
#define sk_OCSP_RESPID_sort(st) SKM_sk_sort(OCSP_RESPID, (st))
#define sk_OCSP_RESPID_is_sorted(st) SKM_sk_is_sorted(OCSP_RESPID, (st))

#define sk_OCSP_SINGLERESP_new(cmp) SKM_sk_new(OCSP_SINGLERESP, (cmp))
#define sk_OCSP_SINGLERESP_new_null() SKM_sk_new_null(OCSP_SINGLERESP)
#define sk_OCSP_SINGLERESP_free(st) SKM_sk_free(OCSP_SINGLERESP, (st))
#define sk_OCSP_SINGLERESP_num(st) SKM_sk_num(OCSP_SINGLERESP, (st))
#define sk_OCSP_SINGLERESP_value(st, i) SKM_sk_value(OCSP_SINGLERESP, (st), (i))
#define sk_OCSP_SINGLERESP_set(st, i, val) SKM_sk_set(OCSP_SINGLERESP, (st), (i), (val))
#define sk_OCSP_SINGLERESP_zero(st) SKM_sk_zero(OCSP_SINGLERESP, (st))
#define sk_OCSP_SINGLERESP_push(st, val) SKM_sk_push(OCSP_SINGLERESP, (st), (val))
#define sk_OCSP_SINGLERESP_unshift(st, val) SKM_sk_unshift(OCSP_SINGLERESP, (st), (val))
#define sk_OCSP_SINGLERESP_find(st, val) SKM_sk_find(OCSP_SINGLERESP, (st), (val))
#define sk_OCSP_SINGLERESP_find_ex(st, val) SKM_sk_find_ex(OCSP_SINGLERESP, (st), (val))
#define sk_OCSP_SINGLERESP_delete(st, i) SKM_sk_delete(OCSP_SINGLERESP, (st), (i))
#define sk_OCSP_SINGLERESP_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_SINGLERESP, (st), (ptr))
#define sk_OCSP_SINGLERESP_insert(st, val, i) SKM_sk_insert(OCSP_SINGLERESP, (st), (val), (i))
#define sk_OCSP_SINGLERESP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_SINGLERESP, (st), (cmp))
#define sk_OCSP_SINGLERESP_dup(st) SKM_sk_dup(OCSP_SINGLERESP, st)
#define sk_OCSP_SINGLERESP_pop_free(st, free_func) SKM_sk_pop_free(OCSP_SINGLERESP, (st), (free_func))
#define sk_OCSP_SINGLERESP_shift(st) SKM_sk_shift(OCSP_SINGLERESP, (st))
#define sk_OCSP_SINGLERESP_pop(st) SKM_sk_pop(OCSP_SINGLERESP, (st))
#define sk_OCSP_SINGLERESP_sort(st) SKM_sk_sort(OCSP_SINGLERESP, (st))
#define sk_OCSP_SINGLERESP_is_sorted(st) SKM_sk_is_sorted(OCSP_SINGLERESP, (st))

#define sk_PKCS12_SAFEBAG_new(cmp) SKM_sk_new(PKCS12_SAFEBAG, (cmp))
#define sk_PKCS12_SAFEBAG_new_null() SKM_sk_new_null(PKCS12_SAFEBAG)
#define sk_PKCS12_SAFEBAG_free(st) SKM_sk_free(PKCS12_SAFEBAG, (st))
#define sk_PKCS12_SAFEBAG_num(st) SKM_sk_num(PKCS12_SAFEBAG, (st))
#define sk_PKCS12_SAFEBAG_value(st, i) SKM_sk_value(PKCS12_SAFEBAG, (st), (i))
#define sk_PKCS12_SAFEBAG_set(st, i, val) SKM_sk_set(PKCS12_SAFEBAG, (st), (i), (val))
#define sk_PKCS12_SAFEBAG_zero(st) SKM_sk_zero(PKCS12_SAFEBAG, (st))
#define sk_PKCS12_SAFEBAG_push(st, val) SKM_sk_push(PKCS12_SAFEBAG, (st), (val))
#define sk_PKCS12_SAFEBAG_unshift(st, val) SKM_sk_unshift(PKCS12_SAFEBAG, (st), (val))
#define sk_PKCS12_SAFEBAG_find(st, val) SKM_sk_find(PKCS12_SAFEBAG, (st), (val))
#define sk_PKCS12_SAFEBAG_find_ex(st, val) SKM_sk_find_ex(PKCS12_SAFEBAG, (st), (val))
#define sk_PKCS12_SAFEBAG_delete(st, i) SKM_sk_delete(PKCS12_SAFEBAG, (st), (i))
#define sk_PKCS12_SAFEBAG_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS12_SAFEBAG, (st), (ptr))
#define sk_PKCS12_SAFEBAG_insert(st, val, i) SKM_sk_insert(PKCS12_SAFEBAG, (st), (val), (i))
#define sk_PKCS12_SAFEBAG_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS12_SAFEBAG, (st), (cmp))
#define sk_PKCS12_SAFEBAG_dup(st) SKM_sk_dup(PKCS12_SAFEBAG, st)
#define sk_PKCS12_SAFEBAG_pop_free(st, free_func) SKM_sk_pop_free(PKCS12_SAFEBAG, (st), (free_func))
#define sk_PKCS12_SAFEBAG_shift(st) SKM_sk_shift(PKCS12_SAFEBAG, (st))
#define sk_PKCS12_SAFEBAG_pop(st) SKM_sk_pop(PKCS12_SAFEBAG, (st))
#define sk_PKCS12_SAFEBAG_sort(st) SKM_sk_sort(PKCS12_SAFEBAG, (st))
#define sk_PKCS12_SAFEBAG_is_sorted(st) SKM_sk_is_sorted(PKCS12_SAFEBAG, (st))

#define sk_PKCS7_new(cmp) SKM_sk_new(PKCS7, (cmp))
#define sk_PKCS7_new_null() SKM_sk_new_null(PKCS7)
#define sk_PKCS7_free(st) SKM_sk_free(PKCS7, (st))
#define sk_PKCS7_num(st) SKM_sk_num(PKCS7, (st))
#define sk_PKCS7_value(st, i) SKM_sk_value(PKCS7, (st), (i))
#define sk_PKCS7_set(st, i, val) SKM_sk_set(PKCS7, (st), (i), (val))
#define sk_PKCS7_zero(st) SKM_sk_zero(PKCS7, (st))
#define sk_PKCS7_push(st, val) SKM_sk_push(PKCS7, (st), (val))
#define sk_PKCS7_unshift(st, val) SKM_sk_unshift(PKCS7, (st), (val))
#define sk_PKCS7_find(st, val) SKM_sk_find(PKCS7, (st), (val))
#define sk_PKCS7_find_ex(st, val) SKM_sk_find_ex(PKCS7, (st), (val))
#define sk_PKCS7_delete(st, i) SKM_sk_delete(PKCS7, (st), (i))
#define sk_PKCS7_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7, (st), (ptr))
#define sk_PKCS7_insert(st, val, i) SKM_sk_insert(PKCS7, (st), (val), (i))
#define sk_PKCS7_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7, (st), (cmp))
#define sk_PKCS7_dup(st) SKM_sk_dup(PKCS7, st)
#define sk_PKCS7_pop_free(st, free_func) SKM_sk_pop_free(PKCS7, (st), (free_func))
#define sk_PKCS7_shift(st) SKM_sk_shift(PKCS7, (st))
#define sk_PKCS7_pop(st) SKM_sk_pop(PKCS7, (st))
#define sk_PKCS7_sort(st) SKM_sk_sort(PKCS7, (st))
#define sk_PKCS7_is_sorted(st) SKM_sk_is_sorted(PKCS7, (st))

#define sk_PKCS7_RECIP_INFO_new(cmp) SKM_sk_new(PKCS7_RECIP_INFO, (cmp))
#define sk_PKCS7_RECIP_INFO_new_null() SKM_sk_new_null(PKCS7_RECIP_INFO)
#define sk_PKCS7_RECIP_INFO_free(st) SKM_sk_free(PKCS7_RECIP_INFO, (st))
#define sk_PKCS7_RECIP_INFO_num(st) SKM_sk_num(PKCS7_RECIP_INFO, (st))
#define sk_PKCS7_RECIP_INFO_value(st, i) SKM_sk_value(PKCS7_RECIP_INFO, (st), (i))
#define sk_PKCS7_RECIP_INFO_set(st, i, val) SKM_sk_set(PKCS7_RECIP_INFO, (st), (i), (val))
#define sk_PKCS7_RECIP_INFO_zero(st) SKM_sk_zero(PKCS7_RECIP_INFO, (st))
#define sk_PKCS7_RECIP_INFO_push(st, val) SKM_sk_push(PKCS7_RECIP_INFO, (st), (val))
#define sk_PKCS7_RECIP_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_RECIP_INFO, (st), (val))
#define sk_PKCS7_RECIP_INFO_find(st, val) SKM_sk_find(PKCS7_RECIP_INFO, (st), (val))
#define sk_PKCS7_RECIP_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_RECIP_INFO, (st), (val))
#define sk_PKCS7_RECIP_INFO_delete(st, i) SKM_sk_delete(PKCS7_RECIP_INFO, (st), (i))
#define sk_PKCS7_RECIP_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_RECIP_INFO, (st), (ptr))
#define sk_PKCS7_RECIP_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_RECIP_INFO, (st), (val), (i))
#define sk_PKCS7_RECIP_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_RECIP_INFO, (st), (cmp))
#define sk_PKCS7_RECIP_INFO_dup(st) SKM_sk_dup(PKCS7_RECIP_INFO, st)
#define sk_PKCS7_RECIP_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_RECIP_INFO, (st), (free_func))
#define sk_PKCS7_RECIP_INFO_shift(st) SKM_sk_shift(PKCS7_RECIP_INFO, (st))
#define sk_PKCS7_RECIP_INFO_pop(st) SKM_sk_pop(PKCS7_RECIP_INFO, (st))
#define sk_PKCS7_RECIP_INFO_sort(st) SKM_sk_sort(PKCS7_RECIP_INFO, (st))
#define sk_PKCS7_RECIP_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_RECIP_INFO, (st))

#define sk_PKCS7_SIGNER_INFO_new(cmp) SKM_sk_new(PKCS7_SIGNER_INFO, (cmp))
#define sk_PKCS7_SIGNER_INFO_new_null() SKM_sk_new_null(PKCS7_SIGNER_INFO)
#define sk_PKCS7_SIGNER_INFO_free(st) SKM_sk_free(PKCS7_SIGNER_INFO, (st))
#define sk_PKCS7_SIGNER_INFO_num(st) SKM_sk_num(PKCS7_SIGNER_INFO, (st))
#define sk_PKCS7_SIGNER_INFO_value(st, i) SKM_sk_value(PKCS7_SIGNER_INFO, (st), (i))
#define sk_PKCS7_SIGNER_INFO_set(st, i, val) SKM_sk_set(PKCS7_SIGNER_INFO, (st), (i), (val))
#define sk_PKCS7_SIGNER_INFO_zero(st) SKM_sk_zero(PKCS7_SIGNER_INFO, (st))
#define sk_PKCS7_SIGNER_INFO_push(st, val) SKM_sk_push(PKCS7_SIGNER_INFO, (st), (val))
#define sk_PKCS7_SIGNER_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_SIGNER_INFO, (st), (val))
#define sk_PKCS7_SIGNER_INFO_find(st, val) SKM_sk_find(PKCS7_SIGNER_INFO, (st), (val))
#define sk_PKCS7_SIGNER_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_SIGNER_INFO, (st), (val))
#define sk_PKCS7_SIGNER_INFO_delete(st, i) SKM_sk_delete(PKCS7_SIGNER_INFO, (st), (i))
#define sk_PKCS7_SIGNER_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_SIGNER_INFO, (st), (ptr))
#define sk_PKCS7_SIGNER_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_SIGNER_INFO, (st), (val), (i))
#define sk_PKCS7_SIGNER_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_SIGNER_INFO, (st), (cmp))
#define sk_PKCS7_SIGNER_INFO_dup(st) SKM_sk_dup(PKCS7_SIGNER_INFO, st)
#define sk_PKCS7_SIGNER_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_SIGNER_INFO, (st), (free_func))
#define sk_PKCS7_SIGNER_INFO_shift(st) SKM_sk_shift(PKCS7_SIGNER_INFO, (st))
#define sk_PKCS7_SIGNER_INFO_pop(st) SKM_sk_pop(PKCS7_SIGNER_INFO, (st))
#define sk_PKCS7_SIGNER_INFO_sort(st) SKM_sk_sort(PKCS7_SIGNER_INFO, (st))
#define sk_PKCS7_SIGNER_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_SIGNER_INFO, (st))

#define sk_POLICYINFO_new(cmp) SKM_sk_new(POLICYINFO, (cmp))
#define sk_POLICYINFO_new_null() SKM_sk_new_null(POLICYINFO)
#define sk_POLICYINFO_free(st) SKM_sk_free(POLICYINFO, (st))
#define sk_POLICYINFO_num(st) SKM_sk_num(POLICYINFO, (st))
#define sk_POLICYINFO_value(st, i) SKM_sk_value(POLICYINFO, (st), (i))
#define sk_POLICYINFO_set(st, i, val) SKM_sk_set(POLICYINFO, (st), (i), (val))
#define sk_POLICYINFO_zero(st) SKM_sk_zero(POLICYINFO, (st))
#define sk_POLICYINFO_push(st, val) SKM_sk_push(POLICYINFO, (st), (val))
#define sk_POLICYINFO_unshift(st, val) SKM_sk_unshift(POLICYINFO, (st), (val))
#define sk_POLICYINFO_find(st, val) SKM_sk_find(POLICYINFO, (st), (val))
#define sk_POLICYINFO_find_ex(st, val) SKM_sk_find_ex(POLICYINFO, (st), (val))
#define sk_POLICYINFO_delete(st, i) SKM_sk_delete(POLICYINFO, (st), (i))
#define sk_POLICYINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYINFO, (st), (ptr))
#define sk_POLICYINFO_insert(st, val, i) SKM_sk_insert(POLICYINFO, (st), (val), (i))
#define sk_POLICYINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYINFO, (st), (cmp))
#define sk_POLICYINFO_dup(st) SKM_sk_dup(POLICYINFO, st)
#define sk_POLICYINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYINFO, (st), (free_func))
#define sk_POLICYINFO_shift(st) SKM_sk_shift(POLICYINFO, (st))
#define sk_POLICYINFO_pop(st) SKM_sk_pop(POLICYINFO, (st))
#define sk_POLICYINFO_sort(st) SKM_sk_sort(POLICYINFO, (st))
#define sk_POLICYINFO_is_sorted(st) SKM_sk_is_sorted(POLICYINFO, (st))

#define sk_POLICYQUALINFO_new(cmp) SKM_sk_new(POLICYQUALINFO, (cmp))
#define sk_POLICYQUALINFO_new_null() SKM_sk_new_null(POLICYQUALINFO)
#define sk_POLICYQUALINFO_free(st) SKM_sk_free(POLICYQUALINFO, (st))
#define sk_POLICYQUALINFO_num(st) SKM_sk_num(POLICYQUALINFO, (st))
#define sk_POLICYQUALINFO_value(st, i) SKM_sk_value(POLICYQUALINFO, (st), (i))
#define sk_POLICYQUALINFO_set(st, i, val) SKM_sk_set(POLICYQUALINFO, (st), (i), (val))
#define sk_POLICYQUALINFO_zero(st) SKM_sk_zero(POLICYQUALINFO, (st))
#define sk_POLICYQUALINFO_push(st, val) SKM_sk_push(POLICYQUALINFO, (st), (val))
#define sk_POLICYQUALINFO_unshift(st, val) SKM_sk_unshift(POLICYQUALINFO, (st), (val))
#define sk_POLICYQUALINFO_find(st, val) SKM_sk_find(POLICYQUALINFO, (st), (val))
#define sk_POLICYQUALINFO_find_ex(st, val) SKM_sk_find_ex(POLICYQUALINFO, (st), (val))
#define sk_POLICYQUALINFO_delete(st, i) SKM_sk_delete(POLICYQUALINFO, (st), (i))
#define sk_POLICYQUALINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYQUALINFO, (st), (ptr))
#define sk_POLICYQUALINFO_insert(st, val, i) SKM_sk_insert(POLICYQUALINFO, (st), (val), (i))
#define sk_POLICYQUALINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYQUALINFO, (st), (cmp))
#define sk_POLICYQUALINFO_dup(st) SKM_sk_dup(POLICYQUALINFO, st)
#define sk_POLICYQUALINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYQUALINFO, (st), (free_func))
#define sk_POLICYQUALINFO_shift(st) SKM_sk_shift(POLICYQUALINFO, (st))
#define sk_POLICYQUALINFO_pop(st) SKM_sk_pop(POLICYQUALINFO, (st))
#define sk_POLICYQUALINFO_sort(st) SKM_sk_sort(POLICYQUALINFO, (st))
#define sk_POLICYQUALINFO_is_sorted(st) SKM_sk_is_sorted(POLICYQUALINFO, (st))

#define sk_POLICY_MAPPING_new(cmp) SKM_sk_new(POLICY_MAPPING, (cmp))
#define sk_POLICY_MAPPING_new_null() SKM_sk_new_null(POLICY_MAPPING)
#define sk_POLICY_MAPPING_free(st) SKM_sk_free(POLICY_MAPPING, (st))
#define sk_POLICY_MAPPING_num(st) SKM_sk_num(POLICY_MAPPING, (st))
#define sk_POLICY_MAPPING_value(st, i) SKM_sk_value(POLICY_MAPPING, (st), (i))
#define sk_POLICY_MAPPING_set(st, i, val) SKM_sk_set(POLICY_MAPPING, (st), (i), (val))
#define sk_POLICY_MAPPING_zero(st) SKM_sk_zero(POLICY_MAPPING, (st))
#define sk_POLICY_MAPPING_push(st, val) SKM_sk_push(POLICY_MAPPING, (st), (val))
#define sk_POLICY_MAPPING_unshift(st, val) SKM_sk_unshift(POLICY_MAPPING, (st), (val))
#define sk_POLICY_MAPPING_find(st, val) SKM_sk_find(POLICY_MAPPING, (st), (val))
#define sk_POLICY_MAPPING_find_ex(st, val) SKM_sk_find_ex(POLICY_MAPPING, (st), (val))
#define sk_POLICY_MAPPING_delete(st, i) SKM_sk_delete(POLICY_MAPPING, (st), (i))
#define sk_POLICY_MAPPING_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICY_MAPPING, (st), (ptr))
#define sk_POLICY_MAPPING_insert(st, val, i) SKM_sk_insert(POLICY_MAPPING, (st), (val), (i))
#define sk_POLICY_MAPPING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICY_MAPPING, (st), (cmp))
#define sk_POLICY_MAPPING_dup(st) SKM_sk_dup(POLICY_MAPPING, st)
#define sk_POLICY_MAPPING_pop_free(st, free_func) SKM_sk_pop_free(POLICY_MAPPING, (st), (free_func))
#define sk_POLICY_MAPPING_shift(st) SKM_sk_shift(POLICY_MAPPING, (st))
#define sk_POLICY_MAPPING_pop(st) SKM_sk_pop(POLICY_MAPPING, (st))
#define sk_POLICY_MAPPING_sort(st) SKM_sk_sort(POLICY_MAPPING, (st))
#define sk_POLICY_MAPPING_is_sorted(st) SKM_sk_is_sorted(POLICY_MAPPING, (st))

#define sk_SRP_gN_new(cmp) SKM_sk_new(SRP_gN, (cmp))
#define sk_SRP_gN_new_null() SKM_sk_new_null(SRP_gN)
#define sk_SRP_gN_free(st) SKM_sk_free(SRP_gN, (st))
#define sk_SRP_gN_num(st) SKM_sk_num(SRP_gN, (st))
#define sk_SRP_gN_value(st, i) SKM_sk_value(SRP_gN, (st), (i))
#define sk_SRP_gN_set(st, i, val) SKM_sk_set(SRP_gN, (st), (i), (val))
#define sk_SRP_gN_zero(st) SKM_sk_zero(SRP_gN, (st))
#define sk_SRP_gN_push(st, val) SKM_sk_push(SRP_gN, (st), (val))
#define sk_SRP_gN_unshift(st, val) SKM_sk_unshift(SRP_gN, (st), (val))
#define sk_SRP_gN_find(st, val) SKM_sk_find(SRP_gN, (st), (val))
#define sk_SRP_gN_find_ex(st, val) SKM_sk_find_ex(SRP_gN, (st), (val))
#define sk_SRP_gN_delete(st, i) SKM_sk_delete(SRP_gN, (st), (i))
#define sk_SRP_gN_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRP_gN, (st), (ptr))
#define sk_SRP_gN_insert(st, val, i) SKM_sk_insert(SRP_gN, (st), (val), (i))
#define sk_SRP_gN_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRP_gN, (st), (cmp))
#define sk_SRP_gN_dup(st) SKM_sk_dup(SRP_gN, st)
#define sk_SRP_gN_pop_free(st, free_func) SKM_sk_pop_free(SRP_gN, (st), (free_func))
#define sk_SRP_gN_shift(st) SKM_sk_shift(SRP_gN, (st))
#define sk_SRP_gN_pop(st) SKM_sk_pop(SRP_gN, (st))
#define sk_SRP_gN_sort(st) SKM_sk_sort(SRP_gN, (st))
#define sk_SRP_gN_is_sorted(st) SKM_sk_is_sorted(SRP_gN, (st))

#define sk_SRP_gN_cache_new(cmp) SKM_sk_new(SRP_gN_cache, (cmp))
#define sk_SRP_gN_cache_new_null() SKM_sk_new_null(SRP_gN_cache)
#define sk_SRP_gN_cache_free(st) SKM_sk_free(SRP_gN_cache, (st))
#define sk_SRP_gN_cache_num(st) SKM_sk_num(SRP_gN_cache, (st))
#define sk_SRP_gN_cache_value(st, i) SKM_sk_value(SRP_gN_cache, (st), (i))
#define sk_SRP_gN_cache_set(st, i, val) SKM_sk_set(SRP_gN_cache, (st), (i), (val))
#define sk_SRP_gN_cache_zero(st) SKM_sk_zero(SRP_gN_cache, (st))
#define sk_SRP_gN_cache_push(st, val) SKM_sk_push(SRP_gN_cache, (st), (val))
#define sk_SRP_gN_cache_unshift(st, val) SKM_sk_unshift(SRP_gN_cache, (st), (val))
#define sk_SRP_gN_cache_find(st, val) SKM_sk_find(SRP_gN_cache, (st), (val))
#define sk_SRP_gN_cache_find_ex(st, val) SKM_sk_find_ex(SRP_gN_cache, (st), (val))
#define sk_SRP_gN_cache_delete(st, i) SKM_sk_delete(SRP_gN_cache, (st), (i))
#define sk_SRP_gN_cache_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRP_gN_cache, (st), (ptr))
#define sk_SRP_gN_cache_insert(st, val, i) SKM_sk_insert(SRP_gN_cache, (st), (val), (i))
#define sk_SRP_gN_cache_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRP_gN_cache, (st), (cmp))
#define sk_SRP_gN_cache_dup(st) SKM_sk_dup(SRP_gN_cache, st)
#define sk_SRP_gN_cache_pop_free(st, free_func) SKM_sk_pop_free(SRP_gN_cache, (st), (free_func))
#define sk_SRP_gN_cache_shift(st) SKM_sk_shift(SRP_gN_cache, (st))
#define sk_SRP_gN_cache_pop(st) SKM_sk_pop(SRP_gN_cache, (st))
#define sk_SRP_gN_cache_sort(st) SKM_sk_sort(SRP_gN_cache, (st))
#define sk_SRP_gN_cache_is_sorted(st) SKM_sk_is_sorted(SRP_gN_cache, (st))

#define sk_SRP_user_pwd_new(cmp) SKM_sk_new(SRP_user_pwd, (cmp))
#define sk_SRP_user_pwd_new_null() SKM_sk_new_null(SRP_user_pwd)
#define sk_SRP_user_pwd_free(st) SKM_sk_free(SRP_user_pwd, (st))
#define sk_SRP_user_pwd_num(st) SKM_sk_num(SRP_user_pwd, (st))
#define sk_SRP_user_pwd_value(st, i) SKM_sk_value(SRP_user_pwd, (st), (i))
#define sk_SRP_user_pwd_set(st, i, val) SKM_sk_set(SRP_user_pwd, (st), (i), (val))
#define sk_SRP_user_pwd_zero(st) SKM_sk_zero(SRP_user_pwd, (st))
#define sk_SRP_user_pwd_push(st, val) SKM_sk_push(SRP_user_pwd, (st), (val))
#define sk_SRP_user_pwd_unshift(st, val) SKM_sk_unshift(SRP_user_pwd, (st), (val))
#define sk_SRP_user_pwd_find(st, val) SKM_sk_find(SRP_user_pwd, (st), (val))
#define sk_SRP_user_pwd_find_ex(st, val) SKM_sk_find_ex(SRP_user_pwd, (st), (val))
#define sk_SRP_user_pwd_delete(st, i) SKM_sk_delete(SRP_user_pwd, (st), (i))
#define sk_SRP_user_pwd_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRP_user_pwd, (st), (ptr))
#define sk_SRP_user_pwd_insert(st, val, i) SKM_sk_insert(SRP_user_pwd, (st), (val), (i))
#define sk_SRP_user_pwd_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRP_user_pwd, (st), (cmp))
#define sk_SRP_user_pwd_dup(st) SKM_sk_dup(SRP_user_pwd, st)
#define sk_SRP_user_pwd_pop_free(st, free_func) SKM_sk_pop_free(SRP_user_pwd, (st), (free_func))
#define sk_SRP_user_pwd_shift(st) SKM_sk_shift(SRP_user_pwd, (st))
#define sk_SRP_user_pwd_pop(st) SKM_sk_pop(SRP_user_pwd, (st))
#define sk_SRP_user_pwd_sort(st) SKM_sk_sort(SRP_user_pwd, (st))
#define sk_SRP_user_pwd_is_sorted(st) SKM_sk_is_sorted(SRP_user_pwd, (st))

#define sk_SRTP_PROTECTION_PROFILE_new(cmp) SKM_sk_new(SRTP_PROTECTION_PROFILE, (cmp))
#define sk_SRTP_PROTECTION_PROFILE_new_null() SKM_sk_new_null(SRTP_PROTECTION_PROFILE)
#define sk_SRTP_PROTECTION_PROFILE_free(st) SKM_sk_free(SRTP_PROTECTION_PROFILE, (st))
#define sk_SRTP_PROTECTION_PROFILE_num(st) SKM_sk_num(SRTP_PROTECTION_PROFILE, (st))
#define sk_SRTP_PROTECTION_PROFILE_value(st, i) SKM_sk_value(SRTP_PROTECTION_PROFILE, (st), (i))
#define sk_SRTP_PROTECTION_PROFILE_set(st, i, val) SKM_sk_set(SRTP_PROTECTION_PROFILE, (st), (i), (val))
#define sk_SRTP_PROTECTION_PROFILE_zero(st) SKM_sk_zero(SRTP_PROTECTION_PROFILE, (st))
#define sk_SRTP_PROTECTION_PROFILE_push(st, val) SKM_sk_push(SRTP_PROTECTION_PROFILE, (st), (val))
#define sk_SRTP_PROTECTION_PROFILE_unshift(st, val) SKM_sk_unshift(SRTP_PROTECTION_PROFILE, (st), (val))
#define sk_SRTP_PROTECTION_PROFILE_find(st, val) SKM_sk_find(SRTP_PROTECTION_PROFILE, (st), (val))
#define sk_SRTP_PROTECTION_PROFILE_find_ex(st, val) SKM_sk_find_ex(SRTP_PROTECTION_PROFILE, (st), (val))
#define sk_SRTP_PROTECTION_PROFILE_delete(st, i) SKM_sk_delete(SRTP_PROTECTION_PROFILE, (st), (i))
#define sk_SRTP_PROTECTION_PROFILE_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRTP_PROTECTION_PROFILE, (st), (ptr))
#define sk_SRTP_PROTECTION_PROFILE_insert(st, val, i) SKM_sk_insert(SRTP_PROTECTION_PROFILE, (st), (val), (i))
#define sk_SRTP_PROTECTION_PROFILE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRTP_PROTECTION_PROFILE, (st), (cmp))
#define sk_SRTP_PROTECTION_PROFILE_dup(st) SKM_sk_dup(SRTP_PROTECTION_PROFILE, st)
#define sk_SRTP_PROTECTION_PROFILE_pop_free(st, free_func) SKM_sk_pop_free(SRTP_PROTECTION_PROFILE, (st), (free_func))
#define sk_SRTP_PROTECTION_PROFILE_shift(st) SKM_sk_shift(SRTP_PROTECTION_PROFILE, (st))
#define sk_SRTP_PROTECTION_PROFILE_pop(st) SKM_sk_pop(SRTP_PROTECTION_PROFILE, (st))
#define sk_SRTP_PROTECTION_PROFILE_sort(st) SKM_sk_sort(SRTP_PROTECTION_PROFILE, (st))
#define sk_SRTP_PROTECTION_PROFILE_is_sorted(st) SKM_sk_is_sorted(SRTP_PROTECTION_PROFILE, (st))

#define sk_SSL_CIPHER_new(cmp) SKM_sk_new(SSL_CIPHER, (cmp))
#define sk_SSL_CIPHER_new_null() SKM_sk_new_null(SSL_CIPHER)
#define sk_SSL_CIPHER_free(st) SKM_sk_free(SSL_CIPHER, (st))
#define sk_SSL_CIPHER_num(st) SKM_sk_num(SSL_CIPHER, (st))
#define sk_SSL_CIPHER_value(st, i) SKM_sk_value(SSL_CIPHER, (st), (i))
#define sk_SSL_CIPHER_set(st, i, val) SKM_sk_set(SSL_CIPHER, (st), (i), (val))
#define sk_SSL_CIPHER_zero(st) SKM_sk_zero(SSL_CIPHER, (st))
#define sk_SSL_CIPHER_push(st, val) SKM_sk_push(SSL_CIPHER, (st), (val))
#define sk_SSL_CIPHER_unshift(st, val) SKM_sk_unshift(SSL_CIPHER, (st), (val))
#define sk_SSL_CIPHER_find(st, val) SKM_sk_find(SSL_CIPHER, (st), (val))
#define sk_SSL_CIPHER_find_ex(st, val) SKM_sk_find_ex(SSL_CIPHER, (st), (val))
#define sk_SSL_CIPHER_delete(st, i) SKM_sk_delete(SSL_CIPHER, (st), (i))
#define sk_SSL_CIPHER_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_CIPHER, (st), (ptr))
#define sk_SSL_CIPHER_insert(st, val, i) SKM_sk_insert(SSL_CIPHER, (st), (val), (i))
#define sk_SSL_CIPHER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_CIPHER, (st), (cmp))
#define sk_SSL_CIPHER_dup(st) SKM_sk_dup(SSL_CIPHER, st)
#define sk_SSL_CIPHER_pop_free(st, free_func) SKM_sk_pop_free(SSL_CIPHER, (st), (free_func))
#define sk_SSL_CIPHER_shift(st) SKM_sk_shift(SSL_CIPHER, (st))
#define sk_SSL_CIPHER_pop(st) SKM_sk_pop(SSL_CIPHER, (st))
#define sk_SSL_CIPHER_sort(st) SKM_sk_sort(SSL_CIPHER, (st))
#define sk_SSL_CIPHER_is_sorted(st) SKM_sk_is_sorted(SSL_CIPHER, (st))

#define sk_SSL_COMP_new(cmp) SKM_sk_new(SSL_COMP, (cmp))
#define sk_SSL_COMP_new_null() SKM_sk_new_null(SSL_COMP)
#define sk_SSL_COMP_free(st) SKM_sk_free(SSL_COMP, (st))
#define sk_SSL_COMP_num(st) SKM_sk_num(SSL_COMP, (st))
#define sk_SSL_COMP_value(st, i) SKM_sk_value(SSL_COMP, (st), (i))
#define sk_SSL_COMP_set(st, i, val) SKM_sk_set(SSL_COMP, (st), (i), (val))
#define sk_SSL_COMP_zero(st) SKM_sk_zero(SSL_COMP, (st))
#define sk_SSL_COMP_push(st, val) SKM_sk_push(SSL_COMP, (st), (val))
#define sk_SSL_COMP_unshift(st, val) SKM_sk_unshift(SSL_COMP, (st), (val))
#define sk_SSL_COMP_find(st, val) SKM_sk_find(SSL_COMP, (st), (val))
#define sk_SSL_COMP_find_ex(st, val) SKM_sk_find_ex(SSL_COMP, (st), (val))
#define sk_SSL_COMP_delete(st, i) SKM_sk_delete(SSL_COMP, (st), (i))
#define sk_SSL_COMP_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_COMP, (st), (ptr))
#define sk_SSL_COMP_insert(st, val, i) SKM_sk_insert(SSL_COMP, (st), (val), (i))
#define sk_SSL_COMP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_COMP, (st), (cmp))
#define sk_SSL_COMP_dup(st) SKM_sk_dup(SSL_COMP, st)
#define sk_SSL_COMP_pop_free(st, free_func) SKM_sk_pop_free(SSL_COMP, (st), (free_func))
#define sk_SSL_COMP_shift(st) SKM_sk_shift(SSL_COMP, (st))
#define sk_SSL_COMP_pop(st) SKM_sk_pop(SSL_COMP, (st))
#define sk_SSL_COMP_sort(st) SKM_sk_sort(SSL_COMP, (st))
#define sk_SSL_COMP_is_sorted(st) SKM_sk_is_sorted(SSL_COMP, (st))

#define sk_STACK_OF_X509_NAME_ENTRY_new(cmp) SKM_sk_new(STACK_OF_X509_NAME_ENTRY, (cmp))
#define sk_STACK_OF_X509_NAME_ENTRY_new_null() SKM_sk_new_null(STACK_OF_X509_NAME_ENTRY)
#define sk_STACK_OF_X509_NAME_ENTRY_free(st) SKM_sk_free(STACK_OF_X509_NAME_ENTRY, (st))
#define sk_STACK_OF_X509_NAME_ENTRY_num(st) SKM_sk_num(STACK_OF_X509_NAME_ENTRY, (st))
#define sk_STACK_OF_X509_NAME_ENTRY_value(st, i) SKM_sk_value(STACK_OF_X509_NAME_ENTRY, (st), (i))
#define sk_STACK_OF_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(STACK_OF_X509_NAME_ENTRY, (st), (i), (val))
#define sk_STACK_OF_X509_NAME_ENTRY_zero(st) SKM_sk_zero(STACK_OF_X509_NAME_ENTRY, (st))
#define sk_STACK_OF_X509_NAME_ENTRY_push(st, val) SKM_sk_push(STACK_OF_X509_NAME_ENTRY, (st), (val))
#define sk_STACK_OF_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(STACK_OF_X509_NAME_ENTRY, (st), (val))
#define sk_STACK_OF_X509_NAME_ENTRY_find(st, val) SKM_sk_find(STACK_OF_X509_NAME_ENTRY, (st), (val))
#define sk_STACK_OF_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(STACK_OF_X509_NAME_ENTRY, (st), (val))
#define sk_STACK_OF_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(STACK_OF_X509_NAME_ENTRY, (st), (i))
#define sk_STACK_OF_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(STACK_OF_X509_NAME_ENTRY, (st), (ptr))
#define sk_STACK_OF_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(STACK_OF_X509_NAME_ENTRY, (st), (val), (i))
#define sk_STACK_OF_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STACK_OF_X509_NAME_ENTRY, (st), (cmp))
#define sk_STACK_OF_X509_NAME_ENTRY_dup(st) SKM_sk_dup(STACK_OF_X509_NAME_ENTRY, st)
#define sk_STACK_OF_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(STACK_OF_X509_NAME_ENTRY, (st), (free_func))
#define sk_STACK_OF_X509_NAME_ENTRY_shift(st) SKM_sk_shift(STACK_OF_X509_NAME_ENTRY, (st))
#define sk_STACK_OF_X509_NAME_ENTRY_pop(st) SKM_sk_pop(STACK_OF_X509_NAME_ENTRY, (st))
#define sk_STACK_OF_X509_NAME_ENTRY_sort(st) SKM_sk_sort(STACK_OF_X509_NAME_ENTRY, (st))
#define sk_STACK_OF_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(STACK_OF_X509_NAME_ENTRY, (st))

#define sk_STORE_ATTR_INFO_new(cmp) SKM_sk_new(STORE_ATTR_INFO, (cmp))
#define sk_STORE_ATTR_INFO_new_null() SKM_sk_new_null(STORE_ATTR_INFO)
#define sk_STORE_ATTR_INFO_free(st) SKM_sk_free(STORE_ATTR_INFO, (st))
#define sk_STORE_ATTR_INFO_num(st) SKM_sk_num(STORE_ATTR_INFO, (st))
#define sk_STORE_ATTR_INFO_value(st, i) SKM_sk_value(STORE_ATTR_INFO, (st), (i))
#define sk_STORE_ATTR_INFO_set(st, i, val) SKM_sk_set(STORE_ATTR_INFO, (st), (i), (val))
#define sk_STORE_ATTR_INFO_zero(st) SKM_sk_zero(STORE_ATTR_INFO, (st))
#define sk_STORE_ATTR_INFO_push(st, val) SKM_sk_push(STORE_ATTR_INFO, (st), (val))
#define sk_STORE_ATTR_INFO_unshift(st, val) SKM_sk_unshift(STORE_ATTR_INFO, (st), (val))
#define sk_STORE_ATTR_INFO_find(st, val) SKM_sk_find(STORE_ATTR_INFO, (st), (val))
#define sk_STORE_ATTR_INFO_find_ex(st, val) SKM_sk_find_ex(STORE_ATTR_INFO, (st), (val))
#define sk_STORE_ATTR_INFO_delete(st, i) SKM_sk_delete(STORE_ATTR_INFO, (st), (i))
#define sk_STORE_ATTR_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_ATTR_INFO, (st), (ptr))
#define sk_STORE_ATTR_INFO_insert(st, val, i) SKM_sk_insert(STORE_ATTR_INFO, (st), (val), (i))
#define sk_STORE_ATTR_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_ATTR_INFO, (st), (cmp))
#define sk_STORE_ATTR_INFO_dup(st) SKM_sk_dup(STORE_ATTR_INFO, st)
#define sk_STORE_ATTR_INFO_pop_free(st, free_func) SKM_sk_pop_free(STORE_ATTR_INFO, (st), (free_func))
#define sk_STORE_ATTR_INFO_shift(st) SKM_sk_shift(STORE_ATTR_INFO, (st))
#define sk_STORE_ATTR_INFO_pop(st) SKM_sk_pop(STORE_ATTR_INFO, (st))
#define sk_STORE_ATTR_INFO_sort(st) SKM_sk_sort(STORE_ATTR_INFO, (st))
#define sk_STORE_ATTR_INFO_is_sorted(st) SKM_sk_is_sorted(STORE_ATTR_INFO, (st))

#define sk_STORE_OBJECT_new(cmp) SKM_sk_new(STORE_OBJECT, (cmp))
#define sk_STORE_OBJECT_new_null() SKM_sk_new_null(STORE_OBJECT)
#define sk_STORE_OBJECT_free(st) SKM_sk_free(STORE_OBJECT, (st))
#define sk_STORE_OBJECT_num(st) SKM_sk_num(STORE_OBJECT, (st))
#define sk_STORE_OBJECT_value(st, i) SKM_sk_value(STORE_OBJECT, (st), (i))
#define sk_STORE_OBJECT_set(st, i, val) SKM_sk_set(STORE_OBJECT, (st), (i), (val))
#define sk_STORE_OBJECT_zero(st) SKM_sk_zero(STORE_OBJECT, (st))
#define sk_STORE_OBJECT_push(st, val) SKM_sk_push(STORE_OBJECT, (st), (val))
#define sk_STORE_OBJECT_unshift(st, val) SKM_sk_unshift(STORE_OBJECT, (st), (val))
#define sk_STORE_OBJECT_find(st, val) SKM_sk_find(STORE_OBJECT, (st), (val))
#define sk_STORE_OBJECT_find_ex(st, val) SKM_sk_find_ex(STORE_OBJECT, (st), (val))
#define sk_STORE_OBJECT_delete(st, i) SKM_sk_delete(STORE_OBJECT, (st), (i))
#define sk_STORE_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_OBJECT, (st), (ptr))
#define sk_STORE_OBJECT_insert(st, val, i) SKM_sk_insert(STORE_OBJECT, (st), (val), (i))
#define sk_STORE_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_OBJECT, (st), (cmp))
#define sk_STORE_OBJECT_dup(st) SKM_sk_dup(STORE_OBJECT, st)
#define sk_STORE_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(STORE_OBJECT, (st), (free_func))
#define sk_STORE_OBJECT_shift(st) SKM_sk_shift(STORE_OBJECT, (st))
#define sk_STORE_OBJECT_pop(st) SKM_sk_pop(STORE_OBJECT, (st))
#define sk_STORE_OBJECT_sort(st) SKM_sk_sort(STORE_OBJECT, (st))
#define sk_STORE_OBJECT_is_sorted(st) SKM_sk_is_sorted(STORE_OBJECT, (st))

#define sk_SXNETID_new(cmp) SKM_sk_new(SXNETID, (cmp))
#define sk_SXNETID_new_null() SKM_sk_new_null(SXNETID)
#define sk_SXNETID_free(st) SKM_sk_free(SXNETID, (st))
#define sk_SXNETID_num(st) SKM_sk_num(SXNETID, (st))
#define sk_SXNETID_value(st, i) SKM_sk_value(SXNETID, (st), (i))
#define sk_SXNETID_set(st, i, val) SKM_sk_set(SXNETID, (st), (i), (val))
#define sk_SXNETID_zero(st) SKM_sk_zero(SXNETID, (st))
#define sk_SXNETID_push(st, val) SKM_sk_push(SXNETID, (st), (val))
#define sk_SXNETID_unshift(st, val) SKM_sk_unshift(SXNETID, (st), (val))
#define sk_SXNETID_find(st, val) SKM_sk_find(SXNETID, (st), (val))
#define sk_SXNETID_find_ex(st, val) SKM_sk_find_ex(SXNETID, (st), (val))
#define sk_SXNETID_delete(st, i) SKM_sk_delete(SXNETID, (st), (i))
#define sk_SXNETID_delete_ptr(st, ptr) SKM_sk_delete_ptr(SXNETID, (st), (ptr))
#define sk_SXNETID_insert(st, val, i) SKM_sk_insert(SXNETID, (st), (val), (i))
#define sk_SXNETID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SXNETID, (st), (cmp))
#define sk_SXNETID_dup(st) SKM_sk_dup(SXNETID, st)
#define sk_SXNETID_pop_free(st, free_func) SKM_sk_pop_free(SXNETID, (st), (free_func))
#define sk_SXNETID_shift(st) SKM_sk_shift(SXNETID, (st))
#define sk_SXNETID_pop(st) SKM_sk_pop(SXNETID, (st))
#define sk_SXNETID_sort(st) SKM_sk_sort(SXNETID, (st))
#define sk_SXNETID_is_sorted(st) SKM_sk_is_sorted(SXNETID, (st))

#define sk_UI_STRING_new(cmp) SKM_sk_new(UI_STRING, (cmp))
#define sk_UI_STRING_new_null() SKM_sk_new_null(UI_STRING)
#define sk_UI_STRING_free(st) SKM_sk_free(UI_STRING, (st))
#define sk_UI_STRING_num(st) SKM_sk_num(UI_STRING, (st))
#define sk_UI_STRING_value(st, i) SKM_sk_value(UI_STRING, (st), (i))
#define sk_UI_STRING_set(st, i, val) SKM_sk_set(UI_STRING, (st), (i), (val))
#define sk_UI_STRING_zero(st) SKM_sk_zero(UI_STRING, (st))
#define sk_UI_STRING_push(st, val) SKM_sk_push(UI_STRING, (st), (val))
#define sk_UI_STRING_unshift(st, val) SKM_sk_unshift(UI_STRING, (st), (val))
#define sk_UI_STRING_find(st, val) SKM_sk_find(UI_STRING, (st), (val))
#define sk_UI_STRING_find_ex(st, val) SKM_sk_find_ex(UI_STRING, (st), (val))
#define sk_UI_STRING_delete(st, i) SKM_sk_delete(UI_STRING, (st), (i))
#define sk_UI_STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(UI_STRING, (st), (ptr))
#define sk_UI_STRING_insert(st, val, i) SKM_sk_insert(UI_STRING, (st), (val), (i))
#define sk_UI_STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(UI_STRING, (st), (cmp))
#define sk_UI_STRING_dup(st) SKM_sk_dup(UI_STRING, st)
#define sk_UI_STRING_pop_free(st, free_func) SKM_sk_pop_free(UI_STRING, (st), (free_func))
#define sk_UI_STRING_shift(st) SKM_sk_shift(UI_STRING, (st))
#define sk_UI_STRING_pop(st) SKM_sk_pop(UI_STRING, (st))
#define sk_UI_STRING_sort(st) SKM_sk_sort(UI_STRING, (st))
#define sk_UI_STRING_is_sorted(st) SKM_sk_is_sorted(UI_STRING, (st))

#define sk_X509_new(cmp) SKM_sk_new(X509, (cmp))
#define sk_X509_new_null() SKM_sk_new_null(X509)
#define sk_X509_free(st) SKM_sk_free(X509, (st))
#define sk_X509_num(st) SKM_sk_num(X509, (st))
#define sk_X509_value(st, i) SKM_sk_value(X509, (st), (i))
#define sk_X509_set(st, i, val) SKM_sk_set(X509, (st), (i), (val))
#define sk_X509_zero(st) SKM_sk_zero(X509, (st))
#define sk_X509_push(st, val) SKM_sk_push(X509, (st), (val))
#define sk_X509_unshift(st, val) SKM_sk_unshift(X509, (st), (val))
#define sk_X509_find(st, val) SKM_sk_find(X509, (st), (val))
#define sk_X509_find_ex(st, val) SKM_sk_find_ex(X509, (st), (val))
#define sk_X509_delete(st, i) SKM_sk_delete(X509, (st), (i))
#define sk_X509_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509, (st), (ptr))
#define sk_X509_insert(st, val, i) SKM_sk_insert(X509, (st), (val), (i))
#define sk_X509_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509, (st), (cmp))
#define sk_X509_dup(st) SKM_sk_dup(X509, st)
#define sk_X509_pop_free(st, free_func) SKM_sk_pop_free(X509, (st), (free_func))
#define sk_X509_shift(st) SKM_sk_shift(X509, (st))
#define sk_X509_pop(st) SKM_sk_pop(X509, (st))
#define sk_X509_sort(st) SKM_sk_sort(X509, (st))
#define sk_X509_is_sorted(st) SKM_sk_is_sorted(X509, (st))

#define sk_X509V3_EXT_METHOD_new(cmp) SKM_sk_new(X509V3_EXT_METHOD, (cmp))
#define sk_X509V3_EXT_METHOD_new_null() SKM_sk_new_null(X509V3_EXT_METHOD)
#define sk_X509V3_EXT_METHOD_free(st) SKM_sk_free(X509V3_EXT_METHOD, (st))
#define sk_X509V3_EXT_METHOD_num(st) SKM_sk_num(X509V3_EXT_METHOD, (st))
#define sk_X509V3_EXT_METHOD_value(st, i) SKM_sk_value(X509V3_EXT_METHOD, (st), (i))
#define sk_X509V3_EXT_METHOD_set(st, i, val) SKM_sk_set(X509V3_EXT_METHOD, (st), (i), (val))
#define sk_X509V3_EXT_METHOD_zero(st) SKM_sk_zero(X509V3_EXT_METHOD, (st))
#define sk_X509V3_EXT_METHOD_push(st, val) SKM_sk_push(X509V3_EXT_METHOD, (st), (val))
#define sk_X509V3_EXT_METHOD_unshift(st, val) SKM_sk_unshift(X509V3_EXT_METHOD, (st), (val))
#define sk_X509V3_EXT_METHOD_find(st, val) SKM_sk_find(X509V3_EXT_METHOD, (st), (val))
#define sk_X509V3_EXT_METHOD_find_ex(st, val) SKM_sk_find_ex(X509V3_EXT_METHOD, (st), (val))
#define sk_X509V3_EXT_METHOD_delete(st, i) SKM_sk_delete(X509V3_EXT_METHOD, (st), (i))
#define sk_X509V3_EXT_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509V3_EXT_METHOD, (st), (ptr))
#define sk_X509V3_EXT_METHOD_insert(st, val, i) SKM_sk_insert(X509V3_EXT_METHOD, (st), (val), (i))
#define sk_X509V3_EXT_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509V3_EXT_METHOD, (st), (cmp))
#define sk_X509V3_EXT_METHOD_dup(st) SKM_sk_dup(X509V3_EXT_METHOD, st)
#define sk_X509V3_EXT_METHOD_pop_free(st, free_func) SKM_sk_pop_free(X509V3_EXT_METHOD, (st), (free_func))
#define sk_X509V3_EXT_METHOD_shift(st) SKM_sk_shift(X509V3_EXT_METHOD, (st))
#define sk_X509V3_EXT_METHOD_pop(st) SKM_sk_pop(X509V3_EXT_METHOD, (st))
#define sk_X509V3_EXT_METHOD_sort(st) SKM_sk_sort(X509V3_EXT_METHOD, (st))
#define sk_X509V3_EXT_METHOD_is_sorted(st) SKM_sk_is_sorted(X509V3_EXT_METHOD, (st))

#define sk_X509_ALGOR_new(cmp) SKM_sk_new(X509_ALGOR, (cmp))
#define sk_X509_ALGOR_new_null() SKM_sk_new_null(X509_ALGOR)
#define sk_X509_ALGOR_free(st) SKM_sk_free(X509_ALGOR, (st))
#define sk_X509_ALGOR_num(st) SKM_sk_num(X509_ALGOR, (st))
#define sk_X509_ALGOR_value(st, i) SKM_sk_value(X509_ALGOR, (st), (i))
#define sk_X509_ALGOR_set(st, i, val) SKM_sk_set(X509_ALGOR, (st), (i), (val))
#define sk_X509_ALGOR_zero(st) SKM_sk_zero(X509_ALGOR, (st))
#define sk_X509_ALGOR_push(st, val) SKM_sk_push(X509_ALGOR, (st), (val))
#define sk_X509_ALGOR_unshift(st, val) SKM_sk_unshift(X509_ALGOR, (st), (val))
#define sk_X509_ALGOR_find(st, val) SKM_sk_find(X509_ALGOR, (st), (val))
#define sk_X509_ALGOR_find_ex(st, val) SKM_sk_find_ex(X509_ALGOR, (st), (val))
#define sk_X509_ALGOR_delete(st, i) SKM_sk_delete(X509_ALGOR, (st), (i))
#define sk_X509_ALGOR_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ALGOR, (st), (ptr))
#define sk_X509_ALGOR_insert(st, val, i) SKM_sk_insert(X509_ALGOR, (st), (val), (i))
#define sk_X509_ALGOR_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ALGOR, (st), (cmp))
#define sk_X509_ALGOR_dup(st) SKM_sk_dup(X509_ALGOR, st)
#define sk_X509_ALGOR_pop_free(st, free_func) SKM_sk_pop_free(X509_ALGOR, (st), (free_func))
#define sk_X509_ALGOR_shift(st) SKM_sk_shift(X509_ALGOR, (st))
#define sk_X509_ALGOR_pop(st) SKM_sk_pop(X509_ALGOR, (st))
#define sk_X509_ALGOR_sort(st) SKM_sk_sort(X509_ALGOR, (st))
#define sk_X509_ALGOR_is_sorted(st) SKM_sk_is_sorted(X509_ALGOR, (st))

#define sk_X509_ATTRIBUTE_new(cmp) SKM_sk_new(X509_ATTRIBUTE, (cmp))
#define sk_X509_ATTRIBUTE_new_null() SKM_sk_new_null(X509_ATTRIBUTE)
#define sk_X509_ATTRIBUTE_free(st) SKM_sk_free(X509_ATTRIBUTE, (st))
#define sk_X509_ATTRIBUTE_num(st) SKM_sk_num(X509_ATTRIBUTE, (st))
#define sk_X509_ATTRIBUTE_value(st, i) SKM_sk_value(X509_ATTRIBUTE, (st), (i))
#define sk_X509_ATTRIBUTE_set(st, i, val) SKM_sk_set(X509_ATTRIBUTE, (st), (i), (val))
#define sk_X509_ATTRIBUTE_zero(st) SKM_sk_zero(X509_ATTRIBUTE, (st))
#define sk_X509_ATTRIBUTE_push(st, val) SKM_sk_push(X509_ATTRIBUTE, (st), (val))
#define sk_X509_ATTRIBUTE_unshift(st, val) SKM_sk_unshift(X509_ATTRIBUTE, (st), (val))
#define sk_X509_ATTRIBUTE_find(st, val) SKM_sk_find(X509_ATTRIBUTE, (st), (val))
#define sk_X509_ATTRIBUTE_find_ex(st, val) SKM_sk_find_ex(X509_ATTRIBUTE, (st), (val))
#define sk_X509_ATTRIBUTE_delete(st, i) SKM_sk_delete(X509_ATTRIBUTE, (st), (i))
#define sk_X509_ATTRIBUTE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ATTRIBUTE, (st), (ptr))
#define sk_X509_ATTRIBUTE_insert(st, val, i) SKM_sk_insert(X509_ATTRIBUTE, (st), (val), (i))
#define sk_X509_ATTRIBUTE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ATTRIBUTE, (st), (cmp))
#define sk_X509_ATTRIBUTE_dup(st) SKM_sk_dup(X509_ATTRIBUTE, st)
#define sk_X509_ATTRIBUTE_pop_free(st, free_func) SKM_sk_pop_free(X509_ATTRIBUTE, (st), (free_func))
#define sk_X509_ATTRIBUTE_shift(st) SKM_sk_shift(X509_ATTRIBUTE, (st))
#define sk_X509_ATTRIBUTE_pop(st) SKM_sk_pop(X509_ATTRIBUTE, (st))
#define sk_X509_ATTRIBUTE_sort(st) SKM_sk_sort(X509_ATTRIBUTE, (st))
#define sk_X509_ATTRIBUTE_is_sorted(st) SKM_sk_is_sorted(X509_ATTRIBUTE, (st))

#define sk_X509_CRL_new(cmp) SKM_sk_new(X509_CRL, (cmp))
#define sk_X509_CRL_new_null() SKM_sk_new_null(X509_CRL)
#define sk_X509_CRL_free(st) SKM_sk_free(X509_CRL, (st))
#define sk_X509_CRL_num(st) SKM_sk_num(X509_CRL, (st))
#define sk_X509_CRL_value(st, i) SKM_sk_value(X509_CRL, (st), (i))
#define sk_X509_CRL_set(st, i, val) SKM_sk_set(X509_CRL, (st), (i), (val))
#define sk_X509_CRL_zero(st) SKM_sk_zero(X509_CRL, (st))
#define sk_X509_CRL_push(st, val) SKM_sk_push(X509_CRL, (st), (val))
#define sk_X509_CRL_unshift(st, val) SKM_sk_unshift(X509_CRL, (st), (val))
#define sk_X509_CRL_find(st, val) SKM_sk_find(X509_CRL, (st), (val))
#define sk_X509_CRL_find_ex(st, val) SKM_sk_find_ex(X509_CRL, (st), (val))
#define sk_X509_CRL_delete(st, i) SKM_sk_delete(X509_CRL, (st), (i))
#define sk_X509_CRL_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_CRL, (st), (ptr))
#define sk_X509_CRL_insert(st, val, i) SKM_sk_insert(X509_CRL, (st), (val), (i))
#define sk_X509_CRL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_CRL, (st), (cmp))
#define sk_X509_CRL_dup(st) SKM_sk_dup(X509_CRL, st)
#define sk_X509_CRL_pop_free(st, free_func) SKM_sk_pop_free(X509_CRL, (st), (free_func))
#define sk_X509_CRL_shift(st) SKM_sk_shift(X509_CRL, (st))
#define sk_X509_CRL_pop(st) SKM_sk_pop(X509_CRL, (st))
#define sk_X509_CRL_sort(st) SKM_sk_sort(X509_CRL, (st))
#define sk_X509_CRL_is_sorted(st) SKM_sk_is_sorted(X509_CRL, (st))

#define sk_X509_EXTENSION_new(cmp) SKM_sk_new(X509_EXTENSION, (cmp))
#define sk_X509_EXTENSION_new_null() SKM_sk_new_null(X509_EXTENSION)
#define sk_X509_EXTENSION_free(st) SKM_sk_free(X509_EXTENSION, (st))
#define sk_X509_EXTENSION_num(st) SKM_sk_num(X509_EXTENSION, (st))
#define sk_X509_EXTENSION_value(st, i) SKM_sk_value(X509_EXTENSION, (st), (i))
#define sk_X509_EXTENSION_set(st, i, val) SKM_sk_set(X509_EXTENSION, (st), (i), (val))
#define sk_X509_EXTENSION_zero(st) SKM_sk_zero(X509_EXTENSION, (st))
#define sk_X509_EXTENSION_push(st, val) SKM_sk_push(X509_EXTENSION, (st), (val))
#define sk_X509_EXTENSION_unshift(st, val) SKM_sk_unshift(X509_EXTENSION, (st), (val))
#define sk_X509_EXTENSION_find(st, val) SKM_sk_find(X509_EXTENSION, (st), (val))
#define sk_X509_EXTENSION_find_ex(st, val) SKM_sk_find_ex(X509_EXTENSION, (st), (val))
#define sk_X509_EXTENSION_delete(st, i) SKM_sk_delete(X509_EXTENSION, (st), (i))
#define sk_X509_EXTENSION_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_EXTENSION, (st), (ptr))
#define sk_X509_EXTENSION_insert(st, val, i) SKM_sk_insert(X509_EXTENSION, (st), (val), (i))
#define sk_X509_EXTENSION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_EXTENSION, (st), (cmp))
#define sk_X509_EXTENSION_dup(st) SKM_sk_dup(X509_EXTENSION, st)
#define sk_X509_EXTENSION_pop_free(st, free_func) SKM_sk_pop_free(X509_EXTENSION, (st), (free_func))
#define sk_X509_EXTENSION_shift(st) SKM_sk_shift(X509_EXTENSION, (st))
#define sk_X509_EXTENSION_pop(st) SKM_sk_pop(X509_EXTENSION, (st))
#define sk_X509_EXTENSION_sort(st) SKM_sk_sort(X509_EXTENSION, (st))
#define sk_X509_EXTENSION_is_sorted(st) SKM_sk_is_sorted(X509_EXTENSION, (st))

#define sk_X509_INFO_new(cmp) SKM_sk_new(X509_INFO, (cmp))
#define sk_X509_INFO_new_null() SKM_sk_new_null(X509_INFO)
#define sk_X509_INFO_free(st) SKM_sk_free(X509_INFO, (st))
#define sk_X509_INFO_num(st) SKM_sk_num(X509_INFO, (st))
#define sk_X509_INFO_value(st, i) SKM_sk_value(X509_INFO, (st), (i))
#define sk_X509_INFO_set(st, i, val) SKM_sk_set(X509_INFO, (st), (i), (val))
#define sk_X509_INFO_zero(st) SKM_sk_zero(X509_INFO, (st))
#define sk_X509_INFO_push(st, val) SKM_sk_push(X509_INFO, (st), (val))
#define sk_X509_INFO_unshift(st, val) SKM_sk_unshift(X509_INFO, (st), (val))
#define sk_X509_INFO_find(st, val) SKM_sk_find(X509_INFO, (st), (val))
#define sk_X509_INFO_find_ex(st, val) SKM_sk_find_ex(X509_INFO, (st), (val))
#define sk_X509_INFO_delete(st, i) SKM_sk_delete(X509_INFO, (st), (i))
#define sk_X509_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_INFO, (st), (ptr))
#define sk_X509_INFO_insert(st, val, i) SKM_sk_insert(X509_INFO, (st), (val), (i))
#define sk_X509_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_INFO, (st), (cmp))
#define sk_X509_INFO_dup(st) SKM_sk_dup(X509_INFO, st)
#define sk_X509_INFO_pop_free(st, free_func) SKM_sk_pop_free(X509_INFO, (st), (free_func))
#define sk_X509_INFO_shift(st) SKM_sk_shift(X509_INFO, (st))
#define sk_X509_INFO_pop(st) SKM_sk_pop(X509_INFO, (st))
#define sk_X509_INFO_sort(st) SKM_sk_sort(X509_INFO, (st))
#define sk_X509_INFO_is_sorted(st) SKM_sk_is_sorted(X509_INFO, (st))

#define sk_X509_LOOKUP_new(cmp) SKM_sk_new(X509_LOOKUP, (cmp))
#define sk_X509_LOOKUP_new_null() SKM_sk_new_null(X509_LOOKUP)
#define sk_X509_LOOKUP_free(st) SKM_sk_free(X509_LOOKUP, (st))
#define sk_X509_LOOKUP_num(st) SKM_sk_num(X509_LOOKUP, (st))
#define sk_X509_LOOKUP_value(st, i) SKM_sk_value(X509_LOOKUP, (st), (i))
#define sk_X509_LOOKUP_set(st, i, val) SKM_sk_set(X509_LOOKUP, (st), (i), (val))
#define sk_X509_LOOKUP_zero(st) SKM_sk_zero(X509_LOOKUP, (st))
#define sk_X509_LOOKUP_push(st, val) SKM_sk_push(X509_LOOKUP, (st), (val))
#define sk_X509_LOOKUP_unshift(st, val) SKM_sk_unshift(X509_LOOKUP, (st), (val))
#define sk_X509_LOOKUP_find(st, val) SKM_sk_find(X509_LOOKUP, (st), (val))
#define sk_X509_LOOKUP_find_ex(st, val) SKM_sk_find_ex(X509_LOOKUP, (st), (val))
#define sk_X509_LOOKUP_delete(st, i) SKM_sk_delete(X509_LOOKUP, (st), (i))
#define sk_X509_LOOKUP_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_LOOKUP, (st), (ptr))
#define sk_X509_LOOKUP_insert(st, val, i) SKM_sk_insert(X509_LOOKUP, (st), (val), (i))
#define sk_X509_LOOKUP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_LOOKUP, (st), (cmp))
#define sk_X509_LOOKUP_dup(st) SKM_sk_dup(X509_LOOKUP, st)
#define sk_X509_LOOKUP_pop_free(st, free_func) SKM_sk_pop_free(X509_LOOKUP, (st), (free_func))
#define sk_X509_LOOKUP_shift(st) SKM_sk_shift(X509_LOOKUP, (st))
#define sk_X509_LOOKUP_pop(st) SKM_sk_pop(X509_LOOKUP, (st))
#define sk_X509_LOOKUP_sort(st) SKM_sk_sort(X509_LOOKUP, (st))
#define sk_X509_LOOKUP_is_sorted(st) SKM_sk_is_sorted(X509_LOOKUP, (st))

#define sk_X509_NAME_new(cmp) SKM_sk_new(X509_NAME, (cmp))
#define sk_X509_NAME_new_null() SKM_sk_new_null(X509_NAME)
#define sk_X509_NAME_free(st) SKM_sk_free(X509_NAME, (st))
#define sk_X509_NAME_num(st) SKM_sk_num(X509_NAME, (st))
#define sk_X509_NAME_value(st, i) SKM_sk_value(X509_NAME, (st), (i))
#define sk_X509_NAME_set(st, i, val) SKM_sk_set(X509_NAME, (st), (i), (val))
#define sk_X509_NAME_zero(st) SKM_sk_zero(X509_NAME, (st))
#define sk_X509_NAME_push(st, val) SKM_sk_push(X509_NAME, (st), (val))
#define sk_X509_NAME_unshift(st, val) SKM_sk_unshift(X509_NAME, (st), (val))
#define sk_X509_NAME_find(st, val) SKM_sk_find(X509_NAME, (st), (val))
#define sk_X509_NAME_find_ex(st, val) SKM_sk_find_ex(X509_NAME, (st), (val))
#define sk_X509_NAME_delete(st, i) SKM_sk_delete(X509_NAME, (st), (i))
#define sk_X509_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME, (st), (ptr))
#define sk_X509_NAME_insert(st, val, i) SKM_sk_insert(X509_NAME, (st), (val), (i))
#define sk_X509_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME, (st), (cmp))
#define sk_X509_NAME_dup(st) SKM_sk_dup(X509_NAME, st)
#define sk_X509_NAME_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME, (st), (free_func))
#define sk_X509_NAME_shift(st) SKM_sk_shift(X509_NAME, (st))
#define sk_X509_NAME_pop(st) SKM_sk_pop(X509_NAME, (st))
#define sk_X509_NAME_sort(st) SKM_sk_sort(X509_NAME, (st))
#define sk_X509_NAME_is_sorted(st) SKM_sk_is_sorted(X509_NAME, (st))

#define sk_X509_NAME_ENTRY_new(cmp) SKM_sk_new(X509_NAME_ENTRY, (cmp))
#define sk_X509_NAME_ENTRY_new_null() SKM_sk_new_null(X509_NAME_ENTRY)
#define sk_X509_NAME_ENTRY_free(st) SKM_sk_free(X509_NAME_ENTRY, (st))
#define sk_X509_NAME_ENTRY_num(st) SKM_sk_num(X509_NAME_ENTRY, (st))
#define sk_X509_NAME_ENTRY_value(st, i) SKM_sk_value(X509_NAME_ENTRY, (st), (i))
#define sk_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(X509_NAME_ENTRY, (st), (i), (val))
#define sk_X509_NAME_ENTRY_zero(st) SKM_sk_zero(X509_NAME_ENTRY, (st))
#define sk_X509_NAME_ENTRY_push(st, val) SKM_sk_push(X509_NAME_ENTRY, (st), (val))
#define sk_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(X509_NAME_ENTRY, (st), (val))
#define sk_X509_NAME_ENTRY_find(st, val) SKM_sk_find(X509_NAME_ENTRY, (st), (val))
#define sk_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(X509_NAME_ENTRY, (st), (val))
#define sk_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(X509_NAME_ENTRY, (st), (i))
#define sk_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME_ENTRY, (st), (ptr))
#define sk_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(X509_NAME_ENTRY, (st), (val), (i))
#define sk_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME_ENTRY, (st), (cmp))
#define sk_X509_NAME_ENTRY_dup(st) SKM_sk_dup(X509_NAME_ENTRY, st)
#define sk_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME_ENTRY, (st), (free_func))
#define sk_X509_NAME_ENTRY_shift(st) SKM_sk_shift(X509_NAME_ENTRY, (st))
#define sk_X509_NAME_ENTRY_pop(st) SKM_sk_pop(X509_NAME_ENTRY, (st))
#define sk_X509_NAME_ENTRY_sort(st) SKM_sk_sort(X509_NAME_ENTRY, (st))
#define sk_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(X509_NAME_ENTRY, (st))

#define sk_X509_OBJECT_new(cmp) SKM_sk_new(X509_OBJECT, (cmp))
#define sk_X509_OBJECT_new_null() SKM_sk_new_null(X509_OBJECT)
#define sk_X509_OBJECT_free(st) SKM_sk_free(X509_OBJECT, (st))
#define sk_X509_OBJECT_num(st) SKM_sk_num(X509_OBJECT, (st))
#define sk_X509_OBJECT_value(st, i) SKM_sk_value(X509_OBJECT, (st), (i))
#define sk_X509_OBJECT_set(st, i, val) SKM_sk_set(X509_OBJECT, (st), (i), (val))
#define sk_X509_OBJECT_zero(st) SKM_sk_zero(X509_OBJECT, (st))
#define sk_X509_OBJECT_push(st, val) SKM_sk_push(X509_OBJECT, (st), (val))
#define sk_X509_OBJECT_unshift(st, val) SKM_sk_unshift(X509_OBJECT, (st), (val))
#define sk_X509_OBJECT_find(st, val) SKM_sk_find(X509_OBJECT, (st), (val))
#define sk_X509_OBJECT_find_ex(st, val) SKM_sk_find_ex(X509_OBJECT, (st), (val))
#define sk_X509_OBJECT_delete(st, i) SKM_sk_delete(X509_OBJECT, (st), (i))
#define sk_X509_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_OBJECT, (st), (ptr))
#define sk_X509_OBJECT_insert(st, val, i) SKM_sk_insert(X509_OBJECT, (st), (val), (i))
#define sk_X509_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_OBJECT, (st), (cmp))
#define sk_X509_OBJECT_dup(st) SKM_sk_dup(X509_OBJECT, st)
#define sk_X509_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(X509_OBJECT, (st), (free_func))
#define sk_X509_OBJECT_shift(st) SKM_sk_shift(X509_OBJECT, (st))
#define sk_X509_OBJECT_pop(st) SKM_sk_pop(X509_OBJECT, (st))
#define sk_X509_OBJECT_sort(st) SKM_sk_sort(X509_OBJECT, (st))
#define sk_X509_OBJECT_is_sorted(st) SKM_sk_is_sorted(X509_OBJECT, (st))

#define sk_X509_POLICY_DATA_new(cmp) SKM_sk_new(X509_POLICY_DATA, (cmp))
#define sk_X509_POLICY_DATA_new_null() SKM_sk_new_null(X509_POLICY_DATA)
#define sk_X509_POLICY_DATA_free(st) SKM_sk_free(X509_POLICY_DATA, (st))
#define sk_X509_POLICY_DATA_num(st) SKM_sk_num(X509_POLICY_DATA, (st))
#define sk_X509_POLICY_DATA_value(st, i) SKM_sk_value(X509_POLICY_DATA, (st), (i))
#define sk_X509_POLICY_DATA_set(st, i, val) SKM_sk_set(X509_POLICY_DATA, (st), (i), (val))
#define sk_X509_POLICY_DATA_zero(st) SKM_sk_zero(X509_POLICY_DATA, (st))
#define sk_X509_POLICY_DATA_push(st, val) SKM_sk_push(X509_POLICY_DATA, (st), (val))
#define sk_X509_POLICY_DATA_unshift(st, val) SKM_sk_unshift(X509_POLICY_DATA, (st), (val))
#define sk_X509_POLICY_DATA_find(st, val) SKM_sk_find(X509_POLICY_DATA, (st), (val))
#define sk_X509_POLICY_DATA_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_DATA, (st), (val))
#define sk_X509_POLICY_DATA_delete(st, i) SKM_sk_delete(X509_POLICY_DATA, (st), (i))
#define sk_X509_POLICY_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_DATA, (st), (ptr))
#define sk_X509_POLICY_DATA_insert(st, val, i) SKM_sk_insert(X509_POLICY_DATA, (st), (val), (i))
#define sk_X509_POLICY_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_DATA, (st), (cmp))
#define sk_X509_POLICY_DATA_dup(st) SKM_sk_dup(X509_POLICY_DATA, st)
#define sk_X509_POLICY_DATA_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_DATA, (st), (free_func))
#define sk_X509_POLICY_DATA_shift(st) SKM_sk_shift(X509_POLICY_DATA, (st))
#define sk_X509_POLICY_DATA_pop(st) SKM_sk_pop(X509_POLICY_DATA, (st))
#define sk_X509_POLICY_DATA_sort(st) SKM_sk_sort(X509_POLICY_DATA, (st))
#define sk_X509_POLICY_DATA_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_DATA, (st))

#define sk_X509_POLICY_NODE_new(cmp) SKM_sk_new(X509_POLICY_NODE, (cmp))
#define sk_X509_POLICY_NODE_new_null() SKM_sk_new_null(X509_POLICY_NODE)
#define sk_X509_POLICY_NODE_free(st) SKM_sk_free(X509_POLICY_NODE, (st))
#define sk_X509_POLICY_NODE_num(st) SKM_sk_num(X509_POLICY_NODE, (st))
#define sk_X509_POLICY_NODE_value(st, i) SKM_sk_value(X509_POLICY_NODE, (st), (i))
#define sk_X509_POLICY_NODE_set(st, i, val) SKM_sk_set(X509_POLICY_NODE, (st), (i), (val))
#define sk_X509_POLICY_NODE_zero(st) SKM_sk_zero(X509_POLICY_NODE, (st))
#define sk_X509_POLICY_NODE_push(st, val) SKM_sk_push(X509_POLICY_NODE, (st), (val))
#define sk_X509_POLICY_NODE_unshift(st, val) SKM_sk_unshift(X509_POLICY_NODE, (st), (val))
#define sk_X509_POLICY_NODE_find(st, val) SKM_sk_find(X509_POLICY_NODE, (st), (val))
#define sk_X509_POLICY_NODE_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_NODE, (st), (val))
#define sk_X509_POLICY_NODE_delete(st, i) SKM_sk_delete(X509_POLICY_NODE, (st), (i))
#define sk_X509_POLICY_NODE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_NODE, (st), (ptr))
#define sk_X509_POLICY_NODE_insert(st, val, i) SKM_sk_insert(X509_POLICY_NODE, (st), (val), (i))
#define sk_X509_POLICY_NODE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_NODE, (st), (cmp))
#define sk_X509_POLICY_NODE_dup(st) SKM_sk_dup(X509_POLICY_NODE, st)
#define sk_X509_POLICY_NODE_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_NODE, (st), (free_func))
#define sk_X509_POLICY_NODE_shift(st) SKM_sk_shift(X509_POLICY_NODE, (st))
#define sk_X509_POLICY_NODE_pop(st) SKM_sk_pop(X509_POLICY_NODE, (st))
#define sk_X509_POLICY_NODE_sort(st) SKM_sk_sort(X509_POLICY_NODE, (st))
#define sk_X509_POLICY_NODE_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_NODE, (st))

#define sk_X509_PURPOSE_new(cmp) SKM_sk_new(X509_PURPOSE, (cmp))
#define sk_X509_PURPOSE_new_null() SKM_sk_new_null(X509_PURPOSE)
#define sk_X509_PURPOSE_free(st) SKM_sk_free(X509_PURPOSE, (st))
#define sk_X509_PURPOSE_num(st) SKM_sk_num(X509_PURPOSE, (st))
#define sk_X509_PURPOSE_value(st, i) SKM_sk_value(X509_PURPOSE, (st), (i))
#define sk_X509_PURPOSE_set(st, i, val) SKM_sk_set(X509_PURPOSE, (st), (i), (val))
#define sk_X509_PURPOSE_zero(st) SKM_sk_zero(X509_PURPOSE, (st))
#define sk_X509_PURPOSE_push(st, val) SKM_sk_push(X509_PURPOSE, (st), (val))
#define sk_X509_PURPOSE_unshift(st, val) SKM_sk_unshift(X509_PURPOSE, (st), (val))
#define sk_X509_PURPOSE_find(st, val) SKM_sk_find(X509_PURPOSE, (st), (val))
#define sk_X509_PURPOSE_find_ex(st, val) SKM_sk_find_ex(X509_PURPOSE, (st), (val))
#define sk_X509_PURPOSE_delete(st, i) SKM_sk_delete(X509_PURPOSE, (st), (i))
#define sk_X509_PURPOSE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_PURPOSE, (st), (ptr))
#define sk_X509_PURPOSE_insert(st, val, i) SKM_sk_insert(X509_PURPOSE, (st), (val), (i))
#define sk_X509_PURPOSE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_PURPOSE, (st), (cmp))
#define sk_X509_PURPOSE_dup(st) SKM_sk_dup(X509_PURPOSE, st)
#define sk_X509_PURPOSE_pop_free(st, free_func) SKM_sk_pop_free(X509_PURPOSE, (st), (free_func))
#define sk_X509_PURPOSE_shift(st) SKM_sk_shift(X509_PURPOSE, (st))
#define sk_X509_PURPOSE_pop(st) SKM_sk_pop(X509_PURPOSE, (st))
#define sk_X509_PURPOSE_sort(st) SKM_sk_sort(X509_PURPOSE, (st))
#define sk_X509_PURPOSE_is_sorted(st) SKM_sk_is_sorted(X509_PURPOSE, (st))

#define sk_X509_REVOKED_new(cmp) SKM_sk_new(X509_REVOKED, (cmp))
#define sk_X509_REVOKED_new_null() SKM_sk_new_null(X509_REVOKED)
#define sk_X509_REVOKED_free(st) SKM_sk_free(X509_REVOKED, (st))
#define sk_X509_REVOKED_num(st) SKM_sk_num(X509_REVOKED, (st))
#define sk_X509_REVOKED_value(st, i) SKM_sk_value(X509_REVOKED, (st), (i))
#define sk_X509_REVOKED_set(st, i, val) SKM_sk_set(X509_REVOKED, (st), (i), (val))
#define sk_X509_REVOKED_zero(st) SKM_sk_zero(X509_REVOKED, (st))
#define sk_X509_REVOKED_push(st, val) SKM_sk_push(X509_REVOKED, (st), (val))
#define sk_X509_REVOKED_unshift(st, val) SKM_sk_unshift(X509_REVOKED, (st), (val))
#define sk_X509_REVOKED_find(st, val) SKM_sk_find(X509_REVOKED, (st), (val))
#define sk_X509_REVOKED_find_ex(st, val) SKM_sk_find_ex(X509_REVOKED, (st), (val))
#define sk_X509_REVOKED_delete(st, i) SKM_sk_delete(X509_REVOKED, (st), (i))
#define sk_X509_REVOKED_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_REVOKED, (st), (ptr))
#define sk_X509_REVOKED_insert(st, val, i) SKM_sk_insert(X509_REVOKED, (st), (val), (i))
#define sk_X509_REVOKED_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_REVOKED, (st), (cmp))
#define sk_X509_REVOKED_dup(st) SKM_sk_dup(X509_REVOKED, st)
#define sk_X509_REVOKED_pop_free(st, free_func) SKM_sk_pop_free(X509_REVOKED, (st), (free_func))
#define sk_X509_REVOKED_shift(st) SKM_sk_shift(X509_REVOKED, (st))
#define sk_X509_REVOKED_pop(st) SKM_sk_pop(X509_REVOKED, (st))
#define sk_X509_REVOKED_sort(st) SKM_sk_sort(X509_REVOKED, (st))
#define sk_X509_REVOKED_is_sorted(st) SKM_sk_is_sorted(X509_REVOKED, (st))

#define sk_X509_TRUST_new(cmp) SKM_sk_new(X509_TRUST, (cmp))
#define sk_X509_TRUST_new_null() SKM_sk_new_null(X509_TRUST)
#define sk_X509_TRUST_free(st) SKM_sk_free(X509_TRUST, (st))
#define sk_X509_TRUST_num(st) SKM_sk_num(X509_TRUST, (st))
#define sk_X509_TRUST_value(st, i) SKM_sk_value(X509_TRUST, (st), (i))
#define sk_X509_TRUST_set(st, i, val) SKM_sk_set(X509_TRUST, (st), (i), (val))
#define sk_X509_TRUST_zero(st) SKM_sk_zero(X509_TRUST, (st))
#define sk_X509_TRUST_push(st, val) SKM_sk_push(X509_TRUST, (st), (val))
#define sk_X509_TRUST_unshift(st, val) SKM_sk_unshift(X509_TRUST, (st), (val))
#define sk_X509_TRUST_find(st, val) SKM_sk_find(X509_TRUST, (st), (val))
#define sk_X509_TRUST_find_ex(st, val) SKM_sk_find_ex(X509_TRUST, (st), (val))
#define sk_X509_TRUST_delete(st, i) SKM_sk_delete(X509_TRUST, (st), (i))
#define sk_X509_TRUST_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_TRUST, (st), (ptr))
#define sk_X509_TRUST_insert(st, val, i) SKM_sk_insert(X509_TRUST, (st), (val), (i))
#define sk_X509_TRUST_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_TRUST, (st), (cmp))
#define sk_X509_TRUST_dup(st) SKM_sk_dup(X509_TRUST, st)
#define sk_X509_TRUST_pop_free(st, free_func) SKM_sk_pop_free(X509_TRUST, (st), (free_func))
#define sk_X509_TRUST_shift(st) SKM_sk_shift(X509_TRUST, (st))
#define sk_X509_TRUST_pop(st) SKM_sk_pop(X509_TRUST, (st))
#define sk_X509_TRUST_sort(st) SKM_sk_sort(X509_TRUST, (st))
#define sk_X509_TRUST_is_sorted(st) SKM_sk_is_sorted(X509_TRUST, (st))

#define sk_X509_VERIFY_PARAM_new(cmp) SKM_sk_new(X509_VERIFY_PARAM, (cmp))
#define sk_X509_VERIFY_PARAM_new_null() SKM_sk_new_null(X509_VERIFY_PARAM)
#define sk_X509_VERIFY_PARAM_free(st) SKM_sk_free(X509_VERIFY_PARAM, (st))
#define sk_X509_VERIFY_PARAM_num(st) SKM_sk_num(X509_VERIFY_PARAM, (st))
#define sk_X509_VERIFY_PARAM_value(st, i) SKM_sk_value(X509_VERIFY_PARAM, (st), (i))
#define sk_X509_VERIFY_PARAM_set(st, i, val) SKM_sk_set(X509_VERIFY_PARAM, (st), (i), (val))
#define sk_X509_VERIFY_PARAM_zero(st) SKM_sk_zero(X509_VERIFY_PARAM, (st))
#define sk_X509_VERIFY_PARAM_push(st, val) SKM_sk_push(X509_VERIFY_PARAM, (st), (val))
#define sk_X509_VERIFY_PARAM_unshift(st, val) SKM_sk_unshift(X509_VERIFY_PARAM, (st), (val))
#define sk_X509_VERIFY_PARAM_find(st, val) SKM_sk_find(X509_VERIFY_PARAM, (st), (val))
#define sk_X509_VERIFY_PARAM_find_ex(st, val) SKM_sk_find_ex(X509_VERIFY_PARAM, (st), (val))
#define sk_X509_VERIFY_PARAM_delete(st, i) SKM_sk_delete(X509_VERIFY_PARAM, (st), (i))
#define sk_X509_VERIFY_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_VERIFY_PARAM, (st), (ptr))
#define sk_X509_VERIFY_PARAM_insert(st, val, i) SKM_sk_insert(X509_VERIFY_PARAM, (st), (val), (i))
#define sk_X509_VERIFY_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_VERIFY_PARAM, (st), (cmp))
#define sk_X509_VERIFY_PARAM_dup(st) SKM_sk_dup(X509_VERIFY_PARAM, st)
#define sk_X509_VERIFY_PARAM_pop_free(st, free_func) SKM_sk_pop_free(X509_VERIFY_PARAM, (st), (free_func))
#define sk_X509_VERIFY_PARAM_shift(st) SKM_sk_shift(X509_VERIFY_PARAM, (st))
#define sk_X509_VERIFY_PARAM_pop(st) SKM_sk_pop(X509_VERIFY_PARAM, (st))
#define sk_X509_VERIFY_PARAM_sort(st) SKM_sk_sort(X509_VERIFY_PARAM, (st))
#define sk_X509_VERIFY_PARAM_is_sorted(st) SKM_sk_is_sorted(X509_VERIFY_PARAM, (st))

#define sk_nid_triple_new(cmp) SKM_sk_new(nid_triple, (cmp))
#define sk_nid_triple_new_null() SKM_sk_new_null(nid_triple)
#define sk_nid_triple_free(st) SKM_sk_free(nid_triple, (st))
#define sk_nid_triple_num(st) SKM_sk_num(nid_triple, (st))
#define sk_nid_triple_value(st, i) SKM_sk_value(nid_triple, (st), (i))
#define sk_nid_triple_set(st, i, val) SKM_sk_set(nid_triple, (st), (i), (val))
#define sk_nid_triple_zero(st) SKM_sk_zero(nid_triple, (st))
#define sk_nid_triple_push(st, val) SKM_sk_push(nid_triple, (st), (val))
#define sk_nid_triple_unshift(st, val) SKM_sk_unshift(nid_triple, (st), (val))
#define sk_nid_triple_find(st, val) SKM_sk_find(nid_triple, (st), (val))
#define sk_nid_triple_find_ex(st, val) SKM_sk_find_ex(nid_triple, (st), (val))
#define sk_nid_triple_delete(st, i) SKM_sk_delete(nid_triple, (st), (i))
#define sk_nid_triple_delete_ptr(st, ptr) SKM_sk_delete_ptr(nid_triple, (st), (ptr))
#define sk_nid_triple_insert(st, val, i) SKM_sk_insert(nid_triple, (st), (val), (i))
#define sk_nid_triple_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(nid_triple, (st), (cmp))
#define sk_nid_triple_dup(st) SKM_sk_dup(nid_triple, st)
#define sk_nid_triple_pop_free(st, free_func) SKM_sk_pop_free(nid_triple, (st), (free_func))
#define sk_nid_triple_shift(st) SKM_sk_shift(nid_triple, (st))
#define sk_nid_triple_pop(st) SKM_sk_pop(nid_triple, (st))
#define sk_nid_triple_sort(st) SKM_sk_sort(nid_triple, (st))
#define sk_nid_triple_is_sorted(st) SKM_sk_is_sorted(nid_triple, (st))

#define sk_void_new(cmp) SKM_sk_new(void, (cmp))
#define sk_void_new_null() SKM_sk_new_null(void)
#define sk_void_free(st) SKM_sk_free(void, (st))
#define sk_void_num(st) SKM_sk_num(void, (st))
#define sk_void_value(st, i) SKM_sk_value(void, (st), (i))
#define sk_void_set(st, i, val) SKM_sk_set(void, (st), (i), (val))
#define sk_void_zero(st) SKM_sk_zero(void, (st))
#define sk_void_push(st, val) SKM_sk_push(void, (st), (val))
#define sk_void_unshift(st, val) SKM_sk_unshift(void, (st), (val))
#define sk_void_find(st, val) SKM_sk_find(void, (st), (val))
#define sk_void_find_ex(st, val) SKM_sk_find_ex(void, (st), (val))
#define sk_void_delete(st, i) SKM_sk_delete(void, (st), (i))
#define sk_void_delete_ptr(st, ptr) SKM_sk_delete_ptr(void, (st), (ptr))
#define sk_void_insert(st, val, i) SKM_sk_insert(void, (st), (val), (i))
#define sk_void_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(void, (st), (cmp))
#define sk_void_dup(st) SKM_sk_dup(void, st)
#define sk_void_pop_free(st, free_func) SKM_sk_pop_free(void, (st), (free_func))
#define sk_void_shift(st) SKM_sk_shift(void, (st))
#define sk_void_pop(st) SKM_sk_pop(void, (st))
#define sk_void_sort(st) SKM_sk_sort(void, (st))
#define sk_void_is_sorted(st) SKM_sk_is_sorted(void, (st))

#define sk_OPENSSL_STRING_new(cmp) ((STACK_OF(OPENSSL_STRING) *)sk_new(CHECKED_SK_CMP_FUNC(char, cmp)))
#define sk_OPENSSL_STRING_new_null() ((STACK_OF(OPENSSL_STRING) *)sk_new_null())
#define sk_OPENSSL_STRING_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val))
#define sk_OPENSSL_STRING_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val))
#define sk_OPENSSL_STRING_value(st, i) ((OPENSSL_STRING)sk_value(CHECKED_STACK_OF(OPENSSL_STRING, st), i))
#define sk_OPENSSL_STRING_num(st) SKM_sk_num(OPENSSL_STRING, st)
#define sk_OPENSSL_STRING_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_SK_FREE_FUNC2(OPENSSL_STRING, free_func))
#define sk_OPENSSL_STRING_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val), i)
#define sk_OPENSSL_STRING_free(st) SKM_sk_free(OPENSSL_STRING, st)
#define sk_OPENSSL_STRING_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_STRING, st), i, CHECKED_PTR_OF(char, val))
#define sk_OPENSSL_STRING_zero(st) SKM_sk_zero(OPENSSL_STRING, (st))
#define sk_OPENSSL_STRING_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val))
#define sk_OPENSSL_STRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_CONST_PTR_OF(char, val))
#define sk_OPENSSL_STRING_delete(st, i) SKM_sk_delete(OPENSSL_STRING, (st), (i))
#define sk_OPENSSL_STRING_delete_ptr(st, ptr) (OPENSSL_STRING *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, ptr))
#define sk_OPENSSL_STRING_set_cmp_func(st, cmp)  \
	((int (*)(const char * const *,const char * const *)) \
	sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_SK_CMP_FUNC(char, cmp)))
#define sk_OPENSSL_STRING_dup(st) SKM_sk_dup(OPENSSL_STRING, st)
#define sk_OPENSSL_STRING_shift(st) SKM_sk_shift(OPENSSL_STRING, (st))
#define sk_OPENSSL_STRING_pop(st) (char *)sk_pop(CHECKED_STACK_OF(OPENSSL_STRING, st))
#define sk_OPENSSL_STRING_sort(st) SKM_sk_sort(OPENSSL_STRING, (st))
#define sk_OPENSSL_STRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_STRING, (st))


#define sk_OPENSSL_BLOCK_new(cmp) ((STACK_OF(OPENSSL_BLOCK) *)sk_new(CHECKED_SK_CMP_FUNC(void, cmp)))
#define sk_OPENSSL_BLOCK_new_null() ((STACK_OF(OPENSSL_BLOCK) *)sk_new_null())
#define sk_OPENSSL_BLOCK_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))
#define sk_OPENSSL_BLOCK_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))
#define sk_OPENSSL_BLOCK_value(st, i) ((OPENSSL_BLOCK)sk_value(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i))
#define sk_OPENSSL_BLOCK_num(st) SKM_sk_num(OPENSSL_BLOCK, st)
#define sk_OPENSSL_BLOCK_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_FREE_FUNC2(OPENSSL_BLOCK, free_func))
#define sk_OPENSSL_BLOCK_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val), i)
#define sk_OPENSSL_BLOCK_free(st) SKM_sk_free(OPENSSL_BLOCK, st)
#define sk_OPENSSL_BLOCK_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i, CHECKED_PTR_OF(void, val))
#define sk_OPENSSL_BLOCK_zero(st) SKM_sk_zero(OPENSSL_BLOCK, (st))
#define sk_OPENSSL_BLOCK_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))
#define sk_OPENSSL_BLOCK_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_CONST_PTR_OF(void, val))
#define sk_OPENSSL_BLOCK_delete(st, i) SKM_sk_delete(OPENSSL_BLOCK, (st), (i))
#define sk_OPENSSL_BLOCK_delete_ptr(st, ptr) (OPENSSL_BLOCK *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, ptr))
#define sk_OPENSSL_BLOCK_set_cmp_func(st, cmp)  \
	((int (*)(const void * const *,const void * const *)) \
	sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_CMP_FUNC(void, cmp)))
#define sk_OPENSSL_BLOCK_dup(st) SKM_sk_dup(OPENSSL_BLOCK, st)
#define sk_OPENSSL_BLOCK_shift(st) SKM_sk_shift(OPENSSL_BLOCK, (st))
#define sk_OPENSSL_BLOCK_pop(st) (void *)sk_pop(CHECKED_STACK_OF(OPENSSL_BLOCK, st))
#define sk_OPENSSL_BLOCK_sort(st) SKM_sk_sort(OPENSSL_BLOCK, (st))
#define sk_OPENSSL_BLOCK_is_sorted(st) SKM_sk_is_sorted(OPENSSL_BLOCK, (st))


#define sk_OPENSSL_PSTRING_new(cmp) ((STACK_OF(OPENSSL_PSTRING) *)sk_new(CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))
#define sk_OPENSSL_PSTRING_new_null() ((STACK_OF(OPENSSL_PSTRING) *)sk_new_null())
#define sk_OPENSSL_PSTRING_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))
#define sk_OPENSSL_PSTRING_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))
#define sk_OPENSSL_PSTRING_value(st, i) ((OPENSSL_PSTRING)sk_value(CHECKED_STACK_OF(OPENSSL_PSTRING, st), i))
#define sk_OPENSSL_PSTRING_num(st) SKM_sk_num(OPENSSL_PSTRING, st)
#define sk_OPENSSL_PSTRING_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_FREE_FUNC2(OPENSSL_PSTRING, free_func))
#define sk_OPENSSL_PSTRING_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val), i)
#define sk_OPENSSL_PSTRING_free(st) SKM_sk_free(OPENSSL_PSTRING, st)
#define sk_OPENSSL_PSTRING_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_PSTRING, st), i, CHECKED_PTR_OF(OPENSSL_STRING, val))
#define sk_OPENSSL_PSTRING_zero(st) SKM_sk_zero(OPENSSL_PSTRING, (st))
#define sk_OPENSSL_PSTRING_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))
#define sk_OPENSSL_PSTRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_CONST_PTR_OF(OPENSSL_STRING, val))
#define sk_OPENSSL_PSTRING_delete(st, i) SKM_sk_delete(OPENSSL_PSTRING, (st), (i))
#define sk_OPENSSL_PSTRING_delete_ptr(st, ptr) (OPENSSL_PSTRING *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, ptr))
#define sk_OPENSSL_PSTRING_set_cmp_func(st, cmp)  \
	((int (*)(const OPENSSL_STRING * const *,const OPENSSL_STRING * const *)) \
	sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))
#define sk_OPENSSL_PSTRING_dup(st) SKM_sk_dup(OPENSSL_PSTRING, st)
#define sk_OPENSSL_PSTRING_shift(st) SKM_sk_shift(OPENSSL_PSTRING, (st))
#define sk_OPENSSL_PSTRING_pop(st) (OPENSSL_STRING *)sk_pop(CHECKED_STACK_OF(OPENSSL_PSTRING, st))
#define sk_OPENSSL_PSTRING_sort(st) SKM_sk_sort(OPENSSL_PSTRING, (st))
#define sk_OPENSSL_PSTRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_PSTRING, (st))


#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(ACCESS_DESCRIPTION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(ACCESS_DESCRIPTION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_ACCESS_DESCRIPTION(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(ACCESS_DESCRIPTION, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_ACCESS_DESCRIPTION(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(ACCESS_DESCRIPTION, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_ASN1_INTEGER(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(ASN1_INTEGER, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_ASN1_INTEGER(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(ASN1_INTEGER, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_ASN1_INTEGER(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(ASN1_INTEGER, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_ASN1_INTEGER(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(ASN1_INTEGER, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_ASN1_OBJECT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(ASN1_OBJECT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_ASN1_OBJECT(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(ASN1_OBJECT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_ASN1_OBJECT(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(ASN1_OBJECT, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_ASN1_OBJECT(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(ASN1_OBJECT, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_ASN1_TYPE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(ASN1_TYPE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_ASN1_TYPE(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(ASN1_TYPE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_ASN1_TYPE(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(ASN1_TYPE, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_ASN1_TYPE(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(ASN1_TYPE, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_ASN1_UTF8STRING(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(ASN1_UTF8STRING, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_ASN1_UTF8STRING(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(ASN1_UTF8STRING, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_ASN1_UTF8STRING(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(ASN1_UTF8STRING, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_ASN1_UTF8STRING(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(ASN1_UTF8STRING, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_DIST_POINT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(DIST_POINT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_DIST_POINT(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(DIST_POINT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_DIST_POINT(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(DIST_POINT, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_DIST_POINT(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(DIST_POINT, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_ESS_CERT_ID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(ESS_CERT_ID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_ESS_CERT_ID(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(ESS_CERT_ID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_ESS_CERT_ID(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(ESS_CERT_ID, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_ESS_CERT_ID(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(ESS_CERT_ID, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_EVP_MD(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(EVP_MD, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_EVP_MD(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(EVP_MD, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_EVP_MD(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(EVP_MD, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_EVP_MD(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(EVP_MD, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_GENERAL_NAME(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(GENERAL_NAME, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_GENERAL_NAME(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(GENERAL_NAME, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_GENERAL_NAME(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(GENERAL_NAME, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_GENERAL_NAME(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(GENERAL_NAME, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_OCSP_ONEREQ(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(OCSP_ONEREQ, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_OCSP_ONEREQ(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(OCSP_ONEREQ, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_OCSP_ONEREQ(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(OCSP_ONEREQ, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_OCSP_ONEREQ(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(OCSP_ONEREQ, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(OCSP_SINGLERESP, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(OCSP_SINGLERESP, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_OCSP_SINGLERESP(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(OCSP_SINGLERESP, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_OCSP_SINGLERESP(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(OCSP_SINGLERESP, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(PKCS12_SAFEBAG, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(PKCS12_SAFEBAG, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_PKCS12_SAFEBAG(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(PKCS12_SAFEBAG, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_PKCS12_SAFEBAG(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(PKCS12_SAFEBAG, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_PKCS7(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(PKCS7, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_PKCS7(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(PKCS7, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_PKCS7(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(PKCS7, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_PKCS7(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(PKCS7, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(PKCS7_RECIP_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(PKCS7_RECIP_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_PKCS7_RECIP_INFO(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(PKCS7_RECIP_INFO, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_PKCS7_RECIP_INFO(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(PKCS7_RECIP_INFO, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(PKCS7_SIGNER_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(PKCS7_SIGNER_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_PKCS7_SIGNER_INFO(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(PKCS7_SIGNER_INFO, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_PKCS7_SIGNER_INFO(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(PKCS7_SIGNER_INFO, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_POLICYINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(POLICYINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_POLICYINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(POLICYINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_POLICYINFO(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(POLICYINFO, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_POLICYINFO(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(POLICYINFO, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_POLICYQUALINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(POLICYQUALINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_POLICYQUALINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(POLICYQUALINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_POLICYQUALINFO(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(POLICYQUALINFO, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_POLICYQUALINFO(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(POLICYQUALINFO, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_SXNETID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(SXNETID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_SXNETID(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(SXNETID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_SXNETID(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(SXNETID, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_SXNETID(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(SXNETID, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_X509(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(X509, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_X509(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(X509, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_X509(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(X509, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_X509(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(X509, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_X509_ALGOR(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(X509_ALGOR, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_X509_ALGOR(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(X509_ALGOR, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_X509_ALGOR(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(X509_ALGOR, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_X509_ALGOR(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(X509_ALGOR, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(X509_ATTRIBUTE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(X509_ATTRIBUTE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_X509_ATTRIBUTE(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(X509_ATTRIBUTE, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_X509_ATTRIBUTE(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(X509_ATTRIBUTE, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_X509_CRL(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(X509_CRL, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_X509_CRL(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(X509_CRL, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_X509_CRL(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(X509_CRL, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_X509_CRL(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(X509_CRL, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_X509_EXTENSION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(X509_EXTENSION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_X509_EXTENSION(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(X509_EXTENSION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_X509_EXTENSION(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(X509_EXTENSION, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_X509_EXTENSION(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(X509_EXTENSION, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(X509_NAME_ENTRY, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(X509_NAME_ENTRY, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_X509_NAME_ENTRY(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(X509_NAME_ENTRY, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_X509_NAME_ENTRY(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(X509_NAME_ENTRY, (buf), (len), (d2i_func), (free_func))

#define d2i_ASN1_SET_OF_X509_REVOKED(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
	SKM_ASN1_SET_OF_d2i(X509_REVOKED, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 
#define i2d_ASN1_SET_OF_X509_REVOKED(st, pp, i2d_func, ex_tag, ex_class, is_set) \
	SKM_ASN1_SET_OF_i2d(X509_REVOKED, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
#define ASN1_seq_pack_X509_REVOKED(st, i2d_func, buf, len) \
	SKM_ASN1_seq_pack(X509_REVOKED, (st), (i2d_func), (buf), (len))
#define ASN1_seq_unpack_X509_REVOKED(buf, len, d2i_func, free_func) \
	SKM_ASN1_seq_unpack(X509_REVOKED, (buf), (len), (d2i_func), (free_func))

#define PKCS12_decrypt_d2i_PKCS12_SAFEBAG(algor, d2i_func, free_func, pass, passlen, oct, seq) \
	SKM_PKCS12_decrypt_d2i(PKCS12_SAFEBAG, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))

#define PKCS12_decrypt_d2i_PKCS7(algor, d2i_func, free_func, pass, passlen, oct, seq) \
	SKM_PKCS12_decrypt_d2i(PKCS7, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))

#define lh_ADDED_OBJ_new() LHM_lh_new(ADDED_OBJ,added_obj)
#define lh_ADDED_OBJ_insert(lh,inst) LHM_lh_insert(ADDED_OBJ,lh,inst)
#define lh_ADDED_OBJ_retrieve(lh,inst) LHM_lh_retrieve(ADDED_OBJ,lh,inst)
#define lh_ADDED_OBJ_delete(lh,inst) LHM_lh_delete(ADDED_OBJ,lh,inst)
#define lh_ADDED_OBJ_doall(lh,fn) LHM_lh_doall(ADDED_OBJ,lh,fn)
#define lh_ADDED_OBJ_doall_arg(lh,fn,arg_type,arg) \
  LHM_lh_doall_arg(ADDED_OBJ,lh,fn,arg_type,arg)
#define lh_ADDED_OBJ_error(lh) LHM_lh_error(ADDED_OBJ,lh)
#define lh_ADDED_OBJ_num_items(lh) LHM_lh_num_items(ADDED_OBJ,lh)
#define lh_ADDED_OBJ_down_load(lh) LHM_lh_down_load(ADDED_OBJ,lh)
#define lh_ADDED_OBJ_node_stats_bio(lh,out) \
  LHM_lh_node_stats_bio(ADDED_OBJ,lh,out)
#define lh_ADDED_OBJ_node_usage_stats_bio(lh,out) \
  LHM_lh_node_usage_stats_bio(ADDED_OBJ,lh,out)
#define lh_ADDED_OBJ_stats_bio(lh,out) \
  LHM_lh_stats_bio(ADDED_OBJ,lh,out)
#define lh_ADDED_OBJ_free(lh) LHM_lh_free(ADDED_OBJ,lh)

#define lh_APP_INFO_new() LHM_lh_new(APP_INFO,app_info)
#define lh_APP_INFO_insert(lh,inst) LHM_lh_insert(APP_INFO,lh,inst)
#define lh_APP_INFO_retrieve(lh,inst) LHM_lh_retrieve(APP_INFO,lh,inst)
#define lh_APP_INFO_delete(lh,inst) LHM_lh_delete(APP_INFO,lh,inst)
#define lh_APP_INFO_doall(lh,fn) LHM_lh_doall(APP_INFO,lh,fn)
#define lh_APP_INFO_doall_arg(lh,fn,arg_type,arg) \
  LHM_lh_doall_arg(APP_INFO,lh,fn,arg_type,arg)
#define lh_APP_INFO_error(lh) LHM_lh_error(APP_INFO,lh)
#define lh_APP_INFO_num_items(lh) LHM_lh_num_items(APP_INFO,lh)
#define lh_APP_INFO_down_load(lh) LHM_lh_down_load(APP_INFO,lh)
#define lh_APP_INFO_node_stats_bio(lh,out) \
  LHM_lh_node_stats_bio(APP_INFO,lh,out)
#define lh_APP_INFO_node_usage_stats_bio(lh,out) \
  LHM_lh_node_usage_stats_bio(APP_INFO,lh,out)
#define lh_APP_INFO_stats_bio(lh,out) \
  LHM_lh_stats_bio(APP_INFO,lh,out)
#define lh_APP_INFO_free(lh) LHM_lh_free(APP_INFO,lh)

#define lh_CONF_VALUE_new() LHM_lh_new(CONF_VALUE,conf_value)
#define lh_CONF_VALUE_insert(lh,inst) LHM_lh_insert(CONF_VALUE,lh,inst)
#define lh_CONF_VALUE_retrieve(lh,inst) LHM_lh_retrieve(CONF_VALUE,lh,inst)
#define lh_CONF_VALUE_delete(lh,inst) LHM_lh_delete(CONF_VALUE,lh,inst)
#define lh_CONF_VALUE_doall(lh,fn) LHM_lh_doall(CONF_VALUE,lh,fn)
#define lh_CONF_VALUE_doall_arg(lh,fn,arg_type,arg) \
  LHM_lh_doall_arg(CONF_VALUE,lh,fn,arg_type,arg)
#define lh_CONF_VALUE_error(lh) LHM_lh_error(CONF_VALUE,lh)
#define lh_CONF_VALUE_num_items(lh) LHM_lh_num_items(CONF_VALUE,lh)
#define lh_CONF_VALUE_down_load(lh) LHM_lh_down_load(CONF_VALUE,lh)
#define lh_CONF_VALUE_node_stats_bio(lh,out) \
  LHM_lh_node_stats_bio(CONF_VALUE,lh,out)
#define lh_CONF_VALUE_node_usage_stats_bio(lh,out) \
  LHM_lh_node_usage_stats_bio(CONF_VALUE,lh,out)
#define lh_CONF_VALUE_stats_bio(lh,out) \
  LHM_lh_stats_bio(CONF_VALUE,lh,out)
#define lh_CONF_VALUE_free(lh) LHM_lh_free(CONF_VALUE,lh)

#define lh_ENGINE_PILE_new() LHM_lh_new(ENGINE_PILE,engine_pile)
#define lh_ENGINE_PILE_insert(lh,inst) LHM_lh_insert(ENGINE_PILE,lh,inst)
#define lh_ENGINE_PILE_retrieve(lh,inst) LHM_lh_retrieve(ENGINE_PILE,lh,inst)
#define lh_ENGINE_PILE_delete(lh,inst) LHM_lh_delete(ENGINE_PILE,lh,inst)
#define lh_ENGINE_PILE_doall(lh,fn) LHM_lh_doall(ENGINE_PILE,lh,fn)
#define lh_ENGINE_PILE_doall_arg(lh,fn,arg_type,arg) \
  LHM_lh_doall_arg(ENGINE_PILE,lh,fn,arg_type,arg)
#define lh_ENGINE_PILE_error(lh) LHM_lh_error(ENGINE_PILE,lh)
#define lh_ENGINE_PILE_num_items(lh) LHM_lh_num_items(ENGINE_PILE,lh)
#define lh_ENGINE_PILE_down_load(lh) LHM_lh_down_load(ENGINE_PILE,lh)
#define lh_ENGINE_PILE_node_stats_bio(lh,out) \
  LHM_lh_node_stats_bio(ENGINE_PILE,lh,out)
#define lh_ENGINE_PILE_node_usage_stats_bio(lh,out) \
  LHM_lh_node_usage_stats_bio(ENGINE_PILE,lh,out)
#define lh_ENGINE_PILE_stats_bio(lh,out) \
  LHM_lh_stats_bio(ENGINE_PILE,lh,out)
#define lh_ENGINE_PILE_free(lh) LHM_lh_free(ENGINE_PILE,lh)

#define lh_ERR_STATE_new() LHM_lh_new(ERR_STATE,err_state)
#define lh_ERR_STATE_insert(lh,inst) LHM_lh_insert(ERR_STATE,lh,inst)
#define lh_ERR_STATE_retrieve(lh,inst) LHM_lh_retrieve(ERR_STATE,lh,inst)
#define lh_ERR_STATE_delete(lh,inst) LHM_lh_delete(ERR_STATE,lh,inst)
#define lh_ERR_STATE_doall(lh,fn) LHM_lh_doall(ERR_STATE,lh,fn)
#define lh_ERR_STATE_doall_arg(lh,fn,arg_type,arg) \
  LHM_lh_doall_arg(ERR_STATE,lh,fn,arg_type,arg)
#define lh_ERR_STATE_error(lh) LHM_lh_error(ERR_STATE,lh)
#define lh_ERR_STATE_num_items(lh) LHM_lh_num_items(ERR_STATE,lh)
#define lh_ERR_STATE_down_load(lh) LHM_lh_down_load(ERR_STATE,lh)
#define lh_ERR_STATE_node_stats_bio(lh,out) \
  LHM_lh_node_stats_bio(ERR_STATE,lh,out)
#define lh_ERR_STATE_node_usage_stats_bio(lh,out) \
  LHM_lh_node_usage_stats_bio(ERR_STATE,lh,out)
#define lh_ERR_STATE_stats_bio(lh,out) \
  LHM_lh_stats_bio(ERR_STATE,lh,out)
#define lh_ERR_STATE_free(lh) LHM_lh_free(ERR_STATE,lh)

#define lh_ERR_STRING_DATA_new() LHM_lh_new(ERR_STRING_DATA,err_string_data)
#define lh_ERR_STRING_DATA_insert(lh,inst) LHM_lh_insert(ERR_STRING_DATA,lh,inst)
#define lh_ERR_STRING_DATA_retrieve(lh,inst) LHM_lh_retrieve(ERR_STRING_DATA,lh,inst)
#define lh_ERR_STRING_DATA_delete(lh,inst) LHM_lh_delete(ERR_STRING_DATA,lh,inst)
#define lh_ERR_STRING_DATA_doall(lh,fn) LHM_lh_doall(ERR_STRING_DATA,lh,fn)
#define lh_ERR_STRING_DATA_doall_arg(lh,fn,arg_type,arg) \
  LHM_lh_doall_arg(ERR_STRING_DATA,lh,fn,arg_type,arg)
#define lh_ERR_STRING_DATA_error(lh) LHM_lh_error(ERR_STRING_DATA,lh)
#define lh_ERR_STRING_DATA_num_items(lh) LHM_lh_num_items(ERR_STRING_DATA,lh)
#define lh_ERR_STRING_DATA_down_load(lh) LHM_lh_down_load(ERR_STRING_DATA,lh)
#define lh_ERR_STRING_DATA_node_stats_bio(lh,out) \
  LHM_lh_node_stats_bio(ERR_STRING_DATA,lh,out)
#define lh_ERR_STRING_DATA_node_usage_stats_bio(lh,out) \
  LHM_lh_node_usage_stats_bio(ERR_STRING_DATA,lh,out)
#define lh_ERR_STRING_DATA_stats_bio(lh,out) \
  LHM_lh_stats_bio(ERR_STRING_DATA,lh,out)
#define lh_ERR_STRING_DATA_free(lh) LHM_lh_free(ERR_STRING_DATA,lh)

#define lh_EX_CLASS_ITEM_new() LHM_lh_new(EX_CLASS_ITEM,ex_class_item)
#define lh_EX_CLASS_ITEM_insert(lh,inst) LHM_lh_insert(EX_CLASS_ITEM,lh,inst)
#define lh_EX_CLASS_ITEM_retrieve(lh,inst) LHM_lh_retrieve(EX_CLASS_ITEM,lh,inst)
#define lh_EX_CLASS_ITEM_delete(lh,inst) LHM_lh_delete(EX_CLASS_ITEM,lh,inst)
#define lh_EX_CLASS_ITEM_doall(lh,fn) LHM_lh_doall(EX_CLASS_ITEM,lh,fn)
#define lh_EX_CLASS_ITEM_doall_arg(lh,fn,arg_type,arg) \
  LHM_lh_doall_arg(EX_CLASS_ITEM,lh,fn,arg_type,arg)
#define lh_EX_CLASS_ITEM_error(lh) LHM_lh_error(EX_CLASS_ITEM,lh)
#define lh_EX_CLASS_ITEM_num_items(lh) LHM_lh_num_items(EX_CLASS_ITEM,lh)
#define lh_EX_CLASS_ITEM_down_load(lh) LHM_lh_down_load(EX_CLASS_ITEM,lh)
#define lh_EX_CLASS_ITEM_node_stats_bio(lh,out) \
  LHM_lh_node_stats_bio(EX_CLASS_ITEM,lh,out)
#define lh_EX_CLASS_ITEM_node_usage_stats_bio(lh,out) \
  LHM_lh_node_usage_stats_bio(EX_CLASS_ITEM,lh,out)
#define lh_EX_CLASS_ITEM_stats_bio(lh,out) \
  LHM_lh_stats_bio(EX_CLASS_ITEM,lh,out)
#define lh_EX_CLASS_ITEM_free(lh) LHM_lh_free(EX_CLASS_ITEM,lh)

#define lh_FUNCTION_new() LHM_lh_new(FUNCTION,function)
#define lh_FUNCTION_insert(lh,inst) LHM_lh_insert(FUNCTION,lh,inst)
#define lh_FUNCTION_retrieve(lh,inst) LHM_lh_retrieve(FUNCTION,lh,inst)
#define lh_FUNCTION_delete(lh,inst) LHM_lh_delete(FUNCTION,lh,inst)
#define lh_FUNCTION_doall(lh,fn) LHM_lh_doall(FUNCTION,lh,fn)
#define lh_FUNCTION_doall_arg(lh,fn,arg_type,arg) \
  LHM_lh_doall_arg(FUNCTION,lh,fn,arg_type,arg)
#define lh_FUNCTION_error(lh) LHM_lh_error(FUNCTION,lh)
#define lh_FUNCTION_num_items(lh) LHM_lh_num_items(FUNCTION,lh)
#define lh_FUNCTION_down_load(lh) LHM_lh_down_load(FUNCTION,lh)
#define lh_FUNCTION_node_stats_bio(lh,out) \
  LHM_lh_node_stats_bio(FUNCTION,lh,out)
#define lh_FUNCTION_node_usage_stats_bio(lh,out) \
  LHM_lh_node_usage_stats_bio(FUNCTION,lh,out)
#define lh_FUNCTION_stats_bio(lh,out) \
  LHM_lh_stats_bio(FUNCTION,lh,out)
#define lh_FUNCTION_free(lh) LHM_lh_free(FUNCTION,lh)

#define lh_MEM_new() LHM_lh_new(MEM,mem)
#define lh_MEM_insert(lh,inst) LHM_lh_insert(MEM,lh,inst)
#define lh_MEM_retrieve(lh,inst) LHM_lh_retrieve(MEM,lh,inst)
#define lh_MEM_delete(lh,inst) LHM_lh_delete(MEM,lh,inst)
#define lh_MEM_doall(lh,fn) LHM_lh_doall(MEM,lh,fn)
#define lh_MEM_doall_arg(lh,fn,arg_type,arg) \
  LHM_lh_doall_arg(MEM,lh,fn,arg_type,arg)
#define lh_MEM_error(lh) LHM_lh_error(MEM,lh)
#define lh_MEM_num_items(lh) LHM_lh_num_items(MEM,lh)
#define lh_MEM_down_load(lh) LHM_lh_down_load(MEM,lh)
#define lh_MEM_node_stats_bio(lh,out) \
  LHM_lh_node_stats_bio(MEM,lh,out)
#define lh_MEM_node_usage_stats_bio(lh,out) \
  LHM_lh_node_usage_stats_bio(MEM,lh,out)
#define lh_MEM_stats_bio(lh,out) \
  LHM_lh_stats_bio(MEM,lh,out)
#define lh_MEM_free(lh) LHM_lh_free(MEM,lh)

#define lh_OBJ_NAME_new() LHM_lh_new(OBJ_NAME,obj_name)
#define lh_OBJ_NAME_insert(lh,inst) LHM_lh_insert(OBJ_NAME,lh,inst)
#define lh_OBJ_NAME_retrieve(lh,inst) LHM_lh_retrieve(OBJ_NAME,lh,inst)
#define lh_OBJ_NAME_delete(lh,inst) LHM_lh_delete(OBJ_NAME,lh,inst)
#define lh_OBJ_NAME_doall(lh,fn) LHM_lh_doall(OBJ_NAME,lh,fn)
#define lh_OBJ_NAME_doall_arg(lh,fn,arg_type,arg) \
  LHM_lh_doall_arg(OBJ_NAME,lh,fn,arg_type,arg)
#define lh_OBJ_NAME_error(lh) LHM_lh_error(OBJ_NAME,lh)
#define lh_OBJ_NAME_num_items(lh) LHM_lh_num_items(OBJ_NAME,lh)
#define lh_OBJ_NAME_down_load(lh) LHM_lh_down_load(OBJ_NAME,lh)
#define lh_OBJ_NAME_node_stats_bio(lh,out) \
  LHM_lh_node_stats_bio(OBJ_NAME,lh,out)
#define lh_OBJ_NAME_node_usage_stats_bio(lh,out) \
  LHM_lh_node_usage_stats_bio(OBJ_NAME,lh,out)
#define lh_OBJ_NAME_stats_bio(lh,out) \
  LHM_lh_stats_bio(OBJ_NAME,lh,out)
#define lh_OBJ_NAME_free(lh) LHM_lh_free(OBJ_NAME,lh)

#define lh_OPENSSL_CSTRING_new() LHM_lh_new(OPENSSL_CSTRING,openssl_cstring)
#define lh_OPENSSL_CSTRING_insert(lh,inst) LHM_lh_insert(OPENSSL_CSTRING,lh,inst)
#define lh_OPENSSL_CSTRING_retrieve(lh,inst) LHM_lh_retrieve(OPENSSL_CSTRING,lh,inst)
#define lh_OPENSSL_CSTRING_delete(lh,inst) LHM_lh_delete(OPENSSL_CSTRING,lh,inst)
#define lh_OPENSSL_CSTRING_doall(lh,fn) LHM_lh_doall(OPENSSL_CSTRING,lh,fn)
#define lh_OPENSSL_CSTRING_doall_arg(lh,fn,arg_type,arg) \
  LHM_lh_doall_arg(OPENSSL_CSTRING,lh,fn,arg_type,arg)
#define lh_OPENSSL_CSTRING_error(lh) LHM_lh_error(OPENSSL_CSTRING,lh)
#define lh_OPENSSL_CSTRING_num_items(lh) LHM_lh_num_items(OPENSSL_CSTRING,lh)
#define lh_OPENSSL_CSTRING_down_load(lh) LHM_lh_down_load(OPENSSL_CSTRING,lh)
#define lh_OPENSSL_CSTRING_node_stats_bio(lh,out) \
  LHM_lh_node_stats_bio(OPENSSL_CSTRING,lh,out)
#define lh_OPENSSL_CSTRING_node_usage_stats_bio(lh,out) \
  LHM_lh_node_usage_stats_bio(OPENSSL_CSTRING,lh,out)
#define lh_OPENSSL_CSTRING_stats_bio(lh,out) \
  LHM_lh_stats_bio(OPENSSL_CSTRING,lh,out)
#define lh_OPENSSL_CSTRING_free(lh) LHM_lh_free(OPENSSL_CSTRING,lh)

#define lh_OPENSSL_STRING_new() LHM_lh_new(OPENSSL_STRING,openssl_string)
#define lh_OPENSSL_STRING_insert(lh,inst) LHM_lh_insert(OPENSSL_STRING,lh,inst)
#define lh_OPENSSL_STRING_retrieve(lh,inst) LHM_lh_retrieve(OPENSSL_STRING,lh,inst)
#define lh_OPENSSL_STRING_delete(lh,inst) LHM_lh_delete(OPENSSL_STRING,lh,inst)
#define lh_OPENSSL_STRING_doall(lh,fn) LHM_lh_doall(OPENSSL_STRING,lh,fn)
#define lh_OPENSSL_STRING_doall_arg(lh,fn,arg_type,arg) \
  LHM_lh_doall_arg(OPENSSL_STRING,lh,fn,arg_type,arg)
#define lh_OPENSSL_STRING_error(lh) LHM_lh_error(OPENSSL_STRING,lh)
#define lh_OPENSSL_STRING_num_items(lh) LHM_lh_num_items(OPENSSL_STRING,lh)
#define lh_OPENSSL_STRING_down_load(lh) LHM_lh_down_load(OPENSSL_STRING,lh)
#define lh_OPENSSL_STRING_node_stats_bio(lh,out) \
  LHM_lh_node_stats_bio(OPENSSL_STRING,lh,out)
#define lh_OPENSSL_STRING_node_usage_stats_bio(lh,out) \
  LHM_lh_node_usage_stats_bio(OPENSSL_STRING,lh,out)
#define lh_OPENSSL_STRING_stats_bio(lh,out) \
  LHM_lh_stats_bio(OPENSSL_STRING,lh,out)
#define lh_OPENSSL_STRING_free(lh) LHM_lh_free(OPENSSL_STRING,lh)

#define lh_SSL_SESSION_new() LHM_lh_new(SSL_SESSION,ssl_session)
#define lh_SSL_SESSION_insert(lh,inst) LHM_lh_insert(SSL_SESSION,lh,inst)
#define lh_SSL_SESSION_retrieve(lh,inst) LHM_lh_retrieve(SSL_SESSION,lh,inst)
#define lh_SSL_SESSION_delete(lh,inst) LHM_lh_delete(SSL_SESSION,lh,inst)
#define lh_SSL_SESSION_doall(lh,fn) LHM_lh_doall(SSL_SESSION,lh,fn)
#define lh_SSL_SESSION_doall_arg(lh,fn,arg_type,arg) \
  LHM_lh_doall_arg(SSL_SESSION,lh,fn,arg_type,arg)
#define lh_SSL_SESSION_error(lh) LHM_lh_error(SSL_SESSION,lh)
#define lh_SSL_SESSION_num_items(lh) LHM_lh_num_items(SSL_SESSION,lh)
#define lh_SSL_SESSION_down_load(lh) LHM_lh_down_load(SSL_SESSION,lh)
#define lh_SSL_SESSION_node_stats_bio(lh,out) \
  LHM_lh_node_stats_bio(SSL_SESSION,lh,out)
#define lh_SSL_SESSION_node_usage_stats_bio(lh,out) \
  LHM_lh_node_usage_stats_bio(SSL_SESSION,lh,out)
#define lh_SSL_SESSION_stats_bio(lh,out) \
  LHM_lh_stats_bio(SSL_SESSION,lh,out)
#define lh_SSL_SESSION_free(lh) LHM_lh_free(SSL_SESSION,lh)
/* End of util/mkstack.pl block, you may now edit :-) */

#endif /* !defined HEADER_SAFESTACK_H */
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/dsa.h0000644000175000017500000002736712360020705021000 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

/*
 * The DSS routines are based on patches supplied by
 * Steven Schoch .  He basically did the
 * work and I have just tweaked them a little to fit into my
 * stylistic vision for SSLeay :-) */

#ifndef HEADER_DSA_H
#define HEADER_DSA_H

#include 

#ifdef OPENSSL_NO_DSA
#error DSA is disabled.
#endif

#ifndef OPENSSL_NO_BIO
#include 
#endif
#include 
#include 

#ifndef OPENSSL_NO_DEPRECATED
#include 
#ifndef OPENSSL_NO_DH
# include 
#endif
#endif

#ifndef OPENSSL_DSA_MAX_MODULUS_BITS
# define OPENSSL_DSA_MAX_MODULUS_BITS	10000
#endif

#define DSA_FLAG_CACHE_MONT_P	0x01
#define DSA_FLAG_NO_EXP_CONSTTIME       0x02 /* new with 0.9.7h; the built-in DSA
                                              * implementation now uses constant time
                                              * modular exponentiation for secret exponents
                                              * by default. This flag causes the
                                              * faster variable sliding window method to
                                              * be used for all exponents.
                                              */

/* If this flag is set the DSA method is FIPS compliant and can be used
 * in FIPS mode. This is set in the validated module method. If an
 * application sets this flag in its own methods it is its reposibility
 * to ensure the result is compliant.
 */

#define DSA_FLAG_FIPS_METHOD			0x0400

/* If this flag is set the operations normally disabled in FIPS mode are
 * permitted it is then the applications responsibility to ensure that the
 * usage is compliant.
 */

#define DSA_FLAG_NON_FIPS_ALLOW			0x0400

#ifdef  __cplusplus
extern "C" {
#endif

/* Already defined in ossl_typ.h */
/* typedef struct dsa_st DSA; */
/* typedef struct dsa_method DSA_METHOD; */

typedef struct DSA_SIG_st
	{
	BIGNUM *r;
	BIGNUM *s;
	} DSA_SIG;

struct dsa_method
	{
	const char *name;
	DSA_SIG * (*dsa_do_sign)(const unsigned char *dgst, int dlen, DSA *dsa);
	int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
								BIGNUM **rp);
	int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
			     DSA_SIG *sig, DSA *dsa);
	int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
			BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
			BN_MONT_CTX *in_mont);
	int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
				const BIGNUM *m, BN_CTX *ctx,
				BN_MONT_CTX *m_ctx); /* Can be null */
	int (*init)(DSA *dsa);
	int (*finish)(DSA *dsa);
	int flags;
	char *app_data;
	/* If this is non-NULL, it is used to generate DSA parameters */
	int (*dsa_paramgen)(DSA *dsa, int bits,
			const unsigned char *seed, int seed_len,
			int *counter_ret, unsigned long *h_ret,
			BN_GENCB *cb);
	/* If this is non-NULL, it is used to generate DSA keys */
	int (*dsa_keygen)(DSA *dsa);
	};

struct dsa_st
	{
	/* This first variable is used to pick up errors where
	 * a DSA is passed instead of of a EVP_PKEY */
	int pad;
	long version;
	int write_params;
	BIGNUM *p;
	BIGNUM *q;	/* == 20 */
	BIGNUM *g;

	BIGNUM *pub_key;  /* y public key */
	BIGNUM *priv_key; /* x private key */

	BIGNUM *kinv;	/* Signing pre-calc */
	BIGNUM *r;	/* Signing pre-calc */

	int flags;
	/* Normally used to cache montgomery values */
	BN_MONT_CTX *method_mont_p;
	int references;
	CRYPTO_EX_DATA ex_data;
	const DSA_METHOD *meth;
	/* functional reference if 'meth' is ENGINE-provided */
	ENGINE *engine;
	};

#define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \
		(char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x))
#define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \
		(unsigned char *)(x))
#define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x)
#define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x)


DSA *DSAparams_dup(DSA *x);
DSA_SIG * DSA_SIG_new(void);
void	DSA_SIG_free(DSA_SIG *a);
int	i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length);

DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa);
int	DSA_do_verify(const unsigned char *dgst,int dgst_len,
		      DSA_SIG *sig,DSA *dsa);

const DSA_METHOD *DSA_OpenSSL(void);

void	DSA_set_default_method(const DSA_METHOD *);
const DSA_METHOD *DSA_get_default_method(void);
int	DSA_set_method(DSA *dsa, const DSA_METHOD *);

DSA *	DSA_new(void);
DSA *	DSA_new_method(ENGINE *engine);
void	DSA_free (DSA *r);
/* "up" the DSA object's reference count */
int	DSA_up_ref(DSA *r);
int	DSA_size(const DSA *);
	/* next 4 return -1 on error */
int	DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp);
int	DSA_sign(int type,const unsigned char *dgst,int dlen,
		unsigned char *sig, unsigned int *siglen, DSA *dsa);
int	DSA_verify(int type,const unsigned char *dgst,int dgst_len,
		const unsigned char *sigbuf, int siglen, DSA *dsa);
int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
	     CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
int DSA_set_ex_data(DSA *d, int idx, void *arg);
void *DSA_get_ex_data(DSA *d, int idx);

DSA *	d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);
DSA *	d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);
DSA * 	d2i_DSAparams(DSA **a, const unsigned char **pp, long length);

/* Deprecated version */
#ifndef OPENSSL_NO_DEPRECATED
DSA *	DSA_generate_parameters(int bits,
		unsigned char *seed,int seed_len,
		int *counter_ret, unsigned long *h_ret,void
		(*callback)(int, int, void *),void *cb_arg);
#endif /* !defined(OPENSSL_NO_DEPRECATED) */

/* New version */
int	DSA_generate_parameters_ex(DSA *dsa, int bits,
		const unsigned char *seed,int seed_len,
		int *counter_ret, unsigned long *h_ret, BN_GENCB *cb);

int	DSA_generate_key(DSA *a);
int	i2d_DSAPublicKey(const DSA *a, unsigned char **pp);
int 	i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);
int	i2d_DSAparams(const DSA *a,unsigned char **pp);

#ifndef OPENSSL_NO_BIO
int	DSAparams_print(BIO *bp, const DSA *x);
int	DSA_print(BIO *bp, const DSA *x, int off);
#endif
int	DSAparams_print_fp(FILE *fp, const DSA *x);
int	DSA_print_fp(FILE *bp, const DSA *x, int off);

#define DSS_prime_checks 50
/* Primality test according to FIPS PUB 186[-1], Appendix 2.1:
 * 50 rounds of Rabin-Miller */
#define DSA_is_prime(n, callback, cb_arg) \
	BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)

#ifndef OPENSSL_NO_DH
/* Convert DSA structure (key or just parameters) into DH structure
 * (be careful to avoid small subgroup attacks when using this!) */
DH *DSA_dup_DH(const DSA *r);
#endif

#define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \
	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \
				EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL)

#define	EVP_PKEY_CTRL_DSA_PARAMGEN_BITS		(EVP_PKEY_ALG_CTRL + 1)
#define	EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS	(EVP_PKEY_ALG_CTRL + 2)
#define	EVP_PKEY_CTRL_DSA_PARAMGEN_MD		(EVP_PKEY_ALG_CTRL + 3)

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_DSA_strings(void);

/* Error codes for the DSA functions. */

/* Function codes. */
#define DSA_F_D2I_DSA_SIG				 110
#define DSA_F_DO_DSA_PRINT				 104
#define DSA_F_DSAPARAMS_PRINT				 100
#define DSA_F_DSAPARAMS_PRINT_FP			 101
#define DSA_F_DSA_DO_SIGN				 112
#define DSA_F_DSA_DO_VERIFY				 113
#define DSA_F_DSA_GENERATE_KEY				 124
#define DSA_F_DSA_GENERATE_PARAMETERS_EX		 123
#define DSA_F_DSA_NEW_METHOD				 103
#define DSA_F_DSA_PARAM_DECODE				 119
#define DSA_F_DSA_PRINT_FP				 105
#define DSA_F_DSA_PRIV_DECODE				 115
#define DSA_F_DSA_PRIV_ENCODE				 116
#define DSA_F_DSA_PUB_DECODE				 117
#define DSA_F_DSA_PUB_ENCODE				 118
#define DSA_F_DSA_SIGN					 106
#define DSA_F_DSA_SIGN_SETUP				 107
#define DSA_F_DSA_SIG_NEW				 109
#define DSA_F_DSA_SIG_PRINT				 125
#define DSA_F_DSA_VERIFY				 108
#define DSA_F_I2D_DSA_SIG				 111
#define DSA_F_OLD_DSA_PRIV_DECODE			 122
#define DSA_F_PKEY_DSA_CTRL				 120
#define DSA_F_PKEY_DSA_KEYGEN				 121
#define DSA_F_SIG_CB					 114

/* Reason codes. */
#define DSA_R_BAD_Q_VALUE				 102
#define DSA_R_BN_DECODE_ERROR				 108
#define DSA_R_BN_ERROR					 109
#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE		 100
#define DSA_R_DECODE_ERROR				 104
#define DSA_R_INVALID_DIGEST_TYPE			 106
#define DSA_R_MISSING_PARAMETERS			 101
#define DSA_R_MODULUS_TOO_LARGE				 103
#define DSA_R_NEED_NEW_SETUP_VALUES			 110
#define DSA_R_NON_FIPS_DSA_METHOD			 111
#define DSA_R_NO_PARAMETERS_SET				 107
#define DSA_R_PARAMETER_ENCODING_ERROR			 105

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/comp.h0000644000175000017500000000370012360020705021150 0ustar  /* $OpenBSD$ */

#ifndef HEADER_COMP_H
#define HEADER_COMP_H

#include 

#ifdef  __cplusplus
extern "C" {
#endif

typedef struct comp_ctx_st COMP_CTX;

typedef struct comp_method_st {
	int type;		/* NID for compression library */
	const char *name;	/* A text string to identify the library */
	int (*init)(COMP_CTX *ctx);
	void (*finish)(COMP_CTX *ctx);
	int (*compress)(COMP_CTX *ctx, unsigned char *out, unsigned int olen,
	    unsigned char *in, unsigned int ilen);
	int (*expand)(COMP_CTX *ctx, unsigned char *out, unsigned int olen,
	    unsigned char *in, unsigned int ilen);
	/* The following two do NOTHING, but are kept for backward compatibility */
	long (*ctrl)(void);
	long (*callback_ctrl)(void);
} COMP_METHOD;

struct comp_ctx_st {
	COMP_METHOD *meth;
	unsigned long compress_in;
	unsigned long compress_out;
	unsigned long expand_in;
	unsigned long expand_out;

	CRYPTO_EX_DATA	ex_data;
};


COMP_CTX *COMP_CTX_new(COMP_METHOD *meth);
void COMP_CTX_free(COMP_CTX *ctx);
int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
    unsigned char *in, int ilen);
int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
    unsigned char *in, int ilen);
COMP_METHOD *COMP_rle(void );
COMP_METHOD *COMP_zlib(void );
void COMP_zlib_cleanup(void);

#ifdef HEADER_BIO_H
#ifdef ZLIB
BIO_METHOD *BIO_f_zlib(void);
#endif
#endif

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_COMP_strings(void);

/* Error codes for the COMP functions. */

/* Function codes. */
#define COMP_F_BIO_ZLIB_FLUSH				 99
#define COMP_F_BIO_ZLIB_NEW				 100
#define COMP_F_BIO_ZLIB_READ				 101
#define COMP_F_BIO_ZLIB_WRITE				 102

/* Reason codes. */
#define COMP_R_ZLIB_DEFLATE_ERROR			 99
#define COMP_R_ZLIB_INFLATE_ERROR			 100
#define COMP_R_ZLIB_NOT_SUPPORTED			 101

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/tls1.h0000644000175000017500000010122112360020705021072 0ustar  /* $OpenBSD: tls1.h,v 1.18 2014/06/13 04:29:13 miod Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */
/* ====================================================================
 * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */
/* ====================================================================
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 *
 * Portions of the attached software ("Contribution") are developed by
 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
 *
 * The Contribution is licensed pursuant to the OpenSSL open source
 * license provided above.
 *
 * ECC cipher suite support in OpenSSL originally written by
 * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories.
 *
 */
/* ====================================================================
 * Copyright 2005 Nokia. All rights reserved.
 *
 * The portions of the attached software ("Contribution") is developed by
 * Nokia Corporation and is licensed pursuant to the OpenSSL open source
 * license.
 *
 * The Contribution, originally written by Mika Kousa and Pasi Eronen of
 * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
 * support (see RFC 4279) to OpenSSL.
 *
 * No patent licenses or other rights except those expressly stated in
 * the OpenSSL open source license shall be deemed granted or received
 * expressly, by implication, estoppel, or otherwise.
 *
 * No assurances are provided by Nokia that the Contribution does not
 * infringe the patent or other intellectual property rights of any third
 * party or that the license provides you with all the necessary rights
 * to make use of the Contribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
 * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
 * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
 * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
 * OTHERWISE.
 */

#ifndef HEADER_TLS1_H
#define HEADER_TLS1_H

#include 

#ifdef  __cplusplus
extern "C" {
#endif

#define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES	0

#define TLS1_2_VERSION			0x0303
#define TLS1_2_VERSION_MAJOR		0x03
#define TLS1_2_VERSION_MINOR		0x03

#define TLS1_1_VERSION			0x0302
#define TLS1_1_VERSION_MAJOR		0x03
#define TLS1_1_VERSION_MINOR		0x02

#define TLS1_VERSION			0x0301
#define TLS1_VERSION_MAJOR		0x03
#define TLS1_VERSION_MINOR		0x01

#define TLS1_get_version(s) \
		((s->version >> 8) == TLS1_VERSION_MAJOR ? s->version : 0)

#define TLS1_get_client_version(s) \
		((s->client_version >> 8) == TLS1_VERSION_MAJOR ? s->client_version : 0)

#define TLS1_AD_DECRYPTION_FAILED	21
#define TLS1_AD_RECORD_OVERFLOW		22
#define TLS1_AD_UNKNOWN_CA		48	/* fatal */
#define TLS1_AD_ACCESS_DENIED		49	/* fatal */
#define TLS1_AD_DECODE_ERROR		50	/* fatal */
#define TLS1_AD_DECRYPT_ERROR		51
#define TLS1_AD_EXPORT_RESTRICTION	60	/* fatal */
#define TLS1_AD_PROTOCOL_VERSION	70	/* fatal */
#define TLS1_AD_INSUFFICIENT_SECURITY	71	/* fatal */
#define TLS1_AD_INTERNAL_ERROR		80	/* fatal */
#define TLS1_AD_USER_CANCELLED		90
#define TLS1_AD_NO_RENEGOTIATION	100
/* codes 110-114 are from RFC3546 */
#define TLS1_AD_UNSUPPORTED_EXTENSION	110
#define TLS1_AD_CERTIFICATE_UNOBTAINABLE 111
#define TLS1_AD_UNRECOGNIZED_NAME 	112
#define TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE 113
#define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114
#define TLS1_AD_UNKNOWN_PSK_IDENTITY	115	/* fatal */

/* ExtensionType values from RFC3546 / RFC4366 / RFC6066 */
#define TLSEXT_TYPE_server_name			0
#define TLSEXT_TYPE_max_fragment_length		1
#define TLSEXT_TYPE_client_certificate_url	2
#define TLSEXT_TYPE_trusted_ca_keys		3
#define TLSEXT_TYPE_truncated_hmac		4
#define TLSEXT_TYPE_status_request		5
/* ExtensionType values from RFC4681 */
#define TLSEXT_TYPE_user_mapping		6

/* ExtensionType values from RFC5878 */
#define TLSEXT_TYPE_client_authz		7
#define TLSEXT_TYPE_server_authz		8

/* ExtensionType values from RFC6091 */
#define TLSEXT_TYPE_cert_type		9

/* ExtensionType values from RFC4492 */
#define TLSEXT_TYPE_elliptic_curves		10
#define TLSEXT_TYPE_ec_point_formats		11

/* ExtensionType value from RFC5054 */
#define TLSEXT_TYPE_srp				12

/* ExtensionType values from RFC5246 */
#define TLSEXT_TYPE_signature_algorithms	13

/* ExtensionType value from RFC5764 */
#define TLSEXT_TYPE_use_srtp	14

/* ExtensionType value from RFC5620 */
#define TLSEXT_TYPE_heartbeat	15

/* ExtensionType value for TLS padding extension.
 * http://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml
 * http://tools.ietf.org/html/draft-agl-tls-padding-03
 */
#define TLSEXT_TYPE_padding	21

/* ExtensionType value from RFC4507 */
#define TLSEXT_TYPE_session_ticket		35

/* Temporary extension type */
#define TLSEXT_TYPE_renegotiate                 0xff01

#ifndef OPENSSL_NO_NEXTPROTONEG
/* This is not an IANA defined extension number */
#define TLSEXT_TYPE_next_proto_neg		13172
#endif

/* NameType value from RFC 3546 */
#define TLSEXT_NAMETYPE_host_name 0
/* status request value from RFC 3546 */
#define TLSEXT_STATUSTYPE_ocsp 1

/* ECPointFormat values from draft-ietf-tls-ecc-12 */
#define TLSEXT_ECPOINTFORMAT_first			0
#define TLSEXT_ECPOINTFORMAT_uncompressed		0
#define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime	1
#define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2	2
#define TLSEXT_ECPOINTFORMAT_last			2

/* Signature and hash algorithms from RFC 5246 */

#define TLSEXT_signature_anonymous			0
#define TLSEXT_signature_rsa				1
#define TLSEXT_signature_dsa				2
#define TLSEXT_signature_ecdsa				3

#define TLSEXT_hash_none				0
#define TLSEXT_hash_md5					1
#define TLSEXT_hash_sha1				2
#define TLSEXT_hash_sha224				3
#define TLSEXT_hash_sha256				4
#define TLSEXT_hash_sha384				5
#define TLSEXT_hash_sha512				6


#define TLSEXT_MAXLEN_host_name 255

const char *SSL_get_servername(const SSL *s, const int type);
int SSL_get_servername_type(const SSL *s);
/* SSL_export_keying_material exports a value derived from the master secret,
 * as specified in RFC 5705. It writes |olen| bytes to |out| given a label and
 * optional context. (Since a zero length context is allowed, the |use_context|
 * flag controls whether a context is included.)
 *
 * It returns 1 on success and zero otherwise.
 */
int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen,
    const char *label, size_t llen, const unsigned char *p, size_t plen,
    int use_context);

#define SSL_set_tlsext_host_name(s,name) \
SSL_ctrl(s,SSL_CTRL_SET_TLSEXT_HOSTNAME,TLSEXT_NAMETYPE_host_name,(char *)name)

#define SSL_set_tlsext_debug_callback(ssl, cb) \
SSL_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_CB,(void (*)(void))cb)

#define SSL_set_tlsext_debug_arg(ssl, arg) \
SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_ARG,0, (void *)arg)

#define SSL_set_tlsext_status_type(ssl, type) \
SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,type, NULL)

#define SSL_get_tlsext_status_exts(ssl, arg) \
SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS,0, (void *)arg)

#define SSL_set_tlsext_status_exts(ssl, arg) \
SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS,0, (void *)arg)

#define SSL_get_tlsext_status_ids(ssl, arg) \
SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS,0, (void *)arg)

#define SSL_set_tlsext_status_ids(ssl, arg) \
SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS,0, (void *)arg)

#define SSL_get_tlsext_status_ocsp_resp(ssl, arg) \
SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP,0, (void *)arg)

#define SSL_set_tlsext_status_ocsp_resp(ssl, arg, arglen) \
SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP,arglen, (void *)arg)

#define SSL_CTX_set_tlsext_servername_callback(ctx, cb) \
SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_CB,(void (*)(void))cb)

#define SSL_TLSEXT_ERR_OK 0
#define SSL_TLSEXT_ERR_ALERT_WARNING 1
#define SSL_TLSEXT_ERR_ALERT_FATAL 2
#define SSL_TLSEXT_ERR_NOACK 3

#define SSL_CTX_set_tlsext_servername_arg(ctx, arg) \
SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG,0, (void *)arg)

#define SSL_CTX_get_tlsext_ticket_keys(ctx, keys, keylen) \
	SSL_CTX_ctrl((ctx),SSL_CTRL_GET_TLSEXT_TICKET_KEYS,(keylen),(keys))
#define SSL_CTX_set_tlsext_ticket_keys(ctx, keys, keylen) \
	SSL_CTX_ctrl((ctx),SSL_CTRL_SET_TLSEXT_TICKET_KEYS,(keylen),(keys))

#define SSL_CTX_set_tlsext_status_cb(ssl, cb) \
SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB,(void (*)(void))cb)

#define SSL_CTX_set_tlsext_status_arg(ssl, arg) \
SSL_CTX_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG,0, (void *)arg)

#define SSL_CTX_set_tlsext_ticket_key_cb(ssl, cb) \
SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb)


/* PSK ciphersuites from 4279 */
#define TLS1_CK_PSK_WITH_RC4_128_SHA                    0x0300008A
#define TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA               0x0300008B
#define TLS1_CK_PSK_WITH_AES_128_CBC_SHA                0x0300008C
#define TLS1_CK_PSK_WITH_AES_256_CBC_SHA                0x0300008D

/* Additional TLS ciphersuites from expired Internet Draft
 * draft-ietf-tls-56-bit-ciphersuites-01.txt
 * (available if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES is defined, see
 * s3_lib.c).  We actually treat them like SSL 3.0 ciphers, which we probably
 * shouldn't.  Note that the first two are actually not in the IDs. */
#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5		0x03000060 /* not in ID */
#define TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5	0x03000061 /* not in ID */
#define TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA		0x03000062
#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA	0x03000063
#define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA		0x03000064
#define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA	0x03000065
#define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA		0x03000066

/* AES ciphersuites from RFC3268 */

#define TLS1_CK_RSA_WITH_AES_128_SHA			0x0300002F
#define TLS1_CK_DH_DSS_WITH_AES_128_SHA			0x03000030
#define TLS1_CK_DH_RSA_WITH_AES_128_SHA			0x03000031
#define TLS1_CK_DHE_DSS_WITH_AES_128_SHA		0x03000032
#define TLS1_CK_DHE_RSA_WITH_AES_128_SHA		0x03000033
#define TLS1_CK_ADH_WITH_AES_128_SHA			0x03000034

#define TLS1_CK_RSA_WITH_AES_256_SHA			0x03000035
#define TLS1_CK_DH_DSS_WITH_AES_256_SHA			0x03000036
#define TLS1_CK_DH_RSA_WITH_AES_256_SHA			0x03000037
#define TLS1_CK_DHE_DSS_WITH_AES_256_SHA		0x03000038
#define TLS1_CK_DHE_RSA_WITH_AES_256_SHA		0x03000039
#define TLS1_CK_ADH_WITH_AES_256_SHA			0x0300003A

/* TLS v1.2 ciphersuites */
#define TLS1_CK_RSA_WITH_NULL_SHA256			0x0300003B
#define TLS1_CK_RSA_WITH_AES_128_SHA256			0x0300003C
#define TLS1_CK_RSA_WITH_AES_256_SHA256			0x0300003D
#define TLS1_CK_DH_DSS_WITH_AES_128_SHA256		0x0300003E
#define TLS1_CK_DH_RSA_WITH_AES_128_SHA256		0x0300003F
#define TLS1_CK_DHE_DSS_WITH_AES_128_SHA256		0x03000040

/* Camellia ciphersuites from RFC4132 */
#define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA		0x03000041
#define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA	0x03000042
#define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA	0x03000043
#define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA	0x03000044
#define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA	0x03000045
#define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA		0x03000046

/* TLS v1.2 ciphersuites */
#define TLS1_CK_DHE_RSA_WITH_AES_128_SHA256		0x03000067
#define TLS1_CK_DH_DSS_WITH_AES_256_SHA256		0x03000068
#define TLS1_CK_DH_RSA_WITH_AES_256_SHA256		0x03000069
#define TLS1_CK_DHE_DSS_WITH_AES_256_SHA256		0x0300006A
#define TLS1_CK_DHE_RSA_WITH_AES_256_SHA256		0x0300006B
#define TLS1_CK_ADH_WITH_AES_128_SHA256			0x0300006C
#define TLS1_CK_ADH_WITH_AES_256_SHA256			0x0300006D

/* Camellia ciphersuites from RFC4132 */
#define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA		0x03000084
#define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA	0x03000085
#define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA	0x03000086
#define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA	0x03000087
#define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA	0x03000088
#define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA		0x03000089

/* SEED ciphersuites from RFC4162 */
#define TLS1_CK_RSA_WITH_SEED_SHA                       0x03000096
#define TLS1_CK_DH_DSS_WITH_SEED_SHA                    0x03000097
#define TLS1_CK_DH_RSA_WITH_SEED_SHA                    0x03000098
#define TLS1_CK_DHE_DSS_WITH_SEED_SHA                   0x03000099
#define TLS1_CK_DHE_RSA_WITH_SEED_SHA                   0x0300009A
#define TLS1_CK_ADH_WITH_SEED_SHA                	0x0300009B

/* TLS v1.2 GCM ciphersuites from RFC5288 */
#define TLS1_CK_RSA_WITH_AES_128_GCM_SHA256		0x0300009C
#define TLS1_CK_RSA_WITH_AES_256_GCM_SHA384		0x0300009D
#define TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256		0x0300009E
#define TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384		0x0300009F
#define TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256		0x030000A0
#define TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384		0x030000A1
#define TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256		0x030000A2
#define TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384		0x030000A3
#define TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256		0x030000A4
#define TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384		0x030000A5
#define TLS1_CK_ADH_WITH_AES_128_GCM_SHA256		0x030000A6
#define TLS1_CK_ADH_WITH_AES_256_GCM_SHA384		0x030000A7

/* ECC ciphersuites from draft-ietf-tls-ecc-12.txt with changes soon to be in draft 13 */
#define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA                0x0300C001
#define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA             0x0300C002
#define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA        0x0300C003
#define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA         0x0300C004
#define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA         0x0300C005

#define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA               0x0300C006
#define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA            0x0300C007
#define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA       0x0300C008
#define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA        0x0300C009
#define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA        0x0300C00A

#define TLS1_CK_ECDH_RSA_WITH_NULL_SHA                  0x0300C00B
#define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA               0x0300C00C
#define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA          0x0300C00D
#define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA           0x0300C00E
#define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA           0x0300C00F

#define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA                 0x0300C010
#define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA              0x0300C011
#define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA         0x0300C012
#define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA          0x0300C013
#define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA          0x0300C014

#define TLS1_CK_ECDH_anon_WITH_NULL_SHA                 0x0300C015
#define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA              0x0300C016
#define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA         0x0300C017
#define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA          0x0300C018
#define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA          0x0300C019

/* SRP ciphersuites from RFC 5054 */
#define TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA		0x0300C01A
#define TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA	0x0300C01B
#define TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA	0x0300C01C
#define TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA		0x0300C01D
#define TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA	0x0300C01E
#define TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA	0x0300C01F
#define TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA		0x0300C020
#define TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA	0x0300C021
#define TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA	0x0300C022

/* ECDH HMAC based ciphersuites from RFC5289 */
#define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256         0x0300C023
#define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384         0x0300C024
#define TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256          0x0300C025
#define TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384          0x0300C026
#define TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256           0x0300C027
#define TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384           0x0300C028
#define TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256            0x0300C029
#define TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384            0x0300C02A

/* ECDH GCM based ciphersuites from RFC5289 */
#define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256	0x0300C02B
#define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384	0x0300C02C
#define TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256      0x0300C02D
#define TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384      0x0300C02E
#define TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256       0x0300C02F
#define TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384       0x0300C030
#define TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256        0x0300C031
#define TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384        0x0300C032

/* ChaCha20-Poly1305 based ciphersuites. */
#define TLS1_CK_ECDHE_RSA_CHACHA20_POLY1305		0x0300CC13
#define TLS1_CK_ECDHE_ECDSA_CHACHA20_POLY1305		0x0300CC14
#define TLS1_CK_DHE_RSA_CHACHA20_POLY1305		0x0300CC15

/* XXX
 * Inconsistency alert:
 * The OpenSSL names of ciphers with ephemeral DH here include the string
 * "DHE", while elsewhere it has always been "EDH".
 * (The alias for the list of all such ciphers also is "EDH".)
 * The specifications speak of "EDH"; maybe we should allow both forms
 * for everything. */
#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5		"EXP1024-RC4-MD5"
#define TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5	"EXP1024-RC2-CBC-MD5"
#define TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA	"EXP1024-DES-CBC-SHA"
#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA	"EXP1024-DHE-DSS-DES-CBC-SHA"
#define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA		"EXP1024-RC4-SHA"
#define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA	"EXP1024-DHE-DSS-RC4-SHA"
#define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA		"DHE-DSS-RC4-SHA"

/* AES ciphersuites from RFC3268 */
#define TLS1_TXT_RSA_WITH_AES_128_SHA			"AES128-SHA"
#define TLS1_TXT_DH_DSS_WITH_AES_128_SHA		"DH-DSS-AES128-SHA"
#define TLS1_TXT_DH_RSA_WITH_AES_128_SHA		"DH-RSA-AES128-SHA"
#define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA		"DHE-DSS-AES128-SHA"
#define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA		"DHE-RSA-AES128-SHA"
#define TLS1_TXT_ADH_WITH_AES_128_SHA			"ADH-AES128-SHA"

#define TLS1_TXT_RSA_WITH_AES_256_SHA			"AES256-SHA"
#define TLS1_TXT_DH_DSS_WITH_AES_256_SHA		"DH-DSS-AES256-SHA"
#define TLS1_TXT_DH_RSA_WITH_AES_256_SHA		"DH-RSA-AES256-SHA"
#define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA		"DHE-DSS-AES256-SHA"
#define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA		"DHE-RSA-AES256-SHA"
#define TLS1_TXT_ADH_WITH_AES_256_SHA			"ADH-AES256-SHA"

/* ECC ciphersuites from draft-ietf-tls-ecc-01.txt (Mar 15, 2001) */
#define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA               "ECDH-ECDSA-NULL-SHA"
#define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA            "ECDH-ECDSA-RC4-SHA"
#define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA       "ECDH-ECDSA-DES-CBC3-SHA"
#define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA        "ECDH-ECDSA-AES128-SHA"
#define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA        "ECDH-ECDSA-AES256-SHA"

#define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA              "ECDHE-ECDSA-NULL-SHA"
#define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA           "ECDHE-ECDSA-RC4-SHA"
#define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA      "ECDHE-ECDSA-DES-CBC3-SHA"
#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA       "ECDHE-ECDSA-AES128-SHA"
#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA       "ECDHE-ECDSA-AES256-SHA"

#define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA                 "ECDH-RSA-NULL-SHA"
#define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA              "ECDH-RSA-RC4-SHA"
#define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA         "ECDH-RSA-DES-CBC3-SHA"
#define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA          "ECDH-RSA-AES128-SHA"
#define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA          "ECDH-RSA-AES256-SHA"

#define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA                "ECDHE-RSA-NULL-SHA"
#define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA             "ECDHE-RSA-RC4-SHA"
#define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA        "ECDHE-RSA-DES-CBC3-SHA"
#define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA         "ECDHE-RSA-AES128-SHA"
#define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA         "ECDHE-RSA-AES256-SHA"

#define TLS1_TXT_ECDH_anon_WITH_NULL_SHA                "AECDH-NULL-SHA"
#define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA             "AECDH-RC4-SHA"
#define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA        "AECDH-DES-CBC3-SHA"
#define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA         "AECDH-AES128-SHA"
#define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA         "AECDH-AES256-SHA"

/* PSK ciphersuites from RFC 4279 */
#define TLS1_TXT_PSK_WITH_RC4_128_SHA			"PSK-RC4-SHA"
#define TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA		"PSK-3DES-EDE-CBC-SHA"
#define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA		"PSK-AES128-CBC-SHA"
#define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA		"PSK-AES256-CBC-SHA"

/* SRP ciphersuite from RFC 5054 */
#define TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA		"SRP-3DES-EDE-CBC-SHA"
#define TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA	"SRP-RSA-3DES-EDE-CBC-SHA"
#define TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA	"SRP-DSS-3DES-EDE-CBC-SHA"
#define TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA		"SRP-AES-128-CBC-SHA"
#define TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA	"SRP-RSA-AES-128-CBC-SHA"
#define TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA	"SRP-DSS-AES-128-CBC-SHA"
#define TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA		"SRP-AES-256-CBC-SHA"
#define TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA	"SRP-RSA-AES-256-CBC-SHA"
#define TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA	"SRP-DSS-AES-256-CBC-SHA"

/* Camellia ciphersuites from RFC4132 */
#define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA		"CAMELLIA128-SHA"
#define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA	"DH-DSS-CAMELLIA128-SHA"
#define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA	"DH-RSA-CAMELLIA128-SHA"
#define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA	"DHE-DSS-CAMELLIA128-SHA"
#define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA	"DHE-RSA-CAMELLIA128-SHA"
#define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA		"ADH-CAMELLIA128-SHA"

#define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA		"CAMELLIA256-SHA"
#define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA	"DH-DSS-CAMELLIA256-SHA"
#define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA	"DH-RSA-CAMELLIA256-SHA"
#define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA	"DHE-DSS-CAMELLIA256-SHA"
#define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA	"DHE-RSA-CAMELLIA256-SHA"
#define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA		"ADH-CAMELLIA256-SHA"

/* SEED ciphersuites from RFC4162 */
#define TLS1_TXT_RSA_WITH_SEED_SHA                      "SEED-SHA"
#define TLS1_TXT_DH_DSS_WITH_SEED_SHA                   "DH-DSS-SEED-SHA"
#define TLS1_TXT_DH_RSA_WITH_SEED_SHA                   "DH-RSA-SEED-SHA"
#define TLS1_TXT_DHE_DSS_WITH_SEED_SHA                  "DHE-DSS-SEED-SHA"
#define TLS1_TXT_DHE_RSA_WITH_SEED_SHA                  "DHE-RSA-SEED-SHA"
#define TLS1_TXT_ADH_WITH_SEED_SHA                      "ADH-SEED-SHA"

/* TLS v1.2 ciphersuites */
#define TLS1_TXT_RSA_WITH_NULL_SHA256			"NULL-SHA256"
#define TLS1_TXT_RSA_WITH_AES_128_SHA256		"AES128-SHA256"
#define TLS1_TXT_RSA_WITH_AES_256_SHA256		"AES256-SHA256"
#define TLS1_TXT_DH_DSS_WITH_AES_128_SHA256		"DH-DSS-AES128-SHA256"
#define TLS1_TXT_DH_RSA_WITH_AES_128_SHA256		"DH-RSA-AES128-SHA256"
#define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256		"DHE-DSS-AES128-SHA256"
#define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256		"DHE-RSA-AES128-SHA256"
#define TLS1_TXT_DH_DSS_WITH_AES_256_SHA256		"DH-DSS-AES256-SHA256"
#define TLS1_TXT_DH_RSA_WITH_AES_256_SHA256		"DH-RSA-AES256-SHA256"
#define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256		"DHE-DSS-AES256-SHA256"
#define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256		"DHE-RSA-AES256-SHA256"
#define TLS1_TXT_ADH_WITH_AES_128_SHA256		"ADH-AES128-SHA256"
#define TLS1_TXT_ADH_WITH_AES_256_SHA256		"ADH-AES256-SHA256"

/* TLS v1.2 GCM ciphersuites from RFC5288 */
#define TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256		"AES128-GCM-SHA256"
#define TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384		"AES256-GCM-SHA384"
#define TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256	"DHE-RSA-AES128-GCM-SHA256"
#define TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384	"DHE-RSA-AES256-GCM-SHA384"
#define TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256		"DH-RSA-AES128-GCM-SHA256"
#define TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384		"DH-RSA-AES256-GCM-SHA384"
#define TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256	"DHE-DSS-AES128-GCM-SHA256"
#define TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384	"DHE-DSS-AES256-GCM-SHA384"
#define TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256		"DH-DSS-AES128-GCM-SHA256"
#define TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384		"DH-DSS-AES256-GCM-SHA384"
#define TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256		"ADH-AES128-GCM-SHA256"
#define TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384		"ADH-AES256-GCM-SHA384"

/* ECDH HMAC based ciphersuites from RFC5289 */

#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256    "ECDHE-ECDSA-AES128-SHA256"
#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384    "ECDHE-ECDSA-AES256-SHA384"
#define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256     "ECDH-ECDSA-AES128-SHA256"
#define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384     "ECDH-ECDSA-AES256-SHA384"
#define TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256      "ECDHE-RSA-AES128-SHA256"
#define TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384      "ECDHE-RSA-AES256-SHA384"
#define TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256       "ECDH-RSA-AES128-SHA256"
#define TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384       "ECDH-RSA-AES256-SHA384"

/* ECDH GCM based ciphersuites from RFC5289 */
#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256    "ECDHE-ECDSA-AES128-GCM-SHA256"
#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384    "ECDHE-ECDSA-AES256-GCM-SHA384"
#define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256     "ECDH-ECDSA-AES128-GCM-SHA256"
#define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384     "ECDH-ECDSA-AES256-GCM-SHA384"
#define TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256      "ECDHE-RSA-AES128-GCM-SHA256"
#define TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384      "ECDHE-RSA-AES256-GCM-SHA384"
#define TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256       "ECDH-RSA-AES128-GCM-SHA256"
#define TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384       "ECDH-RSA-AES256-GCM-SHA384"

/* ChaCha20-Poly1305 based ciphersuites. */
#define TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305	"ECDHE-RSA-CHACHA20-POLY1305"
#define TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305	"ECDHE-ECDSA-CHACHA20-POLY1305"
#define TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305		"DHE-RSA-CHACHA20-POLY1305"

#define TLS_CT_RSA_SIGN			1
#define TLS_CT_DSS_SIGN			2
#define TLS_CT_RSA_FIXED_DH		3
#define TLS_CT_DSS_FIXED_DH		4
#define TLS_CT_ECDSA_SIGN		64
#define TLS_CT_RSA_FIXED_ECDH		65
#define TLS_CT_ECDSA_FIXED_ECDH 	66
#define TLS_CT_GOST94_SIGN		21
#define TLS_CT_GOST01_SIGN		22
/* when correcting this number, correct also SSL3_CT_NUMBER in ssl3.h (see
 * comment there) */
#define TLS_CT_NUMBER			9

#define TLS1_FINISH_MAC_LENGTH		12

#define TLS_MD_MAX_CONST_SIZE			20
#define TLS_MD_CLIENT_FINISH_CONST		"client finished"
#define TLS_MD_CLIENT_FINISH_CONST_SIZE		15
#define TLS_MD_SERVER_FINISH_CONST		"server finished"
#define TLS_MD_SERVER_FINISH_CONST_SIZE		15
#define TLS_MD_SERVER_WRITE_KEY_CONST		"server write key"
#define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE	16
#define TLS_MD_KEY_EXPANSION_CONST		"key expansion"
#define TLS_MD_KEY_EXPANSION_CONST_SIZE		13
#define TLS_MD_CLIENT_WRITE_KEY_CONST		"client write key"
#define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE	16
#define TLS_MD_SERVER_WRITE_KEY_CONST		"server write key"
#define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE	16
#define TLS_MD_IV_BLOCK_CONST			"IV block"
#define TLS_MD_IV_BLOCK_CONST_SIZE		8
#define TLS_MD_MASTER_SECRET_CONST		"master secret"
#define TLS_MD_MASTER_SECRET_CONST_SIZE		13

/* TLS Session Ticket extension struct */
struct tls_session_ticket_ext_st {
	unsigned short length;
	void *data;
};

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/cmac.h0000644000175000017500000000632112360020705021117 0ustar  /* $OpenBSD: cmac.h,v 1.2 2014/06/12 15:49:28 deraadt Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
 * project.
 */
/* ====================================================================
 * Copyright (c) 2010 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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 HEADER_CMAC_H
#define HEADER_CMAC_H

#ifdef __cplusplus
extern "C" {
#endif

#include 

/* Opaque */
typedef struct CMAC_CTX_st CMAC_CTX;

CMAC_CTX *CMAC_CTX_new(void);
void CMAC_CTX_cleanup(CMAC_CTX *ctx);
void CMAC_CTX_free(CMAC_CTX *ctx);
EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx);
int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in);

int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen,
    const EVP_CIPHER *cipher, ENGINE *impl);
int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen);
int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen);
int CMAC_resume(CMAC_CTX *ctx);

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/asn1.h0000644000175000017500000014351012360020705021060 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_ASN1_H
#define HEADER_ASN1_H

#include 

#include 

#ifndef OPENSSL_NO_BIO
#include 
#endif
#include 
#include 

#include 
#ifndef OPENSSL_NO_DEPRECATED
#include 
#endif

#ifdef  __cplusplus
extern "C" {
#endif

#define V_ASN1_UNIVERSAL		0x00
#define	V_ASN1_APPLICATION		0x40
#define V_ASN1_CONTEXT_SPECIFIC		0x80
#define V_ASN1_PRIVATE			0xc0

#define V_ASN1_CONSTRUCTED		0x20
#define V_ASN1_PRIMITIVE_TAG		0x1f
#define V_ASN1_PRIMATIVE_TAG		0x1f

#define V_ASN1_APP_CHOOSE		-2	/* let the recipient choose */
#define V_ASN1_OTHER			-3	/* used in ASN1_TYPE */
#define V_ASN1_ANY			-4	/* used in ASN1 template code */

#define V_ASN1_NEG			0x100	/* negative flag */

#define V_ASN1_UNDEF			-1
#define V_ASN1_EOC			0
#define V_ASN1_BOOLEAN			1	/**/
#define V_ASN1_INTEGER			2
#define V_ASN1_NEG_INTEGER		(2 | V_ASN1_NEG)
#define V_ASN1_BIT_STRING		3
#define V_ASN1_OCTET_STRING		4
#define V_ASN1_NULL			5
#define V_ASN1_OBJECT			6
#define V_ASN1_OBJECT_DESCRIPTOR	7
#define V_ASN1_EXTERNAL			8
#define V_ASN1_REAL			9
#define V_ASN1_ENUMERATED		10
#define V_ASN1_NEG_ENUMERATED		(10 | V_ASN1_NEG)
#define V_ASN1_UTF8STRING		12
#define V_ASN1_SEQUENCE			16
#define V_ASN1_SET			17
#define V_ASN1_NUMERICSTRING		18	/**/
#define V_ASN1_PRINTABLESTRING		19
#define V_ASN1_T61STRING		20
#define V_ASN1_TELETEXSTRING		20	/* alias */
#define V_ASN1_VIDEOTEXSTRING		21	/**/
#define V_ASN1_IA5STRING		22
#define V_ASN1_UTCTIME			23
#define V_ASN1_GENERALIZEDTIME		24	/**/
#define V_ASN1_GRAPHICSTRING		25	/**/
#define V_ASN1_ISO64STRING		26	/**/
#define V_ASN1_VISIBLESTRING		26	/* alias */
#define V_ASN1_GENERALSTRING		27	/**/
#define V_ASN1_UNIVERSALSTRING		28	/**/
#define V_ASN1_BMPSTRING		30

/* For use with d2i_ASN1_type_bytes() */
#define B_ASN1_NUMERICSTRING	0x0001
#define B_ASN1_PRINTABLESTRING	0x0002
#define B_ASN1_T61STRING	0x0004
#define B_ASN1_TELETEXSTRING	0x0004
#define B_ASN1_VIDEOTEXSTRING	0x0008
#define B_ASN1_IA5STRING	0x0010
#define B_ASN1_GRAPHICSTRING	0x0020
#define B_ASN1_ISO64STRING	0x0040
#define B_ASN1_VISIBLESTRING	0x0040
#define B_ASN1_GENERALSTRING	0x0080
#define B_ASN1_UNIVERSALSTRING	0x0100
#define B_ASN1_OCTET_STRING	0x0200
#define B_ASN1_BIT_STRING	0x0400
#define B_ASN1_BMPSTRING	0x0800
#define B_ASN1_UNKNOWN		0x1000
#define B_ASN1_UTF8STRING	0x2000
#define B_ASN1_UTCTIME		0x4000
#define B_ASN1_GENERALIZEDTIME	0x8000
#define B_ASN1_SEQUENCE		0x10000

/* For use with ASN1_mbstring_copy() */
#define MBSTRING_FLAG		0x1000
#define MBSTRING_UTF8		(MBSTRING_FLAG)
#define MBSTRING_ASC		(MBSTRING_FLAG|1)
#define MBSTRING_BMP		(MBSTRING_FLAG|2)
#define MBSTRING_UNIV		(MBSTRING_FLAG|4)

#define SMIME_OLDMIME		0x400
#define SMIME_CRLFEOL		0x800
#define SMIME_STREAM		0x1000

struct X509_algor_st;
DECLARE_STACK_OF(X509_ALGOR)

#define DECLARE_ASN1_SET_OF(type) /* filled in by mkstack.pl */
#define IMPLEMENT_ASN1_SET_OF(type) /* nothing, no longer needed */

/* We MUST make sure that, except for constness, asn1_ctx_st and
   asn1_const_ctx are exactly the same.  Fortunately, as soon as
   the old ASN1 parsing macros are gone, we can throw this away
   as well... */
typedef struct asn1_ctx_st {
	unsigned char *p;/* work char pointer */
	int eos;	/* end of sequence read for indefinite encoding */
	int error;	/* error code to use when returning an error */
	int inf;	/* constructed if 0x20, indefinite is 0x21 */
	int tag;	/* tag from last 'get object' */
	int xclass;	/* class from last 'get object' */
	long slen;	/* length of last 'get object' */
	unsigned char *max; /* largest value of p allowed */
	unsigned char *q;/* temporary variable */
	unsigned char **pp;/* variable */
	int line;	/* used in error processing */
} ASN1_CTX;

typedef struct asn1_const_ctx_st {
	const unsigned char *p;/* work char pointer */
	int eos;	/* end of sequence read for indefinite encoding */
	int error;	/* error code to use when returning an error */
	int inf;	/* constructed if 0x20, indefinite is 0x21 */
	int tag;	/* tag from last 'get object' */
	int xclass;	/* class from last 'get object' */
	long slen;	/* length of last 'get object' */
	const unsigned char *max; /* largest value of p allowed */
	const unsigned char *q;/* temporary variable */
	const unsigned char **pp;/* variable */
	int line;	/* used in error processing */
} ASN1_const_CTX;

/* These are used internally in the ASN1_OBJECT to keep track of
 * whether the names and data need to be free()ed */
#define ASN1_OBJECT_FLAG_DYNAMIC	 0x01	/* internal use */
#define ASN1_OBJECT_FLAG_CRITICAL	 0x02	/* critical x509v3 object id */
#define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04	/* internal use */
#define ASN1_OBJECT_FLAG_DYNAMIC_DATA 	 0x08	/* internal use */
typedef struct asn1_object_st {
	const char *sn, *ln;
	int nid;
	int length;
	const unsigned char *data;	/* data remains const after init */
	int flags;	/* Should we free this one */
} ASN1_OBJECT;

#define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */
/* This indicates that the ASN1_STRING is not a real value but just a place
 * holder for the location where indefinite length constructed data should
 * be inserted in the memory buffer
 */
#define ASN1_STRING_FLAG_NDEF 0x010

/* This flag is used by the CMS code to indicate that a string is not
 * complete and is a place holder for content when it had all been
 * accessed. The flag will be reset when content has been written to it.
 */

#define ASN1_STRING_FLAG_CONT 0x020
/* This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING
 * type.
 */
#define ASN1_STRING_FLAG_MSTRING 0x040
/* This is the base type that holds just about everything :-) */
struct asn1_string_st {
	int length;
	int type;
	unsigned char *data;
	/* The value of the following field depends on the type being
	 * held.  It is mostly being used for BIT_STRING so if the
	 * input data has a non-zero 'unused bits' value, it will be
	 * handled correctly */
	long flags;
};

/* ASN1_ENCODING structure: this is used to save the received
 * encoding of an ASN1 type. This is useful to get round
 * problems with invalid encodings which can break signatures.
 */

typedef struct ASN1_ENCODING_st {
	unsigned char *enc;	/* DER encoding */
	long len;		/* Length of encoding */
	int modified;		 /* set to 1 if 'enc' is invalid */
} ASN1_ENCODING;

/* Used with ASN1 LONG type: if a long is set to this it is omitted */
#define ASN1_LONG_UNDEF	0x7fffffffL

#define STABLE_FLAGS_MALLOC	0x01
#define STABLE_NO_MASK		0x02
#define DIRSTRING_TYPE	\
 (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)
#define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)

typedef struct asn1_string_table_st {
	int nid;
	long minsize;
	long maxsize;
	unsigned long mask;
	unsigned long flags;
} ASN1_STRING_TABLE;

DECLARE_STACK_OF(ASN1_STRING_TABLE)

/* size limits: this stuff is taken straight from RFC2459 */

#define ub_name				32768
#define ub_common_name			64
#define ub_locality_name		128
#define ub_state_name			128
#define ub_organization_name		64
#define ub_organization_unit_name	64
#define ub_title			64
#define ub_email_address		128

/* Declarations for template structures: for full definitions
 * see asn1t.h
 */
typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;
typedef struct ASN1_TLC_st ASN1_TLC;
/* This is just an opaque pointer */
typedef struct ASN1_VALUE_st ASN1_VALUE;

/* Declare ASN1 functions: the implement macro in in asn1t.h */

#define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)

#define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \
	DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type)

#define DECLARE_ASN1_FUNCTIONS_name(type, name) \
	DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
	DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name)

#define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \
	DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
	DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)

#define	DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \
	type *d2i_##name(type **a, const unsigned char **in, long len); \
	int i2d_##name(type *a, unsigned char **out); \
	DECLARE_ASN1_ITEM(itname)

#define	DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \
	type *d2i_##name(type **a, const unsigned char **in, long len); \
	int i2d_##name(const type *a, unsigned char **out); \
	DECLARE_ASN1_ITEM(name)

#define	DECLARE_ASN1_NDEF_FUNCTION(name) \
	int i2d_##name##_NDEF(name *a, unsigned char **out);

#define DECLARE_ASN1_FUNCTIONS_const(name) \
	DECLARE_ASN1_ALLOC_FUNCTIONS(name) \
	DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name)

#define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
	type *name##_new(void); \
	void name##_free(type *a);

#define DECLARE_ASN1_PRINT_FUNCTION(stname) \
	DECLARE_ASN1_PRINT_FUNCTION_fname(stname, stname)

#define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \
	int fname##_print_ctx(BIO *out, stname *x, int indent, \
					 const ASN1_PCTX *pctx);

#define D2I_OF(type) type *(*)(type **,const unsigned char **,long)
#define I2D_OF(type) int (*)(type *,unsigned char **)
#define I2D_OF_const(type) int (*)(const type *,unsigned char **)

#define CHECKED_D2I_OF(type, d2i) \
    ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0)))
#define CHECKED_I2D_OF(type, i2d) \
    ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0)))
#define CHECKED_NEW_OF(type, xnew) \
    ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0)))
#define CHECKED_PTR_OF(type, p) \
    ((void*) (1 ? p : (type*)0))
#define CHECKED_PPTR_OF(type, p) \
    ((void**) (1 ? p : (type**)0))

#define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long)
#define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **)
#define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type)

TYPEDEF_D2I2D_OF(void);

/* The following macros and typedefs allow an ASN1_ITEM
 * to be embedded in a structure and referenced. Since
 * the ASN1_ITEM pointers need to be globally accessible
 * (possibly from shared libraries) they may exist in
 * different forms. On platforms that support it the
 * ASN1_ITEM structure itself will be globally exported.
 * Other platforms will export a function that returns
 * an ASN1_ITEM pointer.
 *
 * To handle both cases transparently the macros below
 * should be used instead of hard coding an ASN1_ITEM
 * pointer in a structure.
 *
 * The structure will look like this:
 *
 * typedef struct SOMETHING_st {
 *      ...
 *      ASN1_ITEM_EXP *iptr;
 *      ...
 * } SOMETHING;
 *
 * It would be initialised as e.g.:
 *
 * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...};
 *
 * and the actual pointer extracted with:
 *
 * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr);
 *
 * Finally an ASN1_ITEM pointer can be extracted from an
 * appropriate reference with: ASN1_ITEM_rptr(X509). This
 * would be used when a function takes an ASN1_ITEM * argument.
 *
 */


/* ASN1_ITEM pointer exported type */
typedef const ASN1_ITEM ASN1_ITEM_EXP;

/* Macro to obtain ASN1_ITEM pointer from exported type */
#define ASN1_ITEM_ptr(iptr) (iptr)

/* Macro to include ASN1_ITEM pointer from base type */
#define ASN1_ITEM_ref(iptr) (&(iptr##_it))

#define ASN1_ITEM_rptr(ref) (&(ref##_it))

#define DECLARE_ASN1_ITEM(name) \
	extern const ASN1_ITEM name##_it;


/* Parameters used by ASN1_STRING_print_ex() */

/* These determine which characters to escape:
 * RFC2253 special characters, control characters and
 * MSB set characters
 */

#define ASN1_STRFLGS_ESC_2253		1
#define ASN1_STRFLGS_ESC_CTRL		2
#define ASN1_STRFLGS_ESC_MSB		4


/* This flag determines how we do escaping: normally
 * RC2253 backslash only, set this to use backslash and
 * quote.
 */

#define ASN1_STRFLGS_ESC_QUOTE		8


/* These three flags are internal use only. */

/* Character is a valid PrintableString character */
#define CHARTYPE_PRINTABLESTRING	0x10
/* Character needs escaping if it is the first character */
#define CHARTYPE_FIRST_ESC_2253		0x20
/* Character needs escaping if it is the last character */
#define CHARTYPE_LAST_ESC_2253		0x40

/* NB the internal flags are safely reused below by flags
 * handled at the top level.
 */

/* If this is set we convert all character strings
 * to UTF8 first
 */

#define ASN1_STRFLGS_UTF8_CONVERT	0x10

/* If this is set we don't attempt to interpret content:
 * just assume all strings are 1 byte per character. This
 * will produce some pretty odd looking output!
 */

#define ASN1_STRFLGS_IGNORE_TYPE	0x20

/* If this is set we include the string type in the output */
#define ASN1_STRFLGS_SHOW_TYPE		0x40

/* This determines which strings to display and which to
 * 'dump' (hex dump of content octets or DER encoding). We can
 * only dump non character strings or everything. If we
 * don't dump 'unknown' they are interpreted as character
 * strings with 1 octet per character and are subject to
 * the usual escaping options.
 */

#define ASN1_STRFLGS_DUMP_ALL		0x80
#define ASN1_STRFLGS_DUMP_UNKNOWN	0x100

/* These determine what 'dumping' does, we can dump the
 * content octets or the DER encoding: both use the
 * RFC2253 #NNNNN notation.
 */

#define ASN1_STRFLGS_DUMP_DER		0x200

/* All the string flags consistent with RFC2253,
 * escaping control characters isn't essential in
 * RFC2253 but it is advisable anyway.
 */

#define ASN1_STRFLGS_RFC2253	(ASN1_STRFLGS_ESC_2253 | \
				ASN1_STRFLGS_ESC_CTRL | \
				ASN1_STRFLGS_ESC_MSB | \
				ASN1_STRFLGS_UTF8_CONVERT | \
				ASN1_STRFLGS_DUMP_UNKNOWN | \
				ASN1_STRFLGS_DUMP_DER)

DECLARE_STACK_OF(ASN1_INTEGER)
DECLARE_ASN1_SET_OF(ASN1_INTEGER)

DECLARE_STACK_OF(ASN1_GENERALSTRING)

typedef struct asn1_type_st {
	int type;
	union {
		char *ptr;
		ASN1_BOOLEAN		boolean;
		ASN1_STRING *		asn1_string;
		ASN1_OBJECT *		object;
		ASN1_INTEGER *		integer;
		ASN1_ENUMERATED *	enumerated;
		ASN1_BIT_STRING *	bit_string;
		ASN1_OCTET_STRING *	octet_string;
		ASN1_PRINTABLESTRING *	printablestring;
		ASN1_T61STRING *	t61string;
		ASN1_IA5STRING *	ia5string;
		ASN1_GENERALSTRING *	generalstring;
		ASN1_BMPSTRING *	bmpstring;
		ASN1_UNIVERSALSTRING *	universalstring;
		ASN1_UTCTIME *		utctime;
		ASN1_GENERALIZEDTIME *	generalizedtime;
		ASN1_VISIBLESTRING *	visiblestring;
		ASN1_UTF8STRING *	utf8string;
		/* set and sequence are left complete and still
		 * contain the set or sequence bytes */
		ASN1_STRING *		set;
		ASN1_STRING *		sequence;
		ASN1_VALUE *		asn1_value;
	} value;
} ASN1_TYPE;

DECLARE_STACK_OF(ASN1_TYPE)
DECLARE_ASN1_SET_OF(ASN1_TYPE)

typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY;

DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)
DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SET_ANY)

typedef struct NETSCAPE_X509_st {
	ASN1_OCTET_STRING *header;
	X509 *cert;
} NETSCAPE_X509;

/* This is used to contain a list of bit names */
typedef struct BIT_STRING_BITNAME_st {
	int bitnum;
	const char *lname;
	const char *sname;
} BIT_STRING_BITNAME;


#define M_ASN1_STRING_length(x)	((x)->length)
#define M_ASN1_STRING_length_set(x, n)	((x)->length = (n))
#define M_ASN1_STRING_type(x)	((x)->type)
#define M_ASN1_STRING_data(x)	((x)->data)

/* Macros for string operations */
#define M_ASN1_BIT_STRING_new()	(ASN1_BIT_STRING *)\
		ASN1_STRING_type_new(V_ASN1_BIT_STRING)
#define M_ASN1_BIT_STRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
#define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\
		ASN1_STRING_dup((const ASN1_STRING *)a)
#define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\
		(const ASN1_STRING *)a,(const ASN1_STRING *)b)
#define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)

#define M_ASN1_INTEGER_new()	(ASN1_INTEGER *)\
		ASN1_STRING_type_new(V_ASN1_INTEGER)
#define M_ASN1_INTEGER_free(a)		ASN1_STRING_free((ASN1_STRING *)a)
#define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)\
		ASN1_STRING_dup((const ASN1_STRING *)a)
#define M_ASN1_INTEGER_cmp(a,b)	ASN1_STRING_cmp(\
		(const ASN1_STRING *)a,(const ASN1_STRING *)b)

#define M_ASN1_ENUMERATED_new()	(ASN1_ENUMERATED *)\
		ASN1_STRING_type_new(V_ASN1_ENUMERATED)
#define M_ASN1_ENUMERATED_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
#define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)\
		ASN1_STRING_dup((const ASN1_STRING *)a)
#define M_ASN1_ENUMERATED_cmp(a,b)	ASN1_STRING_cmp(\
		(const ASN1_STRING *)a,(const ASN1_STRING *)b)

#define M_ASN1_OCTET_STRING_new()	(ASN1_OCTET_STRING *)\
		ASN1_STRING_type_new(V_ASN1_OCTET_STRING)
#define M_ASN1_OCTET_STRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
#define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\
		ASN1_STRING_dup((const ASN1_STRING *)a)
#define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\
		(const ASN1_STRING *)a,(const ASN1_STRING *)b)
#define M_ASN1_OCTET_STRING_set(a,b,c)	ASN1_STRING_set((ASN1_STRING *)a,b,c)
#define M_ASN1_OCTET_STRING_print(a,b)	ASN1_STRING_print(a,(ASN1_STRING *)b)
#define M_i2d_ASN1_OCTET_STRING(a,pp) \
		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\
		V_ASN1_UNIVERSAL)

#define B_ASN1_TIME \
			B_ASN1_UTCTIME | \
			B_ASN1_GENERALIZEDTIME

#define B_ASN1_PRINTABLE \
			B_ASN1_NUMERICSTRING| \
			B_ASN1_PRINTABLESTRING| \
			B_ASN1_T61STRING| \
			B_ASN1_IA5STRING| \
			B_ASN1_BIT_STRING| \
			B_ASN1_UNIVERSALSTRING|\
			B_ASN1_BMPSTRING|\
			B_ASN1_UTF8STRING|\
			B_ASN1_SEQUENCE|\
			B_ASN1_UNKNOWN

#define B_ASN1_DIRECTORYSTRING \
			B_ASN1_PRINTABLESTRING| \
			B_ASN1_TELETEXSTRING|\
			B_ASN1_BMPSTRING|\
			B_ASN1_UNIVERSALSTRING|\
			B_ASN1_UTF8STRING

#define B_ASN1_DISPLAYTEXT \
			B_ASN1_IA5STRING| \
			B_ASN1_VISIBLESTRING| \
			B_ASN1_BMPSTRING|\
			B_ASN1_UTF8STRING

#define M_ASN1_PRINTABLE_new()	ASN1_STRING_type_new(V_ASN1_T61STRING)
#define M_ASN1_PRINTABLE_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
#define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
		pp,a->type,V_ASN1_UNIVERSAL)
#define M_d2i_ASN1_PRINTABLE(a,pp,l) \
		d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \
			B_ASN1_PRINTABLE)

#define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
#define M_DIRECTORYSTRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
#define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
						pp,a->type,V_ASN1_UNIVERSAL)
#define M_d2i_DIRECTORYSTRING(a,pp,l) \
		d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \
			B_ASN1_DIRECTORYSTRING)

#define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)
#define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a)
#define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
						pp,a->type,V_ASN1_UNIVERSAL)
#define M_d2i_DISPLAYTEXT(a,pp,l) \
		d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \
			B_ASN1_DISPLAYTEXT)

#define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\
		ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
#define M_ASN1_PRINTABLESTRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
#define M_i2d_ASN1_PRINTABLESTRING(a,pp) \
		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\
		V_ASN1_UNIVERSAL)
#define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \
		(ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\
		((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING)

#define M_ASN1_T61STRING_new()	(ASN1_T61STRING *)\
		ASN1_STRING_type_new(V_ASN1_T61STRING)
#define M_ASN1_T61STRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
#define M_i2d_ASN1_T61STRING(a,pp) \
		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\
		V_ASN1_UNIVERSAL)
#define M_d2i_ASN1_T61STRING(a,pp,l) \
		(ASN1_T61STRING *)d2i_ASN1_type_bytes\
		((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING)

#define M_ASN1_IA5STRING_new()	(ASN1_IA5STRING *)\
		ASN1_STRING_type_new(V_ASN1_IA5STRING)
#define M_ASN1_IA5STRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
#define M_ASN1_IA5STRING_dup(a)	\
		(ASN1_IA5STRING *)ASN1_STRING_dup((const ASN1_STRING *)a)
#define M_i2d_ASN1_IA5STRING(a,pp) \
		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\
			V_ASN1_UNIVERSAL)
#define M_d2i_ASN1_IA5STRING(a,pp,l) \
		(ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\
			B_ASN1_IA5STRING)

#define M_ASN1_UTCTIME_new()	(ASN1_UTCTIME *)\
		ASN1_STRING_type_new(V_ASN1_UTCTIME)
#define M_ASN1_UTCTIME_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
#define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)\
		ASN1_STRING_dup((const ASN1_STRING *)a)

#define M_ASN1_GENERALIZEDTIME_new()	(ASN1_GENERALIZEDTIME *)\
		ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME)
#define M_ASN1_GENERALIZEDTIME_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
#define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\
	(const ASN1_STRING *)a)

#define M_ASN1_TIME_new()	(ASN1_TIME *)\
		ASN1_STRING_type_new(V_ASN1_UTCTIME)
#define M_ASN1_TIME_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
#define M_ASN1_TIME_dup(a) (ASN1_TIME *)\
	ASN1_STRING_dup((const ASN1_STRING *)a)

#define M_ASN1_GENERALSTRING_new()	(ASN1_GENERALSTRING *)\
		ASN1_STRING_type_new(V_ASN1_GENERALSTRING)
#define M_ASN1_GENERALSTRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
#define M_i2d_ASN1_GENERALSTRING(a,pp) \
		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\
			V_ASN1_UNIVERSAL)
#define M_d2i_ASN1_GENERALSTRING(a,pp,l) \
		(ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\
		((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING)

#define M_ASN1_UNIVERSALSTRING_new()	(ASN1_UNIVERSALSTRING *)\
		ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING)
#define M_ASN1_UNIVERSALSTRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
#define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \
		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\
			V_ASN1_UNIVERSAL)
#define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \
		(ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\
		((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING)

#define M_ASN1_BMPSTRING_new()	(ASN1_BMPSTRING *)\
		ASN1_STRING_type_new(V_ASN1_BMPSTRING)
#define M_ASN1_BMPSTRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
#define M_i2d_ASN1_BMPSTRING(a,pp) \
		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\
			V_ASN1_UNIVERSAL)
#define M_d2i_ASN1_BMPSTRING(a,pp,l) \
		(ASN1_BMPSTRING *)d2i_ASN1_type_bytes\
		((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING)

#define M_ASN1_VISIBLESTRING_new()	(ASN1_VISIBLESTRING *)\
		ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)
#define M_ASN1_VISIBLESTRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
#define M_i2d_ASN1_VISIBLESTRING(a,pp) \
		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\
			V_ASN1_UNIVERSAL)
#define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \
		(ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\
		((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING)

#define M_ASN1_UTF8STRING_new()	(ASN1_UTF8STRING *)\
		ASN1_STRING_type_new(V_ASN1_UTF8STRING)
#define M_ASN1_UTF8STRING_free(a)	ASN1_STRING_free((ASN1_STRING *)a)
#define M_i2d_ASN1_UTF8STRING(a,pp) \
		i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\
			V_ASN1_UNIVERSAL)
#define M_d2i_ASN1_UTF8STRING(a,pp,l) \
		(ASN1_UTF8STRING *)d2i_ASN1_type_bytes\
		((ASN1_STRING **)a,pp,l,B_ASN1_UTF8STRING)

/* for the is_set parameter to i2d_ASN1_SET */
#define IS_SEQUENCE	0
#define IS_SET		1

DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)

int ASN1_TYPE_get(ASN1_TYPE *a);
void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
int ASN1_TYPE_cmp(ASN1_TYPE *a, ASN1_TYPE *b);

ASN1_OBJECT *ASN1_OBJECT_new(void );
void ASN1_OBJECT_free(ASN1_OBJECT *a);
int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp);
ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
    long length);
ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
    long length);

DECLARE_ASN1_ITEM(ASN1_OBJECT)

DECLARE_STACK_OF(ASN1_OBJECT)
DECLARE_ASN1_SET_OF(ASN1_OBJECT)

ASN1_STRING *ASN1_STRING_new(void);
void ASN1_STRING_free(ASN1_STRING *a);
int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str);
ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *a);
ASN1_STRING *ASN1_STRING_type_new(int type );
int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);
  /* Since this is used to store all sorts of things, via macros, for now, make
     its data void * */
int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);
int ASN1_STRING_length(const ASN1_STRING *x);
void ASN1_STRING_length_set(ASN1_STRING *x, int n);
int ASN1_STRING_type(ASN1_STRING *x);
unsigned char * ASN1_STRING_data(ASN1_STRING *x);

DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)
int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp);
ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
    const unsigned char **pp, long length);
int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length );
int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,
    unsigned char *flags, int flags_len);

#ifndef OPENSSL_NO_BIO
int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
    BIT_STRING_BITNAME *tbl, int indent);
#endif
int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl);
int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
    BIT_STRING_BITNAME *tbl);

int i2d_ASN1_BOOLEAN(int a, unsigned char **pp);
int d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, long length);

DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)
int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp);
ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
    long length);
ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
    long length);
ASN1_INTEGER *	ASN1_INTEGER_dup(const ASN1_INTEGER *x);
int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);

DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)

int ASN1_UTCTIME_check(ASN1_UTCTIME *a);
ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t);
ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
    int offset_day, long offset_sec);
int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);
int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);

int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
    time_t t);
ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
    time_t t, int offset_day, long offset_sec);
int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);

DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)
ASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a);
int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,
    const ASN1_OCTET_STRING *b);
int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data,
    int len);

DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)
DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)
DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)
DECLARE_ASN1_FUNCTIONS(ASN1_NULL)
DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)

DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)

DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)
DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT)
DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING)
DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING)
DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING)
DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING)
DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)
DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)
DECLARE_ASN1_FUNCTIONS(ASN1_TIME)

DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)

ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t);
ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t, int offset_day,
    long offset_sec);
int ASN1_TIME_check(ASN1_TIME *t);
ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t,
    ASN1_GENERALIZEDTIME **out);
int ASN1_TIME_set_string(ASN1_TIME *s, const char *str);

int i2d_ASN1_SET(STACK_OF(OPENSSL_BLOCK) *a, unsigned char **pp,
    i2d_of_void *i2d, int ex_tag, int ex_class, int is_set);
STACK_OF(OPENSSL_BLOCK) *d2i_ASN1_SET(STACK_OF(OPENSSL_BLOCK) **a,
    const unsigned char **pp, long length, d2i_of_void *d2i,
    void (*free_func)(OPENSSL_BLOCK), int ex_tag, int ex_class);

#ifndef OPENSSL_NO_BIO
int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);
int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size);
int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a);
int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size);
int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a);
int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size);
int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type);
#endif
int i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a);

int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num);
ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,
    const char *sn, const char *ln);

int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
long ASN1_INTEGER_get(const ASN1_INTEGER *a);
ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);
BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn);

int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);
long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a);
ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai);
BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn);

/* General */
/* given a string, return the correct type, max is the maximum length */
int ASN1_PRINTABLE_type(const unsigned char *s, int max);

int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass);
ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
    long length, int Ptag, int Pclass);
unsigned long ASN1_tag2bit(int tag);
/* type is one or more of the B_ASN1_ values. */
ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp,
    long length, int type);

/* PARSING */
int asn1_Finish(ASN1_CTX *c);
int asn1_const_Finish(ASN1_const_CTX *c);

/* SPECIALS */
int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
    int *pclass, long omax);
int ASN1_check_infinite_end(unsigned char **p, long len);
int ASN1_const_check_infinite_end(const unsigned char **p, long len);
void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag,
    int xclass);
int ASN1_put_eoc(unsigned char **pp);
int ASN1_object_size(int constructed, int length, int tag);

/* Used to implement other functions */
void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x);

#define ASN1_dup_of(type,i2d,d2i,x) \
    ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \
		     CHECKED_D2I_OF(type, d2i), \
		     CHECKED_PTR_OF(type, x)))

#define ASN1_dup_of_const(type,i2d,d2i,x) \
    ((type*)ASN1_dup(CHECKED_I2D_OF(const type, i2d), \
		     CHECKED_D2I_OF(type, d2i), \
		     CHECKED_PTR_OF(const type, x)))

void *ASN1_item_dup(const ASN1_ITEM *it, void *x);

/* ASN1 alloc/free macros for when a type is only used internally */

#define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type))
#define M_ASN1_free_of(x, type) \
		ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type))

void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x);

#define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \
    ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \
			CHECKED_D2I_OF(type, d2i), \
			in, \
			CHECKED_PPTR_OF(type, x)))

void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);
int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x);

#define ASN1_i2d_fp_of(type,i2d,out,x) \
    (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \
		 out, \
		 CHECKED_PTR_OF(type, x)))

#define ASN1_i2d_fp_of_const(type,i2d,out,x) \
    (ASN1_i2d_fp(CHECKED_I2D_OF(const type, i2d), \
		 out, \
		 CHECKED_PTR_OF(const type, x)))

int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x);
int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);

int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in);

#ifndef OPENSSL_NO_BIO
void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x);

#define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \
    ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \
			  CHECKED_D2I_OF(type, d2i), \
			  in, \
			  CHECKED_PPTR_OF(type, x)))

void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);
int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x);

#define ASN1_i2d_bio_of(type,i2d,out,x) \
    (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \
		  out, \
		  CHECKED_PTR_OF(type, x)))

#define ASN1_i2d_bio_of_const(type,i2d,out,x) \
    (ASN1_i2d_bio(CHECKED_I2D_OF(const type, i2d), \
		  out, \
		  CHECKED_PTR_OF(const type, x)))

int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);
int ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a);
int ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a);
int ASN1_TIME_print(BIO *fp, const ASN1_TIME *a);
int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v);
int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);
int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,
    unsigned char *buf, int off);
int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent);
int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent, int dump);
#endif
const char *ASN1_tag2str(int tag);

/* Used to load and write netscape format cert */

DECLARE_ASN1_FUNCTIONS(NETSCAPE_X509)

int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);

int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len);
int ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data, int max_len);
int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data,
    int len);
int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num, unsigned char *data,
    int max_len);

STACK_OF(OPENSSL_BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len,
    d2i_of_void *d2i, void (*free_func)(OPENSSL_BLOCK));
unsigned char *ASN1_seq_pack(STACK_OF(OPENSSL_BLOCK) *safes, i2d_of_void *i2d,
    unsigned char **buf, int *len );
void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i);
void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);
ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d,
    ASN1_OCTET_STRING **oct);

ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it,
    ASN1_OCTET_STRING **oct);

void ASN1_STRING_set_default_mask(unsigned long mask);
int ASN1_STRING_set_default_mask_asc(const char *p);
unsigned long ASN1_STRING_get_default_mask(void);
int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
    int inform, unsigned long mask);
int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
    int inform, unsigned long mask, long minsize, long maxsize);

ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
    const unsigned char *in, int inlen, int inform, int nid);
ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
void ASN1_STRING_TABLE_cleanup(void);

/* ASN1 template functions */

/* Old API compatible functions */
ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);
void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);
ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in,
    long len, const ASN1_ITEM *it);
int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);

void ASN1_add_oid_module(void);

ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf);
ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf);

/* ASN1 Print flags */

/* Indicate missing OPTIONAL fields */
#define ASN1_PCTX_FLAGS_SHOW_ABSENT		0x001
/* Mark start and end of SEQUENCE */
#define ASN1_PCTX_FLAGS_SHOW_SEQUENCE		0x002
/* Mark start and end of SEQUENCE/SET OF */
#define ASN1_PCTX_FLAGS_SHOW_SSOF		0x004
/* Show the ASN1 type of primitives */
#define ASN1_PCTX_FLAGS_SHOW_TYPE		0x008
/* Don't show ASN1 type of ANY */
#define ASN1_PCTX_FLAGS_NO_ANY_TYPE		0x010
/* Don't show ASN1 type of MSTRINGs */
#define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE		0x020
/* Don't show field names in SEQUENCE */
#define ASN1_PCTX_FLAGS_NO_FIELD_NAME		0x040
/* Show structure names of each SEQUENCE field */
#define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME	0x080
/* Don't show structure name even at top level */
#define ASN1_PCTX_FLAGS_NO_STRUCT_NAME		0x100

int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,
    const ASN1_ITEM *it, const ASN1_PCTX *pctx);
ASN1_PCTX *ASN1_PCTX_new(void);
void ASN1_PCTX_free(ASN1_PCTX *p);
unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p);
void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags);
unsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p);
void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags);
unsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p);
void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags);
unsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p);
void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags);
unsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p);
void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags);

BIO_METHOD *BIO_f_asn1(void);

BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it);

int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
    const ASN1_ITEM *it);
int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
    const char *hdr, const ASN1_ITEM *it);
int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
    int ctype_nid, int econt_nid, STACK_OF(X509_ALGOR) *mdalgs,
    const ASN1_ITEM *it);
ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it);
int SMIME_crlf_copy(BIO *in, BIO *out, int flags);
int SMIME_text(BIO *in, BIO *out);

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_ASN1_strings(void);

/* Error codes for the ASN1 functions. */

/* Function codes. */
#define ASN1_F_A2D_ASN1_OBJECT				 100
#define ASN1_F_A2I_ASN1_ENUMERATED			 101
#define ASN1_F_A2I_ASN1_INTEGER				 102
#define ASN1_F_A2I_ASN1_STRING				 103
#define ASN1_F_APPEND_EXP				 176
#define ASN1_F_ASN1_BIT_STRING_SET_BIT			 183
#define ASN1_F_ASN1_CB					 177
#define ASN1_F_ASN1_CHECK_TLEN				 104
#define ASN1_F_ASN1_COLLATE_PRIMITIVE			 105
#define ASN1_F_ASN1_COLLECT				 106
#define ASN1_F_ASN1_D2I_EX_PRIMITIVE			 108
#define ASN1_F_ASN1_D2I_FP				 109
#define ASN1_F_ASN1_D2I_READ_BIO			 107
#define ASN1_F_ASN1_DIGEST				 184
#define ASN1_F_ASN1_DO_ADB				 110
#define ASN1_F_ASN1_DUP					 111
#define ASN1_F_ASN1_ENUMERATED_SET			 112
#define ASN1_F_ASN1_ENUMERATED_TO_BN			 113
#define ASN1_F_ASN1_EX_C2I				 204
#define ASN1_F_ASN1_FIND_END				 190
#define ASN1_F_ASN1_GENERALIZEDTIME_ADJ			 216
#define ASN1_F_ASN1_GENERALIZEDTIME_SET			 185
#define ASN1_F_ASN1_GENERATE_V3				 178
#define ASN1_F_ASN1_GET_OBJECT				 114
#define ASN1_F_ASN1_HEADER_NEW				 115
#define ASN1_F_ASN1_I2D_BIO				 116
#define ASN1_F_ASN1_I2D_FP				 117
#define ASN1_F_ASN1_INTEGER_SET				 118
#define ASN1_F_ASN1_INTEGER_TO_BN			 119
#define ASN1_F_ASN1_ITEM_D2I_FP				 206
#define ASN1_F_ASN1_ITEM_DUP				 191
#define ASN1_F_ASN1_ITEM_EX_COMBINE_NEW			 121
#define ASN1_F_ASN1_ITEM_EX_D2I				 120
#define ASN1_F_ASN1_ITEM_I2D_BIO			 192
#define ASN1_F_ASN1_ITEM_I2D_FP				 193
#define ASN1_F_ASN1_ITEM_PACK				 198
#define ASN1_F_ASN1_ITEM_SIGN				 195
#define ASN1_F_ASN1_ITEM_SIGN_CTX			 220
#define ASN1_F_ASN1_ITEM_UNPACK				 199
#define ASN1_F_ASN1_ITEM_VERIFY				 197
#define ASN1_F_ASN1_MBSTRING_NCOPY			 122
#define ASN1_F_ASN1_OBJECT_NEW				 123
#define ASN1_F_ASN1_OUTPUT_DATA				 214
#define ASN1_F_ASN1_PACK_STRING				 124
#define ASN1_F_ASN1_PCTX_NEW				 205
#define ASN1_F_ASN1_PKCS5_PBE_SET			 125
#define ASN1_F_ASN1_SEQ_PACK				 126
#define ASN1_F_ASN1_SEQ_UNPACK				 127
#define ASN1_F_ASN1_SIGN				 128
#define ASN1_F_ASN1_STR2TYPE				 179
#define ASN1_F_ASN1_STRING_SET				 186
#define ASN1_F_ASN1_STRING_TABLE_ADD			 129
#define ASN1_F_ASN1_STRING_TYPE_NEW			 130
#define ASN1_F_ASN1_TEMPLATE_EX_D2I			 132
#define ASN1_F_ASN1_TEMPLATE_NEW			 133
#define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I			 131
#define ASN1_F_ASN1_TIME_ADJ				 217
#define ASN1_F_ASN1_TIME_SET				 175
#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING		 134
#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING		 135
#define ASN1_F_ASN1_UNPACK_STRING			 136
#define ASN1_F_ASN1_UTCTIME_ADJ				 218
#define ASN1_F_ASN1_UTCTIME_SET				 187
#define ASN1_F_ASN1_VERIFY				 137
#define ASN1_F_B64_READ_ASN1				 209
#define ASN1_F_B64_WRITE_ASN1				 210
#define ASN1_F_BIO_NEW_NDEF				 208
#define ASN1_F_BITSTR_CB				 180
#define ASN1_F_BN_TO_ASN1_ENUMERATED			 138
#define ASN1_F_BN_TO_ASN1_INTEGER			 139
#define ASN1_F_C2I_ASN1_BIT_STRING			 189
#define ASN1_F_C2I_ASN1_INTEGER				 194
#define ASN1_F_C2I_ASN1_OBJECT				 196
#define ASN1_F_COLLECT_DATA				 140
#define ASN1_F_D2I_ASN1_BIT_STRING			 141
#define ASN1_F_D2I_ASN1_BOOLEAN				 142
#define ASN1_F_D2I_ASN1_BYTES				 143
#define ASN1_F_D2I_ASN1_GENERALIZEDTIME			 144
#define ASN1_F_D2I_ASN1_HEADER				 145
#define ASN1_F_D2I_ASN1_INTEGER				 146
#define ASN1_F_D2I_ASN1_OBJECT				 147
#define ASN1_F_D2I_ASN1_SET				 148
#define ASN1_F_D2I_ASN1_TYPE_BYTES			 149
#define ASN1_F_D2I_ASN1_UINTEGER			 150
#define ASN1_F_D2I_ASN1_UTCTIME				 151
#define ASN1_F_D2I_AUTOPRIVATEKEY			 207
#define ASN1_F_D2I_NETSCAPE_RSA				 152
#define ASN1_F_D2I_NETSCAPE_RSA_2			 153
#define ASN1_F_D2I_PRIVATEKEY				 154
#define ASN1_F_D2I_PUBLICKEY				 155
#define ASN1_F_D2I_RSA_NET				 200
#define ASN1_F_D2I_RSA_NET_2				 201
#define ASN1_F_D2I_X509					 156
#define ASN1_F_D2I_X509_CINF				 157
#define ASN1_F_D2I_X509_PKEY				 159
#define ASN1_F_I2D_ASN1_BIO_STREAM			 211
#define ASN1_F_I2D_ASN1_SET				 188
#define ASN1_F_I2D_ASN1_TIME				 160
#define ASN1_F_I2D_DSA_PUBKEY				 161
#define ASN1_F_I2D_EC_PUBKEY				 181
#define ASN1_F_I2D_PRIVATEKEY				 163
#define ASN1_F_I2D_PUBLICKEY				 164
#define ASN1_F_I2D_RSA_NET				 162
#define ASN1_F_I2D_RSA_PUBKEY				 165
#define ASN1_F_LONG_C2I					 166
#define ASN1_F_OID_MODULE_INIT				 174
#define ASN1_F_PARSE_TAGGING				 182
#define ASN1_F_PKCS5_PBE2_SET_IV			 167
#define ASN1_F_PKCS5_PBE_SET				 202
#define ASN1_F_PKCS5_PBE_SET0_ALGOR			 215
#define ASN1_F_PKCS5_PBKDF2_SET				 219
#define ASN1_F_SMIME_READ_ASN1				 212
#define ASN1_F_SMIME_TEXT				 213
#define ASN1_F_X509_CINF_NEW				 168
#define ASN1_F_X509_CRL_ADD0_REVOKED			 169
#define ASN1_F_X509_INFO_NEW				 170
#define ASN1_F_X509_NAME_ENCODE				 203
#define ASN1_F_X509_NAME_EX_D2I				 158
#define ASN1_F_X509_NAME_EX_NEW				 171
#define ASN1_F_X509_NEW					 172
#define ASN1_F_X509_PKEY_NEW				 173

/* Reason codes. */
#define ASN1_R_ADDING_OBJECT				 171
#define ASN1_R_ASN1_PARSE_ERROR				 203
#define ASN1_R_ASN1_SIG_PARSE_ERROR			 204
#define ASN1_R_AUX_ERROR				 100
#define ASN1_R_BAD_CLASS				 101
#define ASN1_R_BAD_OBJECT_HEADER			 102
#define ASN1_R_BAD_PASSWORD_READ			 103
#define ASN1_R_BAD_TAG					 104
#define ASN1_R_BMPSTRING_IS_WRONG_LENGTH		 214
#define ASN1_R_BN_LIB					 105
#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH			 106
#define ASN1_R_BUFFER_TOO_SMALL				 107
#define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER		 108
#define ASN1_R_CONTEXT_NOT_INITIALISED			 217
#define ASN1_R_DATA_IS_WRONG				 109
#define ASN1_R_DECODE_ERROR				 110
#define ASN1_R_DECODING_ERROR				 111
#define ASN1_R_DEPTH_EXCEEDED				 174
#define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED	 198
#define ASN1_R_ENCODE_ERROR				 112
#define ASN1_R_ERROR_GETTING_TIME			 173
#define ASN1_R_ERROR_LOADING_SECTION			 172
#define ASN1_R_ERROR_PARSING_SET_ELEMENT		 113
#define ASN1_R_ERROR_SETTING_CIPHER_PARAMS		 114
#define ASN1_R_EXPECTING_AN_INTEGER			 115
#define ASN1_R_EXPECTING_AN_OBJECT			 116
#define ASN1_R_EXPECTING_A_BOOLEAN			 117
#define ASN1_R_EXPECTING_A_TIME				 118
#define ASN1_R_EXPLICIT_LENGTH_MISMATCH			 119
#define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED		 120
#define ASN1_R_FIELD_MISSING				 121
#define ASN1_R_FIRST_NUM_TOO_LARGE			 122
#define ASN1_R_HEADER_TOO_LONG				 123
#define ASN1_R_ILLEGAL_BITSTRING_FORMAT			 175
#define ASN1_R_ILLEGAL_BOOLEAN				 176
#define ASN1_R_ILLEGAL_CHARACTERS			 124
#define ASN1_R_ILLEGAL_FORMAT				 177
#define ASN1_R_ILLEGAL_HEX				 178
#define ASN1_R_ILLEGAL_IMPLICIT_TAG			 179
#define ASN1_R_ILLEGAL_INTEGER				 180
#define ASN1_R_ILLEGAL_NESTED_TAGGING			 181
#define ASN1_R_ILLEGAL_NULL				 125
#define ASN1_R_ILLEGAL_NULL_VALUE			 182
#define ASN1_R_ILLEGAL_OBJECT				 183
#define ASN1_R_ILLEGAL_OPTIONAL_ANY			 126
#define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE		 170
#define ASN1_R_ILLEGAL_TAGGED_ANY			 127
#define ASN1_R_ILLEGAL_TIME_VALUE			 184
#define ASN1_R_INTEGER_NOT_ASCII_FORMAT			 185
#define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG		 128
#define ASN1_R_INVALID_BMPSTRING_LENGTH			 129
#define ASN1_R_INVALID_DIGIT				 130
#define ASN1_R_INVALID_MIME_TYPE			 205
#define ASN1_R_INVALID_MODIFIER				 186
#define ASN1_R_INVALID_NUMBER				 187
#define ASN1_R_INVALID_OBJECT_ENCODING			 216
#define ASN1_R_INVALID_SEPARATOR			 131
#define ASN1_R_INVALID_TIME_FORMAT			 132
#define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH		 133
#define ASN1_R_INVALID_UTF8STRING			 134
#define ASN1_R_IV_TOO_LARGE				 135
#define ASN1_R_LENGTH_ERROR				 136
#define ASN1_R_LIST_ERROR				 188
#define ASN1_R_MIME_NO_CONTENT_TYPE			 206
#define ASN1_R_MIME_PARSE_ERROR				 207
#define ASN1_R_MIME_SIG_PARSE_ERROR			 208
#define ASN1_R_MISSING_EOC				 137
#define ASN1_R_MISSING_SECOND_NUMBER			 138
#define ASN1_R_MISSING_VALUE				 189
#define ASN1_R_MSTRING_NOT_UNIVERSAL			 139
#define ASN1_R_MSTRING_WRONG_TAG			 140
#define ASN1_R_NESTED_ASN1_STRING			 197
#define ASN1_R_NON_HEX_CHARACTERS			 141
#define ASN1_R_NOT_ASCII_FORMAT				 190
#define ASN1_R_NOT_ENOUGH_DATA				 142
#define ASN1_R_NO_CONTENT_TYPE				 209
#define ASN1_R_NO_DEFAULT_DIGEST			 201
#define ASN1_R_NO_MATCHING_CHOICE_TYPE			 143
#define ASN1_R_NO_MULTIPART_BODY_FAILURE		 210
#define ASN1_R_NO_MULTIPART_BOUNDARY			 211
#define ASN1_R_NO_SIG_CONTENT_TYPE			 212
#define ASN1_R_NULL_IS_WRONG_LENGTH			 144
#define ASN1_R_OBJECT_NOT_ASCII_FORMAT			 191
#define ASN1_R_ODD_NUMBER_OF_CHARS			 145
#define ASN1_R_PRIVATE_KEY_HEADER_MISSING		 146
#define ASN1_R_SECOND_NUMBER_TOO_LARGE			 147
#define ASN1_R_SEQUENCE_LENGTH_MISMATCH			 148
#define ASN1_R_SEQUENCE_NOT_CONSTRUCTED			 149
#define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG		 192
#define ASN1_R_SHORT_LINE				 150
#define ASN1_R_SIG_INVALID_MIME_TYPE			 213
#define ASN1_R_STREAMING_NOT_SUPPORTED			 202
#define ASN1_R_STRING_TOO_LONG				 151
#define ASN1_R_STRING_TOO_SHORT				 152
#define ASN1_R_TAG_VALUE_TOO_HIGH			 153
#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154
#define ASN1_R_TIME_NOT_ASCII_FORMAT			 193
#define ASN1_R_TOO_LONG					 155
#define ASN1_R_TYPE_NOT_CONSTRUCTED			 156
#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY			 157
#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY		 158
#define ASN1_R_UNEXPECTED_EOC				 159
#define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH		 215
#define ASN1_R_UNKNOWN_FORMAT				 160
#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM		 161
#define ASN1_R_UNKNOWN_OBJECT_TYPE			 162
#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE			 163
#define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM		 199
#define ASN1_R_UNKNOWN_TAG				 194
#define ASN1_R_UNKOWN_FORMAT				 195
#define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE		 164
#define ASN1_R_UNSUPPORTED_CIPHER			 165
#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM		 166
#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE		 167
#define ASN1_R_UNSUPPORTED_TYPE				 196
#define ASN1_R_WRONG_PUBLIC_KEY_TYPE			 200
#define ASN1_R_WRONG_TAG				 168
#define ASN1_R_WRONG_TYPE				 169

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/lhash.h0000644000175000017500000002146212360020705021316 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

/* Header for dynamic hash table routines
 * Author - Eric Young
 */

#ifndef HEADER_LHASH_H
#define HEADER_LHASH_H

#include 

#include 

#ifndef OPENSSL_NO_BIO
#include 
#endif

#ifdef  __cplusplus
extern "C" {
#endif

typedef struct lhash_node_st {
	void *data;
	struct lhash_node_st *next;
#ifndef OPENSSL_NO_HASH_COMP
	unsigned long hash;
#endif
} LHASH_NODE;

typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *);
typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *);
typedef void (*LHASH_DOALL_FN_TYPE)(void *);
typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *);

/* Macros for declaring and implementing type-safe wrappers for LHASH callbacks.
 * This way, callbacks can be provided to LHASH structures without function
 * pointer casting and the macro-defined callbacks provide per-variable casting
 * before deferring to the underlying type-specific callbacks. NB: It is
 * possible to place a "static" in front of both the DECLARE and IMPLEMENT
 * macros if the functions are strictly internal. */

/* First: "hash" functions */
#define DECLARE_LHASH_HASH_FN(name, o_type) \
	unsigned long name##_LHASH_HASH(const void *);
#define IMPLEMENT_LHASH_HASH_FN(name, o_type) \
	unsigned long name##_LHASH_HASH(const void *arg) { \
		const o_type *a = arg; \
		return name##_hash(a); }
#define LHASH_HASH_FN(name) name##_LHASH_HASH

/* Second: "compare" functions */
#define DECLARE_LHASH_COMP_FN(name, o_type) \
	int name##_LHASH_COMP(const void *, const void *);
#define IMPLEMENT_LHASH_COMP_FN(name, o_type) \
	int name##_LHASH_COMP(const void *arg1, const void *arg2) { \
		const o_type *a = arg1;		    \
		const o_type *b = arg2; \
		return name##_cmp(a,b); }
#define LHASH_COMP_FN(name) name##_LHASH_COMP

/* Third: "doall" functions */
#define DECLARE_LHASH_DOALL_FN(name, o_type) \
	void name##_LHASH_DOALL(void *);
#define IMPLEMENT_LHASH_DOALL_FN(name, o_type) \
	void name##_LHASH_DOALL(void *arg) { \
		o_type *a = arg; \
		name##_doall(a); }
#define LHASH_DOALL_FN(name) name##_LHASH_DOALL

/* Fourth: "doall_arg" functions */
#define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
	void name##_LHASH_DOALL_ARG(void *, void *);
#define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
	void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \
		o_type *a = arg1; \
		a_type *b = arg2; \
		name##_doall_arg(a, b); }
#define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG

typedef struct lhash_st {
	LHASH_NODE **b;
	LHASH_COMP_FN_TYPE comp;
	LHASH_HASH_FN_TYPE hash;
	unsigned int num_nodes;
	unsigned int num_alloc_nodes;
	unsigned int p;
	unsigned int pmax;
	unsigned long up_load; /* load times 256 */
	unsigned long down_load; /* load times 256 */
	unsigned long num_items;

	unsigned long num_expands;
	unsigned long num_expand_reallocs;
	unsigned long num_contracts;
	unsigned long num_contract_reallocs;
	unsigned long num_hash_calls;
	unsigned long num_comp_calls;
	unsigned long num_insert;
	unsigned long num_replace;
	unsigned long num_delete;
	unsigned long num_no_delete;
	unsigned long num_retrieve;
	unsigned long num_retrieve_miss;
	unsigned long num_hash_comps;

	int error;
} _LHASH;	/* Do not use _LHASH directly, use LHASH_OF
		 * and friends */

#define LH_LOAD_MULT	256

/* Indicates a malloc() error in the last call, this is only bad
 * in lh_insert(). */
#define lh_error(lh)	((lh)->error)

_LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c);
void lh_free(_LHASH *lh);
void *lh_insert(_LHASH *lh, void *data);
void *lh_delete(_LHASH *lh, const void *data);
void *lh_retrieve(_LHASH *lh, const void *data);
void lh_doall(_LHASH *lh, LHASH_DOALL_FN_TYPE func);
void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg);
unsigned long lh_strhash(const char *c);
unsigned long lh_num_items(const _LHASH *lh);

void lh_stats(const _LHASH *lh, FILE *out);
void lh_node_stats(const _LHASH *lh, FILE *out);
void lh_node_usage_stats(const _LHASH *lh, FILE *out);

#ifndef OPENSSL_NO_BIO
void lh_stats_bio(const _LHASH *lh, BIO *out);
void lh_node_stats_bio(const _LHASH *lh, BIO *out);
void lh_node_usage_stats_bio(const _LHASH *lh, BIO *out);
#endif

/* Type checking... */

#define LHASH_OF(type) struct lhash_st_##type

#define DECLARE_LHASH_OF(type) LHASH_OF(type) { int dummy; }

#define CHECKED_LHASH_OF(type,lh) \
  ((_LHASH *)CHECKED_PTR_OF(LHASH_OF(type),lh))

/* Define wrapper functions. */
#define LHM_lh_new(type, name) \
  ((LHASH_OF(type) *)lh_new(LHASH_HASH_FN(name), LHASH_COMP_FN(name)))
#define LHM_lh_error(type, lh) \
  lh_error(CHECKED_LHASH_OF(type,lh))
#define LHM_lh_insert(type, lh, inst) \
  ((type *)lh_insert(CHECKED_LHASH_OF(type, lh), \
		     CHECKED_PTR_OF(type, inst)))
#define LHM_lh_retrieve(type, lh, inst) \
  ((type *)lh_retrieve(CHECKED_LHASH_OF(type, lh), \
		       CHECKED_PTR_OF(type, inst)))
#define LHM_lh_delete(type, lh, inst) \
  ((type *)lh_delete(CHECKED_LHASH_OF(type, lh),			\
		     CHECKED_PTR_OF(type, inst)))
#define LHM_lh_doall(type, lh,fn) lh_doall(CHECKED_LHASH_OF(type, lh), fn)
#define LHM_lh_doall_arg(type, lh, fn, arg_type, arg) \
  lh_doall_arg(CHECKED_LHASH_OF(type, lh), fn, CHECKED_PTR_OF(arg_type, arg))
#define LHM_lh_num_items(type, lh) lh_num_items(CHECKED_LHASH_OF(type, lh))
#define LHM_lh_down_load(type, lh) (CHECKED_LHASH_OF(type, lh)->down_load)
#define LHM_lh_node_stats_bio(type, lh, out) \
  lh_node_stats_bio(CHECKED_LHASH_OF(type, lh), out)
#define LHM_lh_node_usage_stats_bio(type, lh, out) \
  lh_node_usage_stats_bio(CHECKED_LHASH_OF(type, lh), out)
#define LHM_lh_stats_bio(type, lh, out) \
  lh_stats_bio(CHECKED_LHASH_OF(type, lh), out)
#define LHM_lh_free(type, lh) lh_free(CHECKED_LHASH_OF(type, lh))

DECLARE_LHASH_OF(OPENSSL_STRING);
DECLARE_LHASH_OF(OPENSSL_CSTRING);

#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/pem2.h0000644000175000017500000000547612360020705021071 0ustar  /* $OpenBSD$ */
/* ====================================================================
 * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    licensing@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

/*
 * This header only exists to break a circular dependency between pem and err
 * Ben 30 Jan 1999.
 */

#ifdef __cplusplus
extern "C" {
#endif

#ifndef HEADER_PEM_H
void ERR_load_PEM_strings(void);
#endif

#ifdef __cplusplus
}
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/ui_compat.h0000644000175000017500000000651412360020705022200 0ustar  /* $OpenBSD$ */
/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
 * project 2001.
 */
/* ====================================================================
 * Copyright (c) 2001 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#ifndef HEADER_UI_COMPAT_H
#define HEADER_UI_COMPAT_H

#include 
#include 

#ifdef  __cplusplus
extern "C" {
#endif

/* The following functions were previously part of the DES section,
   and are provided here for backward compatibility reasons. */

#define des_read_pw_string(b,l,p,v) \
	_ossl_old_des_read_pw_string((b),(l),(p),(v))
#define des_read_pw(b,bf,s,p,v) \
	_ossl_old_des_read_pw((b),(bf),(s),(p),(v))

int _ossl_old_des_read_pw_string(char *buf, int length, const char *prompt, int verify);
int _ossl_old_des_read_pw(char *buf, char *buff, int size, const char *prompt, int verify);

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/ssl2.h0000644000175000017500000002464112360020705021104 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_SSL2_H 
#define HEADER_SSL2_H 

#ifdef  __cplusplus
extern "C" {
#endif

/* Protocol Version Codes */
#define SSL2_VERSION		0x0002
#define SSL2_VERSION_MAJOR	0x00
#define SSL2_VERSION_MINOR	0x02
/* #define SSL2_CLIENT_VERSION	0x0002 */
/* #define SSL2_SERVER_VERSION	0x0002 */

/* Protocol Message Codes */
#define SSL2_MT_ERROR			0
#define SSL2_MT_CLIENT_HELLO		1
#define SSL2_MT_CLIENT_MASTER_KEY	2
#define SSL2_MT_CLIENT_FINISHED		3
#define SSL2_MT_SERVER_HELLO		4
#define SSL2_MT_SERVER_VERIFY		5
#define SSL2_MT_SERVER_FINISHED		6
#define SSL2_MT_REQUEST_CERTIFICATE	7
#define SSL2_MT_CLIENT_CERTIFICATE	8

/* Error Message Codes */
#define SSL2_PE_UNDEFINED_ERROR		0x0000
#define SSL2_PE_NO_CIPHER		0x0001
#define SSL2_PE_NO_CERTIFICATE		0x0002
#define SSL2_PE_BAD_CERTIFICATE		0x0004
#define SSL2_PE_UNSUPPORTED_CERTIFICATE_TYPE 0x0006

/* Cipher Kind Values */
#define SSL2_CK_NULL_WITH_MD5			0x02000000 /* v3 */
#define SSL2_CK_RC4_128_WITH_MD5		0x02010080
#define SSL2_CK_RC4_128_EXPORT40_WITH_MD5	0x02020080
#define SSL2_CK_RC2_128_CBC_WITH_MD5		0x02030080
#define SSL2_CK_RC2_128_CBC_EXPORT40_WITH_MD5	0x02040080
#define SSL2_CK_IDEA_128_CBC_WITH_MD5		0x02050080
#define SSL2_CK_DES_64_CBC_WITH_MD5		0x02060040
#define SSL2_CK_DES_64_CBC_WITH_SHA		0x02060140 /* v3 */
#define SSL2_CK_DES_192_EDE3_CBC_WITH_MD5	0x020700c0
#define SSL2_CK_DES_192_EDE3_CBC_WITH_SHA	0x020701c0 /* v3 */
#define SSL2_CK_RC4_64_WITH_MD5			0x02080080 /* MS hack */

#define SSL2_CK_DES_64_CFB64_WITH_MD5_1		0x02ff0800 /* SSLeay */
#define SSL2_CK_NULL				0x02ff0810 /* SSLeay */

#define SSL2_TXT_DES_64_CFB64_WITH_MD5_1	"DES-CFB-M1"
#define SSL2_TXT_NULL_WITH_MD5			"NULL-MD5"
#define SSL2_TXT_RC4_128_WITH_MD5		"RC4-MD5"
#define SSL2_TXT_RC4_128_EXPORT40_WITH_MD5	"EXP-RC4-MD5"
#define SSL2_TXT_RC2_128_CBC_WITH_MD5		"RC2-CBC-MD5"
#define SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5	"EXP-RC2-CBC-MD5"
#define SSL2_TXT_IDEA_128_CBC_WITH_MD5		"IDEA-CBC-MD5"
#define SSL2_TXT_DES_64_CBC_WITH_MD5		"DES-CBC-MD5"
#define SSL2_TXT_DES_64_CBC_WITH_SHA		"DES-CBC-SHA"
#define SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5	"DES-CBC3-MD5"
#define SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA	"DES-CBC3-SHA"
#define SSL2_TXT_RC4_64_WITH_MD5		"RC4-64-MD5"

#define SSL2_TXT_NULL				"NULL"

/* Flags for the SSL_CIPHER.algorithm2 field */
#define SSL2_CF_5_BYTE_ENC			0x01
#define SSL2_CF_8_BYTE_ENC			0x02

/* Certificate Type Codes */
#define SSL2_CT_X509_CERTIFICATE		0x01

/* Authentication Type Code */
#define SSL2_AT_MD5_WITH_RSA_ENCRYPTION		0x01

#define SSL2_MAX_SSL_SESSION_ID_LENGTH		32

/* Upper/Lower Bounds */
#define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS	256
#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER	32767u	/* 2^15-1 */
#define SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER	16383	/* 2^14-1 */

#define SSL2_CHALLENGE_LENGTH	16
/*#define SSL2_CHALLENGE_LENGTH	32 */
#define SSL2_MIN_CHALLENGE_LENGTH	16
#define SSL2_MAX_CHALLENGE_LENGTH	32
#define SSL2_CONNECTION_ID_LENGTH	16
#define SSL2_MAX_CONNECTION_ID_LENGTH	16
#define SSL2_SSL_SESSION_ID_LENGTH	16
#define SSL2_MAX_CERT_CHALLENGE_LENGTH	32
#define SSL2_MIN_CERT_CHALLENGE_LENGTH	16
#define SSL2_MAX_KEY_MATERIAL_LENGTH	24

#ifndef HEADER_SSL_LOCL_H
#define  CERT		char
#endif

#ifndef OPENSSL_NO_SSL_INTERN

typedef struct ssl2_state_st {
	int three_byte_header;
	int clear_text;		/* clear text */
	int escape;		/* not used in SSLv2 */
	int ssl2_rollback;	/* used if SSLv23 rolled back to SSLv2 */

	/* non-blocking io info, used to make sure the same
	 * args were passwd */
	unsigned int wnum;	/* number of bytes sent so far */
	int wpend_tot;
	const unsigned char *wpend_buf;

	int wpend_off;	/* offset to data to write */
	int wpend_len;	/* number of bytes passwd to write */
	int wpend_ret;	/* number of bytes to return to caller */

	/* buffer raw data */
	int rbuf_left;
	int rbuf_offs;
	unsigned char *rbuf;
	unsigned char *wbuf;

	unsigned char *write_ptr;/* used to point to the start due to
				  * 2/3 byte header. */

	unsigned int padding;
	unsigned int rlength; /* passed to ssl2_enc */
	int ract_data_length; /* Set when things are encrypted. */
	unsigned int wlength; /* passed to ssl2_enc */
	int wact_data_length; /* Set when things are decrypted. */
	unsigned char *ract_data;
	unsigned char *wact_data;
	unsigned char *mac_data;

	unsigned char *read_key;
	unsigned char *write_key;

	/* Stuff specifically to do with this SSL session */
	unsigned int challenge_length;
	unsigned char challenge[SSL2_MAX_CHALLENGE_LENGTH];
	unsigned int conn_id_length;
	unsigned char conn_id[SSL2_MAX_CONNECTION_ID_LENGTH];
	unsigned int key_material_length;
	unsigned char key_material[SSL2_MAX_KEY_MATERIAL_LENGTH*2];

	unsigned long read_sequence;
	unsigned long write_sequence;

	struct {
		unsigned int conn_id_length;
		unsigned int cert_type;

		unsigned int cert_length;
		unsigned int csl;

		unsigned int clear;
		unsigned int enc;

		unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH];
		unsigned int cipher_spec_length;
		unsigned int session_id_length;
		unsigned int clen;
		unsigned int rlen;
	} tmp;
} SSL2_STATE;

#endif

/* SSLv2 */
/* client */
#define SSL2_ST_SEND_CLIENT_HELLO_A		(0x10|SSL_ST_CONNECT)
#define SSL2_ST_SEND_CLIENT_HELLO_B		(0x11|SSL_ST_CONNECT)
#define SSL2_ST_GET_SERVER_HELLO_A		(0x20|SSL_ST_CONNECT)
#define SSL2_ST_GET_SERVER_HELLO_B		(0x21|SSL_ST_CONNECT)
#define SSL2_ST_SEND_CLIENT_MASTER_KEY_A	(0x30|SSL_ST_CONNECT)
#define SSL2_ST_SEND_CLIENT_MASTER_KEY_B	(0x31|SSL_ST_CONNECT)
#define SSL2_ST_SEND_CLIENT_FINISHED_A		(0x40|SSL_ST_CONNECT)
#define SSL2_ST_SEND_CLIENT_FINISHED_B		(0x41|SSL_ST_CONNECT)
#define SSL2_ST_SEND_CLIENT_CERTIFICATE_A	(0x50|SSL_ST_CONNECT)
#define SSL2_ST_SEND_CLIENT_CERTIFICATE_B	(0x51|SSL_ST_CONNECT)
#define SSL2_ST_SEND_CLIENT_CERTIFICATE_C	(0x52|SSL_ST_CONNECT)
#define SSL2_ST_SEND_CLIENT_CERTIFICATE_D	(0x53|SSL_ST_CONNECT)
#define SSL2_ST_GET_SERVER_VERIFY_A		(0x60|SSL_ST_CONNECT)
#define SSL2_ST_GET_SERVER_VERIFY_B		(0x61|SSL_ST_CONNECT)
#define SSL2_ST_GET_SERVER_FINISHED_A		(0x70|SSL_ST_CONNECT)
#define SSL2_ST_GET_SERVER_FINISHED_B		(0x71|SSL_ST_CONNECT)
#define SSL2_ST_CLIENT_START_ENCRYPTION		(0x80|SSL_ST_CONNECT)
#define SSL2_ST_X509_GET_CLIENT_CERTIFICATE	(0x90|SSL_ST_CONNECT)
/* server */
#define SSL2_ST_GET_CLIENT_HELLO_A		(0x10|SSL_ST_ACCEPT)
#define SSL2_ST_GET_CLIENT_HELLO_B		(0x11|SSL_ST_ACCEPT)
#define SSL2_ST_GET_CLIENT_HELLO_C		(0x12|SSL_ST_ACCEPT)
#define SSL2_ST_SEND_SERVER_HELLO_A		(0x20|SSL_ST_ACCEPT)
#define SSL2_ST_SEND_SERVER_HELLO_B		(0x21|SSL_ST_ACCEPT)
#define SSL2_ST_GET_CLIENT_MASTER_KEY_A		(0x30|SSL_ST_ACCEPT)
#define SSL2_ST_GET_CLIENT_MASTER_KEY_B		(0x31|SSL_ST_ACCEPT)
#define SSL2_ST_SEND_SERVER_VERIFY_A		(0x40|SSL_ST_ACCEPT)
#define SSL2_ST_SEND_SERVER_VERIFY_B		(0x41|SSL_ST_ACCEPT)
#define SSL2_ST_SEND_SERVER_VERIFY_C		(0x42|SSL_ST_ACCEPT)
#define SSL2_ST_GET_CLIENT_FINISHED_A		(0x50|SSL_ST_ACCEPT)
#define SSL2_ST_GET_CLIENT_FINISHED_B		(0x51|SSL_ST_ACCEPT)
#define SSL2_ST_SEND_SERVER_FINISHED_A		(0x60|SSL_ST_ACCEPT)
#define SSL2_ST_SEND_SERVER_FINISHED_B		(0x61|SSL_ST_ACCEPT)
#define SSL2_ST_SEND_REQUEST_CERTIFICATE_A	(0x70|SSL_ST_ACCEPT)
#define SSL2_ST_SEND_REQUEST_CERTIFICATE_B	(0x71|SSL_ST_ACCEPT)
#define SSL2_ST_SEND_REQUEST_CERTIFICATE_C	(0x72|SSL_ST_ACCEPT)
#define SSL2_ST_SEND_REQUEST_CERTIFICATE_D	(0x73|SSL_ST_ACCEPT)
#define SSL2_ST_SERVER_START_ENCRYPTION		(0x80|SSL_ST_ACCEPT)
#define SSL2_ST_X509_GET_SERVER_CERTIFICATE	(0x90|SSL_ST_ACCEPT)

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/objects.h0000644000175000017500000010740612360020705021653 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_OBJECTS_H
#define HEADER_OBJECTS_H

#define USE_OBJ_MAC

#ifdef USE_OBJ_MAC
#include 
#else
#define SN_undef			"UNDEF"
#define LN_undef			"undefined"
#define NID_undef			0
#define OBJ_undef			0L

#define SN_Algorithm			"Algorithm"
#define LN_algorithm			"algorithm"
#define NID_algorithm			38
#define OBJ_algorithm			1L,3L,14L,3L,2L

#define LN_rsadsi			"rsadsi"
#define NID_rsadsi			1
#define OBJ_rsadsi			1L,2L,840L,113549L

#define LN_pkcs				"pkcs"
#define NID_pkcs			2
#define OBJ_pkcs			OBJ_rsadsi,1L

#define SN_md2				"MD2"
#define LN_md2				"md2"
#define NID_md2				3
#define OBJ_md2				OBJ_rsadsi,2L,2L

#define SN_md5				"MD5"
#define LN_md5				"md5"
#define NID_md5				4
#define OBJ_md5				OBJ_rsadsi,2L,5L

#define SN_rc4				"RC4"
#define LN_rc4				"rc4"
#define NID_rc4				5
#define OBJ_rc4				OBJ_rsadsi,3L,4L

#define LN_rsaEncryption		"rsaEncryption"
#define NID_rsaEncryption		6
#define OBJ_rsaEncryption		OBJ_pkcs,1L,1L

#define SN_md2WithRSAEncryption		"RSA-MD2"
#define LN_md2WithRSAEncryption		"md2WithRSAEncryption"
#define NID_md2WithRSAEncryption	7
#define OBJ_md2WithRSAEncryption	OBJ_pkcs,1L,2L

#define SN_md5WithRSAEncryption		"RSA-MD5"
#define LN_md5WithRSAEncryption		"md5WithRSAEncryption"
#define NID_md5WithRSAEncryption	8
#define OBJ_md5WithRSAEncryption	OBJ_pkcs,1L,4L

#define SN_pbeWithMD2AndDES_CBC		"PBE-MD2-DES"
#define LN_pbeWithMD2AndDES_CBC		"pbeWithMD2AndDES-CBC"
#define NID_pbeWithMD2AndDES_CBC	9
#define OBJ_pbeWithMD2AndDES_CBC	OBJ_pkcs,5L,1L

#define SN_pbeWithMD5AndDES_CBC		"PBE-MD5-DES"
#define LN_pbeWithMD5AndDES_CBC		"pbeWithMD5AndDES-CBC"
#define NID_pbeWithMD5AndDES_CBC	10
#define OBJ_pbeWithMD5AndDES_CBC	OBJ_pkcs,5L,3L

#define LN_X500				"X500"
#define NID_X500			11
#define OBJ_X500			2L,5L

#define LN_X509				"X509"
#define NID_X509			12
#define OBJ_X509			OBJ_X500,4L

#define SN_commonName			"CN"
#define LN_commonName			"commonName"
#define NID_commonName			13
#define OBJ_commonName			OBJ_X509,3L

#define SN_countryName			"C"
#define LN_countryName			"countryName"
#define NID_countryName			14
#define OBJ_countryName			OBJ_X509,6L

#define SN_localityName			"L"
#define LN_localityName			"localityName"
#define NID_localityName		15
#define OBJ_localityName		OBJ_X509,7L

/* Postal Address? PA */

/* should be "ST" (rfc1327) but MS uses 'S' */
#define SN_stateOrProvinceName		"ST"
#define LN_stateOrProvinceName		"stateOrProvinceName"
#define NID_stateOrProvinceName		16
#define OBJ_stateOrProvinceName		OBJ_X509,8L

#define SN_organizationName		"O"
#define LN_organizationName		"organizationName"
#define NID_organizationName		17
#define OBJ_organizationName		OBJ_X509,10L

#define SN_organizationalUnitName	"OU"
#define LN_organizationalUnitName	"organizationalUnitName"
#define NID_organizationalUnitName	18
#define OBJ_organizationalUnitName	OBJ_X509,11L

#define SN_rsa				"RSA"
#define LN_rsa				"rsa"
#define NID_rsa				19
#define OBJ_rsa				OBJ_X500,8L,1L,1L

#define LN_pkcs7			"pkcs7"
#define NID_pkcs7			20
#define OBJ_pkcs7			OBJ_pkcs,7L

#define LN_pkcs7_data			"pkcs7-data"
#define NID_pkcs7_data			21
#define OBJ_pkcs7_data			OBJ_pkcs7,1L

#define LN_pkcs7_signed			"pkcs7-signedData"
#define NID_pkcs7_signed		22
#define OBJ_pkcs7_signed		OBJ_pkcs7,2L

#define LN_pkcs7_enveloped		"pkcs7-envelopedData"
#define NID_pkcs7_enveloped		23
#define OBJ_pkcs7_enveloped		OBJ_pkcs7,3L

#define LN_pkcs7_signedAndEnveloped	"pkcs7-signedAndEnvelopedData"
#define NID_pkcs7_signedAndEnveloped	24
#define OBJ_pkcs7_signedAndEnveloped	OBJ_pkcs7,4L

#define LN_pkcs7_digest			"pkcs7-digestData"
#define NID_pkcs7_digest		25
#define OBJ_pkcs7_digest		OBJ_pkcs7,5L

#define LN_pkcs7_encrypted		"pkcs7-encryptedData"
#define NID_pkcs7_encrypted		26
#define OBJ_pkcs7_encrypted		OBJ_pkcs7,6L

#define LN_pkcs3			"pkcs3"
#define NID_pkcs3			27
#define OBJ_pkcs3			OBJ_pkcs,3L

#define LN_dhKeyAgreement		"dhKeyAgreement"
#define NID_dhKeyAgreement		28
#define OBJ_dhKeyAgreement		OBJ_pkcs3,1L

#define SN_des_ecb			"DES-ECB"
#define LN_des_ecb			"des-ecb"
#define NID_des_ecb			29
#define OBJ_des_ecb			OBJ_algorithm,6L

#define SN_des_cfb64			"DES-CFB"
#define LN_des_cfb64			"des-cfb"
#define NID_des_cfb64			30
/* IV + num */
#define OBJ_des_cfb64			OBJ_algorithm,9L

#define SN_des_cbc			"DES-CBC"
#define LN_des_cbc			"des-cbc"
#define NID_des_cbc			31
/* IV */
#define OBJ_des_cbc			OBJ_algorithm,7L

#define SN_des_ede			"DES-EDE"
#define LN_des_ede			"des-ede"
#define NID_des_ede			32
/* ?? */
#define OBJ_des_ede			OBJ_algorithm,17L

#define SN_des_ede3			"DES-EDE3"
#define LN_des_ede3			"des-ede3"
#define NID_des_ede3			33

#define SN_idea_cbc			"IDEA-CBC"
#define LN_idea_cbc			"idea-cbc"
#define NID_idea_cbc			34
#define OBJ_idea_cbc			1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L

#define SN_idea_cfb64			"IDEA-CFB"
#define LN_idea_cfb64			"idea-cfb"
#define NID_idea_cfb64			35

#define SN_idea_ecb			"IDEA-ECB"
#define LN_idea_ecb			"idea-ecb"
#define NID_idea_ecb			36

#define SN_rc2_cbc			"RC2-CBC"
#define LN_rc2_cbc			"rc2-cbc"
#define NID_rc2_cbc			37
#define OBJ_rc2_cbc			OBJ_rsadsi,3L,2L

#define SN_rc2_ecb			"RC2-ECB"
#define LN_rc2_ecb			"rc2-ecb"
#define NID_rc2_ecb			38

#define SN_rc2_cfb64			"RC2-CFB"
#define LN_rc2_cfb64			"rc2-cfb"
#define NID_rc2_cfb64			39

#define SN_rc2_ofb64			"RC2-OFB"
#define LN_rc2_ofb64			"rc2-ofb"
#define NID_rc2_ofb64			40

#define SN_sha				"SHA"
#define LN_sha				"sha"
#define NID_sha				41
#define OBJ_sha				OBJ_algorithm,18L

#define SN_shaWithRSAEncryption		"RSA-SHA"
#define LN_shaWithRSAEncryption		"shaWithRSAEncryption"
#define NID_shaWithRSAEncryption	42
#define OBJ_shaWithRSAEncryption	OBJ_algorithm,15L

#define SN_des_ede_cbc			"DES-EDE-CBC"
#define LN_des_ede_cbc			"des-ede-cbc"
#define NID_des_ede_cbc			43

#define SN_des_ede3_cbc			"DES-EDE3-CBC"
#define LN_des_ede3_cbc			"des-ede3-cbc"
#define NID_des_ede3_cbc		44
#define OBJ_des_ede3_cbc		OBJ_rsadsi,3L,7L

#define SN_des_ofb64			"DES-OFB"
#define LN_des_ofb64			"des-ofb"
#define NID_des_ofb64			45
#define OBJ_des_ofb64			OBJ_algorithm,8L

#define SN_idea_ofb64			"IDEA-OFB"
#define LN_idea_ofb64			"idea-ofb"
#define NID_idea_ofb64			46

#define LN_pkcs9			"pkcs9"
#define NID_pkcs9			47
#define OBJ_pkcs9			OBJ_pkcs,9L

#define SN_pkcs9_emailAddress		"Email"
#define LN_pkcs9_emailAddress		"emailAddress"
#define NID_pkcs9_emailAddress		48
#define OBJ_pkcs9_emailAddress		OBJ_pkcs9,1L

#define LN_pkcs9_unstructuredName	"unstructuredName"
#define NID_pkcs9_unstructuredName	49
#define OBJ_pkcs9_unstructuredName	OBJ_pkcs9,2L

#define LN_pkcs9_contentType		"contentType"
#define NID_pkcs9_contentType		50
#define OBJ_pkcs9_contentType		OBJ_pkcs9,3L

#define LN_pkcs9_messageDigest		"messageDigest"
#define NID_pkcs9_messageDigest		51
#define OBJ_pkcs9_messageDigest		OBJ_pkcs9,4L

#define LN_pkcs9_signingTime		"signingTime"
#define NID_pkcs9_signingTime		52
#define OBJ_pkcs9_signingTime		OBJ_pkcs9,5L

#define LN_pkcs9_countersignature	"countersignature"
#define NID_pkcs9_countersignature	53
#define OBJ_pkcs9_countersignature	OBJ_pkcs9,6L

#define LN_pkcs9_challengePassword	"challengePassword"
#define NID_pkcs9_challengePassword	54
#define OBJ_pkcs9_challengePassword	OBJ_pkcs9,7L

#define LN_pkcs9_unstructuredAddress	"unstructuredAddress"
#define NID_pkcs9_unstructuredAddress	55
#define OBJ_pkcs9_unstructuredAddress	OBJ_pkcs9,8L

#define LN_pkcs9_extCertAttributes	"extendedCertificateAttributes"
#define NID_pkcs9_extCertAttributes	56
#define OBJ_pkcs9_extCertAttributes	OBJ_pkcs9,9L

#define SN_netscape			"Netscape"
#define LN_netscape			"Netscape Communications Corp."
#define NID_netscape			57
#define OBJ_netscape			2L,16L,840L,1L,113730L

#define SN_netscape_cert_extension	"nsCertExt"
#define LN_netscape_cert_extension	"Netscape Certificate Extension"
#define NID_netscape_cert_extension	58
#define OBJ_netscape_cert_extension	OBJ_netscape,1L

#define SN_netscape_data_type		"nsDataType"
#define LN_netscape_data_type		"Netscape Data Type"
#define NID_netscape_data_type		59
#define OBJ_netscape_data_type		OBJ_netscape,2L

#define SN_des_ede_cfb64		"DES-EDE-CFB"
#define LN_des_ede_cfb64		"des-ede-cfb"
#define NID_des_ede_cfb64		60

#define SN_des_ede3_cfb64		"DES-EDE3-CFB"
#define LN_des_ede3_cfb64		"des-ede3-cfb"
#define NID_des_ede3_cfb64		61

#define SN_des_ede_ofb64		"DES-EDE-OFB"
#define LN_des_ede_ofb64		"des-ede-ofb"
#define NID_des_ede_ofb64		62

#define SN_des_ede3_ofb64		"DES-EDE3-OFB"
#define LN_des_ede3_ofb64		"des-ede3-ofb"
#define NID_des_ede3_ofb64		63

/* I'm not sure about the object ID */
#define SN_sha1				"SHA1"
#define LN_sha1				"sha1"
#define NID_sha1			64
#define OBJ_sha1			OBJ_algorithm,26L
/* 28 Jun 1996 - eay */
/* #define OBJ_sha1			1L,3L,14L,2L,26L,05L <- wrong */

#define SN_sha1WithRSAEncryption	"RSA-SHA1"
#define LN_sha1WithRSAEncryption	"sha1WithRSAEncryption"
#define NID_sha1WithRSAEncryption	65
#define OBJ_sha1WithRSAEncryption	OBJ_pkcs,1L,5L

#define SN_dsaWithSHA			"DSA-SHA"
#define LN_dsaWithSHA			"dsaWithSHA"
#define NID_dsaWithSHA			66
#define OBJ_dsaWithSHA			OBJ_algorithm,13L

#define SN_dsa_2			"DSA-old"
#define LN_dsa_2			"dsaEncryption-old"
#define NID_dsa_2			67
#define OBJ_dsa_2			OBJ_algorithm,12L

/* proposed by microsoft to RSA */
#define SN_pbeWithSHA1AndRC2_CBC	"PBE-SHA1-RC2-64"
#define LN_pbeWithSHA1AndRC2_CBC	"pbeWithSHA1AndRC2-CBC"
#define NID_pbeWithSHA1AndRC2_CBC	68
#define OBJ_pbeWithSHA1AndRC2_CBC	OBJ_pkcs,5L,11L

/* proposed by microsoft to RSA as pbeWithSHA1AndRC4: it is now
 * defined explicitly in PKCS#5 v2.0 as id-PBKDF2 which is something
 * completely different.
 */
#define LN_id_pbkdf2			"PBKDF2"
#define NID_id_pbkdf2			69
#define OBJ_id_pbkdf2			OBJ_pkcs,5L,12L

#define SN_dsaWithSHA1_2		"DSA-SHA1-old"
#define LN_dsaWithSHA1_2		"dsaWithSHA1-old"
#define NID_dsaWithSHA1_2		70
/* Got this one from 'sdn706r20.pdf' which is actually an NSA document :-) */
#define OBJ_dsaWithSHA1_2		OBJ_algorithm,27L

#define SN_netscape_cert_type		"nsCertType"
#define LN_netscape_cert_type		"Netscape Cert Type"
#define NID_netscape_cert_type		71
#define OBJ_netscape_cert_type		OBJ_netscape_cert_extension,1L

#define SN_netscape_base_url		"nsBaseUrl"
#define LN_netscape_base_url		"Netscape Base Url"
#define NID_netscape_base_url		72
#define OBJ_netscape_base_url		OBJ_netscape_cert_extension,2L

#define SN_netscape_revocation_url	"nsRevocationUrl"
#define LN_netscape_revocation_url	"Netscape Revocation Url"
#define NID_netscape_revocation_url	73
#define OBJ_netscape_revocation_url	OBJ_netscape_cert_extension,3L

#define SN_netscape_ca_revocation_url	"nsCaRevocationUrl"
#define LN_netscape_ca_revocation_url	"Netscape CA Revocation Url"
#define NID_netscape_ca_revocation_url	74
#define OBJ_netscape_ca_revocation_url	OBJ_netscape_cert_extension,4L

#define SN_netscape_renewal_url		"nsRenewalUrl"
#define LN_netscape_renewal_url		"Netscape Renewal Url"
#define NID_netscape_renewal_url	75
#define OBJ_netscape_renewal_url	OBJ_netscape_cert_extension,7L

#define SN_netscape_ca_policy_url	"nsCaPolicyUrl"
#define LN_netscape_ca_policy_url	"Netscape CA Policy Url"
#define NID_netscape_ca_policy_url	76
#define OBJ_netscape_ca_policy_url	OBJ_netscape_cert_extension,8L

#define SN_netscape_ssl_server_name	"nsSslServerName"
#define LN_netscape_ssl_server_name	"Netscape SSL Server Name"
#define NID_netscape_ssl_server_name	77
#define OBJ_netscape_ssl_server_name	OBJ_netscape_cert_extension,12L

#define SN_netscape_comment		"nsComment"
#define LN_netscape_comment		"Netscape Comment"
#define NID_netscape_comment		78
#define OBJ_netscape_comment		OBJ_netscape_cert_extension,13L

#define SN_netscape_cert_sequence	"nsCertSequence"
#define LN_netscape_cert_sequence	"Netscape Certificate Sequence"
#define NID_netscape_cert_sequence	79
#define OBJ_netscape_cert_sequence	OBJ_netscape_data_type,5L

#define SN_desx_cbc			"DESX-CBC"
#define LN_desx_cbc			"desx-cbc"
#define NID_desx_cbc			80

#define SN_id_ce			"id-ce"
#define NID_id_ce			81
#define OBJ_id_ce			2L,5L,29L

#define SN_subject_key_identifier	"subjectKeyIdentifier"
#define LN_subject_key_identifier	"X509v3 Subject Key Identifier"
#define NID_subject_key_identifier	82
#define OBJ_subject_key_identifier	OBJ_id_ce,14L

#define SN_key_usage			"keyUsage"
#define LN_key_usage			"X509v3 Key Usage"
#define NID_key_usage			83
#define OBJ_key_usage			OBJ_id_ce,15L

#define SN_private_key_usage_period	"privateKeyUsagePeriod"
#define LN_private_key_usage_period	"X509v3 Private Key Usage Period"
#define NID_private_key_usage_period	84
#define OBJ_private_key_usage_period	OBJ_id_ce,16L

#define SN_subject_alt_name		"subjectAltName"
#define LN_subject_alt_name		"X509v3 Subject Alternative Name"
#define NID_subject_alt_name		85
#define OBJ_subject_alt_name		OBJ_id_ce,17L

#define SN_issuer_alt_name		"issuerAltName"
#define LN_issuer_alt_name		"X509v3 Issuer Alternative Name"
#define NID_issuer_alt_name		86
#define OBJ_issuer_alt_name		OBJ_id_ce,18L

#define SN_basic_constraints		"basicConstraints"
#define LN_basic_constraints		"X509v3 Basic Constraints"
#define NID_basic_constraints		87
#define OBJ_basic_constraints		OBJ_id_ce,19L

#define SN_crl_number			"crlNumber"
#define LN_crl_number			"X509v3 CRL Number"
#define NID_crl_number			88
#define OBJ_crl_number			OBJ_id_ce,20L

#define SN_certificate_policies		"certificatePolicies"
#define LN_certificate_policies		"X509v3 Certificate Policies"
#define NID_certificate_policies	89
#define OBJ_certificate_policies	OBJ_id_ce,32L

#define SN_authority_key_identifier	"authorityKeyIdentifier"
#define LN_authority_key_identifier	"X509v3 Authority Key Identifier"
#define NID_authority_key_identifier	90
#define OBJ_authority_key_identifier	OBJ_id_ce,35L

#define SN_bf_cbc			"BF-CBC"
#define LN_bf_cbc			"bf-cbc"
#define NID_bf_cbc			91
#define OBJ_bf_cbc			1L,3L,6L,1L,4L,1L,3029L,1L,2L

#define SN_bf_ecb			"BF-ECB"
#define LN_bf_ecb			"bf-ecb"
#define NID_bf_ecb			92

#define SN_bf_cfb64			"BF-CFB"
#define LN_bf_cfb64			"bf-cfb"
#define NID_bf_cfb64			93

#define SN_bf_ofb64			"BF-OFB"
#define LN_bf_ofb64			"bf-ofb"
#define NID_bf_ofb64			94

#define SN_mdc2				"MDC2"
#define LN_mdc2				"mdc2"
#define NID_mdc2			95
#define OBJ_mdc2			2L,5L,8L,3L,101L
/* An alternative?			1L,3L,14L,3L,2L,19L */

#define SN_mdc2WithRSA			"RSA-MDC2"
#define LN_mdc2WithRSA			"mdc2withRSA"
#define NID_mdc2WithRSA			96
#define OBJ_mdc2WithRSA			2L,5L,8L,3L,100L

#define SN_rc4_40			"RC4-40"
#define LN_rc4_40			"rc4-40"
#define NID_rc4_40			97

#define SN_rc2_40_cbc			"RC2-40-CBC"
#define LN_rc2_40_cbc			"rc2-40-cbc"
#define NID_rc2_40_cbc			98

#define SN_givenName			"G"
#define LN_givenName			"givenName"
#define NID_givenName			99
#define OBJ_givenName			OBJ_X509,42L

#define SN_surname			"S"
#define LN_surname			"surname"
#define NID_surname			100
#define OBJ_surname			OBJ_X509,4L

#define SN_initials			"I"
#define LN_initials			"initials"
#define NID_initials			101
#define OBJ_initials			OBJ_X509,43L

#define SN_uniqueIdentifier		"UID"
#define LN_uniqueIdentifier		"uniqueIdentifier"
#define NID_uniqueIdentifier		102
#define OBJ_uniqueIdentifier		OBJ_X509,45L

#define SN_crl_distribution_points	"crlDistributionPoints"
#define LN_crl_distribution_points	"X509v3 CRL Distribution Points"
#define NID_crl_distribution_points	103
#define OBJ_crl_distribution_points	OBJ_id_ce,31L

#define SN_md5WithRSA			"RSA-NP-MD5"
#define LN_md5WithRSA			"md5WithRSA"
#define NID_md5WithRSA			104
#define OBJ_md5WithRSA			OBJ_algorithm,3L

#define SN_serialNumber			"SN"
#define LN_serialNumber			"serialNumber"
#define NID_serialNumber		105
#define OBJ_serialNumber		OBJ_X509,5L

#define SN_title			"T"
#define LN_title			"title"
#define NID_title			106
#define OBJ_title			OBJ_X509,12L

#define SN_description			"D"
#define LN_description			"description"
#define NID_description			107
#define OBJ_description			OBJ_X509,13L

/* CAST5 is CAST-128, I'm just sticking with the documentation */
#define SN_cast5_cbc			"CAST5-CBC"
#define LN_cast5_cbc			"cast5-cbc"
#define NID_cast5_cbc			108
#define OBJ_cast5_cbc			1L,2L,840L,113533L,7L,66L,10L

#define SN_cast5_ecb			"CAST5-ECB"
#define LN_cast5_ecb			"cast5-ecb"
#define NID_cast5_ecb			109

#define SN_cast5_cfb64			"CAST5-CFB"
#define LN_cast5_cfb64			"cast5-cfb"
#define NID_cast5_cfb64			110

#define SN_cast5_ofb64			"CAST5-OFB"
#define LN_cast5_ofb64			"cast5-ofb"
#define NID_cast5_ofb64			111

#define LN_pbeWithMD5AndCast5_CBC	"pbeWithMD5AndCast5CBC"
#define NID_pbeWithMD5AndCast5_CBC	112
#define OBJ_pbeWithMD5AndCast5_CBC	1L,2L,840L,113533L,7L,66L,12L

/* This is one sun will soon be using :-(
 * id-dsa-with-sha1 ID  ::= {
 *   iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3 }
 */
#define SN_dsaWithSHA1			"DSA-SHA1"
#define LN_dsaWithSHA1			"dsaWithSHA1"
#define NID_dsaWithSHA1			113
#define OBJ_dsaWithSHA1			1L,2L,840L,10040L,4L,3L

#define NID_md5_sha1			114
#define SN_md5_sha1			"MD5-SHA1"
#define LN_md5_sha1			"md5-sha1"

#define SN_sha1WithRSA			"RSA-SHA1-2"
#define LN_sha1WithRSA			"sha1WithRSA"
#define NID_sha1WithRSA			115
#define OBJ_sha1WithRSA			OBJ_algorithm,29L

#define SN_dsa				"DSA"
#define LN_dsa				"dsaEncryption"
#define NID_dsa				116
#define OBJ_dsa				1L,2L,840L,10040L,4L,1L

#define SN_ripemd160			"RIPEMD160"
#define LN_ripemd160			"ripemd160"
#define NID_ripemd160			117
#define OBJ_ripemd160			1L,3L,36L,3L,2L,1L

/* The name should actually be rsaSignatureWithripemd160, but I'm going
 * to continue using the convention I'm using with the other ciphers */
#define SN_ripemd160WithRSA		"RSA-RIPEMD160"
#define LN_ripemd160WithRSA		"ripemd160WithRSA"
#define NID_ripemd160WithRSA		119
#define OBJ_ripemd160WithRSA		1L,3L,36L,3L,3L,1L,2L

/* Taken from rfc2040
 *  RC5_CBC_Parameters ::= SEQUENCE {
 *	version           INTEGER (v1_0(16)),
 *	rounds            INTEGER (8..127),
 *	blockSizeInBits   INTEGER (64, 128),
 *	iv                OCTET STRING OPTIONAL
 *	}
 */
#define SN_rc5_cbc			"RC5-CBC"
#define LN_rc5_cbc			"rc5-cbc"
#define NID_rc5_cbc			120
#define OBJ_rc5_cbc			OBJ_rsadsi,3L,8L

#define SN_rc5_ecb			"RC5-ECB"
#define LN_rc5_ecb			"rc5-ecb"
#define NID_rc5_ecb			121

#define SN_rc5_cfb64			"RC5-CFB"
#define LN_rc5_cfb64			"rc5-cfb"
#define NID_rc5_cfb64			122

#define SN_rc5_ofb64			"RC5-OFB"
#define LN_rc5_ofb64			"rc5-ofb"
#define NID_rc5_ofb64			123

#define SN_rle_compression		"RLE"
#define LN_rle_compression		"run length compression"
#define NID_rle_compression		124
#define OBJ_rle_compression		1L,1L,1L,1L,666L,1L

#define SN_zlib_compression		"ZLIB"
#define LN_zlib_compression		"zlib compression"
#define NID_zlib_compression		125
#define OBJ_zlib_compression		1L,1L,1L,1L,666L,2L

#define SN_ext_key_usage		"extendedKeyUsage"
#define LN_ext_key_usage		"X509v3 Extended Key Usage"
#define NID_ext_key_usage		126
#define OBJ_ext_key_usage		OBJ_id_ce,37

#define SN_id_pkix			"PKIX"
#define NID_id_pkix			127
#define OBJ_id_pkix			1L,3L,6L,1L,5L,5L,7L

#define SN_id_kp			"id-kp"
#define NID_id_kp			128
#define OBJ_id_kp			OBJ_id_pkix,3L

/* PKIX extended key usage OIDs */

#define SN_server_auth			"serverAuth"
#define LN_server_auth			"TLS Web Server Authentication"
#define NID_server_auth			129
#define OBJ_server_auth			OBJ_id_kp,1L

#define SN_client_auth			"clientAuth"
#define LN_client_auth			"TLS Web Client Authentication"
#define NID_client_auth			130
#define OBJ_client_auth			OBJ_id_kp,2L

#define SN_code_sign			"codeSigning"
#define LN_code_sign			"Code Signing"
#define NID_code_sign			131
#define OBJ_code_sign			OBJ_id_kp,3L

#define SN_email_protect		"emailProtection"
#define LN_email_protect		"E-mail Protection"
#define NID_email_protect		132
#define OBJ_email_protect		OBJ_id_kp,4L

#define SN_time_stamp			"timeStamping"
#define LN_time_stamp			"Time Stamping"
#define NID_time_stamp			133
#define OBJ_time_stamp			OBJ_id_kp,8L

/* Additional extended key usage OIDs: Microsoft */

#define SN_ms_code_ind			"msCodeInd"
#define LN_ms_code_ind			"Microsoft Individual Code Signing"
#define NID_ms_code_ind			134
#define OBJ_ms_code_ind			1L,3L,6L,1L,4L,1L,311L,2L,1L,21L

#define SN_ms_code_com			"msCodeCom"
#define LN_ms_code_com			"Microsoft Commercial Code Signing"
#define NID_ms_code_com			135
#define OBJ_ms_code_com			1L,3L,6L,1L,4L,1L,311L,2L,1L,22L

#define SN_ms_ctl_sign			"msCTLSign"
#define LN_ms_ctl_sign			"Microsoft Trust List Signing"
#define NID_ms_ctl_sign			136
#define OBJ_ms_ctl_sign			1L,3L,6L,1L,4L,1L,311L,10L,3L,1L

#define SN_ms_sgc			"msSGC"
#define LN_ms_sgc			"Microsoft Server Gated Crypto"
#define NID_ms_sgc			137
#define OBJ_ms_sgc			1L,3L,6L,1L,4L,1L,311L,10L,3L,3L

#define SN_ms_efs			"msEFS"
#define LN_ms_efs			"Microsoft Encrypted File System"
#define NID_ms_efs			138
#define OBJ_ms_efs			1L,3L,6L,1L,4L,1L,311L,10L,3L,4L

/* Additional usage: Netscape */

#define SN_ns_sgc			"nsSGC"
#define LN_ns_sgc			"Netscape Server Gated Crypto"
#define NID_ns_sgc			139
#define OBJ_ns_sgc			OBJ_netscape,4L,1L

#define SN_delta_crl			"deltaCRL"
#define LN_delta_crl			"X509v3 Delta CRL Indicator"
#define NID_delta_crl			140
#define OBJ_delta_crl			OBJ_id_ce,27L

#define SN_crl_reason			"CRLReason"
#define LN_crl_reason			"CRL Reason Code"
#define NID_crl_reason			141
#define OBJ_crl_reason			OBJ_id_ce,21L

#define SN_invalidity_date		"invalidityDate"
#define LN_invalidity_date		"Invalidity Date"
#define NID_invalidity_date		142
#define OBJ_invalidity_date		OBJ_id_ce,24L

#define SN_sxnet			"SXNetID"
#define LN_sxnet			"Strong Extranet ID"
#define NID_sxnet			143
#define OBJ_sxnet			1L,3L,101L,1L,4L,1L

/* PKCS12 and related OBJECT IDENTIFIERS */

#define OBJ_pkcs12			OBJ_pkcs,12L
#define OBJ_pkcs12_pbeids		OBJ_pkcs12, 1

#define SN_pbe_WithSHA1And128BitRC4	"PBE-SHA1-RC4-128"
#define LN_pbe_WithSHA1And128BitRC4	"pbeWithSHA1And128BitRC4"
#define NID_pbe_WithSHA1And128BitRC4	144
#define OBJ_pbe_WithSHA1And128BitRC4	OBJ_pkcs12_pbeids, 1L

#define SN_pbe_WithSHA1And40BitRC4	"PBE-SHA1-RC4-40"
#define LN_pbe_WithSHA1And40BitRC4	"pbeWithSHA1And40BitRC4"
#define NID_pbe_WithSHA1And40BitRC4	145
#define OBJ_pbe_WithSHA1And40BitRC4	OBJ_pkcs12_pbeids, 2L

#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC	"PBE-SHA1-3DES"
#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC	"pbeWithSHA1And3-KeyTripleDES-CBC"
#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC	146
#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC	OBJ_pkcs12_pbeids, 3L

#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC	"PBE-SHA1-2DES"
#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC	"pbeWithSHA1And2-KeyTripleDES-CBC"
#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC	147
#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC	OBJ_pkcs12_pbeids, 4L

#define SN_pbe_WithSHA1And128BitRC2_CBC		"PBE-SHA1-RC2-128"
#define LN_pbe_WithSHA1And128BitRC2_CBC		"pbeWithSHA1And128BitRC2-CBC"
#define NID_pbe_WithSHA1And128BitRC2_CBC	148
#define OBJ_pbe_WithSHA1And128BitRC2_CBC	OBJ_pkcs12_pbeids, 5L

#define SN_pbe_WithSHA1And40BitRC2_CBC	"PBE-SHA1-RC2-40"
#define LN_pbe_WithSHA1And40BitRC2_CBC	"pbeWithSHA1And40BitRC2-CBC"
#define NID_pbe_WithSHA1And40BitRC2_CBC	149
#define OBJ_pbe_WithSHA1And40BitRC2_CBC	OBJ_pkcs12_pbeids, 6L

#define OBJ_pkcs12_Version1	OBJ_pkcs12, 10L

#define OBJ_pkcs12_BagIds	OBJ_pkcs12_Version1, 1L

#define LN_keyBag		"keyBag"
#define NID_keyBag		150
#define OBJ_keyBag		OBJ_pkcs12_BagIds, 1L

#define LN_pkcs8ShroudedKeyBag	"pkcs8ShroudedKeyBag"
#define NID_pkcs8ShroudedKeyBag	151
#define OBJ_pkcs8ShroudedKeyBag	OBJ_pkcs12_BagIds, 2L

#define LN_certBag		"certBag"
#define NID_certBag		152
#define OBJ_certBag		OBJ_pkcs12_BagIds, 3L

#define LN_crlBag		"crlBag"
#define NID_crlBag		153
#define OBJ_crlBag		OBJ_pkcs12_BagIds, 4L

#define LN_secretBag		"secretBag"
#define NID_secretBag		154
#define OBJ_secretBag		OBJ_pkcs12_BagIds, 5L

#define LN_safeContentsBag	"safeContentsBag"
#define NID_safeContentsBag	155
#define OBJ_safeContentsBag	OBJ_pkcs12_BagIds, 6L

#define LN_friendlyName		"friendlyName"
#define	NID_friendlyName	156
#define OBJ_friendlyName	OBJ_pkcs9, 20L

#define LN_localKeyID		"localKeyID"
#define	NID_localKeyID		157
#define OBJ_localKeyID		OBJ_pkcs9, 21L

#define OBJ_certTypes		OBJ_pkcs9, 22L

#define LN_x509Certificate	"x509Certificate"
#define	NID_x509Certificate	158
#define OBJ_x509Certificate	OBJ_certTypes, 1L

#define LN_sdsiCertificate	"sdsiCertificate"
#define	NID_sdsiCertificate	159
#define OBJ_sdsiCertificate	OBJ_certTypes, 2L

#define OBJ_crlTypes		OBJ_pkcs9, 23L

#define LN_x509Crl		"x509Crl"
#define	NID_x509Crl		160
#define OBJ_x509Crl		OBJ_crlTypes, 1L

/* PKCS#5 v2 OIDs */

#define LN_pbes2		"PBES2"
#define NID_pbes2		161
#define OBJ_pbes2		OBJ_pkcs,5L,13L

#define LN_pbmac1		"PBMAC1"
#define NID_pbmac1		162
#define OBJ_pbmac1		OBJ_pkcs,5L,14L

#define LN_hmacWithSHA1		"hmacWithSHA1"
#define NID_hmacWithSHA1	163
#define OBJ_hmacWithSHA1	OBJ_rsadsi,2L,7L

/* Policy Qualifier Ids */

#define LN_id_qt_cps		"Policy Qualifier CPS"
#define SN_id_qt_cps		"id-qt-cps"
#define NID_id_qt_cps		164
#define OBJ_id_qt_cps		OBJ_id_pkix,2L,1L

#define LN_id_qt_unotice	"Policy Qualifier User Notice"
#define SN_id_qt_unotice	"id-qt-unotice"
#define NID_id_qt_unotice	165
#define OBJ_id_qt_unotice	OBJ_id_pkix,2L,2L

#define SN_rc2_64_cbc			"RC2-64-CBC"
#define LN_rc2_64_cbc			"rc2-64-cbc"
#define NID_rc2_64_cbc			166

#define SN_SMIMECapabilities		"SMIME-CAPS"
#define LN_SMIMECapabilities		"S/MIME Capabilities"
#define NID_SMIMECapabilities		167
#define OBJ_SMIMECapabilities		OBJ_pkcs9,15L

#define SN_pbeWithMD2AndRC2_CBC		"PBE-MD2-RC2-64"
#define LN_pbeWithMD2AndRC2_CBC		"pbeWithMD2AndRC2-CBC"
#define NID_pbeWithMD2AndRC2_CBC	168
#define OBJ_pbeWithMD2AndRC2_CBC	OBJ_pkcs,5L,4L

#define SN_pbeWithMD5AndRC2_CBC		"PBE-MD5-RC2-64"
#define LN_pbeWithMD5AndRC2_CBC		"pbeWithMD5AndRC2-CBC"
#define NID_pbeWithMD5AndRC2_CBC	169
#define OBJ_pbeWithMD5AndRC2_CBC	OBJ_pkcs,5L,6L

#define SN_pbeWithSHA1AndDES_CBC	"PBE-SHA1-DES"
#define LN_pbeWithSHA1AndDES_CBC	"pbeWithSHA1AndDES-CBC"
#define NID_pbeWithSHA1AndDES_CBC	170
#define OBJ_pbeWithSHA1AndDES_CBC	OBJ_pkcs,5L,10L

/* Extension request OIDs */

#define LN_ms_ext_req			"Microsoft Extension Request"
#define SN_ms_ext_req			"msExtReq"
#define NID_ms_ext_req			171
#define OBJ_ms_ext_req			1L,3L,6L,1L,4L,1L,311L,2L,1L,14L

#define LN_ext_req			"Extension Request"
#define SN_ext_req			"extReq"
#define NID_ext_req			172
#define OBJ_ext_req			OBJ_pkcs9,14L

#define SN_name				"name"
#define LN_name				"name"
#define NID_name			173
#define OBJ_name			OBJ_X509,41L

#define SN_dnQualifier			"dnQualifier"
#define LN_dnQualifier			"dnQualifier"
#define NID_dnQualifier			174
#define OBJ_dnQualifier			OBJ_X509,46L

#define SN_id_pe			"id-pe"
#define NID_id_pe			175
#define OBJ_id_pe			OBJ_id_pkix,1L

#define SN_id_ad			"id-ad"
#define NID_id_ad			176
#define OBJ_id_ad			OBJ_id_pkix,48L

#define SN_info_access			"authorityInfoAccess"
#define LN_info_access			"Authority Information Access"
#define NID_info_access			177
#define OBJ_info_access			OBJ_id_pe,1L

#define SN_ad_OCSP			"OCSP"
#define LN_ad_OCSP			"OCSP"
#define NID_ad_OCSP			178
#define OBJ_ad_OCSP			OBJ_id_ad,1L

#define SN_ad_ca_issuers		"caIssuers"
#define LN_ad_ca_issuers		"CA Issuers"
#define NID_ad_ca_issuers		179
#define OBJ_ad_ca_issuers		OBJ_id_ad,2L

#define SN_OCSP_sign			"OCSPSigning"
#define LN_OCSP_sign			"OCSP Signing"
#define NID_OCSP_sign			180
#define OBJ_OCSP_sign			OBJ_id_kp,9L
#endif /* USE_OBJ_MAC */

#include 
#include 

#define	OBJ_NAME_TYPE_UNDEF		0x00
#define	OBJ_NAME_TYPE_MD_METH		0x01
#define	OBJ_NAME_TYPE_CIPHER_METH	0x02
#define	OBJ_NAME_TYPE_PKEY_METH		0x03
#define	OBJ_NAME_TYPE_COMP_METH		0x04
#define	OBJ_NAME_TYPE_NUM		0x05

#define	OBJ_NAME_ALIAS			0x8000

#define OBJ_BSEARCH_VALUE_ON_NOMATCH		0x01
#define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH	0x02


#ifdef  __cplusplus
extern "C" {
#endif

typedef struct obj_name_st {
	int type;
	int alias;
	const char *name;
	const char *data;
} OBJ_NAME;

#define		OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c)


int OBJ_NAME_init(void);
int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *),
    int (*cmp_func)(const char *, const char *),
    void (*free_func)(const char *, int, const char *));
const char *OBJ_NAME_get(const char *name, int type);
int OBJ_NAME_add(const char *name, int type, const char *data);
int OBJ_NAME_remove(const char *name, int type);
void OBJ_NAME_cleanup(int type); /* -1 for everything */
void OBJ_NAME_do_all(int type, void (*fn)(const OBJ_NAME *, void *arg),
    void *arg);
void OBJ_NAME_do_all_sorted(int type, void (*fn)(const OBJ_NAME *, void *arg),
    void *arg);

ASN1_OBJECT *	OBJ_dup(const ASN1_OBJECT *o);
ASN1_OBJECT *	OBJ_nid2obj(int n);
const char *	OBJ_nid2ln(int n);
const char *	OBJ_nid2sn(int n);
int		OBJ_obj2nid(const ASN1_OBJECT *o);
ASN1_OBJECT *	OBJ_txt2obj(const char *s, int no_name);
int	OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);
int		OBJ_txt2nid(const char *s);
int		OBJ_ln2nid(const char *s);
int		OBJ_sn2nid(const char *s);
int		OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b);
const void *	OBJ_bsearch_(const void *key, const void *base, int num,
		    int size, int (*cmp)(const void *, const void *));
const void *	OBJ_bsearch_ex_(const void *key, const void *base, int num,
		    int size, int (*cmp)(const void *, const void *),
		    int flags);

#define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm)	\
  static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \
  static int nm##_cmp(type1 const *, type2 const *); \
  scope type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)

#define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp)	\
  _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp)
#define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm)	\
  type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)

/*
 * Unsolved problem: if a type is actually a pointer type, like
 * nid_triple is, then its impossible to get a const where you need
 * it. Consider:
 *
 * typedef int nid_triple[3];
 * const void *a_;
 * const nid_triple const *a = a_;
 *
 * The assignement discards a const because what you really want is:
 *
 * const int const * const *a = a_;
 *
 * But if you do that, you lose the fact that a is an array of 3 ints,
 * which breaks comparison functions.
 *
 * Thus we end up having to cast, sadly, or unpack the
 * declarations. Or, as I finally did in this case, delcare nid_triple
 * to be a struct, which it should have been in the first place.
 *
 * Ben, August 2008.
 *
 * Also, strictly speaking not all types need be const, but handling
 * the non-constness means a lot of complication, and in practice
 * comparison routines do always not touch their arguments.
 */

#define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm)	\
  static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)	\
      { \
      type1 const *a = a_; \
      type2 const *b = b_; \
      return nm##_cmp(a,b); \
      } \
  static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \
      { \
      return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \
					nm##_cmp_BSEARCH_CMP_FN); \
      } \
      extern void dummy_prototype(void)

#define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm)	\
  static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)	\
      { \
      type1 const *a = a_; \
      type2 const *b = b_; \
      return nm##_cmp(a,b); \
      } \
  type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \
      { \
      return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \
					nm##_cmp_BSEARCH_CMP_FN); \
      } \
      extern void dummy_prototype(void)

#define OBJ_bsearch(type1,key,type2,base,num,cmp)			       \
  ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \
			 num,sizeof(type2),				\
			 ((void)CHECKED_PTR_OF(type1,cmp##_type_1),	\
			  (void)CHECKED_PTR_OF(type2,cmp##_type_2),	\
			  cmp##_BSEARCH_CMP_FN)))

#define OBJ_bsearch_ex(type1,key,type2,base,num,cmp,flags)			\
  ((type2 *)OBJ_bsearch_ex_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \
			 num,sizeof(type2),				\
			 ((void)CHECKED_PTR_OF(type1,cmp##_type_1),	\
			  (void)type_2=CHECKED_PTR_OF(type2,cmp##_type_2), \
			  cmp##_BSEARCH_CMP_FN)),flags)

int		OBJ_new_nid(int num);
int		OBJ_add_object(const ASN1_OBJECT *obj);
int		OBJ_create(const char *oid, const char *sn, const char *ln);
void		OBJ_cleanup(void );
int		OBJ_create_objects(BIO *in);

int OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid);
int OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid);
int OBJ_add_sigid(int signid, int dig_id, int pkey_id);
void OBJ_sigid_free(void);

extern int obj_cleanup_defer;
void check_defer(int nid);

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_OBJ_strings(void);

/* Error codes for the OBJ functions. */

/* Function codes. */
#define OBJ_F_OBJ_ADD_OBJECT				 105
#define OBJ_F_OBJ_CREATE				 100
#define OBJ_F_OBJ_DUP					 101
#define OBJ_F_OBJ_NAME_NEW_INDEX			 106
#define OBJ_F_OBJ_NID2LN				 102
#define OBJ_F_OBJ_NID2OBJ				 103
#define OBJ_F_OBJ_NID2SN				 104

/* Reason codes. */
#define OBJ_R_MALLOC_FAILURE				 100
#define OBJ_R_UNKNOWN_NID				 101

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/krb5_asn.h0000644000175000017500000001672112360020705021725 0ustar  /* $OpenBSD$ */
/* Written by Vern Staats  for the OpenSSL project,
** using ocsp/{*.h,*asn*.c} as a starting point
*/

/* ====================================================================
 * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#ifndef HEADER_KRB5_ASN_H
#define HEADER_KRB5_ASN_H

/*
#include 
*/
#include 

#ifdef  __cplusplus
extern "C" {
#endif


/*	ASN.1 from Kerberos RFC 1510
*/

/*	EncryptedData ::=   SEQUENCE {
**		etype[0]                      INTEGER, -- EncryptionType
**		kvno[1]                       INTEGER OPTIONAL,
**		cipher[2]                     OCTET STRING -- ciphertext
**	}
*/
typedef	struct	krb5_encdata_st
	{
	ASN1_INTEGER			*etype;
	ASN1_INTEGER			*kvno;
	ASN1_OCTET_STRING		*cipher;
	}	KRB5_ENCDATA;

DECLARE_STACK_OF(KRB5_ENCDATA)

/*	PrincipalName ::=   SEQUENCE {
**		name-type[0]                  INTEGER,
**		name-string[1]                SEQUENCE OF GeneralString
**	}
*/
typedef	struct	krb5_princname_st
	{
	ASN1_INTEGER			*nametype;
	STACK_OF(ASN1_GENERALSTRING)	*namestring;
	}	KRB5_PRINCNAME;

DECLARE_STACK_OF(KRB5_PRINCNAME)


/*	Ticket ::=	[APPLICATION 1] SEQUENCE {
**		tkt-vno[0]                    INTEGER,
**		realm[1]                      Realm,
**		sname[2]                      PrincipalName,
**		enc-part[3]                   EncryptedData
**	}
*/
typedef	struct	krb5_tktbody_st
	{
	ASN1_INTEGER			*tktvno;
	ASN1_GENERALSTRING		*realm;
	KRB5_PRINCNAME			*sname;
	KRB5_ENCDATA			*encdata;
	}	KRB5_TKTBODY;

typedef STACK_OF(KRB5_TKTBODY) KRB5_TICKET;
DECLARE_STACK_OF(KRB5_TKTBODY)


/*	AP-REQ ::=      [APPLICATION 14] SEQUENCE {
**		pvno[0]                       INTEGER,
**		msg-type[1]                   INTEGER,
**		ap-options[2]                 APOptions,
**		ticket[3]                     Ticket,
**		authenticator[4]              EncryptedData
**	}
**
**	APOptions ::=   BIT STRING {
**		reserved(0), use-session-key(1), mutual-required(2) }
*/
typedef	struct	krb5_ap_req_st
	{
	ASN1_INTEGER			*pvno;
	ASN1_INTEGER			*msgtype;
	ASN1_BIT_STRING			*apoptions;
	KRB5_TICKET			*ticket;
	KRB5_ENCDATA			*authenticator;
	}	KRB5_APREQBODY;

typedef STACK_OF(KRB5_APREQBODY) KRB5_APREQ;
DECLARE_STACK_OF(KRB5_APREQBODY)


/*	Authenticator Stuff	*/


/*	Checksum ::=   SEQUENCE {
**		cksumtype[0]                  INTEGER,
**		checksum[1]                   OCTET STRING
**	}
*/
typedef	struct	krb5_checksum_st
	{
	ASN1_INTEGER			*ctype;
	ASN1_OCTET_STRING		*checksum;
	}	KRB5_CHECKSUM;

DECLARE_STACK_OF(KRB5_CHECKSUM)


/*	EncryptionKey ::=   SEQUENCE {
**		keytype[0]                    INTEGER,
**		keyvalue[1]                   OCTET STRING
**	}
*/
typedef struct  krb5_encryptionkey_st
	{
	ASN1_INTEGER			*ktype;
	ASN1_OCTET_STRING		*keyvalue;
	}	KRB5_ENCKEY;

DECLARE_STACK_OF(KRB5_ENCKEY)


/*	AuthorizationData ::=   SEQUENCE OF SEQUENCE {
**		ad-type[0]                    INTEGER,
**              ad-data[1]                    OCTET STRING
**	}
*/
typedef struct	krb5_authorization_st
	{
	ASN1_INTEGER			*adtype;
	ASN1_OCTET_STRING		*addata;
	}	KRB5_AUTHDATA;

DECLARE_STACK_OF(KRB5_AUTHDATA)

			
/*	-- Unencrypted authenticator
**	Authenticator ::=    [APPLICATION 2] SEQUENCE    {
**		authenticator-vno[0]          INTEGER,
**		crealm[1]                     Realm,
**		cname[2]                      PrincipalName,
**		cksum[3]                      Checksum OPTIONAL,
**		cusec[4]                      INTEGER,
**		ctime[5]                      KerberosTime,
**		subkey[6]                     EncryptionKey OPTIONAL,
**		seq-number[7]                 INTEGER OPTIONAL,
**		authorization-data[8]         AuthorizationData OPTIONAL
**	}
*/
typedef struct	krb5_authenticator_st
	{
	ASN1_INTEGER			*avno;
	ASN1_GENERALSTRING		*crealm;
	KRB5_PRINCNAME			*cname;
	KRB5_CHECKSUM			*cksum;
	ASN1_INTEGER			*cusec;
	ASN1_GENERALIZEDTIME		*ctime;
	KRB5_ENCKEY			*subkey;
	ASN1_INTEGER			*seqnum;
	KRB5_AUTHDATA			*authorization;
	}	KRB5_AUTHENTBODY;

typedef STACK_OF(KRB5_AUTHENTBODY) KRB5_AUTHENT;
DECLARE_STACK_OF(KRB5_AUTHENTBODY)


/*  DECLARE_ASN1_FUNCTIONS(type) = DECLARE_ASN1_FUNCTIONS_name(type, type) =
**	type *name##_new(void);
**	void name##_free(type *a);
**	DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) =
**	 DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) =
**	  type *d2i_##name(type **a, const unsigned char **in, long len);
**	  int i2d_##name(type *a, unsigned char **out);
**	  DECLARE_ASN1_ITEM(itname) = extern const ASN1_ITEM itname##_it
*/

DECLARE_ASN1_FUNCTIONS(KRB5_ENCDATA)
DECLARE_ASN1_FUNCTIONS(KRB5_PRINCNAME)
DECLARE_ASN1_FUNCTIONS(KRB5_TKTBODY)
DECLARE_ASN1_FUNCTIONS(KRB5_APREQBODY)
DECLARE_ASN1_FUNCTIONS(KRB5_TICKET)
DECLARE_ASN1_FUNCTIONS(KRB5_APREQ)

DECLARE_ASN1_FUNCTIONS(KRB5_CHECKSUM)
DECLARE_ASN1_FUNCTIONS(KRB5_ENCKEY)
DECLARE_ASN1_FUNCTIONS(KRB5_AUTHDATA)
DECLARE_ASN1_FUNCTIONS(KRB5_AUTHENTBODY)
DECLARE_ASN1_FUNCTIONS(KRB5_AUTHENT)


/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */

#ifdef  __cplusplus
}
#endif
#endif

deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/txt_db.h0000644000175000017500000001064112360020705021500 0ustar  /* $OpenBSD: txt_db.h,v 1.8 2014/06/12 15:49:31 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_TXT_DB_H
#define HEADER_TXT_DB_H

#include 

#ifndef OPENSSL_NO_BIO
#include 
#endif
#include 
#include 

#define DB_ERROR_OK			0
#define DB_ERROR_MALLOC			1
#define DB_ERROR_INDEX_CLASH    	2
#define DB_ERROR_INDEX_OUT_OF_RANGE	3
#define DB_ERROR_NO_INDEX		4
#define DB_ERROR_INSERT_INDEX_CLASH    	5

#ifdef  __cplusplus
extern "C" {
#endif

typedef OPENSSL_STRING *OPENSSL_PSTRING;
DECLARE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING)

typedef struct txt_db_st {
	int num_fields;
	STACK_OF(OPENSSL_PSTRING) *data;
	LHASH_OF(OPENSSL_STRING) **index;
	int (**qual)(OPENSSL_STRING *);
	long error;
	long arg1;
	long arg2;
	OPENSSL_STRING *arg_row;
} TXT_DB;

#ifndef OPENSSL_NO_BIO
TXT_DB *TXT_DB_read(BIO *in, int num);
long TXT_DB_write(BIO *out, TXT_DB *db);
#else
TXT_DB *TXT_DB_read(char *in, int num);
long TXT_DB_write(char *out, TXT_DB *db);
#endif
int TXT_DB_create_index(TXT_DB *db, int field, int (*qual)(OPENSSL_STRING *),
    LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp);
void TXT_DB_free(TXT_DB *db);
OPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx, OPENSSL_STRING *value);
int TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value);

#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/opensslfeatures.h0000644000175000017500000000107112360020705023433 0ustar  # define OPENSSL_NO_CAMELLIA
# define OPENSSL_NO_EC_NISTP_64_GCC_128
# define OPENSSL_NO_CMS
# define OPENSSL_NO_COMP
# define OPENSSL_NO_GMP
# define OPENSSL_NO_GOST
# define OPENSSL_NO_JPAKE
# define OPENSSL_NO_KRB5
# define OPENSSL_NO_MD2
# define OPENSSL_NO_PSK
# define OPENSSL_NO_RC5
# define OPENSSL_NO_RFC3779
# define OPENSSL_NO_SCTP
# define OPENSSL_NO_SEED
# define OPENSSL_NO_SRP
# define OPENSSL_NO_SSL2
# define OPENSSL_NO_STORE
# define OPENSSL_NO_BUF_FREELISTS
# define OPENSSL_NO_HEARTBEATS
# define OPENSSL_NO_DYNAMIC_ENGINE

# define OPENSSL_THREADS
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/sha.h0000644000175000017500000001655312360020705020777 0ustar  /* $OpenBSD: sha.h,v 1.16 2014/07/10 09:01:04 miod Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#include 

#ifndef HEADER_SHA_H
#define HEADER_SHA_H

#include 

#ifdef  __cplusplus
extern "C" {
#endif

#if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1))
#error SHA is disabled.
#endif

/*
 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 * ! SHA_LONG has to be at least 32 bits wide. If it's wider, then !
 * ! SHA_LONG_LOG2 has to be defined along.                        !
 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 */

#define SHA_LONG unsigned int

#define SHA_LBLOCK	16
#define SHA_CBLOCK	(SHA_LBLOCK*4)	/* SHA treats input data as a
					 * contiguous array of 32 bit
					 * wide big-endian values. */
#define SHA_LAST_BLOCK  (SHA_CBLOCK-8)
#define SHA_DIGEST_LENGTH 20

typedef struct SHAstate_st
	{
	SHA_LONG h0,h1,h2,h3,h4;
	SHA_LONG Nl,Nh;
	SHA_LONG data[SHA_LBLOCK];
	unsigned int num;
	} SHA_CTX;

#ifndef OPENSSL_NO_SHA0
int SHA_Init(SHA_CTX *c);
int SHA_Update(SHA_CTX *c, const void *data, size_t len)
	__attribute__ ((__bounded__(__buffer__,2,3)));
int SHA_Final(unsigned char *md, SHA_CTX *c);
unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md)
	__attribute__ ((__bounded__(__buffer__,1,2)));
void SHA_Transform(SHA_CTX *c, const unsigned char *data);
#endif
#ifndef OPENSSL_NO_SHA1
int SHA1_Init(SHA_CTX *c);
int SHA1_Update(SHA_CTX *c, const void *data, size_t len)
	__attribute__ ((__bounded__(__buffer__,2,3)));
int SHA1_Final(unsigned char *md, SHA_CTX *c);
unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md)
	__attribute__ ((__bounded__(__buffer__,1,2)));
void SHA1_Transform(SHA_CTX *c, const unsigned char *data);
#endif

#define SHA256_CBLOCK	(SHA_LBLOCK*4)	/* SHA-256 treats input data as a
					 * contiguous array of 32 bit
					 * wide big-endian values. */
#define SHA224_DIGEST_LENGTH	28
#define SHA256_DIGEST_LENGTH	32

typedef struct SHA256state_st
	{
	SHA_LONG h[8];
	SHA_LONG Nl,Nh;
	SHA_LONG data[SHA_LBLOCK];
	unsigned int num,md_len;
	} SHA256_CTX;

#ifndef OPENSSL_NO_SHA256
int SHA224_Init(SHA256_CTX *c);
int SHA224_Update(SHA256_CTX *c, const void *data, size_t len)
	__attribute__ ((__bounded__(__buffer__,2,3)));
int SHA224_Final(unsigned char *md, SHA256_CTX *c);
unsigned char *SHA224(const unsigned char *d, size_t n,unsigned char *md)
	__attribute__ ((__bounded__(__buffer__,1,2)));
int SHA256_Init(SHA256_CTX *c);
int SHA256_Update(SHA256_CTX *c, const void *data, size_t len)
	__attribute__ ((__bounded__(__buffer__,2,3)));
int SHA256_Final(unsigned char *md, SHA256_CTX *c);
unsigned char *SHA256(const unsigned char *d, size_t n,unsigned char *md)
	__attribute__ ((__bounded__(__buffer__,1,2)));
void SHA256_Transform(SHA256_CTX *c, const unsigned char *data);
#endif

#define SHA384_DIGEST_LENGTH	48
#define SHA512_DIGEST_LENGTH	64

#ifndef OPENSSL_NO_SHA512
/*
 * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64
 * being exactly 64-bit wide. See Implementation Notes in sha512.c
 * for further details.
 */
#define SHA512_CBLOCK	(SHA_LBLOCK*8)	/* SHA-512 treats input data as a
					 * contiguous array of 64 bit
					 * wide big-endian values. */
#if defined(_LP64)
#define SHA_LONG64 unsigned long
#define U64(C)     C##UL
#else
#define SHA_LONG64 unsigned long long
#define U64(C)     C##ULL
#endif

typedef struct SHA512state_st
	{
	SHA_LONG64 h[8];
	SHA_LONG64 Nl,Nh;
	union {
		SHA_LONG64	d[SHA_LBLOCK];
		unsigned char	p[SHA512_CBLOCK];
	} u;
	unsigned int num,md_len;
	} SHA512_CTX;
#endif

#ifndef OPENSSL_NO_SHA512
int SHA384_Init(SHA512_CTX *c);
int SHA384_Update(SHA512_CTX *c, const void *data, size_t len)
	__attribute__ ((__bounded__(__buffer__,2,3)));
int SHA384_Final(unsigned char *md, SHA512_CTX *c);
unsigned char *SHA384(const unsigned char *d, size_t n,unsigned char *md)
	__attribute__ ((__bounded__(__buffer__,1,2)));
int SHA512_Init(SHA512_CTX *c);
int SHA512_Update(SHA512_CTX *c, const void *data, size_t len)
	__attribute__ ((__bounded__(__buffer__,2,3)));
int SHA512_Final(unsigned char *md, SHA512_CTX *c);
unsigned char *SHA512(const unsigned char *d, size_t n,unsigned char *md)
	__attribute__ ((__bounded__(__buffer__,1,2)));
void SHA512_Transform(SHA512_CTX *c, const unsigned char *data);
#endif

#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/obj_mac.h0000644000175000017500000041633012360020705021613 0ustar  /* crypto/objects/obj_mac.h */

/* THIS FILE IS GENERATED FROM objects.txt by objects.pl via the
 * following command:
 * perl objects.pl objects.txt obj_mac.num obj_mac.h
 */

/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#define SN_undef			"UNDEF"
#define LN_undef			"undefined"
#define NID_undef			0
#define OBJ_undef			0L

#define SN_itu_t		"ITU-T"
#define LN_itu_t		"itu-t"
#define NID_itu_t		645
#define OBJ_itu_t		0L

#define NID_ccitt		404
#define OBJ_ccitt		OBJ_itu_t

#define SN_iso		"ISO"
#define LN_iso		"iso"
#define NID_iso		181
#define OBJ_iso		1L

#define SN_joint_iso_itu_t		"JOINT-ISO-ITU-T"
#define LN_joint_iso_itu_t		"joint-iso-itu-t"
#define NID_joint_iso_itu_t		646
#define OBJ_joint_iso_itu_t		2L

#define NID_joint_iso_ccitt		393
#define OBJ_joint_iso_ccitt		OBJ_joint_iso_itu_t

#define SN_member_body		"member-body"
#define LN_member_body		"ISO Member Body"
#define NID_member_body		182
#define OBJ_member_body		OBJ_iso,2L

#define SN_identified_organization		"identified-organization"
#define NID_identified_organization		676
#define OBJ_identified_organization		OBJ_iso,3L

#define SN_hmac_md5		"HMAC-MD5"
#define LN_hmac_md5		"hmac-md5"
#define NID_hmac_md5		780
#define OBJ_hmac_md5		OBJ_identified_organization,6L,1L,5L,5L,8L,1L,1L

#define SN_hmac_sha1		"HMAC-SHA1"
#define LN_hmac_sha1		"hmac-sha1"
#define NID_hmac_sha1		781
#define OBJ_hmac_sha1		OBJ_identified_organization,6L,1L,5L,5L,8L,1L,2L

#define SN_certicom_arc		"certicom-arc"
#define NID_certicom_arc		677
#define OBJ_certicom_arc		OBJ_identified_organization,132L

#define SN_international_organizations		"international-organizations"
#define LN_international_organizations		"International Organizations"
#define NID_international_organizations		647
#define OBJ_international_organizations		OBJ_joint_iso_itu_t,23L

#define SN_wap		"wap"
#define NID_wap		678
#define OBJ_wap		OBJ_international_organizations,43L

#define SN_wap_wsg		"wap-wsg"
#define NID_wap_wsg		679
#define OBJ_wap_wsg		OBJ_wap,1L

#define SN_selected_attribute_types		"selected-attribute-types"
#define LN_selected_attribute_types		"Selected Attribute Types"
#define NID_selected_attribute_types		394
#define OBJ_selected_attribute_types		OBJ_joint_iso_itu_t,5L,1L,5L

#define SN_clearance		"clearance"
#define NID_clearance		395
#define OBJ_clearance		OBJ_selected_attribute_types,55L

#define SN_ISO_US		"ISO-US"
#define LN_ISO_US		"ISO US Member Body"
#define NID_ISO_US		183
#define OBJ_ISO_US		OBJ_member_body,840L

#define SN_X9_57		"X9-57"
#define LN_X9_57		"X9.57"
#define NID_X9_57		184
#define OBJ_X9_57		OBJ_ISO_US,10040L

#define SN_X9cm		"X9cm"
#define LN_X9cm		"X9.57 CM ?"
#define NID_X9cm		185
#define OBJ_X9cm		OBJ_X9_57,4L

#define SN_dsa		"DSA"
#define LN_dsa		"dsaEncryption"
#define NID_dsa		116
#define OBJ_dsa		OBJ_X9cm,1L

#define SN_dsaWithSHA1		"DSA-SHA1"
#define LN_dsaWithSHA1		"dsaWithSHA1"
#define NID_dsaWithSHA1		113
#define OBJ_dsaWithSHA1		OBJ_X9cm,3L

#define SN_ansi_X9_62		"ansi-X9-62"
#define LN_ansi_X9_62		"ANSI X9.62"
#define NID_ansi_X9_62		405
#define OBJ_ansi_X9_62		OBJ_ISO_US,10045L

#define OBJ_X9_62_id_fieldType		OBJ_ansi_X9_62,1L

#define SN_X9_62_prime_field		"prime-field"
#define NID_X9_62_prime_field		406
#define OBJ_X9_62_prime_field		OBJ_X9_62_id_fieldType,1L

#define SN_X9_62_characteristic_two_field		"characteristic-two-field"
#define NID_X9_62_characteristic_two_field		407
#define OBJ_X9_62_characteristic_two_field		OBJ_X9_62_id_fieldType,2L

#define SN_X9_62_id_characteristic_two_basis		"id-characteristic-two-basis"
#define NID_X9_62_id_characteristic_two_basis		680
#define OBJ_X9_62_id_characteristic_two_basis		OBJ_X9_62_characteristic_two_field,3L

#define SN_X9_62_onBasis		"onBasis"
#define NID_X9_62_onBasis		681
#define OBJ_X9_62_onBasis		OBJ_X9_62_id_characteristic_two_basis,1L

#define SN_X9_62_tpBasis		"tpBasis"
#define NID_X9_62_tpBasis		682
#define OBJ_X9_62_tpBasis		OBJ_X9_62_id_characteristic_two_basis,2L

#define SN_X9_62_ppBasis		"ppBasis"
#define NID_X9_62_ppBasis		683
#define OBJ_X9_62_ppBasis		OBJ_X9_62_id_characteristic_two_basis,3L

#define OBJ_X9_62_id_publicKeyType		OBJ_ansi_X9_62,2L

#define SN_X9_62_id_ecPublicKey		"id-ecPublicKey"
#define NID_X9_62_id_ecPublicKey		408
#define OBJ_X9_62_id_ecPublicKey		OBJ_X9_62_id_publicKeyType,1L

#define OBJ_X9_62_ellipticCurve		OBJ_ansi_X9_62,3L

#define OBJ_X9_62_c_TwoCurve		OBJ_X9_62_ellipticCurve,0L

#define SN_X9_62_c2pnb163v1		"c2pnb163v1"
#define NID_X9_62_c2pnb163v1		684
#define OBJ_X9_62_c2pnb163v1		OBJ_X9_62_c_TwoCurve,1L

#define SN_X9_62_c2pnb163v2		"c2pnb163v2"
#define NID_X9_62_c2pnb163v2		685
#define OBJ_X9_62_c2pnb163v2		OBJ_X9_62_c_TwoCurve,2L

#define SN_X9_62_c2pnb163v3		"c2pnb163v3"
#define NID_X9_62_c2pnb163v3		686
#define OBJ_X9_62_c2pnb163v3		OBJ_X9_62_c_TwoCurve,3L

#define SN_X9_62_c2pnb176v1		"c2pnb176v1"
#define NID_X9_62_c2pnb176v1		687
#define OBJ_X9_62_c2pnb176v1		OBJ_X9_62_c_TwoCurve,4L

#define SN_X9_62_c2tnb191v1		"c2tnb191v1"
#define NID_X9_62_c2tnb191v1		688
#define OBJ_X9_62_c2tnb191v1		OBJ_X9_62_c_TwoCurve,5L

#define SN_X9_62_c2tnb191v2		"c2tnb191v2"
#define NID_X9_62_c2tnb191v2		689
#define OBJ_X9_62_c2tnb191v2		OBJ_X9_62_c_TwoCurve,6L

#define SN_X9_62_c2tnb191v3		"c2tnb191v3"
#define NID_X9_62_c2tnb191v3		690
#define OBJ_X9_62_c2tnb191v3		OBJ_X9_62_c_TwoCurve,7L

#define SN_X9_62_c2onb191v4		"c2onb191v4"
#define NID_X9_62_c2onb191v4		691
#define OBJ_X9_62_c2onb191v4		OBJ_X9_62_c_TwoCurve,8L

#define SN_X9_62_c2onb191v5		"c2onb191v5"
#define NID_X9_62_c2onb191v5		692
#define OBJ_X9_62_c2onb191v5		OBJ_X9_62_c_TwoCurve,9L

#define SN_X9_62_c2pnb208w1		"c2pnb208w1"
#define NID_X9_62_c2pnb208w1		693
#define OBJ_X9_62_c2pnb208w1		OBJ_X9_62_c_TwoCurve,10L

#define SN_X9_62_c2tnb239v1		"c2tnb239v1"
#define NID_X9_62_c2tnb239v1		694
#define OBJ_X9_62_c2tnb239v1		OBJ_X9_62_c_TwoCurve,11L

#define SN_X9_62_c2tnb239v2		"c2tnb239v2"
#define NID_X9_62_c2tnb239v2		695
#define OBJ_X9_62_c2tnb239v2		OBJ_X9_62_c_TwoCurve,12L

#define SN_X9_62_c2tnb239v3		"c2tnb239v3"
#define NID_X9_62_c2tnb239v3		696
#define OBJ_X9_62_c2tnb239v3		OBJ_X9_62_c_TwoCurve,13L

#define SN_X9_62_c2onb239v4		"c2onb239v4"
#define NID_X9_62_c2onb239v4		697
#define OBJ_X9_62_c2onb239v4		OBJ_X9_62_c_TwoCurve,14L

#define SN_X9_62_c2onb239v5		"c2onb239v5"
#define NID_X9_62_c2onb239v5		698
#define OBJ_X9_62_c2onb239v5		OBJ_X9_62_c_TwoCurve,15L

#define SN_X9_62_c2pnb272w1		"c2pnb272w1"
#define NID_X9_62_c2pnb272w1		699
#define OBJ_X9_62_c2pnb272w1		OBJ_X9_62_c_TwoCurve,16L

#define SN_X9_62_c2pnb304w1		"c2pnb304w1"
#define NID_X9_62_c2pnb304w1		700
#define OBJ_X9_62_c2pnb304w1		OBJ_X9_62_c_TwoCurve,17L

#define SN_X9_62_c2tnb359v1		"c2tnb359v1"
#define NID_X9_62_c2tnb359v1		701
#define OBJ_X9_62_c2tnb359v1		OBJ_X9_62_c_TwoCurve,18L

#define SN_X9_62_c2pnb368w1		"c2pnb368w1"
#define NID_X9_62_c2pnb368w1		702
#define OBJ_X9_62_c2pnb368w1		OBJ_X9_62_c_TwoCurve,19L

#define SN_X9_62_c2tnb431r1		"c2tnb431r1"
#define NID_X9_62_c2tnb431r1		703
#define OBJ_X9_62_c2tnb431r1		OBJ_X9_62_c_TwoCurve,20L

#define OBJ_X9_62_primeCurve		OBJ_X9_62_ellipticCurve,1L

#define SN_X9_62_prime192v1		"prime192v1"
#define NID_X9_62_prime192v1		409
#define OBJ_X9_62_prime192v1		OBJ_X9_62_primeCurve,1L

#define SN_X9_62_prime192v2		"prime192v2"
#define NID_X9_62_prime192v2		410
#define OBJ_X9_62_prime192v2		OBJ_X9_62_primeCurve,2L

#define SN_X9_62_prime192v3		"prime192v3"
#define NID_X9_62_prime192v3		411
#define OBJ_X9_62_prime192v3		OBJ_X9_62_primeCurve,3L

#define SN_X9_62_prime239v1		"prime239v1"
#define NID_X9_62_prime239v1		412
#define OBJ_X9_62_prime239v1		OBJ_X9_62_primeCurve,4L

#define SN_X9_62_prime239v2		"prime239v2"
#define NID_X9_62_prime239v2		413
#define OBJ_X9_62_prime239v2		OBJ_X9_62_primeCurve,5L

#define SN_X9_62_prime239v3		"prime239v3"
#define NID_X9_62_prime239v3		414
#define OBJ_X9_62_prime239v3		OBJ_X9_62_primeCurve,6L

#define SN_X9_62_prime256v1		"prime256v1"
#define NID_X9_62_prime256v1		415
#define OBJ_X9_62_prime256v1		OBJ_X9_62_primeCurve,7L

#define OBJ_X9_62_id_ecSigType		OBJ_ansi_X9_62,4L

#define SN_ecdsa_with_SHA1		"ecdsa-with-SHA1"
#define NID_ecdsa_with_SHA1		416
#define OBJ_ecdsa_with_SHA1		OBJ_X9_62_id_ecSigType,1L

#define SN_ecdsa_with_Recommended		"ecdsa-with-Recommended"
#define NID_ecdsa_with_Recommended		791
#define OBJ_ecdsa_with_Recommended		OBJ_X9_62_id_ecSigType,2L

#define SN_ecdsa_with_Specified		"ecdsa-with-Specified"
#define NID_ecdsa_with_Specified		792
#define OBJ_ecdsa_with_Specified		OBJ_X9_62_id_ecSigType,3L

#define SN_ecdsa_with_SHA224		"ecdsa-with-SHA224"
#define NID_ecdsa_with_SHA224		793
#define OBJ_ecdsa_with_SHA224		OBJ_ecdsa_with_Specified,1L

#define SN_ecdsa_with_SHA256		"ecdsa-with-SHA256"
#define NID_ecdsa_with_SHA256		794
#define OBJ_ecdsa_with_SHA256		OBJ_ecdsa_with_Specified,2L

#define SN_ecdsa_with_SHA384		"ecdsa-with-SHA384"
#define NID_ecdsa_with_SHA384		795
#define OBJ_ecdsa_with_SHA384		OBJ_ecdsa_with_Specified,3L

#define SN_ecdsa_with_SHA512		"ecdsa-with-SHA512"
#define NID_ecdsa_with_SHA512		796
#define OBJ_ecdsa_with_SHA512		OBJ_ecdsa_with_Specified,4L

#define OBJ_secg_ellipticCurve		OBJ_certicom_arc,0L

#define SN_secp112r1		"secp112r1"
#define NID_secp112r1		704
#define OBJ_secp112r1		OBJ_secg_ellipticCurve,6L

#define SN_secp112r2		"secp112r2"
#define NID_secp112r2		705
#define OBJ_secp112r2		OBJ_secg_ellipticCurve,7L

#define SN_secp128r1		"secp128r1"
#define NID_secp128r1		706
#define OBJ_secp128r1		OBJ_secg_ellipticCurve,28L

#define SN_secp128r2		"secp128r2"
#define NID_secp128r2		707
#define OBJ_secp128r2		OBJ_secg_ellipticCurve,29L

#define SN_secp160k1		"secp160k1"
#define NID_secp160k1		708
#define OBJ_secp160k1		OBJ_secg_ellipticCurve,9L

#define SN_secp160r1		"secp160r1"
#define NID_secp160r1		709
#define OBJ_secp160r1		OBJ_secg_ellipticCurve,8L

#define SN_secp160r2		"secp160r2"
#define NID_secp160r2		710
#define OBJ_secp160r2		OBJ_secg_ellipticCurve,30L

#define SN_secp192k1		"secp192k1"
#define NID_secp192k1		711
#define OBJ_secp192k1		OBJ_secg_ellipticCurve,31L

#define SN_secp224k1		"secp224k1"
#define NID_secp224k1		712
#define OBJ_secp224k1		OBJ_secg_ellipticCurve,32L

#define SN_secp224r1		"secp224r1"
#define NID_secp224r1		713
#define OBJ_secp224r1		OBJ_secg_ellipticCurve,33L

#define SN_secp256k1		"secp256k1"
#define NID_secp256k1		714
#define OBJ_secp256k1		OBJ_secg_ellipticCurve,10L

#define SN_secp384r1		"secp384r1"
#define NID_secp384r1		715
#define OBJ_secp384r1		OBJ_secg_ellipticCurve,34L

#define SN_secp521r1		"secp521r1"
#define NID_secp521r1		716
#define OBJ_secp521r1		OBJ_secg_ellipticCurve,35L

#define SN_sect113r1		"sect113r1"
#define NID_sect113r1		717
#define OBJ_sect113r1		OBJ_secg_ellipticCurve,4L

#define SN_sect113r2		"sect113r2"
#define NID_sect113r2		718
#define OBJ_sect113r2		OBJ_secg_ellipticCurve,5L

#define SN_sect131r1		"sect131r1"
#define NID_sect131r1		719
#define OBJ_sect131r1		OBJ_secg_ellipticCurve,22L

#define SN_sect131r2		"sect131r2"
#define NID_sect131r2		720
#define OBJ_sect131r2		OBJ_secg_ellipticCurve,23L

#define SN_sect163k1		"sect163k1"
#define NID_sect163k1		721
#define OBJ_sect163k1		OBJ_secg_ellipticCurve,1L

#define SN_sect163r1		"sect163r1"
#define NID_sect163r1		722
#define OBJ_sect163r1		OBJ_secg_ellipticCurve,2L

#define SN_sect163r2		"sect163r2"
#define NID_sect163r2		723
#define OBJ_sect163r2		OBJ_secg_ellipticCurve,15L

#define SN_sect193r1		"sect193r1"
#define NID_sect193r1		724
#define OBJ_sect193r1		OBJ_secg_ellipticCurve,24L

#define SN_sect193r2		"sect193r2"
#define NID_sect193r2		725
#define OBJ_sect193r2		OBJ_secg_ellipticCurve,25L

#define SN_sect233k1		"sect233k1"
#define NID_sect233k1		726
#define OBJ_sect233k1		OBJ_secg_ellipticCurve,26L

#define SN_sect233r1		"sect233r1"
#define NID_sect233r1		727
#define OBJ_sect233r1		OBJ_secg_ellipticCurve,27L

#define SN_sect239k1		"sect239k1"
#define NID_sect239k1		728
#define OBJ_sect239k1		OBJ_secg_ellipticCurve,3L

#define SN_sect283k1		"sect283k1"
#define NID_sect283k1		729
#define OBJ_sect283k1		OBJ_secg_ellipticCurve,16L

#define SN_sect283r1		"sect283r1"
#define NID_sect283r1		730
#define OBJ_sect283r1		OBJ_secg_ellipticCurve,17L

#define SN_sect409k1		"sect409k1"
#define NID_sect409k1		731
#define OBJ_sect409k1		OBJ_secg_ellipticCurve,36L

#define SN_sect409r1		"sect409r1"
#define NID_sect409r1		732
#define OBJ_sect409r1		OBJ_secg_ellipticCurve,37L

#define SN_sect571k1		"sect571k1"
#define NID_sect571k1		733
#define OBJ_sect571k1		OBJ_secg_ellipticCurve,38L

#define SN_sect571r1		"sect571r1"
#define NID_sect571r1		734
#define OBJ_sect571r1		OBJ_secg_ellipticCurve,39L

#define OBJ_wap_wsg_idm_ecid		OBJ_wap_wsg,4L

#define SN_wap_wsg_idm_ecid_wtls1		"wap-wsg-idm-ecid-wtls1"
#define NID_wap_wsg_idm_ecid_wtls1		735
#define OBJ_wap_wsg_idm_ecid_wtls1		OBJ_wap_wsg_idm_ecid,1L

#define SN_wap_wsg_idm_ecid_wtls3		"wap-wsg-idm-ecid-wtls3"
#define NID_wap_wsg_idm_ecid_wtls3		736
#define OBJ_wap_wsg_idm_ecid_wtls3		OBJ_wap_wsg_idm_ecid,3L

#define SN_wap_wsg_idm_ecid_wtls4		"wap-wsg-idm-ecid-wtls4"
#define NID_wap_wsg_idm_ecid_wtls4		737
#define OBJ_wap_wsg_idm_ecid_wtls4		OBJ_wap_wsg_idm_ecid,4L

#define SN_wap_wsg_idm_ecid_wtls5		"wap-wsg-idm-ecid-wtls5"
#define NID_wap_wsg_idm_ecid_wtls5		738
#define OBJ_wap_wsg_idm_ecid_wtls5		OBJ_wap_wsg_idm_ecid,5L

#define SN_wap_wsg_idm_ecid_wtls6		"wap-wsg-idm-ecid-wtls6"
#define NID_wap_wsg_idm_ecid_wtls6		739
#define OBJ_wap_wsg_idm_ecid_wtls6		OBJ_wap_wsg_idm_ecid,6L

#define SN_wap_wsg_idm_ecid_wtls7		"wap-wsg-idm-ecid-wtls7"
#define NID_wap_wsg_idm_ecid_wtls7		740
#define OBJ_wap_wsg_idm_ecid_wtls7		OBJ_wap_wsg_idm_ecid,7L

#define SN_wap_wsg_idm_ecid_wtls8		"wap-wsg-idm-ecid-wtls8"
#define NID_wap_wsg_idm_ecid_wtls8		741
#define OBJ_wap_wsg_idm_ecid_wtls8		OBJ_wap_wsg_idm_ecid,8L

#define SN_wap_wsg_idm_ecid_wtls9		"wap-wsg-idm-ecid-wtls9"
#define NID_wap_wsg_idm_ecid_wtls9		742
#define OBJ_wap_wsg_idm_ecid_wtls9		OBJ_wap_wsg_idm_ecid,9L

#define SN_wap_wsg_idm_ecid_wtls10		"wap-wsg-idm-ecid-wtls10"
#define NID_wap_wsg_idm_ecid_wtls10		743
#define OBJ_wap_wsg_idm_ecid_wtls10		OBJ_wap_wsg_idm_ecid,10L

#define SN_wap_wsg_idm_ecid_wtls11		"wap-wsg-idm-ecid-wtls11"
#define NID_wap_wsg_idm_ecid_wtls11		744
#define OBJ_wap_wsg_idm_ecid_wtls11		OBJ_wap_wsg_idm_ecid,11L

#define SN_wap_wsg_idm_ecid_wtls12		"wap-wsg-idm-ecid-wtls12"
#define NID_wap_wsg_idm_ecid_wtls12		745
#define OBJ_wap_wsg_idm_ecid_wtls12		OBJ_wap_wsg_idm_ecid,12L

#define SN_cast5_cbc		"CAST5-CBC"
#define LN_cast5_cbc		"cast5-cbc"
#define NID_cast5_cbc		108
#define OBJ_cast5_cbc		OBJ_ISO_US,113533L,7L,66L,10L

#define SN_cast5_ecb		"CAST5-ECB"
#define LN_cast5_ecb		"cast5-ecb"
#define NID_cast5_ecb		109

#define SN_cast5_cfb64		"CAST5-CFB"
#define LN_cast5_cfb64		"cast5-cfb"
#define NID_cast5_cfb64		110

#define SN_cast5_ofb64		"CAST5-OFB"
#define LN_cast5_ofb64		"cast5-ofb"
#define NID_cast5_ofb64		111

#define LN_pbeWithMD5AndCast5_CBC		"pbeWithMD5AndCast5CBC"
#define NID_pbeWithMD5AndCast5_CBC		112
#define OBJ_pbeWithMD5AndCast5_CBC		OBJ_ISO_US,113533L,7L,66L,12L

#define SN_id_PasswordBasedMAC		"id-PasswordBasedMAC"
#define LN_id_PasswordBasedMAC		"password based MAC"
#define NID_id_PasswordBasedMAC		782
#define OBJ_id_PasswordBasedMAC		OBJ_ISO_US,113533L,7L,66L,13L

#define SN_id_DHBasedMac		"id-DHBasedMac"
#define LN_id_DHBasedMac		"Diffie-Hellman based MAC"
#define NID_id_DHBasedMac		783
#define OBJ_id_DHBasedMac		OBJ_ISO_US,113533L,7L,66L,30L

#define SN_rsadsi		"rsadsi"
#define LN_rsadsi		"RSA Data Security, Inc."
#define NID_rsadsi		1
#define OBJ_rsadsi		OBJ_ISO_US,113549L

#define SN_pkcs		"pkcs"
#define LN_pkcs		"RSA Data Security, Inc. PKCS"
#define NID_pkcs		2
#define OBJ_pkcs		OBJ_rsadsi,1L

#define SN_pkcs1		"pkcs1"
#define NID_pkcs1		186
#define OBJ_pkcs1		OBJ_pkcs,1L

#define LN_rsaEncryption		"rsaEncryption"
#define NID_rsaEncryption		6
#define OBJ_rsaEncryption		OBJ_pkcs1,1L

#define SN_md2WithRSAEncryption		"RSA-MD2"
#define LN_md2WithRSAEncryption		"md2WithRSAEncryption"
#define NID_md2WithRSAEncryption		7
#define OBJ_md2WithRSAEncryption		OBJ_pkcs1,2L

#define SN_md4WithRSAEncryption		"RSA-MD4"
#define LN_md4WithRSAEncryption		"md4WithRSAEncryption"
#define NID_md4WithRSAEncryption		396
#define OBJ_md4WithRSAEncryption		OBJ_pkcs1,3L

#define SN_md5WithRSAEncryption		"RSA-MD5"
#define LN_md5WithRSAEncryption		"md5WithRSAEncryption"
#define NID_md5WithRSAEncryption		8
#define OBJ_md5WithRSAEncryption		OBJ_pkcs1,4L

#define SN_sha1WithRSAEncryption		"RSA-SHA1"
#define LN_sha1WithRSAEncryption		"sha1WithRSAEncryption"
#define NID_sha1WithRSAEncryption		65
#define OBJ_sha1WithRSAEncryption		OBJ_pkcs1,5L

#define SN_rsaesOaep		"RSAES-OAEP"
#define LN_rsaesOaep		"rsaesOaep"
#define NID_rsaesOaep		919
#define OBJ_rsaesOaep		OBJ_pkcs1,7L

#define SN_mgf1		"MGF1"
#define LN_mgf1		"mgf1"
#define NID_mgf1		911
#define OBJ_mgf1		OBJ_pkcs1,8L

#define SN_rsassaPss		"RSASSA-PSS"
#define LN_rsassaPss		"rsassaPss"
#define NID_rsassaPss		912
#define OBJ_rsassaPss		OBJ_pkcs1,10L

#define SN_sha256WithRSAEncryption		"RSA-SHA256"
#define LN_sha256WithRSAEncryption		"sha256WithRSAEncryption"
#define NID_sha256WithRSAEncryption		668
#define OBJ_sha256WithRSAEncryption		OBJ_pkcs1,11L

#define SN_sha384WithRSAEncryption		"RSA-SHA384"
#define LN_sha384WithRSAEncryption		"sha384WithRSAEncryption"
#define NID_sha384WithRSAEncryption		669
#define OBJ_sha384WithRSAEncryption		OBJ_pkcs1,12L

#define SN_sha512WithRSAEncryption		"RSA-SHA512"
#define LN_sha512WithRSAEncryption		"sha512WithRSAEncryption"
#define NID_sha512WithRSAEncryption		670
#define OBJ_sha512WithRSAEncryption		OBJ_pkcs1,13L

#define SN_sha224WithRSAEncryption		"RSA-SHA224"
#define LN_sha224WithRSAEncryption		"sha224WithRSAEncryption"
#define NID_sha224WithRSAEncryption		671
#define OBJ_sha224WithRSAEncryption		OBJ_pkcs1,14L

#define SN_pkcs3		"pkcs3"
#define NID_pkcs3		27
#define OBJ_pkcs3		OBJ_pkcs,3L

#define LN_dhKeyAgreement		"dhKeyAgreement"
#define NID_dhKeyAgreement		28
#define OBJ_dhKeyAgreement		OBJ_pkcs3,1L

#define SN_pkcs5		"pkcs5"
#define NID_pkcs5		187
#define OBJ_pkcs5		OBJ_pkcs,5L

#define SN_pbeWithMD2AndDES_CBC		"PBE-MD2-DES"
#define LN_pbeWithMD2AndDES_CBC		"pbeWithMD2AndDES-CBC"
#define NID_pbeWithMD2AndDES_CBC		9
#define OBJ_pbeWithMD2AndDES_CBC		OBJ_pkcs5,1L

#define SN_pbeWithMD5AndDES_CBC		"PBE-MD5-DES"
#define LN_pbeWithMD5AndDES_CBC		"pbeWithMD5AndDES-CBC"
#define NID_pbeWithMD5AndDES_CBC		10
#define OBJ_pbeWithMD5AndDES_CBC		OBJ_pkcs5,3L

#define SN_pbeWithMD2AndRC2_CBC		"PBE-MD2-RC2-64"
#define LN_pbeWithMD2AndRC2_CBC		"pbeWithMD2AndRC2-CBC"
#define NID_pbeWithMD2AndRC2_CBC		168
#define OBJ_pbeWithMD2AndRC2_CBC		OBJ_pkcs5,4L

#define SN_pbeWithMD5AndRC2_CBC		"PBE-MD5-RC2-64"
#define LN_pbeWithMD5AndRC2_CBC		"pbeWithMD5AndRC2-CBC"
#define NID_pbeWithMD5AndRC2_CBC		169
#define OBJ_pbeWithMD5AndRC2_CBC		OBJ_pkcs5,6L

#define SN_pbeWithSHA1AndDES_CBC		"PBE-SHA1-DES"
#define LN_pbeWithSHA1AndDES_CBC		"pbeWithSHA1AndDES-CBC"
#define NID_pbeWithSHA1AndDES_CBC		170
#define OBJ_pbeWithSHA1AndDES_CBC		OBJ_pkcs5,10L

#define SN_pbeWithSHA1AndRC2_CBC		"PBE-SHA1-RC2-64"
#define LN_pbeWithSHA1AndRC2_CBC		"pbeWithSHA1AndRC2-CBC"
#define NID_pbeWithSHA1AndRC2_CBC		68
#define OBJ_pbeWithSHA1AndRC2_CBC		OBJ_pkcs5,11L

#define LN_id_pbkdf2		"PBKDF2"
#define NID_id_pbkdf2		69
#define OBJ_id_pbkdf2		OBJ_pkcs5,12L

#define LN_pbes2		"PBES2"
#define NID_pbes2		161
#define OBJ_pbes2		OBJ_pkcs5,13L

#define LN_pbmac1		"PBMAC1"
#define NID_pbmac1		162
#define OBJ_pbmac1		OBJ_pkcs5,14L

#define SN_pkcs7		"pkcs7"
#define NID_pkcs7		20
#define OBJ_pkcs7		OBJ_pkcs,7L

#define LN_pkcs7_data		"pkcs7-data"
#define NID_pkcs7_data		21
#define OBJ_pkcs7_data		OBJ_pkcs7,1L

#define LN_pkcs7_signed		"pkcs7-signedData"
#define NID_pkcs7_signed		22
#define OBJ_pkcs7_signed		OBJ_pkcs7,2L

#define LN_pkcs7_enveloped		"pkcs7-envelopedData"
#define NID_pkcs7_enveloped		23
#define OBJ_pkcs7_enveloped		OBJ_pkcs7,3L

#define LN_pkcs7_signedAndEnveloped		"pkcs7-signedAndEnvelopedData"
#define NID_pkcs7_signedAndEnveloped		24
#define OBJ_pkcs7_signedAndEnveloped		OBJ_pkcs7,4L

#define LN_pkcs7_digest		"pkcs7-digestData"
#define NID_pkcs7_digest		25
#define OBJ_pkcs7_digest		OBJ_pkcs7,5L

#define LN_pkcs7_encrypted		"pkcs7-encryptedData"
#define NID_pkcs7_encrypted		26
#define OBJ_pkcs7_encrypted		OBJ_pkcs7,6L

#define SN_pkcs9		"pkcs9"
#define NID_pkcs9		47
#define OBJ_pkcs9		OBJ_pkcs,9L

#define LN_pkcs9_emailAddress		"emailAddress"
#define NID_pkcs9_emailAddress		48
#define OBJ_pkcs9_emailAddress		OBJ_pkcs9,1L

#define LN_pkcs9_unstructuredName		"unstructuredName"
#define NID_pkcs9_unstructuredName		49
#define OBJ_pkcs9_unstructuredName		OBJ_pkcs9,2L

#define LN_pkcs9_contentType		"contentType"
#define NID_pkcs9_contentType		50
#define OBJ_pkcs9_contentType		OBJ_pkcs9,3L

#define LN_pkcs9_messageDigest		"messageDigest"
#define NID_pkcs9_messageDigest		51
#define OBJ_pkcs9_messageDigest		OBJ_pkcs9,4L

#define LN_pkcs9_signingTime		"signingTime"
#define NID_pkcs9_signingTime		52
#define OBJ_pkcs9_signingTime		OBJ_pkcs9,5L

#define LN_pkcs9_countersignature		"countersignature"
#define NID_pkcs9_countersignature		53
#define OBJ_pkcs9_countersignature		OBJ_pkcs9,6L

#define LN_pkcs9_challengePassword		"challengePassword"
#define NID_pkcs9_challengePassword		54
#define OBJ_pkcs9_challengePassword		OBJ_pkcs9,7L

#define LN_pkcs9_unstructuredAddress		"unstructuredAddress"
#define NID_pkcs9_unstructuredAddress		55
#define OBJ_pkcs9_unstructuredAddress		OBJ_pkcs9,8L

#define LN_pkcs9_extCertAttributes		"extendedCertificateAttributes"
#define NID_pkcs9_extCertAttributes		56
#define OBJ_pkcs9_extCertAttributes		OBJ_pkcs9,9L

#define SN_ext_req		"extReq"
#define LN_ext_req		"Extension Request"
#define NID_ext_req		172
#define OBJ_ext_req		OBJ_pkcs9,14L

#define SN_SMIMECapabilities		"SMIME-CAPS"
#define LN_SMIMECapabilities		"S/MIME Capabilities"
#define NID_SMIMECapabilities		167
#define OBJ_SMIMECapabilities		OBJ_pkcs9,15L

#define SN_SMIME		"SMIME"
#define LN_SMIME		"S/MIME"
#define NID_SMIME		188
#define OBJ_SMIME		OBJ_pkcs9,16L

#define SN_id_smime_mod		"id-smime-mod"
#define NID_id_smime_mod		189
#define OBJ_id_smime_mod		OBJ_SMIME,0L

#define SN_id_smime_ct		"id-smime-ct"
#define NID_id_smime_ct		190
#define OBJ_id_smime_ct		OBJ_SMIME,1L

#define SN_id_smime_aa		"id-smime-aa"
#define NID_id_smime_aa		191
#define OBJ_id_smime_aa		OBJ_SMIME,2L

#define SN_id_smime_alg		"id-smime-alg"
#define NID_id_smime_alg		192
#define OBJ_id_smime_alg		OBJ_SMIME,3L

#define SN_id_smime_cd		"id-smime-cd"
#define NID_id_smime_cd		193
#define OBJ_id_smime_cd		OBJ_SMIME,4L

#define SN_id_smime_spq		"id-smime-spq"
#define NID_id_smime_spq		194
#define OBJ_id_smime_spq		OBJ_SMIME,5L

#define SN_id_smime_cti		"id-smime-cti"
#define NID_id_smime_cti		195
#define OBJ_id_smime_cti		OBJ_SMIME,6L

#define SN_id_smime_mod_cms		"id-smime-mod-cms"
#define NID_id_smime_mod_cms		196
#define OBJ_id_smime_mod_cms		OBJ_id_smime_mod,1L

#define SN_id_smime_mod_ess		"id-smime-mod-ess"
#define NID_id_smime_mod_ess		197
#define OBJ_id_smime_mod_ess		OBJ_id_smime_mod,2L

#define SN_id_smime_mod_oid		"id-smime-mod-oid"
#define NID_id_smime_mod_oid		198
#define OBJ_id_smime_mod_oid		OBJ_id_smime_mod,3L

#define SN_id_smime_mod_msg_v3		"id-smime-mod-msg-v3"
#define NID_id_smime_mod_msg_v3		199
#define OBJ_id_smime_mod_msg_v3		OBJ_id_smime_mod,4L

#define SN_id_smime_mod_ets_eSignature_88		"id-smime-mod-ets-eSignature-88"
#define NID_id_smime_mod_ets_eSignature_88		200
#define OBJ_id_smime_mod_ets_eSignature_88		OBJ_id_smime_mod,5L

#define SN_id_smime_mod_ets_eSignature_97		"id-smime-mod-ets-eSignature-97"
#define NID_id_smime_mod_ets_eSignature_97		201
#define OBJ_id_smime_mod_ets_eSignature_97		OBJ_id_smime_mod,6L

#define SN_id_smime_mod_ets_eSigPolicy_88		"id-smime-mod-ets-eSigPolicy-88"
#define NID_id_smime_mod_ets_eSigPolicy_88		202
#define OBJ_id_smime_mod_ets_eSigPolicy_88		OBJ_id_smime_mod,7L

#define SN_id_smime_mod_ets_eSigPolicy_97		"id-smime-mod-ets-eSigPolicy-97"
#define NID_id_smime_mod_ets_eSigPolicy_97		203
#define OBJ_id_smime_mod_ets_eSigPolicy_97		OBJ_id_smime_mod,8L

#define SN_id_smime_ct_receipt		"id-smime-ct-receipt"
#define NID_id_smime_ct_receipt		204
#define OBJ_id_smime_ct_receipt		OBJ_id_smime_ct,1L

#define SN_id_smime_ct_authData		"id-smime-ct-authData"
#define NID_id_smime_ct_authData		205
#define OBJ_id_smime_ct_authData		OBJ_id_smime_ct,2L

#define SN_id_smime_ct_publishCert		"id-smime-ct-publishCert"
#define NID_id_smime_ct_publishCert		206
#define OBJ_id_smime_ct_publishCert		OBJ_id_smime_ct,3L

#define SN_id_smime_ct_TSTInfo		"id-smime-ct-TSTInfo"
#define NID_id_smime_ct_TSTInfo		207
#define OBJ_id_smime_ct_TSTInfo		OBJ_id_smime_ct,4L

#define SN_id_smime_ct_TDTInfo		"id-smime-ct-TDTInfo"
#define NID_id_smime_ct_TDTInfo		208
#define OBJ_id_smime_ct_TDTInfo		OBJ_id_smime_ct,5L

#define SN_id_smime_ct_contentInfo		"id-smime-ct-contentInfo"
#define NID_id_smime_ct_contentInfo		209
#define OBJ_id_smime_ct_contentInfo		OBJ_id_smime_ct,6L

#define SN_id_smime_ct_DVCSRequestData		"id-smime-ct-DVCSRequestData"
#define NID_id_smime_ct_DVCSRequestData		210
#define OBJ_id_smime_ct_DVCSRequestData		OBJ_id_smime_ct,7L

#define SN_id_smime_ct_DVCSResponseData		"id-smime-ct-DVCSResponseData"
#define NID_id_smime_ct_DVCSResponseData		211
#define OBJ_id_smime_ct_DVCSResponseData		OBJ_id_smime_ct,8L

#define SN_id_smime_ct_compressedData		"id-smime-ct-compressedData"
#define NID_id_smime_ct_compressedData		786
#define OBJ_id_smime_ct_compressedData		OBJ_id_smime_ct,9L

#define SN_id_ct_asciiTextWithCRLF		"id-ct-asciiTextWithCRLF"
#define NID_id_ct_asciiTextWithCRLF		787
#define OBJ_id_ct_asciiTextWithCRLF		OBJ_id_smime_ct,27L

#define SN_id_smime_aa_receiptRequest		"id-smime-aa-receiptRequest"
#define NID_id_smime_aa_receiptRequest		212
#define OBJ_id_smime_aa_receiptRequest		OBJ_id_smime_aa,1L

#define SN_id_smime_aa_securityLabel		"id-smime-aa-securityLabel"
#define NID_id_smime_aa_securityLabel		213
#define OBJ_id_smime_aa_securityLabel		OBJ_id_smime_aa,2L

#define SN_id_smime_aa_mlExpandHistory		"id-smime-aa-mlExpandHistory"
#define NID_id_smime_aa_mlExpandHistory		214
#define OBJ_id_smime_aa_mlExpandHistory		OBJ_id_smime_aa,3L

#define SN_id_smime_aa_contentHint		"id-smime-aa-contentHint"
#define NID_id_smime_aa_contentHint		215
#define OBJ_id_smime_aa_contentHint		OBJ_id_smime_aa,4L

#define SN_id_smime_aa_msgSigDigest		"id-smime-aa-msgSigDigest"
#define NID_id_smime_aa_msgSigDigest		216
#define OBJ_id_smime_aa_msgSigDigest		OBJ_id_smime_aa,5L

#define SN_id_smime_aa_encapContentType		"id-smime-aa-encapContentType"
#define NID_id_smime_aa_encapContentType		217
#define OBJ_id_smime_aa_encapContentType		OBJ_id_smime_aa,6L

#define SN_id_smime_aa_contentIdentifier		"id-smime-aa-contentIdentifier"
#define NID_id_smime_aa_contentIdentifier		218
#define OBJ_id_smime_aa_contentIdentifier		OBJ_id_smime_aa,7L

#define SN_id_smime_aa_macValue		"id-smime-aa-macValue"
#define NID_id_smime_aa_macValue		219
#define OBJ_id_smime_aa_macValue		OBJ_id_smime_aa,8L

#define SN_id_smime_aa_equivalentLabels		"id-smime-aa-equivalentLabels"
#define NID_id_smime_aa_equivalentLabels		220
#define OBJ_id_smime_aa_equivalentLabels		OBJ_id_smime_aa,9L

#define SN_id_smime_aa_contentReference		"id-smime-aa-contentReference"
#define NID_id_smime_aa_contentReference		221
#define OBJ_id_smime_aa_contentReference		OBJ_id_smime_aa,10L

#define SN_id_smime_aa_encrypKeyPref		"id-smime-aa-encrypKeyPref"
#define NID_id_smime_aa_encrypKeyPref		222
#define OBJ_id_smime_aa_encrypKeyPref		OBJ_id_smime_aa,11L

#define SN_id_smime_aa_signingCertificate		"id-smime-aa-signingCertificate"
#define NID_id_smime_aa_signingCertificate		223
#define OBJ_id_smime_aa_signingCertificate		OBJ_id_smime_aa,12L

#define SN_id_smime_aa_smimeEncryptCerts		"id-smime-aa-smimeEncryptCerts"
#define NID_id_smime_aa_smimeEncryptCerts		224
#define OBJ_id_smime_aa_smimeEncryptCerts		OBJ_id_smime_aa,13L

#define SN_id_smime_aa_timeStampToken		"id-smime-aa-timeStampToken"
#define NID_id_smime_aa_timeStampToken		225
#define OBJ_id_smime_aa_timeStampToken		OBJ_id_smime_aa,14L

#define SN_id_smime_aa_ets_sigPolicyId		"id-smime-aa-ets-sigPolicyId"
#define NID_id_smime_aa_ets_sigPolicyId		226
#define OBJ_id_smime_aa_ets_sigPolicyId		OBJ_id_smime_aa,15L

#define SN_id_smime_aa_ets_commitmentType		"id-smime-aa-ets-commitmentType"
#define NID_id_smime_aa_ets_commitmentType		227
#define OBJ_id_smime_aa_ets_commitmentType		OBJ_id_smime_aa,16L

#define SN_id_smime_aa_ets_signerLocation		"id-smime-aa-ets-signerLocation"
#define NID_id_smime_aa_ets_signerLocation		228
#define OBJ_id_smime_aa_ets_signerLocation		OBJ_id_smime_aa,17L

#define SN_id_smime_aa_ets_signerAttr		"id-smime-aa-ets-signerAttr"
#define NID_id_smime_aa_ets_signerAttr		229
#define OBJ_id_smime_aa_ets_signerAttr		OBJ_id_smime_aa,18L

#define SN_id_smime_aa_ets_otherSigCert		"id-smime-aa-ets-otherSigCert"
#define NID_id_smime_aa_ets_otherSigCert		230
#define OBJ_id_smime_aa_ets_otherSigCert		OBJ_id_smime_aa,19L

#define SN_id_smime_aa_ets_contentTimestamp		"id-smime-aa-ets-contentTimestamp"
#define NID_id_smime_aa_ets_contentTimestamp		231
#define OBJ_id_smime_aa_ets_contentTimestamp		OBJ_id_smime_aa,20L

#define SN_id_smime_aa_ets_CertificateRefs		"id-smime-aa-ets-CertificateRefs"
#define NID_id_smime_aa_ets_CertificateRefs		232
#define OBJ_id_smime_aa_ets_CertificateRefs		OBJ_id_smime_aa,21L

#define SN_id_smime_aa_ets_RevocationRefs		"id-smime-aa-ets-RevocationRefs"
#define NID_id_smime_aa_ets_RevocationRefs		233
#define OBJ_id_smime_aa_ets_RevocationRefs		OBJ_id_smime_aa,22L

#define SN_id_smime_aa_ets_certValues		"id-smime-aa-ets-certValues"
#define NID_id_smime_aa_ets_certValues		234
#define OBJ_id_smime_aa_ets_certValues		OBJ_id_smime_aa,23L

#define SN_id_smime_aa_ets_revocationValues		"id-smime-aa-ets-revocationValues"
#define NID_id_smime_aa_ets_revocationValues		235
#define OBJ_id_smime_aa_ets_revocationValues		OBJ_id_smime_aa,24L

#define SN_id_smime_aa_ets_escTimeStamp		"id-smime-aa-ets-escTimeStamp"
#define NID_id_smime_aa_ets_escTimeStamp		236
#define OBJ_id_smime_aa_ets_escTimeStamp		OBJ_id_smime_aa,25L

#define SN_id_smime_aa_ets_certCRLTimestamp		"id-smime-aa-ets-certCRLTimestamp"
#define NID_id_smime_aa_ets_certCRLTimestamp		237
#define OBJ_id_smime_aa_ets_certCRLTimestamp		OBJ_id_smime_aa,26L

#define SN_id_smime_aa_ets_archiveTimeStamp		"id-smime-aa-ets-archiveTimeStamp"
#define NID_id_smime_aa_ets_archiveTimeStamp		238
#define OBJ_id_smime_aa_ets_archiveTimeStamp		OBJ_id_smime_aa,27L

#define SN_id_smime_aa_signatureType		"id-smime-aa-signatureType"
#define NID_id_smime_aa_signatureType		239
#define OBJ_id_smime_aa_signatureType		OBJ_id_smime_aa,28L

#define SN_id_smime_aa_dvcs_dvc		"id-smime-aa-dvcs-dvc"
#define NID_id_smime_aa_dvcs_dvc		240
#define OBJ_id_smime_aa_dvcs_dvc		OBJ_id_smime_aa,29L

#define SN_id_smime_alg_ESDHwith3DES		"id-smime-alg-ESDHwith3DES"
#define NID_id_smime_alg_ESDHwith3DES		241
#define OBJ_id_smime_alg_ESDHwith3DES		OBJ_id_smime_alg,1L

#define SN_id_smime_alg_ESDHwithRC2		"id-smime-alg-ESDHwithRC2"
#define NID_id_smime_alg_ESDHwithRC2		242
#define OBJ_id_smime_alg_ESDHwithRC2		OBJ_id_smime_alg,2L

#define SN_id_smime_alg_3DESwrap		"id-smime-alg-3DESwrap"
#define NID_id_smime_alg_3DESwrap		243
#define OBJ_id_smime_alg_3DESwrap		OBJ_id_smime_alg,3L

#define SN_id_smime_alg_RC2wrap		"id-smime-alg-RC2wrap"
#define NID_id_smime_alg_RC2wrap		244
#define OBJ_id_smime_alg_RC2wrap		OBJ_id_smime_alg,4L

#define SN_id_smime_alg_ESDH		"id-smime-alg-ESDH"
#define NID_id_smime_alg_ESDH		245
#define OBJ_id_smime_alg_ESDH		OBJ_id_smime_alg,5L

#define SN_id_smime_alg_CMS3DESwrap		"id-smime-alg-CMS3DESwrap"
#define NID_id_smime_alg_CMS3DESwrap		246
#define OBJ_id_smime_alg_CMS3DESwrap		OBJ_id_smime_alg,6L

#define SN_id_smime_alg_CMSRC2wrap		"id-smime-alg-CMSRC2wrap"
#define NID_id_smime_alg_CMSRC2wrap		247
#define OBJ_id_smime_alg_CMSRC2wrap		OBJ_id_smime_alg,7L

#define SN_id_alg_PWRI_KEK		"id-alg-PWRI-KEK"
#define NID_id_alg_PWRI_KEK		893
#define OBJ_id_alg_PWRI_KEK		OBJ_id_smime_alg,9L

#define SN_id_smime_cd_ldap		"id-smime-cd-ldap"
#define NID_id_smime_cd_ldap		248
#define OBJ_id_smime_cd_ldap		OBJ_id_smime_cd,1L

#define SN_id_smime_spq_ets_sqt_uri		"id-smime-spq-ets-sqt-uri"
#define NID_id_smime_spq_ets_sqt_uri		249
#define OBJ_id_smime_spq_ets_sqt_uri		OBJ_id_smime_spq,1L

#define SN_id_smime_spq_ets_sqt_unotice		"id-smime-spq-ets-sqt-unotice"
#define NID_id_smime_spq_ets_sqt_unotice		250
#define OBJ_id_smime_spq_ets_sqt_unotice		OBJ_id_smime_spq,2L

#define SN_id_smime_cti_ets_proofOfOrigin		"id-smime-cti-ets-proofOfOrigin"
#define NID_id_smime_cti_ets_proofOfOrigin		251
#define OBJ_id_smime_cti_ets_proofOfOrigin		OBJ_id_smime_cti,1L

#define SN_id_smime_cti_ets_proofOfReceipt		"id-smime-cti-ets-proofOfReceipt"
#define NID_id_smime_cti_ets_proofOfReceipt		252
#define OBJ_id_smime_cti_ets_proofOfReceipt		OBJ_id_smime_cti,2L

#define SN_id_smime_cti_ets_proofOfDelivery		"id-smime-cti-ets-proofOfDelivery"
#define NID_id_smime_cti_ets_proofOfDelivery		253
#define OBJ_id_smime_cti_ets_proofOfDelivery		OBJ_id_smime_cti,3L

#define SN_id_smime_cti_ets_proofOfSender		"id-smime-cti-ets-proofOfSender"
#define NID_id_smime_cti_ets_proofOfSender		254
#define OBJ_id_smime_cti_ets_proofOfSender		OBJ_id_smime_cti,4L

#define SN_id_smime_cti_ets_proofOfApproval		"id-smime-cti-ets-proofOfApproval"
#define NID_id_smime_cti_ets_proofOfApproval		255
#define OBJ_id_smime_cti_ets_proofOfApproval		OBJ_id_smime_cti,5L

#define SN_id_smime_cti_ets_proofOfCreation		"id-smime-cti-ets-proofOfCreation"
#define NID_id_smime_cti_ets_proofOfCreation		256
#define OBJ_id_smime_cti_ets_proofOfCreation		OBJ_id_smime_cti,6L

#define LN_friendlyName		"friendlyName"
#define NID_friendlyName		156
#define OBJ_friendlyName		OBJ_pkcs9,20L

#define LN_localKeyID		"localKeyID"
#define NID_localKeyID		157
#define OBJ_localKeyID		OBJ_pkcs9,21L

#define SN_ms_csp_name		"CSPName"
#define LN_ms_csp_name		"Microsoft CSP Name"
#define NID_ms_csp_name		417
#define OBJ_ms_csp_name		1L,3L,6L,1L,4L,1L,311L,17L,1L

#define SN_LocalKeySet		"LocalKeySet"
#define LN_LocalKeySet		"Microsoft Local Key set"
#define NID_LocalKeySet		856
#define OBJ_LocalKeySet		1L,3L,6L,1L,4L,1L,311L,17L,2L

#define OBJ_certTypes		OBJ_pkcs9,22L

#define LN_x509Certificate		"x509Certificate"
#define NID_x509Certificate		158
#define OBJ_x509Certificate		OBJ_certTypes,1L

#define LN_sdsiCertificate		"sdsiCertificate"
#define NID_sdsiCertificate		159
#define OBJ_sdsiCertificate		OBJ_certTypes,2L

#define OBJ_crlTypes		OBJ_pkcs9,23L

#define LN_x509Crl		"x509Crl"
#define NID_x509Crl		160
#define OBJ_x509Crl		OBJ_crlTypes,1L

#define OBJ_pkcs12		OBJ_pkcs,12L

#define OBJ_pkcs12_pbeids		OBJ_pkcs12,1L

#define SN_pbe_WithSHA1And128BitRC4		"PBE-SHA1-RC4-128"
#define LN_pbe_WithSHA1And128BitRC4		"pbeWithSHA1And128BitRC4"
#define NID_pbe_WithSHA1And128BitRC4		144
#define OBJ_pbe_WithSHA1And128BitRC4		OBJ_pkcs12_pbeids,1L

#define SN_pbe_WithSHA1And40BitRC4		"PBE-SHA1-RC4-40"
#define LN_pbe_WithSHA1And40BitRC4		"pbeWithSHA1And40BitRC4"
#define NID_pbe_WithSHA1And40BitRC4		145
#define OBJ_pbe_WithSHA1And40BitRC4		OBJ_pkcs12_pbeids,2L

#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC		"PBE-SHA1-3DES"
#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC		"pbeWithSHA1And3-KeyTripleDES-CBC"
#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC		146
#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC		OBJ_pkcs12_pbeids,3L

#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC		"PBE-SHA1-2DES"
#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC		"pbeWithSHA1And2-KeyTripleDES-CBC"
#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC		147
#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC		OBJ_pkcs12_pbeids,4L

#define SN_pbe_WithSHA1And128BitRC2_CBC		"PBE-SHA1-RC2-128"
#define LN_pbe_WithSHA1And128BitRC2_CBC		"pbeWithSHA1And128BitRC2-CBC"
#define NID_pbe_WithSHA1And128BitRC2_CBC		148
#define OBJ_pbe_WithSHA1And128BitRC2_CBC		OBJ_pkcs12_pbeids,5L

#define SN_pbe_WithSHA1And40BitRC2_CBC		"PBE-SHA1-RC2-40"
#define LN_pbe_WithSHA1And40BitRC2_CBC		"pbeWithSHA1And40BitRC2-CBC"
#define NID_pbe_WithSHA1And40BitRC2_CBC		149
#define OBJ_pbe_WithSHA1And40BitRC2_CBC		OBJ_pkcs12_pbeids,6L

#define OBJ_pkcs12_Version1		OBJ_pkcs12,10L

#define OBJ_pkcs12_BagIds		OBJ_pkcs12_Version1,1L

#define LN_keyBag		"keyBag"
#define NID_keyBag		150
#define OBJ_keyBag		OBJ_pkcs12_BagIds,1L

#define LN_pkcs8ShroudedKeyBag		"pkcs8ShroudedKeyBag"
#define NID_pkcs8ShroudedKeyBag		151
#define OBJ_pkcs8ShroudedKeyBag		OBJ_pkcs12_BagIds,2L

#define LN_certBag		"certBag"
#define NID_certBag		152
#define OBJ_certBag		OBJ_pkcs12_BagIds,3L

#define LN_crlBag		"crlBag"
#define NID_crlBag		153
#define OBJ_crlBag		OBJ_pkcs12_BagIds,4L

#define LN_secretBag		"secretBag"
#define NID_secretBag		154
#define OBJ_secretBag		OBJ_pkcs12_BagIds,5L

#define LN_safeContentsBag		"safeContentsBag"
#define NID_safeContentsBag		155
#define OBJ_safeContentsBag		OBJ_pkcs12_BagIds,6L

#define SN_md2		"MD2"
#define LN_md2		"md2"
#define NID_md2		3
#define OBJ_md2		OBJ_rsadsi,2L,2L

#define SN_md4		"MD4"
#define LN_md4		"md4"
#define NID_md4		257
#define OBJ_md4		OBJ_rsadsi,2L,4L

#define SN_md5		"MD5"
#define LN_md5		"md5"
#define NID_md5		4
#define OBJ_md5		OBJ_rsadsi,2L,5L

#define SN_md5_sha1		"MD5-SHA1"
#define LN_md5_sha1		"md5-sha1"
#define NID_md5_sha1		114

#define LN_hmacWithMD5		"hmacWithMD5"
#define NID_hmacWithMD5		797
#define OBJ_hmacWithMD5		OBJ_rsadsi,2L,6L

#define LN_hmacWithSHA1		"hmacWithSHA1"
#define NID_hmacWithSHA1		163
#define OBJ_hmacWithSHA1		OBJ_rsadsi,2L,7L

#define LN_hmacWithSHA224		"hmacWithSHA224"
#define NID_hmacWithSHA224		798
#define OBJ_hmacWithSHA224		OBJ_rsadsi,2L,8L

#define LN_hmacWithSHA256		"hmacWithSHA256"
#define NID_hmacWithSHA256		799
#define OBJ_hmacWithSHA256		OBJ_rsadsi,2L,9L

#define LN_hmacWithSHA384		"hmacWithSHA384"
#define NID_hmacWithSHA384		800
#define OBJ_hmacWithSHA384		OBJ_rsadsi,2L,10L

#define LN_hmacWithSHA512		"hmacWithSHA512"
#define NID_hmacWithSHA512		801
#define OBJ_hmacWithSHA512		OBJ_rsadsi,2L,11L

#define SN_rc2_cbc		"RC2-CBC"
#define LN_rc2_cbc		"rc2-cbc"
#define NID_rc2_cbc		37
#define OBJ_rc2_cbc		OBJ_rsadsi,3L,2L

#define SN_rc2_ecb		"RC2-ECB"
#define LN_rc2_ecb		"rc2-ecb"
#define NID_rc2_ecb		38

#define SN_rc2_cfb64		"RC2-CFB"
#define LN_rc2_cfb64		"rc2-cfb"
#define NID_rc2_cfb64		39

#define SN_rc2_ofb64		"RC2-OFB"
#define LN_rc2_ofb64		"rc2-ofb"
#define NID_rc2_ofb64		40

#define SN_rc2_40_cbc		"RC2-40-CBC"
#define LN_rc2_40_cbc		"rc2-40-cbc"
#define NID_rc2_40_cbc		98

#define SN_rc2_64_cbc		"RC2-64-CBC"
#define LN_rc2_64_cbc		"rc2-64-cbc"
#define NID_rc2_64_cbc		166

#define SN_rc4		"RC4"
#define LN_rc4		"rc4"
#define NID_rc4		5
#define OBJ_rc4		OBJ_rsadsi,3L,4L

#define SN_rc4_40		"RC4-40"
#define LN_rc4_40		"rc4-40"
#define NID_rc4_40		97

#define SN_des_ede3_cbc		"DES-EDE3-CBC"
#define LN_des_ede3_cbc		"des-ede3-cbc"
#define NID_des_ede3_cbc		44
#define OBJ_des_ede3_cbc		OBJ_rsadsi,3L,7L

#define SN_rc5_cbc		"RC5-CBC"
#define LN_rc5_cbc		"rc5-cbc"
#define NID_rc5_cbc		120
#define OBJ_rc5_cbc		OBJ_rsadsi,3L,8L

#define SN_rc5_ecb		"RC5-ECB"
#define LN_rc5_ecb		"rc5-ecb"
#define NID_rc5_ecb		121

#define SN_rc5_cfb64		"RC5-CFB"
#define LN_rc5_cfb64		"rc5-cfb"
#define NID_rc5_cfb64		122

#define SN_rc5_ofb64		"RC5-OFB"
#define LN_rc5_ofb64		"rc5-ofb"
#define NID_rc5_ofb64		123

#define SN_ms_ext_req		"msExtReq"
#define LN_ms_ext_req		"Microsoft Extension Request"
#define NID_ms_ext_req		171
#define OBJ_ms_ext_req		1L,3L,6L,1L,4L,1L,311L,2L,1L,14L

#define SN_ms_code_ind		"msCodeInd"
#define LN_ms_code_ind		"Microsoft Individual Code Signing"
#define NID_ms_code_ind		134
#define OBJ_ms_code_ind		1L,3L,6L,1L,4L,1L,311L,2L,1L,21L

#define SN_ms_code_com		"msCodeCom"
#define LN_ms_code_com		"Microsoft Commercial Code Signing"
#define NID_ms_code_com		135
#define OBJ_ms_code_com		1L,3L,6L,1L,4L,1L,311L,2L,1L,22L

#define SN_ms_ctl_sign		"msCTLSign"
#define LN_ms_ctl_sign		"Microsoft Trust List Signing"
#define NID_ms_ctl_sign		136
#define OBJ_ms_ctl_sign		1L,3L,6L,1L,4L,1L,311L,10L,3L,1L

#define SN_ms_sgc		"msSGC"
#define LN_ms_sgc		"Microsoft Server Gated Crypto"
#define NID_ms_sgc		137
#define OBJ_ms_sgc		1L,3L,6L,1L,4L,1L,311L,10L,3L,3L

#define SN_ms_efs		"msEFS"
#define LN_ms_efs		"Microsoft Encrypted File System"
#define NID_ms_efs		138
#define OBJ_ms_efs		1L,3L,6L,1L,4L,1L,311L,10L,3L,4L

#define SN_ms_smartcard_login		"msSmartcardLogin"
#define LN_ms_smartcard_login		"Microsoft Smartcardlogin"
#define NID_ms_smartcard_login		648
#define OBJ_ms_smartcard_login		1L,3L,6L,1L,4L,1L,311L,20L,2L,2L

#define SN_ms_upn		"msUPN"
#define LN_ms_upn		"Microsoft Universal Principal Name"
#define NID_ms_upn		649
#define OBJ_ms_upn		1L,3L,6L,1L,4L,1L,311L,20L,2L,3L

#define SN_idea_cbc		"IDEA-CBC"
#define LN_idea_cbc		"idea-cbc"
#define NID_idea_cbc		34
#define OBJ_idea_cbc		1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L

#define SN_idea_ecb		"IDEA-ECB"
#define LN_idea_ecb		"idea-ecb"
#define NID_idea_ecb		36

#define SN_idea_cfb64		"IDEA-CFB"
#define LN_idea_cfb64		"idea-cfb"
#define NID_idea_cfb64		35

#define SN_idea_ofb64		"IDEA-OFB"
#define LN_idea_ofb64		"idea-ofb"
#define NID_idea_ofb64		46

#define SN_bf_cbc		"BF-CBC"
#define LN_bf_cbc		"bf-cbc"
#define NID_bf_cbc		91
#define OBJ_bf_cbc		1L,3L,6L,1L,4L,1L,3029L,1L,2L

#define SN_bf_ecb		"BF-ECB"
#define LN_bf_ecb		"bf-ecb"
#define NID_bf_ecb		92

#define SN_bf_cfb64		"BF-CFB"
#define LN_bf_cfb64		"bf-cfb"
#define NID_bf_cfb64		93

#define SN_bf_ofb64		"BF-OFB"
#define LN_bf_ofb64		"bf-ofb"
#define NID_bf_ofb64		94

#define SN_id_pkix		"PKIX"
#define NID_id_pkix		127
#define OBJ_id_pkix		1L,3L,6L,1L,5L,5L,7L

#define SN_id_pkix_mod		"id-pkix-mod"
#define NID_id_pkix_mod		258
#define OBJ_id_pkix_mod		OBJ_id_pkix,0L

#define SN_id_pe		"id-pe"
#define NID_id_pe		175
#define OBJ_id_pe		OBJ_id_pkix,1L

#define SN_id_qt		"id-qt"
#define NID_id_qt		259
#define OBJ_id_qt		OBJ_id_pkix,2L

#define SN_id_kp		"id-kp"
#define NID_id_kp		128
#define OBJ_id_kp		OBJ_id_pkix,3L

#define SN_id_it		"id-it"
#define NID_id_it		260
#define OBJ_id_it		OBJ_id_pkix,4L

#define SN_id_pkip		"id-pkip"
#define NID_id_pkip		261
#define OBJ_id_pkip		OBJ_id_pkix,5L

#define SN_id_alg		"id-alg"
#define NID_id_alg		262
#define OBJ_id_alg		OBJ_id_pkix,6L

#define SN_id_cmc		"id-cmc"
#define NID_id_cmc		263
#define OBJ_id_cmc		OBJ_id_pkix,7L

#define SN_id_on		"id-on"
#define NID_id_on		264
#define OBJ_id_on		OBJ_id_pkix,8L

#define SN_id_pda		"id-pda"
#define NID_id_pda		265
#define OBJ_id_pda		OBJ_id_pkix,9L

#define SN_id_aca		"id-aca"
#define NID_id_aca		266
#define OBJ_id_aca		OBJ_id_pkix,10L

#define SN_id_qcs		"id-qcs"
#define NID_id_qcs		267
#define OBJ_id_qcs		OBJ_id_pkix,11L

#define SN_id_cct		"id-cct"
#define NID_id_cct		268
#define OBJ_id_cct		OBJ_id_pkix,12L

#define SN_id_ppl		"id-ppl"
#define NID_id_ppl		662
#define OBJ_id_ppl		OBJ_id_pkix,21L

#define SN_id_ad		"id-ad"
#define NID_id_ad		176
#define OBJ_id_ad		OBJ_id_pkix,48L

#define SN_id_pkix1_explicit_88		"id-pkix1-explicit-88"
#define NID_id_pkix1_explicit_88		269
#define OBJ_id_pkix1_explicit_88		OBJ_id_pkix_mod,1L

#define SN_id_pkix1_implicit_88		"id-pkix1-implicit-88"
#define NID_id_pkix1_implicit_88		270
#define OBJ_id_pkix1_implicit_88		OBJ_id_pkix_mod,2L

#define SN_id_pkix1_explicit_93		"id-pkix1-explicit-93"
#define NID_id_pkix1_explicit_93		271
#define OBJ_id_pkix1_explicit_93		OBJ_id_pkix_mod,3L

#define SN_id_pkix1_implicit_93		"id-pkix1-implicit-93"
#define NID_id_pkix1_implicit_93		272
#define OBJ_id_pkix1_implicit_93		OBJ_id_pkix_mod,4L

#define SN_id_mod_crmf		"id-mod-crmf"
#define NID_id_mod_crmf		273
#define OBJ_id_mod_crmf		OBJ_id_pkix_mod,5L

#define SN_id_mod_cmc		"id-mod-cmc"
#define NID_id_mod_cmc		274
#define OBJ_id_mod_cmc		OBJ_id_pkix_mod,6L

#define SN_id_mod_kea_profile_88		"id-mod-kea-profile-88"
#define NID_id_mod_kea_profile_88		275
#define OBJ_id_mod_kea_profile_88		OBJ_id_pkix_mod,7L

#define SN_id_mod_kea_profile_93		"id-mod-kea-profile-93"
#define NID_id_mod_kea_profile_93		276
#define OBJ_id_mod_kea_profile_93		OBJ_id_pkix_mod,8L

#define SN_id_mod_cmp		"id-mod-cmp"
#define NID_id_mod_cmp		277
#define OBJ_id_mod_cmp		OBJ_id_pkix_mod,9L

#define SN_id_mod_qualified_cert_88		"id-mod-qualified-cert-88"
#define NID_id_mod_qualified_cert_88		278
#define OBJ_id_mod_qualified_cert_88		OBJ_id_pkix_mod,10L

#define SN_id_mod_qualified_cert_93		"id-mod-qualified-cert-93"
#define NID_id_mod_qualified_cert_93		279
#define OBJ_id_mod_qualified_cert_93		OBJ_id_pkix_mod,11L

#define SN_id_mod_attribute_cert		"id-mod-attribute-cert"
#define NID_id_mod_attribute_cert		280
#define OBJ_id_mod_attribute_cert		OBJ_id_pkix_mod,12L

#define SN_id_mod_timestamp_protocol		"id-mod-timestamp-protocol"
#define NID_id_mod_timestamp_protocol		281
#define OBJ_id_mod_timestamp_protocol		OBJ_id_pkix_mod,13L

#define SN_id_mod_ocsp		"id-mod-ocsp"
#define NID_id_mod_ocsp		282
#define OBJ_id_mod_ocsp		OBJ_id_pkix_mod,14L

#define SN_id_mod_dvcs		"id-mod-dvcs"
#define NID_id_mod_dvcs		283
#define OBJ_id_mod_dvcs		OBJ_id_pkix_mod,15L

#define SN_id_mod_cmp2000		"id-mod-cmp2000"
#define NID_id_mod_cmp2000		284
#define OBJ_id_mod_cmp2000		OBJ_id_pkix_mod,16L

#define SN_info_access		"authorityInfoAccess"
#define LN_info_access		"Authority Information Access"
#define NID_info_access		177
#define OBJ_info_access		OBJ_id_pe,1L

#define SN_biometricInfo		"biometricInfo"
#define LN_biometricInfo		"Biometric Info"
#define NID_biometricInfo		285
#define OBJ_biometricInfo		OBJ_id_pe,2L

#define SN_qcStatements		"qcStatements"
#define NID_qcStatements		286
#define OBJ_qcStatements		OBJ_id_pe,3L

#define SN_ac_auditEntity		"ac-auditEntity"
#define NID_ac_auditEntity		287
#define OBJ_ac_auditEntity		OBJ_id_pe,4L

#define SN_ac_targeting		"ac-targeting"
#define NID_ac_targeting		288
#define OBJ_ac_targeting		OBJ_id_pe,5L

#define SN_aaControls		"aaControls"
#define NID_aaControls		289
#define OBJ_aaControls		OBJ_id_pe,6L

#define SN_sbgp_ipAddrBlock		"sbgp-ipAddrBlock"
#define NID_sbgp_ipAddrBlock		290
#define OBJ_sbgp_ipAddrBlock		OBJ_id_pe,7L

#define SN_sbgp_autonomousSysNum		"sbgp-autonomousSysNum"
#define NID_sbgp_autonomousSysNum		291
#define OBJ_sbgp_autonomousSysNum		OBJ_id_pe,8L

#define SN_sbgp_routerIdentifier		"sbgp-routerIdentifier"
#define NID_sbgp_routerIdentifier		292
#define OBJ_sbgp_routerIdentifier		OBJ_id_pe,9L

#define SN_ac_proxying		"ac-proxying"
#define NID_ac_proxying		397
#define OBJ_ac_proxying		OBJ_id_pe,10L

#define SN_sinfo_access		"subjectInfoAccess"
#define LN_sinfo_access		"Subject Information Access"
#define NID_sinfo_access		398
#define OBJ_sinfo_access		OBJ_id_pe,11L

#define SN_proxyCertInfo		"proxyCertInfo"
#define LN_proxyCertInfo		"Proxy Certificate Information"
#define NID_proxyCertInfo		663
#define OBJ_proxyCertInfo		OBJ_id_pe,14L

#define SN_id_qt_cps		"id-qt-cps"
#define LN_id_qt_cps		"Policy Qualifier CPS"
#define NID_id_qt_cps		164
#define OBJ_id_qt_cps		OBJ_id_qt,1L

#define SN_id_qt_unotice		"id-qt-unotice"
#define LN_id_qt_unotice		"Policy Qualifier User Notice"
#define NID_id_qt_unotice		165
#define OBJ_id_qt_unotice		OBJ_id_qt,2L

#define SN_textNotice		"textNotice"
#define NID_textNotice		293
#define OBJ_textNotice		OBJ_id_qt,3L

#define SN_server_auth		"serverAuth"
#define LN_server_auth		"TLS Web Server Authentication"
#define NID_server_auth		129
#define OBJ_server_auth		OBJ_id_kp,1L

#define SN_client_auth		"clientAuth"
#define LN_client_auth		"TLS Web Client Authentication"
#define NID_client_auth		130
#define OBJ_client_auth		OBJ_id_kp,2L

#define SN_code_sign		"codeSigning"
#define LN_code_sign		"Code Signing"
#define NID_code_sign		131
#define OBJ_code_sign		OBJ_id_kp,3L

#define SN_email_protect		"emailProtection"
#define LN_email_protect		"E-mail Protection"
#define NID_email_protect		132
#define OBJ_email_protect		OBJ_id_kp,4L

#define SN_ipsecEndSystem		"ipsecEndSystem"
#define LN_ipsecEndSystem		"IPSec End System"
#define NID_ipsecEndSystem		294
#define OBJ_ipsecEndSystem		OBJ_id_kp,5L

#define SN_ipsecTunnel		"ipsecTunnel"
#define LN_ipsecTunnel		"IPSec Tunnel"
#define NID_ipsecTunnel		295
#define OBJ_ipsecTunnel		OBJ_id_kp,6L

#define SN_ipsecUser		"ipsecUser"
#define LN_ipsecUser		"IPSec User"
#define NID_ipsecUser		296
#define OBJ_ipsecUser		OBJ_id_kp,7L

#define SN_time_stamp		"timeStamping"
#define LN_time_stamp		"Time Stamping"
#define NID_time_stamp		133
#define OBJ_time_stamp		OBJ_id_kp,8L

#define SN_OCSP_sign		"OCSPSigning"
#define LN_OCSP_sign		"OCSP Signing"
#define NID_OCSP_sign		180
#define OBJ_OCSP_sign		OBJ_id_kp,9L

#define SN_dvcs		"DVCS"
#define LN_dvcs		"dvcs"
#define NID_dvcs		297
#define OBJ_dvcs		OBJ_id_kp,10L

#define SN_id_it_caProtEncCert		"id-it-caProtEncCert"
#define NID_id_it_caProtEncCert		298
#define OBJ_id_it_caProtEncCert		OBJ_id_it,1L

#define SN_id_it_signKeyPairTypes		"id-it-signKeyPairTypes"
#define NID_id_it_signKeyPairTypes		299
#define OBJ_id_it_signKeyPairTypes		OBJ_id_it,2L

#define SN_id_it_encKeyPairTypes		"id-it-encKeyPairTypes"
#define NID_id_it_encKeyPairTypes		300
#define OBJ_id_it_encKeyPairTypes		OBJ_id_it,3L

#define SN_id_it_preferredSymmAlg		"id-it-preferredSymmAlg"
#define NID_id_it_preferredSymmAlg		301
#define OBJ_id_it_preferredSymmAlg		OBJ_id_it,4L

#define SN_id_it_caKeyUpdateInfo		"id-it-caKeyUpdateInfo"
#define NID_id_it_caKeyUpdateInfo		302
#define OBJ_id_it_caKeyUpdateInfo		OBJ_id_it,5L

#define SN_id_it_currentCRL		"id-it-currentCRL"
#define NID_id_it_currentCRL		303
#define OBJ_id_it_currentCRL		OBJ_id_it,6L

#define SN_id_it_unsupportedOIDs		"id-it-unsupportedOIDs"
#define NID_id_it_unsupportedOIDs		304
#define OBJ_id_it_unsupportedOIDs		OBJ_id_it,7L

#define SN_id_it_subscriptionRequest		"id-it-subscriptionRequest"
#define NID_id_it_subscriptionRequest		305
#define OBJ_id_it_subscriptionRequest		OBJ_id_it,8L

#define SN_id_it_subscriptionResponse		"id-it-subscriptionResponse"
#define NID_id_it_subscriptionResponse		306
#define OBJ_id_it_subscriptionResponse		OBJ_id_it,9L

#define SN_id_it_keyPairParamReq		"id-it-keyPairParamReq"
#define NID_id_it_keyPairParamReq		307
#define OBJ_id_it_keyPairParamReq		OBJ_id_it,10L

#define SN_id_it_keyPairParamRep		"id-it-keyPairParamRep"
#define NID_id_it_keyPairParamRep		308
#define OBJ_id_it_keyPairParamRep		OBJ_id_it,11L

#define SN_id_it_revPassphrase		"id-it-revPassphrase"
#define NID_id_it_revPassphrase		309
#define OBJ_id_it_revPassphrase		OBJ_id_it,12L

#define SN_id_it_implicitConfirm		"id-it-implicitConfirm"
#define NID_id_it_implicitConfirm		310
#define OBJ_id_it_implicitConfirm		OBJ_id_it,13L

#define SN_id_it_confirmWaitTime		"id-it-confirmWaitTime"
#define NID_id_it_confirmWaitTime		311
#define OBJ_id_it_confirmWaitTime		OBJ_id_it,14L

#define SN_id_it_origPKIMessage		"id-it-origPKIMessage"
#define NID_id_it_origPKIMessage		312
#define OBJ_id_it_origPKIMessage		OBJ_id_it,15L

#define SN_id_it_suppLangTags		"id-it-suppLangTags"
#define NID_id_it_suppLangTags		784
#define OBJ_id_it_suppLangTags		OBJ_id_it,16L

#define SN_id_regCtrl		"id-regCtrl"
#define NID_id_regCtrl		313
#define OBJ_id_regCtrl		OBJ_id_pkip,1L

#define SN_id_regInfo		"id-regInfo"
#define NID_id_regInfo		314
#define OBJ_id_regInfo		OBJ_id_pkip,2L

#define SN_id_regCtrl_regToken		"id-regCtrl-regToken"
#define NID_id_regCtrl_regToken		315
#define OBJ_id_regCtrl_regToken		OBJ_id_regCtrl,1L

#define SN_id_regCtrl_authenticator		"id-regCtrl-authenticator"
#define NID_id_regCtrl_authenticator		316
#define OBJ_id_regCtrl_authenticator		OBJ_id_regCtrl,2L

#define SN_id_regCtrl_pkiPublicationInfo		"id-regCtrl-pkiPublicationInfo"
#define NID_id_regCtrl_pkiPublicationInfo		317
#define OBJ_id_regCtrl_pkiPublicationInfo		OBJ_id_regCtrl,3L

#define SN_id_regCtrl_pkiArchiveOptions		"id-regCtrl-pkiArchiveOptions"
#define NID_id_regCtrl_pkiArchiveOptions		318
#define OBJ_id_regCtrl_pkiArchiveOptions		OBJ_id_regCtrl,4L

#define SN_id_regCtrl_oldCertID		"id-regCtrl-oldCertID"
#define NID_id_regCtrl_oldCertID		319
#define OBJ_id_regCtrl_oldCertID		OBJ_id_regCtrl,5L

#define SN_id_regCtrl_protocolEncrKey		"id-regCtrl-protocolEncrKey"
#define NID_id_regCtrl_protocolEncrKey		320
#define OBJ_id_regCtrl_protocolEncrKey		OBJ_id_regCtrl,6L

#define SN_id_regInfo_utf8Pairs		"id-regInfo-utf8Pairs"
#define NID_id_regInfo_utf8Pairs		321
#define OBJ_id_regInfo_utf8Pairs		OBJ_id_regInfo,1L

#define SN_id_regInfo_certReq		"id-regInfo-certReq"
#define NID_id_regInfo_certReq		322
#define OBJ_id_regInfo_certReq		OBJ_id_regInfo,2L

#define SN_id_alg_des40		"id-alg-des40"
#define NID_id_alg_des40		323
#define OBJ_id_alg_des40		OBJ_id_alg,1L

#define SN_id_alg_noSignature		"id-alg-noSignature"
#define NID_id_alg_noSignature		324
#define OBJ_id_alg_noSignature		OBJ_id_alg,2L

#define SN_id_alg_dh_sig_hmac_sha1		"id-alg-dh-sig-hmac-sha1"
#define NID_id_alg_dh_sig_hmac_sha1		325
#define OBJ_id_alg_dh_sig_hmac_sha1		OBJ_id_alg,3L

#define SN_id_alg_dh_pop		"id-alg-dh-pop"
#define NID_id_alg_dh_pop		326
#define OBJ_id_alg_dh_pop		OBJ_id_alg,4L

#define SN_id_cmc_statusInfo		"id-cmc-statusInfo"
#define NID_id_cmc_statusInfo		327
#define OBJ_id_cmc_statusInfo		OBJ_id_cmc,1L

#define SN_id_cmc_identification		"id-cmc-identification"
#define NID_id_cmc_identification		328
#define OBJ_id_cmc_identification		OBJ_id_cmc,2L

#define SN_id_cmc_identityProof		"id-cmc-identityProof"
#define NID_id_cmc_identityProof		329
#define OBJ_id_cmc_identityProof		OBJ_id_cmc,3L

#define SN_id_cmc_dataReturn		"id-cmc-dataReturn"
#define NID_id_cmc_dataReturn		330
#define OBJ_id_cmc_dataReturn		OBJ_id_cmc,4L

#define SN_id_cmc_transactionId		"id-cmc-transactionId"
#define NID_id_cmc_transactionId		331
#define OBJ_id_cmc_transactionId		OBJ_id_cmc,5L

#define SN_id_cmc_senderNonce		"id-cmc-senderNonce"
#define NID_id_cmc_senderNonce		332
#define OBJ_id_cmc_senderNonce		OBJ_id_cmc,6L

#define SN_id_cmc_recipientNonce		"id-cmc-recipientNonce"
#define NID_id_cmc_recipientNonce		333
#define OBJ_id_cmc_recipientNonce		OBJ_id_cmc,7L

#define SN_id_cmc_addExtensions		"id-cmc-addExtensions"
#define NID_id_cmc_addExtensions		334
#define OBJ_id_cmc_addExtensions		OBJ_id_cmc,8L

#define SN_id_cmc_encryptedPOP		"id-cmc-encryptedPOP"
#define NID_id_cmc_encryptedPOP		335
#define OBJ_id_cmc_encryptedPOP		OBJ_id_cmc,9L

#define SN_id_cmc_decryptedPOP		"id-cmc-decryptedPOP"
#define NID_id_cmc_decryptedPOP		336
#define OBJ_id_cmc_decryptedPOP		OBJ_id_cmc,10L

#define SN_id_cmc_lraPOPWitness		"id-cmc-lraPOPWitness"
#define NID_id_cmc_lraPOPWitness		337
#define OBJ_id_cmc_lraPOPWitness		OBJ_id_cmc,11L

#define SN_id_cmc_getCert		"id-cmc-getCert"
#define NID_id_cmc_getCert		338
#define OBJ_id_cmc_getCert		OBJ_id_cmc,15L

#define SN_id_cmc_getCRL		"id-cmc-getCRL"
#define NID_id_cmc_getCRL		339
#define OBJ_id_cmc_getCRL		OBJ_id_cmc,16L

#define SN_id_cmc_revokeRequest		"id-cmc-revokeRequest"
#define NID_id_cmc_revokeRequest		340
#define OBJ_id_cmc_revokeRequest		OBJ_id_cmc,17L

#define SN_id_cmc_regInfo		"id-cmc-regInfo"
#define NID_id_cmc_regInfo		341
#define OBJ_id_cmc_regInfo		OBJ_id_cmc,18L

#define SN_id_cmc_responseInfo		"id-cmc-responseInfo"
#define NID_id_cmc_responseInfo		342
#define OBJ_id_cmc_responseInfo		OBJ_id_cmc,19L

#define SN_id_cmc_queryPending		"id-cmc-queryPending"
#define NID_id_cmc_queryPending		343
#define OBJ_id_cmc_queryPending		OBJ_id_cmc,21L

#define SN_id_cmc_popLinkRandom		"id-cmc-popLinkRandom"
#define NID_id_cmc_popLinkRandom		344
#define OBJ_id_cmc_popLinkRandom		OBJ_id_cmc,22L

#define SN_id_cmc_popLinkWitness		"id-cmc-popLinkWitness"
#define NID_id_cmc_popLinkWitness		345
#define OBJ_id_cmc_popLinkWitness		OBJ_id_cmc,23L

#define SN_id_cmc_confirmCertAcceptance		"id-cmc-confirmCertAcceptance"
#define NID_id_cmc_confirmCertAcceptance		346
#define OBJ_id_cmc_confirmCertAcceptance		OBJ_id_cmc,24L

#define SN_id_on_personalData		"id-on-personalData"
#define NID_id_on_personalData		347
#define OBJ_id_on_personalData		OBJ_id_on,1L

#define SN_id_on_permanentIdentifier		"id-on-permanentIdentifier"
#define LN_id_on_permanentIdentifier		"Permanent Identifier"
#define NID_id_on_permanentIdentifier		858
#define OBJ_id_on_permanentIdentifier		OBJ_id_on,3L

#define SN_id_pda_dateOfBirth		"id-pda-dateOfBirth"
#define NID_id_pda_dateOfBirth		348
#define OBJ_id_pda_dateOfBirth		OBJ_id_pda,1L

#define SN_id_pda_placeOfBirth		"id-pda-placeOfBirth"
#define NID_id_pda_placeOfBirth		349
#define OBJ_id_pda_placeOfBirth		OBJ_id_pda,2L

#define SN_id_pda_gender		"id-pda-gender"
#define NID_id_pda_gender		351
#define OBJ_id_pda_gender		OBJ_id_pda,3L

#define SN_id_pda_countryOfCitizenship		"id-pda-countryOfCitizenship"
#define NID_id_pda_countryOfCitizenship		352
#define OBJ_id_pda_countryOfCitizenship		OBJ_id_pda,4L

#define SN_id_pda_countryOfResidence		"id-pda-countryOfResidence"
#define NID_id_pda_countryOfResidence		353
#define OBJ_id_pda_countryOfResidence		OBJ_id_pda,5L

#define SN_id_aca_authenticationInfo		"id-aca-authenticationInfo"
#define NID_id_aca_authenticationInfo		354
#define OBJ_id_aca_authenticationInfo		OBJ_id_aca,1L

#define SN_id_aca_accessIdentity		"id-aca-accessIdentity"
#define NID_id_aca_accessIdentity		355
#define OBJ_id_aca_accessIdentity		OBJ_id_aca,2L

#define SN_id_aca_chargingIdentity		"id-aca-chargingIdentity"
#define NID_id_aca_chargingIdentity		356
#define OBJ_id_aca_chargingIdentity		OBJ_id_aca,3L

#define SN_id_aca_group		"id-aca-group"
#define NID_id_aca_group		357
#define OBJ_id_aca_group		OBJ_id_aca,4L

#define SN_id_aca_role		"id-aca-role"
#define NID_id_aca_role		358
#define OBJ_id_aca_role		OBJ_id_aca,5L

#define SN_id_aca_encAttrs		"id-aca-encAttrs"
#define NID_id_aca_encAttrs		399
#define OBJ_id_aca_encAttrs		OBJ_id_aca,6L

#define SN_id_qcs_pkixQCSyntax_v1		"id-qcs-pkixQCSyntax-v1"
#define NID_id_qcs_pkixQCSyntax_v1		359
#define OBJ_id_qcs_pkixQCSyntax_v1		OBJ_id_qcs,1L

#define SN_id_cct_crs		"id-cct-crs"
#define NID_id_cct_crs		360
#define OBJ_id_cct_crs		OBJ_id_cct,1L

#define SN_id_cct_PKIData		"id-cct-PKIData"
#define NID_id_cct_PKIData		361
#define OBJ_id_cct_PKIData		OBJ_id_cct,2L

#define SN_id_cct_PKIResponse		"id-cct-PKIResponse"
#define NID_id_cct_PKIResponse		362
#define OBJ_id_cct_PKIResponse		OBJ_id_cct,3L

#define SN_id_ppl_anyLanguage		"id-ppl-anyLanguage"
#define LN_id_ppl_anyLanguage		"Any language"
#define NID_id_ppl_anyLanguage		664
#define OBJ_id_ppl_anyLanguage		OBJ_id_ppl,0L

#define SN_id_ppl_inheritAll		"id-ppl-inheritAll"
#define LN_id_ppl_inheritAll		"Inherit all"
#define NID_id_ppl_inheritAll		665
#define OBJ_id_ppl_inheritAll		OBJ_id_ppl,1L

#define SN_Independent		"id-ppl-independent"
#define LN_Independent		"Independent"
#define NID_Independent		667
#define OBJ_Independent		OBJ_id_ppl,2L

#define SN_ad_OCSP		"OCSP"
#define LN_ad_OCSP		"OCSP"
#define NID_ad_OCSP		178
#define OBJ_ad_OCSP		OBJ_id_ad,1L

#define SN_ad_ca_issuers		"caIssuers"
#define LN_ad_ca_issuers		"CA Issuers"
#define NID_ad_ca_issuers		179
#define OBJ_ad_ca_issuers		OBJ_id_ad,2L

#define SN_ad_timeStamping		"ad_timestamping"
#define LN_ad_timeStamping		"AD Time Stamping"
#define NID_ad_timeStamping		363
#define OBJ_ad_timeStamping		OBJ_id_ad,3L

#define SN_ad_dvcs		"AD_DVCS"
#define LN_ad_dvcs		"ad dvcs"
#define NID_ad_dvcs		364
#define OBJ_ad_dvcs		OBJ_id_ad,4L

#define SN_caRepository		"caRepository"
#define LN_caRepository		"CA Repository"
#define NID_caRepository		785
#define OBJ_caRepository		OBJ_id_ad,5L

#define OBJ_id_pkix_OCSP		OBJ_ad_OCSP

#define SN_id_pkix_OCSP_basic		"basicOCSPResponse"
#define LN_id_pkix_OCSP_basic		"Basic OCSP Response"
#define NID_id_pkix_OCSP_basic		365
#define OBJ_id_pkix_OCSP_basic		OBJ_id_pkix_OCSP,1L

#define SN_id_pkix_OCSP_Nonce		"Nonce"
#define LN_id_pkix_OCSP_Nonce		"OCSP Nonce"
#define NID_id_pkix_OCSP_Nonce		366
#define OBJ_id_pkix_OCSP_Nonce		OBJ_id_pkix_OCSP,2L

#define SN_id_pkix_OCSP_CrlID		"CrlID"
#define LN_id_pkix_OCSP_CrlID		"OCSP CRL ID"
#define NID_id_pkix_OCSP_CrlID		367
#define OBJ_id_pkix_OCSP_CrlID		OBJ_id_pkix_OCSP,3L

#define SN_id_pkix_OCSP_acceptableResponses		"acceptableResponses"
#define LN_id_pkix_OCSP_acceptableResponses		"Acceptable OCSP Responses"
#define NID_id_pkix_OCSP_acceptableResponses		368
#define OBJ_id_pkix_OCSP_acceptableResponses		OBJ_id_pkix_OCSP,4L

#define SN_id_pkix_OCSP_noCheck		"noCheck"
#define LN_id_pkix_OCSP_noCheck		"OCSP No Check"
#define NID_id_pkix_OCSP_noCheck		369
#define OBJ_id_pkix_OCSP_noCheck		OBJ_id_pkix_OCSP,5L

#define SN_id_pkix_OCSP_archiveCutoff		"archiveCutoff"
#define LN_id_pkix_OCSP_archiveCutoff		"OCSP Archive Cutoff"
#define NID_id_pkix_OCSP_archiveCutoff		370
#define OBJ_id_pkix_OCSP_archiveCutoff		OBJ_id_pkix_OCSP,6L

#define SN_id_pkix_OCSP_serviceLocator		"serviceLocator"
#define LN_id_pkix_OCSP_serviceLocator		"OCSP Service Locator"
#define NID_id_pkix_OCSP_serviceLocator		371
#define OBJ_id_pkix_OCSP_serviceLocator		OBJ_id_pkix_OCSP,7L

#define SN_id_pkix_OCSP_extendedStatus		"extendedStatus"
#define LN_id_pkix_OCSP_extendedStatus		"Extended OCSP Status"
#define NID_id_pkix_OCSP_extendedStatus		372
#define OBJ_id_pkix_OCSP_extendedStatus		OBJ_id_pkix_OCSP,8L

#define SN_id_pkix_OCSP_valid		"valid"
#define NID_id_pkix_OCSP_valid		373
#define OBJ_id_pkix_OCSP_valid		OBJ_id_pkix_OCSP,9L

#define SN_id_pkix_OCSP_path		"path"
#define NID_id_pkix_OCSP_path		374
#define OBJ_id_pkix_OCSP_path		OBJ_id_pkix_OCSP,10L

#define SN_id_pkix_OCSP_trustRoot		"trustRoot"
#define LN_id_pkix_OCSP_trustRoot		"Trust Root"
#define NID_id_pkix_OCSP_trustRoot		375
#define OBJ_id_pkix_OCSP_trustRoot		OBJ_id_pkix_OCSP,11L

#define SN_algorithm		"algorithm"
#define LN_algorithm		"algorithm"
#define NID_algorithm		376
#define OBJ_algorithm		1L,3L,14L,3L,2L

#define SN_md5WithRSA		"RSA-NP-MD5"
#define LN_md5WithRSA		"md5WithRSA"
#define NID_md5WithRSA		104
#define OBJ_md5WithRSA		OBJ_algorithm,3L

#define SN_des_ecb		"DES-ECB"
#define LN_des_ecb		"des-ecb"
#define NID_des_ecb		29
#define OBJ_des_ecb		OBJ_algorithm,6L

#define SN_des_cbc		"DES-CBC"
#define LN_des_cbc		"des-cbc"
#define NID_des_cbc		31
#define OBJ_des_cbc		OBJ_algorithm,7L

#define SN_des_ofb64		"DES-OFB"
#define LN_des_ofb64		"des-ofb"
#define NID_des_ofb64		45
#define OBJ_des_ofb64		OBJ_algorithm,8L

#define SN_des_cfb64		"DES-CFB"
#define LN_des_cfb64		"des-cfb"
#define NID_des_cfb64		30
#define OBJ_des_cfb64		OBJ_algorithm,9L

#define SN_rsaSignature		"rsaSignature"
#define NID_rsaSignature		377
#define OBJ_rsaSignature		OBJ_algorithm,11L

#define SN_dsa_2		"DSA-old"
#define LN_dsa_2		"dsaEncryption-old"
#define NID_dsa_2		67
#define OBJ_dsa_2		OBJ_algorithm,12L

#define SN_dsaWithSHA		"DSA-SHA"
#define LN_dsaWithSHA		"dsaWithSHA"
#define NID_dsaWithSHA		66
#define OBJ_dsaWithSHA		OBJ_algorithm,13L

#define SN_shaWithRSAEncryption		"RSA-SHA"
#define LN_shaWithRSAEncryption		"shaWithRSAEncryption"
#define NID_shaWithRSAEncryption		42
#define OBJ_shaWithRSAEncryption		OBJ_algorithm,15L

#define SN_des_ede_ecb		"DES-EDE"
#define LN_des_ede_ecb		"des-ede"
#define NID_des_ede_ecb		32
#define OBJ_des_ede_ecb		OBJ_algorithm,17L

#define SN_des_ede3_ecb		"DES-EDE3"
#define LN_des_ede3_ecb		"des-ede3"
#define NID_des_ede3_ecb		33

#define SN_des_ede_cbc		"DES-EDE-CBC"
#define LN_des_ede_cbc		"des-ede-cbc"
#define NID_des_ede_cbc		43

#define SN_des_ede_cfb64		"DES-EDE-CFB"
#define LN_des_ede_cfb64		"des-ede-cfb"
#define NID_des_ede_cfb64		60

#define SN_des_ede3_cfb64		"DES-EDE3-CFB"
#define LN_des_ede3_cfb64		"des-ede3-cfb"
#define NID_des_ede3_cfb64		61

#define SN_des_ede_ofb64		"DES-EDE-OFB"
#define LN_des_ede_ofb64		"des-ede-ofb"
#define NID_des_ede_ofb64		62

#define SN_des_ede3_ofb64		"DES-EDE3-OFB"
#define LN_des_ede3_ofb64		"des-ede3-ofb"
#define NID_des_ede3_ofb64		63

#define SN_desx_cbc		"DESX-CBC"
#define LN_desx_cbc		"desx-cbc"
#define NID_desx_cbc		80

#define SN_sha		"SHA"
#define LN_sha		"sha"
#define NID_sha		41
#define OBJ_sha		OBJ_algorithm,18L

#define SN_sha1		"SHA1"
#define LN_sha1		"sha1"
#define NID_sha1		64
#define OBJ_sha1		OBJ_algorithm,26L

#define SN_dsaWithSHA1_2		"DSA-SHA1-old"
#define LN_dsaWithSHA1_2		"dsaWithSHA1-old"
#define NID_dsaWithSHA1_2		70
#define OBJ_dsaWithSHA1_2		OBJ_algorithm,27L

#define SN_sha1WithRSA		"RSA-SHA1-2"
#define LN_sha1WithRSA		"sha1WithRSA"
#define NID_sha1WithRSA		115
#define OBJ_sha1WithRSA		OBJ_algorithm,29L

#define SN_ripemd160		"RIPEMD160"
#define LN_ripemd160		"ripemd160"
#define NID_ripemd160		117
#define OBJ_ripemd160		1L,3L,36L,3L,2L,1L

#define SN_ripemd160WithRSA		"RSA-RIPEMD160"
#define LN_ripemd160WithRSA		"ripemd160WithRSA"
#define NID_ripemd160WithRSA		119
#define OBJ_ripemd160WithRSA		1L,3L,36L,3L,3L,1L,2L

#define SN_sxnet		"SXNetID"
#define LN_sxnet		"Strong Extranet ID"
#define NID_sxnet		143
#define OBJ_sxnet		1L,3L,101L,1L,4L,1L

#define SN_X500		"X500"
#define LN_X500		"directory services (X.500)"
#define NID_X500		11
#define OBJ_X500		2L,5L

#define SN_X509		"X509"
#define NID_X509		12
#define OBJ_X509		OBJ_X500,4L

#define SN_commonName		"CN"
#define LN_commonName		"commonName"
#define NID_commonName		13
#define OBJ_commonName		OBJ_X509,3L

#define SN_surname		"SN"
#define LN_surname		"surname"
#define NID_surname		100
#define OBJ_surname		OBJ_X509,4L

#define LN_serialNumber		"serialNumber"
#define NID_serialNumber		105
#define OBJ_serialNumber		OBJ_X509,5L

#define SN_countryName		"C"
#define LN_countryName		"countryName"
#define NID_countryName		14
#define OBJ_countryName		OBJ_X509,6L

#define SN_localityName		"L"
#define LN_localityName		"localityName"
#define NID_localityName		15
#define OBJ_localityName		OBJ_X509,7L

#define SN_stateOrProvinceName		"ST"
#define LN_stateOrProvinceName		"stateOrProvinceName"
#define NID_stateOrProvinceName		16
#define OBJ_stateOrProvinceName		OBJ_X509,8L

#define SN_streetAddress		"street"
#define LN_streetAddress		"streetAddress"
#define NID_streetAddress		660
#define OBJ_streetAddress		OBJ_X509,9L

#define SN_organizationName		"O"
#define LN_organizationName		"organizationName"
#define NID_organizationName		17
#define OBJ_organizationName		OBJ_X509,10L

#define SN_organizationalUnitName		"OU"
#define LN_organizationalUnitName		"organizationalUnitName"
#define NID_organizationalUnitName		18
#define OBJ_organizationalUnitName		OBJ_X509,11L

#define SN_title		"title"
#define LN_title		"title"
#define NID_title		106
#define OBJ_title		OBJ_X509,12L

#define LN_description		"description"
#define NID_description		107
#define OBJ_description		OBJ_X509,13L

#define LN_searchGuide		"searchGuide"
#define NID_searchGuide		859
#define OBJ_searchGuide		OBJ_X509,14L

#define LN_businessCategory		"businessCategory"
#define NID_businessCategory		860
#define OBJ_businessCategory		OBJ_X509,15L

#define LN_postalAddress		"postalAddress"
#define NID_postalAddress		861
#define OBJ_postalAddress		OBJ_X509,16L

#define LN_postalCode		"postalCode"
#define NID_postalCode		661
#define OBJ_postalCode		OBJ_X509,17L

#define LN_postOfficeBox		"postOfficeBox"
#define NID_postOfficeBox		862
#define OBJ_postOfficeBox		OBJ_X509,18L

#define LN_physicalDeliveryOfficeName		"physicalDeliveryOfficeName"
#define NID_physicalDeliveryOfficeName		863
#define OBJ_physicalDeliveryOfficeName		OBJ_X509,19L

#define LN_telephoneNumber		"telephoneNumber"
#define NID_telephoneNumber		864
#define OBJ_telephoneNumber		OBJ_X509,20L

#define LN_telexNumber		"telexNumber"
#define NID_telexNumber		865
#define OBJ_telexNumber		OBJ_X509,21L

#define LN_teletexTerminalIdentifier		"teletexTerminalIdentifier"
#define NID_teletexTerminalIdentifier		866
#define OBJ_teletexTerminalIdentifier		OBJ_X509,22L

#define LN_facsimileTelephoneNumber		"facsimileTelephoneNumber"
#define NID_facsimileTelephoneNumber		867
#define OBJ_facsimileTelephoneNumber		OBJ_X509,23L

#define LN_x121Address		"x121Address"
#define NID_x121Address		868
#define OBJ_x121Address		OBJ_X509,24L

#define LN_internationaliSDNNumber		"internationaliSDNNumber"
#define NID_internationaliSDNNumber		869
#define OBJ_internationaliSDNNumber		OBJ_X509,25L

#define LN_registeredAddress		"registeredAddress"
#define NID_registeredAddress		870
#define OBJ_registeredAddress		OBJ_X509,26L

#define LN_destinationIndicator		"destinationIndicator"
#define NID_destinationIndicator		871
#define OBJ_destinationIndicator		OBJ_X509,27L

#define LN_preferredDeliveryMethod		"preferredDeliveryMethod"
#define NID_preferredDeliveryMethod		872
#define OBJ_preferredDeliveryMethod		OBJ_X509,28L

#define LN_presentationAddress		"presentationAddress"
#define NID_presentationAddress		873
#define OBJ_presentationAddress		OBJ_X509,29L

#define LN_supportedApplicationContext		"supportedApplicationContext"
#define NID_supportedApplicationContext		874
#define OBJ_supportedApplicationContext		OBJ_X509,30L

#define SN_member		"member"
#define NID_member		875
#define OBJ_member		OBJ_X509,31L

#define SN_owner		"owner"
#define NID_owner		876
#define OBJ_owner		OBJ_X509,32L

#define LN_roleOccupant		"roleOccupant"
#define NID_roleOccupant		877
#define OBJ_roleOccupant		OBJ_X509,33L

#define SN_seeAlso		"seeAlso"
#define NID_seeAlso		878
#define OBJ_seeAlso		OBJ_X509,34L

#define LN_userPassword		"userPassword"
#define NID_userPassword		879
#define OBJ_userPassword		OBJ_X509,35L

#define LN_userCertificate		"userCertificate"
#define NID_userCertificate		880
#define OBJ_userCertificate		OBJ_X509,36L

#define LN_cACertificate		"cACertificate"
#define NID_cACertificate		881
#define OBJ_cACertificate		OBJ_X509,37L

#define LN_authorityRevocationList		"authorityRevocationList"
#define NID_authorityRevocationList		882
#define OBJ_authorityRevocationList		OBJ_X509,38L

#define LN_certificateRevocationList		"certificateRevocationList"
#define NID_certificateRevocationList		883
#define OBJ_certificateRevocationList		OBJ_X509,39L

#define LN_crossCertificatePair		"crossCertificatePair"
#define NID_crossCertificatePair		884
#define OBJ_crossCertificatePair		OBJ_X509,40L

#define SN_name		"name"
#define LN_name		"name"
#define NID_name		173
#define OBJ_name		OBJ_X509,41L

#define SN_givenName		"GN"
#define LN_givenName		"givenName"
#define NID_givenName		99
#define OBJ_givenName		OBJ_X509,42L

#define SN_initials		"initials"
#define LN_initials		"initials"
#define NID_initials		101
#define OBJ_initials		OBJ_X509,43L

#define LN_generationQualifier		"generationQualifier"
#define NID_generationQualifier		509
#define OBJ_generationQualifier		OBJ_X509,44L

#define LN_x500UniqueIdentifier		"x500UniqueIdentifier"
#define NID_x500UniqueIdentifier		503
#define OBJ_x500UniqueIdentifier		OBJ_X509,45L

#define SN_dnQualifier		"dnQualifier"
#define LN_dnQualifier		"dnQualifier"
#define NID_dnQualifier		174
#define OBJ_dnQualifier		OBJ_X509,46L

#define LN_enhancedSearchGuide		"enhancedSearchGuide"
#define NID_enhancedSearchGuide		885
#define OBJ_enhancedSearchGuide		OBJ_X509,47L

#define LN_protocolInformation		"protocolInformation"
#define NID_protocolInformation		886
#define OBJ_protocolInformation		OBJ_X509,48L

#define LN_distinguishedName		"distinguishedName"
#define NID_distinguishedName		887
#define OBJ_distinguishedName		OBJ_X509,49L

#define LN_uniqueMember		"uniqueMember"
#define NID_uniqueMember		888
#define OBJ_uniqueMember		OBJ_X509,50L

#define LN_houseIdentifier		"houseIdentifier"
#define NID_houseIdentifier		889
#define OBJ_houseIdentifier		OBJ_X509,51L

#define LN_supportedAlgorithms		"supportedAlgorithms"
#define NID_supportedAlgorithms		890
#define OBJ_supportedAlgorithms		OBJ_X509,52L

#define LN_deltaRevocationList		"deltaRevocationList"
#define NID_deltaRevocationList		891
#define OBJ_deltaRevocationList		OBJ_X509,53L

#define SN_dmdName		"dmdName"
#define NID_dmdName		892
#define OBJ_dmdName		OBJ_X509,54L

#define LN_pseudonym		"pseudonym"
#define NID_pseudonym		510
#define OBJ_pseudonym		OBJ_X509,65L

#define SN_role		"role"
#define LN_role		"role"
#define NID_role		400
#define OBJ_role		OBJ_X509,72L

#define SN_X500algorithms		"X500algorithms"
#define LN_X500algorithms		"directory services - algorithms"
#define NID_X500algorithms		378
#define OBJ_X500algorithms		OBJ_X500,8L

#define SN_rsa		"RSA"
#define LN_rsa		"rsa"
#define NID_rsa		19
#define OBJ_rsa		OBJ_X500algorithms,1L,1L

#define SN_mdc2WithRSA		"RSA-MDC2"
#define LN_mdc2WithRSA		"mdc2WithRSA"
#define NID_mdc2WithRSA		96
#define OBJ_mdc2WithRSA		OBJ_X500algorithms,3L,100L

#define SN_mdc2		"MDC2"
#define LN_mdc2		"mdc2"
#define NID_mdc2		95
#define OBJ_mdc2		OBJ_X500algorithms,3L,101L

#define SN_id_ce		"id-ce"
#define NID_id_ce		81
#define OBJ_id_ce		OBJ_X500,29L

#define SN_subject_directory_attributes		"subjectDirectoryAttributes"
#define LN_subject_directory_attributes		"X509v3 Subject Directory Attributes"
#define NID_subject_directory_attributes		769
#define OBJ_subject_directory_attributes		OBJ_id_ce,9L

#define SN_subject_key_identifier		"subjectKeyIdentifier"
#define LN_subject_key_identifier		"X509v3 Subject Key Identifier"
#define NID_subject_key_identifier		82
#define OBJ_subject_key_identifier		OBJ_id_ce,14L

#define SN_key_usage		"keyUsage"
#define LN_key_usage		"X509v3 Key Usage"
#define NID_key_usage		83
#define OBJ_key_usage		OBJ_id_ce,15L

#define SN_private_key_usage_period		"privateKeyUsagePeriod"
#define LN_private_key_usage_period		"X509v3 Private Key Usage Period"
#define NID_private_key_usage_period		84
#define OBJ_private_key_usage_period		OBJ_id_ce,16L

#define SN_subject_alt_name		"subjectAltName"
#define LN_subject_alt_name		"X509v3 Subject Alternative Name"
#define NID_subject_alt_name		85
#define OBJ_subject_alt_name		OBJ_id_ce,17L

#define SN_issuer_alt_name		"issuerAltName"
#define LN_issuer_alt_name		"X509v3 Issuer Alternative Name"
#define NID_issuer_alt_name		86
#define OBJ_issuer_alt_name		OBJ_id_ce,18L

#define SN_basic_constraints		"basicConstraints"
#define LN_basic_constraints		"X509v3 Basic Constraints"
#define NID_basic_constraints		87
#define OBJ_basic_constraints		OBJ_id_ce,19L

#define SN_crl_number		"crlNumber"
#define LN_crl_number		"X509v3 CRL Number"
#define NID_crl_number		88
#define OBJ_crl_number		OBJ_id_ce,20L

#define SN_crl_reason		"CRLReason"
#define LN_crl_reason		"X509v3 CRL Reason Code"
#define NID_crl_reason		141
#define OBJ_crl_reason		OBJ_id_ce,21L

#define SN_invalidity_date		"invalidityDate"
#define LN_invalidity_date		"Invalidity Date"
#define NID_invalidity_date		142
#define OBJ_invalidity_date		OBJ_id_ce,24L

#define SN_delta_crl		"deltaCRL"
#define LN_delta_crl		"X509v3 Delta CRL Indicator"
#define NID_delta_crl		140
#define OBJ_delta_crl		OBJ_id_ce,27L

#define SN_issuing_distribution_point		"issuingDistributionPoint"
#define LN_issuing_distribution_point		"X509v3 Issuing Distrubution Point"
#define NID_issuing_distribution_point		770
#define OBJ_issuing_distribution_point		OBJ_id_ce,28L

#define SN_certificate_issuer		"certificateIssuer"
#define LN_certificate_issuer		"X509v3 Certificate Issuer"
#define NID_certificate_issuer		771
#define OBJ_certificate_issuer		OBJ_id_ce,29L

#define SN_name_constraints		"nameConstraints"
#define LN_name_constraints		"X509v3 Name Constraints"
#define NID_name_constraints		666
#define OBJ_name_constraints		OBJ_id_ce,30L

#define SN_crl_distribution_points		"crlDistributionPoints"
#define LN_crl_distribution_points		"X509v3 CRL Distribution Points"
#define NID_crl_distribution_points		103
#define OBJ_crl_distribution_points		OBJ_id_ce,31L

#define SN_certificate_policies		"certificatePolicies"
#define LN_certificate_policies		"X509v3 Certificate Policies"
#define NID_certificate_policies		89
#define OBJ_certificate_policies		OBJ_id_ce,32L

#define SN_any_policy		"anyPolicy"
#define LN_any_policy		"X509v3 Any Policy"
#define NID_any_policy		746
#define OBJ_any_policy		OBJ_certificate_policies,0L

#define SN_policy_mappings		"policyMappings"
#define LN_policy_mappings		"X509v3 Policy Mappings"
#define NID_policy_mappings		747
#define OBJ_policy_mappings		OBJ_id_ce,33L

#define SN_authority_key_identifier		"authorityKeyIdentifier"
#define LN_authority_key_identifier		"X509v3 Authority Key Identifier"
#define NID_authority_key_identifier		90
#define OBJ_authority_key_identifier		OBJ_id_ce,35L

#define SN_policy_constraints		"policyConstraints"
#define LN_policy_constraints		"X509v3 Policy Constraints"
#define NID_policy_constraints		401
#define OBJ_policy_constraints		OBJ_id_ce,36L

#define SN_ext_key_usage		"extendedKeyUsage"
#define LN_ext_key_usage		"X509v3 Extended Key Usage"
#define NID_ext_key_usage		126
#define OBJ_ext_key_usage		OBJ_id_ce,37L

#define SN_freshest_crl		"freshestCRL"
#define LN_freshest_crl		"X509v3 Freshest CRL"
#define NID_freshest_crl		857
#define OBJ_freshest_crl		OBJ_id_ce,46L

#define SN_inhibit_any_policy		"inhibitAnyPolicy"
#define LN_inhibit_any_policy		"X509v3 Inhibit Any Policy"
#define NID_inhibit_any_policy		748
#define OBJ_inhibit_any_policy		OBJ_id_ce,54L

#define SN_target_information		"targetInformation"
#define LN_target_information		"X509v3 AC Targeting"
#define NID_target_information		402
#define OBJ_target_information		OBJ_id_ce,55L

#define SN_no_rev_avail		"noRevAvail"
#define LN_no_rev_avail		"X509v3 No Revocation Available"
#define NID_no_rev_avail		403
#define OBJ_no_rev_avail		OBJ_id_ce,56L

#define SN_anyExtendedKeyUsage		"anyExtendedKeyUsage"
#define LN_anyExtendedKeyUsage		"Any Extended Key Usage"
#define NID_anyExtendedKeyUsage		910
#define OBJ_anyExtendedKeyUsage		OBJ_ext_key_usage,0L

#define SN_netscape		"Netscape"
#define LN_netscape		"Netscape Communications Corp."
#define NID_netscape		57
#define OBJ_netscape		2L,16L,840L,1L,113730L

#define SN_netscape_cert_extension		"nsCertExt"
#define LN_netscape_cert_extension		"Netscape Certificate Extension"
#define NID_netscape_cert_extension		58
#define OBJ_netscape_cert_extension		OBJ_netscape,1L

#define SN_netscape_data_type		"nsDataType"
#define LN_netscape_data_type		"Netscape Data Type"
#define NID_netscape_data_type		59
#define OBJ_netscape_data_type		OBJ_netscape,2L

#define SN_netscape_cert_type		"nsCertType"
#define LN_netscape_cert_type		"Netscape Cert Type"
#define NID_netscape_cert_type		71
#define OBJ_netscape_cert_type		OBJ_netscape_cert_extension,1L

#define SN_netscape_base_url		"nsBaseUrl"
#define LN_netscape_base_url		"Netscape Base Url"
#define NID_netscape_base_url		72
#define OBJ_netscape_base_url		OBJ_netscape_cert_extension,2L

#define SN_netscape_revocation_url		"nsRevocationUrl"
#define LN_netscape_revocation_url		"Netscape Revocation Url"
#define NID_netscape_revocation_url		73
#define OBJ_netscape_revocation_url		OBJ_netscape_cert_extension,3L

#define SN_netscape_ca_revocation_url		"nsCaRevocationUrl"
#define LN_netscape_ca_revocation_url		"Netscape CA Revocation Url"
#define NID_netscape_ca_revocation_url		74
#define OBJ_netscape_ca_revocation_url		OBJ_netscape_cert_extension,4L

#define SN_netscape_renewal_url		"nsRenewalUrl"
#define LN_netscape_renewal_url		"Netscape Renewal Url"
#define NID_netscape_renewal_url		75
#define OBJ_netscape_renewal_url		OBJ_netscape_cert_extension,7L

#define SN_netscape_ca_policy_url		"nsCaPolicyUrl"
#define LN_netscape_ca_policy_url		"Netscape CA Policy Url"
#define NID_netscape_ca_policy_url		76
#define OBJ_netscape_ca_policy_url		OBJ_netscape_cert_extension,8L

#define SN_netscape_ssl_server_name		"nsSslServerName"
#define LN_netscape_ssl_server_name		"Netscape SSL Server Name"
#define NID_netscape_ssl_server_name		77
#define OBJ_netscape_ssl_server_name		OBJ_netscape_cert_extension,12L

#define SN_netscape_comment		"nsComment"
#define LN_netscape_comment		"Netscape Comment"
#define NID_netscape_comment		78
#define OBJ_netscape_comment		OBJ_netscape_cert_extension,13L

#define SN_netscape_cert_sequence		"nsCertSequence"
#define LN_netscape_cert_sequence		"Netscape Certificate Sequence"
#define NID_netscape_cert_sequence		79
#define OBJ_netscape_cert_sequence		OBJ_netscape_data_type,5L

#define SN_ns_sgc		"nsSGC"
#define LN_ns_sgc		"Netscape Server Gated Crypto"
#define NID_ns_sgc		139
#define OBJ_ns_sgc		OBJ_netscape,4L,1L

#define SN_org		"ORG"
#define LN_org		"org"
#define NID_org		379
#define OBJ_org		OBJ_iso,3L

#define SN_dod		"DOD"
#define LN_dod		"dod"
#define NID_dod		380
#define OBJ_dod		OBJ_org,6L

#define SN_iana		"IANA"
#define LN_iana		"iana"
#define NID_iana		381
#define OBJ_iana		OBJ_dod,1L

#define OBJ_internet		OBJ_iana

#define SN_Directory		"directory"
#define LN_Directory		"Directory"
#define NID_Directory		382
#define OBJ_Directory		OBJ_internet,1L

#define SN_Management		"mgmt"
#define LN_Management		"Management"
#define NID_Management		383
#define OBJ_Management		OBJ_internet,2L

#define SN_Experimental		"experimental"
#define LN_Experimental		"Experimental"
#define NID_Experimental		384
#define OBJ_Experimental		OBJ_internet,3L

#define SN_Private		"private"
#define LN_Private		"Private"
#define NID_Private		385
#define OBJ_Private		OBJ_internet,4L

#define SN_Security		"security"
#define LN_Security		"Security"
#define NID_Security		386
#define OBJ_Security		OBJ_internet,5L

#define SN_SNMPv2		"snmpv2"
#define LN_SNMPv2		"SNMPv2"
#define NID_SNMPv2		387
#define OBJ_SNMPv2		OBJ_internet,6L

#define LN_Mail		"Mail"
#define NID_Mail		388
#define OBJ_Mail		OBJ_internet,7L

#define SN_Enterprises		"enterprises"
#define LN_Enterprises		"Enterprises"
#define NID_Enterprises		389
#define OBJ_Enterprises		OBJ_Private,1L

#define SN_dcObject		"dcobject"
#define LN_dcObject		"dcObject"
#define NID_dcObject		390
#define OBJ_dcObject		OBJ_Enterprises,1466L,344L

#define SN_mime_mhs		"mime-mhs"
#define LN_mime_mhs		"MIME MHS"
#define NID_mime_mhs		504
#define OBJ_mime_mhs		OBJ_Mail,1L

#define SN_mime_mhs_headings		"mime-mhs-headings"
#define LN_mime_mhs_headings		"mime-mhs-headings"
#define NID_mime_mhs_headings		505
#define OBJ_mime_mhs_headings		OBJ_mime_mhs,1L

#define SN_mime_mhs_bodies		"mime-mhs-bodies"
#define LN_mime_mhs_bodies		"mime-mhs-bodies"
#define NID_mime_mhs_bodies		506
#define OBJ_mime_mhs_bodies		OBJ_mime_mhs,2L

#define SN_id_hex_partial_message		"id-hex-partial-message"
#define LN_id_hex_partial_message		"id-hex-partial-message"
#define NID_id_hex_partial_message		507
#define OBJ_id_hex_partial_message		OBJ_mime_mhs_headings,1L

#define SN_id_hex_multipart_message		"id-hex-multipart-message"
#define LN_id_hex_multipart_message		"id-hex-multipart-message"
#define NID_id_hex_multipart_message		508
#define OBJ_id_hex_multipart_message		OBJ_mime_mhs_headings,2L

#define SN_rle_compression		"RLE"
#define LN_rle_compression		"run length compression"
#define NID_rle_compression		124
#define OBJ_rle_compression		1L,1L,1L,1L,666L,1L

#define SN_zlib_compression		"ZLIB"
#define LN_zlib_compression		"zlib compression"
#define NID_zlib_compression		125
#define OBJ_zlib_compression		OBJ_id_smime_alg,8L

#define OBJ_csor		2L,16L,840L,1L,101L,3L

#define OBJ_nistAlgorithms		OBJ_csor,4L

#define OBJ_aes		OBJ_nistAlgorithms,1L

#define SN_aes_128_ecb		"AES-128-ECB"
#define LN_aes_128_ecb		"aes-128-ecb"
#define NID_aes_128_ecb		418
#define OBJ_aes_128_ecb		OBJ_aes,1L

#define SN_aes_128_cbc		"AES-128-CBC"
#define LN_aes_128_cbc		"aes-128-cbc"
#define NID_aes_128_cbc		419
#define OBJ_aes_128_cbc		OBJ_aes,2L

#define SN_aes_128_ofb128		"AES-128-OFB"
#define LN_aes_128_ofb128		"aes-128-ofb"
#define NID_aes_128_ofb128		420
#define OBJ_aes_128_ofb128		OBJ_aes,3L

#define SN_aes_128_cfb128		"AES-128-CFB"
#define LN_aes_128_cfb128		"aes-128-cfb"
#define NID_aes_128_cfb128		421
#define OBJ_aes_128_cfb128		OBJ_aes,4L

#define SN_id_aes128_wrap		"id-aes128-wrap"
#define NID_id_aes128_wrap		788
#define OBJ_id_aes128_wrap		OBJ_aes,5L

#define SN_aes_128_gcm		"id-aes128-GCM"
#define LN_aes_128_gcm		"aes-128-gcm"
#define NID_aes_128_gcm		895
#define OBJ_aes_128_gcm		OBJ_aes,6L

#define SN_aes_128_ccm		"id-aes128-CCM"
#define LN_aes_128_ccm		"aes-128-ccm"
#define NID_aes_128_ccm		896
#define OBJ_aes_128_ccm		OBJ_aes,7L

#define SN_id_aes128_wrap_pad		"id-aes128-wrap-pad"
#define NID_id_aes128_wrap_pad		897
#define OBJ_id_aes128_wrap_pad		OBJ_aes,8L

#define SN_aes_192_ecb		"AES-192-ECB"
#define LN_aes_192_ecb		"aes-192-ecb"
#define NID_aes_192_ecb		422
#define OBJ_aes_192_ecb		OBJ_aes,21L

#define SN_aes_192_cbc		"AES-192-CBC"
#define LN_aes_192_cbc		"aes-192-cbc"
#define NID_aes_192_cbc		423
#define OBJ_aes_192_cbc		OBJ_aes,22L

#define SN_aes_192_ofb128		"AES-192-OFB"
#define LN_aes_192_ofb128		"aes-192-ofb"
#define NID_aes_192_ofb128		424
#define OBJ_aes_192_ofb128		OBJ_aes,23L

#define SN_aes_192_cfb128		"AES-192-CFB"
#define LN_aes_192_cfb128		"aes-192-cfb"
#define NID_aes_192_cfb128		425
#define OBJ_aes_192_cfb128		OBJ_aes,24L

#define SN_id_aes192_wrap		"id-aes192-wrap"
#define NID_id_aes192_wrap		789
#define OBJ_id_aes192_wrap		OBJ_aes,25L

#define SN_aes_192_gcm		"id-aes192-GCM"
#define LN_aes_192_gcm		"aes-192-gcm"
#define NID_aes_192_gcm		898
#define OBJ_aes_192_gcm		OBJ_aes,26L

#define SN_aes_192_ccm		"id-aes192-CCM"
#define LN_aes_192_ccm		"aes-192-ccm"
#define NID_aes_192_ccm		899
#define OBJ_aes_192_ccm		OBJ_aes,27L

#define SN_id_aes192_wrap_pad		"id-aes192-wrap-pad"
#define NID_id_aes192_wrap_pad		900
#define OBJ_id_aes192_wrap_pad		OBJ_aes,28L

#define SN_aes_256_ecb		"AES-256-ECB"
#define LN_aes_256_ecb		"aes-256-ecb"
#define NID_aes_256_ecb		426
#define OBJ_aes_256_ecb		OBJ_aes,41L

#define SN_aes_256_cbc		"AES-256-CBC"
#define LN_aes_256_cbc		"aes-256-cbc"
#define NID_aes_256_cbc		427
#define OBJ_aes_256_cbc		OBJ_aes,42L

#define SN_aes_256_ofb128		"AES-256-OFB"
#define LN_aes_256_ofb128		"aes-256-ofb"
#define NID_aes_256_ofb128		428
#define OBJ_aes_256_ofb128		OBJ_aes,43L

#define SN_aes_256_cfb128		"AES-256-CFB"
#define LN_aes_256_cfb128		"aes-256-cfb"
#define NID_aes_256_cfb128		429
#define OBJ_aes_256_cfb128		OBJ_aes,44L

#define SN_id_aes256_wrap		"id-aes256-wrap"
#define NID_id_aes256_wrap		790
#define OBJ_id_aes256_wrap		OBJ_aes,45L

#define SN_aes_256_gcm		"id-aes256-GCM"
#define LN_aes_256_gcm		"aes-256-gcm"
#define NID_aes_256_gcm		901
#define OBJ_aes_256_gcm		OBJ_aes,46L

#define SN_aes_256_ccm		"id-aes256-CCM"
#define LN_aes_256_ccm		"aes-256-ccm"
#define NID_aes_256_ccm		902
#define OBJ_aes_256_ccm		OBJ_aes,47L

#define SN_id_aes256_wrap_pad		"id-aes256-wrap-pad"
#define NID_id_aes256_wrap_pad		903
#define OBJ_id_aes256_wrap_pad		OBJ_aes,48L

#define SN_aes_128_cfb1		"AES-128-CFB1"
#define LN_aes_128_cfb1		"aes-128-cfb1"
#define NID_aes_128_cfb1		650

#define SN_aes_192_cfb1		"AES-192-CFB1"
#define LN_aes_192_cfb1		"aes-192-cfb1"
#define NID_aes_192_cfb1		651

#define SN_aes_256_cfb1		"AES-256-CFB1"
#define LN_aes_256_cfb1		"aes-256-cfb1"
#define NID_aes_256_cfb1		652

#define SN_aes_128_cfb8		"AES-128-CFB8"
#define LN_aes_128_cfb8		"aes-128-cfb8"
#define NID_aes_128_cfb8		653

#define SN_aes_192_cfb8		"AES-192-CFB8"
#define LN_aes_192_cfb8		"aes-192-cfb8"
#define NID_aes_192_cfb8		654

#define SN_aes_256_cfb8		"AES-256-CFB8"
#define LN_aes_256_cfb8		"aes-256-cfb8"
#define NID_aes_256_cfb8		655

#define SN_aes_128_ctr		"AES-128-CTR"
#define LN_aes_128_ctr		"aes-128-ctr"
#define NID_aes_128_ctr		904

#define SN_aes_192_ctr		"AES-192-CTR"
#define LN_aes_192_ctr		"aes-192-ctr"
#define NID_aes_192_ctr		905

#define SN_aes_256_ctr		"AES-256-CTR"
#define LN_aes_256_ctr		"aes-256-ctr"
#define NID_aes_256_ctr		906

#define SN_aes_128_xts		"AES-128-XTS"
#define LN_aes_128_xts		"aes-128-xts"
#define NID_aes_128_xts		913

#define SN_aes_256_xts		"AES-256-XTS"
#define LN_aes_256_xts		"aes-256-xts"
#define NID_aes_256_xts		914

#define SN_des_cfb1		"DES-CFB1"
#define LN_des_cfb1		"des-cfb1"
#define NID_des_cfb1		656

#define SN_des_cfb8		"DES-CFB8"
#define LN_des_cfb8		"des-cfb8"
#define NID_des_cfb8		657

#define SN_des_ede3_cfb1		"DES-EDE3-CFB1"
#define LN_des_ede3_cfb1		"des-ede3-cfb1"
#define NID_des_ede3_cfb1		658

#define SN_des_ede3_cfb8		"DES-EDE3-CFB8"
#define LN_des_ede3_cfb8		"des-ede3-cfb8"
#define NID_des_ede3_cfb8		659

#define OBJ_nist_hashalgs		OBJ_nistAlgorithms,2L

#define SN_sha256		"SHA256"
#define LN_sha256		"sha256"
#define NID_sha256		672
#define OBJ_sha256		OBJ_nist_hashalgs,1L

#define SN_sha384		"SHA384"
#define LN_sha384		"sha384"
#define NID_sha384		673
#define OBJ_sha384		OBJ_nist_hashalgs,2L

#define SN_sha512		"SHA512"
#define LN_sha512		"sha512"
#define NID_sha512		674
#define OBJ_sha512		OBJ_nist_hashalgs,3L

#define SN_sha224		"SHA224"
#define LN_sha224		"sha224"
#define NID_sha224		675
#define OBJ_sha224		OBJ_nist_hashalgs,4L

#define OBJ_dsa_with_sha2		OBJ_nistAlgorithms,3L

#define SN_dsa_with_SHA224		"dsa_with_SHA224"
#define NID_dsa_with_SHA224		802
#define OBJ_dsa_with_SHA224		OBJ_dsa_with_sha2,1L

#define SN_dsa_with_SHA256		"dsa_with_SHA256"
#define NID_dsa_with_SHA256		803
#define OBJ_dsa_with_SHA256		OBJ_dsa_with_sha2,2L

#define SN_hold_instruction_code		"holdInstructionCode"
#define LN_hold_instruction_code		"Hold Instruction Code"
#define NID_hold_instruction_code		430
#define OBJ_hold_instruction_code		OBJ_id_ce,23L

#define OBJ_holdInstruction		OBJ_X9_57,2L

#define SN_hold_instruction_none		"holdInstructionNone"
#define LN_hold_instruction_none		"Hold Instruction None"
#define NID_hold_instruction_none		431
#define OBJ_hold_instruction_none		OBJ_holdInstruction,1L

#define SN_hold_instruction_call_issuer		"holdInstructionCallIssuer"
#define LN_hold_instruction_call_issuer		"Hold Instruction Call Issuer"
#define NID_hold_instruction_call_issuer		432
#define OBJ_hold_instruction_call_issuer		OBJ_holdInstruction,2L

#define SN_hold_instruction_reject		"holdInstructionReject"
#define LN_hold_instruction_reject		"Hold Instruction Reject"
#define NID_hold_instruction_reject		433
#define OBJ_hold_instruction_reject		OBJ_holdInstruction,3L

#define SN_data		"data"
#define NID_data		434
#define OBJ_data		OBJ_itu_t,9L

#define SN_pss		"pss"
#define NID_pss		435
#define OBJ_pss		OBJ_data,2342L

#define SN_ucl		"ucl"
#define NID_ucl		436
#define OBJ_ucl		OBJ_pss,19200300L

#define SN_pilot		"pilot"
#define NID_pilot		437
#define OBJ_pilot		OBJ_ucl,100L

#define LN_pilotAttributeType		"pilotAttributeType"
#define NID_pilotAttributeType		438
#define OBJ_pilotAttributeType		OBJ_pilot,1L

#define LN_pilotAttributeSyntax		"pilotAttributeSyntax"
#define NID_pilotAttributeSyntax		439
#define OBJ_pilotAttributeSyntax		OBJ_pilot,3L

#define LN_pilotObjectClass		"pilotObjectClass"
#define NID_pilotObjectClass		440
#define OBJ_pilotObjectClass		OBJ_pilot,4L

#define LN_pilotGroups		"pilotGroups"
#define NID_pilotGroups		441
#define OBJ_pilotGroups		OBJ_pilot,10L

#define LN_iA5StringSyntax		"iA5StringSyntax"
#define NID_iA5StringSyntax		442
#define OBJ_iA5StringSyntax		OBJ_pilotAttributeSyntax,4L

#define LN_caseIgnoreIA5StringSyntax		"caseIgnoreIA5StringSyntax"
#define NID_caseIgnoreIA5StringSyntax		443
#define OBJ_caseIgnoreIA5StringSyntax		OBJ_pilotAttributeSyntax,5L

#define LN_pilotObject		"pilotObject"
#define NID_pilotObject		444
#define OBJ_pilotObject		OBJ_pilotObjectClass,3L

#define LN_pilotPerson		"pilotPerson"
#define NID_pilotPerson		445
#define OBJ_pilotPerson		OBJ_pilotObjectClass,4L

#define SN_account		"account"
#define NID_account		446
#define OBJ_account		OBJ_pilotObjectClass,5L

#define SN_document		"document"
#define NID_document		447
#define OBJ_document		OBJ_pilotObjectClass,6L

#define SN_room		"room"
#define NID_room		448
#define OBJ_room		OBJ_pilotObjectClass,7L

#define LN_documentSeries		"documentSeries"
#define NID_documentSeries		449
#define OBJ_documentSeries		OBJ_pilotObjectClass,9L

#define SN_Domain		"domain"
#define LN_Domain		"Domain"
#define NID_Domain		392
#define OBJ_Domain		OBJ_pilotObjectClass,13L

#define LN_rFC822localPart		"rFC822localPart"
#define NID_rFC822localPart		450
#define OBJ_rFC822localPart		OBJ_pilotObjectClass,14L

#define LN_dNSDomain		"dNSDomain"
#define NID_dNSDomain		451
#define OBJ_dNSDomain		OBJ_pilotObjectClass,15L

#define LN_domainRelatedObject		"domainRelatedObject"
#define NID_domainRelatedObject		452
#define OBJ_domainRelatedObject		OBJ_pilotObjectClass,17L

#define LN_friendlyCountry		"friendlyCountry"
#define NID_friendlyCountry		453
#define OBJ_friendlyCountry		OBJ_pilotObjectClass,18L

#define LN_simpleSecurityObject		"simpleSecurityObject"
#define NID_simpleSecurityObject		454
#define OBJ_simpleSecurityObject		OBJ_pilotObjectClass,19L

#define LN_pilotOrganization		"pilotOrganization"
#define NID_pilotOrganization		455
#define OBJ_pilotOrganization		OBJ_pilotObjectClass,20L

#define LN_pilotDSA		"pilotDSA"
#define NID_pilotDSA		456
#define OBJ_pilotDSA		OBJ_pilotObjectClass,21L

#define LN_qualityLabelledData		"qualityLabelledData"
#define NID_qualityLabelledData		457
#define OBJ_qualityLabelledData		OBJ_pilotObjectClass,22L

#define SN_userId		"UID"
#define LN_userId		"userId"
#define NID_userId		458
#define OBJ_userId		OBJ_pilotAttributeType,1L

#define LN_textEncodedORAddress		"textEncodedORAddress"
#define NID_textEncodedORAddress		459
#define OBJ_textEncodedORAddress		OBJ_pilotAttributeType,2L

#define SN_rfc822Mailbox		"mail"
#define LN_rfc822Mailbox		"rfc822Mailbox"
#define NID_rfc822Mailbox		460
#define OBJ_rfc822Mailbox		OBJ_pilotAttributeType,3L

#define SN_info		"info"
#define NID_info		461
#define OBJ_info		OBJ_pilotAttributeType,4L

#define LN_favouriteDrink		"favouriteDrink"
#define NID_favouriteDrink		462
#define OBJ_favouriteDrink		OBJ_pilotAttributeType,5L

#define LN_roomNumber		"roomNumber"
#define NID_roomNumber		463
#define OBJ_roomNumber		OBJ_pilotAttributeType,6L

#define SN_photo		"photo"
#define NID_photo		464
#define OBJ_photo		OBJ_pilotAttributeType,7L

#define LN_userClass		"userClass"
#define NID_userClass		465
#define OBJ_userClass		OBJ_pilotAttributeType,8L

#define SN_host		"host"
#define NID_host		466
#define OBJ_host		OBJ_pilotAttributeType,9L

#define SN_manager		"manager"
#define NID_manager		467
#define OBJ_manager		OBJ_pilotAttributeType,10L

#define LN_documentIdentifier		"documentIdentifier"
#define NID_documentIdentifier		468
#define OBJ_documentIdentifier		OBJ_pilotAttributeType,11L

#define LN_documentTitle		"documentTitle"
#define NID_documentTitle		469
#define OBJ_documentTitle		OBJ_pilotAttributeType,12L

#define LN_documentVersion		"documentVersion"
#define NID_documentVersion		470
#define OBJ_documentVersion		OBJ_pilotAttributeType,13L

#define LN_documentAuthor		"documentAuthor"
#define NID_documentAuthor		471
#define OBJ_documentAuthor		OBJ_pilotAttributeType,14L

#define LN_documentLocation		"documentLocation"
#define NID_documentLocation		472
#define OBJ_documentLocation		OBJ_pilotAttributeType,15L

#define LN_homeTelephoneNumber		"homeTelephoneNumber"
#define NID_homeTelephoneNumber		473
#define OBJ_homeTelephoneNumber		OBJ_pilotAttributeType,20L

#define SN_secretary		"secretary"
#define NID_secretary		474
#define OBJ_secretary		OBJ_pilotAttributeType,21L

#define LN_otherMailbox		"otherMailbox"
#define NID_otherMailbox		475
#define OBJ_otherMailbox		OBJ_pilotAttributeType,22L

#define LN_lastModifiedTime		"lastModifiedTime"
#define NID_lastModifiedTime		476
#define OBJ_lastModifiedTime		OBJ_pilotAttributeType,23L

#define LN_lastModifiedBy		"lastModifiedBy"
#define NID_lastModifiedBy		477
#define OBJ_lastModifiedBy		OBJ_pilotAttributeType,24L

#define SN_domainComponent		"DC"
#define LN_domainComponent		"domainComponent"
#define NID_domainComponent		391
#define OBJ_domainComponent		OBJ_pilotAttributeType,25L

#define LN_aRecord		"aRecord"
#define NID_aRecord		478
#define OBJ_aRecord		OBJ_pilotAttributeType,26L

#define LN_pilotAttributeType27		"pilotAttributeType27"
#define NID_pilotAttributeType27		479
#define OBJ_pilotAttributeType27		OBJ_pilotAttributeType,27L

#define LN_mXRecord		"mXRecord"
#define NID_mXRecord		480
#define OBJ_mXRecord		OBJ_pilotAttributeType,28L

#define LN_nSRecord		"nSRecord"
#define NID_nSRecord		481
#define OBJ_nSRecord		OBJ_pilotAttributeType,29L

#define LN_sOARecord		"sOARecord"
#define NID_sOARecord		482
#define OBJ_sOARecord		OBJ_pilotAttributeType,30L

#define LN_cNAMERecord		"cNAMERecord"
#define NID_cNAMERecord		483
#define OBJ_cNAMERecord		OBJ_pilotAttributeType,31L

#define LN_associatedDomain		"associatedDomain"
#define NID_associatedDomain		484
#define OBJ_associatedDomain		OBJ_pilotAttributeType,37L

#define LN_associatedName		"associatedName"
#define NID_associatedName		485
#define OBJ_associatedName		OBJ_pilotAttributeType,38L

#define LN_homePostalAddress		"homePostalAddress"
#define NID_homePostalAddress		486
#define OBJ_homePostalAddress		OBJ_pilotAttributeType,39L

#define LN_personalTitle		"personalTitle"
#define NID_personalTitle		487
#define OBJ_personalTitle		OBJ_pilotAttributeType,40L

#define LN_mobileTelephoneNumber		"mobileTelephoneNumber"
#define NID_mobileTelephoneNumber		488
#define OBJ_mobileTelephoneNumber		OBJ_pilotAttributeType,41L

#define LN_pagerTelephoneNumber		"pagerTelephoneNumber"
#define NID_pagerTelephoneNumber		489
#define OBJ_pagerTelephoneNumber		OBJ_pilotAttributeType,42L

#define LN_friendlyCountryName		"friendlyCountryName"
#define NID_friendlyCountryName		490
#define OBJ_friendlyCountryName		OBJ_pilotAttributeType,43L

#define LN_organizationalStatus		"organizationalStatus"
#define NID_organizationalStatus		491
#define OBJ_organizationalStatus		OBJ_pilotAttributeType,45L

#define LN_janetMailbox		"janetMailbox"
#define NID_janetMailbox		492
#define OBJ_janetMailbox		OBJ_pilotAttributeType,46L

#define LN_mailPreferenceOption		"mailPreferenceOption"
#define NID_mailPreferenceOption		493
#define OBJ_mailPreferenceOption		OBJ_pilotAttributeType,47L

#define LN_buildingName		"buildingName"
#define NID_buildingName		494
#define OBJ_buildingName		OBJ_pilotAttributeType,48L

#define LN_dSAQuality		"dSAQuality"
#define NID_dSAQuality		495
#define OBJ_dSAQuality		OBJ_pilotAttributeType,49L

#define LN_singleLevelQuality		"singleLevelQuality"
#define NID_singleLevelQuality		496
#define OBJ_singleLevelQuality		OBJ_pilotAttributeType,50L

#define LN_subtreeMinimumQuality		"subtreeMinimumQuality"
#define NID_subtreeMinimumQuality		497
#define OBJ_subtreeMinimumQuality		OBJ_pilotAttributeType,51L

#define LN_subtreeMaximumQuality		"subtreeMaximumQuality"
#define NID_subtreeMaximumQuality		498
#define OBJ_subtreeMaximumQuality		OBJ_pilotAttributeType,52L

#define LN_personalSignature		"personalSignature"
#define NID_personalSignature		499
#define OBJ_personalSignature		OBJ_pilotAttributeType,53L

#define LN_dITRedirect		"dITRedirect"
#define NID_dITRedirect		500
#define OBJ_dITRedirect		OBJ_pilotAttributeType,54L

#define SN_audio		"audio"
#define NID_audio		501
#define OBJ_audio		OBJ_pilotAttributeType,55L

#define LN_documentPublisher		"documentPublisher"
#define NID_documentPublisher		502
#define OBJ_documentPublisher		OBJ_pilotAttributeType,56L

#define SN_id_set		"id-set"
#define LN_id_set		"Secure Electronic Transactions"
#define NID_id_set		512
#define OBJ_id_set		OBJ_international_organizations,42L

#define SN_set_ctype		"set-ctype"
#define LN_set_ctype		"content types"
#define NID_set_ctype		513
#define OBJ_set_ctype		OBJ_id_set,0L

#define SN_set_msgExt		"set-msgExt"
#define LN_set_msgExt		"message extensions"
#define NID_set_msgExt		514
#define OBJ_set_msgExt		OBJ_id_set,1L

#define SN_set_attr		"set-attr"
#define NID_set_attr		515
#define OBJ_set_attr		OBJ_id_set,3L

#define SN_set_policy		"set-policy"
#define NID_set_policy		516
#define OBJ_set_policy		OBJ_id_set,5L

#define SN_set_certExt		"set-certExt"
#define LN_set_certExt		"certificate extensions"
#define NID_set_certExt		517
#define OBJ_set_certExt		OBJ_id_set,7L

#define SN_set_brand		"set-brand"
#define NID_set_brand		518
#define OBJ_set_brand		OBJ_id_set,8L

#define SN_setct_PANData		"setct-PANData"
#define NID_setct_PANData		519
#define OBJ_setct_PANData		OBJ_set_ctype,0L

#define SN_setct_PANToken		"setct-PANToken"
#define NID_setct_PANToken		520
#define OBJ_setct_PANToken		OBJ_set_ctype,1L

#define SN_setct_PANOnly		"setct-PANOnly"
#define NID_setct_PANOnly		521
#define OBJ_setct_PANOnly		OBJ_set_ctype,2L

#define SN_setct_OIData		"setct-OIData"
#define NID_setct_OIData		522
#define OBJ_setct_OIData		OBJ_set_ctype,3L

#define SN_setct_PI		"setct-PI"
#define NID_setct_PI		523
#define OBJ_setct_PI		OBJ_set_ctype,4L

#define SN_setct_PIData		"setct-PIData"
#define NID_setct_PIData		524
#define OBJ_setct_PIData		OBJ_set_ctype,5L

#define SN_setct_PIDataUnsigned		"setct-PIDataUnsigned"
#define NID_setct_PIDataUnsigned		525
#define OBJ_setct_PIDataUnsigned		OBJ_set_ctype,6L

#define SN_setct_HODInput		"setct-HODInput"
#define NID_setct_HODInput		526
#define OBJ_setct_HODInput		OBJ_set_ctype,7L

#define SN_setct_AuthResBaggage		"setct-AuthResBaggage"
#define NID_setct_AuthResBaggage		527
#define OBJ_setct_AuthResBaggage		OBJ_set_ctype,8L

#define SN_setct_AuthRevReqBaggage		"setct-AuthRevReqBaggage"
#define NID_setct_AuthRevReqBaggage		528
#define OBJ_setct_AuthRevReqBaggage		OBJ_set_ctype,9L

#define SN_setct_AuthRevResBaggage		"setct-AuthRevResBaggage"
#define NID_setct_AuthRevResBaggage		529
#define OBJ_setct_AuthRevResBaggage		OBJ_set_ctype,10L

#define SN_setct_CapTokenSeq		"setct-CapTokenSeq"
#define NID_setct_CapTokenSeq		530
#define OBJ_setct_CapTokenSeq		OBJ_set_ctype,11L

#define SN_setct_PInitResData		"setct-PInitResData"
#define NID_setct_PInitResData		531
#define OBJ_setct_PInitResData		OBJ_set_ctype,12L

#define SN_setct_PI_TBS		"setct-PI-TBS"
#define NID_setct_PI_TBS		532
#define OBJ_setct_PI_TBS		OBJ_set_ctype,13L

#define SN_setct_PResData		"setct-PResData"
#define NID_setct_PResData		533
#define OBJ_setct_PResData		OBJ_set_ctype,14L

#define SN_setct_AuthReqTBS		"setct-AuthReqTBS"
#define NID_setct_AuthReqTBS		534
#define OBJ_setct_AuthReqTBS		OBJ_set_ctype,16L

#define SN_setct_AuthResTBS		"setct-AuthResTBS"
#define NID_setct_AuthResTBS		535
#define OBJ_setct_AuthResTBS		OBJ_set_ctype,17L

#define SN_setct_AuthResTBSX		"setct-AuthResTBSX"
#define NID_setct_AuthResTBSX		536
#define OBJ_setct_AuthResTBSX		OBJ_set_ctype,18L

#define SN_setct_AuthTokenTBS		"setct-AuthTokenTBS"
#define NID_setct_AuthTokenTBS		537
#define OBJ_setct_AuthTokenTBS		OBJ_set_ctype,19L

#define SN_setct_CapTokenData		"setct-CapTokenData"
#define NID_setct_CapTokenData		538
#define OBJ_setct_CapTokenData		OBJ_set_ctype,20L

#define SN_setct_CapTokenTBS		"setct-CapTokenTBS"
#define NID_setct_CapTokenTBS		539
#define OBJ_setct_CapTokenTBS		OBJ_set_ctype,21L

#define SN_setct_AcqCardCodeMsg		"setct-AcqCardCodeMsg"
#define NID_setct_AcqCardCodeMsg		540
#define OBJ_setct_AcqCardCodeMsg		OBJ_set_ctype,22L

#define SN_setct_AuthRevReqTBS		"setct-AuthRevReqTBS"
#define NID_setct_AuthRevReqTBS		541
#define OBJ_setct_AuthRevReqTBS		OBJ_set_ctype,23L

#define SN_setct_AuthRevResData		"setct-AuthRevResData"
#define NID_setct_AuthRevResData		542
#define OBJ_setct_AuthRevResData		OBJ_set_ctype,24L

#define SN_setct_AuthRevResTBS		"setct-AuthRevResTBS"
#define NID_setct_AuthRevResTBS		543
#define OBJ_setct_AuthRevResTBS		OBJ_set_ctype,25L

#define SN_setct_CapReqTBS		"setct-CapReqTBS"
#define NID_setct_CapReqTBS		544
#define OBJ_setct_CapReqTBS		OBJ_set_ctype,26L

#define SN_setct_CapReqTBSX		"setct-CapReqTBSX"
#define NID_setct_CapReqTBSX		545
#define OBJ_setct_CapReqTBSX		OBJ_set_ctype,27L

#define SN_setct_CapResData		"setct-CapResData"
#define NID_setct_CapResData		546
#define OBJ_setct_CapResData		OBJ_set_ctype,28L

#define SN_setct_CapRevReqTBS		"setct-CapRevReqTBS"
#define NID_setct_CapRevReqTBS		547
#define OBJ_setct_CapRevReqTBS		OBJ_set_ctype,29L

#define SN_setct_CapRevReqTBSX		"setct-CapRevReqTBSX"
#define NID_setct_CapRevReqTBSX		548
#define OBJ_setct_CapRevReqTBSX		OBJ_set_ctype,30L

#define SN_setct_CapRevResData		"setct-CapRevResData"
#define NID_setct_CapRevResData		549
#define OBJ_setct_CapRevResData		OBJ_set_ctype,31L

#define SN_setct_CredReqTBS		"setct-CredReqTBS"
#define NID_setct_CredReqTBS		550
#define OBJ_setct_CredReqTBS		OBJ_set_ctype,32L

#define SN_setct_CredReqTBSX		"setct-CredReqTBSX"
#define NID_setct_CredReqTBSX		551
#define OBJ_setct_CredReqTBSX		OBJ_set_ctype,33L

#define SN_setct_CredResData		"setct-CredResData"
#define NID_setct_CredResData		552
#define OBJ_setct_CredResData		OBJ_set_ctype,34L

#define SN_setct_CredRevReqTBS		"setct-CredRevReqTBS"
#define NID_setct_CredRevReqTBS		553
#define OBJ_setct_CredRevReqTBS		OBJ_set_ctype,35L

#define SN_setct_CredRevReqTBSX		"setct-CredRevReqTBSX"
#define NID_setct_CredRevReqTBSX		554
#define OBJ_setct_CredRevReqTBSX		OBJ_set_ctype,36L

#define SN_setct_CredRevResData		"setct-CredRevResData"
#define NID_setct_CredRevResData		555
#define OBJ_setct_CredRevResData		OBJ_set_ctype,37L

#define SN_setct_PCertReqData		"setct-PCertReqData"
#define NID_setct_PCertReqData		556
#define OBJ_setct_PCertReqData		OBJ_set_ctype,38L

#define SN_setct_PCertResTBS		"setct-PCertResTBS"
#define NID_setct_PCertResTBS		557
#define OBJ_setct_PCertResTBS		OBJ_set_ctype,39L

#define SN_setct_BatchAdminReqData		"setct-BatchAdminReqData"
#define NID_setct_BatchAdminReqData		558
#define OBJ_setct_BatchAdminReqData		OBJ_set_ctype,40L

#define SN_setct_BatchAdminResData		"setct-BatchAdminResData"
#define NID_setct_BatchAdminResData		559
#define OBJ_setct_BatchAdminResData		OBJ_set_ctype,41L

#define SN_setct_CardCInitResTBS		"setct-CardCInitResTBS"
#define NID_setct_CardCInitResTBS		560
#define OBJ_setct_CardCInitResTBS		OBJ_set_ctype,42L

#define SN_setct_MeAqCInitResTBS		"setct-MeAqCInitResTBS"
#define NID_setct_MeAqCInitResTBS		561
#define OBJ_setct_MeAqCInitResTBS		OBJ_set_ctype,43L

#define SN_setct_RegFormResTBS		"setct-RegFormResTBS"
#define NID_setct_RegFormResTBS		562
#define OBJ_setct_RegFormResTBS		OBJ_set_ctype,44L

#define SN_setct_CertReqData		"setct-CertReqData"
#define NID_setct_CertReqData		563
#define OBJ_setct_CertReqData		OBJ_set_ctype,45L

#define SN_setct_CertReqTBS		"setct-CertReqTBS"
#define NID_setct_CertReqTBS		564
#define OBJ_setct_CertReqTBS		OBJ_set_ctype,46L

#define SN_setct_CertResData		"setct-CertResData"
#define NID_setct_CertResData		565
#define OBJ_setct_CertResData		OBJ_set_ctype,47L

#define SN_setct_CertInqReqTBS		"setct-CertInqReqTBS"
#define NID_setct_CertInqReqTBS		566
#define OBJ_setct_CertInqReqTBS		OBJ_set_ctype,48L

#define SN_setct_ErrorTBS		"setct-ErrorTBS"
#define NID_setct_ErrorTBS		567
#define OBJ_setct_ErrorTBS		OBJ_set_ctype,49L

#define SN_setct_PIDualSignedTBE		"setct-PIDualSignedTBE"
#define NID_setct_PIDualSignedTBE		568
#define OBJ_setct_PIDualSignedTBE		OBJ_set_ctype,50L

#define SN_setct_PIUnsignedTBE		"setct-PIUnsignedTBE"
#define NID_setct_PIUnsignedTBE		569
#define OBJ_setct_PIUnsignedTBE		OBJ_set_ctype,51L

#define SN_setct_AuthReqTBE		"setct-AuthReqTBE"
#define NID_setct_AuthReqTBE		570
#define OBJ_setct_AuthReqTBE		OBJ_set_ctype,52L

#define SN_setct_AuthResTBE		"setct-AuthResTBE"
#define NID_setct_AuthResTBE		571
#define OBJ_setct_AuthResTBE		OBJ_set_ctype,53L

#define SN_setct_AuthResTBEX		"setct-AuthResTBEX"
#define NID_setct_AuthResTBEX		572
#define OBJ_setct_AuthResTBEX		OBJ_set_ctype,54L

#define SN_setct_AuthTokenTBE		"setct-AuthTokenTBE"
#define NID_setct_AuthTokenTBE		573
#define OBJ_setct_AuthTokenTBE		OBJ_set_ctype,55L

#define SN_setct_CapTokenTBE		"setct-CapTokenTBE"
#define NID_setct_CapTokenTBE		574
#define OBJ_setct_CapTokenTBE		OBJ_set_ctype,56L

#define SN_setct_CapTokenTBEX		"setct-CapTokenTBEX"
#define NID_setct_CapTokenTBEX		575
#define OBJ_setct_CapTokenTBEX		OBJ_set_ctype,57L

#define SN_setct_AcqCardCodeMsgTBE		"setct-AcqCardCodeMsgTBE"
#define NID_setct_AcqCardCodeMsgTBE		576
#define OBJ_setct_AcqCardCodeMsgTBE		OBJ_set_ctype,58L

#define SN_setct_AuthRevReqTBE		"setct-AuthRevReqTBE"
#define NID_setct_AuthRevReqTBE		577
#define OBJ_setct_AuthRevReqTBE		OBJ_set_ctype,59L

#define SN_setct_AuthRevResTBE		"setct-AuthRevResTBE"
#define NID_setct_AuthRevResTBE		578
#define OBJ_setct_AuthRevResTBE		OBJ_set_ctype,60L

#define SN_setct_AuthRevResTBEB		"setct-AuthRevResTBEB"
#define NID_setct_AuthRevResTBEB		579
#define OBJ_setct_AuthRevResTBEB		OBJ_set_ctype,61L

#define SN_setct_CapReqTBE		"setct-CapReqTBE"
#define NID_setct_CapReqTBE		580
#define OBJ_setct_CapReqTBE		OBJ_set_ctype,62L

#define SN_setct_CapReqTBEX		"setct-CapReqTBEX"
#define NID_setct_CapReqTBEX		581
#define OBJ_setct_CapReqTBEX		OBJ_set_ctype,63L

#define SN_setct_CapResTBE		"setct-CapResTBE"
#define NID_setct_CapResTBE		582
#define OBJ_setct_CapResTBE		OBJ_set_ctype,64L

#define SN_setct_CapRevReqTBE		"setct-CapRevReqTBE"
#define NID_setct_CapRevReqTBE		583
#define OBJ_setct_CapRevReqTBE		OBJ_set_ctype,65L

#define SN_setct_CapRevReqTBEX		"setct-CapRevReqTBEX"
#define NID_setct_CapRevReqTBEX		584
#define OBJ_setct_CapRevReqTBEX		OBJ_set_ctype,66L

#define SN_setct_CapRevResTBE		"setct-CapRevResTBE"
#define NID_setct_CapRevResTBE		585
#define OBJ_setct_CapRevResTBE		OBJ_set_ctype,67L

#define SN_setct_CredReqTBE		"setct-CredReqTBE"
#define NID_setct_CredReqTBE		586
#define OBJ_setct_CredReqTBE		OBJ_set_ctype,68L

#define SN_setct_CredReqTBEX		"setct-CredReqTBEX"
#define NID_setct_CredReqTBEX		587
#define OBJ_setct_CredReqTBEX		OBJ_set_ctype,69L

#define SN_setct_CredResTBE		"setct-CredResTBE"
#define NID_setct_CredResTBE		588
#define OBJ_setct_CredResTBE		OBJ_set_ctype,70L

#define SN_setct_CredRevReqTBE		"setct-CredRevReqTBE"
#define NID_setct_CredRevReqTBE		589
#define OBJ_setct_CredRevReqTBE		OBJ_set_ctype,71L

#define SN_setct_CredRevReqTBEX		"setct-CredRevReqTBEX"
#define NID_setct_CredRevReqTBEX		590
#define OBJ_setct_CredRevReqTBEX		OBJ_set_ctype,72L

#define SN_setct_CredRevResTBE		"setct-CredRevResTBE"
#define NID_setct_CredRevResTBE		591
#define OBJ_setct_CredRevResTBE		OBJ_set_ctype,73L

#define SN_setct_BatchAdminReqTBE		"setct-BatchAdminReqTBE"
#define NID_setct_BatchAdminReqTBE		592
#define OBJ_setct_BatchAdminReqTBE		OBJ_set_ctype,74L

#define SN_setct_BatchAdminResTBE		"setct-BatchAdminResTBE"
#define NID_setct_BatchAdminResTBE		593
#define OBJ_setct_BatchAdminResTBE		OBJ_set_ctype,75L

#define SN_setct_RegFormReqTBE		"setct-RegFormReqTBE"
#define NID_setct_RegFormReqTBE		594
#define OBJ_setct_RegFormReqTBE		OBJ_set_ctype,76L

#define SN_setct_CertReqTBE		"setct-CertReqTBE"
#define NID_setct_CertReqTBE		595
#define OBJ_setct_CertReqTBE		OBJ_set_ctype,77L

#define SN_setct_CertReqTBEX		"setct-CertReqTBEX"
#define NID_setct_CertReqTBEX		596
#define OBJ_setct_CertReqTBEX		OBJ_set_ctype,78L

#define SN_setct_CertResTBE		"setct-CertResTBE"
#define NID_setct_CertResTBE		597
#define OBJ_setct_CertResTBE		OBJ_set_ctype,79L

#define SN_setct_CRLNotificationTBS		"setct-CRLNotificationTBS"
#define NID_setct_CRLNotificationTBS		598
#define OBJ_setct_CRLNotificationTBS		OBJ_set_ctype,80L

#define SN_setct_CRLNotificationResTBS		"setct-CRLNotificationResTBS"
#define NID_setct_CRLNotificationResTBS		599
#define OBJ_setct_CRLNotificationResTBS		OBJ_set_ctype,81L

#define SN_setct_BCIDistributionTBS		"setct-BCIDistributionTBS"
#define NID_setct_BCIDistributionTBS		600
#define OBJ_setct_BCIDistributionTBS		OBJ_set_ctype,82L

#define SN_setext_genCrypt		"setext-genCrypt"
#define LN_setext_genCrypt		"generic cryptogram"
#define NID_setext_genCrypt		601
#define OBJ_setext_genCrypt		OBJ_set_msgExt,1L

#define SN_setext_miAuth		"setext-miAuth"
#define LN_setext_miAuth		"merchant initiated auth"
#define NID_setext_miAuth		602
#define OBJ_setext_miAuth		OBJ_set_msgExt,3L

#define SN_setext_pinSecure		"setext-pinSecure"
#define NID_setext_pinSecure		603
#define OBJ_setext_pinSecure		OBJ_set_msgExt,4L

#define SN_setext_pinAny		"setext-pinAny"
#define NID_setext_pinAny		604
#define OBJ_setext_pinAny		OBJ_set_msgExt,5L

#define SN_setext_track2		"setext-track2"
#define NID_setext_track2		605
#define OBJ_setext_track2		OBJ_set_msgExt,7L

#define SN_setext_cv		"setext-cv"
#define LN_setext_cv		"additional verification"
#define NID_setext_cv		606
#define OBJ_setext_cv		OBJ_set_msgExt,8L

#define SN_set_policy_root		"set-policy-root"
#define NID_set_policy_root		607
#define OBJ_set_policy_root		OBJ_set_policy,0L

#define SN_setCext_hashedRoot		"setCext-hashedRoot"
#define NID_setCext_hashedRoot		608
#define OBJ_setCext_hashedRoot		OBJ_set_certExt,0L

#define SN_setCext_certType		"setCext-certType"
#define NID_setCext_certType		609
#define OBJ_setCext_certType		OBJ_set_certExt,1L

#define SN_setCext_merchData		"setCext-merchData"
#define NID_setCext_merchData		610
#define OBJ_setCext_merchData		OBJ_set_certExt,2L

#define SN_setCext_cCertRequired		"setCext-cCertRequired"
#define NID_setCext_cCertRequired		611
#define OBJ_setCext_cCertRequired		OBJ_set_certExt,3L

#define SN_setCext_tunneling		"setCext-tunneling"
#define NID_setCext_tunneling		612
#define OBJ_setCext_tunneling		OBJ_set_certExt,4L

#define SN_setCext_setExt		"setCext-setExt"
#define NID_setCext_setExt		613
#define OBJ_setCext_setExt		OBJ_set_certExt,5L

#define SN_setCext_setQualf		"setCext-setQualf"
#define NID_setCext_setQualf		614
#define OBJ_setCext_setQualf		OBJ_set_certExt,6L

#define SN_setCext_PGWYcapabilities		"setCext-PGWYcapabilities"
#define NID_setCext_PGWYcapabilities		615
#define OBJ_setCext_PGWYcapabilities		OBJ_set_certExt,7L

#define SN_setCext_TokenIdentifier		"setCext-TokenIdentifier"
#define NID_setCext_TokenIdentifier		616
#define OBJ_setCext_TokenIdentifier		OBJ_set_certExt,8L

#define SN_setCext_Track2Data		"setCext-Track2Data"
#define NID_setCext_Track2Data		617
#define OBJ_setCext_Track2Data		OBJ_set_certExt,9L

#define SN_setCext_TokenType		"setCext-TokenType"
#define NID_setCext_TokenType		618
#define OBJ_setCext_TokenType		OBJ_set_certExt,10L

#define SN_setCext_IssuerCapabilities		"setCext-IssuerCapabilities"
#define NID_setCext_IssuerCapabilities		619
#define OBJ_setCext_IssuerCapabilities		OBJ_set_certExt,11L

#define SN_setAttr_Cert		"setAttr-Cert"
#define NID_setAttr_Cert		620
#define OBJ_setAttr_Cert		OBJ_set_attr,0L

#define SN_setAttr_PGWYcap		"setAttr-PGWYcap"
#define LN_setAttr_PGWYcap		"payment gateway capabilities"
#define NID_setAttr_PGWYcap		621
#define OBJ_setAttr_PGWYcap		OBJ_set_attr,1L

#define SN_setAttr_TokenType		"setAttr-TokenType"
#define NID_setAttr_TokenType		622
#define OBJ_setAttr_TokenType		OBJ_set_attr,2L

#define SN_setAttr_IssCap		"setAttr-IssCap"
#define LN_setAttr_IssCap		"issuer capabilities"
#define NID_setAttr_IssCap		623
#define OBJ_setAttr_IssCap		OBJ_set_attr,3L

#define SN_set_rootKeyThumb		"set-rootKeyThumb"
#define NID_set_rootKeyThumb		624
#define OBJ_set_rootKeyThumb		OBJ_setAttr_Cert,0L

#define SN_set_addPolicy		"set-addPolicy"
#define NID_set_addPolicy		625
#define OBJ_set_addPolicy		OBJ_setAttr_Cert,1L

#define SN_setAttr_Token_EMV		"setAttr-Token-EMV"
#define NID_setAttr_Token_EMV		626
#define OBJ_setAttr_Token_EMV		OBJ_setAttr_TokenType,1L

#define SN_setAttr_Token_B0Prime		"setAttr-Token-B0Prime"
#define NID_setAttr_Token_B0Prime		627
#define OBJ_setAttr_Token_B0Prime		OBJ_setAttr_TokenType,2L

#define SN_setAttr_IssCap_CVM		"setAttr-IssCap-CVM"
#define NID_setAttr_IssCap_CVM		628
#define OBJ_setAttr_IssCap_CVM		OBJ_setAttr_IssCap,3L

#define SN_setAttr_IssCap_T2		"setAttr-IssCap-T2"
#define NID_setAttr_IssCap_T2		629
#define OBJ_setAttr_IssCap_T2		OBJ_setAttr_IssCap,4L

#define SN_setAttr_IssCap_Sig		"setAttr-IssCap-Sig"
#define NID_setAttr_IssCap_Sig		630
#define OBJ_setAttr_IssCap_Sig		OBJ_setAttr_IssCap,5L

#define SN_setAttr_GenCryptgrm		"setAttr-GenCryptgrm"
#define LN_setAttr_GenCryptgrm		"generate cryptogram"
#define NID_setAttr_GenCryptgrm		631
#define OBJ_setAttr_GenCryptgrm		OBJ_setAttr_IssCap_CVM,1L

#define SN_setAttr_T2Enc		"setAttr-T2Enc"
#define LN_setAttr_T2Enc		"encrypted track 2"
#define NID_setAttr_T2Enc		632
#define OBJ_setAttr_T2Enc		OBJ_setAttr_IssCap_T2,1L

#define SN_setAttr_T2cleartxt		"setAttr-T2cleartxt"
#define LN_setAttr_T2cleartxt		"cleartext track 2"
#define NID_setAttr_T2cleartxt		633
#define OBJ_setAttr_T2cleartxt		OBJ_setAttr_IssCap_T2,2L

#define SN_setAttr_TokICCsig		"setAttr-TokICCsig"
#define LN_setAttr_TokICCsig		"ICC or token signature"
#define NID_setAttr_TokICCsig		634
#define OBJ_setAttr_TokICCsig		OBJ_setAttr_IssCap_Sig,1L

#define SN_setAttr_SecDevSig		"setAttr-SecDevSig"
#define LN_setAttr_SecDevSig		"secure device signature"
#define NID_setAttr_SecDevSig		635
#define OBJ_setAttr_SecDevSig		OBJ_setAttr_IssCap_Sig,2L

#define SN_set_brand_IATA_ATA		"set-brand-IATA-ATA"
#define NID_set_brand_IATA_ATA		636
#define OBJ_set_brand_IATA_ATA		OBJ_set_brand,1L

#define SN_set_brand_Diners		"set-brand-Diners"
#define NID_set_brand_Diners		637
#define OBJ_set_brand_Diners		OBJ_set_brand,30L

#define SN_set_brand_AmericanExpress		"set-brand-AmericanExpress"
#define NID_set_brand_AmericanExpress		638
#define OBJ_set_brand_AmericanExpress		OBJ_set_brand,34L

#define SN_set_brand_JCB		"set-brand-JCB"
#define NID_set_brand_JCB		639
#define OBJ_set_brand_JCB		OBJ_set_brand,35L

#define SN_set_brand_Visa		"set-brand-Visa"
#define NID_set_brand_Visa		640
#define OBJ_set_brand_Visa		OBJ_set_brand,4L

#define SN_set_brand_MasterCard		"set-brand-MasterCard"
#define NID_set_brand_MasterCard		641
#define OBJ_set_brand_MasterCard		OBJ_set_brand,5L

#define SN_set_brand_Novus		"set-brand-Novus"
#define NID_set_brand_Novus		642
#define OBJ_set_brand_Novus		OBJ_set_brand,6011L

#define SN_des_cdmf		"DES-CDMF"
#define LN_des_cdmf		"des-cdmf"
#define NID_des_cdmf		643
#define OBJ_des_cdmf		OBJ_rsadsi,3L,10L

#define SN_rsaOAEPEncryptionSET		"rsaOAEPEncryptionSET"
#define NID_rsaOAEPEncryptionSET		644
#define OBJ_rsaOAEPEncryptionSET		OBJ_rsadsi,1L,1L,6L

#define SN_ipsec3		"Oakley-EC2N-3"
#define LN_ipsec3		"ipsec3"
#define NID_ipsec3		749

#define SN_ipsec4		"Oakley-EC2N-4"
#define LN_ipsec4		"ipsec4"
#define NID_ipsec4		750

#define SN_whirlpool		"whirlpool"
#define NID_whirlpool		804
#define OBJ_whirlpool		OBJ_iso,0L,10118L,3L,0L,55L

#define SN_cryptopro		"cryptopro"
#define NID_cryptopro		805
#define OBJ_cryptopro		OBJ_member_body,643L,2L,2L

#define SN_cryptocom		"cryptocom"
#define NID_cryptocom		806
#define OBJ_cryptocom		OBJ_member_body,643L,2L,9L

#define SN_id_GostR3411_94_with_GostR3410_2001		"id-GostR3411-94-with-GostR3410-2001"
#define LN_id_GostR3411_94_with_GostR3410_2001		"GOST R 34.11-94 with GOST R 34.10-2001"
#define NID_id_GostR3411_94_with_GostR3410_2001		807
#define OBJ_id_GostR3411_94_with_GostR3410_2001		OBJ_cryptopro,3L

#define SN_id_GostR3411_94_with_GostR3410_94		"id-GostR3411-94-with-GostR3410-94"
#define LN_id_GostR3411_94_with_GostR3410_94		"GOST R 34.11-94 with GOST R 34.10-94"
#define NID_id_GostR3411_94_with_GostR3410_94		808
#define OBJ_id_GostR3411_94_with_GostR3410_94		OBJ_cryptopro,4L

#define SN_id_GostR3411_94		"md_gost94"
#define LN_id_GostR3411_94		"GOST R 34.11-94"
#define NID_id_GostR3411_94		809
#define OBJ_id_GostR3411_94		OBJ_cryptopro,9L

#define SN_id_HMACGostR3411_94		"id-HMACGostR3411-94"
#define LN_id_HMACGostR3411_94		"HMAC GOST 34.11-94"
#define NID_id_HMACGostR3411_94		810
#define OBJ_id_HMACGostR3411_94		OBJ_cryptopro,10L

#define SN_id_GostR3410_2001		"gost2001"
#define LN_id_GostR3410_2001		"GOST R 34.10-2001"
#define NID_id_GostR3410_2001		811
#define OBJ_id_GostR3410_2001		OBJ_cryptopro,19L

#define SN_id_GostR3410_94		"gost94"
#define LN_id_GostR3410_94		"GOST R 34.10-94"
#define NID_id_GostR3410_94		812
#define OBJ_id_GostR3410_94		OBJ_cryptopro,20L

#define SN_id_Gost28147_89		"gost89"
#define LN_id_Gost28147_89		"GOST 28147-89"
#define NID_id_Gost28147_89		813
#define OBJ_id_Gost28147_89		OBJ_cryptopro,21L

#define SN_gost89_cnt		"gost89-cnt"
#define NID_gost89_cnt		814

#define SN_id_Gost28147_89_MAC		"gost-mac"
#define LN_id_Gost28147_89_MAC		"GOST 28147-89 MAC"
#define NID_id_Gost28147_89_MAC		815
#define OBJ_id_Gost28147_89_MAC		OBJ_cryptopro,22L

#define SN_id_GostR3411_94_prf		"prf-gostr3411-94"
#define LN_id_GostR3411_94_prf		"GOST R 34.11-94 PRF"
#define NID_id_GostR3411_94_prf		816
#define OBJ_id_GostR3411_94_prf		OBJ_cryptopro,23L

#define SN_id_GostR3410_2001DH		"id-GostR3410-2001DH"
#define LN_id_GostR3410_2001DH		"GOST R 34.10-2001 DH"
#define NID_id_GostR3410_2001DH		817
#define OBJ_id_GostR3410_2001DH		OBJ_cryptopro,98L

#define SN_id_GostR3410_94DH		"id-GostR3410-94DH"
#define LN_id_GostR3410_94DH		"GOST R 34.10-94 DH"
#define NID_id_GostR3410_94DH		818
#define OBJ_id_GostR3410_94DH		OBJ_cryptopro,99L

#define SN_id_Gost28147_89_CryptoPro_KeyMeshing		"id-Gost28147-89-CryptoPro-KeyMeshing"
#define NID_id_Gost28147_89_CryptoPro_KeyMeshing		819
#define OBJ_id_Gost28147_89_CryptoPro_KeyMeshing		OBJ_cryptopro,14L,1L

#define SN_id_Gost28147_89_None_KeyMeshing		"id-Gost28147-89-None-KeyMeshing"
#define NID_id_Gost28147_89_None_KeyMeshing		820
#define OBJ_id_Gost28147_89_None_KeyMeshing		OBJ_cryptopro,14L,0L

#define SN_id_GostR3411_94_TestParamSet		"id-GostR3411-94-TestParamSet"
#define NID_id_GostR3411_94_TestParamSet		821
#define OBJ_id_GostR3411_94_TestParamSet		OBJ_cryptopro,30L,0L

#define SN_id_GostR3411_94_CryptoProParamSet		"id-GostR3411-94-CryptoProParamSet"
#define NID_id_GostR3411_94_CryptoProParamSet		822
#define OBJ_id_GostR3411_94_CryptoProParamSet		OBJ_cryptopro,30L,1L

#define SN_id_Gost28147_89_TestParamSet		"id-Gost28147-89-TestParamSet"
#define NID_id_Gost28147_89_TestParamSet		823
#define OBJ_id_Gost28147_89_TestParamSet		OBJ_cryptopro,31L,0L

#define SN_id_Gost28147_89_CryptoPro_A_ParamSet		"id-Gost28147-89-CryptoPro-A-ParamSet"
#define NID_id_Gost28147_89_CryptoPro_A_ParamSet		824
#define OBJ_id_Gost28147_89_CryptoPro_A_ParamSet		OBJ_cryptopro,31L,1L

#define SN_id_Gost28147_89_CryptoPro_B_ParamSet		"id-Gost28147-89-CryptoPro-B-ParamSet"
#define NID_id_Gost28147_89_CryptoPro_B_ParamSet		825
#define OBJ_id_Gost28147_89_CryptoPro_B_ParamSet		OBJ_cryptopro,31L,2L

#define SN_id_Gost28147_89_CryptoPro_C_ParamSet		"id-Gost28147-89-CryptoPro-C-ParamSet"
#define NID_id_Gost28147_89_CryptoPro_C_ParamSet		826
#define OBJ_id_Gost28147_89_CryptoPro_C_ParamSet		OBJ_cryptopro,31L,3L

#define SN_id_Gost28147_89_CryptoPro_D_ParamSet		"id-Gost28147-89-CryptoPro-D-ParamSet"
#define NID_id_Gost28147_89_CryptoPro_D_ParamSet		827
#define OBJ_id_Gost28147_89_CryptoPro_D_ParamSet		OBJ_cryptopro,31L,4L

#define SN_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet		"id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet"
#define NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet		828
#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet		OBJ_cryptopro,31L,5L

#define SN_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet		"id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet"
#define NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet		829
#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet		OBJ_cryptopro,31L,6L

#define SN_id_Gost28147_89_CryptoPro_RIC_1_ParamSet		"id-Gost28147-89-CryptoPro-RIC-1-ParamSet"
#define NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet		830
#define OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet		OBJ_cryptopro,31L,7L

#define SN_id_GostR3410_94_TestParamSet		"id-GostR3410-94-TestParamSet"
#define NID_id_GostR3410_94_TestParamSet		831
#define OBJ_id_GostR3410_94_TestParamSet		OBJ_cryptopro,32L,0L

#define SN_id_GostR3410_94_CryptoPro_A_ParamSet		"id-GostR3410-94-CryptoPro-A-ParamSet"
#define NID_id_GostR3410_94_CryptoPro_A_ParamSet		832
#define OBJ_id_GostR3410_94_CryptoPro_A_ParamSet		OBJ_cryptopro,32L,2L

#define SN_id_GostR3410_94_CryptoPro_B_ParamSet		"id-GostR3410-94-CryptoPro-B-ParamSet"
#define NID_id_GostR3410_94_CryptoPro_B_ParamSet		833
#define OBJ_id_GostR3410_94_CryptoPro_B_ParamSet		OBJ_cryptopro,32L,3L

#define SN_id_GostR3410_94_CryptoPro_C_ParamSet		"id-GostR3410-94-CryptoPro-C-ParamSet"
#define NID_id_GostR3410_94_CryptoPro_C_ParamSet		834
#define OBJ_id_GostR3410_94_CryptoPro_C_ParamSet		OBJ_cryptopro,32L,4L

#define SN_id_GostR3410_94_CryptoPro_D_ParamSet		"id-GostR3410-94-CryptoPro-D-ParamSet"
#define NID_id_GostR3410_94_CryptoPro_D_ParamSet		835
#define OBJ_id_GostR3410_94_CryptoPro_D_ParamSet		OBJ_cryptopro,32L,5L

#define SN_id_GostR3410_94_CryptoPro_XchA_ParamSet		"id-GostR3410-94-CryptoPro-XchA-ParamSet"
#define NID_id_GostR3410_94_CryptoPro_XchA_ParamSet		836
#define OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet		OBJ_cryptopro,33L,1L

#define SN_id_GostR3410_94_CryptoPro_XchB_ParamSet		"id-GostR3410-94-CryptoPro-XchB-ParamSet"
#define NID_id_GostR3410_94_CryptoPro_XchB_ParamSet		837
#define OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet		OBJ_cryptopro,33L,2L

#define SN_id_GostR3410_94_CryptoPro_XchC_ParamSet		"id-GostR3410-94-CryptoPro-XchC-ParamSet"
#define NID_id_GostR3410_94_CryptoPro_XchC_ParamSet		838
#define OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet		OBJ_cryptopro,33L,3L

#define SN_id_GostR3410_2001_TestParamSet		"id-GostR3410-2001-TestParamSet"
#define NID_id_GostR3410_2001_TestParamSet		839
#define OBJ_id_GostR3410_2001_TestParamSet		OBJ_cryptopro,35L,0L

#define SN_id_GostR3410_2001_CryptoPro_A_ParamSet		"id-GostR3410-2001-CryptoPro-A-ParamSet"
#define NID_id_GostR3410_2001_CryptoPro_A_ParamSet		840
#define OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet		OBJ_cryptopro,35L,1L

#define SN_id_GostR3410_2001_CryptoPro_B_ParamSet		"id-GostR3410-2001-CryptoPro-B-ParamSet"
#define NID_id_GostR3410_2001_CryptoPro_B_ParamSet		841
#define OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet		OBJ_cryptopro,35L,2L

#define SN_id_GostR3410_2001_CryptoPro_C_ParamSet		"id-GostR3410-2001-CryptoPro-C-ParamSet"
#define NID_id_GostR3410_2001_CryptoPro_C_ParamSet		842
#define OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet		OBJ_cryptopro,35L,3L

#define SN_id_GostR3410_2001_CryptoPro_XchA_ParamSet		"id-GostR3410-2001-CryptoPro-XchA-ParamSet"
#define NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet		843
#define OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet		OBJ_cryptopro,36L,0L

#define SN_id_GostR3410_2001_CryptoPro_XchB_ParamSet		"id-GostR3410-2001-CryptoPro-XchB-ParamSet"
#define NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet		844
#define OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet		OBJ_cryptopro,36L,1L

#define SN_id_GostR3410_94_a		"id-GostR3410-94-a"
#define NID_id_GostR3410_94_a		845
#define OBJ_id_GostR3410_94_a		OBJ_id_GostR3410_94,1L

#define SN_id_GostR3410_94_aBis		"id-GostR3410-94-aBis"
#define NID_id_GostR3410_94_aBis		846
#define OBJ_id_GostR3410_94_aBis		OBJ_id_GostR3410_94,2L

#define SN_id_GostR3410_94_b		"id-GostR3410-94-b"
#define NID_id_GostR3410_94_b		847
#define OBJ_id_GostR3410_94_b		OBJ_id_GostR3410_94,3L

#define SN_id_GostR3410_94_bBis		"id-GostR3410-94-bBis"
#define NID_id_GostR3410_94_bBis		848
#define OBJ_id_GostR3410_94_bBis		OBJ_id_GostR3410_94,4L

#define SN_id_Gost28147_89_cc		"id-Gost28147-89-cc"
#define LN_id_Gost28147_89_cc		"GOST 28147-89 Cryptocom ParamSet"
#define NID_id_Gost28147_89_cc		849
#define OBJ_id_Gost28147_89_cc		OBJ_cryptocom,1L,6L,1L

#define SN_id_GostR3410_94_cc		"gost94cc"
#define LN_id_GostR3410_94_cc		"GOST 34.10-94 Cryptocom"
#define NID_id_GostR3410_94_cc		850
#define OBJ_id_GostR3410_94_cc		OBJ_cryptocom,1L,5L,3L

#define SN_id_GostR3410_2001_cc		"gost2001cc"
#define LN_id_GostR3410_2001_cc		"GOST 34.10-2001 Cryptocom"
#define NID_id_GostR3410_2001_cc		851
#define OBJ_id_GostR3410_2001_cc		OBJ_cryptocom,1L,5L,4L

#define SN_id_GostR3411_94_with_GostR3410_94_cc		"id-GostR3411-94-with-GostR3410-94-cc"
#define LN_id_GostR3411_94_with_GostR3410_94_cc		"GOST R 34.11-94 with GOST R 34.10-94 Cryptocom"
#define NID_id_GostR3411_94_with_GostR3410_94_cc		852
#define OBJ_id_GostR3411_94_with_GostR3410_94_cc		OBJ_cryptocom,1L,3L,3L

#define SN_id_GostR3411_94_with_GostR3410_2001_cc		"id-GostR3411-94-with-GostR3410-2001-cc"
#define LN_id_GostR3411_94_with_GostR3410_2001_cc		"GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom"
#define NID_id_GostR3411_94_with_GostR3410_2001_cc		853
#define OBJ_id_GostR3411_94_with_GostR3410_2001_cc		OBJ_cryptocom,1L,3L,4L

#define SN_id_GostR3410_2001_ParamSet_cc		"id-GostR3410-2001-ParamSet-cc"
#define LN_id_GostR3410_2001_ParamSet_cc		"GOST R 3410-2001 Parameter Set Cryptocom"
#define NID_id_GostR3410_2001_ParamSet_cc		854
#define OBJ_id_GostR3410_2001_ParamSet_cc		OBJ_cryptocom,1L,8L,1L

#define SN_camellia_128_cbc		"CAMELLIA-128-CBC"
#define LN_camellia_128_cbc		"camellia-128-cbc"
#define NID_camellia_128_cbc		751
#define OBJ_camellia_128_cbc		1L,2L,392L,200011L,61L,1L,1L,1L,2L

#define SN_camellia_192_cbc		"CAMELLIA-192-CBC"
#define LN_camellia_192_cbc		"camellia-192-cbc"
#define NID_camellia_192_cbc		752
#define OBJ_camellia_192_cbc		1L,2L,392L,200011L,61L,1L,1L,1L,3L

#define SN_camellia_256_cbc		"CAMELLIA-256-CBC"
#define LN_camellia_256_cbc		"camellia-256-cbc"
#define NID_camellia_256_cbc		753
#define OBJ_camellia_256_cbc		1L,2L,392L,200011L,61L,1L,1L,1L,4L

#define SN_id_camellia128_wrap		"id-camellia128-wrap"
#define NID_id_camellia128_wrap		907
#define OBJ_id_camellia128_wrap		1L,2L,392L,200011L,61L,1L,1L,3L,2L

#define SN_id_camellia192_wrap		"id-camellia192-wrap"
#define NID_id_camellia192_wrap		908
#define OBJ_id_camellia192_wrap		1L,2L,392L,200011L,61L,1L,1L,3L,3L

#define SN_id_camellia256_wrap		"id-camellia256-wrap"
#define NID_id_camellia256_wrap		909
#define OBJ_id_camellia256_wrap		1L,2L,392L,200011L,61L,1L,1L,3L,4L

#define OBJ_ntt_ds		0L,3L,4401L,5L

#define OBJ_camellia		OBJ_ntt_ds,3L,1L,9L

#define SN_camellia_128_ecb		"CAMELLIA-128-ECB"
#define LN_camellia_128_ecb		"camellia-128-ecb"
#define NID_camellia_128_ecb		754
#define OBJ_camellia_128_ecb		OBJ_camellia,1L

#define SN_camellia_128_ofb128		"CAMELLIA-128-OFB"
#define LN_camellia_128_ofb128		"camellia-128-ofb"
#define NID_camellia_128_ofb128		766
#define OBJ_camellia_128_ofb128		OBJ_camellia,3L

#define SN_camellia_128_cfb128		"CAMELLIA-128-CFB"
#define LN_camellia_128_cfb128		"camellia-128-cfb"
#define NID_camellia_128_cfb128		757
#define OBJ_camellia_128_cfb128		OBJ_camellia,4L

#define SN_camellia_192_ecb		"CAMELLIA-192-ECB"
#define LN_camellia_192_ecb		"camellia-192-ecb"
#define NID_camellia_192_ecb		755
#define OBJ_camellia_192_ecb		OBJ_camellia,21L

#define SN_camellia_192_ofb128		"CAMELLIA-192-OFB"
#define LN_camellia_192_ofb128		"camellia-192-ofb"
#define NID_camellia_192_ofb128		767
#define OBJ_camellia_192_ofb128		OBJ_camellia,23L

#define SN_camellia_192_cfb128		"CAMELLIA-192-CFB"
#define LN_camellia_192_cfb128		"camellia-192-cfb"
#define NID_camellia_192_cfb128		758
#define OBJ_camellia_192_cfb128		OBJ_camellia,24L

#define SN_camellia_256_ecb		"CAMELLIA-256-ECB"
#define LN_camellia_256_ecb		"camellia-256-ecb"
#define NID_camellia_256_ecb		756
#define OBJ_camellia_256_ecb		OBJ_camellia,41L

#define SN_camellia_256_ofb128		"CAMELLIA-256-OFB"
#define LN_camellia_256_ofb128		"camellia-256-ofb"
#define NID_camellia_256_ofb128		768
#define OBJ_camellia_256_ofb128		OBJ_camellia,43L

#define SN_camellia_256_cfb128		"CAMELLIA-256-CFB"
#define LN_camellia_256_cfb128		"camellia-256-cfb"
#define NID_camellia_256_cfb128		759
#define OBJ_camellia_256_cfb128		OBJ_camellia,44L

#define SN_camellia_128_cfb1		"CAMELLIA-128-CFB1"
#define LN_camellia_128_cfb1		"camellia-128-cfb1"
#define NID_camellia_128_cfb1		760

#define SN_camellia_192_cfb1		"CAMELLIA-192-CFB1"
#define LN_camellia_192_cfb1		"camellia-192-cfb1"
#define NID_camellia_192_cfb1		761

#define SN_camellia_256_cfb1		"CAMELLIA-256-CFB1"
#define LN_camellia_256_cfb1		"camellia-256-cfb1"
#define NID_camellia_256_cfb1		762

#define SN_camellia_128_cfb8		"CAMELLIA-128-CFB8"
#define LN_camellia_128_cfb8		"camellia-128-cfb8"
#define NID_camellia_128_cfb8		763

#define SN_camellia_192_cfb8		"CAMELLIA-192-CFB8"
#define LN_camellia_192_cfb8		"camellia-192-cfb8"
#define NID_camellia_192_cfb8		764

#define SN_camellia_256_cfb8		"CAMELLIA-256-CFB8"
#define LN_camellia_256_cfb8		"camellia-256-cfb8"
#define NID_camellia_256_cfb8		765

#define SN_kisa		"KISA"
#define LN_kisa		"kisa"
#define NID_kisa		773
#define OBJ_kisa		OBJ_member_body,410L,200004L

#define SN_seed_ecb		"SEED-ECB"
#define LN_seed_ecb		"seed-ecb"
#define NID_seed_ecb		776
#define OBJ_seed_ecb		OBJ_kisa,1L,3L

#define SN_seed_cbc		"SEED-CBC"
#define LN_seed_cbc		"seed-cbc"
#define NID_seed_cbc		777
#define OBJ_seed_cbc		OBJ_kisa,1L,4L

#define SN_seed_cfb128		"SEED-CFB"
#define LN_seed_cfb128		"seed-cfb"
#define NID_seed_cfb128		779
#define OBJ_seed_cfb128		OBJ_kisa,1L,5L

#define SN_seed_ofb128		"SEED-OFB"
#define LN_seed_ofb128		"seed-ofb"
#define NID_seed_ofb128		778
#define OBJ_seed_ofb128		OBJ_kisa,1L,6L

#define SN_hmac		"HMAC"
#define LN_hmac		"hmac"
#define NID_hmac		855

#define SN_cmac		"CMAC"
#define LN_cmac		"cmac"
#define NID_cmac		894

#define SN_rc4_hmac_md5		"RC4-HMAC-MD5"
#define LN_rc4_hmac_md5		"rc4-hmac-md5"
#define NID_rc4_hmac_md5		915

#define SN_aes_128_cbc_hmac_sha1		"AES-128-CBC-HMAC-SHA1"
#define LN_aes_128_cbc_hmac_sha1		"aes-128-cbc-hmac-sha1"
#define NID_aes_128_cbc_hmac_sha1		916

#define SN_aes_192_cbc_hmac_sha1		"AES-192-CBC-HMAC-SHA1"
#define LN_aes_192_cbc_hmac_sha1		"aes-192-cbc-hmac-sha1"
#define NID_aes_192_cbc_hmac_sha1		917

#define SN_aes_256_cbc_hmac_sha1		"AES-256-CBC-HMAC-SHA1"
#define LN_aes_256_cbc_hmac_sha1		"aes-256-cbc-hmac-sha1"
#define NID_aes_256_cbc_hmac_sha1		918

#define SN_teletrust		"teletrust"
#define NID_teletrust		920
#define OBJ_teletrust		OBJ_identified_organization,36L

#define SN_brainpool		"brainpool"
#define NID_brainpool		921
#define OBJ_brainpool		OBJ_teletrust,3L,3L,2L,8L,1L

#define SN_brainpoolP160r1		"brainpoolP160r1"
#define NID_brainpoolP160r1		922
#define OBJ_brainpoolP160r1		OBJ_brainpool,1L,1L

#define SN_brainpoolP160t1		"brainpoolP160t1"
#define NID_brainpoolP160t1		923
#define OBJ_brainpoolP160t1		OBJ_brainpool,1L,2L

#define SN_brainpoolP192r1		"brainpoolP192r1"
#define NID_brainpoolP192r1		924
#define OBJ_brainpoolP192r1		OBJ_brainpool,1L,3L

#define SN_brainpoolP192t1		"brainpoolP192t1"
#define NID_brainpoolP192t1		925
#define OBJ_brainpoolP192t1		OBJ_brainpool,1L,4L

#define SN_brainpoolP224r1		"brainpoolP224r1"
#define NID_brainpoolP224r1		926
#define OBJ_brainpoolP224r1		OBJ_brainpool,1L,5L

#define SN_brainpoolP224t1		"brainpoolP224t1"
#define NID_brainpoolP224t1		927
#define OBJ_brainpoolP224t1		OBJ_brainpool,1L,6L

#define SN_brainpoolP256r1		"brainpoolP256r1"
#define NID_brainpoolP256r1		928
#define OBJ_brainpoolP256r1		OBJ_brainpool,1L,7L

#define SN_brainpoolP256t1		"brainpoolP256t1"
#define NID_brainpoolP256t1		929
#define OBJ_brainpoolP256t1		OBJ_brainpool,1L,8L

#define SN_brainpoolP320r1		"brainpoolP320r1"
#define NID_brainpoolP320r1		930
#define OBJ_brainpoolP320r1		OBJ_brainpool,1L,9L

#define SN_brainpoolP320t1		"brainpoolP320t1"
#define NID_brainpoolP320t1		931
#define OBJ_brainpoolP320t1		OBJ_brainpool,1L,10L

#define SN_brainpoolP384r1		"brainpoolP384r1"
#define NID_brainpoolP384r1		932
#define OBJ_brainpoolP384r1		OBJ_brainpool,1L,11L

#define SN_brainpoolP384t1		"brainpoolP384t1"
#define NID_brainpoolP384t1		933
#define OBJ_brainpoolP384t1		OBJ_brainpool,1L,12L

#define SN_brainpoolP512r1		"brainpoolP512r1"
#define NID_brainpoolP512r1		934
#define OBJ_brainpoolP512r1		OBJ_brainpool,1L,13L

#define SN_brainpoolP512t1		"brainpoolP512t1"
#define NID_brainpoolP512t1		935
#define OBJ_brainpoolP512t1		OBJ_brainpool,1L,14L

#define SN_FRP256v1		"FRP256v1"
#define NID_FRP256v1		936
#define OBJ_FRP256v1		1L,2L,250L,1L,223L,101L,256L,1L

#define SN_chacha20		"ChaCha"
#define LN_chacha20		"chacha"
#define NID_chacha20		937

deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/asn1_mac.h0000644000175000017500000003367512360020705021712 0ustar  /* $OpenBSD: asn1_mac.h,v 1.13 2014/06/12 15:49:27 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 *
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 *
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 *
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 *
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_ASN1_MAC_H
#define HEADER_ASN1_MAC_H

#include 

#ifdef  __cplusplus
extern "C" {
#endif

#ifndef ASN1_MAC_ERR_LIB
#define ASN1_MAC_ERR_LIB	ERR_LIB_ASN1
#endif

#define ASN1_MAC_H_err(f,r,line) \
	ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line))

#define M_ASN1_D2I_vars(a,type,func) \
	ASN1_const_CTX c; \
	type ret=NULL; \
	\
	c.pp=(const unsigned char **)pp; \
	c.q= *(const unsigned char **)pp; \
	c.error=ERR_R_NESTED_ASN1_ERROR; \
	if ((a == NULL) || ((*a) == NULL)) \
		{ if ((ret=(type)func()) == NULL) \
			{ c.line=__LINE__; goto err; } } \
	else	ret=(*a);

#define M_ASN1_D2I_Init() \
	c.p= *(const unsigned char **)pp; \
	c.max=(length == 0)?0:(c.p+length);

#define M_ASN1_D2I_Finish_2(a) \
	if (!asn1_const_Finish(&c)) \
		{ c.line=__LINE__; goto err; } \
	*(const unsigned char **)pp=c.p; \
	if (a != NULL) (*a)=ret; \
	return(ret);

#define M_ASN1_D2I_Finish(a,func,e) \
	M_ASN1_D2I_Finish_2(a); \
err:\
	ASN1_MAC_H_err((e),c.error,c.line); \
	asn1_add_error(*(const unsigned char **)pp,(int)(c.q- *pp)); \
	if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \
	return(NULL)

#define M_ASN1_D2I_start_sequence() \
	if (!asn1_GetSequence(&c,&length)) \
		{ c.line=__LINE__; goto err; }
/* Begin reading ASN1 without a surrounding sequence */
#define M_ASN1_D2I_begin() \
	c.slen = length;

/* End reading ASN1 with no check on length */
#define M_ASN1_D2I_Finish_nolen(a, func, e) \
	*pp=c.p; \
	if (a != NULL) (*a)=ret; \
	return(ret); \
err:\
	ASN1_MAC_H_err((e),c.error,c.line); \
	asn1_add_error(*pp,(int)(c.q- *pp)); \
	if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \
	return(NULL)

#define M_ASN1_D2I_end_sequence() \
	(((c.inf&1) == 0)?(c.slen <= 0): \
		(c.eos=ASN1_const_check_infinite_end(&c.p,c.slen)))

/* Don't use this with d2i_ASN1_BOOLEAN() */
#define M_ASN1_D2I_get(b, func) \
	c.q=c.p; \
	if (func(&(b),&c.p,c.slen) == NULL) \
		{c.line=__LINE__; goto err; } \
	c.slen-=(c.p-c.q);

/* Don't use this with d2i_ASN1_BOOLEAN() */
#define M_ASN1_D2I_get_x(type,b,func) \
	c.q=c.p; \
	if (((D2I_OF(type))func)(&(b),&c.p,c.slen) == NULL) \
		{c.line=__LINE__; goto err; } \
	c.slen-=(c.p-c.q);

/* use this instead () */
#define M_ASN1_D2I_get_int(b,func) \
	c.q=c.p; \
	if (func(&(b),&c.p,c.slen) < 0) \
		{c.line=__LINE__; goto err; } \
	c.slen-=(c.p-c.q);

#define M_ASN1_D2I_get_opt(b,func,type) \
	if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \
		== (V_ASN1_UNIVERSAL|(type)))) \
		{ \
		M_ASN1_D2I_get(b,func); \
		}

#define M_ASN1_D2I_get_int_opt(b,func,type) \
	if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \
		== (V_ASN1_UNIVERSAL|(type)))) \
		{ \
		M_ASN1_D2I_get_int(b,func); \
		}

#define M_ASN1_D2I_get_imp(b,func, type) \
	M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \
	c.q=c.p; \
	if (func(&(b),&c.p,c.slen) == NULL) \
		{c.line=__LINE__; M_ASN1_next_prev = _tmp; goto err; } \
	c.slen-=(c.p-c.q);\
	M_ASN1_next_prev=_tmp;

#define M_ASN1_D2I_get_IMP_opt(b,func,tag,type) \
	if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) == \
		(V_ASN1_CONTEXT_SPECIFIC|(tag)))) \
		{ \
		unsigned char _tmp = M_ASN1_next; \
		M_ASN1_D2I_get_imp(b,func, type);\
		}

#define M_ASN1_D2I_get_set_type(type,r,func,free_func) \
		M_ASN1_D2I_get_imp_set_type(type,r,func,free_func, \
			V_ASN1_SET,V_ASN1_UNIVERSAL);

#define M_ASN1_D2I_get_set_opt_type(type,r,func,free_func) \
	if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
		V_ASN1_CONSTRUCTED|V_ASN1_SET)))\
		{ M_ASN1_D2I_get_set_type(type,r,func,free_func); }

#define M_ASN1_I2D_len_SET_opt(a,f) \
	if ((a != NULL) && (sk_num(a) != 0)) \
		M_ASN1_I2D_len_SET(a,f);

#define M_ASN1_I2D_put_SET_opt(a,f) \
	if ((a != NULL) && (sk_num(a) != 0)) \
		M_ASN1_I2D_put_SET(a,f);

#define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \
	if ((a != NULL) && (sk_num(a) != 0)) \
		M_ASN1_I2D_put_SEQUENCE(a,f);

#define M_ASN1_I2D_put_SEQUENCE_opt_type(type,a,f) \
	if ((a != NULL) && (sk_##type##_num(a) != 0)) \
		M_ASN1_I2D_put_SEQUENCE_type(type,a,f);

#define M_ASN1_D2I_get_IMP_set_opt_type(type,b,func,free_func,tag) \
	if ((c.slen != 0) && \
		(M_ASN1_next == \
		(V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\
		{ \
		M_ASN1_D2I_get_imp_set_type(type,b,func,free_func,\
			tag,V_ASN1_CONTEXT_SPECIFIC); \
		}

#define M_ASN1_D2I_get_seq_type(type,r,func,free_func) \
		M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\
					    V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL)

#define M_ASN1_D2I_get_seq_opt_type(type,r,func,free_func) \
	if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
		V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\
		{ M_ASN1_D2I_get_seq_type(type,r,func,free_func); }

#define M_ASN1_D2I_get_IMP_set_type(type,r,func,free_func,x) \
		M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\
			x,V_ASN1_CONTEXT_SPECIFIC);

#define M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,a,b) \
	c.q=c.p; \
	if (d2i_ASN1_SET_OF_##type(&(r),&c.p,c.slen,func,\
				   free_func,a,b) == NULL) \
		{ c.line=__LINE__; goto err; } \
	c.slen-=(c.p-c.q);

#define M_ASN1_D2I_get_set_strings(r,func,a,b) \
	c.q=c.p; \
	if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \
		{ c.line=__LINE__; goto err; } \
	c.slen-=(c.p-c.q);

#define M_ASN1_D2I_get_EXP_opt(r,func,tag) \
	if ((c.slen != 0L) && (M_ASN1_next == \
		(V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \
		{ \
		int Tinf,Ttag,Tclass; \
		long Tlen; \
		\
		c.q=c.p; \
		Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
		if (Tinf & 0x80) \
			{ c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
			c.line=__LINE__; goto err; } \
		if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
					Tlen = c.slen - (c.p - c.q) - 2; \
		if (func(&(r),&c.p,Tlen) == NULL) \
			{ c.line=__LINE__; goto err; } \
		if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
			Tlen = c.slen - (c.p - c.q); \
			if(!ASN1_const_check_infinite_end(&c.p, Tlen)) \
				{ c.error=ERR_R_MISSING_ASN1_EOS; \
				c.line=__LINE__; goto err; } \
		}\
		c.slen-=(c.p-c.q); \
		}

#define M_ASN1_D2I_get_EXP_set_opt_type(type,r,func,free_func,tag,b) \
	if ((c.slen != 0) && (M_ASN1_next == \
		(V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \
		{ \
		int Tinf,Ttag,Tclass; \
		long Tlen; \
		\
		c.q=c.p; \
		Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
		if (Tinf & 0x80) \
			{ c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
			c.line=__LINE__; goto err; } \
		if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
					Tlen = c.slen - (c.p - c.q) - 2; \
		if (d2i_ASN1_SET_OF_##type(&(r),&c.p,Tlen,func, \
			free_func,b,V_ASN1_UNIVERSAL) == NULL) \
			{ c.line=__LINE__; goto err; } \
		if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
			Tlen = c.slen - (c.p - c.q); \
			if(!ASN1_check_infinite_end(&c.p, Tlen)) \
				{ c.error=ERR_R_MISSING_ASN1_EOS; \
				c.line=__LINE__; goto err; } \
		}\
		c.slen-=(c.p-c.q); \
		}

/* BIG UGLY WARNING!  This is so damn ugly I wanna puke.  Unfortunately,
   some macros that use ASN1_const_CTX still insist on writing in the input
   stream.  ARGH!  ARGH!  ARGH!  Let's get rid of this macro package.
   Please?						-- Richard Levitte */
#define M_ASN1_next		(*((unsigned char *)(c.p)))
#define M_ASN1_next_prev	(*((unsigned char *)(c.q)))

/*************************************************/

#define M_ASN1_I2D_vars(a)	int r=0,ret=0; \
				unsigned char *p; \
				if (a == NULL) return(0)

/* Length Macros */
#define M_ASN1_I2D_len(a,f)	ret+=f(a,NULL)
#define M_ASN1_I2D_len_IMP_opt(a,f)	if (a != NULL) M_ASN1_I2D_len(a,f)

#define M_ASN1_I2D_len_SET_type(type,a,f) \
		ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SET, \
					    V_ASN1_UNIVERSAL,IS_SET);

#define M_ASN1_I2D_len_SEQUENCE_type(type,a,f) \
		ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SEQUENCE, \
					    V_ASN1_UNIVERSAL,IS_SEQUENCE)

#define M_ASN1_I2D_len_SEQUENCE_opt(a,f) \
		if ((a != NULL) && (sk_num(a) != 0)) \
			M_ASN1_I2D_len_SEQUENCE(a,f);

#define M_ASN1_I2D_len_SEQUENCE_opt_type(type,a,f) \
		if ((a != NULL) && (sk_##type##_num(a) != 0)) \
			M_ASN1_I2D_len_SEQUENCE_type(type,a,f);

#define M_ASN1_I2D_len_IMP_SET_type(type,a,f,x) \
		ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \
					    V_ASN1_CONTEXT_SPECIFIC,IS_SET);

#define M_ASN1_I2D_len_IMP_SET_opt_type(type,a,f,x) \
		if ((a != NULL) && (sk_##type##_num(a) != 0)) \
			ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \
					       V_ASN1_CONTEXT_SPECIFIC,IS_SET);

#define M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(type,a,f,x) \
		if ((a != NULL) && (sk_##type##_num(a) != 0)) \
			ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \
						    V_ASN1_CONTEXT_SPECIFIC, \
						    IS_SEQUENCE);

#define M_ASN1_I2D_len_EXP_opt(a,f,mtag,v) \
		if (a != NULL)\
			{ \
			v=f(a,NULL); \
			ret+=ASN1_object_size(1,v,mtag); \
			}

#define M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \
		if ((a != NULL) && (sk_##type##_num(a) != 0))\
			{ \
			v=i2d_ASN1_SET_OF_##type(a,NULL,f,tag, \
						 V_ASN1_UNIVERSAL, \
						 IS_SEQUENCE); \
			ret+=ASN1_object_size(1,v,mtag); \
			}

/* Put Macros */
#define M_ASN1_I2D_put(a,f)	f(a,&p)

#define M_ASN1_I2D_put_IMP_opt(a,f,t)	\
		if (a != NULL) \
			{ \
			unsigned char *q=p; \
			f(a,&p); \
			*q=(V_ASN1_CONTEXT_SPECIFIC|t|(*q&V_ASN1_CONSTRUCTED));\
			}

#define M_ASN1_I2D_put_SET_type(type,a,f) \
     i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET)
#define M_ASN1_I2D_put_IMP_SET_type(type,a,f,x) \
     i2d_ASN1_SET_OF_##type(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET)

#define M_ASN1_I2D_put_SEQUENCE_type(type,a,f) \
     i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \
			    IS_SEQUENCE)

#define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \
		if ((a != NULL) && (sk_num(a) != 0)) \
			M_ASN1_I2D_put_SEQUENCE(a,f);

#define M_ASN1_I2D_put_IMP_SET_opt_type(type,a,f,x) \
		if ((a != NULL) && (sk_##type##_num(a) != 0)) \
			{ i2d_ASN1_SET_OF_##type(a,&p,f,x, \
						 V_ASN1_CONTEXT_SPECIFIC, \
						 IS_SET); }

#define M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(type,a,f,x) \
		if ((a != NULL) && (sk_##type##_num(a) != 0)) \
			{ i2d_ASN1_SET_OF_##type(a,&p,f,x, \
						 V_ASN1_CONTEXT_SPECIFIC, \
						 IS_SEQUENCE); }

#define M_ASN1_I2D_put_EXP_opt(a,f,tag,v) \
		if (a != NULL) \
			{ \
			ASN1_put_object(&p,1,v,tag,V_ASN1_CONTEXT_SPECIFIC); \
			f(a,&p); \
			}

#define M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \
		if ((a != NULL) && (sk_##type##_num(a) != 0)) \
			{ \
			ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \
			i2d_ASN1_SET_OF_##type(a,&p,f,tag,V_ASN1_UNIVERSAL, \
					       IS_SEQUENCE); \
			}

#define M_ASN1_I2D_seq_total() \
		r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); \
		if (pp == NULL) return(r); \
		p= *pp; \
		ASN1_put_object(&p,1,ret,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL)

#define M_ASN1_I2D_INF_seq_start(tag,ctx) \
		*(p++)=(V_ASN1_CONSTRUCTED|(tag)|(ctx)); \
		*(p++)=0x80

#define M_ASN1_I2D_INF_seq_end() *(p++)=0x00; *(p++)=0x00

#define M_ASN1_I2D_finish()	*pp=p; \
				return(r);

int asn1_GetSequence(ASN1_const_CTX *c, long *length);
void asn1_add_error(const unsigned char *address, int offset);
#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/des.h0000644000175000017500000002345712360020705021000 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_NEW_DES_H
#define HEADER_NEW_DES_H

#include 

#ifdef OPENSSL_NO_DES
#error DES is disabled.
#endif


#ifdef  __cplusplus
extern "C" {
#endif

typedef unsigned char DES_cblock[8];
typedef /* const */ unsigned char const_DES_cblock[8];
/* With "const", gcc 2.8.1 on Solaris thinks that DES_cblock *
 * and const_DES_cblock * are incompatible pointer types. */

typedef struct DES_ks
    {
    union
	{
	DES_cblock cblock;
	/* make sure things are correct size on machines with
	 * 8 byte longs */
	DES_LONG deslong[2];
	} ks[16];
    } DES_key_schedule;

#define DES_KEY_SZ 	(sizeof(DES_cblock))
#define DES_SCHEDULE_SZ (sizeof(DES_key_schedule))

#define DES_ENCRYPT	1
#define DES_DECRYPT	0

#define DES_CBC_MODE	0
#define DES_PCBC_MODE	1

#define DES_ecb2_encrypt(i,o,k1,k2,e) \
	DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))

#define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
	DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))

#define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
	DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))

#define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
	DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))

extern int DES_check_key;	/* defaults to false */
extern int DES_rw_mode;		/* defaults to DES_PCBC_MODE */

const char *DES_options(void);
void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,
		      DES_key_schedule *ks1,DES_key_schedule *ks2,
		      DES_key_schedule *ks3, int enc);
DES_LONG DES_cbc_cksum(const unsigned char *input,DES_cblock *output,
		       long length,DES_key_schedule *schedule,
		       const_DES_cblock *ivec);
/* DES_cbc_encrypt does not update the IV!  Use DES_ncbc_encrypt instead. */
void DES_cbc_encrypt(const unsigned char *input,unsigned char *output,
		     long length,DES_key_schedule *schedule,DES_cblock *ivec,
		     int enc);
void DES_ncbc_encrypt(const unsigned char *input,unsigned char *output,
		      long length,DES_key_schedule *schedule,DES_cblock *ivec,
		      int enc);
void DES_xcbc_encrypt(const unsigned char *input,unsigned char *output,
		      long length,DES_key_schedule *schedule,DES_cblock *ivec,
		      const_DES_cblock *inw,const_DES_cblock *outw,int enc);
void DES_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
		     long length,DES_key_schedule *schedule,DES_cblock *ivec,
		     int enc);
void DES_ecb_encrypt(const_DES_cblock *input,DES_cblock *output,
		     DES_key_schedule *ks,int enc);

/* 	This is the DES encryption function that gets called by just about
	every other DES routine in the library.  You should not use this
	function except to implement 'modes' of DES.  I say this because the
	functions that call this routine do the conversion from 'char *' to
	long, and this needs to be done to make sure 'non-aligned' memory
	access do not occur.  The characters are loaded 'little endian'.
	Data is a pointer to 2 unsigned long's and ks is the
	DES_key_schedule to use.  enc, is non zero specifies encryption,
	zero if decryption. */
void DES_encrypt1(DES_LONG *data,DES_key_schedule *ks, int enc);

/* 	This functions is the same as DES_encrypt1() except that the DES
	initial permutation (IP) and final permutation (FP) have been left
	out.  As for DES_encrypt1(), you should not use this function.
	It is used by the routines in the library that implement triple DES.
	IP() DES_encrypt2() DES_encrypt2() DES_encrypt2() FP() is the same
	as DES_encrypt1() DES_encrypt1() DES_encrypt1() except faster :-). */
void DES_encrypt2(DES_LONG *data,DES_key_schedule *ks, int enc);

void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,
		  DES_key_schedule *ks2, DES_key_schedule *ks3);
void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
		  DES_key_schedule *ks2, DES_key_schedule *ks3);
void DES_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output, 
			  long length,
			  DES_key_schedule *ks1,DES_key_schedule *ks2,
			  DES_key_schedule *ks3,DES_cblock *ivec,int enc);
void DES_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out,
			   long length,
			   DES_key_schedule *ks1,DES_key_schedule *ks2,
			   DES_key_schedule *ks3,
			   DES_cblock *ivec1,DES_cblock *ivec2,
			   int enc);
void DES_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out,
			    long length,DES_key_schedule *ks1,
			    DES_key_schedule *ks2,DES_key_schedule *ks3,
			    DES_cblock *ivec,int *num,int enc);
void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out,
			  int numbits,long length,DES_key_schedule *ks1,
			  DES_key_schedule *ks2,DES_key_schedule *ks3,
			  DES_cblock *ivec,int enc);
void DES_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out,
			    long length,DES_key_schedule *ks1,
			    DES_key_schedule *ks2,DES_key_schedule *ks3,
			    DES_cblock *ivec,int *num);
#if 0
void DES_xwhite_in2out(const_DES_cblock *DES_key,const_DES_cblock *in_white,
		       DES_cblock *out_white);
#endif

int DES_enc_read(int fd,void *buf,int len,DES_key_schedule *sched,
		 DES_cblock *iv);
int DES_enc_write(int fd,const void *buf,int len,DES_key_schedule *sched,
		  DES_cblock *iv);
char *DES_fcrypt(const char *buf,const char *salt, char *ret);
char *DES_crypt(const char *buf,const char *salt);
void DES_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
		     long length,DES_key_schedule *schedule,DES_cblock *ivec);
void DES_pcbc_encrypt(const unsigned char *input,unsigned char *output,
		      long length,DES_key_schedule *schedule,DES_cblock *ivec,
		      int enc);
DES_LONG DES_quad_cksum(const unsigned char *input,DES_cblock output[],
			long length,int out_count,DES_cblock *seed);
int DES_random_key(DES_cblock *ret);
void DES_set_odd_parity(DES_cblock *key);
int DES_check_key_parity(const_DES_cblock *key);
int DES_is_weak_key(const_DES_cblock *key);
/* DES_set_key (= set_key = DES_key_sched = key_sched) calls
 * DES_set_key_checked if global variable DES_check_key is set,
 * DES_set_key_unchecked otherwise. */
int DES_set_key(const_DES_cblock *key,DES_key_schedule *schedule);
int DES_key_sched(const_DES_cblock *key,DES_key_schedule *schedule);
int DES_set_key_checked(const_DES_cblock *key,DES_key_schedule *schedule);
void DES_set_key_unchecked(const_DES_cblock *key,DES_key_schedule *schedule);
void DES_string_to_key(const char *str,DES_cblock *key);
void DES_string_to_2keys(const char *str,DES_cblock *key1,DES_cblock *key2);
void DES_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length,
		       DES_key_schedule *schedule,DES_cblock *ivec,int *num,
		       int enc);
void DES_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length,
		       DES_key_schedule *schedule,DES_cblock *ivec,int *num);

#define DES_fixup_key_parity DES_set_odd_parity

#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/ripemd.h0000644000175000017500000001025512360020705021475 0ustar  /* $OpenBSD: ripemd.h,v 1.13 2014/06/12 15:49:30 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#include 

#ifndef HEADER_RIPEMD_H
#define HEADER_RIPEMD_H

#include 

#ifdef  __cplusplus
extern "C" {
#endif

#ifdef OPENSSL_NO_RIPEMD
#error RIPEMD is disabled.
#endif

#if defined(__LP32__)
#define RIPEMD160_LONG unsigned long
#elif defined(__ILP64__)
#define RIPEMD160_LONG unsigned long
#define RIPEMD160_LONG_LOG2 3
#else
#define RIPEMD160_LONG unsigned int
#endif

#define RIPEMD160_CBLOCK	64
#define RIPEMD160_LBLOCK	(RIPEMD160_CBLOCK/4)
#define RIPEMD160_DIGEST_LENGTH	20

typedef struct RIPEMD160state_st
	{
	RIPEMD160_LONG A,B,C,D,E;
	RIPEMD160_LONG Nl,Nh;
	RIPEMD160_LONG data[RIPEMD160_LBLOCK];
	unsigned int   num;
	} RIPEMD160_CTX;

int RIPEMD160_Init(RIPEMD160_CTX *c);
int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len);
int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
unsigned char *RIPEMD160(const unsigned char *d, size_t n,
	unsigned char *md);
void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b);
#ifdef  __cplusplus
}
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/ui.h0000644000175000017500000004051612360020705020635 0ustar  /* $OpenBSD: ui.h,v 1.8 2014/06/12 15:49:31 deraadt Exp $ */
/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
 * project 2001.
 */
/* ====================================================================
 * Copyright (c) 2001 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#ifndef HEADER_UI_H
#define HEADER_UI_H

#include 

#ifndef OPENSSL_NO_DEPRECATED
#include 
#endif
#include 
#include 

#ifdef  __cplusplus
extern "C" {
#endif

/* Declared already in ossl_typ.h */
/* typedef struct ui_st UI; */
/* typedef struct ui_method_st UI_METHOD; */


/* All the following functions return -1 or NULL on error and in some cases
   (UI_process()) -2 if interrupted or in some other way cancelled.
   When everything is fine, they return 0, a positive value or a non-NULL
   pointer, all depending on their purpose. */

/* Creators and destructor.   */
UI *UI_new(void);
UI *UI_new_method(const UI_METHOD *method);
void UI_free(UI *ui);

/* The following functions are used to add strings to be printed and prompt
   strings to prompt for data.  The names are UI_{add,dup}__string
   and UI_{add,dup}_input_boolean.

   UI_{add,dup}__string have the following meanings:
	add	add a text or prompt string.  The pointers given to these
		functions are used verbatim, no copying is done.
	dup	make a copy of the text or prompt string, then add the copy
		to the collection of strings in the user interface.
	
		The function is a name for the functionality that the given
		string shall be used for.  It can be one of:
			input	use the string as data prompt.
			verify	use the string as verification prompt.  This
				is used to verify a previous input.
			info	use the string for informational output.
			error	use the string for error output.
   Honestly, there's currently no difference between info and error for the
   moment.

   UI_{add,dup}_input_boolean have the same semantics for "add" and "dup",
   and are typically used when one wants to prompt for a yes/no response.


   All of the functions in this group take a UI and a prompt string.
   The string input and verify addition functions also take a flag argument,
   a buffer for the result to end up with, a minimum input size and a maximum
   input size (the result buffer MUST be large enough to be able to contain
   the maximum number of characters).  Additionally, the verify addition
   functions takes another buffer to compare the result against.
   The boolean input functions take an action description string (which should
   be safe to ignore if the expected user action is obvious, for example with
   a dialog box with an OK button and a Cancel button), a string of acceptable
   characters to mean OK and to mean Cancel.  The two last strings are checked
   to make sure they don't have common characters.  Additionally, the same
   flag argument as for the string input is taken, as well as a result buffer.
   The result buffer is required to be at least one byte long.  Depending on
   the answer, the first character from the OK or the Cancel character strings
   will be stored in the first byte of the result buffer.  No NUL will be
   added, so the result is *not* a string.

   On success, the all return an index of the added information.  That index
   is usefull when retrieving results with UI_get0_result(). */
int UI_add_input_string(UI *ui, const char *prompt, int flags,
    char *result_buf, int minsize, int maxsize);
int UI_dup_input_string(UI *ui, const char *prompt, int flags,
    char *result_buf, int minsize, int maxsize);
int UI_add_verify_string(UI *ui, const char *prompt, int flags,
    char *result_buf, int minsize, int maxsize, const char *test_buf);
int UI_dup_verify_string(UI *ui, const char *prompt, int flags,
    char *result_buf, int minsize, int maxsize, const char *test_buf);
int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
    const char *ok_chars, const char *cancel_chars,
    int flags, char *result_buf);
int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
    const char *ok_chars, const char *cancel_chars,
    int flags, char *result_buf);
int UI_add_info_string(UI *ui, const char *text);
int UI_dup_info_string(UI *ui, const char *text);
int UI_add_error_string(UI *ui, const char *text);
int UI_dup_error_string(UI *ui, const char *text);

/* These are the possible flags.  They can be or'ed together. */
/* Use to have echoing of input */
#define UI_INPUT_FLAG_ECHO		0x01
/* Use a default password.  Where that password is found is completely
   up to the application, it might for example be in the user data set
   with UI_add_user_data().  It is not recommended to have more than
   one input in each UI being marked with this flag, or the application
   might get confused. */
#define UI_INPUT_FLAG_DEFAULT_PWD	0x02

/* The user of these routines may want to define flags of their own.  The core
   UI won't look at those, but will pass them on to the method routines.  They
   must use higher bits so they don't get confused with the UI bits above.
   UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use.  A good
   example of use is this:

	#define MY_UI_FLAG1	(0x01 << UI_INPUT_FLAG_USER_BASE)

*/
#define UI_INPUT_FLAG_USER_BASE	16


/* The following function helps construct a prompt.  object_desc is a
   textual short description of the object, for example "pass phrase",
   and object_name is the name of the object (might be a card name or
   a file name.
   The returned string shall always be allocated on the heap with
   malloc(), and need to be free'd with free().

   If the ui_method doesn't contain a pointer to a user-defined prompt
   constructor, a default string is built, looking like this:

	"Enter {object_desc} for {object_name}:"

   So, if object_desc has the value "pass phrase" and object_name has
   the value "foo.key", the resulting string is:

	"Enter pass phrase for foo.key:"
*/
char *UI_construct_prompt(UI *ui_method, const char *object_desc,
    const char *object_name);


/* The following function is used to store a pointer to user-specific data.
   Any previous such pointer will be returned and replaced.

   For callback purposes, this function makes a lot more sense than using
   ex_data, since the latter requires that different parts of OpenSSL or
   applications share the same ex_data index.

   Note that the UI_OpenSSL() method completely ignores the user data.
   Other methods may not, however.  */
void *UI_add_user_data(UI *ui, void *user_data);
/* We need a user data retrieving function as well.  */
void *UI_get0_user_data(UI *ui);

/* Return the result associated with a prompt given with the index i. */
const char *UI_get0_result(UI *ui, int i);

/* When all strings have been added, process the whole thing. */
int UI_process(UI *ui);

/* Give a user interface parametrised control commands.  This can be used to
   send down an integer, a data pointer or a function pointer, as well as
   be used to get information from a UI. */
int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)(void));

/* The commands */
/* Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the
   OpenSSL error stack before printing any info or added error messages and
   before any prompting. */
#define UI_CTRL_PRINT_ERRORS		1
/* Check if a UI_process() is possible to do again with the same instance of
   a user interface.  This makes UI_ctrl() return 1 if it is redoable, and 0
   if not. */
#define UI_CTRL_IS_REDOABLE		2


/* Some methods may use extra data */
#define UI_set_app_data(s,arg)         UI_set_ex_data(s,0,arg)
#define UI_get_app_data(s)             UI_get_ex_data(s,0)
int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
    CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
int UI_set_ex_data(UI *r, int idx, void *arg);
void *UI_get_ex_data(UI *r, int idx);

/* Use specific methods instead of the built-in one */
void UI_set_default_method(const UI_METHOD *meth);
const UI_METHOD *UI_get_default_method(void);
const UI_METHOD *UI_get_method(UI *ui);
const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth);

/* The method with all the built-in thingies */
UI_METHOD *UI_OpenSSL(void);


/* ---------- For method writers ---------- */
/* A method contains a number of functions that implement the low level
   of the User Interface.  The functions are:

	an opener	This function starts a session, maybe by opening
			a channel to a tty, or by opening a window.
	a writer	This function is called to write a given string,
			maybe to the tty, maybe as a field label in a
			window.
	a flusher	This function is called to flush everything that
			has been output so far.  It can be used to actually
			display a dialog box after it has been built.
	a reader	This function is called to read a given prompt,
			maybe from the tty, maybe from a field in a
			window.  Note that it's called wth all string
			structures, not only the prompt ones, so it must
			check such things itself.
	a closer	This function closes the session, maybe by closing
			the channel to the tty, or closing the window.

   All these functions are expected to return:

	0	on error.
	1	on success.
	-1	on out-of-band events, for example if some prompting has
		been canceled (by pressing Ctrl-C, for example).  This is
		only checked when returned by the flusher or the reader.

   The way this is used, the opener is first called, then the writer for all
   strings, then the flusher, then the reader for all strings and finally the
   closer.  Note that if you want to prompt from a terminal or other command
   line interface, the best is to have the reader also write the prompts
   instead of having the writer do it.  If you want to prompt from a dialog
   box, the writer can be used to build up the contents of the box, and the
   flusher to actually display the box and run the event loop until all data
   has been given, after which the reader only grabs the given data and puts
   them back into the UI strings.

   All method functions take a UI as argument.  Additionally, the writer and
   the reader take a UI_STRING.
*/

/* The UI_STRING type is the data structure that contains all the needed info
   about a string or a prompt, including test data for a verification prompt.
*/
typedef struct ui_string_st UI_STRING;
DECLARE_STACK_OF(UI_STRING)

/* The different types of strings that are currently supported.
   This is only needed by method authors. */
enum UI_string_types {
	UIT_NONE = 0,
	UIT_PROMPT,		/* Prompt for a string */
	UIT_VERIFY,		/* Prompt for a string and verify */
	UIT_BOOLEAN,		/* Prompt for a yes/no response */
	UIT_INFO,		/* Send info to the user */
	UIT_ERROR		/* Send an error message to the user */
};

/* Create and manipulate methods */
UI_METHOD *UI_create_method(char *name);
void UI_destroy_method(UI_METHOD *ui_method);
int UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui));
int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis));
int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui));
int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis));
int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui));
int UI_method_set_prompt_constructor(UI_METHOD *method, char *(*prompt_constructor)(UI* ui, const char* object_desc, const char* object_name));
int (*UI_method_get_opener(UI_METHOD *method))(UI*);
int (*UI_method_get_writer(UI_METHOD *method))(UI*, UI_STRING*);
int (*UI_method_get_flusher(UI_METHOD *method))(UI*);
int (*UI_method_get_reader(UI_METHOD *method))(UI*, UI_STRING*);
int (*UI_method_get_closer(UI_METHOD *method))(UI*);
char * (*UI_method_get_prompt_constructor(UI_METHOD *method))(UI*, const char*, const char*);

/* The following functions are helpers for method writers to access relevant
   data from a UI_STRING. */

/* Return type of the UI_STRING */
enum UI_string_types UI_get_string_type(UI_STRING *uis);
/* Return input flags of the UI_STRING */
int UI_get_input_flags(UI_STRING *uis);
/* Return the actual string to output (the prompt, info or error) */
const char *UI_get0_output_string(UI_STRING *uis);
/* Return the optional action string to output (the boolean promtp instruction) */
const char *UI_get0_action_string(UI_STRING *uis);
/* Return the result of a prompt */
const char *UI_get0_result_string(UI_STRING *uis);
/* Return the string to test the result against.  Only useful with verifies. */
const char *UI_get0_test_string(UI_STRING *uis);
/* Return the required minimum size of the result */
int UI_get_result_minsize(UI_STRING *uis);
/* Return the required maximum size of the result */
int UI_get_result_maxsize(UI_STRING *uis);
/* Set the result of a UI_STRING. */
int UI_set_result(UI *ui, UI_STRING *uis, const char *result);


/* A couple of popular utility functions */
int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, int verify);
int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, int verify);


/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_UI_strings(void);

/* Error codes for the UI functions. */

/* Function codes. */
#define UI_F_GENERAL_ALLOCATE_BOOLEAN			 108
#define UI_F_GENERAL_ALLOCATE_PROMPT			 109
#define UI_F_GENERAL_ALLOCATE_STRING			 100
#define UI_F_UI_CTRL					 111
#define UI_F_UI_DUP_ERROR_STRING			 101
#define UI_F_UI_DUP_INFO_STRING				 102
#define UI_F_UI_DUP_INPUT_BOOLEAN			 110
#define UI_F_UI_DUP_INPUT_STRING			 103
#define UI_F_UI_DUP_VERIFY_STRING			 106
#define UI_F_UI_GET0_RESULT				 107
#define UI_F_UI_NEW_METHOD				 104
#define UI_F_UI_SET_RESULT				 105

/* Reason codes. */
#define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS		 104
#define UI_R_INDEX_TOO_LARGE				 102
#define UI_R_INDEX_TOO_SMALL				 103
#define UI_R_NO_RESULT_BUFFER				 105
#define UI_R_RESULT_TOO_LARGE				 100
#define UI_R_RESULT_TOO_SMALL				 101
#define UI_R_UNKNOWN_CONTROL_COMMAND			 106

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/x509_vfy.h0000644000175000017500000005352212360020705021612 0ustar  /* $OpenBSD: x509_vfy.h,v 1.12 2014/06/12 15:49:31 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */

#ifndef HEADER_X509_H
#include 
/* openssl/x509.h ends up #include-ing this file at about the only
 * appropriate moment. */
#endif

#ifndef HEADER_X509_VFY_H
#define HEADER_X509_VFY_H

#include 

#ifndef OPENSSL_NO_LHASH
#include 
#endif
#include 
#include 

#ifdef  __cplusplus
extern "C" {
#endif

#if 0
/* Outer object */
typedef struct x509_hash_dir_st
	{
	int num_dirs;
	char **dirs;
	int *dirs_type;
	int num_dirs_alloced;
	} X509_HASH_DIR_CTX;
#endif

typedef struct x509_file_st
	{
	int num_paths;	/* number of paths to files or directories */
	int num_alloced;
	char **paths;	/* the list of paths or directories */
	int *path_type;
	} X509_CERT_FILE_CTX;

/*******************************/
/*
SSL_CTX -> X509_STORE    
		-> X509_LOOKUP
			->X509_LOOKUP_METHOD
		-> X509_LOOKUP
			->X509_LOOKUP_METHOD
 
SSL	-> X509_STORE_CTX
		->X509_STORE    

The X509_STORE holds the tables etc for verification stuff.
A X509_STORE_CTX is used while validating a single certificate.
The X509_STORE has X509_LOOKUPs for looking up certs.
The X509_STORE then calls a function to actually verify the
certificate chain.
*/

#define X509_LU_RETRY		-1
#define X509_LU_FAIL		0
#define X509_LU_X509		1
#define X509_LU_CRL		2
#define X509_LU_PKEY		3

typedef struct x509_object_st
	{
	/* one of the above types */
	int type;
	union	{
		char *ptr;
		X509 *x509;
		X509_CRL *crl;
		EVP_PKEY *pkey;
		} data;
	} X509_OBJECT;

typedef struct x509_lookup_st X509_LOOKUP;

DECLARE_STACK_OF(X509_LOOKUP)
DECLARE_STACK_OF(X509_OBJECT)

/* This is a static that defines the function interface */
typedef struct x509_lookup_method_st
	{
	const char *name;
	int (*new_item)(X509_LOOKUP *ctx);
	void (*free)(X509_LOOKUP *ctx);
	int (*init)(X509_LOOKUP *ctx);
	int (*shutdown)(X509_LOOKUP *ctx);
	int (*ctrl)(X509_LOOKUP *ctx,int cmd,const char *argc,long argl,
			char **ret);
	int (*get_by_subject)(X509_LOOKUP *ctx,int type,X509_NAME *name,
			      X509_OBJECT *ret);
	int (*get_by_issuer_serial)(X509_LOOKUP *ctx,int type,X509_NAME *name,
				    ASN1_INTEGER *serial,X509_OBJECT *ret);
	int (*get_by_fingerprint)(X509_LOOKUP *ctx,int type,
				  unsigned char *bytes,int len,
				  X509_OBJECT *ret);
	int (*get_by_alias)(X509_LOOKUP *ctx,int type,char *str,int len,
			    X509_OBJECT *ret);
	} X509_LOOKUP_METHOD;

/* This structure hold all parameters associated with a verify operation
 * by including an X509_VERIFY_PARAM structure in related structures the
 * parameters used can be customized
 */

typedef struct X509_VERIFY_PARAM_st
	{
	char *name;
	time_t check_time;	/* Time to use */
	unsigned long inh_flags; /* Inheritance flags */
	unsigned long flags;	/* Various verify flags */
	int purpose;		/* purpose to check untrusted certificates */
	int trust;		/* trust setting to check */
	int depth;		/* Verify depth */
	STACK_OF(ASN1_OBJECT) *policies;	/* Permissible policies */
	} X509_VERIFY_PARAM;

DECLARE_STACK_OF(X509_VERIFY_PARAM)

/* This is used to hold everything.  It is used for all certificate
 * validation.  Once we have a certificate chain, the 'verify'
 * function is then called to actually check the cert chain. */
struct x509_store_st
	{
	/* The following is a cache of trusted certs */
	int cache; 	/* if true, stash any hits */
	STACK_OF(X509_OBJECT) *objs;	/* Cache of all objects */

	/* These are external lookup methods */
	STACK_OF(X509_LOOKUP) *get_cert_methods;

	X509_VERIFY_PARAM *param;

	/* Callbacks for various operations */
	int (*verify)(X509_STORE_CTX *ctx);	/* called to verify a certificate */
	int (*verify_cb)(int ok,X509_STORE_CTX *ctx);	/* error callback */
	int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);	/* get issuers cert from ctx */
	int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */
	int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */
	int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */
	int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */
	int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */
	STACK_OF(X509) * (*lookup_certs)(X509_STORE_CTX *ctx, X509_NAME *nm);
	STACK_OF(X509_CRL) * (*lookup_crls)(X509_STORE_CTX *ctx, X509_NAME *nm);
	int (*cleanup)(X509_STORE_CTX *ctx);

	CRYPTO_EX_DATA ex_data;
	int references;
	} /* X509_STORE */;

int X509_STORE_set_depth(X509_STORE *store, int depth);

#define X509_STORE_set_verify_cb_func(ctx,func) ((ctx)->verify_cb=(func))
#define X509_STORE_set_verify_func(ctx,func)	((ctx)->verify=(func))

/* This is the functions plus an instance of the local variables. */
struct x509_lookup_st
	{
	int init;			/* have we been started */
	int skip;			/* don't use us. */
	X509_LOOKUP_METHOD *method;	/* the functions */
	char *method_data;		/* method data */

	X509_STORE *store_ctx;	/* who owns us */
	} /* X509_LOOKUP */;

/* This is a used when verifying cert chains.  Since the
 * gathering of the cert chain can take some time (and have to be
 * 'retried', this needs to be kept and passed around. */
struct x509_store_ctx_st      /* X509_STORE_CTX */
	{
	X509_STORE *ctx;
	int current_method;	/* used when looking up certs */

	/* The following are set by the caller */
	X509 *cert;		/* The cert to check */
	STACK_OF(X509) *untrusted;	/* chain of X509s - untrusted - passed in */
	STACK_OF(X509_CRL) *crls;	/* set of CRLs passed in */

	X509_VERIFY_PARAM *param;
	void *other_ctx;	/* Other info for use with get_issuer() */

	/* Callbacks for various operations */
	int (*verify)(X509_STORE_CTX *ctx);	/* called to verify a certificate */
	int (*verify_cb)(int ok,X509_STORE_CTX *ctx);		/* error callback */
	int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);	/* get issuers cert from ctx */
	int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */
	int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */
	int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */
	int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */
	int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */
	int (*check_policy)(X509_STORE_CTX *ctx);
	STACK_OF(X509) * (*lookup_certs)(X509_STORE_CTX *ctx, X509_NAME *nm);
	STACK_OF(X509_CRL) * (*lookup_crls)(X509_STORE_CTX *ctx, X509_NAME *nm);
	int (*cleanup)(X509_STORE_CTX *ctx);

	/* The following is built up */
	int valid;		/* if 0, rebuild chain */
	int last_untrusted;	/* index of last untrusted cert */
	STACK_OF(X509) *chain; 		/* chain of X509s - built up and trusted */
	X509_POLICY_TREE *tree;	/* Valid policy tree */

	int explicit_policy;	/* Require explicit policy value */

	/* When something goes wrong, this is why */
	int error_depth;
	int error;
	X509 *current_cert;
	X509 *current_issuer;	/* cert currently being tested as valid issuer */
	X509_CRL *current_crl;	/* current CRL */

	int current_crl_score;  /* score of current CRL */
	unsigned int current_reasons;  /* Reason mask */

	X509_STORE_CTX *parent; /* For CRL path validation: parent context */

	CRYPTO_EX_DATA ex_data;
	} /* X509_STORE_CTX */;

void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);

#define X509_STORE_CTX_set_app_data(ctx,data) \
	X509_STORE_CTX_set_ex_data(ctx,0,data)
#define X509_STORE_CTX_get_app_data(ctx) \
	X509_STORE_CTX_get_ex_data(ctx,0)

#define X509_L_FILE_LOAD	1
#define X509_L_ADD_DIR		2

#define X509_LOOKUP_load_file(x,name,type) \
		X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL)

#define X509_LOOKUP_add_dir(x,name,type) \
		X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL)

#define		X509_V_OK					0
/* illegal error (for uninitialized values, to avoid X509_V_OK): 1 */

#define		X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT		2
#define		X509_V_ERR_UNABLE_TO_GET_CRL			3
#define		X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE	4
#define		X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE	5
#define		X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY	6
#define		X509_V_ERR_CERT_SIGNATURE_FAILURE		7
#define		X509_V_ERR_CRL_SIGNATURE_FAILURE		8
#define		X509_V_ERR_CERT_NOT_YET_VALID			9
#define		X509_V_ERR_CERT_HAS_EXPIRED			10
#define		X509_V_ERR_CRL_NOT_YET_VALID			11
#define		X509_V_ERR_CRL_HAS_EXPIRED			12
#define		X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD	13
#define		X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD	14
#define		X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD	15
#define		X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD	16
#define		X509_V_ERR_OUT_OF_MEM				17
#define		X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT		18
#define		X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN		19
#define		X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY	20
#define		X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE	21
#define		X509_V_ERR_CERT_CHAIN_TOO_LONG			22
#define		X509_V_ERR_CERT_REVOKED				23
#define		X509_V_ERR_INVALID_CA				24
#define		X509_V_ERR_PATH_LENGTH_EXCEEDED			25
#define		X509_V_ERR_INVALID_PURPOSE			26
#define		X509_V_ERR_CERT_UNTRUSTED			27
#define		X509_V_ERR_CERT_REJECTED			28
/* These are 'informational' when looking for issuer cert */
#define		X509_V_ERR_SUBJECT_ISSUER_MISMATCH		29
#define		X509_V_ERR_AKID_SKID_MISMATCH			30
#define		X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH		31
#define		X509_V_ERR_KEYUSAGE_NO_CERTSIGN			32

#define		X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER		33
#define		X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION		34
#define		X509_V_ERR_KEYUSAGE_NO_CRL_SIGN			35
#define		X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION	36
#define		X509_V_ERR_INVALID_NON_CA			37
#define		X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED		38
#define		X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE	39
#define		X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED	40

#define		X509_V_ERR_INVALID_EXTENSION			41
#define		X509_V_ERR_INVALID_POLICY_EXTENSION		42
#define		X509_V_ERR_NO_EXPLICIT_POLICY			43
#define		X509_V_ERR_DIFFERENT_CRL_SCOPE			44
#define		X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE	45

#define		X509_V_ERR_UNNESTED_RESOURCE			46

#define		X509_V_ERR_PERMITTED_VIOLATION			47
#define		X509_V_ERR_EXCLUDED_VIOLATION			48
#define		X509_V_ERR_SUBTREE_MINMAX			49
#define		X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE		51
#define		X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX	52
#define		X509_V_ERR_UNSUPPORTED_NAME_SYNTAX		53
#define		X509_V_ERR_CRL_PATH_VALIDATION_ERROR		54

/* The application is not happy */
#define		X509_V_ERR_APPLICATION_VERIFICATION		50

/* Certificate verify flags */

/* Send issuer+subject checks to verify_cb */
#define	X509_V_FLAG_CB_ISSUER_CHECK		0x1
/* Use check time instead of current time */
#define	X509_V_FLAG_USE_CHECK_TIME		0x2
/* Lookup CRLs */
#define	X509_V_FLAG_CRL_CHECK			0x4
/* Lookup CRLs for whole chain */
#define	X509_V_FLAG_CRL_CHECK_ALL		0x8
/* Ignore unhandled critical extensions */
#define	X509_V_FLAG_IGNORE_CRITICAL		0x10
/* Disable workarounds for broken certificates */
#define	X509_V_FLAG_X509_STRICT			0x20
/* Enable proxy certificate validation */
#define	X509_V_FLAG_ALLOW_PROXY_CERTS		0x40
/* Enable policy checking */
#define X509_V_FLAG_POLICY_CHECK		0x80
/* Policy variable require-explicit-policy */
#define X509_V_FLAG_EXPLICIT_POLICY		0x100
/* Policy variable inhibit-any-policy */
#define	X509_V_FLAG_INHIBIT_ANY			0x200
/* Policy variable inhibit-policy-mapping */
#define X509_V_FLAG_INHIBIT_MAP			0x400
/* Notify callback that policy is OK */
#define X509_V_FLAG_NOTIFY_POLICY		0x800
/* Extended CRL features such as indirect CRLs, alternate CRL signing keys */
#define X509_V_FLAG_EXTENDED_CRL_SUPPORT	0x1000
/* Delta CRL support */
#define X509_V_FLAG_USE_DELTAS			0x2000
/* Check selfsigned CA signature */
#define X509_V_FLAG_CHECK_SS_SIGNATURE		0x4000


#define X509_VP_FLAG_DEFAULT			0x1
#define X509_VP_FLAG_OVERWRITE			0x2
#define X509_VP_FLAG_RESET_FLAGS		0x4
#define X509_VP_FLAG_LOCKED			0x8
#define X509_VP_FLAG_ONCE			0x10

/* Internal use: mask of policy related options */
#define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \
				| X509_V_FLAG_EXPLICIT_POLICY \
				| X509_V_FLAG_INHIBIT_ANY \
				| X509_V_FLAG_INHIBIT_MAP)

int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,
	     X509_NAME *name);
X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,int type,X509_NAME *name);
X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x);
void X509_OBJECT_up_ref_count(X509_OBJECT *a);
void X509_OBJECT_free_contents(X509_OBJECT *a);
X509_STORE *X509_STORE_new(void );
void X509_STORE_free(X509_STORE *v);

STACK_OF(X509)* X509_STORE_get1_certs(X509_STORE_CTX *st, X509_NAME *nm);
STACK_OF(X509_CRL)* X509_STORE_get1_crls(X509_STORE_CTX *st, X509_NAME *nm);
int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags);
int X509_STORE_set_purpose(X509_STORE *ctx, int purpose);
int X509_STORE_set_trust(X509_STORE *ctx, int trust);
int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm);

void X509_STORE_set_verify_cb(X509_STORE *ctx,
				  int (*verify_cb)(int, X509_STORE_CTX *));

X509_STORE_CTX *X509_STORE_CTX_new(void);

int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);

void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
			 X509 *x509, STACK_OF(X509) *chain);
void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);

X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);

X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);
X509_LOOKUP_METHOD *X509_LOOKUP_file(void);

int X509_STORE_add_cert(X509_STORE *ctx, X509 *x);
int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);

int X509_STORE_get_by_subject(X509_STORE_CTX *vs,int type,X509_NAME *name,
	X509_OBJECT *ret);

int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
	long argl, char **ret);

int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);
int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);
int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);


X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);
void X509_LOOKUP_free(X509_LOOKUP *ctx);
int X509_LOOKUP_init(X509_LOOKUP *ctx);
int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name,
	X509_OBJECT *ret);
int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name,
	ASN1_INTEGER *serial, X509_OBJECT *ret);
int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type,
	unsigned char *bytes, int len, X509_OBJECT *ret);
int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str,
	int len, X509_OBJECT *ret);
int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);

int	X509_STORE_load_locations (X509_STORE *ctx,
		const char *file, const char *dir);
int	X509_STORE_set_default_paths(X509_STORE *ctx);

int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
	CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
int	X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx,int idx,void *data);
void *	X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx,int idx);
int	X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);
void	X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s);
int	X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);
X509 *	X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);
X509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx);
X509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx);
X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx);
STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx);
STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);
void	X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x);
void	X509_STORE_CTX_set_chain(X509_STORE_CTX *c,STACK_OF(X509) *sk);
void	X509_STORE_CTX_set0_crls(X509_STORE_CTX *c,STACK_OF(X509_CRL) *sk);
int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);
int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);
int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
				int purpose, int trust);
void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags);
void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,
								time_t t);
void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,
				  int (*verify_cb)(int, X509_STORE_CTX *));
  
X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx);
int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx);

X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);
void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);
int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);

/* X509_VERIFY_PARAM functions */

X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void);
void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param);
int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to,
						const X509_VERIFY_PARAM *from);
int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, 
						const X509_VERIFY_PARAM *from);
int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name);
int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags);
int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param,
							unsigned long flags);
unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param);
int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose);
int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust);
void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth);
void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t);
int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param,
						ASN1_OBJECT *policy);
int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, 
					STACK_OF(ASN1_OBJECT) *policies);
int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param);

int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param);
const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name);
void X509_VERIFY_PARAM_table_cleanup(void);

int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,
			STACK_OF(X509) *certs,
			STACK_OF(ASN1_OBJECT) *policy_oids,
			unsigned int flags);

void X509_policy_tree_free(X509_POLICY_TREE *tree);

int X509_policy_tree_level_count(const X509_POLICY_TREE *tree);
X509_POLICY_LEVEL *
	X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i);

STACK_OF(X509_POLICY_NODE) *
	X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree);

STACK_OF(X509_POLICY_NODE) *
	X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree);

int X509_policy_level_node_count(X509_POLICY_LEVEL *level);

X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i);

const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node);

STACK_OF(POLICYQUALINFO) *
	X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node);
const X509_POLICY_NODE *
	X509_policy_node_get0_parent(const X509_POLICY_NODE *node);

#ifdef  __cplusplus
}
#endif
#endif

deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/x509.h0000644000175000017500000012652212360020705020727 0ustar  /* $OpenBSD$ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
 * apply to all code found in this distribution, be it the RC4, RSA,
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
 * included with this distribution is covered by the same copyright terms
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
 * 
 * Copyright remains Eric Young's, and as such any Copyright notices in
 * the code are not to be removed.
 * If this package is used in a product, Eric Young should be given attribution
 * as the author of the parts of the library used.
 * This can be in the form of a textual message at program startup or
 * in documentation (online or textual) provided with the package.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    "This product includes cryptographic software written by
 *     Eric Young (eay@cryptsoft.com)"
 *    The word 'cryptographic' can be left out if the rouines from the library
 *    being used are not cryptographic related :-).
 * 4. If you include any Windows specific code (or a derivative thereof) from 
 *    the apps directory (application code) you must include an acknowledgement:
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
 * 
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 THE AUTHOR OR CONTRIBUTORS 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.
 * 
 * The licence and distribution terms for any publically available version or
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
 * copied and put under another distribution licence
 * [including the GNU Public Licence.]
 */
/* ====================================================================
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 * ECDH support in OpenSSL originally developed by 
 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
 */

#ifndef HEADER_X509_H
#define HEADER_X509_H

#include 

#ifndef OPENSSL_NO_BUFFER
#include 
#endif
#ifndef OPENSSL_NO_EVP
#include 
#endif
#ifndef OPENSSL_NO_BIO
#include 
#endif
#include 
#include 
#include 

#ifndef OPENSSL_NO_EC
#include 
#endif

#ifndef OPENSSL_NO_ECDSA
#include 
#endif

#ifndef OPENSSL_NO_ECDH
#include 
#endif

#ifndef OPENSSL_NO_DEPRECATED
#ifndef OPENSSL_NO_RSA
#include 
#endif
#ifndef OPENSSL_NO_DSA
#include 
#endif
#ifndef OPENSSL_NO_DH
#include 
#endif
#endif

#ifndef OPENSSL_NO_SHA
#include 
#endif
#include 

#ifdef  __cplusplus
extern "C" {
#endif

#define X509_FILETYPE_PEM	1
#define X509_FILETYPE_ASN1	2
#define X509_FILETYPE_DEFAULT	3

#define X509v3_KU_DIGITAL_SIGNATURE	0x0080
#define X509v3_KU_NON_REPUDIATION	0x0040
#define X509v3_KU_KEY_ENCIPHERMENT	0x0020
#define X509v3_KU_DATA_ENCIPHERMENT	0x0010
#define X509v3_KU_KEY_AGREEMENT		0x0008
#define X509v3_KU_KEY_CERT_SIGN		0x0004
#define X509v3_KU_CRL_SIGN		0x0002
#define X509v3_KU_ENCIPHER_ONLY		0x0001
#define X509v3_KU_DECIPHER_ONLY		0x8000
#define X509v3_KU_UNDEF			0xffff

typedef struct X509_objects_st
	{
	int nid;
	int (*a2i)(void);
	int (*i2a)(void);
	} X509_OBJECTS;

struct X509_algor_st
	{
	ASN1_OBJECT *algorithm;
	ASN1_TYPE *parameter;
	} /* X509_ALGOR */;

DECLARE_ASN1_SET_OF(X509_ALGOR)

typedef STACK_OF(X509_ALGOR) X509_ALGORS;

typedef struct X509_val_st
	{
	ASN1_TIME *notBefore;
	ASN1_TIME *notAfter;
	} X509_VAL;

struct X509_pubkey_st
	{
	X509_ALGOR *algor;
	ASN1_BIT_STRING *public_key;
	EVP_PKEY *pkey;
	};

typedef struct X509_sig_st
	{
	X509_ALGOR *algor;
	ASN1_OCTET_STRING *digest;
	} X509_SIG;

typedef struct X509_name_entry_st
	{
	ASN1_OBJECT *object;
	ASN1_STRING *value;
	int set;
	int size; 	/* temp variable */
	} X509_NAME_ENTRY;

DECLARE_STACK_OF(X509_NAME_ENTRY)
DECLARE_ASN1_SET_OF(X509_NAME_ENTRY)

/* we always keep X509_NAMEs in 2 forms. */
struct X509_name_st
	{
	STACK_OF(X509_NAME_ENTRY) *entries;
	int modified;	/* true if 'bytes' needs to be built */
#ifndef OPENSSL_NO_BUFFER
	BUF_MEM *bytes;
#else
	char *bytes;
#endif
/*	unsigned long hash; Keep the hash around for lookups */
	unsigned char *canon_enc;
	int canon_enclen;
	} /* X509_NAME */;

DECLARE_STACK_OF(X509_NAME)

#define X509_EX_V_NETSCAPE_HACK		0x8000
#define X509_EX_V_INIT			0x0001
typedef struct X509_extension_st
	{
	ASN1_OBJECT *object;
	ASN1_BOOLEAN critical;
	ASN1_OCTET_STRING *value;
	} X509_EXTENSION;

typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;

DECLARE_STACK_OF(X509_EXTENSION)
DECLARE_ASN1_SET_OF(X509_EXTENSION)

/* a sequence of these are used */
typedef struct x509_attributes_st
	{
	ASN1_OBJECT *object;
	int single; /* 0 for a set, 1 for a single item (which is wrong) */
	union	{
		char		*ptr;
/* 0 */		STACK_OF(ASN1_TYPE) *set;
/* 1 */		ASN1_TYPE	*single;
		} value;
	} X509_ATTRIBUTE;

DECLARE_STACK_OF(X509_ATTRIBUTE)
DECLARE_ASN1_SET_OF(X509_ATTRIBUTE)


typedef struct X509_req_info_st
	{
	ASN1_ENCODING enc;
	ASN1_INTEGER *version;
	X509_NAME *subject;
	X509_PUBKEY *pubkey;
	/*  d=2 hl=2 l=  0 cons: cont: 00 */
	STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
	} X509_REQ_INFO;

typedef struct X509_req_st
	{
	X509_REQ_INFO *req_info;
	X509_ALGOR *sig_alg;
	ASN1_BIT_STRING *signature;
	int references;
	} X509_REQ;

typedef struct x509_cinf_st
	{
	ASN1_INTEGER *version;		/* [ 0 ] default of v1 */
	ASN1_INTEGER *serialNumber;
	X509_ALGOR *signature;
	X509_NAME *issuer;
	X509_VAL *validity;
	X509_NAME *subject;
	X509_PUBKEY *key;
	ASN1_BIT_STRING *issuerUID;		/* [ 1 ] optional in v2 */
	ASN1_BIT_STRING *subjectUID;		/* [ 2 ] optional in v2 */
	STACK_OF(X509_EXTENSION) *extensions;	/* [ 3 ] optional in v3 */
	ASN1_ENCODING enc;
	} X509_CINF;

/* This stuff is certificate "auxiliary info"
 * it contains details which are useful in certificate
 * stores and databases. When used this is tagged onto
 * the end of the certificate itself
 */

typedef struct x509_cert_aux_st
	{
	STACK_OF(ASN1_OBJECT) *trust;		/* trusted uses */
	STACK_OF(ASN1_OBJECT) *reject;		/* rejected uses */
	ASN1_UTF8STRING *alias;			/* "friendly name" */
	ASN1_OCTET_STRING *keyid;		/* key id of private key */
	STACK_OF(X509_ALGOR) *other;		/* other unspecified info */
	} X509_CERT_AUX;

struct x509_st
	{
	X509_CINF *cert_info;
	X509_ALGOR *sig_alg;
	ASN1_BIT_STRING *signature;
	int valid;
	int references;
	char *name;
	CRYPTO_EX_DATA ex_data;
	/* These contain copies of various extension values */
	long ex_pathlen;
	long ex_pcpathlen;
	unsigned long ex_flags;
	unsigned long ex_kusage;
	unsigned long ex_xkusage;
	unsigned long ex_nscert;
	ASN1_OCTET_STRING *skid;
	AUTHORITY_KEYID *akid;
	X509_POLICY_CACHE *policy_cache;
	STACK_OF(DIST_POINT) *crldp;
	STACK_OF(GENERAL_NAME) *altname;
	NAME_CONSTRAINTS *nc;
#ifndef OPENSSL_NO_RFC3779
	STACK_OF(IPAddressFamily) *rfc3779_addr;
	struct ASIdentifiers_st *rfc3779_asid;
#endif
#ifndef OPENSSL_NO_SHA
	unsigned char sha1_hash[SHA_DIGEST_LENGTH];
#endif
	X509_CERT_AUX *aux;
	} /* X509 */;

DECLARE_STACK_OF(X509)
DECLARE_ASN1_SET_OF(X509)

/* This is used for a table of trust checking functions */

typedef struct x509_trust_st {
	int trust;
	int flags;
	int (*check_trust)(struct x509_trust_st *, X509 *, int);
	char *name;
	int arg1;
	void *arg2;
} X509_TRUST;

DECLARE_STACK_OF(X509_TRUST)

typedef struct x509_cert_pair_st {
	X509 *forward;
	X509 *reverse;
} X509_CERT_PAIR;

/* standard trust ids */

#define X509_TRUST_DEFAULT	-1	/* Only valid in purpose settings */

#define X509_TRUST_COMPAT	1
#define X509_TRUST_SSL_CLIENT	2
#define X509_TRUST_SSL_SERVER	3
#define X509_TRUST_EMAIL	4
#define X509_TRUST_OBJECT_SIGN	5
#define X509_TRUST_OCSP_SIGN	6
#define X509_TRUST_OCSP_REQUEST	7
#define X509_TRUST_TSA		8

/* Keep these up to date! */
#define X509_TRUST_MIN		1
#define X509_TRUST_MAX		8


/* trust_flags values */
#define	X509_TRUST_DYNAMIC 	1
#define	X509_TRUST_DYNAMIC_NAME	2

/* check_trust return codes */

#define X509_TRUST_TRUSTED	1
#define X509_TRUST_REJECTED	2
#define X509_TRUST_UNTRUSTED	3

/* Flags for X509_print_ex() */

#define	X509_FLAG_COMPAT		0
#define	X509_FLAG_NO_HEADER		1L
#define	X509_FLAG_NO_VERSION		(1L << 1)
#define	X509_FLAG_NO_SERIAL		(1L << 2)
#define	X509_FLAG_NO_SIGNAME		(1L << 3)
#define	X509_FLAG_NO_ISSUER		(1L << 4)
#define	X509_FLAG_NO_VALIDITY		(1L << 5)
#define	X509_FLAG_NO_SUBJECT		(1L << 6)
#define	X509_FLAG_NO_PUBKEY		(1L << 7)
#define	X509_FLAG_NO_EXTENSIONS		(1L << 8)
#define	X509_FLAG_NO_SIGDUMP		(1L << 9)
#define	X509_FLAG_NO_AUX		(1L << 10)
#define	X509_FLAG_NO_ATTRIBUTES		(1L << 11)

/* Flags specific to X509_NAME_print_ex() */	

/* The field separator information */

#define XN_FLAG_SEP_MASK	(0xf << 16)

#define XN_FLAG_COMPAT		0		/* Traditional SSLeay: use old X509_NAME_print */
#define XN_FLAG_SEP_COMMA_PLUS	(1 << 16)	/* RFC2253 ,+ */
#define XN_FLAG_SEP_CPLUS_SPC	(2 << 16)	/* ,+ spaced: more readable */
#define XN_FLAG_SEP_SPLUS_SPC	(3 << 16)	/* ;+ spaced */
#define XN_FLAG_SEP_MULTILINE	(4 << 16)	/* One line per field */

#define XN_FLAG_DN_REV		(1 << 20)	/* Reverse DN order */

/* How the field name is shown */

#define XN_FLAG_FN_MASK		(0x3 << 21)

#define XN_FLAG_FN_SN		0		/* Object short name */
#define XN_FLAG_FN_LN		(1 << 21)	/* Object long name */
#define XN_FLAG_FN_OID		(2 << 21)	/* Always use OIDs */
#define XN_FLAG_FN_NONE		(3 << 21)	/* No field names */

#define XN_FLAG_SPC_EQ		(1 << 23)	/* Put spaces round '=' */

/* This determines if we dump fields we don't recognise:
 * RFC2253 requires this.
 */

#define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)

#define XN_FLAG_FN_ALIGN	(1 << 25)	/* Align field names to 20 characters */

/* Complete set of RFC2253 flags */

#define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \
			XN_FLAG_SEP_COMMA_PLUS | \
			XN_FLAG_DN_REV | \
			XN_FLAG_FN_SN | \
			XN_FLAG_DUMP_UNKNOWN_FIELDS)

/* readable oneline form */

#define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \
			ASN1_STRFLGS_ESC_QUOTE | \
			XN_FLAG_SEP_CPLUS_SPC | \
			XN_FLAG_SPC_EQ | \
			XN_FLAG_FN_SN)

/* readable multiline form */

#define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \
			ASN1_STRFLGS_ESC_MSB | \
			XN_FLAG_SEP_MULTILINE | \
			XN_FLAG_SPC_EQ | \
			XN_FLAG_FN_LN | \
			XN_FLAG_FN_ALIGN)

struct x509_revoked_st
	{
	ASN1_INTEGER *serialNumber;
	ASN1_TIME *revocationDate;
	STACK_OF(X509_EXTENSION) /* optional */ *extensions;
	/* Set up if indirect CRL */
	STACK_OF(GENERAL_NAME) *issuer;
	/* Revocation reason */
	int reason;
	int sequence; /* load sequence */
	};

DECLARE_STACK_OF(X509_REVOKED)
DECLARE_ASN1_SET_OF(X509_REVOKED)

typedef struct X509_crl_info_st
	{
	ASN1_INTEGER *version;
	X509_ALGOR *sig_alg;
	X509_NAME *issuer;
	ASN1_TIME *lastUpdate;
	ASN1_TIME *nextUpdate;
	STACK_OF(X509_REVOKED) *revoked;
	STACK_OF(X509_EXTENSION) /* [0] */ *extensions;
	ASN1_ENCODING enc;
	} X509_CRL_INFO;

struct X509_crl_st
	{
	/* actual signature */
	X509_CRL_INFO *crl;
	X509_ALGOR *sig_alg;
	ASN1_BIT_STRING *signature;
	int references;
	int flags;
	/* Copies of various extensions */
	AUTHORITY_KEYID *akid;
	ISSUING_DIST_POINT *idp;
	/* Convenient breakdown of IDP */
	int idp_flags;
	int idp_reasons;
	/* CRL and base CRL numbers for delta processing */
	ASN1_INTEGER *crl_number;
	ASN1_INTEGER *base_crl_number;
#ifndef OPENSSL_NO_SHA
	unsigned char sha1_hash[SHA_DIGEST_LENGTH];
#endif
	STACK_OF(GENERAL_NAMES) *issuers;
	const X509_CRL_METHOD *meth;
	void *meth_data;
	} /* X509_CRL */;

DECLARE_STACK_OF(X509_CRL)
DECLARE_ASN1_SET_OF(X509_CRL)

typedef struct private_key_st
	{
	int version;
	/* The PKCS#8 data types */
	X509_ALGOR *enc_algor;
	ASN1_OCTET_STRING *enc_pkey;	/* encrypted pub key */

	/* When decrypted, the following will not be NULL */
	EVP_PKEY *dec_pkey;

	/* used to encrypt and decrypt */
	int key_length;
	char *key_data;
	int key_free;	/* true if we should auto free key_data */

	/* expanded version of 'enc_algor' */
	EVP_CIPHER_INFO cipher;

	int references;
	} X509_PKEY;

#ifndef OPENSSL_NO_EVP
typedef struct X509_info_st
	{
	X509 *x509;
	X509_CRL *crl;
	X509_PKEY *x_pkey;

	EVP_CIPHER_INFO enc_cipher;
	int enc_len;
	char *enc_data;

	int references;
	} X509_INFO;

DECLARE_STACK_OF(X509_INFO)
#endif

/* The next 2 structures and their 8 routines were sent to me by
 * Pat Richard  and are used to manipulate
 * Netscapes spki structures - useful if you are writing a CA web page
 */
typedef struct Netscape_spkac_st
	{
	X509_PUBKEY *pubkey;
	ASN1_IA5STRING *challenge;	/* challenge sent in atlas >= PR2 */
	} NETSCAPE_SPKAC;

typedef struct Netscape_spki_st
	{
	NETSCAPE_SPKAC *spkac;	/* signed public key and challenge */
	X509_ALGOR *sig_algor;
	ASN1_BIT_STRING *signature;
	} NETSCAPE_SPKI;

/* Netscape certificate sequence structure */
typedef struct Netscape_certificate_sequence
	{
	ASN1_OBJECT *type;
	STACK_OF(X509) *certs;
	} NETSCAPE_CERT_SEQUENCE;

/* Unused (and iv length is wrong)
typedef struct CBCParameter_st
	{
	unsigned char iv[8];
	} CBC_PARAM;
*/

/* Password based encryption structure */

typedef struct PBEPARAM_st {
ASN1_OCTET_STRING *salt;
ASN1_INTEGER *iter;
} PBEPARAM;

/* Password based encryption V2 structures */

typedef struct PBE2PARAM_st {
X509_ALGOR *keyfunc;
X509_ALGOR *encryption;
} PBE2PARAM;

typedef struct PBKDF2PARAM_st {
ASN1_TYPE *salt;	/* Usually OCTET STRING but could be anything */
ASN1_INTEGER *iter;
ASN1_INTEGER *keylength;
X509_ALGOR *prf;
} PBKDF2PARAM;


/* PKCS#8 private key info structure */

struct pkcs8_priv_key_info_st
        {
        int broken;     /* Flag for various broken formats */
#define PKCS8_OK		0
#define PKCS8_NO_OCTET		1
#define PKCS8_EMBEDDED_PARAM	2
#define PKCS8_NS_DB		3
#define PKCS8_NEG_PRIVKEY	4
        ASN1_INTEGER *version;
        X509_ALGOR *pkeyalg;
        ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */
        STACK_OF(X509_ATTRIBUTE) *attributes;
        };

#ifdef  __cplusplus
}
#endif

#include 
#include 

#ifdef  __cplusplus
extern "C" {
#endif

#define X509_EXT_PACK_UNKNOWN	1
#define X509_EXT_PACK_STRING	2

#define		X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version)
/* #define	X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */
#define		X509_get_notBefore(x) ((x)->cert_info->validity->notBefore)
#define		X509_get_notAfter(x) ((x)->cert_info->validity->notAfter)
#define		X509_extract_key(x)	X509_get_pubkey(x) /*****/
#define		X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version)
#define		X509_REQ_get_subject_name(x) ((x)->req_info->subject)
#define		X509_REQ_extract_key(a)	X509_REQ_get_pubkey(a)
#define		X509_name_cmp(a,b)	X509_NAME_cmp((a),(b))
#define		X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm))

#define		X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version)
#define 	X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate)
#define 	X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate)
#define		X509_CRL_get_issuer(x) ((x)->crl->issuer)
#define		X509_CRL_get_REVOKED(x) ((x)->crl->revoked)

void X509_CRL_set_default_method(const X509_CRL_METHOD *meth);
X509_CRL_METHOD *X509_CRL_METHOD_new(
	int (*crl_init)(X509_CRL *crl),
	int (*crl_free)(X509_CRL *crl),
	int (*crl_lookup)(X509_CRL *crl, X509_REVOKED **ret,
				ASN1_INTEGER *ser, X509_NAME *issuer),
	int (*crl_verify)(X509_CRL *crl, EVP_PKEY *pk));
void X509_CRL_METHOD_free(X509_CRL_METHOD *m);

void X509_CRL_set_meth_data(X509_CRL *crl, void *dat);
void *X509_CRL_get_meth_data(X509_CRL *crl);

/* This one is only used so that a binary form can output, as in
 * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf) */
#define 	X509_get_X509_PUBKEY(x) ((x)->cert_info->key)


const char *X509_verify_cert_error_string(long n);

#ifndef OPENSSL_NO_EVP
int X509_verify(X509 *a, EVP_PKEY *r);

int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);

NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len);
char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);
EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);
int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);

int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);

int X509_signature_dump(BIO *bp,const ASN1_STRING *sig, int indent);
int X509_signature_print(BIO *bp,X509_ALGOR *alg, ASN1_STRING *sig);

int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx);
int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx);
int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx);
int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);

int X509_pubkey_digest(const X509 *data,const EVP_MD *type,
		unsigned char *md, unsigned int *len);
int X509_digest(const X509 *data,const EVP_MD *type,
		unsigned char *md, unsigned int *len);
int X509_CRL_digest(const X509_CRL *data,const EVP_MD *type,
		unsigned char *md, unsigned int *len);
int X509_REQ_digest(const X509_REQ *data,const EVP_MD *type,
		unsigned char *md, unsigned int *len);
int X509_NAME_digest(const X509_NAME *data,const EVP_MD *type,
		unsigned char *md, unsigned int *len);
#endif

X509 *d2i_X509_fp(FILE *fp, X509 **x509);
int i2d_X509_fp(FILE *fp,X509 *x509);
X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl);
int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl);
X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req);
int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req);
#ifndef OPENSSL_NO_RSA
RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa);
int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa);
RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa);
int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa);
RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa);
int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa);
#endif
#ifndef OPENSSL_NO_DSA
DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);
int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);
int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);
#endif
#ifndef OPENSSL_NO_EC
EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);
int   i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey);
EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);
int   i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey);
#endif
X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8);
int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8);
PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
						PKCS8_PRIV_KEY_INFO **p8inf);
int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf);
int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);
int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);
EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);
int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey);
EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);

#ifndef OPENSSL_NO_BIO
X509 *d2i_X509_bio(BIO *bp,X509 **x509);
int i2d_X509_bio(BIO *bp,X509 *x509);
X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl);
int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl);
X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req);
int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req);
#ifndef OPENSSL_NO_RSA
RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa);
int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa);
RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa);
int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa);
RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa);
int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa);
#endif
#ifndef OPENSSL_NO_DSA
DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);
int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);
DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);
#endif
#ifndef OPENSSL_NO_EC
EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);
int   i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey);
EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);
int   i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey);
#endif
X509_SIG *d2i_PKCS8_bio(BIO *bp,X509_SIG **p8);
int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8);
PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
						PKCS8_PRIV_KEY_INFO **p8inf);
int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf);
int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);
int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);
EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);
int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey);
EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);
#endif

X509 *X509_dup(X509 *x509);
X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);
X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex);
X509_CRL *X509_CRL_dup(X509_CRL *crl);
X509_REQ *X509_REQ_dup(X509_REQ *req);
X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);
int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval);
void X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval,
						X509_ALGOR *algor);
void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);

X509_NAME *X509_NAME_dup(X509_NAME *xn);
X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);

int		X509_cmp_time(const ASN1_TIME *s, time_t *t);
int		X509_cmp_current_time(const ASN1_TIME *s);
ASN1_TIME *	X509_time_adj(ASN1_TIME *s, long adj, time_t *t);
ASN1_TIME *	X509_time_adj_ex(ASN1_TIME *s,
				int offset_day, long offset_sec, time_t *t);
ASN1_TIME *	X509_gmtime_adj(ASN1_TIME *s, long adj);

const char *	X509_get_default_cert_area(void );
const char *	X509_get_default_cert_dir(void );
const char *	X509_get_default_cert_file(void );
const char *	X509_get_default_cert_dir_env(void );
const char *	X509_get_default_cert_file_env(void );
const char *	X509_get_default_private_dir(void );

X509_REQ *	X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
X509 *		X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey);

DECLARE_ASN1_FUNCTIONS(X509_ALGOR)
DECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)
DECLARE_ASN1_FUNCTIONS(X509_VAL)

DECLARE_ASN1_FUNCTIONS(X509_PUBKEY)

int		X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);
EVP_PKEY *	X509_PUBKEY_get(X509_PUBKEY *key);
int		X509_get_pubkey_parameters(EVP_PKEY *pkey,
					   STACK_OF(X509) *chain);
int		i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp);
EVP_PKEY *	d2i_PUBKEY(EVP_PKEY **a,const unsigned char **pp,
			long length);
#ifndef OPENSSL_NO_RSA
int		i2d_RSA_PUBKEY(RSA *a,unsigned char **pp);
RSA *		d2i_RSA_PUBKEY(RSA **a,const unsigned char **pp,
			long length);
#endif
#ifndef OPENSSL_NO_DSA
int		i2d_DSA_PUBKEY(DSA *a,unsigned char **pp);
DSA *		d2i_DSA_PUBKEY(DSA **a,const unsigned char **pp,
			long length);
#endif
#ifndef OPENSSL_NO_EC
int		i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp);
EC_KEY 		*d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp,
			long length);
#endif

DECLARE_ASN1_FUNCTIONS(X509_SIG)
DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO)
DECLARE_ASN1_FUNCTIONS(X509_REQ)

DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE)
X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);

DECLARE_ASN1_FUNCTIONS(X509_EXTENSION)
DECLARE_ASN1_ENCODE_FUNCTIONS(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS)

DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY)

DECLARE_ASN1_FUNCTIONS(X509_NAME)

int		X509_NAME_set(X509_NAME **xn, X509_NAME *name);

DECLARE_ASN1_FUNCTIONS(X509_CINF)

DECLARE_ASN1_FUNCTIONS(X509)
DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)

DECLARE_ASN1_FUNCTIONS(X509_CERT_PAIR)

int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
	     CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
int X509_set_ex_data(X509 *r, int idx, void *arg);
void *X509_get_ex_data(X509 *r, int idx);
int		i2d_X509_AUX(X509 *a,unsigned char **pp);
X509 *		d2i_X509_AUX(X509 **a,const unsigned char **pp,long length);

int X509_alias_set1(X509 *x, unsigned char *name, int len);
int X509_keyid_set1(X509 *x, unsigned char *id, int len);
unsigned char * X509_alias_get0(X509 *x, int *len);
unsigned char * X509_keyid_get0(X509 *x, int *len);
int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int);
int X509_TRUST_set(int *t, int trust);
int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj);
int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj);
void X509_trust_clear(X509 *x);
void X509_reject_clear(X509 *x);

DECLARE_ASN1_FUNCTIONS(X509_REVOKED)
DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO)
DECLARE_ASN1_FUNCTIONS(X509_CRL)

int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
int X509_CRL_get0_by_serial(X509_CRL *crl,
		X509_REVOKED **ret, ASN1_INTEGER *serial);
int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);

X509_PKEY *	X509_PKEY_new(void );
void		X509_PKEY_free(X509_PKEY *a);
int		i2d_X509_PKEY(X509_PKEY *a,unsigned char **pp);
X509_PKEY *	d2i_X509_PKEY(X509_PKEY **a,const unsigned char **pp,long length);

DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI)
DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC)
DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE)

#ifndef OPENSSL_NO_EVP
X509_INFO *	X509_INFO_new(void);
void		X509_INFO_free(X509_INFO *a);
char *		X509_NAME_oneline(X509_NAME *a,char *buf,int size);

int ASN1_item_digest(const ASN1_ITEM *it,const EVP_MD *type,void *data,
	unsigned char *md,unsigned int *len);

int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,
	ASN1_BIT_STRING *signature,void *data,EVP_PKEY *pkey);

int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
	ASN1_BIT_STRING *signature,
	void *data, EVP_PKEY *pkey, const EVP_MD *type);
int ASN1_item_sign_ctx(const ASN1_ITEM *it,
		X509_ALGOR *algor1, X509_ALGOR *algor2,
	     	ASN1_BIT_STRING *signature, void *asn, EVP_MD_CTX *ctx);
#endif

int 		X509_set_version(X509 *x,long version);
int 		X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
ASN1_INTEGER *	X509_get_serialNumber(X509 *x);
int 		X509_set_issuer_name(X509 *x, X509_NAME *name);
X509_NAME *	X509_get_issuer_name(X509 *a);
int 		X509_set_subject_name(X509 *x, X509_NAME *name);
X509_NAME *	X509_get_subject_name(X509 *a);
int 		X509_set_notBefore(X509 *x, const ASN1_TIME *tm);
int 		X509_set_notAfter(X509 *x, const ASN1_TIME *tm);
int 		X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
EVP_PKEY *	X509_get_pubkey(X509 *x);
ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x);
int		X509_certificate_type(X509 *x,EVP_PKEY *pubkey /* optional */);

int		X509_REQ_set_version(X509_REQ *x,long version);
int		X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name);
int		X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
EVP_PKEY *	X509_REQ_get_pubkey(X509_REQ *req);
int		X509_REQ_extension_nid(int nid);
int *		X509_REQ_get_extension_nids(void);
void		X509_REQ_set_extension_nids(int *nids);
STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);
int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,
				int nid);
int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);
int X509_REQ_get_attr_count(const X509_REQ *req);
int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid,
			  int lastpos);
int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj,
			  int lastpos);
X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
			const ASN1_OBJECT *obj, int type,
			const unsigned char *bytes, int len);
int X509_REQ_add1_attr_by_NID(X509_REQ *req,
			int nid, int type,
			const unsigned char *bytes, int len);
int X509_REQ_add1_attr_by_txt(X509_REQ *req,
			const char *attrname, int type,
			const unsigned char *bytes, int len);

int X509_CRL_set_version(X509_CRL *x, long version);
int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
int X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);
int X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);
int X509_CRL_sort(X509_CRL *crl);

int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);
int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);

int		X509_REQ_check_private_key(X509_REQ *x509,EVP_PKEY *pkey);

int		X509_check_private_key(X509 *x509,EVP_PKEY *pkey);

int		X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
unsigned long	X509_issuer_and_serial_hash(X509 *a);

int		X509_issuer_name_cmp(const X509 *a, const X509 *b);
unsigned long	X509_issuer_name_hash(X509 *a);

int		X509_subject_name_cmp(const X509 *a, const X509 *b);
unsigned long	X509_subject_name_hash(X509 *x);

#ifndef OPENSSL_NO_MD5
unsigned long	X509_issuer_name_hash_old(X509 *a);
unsigned long	X509_subject_name_hash_old(X509 *x);
#endif

int		X509_cmp(const X509 *a, const X509 *b);
int		X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
unsigned long	X509_NAME_hash(X509_NAME *x);
unsigned long	X509_NAME_hash_old(X509_NAME *x);

int		X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
int		X509_CRL_match(const X509_CRL *a, const X509_CRL *b);
int		X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
int		X509_print_fp(FILE *bp,X509 *x);
int		X509_CRL_print_fp(FILE *bp,X509_CRL *x);
int		X509_REQ_print_fp(FILE *bp,X509_REQ *req);
int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags);

#ifndef OPENSSL_NO_BIO
int		X509_NAME_print(BIO *bp, X509_NAME *name, int obase);
int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags);
int		X509_print_ex(BIO *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
int		X509_print(BIO *bp,X509 *x);
int		X509_ocspid_print(BIO *bp,X509 *x);
int		X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent);
int		X509_CRL_print(BIO *bp,X509_CRL *x);
int		X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long cflag);
int		X509_REQ_print(BIO *bp,X509_REQ *req);
#endif

int 		X509_NAME_entry_count(X509_NAME *name);
int 		X509_NAME_get_text_by_NID(X509_NAME *name, int nid,
			char *buf,int len);
int		X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,
			char *buf,int len);

/* NOTE: you should be passsing -1, not 0 as lastpos.  The functions that use
 * lastpos, search after that position on. */
int 		X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos);
int 		X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj,
			int lastpos);
X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc);
X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
int 		X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne,
			int loc, int set);
int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type,
			unsigned char *bytes, int len, int loc, int set);
int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
			unsigned char *bytes, int len, int loc, int set);
X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
		const char *field, int type, const unsigned char *bytes, int len);
X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
			int type,unsigned char *bytes, int len);
int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,
			const unsigned char *bytes, int len, int loc, int set);
X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
			ASN1_OBJECT *obj, int type,const unsigned char *bytes,
			int len);
int 		X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne,
			ASN1_OBJECT *obj);
int 		X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
			const unsigned char *bytes, int len);
ASN1_OBJECT *	X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne);
ASN1_STRING *	X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne);

int		X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);
int		X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,
				      int nid, int lastpos);
int		X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,
				      ASN1_OBJECT *obj,int lastpos);
int		X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,
					   int crit, int lastpos);
X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);
X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);
STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,
					 X509_EXTENSION *ex, int loc);

int		X509_get_ext_count(X509 *x);
int		X509_get_ext_by_NID(X509 *x, int nid, int lastpos);
int		X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos);
int		X509_get_ext_by_critical(X509 *x, int crit, int lastpos);
X509_EXTENSION *X509_get_ext(X509 *x, int loc);
X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
int		X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
void	*	X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx);
int		X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
							unsigned long flags);

int		X509_CRL_get_ext_count(X509_CRL *x);
int		X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos);
int		X509_CRL_get_ext_by_OBJ(X509_CRL *x,ASN1_OBJECT *obj,int lastpos);
int		X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos);
X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc);
X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);
int		X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
void	*	X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx);
int		X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,
							unsigned long flags);

int		X509_REVOKED_get_ext_count(X509_REVOKED *x);
int		X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos);
int		X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x,ASN1_OBJECT *obj,int lastpos);
int		X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos);
X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc);
X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);
int		X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);
void	*	X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx);
int		X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,
							unsigned long flags);

X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
			int nid, int crit, ASN1_OCTET_STRING *data);
X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,
			ASN1_OBJECT *obj,int crit,ASN1_OCTET_STRING *data);
int		X509_EXTENSION_set_object(X509_EXTENSION *ex,ASN1_OBJECT *obj);
int		X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);
int		X509_EXTENSION_set_data(X509_EXTENSION *ex,
			ASN1_OCTET_STRING *data);
ASN1_OBJECT *	X509_EXTENSION_get_object(X509_EXTENSION *ex);
ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);
int		X509_EXTENSION_get_critical(X509_EXTENSION *ex);

int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);
int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
			  int lastpos);
int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj,
			  int lastpos);
X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);
X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);
STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
					 X509_ATTRIBUTE *attr);
STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x,
			const ASN1_OBJECT *obj, int type,
			const unsigned char *bytes, int len);
STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x,
			int nid, int type,
			const unsigned char *bytes, int len);
STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x,
			const char *attrname, int type,
			const unsigned char *bytes, int len);
void *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x,
				ASN1_OBJECT *obj, int lastpos, int type);
X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
	     int atrtype, const void *data, int len);
X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
	     const ASN1_OBJECT *obj, int atrtype, const void *data, int len);
X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
		const char *atrname, int type, const unsigned char *bytes, int len);
int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);
int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len);
void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx,
					int atrtype, void *data);
int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr);
ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);
ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);

int EVP_PKEY_get_attr_count(const EVP_PKEY *key);
int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid,
			  int lastpos);
int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj,
			  int lastpos);
X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);
X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);
int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);
int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,
			const ASN1_OBJECT *obj, int type,
			const unsigned char *bytes, int len);
int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,
			int nid, int type,
			const unsigned char *bytes, int len);
int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,
			const char *attrname, int type,
			const unsigned char *bytes, int len);

int		X509_verify_cert(X509_STORE_CTX *ctx);

/* lookup a cert from a X509 STACK */
X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk,X509_NAME *name,
				     ASN1_INTEGER *serial);
X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name);

DECLARE_ASN1_FUNCTIONS(PBEPARAM)
DECLARE_ASN1_FUNCTIONS(PBE2PARAM)
DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM)

int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,
				const unsigned char *salt, int saltlen);

X509_ALGOR *PKCS5_pbe_set(int alg, int iter,
				const unsigned char *salt, int saltlen);
X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
					 unsigned char *salt, int saltlen);
X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,
				 unsigned char *salt, int saltlen,
				 unsigned char *aiv, int prf_nid);

X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,
				int prf_nid, int keylen);

/* PKCS#8 utilities */

DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)

EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8);
PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);
PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken);
PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);

int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,
			int version, int ptype, void *pval,
				unsigned char *penc, int penclen);
int PKCS8_pkey_get0(ASN1_OBJECT **ppkalg,
		const unsigned char **pk, int *ppklen,
		X509_ALGOR **pa,
		PKCS8_PRIV_KEY_INFO *p8);

int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,
					int ptype, void *pval,
					unsigned char *penc, int penclen);
int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,
		const unsigned char **pk, int *ppklen,
		X509_ALGOR **pa,
		X509_PUBKEY *pub);

int X509_check_trust(X509 *x, int id, int flags);
int X509_TRUST_get_count(void);
X509_TRUST * X509_TRUST_get0(int idx);
int X509_TRUST_get_by_id(int id);
int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int),
					char *name, int arg1, void *arg2);
void X509_TRUST_cleanup(void);
int X509_TRUST_get_flags(X509_TRUST *xp);
char *X509_TRUST_get0_name(X509_TRUST *xp);
int X509_TRUST_get_trust(X509_TRUST *xp);

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 */
void ERR_load_X509_strings(void);

/* Error codes for the X509 functions. */

/* Function codes. */
#define X509_F_ADD_CERT_DIR				 100
#define X509_F_BY_FILE_CTRL				 101
#define X509_F_CHECK_POLICY				 145
#define X509_F_DIR_CTRL					 102
#define X509_F_GET_CERT_BY_SUBJECT			 103
#define X509_F_NETSCAPE_SPKI_B64_DECODE			 129
#define X509_F_NETSCAPE_SPKI_B64_ENCODE			 130
#define X509_F_X509AT_ADD1_ATTR				 135
#define X509_F_X509V3_ADD_EXT				 104
#define X509_F_X509_ATTRIBUTE_CREATE_BY_NID		 136
#define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ		 137
#define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT		 140
#define X509_F_X509_ATTRIBUTE_GET0_DATA			 139
#define X509_F_X509_ATTRIBUTE_SET1_DATA			 138
#define X509_F_X509_CHECK_PRIVATE_KEY			 128
#define X509_F_X509_CRL_PRINT_FP			 147
#define X509_F_X509_EXTENSION_CREATE_BY_NID		 108
#define X509_F_X509_EXTENSION_CREATE_BY_OBJ		 109
#define X509_F_X509_GET_PUBKEY_PARAMETERS		 110
#define X509_F_X509_LOAD_CERT_CRL_FILE			 132
#define X509_F_X509_LOAD_CERT_FILE			 111
#define X509_F_X509_LOAD_CRL_FILE			 112
#define X509_F_X509_NAME_ADD_ENTRY			 113
#define X509_F_X509_NAME_ENTRY_CREATE_BY_NID		 114
#define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT		 131
#define X509_F_X509_NAME_ENTRY_SET_OBJECT		 115
#define X509_F_X509_NAME_ONELINE			 116
#define X509_F_X509_NAME_PRINT				 117
#define X509_F_X509_PRINT_EX_FP				 118
#define X509_F_X509_PUBKEY_GET				 119
#define X509_F_X509_PUBKEY_SET				 120
#define X509_F_X509_REQ_CHECK_PRIVATE_KEY		 144
#define X509_F_X509_REQ_PRINT_EX			 121
#define X509_F_X509_REQ_PRINT_FP			 122
#define X509_F_X509_REQ_TO_X509				 123
#define X509_F_X509_STORE_ADD_CERT			 124
#define X509_F_X509_STORE_ADD_CRL			 125
#define X509_F_X509_STORE_CTX_GET1_ISSUER		 146
#define X509_F_X509_STORE_CTX_INIT			 143
#define X509_F_X509_STORE_CTX_NEW			 142
#define X509_F_X509_STORE_CTX_PURPOSE_INHERIT		 134
#define X509_F_X509_TO_X509_REQ				 126
#define X509_F_X509_TRUST_ADD				 133
#define X509_F_X509_TRUST_SET				 141
#define X509_F_X509_VERIFY_CERT				 127

/* Reason codes. */
#define X509_R_BAD_X509_FILETYPE			 100
#define X509_R_BASE64_DECODE_ERROR			 118
#define X509_R_CANT_CHECK_DH_KEY			 114
#define X509_R_CERT_ALREADY_IN_HASH_TABLE		 101
#define X509_R_ERR_ASN1_LIB				 102
#define X509_R_INVALID_DIRECTORY			 113
#define X509_R_INVALID_FIELD_NAME			 119
#define X509_R_INVALID_TRUST				 123
#define X509_R_KEY_TYPE_MISMATCH			 115
#define X509_R_KEY_VALUES_MISMATCH			 116
#define X509_R_LOADING_CERT_DIR				 103
#define X509_R_LOADING_DEFAULTS				 104
#define X509_R_METHOD_NOT_SUPPORTED			 124
#define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY		 105
#define X509_R_PUBLIC_KEY_DECODE_ERROR			 125
#define X509_R_PUBLIC_KEY_ENCODE_ERROR			 126
#define X509_R_SHOULD_RETRY				 106
#define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN	 107
#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY		 108
#define X509_R_UNKNOWN_KEY_TYPE				 117
#define X509_R_UNKNOWN_NID				 109
#define X509_R_UNKNOWN_PURPOSE_ID			 121
#define X509_R_UNKNOWN_TRUST_ID				 120
#define X509_R_UNSUPPORTED_ALGORITHM			 111
#define X509_R_WRONG_LOOKUP_TYPE			 112
#define X509_R_WRONG_TYPE				 122

#ifdef  __cplusplus
}
#endif
#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/openssl/opensslconf.h0000644000175000017500000001045412360020705022547 0ustar  #include 
/* crypto/opensslconf.h.in */

/* Generate 80386 code? */
#undef I386_ONLY

#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)
#define ENGINESDIR "/usr/lib/engines"
#define OPENSSLDIR "/etc/ssl"
#endif

#undef OPENSSL_UNISTD
#define OPENSSL_UNISTD 

#undef OPENSSL_EXPORT_VAR_AS_FUNCTION

#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
#define IDEA_INT unsigned int
#endif

#if defined(HEADER_MD2_H) && !defined(MD2_INT)
#define MD2_INT unsigned int
#endif

#if defined(HEADER_RC2_H) && !defined(RC2_INT)
/* I need to put in a mod for the alpha - eay */
#define RC2_INT unsigned int
#endif

#if defined(HEADER_RC4_H)
#if !defined(RC4_INT)
/* using int types make the structure larger but make the code faster
 * on most boxes I have tested - up to %20 faster. */
/*
 * I don't know what does "most" mean, but declaring "int" is a must on:
 * - Intel P6 because partial register stalls are very expensive;
 * - elder Alpha because it lacks byte load/store instructions;
 */
#define RC4_INT unsigned int
#endif
#if !defined(RC4_CHUNK)
/*
 * This enables code handling data aligned at natural CPU word
 * boundary. See crypto/rc4/rc4_enc.c for further details.
 */
#define RC4_CHUNK unsigned long
#endif
#endif

#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
 * %20 speed up (longs are 8 bytes, int's are 4). */
#ifndef DES_LONG
#define DES_LONG unsigned int
#endif
#endif

#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
#define CONFIG_HEADER_BN_H
#undef BN_LLONG

/* Should we define BN_DIV2W here? */

/* Only one for the following should be defined */
#define SIXTY_FOUR_BIT_LONG
#undef SIXTY_FOUR_BIT
#undef THIRTY_TWO_BIT
#endif

#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
#define CONFIG_HEADER_RC4_LOCL_H
/* if this is defined data[i] is used instead of *data, this is a %20
 * speedup on x86 */
#undef RC4_INDEX
#endif

#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
#define CONFIG_HEADER_BF_LOCL_H
#undef BF_PTR
#endif /* HEADER_BF_LOCL_H */

#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
#define CONFIG_HEADER_DES_LOCL_H
#ifndef DES_DEFAULT_OPTIONS
/* the following is tweaked from a config script, that is why it is a
 * protected undef/define */
#ifndef DES_PTR
#undef DES_PTR
#endif

/* This helps C compiler generate the correct code for multiple functional
 * units.  It reduces register dependancies at the expense of 2 more
 * registers */
#ifndef DES_RISC1
#undef DES_RISC1
#endif

#ifndef DES_RISC2
#undef DES_RISC2
#endif

#if defined(DES_RISC1) && defined(DES_RISC2)
YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
#endif

/* Unroll the inner loop, this sometimes helps, sometimes hinders.
 * Very mucy CPU dependant */
#ifndef DES_UNROLL
#define DES_UNROLL
#endif

/* These default values were supplied by
 * Peter Gutman 
 * They are only used if nothing else has been defined */
#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
/* Special defines which change the way the code is built depending on the
   CPU and OS.  For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
   even newer MIPS CPU's, but at the moment one size fits all for
   optimization options.  Older Sparc's work better with only UNROLL, but
   there's no way to tell at compile time what it is you're running on */
 
#if defined( sun )		/* Newer Sparc's */
#  define DES_PTR
#  define DES_RISC1
#  define DES_UNROLL
#elif defined( __ultrix )	/* Older MIPS */
#  define DES_PTR
#  define DES_RISC2
#  define DES_UNROLL
#elif defined( __osf1__ )	/* Alpha */
#  define DES_PTR
#  define DES_RISC2
#elif defined ( _AIX )		/* RS6000 */
  /* Unknown */
#elif defined( __hpux )		/* HP-PA */
  /* Unknown */
#elif defined( __aux )		/* 68K */
  /* Unknown */
#elif defined( __dgux )		/* 88K (but P6 in latest boxes) */
#  define DES_UNROLL
#elif defined( __sgi )		/* Newer MIPS */
#  define DES_PTR
#  define DES_RISC2
#  define DES_UNROLL
#elif defined(i386) || defined(__i386__)	/* x86 boxes, should be gcc */
#  define DES_PTR
#  define DES_RISC1
#  define DES_UNROLL
#endif /* Systems-specific speed defines */
#endif

#endif /* DES_DEFAULT_OPTIONS */
#endif /* HEADER_DES_LOCL_H */
deps/libressl-pnacl-sys-2.1.6/libressl/include/pqueue.h0000644000175000017500000000661612360020705020044 0ustar  /* $OpenBSD$ */

/*
 * DTLS implementation written by Nagendra Modadugu
 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
 */
/* ====================================================================
 * Copyright (c) 1999-2005 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. 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.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@OpenSSL.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED 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 THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS 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.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#ifndef HEADER_PQUEUE_H
#define HEADER_PQUEUE_H

typedef struct _pqueue *pqueue;

typedef struct _pitem {
	unsigned char priority[8]; /* 64-bit value in big-endian encoding */
	void *data;
	struct _pitem *next;
} pitem;

typedef struct _pitem *piterator;

pitem *pitem_new(unsigned char *prio64be, void *data);
void   pitem_free(pitem *item);

pqueue pqueue_new(void);
void   pqueue_free(pqueue pq);

pitem *pqueue_insert(pqueue pq, pitem *item);
pitem *pqueue_peek(pqueue pq);
pitem *pqueue_pop(pqueue pq);
pitem *pqueue_find(pqueue pq, unsigned char *prio64be);
pitem *pqueue_iterator(pqueue pq);
pitem *pqueue_next(piterator *iter);

int    pqueue_size(pqueue pq);

#endif /* ! HEADER_PQUEUE_H */
deps/libressl-pnacl-sys-2.1.6/libressl/include/sys/0000755000000000000000000000000012666635521020773 5ustar  rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/include/sys/types.h0000644000175000017500000000035112357736107020530 0ustar  #include_next 

#ifndef LIBCRYPTOCOMPAT_SYS_TYPES_H
#define LIBCRYPTOCOMPAT_SYS_TYPES_H

#include 

#if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__bounded__)
# define __bounded__(x, y, z)
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/string.h0000644000175000017500000000114212357514212020042 0ustar  #include_next 

#ifndef LIBCRYPTOCOMPAT_STRING_H
#define LIBCRYPTOCOMPAT_STRING_H

#include 

#ifdef __sun
/* Some functions historically defined in string.h were placed in strings.h by
 * SUS. Use the same hack as OS X and FreeBSD use to work around on Solaris.
 */
#include 
#endif

size_t strlcpy(char *dst, const char *src, size_t siz);

size_t strlcat(char *dst, const char *src, size_t siz);

void explicit_bzero(void *, size_t);

int timingsafe_bcmp(const void *b1, const void *b2, size_t n);

int timingsafe_memcmp(const void *b1, const void *b2, size_t len);

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/machine/0000755000000000000000000000000012666635521021561 5ustar  rootrootdeps/libressl-pnacl-sys-2.1.6/libressl/include/machine/endian.h0000644000175000017500000000032312357514212021376 0ustar  #ifndef _COMPAT_BYTE_ORDER_H_
#define _COMPAT_BYTE_ORDER_H_

#ifdef __linux__
#include 
#else
#ifdef __sun
#include 
#else
#include_next 
#endif
#endif

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/unistd.h0000644000175000017500000000024412357514212020044 0ustar  #include_next 

#ifndef LIBCRYPTOCOMPAT_UNISTD_H
#define LIBCRYPTOCOMPAT_UNISTD_H

int getentropy(void *buf, size_t buflen);
int issetugid(void);

#endif
deps/libressl-pnacl-sys-2.1.6/libressl/include/stdlib.h0000644000175000017500000000057112357514212020022 0ustar  #include_next 

#ifndef LIBCRYPTOCOMPAT_STDLIB_H
#define LIBCRYPTOCOMPAT_STDLIB_H

#include 
#include 
#include 

uint32_t arc4random(void);
void arc4random_buf(void *_buf, size_t n);
void *reallocarray(void *, size_t, size_t);
long long strtonum(const char *nptr, long long minval,
		long long maxval, const char **errstr);

#endif
deps/libressl-pnacl-sys-2.1.6/lib.rs0000664000175000017500000000015612451457301014243 0ustar  
#[link(name = "crypto", kind = "static")]
#[link(name = "ssl", kind = "static")]
extern {}

pub fn stub() {}
deps/libressl-pnacl-sys-2.1.6/.gitignore0000664000175000017500000000005712440476312015120 0ustar  target/
Cargo.lock
*~
libressl/autom4te.cache/
deps/libressl-pnacl-sys-2.1.6/Cargo.toml0000664000175000017500000000061112550302034015043 0ustar  [package]
name = "libressl-pnacl-sys"
version = "2.1.6"
authors = ["Richard Diamond "]
build = "build.rs"
description = "openssl linking provider for PNaCl/NaCl targets."
license = "MIT"
repository = "https://github.com/DiamondLovesYou/libressl-pnacl-sys"

[lib]
name = "libressl_pnacl_sys"
path = "lib.rs"

[build-dependencies.pnacl-build-helper]
version = "1.4"
deps/libressl-pnacl-sys-2.1.6/nacl.patch0000664000175000017500000004151512430033535015065 0ustar  diff -uNr --unidirectional-new-file '--exclude=.git' '--exclude=Cargo.toml' '--exclude=build.rs' ./configure /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/configure
--- ./configure	2014-07-11 12:42:02.000000000 -0500
+++ /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/configure	2014-08-10 15:49:54.979174464 -0500
@@ -698,6 +698,8 @@
 LDFLAGS
 CFLAGS
 CC
+TARGET_NACL_FALSE
+TARGET_NACL_TRUE
 TARGET_SOLARIS_FALSE
 TARGET_SOLARIS_TRUE
 TARGET_LINUX_FALSE
@@ -2908,28 +2910,33 @@
 
 USER_CFLAGS="-O2 $CFLAGS"
 
-CFLAGS="$CFLAGS -Wall -Werror -std=c99 -g -Wno-pointer-sign"
+CFLAGS="$CFLAGS -Wall -Werror -g -Wno-pointer-sign"
 
 case $target_os in
 	*darwin*)
 		TARGET_OS=darwin;
 		LDFLAGS="$LDFLAGS -Qunused-arguments"
+                CFLAGS="$CFLAGS -std=c99"
 		;;
 	*linux*)
 		TARGET_OS=linux;
-		CFLAGS="$CFLAGS -D_BSD_SOURCE -D_POSIX_SOURCE -D_GNU_SOURCE"
+		CFLAGS="$CFLAGS -D_BSD_SOURCE -D_POSIX_SOURCE -D_GNU_SOURCE -std=c99"
 		;;
 	*solaris*)
 		TARGET_OS=solaris;
-		CFLAGS="$CFLAGS -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 -DBSD_COMP"
+		CFLAGS="$CFLAGS -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 -DBSD_COMP -std=c99"
 		PLATFORM_LDADD='-lnsl -lsocket'
 
 		;;
 	*openbsd*)
+                CFLAGS="$CFLAGS -std=c99"
 
 $as_echo "#define HAVE_ATTRIBUTE__BOUNDED__ 1" >>confdefs.h
 
 		;;
+        *nacl*)
+                TARGET_OS=nacl;
+                ;;
 	*) ;;
 esac
 
@@ -2957,6 +2964,14 @@
   TARGET_SOLARIS_FALSE=
 fi
 
+ if test x$TARGET_OS = xnacl; then
+  TARGET_NACL_TRUE=
+  TARGET_NACL_FALSE='#'
+else
+  TARGET_NACL_TRUE='#'
+  TARGET_NACL_FALSE=
+fi
+
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -12671,6 +12686,10 @@
   as_fn_error $? "conditional \"TARGET_SOLARIS\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${TARGET_NACL_TRUE}" && test -z "${TARGET_NACL_FALSE}"; then
+  as_fn_error $? "conditional \"TARGET_NACL\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
   as_fn_error $? "conditional \"AMDEP\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff -uNr --unidirectional-new-file '--exclude=.git' '--exclude=Cargo.toml' '--exclude=build.rs' ./configure.ac /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/configure.ac
--- ./configure.ac	2014-07-11 11:16:40.000000000 -0500
+++ /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/configure.ac	2014-07-23 15:37:20.260466865 -0500
@@ -6,31 +6,37 @@
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
 AC_SUBST([USER_CFLAGS], "-O2 $CFLAGS")
-CFLAGS="$CFLAGS -Wall -Werror -std=c99 -g -Wno-pointer-sign"
+CFLAGS="$CFLAGS -Wall -Werror -g -Wno-pointer-sign"
 
 case $target_os in
 	*darwin*)
 		TARGET_OS=darwin;
 		LDFLAGS="$LDFLAGS -Qunused-arguments"
+                CFLAGS="$CFLAGS -std=c99"
 		;;
 	*linux*)
 		TARGET_OS=linux;
-		CFLAGS="$CFLAGS -D_BSD_SOURCE -D_POSIX_SOURCE -D_GNU_SOURCE"
+		CFLAGS="$CFLAGS -D_BSD_SOURCE -D_POSIX_SOURCE -D_GNU_SOURCE -std=c99"
 		;;
 	*solaris*)
 		TARGET_OS=solaris;
-		CFLAGS="$CFLAGS -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 -DBSD_COMP"
+		CFLAGS="$CFLAGS -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 -DBSD_COMP -std=c99"
 		AC_SUBST([PLATFORM_LDADD], ['-lnsl -lsocket'])
 		;;
 	*openbsd*)
+                CFLAGS="$CFLAGS -std=c99"
 		AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD gcc has bounded])
 		;;
+        *nacl*)
+                TARGET_OS=nacl;
+                ;;
 	*) ;;
 esac
 
 AM_CONDITIONAL(TARGET_DARWIN, test x$TARGET_OS = xdarwin)
 AM_CONDITIONAL(TARGET_LINUX, test x$TARGET_OS = xlinux)
 AM_CONDITIONAL(TARGET_SOLARIS, test x$TARGET_OS = xsolaris)
+AM_CONDITIONAL(TARGET_NACL, test x$TARGET_OS = xnacl)
 
 AC_PROG_CC
 AC_PROG_LIBTOOL
diff -uNr --unidirectional-new-file '--exclude=.git' '--exclude=Cargo.toml' '--exclude=build.rs' ./crypto/bio/b_sock.c /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/crypto/bio/b_sock.c
--- ./crypto/bio/b_sock.c	2014-07-11 12:41:25.000000000 -0500
+++ /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/crypto/bio/b_sock.c	2014-07-23 15:37:20.273800198 -0500
@@ -462,5 +462,8 @@
 int
 BIO_socket_nbio(int s, int mode)
 {
+#ifdef __pnacl__
+#define FIONBIO		0x5421
+#endif
 	return (BIO_socket_ioctl(s, FIONBIO, &mode) == 0);
 }
diff -uNr --unidirectional-new-file '--exclude=.git' '--exclude=Cargo.toml' '--exclude=build.rs' ./crypto/bio/bss_bio.c /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/crypto/bio/bss_bio.c
--- ./crypto/bio/bss_bio.c	2014-07-11 12:41:25.000000000 -0500
+++ /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/crypto/bio/bss_bio.c	2014-07-23 15:37:20.277133532 -0500
@@ -293,6 +293,10 @@
 	return num;
 }
 
+#ifdef __pnacl__
+#define SSIZE_MAX LONG_MAX
+#endif
+
 static ssize_t
 bio_nread(BIO *bio, char **buf, size_t num_)
 {
diff -uNr --unidirectional-new-file '--exclude=.git' '--exclude=Cargo.toml' '--exclude=build.rs' ./crypto/bio/bss_log.c /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/crypto/bio/bss_log.c
--- ./crypto/bio/bss_log.c	2014-07-11 12:41:25.000000000 -0500
+++ /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/crypto/bio/bss_log.c	2014-07-23 15:37:20.277133532 -0500
@@ -65,7 +65,9 @@
 #include 
 #include 
 #include 
+#ifndef __pnacl__
 #include 
+#endif
 
 #include 
 #include 
diff -uNr --unidirectional-new-file '--exclude=.git' '--exclude=Cargo.toml' '--exclude=build.rs' ./crypto/compat/getentropy_nacl.c /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/crypto/compat/getentropy_nacl.c
--- ./crypto/compat/getentropy_nacl.c	1969-12-31 18:00:00.000000000 -0600
+++ /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/crypto/compat/getentropy_nacl.c	2014-07-23 15:37:20.283800198 -0500
@@ -0,0 +1,98 @@
+/*	$OpenBSD: getentropy_linux.c,v 1.17 2014/07/08 09:30:33 beck Exp $	*/
+
+/*
+ * Copyright (c) 2014 Theo de Raadt 
+ * Copyright (c) 2014 Richard Diamond 
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* NOTE: There is no fallback. Don't try to write one. If we can't access the
+ * virtual /dev/urandom, we return -1. End of story.
+ */
+
+/*
+ * Basic sanity checking; wish we could do better.
+ */
+static int
+gotdata(char *buf, size_t len)
+{
+	char	any_set = 0;
+	size_t	i;
+
+	for (i = 0; i < len; ++i)
+		any_set |= buf[i];
+	if (any_set == 0)
+		return -1;
+	return 0;
+}
+
+int getentropy(void *buf, size_t len)
+{
+	struct stat st;
+	size_t i;
+	int fd, flags;
+	int save_errno = errno;
+
+start:
+
+        flags = O_RDONLY;
+#ifdef O_NOFOLLOW
+        flags |= O_NOFOLLOW;
+#endif
+#ifdef O_CLOEXEC
+        flags |= O_CLOEXEC;
+#endif
+	fd = open("/dev/urandom", flags, 0);
+	if (fd == -1) {
+		if (errno == EINTR)
+			goto start;
+		goto nodevrandom;
+	}
+#ifndef O_CLOEXEC
+	fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
+#endif
+
+	/* Lightly verify that the device node looks sane */
+	if (fstat(fd, &st) == -1 || !S_ISCHR(st.st_mode)) {
+		close(fd);
+		goto nodevrandom;
+	}
+	for (i = 0; i < len; ) {
+		size_t wanted = len - i;
+		ssize_t ret = read(fd, buf + i, wanted);
+
+		if (ret == -1) {
+			if (errno == EAGAIN || errno == EINTR)
+				continue;
+			close(fd);
+			goto nodevrandom;
+		}
+		i += ret;
+	}
+	close(fd);
+	if (gotdata(buf, len) == 0) {
+		errno = save_errno;
+		return 0;		/* satisfied */
+	}
+nodevrandom:
+	errno = EIO;
+	return -1;
+}
diff -uNr --unidirectional-new-file '--exclude=.git' '--exclude=Cargo.toml' '--exclude=build.rs' ./crypto/Makefile.am /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/crypto/Makefile.am
--- ./crypto/Makefile.am	2014-07-11 12:41:27.000000000 -0500
+++ /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/crypto/Makefile.am	2014-07-23 15:37:20.260466865 -0500
@@ -53,6 +53,9 @@
 if TARGET_SOLARIS
 libcompat_la_SOURCES += compat/getentropy_solaris.c
 endif
+if TARGET_NACL
+libcompat_la_SOURCES += compat/getentropy_nacl.c
+endif
 endif
 
 endif
diff -uNr --unidirectional-new-file '--exclude=.git' '--exclude=Cargo.toml' '--exclude=build.rs' ./crypto/Makefile.in /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/crypto/Makefile.in
--- ./crypto/Makefile.in	2014-07-11 12:42:04.000000000 -0500
+++ /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/crypto/Makefile.in	2014-07-25 13:55:06.225534475 -0500
@@ -91,7 +91,8 @@
 @NO_ARC4RANDOM_BUF_TRUE@@NO_GETENTROPY_TRUE@@TARGET_LINUX_TRUE@am__append_7 = compat/getentropy_linux.c
 @NO_ARC4RANDOM_BUF_TRUE@@NO_GETENTROPY_TRUE@@TARGET_DARWIN_TRUE@am__append_8 = compat/getentropy_osx.c
 @NO_ARC4RANDOM_BUF_TRUE@@NO_GETENTROPY_TRUE@@TARGET_SOLARIS_TRUE@am__append_9 = compat/getentropy_solaris.c
-@NO_ISSETUGID_TRUE@am__append_10 = compat/issetugid_linux.c
+@NO_ARC4RANDOM_BUF_TRUE@@NO_GETENTROPY_TRUE@@TARGET_NACL_TRUE@am__append_10 = compat/getentropy_nacl.c
+@NO_ISSETUGID_TRUE@am__append_11 = compat/issetugid_linux.c
 subdir = crypto
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -137,7 +138,8 @@
 	compat/reallocarray.c compat/timingsafe_memcmp.c \
 	compat/timingsafe_bcmp.c compat/arc4random.c \
 	compat/getentropy_linux.c compat/getentropy_osx.c \
-	compat/getentropy_solaris.c compat/issetugid_linux.c
+	compat/getentropy_solaris.c compat/getentropy_nacl.c \
+	compat/issetugid_linux.c
 am__dirstamp = $(am__leading_dot)dirstamp
 @NO_STRLCAT_TRUE@am__objects_1 = compat/libcompat_la-strlcat.lo
 @NO_STRLCPY_TRUE@am__objects_2 = compat/libcompat_la-strlcpy.lo
@@ -150,12 +152,13 @@
 @NO_ARC4RANDOM_BUF_TRUE@@NO_GETENTROPY_TRUE@@TARGET_LINUX_TRUE@am__objects_7 = compat/libcompat_la-getentropy_linux.lo
 @NO_ARC4RANDOM_BUF_TRUE@@NO_GETENTROPY_TRUE@@TARGET_DARWIN_TRUE@am__objects_8 = compat/libcompat_la-getentropy_osx.lo
 @NO_ARC4RANDOM_BUF_TRUE@@NO_GETENTROPY_TRUE@@TARGET_SOLARIS_TRUE@am__objects_9 = compat/libcompat_la-getentropy_solaris.lo
-@NO_ISSETUGID_TRUE@am__objects_10 =  \
+@NO_ARC4RANDOM_BUF_TRUE@@NO_GETENTROPY_TRUE@@TARGET_NACL_TRUE@am__objects_10 = compat/libcompat_la-getentropy_nacl.lo
+@NO_ISSETUGID_TRUE@am__objects_11 =  \
 @NO_ISSETUGID_TRUE@	compat/libcompat_la-issetugid_linux.lo
 am_libcompat_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
 	$(am__objects_3) $(am__objects_4) $(am__objects_5) \
 	$(am__objects_6) $(am__objects_7) $(am__objects_8) \
-	$(am__objects_9) $(am__objects_10)
+	$(am__objects_9) $(am__objects_10) $(am__objects_11)
 libcompat_la_OBJECTS = $(am_libcompat_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -663,7 +666,7 @@
 libcompat_la_SOURCES = $(am__append_1) $(am__append_2) $(am__append_3) \
 	$(am__append_4) $(am__append_5) $(am__append_6) \
 	$(am__append_7) $(am__append_8) $(am__append_9) \
-	$(am__append_10)
+	$(am__append_10) $(am__append_11)
 noinst_HEADERS = des/ncbc_enc.c compat/thread_private.h \
 	compat/chacha_private.h cryptlib.h md32_common.h o_time.h \
 	aes/aes_locl.h asn1/asn1_locl.h asn1/charmap.h bf/bf_locl.h \
@@ -924,6 +927,8 @@
 	compat/$(DEPDIR)/$(am__dirstamp)
 compat/libcompat_la-getentropy_solaris.lo: compat/$(am__dirstamp) \
 	compat/$(DEPDIR)/$(am__dirstamp)
+compat/libcompat_la-getentropy_nacl.lo: compat/$(am__dirstamp) \
+	compat/$(DEPDIR)/$(am__dirstamp)
 compat/libcompat_la-issetugid_linux.lo: compat/$(am__dirstamp) \
 	compat/$(DEPDIR)/$(am__dirstamp)
 
@@ -2527,6 +2532,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@comp/$(DEPDIR)/libcrypto_la-comp_lib.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-arc4random.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-getentropy_linux.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-getentropy_nacl.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-getentropy_osx.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-getentropy_solaris.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@compat/$(DEPDIR)/libcompat_la-issetugid_linux.Plo@am__quote@
@@ -2984,6 +2990,13 @@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -c -o compat/libcompat_la-getentropy_solaris.lo `test -f 'compat/getentropy_solaris.c' || echo '$(srcdir)/'`compat/getentropy_solaris.c
 
+compat/libcompat_la-getentropy_nacl.lo: compat/getentropy_nacl.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -MT compat/libcompat_la-getentropy_nacl.lo -MD -MP -MF compat/$(DEPDIR)/libcompat_la-getentropy_nacl.Tpo -c -o compat/libcompat_la-getentropy_nacl.lo `test -f 'compat/getentropy_nacl.c' || echo '$(srcdir)/'`compat/getentropy_nacl.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) compat/$(DEPDIR)/libcompat_la-getentropy_nacl.Tpo compat/$(DEPDIR)/libcompat_la-getentropy_nacl.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='compat/getentropy_nacl.c' object='compat/libcompat_la-getentropy_nacl.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -c -o compat/libcompat_la-getentropy_nacl.lo `test -f 'compat/getentropy_nacl.c' || echo '$(srcdir)/'`compat/getentropy_nacl.c
+
 compat/libcompat_la-issetugid_linux.lo: compat/issetugid_linux.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcompat_la_CFLAGS) $(CFLAGS) -MT compat/libcompat_la-issetugid_linux.lo -MD -MP -MF compat/$(DEPDIR)/libcompat_la-issetugid_linux.Tpo -c -o compat/libcompat_la-issetugid_linux.lo `test -f 'compat/issetugid_linux.c' || echo '$(srcdir)/'`compat/issetugid_linux.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) compat/$(DEPDIR)/libcompat_la-issetugid_linux.Tpo compat/$(DEPDIR)/libcompat_la-issetugid_linux.Plo
diff -uNr --unidirectional-new-file '--exclude=.git' '--exclude=Cargo.toml' '--exclude=build.rs' ./crypto/o_str.c /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/crypto/o_str.c
--- ./crypto/o_str.c	2014-07-11 12:41:25.000000000 -0500
+++ /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/crypto/o_str.c	2014-07-23 15:37:20.307133533 -0500
@@ -11,11 +11,26 @@
 int
 OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n)
 {
+#if !defined(__pnacl__)
 	return strncasecmp(str1, str2, n);
+#else
+        size_t i = 0;
+        for(; str1[i] == str2[i] &&
+              str1[i] != '\0' && str2[i] != '\0' &&
+              i < n; ++i) { }
+        return (int)(str1[i] - str2[i]);
+#endif
 }
 
 int
 OPENSSL_strcasecmp(const char *str1, const char *str2)
 {
+#if !defined(__pnacl__)
 	return strcasecmp(str1, str2);
+#else
+        size_t i = 0;
+        for(; str1[i] == str2[i] &&
+              str1[i] != '\0' && str2[i] != '\0'; ++i) { }
+        return (int)(str1[i] - str2[i]);
+#endif
 }
diff -uNr --unidirectional-new-file '--exclude=.git' '--exclude=Cargo.toml' '--exclude=build.rs' ./crypto/rand/randfile.c /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/crypto/rand/randfile.c
--- ./crypto/rand/randfile.c	2014-07-11 12:41:26.000000000 -0500
+++ /home/dick/workspace/src/hahbee/engine/deps/ppapi/deps/libressl-2.0.0/crypto/rand/randfile.c	2014-07-23 15:37:20.313800200 -0500
@@ -67,6 +67,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #undef BUFSIZE
deps/libressl-pnacl-sys-2.1.6/build.rs0000664000175000017500000000276712504762052014607 0ustar  // Copyright (c) 2014 Richard Diamond & contributors.
//
// This file is part of the Rust PPApi project.
//
// Rust PPApi is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Rust PPApi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Rust PPApi. If not, see .

extern crate pnacl_build_helper as helper;

use std::env::current_dir;
use std::path::Path;

pub fn main() {
    let libs = [(Path::new("ssl/.libs/").to_path_buf(),
                 "ssl:static".to_string()),
                (Path::new("crypto/.libs/").to_path_buf(),
                 "crypto:static".to_string())];
    let mut src_dir = current_dir()
        .unwrap();
    src_dir.push("libressl");

    let mut cfg = helper::ConfigureMake::new
        (&["--disable-shared".to_string(),
           "--without-pic".to_string(),
           "CFLAGS=-DNO_SYSLOG".to_string()],
         &libs,
         src_dir);

    cfg.make_only_dir(Path::new("ssl").to_path_buf())
        .make_only_dir(Path::new("crypto").to_path_buf());

    cfg.configure();
    cfg.make();
}
deps/log-0.3.4/0000755000000000000000000000000012666635521011744 5ustar  rootrootdeps/log-0.3.4/LICENSE-APACHE0000664000175000017500000002513712443132316012107 0ustar                                Apache License
                        Version 2.0, January 2004
                     http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

   "License" shall mean the terms and conditions for use, reproduction,
   and distribution as defined by Sections 1 through 9 of this document.

   "Licensor" shall mean the copyright owner or entity authorized by
   the copyright owner that is granting the License.

   "Legal Entity" shall mean the union of the acting entity and all
   other entities that control, are controlled by, or are under common
   control with that entity. For the purposes of this definition,
   "control" means (i) the power, direct or indirect, to cause the
   direction or management of such entity, whether by contract or
   otherwise, or (ii) ownership of fifty percent (50%) or more of the
   outstanding shares, or (iii) beneficial ownership of such entity.

   "You" (or "Your") shall mean an individual or Legal Entity
   exercising permissions granted by this License.

   "Source" form shall mean the preferred form for making modifications,
   including but not limited to software source code, documentation
   source, and configuration files.

   "Object" form shall mean any form resulting from mechanical
   transformation or translation of a Source form, including but
   not limited to compiled object code, generated documentation,
   and conversions to other media types.

   "Work" shall mean the work of authorship, whether in Source or
   Object form, made available under the License, as indicated by a
   copyright notice that is included in or attached to the work
   (an example is provided in the Appendix below).

   "Derivative Works" shall mean any work, whether in Source or Object
   form, that is based on (or derived from) the Work and for which the
   editorial revisions, annotations, elaborations, or other modifications
   represent, as a whole, an original work of authorship. For the purposes
   of this License, Derivative Works shall not include works that remain
   separable from, or merely link (or bind by name) to the interfaces of,
   the Work and Derivative Works thereof.

   "Contribution" shall mean any work of authorship, including
   the original version of the Work and any modifications or additions
   to that Work or Derivative Works thereof, that is intentionally
   submitted to Licensor for inclusion in the Work by the copyright owner
   or by an individual or Legal Entity authorized to submit on behalf of
   the copyright owner. For the purposes of this definition, "submitted"
   means any form of electronic, verbal, or written communication sent
   to the Licensor or its representatives, including but not limited to
   communication on electronic mailing lists, source code control systems,
   and issue tracking systems that are managed by, or on behalf of, the
   Licensor for the purpose of discussing and improving the Work, but
   excluding communication that is conspicuously marked or otherwise
   designated in writing by the copyright owner as "Not a Contribution."

   "Contributor" shall mean Licensor and any individual or Legal Entity
   on behalf of whom a Contribution has been received by Licensor and
   subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
   this License, each Contributor hereby grants to You a perpetual,
   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
   copyright license to reproduce, prepare Derivative Works of,
   publicly display, publicly perform, sublicense, and distribute the
   Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
   this License, each Contributor hereby grants to You a perpetual,
   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
   (except as stated in this section) patent license to make, have made,
   use, offer to sell, sell, import, and otherwise transfer the Work,
   where such license applies only to those patent claims licensable
   by such Contributor that are necessarily infringed by their
   Contribution(s) alone or by combination of their Contribution(s)
   with the Work to which such Contribution(s) was submitted. If You
   institute patent litigation against any entity (including a
   cross-claim or counterclaim in a lawsuit) alleging that the Work
   or a Contribution incorporated within the Work constitutes direct
   or contributory patent infringement, then any patent licenses
   granted to You under this License for that Work shall terminate
   as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
   Work or Derivative Works thereof in any medium, with or without
   modifications, and in Source or Object form, provided that You
   meet the following conditions:

   (a) You must give any other recipients of the Work or
       Derivative Works a copy of this License; and

   (b) You must cause any modified files to carry prominent notices
       stating that You changed the files; and

   (c) You must retain, in the Source form of any Derivative Works
       that You distribute, all copyright, patent, trademark, and
       attribution notices from the Source form of the Work,
       excluding those notices that do not pertain to any part of
       the Derivative Works; and

   (d) If the Work includes a "NOTICE" text file as part of its
       distribution, then any Derivative Works that You distribute must
       include a readable copy of the attribution notices contained
       within such NOTICE file, excluding those notices that do not
       pertain to any part of the Derivative Works, in at least one
       of the following places: within a NOTICE text file distributed
       as part of the Derivative Works; within the Source form or
       documentation, if provided along with the Derivative Works; or,
       within a display generated by the Derivative Works, if and
       wherever such third-party notices normally appear. The contents
       of the NOTICE file are for informational purposes only and
       do not modify the License. You may add Your own attribution
       notices within Derivative Works that You distribute, alongside
       or as an addendum to the NOTICE text from the Work, provided
       that such additional attribution notices cannot be construed
       as modifying the License.

   You may add Your own copyright statement to Your modifications and
   may provide additional or different license terms and conditions
   for use, reproduction, or distribution of Your modifications, or
   for any such Derivative Works as a whole, provided Your use,
   reproduction, and distribution of the Work otherwise complies with
   the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
   names, trademarks, service marks, or product names of the Licensor,
   except as required for reasonable and customary use in describing the
   origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
   agreed to in writing, Licensor provides the Work (and each
   Contributor provides its Contributions) on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
   implied, including, without limitation, any warranties or conditions
   of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
   PARTICULAR PURPOSE. You are solely responsible for determining the
   appropriateness of using or redistributing the Work and assume any
   risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
   whether in tort (including negligence), contract, or otherwise,
   unless required by applicable law (such as deliberate and grossly
   negligent acts) or agreed to in writing, shall any Contributor be
   liable to You for damages, including any direct, indirect, special,
   incidental, or consequential damages of any character arising as a
   result of this License or out of the use or inability to use the
   Work (including but not limited to damages for loss of goodwill,
   work stoppage, computer failure or malfunction, or any and all
   other commercial damages or losses), even if such Contributor
   has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
   the Work or Derivative Works thereof, You may choose to offer,
   and charge a fee for, acceptance of support, warranty, indemnity,
   or other liability obligations and/or rights consistent with this
   License. However, in accepting such obligations, You may act only
   on Your own behalf and on Your sole responsibility, not on behalf
   of any other Contributor, and only if You agree to indemnify,
   defend, and hold each Contributor harmless for any liability
   incurred by, or claims asserted against, such Contributor by reason
   of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

   To apply the Apache License to your work, attach the following
   boilerplate notice, with the fields enclosed by brackets "[]"
   replaced with your own identifying information. (Don't include
   the brackets!)  The text should be enclosed in the appropriate
   comment syntax for the file format. We also recommend that a
   file or class name and description of purpose be included on the
   same "printed page" as the copyright notice for easier
   identification within third-party archives.

Copyright [yyyy] [name of copyright owner]

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.
deps/log-0.3.4/LICENSE-MIT0000664000175000017500000000205712443132316011613 0ustar  Copyright (c) 2014 The Rust Project Developers

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
deps/log-0.3.4/.travis.yml0000664000175000017500000000201212616224526012266 0ustar  language: rust
sudo: false
rust:
  - 1.0.0
  - stable
  - beta
  - nightly
script:
  - cargo build --verbose
  - cargo test --verbose
  - cargo test --verbose --manifest-path env/Cargo.toml
  - cargo run --verbose --manifest-path tests/max_level_features/Cargo.toml
  - cargo run --verbose --manifest-path tests/max_level_features/Cargo.toml --release
  - cargo doc --manifest-path env/Cargo.toml
after_success: |
  [ $TRAVIS_BRANCH = master ] &&
  [ $TRAVIS_PULL_REQUEST = false ] &&
  [ $TRAVIS_RUST_VERSION = nightly ] &&
  echo '' > env/target/doc/index.html &&
  pip install ghp-import --user $USER &&
  $HOME/.local/bin/ghp-import -n env/target/doc &&
  git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
env:
  global:
    secure: bNUxFmA5uEdKKdVDtgb+5WQuMRDZ6QxK5152sIZWSimxyr/x5erNZ1uacPh02Ng92dbUQ66wz90WPmqTwoL0EeJ/FmZDd29hRHXe82MNpz47QX3cGMgFNldQ2GmJmCHBXKu373B80o/ZB+BTVcYcl1ksTXuIhQg2wZtXh8bZ9F4=
notifications:
  email:
    on_success: never
deps/log-0.3.4/README.md0000664000175000017500000000770112600115146011434 0ustar  log
===

A Rust library providing a lightweight logging *facade*.

[![Build Status](https://travis-ci.org/rust-lang-nursery/log.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/log)
[![Build status](https://ci.appveyor.com/api/projects/status/nopdjmmjt45xcrki?svg=true)](https://ci.appveyor.com/project/alexcrichton/log)

* [`log` documentation](https://doc.rust-lang.org/log)
* [`env_logger` documentation](https://doc.rust-lang.org/log/env_logger)

A logging facade provides a single logging API that abstracts over the actual
logging implementation. Libraries can use the logging API provided by this
crate, and the consumer of those libraries can choose the logging
implementation that is most suitable for its use case.

## Usage

## In libraries

Libraries should link only to the `log` crate, and use the provided macros to
log whatever information will be useful to downstream consumers:

```toml
[dependencies]
log = "0.3"
```

```rust
#[macro_use]
extern crate log;

pub fn shave_the_yak(yak: &Yak) {
    trace!("Commencing yak shaving");

    loop {
        match find_a_razor() {
            Ok(razor) => {
                info!("Razor located: {}", razor);
                yak.shave(razor);
                break;
            }
            Err(err) => {
                warn!("Unable to locate a razor: {}, retrying", err);
            }
        }
    }
}
```

## In executables

Executables should choose a logger implementation and initialize it early in the
runtime of the program. Logger implementations will typically include a
function to do this. Any log messages generated before the logger is
initialized will be ignored.

The executable itself may use the `log` crate to log as well.

The `env_logger` crate provides a logger implementation that mirrors the
functionality of the old revision of the `log` crate.

```toml
[dependencies]
log = "0.3"
env_logger = "0.3"
```

```rust
#[macro_use]
extern crate log;
extern crate env_logger;

fn main() {
    env_logger::init().unwrap();

    info!("starting up");

    // ...
}
```

## In tests

Tests can use the `env_logger` crate to see log messages generated during that test:

```toml
[dependencies]
log = "0.3"

[dev-dependencies]
env_logger = "0.3"
```

```rust
#[macro_use]
extern crate log;

fn add_one(num: i32) -> i32 {
    info!("add_one called with {}", num);
    num + 1
}

#[cfg(test)]
mod tests {
    use super::*;
    extern crate env_logger;

    #[test]
    fn it_adds_one() {
        let _ = env_logger::init();
        info!("can log from the test too");
        assert_eq!(3, add_one(2));
    }

    #[test]
    fn it_handles_negative_numbers() {
        let _ = env_logger::init();
        info!("logging from another test");
        assert_eq!(-7, add_one(-8));
    }
}
```

Assuming the module under test is called `my_lib`, running the tests with the
`RUST_LOG` filtering to info messages from this module looks like:

```bash
$ RUST_LOG=my_lib=info cargo test
     Running target/debug/my_lib-...

running 2 tests
INFO:my_lib::tests: logging from another test
INFO:my_lib: add_one called with -8
test tests::it_handles_negative_numbers ... ok
INFO:my_lib::tests: can log from the test too
INFO:my_lib: add_one called with 2
test tests::it_adds_one ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured
```

Note that `env_logger::init()` needs to be called in each test in which you
want to enable logging. Additionally, the default behavior of tests to
run in parallel means that logging output may be interleaved with test output.
Either run tests in a single thread by specifying `RUST_TEST_THREADS=1` or by
running one test by specifying its name as an argument to the test binaries as
directed by the `cargo test` help docs:

```bash
$ RUST_LOG=my_lib=info cargo test it_adds_one
     Running target/debug/my_lib-...

running 1 test
INFO:my_lib::tests: can log from the test too
INFO:my_lib: add_one called with 2
test tests::it_adds_one ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
```
deps/log-0.3.4/.gitignore0000664000175000017500000000002312461726035012145 0ustar  target/
Cargo.lock
deps/log-0.3.4/src/0000755000000000000000000000000012666635521012533 5ustar  rootrootdeps/log-0.3.4/src/lib.rs0000664000175000017500000006003112625635430012065 0ustar  // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0  or the MIT license
// , at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! A lightweight logging facade.
//!
//! A logging facade provides a single logging API that abstracts over the
//! actual logging implementation. Libraries can use the logging API provided
//! by this crate, and the consumer of those libraries can choose the logging
//! framework that is most suitable for its use case.
//!
//! If no logging implementation is selected, the facade falls back to a "noop"
//! implementation that ignores all log messages. The overhead in this case
//! is very small - just an integer load, comparison and jump.
//!
//! A log request consists of a target, a level, and a body. A target is a
//! string which defaults to the module path of the location of the log
//! request, though that default may be overridden. Logger implementations
//! typically use the target to filter requests based on some user
//! configuration.
//!
//! # Use
//!
//! ## In libraries
//!
//! Libraries should link only to the `log` crate, and use the provided
//! macros to log whatever information will be useful to downstream consumers.
//!
//! ### Examples
//!
//! ```rust
//! # #![allow(unstable)]
//! #[macro_use]
//! extern crate log;
//!
//! # #[derive(Debug)] pub struct Yak(String);
//! # impl Yak { fn shave(&self, _: u32) {} }
//! # fn find_a_razor() -> Result { Ok(1) }
//! pub fn shave_the_yak(yak: &Yak) {
//!     info!(target: "yak_events", "Commencing yak shaving for {:?}", yak);
//!
//!     loop {
//!         match find_a_razor() {
//!             Ok(razor) => {
//!                 info!("Razor located: {}", razor);
//!                 yak.shave(razor);
//!                 break;
//!             }
//!             Err(err) => {
//!                 warn!("Unable to locate a razor: {}, retrying", err);
//!             }
//!         }
//!     }
//! }
//! # fn main() {}
//! ```
//!
//! ## In executables
//!
//! Executables should choose a logging framework and initialize it early in the
//! runtime of the program. Logging frameworks will typically include a
//! function to do this. Any log messages generated before the framework is
//! initialized will be ignored.
//!
//! The executable itself may use the `log` crate to log as well.
//!
//! ### Warning
//!
//! The logging system may only be initialized once.
//!
//! ### Examples
//!
//! ```rust,ignore
//! #[macro_use]
//! extern crate log;
//! extern crate my_logger;
//!
//! fn main() {
//!     my_logger::init();
//!
//!     info!("starting up");
//!
//!     // ...
//! }
//! ```
//!
//! # Logger implementations
//!
//! Loggers implement the `Log` trait. Here's a very basic example that simply
//! logs all messages at the `Error`, `Warn` or `Info` levels to stdout:
//!
//! ```rust
//! extern crate log;
//!
//! use log::{LogRecord, LogLevel, LogMetadata};
//!
//! struct SimpleLogger;
//!
//! impl log::Log for SimpleLogger {
//!     fn enabled(&self, metadata: &LogMetadata) -> bool {
//!         metadata.level() <= LogLevel::Info
//!     }
//!
//!     fn log(&self, record: &LogRecord) {
//!         if self.enabled(record.metadata()) {
//!             println!("{} - {}", record.level(), record.args());
//!         }
//!     }
//! }
//!
//! # fn main() {}
//! ```
//!
//! Loggers are installed by calling the `set_logger` function. It takes a
//! closure which is provided a `MaxLogLevel` token and returns a `Log` trait
//! object. The `MaxLogLevel` token controls the global maximum log level. The
//! logging facade uses this as an optimization to improve performance of log
//! messages at levels that are disabled. In the case of our example logger,
//! we'll want to set the maximum log level to `Info`, since we ignore any
//! `Debug` or `Trace` level log messages. A logging framework should provide a
//! function that wraps a call to `set_logger`, handling initialization of the
//! logger:
//!
//! ```rust
//! # extern crate log;
//! # use log::{LogLevel, LogLevelFilter, SetLoggerError, LogMetadata};
//! # struct SimpleLogger;
//! # impl log::Log for SimpleLogger {
//! #   fn enabled(&self, _: &LogMetadata) -> bool { false }
//! #   fn log(&self, _: &log::LogRecord) {}
//! # }
//! # fn main() {}
//! pub fn init() -> Result<(), SetLoggerError> {
//!     log::set_logger(|max_log_level| {
//!         max_log_level.set(LogLevelFilter::Info);
//!         Box::new(SimpleLogger)
//!     })
//! }
//! ```

#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
       html_favicon_url = "https://www.rust-lang.org/favicon.ico",
       html_root_url = "https://doc.rust-lang.org/log/")]
#![warn(missing_docs)]

extern crate libc;

use std::ascii::AsciiExt;
use std::cmp;
use std::error;
use std::fmt;
use std::mem;
use std::ops::Deref;
use std::str::FromStr;
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
mod macros;

// The setup here is a bit weird to make at_exit work.
//
// There are four different states that we care about: the logger's
// uninitialized, the logger's initializing (set_logger's been called but
// LOGGER hasn't actually been set yet), the logger's active, or the logger's
// shutting down inside of at_exit.
//
// The LOGGER static is normally a Box> with some special possible
// values as well. The uninitialized and initializing states are represented by
// the values 0 and 1 respectively. The shutting down state is also represented
// by 1. Any other value is a valid pointer to the logger.
//
// The at_exit routine needs to make sure that no threads are actively logging
// when it deallocates the logger. The number of actively logging threads is
// tracked in the REFCOUNT static. The routine first sets LOGGER back to 1.
// All logging calls past that point will immediately return without accessing
// the logger. At that point, the at_exit routine just waits for the refcount
// to reach 0 before deallocating the logger. Note that the refcount does not
// necessarily monotonically decrease at this point, as new log calls still
// increment and decrement it, but the interval in between is small enough that
// the wait is really just for the active log calls to finish.
static LOGGER: AtomicUsize = ATOMIC_USIZE_INIT;
static REFCOUNT: AtomicUsize = ATOMIC_USIZE_INIT;

const UNINITIALIZED: usize = 0;
const INITIALIZING: usize = 1;

static MAX_LOG_LEVEL_FILTER: AtomicUsize = ATOMIC_USIZE_INIT;

static LOG_LEVEL_NAMES: [&'static str; 6] = ["OFF", "ERROR", "WARN", "INFO",
                                             "DEBUG", "TRACE"];

/// An enum representing the available verbosity levels of the logging framework
///
/// A `LogLevel` may be compared directly to a `LogLevelFilter`.
#[repr(usize)]
#[derive(Copy, Eq, Debug)]
pub enum LogLevel {
    /// The "error" level.
    ///
    /// Designates very serious errors.
    Error = 1, // This way these line up with the discriminants for LogLevelFilter below
    /// The "warn" level.
    ///
    /// Designates hazardous situations.
    Warn,
    /// The "info" level.
    ///
    /// Designates useful information.
    Info,
    /// The "debug" level.
    ///
    /// Designates lower priority information.
    Debug,
    /// The "trace" level.
    ///
    /// Designates very low priority, often extremely verbose, information.
    Trace,
}

impl Clone for LogLevel {
    #[inline]
    fn clone(&self) -> LogLevel {
        *self
    }
}

impl PartialEq for LogLevel {
    #[inline]
    fn eq(&self, other: &LogLevel) -> bool {
        *self as usize == *other as usize
    }
}

impl PartialEq for LogLevel {
    #[inline]
    fn eq(&self, other: &LogLevelFilter) -> bool {
        *self as usize == *other as usize
    }
}

impl PartialOrd for LogLevel {
    #[inline]
    fn partial_cmp(&self, other: &LogLevel) -> Option {
        Some(self.cmp(other))
    }
}

impl PartialOrd for LogLevel {
    #[inline]
    fn partial_cmp(&self, other: &LogLevelFilter) -> Option {
        Some((*self as usize).cmp(&(*other as usize)))
    }
}

impl Ord for LogLevel {
    #[inline]
    fn cmp(&self, other: &LogLevel) -> cmp::Ordering {
        (*self as usize).cmp(&(*other as usize))
    }
}

fn ok_or(t: Option, e: E) -> Result {
    match t {
        Some(t) => Ok(t),
        None => Err(e),
    }
}

impl FromStr for LogLevel {
    type Err = ();
    fn from_str(level: &str) -> Result {
        ok_or(LOG_LEVEL_NAMES.iter()
                    .position(|&name| name.eq_ignore_ascii_case(level))
                    .into_iter()
                    .filter(|&idx| idx != 0)
                    .map(|idx| LogLevel::from_usize(idx).unwrap())
                    .next(), ())
    }
}

impl fmt::Display for LogLevel {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        fmt.pad(LOG_LEVEL_NAMES[*self as usize])
    }
}

impl LogLevel {
    fn from_usize(u: usize) -> Option {
        match u {
            1 => Some(LogLevel::Error),
            2 => Some(LogLevel::Warn),
            3 => Some(LogLevel::Info),
            4 => Some(LogLevel::Debug),
            5 => Some(LogLevel::Trace),
            _ => None
        }
    }

    /// Returns the most verbose logging level.
    #[inline]
    pub fn max() -> LogLevel {
        LogLevel::Trace
    }

    /// Converts the `LogLevel` to the equivalent `LogLevelFilter`.
    #[inline]
    pub fn to_log_level_filter(&self) -> LogLevelFilter {
        LogLevelFilter::from_usize(*self as usize).unwrap()
    }
}

/// An enum representing the available verbosity level filters of the logging
/// framework.
///
/// A `LogLevelFilter` may be compared directly to a `LogLevel`.
#[repr(usize)]
#[derive(Copy, Eq, Debug)]
pub enum LogLevelFilter {
    /// A level lower than all log levels.
    Off,
    /// Corresponds to the `Error` log level.
    Error,
    /// Corresponds to the `Warn` log level.
    Warn,
    /// Corresponds to the `Info` log level.
    Info,
    /// Corresponds to the `Debug` log level.
    Debug,
    /// Corresponds to the `Trace` log level.
    Trace,
}

// Deriving generates terrible impls of these traits

impl Clone for LogLevelFilter {
    #[inline]
    fn clone(&self) -> LogLevelFilter {
        *self
    }
}

impl PartialEq for LogLevelFilter {
    #[inline]
    fn eq(&self, other: &LogLevelFilter) -> bool {
        *self as usize == *other as usize
    }
}

impl PartialEq for LogLevelFilter {
    #[inline]
    fn eq(&self, other: &LogLevel) -> bool {
        other.eq(self)
    }
}

impl PartialOrd for LogLevelFilter {
    #[inline]
    fn partial_cmp(&self, other: &LogLevelFilter) -> Option {
        Some(self.cmp(other))
    }
}

impl PartialOrd for LogLevelFilter {
    #[inline]
    fn partial_cmp(&self, other: &LogLevel) -> Option {
        other.partial_cmp(self).map(|x| x.reverse())
    }
}

impl Ord for LogLevelFilter {
    #[inline]
    fn cmp(&self, other: &LogLevelFilter) -> cmp::Ordering {
        (*self as usize).cmp(&(*other as usize))
    }
}

impl FromStr for LogLevelFilter {
    type Err = ();
    fn from_str(level: &str) -> Result {
        ok_or(LOG_LEVEL_NAMES.iter()
                    .position(|&name| name.eq_ignore_ascii_case(level))
                    .map(|p| LogLevelFilter::from_usize(p).unwrap()), ())
    }
}

impl fmt::Display for LogLevelFilter {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        write!(fmt, "{}", LOG_LEVEL_NAMES[*self as usize])
    }
}

impl LogLevelFilter {
    fn from_usize(u: usize) -> Option {
        match u {
            0 => Some(LogLevelFilter::Off),
            1 => Some(LogLevelFilter::Error),
            2 => Some(LogLevelFilter::Warn),
            3 => Some(LogLevelFilter::Info),
            4 => Some(LogLevelFilter::Debug),
            5 => Some(LogLevelFilter::Trace),
            _ => None
        }
    }
    /// Returns the most verbose logging level filter.
    #[inline]
    pub fn max() -> LogLevelFilter {
        LogLevelFilter::Trace
    }

    /// Converts `self` to the equivalent `LogLevel`.
    ///
    /// Returns `None` if `self` is `LogLevelFilter::Off`.
    #[inline]
    pub fn to_log_level(&self) -> Option {
        LogLevel::from_usize(*self as usize)
    }
}

/// The "payload" of a log message.
pub struct LogRecord<'a> {
    metadata: LogMetadata<'a>,
    location: &'a LogLocation,
    args: fmt::Arguments<'a>,
}

impl<'a> LogRecord<'a> {
    /// The message body.
    pub fn args(&self) -> &fmt::Arguments<'a> {
        &self.args
    }

    /// Metadata about the log directive.
    pub fn metadata(&self) -> &LogMetadata {
        &self.metadata
    }

    /// The location of the log directive.
    pub fn location(&self) -> &LogLocation {
        self.location
    }

    /// The verbosity level of the message.
    pub fn level(&self) -> LogLevel {
        self.metadata.level()
    }

    /// The name of the target of the directive.
    pub fn target(&self) -> &str {
        self.metadata.target()
    }
}

/// Metadata about a log message.
pub struct LogMetadata<'a> {
    level: LogLevel,
    target: &'a str,
}

impl<'a> LogMetadata<'a> {
    /// The verbosity level of the message.
    pub fn level(&self) -> LogLevel {
        self.level
    }

    /// The name of the target of the directive.
    pub fn target(&self) -> &str {
        self.target
    }
}

/// A trait encapsulating the operations required of a logger
pub trait Log: Sync+Send {
    /// Determines if a log message with the specified metadata would be
    /// logged.
    ///
    /// This is used by the `log_enabled!` macro to allow callers to avoid
    /// expensive computation of log message arguments if the message would be
    /// discarded anyway.
    fn enabled(&self, metadata: &LogMetadata) -> bool;

    /// Logs the `LogRecord`.
    ///
    /// Note that `enabled` is *not* necessarily called before this method.
    /// Implementations of `log` should perform all necessary filtering
    /// internally.
    fn log(&self, record: &LogRecord);
}

/// The location of a log message.
///
/// # Warning
///
/// The fields of this struct are public so that they may be initialized by the
/// `log!` macro. They are subject to change at any time and should never be
/// accessed directly.
#[derive(Copy, Clone, Debug)]
pub struct LogLocation {
    #[doc(hidden)]
    pub __module_path: &'static str,
    #[doc(hidden)]
    pub __file: &'static str,
    #[doc(hidden)]
    pub __line: u32,
}

impl LogLocation {
    /// The module path of the message.
    pub fn module_path(&self) -> &str {
        self.__module_path
    }

    /// The source file containing the message.
    pub fn file(&self) -> &str {
        self.__file
    }

    /// The line containing the message.
    pub fn line(&self) -> u32 {
        self.__line
    }
}

/// A token providing read and write access to the global maximum log level
/// filter.
///
/// The maximum log level is used as an optimization to avoid evaluating log
/// messages that will be ignored by the logger. Any message with a level
/// higher than the maximum log level filter will be ignored. A logger should
/// make sure to keep the maximum log level filter in sync with its current
/// configuration.
#[allow(missing_copy_implementations)]
pub struct MaxLogLevelFilter(());

impl fmt::Debug for MaxLogLevelFilter {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        write!(fmt, "MaxLogLevelFilter")
    }
}

impl MaxLogLevelFilter {
    /// Gets the current maximum log level filter.
    pub fn get(&self) -> LogLevelFilter {
        max_log_level()
    }

    /// Sets the maximum log level.
    pub fn set(&self, level: LogLevelFilter) {
        MAX_LOG_LEVEL_FILTER.store(level as usize, Ordering::SeqCst)
    }
}

/// Returns the current maximum log level.
///
/// The `log!`, `error!`, `warn!`, `info!`, `debug!`, and `trace!` macros check
/// this value and discard any message logged at a higher level. The maximum
/// log level is set by the `MaxLogLevel` token passed to loggers.
#[inline(always)]
pub fn max_log_level() -> LogLevelFilter {
    unsafe { mem::transmute(MAX_LOG_LEVEL_FILTER.load(Ordering::Relaxed)) }
}

/// Sets the global logger.
///
/// The `make_logger` closure is passed a `MaxLogLevel` object, which the
/// logger should use to keep the global maximum log level in sync with the
/// highest log level that the logger will not ignore.
///
/// This function may only be called once in the lifetime of a program. Any log
/// events that occur before the call to `set_logger` completes will be
/// ignored.
///
/// This function does not typically need to be called manually. Logger
/// implementations should provide an initialization method that calls
/// `set_logger` internally.
pub fn set_logger(make_logger: M) -> Result<(), SetLoggerError>
        where M: FnOnce(MaxLogLevelFilter) -> Box {
    if LOGGER.compare_and_swap(UNINITIALIZED, INITIALIZING,
                               Ordering::SeqCst) != UNINITIALIZED {
        return Err(SetLoggerError(()));
    }

    let logger = Box::new(make_logger(MaxLogLevelFilter(())));
    let logger = unsafe { mem::transmute::>, usize>(logger) };
    LOGGER.store(logger, Ordering::SeqCst);

    unsafe {
        assert_eq!(libc::atexit(shutdown), 0);
    }
    return Ok(());

    extern fn shutdown() {
        // Set to INITIALIZING to prevent re-initialization after
        let logger = LOGGER.swap(INITIALIZING, Ordering::SeqCst);

        while REFCOUNT.load(Ordering::SeqCst) != 0 {
            // FIXME add a sleep here when it doesn't involve timers
        }

        unsafe { mem::transmute::>>(logger); }
    }
}

/// The type returned by `set_logger` if `set_logger` has already been called.
#[allow(missing_copy_implementations)]
#[derive(Debug)]
pub struct SetLoggerError(());

impl fmt::Display for SetLoggerError {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        write!(fmt, "attempted to set a logger after the logging system \
                     was already initialized")
    }
}

impl error::Error for SetLoggerError {
    fn description(&self) -> &str { "set_logger() called multiple times" }
}

struct LoggerGuard(usize);

impl Drop for LoggerGuard {
    fn drop(&mut self) {
        REFCOUNT.fetch_sub(1, Ordering::SeqCst);
    }
}

impl Deref for LoggerGuard {
    type Target = Box;

    fn deref(&self) -> &Box {
        unsafe { mem::transmute(self.0) }
    }
}

fn logger() -> Option {
    REFCOUNT.fetch_add(1, Ordering::SeqCst);
    let logger = LOGGER.load(Ordering::SeqCst);
    if logger == UNINITIALIZED || logger == INITIALIZING {
        REFCOUNT.fetch_sub(1, Ordering::SeqCst);
        None
    } else {
        Some(LoggerGuard(logger))
    }
}

// WARNING
// This is not considered part of the crate's public API. It is subject to
// change at any time.
#[doc(hidden)]
pub fn __enabled(level: LogLevel, target: &str) -> bool {
    if let Some(logger) = logger() {
        logger.enabled(&LogMetadata { level: level, target: target })
    } else {
        false
    }
}

// WARNING
// This is not considered part of the crate's public API. It is subject to
// change at any time.
#[doc(hidden)]
pub fn __log(level: LogLevel, target: &str, loc: &LogLocation,
             args: fmt::Arguments) {
    if let Some(logger) = logger() {
        let record = LogRecord {
            metadata: LogMetadata {
                level: level,
                target: target,
            },
            location: loc,
            args: args
        };
        logger.log(&record)
    }
}

// WARNING
// This is not considered part of the crate's public API. It is subject to
// change at any time.
#[inline(always)]
#[doc(hidden)]
pub fn __static_max_level() -> LogLevelFilter {
    if !cfg!(debug_assertions) {
        // This is a release build. Check `release_max_level_*` first.
        if cfg!(feature = "release_max_level_off") {
            return LogLevelFilter::Off
        } else if cfg!(feature = "release_max_level_error") {
            return LogLevelFilter::Error
        } else if cfg!(feature = "release_max_level_warn") {
            return LogLevelFilter::Warn
        } else if cfg!(feature = "release_max_level_info") {
            return LogLevelFilter::Info
        } else if cfg!(feature = "release_max_level_debug") {
            return LogLevelFilter::Debug
        } else if cfg!(feature = "release_max_level_trace") {
            return LogLevelFilter::Trace
        }
    }
    if cfg!(feature = "max_level_off") {
        LogLevelFilter::Off
    } else if cfg!(feature = "max_level_error") {
        LogLevelFilter::Error
    } else if cfg!(feature = "max_level_warn") {
        LogLevelFilter::Warn
    } else if cfg!(feature = "max_level_info") {
        LogLevelFilter::Info
    } else if cfg!(feature = "max_level_debug") {
        LogLevelFilter::Debug
    } else {
        LogLevelFilter::Trace
    }
}

#[cfg(test)]
mod tests {
     use std::error::Error;
     use super::{LogLevel, LogLevelFilter, SetLoggerError};

     #[test]
     fn test_loglevelfilter_from_str() {
         let tests = [
             ("off",   Ok(LogLevelFilter::Off)),
             ("error", Ok(LogLevelFilter::Error)),
             ("warn",  Ok(LogLevelFilter::Warn)),
             ("info",  Ok(LogLevelFilter::Info)),
             ("debug", Ok(LogLevelFilter::Debug)),
             ("trace", Ok(LogLevelFilter::Trace)),
             ("OFF",   Ok(LogLevelFilter::Off)),
             ("ERROR", Ok(LogLevelFilter::Error)),
             ("WARN",  Ok(LogLevelFilter::Warn)),
             ("INFO",  Ok(LogLevelFilter::Info)),
             ("DEBUG", Ok(LogLevelFilter::Debug)),
             ("TRACE", Ok(LogLevelFilter::Trace)),
             ("asdf",  Err(())),
         ];
         for &(s, ref expected) in &tests {
             assert_eq!(expected, &s.parse());
         }
     }

     #[test]
     fn test_loglevel_from_str() {
         let tests = [
             ("OFF",   Err(())),
             ("error", Ok(LogLevel::Error)),
             ("warn",  Ok(LogLevel::Warn)),
             ("info",  Ok(LogLevel::Info)),
             ("debug", Ok(LogLevel::Debug)),
             ("trace", Ok(LogLevel::Trace)),
             ("ERROR", Ok(LogLevel::Error)),
             ("WARN",  Ok(LogLevel::Warn)),
             ("INFO",  Ok(LogLevel::Info)),
             ("DEBUG", Ok(LogLevel::Debug)),
             ("TRACE", Ok(LogLevel::Trace)),
             ("asdf",  Err(())),
         ];
         for &(s, ref expected) in &tests {
             assert_eq!(expected, &s.parse());
         }
     }

     #[test]
     fn test_loglevel_show() {
         assert_eq!("INFO", LogLevel::Info.to_string());
         assert_eq!("ERROR", LogLevel::Error.to_string());
     }

     #[test]
     fn test_loglevelfilter_show() {
         assert_eq!("OFF", LogLevelFilter::Off.to_string());
         assert_eq!("ERROR", LogLevelFilter::Error.to_string());
     }

     #[test]
     fn test_cross_cmp() {
         assert!(LogLevel::Debug > LogLevelFilter::Error);
         assert!(LogLevelFilter::Warn < LogLevel::Trace);
         assert!(LogLevelFilter::Off < LogLevel::Error);
     }

     #[test]
     fn test_cross_eq() {
         assert!(LogLevel::Error == LogLevelFilter::Error);
         assert!(LogLevelFilter::Off != LogLevel::Error);
         assert!(LogLevel::Trace == LogLevelFilter::Trace);
     }

     #[test]
     fn test_to_log_level() {
         assert_eq!(Some(LogLevel::Error), LogLevelFilter::Error.to_log_level());
         assert_eq!(None, LogLevelFilter::Off.to_log_level());
         assert_eq!(Some(LogLevel::Debug), LogLevelFilter::Debug.to_log_level());
     }

     #[test]
     fn test_to_log_level_filter() {
         assert_eq!(LogLevelFilter::Error, LogLevel::Error.to_log_level_filter());
         assert_eq!(LogLevelFilter::Trace, LogLevel::Trace.to_log_level_filter());
     }

     #[test]
     fn test_error_trait() {
         let e = SetLoggerError(());
         assert_eq!(e.description(), "set_logger() called multiple times");
     }
}
deps/log-0.3.4/src/macros.rs0000664000175000017500000001237112616224526012607 0ustar  // Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0  or the MIT license
// , at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
/// The standard logging macro.
///
/// This macro will generically log with the specified `LogLevel` and `format!`
/// based argument list.
///
/// The `max_level_*` features can be used to statically disable logging at
/// various levels.
#[macro_export]
macro_rules! log {
    (target: $target:expr, $lvl:expr, $($arg:tt)+) => ({
        static _LOC: $crate::LogLocation = $crate::LogLocation {
            __line: line!(),
            __file: file!(),
            __module_path: module_path!(),
        };
        let lvl = $lvl;
        if lvl <= $crate::__static_max_level() && lvl <= $crate::max_log_level() {
            $crate::__log(lvl, $target, &_LOC, format_args!($($arg)+))
        }
    });
    ($lvl:expr, $($arg:tt)+) => (log!(target: module_path!(), $lvl, $($arg)+))
}

/// Logs a message at the error level.
///
/// Logging at this level is disabled if the `max_level_off` feature is present.
#[macro_export]
macro_rules! error {
    (target: $target:expr, $($arg:tt)*) => (
        log!(target: $target, $crate::LogLevel::Error, $($arg)*);
    );
    ($($arg:tt)*) => (
        log!($crate::LogLevel::Error, $($arg)*);
    )
}

/// Logs a message at the warn level.
///
/// Logging at this level is disabled if any of the following features are
/// present: `max_level_off` or `max_level_error`.
///
/// When building in release mode (i.e., without the `debug_assertions` option),
/// logging at this level is also disabled if any of the following features are
/// present: `release_max_level_off` or `max_level_error`.
#[macro_export]
macro_rules! warn {
    (target: $target:expr, $($arg:tt)*) => (
        log!(target: $target, $crate::LogLevel::Warn, $($arg)*);
    );
    ($($arg:tt)*) => (
        log!($crate::LogLevel::Warn, $($arg)*);
    )
}

/// Logs a message at the info level.
///
/// Logging at this level is disabled if any of the following features are
/// present: `max_level_off`, `max_level_error`, or `max_level_warn`.
///
/// When building in release mode (i.e., without the `debug_assertions` option),
/// logging at this level is also disabled if any of the following features are
/// present: `release_max_level_off`, `release_max_level_error`, or
/// `release_max_level_warn`.
#[macro_export]
macro_rules! info {
    (target: $target:expr, $($arg:tt)*) => (
        log!(target: $target, $crate::LogLevel::Info, $($arg)*);
    );
    ($($arg:tt)*) => (
        log!($crate::LogLevel::Info, $($arg)*);
    )
}

/// Logs a message at the debug level.
///
/// Logging at this level is disabled if any of the following features are
/// present: `max_level_off`, `max_level_error`, `max_level_warn`, or
/// `max_level_info`.
///
/// When building in release mode (i.e., without the `debug_assertions` option),
/// logging at this level is also disabled if any of the following features are
/// present: `release_max_level_off`, `release_max_level_error`,
/// `release_max_level_warn`, or `release_max_level_info`.
#[macro_export]
macro_rules! debug {
    (target: $target:expr, $($arg:tt)*) => (
        log!(target: $target, $crate::LogLevel::Debug, $($arg)*);
    );
    ($($arg:tt)*) => (
        log!($crate::LogLevel::Debug, $($arg)*);
    )
}

/// Logs a message at the trace level.
///
/// Logging at this level is disabled if any of the following features are
/// present: `max_level_off`, `max_level_error`, `max_level_warn`,
/// `max_level_info`, or `max_level_debug`.
///
/// When building in release mode (i.e., without the `debug_assertions` option),
/// logging at this level is also disabled if any of the following features are
/// present: `release_max_level_off`, `release_max_level_error`,
/// `release_max_level_warn`, `release_max_level_info`, or
/// `release_max_level_debug`.
#[macro_export]
macro_rules! trace {
    (target: $target:expr, $($arg:tt)*) => (
        log!(target: $target, $crate::LogLevel::Trace, $($arg)*);
    );
    ($($arg:tt)*) => (
        log!($crate::LogLevel::Trace, $($arg)*);
    )
}

/// Determines if a message logged at the specified level in that module will
/// be logged.
///
/// This can be used to avoid expensive computation of log message arguments if
/// the message would be ignored anyway.
///
/// # Examples
///
/// ```rust
/// # #[macro_use]
/// # extern crate log;
/// use log::LogLevel::Debug;
///
/// # fn foo() {
/// if log_enabled!(Debug) {
///     let data = expensive_call();
///     debug!("expensive debug data: {} {}", data.x, data.y);
/// }
/// # }
/// # struct Data { x: u32, y: u32 }
/// # fn expensive_call() -> Data { Data { x: 0, y: 0 } }
/// # fn main() {}
/// ```
#[macro_export]
macro_rules! log_enabled {
    (target: $target:expr, $lvl:expr) => ({
        let lvl = $lvl;
        lvl <= $crate::__static_max_level() && lvl <= $crate::max_log_level() &&
            $crate::__enabled(lvl, $target)
    });
    ($lvl:expr) => (log_enabled!(target: module_path!(), $lvl))
}
deps/log-0.3.4/tests/0000755000000000000000000000000012666635521013106 5ustar  rootrootdeps/log-0.3.4/tests/filters.rs0000664000175000017500000000312312507270336013340 0ustar  #[macro_use] extern crate log;

use std::sync::{Arc, Mutex};
use log::{LogLevel, set_logger, LogLevelFilter, Log, LogRecord, LogMetadata};
use log::MaxLogLevelFilter;

struct State {
    last_log: Mutex>,
    filter: MaxLogLevelFilter,
}

struct Logger(Arc);

impl Log for Logger {
    fn enabled(&self, _: &LogMetadata) -> bool {
        true
    }

    fn log(&self, record: &LogRecord) {
        *self.0.last_log.lock().unwrap() = Some(record.level());
    }
}

fn main() {
    let mut a = None;
    set_logger(|max| {
        let me = Arc::new(State {
            last_log: Mutex::new(None),
            filter: max,
        });
        a = Some(me.clone());
        Box::new(Logger(me))
    }).unwrap();
    let a = a.unwrap();

    test(&a, LogLevelFilter::Off);
    test(&a, LogLevelFilter::Error);
    test(&a, LogLevelFilter::Warn);
    test(&a, LogLevelFilter::Info);
    test(&a, LogLevelFilter::Debug);
    test(&a, LogLevelFilter::Trace);
}

fn test(a: &State, filter: LogLevelFilter) {
    a.filter.set(filter);
    error!("");
    last(&a, t(LogLevel::Error, filter));
    warn!("");
    last(&a, t(LogLevel::Warn, filter));
    info!("");
    last(&a, t(LogLevel::Info, filter));
    debug!("");
    last(&a, t(LogLevel::Debug, filter));
    trace!("");
    last(&a, t(LogLevel::Trace, filter));

    fn t(lvl: LogLevel, filter: LogLevelFilter) -> Option {
        if lvl <= filter {Some(lvl)} else {None}
    }
}

fn last(state: &State, expected: Option) {
    let mut lvl = state.last_log.lock().unwrap();
    assert_eq!(*lvl, expected);
    *lvl = None;
}
deps/log-0.3.4/appveyor.yml0000664000175000017500000000101412556741331012547 0ustar  environment:
  matrix:
  - TARGET: x86_64-pc-windows-msvc
  - TARGET: i686-pc-windows-msvc
  - TARGET: i686-pc-windows-gnu
install:
  - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe"
  - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
  - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin
  - SET PATH=%PATH%;C:\MinGW\bin
  - rustc -V
  - cargo -V

build: false

test_script:
  - cargo test --verbose
  - cargo test --manifest-path env/Cargo.toml
deps/log-0.3.4/Cargo.toml0000664000175000017500000000131712625635473012123 0ustar  [package]

name = "log"
version = "0.3.4"
authors = ["The Rust Project Developers"]
license = "MIT/Apache-2.0"
readme = "README.md"
repository = "https://github.com/rust-lang/log"
documentation = "https://doc.rust-lang.org/log"
homepage = "https://github.com/rust-lang/log"
description = """
A lightweight logging facade for Rust
"""

[[test]]
name = "filters"
harness = false

[dependencies]
libc = "0.2"

[features]
max_level_off   = []
max_level_error = []
max_level_warn  = []
max_level_info  = []
max_level_debug = []
max_level_trace = []

release_max_level_off   = []
release_max_level_error = []
release_max_level_warn  = []
release_max_level_info  = []
release_max_level_debug = []
release_max_level_trace = []
deps/matches-0.1.2/0000755000000000000000000000000012666635520012602 5ustar  rootrootdeps/matches-0.1.2/lib.rs0000644000175000017500000000114512454073315012132 0ustar  #[macro_export]
macro_rules! matches {
    ($expression: expr, $($pattern:tt)+) => {
        _tt_as_expr_hack! {
            match $expression {
                $($pattern)+ => true,
                _ => false
            }
        }
    }
}


/// Work around "error: unexpected token: `an interpolated tt`", whatever that means.
#[macro_export]
macro_rules! _tt_as_expr_hack(
    ($value:expr) => ($value)
);


#[test]
fn it_works() {
    let foo = Some("-12");
    assert!(matches!(foo, Some(bar) if
        matches!(bar.as_bytes()[0], b'+' | b'-') &&
        matches!(bar.as_bytes()[1], b'0'...b'9')
    ));
}
deps/matches-0.1.2/Cargo.toml0000644000175000017500000000050512454073345012750 0ustar  [package]

name = "matches"
version = "0.1.2"
authors = ["Simon Sapin "]
license = "MIT"
repository = "https://github.com/SimonSapin/rust-std-candidates"
description = "A macro to evaluate, as a boolean, whether an expression matches a pattern."


[lib]
name = "matches"
path = "lib.rs"
doctest = false
deps/crossbeam-0.1.6/0000755000000000000000000000000012666635520013140 5ustar  rootrootdeps/crossbeam-0.1.6/LICENSE-APACHE0000644000076600000240000002513712567652755014710 0ustar  dialout                              Apache License
                        Version 2.0, January 2004
                     http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

   "License" shall mean the terms and conditions for use, reproduction,
   and distribution as defined by Sections 1 through 9 of this document.

   "Licensor" shall mean the copyright owner or entity authorized by
   the copyright owner that is granting the License.

   "Legal Entity" shall mean the union of the acting entity and all
   other entities that control, are controlled by, or are under common
   control with that entity. For the purposes of this definition,
   "control" means (i) the power, direct or indirect, to cause the
   direction or management of such entity, whether by contract or
   otherwise, or (ii) ownership of fifty percent (50%) or more of the
   outstanding shares, or (iii) beneficial ownership of such entity.

   "You" (or "Your") shall mean an individual or Legal Entity
   exercising permissions granted by this License.

   "Source" form shall mean the preferred form for making modifications,
   including but not limited to software source code, documentation
   source, and configuration files.

   "Object" form shall mean any form resulting from mechanical
   transformation or translation of a Source form, including but
   not limited to compiled object code, generated documentation,
   and conversions to other media types.

   "Work" shall mean the work of authorship, whether in Source or
   Object form, made available under the License, as indicated by a
   copyright notice that is included in or attached to the work
   (an example is provided in the Appendix below).

   "Derivative Works" shall mean any work, whether in Source or Object
   form, that is based on (or derived from) the Work and for which the
   editorial revisions, annotations, elaborations, or other modifications
   represent, as a whole, an original work of authorship. For the purposes
   of this License, Derivative Works shall not include works that remain
   separable from, or merely link (or bind by name) to the interfaces of,
   the Work and Derivative Works thereof.

   "Contribution" shall mean any work of authorship, including
   the original version of the Work and any modifications or additions
   to that Work or Derivative Works thereof, that is intentionally
   submitted to Licensor for inclusion in the Work by the copyright owner
   or by an individual or Legal Entity authorized to submit on behalf of
   the copyright owner. For the purposes of this definition, "submitted"
   means any form of electronic, verbal, or written communication sent
   to the Licensor or its representatives, including but not limited to
   communication on electronic mailing lists, source code control systems,
   and issue tracking systems that are managed by, or on behalf of, the
   Licensor for the purpose of discussing and improving the Work, but
   excluding communication that is conspicuously marked or otherwise
   designated in writing by the copyright owner as "Not a Contribution."

   "Contributor" shall mean Licensor and any individual or Legal Entity
   on behalf of whom a Contribution has been received by Licensor and
   subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
   this License, each Contributor hereby grants to You a perpetual,
   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
   copyright license to reproduce, prepare Derivative Works of,
   publicly display, publicly perform, sublicense, and distribute the
   Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
   this License, each Contributor hereby grants to You a perpetual,
   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
   (except as stated in this section) patent license to make, have made,
   use, offer to sell, sell, import, and otherwise transfer the Work,
   where such license applies only to those patent claims licensable
   by such Contributor that are necessarily infringed by their
   Contribution(s) alone or by combination of their Contribution(s)
   with the Work to which such Contribution(s) was submitted. If You
   institute patent litigation against any entity (including a
   cross-claim or counterclaim in a lawsuit) alleging that the Work
   or a Contribution incorporated within the Work constitutes direct
   or contributory patent infringement, then any patent licenses
   granted to You under this License for that Work shall terminate
   as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
   Work or Derivative Works thereof in any medium, with or without
   modifications, and in Source or Object form, provided that You
   meet the following conditions:

   (a) You must give any other recipients of the Work or
       Derivative Works a copy of this License; and

   (b) You must cause any modified files to carry prominent notices
       stating that You changed the files; and

   (c) You must retain, in the Source form of any Derivative Works
       that You distribute, all copyright, patent, trademark, and
       attribution notices from the Source form of the Work,
       excluding those notices that do not pertain to any part of
       the Derivative Works; and

   (d) If the Work includes a "NOTICE" text file as part of its
       distribution, then any Derivative Works that You distribute must
       include a readable copy of the attribution notices contained
       within such NOTICE file, excluding those notices that do not
       pertain to any part of the Derivative Works, in at least one
       of the following places: within a NOTICE text file distributed
       as part of the Derivative Works; within the Source form or
       documentation, if provided along with the Derivative Works; or,
       within a display generated by the Derivative Works, if and
       wherever such third-party notices normally appear. The contents
       of the NOTICE file are for informational purposes only and
       do not modify the License. You may add Your own attribution
       notices within Derivative Works that You distribute, alongside
       or as an addendum to the NOTICE text from the Work, provided
       that such additional attribution notices cannot be construed
       as modifying the License.

   You may add Your own copyright statement to Your modifications and
   may provide additional or different license terms and conditions
   for use, reproduction, or distribution of Your modifications, or
   for any such Derivative Works as a whole, provided Your use,
   reproduction, and distribution of the Work otherwise complies with
   the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
   names, trademarks, service marks, or product names of the Licensor,
   except as required for reasonable and customary use in describing the
   origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
   agreed to in writing, Licensor provides the Work (and each
   Contributor provides its Contributions) on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
   implied, including, without limitation, any warranties or conditions
   of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
   PARTICULAR PURPOSE. You are solely responsible for determining the
   appropriateness of using or redistributing the Work and assume any
   risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
   whether in tort (including negligence), contract, or otherwise,
   unless required by applicable law (such as deliberate and grossly
   negligent acts) or agreed to in writing, shall any Contributor be
   liable to You for damages, including any direct, indirect, special,
   incidental, or consequential damages of any character arising as a
   result of this License or out of the use or inability to use the
   Work (including but not limited to damages for loss of goodwill,
   work stoppage, computer failure or malfunction, or any and all
   other commercial damages or losses), even if such Contributor
   has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
   the Work or Derivative Works thereof, You may choose to offer,
   and charge a fee for, acceptance of support, warranty, indemnity,
   or other liability obligations and/or rights consistent with this
   License. However, in accepting such obligations, You may act only
   on Your own behalf and on Your sole responsibility, not on behalf
   of any other Contributor, and only if You agree to indemnify,
   defend, and hold each Contributor harmless for any liability
   incurred by, or claims asserted against, such Contributor by reason
   of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

   To apply the Apache License to your work, attach the following
   boilerplate notice, with the fields enclosed by brackets "[]"
   replaced with your own identifying information. (Don't include
   the brackets!)  The text should be enclosed in the appropriate
   comment syntax for the file format. We also recommend that a
   file or class name and description of purpose be included on the
   same "printed page" as the copyright notice for easier
   identification within third-party archives.

Copyright [yyyy] [name of copyright owner]

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.
deps/crossbeam-0.1.6/LICENSE-MIT0000644000076600000240000000205712567652760014410 0ustar  dialoutCopyright (c) 2015 The Rust Project Developers

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
deps/crossbeam-0.1.6/.travis.yml0000644000076600000240000000140012615736406015046 0ustar  dialoutlanguage: rust
# necessary for `travis-cargo coveralls --no-sudo`
addons:
  apt:
    packages:
      - libcurl4-openssl-dev
      - libelf-dev
      - libdw-dev

# run builds for all the trains (and more)
rust:
  - nightly
  - beta
  - stable

# load travis-cargo
before_script:
  - |
      pip install 'travis-cargo<0.2' --user &&
      export PATH=$HOME/.local/bin:$PATH

# the main build
script:
  - |
      travis-cargo build &&
      travis-cargo test &&
      travis-cargo test -- --release &&
      travis-cargo run -- --release &&
      travis-cargo --only stable doc
env:
  global:
    # override the default `--features unstable` used for the nightly branch (optional)
    - TRAVIS_CARGO_NIGHTLY_FEATURE=nightly
notifications:
  email:
    on_success: never
deps/crossbeam-0.1.6/README.md0000644000076600000240000000256712615736406014233 0ustar  dialout# Crossbeam: support for concurrent and parallel programming

[![Build Status](https://travis-ci.org/aturon/crossbeam.svg?branch=master)](https://travis-ci.org/aturon/crossbeam)

This crate is an early work in progress. The focus for the moment is
concurrency:

- **Non-blocking data structures**. These data structures allow for high
performance, highly-concurrent access, much superior to wrapping with a
`Mutex`. Ultimately the goal is to include stacks, queues, deques, bags, sets
and maps.

- **Memory management**. Because non-blocking data structures avoid global
synchronization, it is not easy to tell when internal data can be safely
freed. The `mem` module provides generic, easy to use, and high-performance APIs
for managing memory in these cases.

- **Synchronization**. The standard library provides a few synchronization
primitives (locks, semaphores, barriers, etc) but this crate seeks to expand
that set to include more advanced/niche primitives, as well as userspace
alternatives.

- **Scoped thread API**. Finally, the crate provides a "scoped" thread API,
making it possible to spawn threads that share stack data with their parents.

# Usage

To use Crossbeam, add this to your `Cargo.toml`:

```toml
[dependencies]
crossbeam = "0.1.5"
```

For examples of what Crossbeam is capable of, see the
[documentation][docs].

[docs]: http://aturon.github.io/crossbeam-doc/crossbeam/
deps/crossbeam-0.1.6/.gitignore0000644000076600000240000000015612567653732014742 0ustar  dialout# Compiled files
*.o
*.so
*.rlib
*.dll
*.class

# Executables
*.exe

# Generated by Cargo
/target/
Cargo.lock
deps/crossbeam-0.1.6/src/0000755000000000000000000000000012666635520013727 5ustar  rootrootdeps/crossbeam-0.1.6/src/lib.rs0000644000076600000240000000366712615736406014661 0ustar  dialout//! Support for concurrent and parallel programming.
//!
//! This crate is an early work in progress. The focus for the moment is
//! concurrency:
//!
//! - **Non-blocking data structures**. These data structures allow for high
//! performance, highly-concurrent access, much superior to wrapping with a
//! `Mutex`. Ultimately the goal is to include stacks, queues, deques, bags,
//! sets and maps. These live in the `sync` module.
//!
//! - **Memory management**. Because non-blocking data structures avoid global
//! synchronization, it is not easy to tell when internal data can be safely
//! freed. The `mem` module provides generic, easy to use, and high-performance
//! APIs for managing memory in these cases. These live in the `mem` module.
//!
//! - **Synchronization**. The standard library provides a few synchronization
//! primitives (locks, semaphores, barriers, etc) but this crate seeks to expand
//! that set to include more advanced/niche primitives, as well as userspace
//! alternatives. These live in the `sync` module.
//!
//! - **Scoped thread API**. Finally, the crate provides a "scoped" thread API,
//! making it possible to spawn threads that share stack data with their
//! parents. This functionality is exported at the top-level.

//#![deny(missing_docs)]

#![cfg_attr(feature = "nightly",
            feature(const_fn, repr_simd, optin_builtin_traits))]

use std::thread;

pub use scoped::{scope, Scope, ScopedJoinHandle};

pub mod mem;
pub mod sync;
mod scoped;

#[doc(hidden)]
trait FnBox {
    fn call_box(self: Box);
}

impl FnBox for F {
    fn call_box(self: Box) { (*self)() }
}

/// Like `std::thread::spawn`, but without the closure bounds.
pub unsafe fn spawn_unsafe<'a, F>(f: F) -> thread::JoinHandle<()> where F: FnOnce() + 'a {
    use std::mem;

    let closure: Box = Box::new(f);
    let closure: Box = mem::transmute(closure);
    thread::spawn(move || closure.call_box())
}
deps/crossbeam-0.1.6/src/mem/0000755000000000000000000000000012666635520014505 5ustar  rootrootdeps/crossbeam-0.1.6/src/mem/cache_padded.rs0000644000076600000240000000754712615736406017236 0ustar  dialoutuse std::marker;
use std::cell::UnsafeCell;
use std::mem;
use std::ptr;
use std::ops::{Deref, DerefMut};

// For now, treat this as an arch-independent constant.
const CACHE_LINE: usize = 32;

#[cfg_attr(feature = "nightly",
           repr(simd))]
struct Padding(u64, u64, u64, u64);

/// Pad `T` to the length of a cacheline.
///
/// Sometimes concurrent programming requires a piece of data to be padded out
/// to the size of a cacheline to avoid "false sharing": cachelines being
/// invalidated due to unrelated concurrent activity. Use the `CachePadded` type
/// when you want to *avoid* cache locality.
///
/// At the moment, cache lines are assumed to be 32 * sizeof(usize) on all
/// architectures.
///
/// **Warning**: the wrapped data is never dropped; move out using `ptr::read`
/// if you need to run dtors.
pub struct CachePadded {
    data: UnsafeCell<[usize; CACHE_LINE]>,
    _marker: ([Padding; 0], marker::PhantomData),
}

unsafe impl Send for CachePadded {}
unsafe impl Sync for CachePadded {}

/// Types for which mem::zeroed() is safe.
///
/// If a type `T: ZerosValid`, then a sequence of zeros the size of `T` must be
/// a valid member of the type `T`.
pub unsafe trait ZerosValid {}

#[cfg(feature = "nightly")]
unsafe impl ZerosValid for .. {}

macro_rules! zeros_valid { ($( $T:ty )*) => ($(
    unsafe impl ZerosValid for $T {}
)*)}

zeros_valid!(u8 u16 u32 u64 usize);
zeros_valid!(i8 i16 i32 i64 isize);

unsafe impl ZerosValid for ::std::sync::atomic::AtomicUsize {}
unsafe impl ZerosValid for ::std::sync::atomic::AtomicPtr {}

impl CachePadded {
    /// A const fn equivalent to mem::zeroed().
    #[cfg(not(feature = "nightly"))]
    pub fn zeroed() -> CachePadded {
        CachePadded {
            data: UnsafeCell::new(([0; CACHE_LINE])),
            _marker: ([], marker::PhantomData),
        }
    }

    /// A const fn equivalent to mem::zeroed().
    #[cfg(feature = "nightly")]
    pub const fn zeroed() -> CachePadded {
        CachePadded {
            data: UnsafeCell::new(([0; CACHE_LINE])),
            _marker: ([], marker::PhantomData),
        }
    }
}

#[inline]
/// Assert that the size and alignment of `T` are consistent with `CachePadded`.
fn assert_valid() {
    assert!(mem::size_of::() <= mem::size_of::>());
    assert!(mem::align_of::() <= mem::align_of::>());
}

impl CachePadded {
    /// Wrap `t` with cacheline padding.
    ///
    /// **Warning**: the wrapped data is never dropped; move out using
    /// `ptr:read` if you need to run dtors.
    pub fn new(t: T) -> CachePadded {
        assert_valid::();
        let ret = CachePadded {
            data: UnsafeCell::new(([0; CACHE_LINE])),
            _marker: ([], marker::PhantomData),
        };
        unsafe {
            let p: *mut T = mem::transmute(&ret.data);
            ptr::write(p, t);
        }
        ret
    }
}

impl Deref for CachePadded {
    type Target = T;
    fn deref(&self) -> &T {
        assert_valid::();
        unsafe { mem::transmute(&self.data) }
    }
}

impl DerefMut for CachePadded {
    fn deref_mut(&mut self) -> &mut T {
        assert_valid::();
        unsafe { mem::transmute(&mut self.data) }
    }
}

// FIXME: support Drop by pulling out a version usable for statics
/*
impl Drop for CachePadded {
    fn drop(&mut self) {
        assert_valid::();
        let p: *mut T = mem::transmute(&self.data);
        mem::drop(ptr::read(p));
    }
}
*/

#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn cache_padded_store_u64() {
        let x: CachePadded = unsafe { CachePadded::new(17) };
        assert_eq!(*x, 17);
    }

    #[test]
    fn cache_padded_store_pair() {
        let x: CachePadded<(u64, u64)> = unsafe { CachePadded::new((17, 37)) };
        assert_eq!(x.0, 17);
        assert_eq!(x.1, 37);
    }
}
deps/crossbeam-0.1.6/src/mem/mod.rs0000644000076600000240000000041012615736406015427 0ustar  dialout//! Memory management for concurrent data structures
//!
//! At the moment, the only memory management scheme is epoch-based reclamation,
//! found in the `epoch` submodule.

pub use self::cache_padded::{CachePadded, ZerosValid};

pub mod epoch;
mod cache_padded;
deps/crossbeam-0.1.6/src/mem/epoch/0000755000000000000000000000000012666635520015603 5ustar  rootrootdeps/crossbeam-0.1.6/src/mem/epoch/global.rs0000644000076600000240000000501712615736406017216 0ustar  dialout// Definition of global epoch state. The `get` function is the way to
// access this data externally (until const fn is stabilized...).

use std::sync::atomic::AtomicUsize;

use mem::CachePadded;
use mem::epoch::garbage;
use mem::epoch::participants::Participants;

/// Global epoch state
pub struct EpochState {
    /// Current global epoch
    pub epoch: CachePadded,

    // FIXME: move this into the `garbage` module, rationalize API
    /// Global garbage bags
    pub garbage: [CachePadded; 3],

    /// Participant list
    pub participants: Participants,
}

unsafe impl Send for EpochState {}
unsafe impl Sync for EpochState {}

pub use self::imp::get;

#[cfg(not(feature = "nightly"))]
mod imp {
    use std::mem;
    use std::sync::atomic::{self, AtomicUsize};
    use std::sync::atomic::Ordering::Relaxed;

    use super::EpochState;
    use mem::CachePadded;
    use mem::epoch::participants::Participants;

    impl EpochState {
        fn new() -> EpochState {
            EpochState {
                epoch: CachePadded::zeroed(),
                garbage: [CachePadded::zeroed(),
                          CachePadded::zeroed(),
                          CachePadded::zeroed()],
                participants: Participants::new(),
            }
        }
    }

    static EPOCH: AtomicUsize = atomic::ATOMIC_USIZE_INIT;

    pub fn get() -> &'static EpochState {
        let mut addr = EPOCH.load(Relaxed);

        if addr == 0 {
            let boxed = Box::new(EpochState::new());
            let raw: *mut EpochState = unsafe { mem::transmute(boxed) };

            addr = EPOCH.compare_and_swap(0, raw as usize, Relaxed);
            if addr != 0 {
                let boxed: Box = unsafe { mem::transmute(raw) };
                mem::drop(boxed);
            } else {
                addr = raw as usize;
            }
        }

        unsafe {
            &*(addr as *mut EpochState)
        }
    }
}

#[cfg(feature = "nightly")]
mod imp {
    use super::EpochState;
    use mem::CachePadded;
    use mem::epoch::participants::Participants;

    impl EpochState {
        const fn new() -> EpochState {
            EpochState {
                epoch: CachePadded::zeroed(),
                garbage: [CachePadded::zeroed(),
                          CachePadded::zeroed(),
                          CachePadded::zeroed()],
                participants: Participants::new(),
            }
        }
    }

    static EPOCH: EpochState = EpochState::new();
    pub fn get() -> &'static EpochState { &EPOCH }
}
deps/crossbeam-0.1.6/src/mem/epoch/local.rs0000644000076600000240000000157412615736406017054 0ustar  dialout// Manage the thread-local state, providing access to a `Participant` record.

use std::sync::atomic::Ordering::Relaxed;

use mem::epoch::participant::Participant;
use mem::epoch::global;

struct LocalEpoch {
    participant: *const Participant,
}

impl LocalEpoch {
    fn new() -> LocalEpoch {
        LocalEpoch { participant: global::get().participants.enroll() }
    }

    fn get(&self) -> &Participant {
        unsafe { &*self.participant }
    }
}

// FIXME: avoid leaking when all threads have exited
impl Drop for LocalEpoch {
    fn drop(&mut self) {
        let p = self.get();
        p.enter();
        p.migrate_garbage();
        p.exit();
        p.active.store(false, Relaxed);
    }
}

thread_local!(static LOCAL_EPOCH: LocalEpoch = LocalEpoch::new() );

pub fn with_participant(f: F) -> T where F: FnOnce(&Participant) -> T {
    LOCAL_EPOCH.with(|e| f(e.get()))
}
deps/crossbeam-0.1.6/src/mem/epoch/participant.rs0000644000076600000240000000737112615736406020301 0ustar  dialout// Manages a single participant in the epoch scheme. This is where all
// of the actual epoch management logic happens!

use std::mem;
use std::cell::UnsafeCell;
use std::sync::atomic::{self, AtomicUsize, AtomicBool};
use std::sync::atomic::Ordering::{Relaxed, Acquire, Release, SeqCst};

use mem::epoch::{Atomic, Guard, garbage, global};
use mem::epoch::participants::ParticipantNode;

/// Thread-local data for epoch participation.
pub struct Participant {
    /// The local epoch.
    epoch: AtomicUsize,

    /// Number of pending uses of `epoch::pin()`; keeping a count allows for
    /// reentrant use of epoch management.
    in_critical: AtomicUsize,

    /// Thread-local garbage tracking
    garbage: UnsafeCell,

    /// Is the thread still active? Becomes `false` when the thread exits. This
    /// is ultimately used to free `Participant` records.
    pub active: AtomicBool,

    /// The participant list is coded intrusively; here's the `next` pointer.
    pub next: Atomic,
}

unsafe impl Sync for Participant {}

impl Participant {
    pub fn new() -> Participant {
        Participant {
            epoch: AtomicUsize::new(0),
            in_critical: AtomicUsize::new(0),
            active: AtomicBool::new(true),
            garbage: UnsafeCell::new(garbage::Local::new()),
            next: Atomic::null(),
        }
    }

    /// Enter a critical section.
    ///
    /// This method is reentrant, allowing for nested critical sections.
    pub fn enter(&self) {
        let new_count = self.in_critical.load(Relaxed) + 1;
        self.in_critical.store(new_count, Relaxed);
        if new_count > 1 { return }

        atomic::fence(SeqCst);

        let global_epoch = global::get().epoch.load(Relaxed);
        if global_epoch != self.epoch.load(Relaxed) {
            self.epoch.store(global_epoch, Relaxed);
            unsafe { (*self.garbage.get()).collect(); }
        }
    }

    /// Exit the current (nested) critical section.
    pub fn exit(&self) {
        let new_count = self.in_critical.load(Relaxed) - 1;
        self.in_critical.store(
            new_count,
            if new_count > 0 { Relaxed } else { Release });
    }

    /// Begin the reclamation process for a piece of data.
    pub unsafe fn reclaim(&self, data: *mut T) {
        (*self.garbage.get()).reclaim(data);
    }

    /// Attempt to collect garbage by moving the global epoch forward.
    ///
    /// Returns `true` on success.
    pub fn try_collect(&self, guard: &Guard) -> bool {
        let cur_epoch = global::get().epoch.load(SeqCst);

        for p in global::get().participants.iter(guard) {
            if p.in_critical.load(Relaxed) > 0 && p.epoch.load(Relaxed) != cur_epoch {
                return false
            }
        }

        let new_epoch = cur_epoch.wrapping_add(1);
        atomic::fence(Acquire);
        if global::get().epoch.compare_and_swap(cur_epoch, new_epoch, SeqCst) != cur_epoch {
            return false
        }

        self.epoch.store(new_epoch, Relaxed);

        unsafe {
            global::get().garbage[new_epoch.wrapping_add(1) % 3].collect();
        }

        true
    }

    /// Move the current thread-local garbage into the global garbage bags.
    pub fn migrate_garbage(&self) {
        let cur_epoch = self.epoch.load(Relaxed);
        let local = unsafe { mem::replace(&mut *self.garbage.get(), garbage::Local::new()) };
        global::get().garbage[cur_epoch.wrapping_sub(1) % 3].insert(local.old);
        global::get().garbage[cur_epoch % 3].insert(local.cur);
        global::get().garbage[global::get().epoch.load(Relaxed) % 3].insert(local.new);
    }

    /// How much garbage is this participant currently storing?
    pub fn garbage_size(&self) -> usize {
        unsafe { (*self.garbage.get()).size() }
    }
}
deps/crossbeam-0.1.6/src/mem/epoch/participants.rs0000644000076600000240000000667412615736406020471 0ustar  dialout// Manages the global participant list, which is an intrustive list in
// which items are lazily removed on traversal (after being
// "logically" deleted by becoming inactive.)

use std::mem;
use std::ops::{Deref, DerefMut};
use std::sync::atomic::Ordering::{Relaxed, Acquire, Release};

use mem::epoch::{Atomic, Owned, Guard};
use mem::epoch::participant::Participant;
use mem::CachePadded;

/// Global, threadsafe list of threads participating in epoch management.
pub struct Participants {
    head: Atomic
}

pub struct ParticipantNode(CachePadded);

impl ParticipantNode {
    pub fn new() -> ParticipantNode {
        ParticipantNode(CachePadded::new(Participant::new()))
    }
}

impl Deref for ParticipantNode {
    type Target = Participant;
    fn deref(&self) -> &Participant {
        &self.0
    }
}

impl DerefMut for ParticipantNode {
    fn deref_mut(&mut self) -> &mut Participant {
        &mut self.0
    }
}

impl Participants {
    #[cfg(not(feature = "nightly"))]
    pub fn new() -> Participants {
        Participants { head: Atomic::null() }
    }

    #[cfg(feature = "nightly")]
    pub const fn new() -> Participants {
        Participants { head: Atomic::null() }
    }

    /// Enroll a new thread in epoch management by adding a new `Particpant`
    /// record to the global list.
    pub fn enroll(&self) -> *const Participant {
        let mut participant = Owned::new(ParticipantNode::new());

        // we ultimately use epoch tracking to free Participant nodes, but we
        // can't actually enter an epoch here, so fake it; we know the node
        // can't be removed until marked inactive anyway.
        let fake_guard = ();
        let g: &'static Guard = unsafe { mem::transmute(&fake_guard) };
        loop {
            let head = self.head.load(Relaxed, g);
            participant.next.store_shared(head, Relaxed);
            match self.head.cas_and_ref(head, participant, Release, g) {
                Ok(shared) => {
                    let shared: &Participant = &shared;
                    return shared;
                }
                Err(owned) => {
                    participant = owned;
                }
            }
        }
    }

    pub fn iter<'a>(&'a self, g: &'a Guard) -> Iter<'a> {
        Iter {
            guard: g,
            next: &self.head,
            needs_acq: true,
        }
    }
}

pub struct Iter<'a> {
    // pin to an epoch so that we can free inactive nodes
    guard: &'a Guard,
    next: &'a Atomic,

    // an Acquire read is needed only for the first read, due to release
    // sequences
    needs_acq: bool,
}

impl<'a> Iterator for Iter<'a> {
    type Item = &'a Participant;
    fn next(&mut self) -> Option<&'a Participant> {
        let mut cur = if self.needs_acq {
            self.needs_acq = false;
            self.next.load(Acquire, self.guard)
        } else {
            self.next.load(Relaxed, self.guard)
        };

        while let Some(n) = cur {
            // attempt to clean up inactive nodes
            if !n.active.load(Relaxed) {
                cur = n.next.load(Relaxed, self.guard);
                unsafe {
                    if self.next.cas_shared(Some(n), cur, Relaxed) {
                        self.guard.unlinked(n)
                    }
                }
                self.next = &n.next;
            } else {
                self.next = &n.next;
                return Some(&n)
            }
        }

        None
    }
}
deps/crossbeam-0.1.6/src/mem/epoch/mod.rs0000644000076600000240000003533512615736406016543 0ustar  dialout//! Epoch-based memory management
//!
//! This module provides fast, easy to use memory management for lock free data
//! structures. It's inspired by [Keir Fraser's *epoch-based
//! reclamation*](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-579.pdf).
//!
//! The basic problem this is solving is the fact that when one thread has
//! removed a node from a data structure, other threads may still have pointers
//! to that node (in the form of snapshots that will be validated through things
//! like compare-and-swap), so the memory cannot be immediately freed. Put differently:
//!
//! 1. There are two sources of reachability at play -- the data structure, and
//! the snapshots in threads accessing it. Before we delete a node, we need to know
//! that it cannot be reached in either of these ways.
//!
//! 2. Once a node has been unliked from the data structure, no *new* snapshots
//! reaching it will be created.
//!
//! Using the epoch scheme is fairly straightforward, and does not require
//! understanding any of the implementation details:
//!
//! - When operating on a shared data structure, a thread must "pin the current
//! epoch", which is done by calling `pin()`. This function returns a `Guard`
//! which unpins the epoch when destroyed.
//!
//! - When the thread subsequently reads from a lock-free data structure, the
//! pointers it extracts act like references with lifetime tied to the
//! `Guard`. This allows threads to safely read from snapshotted data, being
//! guaranteed that the data will remain allocated until they exit the epoch.
//!
//! To put the `Guard` to use, Crossbeam provides a set of three pointer types meant to work together:
//!
//! - `Owned`, akin to `Box`, which points to uniquely-owned data that has
//!   not yet been published in a concurrent data structure.
//!
//! - `Shared<'a, T>`, akin to `&'a T`, which points to shared data that may or may
//!   not be reachable from a data structure, but it guaranteed not to be freed
//!   during lifetime `'a`.
//!
//! - `Atomic`, akin to `std::sync::atomic::AtomicPtr`, which provides atomic
//!   updates to a pointer using the `Owned` and `Shared` types, and connects them
//!   to a `Guard`.
//!
//! Each of these types provides further documentation on usage.
//!
//! # Example
//!
//! ```
//! use std::sync::atomic::Ordering::{Acquire, Release, Relaxed};
//! use std::ptr;
//!
//! use crossbeam::mem::epoch::{self, Atomic, Owned};
//!
//! struct TreiberStack {
//!     head: Atomic>,
//! }
//!
//! struct Node {
//!     data: T,
//!     next: Atomic>,
//! }
//!
//! impl TreiberStack {
//!     fn new() -> TreiberStack {
//!         TreiberStack {
//!             head: Atomic::null()
//!         }
//!     }
//!
//!     fn push(&self, t: T) {
//!         // allocate the node via Owned
//!         let mut n = Owned::new(Node {
//!             data: t,
//!             next: Atomic::null(),
//!         });
//!
//!         // become active
//!         let guard = epoch::pin();
//!
//!         loop {
//!             // snapshot current head
//!             let head = self.head.load(Relaxed, &guard);
//!
//!             // update `next` pointer with snapshot
//!             n.next.store_shared(head, Relaxed);
//!
//!             // if snapshot is still good, link in the new node
//!             match self.head.cas_and_ref(head, n, Release, &guard) {
//!                 Ok(_) => return,
//!                 Err(owned) => n = owned,
//!             }
//!         }
//!     }
//!
//!     fn pop(&self) -> Option {
//!         // become active
//!         let guard = epoch::pin();
//!
//!         loop {
//!             // take a snapshot
//!             match self.head.load(Acquire, &guard) {
//!                 // the stack is non-empty
//!                 Some(head) => {
//!                     // read through the snapshot, *safely*!
//!                     let next = head.next.load(Relaxed, &guard);
//!
//!                     // if snapshot is still good, update from `head` to `next`
//!                     if self.head.cas_shared(Some(head), next, Release) {
//!                         unsafe {
//!                             // mark the node as unlinked
//!                             guard.unlinked(head);
//!
//!                             // extract out the data from the now-unlinked node
//!                             return Some(ptr::read(&(*head).data))
//!                         }
//!                     }
//!                 }
//!
//!                 // we observed the stack empty
//!                 None => return None
//!             }
//!         }
//!     }
//! }
//! ```

// FIXME: document implementation details

use std::marker::PhantomData;
use std::marker;
use std::mem;
use std::ops::{Deref, DerefMut};
use std::ptr;
use std::sync::atomic::{self, Ordering};

mod participant;
mod participants;
mod global;
mod local;
mod garbage;

/// Like `Box`: an owned, heap-allocated data value of type `T`.
pub struct Owned {
    data: Box,
}

impl Owned {
    /// Move `t` to a new heap allocation.
    pub fn new(t: T) -> Owned {
        Owned { data: Box::new(t) }
    }

    fn as_raw(&self) -> *mut T {
        self.deref() as *const _ as *mut _
    }
}

impl Deref for Owned {
    type Target = T;
    fn deref(&self) -> &T {
        &self.data
    }
}

impl DerefMut for Owned {
    fn deref_mut(&mut self) -> &mut T {
        &mut self.data
    }
}

#[derive(PartialEq, Eq)]
/// Like `&'a T`: a shared reference valid for lifetime `'a`.
pub struct Shared<'a, T: 'a> {
    data: &'a T,
}

impl<'a, T> Copy for Shared<'a, T> {}
impl<'a, T> Clone for Shared<'a, T> {
    fn clone(&self) -> Shared<'a, T> {
        Shared { data: self.data }
    }
}

impl<'a, T> Deref for Shared<'a, T> {
    type Target = &'a T;
    fn deref(&self) -> &&'a T {
        &self.data
    }
}

impl<'a, T> Shared<'a, T> {
    unsafe fn from_raw(raw: *mut T) -> Option> {
        if raw == ptr::null_mut() { None }
        else {
            Some(Shared {
                data: mem::transmute::<*mut T, &T>(raw)
            })
        }
    }

    unsafe fn from_ref(r: &T) -> Shared<'a, T> {
        Shared { data: mem::transmute(r) }
    }

    unsafe fn from_owned(owned: Owned) -> Shared<'a, T> {
        let ret = Shared::from_ref(owned.deref());
        mem::forget(owned);
        ret
    }

    fn as_raw(&self) -> *mut T {
        self.data as *const _ as *mut _
    }
}

/// Like `std::sync::atomic::AtomicPtr`.
///
/// Provides atomic access to a (nullable) pointer of type `T`, interfacing with
/// the `Owned` and `Shared` types.
pub struct Atomic {
    ptr: atomic::AtomicPtr,
    _marker: PhantomData<*const ()>,
}

unsafe impl Send for Atomic {}
unsafe impl Sync for Atomic {}

fn opt_shared_into_raw(val: Option>) -> *mut T {
    val.map(|p| p.as_raw()).unwrap_or(ptr::null_mut())
}

fn opt_owned_as_raw(val: &Option>) -> *mut T {
    val.as_ref().map(Owned::as_raw).unwrap_or(ptr::null_mut())
}

fn opt_owned_into_raw(val: Option>) -> *mut T {
    let ptr = val.as_ref().map(Owned::as_raw).unwrap_or(ptr::null_mut());
    mem::forget(val);
    ptr
}

impl Atomic {
    /// Create a new, null atomic pointer.
    #[cfg(not(feature = "nightly"))]
    pub fn null() -> Atomic {
        Atomic {
            ptr: atomic::AtomicPtr::new(0 as *mut _),
            _marker: PhantomData
        }
    }

    /// Create a new, null atomic pointer.
    #[cfg(feature = "nightly")]
    pub const fn null() -> Atomic {
        Atomic {
            ptr: atomic::AtomicPtr::new(0 as *mut _),
            _marker: PhantomData
        }
    }

    /// Do an atomic load with the given memory ordering.
    ///
    /// In order to perform the load, we must pass in a borrow of a
    /// `Guard`. This is a way of guaranteeing that the thread has pinned the
    /// epoch for the entire lifetime `'a`. In return, you get an optional
    /// `Shared` pointer back (`None` if the `Atomic` is currently null), with
    /// lifetime tied to the guard.
    ///
    /// # Panics
    ///
    /// Panics if `ord` is `Release` or `AcqRel`.
    pub fn load<'a>(&self, ord: Ordering, _: &'a Guard) -> Option> {
        unsafe { Shared::from_raw(self.ptr.load(ord)) }
    }

    /// Do an atomic store with the given memory ordering.
    ///
    /// Transfers ownership of the given `Owned` pointer, if any. Since no
    /// lifetime information is acquired, no `Guard` value is needed.
    ///
    /// # Panics
    ///
    /// Panics if `ord` is `Acquire` or `AcqRel`.
    pub fn store(&self, val: Option>, ord: Ordering) {
        self.ptr.store(opt_owned_into_raw(val), ord)
    }

    /// Do an atomic store with the given memory ordering, immediately yielding
    /// a shared reference to the pointer that was stored.
    ///
    /// Transfers ownership of the given `Owned` pointer, yielding a `Shared`
    /// reference to it. Since the reference is valid only for the curent epoch,
    /// it's lifetime is tied to a `Guard` value.
    ///
    /// # Panics
    ///
    /// Panics if `ord` is `Acquire` or `AcqRel`.
    pub fn store_and_ref<'a>(&self, val: Owned, ord: Ordering, _: &'a Guard)
                             -> Shared<'a, T>
    {
        unsafe {
            let shared = Shared::from_owned(val);
            self.store_shared(Some(shared), ord);
            shared
        }
    }

    /// Do an atomic store of a `Shared` pointer with the given memory ordering.
    ///
    /// This operation does not require a guard, because it does not yield any
    /// new information about the lifetime of a pointer.
    ///
    /// # Panics
    ///
    /// Panics if `ord` is `Acquire` or `AcqRel`.
    pub fn store_shared(&self, val: Option>, ord: Ordering) {
        self.ptr.store(opt_shared_into_raw(val), ord)
    }

    /// Do a compare-and-set from a `Shared` to an `Owned` pointer with the
    /// given memory ordering.
    ///
    /// As with `store`, this operation does not require a guard; it produces no new
    /// lifetime information. The `Result` indicates whether the CAS succeeded; if
    /// not, ownership of the `new` pointer is returned to the caller.
    pub fn cas(&self, old: Option>, new: Option>, ord: Ordering)
               -> Result<(), Option>>
    {
        if self.ptr.compare_and_swap(opt_shared_into_raw(old),
                                     opt_owned_as_raw(&new),
                                     ord) == opt_shared_into_raw(old)
        {
            mem::forget(new);
            Ok(())
        } else {
            Err(new)
        }
    }

    /// Do a compare-and-set from a `Shared` to an `Owned` pointer with the
    /// given memory ordering, immediatley acquiring a new `Shared` reference to
    /// the previously-owned pointer if successful.
    ///
    /// This operation is analogous to `store_and_ref`.
    pub fn cas_and_ref<'a>(&self, old: Option>, new: Owned,
                           ord: Ordering, _: &'a Guard)
                           -> Result, Owned>
    {
        if self.ptr.compare_and_swap(opt_shared_into_raw(old), new.as_raw(), ord)
            == opt_shared_into_raw(old)
        {
            Ok(unsafe { Shared::from_owned(new) })
        } else {
            Err(new)
        }
    }

    /// Do a compare-and-set from a `Shared` to another `Shared` pointer with
    /// the given memory ordering.
    ///
    /// The boolean return value is `true` when the CAS is successful.
    pub fn cas_shared(&self, old: Option>, new: Option>, ord: Ordering)
                      -> bool
    {
        self.ptr.compare_and_swap(opt_shared_into_raw(old),
                                  opt_shared_into_raw(new),
                                  ord) == opt_shared_into_raw(old)
    }

    /// Do an atomic swap with an `Owned` pointer with the given memory ordering.
    pub fn swap<'a>(&self, new: Option>, ord: Ordering, _: &'a Guard)
                    -> Option> {
        unsafe { Shared::from_raw(self.ptr.swap(opt_owned_into_raw(new), ord)) }
    }

    /// Do an atomic swap with a `Shared` pointer with the given memory ordering.
    pub fn swap_shared<'a>(&self, new: Option>, ord: Ordering, _: &'a Guard)
                           -> Option> {
        unsafe { Shared::from_raw(self.ptr.swap(opt_shared_into_raw(new), ord)) }
    }
}

/// An RAII-style guard for pinning the current epoch.
///
/// A guard must be acquired before most operations on an `Atomic` pointer. On
/// destruction, it unpins the epoch.
#[must_use]
pub struct Guard {
    _marker: marker::PhantomData<*mut ()>, // !Send and !Sync
}

static GC_THRESH: usize = 32;

/// Pin the current epoch.
///
/// Threads generally pin before interacting with a lock-free data
/// structure. Pinning requires a full memory barrier, so is somewhat
/// expensive. It is rentrant -- you can safely acquire nested guards, and only
/// the first guard requires a barrier. Thus, in cases where you expect to
/// perform several lock-free operations in quick succession, you may consider
/// pinning around the entire set of operations.
pub fn pin() -> Guard {
    local::with_participant(|p| {
        p.enter();

        let g = Guard {
            _marker: marker::PhantomData,
        };

        if p.garbage_size() > GC_THRESH {
            p.try_collect(&g);
        }

        g
    })
}

impl Guard {
    /// Assert that the value is no longer reachable from a lock-free data
    /// structure and should be collected when sufficient epochs have passed.
    pub unsafe fn unlinked(&self, val: Shared) {
        local::with_participant(|p| p.reclaim(val.as_raw()))
    }

    /// Move the thread-local garbage into the global set of garbage.
    pub fn migrate_garbage(&self) {
        local::with_participant(|p| p.migrate_garbage())
    }
}

impl Drop for Guard {
    fn drop(&mut self) {
        local::with_participant(|p| p.exit());
    }
}

#[cfg(test)]
mod test {
    use std::sync::atomic::Ordering;
    use super::*;

    #[test]
    fn smoke_guard() {
        let g = pin();
    }

    #[test]
    fn test_no_drop() {
        static mut DROPS: i32 = 0;
        struct Test;
        impl Drop for Test {
            fn drop(&mut self) {
                unsafe {
                    DROPS += 1;
                }
            }
        }
        let g = pin();

        let x = Atomic::null();
        x.store(Some(Owned::new(Test)), Ordering::Relaxed);
        x.store_and_ref(Owned::new(Test), Ordering::Relaxed, &g);
        let y = x.load(Ordering::Relaxed, &g);
        let z = x.cas_and_ref(y, Owned::new(Test), Ordering::Relaxed, &g).ok();
        x.cas(z, Some(Owned::new(Test)), Ordering::Relaxed);
        x.swap(Some(Owned::new(Test)), Ordering::Relaxed, &g);

        unsafe {
            assert_eq!(DROPS, 0);
        }
    }
}
deps/crossbeam-0.1.6/src/mem/epoch/garbage.rs0000644000076600000240000000677312615736406017360 0ustar  dialout// Data structures for storing garbage to be freed later (once the
// epochs have sufficiently advanced).
//
// In general, we try to manage the garbage thread locally whenever
// possible. Each thread keep track of three bags of garbage. But if a
// thread is exiting, these bags must be moved into the global garbage
// bags.

use std::ptr;
use std::mem;
use std::sync::atomic::AtomicPtr;
use std::sync::atomic::Ordering::{Relaxed, Release};

use mem::ZerosValid;

/// One item of garbage.
///
/// Stores enough information to do a deallocation.
struct Item {
    ptr: *mut u8,
    free: unsafe fn(*mut u8),
}

/// A single, thread-local bag of garbage.
pub struct Bag(Vec);

impl Bag {
    fn new() -> Bag {
        Bag(vec![])
    }

    fn insert(&mut self, elem: *mut T) {
        let size = mem::size_of::();
        if size > 0 {
            self.0.push(Item {
                ptr: elem as *mut u8,
                free: free::,
            })
        }
        unsafe fn free(t: *mut u8) {
            drop(Vec::from_raw_parts(t as *mut T, 0, 1));
        }
    }

    fn len(&self) -> usize {
        self.0.len()
    }

    /// Deallocate all garbage in the bag
    pub unsafe fn collect(&mut self) {
        let mut data = mem::replace(&mut self.0, Vec::new());
        for item in data.iter() {
            (item.free)(item.ptr);
        }
        data.truncate(0);
        self.0 = data;
    }
}

// needed because the bags store raw pointers.
unsafe impl Send for Bag {}
unsafe impl Sync for Bag {}

/// A thread-local set of garbage bags.
// FIXME: switch this to use modular arithmetic and accessors instead
pub struct Local {
    /// Garbage added at least one epoch behind the current local epoch
    pub old: Bag,
    /// Garbage added in the current local epoch or earlier
    pub cur: Bag,
    /// Garbage added in the current *global* epoch
    pub new: Bag,
}

impl Local {
    pub fn new() -> Local {
        Local {
            old: Bag::new(),
            cur: Bag::new(),
            new: Bag::new(),
        }
    }

    pub fn reclaim(&mut self, elem: *mut T) {
        self.new.insert(elem)
    }

    /// Collect one epoch of garbage, rotating the local garbage bags.
    pub unsafe fn collect(&mut self) {
        let ret = self.old.collect();
        mem::swap(&mut self.old, &mut self.cur);
        mem::swap(&mut self.cur, &mut self.new);
        ret
    }

    pub fn size(&self) -> usize {
        self.old.len() + self.cur.len()
    }
}

/// A concurrent garbage bag, currently based on Treiber's stack.
///
/// The elements are themselves owned `Bag`s.
pub struct ConcBag {
    head: AtomicPtr,
}

unsafe impl ZerosValid for ConcBag {}

struct Node {
    data: Bag,
    next: AtomicPtr,
}

impl ConcBag {
    pub fn insert(&self, t: Bag){
        let n = into_raw(Box::new(
            Node { data: t, next: AtomicPtr::new(ptr::null_mut()) }));
        loop {
            let head = self.head.load(Relaxed);
            unsafe { (*n).next.store(head, Relaxed) };
            if self.head.compare_and_swap(head, n, Release) == head { break }
        }
    }

    pub unsafe fn collect(&self) {
        let mut head = self.head.load(Relaxed);
        self.head.store(ptr::null_mut(), Relaxed);

        while head != ptr::null_mut() {
            let mut n = from_raw(head);
            n.data.collect();
            head = n.next.load(Relaxed);
        }
    }
}

fn into_raw(b: Box) -> *mut T {
    unsafe { mem::transmute(b) }
}

unsafe fn from_raw(p: *mut T) -> Box {
    mem::transmute(p)
}
deps/crossbeam-0.1.6/src/sync/0000755000000000000000000000000012666635520014703 5ustar  rootrootdeps/crossbeam-0.1.6/src/sync/ms_queue.rs0000644000076600000240000001375412615737217016711 0ustar  dialoutuse std::sync::atomic::Ordering::{Acquire, Release, Relaxed};
use std::{ptr, mem};

use mem::epoch::{self, Atomic, Owned};
use mem::CachePadded;

/// A Michael-Scott lock-free queue.
///
/// Usable with any number of producers and consumers.
pub struct MsQueue {
    head: CachePadded>>,
    tail: CachePadded>>,
}

struct Node {
    data: T,
    next: Atomic>,
}

impl MsQueue {
    /// Create a new, empty queue.
    pub fn new() -> MsQueue {
        let q = MsQueue {
            head: CachePadded::new(Atomic::null()),
            tail: CachePadded::new(Atomic::null()),
        };
        let sentinel = Owned::new(Node {
            data: unsafe { mem::uninitialized() },
            next: Atomic::null()
        });
        let guard = epoch::pin();
        let sentinel = q.head.store_and_ref(sentinel, Relaxed, &guard);
        q.tail.store_shared(Some(sentinel), Relaxed);
        q
    }

    /// Add `t` to the back of the queue.
    pub fn push(&self, t: T) {
        let mut n = Owned::new(Node {
            data: t,
            next: Atomic::null()
        });
        let guard = epoch::pin();
        loop {
            let tail = self.tail.load(Acquire, &guard).unwrap();
            if let Some(next) = tail.next.load(Acquire, &guard) {
                self.tail.cas_shared(Some(tail), Some(next), Release);
                continue;
            }

            match tail.next.cas_and_ref(None, n, Release, &guard) {
                Ok(shared) => {
                    self.tail.cas_shared(Some(tail), Some(shared), Release);
                    break;
                }
                Err(owned) => {
                    n = owned;
                }
            }
        }
    }

    /// Attempt to dequeue from the front.
    ///
    /// Returns `None` if the queue is observed to be empty.
    pub fn pop(&self) -> Option {
        let guard = epoch::pin();
        loop {
            let head = self.head.load(Acquire, &guard).unwrap();

            if let Some(next) = head.next.load(Acquire, &guard) {
                unsafe {
                    if self.head.cas_shared(Some(head), Some(next), Release) {
                        guard.unlinked(head);
                        return Some(ptr::read(&(*next).data))
                    }
                }
            } else {
                return None
            }
        }
    }
}

#[cfg(test)]
mod test {
    const CONC_COUNT: i64 = 1000000;

    use std::io::stderr;
    use std::io::prelude::*;

    use mem::epoch;
    use scope;
    use super::*;

    #[test]
    fn smoke_queue() {
        let q: MsQueue = MsQueue::new();
    }

    #[test]
    fn push_pop_1() {
        let q: MsQueue = MsQueue::new();
        q.push(37);
        assert_eq!(q.pop(), Some(37));
    }

    #[test]
    fn push_pop_2() {
        let q: MsQueue = MsQueue::new();
        q.push(37);
        q.push(48);
        assert_eq!(q.pop(), Some(37));
        assert_eq!(q.pop(), Some(48));
    }

    #[test]
    fn push_pop_many_seq() {
        let q: MsQueue = MsQueue::new();
        for i in 0..200 {
            q.push(i)
        }
        for i in 0..200 {
            assert_eq!(q.pop(), Some(i));
        }
    }

    #[test]
    fn push_pop_many_spsc() {
        let q: MsQueue = MsQueue::new();

        scope(|scope| {
            scope.spawn(|| {
                let mut next = 0;

                while next < CONC_COUNT {
                    if let Some(elem) = q.pop() {
                        assert_eq!(elem, next);
                        next += 1;
                    }
                }
            });

            for i in 0..CONC_COUNT {
                q.push(i)
            }
        });
    }

    #[test]
    fn push_pop_many_spmc() {
        use std::time::Duration;

        fn recv(t: i32, q: &MsQueue) {
            let mut cur = -1;
            for i in 0..CONC_COUNT {
                if let Some(elem) = q.pop() {
                    if elem <= cur {
                        writeln!(stderr(), "{}: {} <= {}", t, elem, cur);
                    }
                    assert!(elem > cur);
                    cur = elem;

                    if cur == CONC_COUNT - 1 { break }
                }

                if i % 10000 == 0 {
                    //writeln!(stderr(), "{}: {} @ {}", t, i, cur);
                }
            }
        }

        let q: MsQueue = MsQueue::new();
        let qr = &q;
        scope(|scope| {
            for i in 0..3 {
                scope.spawn(move || recv(i, qr));
            }

            scope.spawn(|| {
                for i in 0..CONC_COUNT {
                    q.push(i);

                    if i % 10000 == 0 {
                        //writeln!(stderr(), "Push: {}", i);
                    }
                }
            })
        });
    }

    #[test]
    fn push_pop_many_mpmc() {
        enum LR { Left(i64), Right(i64) }

        let q: MsQueue = MsQueue::new();

        scope(|scope| {
            for _t in 0..2 {
                scope.spawn(|| {
                    for i in CONC_COUNT-1..CONC_COUNT {
                        q.push(LR::Left(i))
                    }
                });
                scope.spawn(|| {
                    for i in CONC_COUNT-1..CONC_COUNT {
                        q.push(LR::Right(i))
                    }
                });
                scope.spawn(|| {
                    let mut vl = vec![];
                    let mut vr = vec![];
                    for _i in 0..CONC_COUNT {
                        match q.pop() {
                            Some(LR::Left(x)) => vl.push(x),
                            Some(LR::Right(x)) => vr.push(x),
                            _ => {}
                        }
                    }

                    let mut vl2 = vl.clone();
                    let mut vr2 = vr.clone();
                    vl2.sort();
                    vr2.sort();

                    assert_eq!(vl, vl2);
                    assert_eq!(vr, vr2);
                });
            }
        });
    }
}
deps/crossbeam-0.1.6/src/sync/atomic_option.rs0000644000076600000240000000202612571072367017717 0ustar  dialoutuse std::sync::atomic::{AtomicPtr, Ordering};
use std::ptr;
use std::mem;

unsafe impl Send for AtomicOption {}
unsafe impl Sync for AtomicOption {}

pub struct AtomicOption {
    inner: AtomicPtr,
}

impl AtomicOption {
    pub fn new() -> AtomicOption {
        AtomicOption { inner: AtomicPtr::new(ptr::null_mut()) }
    }

    fn swap_inner(&self, ptr: *mut T, order: Ordering) -> Option> {
        let old = self.inner.swap(ptr, order);
        if old.is_null() {
            None
        } else {
            Some(unsafe { mem::transmute(old) })
        }
    }

    // allows re-use of allocation
    pub fn swap_box(&self, t: Box, order: Ordering) -> Option> {
        self.swap_inner(unsafe { mem::transmute(t) }, order)
    }

    pub fn swap(&self, t: T, order: Ordering) -> Option {
        self.swap_box(Box::new(t), order).map(|old| *old)
    }

    pub fn take(&self, order: Ordering) -> Option {
        self.swap_inner(ptr::null_mut(), order).map(|old| *old)
    }
}
deps/crossbeam-0.1.6/src/sync/treiber_stack.rs0000644000076600000240000000325312567701620017673 0ustar  dialoutuse std::sync::atomic::Ordering::{Acquire, Release, Relaxed};
use std::ptr;

use mem::epoch::{self, Atomic, Owned};

/// Treiber's lock-free stack.
///
/// Usable with any number of producers and consumers.
pub struct TreiberStack {
    head: Atomic>,
}

struct Node {
    data: T,
    next: Atomic>,
}

impl TreiberStack {
    /// Crate a new, empty stack.
    pub fn new() -> TreiberStack {
        TreiberStack {
            head: Atomic::null()
        }
    }

    /// Push `t` on top of the stack.
    pub fn push(&self, t: T) {
        let mut n = Owned::new(Node {
            data: t,
            next: Atomic::null()
        });
        let guard = epoch::pin();
        loop {
            let head = self.head.load(Relaxed, &guard);
            n.next.store_shared(head, Relaxed);
            match self.head.cas_and_ref(head, n, Release, &guard) {
                Ok(_) => break,
                Err(owned) => n = owned,
            }
        }
    }

    /// Attempt to pop the top element of the stack.
    ///
    /// Returns `None` if the stack is observed to be empty.
    pub fn pop(&self) -> Option {
        let guard = epoch::pin();
        loop {
            match self.head.load(Acquire, &guard) {
                Some(head) => {
                    let next = head.next.load(Relaxed, &guard);
                    if self.head.cas_shared(Some(head), next, Release) {
                        unsafe {
                            guard.unlinked(head);
                            return Some(ptr::read(&(*head).data))
                        }
                    }
                }
                None => return None
            }
        }
    }
}
deps/crossbeam-0.1.6/src/sync/seg_queue.rs0000644000076600000240000001603512615736406017042 0ustar  dialoutuse std::sync::atomic::Ordering::{Acquire, Release, Relaxed};
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::{ptr, mem};
use std::cmp;
use std::cell::UnsafeCell;

use mem::epoch::{self, Atomic, Owned};

const SEG_SIZE: usize = 32;

/// A Michael-Scott queue that allocates "segments" (arrays of nodes)
/// for efficiency.
///
/// Usable with any number of producers and consumers.
pub struct SegQueue {
    head: Atomic>,
    tail: Atomic>,
}

struct Segment {
    low: AtomicUsize,
    data: [UnsafeCell; SEG_SIZE],
    ready: [AtomicBool; SEG_SIZE],
    high: AtomicUsize,
    next: Atomic>,
}

unsafe impl Sync for Segment {}

impl Segment {
    fn new() -> Segment {
        Segment {
            data: unsafe { mem::uninitialized() },
            ready: unsafe { mem::transmute([0usize; SEG_SIZE]) },
            low: AtomicUsize::new(0),
            high: AtomicUsize::new(0),
            next: Atomic::null(),
        }
    }
}

impl SegQueue {
    /// Create a new, empty queue.
    pub fn new() -> SegQueue {
        let q = SegQueue {
            head: Atomic::null(),
            tail: Atomic::null(),
        };
        let sentinel = Owned::new(Segment::new());
        let guard = epoch::pin();
        let sentinel = q.head.store_and_ref(sentinel, Relaxed, &guard);
        q.tail.store_shared(Some(sentinel), Relaxed);
        q
    }

    /// Add `t` to the back of the queue.
    pub fn push(&self, t: T) {
        let guard = epoch::pin();
        loop {
            let tail = self.tail.load(Acquire, &guard).unwrap();
            if tail.high.load(Relaxed) >= SEG_SIZE { continue }
            let i = tail.high.fetch_add(1, Relaxed);
            unsafe {
                if i < SEG_SIZE {
                    *(*tail).data.get_unchecked(i).get() = t;
                    tail.ready.get_unchecked(i).store(true, Release);

                    if i + 1 == SEG_SIZE {
                        let tail = tail.next.store_and_ref(Owned::new(Segment::new()), Release, &guard);
                        self.tail.store_shared(Some(tail), Release);
                    }

                    return
                }
            }
        }
    }

    /// Attempt to dequeue from the front.
    ///
    /// Returns `None` if the queue is observed to be empty.
    pub fn pop(&self) -> Option {
        let guard = epoch::pin();
        loop {
            let head = self.head.load(Acquire, &guard).unwrap();
            loop {
                let low = head.low.load(Relaxed);
                if low >= cmp::min(head.high.load(Relaxed), SEG_SIZE) { break }
                if head.low.compare_and_swap(low, low+1, Relaxed) == low {
                    loop {
                        if unsafe { head.ready.get_unchecked(low).load(Acquire) } { break }
                    }
                    if low + 1 == SEG_SIZE {
                        loop {
                            if let Some(next) = head.next.load(Acquire, &guard) {
                                self.head.store_shared(Some(next), Release);
                                break
                            }
                        }
                    }
                    return Some(unsafe { ptr::read((*head).data.get_unchecked(low).get()) })
                }
            }
            if head.next.load(Relaxed, &guard).is_none() { return None }
        }
    }
}

#[cfg(test)]
mod test {
    const CONC_COUNT: i64 = 1000000;

    use std::io::stderr;
    use std::io::prelude::*;

    use mem::epoch;
    use scope;
    use super::*;

    #[test]
    fn smoke_queue() {
        let q: SegQueue = SegQueue::new();
    }

    #[test]
    fn push_pop_1() {
        let q: SegQueue = SegQueue::new();
        q.push(37);
        assert_eq!(q.pop(), Some(37));
    }

    #[test]
    fn push_pop_2() {
        let q: SegQueue = SegQueue::new();
        q.push(37);
        q.push(48);
        assert_eq!(q.pop(), Some(37));
        assert_eq!(q.pop(), Some(48));
    }

    #[test]
    fn push_pop_many_seq() {
        let q: SegQueue = SegQueue::new();
        for i in 0..200 {
            q.push(i)
        }
        writeln!(stderr(), "done pushing");
        for i in 0..200 {
            assert_eq!(q.pop(), Some(i));
        }
    }

    #[test]
    fn push_pop_many_spsc() {
        let q: SegQueue = SegQueue::new();

        scope(|scope| {
            scope.spawn(|| {
                let mut next = 0;

                while next < CONC_COUNT {
                    if let Some(elem) = q.pop() {
                        assert_eq!(elem, next);
                        next += 1;
                    }
                }
            });

            for i in 0..CONC_COUNT {
                q.push(i)
            }
        });
    }

    #[test]
    fn push_pop_many_spmc() {
        use std::time::Duration;

        fn recv(t: i32, q: &SegQueue) {
            let mut cur = -1;
            for i in 0..CONC_COUNT {
                if let Some(elem) = q.pop() {
                    if elem <= cur {
                        writeln!(stderr(), "{}: {} <= {}", t, elem, cur);
                    }
                    assert!(elem > cur);
                    cur = elem;

                    if cur == CONC_COUNT - 1 { break }
                }

                if i % 10000 == 0 {
                    //writeln!(stderr(), "{}: {} @ {}", t, i, cur);
                }
            }
        }

        let q: SegQueue = SegQueue::new();
        let qr = &q;
        scope(|scope| {
            for i in 0..3 {
                scope.spawn(move || recv(i, qr));
            }

            scope.spawn(|| {
                for i in 0..CONC_COUNT {
                    q.push(i);

                    if i % 10000 == 0 {
                        //writeln!(stderr(), "Push: {}", i);
                    }
                }
            })
        });
    }

    #[test]
    fn push_pop_many_mpmc() {
        enum LR { Left(i64), Right(i64) }

        let q: SegQueue = SegQueue::new();

        scope(|scope| {
            for _t in 0..2 {
                scope.spawn(|| {
                    for i in CONC_COUNT-1..CONC_COUNT {
                        q.push(LR::Left(i))
                    }
                });
                scope.spawn(|| {
                    for i in CONC_COUNT-1..CONC_COUNT {
                        q.push(LR::Right(i))
                    }
                });
                scope.spawn(|| {
                    let mut vl = vec![];
                    let mut vr = vec![];
                    for _i in 0..CONC_COUNT {
                        match q.pop() {
                            Some(LR::Left(x)) => vl.push(x),
                            Some(LR::Right(x)) => vr.push(x),
                            _ => {}
                        }
                    }

                    let mut vl2 = vl.clone();
                    let mut vr2 = vr.clone();
                    vl2.sort();
                    vr2.sort();

                    assert_eq!(vl, vl2);
                    assert_eq!(vr, vr2);
                });
            }
        });
    }
}
deps/crossbeam-0.1.6/src/sync/mod.rs0000644000076600000240000000037712567654027015645 0ustar  dialout//! Synchronization primitives.

pub use self::ms_queue::MsQueue;
pub use self::atomic_option::AtomicOption;
pub use self::treiber_stack::TreiberStack;
pub use self::seg_queue::SegQueue;

mod atomic_option;
mod ms_queue;
mod treiber_stack;
mod seg_queue;
deps/crossbeam-0.1.6/src/bin/0000755000000000000000000000000012666635520014477 5ustar  rootrootdeps/crossbeam-0.1.6/src/bin/bench.rs0000755000076600000240000001014212615736406015727 0ustar  dialout#![cfg_attr(feature = "nightly",
            feature(duration_span))]

extern crate crossbeam;

use std::collections::VecDeque;
use std::sync::Mutex;
use std::sync::mpsc::channel;
use std::time::Duration;

use crossbeam::scope;
use crossbeam::sync::MsQueue;
use crossbeam::sync::SegQueue;

use extra_impls::mpsc_queue::Queue as MpscQueue;

mod extra_impls;

const COUNT: u64 = 10000000;
const THREADS: u64 = 2;

#[cfg(feature = "nightly")]
fn time(f: F) -> Duration {
    Duration::span(f)
}

#[cfg(not(feature = "nightly"))]
fn time(_f: F) -> Duration {
    Duration::new(0, 0)
}

fn nanos(d: Duration) -> f64 {
    d.as_secs() as f64 * 1000000000f64 + (d.subsec_nanos() as f64)
}

trait Queue {
    fn push(&self, T);
    fn pop(&self) -> Option;
}

impl Queue for MsQueue {
    fn push(&self, t: T) { self.push(t) }
    fn pop(&self) -> Option { self.pop() }
}

impl Queue for SegQueue {
    fn push(&self, t: T) { self.push(t) }
    fn pop(&self) -> Option { self.pop() }
}

impl Queue for MpscQueue {
    fn push(&self, t: T) { self.push(t) }
    fn pop(&self) -> Option {
        use extra_impls::mpsc_queue::*;

        loop {
            match self.pop() {
                Data(t) => return Some(t),
                Empty => return None,
                Inconsistent => (),
            }
        }
    }
}

impl Queue for Mutex> {
    fn push(&self, t: T) { self.lock().unwrap().push_back(t) }
    fn pop(&self) -> Option { self.lock().unwrap().pop_front() }
}

fn bench_queue_mpsc + Sync>(q: Q) -> f64 {
    let d = time(|| {
        scope(|scope| {
            for _i in 0..THREADS {
                let qr = &q;
                scope.spawn(move || {
                    for x in 0..COUNT {
                        let _ = qr.push(x);
                    }
                });
            }

            let mut count = 0;
            while count < COUNT*THREADS {
                if q.pop().is_some() {
                    count += 1;
                }
            }
        });
    });

    nanos(d) / ((COUNT * THREADS) as f64)
}

fn bench_queue_mpmc + Sync>(q: Q) -> f64 {
    use std::sync::atomic::AtomicUsize;
    use std::sync::atomic::Ordering::Relaxed;

    let prod_count = AtomicUsize::new(0);

    let d = time(|| {
        scope(|scope| {
            for _i in 0..THREADS {
                let qr = &q;
                let pcr = &prod_count;
                scope.spawn(move || {
                    for _x in 0..COUNT {
                        qr.push(true);
                    }
                    if pcr.fetch_add(1, Relaxed) == (THREADS as usize) - 1 {
                        for _x in 0..THREADS {
                            qr.push(false)
                        }
                    }
                });
                scope.spawn(move || {
                    loop {
                        if let Some(false) = qr.pop() { break }
                    }
                });
            }


        });
    });

    nanos(d) / ((COUNT * THREADS) as f64)
}

fn bench_chan_mpsc() -> f64 {
    let (tx, rx) = channel();

    let d = time(|| {
        scope(|scope| {
            for _i in 0..THREADS {
                let my_tx = tx.clone();

                scope.spawn(move || {
                    for x in 0..COUNT {
                        let _ = my_tx.send(x);
                    }
                });
            }

            for _i in 0..COUNT*THREADS {
                let _ = rx.recv().unwrap();
            }
        });
    });

    nanos(d) / ((COUNT * THREADS) as f64)
}

fn main() {
    println!("MSQ mpsc: {}", bench_queue_mpsc(MsQueue::new()));
    println!("chan mpsc: {}", bench_chan_mpsc());
    println!("mpsc mpsc: {}", bench_queue_mpsc(MpscQueue::new()));
    println!("Seg mpsc: {}", bench_queue_mpsc(SegQueue::new()));

    println!("MSQ mpmc: {}", bench_queue_mpmc(MsQueue::new()));
    println!("Seg mpmc: {}", bench_queue_mpmc(SegQueue::new()));

//    println!("queue_mpsc: {}", bench_queue_mpsc());
//    println!("queue_mpmc: {}", bench_queue_mpmc());
//   println!("mutex_mpmc: {}", bench_mutex_mpmc());
}
deps/crossbeam-0.1.6/src/bin/extra_impls/0000755000000000000000000000000012666635520017026 5ustar  rootrootdeps/crossbeam-0.1.6/src/bin/extra_impls/mpsc_queue.rs0000644000076600000240000001260612615736406021351 0ustar  dialout/* Copyright (c) 2010-2011 Dmitry Vyukov. All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *    1. Redistributions of source code must retain the above copyright notice,
 *       this list of conditions and the following disclaimer.
 *
 *    2. 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.
 *
 * THIS SOFTWARE IS PROVIDED BY DMITRY VYUKOV "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 DMITRY VYUKOV OR CONTRIBUTORS 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.
 *
 * The views and conclusions contained in the software and documentation are
 * those of the authors and should not be interpreted as representing official
 * policies, either expressed or implied, of Dmitry Vyukov.
 */

//! A mostly lock-free multi-producer, single consumer queue.
//!
//! This module contains an implementation of a concurrent MPSC queue. This
//! queue can be used to share data between threads, and is also used as the
//! building block of channels in rust.
//!
//! Note that the current implementation of this queue has a caveat of the `pop`
//! method, and see the method for more information about it. Due to this
//! caveat, this queue may not be appropriate for all use-cases.

// http://www.1024cores.net/home/lock-free-algorithms
//                         /queues/non-intrusive-mpsc-node-based-queue

pub use self::PopResult::*;

use std::mem;
use std::ptr;
use std::cell::UnsafeCell;

use std::sync::atomic::{AtomicPtr, Ordering};

/// A result of the `pop` function.
pub enum PopResult {
    /// Some data has been popped
    Data(T),
    /// The queue is empty
    Empty,
    /// The queue is in an inconsistent state. Popping data should succeed, but
    /// some pushers have yet to make enough progress in order allow a pop to
    /// succeed. It is recommended that a pop() occur "in the near future" in
    /// order to see if the sender has made progress or not
    Inconsistent,
}

struct Node {
    next: AtomicPtr>,
    value: Option,
}

/// The multi-producer single-consumer structure. This is not cloneable, but it
/// may be safely shared so long as it is guaranteed that there is only one
/// popper at a time (many pushers are allowed).
pub struct Queue {
    head: AtomicPtr>,
    tail: UnsafeCell<*mut Node>,
}

unsafe impl Send for Queue { }
unsafe impl Sync for Queue { }

impl Node {
    unsafe fn new(v: Option) -> *mut Node {
        mem::transmute(Box::new(Node {
            next: AtomicPtr::new(ptr::null_mut()),
            value: v,
        }))
    }
}

impl Queue {
    /// Creates a new queue that is safe to share among multiple producers and
    /// one consumer.
    pub fn new() -> Queue {
        let stub = unsafe { Node::new(None) };
        Queue {
            head: AtomicPtr::new(stub),
            tail: UnsafeCell::new(stub),
        }
    }

    /// Pushes a new value onto this queue.
    pub fn push(&self, t: T) {
        unsafe {
            let n = Node::new(Some(t));
            let prev = self.head.swap(n, Ordering::AcqRel);
            (*prev).next.store(n, Ordering::Release);
        }
    }

    /// Pops some data from this queue.
    ///
    /// Note that the current implementation means that this function cannot
    /// return `Option`. It is possible for this queue to be in an
    /// inconsistent state where many pushes have succeeded and completely
    /// finished, but pops cannot return `Some(t)`. This inconsistent state
    /// happens when a pusher is pre-empted at an inopportune moment.
    ///
    /// This inconsistent state means that this queue does indeed have data, but
    /// it does not currently have access to it at this time.
    pub fn pop(&self) -> PopResult {
        unsafe {
            let tail = *self.tail.get();
            let next = (*tail).next.load(Ordering::Acquire);

            if !next.is_null() {
                *self.tail.get() = next;
                assert!((*tail).value.is_none());
                assert!((*next).value.is_some());
                let ret = (*next).value.take().unwrap();
                let _: Box> = mem::transmute(tail);
                return Data(ret);
            }

            if self.head.load(Ordering::Acquire) == tail {Empty} else {Inconsistent}
        }
    }
}

impl Drop for Queue {
    fn drop(&mut self) {
        unsafe {
            let mut cur = *self.tail.get();
            while !cur.is_null() {
                let next = (*cur).next.load(Ordering::Relaxed);
                let _: Box> = mem::transmute(cur);
                cur = next;
            }
        }
    }
}
deps/crossbeam-0.1.6/src/bin/extra_impls/mod.rs0000644000076600000240000000002412567443246017754 0ustar  dialoutpub mod mpsc_queue;
deps/crossbeam-0.1.6/src/scoped.rs0000644000076600000240000001703112615736406015356 0ustar  dialoutuse std::cell::RefCell;
use std::mem;
use std::rc::Rc;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::thread;

use {spawn_unsafe, FnBox};
use sync::AtomicOption;

pub struct Scope<'a> {
    dtors: RefCell>>
}

struct DtorChain<'a> {
    dtor: Box,
    next: Option>>
}

enum JoinState {
    Running(thread::JoinHandle<()>),
    Joined,
}

impl JoinState {
    fn join(&mut self) {
        let mut state = JoinState::Joined;
        mem::swap(self, &mut state);
        if let JoinState::Running(handle) = state {
            let res = handle.join();

            if !thread::panicking() { res.unwrap(); }
        }
    }
}

/// A handle to a scoped thread
pub struct ScopedJoinHandle {
    inner: Rc>,
    packet: Arc>,
    thread: thread::Thread,
}

/// Create a new `scope`, for deferred destructors.
///
/// Scopes, in particular, support [*scoped thread spawning*](struct.Scope.html#method.spawn).
///
/// # Examples
///
/// Creating and using a scope:
///
/// ```
/// crossbeam::scope(|scope| {
///     scope.defer(|| println!("Exiting scope"));
///     scope.spawn(|| println!("Running child thread in scope"))
/// });
/// // Prints messages in the reverse order written
/// ```
pub fn scope<'a, F, R>(f: F) -> R where F: FnOnce(&Scope<'a>) -> R {
    let mut scope = Scope { dtors: RefCell::new(None) };
    let ret = f(&scope);
    scope.drop_all();
    ret
}

impl<'a> Scope<'a> {
    // This method is carefully written in a transactional style, so
    // that it can be called directly and, if any dtor panics, can be
    // resumed in the unwinding this causes. By initially running the
    // method outside of any destructor, we avoid any leakage problems
    // due to @rust-lang/rust#14875.
    fn drop_all(&mut self) {
        loop {
            // use a separate scope to ensure that the RefCell borrow
            // is relinquishe before running `dtor`
            let dtor = {
                let mut dtors = self.dtors.borrow_mut();
                if let Some(mut node) = dtors.take() {
                    *dtors = node.next.take().map(|b| *b);
                    node.dtor
                } else {
                    return
                }
            };
            dtor.call_box()
        }
    }

    /// Schedule code to be executed when exiting the scope.
    ///
    /// This is akin to having a destructor on the stack, except that it is
    /// *guaranteed* to be run.
    pub fn defer(&self, f: F) where F: FnOnce() + 'a {
        let mut dtors = self.dtors.borrow_mut();
        *dtors = Some(DtorChain {
            dtor: Box::new(f),
            next: dtors.take().map(Box::new)
        });
    }

    /// Create a scoped thread.
    ///
    /// `spawn` is similar to the [`spawn`][spawn] function in Rust's standard library. The
    /// difference is that this thread is scoped, meaning that it's guaranteed to terminate
    /// before the current stack frame goes away, allowing you to reference the parent stack frame
    /// directly. This is ensured by having the parent thread join on the child thread before the
    /// scope exits.
    ///
    /// [spawn]: http://doc.rust-lang.org/std/thread/fn.spawn.html
    ///
    /// # Examples
    ///
    /// A basic scoped thread:
    ///
    /// ```
    /// crossbeam::scope(|scope| {
    ///     scope.spawn(|| {
    ///         println!("Hello from a scoped thread!");
    ///     });
    /// });
    /// ```
    ///
    /// When writing concurrent Rust programs, you'll sometimes see a pattern like this, using
    /// [`std::thread::spawn`][spawn]:
    ///
    /// ```ignore
    /// let array = [1, 2, 3];
    /// let mut guards = vec![];
    ///
    /// for i in &array {
    ///     let guard = std::thread::spawn(move || {
    ///         println!("element: {}", i);
    ///     });
    ///
    ///     guards.push(guard);
    /// }
    ///
    /// for guard in guards {
    ///     guard.join().unwrap();
    /// }
    /// ```
    ///
    /// The basic pattern is:
    ///
    /// 1. Iterate over some collection.
    /// 2. Spin up a thread to operate on each part of the collection.
    /// 3. Join all the threads.
    ///
    /// However, this code actually gives an error:
    ///
    /// ```text
    /// error: `array` does not live long enough
    /// for i in &array {
    ///           ^~~~~
    /// in expansion of for loop expansion
    /// note: expansion site
    /// note: reference must be valid for the static lifetime...
    /// note: ...but borrowed value is only valid for the block suffix following statement 0 at ...
    ///     let array = [1, 2, 3];
    ///     let mut guards = vec![];
    ///
    ///     for i in &array {
    ///         let guard = std::thread::spawn(move || {
    ///             println!("element: {}", i);
    /// ...
    /// error: aborting due to previous error
    /// ```
    ///
    /// Because [`std::thread::spawn`][spawn] doesn't know about this scope, it requires a
    /// `'static` lifetime. One way of giving it a proper lifetime is to use an [`Arc`][arc]:
    ///
    /// [arc]: http://doc.rust-lang.org/stable/std/sync/struct.Arc.html
    ///
    /// ```
    /// use std::sync::Arc;
    ///
    /// let array = Arc::new([1, 2, 3]);
    /// let mut guards = vec![];
    ///
    /// for i in (0..array.len()) {
    ///     let a = array.clone();
    ///
    ///     let guard = std::thread::spawn(move || {
    ///         println!("element: {}", a[i]);
    ///     });
    ///
    ///     guards.push(guard);
    /// }
    ///
    /// for guard in guards {
    ///     guard.join().unwrap();
    /// }
    /// ```
    ///
    /// But this introduces unnecessary allocation, as `Arc` puts its data on the heap, and we
    /// also end up dealing with reference counts. We know that we're joining the threads before
    /// our function returns, so just taking a reference _should_ be safe. Rust can't know that,
    /// though.
    ///
    /// Enter scoped threads. Here's our original example, using `spawn` from crossbeam rather
    /// than from `std::thread`:
    ///
    /// ```
    /// let array = [1, 2, 3];
    ///
    /// crossbeam::scope(|scope| {
    ///     for i in &array {
    ///         scope.spawn(move || {
    ///             println!("element: {}", i);
    ///         });
    ///     }
    /// });
    /// ```
    ///
    /// Much more straightforward.
    pub fn spawn(&self, f: F) -> ScopedJoinHandle where
        F: FnOnce() -> T + Send + 'a, T: Send + 'a
    {
        let their_packet = Arc::new(AtomicOption::new());
        let my_packet = their_packet.clone();

        let join_handle = unsafe {
            spawn_unsafe(move || {
                their_packet.swap(f(), Ordering::Relaxed);
            })
        };

        let thread = join_handle.thread().clone();
        let deferred_handle = Rc::new(RefCell::new(JoinState::Running(join_handle)));
        let my_handle = deferred_handle.clone();

        self.defer(move || {
            let mut state = deferred_handle.borrow_mut();
            state.join();
        });

        ScopedJoinHandle {
            inner: my_handle,
            packet: my_packet,
            thread: thread,
        }
    }
}

impl ScopedJoinHandle {
    /// Join the scoped thread, returning the result it produced.
    pub fn join(self) -> T {
        self.inner.borrow_mut().join();
        self.packet.take(Ordering::Relaxed).unwrap()
    }

    /// Get the underlying thread handle.
    pub fn thread(&self) -> &thread::Thread {
        &self.thread
    }
}

impl<'a> Drop for Scope<'a> {
    fn drop(&mut self) {
        self.drop_all()
    }
}
deps/crossbeam-0.1.6/Cargo.toml0000644000076600000240000000057412615737514014701 0ustar  dialout[package]
name = "crossbeam"
version = "0.1.6"
authors = ["Aaron Turon "]
description = "Support for lock-free data structures, synchronizers, and parallel programming"
repository = "https://github.com/aturon/crossbeam"
documentation = "http://aturon.github.io/crossbeam-doc/crossbeam/"
readme = "README.md"
license = "Apache-2.0/MIT"

[features]
nightly = []
deps/crossbeam-0.1.6/.DS_Store0000644000076600000240000001400412566733054014425 0ustar  dialoutBud1
	o.lock	
Cargo.lockIlocblobF(
Cargo.tomlIlocblob(LICENSEIlocblobR(	README.mdIlocblob(scala-benchIlocblob^(srcIlocblobFtargetIlocblobtargetbwspblobbplist00			]ShowStatusBar[ShowPathbar[ShowToolbar[ShowTabView_ContainerShowSidebar\WindowBounds\SidebarWidth[ShowSidebar		_{{838, -0}, {838, 1028}}y	'3?Kbo|targetvSrnlong @ @ @ @E
DSDB ` @ @ @deps/crossbeam-0.1.6/scala-bench/0000755000000000000000000000000012666635520015300 5ustar  rootrootdeps/crossbeam-0.1.6/scala-bench/bench.scala0000644000076600000240000001107612567170017017167 0ustar  dialoutimport scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent._
import scala.concurrent.duration._
import java.util.concurrent.ConcurrentLinkedQueue
import java.util.concurrent.atomic._
import java.util.Stack

import scala.annotation.tailrec

final class MSQueue[A](a: A) {
  private abstract class Q
  private final case class Node(data: A, next: AtomicReference[Q] = new AtomicReference(Emp)) extends Q
  private final case object Emp extends Q
  private val head = new AtomicReference(Node(a))
  private val tail = new AtomicReference(head.get())

  def enq(a: A) {
    val newNode = new Node(a)
    while (true) {
      val curTail = tail.get()
      curTail.next.get()match {
        case n@Node(_,_) => tail.compareAndSet(curTail, n)
        case Emp => {
          if (curTail.next.compareAndSet(Emp, newNode)) {
            tail.compareAndSet(curTail, newNode)
            return
          }
        }
      }
    }
  }

  def deq(): Option[A] = {
    while (true) {
      val cur_head = head.get()
      cur_head.next.get() match {
        case Emp => return None
        case n@Node(data, _) => {
          if (head.compareAndSet(cur_head, n)) {
            return Some(data)
          }
        }
      }
    }
    None
  }
}

abstract class MyBool
final case class MyTrue() extends MyBool
final case class MyFalse() extends MyBool

object Bench {
  def time(block: => Unit): Long = {
    val t0 = System.nanoTime()
    val result = block    // call-by-name
    val t1 = System.nanoTime()
    t1 - t0
  }

  def do_linked(threads: Int, count: Int) {
    val q: ConcurrentLinkedQueue[MyBool] = new ConcurrentLinkedQueue();

    val t = time {
      var s = new Stack[Future[Unit]]
      for (i <- 1 to threads) {
        s.push(Future {
          for (i <- 1 to count+1) {
            //if (i % 100000 == 0) { println(q.size()) }
            q.offer(MyTrue())
          }
        })
      }

      var rn = 0
      while (rn < count) {
        if (q.poll() != null) {
          rn += 1
        }
      }

      while (!s.empty()) {
        Await.ready(s.pop(), Duration.Inf)
      }
    }

    println("Linked: " + t / (count * threads))
  }

  def do_linked_mpmc(threads: Int, count: Int) {
    val q = new ConcurrentLinkedQueue[MyBool];
    val prod = new AtomicInteger();

    val t = time {
      var s = new Stack[Future[Unit]]
      for (i <- 1 to threads) {
        s.push(Future {
          for (i <- 1 to count+1) {
            q.offer(MyTrue())
            //if (i % 100000 == 0) { println(q.size()) }
          }
          if (prod.incrementAndGet() == threads) {
            for (i <- 0 to threads) { q.offer(MyFalse()) }
          }
        })
        s.push(Future {
          var done = false;
          while (!done) {
            q.poll() match {
              case MyFalse() => done = true
              case _ => {}
            }
          }
        })
      }

      while (!s.empty()) {
        Await.ready(s.pop(), Duration.Inf)
      }
    }

    println("Linked mpmc: " + t / (count * threads) + " (" + t / 1000000000 + ")")
  }


  def do_msq(threads: Int, count: Int) {
    val q = new MSQueue[Int](0);

    val t = time {
      var s = new Stack[Future[Unit]]
      for (i <- 1 to threads) {
        s.push(Future { for (i <- 1 to count+1) { q.enq(i) } })
      }

      var rn = 0
      while (rn < count) {
        if (q.deq() != None) {
          rn += 1
        }
      }

      while (!s.empty()) {
        Await.ready(s.pop(), Duration.Inf)
      }
    }

    println("MSQ: " + t / (count * threads) + " (" + t / 1000000000 + ")")
  }

  def do_msq_mpmc(threads: Int, count: Int) {
    val q = new MSQueue[Boolean](true);
    val prod = new AtomicInteger();

    val t = time {
      var s = new Stack[Future[Unit]]
      for (i <- 1 to threads) {
        s.push(Future {
          for (i <- 1 to count+1) { q.enq(true) }
          if (prod.incrementAndGet() == threads) {
            for (i <- 1 to threads) { q.enq(false) }
          }
        })
        s.push(Future {
          var done = false;
          while (!done) {
            q.deq() match {
              case Some(false) => done = true
              case _ => {}
            }
          }
        })
      }

      while (!s.empty()) {
        Await.ready(s.pop(), Duration.Inf)
      }
    }

    println("MSQ mpmc: " + t / (count * threads) + " (" + t / 1000000000 + ")")
  }

  def main(args: Array[String]) {
    do_linked(2, 1000000)
    do_linked(2, 10000000)

    do_msq(2, 1000000)
    do_msq(2, 10000000)

    do_linked_mpmc(2, 1000000)
    do_linked_mpmc(2, 10000000)

    do_msq_mpmc(2, 1000000)
    do_msq_mpmc(2, 10000000)
  }
}
deps/git2-curl-0.3.0/0000755000000000000000000000000012666635520012766 5ustar  rootrootdeps/git2-curl-0.3.0/src/0000755000000000000000000000000012666635520013555 5ustar  rootrootdeps/git2-curl-0.3.0/src/lib.rs0000664000175000017500000001671012517471774013126 0ustar  //! A crate for using libcurl as a backend for HTTP git requests with git2-rs.
//!
//! This crate provides one public function, `register`, which will register
//! a custom HTTP transport with libcurl for any HTTP requests made by libgit2.
//! At this time the `register` function is unsafe for the same reasons that
//! `git2::transport::register` is also unsafe.
//!
//! It is not recommended to use this crate wherever possible. The current
//! libcurl backend used, `curl-rust`, only supports executing a request in one
//! method call implying no streaming support. This consequently means that
//! when a repository is cloned the entire contents of the repo are downloaded
//! into memory, and *then* written off to disk by libgit2 afterwards. It
//! should be possible to alleviate this problem in the future.
//!
//! > **NOTE**: At this time this crate likely does not support a `git push`
//! >           operation, only clones.

#![doc(html_root_url = "http://alexcrichton.com/git2-rs")]

extern crate git2;
extern crate curl;
extern crate url;
#[macro_use] extern crate log;

use std::io::prelude::*;
use std::io::{self, Cursor};
use std::sync::{Once, ONCE_INIT, Arc, Mutex};
use std::error;

use curl::http::handle::Method;
use curl::http::{Handle, Request};
use git2::Error;
use git2::transport::{SmartSubtransportStream};
use git2::transport::{Transport, SmartSubtransport, Service};
use url::Url;

struct CurlTransport {
    handle: Arc>,
}

struct CurlSubtransport {
    handle: Arc>,
    service: &'static str,
    url_path: &'static str,
    base_url: String,
    method: Method,
    reader: Option>>,
    sent_request: bool,
}

struct MyHandle(Handle);
unsafe impl Send for MyHandle {} // Handle is not send...

/// Register the libcurl backend for HTTP requests made by libgit2.
///
/// This function takes one parameter, a `handle`, which is used to perform all
/// future HTTP requests. The handle can be previously configured with
/// information such as proxies, SSL information, etc.
///
/// This function is unsafe largely for the same reasons as
/// `git2::transport::register`:
///
/// * The function needs to be synchronized against all other creations of
///   transport (any API calls to libgit2).
/// * The function will leak `handle` as once registered it is not currently
///   possible to unregister the backend.
///
/// This function may be called concurrently, but only the first `handle` will
/// be used. All others will be discarded.
pub unsafe fn register(handle: Handle) {
    static INIT: Once = ONCE_INIT;

    let handle = Arc::new(Mutex::new(MyHandle(handle)));
    let handle2 = handle.clone();
    INIT.call_once(move || {
        git2::transport::register("http", move |remote| {
            factory(remote, handle.clone())
        }).unwrap();
        git2::transport::register("https", move |remote| {
            factory(remote, handle2.clone())
        }).unwrap();
    });
}

fn factory(remote: &git2::Remote, handle: Arc>)
           -> Result {
    Transport::smart(remote, true, CurlTransport { handle: handle })
}

impl SmartSubtransport for CurlTransport {
    fn action(&self, url: &str, action: Service)
              -> Result, Error> {
        let (service, path, method) = match action {
            Service::UploadPackLs => {
                ("upload-pack", "/info/refs?service=git-upload-pack", Method::Get)
            }
            Service::UploadPack => {
                ("upload-pack", "/git-upload-pack", Method::Post)
            }
            Service::ReceivePackLs => {
                ("receive-pack", "/info/refs?service=git-receive-pack",
                 Method::Get)
            }
            Service::ReceivePack => {
                ("receive-pack", "/git-receive-pack", Method::Post)
            }
        };
        info!("action {} {}", service, path);
        Ok(Box::new(CurlSubtransport {
            handle: self.handle.clone(),
            service: service,
            url_path: path,
            base_url: url.to_string(),
            method: method,
            reader: None,
            sent_request: false,
        }))
    }

    fn close(&self) -> Result<(), Error> {
        Ok(()) // ...
    }
}

impl CurlSubtransport {
    fn err>>(&self, err: E) -> io::Error {
        io::Error::new(io::ErrorKind::Other, err)
    }

    fn execute(&mut self, mut data: &[u8]) -> io::Result<()> {
        if self.sent_request {
            return Err(self.err("already sent HTTP request"))
        }
        let agent = format!("git/1.0 (git2-curl {})", env!("CARGO_PKG_VERSION"));

        // Parse our input URL to figure out the host
        let url = format!("{}{}", self.base_url, self.url_path);
        let parsed = try!(Url::parse(&url).map_err(|_| {
            self.err("invalid url, failed to parse")
        }));
        let host = match parsed.host() {
            Some(host) => host.to_string(),
            None => return Err(self.err("invalid url, did not have a host")),
        };

        // Prep the request
        debug!("request to {}", url);
        let mut h = self.handle.lock().unwrap();
        let mut req = Request::new(&mut h.0, self.method)
                              .uri(url)
                              .header("User-Agent", &agent)
                              .header("Host", &host)
                              .follow_redirects(true);
        if data.len() > 0 {
            req = req.body(&mut data)
                     .content_length(data.len())
                     .header("Accept", &format!("application/x-git-{}-result",
                                                self.service))
                     .header("Content-Type",
                             &format!("application/x-git-{}-request",
                                      self.service));
        } else {
            req = req.header("Accept", "*/*");
        }

        // Send the request
        let resp = try!(req.exec().map_err(|e| self.err(e)));
        debug!("response: {}", resp);
        if resp.get_code() != 200 {
            return Err(self.err(&format!("failed to receive HTTP 200 response: \
                                          got {}", resp.get_code())[..]))
        }

        // Check returned headers
        let expected = match self.method {
            Method::Get => format!("application/x-git-{}-advertisement",
                                   self.service),
            _ => format!("application/x-git-{}-result", self.service),
        };
        if &resp.get_header("content-type") != &[expected.clone()] {
            return Err(self.err(&format!("invalid Content-Type header: \
                                          found `{:?}` expected `{}`",
                                         resp.get_header("Content-Type"),
                                         expected)[..]))
        }

        // Ok, time to read off some data.
        let rdr = Cursor::new(resp.move_body());
        self.reader = Some(rdr);
        Ok(())
    }
}

impl Read for CurlSubtransport {
    fn read(&mut self, buf: &mut [u8]) -> io::Result {
        if self.reader.is_none() {
            try!(self.execute(&[]));
        }
        self.reader.as_mut().unwrap().read(buf)
    }
}

impl Write for CurlSubtransport {
    fn write(&mut self, data: &[u8]) -> io::Result {
        if self.reader.is_none() {
            try!(self.execute(data));
        }
        Ok(data.len())
    }
    fn flush(&mut self) -> io::Result<()> { Ok(()) }
}
deps/git2-curl-0.3.0/tests/0000755000000000000000000000000012666635520014130 5ustar  rootrootdeps/git2-curl-0.3.0/tests/tempdir.rs0000664000175000017500000000054112473220215014351 0ustar  use std::old_io;
use std::io;
use std::path;

pub struct TempDir {
    inner: old_io::TempDir,
}

impl TempDir {
    pub fn new(prefix: &str) -> io::Result {
        Ok(TempDir { inner: old_io::TempDir::new(prefix).unwrap() })
    }

    pub fn path(&self) -> &path::Path {
        path::Path::new(self.inner.path().as_str().unwrap())
    }
}

deps/git2-curl-0.3.0/tests/all.rs0000664000175000017500000000465312555773235013505 0ustar  extern crate conduit_git_http_backend as git_backend;
extern crate git2_curl;
extern crate civet;
extern crate conduit;
extern crate curl;
extern crate git2;
extern crate tempdir;

use civet::{Server, Config};
use std::fs::File;
use std::path::Path;
use tempdir::TempDir;

const PORT: u16 = 7848;

fn main() {
    unsafe {
        let h = curl::http::handle::Handle::new();
        git2_curl::register(h.timeout(1000));
    }

    // Spin up a server for git-http-backend
    let td = TempDir::new("wut").unwrap();
    let _a = Server::start(Config { port: PORT, threads: 1 },
                           git_backend::Serve(td.path().to_path_buf()));

    // Prep a repo with one file called `foo`
    let sig = git2::Signature::now("foo", "bar").unwrap();
    let r1 = git2::Repository::init(td.path()).unwrap();
    File::create(&td.path().join(".git").join("git-daemon-export-ok")).unwrap();
    {
        let mut index = r1.index().unwrap();
        File::create(&td.path().join("foo")).unwrap();
        index.add_path(Path::new("foo")).unwrap();
        index.write().unwrap();
        let tree_id = index.write_tree().unwrap();
        r1.commit(Some("HEAD"), &sig, &sig, "test",
                  &r1.find_tree(tree_id).unwrap(),
                  &[]).unwrap();
    }

    // Clone through the git-http-backend
    let td2 = TempDir::new("wut2").unwrap();
    let r = git2::Repository::clone(&format!("http://localhost:{}", PORT),
                                    td2.path()).unwrap();
    assert!(File::open(&td2.path().join("foo")).is_ok());
    {
        File::create(&td.path().join("bar")).unwrap();
        let mut index = r1.index().unwrap();
        index.add_path(&Path::new("bar")).unwrap();
        index.write().unwrap();
        let tree_id = index.write_tree().unwrap();
        let parent = r1.head().ok().and_then(|h| h.target()).unwrap();
        let parent = r1.find_commit(parent).unwrap();
        r1.commit(Some("HEAD"), &sig, &sig, "test",
                  &r1.find_tree(tree_id).unwrap(),
                  &[&parent]).unwrap();
    }

    let mut remote = r.find_remote("origin").unwrap();
    remote.fetch(&["refs/heads/*:refs/heads/*"], None, None).unwrap();
    let b = r.find_branch("master", git2::BranchType::Local).unwrap();
    let id = b.get().target().unwrap();
    let obj = r.find_object(id, None).unwrap();
    r.reset(&obj, git2::ResetType::Hard, None).unwrap();;

    assert!(File::open(&td2.path().join("bar")).is_ok());
}
deps/git2-curl-0.3.0/Cargo.toml0000664000175000017500000000121312557237324013136 0ustar  [package]

name = "git2-curl"
version = "0.3.0"
authors = ["Alex Crichton "]
license = "MIT/Apache-2.0"
repository = "https://github.com/alexcrichton/git2-rs"
homepage = "https://github.com/alexcrichton/git2-rs"
documentation = "http://alexcrichton.com/git2-rs/git2-curl"
description = """
Backend for an HTTP transport in libgit2 powered by libcurl.

Intended to be used with the git2 crate.
"""

[dependencies]
curl = "0.2"
url = "0.2"
log = "0.3"
git2 = { path = "..", version = "0.3" }

[dev-dependencies]
civet = "0.7"
conduit = "0.7"
conduit-git-http-backend = "0.7"
tempdir = "0.3"

[[test]]
name = "all"
harness = false
deps/rustc-serialize-0.3.16/0000755000000000000000000000000012666635520014372 5ustar  rootrootdeps/rustc-serialize-0.3.16/LICENSE-APACHE0000664000175000017500000002513712442360721014540 0ustar                                Apache License
                        Version 2.0, January 2004
                     http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

   "License" shall mean the terms and conditions for use, reproduction,
   and distribution as defined by Sections 1 through 9 of this document.

   "Licensor" shall mean the copyright owner or entity authorized by
   the copyright owner that is granting the License.

   "Legal Entity" shall mean the union of the acting entity and all
   other entities that control, are controlled by, or are under common
   control with that entity. For the purposes of this definition,
   "control" means (i) the power, direct or indirect, to cause the
   direction or management of such entity, whether by contract or
   otherwise, or (ii) ownership of fifty percent (50%) or more of the
   outstanding shares, or (iii) beneficial ownership of such entity.

   "You" (or "Your") shall mean an individual or Legal Entity
   exercising permissions granted by this License.

   "Source" form shall mean the preferred form for making modifications,
   including but not limited to software source code, documentation
   source, and configuration files.

   "Object" form shall mean any form resulting from mechanical
   transformation or translation of a Source form, including but
   not limited to compiled object code, generated documentation,
   and conversions to other media types.

   "Work" shall mean the work of authorship, whether in Source or
   Object form, made available under the License, as indicated by a
   copyright notice that is included in or attached to the work
   (an example is provided in the Appendix below).

   "Derivative Works" shall mean any work, whether in Source or Object
   form, that is based on (or derived from) the Work and for which the
   editorial revisions, annotations, elaborations, or other modifications
   represent, as a whole, an original work of authorship. For the purposes
   of this License, Derivative Works shall not include works that remain
   separable from, or merely link (or bind by name) to the interfaces of,
   the Work and Derivative Works thereof.

   "Contribution" shall mean any work of authorship, including
   the original version of the Work and any modifications or additions
   to that Work or Derivative Works thereof, that is intentionally
   submitted to Licensor for inclusion in the Work by the copyright owner
   or by an individual or Legal Entity authorized to submit on behalf of
   the copyright owner. For the purposes of this definition, "submitted"
   means any form of electronic, verbal, or written communication sent
   to the Licensor or its representatives, including but not limited to
   communication on electronic mailing lists, source code control systems,
   and issue tracking systems that are managed by, or on behalf of, the
   Licensor for the purpose of discussing and improving the Work, but
   excluding communication that is conspicuously marked or otherwise
   designated in writing by the copyright owner as "Not a Contribution."

   "Contributor" shall mean Licensor and any individual or Legal Entity
   on behalf of whom a Contribution has been received by Licensor and
   subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
   this License, each Contributor hereby grants to You a perpetual,
   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
   copyright license to reproduce, prepare Derivative Works of,
   publicly display, publicly perform, sublicense, and distribute the
   Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
   this License, each Contributor hereby grants to You a perpetual,
   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
   (except as stated in this section) patent license to make, have made,
   use, offer to sell, sell, import, and otherwise transfer the Work,
   where such license applies only to those patent claims licensable
   by such Contributor that are necessarily infringed by their
   Contribution(s) alone or by combination of their Contribution(s)
   with the Work to which such Contribution(s) was submitted. If You
   institute patent litigation against any entity (including a
   cross-claim or counterclaim in a lawsuit) alleging that the Work
   or a Contribution incorporated within the Work constitutes direct
   or contributory patent infringement, then any patent licenses
   granted to You under this License for that Work shall terminate
   as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
   Work or Derivative Works thereof in any medium, with or without
   modifications, and in Source or Object form, provided that You
   meet the following conditions:

   (a) You must give any other recipients of the Work or
       Derivative Works a copy of this License; and

   (b) You must cause any modified files to carry prominent notices
       stating that You changed the files; and

   (c) You must retain, in the Source form of any Derivative Works
       that You distribute, all copyright, patent, trademark, and
       attribution notices from the Source form of the Work,
       excluding those notices that do not pertain to any part of
       the Derivative Works; and

   (d) If the Work includes a "NOTICE" text file as part of its
       distribution, then any Derivative Works that You distribute must
       include a readable copy of the attribution notices contained
       within such NOTICE file, excluding those notices that do not
       pertain to any part of the Derivative Works, in at least one
       of the following places: within a NOTICE text file distributed
       as part of the Derivative Works; within the Source form or
       documentation, if provided along with the Derivative Works; or,
       within a display generated by the Derivative Works, if and
       wherever such third-party notices normally appear. The contents
       of the NOTICE file are for informational purposes only and
       do not modify the License. You may add Your own attribution
       notices within Derivative Works that You distribute, alongside
       or as an addendum to the NOTICE text from the Work, provided
       that such additional attribution notices cannot be construed
       as modifying the License.

   You may add Your own copyright statement to Your modifications and
   may provide additional or different license terms and conditions
   for use, reproduction, or distribution of Your modifications, or
   for any such Derivative Works as a whole, provided Your use,
   reproduction, and distribution of the Work otherwise complies with
   the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
   names, trademarks, service marks, or product names of the Licensor,
   except as required for reasonable and customary use in describing the
   origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
   agreed to in writing, Licensor provides the Work (and each
   Contributor provides its Contributions) on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
   implied, including, without limitation, any warranties or conditions
   of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
   PARTICULAR PURPOSE. You are solely responsible for determining the
   appropriateness of using or redistributing the Work and assume any
   risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
   whether in tort (including negligence), contract, or otherwise,
   unless required by applicable law (such as deliberate and grossly
   negligent acts) or agreed to in writing, shall any Contributor be
   liable to You for damages, including any direct, indirect, special,
   incidental, or consequential damages of any character arising as a
   result of this License or out of the use or inability to use the
   Work (including but not limited to damages for loss of goodwill,
   work stoppage, computer failure or malfunction, or any and all
   other commercial damages or losses), even if such Contributor
   has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
   the Work or Derivative Works thereof, You may choose to offer,
   and charge a fee for, acceptance of support, warranty, indemnity,
   or other liability obligations and/or rights consistent with this
   License. However, in accepting such obligations, You may act only
   on Your own behalf and on Your sole responsibility, not on behalf
   of any other Contributor, and only if You agree to indemnify,
   defend, and hold each Contributor harmless for any liability
   incurred by, or claims asserted against, such Contributor by reason
   of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

   To apply the Apache License to your work, attach the following
   boilerplate notice, with the fields enclosed by brackets "[]"
   replaced with your own identifying information. (Don't include
   the brackets!)  The text should be enclosed in the appropriate
   comment syntax for the file format. We also recommend that a
   file or class name and description of purpose be included on the
   same "printed page" as the copyright notice for easier
   identification within third-party archives.

Copyright [yyyy] [name of copyright owner]

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.
deps/rustc-serialize-0.3.16/LICENSE-MIT0000664000175000017500000000205712442360721014244 0ustar  Copyright (c) 2014 The Rust Project Developers

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
deps/rustc-serialize-0.3.16/.travis.yml0000664000175000017500000000154212526021333014713 0ustar  language: rust
rust:
  - 1.0.0
  - beta
  - nightly
sudo: false
script:
  - cargo build --verbose
  - cargo test --verbose
  - |
    [ $TRAVIS_RUST_VERSION != nightly ] || cargo bench --verbose
  - cargo doc
after_success: |
  [ $TRAVIS_BRANCH = master ] &&
  [ $TRAVIS_PULL_REQUEST = false ] &&
  [ $TRAVIS_RUST_VERSION = nightly ] &&
  echo '' > target/doc/index.html &&
  pip install ghp-import --user $USER &&
  $HOME/.local/bin/ghp-import -n target/doc &&
  git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
env:
  global:
    secure: f0CwX+CnvRbEqK3H6zhBQe4u0t14OQvyd6nUhq/oXkJ6LdtrSx+qQtLSmAU7L8p1IXyP8csxv37bTdEB7/U1c6bJcN2OXHrw9nD0NDvZEs1zSZvFQBm+YBwV7EaposPHCeqee3X9b00g7+bObywMYtEkk7yD2NiOY9SjMRcjTLQ=
notifications:
  email:
    on_success: never
deps/rustc-serialize-0.3.16/README.md0000664000175000017500000000123512520213515014057 0ustar  # rustc-serialize

Serialization and deserialization support provided by the compiler in the form
of `derive(RustcEncodable, RustcDecodable)`.

[![Linux Build Status](https://travis-ci.org/rust-lang/rustc-serialize.svg?branch=master)](https://travis-ci.org/rust-lang/rustc-serialize)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/ka194de75aapwpft?svg=true)](https://ci.appveyor.com/project/alexcrichton/rustc-serialize)

[Documentation](http://doc.rust-lang.org/rustc-serialize)

## Usage

Add this to your `Cargo.toml`:

```toml
[dependencies]
rustc-serialize = "0.3"
```

and this to your crate root:

```rust
extern crate rustc_serialize;
```
deps/rustc-serialize-0.3.16/.gitignore0000600000175000017500000000002412442360705014560 0ustar  /target
/Cargo.lock
deps/rustc-serialize-0.3.16/src/0000755000000000000000000000000012666635520015161 5ustar  rootrootdeps/rustc-serialize-0.3.16/src/serialize.rs0000664000175000017500000005600212564147216015742 0ustar  // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0  or the MIT license
// , at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Support code for encoding and decoding types.

/*
Core encoding and decoding interfaces.
*/

use std::cell::{Cell, RefCell};
use std::ffi::OsString;
use std::path;
use std::rc::Rc;
use std::sync::Arc;
use std::marker::PhantomData;
use std::borrow::Cow;

pub trait Encoder {
    type Error;

    // Primitive types:
    fn emit_nil(&mut self) -> Result<(), Self::Error>;
    fn emit_usize(&mut self, v: usize) -> Result<(), Self::Error>;
    fn emit_u64(&mut self, v: u64) -> Result<(), Self::Error>;
    fn emit_u32(&mut self, v: u32) -> Result<(), Self::Error>;
    fn emit_u16(&mut self, v: u16) -> Result<(), Self::Error>;
    fn emit_u8(&mut self, v: u8) -> Result<(), Self::Error>;
    fn emit_isize(&mut self, v: isize) -> Result<(), Self::Error>;
    fn emit_i64(&mut self, v: i64) -> Result<(), Self::Error>;
    fn emit_i32(&mut self, v: i32) -> Result<(), Self::Error>;
    fn emit_i16(&mut self, v: i16) -> Result<(), Self::Error>;
    fn emit_i8(&mut self, v: i8) -> Result<(), Self::Error>;
    fn emit_bool(&mut self, v: bool) -> Result<(), Self::Error>;
    fn emit_f64(&mut self, v: f64) -> Result<(), Self::Error>;
    fn emit_f32(&mut self, v: f32) -> Result<(), Self::Error>;
    fn emit_char(&mut self, v: char) -> Result<(), Self::Error>;
    fn emit_str(&mut self, v: &str) -> Result<(), Self::Error>;

    // Compound types:
    fn emit_enum(&mut self, name: &str, f: F) -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;

    fn emit_enum_variant(&mut self, v_name: &str,
                            v_id: usize,
                            len: usize,
                            f: F) -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;
    fn emit_enum_variant_arg(&mut self, a_idx: usize, f: F)
                                -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;

    fn emit_enum_struct_variant(&mut self, v_name: &str,
                                   v_id: usize,
                                   len: usize,
                                   f: F) -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;
    fn emit_enum_struct_variant_field(&mut self,
                                         f_name: &str,
                                         f_idx: usize,
                                         f: F) -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;

    fn emit_struct(&mut self, name: &str, len: usize, f: F)
                      -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;
    fn emit_struct_field(&mut self, f_name: &str, f_idx: usize, f: F)
                            -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;

    fn emit_tuple(&mut self, len: usize, f: F) -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;
    fn emit_tuple_arg(&mut self, idx: usize, f: F) -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;

    fn emit_tuple_struct(&mut self, name: &str, len: usize, f: F)
                            -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;
    fn emit_tuple_struct_arg(&mut self, f_idx: usize, f: F)
                                -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;

    // Specialized types:
    fn emit_option(&mut self, f: F) -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;
    fn emit_option_none(&mut self) -> Result<(), Self::Error>;
    fn emit_option_some(&mut self, f: F) -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;

    fn emit_seq(&mut self, len: usize, f: F) -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;
    fn emit_seq_elt(&mut self, idx: usize, f: F) -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;

    fn emit_map(&mut self, len: usize, f: F) -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;
    fn emit_map_elt_key(&mut self, idx: usize, f: F) -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;
    fn emit_map_elt_val(&mut self, idx: usize, f: F) -> Result<(), Self::Error>
        where F: FnOnce(&mut Self) -> Result<(), Self::Error>;
}

pub trait Decoder {
    type Error;

    // Primitive types:
    fn read_nil(&mut self) -> Result<(), Self::Error>;
    fn read_usize(&mut self) -> Result;
    fn read_u64(&mut self) -> Result;
    fn read_u32(&mut self) -> Result;
    fn read_u16(&mut self) -> Result;
    fn read_u8(&mut self) -> Result;
    fn read_isize(&mut self) -> Result;
    fn read_i64(&mut self) -> Result;
    fn read_i32(&mut self) -> Result;
    fn read_i16(&mut self) -> Result;
    fn read_i8(&mut self) -> Result;
    fn read_bool(&mut self) -> Result;
    fn read_f64(&mut self) -> Result;
    fn read_f32(&mut self) -> Result;
    fn read_char(&mut self) -> Result;
    fn read_str(&mut self) -> Result;

    // Compound types:
    fn read_enum(&mut self, name: &str, f: F) -> Result
        where F: FnOnce(&mut Self) -> Result;

    fn read_enum_variant(&mut self, names: &[&str], f: F)
                               -> Result
        where F: FnMut(&mut Self, usize) -> Result;
    fn read_enum_variant_arg(&mut self, a_idx: usize, f: F)
                                   -> Result
        where F: FnOnce(&mut Self) -> Result;

    fn read_enum_struct_variant(&mut self, names: &[&str], f: F)
                                      -> Result
        where F: FnMut(&mut Self, usize) -> Result;
    fn read_enum_struct_variant_field(&mut self,
                                            &f_name: &str,
                                            f_idx: usize,
                                            f: F)
                                            -> Result
        where F: FnOnce(&mut Self) -> Result;

    fn read_struct(&mut self, s_name: &str, len: usize, f: F)
                         -> Result
        where F: FnOnce(&mut Self) -> Result;
    fn read_struct_field(&mut self,
                               f_name: &str,
                               f_idx: usize,
                               f: F)
                               -> Result
        where F: FnOnce(&mut Self) -> Result;

    fn read_tuple(&mut self, len: usize, f: F) -> Result
        where F: FnOnce(&mut Self) -> Result;
    fn read_tuple_arg(&mut self, a_idx: usize, f: F)
                            -> Result
        where F: FnOnce(&mut Self) -> Result;

    fn read_tuple_struct(&mut self, s_name: &str, len: usize, f: F)
                               -> Result
        where F: FnOnce(&mut Self) -> Result;
    fn read_tuple_struct_arg(&mut self, a_idx: usize, f: F)
                                   -> Result
        where F: FnOnce(&mut Self) -> Result;

    // Specialized types:
    fn read_option(&mut self, f: F) -> Result
        where F: FnMut(&mut Self, bool) -> Result;

    fn read_seq(&mut self, f: F) -> Result
        where F: FnOnce(&mut Self, usize) -> Result;
    fn read_seq_elt(&mut self, idx: usize, f: F) -> Result
        where F: FnOnce(&mut Self) -> Result;

    fn read_map(&mut self, f: F) -> Result
        where F: FnOnce(&mut Self, usize) -> Result;
    fn read_map_elt_key(&mut self, idx: usize, f: F)
                              -> Result
        where F: FnOnce(&mut Self) -> Result;
    fn read_map_elt_val(&mut self, idx: usize, f: F)
                              -> Result
        where F: FnOnce(&mut Self) -> Result;

    // Failure
    fn error(&mut self, err: &str) -> Self::Error;
}

pub trait Encodable {
    fn encode(&self, s: &mut S) -> Result<(), S::Error>;
}

pub trait Decodable: Sized {
    fn decode(d: &mut D) -> Result;
}

impl Encodable for usize {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_usize(*self)
    }
}

impl Decodable for usize {
    fn decode(d: &mut D) -> Result {
        d.read_usize()
    }
}

impl Encodable for u8 {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_u8(*self)
    }
}

impl Decodable for u8 {
    fn decode(d: &mut D) -> Result {
        d.read_u8()
    }
}

impl Encodable for u16 {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_u16(*self)
    }
}

impl Decodable for u16 {
    fn decode(d: &mut D) -> Result {
        d.read_u16()
    }
}

impl Encodable for u32 {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_u32(*self)
    }
}

impl Decodable for u32 {
    fn decode(d: &mut D) -> Result {
        d.read_u32()
    }
}

impl Encodable for u64 {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_u64(*self)
    }
}

impl Decodable for u64 {
    fn decode(d: &mut D) -> Result {
        d.read_u64()
    }
}

impl Encodable for isize {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_isize(*self)
    }
}

impl Decodable for isize {
    fn decode(d: &mut D) -> Result {
        d.read_isize()
    }
}

impl Encodable for i8 {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_i8(*self)
    }
}

impl Decodable for i8 {
    fn decode(d: &mut D) -> Result {
        d.read_i8()
    }
}

impl Encodable for i16 {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_i16(*self)
    }
}

impl Decodable for i16 {
    fn decode(d: &mut D) -> Result {
        d.read_i16()
    }
}

impl Encodable for i32 {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_i32(*self)
    }
}

impl Decodable for i32 {
    fn decode(d: &mut D) -> Result {
        d.read_i32()
    }
}

impl Encodable for i64 {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_i64(*self)
    }
}

impl Decodable for i64 {
    fn decode(d: &mut D) -> Result {
        d.read_i64()
    }
}

impl Encodable for str {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_str(self)
    }
}

impl Encodable for String {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_str(self)
    }
}

impl Decodable for String {
    fn decode(d: &mut D) -> Result {
        d.read_str()
    }
}

impl Encodable for f32 {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_f32(*self)
    }
}

impl Decodable for f32 {
    fn decode(d: &mut D) -> Result {
        d.read_f32()
    }
}

impl Encodable for f64 {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_f64(*self)
    }
}

impl Decodable for f64 {
    fn decode(d: &mut D) -> Result {
        d.read_f64()
    }
}

impl Encodable for bool {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_bool(*self)
    }
}

impl Decodable for bool {
    fn decode(d: &mut D) -> Result {
        d.read_bool()
    }
}

impl Encodable for char {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_char(*self)
    }
}

impl Decodable for char {
    fn decode(d: &mut D) -> Result {
        d.read_char()
    }
}

impl Encodable for () {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_nil()
    }
}

impl Decodable for () {
    fn decode(d: &mut D) -> Result<(), D::Error> {
        d.read_nil()
    }
}

impl<'a, T: ?Sized + Encodable> Encodable for &'a T {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        (**self).encode(s)
    }
}

impl Encodable for Box {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        (**self).encode(s)
    }
}

impl< T: Decodable> Decodable for Box {
    fn decode(d: &mut D) -> Result, D::Error> {
        Ok(Box::new(try!(Decodable::decode(d))))
    }
}

impl< T: Decodable> Decodable for Box<[T]> {
    fn decode(d: &mut D) -> Result, D::Error> {
        let v: Vec = try!(Decodable::decode(d));
        Ok(v.into_boxed_slice())
    }
}

impl Encodable for Rc {
    #[inline]
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        (**self).encode(s)
    }
}

impl Decodable for Rc {
    #[inline]
    fn decode(d: &mut D) -> Result, D::Error> {
        Ok(Rc::new(try!(Decodable::decode(d))))
    }
}

impl<'a, T:Encodable + ToOwned + ?Sized> Encodable for Cow<'a, T> {
    #[inline]
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        (**self).encode(s)
    }
}

impl<'a, T: ?Sized> Decodable for Cow<'a, T>
    where T: ToOwned, T::Owned: Decodable
{
    #[inline]
    fn decode(d: &mut D) -> Result, D::Error> {
        Ok(Cow::Owned(try!(Decodable::decode(d))))
    }
}

impl Encodable for [T] {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_seq(self.len(), |s| {
            for (i, e) in self.iter().enumerate() {
                try!(s.emit_seq_elt(i, |s| e.encode(s)))
            }
            Ok(())
        })
    }
}

impl Encodable for Vec {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_seq(self.len(), |s| {
            for (i, e) in self.iter().enumerate() {
                try!(s.emit_seq_elt(i, |s| e.encode(s)))
            }
            Ok(())
        })
    }
}

impl Decodable for Vec {
    fn decode(d: &mut D) -> Result, D::Error> {
        d.read_seq(|d, len| {
            let mut v = Vec::with_capacity(len);
            for i in 0..len {
                v.push(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
            }
            Ok(v)
        })
    }
}

impl Encodable for Option {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_option(|s| {
            match *self {
                None => s.emit_option_none(),
                Some(ref v) => s.emit_option_some(|s| v.encode(s)),
            }
        })
    }
}

impl Decodable for Option {
    fn decode(d: &mut D) -> Result, D::Error> {
        d.read_option(|d, b| {
            if b {
                Ok(Some(try!(Decodable::decode(d))))
            } else {
                Ok(None)
            }
        })
    }
}

impl Encodable for PhantomData {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        s.emit_nil()
    }
}

impl Decodable for PhantomData {
    fn decode(_d: &mut D) -> Result, D::Error> {
        Ok(PhantomData)
    }
}

macro_rules! peel {
    ($name:ident, $($other:ident,)*) => (tuple! { $($other,)* })
}

/// Evaluates to the number of identifiers passed to it, for example:
/// `count_idents!(a, b, c) == 3
macro_rules! count_idents {
    () => { 0 };
    ($_i:ident, $($rest:ident,)*) => { 1 + count_idents!($($rest,)*) }
}

macro_rules! tuple {
    () => ();
    ( $($name:ident,)+ ) => (
        impl<$($name:Decodable),*> Decodable for ($($name,)*) {
            fn decode(d: &mut D) -> Result<($($name,)*), D::Error> {
                let len: usize = count_idents!($($name,)*);
                d.read_tuple(len, |d| {
                    let mut i = 0;
                    let ret = ($(try!(d.read_tuple_arg({ i+=1; i-1 },
                                                       |d| -> Result<$name,D::Error> {
                        Decodable::decode(d)
                    })),)*);
                    return Ok(ret);
                })
            }
        }
        impl<$($name:Encodable),*> Encodable for ($($name,)*) {
            #[allow(non_snake_case)]
            fn encode(&self, s: &mut S) -> Result<(), S::Error> {
                let ($(ref $name,)*) = *self;
                let mut n = 0;
                $(let $name = $name; n += 1;)*
                s.emit_tuple(n, |s| {
                    let mut i = 0;
                    $(try!(s.emit_tuple_arg({ i+=1; i-1 }, |s| $name.encode(s)));)*
                    Ok(())
                })
            }
        }
        peel! { $($name,)* }
    )
}

tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, }

macro_rules! array {
    ($zero:expr) => ();
    ($len:expr, $($idx:expr),*) => {
        impl Decodable for [T; $len] {
            fn decode(d: &mut D) -> Result<[T; $len], D::Error> {
                d.read_seq(|d, len| {
                    if len != $len {
                        return Err(d.error("wrong array length"));
                    }
                    Ok([$(
                        try!(d.read_seq_elt($len - $idx - 1,
                                            |d| Decodable::decode(d)))
                    ),+])
                })
            }
        }

        impl Encodable for [T; $len] {
            fn encode(&self, s: &mut S) -> Result<(), S::Error> {
                s.emit_seq($len, |s| {
                    for i in 0..$len {
                        try!(s.emit_seq_elt(i, |s| self[i].encode(s)));
                    }
                    Ok(())
                })
            }
        }
        array! { $($idx),* }
    }
}

array! {
    32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16,
    15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
}

impl Encodable for path::Path {
    #[cfg(unix)]
    fn encode(&self, e: &mut S) -> Result<(), S::Error> {
        use std::os::unix::prelude::*;
        self.as_os_str().as_bytes().encode(e)
    }
    #[cfg(windows)]
    fn encode(&self, e: &mut S) -> Result<(), S::Error> {
        use std::os::windows::prelude::*;
        let v = self.as_os_str().encode_wide().collect::>();
        v.encode(e)
    }
}

impl Encodable for path::PathBuf {
    fn encode(&self, e: &mut S) -> Result<(), S::Error> {
        (**self).encode(e)
    }
}

impl Decodable for path::PathBuf {
    #[cfg(unix)]
    fn decode(d: &mut D) -> Result {
        use std::os::unix::prelude::*;
        let bytes: Vec = try!(Decodable::decode(d));
        let s: OsString = OsStringExt::from_vec(bytes);
        let mut p = path::PathBuf::new();
        p.push(s);
        Ok(p)
    }
    #[cfg(windows)]
    fn decode(d: &mut D) -> Result {
        use std::os::windows::prelude::*;
        let bytes: Vec = try!(Decodable::decode(d));
        let s: OsString = OsStringExt::from_wide(&bytes);
        let mut p = path::PathBuf::new();
        p.push(s);
        Ok(p)
    }
}

impl Encodable for Cell {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        self.get().encode(s)
    }
}

impl Decodable for Cell {
    fn decode(d: &mut D) -> Result, D::Error> {
        Ok(Cell::new(try!(Decodable::decode(d))))
    }
}

// FIXME: #15036
// Should use `try_borrow`, returning a
// `encoder.error("attempting to Encode borrowed RefCell")`
// from `encode` when `try_borrow` returns `None`.

impl Encodable for RefCell {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        self.borrow().encode(s)
    }
}

impl Decodable for RefCell {
    fn decode(d: &mut D) -> Result, D::Error> {
        Ok(RefCell::new(try!(Decodable::decode(d))))
    }
}

impl Encodable for Arc {
    fn encode(&self, s: &mut S) -> Result<(), S::Error> {
        (**self).encode(s)
    }
}

impl Decodable for Arc {
    fn decode(d: &mut D) -> Result, D::Error> {
        Ok(Arc::new(try!(Decodable::decode(d))))
    }
}

// ___________________________________________________________________________
// Helper routines

pub trait EncoderHelpers: Encoder {
    fn emit_from_vec(&mut self, v: &[T], f: F)
                           -> Result<(), ::Error>
        where F: FnMut(&mut Self, &T) -> Result<(), ::Error>;
}

impl EncoderHelpers for S {
    fn emit_from_vec(&mut self, v: &[T], mut f: F) -> Result<(), S::Error> where
        F: FnMut(&mut S, &T) -> Result<(), S::Error>,
    {
        self.emit_seq(v.len(), |this| {
            for (i, e) in v.iter().enumerate() {
                try!(this.emit_seq_elt(i, |this| {
                    f(this, e)
                }));
            }
            Ok(())
        })
    }
}

pub trait DecoderHelpers: Decoder {
    fn read_to_vec(&mut self, f: F)
                         -> Result, ::Error> where
        F: FnMut(&mut Self) -> Result::Error>;
}

impl DecoderHelpers for D {
    fn read_to_vec(&mut self, mut f: F) -> Result, D::Error> where F:
        FnMut(&mut D) -> Result,
    {
        self.read_seq(|this, len| {
            let mut v = Vec::with_capacity(len);
            for i in 0..len {
                v.push(try!(this.read_seq_elt(i, |this| f(this))));
            }
            Ok(v)
        })
    }
}
deps/rustc-serialize-0.3.16/src/lib.rs0000664000175000017500000000325712534623023014515 0ustar  // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0  or the MIT license
// , at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Support code for encoding and decoding types.
//!
//! # Usage
//!
//! This crate is [on crates.io](https://crates.io/crates/rustc-serialize) and
//! can be used by adding `rustc-serialize` to the dependencies in your
//! project's `Cargo.toml`.
//!
//! ```toml
//! [dependencies]
//! rustc-serialize = "0.3"
//! ```
//!
//! and this to your crate root:
//!
//! ```rust
//! extern crate rustc_serialize;
//! ```

#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
       html_root_url = "http://doc.rust-lang.org/rustc-serialize/")]
#![cfg_attr(test, deny(warnings))]
#![allow(trivial_numeric_casts)]
#![cfg_attr(rust_build, feature(staged_api))]
#![cfg_attr(rust_build, staged_api)]
#![cfg_attr(rust_build,
            unstable(feature = "rustc_private",
                     reason = "use the crates.io `rustc-serialize` library instead"))]

#[cfg(test)] extern crate rand;

pub use self::serialize::{Decoder, Encoder, Decodable, Encodable,
                          DecoderHelpers, EncoderHelpers};

mod serialize;
mod collection_impls;

pub mod base64;
pub mod hex;
pub mod json;

mod rustc_serialize {
    pub use serialize::*;
}
deps/rustc-serialize-0.3.16/src/json.rs0000664000175000017500000040062112554203715014720 0ustar  // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0  or the MIT license
// , at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// Rust JSON serialization library
// Copyright (c) 2011 Google Inc.

//! JSON parsing and serialization
//!
//! # What is JSON?
//!
//! JSON (JavaScript Object Notation) is a way to write data in Javascript.
//! Like XML, it allows to encode structured data in a text format that can be
//! easily read by humans Its simple syntax and native compatibility with
//! JavaScript have made it a widely used format.
//!
//! Data types that can be encoded are JavaScript types (see the `Json` enum
//! for more details):
//!
//! * `I64`: equivalent to rust's `i64`
//! * `U64`: equivalent to rust's `u64`
//! * `F64`: equivalent to rust's `f64`
//! * `Boolean`: equivalent to rust's `bool`
//! * `String`: equivalent to rust's `String`
//! * `Array`: equivalent to rust's `Vec`, but also allowing objects of
//!   different types in the
//!   same array
//! * `Object`: equivalent to rust's `BTreeMap`
//! * `Null`
//!
//! An object is a series of string keys mapping to values, in `"key": value`
//! format.  Arrays are enclosed in square brackets ([ ... ]) and objects in
//! curly brackets ({ ... }).  A simple JSON document encoding a person,
//! their age, address and phone numbers could look like
//!
//! ```ignore
//! {
//!     "FirstName": "John",
//!     "LastName": "Doe",
//!     "Age": 43,
//!     "Address": {
//!         "Street": "Downing Street 10",
//!         "City": "London",
//!         "Country": "Great Britain"
//!     },
//!     "PhoneNumbers": [
//!         "+44 1234567",
//!         "+44 2345678"
//!     ]
//! }
//! ```
//!
//! # Rust Type-based Encoding and Decoding
//!
//! Rust provides a mechanism for low boilerplate encoding & decoding of values
//! to and from JSON via the serialization API.  To be able to encode a piece
//! of data, it must implement the `rustc_serialize::Encodable` trait.  To be
//! able to decode a piece of data, it must implement the
//! `rustc_serialize::Decodable` trait.  The Rust compiler provides an
//! annotation to automatically generate the code for these traits:
//! `#[derive(RustcDecodable, RustcEncodable)]`
//!
//! The JSON API provides an enum `json::Json` and a trait `ToJson` to encode
//! objects.  The `ToJson` trait provides a `to_json` method to convert an
//! object into a `json::Json` value.  A `json::Json` value can be encoded as a
//! string or buffer using the functions described above.  You can also use the
//! `json::Encoder` object, which implements the `Encoder` trait.
//!
//! When using `ToJson` the `Encodable` trait implementation is not
//! mandatory.
//!
//! # Examples of use
//!
//! ## Using Autoserialization
//!
//! Create a struct called `TestStruct` and serialize and deserialize it to and
//! from JSON using the serialization API, using the derived serialization code.
//!
//! ```rust
//! extern crate rustc_serialize;
//! use rustc_serialize::json;
//!
//! // Automatically generate `RustcDecodable` and `RustcEncodable` trait
//! // implementations
//! #[derive(RustcDecodable, RustcEncodable)]
//! pub struct TestStruct  {
//!     data_int: u8,
//!     data_str: String,
//!     data_vector: Vec,
//! }
//!
//! fn main() {
//!     let object = TestStruct {
//!         data_int: 1,
//!         data_str: "homura".to_string(),
//!         data_vector: vec![2,3,4,5],
//!     };
//!
//!     // Serialize using `json::encode`
//!     let encoded = json::encode(&object).unwrap();
//!
//!     // Deserialize using `json::decode`
//!     let decoded: TestStruct = json::decode(&encoded).unwrap();
//! }
//! ```
//!
//! ## Using the `ToJson` trait
//!
//! The examples above use the `ToJson` trait to generate the JSON string,
//! which is required for custom mappings.
//!
//! ### Simple example of `ToJson` usage
//!
//! ```rust
//! extern crate rustc_serialize;
//! use rustc_serialize::json::{self, ToJson, Json};
//!
//! // A custom data structure
//! struct ComplexNum {
//!     a: f64,
//!     b: f64,
//! }
//!
//! // JSON value representation
//! impl ToJson for ComplexNum {
//!     fn to_json(&self) -> Json {
//!         Json::String(format!("{}+{}i", self.a, self.b))
//!     }
//! }
//!
//! // Only generate `RustcEncodable` trait implementation
//! #[derive(RustcEncodable)]
//! pub struct ComplexNumRecord {
//!     uid: u8,
//!     dsc: String,
//!     val: Json,
//! }
//!
//! fn main() {
//!     let num = ComplexNum { a: 0.0001, b: 12.539 };
//!     let data: String = json::encode(&ComplexNumRecord{
//!         uid: 1,
//!         dsc: "test".to_string(),
//!         val: num.to_json(),
//!     }).unwrap();
//!     println!("data: {}", data);
//!     // data: {"uid":1,"dsc":"test","val":"0.0001+12.539i"};
//! }
//! ```
//!
//! ### Verbose example of `ToJson` usage
//!
//! ```rust
//! extern crate rustc_serialize;
//! use std::collections::BTreeMap;
//! use rustc_serialize::json::{self, Json, ToJson};
//!
//! // Only generate `Decodable` trait implementation
//! #[derive(RustcDecodable)]
//! pub struct TestStruct {
//!     data_int: u8,
//!     data_str: String,
//!     data_vector: Vec,
//! }
//!
//! // Specify encoding method manually
//! impl ToJson for TestStruct {
//!     fn to_json(&self) -> Json {
//!         let mut d = BTreeMap::new();
//!         // All standard types implement `to_json()`, so use it
//!         d.insert("data_int".to_string(), self.data_int.to_json());
//!         d.insert("data_str".to_string(), self.data_str.to_json());
//!         d.insert("data_vector".to_string(), self.data_vector.to_json());
//!         Json::Object(d)
//!     }
//! }
//!
//! fn main() {
//!     // Serialize using `ToJson`
//!     let input_data = TestStruct {
//!         data_int: 1,
//!         data_str: "madoka".to_string(),
//!         data_vector: vec![2,3,4,5],
//!     };
//!     let json_obj: Json = input_data.to_json();
//!     let json_str: String = json_obj.to_string();
//!
//!     // Deserialize like before
//!     let decoded: TestStruct = json::decode(&json_str).unwrap();
//! }
//! ```
//!
//! ## Parsing a `str` to `Json` and reading the result
//!
//! ```rust
//! extern crate rustc_serialize;
//! use rustc_serialize::json::Json;
//!
//! fn main() {
//!     let data = Json::from_str("{\"foo\": 13, \"bar\": \"baz\"}").unwrap();
//!     println!("data: {}", data);
//!     // data: {"bar":"baz","foo":13}
//!     println!("object? {}", data.is_object());
//!     // object? true
//!
//!     let obj = data.as_object().unwrap();
//!     let foo = obj.get("foo").unwrap();
//!
//!     println!("array? {:?}", foo.as_array());
//!     // array? None
//!     println!("u64? {:?}", foo.as_u64());
//!     // u64? Some(13u64)
//!
//!     for (key, value) in obj.iter() {
//!         println!("{}: {}", key, match *value {
//!             Json::U64(v) => format!("{} (u64)", v),
//!             Json::String(ref v) => format!("{} (string)", v),
//!             _ => format!("other")
//!         });
//!     }
//!     // bar: baz (string)
//!     // foo: 13 (u64)
//! }
//! ```
//!
//! # The status of this library
//!
//! While this library is the standard way of working with JSON in Rust,
//! there is a next-generation library called Serde that's in the works (it's
//! faster, overcomes some design limitations of rustc-serialize and has more
//! features). You might consider using it when starting new project or
//! evaluating Rust JSON performance.

use self::JsonEvent::*;
use self::ErrorCode::*;
use self::ParserError::*;
use self::DecoderError::*;
use self::ParserState::*;
use self::InternalStackElement::*;

use std::collections::{HashMap, BTreeMap};
use std::error::Error as StdError;
use std::i64;
use std::io::prelude::*;
use std::mem::swap;
use std::ops::Index;
use std::str::FromStr;
use std::string;
use std::{char, f64, fmt, io, str};

use Encodable;

/// Represents a json value
#[derive(Clone, PartialEq, PartialOrd, Debug)]
pub enum Json {
    I64(i64),
    U64(u64),
    F64(f64),
    String(string::String),
    Boolean(bool),
    Array(self::Array),
    Object(self::Object),
    Null,
}

pub type Array = Vec;
pub type Object = BTreeMap;

pub struct PrettyJson<'a> { inner: &'a Json }

pub struct AsJson<'a, T: 'a> { inner: &'a T }
pub struct AsPrettyJson<'a, T: 'a> { inner: &'a T, indent: Option }

/// The errors that can arise while parsing a JSON stream.
#[derive(Clone, Copy, PartialEq)]
pub enum ErrorCode {
    InvalidSyntax,
    InvalidNumber,
    EOFWhileParsingObject,
    EOFWhileParsingArray,
    EOFWhileParsingValue,
    EOFWhileParsingString,
    KeyMustBeAString,
    ExpectedColon,
    TrailingCharacters,
    TrailingComma,
    InvalidEscape,
    InvalidUnicodeCodePoint,
    LoneLeadingSurrogateInHexEscape,
    UnexpectedEndOfHexEscape,
    UnrecognizedHex,
    NotFourDigit,
    ControlCharacterInString,
    NotUtf8,
}

#[derive(Debug)]
pub enum ParserError {
    /// msg, line, col
    SyntaxError(ErrorCode, usize, usize),
    IoError(io::Error),
}

impl PartialEq for ParserError {
    fn eq(&self, other: &ParserError) -> bool {
        match (self, other) {
            (&SyntaxError(msg0, line0, col0), &SyntaxError(msg1, line1, col1)) =>
                msg0 == msg1 && line0 == line1 && col0 == col1,
            (&IoError(_), _) => false,
            (_, &IoError(_)) => false,
        }
    }
}

// Builder and Parser have the same errors.
pub type BuilderError = ParserError;

#[derive(PartialEq, Debug)]
pub enum DecoderError {
    ParseError(ParserError),
    ExpectedError(string::String, string::String),
    MissingFieldError(string::String),
    UnknownVariantError(string::String),
    ApplicationError(string::String),
    EOF,
}

#[derive(Copy, Debug)]
pub enum EncoderError {
    FmtError(fmt::Error),
    BadHashmapKey,
}

impl Clone for EncoderError {
    fn clone(&self) -> Self { *self }
}

/// Returns a readable error string for a given error code.
pub fn error_str(error: ErrorCode) -> &'static str {
    match error {
        InvalidSyntax => "invalid syntax",
        InvalidNumber => "invalid number",
        EOFWhileParsingObject => "EOF While parsing object",
        EOFWhileParsingArray => "EOF While parsing array",
        EOFWhileParsingValue => "EOF While parsing value",
        EOFWhileParsingString => "EOF While parsing string",
        KeyMustBeAString => "key must be a string",
        ExpectedColon => "expected `:`",
        TrailingCharacters => "trailing characters",
        TrailingComma => "trailing comma",
        InvalidEscape => "invalid escape",
        UnrecognizedHex => "invalid \\u{ esc}ape (unrecognized hex)",
        NotFourDigit => "invalid \\u{ esc}ape (not four digits)",
        ControlCharacterInString => "unescaped control character in string",
        NotUtf8 => "contents not utf-8",
        InvalidUnicodeCodePoint => "invalid Unicode code point",
        LoneLeadingSurrogateInHexEscape => "lone leading surrogate in hex escape",
        UnexpectedEndOfHexEscape => "unexpected end of hex escape",
    }
}

/// Shortcut function to decode a JSON `&str` into an object
pub fn decode(s: &str) -> DecodeResult {
    let json = match Json::from_str(s) {
        Ok(x) => x,
        Err(e) => return Err(ParseError(e))
    };

    let mut decoder = Decoder::new(json);
    ::Decodable::decode(&mut decoder)
}

/// Shortcut function to encode a `T` into a JSON `String`
pub fn encode(object: &T) -> EncodeResult {
    let mut s = String::new();
    {
        let mut encoder = Encoder::new(&mut s);
        try!(object.encode(&mut encoder));
    }
    Ok(s)
}

impl fmt::Debug for ErrorCode {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        error_str(*self).fmt(f)
    }
}

impl StdError for DecoderError {
    fn description(&self) -> &str { "decoder error" }
    fn cause(&self) -> Option<&StdError> {
        match *self {
            DecoderError::ParseError(ref e) => Some(e),
            _ => None,
        }
    }
}

impl fmt::Display for DecoderError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        fmt::Debug::fmt(&self, f)
    }
}

impl From for DecoderError {
    fn from(err: ParserError) -> DecoderError {
        ParseError(From::from(err))
    }
}

impl StdError for ParserError {
    fn description(&self) -> &str { "failed to parse json" }
}

impl fmt::Display for ParserError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        fmt::Debug::fmt(&self, f)
    }
}

impl From for ParserError {
    fn from(err: io::Error) -> ParserError {
        IoError(err)
    }
}

impl StdError for EncoderError {
    fn description(&self) -> &str { "encoder error" }
}

impl fmt::Display for EncoderError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        fmt::Debug::fmt(&self, f)
    }
}

impl From for EncoderError {
    fn from(err: fmt::Error) -> EncoderError { EncoderError::FmtError(err) }
}

pub type EncodeResult = Result;
pub type DecodeResult = Result;

fn escape_str(wr: &mut fmt::Write, v: &str) -> EncodeResult<()> {
    try!(wr.write_str("\""));

    let mut start = 0;

    for (i, byte) in v.bytes().enumerate() {
        let escaped = match byte {
            b'"' => "\\\"",
            b'\\' => "\\\\",
            b'\x00' => "\\u0000",
            b'\x01' => "\\u0001",
            b'\x02' => "\\u0002",
            b'\x03' => "\\u0003",
            b'\x04' => "\\u0004",
            b'\x05' => "\\u0005",
            b'\x06' => "\\u0006",
            b'\x07' => "\\u0007",
            b'\x08' => "\\b",
            b'\t' => "\\t",
            b'\n' => "\\n",
            b'\x0b' => "\\u000b",
            b'\x0c' => "\\f",
            b'\r' => "\\r",
            b'\x0e' => "\\u000e",
            b'\x0f' => "\\u000f",
            b'\x10' => "\\u0010",
            b'\x11' => "\\u0011",
            b'\x12' => "\\u0012",
            b'\x13' => "\\u0013",
            b'\x14' => "\\u0014",
            b'\x15' => "\\u0015",
            b'\x16' => "\\u0016",
            b'\x17' => "\\u0017",
            b'\x18' => "\\u0018",
            b'\x19' => "\\u0019",
            b'\x1a' => "\\u001a",
            b'\x1b' => "\\u001b",
            b'\x1c' => "\\u001c",
            b'\x1d' => "\\u001d",
            b'\x1e' => "\\u001e",
            b'\x1f' => "\\u001f",
            b'\x7f' => "\\u007f",
            _ => { continue; }
        };

        if start < i {
            try!(wr.write_str(&v[start..i]));
        }

        try!(wr.write_str(escaped));

        start = i + 1;
    }

    if start != v.len() {
        try!(wr.write_str(&v[start..]));
    }

    try!(wr.write_str("\""));
    Ok(())
}

fn escape_char(writer: &mut fmt::Write, v: char) -> EncodeResult<()> {
    let mut buf = [0; 4];
    let _ = write!(&mut &mut buf[..], "{}", v);
    let buf = unsafe { str::from_utf8_unchecked(&buf[..v.len_utf8()]) };
    escape_str(writer, buf)
}

fn spaces(wr: &mut fmt::Write, n: u32) -> EncodeResult<()> {
    let mut n = n as usize;
    const BUF: &'static str = "                ";

    while n >= BUF.len() {
        try!(wr.write_str(BUF));
        n -= BUF.len();
    }

    if n > 0 {
        try!(wr.write_str(&BUF[..n]));
    }
    Ok(())
}

fn fmt_number_or_null(v: f64) -> string::String {
    use std::num::FpCategory::{Nan, Infinite};

    match v.classify() {
        Nan | Infinite => "null".to_string(),
        _ => {
            let s = v.to_string();
            if s.contains(".") {s} else {s + ".0"}
        }
    }
}

macro_rules! emit_enquoted_if_mapkey {
    ($enc:ident,$e:expr) => {
        if $enc.is_emitting_map_key {
            try!(write!($enc.writer, "\"{}\"", $e));
            Ok(())
        } else {
            try!(write!($enc.writer, "{}", $e));
            Ok(())
        }
    }
}

enum EncodingFormat {
    Compact,
    Pretty {
        curr_indent: u32,
        indent: u32
    }
}

/// A structure for implementing serialization to JSON.
pub struct Encoder<'a> {
    writer: &'a mut (fmt::Write+'a),
    format : EncodingFormat,
    is_emitting_map_key: bool,
}

impl<'a> Encoder<'a> {
    /// Creates a new encoder whose output will be written in human-readable
    /// JSON to the specified writer
    pub fn new_pretty(writer: &'a mut fmt::Write) -> Encoder<'a> {
        Encoder {
            writer: writer,
            format: EncodingFormat::Pretty {
                curr_indent: 0,
                indent: 2,
            },
            is_emitting_map_key: false,
        }
    }

    /// Creates a new encoder whose output will be written in compact
    /// JSON to the specified writer
    pub fn new(writer: &'a mut fmt::Write) -> Encoder<'a> {
        Encoder {
            writer: writer,
            format: EncodingFormat::Compact,
            is_emitting_map_key: false,
        }
    }

    /// Set the number of spaces to indent for each level.
    /// This is safe to set during encoding.
    pub fn set_indent(&mut self, new_indent: u32) -> Result<(), ()> {
        if let EncodingFormat::Pretty{ref mut curr_indent, ref mut indent} = self.format {
            // self.indent very well could be 0 so we need to use checked division.
            let level = curr_indent.checked_div(*indent).unwrap_or(0);
            *indent = new_indent;
            *curr_indent = level * *indent;
            Ok(())
        } else {
            Err(())
        }
    }
}

impl<'a> ::Encoder for Encoder<'a> {
    type Error = EncoderError;

    fn emit_nil(&mut self) -> EncodeResult<()> {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        try!(write!(self.writer, "null"));
        Ok(())
    }

    fn emit_usize(&mut self, v: usize) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) }
    fn emit_u64(&mut self, v: u64) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) }
    fn emit_u32(&mut self, v: u32) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) }
    fn emit_u16(&mut self, v: u16) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) }
    fn emit_u8(&mut self, v: u8) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) }

    fn emit_isize(&mut self, v: isize) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) }
    fn emit_i64(&mut self, v: i64) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) }
    fn emit_i32(&mut self, v: i32) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) }
    fn emit_i16(&mut self, v: i16) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) }
    fn emit_i8(&mut self, v: i8) -> EncodeResult<()> { emit_enquoted_if_mapkey!(self, v) }

    fn emit_bool(&mut self, v: bool) -> EncodeResult<()> {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        if v {
            try!(write!(self.writer, "true"));
        } else {
            try!(write!(self.writer, "false"));
        }
        Ok(())
    }

    fn emit_f64(&mut self, v: f64) -> EncodeResult<()> {
        emit_enquoted_if_mapkey!(self, fmt_number_or_null(v))
    }
    fn emit_f32(&mut self, v: f32) -> EncodeResult<()> {
        self.emit_f64(v as f64)
    }

    fn emit_char(&mut self, v: char) -> EncodeResult<()> {
        escape_char(self.writer, v)
    }
    fn emit_str(&mut self, v: &str) -> EncodeResult<()> {
        escape_str(self.writer, v)
    }

    fn emit_enum(&mut self, _name: &str, f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        f(self)
    }

    fn emit_enum_variant(&mut self,
                            name: &str,
                            _id: usize,
                            cnt: usize,
                            f: F)
                            -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        // enums are encoded as strings or objects
        // Bunny => "Bunny"
        // Kangaroo(34,"William") => {"variant": "Kangaroo", "fields": [34,"William"]}
        if cnt == 0 {
            escape_str(self.writer, name)
        } else {
            if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
            if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format {
                try!(write!(self.writer, "{{\n"));
                *curr_indent += indent;
                try!(spaces(self.writer, *curr_indent));
                try!(write!(self.writer, "\"variant\": "));
                try!(escape_str(self.writer, name));
                try!(write!(self.writer, ",\n"));
                try!(spaces(self.writer, *curr_indent));
                try!(write!(self.writer, "\"fields\": [\n"));
                *curr_indent += indent;
            } else {
                try!(write!(self.writer, "{{\"variant\":"));
                try!(escape_str(self.writer, name));
                try!(write!(self.writer, ",\"fields\":["));
            }
            try!(f(self));
            if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format {
                *curr_indent -= indent;
                try!(write!(self.writer, "\n"));
                try!(spaces(self.writer, *curr_indent));
                *curr_indent -= indent;
                try!(write!(self.writer, "]\n"));
                try!(spaces(self.writer, *curr_indent));
                try!(write!(self.writer, "}}"));
            } else {
                try!(write!(self.writer, "]}}"));
            }
            Ok(())
        }
    }

    fn emit_enum_variant_arg(&mut self, idx: usize, f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        if idx != 0 {
            try!(write!(self.writer, ","));
            if let EncodingFormat::Pretty{..} = self.format {
                try!(write!(self.writer, "\n"));
            }
        }
        if let EncodingFormat::Pretty{curr_indent, ..} = self.format {
            try!(spaces(self.writer, curr_indent));
        }
        f(self)
    }

    fn emit_enum_struct_variant(&mut self,
                                   name: &str,
                                   id: usize,
                                   cnt: usize,
                                   f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        self.emit_enum_variant(name, id, cnt, f)
    }

    fn emit_enum_struct_variant_field(&mut self,
                                         _: &str,
                                         idx: usize,
                                         f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        self.emit_enum_variant_arg(idx, f)
    }


    fn emit_struct(&mut self, _: &str, len: usize, f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        if len == 0 {
            try!(write!(self.writer, "{{}}"));
        } else {
            try!(write!(self.writer, "{{"));
            if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format {
                *curr_indent += indent;
            }
            try!(f(self));
            if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format {
                *curr_indent -= indent;
                try!(write!(self.writer, "\n"));
                try!(spaces(self.writer, *curr_indent));
            }
            try!(write!(self.writer, "}}"));
        }
        Ok(())
    }

    fn emit_struct_field(&mut self, name: &str, idx: usize, f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        if idx != 0 {
            try!(write!(self.writer, ","));
        }
        if let EncodingFormat::Pretty{curr_indent, ..} = self.format {
            try!(write!(self.writer, "\n"));
            try!(spaces(self.writer, curr_indent));
        }
        try!(escape_str(self.writer, name));
        if let EncodingFormat::Pretty{..} = self.format {
            try!(write!(self.writer, ": "));
        } else {
            try!(write!(self.writer, ":"));
        }
        f(self)
    }

    fn emit_tuple(&mut self, len: usize, f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        self.emit_seq(len, f)
    }
    fn emit_tuple_arg(&mut self, idx: usize, f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        self.emit_seq_elt(idx, f)
    }

    fn emit_tuple_struct(&mut self, _: &str, len: usize, f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        self.emit_seq(len, f)
    }
    fn emit_tuple_struct_arg(&mut self, idx: usize, f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        self.emit_seq_elt(idx, f)
    }

    fn emit_option(&mut self, f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        f(self)
    }
    fn emit_option_none(&mut self) -> EncodeResult<()> {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        self.emit_nil()
    }
    fn emit_option_some(&mut self, f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        f(self)
    }

    fn emit_seq(&mut self, len: usize, f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        if len == 0 {
            try!(write!(self.writer, "[]"));
        } else {
            try!(write!(self.writer, "["));
            if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format {
                *curr_indent += indent;
            }
            try!(f(self));
            if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format {
                *curr_indent -= indent;
                try!(write!(self.writer, "\n"));
                try!(spaces(self.writer, *curr_indent));
            }
            try!(write!(self.writer, "]"));
        }
        Ok(())
    }

    fn emit_seq_elt(&mut self, idx: usize, f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        if idx != 0 {
            try!(write!(self.writer, ","));
        }
        if let EncodingFormat::Pretty{ref mut curr_indent, ..} = self.format {
            try!(write!(self.writer, "\n"));
            try!(spaces(self.writer, *curr_indent));
        }
        f(self)
    }

    fn emit_map(&mut self, len: usize, f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        if len == 0 {
            try!(write!(self.writer, "{{}}"));
        } else {
            try!(write!(self.writer, "{{"));
            if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format {
                *curr_indent += indent;
            }
            try!(f(self));
            if let EncodingFormat::Pretty{ref mut curr_indent, indent} = self.format {
                *curr_indent -= indent;
                try!(write!(self.writer, "\n"));
                try!(spaces(self.writer, *curr_indent));
            }
            try!(write!(self.writer, "}}"));
        }
        Ok(())
    }

    fn emit_map_elt_key(&mut self, idx: usize, f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        if idx != 0 {
            try!(write!(self.writer, ","));
        }
        if let EncodingFormat::Pretty{curr_indent, ..} = self.format {
            try!(write!(self.writer, "\n"));
            try!(spaces(self.writer, curr_indent));
        }
        self.is_emitting_map_key = true;
        try!(f(self));
        self.is_emitting_map_key = false;
        Ok(())
    }

    fn emit_map_elt_val(&mut self, _idx: usize, f: F) -> EncodeResult<()> where
        F: FnOnce(&mut Encoder<'a>) -> EncodeResult<()>,
    {
        if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); }
        if let EncodingFormat::Pretty{..} = self.format {
            try!(write!(self.writer, ": "));
        } else {
            try!(write!(self.writer, ":"));
        }
        f(self)
    }
}

impl Encodable for Json {
    fn encode(&self, e: &mut S) -> Result<(), S::Error> {
        match *self {
            Json::I64(v) => v.encode(e),
            Json::U64(v) => v.encode(e),
            Json::F64(v) => v.encode(e),
            Json::String(ref v) => v.encode(e),
            Json::Boolean(v) => v.encode(e),
            Json::Array(ref v) => v.encode(e),
            Json::Object(ref v) => v.encode(e),
            Json::Null => e.emit_nil(),
        }
    }
}

/// Create an `AsJson` wrapper which can be used to print a value as JSON
/// on-the-fly via `write!`
pub fn as_json(t: &T) -> AsJson {
    AsJson { inner: t }
}

/// Create an `AsPrettyJson` wrapper which can be used to print a value as JSON
/// on-the-fly via `write!`
pub fn as_pretty_json(t: &T) -> AsPrettyJson {
    AsPrettyJson { inner: t, indent: None }
}

impl Json {
    /// Decodes a json value from an `&mut io::Read`
    pub fn from_reader(rdr: &mut io::Read) -> Result {
        let contents = {
            let mut c = Vec::new();
            try!(rdr.read_to_end(&mut c));
            c
        };
        let s = match str::from_utf8(&contents).ok() {
            Some(s) => s,
            _       => return Err(SyntaxError(NotUtf8, 0, 0))
        };
        let mut builder = Builder::new(s.chars());
        builder.build()
    }

    /// Decodes a json value from a string
    pub fn from_str(s: &str) -> Result {
        let mut builder = Builder::new(s.chars());
        builder.build()
    }

    /// Borrow this json object as a pretty object to generate a pretty
    /// representation for it via `Display`.
    pub fn pretty(&self) -> PrettyJson {
        PrettyJson { inner: self }
    }

     /// If the Json value is an Object, returns the value associated with the provided key.
    /// Otherwise, returns None.
    pub fn find<'a>(&'a self, key: &str) -> Option<&'a Json>{
        match self {
            &Json::Object(ref map) => map.get(key),
            _ => None
        }
    }

    /// Attempts to get a nested Json Object for each key in `keys`.
    /// If any key is found not to exist, find_path will return None.
    /// Otherwise, it will return the Json value associated with the final key.
    pub fn find_path<'a>(&'a self, keys: &[&str]) -> Option<&'a Json>{
        let mut target = self;
        for key in keys.iter() {
            match target.find(*key) {
                Some(t) => { target = t; },
                None => return None
            }
        }
        Some(target)
    }

    /// If the Json value is an Object, performs a depth-first search until
    /// a value associated with the provided key is found. If no value is found
    /// or the Json value is not an Object, returns None.
    pub fn search<'a>(&'a self, key: &str) -> Option<&'a Json> {
        match self {
            &Json::Object(ref map) => {
                match map.get(key) {
                    Some(json_value) => Some(json_value),
                    None => {
                        for (_, v) in map.iter() {
                            match v.search(key) {
                                x if x.is_some() => return x,
                                _ => ()
                            }
                        }
                        None
                    }
                }
            },
            _ => None
        }
    }

    /// Returns true if the Json value is an Object. Returns false otherwise.
    pub fn is_object<'a>(&'a self) -> bool {
        self.as_object().is_some()
    }

    /// If the Json value is an Object, returns the associated BTreeMap.
    /// Returns None otherwise.
    pub fn as_object<'a>(&'a self) -> Option<&'a Object> {
        match self {
            &Json::Object(ref map) => Some(map),
            _ => None
        }
    }

    /// If the Json value is an Object, returns the associated mutable BTreeMap.
    /// Returns None otherwise.
    pub fn as_object_mut<'a>(&'a mut self) -> Option<&'a mut Object> {
        match self {
            &mut Json::Object(ref mut map) => Some(map),
            _ => None
        }
    }

    /// Returns true if the Json value is an Array. Returns false otherwise.
    pub fn is_array<'a>(&'a self) -> bool {
        self.as_array().is_some()
    }

    /// If the Json value is an Array, returns the associated vector.
    /// Returns None otherwise.
    pub fn as_array<'a>(&'a self) -> Option<&'a Array> {
        match self {
            &Json::Array(ref array) => Some(&*array),
            _ => None
        }
    }

    /// If the Json value is an Array, returns the associated mutable vector.
    /// Returns None otherwise.
    pub fn as_array_mut<'a>(&'a mut self) -> Option<&'a mut Array> {
        match self {
            &mut Json::Array(ref mut list) => Some(list),
            _ => None
        }
    }

    /// Returns true if the Json value is a String. Returns false otherwise.
    pub fn is_string<'a>(&'a self) -> bool {
        self.as_string().is_some()
    }

    /// If the Json value is a String, returns the associated str.
    /// Returns None otherwise.
    pub fn as_string<'a>(&'a self) -> Option<&'a str> {
        match *self {
            Json::String(ref s) => Some(&s),
            _ => None
        }
    }

    /// Returns true if the Json value is a Number. Returns false otherwise.
    pub fn is_number(&self) -> bool {
        match *self {
            Json::I64(_) | Json::U64(_) | Json::F64(_) => true,
            _ => false,
        }
    }

    /// Returns true if the Json value is a i64. Returns false otherwise.
    pub fn is_i64(&self) -> bool {
        match *self {
            Json::I64(_) => true,
            _ => false,
        }
    }

    /// Returns true if the Json value is a u64. Returns false otherwise.
    pub fn is_u64(&self) -> bool {
        match *self {
            Json::U64(_) => true,
            _ => false,
        }
    }

    /// Returns true if the Json value is a f64. Returns false otherwise.
    pub fn is_f64(&self) -> bool {
        match *self {
            Json::F64(_) => true,
            _ => false,
        }
    }

    /// If the Json value is a number, return or cast it to a i64.
    /// Returns None otherwise.
    pub fn as_i64(&self) -> Option {
        match *self {
            Json::I64(n) => Some(n),
            Json::U64(n) if n >= i64::MAX as u64 => None,
            Json::U64(n) => Some(n as i64),
            _ => None
        }
    }

    /// If the Json value is a number, return or cast it to a u64.
    /// Returns None otherwise.
    pub fn as_u64(&self) -> Option {
        match *self {
            Json::I64(n) if n >= 0 => Some(n as u64),
            Json::U64(n) => Some(n),
            _ => None
        }
    }

    /// If the Json value is a number, return or cast it to a f64.
    /// Returns None otherwise.
    pub fn as_f64(&self) -> Option {
        match *self {
            Json::I64(n) => Some(n as f64),
            Json::U64(n) => Some(n as f64),
            Json::F64(n) => Some(n),
            _ => None
        }
    }

    /// Returns true if the Json value is a Boolean. Returns false otherwise.
    pub fn is_boolean(&self) -> bool {
        self.as_boolean().is_some()
    }

    /// If the Json value is a Boolean, returns the associated bool.
    /// Returns None otherwise.
    pub fn as_boolean(&self) -> Option {
        match self {
            &Json::Boolean(b) => Some(b),
            _ => None
        }
    }

    /// Returns true if the Json value is a Null. Returns false otherwise.
    pub fn is_null(&self) -> bool {
        self.as_null().is_some()
    }

    /// If the Json value is a Null, returns ().
    /// Returns None otherwise.
    pub fn as_null(&self) -> Option<()> {
        match self {
            &Json::Null => Some(()),
            _ => None
        }
    }
}

impl<'a> Index<&'a str>  for Json {
    type Output = Json;

    fn index(&self, idx: &str) -> &Json {
        self.find(idx).unwrap()
    }
}

impl Index for Json {
    type Output = Json;

    fn index<'a>(&'a self, idx: usize) -> &'a Json {
        match self {
            &Json::Array(ref v) => &v[idx],
            _ => panic!("can only index Json with usize if it is an array")
        }
    }
}

/// The output of the streaming parser.
#[derive(PartialEq, Debug)]
pub enum JsonEvent {
    ObjectStart,
    ObjectEnd,
    ArrayStart,
    ArrayEnd,
    BooleanValue(bool),
    I64Value(i64),
    U64Value(u64),
    F64Value(f64),
    StringValue(string::String),
    NullValue,
    Error(ParserError),
}

#[derive(PartialEq, Debug)]
enum ParserState {
    // Parse a value in an array, true means first element.
    ParseArray(bool),
    // Parse ',' or ']' after an element in an array.
    ParseArrayComma,
    // Parse a key:value in an object, true means first element.
    ParseObject(bool),
    // Parse ',' or ']' after an element in an object.
    ParseObjectComma,
    // Initial state.
    ParseStart,
    // Expecting the stream to end.
    ParseBeforeFinish,
    // Parsing can't continue.
    ParseFinished,
}

/// A Stack represents the current position of the parser in the logical
/// structure of the JSON stream.
/// For example foo.bar[3].x
pub struct Stack {
    stack: Vec,
    str_buffer: Vec,
}

/// StackElements compose a Stack.
/// For example, Key("foo"), Key("bar"), Index(3) and Key("x") are the
/// StackElements compositing the stack that represents foo.bar[3].x
#[derive(PartialEq, Clone, Debug)]
pub enum StackElement<'l> {
    Index(u32),
    Key(&'l str),
}

// Internally, Key elements are stored as indices in a buffer to avoid
// allocating a string for every member of an object.
#[derive(PartialEq, Clone, Debug)]
enum InternalStackElement {
    InternalIndex(u32),
    InternalKey(u16, u16), // start, size
}

impl Stack {
    pub fn new() -> Stack {
        Stack { stack: Vec::new(), str_buffer: Vec::new() }
    }

    /// Returns The number of elements in the Stack.
    pub fn len(&self) -> usize { self.stack.len() }

    /// Returns true if the stack is empty.
    pub fn is_empty(&self) -> bool { self.stack.is_empty() }

    /// Provides access to the StackElement at a given index.
    /// lower indices are at the bottom of the stack while higher indices are
    /// at the top.
    pub fn get<'l>(&'l self, idx: usize) -> StackElement<'l> {
        match self.stack[idx] {
            InternalIndex(i) => StackElement::Index(i),
            InternalKey(start, size) => {
                StackElement::Key(str::from_utf8(
                    &self.str_buffer[start as usize .. start as usize + size as usize]).unwrap())
            }
        }
    }

    /// Compares this stack with an array of StackElements.
    pub fn is_equal_to(&self, rhs: &[StackElement]) -> bool {
        if self.stack.len() != rhs.len() { return false; }
        for i in 0..rhs.len() {
            if self.get(i) != rhs[i] { return false; }
        }
        return true;
    }

    /// Returns true if the bottom-most elements of this stack are the same as
    /// the ones passed as parameter.
    pub fn starts_with(&self, rhs: &[StackElement]) -> bool {
        if self.stack.len() < rhs.len() { return false; }
        for i in 0..rhs.len() {
            if self.get(i) != rhs[i] { return false; }
        }
        return true;
    }

    /// Returns true if the top-most elements of this stack are the same as
    /// the ones passed as parameter.
    pub fn ends_with(&self, rhs: &[StackElement]) -> bool {
        if self.stack.len() < rhs.len() { return false; }
        let offset = self.stack.len() - rhs.len();
        for i in 0..rhs.len() {
            if self.get(i + offset) != rhs[i] { return false; }
        }
        return true;
    }

    /// Returns the top-most element (if any).
    pub fn top<'l>(&'l self) -> Option> {
        return match self.stack.last() {
            None => None,
            Some(&InternalIndex(i)) => Some(StackElement::Index(i)),
            Some(&InternalKey(start, size)) => {
                Some(StackElement::Key(str::from_utf8(
                    &self.str_buffer[start as usize .. (start+size) as usize]
                ).unwrap()))
            }
        }
    }

    // Used by Parser to insert Key elements at the top of the stack.
    fn push_key(&mut self, key: string::String) {
        self.stack.push(InternalKey(self.str_buffer.len() as u16, key.len() as u16));
        for c in key.as_bytes().iter() {
            self.str_buffer.push(*c);
        }
    }

    // Used by Parser to insert Index elements at the top of the stack.
    fn push_index(&mut self, index: u32) {
        self.stack.push(InternalIndex(index));
    }

    // Used by Parser to remove the top-most element of the stack.
    fn pop(&mut self) {
        assert!(!self.is_empty());
        match *self.stack.last().unwrap() {
            InternalKey(_, sz) => {
                let new_size = self.str_buffer.len() - sz as usize;
                self.str_buffer.truncate(new_size);
            }
            InternalIndex(_) => {}
        }
        self.stack.pop();
    }

    // Used by Parser to test whether the top-most element is an index.
    fn last_is_index(&self) -> bool {
        if self.is_empty() { return false; }
        return match *self.stack.last().unwrap() {
            InternalIndex(_) => true,
            _ => false,
        }
    }

    // Used by Parser to increment the index of the top-most element.
    fn bump_index(&mut self) {
        let len = self.stack.len();
        let idx = match *self.stack.last().unwrap() {
            InternalIndex(i) => { i + 1 }
            _ => { panic!(); }
        };
        self.stack[len - 1] = InternalIndex(idx);
    }
}

/// A streaming JSON parser implemented as an iterator of JsonEvent, consuming
/// an iterator of char.
pub struct Parser {
    rdr: T,
    ch: Option,
    line: usize,
    col: usize,
    // We maintain a stack representing where we are in the logical structure
    // of the JSON stream.
    stack: Stack,
    // A state machine is kept to make it possible to interrupt and resume parsing.
    state: ParserState,
}

impl> Iterator for Parser {
    type Item = JsonEvent;

    fn next(&mut self) -> Option {
        if self.state == ParseFinished {
            return None;
        }

        if self.state == ParseBeforeFinish {
            self.parse_whitespace();
            // Make sure there is no trailing characters.
            if self.eof() {
                self.state = ParseFinished;
                return None;
            } else {
                return Some(self.error_event(TrailingCharacters));
            }
        }

        return Some(self.parse());
    }
}

impl> Parser {
    /// Creates the JSON parser.
    pub fn new(rdr: T) -> Parser {
        let mut p = Parser {
            rdr: rdr,
            ch: Some('\x00'),
            line: 1,
            col: 0,
            stack: Stack::new(),
            state: ParseStart,
        };
        p.bump();
        return p;
    }

    /// Provides access to the current position in the logical structure of the
    /// JSON stream.
    pub fn stack<'l>(&'l self) -> &'l Stack {
        return &self.stack;
    }

    fn eof(&self) -> bool { self.ch.is_none() }
    fn ch_or_null(&self) -> char { self.ch.unwrap_or('\x00') }
    fn bump(&mut self) {
        self.ch = self.rdr.next();

        if self.ch_is('\n') {
            self.line += 1;
            self.col = 1;
        } else {
            self.col += 1;
        }
    }

    fn next_char(&mut self) -> Option {
        self.bump();
        self.ch
    }
    fn ch_is(&self, c: char) -> bool {
        self.ch == Some(c)
    }

    fn error(&self, reason: ErrorCode) -> Result {
        Err(SyntaxError(reason, self.line, self.col))
    }

    fn parse_whitespace(&mut self) {
        while self.ch_is(' ') ||
              self.ch_is('\n') ||
              self.ch_is('\t') ||
              self.ch_is('\r') { self.bump(); }
    }

    fn parse_number(&mut self) -> JsonEvent {
        let mut neg = false;

        if self.ch_is('-') {
            self.bump();
            neg = true;
        }

        let res = match self.parse_u64() {
            Ok(res) => res,
            Err(e) => { return Error(e); }
        };

        if self.ch_is('.') || self.ch_is('e') || self.ch_is('E') {
            let mut res = res as f64;

            if self.ch_is('.') {
                res = match self.parse_decimal(res) {
                    Ok(res) => res,
                    Err(e) => { return Error(e); }
                };
            }

            if self.ch_is('e') || self.ch_is('E') {
                res = match self.parse_exponent(res) {
                    Ok(res) => res,
                    Err(e) => { return Error(e); }
                };
            }

            if neg {
                res *= -1.0;
            }

            F64Value(res)
        } else {
            if neg {
                // Make sure we don't underflow.
                if res > (i64::MAX as u64) + 1 {
                    Error(SyntaxError(InvalidNumber, self.line, self.col))
                } else {
                    I64Value((!res + 1) as i64)
                }
            } else {
                U64Value(res)
            }
        }
    }

    fn parse_u64(&mut self) -> Result {
        let mut accum: u64 = 0;

        match self.ch_or_null() {
            '0' => {
                self.bump();

                // A leading '0' must be the only digit before the decimal point.
                match self.ch_or_null() {
                    '0' ... '9' => return self.error(InvalidNumber),
                    _ => ()
                }
            },
            '1' ... '9' => {
                while !self.eof() {
                    match self.ch_or_null() {
                        c @ '0' ... '9' => {
                            macro_rules! try_or_invalid {
                                ($e: expr) => {
                                    match $e {
                                        Some(v) => v,
                                        None => return self.error(InvalidNumber)
                                    }
                                }
                            }
                            accum = try_or_invalid!(accum.checked_mul(10));
                            accum = try_or_invalid!(accum.checked_add((c as u64) - ('0' as u64)));

                            self.bump();
                        }
                        _ => break,
                    }
                }
            }
            _ => return self.error(InvalidNumber),
        }

        Ok(accum)
    }

    fn parse_decimal(&mut self, mut res: f64) -> Result {
        self.bump();

        // Make sure a digit follows the decimal place.
        match self.ch_or_null() {
            '0' ... '9' => (),
             _ => return self.error(InvalidNumber)
        }

        let mut dec = 1.0;
        while !self.eof() {
            match self.ch_or_null() {
                c @ '0' ... '9' => {
                    dec /= 10.0;
                    res += (((c as isize) - ('0' as isize)) as f64) * dec;
                    self.bump();
                }
                _ => break,
            }
        }

        Ok(res)
    }

    fn parse_exponent(&mut self, mut res: f64) -> Result {
        self.bump();

        let mut exp = 0;
        let mut neg_exp = false;

        if self.ch_is('+') {
            self.bump();
        } else if self.ch_is('-') {
            self.bump();
            neg_exp = true;
        }

        // Make sure a digit follows the exponent place.
        match self.ch_or_null() {
            '0' ... '9' => (),
            _ => return self.error(InvalidNumber)
        }
        while !self.eof() {
            match self.ch_or_null() {
                c @ '0' ... '9' => {
                    exp *= 10;
                    exp += (c as usize) - ('0' as usize);

                    self.bump();
                }
                _ => break
            }
        }

        let exp = 10_f64.powi(exp as i32);
        if neg_exp {
            res /= exp;
        } else {
            res *= exp;
        }

        Ok(res)
    }

    fn decode_hex_escape(&mut self) -> Result {
        let mut i = 0;
        let mut n = 0;
        while i < 4 {
            self.bump();
            n = match self.ch_or_null() {
                c @ '0' ... '9' => n * 16 + ((c as u16) - ('0' as u16)),
                c @ 'a' ... 'f' => n * 16 + (10 + (c as u16) - ('a' as u16)),
                c @ 'A' ... 'F' => n * 16 + (10 + (c as u16) - ('A' as u16)),
                _ => return self.error(InvalidEscape)
            };

            i += 1;
        }

        Ok(n)
    }

    fn parse_str(&mut self) -> Result {
        let mut escape = false;
        let mut res = string::String::new();

        loop {
            self.bump();
            if self.eof() {
                return self.error(EOFWhileParsingString);
            }

            if escape {
                match self.ch_or_null() {
                    '"' => res.push('"'),
                    '\\' => res.push('\\'),
                    '/' => res.push('/'),
                    'b' => res.push('\x08'),
                    'f' => res.push('\x0c'),
                    'n' => res.push('\n'),
                    'r' => res.push('\r'),
                    't' => res.push('\t'),
                    'u' => match try!(self.decode_hex_escape()) {
                        0xDC00 ... 0xDFFF => {
                            return self.error(LoneLeadingSurrogateInHexEscape)
                        }

                        // Non-BMP characters are encoded as a sequence of
                        // two hex escapes, representing UTF-16 surrogates.
                        n1 @ 0xD800 ... 0xDBFF => {
                            match (self.next_char(), self.next_char()) {
                                (Some('\\'), Some('u')) => (),
                                _ => return self.error(UnexpectedEndOfHexEscape),
                            }

                            let n2 = try!(self.decode_hex_escape());
                            if n2 < 0xDC00 || n2 > 0xDFFF {
                                return self.error(LoneLeadingSurrogateInHexEscape)
                            }
                            let c = (((n1 - 0xD800) as u32) << 10 |
                                     (n2 - 0xDC00) as u32) + 0x1_0000;
                            res.push(char::from_u32(c).unwrap());
                        }

                        n => match char::from_u32(n as u32) {
                            Some(c) => res.push(c),
                            None => return self.error(InvalidUnicodeCodePoint),
                        },
                    },
                    _ => return self.error(InvalidEscape),
                }
                escape = false;
            } else if self.ch_is('\\') {
                escape = true;
            } else {
                match self.ch {
                    Some('"') => {
                        self.bump();
                        return Ok(res);
                    },
                    Some(c) if c.is_control() =>
                        return self.error(ControlCharacterInString),
                    Some(c) => res.push(c),
                    None => unreachable!()
                }
            }
        }
    }

    // Invoked at each iteration, consumes the stream until it has enough
    // information to return a JsonEvent.
    // Manages an internal state so that parsing can be interrupted and resumed.
    // Also keeps track of the position in the logical structure of the json
    // stream int the form of a stack that can be queried by the user using the
    // stack() method.
    fn parse(&mut self) -> JsonEvent {
        loop {
            // The only paths where the loop can spin a new iteration
            // are in the cases ParseArrayComma and ParseObjectComma if ','
            // is parsed. In these cases the state is set to (respectively)
            // ParseArray(false) and ParseObject(false), which always return,
            // so there is no risk of getting stuck in an infinite loop.
            // All other paths return before the end of the loop's iteration.
            self.parse_whitespace();

            match self.state {
                ParseStart => {
                    return self.parse_start();
                }
                ParseArray(first) => {
                    return self.parse_array(first);
                }
                ParseArrayComma => {
                    match self.parse_array_comma_or_end() {
                        Some(evt) => { return evt; }
                        None => {}
                    }
                }
                ParseObject(first) => {
                    return self.parse_object(first);
                }
                ParseObjectComma => {
                    self.stack.pop();
                    if self.ch_is(',') {
                        self.state = ParseObject(false);
                        self.bump();
                    } else {
                        return self.parse_object_end();
                    }
                }
                _ => {
                    return self.error_event(InvalidSyntax);
                }
            }
        }
    }

    fn parse_start(&mut self) -> JsonEvent {
        let val = self.parse_value();
        self.state = match val {
            Error(_) => ParseFinished,
            ArrayStart => ParseArray(true),
            ObjectStart => ParseObject(true),
            _ => ParseBeforeFinish,
        };
        return val;
    }

    fn parse_array(&mut self, first: bool) -> JsonEvent {
        if self.ch_is(']') {
            if !first {
                self.error_event(InvalidSyntax)
            } else {
                self.state = if self.stack.is_empty() {
                    ParseBeforeFinish
                } else if self.stack.last_is_index() {
                    ParseArrayComma
                } else {
                    ParseObjectComma
                };
                self.bump();
                ArrayEnd
            }
        } else {
            if first {
                self.stack.push_index(0);
            }
            let val = self.parse_value();
            self.state = match val {
                Error(_) => ParseFinished,
                ArrayStart => ParseArray(true),
                ObjectStart => ParseObject(true),
                _ => ParseArrayComma,
            };
            val
        }
    }

    fn parse_array_comma_or_end(&mut self) -> Option {
        if self.ch_is(',') {
            self.stack.bump_index();
            self.state = ParseArray(false);
            self.bump();
            None
        } else if self.ch_is(']') {
            self.stack.pop();
            self.state = if self.stack.is_empty() {
                ParseBeforeFinish
            } else if self.stack.last_is_index() {
                ParseArrayComma
            } else {
                ParseObjectComma
            };
            self.bump();
            Some(ArrayEnd)
        } else if self.eof() {
            Some(self.error_event(EOFWhileParsingArray))
        } else {
            Some(self.error_event(InvalidSyntax))
        }
    }

    fn parse_object(&mut self, first: bool) -> JsonEvent {
        if self.ch_is('}') {
            if !first {
                if self.stack.is_empty() {
                    return self.error_event(TrailingComma);
                } else {
                    self.stack.pop();
                }
            }
            self.state = if self.stack.is_empty() {
                ParseBeforeFinish
            } else if self.stack.last_is_index() {
                ParseArrayComma
            } else {
                ParseObjectComma
            };
            self.bump();
            return ObjectEnd;
        }
        if self.eof() {
            return self.error_event(EOFWhileParsingObject);
        }
        if !self.ch_is('"') {
            return self.error_event(KeyMustBeAString);
        }
        let s = match self.parse_str() {
            Ok(s) => s,
            Err(e) => {
                self.state = ParseFinished;
                return Error(e);
            }
        };
        self.parse_whitespace();
        if self.eof() {
            return self.error_event(EOFWhileParsingObject);
        } else if self.ch_or_null() != ':' {
            return self.error_event(ExpectedColon);
        }
        self.stack.push_key(s);
        self.bump();
        self.parse_whitespace();

        let val = self.parse_value();

        self.state = match val {
            Error(_) => ParseFinished,
            ArrayStart => ParseArray(true),
            ObjectStart => ParseObject(true),
            _ => ParseObjectComma,
        };
        return val;
    }

    fn parse_object_end(&mut self) -> JsonEvent {
        if self.ch_is('}') {
            self.state = if self.stack.is_empty() {
                ParseBeforeFinish
            } else if self.stack.last_is_index() {
                ParseArrayComma
            } else {
                ParseObjectComma
            };
            self.bump();
            ObjectEnd
        } else if self.eof() {
            self.error_event(EOFWhileParsingObject)
        } else {
            self.error_event(InvalidSyntax)
        }
    }

    fn parse_value(&mut self) -> JsonEvent {
        if self.eof() { return self.error_event(EOFWhileParsingValue); }
        match self.ch_or_null() {
            'n' => { self.parse_ident("ull", NullValue) }
            't' => { self.parse_ident("rue", BooleanValue(true)) }
            'f' => { self.parse_ident("alse", BooleanValue(false)) }
            '0' ... '9' | '-' => self.parse_number(),
            '"' => match self.parse_str() {
                Ok(s) => StringValue(s),
                Err(e) => Error(e),
            },
            '[' => {
                self.bump();
                ArrayStart
            }
            '{' => {
                self.bump();
                ObjectStart
            }
            _ => { self.error_event(InvalidSyntax) }
        }
    }

    fn parse_ident(&mut self, ident: &str, value: JsonEvent) -> JsonEvent {
        if ident.chars().all(|c| Some(c) == self.next_char()) {
            self.bump();
            value
        } else {
            Error(SyntaxError(InvalidSyntax, self.line, self.col))
        }
    }

    fn error_event(&mut self, reason: ErrorCode) -> JsonEvent {
        self.state = ParseFinished;
        Error(SyntaxError(reason, self.line, self.col))
    }
}

/// A Builder consumes a json::Parser to create a generic Json structure.
pub struct Builder {
    parser: Parser,
    token: Option,
}

impl> Builder {
    /// Create a JSON Builder.
    pub fn new(src: T) -> Builder {
        Builder { parser: Parser::new(src), token: None, }
    }

    // Decode a Json value from a Parser.
    pub fn build(&mut self) -> Result {
        self.bump();
        let result = self.build_value();
        self.bump();
        match self.token.take() {
            None => {}
            Some(Error(e)) => { return Err(e); }
            ref tok => { panic!("unexpected token {:?}", tok); }
        }
        result
    }

    fn bump(&mut self) {
        self.token = self.parser.next();
    }

    fn build_value(&mut self) -> Result {
        return match self.token.take() {
            Some(NullValue) => Ok(Json::Null),
            Some(I64Value(n)) => Ok(Json::I64(n)),
            Some(U64Value(n)) => Ok(Json::U64(n)),
            Some(F64Value(n)) => Ok(Json::F64(n)),
            Some(BooleanValue(b)) => Ok(Json::Boolean(b)),
            Some(StringValue(ref mut s)) => {
                let mut temp = string::String::new();
                swap(s, &mut temp);
                Ok(Json::String(temp))
            }
            Some(Error(e)) => Err(e),
            Some(ArrayStart) => self.build_array(),
            Some(ObjectStart) => self.build_object(),
            Some(ObjectEnd) => self.parser.error(InvalidSyntax),
            Some(ArrayEnd) => self.parser.error(InvalidSyntax),
            None => self.parser.error(EOFWhileParsingValue),
        }
    }

    fn build_array(&mut self) -> Result {
        self.bump();
        let mut values = Vec::new();

        loop {
            if let Some(ArrayEnd) = self.token {
                return Ok(Json::Array(values.into_iter().collect()));
            }
            match self.build_value() {
                Ok(v) => values.push(v),
                Err(e) => { return Err(e) }
            }
            self.bump();
        }
    }

    fn build_object(&mut self) -> Result {
        self.bump();

        let mut values = BTreeMap::new();

        loop {
            match self.token.take() {
                Some(ObjectEnd) => { return Ok(Json::Object(values)); }
                Some(Error(e)) => { return Err(e); }
                None => { break; }
                token => { self.token = token; }
            }
            let key = match self.parser.stack().top() {
                Some(StackElement::Key(k)) => { k.to_string() }
                _ => { panic!("invalid state"); }
            };
            match self.build_value() {
                Ok(value) => { values.insert(key, value); }
                Err(e) => { return Err(e); }
            }
            self.bump();
        }
        return self.parser.error(EOFWhileParsingObject);
    }
}

/// A structure to decode JSON to values in rust.
pub struct Decoder {
    stack: Vec,
}

impl Decoder {
    /// Creates a new decoder instance for decoding the specified JSON value.
    pub fn new(json: Json) -> Decoder {
        Decoder { stack: vec![json] }
    }
}

impl Decoder {
    fn pop(&mut self) -> DecodeResult {
        match self.stack.pop() {
            Some(s) => Ok(s),
            None => Err(EOF),
        }
    }
}

macro_rules! expect {
    ($e:expr, Null) => ({
        match try!($e) {
            Json::Null => Ok(()),
            other => Err(ExpectedError("Null".to_string(),
                                       format!("{}", other)))
        }
    });
    ($e:expr, $t:ident) => ({
        match try!($e) {
            Json::$t(v) => Ok(v),
            other => {
                Err(ExpectedError(stringify!($t).to_string(),
                                  format!("{}", other)))
            }
        }
    })
}

macro_rules! read_primitive {
    ($name:ident, $ty:ident) => {
        #[allow(unused_comparisons)]
        fn $name(&mut self) -> DecodeResult<$ty> {
            match try!(self.pop()) {
                Json::I64(i) => {
                    let other = i as $ty;
                    if i == other as i64 && (other > 0) == (i > 0) {
                        Ok(other)
                    } else {
                        Err(ExpectedError("Number".to_string(), i.to_string()))
                    }
                }
                Json::U64(u) => {
                    let other = u as $ty;
                    if u == other as u64 && other >= 0 {
                        Ok(other)
                    } else {
                        Err(ExpectedError("Number".to_string(), u.to_string()))
                    }
                }
                Json::F64(f) => {
                    Err(ExpectedError("Integer".to_string(), f.to_string()))
                }
                // re: #12967.. a type w/ numeric keys (ie HashMap etc)
                // is going to have a string here, as per JSON spec.
                Json::String(s) => match s.parse() {
                    Ok(f)  => Ok(f),
                    Err(_) => Err(ExpectedError("Number".to_string(), s)),
                },
                value => {
                    Err(ExpectedError("Number".to_string(), value.to_string()))
                }
            }
        }
    }
}

impl ::Decoder for Decoder {
    type Error = DecoderError;

    fn read_nil(&mut self) -> DecodeResult<()> {
        expect!(self.pop(), Null)
    }

    read_primitive! { read_usize, usize }
    read_primitive! { read_u8, u8 }
    read_primitive! { read_u16, u16 }
    read_primitive! { read_u32, u32 }
    read_primitive! { read_u64, u64 }
    read_primitive! { read_isize, isize }
    read_primitive! { read_i8, i8 }
    read_primitive! { read_i16, i16 }
    read_primitive! { read_i32, i32 }
    read_primitive! { read_i64, i64 }

    fn read_f32(&mut self) -> DecodeResult {
        self.read_f64().map(|x| x as f32)
    }

    fn read_f64(&mut self) -> DecodeResult {
        match try!(self.pop()) {
            Json::I64(f) => Ok(f as f64),
            Json::U64(f) => Ok(f as f64),
            Json::F64(f) => Ok(f),
            Json::String(s) => {
                // re: #12967.. a type w/ numeric keys (ie HashMap etc)
                // is going to have a string here, as per JSON spec.
                match s.parse() {
                    Ok(f)  => Ok(f),
                    Err(_) => Err(ExpectedError("Number".to_string(), s)),
                }
            },
            Json::Null => Ok(f64::NAN),
            value => Err(ExpectedError("Number".to_string(), format!("{}", value)))
        }
    }

    fn read_bool(&mut self) -> DecodeResult {
        expect!(self.pop(), Boolean)
    }

    fn read_char(&mut self) -> DecodeResult {
        let s = try!(self.read_str());
        {
            let mut it = s.chars();
            match (it.next(), it.next()) {
                // exactly one character
                (Some(c), None) => return Ok(c),
                _ => ()
            }
        }
        Err(ExpectedError("single character string".to_string(), format!("{}", s)))
    }

    fn read_str(&mut self) -> DecodeResult {
        expect!(self.pop(), String)
    }

    fn read_enum(&mut self, _name: &str, f: F) -> DecodeResult where
        F: FnOnce(&mut Decoder) -> DecodeResult,
    {
        f(self)
    }

    fn read_enum_variant(&mut self, names: &[&str],
                               mut f: F) -> DecodeResult
        where F: FnMut(&mut Decoder, usize) -> DecodeResult,
    {
        let name = match try!(self.pop()) {
            Json::String(s) => s,
            Json::Object(mut o) => {
                let n = match o.remove(&"variant".to_string()) {
                    Some(Json::String(s)) => s,
                    Some(val) => {
                        return Err(ExpectedError("String".to_string(), format!("{}", val)))
                    }
                    None => {
                        return Err(MissingFieldError("variant".to_string()))
                    }
                };
                match o.remove(&"fields".to_string()) {
                    Some(Json::Array(l)) => {
                        for field in l.into_iter().rev() {
                            self.stack.push(field);
                        }
                    },
                    Some(val) => {
                        return Err(ExpectedError("Array".to_string(), format!("{}", val)))
                    }
                    None => {
                        return Err(MissingFieldError("fields".to_string()))
                    }
                }
                n
            }
            json => {
                return Err(ExpectedError("String or Object".to_string(), format!("{}", json)))
            }
        };
        let idx = match names.iter().position(|n| *n == name) {
            Some(idx) => idx,
            None => return Err(UnknownVariantError(name))
        };
        f(self, idx)
    }

    fn read_enum_variant_arg(&mut self, _idx: usize, f: F) -> DecodeResult where
        F: FnOnce(&mut Decoder) -> DecodeResult,
    {
        f(self)
    }

    fn read_enum_struct_variant(&mut self, names: &[&str], f: F) -> DecodeResult where
        F: FnMut(&mut Decoder, usize) -> DecodeResult,
    {
        self.read_enum_variant(names, f)
    }


    fn read_enum_struct_variant_field(&mut self,
                                         _name: &str,
                                         idx: usize,
                                         f: F)
                                         -> DecodeResult where
        F: FnOnce(&mut Decoder) -> DecodeResult,
    {
        self.read_enum_variant_arg(idx, f)
    }

    fn read_struct(&mut self, _name: &str, _len: usize, f: F) -> DecodeResult where
        F: FnOnce(&mut Decoder) -> DecodeResult,
    {
        let value = try!(f(self));
        try!(self.pop());
        Ok(value)
    }

    fn read_struct_field(&mut self,
                               name: &str,
                               _idx: usize,
                               f: F)
                               -> DecodeResult where
        F: FnOnce(&mut Decoder) -> DecodeResult,
    {
        let mut obj = try!(expect!(self.pop(), Object));

        let value = match obj.remove(&name.to_string()) {
            None => {
                // Add a Null and try to parse it as an Option<_>
                // to get None as a default value.
                self.stack.push(Json::Null);
                match f(self) {
                    Ok(x) => x,
                    Err(_) => return Err(MissingFieldError(name.to_string())),
                }
            },
            Some(json) => {
                self.stack.push(json);
                try!(f(self))
            }
        };
        self.stack.push(Json::Object(obj));
        Ok(value)
    }

    fn read_tuple(&mut self, tuple_len: usize, f: F) -> DecodeResult where
        F: FnOnce(&mut Decoder) -> DecodeResult,
    {
        self.read_seq(move |d, len| {
            if len == tuple_len {
                f(d)
            } else {
                Err(ExpectedError(format!("Tuple{}", tuple_len), format!("Tuple{}", len)))
            }
        })
    }

    fn read_tuple_arg(&mut self, idx: usize, f: F) -> DecodeResult where
        F: FnOnce(&mut Decoder) -> DecodeResult,
    {
        self.read_seq_elt(idx, f)
    }

    fn read_tuple_struct(&mut self,
                               _name: &str,
                               len: usize,
                               f: F)
                               -> DecodeResult where
        F: FnOnce(&mut Decoder) -> DecodeResult,
    {
        self.read_tuple(len, f)
    }

    fn read_tuple_struct_arg(&mut self,
                                   idx: usize,
                                   f: F)
                                   -> DecodeResult where
        F: FnOnce(&mut Decoder) -> DecodeResult,
    {
        self.read_tuple_arg(idx, f)
    }

    fn read_option(&mut self, mut f: F) -> DecodeResult where
        F: FnMut(&mut Decoder, bool) -> DecodeResult,
    {
        match try!(self.pop()) {
            Json::Null => f(self, false),
            value => { self.stack.push(value); f(self, true) }
        }
    }

    fn read_seq(&mut self, f: F) -> DecodeResult where
        F: FnOnce(&mut Decoder, usize) -> DecodeResult,
    {
        let array = try!(expect!(self.pop(), Array));
        let len = array.len();
        for v in array.into_iter().rev() {
            self.stack.push(v);
        }
        f(self, len)
    }

    fn read_seq_elt(&mut self, _idx: usize, f: F) -> DecodeResult where
        F: FnOnce(&mut Decoder) -> DecodeResult,
    {
        f(self)
    }

    fn read_map(&mut self, f: F) -> DecodeResult where
        F: FnOnce(&mut Decoder, usize) -> DecodeResult,
    {
        let obj = try!(expect!(self.pop(), Object));
        let len = obj.len();
        for (key, value) in obj.into_iter() {
            self.stack.push(value);
            self.stack.push(Json::String(key));
        }
        f(self, len)
    }

    fn read_map_elt_key(&mut self, _idx: usize, f: F) -> DecodeResult where
       F: FnOnce(&mut Decoder) -> DecodeResult,
    {
        f(self)
    }

    fn read_map_elt_val(&mut self, _idx: usize, f: F) -> DecodeResult where
       F: FnOnce(&mut Decoder) -> DecodeResult,
    {
        f(self)
    }

    fn error(&mut self, err: &str) -> DecoderError {
        ApplicationError(err.to_string())
    }
}

/// A trait for converting values to JSON
pub trait ToJson {
    /// Converts the value of `self` to an instance of JSON
    fn to_json(&self) -> Json;
}

macro_rules! to_json_impl_i64 {
    ($($t:ty), +) => (
        $(impl ToJson for $t {
            fn to_json(&self) -> Json { Json::I64(*self as i64) }
        })+
    )
}

to_json_impl_i64! { isize, i8, i16, i32, i64 }

macro_rules! to_json_impl_u64 {
    ($($t:ty), +) => (
        $(impl ToJson for $t {
            fn to_json(&self) -> Json { Json::U64(*self as u64) }
        })+
    )
}

to_json_impl_u64! { usize, u8, u16, u32, u64 }

impl ToJson for Json {
    fn to_json(&self) -> Json { self.clone() }
}

impl ToJson for f32 {
    fn to_json(&self) -> Json { (*self as f64).to_json() }
}

impl ToJson for f64 {
    fn to_json(&self) -> Json {
        use std::num::FpCategory::{Nan, Infinite};

        match self.classify() {
            Nan | Infinite => Json::Null,
            _                  => Json::F64(*self)
        }
    }
}

impl ToJson for () {
    fn to_json(&self) -> Json { Json::Null }
}

impl ToJson for bool {
    fn to_json(&self) -> Json { Json::Boolean(*self) }
}

impl ToJson for str {
    fn to_json(&self) -> Json { Json::String(self.to_string()) }
}

impl ToJson for string::String {
    fn to_json(&self) -> Json { Json::String((*self).clone()) }
}

macro_rules! tuple_impl {
    // use variables to indicate the arity of the tuple
    ($($tyvar:ident),* ) => {
        // the trailing commas are for the 1 tuple
        impl<
            $( $tyvar : ToJson ),*
            > ToJson for ( $( $tyvar ),* , ) {

            #[inline]
            #[allow(non_snake_case)]
            fn to_json(&self) -> Json {
                match *self {
                    ($(ref $tyvar),*,) => Json::Array(vec![$($tyvar.to_json()),*])
                }
            }
        }
    }
}

tuple_impl!{A}
tuple_impl!{A, B}
tuple_impl!{A, B, C}
tuple_impl!{A, B, C, D}
tuple_impl!{A, B, C, D, E}
tuple_impl!{A, B, C, D, E, F}
tuple_impl!{A, B, C, D, E, F, G}
tuple_impl!{A, B, C, D, E, F, G, H}
tuple_impl!{A, B, C, D, E, F, G, H, I}
tuple_impl!{A, B, C, D, E, F, G, H, I, J}
tuple_impl!{A, B, C, D, E, F, G, H, I, J, K}
tuple_impl!{A, B, C, D, E, F, G, H, I, J, K, L}

impl ToJson for [A] {
    fn to_json(&self) -> Json { Json::Array(self.iter().map(|elt| elt.to_json()).collect()) }
}

impl ToJson for Vec {
    fn to_json(&self) -> Json { Json::Array(self.iter().map(|elt| elt.to_json()).collect()) }
}

impl ToJson for BTreeMap {
    fn to_json(&self) -> Json {
        let mut d = BTreeMap::new();
        for (key, value) in self.iter() {
            d.insert((*key).clone(), value.to_json());
        }
        Json::Object(d)
    }
}

impl ToJson for HashMap {
    fn to_json(&self) -> Json {
        let mut d = BTreeMap::new();
        for (key, value) in self.iter() {
            d.insert((*key).clone(), value.to_json());
        }
        Json::Object(d)
    }
}

impl ToJson for Option {
    fn to_json(&self) -> Json {
        match *self {
            None => Json::Null,
            Some(ref value) => value.to_json()
        }
    }
}

struct FormatShim<'a, 'b: 'a> {
    inner: &'a mut fmt::Formatter<'b>,
}

impl<'a, 'b> fmt::Write for FormatShim<'a, 'b> {
    fn write_str(&mut self, s: &str) -> fmt::Result {
        match self.inner.write_str(s) {
            Ok(_) => Ok(()),
            Err(_) => Err(fmt::Error)
        }
    }
}

impl fmt::Display for Json {
    /// Encodes a json value into a string
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let mut shim = FormatShim { inner: f };
        let mut encoder = Encoder::new(&mut shim);
        match self.encode(&mut encoder) {
            Ok(_) => Ok(()),
            Err(_) => Err(fmt::Error)
        }
    }
}

impl<'a> fmt::Display for PrettyJson<'a> {
    /// Encodes a json value into a string
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let mut shim = FormatShim { inner: f };
        let mut encoder = Encoder::new_pretty(&mut shim);
        match self.inner.encode(&mut encoder) {
            Ok(_) => Ok(()),
            Err(_) => Err(fmt::Error)
        }
    }
}

impl<'a, T: Encodable> fmt::Display for AsJson<'a, T> {
    /// Encodes a json value into a string
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let mut shim = FormatShim { inner: f };
        let mut encoder = Encoder::new(&mut shim);
        match self.inner.encode(&mut encoder) {
            Ok(_) => Ok(()),
            Err(_) => Err(fmt::Error)
        }
    }
}

impl<'a, T> AsPrettyJson<'a, T> {
    /// Set the indentation level for the emitted JSON
    pub fn indent(mut self, indent: u32) -> AsPrettyJson<'a, T> {
        self.indent = Some(indent);
        self
    }
}

impl<'a, T: Encodable> fmt::Display for AsPrettyJson<'a, T> {
    /// Encodes a json value into a string
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let mut shim = FormatShim { inner: f };
        let mut encoder = Encoder::new_pretty(&mut shim);
        if let Some(n) = self.indent {
            // unwrap cannot panic for pretty encoders
            let _ = encoder.set_indent(n);
        }
        match self.inner.encode(&mut encoder) {
            Ok(_) => Ok(()),
            Err(_) => Err(fmt::Error)
        }
    }
}

impl FromStr for Json {
    type Err = ParserError;
    fn from_str(s: &str) -> Result {
        Json::from_str(s)
    }
}

#[cfg(test)]
mod tests {
    use self::Animal::*;
    use self::DecodeEnum::*;
    use {Encodable, Decodable};
    use super::Json::*;
    use super::ErrorCode::*;
    use super::ParserError::*;
    use super::DecoderError::*;
    use super::JsonEvent::*;
    use super::StackElement::*;
    use super::{Json, DecodeResult, DecoderError, JsonEvent, Parser,
                StackElement, Stack, Decoder, Encoder, EncoderError};
    use std::{i64, u64, f32, f64};
    use std::collections::BTreeMap;
    use std::string;

    #[derive(RustcDecodable, Eq, PartialEq, Debug)]
    struct OptionData {
        opt: Option,
    }

    #[test]
    fn test_decode_option_none() {
        let s ="{}";
        let obj: OptionData = super::decode(s).unwrap();
        assert_eq!(obj, OptionData { opt: None });
    }

    #[test]
    fn test_decode_option_some() {
        let s = "{ \"opt\": 10 }";
        let obj: OptionData = super::decode(s).unwrap();
        assert_eq!(obj, OptionData { opt: Some(10) });
    }

    #[test]
    fn test_decode_option_malformed() {
        check_err::("{ \"opt\": [] }",
                                ExpectedError("Number".to_string(), "[]".to_string()));
        check_err::("{ \"opt\": false }",
                                ExpectedError("Number".to_string(), "false".to_string()));
    }

    #[derive(PartialEq, RustcEncodable, RustcDecodable, Debug)]
    enum Animal {
        Dog,
        Frog(string::String, isize)
    }

    #[derive(PartialEq, RustcEncodable, RustcDecodable, Debug)]
    struct Inner {
        a: (),
        b: usize,
        c: Vec,
    }

    #[derive(PartialEq, RustcEncodable, RustcDecodable, Debug)]
    struct Outer {
        inner: Vec,
    }

    fn mk_object(items: &[(string::String, Json)]) -> Json {
        let mut d = BTreeMap::new();

        for item in items.iter() {
            match *item {
                (ref key, ref value) => { d.insert((*key).clone(), (*value).clone()); },
            }
        };

        Object(d)
    }

    #[test]
    fn test_from_str_trait() {
        let s = "null";
        assert!(s.parse::().unwrap() == s.parse().unwrap());
    }

    #[test]
    fn test_write_null() {
        assert_eq!(Null.to_string(), "null");
        assert_eq!(Null.pretty().to_string(), "null");
    }

    #[test]
    fn test_write_i64() {
        assert_eq!(U64(0).to_string(), "0");
        assert_eq!(U64(0).pretty().to_string(), "0");

        assert_eq!(U64(1234).to_string(), "1234");
        assert_eq!(U64(1234).pretty().to_string(), "1234");

        assert_eq!(I64(-5678).to_string(), "-5678");
        assert_eq!(I64(-5678).pretty().to_string(), "-5678");

        assert_eq!(U64(7650007200025252000).to_string(), "7650007200025252000");
        assert_eq!(U64(7650007200025252000).pretty().to_string(), "7650007200025252000");
    }

    #[test]
    fn test_write_f64() {
        assert_eq!(F64(3.0).to_string(), "3.0");
        assert_eq!(F64(3.0).pretty().to_string(), "3.0");

        assert_eq!(F64(3.1).to_string(), "3.1");
        assert_eq!(F64(3.1).pretty().to_string(), "3.1");

        assert_eq!(F64(-1.5).to_string(), "-1.5");
        assert_eq!(F64(-1.5).pretty().to_string(), "-1.5");

        assert_eq!(F64(0.5).to_string(), "0.5");
        assert_eq!(F64(0.5).pretty().to_string(), "0.5");

        assert_eq!(F64(f64::NAN).to_string(), "null");
        assert_eq!(F64(f64::NAN).pretty().to_string(), "null");

        assert_eq!(F64(f64::INFINITY).to_string(), "null");
        assert_eq!(F64(f64::INFINITY).pretty().to_string(), "null");

        assert_eq!(F64(f64::NEG_INFINITY).to_string(), "null");
        assert_eq!(F64(f64::NEG_INFINITY).pretty().to_string(), "null");
    }

    #[test]
    fn test_write_str() {
        assert_eq!(String("".to_string()).to_string(), "\"\"");
        assert_eq!(String("".to_string()).pretty().to_string(), "\"\"");

        assert_eq!(String("homura".to_string()).to_string(), "\"homura\"");
        assert_eq!(String("madoka".to_string()).pretty().to_string(), "\"madoka\"");
    }

    #[test]
    fn test_write_bool() {
        assert_eq!(Boolean(true).to_string(), "true");
        assert_eq!(Boolean(true).pretty().to_string(), "true");

        assert_eq!(Boolean(false).to_string(), "false");
        assert_eq!(Boolean(false).pretty().to_string(), "false");
    }

    #[test]
    fn test_write_array() {
        assert_eq!(Array(vec![]).to_string(), "[]");
        assert_eq!(Array(vec![]).pretty().to_string(), "[]");

        assert_eq!(Array(vec![Boolean(true)]).to_string(), "[true]");
        assert_eq!(
            Array(vec![Boolean(true)]).pretty().to_string(),
            "\
            [\n  \
                true\n\
            ]"
        );

        let long_test_array = Array(vec![
            Boolean(false),
            Null,
            Array(vec![String("foo\nbar".to_string()), F64(3.5)])]);

        assert_eq!(long_test_array.to_string(),
            "[false,null,[\"foo\\nbar\",3.5]]");
        assert_eq!(
            long_test_array.pretty().to_string(),
            "\
            [\n  \
                false,\n  \
                null,\n  \
                [\n    \
                    \"foo\\nbar\",\n    \
                    3.5\n  \
                ]\n\
            ]"
        );
    }

    #[test]
    fn test_write_object() {
        assert_eq!(mk_object(&[]).to_string(), "{}");
        assert_eq!(mk_object(&[]).pretty().to_string(), "{}");

        assert_eq!(
            mk_object(&[
                ("a".to_string(), Boolean(true))
            ]).to_string(),
            "{\"a\":true}"
        );
        assert_eq!(
            mk_object(&[("a".to_string(), Boolean(true))]).pretty().to_string(),
            "\
            {\n  \
                \"a\": true\n\
            }"
        );

        let complex_obj = mk_object(&[
                ("b".to_string(), Array(vec![
                    mk_object(&[("c".to_string(), String("\x0c\r".to_string()))]),
                    mk_object(&[("d".to_string(), String("".to_string()))])
                ]))
            ]);

        assert_eq!(
            complex_obj.to_string(),
            "{\
                \"b\":[\
                    {\"c\":\"\\f\\r\"},\
                    {\"d\":\"\"}\
                ]\
            }"
        );
        assert_eq!(
            complex_obj.pretty().to_string(),
            "\
            {\n  \
                \"b\": [\n    \
                    {\n      \
                        \"c\": \"\\f\\r\"\n    \
                    },\n    \
                    {\n      \
                        \"d\": \"\"\n    \
                    }\n  \
                ]\n\
            }"
        );

        let a = mk_object(&[
            ("a".to_string(), Boolean(true)),
            ("b".to_string(), Array(vec![
                mk_object(&[("c".to_string(), String("\x0c\r".to_string()))]),
                mk_object(&[("d".to_string(), String("".to_string()))])
            ]))
        ]);

        // We can't compare the strings directly because the object fields be
        // printed in a different order.
        assert_eq!(a.clone(), a.to_string().parse().unwrap());
        assert_eq!(a.clone(), a.pretty().to_string().parse().unwrap());
    }

    #[test]
    fn test_write_enum() {
        let animal = Dog;
        assert_eq!(
            format!("{}", super::as_json(&animal)),
            "\"Dog\""
        );
        assert_eq!(
            format!("{}", super::as_pretty_json(&animal)),
            "\"Dog\""
        );

        let animal = Frog("Henry".to_string(), 349);
        assert_eq!(
            format!("{}", super::as_json(&animal)),
            "{\"variant\":\"Frog\",\"fields\":[\"Henry\",349]}"
        );
        assert_eq!(
            format!("{}", super::as_pretty_json(&animal)),
            "{\n  \
               \"variant\": \"Frog\",\n  \
               \"fields\": [\n    \
                 \"Henry\",\n    \
                 349\n  \
               ]\n\
             }"
        );
    }

    macro_rules! check_encoder_for_simple {
        ($value:expr, $expected:expr) => ({
            let s = format!("{}", super::as_json(&$value));
            assert_eq!(s, $expected);

            let s = format!("{}", super::as_pretty_json(&$value));
            assert_eq!(s, $expected);
        })
    }

    #[test]
    fn test_write_some() {
        check_encoder_for_simple!(Some("jodhpurs".to_string()), "\"jodhpurs\"");
    }

    #[test]
    fn test_write_none() {
        check_encoder_for_simple!(None::, "null");
    }

    #[test]
    fn test_write_char() {
        check_encoder_for_simple!('a', "\"a\"");
        check_encoder_for_simple!('\t', "\"\\t\"");
        check_encoder_for_simple!('\u{0000}', "\"\\u0000\"");
        check_encoder_for_simple!('\u{001b}', "\"\\u001b\"");
        check_encoder_for_simple!('\u{007f}', "\"\\u007f\"");
        check_encoder_for_simple!('\u{00a0}', "\"\u{00a0}\"");
        check_encoder_for_simple!('\u{abcd}', "\"\u{abcd}\"");
        check_encoder_for_simple!('\u{10ffff}', "\"\u{10ffff}\"");
    }

    #[test]
    fn test_trailing_characters() {
        assert_eq!(Json::from_str("nulla"),  Err(SyntaxError(TrailingCharacters, 1, 5)));
        assert_eq!(Json::from_str("truea"),  Err(SyntaxError(TrailingCharacters, 1, 5)));
        assert_eq!(Json::from_str("falsea"), Err(SyntaxError(TrailingCharacters, 1, 6)));
        assert_eq!(Json::from_str("1a"),     Err(SyntaxError(TrailingCharacters, 1, 2)));
        assert_eq!(Json::from_str("[]a"),    Err(SyntaxError(TrailingCharacters, 1, 3)));
        assert_eq!(Json::from_str("{}a"),    Err(SyntaxError(TrailingCharacters, 1, 3)));
    }

    #[test]
    fn test_read_identifiers() {
        assert_eq!(Json::from_str("n"),    Err(SyntaxError(InvalidSyntax, 1, 2)));
        assert_eq!(Json::from_str("nul"),  Err(SyntaxError(InvalidSyntax, 1, 4)));
        assert_eq!(Json::from_str("t"),    Err(SyntaxError(InvalidSyntax, 1, 2)));
        assert_eq!(Json::from_str("truz"), Err(SyntaxError(InvalidSyntax, 1, 4)));
        assert_eq!(Json::from_str("f"),    Err(SyntaxError(InvalidSyntax, 1, 2)));
        assert_eq!(Json::from_str("faz"),  Err(SyntaxError(InvalidSyntax, 1, 3)));

        assert_eq!(Json::from_str("null"), Ok(Null));
        assert_eq!(Json::from_str("true"), Ok(Boolean(true)));
        assert_eq!(Json::from_str("false"), Ok(Boolean(false)));
        assert_eq!(Json::from_str(" null "), Ok(Null));
        assert_eq!(Json::from_str(" true "), Ok(Boolean(true)));
        assert_eq!(Json::from_str(" false "), Ok(Boolean(false)));
    }

    #[test]
    fn test_decode_identifiers() {
        let v: () = super::decode("null").unwrap();
        assert_eq!(v, ());

        let v: bool = super::decode("true").unwrap();
        assert_eq!(v, true);

        let v: bool = super::decode("false").unwrap();
        assert_eq!(v, false);
    }

    #[test]
    fn test_read_number() {
        assert_eq!(Json::from_str("+"),   Err(SyntaxError(InvalidSyntax, 1, 1)));
        assert_eq!(Json::from_str("."),   Err(SyntaxError(InvalidSyntax, 1, 1)));
        assert_eq!(Json::from_str("NaN"), Err(SyntaxError(InvalidSyntax, 1, 1)));
        assert_eq!(Json::from_str("-"),   Err(SyntaxError(InvalidNumber, 1, 2)));
        assert_eq!(Json::from_str("00"),  Err(SyntaxError(InvalidNumber, 1, 2)));
        assert_eq!(Json::from_str("1."),  Err(SyntaxError(InvalidNumber, 1, 3)));
        assert_eq!(Json::from_str("1e"),  Err(SyntaxError(InvalidNumber, 1, 3)));
        assert_eq!(Json::from_str("1e+"), Err(SyntaxError(InvalidNumber, 1, 4)));

        assert_eq!(Json::from_str("18446744073709551616"), Err(SyntaxError(InvalidNumber, 1, 20)));
        assert_eq!(Json::from_str("18446744073709551617"), Err(SyntaxError(InvalidNumber, 1, 20)));
        assert_eq!(Json::from_str("-9223372036854775809"), Err(SyntaxError(InvalidNumber, 1, 21)));

        assert_eq!(Json::from_str("3"), Ok(U64(3)));
        assert_eq!(Json::from_str("3.1"), Ok(F64(3.1)));
        assert_eq!(Json::from_str("-1.2"), Ok(F64(-1.2)));
        assert_eq!(Json::from_str("0.4"), Ok(F64(0.4)));
        assert_eq!(Json::from_str("0.4e5"), Ok(F64(0.4e5)));
        assert_eq!(Json::from_str("0.4e+15"), Ok(F64(0.4e15)));
        assert_eq!(Json::from_str("0.4e-01"), Ok(F64(0.4e-01)));
        assert_eq!(Json::from_str(" 3 "), Ok(U64(3)));

        assert_eq!(Json::from_str("-9223372036854775808"), Ok(I64(i64::MIN)));
        assert_eq!(Json::from_str("9223372036854775807"), Ok(U64(i64::MAX as u64)));
        assert_eq!(Json::from_str("18446744073709551615"), Ok(U64(u64::MAX)));
    }

    #[test]
    fn test_decode_numbers() {
        let v: f64 = super::decode("3").unwrap();
        assert_eq!(v, 3.0);

        let v: f64 = super::decode("3.1").unwrap();
        assert_eq!(v, 3.1);

        let v: f64 = super::decode("-1.2").unwrap();
        assert_eq!(v, -1.2);

        let v: f64 = super::decode("0.4").unwrap();
        assert_eq!(v, 0.4);

        let v: f64 = super::decode("0.4e5").unwrap();
        assert_eq!(v, 0.4e5);

        let v: f64 = super::decode("0.4e15").unwrap();
        assert_eq!(v, 0.4e15);

        let v: f64 = super::decode("0.4e-01").unwrap();
        assert_eq!(v, 0.4e-01);

        let v: u64 = super::decode("0").unwrap();
        assert_eq!(v, 0);

        let v: u64 = super::decode("18446744073709551615").unwrap();
        assert_eq!(v, u64::MAX);

        let v: i64 = super::decode("-9223372036854775808").unwrap();
        assert_eq!(v, i64::MIN);

        let v: i64 = super::decode("9223372036854775807").unwrap();
        assert_eq!(v, i64::MAX);

        let res: DecodeResult = super::decode("765.25252");
        match res {
            Ok(..) => panic!("expected an error"),
            Err(ExpectedError(ref s, _)) => assert_eq!(s, "Integer"),
            Err(..) => panic!("expected an 'expected integer' error"),
        }
    }

    #[test]
    fn test_read_str() {
        assert_eq!(Json::from_str("\""),     Err(SyntaxError(EOFWhileParsingString, 1, 2)));
        assert_eq!(Json::from_str("\"lol"),  Err(SyntaxError(EOFWhileParsingString, 1, 5)));
        assert_eq!(Json::from_str("\"\n\""), Err(SyntaxError(ControlCharacterInString, 2, 1)));

        assert_eq!(Json::from_str("\"\""), Ok(String("".to_string())));
        assert_eq!(Json::from_str("\"foo\""), Ok(String("foo".to_string())));
        assert_eq!(Json::from_str("\"\\\"\""), Ok(String("\"".to_string())));
        assert_eq!(Json::from_str("\"\\b\""), Ok(String("\x08".to_string())));
        assert_eq!(Json::from_str("\"\\n\""), Ok(String("\n".to_string())));
        assert_eq!(Json::from_str("\"\\r\""), Ok(String("\r".to_string())));
        assert_eq!(Json::from_str("\"\\t\""), Ok(String("\t".to_string())));
        assert_eq!(Json::from_str(" \"foo\" "), Ok(String("foo".to_string())));
        assert_eq!(Json::from_str("\"\\u12ab\""), Ok(String("\u{12ab}".to_string())));
        assert_eq!(Json::from_str("\"\\uAB12\""), Ok(String("\u{AB12}".to_string())));
    }

    #[test]
    fn test_decode_str() {
        let s = [("\"\"", ""),
                 ("\"foo\"", "foo"),
                 ("\"\\\"\"", "\""),
                 ("\"\\b\"", "\x08"),
                 ("\"\\n\"", "\n"),
                 ("\"\\r\"", "\r"),
                 ("\"\\t\"", "\t"),
                 ("\"\\u12ab\"", "\u{12ab}"),
                 ("\"\\uAB12\"", "\u{AB12}")];

        for &(i, o) in s.iter() {
            let v: string::String = super::decode(i).unwrap();
            assert_eq!(v, o);
        }
    }

    #[test]
    fn test_read_array() {
        assert_eq!(Json::from_str("["),     Err(SyntaxError(EOFWhileParsingValue, 1, 2)));
        assert_eq!(Json::from_str("[1"),    Err(SyntaxError(EOFWhileParsingArray, 1, 3)));
        assert_eq!(Json::from_str("[1,"),   Err(SyntaxError(EOFWhileParsingValue, 1, 4)));
        assert_eq!(Json::from_str("[1,]"),  Err(SyntaxError(InvalidSyntax,        1, 4)));
        assert_eq!(Json::from_str("[6 7]"), Err(SyntaxError(InvalidSyntax,        1, 4)));

        assert_eq!(Json::from_str("[]"), Ok(Array(vec![])));
        assert_eq!(Json::from_str("[ ]"), Ok(Array(vec![])));
        assert_eq!(Json::from_str("[true]"), Ok(Array(vec![Boolean(true)])));
        assert_eq!(Json::from_str("[ false ]"), Ok(Array(vec![Boolean(false)])));
        assert_eq!(Json::from_str("[null]"), Ok(Array(vec![Null])));
        assert_eq!(Json::from_str("[3, 1]"),
                     Ok(Array(vec![U64(3), U64(1)])));
        assert_eq!(Json::from_str("\n[3, 2]\n"),
                     Ok(Array(vec![U64(3), U64(2)])));
        assert_eq!(Json::from_str("[2, [4, 1]]"),
               Ok(Array(vec![U64(2), Array(vec![U64(4), U64(1)])])));
    }

    #[test]
    fn test_decode_array() {
        let v: Vec<()> = super::decode("[]").unwrap();
        assert_eq!(v, vec![]);

        let v: Vec<()> = super::decode("[null]").unwrap();
        assert_eq!(v, vec![()]);

        let v: Vec = super::decode("[true]").unwrap();
        assert_eq!(v, vec![true]);

        let v: Vec = super::decode("[3, 1]").unwrap();
        assert_eq!(v, vec![3, 1]);

        let v: Vec> = super::decode("[[3], [1, 2]]").unwrap();
        assert_eq!(v, vec![vec![3], vec![1, 2]]);
    }

    #[test]
    fn test_decode_tuple() {
        let t: (usize, usize, usize) = super::decode("[1, 2, 3]").unwrap();
        assert_eq!(t, (1, 2, 3));

        let t: (usize, string::String) = super::decode("[1, \"two\"]").unwrap();
        assert_eq!(t, (1, "two".to_string()));
    }

    #[test]
    fn test_decode_tuple_malformed_types() {
        assert!(super::decode::<(usize, string::String)>("[1, 2]").is_err());
    }

    #[test]
    fn test_decode_tuple_malformed_length() {
        assert!(super::decode::<(usize, usize)>("[1, 2, 3]").is_err());
    }

    #[test]
    fn test_read_object() {
        assert_eq!(Json::from_str("{"),       Err(SyntaxError(EOFWhileParsingObject, 1, 2)));
        assert_eq!(Json::from_str("{ "),      Err(SyntaxError(EOFWhileParsingObject, 1, 3)));
        assert_eq!(Json::from_str("{1"),      Err(SyntaxError(KeyMustBeAString,      1, 2)));
        assert_eq!(Json::from_str("{ \"a\""), Err(SyntaxError(EOFWhileParsingObject, 1, 6)));
        assert_eq!(Json::from_str("{\"a\""),  Err(SyntaxError(EOFWhileParsingObject, 1, 5)));
        assert_eq!(Json::from_str("{\"a\" "), Err(SyntaxError(EOFWhileParsingObject, 1, 6)));

        assert_eq!(Json::from_str("{\"a\" 1"),   Err(SyntaxError(ExpectedColon,         1, 6)));
        assert_eq!(Json::from_str("{\"a\":"),    Err(SyntaxError(EOFWhileParsingValue,  1, 6)));
        assert_eq!(Json::from_str("{\"a\":1"),   Err(SyntaxError(EOFWhileParsingObject, 1, 7)));
        assert_eq!(Json::from_str("{\"a\":1 1"), Err(SyntaxError(InvalidSyntax,         1, 8)));
        assert_eq!(Json::from_str("{\"a\":1,"),  Err(SyntaxError(EOFWhileParsingObject, 1, 8)));

        assert_eq!(Json::from_str("{}").unwrap(), mk_object(&[]));
        assert_eq!(Json::from_str("{\"a\": 3}").unwrap(),
                  mk_object(&[("a".to_string(), U64(3))]));

        assert_eq!(Json::from_str(
                      "{ \"a\": null, \"b\" : true }").unwrap(),
                  mk_object(&[
                      ("a".to_string(), Null),
                      ("b".to_string(), Boolean(true))]));
        assert_eq!(Json::from_str("\n{ \"a\": null, \"b\" : true }\n").unwrap(),
                  mk_object(&[
                      ("a".to_string(), Null),
                      ("b".to_string(), Boolean(true))]));
        assert_eq!(Json::from_str(
                      "{\"a\" : 1.0 ,\"b\": [ true ]}").unwrap(),
                  mk_object(&[
                      ("a".to_string(), F64(1.0)),
                      ("b".to_string(), Array(vec![Boolean(true)]))
                  ]));
        assert_eq!(Json::from_str(
                      "{\
                          \"a\": 1.0, \
                          \"b\": [\
                              true,\
                              \"foo\\nbar\", \
                              { \"c\": {\"d\": null} } \
                          ]\
                      }").unwrap(),
                  mk_object(&[
                      ("a".to_string(), F64(1.0)),
                      ("b".to_string(), Array(vec![
                          Boolean(true),
                          String("foo\nbar".to_string()),
                          mk_object(&[
                              ("c".to_string(), mk_object(&[("d".to_string(), Null)]))
                          ])
                      ]))
                  ]));
    }

    #[test]
    fn test_decode_struct() {
        let s = "{
            \"inner\": [
                { \"a\": null, \"b\": 2, \"c\": [\"abc\", \"xyz\"] }
            ]
        }";

        let v: Outer = super::decode(s).unwrap();
        assert_eq!(
            v,
            Outer {
                inner: vec![
                    Inner { a: (), b: 2, c: vec!["abc".to_string(), "xyz".to_string()] }
                ]
            }
        );
    }

    #[derive(RustcDecodable)]
    struct FloatStruct {
        f: f64,
        a: Vec
    }
    #[test]
    fn test_decode_struct_with_nan() {
        let s = "{\"f\":null,\"a\":[null,123]}";
        let obj: FloatStruct = super::decode(s).unwrap();
        assert!(obj.f.is_nan());
        assert!(obj.a[0].is_nan());
        assert_eq!(obj.a[1], 123f64);
    }

    #[test]
    fn test_decode_option() {
        let value: Option = super::decode("null").unwrap();
        assert_eq!(value, None);

        let value: Option = super::decode("\"jodhpurs\"").unwrap();
        assert_eq!(value, Some("jodhpurs".to_string()));
    }

    #[test]
    fn test_decode_enum() {
        let value: Animal = super::decode("\"Dog\"").unwrap();
        assert_eq!(value, Dog);

        let s = "{\"variant\":\"Frog\",\"fields\":[\"Henry\",349]}";
        let value: Animal = super::decode(s).unwrap();
        assert_eq!(value, Frog("Henry".to_string(), 349));
    }

    #[test]
    fn test_decode_map() {
        let s = "{\"a\": \"Dog\", \"b\": {\"variant\":\"Frog\",\
                  \"fields\":[\"Henry\", 349]}}";
        let mut map: BTreeMap = super::decode(s).unwrap();

        assert_eq!(map.remove(&"a".to_string()), Some(Dog));
        assert_eq!(map.remove(&"b".to_string()), Some(Frog("Henry".to_string(), 349)));
    }

    #[test]
    fn test_multiline_errors() {
        assert_eq!(Json::from_str("{\n  \"foo\":\n \"bar\""),
            Err(SyntaxError(EOFWhileParsingObject, 3, 8)));
    }

    #[derive(RustcDecodable)]
    #[allow(dead_code)]
    struct DecodeStruct {
        x: f64,
        y: bool,
        z: string::String,
        w: Vec
    }
    #[derive(RustcDecodable)]
    enum DecodeEnum {
        A(f64),
        B(string::String)
    }
    fn check_err(to_parse: &'static str, expected: DecoderError) {
        let res: DecodeResult = match Json::from_str(to_parse) {
            Err(e) => Err(ParseError(e)),
            Ok(json) => Decodable::decode(&mut Decoder::new(json))
        };
        match res {
            Ok(_) => panic!("`{:?}` parsed & decoded ok, expecting error `{:?}`",
                              to_parse, expected),
            Err(ParseError(e)) => panic!("`{}` is not valid json: {:?}",
                                           to_parse, e),
            Err(e) => {
                assert_eq!(e, expected);
            }
        }
    }
    #[test]
    fn test_decode_errors_struct() {
        check_err::("[]", ExpectedError("Object".to_string(), "[]".to_string()));
        check_err::("{\"x\": true, \"y\": true, \"z\": \"\", \"w\": []}",
                                  ExpectedError("Number".to_string(), "true".to_string()));
        check_err::("{\"x\": 1, \"y\": [], \"z\": \"\", \"w\": []}",
                                  ExpectedError("Boolean".to_string(), "[]".to_string()));
        check_err::("{\"x\": 1, \"y\": true, \"z\": {}, \"w\": []}",
                                  ExpectedError("String".to_string(), "{}".to_string()));
        check_err::("{\"x\": 1, \"y\": true, \"z\": \"\", \"w\": null}",
                                  ExpectedError("Array".to_string(), "null".to_string()));
        check_err::("{\"x\": 1, \"y\": true, \"z\": \"\"}",
                                  MissingFieldError("w".to_string()));
    }
    #[test]
    fn test_decode_errors_enum() {
        check_err::("{}",
                                MissingFieldError("variant".to_string()));
        check_err::("{\"variant\": 1}",
                                ExpectedError("String".to_string(), "1".to_string()));
        check_err::("{\"variant\": \"A\"}",
                                MissingFieldError("fields".to_string()));
        check_err::("{\"variant\": \"A\", \"fields\": null}",
                                ExpectedError("Array".to_string(), "null".to_string()));
        check_err::("{\"variant\": \"C\", \"fields\": []}",
                                UnknownVariantError("C".to_string()));
    }

    #[test]
    fn test_find(){
        let json_value = Json::from_str("{\"dog\" : \"cat\"}").unwrap();
        let found_str = json_value.find("dog");
        assert!(found_str.unwrap().as_string().unwrap() == "cat");
    }

    #[test]
    fn test_find_path(){
        let json_value = Json::from_str("{\"dog\":{\"cat\": {\"mouse\" : \"cheese\"}}}").unwrap();
        let found_str = json_value.find_path(&["dog", "cat", "mouse"]);
        assert!(found_str.unwrap().as_string().unwrap() == "cheese");
    }

    #[test]
    fn test_search(){
        let json_value = Json::from_str("{\"dog\":{\"cat\": {\"mouse\" : \"cheese\"}}}").unwrap();
        let found_str = json_value.search("mouse").and_then(|j| j.as_string());
        assert!(found_str.unwrap() == "cheese");
    }

    #[test]
    fn test_index(){
        let json_value = Json::from_str("{\"animals\":[\"dog\",\"cat\",\"mouse\"]}").unwrap();
        let ref array = json_value["animals"];
        assert_eq!(array[0].as_string().unwrap(), "dog");
        assert_eq!(array[1].as_string().unwrap(), "cat");
        assert_eq!(array[2].as_string().unwrap(), "mouse");
    }

    #[test]
    fn test_is_object(){
        let json_value = Json::from_str("{}").unwrap();
        assert!(json_value.is_object());
    }

    #[test]
    fn test_as_object(){
        let json_value = Json::from_str("{}").unwrap();
        let json_object = json_value.as_object();
        assert!(json_object.is_some());
    }

    #[test]
    fn test_is_array(){
        let json_value = Json::from_str("[1, 2, 3]").unwrap();
        assert!(json_value.is_array());
    }

    #[test]
    fn test_as_array(){
        let json_value = Json::from_str("[1, 2, 3]").unwrap();
        let json_array = json_value.as_array();
        let expected_length = 3;
        assert!(json_array.is_some() && json_array.unwrap().len() == expected_length);
    }

    #[test]
    fn test_is_string(){
        let json_value = Json::from_str("\"dog\"").unwrap();
        assert!(json_value.is_string());
    }

    #[test]
    fn test_as_string(){
        let json_value = Json::from_str("\"dog\"").unwrap();
        let json_str = json_value.as_string();
        let expected_str = "dog";
        assert_eq!(json_str, Some(expected_str));
    }

    #[test]
    fn test_is_number(){
        let json_value = Json::from_str("12").unwrap();
        assert!(json_value.is_number());
    }

    #[test]
    fn test_is_i64(){
        let json_value = Json::from_str("-12").unwrap();
        assert!(json_value.is_i64());

        let json_value = Json::from_str("12").unwrap();
        assert!(!json_value.is_i64());

        let json_value = Json::from_str("12.0").unwrap();
        assert!(!json_value.is_i64());
    }

    #[test]
    fn test_is_u64(){
        let json_value = Json::from_str("12").unwrap();
        assert!(json_value.is_u64());

        let json_value = Json::from_str("-12").unwrap();
        assert!(!json_value.is_u64());

        let json_value = Json::from_str("12.0").unwrap();
        assert!(!json_value.is_u64());
    }

    #[test]
    fn test_is_f64(){
        let json_value = Json::from_str("12").unwrap();
        assert!(!json_value.is_f64());

        let json_value = Json::from_str("-12").unwrap();
        assert!(!json_value.is_f64());

        let json_value = Json::from_str("12.0").unwrap();
        assert!(json_value.is_f64());

        let json_value = Json::from_str("-12.0").unwrap();
        assert!(json_value.is_f64());
    }

    #[test]
    fn test_as_i64(){
        let json_value = Json::from_str("-12").unwrap();
        let json_num = json_value.as_i64();
        assert_eq!(json_num, Some(-12));
    }

    #[test]
    fn test_as_u64(){
        let json_value = Json::from_str("12").unwrap();
        let json_num = json_value.as_u64();
        assert_eq!(json_num, Some(12));
    }

    #[test]
    fn test_as_f64(){
        let json_value = Json::from_str("12.0").unwrap();
        let json_num = json_value.as_f64();
        assert_eq!(json_num, Some(12f64));
    }

    #[test]
    fn test_is_boolean(){
        let json_value = Json::from_str("false").unwrap();
        assert!(json_value.is_boolean());
    }

    #[test]
    fn test_as_boolean(){
        let json_value = Json::from_str("false").unwrap();
        let json_bool = json_value.as_boolean();
        let expected_bool = false;
        assert!(json_bool.is_some() && json_bool.unwrap() == expected_bool);
    }

    #[test]
    fn test_is_null(){
        let json_value = Json::from_str("null").unwrap();
        assert!(json_value.is_null());
    }

    #[test]
    fn test_as_null(){
        let json_value = Json::from_str("null").unwrap();
        let json_null = json_value.as_null();
        let expected_null = ();
        assert!(json_null.is_some() && json_null.unwrap() == expected_null);
    }

    #[test]
    fn test_encode_hashmap_with_numeric_key() {
        use std::collections::HashMap;
        let mut hm: HashMap = HashMap::new();
        hm.insert(1, true);
        let json_str = super::as_pretty_json(&hm).to_string();
        match Json::from_str(&json_str) {
            Err(_) => panic!("Unable to parse json_str: {}", json_str),
            _ => {} // it parsed and we are good to go
        }
    }

    #[test]
    fn test_prettyencode_hashmap_with_numeric_key() {
        use std::collections::HashMap;
        let mut hm: HashMap = HashMap::new();
        hm.insert(1, true);
        let json_str = super::as_pretty_json(&hm).to_string();
        match Json::from_str(&json_str) {
            Err(_) => panic!("Unable to parse json_str: {}", json_str),
            _ => {} // it parsed and we are good to go
        }
    }

    #[test]
    fn test_prettyencoder_indent_level_param() {
        use std::collections::BTreeMap;

        let mut tree = BTreeMap::new();

        tree.insert("hello".to_string(), String("guten tag".to_string()));
        tree.insert("goodbye".to_string(), String("sayonara".to_string()));

        let json = Array(
            // The following layout below should look a lot like
            // the pretty-printed JSON (indent * x)
            vec!
            ( // 0x
                String("greetings".to_string()), // 1x
                Object(tree), // 1x + 2x + 2x + 1x
            ) // 0x
            // End JSON array (7 lines)
        );

        // Helper function for counting indents
        fn indents(source: &str) -> usize {
            let trimmed = source.trim_left_matches(' ');
            source.len() - trimmed.len()
        }

        // Test up to 4 spaces of indents (more?)
        for i in 0..4 {
            let printed = super::as_pretty_json(&json).indent(i as u32)
                                .to_string();

            // Check for indents at each line
            let lines: Vec<&str> = printed.lines().collect();
            assert_eq!(lines.len(), 7); // JSON should be 7 lines

            assert_eq!(indents(lines[0]), 0 * i); // [
            assert_eq!(indents(lines[1]), 1 * i); //   "greetings",
            assert_eq!(indents(lines[2]), 1 * i); //   {
            assert_eq!(indents(lines[3]), 2 * i); //     "hello": "guten tag",
            assert_eq!(indents(lines[4]), 2 * i); //     "goodbye": "sayonara"
            assert_eq!(indents(lines[5]), 1 * i); //   },
            assert_eq!(indents(lines[6]), 0 * i); // ]

            // Finally, test that the pretty-printed JSON is valid
            Json::from_str(&printed).ok()
                 .expect("Pretty-printed JSON is invalid!");
        }
    }

    #[test]
    fn test_hashmap_with_numeric_key_can_handle_double_quote_delimited_key() {
        use std::collections::HashMap;
        use Decodable;
        let json_str = "{\"1\":true}";
        let json_obj = match Json::from_str(json_str) {
            Err(_) => panic!("Unable to parse json_str: {}", json_str),
            Ok(o) => o
        };
        let mut decoder = Decoder::new(json_obj);
        let _hm: HashMap = Decodable::decode(&mut decoder).unwrap();
    }

    #[test]
    fn test_hashmap_with_enum_key() {
        use std::collections::HashMap;
        use json;
        #[derive(RustcEncodable, Eq, Hash, PartialEq, RustcDecodable, Debug)]
        enum Enum {
            Foo,
            #[allow(dead_code)]
            Bar,
        }
        let mut map = HashMap::new();
        map.insert(Enum::Foo, 0);
        let result = json::encode(&map).unwrap();
        assert_eq!(result, r#"{"Foo":0}"#);
        let decoded: HashMap = json::decode(&result).unwrap();
        assert_eq!(map, decoded);
    }

    #[test]
    fn test_hashmap_with_numeric_key_will_error_with_string_keys() {
        use std::collections::HashMap;
        use Decodable;
        let json_str = "{\"a\":true}";
        let json_obj = match Json::from_str(json_str) {
            Err(_) => panic!("Unable to parse json_str: {}", json_str),
            Ok(o) => o
        };
        let mut decoder = Decoder::new(json_obj);
        let result: Result, DecoderError> = Decodable::decode(&mut decoder);
        assert_eq!(result, Err(ExpectedError("Number".to_string(), "a".to_string())));
    }

    fn assert_stream_equal(src: &str,
                           expected: Vec<(JsonEvent, Vec)>) {
        let mut parser = Parser::new(src.chars());
        let mut i = 0;
        loop {
            let evt = match parser.next() {
                Some(e) => e,
                None => { break; }
            };
            let (ref expected_evt, ref expected_stack) = expected[i];
            if !parser.stack().is_equal_to(&expected_stack) {
                panic!("Parser stack is not equal to {:?}", expected_stack);
            }
            assert_eq!(&evt, expected_evt);
            i+=1;
        }
    }
    #[test]
    #[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064)
    fn test_streaming_parser() {
        assert_stream_equal(
            r#"{ "foo":"bar", "array" : [0, 1, 2, 3, 4, 5], "idents":[null,true,false]}"#,
            vec![
                (ObjectStart,             vec![]),
                  (StringValue("bar".to_string()),   vec![Key("foo")]),
                  (ArrayStart,            vec![Key("array")]),
                    (U64Value(0),         vec![Key("array"), Index(0)]),
                    (U64Value(1),         vec![Key("array"), Index(1)]),
                    (U64Value(2),         vec![Key("array"), Index(2)]),
                    (U64Value(3),         vec![Key("array"), Index(3)]),
                    (U64Value(4),         vec![Key("array"), Index(4)]),
                    (U64Value(5),         vec![Key("array"), Index(5)]),
                  (ArrayEnd,              vec![Key("array")]),
                  (ArrayStart,            vec![Key("idents")]),
                    (NullValue,           vec![Key("idents"), Index(0)]),
                    (BooleanValue(true),  vec![Key("idents"), Index(1)]),
                    (BooleanValue(false), vec![Key("idents"), Index(2)]),
                  (ArrayEnd,              vec![Key("idents")]),
                (ObjectEnd,               vec![]),
            ]
        );
    }
    fn last_event(src: &str) -> JsonEvent {
        let mut parser = Parser::new(src.chars());
        let mut evt = NullValue;
        loop {
            evt = match parser.next() {
                Some(e) => e,
                None => return evt,
            }
        }
    }

    #[test]
    #[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064)
    fn test_read_object_streaming() {
        assert_eq!(last_event("{ "),      Error(SyntaxError(EOFWhileParsingObject, 1, 3)));
        assert_eq!(last_event("{1"),      Error(SyntaxError(KeyMustBeAString,      1, 2)));
        assert_eq!(last_event("{ \"a\""), Error(SyntaxError(EOFWhileParsingObject, 1, 6)));
        assert_eq!(last_event("{\"a\""),  Error(SyntaxError(EOFWhileParsingObject, 1, 5)));
        assert_eq!(last_event("{\"a\" "), Error(SyntaxError(EOFWhileParsingObject, 1, 6)));

        assert_eq!(last_event("{\"a\" 1"),   Error(SyntaxError(ExpectedColon,         1, 6)));
        assert_eq!(last_event("{\"a\":"),    Error(SyntaxError(EOFWhileParsingValue,  1, 6)));
        assert_eq!(last_event("{\"a\":1"),   Error(SyntaxError(EOFWhileParsingObject, 1, 7)));
        assert_eq!(last_event("{\"a\":1 1"), Error(SyntaxError(InvalidSyntax,         1, 8)));
        assert_eq!(last_event("{\"a\":1,"),  Error(SyntaxError(EOFWhileParsingObject, 1, 8)));
        assert_eq!(last_event("{\"a\":1,}"), Error(SyntaxError(TrailingComma, 1, 8)));

        assert_stream_equal(
            "{}",
            vec![(ObjectStart, vec![]), (ObjectEnd, vec![])]
        );
        assert_stream_equal(
            "{\"a\": 3}",
            vec![
                (ObjectStart,        vec![]),
                  (U64Value(3),      vec![Key("a")]),
                (ObjectEnd,          vec![]),
            ]
        );
        assert_stream_equal(
            "{ \"a\": null, \"b\" : true }",
            vec![
                (ObjectStart,           vec![]),
                  (NullValue,           vec![Key("a")]),
                  (BooleanValue(true),  vec![Key("b")]),
                (ObjectEnd,             vec![]),
            ]
        );
        assert_stream_equal(
            "{\"a\" : 1.0 ,\"b\": [ true ]}",
            vec![
                (ObjectStart,           vec![]),
                  (F64Value(1.0),       vec![Key("a")]),
                  (ArrayStart,          vec![Key("b")]),
                    (BooleanValue(true),vec![Key("b"), Index(0)]),
                  (ArrayEnd,            vec![Key("b")]),
                (ObjectEnd,             vec![]),
            ]
        );
        assert_stream_equal(
            r#"{
                "a": 1.0,
                "b": [
                    true,
                    "foo\nbar",
                    { "c": {"d": null} },
                    "\uD834\uDF06"
                ]
            }"#,
            vec![
                (ObjectStart,                   vec![]),
                  (F64Value(1.0),               vec![Key("a")]),
                  (ArrayStart,                  vec![Key("b")]),
                    (BooleanValue(true),        vec![Key("b"), Index(0)]),
                    (StringValue("foo\nbar".to_string()),  vec![Key("b"), Index(1)]),
                    (ObjectStart,               vec![Key("b"), Index(2)]),
                      (ObjectStart,             vec![Key("b"), Index(2), Key("c")]),
                        (NullValue,             vec![Key("b"), Index(2), Key("c"), Key("d")]),
                      (ObjectEnd,               vec![Key("b"), Index(2), Key("c")]),
                    (ObjectEnd,                 vec![Key("b"), Index(2)]),
                    (StringValue("\u{1D306}".to_string()),  vec![Key("b"), Index(3)]),
                  (ArrayEnd,                    vec![Key("b")]),
                (ObjectEnd,                     vec![]),
            ]
        );
    }
    #[test]
    #[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064)
    fn test_read_array_streaming() {
        assert_stream_equal(
            "[]",
            vec![
                (ArrayStart, vec![]),
                (ArrayEnd,   vec![]),
            ]
        );
        assert_stream_equal(
            "[ ]",
            vec![
                (ArrayStart, vec![]),
                (ArrayEnd,   vec![]),
            ]
        );
        assert_stream_equal(
            "[true]",
            vec![
                (ArrayStart,             vec![]),
                    (BooleanValue(true), vec![Index(0)]),
                (ArrayEnd,               vec![]),
            ]
        );
        assert_stream_equal(
            "[ false ]",
            vec![
                (ArrayStart,              vec![]),
                    (BooleanValue(false), vec![Index(0)]),
                (ArrayEnd,                vec![]),
            ]
        );
        assert_stream_equal(
            "[null]",
            vec![
                (ArrayStart,    vec![]),
                    (NullValue, vec![Index(0)]),
                (ArrayEnd,      vec![]),
            ]
        );
        assert_stream_equal(
            "[3, 1]",
            vec![
                (ArrayStart,      vec![]),
                    (U64Value(3), vec![Index(0)]),
                    (U64Value(1), vec![Index(1)]),
                (ArrayEnd,        vec![]),
            ]
        );
        assert_stream_equal(
            "\n[3, 2]\n",
            vec![
                (ArrayStart,      vec![]),
                    (U64Value(3), vec![Index(0)]),
                    (U64Value(2), vec![Index(1)]),
                (ArrayEnd,        vec![]),
            ]
        );
        assert_stream_equal(
            "[2, [4, 1]]",
            vec![
                (ArrayStart,           vec![]),
                    (U64Value(2),      vec![Index(0)]),
                    (ArrayStart,       vec![Index(1)]),
                        (U64Value(4),  vec![Index(1), Index(0)]),
                        (U64Value(1),  vec![Index(1), Index(1)]),
                    (ArrayEnd,         vec![Index(1)]),
                (ArrayEnd,             vec![]),
            ]
        );

        assert_eq!(last_event("["), Error(SyntaxError(EOFWhileParsingValue, 1,  2)));

        assert_eq!(Json::from_str("["),     Err(SyntaxError(EOFWhileParsingValue, 1, 2)));
        assert_eq!(Json::from_str("[1"),    Err(SyntaxError(EOFWhileParsingArray, 1, 3)));
        assert_eq!(Json::from_str("[1,"),   Err(SyntaxError(EOFWhileParsingValue, 1, 4)));
        assert_eq!(Json::from_str("[1,]"),  Err(SyntaxError(InvalidSyntax,        1, 4)));
        assert_eq!(Json::from_str("[6 7]"), Err(SyntaxError(InvalidSyntax,        1, 4)));

    }
    #[test]
    fn test_trailing_characters_streaming() {
        assert_eq!(last_event("nulla"),  Error(SyntaxError(TrailingCharacters, 1, 5)));
        assert_eq!(last_event("truea"),  Error(SyntaxError(TrailingCharacters, 1, 5)));
        assert_eq!(last_event("falsea"), Error(SyntaxError(TrailingCharacters, 1, 6)));
        assert_eq!(last_event("1a"),     Error(SyntaxError(TrailingCharacters, 1, 2)));
        assert_eq!(last_event("[]a"),    Error(SyntaxError(TrailingCharacters, 1, 3)));
        assert_eq!(last_event("{}a"),    Error(SyntaxError(TrailingCharacters, 1, 3)));
    }
    #[test]
    fn test_read_identifiers_streaming() {
        assert_eq!(Parser::new("null".chars()).next(), Some(NullValue));
        assert_eq!(Parser::new("true".chars()).next(), Some(BooleanValue(true)));
        assert_eq!(Parser::new("false".chars()).next(), Some(BooleanValue(false)));

        assert_eq!(last_event("n"),    Error(SyntaxError(InvalidSyntax, 1, 2)));
        assert_eq!(last_event("nul"),  Error(SyntaxError(InvalidSyntax, 1, 4)));
        assert_eq!(last_event("t"),    Error(SyntaxError(InvalidSyntax, 1, 2)));
        assert_eq!(last_event("truz"), Error(SyntaxError(InvalidSyntax, 1, 4)));
        assert_eq!(last_event("f"),    Error(SyntaxError(InvalidSyntax, 1, 2)));
        assert_eq!(last_event("faz"),  Error(SyntaxError(InvalidSyntax, 1, 3)));
    }

    #[test]
    fn test_stack() {
        let mut stack = Stack::new();

        assert!(stack.is_empty());
        assert!(stack.len() == 0);
        assert!(!stack.last_is_index());

        stack.push_index(0);
        stack.bump_index();

        assert!(stack.len() == 1);
        assert!(stack.is_equal_to(&[Index(1)]));
        assert!(stack.starts_with(&[Index(1)]));
        assert!(stack.ends_with(&[Index(1)]));
        assert!(stack.last_is_index());
        assert!(stack.get(0) == Index(1));

        stack.push_key("foo".to_string());

        assert!(stack.len() == 2);
        assert!(stack.is_equal_to(&[Index(1), Key("foo")]));
        assert!(stack.starts_with(&[Index(1), Key("foo")]));
        assert!(stack.starts_with(&[Index(1)]));
        assert!(stack.ends_with(&[Index(1), Key("foo")]));
        assert!(stack.ends_with(&[Key("foo")]));
        assert!(!stack.last_is_index());
        assert!(stack.get(0) == Index(1));
        assert!(stack.get(1) == Key("foo"));

        stack.push_key("bar".to_string());

        assert!(stack.len() == 3);
        assert!(stack.is_equal_to(&[Index(1), Key("foo"), Key("bar")]));
        assert!(stack.starts_with(&[Index(1)]));
        assert!(stack.starts_with(&[Index(1), Key("foo")]));
        assert!(stack.starts_with(&[Index(1), Key("foo"), Key("bar")]));
        assert!(stack.ends_with(&[Key("bar")]));
        assert!(stack.ends_with(&[Key("foo"), Key("bar")]));
        assert!(stack.ends_with(&[Index(1), Key("foo"), Key("bar")]));
        assert!(!stack.last_is_index());
        assert!(stack.get(0) == Index(1));
        assert!(stack.get(1) == Key("foo"));
        assert!(stack.get(2) == Key("bar"));

        stack.pop();

        assert!(stack.len() == 2);
        assert!(stack.is_equal_to(&[Index(1), Key("foo")]));
        assert!(stack.starts_with(&[Index(1), Key("foo")]));
        assert!(stack.starts_with(&[Index(1)]));
        assert!(stack.ends_with(&[Index(1), Key("foo")]));
        assert!(stack.ends_with(&[Key("foo")]));
        assert!(!stack.last_is_index());
        assert!(stack.get(0) == Index(1));
        assert!(stack.get(1) == Key("foo"));
    }

    #[test]
    fn test_to_json() {
        use std::collections::{HashMap,BTreeMap};
        use super::ToJson;

        let array2 = Array(vec!(I64(1), I64(2)));
        let array3 = Array(vec!(I64(1), I64(2), I64(3)));
        let object = {
            let mut tree_map = BTreeMap::new();
            tree_map.insert("a".to_string(), U64(1));
            tree_map.insert("b".to_string(), U64(2));
            Object(tree_map)
        };

        assert_eq!(array2.to_json(), array2);
        assert_eq!(object.to_json(), object);
        assert_eq!(3_isize.to_json(), I64(3));
        assert_eq!(4_i8.to_json(), I64(4));
        assert_eq!(5_i16.to_json(), I64(5));
        assert_eq!(6_i32.to_json(), I64(6));
        assert_eq!(7_i64.to_json(), I64(7));
        assert_eq!(8_usize.to_json(), U64(8));
        assert_eq!(9_u8.to_json(), U64(9));
        assert_eq!(10_u16.to_json(), U64(10));
        assert_eq!(11_u32.to_json(), U64(11));
        assert_eq!(12_u64.to_json(), U64(12));
        assert_eq!(13.0_f32.to_json(), F64(13.0_f64));
        assert_eq!(14.0_f64.to_json(), F64(14.0_f64));
        assert_eq!(().to_json(), Null);
        assert_eq!(f32::INFINITY.to_json(), Null);
        assert_eq!(f64::NAN.to_json(), Null);
        assert_eq!(true.to_json(), Boolean(true));
        assert_eq!(false.to_json(), Boolean(false));
        assert_eq!("abc".to_json(), String("abc".to_string()));
        assert_eq!("abc".to_string().to_json(), String("abc".to_string()));
        assert_eq!((1, 2).to_json(), array2);
        assert_eq!((1, 2, 3).to_json(), array3);
        assert_eq!([1, 2].to_json(), array2);
        assert_eq!((&[1, 2, 3]).to_json(), array3);
        assert_eq!((vec![1, 2]).to_json(), array2);
        assert_eq!(vec!(1, 2, 3).to_json(), array3);
        let mut tree_map = BTreeMap::new();
        tree_map.insert("a".to_string(), 1 as u32);
        tree_map.insert("b".to_string(), 2);
        assert_eq!(tree_map.to_json(), object);
        let mut hash_map = HashMap::new();
        hash_map.insert("a".to_string(), 1 as u32);
        hash_map.insert("b".to_string(), 2);
        assert_eq!(hash_map.to_json(), object);
        assert_eq!(Some(15).to_json(), I64(15));
        assert_eq!(Some(15 as u32).to_json(), U64(15));
        assert_eq!(None::.to_json(), Null);
    }

    #[test]
    fn test_encode_hashmap_with_arbitrary_key() {
        use std::collections::HashMap;
        #[derive(PartialEq, Eq, Hash, RustcEncodable)]
        struct ArbitraryType(u32);
        let mut hm: HashMap = HashMap::new();
        hm.insert(ArbitraryType(1), true);
        let mut mem_buf = string::String::new();
        let mut encoder = Encoder::new(&mut mem_buf);
        let result = hm.encode(&mut encoder);
        match result.err().unwrap() {
            EncoderError::BadHashmapKey => (),
            _ => panic!("expected bad hash map key")
        }
    }

    #[test]
    fn test_encode_decode_phantom_data() {
        use std::marker::PhantomData;

        #[derive(Debug, RustcDecodable, RustcEncodable, Eq, PartialEq)]
        struct Foo

{ phantom_data: PhantomData

} let f: Foo = Foo { phantom_data: PhantomData }; let s = super::encode(&f).unwrap(); let d: Foo = super::decode(&s).unwrap(); assert_eq!(f, d); } #[test] fn test_bad_json_stack_depleted() { use json; #[derive(Debug, RustcDecodable)] enum ChatEvent { Variant(i32) } let serialized = "{\"variant\": \"Variant\", \"fields\": []}"; let r: Result = json::decode(serialized); assert!(r.unwrap_err() == EOF); } #[test] fn fixed_length_array() { #[derive(Debug, RustcDecodable, RustcEncodable, Eq, PartialEq)] struct Foo { a: [u8; 1], b: [i32; 2], c: [u64; 3], } let f = Foo { a: [0], b: [1, 2], c: [3, 4, 5], }; let s = super::encode(&f).unwrap(); let d = super::decode(&s).unwrap(); assert_eq!(f, d); } } deps/rustc-serialize-0.3.16/src/hex.rs0000664000175000017500000001350312534625075014537 0ustar // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // // ignore-lexer-test FIXME #15679 //! Hex binary-to-text encoding pub use self::FromHexError::*; use std::fmt; use std::error; /// A trait for converting a value to hexadecimal encoding pub trait ToHex { /// Converts the value of `self` to a hex value, returning the owned /// string. fn to_hex(&self) -> String; } static CHARS: &'static[u8] = b"0123456789abcdef"; impl ToHex for [u8] { /// Turn a vector of `u8` bytes into a hexadecimal string. /// /// # Example /// /// ```rust /// extern crate rustc_serialize; /// use rustc_serialize::hex::ToHex; /// /// fn main () { /// let str = [52,32].to_hex(); /// println!("{}", str); /// } /// ``` fn to_hex(&self) -> String { let mut v = Vec::with_capacity(self.len() * 2); for &byte in self.iter() { v.push(CHARS[(byte >> 4) as usize]); v.push(CHARS[(byte & 0xf) as usize]); } unsafe { String::from_utf8_unchecked(v) } } } /// A trait for converting hexadecimal encoded values pub trait FromHex { /// Converts the value of `self`, interpreted as hexadecimal encoded data, /// into an owned vector of bytes, returning the vector. fn from_hex(&self) -> Result, FromHexError>; } /// Errors that can occur when decoding a hex encoded string #[derive(Clone, Copy)] pub enum FromHexError { /// The input contained a character not part of the hex format InvalidHexCharacter(char, usize), /// The input had an invalid length InvalidHexLength, } impl fmt::Debug for FromHexError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { InvalidHexCharacter(ch, idx) => write!(f, "Invalid character '{}' at position {}", ch, idx), InvalidHexLength => write!(f, "Invalid input length"), } } } impl error::Error for FromHexError { fn description(&self) -> &str { match *self { InvalidHexCharacter(_, _) => "invalid character", InvalidHexLength => "invalid length", } } } impl fmt::Display for FromHexError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&self, f) } } impl FromHex for str { /// Convert any hexadecimal encoded string (literal, `@`, `&`, or `~`) /// to the byte values it encodes. /// /// You can use the `String::from_utf8` function to turn a /// `Vec` into a string with characters corresponding to those values. /// /// # Example /// /// This converts a string literal to hexadecimal and back. /// /// ```rust /// extern crate rustc_serialize; /// use rustc_serialize::hex::{FromHex, ToHex}; /// /// fn main () { /// let hello_str = "Hello, World".as_bytes().to_hex(); /// println!("{}", hello_str); /// let bytes = hello_str.from_hex().unwrap(); /// println!("{:?}", bytes); /// let result_str = String::from_utf8(bytes).unwrap(); /// println!("{}", result_str); /// } /// ``` fn from_hex(&self) -> Result, FromHexError> { // This may be an overestimate if there is any whitespace let mut b = Vec::with_capacity(self.len() / 2); let mut modulus = 0; let mut buf = 08; for (idx, byte) in self.bytes().enumerate() { buf <<= 4; match byte { b'A'...b'F' => buf |= byte - b'A' + 10, b'a'...b'f' => buf |= byte - b'a' + 10, b'0'...b'9' => buf |= byte - b'0', b' '|b'\r'|b'\n'|b'\t' => { buf >>= 4; continue } _ => { let ch = self[idx..].chars().next().unwrap(); return Err(InvalidHexCharacter(ch, idx)) } } modulus += 1; if modulus == 2 { modulus = 0; b.push(buf); } } match modulus { 0 => Ok(b.into_iter().collect()), _ => Err(InvalidHexLength), } } } #[cfg(test)] mod tests { use hex::{FromHex, ToHex}; #[test] pub fn test_to_hex() { assert_eq!("foobar".as_bytes().to_hex(), "666f6f626172"); } #[test] pub fn test_from_hex_okay() { assert_eq!("666f6f626172".from_hex().unwrap(), b"foobar"); assert_eq!("666F6F626172".from_hex().unwrap(), b"foobar"); } #[test] pub fn test_from_hex_odd_len() { assert!("666".from_hex().is_err()); assert!("66 6".from_hex().is_err()); } #[test] pub fn test_from_hex_invalid_char() { assert!("66y6".from_hex().is_err()); } #[test] pub fn test_from_hex_ignores_whitespace() { assert_eq!("666f 6f6\r\n26172 ".from_hex().unwrap(), b"foobar"); } #[test] pub fn test_to_hex_all_bytes() { for i in 0..256 { assert_eq!([i as u8].to_hex(), format!("{:02x}", i)); } } #[test] pub fn test_from_hex_all_bytes() { for i in 0..256 { let ii: &[u8] = &[i as u8]; assert_eq!(format!("{:02x}", i).from_hex().unwrap(), ii); assert_eq!(format!("{:02X}", i).from_hex().unwrap(), ii); } } } deps/rustc-serialize-0.3.16/src/base64.rs0000664000175000017500000004005212534623164015033 0ustar // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // // ignore-lexer-test FIXME #15679 //! Base64 binary-to-text encoding pub use self::FromBase64Error::*; pub use self::CharacterSet::*; use std::fmt; use std::error; /// Available encoding character sets #[derive(Clone, Copy)] pub enum CharacterSet { /// The standard character set (uses `+` and `/`) Standard, /// The URL safe character set (uses `-` and `_`) UrlSafe } /// Available newline types #[derive(Clone, Copy)] pub enum Newline { /// A linefeed (i.e. Unix-style newline) LF, /// A carriage return and a linefeed (i.e. Windows-style newline) CRLF } /// Contains configuration parameters for `to_base64`. #[derive(Clone, Copy)] pub struct Config { /// Character set to use pub char_set: CharacterSet, /// Newline to use pub newline: Newline, /// True to pad output with `=` characters pub pad: bool, /// `Some(len)` to wrap lines at `len`, `None` to disable line wrapping pub line_length: Option } /// Configuration for RFC 4648 standard base64 encoding pub static STANDARD: Config = Config {char_set: Standard, newline: Newline::CRLF, pad: true, line_length: None}; /// Configuration for RFC 4648 base64url encoding pub static URL_SAFE: Config = Config {char_set: UrlSafe, newline: Newline::CRLF, pad: false, line_length: None}; /// Configuration for RFC 2045 MIME base64 encoding pub static MIME: Config = Config {char_set: Standard, newline: Newline::CRLF, pad: true, line_length: Some(76)}; static STANDARD_CHARS: &'static[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz\ 0123456789+/"; static URLSAFE_CHARS: &'static[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz\ 0123456789-_"; /// A trait for converting a value to base64 encoding. pub trait ToBase64 { /// Converts the value of `self` to a base64 value following the specified /// format configuration, returning the owned string. fn to_base64(&self, config: Config) -> String; } impl ToBase64 for [u8] { /// Turn a vector of `u8` bytes into a base64 string. /// /// # Example /// /// ```rust /// extern crate rustc_serialize; /// use rustc_serialize::base64::{ToBase64, STANDARD}; /// /// fn main () { /// let str = [52,32].to_base64(STANDARD); /// println!("base 64 output: {:?}", str); /// } /// ``` fn to_base64(&self, config: Config) -> String { let bytes = match config.char_set { Standard => STANDARD_CHARS, UrlSafe => URLSAFE_CHARS }; let len = self.len(); let newline = match config.newline { Newline::LF => "\n", Newline::CRLF => "\r\n", }; // Preallocate memory. let mut prealloc_len = (len + 2) / 3 * 4; if let Some(line_length) = config.line_length { let num_lines = (prealloc_len - 1) / line_length; prealloc_len += num_lines * newline.bytes().count(); } let mut out_bytes = vec![b'='; prealloc_len]; // Deal with padding bytes let mod_len = len % 3; // Use iterators to reduce branching { let mut cur_length = 0; let mut s_in = self[..len - mod_len].iter().map(|&x| x as u32); let mut s_out = out_bytes.iter_mut(); // Convenient shorthand let enc = |val| bytes[val as usize]; let mut write = |val| *s_out.next().unwrap() = val; // Iterate though blocks of 4 while let (Some(first), Some(second), Some(third)) = (s_in.next(), s_in.next(), s_in.next()) { // Line break if needed if let Some(line_length) = config.line_length { if cur_length >= line_length { for b in newline.bytes() { write(b) }; cur_length = 0; } } let n = first << 16 | second << 8 | third; // This 24-bit number gets separated into four 6-bit numbers. write(enc((n >> 18) & 63)); write(enc((n >> 12) & 63)); write(enc((n >> 6 ) & 63)); write(enc((n >> 0 ) & 63)); cur_length += 4; } // Line break only needed if padding is required if mod_len != 0 { if let Some(line_length) = config.line_length { if cur_length >= line_length { for b in newline.bytes() { write(b) }; } } } // Heh, would be cool if we knew this was exhaustive // (the dream of bounded integer types) match mod_len { 0 => (), 1 => { let n = (self[len-1] as u32) << 16; write(enc((n >> 18) & 63)); write(enc((n >> 12) & 63)); } 2 => { let n = (self[len-2] as u32) << 16 | (self[len-1] as u32) << 8; write(enc((n >> 18) & 63)); write(enc((n >> 12) & 63)); write(enc((n >> 6 ) & 63)); } _ => panic!("Algebra is broken, please alert the math police") } } // We get padding for "free", so only have to drop it if unwanted. if !config.pad { while let Some(&b'=') = out_bytes.last() { out_bytes.pop(); } } unsafe { String::from_utf8_unchecked(out_bytes) } } } /// A trait for converting from base64 encoded values. pub trait FromBase64 { /// Converts the value of `self`, interpreted as base64 encoded data, into /// an owned vector of bytes, returning the vector. fn from_base64(&self) -> Result, FromBase64Error>; } /// Errors that can occur when decoding a base64 encoded string #[derive(Clone, Copy)] pub enum FromBase64Error { /// The input contained a character not part of the base64 format InvalidBase64Byte(u8, usize), /// The input had an invalid length InvalidBase64Length, } impl fmt::Debug for FromBase64Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { InvalidBase64Byte(ch, idx) => write!(f, "Invalid character '{}' at position {}", ch, idx), InvalidBase64Length => write!(f, "Invalid length"), } } } impl error::Error for FromBase64Error { fn description(&self) -> &str { match *self { InvalidBase64Byte(_, _) => "invalid character", InvalidBase64Length => "invalid length", } } } impl fmt::Display for FromBase64Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&self, f) } } impl FromBase64 for str { /// Convert any base64 encoded string (literal, `@`, `&`, or `~`) /// to the byte values it encodes. /// /// You can use the `String::from_utf8` function to turn a `Vec` into a /// string with characters corresponding to those values. /// /// # Example /// /// This converts a string literal to base64 and back. /// /// ```rust /// extern crate rustc_serialize; /// use rustc_serialize::base64::{ToBase64, FromBase64, STANDARD}; /// /// fn main () { /// let hello_str = b"Hello, World".to_base64(STANDARD); /// println!("base64 output: {}", hello_str); /// let res = hello_str.from_base64(); /// if res.is_ok() { /// let opt_bytes = String::from_utf8(res.unwrap()); /// if opt_bytes.is_ok() { /// println!("decoded from base64: {:?}", opt_bytes.unwrap()); /// } /// } /// } /// ``` #[inline] fn from_base64(&self) -> Result, FromBase64Error> { self.as_bytes().from_base64() } } impl FromBase64 for [u8] { fn from_base64(&self) -> Result, FromBase64Error> { let mut r = Vec::with_capacity(self.len()); let mut buf: u32 = 0; let mut modulus = 0; let mut it = self.iter(); for byte in it.by_ref() { let code = DECODE_TABLE[*byte as usize]; if code >= SPECIAL_CODES_START { match code { NEWLINE_CODE => continue, EQUALS_CODE => break, INVALID_CODE => return Err(InvalidBase64Byte( *byte, (byte as *const _ as usize) - self.as_ptr() as usize)), _ => unreachable!(), } } buf = (buf | code as u32) << 6; modulus += 1; if modulus == 4 { modulus = 0; r.push((buf >> 22) as u8); r.push((buf >> 14) as u8); r.push((buf >> 6 ) as u8); } } for byte in it { match *byte { b'=' | b'\r' | b'\n' => continue, _ => return Err(InvalidBase64Byte( *byte, (byte as *const _ as usize) - self.as_ptr() as usize)), } } match modulus { 2 => { r.push((buf >> 10) as u8); } 3 => { r.push((buf >> 16) as u8); r.push((buf >> 8 ) as u8); } 0 => (), _ => return Err(InvalidBase64Length), } Ok(r) } } /// Base64 decoding lookup table, generated using: /// ```rust /// let mut ch = 0u8; /// loop { /// let code = match ch { /// b'A'...b'Z' => ch - 0x41, /// b'a'...b'z' => ch - 0x47, /// b'0'...b'9' => ch + 0x04, /// b'+' | b'-' => 0x3E, /// b'/' | b'_' => 0x3F, /// b'=' => 0xFE, /// b'\r' | b'\n' => 0xFD, /// _ => 0xFF, /// }; /// print!("0x{:02X}, ", code); /// if ch % 16 == 15 { println!(""); } /// else if ch == 0xFF { break; } /// ch += 1; /// } /// println!(""); /// } /// ``` const DECODE_TABLE: [u8; 256] = [ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3E, 0xFF, 0x3E, 0xFF, 0x3F, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, ]; const INVALID_CODE: u8 = 0xFF; const EQUALS_CODE: u8 = 0xFE; const NEWLINE_CODE: u8 = 0xFD; const SPECIAL_CODES_START: u8 = NEWLINE_CODE; #[cfg(test)] mod tests { use base64::{Config, Newline, FromBase64, ToBase64, STANDARD, URL_SAFE}; #[test] fn test_to_base64_basic() { assert_eq!("".as_bytes().to_base64(STANDARD), ""); assert_eq!("f".as_bytes().to_base64(STANDARD), "Zg=="); assert_eq!("fo".as_bytes().to_base64(STANDARD), "Zm8="); assert_eq!("foo".as_bytes().to_base64(STANDARD), "Zm9v"); assert_eq!("foob".as_bytes().to_base64(STANDARD), "Zm9vYg=="); assert_eq!("fooba".as_bytes().to_base64(STANDARD), "Zm9vYmE="); assert_eq!("foobar".as_bytes().to_base64(STANDARD), "Zm9vYmFy"); } #[test] fn test_to_base64_crlf_line_break() { assert!(![08; 1000].to_base64(Config {line_length: None, ..STANDARD}) .contains("\r\n")); assert_eq!(b"foobar".to_base64(Config {line_length: Some(4), ..STANDARD}), "Zm9v\r\nYmFy"); } #[test] fn test_to_base64_lf_line_break() { assert!(![08; 1000].to_base64(Config {line_length: None, newline: Newline::LF, ..STANDARD}) .contains("\n")); assert_eq!(b"foobar".to_base64(Config {line_length: Some(4), newline: Newline::LF, ..STANDARD}), "Zm9v\nYmFy"); } #[test] fn test_to_base64_padding() { assert_eq!("f".as_bytes().to_base64(Config {pad: false, ..STANDARD}), "Zg"); assert_eq!("fo".as_bytes().to_base64(Config {pad: false, ..STANDARD}), "Zm8"); } #[test] fn test_to_base64_url_safe() { assert_eq!([251, 255].to_base64(URL_SAFE), "-_8"); assert_eq!([251, 255].to_base64(STANDARD), "+/8="); } #[test] fn test_from_base64_basic() { assert_eq!("".from_base64().unwrap(), b""); assert_eq!("Zg==".from_base64().unwrap(), b"f"); assert_eq!("Zm8=".from_base64().unwrap(), b"fo"); assert_eq!("Zm9v".from_base64().unwrap(), b"foo"); assert_eq!("Zm9vYg==".from_base64().unwrap(), b"foob"); assert_eq!("Zm9vYmE=".from_base64().unwrap(), b"fooba"); assert_eq!("Zm9vYmFy".from_base64().unwrap(), b"foobar"); } #[test] fn test_from_base64_bytes() { assert_eq!(b"Zm9vYmFy".from_base64().unwrap(), b"foobar"); } #[test] fn test_from_base64_newlines() { assert_eq!("Zm9v\r\nYmFy".from_base64().unwrap(), b"foobar"); assert_eq!("Zm9vYg==\r\n".from_base64().unwrap(), b"foob"); assert_eq!("Zm9v\nYmFy".from_base64().unwrap(), b"foobar"); assert_eq!("Zm9vYg==\n".from_base64().unwrap(), b"foob"); } #[test] fn test_from_base64_urlsafe() { assert_eq!("-_8".from_base64().unwrap(), "+/8=".from_base64().unwrap()); } #[test] fn test_from_base64_invalid_char() { assert!("Zm$=".from_base64().is_err()); assert!("Zg==$".from_base64().is_err()); } #[test] fn test_from_base64_invalid_padding() { assert!("Z===".from_base64().is_err()); } #[test] fn test_base64_random() { use rand::{thread_rng, Rng}; for _ in 0..1000 { let times = thread_rng().gen_range(1, 100); let v = thread_rng().gen_iter::().take(times) .collect::>(); assert_eq!(v.to_base64(STANDARD) .from_base64() .unwrap(), v); } } } deps/rustc-serialize-0.3.16/src/collection_impls.rs0000664000175000017500000001301112475675333017312 0ustar // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Implementations of serialization for structures found in libcollections use std::hash::Hash; use {Decodable, Encodable, Decoder, Encoder}; use std::collections::{LinkedList, VecDeque, BTreeMap, BTreeSet, HashMap, HashSet}; impl< T: Encodable > Encodable for LinkedList { fn encode(&self, s: &mut S) -> Result<(), S::Error> { s.emit_seq(self.len(), |s| { for (i, e) in self.iter().enumerate() { try!(s.emit_seq_elt(i, |s| e.encode(s))); } Ok(()) }) } } impl Decodable for LinkedList { fn decode(d: &mut D) -> Result, D::Error> { d.read_seq(|d, len| { let mut list = LinkedList::new(); for i in 0..len { list.push_back(try!(d.read_seq_elt(i, |d| Decodable::decode(d)))); } Ok(list) }) } } impl Encodable for VecDeque { fn encode(&self, s: &mut S) -> Result<(), S::Error> { s.emit_seq(self.len(), |s| { for (i, e) in self.iter().enumerate() { try!(s.emit_seq_elt(i, |s| e.encode(s))); } Ok(()) }) } } impl Decodable for VecDeque { fn decode(d: &mut D) -> Result, D::Error> { d.read_seq(|d, len| { let mut deque: VecDeque = VecDeque::new(); for i in 0..len { deque.push_back(try!(d.read_seq_elt(i, |d| Decodable::decode(d)))); } Ok(deque) }) } } impl< K: Encodable + PartialEq + Ord, V: Encodable + PartialEq > Encodable for BTreeMap { fn encode(&self, e: &mut S) -> Result<(), S::Error> { e.emit_map(self.len(), |e| { let mut i = 0; for (key, val) in self.iter() { try!(e.emit_map_elt_key(i, |e| key.encode(e))); try!(e.emit_map_elt_val(i, |e| val.encode(e))); i += 1; } Ok(()) }) } } impl< K: Decodable + PartialEq + Ord, V: Decodable + PartialEq > Decodable for BTreeMap { fn decode(d: &mut D) -> Result, D::Error> { d.read_map(|d, len| { let mut map = BTreeMap::new(); for i in 0..len { let key = try!(d.read_map_elt_key(i, |d| Decodable::decode(d))); let val = try!(d.read_map_elt_val(i, |d| Decodable::decode(d))); map.insert(key, val); } Ok(map) }) } } impl< T: Encodable + PartialEq + Ord > Encodable for BTreeSet { fn encode(&self, s: &mut S) -> Result<(), S::Error> { s.emit_seq(self.len(), |s| { let mut i = 0; for e in self.iter() { try!(s.emit_seq_elt(i, |s| e.encode(s))); i += 1; } Ok(()) }) } } impl< T: Decodable + PartialEq + Ord > Decodable for BTreeSet { fn decode(d: &mut D) -> Result, D::Error> { d.read_seq(|d, len| { let mut set = BTreeSet::new(); for i in 0..len { set.insert(try!(d.read_seq_elt(i, |d| Decodable::decode(d)))); } Ok(set) }) } } impl Encodable for HashMap where K: Encodable + Hash + Eq, V: Encodable, { fn encode(&self, e: &mut E) -> Result<(), E::Error> { e.emit_map(self.len(), |e| { let mut i = 0; for (key, val) in self.iter() { try!(e.emit_map_elt_key(i, |e| key.encode(e))); try!(e.emit_map_elt_val(i, |e| val.encode(e))); i += 1; } Ok(()) }) } } impl Decodable for HashMap where K: Decodable + Hash + Eq, V: Decodable, { fn decode(d: &mut D) -> Result, D::Error> { d.read_map(|d, len| { let mut map = HashMap::with_capacity(len); for i in 0..len { let key = try!(d.read_map_elt_key(i, |d| Decodable::decode(d))); let val = try!(d.read_map_elt_val(i, |d| Decodable::decode(d))); map.insert(key, val); } Ok(map) }) } } impl Encodable for HashSet where T: Encodable + Hash + Eq { fn encode(&self, s: &mut E) -> Result<(), E::Error> { s.emit_seq(self.len(), |s| { let mut i = 0; for e in self.iter() { try!(s.emit_seq_elt(i, |s| e.encode(s))); i += 1; } Ok(()) }) } } impl Decodable for HashSet where T: Decodable + Hash + Eq, { fn decode(d: &mut D) -> Result, D::Error> { d.read_seq(|d, len| { let mut set = HashSet::with_capacity(len); for i in 0..len { set.insert(try!(d.read_seq_elt(i, |d| Decodable::decode(d)))); } Ok(set) }) } } deps/rustc-serialize-0.3.16/appveyor.yml0000664000175000017500000000073612556741456015220 0ustar environment: matrix: - TARGET: x86_64-pc-windows-msvc - TARGET: i686-pc-windows-msvc - TARGET: i686-pc-windows-gnu install: - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin - SET PATH=%PATH%;C:\MinGW\bin - rustc -V - cargo -V build: false test_script: - cargo test --verbose deps/rustc-serialize-0.3.16/Cargo.toml0000664000175000017500000000110212564147241014533 0ustar [package] name = "rustc-serialize" version = "0.3.16" authors = ["The Rust Project Developers"] license = "MIT/Apache-2.0" readme = "README.md" repository = "https://github.com/rust-lang/rustc-serialize" homepage = "https://github.com/rust-lang/rustc-serialize" documentation = "http://doc.rust-lang.org/rustc-serialize" description = """ Generic serialization/deserialization support corresponding to the `derive(RustcEncodable, RustcDecodable)` mode in the compiler. Also includes support for hex, base64, and json encoding and decoding. """ [dev-dependencies] rand = "0.3" deps/rustc-serialize-0.3.16/benches/0000755000000000000000000000000012666635520016001 5ustar rootrootdeps/rustc-serialize-0.3.16/benches/json.rs0000664000175000017500000000346312526023246015541 0ustar #![feature(test)] extern crate test; extern crate rustc_serialize; use std::string; use rustc_serialize::json::{Json, Parser}; use test::Bencher; #[bench] fn bench_streaming_small(b: &mut Bencher) { b.iter( || { let mut parser = Parser::new( r#"{ "a": 1.0, "b": [ true, "foo\nbar", { "c": {"d": null} } ] }"#.chars() ); loop { match parser.next() { None => return, _ => {} } } }); } #[bench] fn bench_small(b: &mut Bencher) { b.iter( || { let _ = Json::from_str(r#"{ "a": 1.0, "b": [ true, "foo\nbar", { "c": {"d": null} } ] }"#); }); } #[bench] fn bench_decode_hex_escape(b: &mut Bencher) { let mut src = "\"".to_string(); for _ in 0..10 { src.push_str("\\uF975\\uf9bc\\uF9A0\\uF9C4\\uF975\\uf9bc\\uF9A0\\uF9C4"); } src.push_str("\""); b.iter( || { let _ = Json::from_str(&src); }); } fn big_json() -> string::String { let mut src = "[\n".to_string(); for _ in 0..500 { src.push_str(r#"{ "a": true, "b": null, "c":3.1415, "d": "Hello world", "e": \ [1,2,3]},"#); } src.push_str("{}]"); return src; } #[bench] fn bench_streaming_large(b: &mut Bencher) { let src = big_json(); b.iter( || { let mut parser = Parser::new(src.chars()); loop { match parser.next() { None => return, _ => {} } } }); } #[bench] fn bench_large(b: &mut Bencher) { let src = big_json(); b.iter( || { let _ = Json::from_str(&src); }); } deps/rustc-serialize-0.3.16/benches/hex.rs0000664000175000017500000000144012534625075015354 0ustar #![feature(test)] extern crate test; extern crate rustc_serialize; use test::Bencher; use rustc_serialize::hex::{FromHex, ToHex}; #[bench] fn bench_to_hex(b: &mut Bencher) { let s = "イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム \ ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン"; b.iter(|| { s.as_bytes().to_hex(); }); b.bytes = s.len() as u64; } #[bench] fn bench_from_hex(b: &mut Bencher) { let s = "イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム \ ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン"; let sb = s.as_bytes().to_hex(); b.iter(|| { sb.from_hex().unwrap(); }); b.bytes = sb.len() as u64; } deps/rustc-serialize-0.3.16/benches/base64.rs0000664000175000017500000000250012534623164015647 0ustar #![feature(test)] extern crate test; extern crate rustc_serialize; use rustc_serialize::base64::{FromBase64, ToBase64, STANDARD}; use test::Bencher; #[bench] fn bench_to_base64(b: &mut Bencher) { let s = "イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム \ ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン"; b.iter(|| { s.as_bytes().to_base64(STANDARD); }); b.bytes = s.len() as u64; } #[bench] fn bench_from_base64(b: &mut Bencher) { let s = "イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム \ ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン"; let sb = s.as_bytes().to_base64(STANDARD); b.iter(|| { sb.from_base64().unwrap(); }); b.bytes = sb.len() as u64; } #[bench] fn bench_to_base64_large(b: &mut Bencher) { let s: Vec<_> = (0..10000).map(|i| ((i as u32 * 12345) % 256) as u8).collect(); b.iter(|| { s.to_base64(STANDARD); }); b.bytes = s.len() as u64; } #[bench] fn bench_from_base64_large(b: &mut Bencher) { let s: Vec<_> = (0..10000).map(|i| ((i as u32 * 12345) % 256) as u8).collect(); let sb = s.to_base64(STANDARD); b.iter(|| { sb.from_base64().unwrap(); }); b.bytes = sb.len() as u64; } deps/glob-0.2.10/0000755000000000000000000000000012666635520012161 5ustar rootrootdeps/glob-0.2.10/LICENSE-APACHE0000664000000000000000000002513712375741306014114 0ustar rootroot Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/glob-0.2.10/LICENSE-MIT0000664000000000000000000000205712375741306013620 0ustar rootrootCopyright (c) 2014 The Rust Project Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/glob-0.2.10/.travis.yml0000664000000000000000000000126212455041474014270 0ustar rootrootlanguage: rust sudo: false script: - cargo build --verbose - cargo test --verbose - cargo doc after_success: | [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && echo '' > target/doc/index.html && pip install ghp-import --user $USER && $HOME/.local/bin/ghp-import -n target/doc && git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages env: global: secure: I3a1njiqfFW9TpMKB715bpq3qHmsSmue/ahYbXhYbRoskWDWk+ruSKHS/X3nvSXY2Vv9oBCFaWldQvKdPtbpLYlfnIfquvUSzGzT3BW8bOAU6EY6+MQiToDln+xlcfjlSqBF4RGyrZtmuXzC1xXPKotG6jfUT1+7iOgaXLxyaRU= notifications: email: on_success: never deps/glob-0.2.10/README.md0000664000000000000000000000062212445474165013443 0ustar rootrootglob ==== Support for matching file paths against Unix shell style patterns. [![Build Status](https://travis-ci.org/rust-lang/glob.svg?branch=master)](https://travis-ci.org/rust-lang/glob) [Documentation](http://doc.rust-lang.org/glob) ## Usage To use `glob`, add this to your `Cargo.toml`: ```toml [dependencies] glob = "*" ``` And add this to your crate root: ```rust extern crate glob; ``` deps/glob-0.2.10/.gitignore0000600000000000000000000000002412375741142014130 0ustar rootroot/target /Cargo.lock deps/glob-0.2.10/src/0000755000000000000000000000000012666635520012750 5ustar rootrootdeps/glob-0.2.10/src/lib.rs0000664000000000000000000013301412513061716014057 0ustar rootroot// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Support for matching file paths against Unix shell style patterns. //! //! The `glob` and `glob_with` functions, in concert with the `Paths` //! type, allow querying the filesystem for all files that match a particular //! pattern - just like the libc `glob` function (for an example see the `glob` //! documentation). The methods on the `Pattern` type provide functionality //! for checking if individual paths match a particular pattern - in a similar //! manner to the libc `fnmatch` function //! For consistency across platforms, and for Windows support, this module //! is implemented entirely in Rust rather than deferring to the libc //! `glob`/`fnmatch` functions. #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/glob/")] #![cfg_attr(all(test, windows), feature(std_misc))] use std::ascii::AsciiExt; use std::cell::Cell; use std::cmp; use std::fmt; use std::fs; use std::io::prelude::*; use std::io; use std::path::{self, Path, PathBuf, Component}; use std::str::FromStr; use PatternToken::{Char, AnyChar, AnySequence, AnyRecursiveSequence, AnyWithin}; use PatternToken::AnyExcept; use CharSpecifier::{SingleChar, CharRange}; use MatchResult::{Match, SubPatternDoesntMatch, EntirePatternDoesntMatch}; /// An iterator that yields `Path`s from the filesystem that match a particular /// pattern. /// /// Note that it yields `GlobResult` in order to report any `IoErrors` that may /// arise during iteration. If a directory matches but is unreadable, /// thereby preventing its contents from being checked for matches, a /// `GlobError` is returned to express this. /// /// See the `glob` function for more details. pub struct Paths { dir_patterns: Vec, require_dir: bool, options: MatchOptions, todo: Vec>, scope: Option, } /// Return an iterator that produces all the Paths that match the given pattern, /// which may be absolute or relative to the current working directory. /// /// This may return an error if the pattern is invalid. /// /// This method uses the default match options and is equivalent to calling /// `glob_with(pattern, MatchOptions::new())`. Use `glob_with` directly if you /// want to use non-default match options. /// /// When iterating, each result is a `GlobResult` which expresses the /// possibility that there was an `IoError` when attempting to read the contents /// of the matched path. In other words, each item returned by the iterator /// will either be an `Ok(Path)` if the path matched, or an `Err(GlobError)` if /// the path (partially) matched _but_ its contents could not be read in order /// to determine if its contents matched. /// /// See the `Paths` documentation for more information. /// /// # Example /// /// Consider a directory `/media/pictures` containing only the files /// `kittens.jpg`, `puppies.jpg` and `hamsters.gif`: /// /// ```rust /// use glob::glob; /// /// for entry in glob("/media/pictures/*.jpg").unwrap() { /// match entry { /// Ok(path) => println!("{:?}", path.display()), /// /// // if the path matched but was unreadable, /// // thereby preventing its contents from matching /// Err(e) => println!("{:?}", e), /// } /// } /// ``` /// /// The above code will print: /// /// ```ignore /// /media/pictures/kittens.jpg /// /media/pictures/puppies.jpg /// ``` /// /// If you want to ignore unreadable paths, you can use something like /// `filter_map`: /// /// ```rust /// use glob::glob; /// use std::result::Result; /// /// for path in glob("/media/pictures/*.jpg").unwrap().filter_map(Result::ok) { /// println!("{}", path.display()); /// } /// ``` /// pub fn glob(pattern: &str) -> Result { glob_with(pattern, &MatchOptions::new()) } /// Return an iterator that produces all the Paths that match the given pattern, /// which may be absolute or relative to the current working directory. /// /// This may return an error if the pattern is invalid. /// /// This function accepts Unix shell style patterns as described by /// `Pattern::new(..)`. The options given are passed through unchanged to /// `Pattern::matches_with(..)` with the exception that /// `require_literal_separator` is always set to `true` regardless of the value /// passed to this function. /// /// Paths are yielded in alphabetical order. pub fn glob_with(pattern: &str, options: &MatchOptions) -> Result { // make sure that the pattern is valid first, else early return with error let _compiled = try!(Pattern::new(pattern)); #[cfg(windows)] fn check_windows_verbatim(p: &Path) -> bool { use std::path::Prefix; match p.components().next() { Some(Component::Prefix(ref p)) => p.kind().is_verbatim(), _ => false } } #[cfg(not(windows))] fn check_windows_verbatim(_: &Path) -> bool { false } #[cfg(windows)] fn to_scope(p: &Path) -> PathBuf { // FIXME handle volume relative paths here p.to_path_buf() } #[cfg(not(windows))] fn to_scope(p: &Path) -> PathBuf { p.to_path_buf() } let mut components = Path::new(pattern).components().peekable(); loop { match components.peek() { Some(&Component::Prefix(..)) | Some(&Component::RootDir) => { components.next(); } _ => break, } } let rest = components.map(|s| s.as_os_str()).collect::(); let normalized_pattern = Path::new(pattern).iter().collect::(); let root_len = normalized_pattern.to_str().unwrap().len() - rest.to_str().unwrap().len(); let root = if root_len > 0 {Some(Path::new(&pattern[..root_len]))} else {None}; if root_len > 0 && check_windows_verbatim(root.unwrap()) { // FIXME: How do we want to handle verbatim paths? I'm inclined to // return nothing, since we can't very well find all UNC shares with a // 1-letter server name. return Ok(Paths { dir_patterns: Vec::new(), require_dir: false, options: options.clone(), todo: Vec::new(), scope: None, }); } let scope = root.map(to_scope).unwrap_or_else(|| PathBuf::from(".")); let mut dir_patterns = Vec::new(); let components = pattern[cmp::min(root_len, pattern.len())..] .split_terminator(path::is_separator); for component in components { let compiled = try!(Pattern::new(component)); dir_patterns.push(compiled); } if root_len == pattern.len() { dir_patterns.push(Pattern { original: "".to_string(), tokens: Vec::new(), is_recursive: false, }); } let require_dir = pattern.chars().next_back().map(path::is_separator) == Some(true); let todo = Vec::new(); Ok(Paths { dir_patterns: dir_patterns, require_dir: require_dir, options: options.clone(), todo: todo, scope: Some(scope), }) } /// A glob iteration error. /// /// This is typically returned when a particular path cannot be read /// to determine if its contents match the glob pattern. This is possible /// if the program lacks the permissions, for example. #[derive(Debug)] pub struct GlobError { path: PathBuf, error: io::Error, } impl GlobError { /// The Path that the error corresponds to. pub fn path(&self) -> &Path { &self.path } /// The error in question. pub fn error(&self) -> &io::Error { &self.error } } impl fmt::Display for GlobError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "attempting to read `{}` resulted in an error: {}", self.path.display(), self.error) } } fn is_dir(p: &Path) -> bool { fs::metadata(p).map(|m| m.is_dir()).unwrap_or(false) } /// An alias for a glob iteration result. /// /// This represents either a matched path or a glob iteration error, /// such as failing to read a particular directory's contents. pub type GlobResult = Result; impl Iterator for Paths { type Item = GlobResult; fn next(&mut self) -> Option { // the todo buffer hasn't been initialized yet, so it's done at this // point rather than in glob() so that the errors are unified that is, // failing to fill the buffer is an iteration error construction of the // iterator (i.e. glob()) only fails if it fails to compile the Pattern if let Some(scope) = self.scope.take() { if self.dir_patterns.len() > 0 { // Shouldn't happen, but we're using -1 as a special index. assert!(self.dir_patterns.len() < !0 as usize); fill_todo(&mut self.todo, &self.dir_patterns, 0, &scope, &self.options); } } loop { if self.dir_patterns.is_empty() || self.todo.is_empty() { return None; } let (path, mut idx) = match self.todo.pop().unwrap() { Ok(pair) => pair, Err(e) => return Some(Err(e)), }; // idx -1: was already checked by fill_todo, maybe path was '.' or // '..' that we can't match here because of normalization. if idx == !0 as usize { if self.require_dir && !is_dir(&path) { continue; } return Some(Ok(path)); } if self.dir_patterns[idx].is_recursive { let mut next = idx; // collapse consecutive recursive patterns while (next + 1) < self.dir_patterns.len() && self.dir_patterns[next + 1].is_recursive { next += 1; } // the path is a directory, so it's a match if is_dir(&path) { // push this directory's contents fill_todo(&mut self.todo, &self.dir_patterns, next, &path, &self.options); // pattern ends in recursive pattern, so return this // directory as a result if next == self.dir_patterns.len() - 1 { return Some(Ok(path)); // advanced to the next pattern for this path } else { idx = next + 1; } // advanced to the next pattern for this path } else if next != self.dir_patterns.len() - 1 { idx = next + 1; // not a directory and it's the last pattern, meaning no match } else { continue; } } // not recursive, so match normally if self.dir_patterns[idx].matches_with({ match path.file_name().and_then(|s| s.to_str()) { // FIXME (#9639): How do we handle non-utf8 filenames? // Ignore them for now Ideally we'd still match them // against a * None => continue, Some(x) => x } }, &self.options) { if idx == self.dir_patterns.len() - 1 { // it is not possible for a pattern to match a directory // *AND* its children so we don't need to check the // children if !self.require_dir || is_dir(&path) { return Some(Ok(path)); } } else { fill_todo(&mut self.todo, &self.dir_patterns, idx + 1, &path, &self.options); } } } } } /// A pattern parsing error. #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct PatternError { /// The approximate character index of where the error occurred. pub pos: usize, /// A message describing the error. pub msg: &'static str, } impl fmt::Display for PatternError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Pattern syntax error near position {}: {}", self.pos, self.msg) } } /// A compiled Unix shell style pattern. /// /// `?` matches any single character /// /// `*` matches any (possibly empty) sequence of characters /// /// `**` matches the current directory and arbitrary subdirectories. This /// sequence **must** form a single path component, so both `**a` and `b**` are /// invalid and will result in an error. A sequence of more than two /// consecutive `*` characters is also invalid. /// /// `[...]` matches any character inside the brackets. /// Character sequences can also specify ranges /// of characters, as ordered by Unicode, so e.g. `[0-9]` specifies any /// character between 0 and 9 inclusive. An unclosed bracket is invalid. /// /// `[!...]` is the negation of `[...]`, i.e. it matches any characters **not** /// in the brackets. /// /// The metacharacters `?`, `*`, `[`, `]` can be matched by using brackets /// (e.g. `[?]`). When a `]` occurs immediately following `[` or `[!` then /// it is interpreted as being part of, rather then ending, the character /// set, so `]` and NOT `]` can be matched by `[]]` and `[!]]` respectively. /// The `-` character can be specified inside a character sequence pattern by /// placing it at the start or the end, e.g. `[abc-]`. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug)] pub struct Pattern { original: String, tokens: Vec, is_recursive: bool, } /// Show the original glob pattern. impl fmt::Display for Pattern { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.original.fmt(f) } } impl FromStr for Pattern { type Err = PatternError; fn from_str(s: &str) -> Result { Pattern::new(s) } } #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] enum PatternToken { Char(char), AnyChar, AnySequence, AnyRecursiveSequence, AnyWithin(Vec ), AnyExcept(Vec ) } #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] enum CharSpecifier { SingleChar(char), CharRange(char, char) } #[derive(Copy, Clone, PartialEq)] enum MatchResult { Match, SubPatternDoesntMatch, EntirePatternDoesntMatch } const ERROR_WILDCARDS: &'static str = "wildcards are either regular `*` or recursive `**`"; const ERROR_RECURSIVE_WILDCARDS: &'static str = "recursive wildcards must form a single path component"; const ERROR_INVALID_RANGE: &'static str = "invalid range pattern"; impl Pattern { /// This function compiles Unix shell style patterns. /// /// An invalid glob pattern will yield an error. pub fn new(pattern: &str) -> Result { let chars = pattern.chars().collect::>(); let mut tokens = Vec::new(); let mut is_recursive = false; let mut i = 0; while i < chars.len() { match chars[i] { '?' => { tokens.push(AnyChar); i += 1; } '*' => { let old = i; while i < chars.len() && chars[i] == '*' { i += 1; } let count = i - old; if count > 2 { return Err( PatternError { pos: old + 2, msg: ERROR_WILDCARDS, }); } else if count == 2 { // ** can only be an entire path component // i.e. a/**/b is valid, but a**/b or a/**b is not // invalid matches are treated literally let is_valid = // is the beginning of the pattern or begins with '/' if i == 2 || chars[i - count - 1] == '/' { // it ends in a '/' if i < chars.len() && chars[i] == '/' { i += 1; true // or the pattern ends here // this enables the existing globbing mechanism } else if i == chars.len() { true // `**` ends in non-separator } else { return Err( PatternError { pos: i, msg: ERROR_RECURSIVE_WILDCARDS, }); } // `**` begins with non-separator } else { return Err( PatternError { pos: old - 1, msg: ERROR_RECURSIVE_WILDCARDS, }); }; let tokens_len = tokens.len(); if is_valid { // collapse consecutive AnyRecursiveSequence to a // single one if !(tokens_len > 1 && tokens[tokens_len - 1] == AnyRecursiveSequence) { is_recursive = true; tokens.push(AnyRecursiveSequence); } } } else { tokens.push(AnySequence); } } '[' => { if i + 4 <= chars.len() && chars[i + 1] == '!' { match chars[i + 3..].iter().position(|x| *x == ']') { None => (), Some(j) => { let chars = &chars[i + 2 .. i + 3 + j]; let cs = parse_char_specifiers(chars); tokens.push(AnyExcept(cs)); i += j + 4; continue; } } } else if i + 3 <= chars.len() && chars[i + 1] != '!' { match chars[i + 2..].iter().position(|x| *x == ']') { None => (), Some(j) => { let cs = parse_char_specifiers(&chars[i + 1 .. i + 2 + j]); tokens.push(AnyWithin(cs)); i += j + 3; continue; } } } // if we get here then this is not a valid range pattern return Err( PatternError { pos: i, msg: ERROR_INVALID_RANGE, }); } c => { tokens.push(Char(c)); i += 1; } } } Ok(Pattern { tokens: tokens, original: pattern.to_string(), is_recursive: is_recursive, }) } /// Escape metacharacters within the given string by surrounding them in /// brackets. The resulting string will, when compiled into a `Pattern`, /// match the input string and nothing else. pub fn escape(s: &str) -> String { let mut escaped = String::new(); for c in s.chars() { match c { // note that ! does not need escaping because it is only special // inside brackets '?' | '*' | '[' | ']' => { escaped.push('['); escaped.push(c); escaped.push(']'); } c => { escaped.push(c); } } } escaped } /// Return if the given `str` matches this `Pattern` using the default /// match options (i.e. `MatchOptions::new()`). /// /// # Example /// /// ```rust /// use glob::Pattern; /// /// assert!(Pattern::new("c?t").unwrap().matches("cat")); /// assert!(Pattern::new("k[!e]tteh").unwrap().matches("kitteh")); /// assert!(Pattern::new("d*g").unwrap().matches("doog")); /// ``` pub fn matches(&self, str: &str) -> bool { self.matches_with(str, &MatchOptions::new()) } /// Return if the given `Path`, when converted to a `str`, matches this /// `Pattern` using the default match options (i.e. `MatchOptions::new()`). pub fn matches_path(&self, path: &Path) -> bool { // FIXME (#9639): This needs to handle non-utf8 paths path.to_str().map_or(false, |s| { self.matches(s) }) } /// Return if the given `str` matches this `Pattern` using the specified /// match options. pub fn matches_with(&self, str: &str, options: &MatchOptions) -> bool { self.matches_from(None, str, 0, options) == Match } /// Return if the given `Path`, when converted to a `str`, matches this /// `Pattern` using the specified match options. pub fn matches_path_with(&self, path: &Path, options: &MatchOptions) -> bool { // FIXME (#9639): This needs to handle non-utf8 paths path.to_str().map_or(false, |s| { self.matches_with(s, options) }) } /// Access the original glob pattern. pub fn as_str<'a>(&'a self) -> &'a str { &self.original } fn matches_from(&self, prev_char: Option, mut file: &str, i: usize, options: &MatchOptions) -> MatchResult { let prev_char = Cell::new(prev_char); let require_literal = |c| { (options.require_literal_separator && path::is_separator(c)) || (options.require_literal_leading_dot && c == '.' && path::is_separator(prev_char.get().unwrap_or('/'))) }; for (ti, token) in self.tokens[i..].iter().enumerate() { match *token { AnySequence | AnyRecursiveSequence => { loop { match self.matches_from(prev_char.get(), file, i + ti + 1, options) { SubPatternDoesntMatch => (), // keep trying m => return m, } if file.len() == 0 { return EntirePatternDoesntMatch } let c = file.chars().next().unwrap(); let next = &file[c.len_utf8()..]; if let AnySequence = *token { if require_literal(c) { return SubPatternDoesntMatch; } } prev_char.set(Some(c)); file = next; } } _ => { if file.len() == 0 { return EntirePatternDoesntMatch } let c = file.chars().next().unwrap(); let next = &file[c.len_utf8()..]; let matches = match *token { AnyChar => { !require_literal(c) } AnyWithin(ref specifiers) => { !require_literal(c) && in_char_specifiers(&specifiers, c, options) } AnyExcept(ref specifiers) => { !require_literal(c) && !in_char_specifiers(&specifiers, c, options) } Char(c2) => { chars_eq(c, c2, options.case_sensitive) } AnySequence | AnyRecursiveSequence => { unreachable!() } }; if !matches { return SubPatternDoesntMatch; } prev_char.set(Some(c)); file = next; } } } if file.is_empty() { Match } else { SubPatternDoesntMatch } } } // Fills `todo` with paths under `path` to be matched by `patterns[idx]`, // special-casing patterns to match `.` and `..`, and avoiding `readdir()` // calls when there are no metacharacters in the pattern. fn fill_todo(todo: &mut Vec>, patterns: &[Pattern], idx: usize, path: &Path, options: &MatchOptions) { // convert a pattern that's just many Char(_) to a string fn pattern_as_str(pattern: &Pattern) -> Option { let mut s = String::new(); for token in pattern.tokens.iter() { match *token { Char(c) => s.push(c), _ => return None } } return Some(s); } let add = |todo: &mut Vec<_>, next_path: PathBuf| { if idx + 1 == patterns.len() { // We know it's good, so don't make the iterator match this path // against the pattern again. In particular, it can't match // . or .. globs since these never show up as path components. todo.push(Ok((next_path, !0 as usize))); } else { fill_todo(todo, patterns, idx + 1, &next_path, options); } }; let pattern = &patterns[idx]; let is_dir = is_dir(path); let curdir = path == Path::new("."); match pattern_as_str(pattern) { Some(s) => { // This pattern component doesn't have any metacharacters, so we // don't need to read the current directory to know where to // continue. So instead of passing control back to the iterator, // we can just check for that one entry and potentially recurse // right away. let special = "." == s || ".." == s; let next_path = if curdir {PathBuf::from(s)} else {path.join(&s)}; if (special && is_dir) || (!special && fs::metadata(&next_path).is_ok()) { add(todo, next_path); } }, None if is_dir => { let dirs = fs::read_dir(path).and_then(|d| { d.map(|e| e.map(|e| { if curdir { PathBuf::from(e.path().file_name().unwrap()) } else { e.path() } })).collect::, _>>() }); match dirs { Ok(mut children) => { children.sort_by(|p1, p2| p2.file_name().cmp(&p1.file_name())); todo.extend(children.into_iter().map(|x| Ok((x, idx)))); // Matching the special directory entries . and .. that // refer to the current and parent directory respectively // requires that the pattern has a leading dot, even if the // `MatchOptions` field `require_literal_leading_dot` is not // set. if pattern.tokens.len() > 0 && pattern.tokens[0] == Char('.') { for &special in [".", ".."].iter() { if pattern.matches_with(special, options) { add(todo, path.join(special)); } } } }, Err(e) => { todo.push(Err(GlobError { path: path.to_path_buf(), error: e, })); } } } None => {/* not a directory, nothing more to find */} } } fn parse_char_specifiers(s: &[char]) -> Vec { let mut cs = Vec::new(); let mut i = 0; while i < s.len() { if i + 3 <= s.len() && s[i + 1] == '-' { cs.push(CharRange(s[i], s[i + 2])); i += 3; } else { cs.push(SingleChar(s[i])); i += 1; } } cs } fn in_char_specifiers(specifiers: &[CharSpecifier], c: char, options: &MatchOptions) -> bool { for &specifier in specifiers.iter() { match specifier { SingleChar(sc) => { if chars_eq(c, sc, options.case_sensitive) { return true; } } CharRange(start, end) => { // FIXME: work with non-ascii chars properly (issue #1347) if !options.case_sensitive && c.is_ascii() && start.is_ascii() && end.is_ascii() { let start = start.to_ascii_lowercase(); let end = end.to_ascii_lowercase(); let start_up = start.to_uppercase().next().unwrap(); let end_up = end.to_uppercase().next().unwrap(); // only allow case insensitive matching when // both start and end are within a-z or A-Z if start != start_up && end != end_up { let c = c.to_ascii_lowercase(); if c >= start && c <= end { return true; } } } if c >= start && c <= end { return true; } } } } false } /// A helper function to determine if two chars are (possibly case-insensitively) equal. fn chars_eq(a: char, b: char, case_sensitive: bool) -> bool { if cfg!(windows) && path::is_separator(a) && path::is_separator(b) { true } else if !case_sensitive && a.is_ascii() && b.is_ascii() { // FIXME: work with non-ascii chars properly (issue #9084) a.to_ascii_lowercase() == b.to_ascii_lowercase() } else { a == b } } /// Configuration options to modify the behaviour of `Pattern::matches_with(..)` #[allow(missing_copy_implementations)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] pub struct MatchOptions { /// Whether or not patterns should be matched in a case-sensitive manner. /// This currently only considers upper/lower case relationships between /// ASCII characters, but in future this might be extended to work with /// Unicode. pub case_sensitive: bool, /// If this is true then path-component separator characters (e.g. `/` on /// Posix) must be matched by a literal `/`, rather than by `*` or `?` or /// `[...]` pub require_literal_separator: bool, /// If this is true then paths that contain components that start with a `.` /// will not match unless the `.` appears literally in the pattern: `*`, `?` /// or `[...]` will not match. This is useful because such files are /// conventionally considered hidden on Unix systems and it might be /// desirable to skip them when listing files. pub require_literal_leading_dot: bool } impl MatchOptions { /// Constructs a new `MatchOptions` with default field values. This is used /// when calling functions that do not take an explicit `MatchOptions` /// parameter. /// /// This function always returns this value: /// /// ```rust,ignore /// MatchOptions { /// case_sensitive: true, /// require_literal_separator: false. /// require_literal_leading_dot: false /// } /// ``` pub fn new() -> MatchOptions { MatchOptions { case_sensitive: true, require_literal_separator: false, require_literal_leading_dot: false } } } #[cfg(test)] mod test { use std::path::Path; use super::{glob, Pattern, MatchOptions}; #[test] fn test_pattern_from_str() { assert!("a*b".parse::().unwrap().matches("a_b")); assert!("a/**b".parse::().unwrap_err().pos == 4); } #[test] fn test_wildcard_errors() { assert!(Pattern::new("a/**b").unwrap_err().pos == 4); assert!(Pattern::new("a/bc**").unwrap_err().pos == 3); assert!(Pattern::new("a/*****").unwrap_err().pos == 4); assert!(Pattern::new("a/b**c**d").unwrap_err().pos == 2); assert!(Pattern::new("a**b").unwrap_err().pos == 0); } #[test] fn test_unclosed_bracket_errors() { assert!(Pattern::new("abc[def").unwrap_err().pos == 3); assert!(Pattern::new("abc[!def").unwrap_err().pos == 3 ); assert!(Pattern::new("abc[").unwrap_err().pos == 3); assert!(Pattern::new("abc[!").unwrap_err().pos == 3); assert!(Pattern::new("abc[d").unwrap_err().pos == 3); assert!(Pattern::new("abc[!d").unwrap_err().pos == 3); assert!(Pattern::new("abc[]").unwrap_err().pos == 3); assert!(Pattern::new("abc[!]").unwrap_err().pos == 3); } #[test] fn test_glob_errors() { assert!(glob("a/**b").err().unwrap().pos == 4); assert!(glob("abc[def").err().unwrap().pos == 3); } // this test assumes that there is a /root directory and that // the user running this test is not root or otherwise doesn't // have permission to read its contents #[cfg(unix)] #[test] fn test_iteration_errors() { use std::io; let mut iter = glob("/root/*").unwrap(); // GlobErrors shouldn't halt iteration let next = iter.next(); assert!(next.is_some()); let err = next.unwrap(); assert!(err.is_err()); let err = err.err().unwrap(); assert!(err.path() == Path::new("/root")); assert!(err.error().kind() == io::ErrorKind::PermissionDenied); } #[test] fn test_absolute_pattern() { assert!(glob("/").unwrap().next().is_some()); assert!(glob("//").unwrap().next().is_some()); // assume that the filesystem is not empty! assert!(glob("/*").unwrap().next().is_some()); #[cfg(not(windows))] fn win() {} #[cfg(windows)] fn win() { use std::env::current_dir; use std::ffi::AsOsStr; // check windows absolute paths with host/device components let root_with_device = current_dir().ok().and_then(|p| p.prefix().map(|p| p.join("*"))).unwrap(); // FIXME (#9639): This needs to handle non-utf8 paths assert!(glob(root_with_device.as_os_str().to_str().unwrap()).unwrap().next().is_some()); } win() } #[test] fn test_wildcards() { assert!(Pattern::new("a*b").unwrap().matches("a_b")); assert!(Pattern::new("a*b*c").unwrap().matches("abc")); assert!(!Pattern::new("a*b*c").unwrap().matches("abcd")); assert!(Pattern::new("a*b*c").unwrap().matches("a_b_c")); assert!(Pattern::new("a*b*c").unwrap().matches("a___b___c")); assert!(Pattern::new("abc*abc*abc").unwrap().matches("abcabcabcabcabcabcabc")); assert!(!Pattern::new("abc*abc*abc").unwrap().matches("abcabcabcabcabcabcabca")); assert!(Pattern::new("a*a*a*a*a*a*a*a*a").unwrap().matches("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); assert!(Pattern::new("a*b[xyz]c*d").unwrap().matches("abxcdbxcddd")); } #[test] fn test_recursive_wildcards() { let pat = Pattern::new("some/**/needle.txt").unwrap(); assert!(pat.matches("some/needle.txt")); assert!(pat.matches("some/one/needle.txt")); assert!(pat.matches("some/one/two/needle.txt")); assert!(pat.matches("some/other/needle.txt")); assert!(!pat.matches("some/other/notthis.txt")); // a single ** should be valid, for globs assert!(Pattern::new("**").unwrap().is_recursive); // collapse consecutive wildcards let pat = Pattern::new("some/**/**/needle.txt").unwrap(); assert!(pat.matches("some/needle.txt")); assert!(pat.matches("some/one/needle.txt")); assert!(pat.matches("some/one/two/needle.txt")); assert!(pat.matches("some/other/needle.txt")); assert!(!pat.matches("some/other/notthis.txt")); // ** can begin the pattern let pat = Pattern::new("**/test").unwrap(); assert!(pat.matches("one/two/test")); assert!(pat.matches("one/test")); assert!(pat.matches("test")); // /** can begin the pattern let pat = Pattern::new("/**/test").unwrap(); assert!(pat.matches("/one/two/test")); assert!(pat.matches("/one/test")); assert!(pat.matches("/test")); assert!(!pat.matches("/one/notthis")); assert!(!pat.matches("/notthis")); } #[test] fn test_lots_of_files() { // this is a good test because it touches lots of differently named files glob("/*/*/*/*").unwrap().skip(10000).next(); } #[test] fn test_range_pattern() { let pat = Pattern::new("a[0-9]b").unwrap(); for i in 0..10 { assert!(pat.matches(&format!("a{}b", i))); } assert!(!pat.matches("a_b")); let pat = Pattern::new("a[!0-9]b").unwrap(); for i in 0..10 { assert!(!pat.matches(&format!("a{}b", i))); } assert!(pat.matches("a_b")); let pats = ["[a-z123]", "[1a-z23]", "[123a-z]"]; for &p in pats.iter() { let pat = Pattern::new(p).unwrap(); for c in "abcdefghijklmnopqrstuvwxyz".chars() { assert!(pat.matches(&c.to_string())); } for c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars() { let options = MatchOptions {case_sensitive: false, .. MatchOptions::new()}; assert!(pat.matches_with(&c.to_string(), &options)); } assert!(pat.matches("1")); assert!(pat.matches("2")); assert!(pat.matches("3")); } let pats = ["[abc-]", "[-abc]", "[a-c-]"]; for &p in pats.iter() { let pat = Pattern::new(p).unwrap(); assert!(pat.matches("a")); assert!(pat.matches("b")); assert!(pat.matches("c")); assert!(pat.matches("-")); assert!(!pat.matches("d")); } let pat = Pattern::new("[2-1]").unwrap(); assert!(!pat.matches("1")); assert!(!pat.matches("2")); assert!(Pattern::new("[-]").unwrap().matches("-")); assert!(!Pattern::new("[!-]").unwrap().matches("-")); } #[test] fn test_pattern_matches() { let txt_pat = Pattern::new("*hello.txt").unwrap(); assert!(txt_pat.matches("hello.txt")); assert!(txt_pat.matches("gareth_says_hello.txt")); assert!(txt_pat.matches("some/path/to/hello.txt")); assert!(txt_pat.matches("some\\path\\to\\hello.txt")); assert!(txt_pat.matches("/an/absolute/path/to/hello.txt")); assert!(!txt_pat.matches("hello.txt-and-then-some")); assert!(!txt_pat.matches("goodbye.txt")); let dir_pat = Pattern::new("*some/path/to/hello.txt").unwrap(); assert!(dir_pat.matches("some/path/to/hello.txt")); assert!(dir_pat.matches("a/bigger/some/path/to/hello.txt")); assert!(!dir_pat.matches("some/path/to/hello.txt-and-then-some")); assert!(!dir_pat.matches("some/other/path/to/hello.txt")); } #[test] fn test_pattern_escape() { let s = "_[_]_?_*_!_"; assert_eq!(Pattern::escape(s), "_[[]_[]]_[?]_[*]_!_".to_string()); assert!(Pattern::new(&Pattern::escape(s)).unwrap().matches(s)); } #[test] fn test_pattern_matches_case_insensitive() { let pat = Pattern::new("aBcDeFg").unwrap(); let options = MatchOptions { case_sensitive: false, require_literal_separator: false, require_literal_leading_dot: false }; assert!(pat.matches_with("aBcDeFg", &options)); assert!(pat.matches_with("abcdefg", &options)); assert!(pat.matches_with("ABCDEFG", &options)); assert!(pat.matches_with("AbCdEfG", &options)); } #[test] fn test_pattern_matches_case_insensitive_range() { let pat_within = Pattern::new("[a]").unwrap(); let pat_except = Pattern::new("[!a]").unwrap(); let options_case_insensitive = MatchOptions { case_sensitive: false, require_literal_separator: false, require_literal_leading_dot: false }; let options_case_sensitive = MatchOptions { case_sensitive: true, require_literal_separator: false, require_literal_leading_dot: false }; assert!(pat_within.matches_with("a", &options_case_insensitive)); assert!(pat_within.matches_with("A", &options_case_insensitive)); assert!(!pat_within.matches_with("A", &options_case_sensitive)); assert!(!pat_except.matches_with("a", &options_case_insensitive)); assert!(!pat_except.matches_with("A", &options_case_insensitive)); assert!(pat_except.matches_with("A", &options_case_sensitive)); } #[test] fn test_pattern_matches_require_literal_separator() { let options_require_literal = MatchOptions { case_sensitive: true, require_literal_separator: true, require_literal_leading_dot: false }; let options_not_require_literal = MatchOptions { case_sensitive: true, require_literal_separator: false, require_literal_leading_dot: false }; assert!(Pattern::new("abc/def").unwrap().matches_with("abc/def", &options_require_literal)); assert!(!Pattern::new("abc?def").unwrap().matches_with("abc/def", &options_require_literal)); assert!(!Pattern::new("abc*def").unwrap().matches_with("abc/def", &options_require_literal)); assert!(!Pattern::new("abc[/]def").unwrap().matches_with("abc/def", &options_require_literal)); assert!(Pattern::new("abc/def").unwrap().matches_with("abc/def", &options_not_require_literal)); assert!(Pattern::new("abc?def").unwrap().matches_with("abc/def", &options_not_require_literal)); assert!(Pattern::new("abc*def").unwrap().matches_with("abc/def", &options_not_require_literal)); assert!(Pattern::new("abc[/]def").unwrap().matches_with("abc/def", &options_not_require_literal)); } #[test] fn test_pattern_matches_require_literal_leading_dot() { let options_require_literal_leading_dot = MatchOptions { case_sensitive: true, require_literal_separator: false, require_literal_leading_dot: true }; let options_not_require_literal_leading_dot = MatchOptions { case_sensitive: true, require_literal_separator: false, require_literal_leading_dot: false }; let f = |options| Pattern::new("*.txt").unwrap().matches_with(".hello.txt", options); assert!(f(&options_not_require_literal_leading_dot)); assert!(!f(&options_require_literal_leading_dot)); let f = |options| Pattern::new(".*.*").unwrap().matches_with(".hello.txt", options); assert!(f(&options_not_require_literal_leading_dot)); assert!(f(&options_require_literal_leading_dot)); let f = |options| Pattern::new("aaa/bbb/*").unwrap().matches_with("aaa/bbb/.ccc", options); assert!(f(&options_not_require_literal_leading_dot)); assert!(!f(&options_require_literal_leading_dot)); let f = |options| Pattern::new("aaa/bbb/*").unwrap().matches_with("aaa/bbb/c.c.c.", options); assert!(f(&options_not_require_literal_leading_dot)); assert!(f(&options_require_literal_leading_dot)); let f = |options| Pattern::new("aaa/bbb/.*").unwrap().matches_with("aaa/bbb/.ccc", options); assert!(f(&options_not_require_literal_leading_dot)); assert!(f(&options_require_literal_leading_dot)); let f = |options| Pattern::new("aaa/?bbb").unwrap().matches_with("aaa/.bbb", options); assert!(f(&options_not_require_literal_leading_dot)); assert!(!f(&options_require_literal_leading_dot)); let f = |options| Pattern::new("aaa/[.]bbb").unwrap().matches_with("aaa/.bbb", options); assert!(f(&options_not_require_literal_leading_dot)); assert!(!f(&options_require_literal_leading_dot)); } #[test] fn test_matches_path() { // on windows, (Path::new("a/b").as_str().unwrap() == "a\\b"), so this // tests that / and \ are considered equivalent on windows assert!(Pattern::new("a/b").unwrap().matches_path(&Path::new("a/b"))); } } deps/glob-0.2.10/tests/0000755000000000000000000000000012666635520013323 5ustar rootrootdeps/glob-0.2.10/tests/glob-std.rs0000664000000000000000000002363512507266213015410 0ustar rootroot// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // ignore-windows TempDir may cause IoError on windows: #10462 #![cfg_attr(test, deny(warnings))] extern crate glob; extern crate tempdir; use glob::glob; use std::env; use std::path::PathBuf; use std::fs; use tempdir::TempDir; #[test] fn main() { fn mk_file(path: &str, directory: bool) { if directory { fs::create_dir(path).unwrap(); } else { fs::File::create(path).unwrap(); } } fn glob_vec(pattern: &str) -> Vec { glob(pattern).unwrap().map(|r| r.unwrap()).collect() } let root = TempDir::new("glob-tests"); let root = root.ok().expect("Should have created a temp directory"); assert!(env::set_current_dir(root.path()).is_ok()); mk_file("aaa", true); mk_file("aaa/apple", true); mk_file("aaa/orange", true); mk_file("aaa/tomato", true); mk_file("aaa/tomato/tomato.txt", false); mk_file("aaa/tomato/tomoto.txt", false); mk_file("bbb", true); mk_file("bbb/specials", true); mk_file("bbb/specials/!", false); // windows does not allow `*` or `?` characters to exist in filenames if env::consts::FAMILY != "windows" { mk_file("bbb/specials/*", false); mk_file("bbb/specials/?", false); } mk_file("bbb/specials/[", false); mk_file("bbb/specials/]", false); mk_file("ccc", true); mk_file("xyz", true); mk_file("xyz/x", false); mk_file("xyz/y", false); mk_file("xyz/z", false); mk_file("r", true); mk_file("r/current_dir.md", false); mk_file("r/one", true); mk_file("r/one/a.md", false); mk_file("r/one/another", true); mk_file("r/one/another/a.md", false); mk_file("r/one/another/deep", true); mk_file("r/one/another/deep/spelunking.md", false); mk_file("r/another", true); mk_file("r/another/a.md", false); mk_file("r/two", true); mk_file("r/two/b.md", false); mk_file("r/three", true); mk_file("r/three/c.md", false); // all recursive entities assert_eq!(glob_vec("r/**"), vec!( PathBuf::from("r/another"), PathBuf::from("r/one"), PathBuf::from("r/one/another"), PathBuf::from("r/one/another/deep"), PathBuf::from("r/three"), PathBuf::from("r/two"))); // collapse consecutive recursive patterns assert_eq!(glob_vec("r/**/**"), vec!( PathBuf::from("r/another"), PathBuf::from("r/one"), PathBuf::from("r/one/another"), PathBuf::from("r/one/another/deep"), PathBuf::from("r/three"), PathBuf::from("r/two"))); assert_eq!(glob_vec("r/**/*"), vec!( PathBuf::from("r/another"), PathBuf::from("r/another/a.md"), PathBuf::from("r/current_dir.md"), PathBuf::from("r/one"), PathBuf::from("r/one/a.md"), PathBuf::from("r/one/another"), PathBuf::from("r/one/another/a.md"), PathBuf::from("r/one/another/deep"), PathBuf::from("r/one/another/deep/spelunking.md"), PathBuf::from("r/three"), PathBuf::from("r/three/c.md"), PathBuf::from("r/two"), PathBuf::from("r/two/b.md"))); // followed by a wildcard assert_eq!(glob_vec("r/**/*.md"), vec!( PathBuf::from("r/another/a.md"), PathBuf::from("r/current_dir.md"), PathBuf::from("r/one/a.md"), PathBuf::from("r/one/another/a.md"), PathBuf::from("r/one/another/deep/spelunking.md"), PathBuf::from("r/three/c.md"), PathBuf::from("r/two/b.md"))); // followed by a precise pattern assert_eq!(glob_vec("r/one/**/a.md"), vec!( PathBuf::from("r/one/a.md"), PathBuf::from("r/one/another/a.md"))); // followed by another recursive pattern // collapses consecutive recursives into one assert_eq!(glob_vec("r/one/**/**/a.md"), vec!( PathBuf::from("r/one/a.md"), PathBuf::from("r/one/another/a.md"))); // followed by two precise patterns assert_eq!(glob_vec("r/**/another/a.md"), vec!( PathBuf::from("r/another/a.md"), PathBuf::from("r/one/another/a.md"))); assert_eq!(glob_vec(""), Vec::new()); assert_eq!(glob_vec("."), vec!(PathBuf::from("."))); assert_eq!(glob_vec(".."), vec!(PathBuf::from(".."))); assert_eq!(glob_vec("aaa"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("aaa/"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("a"), Vec::new()); assert_eq!(glob_vec("aa"), Vec::new()); assert_eq!(glob_vec("aaaa"), Vec::new()); assert_eq!(glob_vec("aaa/apple"), vec!(PathBuf::from("aaa/apple"))); assert_eq!(glob_vec("aaa/apple/nope"), Vec::new()); // windows should support both / and \ as directory separators if env::consts::FAMILY == "windows" { assert_eq!(glob_vec("aaa\\apple"), vec!(PathBuf::from("aaa/apple"))); } assert_eq!(glob_vec("???/"), vec!( PathBuf::from("aaa"), PathBuf::from("bbb"), PathBuf::from("ccc"), PathBuf::from("xyz"))); assert_eq!(glob_vec("aaa/tomato/tom?to.txt"), vec!( PathBuf::from("aaa/tomato/tomato.txt"), PathBuf::from("aaa/tomato/tomoto.txt"))); assert_eq!(glob_vec("xyz/?"), vec!( PathBuf::from("xyz/x"), PathBuf::from("xyz/y"), PathBuf::from("xyz/z"))); assert_eq!(glob_vec("a*"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("*a*"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("a*a"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("aaa*"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("*aaa"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("*aaa*"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("*a*a*a*"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("aaa*/"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("aaa/*"), vec!( PathBuf::from("aaa/apple"), PathBuf::from("aaa/orange"), PathBuf::from("aaa/tomato"))); assert_eq!(glob_vec("aaa/*a*"), vec!( PathBuf::from("aaa/apple"), PathBuf::from("aaa/orange"), PathBuf::from("aaa/tomato"))); assert_eq!(glob_vec("*/*/*.txt"), vec!( PathBuf::from("aaa/tomato/tomato.txt"), PathBuf::from("aaa/tomato/tomoto.txt"))); assert_eq!(glob_vec("*/*/t[aob]m?to[.]t[!y]t"), vec!( PathBuf::from("aaa/tomato/tomato.txt"), PathBuf::from("aaa/tomato/tomoto.txt"))); assert_eq!(glob_vec("./aaa"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("./*"), glob_vec("*")); assert_eq!(glob_vec("*/..").pop().unwrap(), PathBuf::from("xyz/..")); assert_eq!(glob_vec("aaa/../bbb"), vec!(PathBuf::from("aaa/../bbb"))); assert_eq!(glob_vec("nonexistent/../bbb"), Vec::new()); assert_eq!(glob_vec("aaa/tomato/tomato.txt/.."), Vec::new()); assert_eq!(glob_vec("aaa/tomato/tomato.txt/"), Vec::new()); assert_eq!(glob_vec("aa[a]"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("aa[abc]"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("a[bca]a"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("aa[b]"), Vec::new()); assert_eq!(glob_vec("aa[xyz]"), Vec::new()); assert_eq!(glob_vec("aa[]]"), Vec::new()); assert_eq!(glob_vec("aa[!b]"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("aa[!bcd]"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("a[!bcd]a"), vec!(PathBuf::from("aaa"))); assert_eq!(glob_vec("aa[!a]"), Vec::new()); assert_eq!(glob_vec("aa[!abc]"), Vec::new()); assert_eq!(glob_vec("bbb/specials/[[]"), vec!(PathBuf::from("bbb/specials/["))); assert_eq!(glob_vec("bbb/specials/!"), vec!(PathBuf::from("bbb/specials/!"))); assert_eq!(glob_vec("bbb/specials/[]]"), vec!(PathBuf::from("bbb/specials/]"))); if env::consts::FAMILY != "windows" { assert_eq!(glob_vec("bbb/specials/[*]"), vec!(PathBuf::from("bbb/specials/*"))); assert_eq!(glob_vec("bbb/specials/[?]"), vec!(PathBuf::from("bbb/specials/?"))); } if env::consts::FAMILY == "windows" { assert_eq!(glob_vec("bbb/specials/[![]"), vec!( PathBuf::from("bbb/specials/!"), PathBuf::from("bbb/specials/]"))); assert_eq!(glob_vec("bbb/specials/[!]]"), vec!( PathBuf::from("bbb/specials/!"), PathBuf::from("bbb/specials/["))); assert_eq!(glob_vec("bbb/specials/[!!]"), vec!( PathBuf::from("bbb/specials/["), PathBuf::from("bbb/specials/]"))); } else { assert_eq!(glob_vec("bbb/specials/[![]"), vec!( PathBuf::from("bbb/specials/!"), PathBuf::from("bbb/specials/*"), PathBuf::from("bbb/specials/?"), PathBuf::from("bbb/specials/]"))); assert_eq!(glob_vec("bbb/specials/[!]]"), vec!( PathBuf::from("bbb/specials/!"), PathBuf::from("bbb/specials/*"), PathBuf::from("bbb/specials/?"), PathBuf::from("bbb/specials/["))); assert_eq!(glob_vec("bbb/specials/[!!]"), vec!( PathBuf::from("bbb/specials/*"), PathBuf::from("bbb/specials/?"), PathBuf::from("bbb/specials/["), PathBuf::from("bbb/specials/]"))); assert_eq!(glob_vec("bbb/specials/[!*]"), vec!( PathBuf::from("bbb/specials/!"), PathBuf::from("bbb/specials/?"), PathBuf::from("bbb/specials/["), PathBuf::from("bbb/specials/]"))); assert_eq!(glob_vec("bbb/specials/[!?]"), vec!( PathBuf::from("bbb/specials/!"), PathBuf::from("bbb/specials/*"), PathBuf::from("bbb/specials/["), PathBuf::from("bbb/specials/]"))); } } deps/glob-0.2.10/Cargo.toml0000664000000000000000000000057612513061721014106 0ustar rootroot[package] name = "glob" version = "0.2.10" authors = ["The Rust Project Developers"] license = "MIT/Apache-2.0" homepage = "https://github.com/rust-lang/glob" repository = "https://github.com/rust-lang/glob" documentation = "http://doc.rust-lang.org/glob" description = """ Support for matching file paths against Unix shell style patterns. """ [dev-dependencies] tempdir = "0.3" deps/libc-0.2.4/0000755000000000000000000000000012666635520012072 5ustar rootrootdeps/libc-0.2.4/LICENSE-APACHE0000664000175000017500000002513712455237633012251 0ustar Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/libc-0.2.4/LICENSE-MIT0000664000175000017500000000205712455237633011755 0ustar Copyright (c) 2014 The Rust Project Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/libc-0.2.4/ci/0000755000000000000000000000000012666635520012465 5ustar rootrootdeps/libc-0.2.4/ci/rumprun/0000755000000000000000000000000012666635520014175 5ustar rootrootdeps/libc-0.2.4/ci/rumprun/Dockerfile0000664000175000017500000000042012634314552014401 0ustar FROM ubuntu:15.04 RUN apt-get update RUN apt-get install -y binutils git g++ make qemu WORKDIR /build RUN git clone --recursive http://repo.rumpkernel.org/rumprun WORKDIR /build/rumprun RUN CC=cc ./build-rr.sh hw ENV PATH=$PATH:/build/rumprun/rumprun/bin WORKDIR /root deps/libc-0.2.4/ci/dox.sh0000664000175000017500000000200212622171553012022 0ustar #!/bin/sh # Builds documentation for all target triples that we have a registered URL for # in liblibc. This scrapes the list of triples to document from `src/lib.rs` # which has a bunch of `html_root_url` directives we pick up. set -e TARGETS=`grep html_root_url src/lib.rs | sed 's/.*".*\/\(.*\)"/\1/'` rm -rf target/doc mkdir -p target/doc cp ci/landing-page-head.html target/doc/index.html for target in $TARGETS; do echo documenting $target rustdoc -o target/doc/$target --target $target src/lib.rs --cfg dox \ --crate-name libc echo "

  • $target
  • " \ >> target/doc/index.html done cat ci/landing-page-footer.html >> target/doc/index.html # If we're on travis, not a PR, and on the right branch, publish! if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then pip install ghp-import --user $USER $HOME/.local/bin/ghp-import -n target/doc git push -qf https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages fi deps/libc-0.2.4/ci/Vagrantfile0000664000175000017500000000212112627157727013077 0ustar # A vagrant configuration file for running tests on BSD-like machines # # Note that this was originally intended to later be used to run tests on # Travis, but it didn't work out. Regardless this has stuck around! You can run # tests in FreeBSD via: # # git clone https://github.com/alexcrichton/libc # cd libc/ci # vagrant up freebsd # vagrant ssh freebsd # ... # cd /vagrant/libc-test # cargo run # # And "that's it"! You look up instructions on Vagrant's website for how to # install vagrant. Vagrant.configure(2) do |config| # For a complete reference, please see the online documentation at # https://docs.vagrantup.com. config.vm.synced_folder "..", "/vagrant" config.vm.define :freebsd do |bsd| bsd.vm.box = "arkadi/freebsd-10.1-amd64" bsd.vm.provision :shell, inline: 'yes | sudo pkg install rust cargo' bsd.vm.provider "virtualbox" do |vb| vb.memory = "2048" end end config.vm.define :openbsd do |bsd| bsd.vm.box = "bodgit/openbsd-5.7-amd64" bsd.vm.provider "virtualbox" do |vb| vb.memory = "2048" end end end deps/libc-0.2.4/ci/run.sh0000664000175000017500000000257712634314567012064 0ustar #!/bin/sh # Builds and runs tests for a particular target passed as an argument to this # script. set -ex TARGET=$1 case "$TARGET" in *-apple-ios) cargo rustc --manifest-path libc-test/Cargo.toml --target $TARGET -- \ -C link-args=-mios-simulator-version-min=7.0 ;; *) cargo build --manifest-path libc-test/Cargo.toml --target $TARGET ;; esac case "$TARGET" in arm-linux-androideabi) emulator @arm-18 -no-window & adb wait-for-device adb push /tmp/$TARGET/debug/libc-test /data/libc-test adb shell /data/libc-test 2>&1 | tee /tmp/out grep "^PASSED .* tests" /tmp/out ;; arm-unknown-linux-gnueabihf) qemu-arm -L /usr/arm-linux-gnueabihf libc-test/target/$TARGET/debug/libc-test ;; mips-unknown-linux-gnu) qemu-mips -L /usr/mips-linux-gnu libc-test/target/$TARGET/debug/libc-test ;; aarch64-unknown-linux-gnu) qemu-aarch64 -L /usr/aarch64-linux-gnu/ \ libc-test/target/$TARGET/debug/libc-test ;; *-rumprun-netbsd) rumprun-bake hw_virtio /tmp/libc-test.img /tmp/$TARGET/debug/libc-test qemu-system-x86_64 -nographic -vga none -m 64 \ -kernel /tmp/libc-test.img 2>&1 | tee /tmp/out & sleep 5 grep "^PASSED .* tests" /tmp/out ;; *-apple-ios) libc-test/target/$TARGET/debug/libc-test ;; *) cargo run --manifest-path libc-test/Cargo.toml --target $TARGET ;; esac deps/libc-0.2.4/ci/README.md0000664000175000017500000000564012614522071012162 0ustar The goal of the libc crate is to have CI running everywhere to have the strongest guarantees about the definitions that this library contains, and as a result the CI is pretty complicated and also pretty large! Hopefully this can serve as a guide through the sea of scripts in this directory and elsewhere in this project. # Files First up, let's talk about the files in this directory: * `msys2.ps1` - a PowerShell script which is used to install MSYS2 on the AppVeyor bots. As of this writing MSYS2 isn't installed by default, and this script will install the right version/arch of msys2 in preparation of using the contained C compiler to compile C shims. * `run-travis.sh` - a shell script run by all Travis builders, this is responsible for setting up the rest of the environment such as installing new packages, downloading Rust target libraries, etc. * `run.sh` - the actual script which runs tests for a particular architecture. Called from the `run-travis.sh` script this will run all tests for the target specified. * `cargo-config` - Cargo configuration of linkers to use copied into place by the `run-travis.sh` script before builds are run. * `dox.sh` - script called from `run-travis.sh` on only the linux 64-bit nightly Travis bots to build documentation for this crate. * `landing-page-*.html` - used by `dox.sh` to generate a landing page for all architectures' documentation. # CI Systems Currently this repository leverages a combination of Travis CI and AppVeyor for running tests. The triples tested are: * AppVeyor * `{i686,x86_64}-pc-windows-{msvc,gnu}` * Travis * `{i686,x86_64,mips,aarch64}-unknown-linux-gnu` * `x86_64-unknown-linux-musl` * `arm-unknown-linux-gnueabihf` * `arm-linux-androideabi` * `{i686,x86_64}-apple-{darwin,ios}` The Windows triples are all pretty standard, they just set up their environment then run tests, no need for downloading any extra target libs (we just download the right installer). The Intel Linux/OSX builds are similar in that we just download the right target libs and run tests. Note that the Intel Linux/OSX builds are run on stable/beta/nightly, but are the only ones that do so. The remaining architectures look like: * Android runs in a [docker image][android-docker] with an emulator, the NDK, and the SDK already set up. The entire build happens within the docker image. * The MIPS, ARM, and AArch64 builds all use QEMU to run the generated binary to actually verify the tests pass. * The MUSL build just has to download a MUSL compiler and target libraries and then otherwise runs tests normally. * iOS builds need an extra linker flag currently, but beyond that they're built as standard as everything else. [android-docker]: https://github.com/rust-lang/rust-buildbot/blob/master/slaves/android/Dockerfile Hopefully that's at least somewhat of an introduction to everything going on here, and feel free to ping @alexcrichton with questions! deps/libc-0.2.4/ci/run-all.sh0000664000175000017500000000311612616003101012573 0ustar # This is **not** meant to be run on CI, but rather locally instead. If you're # on a Linux machine you'll be able to run most of these, but otherwise this'll # just attempt to run as many platforms as possible! run() { _target=$1 _cc=$2 if [ "$_cc" != "" ]; then which $_cc > /dev/null if [ $? -ne 0 ]; then echo "$_cc not installed, skipping $_target" return fi export CC=$_cc fi if [ ! -d .cargo ]; then mkdir .cargo cp ci/cargo-config .cargo/config fi sh ci/run.sh $_target if [ "$?" != "0" ]; then exit 1 fi } OS=`uname` if [ "$OS" = "Linux" ]; then # For more info on where to get all these cross compilers see # ci/run-travis.sh and what packages are needed on ubuntu run x86_64-unknown-linux-gnu clang run i686-unknown-linux-gnu clang run x86_64-unknown-linux-musl musl-gcc run mips-unknown-linux-gnu mips-linux-gnu-gcc run aarch64-unknown-linux-gnu aarch64-linux-gnueabihf-gcc run arm-unknown-linux-gnueabihf arm-linux-gnueabihf-gcc-4.7 # Prep for this by running `vagrant up freebsd` in the `ci` directory (cd ci && vagrant ssh freebsd -c \ "cd /vagrant && sh ci/run.sh x86_64-unknown-freebsd") # Make sure you've run `docker pull alexcrichton/rust-libc-test` to get # this image ahead of time. docker run -itv `pwd`:/clone alexcrichton/rust-libc-test \ sh ci/run.sh arm-linux-androideabi elif [ "$OS" = "Darwin" ]; then cargo run --target x86_64-unknown-linux-gnu cargo run --target i686-unknown-linux-gnu fi deps/libc-0.2.4/ci/landing-page-footer.html0000664000175000017500000000014112614241040015374 0ustar
      deps/libc-0.2.4/ci/cargo-config0000664000175000017500000000054312614241040013153 0ustar # Configuration of which linkers to call on Travis for various architectures [target.arm-linux-androideabi] linker = "arm-linux-androideabi-gcc" [target.arm-unknown-linux-gnueabihf] linker = "arm-linux-gnueabihf-gcc-4.7" [target.mips-unknown-linux-gnu] linker = "mips-linux-gnu-gcc" [target.aarch64-unknown-linux-gnu] linker = "aarch64-linux-gnu-gcc" deps/libc-0.2.4/ci/run-travis.sh0000664000175000017500000000617712634314567013372 0ustar # Entry point for all travis builds, this will set up the Travis environment by # downloading any dependencies. It will then execute the `run.sh` script to # build and execute all tests. set -ex if [ "$TRAVIS_OS_NAME" = "linux" ]; then OS=unknown-linux-gnu else OS=apple-darwin fi export HOST=$ARCH-$OS if [ "$TARGET" = "" ]; then TARGET=$HOST fi MAIN_TARGETS=https://static.rust-lang.org/dist DATE=$(echo $TRAVIS_RUST_VERSION | sed s/nightly-//) EXTRA_TARGETS=https://people.mozilla.org/~acrichton/libc-test/$DATE install() { if [ "$TRAVIS" = "true" ]; then sudo apt-get update sudo apt-get install -y $@ fi } mkdir -p .cargo cp ci/cargo-config .cargo/config if [ "$TRAVIS" = "true" ]; then case "$TARGET" in *-apple-ios | *-rumprun-*) curl -s $EXTRA_TARGETS/$TARGET.tar.gz | \ tar xzf - -C `rustc --print sysroot`/lib/rustlib ;; *) # Download the rustlib folder from the relevant portion of main distribution's # tarballs. dir=rust-std-$TARGET pkg=rust-std if [ "$TRAVIS_RUST_VERSION" = "1.0.0" ]; then pkg=rust dir=rustc fi curl -s $MAIN_TARGETS/$pkg-$TRAVIS_RUST_VERSION-$TARGET.tar.gz | \ tar xzf - -C $HOME/rust/lib/rustlib --strip-components=4 \ $pkg-$TRAVIS_RUST_VERSION-$TARGET/$dir/lib/rustlib/$TARGET ;; esac fi # Pull a pre-built docker image for testing android, then run tests entirely # within that image. Note that this is using the same rustc installation that # travis has (sharing it via `-v`) and otherwise the tests run entirely within # the container. if [ "$DOCKER" != "" ]; then exec docker run \ --entrypoint bash \ -v `rustc --print sysroot`:/usr/local:ro \ -v `pwd`:/checkout \ -e LD_LIBRARY_PATH=/usr/local/lib \ -e CARGO_TARGET_DIR=/tmp \ -w /checkout \ -it $DOCKER \ ci/run.sh $TARGET fi case "$TARGET" in x86_64-unknown-linux-musl) install musl-tools export CC=musl-gcc ;; arm-unknown-linux-gnueabihf) install gcc-4.7-arm-linux-gnueabihf qemu-user export CC=arm-linux-gnueabihf-gcc-4.7 ;; aarch64-unknown-linux-gnu) install gcc-aarch64-linux-gnu qemu-user export CC=aarch64-linux-gnu-gcc ;; *-apple-ios) ;; mips-unknown-linux-gnu) # Download pre-built and custom MIPS libs and then also instsall the MIPS # compiler according to this post: # http://sathisharada.blogspot.com/2014_10_01_archive.html echo 'deb http://ftp.de.debian.org/debian squeeze main' | \ sudo tee -a /etc/apt/sources.list echo 'deb http://www.emdebian.org/debian/ squeeze main' | \ sudo tee -a /etc/apt/sources.list install emdebian-archive-keyring install qemu-user gcc-4.4-mips-linux-gnu -y --force-yes export CC=mips-linux-gnu-gcc ;; *) # clang has better error messages and implements alignof more broadly export CC=clang if [ "$TARGET" = "i686-unknown-linux-gnu" ]; then install gcc-multilib fi ;; esac sh ci/run.sh $TARGET if [ "$TARGET" = "x86_64-unknown-linux-gnu" ] && \ [ "$TRAVIS_RUST_VERSION" = "nightly" ] && \ [ "$TRAVIS_OS_NAME" = "linux" ]; then sh ci/dox.sh fi deps/libc-0.2.4/ci/landing-page-head.html0000664000175000017500000000003512614241040015001 0ustar
    deps/libc-0.2.4/.travis.yml0000664000175000017500000000245312634314567012433 0ustar language: rust sudo: required dist: trusty rust: - 1.0.0 - beta - nightly services: - docker script: - if [[ $TRAVIS_RUST_VERSION = nightly* ]]; then sh ci/run-travis.sh; else cargo build; fi os: - linux - osx env: matrix: - ARCH=x86_64 - ARCH=i686 global: secure: eIDEoQdTyglcsTD13zSGotAX2HDhRSXIaaTnVZTThqLSrySOc3/6KY3qmOc2Msf7XaBqfFy9QA+alk7OwfePp253eiy1Kced67ffjjFOytEcRT7FlQiYpcYQD6WNHZEj62/bJBO4LTM9sGtWNCTJVEDKW0WM8mUK7qNuC+honPM= matrix: include: - os: linux env: TARGET=arm-linux-androideabi DOCKER=alexcrichton/rust-slave-android:2015-10-21 rust: nightly - os: linux env: TARGET=x86_64-unknown-linux-musl rust: nightly - os: linux env: TARGET=arm-unknown-linux-gnueabihf rust: nightly - os: linux env: TARGET=mips-unknown-linux-gnu rust: nightly - os: linux env: TARGET=aarch64-unknown-linux-gnu rust: nightly - os: osx env: TARGET=i386-apple-ios rust: nightly-2015-09-08 - os: osx env: TARGET=x86_64-apple-ios rust: nightly-2015-09-08 - os: linux env: TARGET=x86_64-rumprun-netbsd DOCKER=alexcrichton/rust-libc-rumprun:2015-11-27 rust: nightly-2015-09-27 notifications: email: on_success: never branches: only: - master deps/libc-0.2.4/README.md0000664000175000017500000001133212616222667011574 0ustar libc ==== A Rust library with native bindings to the types and functions commonly found on various systems, including libc. [![Build Status](https://travis-ci.org/rust-lang-nursery/libc.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/libc) [![Build status](https://ci.appveyor.com/api/projects/status/34csq3uurnw7c0rl?svg=true)](https://ci.appveyor.com/project/alexcrichton/libc) [Documentation](#platforms-and-documentation) ## Usage First, add the following to your `Cargo.toml`: ```toml [dependencies] libc = "0.2" ``` Next, add this to your crate root: ```rust extern crate libc; ``` ## What is libc? The primary purpose of this crate is to provide all of the definitions necessary to easily interoperate with C code (or "C-like" code) on each of the platforms that Rust supports. This includes type definitions (e.g. `c_int`), constants (e.g. `EINVAL`) as well as function headers (e.g. `malloc`). This crate does not strive to have any form of compatibility across platforms, but rather it is simply a straight binding to the system libraries on the platform in question. ## Public API This crate exports all underlying platform types, functions, and constants under the crate root, so all items are accessible as `libc::foo`. The types and values of all the exported APIs match the platform that libc is compiled for. More detailed information about the design of this library can be found in its [associated RFC][rfc]. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1291-promote-libc.md ## Adding an API Want to use an API which currently isn't bound in `libc`? It's quite easy to add one! The internal structure of this crate is designed to minimize the number of `#[cfg]` attributes in order to easily be able to add new items which apply to all platforms in the future. As a result, the crate is organized hierarchically based on platform. Each module has a number of `#[cfg]`'d children, but only one is ever actually compiled. Each module then reexports all the contents of its children. This means that for each platform that libc supports, the path from a leaf module to the root will contain all bindings for the platform in question. Consequently, this indicates where an API should be added! Adding an API at a particular level in the hierarchy means that it is supported on all the child platforms of that level. For example, when adding a Unix API it should be added to `src/unix/mod.rs`, but when adding a Linux-only API it should be added to `src/unix/notbsd/linux/mod.rs`. If you're not 100% sure at what level of the hierarchy an API should be added at, fear not! This crate has CI support which tests any binding against all platforms supported, so you'll see failures if an API is added at the wrong level or has different signatures across platforms. With that in mind, the steps for adding a new API are: 1. Determine where in the module hierarchy your API should be added. 2. Add the API. 3. Send a PR to this repo. 4. Wait for CI to pass, fixing errors. 5. Wait for a merge! ## Platforms and Documentation The following platforms are currently tested and have documentation available: Tested: * [`i686-pc-windows-msvc`](https://doc.rust-lang.org/libc/i686-pc-windows-msvc/libc) * [`x86_64-pc-windows-msvc`](https://doc.rust-lang.org/libc/x86_64-pc-windows-msvc/libc) (Windows) * [`i686-pc-windows-gnu`](https://doc.rust-lang.org/libc/i686-pc-windows-gnu/libc) * [`x86_64-pc-windows-gnu`](https://doc.rust-lang.org/libc/x86_64-pc-windows-gnu/libc) * [`i686-apple-darwin`](https://doc.rust-lang.org/libc/i686-apple-darwin/libc) * [`x86_64-apple-darwin`](https://doc.rust-lang.org/libc/x86_64-apple-darwin/libc) (OSX) * [`i686-apple-ios`](https://doc.rust-lang.org/libc/i686-apple-ios/libc) * [`x86_64-apple-ios`](https://doc.rust-lang.org/libc/x86_64-apple-ios/libc) (iOS) * [`i686-unknown-linux-gnu`](https://doc.rust-lang.org/libc/i686-unknown-linux-gnu/libc) * [`x86_64-unknown-linux-gnu`](https://doc.rust-lang.org/libc/x86_64-unknown-linux-gnu/libc) (Linux) * [`x86_64-unknown-linux-musl`](https://doc.rust-lang.org/libc/x86_64-unknown-linux-musl/libc) (Linux MUSL) * [`aarch64-unknown-linux-gnu`](https://doc.rust-lang.org/libc/aarch64-unknown-linux-gnu/libc) * [`mips-unknown-linux-gnu`](https://doc.rust-lang.org/libc/mips-unknown-linux-gnu/libc) * [`arm-unknown-linux-gnueabihf`](https://doc.rust-lang.org/libc/arm-unknown-linux-gnueabihf/libc) * [`arm-linux-androideabi`](https://doc.rust-lang.org/libc/arm-linux-androideabi/libc) (Android) The following may be supported, but are not guaranteed to always work: * `x86_64-unknown-freebsd` * `i686-unknown-freebsd` * `x86_64-unknown-bitrig` * `x86_64-unknown-dragonfly` * `x86_64-unknown-openbsd` * `x86_64-unknown-netbsd` deps/libc-0.2.4/.gitignore0000664000175000017500000000002212614466575012305 0ustar target Cargo.lock deps/libc-0.2.4/src/0000755000000000000000000000000012666635520012661 5ustar rootrootdeps/libc-0.2.4/src/lib.rs0000664000175000017500000002470512634630015012216 0ustar // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Crate docs #![allow(bad_style, overflowing_literals, improper_ctypes)] #![crate_type = "rlib"] #![crate_name = "libc"] #![cfg_attr(dox, feature(no_core, lang_items))] #![cfg_attr(dox, no_core)] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico")] #![cfg_attr(all(target_os = "linux", target_arch = "x86_64"), doc( html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-linux-gnu" ))] #![cfg_attr(all(target_os = "linux", target_arch = "x86"), doc( html_root_url = "https://doc.rust-lang.org/libc/i686-unknown-linux-gnu" ))] #![cfg_attr(all(target_os = "linux", target_arch = "arm"), doc( html_root_url = "https://doc.rust-lang.org/libc/arm-unknown-linux-gnueabihf" ))] #![cfg_attr(all(target_os = "linux", target_arch = "mips"), doc( html_root_url = "https://doc.rust-lang.org/libc/mips-unknown-linux-gnu" ))] #![cfg_attr(all(target_os = "linux", target_arch = "aarch64"), doc( html_root_url = "https://doc.rust-lang.org/libc/aarch64-unknown-linux-gnu" ))] #![cfg_attr(all(target_os = "linux", target_env = "musl"), doc( html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-linux-musl" ))] #![cfg_attr(all(target_os = "macos", target_arch = "x86_64"), doc( html_root_url = "https://doc.rust-lang.org/libc/x86_64-apple-darwin" ))] #![cfg_attr(all(target_os = "macos", target_arch = "x86"), doc( html_root_url = "https://doc.rust-lang.org/libc/i686-apple-darwin" ))] #![cfg_attr(all(windows, target_arch = "x86_64", target_env = "gnu"), doc( html_root_url = "https://doc.rust-lang.org/libc/x86_64-pc-windows-gnu" ))] #![cfg_attr(all(windows, target_arch = "x86", target_env = "gnu"), doc( html_root_url = "https://doc.rust-lang.org/libc/i686-pc-windows-gnu" ))] #![cfg_attr(all(windows, target_arch = "x86_64", target_env = "msvc"), doc( html_root_url = "https://doc.rust-lang.org/libc/x86_64-pc-windows-msvc" ))] #![cfg_attr(all(windows, target_arch = "x86", target_env = "msvc"), doc( html_root_url = "https://doc.rust-lang.org/libc/i686-pc-windows-msvc" ))] #![cfg_attr(target_os = "android", doc( html_root_url = "https://doc.rust-lang.org/libc/arm-linux-androideabi" ))] #![cfg_attr(target_os = "freebsd", doc( html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-freebsd" ))] #![cfg_attr(target_os = "openbsd", doc( html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-openbsd" ))] #![cfg_attr(target_os = "bitrig", doc( html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-bitrig" ))] #![cfg_attr(target_os = "netbsd", doc( html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-netbsd" ))] #![cfg_attr(target_os = "dragonfly", doc( html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-dragonfly" ))] // Attributes needed when building as part of the standard library #![cfg_attr(stdbuild, feature(no_std, core, core_slice_ext, staged_api, custom_attribute))] #![cfg_attr(stdbuild, no_std)] #![cfg_attr(stdbuild, staged_api)] #![cfg_attr(stdbuild, allow(warnings))] #![cfg_attr(stdbuild, unstable(feature = "libc", reason = "use `libc` from crates.io", issue = "27783"))] #[cfg(all(not(stdbuild), not(dox)))] extern crate std as core; #[macro_use] mod macros; mod dox; // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable // more optimization opportunities around it recognizing things like // malloc/free. #[repr(u8)] pub enum c_void { // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] __variant1, #[doc(hidden)] __variant2, } pub type int8_t = i8; pub type int16_t = i16; pub type int32_t = i32; pub type int64_t = i64; pub type uint8_t = u8; pub type uint16_t = u16; pub type uint32_t = u32; pub type uint64_t = u64; pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; pub type c_ushort = u16; pub type c_int = i32; pub type c_uint = u32; pub type c_float = f32; pub type c_double = f64; pub type c_longlong = i64; pub type c_ulonglong = u64; pub type intmax_t = i64; pub type uintmax_t = u64; pub type size_t = usize; pub type ptrdiff_t = isize; pub type intptr_t = isize; pub type uintptr_t = usize; pub type ssize_t = isize; pub enum FILE {} pub enum fpos_t {} // TODO: fill this out with a struct extern { pub fn isalnum(c: c_int) -> c_int; pub fn isalpha(c: c_int) -> c_int; pub fn iscntrl(c: c_int) -> c_int; pub fn isdigit(c: c_int) -> c_int; pub fn isgraph(c: c_int) -> c_int; pub fn islower(c: c_int) -> c_int; pub fn isprint(c: c_int) -> c_int; pub fn ispunct(c: c_int) -> c_int; pub fn isspace(c: c_int) -> c_int; pub fn isupper(c: c_int) -> c_int; pub fn isxdigit(c: c_int) -> c_int; pub fn tolower(c: c_int) -> c_int; pub fn toupper(c: c_int) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fopen$UNIX2003")] pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "freopen$UNIX2003")] pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE; pub fn fflush(file: *mut FILE) -> c_int; pub fn fclose(file: *mut FILE) -> c_int; pub fn remove(filename: *const c_char) -> c_int; pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; pub fn tmpfile() -> *mut FILE; pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int; pub fn setbuf(stream: *mut FILE, buf: *mut c_char); pub fn fgetc(stream: *mut FILE) -> c_int; pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fputs$UNIX2003")] pub fn fputs(s: *const c_char, stream: *mut FILE)-> c_int; pub fn puts(s: *const c_char) -> c_int; pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fwrite$UNIX2003")] pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t; pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; pub fn ftell(stream: *mut FILE) -> c_long; pub fn rewind(stream: *mut FILE); #[cfg_attr(target_os = "netbsd", link_name = "__fgetpos50")] pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; #[cfg_attr(target_os = "netbsd", link_name = "__fsetpos50")] pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; pub fn feof(stream: *mut FILE) -> c_int; pub fn ferror(stream: *mut FILE) -> c_int; pub fn perror(s: *const c_char); pub fn atoi(s: *const c_char) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "strtod$UNIX2003")] pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long; pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong; pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; pub fn malloc(size: size_t) -> *mut c_void; pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; pub fn free(p: *mut c_void); pub fn exit(status: c_int) -> !; pub fn _exit(status: c_int) -> !; pub fn atexit(cb: extern fn()) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "system$UNIX2003")] pub fn system(s: *const c_char) -> c_int; pub fn getenv(s: *const c_char) -> *mut c_char; pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char; pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; pub fn strlen(cs: *const c_char) -> size_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "strerror$UNIX2003")] pub fn strerror(n: c_int) -> *mut c_char; pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; pub fn wcslen(buf: *const wchar_t) -> size_t; pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; } // These are all inline functions on android, so they end up just being entirely // missing on that platform. #[cfg(not(target_os = "android"))] extern { pub fn abs(i: c_int) -> c_int; pub fn atof(s: *const c_char) -> c_double; pub fn labs(i: c_long) -> c_long; pub fn rand() -> c_int; pub fn srand(seed: c_uint); } cfg_if! { if #[cfg(windows)] { mod windows; pub use windows::*; } else { mod unix; pub use unix::*; } } deps/libc-0.2.4/src/macros.rs0000664000175000017500000000503112634314552012730 0ustar /// A macro for defining #[cfg] if-else statements. /// /// This is similar to the `if/elif` C preprocessor macro by allowing definition /// of a cascade of `#[cfg]` cases, emitting the implementation which matches /// first. /// /// This allows you to conveniently provide a long list #[cfg]'d blocks of code /// without having to rewrite each clause multiple times. macro_rules! cfg_if { ($( if #[cfg($($meta:meta),*)] { $($it:item)* } ) else * else { $($it2:item)* }) => { __cfg_if_items! { () ; $( ( ($($meta),*) ($($it)*) ), )* ( () ($($it2)*) ), } } } macro_rules! __cfg_if_items { (($($not:meta,)*) ; ) => {}; (($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ), $($rest:tt)*) => { __cfg_if_apply! { cfg(all($($m,)* not(any($($not),*)))), $($it)* } __cfg_if_items! { ($($not,)* $($m,)*) ; $($rest)* } } } macro_rules! __cfg_if_apply { ($m:meta, $($it:item)*) => { $(#[$m] $it)* } } macro_rules! s { ($($(#[$attr:meta])* pub struct $i:ident { $($field:tt)* })*) => ($( __item! { #[repr(C)] $(#[$attr])* pub struct $i { $($field)* } } impl ::dox::Copy for $i {} impl ::dox::Clone for $i { fn clone(&self) -> $i { *self } } )*) } macro_rules! f { ($(pub fn $i:ident($($arg:ident: $argty:ty),*) -> $ret:ty { $($body:stmt);* })*) => ($( #[inline] #[cfg(not(dox))] pub unsafe extern fn $i($($arg: $argty),*) -> $ret { $($body);* } #[cfg(dox)] #[allow(dead_code)] pub unsafe extern fn $i($($arg: $argty),*) -> $ret { loop {} } )*) } macro_rules! __item { ($i:item) => ($i) } #[cfg(test)] mod tests { cfg_if! { if #[cfg(test)] { use std::option::Option as Option2; fn works1() -> Option2 { Some(1) } } else { fn works1() -> Option { None } } } cfg_if! { if #[cfg(foo)] { fn works2() -> bool { false } } else if #[cfg(test)] { fn works2() -> bool { true } } else { fn works2() -> bool { false } } } cfg_if! { if #[cfg(foo)] { fn works3() -> bool { false } } else { fn works3() -> bool { true } } } #[test] fn it_works() { assert!(works1().is_some()); assert!(works2()); assert!(works3()); } } deps/libc-0.2.4/src/windows.rs0000664000175000017500000001345312614760104013141 0ustar //! Windows CRT definitions pub type c_char = i8; pub type c_long = i32; pub type c_ulong = u32; pub type wchar_t = u16; pub type clock_t = i32; cfg_if! { if #[cfg(all(target_arch = "x86", target_env = "gnu"))] { pub type time_t = i32; } else { pub type time_t = i64; } } pub type off_t = i32; pub type dev_t = u32; pub type ino_t = u16; pub enum timezone {} pub type time64_t = i64; s! { // note this is the struct called stat64 in Windows. Not stat, nor stati64. pub struct stat { pub st_dev: dev_t, pub st_ino: ino_t, pub st_mode: u16, pub st_nlink: ::c_short, pub st_uid: ::c_short, pub st_gid: ::c_short, pub st_rdev: dev_t, pub st_size: i64, pub st_atime: time64_t, pub st_mtime: time64_t, pub st_ctime: time64_t, } // note that this is called utimbuf64 in Windows pub struct utimbuf { pub actime: time64_t, pub modtime: time64_t, } pub struct timeval { pub tv_sec: c_long, pub tv_usec: c_long, } pub struct timespec { pub tv_sec: time_t, pub tv_nsec: c_long, } } pub const EXIT_FAILURE: ::c_int = 1; pub const EXIT_SUCCESS: ::c_int = 0; pub const RAND_MAX: ::c_int = 32767; pub const EOF: ::c_int = -1; pub const SEEK_SET: ::c_int = 0; pub const SEEK_CUR: ::c_int = 1; pub const SEEK_END: ::c_int = 2; pub const _IOFBF: ::c_int = 0; pub const _IONBF: ::c_int = 4; pub const _IOLBF: ::c_int = 64; pub const BUFSIZ: ::c_uint = 512; pub const FOPEN_MAX: ::c_uint = 20; pub const FILENAME_MAX: ::c_uint = 260; cfg_if! { if #[cfg(all(target_env = "gnu"))] { pub const L_tmpnam: ::c_uint = 14; pub const TMP_MAX: ::c_uint = 0x7fff; } else { pub const L_tmpnam: ::c_uint = 260; pub const TMP_MAX: ::c_uint = 0x7fff_ffff; } } pub const O_RDONLY: ::c_int = 0; pub const O_WRONLY: ::c_int = 1; pub const O_RDWR: ::c_int = 2; pub const O_APPEND: ::c_int = 8; pub const O_CREAT: ::c_int = 256; pub const O_EXCL: ::c_int = 1024; pub const O_TEXT: ::c_int = 16384; pub const O_BINARY: ::c_int = 32768; pub const O_NOINHERIT: ::c_int = 128; pub const O_TRUNC: ::c_int = 512; pub const S_IFCHR: ::c_int = 8192; pub const S_IFDIR: ::c_int = 16384; pub const S_IFREG: ::c_int = 32768; pub const S_IFMT: ::c_int = 61440; pub const S_IEXEC: ::c_int = 64; pub const S_IWRITE: ::c_int = 128; pub const S_IREAD: ::c_int = 256; #[cfg(target_env = "msvc")] #[link(name = "msvcrt")] extern {} extern { #[link_name = "_chmod"] pub fn chmod(path: *const c_char, mode: ::c_int) -> ::c_int; #[link_name = "_wchmod"] pub fn wchmod(path: *const wchar_t, mode: ::c_int) -> ::c_int; #[link_name = "_mkdir"] pub fn mkdir(path: *const c_char) -> ::c_int; #[link_name = "_wrmdir"] pub fn wrmdir(path: *const wchar_t) -> ::c_int; #[link_name = "_fstat64"] pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; #[link_name = "_stat64"] pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; #[link_name = "_wstat64"] pub fn wstat(path: *const wchar_t, buf: *mut stat) -> ::c_int; #[link_name = "_wutime64"] pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> ::c_int; #[link_name = "_popen"] pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; #[link_name = "_pclose"] pub fn pclose(stream: *mut ::FILE) -> ::c_int; #[link_name = "_fdopen"] pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE; #[link_name = "_fileno"] pub fn fileno(stream: *mut ::FILE) -> ::c_int; #[link_name = "_open"] pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; #[link_name = "_wopen"] pub fn wopen(path: *const wchar_t, oflag: ::c_int, ...) -> ::c_int; #[link_name = "_creat"] pub fn creat(path: *const c_char, mode: ::c_int) -> ::c_int; #[link_name = "_access"] pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int; #[link_name = "_chdir"] pub fn chdir(dir: *const c_char) -> ::c_int; #[link_name = "_close"] pub fn close(fd: ::c_int) -> ::c_int; #[link_name = "_dup"] pub fn dup(fd: ::c_int) -> ::c_int; #[link_name = "_dup2"] pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int; #[link_name = "_execv"] pub fn execv(prog: *const c_char, argv: *const *const c_char) -> ::intptr_t; #[link_name = "_execve"] pub fn execve(prog: *const c_char, argv: *const *const c_char, envp: *const *const c_char) -> ::c_int; #[link_name = "_execvp"] pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int; #[link_name = "_execvpe"] pub fn execvpe(c: *const c_char, argv: *const *const c_char, envp: *const *const c_char) -> ::c_int; #[link_name = "_getcwd"] pub fn getcwd(buf: *mut c_char, size: ::c_int) -> *mut c_char; #[link_name = "_getpid"] pub fn getpid() -> ::c_int; #[link_name = "_isatty"] pub fn isatty(fd: ::c_int) -> ::c_int; #[link_name = "_lseek"] pub fn lseek(fd: ::c_int, offset: c_long, origin: ::c_int) -> c_long; #[link_name = "_pipe"] pub fn pipe(fds: *mut ::c_int, psize: ::c_uint, textmode: ::c_int) -> ::c_int; #[link_name = "_read"] pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::c_uint) -> ::c_int; #[link_name = "_rmdir"] pub fn rmdir(path: *const c_char) -> ::c_int; #[link_name = "_unlink"] pub fn unlink(c: *const c_char) -> ::c_int; #[link_name = "_write"] pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::c_uint) -> ::c_int; #[link_name = "_commit"] pub fn commit(fd: ::c_int) -> ::c_int; #[link_name = "_get_osfhandle"] pub fn get_osfhandle(fd: ::c_int) -> ::intptr_t; #[link_name = "_open_osfhandle"] pub fn open_osfhandle(osfhandle: ::intptr_t, flags: ::c_int) -> ::c_int; } deps/libc-0.2.4/src/unix/0000755000000000000000000000000012666635520013644 5ustar rootrootdeps/libc-0.2.4/src/unix/notbsd/0000755000000000000000000000000012666635520015135 5ustar rootrootdeps/libc-0.2.4/src/unix/notbsd/linux/0000755000000000000000000000000012666635520016274 5ustar rootrootdeps/libc-0.2.4/src/unix/notbsd/linux/musl.rs0000664000175000017500000003250112634314567016047 0ustar pub type c_long = i64; pub type c_ulong = u64; pub type clock_t = i64; pub type time_t = i64; pub type suseconds_t = i64; pub type ino_t = u64; pub type off_t = i64; pub type blkcnt_t = i64; pub type c_char = i8; pub type wchar_t = i32; pub type nlink_t = u64; pub type blksize_t = i64; s! { pub struct stat { pub st_dev: ::dev_t, pub st_ino: ::ino_t, pub st_nlink: ::nlink_t, pub st_mode: ::mode_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, __pad0: ::c_int, pub st_rdev: ::dev_t, pub st_size: ::off_t, pub st_blksize: ::blksize_t, pub st_blocks: ::blkcnt_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, __unused: [::c_long; 3], } pub struct stat64 { pub st_dev: ::dev_t, pub st_ino: ::ino64_t, pub st_nlink: ::nlink_t, pub st_mode: ::mode_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, __pad0: ::c_int, pub st_rdev: ::dev_t, pub st_size: ::off_t, pub st_blksize: ::blksize_t, pub st_blocks: ::blkcnt64_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, __reserved: [::c_long; 3], } pub struct pthread_attr_t { __size: [u64; 7] } pub struct sigset_t { __val: [::c_ulong; 16], } pub struct sigaction { pub sa_sigaction: ::sighandler_t, pub sa_mask: ::sigset_t, pub sa_flags: ::c_int, _restorer: *mut ::c_void, } pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, pub ss_size: ::size_t } pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, pub si_code: ::c_int, pub _pad: [::c_int; 29], _align: [usize; 0], } pub struct ipc_perm { pub __ipc_perm_key: ::key_t, pub uid: ::uid_t, pub gid: ::gid_t, pub cuid: ::uid_t, pub cgid: ::gid_t, pub mode: ::mode_t, pub __seq: ::c_int, __unused1: ::c_long, __unused2: ::c_long } pub struct shmid_ds { pub shm_perm: ::ipc_perm, pub shm_segsz: ::size_t, pub shm_atime: ::time_t, pub shm_dtime: ::time_t, pub shm_ctime: ::time_t, pub shm_cpid: ::pid_t, pub shm_lpid: ::pid_t, pub shm_nattch: ::c_ulong, __pad1: ::c_ulong, __pad2: ::c_ulong, } pub struct statfs { pub f_type: ::c_ulong, pub f_bsize: ::c_ulong, pub f_blocks: ::fsblkcnt_t, pub f_bfree: ::fsblkcnt_t, pub f_bavail: ::fsblkcnt_t, pub f_files: ::fsfilcnt_t, pub f_ffree: ::fsfilcnt_t, pub f_fsid: ::fsid_t, pub f_namelen: ::c_ulong, pub f_frsize: ::c_ulong, pub f_flags: ::c_ulong, pub f_spare: [::c_ulong; 4], } pub struct msghdr { pub msg_name: *mut ::c_void, pub msg_namelen: ::socklen_t, pub msg_iov: *mut ::iovec, pub msg_iovlen: ::c_int, __pad1: ::c_int, pub msg_control: *mut ::c_void, pub msg_controllen: ::socklen_t, __pad2: ::socklen_t, pub msg_flags: ::c_int, } pub struct termios { pub c_iflag: ::tcflag_t, pub c_oflag: ::tcflag_t, pub c_cflag: ::tcflag_t, pub c_lflag: ::tcflag_t, pub c_line: ::cc_t, pub c_cc: [::cc_t; ::NCCS], pub __c_ispeed: ::speed_t, pub __c_ospeed: ::speed_t, } pub struct flock { pub l_type: ::c_short, pub l_whence: ::c_short, pub l_start: ::off_t, pub l_len: ::off_t, pub l_pid: ::pid_t, } } pub const BUFSIZ: ::c_uint = 1024; pub const TMP_MAX: ::c_uint = 10000; pub const FOPEN_MAX: ::c_uint = 1000; pub const POSIX_MADV_DONTNEED: ::c_int = 0; pub const O_ACCMODE: ::c_int = 0o10000003; pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; pub const O_NOFOLLOW: ::c_int = 0x20000; pub const O_ASYNC: ::c_int = 0x2000; pub const O_NDELAY: ::c_int = 0x800; pub const RUSAGE_CHILDREN: ::c_int = 1; pub const NI_MAXHOST: ::socklen_t = 255; pub const PTHREAD_STACK_MIN: ::size_t = 2048; pub const FIOCLEX: ::c_int = 0x5451; pub const FIONBIO: ::c_int = 0x5421; pub const RLIMIT_RSS: ::c_int = 5; pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_AS: ::c_int = 9; pub const RLIMIT_NPROC: ::c_int = 6; pub const RLIMIT_MEMLOCK: ::c_int = 8; pub const RLIM_INFINITY: ::rlim_t = !0; pub const RLIMIT_RTTIME: ::c_int = 15; pub const RLIMIT_NLIMITS: ::c_int = 16; pub const O_APPEND: ::c_int = 1024; pub const O_CREAT: ::c_int = 64; pub const O_EXCL: ::c_int = 128; pub const O_NOCTTY: ::c_int = 256; pub const O_NONBLOCK: ::c_int = 2048; pub const O_SYNC: ::c_int = 1052672; pub const O_RSYNC: ::c_int = 1052672; pub const O_DSYNC: ::c_int = 4096; pub const MAP_ANON: ::c_int = 0x0020; pub const MAP_ANONYMOUS: ::c_int = 0x0020; pub const MAP_GROWSDOWN: ::c_int = 0x0100; pub const MAP_DENYWRITE: ::c_int = 0x0800; pub const MAP_EXECUTABLE: ::c_int = 0x01000; pub const MAP_LOCKED: ::c_int = 0x02000; pub const MAP_NORESERVE: ::c_int = 0x04000; pub const MAP_POPULATE: ::c_int = 0x08000; pub const MAP_NONBLOCK: ::c_int = 0x010000; pub const MAP_STACK: ::c_int = 0x020000; pub const EDEADLK: ::c_int = 35; pub const ENAMETOOLONG: ::c_int = 36; pub const ENOLCK: ::c_int = 37; pub const ENOSYS: ::c_int = 38; pub const ENOTEMPTY: ::c_int = 39; pub const ELOOP: ::c_int = 40; pub const ENOMSG: ::c_int = 42; pub const EIDRM: ::c_int = 43; pub const ECHRNG: ::c_int = 44; pub const EL2NSYNC: ::c_int = 45; pub const EL3HLT: ::c_int = 46; pub const EL3RST: ::c_int = 47; pub const ELNRNG: ::c_int = 48; pub const EUNATCH: ::c_int = 49; pub const ENOCSI: ::c_int = 50; pub const EL2HLT: ::c_int = 51; pub const EBADE: ::c_int = 52; pub const EBADR: ::c_int = 53; pub const EXFULL: ::c_int = 54; pub const ENOANO: ::c_int = 55; pub const EBADRQC: ::c_int = 56; pub const EBADSLT: ::c_int = 57; pub const EDEADLOCK: ::c_int = EDEADLK; pub const EMULTIHOP: ::c_int = 72; pub const EOVERFLOW: ::c_int = 75; pub const ENOTUNIQ: ::c_int = 76; pub const EBADFD: ::c_int = 77; pub const EBADMSG: ::c_int = 74; pub const EREMCHG: ::c_int = 78; pub const ELIBACC: ::c_int = 79; pub const ELIBBAD: ::c_int = 80; pub const ELIBSCN: ::c_int = 81; pub const ELIBMAX: ::c_int = 82; pub const ELIBEXEC: ::c_int = 83; pub const EILSEQ: ::c_int = 84; pub const ERESTART: ::c_int = 85; pub const ESTRPIPE: ::c_int = 86; pub const EUSERS: ::c_int = 87; pub const ENOTSOCK: ::c_int = 88; pub const EDESTADDRREQ: ::c_int = 89; pub const EMSGSIZE: ::c_int = 90; pub const EPROTOTYPE: ::c_int = 91; pub const ENOPROTOOPT: ::c_int = 92; pub const EPROTONOSUPPORT: ::c_int = 93; pub const ESOCKTNOSUPPORT: ::c_int = 94; pub const EOPNOTSUPP: ::c_int = 95; pub const EPFNOSUPPORT: ::c_int = 96; pub const EAFNOSUPPORT: ::c_int = 97; pub const EADDRINUSE: ::c_int = 98; pub const EADDRNOTAVAIL: ::c_int = 99; pub const ENETDOWN: ::c_int = 100; pub const ENETUNREACH: ::c_int = 101; pub const ENETRESET: ::c_int = 102; pub const ECONNABORTED: ::c_int = 103; pub const ECONNRESET: ::c_int = 104; pub const ENOBUFS: ::c_int = 105; pub const EISCONN: ::c_int = 106; pub const ENOTCONN: ::c_int = 107; pub const ESHUTDOWN: ::c_int = 108; pub const ETOOMANYREFS: ::c_int = 109; pub const ETIMEDOUT: ::c_int = 110; pub const ECONNREFUSED: ::c_int = 111; pub const EHOSTDOWN: ::c_int = 112; pub const EHOSTUNREACH: ::c_int = 113; pub const EALREADY: ::c_int = 114; pub const EINPROGRESS: ::c_int = 115; pub const ESTALE: ::c_int = 116; pub const EUCLEAN: ::c_int = 117; pub const ENOTNAM: ::c_int = 118; pub const ENAVAIL: ::c_int = 119; pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; pub const EDQUOT: ::c_int = 122; pub const ENOMEDIUM: ::c_int = 123; pub const EMEDIUMTYPE: ::c_int = 124; pub const ECANCELED: ::c_int = 125; pub const ENOKEY: ::c_int = 126; pub const EKEYEXPIRED: ::c_int = 127; pub const EKEYREVOKED: ::c_int = 128; pub const EKEYREJECTED: ::c_int = 129; pub const EOWNERDEAD: ::c_int = 130; pub const ENOTRECOVERABLE: ::c_int = 131; pub const EHWPOISON: ::c_int = 133; pub const ERFKILL: ::c_int = 132; pub const SOCK_STREAM: ::c_int = 1; pub const SOCK_DGRAM: ::c_int = 2; pub const SOL_SOCKET: ::c_int = 1; pub const SO_REUSEADDR: ::c_int = 2; pub const SO_TYPE: ::c_int = 3; pub const SO_ERROR: ::c_int = 4; pub const SO_DONTROUTE: ::c_int = 5; pub const SO_BROADCAST: ::c_int = 6; pub const SO_SNDBUF: ::c_int = 7; pub const SO_RCVBUF: ::c_int = 8; pub const SO_KEEPALIVE: ::c_int = 9; pub const SO_OOBINLINE: ::c_int = 10; pub const SO_LINGER: ::c_int = 13; pub const SO_REUSEPORT: ::c_int = 15; pub const SO_RCVLOWAT: ::c_int = 18; pub const SO_SNDLOWAT: ::c_int = 19; pub const SO_RCVTIMEO: ::c_int = 20; pub const SO_SNDTIMEO: ::c_int = 21; pub const SO_ACCEPTCONN: ::c_int = 30; pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; pub const TCP_THIN_DUPACK: ::c_int = 17; pub const TCP_USER_TIMEOUT: ::c_int = 18; pub const TCP_REPAIR: ::c_int = 19; pub const TCP_REPAIR_QUEUE: ::c_int = 20; pub const TCP_QUEUE_SEQ: ::c_int = 21; pub const TCP_REPAIR_OPTIONS: ::c_int = 22; pub const TCP_FASTOPEN: ::c_int = 23; pub const TCP_TIMESTAMP: ::c_int = 24; pub const SA_ONSTACK: ::c_int = 0x08000000; pub const SA_SIGINFO: ::c_int = 0x00000004; pub const SA_NOCLDWAIT: ::c_int = 0x00000002; pub const SIGCHLD: ::c_int = 17; pub const SIGBUS: ::c_int = 7; pub const SIGTTIN: ::c_int = 21; pub const SIGTTOU: ::c_int = 22; pub const SIGXCPU: ::c_int = 24; pub const SIGXFSZ: ::c_int = 25; pub const SIGVTALRM: ::c_int = 26; pub const SIGPROF: ::c_int = 27; pub const SIGWINCH: ::c_int = 28; pub const SIGUSR1: ::c_int = 10; pub const SIGUSR2: ::c_int = 12; pub const SIGCONT: ::c_int = 18; pub const SIGSTOP: ::c_int = 19; pub const SIGTSTP: ::c_int = 20; pub const SIGURG: ::c_int = 23; pub const SIGIO: ::c_int = 29; pub const SIGSYS: ::c_int = 31; pub const SIGSTKFLT: ::c_int = 16; pub const SIGUNUSED: ::c_int = 31; pub const SIGPOLL: ::c_int = 29; pub const SIGPWR: ::c_int = 30; pub const SIG_SETMASK: ::c_int = 2; pub const SIG_BLOCK: ::c_int = 0x000000; pub const SIG_UNBLOCK: ::c_int = 0x01; pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01; pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02; pub const _SC_2_C_VERSION: ::c_int = 96; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const CPU_SETSIZE: ::c_int = 128; pub const EXTPROC: ::tcflag_t = 0x00010000; pub const QFMT_VFS_V1: ::c_int = 4; pub const PTRACE_TRACEME: ::c_int = 0; pub const PTRACE_PEEKTEXT: ::c_int = 1; pub const PTRACE_PEEKDATA: ::c_int = 2; pub const PTRACE_PEEKUSER: ::c_int = 3; pub const PTRACE_POKETEXT: ::c_int = 4; pub const PTRACE_POKEDATA: ::c_int = 5; pub const PTRACE_POKEUSER: ::c_int = 6; pub const PTRACE_CONT: ::c_int = 7; pub const PTRACE_KILL: ::c_int = 8; pub const PTRACE_SINGLESTEP: ::c_int = 9; pub const PTRACE_ATTACH: ::c_int = 16; pub const PTRACE_DETACH: ::c_int = 17; pub const PTRACE_SYSCALL: ::c_int = 24; pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; pub const PTRACE_GETREGSET: ::c_int = 0x4204; pub const PTRACE_SETREGSET: ::c_int = 0x4205; pub const PTRACE_SEIZE: ::c_int = 0x4206; pub const PTRACE_INTERRUPT: ::c_int = 0x4207; pub const PTRACE_LISTEN: ::c_int = 0x4208; pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; pub const MADV_DODUMP: ::c_int = 17; pub const MADV_DONTDUMP: ::c_int = 16; pub const EPOLLWAKEUP: ::c_int = 0x20000000; pub const MS_NOSEC: ::c_ulong = 0x10000000; pub const MS_BORN: ::c_ulong = 0x20000000; pub const MADV_HUGEPAGE: ::c_int = 14; pub const MADV_NOHUGEPAGE: ::c_int = 15; pub const MAP_HUGETLB: ::c_int = 0x040000; pub const PTRACE_GETFPREGS: ::c_uint = 14; pub const PTRACE_SETFPREGS: ::c_uint = 15; pub const PTRACE_GETFPXREGS: ::c_uint = 18; pub const PTRACE_SETFPXREGS: ::c_uint = 19; pub const PTRACE_GETREGS: ::c_uint = 12; pub const PTRACE_SETREGS: ::c_uint = 13; pub const EFD_NONBLOCK: ::c_int = 0x800; pub const F_GETLK: ::c_int = 5; pub const F_GETOWN: ::c_int = 9; pub const F_SETOWN: ::c_int = 8; pub const VEOF: usize = 4; pub const VEOL: usize = 11; pub const VEOL2: usize = 16; pub const VMIN: usize = 6; pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; pub const SFD_NONBLOCK: ::c_int = 0x0800; pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; extern { pub fn getnameinfo(sa: *const ::sockaddr, salen: ::socklen_t, host: *mut ::c_char, hostlen: ::socklen_t, serv: *mut ::c_char, sevlen: ::socklen_t, flags: ::c_int) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; pub fn ptrace(request: ::c_int, ...) -> ::c_long; } deps/libc-0.2.4/src/unix/notbsd/linux/mips.rs0000664000175000017500000003506012634314567016042 0ustar pub type c_char = i8; pub type c_long = i32; pub type c_ulong = u32; pub type clock_t = i32; pub type time_t = i32; pub type suseconds_t = i32; pub type wchar_t = i32; pub type off_t = i32; pub type ino_t = u32; pub type blkcnt_t = i32; pub type blksize_t = i32; pub type nlink_t = u32; s! { pub struct stat { pub st_dev: ::c_ulong, st_pad1: [::c_long; 3], pub st_ino: ::ino_t, pub st_mode: ::mode_t, pub st_nlink: ::nlink_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, pub st_rdev: ::c_ulong, pub st_pad2: [::c_long; 2], pub st_size: ::off_t, st_pad3: ::c_long, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, pub st_blksize: ::blksize_t, pub st_blocks: ::blkcnt_t, st_pad5: [::c_long; 14], } pub struct stat64 { pub st_dev: ::c_ulong, st_pad1: [::c_long; 3], pub st_ino: ::ino64_t, pub st_mode: ::mode_t, pub st_nlink: ::nlink_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, pub st_rdev: ::c_ulong, st_pad2: [::c_long; 2], pub st_size: ::off64_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, pub st_blksize: ::blksize_t, st_pad3: ::c_long, pub st_blocks: ::blkcnt64_t, st_pad5: [::c_long; 14], } pub struct pthread_attr_t { __size: [u32; 9] } pub struct sigaction { pub sa_flags: ::c_uint, pub sa_sigaction: ::sighandler_t, pub sa_mask: sigset_t, _restorer: *mut ::c_void, _resv: [::c_int; 1], } pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_size: ::size_t, pub ss_flags: ::c_int, } pub struct sigset_t { __val: [::c_ulong; 32], } pub struct siginfo_t { pub si_signo: ::c_int, pub si_code: ::c_int, pub si_errno: ::c_int, pub _pad: [::c_int; 29], } pub struct glob64_t { pub gl_pathc: ::size_t, pub gl_pathv: *mut *mut ::c_char, pub gl_offs: ::size_t, pub gl_flags: ::c_int, __unused1: *mut ::c_void, __unused2: *mut ::c_void, __unused3: *mut ::c_void, __unused4: *mut ::c_void, __unused5: *mut ::c_void, } pub struct ipc_perm { pub __key: ::key_t, pub uid: ::uid_t, pub gid: ::gid_t, pub cuid: ::uid_t, pub cgid: ::gid_t, pub mode: ::c_uint, pub __seq: ::c_ushort, __pad1: ::c_ushort, __unused1: ::c_ulong, __unused2: ::c_ulong } pub struct shmid_ds { pub shm_perm: ::ipc_perm, pub shm_segsz: ::size_t, pub shm_atime: ::time_t, pub shm_dtime: ::time_t, pub shm_ctime: ::time_t, pub shm_cpid: ::pid_t, pub shm_lpid: ::pid_t, pub shm_nattch: ::shmatt_t, __unused4: ::c_ulong, __unused5: ::c_ulong } pub struct statfs { pub f_type: ::c_long, pub f_bsize: ::c_long, pub f_frsize: ::c_long, pub f_blocks: ::fsblkcnt_t, pub f_bfree: ::fsblkcnt_t, pub f_files: ::fsblkcnt_t, pub f_ffree: ::fsblkcnt_t, pub f_bavail: ::fsblkcnt_t, pub f_fsid: ::fsid_t, pub f_namelen: ::c_long, f_spare: [::c_long; 6], } pub struct msghdr { pub msg_name: *mut ::c_void, pub msg_namelen: ::socklen_t, pub msg_iov: *mut ::iovec, pub msg_iovlen: ::size_t, pub msg_control: *mut ::c_void, pub msg_controllen: ::size_t, pub msg_flags: ::c_int, } pub struct termios { pub c_iflag: ::tcflag_t, pub c_oflag: ::tcflag_t, pub c_cflag: ::tcflag_t, pub c_lflag: ::tcflag_t, pub c_line: ::cc_t, pub c_cc: [::cc_t; ::NCCS], } pub struct flock { pub l_type: ::c_short, pub l_whence: ::c_short, pub l_start: ::off_t, pub l_len: ::off_t, pub l_sysid: ::c_long, pub l_pid: ::pid_t, pad: [::c_long; 4], } } pub const BUFSIZ: ::c_uint = 8192; pub const TMP_MAX: ::c_uint = 238328; pub const FOPEN_MAX: ::c_uint = 16; pub const POSIX_MADV_DONTNEED: ::c_int = 4; pub const _SC_2_C_VERSION: ::c_int = 96; pub const RUSAGE_THREAD: ::c_int = 1; pub const O_ACCMODE: ::c_int = 3; pub const O_DIRECT: ::c_int = 0x8000; pub const O_DIRECTORY: ::c_int = 0x10000; pub const O_NOFOLLOW: ::c_int = 0x20000; pub const RUSAGE_CHILDREN: ::c_int = -1; pub const ST_RELATIME: ::c_ulong = 4096; pub const NI_MAXHOST: ::socklen_t = 1025; pub const RLIMIT_NOFILE: ::c_int = 5; pub const RLIMIT_AS: ::c_int = 6; pub const RLIMIT_RSS: ::c_int = 7; pub const RLIMIT_NPROC: ::c_int = 8; pub const RLIMIT_MEMLOCK: ::c_int = 9; pub const RLIMIT_NLIMITS: ::c_int = 15; pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff; pub const O_APPEND: ::c_int = 8; pub const O_CREAT: ::c_int = 256; pub const O_EXCL: ::c_int = 1024; pub const O_NOCTTY: ::c_int = 2048; pub const O_NONBLOCK: ::c_int = 128; pub const O_SYNC: ::c_int = 0x10; pub const O_RSYNC: ::c_int = 0x10; pub const O_DSYNC: ::c_int = 0x10; pub const O_FSYNC: ::c_int = 0x10; pub const O_ASYNC: ::c_int = 0x1000; pub const O_NDELAY: ::c_int = 0x80; pub const EDEADLK: ::c_int = 45; pub const ENAMETOOLONG: ::c_int = 78; pub const ENOLCK: ::c_int = 46; pub const ENOSYS: ::c_int = 89; pub const ENOTEMPTY: ::c_int = 93; pub const ELOOP: ::c_int = 90; pub const ENOMSG: ::c_int = 35; pub const EIDRM: ::c_int = 36; pub const ECHRNG: ::c_int = 37; pub const EL2NSYNC: ::c_int = 38; pub const EL3HLT: ::c_int = 39; pub const EL3RST: ::c_int = 40; pub const ELNRNG: ::c_int = 41; pub const EUNATCH: ::c_int = 42; pub const ENOCSI: ::c_int = 43; pub const EL2HLT: ::c_int = 44; pub const EBADE: ::c_int = 50; pub const EBADR: ::c_int = 51; pub const EXFULL: ::c_int = 52; pub const ENOANO: ::c_int = 53; pub const EBADRQC: ::c_int = 54; pub const EBADSLT: ::c_int = 55; pub const EDEADLOCK: ::c_int = 56; pub const EMULTIHOP: ::c_int = 74; pub const EOVERFLOW: ::c_int = 79; pub const ENOTUNIQ: ::c_int = 80; pub const EBADFD: ::c_int = 81; pub const EBADMSG: ::c_int = 77; pub const EREMCHG: ::c_int = 82; pub const ELIBACC: ::c_int = 83; pub const ELIBBAD: ::c_int = 84; pub const ELIBSCN: ::c_int = 85; pub const ELIBMAX: ::c_int = 86; pub const ELIBEXEC: ::c_int = 87; pub const EILSEQ: ::c_int = 88; pub const ERESTART: ::c_int = 91; pub const ESTRPIPE: ::c_int = 92; pub const EUSERS: ::c_int = 94; pub const ENOTSOCK: ::c_int = 95; pub const EDESTADDRREQ: ::c_int = 96; pub const EMSGSIZE: ::c_int = 97; pub const EPROTOTYPE: ::c_int = 98; pub const ENOPROTOOPT: ::c_int = 99; pub const EPROTONOSUPPORT: ::c_int = 120; pub const ESOCKTNOSUPPORT: ::c_int = 121; pub const EOPNOTSUPP: ::c_int = 122; pub const EPFNOSUPPORT: ::c_int = 123; pub const EAFNOSUPPORT: ::c_int = 124; pub const EADDRINUSE: ::c_int = 125; pub const EADDRNOTAVAIL: ::c_int = 126; pub const ENETDOWN: ::c_int = 127; pub const ENETUNREACH: ::c_int = 128; pub const ENETRESET: ::c_int = 129; pub const ECONNABORTED: ::c_int = 130; pub const ECONNRESET: ::c_int = 131; pub const ENOBUFS: ::c_int = 132; pub const EISCONN: ::c_int = 133; pub const ENOTCONN: ::c_int = 134; pub const ESHUTDOWN: ::c_int = 143; pub const ETOOMANYREFS: ::c_int = 144; pub const ETIMEDOUT: ::c_int = 145; pub const ECONNREFUSED: ::c_int = 146; pub const EHOSTDOWN: ::c_int = 147; pub const EHOSTUNREACH: ::c_int = 148; pub const EALREADY: ::c_int = 149; pub const EINPROGRESS: ::c_int = 150; pub const ESTALE: ::c_int = 151; pub const EUCLEAN: ::c_int = 135; pub const ENOTNAM: ::c_int = 137; pub const ENAVAIL: ::c_int = 138; pub const EISNAM: ::c_int = 139; pub const EREMOTEIO: ::c_int = 140; pub const EDQUOT: ::c_int = 1133; pub const ENOMEDIUM: ::c_int = 159; pub const EMEDIUMTYPE: ::c_int = 160; pub const ECANCELED: ::c_int = 158; pub const ENOKEY: ::c_int = 161; pub const EKEYEXPIRED: ::c_int = 162; pub const EKEYREVOKED: ::c_int = 163; pub const EKEYREJECTED: ::c_int = 164; pub const EOWNERDEAD: ::c_int = 165; pub const ENOTRECOVERABLE: ::c_int = 166; pub const ERFKILL: ::c_int = 167; pub const MAP_NORESERVE: ::c_int = 0x400; pub const MAP_ANON: ::c_int = 0x800; pub const MAP_ANONYMOUS: ::c_int = 0x800; pub const MAP_GROWSDOWN: ::c_int = 0x1000; pub const MAP_DENYWRITE: ::c_int = 0x2000; pub const MAP_EXECUTABLE: ::c_int = 0x4000; pub const MAP_LOCKED: ::c_int = 0x8000; pub const MAP_POPULATE: ::c_int = 0x10000; pub const MAP_NONBLOCK: ::c_int = 0x20000; pub const SOCK_STREAM: ::c_int = 2; pub const SOCK_DGRAM: ::c_int = 1; pub const SOL_SOCKET: ::c_int = 0xffff; pub const SO_REUSEADDR: ::c_int = 4; pub const SO_TYPE: ::c_int = 4104; pub const SO_ERROR: ::c_int = 4103; pub const SO_DONTROUTE: ::c_int = 16; pub const SO_BROADCAST: ::c_int = 32; pub const SO_SNDBUF: ::c_int = 4097; pub const SO_RCVBUF: ::c_int = 4098; pub const SO_KEEPALIVE: ::c_int = 8; pub const SO_OOBINLINE: ::c_int = 256; pub const SO_LINGER: ::c_int = 128; pub const SO_RCVLOWAT: ::c_int = 4100; pub const SO_SNDLOWAT: ::c_int = 4099; pub const SO_RCVTIMEO: ::c_int = 4102; pub const SO_SNDTIMEO: ::c_int = 4101; pub const SO_ACCEPTCONN: ::c_int = 4105; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const FIOCLEX: ::c_ulong = 0x6601; pub const FIONBIO: ::c_ulong = 0x667e; pub const SA_ONSTACK: ::c_uint = 0x08000000; pub const SA_SIGINFO: ::c_uint = 0x00000008; pub const SA_NOCLDWAIT: ::c_uint = 0x00010000; pub const SIGCHLD: ::c_int = 18; pub const SIGBUS: ::c_int = 10; pub const SIGTTIN: ::c_int = 26; pub const SIGTTOU: ::c_int = 27; pub const SIGXCPU: ::c_int = 30; pub const SIGXFSZ: ::c_int = 31; pub const SIGVTALRM: ::c_int = 28; pub const SIGPROF: ::c_int = 29; pub const SIGWINCH: ::c_int = 20; pub const SIGUSR1: ::c_int = 16; pub const SIGUSR2: ::c_int = 17; pub const SIGCONT: ::c_int = 25; pub const SIGSTOP: ::c_int = 23; pub const SIGTSTP: ::c_int = 24; pub const SIGURG: ::c_int = 21; pub const SIGIO: ::c_int = 22; pub const SIGSYS: ::c_int = 12; pub const SIGPOLL: ::c_int = 22; pub const SIGPWR: ::c_int = 19; pub const SIG_SETMASK: ::c_int = 3; pub const SIG_BLOCK: ::c_int = 0x1; pub const SIG_UNBLOCK: ::c_int = 0x2; pub const PTHREAD_STACK_MIN: ::size_t = 131072; pub const MS_VERBOSE: ::c_ulong = 0x8000; pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; pub const TMPFS_MAGIC: ::c_long = 0x01021994; pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; pub const VEOF: usize = 16; pub const VEOL: usize = 17; pub const VEOL2: usize = 6; pub const VMIN: usize = 4; pub const IEXTEN: ::tcflag_t = 0x00000100; pub const TOSTOP: ::tcflag_t = 0x00008000; pub const FLUSHO: ::tcflag_t = 0x00002000; pub const IUTF8: ::tcflag_t = 0x00004000; pub const TCSANOW: ::c_int = 0x540e; pub const TCSADRAIN: ::c_int = 0x540f; pub const TCSAFLUSH: ::c_int = 0x5410; pub const CPU_SETSIZE: ::c_int = 0x400; pub const PTRACE_TRACEME: ::c_uint = 0; pub const PTRACE_PEEKTEXT: ::c_uint = 1; pub const PTRACE_PEEKDATA: ::c_uint = 2; pub const PTRACE_PEEKUSER: ::c_uint = 3; pub const PTRACE_POKETEXT: ::c_uint = 4; pub const PTRACE_POKEDATA: ::c_uint = 5; pub const PTRACE_POKEUSER: ::c_uint = 6; pub const PTRACE_CONT: ::c_uint = 7; pub const PTRACE_KILL: ::c_uint = 8; pub const PTRACE_SINGLESTEP: ::c_uint = 9; pub const PTRACE_ATTACH: ::c_uint = 16; pub const PTRACE_DETACH: ::c_uint = 17; pub const PTRACE_SYSCALL: ::c_uint = 24; pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200; pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201; pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202; pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203; pub const PTRACE_GETFPREGS: ::c_uint = 14; pub const PTRACE_SETFPREGS: ::c_uint = 15; pub const PTRACE_GETFPXREGS: ::c_uint = 18; pub const PTRACE_SETFPXREGS: ::c_uint = 19; pub const PTRACE_GETREGS: ::c_uint = 12; pub const PTRACE_SETREGS: ::c_uint = 13; pub const EFD_NONBLOCK: ::c_int = 0x80; pub const F_GETLK: ::c_int = 14; pub const F_GETOWN: ::c_int = 23; pub const F_SETOWN: ::c_int = 24; pub const SFD_NONBLOCK: ::c_int = 0x80; extern { pub fn sysctl(name: *mut ::c_int, namelen: ::c_int, oldp: *mut ::c_void, oldlenp: *mut ::size_t, newp: *mut ::c_void, newlen: ::size_t) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int; pub fn glob64(pattern: *const ::c_char, flags: ::c_int, errfunc: ::dox::Option ::c_int>, pglob: *mut glob64_t) -> ::c_int; pub fn globfree64(pglob: *mut glob64_t); pub fn getnameinfo(sa: *const ::sockaddr, salen: ::socklen_t, host: *mut ::c_char, hostlen: ::socklen_t, serv: *mut ::c_char, sevlen: ::socklen_t, flags: ::c_uint) -> ::c_int; pub fn eventfd(init: ::c_int, flags: ::c_int) -> ::c_int; pub fn ptrace(request: ::c_uint, ...) -> ::c_long; } deps/libc-0.2.4/src/unix/notbsd/linux/mod.rs0000664000175000017500000004534612634314567015661 0ustar //! Linux-specific definitions for linux-like values pub type useconds_t = u32; pub type dev_t = u64; pub type socklen_t = u32; pub type pthread_t = c_ulong; pub type mode_t = u32; pub type ino64_t = u64; pub type off64_t = i64; pub type blkcnt64_t = i64; pub type rlim64_t = u64; pub type fsblkcnt_t = ::c_ulong; pub type fsfilcnt_t = ::c_ulong; pub type key_t = ::c_int; pub type shmatt_t = ::c_ulong; pub enum fpos64_t {} // TODO: fill this out with a struct s! { pub struct dirent { pub d_ino: ::ino_t, pub d_off: ::off_t, pub d_reclen: ::c_ushort, pub d_type: ::c_uchar, pub d_name: [::c_char; 256], } pub struct dirent64 { pub d_ino: ::ino64_t, pub d_off: ::off64_t, pub d_reclen: ::c_ushort, pub d_type: ::c_uchar, pub d_name: [::c_char; 256], } pub struct rlimit64 { pub rlim_cur: rlim64_t, pub rlim_max: rlim64_t, } pub struct glob_t { pub gl_pathc: ::size_t, pub gl_pathv: *mut *mut c_char, pub gl_offs: ::size_t, pub gl_flags: ::c_int, __unused1: *mut ::c_void, __unused2: *mut ::c_void, __unused3: *mut ::c_void, __unused4: *mut ::c_void, __unused5: *mut ::c_void, } pub struct ifaddrs { pub ifa_next: *mut ifaddrs, pub ifa_name: *mut c_char, pub ifa_flags: ::c_uint, pub ifa_addr: *mut ::sockaddr, pub ifa_netmask: *mut ::sockaddr, pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union pub ifa_data: *mut ::c_void } pub struct pthread_mutex_t { #[cfg(any(target_arch = "mips", target_arch = "mipsel", target_arch = "arm"))] __align: [::c_long; 0], #[cfg(not(any(target_arch = "mips", target_arch = "mipsel", target_arch = "arm")))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } pub struct pthread_rwlock_t { #[cfg(any(target_arch = "mips", target_arch = "mipsel", target_arch = "arm"))] __align: [::c_long; 0], #[cfg(not(any(target_arch = "mips", target_arch = "mipsel", target_arch = "arm")))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], } pub struct pthread_mutexattr_t { #[cfg(target_arch = "x86_64")] __align: [::c_int; 0], #[cfg(not(target_arch = "x86_64"))] __align: [::c_long; 0], size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } pub struct pthread_cond_t { __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_COND_T], } pub struct passwd { pub pw_name: *mut ::c_char, pub pw_passwd: *mut ::c_char, pub pw_uid: ::uid_t, pub pw_gid: ::gid_t, pub pw_gecos: *mut ::c_char, pub pw_dir: *mut ::c_char, pub pw_shell: *mut ::c_char, } pub struct statvfs { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, pub f_blocks: ::fsblkcnt_t, pub f_bfree: ::fsblkcnt_t, pub f_bavail: ::fsblkcnt_t, pub f_files: ::fsfilcnt_t, pub f_ffree: ::fsfilcnt_t, pub f_favail: ::fsfilcnt_t, pub f_fsid: ::c_ulong, #[cfg(target_pointer_width = "32")] pub __f_unused: ::c_int, pub f_flag: ::c_ulong, pub f_namemax: ::c_ulong, __f_spare: [::c_int; 6], } pub struct sockaddr_nl { pub nl_family: ::sa_family_t, nl_pad: ::c_ushort, pub nl_pid: u32, pub nl_groups: u32 } pub struct dqblk { pub dqb_bhardlimit: ::uint64_t, pub dqb_bsoftlimit: ::uint64_t, pub dqb_curspace: ::uint64_t, pub dqb_ihardlimit: ::uint64_t, pub dqb_isoftlimit: ::uint64_t, pub dqb_curinodes: ::uint64_t, pub dqb_btime: ::uint64_t, pub dqb_itime: ::uint64_t, pub dqb_valid: ::uint32_t, } pub struct signalfd_siginfo { pub ssi_signo: ::uint32_t, pub ssi_errno: ::int32_t, pub ssi_code: ::int32_t, pub ssi_pid: ::uint32_t, pub ssi_uid: ::uint32_t, pub ssi_fd: ::int32_t, pub ssi_tid: ::uint32_t, pub ssi_band: ::uint32_t, pub ssi_overrun: ::uint32_t, pub ssi_trapno: ::uint32_t, pub ssi_status: ::int32_t, pub ssi_int: ::int32_t, pub ssi_ptr: ::uint64_t, pub ssi_utime: ::uint64_t, pub ssi_stime: ::uint64_t, pub ssi_addr: ::uint64_t, _pad: [::uint8_t; 48], } pub struct fsid_t { __val: [::c_int; 2], } pub struct mq_attr { pub mq_flags: ::c_long, pub mq_maxmsg: ::c_long, pub mq_msgsize: ::c_long, pub mq_curmsgs: ::c_long, pad: [::c_long; 4] } pub struct cpu_set_t { #[cfg(target_pointer_width = "32")] bits: [u32; 32], #[cfg(target_pointer_width = "64")] bits: [u64; 16], } } pub const FILENAME_MAX: ::c_uint = 4096; pub const L_tmpnam: ::c_uint = 20; pub const _PC_NAME_MAX: ::c_int = 3; pub const _SC_ARG_MAX: ::c_int = 0; pub const _SC_CHILD_MAX: ::c_int = 1; pub const _SC_CLK_TCK: ::c_int = 2; pub const _SC_NGROUPS_MAX: ::c_int = 3; pub const _SC_OPEN_MAX: ::c_int = 4; pub const _SC_STREAM_MAX: ::c_int = 5; pub const _SC_TZNAME_MAX: ::c_int = 6; pub const _SC_JOB_CONTROL: ::c_int = 7; pub const _SC_SAVED_IDS: ::c_int = 8; pub const _SC_REALTIME_SIGNALS: ::c_int = 9; pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10; pub const _SC_TIMERS: ::c_int = 11; pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12; pub const _SC_PRIORITIZED_IO: ::c_int = 13; pub const _SC_SYNCHRONIZED_IO: ::c_int = 14; pub const _SC_FSYNC: ::c_int = 15; pub const _SC_MAPPED_FILES: ::c_int = 16; pub const _SC_MEMLOCK: ::c_int = 17; pub const _SC_MEMLOCK_RANGE: ::c_int = 18; pub const _SC_MEMORY_PROTECTION: ::c_int = 19; pub const _SC_MESSAGE_PASSING: ::c_int = 20; pub const _SC_SEMAPHORES: ::c_int = 21; pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22; pub const _SC_AIO_LISTIO_MAX: ::c_int = 23; pub const _SC_AIO_MAX: ::c_int = 24; pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25; pub const _SC_DELAYTIMER_MAX: ::c_int = 26; pub const _SC_MQ_OPEN_MAX: ::c_int = 27; pub const _SC_MQ_PRIO_MAX: ::c_int = 28; pub const _SC_VERSION: ::c_int = 29; pub const _SC_PAGESIZE: ::c_int = 30; pub const _SC_RTSIG_MAX: ::c_int = 31; pub const _SC_SEM_NSEMS_MAX: ::c_int = 32; pub const _SC_SEM_VALUE_MAX: ::c_int = 33; pub const _SC_SIGQUEUE_MAX: ::c_int = 34; pub const _SC_TIMER_MAX: ::c_int = 35; pub const _SC_BC_BASE_MAX: ::c_int = 36; pub const _SC_BC_DIM_MAX: ::c_int = 37; pub const _SC_BC_SCALE_MAX: ::c_int = 38; pub const _SC_BC_STRING_MAX: ::c_int = 39; pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40; pub const _SC_EXPR_NEST_MAX: ::c_int = 42; pub const _SC_LINE_MAX: ::c_int = 43; pub const _SC_RE_DUP_MAX: ::c_int = 44; pub const _SC_2_VERSION: ::c_int = 46; pub const _SC_2_C_BIND: ::c_int = 47; pub const _SC_2_C_DEV: ::c_int = 48; pub const _SC_2_FORT_DEV: ::c_int = 49; pub const _SC_2_FORT_RUN: ::c_int = 50; pub const _SC_2_SW_DEV: ::c_int = 51; pub const _SC_2_LOCALEDEF: ::c_int = 52; pub const _SC_IOV_MAX: ::c_int = 60; pub const _SC_THREADS: ::c_int = 67; pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68; pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69; pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70; pub const _SC_LOGIN_NAME_MAX: ::c_int = 71; pub const _SC_TTY_NAME_MAX: ::c_int = 72; pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73; pub const _SC_THREAD_KEYS_MAX: ::c_int = 74; pub const _SC_THREAD_STACK_MIN: ::c_int = 75; pub const _SC_THREAD_THREADS_MAX: ::c_int = 76; pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77; pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78; pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79; pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80; pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81; pub const _SC_NPROCESSORS_ONLN: ::c_int = 84; pub const _SC_ATEXIT_MAX: ::c_int = 87; pub const _SC_XOPEN_VERSION: ::c_int = 89; pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90; pub const _SC_XOPEN_UNIX: ::c_int = 91; pub const _SC_XOPEN_CRYPT: ::c_int = 92; pub const _SC_XOPEN_ENH_I18N: ::c_int = 93; pub const _SC_XOPEN_SHM: ::c_int = 94; pub const _SC_2_CHAR_TERM: ::c_int = 95; pub const _SC_2_UPE: ::c_int = 97; pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125; pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126; pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128; pub const _SC_XOPEN_LEGACY: ::c_int = 129; pub const _SC_XOPEN_REALTIME: ::c_int = 130; pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131; pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY; pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY; pub const GLOB_ERR: ::c_int = 1 << 0; pub const GLOB_MARK: ::c_int = 1 << 1; pub const GLOB_NOSORT: ::c_int = 1 << 2; pub const GLOB_DOOFFS: ::c_int = 1 << 3; pub const GLOB_NOCHECK: ::c_int = 1 << 4; pub const GLOB_APPEND: ::c_int = 1 << 5; pub const GLOB_NOESCAPE: ::c_int = 1 << 6; pub const GLOB_NOSPACE: ::c_int = 1; pub const GLOB_ABORTED: ::c_int = 2; pub const GLOB_NOMATCH: ::c_int = 3; pub const POSIX_MADV_NORMAL: ::c_int = 0; pub const POSIX_MADV_RANDOM: ::c_int = 1; pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; pub const POSIX_MADV_WILLNEED: ::c_int = 3; pub const S_IEXEC: mode_t = 64; pub const S_IWRITE: mode_t = 128; pub const S_IREAD: mode_t = 256; pub const F_LOCK: ::c_int = 1; pub const F_TEST: ::c_int = 3; pub const F_TLOCK: ::c_int = 2; pub const F_ULOCK: ::c_int = 0; pub const ST_RDONLY: ::c_ulong = 1; pub const ST_NOSUID: ::c_ulong = 2; pub const ST_NODEV: ::c_ulong = 4; pub const ST_NOEXEC: ::c_ulong = 8; pub const ST_SYNCHRONOUS: ::c_ulong = 16; pub const ST_MANDLOCK: ::c_ulong = 64; pub const ST_WRITE: ::c_ulong = 128; pub const ST_APPEND: ::c_ulong = 256; pub const ST_IMMUTABLE: ::c_ulong = 512; pub const ST_NOATIME: ::c_ulong = 1024; pub const ST_NODIRATIME: ::c_ulong = 2048; pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void; pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub const MAP_32BIT: ::c_int = 0x0040; pub const TCP_MD5SIG: ::c_int = 14; pub const F_DUPFD_CLOEXEC: ::c_int = 1030; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { __align: [], size: [0; __SIZEOF_PTHREAD_MUTEX_T], }; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { __align: [], size: [0; __SIZEOF_PTHREAD_COND_T], }; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __align: [], size: [0; __SIZEOF_PTHREAD_RWLOCK_T], }; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const __SIZEOF_PTHREAD_COND_T: usize = 48; pub const SCHED_OTHER: ::c_int = 0; pub const SCHED_FIFO: ::c_int = 1; pub const SCHED_RR: ::c_int = 2; pub const SCHED_BATCH: ::c_int = 3; pub const SCHED_IDLE: ::c_int = 5; pub const IPC_CREAT: ::c_int = 0o1000; pub const IPC_EXCL: ::c_int = 0o2000; pub const IPC_NOWAIT: ::c_int = 0o4000; pub const IPC_RMID: ::c_int = 0; pub const IPC_SET: ::c_int = 1; pub const IPC_STAT: ::c_int = 2; pub const IPC_INFO: ::c_int = 3; pub const SHM_R: ::c_int = 0o400; pub const SHM_W: ::c_int = 0o200; pub const SHM_RDONLY: ::c_int = 0o10000; pub const SHM_RND: ::c_int = 0o20000; pub const SHM_REMAP: ::c_int = 0o40000; pub const SHM_EXEC: ::c_int = 0o100000; pub const SHM_LOCK: ::c_int = 11; pub const SHM_UNLOCK: ::c_int = 12; pub const SHM_HUGETLB: ::c_int = 0o4000; pub const SHM_NORESERVE: ::c_int = 0o10000; pub const MS_RELATIME: ::c_ulong = 0x200000; pub const MS_KERNMOUNT: ::c_ulong = 0x400000; pub const MS_I_VERSION: ::c_ulong = 0x800000; pub const MS_STRICTATIME: ::c_ulong = 0x01000000; pub const MS_RMT_MASK: ::c_ulong = 0x800051; pub const EPOLLRDHUP: ::c_int = 0x2000; pub const EPOLLONESHOT: ::c_int = 0x40000000; pub const QFMT_VFS_OLD: ::c_int = 1; pub const QFMT_VFS_V0: ::c_int = 2; pub const SFD_CLOEXEC: ::c_int = 0x080000; pub const EFD_SEMAPHORE: ::c_int = 0x1; pub const NCCS: usize = 32; pub const CLONE_NEWUTS: ::c_uint = 0x04000000; pub const CLONE_NEWIPC: ::c_uint = 0x08000000; pub const CLONE_NEWUSER: ::c_uint = 0x10000000; pub const CLONE_NEWPID: ::c_uint = 0x20000000; pub const CLONE_NEWNET: ::c_uint = 0x40000000; pub const CLONE_IO: ::c_uint = 0x80000000; extern { pub fn shm_open(name: *const c_char, oflag: ::c_int, mode: mode_t) -> ::c_int; pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void, shmflg: ::c_int) -> *mut ::c_void; pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; pub fn shmctl(shmid: ::c_int, cmd: ::c_int, buf: *mut ::shmid_ds) -> ::c_int; pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; pub fn __errno_location() -> *mut ::c_int; pub fn fopen64(filename: *const c_char, mode: *const c_char) -> *mut ::FILE; pub fn freopen64(filename: *const c_char, mode: *const c_char, file: *mut ::FILE) -> *mut ::FILE; pub fn tmpfile64() -> *mut ::FILE; pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int; pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int; pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int; pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int; pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; pub fn creat64(path: *const c_char, mode: mode_t) -> ::c_int; pub fn lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t; pub fn pread64(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, offset: off64_t) -> ::ssize_t; pub fn pwrite64(fd: ::c_int, buf: *const ::c_void, count: ::size_t, offset: off64_t) -> ::ssize_t; pub fn mmap64(addr: *mut ::c_void, len: ::size_t, prot: ::c_int, flags: ::c_int, fd: ::c_int, offset: off64_t) -> *mut ::c_void; pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int; pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int; pub fn readdir64_r(dirp: *mut ::DIR, entry: *mut ::dirent64, result: *mut *mut ::dirent64) -> ::c_int; pub fn getrlimit64(resource: ::c_int, rlim: *mut rlimit64) -> ::c_int; pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int; pub fn fseeko64(stream: *mut ::FILE, offset: ::off64_t, whence: ::c_int) -> ::c_int; pub fn ftello64(stream: *mut ::FILE) -> ::off64_t; pub fn fallocate(fd: ::c_int, mode: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; pub fn readahead(fd: ::c_int, offset: ::off64_t, count: ::size_t) -> ::ssize_t; pub fn getxattr(path: *const c_char, name: *const c_char, value: *mut ::c_void, size: ::size_t) -> ::ssize_t; pub fn lgetxattr(path: *const c_char, name: *const c_char, value: *mut ::c_void, size: ::size_t) -> ::ssize_t; pub fn fgetxattr(filedes: ::c_int, name: *const c_char, value: *mut ::c_void, size: ::size_t) -> ::ssize_t; pub fn setxattr(path: *const c_char, name: *const c_char, value: *const ::c_void, size: ::size_t, flags: ::c_int) -> ::c_int; pub fn lsetxattr(path: *const c_char, name: *const c_char, value: *const ::c_void, size: ::size_t, flags: ::c_int) -> ::c_int; pub fn fsetxattr(filedes: ::c_int, name: *const c_char, value: *const ::c_void, size: ::size_t, flags: ::c_int) -> ::c_int; pub fn listxattr(path: *const c_char, list: *mut c_char, size: ::size_t) -> ::ssize_t; pub fn llistxattr(path: *const c_char, list: *mut c_char, size: ::size_t) -> ::ssize_t; pub fn flistxattr(filedes: ::c_int, list: *mut c_char, size: ::size_t) -> ::ssize_t; pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int; pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int; pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int; pub fn signalfd(fd: ::c_int, mask: *const ::sigset_t, flags: ::c_int) -> ::c_int; pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t; pub fn preadv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t; pub fn quotactl(cmd: ::c_int, special: *const ::c_char, id: ::c_int, data: *mut ::c_char) -> ::c_int; pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; pub fn mq_close(mqd: ::mqd_t) -> ::c_int; pub fn mq_unlink(name: *const ::c_char) -> ::c_int; pub fn mq_receive(mqd: ::mqd_t, msg_ptr: *mut ::c_char, msg_len: ::size_t, msq_prio: *mut ::c_uint) -> ::ssize_t; pub fn mq_send(mqd: ::mqd_t, msg_ptr: *const ::c_char, msg_len: ::size_t, msq_prio: ::c_uint) -> ::c_int; pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; pub fn mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, oldattr: *mut ::mq_attr) -> ::c_int; pub fn sched_getaffinity(pid: ::pid_t, cpusetsize: ::size_t, cpuset: *mut cpu_set_t) -> ::c_int; pub fn sched_setaffinity(pid: ::pid_t, cpusetsize: ::size_t, cpuset: *const cpu_set_t) -> ::c_int; pub fn epoll_pwait(epfd: ::c_int, events: *mut ::epoll_event, maxevents: ::c_int, timeout: ::c_int, sigmask: *const ::sigset_t) -> ::c_int; pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int; pub fn unshare(flags: ::c_int) -> ::c_int; pub fn syscall(num: ::c_long, ...) -> ::c_long; pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; } cfg_if! { if #[cfg(target_env = "musl")] { mod musl; pub use self::musl::*; } else if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] { mod mips; pub use self::mips::*; } else { mod other; pub use self::other::*; } } pub const AF_NETLINK: ::c_int = 16; deps/libc-0.2.4/src/unix/notbsd/linux/other/0000755000000000000000000000000012666635520017415 5ustar rootrootdeps/libc-0.2.4/src/unix/notbsd/linux/other/b32/0000755000000000000000000000000012666635520020003 5ustar rootrootdeps/libc-0.2.4/src/unix/notbsd/linux/other/b32/x86.rs0000664000175000017500000000025012634314567017217 0ustar pub type c_char = i8; pub type wchar_t = i32; pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; pub const O_NOFOLLOW: ::c_int = 0x20000; deps/libc-0.2.4/src/unix/notbsd/linux/other/b32/arm.rs0000664000175000017500000000024712634314567017357 0ustar pub type c_char = u8; pub type wchar_t = u32; pub const O_DIRECT: ::c_int = 0x10000; pub const O_DIRECTORY: ::c_int = 0x4000; pub const O_NOFOLLOW: ::c_int = 0x8000; deps/libc-0.2.4/src/unix/notbsd/linux/other/b32/mod.rs0000664000175000017500000000451712634314567017363 0ustar //! 32-bit specific definitions for linux-like values pub type c_long = i32; pub type c_ulong = u32; pub type clock_t = i32; pub type time_t = i32; pub type suseconds_t = i32; pub type ino_t = u32; pub type off_t = i32; pub type blkcnt_t = i32; pub type __fsword_t = i32; pub type blksize_t = i32; pub type nlink_t = u32; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const PTRACE_GETFPREGS: ::c_uint = 14; pub const PTRACE_SETFPREGS: ::c_uint = 15; pub const PTRACE_GETFPXREGS: ::c_uint = 18; pub const PTRACE_SETFPXREGS: ::c_uint = 19; pub const PTRACE_GETREGS: ::c_uint = 12; pub const PTRACE_SETREGS: ::c_uint = 13; s! { pub struct stat { pub st_dev: ::dev_t, __pad1: ::c_short, pub st_ino: ::ino_t, pub st_mode: ::mode_t, pub st_nlink: ::nlink_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, pub st_rdev: ::dev_t, __pad2: ::c_short, pub st_size: ::off_t, pub st_blksize: ::blksize_t, pub st_blocks: ::blkcnt_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, __unused4: ::c_long, __unused5: ::c_long, } pub struct stat64 { pub st_dev: ::dev_t, __pad1: ::c_uint, __st_ino: ::ino_t, pub st_mode: ::mode_t, pub st_nlink: ::nlink_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, pub st_rdev: ::dev_t, __pad2: ::c_uint, pub st_size: ::off64_t, pub st_blksize: ::blksize_t, pub st_blocks: ::blkcnt64_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, pub st_ino: ::ino64_t, } pub struct pthread_attr_t { __size: [u32; 9] } pub struct sigset_t { __val: [::c_ulong; 32], } } cfg_if! { if #[cfg(target_arch = "x86")] { mod x86; pub use self::x86::*; } else if #[cfg(target_arch = "arm")] { mod arm; pub use self::arm::*; } else { // ... } } deps/libc-0.2.4/src/unix/notbsd/linux/other/mod.rs0000664000175000017500000003505112634314567016772 0ustar s! { pub struct sigaction { pub sa_sigaction: ::sighandler_t, pub sa_mask: ::sigset_t, pub sa_flags: ::c_int, _restorer: *mut ::c_void, } pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, pub ss_size: ::size_t } pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, pub si_code: ::c_int, pub _pad: [::c_int; 29], _align: [usize; 0], } pub struct glob64_t { pub gl_pathc: ::size_t, pub gl_pathv: *mut *mut ::c_char, pub gl_offs: ::size_t, pub gl_flags: ::c_int, __unused1: *mut ::c_void, __unused2: *mut ::c_void, __unused3: *mut ::c_void, __unused4: *mut ::c_void, __unused5: *mut ::c_void, } pub struct ucred { pub pid: ::pid_t, pub uid: ::uid_t, pub gid: ::gid_t, } pub struct statfs { pub f_type: __fsword_t, pub f_bsize: __fsword_t, pub f_blocks: ::fsblkcnt_t, pub f_bfree: ::fsblkcnt_t, pub f_bavail: ::fsblkcnt_t, pub f_files: ::fsfilcnt_t, pub f_ffree: ::fsfilcnt_t, pub f_fsid: ::fsid_t, pub f_namelen: __fsword_t, pub f_frsize: __fsword_t, f_spare: [__fsword_t; 5], } pub struct msghdr { pub msg_name: *mut ::c_void, pub msg_namelen: ::socklen_t, pub msg_iov: *mut ::iovec, pub msg_iovlen: ::size_t, pub msg_control: *mut ::c_void, pub msg_controllen: ::size_t, pub msg_flags: ::c_int, } pub struct termios { pub c_iflag: ::tcflag_t, pub c_oflag: ::tcflag_t, pub c_cflag: ::tcflag_t, pub c_lflag: ::tcflag_t, pub c_line: ::cc_t, pub c_cc: [::cc_t; ::NCCS], pub c_ispeed: ::speed_t, pub c_ospeed: ::speed_t, } pub struct flock { pub l_type: ::c_short, pub l_whence: ::c_short, pub l_start: ::off_t, pub l_len: ::off_t, pub l_pid: ::pid_t, } } pub const RLIMIT_RSS: ::c_int = 5; pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_AS: ::c_int = 9; pub const RLIMIT_NPROC: ::c_int = 6; pub const RLIMIT_MEMLOCK: ::c_int = 8; pub const RLIM_INFINITY: ::rlim_t = !0; pub const RLIMIT_RTTIME: ::c_int = 15; pub const RLIMIT_NLIMITS: ::c_int = 16; pub const O_APPEND: ::c_int = 1024; pub const O_CREAT: ::c_int = 64; pub const O_EXCL: ::c_int = 128; pub const O_NOCTTY: ::c_int = 256; pub const O_NONBLOCK: ::c_int = 2048; pub const O_SYNC: ::c_int = 1052672; pub const O_RSYNC: ::c_int = 1052672; pub const O_DSYNC: ::c_int = 4096; pub const O_FSYNC: ::c_int = 0x101000; pub const MAP_ANON: ::c_int = 0x0020; pub const MAP_ANONYMOUS: ::c_int = 0x0020; pub const MAP_GROWSDOWN: ::c_int = 0x0100; pub const MAP_DENYWRITE: ::c_int = 0x0800; pub const MAP_EXECUTABLE: ::c_int = 0x01000; pub const MAP_LOCKED: ::c_int = 0x02000; pub const MAP_NORESERVE: ::c_int = 0x04000; pub const MAP_POPULATE: ::c_int = 0x08000; pub const MAP_NONBLOCK: ::c_int = 0x010000; pub const MAP_STACK: ::c_int = 0x020000; pub const EDEADLK: ::c_int = 35; pub const ENAMETOOLONG: ::c_int = 36; pub const ENOLCK: ::c_int = 37; pub const ENOSYS: ::c_int = 38; pub const ENOTEMPTY: ::c_int = 39; pub const ELOOP: ::c_int = 40; pub const ENOMSG: ::c_int = 42; pub const EIDRM: ::c_int = 43; pub const ECHRNG: ::c_int = 44; pub const EL2NSYNC: ::c_int = 45; pub const EL3HLT: ::c_int = 46; pub const EL3RST: ::c_int = 47; pub const ELNRNG: ::c_int = 48; pub const EUNATCH: ::c_int = 49; pub const ENOCSI: ::c_int = 50; pub const EL2HLT: ::c_int = 51; pub const EBADE: ::c_int = 52; pub const EBADR: ::c_int = 53; pub const EXFULL: ::c_int = 54; pub const ENOANO: ::c_int = 55; pub const EBADRQC: ::c_int = 56; pub const EBADSLT: ::c_int = 57; pub const EDEADLOCK: ::c_int = EDEADLK; pub const EMULTIHOP: ::c_int = 72; pub const EOVERFLOW: ::c_int = 75; pub const ENOTUNIQ: ::c_int = 76; pub const EBADFD: ::c_int = 77; pub const EBADMSG: ::c_int = 74; pub const EREMCHG: ::c_int = 78; pub const ELIBACC: ::c_int = 79; pub const ELIBBAD: ::c_int = 80; pub const ELIBSCN: ::c_int = 81; pub const ELIBMAX: ::c_int = 82; pub const ELIBEXEC: ::c_int = 83; pub const EILSEQ: ::c_int = 84; pub const ERESTART: ::c_int = 85; pub const ESTRPIPE: ::c_int = 86; pub const EUSERS: ::c_int = 87; pub const ENOTSOCK: ::c_int = 88; pub const EDESTADDRREQ: ::c_int = 89; pub const EMSGSIZE: ::c_int = 90; pub const EPROTOTYPE: ::c_int = 91; pub const ENOPROTOOPT: ::c_int = 92; pub const EPROTONOSUPPORT: ::c_int = 93; pub const ESOCKTNOSUPPORT: ::c_int = 94; pub const EOPNOTSUPP: ::c_int = 95; pub const EPFNOSUPPORT: ::c_int = 96; pub const EAFNOSUPPORT: ::c_int = 97; pub const EADDRINUSE: ::c_int = 98; pub const EADDRNOTAVAIL: ::c_int = 99; pub const ENETDOWN: ::c_int = 100; pub const ENETUNREACH: ::c_int = 101; pub const ENETRESET: ::c_int = 102; pub const ECONNABORTED: ::c_int = 103; pub const ECONNRESET: ::c_int = 104; pub const ENOBUFS: ::c_int = 105; pub const EISCONN: ::c_int = 106; pub const ENOTCONN: ::c_int = 107; pub const ESHUTDOWN: ::c_int = 108; pub const ETOOMANYREFS: ::c_int = 109; pub const ETIMEDOUT: ::c_int = 110; pub const ECONNREFUSED: ::c_int = 111; pub const EHOSTDOWN: ::c_int = 112; pub const EHOSTUNREACH: ::c_int = 113; pub const EALREADY: ::c_int = 114; pub const EINPROGRESS: ::c_int = 115; pub const ESTALE: ::c_int = 116; pub const EUCLEAN: ::c_int = 117; pub const ENOTNAM: ::c_int = 118; pub const ENAVAIL: ::c_int = 119; pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; pub const EDQUOT: ::c_int = 122; pub const ENOMEDIUM: ::c_int = 123; pub const EMEDIUMTYPE: ::c_int = 124; pub const ECANCELED: ::c_int = 125; pub const ENOKEY: ::c_int = 126; pub const EKEYEXPIRED: ::c_int = 127; pub const EKEYREVOKED: ::c_int = 128; pub const EKEYREJECTED: ::c_int = 129; pub const EOWNERDEAD: ::c_int = 130; pub const ENOTRECOVERABLE: ::c_int = 131; pub const EHWPOISON: ::c_int = 133; pub const ERFKILL: ::c_int = 132; pub const SOCK_STREAM: ::c_int = 1; pub const SOCK_DGRAM: ::c_int = 2; pub const SOL_SOCKET: ::c_int = 1; pub const SO_REUSEADDR: ::c_int = 2; pub const SO_TYPE: ::c_int = 3; pub const SO_ERROR: ::c_int = 4; pub const SO_DONTROUTE: ::c_int = 5; pub const SO_BROADCAST: ::c_int = 6; pub const SO_SNDBUF: ::c_int = 7; pub const SO_RCVBUF: ::c_int = 8; pub const SO_KEEPALIVE: ::c_int = 9; pub const SO_OOBINLINE: ::c_int = 10; pub const SO_LINGER: ::c_int = 13; pub const SO_REUSEPORT: ::c_int = 15; pub const SO_PEERCRED: ::c_int = 17; pub const SO_RCVLOWAT: ::c_int = 18; pub const SO_SNDLOWAT: ::c_int = 19; pub const SO_RCVTIMEO: ::c_int = 20; pub const SO_SNDTIMEO: ::c_int = 21; pub const SO_ACCEPTCONN: ::c_int = 30; pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; pub const TCP_THIN_DUPACK: ::c_int = 17; pub const TCP_USER_TIMEOUT: ::c_int = 18; pub const TCP_REPAIR: ::c_int = 19; pub const TCP_REPAIR_QUEUE: ::c_int = 20; pub const TCP_QUEUE_SEQ: ::c_int = 21; pub const TCP_REPAIR_OPTIONS: ::c_int = 22; pub const TCP_FASTOPEN: ::c_int = 23; pub const TCP_TIMESTAMP: ::c_int = 24; pub const SA_ONSTACK: ::c_int = 0x08000000; pub const SA_SIGINFO: ::c_int = 0x00000004; pub const SA_NOCLDWAIT: ::c_int = 0x00000002; pub const SIGCHLD: ::c_int = 17; pub const SIGBUS: ::c_int = 7; pub const SIGUSR1: ::c_int = 10; pub const SIGUSR2: ::c_int = 12; pub const SIGCONT: ::c_int = 18; pub const SIGSTOP: ::c_int = 19; pub const SIGTSTP: ::c_int = 20; pub const SIGURG: ::c_int = 23; pub const SIGIO: ::c_int = 29; pub const SIGSYS: ::c_int = 31; pub const SIGSTKFLT: ::c_int = 16; pub const SIGUNUSED: ::c_int = 31; pub const SIGTTIN: ::c_int = 21; pub const SIGTTOU: ::c_int = 22; pub const SIGXCPU: ::c_int = 24; pub const SIGXFSZ: ::c_int = 25; pub const SIGVTALRM: ::c_int = 26; pub const SIGPROF: ::c_int = 27; pub const SIGWINCH: ::c_int = 28; pub const SIGPOLL: ::c_int = 29; pub const SIGPWR: ::c_int = 30; pub const SIG_SETMASK: ::c_int = 2; pub const SIG_BLOCK: ::c_int = 0x000000; pub const SIG_UNBLOCK: ::c_int = 0x01; pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01; pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02; pub const FIOCLEX: ::c_ulong = 0x5451; pub const FIONBIO: ::c_ulong = 0x5421; pub const BUFSIZ: ::c_uint = 8192; pub const TMP_MAX: ::c_uint = 238328; pub const FOPEN_MAX: ::c_uint = 16; pub const POSIX_MADV_DONTNEED: ::c_int = 4; pub const _SC_2_C_VERSION: ::c_int = 96; pub const RUSAGE_THREAD: ::c_int = 1; pub const O_ACCMODE: ::c_int = 3; pub const O_ASYNC: ::c_int = 0x2000; pub const O_NDELAY: ::c_int = 0x800; pub const RUSAGE_CHILDREN: ::c_int = -1; pub const ST_RELATIME: ::c_ulong = 4096; pub const NI_MAXHOST: ::socklen_t = 1025; pub const MS_VERBOSE: ::c_ulong = 0x8000; pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; pub const TMPFS_MAGIC: ::c_long = 0x01021994; pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; pub const VEOF: usize = 4; pub const VEOL: usize = 11; pub const VEOL2: usize = 16; pub const VMIN: usize = 6; pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; pub const IUTF8: ::tcflag_t = 0x00004000; pub const CPU_SETSIZE: ::c_int = 0x400; pub const EXTPROC: ::tcflag_t = 0x00010000; pub const QFMT_VFS_V1: ::c_int = 4; pub const PTRACE_TRACEME: ::c_uint = 0; pub const PTRACE_PEEKTEXT: ::c_uint = 1; pub const PTRACE_PEEKDATA: ::c_uint = 2; pub const PTRACE_PEEKUSER: ::c_uint = 3; pub const PTRACE_POKETEXT: ::c_uint = 4; pub const PTRACE_POKEDATA: ::c_uint = 5; pub const PTRACE_POKEUSER: ::c_uint = 6; pub const PTRACE_CONT: ::c_uint = 7; pub const PTRACE_KILL: ::c_uint = 8; pub const PTRACE_SINGLESTEP: ::c_uint = 9; pub const PTRACE_ATTACH: ::c_uint = 16; pub const PTRACE_DETACH: ::c_uint = 17; pub const PTRACE_SYSCALL: ::c_uint = 24; pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200; pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201; pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202; pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203; pub const PTRACE_GETREGSET: ::c_uint = 0x4204; pub const PTRACE_SETREGSET: ::c_uint = 0x4205; pub const PTRACE_SEIZE: ::c_uint = 0x4206; pub const PTRACE_INTERRUPT: ::c_uint = 0x4207; pub const PTRACE_LISTEN: ::c_uint = 0x4208; pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209; pub const MADV_DODUMP: ::c_int = 17; pub const MADV_DONTDUMP: ::c_int = 16; pub const EPOLLWAKEUP: ::c_int = 0x20000000; pub const MS_NOSEC: ::c_ulong = 0x10000000; pub const MS_BORN: ::c_ulong = 0x20000000; pub const MADV_HUGEPAGE: ::c_int = 14; pub const MADV_NOHUGEPAGE: ::c_int = 15; pub const MAP_HUGETLB: ::c_int = 0x040000; pub const EFD_NONBLOCK: ::c_int = 0x800; pub const F_GETLK: ::c_int = 5; pub const F_GETOWN: ::c_int = 9; pub const F_SETOWN: ::c_int = 8; pub const SFD_NONBLOCK: ::c_int = 0x0800; pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; cfg_if! { if #[cfg(any(target_arch = "arm", target_arch = "x86", target_arch = "x86_64"))] { pub const PTHREAD_STACK_MIN: ::size_t = 16384; } else { pub const PTHREAD_STACK_MIN: ::size_t = 131072; } } extern { pub fn sysctl(name: *mut ::c_int, namelen: ::c_int, oldp: *mut ::c_void, oldlenp: *mut ::size_t, newp: *mut ::c_void, newlen: ::size_t) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int; pub fn glob64(pattern: *const ::c_char, flags: ::c_int, errfunc: ::dox::Option ::c_int>, pglob: *mut glob64_t) -> ::c_int; pub fn globfree64(pglob: *mut glob64_t); pub fn getnameinfo(sa: *const ::sockaddr, salen: ::socklen_t, host: *mut ::c_char, hostlen: ::socklen_t, serv: *mut ::c_char, sevlen: ::socklen_t, flags: ::c_int) -> ::c_int; pub fn eventfd(init: ::c_int, flags: ::c_int) -> ::c_int; pub fn ptrace(request: ::c_uint, ...) -> ::c_long; } cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "arm"))] { mod b32; pub use self::b32::*; } else if #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] { mod b64; pub use self::b64::*; } else { // ... } } s! { pub struct ipc_perm { pub __key: ::key_t, pub uid: ::uid_t, pub gid: ::gid_t, pub cuid: ::uid_t, pub cgid: ::gid_t, pub mode: ::c_ushort, __pad1: ::c_ushort, pub __seq: ::c_ushort, __pad2: ::c_ushort, __unused1: ::c_ulong, __unused2: ::c_ulong } pub struct shmid_ds { pub shm_perm: ::ipc_perm, pub shm_segsz: ::size_t, pub shm_atime: ::time_t, #[cfg(target_pointer_width = "32")] __unused1: ::c_ulong, pub shm_dtime: ::time_t, #[cfg(target_pointer_width = "32")] __unused2: ::c_ulong, pub shm_ctime: ::time_t, #[cfg(target_pointer_width = "32")] __unused3: ::c_ulong, pub shm_cpid: ::pid_t, pub shm_lpid: ::pid_t, pub shm_nattch: ::shmatt_t, __unused4: ::c_ulong, __unused5: ::c_ulong } } deps/libc-0.2.4/src/unix/notbsd/linux/other/b64/0000755000000000000000000000000012666635520020010 5ustar rootrootdeps/libc-0.2.4/src/unix/notbsd/linux/other/b64/x86_64.rs0000664000175000017500000000361012634314567017540 0ustar //! x86_64-specific definitions for 64-bit linux-like values pub type c_char = i8; pub type wchar_t = i32; pub type nlink_t = u64; pub type blksize_t = i64; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; pub const O_NOFOLLOW: ::c_int = 0x20000; pub const PTRACE_GETFPREGS: ::c_uint = 14; pub const PTRACE_SETFPREGS: ::c_uint = 15; pub const PTRACE_GETFPXREGS: ::c_uint = 18; pub const PTRACE_SETFPXREGS: ::c_uint = 19; pub const PTRACE_GETREGS: ::c_uint = 12; pub const PTRACE_SETREGS: ::c_uint = 13; s! { pub struct stat { pub st_dev: ::dev_t, pub st_ino: ::ino_t, pub st_nlink: ::nlink_t, pub st_mode: ::mode_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, __pad0: ::c_int, pub st_rdev: ::dev_t, pub st_size: ::off_t, pub st_blksize: ::blksize_t, pub st_blocks: ::blkcnt_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, __unused: [::c_long; 3], } pub struct stat64 { pub st_dev: ::dev_t, pub st_ino: ::ino64_t, pub st_nlink: ::nlink_t, pub st_mode: ::mode_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, __pad0: ::c_int, pub st_rdev: ::dev_t, pub st_size: ::off_t, pub st_blksize: ::blksize_t, pub st_blocks: ::blkcnt64_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, __reserved: [::c_long; 3], } pub struct pthread_attr_t { __size: [u64; 7] } } deps/libc-0.2.4/src/unix/notbsd/linux/other/b64/mod.rs0000664000175000017500000000110512634314567017356 0ustar //! 64-bit specific definitions for linux-like values pub type c_long = i64; pub type c_ulong = u64; pub type clock_t = i64; pub type time_t = i64; pub type suseconds_t = i64; pub type ino_t = u64; pub type off_t = i64; pub type blkcnt_t = i64; pub type __fsword_t = ::c_long; s! { pub struct sigset_t { __val: [::c_ulong; 16], } } pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; cfg_if! { if #[cfg(target_arch = "aarch64")] { mod aarch64; pub use self::aarch64::*; } else { mod x86_64; pub use self::x86_64::*; } } deps/libc-0.2.4/src/unix/notbsd/linux/other/b64/aarch64.rs0000664000175000017500000000326512634314567020040 0ustar //! AArch64-specific definitions for 64-bit linux-like values pub type c_char = u8; pub type wchar_t = u32; pub type nlink_t = u32; pub type blksize_t = i32; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 48; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 8; pub const O_DIRECT: ::c_int = 0x10000; pub const O_DIRECTORY: ::c_int = 0x4000; pub const O_NOFOLLOW: ::c_int = 0x8000; s! { pub struct stat { pub st_dev: ::dev_t, pub st_ino: ::ino_t, pub st_mode: ::mode_t, pub st_nlink: ::nlink_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, pub st_rdev: ::dev_t, __pad1: ::dev_t, pub st_size: ::off_t, pub st_blksize: ::blksize_t, __pad2: ::c_int, pub st_blocks: ::blkcnt_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, __unused: [::c_int; 2], } pub struct stat64 { pub st_dev: ::dev_t, pub st_ino: ::ino_t, pub st_mode: ::mode_t, pub st_nlink: ::nlink_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, pub st_rdev: ::dev_t, __pad1: ::dev_t, pub st_size: ::off64_t, pub st_blksize: ::blksize_t, __pad2: ::c_int, pub st_blocks: ::blkcnt64_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, __unused: [::c_int; 2], } pub struct pthread_attr_t { __size: [u64; 8] } } deps/libc-0.2.4/src/unix/notbsd/mod.rs0000664000175000017500000004732612634601304014506 0ustar use dox::mem; pub type rlim_t = c_ulong; pub type sa_family_t = u16; pub type pthread_key_t = ::c_uint; pub type mqd_t = ::c_int; pub type speed_t = ::c_uint; pub type tcflag_t = ::c_uint; pub enum timezone {} s! { pub struct sockaddr { pub sa_family: sa_family_t, pub sa_data: [::c_char; 14], } pub struct sockaddr_in { pub sin_family: sa_family_t, pub sin_port: ::in_port_t, pub sin_addr: ::in_addr, pub sin_zero: [u8; 8], } pub struct sockaddr_in6 { pub sin6_family: sa_family_t, pub sin6_port: ::in_port_t, pub sin6_flowinfo: u32, pub sin6_addr: ::in6_addr, pub sin6_scope_id: u32, } pub struct sockaddr_un { pub sun_family: sa_family_t, pub sun_path: [::c_char; 108] } pub struct sockaddr_storage { pub ss_family: sa_family_t, __ss_align: ::size_t, #[cfg(target_pointer_width = "32")] __ss_pad2: [u8; 128 - 2 * 4], #[cfg(target_pointer_width = "64")] __ss_pad2: [u8; 128 - 2 * 8], } pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, pub ai_socktype: ::c_int, pub ai_protocol: ::c_int, pub ai_addrlen: socklen_t, #[cfg(target_os = "linux")] pub ai_addr: *mut ::sockaddr, pub ai_canonname: *mut c_char, #[cfg(target_os = "android")] pub ai_addr: *mut ::sockaddr, pub ai_next: *mut addrinfo, } pub struct sockaddr_ll { pub sll_family: ::c_ushort, pub sll_protocol: ::c_ushort, pub sll_ifindex: ::c_int, pub sll_hatype: ::c_ushort, pub sll_pkttype: ::c_uchar, pub sll_halen: ::c_uchar, pub sll_addr: [::c_uchar; 8] } pub struct fd_set { fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE], } pub struct tm { pub tm_sec: ::c_int, pub tm_min: ::c_int, pub tm_hour: ::c_int, pub tm_mday: ::c_int, pub tm_mon: ::c_int, pub tm_year: ::c_int, pub tm_wday: ::c_int, pub tm_yday: ::c_int, pub tm_isdst: ::c_int, pub tm_gmtoff: ::c_long, pub tm_zone: *const ::c_char, } pub struct sched_param { pub sched_priority: ::c_int, #[cfg(target_env = "musl")] pub sched_ss_low_priority: ::c_int, #[cfg(target_env = "musl")] pub sched_ss_repl_period: ::timespec, #[cfg(target_env = "musl")] pub sched_ss_init_budget: ::timespec, #[cfg(target_env = "musl")] pub sched_ss_max_repl: ::c_int, } pub struct Dl_info { pub dli_fname: *const ::c_char, pub dli_fbase: *mut ::c_void, pub dli_sname: *const ::c_char, pub dli_saddr: *mut ::c_void, } #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed))] pub struct epoll_event { pub events: ::uint32_t, pub u64: ::uint64_t, } pub struct utsname { pub sysname: [::c_char; 65], pub nodename: [::c_char; 65], pub release: [::c_char; 65], pub version: [::c_char; 65], pub machine: [::c_char; 65], pub domainname: [::c_char; 65] } } // intentionally not public, only used for fd_set #[cfg(target_pointer_width = "32")] const ULONG_SIZE: usize = 32; #[cfg(target_pointer_width = "64")] const ULONG_SIZE: usize = 64; pub const EXIT_FAILURE: ::c_int = 1; pub const EXIT_SUCCESS: ::c_int = 0; pub const RAND_MAX: ::c_int = 2147483647; pub const EOF: ::c_int = -1; pub const SEEK_SET: ::c_int = 0; pub const SEEK_CUR: ::c_int = 1; pub const SEEK_END: ::c_int = 2; pub const _IOFBF: ::c_int = 0; pub const _IONBF: ::c_int = 2; pub const _IOLBF: ::c_int = 1; pub const F_DUPFD: ::c_int = 0; pub const F_GETFD: ::c_int = 1; pub const F_SETFD: ::c_int = 2; pub const F_GETFL: ::c_int = 3; pub const F_SETFL: ::c_int = 4; pub const SIGTRAP: ::c_int = 5; pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; pub const CLOCK_REALTIME: ::c_int = 0; pub const CLOCK_MONOTONIC: ::c_int = 1; pub const RLIMIT_CPU: ::c_int = 0; pub const RLIMIT_FSIZE: ::c_int = 1; pub const RLIMIT_DATA: ::c_int = 2; pub const RLIMIT_STACK: ::c_int = 3; pub const RLIMIT_CORE: ::c_int = 4; pub const RLIMIT_LOCKS: ::c_int = 10; pub const RLIMIT_SIGPENDING: ::c_int = 11; pub const RLIMIT_MSGQUEUE: ::c_int = 12; pub const RLIMIT_NICE: ::c_int = 13; pub const RLIMIT_RTPRIO: ::c_int = 14; pub const RUSAGE_SELF: ::c_int = 0; pub const O_RDONLY: ::c_int = 0; pub const O_WRONLY: ::c_int = 1; pub const O_RDWR: ::c_int = 2; pub const O_TRUNC: ::c_int = 512; pub const O_CLOEXEC: ::c_int = 0x80000; pub const S_IFIFO: ::mode_t = 4096; pub const S_IFCHR: ::mode_t = 8192; pub const S_IFBLK: ::mode_t = 24576; pub const S_IFDIR: ::mode_t = 16384; pub const S_IFREG: ::mode_t = 32768; pub const S_IFLNK: ::mode_t = 40960; pub const S_IFSOCK: ::mode_t = 49152; pub const S_IFMT: ::mode_t = 61440; pub const S_IRWXU: ::mode_t = 448; pub const S_IXUSR: ::mode_t = 64; pub const S_IWUSR: ::mode_t = 128; pub const S_IRUSR: ::mode_t = 256; pub const S_IRWXG: ::mode_t = 56; pub const S_IXGRP: ::mode_t = 8; pub const S_IWGRP: ::mode_t = 16; pub const S_IRGRP: ::mode_t = 32; pub const S_IRWXO: ::mode_t = 7; pub const S_IXOTH: ::mode_t = 1; pub const S_IWOTH: ::mode_t = 2; pub const S_IROTH: ::mode_t = 4; pub const F_OK: ::c_int = 0; pub const R_OK: ::c_int = 4; pub const W_OK: ::c_int = 2; pub const X_OK: ::c_int = 1; pub const STDIN_FILENO: ::c_int = 0; pub const STDOUT_FILENO: ::c_int = 1; pub const STDERR_FILENO: ::c_int = 2; pub const SIGHUP: ::c_int = 1; pub const SIGINT: ::c_int = 2; pub const SIGQUIT: ::c_int = 3; pub const SIGILL: ::c_int = 4; pub const SIGABRT: ::c_int = 6; pub const SIGFPE: ::c_int = 8; pub const SIGKILL: ::c_int = 9; pub const SIGSEGV: ::c_int = 11; pub const SIGPIPE: ::c_int = 13; pub const SIGALRM: ::c_int = 14; pub const SIGTERM: ::c_int = 15; pub const PROT_NONE: ::c_int = 0; pub const PROT_READ: ::c_int = 1; pub const PROT_WRITE: ::c_int = 2; pub const PROT_EXEC: ::c_int = 4; pub const MAP_FILE: ::c_int = 0x0000; pub const MAP_SHARED: ::c_int = 0x0001; pub const MAP_PRIVATE: ::c_int = 0x0002; pub const MAP_FIXED: ::c_int = 0x0010; pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; pub const MS_ASYNC: ::c_int = 0x0001; pub const MS_INVALIDATE: ::c_int = 0x0002; pub const MS_SYNC: ::c_int = 0x0004; pub const MS_RDONLY: ::c_ulong = 0x01; pub const MS_NOSUID: ::c_ulong = 0x02; pub const MS_NODEV: ::c_ulong = 0x04; pub const MS_NOEXEC: ::c_ulong = 0x08; pub const MS_SYNCHRONOUS: ::c_ulong = 0x10; pub const MS_REMOUNT: ::c_ulong = 0x20; pub const MS_MANDLOCK: ::c_ulong = 0x40; pub const MS_DIRSYNC: ::c_ulong = 0x80; pub const MS_NOATIME: ::c_ulong = 0x0400; pub const MS_NODIRATIME: ::c_ulong = 0x0800; pub const MS_BIND: ::c_ulong = 0x1000; pub const MS_MOVE: ::c_ulong = 0x2000; pub const MS_REC: ::c_ulong = 0x4000; pub const MS_SILENT: ::c_ulong = 0x8000; pub const MS_POSIXACL: ::c_ulong = 0x010000; pub const MS_UNBINDABLE: ::c_ulong = 0x020000; pub const MS_PRIVATE: ::c_ulong = 0x040000; pub const MS_SLAVE: ::c_ulong = 0x080000; pub const MS_SHARED: ::c_ulong = 0x100000; pub const MS_ACTIVE: ::c_ulong = 0x40000000; pub const MS_NOUSER: ::c_ulong = 0x80000000; pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000; pub const MS_MGC_MSK: ::c_ulong = 0xffff0000; pub const EPERM: ::c_int = 1; pub const ENOENT: ::c_int = 2; pub const ESRCH: ::c_int = 3; pub const EINTR: ::c_int = 4; pub const EIO: ::c_int = 5; pub const ENXIO: ::c_int = 6; pub const E2BIG: ::c_int = 7; pub const ENOEXEC: ::c_int = 8; pub const EBADF: ::c_int = 9; pub const ECHILD: ::c_int = 10; pub const EAGAIN: ::c_int = 11; pub const ENOMEM: ::c_int = 12; pub const EACCES: ::c_int = 13; pub const EFAULT: ::c_int = 14; pub const ENOTBLK: ::c_int = 15; pub const EBUSY: ::c_int = 16; pub const EEXIST: ::c_int = 17; pub const EXDEV: ::c_int = 18; pub const ENODEV: ::c_int = 19; pub const ENOTDIR: ::c_int = 20; pub const EISDIR: ::c_int = 21; pub const EINVAL: ::c_int = 22; pub const ENFILE: ::c_int = 23; pub const EMFILE: ::c_int = 24; pub const ENOTTY: ::c_int = 25; pub const ETXTBSY: ::c_int = 26; pub const EFBIG: ::c_int = 27; pub const ENOSPC: ::c_int = 28; pub const ESPIPE: ::c_int = 29; pub const EROFS: ::c_int = 30; pub const EMLINK: ::c_int = 31; pub const EPIPE: ::c_int = 32; pub const EDOM: ::c_int = 33; pub const ERANGE: ::c_int = 34; pub const EWOULDBLOCK: ::c_int = EAGAIN; pub const EBFONT: ::c_int = 59; pub const ENOSTR: ::c_int = 60; pub const ENODATA: ::c_int = 61; pub const ETIME: ::c_int = 62; pub const ENOSR: ::c_int = 63; pub const ENONET: ::c_int = 64; pub const ENOPKG: ::c_int = 65; pub const EREMOTE: ::c_int = 66; pub const ENOLINK: ::c_int = 67; pub const EADV: ::c_int = 68; pub const ESRMNT: ::c_int = 69; pub const ECOMM: ::c_int = 70; pub const EPROTO: ::c_int = 71; pub const EDOTDOT: ::c_int = 73; pub const AF_PACKET: ::c_int = 17; pub const IPPROTO_RAW: ::c_int = 255; pub const PROT_GROWSDOWN: ::c_int = 0x1000000; pub const PROT_GROWSUP: ::c_int = 0x2000000; pub const MAP_TYPE: ::c_int = 0x000f; pub const MADV_NORMAL: ::c_int = 0; pub const MADV_RANDOM: ::c_int = 1; pub const MADV_SEQUENTIAL: ::c_int = 2; pub const MADV_WILLNEED: ::c_int = 3; pub const MADV_DONTNEED: ::c_int = 4; pub const MADV_REMOVE: ::c_int = 9; pub const MADV_DONTFORK: ::c_int = 10; pub const MADV_DOFORK: ::c_int = 11; pub const MADV_MERGEABLE: ::c_int = 12; pub const MADV_UNMERGEABLE: ::c_int = 13; pub const MADV_HWPOISON: ::c_int = 100; pub const IFF_LOOPBACK: ::c_int = 0x8; pub const AF_UNIX: ::c_int = 1; pub const AF_INET: ::c_int = 2; pub const AF_INET6: ::c_int = 10; pub const SOCK_RAW: ::c_int = 3; pub const IPPROTO_TCP: ::c_int = 6; pub const IPPROTO_IP: ::c_int = 0; pub const IPPROTO_IPV6: ::c_int = 41; pub const IP_MULTICAST_TTL: ::c_int = 33; pub const IP_MULTICAST_LOOP: ::c_int = 34; pub const IP_TTL: ::c_int = 2; pub const IP_HDRINCL: ::c_int = 3; pub const IP_ADD_MEMBERSHIP: ::c_int = 35; pub const IP_DROP_MEMBERSHIP: ::c_int = 36; pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; pub const TCP_NODELAY: ::c_int = 1; pub const TCP_MAXSEG: ::c_int = 2; pub const TCP_CORK: ::c_int = 3; pub const TCP_KEEPIDLE: ::c_int = 4; pub const TCP_KEEPINTVL: ::c_int = 5; pub const TCP_KEEPCNT: ::c_int = 6; pub const TCP_SYNCNT: ::c_int = 7; pub const TCP_LINGER2: ::c_int = 8; pub const TCP_DEFER_ACCEPT: ::c_int = 9; pub const TCP_WINDOW_CLAMP: ::c_int = 10; pub const TCP_INFO: ::c_int = 11; pub const TCP_QUICKACK: ::c_int = 12; pub const TCP_CONGESTION: ::c_int = 13; pub const IPV6_MULTICAST_LOOP: ::c_int = 19; pub const IPV6_V6ONLY: ::c_int = 26; pub const SO_DEBUG: ::c_int = 1; pub const SHUT_RD: ::c_int = 0; pub const SHUT_WR: ::c_int = 1; pub const SHUT_RDWR: ::c_int = 2; pub const LOCK_SH: ::c_int = 1; pub const LOCK_EX: ::c_int = 2; pub const LOCK_NB: ::c_int = 4; pub const LOCK_UN: ::c_int = 8; pub const SIGSTKSZ: ::size_t = 8192; pub const SA_NODEFER: ::c_int = 0x40000000; pub const SA_RESETHAND: ::c_int = 0x80000000; pub const SA_RESTART: ::c_int = 0x10000000; pub const SA_NOCLDSTOP: ::c_int = 0x00000001; pub const PATH_MAX: ::c_int = 4096; pub const FD_SETSIZE: usize = 1024; pub const EPOLLIN: ::c_int = 0x1; pub const EPOLLPRI: ::c_int = 0x2; pub const EPOLLOUT: ::c_int = 0x4; pub const EPOLLRDNORM: ::c_int = 0x40; pub const EPOLLRDBAND: ::c_int = 0x80; pub const EPOLLWRNORM: ::c_int = 0x100; pub const EPOLLWRBAND: ::c_int = 0x200; pub const EPOLLMSG: ::c_int = 0x400; pub const EPOLLERR: ::c_int = 0x8; pub const EPOLLHUP: ::c_int = 0x10; pub const EPOLLET: ::c_int = 0x80000000; pub const EPOLL_CTL_ADD: ::c_int = 1; pub const EPOLL_CTL_MOD: ::c_int = 3; pub const EPOLL_CTL_DEL: ::c_int = 2; pub const MNT_DETACH: ::c_int = 0x2; pub const MNT_EXPIRE: ::c_int = 0x4; pub const Q_GETFMT: ::c_int = 0x800004; pub const Q_GETINFO: ::c_int = 0x800005; pub const Q_SETINFO: ::c_int = 0x800006; pub const QIF_BLIMITS: ::uint32_t = 1; pub const QIF_SPACE: ::uint32_t = 2; pub const QIF_ILIMITS: ::uint32_t = 4; pub const QIF_INODES: ::uint32_t = 8; pub const QIF_BTIME: ::uint32_t = 16; pub const QIF_ITIME: ::uint32_t = 32; pub const QIF_LIMITS: ::uint32_t = 5; pub const QIF_USAGE: ::uint32_t = 10; pub const QIF_TIMES: ::uint32_t = 48; pub const QIF_ALL: ::uint32_t = 63; pub const CBAUD: ::tcflag_t = 0o0010017; pub const EFD_CLOEXEC: ::c_int = 0x80000; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; pub const MNT_FORCE: ::c_int = 0x1; pub const Q_SYNC: ::c_int = 0x800001; pub const Q_QUOTAON: ::c_int = 0x800002; pub const Q_QUOTAOFF: ::c_int = 0x800003; pub const Q_GETQUOTA: ::c_int = 0x800007; pub const Q_SETQUOTA: ::c_int = 0x800008; pub const TCIOFF: ::c_int = 2; pub const TCION: ::c_int = 3; pub const TCOOFF: ::c_int = 0; pub const TCOON: ::c_int = 1; pub const TCIFLUSH: ::c_int = 0; pub const TCOFLUSH: ::c_int = 1; pub const TCIOFLUSH: ::c_int = 2; pub const NL0: ::c_int = 0x00000000; pub const NL1: ::c_int = 0x00000100; pub const TAB0: ::c_int = 0x00000000; pub const TAB1: ::c_int = 0x00000800; pub const TAB2: ::c_int = 0x00001000; pub const TAB3: ::c_int = 0x00001800; pub const CR0: ::c_int = 0x00000000; pub const CR1: ::c_int = 0x00000200; pub const CR2: ::c_int = 0x00000400; pub const CR3: ::c_int = 0x00000600; pub const FF0: ::c_int = 0x00000000; pub const FF1: ::c_int = 0x00008000; pub const BS0: ::c_int = 0x00000000; pub const BS1: ::c_int = 0x00002000; pub const VT0: ::c_int = 0x00000000; pub const VT1: ::c_int = 0x00004000; pub const VERASE: usize = 2; pub const VWERASE: usize = 14; pub const VKILL: usize = 3; pub const VREPRINT: usize = 12; pub const VINTR: usize = 0; pub const VQUIT: usize = 1; pub const VSUSP: usize = 10; pub const VSTART: usize = 8; pub const VSTOP: usize = 9; pub const VLNEXT: usize = 15; pub const VDISCARD: usize = 13; pub const VTIME: usize = 5; pub const IGNBRK: ::tcflag_t = 0x00000001; pub const BRKINT: ::tcflag_t = 0x00000002; pub const IGNPAR: ::tcflag_t = 0x00000004; pub const PARMRK: ::tcflag_t = 0x00000008; pub const INPCK: ::tcflag_t = 0x00000010; pub const ISTRIP: ::tcflag_t = 0x00000020; pub const INLCR: ::tcflag_t = 0x00000040; pub const IGNCR: ::tcflag_t = 0x00000080; pub const ICRNL: ::tcflag_t = 0x00000100; pub const IXON: ::tcflag_t = 0x00000400; pub const IXOFF: ::tcflag_t = 0x00001000; pub const IXANY: ::tcflag_t = 0x00000800; pub const IMAXBEL: ::tcflag_t = 0x00002000; pub const OPOST: ::tcflag_t = 0x1; pub const ONLCR: ::tcflag_t = 0x4; pub const CSIZE: ::tcflag_t = 0x00000030; pub const CS5: ::tcflag_t = 0x00000000; pub const CS6: ::tcflag_t = 0x00000010; pub const CS7: ::tcflag_t = 0x00000020; pub const CS8: ::tcflag_t = 0x00000030; pub const CSTOPB: ::tcflag_t = 0x00000040; pub const CREAD: ::tcflag_t = 0x00000080; pub const PARENB: ::tcflag_t = 0x00000100; pub const PARODD: ::tcflag_t = 0x00000200; pub const HUPCL: ::tcflag_t = 0x00000400; pub const CLOCAL: ::tcflag_t = 0x00000800; pub const CRTSCTS: ::tcflag_t = 0x80000000; pub const ECHOKE: ::tcflag_t = 0x00000800; pub const ECHOE: ::tcflag_t = 0x00000010; pub const ECHOK: ::tcflag_t = 0x00000020; pub const ECHO: ::tcflag_t = 0x00000008; pub const ECHONL: ::tcflag_t = 0x00000040; pub const ECHOPRT: ::tcflag_t = 0x00000400; pub const ECHOCTL: ::tcflag_t = 0x00000200; pub const ISIG: ::tcflag_t = 0x00000001; pub const ICANON: ::tcflag_t = 0x00000002; pub const PENDIN: ::tcflag_t = 0x00004000; pub const NOFLSH: ::tcflag_t = 0x00000080; pub const CLONE_VM: ::c_int = 0x100; pub const CLONE_FS: ::c_int = 0x200; pub const CLONE_FILES: ::c_int = 0x400; pub const CLONE_SIGHAND: ::c_int = 0x800; pub const CLONE_PTRACE: ::c_int = 0x2000; pub const CLONE_VFORK: ::c_int = 0x4000; pub const CLONE_PARENT: ::c_int = 0x8000; pub const CLONE_THREAD: ::c_int = 0x10000; pub const CLONE_NEWNS: ::c_int = 0x20000; pub const CLONE_SYSVSEM: ::c_int = 0x40000; pub const CLONE_SETTLS: ::c_int = 0x80000; pub const CLONE_PARENT_SETTID: ::c_int = 0x100000; pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000; pub const CLONE_DETACHED: ::c_int = 0x400000; pub const CLONE_UNTRACED: ::c_int = 0x800000; pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000; f! { pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { let fd = fd as usize; let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] &= !(1 << (fd % size)); return } pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { let fd = fd as usize; let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 } pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { let fd = fd as usize; let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] |= 1 << (fd % size); return } pub fn FD_ZERO(set: *mut fd_set) -> () { for slot in (*set).fds_bits.iter_mut() { *slot = 0; } } pub fn WIFEXITED(status: ::c_int) -> bool { (status & 0xff) == 0 } pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { (status >> 8) & 0xff } pub fn WTERMSIG(status: ::c_int) -> ::c_int { status & 0x7f } } extern { pub fn fdatasync(fd: ::c_int) -> ::c_int; pub fn mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_uchar) -> ::c_int; pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; pub fn prctl(option: ::c_int, ...) -> ::c_int; pub fn pthread_getattr_np(native: ::pthread_t, attr: *mut ::pthread_attr_t) -> ::c_int; pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, guardsize: *mut ::size_t) -> ::c_int; pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, stackaddr: *mut *mut ::c_void, stacksize: *mut ::size_t) -> ::c_int; pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; pub fn setgroups(ngroups: ::size_t, ptr: *const ::gid_t) -> ::c_int; pub fn sched_setscheduler(pid: ::pid_t, policy: ::c_int, param: *const sched_param) -> ::c_int; pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int; pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; pub fn epoll_create(size: ::c_int) -> ::c_int; pub fn epoll_ctl(epfd: ::c_int, op: ::c_int, fd: ::c_int, event: *mut epoll_event) -> ::c_int; pub fn epoll_wait(epfd: ::c_int, events: *mut epoll_event, maxevents: ::c_int, timeout: ::c_int) -> ::c_int; pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; pub fn mount(src: *const ::c_char, target: *const ::c_char, fstype: *const ::c_char, flags: ::c_ulong, data: *const ::c_void) -> ::c_int; pub fn umount(target: *const ::c_char) -> ::c_int; pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int; pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int, child_stack: *mut ::c_void, flags: ::c_int, arg: *mut ::c_void, ...) -> ::c_int; pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void; } cfg_if! { if #[cfg(target_os = "linux")] { mod linux; pub use self::linux::*; } else if #[cfg(target_os = "android")] { mod android; pub use self::android::*; } else { // ... } } deps/libc-0.2.4/src/unix/notbsd/android/0000755000000000000000000000000012666635520016555 5ustar rootrootdeps/libc-0.2.4/src/unix/notbsd/android/b64.rs0000664000175000017500000000026512622171542015734 0ustar s! { pub struct sigaction { pub sa_flags: ::c_uint, pub sa_sigaction: ::sighandler_t, pub sa_mask: ::sigset_t, _restorer: *mut ::c_void, } } deps/libc-0.2.4/src/unix/notbsd/android/mod.rs0000664000175000017500000004602312634314567016133 0ustar //! Android-specific definitions for linux-like values pub type c_char = u8; pub type c_long = i32; pub type c_ulong = u32; pub type clock_t = i32; pub type time_t = i32; pub type suseconds_t = i32; pub type wchar_t = u32; pub type off_t = i32; pub type ino_t = u32; pub type blkcnt_t = u32; pub type blksize_t = u32; pub type dev_t = u32; pub type mode_t = u16; pub type nlink_t = u16; pub type useconds_t = i32; pub type socklen_t = i32; pub type pthread_t = c_long; pub type pthread_mutexattr_t = ::c_long; pub type sigset_t = c_ulong; pub type time64_t = i64; pub type fsfilcnt_t = ::c_ulong; pub type fsblkcnt_t = ::c_ulong; s! { pub struct stat { pub st_dev: ::c_ulonglong, __pad0: [::c_uchar; 4], __st_ino: ::ino_t, pub st_mode: ::c_uint, pub st_nlink: ::c_uint, pub st_uid: ::c_ulong, pub st_gid: ::c_ulong, pub st_rdev: ::c_ulonglong, __pad3: [::c_uchar; 4], pub st_size: ::c_longlong, pub st_blksize: blksize_t, pub st_blocks: ::c_ulonglong, pub st_atime: ::c_ulong, pub st_atime_nsec: ::c_ulong, pub st_mtime: ::c_ulong, pub st_mtime_nsec: ::c_ulong, pub st_ctime: ::c_ulong, pub st_ctime_nsec: ::c_ulong, pub st_ino: ::c_ulonglong, } pub struct dirent { pub d_ino: u64, pub d_off: i64, pub d_reclen: ::c_ushort, pub d_type: ::c_uchar, pub d_name: [::c_char; 256], } pub struct pthread_attr_t { pub flags: ::uint32_t, pub stack_base: *mut ::c_void, pub stack_size: ::size_t, pub guard_size: ::size_t, pub sched_policy: ::int32_t, pub sched_priority: ::int32_t, } pub struct pthread_mutex_t { value: ::c_int } pub struct pthread_cond_t { value: ::c_int } pub struct pthread_rwlock_t { lock: pthread_mutex_t, cond: pthread_cond_t, numLocks: ::c_int, writerThreadId: ::c_int, pendingReaders: ::c_int, pendingWriters: ::c_int, reserved: [*mut ::c_void; 4], } pub struct passwd { pub pw_name: *mut ::c_char, pub pw_passwd: *mut ::c_char, pub pw_uid: ::uid_t, pub pw_gid: ::gid_t, pub pw_dir: *mut ::c_char, pub pw_shell: *mut ::c_char, } pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, pub ss_size: ::size_t } pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, pub si_code: ::c_int, pub _pad: [::c_int; 29], } pub struct statfs { pub f_type: ::uint32_t, pub f_bsize: ::uint32_t, pub f_blocks: ::uint64_t, pub f_bfree: ::uint64_t, pub f_bavail: ::uint64_t, pub f_files: ::uint64_t, pub f_ffree: ::uint64_t, pub f_fsid: ::__fsid_t, pub f_namelen: ::uint32_t, pub f_frsize: ::uint32_t, pub f_flags: ::uint32_t, pub f_spare: [::uint32_t; 4], } pub struct __fsid_t { __val: [::c_int; 2], } pub struct msghdr { pub msg_name: *mut ::c_void, pub msg_namelen: ::c_int, pub msg_iov: *mut ::iovec, pub msg_iovlen: ::size_t, pub msg_control: *mut ::c_void, pub msg_controllen: ::size_t, pub msg_flags: ::c_uint, } pub struct termios { pub c_iflag: ::tcflag_t, pub c_oflag: ::tcflag_t, pub c_cflag: ::tcflag_t, pub c_lflag: ::tcflag_t, pub c_line: ::cc_t, pub c_cc: [::cc_t; ::NCCS], } pub struct flock { pub l_type: ::c_short, pub l_whence: ::c_short, pub l_start: ::off_t, pub l_len: ::off_t, pub l_pid: ::pid_t, } } pub const BUFSIZ: ::c_uint = 1024; pub const FILENAME_MAX: ::c_uint = 1024; pub const FOPEN_MAX: ::c_uint = 20; pub const L_tmpnam: ::c_uint = 1024; pub const TMP_MAX: ::c_uint = 308915776; pub const _PC_NAME_MAX: ::c_int = 4; pub const FIONBIO: ::c_int = 0x5421; pub const _SC_ARG_MAX: ::c_int = 0; pub const _SC_BC_BASE_MAX: ::c_int = 1; pub const _SC_BC_DIM_MAX: ::c_int = 2; pub const _SC_BC_SCALE_MAX: ::c_int = 3; pub const _SC_BC_STRING_MAX: ::c_int = 4; pub const _SC_CHILD_MAX: ::c_int = 5; pub const _SC_CLK_TCK: ::c_int = 6; pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 7; pub const _SC_EXPR_NEST_MAX: ::c_int = 8; pub const _SC_LINE_MAX: ::c_int = 9; pub const _SC_NGROUPS_MAX: ::c_int = 10; pub const _SC_OPEN_MAX: ::c_int = 11; pub const _SC_2_C_BIND: ::c_int = 13; pub const _SC_2_C_DEV: ::c_int = 14; pub const _SC_2_C_VERSION: ::c_int = 15; pub const _SC_2_CHAR_TERM: ::c_int = 16; pub const _SC_2_FORT_DEV: ::c_int = 17; pub const _SC_2_FORT_RUN: ::c_int = 18; pub const _SC_2_LOCALEDEF: ::c_int = 19; pub const _SC_2_SW_DEV: ::c_int = 20; pub const _SC_2_UPE: ::c_int = 21; pub const _SC_2_VERSION: ::c_int = 22; pub const _SC_JOB_CONTROL: ::c_int = 23; pub const _SC_SAVED_IDS: ::c_int = 24; pub const _SC_VERSION: ::c_int = 25; pub const _SC_RE_DUP_MAX: ::c_int = 26; pub const _SC_STREAM_MAX: ::c_int = 27; pub const _SC_TZNAME_MAX: ::c_int = 28; pub const _SC_XOPEN_CRYPT: ::c_int = 29; pub const _SC_XOPEN_ENH_I18N: ::c_int = 30; pub const _SC_XOPEN_SHM: ::c_int = 31; pub const _SC_XOPEN_VERSION: ::c_int = 32; pub const _SC_XOPEN_XCU_VERSION: ::c_int = 33; pub const _SC_XOPEN_REALTIME: ::c_int = 34; pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 35; pub const _SC_XOPEN_LEGACY: ::c_int = 36; pub const _SC_ATEXIT_MAX: ::c_int = 37; pub const _SC_IOV_MAX: ::c_int = 38; pub const _SC_PAGESIZE: ::c_int = 39; pub const _SC_XOPEN_UNIX: ::c_int = 41; pub const _SC_MQ_PRIO_MAX: ::c_int = 51; pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 71; pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 72; pub const _SC_LOGIN_NAME_MAX: ::c_int = 73; pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 74; pub const _SC_THREAD_KEYS_MAX: ::c_int = 75; pub const _SC_THREAD_STACK_MIN: ::c_int = 76; pub const _SC_THREAD_THREADS_MAX: ::c_int = 77; pub const _SC_TTY_NAME_MAX: ::c_int = 78; pub const _SC_THREADS: ::c_int = 79; pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 80; pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 81; pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 82; pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 83; pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 84; pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 85; pub const _SC_NPROCESSORS_ONLN: ::c_int = 97; pub const PTHREAD_STACK_MIN: ::size_t = 8192; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { value: 0, }; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { value: 0, }; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { lock: PTHREAD_MUTEX_INITIALIZER, cond: PTHREAD_COND_INITIALIZER, numLocks: 0, writerThreadId: 0, pendingReaders: 0, pendingWriters: 0, reserved: [0 as *mut _; 4], }; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const FIOCLEX: ::c_int = 0x5451; pub const SA_ONSTACK: ::c_ulong = 0x08000000; pub const SA_SIGINFO: ::c_ulong = 0x00000004; pub const SA_NOCLDWAIT: ::c_ulong = 0x00000002; pub const SIGCHLD: ::c_int = 17; pub const SIGBUS: ::c_int = 7; pub const SIGUSR1: ::c_int = 10; pub const SIGUSR2: ::c_int = 12; pub const SIGCONT: ::c_int = 18; pub const SIGSTOP: ::c_int = 19; pub const SIGTSTP: ::c_int = 20; pub const SIGURG: ::c_int = 23; pub const SIGIO: ::c_int = 29; pub const SIGSYS: ::c_int = 31; pub const SIGSTKFLT: ::c_int = 16; pub const SIGUNUSED: ::c_int = 31; pub const SIGTTIN: ::c_int = 21; pub const SIGTTOU: ::c_int = 22; pub const SIGXCPU: ::c_int = 24; pub const SIGXFSZ: ::c_int = 25; pub const SIGVTALRM: ::c_int = 26; pub const SIGPROF: ::c_int = 27; pub const SIGWINCH: ::c_int = 28; pub const SIGPOLL: ::c_int = 29; pub const SIGPWR: ::c_int = 30; pub const SIG_SETMASK: ::c_int = 2; pub const SIG_BLOCK: ::c_int = 0x000000; pub const SIG_UNBLOCK: ::c_int = 0x01; pub const RUSAGE_CHILDREN: ::c_int = -1; pub const MAP_ANON: ::c_int = 0x0020; pub const MAP_ANONYMOUS: ::c_int = 0x0020; pub const MAP_GROWSDOWN: ::c_int = 0x0100; pub const MAP_DENYWRITE: ::c_int = 0x0800; pub const MAP_EXECUTABLE: ::c_int = 0x01000; pub const MAP_LOCKED: ::c_int = 0x02000; pub const MAP_NORESERVE: ::c_int = 0x04000; pub const MAP_POPULATE: ::c_int = 0x08000; pub const MAP_NONBLOCK: ::c_int = 0x010000; pub const MAP_STACK: ::c_int = 0x020000; pub const EDEADLK: ::c_int = 35; pub const ENAMETOOLONG: ::c_int = 36; pub const ENOLCK: ::c_int = 37; pub const ENOSYS: ::c_int = 38; pub const ENOTEMPTY: ::c_int = 39; pub const ELOOP: ::c_int = 40; pub const ENOMSG: ::c_int = 42; pub const EIDRM: ::c_int = 43; pub const ECHRNG: ::c_int = 44; pub const EL2NSYNC: ::c_int = 45; pub const EL3HLT: ::c_int = 46; pub const EL3RST: ::c_int = 47; pub const ELNRNG: ::c_int = 48; pub const EUNATCH: ::c_int = 49; pub const ENOCSI: ::c_int = 50; pub const EL2HLT: ::c_int = 51; pub const EBADE: ::c_int = 52; pub const EBADR: ::c_int = 53; pub const EXFULL: ::c_int = 54; pub const ENOANO: ::c_int = 55; pub const EBADRQC: ::c_int = 56; pub const EBADSLT: ::c_int = 57; pub const EMULTIHOP: ::c_int = 72; pub const EBADMSG: ::c_int = 74; pub const EOVERFLOW: ::c_int = 75; pub const ENOTUNIQ: ::c_int = 76; pub const EBADFD: ::c_int = 77; pub const EREMCHG: ::c_int = 78; pub const ELIBACC: ::c_int = 79; pub const ELIBBAD: ::c_int = 80; pub const ELIBSCN: ::c_int = 81; pub const ELIBMAX: ::c_int = 82; pub const ELIBEXEC: ::c_int = 83; pub const EILSEQ: ::c_int = 84; pub const ERESTART: ::c_int = 85; pub const ESTRPIPE: ::c_int = 86; pub const EUSERS: ::c_int = 87; pub const ENOTSOCK: ::c_int = 88; pub const EDESTADDRREQ: ::c_int = 89; pub const EMSGSIZE: ::c_int = 90; pub const EPROTOTYPE: ::c_int = 91; pub const ENOPROTOOPT: ::c_int = 92; pub const EPROTONOSUPPORT: ::c_int = 93; pub const ESOCKTNOSUPPORT: ::c_int = 94; pub const EOPNOTSUPP: ::c_int = 95; pub const EPFNOSUPPORT: ::c_int = 96; pub const EAFNOSUPPORT: ::c_int = 97; pub const EADDRINUSE: ::c_int = 98; pub const EADDRNOTAVAIL: ::c_int = 99; pub const ENETDOWN: ::c_int = 100; pub const ENETUNREACH: ::c_int = 101; pub const ENETRESET: ::c_int = 102; pub const ECONNABORTED: ::c_int = 103; pub const ECONNRESET: ::c_int = 104; pub const ENOBUFS: ::c_int = 105; pub const EISCONN: ::c_int = 106; pub const ENOTCONN: ::c_int = 107; pub const ESHUTDOWN: ::c_int = 108; pub const ETOOMANYREFS: ::c_int = 109; pub const ETIMEDOUT: ::c_int = 110; pub const ECONNREFUSED: ::c_int = 111; pub const EHOSTDOWN: ::c_int = 112; pub const EHOSTUNREACH: ::c_int = 113; pub const EALREADY: ::c_int = 114; pub const EINPROGRESS: ::c_int = 115; pub const ESTALE: ::c_int = 116; pub const EUCLEAN: ::c_int = 117; pub const ENOTNAM: ::c_int = 118; pub const ENAVAIL: ::c_int = 119; pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; pub const EDQUOT: ::c_int = 122; pub const ENOMEDIUM: ::c_int = 123; pub const EMEDIUMTYPE: ::c_int = 124; pub const ECANCELED: ::c_int = 125; pub const ENOKEY: ::c_int = 126; pub const EKEYEXPIRED: ::c_int = 127; pub const EKEYREVOKED: ::c_int = 128; pub const EKEYREJECTED: ::c_int = 129; pub const EOWNERDEAD: ::c_int = 130; pub const ENOTRECOVERABLE: ::c_int = 131; pub const SOCK_STREAM: ::c_int = 1; pub const SOCK_DGRAM: ::c_int = 2; pub const SOL_SOCKET: ::c_int = 1; pub const SO_REUSEADDR: ::c_int = 2; pub const SO_TYPE: ::c_int = 3; pub const SO_ERROR: ::c_int = 4; pub const SO_DONTROUTE: ::c_int = 5; pub const SO_BROADCAST: ::c_int = 6; pub const SO_SNDBUF: ::c_int = 7; pub const SO_RCVBUF: ::c_int = 8; pub const SO_KEEPALIVE: ::c_int = 9; pub const SO_OOBINLINE: ::c_int = 10; pub const SO_LINGER: ::c_int = 13; pub const SO_RCVLOWAT: ::c_int = 18; pub const SO_SNDLOWAT: ::c_int = 19; pub const SO_RCVTIMEO: ::c_int = 20; pub const SO_SNDTIMEO: ::c_int = 21; pub const SO_ACCEPTCONN: ::c_int = 30; pub const O_ACCMODE: ::c_int = 3; pub const O_APPEND: ::c_int = 1024; pub const O_CREAT: ::c_int = 64; pub const O_EXCL: ::c_int = 128; pub const O_NOCTTY: ::c_int = 256; pub const O_NONBLOCK: ::c_int = 2048; pub const O_SYNC: ::c_int = 0x1000; pub const O_DIRECT: ::c_int = 0x10000; pub const O_DIRECTORY: ::c_int = 0x4000; pub const O_NOFOLLOW: ::c_int = 0x8000; pub const O_ASYNC: ::c_int = 0x2000; pub const O_NDELAY: ::c_int = 0x800; pub const NI_MAXHOST: ::size_t = 1025; pub const NCCS: usize = 19; pub const TCXONC: ::c_int = 0x540A; pub const TCFLSH: ::c_int = 0x540B; pub const TCSBRKP: ::c_int = 0x5425; pub const TCGETS: ::c_int = 0x5401; pub const TCSANOW: ::c_int = 0x5402; pub const TCSADRAIN: ::c_int = 0x5403; pub const TCSAFLUSH: ::c_int = 0x5404; pub const IUTF8: ::tcflag_t = 0x00004000; pub const VEOF: usize = 4; pub const VEOL: usize = 11; pub const VEOL2: usize = 16; pub const VMIN: usize = 6; pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; pub const MS_RMT_MASK: ::c_ulong = 0x51; pub const MS_VERBOSE: ::c_ulong = 0x8000; pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; pub const TMPFS_MAGIC: ::c_long = 0x01021994; pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; pub const MADV_HUGEPAGE: ::c_int = 14; pub const MADV_NOHUGEPAGE: ::c_int = 15; pub const MAP_HUGETLB: ::c_int = 0x040000; pub const PTRACE_TRACEME: ::c_int = 0; pub const PTRACE_PEEKTEXT: ::c_int = 1; pub const PTRACE_PEEKDATA: ::c_int = 2; pub const PTRACE_PEEKUSER: ::c_int = 3; pub const PTRACE_POKETEXT: ::c_int = 4; pub const PTRACE_POKEDATA: ::c_int = 5; pub const PTRACE_POKEUSER: ::c_int = 6; pub const PTRACE_CONT: ::c_int = 7; pub const PTRACE_KILL: ::c_int = 8; pub const PTRACE_SINGLESTEP: ::c_int = 9; pub const PTRACE_ATTACH: ::c_int = 16; pub const PTRACE_DETACH: ::c_int = 17; pub const PTRACE_SYSCALL: ::c_int = 24; pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; pub const PTRACE_GETFPREGS: ::c_int = 14; pub const PTRACE_SETFPREGS: ::c_int = 15; pub const PTRACE_GETREGS: ::c_int = 12; pub const PTRACE_SETREGS: ::c_int = 13; pub const EFD_NONBLOCK: ::c_int = 0x800; pub const F_GETLK: ::c_int = 5; pub const F_GETOWN: ::c_int = 9; pub const F_SETOWN: ::c_int = 8; f! { pub fn sigemptyset(set: *mut sigset_t) -> ::c_int { *set = 0; return 0 } pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int { *set |= signum as sigset_t; return 0 } pub fn sigfillset(set: *mut sigset_t) -> ::c_int { *set = !0; return 0 } pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int { *set &= !(signum as sigset_t); return 0 } pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int { (*set & (signum as sigset_t)) as ::c_int } pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t { (*termios).c_cflag & ::CBAUD } pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t { (*termios).c_cflag & ::CBAUD } pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int { (*termios).c_cflag = ((*termios).c_cflag & !::CBAUD) | (speed & ::CBAUD); return 0 } pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int { (*termios).c_cflag = ((*termios).c_cflag & !::CBAUD) | (speed & ::CBAUD); return 0 } pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int { ioctl(fd, TCGETS, termios) } pub fn tcsetattr(fd: ::c_int, optional_actions: ::c_int, termios: *const ::termios) -> ::c_int { ioctl(fd, optional_actions, termios) } pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int { ioctl(fd, TCXONC, action as *mut ::c_void) } pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int { ioctl(fd, TCFLSH, action as *mut ::c_void) } pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int { ioctl(fd, TCSBRKP, duration as *mut ::c_void) } } extern { pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; pub fn putenv(string: *const ::c_char) -> ::c_int; pub fn readlink(path: *const ::c_char, buf: *mut ::c_char, bufsz: ::size_t) -> ::c_int; pub fn msync(addr: *const ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; pub fn sysconf(name: ::c_int) -> ::c_long; pub fn usleep(secs: ::c_ulong) -> ::c_int; pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, flags: ::c_uint, addr: *const ::sockaddr, addrlen: *mut ::socklen_t) -> ::ssize_t; pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, flags: ::c_uint) -> ::ssize_t; pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, flags: ::c_uint) -> ::ssize_t; pub fn getnameinfo(sa: *const ::sockaddr, salen: ::socklen_t, host: *mut ::c_char, hostlen: ::size_t, serv: *mut ::c_char, sevlen: ::size_t, flags: ::c_int) -> ::c_int; pub fn timegm64(tm: *const ::tm) -> time64_t; pub fn sendmsg(fd: ::c_int, msg: *const ::msghdr, flags: ::c_uint) -> ::c_int; pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_uint) -> ::c_int; pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; pub fn ptrace(request: ::c_int, ...) -> ::c_long; pub fn syscall(num: ::c_int, ...) -> ::c_int; } cfg_if! { if #[cfg(target_pointer_width = "32")] { mod b32; pub use self::b32::*; } else if #[cfg(target_pointer_width = "64")] { mod b64; pub use self::b64::*; } else { // ... } } deps/libc-0.2.4/src/unix/notbsd/android/b32.rs0000664000175000017500000000031112614241040015707 0ustar s! { pub struct sigaction { pub sa_sigaction: ::sighandler_t, pub sa_mask: ::sigset_t, pub sa_flags: ::c_ulong, pub sa_restorer: ::dox::Option, } } deps/libc-0.2.4/src/unix/mod.rs0000664000175000017500000007426312634314567013231 0ustar //! Definitions found commonly among almost all Unix derivatives //! //! More functions and definitions can be found in the more specific modules //! according to the platform in question. pub type pid_t = i32; pub type uid_t = u32; pub type gid_t = u32; pub type in_addr_t = u32; pub type in_port_t = u16; pub type sighandler_t = ::size_t; pub type cc_t = ::c_uchar; pub enum DIR {} s! { pub struct utimbuf { pub actime: time_t, pub modtime: time_t, } pub struct timeval { pub tv_sec: time_t, pub tv_usec: suseconds_t, } pub struct timespec { pub tv_sec: time_t, pub tv_nsec: c_long, } pub struct rlimit { pub rlim_cur: rlim_t, pub rlim_max: rlim_t, } pub struct rusage { pub ru_utime: timeval, pub ru_stime: timeval, pub ru_maxrss: c_long, pub ru_ixrss: c_long, pub ru_idrss: c_long, pub ru_isrss: c_long, pub ru_minflt: c_long, pub ru_majflt: c_long, pub ru_nswap: c_long, pub ru_inblock: c_long, pub ru_oublock: c_long, pub ru_msgsnd: c_long, pub ru_msgrcv: c_long, pub ru_nsignals: c_long, pub ru_nvcsw: c_long, pub ru_nivcsw: c_long, #[cfg(target_env = "musl")] __reserved: [c_long; 16], } #[cfg_attr(target_os = "netbsd", repr(packed))] pub struct in_addr { pub s_addr: in_addr_t, } pub struct in6_addr { pub s6_addr: [u8; 16], __align: [u32; 0], } pub struct ip_mreq { pub imr_multiaddr: in_addr, pub imr_interface: in_addr, } pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, #[cfg(target_os = "android")] pub ipv6mr_interface: ::c_int, #[cfg(not(target_os = "android"))] pub ipv6mr_interface: ::c_uint, } pub struct hostent { pub h_name: *mut ::c_char, pub h_aliases: *mut *mut ::c_char, pub h_addrtype: ::c_int, pub h_length: ::c_int, pub h_addr_list: *mut *mut ::c_char, } pub struct iovec { pub iov_base: *mut ::c_void, pub iov_len: ::size_t, } } pub const WNOHANG: ::c_int = 1; pub const SIG_DFL: sighandler_t = 0 as sighandler_t; pub const SIG_IGN: sighandler_t = 1 as sighandler_t; pub const SIG_ERR: sighandler_t = !0 as sighandler_t; pub const DT_FIFO: u8 = 1; pub const DT_CHR: u8 = 2; pub const DT_DIR: u8 = 4; pub const DT_BLK: u8 = 6; pub const DT_REG: u8 = 8; pub const DT_LNK: u8 = 10; pub const DT_SOCK: u8 = 12; pub const FD_CLOEXEC: ::c_int = 0x1; pub const USRQUOTA: ::c_int = 0; pub const GRPQUOTA: ::c_int = 1; pub const SIGIOT: ::c_int = 6; pub const S_ISUID: ::c_int = 0x800; pub const S_ISGID: ::c_int = 0x400; pub const S_ISVTX: ::c_int = 0x200; cfg_if! { if #[cfg(feature = "default")] { // cargo build, don't pull in anything extra as the libstd dep // already pulls in all libs. } else if #[cfg(target_env = "musl")] { #[link(name = "c", kind = "static")] extern {} } else if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "android", target_os = "openbsd", target_os = "bitrig"))] { #[link(name = "c")] #[link(name = "m")] extern {} } else { #[link(name = "c")] #[link(name = "m")] #[link(name = "rt")] extern {} } } extern { #[cfg_attr(target_os = "netbsd", link_name = "__socket30")] pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "connect$UNIX2003")] pub fn connect(socket: ::c_int, address: *const sockaddr, len: socklen_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "bind$UNIX2003")] pub fn bind(socket: ::c_int, address: *const sockaddr, address_len: socklen_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "listen$UNIX2003")] pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "accept$UNIX2003")] pub fn accept(socket: ::c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "getpeername$UNIX2003")] pub fn getpeername(socket: ::c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "getsockname$UNIX2003")] pub fn getsockname(socket: ::c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> ::c_int; pub fn setsockopt(socket: ::c_int, level: ::c_int, name: ::c_int, value: *const ::c_void, option_len: socklen_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "socketpair$UNIX2003")] pub fn socketpair(domain: ::c_int, type_: ::c_int, protocol: ::c_int, socket_vector: *mut ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "sendto$UNIX2003")] pub fn sendto(socket: ::c_int, buf: *const ::c_void, len: ::size_t, flags: ::c_int, addr: *const sockaddr, addrlen: socklen_t) -> ::ssize_t; pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "chmod$UNIX2003")] pub fn chmod(path: *const c_char, mode: mode_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fchmod$UNIX2003")] pub fn fchmod(fd: ::c_int, mode: mode_t) -> ::c_int; #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")] pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int; #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__stat50")] pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "popen$UNIX2003")] pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; pub fn pclose(stream: *mut ::FILE) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fdopen$UNIX2003")] pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE; pub fn fileno(stream: *mut ::FILE) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "open$UNIX2003")] pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "creat$UNIX2003")] pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fcntl$UNIX2003")] pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "opendir$INODE64")] #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "opendir$INODE64$UNIX2003")] #[cfg_attr(target_os = "netbsd", link_name = "__opendir30")] pub fn opendir(dirname: *const c_char) -> *mut ::DIR; #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")] pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent, result: *mut *mut ::dirent) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "closedir$UNIX2003")] pub fn closedir(dirp: *mut ::DIR) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "rewinddir$INODE64")] #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "rewinddir$INODE64$UNIX2003")] pub fn rewinddir(dirp: *mut ::DIR); pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int; pub fn alarm(seconds: ::c_uint) -> ::c_uint; pub fn chdir(dir: *const c_char) -> ::c_int; pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "close$UNIX2003")] pub fn close(fd: ::c_int) -> ::c_int; pub fn dup(fd: ::c_int) -> ::c_int; pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int; pub fn execv(prog: *const c_char, argv: *const *const c_char) -> ::c_int; pub fn execve(prog: *const c_char, argv: *const *const c_char, envp: *const *const c_char) -> ::c_int; pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int; pub fn fork() -> pid_t; pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long; pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char; pub fn getegid() -> gid_t; pub fn geteuid() -> uid_t; pub fn getgid() -> gid_t; pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t) -> ::c_int; pub fn getlogin() -> *mut c_char; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "getopt$UNIX2003")] pub fn getopt(argc: ::c_int, argv: *const *mut c_char, optstr: *const c_char) -> ::c_int; pub fn getpgrp() -> pid_t; pub fn getpid() -> pid_t; pub fn getppid() -> pid_t; pub fn getuid() -> uid_t; pub fn isatty(fd: ::c_int) -> ::c_int; pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int; pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t; pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pause$UNIX2003")] pub fn pause() -> ::c_int; pub fn pipe(fds: *mut ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "read$UNIX2003")] pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) -> ::ssize_t; pub fn rmdir(path: *const c_char) -> ::c_int; pub fn setgid(gid: gid_t) -> ::c_int; pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int; pub fn setsid() -> pid_t; pub fn setuid(uid: uid_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "sleep$UNIX2003")] pub fn sleep(secs: ::c_uint) -> ::c_uint; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "nanosleep$UNIX2003")] #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")] pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> ::c_int; pub fn tcgetpgrp(fd: ::c_int) -> pid_t; pub fn ttyname(fd: ::c_int) -> *mut c_char; pub fn unlink(c: *const c_char) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "wait$UNIX2003")] pub fn wait(status: *mut ::c_int) -> pid_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "waitpid$UNIX2003")] pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int) -> pid_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "write$UNIX2003")] pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pread$UNIX2003")] pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, offset: off_t) -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pwrite$UNIX2003")] pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t, offset: off_t) -> ::ssize_t; pub fn umask(mask: mode_t) -> mode_t; #[cfg_attr(target_os = "netbsd", link_name = "__utime50")] pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "kill$UNIX2003")] pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int; pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; pub fn mlockall(flags: ::c_int) -> ::c_int; pub fn munlockall() -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "mmap$UNIX2003")] pub fn mmap(addr: *mut ::c_void, len: ::size_t, prot: ::c_int, flags: ::c_int, fd: ::c_int, offset: off_t) -> *mut ::c_void; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "munmap$UNIX2003")] pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int; pub fn if_nametoindex(ifname: *const c_char) -> ::c_uint; #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")] pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fsync$UNIX2003")] pub fn fsync(fd: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "setenv$UNIX2003")] pub fn setenv(name: *const c_char, val: *const c_char, overwrite: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "unsetenv$UNIX2003")] #[cfg_attr(target_os = "netbsd", link_name = "__unsetenv13")] pub fn unsetenv(name: *const c_char) -> ::c_int; pub fn symlink(path1: *const c_char, path2: *const c_char) -> ::c_int; pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int; #[cfg_attr(target_os = "android", link_name = "bsd_signal")] pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "getrlimit$UNIX2003")] pub fn getrlimit(resource: ::c_int, rlim: *mut rlimit) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "setrlimit$UNIX2003")] pub fn setrlimit(resource: ::c_int, rlim: *const rlimit) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")] pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int; pub fn getdtablesize() -> ::c_int; #[cfg_attr(any(target_os = "macos", target_os = "ios"), link_name = "realpath$DARWIN_EXTSN")] pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) -> *mut ::c_char; pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int; #[cfg_attr(arget_os = "netbsd", link_name = "__gettimeofday50")] pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; pub fn pthread_self() -> ::pthread_t; pub fn pthread_create(native: *mut ::pthread_t, attr: *const ::pthread_attr_t, f: extern fn(*mut ::c_void) -> *mut ::c_void, value: *mut ::c_void) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pthread_join$UNIX2003")] pub fn pthread_join(native: ::pthread_t, value: *mut *mut ::c_void) -> ::c_int; pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int; pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int; pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t, stack_size: ::size_t) -> ::c_int; pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t, state: ::c_int) -> ::c_int; pub fn pthread_detach(thread: ::pthread_t) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")] pub fn sched_yield() -> ::c_int; pub fn pthread_key_create(key: *mut pthread_key_t, dtor: ::dox::Option) -> ::c_int; pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int; pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void; pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void) -> ::c_int; pub fn pthread_mutex_init(lock: *mut pthread_mutex_t, attr: *const pthread_mutexattr_t) -> ::c_int; pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int; pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int; pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int; pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int; pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pthread_mutexattr_destroy$UNIX2003")] pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int; pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, _type: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pthread_cond_wait$UNIX2003")] pub fn pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pthread_cond_timedwait$UNIX2003")] pub fn pthread_cond_timedwait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t, abstime: *const ::timespec) -> ::c_int; pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int; pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int; pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pthread_rwlock_destroy$UNIX2003")] pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pthread_rwlock_rdlock$UNIX2003")] pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pthread_rwlock_tryrdlock$UNIX2003")] pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pthread_rwlock_wrlock$UNIX2003")] pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pthread_rwlock_trywrlock$UNIX2003")] pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pthread_rwlock_unlock$UNIX2003")] pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pthread_sigmask$UNIX2003")] pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, oldset: *mut sigset_t) -> ::c_int; // #[cfg_attr(target_os = "linux", link_name = "__xpg_strerror_r")] pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int; pub fn getsockopt(sockfd: ::c_int, level: ::c_int, optname: ::c_int, optval: *mut ::c_void, optlen: *mut ::socklen_t) -> ::c_int; pub fn raise(signum: ::c_int) -> ::c_int; pub fn sigaction(signum: ::c_int, act: *const sigaction, oldact: *mut sigaction) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "sigaltstack$UNIX2003")] pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")] pub fn utimes(filename: *const ::c_char, times: *const ::timeval) -> ::c_int; pub fn dlopen(filename: *const ::c_char, flag: ::c_int) -> *mut ::c_void; pub fn dlerror() -> *mut ::c_char; pub fn dlsym(handle: *mut ::c_void, symbol: *const ::c_char) -> *mut ::c_void; pub fn dlclose(handle: *mut ::c_void) -> ::c_int; pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int; pub fn getaddrinfo(node: *const c_char, service: *const c_char, hints: *const addrinfo, res: *mut *mut addrinfo) -> ::c_int; pub fn freeaddrinfo(res: *mut addrinfo); pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char; #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")] pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")] pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "mktime$UNIX2003")] #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")] pub fn mktime(tm: *mut tm) -> time_t; #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] pub fn mknod(pathname: *const ::c_char, mode: ::mode_t, dev: ::dev_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "writev$UNIX2003")] pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "readv$UNIX2003")] pub fn readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t; pub fn uname(buf: *mut ::utsname) -> ::c_int; pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int; pub fn chroot(name: *const ::c_char) -> ::c_int; } // TODO: get rid of this #[cfg(not(...))] #[cfg(not(target_os = "android"))] extern { pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> ::c_int; pub fn freeifaddrs(ifa: *mut ifaddrs); #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__glob30")] pub fn glob(pattern: *const c_char, flags: ::c_int, errfunc: ::dox::Option ::c_int>, pglob: *mut glob_t) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")] pub fn globfree(pglob: *mut glob_t); pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; pub fn shm_unlink(name: *const c_char) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "seekdir$INODE64")] #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "seekdir$INODE64$UNIX2003")] pub fn seekdir(dirp: *mut ::DIR, loc: c_long); #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "telldir$INODE64")] #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "telldir$INODE64$UNIX2003")] pub fn telldir(dirp: *mut ::DIR) -> c_long; pub fn getsid(pid: pid_t) -> pid_t; pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "putenv$UNIX2003")] #[cfg_attr(target_os = "netbsd", link_name = "__putenv50")] pub fn putenv(string: *mut c_char) -> ::c_int; pub fn readlink(path: *const c_char, buf: *mut c_char, bufsz: ::size_t) -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "msync$UNIX2003")] #[cfg_attr(target_os = "netbsd", link_name = "__msync13")] pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; pub fn sysconf(name: ::c_int) -> c_long; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "usleep$UNIX2003")] pub fn usleep(secs: ::c_uint) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "recvfrom$UNIX2003")] pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, flags: ::c_int, addr: *mut sockaddr, addrlen: *mut socklen_t) -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "send$UNIX2003")] pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, flags: ::c_int) -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "recv$UNIX2003")] pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::ssize_t; pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")] pub fn getpwuid_r(uid: ::uid_t, pwd: *mut passwd, buf: *mut ::c_char, buflen: ::size_t, result: *mut *mut passwd) -> ::c_int; pub fn posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_t) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")] pub fn sigemptyset(set: *mut sigset_t) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")] pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")] pub fn sigfillset(set: *mut sigset_t) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")] pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")] pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "select$1050")] #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "select$UNIX2003")] #[cfg_attr(target_os = "netbsd", link_name = "__select50")] pub fn select(nfds: ::c_int, readfs: *mut fd_set, writefds: *mut fd_set, errorfds: *mut fd_set, timeout: *mut timeval) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "pselect$1050")] #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pselect$UNIX2003")] #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")] pub fn pselect(nfds: ::c_int, readfs: *mut fd_set, writefds: *mut fd_set, errorfds: *mut fd_set, timeout: *const timespec, sigmask: *const sigset_t) -> ::c_int; pub fn fseeko(stream: *mut ::FILE, offset: ::off_t, whence: ::c_int) -> ::c_int; pub fn ftello(stream: *mut ::FILE) -> ::off_t; #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")] pub fn timegm(tm: *mut ::tm) -> time_t; pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int; pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "sendmsg$UNIX2003")] pub fn sendmsg(fd: ::c_int, msg: *const msghdr, flags: ::c_int) -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "recvmsg$UNIX2003")] pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "tcdrain$UNIX2003")] pub fn tcdrain(fd: ::c_int) -> ::c_int; pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t; pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t; pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int; pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int; pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int; pub fn tcsetattr(fd: ::c_int, optional_actions: ::c_int, termios: *const ::termios) -> ::c_int; pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int; pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int; pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int; } cfg_if! { if #[cfg(any(target_os = "linux", target_os = "android"))] { mod notbsd; pub use self::notbsd::*; } else if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd", target_os = "bitrig"))] { mod bsd; pub use self::bsd::*; } else { // ... } } deps/libc-0.2.4/src/unix/bsd/0000755000000000000000000000000012666635520014414 5ustar rootrootdeps/libc-0.2.4/src/unix/bsd/freebsdlike/0000755000000000000000000000000012666635520016673 5ustar rootrootdeps/libc-0.2.4/src/unix/bsd/freebsdlike/x86.rs0000664000175000017500000000153112614241040016071 0ustar pub type c_long = i32; pub type c_ulong = u32; pub type time_t = i32; pub type suseconds_t = i32; s! { pub struct stat { pub st_dev: ::dev_t, pub st_ino: ::ino_t, pub st_mode: ::mode_t, pub st_nlink: ::nlink_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, pub st_rdev: ::dev_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, pub st_size: ::off_t, pub st_blocks: ::blkcnt_t, pub st_blksize: ::blksize_t, pub st_flags: ::fflags_t, pub st_gen: ::uint32_t, pub st_lspare: ::int32_t, pub st_birthtime: ::time_t, pub st_birthtime_nsec: ::c_long, __unused: [u8; 8], } } deps/libc-0.2.4/src/unix/bsd/freebsdlike/freebsd.rs0000664000175000017500000000026212627157536017102 0ustar pub const PTHREAD_STACK_MIN: ::size_t = 2048; pub const KERN_PROC_PATHNAME: ::c_int = 12; pub const SIGSTKSZ: ::size_t = 34816; extern { pub fn __error() -> *mut ::c_int; } deps/libc-0.2.4/src/unix/bsd/freebsdlike/x86_64.rs0000664000175000017500000000147612614241040016412 0ustar pub type c_long = i64; pub type c_ulong = u64; pub type time_t = i64; pub type suseconds_t = i64; s! { pub struct stat { pub st_dev: ::dev_t, pub st_ino: ::ino_t, pub st_mode: ::mode_t, pub st_nlink: ::nlink_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, pub st_rdev: ::dev_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, pub st_size: ::off_t, pub st_blocks: ::blkcnt_t, pub st_blksize: ::blksize_t, pub st_flags: ::fflags_t, pub st_gen: ::uint32_t, pub st_lspare: ::int32_t, pub st_birthtime: ::time_t, pub st_birthtime_nsec: ::c_long, } } deps/libc-0.2.4/src/unix/bsd/freebsdlike/mod.rs0000664000175000017500000004714012634630015016237 0ustar pub type clock_t = i32; pub type dev_t = u32; pub type ino_t = u32; pub type mode_t = u16; pub type nlink_t = u16; pub type blksize_t = u32; pub type fflags_t = u32; pub type pthread_attr_t = *mut ::c_void; pub type rlim_t = i64; pub type pthread_mutex_t = *mut ::c_void; pub type pthread_mutexattr_t = *mut ::c_void; pub type pthread_cond_t = *mut ::c_void; pub type pthread_rwlock_t = *mut ::c_void; pub type pthread_key_t = ::c_int; pub type fsblkcnt_t = ::c_uint; pub type fsfilcnt_t = ::c_uint; pub type tcflag_t = ::c_uint; pub type speed_t = ::c_uint; pub enum timezone {} s! { pub struct dirent { pub d_fileno: u32, pub d_reclen: u16, pub d_type: u8, pub d_namelen: u8, pub d_name: [::c_char; 256], } pub struct glob_t { pub gl_pathc: ::size_t, __unused1: ::size_t, pub gl_offs: ::size_t, __unused2: ::c_int, pub gl_pathv: *mut *mut ::c_char, __unused3: *mut ::c_void, __unused4: *mut ::c_void, __unused5: *mut ::c_void, __unused6: *mut ::c_void, __unused7: *mut ::c_void, __unused8: *mut ::c_void, } pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: ::sa_family_t, __ss_pad1: [u8; 6], __ss_align: i64, __ss_pad2: [u8; 112], } pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, pub ai_socktype: ::c_int, pub ai_protocol: ::c_int, pub ai_addrlen: ::socklen_t, pub ai_canonname: *mut ::c_char, pub ai_addr: *mut ::sockaddr, pub ai_next: *mut addrinfo, } pub struct sigset_t { bits: [u32; 4], } pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, pub si_code: ::c_int, pub si_pid: ::pid_t, pub si_uid: ::uid_t, pub si_status: ::c_int, pub si_addr: *mut ::c_void, _pad: [::c_int; 12], } pub struct sigaction { pub sa_sigaction: ::sighandler_t, pub sa_flags: ::c_int, pub sa_mask: sigset_t, } pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_size: ::size_t, pub ss_flags: ::c_int, } pub struct statvfs { pub f_bavail: ::fsblkcnt_t, pub f_bfree: ::fsblkcnt_t, pub f_blocks: ::fsblkcnt_t, pub f_favail: ::fsfilcnt_t, pub f_ffree: ::fsfilcnt_t, pub f_files: ::fsfilcnt_t, pub f_bsize: ::c_ulong, pub f_flag: ::c_ulong, pub f_frsize: ::c_ulong, pub f_fsid: ::c_ulong, pub f_namemax: ::c_ulong, } pub struct sched_param { pub sched_priority: ::c_int, } pub struct Dl_info { pub dli_fname: *const ::c_char, pub dli_fbase: *mut ::c_void, pub dli_sname: *const ::c_char, pub dli_saddr: *mut ::c_void, } pub struct sockaddr_in { pub sin_len: u8, pub sin_family: ::sa_family_t, pub sin_port: ::in_port_t, pub sin_addr: ::in_addr, pub sin_zero: [::c_char; 8], } pub struct termios { pub c_iflag: ::tcflag_t, pub c_oflag: ::tcflag_t, pub c_cflag: ::tcflag_t, pub c_lflag: ::tcflag_t, pub c_cc: [::cc_t; ::NCCS], pub c_ispeed: ::speed_t, pub c_ospeed: ::speed_t, } } pub const EXIT_FAILURE: ::c_int = 1; pub const EXIT_SUCCESS: ::c_int = 0; pub const RAND_MAX: ::c_int = 0x7fff_fffd; pub const EOF: ::c_int = -1; pub const SEEK_SET: ::c_int = 0; pub const SEEK_CUR: ::c_int = 1; pub const SEEK_END: ::c_int = 2; pub const _IOFBF: ::c_int = 0; pub const _IONBF: ::c_int = 2; pub const _IOLBF: ::c_int = 1; pub const BUFSIZ: ::c_uint = 1024; pub const FOPEN_MAX: ::c_uint = 20; pub const FILENAME_MAX: ::c_uint = 1024; pub const L_tmpnam: ::c_uint = 1024; pub const TMP_MAX: ::c_uint = 308915776; pub const O_RDONLY: ::c_int = 0; pub const O_WRONLY: ::c_int = 1; pub const O_RDWR: ::c_int = 2; pub const O_APPEND: ::c_int = 8; pub const O_CREAT: ::c_int = 512; pub const O_EXCL: ::c_int = 2048; pub const O_NOCTTY: ::c_int = 32768; pub const O_TRUNC: ::c_int = 1024; pub const O_CLOEXEC: ::c_int = 0x00100000; pub const S_IFIFO: mode_t = 4096; pub const S_IFCHR: mode_t = 8192; pub const S_IFBLK: mode_t = 24576; pub const S_IFDIR: mode_t = 16384; pub const S_IFREG: mode_t = 32768; pub const S_IFLNK: mode_t = 40960; pub const S_IFSOCK: mode_t = 49152; pub const S_IFMT: mode_t = 61440; pub const S_IEXEC: mode_t = 64; pub const S_IWRITE: mode_t = 128; pub const S_IREAD: mode_t = 256; pub const S_IRWXU: mode_t = 448; pub const S_IXUSR: mode_t = 64; pub const S_IWUSR: mode_t = 128; pub const S_IRUSR: mode_t = 256; pub const S_IRWXG: mode_t = 56; pub const S_IXGRP: mode_t = 8; pub const S_IWGRP: mode_t = 16; pub const S_IRGRP: mode_t = 32; pub const S_IRWXO: mode_t = 7; pub const S_IXOTH: mode_t = 1; pub const S_IWOTH: mode_t = 2; pub const S_IROTH: mode_t = 4; pub const F_OK: ::c_int = 0; pub const R_OK: ::c_int = 4; pub const W_OK: ::c_int = 2; pub const X_OK: ::c_int = 1; pub const STDIN_FILENO: ::c_int = 0; pub const STDOUT_FILENO: ::c_int = 1; pub const STDERR_FILENO: ::c_int = 2; pub const F_LOCK: ::c_int = 1; pub const F_TEST: ::c_int = 3; pub const F_TLOCK: ::c_int = 2; pub const F_ULOCK: ::c_int = 0; pub const F_DUPFD_CLOEXEC: ::c_int = 17; pub const SIGHUP: ::c_int = 1; pub const SIGINT: ::c_int = 2; pub const SIGQUIT: ::c_int = 3; pub const SIGILL: ::c_int = 4; pub const SIGABRT: ::c_int = 6; pub const SIGFPE: ::c_int = 8; pub const SIGKILL: ::c_int = 9; pub const SIGSEGV: ::c_int = 11; pub const SIGPIPE: ::c_int = 13; pub const SIGALRM: ::c_int = 14; pub const SIGTERM: ::c_int = 15; pub const PROT_NONE: ::c_int = 0; pub const PROT_READ: ::c_int = 1; pub const PROT_WRITE: ::c_int = 2; pub const PROT_EXEC: ::c_int = 4; pub const MAP_FILE: ::c_int = 0x0000; pub const MAP_SHARED: ::c_int = 0x0001; pub const MAP_PRIVATE: ::c_int = 0x0002; pub const MAP_FIXED: ::c_int = 0x0010; pub const MAP_ANON: ::c_int = 0x1000; pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; pub const MS_SYNC: ::c_int = 0x0000; pub const MS_ASYNC: ::c_int = 0x0001; pub const MS_INVALIDATE: ::c_int = 0x0002; pub const EPERM: ::c_int = 1; pub const ENOENT: ::c_int = 2; pub const ESRCH: ::c_int = 3; pub const EINTR: ::c_int = 4; pub const EIO: ::c_int = 5; pub const ENXIO: ::c_int = 6; pub const E2BIG: ::c_int = 7; pub const ENOEXEC: ::c_int = 8; pub const EBADF: ::c_int = 9; pub const ECHILD: ::c_int = 10; pub const EDEADLK: ::c_int = 11; pub const ENOMEM: ::c_int = 12; pub const EACCES: ::c_int = 13; pub const EFAULT: ::c_int = 14; pub const ENOTBLK: ::c_int = 15; pub const EBUSY: ::c_int = 16; pub const EEXIST: ::c_int = 17; pub const EXDEV: ::c_int = 18; pub const ENODEV: ::c_int = 19; pub const ENOTDIR: ::c_int = 20; pub const EISDIR: ::c_int = 21; pub const EINVAL: ::c_int = 22; pub const ENFILE: ::c_int = 23; pub const EMFILE: ::c_int = 24; pub const ENOTTY: ::c_int = 25; pub const ETXTBSY: ::c_int = 26; pub const EFBIG: ::c_int = 27; pub const ENOSPC: ::c_int = 28; pub const ESPIPE: ::c_int = 29; pub const EROFS: ::c_int = 30; pub const EMLINK: ::c_int = 31; pub const EPIPE: ::c_int = 32; pub const EDOM: ::c_int = 33; pub const ERANGE: ::c_int = 34; pub const EAGAIN: ::c_int = 35; pub const EWOULDBLOCK: ::c_int = 35; pub const EINPROGRESS: ::c_int = 36; pub const EALREADY: ::c_int = 37; pub const ENOTSOCK: ::c_int = 38; pub const EDESTADDRREQ: ::c_int = 39; pub const EMSGSIZE: ::c_int = 40; pub const EPROTOTYPE: ::c_int = 41; pub const ENOPROTOOPT: ::c_int = 42; pub const EPROTONOSUPPORT: ::c_int = 43; pub const ESOCKTNOSUPPORT: ::c_int = 44; pub const EOPNOTSUPP: ::c_int = 45; pub const EPFNOSUPPORT: ::c_int = 46; pub const EAFNOSUPPORT: ::c_int = 47; pub const EADDRINUSE: ::c_int = 48; pub const EADDRNOTAVAIL: ::c_int = 49; pub const ENETDOWN: ::c_int = 50; pub const ENETUNREACH: ::c_int = 51; pub const ENETRESET: ::c_int = 52; pub const ECONNABORTED: ::c_int = 53; pub const ECONNRESET: ::c_int = 54; pub const ENOBUFS: ::c_int = 55; pub const EISCONN: ::c_int = 56; pub const ENOTCONN: ::c_int = 57; pub const ESHUTDOWN: ::c_int = 58; pub const ETOOMANYREFS: ::c_int = 59; pub const ETIMEDOUT: ::c_int = 60; pub const ECONNREFUSED: ::c_int = 61; pub const ELOOP: ::c_int = 62; pub const ENAMETOOLONG: ::c_int = 63; pub const EHOSTDOWN: ::c_int = 64; pub const EHOSTUNREACH: ::c_int = 65; pub const ENOTEMPTY: ::c_int = 66; pub const EPROCLIM: ::c_int = 67; pub const EUSERS: ::c_int = 68; pub const EDQUOT: ::c_int = 69; pub const ESTALE: ::c_int = 70; pub const EREMOTE: ::c_int = 71; pub const EBADRPC: ::c_int = 72; pub const ERPCMISMATCH: ::c_int = 73; pub const EPROGUNAVAIL: ::c_int = 74; pub const EPROGMISMATCH: ::c_int = 75; pub const EPROCUNAVAIL: ::c_int = 76; pub const ENOLCK: ::c_int = 77; pub const ENOSYS: ::c_int = 78; pub const EFTYPE: ::c_int = 79; pub const EAUTH: ::c_int = 80; pub const ENEEDAUTH: ::c_int = 81; pub const EIDRM: ::c_int = 82; pub const ENOMSG: ::c_int = 83; pub const EOVERFLOW: ::c_int = 84; pub const ECANCELED: ::c_int = 85; pub const EILSEQ: ::c_int = 86; pub const ENOATTR: ::c_int = 87; pub const EDOOFUS: ::c_int = 88; pub const EBADMSG: ::c_int = 89; pub const EMULTIHOP: ::c_int = 90; pub const ENOLINK: ::c_int = 91; pub const EPROTO: ::c_int = 92; pub const ELAST: ::c_int = 96; pub const F_DUPFD: ::c_int = 0; pub const F_GETFD: ::c_int = 1; pub const F_SETFD: ::c_int = 2; pub const F_GETFL: ::c_int = 3; pub const F_SETFL: ::c_int = 4; pub const SIGTRAP: ::c_int = 5; pub const GLOB_APPEND : ::c_int = 0x0001; pub const GLOB_DOOFFS : ::c_int = 0x0002; pub const GLOB_ERR : ::c_int = 0x0004; pub const GLOB_MARK : ::c_int = 0x0008; pub const GLOB_NOCHECK : ::c_int = 0x0010; pub const GLOB_NOSORT : ::c_int = 0x0020; pub const GLOB_NOESCAPE: ::c_int = 0x2000; pub const GLOB_NOSPACE : ::c_int = -1; pub const GLOB_ABORTED : ::c_int = -2; pub const GLOB_NOMATCH : ::c_int = -3; pub const POSIX_MADV_NORMAL: ::c_int = 0; pub const POSIX_MADV_RANDOM: ::c_int = 1; pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; pub const POSIX_MADV_WILLNEED: ::c_int = 3; pub const POSIX_MADV_DONTNEED: ::c_int = 4; pub const _SC_IOV_MAX: ::c_int = 56; pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 70; pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 71; pub const _SC_LOGIN_NAME_MAX: ::c_int = 73; pub const _SC_MQ_PRIO_MAX: ::c_int = 75; pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 82; pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 83; pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 85; pub const _SC_THREAD_KEYS_MAX: ::c_int = 86; pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 87; pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 88; pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 89; pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 90; pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 91; pub const _SC_THREAD_STACK_MIN: ::c_int = 93; pub const _SC_THREAD_THREADS_MAX: ::c_int = 94; pub const _SC_THREADS: ::c_int = 96; pub const _SC_TTY_NAME_MAX: ::c_int = 101; pub const _SC_ATEXIT_MAX: ::c_int = 107; pub const _SC_XOPEN_CRYPT: ::c_int = 108; pub const _SC_XOPEN_ENH_I18N: ::c_int = 109; pub const _SC_XOPEN_LEGACY: ::c_int = 110; pub const _SC_XOPEN_REALTIME: ::c_int = 111; pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 112; pub const _SC_XOPEN_SHM: ::c_int = 113; pub const _SC_XOPEN_UNIX: ::c_int = 115; pub const _SC_XOPEN_VERSION: ::c_int = 116; pub const _SC_XOPEN_XCU_VERSION: ::c_int = 117; pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; pub const CLOCK_REALTIME: ::c_int = 0; pub const CLOCK_MONOTONIC: ::c_int = 4; pub const RLIMIT_CPU: ::c_int = 0; pub const RLIMIT_FSIZE: ::c_int = 1; pub const RLIMIT_DATA: ::c_int = 2; pub const RLIMIT_STACK: ::c_int = 3; pub const RLIMIT_CORE: ::c_int = 4; pub const RLIMIT_RSS: ::c_int = 5; pub const RLIMIT_MEMLOCK: ::c_int = 6; pub const RLIMIT_NPROC: ::c_int = 7; pub const RLIMIT_NOFILE: ::c_int = 8; pub const RLIMIT_SBSIZE: ::c_int = 9; pub const RLIMIT_VMEM: ::c_int = 10; pub const RLIMIT_AS: ::c_int = RLIMIT_VMEM; pub const RLIMIT_NPTS: ::c_int = 11; pub const RLIMIT_SWAP: ::c_int = 12; pub const RLIM_NLIMITS: rlim_t = 13; pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; pub const RUSAGE_SELF: ::c_int = 0; pub const RUSAGE_CHILDREN: ::c_int = -1; pub const RUSAGE_THREAD: ::c_int = 1; pub const MADV_NORMAL: ::c_int = 0; pub const MADV_RANDOM: ::c_int = 1; pub const MADV_SEQUENTIAL: ::c_int = 2; pub const MADV_WILLNEED: ::c_int = 3; pub const MADV_DONTNEED: ::c_int = 4; pub const MADV_FREE: ::c_int = 5; pub const MADV_NOSYNC: ::c_int = 6; pub const MADV_AUTOSYNC: ::c_int = 7; pub const MADV_NOCORE: ::c_int = 8; pub const MADV_CORE: ::c_int = 9; pub const MADV_PROTECT: ::c_int = 10; pub const MINCORE_INCORE: ::c_int = 0x1; pub const MINCORE_REFERENCED: ::c_int = 0x2; pub const MINCORE_MODIFIED: ::c_int = 0x4; pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8; pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10; pub const MINCORE_SUPER: ::c_int = 0x20; pub const AF_INET: ::c_int = 2; pub const AF_INET6: ::c_int = 28; pub const AF_UNIX: ::c_int = 1; pub const SOCK_STREAM: ::c_int = 1; pub const SOCK_DGRAM: ::c_int = 2; pub const SOCK_RAW: ::c_int = 3; pub const IPPROTO_TCP: ::c_int = 6; pub const IPPROTO_IP: ::c_int = 0; pub const IPPROTO_IPV6: ::c_int = 41; pub const IP_MULTICAST_TTL: ::c_int = 10; pub const IP_MULTICAST_LOOP: ::c_int = 11; pub const IP_TTL: ::c_int = 4; pub const IP_HDRINCL: ::c_int = 2; pub const IP_ADD_MEMBERSHIP: ::c_int = 12; pub const IP_DROP_MEMBERSHIP: ::c_int = 13; pub const IPV6_JOIN_GROUP: ::c_int = 12; pub const IPV6_LEAVE_GROUP: ::c_int = 13; pub const TCP_NODELAY: ::c_int = 1; pub const TCP_KEEPIDLE: ::c_int = 256; pub const SOL_SOCKET: ::c_int = 0xffff; pub const SO_DEBUG: ::c_int = 0x01; pub const SO_ACCEPTCONN: ::c_int = 0x0002; pub const SO_REUSEADDR: ::c_int = 0x0004; pub const SO_KEEPALIVE: ::c_int = 0x0008; pub const SO_DONTROUTE: ::c_int = 0x0010; pub const SO_BROADCAST: ::c_int = 0x0020; pub const SO_USELOOPBACK: ::c_int = 0x0040; pub const SO_LINGER: ::c_int = 0x0080; pub const SO_OOBINLINE: ::c_int = 0x0100; pub const SO_REUSEPORT: ::c_int = 0x0200; pub const SO_SNDBUF: ::c_int = 0x1001; pub const SO_RCVBUF: ::c_int = 0x1002; pub const SO_SNDLOWAT: ::c_int = 0x1003; pub const SO_RCVLOWAT: ::c_int = 0x1004; pub const SO_SNDTIMEO: ::c_int = 0x1005; pub const SO_RCVTIMEO: ::c_int = 0x1006; pub const SO_ERROR: ::c_int = 0x1007; pub const SO_TYPE: ::c_int = 0x1008; pub const IFF_LOOPBACK: ::c_int = 0x8; pub const SHUT_RD: ::c_int = 0; pub const SHUT_WR: ::c_int = 1; pub const SHUT_RDWR: ::c_int = 2; pub const LOCK_SH: ::c_int = 1; pub const LOCK_EX: ::c_int = 2; pub const LOCK_NB: ::c_int = 4; pub const LOCK_UN: ::c_int = 8; pub const O_SYNC: ::c_int = 128; pub const O_NONBLOCK: ::c_int = 4; pub const CTL_KERN: ::c_int = 1; pub const KERN_PROC: ::c_int = 14; pub const MAP_COPY: ::c_int = 0x0002; pub const MAP_RENAME: ::c_int = 0x0020; pub const MAP_NORESERVE: ::c_int = 0x0040; pub const MAP_HASSEMAPHORE: ::c_int = 0x0200; pub const MAP_STACK: ::c_int = 0x0400; pub const MAP_NOSYNC: ::c_int = 0x0800; pub const MAP_NOCORE: ::c_int = 0x020000; pub const IPPROTO_RAW: ::c_int = 255; pub const _SC_ARG_MAX: ::c_int = 1; pub const _SC_CHILD_MAX: ::c_int = 2; pub const _SC_CLK_TCK: ::c_int = 3; pub const _SC_NGROUPS_MAX: ::c_int = 4; pub const _SC_OPEN_MAX: ::c_int = 5; pub const _SC_JOB_CONTROL: ::c_int = 6; pub const _SC_SAVED_IDS: ::c_int = 7; pub const _SC_VERSION: ::c_int = 8; pub const _SC_BC_BASE_MAX: ::c_int = 9; pub const _SC_BC_DIM_MAX: ::c_int = 10; pub const _SC_BC_SCALE_MAX: ::c_int = 11; pub const _SC_BC_STRING_MAX: ::c_int = 12; pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 13; pub const _SC_EXPR_NEST_MAX: ::c_int = 14; pub const _SC_LINE_MAX: ::c_int = 15; pub const _SC_RE_DUP_MAX: ::c_int = 16; pub const _SC_2_VERSION: ::c_int = 17; pub const _SC_2_C_BIND: ::c_int = 18; pub const _SC_2_C_DEV: ::c_int = 19; pub const _SC_2_CHAR_TERM: ::c_int = 20; pub const _SC_2_FORT_DEV: ::c_int = 21; pub const _SC_2_FORT_RUN: ::c_int = 22; pub const _SC_2_LOCALEDEF: ::c_int = 23; pub const _SC_2_SW_DEV: ::c_int = 24; pub const _SC_2_UPE: ::c_int = 25; pub const _SC_STREAM_MAX: ::c_int = 26; pub const _SC_TZNAME_MAX: ::c_int = 27; pub const _SC_ASYNCHRONOUS_IO: ::c_int = 28; pub const _SC_MAPPED_FILES: ::c_int = 29; pub const _SC_MEMLOCK: ::c_int = 30; pub const _SC_MEMLOCK_RANGE: ::c_int = 31; pub const _SC_MEMORY_PROTECTION: ::c_int = 32; pub const _SC_MESSAGE_PASSING: ::c_int = 33; pub const _SC_PRIORITIZED_IO: ::c_int = 34; pub const _SC_PRIORITY_SCHEDULING: ::c_int = 35; pub const _SC_REALTIME_SIGNALS: ::c_int = 36; pub const _SC_SEMAPHORES: ::c_int = 37; pub const _SC_FSYNC: ::c_int = 38; pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 39; pub const _SC_SYNCHRONIZED_IO: ::c_int = 40; pub const _SC_TIMERS: ::c_int = 41; pub const _SC_AIO_LISTIO_MAX: ::c_int = 42; pub const _SC_AIO_MAX: ::c_int = 43; pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 44; pub const _SC_DELAYTIMER_MAX: ::c_int = 45; pub const _SC_MQ_OPEN_MAX: ::c_int = 46; pub const _SC_PAGESIZE: ::c_int = 47; pub const _SC_RTSIG_MAX: ::c_int = 48; pub const _SC_SEM_NSEMS_MAX: ::c_int = 49; pub const _SC_SEM_VALUE_MAX: ::c_int = 50; pub const _SC_SIGQUEUE_MAX: ::c_int = 51; pub const _SC_TIMER_MAX: ::c_int = 52; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; pub const SCHED_FIFO: ::c_int = 1; pub const SCHED_OTHER: ::c_int = 2; pub const SCHED_RR: ::c_int = 3; pub const FD_SETSIZE: usize = 1024; pub const ST_NOSUID: ::c_ulong = 2; pub const HW_AVAILCPU: ::c_int = 25; extern { pub fn mincore(addr: *const ::c_void, len: ::size_t, vec: *mut ::c_char) -> ::c_int; pub fn sysctlnametomib(name: *const ::c_char, mibp: *mut ::c_int, sizep: *mut ::size_t) -> ::c_int; pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) -> ::c_int; pub fn sysctl(name: *const ::c_int, namelen: ::c_uint, oldp: *mut ::c_void, oldlenp: *mut ::size_t, newp: *const ::c_void, newlen: ::size_t) -> ::c_int; pub fn sysctlbyname(name: *const ::c_char, oldp: *mut ::c_void, oldlenp: *mut ::size_t, newp: *const ::c_void, newlen: ::size_t) -> ::c_int; pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; pub fn sched_setscheduler(pid: ::pid_t, policy: ::c_int, param: *const sched_param) -> ::c_int; pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void; } cfg_if! { if #[cfg(target_arch = "x86")] { mod x86; pub use self::x86::*; } else if #[cfg(target_arch = "x86_64")] { mod x86_64; pub use self::x86_64::*; } else { // ... } } cfg_if! { if #[cfg(target_os = "freebsd")] { mod freebsd; pub use self::freebsd::*; } else if #[cfg(target_os = "dragonfly")] { mod dragonfly; pub use self::dragonfly::*; } else { // ... } } deps/libc-0.2.4/src/unix/bsd/freebsdlike/dragonfly.rs0000664000175000017500000000033412634314567017452 0ustar pub const PTHREAD_STACK_MIN: ::size_t = 1024; pub const KERN_PROC_PATHNAME: ::c_int = 9; pub const SIGSTKSZ: ::size_t = 40960; pub const MADV_INVAL: ::c_int = 10; extern { pub fn __dfly_error() -> *const ::c_int; } deps/libc-0.2.4/src/unix/bsd/openbsdlike/0000755000000000000000000000000012666635520016713 5ustar rootrootdeps/libc-0.2.4/src/unix/bsd/openbsdlike/netbsd.rs0000664000175000017500000002451112634630015016754 0ustar pub type clock_t = ::c_uint; pub type suseconds_t = ::c_int; pub type dev_t = u64; pub type blksize_t = ::int32_t; pub type fsblkcnt_t = ::uint64_t; pub type fsfilcnt_t = ::uint64_t; s! { pub struct dirent { pub d_fileno: ::ino_t, pub d_reclen: u16, pub d_namlen: u16, pub d_type: u8, pub d_name: [::c_char; 512], } pub struct glob_t { pub gl_pathc: ::size_t, __unused1: ::c_int, pub gl_offs: ::size_t, __unused2: ::c_int, pub gl_pathv: *mut *mut ::c_char, __unused3: *mut ::c_void, __unused4: *mut ::c_void, __unused5: *mut ::c_void, __unused6: *mut ::c_void, __unused7: *mut ::c_void, __unused8: *mut ::c_void, } pub struct sigset_t { __bits: [u32; 4], } pub struct stat { pub st_dev: ::dev_t, pub st_mode: ::mode_t, pub st_ino: ::ino_t, pub st_nlink: ::nlink_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, pub st_rdev: ::dev_t, pub st_atime: ::time_t, pub st_atimensec: ::c_long, pub st_mtime: ::time_t, pub st_mtimensec: ::c_long, pub st_ctime: ::time_t, pub st_ctimensec: ::c_long, pub st_birthtime: ::time_t, pub st_birthtimensec: ::c_long, pub st_size: ::off_t, pub st_blocks: ::blkcnt_t, pub st_blksize: ::blksize_t, pub st_flags: ::uint32_t, pub st_gen: ::uint32_t, pub st_spare: [::uint32_t; 2], } pub struct statvfs { pub f_flag: ::c_ulong, pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, pub f_iosize: ::c_ulong, pub f_blocks: ::fsblkcnt_t, pub f_bfree: ::fsblkcnt_t, pub f_bavail: ::fsblkcnt_t, pub f_bresvd: ::fsblkcnt_t, pub f_files: ::fsfilcnt_t, pub f_ffree: ::fsfilcnt_t, pub f_favail: ::fsfilcnt_t, pub f_fresvd: ::fsfilcnt_t, pub f_syncreads: ::uint64_t, pub f_syncwrites: ::uint64_t, pub f_asyncreads: ::uint64_t, pub f_asyncwrites: ::uint64_t, pub f_fsidx: ::fsid_t, pub f_fsid: ::c_ulong, pub f_namemax: ::c_ulong, pub f_owner: ::uid_t, pub f_spare: [::uint32_t; 4], pub f_fstypename: [::c_char; 32], pub f_mntonname: [::c_char; 1024], pub f_mntfromname: [::c_char; 1024], } pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, pub ai_socktype: ::c_int, pub ai_protocol: ::c_int, pub ai_addrlen: ::socklen_t, pub ai_canonname: *mut ::c_char, pub ai_addr: *mut ::sockaddr, pub ai_next: *mut ::addrinfo, } pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: ::sa_family_t, __ss_pad1: [u8; 6], __ss_pad2: i64, __ss_pad3: [u8; 112], } pub struct siginfo_t { pub si_signo: ::c_int, pub si_code: ::c_int, pub si_errno: ::c_int, __pad1: ::c_int, __pad2: [u64; 14], } pub struct pthread_attr_t { pta_magic: ::c_uint, pta_flags: ::c_int, pta_private: *mut ::c_void, } pub struct pthread_mutex_t { ptm_magic: ::c_uint, ptm_errorcheck: ::c_uchar, ptm_pad1: [u8; 3], ptm_interlock: ::c_uchar, ptm_pad2: [u8; 3], ptm_owner: ::pthread_t, ptm_waiters: *mut u8, ptm_recursed: ::c_uint, ptm_spare2: *mut ::c_void, } pub struct pthread_mutexattr_t { ptma_magic: ::c_uint, ptma_private: *mut ::c_void, } pub struct pthread_cond_t { ptc_magic: ::c_uint, ptc_lock: ::c_uchar, ptc_waiters_first: *mut u8, ptc_waiters_last: *mut u8, ptc_mutex: *mut ::pthread_mutex_t, ptc_private: *mut ::c_void, } pub struct pthread_rwlock_t { ptr_magic: ::c_uint, ptr_interlock: ::c_uchar, ptr_rblocked_first: *mut u8, ptr_rblocked_last: *mut u8, ptr_wblocked_first: *mut u8, ptr_wblocked_last: *mut u8, ptr_nreaders: ::c_uint, ptr_owner: ::pthread_t, ptr_private: *mut ::c_void, } pub struct kevent { pub ident: ::uintptr_t, pub filter: ::uint32_t, pub flags: ::uint32_t, pub fflags: ::uint32_t, pub data: ::int64_t, pub udata: ::intptr_t, } pub struct dqblk { pub dqb_bhardlimit: ::uint32_t, pub dqb_bsoftlimit: ::uint32_t, pub dqb_curblocks: ::uint32_t, pub dqb_ihardlimit: ::uint32_t, pub dqb_isoftlimit: ::uint32_t, pub dqb_curinodes: ::uint32_t, pub dqb_btime: ::int32_t, pub dqb_itime: ::int32_t, } } pub const O_CLOEXEC: ::c_int = 0x400000; pub const O_ALT_IO: ::c_int = 0x40000; pub const O_NOSIGPIPE: ::c_int = 0x1000000; pub const O_SEARCH: ::c_int = 0x800000; pub const O_EXLOCK: ::c_int = 0x20; pub const O_SHLOCK: ::c_int = 0x10; pub const O_DIRECTORY: ::c_int = 0x200000; pub const MS_SYNC : ::c_int = 0x4; pub const MS_INVALIDATE : ::c_int = 0x2; pub const RLIM_NLIMITS: ::c_int = 12; pub const ENOATTR : ::c_int = 93; pub const EILSEQ : ::c_int = 85; pub const EOVERFLOW : ::c_int = 84; pub const ECANCELED : ::c_int = 87; pub const EIDRM : ::c_int = 82; pub const ENOMSG : ::c_int = 83; pub const ENOTSUP : ::c_int = 86; pub const ELAST : ::c_int = 96; pub const F_DUPFD_CLOEXEC : ::c_int = 12; pub const F_CLOSEM: ::c_int = 10; pub const F_GETNOSIGPIPE: ::c_int = 13; pub const F_SETNOSIGPIPE: ::c_int = 14; pub const F_MAXFD: ::c_int = 11; pub const IPV6_JOIN_GROUP: ::c_int = 12; pub const IPV6_LEAVE_GROUP: ::c_int = 13; pub const SO_SNDTIMEO: ::c_int = 0x100b; pub const SO_RCVTIMEO: ::c_int = 0x100c; pub const KERN_PROC : ::c_int = 14; pub const O_DSYNC : ::c_int = 0x10000; pub const MAP_RENAME : ::c_int = 0x20; pub const MAP_NORESERVE : ::c_int = 0x40; pub const MAP_HASSEMAPHORE : ::c_int = 0x200; pub const MAP_WIRED: ::c_int = 0x800; pub const _SC_IOV_MAX : ::c_int = 32; pub const _SC_GETGR_R_SIZE_MAX : ::c_int = 47; pub const _SC_GETPW_R_SIZE_MAX : ::c_int = 48; pub const _SC_LOGIN_NAME_MAX : ::c_int = 37; pub const _SC_MQ_PRIO_MAX : ::c_int = 55; pub const _SC_THREADS : ::c_int = 41; pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 61; pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 62; pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : ::c_int = 57; pub const _SC_THREAD_KEYS_MAX : ::c_int = 58; pub const _SC_THREAD_PRIO_INHERIT : ::c_int = 64; pub const _SC_THREAD_PRIO_PROTECT : ::c_int = 65; pub const _SC_THREAD_PRIORITY_SCHEDULING : ::c_int = 63; pub const _SC_THREAD_PROCESS_SHARED : ::c_int = 66; pub const _SC_THREAD_SAFE_FUNCTIONS : ::c_int = 67; pub const _SC_THREAD_STACK_MIN : ::c_int = 59; pub const _SC_THREAD_THREADS_MAX : ::c_int = 60; pub const _SC_TTY_NAME_MAX : ::c_int = 68; pub const _SC_ATEXIT_MAX : ::c_int = 40; pub const _SC_CLK_TCK : ::c_int = 39; pub const _SC_AIO_LISTIO_MAX : ::c_int = 51; pub const _SC_AIO_MAX : ::c_int = 52; pub const _SC_ASYNCHRONOUS_IO : ::c_int = 50; pub const _SC_MAPPED_FILES : ::c_int = 33; pub const _SC_MEMLOCK : ::c_int = 34; pub const _SC_MEMLOCK_RANGE : ::c_int = 35; pub const _SC_MEMORY_PROTECTION : ::c_int = 36; pub const _SC_MESSAGE_PASSING : ::c_int = 53; pub const _SC_MQ_OPEN_MAX : ::c_int = 54; pub const _SC_PRIORITY_SCHEDULING : ::c_int = 56; pub const _SC_SEMAPHORES : ::c_int = 42; pub const _SC_SHARED_MEMORY_OBJECTS : ::c_int = 87; pub const _SC_SYNCHRONIZED_IO : ::c_int = 31; pub const _SC_TIMERS : ::c_int = 44; pub const SIGSTKSZ: ::size_t = 0xa000; pub const FD_SETSIZE: usize = 0x100; pub const ST_NOSUID: ::c_ulong = 8; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { ptm_magic: 0x33330003, ptm_errorcheck: 0, ptm_interlock: 0, ptm_waiters: 0 as *mut _, ptm_owner: 0, ptm_pad1: [0; 3], ptm_pad2: [0; 3], ptm_recursed: 0, ptm_spare2: 0 as *mut _, }; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { ptc_magic: 0x55550005, ptc_lock: 0, ptc_waiters_first: 0 as *mut _, ptc_waiters_last: 0 as *mut _, ptc_mutex: 0 as *mut _, ptc_private: 0 as *mut _, }; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { ptr_magic: 0x99990009, ptr_interlock: 0, ptr_rblocked_first: 0 as *mut _, ptr_rblocked_last: 0 as *mut _, ptr_wblocked_first: 0 as *mut _, ptr_wblocked_last: 0 as *mut _, ptr_nreaders: 0, ptr_owner: 0, ptr_private: 0 as *mut _, }; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; pub const KERN_PROC_ARGS: ::c_int = 48; pub const EVFILT_AIO: ::int16_t = 2; pub const EVFILT_PROC: ::int16_t = 4; pub const EVFILT_READ: ::int16_t = 0; pub const EVFILT_SIGNAL: ::int16_t = 5; pub const EVFILT_SYSCOUNT: ::int16_t = 7; pub const EVFILT_TIMER: ::int16_t = 6; pub const EVFILT_VNODE: ::int16_t = 3; pub const EVFILT_WRITE: ::int16_t = 1; pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000; pub const CRTSCTS: ::tcflag_t = 0x00010000; extern { pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; pub fn sysctl(name: *const ::c_int, namelen: ::c_uint, oldp: *mut ::c_void, oldlenp: *mut ::size_t, newp: *const ::c_void, newlen: ::size_t) -> ::c_int; pub fn sysctlbyname(name: *const ::c_char, oldp: *mut ::c_void, oldlenp: *mut ::size_t, newp: *const ::c_void, newlen: ::size_t) -> ::c_int; #[link_name = "__kevent50"] pub fn kevent(kq: ::c_int, changelist: *const ::kevent, nchanges: ::size_t, eventlist: *mut ::kevent, nevents: ::size_t, timeout: *const ::timespec) -> ::c_int; #[link_name = "__mount50"] pub fn mount(src: *const ::c_char, target: *const ::c_char, flags: ::c_int, data: *mut ::c_void, size: ::size_t) -> ::c_int; pub fn ptrace(requeset: ::c_int, pid: ::pid_t, addr: *mut ::c_void, data: ::c_int) -> ::c_int; pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; } deps/libc-0.2.4/src/unix/bsd/openbsdlike/mod.rs0000664000175000017500000003075512634630015016263 0ustar pub type c_long = i64; pub type c_ulong = u64; pub type time_t = i64; pub type mode_t = u32; pub type nlink_t = ::uint32_t; pub type ino_t = ::uint64_t; pub type pthread_key_t = ::c_int; pub type rlim_t = u64; pub type speed_t = ::c_uint; pub type tcflag_t = ::c_uint; pub enum timezone {} s! { pub struct sigaction { pub sa_sigaction: ::sighandler_t, pub sa_mask: ::sigset_t, pub sa_flags: ::c_int, } pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_size: ::size_t, pub ss_flags: ::c_int, } pub struct Dl_info { pub dli_fname: *const ::c_char, pub dli_fbase: *mut ::c_void, pub dli_sname: *const ::c_char, pub dli_saddr: *const ::c_void, } pub struct sockaddr_in { pub sin_len: u8, pub sin_family: ::sa_family_t, pub sin_port: ::in_port_t, pub sin_addr: ::in_addr, pub sin_zero: [::int8_t; 8], } pub struct termios { pub c_iflag: ::tcflag_t, pub c_oflag: ::tcflag_t, pub c_cflag: ::tcflag_t, pub c_lflag: ::tcflag_t, pub c_cc: [::cc_t; ::NCCS], pub c_ispeed: ::c_int, pub c_ospeed: ::c_int, } } pub const EXIT_FAILURE : ::c_int = 1; pub const EXIT_SUCCESS : ::c_int = 0; pub const RAND_MAX : ::c_int = 2147483647; pub const EOF : ::c_int = -1; pub const SEEK_SET : ::c_int = 0; pub const SEEK_CUR : ::c_int = 1; pub const SEEK_END : ::c_int = 2; pub const _IOFBF : ::c_int = 0; pub const _IONBF : ::c_int = 2; pub const _IOLBF : ::c_int = 1; pub const BUFSIZ : ::c_uint = 1024; pub const FOPEN_MAX : ::c_uint = 20; pub const FILENAME_MAX : ::c_uint = 1024; pub const L_tmpnam : ::c_uint = 1024; pub const TMP_MAX : ::c_uint = 308915776; pub const O_RDONLY : ::c_int = 0; pub const O_WRONLY : ::c_int = 1; pub const O_RDWR : ::c_int = 2; pub const O_APPEND : ::c_int = 8; pub const O_CREAT : ::c_int = 512; pub const O_EXCL : ::c_int = 2048; pub const O_NOCTTY : ::c_int = 32768; pub const O_TRUNC : ::c_int = 1024; pub const O_SYNC : ::c_int = 128; pub const S_IFIFO : mode_t = 4096; pub const S_IFCHR : mode_t = 8192; pub const S_IFBLK : mode_t = 24576; pub const S_IFDIR : mode_t = 16384; pub const S_IFREG : mode_t = 32768; pub const S_IFLNK : mode_t = 40960; pub const S_IFSOCK : mode_t = 49152; pub const S_IFMT : mode_t = 61440; pub const S_IEXEC : mode_t = 64; pub const S_IWRITE : mode_t = 128; pub const S_IREAD : mode_t = 256; pub const S_IRWXU : mode_t = 448; pub const S_IXUSR : mode_t = 64; pub const S_IWUSR : mode_t = 128; pub const S_IRUSR : mode_t = 256; pub const S_IRWXG : mode_t = 56; pub const S_IXGRP : mode_t = 8; pub const S_IWGRP : mode_t = 16; pub const S_IRGRP : mode_t = 32; pub const S_IRWXO : mode_t = 7; pub const S_IXOTH : mode_t = 1; pub const S_IWOTH : mode_t = 2; pub const S_IROTH : mode_t = 4; pub const F_OK : ::c_int = 0; pub const R_OK : ::c_int = 4; pub const W_OK : ::c_int = 2; pub const X_OK : ::c_int = 1; pub const STDIN_FILENO : ::c_int = 0; pub const STDOUT_FILENO : ::c_int = 1; pub const STDERR_FILENO : ::c_int = 2; pub const F_LOCK : ::c_int = 1; pub const F_TEST : ::c_int = 3; pub const F_TLOCK : ::c_int = 2; pub const F_ULOCK : ::c_int = 0; pub const SIGHUP : ::c_int = 1; pub const SIGINT : ::c_int = 2; pub const SIGQUIT : ::c_int = 3; pub const SIGILL : ::c_int = 4; pub const SIGABRT : ::c_int = 6; pub const SIGFPE : ::c_int = 8; pub const SIGKILL : ::c_int = 9; pub const SIGSEGV : ::c_int = 11; pub const SIGPIPE : ::c_int = 13; pub const SIGALRM : ::c_int = 14; pub const SIGTERM : ::c_int = 15; pub const PROT_NONE : ::c_int = 0; pub const PROT_READ : ::c_int = 1; pub const PROT_WRITE : ::c_int = 2; pub const PROT_EXEC : ::c_int = 4; pub const MAP_FILE : ::c_int = 0x0000; pub const MAP_SHARED : ::c_int = 0x0001; pub const MAP_PRIVATE : ::c_int = 0x0002; pub const MAP_FIXED : ::c_int = 0x0010; pub const MAP_ANON : ::c_int = 0x1000; pub const MAP_FAILED : *mut ::c_void = !0 as *mut ::c_void; pub const MCL_CURRENT : ::c_int = 0x0001; pub const MCL_FUTURE : ::c_int = 0x0002; pub const MS_ASYNC : ::c_int = 0x0001; pub const EPERM : ::c_int = 1; pub const ENOENT : ::c_int = 2; pub const ESRCH : ::c_int = 3; pub const EINTR : ::c_int = 4; pub const EIO : ::c_int = 5; pub const ENXIO : ::c_int = 6; pub const E2BIG : ::c_int = 7; pub const ENOEXEC : ::c_int = 8; pub const EBADF : ::c_int = 9; pub const ECHILD : ::c_int = 10; pub const EDEADLK : ::c_int = 11; pub const ENOMEM : ::c_int = 12; pub const EACCES : ::c_int = 13; pub const EFAULT : ::c_int = 14; pub const ENOTBLK : ::c_int = 15; pub const EBUSY : ::c_int = 16; pub const EEXIST : ::c_int = 17; pub const EXDEV : ::c_int = 18; pub const ENODEV : ::c_int = 19; pub const ENOTDIR : ::c_int = 20; pub const EISDIR : ::c_int = 21; pub const EINVAL : ::c_int = 22; pub const ENFILE : ::c_int = 23; pub const EMFILE : ::c_int = 24; pub const ENOTTY : ::c_int = 25; pub const ETXTBSY : ::c_int = 26; pub const EFBIG : ::c_int = 27; pub const ENOSPC : ::c_int = 28; pub const ESPIPE : ::c_int = 29; pub const EROFS : ::c_int = 30; pub const EMLINK : ::c_int = 31; pub const EPIPE : ::c_int = 32; pub const EDOM : ::c_int = 33; pub const ERANGE : ::c_int = 34; pub const EAGAIN : ::c_int = 35; pub const EWOULDBLOCK : ::c_int = 35; pub const EINPROGRESS : ::c_int = 36; pub const EALREADY : ::c_int = 37; pub const ENOTSOCK : ::c_int = 38; pub const EDESTADDRREQ : ::c_int = 39; pub const EMSGSIZE : ::c_int = 40; pub const EPROTOTYPE : ::c_int = 41; pub const ENOPROTOOPT : ::c_int = 42; pub const EPROTONOSUPPORT : ::c_int = 43; pub const ESOCKTNOSUPPORT : ::c_int = 44; pub const EOPNOTSUPP : ::c_int = 45; pub const EPFNOSUPPORT : ::c_int = 46; pub const EAFNOSUPPORT : ::c_int = 47; pub const EADDRINUSE : ::c_int = 48; pub const EADDRNOTAVAIL : ::c_int = 49; pub const ENETDOWN : ::c_int = 50; pub const ENETUNREACH : ::c_int = 51; pub const ENETRESET : ::c_int = 52; pub const ECONNABORTED : ::c_int = 53; pub const ECONNRESET : ::c_int = 54; pub const ENOBUFS : ::c_int = 55; pub const EISCONN : ::c_int = 56; pub const ENOTCONN : ::c_int = 57; pub const ESHUTDOWN : ::c_int = 58; pub const ETOOMANYREFS : ::c_int = 59; pub const ETIMEDOUT : ::c_int = 60; pub const ECONNREFUSED : ::c_int = 61; pub const ELOOP : ::c_int = 62; pub const ENAMETOOLONG : ::c_int = 63; pub const EHOSTDOWN : ::c_int = 64; pub const EHOSTUNREACH : ::c_int = 65; pub const ENOTEMPTY : ::c_int = 66; pub const EPROCLIM : ::c_int = 67; pub const EUSERS : ::c_int = 68; pub const EDQUOT : ::c_int = 69; pub const ESTALE : ::c_int = 70; pub const EREMOTE : ::c_int = 71; pub const EBADRPC : ::c_int = 72; pub const ERPCMISMATCH : ::c_int = 73; pub const EPROGUNAVAIL : ::c_int = 74; pub const EPROGMISMATCH : ::c_int = 75; pub const EPROCUNAVAIL : ::c_int = 76; pub const ENOLCK : ::c_int = 77; pub const ENOSYS : ::c_int = 78; pub const EFTYPE : ::c_int = 79; pub const EAUTH : ::c_int = 80; pub const ENEEDAUTH : ::c_int = 81; pub const F_DUPFD : ::c_int = 0; pub const F_GETFD : ::c_int = 1; pub const F_SETFD : ::c_int = 2; pub const F_GETFL : ::c_int = 3; pub const F_SETFL : ::c_int = 4; pub const SIGTRAP : ::c_int = 5; pub const GLOB_APPEND : ::c_int = 0x0001; pub const GLOB_DOOFFS : ::c_int = 0x0002; pub const GLOB_ERR : ::c_int = 0x0004; pub const GLOB_MARK : ::c_int = 0x0008; pub const GLOB_NOCHECK : ::c_int = 0x0010; pub const GLOB_NOSORT : ::c_int = 0x0020; pub const GLOB_NOESCAPE : ::c_int = 0x1000; pub const GLOB_NOSPACE : ::c_int = -1; pub const GLOB_ABORTED : ::c_int = -2; pub const GLOB_NOMATCH : ::c_int = -3; pub const GLOB_NOSYS : ::c_int = -4; pub const POSIX_MADV_NORMAL : ::c_int = 0; pub const POSIX_MADV_RANDOM : ::c_int = 1; pub const POSIX_MADV_SEQUENTIAL : ::c_int = 2; pub const POSIX_MADV_WILLNEED : ::c_int = 3; pub const POSIX_MADV_DONTNEED : ::c_int = 4; pub const _SC_XOPEN_SHM : ::c_int = 30; pub const PTHREAD_CREATE_JOINABLE : ::c_int = 0; pub const PTHREAD_CREATE_DETACHED : ::c_int = 1; pub const CLOCK_REALTIME : ::c_int = 0; pub const CLOCK_MONOTONIC : ::c_int = 3; pub const RLIMIT_CPU: ::c_int = 0; pub const RLIMIT_FSIZE: ::c_int = 1; pub const RLIMIT_DATA: ::c_int = 2; pub const RLIMIT_STACK: ::c_int = 3; pub const RLIMIT_CORE: ::c_int = 4; pub const RLIMIT_RSS: ::c_int = 5; pub const RLIMIT_MEMLOCK: ::c_int = 6; pub const RLIMIT_NPROC: ::c_int = 7; pub const RLIMIT_NOFILE: ::c_int = 8; pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; pub const RUSAGE_SELF: ::c_int = 0; pub const RUSAGE_CHILDREN: ::c_int = -1; pub const MADV_NORMAL : ::c_int = 0; pub const MADV_RANDOM : ::c_int = 1; pub const MADV_SEQUENTIAL : ::c_int = 2; pub const MADV_WILLNEED : ::c_int = 3; pub const MADV_DONTNEED : ::c_int = 4; pub const MADV_FREE : ::c_int = 6; pub const AF_UNIX: ::c_int = 1; pub const AF_INET: ::c_int = 2; pub const AF_INET6: ::c_int = 24; pub const SOCK_STREAM: ::c_int = 1; pub const SOCK_DGRAM: ::c_int = 2; pub const SOCK_RAW: ::c_int = 3; pub const IPPROTO_TCP: ::c_int = 6; pub const IPPROTO_IP: ::c_int = 0; pub const IPPROTO_IPV6: ::c_int = 41; pub const IP_MULTICAST_TTL: ::c_int = 10; pub const IP_MULTICAST_LOOP: ::c_int = 11; pub const IP_TTL: ::c_int = 4; pub const IP_HDRINCL: ::c_int = 2; pub const IP_ADD_MEMBERSHIP: ::c_int = 12; pub const IP_DROP_MEMBERSHIP: ::c_int = 13; pub const TCP_NODELAY: ::c_int = 0x01; pub const SOL_SOCKET: ::c_int = 0xffff; pub const SO_DEBUG: ::c_int = 0x01; pub const SO_ACCEPTCONN: ::c_int = 0x0002; pub const SO_REUSEADDR: ::c_int = 0x0004; pub const SO_KEEPALIVE: ::c_int = 0x0008; pub const SO_DONTROUTE: ::c_int = 0x0010; pub const SO_BROADCAST: ::c_int = 0x0020; pub const SO_USELOOPBACK: ::c_int = 0x0040; pub const SO_LINGER: ::c_int = 0x0080; pub const SO_OOBINLINE: ::c_int = 0x0100; pub const SO_REUSEPORT: ::c_int = 0x0200; pub const SO_SNDBUF: ::c_int = 0x1001; pub const SO_RCVBUF: ::c_int = 0x1002; pub const SO_SNDLOWAT: ::c_int = 0x1003; pub const SO_RCVLOWAT: ::c_int = 0x1004; pub const SO_ERROR: ::c_int = 0x1007; pub const SO_TYPE: ::c_int = 0x1008; pub const IFF_LOOPBACK: ::c_int = 0x8; pub const SHUT_RD: ::c_int = 0; pub const SHUT_WR: ::c_int = 1; pub const SHUT_RDWR: ::c_int = 2; pub const LOCK_SH: ::c_int = 1; pub const LOCK_EX: ::c_int = 2; pub const LOCK_NB: ::c_int = 4; pub const LOCK_UN: ::c_int = 8; pub const O_NONBLOCK : ::c_int = 4; pub const CTL_KERN : ::c_int = 1; pub const IPPROTO_RAW : ::c_int = 255; pub const _SC_ARG_MAX : ::c_int = 1; pub const _SC_CHILD_MAX : ::c_int = 2; pub const _SC_NGROUPS_MAX : ::c_int = 4; pub const _SC_OPEN_MAX : ::c_int = 5; pub const _SC_JOB_CONTROL : ::c_int = 6; pub const _SC_SAVED_IDS : ::c_int = 7; pub const _SC_VERSION : ::c_int = 8; pub const _SC_BC_BASE_MAX : ::c_int = 9; pub const _SC_BC_DIM_MAX : ::c_int = 10; pub const _SC_BC_SCALE_MAX : ::c_int = 11; pub const _SC_BC_STRING_MAX : ::c_int = 12; pub const _SC_COLL_WEIGHTS_MAX : ::c_int = 13; pub const _SC_EXPR_NEST_MAX : ::c_int = 14; pub const _SC_LINE_MAX : ::c_int = 15; pub const _SC_RE_DUP_MAX : ::c_int = 16; pub const _SC_2_VERSION : ::c_int = 17; pub const _SC_2_C_BIND : ::c_int = 18; pub const _SC_2_C_DEV : ::c_int = 19; pub const _SC_2_CHAR_TERM : ::c_int = 20; pub const _SC_2_FORT_DEV : ::c_int = 21; pub const _SC_2_FORT_RUN : ::c_int = 22; pub const _SC_2_LOCALEDEF : ::c_int = 23; pub const _SC_2_SW_DEV : ::c_int = 24; pub const _SC_2_UPE : ::c_int = 25; pub const _SC_STREAM_MAX : ::c_int = 26; pub const _SC_TZNAME_MAX : ::c_int = 27; pub const _SC_PAGESIZE : ::c_int = 28; pub const _SC_FSYNC : ::c_int = 29; pub const KERN_PROC_ARGV: ::c_int = 1; extern { pub fn mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_char) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__clock_gettime50")] pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; pub fn __errno() -> *mut ::c_int; pub fn backtrace(buf: *mut *mut ::c_void, sz: ::size_t) -> ::size_t; pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) -> ::c_int; pub fn pthread_main_np() -> ::c_uint; pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); pub fn pthread_stackseg_np(thread: ::pthread_t, sinfo: *mut ::stack_t) -> ::c_uint; pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void; } cfg_if! { if #[cfg(target_os = "bitrig")] { mod bitrig; pub use self::bitrig::*; } else if #[cfg(target_os = "netbsd")] { mod netbsd; pub use self::netbsd::*; } else { mod openbsd; pub use self::openbsd::*; } } deps/libc-0.2.4/src/unix/bsd/openbsdlike/bitrig.rs0000664000175000017500000001630012634314567016765 0ustar pub type clock_t = i64; pub type suseconds_t = i64; pub type dev_t = i32; pub type sigset_t = ::c_uint; pub type blksize_t = ::uint32_t; pub type fsblkcnt_t = ::c_uint; pub type fsfilcnt_t = ::c_uint; pub type pthread_attr_t = *mut ::c_void; pub type pthread_mutex_t = *mut ::c_void; pub type pthread_mutexattr_t = *mut ::c_void; pub type pthread_cond_t = *mut ::c_void; pub type pthread_rwlock_t = *mut ::c_void; s! { pub struct dirent { pub d_fileno: ::ino_t, pub d_off: ::off_t, pub d_reclen: u16, pub d_type: u8, pub d_namelen: u8, __d_padding: [u8; 4], pub d_name: [::c_char; 256], } pub struct glob_t { pub gl_pathc: ::c_int, pub gl_matchc: ::c_int, pub gl_offs: ::c_int, pub gl_flags: ::c_int, pub gl_pathv: *mut *mut ::c_char, __unused1: *mut ::c_void, __unused2: *mut ::c_void, __unused3: *mut ::c_void, __unused4: *mut ::c_void, __unused5: *mut ::c_void, __unused6: *mut ::c_void, __unused7: *mut ::c_void, } pub struct stat { pub st_mode: ::mode_t, pub st_dev: ::dev_t, pub st_ino: ::ino_t, pub st_nlink: ::nlink_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, pub st_rdev: ::dev_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, pub st_size: ::off_t, pub st_blocks: ::blkcnt_t, pub st_blksize: ::blksize_t, pub st_flags: ::uint32_t, pub st_gen: ::uint32_t, pub st_birthtime: ::time_t, pub st_birthtime_nsec: ::c_long, } pub struct statvfs { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, pub f_blocks: ::fsblkcnt_t, pub f_bfree: ::fsblkcnt_t, pub f_bavail: ::fsblkcnt_t, pub f_files: ::fsfilcnt_t, pub f_ffree: ::fsfilcnt_t, pub f_favail: ::fsfilcnt_t, pub f_fsid: ::c_ulong, pub f_flag: ::c_ulong, pub f_namemax: ::c_ulong, } pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, pub ai_socktype: ::c_int, pub ai_protocol: ::c_int, pub ai_addrlen: ::socklen_t, pub ai_addr: *mut ::sockaddr, pub ai_canonname: *mut ::c_char, pub ai_next: *mut ::addrinfo, } pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: ::sa_family_t, __ss_pad1: [u8; 6], __ss_pad2: i64, __ss_pad3: [u8; 240], } pub struct siginfo_t { pub si_signo: ::c_int, pub si_code: ::c_int, pub si_errno: ::c_int, pub si_addr: *mut ::c_void } } pub const O_CLOEXEC: ::c_int = 0x10000; pub const MS_SYNC : ::c_int = 0x0002; pub const MS_INVALIDATE : ::c_int = 0x0004; pub const PTHREAD_STACK_MIN : ::size_t = 2048; pub const ENOATTR : ::c_int = 83; pub const EILSEQ : ::c_int = 84; pub const EOVERFLOW : ::c_int = 87; pub const ECANCELED : ::c_int = 88; pub const EIDRM : ::c_int = 89; pub const ENOMSG : ::c_int = 90; pub const ENOTSUP : ::c_int = 91; pub const ELAST : ::c_int = 91; pub const F_DUPFD_CLOEXEC : ::c_int = 10; pub const RLIM_NLIMITS: ::c_int = 9; pub const SO_SNDTIMEO: ::c_int = 0x1005; pub const SO_RCVTIMEO: ::c_int = 0x1006; pub const KERN_PROC : ::c_int = 66; pub const O_DSYNC : ::c_int = 128; pub const MAP_RENAME : ::c_int = 0x0000; pub const MAP_NORESERVE : ::c_int = 0x0000; pub const MAP_HASSEMAPHORE : ::c_int = 0x0000; pub const EIPSEC : ::c_int = 82; pub const ENOMEDIUM : ::c_int = 85; pub const EMEDIUMTYPE : ::c_int = 86; pub const RUSAGE_THREAD: ::c_int = 1; pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12; pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13; pub const MAP_COPY : ::c_int = 0x0002; pub const MAP_NOEXTEND : ::c_int = 0x0000; pub const _SC_IOV_MAX : ::c_int = 51; pub const _SC_GETGR_R_SIZE_MAX : ::c_int = 100; pub const _SC_GETPW_R_SIZE_MAX : ::c_int = 101; pub const _SC_LOGIN_NAME_MAX : ::c_int = 102; pub const _SC_MQ_PRIO_MAX : ::c_int = 59; pub const _SC_THREADS : ::c_int = 91; pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 77; pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 78; pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : ::c_int = 80; pub const _SC_THREAD_KEYS_MAX : ::c_int = 81; pub const _SC_THREAD_PRIO_INHERIT : ::c_int = 82; pub const _SC_THREAD_PRIO_PROTECT : ::c_int = 83; pub const _SC_THREAD_PRIORITY_SCHEDULING : ::c_int = 84; pub const _SC_THREAD_PROCESS_SHARED : ::c_int = 85; pub const _SC_THREAD_SAFE_FUNCTIONS : ::c_int = 103; pub const _SC_THREAD_STACK_MIN : ::c_int = 89; pub const _SC_THREAD_THREADS_MAX : ::c_int = 90; pub const _SC_TTY_NAME_MAX : ::c_int = 107; pub const _SC_ATEXIT_MAX : ::c_int = 46; pub const _SC_CLK_TCK : ::c_int = 3; pub const _SC_AIO_LISTIO_MAX : ::c_int = 42; pub const _SC_AIO_MAX : ::c_int = 43; pub const _SC_ASYNCHRONOUS_IO : ::c_int = 45; pub const _SC_MAPPED_FILES : ::c_int = 53; pub const _SC_MEMLOCK : ::c_int = 54; pub const _SC_MEMLOCK_RANGE : ::c_int = 55; pub const _SC_MEMORY_PROTECTION : ::c_int = 56; pub const _SC_MESSAGE_PASSING : ::c_int = 57; pub const _SC_MQ_OPEN_MAX : ::c_int = 58; pub const _SC_PRIORITY_SCHEDULING : ::c_int = 61; pub const _SC_SEMAPHORES : ::c_int = 67; pub const _SC_SHARED_MEMORY_OBJECTS : ::c_int = 68; pub const _SC_SYNCHRONIZED_IO : ::c_int = 75; pub const _SC_TIMERS : ::c_int = 94; pub const _SC_XOPEN_CRYPT : ::c_int = 117; pub const _SC_XOPEN_ENH_I18N : ::c_int = 118; pub const _SC_XOPEN_LEGACY : ::c_int = 119; pub const _SC_XOPEN_REALTIME : ::c_int = 120; pub const _SC_XOPEN_REALTIME_THREADS : ::c_int = 121; pub const _SC_XOPEN_UNIX : ::c_int = 123; pub const _SC_XOPEN_VERSION : ::c_int = 125; pub const _SC_SEM_NSEMS_MAX : ::c_int = 31; pub const _SC_SEM_VALUE_MAX : ::c_int = 32; pub const _SC_AIO_PRIO_DELTA_MAX : ::c_int = 44; pub const _SC_DELAYTIMER_MAX : ::c_int = 50; pub const _SC_PRIORITIZED_IO : ::c_int = 60; pub const _SC_REALTIME_SIGNALS : ::c_int = 64; pub const _SC_RTSIG_MAX : ::c_int = 66; pub const _SC_SIGQUEUE_MAX : ::c_int = 70; pub const _SC_TIMER_MAX : ::c_int = 93; pub const SIGSTKSZ: ::size_t = 131072; pub const FD_SETSIZE: usize = 1024; pub const ST_NOSUID: ::c_ulong = 2; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; pub const HW_AVAILCPU: ::c_int = 25; pub const KERN_PROC_ARGS: ::c_int = 55; extern { pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; pub fn sysctl(name: *mut ::c_int, namelen: ::c_uint, oldp: *mut ::c_void, oldlenp: *mut ::size_t, newp: *mut ::c_void, newlen: ::size_t) -> ::c_int; pub fn sysctlbyname(name: *const ::c_char, oldp: *mut ::c_void, oldlenp: *mut ::size_t, newp: *mut ::c_void, newlen: ::size_t) -> ::c_int; } deps/libc-0.2.4/src/unix/bsd/openbsdlike/openbsd.rs0000664000175000017500000001633012634314567017142 0ustar pub type clock_t = i64; pub type suseconds_t = i64; pub type dev_t = i32; pub type sigset_t = ::c_uint; pub type blksize_t = ::uint32_t; pub type fsblkcnt_t = ::c_uint; pub type fsfilcnt_t = ::c_uint; pub type pthread_attr_t = *mut ::c_void; pub type pthread_mutex_t = *mut ::c_void; pub type pthread_mutexattr_t = *mut ::c_void; pub type pthread_cond_t = *mut ::c_void; pub type pthread_rwlock_t = *mut ::c_void; s! { pub struct dirent { pub d_fileno: ::ino_t, pub d_off: ::off_t, pub d_reclen: u16, pub d_type: u8, pub d_namelen: u8, __d_padding: [u8; 4], pub d_name: [::c_char; 256], } pub struct glob_t { pub gl_pathc: ::c_int, __unused1: ::c_int, pub gl_offs: ::c_int, __unused2: ::c_int, pub gl_pathv: *mut *mut ::c_char, __unused3: *mut ::c_void, __unused4: *mut ::c_void, __unused5: *mut ::c_void, __unused6: *mut ::c_void, __unused7: *mut ::c_void, __unused8: *mut ::c_void, __unused9: *mut ::c_void, } pub struct stat { pub st_mode: ::mode_t, pub st_dev: ::dev_t, pub st_ino: ::ino_t, pub st_nlink: ::nlink_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, pub st_rdev: ::dev_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, pub st_mtime: ::time_t, pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, pub st_size: ::off_t, pub st_blocks: ::blkcnt_t, pub st_blksize: ::blksize_t, pub st_flags: ::uint32_t, pub st_gen: ::uint32_t, pub st_birthtime: ::time_t, pub st_birthtime_nsec: ::c_long, } pub struct statvfs { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, pub f_blocks: ::fsblkcnt_t, pub f_bfree: ::fsblkcnt_t, pub f_bavail: ::fsblkcnt_t, pub f_files: ::fsfilcnt_t, pub f_ffree: ::fsfilcnt_t, pub f_favail: ::fsfilcnt_t, pub f_fsid: ::c_ulong, pub f_flag: ::c_ulong, pub f_namemax: ::c_ulong, } pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, pub ai_socktype: ::c_int, pub ai_protocol: ::c_int, pub ai_addrlen: ::socklen_t, pub ai_addr: *mut ::sockaddr, pub ai_canonname: *mut ::c_char, pub ai_next: *mut ::addrinfo, } pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: ::sa_family_t, __ss_pad1: [u8; 6], __ss_pad2: i64, __ss_pad3: [u8; 240], } pub struct siginfo_t { pub si_signo: ::c_int, pub si_code: ::c_int, pub si_errno: ::c_int, __pad1: ::c_int, __pad2: [u8; 240], } } pub const O_CLOEXEC: ::c_int = 0x10000; pub const MS_SYNC : ::c_int = 0x0002; pub const MS_INVALIDATE : ::c_int = 0x0004; pub const PTHREAD_STACK_MIN : ::size_t = 2048; pub const ENOATTR : ::c_int = 83; pub const EILSEQ : ::c_int = 84; pub const EOVERFLOW : ::c_int = 87; pub const ECANCELED : ::c_int = 88; pub const EIDRM : ::c_int = 89; pub const ENOMSG : ::c_int = 90; pub const ENOTSUP : ::c_int = 91; pub const ELAST : ::c_int = 91; pub const F_DUPFD_CLOEXEC : ::c_int = 10; pub const RLIM_NLIMITS: ::c_int = 9; pub const SO_SNDTIMEO: ::c_int = 0x1005; pub const SO_RCVTIMEO: ::c_int = 0x1006; pub const KERN_PROC : ::c_int = 66; pub const O_DSYNC : ::c_int = 128; pub const MAP_RENAME : ::c_int = 0x0000; pub const MAP_NORESERVE : ::c_int = 0x0000; pub const MAP_HASSEMAPHORE : ::c_int = 0x0000; pub const EIPSEC : ::c_int = 82; pub const ENOMEDIUM : ::c_int = 85; pub const EMEDIUMTYPE : ::c_int = 86; pub const RUSAGE_THREAD: ::c_int = 1; pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12; pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13; pub const MAP_COPY : ::c_int = 0x0002; pub const MAP_NOEXTEND : ::c_int = 0x0000; pub const _SC_CLK_TCK : ::c_int = 3; pub const _SC_IOV_MAX : ::c_int = 51; pub const _SC_GETGR_R_SIZE_MAX : ::c_int = 100; pub const _SC_GETPW_R_SIZE_MAX : ::c_int = 101; pub const _SC_LOGIN_NAME_MAX : ::c_int = 102; pub const _SC_MQ_PRIO_MAX : ::c_int = 59; pub const _SC_THREADS : ::c_int = 91; pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 77; pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 78; pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : ::c_int = 80; pub const _SC_THREAD_KEYS_MAX : ::c_int = 81; pub const _SC_THREAD_PRIO_INHERIT : ::c_int = 82; pub const _SC_THREAD_PRIO_PROTECT : ::c_int = 83; pub const _SC_THREAD_PRIORITY_SCHEDULING : ::c_int = 84; pub const _SC_THREAD_PROCESS_SHARED : ::c_int = 85; pub const _SC_THREAD_SAFE_FUNCTIONS : ::c_int = 103; pub const _SC_THREAD_STACK_MIN : ::c_int = 89; pub const _SC_THREAD_THREADS_MAX : ::c_int = 90; pub const _SC_TTY_NAME_MAX : ::c_int = 107; pub const _SC_ATEXIT_MAX : ::c_int = 46; pub const _SC_AIO_LISTIO_MAX : ::c_int = 42; pub const _SC_AIO_MAX : ::c_int = 43; pub const _SC_ASYNCHRONOUS_IO : ::c_int = 45; pub const _SC_MAPPED_FILES : ::c_int = 53; pub const _SC_MEMLOCK : ::c_int = 54; pub const _SC_MEMLOCK_RANGE : ::c_int = 55; pub const _SC_MEMORY_PROTECTION : ::c_int = 56; pub const _SC_MESSAGE_PASSING : ::c_int = 57; pub const _SC_MQ_OPEN_MAX : ::c_int = 58; pub const _SC_PRIORITY_SCHEDULING : ::c_int = 61; pub const _SC_SEMAPHORES : ::c_int = 67; pub const _SC_SHARED_MEMORY_OBJECTS : ::c_int = 68; pub const _SC_SYNCHRONIZED_IO : ::c_int = 75; pub const _SC_TIMERS : ::c_int = 94; pub const _SC_XOPEN_CRYPT : ::c_int = 117; pub const _SC_XOPEN_ENH_I18N : ::c_int = 118; pub const _SC_XOPEN_LEGACY : ::c_int = 119; pub const _SC_XOPEN_REALTIME : ::c_int = 120; pub const _SC_XOPEN_REALTIME_THREADS : ::c_int = 121; pub const _SC_XOPEN_UNIX : ::c_int = 123; pub const _SC_XOPEN_VERSION : ::c_int = 125; pub const _SC_SEM_NSEMS_MAX : ::c_int = 31; pub const _SC_SEM_VALUE_MAX : ::c_int = 32; pub const _SC_AIO_PRIO_DELTA_MAX : ::c_int = 44; pub const _SC_DELAYTIMER_MAX : ::c_int = 50; pub const _SC_PRIORITIZED_IO : ::c_int = 60; pub const _SC_REALTIME_SIGNALS : ::c_int = 64; pub const _SC_RTSIG_MAX : ::c_int = 66; pub const _SC_SIGQUEUE_MAX : ::c_int = 70; pub const _SC_TIMER_MAX : ::c_int = 93; pub const SIGSTKSZ: ::size_t = 131072; pub const FD_SETSIZE: usize = 1024; pub const ST_NOSUID: ::c_ulong = 2; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; pub const HW_AVAILCPU: ::c_int = 25; pub const KERN_PROC_ARGS: ::c_int = 55; extern { pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; pub fn sysctl(name: *mut ::c_int, namelen: ::c_uint, oldp: *mut ::c_void, oldlenp: *mut ::size_t, newp: *mut ::c_void, newlen: ::size_t) -> ::c_int; pub fn sysctlbyname(name: *const ::c_char, oldp: *mut ::c_void, oldlenp: *mut ::size_t, newp: *mut ::c_void, newlen: ::size_t) -> ::c_int; } deps/libc-0.2.4/src/unix/bsd/apple/0000755000000000000000000000000012666635520015515 5ustar rootrootdeps/libc-0.2.4/src/unix/bsd/apple/b64.rs0000664000175000017500000000052512614241040014663 0ustar //! 64-bit specific Apple (ios/darwin) definitions pub type c_long = i64; pub type c_ulong = u64; pub const __PTHREAD_MUTEX_SIZE__: usize = 56; pub const __PTHREAD_COND_SIZE__: usize = 40; pub const __PTHREAD_RWLOCK_SIZE__: usize = 192; s! { pub struct pthread_attr_t { __sig: c_long, __opaque: [::c_char; 56] } } deps/libc-0.2.4/src/unix/bsd/apple/mod.rs0000664000175000017500000007241312634314567015075 0ustar //! Apple (ios/darwin)-specific definitions //! //! This covers *-apple-* triples currently pub type clock_t = c_ulong; pub type time_t = c_long; pub type suseconds_t = i32; pub type dev_t = i32; pub type ino_t = u64; pub type mode_t = u16; pub type nlink_t = u16; pub type blksize_t = i32; pub type rlim_t = u64; pub type mach_timebase_info_data_t = mach_timebase_info; pub type pthread_key_t = c_ulong; pub type sigset_t = u32; pub type fsblkcnt_t = ::c_uint; pub type fsfilcnt_t = ::c_uint; pub type speed_t = ::c_ulong; pub type tcflag_t = ::c_ulong; pub enum timezone {} s! { pub struct glob_t { pub gl_pathc: ::size_t, __unused1: ::c_int, pub gl_offs: ::size_t, __unused2: ::c_int, pub gl_pathv: *mut *mut ::c_char, __unused3: *mut ::c_void, __unused4: *mut ::c_void, __unused5: *mut ::c_void, __unused6: *mut ::c_void, __unused7: *mut ::c_void, __unused8: *mut ::c_void, } pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: ::sa_family_t, __ss_pad1: [u8; 6], __ss_align: i64, __ss_pad2: [u8; 112], } pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, pub ai_socktype: ::c_int, pub ai_protocol: ::c_int, pub ai_addrlen: ::socklen_t, pub ai_canonname: *mut ::c_char, pub ai_addr: *mut ::sockaddr, pub ai_next: *mut addrinfo, } pub struct mach_timebase_info { pub numer: u32, pub denom: u32, } pub struct stat { pub st_dev: dev_t, pub st_mode: mode_t, pub st_nlink: nlink_t, pub st_ino: ino_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, pub st_rdev: dev_t, pub st_atime: time_t, pub st_atime_nsec: c_long, pub st_mtime: time_t, pub st_mtime_nsec: c_long, pub st_ctime: time_t, pub st_ctime_nsec: c_long, pub st_birthtime: time_t, pub st_birthtime_nsec: c_long, pub st_size: ::off_t, pub st_blocks: ::blkcnt_t, pub st_blksize: blksize_t, pub st_flags: ::uint32_t, pub st_gen: ::uint32_t, pub st_lspare: ::int32_t, pub st_qspare: [::int64_t; 2], } pub struct dirent { pub d_ino: u64, pub d_seekoff: u64, pub d_reclen: u16, pub d_namlen: u16, pub d_type: u8, pub d_name: [::c_char; 1024], } pub struct pthread_mutex_t { __sig: ::c_long, __opaque: [u8; __PTHREAD_MUTEX_SIZE__], } pub struct pthread_mutexattr_t { __sig: ::c_long, __opaque: [u8; 8], } pub struct pthread_cond_t { __sig: ::c_long, __opaque: [u8; __PTHREAD_COND_SIZE__], } pub struct pthread_rwlock_t { __sig: ::c_long, __opaque: [u8; __PTHREAD_RWLOCK_SIZE__], } pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, pub si_code: ::c_int, pub si_pid: ::pid_t, pub si_uid: ::uid_t, pub si_status: ::c_int, pub si_addr: *mut ::c_void, _pad: [usize; 9], } pub struct sigaction { pub sa_sigaction: ::sighandler_t, pub sa_mask: sigset_t, pub sa_flags: ::c_int, } pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_size: ::size_t, pub ss_flags: ::c_int, } pub struct fstore_t { pub fst_flags: ::c_uint, pub fst_posmode: ::c_int, pub fst_offset: ::off_t, pub fst_length: ::off_t, pub fst_bytesalloc: ::off_t, } pub struct radvisory { pub ra_offset: ::off_t, pub ra_count: ::c_int, } pub struct statvfs { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, pub f_blocks: ::fsblkcnt_t, pub f_bfree: ::fsblkcnt_t, pub f_bavail: ::fsblkcnt_t, pub f_files: ::fsfilcnt_t, pub f_ffree: ::fsfilcnt_t, pub f_favail: ::fsfilcnt_t, pub f_fsid: ::c_ulong, pub f_flag: ::c_ulong, pub f_namemax: ::c_ulong, } pub struct Dl_info { pub dli_fname: *const ::c_char, pub dli_fbase: *mut ::c_void, pub dli_sname: *const ::c_char, pub dli_saddr: *mut ::c_void, } pub struct sockaddr_in { pub sin_len: u8, pub sin_family: ::sa_family_t, pub sin_port: ::in_port_t, pub sin_addr: ::in_addr, pub sin_zero: [::c_char; 8], } pub struct statfs { pub f_bsize: ::uint32_t, pub f_iosize: ::int32_t, pub f_blocks: ::uint64_t, pub f_bfree: ::uint64_t, pub f_bavail: ::uint64_t, pub f_files: ::uint64_t, pub f_ffree: ::uint64_t, pub f_fsid: ::fsid_t, pub f_owner: ::uid_t, pub f_type: ::uint32_t, pub f_flags: ::uint32_t, pub f_fssubtype: ::uint32_t, pub f_fstypename: [::c_char; 16], pub f_mntonname: [::c_char; 1024], pub f_mntfromname: [::c_char; 1024], pub f_reserved: [::uint32_t; 8], } // FIXME: this should have align 4 but it's got align 8 on 64-bit pub struct kevent { pub ident: ::uintptr_t, pub filter: ::int16_t, pub flags: ::uint16_t, pub fflags: ::uint32_t, pub data: ::intptr_t, pub udata: *mut ::c_void, } pub struct kevent64_s { pub ident: ::uint64_t, pub filter: ::int16_t, pub flags: ::uint16_t, pub fflags: ::uint32_t, pub data: ::int64_t, pub udata: ::uint64_t, pub ext: [::uint64_t; 2], } pub struct dqblk { pub dqb_bhardlimit: ::uint64_t, pub dqb_bsoftlimit: ::uint64_t, pub dqb_curbytes: ::uint64_t, pub dqb_ihardlimit: ::uint32_t, pub dqb_isoftlimit: ::uint32_t, pub dqb_curinodes: ::uint32_t, pub dqb_btime: ::uint32_t, pub dqb_itime: ::uint32_t, pub dqb_id: ::uint32_t, pub dqb_spare: [::uint32_t; 4], } pub struct termios { pub c_iflag: ::tcflag_t, pub c_oflag: ::tcflag_t, pub c_cflag: ::tcflag_t, pub c_lflag: ::tcflag_t, pub c_cc: [::cc_t; ::NCCS], pub c_ispeed: ::speed_t, pub c_ospeed: ::speed_t, } } pub const EXIT_FAILURE: ::c_int = 1; pub const EXIT_SUCCESS: ::c_int = 0; pub const RAND_MAX: ::c_int = 2147483647; pub const EOF: ::c_int = -1; pub const SEEK_SET: ::c_int = 0; pub const SEEK_CUR: ::c_int = 1; pub const SEEK_END: ::c_int = 2; pub const _IOFBF: ::c_int = 0; pub const _IONBF: ::c_int = 2; pub const _IOLBF: ::c_int = 1; pub const BUFSIZ: ::c_uint = 1024; pub const FOPEN_MAX: ::c_uint = 20; pub const FILENAME_MAX: ::c_uint = 1024; pub const L_tmpnam: ::c_uint = 1024; pub const TMP_MAX: ::c_uint = 308915776; pub const _PC_NAME_MAX: ::c_int = 4; pub const O_RDONLY: ::c_int = 0; pub const O_WRONLY: ::c_int = 1; pub const O_RDWR: ::c_int = 2; pub const O_APPEND: ::c_int = 8; pub const O_CREAT: ::c_int = 512; pub const O_EXCL: ::c_int = 2048; pub const O_NOCTTY: ::c_int = 131072; pub const O_TRUNC: ::c_int = 1024; pub const O_CLOEXEC: ::c_int = 0x1000000; pub const O_DIRECTORY: ::c_int = 0x100000; pub const S_IFIFO: mode_t = 4096; pub const S_IFCHR: mode_t = 8192; pub const S_IFBLK: mode_t = 24576; pub const S_IFDIR: mode_t = 16384; pub const S_IFREG: mode_t = 32768; pub const S_IFLNK: mode_t = 40960; pub const S_IFSOCK: mode_t = 49152; pub const S_IFMT: mode_t = 61440; pub const S_IEXEC: mode_t = 64; pub const S_IWRITE: mode_t = 128; pub const S_IREAD: mode_t = 256; pub const S_IRWXU: mode_t = 448; pub const S_IXUSR: mode_t = 64; pub const S_IWUSR: mode_t = 128; pub const S_IRUSR: mode_t = 256; pub const S_IRWXG: mode_t = 56; pub const S_IXGRP: mode_t = 8; pub const S_IWGRP: mode_t = 16; pub const S_IRGRP: mode_t = 32; pub const S_IRWXO: mode_t = 7; pub const S_IXOTH: mode_t = 1; pub const S_IWOTH: mode_t = 2; pub const S_IROTH: mode_t = 4; pub const F_OK: ::c_int = 0; pub const R_OK: ::c_int = 4; pub const W_OK: ::c_int = 2; pub const X_OK: ::c_int = 1; pub const STDIN_FILENO: ::c_int = 0; pub const STDOUT_FILENO: ::c_int = 1; pub const STDERR_FILENO: ::c_int = 2; pub const F_LOCK: ::c_int = 1; pub const F_TEST: ::c_int = 3; pub const F_TLOCK: ::c_int = 2; pub const F_ULOCK: ::c_int = 0; pub const SIGHUP: ::c_int = 1; pub const SIGINT: ::c_int = 2; pub const SIGQUIT: ::c_int = 3; pub const SIGILL: ::c_int = 4; pub const SIGABRT: ::c_int = 6; pub const SIGFPE: ::c_int = 8; pub const SIGKILL: ::c_int = 9; pub const SIGSEGV: ::c_int = 11; pub const SIGPIPE: ::c_int = 13; pub const SIGALRM: ::c_int = 14; pub const SIGTERM: ::c_int = 15; pub const PROT_NONE: ::c_int = 0; pub const PROT_READ: ::c_int = 1; pub const PROT_WRITE: ::c_int = 2; pub const PROT_EXEC: ::c_int = 4; pub const MAP_FILE: ::c_int = 0x0000; pub const MAP_SHARED: ::c_int = 0x0001; pub const MAP_PRIVATE: ::c_int = 0x0002; pub const MAP_FIXED: ::c_int = 0x0010; pub const MAP_ANON: ::c_int = 0x1000; pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; pub const MS_ASYNC: ::c_int = 0x0001; pub const MS_INVALIDATE: ::c_int = 0x0002; pub const MS_SYNC: ::c_int = 0x0010; pub const MS_KILLPAGES: ::c_int = 0x0004; pub const MS_DEACTIVATE: ::c_int = 0x0008; pub const EPERM: ::c_int = 1; pub const ENOENT: ::c_int = 2; pub const ESRCH: ::c_int = 3; pub const EINTR: ::c_int = 4; pub const EIO: ::c_int = 5; pub const ENXIO: ::c_int = 6; pub const E2BIG: ::c_int = 7; pub const ENOEXEC: ::c_int = 8; pub const EBADF: ::c_int = 9; pub const ECHILD: ::c_int = 10; pub const EDEADLK: ::c_int = 11; pub const ENOMEM: ::c_int = 12; pub const EACCES: ::c_int = 13; pub const EFAULT: ::c_int = 14; pub const ENOTBLK: ::c_int = 15; pub const EBUSY: ::c_int = 16; pub const EEXIST: ::c_int = 17; pub const EXDEV: ::c_int = 18; pub const ENODEV: ::c_int = 19; pub const ENOTDIR: ::c_int = 20; pub const EISDIR: ::c_int = 21; pub const EINVAL: ::c_int = 22; pub const ENFILE: ::c_int = 23; pub const EMFILE: ::c_int = 24; pub const ENOTTY: ::c_int = 25; pub const ETXTBSY: ::c_int = 26; pub const EFBIG: ::c_int = 27; pub const ENOSPC: ::c_int = 28; pub const ESPIPE: ::c_int = 29; pub const EROFS: ::c_int = 30; pub const EMLINK: ::c_int = 31; pub const EPIPE: ::c_int = 32; pub const EDOM: ::c_int = 33; pub const ERANGE: ::c_int = 34; pub const EAGAIN: ::c_int = 35; pub const EWOULDBLOCK: ::c_int = EAGAIN; pub const EINPROGRESS: ::c_int = 36; pub const EALREADY: ::c_int = 37; pub const ENOTSOCK: ::c_int = 38; pub const EDESTADDRREQ: ::c_int = 39; pub const EMSGSIZE: ::c_int = 40; pub const EPROTOTYPE: ::c_int = 41; pub const ENOPROTOOPT: ::c_int = 42; pub const EPROTONOSUPPORT: ::c_int = 43; pub const ESOCKTNOSUPPORT: ::c_int = 44; pub const ENOTSUP: ::c_int = 45; pub const EPFNOSUPPORT: ::c_int = 46; pub const EAFNOSUPPORT: ::c_int = 47; pub const EADDRINUSE: ::c_int = 48; pub const EADDRNOTAVAIL: ::c_int = 49; pub const ENETDOWN: ::c_int = 50; pub const ENETUNREACH: ::c_int = 51; pub const ENETRESET: ::c_int = 52; pub const ECONNABORTED: ::c_int = 53; pub const ECONNRESET: ::c_int = 54; pub const ENOBUFS: ::c_int = 55; pub const EISCONN: ::c_int = 56; pub const ENOTCONN: ::c_int = 57; pub const ESHUTDOWN: ::c_int = 58; pub const ETOOMANYREFS: ::c_int = 59; pub const ETIMEDOUT: ::c_int = 60; pub const ECONNREFUSED: ::c_int = 61; pub const ELOOP: ::c_int = 62; pub const ENAMETOOLONG: ::c_int = 63; pub const EHOSTDOWN: ::c_int = 64; pub const EHOSTUNREACH: ::c_int = 65; pub const ENOTEMPTY: ::c_int = 66; pub const EPROCLIM: ::c_int = 67; pub const EUSERS: ::c_int = 68; pub const EDQUOT: ::c_int = 69; pub const ESTALE: ::c_int = 70; pub const EREMOTE: ::c_int = 71; pub const EBADRPC: ::c_int = 72; pub const ERPCMISMATCH: ::c_int = 73; pub const EPROGUNAVAIL: ::c_int = 74; pub const EPROGMISMATCH: ::c_int = 75; pub const EPROCUNAVAIL: ::c_int = 76; pub const ENOLCK: ::c_int = 77; pub const ENOSYS: ::c_int = 78; pub const EFTYPE: ::c_int = 79; pub const EAUTH: ::c_int = 80; pub const ENEEDAUTH: ::c_int = 81; pub const EPWROFF: ::c_int = 82; pub const EDEVERR: ::c_int = 83; pub const EOVERFLOW: ::c_int = 84; pub const EBADEXEC: ::c_int = 85; pub const EBADARCH: ::c_int = 86; pub const ESHLIBVERS: ::c_int = 87; pub const EBADMACHO: ::c_int = 88; pub const ECANCELED: ::c_int = 89; pub const EIDRM: ::c_int = 90; pub const ENOMSG: ::c_int = 91; pub const EILSEQ: ::c_int = 92; pub const ENOATTR: ::c_int = 93; pub const EBADMSG: ::c_int = 94; pub const EMULTIHOP: ::c_int = 95; pub const ENODATA: ::c_int = 96; pub const ENOLINK: ::c_int = 97; pub const ENOSR: ::c_int = 98; pub const ENOSTR: ::c_int = 99; pub const EPROTO: ::c_int = 100; pub const ETIME: ::c_int = 101; pub const EOPNOTSUPP: ::c_int = 102; pub const ENOPOLICY: ::c_int = 103; pub const ENOTRECOVERABLE: ::c_int = 104; pub const EOWNERDEAD: ::c_int = 105; pub const EQFULL: ::c_int = 106; pub const ELAST: ::c_int = 106; pub const F_DUPFD: ::c_int = 0; pub const F_DUPFD_CLOEXEC: ::c_int = 67; pub const F_GETFD: ::c_int = 1; pub const F_SETFD: ::c_int = 2; pub const F_GETFL: ::c_int = 3; pub const F_SETFL: ::c_int = 4; pub const F_PREALLOCATE: ::c_int = 42; pub const F_RDADVISE: ::c_int = 44; pub const F_RDAHEAD: ::c_int = 45; pub const F_NOCACHE: ::c_int = 48; pub const F_GETPATH: ::c_int = 50; pub const F_FULLFSYNC: ::c_int = 51; pub const F_FREEZE_FS: ::c_int = 53; pub const F_THAW_FS: ::c_int = 54; pub const F_GLOBAL_NOCACHE: ::c_int = 55; pub const F_NODIRECT: ::c_int = 62; pub const F_ALLOCATECONTIG: ::c_uint = 0x02; pub const F_ALLOCATEALL: ::c_uint = 0x04; pub const F_PEOFPOSMODE: ::c_int = 3; pub const F_VOLPOSMODE: ::c_int = 4; pub const O_ACCMODE: ::c_int = 3; pub const SIGTRAP: ::c_int = 5; pub const GLOB_APPEND : ::c_int = 0x0001; pub const GLOB_DOOFFS : ::c_int = 0x0002; pub const GLOB_ERR : ::c_int = 0x0004; pub const GLOB_MARK : ::c_int = 0x0008; pub const GLOB_NOCHECK : ::c_int = 0x0010; pub const GLOB_NOSORT : ::c_int = 0x0020; pub const GLOB_NOESCAPE: ::c_int = 0x2000; pub const GLOB_NOSPACE : ::c_int = -1; pub const GLOB_ABORTED : ::c_int = -2; pub const GLOB_NOMATCH : ::c_int = -3; pub const POSIX_MADV_NORMAL: ::c_int = 0; pub const POSIX_MADV_RANDOM: ::c_int = 1; pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; pub const POSIX_MADV_WILLNEED: ::c_int = 3; pub const POSIX_MADV_DONTNEED: ::c_int = 4; pub const _SC_IOV_MAX: ::c_int = 56; pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 70; pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 71; pub const _SC_LOGIN_NAME_MAX: ::c_int = 73; pub const _SC_MQ_PRIO_MAX: ::c_int = 75; pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 82; pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 83; pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 85; pub const _SC_THREAD_KEYS_MAX: ::c_int = 86; pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 87; pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 88; pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 89; pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 90; pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 91; pub const _SC_THREAD_STACK_MIN: ::c_int = 93; pub const _SC_THREAD_THREADS_MAX: ::c_int = 94; pub const _SC_THREADS: ::c_int = 96; pub const _SC_TTY_NAME_MAX: ::c_int = 101; pub const _SC_ATEXIT_MAX: ::c_int = 107; pub const _SC_XOPEN_CRYPT: ::c_int = 108; pub const _SC_XOPEN_ENH_I18N: ::c_int = 109; pub const _SC_XOPEN_LEGACY: ::c_int = 110; pub const _SC_XOPEN_REALTIME: ::c_int = 111; pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 112; pub const _SC_XOPEN_SHM: ::c_int = 113; pub const _SC_XOPEN_UNIX: ::c_int = 115; pub const _SC_XOPEN_VERSION: ::c_int = 116; pub const _SC_XOPEN_XCU_VERSION: ::c_int = 121; pub const PTHREAD_CREATE_JOINABLE: ::c_int = 1; pub const PTHREAD_CREATE_DETACHED: ::c_int = 2; pub const PTHREAD_STACK_MIN: ::size_t = 8192; pub const RLIMIT_CPU: ::c_int = 0; pub const RLIMIT_FSIZE: ::c_int = 1; pub const RLIMIT_DATA: ::c_int = 2; pub const RLIMIT_STACK: ::c_int = 3; pub const RLIMIT_CORE: ::c_int = 4; pub const RLIMIT_AS: ::c_int = 5; pub const RLIMIT_MEMLOCK: ::c_int = 6; pub const RLIMIT_NPROC: ::c_int = 7; pub const RLIMIT_NOFILE: ::c_int = 8; pub const RLIM_NLIMITS: ::c_int = 9; pub const _RLIMIT_POSIX_FLAG: ::c_int = 0x1000; pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; pub const RUSAGE_SELF: ::c_int = 0; pub const RUSAGE_CHILDREN: ::c_int = -1; pub const MADV_NORMAL: ::c_int = 0; pub const MADV_RANDOM: ::c_int = 1; pub const MADV_SEQUENTIAL: ::c_int = 2; pub const MADV_WILLNEED: ::c_int = 3; pub const MADV_DONTNEED: ::c_int = 4; pub const MADV_FREE: ::c_int = 5; pub const MADV_ZERO_WIRED_PAGES: ::c_int = 6; pub const MADV_FREE_REUSABLE: ::c_int = 7; pub const MADV_FREE_REUSE: ::c_int = 8; pub const MADV_CAN_REUSE: ::c_int = 9; pub const MINCORE_INCORE: ::c_int = 0x1; pub const MINCORE_REFERENCED: ::c_int = 0x2; pub const MINCORE_MODIFIED: ::c_int = 0x4; pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8; pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10; pub const AF_UNIX: ::c_int = 1; pub const AF_INET: ::c_int = 2; pub const AF_INET6: ::c_int = 30; pub const SOCK_STREAM: ::c_int = 1; pub const SOCK_DGRAM: ::c_int = 2; pub const SOCK_RAW: ::c_int = 3; pub const IPPROTO_TCP: ::c_int = 6; pub const IPPROTO_IP: ::c_int = 0; pub const IPPROTO_IPV6: ::c_int = 41; pub const IP_MULTICAST_TTL: ::c_int = 10; pub const IP_MULTICAST_LOOP: ::c_int = 11; pub const IP_TTL: ::c_int = 4; pub const IP_HDRINCL: ::c_int = 2; pub const IP_ADD_MEMBERSHIP: ::c_int = 12; pub const IP_DROP_MEMBERSHIP: ::c_int = 13; pub const IPV6_JOIN_GROUP: ::c_int = 12; pub const IPV6_LEAVE_GROUP: ::c_int = 13; pub const TCP_NODELAY: ::c_int = 0x01; pub const TCP_KEEPALIVE: ::c_int = 0x10; pub const SOL_SOCKET: ::c_int = 0xffff; pub const SO_DEBUG: ::c_int = 0x01; pub const SO_ACCEPTCONN: ::c_int = 0x0002; pub const SO_REUSEADDR: ::c_int = 0x0004; pub const SO_KEEPALIVE: ::c_int = 0x0008; pub const SO_DONTROUTE: ::c_int = 0x0010; pub const SO_BROADCAST: ::c_int = 0x0020; pub const SO_USELOOPBACK: ::c_int = 0x0040; pub const SO_LINGER: ::c_int = 0x0080; pub const SO_OOBINLINE: ::c_int = 0x0100; pub const SO_REUSEPORT: ::c_int = 0x0200; pub const SO_SNDBUF: ::c_int = 0x1001; pub const SO_RCVBUF: ::c_int = 0x1002; pub const SO_SNDLOWAT: ::c_int = 0x1003; pub const SO_RCVLOWAT: ::c_int = 0x1004; pub const SO_SNDTIMEO: ::c_int = 0x1005; pub const SO_RCVTIMEO: ::c_int = 0x1006; pub const SO_ERROR: ::c_int = 0x1007; pub const SO_TYPE: ::c_int = 0x1008; pub const IFF_LOOPBACK: ::c_int = 0x8; pub const SHUT_RD: ::c_int = 0; pub const SHUT_WR: ::c_int = 1; pub const SHUT_RDWR: ::c_int = 2; pub const LOCK_SH: ::c_int = 1; pub const LOCK_EX: ::c_int = 2; pub const LOCK_NB: ::c_int = 4; pub const LOCK_UN: ::c_int = 8; pub const O_DSYNC: ::c_int = 4194304; pub const O_SYNC: ::c_int = 128; pub const O_NONBLOCK: ::c_int = 4; pub const MAP_COPY: ::c_int = 0x0002; pub const MAP_RENAME: ::c_int = 0x0020; pub const MAP_NORESERVE: ::c_int = 0x0040; pub const MAP_NOEXTEND: ::c_int = 0x0100; pub const MAP_HASSEMAPHORE: ::c_int = 0x0200; pub const MAP_NOCACHE: ::c_int = 0x0400; pub const MAP_JIT: ::c_int = 0x0800; pub const IPPROTO_RAW: ::c_int = 255; pub const SO_NREAD: ::c_int = 0x1020; pub const SO_NKE: ::c_int = 0x1021; pub const SO_NOSIGPIPE: ::c_int = 0x1022; pub const SO_NOADDRERR: ::c_int = 0x1023; pub const SO_NWRITE: ::c_int = 0x1024; pub const SO_DONTTRUNC: ::c_int = 0x2000; pub const SO_WANTMORE: ::c_int = 0x4000; pub const SO_WANTOOBFLAG: ::c_int = 0x8000; pub const _SC_ARG_MAX: ::c_int = 1; pub const _SC_CHILD_MAX: ::c_int = 2; pub const _SC_CLK_TCK: ::c_int = 3; pub const _SC_NGROUPS_MAX: ::c_int = 4; pub const _SC_OPEN_MAX: ::c_int = 5; pub const _SC_JOB_CONTROL: ::c_int = 6; pub const _SC_SAVED_IDS: ::c_int = 7; pub const _SC_VERSION: ::c_int = 8; pub const _SC_BC_BASE_MAX: ::c_int = 9; pub const _SC_BC_DIM_MAX: ::c_int = 10; pub const _SC_BC_SCALE_MAX: ::c_int = 11; pub const _SC_BC_STRING_MAX: ::c_int = 12; pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 13; pub const _SC_EXPR_NEST_MAX: ::c_int = 14; pub const _SC_LINE_MAX: ::c_int = 15; pub const _SC_RE_DUP_MAX: ::c_int = 16; pub const _SC_2_VERSION: ::c_int = 17; pub const _SC_2_C_BIND: ::c_int = 18; pub const _SC_2_C_DEV: ::c_int = 19; pub const _SC_2_CHAR_TERM: ::c_int = 20; pub const _SC_2_FORT_DEV: ::c_int = 21; pub const _SC_2_FORT_RUN: ::c_int = 22; pub const _SC_2_LOCALEDEF: ::c_int = 23; pub const _SC_2_SW_DEV: ::c_int = 24; pub const _SC_2_UPE: ::c_int = 25; pub const _SC_STREAM_MAX: ::c_int = 26; pub const _SC_TZNAME_MAX: ::c_int = 27; pub const _SC_ASYNCHRONOUS_IO: ::c_int = 28; pub const _SC_PAGESIZE: ::c_int = 29; pub const _SC_MEMLOCK: ::c_int = 30; pub const _SC_MEMLOCK_RANGE: ::c_int = 31; pub const _SC_MEMORY_PROTECTION: ::c_int = 32; pub const _SC_MESSAGE_PASSING: ::c_int = 33; pub const _SC_PRIORITIZED_IO: ::c_int = 34; pub const _SC_PRIORITY_SCHEDULING: ::c_int = 35; pub const _SC_REALTIME_SIGNALS: ::c_int = 36; pub const _SC_SEMAPHORES: ::c_int = 37; pub const _SC_FSYNC: ::c_int = 38; pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 39; pub const _SC_SYNCHRONIZED_IO: ::c_int = 40; pub const _SC_TIMERS: ::c_int = 41; pub const _SC_AIO_LISTIO_MAX: ::c_int = 42; pub const _SC_AIO_MAX: ::c_int = 43; pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 44; pub const _SC_DELAYTIMER_MAX: ::c_int = 45; pub const _SC_MQ_OPEN_MAX: ::c_int = 46; pub const _SC_MAPPED_FILES: ::c_int = 47; pub const _SC_RTSIG_MAX: ::c_int = 48; pub const _SC_SEM_NSEMS_MAX: ::c_int = 49; pub const _SC_SEM_VALUE_MAX: ::c_int = 50; pub const _SC_SIGQUEUE_MAX: ::c_int = 51; pub const _SC_TIMER_MAX: ::c_int = 52; pub const _SC_NPROCESSORS_CONF: ::c_int = 57; pub const _SC_NPROCESSORS_ONLN: ::c_int = 58; pub const _SC_2_PBS: ::c_int = 59; pub const _SC_2_PBS_ACCOUNTING: ::c_int = 60; pub const _SC_2_PBS_CHECKPOINT: ::c_int = 61; pub const _SC_2_PBS_LOCATE: ::c_int = 62; pub const _SC_2_PBS_MESSAGE: ::c_int = 63; pub const _SC_2_PBS_TRACK: ::c_int = 64; pub const _SC_ADVISORY_INFO: ::c_int = 65; pub const _SC_BARRIERS: ::c_int = 66; pub const _SC_CLOCK_SELECTION: ::c_int = 67; pub const _SC_CPUTIME: ::c_int = 68; pub const _SC_FILE_LOCKING: ::c_int = 69; pub const _SC_HOST_NAME_MAX: ::c_int = 72; pub const _SC_MONOTONIC_CLOCK: ::c_int = 74; pub const _SC_READER_WRITER_LOCKS: ::c_int = 76; pub const _SC_REGEXP: ::c_int = 77; pub const _SC_SHELL: ::c_int = 78; pub const _SC_SPAWN: ::c_int = 79; pub const _SC_SPIN_LOCKS: ::c_int = 80; pub const _SC_SPORADIC_SERVER: ::c_int = 81; pub const _SC_THREAD_CPUTIME: ::c_int = 84; pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 92; pub const _SC_TIMEOUTS: ::c_int = 95; pub const _SC_TRACE: ::c_int = 97; pub const _SC_TRACE_EVENT_FILTER: ::c_int = 98; pub const _SC_TRACE_INHERIT: ::c_int = 99; pub const _SC_TRACE_LOG: ::c_int = 100; pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 102; pub const _SC_V6_ILP32_OFF32: ::c_int = 103; pub const _SC_V6_ILP32_OFFBIG: ::c_int = 104; pub const _SC_V6_LP64_OFF64: ::c_int = 105; pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 106; pub const _SC_IPV6: ::c_int = 118; pub const _SC_RAW_SOCKETS: ::c_int = 119; pub const _SC_SYMLOOP_MAX: ::c_int = 120; pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; pub const _SC_XOPEN_STREAMS: ::c_int = 114; pub const _SC_XBS5_ILP32_OFF32: ::c_int = 122; pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 123; pub const _SC_XBS5_LP64_OFF64: ::c_int = 124; pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 125; pub const _SC_SS_REPL_MAX: ::c_int = 126; pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 127; pub const _SC_TRACE_NAME_MAX: ::c_int = 128; pub const _SC_TRACE_SYS_MAX: ::c_int = 129; pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 130; pub const _SC_PASS_MAX: ::c_int = 131; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; pub const _PTHREAD_MUTEX_SIG_init: ::c_long = 0x32AAABA7; pub const _PTHREAD_COND_SIG_init: ::c_long = 0x3CB0B1BB; pub const _PTHREAD_RWLOCK_SIG_init: ::c_long = 0x2DA8B3B4; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { __sig: _PTHREAD_MUTEX_SIG_init, __opaque: [0; __PTHREAD_MUTEX_SIZE__], }; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { __sig: _PTHREAD_COND_SIG_init, __opaque: [0; __PTHREAD_COND_SIZE__], }; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __sig: _PTHREAD_RWLOCK_SIG_init, __opaque: [0; __PTHREAD_RWLOCK_SIZE__], }; pub const SIGSTKSZ: ::size_t = 131072; pub const FD_SETSIZE: usize = 1024; pub const ST_NOSUID: ::c_ulong = 2; pub const HW_AVAILCPU: ::c_int = 25; pub const EVFILT_AIO: ::int16_t = 0xfffd; pub const EVFILT_PROC: ::int16_t = 0xfffb; pub const EVFILT_READ: ::int16_t = 0xffff; pub const EVFILT_SIGNAL: ::int16_t = 0xfffa; pub const EVFILT_SYSCOUNT: ::int16_t = 0xe; pub const EVFILT_TIMER: ::int16_t = 0xfff9; pub const EVFILT_VNODE: ::int16_t = 0xfffc; pub const EVFILT_WRITE: ::int16_t = 0xfffe; pub const EVFILT_FS: ::int16_t = 0xfff7; pub const EVFILT_MACHPORT: ::int16_t = 0xfff8; pub const EVFILT_USER: ::int16_t = 0xfff6; pub const EVFILT_VM: ::int16_t = 0xfff4; pub const EV_DISPATCH: ::uint16_t = 0x80; pub const EV_FLAG0: ::uint16_t = 0x1000; pub const EV_OOBAND: ::uint16_t = 0x2000; pub const EV_POLL: ::uint16_t = 0x1000; pub const EV_RECEIPT: ::uint16_t = 0x40; pub const NOTE_ABSOLUTE: ::uint32_t = 0x8; pub const NOTE_EXITSTATUS: ::uint32_t = 0x04000000; pub const NOTE_EXIT_REPARENTED: ::uint32_t = 0x00080000; pub const NOTE_FFAND: ::uint32_t = 0x40000000; pub const NOTE_FFCOPY: ::uint32_t = 0xc0000000; pub const NOTE_FFCTRLMASK: ::uint32_t = 0xc0000000; pub const NOTE_FFLAGSMASK: ::uint32_t = 0x00ffffff; pub const NOTE_FFNOP: ::uint32_t = 0x0; pub const NOTE_FFOR: ::uint32_t = 0x80000000; pub const NOTE_NONE: ::uint32_t = 0x80; pub const NOTE_NSECONDS: ::uint32_t = 0x4; pub const NOTE_REAP: ::uint32_t = 0x10000000; pub const NOTE_SECONDS: ::uint32_t = 0x1; pub const NOTE_SIGNAL: ::uint32_t = 0x8000000; pub const NOTE_TRIGGER: ::uint32_t = 0x01000000; pub const NOTE_USECONDS: ::uint32_t = 0x2; pub const NOTE_VM_ERROR: ::uint32_t = 0x10000000; pub const NOTE_VM_PRESSURE: ::uint32_t = 0x80000000; pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE: ::uint32_t = 0x20000000; pub const NOTE_VM_PRESSURE_TERMINATE: ::uint32_t = 0x40000000; pub const NOTE_PCTRLMASK: ::uint32_t = 0xfff00000; pub const TAB3: ::c_int = 0x00000004; pub const VT0: ::c_int = 0x00000000; pub const VT1: ::c_int = 0x00010000; pub const IUTF8: ::tcflag_t = 0x00004000; pub const CRTSCTS: ::tcflag_t = 0x00030000; extern { pub fn mincore(addr: *const ::c_void, len: ::size_t, vec: *mut ::c_char) -> ::c_int; pub fn sysctlnametomib(name: *const ::c_char, mibp: *mut ::c_int, sizep: *mut ::size_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "mprotect$UNIX2003")] pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; pub fn shm_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::c_int; pub fn sysctl(name: *mut ::c_int, namelen: ::c_uint, oldp: *mut ::c_void, oldlenp: *mut ::size_t, newp: *mut ::c_void, newlen: ::size_t) -> ::c_int; pub fn sysctlbyname(name: *const ::c_char, oldp: *mut ::c_void, oldlenp: *mut ::size_t, newp: *mut ::c_void, newlen: ::size_t) -> ::c_int; pub fn mach_absolute_time() -> u64; pub fn mach_timebase_info(info: *mut ::mach_timebase_info) -> ::c_int; pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int; pub fn pthread_get_stackaddr_np(thread: ::pthread_t) -> *mut ::c_void; pub fn pthread_get_stacksize_np(thread: ::pthread_t) -> ::size_t; pub fn __error() -> *mut ::c_int; pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int; #[cfg_attr(target_os = "macos", link_name = "statfs$INODE64")] pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; #[cfg_attr(target_os = "macos", link_name = "fstatfs$INODE64")] pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; pub fn kevent(kq: ::c_int, changelist: *const ::kevent, nchanges: ::c_int, eventlist: *mut ::kevent, nevents: ::c_int, timeout: *const ::timespec) -> ::c_int; pub fn kevent64(kq: ::c_int, changelist: *const ::kevent64_s, nchanges: ::c_int, eventlist: *mut ::kevent64_s, nevents: ::c_int, flags: ::c_uint, timeout: *const ::timespec) -> ::c_int; pub fn mount(src: *const ::c_char, target: *const ::c_char, flags: ::c_int, data: *mut ::c_void) -> ::c_int; pub fn ptrace(requeset: ::c_int, pid: ::pid_t, addr: *mut ::c_char, data: ::c_int) -> ::c_int; pub fn quotactl(special: *const ::c_char, cmd: ::c_int, id: ::c_int, data: *mut ::c_char) -> ::c_int; pub fn sethostname(name: *const ::c_char, len: ::c_int) -> ::c_int; } cfg_if! { if #[cfg(any(target_arch = "arm", target_arch = "x86"))] { mod b32; pub use self::b32::*; } else if #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] { mod b64; pub use self::b64::*; } else { // unknown arch... } } deps/libc-0.2.4/src/unix/bsd/apple/b32.rs0000664000175000017500000000052512614241040014656 0ustar //! 32-bit specific Apple (ios/darwin) definitions pub type c_long = i32; pub type c_ulong = u32; pub const __PTHREAD_MUTEX_SIZE__: usize = 40; pub const __PTHREAD_COND_SIZE__: usize = 24; pub const __PTHREAD_RWLOCK_SIZE__: usize = 124; s! { pub struct pthread_attr_t { __sig: c_long, __opaque: [::c_char; 36] } } deps/libc-0.2.4/src/unix/bsd/mod.rs0000664000175000017500000002464412634314567013777 0ustar pub type c_char = i8; pub type wchar_t = i32; pub type off_t = i64; pub type useconds_t = u32; pub type blkcnt_t = i64; pub type socklen_t = u32; pub type sa_family_t = u8; pub type pthread_t = ::uintptr_t; s! { pub struct sockaddr { pub sa_len: u8, pub sa_family: sa_family_t, pub sa_data: [::c_char; 14], } pub struct sockaddr_in6 { pub sin6_len: u8, pub sin6_family: sa_family_t, pub sin6_port: ::in_port_t, pub sin6_flowinfo: u32, pub sin6_addr: ::in6_addr, pub sin6_scope_id: u32, } pub struct sockaddr_un { pub sun_len: u8, pub sun_family: sa_family_t, pub sun_path: [c_char; 104] } pub struct passwd { pub pw_name: *mut ::c_char, pub pw_passwd: *mut ::c_char, pub pw_uid: ::uid_t, pub pw_gid: ::gid_t, pub pw_change: ::time_t, pub pw_class: *mut ::c_char, pub pw_gecos: *mut ::c_char, pub pw_dir: *mut ::c_char, pub pw_shell: *mut ::c_char, pub pw_expire: ::time_t, #[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "netbsd")))] pub pw_fields: ::c_int, } pub struct ifaddrs { pub ifa_next: *mut ifaddrs, pub ifa_name: *mut ::c_char, pub ifa_flags: ::c_uint, pub ifa_addr: *mut ::sockaddr, pub ifa_netmask: *mut ::sockaddr, pub ifa_dstaddr: *mut ::sockaddr, pub ifa_data: *mut ::c_void } pub struct fd_set { fds_bits: [i32; FD_SETSIZE / 32], } pub struct tm { pub tm_sec: ::c_int, pub tm_min: ::c_int, pub tm_hour: ::c_int, pub tm_mday: ::c_int, pub tm_mon: ::c_int, pub tm_year: ::c_int, pub tm_wday: ::c_int, pub tm_yday: ::c_int, pub tm_isdst: ::c_int, pub tm_gmtoff: ::c_long, pub tm_zone: *mut ::c_char, } pub struct utsname { pub sysname: [::c_char; 256], pub nodename: [::c_char; 256], pub release: [::c_char; 256], pub version: [::c_char; 256], pub machine: [::c_char; 256], } pub struct msghdr { pub msg_name: *mut ::c_void, pub msg_namelen: ::socklen_t, pub msg_iov: *mut ::iovec, pub msg_iovlen: ::c_int, pub msg_control: *mut ::c_void, pub msg_controllen: ::socklen_t, pub msg_flags: ::c_int, } pub struct flock { pub l_start: ::off_t, pub l_len: ::off_t, pub l_pid: ::pid_t, pub l_type: ::c_short, pub l_whence: ::c_short, } pub struct fsid_t { __fsid_val: [::int32_t; 2], } } pub const FIOCLEX: ::c_ulong = 0x20006601; pub const FIONBIO: ::c_ulong = 0x8004667e; pub const PATH_MAX: ::c_int = 1024; pub const SA_ONSTACK: ::c_int = 0x0001; pub const SA_SIGINFO: ::c_int = 0x0040; pub const SA_RESTART: ::c_int = 0x0002; pub const SA_RESETHAND: ::c_int = 0x0004; pub const SA_NOCLDSTOP: ::c_int = 0x0008; pub const SA_NODEFER: ::c_int = 0x0010; pub const SA_NOCLDWAIT: ::c_int = 0x0020; pub const SIGCHLD: ::c_int = 20; pub const SIGBUS: ::c_int = 10; pub const SIGUSR1: ::c_int = 30; pub const SIGUSR2: ::c_int = 31; pub const SIGCONT: ::c_int = 19; pub const SIGSTOP: ::c_int = 17; pub const SIGTSTP: ::c_int = 18; pub const SIGURG: ::c_int = 16; pub const SIGIO: ::c_int = 23; pub const SIGSYS: ::c_int = 12; pub const SIGTTIN: ::c_int = 21; pub const SIGTTOU: ::c_int = 22; pub const SIGXCPU: ::c_int = 24; pub const SIGXFSZ: ::c_int = 25; pub const SIGVTALRM: ::c_int = 26; pub const SIGPROF: ::c_int = 27; pub const SIGWINCH: ::c_int = 28; pub const SIG_SETMASK: ::c_int = 3; pub const SIG_BLOCK: ::c_int = 0x1; pub const SIG_UNBLOCK: ::c_int = 0x2; pub const IPV6_MULTICAST_LOOP: ::c_int = 11; pub const IPV6_V6ONLY: ::c_int = 27; pub const ST_RDONLY: ::c_ulong = 1; pub const NI_MAXHOST: ::socklen_t = 1025; pub const CTL_HW: ::c_int = 6; pub const HW_NCPU: ::c_int = 3; pub const EV_ADD: ::uint16_t = 0x1; pub const EV_CLEAR: ::uint16_t = 0x20; pub const EV_DELETE: ::uint16_t = 0x2; pub const EV_DISABLE: ::uint16_t = 0x8; pub const EV_ENABLE: ::uint16_t = 0x4; pub const EV_EOF: ::uint16_t = 0x8000; pub const EV_ERROR: ::uint16_t = 0x4000; pub const EV_FLAG1: ::uint16_t = 0x2000; pub const EV_ONESHOT: ::uint16_t = 0x10; pub const EV_SYSFLAGS: ::uint16_t = 0xf000; pub const NOTE_ATTRIB: ::uint32_t = 0x8; pub const NOTE_CHILD: ::uint32_t = 0x4; pub const NOTE_DELETE: ::uint32_t = 0x1; pub const NOTE_EXEC: ::uint32_t = 0x20000000; pub const NOTE_EXIT: ::uint32_t = 0x80000000; pub const NOTE_EXTEND: ::uint32_t = 0x4; pub const NOTE_FORK: ::uint32_t = 0x40000000; pub const NOTE_LINK: ::uint32_t = 0x10; pub const NOTE_LOWAT: ::uint32_t = 0x1; pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff; pub const NOTE_RENAME: ::uint32_t = 0x20; pub const NOTE_REVOKE: ::uint32_t = 0x40; pub const NOTE_TRACK: ::uint32_t = 0x1; pub const NOTE_TRACKERR: ::uint32_t = 0x2; pub const NOTE_WRITE: ::uint32_t = 0x2; pub const NCCS: usize = 20; pub const O_ASYNC: ::c_int = 0x40; pub const O_FSYNC: ::c_int = 0x80; pub const O_NDELAY: ::c_int = 0x4; pub const O_NOFOLLOW: ::c_int = 0x100; pub const F_GETLK: ::c_int = 7; pub const F_GETOWN: ::c_int = 5; pub const F_SETLK: ::c_int = 8; pub const F_SETLKW: ::c_int = 9; pub const F_SETOWN: ::c_int = 6; pub const MNT_FORCE: ::c_int = 0x80000; pub const Q_SYNC: ::c_int = 0x600; pub const Q_QUOTAON: ::c_int = 0x100; pub const Q_QUOTAOFF: ::c_int = 0x200; pub const Q_GETQUOTA: ::c_int = 0x300; pub const Q_SETQUOTA: ::c_int = 0x400; pub const TCIOFF: ::c_int = 3; pub const TCION: ::c_int = 4; pub const TCOOFF: ::c_int = 1; pub const TCOON: ::c_int = 2; pub const TCIFLUSH: ::c_int = 1; pub const TCOFLUSH: ::c_int = 2; pub const TCIOFLUSH: ::c_int = 3; pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; pub const NL0: ::c_int = 0x00000000; pub const NL1: ::c_int = 0x00000100; pub const TAB0: ::c_int = 0x00000000; pub const TAB1: ::c_int = 0x00000400; pub const TAB2: ::c_int = 0x00000800; pub const CR0: ::c_int = 0x00000000; pub const CR1: ::c_int = 0x00001000; pub const CR2: ::c_int = 0x00002000; pub const CR3: ::c_int = 0x00003000; pub const FF0: ::c_int = 0x00000000; pub const FF1: ::c_int = 0x00004000; pub const BS0: ::c_int = 0x00000000; pub const BS1: ::c_int = 0x00008000; pub const VEOF: usize = 0; pub const VEOL: usize = 1; pub const VEOL2: usize = 2; pub const VERASE: usize = 3; pub const VWERASE: usize = 4; pub const VKILL: usize = 5; pub const VREPRINT: usize = 6; pub const VINTR: usize = 8; pub const VQUIT: usize = 9; pub const VSUSP: usize = 10; pub const VSTART: usize = 12; pub const VSTOP: usize = 13; pub const VLNEXT: usize = 14; pub const VDISCARD: usize = 15; pub const VMIN: usize = 16; pub const VTIME: usize = 17; pub const IGNBRK: ::tcflag_t = 0x00000001; pub const BRKINT: ::tcflag_t = 0x00000002; pub const IGNPAR: ::tcflag_t = 0x00000004; pub const PARMRK: ::tcflag_t = 0x00000008; pub const INPCK: ::tcflag_t = 0x00000010; pub const ISTRIP: ::tcflag_t = 0x00000020; pub const INLCR: ::tcflag_t = 0x00000040; pub const IGNCR: ::tcflag_t = 0x00000080; pub const ICRNL: ::tcflag_t = 0x00000100; pub const IXON: ::tcflag_t = 0x00000200; pub const IXOFF: ::tcflag_t = 0x00000400; pub const IXANY: ::tcflag_t = 0x00000800; pub const IMAXBEL: ::tcflag_t = 0x00002000; pub const OPOST: ::tcflag_t = 0x1; pub const ONLCR: ::tcflag_t = 0x2; pub const CSIZE: ::tcflag_t = 0x00000300; pub const CS5: ::tcflag_t = 0x00000000; pub const CS6: ::tcflag_t = 0x00000100; pub const CS7: ::tcflag_t = 0x00000200; pub const CS8: ::tcflag_t = 0x00000300; pub const CSTOPB: ::tcflag_t = 0x00000400; pub const CREAD: ::tcflag_t = 0x00000800; pub const PARENB: ::tcflag_t = 0x00001000; pub const PARODD: ::tcflag_t = 0x00002000; pub const HUPCL: ::tcflag_t = 0x00004000; pub const CLOCAL: ::tcflag_t = 0x00008000; pub const ECHOKE: ::tcflag_t = 0x00000001; pub const ECHOE: ::tcflag_t = 0x00000002; pub const ECHOK: ::tcflag_t = 0x00000004; pub const ECHO: ::tcflag_t = 0x00000008; pub const ECHONL: ::tcflag_t = 0x00000010; pub const ECHOPRT: ::tcflag_t = 0x00000020; pub const ECHOCTL: ::tcflag_t = 0x00000040; pub const ISIG: ::tcflag_t = 0x00000080; pub const ICANON: ::tcflag_t = 0x00000100; pub const IEXTEN: ::tcflag_t = 0x00000400; pub const EXTPROC: ::tcflag_t = 0x00000800; pub const TOSTOP: ::tcflag_t = 0x00400000; pub const FLUSHO: ::tcflag_t = 0x00800000; pub const PENDIN: ::tcflag_t = 0x20000000; pub const NOFLSH: ::tcflag_t = 0x80000000; f! { pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { let fd = fd as usize; (*set).fds_bits[fd / 32] &= !(1 << (fd % 32)); return } pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { let fd = fd as usize; return ((*set).fds_bits[fd / 32] & (1 << (fd % 32))) != 0 } pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { let fd = fd as usize; (*set).fds_bits[fd / 32] |= 1 << (fd % 32); return } pub fn FD_ZERO(set: *mut fd_set) -> () { for slot in (*set).fds_bits.iter_mut() { *slot = 0; } } pub fn WIFEXITED(status: ::c_int) -> bool { (status & 0x7f) == 0 } pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { status >> 8 } pub fn WTERMSIG(status: ::c_int) -> ::c_int { status & 0o177 } } extern { pub fn setgroups(ngroups: ::c_int, ptr: *const ::gid_t) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; pub fn getnameinfo(sa: *const ::sockaddr, salen: ::socklen_t, host: *mut ::c_char, hostlen: ::socklen_t, serv: *mut ::c_char, sevlen: ::socklen_t, flags: ::c_int) -> ::c_int; pub fn kqueue() -> ::c_int; pub fn unmount(target: *const ::c_char, arg: ::c_int) -> ::c_int; pub fn syscall(num: ::c_int, ...) -> ::c_int; } cfg_if! { if #[cfg(any(target_os = "macos", target_os = "ios"))] { mod apple; pub use self::apple::*; } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd", target_os = "bitrig"))] { mod openbsdlike; pub use self::openbsdlike::*; } else if #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] { mod freebsdlike; pub use self::freebsdlike::*; } else { // ... } } deps/libc-0.2.4/src/dox.rs0000664000175000017500000000543612634314567012255 0ustar pub use self::imp::*; #[cfg(not(dox))] mod imp { pub use core::option::Option; pub use core::clone::Clone; pub use core::marker::Copy; pub use core::mem; } #[cfg(dox)] mod imp { pub enum Option { Some(T), None, } impl Copy for Option {} impl Clone for Option { fn clone(&self) -> Option { loop {} } } pub trait Clone { fn clone(&self) -> Self; } #[lang = "copy"] pub trait Copy {} #[lang = "sync"] pub trait Sync {} impl Sync for T {} #[lang = "sized"] pub trait Sized {} macro_rules! each_int { ($mac:ident) => ( $mac!(u8); $mac!(u16); $mac!(u32); $mac!(u64); $mac!(usize); $mac!(i8); $mac!(i16); $mac!(i32); $mac!(i64); $mac!(isize); ) } #[lang = "div"] pub trait Div { type Output; fn div(self, rhs: RHS) -> Self::Output; } macro_rules! impl_div { ($($i:ident)*) => ($( impl Div<$i> for $i { type Output = $i; fn div(self, rhs: $i) -> $i { self / rhs } } )*) } each_int!(impl_div); #[lang = "shl"] pub trait Shl { type Output; fn shl(self, rhs: RHS) -> Self::Output; } macro_rules! impl_shl { ($($i:ident)*) => ($( impl Shl<$i> for $i { type Output = $i; fn shl(self, rhs: $i) -> $i { self << rhs } } )*) } each_int!(impl_shl); #[lang = "mul"] pub trait Mul { type Output; fn mul(self, rhs: RHS) -> Self::Output; } macro_rules! impl_mul { ($($i:ident)*) => ($( impl Mul for $i { type Output = $i; fn mul(self, rhs: $i) -> $i { self * rhs } } )*) } each_int!(impl_mul); #[lang = "sub"] pub trait Sub { type Output; fn sub(self, rhs: RHS) -> Self::Output; } macro_rules! impl_sub { ($($i:ident)*) => ($( impl Sub for $i { type Output = $i; fn sub(self, rhs: $i) -> $i { self - rhs } } )*) } each_int!(impl_sub); #[lang = "bitor"] pub trait Bitor { type Output; fn bitor(self, rhs: RHS) -> Self::Output; } macro_rules! impl_bitor { ($($i:ident)*) => ($( impl Bitor for $i { type Output = $i; fn bitor(self, rhs: $i) -> $i { self | rhs } } )*) } each_int!(impl_bitor); pub mod mem { pub fn size_of_val(_: &T) -> usize { 4 } } } deps/libc-0.2.4/appveyor.yml0000664000175000017500000000123012614241040012661 0ustar environment: matrix: - TARGET: x86_64-pc-windows-gnu MSYS2_BITS: 64 - TARGET: i686-pc-windows-gnu MSYS2_BITS: 32 - TARGET: x86_64-pc-windows-msvc - TARGET: i686-pc-windows-msvc install: - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin - if defined MSYS2_BITS set PATH=%PATH%;C:\msys64\mingw%MSYS2_BITS%\bin - rustc -V - cargo -V build: false test_script: - cargo test - cargo run --manifest-path libc-test/Cargo.toml branches: only: - master deps/libc-0.2.4/Cargo.toml0000664000175000017500000000066312634630020012234 0ustar [package] name = "libc" version = "0.2.4" authors = ["The Rust Project Developers"] license = "MIT/Apache-2.0" readme = "README.md" repository = "https://github.com/rust-lang/libc" homepage = "https://github.com/rust-lang/libc" documentation = "http://doc.rust-lang.org/libc" description = """ A library for types and bindings to native C functions often found in libc or other common platform libraries. """ [features] default = [] deps/bitflags-0.1.1/0000755000000000000000000000000012666635521012751 5ustar rootrootdeps/bitflags-0.1.1/LICENSE-APACHE0000664000175000017500000002513712455675200013123 0ustar Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/bitflags-0.1.1/LICENSE-MIT0000664000175000017500000000205712455675200012627 0ustar Copyright (c) 2014 The Rust Project Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/bitflags-0.1.1/.travis.yml0000664000175000017500000000126612455675622013315 0ustar language: rust sudo: false script: - cargo build --verbose - cargo test --verbose - cargo doc after_success: | [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && echo '' > target/doc/index.html && pip install ghp-import --user $USER && $HOME/.local/bin/ghp-import -n target/doc && git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages env: global: secure: d+l63TtlF6cfFVDGauYRexgx4lBww4ORqqK4Vt75nWbiCbjZYsKXbcTUdhAr193nIVGiNW50A8SekM01F3EngHwHwr6u5kFleOggm+HA0kkBVeX+k2A4WCVVfYI+gth+zk99WaF8h46MA0evhx6FYDoqeyl9oqmVifI4kaqhMwc= notifications: email: on_success: never deps/bitflags-0.1.1/README.md0000664000175000017500000000065712455675252012465 0ustar bitflags ======== A Rust macro to generate structures which behave like a set of bitflags [![Build Status](https://travis-ci.org/rust-lang/bitflags.svg?branch=master)](https://travis-ci.org/rust-lang/bitflags) [Documentation](http://doc.rust-lang.org/bitflags) ## Usage Add this to your `Cargo.toml`: ```toml [dependencies] bitflags = "0.1" ``` and this to your crate root: ```rust #[macro_use] extern crate bitflags; ``` deps/bitflags-0.1.1/.gitignore0000600000175000017500000000002412455675150013145 0ustar /target /Cargo.lock deps/bitflags-0.1.1/src/0000755000000000000000000000000012666635521013540 5ustar rootrootdeps/bitflags-0.1.1/src/lib.rs0000664000175000017500000003467512466166271013116 0ustar // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! A typesafe bitmask flag generator. #![cfg_attr(test, feature(hash))] /// The `bitflags!` macro generates a `struct` that holds a set of C-style /// bitmask flags. It is useful for creating typesafe wrappers for C APIs. /// /// The flags should only be defined for integer types, otherwise unexpected /// type errors may occur at compile time. /// /// # Example /// /// ```{.rust} /// #[macro_use] /// extern crate bitflags; /// /// bitflags! { /// flags Flags: u32 { /// const FLAG_A = 0b00000001, /// const FLAG_B = 0b00000010, /// const FLAG_C = 0b00000100, /// const FLAG_ABC = FLAG_A.bits /// | FLAG_B.bits /// | FLAG_C.bits, /// } /// } /// /// fn main() { /// let e1 = FLAG_A | FLAG_C; /// let e2 = FLAG_B | FLAG_C; /// assert!((e1 | e2) == FLAG_ABC); // union /// assert!((e1 & e2) == FLAG_C); // intersection /// assert!((e1 - e2) == FLAG_A); // set difference /// assert!(!e2 == FLAG_A); // set complement /// } /// ``` /// /// The generated `struct`s can also be extended with type and trait implementations: /// /// ```{.rust} /// #[macro_use] /// extern crate bitflags; /// /// use std::fmt; /// /// bitflags! { /// flags Flags: u32 { /// const FLAG_A = 0b00000001, /// const FLAG_B = 0b00000010, /// } /// } /// /// impl Flags { /// pub fn clear(&mut self) { /// self.bits = 0; // The `bits` field can be accessed from within the /// // same module where the `bitflags!` macro was invoked. /// } /// } /// /// impl fmt::Show for Flags { /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { /// write!(f, "hi!") /// } /// } /// /// fn main() { /// let mut flags = FLAG_A | FLAG_B; /// flags.clear(); /// assert!(flags.is_empty()); /// assert_eq!(format!("{:?}", flags).as_slice(), "hi!"); /// } /// ``` /// /// # Attributes /// /// Attributes can be attached to the generated `struct` by placing them /// before the `flags` keyword. /// /// # Derived traits /// /// The `PartialEq` and `Clone` traits are automatically derived for the `struct` using /// the `deriving` attribute. Additional traits can be derived by providing an /// explicit `deriving` attribute on `flags`. /// /// # Operators /// /// The following operator traits are implemented for the generated `struct`: /// /// - `BitOr`: union /// - `BitAnd`: intersection /// - `BitXor`: toggle /// - `Sub`: set difference /// - `Not`: set complement /// /// # Methods /// /// The following methods are defined for the generated `struct`: /// /// - `empty`: an empty set of flags /// - `all`: the set of all flags /// - `bits`: the raw value of the flags currently stored /// - `from_bits`: convert from underlying bit representation, unless that /// representation contains bits that do not correspond to a flag /// - `from_bits_truncate`: convert from underlying bit representation, dropping /// any bits that do not correspond to flags /// - `is_empty`: `true` if no flags are currently stored /// - `is_all`: `true` if all flags are currently set /// - `intersects`: `true` if there are flags common to both `self` and `other` /// - `contains`: `true` all of the flags in `other` are contained within `self` /// - `insert`: inserts the specified flags in-place /// - `remove`: removes the specified flags in-place /// - `toggle`: the specified flags will be inserted if not present, and removed /// if they are. #[macro_export] macro_rules! bitflags { ($(#[$attr:meta])* flags $BitFlags:ident: $T:ty { $($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr),+ }) => { #[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)] $(#[$attr])* pub struct $BitFlags { bits: $T, } $($(#[$Flag_attr])* pub const $Flag: $BitFlags = $BitFlags { bits: $value };)+ impl $BitFlags { /// Returns an empty set of flags. #[inline] pub fn empty() -> $BitFlags { $BitFlags { bits: 0 } } /// Returns the set containing all flags. #[inline] pub fn all() -> $BitFlags { $BitFlags { bits: $($value)|+ } } /// Returns the raw value of the flags currently stored. #[inline] pub fn bits(&self) -> $T { self.bits } /// Convert from underlying bit representation, unless that /// representation contains bits that do not correspond to a flag. #[inline] pub fn from_bits(bits: $T) -> ::std::option::Option<$BitFlags> { if (bits & !$BitFlags::all().bits()) != 0 { ::std::option::Option::None } else { ::std::option::Option::Some($BitFlags { bits: bits }) } } /// Convert from underlying bit representation, dropping any bits /// that do not correspond to flags. #[inline] pub fn from_bits_truncate(bits: $T) -> $BitFlags { $BitFlags { bits: bits } & $BitFlags::all() } /// Returns `true` if no flags are currently stored. #[inline] pub fn is_empty(&self) -> bool { *self == $BitFlags::empty() } /// Returns `true` if all flags are currently set. #[inline] pub fn is_all(&self) -> bool { *self == $BitFlags::all() } /// Returns `true` if there are flags common to both `self` and `other`. #[inline] pub fn intersects(&self, other: $BitFlags) -> bool { !(*self & other).is_empty() } /// Returns `true` all of the flags in `other` are contained within `self`. #[inline] pub fn contains(&self, other: $BitFlags) -> bool { (*self & other) == other } /// Inserts the specified flags in-place. #[inline] pub fn insert(&mut self, other: $BitFlags) { self.bits |= other.bits; } /// Removes the specified flags in-place. #[inline] pub fn remove(&mut self, other: $BitFlags) { self.bits &= !other.bits; } /// Toggles the specified flags in-place. #[inline] pub fn toggle(&mut self, other: $BitFlags) { self.bits ^= other.bits; } } impl ::std::ops::BitOr for $BitFlags { type Output = $BitFlags; /// Returns the union of the two sets of flags. #[inline] fn bitor(self, other: $BitFlags) -> $BitFlags { $BitFlags { bits: self.bits | other.bits } } } impl ::std::ops::BitXor for $BitFlags { type Output = $BitFlags; /// Returns the left flags, but with all the right flags toggled. #[inline] fn bitxor(self, other: $BitFlags) -> $BitFlags { $BitFlags { bits: self.bits ^ other.bits } } } impl ::std::ops::BitAnd for $BitFlags { type Output = $BitFlags; /// Returns the intersection between the two sets of flags. #[inline] fn bitand(self, other: $BitFlags) -> $BitFlags { $BitFlags { bits: self.bits & other.bits } } } impl ::std::ops::Sub for $BitFlags { type Output = $BitFlags; /// Returns the set difference of the two sets of flags. #[inline] fn sub(self, other: $BitFlags) -> $BitFlags { $BitFlags { bits: self.bits & !other.bits } } } impl ::std::ops::Not for $BitFlags { type Output = $BitFlags; /// Returns the complement of this set of flags. #[inline] fn not(self) -> $BitFlags { $BitFlags { bits: !self.bits } & $BitFlags::all() } } }; ($(#[$attr:meta])* flags $BitFlags:ident: $T:ty { $($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr),+, }) => { bitflags! { $(#[$attr])* flags $BitFlags: $T { $($(#[$Flag_attr])* const $Flag = $value),+ } } }; } #[cfg(test)] #[allow(non_upper_case_globals)] mod tests { use std::prelude::v1::*; use std::hash::{self, SipHasher}; bitflags! { #[doc = "> The first principle is that you must not fool yourself — and"] #[doc = "> you are the easiest person to fool."] #[doc = "> "] #[doc = "> - Richard Feynman"] flags Flags: u32 { const FlagA = 0b00000001, #[doc = " macros are way better at generating code than trans is"] const FlagB = 0b00000010, const FlagC = 0b00000100, #[doc = "* cmr bed"] #[doc = "* strcat table"] #[doc = " wait what?"] const FlagABC = FlagA.bits | FlagB.bits | FlagC.bits, } } bitflags! { flags AnotherSetOfFlags: i8 { const AnotherFlag = -1_i8, } } #[test] fn test_bits(){ assert_eq!(Flags::empty().bits(), 0b00000000); assert_eq!(FlagA.bits(), 0b00000001); assert_eq!(FlagABC.bits(), 0b00000111); assert_eq!(AnotherSetOfFlags::empty().bits(), 0b00); assert_eq!(AnotherFlag.bits(), !0_i8); } #[test] fn test_from_bits() { assert!(Flags::from_bits(0) == Some(Flags::empty())); assert!(Flags::from_bits(0b1) == Some(FlagA)); assert!(Flags::from_bits(0b10) == Some(FlagB)); assert!(Flags::from_bits(0b11) == Some(FlagA | FlagB)); assert!(Flags::from_bits(0b1000) == None); assert!(AnotherSetOfFlags::from_bits(!0_i8) == Some(AnotherFlag)); } #[test] fn test_from_bits_truncate() { assert!(Flags::from_bits_truncate(0) == Flags::empty()); assert!(Flags::from_bits_truncate(0b1) == FlagA); assert!(Flags::from_bits_truncate(0b10) == FlagB); assert!(Flags::from_bits_truncate(0b11) == (FlagA | FlagB)); assert!(Flags::from_bits_truncate(0b1000) == Flags::empty()); assert!(Flags::from_bits_truncate(0b1001) == FlagA); assert!(AnotherSetOfFlags::from_bits_truncate(0_i8) == AnotherSetOfFlags::empty()); } #[test] fn test_is_empty(){ assert!(Flags::empty().is_empty()); assert!(!FlagA.is_empty()); assert!(!FlagABC.is_empty()); assert!(!AnotherFlag.is_empty()); } #[test] fn test_is_all() { assert!(Flags::all().is_all()); assert!(!FlagA.is_all()); assert!(FlagABC.is_all()); assert!(AnotherFlag.is_all()); } #[test] fn test_two_empties_do_not_intersect() { let e1 = Flags::empty(); let e2 = Flags::empty(); assert!(!e1.intersects(e2)); assert!(AnotherFlag.intersects(AnotherFlag)); } #[test] fn test_empty_does_not_intersect_with_full() { let e1 = Flags::empty(); let e2 = FlagABC; assert!(!e1.intersects(e2)); } #[test] fn test_disjoint_intersects() { let e1 = FlagA; let e2 = FlagB; assert!(!e1.intersects(e2)); } #[test] fn test_overlapping_intersects() { let e1 = FlagA; let e2 = FlagA | FlagB; assert!(e1.intersects(e2)); } #[test] fn test_contains() { let e1 = FlagA; let e2 = FlagA | FlagB; assert!(!e1.contains(e2)); assert!(e2.contains(e1)); assert!(FlagABC.contains(e2)); assert!(AnotherFlag.contains(AnotherFlag)); } #[test] fn test_insert(){ let mut e1 = FlagA; let e2 = FlagA | FlagB; e1.insert(e2); assert!(e1 == e2); let mut e3 = AnotherSetOfFlags::empty(); e3.insert(AnotherFlag); assert!(e3 == AnotherFlag); } #[test] fn test_remove(){ let mut e1 = FlagA | FlagB; let e2 = FlagA | FlagC; e1.remove(e2); assert!(e1 == FlagB); let mut e3 = AnotherFlag; e3.remove(AnotherFlag); assert!(e3 == AnotherSetOfFlags::empty()); } #[test] fn test_operators() { let e1 = FlagA | FlagC; let e2 = FlagB | FlagC; assert!((e1 | e2) == FlagABC); // union assert!((e1 & e2) == FlagC); // intersection assert!((e1 - e2) == FlagA); // set difference assert!(!e2 == FlagA); // set complement assert!(e1 ^ e2 == FlagA | FlagB); // toggle let mut e3 = e1; e3.toggle(e2); assert!(e3 == FlagA | FlagB); let mut m4 = AnotherSetOfFlags::empty(); m4.toggle(AnotherSetOfFlags::empty()); assert!(m4 == AnotherSetOfFlags::empty()); } #[test] fn test_lt() { let mut a = Flags::empty(); let mut b = Flags::empty(); assert!(!(a < b) && !(b < a)); b = FlagB; assert!(a < b); a = FlagC; assert!(!(a < b) && b < a); b = FlagC | FlagB; assert!(a < b); } #[test] fn test_ord() { let mut a = Flags::empty(); let mut b = Flags::empty(); assert!(a <= b && a >= b); a = FlagA; assert!(a > b && a >= b); assert!(b < a && b <= a); b = FlagB; assert!(b > a && b >= a); assert!(a < b && a <= b); } #[test] fn test_hash() { let mut x = Flags::empty(); let mut y = Flags::empty(); assert!(hash::hash::(&x) == hash::hash::(&y)); x = Flags::all(); y = FlagABC; assert!(hash::hash::(&x) == hash::hash::(&y)); } } deps/bitflags-0.1.1/Cargo.toml0000600000175000017500000000056612466166337013124 0ustar [package] name = "bitflags" version = "0.1.1" authors = ["The Rust Project Developers"] license = "MIT/Apache-2.0" readme = "README.md" repository = "https://github.com/rust-lang/bitflags" homepage = "https://github.com/rust-lang/bitflags" documentation = "http://doc.rust-lang.org/bitflags" description = """ A macro to generate structures which behave like bitflags. """ deps/git2-0.3.3/0000755000000000000000000000000012666635520012026 5ustar rootrootdeps/git2-0.3.3/LICENSE-APACHE0000664000175000017500000002513712425264744012205 0ustar Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/git2-0.3.3/LICENSE-MIT0000664000175000017500000000204112425264746011704 0ustar Copyright (c) 2014 Alex Crichton Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/git2-0.3.3/examples/0000755000000000000000000000000012666635520013644 5ustar rootrootdeps/git2-0.3.3/examples/ls-remote.rs0000664000175000017500000000317512563210063014336 0ustar /* * libgit2 "ls-remote" example * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without any warranty. * * You should have received a copy of the CC0 Public Domain Dedication along * with this software. If not, see * . */ #![deny(warnings)] extern crate git2; extern crate docopt; extern crate rustc_serialize; use docopt::Docopt; use git2::{Repository, Direction}; #[derive(RustcDecodable)] struct Args { arg_remote: String, } fn run(args: &Args) -> Result<(), git2::Error> { let repo = try!(Repository::open(".")); let remote = &args.arg_remote; let mut remote = try!(repo.find_remote(remote).or_else(|_| { repo.remote_anonymous(remote) })); // Connect to the remote and call the printing function for each of the // remote references. try!(remote.connect(Direction::Fetch)); // Get the list of references on the remote and print out their name next to // what they point to. for head in try!(remote.list()).iter() { println!("{}\t{}", head.oid(), head.name()); } Ok(()) } fn main() { const USAGE: &'static str = " usage: ls-remote [option] Options: -h, --help show this message "; let args = Docopt::new(USAGE).and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(&args) { Ok(()) => {} Err(e) => println!("error: {}", e), } } deps/git2-0.3.3/examples/cat-file.rs0000664000175000017500000001010612524545205014111 0ustar /* * libgit2 "cat-file" example - shows how to print data from the ODB * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without any warranty. * * You should have received a copy of the CC0 Public Domain Dedication along * with this software. If not, see * . */ #![deny(warnings)] extern crate git2; extern crate docopt; extern crate rustc_serialize; use std::io::{self, Write}; use docopt::Docopt; use git2::{Repository, ObjectType, Blob, Commit, Signature, Tag, Tree}; #[derive(RustcDecodable)] struct Args { arg_object: String, flag_t: bool, flag_s: bool, flag_e: bool, flag_p: bool, flag_q: bool, flag_v: bool, flag_git_dir: Option, } fn run(args: &Args) -> Result<(), git2::Error> { let path = args.flag_git_dir.as_ref().map(|s| &s[..]).unwrap_or("."); let repo = try!(Repository::open(path)); let obj = try!(repo.revparse_single(&args.arg_object)); if args.flag_v && !args.flag_q { println!("{} {}\n--", obj.kind().unwrap().str(), obj.id()); } if args.flag_t { println!("{}", obj.kind().unwrap().str()); } else if args.flag_s { /* ... */ } else if args.flag_e { /* ... */ } else if args.flag_p { match obj.kind() { Some(ObjectType::Blob) => { show_blob(obj.as_blob().unwrap()); } Some(ObjectType::Commit) => { show_commit(obj.as_commit().unwrap()); } Some(ObjectType::Tag) => { show_tag(obj.as_tag().unwrap()); } Some(ObjectType::Tree) => { show_tree(obj.as_tree().unwrap()); } Some(ObjectType::Any) | None => { println!("unknown {}", obj.id()) } } } Ok(()) } fn show_blob(blob: &Blob) { io::stdout().write_all(blob.content()).unwrap(); } fn show_commit(commit: &Commit) { println!("tree {}", commit.tree_id()); for parent in commit.parent_ids() { println!("parent {}", parent); } show_sig("author", Some(commit.author())); show_sig("committer", Some(commit.committer())); if let Some(msg) = commit.message() { println!("\n{}", msg); } } fn show_tag(tag: &Tag) { println!("object {}", tag.target_id()); println!("type {}", tag.target_type().unwrap().str()); println!("tag {}", tag.name().unwrap()); show_sig("tagger", tag.tagger()); if let Some(msg) = tag.message() { println!("\n{}", msg); } } fn show_tree(tree: &Tree) { for entry in tree.iter() { println!("{:06o} {} {}\t{}", entry.filemode(), entry.kind().unwrap().str(), entry.id(), entry.name().unwrap()); } } fn show_sig(header: &str, sig: Option) { let sig = match sig { Some(s) => s, None => return }; let offset = sig.when().offset_minutes(); let (sign, offset) = if offset < 0 {('-', -offset)} else {('+', offset)}; let (hours, minutes) = (offset / 60, offset % 60); println!("{} {} {} {}{:02}{:02}", header, sig, sig.when().seconds(), sign, hours, minutes); } fn main() { const USAGE: &'static str = " usage: cat-file (-t | -s | -e | -p) [options] Options: -t show the object type -s show the object size -e suppress all output -p pretty print the contents of the object -q suppress output -v use verbose output --git-dir use the specified directory as the base directory -h, --help show this message "; let args = Docopt::new(USAGE).and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(&args) { Ok(()) => {} Err(e) => println!("error: {}", e), } } deps/git2-0.3.3/examples/log.rs0000664000175000017500000002145412524545205013216 0ustar /* * libgit2 "log" example - shows how to walk history and get commit info * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without any warranty. * * You should have received a copy of the CC0 Public Domain Dedication along * with this software. If not, see * . */ #![deny(warnings)] extern crate rustc_serialize; extern crate docopt; extern crate git2; extern crate time; use std::str; use docopt::Docopt; use git2::{Repository, Signature, Commit, ObjectType, Time, DiffOptions}; use git2::{Pathspec, Diff, Error, DiffFormat}; #[derive(RustcDecodable)] struct Args { arg_commit: Vec, arg_spec: Vec, flag_topo_order: bool, flag_date_order: bool, flag_reverse: bool, flag_author: Option, flag_committer: Option, flag_grep: Option, flag_git_dir: Option, flag_skip: Option, flag_max_count: Option, flag_merges: bool, flag_no_merges: bool, flag_no_min_parents: bool, flag_no_max_parents: bool, flag_max_parents: Option, flag_min_parents: Option, flag_patch: bool, } fn run(args: &Args) -> Result<(), Error> { let path = args.flag_git_dir.as_ref().map(|s| &s[..]).unwrap_or("."); let repo = try!(Repository::open(path)); let mut revwalk = try!(repo.revwalk()); // Prepare the revwalk based on CLI parameters let base = if args.flag_reverse {git2::SORT_REVERSE} else {git2::SORT_NONE}; revwalk.set_sorting(base | if args.flag_topo_order { git2::SORT_TOPOLOGICAL } else if args.flag_date_order { git2::SORT_TIME } else { git2::SORT_NONE }); for commit in args.arg_commit.iter() { if commit.starts_with("^") { let obj = try!(repo.revparse_single(&commit[1..])); try!(revwalk.hide(obj.id())); continue } let revspec = try!(repo.revparse(&commit)); if revspec.mode().contains(git2::REVPARSE_SINGLE) { try!(revwalk.push(revspec.from().unwrap().id())); } else { let from = revspec.from().unwrap().id(); let to = revspec.to().unwrap().id(); try!(revwalk.push(to)); if revspec.mode().contains(git2::REVPARSE_MERGE_BASE) { let base = try!(repo.merge_base(from, to)); let o = try!(repo.find_object(base, Some(ObjectType::Commit))); try!(revwalk.push(o.id())); } try!(revwalk.hide(from)); } } if args.arg_commit.len() == 0 { try!(revwalk.push_head()); } // Prepare our diff options and pathspec matcher let (mut diffopts, mut diffopts2) = (DiffOptions::new(), DiffOptions::new()); for spec in args.arg_spec.iter() { diffopts.pathspec(spec); diffopts2.pathspec(spec); } let ps = try!(Pathspec::new(args.arg_spec.iter())); // Filter our revwalk based on the CLI parameters macro_rules! filter_try { ($e:expr) => (match $e { Ok(t) => t, Err(e) => return Some(Err(e)) }) } let revwalk = revwalk.filter_map(|id| { let commit = filter_try!(repo.find_commit(id)); let parents = commit.parents().len(); if parents < args.min_parents() { return None } if let Some(n) = args.max_parents() { if parents >= n { return None } } if args.arg_spec.len() > 0 { match commit.parents().len() { 0 => { let tree = filter_try!(commit.tree()); let flags = git2::PATHSPEC_NO_MATCH_ERROR; if ps.match_tree(&tree, flags).is_err() { return None } } _ => { let m = commit.parents().all(|parent| { match_with_parent(&repo, &commit, &parent, &mut diffopts) .unwrap_or(false) }); if !m { return None } } } } if !sig_matches(commit.author(), &args.flag_author) { return None } if !sig_matches(commit.committer(), &args.flag_committer) { return None } if !log_message_matches(commit.message(), &args.flag_grep) { return None } Some(Ok(commit)) }).skip(args.flag_skip.unwrap_or(0)).take(args.flag_max_count.unwrap_or(!0)); // print! for commit in revwalk { let commit = try!(commit); print_commit(&commit); if !args.flag_patch || commit.parents().len() > 1 { continue } let a = if commit.parents().len() == 1 { let parent = try!(commit.parent(0)); Some(try!(parent.tree())) } else { None }; let b = try!(commit.tree()); let diff = try!(Diff::tree_to_tree(&repo, a.as_ref(), Some(&b), Some(&mut diffopts2))); try!(diff.print(DiffFormat::Patch, |_delta, _hunk, line| { match line.origin() { ' ' | '+' | '-' => print!("{}", line.origin()), _ => {} } print!("{}", str::from_utf8(line.content()).unwrap()); true })); } Ok(()) } fn sig_matches(sig: Signature, arg: &Option) -> bool { match *arg { Some(ref s) => { sig.name().map(|n| n.contains(s)).unwrap_or(false) || sig.email().map(|n| n.contains(s)).unwrap_or(false) } None => true } } fn log_message_matches(msg: Option<&str>, grep: &Option) -> bool { match (grep, msg) { (&None, _) => true, (&Some(_), None) => false, (&Some(ref s), Some(msg)) => msg.contains(s), } } fn print_commit(commit: &Commit) { println!("commit {}", commit.id()); if commit.parents().len() > 1 { print!("Merge:"); for id in commit.parent_ids() { print!(" {:.8}", id); } println!(""); } let author = commit.author(); println!("Author: {}", author); print_time(&author.when(), "Date: "); println!(""); for line in String::from_utf8_lossy(commit.message_bytes()).lines() { println!(" {}", line); } println!(""); } fn print_time(time: &Time, prefix: &str) { let (offset, sign) = match time.offset_minutes() { n if n < 0 => (-n, '-'), n => (n, '+'), }; let (hours, minutes) = (offset / 60, offset % 60); let ts = time::Timespec::new(time.seconds() + (time.offset_minutes() as i64) * 60, 0); let time = time::at(ts); println!("{}{} {}{:02}{:02}", prefix, time.strftime("%a %b %e %T %Y").unwrap(), sign, hours, minutes); } fn match_with_parent(repo: &Repository, commit: &Commit, parent: &Commit, opts: &mut DiffOptions) -> Result { let a = try!(parent.tree()); let b = try!(commit.tree()); let diff = try!(Diff::tree_to_tree(repo, Some(&a), Some(&b), Some(opts))); Ok(diff.deltas().len() > 0) } impl Args { fn min_parents(&self) -> usize { if self.flag_no_min_parents { return 0 } self.flag_min_parents.unwrap_or(if self.flag_merges {2} else {0}) } fn max_parents(&self) -> Option { if self.flag_no_max_parents { return None } self.flag_max_parents.or(if self.flag_no_merges {Some(1)} else {None}) } } fn main() { const USAGE: &'static str = " usage: log [options] [..] [--] [..] Options: --topo-order sort commits in topological order --date-order sort commits in date order --reverse sort commits in reverse --author author to sort by --committer committer to sort by --grep pattern to filter commit messages by --git-dir alternative git directory to use --skip number of commits to skip -n, --max-count maximum number of commits to show --merges only show merge commits --no-merges don't show merge commits --no-min-parents don't require a minimum number of parents --no-max-parents don't require a maximum number of parents --max-parents specify a maximum number of parents for a commit --min-parents specify a minimum number of parents for a commit -p, --patch show commit diff -h, --help show this message "; let args = Docopt::new(USAGE).and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(&args) { Ok(()) => {} Err(e) => println!("error: {}", e), } } deps/git2-0.3.3/examples/diff.rs0000664000175000017500000002464412517471774013364 0ustar /* * libgit2 "diff" example - shows how to use the diff API * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without any warranty. * * You should have received a copy of the CC0 Public Domain Dedication along * with this software. If not, see * . */ #![deny(warnings)] extern crate git2; extern crate docopt; extern crate rustc_serialize; use std::str; use docopt::Docopt; use git2::{Repository, Error, Object, ObjectType, DiffOptions, Diff}; use git2::{DiffFindOptions, DiffFormat}; #[derive(RustcDecodable)] #[allow(non_snake_case)] struct Args { arg_from_oid: Option, arg_to_oid: Option, flag_patch: bool, flag_cached: bool, flag_nocached: bool, flag_name_only: bool, flag_name_status: bool, flag_raw: bool, flag_format: Option, flag_color: bool, flag_no_color: bool, flag_R: bool, flag_text: bool, flag_ignore_space_at_eol: bool, flag_ignore_space_change: bool, flag_ignore_all_space: bool, flag_ignored: bool, flag_untracked: bool, flag_patience: bool, flag_minimal: bool, flag_stat: bool, flag_numstat: bool, flag_shortstat: bool, flag_summary: bool, flag_find_renames: Option, flag_find_copies: Option, flag_find_copies_harder: bool, flag_break_rewrites: bool, flag_unified: Option, flag_inter_hunk_context: Option, flag_abbrev: Option, flag_src_prefix: Option, flag_dst_prefix: Option, flag_git_dir: Option, } const RESET: &'static str = "\u{1b}[m"; const BOLD: &'static str = "\u{1b}[1m"; const RED: &'static str = "\u{1b}[31m"; const GREEN: &'static str = "\u{1b}[32m"; const CYAN: &'static str = "\u{1b}[36m"; #[derive(PartialEq, Eq, Copy, Clone)] enum Cache { Normal, Only, None } fn run(args: &Args) -> Result<(), Error> { let path = args.flag_git_dir.as_ref().map(|s| &s[..]).unwrap_or("."); let repo = try!(Repository::open(path)); // Prepare our diff options based on the arguments given let mut opts = DiffOptions::new(); opts.reverse(args.flag_R) .force_text(args.flag_text) .ignore_whitespace_eol(args.flag_ignore_space_at_eol) .ignore_whitespace_change(args.flag_ignore_space_change) .ignore_whitespace(args.flag_ignore_all_space) .include_ignored(args.flag_ignored) .include_untracked(args.flag_untracked) .patience(args.flag_patience) .minimal(args.flag_minimal); if let Some(amt) = args.flag_unified { opts.context_lines(amt); } if let Some(amt) = args.flag_inter_hunk_context { opts.interhunk_lines(amt); } if let Some(amt) = args.flag_abbrev { opts.id_abbrev(amt); } if let Some(ref s) = args.flag_src_prefix { opts.old_prefix(&s); } if let Some(ref s) = args.flag_dst_prefix { opts.new_prefix(&s); } if let Some("diff-index") = args.flag_format.as_ref().map(|s| &s[..]) { opts.id_abbrev(40); } // Prepare the diff to inspect let t1 = try!(tree_to_treeish(&repo, args.arg_from_oid.as_ref())); let t2 = try!(tree_to_treeish(&repo, args.arg_to_oid.as_ref())); let head = try!(tree_to_treeish(&repo, Some(&"HEAD".to_string()))).unwrap(); let mut diff = match (t1, t2, args.cache()) { (Some(t1), Some(t2), _) => { try!(Diff::tree_to_tree(&repo, t1.as_tree(), t2.as_tree(), Some(&mut opts))) } (t1, None, Cache::None) => { let t1 = t1.unwrap_or(head); try!(Diff::tree_to_workdir(&repo, t1.as_tree(), Some(&mut opts))) } (t1, None, Cache::Only) => { let t1 = t1.unwrap_or(head); try!(Diff::tree_to_index(&repo, t1.as_tree(), None, Some(&mut opts))) } (Some(t1), None, _) => { try!(Diff::tree_to_workdir_with_index(&repo, t1.as_tree(), Some(&mut opts))) } (None, None, _) => { try!(Diff::index_to_workdir(&repo, None, Some(&mut opts))) } (None, Some(_), _) => unreachable!(), }; // Apply rename and copy detection if requested if args.flag_break_rewrites || args.flag_find_copies_harder || args.flag_find_renames.is_some() || args.flag_find_copies.is_some() { let mut opts = DiffFindOptions::new(); if let Some(t) = args.flag_find_renames { opts.rename_threshold(t); opts.renames(true); } if let Some(t) = args.flag_find_copies { opts.copy_threshold(t); opts.copies(true); } opts.copies_from_unmodified(args.flag_find_copies_harder) .rewrites(args.flag_break_rewrites); try!(diff.find_similar(Some(&mut opts))); } // Generate simple output let stats = args.flag_stat | args.flag_numstat | args.flag_shortstat | args.flag_summary; if stats { try!(print_stats(&diff, args)); } if args.flag_patch || !stats { if args.color() { print!("{}", RESET); } let mut last_color = None; try!(diff.print(args.diff_format(), |_delta, _hunk, line| { if args.color() { let next = match line.origin() { '+' => Some(GREEN), '-' => Some(RED), '>' => Some(GREEN), '<' => Some(RED), 'F' => Some(BOLD), 'H' => Some(CYAN), _ => None }; if args.color() && next != last_color { if last_color == Some(BOLD) || next == Some(BOLD) { print!("{}", RESET); } print!("{}", next.unwrap_or(RESET)); last_color = next; } } match line.origin() { '+' | '-' | ' ' => print!("{}", line.origin()), _ => {} } print!("{}", str::from_utf8(line.content()).unwrap()); true })); if args.color() { print!("{}", RESET); } } Ok(()) } fn print_stats(diff: &Diff, args: &Args) -> Result<(), Error> { let stats = try!(diff.stats()); let mut format = git2::DIFF_STATS_NONE; if args.flag_stat { format = format | git2::DIFF_STATS_FULL; } if args.flag_shortstat { format = format | git2::DIFF_STATS_SHORT; } if args.flag_numstat { format = format | git2::DIFF_STATS_NUMBER; } if args.flag_summary { format = format | git2::DIFF_STATS_INCLUDE_SUMMARY; } let buf = try!(stats.to_buf(format, 80)); print!("{}", str::from_utf8(&*buf).unwrap()); Ok(()) } fn tree_to_treeish<'a>(repo: &'a Repository, arg: Option<&String>) -> Result>, Error> { let arg = match arg { Some(s) => s, None => return Ok(None) }; let obj = try!(repo.revparse_single(arg)); let tree = try!(obj.peel(ObjectType::Tree)); Ok(Some(tree)) } impl Args { fn cache(&self) -> Cache { if self.flag_cached {Cache::Only} else if self.flag_nocached {Cache::None} else {Cache::Normal} } fn color(&self) -> bool { self.flag_color && !self.flag_no_color } fn diff_format(&self) -> DiffFormat { if self.flag_patch {DiffFormat::Patch} else if self.flag_name_only {DiffFormat::NameOnly} else if self.flag_name_status {DiffFormat::NameStatus} else if self.flag_raw {DiffFormat::Raw} else { match self.flag_format.as_ref().map(|s| &s[..]) { Some("name") => DiffFormat::NameOnly, Some("name-status") => DiffFormat::NameStatus, Some("raw") => DiffFormat::Raw, Some("diff-index") => DiffFormat::Raw, _ => DiffFormat::Patch, } } } } fn main() { const USAGE: &'static str = " usage: diff [options] [ []] Options: -p, --patch show output in patch format --cached use staged changes as diff --nocached do not use staged changes --name-only show only names of changed files --name-status show only names and status changes --raw generate the raw format --format= specify format for stat summary --color use color output --no-color never use color output -R swap two inputs -a, --text treat all files as text --ignore-space-at-eol ignore changes in whitespace at EOL -b, --ignore-space-change ignore changes in amount of whitespace -w, --ignore-all-space ignore whitespace when comparing lines --ignored show ignored files as well --untracked show untracked files --patience generate diff using the patience algorithm --minimal spend extra time to find smallest diff --stat generate a diffstat --numstat similar to --stat, but more machine friendly --shortstat only output last line of --stat --summary output condensed summary of header info -M, --find-renames set threshold for findind renames (default 50) -C, --find-copies set threshold for finding copies (default 50) --find-copies-harder inspect unmodified files for sources of copies -B, --break-rewrites break complete rewrite changes into pairs -U, --unified lints of context to show --inter-hunk-context maximum lines of change between hunks --abbrev length to abbreviate commits to --src-prefix show given source prefix instead of 'a/' --dst-prefix show given destinction prefix instead of 'b/' --git-dir path to git repository to use -h, --help show this message "; let args = Docopt::new(USAGE).and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(&args) { Ok(()) => {} Err(e) => println!("error: {}", e), } } deps/git2-0.3.3/examples/tag.rs0000664000175000017500000000761512504621270013206 0ustar /* * libgit2 "tag" example - shows how to list, create and delete tags * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without any warranty. * * You should have received a copy of the CC0 Public Domain Dedication along * with this software. If not, see * . */ #![deny(warnings)] extern crate git2; extern crate docopt; extern crate rustc_serialize; use std::str; use docopt::Docopt; use git2::{Repository, Error, Tag, Commit}; #[derive(RustcDecodable)] struct Args { arg_tagname: Option, arg_object: Option, arg_pattern: Option, flag_n: Option, flag_force: bool, flag_list: bool, flag_delete: Option, flag_message: Option, } fn run(args: &Args) -> Result<(), Error> { let repo = try!(Repository::open(".")); if let Some(ref name) = args.arg_tagname { let target = args.arg_object.as_ref().map(|s| &s[..]).unwrap_or("HEAD"); let obj = try!(repo.revparse_single(target)); if let Some(ref message) = args.flag_message { let sig = try!(repo.signature()); try!(repo.tag(&name, &obj, &sig, &message, args.flag_force)); } else { try!(repo.tag_lightweight(&name, &obj, args.flag_force)); } } else if let Some(ref name) = args.flag_delete { let obj = try!(repo.revparse_single(name)); let id = try!(obj.short_id()); try!(repo.tag_delete(name)); println!("Deleted tag '{}' (was {})", name, str::from_utf8(&*id).unwrap()); } else if args.flag_list { let pattern = args.arg_pattern.as_ref().map(|s| &s[..]).unwrap_or("*"); for name in try!(repo.tag_names(Some(pattern))).iter() { let name = name.unwrap(); let obj = try!(repo.revparse_single(name)); if let Some(tag) = obj.as_tag() { print_tag(tag, args); } else if let Some(commit) = obj.as_commit() { print_commit(commit, name, args); } else { print_name(name); } } } Ok(()) } fn print_tag(tag: &Tag, args: &Args) { print!("{:<16}", tag.name().unwrap()); if args.flag_n.is_some() { print_list_lines(tag.message(), args); } else { println!(""); } } fn print_commit(commit: &Commit, name: &str, args: &Args) { print!("{:<16}", name); if args.flag_n.is_some() { print_list_lines(commit.message(), args); } else { println!(""); } } fn print_name(name: &str) { println!("{}", name); } fn print_list_lines(message: Option<&str>, args: &Args) { let message = match message { Some(s) => s, None => return }; let mut lines = message.lines().filter(|l| !l.trim().is_empty()); if let Some(first) = lines.next() { print!("{}", first); } println!(""); for line in lines.take(args.flag_n.unwrap_or(0) as usize) { print!(" {}", line); } } fn main() { const USAGE: &'static str = " usage: tag [-a] [-f] [-m ] [] tag -d tag [-n ] -l [] Options: -n specify number of lines from teh annotation to print -f, --force replace an existing tag with the given name -l, --list list tags with names matching the pattern given -d, --delete delete the tag specified -m, --message message for a new tag -h, --help show this message "; let args = Docopt::new(USAGE).and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(&args) { Ok(()) => {} Err(e) => println!("error: {}", e), } } deps/git2-0.3.3/examples/init.rs0000664000175000017500000001202312517471774013403 0ustar /* * libgit2 "init" example - shows how to initialize a new repo * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without any warranty. * * You should have received a copy of the CC0 Public Domain Dedication along * with this software. If not, see * . */ #![deny(warnings)] extern crate git2; extern crate docopt; extern crate rustc_serialize; use docopt::Docopt; use git2::{Repository, RepositoryInitOptions, RepositoryInitMode, Error}; use std::path::{PathBuf, Path}; #[derive(RustcDecodable)] struct Args { arg_directory: String, flag_quiet: bool, flag_bare: bool, flag_template: Option, flag_separate_git_dir: Option, flag_initial_commit: bool, flag_shared: Option, } fn run(args: &Args) -> Result<(), Error> { let mut path = PathBuf::from(&args.arg_directory); let repo = if !args.flag_bare && args.flag_template.is_none() && args.flag_shared.is_none() && args.flag_separate_git_dir.is_none() { try!(Repository::init(&path)) } else { let mut opts = RepositoryInitOptions::new(); opts.bare(args.flag_bare); if let Some(ref s) = args.flag_template { opts.template_path(Path::new(s)); } // If you specified a separate git directory, then initialize // the repository at that path and use the second path as the // working directory of the repository (with a git-link file) if let Some(ref s) = args.flag_separate_git_dir { opts.workdir_path(&path); path = PathBuf::from(s); } if let Some(ref s) = args.flag_shared { opts.mode(try!(parse_shared(&s))); } try!(Repository::init_opts(&path, &opts)) }; // Print a message to stdout like "git init" does if !args.flag_quiet { if args.flag_bare || args.flag_separate_git_dir.is_some() { path = repo.path().to_path_buf(); } else { path = repo.workdir().unwrap().to_path_buf(); } println!("Initialized empty Git repository in {}", path.display()); } if args.flag_initial_commit { try!(create_initial_commit(&repo)); println!("Created empty initial commit"); } Ok(()) } /// Unlike regular "git init", this example shows how to create an initial empty /// commit in the repository. This is the helper function that does that. fn create_initial_commit(repo: &Repository) -> Result<(), Error> { // First use the config to initialize a commit signature for the user. let sig = try!(repo.signature()); // Now let's create an empty tree for this commit let tree_id = { let mut index = try!(repo.index()); // Outside of this example, you could call index.add_path() // here to put actual files into the index. For our purposes, we'll // leave it empty for now. try!(index.write_tree()) }; let tree = try!(repo.find_tree(tree_id)); // Ready to create the initial commit. // // Normally creating a commit would involve looking up the current HEAD // commit and making that be the parent of the initial commit, but here this // is the first commit so there will be no parent. try!(repo.commit(Some("HEAD"), &sig, &sig, "Initial commit", &tree, &[])); Ok(()) } fn parse_shared(shared: &str) -> Result { match shared { "false" | "umask" => Ok(git2::REPOSITORY_INIT_SHARED_UMASK), "true" | "group" => Ok(git2::REPOSITORY_INIT_SHARED_GROUP), "all" | "world" => Ok(git2::REPOSITORY_INIT_SHARED_ALL), _ => { if shared.starts_with("0") { match u32::from_str_radix(&shared[1..], 8).ok() { Some(n) => { return Ok(RepositoryInitMode::from_bits_truncate(n)) } None => { Err(Error::from_str("invalid octal value for --shared")) } } } else { Err(Error::from_str("unknown value for --shared")) } } } } fn main() { const USAGE: &'static str = " usage: init [options] Options: -q, --quiet don't print information to stdout --bare initialize a new bare repository --template use as an initialization template --separate-git-dir use as the .git directory --initial-commit create an initial empty commit --shared permissions to create the repository with "; let args = Docopt::new(USAGE).and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(&args) { Ok(()) => {} Err(e) => println!("error: {}", e), } } deps/git2-0.3.3/examples/blame.rs0000664000175000017500000000612112531247251013505 0ustar /* * libgit2 "blame" example - shows how to use the blame API * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without any warranty. * * You should have received a copy of the CC0 Public Domain Dedication along * with this software. If not, see * . */ extern crate git2; extern crate docopt; extern crate rustc_serialize; use docopt::Docopt; use git2::{Repository, BlameOptions}; use std::path::Path; use std::io::{BufReader, BufRead}; #[derive(RustcDecodable)] #[allow(non_snake_case)] struct Args { arg_path: String, arg_spec: Option, flag_M: bool, flag_C: bool, flag_F: bool, } fn run(args: &Args) -> Result<(), git2::Error> { let repo = try!(Repository::open(".")); let path = Path::new(&args.arg_path[..]); // Prepare our blame options let mut opts = BlameOptions::new(); opts.track_copies_same_commit_moves(args.flag_M) .track_copies_same_commit_copies(args.flag_C) .first_parent(args.flag_F); let mut commit_id = "HEAD".to_string(); // Parse spec if let Some(spec) = args.arg_spec.as_ref() { let revspec = try!(repo.revparse(spec)); let (oldest, newest) = if revspec.mode().contains(git2::REVPARSE_SINGLE) { (None, revspec.from()) } else if revspec.mode().contains(git2::REVPARSE_RANGE) { (revspec.from(), revspec.to()) } else { (None, None) }; if let Some(commit) = oldest { opts.oldest_commit(commit.id()); } if let Some(commit) = newest { opts.newest_commit(commit.id()); if !commit.id().is_zero() { commit_id = format!("{}", commit.id()) } } } let spec = format!("{}:{}", commit_id, path.display()); let blame = try!(repo.blame_file(path, Some(&mut opts))); let object = try!(repo.revparse_single(&spec[..])); let blob = try!(repo.find_blob(object.id())); let reader = BufReader::new(blob.content()); for (i, line) in reader.lines().enumerate() { if let (Ok(line), Some(hunk)) = (line, blame.get_line(i+1)) { let sig = hunk.final_signature(); println!("{} {} <{}> {}", hunk.final_commit_id(), String::from_utf8_lossy(sig.name_bytes()), String::from_utf8_lossy(sig.email_bytes()), line); } } Ok(()) } fn main() { const USAGE: &'static str = " usage: blame [options] [] Options: -M find line moves within and across files -C find line copies within and across files -F follow only the first parent commits "; let args = Docopt::new(USAGE).and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(&args) { Ok(()) => {} Err(e) => println!("error: {}", e), } } deps/git2-0.3.3/examples/clone.rs0000664000175000017500000000665212563210063013532 0ustar /* * libgit2 "clone" example * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without any warranty. * * You should have received a copy of the CC0 Public Domain Dedication along * with this software. If not, see * . */ #![deny(warnings)] extern crate git2; extern crate docopt; extern crate rustc_serialize; use docopt::Docopt; use git2::build::{RepoBuilder, CheckoutBuilder}; use git2::{RemoteCallbacks, Progress, FetchOptions}; use std::cell::RefCell; use std::io::{self, Write}; use std::path::{Path, PathBuf}; #[derive(RustcDecodable)] struct Args { arg_url: String, arg_path: String, } struct State { progress: Option>, total: usize, current: usize, path: Option, newline: bool, } fn print(state: &mut State) { let stats = state.progress.as_ref().unwrap(); let network_pct = (100 * stats.received_objects()) / stats.total_objects(); let index_pct = (100 * stats.indexed_objects()) / stats.total_objects(); let co_pct = if state.total > 0 { (100 * state.current) / state.total } else { 0 }; let kbytes = stats.received_bytes() / 1024; if stats.received_objects() == stats.total_objects() && false { if !state.newline { println!(""); state.newline = true; } print!("Resolving deltas {}/{}\r", stats.indexed_deltas(), stats.total_deltas()); } else { print!("net {:3}% ({:4} kb, {:5}/{:5}) / idx {:3}% ({:5}/{:5}) \ / chk {:3}% ({:4}/{:4}) {}\r", network_pct, kbytes, stats.received_objects(), stats.total_objects(), index_pct, stats.indexed_objects(), stats.total_objects(), co_pct, state.current, state.total, state.path.as_ref().map(|s| s.to_string_lossy().into_owned()) .unwrap_or(String::new())); } io::stdout().flush().unwrap(); } fn run(args: &Args) -> Result<(), git2::Error> { let state = RefCell::new(State { progress: None, total: 0, current: 0, path: None, newline: false, }); let mut cb = RemoteCallbacks::new(); cb.transfer_progress(|stats| { let mut state = state.borrow_mut(); state.progress = Some(stats.to_owned()); print(&mut *state); true }); let mut co = CheckoutBuilder::new(); co.progress(|path, cur, total| { let mut state = state.borrow_mut(); state.path = path.map(|p| p.to_path_buf()); state.current = cur; state.total = total; print(&mut *state); }); let mut fo = FetchOptions::new(); fo.remote_callbacks(cb); try!(RepoBuilder::new().fetch_options(fo).with_checkout(co) .clone(&args.arg_url, Path::new(&args.arg_path))); println!(""); Ok(()) } fn main() { const USAGE: &'static str = " usage: add [options] Options: -h, --help show this message "; let args = Docopt::new(USAGE).and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(&args) { Ok(()) => {} Err(e) => println!("error: {}", e), } } deps/git2-0.3.3/examples/fetch.rs0000664000175000017500000001064112563210063013514 0ustar /* * libgit2 "fetch" example - shows how to fetch remote data * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without any warranty. * * You should have received a copy of the CC0 Public Domain Dedication along * with this software. If not, see * . */ #![deny(warnings)] extern crate git2; extern crate docopt; extern crate rustc_serialize; use docopt::Docopt; use git2::{Repository, RemoteCallbacks, Direction, AutotagOption, FetchOptions}; use std::io::{self, Write}; use std::str; #[derive(RustcDecodable)] struct Args { arg_remote: Option, } fn run(args: &Args) -> Result<(), git2::Error> { let repo = try!(Repository::open(".")); let remote = args.arg_remote.as_ref().map(|s| &s[..]).unwrap_or("origin"); // Figure out whether it's a named remote or a URL println!("Fetcing {} for repo", remote); let mut cb = RemoteCallbacks::new(); let mut remote = try!(repo.find_remote(remote).or_else(|_| { repo.remote_anonymous(remote) })); cb.sideband_progress(|data| { print!("remote: {}", str::from_utf8(data).unwrap()); io::stdout().flush().unwrap(); true }); // This callback gets called for each remote-tracking branch that gets // updated. The message we output depends on whether it's a new one or an // update. cb.update_tips(|refname, a, b| { if a.is_zero() { println!("[new] {:20} {}", b, refname); } else { println!("[updated] {:10}..{:10} {}", a, b, refname); } true }); // Here we show processed and total objects in the pack and the amount of // received data. Most frontends will probably want to show a percentage and // the download rate. cb.transfer_progress(|stats| { if stats.received_objects() == stats.total_objects() { print!("Resolving deltas {}/{}\r", stats.indexed_deltas(), stats.total_deltas()); } else if stats.total_objects() > 0 { print!("Received {}/{} objects ({}) in {} bytes\r", stats.received_objects(), stats.total_objects(), stats.indexed_objects(), stats.received_bytes()); } io::stdout().flush().unwrap(); true }); // Connect to the remote end specifying that we want to fetch information // from it. try!(remote.connect(Direction::Fetch)); // Download the packfile and index it. This function updates the amount of // received data and the indexer stats which lets you inform the user about // progress. let mut fo = FetchOptions::new(); fo.remote_callbacks(cb); try!(remote.download(&[], Some(&mut fo))); { // If there are local objects (we got a thin pack), then tell the user // how many objects we saved from having to cross the network. let stats = remote.stats(); if stats.local_objects() > 0 { println!("\rReceived {}/{} objects in {} bytes (used {} local \ objects)", stats.indexed_objects(), stats.total_objects(), stats.received_bytes(), stats.local_objects()); } else { println!("\rReceived {}/{} objects in {} bytes", stats.indexed_objects(), stats.total_objects(), stats.received_bytes()); } } // Disconnect the underlying connection to prevent from idling. remote.disconnect(); // Update the references in the remote's namespace to point to the right // commits. This may be needed even if there was no packfile to download, // which can happen e.g. when the branches have been changed but all the // needed objects are available locally. try!(remote.update_tips(None, true, AutotagOption::Unspecified, None)); Ok(()) } fn main() { const USAGE: &'static str = " usage: fetch [options] [] Options: -h, --help show this message "; let args = Docopt::new(USAGE).and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(&args) { Ok(()) => {} Err(e) => println!("error: {}", e), } } deps/git2-0.3.3/examples/rev-parse.rs0000664000175000017500000000364012504621254014333 0ustar /* * libgit2 "rev-parse" example - shows how to parse revspecs * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without any warranty. * * You should have received a copy of the CC0 Public Domain Dedication along * with this software. If not, see * . */ #![deny(warnings)] extern crate git2; extern crate docopt; extern crate rustc_serialize; use docopt::Docopt; use git2::Repository; #[derive(RustcDecodable)] struct Args { arg_spec: String, flag_git_dir: Option, } fn run(args: &Args) -> Result<(), git2::Error> { let path = args.flag_git_dir.as_ref().map(|s| &s[..]).unwrap_or("."); let repo = try!(Repository::open(path)); let revspec = try!(repo.revparse(&args.arg_spec)); if revspec.mode().contains(git2::REVPARSE_SINGLE) { println!("{}", revspec.from().unwrap().id()); } else if revspec.mode().contains(git2::REVPARSE_RANGE) { let to = revspec.to().unwrap(); let from = revspec.from().unwrap(); println!("{}", to.id()); if revspec.mode().contains(git2::REVPARSE_MERGE_BASE) { let base = try!(repo.merge_base(from.id(), to.id())); println!("{}", base); } println!("^{}", from.id()); } else { return Err(git2::Error::from_str("invalid results from revparse")) } Ok(()) } fn main() { const USAGE: &'static str = " usage: rev-parse [options] Options: --git-dir directory for the git repository to check "; let args = Docopt::new(USAGE).and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(&args) { Ok(()) => {} Err(e) => println!("error: {}", e), } } deps/git2-0.3.3/examples/add.rs0000664000175000017500000000422412505312621013152 0ustar /* * libgit2 "add" example - shows how to modify the index * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without any warranty. * * You should have received a copy of the CC0 Public Domain Dedication along * with this software. If not, see * . */ #![deny(warnings)] #![allow(trivial_casts)] extern crate git2; extern crate docopt; extern crate rustc_serialize; use std::path::Path; use docopt::Docopt; use git2::Repository; #[derive(RustcDecodable)] struct Args { arg_spec: Vec, flag_dry_run: bool, flag_verbose: bool, flag_update: bool, } fn run(args: &Args) -> Result<(), git2::Error> { let repo = try!(Repository::open(&Path::new("."))); let mut index = try!(repo.index()); let cb = &mut |path: &Path, _matched_spec: &[u8]| -> i32 { let status = repo.status_file(path).unwrap(); let ret = if status.contains(git2::STATUS_WT_MODIFIED) || status.contains(git2::STATUS_WT_NEW) { println!("add '{}'", path.display()); 0 } else { 1 }; if args.flag_dry_run {1} else {ret} }; let cb = if args.flag_verbose || args.flag_update { Some(cb as &mut git2::IndexMatchedPath) } else { None }; if args.flag_update { try!(index.update_all(args.arg_spec.iter(), cb)); } else { try!(index.add_all(args.arg_spec.iter(), git2::ADD_DEFAULT, cb)); } try!(index.write()); Ok(()) } fn main() { const USAGE: &'static str = " usage: add [options] [--] [..] Options: -n, --dry-run dry run -v, --verbose be verbose -u, --update update tracked files -h, --help show this message "; let args = Docopt::new(USAGE).and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(&args) { Ok(()) => {} Err(e) => println!("error: {}", e), } } deps/git2-0.3.3/examples/rev-list.rs0000664000175000017500000000542312504621334014174 0ustar /* * libgit2 "rev-list" example - shows how to transform a rev-spec into a list * of commit ids * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without any warranty. * * You should have received a copy of the CC0 Public Domain Dedication along * with this software. If not, see * . */ #![deny(warnings)] extern crate git2; extern crate docopt; extern crate rustc_serialize; use docopt::Docopt; use git2::{Repository, Error, Revwalk, Oid}; #[derive(RustcDecodable)] struct Args { arg_spec: Vec, flag_topo_order: bool, flag_date_order: bool, flag_reverse: bool, flag_not: Vec, } fn run(args: &Args) -> Result<(), git2::Error> { let repo = try!(Repository::open(".")); let mut revwalk = try!(repo.revwalk()); let base = if args.flag_reverse {git2::SORT_REVERSE} else {git2::SORT_NONE}; revwalk.set_sorting(base | if args.flag_topo_order { git2::SORT_TOPOLOGICAL } else if args.flag_date_order { git2::SORT_TIME } else { git2::SORT_NONE }); let specs = args.flag_not.iter().map(|s| (s, true)) .chain(args.arg_spec.iter().map(|s| (s, false))) .map(|(spec, hide)| { if spec.starts_with("^") {(&spec[1..], !hide)} else {(&spec[..], hide)} }); for (spec, hide) in specs { let id = if spec.contains("..") { let revspec = try!(repo.revparse(spec)); if revspec.mode().contains(git2::REVPARSE_MERGE_BASE) { return Err(Error::from_str("merge bases not implemented")) } try!(push(&mut revwalk, revspec.from().unwrap().id(), !hide)); revspec.to().unwrap().id() } else { try!(repo.revparse_single(spec)).id() }; try!(push(&mut revwalk, id, hide)); } for id in revwalk { println!("{}", id); } Ok(()) } fn push(revwalk: &mut Revwalk, id: Oid, hide: bool) -> Result<(), Error> { if hide {revwalk.hide(id)} else {revwalk.push(id)} } fn main() { const USAGE: &'static str = " usage: rev-list [options] [--] ... Options: --topo-order sort commits in topological order --date-order sort commits in date order --reverse sort commits in reverse --not don't show -h, --help show this message "; let args = Docopt::new(USAGE).and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(&args) { Ok(()) => {} Err(e) => println!("error: {}", e), } } deps/git2-0.3.3/examples/status.rs0000664000175000017500000003152312617505731013761 0ustar /* * libgit2 "status" example - shows how to use the status APIs * * Written by the libgit2 contributors * * To the extent possible under law, the author(s) have dedicated all copyright * and related and neighboring rights to this software to the public domain * worldwide. This software is distributed without any warranty. * * You should have received a copy of the CC0 Public Domain Dedication along * with this software. If not, see * . */ #![deny(warnings)] extern crate git2; extern crate docopt; extern crate rustc_serialize; use std::str; use std::time::Duration; use docopt::Docopt; use git2::{Repository, Error, StatusOptions, ErrorCode, SubmoduleIgnore}; #[derive(RustcDecodable)] struct Args { arg_spec: Vec, flag_short: bool, flag_long: bool, flag_porcelain: bool, flag_branch: bool, flag_z: bool, flag_ignored: bool, flag_untracked_files: Option, flag_ignore_submodules: Option, flag_git_dir: Option, flag_repeat: bool, flag_list_submodules: bool, } #[derive(Eq, PartialEq)] enum Format { Long, Short, Porcelain } fn run(args: &Args) -> Result<(), Error> { let path = args.flag_git_dir.clone().unwrap_or(".".to_string()); let repo = try!(Repository::open(&path)); if repo.is_bare() { return Err(Error::from_str("cannot report status on bare repository")) } let mut opts = StatusOptions::new(); opts.include_ignored(args.flag_ignored); match args.flag_untracked_files.as_ref().map(|s| &s[..]) { Some("no") => { opts.include_untracked(false); } Some("normal") => { opts.include_untracked(true); } Some("all") => { opts.include_untracked(true).recurse_untracked_dirs(true); } Some(_) => return Err(Error::from_str("invalid untracked-files value")), None => {} } match args.flag_ignore_submodules.as_ref().map(|s| &s[..]) { Some("all") => { opts.exclude_submodules(true); } Some(_) => return Err(Error::from_str("invalid ignore-submodules value")), None => {} } opts.include_untracked(!args.flag_ignored); for spec in args.arg_spec.iter() { opts.pathspec(spec); } loop { if args.flag_repeat { println!("\u{1b}[H\u{1b}[2J"); } let statuses = try!(repo.statuses(Some(&mut opts))); if args.flag_branch { try!(show_branch(&repo, args.format())); } if args.flag_list_submodules { try!(print_submodules(&repo)); } if args.format() == Format::Long { print_long(statuses); } else { print_short(&repo, statuses); } if args.flag_repeat { std::thread::sleep(Duration::new(10, 0)); } else { return Ok(()) } } } fn show_branch(repo: &Repository, format: Format) -> Result<(), Error> { let head = match repo.head() { Ok(head) => Some(head), Err(ref e) if e.code() == ErrorCode::UnbornBranch || e.code() == ErrorCode::NotFound => None, Err(e) => return Err(e), }; let head = head.as_ref().and_then(|h| h.shorthand()); if format == Format::Long { println!("# On branch {}", head.unwrap_or("Not currently on any branch")); } else { println!("## {}", head.unwrap_or("HEAD (no branch)")); } Ok(()) } fn print_submodules(repo: &Repository) -> Result<(), Error> { let modules = try!(repo.submodules()); println!("# Submodules"); for sm in modules.iter() { println!("# - submodule '{}' at {}", sm.name().unwrap(), sm.path().display()); } Ok(()) } // This function print out an output similar to git's status command in long // form, including the command-line hints. fn print_long(statuses: git2::Statuses) { let mut header = false; let mut rm_in_workdir = false; let mut changes_in_index = false; let mut changed_in_workdir = false; // Print index changes for entry in statuses.iter().filter(|e| e.status() != git2::STATUS_CURRENT) { if entry.status().contains(git2::STATUS_WT_DELETED) { rm_in_workdir = true; } let istatus = match entry.status() { s if s.contains(git2::STATUS_INDEX_NEW) => "new file: ", s if s.contains(git2::STATUS_INDEX_MODIFIED) => "modified: ", s if s.contains(git2::STATUS_INDEX_DELETED) => "deleted: ", s if s.contains(git2::STATUS_INDEX_RENAMED) => "renamed: ", s if s.contains(git2::STATUS_INDEX_TYPECHANGE) => "typechange:", _ => continue, }; if !header { println!("\ # Changes to be committed: # (use \"git reset HEAD ...\" to unstage) #"); header = true; } let old_path = entry.head_to_index().unwrap().old_file().path(); let new_path = entry.head_to_index().unwrap().new_file().path(); match (old_path, new_path) { (Some(ref old), Some(ref new)) if old != new => { println!("#\t{} {} -> {}", istatus, old.display(), new.display()); } (old, new) => { println!("#\t{} {}", istatus, old.or(new).unwrap().display()); } } } if header { changes_in_index = true; println!("#"); } header = false; // Print workdir changes to tracked files for entry in statuses.iter() { // With `STATUS_OPT_INCLUDE_UNMODIFIED` (not used in this example) // `index_to_workdir` may not be `None` even if there are no differences, // in which case it will be a `Delta::Unmodified`. if entry.status() == git2::STATUS_CURRENT || entry.index_to_workdir().is_none() { continue } let istatus = match entry.status() { s if s.contains(git2::STATUS_WT_MODIFIED) => "modified: ", s if s.contains(git2::STATUS_WT_DELETED) => "deleted: ", s if s.contains(git2::STATUS_WT_RENAMED) => "renamed: ", s if s.contains(git2::STATUS_WT_TYPECHANGE) => "typechange:", _ => continue, }; if !header { println!("\ # Changes not staged for commit: # (use \"git add{} ...\" to update what will be committed) # (use \"git checkout -- ...\" to discard changes in working directory) #\ ", if rm_in_workdir {"/rm"} else {""}); header = true; } let old_path = entry.index_to_workdir().unwrap().old_file().path(); let new_path = entry.index_to_workdir().unwrap().new_file().path(); match (old_path, new_path) { (Some(ref old), Some(ref new)) if old != new => { println!("#\t{} {} -> {}", istatus, old.display(), new.display()); } (old, new) => { println!("#\t{} {}", istatus, old.or(new).unwrap().display()); } } } if header { changed_in_workdir = true; println!("#"); } header = false; // Print untracked files for entry in statuses.iter().filter(|e| e.status() == git2::STATUS_WT_NEW) { if !header { println!("\ # Untracked files # (use \"git add ...\" to include in what will be committed) #"); header = true; } let file = entry.index_to_workdir().unwrap().old_file().path().unwrap(); println!("#\t{}", file.display()); } header = false; // Print ignored files for entry in statuses.iter().filter(|e| e.status() == git2::STATUS_IGNORED) { if !header { println!("\ # Ignored files # (use \"git add -f ...\" to include in what will be committed) #"); header = true; } let file = entry.index_to_workdir().unwrap().old_file().path().unwrap(); println!("#\t{}", file.display()); } if !changes_in_index && changed_in_workdir { println!("no changes added to commit (use \"git add\" and/or \ \"git commit -a\")"); } } // This version of the output prefixes each path with two status columns and // shows submodule status information. fn print_short(repo: &Repository, statuses: git2::Statuses) { for entry in statuses.iter().filter(|e| e.status() != git2::STATUS_CURRENT) { let mut istatus = match entry.status() { s if s.contains(git2::STATUS_INDEX_NEW) => 'A', s if s.contains(git2::STATUS_INDEX_MODIFIED) => 'M', s if s.contains(git2::STATUS_INDEX_DELETED) => 'D', s if s.contains(git2::STATUS_INDEX_RENAMED) => 'R', s if s.contains(git2::STATUS_INDEX_TYPECHANGE) => 'T', _ => ' ', }; let mut wstatus = match entry.status() { s if s.contains(git2::STATUS_WT_NEW) => { if istatus == ' ' { istatus = '?'; } '?' } s if s.contains(git2::STATUS_WT_MODIFIED) => 'M', s if s.contains(git2::STATUS_WT_DELETED) => 'D', s if s.contains(git2::STATUS_WT_RENAMED) => 'R', s if s.contains(git2::STATUS_WT_TYPECHANGE) => 'T', _ => ' ', }; if entry.status().contains(git2::STATUS_IGNORED) { istatus = '!'; wstatus = '!'; } if istatus == '?' && wstatus == '?' { continue } let mut extra = ""; // A commit in a tree is how submodules are stored, so let's go take a // look at its status. // // TODO: check for GIT_FILEMODE_COMMIT let status = entry.index_to_workdir().and_then(|diff| { let ignore = SubmoduleIgnore::Unspecified; diff.new_file().path_bytes() .and_then(|s| str::from_utf8(s).ok()) .and_then(|name| repo.submodule_status(name, ignore).ok()) }); if let Some(status) = status { if status.contains(git2::SUBMODULE_STATUS_WD_MODIFIED) { extra = " (new commits)"; } else if status.contains(git2::SUBMODULE_STATUS_WD_INDEX_MODIFIED) { extra = " (modified content)"; } else if status.contains(git2::SUBMODULE_STATUS_WD_WD_MODIFIED) { extra = " (modified content)"; } else if status.contains(git2::SUBMODULE_STATUS_WD_UNTRACKED) { extra = " (untracked content)"; } } let (mut a, mut b, mut c) = (None, None, None); if let Some(diff) = entry.head_to_index() { a = diff.old_file().path(); b = diff.new_file().path(); } if let Some(diff) = entry.index_to_workdir() { a = a.or(diff.old_file().path()); b = b.or(diff.old_file().path()); c = diff.new_file().path(); } match (istatus, wstatus) { ('R', 'R') => println!("RR {} {} {}{}", a.unwrap().display(), b.unwrap().display(), c.unwrap().display(), extra), ('R', w) => println!("R{} {} {}{}", w, a.unwrap().display(), b.unwrap().display(), extra), (i, 'R') => println!("{}R {} {}{}", i, a.unwrap().display(), c.unwrap().display(), extra), (i, w) => println!("{}{} {}{}", i, w, a.unwrap().display(), extra), } } for entry in statuses.iter().filter(|e| e.status() == git2::STATUS_WT_NEW) { println!("?? {}", entry.index_to_workdir().unwrap().old_file() .path().unwrap().display()); } } impl Args { fn format(&self) -> Format { if self.flag_short { Format::Short } else if self.flag_long { Format::Long } else if self.flag_porcelain { Format::Porcelain } else if self.flag_z { Format::Porcelain } else { Format::Long } } } fn main() { const USAGE: &'static str = " usage: status [options] [--] [..] Options: -s, --short show short statuses --long show longer statuses (default) --porcelain ?? -b, --branch show branch information -z ?? --ignored show ignored files as well --untracked-files setting for showing untracked files [no|normal|all] --ignore-submodules setting for ignoring submodules [all] --git-dir git directory to analyze --repeat repeatedly show status, sleeping inbetween --list-submodules show submodules -h, --help show this message "; let args = Docopt::new(USAGE).and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(&args) { Ok(()) => {} Err(e) => println!("error: {}", e), } } deps/git2-0.3.3/.travis.yml0000664000175000017500000000213612616441135012355 0ustar language: rust rust: - stable - beta - nightly sudo: false before_script: - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH script: - export CARGO_TARGET_DIR=`pwd`/target - cargo test --no-default-features - cargo test - cargo run --manifest-path systest/Cargo.toml - if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then cargo test --features unstable; cargo test --manifest-path git2-curl/Cargo.toml; fi - cargo doc --no-deps - cargo doc --manifest-path=git2-curl/Cargo.toml --no-deps - cargo doc --manifest-path=libgit2-sys/Cargo.toml --no-deps after_success: - travis-cargo --only nightly doc-upload - travis-cargo coveralls --no-sudo notifications: email: on_success: never os: - linux - osx addons: apt: sources: - kalakris-cmake packages: - cmake - libcurl4-openssl-dev - libelf-dev - libdw-dev env: global: secure: HlDs6Eyhy/67Wmqd6frmCnOMYQyqbv2ulL9qqqFF2zdlinJ2/Z0FDs+0GHNWu0BQ9v6+51KHbhieUaz3dTYDCKPlDiA2OmE8DQuXloxrrJfGmPLc1F+cKQGn5a5FrIrLJDkEpcfWXZItRtzSPkpVNEWGA66Osx50/Nd8lkdjFYA= deps/git2-0.3.3/README.md0000664000175000017500000000147012615706065011530 0ustar # git2-rs [![Build Status](https://travis-ci.org/alexcrichton/git2-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/git2-rs) [![Build Status](https://ci.appveyor.com/api/projects/status/6vem3xgno2kuxnfm?svg=true)](https://ci.appveyor.com/project/alexcrichton/git2-rs) [Documentation](http://alexcrichton.com/git2-rs/git2/index.html) libgit2 bindings for Rust ```toml [dependencies] git2 = "0.3" ``` ## Building git2-rs First, you'll need to install _CMake_. Afterwards, just run: ```sh $ git clone --recursive https://github.com/alexcrichton/git2-rs $ cd git2-rs $ cargo build ``` # License `git2-rs` is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses. See LICENSE-APACHE, and LICENSE-MIT for details. deps/git2-0.3.3/.gitignore0000664000175000017500000000003612462464663012243 0ustar target Cargo.lock src/main.rs deps/git2-0.3.3/src/0000755000000000000000000000000012666635520012615 5ustar rootrootdeps/git2-0.3.3/src/tree.rs0000664000175000017500000002560412617153425012350 0ustar use std::mem; use std::cmp::Ordering; use std::ffi::CString; use std::ops::Range; use std::marker; use std::path::Path; use std::str; use libc; use {raw, Oid, Repository, Error, Object, ObjectType}; use util::{Binding, IntoCString}; /// A structure to represent a git [tree][1] /// /// [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects pub struct Tree<'repo> { raw: *mut raw::git_tree, _marker: marker::PhantomData>, } /// A structure representing an entry inside of a tree. An entry is borrowed /// from a tree. pub struct TreeEntry<'tree> { raw: *mut raw::git_tree_entry, owned: bool, _marker: marker::PhantomData<&'tree raw::git_tree_entry>, } /// An iterator over the entries in a tree. pub struct TreeIter<'tree> { range: Range, tree: &'tree Tree<'tree>, } impl<'repo> Tree<'repo> { /// Get the id (SHA1) of a repository object pub fn id(&self) -> Oid { unsafe { Binding::from_raw(raw::git_tree_id(&*self.raw)) } } /// Get the number of entries listed in this tree. pub fn len(&self) -> usize { unsafe { raw::git_tree_entrycount(&*self.raw) as usize } } /// Returns an iterator over the entries in this tree. pub fn iter(&self) -> TreeIter { TreeIter { range: 0..self.len(), tree: self } } /// Lookup a tree entry by SHA value. pub fn get_id(&self, id: Oid) -> Option { unsafe { let ptr = raw::git_tree_entry_byid(&*self.raw(), &*id.raw()); if ptr.is_null() { None } else { Some(entry_from_raw_const(ptr)) } } } /// Lookup a tree entry by its position in the tree pub fn get(&self, n: usize) -> Option { unsafe { let ptr = raw::git_tree_entry_byindex(&*self.raw(), n as libc::size_t); if ptr.is_null() { None } else { Some(entry_from_raw_const(ptr)) } } } /// Lookup a tree entry by its filename pub fn get_name(&self, filename: &str) -> Option { let filename = CString::new(filename).unwrap(); unsafe { let ptr = call!(raw::git_tree_entry_byname(&*self.raw(), filename)); if ptr.is_null() { None } else { Some(entry_from_raw_const(ptr)) } } } /// Retrieve a tree entry contained in a tree or in any of its subtrees, /// given its relative path. pub fn get_path(&self, path: &Path) -> Result, Error> { let path = try!(path.into_c_string()); let mut ret = 0 as *mut raw::git_tree_entry; unsafe { try_call!(raw::git_tree_entry_bypath(&mut ret, &*self.raw(), path)); Ok(Binding::from_raw(ret)) } } /// Casts this Tree to be usable as an `Object` pub fn as_object(&self) -> &Object<'repo> { unsafe { &*(self as *const _ as *const Object<'repo>) } } } impl<'repo> Binding for Tree<'repo> { type Raw = *mut raw::git_tree; unsafe fn from_raw(raw: *mut raw::git_tree) -> Tree<'repo> { Tree { raw: raw, _marker: marker::PhantomData } } fn raw(&self) -> *mut raw::git_tree { self.raw } } impl<'repo> Drop for Tree<'repo> { fn drop(&mut self) { unsafe { raw::git_tree_free(self.raw) } } } /// Create a new tree entry from the raw pointer provided. /// /// The lifetime of the entry is tied to the tree provided and the function /// is unsafe because the validity of the pointer cannot be guaranteed. pub unsafe fn entry_from_raw_const<'tree>(raw: *const raw::git_tree_entry) -> TreeEntry<'tree> { TreeEntry { raw: raw as *mut raw::git_tree_entry, owned: false, _marker: marker::PhantomData, } } impl<'tree> TreeEntry<'tree> { /// Get the id of the object pointed by the entry pub fn id(&self) -> Oid { unsafe { Binding::from_raw(raw::git_tree_entry_id(&*self.raw)) } } /// Get the filename of a tree entry /// /// Returns `None` if the name is not valid utf-8 pub fn name(&self) -> Option<&str> { str::from_utf8(self.name_bytes()).ok() } /// Get the filename of a tree entry pub fn name_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, raw::git_tree_entry_name(&*self.raw())).unwrap() } } /// Convert a tree entry to the object it points to. pub fn to_object<'a>(&self, repo: &'a Repository) -> Result, Error> { let mut ret = 0 as *mut raw::git_object; unsafe { try_call!(raw::git_tree_entry_to_object(&mut ret, repo.raw(), &*self.raw())); Ok(Binding::from_raw(ret)) } } /// Get the type of the object pointed by the entry pub fn kind(&self) -> Option { ObjectType::from_raw(unsafe { raw::git_tree_entry_type(&*self.raw) }) } /// Get the UNIX file attributes of a tree entry pub fn filemode(&self) -> i32 { unsafe { raw::git_tree_entry_filemode(&*self.raw) as i32 } } /// Get the raw UNIX file attributes of a tree entry pub fn filemode_raw(&self) -> i32 { unsafe { raw::git_tree_entry_filemode_raw(&*self.raw) as i32 } } /// Convert this entry of any lifetime into an owned signature with a static /// lifetime. /// /// This will use the `Clone::clone` implementation under the hood. pub fn to_owned(&self) -> TreeEntry<'static> { unsafe { let me = mem::transmute::<&TreeEntry<'tree>, &TreeEntry<'static>>(self); me.clone() } } } impl<'a> Binding for TreeEntry<'a> { type Raw = *mut raw::git_tree_entry; unsafe fn from_raw(raw: *mut raw::git_tree_entry) -> TreeEntry<'a> { TreeEntry { raw: raw, owned: true, _marker: marker::PhantomData, } } fn raw(&self) -> *mut raw::git_tree_entry { self.raw } } impl<'a> Clone for TreeEntry<'a> { fn clone(&self) -> TreeEntry<'a> { let mut ret = 0 as *mut raw::git_tree_entry; unsafe { assert_eq!(raw::git_tree_entry_dup(&mut ret, &*self.raw()), 0); Binding::from_raw(ret) } } } impl<'a> PartialOrd for TreeEntry<'a> { fn partial_cmp(&self, other: &TreeEntry<'a>) -> Option { Some(self.cmp(other)) } } impl<'a> Ord for TreeEntry<'a> { fn cmp(&self, other: &TreeEntry<'a>) -> Ordering { match unsafe { raw::git_tree_entry_cmp(&*self.raw(), &*other.raw()) } { 0 => Ordering::Equal, n if n < 0 => Ordering::Less, _ => Ordering::Greater, } } } impl<'a> PartialEq for TreeEntry<'a> { fn eq(&self, other: &TreeEntry<'a>) -> bool { self.cmp(other) == Ordering::Equal } } impl<'a> Eq for TreeEntry<'a> {} impl<'a> Drop for TreeEntry<'a> { fn drop(&mut self) { if self.owned { unsafe { raw::git_tree_entry_free(self.raw) } } } } impl<'tree> Iterator for TreeIter<'tree> { type Item = TreeEntry<'tree>; fn next(&mut self) -> Option> { self.range.next().and_then(|i| self.tree.get(i)) } fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } } impl<'tree> DoubleEndedIterator for TreeIter<'tree> { fn next_back(&mut self) -> Option> { self.range.next_back().and_then(|i| self.tree.get(i)) } } impl<'tree> ExactSizeIterator for TreeIter<'tree> {} #[cfg(test)] mod tests { use {Repository,Tree,TreeEntry,ObjectType,Object}; use tempdir::TempDir; use std::fs::File; use std::io::prelude::*; use std::path::Path; pub struct TestTreeIter<'a> { entries: Vec>, repo: &'a Repository, } impl<'a> Iterator for TestTreeIter<'a> { type Item = TreeEntry<'a>; fn next(&mut self) -> Option > { if self.entries.is_empty() { None } else { let entry = self.entries.remove(0); match entry.kind() { Some(ObjectType::Tree) => { let obj: Object<'a> = entry.to_object(self.repo).unwrap(); let tree: &Tree<'a> = obj.as_tree().unwrap(); for entry in tree.iter() { self.entries.push(entry.to_owned()); } } _ => {} } Some(entry) } } } fn tree_iter<'repo>(tree: &Tree<'repo>, repo: &'repo Repository) -> TestTreeIter<'repo> { let mut initial = vec![]; for entry in tree.iter() { initial.push(entry.to_owned()); } TestTreeIter { entries: initial, repo: repo, } } #[test] fn smoke_tree_iter() { let (td, repo) = ::test::repo_init(); setup_repo(&td, &repo); let head = repo.head().unwrap(); let target = head.target().unwrap(); let commit = repo.find_commit(target).unwrap(); let tree = repo.find_tree(commit.tree_id()).unwrap(); assert_eq!(tree.id(), commit.tree_id()); assert_eq!(tree.len(), 1); for entry in tree_iter(&tree, &repo) { println!("iter entry {:?}", entry.name()); } } fn setup_repo(td: &TempDir, repo: &Repository) { let mut index = repo.index().unwrap(); File::create(&td.path().join("foo")).unwrap().write_all(b"foo").unwrap(); index.add_path(Path::new("foo")).unwrap(); let id = index.write_tree().unwrap(); let sig = repo.signature().unwrap(); let tree = repo.find_tree(id).unwrap(); let parent = repo.find_commit(repo.head().unwrap().target() .unwrap()).unwrap(); repo.commit(Some("HEAD"), &sig, &sig, "another commit", &tree, &[&parent]).unwrap(); } #[test] fn smoke() { let (td, repo) = ::test::repo_init(); setup_repo(&td, &repo); let head = repo.head().unwrap(); let target = head.target().unwrap(); let commit = repo.find_commit(target).unwrap(); let tree = repo.find_tree(commit.tree_id()).unwrap(); assert_eq!(tree.id(), commit.tree_id()); assert_eq!(tree.len(), 1); let e1 = tree.get(0).unwrap(); assert!(e1 == tree.get_id(e1.id()).unwrap()); assert!(e1 == tree.get_name("foo").unwrap()); assert!(e1 == tree.get_path(Path::new("foo")).unwrap()); assert_eq!(e1.name(), Some("foo")); e1.to_object(&repo).unwrap(); repo.find_object(commit.tree_id(), None).unwrap().as_tree().unwrap(); } } deps/git2-0.3.3/src/pathspec.rs0000664000175000017500000002573412600564126013220 0ustar use std::iter::IntoIterator; use std::marker; use std::ops::Range; use std::path::Path; use libc::size_t; use {raw, Error, Diff, Tree, PathspecFlags, Index, Repository, DiffDelta, IntoCString}; use util::Binding; /// Structure representing a compiled pathspec used for matching against various /// structures. pub struct Pathspec { raw: *mut raw::git_pathspec, } /// List of filenames matching a pathspec. pub struct PathspecMatchList<'ps> { raw: *mut raw::git_pathspec_match_list, _marker: marker::PhantomData<&'ps Pathspec>, } /// Iterator over the matched paths in a pathspec. pub struct PathspecEntries<'list> { range: Range, list: &'list PathspecMatchList<'list>, } /// Iterator over the matching diff deltas. pub struct PathspecDiffEntries<'list> { range: Range, list: &'list PathspecMatchList<'list>, } /// Iterator over the failed list of pathspec items that did not match. pub struct PathspecFailedEntries<'list> { range: Range, list: &'list PathspecMatchList<'list>, } impl Pathspec { /// Creates a new pathspec from a list of specs to match against. pub fn new(specs: I) -> Result where T: IntoCString, I: IntoIterator { let (_a, _b, arr) = try!(::util::iter2cstrs(specs)); unsafe { let mut ret = 0 as *mut raw::git_pathspec; try_call!(raw::git_pathspec_new(&mut ret, &arr)); Ok(Binding::from_raw(ret)) } } /// Match a pathspec against files in a diff. /// /// The list returned contains the list of all matched filenames (unless you /// pass `PATHSPEC_FAILURES_ONLY` in the flags) and may also contain the /// list of pathspecs with no match if the `PATHSPEC_FIND_FAILURES` flag is /// specified. pub fn match_diff(&self, diff: &Diff, flags: PathspecFlags) -> Result { let mut ret = 0 as *mut raw::git_pathspec_match_list; unsafe { try_call!(raw::git_pathspec_match_diff(&mut ret, diff.raw(), flags.bits(), self.raw)); Ok(Binding::from_raw(ret)) } } /// Match a pathspec against files in a tree. /// /// The list returned contains the list of all matched filenames (unless you /// pass `PATHSPEC_FAILURES_ONLY` in the flags) and may also contain the /// list of pathspecs with no match if the `PATHSPEC_FIND_FAILURES` flag is /// specified. pub fn match_tree(&self, tree: &Tree, flags: PathspecFlags) -> Result { let mut ret = 0 as *mut raw::git_pathspec_match_list; unsafe { try_call!(raw::git_pathspec_match_tree(&mut ret, tree.raw(), flags.bits(), self.raw)); Ok(Binding::from_raw(ret)) } } /// This matches the pathspec against the files in the repository index. /// /// The list returned contains the list of all matched filenames (unless you /// pass `PATHSPEC_FAILURES_ONLY` in the flags) and may also contain the /// list of pathspecs with no match if the `PATHSPEC_FIND_FAILURES` flag is /// specified. pub fn match_index(&self, index: &Index, flags: PathspecFlags) -> Result { let mut ret = 0 as *mut raw::git_pathspec_match_list; unsafe { try_call!(raw::git_pathspec_match_index(&mut ret, index.raw(), flags.bits(), self.raw)); Ok(Binding::from_raw(ret)) } } /// Match a pathspec against the working directory of a repository. /// /// This matches the pathspec against the current files in the working /// directory of the repository. It is an error to invoke this on a bare /// repo. This handles git ignores (i.e. ignored files will not be /// considered to match the pathspec unless the file is tracked in the /// index). /// /// The list returned contains the list of all matched filenames (unless you /// pass `PATHSPEC_FAILURES_ONLY` in the flags) and may also contain the /// list of pathspecs with no match if the `PATHSPEC_FIND_FAILURES` flag is /// specified. pub fn match_workdir(&self, repo: &Repository, flags: PathspecFlags) -> Result { let mut ret = 0 as *mut raw::git_pathspec_match_list; unsafe { try_call!(raw::git_pathspec_match_workdir(&mut ret, repo.raw(), flags.bits(), self.raw)); Ok(Binding::from_raw(ret)) } } /// Try to match a path against a pathspec /// /// Unlike most of the other pathspec matching functions, this will not fall /// back on the native case-sensitivity for your platform. You must /// explicitly pass flags to control case sensitivity or else this will fall /// back on being case sensitive. pub fn matches_path(&self, path: &Path, flags: PathspecFlags) -> bool { let path = path.into_c_string().unwrap(); unsafe { raw::git_pathspec_matches_path(&*self.raw, flags.bits(), path.as_ptr()) == 1 } } } impl Binding for Pathspec { type Raw = *mut raw::git_pathspec; unsafe fn from_raw(raw: *mut raw::git_pathspec) -> Pathspec { Pathspec { raw: raw } } fn raw(&self) -> *mut raw::git_pathspec { self.raw } } impl Drop for Pathspec { fn drop(&mut self) { unsafe { raw::git_pathspec_free(self.raw) } } } impl<'ps> PathspecMatchList<'ps> { fn entrycount(&self) -> usize { unsafe { raw::git_pathspec_match_list_entrycount(&*self.raw) as usize } } fn failed_entrycount(&self) -> usize { unsafe { raw::git_pathspec_match_list_failed_entrycount(&*self.raw) as usize } } /// Returns an iterator over the matching filenames in this list. pub fn entries(&self) -> PathspecEntries { let n = self.entrycount(); let n = if n > 0 && self.entry(0).is_none() {0} else {n}; PathspecEntries { range: 0..n, list: self } } /// Get a matching filename by position. /// /// If this list was generated from a diff, then the return value will /// always be `None. pub fn entry(&self, i: usize) -> Option<&[u8]> { unsafe { let ptr = raw::git_pathspec_match_list_entry(&*self.raw, i as size_t); ::opt_bytes(self, ptr) } } /// Returns an iterator over the matching diff entries in this list. pub fn diff_entries(&self) -> PathspecDiffEntries { let n = self.entrycount(); let n = if n > 0 && self.diff_entry(0).is_none() {0} else {n}; PathspecDiffEntries { range: 0..n, list: self } } /// Get a matching diff delta by position. /// /// If the list was not generated from a diff, then the return value will /// always be `None`. pub fn diff_entry(&self, i: usize) -> Option { unsafe { let ptr = raw::git_pathspec_match_list_diff_entry(&*self.raw, i as size_t); Binding::from_raw_opt(ptr as *mut _) } } /// Returns an iterator over the non-matching entries in this list. pub fn failed_entries(&self) -> PathspecFailedEntries { let n = self.failed_entrycount(); let n = if n > 0 && self.failed_entry(0).is_none() {0} else {n}; PathspecFailedEntries { range: 0..n, list: self } } /// Get an original pathspec string that had no matches. pub fn failed_entry(&self, i: usize) -> Option<&[u8]> { unsafe { let ptr = raw::git_pathspec_match_list_failed_entry(&*self.raw, i as size_t); ::opt_bytes(self, ptr) } } } impl<'ps> Binding for PathspecMatchList<'ps> { type Raw = *mut raw::git_pathspec_match_list; unsafe fn from_raw(raw: *mut raw::git_pathspec_match_list) -> PathspecMatchList<'ps> { PathspecMatchList { raw: raw, _marker: marker::PhantomData } } fn raw(&self) -> *mut raw::git_pathspec_match_list { self.raw } } impl<'ps> Drop for PathspecMatchList<'ps> { fn drop(&mut self) { unsafe { raw::git_pathspec_match_list_free(self.raw) } } } impl<'list> Iterator for PathspecEntries<'list> { type Item = &'list [u8]; fn next(&mut self) -> Option<&'list [u8]> { self.range.next().and_then(|i| self.list.entry(i)) } fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } } impl<'list> DoubleEndedIterator for PathspecEntries<'list> { fn next_back(&mut self) -> Option<&'list [u8]> { self.range.next_back().and_then(|i| self.list.entry(i)) } } impl<'list> ExactSizeIterator for PathspecEntries<'list> {} impl<'list> Iterator for PathspecDiffEntries<'list> { type Item = DiffDelta<'list>; fn next(&mut self) -> Option> { self.range.next().and_then(|i| self.list.diff_entry(i)) } fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } } impl<'list> DoubleEndedIterator for PathspecDiffEntries<'list> { fn next_back(&mut self) -> Option> { self.range.next_back().and_then(|i| self.list.diff_entry(i)) } } impl<'list> ExactSizeIterator for PathspecDiffEntries<'list> {} impl<'list> Iterator for PathspecFailedEntries<'list> { type Item = &'list [u8]; fn next(&mut self) -> Option<&'list [u8]> { self.range.next().and_then(|i| self.list.failed_entry(i)) } fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } } impl<'list> DoubleEndedIterator for PathspecFailedEntries<'list> { fn next_back(&mut self) -> Option<&'list [u8]> { self.range.next_back().and_then(|i| self.list.failed_entry(i)) } } impl<'list> ExactSizeIterator for PathspecFailedEntries<'list> {} #[cfg(test)] mod tests { use PATHSPEC_DEFAULT; use super::Pathspec; use std::fs::File; use std::path::Path; #[test] fn smoke() { let ps = Pathspec::new(["a"].iter()).unwrap(); assert!(ps.matches_path(Path::new("a"), PATHSPEC_DEFAULT)); assert!(ps.matches_path(Path::new("a/b"), PATHSPEC_DEFAULT)); assert!(!ps.matches_path(Path::new("b"), PATHSPEC_DEFAULT)); assert!(!ps.matches_path(Path::new("ab/c"), PATHSPEC_DEFAULT)); let (td, repo) = ::test::repo_init(); let list = ps.match_workdir(&repo, PATHSPEC_DEFAULT).unwrap(); assert_eq!(list.entries().len(), 0); assert_eq!(list.diff_entries().len(), 0); assert_eq!(list.failed_entries().len(), 0); File::create(&td.path().join("a")).unwrap(); let list = ps.match_workdir(&repo, ::PATHSPEC_FIND_FAILURES).unwrap(); assert_eq!(list.entries().len(), 1); assert_eq!(list.entries().next(), Some("a".as_bytes())); } } deps/git2-0.3.3/src/remote_callbacks.rs0000664000175000017500000003071112517471774014707 0ustar use std::ffi::CStr; use std::marker; use std::mem; use std::slice; use std::str; use libc::{c_void, c_int, c_char, c_uint}; use {raw, Error, Cred, CredentialType, Oid}; use cert::Cert; use util::Binding; /// A structure to contain the callbacks which are invoked when a repository is /// being updated or downloaded. /// /// These callbacks are used to manage facilities such as authentication, /// transfer progress, etc. pub struct RemoteCallbacks<'a> { progress: Option>>, credentials: Option>>, sideband_progress: Option>>, update_tips: Option>>, certificate_check: Option>>, } /// Struct representing the progress by an in-flight transfer. pub struct Progress<'a> { raw: ProgressState, _marker: marker::PhantomData<&'a raw::git_transfer_progress>, } enum ProgressState { Borrowed(*const raw::git_transfer_progress), Owned(raw::git_transfer_progress), } /// Callback used to acquire credentials for when a remote is fetched. /// /// * `url` - the resource for which the credentials are required. /// * `username_from_url` - the username that was embedded in the url, or `None` /// if it was not included. /// * `allowed_types` - a bitmask stating which cred types are ok to return. pub type Credentials<'a> = FnMut(&str, Option<&str>, CredentialType) -> Result + 'a; /// Callback to be invoked while a transfer is in progress. /// /// This callback will be periodically called with updates to the progress of /// the transfer so far. The return value indicates whether the transfer should /// continue. A return value of `false` will cancel the transfer. /// /// * `progress` - the progress being made so far. pub type TransferProgress<'a> = FnMut(Progress) -> bool + 'a; /// Callback for receiving messages delivered by the transport. /// /// The return value indicates whether the network operation should continue. pub type TransportMessage<'a> = FnMut(&[u8]) -> bool + 'a; /// Callback for whenever a reference is updated locally. pub type UpdateTips<'a> = FnMut(&str, Oid, Oid) -> bool + 'a; /// Callback for a custom certificate check. /// /// The first argument is the certificate receved on the connection. /// Certificates are typically either an SSH or X509 certificate. /// /// The second argument is the hostname for the connection is passed as the last /// argument. pub type CertificateCheck<'a> = FnMut(&Cert, &str) -> bool + 'a; impl<'a> RemoteCallbacks<'a> { /// Creates a new set of empty callbacks pub fn new() -> RemoteCallbacks<'a> { RemoteCallbacks { credentials: None, progress: None, sideband_progress: None, update_tips: None, certificate_check: None, } } /// The callback through which to fetch credentials if required. pub fn credentials(&mut self, cb: F) -> &mut RemoteCallbacks<'a> where F: FnMut(&str, Option<&str>, CredentialType) -> Result + 'a { self.credentials = Some(Box::new(cb) as Box>); self } /// The callback through which progress is monitored. pub fn transfer_progress(&mut self, cb: F) -> &mut RemoteCallbacks<'a> where F: FnMut(Progress) -> bool + 'a { self.progress = Some(Box::new(cb) as Box>); self } /// Textual progress from the remote. /// /// Text sent over the progress side-band will be passed to this function /// (this is the 'counting objects' output. pub fn sideband_progress(&mut self, cb: F) -> &mut RemoteCallbacks<'a> where F: FnMut(&[u8]) -> bool + 'a { self.sideband_progress = Some(Box::new(cb) as Box>); self } /// Each time a reference is updated locally, the callback will be called /// with information about it. pub fn update_tips(&mut self, cb: F) -> &mut RemoteCallbacks<'a> where F: FnMut(&str, Oid, Oid) -> bool + 'a { self.update_tips = Some(Box::new(cb) as Box>); self } /// If certificate verification fails, then this callback will be invoked to /// let the caller make the final decision of whether to allow the /// connection to proceed. pub fn certificate_check(&mut self, cb: F) -> &mut RemoteCallbacks<'a> where F: FnMut(&Cert, &str) -> bool + 'a { self.certificate_check = Some(Box::new(cb) as Box>); self } } impl<'a> Binding for RemoteCallbacks<'a> { type Raw = raw::git_remote_callbacks; unsafe fn from_raw(_raw: raw::git_remote_callbacks) -> RemoteCallbacks<'a> { panic!("unimplemented"); } fn raw(&self) -> raw::git_remote_callbacks { unsafe { let mut callbacks: raw::git_remote_callbacks = mem::zeroed(); assert_eq!(raw::git_remote_init_callbacks(&mut callbacks, raw::GIT_REMOTE_CALLBACKS_VERSION), 0); if self.progress.is_some() { let f: raw::git_transfer_progress_cb = transfer_progress_cb; callbacks.transfer_progress = Some(f); } if self.credentials.is_some() { let f: raw::git_cred_acquire_cb = credentials_cb; callbacks.credentials = Some(f); } if self.sideband_progress.is_some() { let f: raw::git_transport_message_cb = sideband_progress_cb; callbacks.sideband_progress = Some(f); } if self.certificate_check.is_some() { let f: raw::git_transport_certificate_check_cb = certificate_check_cb; callbacks.certificate_check = Some(f); } if self.update_tips.is_some() { let f: extern fn(*const c_char, *const raw::git_oid, *const raw::git_oid, *mut c_void) -> c_int = update_tips_cb; callbacks.update_tips = Some(f); } callbacks.payload = self as *const _ as *mut _; return callbacks; } } } impl<'a> Progress<'a> { /// Number of objects in the packfile being downloaded pub fn total_objects(&self) -> usize { unsafe { (*self.raw()).total_objects as usize } } /// Received objects that have been hashed pub fn indexed_objects(&self) -> usize { unsafe { (*self.raw()).indexed_objects as usize } } /// Objects which have been downloaded pub fn received_objects(&self) -> usize { unsafe { (*self.raw()).received_objects as usize } } /// Locally-available objects that have been injected in order to fix a thin /// pack. pub fn local_objects(&self) -> usize { unsafe { (*self.raw()).local_objects as usize } } /// Number of deltas in the packfile being downloaded pub fn total_deltas(&self) -> usize { unsafe { (*self.raw()).total_deltas as usize } } /// Received deltas that have been hashed. pub fn indexed_deltas(&self) -> usize { unsafe { (*self.raw()).indexed_deltas as usize } } /// Size of the packfile received up to now pub fn received_bytes(&self) -> usize { unsafe { (*self.raw()).received_bytes as usize } } /// Convert this to an owned version of `Progress`. pub fn to_owned(&self) -> Progress<'static> { Progress { raw: ProgressState::Owned(unsafe { *self.raw() }), _marker: marker::PhantomData, } } } impl<'a> Binding for Progress<'a> { type Raw = *const raw::git_transfer_progress; unsafe fn from_raw(raw: *const raw::git_transfer_progress) -> Progress<'a> { Progress { raw: ProgressState::Borrowed(raw), _marker: marker::PhantomData, } } fn raw(&self) -> *const raw::git_transfer_progress { match self.raw { ProgressState::Borrowed(raw) => raw, ProgressState::Owned(ref raw) => raw as *const _, } } } wrap_env! { fn credentials_cb(ret: *mut *mut raw::git_cred, url: *const c_char, username_from_url: *const c_char, allowed_types: c_uint, payload: *mut c_void) -> c_int { unsafe { let payload = &mut *(payload as *mut RemoteCallbacks); let callback = try!(payload.credentials.as_mut() .ok_or(raw::GIT_PASSTHROUGH as c_int)); *ret = 0 as *mut raw::git_cred; let url = try!(str::from_utf8(CStr::from_ptr(url).to_bytes()) .map_err(|_| raw::GIT_PASSTHROUGH as c_int)); let username_from_url = match ::opt_bytes(&url, username_from_url) { Some(username) => { Some(try!(str::from_utf8(username) .map_err(|_| raw::GIT_PASSTHROUGH as c_int))) } None => None, }; let cred_type = CredentialType::from_bits_truncate(allowed_types as u32); callback(url, username_from_url, cred_type).map_err(|e| { e.raw_code() as c_int }) } } returning ok as unsafe { match ok { Some(Ok(cred)) => { // Turns out it's a memory safety issue if we pass through any // and all credentials into libgit2 if allowed_types & (cred.credtype() as c_uint) != 0 { *ret = cred.unwrap(); 0 } else { raw::GIT_PASSTHROUGH as c_int } } Some(Err(e)) => e, None => -1, } } } wrap_env! { fn transfer_progress_cb(stats: *const raw::git_transfer_progress, payload: *mut c_void) -> c_int { unsafe { let payload = &mut *(payload as *mut RemoteCallbacks); let callback = match payload.progress { Some(ref mut c) => c, None => return true, }; let progress = Binding::from_raw(stats); callback(progress) } } returning ok as (if ok == Some(true) {0} else {-1}) } wrap_env! { fn sideband_progress_cb(str: *const c_char, len: c_int, payload: *mut c_void) -> c_int { unsafe { let payload = &mut *(payload as *mut RemoteCallbacks); let callback = match payload.sideband_progress { Some(ref mut c) => c, None => return true, }; let buf = slice::from_raw_parts(str as *const u8, len as usize); callback(buf) } } returning ok as (if ok == Some(true) {0} else {-1}) } wrap_env! { fn update_tips_cb(refname: *const c_char, a: *const raw::git_oid, b: *const raw::git_oid, data: *mut c_void) -> c_int { unsafe { let payload = &mut *(data as *mut RemoteCallbacks); let callback = match payload.update_tips { Some(ref mut c) => c, None => return true, }; let refname = str::from_utf8(CStr::from_ptr(refname).to_bytes()) .unwrap(); let a = Binding::from_raw(a); let b = Binding::from_raw(b); callback(refname, a, b) } } returning ok as (if ok == Some(true) {0} else {-1}) } wrap_env! { fn certificate_check_cb(cert: *mut raw::git_cert, _valid: c_int, hostname: *const c_char, data: *mut c_void) -> c_int { unsafe { let payload = &mut *(data as *mut RemoteCallbacks); let callback = match payload.certificate_check { Some(ref mut c) => c, None => return true, }; let cert = Binding::from_raw(cert); let hostname = str::from_utf8(CStr::from_ptr(hostname).to_bytes()) .unwrap(); callback(&cert, hostname) } } returning ok as (if ok == Some(true) {0} else {-1}) } deps/git2-0.3.3/src/buf.rs0000664000175000017500000000311312466551515012160 0ustar use std::slice; use std::str; use std::ops::{Deref, DerefMut}; use libc; use raw; use util::Binding; /// A structure to wrap an intermediate buffer used by libgit2. /// /// A buffer can be thought of a `Vec`, but the `Vec` type is not used to /// avoid copying data back and forth. pub struct Buf { raw: raw::git_buf, } impl Buf { /// Creates a new empty buffer. pub fn new() -> Buf { ::init(); unsafe { Binding::from_raw(&mut raw::git_buf { ptr: 0 as *mut libc::c_char, size: 0, asize: 0, } as *mut _) } } /// Attempt to view this buffer as a string slice. /// /// Returns `None` if the buffer is not valid utf-8. pub fn as_str(&self) -> Option<&str> { str::from_utf8(&**self).ok() } } impl Deref for Buf { type Target = [u8]; fn deref(&self) -> &[u8] { unsafe { slice::from_raw_parts(self.raw.ptr as *const u8, self.raw.size as usize) } } } impl DerefMut for Buf { fn deref_mut(&mut self) -> &mut [u8] { unsafe { slice::from_raw_parts_mut(self.raw.ptr as *mut u8, self.raw.size as usize) } } } impl Binding for Buf { type Raw = *mut raw::git_buf; unsafe fn from_raw(raw: *mut raw::git_buf) -> Buf { Buf { raw: *raw } } fn raw(&self) -> *mut raw::git_buf { &self.raw as *const _ as *mut _ } } impl Drop for Buf { fn drop(&mut self) { unsafe { raw::git_buf_free(&mut self.raw) } } } deps/git2-0.3.3/src/object.rs0000664000175000017500000001001512603146747012651 0ustar use std::marker; use std::mem; use {raw, Oid, ObjectType, Error, Buf, Commit, Tag, Blob, Tree, Repository}; use {Describe, DescribeOptions}; use util::Binding; /// A structure to represent a git [object][1] /// /// [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects pub struct Object<'repo> { raw: *mut raw::git_object, _marker: marker::PhantomData<&'repo Repository>, } impl<'repo> Object<'repo> { /// Get the id (SHA1) of a repository object pub fn id(&self) -> Oid { unsafe { Binding::from_raw(raw::git_object_id(&*self.raw)) } } /// Get the object type of an object. /// /// If the type is unknown, then `None` is returned. pub fn kind(&self) -> Option { ObjectType::from_raw(unsafe { raw::git_object_type(&*self.raw) }) } /// Recursively peel an object until an object of the specified type is met. /// /// If you pass `Any` as the target type, then the object will be /// peeled until the type changes (e.g. a tag will be chased until the /// referenced object is no longer a tag). pub fn peel(&self, kind: ObjectType) -> Result, Error> { let mut raw = 0 as *mut raw::git_object; unsafe { try_call!(raw::git_object_peel(&mut raw, &*self.raw(), kind)); Ok(Binding::from_raw(raw)) } } /// Get a short abbreviated OID string for the object /// /// This starts at the "core.abbrev" length (default 7 characters) and /// iteratively extends to a longer string if that length is ambiguous. The /// result will be unambiguous (at least until new objects are added to the /// repository). pub fn short_id(&self) -> Result { unsafe { let buf = Buf::new(); try_call!(raw::git_object_short_id(buf.raw(), &*self.raw())); Ok(buf) } } /// Attempt to view this object as a commit. /// /// Returns `None` if the object is not actually a commit. pub fn as_commit(&self) -> Option<&Commit<'repo>> { self.cast(ObjectType::Commit) } /// Attempt to view this object as a tag. /// /// Returns `None` if the object is not actually a tag. pub fn as_tag(&self) -> Option<&Tag<'repo>> { self.cast(ObjectType::Tag) } /// Attempt to view this object as a tree. /// /// Returns `None` if the object is not actually a tree. pub fn as_tree(&self) -> Option<&Tree<'repo>> { self.cast(ObjectType::Tree) } /// Attempt to view this object as a blob. /// /// Returns `None` if the object is not actually a blob. pub fn as_blob(&self) -> Option<&Blob<'repo>> { self.cast(ObjectType::Blob) } /// Describes a commit /// /// Performs a describe operation on this commitish object. pub fn describe(&self, opts: &DescribeOptions) -> Result { let mut ret = 0 as *mut _; unsafe { try_call!(raw::git_describe_commit(&mut ret, self.raw, opts.raw())); Ok(Binding::from_raw(ret)) } } fn cast(&self, kind: ObjectType) -> Option<&T> { assert_eq!(mem::size_of::(), mem::size_of::()); if self.kind() == Some(kind) { unsafe { Some(&*(self as *const _ as *const T)) } } else { None } } } impl<'repo> Clone for Object<'repo> { fn clone(&self) -> Object<'repo> { let mut raw = 0 as *mut raw::git_object; unsafe { let rc = raw::git_object_dup(&mut raw, self.raw); assert_eq!(rc, 0); Binding::from_raw(raw) } } } impl<'repo> Binding for Object<'repo> { type Raw = *mut raw::git_object; unsafe fn from_raw(raw: *mut raw::git_object) -> Object<'repo> { Object { raw: raw, _marker: marker::PhantomData, } } fn raw(&self) -> *mut raw::git_object { self.raw } } impl<'repo> Drop for Object<'repo> { fn drop(&mut self) { unsafe { raw::git_object_free(self.raw) } } } deps/git2-0.3.3/src/index.rs0000664000175000017500000005167012563210063012512 0ustar use std::ffi::{CStr, OsString}; use std::iter::IntoIterator; use std::ops::Range; use std::path::Path; use libc::{c_int, c_uint, size_t, c_void, c_char}; use {raw, Repository, Error, Tree, Oid, IndexAddOption, IndexTime}; use IntoCString; use util::{self, Binding}; /// A structure to represent a git [index][1] /// /// [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects pub struct Index { raw: *mut raw::git_index, } /// An iterator over the entries in an index pub struct IndexEntries<'index> { range: Range, index: &'index Index, } /// A callback function to filter index matches. /// /// Used by `Index::{add_all,remove_all,update_all}`. The first argument is the /// path, and the second is the patchspec that matched it. Return 0 to confirm /// the operation on the item, > 0 to skip the item, and < 0 to abort the scan. pub type IndexMatchedPath<'a> = FnMut(&Path, &[u8]) -> i32 + 'a; /// A structure to represent an entry or a file inside of an index. /// /// All fields of an entry are public for modification and inspection. This is /// also how a new index entry is created. #[allow(missing_docs)] pub struct IndexEntry { pub ctime: IndexTime, pub mtime: IndexTime, pub dev: u32, pub ino: u32, pub mode: u32, pub uid: u32, pub gid: u32, pub file_size: u32, pub id: Oid, pub flags: u16, pub flags_extended: u16, pub path: Vec, } impl Index { /// Creates a new in-memory index. /// /// This index object cannot be read/written to the filesystem, but may be /// used to perform in-memory index operations. pub fn new() -> Result { ::init(); let mut raw = 0 as *mut raw::git_index; unsafe { try_call!(raw::git_index_new(&mut raw)); Ok(Binding::from_raw(raw)) } } /// Create a new bare Git index object as a memory representation of the Git /// index file in 'index_path', without a repository to back it. /// /// Since there is no ODB or working directory behind this index, any Index /// methods which rely on these (e.g. add_path) will fail. /// /// If you need an index attached to a repository, use the `index()` method /// on `Repository`. pub fn open(index_path: &Path) -> Result { ::init(); let mut raw = 0 as *mut raw::git_index; let index_path = try!(index_path.into_c_string()); unsafe { try_call!(raw::git_index_open(&mut raw, index_path)); Ok(Binding::from_raw(raw)) } } /// Add or update an index entry from an in-memory struct /// /// If a previous index entry exists that has the same path and stage as the /// given 'source_entry', it will be replaced. Otherwise, the 'source_entry' /// will be added. pub fn add(&mut self, source_entry: &IndexEntry) -> Result<(), Error> { let entry = source_entry.raw(); unsafe { try_call!(raw::git_index_add(self.raw, &entry)); Ok(()) } } /// Add or update an index entry from a file on disk /// /// The file path must be relative to the repository's working folder and /// must be readable. /// /// This method will fail in bare index instances. /// /// This forces the file to be added to the index, not looking at gitignore /// rules. /// /// If this file currently is the result of a merge conflict, this file will /// no longer be marked as conflicting. The data about the conflict will be /// moved to the "resolve undo" (REUC) section. pub fn add_path(&mut self, path: &Path) -> Result<(), Error> { // Git apparently expects '/' to be separators for paths let mut posix_path = OsString::new(); for (i, comp) in path.components().enumerate() { if i != 0 { posix_path.push("/"); } posix_path.push(comp.as_os_str()); } let posix_path = try!(posix_path.into_c_string()); unsafe { try_call!(raw::git_index_add_bypath(self.raw, posix_path)); Ok(()) } } /// Add or update index entries matching files in the working directory. /// /// This method will fail in bare index instances. /// /// The `pathspecs` are a list of file names or shell glob patterns that /// will matched against files in the repository's working directory. Each /// file that matches will be added to the index (either updating an /// existing entry or adding a new entry). You can disable glob expansion /// and force exact matching with the `AddDisablePathspecMatch` flag. /// /// Files that are ignored will be skipped (unlike `add_path`). If a file is /// already tracked in the index, then it will be updated even if it is /// ignored. Pass the `AddForce` flag to skip the checking of ignore rules. /// /// To emulate `git add -A` and generate an error if the pathspec contains /// the exact path of an ignored file (when not using `AddForce`), add the /// `AddCheckPathspec` flag. This checks that each entry in `pathspecs` /// that is an exact match to a filename on disk is either not ignored or /// already in the index. If this check fails, the function will return /// an error. /// /// To emulate `git add -A` with the "dry-run" option, just use a callback /// function that always returns a positive value. See below for details. /// /// If any files are currently the result of a merge conflict, those files /// will no longer be marked as conflicting. The data about the conflicts /// will be moved to the "resolve undo" (REUC) section. /// /// If you provide a callback function, it will be invoked on each matching /// item in the working directory immediately before it is added to / /// updated in the index. Returning zero will add the item to the index, /// greater than zero will skip the item, and less than zero will abort the /// scan an return an error to the caller. pub fn add_all(&mut self, pathspecs: I, flag: IndexAddOption, mut cb: Option<&mut IndexMatchedPath>) -> Result<(), Error> where T: IntoCString, I: IntoIterator, { let (_a, _b, raw_strarray) = try!(::util::iter2cstrs(pathspecs)); let ptr = cb.as_mut(); let callback = ptr.as_ref().map(|_| { index_matched_path_cb as raw::git_index_matched_path_cb }); unsafe { try_call!(raw::git_index_add_all(self.raw, &raw_strarray, flag.bits() as c_uint, callback, ptr.map(|p| p as *mut _) .unwrap_or(0 as *mut _) as *mut c_void)); } return Ok(()); } /// Clear the contents (all the entries) of an index object. /// /// This clears the index object in memory; changes must be explicitly /// written to disk for them to take effect persistently via `write_*`. pub fn clear(&mut self) -> Result<(), Error> { unsafe { try_call!(raw::git_index_clear(self.raw)); } Ok(()) } /// Get the count of entries currently in the index pub fn len(&self) -> usize { unsafe { raw::git_index_entrycount(&*self.raw) as usize } } /// Get one of the entries in the index by its position. pub fn get(&self, n: usize) -> Option { unsafe { let ptr = raw::git_index_get_byindex(self.raw, n as size_t); if ptr.is_null() {None} else {Some(Binding::from_raw(*ptr))} } } /// Get an iterator over the entries in this index. pub fn iter(&self) -> IndexEntries { IndexEntries { range: 0..self.len(), index: self } } /// Get one of the entries in the index by its path. pub fn get_path(&self, path: &Path, stage: i32) -> Option { let path = path.into_c_string().unwrap(); unsafe { let ptr = call!(raw::git_index_get_bypath(self.raw, path, stage as c_int)); if ptr.is_null() {None} else {Some(Binding::from_raw(*ptr))} } } /// Get the full path to the index file on disk. /// /// Returns `None` if this is an in-memory index. pub fn path(&self) -> Option<&Path> { unsafe { ::opt_bytes(self, raw::git_index_path(&*self.raw)).map(util::bytes2path) } } /// Update the contents of an existing index object in memory by reading /// from the hard disk. /// /// If force is true, this performs a "hard" read that discards in-memory /// changes and always reloads the on-disk index data. If there is no /// on-disk version, the index will be cleared. /// /// If force is false, this does a "soft" read that reloads the index data /// from disk only if it has changed since the last time it was loaded. /// Purely in-memory index data will be untouched. Be aware: if there are /// changes on disk, unwritten in-memory changes are discarded. pub fn read(&mut self, force: bool) -> Result<(), Error> { unsafe { try_call!(raw::git_index_read(self.raw, force)); } Ok(()) } /// Read a tree into the index file with stats /// /// The current index contents will be replaced by the specified tree. pub fn read_tree(&mut self, tree: &Tree) -> Result<(), Error> { unsafe { try_call!(raw::git_index_read_tree(self.raw, &*tree.raw())); } Ok(()) } /// Remove an entry from the index pub fn remove(&mut self, path: &Path, stage: i32) -> Result<(), Error> { let path = try!(path.into_c_string()); unsafe { try_call!(raw::git_index_remove(self.raw, path, stage as c_int)); } Ok(()) } /// Remove an index entry corresponding to a file on disk. /// /// The file path must be relative to the repository's working folder. It /// may exist. /// /// If this file currently is the result of a merge conflict, this file will /// no longer be marked as conflicting. The data about the conflict will be /// moved to the "resolve undo" (REUC) section. pub fn remove_path(&mut self, path: &Path) -> Result<(), Error> { let path = try!(path.into_c_string()); unsafe { try_call!(raw::git_index_remove_bypath(self.raw, path)); } Ok(()) } /// Remove all entries from the index under a given directory. pub fn remove_dir(&mut self, path: &Path, stage: i32) -> Result<(), Error> { let path = try!(path.into_c_string()); unsafe { try_call!(raw::git_index_remove_directory(self.raw, path, stage as c_int)); } Ok(()) } /// Remove all matching index entries. /// /// If you provide a callback function, it will be invoked on each matching /// item in the index immediately before it is removed. Return 0 to remove /// the item, > 0 to skip the item, and < 0 to abort the scan. pub fn remove_all(&mut self, pathspecs: I, mut cb: Option<&mut IndexMatchedPath>) -> Result<(), Error> where T: IntoCString, I: IntoIterator, { let (_a, _b, raw_strarray) = try!(::util::iter2cstrs(pathspecs)); let ptr = cb.as_mut(); let callback = ptr.as_ref().map(|_| { index_matched_path_cb as raw::git_index_matched_path_cb }); unsafe { try_call!(raw::git_index_remove_all(self.raw, &raw_strarray, callback, ptr.map(|p| p as *mut _) .unwrap_or(0 as *mut _) as *mut c_void)); } return Ok(()); } /// Update all index entries to match the working directory /// /// This method will fail in bare index instances. /// /// This scans the existing index entries and synchronizes them with the /// working directory, deleting them if the corresponding working directory /// file no longer exists otherwise updating the information (including /// adding the latest version of file to the ODB if needed). /// /// If you provide a callback function, it will be invoked on each matching /// item in the index immediately before it is updated (either refreshed or /// removed depending on working directory state). Return 0 to proceed with /// updating the item, > 0 to skip the item, and < 0 to abort the scan. pub fn update_all(&mut self, pathspecs: I, mut cb: Option<&mut IndexMatchedPath>) -> Result<(), Error> where T: IntoCString, I: IntoIterator, { let (_a, _b, raw_strarray) = try!(::util::iter2cstrs(pathspecs)); let ptr = cb.as_mut(); let callback = ptr.as_ref().map(|_| { index_matched_path_cb as raw::git_index_matched_path_cb }); unsafe { try_call!(raw::git_index_update_all(self.raw, &raw_strarray, callback, ptr.map(|p| p as *mut _) .unwrap_or(0 as *mut _) as *mut c_void)); } return Ok(()); } /// Write an existing index object from memory back to disk using an atomic /// file lock. pub fn write(&mut self) -> Result<(), Error> { unsafe { try_call!(raw::git_index_write(self.raw)); } Ok(()) } /// Write the index as a tree. /// /// This method will scan the index and write a representation of its /// current state back to disk; it recursively creates tree objects for each /// of the subtrees stored in the index, but only returns the OID of the /// root tree. This is the OID that can be used e.g. to create a commit. /// /// The index instance cannot be bare, and needs to be associated to an /// existing repository. /// /// The index must not contain any file in conflict. pub fn write_tree(&mut self) -> Result { let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; unsafe { try_call!(raw::git_index_write_tree(&mut raw, self.raw)); Ok(Binding::from_raw(&raw as *const _)) } } /// Write the index as a tree to the given repository /// /// This is the same as `write_tree` except that the destination repository /// can be chosen. pub fn write_tree_to(&mut self, repo: &Repository) -> Result { let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; unsafe { try_call!(raw::git_index_write_tree_to(&mut raw, self.raw, repo.raw())); Ok(Binding::from_raw(&raw as *const _)) } } } impl Binding for Index { type Raw = *mut raw::git_index; unsafe fn from_raw(raw: *mut raw::git_index) -> Index { Index { raw: raw } } fn raw(&self) -> *mut raw::git_index { self.raw } } wrap_env! { fn index_matched_path_cb(path: *const c_char, matched_pathspec: *const c_char, payload: *mut c_void) -> c_int { unsafe { let path = CStr::from_ptr(path).to_bytes(); let matched_pathspec = CStr::from_ptr(matched_pathspec).to_bytes(); let payload = payload as *mut &mut IndexMatchedPath; (*payload)(util::bytes2path(path), matched_pathspec) as c_int } } returning code as code.unwrap_or(-1) } impl Drop for Index { fn drop(&mut self) { unsafe { raw::git_index_free(self.raw) } } } impl<'index> Iterator for IndexEntries<'index> { type Item = IndexEntry; fn next(&mut self) -> Option { self.range.next().map(|i| self.index.get(i).unwrap()) } } impl Binding for IndexEntry { type Raw = raw::git_index_entry; unsafe fn from_raw(raw: raw::git_index_entry) -> IndexEntry { let raw::git_index_entry { ctime, mtime, dev, ino, mode, uid, gid, file_size, id, flags, flags_extended, path } = raw; IndexEntry { dev: dev, ino: ino, mode: mode, uid: uid, gid: gid, file_size: file_size, id: Binding::from_raw(&id as *const _), flags: flags, flags_extended: flags_extended, path: CStr::from_ptr(path).to_bytes().to_vec(), mtime: Binding::from_raw(mtime), ctime: Binding::from_raw(ctime), } } fn raw(&self) -> raw::git_index_entry { raw::git_index_entry { dev: self.dev, ino: self.ino, mode: self.mode, uid: self.uid, gid: self.gid, file_size: self.file_size, id: unsafe { *self.id.raw() }, flags: self.flags, flags_extended: self.flags_extended, path: self.path.as_ptr() as *const _, mtime: raw::git_index_time { seconds: self.mtime.seconds(), nanoseconds: self.mtime.nanoseconds(), }, ctime: raw::git_index_time { seconds: self.ctime.seconds(), nanoseconds: self.ctime.nanoseconds(), }, } } } #[cfg(test)] mod tests { use std::fs::{self, File}; use std::path::Path; use tempdir::TempDir; use {Index, Repository, ResetType}; #[test] fn smoke() { let mut index = Index::new().unwrap(); assert!(index.add_path(&Path::new(".")).is_err()); index.clear().unwrap(); assert_eq!(index.len(), 0); assert!(index.get(0).is_none()); assert!(index.path().is_none()); assert!(index.read(true).is_err()); } #[test] fn smoke_from_repo() { let (_td, repo) = ::test::repo_init(); let mut index = repo.index().unwrap(); assert_eq!(index.path().map(|s| s.to_path_buf()), Some(repo.path().join("index"))); Index::open(&repo.path().join("index")).unwrap(); index.clear().unwrap(); index.read(true).unwrap(); index.write().unwrap(); index.write_tree().unwrap(); index.write_tree_to(&repo).unwrap(); } #[test] fn add_all() { let (_td, repo) = ::test::repo_init(); let mut index = repo.index().unwrap(); let root = repo.path().parent().unwrap(); fs::create_dir(&root.join("foo")).unwrap(); File::create(&root.join("foo/bar")).unwrap(); let mut called = false; index.add_all(["foo"].iter(), ::ADD_DEFAULT, Some(&mut |a: &Path, b: &[u8]| { assert!(!called); called = true; assert_eq!(b, b"foo"); assert_eq!(a, Path::new("foo/bar")); 0 })).unwrap(); assert!(called); called = false; index.remove_all(["."].iter(), Some(&mut |a: &Path, b: &[u8]| { assert!(!called); called = true; assert_eq!(b, b"."); assert_eq!(a, Path::new("foo/bar")); 0 })).unwrap(); assert!(called); } #[test] fn smoke_add() { let (_td, repo) = ::test::repo_init(); let mut index = repo.index().unwrap(); let root = repo.path().parent().unwrap(); fs::create_dir(&root.join("foo")).unwrap(); File::create(&root.join("foo/bar")).unwrap(); index.add_path(Path::new("foo/bar")).unwrap(); index.write().unwrap(); assert_eq!(index.iter().count(), 1); // Make sure we can use this repo somewhere else now. let id = index.write_tree().unwrap(); let tree = repo.find_tree(id).unwrap(); let sig = repo.signature().unwrap(); let id = repo.refname_to_id("HEAD").unwrap(); let parent = repo.find_commit(id).unwrap(); let commit = repo.commit(Some("HEAD"), &sig, &sig, "commit", &tree, &[&parent]).unwrap(); let obj = repo.find_object(commit, None).unwrap(); repo.reset(&obj, ResetType::Hard, None).unwrap(); let td2 = TempDir::new("git").unwrap(); let url = ::test::path2url(&root); let repo = Repository::clone(&url, td2.path()).unwrap(); let obj = repo.find_object(commit, None).unwrap(); repo.reset(&obj, ResetType::Hard, None).unwrap(); } } deps/git2-0.3.3/src/test.rs0000664000175000017500000000327712572110344012363 0ustar use std::path::{Path, PathBuf}; use std::io; use tempdir::TempDir; use url::Url; use Repository; macro_rules! t { ($e:expr) => (match $e { Ok(e) => e, Err(e) => panic!("{} failed with {}", stringify!($e), e), }) } pub fn repo_init() -> (TempDir, Repository) { let td = TempDir::new("test").unwrap(); let repo = Repository::init(td.path()).unwrap(); { let mut config = repo.config().unwrap(); config.set_str("user.name", "name").unwrap(); config.set_str("user.email", "email").unwrap(); let mut index = repo.index().unwrap(); let id = index.write_tree().unwrap(); let tree = repo.find_tree(id).unwrap(); let sig = repo.signature().unwrap(); repo.commit(Some("HEAD"), &sig, &sig, "initial", &tree, &[]).unwrap(); } (td, repo) } pub fn path2url(path: &Path) -> String { Url::from_file_path(path).unwrap().to_string() } #[cfg(windows)] pub fn realpath(original: &Path) -> io::Result { Ok(original.to_path_buf()) } #[cfg(unix)] pub fn realpath(original: &Path) -> io::Result { use std::ffi::{CStr, OsString, CString}; use std::os::unix::prelude::*; use libc::{self, c_char}; extern { fn realpath(name: *const c_char, resolved: *mut c_char) -> *mut c_char; } unsafe { let cstr = try!(CString::new(original.as_os_str().as_bytes())); let ptr = realpath(cstr.as_ptr(), 0 as *mut _); if ptr.is_null() { return Err(io::Error::last_os_error()) } let bytes = CStr::from_ptr(ptr).to_bytes().to_vec(); libc::free(ptr as *mut _); Ok(PathBuf::from(OsString::from_vec(bytes))) } } deps/git2-0.3.3/src/revwalk.rs0000664000175000017500000001440312517471774013070 0ustar use std::marker; use std::ffi::CString; use libc::c_uint; use {raw, Error, Sort, Oid, Repository}; use util::Binding; /// A revwalk allows traversal of the commit graph defined by including one or /// more leaves and excluding one or more roots. pub struct Revwalk<'repo> { raw: *mut raw::git_revwalk, _marker: marker::PhantomData<&'repo Repository>, } impl<'repo> Revwalk<'repo> { /// Reset a revwalk to allow re-configuring it. /// /// The revwalk is automatically reset when iteration of its commits /// completes. pub fn reset(&mut self) { unsafe { raw::git_revwalk_reset(self.raw()) } } /// Set the order in which commits are visited. pub fn set_sorting(&mut self, sort_mode: Sort) { unsafe { raw::git_revwalk_sorting(self.raw(), sort_mode.bits() as c_uint) } } /// Simplify the history by first-parent /// /// No parents other than the first for each commit will be enqueued. pub fn simplify_first_parent(&mut self) { unsafe { raw::git_revwalk_simplify_first_parent(self.raw) } } /// Mark a commit to start traversal from. /// /// The given OID must belong to a committish on the walked repository. /// /// The given commit will be used as one of the roots when starting the /// revision walk. At least one commit must be pushed onto the walker before /// a walk can be started. pub fn push(&mut self, oid: Oid) -> Result<(), Error> { unsafe { try_call!(raw::git_revwalk_push(self.raw(), oid.raw())); } Ok(()) } /// Push the repository's HEAD /// /// For more information, see `push`. pub fn push_head(&mut self) -> Result<(), Error> { unsafe { try_call!(raw::git_revwalk_push_head(self.raw())); } Ok(()) } /// Push matching references /// /// The OIDs pointed to by the references that match the given glob pattern /// will be pushed to the revision walker. /// /// A leading 'refs/' is implied if not present as well as a trailing `/ \ /// *` if the glob lacks '?', ' \ *' or '['. /// /// Any references matching this glob which do not point to a committish /// will be ignored. pub fn push_glob(&mut self, glob: &str) -> Result<(), Error> { let glob = try!(CString::new(glob)); unsafe { try_call!(raw::git_revwalk_push_glob(self.raw, glob)); } Ok(()) } /// Push and hide the respective endpoints of the given range. /// /// The range should be of the form `..` where each /// `` is in the form accepted by `revparse_single`. The left-hand /// commit will be hidden and the right-hand commit pushed. pub fn push_range(&mut self, range: &str) -> Result<(), Error> { let range = try!(CString::new(range)); unsafe { try_call!(raw::git_revwalk_push_range(self.raw, range)); } Ok(()) } /// Push the OID pointed to by a reference /// /// The reference must point to a committish. pub fn push_ref(&mut self, reference: &str) -> Result<(), Error> { let reference = try!(CString::new(reference)); unsafe { try_call!(raw::git_revwalk_push_ref(self.raw, reference)); } Ok(()) } /// Mark a commit as not of interest to this revwalk. pub fn hide(&mut self, oid: Oid) -> Result<(), Error> { unsafe { try_call!(raw::git_revwalk_hide(self.raw(), oid.raw())); } Ok(()) } /// Hide the repository's HEAD /// /// For more information, see `hide`. pub fn hide_head(&mut self) -> Result<(), Error> { unsafe { try_call!(raw::git_revwalk_hide_head(self.raw())); } Ok(()) } /// Hide matching references. /// /// The OIDs pointed to by the references that match the given glob pattern /// and their ancestors will be hidden from the output on the revision walk. /// /// A leading 'refs/' is implied if not present as well as a trailing `/ \ /// *` if the glob lacks '?', ' \ *' or '['. /// /// Any references matching this glob which do not point to a committish /// will be ignored. pub fn hide_glob(&mut self, glob: &str) -> Result<(), Error> { let glob = try!(CString::new(glob)); unsafe { try_call!(raw::git_revwalk_hide_glob(self.raw, glob)); } Ok(()) } /// Hide the OID pointed to by a reference. /// /// The reference must point to a committish. pub fn hide_ref(&mut self, reference: &str) -> Result<(), Error> { let reference = try!(CString::new(reference)); unsafe { try_call!(raw::git_revwalk_hide_ref(self.raw, reference)); } Ok(()) } } impl<'repo> Binding for Revwalk<'repo> { type Raw = *mut raw::git_revwalk; unsafe fn from_raw(raw: *mut raw::git_revwalk) -> Revwalk<'repo> { Revwalk { raw: raw, _marker: marker::PhantomData } } fn raw(&self) -> *mut raw::git_revwalk { self.raw } } impl<'repo> Drop for Revwalk<'repo> { fn drop(&mut self) { unsafe { raw::git_revwalk_free(self.raw) } } } impl<'repo> Iterator for Revwalk<'repo> { type Item = Oid; fn next(&mut self) -> Option { let mut out: raw::git_oid = raw::git_oid{ id: [0; raw::GIT_OID_RAWSZ] }; unsafe { match raw::git_revwalk_next(&mut out, self.raw()) { 0 => (), _ => return None, } Some(Binding::from_raw(&out as *const _)) } } } #[cfg(test)] mod tests { extern crate std; use std::vec::{Vec}; #[test] fn smoke() { let (_td, repo) = ::test::repo_init(); let head = repo.head().unwrap(); let target = head.target().unwrap(); let mut walk = repo.revwalk().unwrap(); walk.push(target).unwrap(); let oids: Vec<::Oid> = walk.by_ref().collect(); assert_eq!(oids.len(), 1); assert_eq!(oids[0], target); walk.reset(); walk.push_head().unwrap(); assert_eq!(walk.by_ref().count(), 1); walk.reset(); walk.push_head().unwrap(); walk.hide_head().unwrap(); assert_eq!(walk.by_ref().count(), 0); } } deps/git2-0.3.3/src/revspec.rs0000664000175000017500000000154312464717242013057 0ustar use {Object, RevparseMode}; /// A revspec represents a range of revisions within a repository. pub struct Revspec<'repo> { from: Option>, to: Option>, mode: RevparseMode, } impl<'repo> Revspec<'repo> { /// Assembles a new revspec from the from/to components. pub fn from_objects(from: Option>, to: Option>, mode: RevparseMode) -> Revspec<'repo> { Revspec { from: from, to: to, mode: mode } } /// Access the `from` range of this revspec. pub fn from(&self) -> Option<&Object<'repo>> { self.from.as_ref() } /// Access the `to` range of this revspec. pub fn to(&self) -> Option<&Object<'repo>> { self.to.as_ref() } /// Returns the intent of the revspec. pub fn mode(&self) -> RevparseMode { self.mode } } deps/git2-0.3.3/src/lib.rs0000664000175000017500000006552712623026262012162 0ustar //! # libgit2 bindings for Rust //! //! This library contains bindings to the [libgit2][1] C library which is used //! to manage git repositories. The library itself is a work in progress and is //! likely lacking some bindings here and there, so be warned. //! //! [1]: https://libgit2.github.com/ //! //! The git2-rs library strives to be as close to libgit2 as possible, but also //! strives to make using libgit2 as safe as possible. All resource management //! is automatic as well as adding strong types to all interfaces (including //! `Result`) //! //! ## Creating a `Repository` //! //! The `Repository` is the source from which almost all other objects in git-rs //! are spawned. A repository can be created through opening, initializing, or //! cloning. //! //! ### Initializing a new repository //! //! The `init` method will create a new repository, assuming one does not //! already exist. //! //! ```no_run //! # #![allow(unstable)] //! use git2::Repository; //! //! let repo = match Repository::init("/path/to/a/repo") { //! Ok(repo) => repo, //! Err(e) => panic!("failed to init: {}", e), //! }; //! ``` //! //! ### Opening an existing repository //! //! ```no_run //! # #![allow(unstable)] //! use git2::Repository; //! //! let repo = match Repository::open("/path/to/a/repo") { //! Ok(repo) => repo, //! Err(e) => panic!("failed to open: {}", e), //! }; //! ``` //! //! ### Cloning an existing repository //! //! ```no_run //! # #![allow(unstable)] //! use git2::Repository; //! //! let url = "https://github.com/alexcrichton/git2-rs"; //! let repo = match Repository::clone(url, "/path/to/a/repo") { //! Ok(repo) => repo, //! Err(e) => panic!("failed to clone: {}", e), //! }; //! ``` //! //! ## Working with a `Repository` //! //! All deriviative objects, references, etc are attached to the lifetime of the //! source `Repository`, to ensure that they do not outlive the repository //! itself. #![doc(html_root_url = "http://alexcrichton.com/git2-rs")] #![allow(trivial_numeric_casts, trivial_casts)] #![deny(missing_docs)] #![cfg_attr(test, deny(warnings))] #![cfg_attr(feature = "unstable", feature(catch_panic))] extern crate libc; extern crate url; extern crate libgit2_sys as raw; #[macro_use] extern crate bitflags; #[cfg(test)] extern crate tempdir; use std::ffi::{CStr, CString}; use std::fmt; use std::str; use std::sync::{Once, ONCE_INIT}; pub use blame::{Blame, BlameHunk, BlameIter, BlameOptions}; pub use blob::Blob; pub use branch::{Branch, Branches}; pub use buf::Buf; pub use commit::{Commit, Parents}; pub use config::{Config, ConfigEntry, ConfigEntries}; pub use cred::{Cred, CredentialHelper}; pub use describe::{Describe, DescribeFormatOptions, DescribeOptions}; pub use diff::{Diff, DiffDelta, DiffFile, DiffOptions, Deltas}; pub use diff::{DiffLine, DiffHunk, DiffStats, DiffFindOptions}; pub use merge::{AnnotatedCommit, MergeOptions}; pub use error::Error; pub use index::{Index, IndexEntry, IndexEntries, IndexMatchedPath}; pub use note::{Note, Notes}; pub use object::Object; pub use oid::Oid; pub use pathspec::{Pathspec, PathspecMatchList, PathspecFailedEntries}; pub use pathspec::{PathspecDiffEntries, PathspecEntries}; pub use reference::{Reference, References, ReferenceNames}; pub use reflog::{Reflog, ReflogEntry, ReflogIter}; pub use refspec::Refspec; pub use remote::{Remote, Refspecs, RemoteHead, FetchOptions, PushOptions}; pub use remote_callbacks::{RemoteCallbacks, Credentials, TransferProgress}; pub use remote_callbacks::{TransportMessage, Progress, UpdateTips}; pub use repo::{Repository, RepositoryInitOptions}; pub use revspec::Revspec; pub use revwalk::Revwalk; pub use signature::Signature; pub use status::{StatusOptions, Statuses, StatusIter, StatusEntry, StatusShow}; pub use submodule::Submodule; pub use tag::Tag; pub use time::{Time, IndexTime}; pub use tree::{Tree, TreeEntry, TreeIter}; pub use treebuilder::TreeBuilder; pub use util::IntoCString; /// An enumeration of possible errors that can happen when working with a git /// repository. #[derive(PartialEq, Eq, Clone, Debug, Copy)] pub enum ErrorCode { /// Generic error GenericError, /// Requested object could not be found NotFound, /// Object exists preventing operation Exists, /// More than one object matches Ambiguous, /// Output buffer too short to hold data BufSize, /// User-generated error User, /// Operation not allowed on bare repository BareRepo, /// HEAD refers to branch with no commits UnbornBranch, /// Merge in progress prevented operation Unmerged, /// Reference was not fast-forwardable NotFastForward, /// Name/ref spec was not in a valid format InvalidSpec, /// Checkout conflicts prevented operation Conflict, /// Lock file prevented operation Locked, /// Reference value does not match expected Modified, /// Authentication error Auth, /// Server certificate is invalid Certificate, /// Patch/merge has already been applied Applied, /// The requested peel operation is not possible Peel, /// Unexpected EOF Eof, /// Invalid operation or input Invalid, /// Uncommitted changes in index prevented operation Uncommitted, /// Operation was not valid for a directory, Directory, } /// An enumeration of possible categories of things that can have /// errors when working with a git repository. #[derive(PartialEq, Eq, Clone, Debug, Copy)] pub enum ErrorClass { /// Uncategorized None, /// Out of memory or insufficient allocated space NoMemory, /// Syscall or standard system library error Os, /// Invalid input Invalid, /// Error resolving or manipulating a reference Reference, /// ZLib failure Zlib, /// Bad repository state Repository, /// Bad configuration Config, /// Regex failure Regex, /// Bad object Odb, /// Invalid index data Index, /// Error creating or obtaining an object Object, /// Network error Net, /// Error manpulating a tag Tag, /// Invalid value in tree Tree, /// Hashing or packing error Indexer, /// Error from SSL Ssl, /// Error involing submodules Submodule, /// Threading error Thread, /// Error manipulating a stash Stash, /// Checkout failure Checkout, /// Invalid FETCH_HEAD FetchHead, /// Merge failure Merge, /// SSH failure Ssh, /// Error manipulating filters Filter, /// Error reverting commit Revert, /// Error from a user callback Callback, /// Error cherry-picking commit CherryPick, /// Can't describe object Describe, /// Error during rebase Rebase, /// Filesystem-related error Filesystem, } /// A listing of the possible states that a repository can be in. #[derive(PartialEq, Eq, Clone, Debug, Copy)] #[allow(missing_docs)] pub enum RepositoryState { Clean, Merge, Revert, CherryPick, Bisect, Rebase, RebaseInteractive, RebaseMerge, ApplyMailbox, ApplyMailboxOrRebase, } /// An enumeration of the possible directions for a remote. #[derive(Copy, Clone)] pub enum Direction { /// Data will be fetched (read) from this remote. Fetch, /// Data will be pushed (written) to this remote. Push, } /// An enumeration of the operations that can be performed for the `reset` /// method on a `Repository`. #[derive(Copy, Clone)] pub enum ResetType { /// Move the head to the given commit. Soft, /// Soft plus reset the index to the commit. Mixed, /// Mixed plus changes in the working tree are discarded. Hard, } /// An enumeration all possible kinds objects may have. #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum ObjectType { /// An object which corresponds to a any git object Any, /// An object which corresponds to a git commit Commit, /// An object which corresponds to a git tree Tree, /// An object which corresponds to a git blob Blob, /// An object which corresponds to a git tag Tag, } /// An enumeration for the possible types of branches #[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum BranchType { /// A local branch not on a remote. Local, /// A branch for a remote. Remote, } /// An enumeration of the possible priority levels of a config file. /// /// The levels corresponding to the escalation logic (higher to lower) when /// searching for config entries. #[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum ConfigLevel { /// System-wide configuration file, e.g. /etc/gitconfig System, /// XDG-compatible configuration file, e.g. ~/.config/git/config XDG, /// User-specific configuration, e.g. ~/.gitconfig Global, /// Reopsitory specific config, e.g. $PWD/.git/config Local, /// Application specific configuration file App, /// Highest level available Highest, } /// Merge file favor options for `MergeOptions` instruct the file-level /// merging functionality how to deal with conflicting regions of the files. #[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum FileFavor { /// When a region of a file is changed in both branches, a conflict will be /// recorded in the index so that git_checkout can produce a merge file with /// conflict markers in the working directory. This is the default. Normal, /// When a region of a file is changed in both branches, the file created /// in the index will contain the "ours" side of any conflicting region. /// The index will not record a conflict. Ours, /// When a region of a file is changed in both branches, the file created /// in the index will contain the "theirs" side of any conflicting region. /// The index will not record a conflict. Theirs, /// When a region of a file is changed in both branches, the file created /// in the index will contain each unique line from each side, which has /// the result of combining both files. The index will not record a conflict. Union, } bitflags! { #[doc = " Orderings that may be specified for Revwalk iteration. "] flags Sort: u32 { /// Sort the repository contents in no particular ordering. /// /// This sorting is arbitrary, implementation-specific, and subject to /// change at any time. This is the default sorting for new walkers. const SORT_NONE = raw::GIT_SORT_NONE as u32, /// Sort the repository contents in topological order (parents before /// children). /// /// This sorting mode can be combined with time sorting. const SORT_TOPOLOGICAL = raw::GIT_SORT_TOPOLOGICAL as u32, /// Sort the repository contents by commit time. /// /// This sorting mode can be combined with topological sorting. const SORT_TIME = raw::GIT_SORT_TIME as u32, /// Iterate through the repository contents in reverse order. /// /// This sorting mode can be combined with any others. const SORT_REVERSE = raw::GIT_SORT_REVERSE as u32, } } bitflags! { #[doc = " Types of credentials that can be requested by a credential callback. "] flags CredentialType: u32 { #[allow(missing_docs)] const USER_PASS_PLAINTEXT = raw::GIT_CREDTYPE_USERPASS_PLAINTEXT as u32, #[allow(missing_docs)] const SSH_KEY = raw::GIT_CREDTYPE_SSH_KEY as u32, #[allow(missing_docs)] const SSH_MEMORY = raw::GIT_CREDTYPE_SSH_MEMORY as u32, #[allow(missing_docs)] const SSH_CUSTOM = raw::GIT_CREDTYPE_SSH_CUSTOM as u32, #[allow(missing_docs)] const DEFAULT = raw::GIT_CREDTYPE_DEFAULT as u32, #[allow(missing_docs)] const SSH_INTERACTIVE = raw::GIT_CREDTYPE_SSH_INTERACTIVE as u32, #[allow(missing_docs)] const USERNAME = raw::GIT_CREDTYPE_USERNAME as u32, } } bitflags! { #[doc = " Flags for APIs that add files matching pathspec "] flags IndexAddOption: u32 { #[allow(missing_docs)] const ADD_DEFAULT = raw::GIT_INDEX_ADD_DEFAULT as u32, #[allow(missing_docs)] const ADD_FORCE = raw::GIT_INDEX_ADD_FORCE as u32, #[allow(missing_docs)] const ADD_DISABLE_PATHSPEC_MATCH = raw::GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH as u32, #[allow(missing_docs)] const ADD_CHECK_PATHSPEC = raw::GIT_INDEX_ADD_CHECK_PATHSPEC as u32, } } bitflags! { #[doc = " Flags for the return value of `Repository::revparse` "] flags RevparseMode: u32 { /// The spec targeted a single object const REVPARSE_SINGLE = raw::GIT_REVPARSE_SINGLE as u32, /// The spec targeted a range of commits const REVPARSE_RANGE = raw::GIT_REVPARSE_RANGE as u32, /// The spec used the `...` operator, which invokes special semantics. const REVPARSE_MERGE_BASE = raw::GIT_REVPARSE_MERGE_BASE as u32, } } #[cfg(test)] #[macro_use] mod test; #[macro_use] mod panic; mod call; mod util; pub mod build; pub mod cert; pub mod string_array; pub mod oid_array; pub mod transport; mod blame; mod blob; mod branch; mod buf; mod commit; mod config; mod cred; mod describe; mod diff; mod merge; mod error; mod index; mod note; mod object; mod oid; mod pathspec; mod reference; mod reflog; mod refspec; mod remote; mod remote_callbacks; mod repo; mod revspec; mod revwalk; mod signature; mod status; mod submodule; mod tag; mod time; mod tree; mod treebuilder; fn init() { static INIT: Once = ONCE_INIT; INIT.call_once(|| unsafe { raw::openssl_init(); let r = raw::git_libgit2_init(); assert!(r >= 0, "couldn't initialize the libgit2 library: {}", r); assert_eq!(libc::atexit(shutdown), 0); }); extern fn shutdown() { unsafe { raw::git_libgit2_shutdown(); } } } unsafe fn opt_bytes<'a, T>(_anchor: &'a T, c: *const libc::c_char) -> Option<&'a [u8]> { if c.is_null() { None } else { Some(CStr::from_ptr(c).to_bytes()) } } fn opt_cstr(o: Option) -> Result, Error> { match o { Some(s) => s.into_c_string().map(Some), None => Ok(None) } } impl ObjectType { /// Convert an object type to its string representation. pub fn str(&self) -> &'static str { unsafe { let ptr = call!(raw::git_object_type2string(*self)) as *const _; let data = CStr::from_ptr(ptr).to_bytes(); str::from_utf8(data).unwrap() } } /// Determine if the given git_otype is a valid loose object type. pub fn is_loose(&self) -> bool { unsafe { (call!(raw::git_object_typeisloose(*self)) == 1) } } /// Convert a raw git_otype to an ObjectType pub fn from_raw(raw: raw::git_otype) -> Option { match raw { raw::GIT_OBJ_ANY => Some(ObjectType::Any), raw::GIT_OBJ_COMMIT => Some(ObjectType::Commit), raw::GIT_OBJ_TREE => Some(ObjectType::Tree), raw::GIT_OBJ_BLOB => Some(ObjectType::Blob), raw::GIT_OBJ_TAG => Some(ObjectType::Tag), _ => None, } } /// Convert this kind into its raw representation pub fn raw(&self) -> raw::git_otype { call::convert(self) } /// Convert a string object type representation to its object type. pub fn from_str(s: &str) -> Option { let raw = unsafe { call!(raw::git_object_string2type(CString::new(s).unwrap())) }; ObjectType::from_raw(raw) } } impl fmt::Display for ObjectType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.str().fmt(f) } } impl ConfigLevel { /// Converts a raw configuration level to a ConfigLevel pub fn from_raw(raw: raw::git_config_level_t) -> ConfigLevel { match raw { raw::GIT_CONFIG_LEVEL_SYSTEM => ConfigLevel::System, raw::GIT_CONFIG_LEVEL_XDG => ConfigLevel::XDG, raw::GIT_CONFIG_LEVEL_GLOBAL => ConfigLevel::Global, raw::GIT_CONFIG_LEVEL_LOCAL => ConfigLevel::Local, raw::GIT_CONFIG_LEVEL_APP => ConfigLevel::App, raw::GIT_CONFIG_HIGHEST_LEVEL => ConfigLevel::Highest, n => panic!("unknown config level: {}", n), } } } bitflags! { /// Status flags for a single file /// /// A combination of these values will be returned to indicate the status of /// a file. Status compares the working directory, the index, and the /// current HEAD of the repository. The `STATUS_INDEX_*` set of flags /// represents the status of file in the index relative to the HEAD, and the /// `STATUS_WT_*` set of flags represent the status of the file in the /// working directory relative to the index. flags Status: u32 { #[allow(missing_docs)] const STATUS_CURRENT = raw::GIT_STATUS_CURRENT as u32, #[allow(missing_docs)] const STATUS_INDEX_NEW = raw::GIT_STATUS_INDEX_NEW as u32, #[allow(missing_docs)] const STATUS_INDEX_MODIFIED = raw::GIT_STATUS_INDEX_MODIFIED as u32, #[allow(missing_docs)] const STATUS_INDEX_DELETED = raw::GIT_STATUS_INDEX_DELETED as u32, #[allow(missing_docs)] const STATUS_INDEX_RENAMED = raw::GIT_STATUS_INDEX_RENAMED as u32, #[allow(missing_docs)] const STATUS_INDEX_TYPECHANGE = raw::GIT_STATUS_INDEX_TYPECHANGE as u32, #[allow(missing_docs)] const STATUS_WT_NEW = raw::GIT_STATUS_WT_NEW as u32, #[allow(missing_docs)] const STATUS_WT_MODIFIED = raw::GIT_STATUS_WT_MODIFIED as u32, #[allow(missing_docs)] const STATUS_WT_DELETED = raw::GIT_STATUS_WT_DELETED as u32, #[allow(missing_docs)] const STATUS_WT_TYPECHANGE = raw::GIT_STATUS_WT_TYPECHANGE as u32, #[allow(missing_docs)] const STATUS_WT_RENAMED = raw::GIT_STATUS_WT_RENAMED as u32, #[allow(missing_docs)] const STATUS_IGNORED = raw::GIT_STATUS_IGNORED as u32, #[allow(missing_docs)] const STATUS_CONFLICTED = raw::GIT_STATUS_CONFLICTED as u32, } } bitflags! { #[doc = " Mode options for RepositoryInitOptions "] flags RepositoryInitMode: u32 { /// Use permissions configured by umask - the default const REPOSITORY_INIT_SHARED_UMASK = raw::GIT_REPOSITORY_INIT_SHARED_UMASK as u32, /// Use `--shared=group` behavior, chmod'ing the new repo to be /// group writable and \"g+sx\" for sticky group assignment const REPOSITORY_INIT_SHARED_GROUP = raw::GIT_REPOSITORY_INIT_SHARED_GROUP as u32, /// Use `--shared=all` behavior, adding world readability. const REPOSITORY_INIT_SHARED_ALL = raw::GIT_REPOSITORY_INIT_SHARED_ALL as u32, } } /// What type of change is described by a `DiffDelta`? #[derive(Copy, Clone, Debug)] pub enum Delta { /// No changes Unmodified, /// Entry does not exist in old version Added, /// Entry does not exist in new version Deleted, /// Entry content changed between old and new Modified, /// Entry was renamed wbetween old and new Renamed, /// Entry was copied from another old entry Copied, /// Entry is ignored item in workdir Ignored, /// Entry is untracked item in workdir Untracked, /// Type of entry changed between old and new Typechange, /// Entry is unreadable Unreadable, /// Entry in the index is conflicted Conflicted, } bitflags! { #[doc = r#" Return codes for submodule status. A combination of these flags will be returned to describe the status of a submodule. Depending on the "ignore" property of the submodule, some of the flags may never be returned because they indicate changes that are supposed to be ignored. Submodule info is contained in 4 places: the HEAD tree, the index, config files (both .git/config and .gitmodules), and the working directory. Any or all of those places might be missing information about the submodule depending on what state the repo is in. We consider all four places to build the combination of status flags. There are four values that are not really status, but give basic info about what sources of submodule data are available. These will be returned even if ignore is set to "ALL". * IN_HEAD - superproject head contains submodule * IN_INDEX - superproject index contains submodule * IN_CONFIG - superproject gitmodules has submodule * IN_WD - superproject workdir has submodule The following values will be returned so long as ignore is not "ALL". * INDEX_ADDED - in index, not in head * INDEX_DELETED - in head, not in index * INDEX_MODIFIED - index and head don't match * WD_UNINITIALIZED - workdir contains empty directory * WD_ADDED - in workdir, not index * WD_DELETED - in index, not workdir * WD_MODIFIED - index and workdir head don't match The following can only be returned if ignore is "NONE" or "UNTRACKED". * WD_INDEX_MODIFIED - submodule workdir index is dirty * WD_WD_MODIFIED - submodule workdir has modified files Lastly, the following will only be returned for ignore "NONE". * WD_UNTRACKED - wd contains untracked files "#] flags SubmoduleStatus: u32 { #[allow(missing_docs)] const SUBMODULE_STATUS_IN_HEAD = raw::GIT_SUBMODULE_STATUS_IN_HEAD as u32, #[allow(missing_docs)] const SUBMODULE_STATUS_IN_INDEX = raw::GIT_SUBMODULE_STATUS_IN_INDEX as u32, #[allow(missing_docs)] const SUBMODULE_STATUS_IN_CONFIG = raw::GIT_SUBMODULE_STATUS_IN_CONFIG as u32, #[allow(missing_docs)] const SUBMODULE_STATUS_IN_WD = raw::GIT_SUBMODULE_STATUS_IN_WD as u32, #[allow(missing_docs)] const SUBMODULE_STATUS_INDEX_ADDED = raw::GIT_SUBMODULE_STATUS_INDEX_ADDED as u32, #[allow(missing_docs)] const SUBMODULE_STATUS_INDEX_DELETED = raw::GIT_SUBMODULE_STATUS_INDEX_DELETED as u32, #[allow(missing_docs)] const SUBMODULE_STATUS_INDEX_MODIFIED = raw::GIT_SUBMODULE_STATUS_INDEX_MODIFIED as u32, #[allow(missing_docs)] const SUBMODULE_STATUS_WD_UNINITIALIZED = raw::GIT_SUBMODULE_STATUS_WD_UNINITIALIZED as u32, #[allow(missing_docs)] const SUBMODULE_STATUS_WD_ADDED = raw::GIT_SUBMODULE_STATUS_WD_ADDED as u32, #[allow(missing_docs)] const SUBMODULE_STATUS_WD_DELETED = raw::GIT_SUBMODULE_STATUS_WD_DELETED as u32, #[allow(missing_docs)] const SUBMODULE_STATUS_WD_MODIFIED = raw::GIT_SUBMODULE_STATUS_WD_MODIFIED as u32, #[allow(missing_docs)] const SUBMODULE_STATUS_WD_INDEX_MODIFIED = raw::GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED as u32, #[allow(missing_docs)] const SUBMODULE_STATUS_WD_WD_MODIFIED = raw::GIT_SUBMODULE_STATUS_WD_WD_MODIFIED as u32, #[allow(missing_docs)] const SUBMODULE_STATUS_WD_UNTRACKED = raw::GIT_SUBMODULE_STATUS_WD_UNTRACKED as u32, } } /// Submodule ignore values /// /// These values represent settings for the `submodule.$name.ignore` /// configuration value which says how deeply to look at the working /// directory when getting the submodule status. pub enum SubmoduleIgnore { /// Use the submodule's configuration Unspecified, /// Any change or untracked file is considered dirty None, /// Only dirty if tracked files have changed Untracked, /// Only dirty if HEAD has moved Dirty, /// Never dirty All, } bitflags! { /// ... flags PathspecFlags: u32 { /// Use the default pathspec matching configuration. const PATHSPEC_DEFAULT = raw::GIT_PATHSPEC_DEFAULT as u32, /// Force matching to ignore case, otherwise matching will use native /// case sensitivity fo the platform filesystem. const PATHSPEC_IGNORE_CASE = raw::GIT_PATHSPEC_IGNORE_CASE as u32, /// Force case sensitive matches, otherwise match will use the native /// case sensitivity of the platform filesystem. const PATHSPEC_USE_CASE = raw::GIT_PATHSPEC_USE_CASE as u32, /// Disable glob patterns and just use simple string comparison for /// matching. const PATHSPEC_NO_GLOB = raw::GIT_PATHSPEC_NO_GLOB as u32, /// Means that match functions return the error code `NotFound` if no /// matches are found. By default no matches is a success. const PATHSPEC_NO_MATCH_ERROR = raw::GIT_PATHSPEC_NO_MATCH_ERROR as u32, /// Means that the list returned should track which patterns matched /// which files so that at the end of the match we can identify patterns /// that did not match any files. const PATHSPEC_FIND_FAILURES = raw::GIT_PATHSPEC_FIND_FAILURES as u32, /// Means that the list returned does not need to keep the actual /// matching filenames. Use this to just test if there were any matches /// at all or in combination with `PATHSPEC_FAILURES` to validate a /// pathspec. const PATHSPEC_FAILURES_ONLY = raw::GIT_PATHSPEC_FAILURES_ONLY as u32, } } /// Possible output formats for diff data #[derive(Copy, Clone)] pub enum DiffFormat { /// full git diff Patch, /// just the headers of the patch PatchHeader, /// like git diff --raw Raw, /// like git diff --name-only NameOnly, /// like git diff --name-status NameStatus, } bitflags! { /// Formatting options for diff stats flags DiffStatsFormat: raw::git_diff_stats_format_t { /// Don't generate any stats const DIFF_STATS_NONE = raw::GIT_DIFF_STATS_NONE, /// Equivalent of `--stat` in git const DIFF_STATS_FULL = raw::GIT_DIFF_STATS_FULL, /// Equivalent of `--shortstat` in git const DIFF_STATS_SHORT = raw::GIT_DIFF_STATS_SHORT, /// Equivalent of `--numstat` in git const DIFF_STATS_NUMBER = raw::GIT_DIFF_STATS_NUMBER, /// Extended header information such as creations, renames and mode /// changes, equivalent of `--summary` in git const DIFF_STATS_INCLUDE_SUMMARY = raw::GIT_DIFF_STATS_INCLUDE_SUMMARY, } } /// Automatic tag following options. pub enum AutotagOption { /// Use the setting from the remote's configuration Unspecified, /// Ask the server for tags pointing to objects we're already downloading Auto, /// Don't ask for any tags beyond the refspecs None, /// Ask for all the tags All, } /// Configuration for how pruning is done on a fetch pub enum FetchPrune { /// Use the setting from the configuration Unspecified, /// Force pruning on On, /// Force pruning off Off, } #[cfg(test)] mod tests { use super::ObjectType; #[test] fn convert() { assert_eq!(ObjectType::Blob.str(), "blob"); assert_eq!(ObjectType::from_str("blob"), Some(ObjectType::Blob)); assert!(ObjectType::Blob.is_loose()); } } deps/git2-0.3.3/src/note.rs0000664000175000017500000000734612517471774012372 0ustar use std::marker; use std::str; use {raw, signature, Signature, Oid, Repository}; use util::Binding; /// A structure representing a [note][note] in git. /// /// [note]: http://git-scm.com/blog/2010/08/25/notes.html pub struct Note<'repo> { raw: *mut raw::git_note, // Hmm, the current libgit2 version does not have this inside of it, but // perhaps it's a good idea to keep it around? Can always remove it later I // suppose... _marker: marker::PhantomData<&'repo Repository>, } /// An iterator over all of the notes within a repository. pub struct Notes<'repo> { raw: *mut raw::git_note_iterator, _marker: marker::PhantomData<&'repo Repository>, } impl<'repo> Note<'repo> { /// Get the note author pub fn author(&self) -> Signature { unsafe { signature::from_raw_const(self, raw::git_note_author(&*self.raw)) } } /// Get the note committer pub fn committer(&self) -> Signature { unsafe { signature::from_raw_const(self, raw::git_note_committer(&*self.raw)) } } /// Get the note message, in bytes. pub fn message_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, raw::git_note_message(&*self.raw)).unwrap() } } /// Get the note message as a string, returning `None` if it is not UTF-8. pub fn message(&self) -> Option<&str> { str::from_utf8(self.message_bytes()).ok() } /// Get the note object's id pub fn id(&self) -> Oid { unsafe { Binding::from_raw(raw::git_note_id(&*self.raw)) } } } impl<'repo> Binding for Note<'repo> { type Raw = *mut raw::git_note; unsafe fn from_raw(raw: *mut raw::git_note) -> Note<'repo> { Note { raw: raw, _marker: marker::PhantomData, } } fn raw(&self) -> *mut raw::git_note { self.raw } } impl<'repo> Drop for Note<'repo> { fn drop(&mut self) { unsafe { raw::git_note_free(self.raw); } } } impl<'repo> Binding for Notes<'repo> { type Raw = *mut raw::git_note_iterator; unsafe fn from_raw(raw: *mut raw::git_note_iterator) -> Notes<'repo> { Notes { raw: raw, _marker: marker::PhantomData, } } fn raw(&self) -> *mut raw::git_note_iterator { self.raw } } impl<'repo> Iterator for Notes<'repo> { type Item = (Oid, Oid); fn next(&mut self) -> Option<(Oid, Oid)> { let mut note_id = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; let mut annotated_id = note_id; unsafe { match raw::git_note_next(&mut note_id, &mut annotated_id, self.raw) { 0 => Some((Binding::from_raw(¬e_id as *const _), Binding::from_raw(&annotated_id as *const _))), _ => None, } } } } impl<'repo> Drop for Notes<'repo> { fn drop(&mut self) { unsafe { raw::git_note_iterator_free(self.raw); } } } #[cfg(test)] mod tests { #[test] fn smoke() { let (_td, repo) = ::test::repo_init(); assert!(repo.notes(None).is_err()); let sig = repo.signature().unwrap(); let head = repo.head().unwrap().target().unwrap(); let note = repo.note(&sig, &sig, None, head, "foo", false).unwrap(); assert_eq!(repo.notes(None).unwrap().count(), 1); let note_obj = repo.find_note(None, head).unwrap(); assert_eq!(note_obj.id(), note); assert_eq!(note_obj.message(), Some("foo")); let (a, b) = repo.notes(None).unwrap().next().unwrap(); assert_eq!(a, note); assert_eq!(b, head); assert_eq!(repo.note_default_ref().unwrap(), "refs/notes/commits"); assert_eq!(sig.name(), note_obj.author().name()); assert_eq!(sig.name(), note_obj.committer().name()); assert!(sig.when() == note_obj.committer().when()); } } deps/git2-0.3.3/src/transport.rs0000664000175000017500000002740512623026431013437 0ustar //! Interfaces for adding custom transports to libgit2 use std::ffi::{CStr, CString}; use std::io::prelude::*; use std::io; use std::mem; use std::slice; use std::str; use libc::{c_int, c_void, c_uint, c_char, size_t}; use {raw, Error, Remote}; use util::Binding; /// A transport is a structure which knows how to transfer data to and from a /// remote. /// /// This transport is a representation of the raw transport underneath it, which /// is similar to a trait object in Rust. #[allow(missing_copy_implementations)] pub struct Transport { raw: *mut raw::git_transport, owned: bool, } /// Interfaced used by smart transports. /// /// The full-fledged definiton of transports has to deal with lots of /// nitty-gritty details of the git protocol, but "smart transports" largely /// only need to deal with read() and write() of data over a channel. /// /// A smart subtransport is contained within an instance of a smart transport /// and is delegated to in order to actually conduct network activity to push or /// pull data from a remote. pub trait SmartSubtransport: Send + 'static { /// Indicates that this subtransport will be performing the specified action /// on the specified URL. /// /// This function is responsible for making any network connections and /// returns a stream which can be read and written from in order to /// negotiate the git protocol. fn action(&self, url: &str, action: Service) -> Result, Error>; /// Terminates a connection with the remote. /// /// Each subtransport is guaranteed a call to close() between calls to /// action(), except for the following tow natural progressions of actions /// against a constant URL. /// /// 1. UploadPackLs -> UploadPack /// 2. ReceivePackLs -> ReceivePack fn close(&self) -> Result<(), Error>; } /// Actions that a smart transport can ask a subtransport to perform #[derive(Copy, Clone)] #[allow(missing_docs)] pub enum Service { UploadPackLs, UploadPack, ReceivePackLs, ReceivePack, } /// An instance of a stream over which a smart transport will communicate with a /// remote. /// /// Currently this only requires the standard `Read` and `Write` traits. This /// trait also does not need to be implemented manually as long as the `Read` /// and `Write` traits are implemented. pub trait SmartSubtransportStream: Read + Write + Send + 'static {} impl SmartSubtransportStream for T {} type TransportFactory = Fn(&Remote) -> Result + Send + Sync + 'static; /// Boxed data payload used for registering new transports. /// /// Currently only contains a field which knows how to create transports. struct TransportData { factory: Box, } /// Instance of a `git_smart_subtransport`, must use `#[repr(C)]` to ensure that /// the C fields come first. #[repr(C)] struct RawSmartSubtransport { raw: raw::git_smart_subtransport, obj: Box, } /// Instance of a `git_smart_subtransport_stream`, must use `#[repr(C)]` to /// ensure that the C fields come first. #[repr(C)] struct RawSmartSubtransportStream { raw: raw::git_smart_subtransport_stream, obj: Box, } /// Add a custom transport definition, to be used in addition to the built-in /// set of transports that come with libgit2. /// /// This function is unsafe as it needs to be externally synchronized with calls /// to creation of other transports. pub unsafe fn register(prefix: &str, factory: F) -> Result<(), Error> where F: Fn(&Remote) -> Result + Send + Sync + 'static { let mut data = Box::new(TransportData { factory: Box::new(factory), }); let prefix = try!(CString::new(prefix)); let datap = (&mut *data) as *mut TransportData as *mut c_void; try_call!(raw::git_transport_register(prefix, transport_factory, datap)); mem::forget(data); Ok(()) } impl Transport { /// Creates a new transport which will use the "smart" transport protocol /// for transferring data. /// /// A smart transport requires a *subtransport* over which data is actually /// communicated, but this subtransport largely just needs to be able to /// read() and write(). The subtransport provided will be used to make /// connections which can then be read/written from. /// /// The `rpc` argument is `true` if the protocol is stateless, false /// otherwise. For example `http://` is stateless but `git://` is not. pub fn smart(remote: &Remote, rpc: bool, subtransport: S) -> Result where S: SmartSubtransport { let mut ret = 0 as *mut _; let mut raw = Box::new(RawSmartSubtransport { raw: raw::git_smart_subtransport { action: subtransport_action, close: subtransport_close, free: subtransport_free, }, obj: Box::new(subtransport), }); let mut defn = raw::git_smart_subtransport_definition { callback: smart_factory, rpc: rpc as c_uint, param: &mut *raw as *mut _ as *mut _, }; // Currently there's no way to pass a paload via the // git_smart_subtransport_definition structure, but it's only used as a // configuration for the initial creation of the smart transport (verified // by reading the current code, hopefully it doesn't change!). // // We, however, need some state (gotta pass in our // `RawSmartSubtransport`). This also means that this block must be // entirely synchronized with a lock (boo!) unsafe { try_call!(raw::git_transport_smart(&mut ret, remote.raw(), &mut defn as *mut _ as *mut _)); mem::forget(raw); // ownership transport to `ret` } return Ok(Transport { raw: ret, owned: true }); extern fn smart_factory(out: *mut *mut raw::git_smart_subtransport, _owner: *mut raw::git_transport, ptr: *mut c_void) -> c_int { unsafe { *out = ptr as *mut raw::git_smart_subtransport; 0 } } } } impl Drop for Transport { fn drop(&mut self) { if self.owned { unsafe { ((*self.raw).free)(self.raw) } } } } // callback used by register() to create new transports wrap_env! { fn transport_factory(out: *mut *mut raw::git_transport, owner: *mut raw::git_remote, param: *mut c_void) -> c_int {{ struct Bomb<'a> { remote: Option> } impl<'a> Drop for Bomb<'a> { fn drop(&mut self) { // TODO: maybe a method instead? mem::forget(self.remote.take()); } } unsafe { let remote = Bomb { remote: Some(Binding::from_raw(owner)) }; let data = &mut *(param as *mut TransportData); match (data.factory)(remote.remote.as_ref().unwrap()) { Ok(mut transport) => { *out = transport.raw; transport.owned = false; 0 } Err(e) => e.raw_code() as c_int, } } }} returning ret as ret.unwrap_or(-1) } // callback used by smart transports to delegate an action to a // `SmartSubtransport` trait object. wrap_env! { fn subtransport_action(stream: *mut *mut raw::git_smart_subtransport_stream, raw_transport: *mut raw::git_smart_subtransport, url: *const c_char, action: raw::git_smart_service_t) -> c_int { unsafe { let url = CStr::from_ptr(url).to_bytes(); let url = match str::from_utf8(url).ok() { Some(s) => s, None => return -1, }; let action = match action { raw::GIT_SERVICE_UPLOADPACK_LS => Service::UploadPackLs, raw::GIT_SERVICE_UPLOADPACK => Service::UploadPack, raw::GIT_SERVICE_RECEIVEPACK_LS => Service::ReceivePackLs, raw::GIT_SERVICE_RECEIVEPACK => Service::ReceivePack, n => panic!("unknown action: {}", n), }; let transport = &mut *(raw_transport as *mut RawSmartSubtransport); let obj = match transport.obj.action(url, action) { Ok(s) => s, Err(e) => return e.raw_code() as c_int, }; *stream = mem::transmute(Box::new(RawSmartSubtransportStream { raw: raw::git_smart_subtransport_stream { subtransport: raw_transport, read: stream_read, write: stream_write, free: stream_free, }, obj: obj, })); 0 } } returning ret as ret.unwrap_or(-1) } // callback used by smart transports to close a `SmartSubtransport` trait // object. wrap_env! { fn subtransport_close(transport: *mut raw::git_smart_subtransport) -> c_int { unsafe { let transport = &mut *(transport as *mut RawSmartSubtransport); transport.obj.close() } } returning ret as { match ret { Some(Ok(())) => 0, Some(Err(e)) => e.raw_code() as c_int, None => -1, } } } // callback used by smart transports to free a `SmartSubtransport` trait // object. extern fn subtransport_free(transport: *mut raw::git_smart_subtransport) { unsafe { mem::transmute::<_, Box>(transport); } } // callback used by smart transports to read from a `SmartSubtransportStream` // object. wrap_env! { fn stream_read(stream: *mut raw::git_smart_subtransport_stream, buffer: *mut c_char, buf_size: size_t, bytes_read: *mut size_t) -> c_int { unsafe { let transport = &mut *(stream as *mut RawSmartSubtransportStream); let buf = slice::from_raw_parts_mut(buffer as *mut u8, buf_size as usize); match transport.obj.read(buf) { Ok(n) => { *bytes_read = n as size_t; Ok(n) } e => e, } } } returning ret as unsafe { match ret { Some(Ok(_)) => 0, Some(Err(e)) => { set_err(e); -2 } None => -1, } } } // callback used by smart transports to write to a `SmartSubtransportStream` // object. wrap_env! { fn stream_write(stream: *mut raw::git_smart_subtransport_stream, buffer: *const c_char, len: size_t) -> c_int { unsafe { let transport = &mut *(stream as *mut RawSmartSubtransportStream); let buf = slice::from_raw_parts(buffer as *const u8, len as usize); transport.obj.write_all(buf) } } returning ret as unsafe { match ret { Some(Ok(())) => 0, Some(Err(e)) => { set_err(e); -2 } None => -1, } } } unsafe fn set_err(e: io::Error) { let s = CString::new(e.to_string()).unwrap(); raw::giterr_set_str(raw::GITERR_NET as c_int, s.as_ptr()) } // callback used by smart transports to free a `SmartSubtransportStream` // object. extern fn stream_free(stream: *mut raw::git_smart_subtransport_stream) { unsafe { mem::transmute::<_, Box>(stream); } } deps/git2-0.3.3/src/error.rs0000664000175000017500000001761712623026524012543 0ustar use std::ffi::{CStr, NulError}; use std::error; use std::fmt; use std::str; use libc::c_int; use {raw, ErrorClass, ErrorCode}; /// A structure to represent errors coming out of libgit2. #[derive(Debug)] pub struct Error { code: c_int, klass: c_int, message: String, } impl Error { /// Returns the last error, or `None` if one is not available. pub fn last_error(code: c_int) -> Option { ::init(); unsafe { let ptr = raw::giterr_last(); if ptr.is_null() { None } else { Some(Error::from_raw(code, ptr)) } } } unsafe fn from_raw(code: c_int, ptr: *const raw::git_error) -> Error { let msg = CStr::from_ptr((*ptr).message as *const _).to_bytes(); let msg = str::from_utf8(msg).unwrap(); Error { code: code, klass: (*ptr).klass, message: msg.to_string() } } /// Creates a new error from the given string as the error. pub fn from_str(s: &str) -> Error { Error { code: raw::GIT_ERROR as c_int, klass: raw::GITERR_NONE as c_int, message: s.to_string(), } } /// Return the error code associated with this error. pub fn code(&self) -> ErrorCode { match self.raw_code() { raw::GIT_OK => super::ErrorCode::GenericError, raw::GIT_ERROR => super::ErrorCode::GenericError, raw::GIT_ENOTFOUND => super::ErrorCode::NotFound, raw::GIT_EEXISTS => super::ErrorCode::Exists, raw::GIT_EAMBIGUOUS => super::ErrorCode::Ambiguous, raw::GIT_EBUFS => super::ErrorCode::BufSize, raw::GIT_EUSER => super::ErrorCode::User, raw::GIT_EBAREREPO => super::ErrorCode::BareRepo, raw::GIT_EUNBORNBRANCH => super::ErrorCode::UnbornBranch, raw::GIT_EUNMERGED => super::ErrorCode::Unmerged, raw::GIT_ENONFASTFORWARD => super::ErrorCode::NotFastForward, raw::GIT_EINVALIDSPEC => super::ErrorCode::InvalidSpec, raw::GIT_ECONFLICT => super::ErrorCode::Conflict, raw::GIT_ELOCKED => super::ErrorCode::Locked, raw::GIT_EMODIFIED => super::ErrorCode::Modified, raw::GIT_PASSTHROUGH => super::ErrorCode::GenericError, raw::GIT_ITEROVER => super::ErrorCode::GenericError, raw::GIT_EAUTH => super::ErrorCode::Auth, raw::GIT_ECERTIFICATE => super::ErrorCode::Certificate, raw::GIT_EAPPLIED => super::ErrorCode::Applied, raw::GIT_EPEEL => super::ErrorCode::Peel, raw::GIT_EEOF => super::ErrorCode::Eof, raw::GIT_EINVALID => super::ErrorCode::Invalid, raw::GIT_EUNCOMMITTED => super::ErrorCode::Uncommitted, raw::GIT_EDIRECTORY => super::ErrorCode::Directory, _ => super::ErrorCode::GenericError, } } /// Return the error class associated with this error. pub fn class(&self) -> ErrorClass { match self.raw_class() { raw::GITERR_NONE => super::ErrorClass::None, raw::GITERR_NOMEMORY => super::ErrorClass::NoMemory, raw::GITERR_OS => super::ErrorClass::Os, raw::GITERR_INVALID => super::ErrorClass::Invalid, raw::GITERR_REFERENCE => super::ErrorClass::Reference, raw::GITERR_ZLIB => super::ErrorClass::Zlib, raw::GITERR_REPOSITORY => super::ErrorClass::Repository, raw::GITERR_CONFIG => super::ErrorClass::Config, raw::GITERR_REGEX => super::ErrorClass::Regex, raw::GITERR_ODB => super::ErrorClass::Odb, raw::GITERR_INDEX => super::ErrorClass::Index, raw::GITERR_OBJECT => super::ErrorClass::Object, raw::GITERR_NET => super::ErrorClass::Net, raw::GITERR_TAG => super::ErrorClass::Tag, raw::GITERR_TREE => super::ErrorClass::Tree, raw::GITERR_INDEXER => super::ErrorClass::Indexer, raw::GITERR_SSL => super::ErrorClass::Ssl, raw::GITERR_SUBMODULE => super::ErrorClass::Submodule, raw::GITERR_THREAD => super::ErrorClass::Thread, raw::GITERR_STASH => super::ErrorClass::Stash, raw::GITERR_CHECKOUT => super::ErrorClass::Checkout, raw::GITERR_FETCHHEAD => super::ErrorClass::FetchHead, raw::GITERR_MERGE => super::ErrorClass::Merge, raw::GITERR_SSH => super::ErrorClass::Ssh, raw::GITERR_FILTER => super::ErrorClass::Filter, raw::GITERR_REVERT => super::ErrorClass::Revert, raw::GITERR_CALLBACK => super::ErrorClass::Callback, raw::GITERR_CHERRYPICK => super::ErrorClass::CherryPick, raw::GITERR_DESCRIBE => super::ErrorClass::Describe, raw::GITERR_REBASE => super::ErrorClass::Rebase, raw::GITERR_FILESYSTEM => super::ErrorClass::Filesystem, _ => super::ErrorClass::None, } } /// Return the raw error code associated with this error. pub fn raw_code(&self) -> raw::git_error_code { macro_rules! check( ($($e:ident,)*) => ( $(if self.code == raw::$e as c_int { raw::$e }) else * else { raw::GIT_ERROR } ) ); check!( GIT_OK, GIT_ERROR, GIT_ENOTFOUND, GIT_EEXISTS, GIT_EAMBIGUOUS, GIT_EBUFS, GIT_EUSER, GIT_EBAREREPO, GIT_EUNBORNBRANCH, GIT_EUNMERGED, GIT_ENONFASTFORWARD, GIT_EINVALIDSPEC, GIT_ECONFLICT, GIT_ELOCKED, GIT_EMODIFIED, GIT_EAUTH, GIT_ECERTIFICATE, GIT_EAPPLIED, GIT_EPEEL, GIT_EEOF, GIT_EINVALID, GIT_EUNCOMMITTED, GIT_PASSTHROUGH, GIT_ITEROVER, ) } /// Return the raw error class associated with this error. pub fn raw_class(&self) -> raw::git_error_t { macro_rules! check( ($($e:ident,)*) => ( $(if self.klass == raw::$e as c_int { raw::$e }) else * else { raw::GITERR_NONE } ) ); check!( GITERR_NONE, GITERR_NOMEMORY, GITERR_OS, GITERR_INVALID, GITERR_REFERENCE, GITERR_ZLIB, GITERR_REPOSITORY, GITERR_CONFIG, GITERR_REGEX, GITERR_ODB, GITERR_INDEX, GITERR_OBJECT, GITERR_NET, GITERR_TAG, GITERR_TREE, GITERR_INDEXER, GITERR_SSL, GITERR_SUBMODULE, GITERR_THREAD, GITERR_STASH, GITERR_CHECKOUT, GITERR_FETCHHEAD, GITERR_MERGE, GITERR_SSH, GITERR_FILTER, GITERR_REVERT, GITERR_CALLBACK, GITERR_CHERRYPICK, GITERR_DESCRIBE, GITERR_REBASE, GITERR_FILESYSTEM, ) } /// Return the message associated with this error pub fn message(&self) -> &str { &self.message } } impl error::Error for Error { fn description(&self) -> &str { &self.message } } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { try!(write!(f, "[{}/{}] ", self.klass, self.code)); f.write_str(&self.message) } } impl From for Error { fn from(_: NulError) -> Error { Error::from_str("data contained a nul byte that could not be \ represented as a string") } } #[cfg(test)] mod tests { use {ErrorClass, ErrorCode}; #[test] fn smoke() { let (_td, repo) = ::test::repo_init(); let err = repo.find_submodule("does_not_exist").err().unwrap(); assert_eq!(err.code(), ErrorCode::NotFound); assert_eq!(err.class(), ErrorClass::Submodule); } } deps/git2-0.3.3/src/merge.rs0000664000175000017500000001112112542605012012464 0ustar use std::marker; use std::mem; use libc::c_uint; use {raw, Oid, Commit, FileFavor}; use util::Binding; use call::Convert; /// A structure to represent an annotated commit, the input to merge and rebase. /// /// An annotated commit contains information about how it was looked up, which /// may be useful for functions like merge or rebase to provide context to the /// operation. pub struct AnnotatedCommit<'repo> { raw: *mut raw::git_annotated_commit, _marker: marker::PhantomData>, } /// Options to specify when merging. pub struct MergeOptions { raw: raw::git_merge_options, } impl<'repo> AnnotatedCommit<'repo> { /// Gets the commit ID that the given git_annotated_commit refers to pub fn id(&self) -> Oid { unsafe { Binding::from_raw(raw::git_annotated_commit_id(self.raw)) } } } impl MergeOptions { /// Creates a default set of merge options. pub fn new() -> MergeOptions { let mut opts = MergeOptions { raw: unsafe { mem::zeroed() }, }; assert_eq!(unsafe { raw::git_merge_init_options(&mut opts.raw, 1) }, 0); opts } /// Detect file renames pub fn find_renames(&mut self, find: bool) -> &mut MergeOptions { if find { self.raw.tree_flags |= raw::GIT_MERGE_TREE_FIND_RENAMES; } else { self.raw.tree_flags &= !raw::GIT_MERGE_TREE_FIND_RENAMES; } self } /// Similarity to consider a file renamed (default 50) pub fn rename_threshold(&mut self, thresh: u32) -> &mut MergeOptions { self.raw.rename_threshold = thresh; self } /// Maximum similarity sources to examine for renames (default 200). /// If the number of rename candidates (add / delete pairs) is greater /// than this value, inexact rename detection is aborted. This setting /// overrides the `merge.renameLimit` configuration value. pub fn target_limit(&mut self, limit: u32) -> &mut MergeOptions { self.raw.target_limit = limit as c_uint; self } /// Specify a side to favor for resolving conflicts pub fn file_favor(&mut self, favor: FileFavor) -> &mut MergeOptions { self.raw.file_favor = favor.convert(); self } fn flag(&mut self, opt: u32, val: bool) -> &mut MergeOptions { if val { self.raw.file_flags |= opt; } else { self.raw.file_flags &= !opt; } self } /// Create standard conflicted merge files pub fn standard_style(&mut self, standard: bool) -> &mut MergeOptions { self.flag(raw::GIT_MERGE_FILE_STYLE_MERGE, standard) } /// Create diff3-style file pub fn diff3_style(&mut self, diff3: bool) -> &mut MergeOptions { self.flag(raw::GIT_MERGE_FILE_STYLE_DIFF3, diff3) } /// Condense non-alphanumeric regions for simplified diff file pub fn simplify_alnum(&mut self, simplify: bool) -> &mut MergeOptions { self.flag(raw::GIT_MERGE_FILE_SIMPLIFY_ALNUM, simplify) } /// Ignore all whitespace pub fn ignore_whitespace(&mut self, ignore: bool) -> &mut MergeOptions { self.flag(raw::GIT_MERGE_FILE_IGNORE_WHITESPACE, ignore) } /// Ignore changes in amount of whitespace pub fn ignore_whitespace_change(&mut self, ignore: bool) -> &mut MergeOptions { self.flag(raw::GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE, ignore) } /// Ignore whitespace at end of line pub fn ignore_whitespace_eol(&mut self, ignore: bool) -> &mut MergeOptions { self.flag(raw::GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL, ignore) } /// Use the "patience diff" algorithm pub fn patience(&mut self, patience: bool) -> &mut MergeOptions { self.flag(raw::GIT_MERGE_FILE_DIFF_PATIENCE, patience) } /// Take extra time to find minimal diff pub fn minimal(&mut self, minimal: bool) -> &mut MergeOptions { self.flag(raw::GIT_MERGE_FILE_DIFF_MINIMAL, minimal) } /// Acquire a pointer to the underlying raw options. pub unsafe fn raw(&self) -> *const raw::git_merge_options { &self.raw as *const _ } } impl<'repo> Binding for AnnotatedCommit<'repo> { type Raw = *mut raw::git_annotated_commit; unsafe fn from_raw(raw: *mut raw::git_annotated_commit) -> AnnotatedCommit<'repo> { AnnotatedCommit { raw: raw, _marker: marker::PhantomData, } } fn raw(&self) -> *mut raw::git_annotated_commit { self.raw } } impl<'repo> Drop for AnnotatedCommit<'repo> { fn drop(&mut self) { unsafe { raw::git_annotated_commit_free(self.raw) } } } deps/git2-0.3.3/src/diff.rs0000664000175000017500000010204712623026373012314 0ustar use std::ffi::CString; use std::marker; use std::mem; use std::ops::Range; use std::path::Path; use std::slice; use libc::{c_char, size_t, c_void, c_int}; use {raw, Buf, Delta, Oid, Repository, Tree, Error, Index, DiffFormat}; use {DiffStatsFormat, IntoCString}; use util::{self, Binding}; /// The diff object that contains all individual file deltas. /// /// This is an opaque structure which will be allocated by one of the diff /// generator functions on the `Repository` structure (e.g. `diff_tree_to_tree` /// or other `diff_*` functions). pub struct Diff { raw: *mut raw::git_diff, } unsafe impl Send for Diff {} /// Description of changes to one entry. pub struct DiffDelta<'a> { raw: *mut raw::git_diff_delta, _marker: marker::PhantomData<&'a raw::git_diff_delta>, } /// Description of one side of a delta. /// /// Although this is called a "file" it could represent a file, a symbolic /// link, a submodule commit id, or even a tree (although that only happens if /// you are tracking type changes or ignored/untracked directories). pub struct DiffFile<'a> { raw: *const raw::git_diff_file, _marker: marker::PhantomData<&'a raw::git_diff_file>, } /// Structure describing options about how the diff should be executed. pub struct DiffOptions { pathspec: Vec, pathspec_ptrs: Vec<*const c_char>, old_prefix: Option, new_prefix: Option, raw: raw::git_diff_options, } /// Control behavior of rename and copy detection pub struct DiffFindOptions { raw: raw::git_diff_find_options, } /// An iterator over the diffs in a delta pub struct Deltas<'diff> { range: Range, diff: &'diff Diff, } /// Structure describing a line (or data span) of a diff. pub struct DiffLine<'a> { raw: *const raw::git_diff_line, _marker: marker::PhantomData<&'a raw::git_diff_line>, } /// Structure describing a hunk of a diff. pub struct DiffHunk<'a> { raw: *const raw::git_diff_hunk, _marker: marker::PhantomData<&'a raw::git_diff_hunk>, } /// Structure describing a hunk of a diff. pub struct DiffStats { raw: *mut raw::git_diff_stats, } type PrintCb<'a> = FnMut(DiffDelta, Option, DiffLine) -> bool + 'a; impl Diff { /// Deprecated, use repo.diff_tree_to_tree(..) instead #[doc(hidden)] pub fn tree_to_tree(repo: &Repository, old_tree: Option<&Tree>, new_tree: Option<&Tree>, opts: Option<&mut DiffOptions>) -> Result { repo.diff_tree_to_tree(old_tree, new_tree, opts) } /// Deprecated, use repo.diff_tree_to_index(..) instead #[doc(hidden)] pub fn tree_to_index(repo: &Repository, old_tree: Option<&Tree>, index: Option<&Index>, opts: Option<&mut DiffOptions>) -> Result { repo.diff_tree_to_index(old_tree, index, opts) } /// Deprecated, use repo.diff_index_to_workdir(..) instead #[doc(hidden)] pub fn index_to_workdir(repo: &Repository, index: Option<&Index>, opts: Option<&mut DiffOptions>) -> Result { repo.diff_index_to_workdir(index, opts) } /// Deprecated, use repo.diff_tree_to_tree(..) instead #[doc(hidden)] pub fn tree_to_workdir(repo: &Repository, old_tree: Option<&Tree>, opts: Option<&mut DiffOptions>) -> Result { repo.diff_tree_to_workdir(old_tree, opts) } /// Deprecated, use repo.diff_tree_to_workdir_with_index(..) instead #[doc(hidden)] pub fn tree_to_workdir_with_index(repo: &Repository, old_tree: Option<&Tree>, opts: Option<&mut DiffOptions>) -> Result { repo.diff_tree_to_workdir_with_index(old_tree, opts) } /// Merge one diff into another. /// /// This merges items from the "from" list into the "self" list. The /// resulting diff will have all items that appear in either list. /// If an item appears in both lists, then it will be "merged" to appear /// as if the old version was from the "onto" list and the new version /// is from the "from" list (with the exception that if the item has a /// pending DELETE in the middle, then it will show as deleted). pub fn merge(&mut self, from: &Diff) -> Result<(), Error> { unsafe { try_call!(raw::git_diff_merge(self.raw, &*from.raw)); } Ok(()) } /// Returns an iterator over the deltas in this diff. pub fn deltas(&self) -> Deltas { let num_deltas = unsafe { raw::git_diff_num_deltas(&*self.raw) }; Deltas { range: 0..(num_deltas as usize), diff: self } } /// Return the diff delta for an entry in the diff list. pub fn get_delta(&self, i: usize) -> Option { unsafe { let ptr = raw::git_diff_get_delta(&*self.raw, i as size_t); Binding::from_raw_opt(ptr as *mut _) } } /// Check if deltas are sorted case sensitively or insensitively. pub fn is_sorted_icase(&self) -> bool { unsafe { raw::git_diff_is_sorted_icase(&*self.raw) == 1 } } /// Iterate over a diff generating formatted text output. /// /// Returning `false` from the callback will terminate the iteration and /// return an error from this function. pub fn print(&self, format: DiffFormat, mut cb: F) -> Result<(), Error> where F: FnMut(DiffDelta, Option, DiffLine) -> bool { let mut cb: &mut PrintCb = &mut cb; let ptr = &mut cb as *mut _; unsafe { try_call!(raw::git_diff_print(self.raw, format, print_cb, ptr as *mut _)); return Ok(()) } } /// Accumulate diff statistics for all patches. pub fn stats(&self) -> Result { let mut ret = 0 as *mut raw::git_diff_stats; unsafe { try_call!(raw::git_diff_get_stats(&mut ret, self.raw)); Ok(Binding::from_raw(ret)) } } /// Transform a diff marking file renames, copies, etc. /// /// This modifies a diff in place, replacing old entries that look like /// renames or copies with new entries reflecting those changes. This also /// will, if requested, break modified files into add/remove pairs if the /// amount of change is above a threshold. pub fn find_similar(&mut self, opts: Option<&mut DiffFindOptions>) -> Result<(), Error> { let opts = opts.map(|opts| &opts.raw); unsafe { try_call!(raw::git_diff_find_similar(self.raw, opts)); } Ok(()) } // TODO: num_deltas_of_type, foreach, format_email, find_similar } wrap_env! { fn print_cb(delta: *const raw::git_diff_delta, hunk: *const raw::git_diff_hunk, line: *const raw::git_diff_line, data: *mut c_void) -> c_int { unsafe { let delta = Binding::from_raw(delta as *mut _); let hunk = Binding::from_raw_opt(hunk); let line = Binding::from_raw(line); let data = data as *mut &mut PrintCb; (*data)(delta, hunk, line) } } returning ok as if ok == Some(true) {0} else {-1} } impl Binding for Diff { type Raw = *mut raw::git_diff; unsafe fn from_raw(raw: *mut raw::git_diff) -> Diff { Diff { raw: raw } } fn raw(&self) -> *mut raw::git_diff { self.raw } } impl Drop for Diff { fn drop(&mut self) { unsafe { raw::git_diff_free(self.raw) } } } impl<'a> DiffDelta<'a> { // TODO: expose when diffs are more exposed // pub fn similarity(&self) -> u16 { // unsafe { (*self.raw).similarity } // } /// Returns the number of files in this delta. pub fn nfiles(&self) -> u16 { unsafe { (*self.raw).nfiles } } /// Returns the status of this entry /// /// For more information, see `Delta`'s documentation pub fn status(&self) -> Delta { match unsafe { (*self.raw).status } { raw::GIT_DELTA_UNMODIFIED => Delta::Unmodified, raw::GIT_DELTA_ADDED => Delta::Added, raw::GIT_DELTA_DELETED => Delta::Deleted, raw::GIT_DELTA_MODIFIED => Delta::Modified, raw::GIT_DELTA_RENAMED => Delta::Renamed, raw::GIT_DELTA_COPIED => Delta::Copied, raw::GIT_DELTA_IGNORED => Delta::Ignored, raw::GIT_DELTA_UNTRACKED => Delta::Untracked, raw::GIT_DELTA_TYPECHANGE => Delta::Typechange, raw::GIT_DELTA_UNREADABLE => Delta::Unreadable, raw::GIT_DELTA_CONFLICTED => Delta::Conflicted, n => panic!("unknown diff status: {}", n), } } /// Return the file which represents the "from" side of the diff. /// /// What side this means depends on the function that was used to generate /// the diff and will be documented on the function itself. pub fn old_file(&self) -> DiffFile<'a> { unsafe { Binding::from_raw(&(*self.raw).old_file as *const _) } } /// Return the file which represents the "to" side of the diff. /// /// What side this means depends on the function that was used to generate /// the diff and will be documented on the function itself. pub fn new_file(&self) -> DiffFile<'a> { unsafe { Binding::from_raw(&(*self.raw).new_file as *const _) } } } impl<'a> Binding for DiffDelta<'a> { type Raw = *mut raw::git_diff_delta; unsafe fn from_raw(raw: *mut raw::git_diff_delta) -> DiffDelta<'a> { DiffDelta { raw: raw, _marker: marker::PhantomData, } } fn raw(&self) -> *mut raw::git_diff_delta { self.raw } } impl<'a> DiffFile<'a> { /// Returns the Oid of this item. /// /// If this entry represents an absent side of a diff (e.g. the `old_file` /// of a `Added` delta), then the oid returned will be zeroes. pub fn id(&self) -> Oid { unsafe { Binding::from_raw(&(*self.raw).id as *const _) } } /// Returns the path, in bytes, of the entry relative to the working /// directory of the repository. pub fn path_bytes(&self) -> Option<&'a [u8]> { static FOO: () = (); unsafe { ::opt_bytes(&FOO, (*self.raw).path) } } /// Returns the path of the entry relative to the working directory of the /// repository. pub fn path(&self) -> Option<&'a Path> { self.path_bytes().map(util::bytes2path) } /// Returns the size of this entry, in bytes pub fn size(&self) -> u64 { unsafe { (*self.raw).size as u64 } } // TODO: expose flags/mode } impl<'a> Binding for DiffFile<'a> { type Raw = *const raw::git_diff_file; unsafe fn from_raw(raw: *const raw::git_diff_file) -> DiffFile<'a> { DiffFile { raw: raw, _marker: marker::PhantomData, } } fn raw(&self) -> *const raw::git_diff_file { self.raw } } impl DiffOptions { /// Creates a new set of empty diff options. /// /// All flags and other options are defaulted to false or their otherwise /// zero equivalents. pub fn new() -> DiffOptions { let mut opts = DiffOptions { pathspec: Vec::new(), pathspec_ptrs: Vec::new(), raw: unsafe { mem::zeroed() }, old_prefix: None, new_prefix: None, }; assert_eq!(unsafe { raw::git_diff_init_options(&mut opts.raw, 1) }, 0); opts } fn flag(&mut self, opt: u32, val: bool) -> &mut DiffOptions { if val { self.raw.flags |= opt; } else { self.raw.flags &= !opt; } self } /// Flag indicating whether the sides of the diff will be reversed. pub fn reverse(&mut self, reverse: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_REVERSE, reverse) } /// Flag indicating whether ignored files are included. pub fn include_ignored(&mut self, include: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_INCLUDE_IGNORED, include) } /// Flag indicating whether ignored directories are traversed deeply or not. pub fn recurse_ignored_dirs(&mut self, recurse: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_RECURSE_IGNORED_DIRS, recurse) } /// Flag indicating whether untracked files are in the diff pub fn include_untracked(&mut self, include: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_INCLUDE_UNTRACKED, include) } /// Flag indicating whether untracked directories are deeply traversed or /// not. pub fn recurse_untracked_dirs(&mut self, recurse: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_RECURSE_UNTRACKED_DIRS, recurse) } /// Flag indicating whether unmodified files are in the diff. pub fn include_unmodified(&mut self, include: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_INCLUDE_UNMODIFIED, include) } /// If entrabled, then Typechange delta records are generated. pub fn include_typechange(&mut self, include: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_INCLUDE_TYPECHANGE, include) } /// Event with `include_typechange`, the tree treturned generally shows a /// deleted blow. This flag correctly labels the tree transitions as a /// typechange record with the `new_file`'s mode set to tree. /// /// Note that the tree SHA will not be available. pub fn include_typechange_trees(&mut self, include: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_INCLUDE_TYPECHANGE_TREES, include) } /// Flag indicating whether file mode changes are ignored. pub fn ignore_filemode(&mut self, ignore: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_IGNORE_FILEMODE, ignore) } /// Flag indicating whether all submodules should be treated as unmodified. pub fn ignore_submodules(&mut self, ignore: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_IGNORE_SUBMODULES, ignore) } /// Flag indicating whether case insensitive filenames should be used. pub fn ignore_case(&mut self, ignore: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_IGNORE_CASE, ignore) } /// If pathspecs are specified, this flag means that they should be applied /// as an exact match instead of a fnmatch pattern. pub fn disable_pathspec_match(&mut self, disable: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_DISABLE_PATHSPEC_MATCH, disable) } /// Disable updating the `binary` flag in delta records. This is useful when /// iterating over a diff if you don't need hunk and data callbacks and want /// to avoid having to load a file completely. pub fn skip_binary_check(&mut self, skip: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_SKIP_BINARY_CHECK, skip) } /// When diff finds an untracked directory, to match the behavior of core /// Git, it scans the contents for ignored and untracked files. If all /// contents are ignored, then the directory is ignored; if any contents are /// not ignored, then the directory is untracked. This is extra work that /// may not matter in many cases. /// /// This flag turns off that scan and immediately labels an untracked /// directory as untracked (changing the behavior to not match core git). pub fn enable_fast_untracked_dirs(&mut self, enable: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_ENABLE_FAST_UNTRACKED_DIRS, enable) } /// When diff finds a file in the working directory with stat information /// different from the index, but the OID ends up being the same, write the /// correct stat information into the index. Note: without this flag, diff /// will always leave the index untouched. pub fn update_index(&mut self, update: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_UPDATE_INDEX, update) } /// Include unreadable files in the diff pub fn include_unreadable(&mut self, include: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_INCLUDE_UNREADABLE, include) } /// Include unreadable files in the diff pub fn include_unreadable_as_untracked(&mut self, include: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED, include) } /// Treat all files as text, disabling binary attributes and detection. pub fn force_text(&mut self, force: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_FORCE_TEXT, force) } /// Treat all files as binary, disabling text diffs pub fn force_binary(&mut self, force: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_FORCE_TEXT, force) } /// Ignore all whitespace pub fn ignore_whitespace(&mut self, ignore: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_IGNORE_WHITESPACE, ignore) } /// Ignore changes in the amount of whitespace pub fn ignore_whitespace_change(&mut self, ignore: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_IGNORE_WHITESPACE_CHANGE, ignore) } /// Ignore whitespace at tend of line pub fn ignore_whitespace_eol(&mut self, ignore: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_IGNORE_WHITESPACE_EOL, ignore) } /// When generating patch text, include the content of untracked files. /// /// This automatically turns on `include_untracked` but it does not turn on /// `recurse_untracked_dirs`. Add that flag if you want the content of every /// single untracked file. pub fn show_untracked_content(&mut self, show: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_SHOW_UNTRACKED_CONTENT, show) } /// When generating output, include the names of unmodified files if they /// are included in the `Diff`. Normally these are skipped in the formats /// that list files (e.g. name-only, name-status, raw). Even with this these /// will not be included in the patch format. pub fn show_unmodified(&mut self, show: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_SHOW_UNMODIFIED, show) } /// Use the "patience diff" algorithm pub fn patience(&mut self, patience: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_PATIENCE, patience) } /// Take extra time to find the minimal diff pub fn minimal(&mut self, minimal: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_MINIMAL, minimal) } /// Include the necessary deflate/delta information so that `git-apply` can /// apply given diff information to binary files. pub fn show_binary(&mut self, show: bool) -> &mut DiffOptions { self.flag(raw::GIT_DIFF_SHOW_BINARY, show) } /// Set the number of unchanged lines that define the boundary of a hunk /// (and to display before and after). /// /// The default value for this is 3. pub fn context_lines(&mut self, lines: u32) -> &mut DiffOptions { self.raw.context_lines = lines; self } /// Set the maximum number of unchanged lines between hunk boundaries before /// the hunks will be merged into one. /// /// The default value for this is 0. pub fn interhunk_lines(&mut self, lines: u32) -> &mut DiffOptions { self.raw.interhunk_lines = lines; self } /// The default value for this is `core.abbrev` or 7 if unset. pub fn id_abbrev(&mut self, abbrev: u16) -> &mut DiffOptions { self.raw.id_abbrev = abbrev; self } /// Maximum size (in bytes) above which a blob will be marked as binary /// automatically. /// /// A negative value will disable this entirely. /// /// The default value for this is 512MB. pub fn max_size(&mut self, size: i64) -> &mut DiffOptions { self.raw.max_size = size as raw::git_off_t; self } /// The virtual "directory" to prefix old file names with in hunk headers. /// /// The default value for this is "a". pub fn old_prefix(&mut self, t: T) -> &mut DiffOptions { self.old_prefix = Some(t.into_c_string().unwrap()); self } /// The virtual "directory" to prefix new file names with in hunk headers. /// /// The default value for this is "b". pub fn new_prefix(&mut self, t: T) -> &mut DiffOptions { self.new_prefix = Some(t.into_c_string().unwrap()); self } /// Add to the array of paths/fnmatch patterns to constrain the diff. pub fn pathspec(&mut self, pathspec: T) -> &mut DiffOptions { let s = pathspec.into_c_string().unwrap(); self.pathspec_ptrs.push(s.as_ptr()); self.pathspec.push(s); self } /// Acquire a pointer to the underlying raw options. /// /// This function is unsafe as the pointer is only valid so long as this /// structure is not moved, modified, or used elsewhere. pub unsafe fn raw(&mut self) -> *const raw::git_diff_options { self.raw.old_prefix = self.old_prefix.as_ref().map(|s| s.as_ptr()) .unwrap_or(0 as *const _); self.raw.new_prefix = self.new_prefix.as_ref().map(|s| s.as_ptr()) .unwrap_or(0 as *const _); self.raw.pathspec.count = self.pathspec_ptrs.len() as size_t; self.raw.pathspec.strings = self.pathspec_ptrs.as_ptr() as *mut _; &self.raw as *const _ } // TODO: expose ignore_submodules, notify_cb/notify_payload } impl<'diff> Iterator for Deltas<'diff> { type Item = DiffDelta<'diff>; fn next(&mut self) -> Option> { self.range.next().and_then(|i| self.diff.get_delta(i)) } fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } } impl<'diff> DoubleEndedIterator for Deltas<'diff> { fn next_back(&mut self) -> Option> { self.range.next_back().and_then(|i| self.diff.get_delta(i)) } } impl<'diff> ExactSizeIterator for Deltas<'diff> {} impl<'a> DiffLine<'a> { /// Line number in old file or `None` for added line pub fn old_lineno(&self) -> Option { match unsafe { (*self.raw).old_lineno } { n if n < 0 => None, n => Some(n as u32), } } /// Line number in new file or `None` for deleted line pub fn new_lineno(&self) -> Option { match unsafe { (*self.raw).new_lineno } { n if n < 0 => None, n => Some(n as u32), } } /// Number of newline characters in content pub fn num_lines(&self) -> u32 { unsafe { (*self.raw).num_lines as u32 } } /// Offset in the original file to the content pub fn content_offset(&self) -> i64 { unsafe { (*self.raw).content_offset as i64 } } /// Content of this line as bytes. pub fn content(&self) -> &[u8] { unsafe { slice::from_raw_parts((*self.raw).content as *const u8, (*self.raw).content_len as usize) } } /// Sigil showing the origin of this `DiffLine`. /// /// * ` ` - Line context /// * `+` - Line addition /// * `-` - Line deletion /// * `=` - Context (End of file) /// * `>` - Add (End of file) /// * `<` - Remove (End of file) /// * `F` - File header /// * `H` - Hunk header /// * `B` - Line binary pub fn origin(&self) -> char { match unsafe { (*self.raw).origin } { raw::GIT_DIFF_LINE_CONTEXT => ' ', raw::GIT_DIFF_LINE_ADDITION => '+', raw::GIT_DIFF_LINE_DELETION => '-', raw::GIT_DIFF_LINE_CONTEXT_EOFNL => '=', raw::GIT_DIFF_LINE_ADD_EOFNL => '>', raw::GIT_DIFF_LINE_DEL_EOFNL => '<', raw::GIT_DIFF_LINE_FILE_HDR => 'F', raw::GIT_DIFF_LINE_HUNK_HDR => 'H', raw::GIT_DIFF_LINE_BINARY => 'B', _ => ' ', } } } impl<'a> Binding for DiffLine<'a> { type Raw = *const raw::git_diff_line; unsafe fn from_raw(raw: *const raw::git_diff_line) -> DiffLine<'a> { DiffLine { raw: raw, _marker: marker::PhantomData, } } fn raw(&self) -> *const raw::git_diff_line { self.raw } } impl<'a> DiffHunk<'a> { /// Starting line number in old_file pub fn old_start(&self) -> u32 { unsafe { (*self.raw).old_start as u32 } } /// Number of lines in old_file pub fn old_lines(&self) -> u32 { unsafe { (*self.raw).old_lines as u32 } } /// Starting line number in new_file pub fn new_start(&self) -> u32 { unsafe { (*self.raw).new_start as u32 } } /// Number of lines in new_file pub fn new_lines(&self) -> u32 { unsafe { (*self.raw).new_lines as u32 } } /// Header text pub fn header(&self) -> &[u8] { unsafe { slice::from_raw_parts((*self.raw).header.as_ptr() as *const u8, (*self.raw).header_len as usize) } } } impl<'a> Binding for DiffHunk<'a> { type Raw = *const raw::git_diff_hunk; unsafe fn from_raw(raw: *const raw::git_diff_hunk) -> DiffHunk<'a> { DiffHunk { raw: raw, _marker: marker::PhantomData, } } fn raw(&self) -> *const raw::git_diff_hunk { self.raw } } impl DiffStats { /// Get the total number of files chaned in a diff. pub fn files_changed(&self) -> usize { unsafe { raw::git_diff_stats_files_changed(&*self.raw) as usize } } /// Get the total number of insertions in a diff pub fn insertions(&self) -> usize { unsafe { raw::git_diff_stats_insertions(&*self.raw) as usize } } /// Get the total number of deletions in a diff pub fn deletions(&self) -> usize { unsafe { raw::git_diff_stats_deletions(&*self.raw) as usize } } /// Print diff statistics to a Buf pub fn to_buf(&self, format: DiffStatsFormat, width: usize) -> Result { let buf = Buf::new(); unsafe { try_call!(raw::git_diff_stats_to_buf(buf.raw(), self.raw, format.bits(), width as size_t)); } Ok(buf) } } impl Binding for DiffStats { type Raw = *mut raw::git_diff_stats; unsafe fn from_raw(raw: *mut raw::git_diff_stats) -> DiffStats { DiffStats { raw: raw } } fn raw(&self) -> *mut raw::git_diff_stats { self.raw } } impl Drop for DiffStats { fn drop(&mut self) { unsafe { raw::git_diff_stats_free(self.raw) } } } impl DiffFindOptions { /// Creates a new set of empty diff find options. /// /// All flags and other options are defaulted to false or their otherwise /// zero equivalents. pub fn new() -> DiffFindOptions { let mut opts = DiffFindOptions { raw: unsafe { mem::zeroed() }, }; assert_eq!(unsafe { raw::git_diff_find_init_options(&mut opts.raw, 1) }, 0); opts } fn flag(&mut self, opt: u32, val: bool) -> &mut DiffFindOptions { if val { self.raw.flags |= opt; } else { self.raw.flags &= !opt; } self } /// Reset all flags back to their unset state, indicating that /// `diff.renames` should be used instead. This is overridden once any flag /// is set. pub fn by_config(&mut self) -> &mut DiffFindOptions { self.flag(0xffffffff, false) } /// Look for renames? pub fn renames(&mut self, find: bool) -> &mut DiffFindOptions { self.flag(raw::GIT_DIFF_FIND_RENAMES, find) } /// Consider old side of modified for renames? pub fn renames_from_rewrites(&mut self, find: bool) -> &mut DiffFindOptions { self.flag(raw::GIT_DIFF_FIND_RENAMES_FROM_REWRITES, find) } /// Look for copies? pub fn copies(&mut self, find: bool) -> &mut DiffFindOptions { self.flag(raw::GIT_DIFF_FIND_COPIES, find) } /// Consider unmodified as copy sources? /// /// For this to work correctly, use `include_unmodified` when the initial /// diff is being generated. pub fn copies_from_unmodified(&mut self, find: bool) -> &mut DiffFindOptions { self.flag(raw::GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED, find) } /// Mark significant rewrites for split. pub fn rewrites(&mut self, find: bool) -> &mut DiffFindOptions { self.flag(raw::GIT_DIFF_FIND_REWRITES, find) } /// Actually split large rewrites into delete/add pairs pub fn break_rewries(&mut self, find: bool) -> &mut DiffFindOptions { self.flag(raw::GIT_DIFF_BREAK_REWRITES, find) } /// Find renames/copies for untracked items in working directory. /// /// For this to work correctly use the `include_untracked` option when the /// initial diff is being generated. pub fn for_untracked(&mut self, find: bool) -> &mut DiffFindOptions { self.flag(raw::GIT_DIFF_FIND_FOR_UNTRACKED, find) } /// Turn on all finding features. pub fn all(&mut self, find: bool) -> &mut DiffFindOptions { self.flag(raw::GIT_DIFF_FIND_ALL, find) } /// Measure similarity ignoring leading whitespace (default) pub fn ignore_leading_whitespace(&mut self, ignore: bool) -> &mut DiffFindOptions { self.flag(raw::GIT_DIFF_FIND_IGNORE_LEADING_WHITESPACE, ignore) } /// Measure similarity ignoring all whitespace pub fn ignore_whitespace(&mut self, ignore: bool) -> &mut DiffFindOptions { self.flag(raw::GIT_DIFF_FIND_IGNORE_WHITESPACE, ignore) } /// Measure similarity including all data pub fn dont_ignore_whitespace(&mut self, dont: bool) -> &mut DiffFindOptions { self.flag(raw::GIT_DIFF_FIND_DONT_IGNORE_WHITESPACE, dont) } /// Measure similarity only by comparing SHAs (fast and cheap) pub fn exact_match_only(&mut self, exact: bool) -> &mut DiffFindOptions { self.flag(raw::GIT_DIFF_FIND_EXACT_MATCH_ONLY, exact) } /// Do not break rewrites unless they contribute to a rename. /// /// Normally, `break_rewrites` and `rewrites` will measure the /// self-similarity of modified files and split the ones that have changed a /// lot into a delete/add pair. Then the sides of that pair will be /// considered candidates for rename and copy detection /// /// If you add this flag in and the split pair is not used for an actual /// rename or copy, then the modified record will be restored to a regular /// modified record instead of being split. pub fn break_rewrites_for_renames_only(&mut self, b: bool) -> &mut DiffFindOptions { self.flag(raw::GIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY, b) } /// Remove any unmodified deltas after find_similar is done. /// /// Using `copies_from_unmodified` to emulate the `--find-copies-harder` /// behavior requires building a diff with the `include_unmodified` flag. If /// you do not want unmodified records in the final result, pas this flag to /// have them removed. pub fn remove_unmodified(&mut self, remove: bool) -> &mut DiffFindOptions { self.flag(raw::GIT_DIFF_FIND_REMOVE_UNMODIFIED, remove) } /// Similarity to consider a file renamed (default 50) pub fn rename_threshold(&mut self, thresh: u16) -> &mut DiffFindOptions { self.raw.rename_threshold = thresh; self } /// Similarity of modified to be glegible rename source (default 50) pub fn rename_from_rewrite_threshold(&mut self, thresh: u16) -> &mut DiffFindOptions { self.raw.rename_from_rewrite_threshold = thresh; self } /// Similarity to consider a file copy (default 50) pub fn copy_threshold(&mut self, thresh: u16) -> &mut DiffFindOptions { self.raw.copy_threshold = thresh; self } /// Similarity to split modify into delete/add pair (default 60) pub fn break_rewrite_threshold(&mut self, thresh: u16) -> &mut DiffFindOptions { self.raw.break_rewrite_threshold = thresh; self } /// Maximum similarity sources to examine for a file (somewhat like /// git-diff's `-l` option or `diff.renameLimit` config) /// /// Defaults to 200 pub fn rename_limit(&mut self, limit: usize) -> &mut DiffFindOptions { self.raw.rename_limit = limit as size_t; self } // TODO: expose git_diff_similarity_metric } #[cfg(test)] mod tests { #[test] fn smoke() { let (_td, repo) = ::test::repo_init(); let diff = repo.diff_tree_to_workdir(None, None).unwrap(); assert_eq!(diff.deltas().len(), 0); let stats = diff.stats().unwrap(); assert_eq!(stats.insertions(), 0); assert_eq!(stats.deletions(), 0); assert_eq!(stats.files_changed(), 0); } } deps/git2-0.3.3/src/reference.rs0000664000175000017500000002743112576206374013355 0ustar use std::cmp::Ordering; use std::ffi::CString; use std::marker; use std::mem; use std::str; use libc; use {raw, Error, Oid, Repository, Object, ObjectType}; use util::Binding; struct Refdb<'repo>(&'repo Repository); /// A structure to represent a git [reference][1]. /// /// [1]: http://git-scm.com/book/en/Git-Internals-Git-References pub struct Reference<'repo> { raw: *mut raw::git_reference, _marker: marker::PhantomData>, } /// An iterator over the references in a repository. pub struct References<'repo> { raw: *mut raw::git_reference_iterator, _marker: marker::PhantomData>, } /// An iterator over the names of references in a repository. pub struct ReferenceNames<'repo> { inner: References<'repo>, } impl<'repo> Reference<'repo> { /// Ensure the reference name is well-formed. pub fn is_valid_name(refname: &str) -> bool { ::init(); let refname = CString::new(refname).unwrap(); unsafe { raw::git_reference_is_valid_name(refname.as_ptr()) == 1 } } /// Get access to the underlying raw pointer. pub fn raw(&self) -> *mut raw::git_reference { self.raw } /// Delete an existing reference. /// /// This method works for both direct and symbolic references. The reference /// will be immediately removed on disk. /// /// This function will return an error if the reference has changed from the /// time it was looked up. pub fn delete(&mut self) -> Result<(), Error> { unsafe { try_call!(raw::git_reference_delete(self.raw)); } Ok(()) } /// Check if a reference is a local branch. pub fn is_branch(&self) -> bool { unsafe { raw::git_reference_is_branch(&*self.raw) == 1 } } /// Check if a reference is a note. pub fn is_note(&self) -> bool { unsafe { raw::git_reference_is_note(&*self.raw) == 1 } } /// Check if a reference is a remote tracking branch pub fn is_remote(&self) -> bool { unsafe { raw::git_reference_is_remote(&*self.raw) == 1 } } /// Check if a reference is a tag pub fn is_tag(&self) -> bool { unsafe { raw::git_reference_is_tag(&*self.raw) == 1 } } /// Get the full name of a reference. /// /// Returns `None` if the name is not valid utf-8. pub fn name(&self) -> Option<&str> { str::from_utf8(self.name_bytes()).ok() } /// Get the full name of a reference. pub fn name_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, raw::git_reference_name(&*self.raw)).unwrap() } } /// Get the full shorthand of a reference. /// /// This will transform the reference name into a name "human-readable" /// version. If no shortname is appropriate, it will return the full name. /// /// Returns `None` if the shorthand is not valid utf-8. pub fn shorthand(&self) -> Option<&str> { str::from_utf8(self.shorthand_bytes()).ok() } /// Get the full shorthand of a reference. pub fn shorthand_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, raw::git_reference_shorthand(&*self.raw)).unwrap() } } /// Get the OID pointed to by a direct reference. /// /// Only available if the reference is direct (i.e. an object id reference, /// not a symbolic one). pub fn target(&self) -> Option { unsafe { Binding::from_raw_opt(raw::git_reference_target(&*self.raw)) } } /// Return the peeled OID target of this reference. /// /// This peeled OID only applies to direct references that point to a hard /// Tag object: it is the result of peeling such Tag. pub fn target_peel(&self) -> Option { unsafe { Binding::from_raw_opt(raw::git_reference_target_peel(&*self.raw)) } } /// Get full name to the reference pointed to by a symbolic reference. /// /// May return `None` if the reference is either not symbolic or not a /// valid utf-8 string. pub fn symbolic_target(&self) -> Option<&str> { self.symbolic_target_bytes().and_then(|s| str::from_utf8(s).ok()) } /// Get full name to the reference pointed to by a symbolic reference. /// /// Only available if the reference is symbolic. pub fn symbolic_target_bytes(&self) -> Option<&[u8]> { unsafe { ::opt_bytes(self, raw::git_reference_symbolic_target(&*self.raw)) } } /// Resolve a symbolic reference to a direct reference. /// /// This method iteratively peels a symbolic reference until it resolves to /// a direct reference to an OID. /// /// If a direct reference is passed as an argument, a copy of that /// reference is returned. pub fn resolve(&self) -> Result, Error> { let mut raw = 0 as *mut raw::git_reference; unsafe { try_call!(raw::git_reference_resolve(&mut raw, &*self.raw)); Ok(Binding::from_raw(raw)) } } /// Peel a reference to an object /// /// This method recursively peels the reference until it reaches /// an object of the specified type. pub fn peel(&self, kind: ObjectType) -> Result, Error> { let mut raw = 0 as *mut raw::git_object; unsafe { try_call!(raw::git_reference_peel(&mut raw, self.raw, kind)); Ok(Binding::from_raw(raw)) } } /// Rename an existing reference. /// /// This method works for both direct and symbolic references. /// /// If the force flag is not enabled, and there's already a reference with /// the given name, the renaming will fail. pub fn rename(&mut self, new_name: &str, force: bool, msg: &str) -> Result, Error> { let mut raw = 0 as *mut raw::git_reference; let new_name = try!(CString::new(new_name)); let msg = try!(CString::new(msg)); unsafe { try_call!(raw::git_reference_rename(&mut raw, self.raw, new_name, force, msg)); Ok(Binding::from_raw(raw)) } } /// Conditionally create a new reference with the same name as the given /// reference but a different OID target. The reference must be a direct /// reference, otherwise this will fail. /// /// The new reference will be written to disk, overwriting the given /// reference. pub fn set_target(&mut self, id: Oid, reflog_msg: &str) -> Result, Error> { let mut raw = 0 as *mut raw::git_reference; let msg = try!(CString::new(reflog_msg)); unsafe { try_call!(raw::git_reference_set_target(&mut raw, self.raw, id.raw(), msg)); Ok(Binding::from_raw(raw)) } } } impl<'repo> PartialOrd for Reference<'repo> { fn partial_cmp(&self, other: &Reference<'repo>) -> Option { Some(self.cmp(other)) } } impl<'repo> Ord for Reference<'repo> { fn cmp(&self, other: &Reference<'repo>) -> Ordering { match unsafe { raw::git_reference_cmp(&*self.raw, &*other.raw) } { 0 => Ordering::Equal, n if n < 0 => Ordering::Less, _ => Ordering::Greater, } } } impl<'repo> PartialEq for Reference<'repo> { fn eq(&self, other: &Reference<'repo>) -> bool { self.cmp(other) == Ordering::Equal } } impl<'repo> Eq for Reference<'repo> {} impl<'repo> Binding for Reference<'repo> { type Raw = *mut raw::git_reference; unsafe fn from_raw(raw: *mut raw::git_reference) -> Reference<'repo> { Reference { raw: raw, _marker: marker::PhantomData } } fn raw(&self) -> *mut raw::git_reference { self.raw } } impl<'repo> Drop for Reference<'repo> { fn drop(&mut self) { unsafe { raw::git_reference_free(self.raw) } } } impl<'repo> References<'repo> { /// Consumes a `References` iterator to create an iterator over just the /// name of some references. /// /// This is more efficient if only the names are desired of references as /// the references themselves don't have to be allocated and deallocated. /// /// The returned iterator will yield strings as opposed to a `Reference`. pub fn names(self) -> ReferenceNames<'repo> { ReferenceNames { inner: self } } } impl<'repo> Binding for References<'repo> { type Raw = *mut raw::git_reference_iterator; unsafe fn from_raw(raw: *mut raw::git_reference_iterator) -> References<'repo> { References { raw: raw, _marker: marker::PhantomData } } fn raw(&self) -> *mut raw::git_reference_iterator { self.raw } } impl<'repo> Iterator for References<'repo> { type Item = Reference<'repo>; fn next(&mut self) -> Option> { let mut out = 0 as *mut raw::git_reference; if unsafe { raw::git_reference_next(&mut out, self.raw) == 0 } { Some(unsafe { Binding::from_raw(out) }) } else { None } } } impl<'repo> Drop for References<'repo> { fn drop(&mut self) { unsafe { raw::git_reference_iterator_free(self.raw) } } } impl<'repo> Iterator for ReferenceNames<'repo> { type Item = &'repo str; fn next(&mut self) -> Option<&'repo str> { let mut out = 0 as *const libc::c_char; if unsafe { raw::git_reference_next_name(&mut out, self.inner.raw) == 0 } { Some(unsafe { let bytes = ::opt_bytes(self, out).unwrap(); let s = str::from_utf8(bytes).unwrap(); mem::transmute::<&str, &'repo str>(s) }) } else { None } } } #[cfg(test)] mod tests { use {Reference, ObjectType}; #[test] fn smoke() { assert!(Reference::is_valid_name("refs/foo")); assert!(!Reference::is_valid_name("foo")); } #[test] fn smoke2() { let (_td, repo) = ::test::repo_init(); let mut head = repo.head().unwrap(); assert!(head.is_branch()); assert!(!head.is_remote()); assert!(!head.is_tag()); assert!(!head.is_note()); assert!(head == repo.head().unwrap()); assert_eq!(head.name(), Some("refs/heads/master")); assert!(head == repo.find_reference("refs/heads/master").unwrap()); assert_eq!(repo.refname_to_id("refs/heads/master").unwrap(), head.target().unwrap()); assert!(head.symbolic_target().is_none()); assert!(head.target_peel().is_none()); assert_eq!(head.shorthand(), Some("master")); assert!(head.resolve().unwrap() == head); let mut tag1 = repo.reference("refs/tags/tag1", head.target().unwrap(), false, "test").unwrap(); assert!(tag1.is_tag()); let peeled_commit = tag1.peel(ObjectType::Commit).unwrap(); assert_eq!(ObjectType::Commit, peeled_commit.kind().unwrap()); assert_eq!(tag1.target().unwrap(), peeled_commit.id()); tag1.delete().unwrap(); let mut sym1 = repo.reference_symbolic("refs/tags/tag1", "refs/heads/master", false, "test").unwrap(); sym1.delete().unwrap(); { assert!(repo.references().unwrap().count() == 1); assert!(repo.references().unwrap().next().unwrap() == head); let mut names = repo.references().unwrap().names(); assert_eq!(names.next(), Some("refs/heads/master")); assert_eq!(names.next(), None); assert!(repo.references_glob("foo").unwrap().count() == 0); assert!(repo.references_glob("refs/heads/*").unwrap().count() == 1); } let mut head = head.rename("refs/foo", true, "test").unwrap(); head.delete().unwrap(); } } deps/git2-0.3.3/src/tag.rs0000664000175000017500000001151312603146277012160 0ustar use std::marker; use std::str; use {raw, signature, Error, Oid, Object, Signature, ObjectType}; use util::Binding; /// A structure to represent a git [tag][1] /// /// [1]: http://git-scm.com/book/en/Git-Basics-Tagging pub struct Tag<'repo> { raw: *mut raw::git_tag, _marker: marker::PhantomData>, } impl<'repo> Tag<'repo> { /// Get the id (SHA1) of a repository tag pub fn id(&self) -> Oid { unsafe { Binding::from_raw(raw::git_tag_id(&*self.raw)) } } /// Get the message of a tag /// /// Returns None if there is no message or if it is not valid utf8 pub fn message(&self) -> Option<&str> { self.message_bytes().and_then(|s| str::from_utf8(s).ok()) } /// Get the message of a tag /// /// Returns None if there is no message pub fn message_bytes(&self) -> Option<&[u8]> { unsafe { ::opt_bytes(self, raw::git_tag_message(&*self.raw)) } } /// Get the name of a tag /// /// Returns None if it is not valid utf8 pub fn name(&self) -> Option<&str> { str::from_utf8(self.name_bytes()).ok() } /// Get the name of a tag pub fn name_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, raw::git_tag_name(&*self.raw)).unwrap() } } /// Recursively peel a tag until a non tag git_object is found pub fn peel(&self) -> Result, Error> { let mut ret = 0 as *mut raw::git_object; unsafe { try_call!(raw::git_tag_peel(&mut ret, &*self.raw)); Ok(Binding::from_raw(ret)) } } /// Get the tagger (author) of a tag /// /// If the author is unspecified, then `None` is returned. pub fn tagger(&self) -> Option { unsafe { let ptr = raw::git_tag_tagger(&*self.raw); if ptr.is_null() { None } else { Some(signature::from_raw_const(self, ptr)) } } } /// Get the tagged object of a tag /// /// This method performs a repository lookup for the given object and /// returns it pub fn target(&self) -> Result, Error> { let mut ret = 0 as *mut raw::git_object; unsafe { try_call!(raw::git_tag_target(&mut ret, &*self.raw)); Ok(Binding::from_raw(ret)) } } /// Get the OID of the tagged object of a tag pub fn target_id(&self) -> Oid { unsafe { Binding::from_raw(raw::git_tag_target_id(&*self.raw)) } } /// Get the OID of the tagged object of a tag pub fn target_type(&self) -> Option { unsafe { ObjectType::from_raw(raw::git_tag_target_type(&*self.raw)) } } /// Casts this Tag to be usable as an `Object` pub fn as_object(&self) -> &Object<'repo> { unsafe { &*(self as *const _ as *const Object<'repo>) } } } impl<'repo> Binding for Tag<'repo> { type Raw = *mut raw::git_tag; unsafe fn from_raw(raw: *mut raw::git_tag) -> Tag<'repo> { Tag { raw: raw, _marker: marker::PhantomData } } fn raw(&self) -> *mut raw::git_tag { self.raw } } impl<'repo> Drop for Tag<'repo> { fn drop(&mut self) { unsafe { raw::git_tag_free(self.raw) } } } #[cfg(test)] mod tests { #[test] fn smoke() { let (_td, repo) = ::test::repo_init(); let head = repo.head().unwrap(); let id = head.target().unwrap(); assert!(repo.find_tag(id).is_err()); let obj = repo.find_object(id, None).unwrap(); let sig = repo.signature().unwrap(); let tag_id = repo.tag("foo", &obj, &sig, "msg", false).unwrap(); let tag = repo.find_tag(tag_id).unwrap(); assert_eq!(tag.id(), tag_id); let tags = repo.tag_names(None).unwrap(); assert_eq!(tags.len(), 1); assert_eq!(tags.get(0), Some("foo")); assert_eq!(tag.name(), Some("foo")); assert_eq!(tag.message(), Some("msg")); assert_eq!(tag.peel().unwrap().id(), obj.id()); assert_eq!(tag.target_id(), obj.id()); assert_eq!(tag.target_type(), Some(::ObjectType::Commit)); assert_eq!(tag.tagger().unwrap().name(), sig.name()); tag.target().unwrap(); repo.find_object(tag_id, None).unwrap().as_tag().unwrap(); repo.tag_delete("foo").unwrap(); } #[test] fn lite() { let (_td, repo) = ::test::repo_init(); let head = t!(repo.head()); let id = head.target().unwrap(); let obj = t!(repo.find_object(id, None)); let tag_id = t!(repo.tag_lightweight("foo", &obj, false)); assert!(repo.find_tag(tag_id).is_err()); assert_eq!(t!(repo.refname_to_id("refs/tags/foo")), id); let tags = t!(repo.tag_names(Some("f*"))); assert_eq!(tags.len(), 1); let tags = t!(repo.tag_names(Some("b*"))); assert_eq!(tags.len(), 0); } } deps/git2-0.3.3/src/describe.rs0000664000175000017500000001345212603147372013166 0ustar use std::marker; use std::mem; use std::ffi::CString; use libc::{c_uint, c_int}; use {raw, Repository, Error, Buf}; use util::Binding; /// The result of a `describe` operation on either an `Describe` or a /// `Repository`. pub struct Describe<'repo> { raw: *mut raw::git_describe_result, _marker: marker::PhantomData<&'repo Repository>, } /// Options which indicate how a `Describe` is created. pub struct DescribeOptions { raw: raw::git_describe_options, pattern: CString, } /// Options which can be used to customize how a description is formatted. pub struct DescribeFormatOptions { raw: raw::git_describe_format_options, dirty_suffix: CString, } impl<'repo> Describe<'repo> { /// Prints this describe result, returning the result as a string. pub fn format(&self, opts: Option<&DescribeFormatOptions>) -> Result { let buf = Buf::new(); let opts = opts.map(|o| &o.raw as *const _).unwrap_or(0 as *const _); unsafe { try_call!(raw::git_describe_format(buf.raw(), self.raw, opts)); } Ok(String::from_utf8(buf.to_vec()).unwrap()) } } impl<'repo> Binding for Describe<'repo> { type Raw = *mut raw::git_describe_result; unsafe fn from_raw(raw: *mut raw::git_describe_result) -> Describe<'repo> { Describe { raw: raw, _marker: marker::PhantomData, } } fn raw(&self) -> *mut raw::git_describe_result { self.raw } } impl<'repo> Drop for Describe<'repo> { fn drop(&mut self) { unsafe { raw::git_describe_result_free(self.raw) } } } impl DescribeFormatOptions { /// Creates a new blank set of formatting options for a description. pub fn new() -> DescribeFormatOptions { let mut opts = DescribeFormatOptions { raw: unsafe { mem::zeroed() }, dirty_suffix: CString::new(Vec::new()).unwrap(), }; opts.raw.version = 1; opts.raw.abbreviated_size = 7; return opts } /// Sets the size of the abbreviated commit id to use. /// /// The value is the lower bound for the length of the abbreviated string, /// and the default is 7. pub fn abbreviated_size(&mut self, size: u32) -> &mut Self { self.raw.abbreviated_size = size as c_uint; self } /// Sets whether or not the long format is used even when a shorter name /// could be used. pub fn always_use_long_format(&mut self, long: bool) -> &mut Self { self.raw.always_use_long_format = long as c_int; self } /// If the workdir is dirty and this is set, this string will be appended to /// the description string. pub fn dirty_suffix(&mut self, suffix: &str) -> &mut Self { self.dirty_suffix = CString::new(suffix).unwrap(); self.raw.dirty_suffix = self.dirty_suffix.as_ptr(); self } } impl DescribeOptions { /// Creates a new blank set of formatting options for a description. pub fn new() -> DescribeOptions { let mut opts = DescribeOptions { raw: unsafe { mem::zeroed() }, pattern: CString::new(Vec::new()).unwrap(), }; opts.raw.version = 1; opts.raw.max_candidates_tags = 10; return opts } #[allow(missing_docs)] pub fn max_candidates_tags(&mut self, max: u32) -> &mut Self { self.raw.max_candidates_tags = max as c_uint; self } /// Sets the reference lookup strategy /// /// This behaves like the `--tags` option to git-decribe. pub fn describe_tags(&mut self) -> &mut Self { self.raw.describe_strategy = raw::GIT_DESCRIBE_TAGS as c_uint; self } /// Sets the reference lookup strategy /// /// This behaves like the `--all` option to git-decribe. pub fn describe_all(&mut self) -> &mut Self { self.raw.describe_strategy = raw::GIT_DESCRIBE_ALL as c_uint; self } /// Indicates when calculating the distance from the matching tag or /// reference whether to only walk down the first-parent ancestry. pub fn only_follow_first_parent(&mut self, follow: bool) -> &mut Self { self.raw.only_follow_first_parent = follow as c_int; self } /// If no matching tag or reference is found whether a describe option would /// normally fail. This option indicates, however, that it will instead fall /// back to showing the full id of the commit. pub fn show_commit_oid_as_fallback(&mut self, show: bool) -> &mut Self { self.raw.show_commit_oid_as_fallback = show as c_int; self } #[allow(missing_docs)] pub fn pattern(&mut self, pattern: &str) -> &mut Self { self.pattern = CString::new(pattern).unwrap(); self.raw.pattern = self.pattern.as_ptr(); self } } impl Binding for DescribeOptions { type Raw = *mut raw::git_describe_options; unsafe fn from_raw(_raw: *mut raw::git_describe_options) -> DescribeOptions { panic!("unimplemened") } fn raw(&self) -> *mut raw::git_describe_options { &self.raw as *const _ as *mut _ } } #[cfg(test)] mod tests { use DescribeOptions; #[test] fn smoke() { let (_td, repo) = ::test::repo_init(); let head = t!(repo.head()).target().unwrap(); let d = t!(repo.describe(DescribeOptions::new() .show_commit_oid_as_fallback(true))); let id = head.to_string(); assert_eq!(t!(d.format(None)), &id[..7]); let obj = t!(repo.find_object(head, None)); let sig = t!(repo.signature()); t!(repo.tag("foo", &obj, &sig, "message", true)); let d = t!(repo.describe(&DescribeOptions::new())); assert_eq!(t!(d.format(None)), "foo"); let d = t!(obj.describe(&DescribeOptions::new())); assert_eq!(t!(d.format(None)), "foo"); } } deps/git2-0.3.3/src/repo.rs0000664000175000017500000022746712620677726012402 0ustar use std::ffi::{CStr, CString}; use std::iter::IntoIterator; use std::mem; use std::path::Path; use std::str; use libc::{c_int, c_char, size_t, c_void, c_uint}; use {raw, Revspec, Error, init, Object, RepositoryState, Remote, Buf}; use {ResetType, Signature, Reference, References, Submodule, Blame, BlameOptions}; use {Branches, BranchType, Index, Config, Oid, Blob, Branch, Commit, Tree}; use {AnnotatedCommit, MergeOptions, SubmoduleIgnore, SubmoduleStatus}; use {ObjectType, Tag, Note, Notes, StatusOptions, Statuses, Status, Revwalk}; use {RevparseMode, RepositoryInitMode, Reflog, IntoCString, Describe}; use {DescribeOptions, TreeBuilder, Diff, DiffOptions}; use build::{RepoBuilder, CheckoutBuilder}; use string_array::StringArray; use oid_array::OidArray; use util::{self, Binding}; /// An owned git repository, representing all state associated with the /// underlying filesystem. /// /// This structure corresponds to a `git_repository` in libgit2. Many other /// types in git2-rs are derivative from this structure and are attached to its /// lifetime. /// /// When a repository goes out of scope it is freed in memory but not deleted /// from the filesystem. pub struct Repository { raw: *mut raw::git_repository, } // It is the current belief that a `Repository` can be sent among threads, or // even shared among threads in a mutex. unsafe impl Send for Repository {} /// Options which can be used to configure how a repository is initialized pub struct RepositoryInitOptions { flags: u32, mode: u32, workdir_path: Option, description: Option, template_path: Option, initial_head: Option, origin_url: Option, } impl Repository { /// Attempt to open an already-existing repository at `path`. /// /// The path can point to either a normal or bare repository. pub fn open>(path: P) -> Result { init(); let path = try!(path.as_ref().into_c_string()); let mut ret = 0 as *mut raw::git_repository; unsafe { try_call!(raw::git_repository_open(&mut ret, path)); Ok(Binding::from_raw(ret)) } } /// Attempt to open an already-existing repository at or above `path` /// /// This starts at `path` and looks up the filesystem hierarchy /// until it finds a repository. pub fn discover>(path: P) -> Result { // TODO: this diverges significantly from the libgit2 API init(); let buf = Buf::new(); let path = try!(path.as_ref().into_c_string()); unsafe { try_call!(raw::git_repository_discover(buf.raw(), path, 1, 0 as *const _)); } Repository::open(util::bytes2path(&*buf)) } /// Creates a new repository in the specified folder. /// /// This by default will create any necessary directories to create the /// repository, and it will read any user-specified templates when creating /// the repository. This behavior can be configured through `init_opts`. pub fn init>(path: P) -> Result { Repository::init_opts(path, &RepositoryInitOptions::new()) } /// Creates a new `--bare` repository in the specified folder. /// /// The folder must exist prior to invoking this function. pub fn init_bare>(path: P) -> Result { Repository::init_opts(path, RepositoryInitOptions::new().bare(true)) } /// Creates a new `--bare` repository in the specified folder. /// /// The folder must exist prior to invoking this function. pub fn init_opts>(path: P, opts: &RepositoryInitOptions) -> Result { init(); let path = try!(path.as_ref().into_c_string()); let mut ret = 0 as *mut raw::git_repository; unsafe { let mut opts = opts.raw(); try_call!(raw::git_repository_init_ext(&mut ret, path, &mut opts)); Ok(Binding::from_raw(ret)) } } /// Clone a remote repository. /// /// See the `RepoBuilder` struct for more information. This function will /// delegate to a fresh `RepoBuilder` pub fn clone>(url: &str, into: P) -> Result { ::init(); RepoBuilder::new().clone(url, into.as_ref()) } /// Execute a rev-parse operation against the `spec` listed. /// /// The resulting revision specification is returned, or an error is /// returned if one occurs. pub fn revparse(&self, spec: &str) -> Result { let mut raw = raw::git_revspec { from: 0 as *mut _, to: 0 as *mut _, flags: 0, }; let spec = try!(CString::new(spec)); unsafe { try_call!(raw::git_revparse(&mut raw, self.raw, spec)); let to = Binding::from_raw_opt(raw.to); let from = Binding::from_raw_opt(raw.from); let mode = RevparseMode::from_bits_truncate(raw.flags as u32); Ok(Revspec::from_objects(from, to, mode)) } } /// Find a single object, as specified by a revision string. pub fn revparse_single(&self, spec: &str) -> Result { let spec = try!(CString::new(spec)); let mut obj = 0 as *mut raw::git_object; unsafe { try_call!(raw::git_revparse_single(&mut obj, self.raw, spec)); assert!(!obj.is_null()); Ok(Binding::from_raw(obj)) } } /// Find a single object and intermediate reference by a revision string. /// /// See `man gitrevisions`, or /// http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for /// information on the syntax accepted. /// /// In some cases (`@{<-n>}` or `@{upstream}`), the expression /// may point to an intermediate reference. When such expressions are being /// passed in, this intermediate reference is returned. pub fn revparse_ext(&self, spec: &str) -> Result<(Object, Option), Error> { let spec = try!(CString::new(spec)); let mut git_obj = 0 as *mut raw::git_object; let mut git_ref = 0 as *mut raw::git_reference; unsafe { try_call!(raw::git_revparse_ext(&mut git_obj, &mut git_ref, self.raw, spec)); assert!(!git_obj.is_null()); Ok((Binding::from_raw(git_obj), Binding::from_raw_opt(git_ref))) } } /// Tests whether this repository is a bare repository or not. pub fn is_bare(&self) -> bool { unsafe { raw::git_repository_is_bare(self.raw) == 1 } } /// Tests whether this repository is a shallow clone. pub fn is_shallow(&self) -> bool { unsafe { raw::git_repository_is_shallow(self.raw) == 1 } } /// Tests whether this repository is empty. pub fn is_empty(&self) -> Result { let empty = unsafe { try_call!(raw::git_repository_is_empty(self.raw)) }; Ok(empty == 1) } /// Returns the path to the `.git` folder for normal repositories or the /// repository itself for bare repositories. pub fn path(&self) -> &Path { unsafe { let ptr = raw::git_repository_path(self.raw); util::bytes2path(::opt_bytes(self, ptr).unwrap()) } } /// Returns the current state of this repository pub fn state(&self) -> RepositoryState { let state = unsafe { raw::git_repository_state(self.raw) }; macro_rules! check( ($($raw:ident => $real:ident),*) => ( $(if state == raw::$raw as c_int { super::RepositoryState::$real }) else * else { panic!("unknown repository state: {}", state) } ) ); check!( GIT_REPOSITORY_STATE_NONE => Clean, GIT_REPOSITORY_STATE_MERGE => Merge, GIT_REPOSITORY_STATE_REVERT => Revert, GIT_REPOSITORY_STATE_CHERRYPICK => CherryPick, GIT_REPOSITORY_STATE_BISECT => Bisect, GIT_REPOSITORY_STATE_REBASE => Rebase, GIT_REPOSITORY_STATE_REBASE_INTERACTIVE => RebaseInteractive, GIT_REPOSITORY_STATE_REBASE_MERGE => RebaseMerge, GIT_REPOSITORY_STATE_APPLY_MAILBOX => ApplyMailbox, GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE => ApplyMailboxOrRebase ) } /// Get the path of the working directory for this repository. /// /// If this repository is bare, then `None` is returned. pub fn workdir(&self) -> Option<&Path> { unsafe { let ptr = raw::git_repository_workdir(self.raw); if ptr.is_null() { None } else { Some(util::bytes2path(CStr::from_ptr(ptr).to_bytes())) } } } /// Get the currently active namespace for this repository. /// /// If there is no namespace, or the namespace is not a valid utf8 string, /// `None` is returned. pub fn namespace(&self) -> Option<&str> { self.namespace_bytes().and_then(|s| str::from_utf8(s).ok()) } /// Get the currently active namespace for this repository as a byte array. /// /// If there is no namespace, `None` is returned. pub fn namespace_bytes(&self) -> Option<&[u8]> { unsafe { ::opt_bytes(self, raw::git_repository_get_namespace(self.raw)) } } /// List all remotes for a given repository pub fn remotes(&self) -> Result { let mut arr = raw::git_strarray { strings: 0 as *mut *mut c_char, count: 0, }; unsafe { try_call!(raw::git_remote_list(&mut arr, self.raw)); Ok(Binding::from_raw(arr)) } } /// Get the information for a particular remote pub fn find_remote(&self, name: &str) -> Result { let mut ret = 0 as *mut raw::git_remote; let name = try!(CString::new(name)); unsafe { try_call!(raw::git_remote_lookup(&mut ret, self.raw, name)); Ok(Binding::from_raw(ret)) } } /// Add a remote with the default fetch refspec to the repository's /// configuration. pub fn remote(&self, name: &str, url: &str) -> Result { let mut ret = 0 as *mut raw::git_remote; let name = try!(CString::new(name)); let url = try!(CString::new(url)); unsafe { try_call!(raw::git_remote_create(&mut ret, self.raw, name, url)); Ok(Binding::from_raw(ret)) } } /// Create an anonymous remote /// /// Create a remote with the given url and refspec in memory. You can use /// this when you have a URL instead of a remote's name. Note that anonymous /// remotes cannot be converted to persisted remotes. pub fn remote_anonymous(&self, url: &str) -> Result { let mut ret = 0 as *mut raw::git_remote; let url = try!(CString::new(url)); unsafe { try_call!(raw::git_remote_create_anonymous(&mut ret, self.raw, url)); Ok(Binding::from_raw(ret)) } } /// Give a remote a new name /// /// All remote-tracking branches and configuration settings for the remote /// are updated. /// /// A temporary in-memory remote cannot be given a name with this method. /// /// No loaded instances of the remote with the old name will change their /// name or their list of refspecs. /// /// The returned array of strings is a list of the non-default refspecs /// which cannot be renamed and are returned for further processing by the /// caller. pub fn remote_rename(&self, name: &str, new_name: &str) -> Result { let name = try!(CString::new(name)); let new_name = try!(CString::new(new_name)); let mut problems = raw::git_strarray { count: 0, strings: 0 as *mut *mut c_char, }; unsafe { try_call!(raw::git_remote_rename(&mut problems, self.raw, name, new_name)); Ok(Binding::from_raw(problems)) } } /// Delete an existing persisted remote. /// /// All remote-tracking branches and configuration settings for the remote /// will be removed. pub fn remote_delete(&self, name: &str) -> Result<(), Error> { let name = try!(CString::new(name)); unsafe { try_call!(raw::git_remote_delete(self.raw, name)); } Ok(()) } /// Add a fetch refspec to the remote's configuration /// /// Add the given refspec to the fetch list in the configuration. No loaded /// remote instances will be affected. pub fn remote_add_fetch(&self, name: &str, spec: &str) -> Result<(), Error> { let name = try!(CString::new(name)); let spec = try!(CString::new(spec)); unsafe { try_call!(raw::git_remote_add_fetch(self.raw, name, spec)); } Ok(()) } /// Add a push refspec to the remote's configuration. /// /// Add the given refspec to the push list in the configuration. No /// loaded remote instances will be affected. pub fn remote_add_push(&self, name: &str, spec: &str) -> Result<(), Error> { let name = try!(CString::new(name)); let spec = try!(CString::new(spec)); unsafe { try_call!(raw::git_remote_add_push(self.raw, name, spec)); } Ok(()) } /// Set the remote's url in the configuration /// /// Remote objects already in memory will not be affected. This assumes /// the common case of a single-url remote and will otherwise return an /// error. pub fn remote_set_url(&self, name: &str, url: &str) -> Result<(), Error> { let name = try!(CString::new(name)); let url = try!(CString::new(url)); unsafe { try_call!(raw::git_remote_set_url(self.raw, name, url)); } Ok(()) } /// Set the remote's url for pushing in the configuration. /// /// Remote objects already in memory will not be affected. This assumes /// the common case of a single-url remote and will otherwise return an /// error. /// /// `None` indicates that it should be cleared. pub fn remote_set_pushurl(&self, name: &str, pushurl: Option<&str>) -> Result<(), Error> { let name = try!(CString::new(name)); let pushurl = try!(::opt_cstr(pushurl)); unsafe { try_call!(raw::git_remote_set_pushurl(self.raw, name, pushurl)); } Ok(()) } /// Sets the current head to the specified object and optionally resets /// the index and working tree to match. /// /// A soft reset means the head will be moved to the commit. /// /// A mixed reset will trigger a soft reset, plus the index will be /// replaced with the content of the commit tree. /// /// A hard reset will trigger a mixed reset and the working directory will /// be replaced with the content of the index. (Untracked and ignored files /// will be left alone, however.) /// /// The `target` is a commit-ish to which the head should be moved to. The /// object can either be a commit or a tag, but tags must be derefernceable /// to a commit. /// /// The `checkout` options will only be used for a hard reset. pub fn reset(&self, target: &Object, kind: ResetType, checkout: Option<&mut CheckoutBuilder>) -> Result<(), Error> { unsafe { let mut opts: raw::git_checkout_options = mem::zeroed(); let opts = checkout.map(|c| { c.configure(&mut opts); &mut opts }); try_call!(raw::git_reset(self.raw, target.raw(), kind, opts)); } Ok(()) } /// Updates some entries in the index from the target commit tree. /// /// The scope of the updated entries is determined by the paths being /// in the iterator provided. /// /// Passing a `None` target will result in removing entries in the index /// matching the provided pathspecs. pub fn reset_default(&self, target: Option<&Object>, paths: I) -> Result<(), Error> where T: IntoCString, I: IntoIterator, { let (_a, _b, mut arr) = try!(::util::iter2cstrs(paths)); let target = target.map(|t| t.raw()); unsafe { try_call!(raw::git_reset_default(self.raw, target, &mut arr)); } Ok(()) } /// Retrieve and resolve the reference pointed at by HEAD. pub fn head(&self) -> Result { let mut ret = 0 as *mut raw::git_reference; unsafe { try_call!(raw::git_repository_head(&mut ret, self.raw)); Ok(Binding::from_raw(ret)) } } /// Make the repository HEAD point to the specified reference. /// /// If the provided reference points to a tree or a blob, the HEAD is /// unaltered and an error is returned. /// /// If the provided reference points to a branch, the HEAD will point to /// that branch, staying attached, or become attached if it isn't yet. If /// the branch doesn't exist yet, no error will be returned. The HEAD will /// then be attached to an unborn branch. /// /// Otherwise, the HEAD will be detached and will directly point to the /// commit. pub fn set_head(&self, refname: &str) -> Result<(), Error> { let refname = try!(CString::new(refname)); unsafe { try_call!(raw::git_repository_set_head(self.raw, refname)); } Ok(()) } /// Make the repository HEAD directly point to the commit. /// /// If the provided committish cannot be found in the repository, the HEAD /// is unaltered and an error is returned. /// /// If the provided commitish cannot be peeled into a commit, the HEAD is /// unaltered and an error is returned. /// /// Otherwise, the HEAD will eventually be detached and will directly point /// to the peeled commit. pub fn set_head_detached(&self, commitish: Oid) -> Result<(), Error> { unsafe { try_call!(raw::git_repository_set_head_detached(self.raw, commitish.raw())); } Ok(()) } /// Create an iterator for the repo's references pub fn references(&self) -> Result { let mut ret = 0 as *mut raw::git_reference_iterator; unsafe { try_call!(raw::git_reference_iterator_new(&mut ret, self.raw)); Ok(Binding::from_raw(ret)) } } /// Create an iterator for the repo's references that match the specified /// glob pub fn references_glob(&self, glob: &str) -> Result { let mut ret = 0 as *mut raw::git_reference_iterator; let glob = try!(CString::new(glob)); unsafe { try_call!(raw::git_reference_iterator_glob_new(&mut ret, self.raw, glob)); Ok(Binding::from_raw(ret)) } } /// Load all submodules for this repository and return them. pub fn submodules(&self) -> Result, Error> { struct Data<'a, 'b:'a> { repo: &'b Repository, ret: &'a mut Vec>, } let mut ret = Vec::new(); unsafe { let mut data = Data { repo: self, ret: &mut ret, }; try_call!(raw::git_submodule_foreach(self.raw, append, &mut data as *mut _ as *mut c_void)); } return Ok(ret); extern fn append(_repo: *mut raw::git_submodule, name: *const c_char, data: *mut c_void) -> c_int { unsafe { let data = &mut *(data as *mut Data); let mut raw = 0 as *mut raw::git_submodule; let rc = raw::git_submodule_lookup(&mut raw, data.repo.raw(), name); assert_eq!(rc, 0); data.ret.push(Binding::from_raw(raw)); } 0 } } /// Gather file status information and populate the returned structure. /// /// Note that if a pathspec is given in the options to filter the /// status, then the results from rename detection (if you enable it) may /// not be accurate. To do rename detection properly, this must be called /// with no pathspec so that all files can be considered. pub fn statuses(&self, options: Option<&mut StatusOptions>) -> Result { let mut ret = 0 as *mut raw::git_status_list; unsafe { try_call!(raw::git_status_list_new(&mut ret, self.raw, options.map(|s| s.raw()) .unwrap_or(0 as *const _))); Ok(Binding::from_raw(ret)) } } /// Test if the ignore rules apply to a given file. /// /// This function checks the ignore rules to see if they would apply to the /// given file. This indicates if the file would be ignored regardless of /// whether the file is already in the index or committed to the repository. /// /// One way to think of this is if you were to do "git add ." on the /// directory containing the file, would it be added or not? pub fn status_should_ignore(&self, path: &Path) -> Result { let mut ret = 0 as c_int; let path = try!(path.into_c_string()); unsafe { try_call!(raw::git_status_should_ignore(&mut ret, self.raw, path)); } Ok(ret != 0) } /// Get file status for a single file. /// /// This tries to get status for the filename that you give. If no files /// match that name (in either the HEAD, index, or working directory), this /// returns NotFound. /// /// If the name matches multiple files (for example, if the path names a /// directory or if running on a case- insensitive filesystem and yet the /// HEAD has two entries that both match the path), then this returns /// Ambiguous because it cannot give correct results. /// /// This does not do any sort of rename detection. Renames require a set of /// targets and because of the path filtering, there is not enough /// information to check renames correctly. To check file status with rename /// detection, there is no choice but to do a full `statuses` and scan /// through looking for the path that you are interested in. pub fn status_file(&self, path: &Path) -> Result { let mut ret = 0 as c_uint; let path = try!(path.into_c_string()); unsafe { try_call!(raw::git_status_file(&mut ret, self.raw, path)); } Ok(Status::from_bits_truncate(ret as u32)) } /// Create an iterator which loops over the requested branches. pub fn branches(&self, filter: Option) -> Result { let mut raw = 0 as *mut raw::git_branch_iterator; unsafe { try_call!(raw::git_branch_iterator_new(&mut raw, self.raw(), filter)); Ok(Branches::from_raw(raw)) } } /// Get the Index file for this repository. /// /// If a custom index has not been set, the default index for the repository /// will be returned (the one located in .git/index). pub fn index(&self) -> Result { let mut raw = 0 as *mut raw::git_index; unsafe { try_call!(raw::git_repository_index(&mut raw, self.raw())); Ok(Binding::from_raw(raw)) } } /// Get the configuration file for this repository. /// /// If a configuration file has not been set, the default config set for the /// repository will be returned, including global and system configurations /// (if they are available). pub fn config(&self) -> Result { let mut raw = 0 as *mut raw::git_config; unsafe { try_call!(raw::git_repository_config(&mut raw, self.raw())); Ok(Binding::from_raw(raw)) } } /// Write an in-memory buffer to the ODB as a blob. /// /// The Oid returned can in turn be passed to `find_blob` to get a handle to /// the blob. pub fn blob(&self, data: &[u8]) -> Result { let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; unsafe { let ptr = data.as_ptr() as *const c_void; let len = data.len() as size_t; try_call!(raw::git_blob_create_frombuffer(&mut raw, self.raw(), ptr, len)); Ok(Binding::from_raw(&raw as *const _)) } } /// Read a file from the filesystem and write its content to the Object /// Database as a loose blob /// /// The Oid returned can in turn be passed to `find_blob` to get a handle to /// the blob. pub fn blob_path(&self, path: &Path) -> Result { let path = try!(path.into_c_string()); let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; unsafe { try_call!(raw::git_blob_create_fromdisk(&mut raw, self.raw(), path)); Ok(Binding::from_raw(&raw as *const _)) } } /// Lookup a reference to one of the objects in a repository. pub fn find_blob(&self, oid: Oid) -> Result { let mut raw = 0 as *mut raw::git_blob; unsafe { try_call!(raw::git_blob_lookup(&mut raw, self.raw(), oid.raw())); Ok(Binding::from_raw(raw)) } } /// Create a new branch pointing at a target commit /// /// A new direct reference will be created pointing to this target commit. /// If `force` is true and a reference already exists with the given name, /// it'll be replaced. pub fn branch(&self, branch_name: &str, target: &Commit, force: bool) -> Result { let branch_name = try!(CString::new(branch_name)); let mut raw = 0 as *mut raw::git_reference; unsafe { try_call!(raw::git_branch_create(&mut raw, self.raw(), branch_name, target.raw(), force)); Ok(Branch::wrap(Binding::from_raw(raw))) } } /// Lookup a branch by its name in a repository. pub fn find_branch(&self, name: &str, branch_type: BranchType) -> Result { let name = try!(CString::new(name)); let mut ret = 0 as *mut raw::git_reference; unsafe { try_call!(raw::git_branch_lookup(&mut ret, self.raw(), name, branch_type)); Ok(Branch::wrap(Binding::from_raw(ret))) } } /// Create new commit in the repository /// /// If the `update_ref` is not `None`, name of the reference that will be /// updated to point to this commit. If the reference is not direct, it will /// be resolved to a direct reference. Use "HEAD" to update the HEAD of the /// current branch and make it point to this commit. If the reference /// doesn't exist yet, it will be created. If it does exist, the first /// parent must be the tip of this branch. pub fn commit(&self, update_ref: Option<&str>, author: &Signature, committer: &Signature, message: &str, tree: &Tree, parents: &[&Commit]) -> Result { let update_ref = try!(::opt_cstr(update_ref)); let mut parent_ptrs = parents.iter().map(|p| { p.raw() as *const raw::git_commit }).collect::>(); let message = try!(CString::new(message)); let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; unsafe { try_call!(raw::git_commit_create(&mut raw, self.raw(), update_ref, author.raw(), committer.raw(), 0 as *const c_char, message, tree.raw(), parents.len() as size_t, parent_ptrs.as_mut_ptr())); Ok(Binding::from_raw(&raw as *const _)) } } /// Lookup a reference to one of the commits in a repository. pub fn find_commit(&self, oid: Oid) -> Result { let mut raw = 0 as *mut raw::git_commit; unsafe { try_call!(raw::git_commit_lookup(&mut raw, self.raw(), oid.raw())); Ok(Binding::from_raw(raw)) } } /// Lookup a reference to one of the objects in a repository. pub fn find_object(&self, oid: Oid, kind: Option) -> Result { let mut raw = 0 as *mut raw::git_object; unsafe { try_call!(raw::git_object_lookup(&mut raw, self.raw(), oid.raw(), kind)); Ok(Binding::from_raw(raw)) } } /// Create a new direct reference. /// /// This function will return an error if a reference already exists with /// the given name unless force is true, in which case it will be /// overwritten. pub fn reference(&self, name: &str, id: Oid, force: bool, log_message: &str) -> Result { let name = try!(CString::new(name)); let log_message = try!(CString::new(log_message)); let mut raw = 0 as *mut raw::git_reference; unsafe { try_call!(raw::git_reference_create(&mut raw, self.raw(), name, id.raw(), force, log_message)); Ok(Binding::from_raw(raw)) } } /// Create a new symbolic reference. /// /// This function will return an error if a reference already exists with /// the given name unless force is true, in which case it will be /// overwritten. pub fn reference_symbolic(&self, name: &str, target: &str, force: bool, log_message: &str) -> Result { let name = try!(CString::new(name)); let target = try!(CString::new(target)); let log_message = try!(CString::new(log_message)); let mut raw = 0 as *mut raw::git_reference; unsafe { try_call!(raw::git_reference_symbolic_create(&mut raw, self.raw(), name, target, force, log_message)); Ok(Binding::from_raw(raw)) } } /// Lookup a reference to one of the objects in a repository. pub fn find_reference(&self, name: &str) -> Result { let name = try!(CString::new(name)); let mut raw = 0 as *mut raw::git_reference; unsafe { try_call!(raw::git_reference_lookup(&mut raw, self.raw(), name)); Ok(Binding::from_raw(raw)) } } /// Lookup a reference by name and resolve immediately to OID. /// /// This function provides a quick way to resolve a reference name straight /// through to the object id that it refers to. This avoids having to /// allocate or free any `Reference` objects for simple situations. pub fn refname_to_id(&self, name: &str) -> Result { let name = try!(CString::new(name)); let mut ret = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; unsafe { try_call!(raw::git_reference_name_to_id(&mut ret, self.raw(), name)); Ok(Binding::from_raw(&ret as *const _)) } } /// Creates a git_annotated_commit from the given reference. pub fn reference_to_annotated_commit(&self, reference: &Reference) -> Result { let mut ret = 0 as *mut raw::git_annotated_commit; unsafe { try_call!(raw::git_annotated_commit_from_ref(&mut ret, self.raw(), reference.raw())); Ok(AnnotatedCommit::from_raw(ret)) } } /// Create a new action signature with default user and now timestamp. /// /// This looks up the user.name and user.email from the configuration and /// uses the current time as the timestamp, and creates a new signature /// based on that information. It will return `NotFound` if either the /// user.name or user.email are not set. pub fn signature(&self) -> Result, Error> { let mut ret = 0 as *mut raw::git_signature; unsafe { try_call!(raw::git_signature_default(&mut ret, self.raw())); Ok(Binding::from_raw(ret)) } } /// Set up a new git submodule for checkout. /// /// This does "git submodule add" up to the fetch and checkout of the /// submodule contents. It preps a new submodule, creates an entry in /// `.gitmodules` and creates an empty initialized repository either at the /// given path in the working directory or in `.git/modules` with a gitlink /// from the working directory to the new repo. /// /// To fully emulate "git submodule add" call this function, then `open()` /// the submodule repo and perform the clone step as needed. Lastly, call /// `finalize()` to wrap up adding the new submodule and `.gitmodules` to /// the index to be ready to commit. pub fn submodule(&self, url: &str, path: &Path, use_gitlink: bool) -> Result { let url = try!(CString::new(url)); let path = try!(path.into_c_string()); let mut raw = 0 as *mut raw::git_submodule; unsafe { try_call!(raw::git_submodule_add_setup(&mut raw, self.raw(), url, path, use_gitlink)); Ok(Binding::from_raw(raw)) } } /// Lookup submodule information by name or path. /// /// Given either the submodule name or path (they are usually the same), /// this returns a structure describing the submodule. pub fn find_submodule(&self, name: &str) -> Result { let name = try!(CString::new(name)); let mut raw = 0 as *mut raw::git_submodule; unsafe { try_call!(raw::git_submodule_lookup(&mut raw, self.raw(), name)); Ok(Binding::from_raw(raw)) } } /// Get the status for a submodule. /// /// This looks at a submodule and tries to determine the status. It /// will return a combination of the `SubmoduleStatus` values. pub fn submodule_status(&self, name: &str, ignore: SubmoduleIgnore) -> Result { let mut ret = 0; let name = try!(CString::new(name)); unsafe { try_call!(raw::git_submodule_status(&mut ret, self.raw, name, ignore)); } Ok(SubmoduleStatus::from_bits_truncate(ret as u32)) } /// Lookup a reference to one of the objects in a repository. pub fn find_tree(&self, oid: Oid) -> Result { let mut raw = 0 as *mut raw::git_tree; unsafe { try_call!(raw::git_tree_lookup(&mut raw, self.raw(), oid.raw())); Ok(Binding::from_raw(raw)) } } /// Create a new TreeBuilder, optionally initialized with the /// entries of the given Tree. /// /// The tree builder can be used to create or modify trees in memory and /// write them as tree objects to the database. pub fn treebuilder(&self, tree: Option<&Tree>) -> Result { unsafe { let mut ret = 0 as *mut raw::git_treebuilder; let tree = match tree { Some(tree) => tree.raw(), None => 0 as *mut raw::git_tree, }; try_call!(raw::git_treebuilder_new(&mut ret, self.raw, tree)); Ok(Binding::from_raw(ret)) } } /// Create a new tag in the repository from an object /// /// A new reference will also be created pointing to this tag object. If /// `force` is true and a reference already exists with the given name, /// it'll be replaced. /// /// The message will not be cleaned up. /// /// The tag name will be checked for validity. You must avoid the characters /// '~', '^', ':', ' \ ', '?', '[', and '*', and the sequences ".." and " @ /// {" which have special meaning to revparse. pub fn tag(&self, name: &str, target: &Object, tagger: &Signature, message: &str, force: bool) -> Result { let name = try!(CString::new(name)); let message = try!(CString::new(message)); let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; unsafe { try_call!(raw::git_tag_create(&mut raw, self.raw, name, target.raw(), tagger.raw(), message, force)); Ok(Binding::from_raw(&raw as *const _)) } } /// Create a new lightweight tag pointing at a target object /// /// A new direct reference will be created pointing to this target object. /// If force is true and a reference already exists with the given name, /// it'll be replaced. pub fn tag_lightweight(&self, name: &str, target: &Object, force: bool) -> Result { let name = try!(CString::new(name)); let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; unsafe { try_call!(raw::git_tag_create_lightweight(&mut raw, self.raw, name, target.raw(), force)); Ok(Binding::from_raw(&raw as *const _)) } } /// Lookup a tag object from the repository. pub fn find_tag(&self, id: Oid) -> Result { let mut raw = 0 as *mut raw::git_tag; unsafe { try_call!(raw::git_tag_lookup(&mut raw, self.raw, id.raw())); Ok(Binding::from_raw(raw)) } } /// Delete an existing tag reference. /// /// The tag name will be checked for validity, see `tag` for some rules /// about valid names. pub fn tag_delete(&self, name: &str) -> Result<(), Error> { let name = try!(CString::new(name)); unsafe { try_call!(raw::git_tag_delete(self.raw, name)); Ok(()) } } /// Get a list with all the tags in the repository. /// /// An optional fnmatch pattern can also be specified. pub fn tag_names(&self, pattern: Option<&str>) -> Result { let mut arr = raw::git_strarray { strings: 0 as *mut *mut c_char, count: 0, }; unsafe { match pattern { Some(s) => { let s = try!(CString::new(s)); try_call!(raw::git_tag_list_match(&mut arr, s, self.raw)); } None => { try_call!(raw::git_tag_list(&mut arr, self.raw)); } } Ok(Binding::from_raw(arr)) } } /// Updates files in the index and the working tree to match the content of /// the commit pointed at by HEAD. pub fn checkout_head(&self, opts: Option<&mut CheckoutBuilder>) -> Result<(), Error> { unsafe { let mut raw_opts = mem::zeroed(); try_call!(raw::git_checkout_init_options(&mut raw_opts, raw::GIT_CHECKOUT_OPTIONS_VERSION)); match opts { Some(c) => c.configure(&mut raw_opts), None => {} } try_call!(raw::git_checkout_head(self.raw, &raw_opts)); } Ok(()) } /// Updates files in the working tree to match the content of the index. /// /// If the index is `None`, the repository's index will be used. pub fn checkout_index(&self, index: Option<&mut Index>, opts: Option<&mut CheckoutBuilder>) -> Result<(), Error> { unsafe { let mut raw_opts = mem::zeroed(); try_call!(raw::git_checkout_init_options(&mut raw_opts, raw::GIT_CHECKOUT_OPTIONS_VERSION)); match opts { Some(c) => c.configure(&mut raw_opts), None => {} } try_call!(raw::git_checkout_index(self.raw, index.map(|i| &mut *i.raw()), &raw_opts)); } Ok(()) } /// Updates files in the index and working tree to match the content of the /// tree pointed at by the treeish. pub fn checkout_tree(&self, treeish: &Object, opts: Option<&mut CheckoutBuilder>) -> Result<(), Error> { unsafe { let mut raw_opts = mem::zeroed(); try_call!(raw::git_checkout_init_options(&mut raw_opts, raw::GIT_CHECKOUT_OPTIONS_VERSION)); match opts { Some(c) => c.configure(&mut raw_opts), None => {} } try_call!(raw::git_checkout_tree(self.raw, &*treeish.raw(), &raw_opts)); } Ok(()) } /// Merges the given commit(s) into HEAD, writing the results into the /// working directory. Any changes are staged for commit and any conflicts /// are written to the index. Callers should inspect the repository's index /// after this completes, resolve any conflicts and prepare a commit. /// /// The merge performed uses the first common ancestor, unlike the /// git-merge-recursive strategy, which may produce an artificial common /// ancestor tree when there are multiple ancestors. /// For compatibility with git, the repository is put into a merging state. /// Once the commit is done (or if the uses wishes to abort), you should /// clear this state by calling git_repository_state_cleanup(). pub fn merge(&self, annotated_commits: &[&AnnotatedCommit], merge_opts: Option<&mut MergeOptions>, checkout_opts: Option<&mut CheckoutBuilder>) -> Result<(), Error> { unsafe { let mut raw_checkout_opts = mem::zeroed(); try_call!(raw::git_checkout_init_options(&mut raw_checkout_opts, raw::GIT_CHECKOUT_OPTIONS_VERSION)); if let Some(c) = checkout_opts { c.configure(&mut raw_checkout_opts); } let mut commit_ptrs = annotated_commits.iter().map(|c| { c.raw() as *const raw::git_annotated_commit }).collect::>(); try_call!(raw::git_merge(self.raw, commit_ptrs.as_mut_ptr(), annotated_commits.len() as size_t, merge_opts.map(|o| o.raw()) .unwrap_or(0 as *const _), &raw_checkout_opts)); } Ok(()) } /// Merge two commits, producing an index that reflects the result of /// the merge. The index may be written as-is to the working directory or /// checked out. If the index is to be converted to a tree, the caller /// should resolve any conflicts that arose as part of the merge. /// /// The merge performed uses the first common ancestor, unlike the /// git-merge-recursive strategy, which may produce an artificial common /// ancestor tree when there are multiple ancestors. /// /// The returned index must be freed explicitly with git_index_free. pub fn merge_commits(&self, our_commit: &Commit, their_commit: &Commit, opts: Option<&MergeOptions>) -> Result { let mut raw = 0 as *mut raw::git_index; unsafe { try_call!(raw::git_merge_commits(&mut raw, self.raw, our_commit.raw(), their_commit.raw(), opts.map(|o| o.raw()))); Ok(Binding::from_raw(raw)) } } /// Remove all the metadata associated with an ongoing command like merge, /// revert, cherry-pick, etc. For example: MERGE_HEAD, MERGE_MSG, etc. pub fn cleanup_state(&self) -> Result<(), Error> { unsafe { try_call!(raw::git_repository_state_cleanup(self.raw)); } Ok(()) } /// Add a note for an object /// /// The `notes_ref` argument is the canonical name of the reference to use, /// defaulting to "refs/notes/commits". If `force` is specified then /// previous notes are overwritten. pub fn note(&self, author: &Signature, committer: &Signature, notes_ref: Option<&str>, oid: Oid, note: &str, force: bool) -> Result { let notes_ref = try!(::opt_cstr(notes_ref)); let note = try!(CString::new(note)); let mut ret = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; unsafe { try_call!(raw::git_note_create(&mut ret, self.raw, notes_ref, author.raw(), committer.raw(), oid.raw(), note, force)); Ok(Binding::from_raw(&ret as *const _)) } } /// Get the default notes reference for this repository pub fn note_default_ref(&self) -> Result { let ret = Buf::new(); unsafe { try_call!(raw::git_note_default_ref(ret.raw(), self.raw)); } Ok(str::from_utf8(&ret).unwrap().to_string()) } /// Creates a new iterator for notes in this repository. /// /// The `notes_ref` argument is the canonical name of the reference to use, /// defaulting to "refs/notes/commits". /// /// The iterator returned yields pairs of (Oid, Oid) where the first element /// is the id of the note and the second id is the id the note is /// annotating. pub fn notes(&self, notes_ref: Option<&str>) -> Result { let notes_ref = try!(::opt_cstr(notes_ref)); let mut ret = 0 as *mut raw::git_note_iterator; unsafe { try_call!(raw::git_note_iterator_new(&mut ret, self.raw, notes_ref)); Ok(Binding::from_raw(ret)) } } /// Read the note for an object. /// /// The `notes_ref` argument is the canonical name of the reference to use, /// defaulting to "refs/notes/commits". /// /// The id specified is the Oid of the git object to read the note from. pub fn find_note(&self, notes_ref: Option<&str>, id: Oid) -> Result { let notes_ref = try!(::opt_cstr(notes_ref)); let mut ret = 0 as *mut raw::git_note; unsafe { try_call!(raw::git_note_read(&mut ret, self.raw, notes_ref, id.raw())); Ok(Binding::from_raw(ret)) } } /// Remove the note for an object. /// /// The `notes_ref` argument is the canonical name of the reference to use, /// defaulting to "refs/notes/commits". /// /// The id specified is the Oid of the git object to remove the note from. pub fn note_delete(&self, id: Oid, notes_ref: Option<&str>, author: &Signature, committer: &Signature) -> Result<(), Error> { let notes_ref = try!(::opt_cstr(notes_ref)); unsafe { try_call!(raw::git_note_remove(self.raw, notes_ref, author.raw(), committer.raw(), id.raw())); Ok(()) } } /// Create a revwalk that can be used to traverse the commit graph. pub fn revwalk(&self) -> Result { let mut raw = 0 as *mut raw::git_revwalk; unsafe { try_call!(raw::git_revwalk_new(&mut raw, self.raw())); Ok(Binding::from_raw(raw)) } } /// Get the blame for a single file. pub fn blame_file(&self, path: &Path, opts: Option<&mut BlameOptions>) -> Result { let path = try!(path.into_c_string()); let mut raw = 0 as *mut raw::git_blame; unsafe { try_call!(raw::git_blame_file(&mut raw, self.raw(), path, opts.map(|s| s.raw()))); Ok(Binding::from_raw(raw)) } } /// Find a merge base between two commits pub fn merge_base(&self, one: Oid, two: Oid) -> Result { let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; unsafe { try_call!(raw::git_merge_base(&mut raw, self.raw, one.raw(), two.raw())); Ok(Binding::from_raw(&raw as *const _)) } } /// Find all merge bases between two commits pub fn merge_bases(&self, one: Oid, two: Oid) -> Result { let mut arr = raw::git_oidarray { ids: 0 as *mut raw::git_oid, count: 0, }; unsafe { try_call!(raw::git_merge_bases(&mut arr, self.raw, one.raw(), two.raw())); Ok(Binding::from_raw(arr)) } } /// Count the number of unique commits between two commit objects /// /// There is no need for branches containing the commits to have any /// upstream relationship, but it helps to think of one as a branch and the /// other as its upstream, the ahead and behind values will be what git /// would report for the branches. pub fn graph_ahead_behind(&self, local: Oid, upstream: Oid) -> Result<(usize, usize), Error> { unsafe { let mut ahead: size_t = 0; let mut behind: size_t = 0; try_call!(raw::git_graph_ahead_behind(&mut ahead, &mut behind, self.raw(), local.raw(), upstream.raw())); Ok((ahead as usize, behind as usize)) } } /// Determine if a commit is the descendant of another commit pub fn graph_descendant_of(&self, commit: Oid, ancestor: Oid) -> Result { unsafe { let rv = try_call!(raw::git_graph_descendant_of(self.raw(), commit.raw(), ancestor.raw())); Ok(rv != 0) } } /// Read the reflog for the given reference /// /// If there is no reflog file for the given reference yet, an empty reflog /// object will be returned. pub fn reflog(&self, name: &str) -> Result { let name = try!(CString::new(name)); let mut ret = 0 as *mut raw::git_reflog; unsafe { try_call!(raw::git_reflog_read(&mut ret, self.raw, name)); Ok(Binding::from_raw(ret)) } } /// Delete the reflog for the given reference pub fn reflog_delete(&self, name: &str) -> Result<(), Error> { let name = try!(CString::new(name)); unsafe { try_call!(raw::git_reflog_delete(self.raw, name)); } Ok(()) } /// Rename a reflog /// /// The reflog to be renamed is expected to already exist. pub fn reflog_rename(&self, old_name: &str, new_name: &str) -> Result<(), Error> { let old_name = try!(CString::new(old_name)); let new_name = try!(CString::new(new_name)); unsafe { try_call!(raw::git_reflog_rename(self.raw, old_name, new_name)); } Ok(()) } /// Describes a commit /// /// Performs a describe operation on the current commit and the worktree. /// After performing a describe on HEAD, a status is run and description is /// considered to be dirty if there are. pub fn describe(&self, opts: &DescribeOptions) -> Result { let mut ret = 0 as *mut _; unsafe { try_call!(raw::git_describe_workdir(&mut ret, self.raw, opts.raw())); Ok(Binding::from_raw(ret)) } } /// Create a diff with the difference between two tree objects. /// /// This is equivalent to `git diff ` /// /// The first tree will be used for the "old_file" side of the delta and the /// second tree will be used for the "new_file" side of the delta. You can /// pass `None` to indicate an empty tree, although it is an error to pass /// `None` for both the `old_tree` and `new_tree`. pub fn diff_tree_to_tree(&self, old_tree: Option<&Tree>, new_tree: Option<&Tree>, opts: Option<&mut DiffOptions>) -> Result { let mut ret = 0 as *mut raw::git_diff; unsafe { try_call!(raw::git_diff_tree_to_tree(&mut ret, self.raw(), old_tree.map(|s| s.raw()), new_tree.map(|s| s.raw()), opts.map(|s| s.raw()))); Ok(Binding::from_raw(ret)) } } /// Create a diff between a tree and repository index. /// /// This is equivalent to `git diff --cached ` or if you pass /// the HEAD tree, then like `git diff --cached`. /// /// The tree you pass will be used for the "old_file" side of the delta, and /// the index will be used for the "new_file" side of the delta. /// /// If you pass `None` for the index, then the existing index of the `repo` /// will be used. In this case, the index will be refreshed from disk /// (if it has changed) before the diff is generated. /// /// If the tree is `None`, then it is considered an empty tree. pub fn diff_tree_to_index(&self, old_tree: Option<&Tree>, index: Option<&Index>, opts: Option<&mut DiffOptions>) -> Result { let mut ret = 0 as *mut raw::git_diff; unsafe { try_call!(raw::git_diff_tree_to_index(&mut ret, self.raw(), old_tree.map(|s| s.raw()), index.map(|s| s.raw()), opts.map(|s| s.raw()))); Ok(Binding::from_raw(ret)) } } /// Create a diff between the repository index and the workdir directory. /// /// This matches the `git diff` command. See the note below on /// `tree_to_workdir` for a discussion of the difference between /// `git diff` and `git diff HEAD` and how to emulate a `git diff ` /// using libgit2. /// /// The index will be used for the "old_file" side of the delta, and the /// working directory will be used for the "new_file" side of the delta. /// /// If you pass `None` for the index, then the existing index of the `repo` /// will be used. In this case, the index will be refreshed from disk /// (if it has changed) before the diff is generated. pub fn diff_index_to_workdir(&self, index: Option<&Index>, opts: Option<&mut DiffOptions>) -> Result { let mut ret = 0 as *mut raw::git_diff; unsafe { try_call!(raw::git_diff_index_to_workdir(&mut ret, self.raw(), index.map(|s| s.raw()), opts.map(|s| s.raw()))); Ok(Binding::from_raw(ret)) } } /// Create a diff between a tree and the working directory. /// /// The tree you provide will be used for the "old_file" side of the delta, /// and the working directory will be used for the "new_file" side. /// /// This is not the same as `git diff ` or `git diff-index /// `. Those commands use information from the index, whereas this /// function strictly returns the differences between the tree and the files /// in the working directory, regardless of the state of the index. Use /// `tree_to_workdir_with_index` to emulate those commands. /// /// To see difference between this and `tree_to_workdir_with_index`, /// consider the example of a staged file deletion where the file has then /// been put back into the working dir and further modified. The /// tree-to-workdir diff for that file is 'modified', but `git diff` would /// show status 'deleted' since there is a staged delete. /// /// If `None` is passed for `tree`, then an empty tree is used. pub fn diff_tree_to_workdir(&self, old_tree: Option<&Tree>, opts: Option<&mut DiffOptions>) -> Result { let mut ret = 0 as *mut raw::git_diff; unsafe { try_call!(raw::git_diff_tree_to_workdir(&mut ret, self.raw(), old_tree.map(|s| s.raw()), opts.map(|s| s.raw()))); Ok(Binding::from_raw(ret)) } } /// Create a diff between a tree and the working directory using index data /// to account for staged deletes, tracked files, etc. /// /// This emulates `git diff ` by diffing the tree to the index and /// the index to the working directory and blending the results into a /// single diff that includes staged deleted, etc. pub fn diff_tree_to_workdir_with_index(&self, old_tree: Option<&Tree>, opts: Option<&mut DiffOptions>) -> Result { let mut ret = 0 as *mut raw::git_diff; unsafe { try_call!(raw::git_diff_tree_to_workdir_with_index(&mut ret, self.raw(), old_tree.map(|s| s.raw()), opts.map(|s| s.raw()))); Ok(Binding::from_raw(ret)) } } } impl Binding for Repository { type Raw = *mut raw::git_repository; unsafe fn from_raw(ptr: *mut raw::git_repository) -> Repository { Repository { raw: ptr } } fn raw(&self) -> *mut raw::git_repository { self.raw } } impl Drop for Repository { fn drop(&mut self) { unsafe { raw::git_repository_free(self.raw) } } } impl RepositoryInitOptions { /// Creates a default set of initialization options. /// /// By default this will set flags for creating all necessary directories /// and initializing a directory from the user-configured templates path. pub fn new() -> RepositoryInitOptions { RepositoryInitOptions { flags: raw::GIT_REPOSITORY_INIT_MKDIR as u32 | raw::GIT_REPOSITORY_INIT_MKPATH as u32 | raw::GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE as u32, mode: 0, workdir_path: None, description: None, template_path: None, initial_head: None, origin_url: None, } } /// Create a bare repository with no working directory. /// /// Defaults to false. pub fn bare(&mut self, bare: bool) -> &mut RepositoryInitOptions { self.flag(raw::GIT_REPOSITORY_INIT_BARE, bare) } /// Return an error if the repository path appears to already be a git /// repository. /// /// Defaults to false. pub fn no_reinit(&mut self, enabled: bool) -> &mut RepositoryInitOptions { self.flag(raw::GIT_REPOSITORY_INIT_NO_REINIT, enabled) } /// Normally a '/.git/' will be appended to the repo apth for non-bare repos /// (if it is not already there), but passing this flag prevents that /// behavior. /// /// Defaults to false. pub fn no_dotgit_dir(&mut self, enabled: bool) -> &mut RepositoryInitOptions { self.flag(raw::GIT_REPOSITORY_INIT_NO_DOTGIT_DIR, enabled) } /// Make the repo path (and workdir path) as needed. The ".git" directory /// will always be created regardless of this flag. /// /// Defaults to true. pub fn mkdir(&mut self, enabled: bool) -> &mut RepositoryInitOptions { self.flag(raw::GIT_REPOSITORY_INIT_MKDIR, enabled) } /// Recursively make all components of the repo and workdir path sas /// necessary. /// /// Defaults to true. pub fn mkpath(&mut self, enabled: bool) -> &mut RepositoryInitOptions { self.flag(raw::GIT_REPOSITORY_INIT_MKPATH, enabled) } /// Set to one of the `RepositoryInit` constants, or a custom value. pub fn mode(&mut self, mode: RepositoryInitMode) -> &mut RepositoryInitOptions { self.mode = mode.bits(); self } /// Enable or disable using external templates. /// /// If enabled, then the `template_path` option will be queried first, then /// `init.templatedir` from the global config, and finally /// `/usr/share/git-core-templates` will be used (if it exists). /// /// Defaults to true. pub fn external_template(&mut self, enabled: bool) -> &mut RepositoryInitOptions { self.flag(raw::GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE, enabled) } fn flag(&mut self, flag: raw::git_repository_init_flag_t, on: bool) -> &mut RepositoryInitOptions { if on { self.flags |= flag as u32; } else { self.flags &= !(flag as u32); } self } /// The path do the working directory. /// /// If this is a relative path it will be evaulated relative to the repo /// path. If this is not the "natural" working directory, a .git gitlink /// file will be created here linking to the repo path. pub fn workdir_path(&mut self, path: &Path) -> &mut RepositoryInitOptions { self.workdir_path = Some(path.into_c_string().unwrap()); self } /// If set, this will be used to initialize the "description" file in the /// repository instead of using the template content. pub fn description(&mut self, desc: &str) -> &mut RepositoryInitOptions { self.description = Some(CString::new(desc).unwrap()); self } /// When the `external_template` option is set, this is the first location /// to check for the template directory. /// /// If this is not configured, then the default locations will be searched /// instead. pub fn template_path(&mut self, path: &Path) -> &mut RepositoryInitOptions { self.template_path = Some(path.into_c_string().unwrap()); self } /// The name of the head to point HEAD at. /// /// If not configured, this will be treated as `master` and the HEAD ref /// will be set to `refs/heads/master`. If this begins with `refs/` it will /// be used verbatim; otherwise `refs/heads/` will be prefixed pub fn initial_head(&mut self, head: &str) -> &mut RepositoryInitOptions { self.initial_head = Some(CString::new(head).unwrap()); self } /// If set, then after the rest of the repository initialization is /// completed an `origin` remote will be added pointing to this URL. pub fn origin_url(&mut self, url: &str) -> &mut RepositoryInitOptions { self.origin_url = Some(CString::new(url).unwrap()); self } /// Creates a set of raw init options to be used with /// `git_repository_init_ext`. /// /// This method is unsafe as the returned value may have pointers to the /// interior of this structure. pub unsafe fn raw(&self) -> raw::git_repository_init_options { let mut opts = mem::zeroed(); assert_eq!(raw::git_repository_init_init_options(&mut opts, raw::GIT_REPOSITORY_INIT_OPTIONS_VERSION), 0); opts.flags = self.flags; opts.mode = self.mode; opts.workdir_path = ::call::convert(&self.workdir_path); opts.description = ::call::convert(&self.description); opts.template_path = ::call::convert(&self.template_path); opts.initial_head = ::call::convert(&self.initial_head); opts.origin_url = ::call::convert(&self.origin_url); return opts; } } #[cfg(test)] mod tests { use std::fs; use std::path::Path; use tempdir::TempDir; use {Repository, Oid, ObjectType, ResetType}; use build::CheckoutBuilder; #[test] fn smoke_init() { let td = TempDir::new("test").unwrap(); let path = td.path(); let repo = Repository::init(path).unwrap(); assert!(!repo.is_bare()); } #[test] fn smoke_init_bare() { let td = TempDir::new("test").unwrap(); let path = td.path(); let repo = Repository::init_bare(path).unwrap(); assert!(repo.is_bare()); assert!(repo.namespace().is_none()); } #[test] fn smoke_open() { let td = TempDir::new("test").unwrap(); let path = td.path(); Repository::init(td.path()).unwrap(); let repo = Repository::open(path).unwrap(); assert!(!repo.is_bare()); assert!(!repo.is_shallow()); assert!(repo.is_empty().unwrap()); assert_eq!(::test::realpath(&repo.path()).unwrap(), ::test::realpath(&td.path().join(".git/")).unwrap()); assert_eq!(repo.state(), ::RepositoryState::Clean); } #[test] fn smoke_open_bare() { let td = TempDir::new("test").unwrap(); let path = td.path(); Repository::init_bare(td.path()).unwrap(); let repo = Repository::open(path).unwrap(); assert!(repo.is_bare()); assert_eq!(::test::realpath(&repo.path()).unwrap(), ::test::realpath(&td.path().join("")).unwrap()); } #[test] fn smoke_checkout() { let (_td, repo) = ::test::repo_init(); repo.checkout_head(None).unwrap(); } #[test] fn smoke_revparse() { let (_td, repo) = ::test::repo_init(); let rev = repo.revparse("HEAD").unwrap(); assert!(rev.to().is_none()); let from = rev.from().unwrap(); assert!(rev.from().is_some()); assert_eq!(repo.revparse_single("HEAD").unwrap().id(), from.id()); let obj = repo.find_object(from.id(), None).unwrap().clone(); obj.peel(ObjectType::Any).unwrap(); obj.short_id().unwrap(); repo.reset(&obj, ResetType::Hard, None).unwrap(); let mut opts = CheckoutBuilder::new(); t!(repo.reset(&obj, ResetType::Soft, Some(&mut opts))); } #[test] fn makes_dirs() { let td = TempDir::new("foo").unwrap(); Repository::init(&td.path().join("a/b/c/d")).unwrap(); } #[test] fn smoke_discover() { let td = TempDir::new("test").unwrap(); let subdir = td.path().join("subdi"); fs::create_dir(&subdir).unwrap(); Repository::init_bare(td.path()).unwrap(); let repo = Repository::discover(&subdir).unwrap(); assert_eq!(::test::realpath(&repo.path()).unwrap(), ::test::realpath(&td.path().join("")).unwrap()); } fn graph_repo_init() -> (TempDir, Repository) { let (_td, repo) = ::test::repo_init(); { let head = repo.head().unwrap().target().unwrap(); let head = repo.find_commit(head).unwrap(); let mut index = repo.index().unwrap(); let id = index.write_tree().unwrap(); let tree = repo.find_tree(id).unwrap(); let sig = repo.signature().unwrap(); repo.commit(Some("HEAD"), &sig, &sig, "second", &tree, &[&head]).unwrap(); } (_td, repo) } #[test] fn smoke_graph_ahead_behind() { let (_td, repo) = graph_repo_init(); let head = repo.head().unwrap().target().unwrap(); let head = repo.find_commit(head).unwrap(); let head_id = head.id(); let head_parent_id = head.parent(0).unwrap().id(); let (ahead, behind) = repo.graph_ahead_behind(head_id, head_parent_id).unwrap(); assert_eq!(ahead, 1); assert_eq!(behind, 0); let (ahead, behind) = repo.graph_ahead_behind(head_parent_id, head_id).unwrap(); assert_eq!(ahead, 0); assert_eq!(behind, 1); } #[test] fn smoke_graph_descendant_of() { let (_td, repo) = graph_repo_init(); let head = repo.head().unwrap().target().unwrap(); let head = repo.find_commit(head).unwrap(); let head_id = head.id(); let head_parent_id = head.parent(0).unwrap().id(); assert!(repo.graph_descendant_of(head_id, head_parent_id).unwrap()); assert!(!repo.graph_descendant_of(head_parent_id, head_id).unwrap()); } #[test] fn smoke_set_head() { let (_td, repo) = ::test::repo_init(); assert!(repo.set_head("refs/heads/does-not-exist").is_ok()); assert!(repo.head().is_err()); assert!(repo.set_head("refs/heads/master").is_ok()); assert!(repo.head().is_ok()); assert!(repo.set_head("*").is_err()); } #[test] fn smoke_set_head_detached() { let (_td, repo) = ::test::repo_init(); let void_oid = Oid::from_bytes(b"00000000000000000000").unwrap(); assert!(repo.set_head_detached(void_oid).is_err()); let master_oid = repo.revparse_single("master").unwrap().id(); assert!(repo.set_head_detached(master_oid).is_ok()); assert_eq!(repo.head().unwrap().target().unwrap(), master_oid); } /// create an octopus: /// /---o2-o4 /// o1 X /// \---o3-o5 /// and checks that the merge bases of (o4,o5) are (o2,o3) #[test] fn smoke_merge_bases() { let (_td, repo) = graph_repo_init(); let sig = repo.signature().unwrap(); // let oid1 = head let oid1 = repo.head().unwrap().target().unwrap(); let commit1 = repo.find_commit(oid1).unwrap(); println!("created oid1 {:?}", oid1); repo.branch("branch_a", &commit1, true).unwrap(); repo.branch("branch_b", &commit1, true).unwrap(); // create commit oid2 on branchA let mut index = repo.index().unwrap(); let p = Path::new(repo.workdir().unwrap()).join("file_a"); println!("using path {:?}", p); fs::File::create(&p).unwrap(); index.add_path(Path::new("file_a")).unwrap(); let id_a = index.write_tree().unwrap(); let tree_a = repo.find_tree(id_a).unwrap(); let oid2 = repo.commit(Some("refs/heads/branch_a"), &sig, &sig, "commit 2", &tree_a, &[&commit1]).unwrap(); let commit2 = repo.find_commit(oid2).unwrap(); println!("created oid2 {:?}", oid2); // create commit oid3 on branchB let mut index = repo.index().unwrap(); let p = Path::new(repo.workdir().unwrap()).join("file_b"); fs::File::create(&p).unwrap(); index.add_path(Path::new("file_b")).unwrap(); let id_b = index.write_tree().unwrap(); let tree_b = repo.find_tree(id_b).unwrap(); let oid3 = repo.commit(Some("refs/heads/branch_b"), &sig, &sig, "commit 3", &tree_b, &[&commit1]).unwrap(); let commit3 = repo.find_commit(oid3).unwrap(); println!("created oid3 {:?}", oid3); // create merge commit oid4 on branchA with parents oid2 and oid3 //let mut index4 = repo.merge_commits(&commit2, &commit3, None).unwrap(); repo.set_head("refs/heads/branch_a").unwrap(); repo.checkout_head(None).unwrap(); let oid4 = repo.commit(Some("refs/heads/branch_a"), &sig, &sig, "commit 4", &tree_a, &[&commit2, &commit3]).unwrap(); //index4.write_tree_to(&repo).unwrap(); println!("created oid4 {:?}", oid4); // create merge commit oid5 on branchB with parents oid2 and oid3 //let mut index5 = repo.merge_commits(&commit3, &commit2, None).unwrap(); repo.set_head("refs/heads/branch_b").unwrap(); repo.checkout_head(None).unwrap(); let oid5 = repo.commit(Some("refs/heads/branch_b"), &sig, &sig, "commit 5", &tree_a, &[&commit3, &commit2]).unwrap(); //index5.write_tree_to(&repo).unwrap(); println!("created oid5 {:?}", oid5); // merge bases of (oid4,oid5) should be (oid2,oid3) let merge_bases = repo.merge_bases(oid4, oid5).unwrap(); let mut found_oid2 = false; let mut found_oid3 = false; for mg in merge_bases.iter() { println!("found merge base {:?}", mg); if mg == &oid2 { found_oid2 = true; } else if mg == &oid3 { found_oid3 = true; } else { assert!(false); } } assert!(found_oid2); assert!(found_oid3); assert_eq!(merge_bases.len(), 2); } #[test] fn smoke_revparse_ext() { let (_td, repo) = graph_repo_init(); { let short_refname = "master"; let expected_refname = "refs/heads/master"; let (obj, reference) = repo.revparse_ext(short_refname).unwrap(); let expected_obj = repo.revparse_single(expected_refname).unwrap(); assert_eq!(obj.id(), expected_obj.id()); assert_eq!(reference.unwrap().name().unwrap(), expected_refname); } { let missing_refname = "refs/heads/does-not-exist"; assert!(repo.revparse_ext(missing_refname).is_err()); } { let (_obj, reference) = repo.revparse_ext("HEAD^").unwrap(); assert!(reference.is_none()); } } } deps/git2-0.3.3/src/util.rs0000664000175000017500000000713112505356750012363 0ustar use std::ffi::{CString, OsStr, OsString}; use std::iter::IntoIterator; use std::path::{Path, PathBuf}; use libc::{c_char, size_t}; use {raw, Error}; #[doc(hidden)] trait IsNull { fn is_ptr_null(&self) -> bool; } impl IsNull for *const T { fn is_ptr_null(&self) -> bool { self.is_null() } } impl IsNull for *mut T { fn is_ptr_null(&self) -> bool { self.is_null() } } #[doc(hidden)] pub trait Binding: Sized { type Raw; unsafe fn from_raw(raw: Self::Raw) -> Self; fn raw(&self) -> Self::Raw; unsafe fn from_raw_opt(raw: T) -> Option where T: Copy + IsNull, Self: Binding { if raw.is_ptr_null() { None } else { Some(Binding::from_raw(raw)) } } } pub fn iter2cstrs(iter: I) -> Result<(Vec, Vec<*const c_char>, raw::git_strarray), Error> where T: IntoCString, I: IntoIterator { let cstrs: Vec<_> = try!(iter.into_iter().map(|i| i.into_c_string()).collect()); let ptrs = cstrs.iter().map(|i| i.as_ptr()).collect::>(); let raw = raw::git_strarray { strings: ptrs.as_ptr() as *mut _, count: ptrs.len() as size_t, }; Ok((cstrs, ptrs, raw)) } #[cfg(unix)] pub fn bytes2path(b: &[u8]) -> &Path { use std::os::unix::prelude::*; Path::new(OsStr::from_bytes(b)) } #[cfg(windows)] pub fn bytes2path(b: &[u8]) -> &Path { use std::str; Path::new(str::from_utf8(b).unwrap()) } /// A class of types that can be converted to C strings. /// /// These types are represented internally as byte slices and it is quite rare /// for them to contain an interior 0 byte. pub trait IntoCString { /// Consume this container, converting it into a CString fn into_c_string(self) -> Result; } impl<'a, T: IntoCString + Clone> IntoCString for &'a T { fn into_c_string(self) -> Result { self.clone().into_c_string() } } impl<'a> IntoCString for &'a str { fn into_c_string(self) -> Result { Ok(try!(CString::new(self))) } } impl IntoCString for String { fn into_c_string(self) -> Result { Ok(try!(CString::new(self.into_bytes()))) } } impl IntoCString for CString { fn into_c_string(self) -> Result { Ok(self) } } impl<'a> IntoCString for &'a Path { fn into_c_string(self) -> Result { let s: &OsStr = self.as_ref(); s.into_c_string() } } impl IntoCString for PathBuf { fn into_c_string(self) -> Result { let s: OsString = self.into(); s.into_c_string() } } impl<'a> IntoCString for &'a OsStr { fn into_c_string(self) -> Result { self.to_os_string().into_c_string() } } impl IntoCString for OsString { #[cfg(unix)] fn into_c_string(self) -> Result { use std::os::unix::prelude::*; let s: &OsStr = self.as_ref(); Ok(try!(CString::new(s.as_bytes()))) } #[cfg(windows)] fn into_c_string(self) -> Result { match self.to_str() { Some(s) => s.into_c_string(), None => Err(Error::from_str("only valid unicode paths are accepted \ on windows")), } } } impl<'a> IntoCString for &'a [u8] { fn into_c_string(self) -> Result { Ok(try!(CString::new(self))) } } impl IntoCString for Vec { fn into_c_string(self) -> Result { Ok(try!(CString::new(self))) } } deps/git2-0.3.3/src/blob.rs0000664000175000017500000000466512603146276012334 0ustar use std::marker; use std::slice; use {raw, Oid, Object}; use util::Binding; /// A structure to represent a git [blob][1] /// /// [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects pub struct Blob<'repo> { raw: *mut raw::git_blob, _marker: marker::PhantomData>, } impl<'repo> Blob<'repo> { /// Get the id (SHA1) of a repository blob pub fn id(&self) -> Oid { unsafe { Binding::from_raw(raw::git_blob_id(&*self.raw)) } } /// Determine if the blob content is most certainly binary or not. pub fn is_binary(&self) -> bool { unsafe { raw::git_blob_is_binary(&*self.raw) == 1 } } /// Get the content of this blob. pub fn content(&self) -> &[u8] { unsafe { let data = raw::git_blob_rawcontent(&*self.raw) as *const u8; let len = raw::git_blob_rawsize(&*self.raw) as usize; slice::from_raw_parts(data, len) } } /// Casts this Blob to be usable as an `Object` pub fn as_object(&self) -> &Object<'repo> { unsafe { &*(self as *const _ as *const Object<'repo>) } } } impl<'repo> Binding for Blob<'repo> { type Raw = *mut raw::git_blob; unsafe fn from_raw(raw: *mut raw::git_blob) -> Blob<'repo> { Blob { raw: raw, _marker: marker::PhantomData, } } fn raw(&self) -> *mut raw::git_blob { self.raw } } impl<'repo> Drop for Blob<'repo> { fn drop(&mut self) { unsafe { raw::git_blob_free(self.raw) } } } #[cfg(test)] mod tests { use std::io::prelude::*; use std::fs::File; use tempdir::TempDir; use Repository; #[test] fn buffer() { let td = TempDir::new("test").unwrap(); let repo = Repository::init(td.path()).unwrap(); let id = repo.blob(&[5, 4, 6]).unwrap(); let blob = repo.find_blob(id).unwrap(); assert_eq!(blob.id(), id); assert_eq!(blob.content(), [5, 4, 6]); assert!(blob.is_binary()); repo.find_object(id, None).unwrap().as_blob().unwrap(); } #[test] fn path() { let td = TempDir::new("test").unwrap(); let path = td.path().join("foo"); File::create(&path).unwrap().write_all(&[7, 8, 9]).unwrap(); let repo = Repository::init(td.path()).unwrap(); let id = repo.blob_path(&path).unwrap(); let blob = repo.find_blob(id).unwrap(); assert_eq!(blob.content(), [7, 8, 9]); } } deps/git2-0.3.3/src/branch.rs0000664000175000017500000001300512623026412012626 0ustar use std::ffi::CString; use std::marker; use std::str; use libc; use {raw, Error, Reference, BranchType, References}; use util::Binding; /// A structure to represent a git [branch][1] /// /// A branch is currently just a wrapper to an underlying `Reference`. The /// reference can be accessed through the `get` and `unwrap` methods. /// /// [1]: http://git-scm.com/book/en/Git-Branching-What-a-Branch-Is pub struct Branch<'repo> { inner: Reference<'repo>, } /// An iterator over the branches inside of a repository. pub struct Branches<'repo> { raw: *mut raw::git_branch_iterator, _marker: marker::PhantomData>, } impl<'repo> Branch<'repo> { /// Creates a new branch from a reference pub fn wrap(reference: Reference) -> Branch { Branch { inner: reference } } /// Gain access to the reference that is this branch pub fn get(&self) -> &Reference<'repo> { &self.inner } /// Take ownership of the underlying reference. pub fn into_reference(self) -> Reference<'repo> { self.inner } /// Delete an existing branch reference. pub fn delete(&mut self) -> Result<(), Error> { unsafe { try_call!(raw::git_branch_delete(self.get().raw())); } Ok(()) } /// Determine if the current local branch is pointed at by HEAD. pub fn is_head(&self) -> bool { unsafe { raw::git_branch_is_head(&*self.get().raw()) == 1 } } /// Move/rename an existing local branch reference. pub fn rename(&mut self, new_branch_name: &str, force: bool) -> Result, Error> { let mut ret = 0 as *mut raw::git_reference; let new_branch_name = try!(CString::new(new_branch_name)); unsafe { try_call!(raw::git_branch_move(&mut ret, self.get().raw(), new_branch_name, force)); Ok(Branch::wrap(Binding::from_raw(ret))) } } /// Return the name of the given local or remote branch. /// /// May return `Ok(None)` if the name is not valid utf-8. pub fn name(&self) -> Result, Error> { self.name_bytes().map(|s| str::from_utf8(s).ok()) } /// Return the name of the given local or remote branch. pub fn name_bytes(&self) -> Result<&[u8], Error> { let mut ret = 0 as *const libc::c_char; unsafe { try_call!(raw::git_branch_name(&mut ret, &*self.get().raw())); Ok(::opt_bytes(self, ret).unwrap()) } } /// Return the reference supporting the remote tracking branch, given a /// local branch reference. pub fn upstream<'a>(&'a self) -> Result, Error> { let mut ret = 0 as *mut raw::git_reference; unsafe { try_call!(raw::git_branch_upstream(&mut ret, &*self.get().raw())); Ok(Branch::wrap(Binding::from_raw(ret))) } } /// Set the upstream configuration for a given local branch. /// /// If `None` is specified, then the upstream branch is unset. The name /// provided is the name of the branch to set as upstream. pub fn set_upstream(&mut self, upstream_name: Option<&str>) -> Result<(), Error> { let upstream_name = try!(::opt_cstr(upstream_name)); unsafe { try_call!(raw::git_branch_set_upstream(self.get().raw(), upstream_name)); Ok(()) } } } impl<'repo> Branches<'repo> { /// Creates a new iterator from the raw pointer given. /// /// This function is unsafe as it is not guaranteed that `raw` is a valid /// pointer. pub unsafe fn from_raw(raw: *mut raw::git_branch_iterator) -> Branches<'repo> { Branches { raw: raw, _marker: marker::PhantomData, } } } impl<'repo> Iterator for Branches<'repo> { type Item = (Branch<'repo>, BranchType); fn next(&mut self) -> Option<(Branch<'repo>, BranchType)> { let mut ret = 0 as *mut raw::git_reference; let mut typ = raw::GIT_BRANCH_LOCAL; unsafe { let rc = raw::git_branch_next(&mut ret, &mut typ, self.raw); if rc == raw::GIT_ITEROVER as libc::c_int { return None } assert_eq!(rc, 0); let typ = match typ { raw::GIT_BRANCH_LOCAL => BranchType::Local, raw::GIT_BRANCH_REMOTE => BranchType::Remote, n => panic!("unexected branch type: {}", n), }; Some((Branch::wrap(Binding::from_raw(ret)), typ)) } } } impl<'repo> Drop for Branches<'repo> { fn drop(&mut self) { unsafe { raw::git_branch_iterator_free(self.raw) } } } #[cfg(test)] mod tests { use BranchType; #[test] fn smoke() { let (_td, repo) = ::test::repo_init(); let head = repo.head().unwrap(); let target = head.target().unwrap(); let commit = repo.find_commit(target).unwrap(); let mut b1 = repo.branch("foo", &commit, false).unwrap(); assert!(!b1.is_head()); repo.branch("foo2", &commit, false).unwrap(); assert_eq!(repo.branches(None).unwrap().count(), 3); repo.find_branch("foo", BranchType::Local).unwrap(); let mut b1 = b1.rename("bar", false).unwrap(); assert_eq!(b1.name().unwrap(), Some("bar")); assert!(b1.upstream().is_err()); b1.set_upstream(Some("master")).unwrap(); b1.upstream().unwrap(); b1.set_upstream(None).unwrap(); b1.delete().unwrap(); } } deps/git2-0.3.3/src/submodule.rs0000664000175000017500000001722312563210063013376 0ustar use std::marker; use std::str; use std::path::Path; use {raw, Oid, Repository, Error}; use util::{self, Binding}; /// A structure to represent a git [submodule][1] /// /// [1]: http://git-scm.com/book/en/Git-Tools-Submodules pub struct Submodule<'repo> { raw: *mut raw::git_submodule, _marker: marker::PhantomData<&'repo Repository>, } impl<'repo> Submodule<'repo> { /// Get the submodule's branch. /// /// Returns `None` if the branch is not valid utf-8 or if the branch is not /// yet available. pub fn branch(&self) -> Option<&str> { self.branch_bytes().and_then(|s| str::from_utf8(s).ok()) } /// Get the branch for the submodule. /// /// Returns `None` if the branch is not yet available. pub fn branch_bytes(&self) -> Option<&[u8]> { unsafe { ::opt_bytes(self, raw::git_submodule_branch(self.raw)) } } /// Get the submodule's url. /// /// Returns `None` if the url is not valid utf-8 pub fn url(&self) -> Option<&str> { str::from_utf8(self.url_bytes()).ok() } /// Get the url for the submodule. pub fn url_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, raw::git_submodule_url(self.raw)).unwrap() } } /// Get the submodule's name. /// /// Returns `None` if the name is not valid utf-8 pub fn name(&self) -> Option<&str> { str::from_utf8(self.name_bytes()).ok() } /// Get the name for the submodule. pub fn name_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, raw::git_submodule_name(self.raw)).unwrap() } } /// Get the path for the submodule. pub fn path(&self) -> &Path { util::bytes2path(unsafe { ::opt_bytes(self, raw::git_submodule_path(self.raw)).unwrap() }) } /// Get the OID for the submodule in the current HEAD tree. pub fn head_id(&self) -> Option { unsafe { Binding::from_raw_opt(raw::git_submodule_head_id(self.raw)) } } /// Get the OID for the submodule in the index. pub fn index_id(&self) -> Option { unsafe { Binding::from_raw_opt(raw::git_submodule_index_id(self.raw)) } } /// Get the OID for the submodule in the current working directory. /// /// This returns the OID that corresponds to looking up 'HEAD' in the /// checked out submodule. If there are pending changes in the index or /// anything else, this won't notice that. pub fn workdir_id(&self) -> Option { unsafe { Binding::from_raw_opt(raw::git_submodule_wd_id(self.raw)) } } /// Copy submodule info into ".git/config" file. /// /// Just like "git submodule init", this copies information about the /// submodule into ".git/config". You can use the accessor functions above /// to alter the in-memory git_submodule object and control what is written /// to the config, overriding what is in .gitmodules. /// /// By default, existing entries will not be overwritten, but passing `true` /// for `overwrite` forces them to be updated. pub fn init(&mut self, overwrite: bool) -> Result<(), Error> { unsafe { try_call!(raw::git_submodule_init(self.raw, overwrite)); } Ok(()) } /// Open the repository for a submodule. /// /// This will only work if the submodule is checked out into the working /// directory. pub fn open(&self) -> Result { let mut raw = 0 as *mut raw::git_repository; unsafe { try_call!(raw::git_submodule_open(&mut raw, self.raw)); Ok(Binding::from_raw(raw)) } } /// Reread submodule info from config, index, and HEAD. /// /// Call this to reread cached submodule information for this submodule if /// you have reason to believe that it has changed. /// /// If `force` is `true`, then data will be reloaded even if it doesn't seem /// out of date pub fn reload(&mut self, force: bool) -> Result<(), Error> { unsafe { try_call!(raw::git_submodule_reload(self.raw, force)); } Ok(()) } /// Copy submodule remote info into submodule repo. /// /// This copies the information about the submodules URL into the checked /// out submodule config, acting like "git submodule sync". This is useful /// if you have altered the URL for the submodule (or it has been altered /// by a fetch of upstream changes) and you need to update your local repo. pub fn sync(&mut self) -> Result<(), Error> { unsafe { try_call!(raw::git_submodule_sync(self.raw)); } Ok(()) } /// Add current submodule HEAD commit to index of superproject. /// /// If `write_index` is true, then the index file will be immediately /// written. Otherwise you must explicitly call `write()` on an `Index` /// later on. pub fn add_to_index(&mut self, write_index: bool) -> Result<(), Error> { unsafe { try_call!(raw::git_submodule_add_to_index(self.raw, write_index)); } Ok(()) } /// Resolve the setup of a new git submodule. /// /// This should be called on a submodule once you have called add setup and /// done the clone of the submodule. This adds the .gitmodules file and the /// newly cloned submodule to the index to be ready to be committed (but /// doesn't actually do the commit). pub fn add_finalize(&mut self) -> Result<(), Error> { unsafe { try_call!(raw::git_submodule_add_finalize(self.raw)); } Ok(()) } } impl<'repo> Binding for Submodule<'repo> { type Raw = *mut raw::git_submodule; unsafe fn from_raw(raw: *mut raw::git_submodule) -> Submodule<'repo> { Submodule { raw: raw, _marker: marker::PhantomData } } fn raw(&self) -> *mut raw::git_submodule { self.raw } } impl<'repo> Drop for Submodule<'repo> { fn drop(&mut self) { unsafe { raw::git_submodule_free(self.raw) } } } #[cfg(test)] mod tests { use std::path::Path; use std::fs; use tempdir::TempDir; use url::Url; use Repository; #[test] fn smoke() { let td = TempDir::new("test").unwrap(); let repo = Repository::init(td.path()).unwrap(); let mut s1 = repo.submodule("/path/to/nowhere", Path::new("foo"), true).unwrap(); s1.init(false).unwrap(); s1.sync().unwrap(); let s2 = repo.submodule("/path/to/nowhere", Path::new("bar"), true).unwrap(); drop((s1, s2)); let mut submodules = repo.submodules().unwrap(); assert_eq!(submodules.len(), 2); let mut s = submodules.remove(0); assert_eq!(s.name(), Some("bar")); assert_eq!(s.url(), Some("/path/to/nowhere")); assert_eq!(s.branch(), None); assert!(s.head_id().is_none()); assert!(s.index_id().is_none()); assert!(s.workdir_id().is_none()); repo.find_submodule("bar").unwrap(); s.open().unwrap(); assert!(s.path() == Path::new("bar")); s.reload(true).unwrap(); } #[test] fn add_a_submodule() { let (_td, repo1) = ::test::repo_init(); let (td, repo2) = ::test::repo_init(); let url = Url::from_file_path(&repo1.workdir().unwrap()).unwrap(); let mut s = repo2.submodule(&url.to_string(), Path::new("bar"), true).unwrap(); t!(fs::remove_dir_all(td.path().join("bar"))); t!(Repository::clone(&url.to_string(), td.path().join("bar"))); t!(s.add_to_index(false)); t!(s.add_finalize()); } } deps/git2-0.3.3/src/oid_array.rs0000664000175000017500000000205712600564142013351 0ustar //! Bindings to libgit2's raw git_strarray type use std::ops::Deref; use oid::Oid; use raw; use util::Binding; use std::slice; use std::mem; /// An oid array structure used by libgit2 /// /// Some apis return arrays of oids which originate from libgit2. This /// wrapper type behaves a little like `Vec<&Oid>` but does so without copying /// the underlying Oids until necessary. pub struct OidArray { raw: raw::git_oidarray, } impl Deref for OidArray { type Target = [Oid]; fn deref(&self) -> &[Oid] { unsafe { debug_assert_eq!(mem::size_of::(), mem::size_of_val(&*self.raw.ids)); slice::from_raw_parts(self.raw.ids as *const Oid, self.raw.count as usize) } } } impl Binding for OidArray { type Raw = raw::git_oidarray; unsafe fn from_raw(raw: raw::git_oidarray) -> OidArray { OidArray { raw: raw } } fn raw(&self) -> raw::git_oidarray { self.raw } } impl Drop for OidArray { fn drop(&mut self) { unsafe { raw::git_oidarray_free(&mut self.raw) } } } deps/git2-0.3.3/src/blame.rs0000664000175000017500000002217112531247414012462 0ustar use std::marker; use {raw, Repository, Oid, signature, Signature}; use util::{self, Binding}; use std::path::Path; use std::ops::Range; use std::mem; /// Opaque structure to hold blame results. pub struct Blame<'repo> { raw: *mut raw::git_blame, _marker: marker::PhantomData<&'repo Repository>, } /// Structure that represents a blame hunk. pub struct BlameHunk<'blame> { raw: *mut raw::git_blame_hunk, _marker: marker::PhantomData<&'blame raw::git_blame>, } /// Blame options pub struct BlameOptions { raw: raw::git_blame_options, } /// An iterator over the hunks in a blame. pub struct BlameIter<'blame> { range: Range, blame: &'blame Blame<'blame>, } impl<'repo> Blame<'repo> { /// Gets the number of hunks that exist in the blame structure. pub fn len(&self) -> usize { unsafe { raw::git_blame_get_hunk_count(self.raw) as usize } } /// Gets the blame hunk at the given index. pub fn get_index(&self, index: usize) -> Option { unsafe { let ptr = raw::git_blame_get_hunk_byindex(self.raw(), index as u32); if ptr.is_null() { None } else { Some(BlameHunk::from_raw_const(ptr)) } } } /// Gets the hunk that relates to the given line number in the newest /// commit. pub fn get_line(&self, lineno: usize) -> Option { unsafe { let ptr = raw::git_blame_get_hunk_byline(self.raw(), lineno as u32); if ptr.is_null() { None } else { Some(BlameHunk::from_raw_const(ptr)) } } } /// Returns an iterator over the hunks in this blame. pub fn iter(&self) -> BlameIter { BlameIter { range: 0..self.len(), blame: self } } } impl<'blame> BlameHunk<'blame> { unsafe fn from_raw_const(raw: *const raw::git_blame_hunk) -> BlameHunk<'blame> { BlameHunk { raw: raw as *mut raw::git_blame_hunk, _marker: marker::PhantomData, } } /// Returns OID of the commit where this line was last changed pub fn final_commit_id(&self) -> Oid { unsafe { Oid::from_raw(&(*self.raw).final_commit_id) } } /// Returns signature of the commit. pub fn final_signature(&self) -> Signature { unsafe { signature::from_raw_const(self, (*self.raw).final_signature) } } /// Returns line number where this hunk begins. /// /// Note that the start line is counting from 1. pub fn final_start_line(&self) -> usize { unsafe { (*self.raw).final_start_line_number as usize } } /// Returns the OID of the commit where this hunk was found. /// /// This will usually be the same as `final_commit_id`, /// except when `BlameOptions::track_copies_any_commit_copies` has been /// turned on pub fn orig_commit_id(&self) -> Oid { unsafe { Oid::from_raw(&(*self.raw).orig_commit_id) } } /// Returns signature of the commit. pub fn orig_signature(&self) -> Signature { unsafe { signature::from_raw_const(self, (*self.raw).orig_signature) } } /// Returns line number where this hunk begins. /// /// Note that the start line is counting from 1. pub fn orig_start_line(&self) -> usize { unsafe { (*self.raw).orig_start_line_number as usize } } /// Returns path to the file where this hunk originated. /// /// Note: `None` could be returned for non-unicode paths on Widnows. pub fn path(&self) -> Option<&Path> { unsafe { if let Some(bytes) = ::opt_bytes(self, (*self.raw).orig_path) { Some(util::bytes2path(bytes)) } else { None } } } /// Tests whether this hunk has been tracked to a boundary commit /// (the root, or the commit specified in git_blame_options.oldest_commit). pub fn is_boundary(&self) -> bool { unsafe { (*self.raw).boundary == 1 } } /// Returns number of lines in this hunk. pub fn lines_in_hunk(&self) -> usize { unsafe { (*self.raw).lines_in_hunk as usize } } } impl BlameOptions { /// Initialize options pub fn new() -> BlameOptions { unsafe { let mut raw: raw::git_blame_options = mem::zeroed(); assert_eq!( raw::git_blame_init_options(&mut raw, raw::GIT_BLAME_OPTIONS_VERSION) , 0); Binding::from_raw(&raw as *const _ as *mut _) } } fn flag(&mut self, opt: u32, val: bool) -> &mut BlameOptions { if val { self.raw.flags |= opt; } else { self.raw.flags &= !opt; } self } /// Track lines that have moved within a file. pub fn track_copies_same_file(&mut self, opt: bool) -> &mut BlameOptions { self.flag(raw::GIT_BLAME_TRACK_COPIES_SAME_FILE, opt) } /// Track lines that have moved across files in the same commit. pub fn track_copies_same_commit_moves(&mut self, opt: bool) -> &mut BlameOptions { self.flag(raw::GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES, opt) } /// Track lines that have been copied from another file that exists /// in the same commit. pub fn track_copies_same_commit_copies(&mut self, opt: bool) -> &mut BlameOptions { self.flag(raw::GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES, opt) } /// Track lines that have been copied from another file that exists /// in any commit. pub fn track_copies_any_commit_copies(&mut self, opt: bool) -> &mut BlameOptions { self.flag(raw::GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES, opt) } /// Restrict the search of commits to those reachable following only /// the first parents. pub fn first_parent(&mut self, opt: bool) -> &mut BlameOptions { self.flag(raw::GIT_BLAME_FIRST_PARENT, opt) } /// Setter for the id of the newest commit to consider. pub fn newest_commit(&mut self, id: Oid) -> &mut BlameOptions { unsafe { self.raw.newest_commit = *id.raw(); } self } /// Setter for the id of the oldest commit to consider. pub fn oldest_commit(&mut self, id: Oid) -> &mut BlameOptions { unsafe { self.raw.oldest_commit = *id.raw(); } self } } impl<'repo> Binding for Blame<'repo> { type Raw = *mut raw::git_blame; unsafe fn from_raw(raw: *mut raw::git_blame) -> Blame<'repo> { Blame { raw: raw, _marker: marker::PhantomData } } fn raw(&self) -> *mut raw::git_blame { self.raw } } impl<'repo> Drop for Blame<'repo> { fn drop(&mut self) { unsafe { raw::git_blame_free(self.raw) } } } impl<'blame> Binding for BlameHunk<'blame> { type Raw = *mut raw::git_blame_hunk; unsafe fn from_raw(raw: *mut raw::git_blame_hunk) -> BlameHunk<'blame> { BlameHunk { raw: raw, _marker: marker::PhantomData } } fn raw(&self) -> *mut raw::git_blame_hunk { self.raw } } impl Binding for BlameOptions { type Raw = *mut raw::git_blame_options; unsafe fn from_raw(opts: *mut raw::git_blame_options) -> BlameOptions { BlameOptions { raw: *opts } } fn raw(&self) -> *mut raw::git_blame_options { &self.raw as *const _ as *mut _ } } impl<'blame> Iterator for BlameIter<'blame> { type Item = BlameHunk<'blame>; fn next(&mut self) -> Option> { self.range.next().and_then(|i| self.blame.get_index(i)) } fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } } impl<'blame> DoubleEndedIterator for BlameIter<'blame> { fn next_back(&mut self) -> Option> { self.range.next_back().and_then(|i| self.blame.get_index(i)) } } impl<'blame> ExactSizeIterator for BlameIter<'blame> {} #[cfg(test)] mod tests { use std::fs::{self, File}; use std::path::Path; #[test] fn smoke() { let (_td, repo) = ::test::repo_init(); let mut index = repo.index().unwrap(); let root = repo.path().parent().unwrap(); fs::create_dir(&root.join("foo")).unwrap(); File::create(&root.join("foo/bar")).unwrap(); index.add_path(Path::new("foo/bar")).unwrap(); let id = index.write_tree().unwrap(); let tree = repo.find_tree(id).unwrap(); let sig = repo.signature().unwrap(); let id = repo.refname_to_id("HEAD").unwrap(); let parent = repo.find_commit(id).unwrap(); let commit = repo.commit(Some("HEAD"), &sig, &sig, "commit", &tree, &[&parent]).unwrap(); let blame = repo.blame_file(Path::new("foo/bar"), None).unwrap(); assert_eq!(blame.len(), 1); assert_eq!(blame.iter().count(), 1); let hunk = blame.get_index(0).unwrap(); assert_eq!(hunk.final_commit_id(), commit); assert_eq!(hunk.final_signature().name(), sig.name()); assert_eq!(hunk.final_signature().email(), sig.email()); assert_eq!(hunk.final_start_line(), 1); assert_eq!(hunk.path(), Some(Path::new("foo/bar"))); assert_eq!(hunk.lines_in_hunk(), 0); assert!(!hunk.is_boundary()) } } deps/git2-0.3.3/src/cred.rs0000664000175000017500000004040012526404533012313 0ustar use std::ffi::CString; use std::io::Write; use std::mem; use std::path::Path; use std::process::{Command, Stdio}; use url::{self, UrlParser}; use {raw, Error, Config, IntoCString}; use util::Binding; /// A structure to represent git credentials in libgit2. pub struct Cred { raw: *mut raw::git_cred, } /// Management of the gitcredentials(7) interface. pub struct CredentialHelper { /// A public field representing the currently discovered username from /// configuration. pub username: Option, protocol: Option, host: Option, url: String, commands: Vec, } impl Cred { /// Create a "default" credential usable for Negotiate mechanisms like NTLM /// or Kerberos authentication. pub fn default() -> Result { ::init(); let mut out = 0 as *mut raw::git_cred; unsafe { try_call!(raw::git_cred_default_new(&mut out)); Ok(Binding::from_raw(out)) } } /// Create a new ssh key credential object used for querying an ssh-agent. /// /// The username specified is the username to authenticate. pub fn ssh_key_from_agent(username: &str) -> Result { ::init(); let mut out = 0 as *mut raw::git_cred; let username = try!(CString::new(username)); unsafe { try_call!(raw::git_cred_ssh_key_from_agent(&mut out, username)); Ok(Binding::from_raw(out)) } } /// Create a new passphrase-protected ssh key credential object. pub fn ssh_key(username: &str, publickey: Option<&Path>, privatekey: &Path, passphrase: Option<&str>) -> Result { ::init(); let username = try!(CString::new(username)); let publickey = try!(::opt_cstr(publickey)); let privatekey = try!(privatekey.into_c_string()); let passphrase = try!(::opt_cstr(passphrase)); let mut out = 0 as *mut raw::git_cred; unsafe { try_call!(raw::git_cred_ssh_key_new(&mut out, username, publickey, privatekey, passphrase)); Ok(Binding::from_raw(out)) } } /// Create a new plain-text username and password credential object. pub fn userpass_plaintext(username: &str, password: &str) -> Result { ::init(); let username = try!(CString::new(username)); let password = try!(CString::new(password)); let mut out = 0 as *mut raw::git_cred; unsafe { try_call!(raw::git_cred_userpass_plaintext_new(&mut out, username, password)); Ok(Binding::from_raw(out)) } } /// Attempt to read `credential.helper` according to gitcredentials(7) [1] /// /// This function will attempt to parse the user's `credential.helper` /// configuration, invoke the necessary processes, and read off what the /// username/password should be for a particular url. /// /// The returned credential type will be a username/password credential if /// successful. /// /// [1]: https://www.kernel.org/pub/software/scm/git/docs/gitcredentials.html pub fn credential_helper(config: &Config, url: &str, username: Option<&str>) -> Result { match CredentialHelper::new(url).config(config).username(username) .execute() { Some((username, password)) => { Cred::userpass_plaintext(&username, &password) } None => Err(Error::from_str("failed to acquire username/password \ from local configuration")) } } /// Create a credential to specify a username. /// /// THis is used with ssh authentication to query for the username if non is /// specified in the url. pub fn username(username: &str) -> Result { ::init(); let username = try!(CString::new(username)); let mut out = 0 as *mut raw::git_cred; unsafe { try_call!(raw::git_cred_username_new(&mut out, username)); Ok(Binding::from_raw(out)) } } /// Check whether a credential object contains username information. pub fn has_username(&self) -> bool { unsafe { raw::git_cred_has_username(self.raw) == 1 } } /// Return the type of credentials that this object represents. pub fn credtype(&self) -> raw::git_credtype_t { unsafe { (*self.raw).credtype } } /// Unwrap access to the underlying raw pointer, canceling the destructor pub unsafe fn unwrap(mut self) -> *mut raw::git_cred { mem::replace(&mut self.raw, 0 as *mut raw::git_cred) } } impl Binding for Cred { type Raw = *mut raw::git_cred; unsafe fn from_raw(raw: *mut raw::git_cred) -> Cred { Cred { raw: raw } } fn raw(&self) -> *mut raw::git_cred { self.raw } } impl Drop for Cred { fn drop(&mut self) { if !self.raw.is_null() { unsafe { ((*self.raw).free)(self.raw) } } } } impl CredentialHelper { /// Create a new credential helper object which will be used to probe git's /// local credential configuration. /// /// The url specified is the namespace on which this will query credentials. /// Invalid urls are currently ignored. pub fn new(url: &str) -> CredentialHelper { let mut ret = CredentialHelper { protocol: None, host: None, username: None, url: url.to_string(), commands: Vec::new(), }; // Parse out the (protocol, host) if one is available let parsed_url = UrlParser::new().scheme_type_mapper(mapper).parse(url); match parsed_url { Ok(url) => { match url.host() { Some(&url::Host::Domain(ref s)) => ret.host = Some(s.clone()), _ => {} } ret.protocol = Some(url.scheme) } Err(..) => {} }; return ret; fn mapper(s: &str) -> url::SchemeType { match s { "git" => url::SchemeType::Relative(9418), "ssh" => url::SchemeType::Relative(22), s => url::whatwg_scheme_type_mapper(s), } } } /// Set the username that this credential helper will query with. /// /// By default the username is `None`. pub fn username(&mut self, username: Option<&str>) -> &mut CredentialHelper { self.username = username.map(|s| s.to_string()); self } /// Query the specified configuration object to discover commands to /// execute, usernames to query, etc. pub fn config(&mut self, config: &Config) -> &mut CredentialHelper { // Figure out the configured username/helper program. // // see http://git-scm.com/docs/gitcredentials.html#_configuration_options // // TODO: implement useHttpPath if self.username.is_none() { self.config_username(config); } self.config_helper(config); self } // Configure the queried username from `config` fn config_username(&mut self, config: &Config) { let key = self.exact_key("username"); self.username = config.get_string(&key).ok().or_else(|| { self.url_key("username").and_then(|s| { config.get_string(&s).ok() }) }).or_else(|| { config.get_string("credential.username").ok() }) } // Discover all `helper` directives from `config` fn config_helper(&mut self, config: &Config) { let exact = config.get_string(&self.exact_key("helper")); self.add_command(exact.as_ref().ok().map(|s| &s[..])); match self.url_key("helper") { Some(key) => { let url = config.get_string(&key); self.add_command(url.as_ref().ok().map(|s| &s[..])); } None => {} } let global = config.get_string("credential.helper"); self.add_command(global.as_ref().ok().map(|s| &s[..])); } // Add a `helper` configured command to the list of commands to execute. // // see https://www.kernel.org/pub/software/scm/git/docs/technical // /api-credentials.html#_credential_helpers fn add_command(&mut self, cmd: Option<&str>) { let cmd = match cmd { Some(s) => s, None => return }; if cmd.starts_with("!") { self.commands.push(cmd[1..].to_string()); } else if cmd.starts_with("/") || cmd.starts_with("\\") || cmd[1..].starts_with(":\\") { self.commands.push(format!("\"{}\"", cmd)); } else { self.commands.push(format!("git credential-{}", cmd)); } } fn exact_key(&self, name: &str) -> String { format!("credential.{}.{}", self.url, name) } fn url_key(&self, name: &str) -> Option { match (&self.host, &self.protocol) { (&Some(ref host), &Some(ref protocol)) => { Some(format!("credential.{}://{}.{}", protocol, host, name)) } _ => None } } /// Execute this helper, attempting to discover a username/password pair. /// /// All I/O errors are ignored, (to match git behavior), and this function /// only succeeds if both a username and a password were found pub fn execute(&self) -> Option<(String, String)> { let mut username = self.username.clone(); let mut password = None; for cmd in self.commands.iter() { let (u, p) = self.execute_cmd(&cmd, &username); if u.is_some() && username.is_none() { username = u; } if p.is_some() && password.is_none() { password = p; } if username.is_some() && password.is_some() { break } } match (username, password) { (Some(u), Some(p)) => Some((u, p)), _ => None, } } // Execute the given `cmd`, providing the appropriate variables on stdin and // then afterwards parsing the output into the username/password on stdout. fn execute_cmd(&self, cmd: &str, username: &Option) -> (Option, Option) { macro_rules! my_try( ($e:expr) => ( match $e { Ok(e) => e, Err(..) => return (None, None) } ) ); let mut p = my_try!(Command::new("sh").arg("-c") .arg(&format!("{} get", cmd)) .stdin(Stdio::piped()) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .spawn()); // Ignore write errors as the command may not actually be listening for // stdin { let stdin = p.stdin.as_mut().unwrap(); match self.protocol { Some(ref p) => { let _ = writeln!(stdin, "protocol={}", p); } None => {} } match self.host { Some(ref p) => { let _ = writeln!(stdin, "host={}", p); } None => {} } match *username { Some(ref p) => { let _ = writeln!(stdin, "username={}", p); } None => {} } } let output = my_try!(p.wait_with_output()); if !output.status.success() { return (None, None) } return self.parse_output(output.stdout) } // Parse the output of a command into the username/password found fn parse_output(&self, output: Vec) -> (Option, Option) { // Parse the output of the command, looking for username/password let mut username = None; let mut password = None; for line in output.split(|t| *t == b'\n') { let mut parts = line.splitn(2, |t| *t == b'='); let key = parts.next().unwrap(); let value = match parts.next() { Some(s) => s, None => continue }; let value = match String::from_utf8(value.to_vec()) { Ok(s) => s, Err(..) => continue, }; match key { b"username" => username = Some(value), b"password" => password = Some(value), _ => {} } } (username, password) } } #[cfg(all(test, feature = "unstable"))] mod test { use std::env; use std::fs::File; use std::io::prelude::*; use std::path::Path; use tempdir::TempDir; use {Cred, Config, CredentialHelper, ConfigLevel}; macro_rules! cfg( ($($k:expr => $v:expr),*) => ({ let td = TempDir::new("git2-rs").unwrap(); let mut cfg = Config::new().unwrap(); cfg.add_file(&td.path().join("cfg"), ConfigLevel::Highest, false).unwrap(); $(cfg.set_str($k, $v).unwrap();)* cfg }) ); #[test] fn smoke() { Cred::default().unwrap(); } #[test] fn credential_helper1() { let cfg = cfg! { "credential.helper" => "!f() { echo username=a; echo password=b; }; f" }; let (u, p) = CredentialHelper::new("https://example.com/foo/bar") .config(&cfg) .execute().unwrap(); assert_eq!(u, "a"); assert_eq!(p, "b"); } #[test] fn credential_helper2() { let cfg = cfg! {}; assert!(CredentialHelper::new("https://example.com/foo/bar") .config(&cfg) .execute().is_none()); } #[test] fn credential_helper3() { let cfg = cfg! { "credential.https://example.com.helper" => "!f() { echo username=c; }; f", "credential.helper" => "!f() { echo username=a; echo password=b; }; f" }; let (u, p) = CredentialHelper::new("https://example.com/foo/bar") .config(&cfg) .execute().unwrap(); assert_eq!(u, "c"); assert_eq!(p, "b"); } #[test] fn credential_helper4() { let td = TempDir::new("git2-rs").unwrap(); let path = td.path().join("script"); File::create(&path).unwrap().write(br"\ #!/bin/sh echo username=c ").unwrap(); chmod(&path); let cfg = cfg! { "credential.https://example.com.helper" => &path.display().to_string()[..], "credential.helper" => "!f() { echo username=a; echo password=b; }; f" }; let (u, p) = CredentialHelper::new("https://example.com/foo/bar") .config(&cfg) .execute().unwrap(); assert_eq!(u, "c"); assert_eq!(p, "b"); } #[test] fn credential_helper5() { let td = TempDir::new("git2-rs").unwrap(); let path = td.path().join("git-credential-script"); File::create(&path).unwrap().write(br"\ #!/bin/sh echo username=c ").unwrap(); chmod(&path); let paths = env::var("PATH").unwrap(); let paths = env::split_paths(&paths) .chain(path.parent().map(|p| p.to_path_buf()).into_iter()); env::set_var("PATH", &env::join_paths(paths).unwrap()); let cfg = cfg! { "credential.https://example.com.helper" => "script", "credential.helper" => "!f() { echo username=a; echo password=b; }; f" }; let (u, p) = CredentialHelper::new("https://example.com/foo/bar") .config(&cfg) .execute().unwrap(); assert_eq!(u, "c"); assert_eq!(p, "b"); } #[cfg(unix)] fn chmod(path: &Path) { use std::os::unix::prelude::*; use std::fs; let mut perms = fs::metadata(path).unwrap().permissions(); perms.set_mode(0o755); fs::set_permissions(path, perms).unwrap(); } #[cfg(windows)] fn chmod(_path: &Path) {} } deps/git2-0.3.3/src/cert.rs0000664000175000017500000000524712503163146012342 0ustar //! Certificate types which are passed to `CertificateCheck` in //! `RemoteCallbacks`. use std::marker; use std::mem; use std::slice; use raw; use util::Binding; /// A certificate for a remote connection, viewable as one of `CertHostkey` or /// `CertX509` currently. pub struct Cert<'a> { raw: *mut raw::git_cert, _marker: marker::PhantomData<&'a raw::git_cert>, } /// Hostkey information taken from libssh2 pub struct CertHostkey<'a> { raw: *mut raw::git_cert_hostkey, _marker: marker::PhantomData<&'a raw::git_cert>, } /// X.509 certificate information pub struct CertX509<'a> { raw: *mut raw::git_cert_x509, _marker: marker::PhantomData<&'a raw::git_cert>, } impl<'a> Cert<'a> { /// Attempt to view this certificate as an SSH hostkey. /// /// Returns `None` if this is not actually an SSH hostkey. pub fn as_hostkey(&self) -> Option<&CertHostkey<'a>> { self.cast(raw::GIT_CERT_HOSTKEY_LIBSSH2) } /// Attempt to view this certificate as an X.509 certificate. /// /// Returns `None` if this is not actually an X.509 certificate. pub fn as_x509(&self) -> Option<&CertX509<'a>> { self.cast(raw::GIT_CERT_X509) } fn cast(&self, kind: raw::git_cert_t) -> Option<&T> { assert_eq!(mem::size_of::>(), mem::size_of::()); unsafe { if kind == (*self.raw).cert_type { Some(&*(self as *const Cert<'a> as *const T)) } else { None } } } } impl<'a> CertHostkey<'a> { /// Returns the md5 hash of the hostkey, if available. pub fn hash_md5(&self) -> Option<&[u8; 16]> { unsafe { if (*self.raw).kind as u32 & raw::GIT_CERT_SSH_MD5 as u32 == 0 { None } else { Some(&(*self.raw).hash_md5) } } } /// Returns the SHA-1 hash of the hostkey, if available. pub fn hash_sha1(&self) -> Option<&[u8; 20]> { unsafe { if (*self.raw).kind as u32 & raw::GIT_CERT_SSH_SHA1 as u32 == 0 { None } else { Some(&(*self.raw).hash_sha1) } } } } impl<'a> CertX509<'a> { /// Return the X.509 certificate data as a byte slice pub fn data(&self) -> &[u8] { unsafe { slice::from_raw_parts((*self.raw).data as *const u8, (*self.raw).len as usize) } } } impl<'a> Binding for Cert<'a> { type Raw = *mut raw::git_cert; unsafe fn from_raw(raw: *mut raw::git_cert) -> Cert<'a> { Cert { raw: raw, _marker: marker::PhantomData } } fn raw(&self) -> *mut raw::git_cert { self.raw } } deps/git2-0.3.3/src/call.rs0000664000175000017500000001544412623023435012317 0ustar #![macro_use] use libc; use Error; macro_rules! call { (raw::$p:ident ($($e:expr),*)) => ( raw::$p($(::call::convert(&$e)),*) ) } macro_rules! try_call { (raw::$p:ident ($($e:expr),*)) => ({ match ::call::try(raw::$p($(::call::convert(&$e)),*)) { Ok(o) => o, Err(e) => { ::panic::check(); return Err(e) } } }) } #[doc(hidden)] pub trait Convert { fn convert(&self) -> T; } pub fn convert>(u: &U) -> T { u.convert() } pub fn try(ret: libc::c_int) -> Result { match ret { n if n < 0 => Err(last_error(n)), n => Ok(n), } } fn last_error(code: libc::c_int) -> Error { // Apparently libgit2 isn't necessarily guaranteed to set the last error // whenever a function returns a negative value! Error::last_error(code).unwrap_or_else(|| { Error::from_str("an unknown error occurred") }) } mod impls { use std::ffi::CString; use libc; use {raw, ConfigLevel, ResetType, ObjectType, BranchType, Direction}; use {DiffFormat, FileFavor, SubmoduleIgnore, AutotagOption, FetchPrune}; use call::Convert; impl Convert for T { fn convert(&self) -> T { *self } } impl Convert for bool { fn convert(&self) -> libc::c_int { *self as libc::c_int } } impl<'a, T> Convert<*const T> for &'a T { fn convert(&self) -> *const T { *self as *const T } } impl<'a, T> Convert<*mut T> for &'a mut T { fn convert(&self) -> *mut T { &**self as *const T as *mut T } } impl Convert<*const T> for *mut T { fn convert(&self) -> *const T { *self as *const T } } impl Convert<*const libc::c_char> for CString { fn convert(&self) -> *const libc::c_char { self.as_ptr() } } impl> Convert<*const T> for Option { fn convert(&self) -> *const T { self.as_ref().map(|s| s.convert()).unwrap_or(0 as *const _) } } impl> Convert<*mut T> for Option { fn convert(&self) -> *mut T { self.as_ref().map(|s| s.convert()).unwrap_or(0 as *mut _) } } impl Convert for ResetType { fn convert(&self) -> raw::git_reset_t { match *self { ResetType::Soft => raw::GIT_RESET_SOFT, ResetType::Hard => raw::GIT_RESET_HARD, ResetType::Mixed => raw::GIT_RESET_MIXED, } } } impl Convert for Direction { fn convert(&self) -> raw::git_direction { match *self { Direction::Push => raw::GIT_DIRECTION_PUSH, Direction::Fetch => raw::GIT_DIRECTION_FETCH, } } } impl Convert for ObjectType { fn convert(&self) -> raw::git_otype { match *self { ObjectType::Any => raw::GIT_OBJ_ANY, ObjectType::Commit => raw::GIT_OBJ_COMMIT, ObjectType::Tree => raw::GIT_OBJ_TREE, ObjectType::Blob => raw::GIT_OBJ_BLOB, ObjectType::Tag => raw::GIT_OBJ_TAG, } } } impl Convert for Option { fn convert(&self) -> raw::git_otype { self.unwrap_or(ObjectType::Any).convert() } } impl Convert for BranchType { fn convert(&self) -> raw::git_branch_t { match *self { BranchType::Remote => raw::GIT_BRANCH_REMOTE, BranchType::Local => raw::GIT_BRANCH_LOCAL, } } } impl Convert for Option { fn convert(&self) -> raw::git_branch_t { self.map(|s| s.convert()).unwrap_or(raw::GIT_BRANCH_ALL) } } impl Convert for ConfigLevel { fn convert(&self) -> raw::git_config_level_t { match *self { ConfigLevel::System => raw::GIT_CONFIG_LEVEL_SYSTEM, ConfigLevel::XDG => raw::GIT_CONFIG_LEVEL_XDG, ConfigLevel::Global => raw::GIT_CONFIG_LEVEL_GLOBAL, ConfigLevel::Local => raw::GIT_CONFIG_LEVEL_LOCAL, ConfigLevel::App => raw::GIT_CONFIG_LEVEL_APP, ConfigLevel::Highest => raw::GIT_CONFIG_HIGHEST_LEVEL, } } } impl Convert for DiffFormat { fn convert(&self) -> raw::git_diff_format_t { match *self { DiffFormat::Patch => raw::GIT_DIFF_FORMAT_PATCH, DiffFormat::PatchHeader => raw::GIT_DIFF_FORMAT_PATCH_HEADER, DiffFormat::Raw => raw::GIT_DIFF_FORMAT_RAW, DiffFormat::NameOnly => raw::GIT_DIFF_FORMAT_NAME_ONLY, DiffFormat::NameStatus => raw::GIT_DIFF_FORMAT_NAME_STATUS, } } } impl Convert for FileFavor { fn convert(&self) -> raw::git_merge_file_favor_t { match *self { FileFavor::Normal => raw::GIT_MERGE_FILE_FAVOR_NORMAL, FileFavor::Ours => raw::GIT_MERGE_FILE_FAVOR_OURS, FileFavor::Theirs => raw::GIT_MERGE_FILE_FAVOR_THEIRS, FileFavor::Union => raw::GIT_MERGE_FILE_FAVOR_UNION, } } } impl Convert for SubmoduleIgnore { fn convert(&self) -> raw::git_submodule_ignore_t { match *self { SubmoduleIgnore::Unspecified => raw::GIT_SUBMODULE_IGNORE_UNSPECIFIED, SubmoduleIgnore::None => raw::GIT_SUBMODULE_IGNORE_NONE, SubmoduleIgnore::Untracked => raw::GIT_SUBMODULE_IGNORE_UNTRACKED, SubmoduleIgnore::Dirty => raw::GIT_SUBMODULE_IGNORE_DIRTY, SubmoduleIgnore::All => raw::GIT_SUBMODULE_IGNORE_ALL, } } } impl Convert for AutotagOption { fn convert(&self) -> raw::git_remote_autotag_option_t { match *self { AutotagOption::Unspecified => raw::GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED, AutotagOption::None => raw::GIT_REMOTE_DOWNLOAD_TAGS_NONE, AutotagOption::Auto => raw::GIT_REMOTE_DOWNLOAD_TAGS_AUTO, AutotagOption::All => raw::GIT_REMOTE_DOWNLOAD_TAGS_ALL, } } } impl Convert for FetchPrune { fn convert(&self) -> raw::git_fetch_prune_t { match *self { FetchPrune::Unspecified => raw::GIT_FETCH_PRUNE_UNSPECIFIED, FetchPrune::On => raw::GIT_FETCH_PRUNE, FetchPrune::Off => raw::GIT_FETCH_NO_PRUNE, } } } } deps/git2-0.3.3/src/panic.rs0000664000175000017500000000473712617153425012507 0ustar use std::any::Any; use std::cell::RefCell; // This is technically super unsafe, allowing capturing an arbitrary environment // and then declaring it Send to cross the boundary into a safe call to `wrap`. // // One of the main reasons for the `Send` bound, however, is for exception // safety mitigation. We do not want to impose exception safety concerns on // consumers, so at the end of all calls to libgit2 we check if there was an // error while calling a callback and then re-raise as a panic if necessary. // Along these lines we simply catch an exception to be re-raised on the Rust // side after passing back through C. // // As a result we're generally keeping the equivalent semantics for Rust, so // this `unsafe impl Send` should be ok. macro_rules! wrap_env { (fn $fn_name:ident($($arg:ident: $arg_t:ty),*) -> $ret:ty { $body:expr } returning $name:ident as $ret_expr:expr ) => { extern fn $fn_name($($arg: $arg_t),*) -> $ret { struct Env { $($arg: $arg_t),* } unsafe impl Send for Env {} let env = Env { $($arg: $arg),* }; let $name = ::panic::wrap(move || { $(let $arg = env.$arg;)* $body }); $ret_expr } } } thread_local!(static LAST_ERROR: RefCell>> = { RefCell::new(None) }); #[cfg(feature = "unstable")] pub fn wrap T + Send + 'static>(f: F) -> Option { use std::thread; if LAST_ERROR.with(|slot| slot.borrow().is_some()) { return None } match thread::catch_panic(f) { Ok(ret) => Some(ret), Err(e) => { LAST_ERROR.with(move |slot| { *slot.borrow_mut() = Some(e); }); None } } } #[cfg(not(feature = "unstable"))] pub fn wrap T + Send + 'static>(f: F) -> Option { struct Bomb { enabled: bool } impl Drop for Bomb { fn drop(&mut self) { if !self.enabled { return } panic!("callback has panicked, and continuing to unwind into C \ is not safe, so aborting the process"); } } let mut bomb = Bomb { enabled: true }; let ret = Some(f()); bomb.enabled = false; return ret; } pub fn check() { let err = LAST_ERROR.with(|slot| slot.borrow_mut().take()); match err { Some(err) => panic!(err), None => {} } } pub fn panicked() -> bool { LAST_ERROR.with(|slot| slot.borrow().is_some()) } deps/git2-0.3.3/src/signature.rs0000664000175000017500000001227012524545205013403 0ustar use std::ffi::CString; use std::marker; use std::mem; use std::str; use std::fmt; use libc; use {raw, Error, Time}; use util::Binding; /// A Signature is used to indicate authorship of various actions throughout the /// library. /// /// Signatures contain a name, email, and timestamp. All fields can be specified /// with `new`, the `now` constructor omits the timestamp, and the `default` /// constructor reads configuration from the given repository. pub struct Signature<'a> { raw: *mut raw::git_signature, _marker: marker::PhantomData<&'a str>, owned: bool, } impl<'a> Signature<'a> { /// Create a new action signature with a timestamp of 'now'. /// /// See `new` for more information pub fn now(name: &str, email: &str) -> Result, Error> { ::init(); let mut ret = 0 as *mut raw::git_signature; let name = try!(CString::new(name)); let email = try!(CString::new(email)); unsafe { try_call!(raw::git_signature_now(&mut ret, name, email)); Ok(Binding::from_raw(ret)) } } /// Create a new action signature. /// /// The `time` specified is in seconds since the epoch, and the `offset` is /// the time zone offset in minutes. /// /// Returns error if either `name` or `email` contain angle brackets. pub fn new(name: &str, email: &str, time: &Time) -> Result, Error> { ::init(); let mut ret = 0 as *mut raw::git_signature; let name = try!(CString::new(name)); let email = try!(CString::new(email)); unsafe { try_call!(raw::git_signature_new(&mut ret, name, email, time.seconds() as raw::git_time_t, time.offset_minutes() as libc::c_int)); Ok(Binding::from_raw(ret)) } } /// Gets the name on the signature. /// /// Returns `None` if the name is not valid utf-8 pub fn name(&self) -> Option<&str> { str::from_utf8(self.name_bytes()).ok() } /// Gets the name on the signature as a byte slice. pub fn name_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, (*self.raw).name).unwrap() } } /// Gets the email on the signature. /// /// Returns `None` if the email is not valid utf-8 pub fn email(&self) -> Option<&str> { str::from_utf8(self.email_bytes()).ok() } /// Gets the email on the signature as a byte slice. pub fn email_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, (*self.raw).email).unwrap() } } /// Get the `when` of this signature. pub fn when(&self) -> Time { unsafe { Binding::from_raw((*self.raw).when) } } /// Convert a signature of any lifetime into an owned signature with a /// static lifetime. pub fn to_owned(&self) -> Signature<'static> { unsafe { let me = mem::transmute::<&Signature<'a>, &Signature<'static>>(self); me.clone() } } } impl<'a> Binding for Signature<'a> { type Raw = *mut raw::git_signature; unsafe fn from_raw(raw: *mut raw::git_signature) -> Signature<'a> { Signature { raw: raw, _marker: marker::PhantomData, owned: true, } } fn raw(&self) -> *mut raw::git_signature { self.raw } } /// Creates a new signature from the give raw pointer, tied to the lifetime /// of the given object. /// /// This function is unsafe as there is no guarantee that `raw` is valid for /// `'a` nor if it's a valid pointer. pub unsafe fn from_raw_const<'b, T>(_lt: &'b T, raw: *const raw::git_signature) -> Signature<'b> { Signature { raw: raw as *mut raw::git_signature, _marker: marker::PhantomData, owned: false, } } impl Clone for Signature<'static> { fn clone(&self) -> Signature<'static> { // TODO: can this be defined for 'a and just do a plain old copy if the // lifetime isn't static? let mut raw = 0 as *mut raw::git_signature; let rc = unsafe { raw::git_signature_dup(&mut raw, &*self.raw) }; assert_eq!(rc, 0); unsafe { Binding::from_raw(raw) } } } impl<'a> Drop for Signature<'a> { fn drop(&mut self) { if self.owned { unsafe { raw::git_signature_free(self.raw) } } } } impl<'a> fmt::Display for Signature<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{} <{}>", String::from_utf8_lossy(self.name_bytes()), String::from_utf8_lossy(self.email_bytes())) } } #[cfg(test)] mod tests { use {Signature, Time}; #[test] fn smoke() { Signature::new("foo", "bar", &Time::new(89, 0)).unwrap(); Signature::now("foo", "bar").unwrap(); assert!(Signature::new("", "bar", &Time::new(89, 0)).is_err()); assert!(Signature::now("", "bar").is_err()); let s = Signature::now("foo", "bar").unwrap(); assert_eq!(s.name(), Some("foo")); assert_eq!(s.email(), Some("bar")); drop(s.clone()); drop(s.to_owned()); } } deps/git2-0.3.3/src/string_array.rs0000664000175000017500000000615212477652761014125 0ustar //! Bindings to libgit2's raw git_strarray type use std::str; use std::ops::Range; use raw; use util::Binding; /// A string array structure used by libgit2 /// /// Some apis return arrays of strings which originate from libgit2. This /// wrapper type behaves a little like `Vec<&str>` but does so without copying /// the underlying strings until necessary. pub struct StringArray { raw: raw::git_strarray, } /// A forward iterator over the strings of an array, casted to `&str`. pub struct Iter<'a> { range: Range, arr: &'a StringArray, } /// A forward iterator over the strings of an array, casted to `&[u8]`. pub struct IterBytes<'a> { range: Range, arr: &'a StringArray, } impl StringArray { /// Returns None if the i'th string is not utf8 or if i is out of bounds. pub fn get(&self, i: usize) -> Option<&str> { self.get_bytes(i).and_then(|s| str::from_utf8(s).ok()) } /// Returns None if `i` is out of bounds. pub fn get_bytes(&self, i: usize) -> Option<&[u8]> { if i < self.raw.count as usize { unsafe { let ptr = *self.raw.strings.offset(i as isize) as *const _; Some(::opt_bytes(self, ptr).unwrap()) } } else { None } } /// Returns an iterator over the strings contained within this array. /// /// The iterator yields `Option<&str>` as it is unknown whether the contents /// are utf-8 or not. pub fn iter(&self) -> Iter { Iter { range: 0..self.len(), arr: self } } /// Returns an iterator over the strings contained within this array, /// yielding byte slices. pub fn iter_bytes(&self) -> IterBytes { IterBytes { range: 0..self.len(), arr: self } } /// Returns the number of strings in this array. pub fn len(&self) -> usize { self.raw.count as usize } } impl Binding for StringArray { type Raw = raw::git_strarray; unsafe fn from_raw(raw: raw::git_strarray) -> StringArray { StringArray { raw: raw } } fn raw(&self) -> raw::git_strarray { self.raw } } impl<'a> Iterator for Iter<'a> { type Item = Option<&'a str>; fn next(&mut self) -> Option> { self.range.next().map(|i| self.arr.get(i)) } fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } } impl<'a> DoubleEndedIterator for Iter<'a> { fn next_back(&mut self) -> Option> { self.range.next_back().map(|i| self.arr.get(i)) } } impl<'a> ExactSizeIterator for Iter<'a> {} impl<'a> Iterator for IterBytes<'a> { type Item = &'a [u8]; fn next(&mut self) -> Option<&'a [u8]> { self.range.next().and_then(|i| self.arr.get_bytes(i)) } fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } } impl<'a> DoubleEndedIterator for IterBytes<'a> { fn next_back(&mut self) -> Option<&'a [u8]> { self.range.next_back().and_then(|i| self.arr.get_bytes(i)) } } impl<'a> ExactSizeIterator for IterBytes<'a> {} impl Drop for StringArray { fn drop(&mut self) { unsafe { raw::git_strarray_free(&mut self.raw) } } } deps/git2-0.3.3/src/oid.rs0000664000175000017500000000673612477652505012200 0ustar use std::fmt; use std::cmp::Ordering; use std::hash::{Hasher, Hash}; use std::str; use libc; use {raw, Error}; use util::Binding; /// Unique identity of any object (commit, tree, blob, tag). #[derive(Copy)] pub struct Oid { raw: raw::git_oid, } impl Oid { /// Parse a hex-formatted object id into an Oid structure. /// /// If the string is not a valid 40-character hex string, an error is /// returned. pub fn from_str(s: &str) -> Result { ::init(); let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; unsafe { try_call!(raw::git_oid_fromstrn(&mut raw, s.as_bytes().as_ptr() as *const libc::c_char, s.len() as libc::size_t)); } Ok(Oid { raw: raw }) } /// Parse a raw object id into an Oid structure. /// /// If the array given is not 20 bytes in length, an error is returned. pub fn from_bytes(bytes: &[u8]) -> Result { ::init(); let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; if bytes.len() != raw::GIT_OID_RAWSZ { Err(Error::from_str("raw byte array must be 20 bytes")) } else { unsafe { raw::git_oid_fromraw(&mut raw, bytes.as_ptr()) } Ok(Oid { raw: raw }) } } /// View this OID as a byte-slice 20 bytes in length. pub fn as_bytes(&self) -> &[u8] { &self.raw.id } /// Test if this OID is all zeros. pub fn is_zero(&self) -> bool { unsafe { raw::git_oid_iszero(&self.raw) == 1 } } } impl Binding for Oid { type Raw = *const raw::git_oid; unsafe fn from_raw(oid: *const raw::git_oid) -> Oid { Oid { raw: *oid } } fn raw(&self) -> *const raw::git_oid { &self.raw as *const _ } } impl fmt::Debug for Oid { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(self, f) } } impl fmt::Display for Oid { /// Hex-encode this Oid into a formatter. fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut dst = [0u8; raw::GIT_OID_HEXSZ + 1]; unsafe { raw::git_oid_tostr(dst.as_mut_ptr() as *mut libc::c_char, dst.len() as libc::size_t, &self.raw); } let s = &dst[..dst.iter().position(|&a| a == 0).unwrap()]; str::from_utf8(s).unwrap().fmt(f) } } impl PartialEq for Oid { fn eq(&self, other: &Oid) -> bool { unsafe { raw::git_oid_equal(&self.raw, &other.raw) != 0 } } } impl Eq for Oid {} impl PartialOrd for Oid { fn partial_cmp(&self, other: &Oid) -> Option { Some(self.cmp(other)) } } impl Ord for Oid { fn cmp(&self, other: &Oid) -> Ordering { match unsafe { raw::git_oid_cmp(&self.raw, &other.raw) } { 0 => Ordering::Equal, n if n < 0 => Ordering::Less, _ => Ordering::Greater, } } } impl Clone for Oid { fn clone(&self) -> Oid { *self } } impl Hash for Oid { fn hash(&self, into: &mut H) { self.raw.id.hash(into) } } #[cfg(test)] mod tests { use super::Oid; #[test] fn conversions() { assert!(Oid::from_str("foo").is_err()); assert!(Oid::from_str("decbf2be529ab6557d5429922251e5ee36519817").is_ok()); assert!(Oid::from_bytes(b"foo").is_err()); assert!(Oid::from_bytes(b"00000000000000000000").is_ok()); } } deps/git2-0.3.3/src/refspec.rs0000664000175000017500000000541512623026314013027 0ustar use std::ffi::CString; use std::marker; use std::str; use {raw, Direction}; use util::Binding; /// A structure to represent a git [refspec][1]. /// /// Refspecs are currently mainly accessed/created through a `Remote`. /// /// [1]: http://git-scm.com/book/en/Git-Internals-The-Refspec pub struct Refspec<'remote> { raw: *const raw::git_refspec, _marker: marker::PhantomData<&'remote raw::git_remote>, } impl<'remote> Refspec<'remote> { /// Get the refspec's direction. pub fn direction(&self) -> Direction { match unsafe { raw::git_refspec_direction(self.raw) } { raw::GIT_DIRECTION_FETCH => Direction::Fetch, raw::GIT_DIRECTION_PUSH => Direction::Push, n => panic!("unknown refspec direction: {}", n), } } /// Get the destination specifier. /// /// If the destination is not utf-8, None is returned. pub fn dst(&self) -> Option<&str> { str::from_utf8(self.dst_bytes()).ok() } /// Get the destination specifier, in bytes. pub fn dst_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, raw::git_refspec_dst(self.raw)).unwrap() } } /// Check if a refspec's destination descriptor matches a reference pub fn dst_matches(&self, refname: &str) -> bool { let refname = CString::new(refname).unwrap(); unsafe { raw::git_refspec_dst_matches(self.raw, refname.as_ptr()) == 1 } } /// Get the source specifier. /// /// If the source is not utf-8, None is returned. pub fn src(&self) -> Option<&str> { str::from_utf8(self.src_bytes()).ok() } /// Get the source specifier, in bytes. pub fn src_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, raw::git_refspec_src(self.raw)).unwrap() } } /// Check if a refspec's source descriptor matches a reference pub fn src_matches(&self, refname: &str) -> bool { let refname = CString::new(refname).unwrap(); unsafe { raw::git_refspec_src_matches(self.raw, refname.as_ptr()) == 1 } } /// Get the force update setting. pub fn is_force(&self) -> bool { unsafe { raw::git_refspec_force(self.raw) == 1 } } /// Get the refspec's string. /// /// Returns None if the string is not valid utf8. pub fn str(&self) -> Option<&str> { str::from_utf8(self.bytes()).ok() } /// Get the refspec's string as a byte array pub fn bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, raw::git_refspec_string(self.raw)).unwrap() } } } impl<'remote> Binding for Refspec<'remote> { type Raw = *const raw::git_refspec; unsafe fn from_raw(raw: *const raw::git_refspec) -> Refspec<'remote> { Refspec { raw: raw, _marker: marker::PhantomData } } fn raw(&self) -> *const raw::git_refspec { self.raw } } deps/git2-0.3.3/src/reflog.rs0000664000175000017500000001171212517471774012673 0ustar use std::ops::Range; use std::marker; use std::str; use libc::size_t; use {raw, signature, Oid, Error, Signature}; use util::Binding; /// A reference log of a git repository. pub struct Reflog { raw: *mut raw::git_reflog, } /// An entry inside the reflog of a repository pub struct ReflogEntry<'reflog> { raw: *const raw::git_reflog_entry, _marker: marker::PhantomData<&'reflog Reflog>, } /// An iterator over the entries inside of a reflog. pub struct ReflogIter<'reflog> { range: Range, reflog: &'reflog Reflog, } impl Reflog { /// Add a new entry to the in-memory reflog. pub fn append(&mut self, new_oid: Oid, committer: &Signature, msg: Option<&str>) -> Result<(), Error> { let msg = try!(::opt_cstr(msg)); unsafe { try_call!(raw::git_reflog_append(self.raw, new_oid.raw(), committer.raw(), msg)); } Ok(()) } /// Remove an entry from the reflog by its index /// /// To ensure there's no gap in the log history, set rewrite_previous_entry /// param value to `true`. When deleting entry n, member old_oid of entry /// n-1 (if any) will be updated with the value of member new_oid of entry /// n+1. pub fn remove(&mut self, i: usize, rewrite_previous_entry: bool) -> Result<(), Error> { unsafe { try_call!(raw::git_reflog_drop(self.raw, i as size_t, rewrite_previous_entry)); } Ok(()) } /// Lookup an entry by its index /// /// Requesting the reflog entry with an index of 0 (zero) will return the /// most recently created entry. pub fn get(&self, i: usize) -> Option { unsafe { let ptr = raw::git_reflog_entry_byindex(self.raw, i as size_t); Binding::from_raw_opt(ptr) } } /// Get the number of log entries in a reflog pub fn len(&self) -> usize { unsafe { raw::git_reflog_entrycount(self.raw) as usize } } /// Get an iterator to all entries inside of this reflog pub fn iter(&self) -> ReflogIter { ReflogIter { range: 0..self.len(), reflog: self } } /// Write an existing in-memory reflog object back to disk using an atomic /// file lock. pub fn write(&mut self) -> Result<(), Error> { unsafe { try_call!(raw::git_reflog_write(self.raw)); } Ok(()) } } impl Binding for Reflog { type Raw = *mut raw::git_reflog; unsafe fn from_raw(raw: *mut raw::git_reflog) -> Reflog { Reflog { raw: raw } } fn raw(&self) -> *mut raw::git_reflog { self.raw } } impl Drop for Reflog { fn drop(&mut self) { unsafe { raw::git_reflog_free(self.raw) } } } impl<'reflog> ReflogEntry<'reflog> { /// Get the committer of this entry pub fn committer(&self) -> Signature { unsafe { let ptr = raw::git_reflog_entry_committer(self.raw); signature::from_raw_const(self, ptr) } } /// Get the new oid pub fn id_new(&self) -> Oid { unsafe { Binding::from_raw(raw::git_reflog_entry_id_new(self.raw)) } } /// Get the old oid pub fn id_old(&self) -> Oid { unsafe { Binding::from_raw(raw::git_reflog_entry_id_new(self.raw)) } } /// Get the log message, returning `None` on invalid UTF-8. pub fn message(&self) -> Option<&str> { self.message_bytes().and_then(|s| str::from_utf8(s).ok()) } /// Get the log message as a byte array. pub fn message_bytes(&self) -> Option<&[u8]> { unsafe { ::opt_bytes(self, raw::git_reflog_entry_message(self.raw)) } } } impl<'reflog> Binding for ReflogEntry<'reflog> { type Raw = *const raw::git_reflog_entry; unsafe fn from_raw(raw: *const raw::git_reflog_entry) -> ReflogEntry<'reflog> { ReflogEntry { raw: raw, _marker: marker::PhantomData } } fn raw(&self) -> *const raw::git_reflog_entry { self.raw } } impl<'reflog> Iterator for ReflogIter<'reflog> { type Item = ReflogEntry<'reflog>; fn next(&mut self) -> Option> { self.range.next().and_then(|i| self.reflog.get(i)) } fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } } impl<'reflog> DoubleEndedIterator for ReflogIter<'reflog> { fn next_back(&mut self) -> Option> { self.range.next_back().and_then(|i| self.reflog.get(i)) } } impl<'reflog> ExactSizeIterator for ReflogIter<'reflog> {} #[cfg(test)] mod tests { #[test] fn smoke() { let (_td, repo) = ::test::repo_init(); let mut reflog = repo.reflog("HEAD").unwrap(); assert_eq!(reflog.iter().len(), 1); reflog.write().unwrap(); let entry = reflog.iter().next().unwrap(); assert!(entry.message().is_some()); repo.reflog_rename("HEAD", "refs/heads/foo").unwrap(); repo.reflog_delete("refs/heads/foo").unwrap(); } } deps/git2-0.3.3/src/build.rs0000664000175000017500000003735112563210063012502 0ustar //! Builder-pattern objects for configuration various git operations. use std::ffi::{CStr, CString}; use std::mem; use std::path::Path; use libc::{c_char, size_t, c_void, c_uint, c_int}; use {raw, Error, Repository, FetchOptions, IntoCString}; use util::{self, Binding}; /// A builder struct which is used to build configuration for cloning a new git /// repository. pub struct RepoBuilder<'cb> { bare: bool, branch: Option, local: bool, hardlinks: bool, checkout: Option>, fetch_opts: Option>, } /// A builder struct for configuring checkouts of a repository. pub struct CheckoutBuilder<'cb> { their_label: Option, our_label: Option, ancestor_label: Option, target_dir: Option, paths: Vec, path_ptrs: Vec<*const c_char>, file_perm: Option, dir_perm: Option, disable_filters: bool, checkout_opts: u32, progress: Option>>, } /// Checkout progress notification callback. /// /// The first argument is the path for the notification, the next is the numver /// of completed steps so far, and the final is the total number of steps. pub type Progress<'a> = FnMut(Option<&Path>, usize, usize) + 'a; impl<'cb> RepoBuilder<'cb> { /// Creates a new repository builder with all of the default configuration. /// /// When ready, the `clone()` method can be used to clone a new repository /// using this configuration. pub fn new() -> RepoBuilder<'cb> { ::init(); RepoBuilder { bare: false, branch: None, local: true, hardlinks: true, checkout: None, fetch_opts: None, } } /// Indicate whether the repository will be cloned as a bare repository or /// not. pub fn bare(&mut self, bare: bool) -> &mut RepoBuilder<'cb> { self.bare = bare; self } /// Specify the name of the branch to check out after the clone. /// /// If not specified, the remote's default branch will be used. pub fn branch(&mut self, branch: &str) -> &mut RepoBuilder<'cb> { self.branch = Some(CString::new(branch).unwrap()); self } /// Set the flag for bypassing the git aware transport mechanism for local /// paths. /// /// If `true`, the git-aware transport will be bypassed for local paths. If /// `false`, the git-aware transport will not be bypassed. pub fn local(&mut self, local: bool) -> &mut RepoBuilder<'cb> { self.local = local; self } /// Set the flag for whether hardlinks are used when using a local git-aware /// transport mechanism. pub fn hardlinks(&mut self, links: bool) -> &mut RepoBuilder<'cb> { self.hardlinks = links; self } /// Configure the checkout which will be performed by consuming a checkout /// builder. pub fn with_checkout(&mut self, checkout: CheckoutBuilder<'cb>) -> &mut RepoBuilder<'cb> { self.checkout = Some(checkout); self } /// Options which control the fetch, including callbacks. /// /// The callbacks are used for reporting fetch progress, and for acquiring /// credentials in the event they are needed. pub fn fetch_options(&mut self, fetch_opts: FetchOptions<'cb>) -> &mut RepoBuilder<'cb> { self.fetch_opts = Some(fetch_opts); self } /// Clone a remote repository. /// /// This will use the options configured so far to clone the specified url /// into the specified local path. pub fn clone(&mut self, url: &str, into: &Path) -> Result { let mut opts: raw::git_clone_options = unsafe { mem::zeroed() }; unsafe { try_call!(raw::git_clone_init_options(&mut opts, raw::GIT_CLONE_OPTIONS_VERSION)); } opts.bare = self.bare as c_int; opts.checkout_branch = self.branch.as_ref().map(|s| { s.as_ptr() }).unwrap_or(0 as *const _); opts.local = match (self.local, self.hardlinks) { (true, false) => raw::GIT_CLONE_LOCAL_NO_LINKS, (false, _) => raw::GIT_CLONE_NO_LOCAL, (true, _) => raw::GIT_CLONE_LOCAL_AUTO, }; opts.checkout_opts.checkout_strategy = raw::GIT_CHECKOUT_SAFE as c_uint; match self.fetch_opts { Some(ref mut cbs) => { opts.fetch_opts = cbs.raw(); }, None => {} } match self.checkout { Some(ref mut c) => unsafe { c.configure(&mut opts.checkout_opts) }, None => {} } let url = try!(CString::new(url)); let into = try!(into.into_c_string()); let mut raw = 0 as *mut raw::git_repository; unsafe { try_call!(raw::git_clone(&mut raw, url, into, &opts)); Ok(Binding::from_raw(raw)) } } } impl<'cb> CheckoutBuilder<'cb> { /// Creates a new builder for checkouts with all of its default /// configuration. pub fn new() -> CheckoutBuilder<'cb> { ::init(); CheckoutBuilder { disable_filters: false, dir_perm: None, file_perm: None, path_ptrs: Vec::new(), paths: Vec::new(), target_dir: None, ancestor_label: None, our_label: None, their_label: None, checkout_opts: raw::GIT_CHECKOUT_SAFE as u32, progress: None, } } /// Indicate that this checkout should perform a dry run by checking for /// conflicts but not make any actual changes. pub fn dry_run(&mut self) -> &mut CheckoutBuilder<'cb> { self.checkout_opts &= !((1 << 4) - 1); self.checkout_opts |= raw::GIT_CHECKOUT_NONE as u32; self } /// Take any action necessary to get the working directory to match the /// target including potentially discarding modified files. pub fn force(&mut self) -> &mut CheckoutBuilder<'cb> { self.checkout_opts &= !((1 << 4) - 1); self.checkout_opts |= raw::GIT_CHECKOUT_FORCE as u32; self } /// Indicate that the checkout should be performed safely, allowing new /// files to be created but not overwriting extisting files or changes. /// /// This is the default. pub fn safe(&mut self) -> &mut CheckoutBuilder<'cb> { self.checkout_opts &= !((1 << 4) - 1); self.checkout_opts |= raw::GIT_CHECKOUT_SAFE as u32; self } fn flag(&mut self, bit: raw::git_checkout_strategy_t, on: bool) -> &mut CheckoutBuilder<'cb> { if on { self.checkout_opts |= bit as u32; } else { self.checkout_opts &= !(bit as u32); } self } /// In safe mode, apply safe file updates even when there are conflicts /// instead of canceling the checkout. /// /// Defaults to false. pub fn allow_conflicts(&mut self, allow: bool) -> &mut CheckoutBuilder<'cb> { self.flag(raw::GIT_CHECKOUT_ALLOW_CONFLICTS, allow) } /// Remove untracked files from the working dir. /// /// Defaults to false. pub fn remove_untracked(&mut self, remove: bool) -> &mut CheckoutBuilder<'cb> { self.flag(raw::GIT_CHECKOUT_REMOVE_UNTRACKED, remove) } /// Remove ignored files from the working dir. /// /// Defaults to false. pub fn remove_ignored(&mut self, remove: bool) -> &mut CheckoutBuilder<'cb> { self.flag(raw::GIT_CHECKOUT_REMOVE_IGNORED, remove) } /// Only update the contents of files that already exist. /// /// If set, files will not be created or deleted. /// /// Defaults to false. pub fn update_only(&mut self, update: bool) -> &mut CheckoutBuilder<'cb> { self.flag(raw::GIT_CHECKOUT_UPDATE_ONLY, update) } /// Prevents checkout from writing the updated files' information to the /// index. /// /// Defaults to true. pub fn update_index(&mut self, update: bool) -> &mut CheckoutBuilder<'cb> { self.flag(raw::GIT_CHECKOUT_DONT_UPDATE_INDEX, !update) } /// Indicate whether the index and git attributes should be refreshed from /// disk before any operations. /// /// Defaults to true, pub fn refresh(&mut self, refresh: bool) -> &mut CheckoutBuilder<'cb> { self.flag(raw::GIT_CHECKOUT_NO_REFRESH, !refresh) } /// Skip files with unmerged index entries. /// /// Defaults to false. pub fn skip_unmerged(&mut self, skip: bool) -> &mut CheckoutBuilder<'cb> { self.flag(raw::GIT_CHECKOUT_SKIP_UNMERGED, skip) } /// Indicate whether the checkout should proceed on conflicts by using the /// stage 2 version of the file ("ours"). /// /// Defaults to false. pub fn use_ours(&mut self, ours: bool) -> &mut CheckoutBuilder<'cb> { self.flag(raw::GIT_CHECKOUT_USE_OURS, ours) } /// Indicate whether the checkout should proceed on conflicts by using the /// stage 3 version of the file ("theirs"). /// /// Defaults to false. pub fn use_theirs(&mut self, theirs: bool) -> &mut CheckoutBuilder<'cb> { self.flag(raw::GIT_CHECKOUT_USE_THEIRS, theirs) } /// Indicate whether ignored files should be overwritten during the checkout. /// /// Defaults to true. pub fn overwrite_ignored(&mut self, overwrite: bool) -> &mut CheckoutBuilder<'cb> { self.flag(raw::GIT_CHECKOUT_DONT_OVERWRITE_IGNORED, !overwrite) } /// Indicate whether a normal merge file should be written for conflicts. /// /// Defaults to false. pub fn conflict_style_merge(&mut self, on: bool) -> &mut CheckoutBuilder<'cb> { self.flag(raw::GIT_CHECKOUT_CONFLICT_STYLE_MERGE, on) } /// Indicates whether to include common ancestor data in diff3 format files /// for conflicts. /// /// Defaults to false. pub fn conflict_style_diff3(&mut self, on: bool) -> &mut CheckoutBuilder<'cb> { self.flag(raw::GIT_CHECKOUT_CONFLICT_STYLE_DIFF3, on) } /// Indicate whether to apply filters like CRLF conversion. pub fn disable_filters(&mut self, disable: bool) -> &mut CheckoutBuilder<'cb> { self.disable_filters = disable; self } /// Set the mode with which new directories are created. /// /// Default is 0755 pub fn dir_perm(&mut self, perm: i32) -> &mut CheckoutBuilder<'cb> { self.dir_perm = Some(perm); self } /// Set the mode with which new files are created. /// /// The default is 0644 or 0755 as dictated by the blob. pub fn file_perm(&mut self, perm: i32) -> &mut CheckoutBuilder<'cb> { self.file_perm = Some(perm); self } /// Add a path to be checked out. /// /// If no paths are specified, then all files are checked out. Otherwise /// only these specified paths are checked out. pub fn path(&mut self, path: T) -> &mut CheckoutBuilder<'cb> { let path = path.into_c_string().unwrap(); self.path_ptrs.push(path.as_ptr()); self.paths.push(path); self } /// Set the directory to check out to pub fn target_dir(&mut self, dst: &Path) -> &mut CheckoutBuilder<'cb> { self.target_dir = Some(dst.into_c_string().unwrap()); self } /// The name of the common ancestor side of conflicts pub fn ancestor_label(&mut self, label: &str) -> &mut CheckoutBuilder<'cb> { self.ancestor_label = Some(CString::new(label).unwrap()); self } /// The name of the common our side of conflicts pub fn our_label(&mut self, label: &str) -> &mut CheckoutBuilder<'cb> { self.our_label = Some(CString::new(label).unwrap()); self } /// The name of the common their side of conflicts pub fn their_label(&mut self, label: &str) -> &mut CheckoutBuilder<'cb> { self.their_label = Some(CString::new(label).unwrap()); self } /// Set a callback to receive notifications of checkout progress. pub fn progress(&mut self, cb: F) -> &mut CheckoutBuilder<'cb> where F: FnMut(Option<&Path>, usize, usize) + 'cb { self.progress = Some(Box::new(cb) as Box>); self } /// Configure a raw checkout options based on this configuration. /// /// This method is unsafe as there is no guarantee that this structure will /// outlive the provided checkout options. pub unsafe fn configure(&mut self, opts: &mut raw::git_checkout_options) { opts.version = raw::GIT_CHECKOUT_OPTIONS_VERSION; opts.disable_filters = self.disable_filters as c_int; opts.dir_mode = self.dir_perm.unwrap_or(0) as c_uint; opts.file_mode = self.file_perm.unwrap_or(0) as c_uint; if self.path_ptrs.len() > 0 { opts.paths.strings = self.path_ptrs.as_ptr() as *mut _; opts.paths.count = self.path_ptrs.len() as size_t; } match self.target_dir { Some(ref c) => opts.target_directory = c.as_ptr(), None => {} } match self.ancestor_label { Some(ref c) => opts.ancestor_label = c.as_ptr(), None => {} } match self.our_label { Some(ref c) => opts.our_label = c.as_ptr(), None => {} } match self.their_label { Some(ref c) => opts.their_label = c.as_ptr(), None => {} } if self.progress.is_some() { let f: raw::git_checkout_progress_cb = progress_cb; opts.progress_cb = Some(f); opts.progress_payload = self as *mut _ as *mut _; } opts.checkout_strategy = self.checkout_opts as c_uint; } } wrap_env! { fn progress_cb(path: *const c_char, completed: size_t, total: size_t, data: *mut c_void) -> () { unsafe { let payload = &mut *(data as *mut CheckoutBuilder); let callback = match payload.progress { Some(ref mut c) => c, None => return, }; let path = if path.is_null() { None } else { Some(util::bytes2path(CStr::from_ptr(path).to_bytes())) }; callback(path, completed as usize, total as usize) } } returning _ok as () } #[cfg(test)] mod tests { use std::fs; use std::path::Path; use tempdir::TempDir; use super::RepoBuilder; use Repository; #[test] fn smoke() { let r = RepoBuilder::new().clone("/path/to/nowhere", Path::new("foo")); assert!(r.is_err()); } #[test] fn smoke2() { let td = TempDir::new("test").unwrap(); Repository::init_bare(&td.path().join("bare")).unwrap(); let url = if cfg!(unix) { format!("file://{}/bare", td.path().display()) } else { format!("file:///{}/bare", td.path().display().to_string() .replace("\\", "/")) }; let dst = td.path().join("foo"); RepoBuilder::new().clone(&url, &dst).unwrap(); fs::remove_dir_all(&dst).unwrap(); RepoBuilder::new().local(false).clone(&url, &dst).unwrap(); fs::remove_dir_all(&dst).unwrap(); RepoBuilder::new().local(false).hardlinks(false).bare(true) .clone(&url, &dst).unwrap(); fs::remove_dir_all(&dst).unwrap(); assert!(RepoBuilder::new().branch("foo") .clone(&url, &dst).is_err()); } } deps/git2-0.3.3/src/config.rs0000664000175000017500000004131512555730553012657 0ustar use std::ffi::CString; use std::marker; use std::path::{Path, PathBuf}; use std::str; use libc; use {raw, Error, ConfigLevel, Buf, IntoCString}; use util::{self, Binding}; /// A structure representing a git configuration key/value store pub struct Config { raw: *mut raw::git_config, } /// A struct representing a certain entry owned by a `Config` instance. /// /// An entry has a name, a value, and a level it applies to. pub struct ConfigEntry<'cfg> { raw: *mut raw::git_config_entry, _marker: marker::PhantomData<&'cfg Config>, owned: bool, } /// An iterator over the `ConfigEntry` values of a `Config` structure. pub struct ConfigEntries<'cfg> { raw: *mut raw::git_config_iterator, _marker: marker::PhantomData<&'cfg Config>, } impl Config { /// Allocate a new configuration object /// /// This object is empty, so you have to add a file to it before you can do /// anything with it. pub fn new() -> Result { ::init(); let mut raw = 0 as *mut raw::git_config; unsafe { try_call!(raw::git_config_new(&mut raw)); Ok(Binding::from_raw(raw)) } } /// Create a new config instance containing a single on-disk file pub fn open(path: &Path) -> Result { ::init(); let mut raw = 0 as *mut raw::git_config; let path = try!(path.into_c_string()); unsafe { try_call!(raw::git_config_open_ondisk(&mut raw, path)); Ok(Binding::from_raw(raw)) } } /// Open the global, XDG and system configuration files /// /// Utility wrapper that finds the global, XDG and system configuration /// files and opens them into a single prioritized config object that can /// be used when accessing default config data outside a repository. pub fn open_default() -> Result { ::init(); let mut raw = 0 as *mut raw::git_config; unsafe { try_call!(raw::git_config_open_default(&mut raw)); Ok(Binding::from_raw(raw)) } } /// Locate the path to the global configuration file /// /// The user or global configuration file is usually located in /// `$HOME/.gitconfig`. /// /// This method will try to guess the full path to that file, if the file /// exists. The returned path may be used on any method call to load /// the global configuration file. /// /// This method will not guess the path to the xdg compatible config file /// (`.config/git/config`). pub fn find_global() -> Result { ::init(); let buf = Buf::new(); unsafe { try_call!(raw::git_config_find_global(buf.raw())); } Ok(util::bytes2path(&buf).to_path_buf()) } /// Locate the path to the system configuration file /// /// If /etc/gitconfig doesn't exist, it will look for %PROGRAMFILES% pub fn find_system() -> Result { ::init(); let buf = Buf::new(); unsafe { try_call!(raw::git_config_find_system(buf.raw())); } Ok(util::bytes2path(&buf).to_path_buf()) } /// Locate the path to the global xdg compatible configuration file /// /// The xdg compatible configuration file is usually located in /// `$HOME/.config/git/config`. pub fn find_xdg() -> Result { ::init(); let buf = Buf::new(); unsafe { try_call!(raw::git_config_find_xdg(buf.raw())); } Ok(util::bytes2path(&buf).to_path_buf()) } /// Add an on-disk config file instance to an existing config /// /// The on-disk file pointed at by path will be opened and parsed; it's /// expected to be a native Git config file following the default Git config /// syntax (see man git-config). /// /// Further queries on this config object will access each of the config /// file instances in order (instances with a higher priority level will be /// accessed first). pub fn add_file(&mut self, path: &Path, level: ConfigLevel, force: bool) -> Result<(), Error> { let path = try!(path.into_c_string()); unsafe { try_call!(raw::git_config_add_file_ondisk(self.raw, path, level, force)); Ok(()) } } /// Delete a config variable from the config file with the highest level /// (usually the local one). pub fn remove(&mut self, name: &str) -> Result<(), Error> { let name = try!(CString::new(name)); unsafe { try_call!(raw::git_config_delete_entry(self.raw, name)); Ok(()) } } /// Get the value of a boolean config variable. /// /// All config files will be looked into, in the order of their defined /// level. A higher level means a higher priority. The first occurrence of /// the variable will be returned here. pub fn get_bool(&self, name: &str) -> Result { let mut out = 0 as libc::c_int; let name = try!(CString::new(name)); unsafe { try_call!(raw::git_config_get_bool(&mut out, &*self.raw, name)); } Ok(if out == 0 {false} else {true}) } /// Get the value of an integer config variable. /// /// All config files will be looked into, in the order of their defined /// level. A higher level means a higher priority. The first occurrence of /// the variable will be returned here. pub fn get_i32(&self, name: &str) -> Result { let mut out = 0i32; let name = try!(CString::new(name)); unsafe { try_call!(raw::git_config_get_int32(&mut out, &*self.raw, name)); } Ok(out) } /// Get the value of an integer config variable. /// /// All config files will be looked into, in the order of their defined /// level. A higher level means a higher priority. The first occurrence of /// the variable will be returned here. pub fn get_i64(&self, name: &str) -> Result { let mut out = 0i64; let name = try!(CString::new(name)); unsafe { try_call!(raw::git_config_get_int64(&mut out, &*self.raw, name)); } Ok(out) } /// Get the value of a string config variable. /// /// This is the same as `get_bytes` except that it may return `Err` if /// the bytes are not valid utf-8. pub fn get_str(&self, name: &str) -> Result<&str, Error> { str::from_utf8(try!(self.get_bytes(name))).map_err(|_| { Error::from_str("configuration value is not valid utf8") }) } /// Get the value of a string config variable as a byte slice. /// /// This method will return an error if this `Config` is not a snapshot. pub fn get_bytes(&self, name: &str) -> Result<&[u8], Error> { let mut ret = 0 as *const libc::c_char; let name = try!(CString::new(name)); unsafe { try_call!(raw::git_config_get_string(&mut ret, &*self.raw, name)); Ok(::opt_bytes(self, ret).unwrap()) } } /// Get the value of a string config variable as an owned string. /// /// An error will be returned if the config value is not valid utf-8. pub fn get_string(&self, name: &str) -> Result { let ret = Buf::new(); let name = try!(CString::new(name)); unsafe { try_call!(raw::git_config_get_string_buf(ret.raw(), self.raw, name)); } str::from_utf8(&ret).map(|s| s.to_string()).map_err(|_| { Error::from_str("configuration value is not valid utf8") }) } /// Get the value of a path config variable as an owned . pub fn get_path(&self, name: &str) -> Result { let ret = Buf::new(); let name = try!(CString::new(name)); unsafe { try_call!(raw::git_config_get_path(ret.raw(), self.raw, name)); } Ok(::util::bytes2path(&ret).to_path_buf()) } /// Get the ConfigEntry for a config variable. pub fn get_entry(&self, name: &str) -> Result { let mut ret = 0 as *mut raw::git_config_entry; let name = try!(CString::new(name)); unsafe { try_call!(raw::git_config_get_entry(&mut ret, self.raw, name)); Ok(Binding::from_raw(ret)) } } /// Iterate over all the config variables /// /// If `glob` is `Some`, then the iterator will only iterate over all /// variables whose name matches the pattern. /// /// # Example /// /// ``` /// # #![allow(unstable)] /// use git2::Config; /// /// let cfg = Config::new().unwrap(); /// /// for entry in &cfg.entries(None).unwrap() { /// println!("{} => {}", entry.name().unwrap(), entry.value().unwrap()); /// } /// ``` pub fn entries(&self, glob: Option<&str>) -> Result { let mut ret = 0 as *mut raw::git_config_iterator; unsafe { match glob { Some(s) => { let s = try!(CString::new(s)); try_call!(raw::git_config_iterator_glob_new(&mut ret, &*self.raw, s)); } None => { try_call!(raw::git_config_iterator_new(&mut ret, &*self.raw)); } } Ok(Binding::from_raw(ret)) } } /// Open the global/XDG configuration file according to git's rules /// /// Git allows you to store your global configuration at `$HOME/.config` or /// `$XDG_CONFIG_HOME/git/config`. For backwards compatability, the XDG file /// shouldn't be used unless the use has created it explicitly. With this /// function you'll open the correct one to write to. pub fn open_global(&mut self) -> Result { let mut raw = 0 as *mut raw::git_config; unsafe { try_call!(raw::git_config_open_global(&mut raw, self.raw)); Ok(Binding::from_raw(raw)) } } /// Build a single-level focused config object from a multi-level one. /// /// The returned config object can be used to perform get/set/delete /// operations on a single specific level. pub fn open_level(&self, level: ConfigLevel) -> Result { let mut raw = 0 as *mut raw::git_config; unsafe { try_call!(raw::git_config_open_level(&mut raw, &*self.raw, level)); Ok(Binding::from_raw(raw)) } } /// Set the value of a boolean config variable in the config file with the /// highest level (usually the local one). pub fn set_bool(&mut self, name: &str, value: bool) -> Result<(), Error> { let name = try!(CString::new(name)); unsafe { try_call!(raw::git_config_set_bool(self.raw, name, value)); } Ok(()) } /// Set the value of an integer config variable in the config file with the /// highest level (usually the local one). pub fn set_i32(&mut self, name: &str, value: i32) -> Result<(), Error> { let name = try!(CString::new(name)); unsafe { try_call!(raw::git_config_set_int32(self.raw, name, value)); } Ok(()) } /// Set the value of an integer config variable in the config file with the /// highest level (usually the local one). pub fn set_i64(&mut self, name: &str, value: i64) -> Result<(), Error> { let name = try!(CString::new(name)); unsafe { try_call!(raw::git_config_set_int64(self.raw, name, value)); } Ok(()) } /// Set the value of a string config variable in the config file with the /// highest level (usually the local one). pub fn set_str(&mut self, name: &str, value: &str) -> Result<(), Error> { let name = try!(CString::new(name)); let value = try!(CString::new(value)); unsafe { try_call!(raw::git_config_set_string(self.raw, name, value)); } Ok(()) } /// Create a snapshot of the configuration /// /// Create a snapshot of the current state of a configuration, which allows /// you to look into a consistent view of the configuration for looking up /// complex values (e.g. a remote, submodule). pub fn snapshot(&mut self) -> Result { let mut ret = 0 as *mut raw::git_config; unsafe { try_call!(raw::git_config_snapshot(&mut ret, self.raw)); Ok(Binding::from_raw(ret)) } } } impl Binding for Config { type Raw = *mut raw::git_config; unsafe fn from_raw(raw: *mut raw::git_config) -> Config { Config { raw: raw } } fn raw(&self) -> *mut raw::git_config { self.raw } } impl Drop for Config { fn drop(&mut self) { unsafe { raw::git_config_free(self.raw) } } } impl<'cfg> ConfigEntry<'cfg> { /// Gets the name of this entry. /// /// May return `None` if the name is not valid utf-8 pub fn name(&self) -> Option<&str> { str::from_utf8(self.name_bytes()).ok() } /// Gets the name of this entry as a byte slice. pub fn name_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, (*self.raw).name).unwrap() } } /// Gets the value of this entry. /// /// May return `None` if the value is not valid utf-8 pub fn value(&self) -> Option<&str> { str::from_utf8(self.value_bytes()).ok() } /// Gets the value of this entry as a byte slice. pub fn value_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, (*self.raw).value).unwrap() } } /// Gets the configuration level of this entry. pub fn level(&self) -> ConfigLevel { unsafe { ConfigLevel::from_raw((*self.raw).level) } } } impl<'cfg> Binding for ConfigEntry<'cfg> { type Raw = *mut raw::git_config_entry; unsafe fn from_raw(raw: *mut raw::git_config_entry) -> ConfigEntry<'cfg> { ConfigEntry { raw: raw, _marker: marker::PhantomData, owned: true, } } fn raw(&self) -> *mut raw::git_config_entry { self.raw } } impl<'cfg> Binding for ConfigEntries<'cfg> { type Raw = *mut raw::git_config_iterator; unsafe fn from_raw(raw: *mut raw::git_config_iterator) -> ConfigEntries<'cfg> { ConfigEntries { raw: raw, _marker: marker::PhantomData, } } fn raw(&self) -> *mut raw::git_config_iterator { self.raw } } // entries are only valid until the iterator is freed, so this impl is for // `&'b T` instead of `T` to have a lifetime to tie them to. // // It's also not implemented for `&'b mut T` so we can have multiple entries // (ok). impl<'cfg, 'b> Iterator for &'b ConfigEntries<'cfg> { type Item = ConfigEntry<'b>; fn next(&mut self) -> Option> { let mut raw = 0 as *mut raw::git_config_entry; unsafe { if raw::git_config_next(&mut raw, self.raw) == 0 { Some(ConfigEntry { owned: false, raw: raw, _marker: marker::PhantomData, }) } else { None } } } } impl<'cfg> Drop for ConfigEntries<'cfg> { fn drop(&mut self) { unsafe { raw::git_config_iterator_free(self.raw) } } } impl<'cfg> Drop for ConfigEntry<'cfg> { fn drop(&mut self) { if self.owned { unsafe { raw::git_config_entry_free(self.raw) } } } } #[cfg(test)] mod tests { use std::fs::File; use tempdir::TempDir; use Config; #[test] fn smoke() { let _cfg = Config::new().unwrap(); let _ = Config::find_global(); let _ = Config::find_system(); let _ = Config::find_xdg(); } #[test] fn persisted() { let td = TempDir::new("test").unwrap(); let path = td.path().join("foo"); File::create(&path).unwrap(); let mut cfg = Config::open(&path).unwrap(); assert!(cfg.get_bool("foo.bar").is_err()); cfg.set_bool("foo.k1", true).unwrap(); cfg.set_i32("foo.k2", 1).unwrap(); cfg.set_i64("foo.k3", 2).unwrap(); cfg.set_str("foo.k4", "bar").unwrap(); cfg.snapshot().unwrap(); drop(cfg); let cfg = Config::open(&path).unwrap().snapshot().unwrap(); assert_eq!(cfg.get_bool("foo.k1").unwrap(), true); assert_eq!(cfg.get_i32("foo.k2").unwrap(), 1); assert_eq!(cfg.get_i64("foo.k3").unwrap(), 2); assert_eq!(cfg.get_str("foo.k4").unwrap(), "bar"); for entry in &cfg.entries(None).unwrap() { entry.name(); entry.value(); entry.level(); } } } deps/git2-0.3.3/src/commit.rs0000664000175000017500000002620612603146276012701 0ustar use std::marker; use std::ops::Range; use std::str; use libc; use {raw, signature, Oid, Error, Signature, Tree, Time, Object}; use util::Binding; /// A structure to represent a git [commit][1] /// /// [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects pub struct Commit<'repo> { raw: *mut raw::git_commit, _marker: marker::PhantomData>, } /// An iterator over the parent commits of a commit. pub struct Parents<'commit, 'repo: 'commit> { range: Range, commit: &'commit Commit<'repo>, } /// An iterator over the parent commits' ids of a commit. pub struct ParentIds<'commit> { range: Range, commit: &'commit Commit<'commit>, } impl<'repo> Commit<'repo> { /// Get the id (SHA1) of a repository commit pub fn id(&self) -> Oid { unsafe { Binding::from_raw(raw::git_commit_id(&*self.raw)) } } /// Get the id of the tree pointed to by this commit. /// /// No attempts are made to fetch an object from the ODB. pub fn tree_id(&self) -> Oid { unsafe { Binding::from_raw(raw::git_commit_tree_id(&*self.raw)) } } /// Get the tree pointed to by a commit. pub fn tree(&self) -> Result, Error> { let mut ret = 0 as *mut raw::git_tree; unsafe { try_call!(raw::git_commit_tree(&mut ret, &*self.raw)); Ok(Binding::from_raw(ret)) } } /// Get access to the underlying raw pointer. pub fn raw(&self) -> *mut raw::git_commit { self.raw } /// Get the full message of a commit. /// /// The returned message will be slightly prettified by removing any /// potential leading newlines. /// /// `None` will be returned if the message is not valid utf-8 pub fn message(&self) -> Option<&str> { str::from_utf8(self.message_bytes()).ok() } /// Get the full message of a commit as a byte slice. /// /// The returned message will be slightly prettified by removing any /// potential leading newlines. pub fn message_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, raw::git_commit_message(&*self.raw)).unwrap() } } /// Get the encoding for the message of a commit, as a string representing a /// standard encoding name. /// /// `None` will be returned if the encoding is not known pub fn message_encoding(&self) -> Option<&str> { let bytes = unsafe { ::opt_bytes(self, raw::git_commit_message(&*self.raw)) }; bytes.map(|b| str::from_utf8(b).unwrap()) } /// Get the full raw message of a commit. /// /// `None` will be returned if the message is not valid utf-8 pub fn message_raw(&self) -> Option<&str> { str::from_utf8(self.message_raw_bytes()).ok() } /// Get the full raw message of a commit. pub fn message_raw_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, raw::git_commit_message_raw(&*self.raw)).unwrap() } } /// Get the full raw text of the commit header. /// /// `None` will be returned if the message is not valid utf-8 pub fn raw_header(&self) -> Option<&str> { str::from_utf8(self.raw_header_bytes()).ok() } /// Get the full raw text of the commit header. pub fn raw_header_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, raw::git_commit_raw_header(&*self.raw)).unwrap() } } /// Get the short "summary" of the git commit message. /// /// The returned message is the summary of the commit, comprising the first /// paragraph of the message with whitespace trimmed and squashed. /// /// `None` may be returned if an error occurs or if the summary is not valid /// utf-8. pub fn summary(&mut self) -> Option<&str> { self.summary_bytes().and_then(|s| str::from_utf8(s).ok()) } /// Get the short "summary" of the git commit message. /// /// The returned message is the summary of the commit, comprising the first /// paragraph of the message with whitespace trimmed and squashed. /// /// `None` may be returned if an error occurs pub fn summary_bytes(&mut self) -> Option<&[u8]> { unsafe { ::opt_bytes(self, raw::git_commit_summary(self.raw)) } } /// Get the commit time (i.e. committer time) of a commit. /// /// The first element of the tuple is the time, in seconds, since the epoch. /// The second element is the offset, in minutes, of the time zone of the /// committer's preferred time zone. pub fn time(&self) -> Time { unsafe { Time::new(raw::git_commit_time(&*self.raw) as i64, raw::git_commit_time_offset(&*self.raw) as i32) } } /// Creates a new iterator over the parents of this commit. pub fn parents<'a>(&'a self) -> Parents<'a, 'repo> { let max = unsafe { raw::git_commit_parentcount(&*self.raw) as usize }; Parents { range: 0..max, commit: self } } /// Creates a new iterator over the parents of this commit. pub fn parent_ids(&self) -> ParentIds { let max = unsafe { raw::git_commit_parentcount(&*self.raw) as usize }; ParentIds { range: 0..max, commit: self } } /// Get the author of this commit. pub fn author(&self) -> Signature { unsafe { let ptr = raw::git_commit_author(&*self.raw); signature::from_raw_const(self, ptr) } } /// Get the committer of this commit. pub fn committer(&self) -> Signature { unsafe { let ptr = raw::git_commit_committer(&*self.raw); signature::from_raw_const(self, ptr) } } /// Amend this existing commit with all non-`None` values /// /// This creates a new commit that is exactly the same as the old commit, /// except that any non-`None` values will be updated. The new commit has /// the same parents as the old commit. /// /// For information about `update_ref`, see `new`. pub fn amend(&self, update_ref: Option<&str>, author: Option<&Signature>, committer: Option<&Signature>, message_encoding: Option<&str>, message: Option<&str>, tree: Option<&Tree<'repo>>) -> Result { let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; let update_ref = try!(::opt_cstr(update_ref)); let encoding = try!(::opt_cstr(message_encoding)); let message = try!(::opt_cstr(message)); unsafe { try_call!(raw::git_commit_amend(&mut raw, self.raw(), update_ref, author.map(|s| s.raw()), committer.map(|s| s.raw()), encoding, message, tree.map(|t| t.raw()))); Ok(Binding::from_raw(&raw as *const _)) } } /// Get the specified parent of the commit. /// /// Use the `parents` iterator to return an iterator over all parents. pub fn parent(&self, i: usize) -> Result, Error> { unsafe { let mut raw = 0 as *mut raw::git_commit; try_call!(raw::git_commit_parent(&mut raw, &*self.raw, i as libc::c_uint)); Ok(Binding::from_raw(raw)) } } /// Get the specified parent id of the commit. /// /// This is different from `parent`, which will attemptstempt to load the /// parent commit from the ODB. /// /// Use the `parent_ids` iterator to return an iterator over all parents. pub fn parent_id(&self, i: usize) -> Result { unsafe { let id = raw::git_commit_parent_id(self.raw, i as libc::c_uint); if id.is_null() { Err(Error::from_str("parent index out of bounds")) } else { Ok(Binding::from_raw(id)) } } } /// Casts this Commit to be usable as an `Object` pub fn as_object(&self) -> &Object<'repo> { unsafe { &*(self as *const _ as *const Object<'repo>) } } } impl<'repo> Binding for Commit<'repo> { type Raw = *mut raw::git_commit; unsafe fn from_raw(raw: *mut raw::git_commit) -> Commit<'repo> { Commit { raw: raw, _marker: marker::PhantomData, } } fn raw(&self) -> *mut raw::git_commit { self.raw } } impl<'repo, 'commit> Iterator for Parents<'commit, 'repo> { type Item = Commit<'repo>; fn next(&mut self) -> Option> { self.range.next().map(|i| self.commit.parent(i).unwrap()) } fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } } impl<'repo, 'commit> DoubleEndedIterator for Parents<'commit, 'repo> { fn next_back(&mut self) -> Option> { self.range.next_back().map(|i| self.commit.parent(i).unwrap()) } } impl<'repo, 'commit> ExactSizeIterator for Parents<'commit, 'repo> {} impl<'commit> Iterator for ParentIds<'commit> { type Item = Oid; fn next(&mut self) -> Option { self.range.next().map(|i| self.commit.parent_id(i).unwrap()) } fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } } impl<'commit> DoubleEndedIterator for ParentIds<'commit> { fn next_back(&mut self) -> Option { self.range.next_back().map(|i| self.commit.parent_id(i).unwrap()) } } impl<'commit> ExactSizeIterator for ParentIds<'commit> {} impl<'repo> Drop for Commit<'repo> { fn drop(&mut self) { unsafe { raw::git_commit_free(self.raw) } } } #[cfg(test)] mod tests { #[test] fn smoke() { let (_td, repo) = ::test::repo_init(); let head = repo.head().unwrap(); let target = head.target().unwrap(); let mut commit = repo.find_commit(target).unwrap(); assert_eq!(commit.message(), Some("initial")); assert_eq!(commit.id(), target); commit.message_raw().unwrap(); commit.raw_header().unwrap(); commit.message_encoding(); commit.summary().unwrap(); commit.tree_id(); commit.tree().unwrap(); assert_eq!(commit.parents().count(), 0); assert_eq!(commit.author().name(), Some("name")); assert_eq!(commit.author().email(), Some("email")); assert_eq!(commit.committer().name(), Some("name")); assert_eq!(commit.committer().email(), Some("email")); let sig = repo.signature().unwrap(); let tree = repo.find_tree(commit.tree_id()).unwrap(); let id = repo.commit(Some("HEAD"), &sig, &sig, "bar", &tree, &[&commit]).unwrap(); let head = repo.find_commit(id).unwrap(); let new_head = head.amend(Some("HEAD"), None, None, None, Some("new message"), None).unwrap(); let new_head = repo.find_commit(new_head).unwrap(); assert_eq!(new_head.message(), Some("new message")); repo.find_object(target, None).unwrap().as_commit().unwrap(); } } deps/git2-0.3.3/src/remote.rs0000664000175000017500000004516112610312451012671 0ustar use std::ffi::CString; use std::ops::Range; use std::marker; use std::mem; use std::slice; use std::str; use libc; use {raw, Direction, Error, Refspec, Oid, FetchPrune}; use {RemoteCallbacks, Progress, Repository, AutotagOption}; use util::Binding; /// A structure representing a [remote][1] of a git repository. /// /// [1]: http://git-scm.com/book/en/Git-Basics-Working-with-Remotes /// /// The lifetime is the lifetime of the repository that it is attached to. The /// remote is used to manage fetches and pushes as well as refspecs. pub struct Remote<'repo> { raw: *mut raw::git_remote, _marker: marker::PhantomData<&'repo Repository>, } /// An iterator over the refspecs that a remote contains. pub struct Refspecs<'remote> { range: Range, remote: &'remote Remote<'remote>, } /// Description of a reference advertised bya remote server, given out on calls /// to `list`. pub struct RemoteHead<'remote> { raw: *const raw::git_remote_head, _marker: marker::PhantomData<&'remote str>, } /// Options which can be specified to various fetch operations. pub struct FetchOptions<'cb> { callbacks: Option>, prune: FetchPrune, update_fetchhead: bool, download_tags: AutotagOption, } /// Options to control the behavior of a git push. pub struct PushOptions<'cb> { callbacks: Option>, pb_parallelism: u32, } impl<'repo> Remote<'repo> { /// Ensure the remote name is well-formed. pub fn is_valid_name(remote_name: &str) -> bool { ::init(); let remote_name = CString::new(remote_name).unwrap(); unsafe { raw::git_remote_is_valid_name(remote_name.as_ptr()) == 1 } } /// Get the remote's name. /// /// Returns `None` if this remote has not yet been named or if the name is /// not valid utf-8 pub fn name(&self) -> Option<&str> { self.name_bytes().and_then(|s| str::from_utf8(s).ok()) } /// Get the remote's name, in bytes. /// /// Returns `None` if this remote has not yet been named pub fn name_bytes(&self) -> Option<&[u8]> { unsafe { ::opt_bytes(self, raw::git_remote_name(&*self.raw)) } } /// Get the remote's url. /// /// Returns `None` if the url is not valid utf-8 pub fn url(&self) -> Option<&str> { str::from_utf8(self.url_bytes()).ok() } /// Get the remote's url as a byte array. pub fn url_bytes(&self) -> &[u8] { unsafe { ::opt_bytes(self, raw::git_remote_url(&*self.raw)).unwrap() } } /// Get the remote's pushurl. /// /// Returns `None` if the pushurl is not valid utf-8 pub fn pushurl(&self) -> Option<&str> { self.pushurl_bytes().and_then(|s| str::from_utf8(s).ok()) } /// Get the remote's pushurl as a byte array. pub fn pushurl_bytes(&self) -> Option<&[u8]> { unsafe { ::opt_bytes(self, raw::git_remote_pushurl(&*self.raw)) } } /// Open a connection to a remote. pub fn connect(&mut self, dir: Direction) -> Result<(), Error> { // TODO: can callbacks be exposed safely? unsafe { try_call!(raw::git_remote_connect(self.raw, dir, 0 as *const _, 0 as *const _)); } Ok(()) } /// Check whether the remote is connected pub fn connected(&mut self) -> bool { unsafe { raw::git_remote_connected(self.raw) == 1 } } /// Disconnect from the remote pub fn disconnect(&mut self) { unsafe { raw::git_remote_disconnect(self.raw) } } /// Download and index the packfile /// /// Connect to the remote if it hasn't been done yet, negotiate with the /// remote git which objects are missing, download and index the packfile. /// /// The .idx file will be created and both it and the packfile with be /// renamed to their final name. /// /// The `specs` argument is a list of refspecs to use for this negotiation /// and download. Use an empty array to use the base refspecs. pub fn download(&mut self, specs: &[&str], opts: Option<&mut FetchOptions>) -> Result<(), Error> { let (_a, _b, arr) = try!(::util::iter2cstrs(specs.iter())); let raw = opts.map(|o| o.raw()); unsafe { try_call!(raw::git_remote_download(self.raw, &arr, raw.as_ref())); } Ok(()) } /// Get the number of refspecs for a remote pub fn refspecs<'a>(&'a self) -> Refspecs<'a> { let cnt = unsafe { raw::git_remote_refspec_count(&*self.raw) as usize }; Refspecs { range: 0..cnt, remote: self } } /// Get the `nth` refspec from this remote. /// /// The `refspecs` iterator can be used to iterate over all refspecs. pub fn get_refspec(&self, i: usize) -> Option> { unsafe { let ptr = raw::git_remote_get_refspec(&*self.raw, i as libc::size_t); Binding::from_raw_opt(ptr) } } /// Download new data and update tips /// /// Convenience function to connect to a remote, download the data, /// disconnect and update the remote-tracking branches. pub fn fetch(&mut self, refspecs: &[&str], opts: Option<&mut FetchOptions>, reflog_msg: Option<&str>) -> Result<(), Error> { let (_a, _b, arr) = try!(::util::iter2cstrs(refspecs.iter())); let msg = try!(::opt_cstr(reflog_msg)); let raw = opts.map(|o| o.raw()); unsafe { try_call!(raw::git_remote_fetch(self.raw, &arr, raw.as_ref(), msg)); } Ok(()) } /// Update the tips to the new state pub fn update_tips(&mut self, callbacks: Option<&mut RemoteCallbacks>, update_fetchhead: bool, download_tags: AutotagOption, msg: Option<&str>) -> Result<(), Error> { let msg = try!(::opt_cstr(msg)); let cbs = callbacks.map(|cb| cb.raw()); unsafe { try_call!(raw::git_remote_update_tips(self.raw, cbs.as_ref(), update_fetchhead, download_tags, msg)); } Ok(()) } /// Perform a push /// /// Perform all the steps for a push. If no refspecs are passed then the /// configured refspecs will be used. pub fn push(&mut self, refspecs: &[&str], opts: Option<&mut PushOptions>) -> Result<(), Error> { let (_a, _b, arr) = try!(::util::iter2cstrs(refspecs.iter())); let raw = opts.map(|o| o.raw()); unsafe { try_call!(raw::git_remote_push(self.raw, &arr, raw.as_ref())); } Ok(()) } /// Get the statistics structure that is filled in by the fetch operation. pub fn stats(&self) -> Progress { unsafe { Binding::from_raw(raw::git_remote_stats(self.raw)) } } /// Get the remote repository's reference advertisement list. /// /// Get the list of references with which the server responds to a new /// connection. /// /// The remote (or more exactly its transport) must have connected to the /// remote repository. This list is available as soon as the connection to /// the remote is initiated and it remains available after disconnecting. pub fn list(&self) -> Result<&[RemoteHead], Error> { let mut size = 0; let mut base = 0 as *mut _; unsafe { try_call!(raw::git_remote_ls(&mut base, &mut size, self.raw)); assert_eq!(mem::size_of::(), mem::size_of::<*const raw::git_remote_head>()); let slice = slice::from_raw_parts(base as *const _, size as usize); Ok(mem::transmute::<&[*const raw::git_remote_head], &[RemoteHead]>(slice)) } } } impl<'repo> Clone for Remote<'repo> { fn clone(&self) -> Remote<'repo> { let mut ret = 0 as *mut raw::git_remote; let rc = unsafe { call!(raw::git_remote_dup(&mut ret, self.raw)) }; assert_eq!(rc, 0); Remote { raw: ret, _marker: marker::PhantomData, } } } impl<'repo> Binding for Remote<'repo> { type Raw = *mut raw::git_remote; unsafe fn from_raw(raw: *mut raw::git_remote) -> Remote<'repo> { Remote { raw: raw, _marker: marker::PhantomData, } } fn raw(&self) -> *mut raw::git_remote { self.raw } } impl<'repo> Drop for Remote<'repo> { fn drop(&mut self) { unsafe { raw::git_remote_free(self.raw) } } } impl<'repo> Iterator for Refspecs<'repo> { type Item = Refspec<'repo>; fn next(&mut self) -> Option> { self.range.next().and_then(|i| self.remote.get_refspec(i)) } fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } } impl<'repo> DoubleEndedIterator for Refspecs<'repo> { fn next_back(&mut self) -> Option> { self.range.next_back().and_then(|i| self.remote.get_refspec(i)) } } impl<'repo> ExactSizeIterator for Refspecs<'repo> {} #[allow(missing_docs)] // not documented in libgit2 :( impl<'remote> RemoteHead<'remote> { /// Flag if this is available locally. pub fn is_local(&self) -> bool { unsafe { (*self.raw).local != 0 } } pub fn oid(&self) -> Oid { unsafe { Binding::from_raw(&(*self.raw).oid as *const _) } } pub fn loid(&self) -> Oid { unsafe { Binding::from_raw(&(*self.raw).loid as *const _) } } pub fn name(&self) -> &str { let b = unsafe { ::opt_bytes(self, (*self.raw).name).unwrap() }; str::from_utf8(b).unwrap() } pub fn symref_target(&self) -> Option<&str> { let b = unsafe { ::opt_bytes(self, (*self.raw).symref_target) }; b.map(|b| str::from_utf8(b).unwrap()) } } impl<'cb> FetchOptions<'cb> { /// Creates a new blank set of fetch options pub fn new() -> FetchOptions<'cb> { FetchOptions { callbacks: None, prune: FetchPrune::Unspecified, update_fetchhead: true, download_tags: AutotagOption::Unspecified, } } /// Set the callbacks to use for the fetch operation. pub fn remote_callbacks(&mut self, cbs: RemoteCallbacks<'cb>) -> &mut Self { self.callbacks = Some(cbs); self } /// Set whether to perform a prune after the fetch. pub fn prune(&mut self, prune: FetchPrune) -> &mut Self { self.prune = prune; self } /// Set whether to write the results to FETCH_HEAD. /// /// Defaults to `true`. pub fn update_fetchhead(&mut self, update: bool) -> &mut Self { self.update_fetchhead = update; self } /// Set how to behave regarding tags on the remote, such as auto-downloading /// tags for objects we're downloading or downloading all of them. /// /// The default is to auto-follow tags. pub fn download_tags(&mut self, opt: AutotagOption) -> &mut Self { self.download_tags = opt; self } } impl<'cb> Binding for FetchOptions<'cb> { type Raw = raw::git_fetch_options; unsafe fn from_raw(_raw: raw::git_fetch_options) -> FetchOptions<'cb> { panic!("unimplemented"); } fn raw(&self) -> raw::git_fetch_options { raw::git_fetch_options { version: 1, callbacks: self.callbacks.as_ref().map(|m| m.raw()) .unwrap_or(unsafe { mem::zeroed() }), prune: ::call::convert(&self.prune), update_fetchhead: ::call::convert(&self.update_fetchhead), download_tags: ::call::convert(&self.download_tags), // TODO: expose this as a builder option custom_headers: raw::git_strarray { count: 0, strings: 0 as *mut _, }, } } } impl<'cb> PushOptions<'cb> { /// Creates a new blank set of push options pub fn new() -> PushOptions<'cb> { PushOptions { callbacks: None, pb_parallelism: 1, } } /// Set the callbacks to use for the fetch operation. pub fn remote_callbacks(&mut self, cbs: RemoteCallbacks<'cb>) -> &mut Self { self.callbacks = Some(cbs); self } /// If the transport being used to push to the remote requires the creation /// of a pack file, this controls the number of worker threads used by the /// packbuilder when creating that pack file to be sent to the remote. /// /// if set to 0 the packbuilder will auto-detect the number of threads to /// create, and the default value is 1. pub fn packbuilder_parallelism(&mut self, parallel: u32) -> &mut Self { self.pb_parallelism = parallel; self } } impl<'cb> Binding for PushOptions<'cb> { type Raw = raw::git_push_options; unsafe fn from_raw(_raw: raw::git_push_options) -> PushOptions<'cb> { panic!("unimplemented"); } fn raw(&self) -> raw::git_push_options { raw::git_push_options { version: 1, callbacks: self.callbacks.as_ref().map(|m| m.raw()) .unwrap_or(unsafe { mem::zeroed() }), pb_parallelism: self.pb_parallelism as libc::c_uint, // TODO: expose this as a builder option custom_headers: raw::git_strarray { count: 0, strings: 0 as *mut _, }, } } } #[cfg(test)] mod tests { use std::cell::Cell; use tempdir::TempDir; use {Repository, Remote, RemoteCallbacks, Direction, FetchOptions}; use {AutotagOption}; #[test] fn smoke() { let (td, repo) = ::test::repo_init(); t!(repo.remote("origin", "/path/to/nowhere")); drop(repo); let repo = t!(Repository::init(td.path())); let origin = t!(repo.find_remote("origin")); assert_eq!(origin.name(), Some("origin")); assert_eq!(origin.url(), Some("/path/to/nowhere")); assert_eq!(origin.pushurl(), None); t!(repo.remote_set_url("origin", "/path/to/elsewhere")); t!(repo.remote_set_pushurl("origin", Some("/path/to/elsewhere"))); let stats = origin.stats(); assert_eq!(stats.total_objects(), 0); } #[test] fn create_remote() { let td = TempDir::new("test").unwrap(); let remote = td.path().join("remote"); Repository::init_bare(&remote).unwrap(); let (_td, repo) = ::test::repo_init(); let url = if cfg!(unix) { format!("file://{}", remote.display()) } else { format!("file:///{}", remote.display().to_string() .replace("\\", "/")) }; let mut origin = repo.remote("origin", &url).unwrap(); assert_eq!(origin.name(), Some("origin")); assert_eq!(origin.url(), Some(&url[..])); assert_eq!(origin.pushurl(), None); { let mut specs = origin.refspecs(); let spec = specs.next().unwrap(); assert!(specs.next().is_none()); assert_eq!(spec.str(), Some("+refs/heads/*:refs/remotes/origin/*")); assert_eq!(spec.dst(), Some("refs/remotes/origin/*")); assert_eq!(spec.src(), Some("refs/heads/*")); assert!(spec.is_force()); } assert!(origin.refspecs().next_back().is_some()); { let remotes = repo.remotes().unwrap(); assert_eq!(remotes.len(), 1); assert_eq!(remotes.get(0), Some("origin")); assert_eq!(remotes.iter().count(), 1); assert_eq!(remotes.iter().next().unwrap(), Some("origin")); } origin.connect(Direction::Push).unwrap(); assert!(origin.connected()); origin.disconnect(); origin.connect(Direction::Fetch).unwrap(); assert!(origin.connected()); origin.download(&[], None).unwrap(); origin.disconnect(); origin.fetch(&[], None, None).unwrap(); origin.fetch(&[], None, Some("foo")).unwrap(); origin.update_tips(None, true, AutotagOption::Unspecified, None).unwrap(); origin.update_tips(None, true, AutotagOption::All, Some("foo")).unwrap(); t!(repo.remote_add_fetch("origin", "foo")); t!(repo.remote_add_fetch("origin", "bar")); } #[test] fn rename_remote() { let (_td, repo) = ::test::repo_init(); repo.remote("origin", "foo").unwrap(); repo.remote_rename("origin", "foo").unwrap(); repo.remote_delete("foo").unwrap(); } #[test] fn create_remote_anonymous() { let td = TempDir::new("test").unwrap(); let repo = Repository::init(td.path()).unwrap(); let origin = repo.remote_anonymous("/path/to/nowhere").unwrap(); assert_eq!(origin.name(), None); drop(origin.clone()); } #[test] fn is_valid() { assert!(Remote::is_valid_name("foobar")); assert!(!Remote::is_valid_name("\x01")); } #[test] fn transfer_cb() { let (td, _repo) = ::test::repo_init(); let td2 = TempDir::new("git").unwrap(); let url = ::test::path2url(&td.path()); let repo = Repository::init(td2.path()).unwrap(); let progress_hit = Cell::new(false); { let mut callbacks = RemoteCallbacks::new(); let mut origin = repo.remote("origin", &url).unwrap(); callbacks.transfer_progress(|_progress| { progress_hit.set(true); true }); origin.fetch(&[], Some(FetchOptions::new().remote_callbacks(callbacks)), None).unwrap(); let list = t!(origin.list()); assert_eq!(list.len(), 2); assert_eq!(list[0].name(), "HEAD"); assert!(!list[0].is_local()); assert_eq!(list[1].name(), "refs/heads/master"); assert!(!list[1].is_local()); } assert!(progress_hit.get()); } #[test] fn push() { let (_td, repo) = ::test::repo_init(); let td2 = TempDir::new("git1").unwrap(); let td3 = TempDir::new("git2").unwrap(); let url = ::test::path2url(&td2.path()); Repository::init_bare(td2.path()).unwrap(); // git push let mut remote = repo.remote("origin", &url).unwrap(); remote.push(&["refs/heads/master"], None).unwrap(); let repo = Repository::clone(&url, td3.path()).unwrap(); let commit = repo.head().unwrap().target().unwrap(); let commit = repo.find_commit(commit).unwrap(); assert_eq!(commit.message(), Some("initial")); } } deps/git2-0.3.3/src/time.rs0000664000175000017500000000340412563210063012331 0ustar use libc::c_int; use raw; use util::Binding; /// Time in a signature #[derive(Copy, Clone, Eq, PartialEq)] pub struct Time { raw: raw::git_time, } /// Time structure used in a git index entry. #[derive(Copy, Clone, Eq, PartialEq)] pub struct IndexTime { raw: raw::git_index_time, } impl Time { /// Creates a new time structure from its components. pub fn new(time: i64, offset: i32) -> Time { unsafe { Binding::from_raw(raw::git_time { time: time as raw::git_time_t, offset: offset as c_int, }) } } /// Return the time, in seconds, from epoch pub fn seconds(&self) -> i64 { self.raw.time as i64 } /// Return the timezone offset, in minutes pub fn offset_minutes(&self) -> i32 { self.raw.offset as i32 } } impl Binding for Time { type Raw = raw::git_time; unsafe fn from_raw(raw: raw::git_time) -> Time { Time { raw: raw } } fn raw(&self) -> raw::git_time { self.raw } } impl IndexTime { /// Creates a new time structure from its components. pub fn new(seconds: i32, nanoseconds: u32) -> IndexTime { unsafe { Binding::from_raw(raw::git_index_time { seconds: seconds, nanoseconds: nanoseconds, }) } } /// Returns the number of seconds in the second component of this time. pub fn seconds(&self) -> i32 { self.raw.seconds } /// Returns the nanosecond component of this time. pub fn nanoseconds(&self) -> u32 { self.raw.nanoseconds } } impl Binding for IndexTime { type Raw = raw::git_index_time; unsafe fn from_raw(raw: raw::git_index_time) -> IndexTime { IndexTime { raw: raw } } fn raw(&self) -> raw::git_index_time { self.raw } } deps/git2-0.3.3/src/treebuilder.rs0000664000175000017500000001435712617154611013720 0ustar use std::marker; use libc::{c_int, c_void}; use {panic, raw, tree, Error, Oid, Repository, TreeEntry}; use util::{Binding, IntoCString}; /// Constructor for in-memory trees pub struct TreeBuilder<'repo> { raw: *mut raw::git_treebuilder, _marker: marker::PhantomData<&'repo Repository>, } impl<'repo> TreeBuilder<'repo> { /// Clear all the entries in the builder pub fn clear(&mut self) { unsafe { raw::git_treebuilder_clear(self.raw) } } /// Get the number of entries pub fn len(&self) -> usize { unsafe { raw::git_treebuilder_entrycount(self.raw) as usize } } /// Get en entry from the builder from its filename pub fn get

    (&self, filename: P) -> Result, Error> where P: IntoCString { let filename = try!(filename.into_c_string()); unsafe { let ret = raw::git_treebuilder_get(self.raw, filename.as_ptr()); if ret.is_null() { Ok(None) } else { Ok(Some(tree::entry_from_raw_const(ret))) } } } /// Add or update an entry in the builder /// /// No attempt is made to ensure that the provided Oid points to /// an object of a reasonable type (or any object at all). /// /// The mode given must be one of 0o040000, 0o100644, 0o100755, 0o120000 or /// 0o160000 currently. pub fn insert(&mut self, filename: P, oid: Oid, filemode: i32) -> Result { let filename = try!(filename.into_c_string()); let filemode = filemode as raw::git_filemode_t; let mut ret = 0 as *const raw::git_tree_entry; unsafe { try_call!(raw::git_treebuilder_insert(&mut ret, self.raw, filename, oid.raw(), filemode)); Ok(tree::entry_from_raw_const(ret)) } } /// Remove an entry from the builder by its filename pub fn remove(&mut self, filename: P) -> Result<(), Error> { let filename = try!(filename.into_c_string()); unsafe { try_call!(raw::git_treebuilder_remove(self.raw, filename)); } Ok(()) } /// Selectively remove entries from the tree /// /// Values for which the filter returns `true` will be kept. Note /// that this behavior is different from the libgit2 C interface. pub fn filter(&mut self, mut filter: F) where F: FnMut(&TreeEntry) -> bool { let mut cb: &mut FilterCb = &mut filter; let ptr = &mut cb as *mut _; unsafe { raw::git_treebuilder_filter(self.raw, filter_cb, ptr as *mut _); panic::check(); } } /// Write the contents of the TreeBuilder as a Tree object and /// return its Oid pub fn write(&self) -> Result { let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; unsafe { try_call!(raw::git_treebuilder_write(&mut raw, self.raw())); Ok(Binding::from_raw(&raw as *const _)) } } } type FilterCb<'a> = FnMut(&TreeEntry) -> bool + 'a; wrap_env! { fn filter_cb(entry: *const raw::git_tree_entry, payload: *mut c_void) -> c_int { unsafe { // There's no way to return early from git_treebuilder_filter. if panic::panicked() { true } else { let entry = tree::entry_from_raw_const(entry); let payload = payload as *mut &mut FilterCb; (*payload)(&entry) } } } returning ret as if ret == Some(false) { 1 } else { 0 } } impl<'repo> Binding for TreeBuilder<'repo> { type Raw = *mut raw::git_treebuilder; unsafe fn from_raw(raw: *mut raw::git_treebuilder) -> TreeBuilder<'repo> { TreeBuilder { raw: raw, _marker: marker::PhantomData } } fn raw(&self) -> *mut raw::git_treebuilder { self.raw } } impl<'repo> Drop for TreeBuilder<'repo> { fn drop(&mut self) { unsafe { raw::git_treebuilder_free(self.raw) } } } #[cfg(test)] mod tests { use ObjectType; #[test] fn smoke() { let (_td, repo) = ::test::repo_init(); let mut builder = repo.treebuilder(None).unwrap(); assert_eq!(builder.len(), 0); let blob = repo.blob(b"data").unwrap(); { let entry = builder.insert("a", blob, 0o100644).unwrap(); assert_eq!(entry.kind(), Some(ObjectType::Blob)); } builder.insert("b", blob, 0o100644).unwrap(); assert_eq!(builder.len(), 2); builder.remove("a").unwrap(); assert_eq!(builder.len(), 1); assert_eq!(builder.get("b").unwrap().unwrap().id(), blob); builder.clear(); assert_eq!(builder.len(), 0); } #[test] fn write() { let (_td, repo) = ::test::repo_init(); let mut builder = repo.treebuilder(None).unwrap(); let data = repo.blob(b"data").unwrap(); builder.insert("name", data, 0o100644).unwrap(); let tree = builder.write().unwrap(); let tree = repo.find_tree(tree).unwrap(); let entry = tree.get(0).unwrap(); assert_eq!(entry.name(), Some("name")); let blob = entry.to_object(&repo).unwrap(); let blob = blob.as_blob().unwrap(); assert_eq!(blob.content(), b"data"); let builder = repo.treebuilder(Some(&tree)).unwrap(); assert_eq!(builder.len(), 1); } #[test] fn filter() { let (_td, repo) = ::test::repo_init(); let mut builder = repo.treebuilder(None).unwrap(); let blob = repo.blob(b"data").unwrap(); let tree = { let head = repo.head().unwrap() .peel(ObjectType::Commit).unwrap(); let head = head.as_commit().unwrap(); head.tree_id() }; builder.insert("blob", blob, 0o100644).unwrap(); builder.insert("dir", tree, 0o040000).unwrap(); builder.insert("dir2", tree, 0o040000).unwrap(); builder.filter(|_| true); assert_eq!(builder.len(), 3); builder.filter(|e| e.kind().unwrap() != ObjectType::Blob); assert_eq!(builder.len(), 2); builder.filter(|_| false); assert_eq!(builder.len(), 0); } } deps/git2-0.3.3/src/status.rs0000664000175000017500000003375612517471774012754 0ustar use std::ffi::CString; use std::ops::Range; use std::marker; use std::mem; use std::str; use libc::{c_char, size_t, c_uint}; use {raw, Status, DiffDelta, IntoCString, Repository}; use util::Binding; /// Options that can be provided to `repo.statuses()` to control how the status /// information is gathered. pub struct StatusOptions { raw: raw::git_status_options, pathspec: Vec, ptrs: Vec<*const c_char>, } /// Enumeration of possible methods of what can be shown through a status /// operation. #[derive(Copy, Clone)] pub enum StatusShow { /// Only gives status based on HEAD to index comparison, not looking at /// working directory changes. Index, /// Only gives status based on index to working directory comparison, not /// comparing the index to the HEAD. Workdir, /// The default, this roughly matches `git status --porcelain` regarding /// which files are included and in what order. IndexAndWorkdir, } /// A container for a list of status information about a repository. /// /// Each instances appears as a if it were a collection, having a length and /// allowing indexing as well as provding an iterator. pub struct Statuses<'repo> { raw: *mut raw::git_status_list, // Hm, not currently present, but can't hurt? _marker: marker::PhantomData<&'repo Repository>, } /// An iterator over the statuses in a `Statuses` instance. pub struct StatusIter<'statuses> { statuses: &'statuses Statuses<'statuses>, range: Range, } /// A structure representing an entry in the `Statuses` structure. /// /// Instances are created through the `.iter()` method or the `.get()` method. pub struct StatusEntry<'statuses> { raw: *const raw::git_status_entry, _marker: marker::PhantomData<&'statuses DiffDelta<'statuses>>, } impl StatusOptions { /// Creates a new blank set of status options. pub fn new() -> StatusOptions { unsafe { let mut raw = mem::zeroed(); let r = raw::git_status_init_options(&mut raw, raw::GIT_STATUS_OPTIONS_VERSION); assert_eq!(r, 0); StatusOptions { raw: raw, pathspec: Vec::new(), ptrs: Vec::new(), } } } /// Select the files on which to report status. /// /// The default, if unspecified, is to show the index and the working /// directory. pub fn show(&mut self, show: StatusShow) -> &mut StatusOptions { self.raw.show = match show { StatusShow::Index => raw::GIT_STATUS_SHOW_INDEX_ONLY, StatusShow::Workdir => raw::GIT_STATUS_SHOW_WORKDIR_ONLY, StatusShow::IndexAndWorkdir => raw::GIT_STATUS_SHOW_INDEX_AND_WORKDIR, }; self } /// Add a path pattern to match (using fnmatch-style matching). /// /// If the `disable_pathspec_match` option is given, then this is a literal /// path to match. If this is not called, then there will be no patterns to /// match and the entire directory will be used. pub fn pathspec(&mut self, pathspec: T) -> &mut StatusOptions { let s = pathspec.into_c_string().unwrap(); self.ptrs.push(s.as_ptr()); self.pathspec.push(s); self } fn flag(&mut self, flag: raw::git_status_opt_t, val: bool) -> &mut StatusOptions { if val { self.raw.flags |= flag as c_uint; } else { self.raw.flags &= !(flag as c_uint); } self } /// Flag whether untracked files will be included. /// /// Untracked files will only be included if the workdir files are included /// in the status "show" option. pub fn include_untracked(&mut self, include: bool) -> &mut StatusOptions { self.flag(raw::GIT_STATUS_OPT_INCLUDE_UNTRACKED, include) } /// Flag whether ignored files will be included. /// /// The files will only be included if the workdir files are included /// in the status "show" option. pub fn include_ignored(&mut self, include: bool) -> &mut StatusOptions { self.flag(raw::GIT_STATUS_OPT_INCLUDE_IGNORED, include) } /// Flag to include unmodified files. pub fn include_unmodified(&mut self, include: bool) -> &mut StatusOptions { self.flag(raw::GIT_STATUS_OPT_INCLUDE_UNMODIFIED, include) } /// Flag that submodules should be skipped. /// /// This only applies if there are no pending typechanges to the submodule /// (either from or to another type). pub fn exclude_submodules(&mut self, exclude: bool) -> &mut StatusOptions { self.flag(raw::GIT_STATUS_OPT_EXCLUDE_SUBMODULES, exclude) } /// Flag that all files in untracked directories should be included. /// /// Normally if an entire directory is new then just the top-level directory /// is included (with a trailing slash on the entry name). pub fn recurse_untracked_dirs(&mut self, include: bool) -> &mut StatusOptions { self.flag(raw::GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS, include) } /// Indicates that the given paths should be treated as literals paths, note /// patterns. pub fn disable_pathspec_match(&mut self, include: bool) -> &mut StatusOptions { self.flag(raw::GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH, include) } /// Indicates that the contents of ignored directories should be included in /// the status. pub fn recurse_ignored_dirs(&mut self, include: bool) -> &mut StatusOptions { self.flag(raw::GIT_STATUS_OPT_RECURSE_IGNORED_DIRS, include) } /// Indicates that rename detection should be processed between the head. pub fn renames_head_to_index(&mut self, include: bool) -> &mut StatusOptions { self.flag(raw::GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX, include) } /// Indicates that rename detection should be run between the index and the /// working directory. pub fn renames_index_to_workdir(&mut self, include: bool) -> &mut StatusOptions { self.flag(raw::GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR, include) } /// Override the native case sensitivity for the file system and force the /// output to be in case sensitive order. pub fn sort_case_sensitively(&mut self, include: bool) -> &mut StatusOptions { self.flag(raw::GIT_STATUS_OPT_SORT_CASE_SENSITIVELY, include) } /// Override the native case sensitivity for the file system and force the /// output to be in case-insensitive order. pub fn sort_case_insensitively(&mut self, include: bool) -> &mut StatusOptions { self.flag(raw::GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY, include) } /// Indicates that rename detection should include rewritten files. pub fn renames_from_rewrites(&mut self, include: bool) -> &mut StatusOptions { self.flag(raw::GIT_STATUS_OPT_RENAMES_FROM_REWRITES, include) } /// Bypasses the default status behavior of doing a "soft" index reload. pub fn no_refresh(&mut self, include: bool) -> &mut StatusOptions { self.flag(raw::GIT_STATUS_OPT_NO_REFRESH, include) } /// Refresh the stat cache in the index for files are unchanged but have /// out of date stat information in the index. /// /// This will result in less work being done on subsequent calls to fetching /// the status. pub fn update_index(&mut self, include: bool) -> &mut StatusOptions { self.flag(raw::GIT_STATUS_OPT_UPDATE_INDEX, include) } // erm... #[allow(missing_docs)] pub fn include_unreadable(&mut self, include: bool) -> &mut StatusOptions { self.flag(raw::GIT_STATUS_OPT_INCLUDE_UNREADABLE, include) } // erm... #[allow(missing_docs)] pub fn include_unreadable_as_untracked(&mut self, include: bool) -> &mut StatusOptions { self.flag(raw::GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED, include) } /// Get a pointer to the inner list of status options. /// /// This function is unsafe as the returned structure has interior pointers /// and may no longer be valid if these options continue to be mutated. pub unsafe fn raw(&mut self) -> *const raw::git_status_options { self.raw.pathspec.strings = self.ptrs.as_ptr() as *mut _; self.raw.pathspec.count = self.ptrs.len() as size_t; &self.raw } } impl<'repo> Statuses<'repo> { /// Gets a status entry from this list at the specified index. /// /// Returns `None` if the index is out of bounds. pub fn get(&self, index: usize) -> Option { unsafe { let p = raw::git_status_byindex(self.raw, index as size_t); Binding::from_raw_opt(p) } } /// Gets the count of status entries in this list. /// /// If there are no changes in status (at least according the options given /// when the status list was created), this can return 0. pub fn len(&self) -> usize { unsafe { raw::git_status_list_entrycount(self.raw) as usize } } /// Returns an iterator over the statuses in this list. pub fn iter(&self) -> StatusIter { StatusIter { statuses: self, range: 0..self.len(), } } } impl<'repo> Binding for Statuses<'repo> { type Raw = *mut raw::git_status_list; unsafe fn from_raw(raw: *mut raw::git_status_list) -> Statuses<'repo> { Statuses { raw: raw, _marker: marker::PhantomData } } fn raw(&self) -> *mut raw::git_status_list { self.raw } } impl<'repo> Drop for Statuses<'repo> { fn drop(&mut self) { unsafe { raw::git_status_list_free(self.raw); } } } impl<'a> Iterator for StatusIter<'a> { type Item = StatusEntry<'a>; fn next(&mut self) -> Option> { self.range.next().and_then(|i| self.statuses.get(i)) } fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } } impl<'a> DoubleEndedIterator for StatusIter<'a> { fn next_back(&mut self) -> Option> { self.range.next_back().and_then(|i| self.statuses.get(i)) } } impl<'a> ExactSizeIterator for StatusIter<'a> {} impl<'statuses> StatusEntry<'statuses> { /// Access the bytes for this entry's corresponding pathname pub fn path_bytes(&self) -> &[u8] { unsafe { if (*self.raw).head_to_index.is_null() { ::opt_bytes(self, (*(*self.raw).index_to_workdir).old_file.path) } else { ::opt_bytes(self, (*(*self.raw).head_to_index).old_file.path) }.unwrap() } } /// Access this entry's path name as a string. /// /// Returns `None` if the path is not valid utf-8. pub fn path(&self) -> Option<&str> { str::from_utf8(self.path_bytes()).ok() } /// Access the status flags for this file pub fn status(&self) -> Status { Status::from_bits_truncate(unsafe { (*self.raw).status as u32 }) } /// Access detailed information about the differences between the file in /// HEAD and the file in the index. pub fn head_to_index(&self) -> Option> { unsafe { Binding::from_raw_opt((*self.raw).head_to_index) } } /// Access detailed information about the differences between the file in /// the index and the file in the working directory. pub fn index_to_workdir(&self) -> Option> { unsafe { Binding::from_raw_opt((*self.raw).index_to_workdir) } } } impl<'statuses> Binding for StatusEntry<'statuses> { type Raw = *const raw::git_status_entry; unsafe fn from_raw(raw: *const raw::git_status_entry) -> StatusEntry<'statuses> { StatusEntry { raw: raw, _marker: marker::PhantomData } } fn raw(&self) -> *const raw::git_status_entry { self.raw } } #[cfg(test)] mod tests { use std::fs::File; use std::path::Path; use std::io::prelude::*; use super::StatusOptions; #[test] fn smoke() { let (td, repo) = ::test::repo_init(); assert_eq!(repo.statuses(None).unwrap().len(), 0); File::create(&td.path().join("foo")).unwrap(); let statuses = repo.statuses(None).unwrap(); assert_eq!(statuses.iter().count(), 1); let status = statuses.iter().next().unwrap(); assert_eq!(status.path(), Some("foo")); assert!(status.status().contains(::STATUS_WT_NEW)); assert!(!status.status().contains(::STATUS_INDEX_NEW)); assert!(status.head_to_index().is_none()); let diff = status.index_to_workdir().unwrap(); assert_eq!(diff.old_file().path_bytes().unwrap(), b"foo"); assert_eq!(diff.new_file().path_bytes().unwrap(), b"foo"); } #[test] fn filter() { let (td, repo) = ::test::repo_init(); t!(File::create(&td.path().join("foo"))); t!(File::create(&td.path().join("bar"))); let mut opts = StatusOptions::new(); opts.include_untracked(true) .pathspec("foo"); let statuses = t!(repo.statuses(Some(&mut opts))); assert_eq!(statuses.iter().count(), 1); let status = statuses.iter().next().unwrap(); assert_eq!(status.path(), Some("foo")); } #[test] fn gitignore() { let (td, repo) = ::test::repo_init(); t!(t!(File::create(td.path().join(".gitignore"))).write_all(b"foo\n")); assert!(!t!(repo.status_should_ignore(Path::new("bar")))); assert!(t!(repo.status_should_ignore(Path::new("foo")))); } #[test] fn status_file() { let (td, repo) = ::test::repo_init(); assert!(repo.status_file(Path::new("foo")).is_err()); t!(File::create(td.path().join("foo"))); let status = t!(repo.status_file(Path::new("foo"))); assert!(status.contains(::STATUS_WT_NEW)); } } deps/git2-0.3.3/appveyor.yml0000664000175000017500000000140112607371460012631 0ustar environment: matrix: - TARGET: x86_64-pc-windows-gnu MSYS_BITS: 64 - TARGET: i686-pc-windows-gnu MSYS_BITS: 32 - TARGET: x86_64-pc-windows-msvc - TARGET: i686-pc-windows-msvc install: - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - set PATH=%PATH%;C:\Program Files (x86)\Rust\bin - if defined MSYS_BITS set PATH=%PATH%;C:\msys64\mingw%MSYS_BITS%\bin;C:\msys64\usr\bin - set CARGO_TARGET_DIR=%APPVEYOR_BUILD_FOLDER%\target - rustc -V - cargo -V - git submodule update --init build: false test_script: - cargo test - cargo test --no-default-features - cargo run --manifest-path systest/Cargo.toml deps/git2-0.3.3/Cargo.toml0000664000175000017500000000146312623211322012165 0ustar [package] name = "git2" version = "0.3.3" authors = ["Alex Crichton "] license = "MIT/Apache-2.0" readme = "README.md" keywords = ["git"] repository = "https://github.com/alexcrichton/git2-rs" homepage = "https://github.com/alexcrichton/git2-rs" documentation = "http://alexcrichton.com/git2-rs" description = """ Bindings to libgit2 for interoperating with git repositories. This library is both threadsafe and memory safe and allows both reading and writing git repositories. """ [dependencies] url = "0.2" bitflags = "0.1" libc = "0.2" libgit2-sys = { path = "libgit2-sys", version = "0.3.3" } [dev-dependencies] docopt = "0.6" rustc-serialize = "0.3" time = "0.1" tempdir = "0.3" [features] unstable = [] default = ["ssh", "https"] ssh = ["libgit2-sys/ssh"] https = ["libgit2-sys/https"] deps/git2-0.3.3/.gitmodules0000664000175000017500000000015012517471774012427 0ustar [submodule "libgit2-sys/libgit2"] path = libgit2-sys/libgit2 url = https://github.com/libgit2/libgit2 deps/winapi-0.2.5/0000755000000000000000000000000012666635521012452 5ustar rootrootdeps/winapi-0.2.5/.travis.yml0000644000000000000000000000054712566431667014575 0ustar rootrootlanguage: rust sudo: false script: - cargo build - cargo package - cargo test - cargo doc notifications: email: false webhooks: - https://webhooks.gitter.im/e/295a1e640ebd30d63457 irc: channels: - "irc.mozilla.org#winapi" template: - "%{repository_slug}/%{branch} (%{commit} - %{author}): %{message}" skip_join: true deps/winapi-0.2.5/README.md0000644000000000000000000014347512617157061013741 0ustar rootroot# winapi-rs [![Build status](https://ci.appveyor.com/api/projects/status/i47oonf5e7qm5utq/branch/master?svg=true)](https://ci.appveyor.com/project/retep998/winapi-rs/branch/master) [![Build Status](https://travis-ci.org/retep998/winapi-rs.svg?branch=master)](https://travis-ci.org/retep998/winapi-rs) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/retep998/winapi-rs) [![Crates.io](https://img.shields.io/crates/v/winapi.svg)](https://crates.io/crates/winapi) # [Documentation](https://retep998.github.io/doc/winapi/) Official IRC channel: #winapi on [Mozilla IRC](https://wiki.mozilla.org/IRC) This crate provides types and constants for WinAPI FFI bindings. They are gathered by hand using the Windows 8.1 SDK from Microsoft. I aim to replace all existing Windows FFI in other crates with this set of crates through the "[Embrace, extend, and extinguish](http://en.wikipedia.org/wiki/Embrace,_extend_and_extinguish)" technique. If this crate is missing something you need, feel free to create an issue, open a pull request, or contact me via [other means](http://www.rustaceans.org/retep998). As of version 0.2, this crate depends on Rust 1.1 (in order to lose the dependency on libc). If you need compatibility with Rust 1.0 you must continue to use older 0.1.x versions. ## Example ## Cargo.toml: ```toml [dependencies] winapi = "0.2" winmm-sys = "0.1" ``` example.rs: ```Rust extern crate winapi; extern crate winmm; fn func() { winmm::PlaySoundA(...); } ``` ## Functions ## Bindings to library functions are in separate crates. The source to each crate is in the relevant subdirectory under the `lib` directory. ### Usable crates ### These are the ones that actually have functions in them: * [advapi32-sys ![Crates.io](https://img.shields.io/crates/v/advapi32-sys.svg)](https://crates.io/crates/advapi32-sys) * [crypt32-sys ![Crates.io](https://img.shields.io/crates/v/crypt32-sys.svg)](https://crates.io/crates/crypt32-sys) * [d3d9-sys ![Crates.io](https://img.shields.io/crates/v/d3d9-sys.svg)](https://crates.io/crates/d3d9-sys) * [d3d11-sys ![Crates.io](https://img.shields.io/crates/v/d3d11-sys.svg)](https://crates.io/crates/d3d11-sys) * [dbghelp-sys ![Crates.io](https://img.shields.io/crates/v/dbghelp-sys.svg)](https://crates.io/crates/dbghelp-sys) * [dsound-sys ![Crates.io](https://img.shields.io/crates/v/dsound-sys.svg)](https://crates.io/crates/dsound-sys) * [dwmapi-sys ![Crates.io](https://img.shields.io/crates/v/dwmapi-sys.svg)](https://crates.io/crates/dwmapi-sys) * [gdi32-sys ![Crates.io](https://img.shields.io/crates/v/gdi32-sys.svg)](https://crates.io/crates/gdi32-sys) * [kernel32-sys ![Crates.io](https://img.shields.io/crates/v/kernel32-sys.svg)](https://crates.io/crates/kernel32-sys) * [ktmw32-sys ![Crates.io](https://img.shields.io/crates/v/ktmw32-sys.svg)](https://crates.io/crates/ktmw32-sys) * [mpr-sys ![Crates.io](https://img.shields.io/crates/v/mpr-sys.svg)](https://crates.io/crates/mpr-sys) * [ole32-sys ![Crates.io](https://img.shields.io/crates/v/ole32-sys.svg)](https://crates.io/crates/ole32-sys) * [oleaut32-sys ![Crates.io](https://img.shields.io/crates/v/oleaut32-sys.svg)](https://crates.io/crates/oleaut32-sys) * [opengl32-sys ![Crates.io](https://img.shields.io/crates/v/opengl32-sys.svg)](https://crates.io/crates/opengl32-sys) * [psapi-sys ![Crates.io](https://img.shields.io/crates/v/psapi-sys.svg)](https://crates.io/crates/psapi-sys) * [secur32-sys ![Crates.io](https://img.shields.io/crates/v/secur32-sys.svg)](https://crates.io/crates/secur32-sys) * [shell32-sys ![Crates.io](https://img.shields.io/crates/v/shell32-sys.svg)](https://crates.io/crates/shell32-sys) * [user32-sys ![Crates.io](https://img.shields.io/crates/v/user32-sys.svg)](https://crates.io/crates/user32-sys) * [uuid-sys ![Crates.io](https://img.shields.io/crates/v/uuid-sys.svg)](https://crates.io/crates/uuid-sys) * [vssapi-sys ![Crates.io](https://img.shields.io/crates/v/vssapi-sys.svg)](https://crates.io/crates/vssapi-sys) * [winmm-sys ![Crates.io](https://img.shields.io/crates/v/winmm-sys.svg)](https://crates.io/crates/winmm-sys) * [ws2_32-sys ![Crates.io](https://img.shields.io/crates/v/ws2_32-sys.svg)](https://crates.io/crates/ws2_32-sys) * [xinput-sys ![Crates.io](https://img.shields.io/crates/v/xinput-sys.svg)](https://crates.io/crates/xinput-sys) ### Reserved crates ### These are the ones that are reserved for future use: * [aclui-sys ![Crates.io](https://img.shields.io/crates/v/aclui-sys.svg)](https://crates.io/crates/aclui-sys) * [activeds-sys ![Crates.io](https://img.shields.io/crates/v/activeds-sys.svg)](https://crates.io/crates/activeds-sys) * [adsiid-sys ![Crates.io](https://img.shields.io/crates/v/adsiid-sys.svg)](https://crates.io/crates/adsiid-sys) * [advpack-sys ![Crates.io](https://img.shields.io/crates/v/advpack-sys.svg)](https://crates.io/crates/advpack-sys) * [ahadmin-sys ![Crates.io](https://img.shields.io/crates/v/ahadmin-sys.svg)](https://crates.io/crates/ahadmin-sys) * [alink-sys ![Crates.io](https://img.shields.io/crates/v/alink-sys.svg)](https://crates.io/crates/alink-sys) * [amstrmid-sys ![Crates.io](https://img.shields.io/crates/v/amstrmid-sys.svg)](https://crates.io/crates/amstrmid-sys) * [api-ms-win-net-isolation-l1-1-0-sys ![Crates.io](https://img.shields.io/crates/v/api-ms-win-net-isolation-l1-1-0-sys.svg)](https://crates.io/crates/api-ms-win-net-isolation-l1-1-0-sys) * [apidll-sys ![Crates.io](https://img.shields.io/crates/v/apidll-sys.svg)](https://crates.io/crates/apidll-sys) * [appmgmts-sys ![Crates.io](https://img.shields.io/crates/v/appmgmts-sys.svg)](https://crates.io/crates/appmgmts-sys) * [appmgr-sys ![Crates.io](https://img.shields.io/crates/v/appmgr-sys.svg)](https://crates.io/crates/appmgr-sys) * [appnotify-sys ![Crates.io](https://img.shields.io/crates/v/appnotify-sys.svg)](https://crates.io/crates/appnotify-sys) * [asycfilt-sys ![Crates.io](https://img.shields.io/crates/v/asycfilt-sys.svg)](https://crates.io/crates/asycfilt-sys) * [audiobaseprocessingobject-sys ![Crates.io](https://img.shields.io/crates/v/audiobaseprocessingobject-sys.svg)](https://crates.io/crates/audiobaseprocessingobject-sys) * [audioeng-sys ![Crates.io](https://img.shields.io/crates/v/audioeng-sys.svg)](https://crates.io/crates/audioeng-sys) * [audiomediatypecrt-sys ![Crates.io](https://img.shields.io/crates/v/audiomediatypecrt-sys.svg)](https://crates.io/crates/audiomediatypecrt-sys) * [authz-sys ![Crates.io](https://img.shields.io/crates/v/authz-sys.svg)](https://crates.io/crates/authz-sys) * [aux_ulib-sys ![Crates.io](https://img.shields.io/crates/v/aux_ulib-sys.svg)](https://crates.io/crates/aux_ulib-sys) * [avifil32-sys ![Crates.io](https://img.shields.io/crates/v/avifil32-sys.svg)](https://crates.io/crates/avifil32-sys) * [avrt-sys ![Crates.io](https://img.shields.io/crates/v/avrt-sys.svg)](https://crates.io/crates/avrt-sys) * [basesrv-sys ![Crates.io](https://img.shields.io/crates/v/basesrv-sys.svg)](https://crates.io/crates/basesrv-sys) * [bcrypt-sys ![Crates.io](https://img.shields.io/crates/v/bcrypt-sys.svg)](https://crates.io/crates/bcrypt-sys) * [bits-sys ![Crates.io](https://img.shields.io/crates/v/bits-sys.svg)](https://crates.io/crates/bits-sys) * [bluetoothapis-sys ![Crates.io](https://img.shields.io/crates/v/bluetoothapis-sys.svg)](https://crates.io/crates/bluetoothapis-sys) * [bthprops-sys ![Crates.io](https://img.shields.io/crates/v/bthprops-sys.svg)](https://crates.io/crates/bthprops-sys) * [bufferoverflow-sys ![Crates.io](https://img.shields.io/crates/v/bufferoverflow-sys.svg)](https://crates.io/crates/bufferoverflow-sys) * [bufferoverflowu-sys ![Crates.io](https://img.shields.io/crates/v/bufferoverflowu-sys.svg)](https://crates.io/crates/bufferoverflowu-sys) * [cabinet-sys ![Crates.io](https://img.shields.io/crates/v/cabinet-sys.svg)](https://crates.io/crates/cabinet-sys) * [certadm-sys ![Crates.io](https://img.shields.io/crates/v/certadm-sys.svg)](https://crates.io/crates/certadm-sys) * [certca-sys ![Crates.io](https://img.shields.io/crates/v/certca-sys.svg)](https://crates.io/crates/certca-sys) * [certcli-sys ![Crates.io](https://img.shields.io/crates/v/certcli-sys.svg)](https://crates.io/crates/certcli-sys) * [certidl-sys ![Crates.io](https://img.shields.io/crates/v/certidl-sys.svg)](https://crates.io/crates/certidl-sys) * [certpoleng-sys ![Crates.io](https://img.shields.io/crates/v/certpoleng-sys.svg)](https://crates.io/crates/certpoleng-sys) * [cfgmgr32-sys ![Crates.io](https://img.shields.io/crates/v/cfgmgr32-sys.svg)](https://crates.io/crates/cfgmgr32-sys) * [clfsmgmt-sys ![Crates.io](https://img.shields.io/crates/v/clfsmgmt-sys.svg)](https://crates.io/crates/clfsmgmt-sys) * [clfsw32-sys ![Crates.io](https://img.shields.io/crates/v/clfsw32-sys.svg)](https://crates.io/crates/clfsw32-sys) * [clusapi-sys ![Crates.io](https://img.shields.io/crates/v/clusapi-sys.svg)](https://crates.io/crates/clusapi-sys) * [comctl32-sys ![Crates.io](https://img.shields.io/crates/v/comctl32-sys.svg)](https://crates.io/crates/comctl32-sys) * [comdlg32-sys ![Crates.io](https://img.shields.io/crates/v/comdlg32-sys.svg)](https://crates.io/crates/comdlg32-sys) * [comppkgsup-sys ![Crates.io](https://img.shields.io/crates/v/comppkgsup-sys.svg)](https://crates.io/crates/comppkgsup-sys) * [compstui-sys ![Crates.io](https://img.shields.io/crates/v/compstui-sys.svg)](https://crates.io/crates/compstui-sys) * [comsvcs-sys ![Crates.io](https://img.shields.io/crates/v/comsvcs-sys.svg)](https://crates.io/crates/comsvcs-sys) * [corguids-sys ![Crates.io](https://img.shields.io/crates/v/corguids-sys.svg)](https://crates.io/crates/corguids-sys) * [correngine-sys ![Crates.io](https://img.shields.io/crates/v/correngine-sys.svg)](https://crates.io/crates/correngine-sys) * [credui-sys ![Crates.io](https://img.shields.io/crates/v/credui-sys.svg)](https://crates.io/crates/credui-sys) * [cryptdll-sys ![Crates.io](https://img.shields.io/crates/v/cryptdll-sys.svg)](https://crates.io/crates/cryptdll-sys) * [cryptnet-sys ![Crates.io](https://img.shields.io/crates/v/cryptnet-sys.svg)](https://crates.io/crates/cryptnet-sys) * [cryptui-sys ![Crates.io](https://img.shields.io/crates/v/cryptui-sys.svg)](https://crates.io/crates/cryptui-sys) * [cryptxml-sys ![Crates.io](https://img.shields.io/crates/v/cryptxml-sys.svg)](https://crates.io/crates/cryptxml-sys) * [cscapi-sys ![Crates.io](https://img.shields.io/crates/v/cscapi-sys.svg)](https://crates.io/crates/cscapi-sys) * [cscdll-sys ![Crates.io](https://img.shields.io/crates/v/cscdll-sys.svg)](https://crates.io/crates/cscdll-sys) * [d2d1-sys ![Crates.io](https://img.shields.io/crates/v/d2d1-sys.svg)](https://crates.io/crates/d2d1-sys) * [d3d10-sys ![Crates.io](https://img.shields.io/crates/v/d3d10-sys.svg)](https://crates.io/crates/d3d10-sys) * [d3d10_1-sys ![Crates.io](https://img.shields.io/crates/v/d3d10_1-sys.svg)](https://crates.io/crates/d3d10_1-sys) * [d3dcompiler-sys ![Crates.io](https://img.shields.io/crates/v/d3dcompiler-sys.svg)](https://crates.io/crates/d3dcompiler-sys) * [d3dcsx-sys ![Crates.io](https://img.shields.io/crates/v/d3dcsx-sys.svg)](https://crates.io/crates/d3dcsx-sys) * [d3dcsxd-sys ![Crates.io](https://img.shields.io/crates/v/d3dcsxd-sys.svg)](https://crates.io/crates/d3dcsxd-sys) * [davclnt-sys ![Crates.io](https://img.shields.io/crates/v/davclnt-sys.svg)](https://crates.io/crates/davclnt-sys) * [dbgeng-sys ![Crates.io](https://img.shields.io/crates/v/dbgeng-sys.svg)](https://crates.io/crates/dbgeng-sys) * [dciman32-sys ![Crates.io](https://img.shields.io/crates/v/dciman32-sys.svg)](https://crates.io/crates/dciman32-sys) * [dcomp-sys ![Crates.io](https://img.shields.io/crates/v/dcomp-sys.svg)](https://crates.io/crates/dcomp-sys) * [ddraw-sys ![Crates.io](https://img.shields.io/crates/v/ddraw-sys.svg)](https://crates.io/crates/ddraw-sys) * [devenum-sys ![Crates.io](https://img.shields.io/crates/v/devenum-sys.svg)](https://crates.io/crates/devenum-sys) * [deviceaccess-sys ![Crates.io](https://img.shields.io/crates/v/deviceaccess-sys.svg)](https://crates.io/crates/deviceaccess-sys) * [devmgr-sys ![Crates.io](https://img.shields.io/crates/v/devmgr-sys.svg)](https://crates.io/crates/devmgr-sys) * [dflayout-sys ![Crates.io](https://img.shields.io/crates/v/dflayout-sys.svg)](https://crates.io/crates/dflayout-sys) * [dhcpcsvc-sys ![Crates.io](https://img.shields.io/crates/v/dhcpcsvc-sys.svg)](https://crates.io/crates/dhcpcsvc-sys) * [dhcpcsvc6-sys ![Crates.io](https://img.shields.io/crates/v/dhcpcsvc6-sys.svg)](https://crates.io/crates/dhcpcsvc6-sys) * [dhcpsapi-sys ![Crates.io](https://img.shields.io/crates/v/dhcpsapi-sys.svg)](https://crates.io/crates/dhcpsapi-sys) * [difxapi-sys ![Crates.io](https://img.shields.io/crates/v/difxapi-sys.svg)](https://crates.io/crates/difxapi-sys) * [dinput8-sys ![Crates.io](https://img.shields.io/crates/v/dinput8-sys.svg)](https://crates.io/crates/dinput8-sys) * [dloadhelper-sys ![Crates.io](https://img.shields.io/crates/v/dloadhelper-sys.svg)](https://crates.io/crates/dloadhelper-sys) * [dmoguids-sys ![Crates.io](https://img.shields.io/crates/v/dmoguids-sys.svg)](https://crates.io/crates/dmoguids-sys) * [dnsapi-sys ![Crates.io](https://img.shields.io/crates/v/dnsapi-sys.svg)](https://crates.io/crates/dnsapi-sys) * [dnscrcli-sys ![Crates.io](https://img.shields.io/crates/v/dnscrcli-sys.svg)](https://crates.io/crates/dnscrcli-sys) * [dnslib-sys ![Crates.io](https://img.shields.io/crates/v/dnslib-sys.svg)](https://crates.io/crates/dnslib-sys) * [dnsperf-sys ![Crates.io](https://img.shields.io/crates/v/dnsperf-sys.svg)](https://crates.io/crates/dnsperf-sys) * [dnsrpc-sys ![Crates.io](https://img.shields.io/crates/v/dnsrpc-sys.svg)](https://crates.io/crates/dnsrpc-sys) * [dnsrslvr-sys ![Crates.io](https://img.shields.io/crates/v/dnsrslvr-sys.svg)](https://crates.io/crates/dnsrslvr-sys) * [dpx-sys ![Crates.io](https://img.shields.io/crates/v/dpx-sys.svg)](https://crates.io/crates/dpx-sys) * [drt-sys ![Crates.io](https://img.shields.io/crates/v/drt-sys.svg)](https://crates.io/crates/drt-sys) * [drtprov-sys ![Crates.io](https://img.shields.io/crates/v/drtprov-sys.svg)](https://crates.io/crates/drtprov-sys) * [drttransport-sys ![Crates.io](https://img.shields.io/crates/v/drttransport-sys.svg)](https://crates.io/crates/drttransport-sys) * [dsprop-sys ![Crates.io](https://img.shields.io/crates/v/dsprop-sys.svg)](https://crates.io/crates/dsprop-sys) * [dssec-sys ![Crates.io](https://img.shields.io/crates/v/dssec-sys.svg)](https://crates.io/crates/dssec-sys) * [dststlog-sys ![Crates.io](https://img.shields.io/crates/v/dststlog-sys.svg)](https://crates.io/crates/dststlog-sys) * [dsuiext-sys ![Crates.io](https://img.shields.io/crates/v/dsuiext-sys.svg)](https://crates.io/crates/dsuiext-sys) * [dtchelp-sys ![Crates.io](https://img.shields.io/crates/v/dtchelp-sys.svg)](https://crates.io/crates/dtchelp-sys) * [dwrite-sys ![Crates.io](https://img.shields.io/crates/v/dwrite-sys.svg)](https://crates.io/crates/dwrite-sys) * [dxgi-sys ![Crates.io](https://img.shields.io/crates/v/dxgi-sys.svg)](https://crates.io/crates/dxgi-sys) * [dxguid-sys ![Crates.io](https://img.shields.io/crates/v/dxguid-sys.svg)](https://crates.io/crates/dxguid-sys) * [dxtmsft-sys ![Crates.io](https://img.shields.io/crates/v/dxtmsft-sys.svg)](https://crates.io/crates/dxtmsft-sys) * [dxtrans-sys ![Crates.io](https://img.shields.io/crates/v/dxtrans-sys.svg)](https://crates.io/crates/dxtrans-sys) * [dxva2-sys ![Crates.io](https://img.shields.io/crates/v/dxva2-sys.svg)](https://crates.io/crates/dxva2-sys) * [eappcfg-sys ![Crates.io](https://img.shields.io/crates/v/eappcfg-sys.svg)](https://crates.io/crates/eappcfg-sys) * [eappprxy-sys ![Crates.io](https://img.shields.io/crates/v/eappprxy-sys.svg)](https://crates.io/crates/eappprxy-sys) * [easregprov-sys ![Crates.io](https://img.shields.io/crates/v/easregprov-sys.svg)](https://crates.io/crates/easregprov-sys) * [efswrt-sys ![Crates.io](https://img.shields.io/crates/v/efswrt-sys.svg)](https://crates.io/crates/efswrt-sys) * [ehstorguids-sys ![Crates.io](https://img.shields.io/crates/v/ehstorguids-sys.svg)](https://crates.io/crates/ehstorguids-sys) * [elfapi-sys ![Crates.io](https://img.shields.io/crates/v/elfapi-sys.svg)](https://crates.io/crates/elfapi-sys) * [els-sys ![Crates.io](https://img.shields.io/crates/v/els-sys.svg)](https://crates.io/crates/els-sys) * [elscore-sys ![Crates.io](https://img.shields.io/crates/v/elscore-sys.svg)](https://crates.io/crates/elscore-sys) * [esent-sys ![Crates.io](https://img.shields.io/crates/v/esent-sys.svg)](https://crates.io/crates/esent-sys) * [evr-sys ![Crates.io](https://img.shields.io/crates/v/evr-sys.svg)](https://crates.io/crates/evr-sys) * [evr_vista-sys ![Crates.io](https://img.shields.io/crates/v/evr_vista-sys.svg)](https://crates.io/crates/evr_vista-sys) * [faultrep-sys ![Crates.io](https://img.shields.io/crates/v/faultrep-sys.svg)](https://crates.io/crates/faultrep-sys) * [feclient-sys ![Crates.io](https://img.shields.io/crates/v/feclient-sys.svg)](https://crates.io/crates/feclient-sys) * [fhsvcctl-sys ![Crates.io](https://img.shields.io/crates/v/fhsvcctl-sys.svg)](https://crates.io/crates/fhsvcctl-sys) * [fileextd-sys ![Crates.io](https://img.shields.io/crates/v/fileextd-sys.svg)](https://crates.io/crates/fileextd-sys) * [fltlib-sys ![Crates.io](https://img.shields.io/crates/v/fltlib-sys.svg)](https://crates.io/crates/fltlib-sys) * [fontsub-sys ![Crates.io](https://img.shields.io/crates/v/fontsub-sys.svg)](https://crates.io/crates/fontsub-sys) * [format-sys ![Crates.io](https://img.shields.io/crates/v/format-sys.svg)](https://crates.io/crates/format-sys) * [framedyd-sys ![Crates.io](https://img.shields.io/crates/v/framedyd-sys.svg)](https://crates.io/crates/framedyd-sys) * [framedyn-sys ![Crates.io](https://img.shields.io/crates/v/framedyn-sys.svg)](https://crates.io/crates/framedyn-sys) * [fwpuclnt-sys ![Crates.io](https://img.shields.io/crates/v/fwpuclnt-sys.svg)](https://crates.io/crates/fwpuclnt-sys) * [fxsutility-sys ![Crates.io](https://img.shields.io/crates/v/fxsutility-sys.svg)](https://crates.io/crates/fxsutility-sys) * [gdiplus-sys ![Crates.io](https://img.shields.io/crates/v/gdiplus-sys.svg)](https://crates.io/crates/gdiplus-sys) * [glmf32-sys ![Crates.io](https://img.shields.io/crates/v/glmf32-sys.svg)](https://crates.io/crates/glmf32-sys) * [glu32-sys ![Crates.io](https://img.shields.io/crates/v/glu32-sys.svg)](https://crates.io/crates/glu32-sys) * [gpedit-sys ![Crates.io](https://img.shields.io/crates/v/gpedit-sys.svg)](https://crates.io/crates/gpedit-sys) * [gpmuuid-sys ![Crates.io](https://img.shields.io/crates/v/gpmuuid-sys.svg)](https://crates.io/crates/gpmuuid-sys) * [hbaapi-sys ![Crates.io](https://img.shields.io/crates/v/hbaapi-sys.svg)](https://crates.io/crates/hbaapi-sys) * [hhsetup-sys ![Crates.io](https://img.shields.io/crates/v/hhsetup-sys.svg)](https://crates.io/crates/hhsetup-sys) * [hid-sys ![Crates.io](https://img.shields.io/crates/v/hid-sys.svg)](https://crates.io/crates/hid-sys) * [hlink-sys ![Crates.io](https://img.shields.io/crates/v/hlink-sys.svg)](https://crates.io/crates/hlink-sys) * [htmlhelp-sys ![Crates.io](https://img.shields.io/crates/v/htmlhelp-sys.svg)](https://crates.io/crates/htmlhelp-sys) * [httpapi-sys ![Crates.io](https://img.shields.io/crates/v/httpapi-sys.svg)](https://crates.io/crates/httpapi-sys) * [iashlpr-sys ![Crates.io](https://img.shields.io/crates/v/iashlpr-sys.svg)](https://crates.io/crates/iashlpr-sys) * [icm32-sys ![Crates.io](https://img.shields.io/crates/v/icm32-sys.svg)](https://crates.io/crates/icm32-sys) * [icmui-sys ![Crates.io](https://img.shields.io/crates/v/icmui-sys.svg)](https://crates.io/crates/icmui-sys) * [iepmapi-sys ![Crates.io](https://img.shields.io/crates/v/iepmapi-sys.svg)](https://crates.io/crates/iepmapi-sys) * [iesetup-sys ![Crates.io](https://img.shields.io/crates/v/iesetup-sys.svg)](https://crates.io/crates/iesetup-sys) * [imagehlp-sys ![Crates.io](https://img.shields.io/crates/v/imagehlp-sys.svg)](https://crates.io/crates/imagehlp-sys) * [imgutil-sys ![Crates.io](https://img.shields.io/crates/v/imgutil-sys.svg)](https://crates.io/crates/imgutil-sys) * [imm32-sys ![Crates.io](https://img.shields.io/crates/v/imm32-sys.svg)](https://crates.io/crates/imm32-sys) * [infocardapi-sys ![Crates.io](https://img.shields.io/crates/v/infocardapi-sys.svg)](https://crates.io/crates/infocardapi-sys) * [inseng-sys ![Crates.io](https://img.shields.io/crates/v/inseng-sys.svg)](https://crates.io/crates/inseng-sys) * [int64-sys ![Crates.io](https://img.shields.io/crates/v/int64-sys.svg)](https://crates.io/crates/int64-sys) * [iphlpapi-sys ![Crates.io](https://img.shields.io/crates/v/iphlpapi-sys.svg)](https://crates.io/crates/iphlpapi-sys) * [iprop-sys ![Crates.io](https://img.shields.io/crates/v/iprop-sys.svg)](https://crates.io/crates/iprop-sys) * [irprops-sys ![Crates.io](https://img.shields.io/crates/v/irprops-sys.svg)](https://crates.io/crates/irprops-sys) * [iscsidsc-sys ![Crates.io](https://img.shields.io/crates/v/iscsidsc-sys.svg)](https://crates.io/crates/iscsidsc-sys) * [jetoledb-sys ![Crates.io](https://img.shields.io/crates/v/jetoledb-sys.svg)](https://crates.io/crates/jetoledb-sys) * [jsrt-sys ![Crates.io](https://img.shields.io/crates/v/jsrt-sys.svg)](https://crates.io/crates/jsrt-sys) * [kerbcli-sys ![Crates.io](https://img.shields.io/crates/v/kerbcli-sys.svg)](https://crates.io/crates/kerbcli-sys) * [ksproxy-sys ![Crates.io](https://img.shields.io/crates/v/ksproxy-sys.svg)](https://crates.io/crates/ksproxy-sys) * [ksuser-sys ![Crates.io](https://img.shields.io/crates/v/ksuser-sys.svg)](https://crates.io/crates/ksuser-sys) * [loadperf-sys ![Crates.io](https://img.shields.io/crates/v/loadperf-sys.svg)](https://crates.io/crates/loadperf-sys) * [locationapi-sys ![Crates.io](https://img.shields.io/crates/v/locationapi-sys.svg)](https://crates.io/crates/locationapi-sys) * [lz32-sys ![Crates.io](https://img.shields.io/crates/v/lz32-sys.svg)](https://crates.io/crates/lz32-sys) * [magnification-sys ![Crates.io](https://img.shields.io/crates/v/magnification-sys.svg)](https://crates.io/crates/magnification-sys) * [mapi32-sys ![Crates.io](https://img.shields.io/crates/v/mapi32-sys.svg)](https://crates.io/crates/mapi32-sys) * [mbnapi_uuid-sys ![Crates.io](https://img.shields.io/crates/v/mbnapi_uuid-sys.svg)](https://crates.io/crates/mbnapi_uuid-sys) * [mciole32-sys ![Crates.io](https://img.shields.io/crates/v/mciole32-sys.svg)](https://crates.io/crates/mciole32-sys) * [mdmregistration-sys ![Crates.io](https://img.shields.io/crates/v/mdmregistration-sys.svg)](https://crates.io/crates/mdmregistration-sys) * [mf-sys ![Crates.io](https://img.shields.io/crates/v/mf-sys.svg)](https://crates.io/crates/mf-sys) * [mf_vista-sys ![Crates.io](https://img.shields.io/crates/v/mf_vista-sys.svg)](https://crates.io/crates/mf_vista-sys) * [mfcore-sys ![Crates.io](https://img.shields.io/crates/v/mfcore-sys.svg)](https://crates.io/crates/mfcore-sys) * [mfplat-sys ![Crates.io](https://img.shields.io/crates/v/mfplat-sys.svg)](https://crates.io/crates/mfplat-sys) * [mfplat_vista-sys ![Crates.io](https://img.shields.io/crates/v/mfplat_vista-sys.svg)](https://crates.io/crates/mfplat_vista-sys) * [mfplay-sys ![Crates.io](https://img.shields.io/crates/v/mfplay-sys.svg)](https://crates.io/crates/mfplay-sys) * [mfreadwrite-sys ![Crates.io](https://img.shields.io/crates/v/mfreadwrite-sys.svg)](https://crates.io/crates/mfreadwrite-sys) * [mfsrcsnk-sys ![Crates.io](https://img.shields.io/crates/v/mfsrcsnk-sys.svg)](https://crates.io/crates/mfsrcsnk-sys) * [mfuuid-sys ![Crates.io](https://img.shields.io/crates/v/mfuuid-sys.svg)](https://crates.io/crates/mfuuid-sys) * [mgmtapi-sys ![Crates.io](https://img.shields.io/crates/v/mgmtapi-sys.svg)](https://crates.io/crates/mgmtapi-sys) * [mi-sys ![Crates.io](https://img.shields.io/crates/v/mi-sys.svg)](https://crates.io/crates/mi-sys) * [mincore-sys ![Crates.io](https://img.shields.io/crates/v/mincore-sys.svg)](https://crates.io/crates/mincore-sys) * [mincore_downlevel-sys ![Crates.io](https://img.shields.io/crates/v/mincore_downlevel-sys.svg)](https://crates.io/crates/mincore_downlevel-sys) * [mmc-sys ![Crates.io](https://img.shields.io/crates/v/mmc-sys.svg)](https://crates.io/crates/mmc-sys) * [mmdevapi-sys ![Crates.io](https://img.shields.io/crates/v/mmdevapi-sys.svg)](https://crates.io/crates/mmdevapi-sys) * [mprapi-sys ![Crates.io](https://img.shields.io/crates/v/mprapi-sys.svg)](https://crates.io/crates/mprapi-sys) * [mprsnap-sys ![Crates.io](https://img.shields.io/crates/v/mprsnap-sys.svg)](https://crates.io/crates/mprsnap-sys) * [mqoa-sys ![Crates.io](https://img.shields.io/crates/v/mqoa-sys.svg)](https://crates.io/crates/mqoa-sys) * [mqrt-sys ![Crates.io](https://img.shields.io/crates/v/mqrt-sys.svg)](https://crates.io/crates/mqrt-sys) * [msaatext-sys ![Crates.io](https://img.shields.io/crates/v/msaatext-sys.svg)](https://crates.io/crates/msaatext-sys) * [msacm32-sys ![Crates.io](https://img.shields.io/crates/v/msacm32-sys.svg)](https://crates.io/crates/msacm32-sys) * [mscms-sys ![Crates.io](https://img.shields.io/crates/v/mscms-sys.svg)](https://crates.io/crates/mscms-sys) * [mscoree-sys ![Crates.io](https://img.shields.io/crates/v/mscoree-sys.svg)](https://crates.io/crates/mscoree-sys) * [mscorsn-sys ![Crates.io](https://img.shields.io/crates/v/mscorsn-sys.svg)](https://crates.io/crates/mscorsn-sys) * [msctfmonitor-sys ![Crates.io](https://img.shields.io/crates/v/msctfmonitor-sys.svg)](https://crates.io/crates/msctfmonitor-sys) * [msdasc-sys ![Crates.io](https://img.shields.io/crates/v/msdasc-sys.svg)](https://crates.io/crates/msdasc-sys) * [msdelta-sys ![Crates.io](https://img.shields.io/crates/v/msdelta-sys.svg)](https://crates.io/crates/msdelta-sys) * [msdmo-sys ![Crates.io](https://img.shields.io/crates/v/msdmo-sys.svg)](https://crates.io/crates/msdmo-sys) * [msdrm-sys ![Crates.io](https://img.shields.io/crates/v/msdrm-sys.svg)](https://crates.io/crates/msdrm-sys) * [msi-sys ![Crates.io](https://img.shields.io/crates/v/msi-sys.svg)](https://crates.io/crates/msi-sys) * [msimg32-sys ![Crates.io](https://img.shields.io/crates/v/msimg32-sys.svg)](https://crates.io/crates/msimg32-sys) * [mspatcha-sys ![Crates.io](https://img.shields.io/crates/v/mspatcha-sys.svg)](https://crates.io/crates/mspatcha-sys) * [mspatchc-sys ![Crates.io](https://img.shields.io/crates/v/mspatchc-sys.svg)](https://crates.io/crates/mspatchc-sys) * [mspbase-sys ![Crates.io](https://img.shields.io/crates/v/mspbase-sys.svg)](https://crates.io/crates/mspbase-sys) * [msports-sys ![Crates.io](https://img.shields.io/crates/v/msports-sys.svg)](https://crates.io/crates/msports-sys) * [msrating-sys ![Crates.io](https://img.shields.io/crates/v/msrating-sys.svg)](https://crates.io/crates/msrating-sys) * [mstask-sys ![Crates.io](https://img.shields.io/crates/v/mstask-sys.svg)](https://crates.io/crates/mstask-sys) * [msv1_0-sys ![Crates.io](https://img.shields.io/crates/v/msv1_0-sys.svg)](https://crates.io/crates/msv1_0-sys) * [msvfw32-sys ![Crates.io](https://img.shields.io/crates/v/msvfw32-sys.svg)](https://crates.io/crates/msvfw32-sys) * [mswsock-sys ![Crates.io](https://img.shields.io/crates/v/mswsock-sys.svg)](https://crates.io/crates/mswsock-sys) * [msxml2-sys ![Crates.io](https://img.shields.io/crates/v/msxml2-sys.svg)](https://crates.io/crates/msxml2-sys) * [msxml6-sys ![Crates.io](https://img.shields.io/crates/v/msxml6-sys.svg)](https://crates.io/crates/msxml6-sys) * [mtx-sys ![Crates.io](https://img.shields.io/crates/v/mtx-sys.svg)](https://crates.io/crates/mtx-sys) * [mtxdm-sys ![Crates.io](https://img.shields.io/crates/v/mtxdm-sys.svg)](https://crates.io/crates/mtxdm-sys) * [muiload-sys ![Crates.io](https://img.shields.io/crates/v/muiload-sys.svg)](https://crates.io/crates/muiload-sys) * [ncrypt-sys ![Crates.io](https://img.shields.io/crates/v/ncrypt-sys.svg)](https://crates.io/crates/ncrypt-sys) * [nddeapi-sys ![Crates.io](https://img.shields.io/crates/v/nddeapi-sys.svg)](https://crates.io/crates/nddeapi-sys) * [ndfapi-sys ![Crates.io](https://img.shields.io/crates/v/ndfapi-sys.svg)](https://crates.io/crates/ndfapi-sys) * [ndproxystub-sys ![Crates.io](https://img.shields.io/crates/v/ndproxystub-sys.svg)](https://crates.io/crates/ndproxystub-sys) * [netapi32-sys ![Crates.io](https://img.shields.io/crates/v/netapi32-sys.svg)](https://crates.io/crates/netapi32-sys) * [netlib-sys ![Crates.io](https://img.shields.io/crates/v/netlib-sys.svg)](https://crates.io/crates/netlib-sys) * [netsh-sys ![Crates.io](https://img.shields.io/crates/v/netsh-sys.svg)](https://crates.io/crates/netsh-sys) * [newdev-sys ![Crates.io](https://img.shields.io/crates/v/newdev-sys.svg)](https://crates.io/crates/newdev-sys) * [ninput-sys ![Crates.io](https://img.shields.io/crates/v/ninput-sys.svg)](https://crates.io/crates/ninput-sys) * [normaliz-sys ![Crates.io](https://img.shields.io/crates/v/normaliz-sys.svg)](https://crates.io/crates/normaliz-sys) * [nt-sys ![Crates.io](https://img.shields.io/crates/v/nt-sys.svg)](https://crates.io/crates/nt-sys) * [ntdll-sys ![Crates.io](https://img.shields.io/crates/v/ntdll-sys.svg)](https://crates.io/crates/ntdll-sys) * [ntdsa-sys ![Crates.io](https://img.shields.io/crates/v/ntdsa-sys.svg)](https://crates.io/crates/ntdsa-sys) * [ntdsapi-sys ![Crates.io](https://img.shields.io/crates/v/ntdsapi-sys.svg)](https://crates.io/crates/ntdsapi-sys) * [ntdsatq-sys ![Crates.io](https://img.shields.io/crates/v/ntdsatq-sys.svg)](https://crates.io/crates/ntdsatq-sys) * [ntdsetup-sys ![Crates.io](https://img.shields.io/crates/v/ntdsetup-sys.svg)](https://crates.io/crates/ntdsetup-sys) * [ntfrsapi-sys ![Crates.io](https://img.shields.io/crates/v/ntfrsapi-sys.svg)](https://crates.io/crates/ntfrsapi-sys) * [ntlanman-sys ![Crates.io](https://img.shields.io/crates/v/ntlanman-sys.svg)](https://crates.io/crates/ntlanman-sys) * [ntmarta-sys ![Crates.io](https://img.shields.io/crates/v/ntmarta-sys.svg)](https://crates.io/crates/ntmarta-sys) * [ntquery-sys ![Crates.io](https://img.shields.io/crates/v/ntquery-sys.svg)](https://crates.io/crates/ntquery-sys) * [ntstc_libcmt-sys ![Crates.io](https://img.shields.io/crates/v/ntstc_libcmt-sys.svg)](https://crates.io/crates/ntstc_libcmt-sys) * [ntstc_msvcrt-sys ![Crates.io](https://img.shields.io/crates/v/ntstc_msvcrt-sys.svg)](https://crates.io/crates/ntstc_msvcrt-sys) * [ntvdm-sys ![Crates.io](https://img.shields.io/crates/v/ntvdm-sys.svg)](https://crates.io/crates/ntvdm-sys) * [objsel-sys ![Crates.io](https://img.shields.io/crates/v/objsel-sys.svg)](https://crates.io/crates/objsel-sys) * [odbc32-sys ![Crates.io](https://img.shields.io/crates/v/odbc32-sys.svg)](https://crates.io/crates/odbc32-sys) * [odbcbcp-sys ![Crates.io](https://img.shields.io/crates/v/odbcbcp-sys.svg)](https://crates.io/crates/odbcbcp-sys) * [odbccp32-sys ![Crates.io](https://img.shields.io/crates/v/odbccp32-sys.svg)](https://crates.io/crates/odbccp32-sys) * [oemlicense-sys ![Crates.io](https://img.shields.io/crates/v/oemlicense-sys.svg)](https://crates.io/crates/oemlicense-sys) * [oleacc-sys ![Crates.io](https://img.shields.io/crates/v/oleacc-sys.svg)](https://crates.io/crates/oleacc-sys) * [olecli32-sys ![Crates.io](https://img.shields.io/crates/v/olecli32-sys.svg)](https://crates.io/crates/olecli32-sys) * [oledb-sys ![Crates.io](https://img.shields.io/crates/v/oledb-sys.svg)](https://crates.io/crates/oledb-sys) * [oledlg-sys ![Crates.io](https://img.shields.io/crates/v/oledlg-sys.svg)](https://crates.io/crates/oledlg-sys) * [olepro32-sys ![Crates.io](https://img.shields.io/crates/v/olepro32-sys.svg)](https://crates.io/crates/olepro32-sys) * [olesvr32-sys ![Crates.io](https://img.shields.io/crates/v/olesvr32-sys.svg)](https://crates.io/crates/olesvr32-sys) * [ondemandconnroutehelper-sys ![Crates.io](https://img.shields.io/crates/v/ondemandconnroutehelper-sys.svg)](https://crates.io/crates/ondemandconnroutehelper-sys) * [osptk-sys ![Crates.io](https://img.shields.io/crates/v/osptk-sys.svg)](https://crates.io/crates/osptk-sys) * [p2p-sys ![Crates.io](https://img.shields.io/crates/v/p2p-sys.svg)](https://crates.io/crates/p2p-sys) * [p2pgraph-sys ![Crates.io](https://img.shields.io/crates/v/p2pgraph-sys.svg)](https://crates.io/crates/p2pgraph-sys) * [patchwiz-sys ![Crates.io](https://img.shields.io/crates/v/patchwiz-sys.svg)](https://crates.io/crates/patchwiz-sys) * [pathcch-sys ![Crates.io](https://img.shields.io/crates/v/pathcch-sys.svg)](https://crates.io/crates/pathcch-sys) * [pdh-sys ![Crates.io](https://img.shields.io/crates/v/pdh-sys.svg)](https://crates.io/crates/pdh-sys) * [peerdist-sys ![Crates.io](https://img.shields.io/crates/v/peerdist-sys.svg)](https://crates.io/crates/peerdist-sys) * [photoacquireuid-sys ![Crates.io](https://img.shields.io/crates/v/photoacquireuid-sys.svg)](https://crates.io/crates/photoacquireuid-sys) * [portabledeviceguids-sys ![Crates.io](https://img.shields.io/crates/v/portabledeviceguids-sys.svg)](https://crates.io/crates/portabledeviceguids-sys) * [powrprof-sys ![Crates.io](https://img.shields.io/crates/v/powrprof-sys.svg)](https://crates.io/crates/powrprof-sys) * [prntvpt-sys ![Crates.io](https://img.shields.io/crates/v/prntvpt-sys.svg)](https://crates.io/crates/prntvpt-sys) * [propsys-sys ![Crates.io](https://img.shields.io/crates/v/propsys-sys.svg)](https://crates.io/crates/propsys-sys) * [quartz-sys ![Crates.io](https://img.shields.io/crates/v/quartz-sys.svg)](https://crates.io/crates/quartz-sys) * [query-sys ![Crates.io](https://img.shields.io/crates/v/query-sys.svg)](https://crates.io/crates/query-sys) * [qutil-sys ![Crates.io](https://img.shields.io/crates/v/qutil-sys.svg)](https://crates.io/crates/qutil-sys) * [qwave-sys ![Crates.io](https://img.shields.io/crates/v/qwave-sys.svg)](https://crates.io/crates/qwave-sys) * [rasapi32-sys ![Crates.io](https://img.shields.io/crates/v/rasapi32-sys.svg)](https://crates.io/crates/rasapi32-sys) * [rasdlg-sys ![Crates.io](https://img.shields.io/crates/v/rasdlg-sys.svg)](https://crates.io/crates/rasdlg-sys) * [rasuser-sys ![Crates.io](https://img.shields.io/crates/v/rasuser-sys.svg)](https://crates.io/crates/rasuser-sys) * [resutils-sys ![Crates.io](https://img.shields.io/crates/v/resutils-sys.svg)](https://crates.io/crates/resutils-sys) * [rometadata-sys ![Crates.io](https://img.shields.io/crates/v/rometadata-sys.svg)](https://crates.io/crates/rometadata-sys) * [rpcexts-sys ![Crates.io](https://img.shields.io/crates/v/rpcexts-sys.svg)](https://crates.io/crates/rpcexts-sys) * [rpcns4-sys ![Crates.io](https://img.shields.io/crates/v/rpcns4-sys.svg)](https://crates.io/crates/rpcns4-sys) * [rpcproxy-sys ![Crates.io](https://img.shields.io/crates/v/rpcproxy-sys.svg)](https://crates.io/crates/rpcproxy-sys) * [rpcrt4-sys ![Crates.io](https://img.shields.io/crates/v/rpcrt4-sys.svg)](https://crates.io/crates/rpcrt4-sys) * [rpcutil-sys ![Crates.io](https://img.shields.io/crates/v/rpcutil-sys.svg)](https://crates.io/crates/rpcutil-sys) * [rstrtmgr-sys ![Crates.io](https://img.shields.io/crates/v/rstrtmgr-sys.svg)](https://crates.io/crates/rstrtmgr-sys) * [rtm-sys ![Crates.io](https://img.shields.io/crates/v/rtm-sys.svg)](https://crates.io/crates/rtm-sys) * [rtutils-sys ![Crates.io](https://img.shields.io/crates/v/rtutils-sys.svg)](https://crates.io/crates/rtutils-sys) * [rtworkq-sys ![Crates.io](https://img.shields.io/crates/v/rtworkq-sys.svg)](https://crates.io/crates/rtworkq-sys) * [runtimeobject-sys ![Crates.io](https://img.shields.io/crates/v/runtimeobject-sys.svg)](https://crates.io/crates/runtimeobject-sys) * [samlib-sys ![Crates.io](https://img.shields.io/crates/v/samlib-sys.svg)](https://crates.io/crates/samlib-sys) * [samsrv-sys ![Crates.io](https://img.shields.io/crates/v/samsrv-sys.svg)](https://crates.io/crates/samsrv-sys) * [sapi-sys ![Crates.io](https://img.shields.io/crates/v/sapi-sys.svg)](https://crates.io/crates/sapi-sys) * [sas-sys ![Crates.io](https://img.shields.io/crates/v/sas-sys.svg)](https://crates.io/crates/sas-sys) * [sbtsv-sys ![Crates.io](https://img.shields.io/crates/v/sbtsv-sys.svg)](https://crates.io/crates/sbtsv-sys) * [scarddlg-sys ![Crates.io](https://img.shields.io/crates/v/scarddlg-sys.svg)](https://crates.io/crates/scarddlg-sys) * [scecli-sys ![Crates.io](https://img.shields.io/crates/v/scecli-sys.svg)](https://crates.io/crates/scecli-sys) * [scesrv-sys ![Crates.io](https://img.shields.io/crates/v/scesrv-sys.svg)](https://crates.io/crates/scesrv-sys) * [schannel-sys ![Crates.io](https://img.shields.io/crates/v/schannel-sys.svg)](https://crates.io/crates/schannel-sys) * [scrnsave-sys ![Crates.io](https://img.shields.io/crates/v/scrnsave-sys.svg)](https://crates.io/crates/scrnsave-sys) * [scrnsavw-sys ![Crates.io](https://img.shields.io/crates/v/scrnsavw-sys.svg)](https://crates.io/crates/scrnsavw-sys) * [searchsdk-sys ![Crates.io](https://img.shields.io/crates/v/searchsdk-sys.svg)](https://crates.io/crates/searchsdk-sys) * [security-sys ![Crates.io](https://img.shields.io/crates/v/security-sys.svg)](https://crates.io/crates/security-sys) * [sens-sys ![Crates.io](https://img.shields.io/crates/v/sens-sys.svg)](https://crates.io/crates/sens-sys) * [sensapi-sys ![Crates.io](https://img.shields.io/crates/v/sensapi-sys.svg)](https://crates.io/crates/sensapi-sys) * [sensorsapi-sys ![Crates.io](https://img.shields.io/crates/v/sensorsapi-sys.svg)](https://crates.io/crates/sensorsapi-sys) * [setupapi-sys ![Crates.io](https://img.shields.io/crates/v/setupapi-sys.svg)](https://crates.io/crates/setupapi-sys) * [sfc-sys ![Crates.io](https://img.shields.io/crates/v/sfc-sys.svg)](https://crates.io/crates/sfc-sys) * [shcore-sys ![Crates.io](https://img.shields.io/crates/v/shcore-sys.svg)](https://crates.io/crates/shcore-sys) * [shdocvw-sys ![Crates.io](https://img.shields.io/crates/v/shdocvw-sys.svg)](https://crates.io/crates/shdocvw-sys) * [shfolder-sys ![Crates.io](https://img.shields.io/crates/v/shfolder-sys.svg)](https://crates.io/crates/shfolder-sys) * [shlwapi-sys ![Crates.io](https://img.shields.io/crates/v/shlwapi-sys.svg)](https://crates.io/crates/shlwapi-sys) * [sisbkup-sys ![Crates.io](https://img.shields.io/crates/v/sisbkup-sys.svg)](https://crates.io/crates/sisbkup-sys) * [slc-sys ![Crates.io](https://img.shields.io/crates/v/slc-sys.svg)](https://crates.io/crates/slc-sys) * [slcext-sys ![Crates.io](https://img.shields.io/crates/v/slcext-sys.svg)](https://crates.io/crates/slcext-sys) * [slwga-sys ![Crates.io](https://img.shields.io/crates/v/slwga-sys.svg)](https://crates.io/crates/slwga-sys) * [snmpapi-sys ![Crates.io](https://img.shields.io/crates/v/snmpapi-sys.svg)](https://crates.io/crates/snmpapi-sys) * [spoolss-sys ![Crates.io](https://img.shields.io/crates/v/spoolss-sys.svg)](https://crates.io/crates/spoolss-sys) * [sporder-sys ![Crates.io](https://img.shields.io/crates/v/sporder-sys.svg)](https://crates.io/crates/sporder-sys) * [srclient-sys ![Crates.io](https://img.shields.io/crates/v/srclient-sys.svg)](https://crates.io/crates/srclient-sys) * [ssdpapi-sys ![Crates.io](https://img.shields.io/crates/v/ssdpapi-sys.svg)](https://crates.io/crates/ssdpapi-sys) * [sti-sys ![Crates.io](https://img.shields.io/crates/v/sti-sys.svg)](https://crates.io/crates/sti-sys) * [strmbase-sys ![Crates.io](https://img.shields.io/crates/v/strmbase-sys.svg)](https://crates.io/crates/strmbase-sys) * [strmiids-sys ![Crates.io](https://img.shields.io/crates/v/strmiids-sys.svg)](https://crates.io/crates/strmiids-sys) * [strsafe-sys ![Crates.io](https://img.shields.io/crates/v/strsafe-sys.svg)](https://crates.io/crates/strsafe-sys) * [structuredquery-sys ![Crates.io](https://img.shields.io/crates/v/structuredquery-sys.svg)](https://crates.io/crates/structuredquery-sys) * [svcguid-sys ![Crates.io](https://img.shields.io/crates/v/svcguid-sys.svg)](https://crates.io/crates/svcguid-sys) * [swdevice-sys ![Crates.io](https://img.shields.io/crates/v/swdevice-sys.svg)](https://crates.io/crates/swdevice-sys) * [synchronization-sys ![Crates.io](https://img.shields.io/crates/v/synchronization-sys.svg)](https://crates.io/crates/synchronization-sys) * [t2embed-sys ![Crates.io](https://img.shields.io/crates/v/t2embed-sys.svg)](https://crates.io/crates/t2embed-sys) * [tapi32-sys ![Crates.io](https://img.shields.io/crates/v/tapi32-sys.svg)](https://crates.io/crates/tapi32-sys) * [tapi32l-sys ![Crates.io](https://img.shields.io/crates/v/tapi32l-sys.svg)](https://crates.io/crates/tapi32l-sys) * [taskschd-sys ![Crates.io](https://img.shields.io/crates/v/taskschd-sys.svg)](https://crates.io/crates/taskschd-sys) * [tbs-sys ![Crates.io](https://img.shields.io/crates/v/tbs-sys.svg)](https://crates.io/crates/tbs-sys) * [tdh-sys ![Crates.io](https://img.shields.io/crates/v/tdh-sys.svg)](https://crates.io/crates/tdh-sys) * [thunk32-sys ![Crates.io](https://img.shields.io/crates/v/thunk32-sys.svg)](https://crates.io/crates/thunk32-sys) * [tlbref-sys ![Crates.io](https://img.shields.io/crates/v/tlbref-sys.svg)](https://crates.io/crates/tlbref-sys) * [traffic-sys ![Crates.io](https://img.shields.io/crates/v/traffic-sys.svg)](https://crates.io/crates/traffic-sys) * [transcodeimageuid-sys ![Crates.io](https://img.shields.io/crates/v/transcodeimageuid-sys.svg)](https://crates.io/crates/transcodeimageuid-sys) * [tsec-sys ![Crates.io](https://img.shields.io/crates/v/tsec-sys.svg)](https://crates.io/crates/tsec-sys) * [tspubplugincom-sys ![Crates.io](https://img.shields.io/crates/v/tspubplugincom-sys.svg)](https://crates.io/crates/tspubplugincom-sys) * [twain_32-sys ![Crates.io](https://img.shields.io/crates/v/twain_32-sys.svg)](https://crates.io/crates/twain_32-sys) * [twinapi-sys ![Crates.io](https://img.shields.io/crates/v/twinapi-sys.svg)](https://crates.io/crates/twinapi-sys) * [txfw32-sys ![Crates.io](https://img.shields.io/crates/v/txfw32-sys.svg)](https://crates.io/crates/txfw32-sys) * [ualapi-sys ![Crates.io](https://img.shields.io/crates/v/ualapi-sys.svg)](https://crates.io/crates/ualapi-sys) * [uiautomationcore-sys ![Crates.io](https://img.shields.io/crates/v/uiautomationcore-sys.svg)](https://crates.io/crates/uiautomationcore-sys) * [umpdddi-sys ![Crates.io](https://img.shields.io/crates/v/umpdddi-sys.svg)](https://crates.io/crates/umpdddi-sys) * [unicows-sys ![Crates.io](https://img.shields.io/crates/v/unicows-sys.svg)](https://crates.io/crates/unicows-sys) * [urlmon-sys ![Crates.io](https://img.shields.io/crates/v/urlmon-sys.svg)](https://crates.io/crates/urlmon-sys) * [userenv-sys ![Crates.io](https://img.shields.io/crates/v/userenv-sys.svg)](https://crates.io/crates/userenv-sys) * [usp10-sys ![Crates.io](https://img.shields.io/crates/v/usp10-sys.svg)](https://crates.io/crates/usp10-sys) * [uxtheme-sys ![Crates.io](https://img.shields.io/crates/v/uxtheme-sys.svg)](https://crates.io/crates/uxtheme-sys) * [vccomsup-sys ![Crates.io](https://img.shields.io/crates/v/vccomsup-sys.svg)](https://crates.io/crates/vccomsup-sys) * [vdmdbg-sys ![Crates.io](https://img.shields.io/crates/v/vdmdbg-sys.svg)](https://crates.io/crates/vdmdbg-sys) * [vds_uuid-sys ![Crates.io](https://img.shields.io/crates/v/vds_uuid-sys.svg)](https://crates.io/crates/vds_uuid-sys) * [version-sys ![Crates.io](https://img.shields.io/crates/v/version-sys.svg)](https://crates.io/crates/version-sys) * [vfw32-sys ![Crates.io](https://img.shields.io/crates/v/vfw32-sys.svg)](https://crates.io/crates/vfw32-sys) * [virtdisk-sys ![Crates.io](https://img.shields.io/crates/v/virtdisk-sys.svg)](https://crates.io/crates/virtdisk-sys) * [vscmgr-sys ![Crates.io](https://img.shields.io/crates/v/vscmgr-sys.svg)](https://crates.io/crates/vscmgr-sys) * [vss_uuid-sys ![Crates.io](https://img.shields.io/crates/v/vss_uuid-sys.svg)](https://crates.io/crates/vss_uuid-sys) * [vstorinterface-sys ![Crates.io](https://img.shields.io/crates/v/vstorinterface-sys.svg)](https://crates.io/crates/vstorinterface-sys) * [wbemuuid-sys ![Crates.io](https://img.shields.io/crates/v/wbemuuid-sys.svg)](https://crates.io/crates/wbemuuid-sys) * [wcmapi-sys ![Crates.io](https://img.shields.io/crates/v/wcmapi-sys.svg)](https://crates.io/crates/wcmapi-sys) * [wcmguid-sys ![Crates.io](https://img.shields.io/crates/v/wcmguid-sys.svg)](https://crates.io/crates/wcmguid-sys) * [wdsbp-sys ![Crates.io](https://img.shields.io/crates/v/wdsbp-sys.svg)](https://crates.io/crates/wdsbp-sys) * [wdsclientapi-sys ![Crates.io](https://img.shields.io/crates/v/wdsclientapi-sys.svg)](https://crates.io/crates/wdsclientapi-sys) * [wdsmc-sys ![Crates.io](https://img.shields.io/crates/v/wdsmc-sys.svg)](https://crates.io/crates/wdsmc-sys) * [wdspxe-sys ![Crates.io](https://img.shields.io/crates/v/wdspxe-sys.svg)](https://crates.io/crates/wdspxe-sys) * [wdstptc-sys ![Crates.io](https://img.shields.io/crates/v/wdstptc-sys.svg)](https://crates.io/crates/wdstptc-sys) * [webservices-sys ![Crates.io](https://img.shields.io/crates/v/webservices-sys.svg)](https://crates.io/crates/webservices-sys) * [websocket-sys ![Crates.io](https://img.shields.io/crates/v/websocket-sys.svg)](https://crates.io/crates/websocket-sys) * [wecapi-sys ![Crates.io](https://img.shields.io/crates/v/wecapi-sys.svg)](https://crates.io/crates/wecapi-sys) * [wer-sys ![Crates.io](https://img.shields.io/crates/v/wer-sys.svg)](https://crates.io/crates/wer-sys) * [wevtapi-sys ![Crates.io](https://img.shields.io/crates/v/wevtapi-sys.svg)](https://crates.io/crates/wevtapi-sys) * [wiaguid-sys ![Crates.io](https://img.shields.io/crates/v/wiaguid-sys.svg)](https://crates.io/crates/wiaguid-sys) * [wiaservc-sys ![Crates.io](https://img.shields.io/crates/v/wiaservc-sys.svg)](https://crates.io/crates/wiaservc-sys) * [wiautil-sys ![Crates.io](https://img.shields.io/crates/v/wiautil-sys.svg)](https://crates.io/crates/wiautil-sys) * [winbio-sys ![Crates.io](https://img.shields.io/crates/v/winbio-sys.svg)](https://crates.io/crates/winbio-sys) * [windows-data-pdf-sys ![Crates.io](https://img.shields.io/crates/v/windows-data-pdf-sys.svg)](https://crates.io/crates/windows-data-pdf-sys) * [windows-networking-sys ![Crates.io](https://img.shields.io/crates/v/windows-networking-sys.svg)](https://crates.io/crates/windows-networking-sys) * [windows-ui-sys ![Crates.io](https://img.shields.io/crates/v/windows-ui-sys.svg)](https://crates.io/crates/windows-ui-sys) * [windowscodecs-sys ![Crates.io](https://img.shields.io/crates/v/windowscodecs-sys.svg)](https://crates.io/crates/windowscodecs-sys) * [windowssideshowguids-sys ![Crates.io](https://img.shields.io/crates/v/windowssideshowguids-sys.svg)](https://crates.io/crates/windowssideshowguids-sys) * [winfax-sys ![Crates.io](https://img.shields.io/crates/v/winfax-sys.svg)](https://crates.io/crates/winfax-sys) * [winhttp-sys ![Crates.io](https://img.shields.io/crates/v/winhttp-sys.svg)](https://crates.io/crates/winhttp-sys) * [wininet-sys ![Crates.io](https://img.shields.io/crates/v/wininet-sys.svg)](https://crates.io/crates/wininet-sys) * [winsatapi-sys ![Crates.io](https://img.shields.io/crates/v/winsatapi-sys.svg)](https://crates.io/crates/winsatapi-sys) * [winscard-sys ![Crates.io](https://img.shields.io/crates/v/winscard-sys.svg)](https://crates.io/crates/winscard-sys) * [winspool-sys ![Crates.io](https://img.shields.io/crates/v/winspool-sys.svg)](https://crates.io/crates/winspool-sys) * [winsta-sys ![Crates.io](https://img.shields.io/crates/v/winsta-sys.svg)](https://crates.io/crates/winsta-sys) * [winstrm-sys ![Crates.io](https://img.shields.io/crates/v/winstrm-sys.svg)](https://crates.io/crates/winstrm-sys) * [wintrust-sys ![Crates.io](https://img.shields.io/crates/v/wintrust-sys.svg)](https://crates.io/crates/wintrust-sys) * [winusb-sys ![Crates.io](https://img.shields.io/crates/v/winusb-sys.svg)](https://crates.io/crates/winusb-sys) * [wlanapi-sys ![Crates.io](https://img.shields.io/crates/v/wlanapi-sys.svg)](https://crates.io/crates/wlanapi-sys) * [wlanui-sys ![Crates.io](https://img.shields.io/crates/v/wlanui-sys.svg)](https://crates.io/crates/wlanui-sys) * [wldap32-sys ![Crates.io](https://img.shields.io/crates/v/wldap32-sys.svg)](https://crates.io/crates/wldap32-sys) * [wmcodecdspuuid-sys ![Crates.io](https://img.shields.io/crates/v/wmcodecdspuuid-sys.svg)](https://crates.io/crates/wmcodecdspuuid-sys) * [wmdrmsdk-sys ![Crates.io](https://img.shields.io/crates/v/wmdrmsdk-sys.svg)](https://crates.io/crates/wmdrmsdk-sys) * [wmip-sys ![Crates.io](https://img.shields.io/crates/v/wmip-sys.svg)](https://crates.io/crates/wmip-sys) * [wmiutils-sys ![Crates.io](https://img.shields.io/crates/v/wmiutils-sys.svg)](https://crates.io/crates/wmiutils-sys) * [wmvcore-sys ![Crates.io](https://img.shields.io/crates/v/wmvcore-sys.svg)](https://crates.io/crates/wmvcore-sys) * [wnvapi-sys ![Crates.io](https://img.shields.io/crates/v/wnvapi-sys.svg)](https://crates.io/crates/wnvapi-sys) * [workspaceax-sys ![Crates.io](https://img.shields.io/crates/v/workspaceax-sys.svg)](https://crates.io/crates/workspaceax-sys) * [wow32-sys ![Crates.io](https://img.shields.io/crates/v/wow32-sys.svg)](https://crates.io/crates/wow32-sys) * [wsbapp_uuid-sys ![Crates.io](https://img.shields.io/crates/v/wsbapp_uuid-sys.svg)](https://crates.io/crates/wsbapp_uuid-sys) * [wsbonline-sys ![Crates.io](https://img.shields.io/crates/v/wsbonline-sys.svg)](https://crates.io/crates/wsbonline-sys) * [wscapi-sys ![Crates.io](https://img.shields.io/crates/v/wscapi-sys.svg)](https://crates.io/crates/wscapi-sys) * [wsclient-sys ![Crates.io](https://img.shields.io/crates/v/wsclient-sys.svg)](https://crates.io/crates/wsclient-sys) * [wsdapi-sys ![Crates.io](https://img.shields.io/crates/v/wsdapi-sys.svg)](https://crates.io/crates/wsdapi-sys) * [wsmsvc-sys ![Crates.io](https://img.shields.io/crates/v/wsmsvc-sys.svg)](https://crates.io/crates/wsmsvc-sys) * [wsnmp32-sys ![Crates.io](https://img.shields.io/crates/v/wsnmp32-sys.svg)](https://crates.io/crates/wsnmp32-sys) * [wsock32-sys ![Crates.io](https://img.shields.io/crates/v/wsock32-sys.svg)](https://crates.io/crates/wsock32-sys) * [wtsapi32-sys ![Crates.io](https://img.shields.io/crates/v/wtsapi32-sys.svg)](https://crates.io/crates/wtsapi32-sys) * [wuguid-sys ![Crates.io](https://img.shields.io/crates/v/wuguid-sys.svg)](https://crates.io/crates/wuguid-sys) * [xapobase-sys ![Crates.io](https://img.shields.io/crates/v/xapobase-sys.svg)](https://crates.io/crates/xapobase-sys) * [xaswitch-sys ![Crates.io](https://img.shields.io/crates/v/xaswitch-sys.svg)](https://crates.io/crates/xaswitch-sys) * [xaudio2-sys ![Crates.io](https://img.shields.io/crates/v/xaudio2-sys.svg)](https://crates.io/crates/xaudio2-sys) * [xinput9_1_0-sys ![Crates.io](https://img.shields.io/crates/v/xinput9_1_0-sys.svg)](https://crates.io/crates/xinput9_1_0-sys) * [xmllite-sys ![Crates.io](https://img.shields.io/crates/v/xmllite-sys.svg)](https://crates.io/crates/xmllite-sys) * [xolehlp-sys ![Crates.io](https://img.shields.io/crates/v/xolehlp-sys.svg)](https://crates.io/crates/xolehlp-sys) * [xpsprint-sys ![Crates.io](https://img.shields.io/crates/v/xpsprint-sys.svg)](https://crates.io/crates/xpsprint-sys) deps/winapi-0.2.5/.gitignore0000644000000000000000000000002312542643300014420 0ustar rootroottarget/ Cargo.lock deps/winapi-0.2.5/src/0000755000000000000000000000000012666635521013241 5ustar rootrootdeps/winapi-0.2.5/src/shlguid.rs0000644000000000000000000000012412605021253015223 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License deps/winapi-0.2.5/src/lmcons.rs0000644000000000000000000000426412605021351015067 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! This file contains constants used throughout the LAN Manager API header files. pub const CNLEN: ::DWORD = 15; pub const LM20_CNLEN: ::DWORD = 15; pub const DNLEN: ::DWORD = CNLEN; pub const LM20_DNLEN: ::DWORD = LM20_CNLEN; pub const UNCLEN: ::DWORD = CNLEN + 2; pub const LM20_UNCLEN: ::DWORD = LM20_CNLEN + 2; pub const NNLEN: ::DWORD = 80; pub const LM20_NNLEN: ::DWORD = 12; pub const RMLEN: ::DWORD = UNCLEN + 1 + NNLEN; pub const LM20_RMLEN: ::DWORD = LM20_UNCLEN + 1 + LM20_NNLEN; pub const SNLEN: ::DWORD = 80; pub const LM20_SNLEN: ::DWORD = 15; pub const STXTLEN: ::DWORD = 256; pub const LM20_STXTLEN: ::DWORD = 63; pub const PATHLEN: ::DWORD = 256; pub const LM20_PATHLEN: ::DWORD = 256; pub const DEVLEN: ::DWORD = 80; pub const LM20_DEVLEN: ::DWORD = 8; pub const EVLEN: ::DWORD = 16; pub const UNLEN: ::DWORD = 256; pub const LM20_UNLEN: ::DWORD = 20; pub const GNLEN: ::DWORD = UNLEN; pub const LM20_GNLEN: ::DWORD = LM20_UNLEN; pub const PWLEN: ::DWORD = 256; pub const LM20_PWLEN: ::DWORD = 14; pub const SHPWLEN: ::DWORD = 8; pub const CLTYPE_LEN: ::DWORD = 12; pub const MAXCOMMENTSZ: ::DWORD = 256; pub const LM20_MAXCOMMENTSZ: ::DWORD = 48; pub const QNLEN: ::DWORD = NNLEN; pub const LM20_QNLEN: ::DWORD = LM20_NNLEN; pub const ALERTSZ: ::DWORD = 128; pub const MAXDEVENTRIES: ::DWORD = 4 * 8; // FIXME: sizeof(int) instead of 4 pub const NETBIOS_NAME_LEN: ::DWORD = 16; pub const MAX_PREFERRED_LENGTH: ::DWORD = -1i32 as ::DWORD; pub const CRYPT_KEY_LEN: ::DWORD = 7; pub const CRYPT_TXT_LEN: ::DWORD = 8; pub const ENCRYPTED_PWLEN: usize = 16; pub const SESSION_PWLEN: ::DWORD = 24; pub const SESSION_CRYPT_KLEN: ::DWORD = 21; pub const PARM_ERROR_UNKNOWN: ::DWORD = -1i32 as ::DWORD; pub const PARM_ERROR_NONE: ::DWORD = 0; pub const PARMNUM_BASE_INFOLEVEL: ::DWORD = 1000; pub type LMSTR = ::LPWSTR; pub type LMCSTR = ::LPCWSTR; pub type NET_API_STATUS = ::DWORD; pub type API_RET_TYPE = NET_API_STATUS; pub const PLATFORM_ID_DOS: ::DWORD = 300; pub const PLATFORM_ID_OS2: ::DWORD = 400; pub const PLATFORM_ID_NT: ::DWORD = 500; pub const PLATFORM_ID_OSF: ::DWORD = 600; pub const PLATFORM_ID_VMS: ::DWORD = 700; deps/winapi-0.2.5/src/hidsdi.rs0000644000000000000000000000044512613167613015050 0ustar rootroot// Copyright © 2015, Alex Daniel Jones // Licensed under the MIT License // Taken from hidsdi.h STRUCT!{struct HIDD_ATTRIBUTES { Size: ::ULONG, VendorID: ::USHORT, ProductID: ::USHORT, VersionNumber: ::USHORT, }} pub type PHIDD_ATTRIBUTES = *mut HIDD_ATTRIBUTES; deps/winapi-0.2.5/src/ws2tcpip.rs0000644000000000000000000000203112616503465015352 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! WinSock2 Extension for TCP/IP protocols pub type LPLOOKUPSERVICE_COMPLETION_ROUTINE = Option; pub type socklen_t = ::c_int; STRUCT!{struct ip_mreq { imr_multiaddr: ::in_addr, imr_interface: ::in_addr, }} pub const IP_OPTIONS: ::c_int = 1; pub const IP_HDRINCL: ::c_int = 2; pub const IP_TOS: ::c_int = 3; pub const IP_TTL: ::c_int = 4; pub const IP_MULTICAST_IF: ::c_int = 9; pub const IP_MULTICAST_TTL: ::c_int = 10; pub const IP_MULTICAST_LOOP: ::c_int = 11; pub const IP_ADD_MEMBERSHIP: ::c_int = 12; pub const IP_DROP_MEMBERSHIP: ::c_int = 13; pub const IP_DONTFRAGMENT: ::c_int = 14; pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 15; pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 16; pub const IP_BLOCK_SOURCE: ::c_int = 17; pub const IP_UNBLOCK_SOURCE: ::c_int = 18; pub const IP_PKTINFO: ::c_int = 19; pub const IP_RECEIVE_BROADCAST: ::c_int = 22; deps/winapi-0.2.5/src/dwrite.rs0000644000000000000000000013470012613167613015104 0ustar rootroot// Copyright © 2015, Connor Hilarides // Licensed under the MIT License //! DirectX Typography Services public API definitions. ENUM!{enum DWRITE_FONT_FILE_TYPE { DWRITE_FONT_FILE_TYPE_UNKNOWN, DWRITE_FONT_FILE_TYPE_CFF, DWRITE_FONT_FILE_TYPE_TRUETYPE, DWRITE_FONT_FILE_TYPE_TRUETYPE_COLLECTION, DWRITE_FONT_FILE_TYPE_TYPE1_PFM, DWRITE_FONT_FILE_TYPE_TYPE1_PFB, DWRITE_FONT_FILE_TYPE_VECTOR, DWRITE_FONT_FILE_TYPE_BITMAP, }} ENUM!{enum DWRITE_FONT_FACE_TYPE { DWRITE_FONT_FACE_TYPE_CFF, DWRITE_FONT_FACE_TYPE_TRUETYPE, DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION, DWRITE_FONT_FACE_TYPE_TYPE1, DWRITE_FONT_FACE_TYPE_VECTOR, DWRITE_FONT_FACE_TYPE_BITMAP, DWRITE_FONT_FACE_TYPE_UNKNOWN, DWRITE_FONT_FACE_TYPE_RAW_CFF, }} FLAGS!{enum DWRITE_FONT_SIMULATIONS { DWRITE_FONT_SIMULATIONS_NONE = 0x0000, DWRITE_FONT_SIMULATIONS_BOLD = 0x0001, DWRITE_FONT_SIMULATIONS_OBLIQUE = 0x0002, }} ENUM!{enum DWRITE_FONT_WEIGHT { DWRITE_FONT_WEIGHT_THIN = 100, DWRITE_FONT_WEIGHT_EXTRA_LIGHT = 200, DWRITE_FONT_WEIGHT_ULTRA_LIGHT = 200, DWRITE_FONT_WEIGHT_LIGHT = 300, DWRITE_FONT_WEIGHT_SEMI_LIGHT = 350, DWRITE_FONT_WEIGHT_NORMAL = 400, DWRITE_FONT_WEIGHT_REGULAR = 400, DWRITE_FONT_WEIGHT_MEDIUM = 500, DWRITE_FONT_WEIGHT_DEMI_BOLD = 600, DWRITE_FONT_WEIGHT_SEMI_BOLD = 600, DWRITE_FONT_WEIGHT_BOLD = 700, DWRITE_FONT_WEIGHT_EXTRA_BOLD = 800, DWRITE_FONT_WEIGHT_ULTRA_BOLD = 800, DWRITE_FONT_WEIGHT_BLACK = 900, DWRITE_FONT_WEIGHT_HEAVY = 900, DWRITE_FONT_WEIGHT_EXTRA_BLACK = 950, DWRITE_FONT_WEIGHT_ULTRA_BLACK = 950, }} ENUM!{enum DWRITE_FONT_STRETCH { DWRITE_FONT_STRETCH_UNDEFINED = 0, DWRITE_FONT_STRETCH_ULTRA_CONDENSED = 1, DWRITE_FONT_STRETCH_EXTRA_CONDENSED = 2, DWRITE_FONT_STRETCH_CONDENSED = 3, DWRITE_FONT_STRETCH_SEMI_CONDENSED = 4, DWRITE_FONT_STRETCH_NORMAL = 5, DWRITE_FONT_STRETCH_MEDIUM = 5, DWRITE_FONT_STRETCH_SEMI_EXPANDED = 6, DWRITE_FONT_STRETCH_EXPANDED = 7, DWRITE_FONT_STRETCH_EXTRA_EXPANDED = 8, DWRITE_FONT_STRETCH_ULTRA_EXPANDED = 9, }} ENUM!{enum DWRITE_FONT_STYLE { DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STYLE_OBLIQUE, DWRITE_FONT_STYLE_ITALIC, }} ENUM!{enum DWRITE_INFORMATIONAL_STRING_ID { DWRITE_INFORMATIONAL_STRING_NONE, DWRITE_INFORMATIONAL_STRING_COPYRIGHT_NOTICE, DWRITE_INFORMATIONAL_STRING_VERSION_STRINGS, DWRITE_INFORMATIONAL_STRING_TRADEMARK, DWRITE_INFORMATIONAL_STRING_MANUFACTURER, DWRITE_INFORMATIONAL_STRING_DESIGNER, DWRITE_INFORMATIONAL_STRING_DESIGNER_URL, DWRITE_INFORMATIONAL_STRING_DESCRIPTION, DWRITE_INFORMATIONAL_STRING_FONT_VENDOR_URL, DWRITE_INFORMATIONAL_STRING_LICENSE_DESCRIPTION, DWRITE_INFORMATIONAL_STRING_LICENSE_INFO_URL, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, DWRITE_INFORMATIONAL_STRING_WIN32_SUBFAMILY_NAMES, DWRITE_INFORMATIONAL_STRING_PREFERRED_FAMILY_NAMES, DWRITE_INFORMATIONAL_STRING_PREFERRED_SUBFAMILY_NAMES, DWRITE_INFORMATIONAL_STRING_SAMPLE_TEXT, DWRITE_INFORMATIONAL_STRING_FULL_NAME, DWRITE_INFORMATIONAL_STRING_POSTSCRIPT_NAME, DWRITE_INFORMATIONAL_STRING_POSTSCRIPT_CID_NAME, DWRITE_INFORMATIONAL_STRING_WWS_FAMILY_NAME, DWRITE_INFORMATIONAL_STRING_DESIGN_SCRIPT_LANGUAGE_TAG, DWRITE_INFORMATIONAL_STRING_SUPPORTED_SCRIPT_LANGUAGE_TAG, }} STRUCT!{struct DWRITE_FONT_METRICS { designUnitsPerEm: ::UINT16, ascent: ::UINT16, descent: ::UINT16, lineGap: ::INT16, capHeight: ::UINT16, xHeight: ::UINT16, underlinePosition: ::INT16, underlineThickness: ::UINT16, strikethroughPosition: ::INT16, strikethroughThickness: ::UINT16, }} STRUCT!{struct DWRITE_GLYPH_METRICS { leftSideBearing: ::INT32, advanceWidth: ::UINT32, rightSideBearing: ::INT32, topSideBearing: ::INT32, advanceHeight: ::UINT32, bottomSideBearing: ::INT32, verticalOriginY: ::INT32, }} STRUCT!{struct DWRITE_GLYPH_OFFSET { advanceOffset: ::FLOAT, ascenderOffset: ::FLOAT, }} ENUM!{enum DWRITE_FACTORY_TYPE { DWRITE_FACTORY_TYPE_SHARED, DWRITE_FACTORY_TYPE_ISOLATED, }} #[inline] pub fn DWRITE_MAKE_OPENTYPE_TAG(a: u8, b: u8, c: u8, d: u8) -> u32 { ((d as u32) << 24) | ((c as u32) << 16) | ((b as u32) << 8) | (a as u32) } RIDL!{interface IDWriteFontFileLoader(IDWriteFontFileLoaderVtbl): IUnknown(IUnknownVtbl) { fn CreateStreamFromKey( &mut self, fontFileReferenceKey: *const ::c_void, fontFileReferenceKeySize: ::UINT32, fontFileStream: *mut *mut IDWriteFontFileStream ) -> ::HRESULT }} RIDL!{interface IDWriteLocalFontFileLoader(IDWriteLocalFontFileLoaderVtbl): IDWriteFontFileLoader(IDWriteFontFileLoaderVtbl) { fn GetFilePathLengthFromKey( &mut self, fontFileReferenceKey: *const ::c_void, fontFileReferenceKeySize: ::UINT32, filePathLength: *mut ::UINT32 ) -> ::HRESULT, fn GetFilePathFromKey( &mut self, fontFileReferenceKey: *const ::c_void, fontFileReferenceKeySize: ::UINT32, filePath: *mut ::WCHAR, filePathSize: ::UINT32 ) -> ::HRESULT, fn GetLastWriteTimeFromKey( &mut self, fontFileReferenceKey: *const ::c_void, fontFileReferenceKeySize: ::UINT32, lastWriteTime: *mut ::FILETIME ) -> ::HRESULT }} RIDL!{interface IDWriteFontFileStream(IDWriteFontFileStreamVtbl): IUnknown(IUnknownVtbl) { fn ReadFileFragment( &mut self, fragmentStart: *mut *const ::c_void, fileOffset: ::UINT64, fragmentSize: ::UINT64, fragmentContext: *mut *mut ::c_void ) -> ::HRESULT, fn ReleaseFileFragment(&mut self, fragmentContext: *mut ::c_void) -> (), fn GetFileSize(&mut self, fileSize: *mut ::UINT64) -> ::HRESULT, fn GetLastWriteTime(&mut self, lastWriteTime: *mut ::UINT64) -> ::HRESULT }} RIDL!{interface IDWriteFontFile(IDWriteFontFileVtbl): IUnknown(IUnknownVtbl) { fn GetReferenceKey( &mut self, fontFileReferenceKey: *mut *const ::c_void, fontFileReferenceKeySize: *mut ::UINT32 ) -> ::HRESULT, fn GetLoader(&mut self, fontFileLoader: *mut *mut IDWriteFontFileLoader) -> ::HRESULT, fn Analyze( &mut self, isSupportedFontType: *mut ::BOOL, fontFileType: *mut DWRITE_FONT_FILE_TYPE, fontFaceType: *mut DWRITE_FONT_FACE_TYPE, numberOfFaces: *mut ::UINT32 ) -> ::HRESULT }} ENUM!{enum DWRITE_PIXEL_GEOMETRY { DWRITE_PIXEL_GEOMETRY_FLAT, DWRITE_PIXEL_GEOMETRY_RGB, DWRITE_PIXEL_GEOMETRY_BGR, }} ENUM!{enum DWRITE_RENDERING_MODE { DWRITE_RENDERING_MODE_DEFAULT, DWRITE_RENDERING_MODE_ALIASED, DWRITE_RENDERING_MODE_GDI_CLASSIC, DWRITE_RENDERING_MODE_GDI_NATURAL, DWRITE_RENDERING_MODE_NATURAL, DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC, DWRITE_RENDERING_MODE_OUTLINE, DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC = DWRITE_RENDERING_MODE_GDI_CLASSIC.0, DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL = DWRITE_RENDERING_MODE_GDI_NATURAL.0, DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL = DWRITE_RENDERING_MODE_NATURAL.0, DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC = DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC.0, }} STRUCT!{struct DWRITE_MATRIX { m11: ::FLOAT, m12: ::FLOAT, m21: ::FLOAT, m22: ::FLOAT, dx: ::FLOAT, dy: ::FLOAT, }} RIDL!{interface IDWriteRenderingParams(IDWriteRenderingParamsVtbl): IUnknown(IUnknownVtbl) { fn GetGamma(&mut self) -> ::FLOAT, fn GetEnhancedContrast(&mut self) -> ::FLOAT, fn GetClearTypeLevel(&mut self) -> ::FLOAT, fn GetPixelGeometry(&mut self) -> DWRITE_PIXEL_GEOMETRY, fn GetRenderingMode(&mut self) -> DWRITE_RENDERING_MODE }} pub type IDWriteGeometrySink = ::ID2D1SimplifiedGeometrySink; RIDL!{interface IDWriteFontFace(IDWriteFontFaceVtbl): IUnknown(IUnknownVtbl) { fn GetType(&mut self) -> DWRITE_FONT_FACE_TYPE, fn GetFiles( &mut self, numberOfFiles: *mut ::UINT32, fontFiles: *mut *mut IDWriteFontFile ) -> ::HRESULT, fn GetIndex(&mut self) -> ::UINT32, fn GetSimulations(&mut self) -> DWRITE_FONT_SIMULATIONS, fn IsSymbolFont(&mut self) -> ::BOOL, fn GetMetrics(&mut self, fontFaceMetrics: *mut DWRITE_FONT_METRICS) -> (), fn GetGlyphCount(&mut self) -> ::UINT16, fn GetDesignGlyphMetrics( &mut self, glyphIndices: *const ::UINT16, glyphCount: ::UINT32, glyphMetrics: *mut DWRITE_GLYPH_METRICS, isSideways: ::BOOL ) -> ::HRESULT, fn GetGlyphIndices( &mut self, codePoints: *const ::UINT32, codePointCount: ::UINT32, glyphIndices: *mut ::UINT16 ) -> ::HRESULT, fn TryGetFontTable( &mut self, openTypeTableTag: ::UINT32, tableData: *mut *const ::c_void, tableSize: *mut ::UINT32, tableContext: *mut *mut ::c_void, exists: *mut ::BOOL ) -> ::HRESULT, fn ReleaseFontTable( &mut self, tableContext: *mut ::c_void ) -> ::HRESULT, fn GetGlyphRunOutline( &mut self, emSize: ::FLOAT, glyphIndices: *const ::UINT16, glyphAdvances: *const ::FLOAT, glyphOffsets: *const DWRITE_GLYPH_OFFSET, glyphCount: ::UINT32, isSideways: ::BOOL, isRightToLeft: ::BOOL, geometrySink: *mut IDWriteGeometrySink ) -> ::HRESULT, fn GetRecommendedRenderingMode( &mut self, emSize: ::FLOAT, pixelsPerDip: ::FLOAT, measuringMode: ::DWRITE_MEASURING_MODE, renderingParams: *mut IDWriteRenderingParams, renderingMode: *mut DWRITE_RENDERING_MODE ) -> ::HRESULT, fn GetGdiCompatibleMetrics( &mut self, emSize: ::FLOAT, pixelsPerDip: ::FLOAT, transform: *const DWRITE_MATRIX, fontFaceMetrics: *mut DWRITE_FONT_METRICS ) -> ::HRESULT, fn GetGdiCompatibleGlyphMetrics( &mut self, enSize: ::FLOAT, pixelsPerDip: ::FLOAT, transform: *const DWRITE_MATRIX, useGdiNatrual: ::BOOL, glyphIndices: *const ::UINT16, glyphCount: ::UINT32, glyphMetrics: *mut DWRITE_GLYPH_METRICS, isSideways: ::BOOL ) -> ::HRESULT }} RIDL!{interface IDWriteFontCollectionLoader(IDWriteFontCollectionLoaderVtbl): IUnknown(IUnknownVtbl) { fn CreateEnumeratorFromKey( &mut self, factory: *mut IDWriteFactory, collectionKey: *const ::c_void, collectionKeySize: ::UINT32, fontFileEnumerator: *mut *mut IDWriteFontFileEnumerator ) -> ::HRESULT }} RIDL!{interface IDWriteFontFileEnumerator(IDWriteFontFileEnumeratorVtbl): IUnknown(IUnknownVtbl) { fn MoveNext(&mut self, hasCurrentFile: *mut ::BOOL) -> ::HRESULT, fn GetCurrentFontFile(&mut self, fontFile: *mut *mut IDWriteFontFile) -> ::HRESULT }} RIDL!{interface IDWriteLocalizedStrings(IDWriteLocalizedStringsVtbl): IUnknown(IUnknownVtbl) { fn GetCount(&mut self) -> ::UINT32, fn FindLocaleName( &mut self, localeName: *const ::WCHAR, index: *mut ::UINT32, exists: *mut ::BOOL ) -> ::HRESULT, fn GetLocaleNameLength(&mut self, index: ::UINT32, length: *mut ::UINT32) -> ::HRESULT, fn GetLocaleName( &mut self, index: ::UINT32, localeName: *mut ::WCHAR, size: ::UINT32 ) -> ::HRESULT, fn GetStringLength(&mut self, index: ::UINT32, length: *mut ::UINT32) -> ::HRESULT, fn GetString( &mut self, index: ::UINT32, stringBuffer: *mut ::WCHAR, size: ::UINT32 ) -> ::HRESULT }} RIDL!{interface IDWriteFontCollection(IDWriteFontCollectionVtbl): IUnknown(IUnknownVtbl) { fn GetFontFamilyCount(&mut self) -> ::UINT32, fn GetFontFamily( &mut self, index: ::UINT32, fontFamily: *mut *mut IDWriteFontFamily ) -> ::HRESULT, fn FindFamilyName( &mut self, familyName: *const ::WCHAR, index: *mut ::UINT32, exists: *mut ::BOOL ) -> ::HRESULT, fn GetFontFromFontFace( &mut self, fontFace: *mut IDWriteFontFace, font: *mut *mut IDWriteFont ) -> ::HRESULT }} RIDL!{interface IDWriteFontList(IDWriteFontListVtbl): IUnknown(IUnknownVtbl) { fn GetFontCollection(&mut self, fontCollection: *mut *mut IDWriteFontCollection) -> ::HRESULT, fn GetFontCount(&mut self) -> ::UINT32, fn GetFont(&mut self, index: ::UINT32, font: *mut *mut IDWriteFont) -> ::HRESULT }} RIDL!{interface IDWriteFontFamily(IDWriteFontFamilyVtbl): IDWriteFontList(IDWriteFontListVtbl) { fn GetFamilyNames(&mut self, names: *mut *mut IDWriteLocalizedStrings) -> ::HRESULT, fn GetFirstMatchingFont( &mut self, weight: DWRITE_FONT_WEIGHT, stretch: DWRITE_FONT_STRETCH, style: DWRITE_FONT_STYLE, matchingFont: *mut *mut IDWriteFont ) -> ::HRESULT, fn GetMatchingFonts( &mut self, weight: DWRITE_FONT_WEIGHT, stretch: DWRITE_FONT_STRETCH, style: DWRITE_FONT_STYLE, matchingFonts: *mut *mut IDWriteFontList ) -> ::HRESULT }} RIDL!{interface IDWriteFont(IDWriteFontVtbl): IUnknown(IUnknownVtbl) { fn GetFontFamily(&mut self, fontFamily: *mut *mut IDWriteFontFamily) -> ::HRESULT, fn GetWeight(&mut self) -> DWRITE_FONT_WEIGHT, fn GetStretch(&mut self) -> DWRITE_FONT_STRETCH, fn GetStyle(&mut self) -> DWRITE_FONT_STYLE, fn IsSymbolFont(&mut self) -> ::BOOL, fn GetFaceNames(&mut self, names: *mut *mut IDWriteLocalizedStrings) -> ::HRESULT, fn GetInformationalStrings( &mut self, informationalStringId: DWRITE_INFORMATIONAL_STRING_ID, informationalStrings: *mut *mut IDWriteLocalizedStrings, exists: *mut ::BOOL ) -> ::HRESULT, fn GetSimulations(&mut self) -> DWRITE_FONT_SIMULATIONS, fn GetMetrics(&mut self, fontMetrics: *mut DWRITE_FONT_METRICS) -> (), fn HasCharacter(&mut self, unicodeValue: ::UINT32, exists: *mut ::BOOL) -> ::HRESULT, fn CreateFontFace(&mut self, fontFace: *mut *mut IDWriteFontFace) -> ::HRESULT }} ENUM!{enum DWRITE_READING_DIRECTION { DWRITE_READING_DIRECTION_LEFT_TO_RIGHT = 0, DWRITE_READING_DIRECTION_RIGHT_TO_LEFT = 1, DWRITE_READING_DIRECTION_TOP_TO_BOTTOM = 2, DWRITE_READING_DIRECTION_BOTTOM_TO_TOP = 3, }} ENUM!{enum DWRITE_FLOW_DIRECTION { DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM = 0, DWRITE_FLOW_DIRECTION_BOTTOM_TO_TOP = 1, DWRITE_FLOW_DIRECTION_LEFT_TO_RIGHT = 2, DWRITE_FLOW_DIRECTION_RIGHT_TO_LEFT = 3, }} ENUM!{enum DWRITE_TEXT_ALIGNMENT { DWRITE_TEXT_ALIGNMENT_LEADING, DWRITE_TEXT_ALIGNMENT_TRAILING, DWRITE_TEXT_ALIGNMENT_CENTER, DWRITE_TEXT_ALIGNMENT_JUSTIFIED, }} ENUM!{enum DWRITE_PARAGRAPH_ALIGNMENT { DWRITE_PARAGRAPH_ALIGNMENT_NEAR, DWRITE_PARAGRAPH_ALIGNMENT_FAR, DWRITE_PARAGRAPH_ALIGNMENT_CENTER, }} ENUM!{enum DWRITE_WORD_WRAPPING { DWRITE_WORD_WRAPPING_WRAP = 0, DWRITE_WORD_WRAPPING_NO_WRAP = 1, DWRITE_WORD_WRAPPING_EMERGENCY_BREAK = 2, DWRITE_WORD_WRAPPING_WHOLE_WORD = 3, DWRITE_WORD_WRAPPING_CHARACTER = 4, }} ENUM!{enum DWRITE_LINE_SPACING_METHOD { DWRITE_LINE_SPACING_METHOD_DEFAULT, DWRITE_LINE_SPACING_METHOD_UNIFORM, DWRITE_LINE_SPACING_METHOD_PROPORTIONAL, }} ENUM!{enum DWRITE_TRIMMING_GRANULARITY { DWRITE_TRIMMING_GRANULARITY_NONE, DWRITE_TRIMMING_GRANULARITY_CHARACTER, DWRITE_TRIMMING_GRANULARITY_WORD, }} ENUM!{enum DWRITE_FONT_FEATURE_TAG { DWRITE_FONT_FEATURE_TAG_ALTERNATIVE_FRACTIONS = 0x63726661, // 'afrc' DWRITE_FONT_FEATURE_TAG_PETITE_CAPITALS_FROM_CAPITALS = 0x63703263, // 'c2pc' DWRITE_FONT_FEATURE_TAG_SMALL_CAPITALS_FROM_CAPITALS = 0x63733263, // 'c2sc' DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_ALTERNATES = 0x746c6163, // 'calt' DWRITE_FONT_FEATURE_TAG_CASE_SENSITIVE_FORMS = 0x65736163, // 'case' DWRITE_FONT_FEATURE_TAG_GLYPH_COMPOSITION_DECOMPOSITION = 0x706d6363, // 'ccmp' DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_LIGATURES = 0x67696c63, // 'clig' DWRITE_FONT_FEATURE_TAG_CAPITAL_SPACING = 0x70737063, // 'cpsp' DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_SWASH = 0x68777363, // 'cswh' DWRITE_FONT_FEATURE_TAG_CURSIVE_POSITIONING = 0x73727563, // 'curs' DWRITE_FONT_FEATURE_TAG_DEFAULT = 0x746c6664, // 'dflt' DWRITE_FONT_FEATURE_TAG_DISCRETIONARY_LIGATURES = 0x67696c64, // 'dlig' DWRITE_FONT_FEATURE_TAG_EXPERT_FORMS = 0x74707865, // 'expt' DWRITE_FONT_FEATURE_TAG_FRACTIONS = 0x63617266, // 'frac' DWRITE_FONT_FEATURE_TAG_FULL_WIDTH = 0x64697766, // 'fwid' DWRITE_FONT_FEATURE_TAG_HALF_FORMS = 0x666c6168, // 'half' DWRITE_FONT_FEATURE_TAG_HALANT_FORMS = 0x6e6c6168, // 'haln' DWRITE_FONT_FEATURE_TAG_ALTERNATE_HALF_WIDTH = 0x746c6168, // 'halt' DWRITE_FONT_FEATURE_TAG_HISTORICAL_FORMS = 0x74736968, // 'hist' DWRITE_FONT_FEATURE_TAG_HORIZONTAL_KANA_ALTERNATES = 0x616e6b68, // 'hkna' DWRITE_FONT_FEATURE_TAG_HISTORICAL_LIGATURES = 0x67696c68, // 'hlig' DWRITE_FONT_FEATURE_TAG_HALF_WIDTH = 0x64697768, // 'hwid' DWRITE_FONT_FEATURE_TAG_HOJO_KANJI_FORMS = 0x6f6a6f68, // 'hojo' DWRITE_FONT_FEATURE_TAG_JIS04_FORMS = 0x3430706a, // 'jp04' DWRITE_FONT_FEATURE_TAG_JIS78_FORMS = 0x3837706a, // 'jp78' DWRITE_FONT_FEATURE_TAG_JIS83_FORMS = 0x3338706a, // 'jp83' DWRITE_FONT_FEATURE_TAG_JIS90_FORMS = 0x3039706a, // 'jp90' DWRITE_FONT_FEATURE_TAG_KERNING = 0x6e72656b, // 'kern' DWRITE_FONT_FEATURE_TAG_STANDARD_LIGATURES = 0x6167696c, // 'liga' DWRITE_FONT_FEATURE_TAG_LINING_FIGURES = 0x6d756e6c, // 'lnum' DWRITE_FONT_FEATURE_TAG_LOCALIZED_FORMS = 0x6c636f6c, // 'locl' DWRITE_FONT_FEATURE_TAG_MARK_POSITIONING = 0x6b72616d, // 'mark' DWRITE_FONT_FEATURE_TAG_MATHEMATICAL_GREEK = 0x6b72676d, // 'mgrk' DWRITE_FONT_FEATURE_TAG_MARK_TO_MARK_POSITIONING = 0x6b6d6b6d, // 'mkmk' DWRITE_FONT_FEATURE_TAG_ALTERNATE_ANNOTATION_FORMS = 0x746c616e, // 'nalt' DWRITE_FONT_FEATURE_TAG_NLC_KANJI_FORMS = 0x6b636c6e, // 'nlck' DWRITE_FONT_FEATURE_TAG_OLD_STYLE_FIGURES = 0x6d756e6f, // 'onum' DWRITE_FONT_FEATURE_TAG_ORDINALS = 0x6e64726f, // 'ordn' DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_ALTERNATE_WIDTH = 0x746c6170, // 'palt' DWRITE_FONT_FEATURE_TAG_PETITE_CAPITALS = 0x70616370, // 'pcap' DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_FIGURES = 0x6d756e70, // 'pnum' DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_WIDTHS = 0x64697770, // 'pwid' DWRITE_FONT_FEATURE_TAG_QUARTER_WIDTHS = 0x64697771, // 'qwid' DWRITE_FONT_FEATURE_TAG_REQUIRED_LIGATURES = 0x67696c72, // 'rlig' DWRITE_FONT_FEATURE_TAG_RUBY_NOTATION_FORMS = 0x79627572, // 'ruby' DWRITE_FONT_FEATURE_TAG_STYLISTIC_ALTERNATES = 0x746c6173, // 'salt' DWRITE_FONT_FEATURE_TAG_SCIENTIFIC_INFERIORS = 0x666e6973, // 'sinf' DWRITE_FONT_FEATURE_TAG_SMALL_CAPITALS = 0x70636d73, // 'smcp' DWRITE_FONT_FEATURE_TAG_SIMPLIFIED_FORMS = 0x6c706d73, // 'smpl' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_1 = 0x31307373, // 'ss01' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_2 = 0x32307373, // 'ss02' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_3 = 0x33307373, // 'ss03' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_4 = 0x34307373, // 'ss04' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_5 = 0x35307373, // 'ss05' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_6 = 0x36307373, // 'ss06' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_7 = 0x37307373, // 'ss07' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_8 = 0x38307373, // 'ss08' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_9 = 0x39307373, // 'ss09' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_10 = 0x30317373, // 'ss10' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_11 = 0x31317373, // 'ss11' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_12 = 0x32317373, // 'ss12' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_13 = 0x33317373, // 'ss13' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_14 = 0x34317373, // 'ss14' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_15 = 0x35317373, // 'ss15' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_16 = 0x36317373, // 'ss16' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_17 = 0x37317373, // 'ss17' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_18 = 0x38317373, // 'ss18' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_19 = 0x39317373, // 'ss19' DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_20 = 0x30327373, // 'ss20' DWRITE_FONT_FEATURE_TAG_SUBSCRIPT = 0x73627573, // 'subs' DWRITE_FONT_FEATURE_TAG_SUPERSCRIPT = 0x73707573, // 'sups' DWRITE_FONT_FEATURE_TAG_SWASH = 0x68737773, // 'swsh' DWRITE_FONT_FEATURE_TAG_TITLING = 0x6c746974, // 'titl' DWRITE_FONT_FEATURE_TAG_TRADITIONAL_NAME_FORMS = 0x6d616e74, // 'tnam' DWRITE_FONT_FEATURE_TAG_TABULAR_FIGURES = 0x6d756e74, // 'tnum' DWRITE_FONT_FEATURE_TAG_TRADITIONAL_FORMS = 0x64617274, // 'trad' DWRITE_FONT_FEATURE_TAG_THIRD_WIDTHS = 0x64697774, // 'twid' DWRITE_FONT_FEATURE_TAG_UNICASE = 0x63696e75, // 'unic' DWRITE_FONT_FEATURE_TAG_VERTICAL_WRITING = 0x74726576, // 'vert' DWRITE_FONT_FEATURE_TAG_VERTICAL_ALTERNATES_AND_ROTATION = 0x32747276, // 'vrt2' DWRITE_FONT_FEATURE_TAG_SLASHED_ZERO = 0x6f72657a, // 'zero' }} STRUCT!{struct DWRITE_TEXT_RANGE { startPosition: ::UINT32, length: ::UINT32, }} STRUCT!{struct DWRITE_FONT_FEATURE { nameTag: DWRITE_FONT_FEATURE_TAG, parameter: ::UINT32, }} STRUCT!{struct DWRITE_TYPOGRAPHIC_FEATURES { features: *mut DWRITE_FONT_FEATURE, featureCount: ::UINT32, }} STRUCT!{struct DWRITE_TRIMMING { granularity: DWRITE_TRIMMING_GRANULARITY, delimiter: ::UINT32, delimiterCount: ::UINT32, }} RIDL!{interface IDWriteTextFormat(IDWriteTextFormatVtbl): IUnknown(IUnknownVtbl) { fn SetTextAlignment(&mut self, textAlignment: DWRITE_TEXT_ALIGNMENT) -> ::HRESULT, fn SetParagraphAlignment( &mut self, paragraphAlignment: DWRITE_PARAGRAPH_ALIGNMENT ) -> ::HRESULT, fn SetWordWrapping(&mut self, wordWrapping: DWRITE_WORD_WRAPPING) -> ::HRESULT, fn SetReadingDirection(&mut self, readingDirection: DWRITE_READING_DIRECTION) -> ::HRESULT, fn SetFlowDirection(&mut self, flowDirection: DWRITE_FLOW_DIRECTION) -> ::HRESULT, fn SetIncrementalTabStop(&mut self, incrementalTabStop: ::FLOAT) -> ::HRESULT, fn SetTrimming( &mut self, trimmingOptions: *const DWRITE_TRIMMING, trimmingSign: *mut IDWriteInlineObject ) -> ::HRESULT, fn SetLineSpacing( &mut self, lineSpacingMethod: DWRITE_LINE_SPACING_METHOD, lineSpacing: ::FLOAT, baseLine: ::FLOAT ) -> ::HRESULT, fn GetTextAlignment(&mut self) -> DWRITE_TEXT_ALIGNMENT, fn GetParagraphAlignment(&mut self) -> DWRITE_PARAGRAPH_ALIGNMENT, fn GetWordWrapping(&mut self) -> DWRITE_WORD_WRAPPING, fn GetReadingDirection(&mut self) -> DWRITE_READING_DIRECTION, fn GetFlowDirection(&mut self) -> DWRITE_FLOW_DIRECTION, fn GetIncrementalTabStop(&mut self) -> ::FLOAT, fn GetTrimming( &mut self, trimmingOptions: *mut DWRITE_TRIMMING, trimmingSign: *mut *mut IDWriteInlineObject ) -> ::HRESULT, fn GetLineSpacing( &mut self, lineSpacingMethod: *mut DWRITE_LINE_SPACING_METHOD, lineSpacing: *mut ::FLOAT, baseline: *mut ::FLOAT ) -> ::HRESULT, fn GetFontCollection(&mut self, fontCollection: *mut *mut IDWriteFontCollection) -> ::HRESULT, fn GetFontFamilyNameLength(&mut self) -> ::UINT32, fn GetFontFamilyName(&mut self, fontFamilyName: *mut ::WCHAR, nameSize: ::UINT32) -> ::HRESULT, fn GetFontWeight(&mut self) -> DWRITE_FONT_WEIGHT, fn GetFontStyle(&mut self) -> DWRITE_FONT_STYLE, fn GetFontStretch(&mut self) -> DWRITE_FONT_STRETCH, fn GetFontSize(&mut self) -> ::FLOAT, fn GetLocaleNameLength(&mut self) -> ::UINT32, fn GetLocaleName(&mut self, localeName: *mut ::WCHAR, nameSize: ::UINT32) -> ::HRESULT }} RIDL!{interface IDWriteTypography(IDWriteTypographyVtbl): IUnknown(IUnknownVtbl) { fn AddFontFeature(&mut self, fontFeature: DWRITE_FONT_FEATURE) -> ::HRESULT, fn GetFontFeatureCount(&mut self) -> ::UINT32, fn GetFontFeature( &mut self, fontFeatureIndex: ::UINT32, fontFeature: *mut DWRITE_FONT_FEATURE ) -> ::HRESULT }} FLAGS!{enum DWRITE_SCRIPT_SHAPES { DWRITE_SCRIPT_SHAPES_DEFAULT = 0, DWRITE_SCRIPT_SHAPES_NO_VISUAL = 1, }} STRUCT!{struct DWRITE_SCRIPT_ANALYSIS { script: ::UINT16, shapes: DWRITE_SCRIPT_SHAPES, }} ENUM!{enum DWRITE_BREAK_CONDITION { DWRITE_BREAK_CONDITION_NEUTRAL, DWRITE_BREAK_CONDITION_CAN_BREAK, DWRITE_BREAK_CONDITION_MAY_NOT_BREAK, DWRITE_BREAK_CONDITION_MUST_BREAK, }} STRUCT!{struct DWRITE_LINE_BREAKPOINT { bit_fields: ::UINT8, }} BITFIELD!{DWRITE_LINE_BREAKPOINT bit_fields: ::UINT8 [ breakConditionBefore set_breakConditionBefore[0..2], breakConditionAfter set_breakConditionAfter[2..4], isWhitespace set_isWhitespace[4..5], isSoftHyphen set_isSoftHyphen[5..6], padding set_padding[6..8], ]} ENUM!{enum DWRITE_NUMBER_SUBSTITUTION_METHOD { DWRITE_NUMBER_SUBSTITUTION_METHOD_FROM_CULTURE, DWRITE_NUMBER_SUBSTITUTION_METHOD_CONTEXTUAL, DWRITE_NUMBER_SUBSTITUTION_METHOD_NONE, DWRITE_NUMBER_SUBSTITUTION_METHOD_NATIONAL, DWRITE_NUMBER_SUBSTITUTION_METHOD_TRADITIONAL, }} RIDL!{interface IDWriteNumberSubstitution(IDWriteNumberSubstitutionVtbl): IUnknown(IUnknownVtbl) { }} STRUCT!{struct DWRITE_SHAPING_TEXT_PROPERTIES { bit_fields: ::UINT16, }} BITFIELD!{DWRITE_SHAPING_TEXT_PROPERTIES bit_fields: ::UINT16 [ isShapedAlone set_isShapedAlone[0..1], reserved set_reserved[1..16], ]} STRUCT!{struct DWRITE_SHAPING_GLYPH_PROPERTIES { bit_fields: ::UINT16, }} BITFIELD!{DWRITE_SHAPING_GLYPH_PROPERTIES bit_fields: ::UINT16 [ justification set_justification[0..4], isClusterStart set_isClusterStart[4..5], isDiacritic set_isDiacritic[5..6], isZeroWidthSpace set_isZeroWidthSpace[6..7], reserved set_reserved[7..16], ]} RIDL!{interface IDWriteTextAnalysisSource(IDWriteTextAnalysisSourceVtbl): IUnknown(IUnknownVtbl) { fn GetTextAtPosition( &mut self, textPosition: ::UINT32, textString: *mut *const ::WCHAR, textLength: *mut ::UINT32 ) -> ::HRESULT, fn GetTextBeforePosition( &mut self, textPosition: ::UINT32, textString: *mut *const ::WCHAR, textLength: *mut ::UINT32 ) -> ::HRESULT, fn GetParagraphReadingDirection(&mut self) -> DWRITE_READING_DIRECTION, fn GetLocaleName( &mut self, textPosition: ::UINT32, textLength: *mut ::UINT32, localeName: *mut *const ::WCHAR ) -> ::HRESULT, fn GetNumberSubstitution( &mut self, textPosition: ::UINT32, textLength: *mut ::UINT32, numberSubstitution: *mut *mut IDWriteNumberSubstitution ) -> ::HRESULT }} RIDL!{interface IDWriteTextAnalysisSink(IDWriteTextAnalysisSinkVtbl): IUnknown(IUnknownVtbl) { fn SetScriptAnalysis( &mut self, textPosition: ::UINT32, textLength: ::UINT32, scriptAnalysis: *const DWRITE_SCRIPT_ANALYSIS ) -> ::HRESULT, fn SetLineBreakpoints( &mut self, textPosition: ::UINT32, textLength: ::UINT32, lineBreakpoints: *const DWRITE_LINE_BREAKPOINT ) -> ::HRESULT, fn SetBidiLevel( &mut self, textPosition: ::UINT32, textLength: ::UINT32, explicitLevel: ::UINT8, resolvedLevel: ::UINT8 ) -> ::HRESULT, fn SetNumberSubstitution( &mut self, textPosition: ::UINT32, textLength: ::UINT32, numberSubstitution: *mut IDWriteNumberSubstitution ) -> ::HRESULT }} RIDL!{interface IDWriteTextAnalyzer(IDWriteTextAnalyzerVtbl): IUnknown(IUnknownVtbl) { fn AnalyzeScript( &mut self, analysisSource: *mut IDWriteTextAnalysisSource, textPosition: ::UINT32, textLength: ::UINT32, analysisSink: *mut IDWriteTextAnalysisSink ) -> ::HRESULT, fn AnalyzeBidi( &mut self, analysisSource: *mut IDWriteTextAnalysisSource, textPosition: ::UINT32, textLength: ::UINT32, analysisSink: *mut IDWriteTextAnalysisSink ) -> ::HRESULT, fn AnalyzeNumberSubstitution( &mut self, analysisSource: *mut IDWriteTextAnalysisSource, textPosition: ::UINT32, textLength: ::UINT32, analysisSink: *mut IDWriteTextAnalysisSink ) -> ::HRESULT, fn AnalyzeLineBreakpoints( &mut self, analysisSource: *mut IDWriteTextAnalysisSource, textPosition: ::UINT32, textLength: ::UINT32, analysisSink: *mut IDWriteTextAnalysisSink ) -> ::HRESULT, fn GetGlyphs( &mut self, textString: *const ::WCHAR, textLength: ::UINT32, fontFace: *mut IDWriteFontFace, isSideways: ::BOOL, isRightToLeft: ::BOOL, scriptAnalysis: *const DWRITE_SCRIPT_ANALYSIS, localeName: *const ::WCHAR, numberSubstitution: *mut IDWriteNumberSubstitution, features: *mut *const DWRITE_TYPOGRAPHIC_FEATURES, featureRangeLengths: *const ::UINT32, featureRanges: ::UINT32, maxGlyphCount: ::UINT32, clusterMap: *mut ::UINT16, textProps: *mut DWRITE_SHAPING_TEXT_PROPERTIES, glyphIndices: *mut ::UINT16, glyphProps: *mut DWRITE_SHAPING_GLYPH_PROPERTIES, actualGlyphCount: *mut ::UINT32 ) -> ::HRESULT, fn GetGlyphPlacements( &mut self, textString: *const ::WCHAR, clusterMap: *const ::UINT16, textProps: *mut DWRITE_SHAPING_TEXT_PROPERTIES, textLength: ::UINT32, glyphIndices: *const ::UINT16, glyphProps: *const DWRITE_SHAPING_GLYPH_PROPERTIES, glyphCount: ::UINT32, fontFace: *mut IDWriteFontFace, fontEmSize: ::FLOAT, isSideways: ::BOOL, isRightToLeft: ::BOOL, scriptAnalysis: *const DWRITE_SCRIPT_ANALYSIS, localeName: *const ::WCHAR, features: *mut *const DWRITE_TYPOGRAPHIC_FEATURES, featureRangeLengths: *const ::UINT32, featureRanges: ::UINT32, glyphAdvances: *mut ::FLOAT, glyphOffsets: *mut DWRITE_GLYPH_OFFSET ) -> ::HRESULT, fn GetGdiCompatibleGlyphPlacements( &mut self, textString: *const ::WCHAR, clusterMap: *const ::UINT16, textProps: *mut DWRITE_SHAPING_TEXT_PROPERTIES, textLength: ::UINT32, glyphIndices: *const ::UINT16, glyphProps: *const DWRITE_SHAPING_GLYPH_PROPERTIES, glyphCount: ::UINT32, fontFace: *mut IDWriteFontFace, fontEmSize: ::FLOAT, pixelsPerDip: ::FLOAT, transform: *const DWRITE_MATRIX, useGdiNatrual: ::BOOL, isSideways: ::BOOL, isRightToLeft: ::BOOL, scriptAnalysis: *const DWRITE_SCRIPT_ANALYSIS, localeName: *const ::WCHAR, features: *mut *const DWRITE_TYPOGRAPHIC_FEATURES, featureRangeLengths: *const ::UINT32, featureRanges: ::UINT32, glyphAdvances: *mut ::FLOAT, glyphOffsets: *mut DWRITE_GLYPH_OFFSET ) -> ::HRESULT }} STRUCT!{struct DWRITE_GLYPH_RUN { fontFace: *mut IDWriteFontFace, fontEmSize: ::FLOAT, glyphCount: ::UINT32, glyphIndices: *const ::UINT16, glyphAdvances: *const ::FLOAT, glyphOffsets: *const DWRITE_GLYPH_OFFSET, isSideways: ::BOOL, bidiLevel: ::UINT32, }} STRUCT!{struct DWRITE_GLYPH_RUN_DESCRIPTION { localeName: *const ::WCHAR, string: *const ::WCHAR, stringLength: ::UINT32, clusterMap: *const ::UINT16, textPosition: ::UINT32, }} STRUCT!{struct DWRITE_UNDERLINE { width: ::FLOAT, thickness: ::FLOAT, offset: ::FLOAT, runHeight: ::FLOAT, readingDirection: DWRITE_READING_DIRECTION, flowDirection: DWRITE_FLOW_DIRECTION, localeName: *const ::WCHAR, measuringMode: ::DWRITE_MEASURING_MODE, }} STRUCT!{struct DWRITE_STRIKETHROUGH { width: ::FLOAT, thickness: ::FLOAT, offset: ::FLOAT, readingDirection: DWRITE_READING_DIRECTION, flowDirection: DWRITE_FLOW_DIRECTION, localeName: *const ::WCHAR, measuringMode: ::DWRITE_MEASURING_MODE, }} STRUCT!{struct DWRITE_LINE_METRICS { length: ::UINT32, trailingWhitespaceLength: ::UINT32, newlineLength: ::UINT32, height: ::FLOAT, baseline: ::FLOAT, isTrimmed: ::BOOL, }} STRUCT!{struct DWRITE_CLUSTER_METRICS { width: ::FLOAT, length: ::UINT16, bit_fields: ::UINT16, }} BITFIELD!{DWRITE_CLUSTER_METRICS bit_fields: ::UINT16 [ canWrapLineAfter set_canWrapLineAfter[0..1], isWhitespace set_isWhitespace[1..2], isNewline set_isNewline[2..3], isSoftHyphen set_isSoftHyphen[3..4], isRightToLeft set_isRightToLeft[4..5], padding set_padding[5..16], ]} STRUCT!{struct DWRITE_TEXT_METRICS { left: ::FLOAT, top: ::FLOAT, width: ::FLOAT, widthIncludingTrailingWhitespace: ::FLOAT, height: ::FLOAT, layoutWidth: ::FLOAT, layoutHeight: ::FLOAT, maxBidiReorderingDepth: ::UINT32, lineCount: ::UINT32, }} STRUCT!{struct DWRITE_INLINE_OBJECT_METRICS { width: ::FLOAT, height: ::FLOAT, baseline: ::FLOAT, supportsSideways: ::BOOL, }} STRUCT!{struct DWRITE_OVERHANG_METRICS { left: ::FLOAT, top: ::FLOAT, right: ::FLOAT, bottom: ::FLOAT, }} STRUCT!{struct DWRITE_HIT_TEST_METRICS { textPosition: ::UINT32, length: ::UINT32, left: ::FLOAT, top: ::FLOAT, width: ::FLOAT, height: ::FLOAT, bidiLevel: ::UINT32, isText: ::BOOL, isTrimmed: ::BOOL, }} RIDL!{interface IDWriteInlineObject(IDWriteInlineObjectVtbl): IUnknown(IUnknownVtbl) { fn Draw( &mut self, clientDrawingContext: *mut ::c_void, renderer: *mut IDWriteTextRenderer, originX: ::FLOAT, originY: ::FLOAT, isSideways: ::BOOL, isRightToLeft: ::BOOL, clientDrawingEffect: *mut ::IUnknown ) -> ::HRESULT, fn GetMetrics(&mut self, metrics: *mut DWRITE_INLINE_OBJECT_METRICS) -> ::HRESULT, fn GetOverhangMetrics(&mut self, overhangs: *mut DWRITE_OVERHANG_METRICS) -> ::HRESULT, fn GetBreakConditions( &mut self, breakConditionBefore: *mut DWRITE_BREAK_CONDITION, breakConditionAfter: *mut DWRITE_BREAK_CONDITION ) -> ::HRESULT }} RIDL!{interface IDWritePixelSnapping(IDWritePixelSnappingVtbl): IUnknown(IUnknownVtbl) { fn IsPixelSnappingDisabled( &mut self, clientDrawingContext: *mut ::c_void, isDisabled: *mut ::BOOL ) -> ::HRESULT, fn GetCurrentTransform( &mut self, clientDrawingContext: *mut ::c_void, transform: *mut DWRITE_MATRIX ) -> ::HRESULT, fn GetPixelsPerDip( &mut self, clientDrawingContext: *mut ::c_void, pixelsPerDip: *mut ::FLOAT ) -> ::HRESULT }} RIDL!{interface IDWriteTextRenderer(IDWriteTextRendererVtbl): IDWritePixelSnapping(IDWritePixelSnappingVtbl) { fn DrawGlyphRun( &mut self, clientDrawingContext: *mut ::c_void, baselineOriginX: ::FLOAT, baselineOriginY: ::FLOAT, measuringMode: ::DWRITE_MEASURING_MODE, glyphRun: *const DWRITE_GLYPH_RUN, glyphRunDescription: *const DWRITE_GLYPH_RUN_DESCRIPTION, clientDrawingEffect: *mut ::IUnknown ) -> ::HRESULT, fn DrawUnderline( &mut self, clientDrawingContext: *mut ::c_void, baselineOriginX: ::FLOAT, baselineOriginY: ::FLOAT, underline: *const DWRITE_UNDERLINE, clientDrawingEffect: *mut ::IUnknown ) -> ::HRESULT, fn DrawStrikethrough( &mut self, clientDrawingContext: *mut ::c_void, baselineOriginX: ::FLOAT, baselineOriginY: ::FLOAT, strikethrough: *const DWRITE_STRIKETHROUGH, clientDrawingEffect: *mut ::IUnknown ) -> ::HRESULT, fn DrawInlineObject( &mut self, clientDrawingContext: *mut ::c_void, baselineOriginX: ::FLOAT, baselineOriginY: ::FLOAT, inlineObject: *mut IDWriteInlineObject, isSideways: ::BOOL, isRightToLeft: ::BOOL, clientDrawingEffect: *mut ::IUnknown ) -> ::HRESULT }} RIDL!{interface IDWriteTextLayout(IDWriteTextLayoutVtbl): IDWriteTextFormat(IDWriteTextFormatVtbl) { fn SetMaxWidth(&mut self, maxWidth: ::FLOAT) -> ::HRESULT, fn SetMaxHeight(&mut self, maxHeight: ::FLOAT) -> ::HRESULT, fn SetFontCollection( &mut self, fontCollection: *mut IDWriteFontCollection, textRange: DWRITE_TEXT_RANGE ) -> ::HRESULT, fn SetFontFamilyName( &mut self, fontFamilyName: *const ::WCHAR, textRange: DWRITE_TEXT_RANGE ) -> ::HRESULT, fn SetFontWeight( &mut self, fontWeight: DWRITE_FONT_WEIGHT, textRange: DWRITE_TEXT_RANGE ) -> ::HRESULT, fn SetFontStyle( &mut self, fontStyle: DWRITE_FONT_STYLE, textRange: DWRITE_TEXT_RANGE ) -> ::HRESULT, fn SetFontStretch( &mut self, fontStretch: DWRITE_FONT_STRETCH, textRange: DWRITE_TEXT_RANGE ) -> ::HRESULT, fn SetFontSize(&mut self, fontSize: ::FLOAT, textRange: DWRITE_TEXT_RANGE) -> ::HRESULT, fn SetUnderline(&mut self, hasUnderline: ::BOOL, textRange: DWRITE_TEXT_RANGE) -> ::HRESULT, fn SetStrikethrough( &mut self, hasStrikethrough: ::BOOL, textRange: DWRITE_TEXT_RANGE ) -> ::HRESULT, fn SetDrawingEffect( &mut self, drawingEffect: *mut ::IUnknown, textRange: DWRITE_TEXT_RANGE ) -> ::HRESULT, fn SetInlineObject( &mut self, inlineObject: *mut IDWriteInlineObject, textRange: DWRITE_TEXT_RANGE ) -> ::HRESULT, fn SetTypography( &mut self, typography: *mut IDWriteTypography, textRange: DWRITE_TEXT_RANGE ) -> ::HRESULT, fn SetLocaleName( &mut self, localeName: *const ::WCHAR, textRange: DWRITE_TEXT_RANGE ) -> ::HRESULT, fn GetMaxWidth(&mut self) -> ::FLOAT, fn GetMaxHeight(&mut self) -> ::FLOAT, fn GetFontCollection( &mut self, currentPosition: ::UINT32, fontCollection: *mut *mut IDWriteFontCollection, textRange: *mut DWRITE_TEXT_RANGE ) -> ::HRESULT, fn GetFontFamilyNameLength( &mut self, currentPosition: *mut ::UINT32, nameLength: *mut ::UINT32, textRange: *mut DWRITE_TEXT_RANGE ) -> ::HRESULT, fn GetFontFamilyName( &mut self, currentPosition: ::UINT32, fontFamilyName: *mut ::WCHAR, nameSize: ::UINT32, textRange: *mut DWRITE_TEXT_RANGE ) -> ::HRESULT, fn GetFontWeight( &mut self, currentPosition: ::UINT32, fontWeight: *mut DWRITE_FONT_WEIGHT, textRange: *mut DWRITE_TEXT_RANGE ) -> ::HRESULT, fn GetFontStyle( &mut self, currentPosition: ::UINT32, fontStyle: *mut DWRITE_FONT_STYLE, textRange: *mut DWRITE_TEXT_RANGE ) -> ::HRESULT, fn GetFontStretch( &mut self, currentPosition: ::UINT32, fontStretch: *mut DWRITE_FONT_STRETCH, textRange: *mut DWRITE_TEXT_RANGE ) -> ::HRESULT, fn GetFontSize( &mut self, currentPosition: ::UINT32, fontSize: *mut ::FLOAT, textRange: *mut DWRITE_TEXT_RANGE ) -> ::HRESULT, fn GetUnderline( &mut self, currentPosition: ::UINT32, hasUnderline: *mut ::BOOL, textRange: *mut DWRITE_TEXT_RANGE ) -> ::HRESULT, fn GetStrikethrough( &mut self, currentPosition: ::UINT32, hasStrikethrough: *mut ::BOOL, textRange: *mut DWRITE_TEXT_RANGE ) -> ::HRESULT, fn GetDrawingEffect( &mut self, currentPosition: ::UINT32, drawingEffect: *mut *mut ::IUnknown, textRange: *mut DWRITE_TEXT_RANGE ) -> ::HRESULT, fn GetInlineObject( &mut self, currentPosition: ::UINT32, inlineObject: *mut *mut IDWriteInlineObject, textRange: *mut DWRITE_TEXT_RANGE ) -> ::HRESULT, fn GetTypography( &mut self, currentPosition: ::UINT32, typography: *mut *mut IDWriteTypography, textRange: *mut DWRITE_TEXT_RANGE ) -> ::HRESULT, fn GetLocaleNameLength( &mut self, currentPosition: ::UINT32, nameLength: *mut ::UINT32, textRange: *mut DWRITE_TEXT_RANGE ) -> ::HRESULT, fn GetLocaleName( &mut self, currentPosition: ::UINT32, localeName: *mut ::WCHAR, nameSize: ::UINT32, textRange: *mut DWRITE_TEXT_RANGE ) -> ::HRESULT, fn Draw( &mut self, clientDrawingContext: *mut ::c_void, renderer: *mut IDWriteTextRenderer, originX: ::FLOAT, originY: ::FLOAT ) -> ::HRESULT, fn GetLineMetrics( &mut self, lineMetrics: *mut DWRITE_LINE_METRICS, maxLineCount: ::UINT32, actualLineCount: *mut ::UINT32 ) -> ::HRESULT, fn GetMetrics(&mut self, textMetrics: *mut DWRITE_TEXT_METRICS) -> ::HRESULT, fn GetOverhangMetrics(&mut self, overhangs: *mut DWRITE_OVERHANG_METRICS) -> ::HRESULT, fn GetClusterMetrics( &mut self, clusterMetrics: *mut DWRITE_CLUSTER_METRICS, maxClusterCount: ::UINT32, actualClusterCount: *mut ::UINT32 ) -> ::HRESULT, fn DetermineMinWidth(&mut self, minWidth: *mut ::FLOAT) -> ::HRESULT, fn HitTestPoint( &mut self, pointX: ::FLOAT, pointY: ::FLOAT, isTrailingHit: *mut ::BOOL, isInside: *mut ::BOOL, hitTestMetrics: *mut DWRITE_HIT_TEST_METRICS ) -> ::HRESULT, fn HitTestTextPosition( &mut self, textPosition: ::UINT32, isTrailingHit: ::BOOL, pointX: *mut ::FLOAT, pointY: *mut ::FLOAT, hitTestMetrics: *mut DWRITE_HIT_TEST_METRICS ) -> ::HRESULT, fn HitTestTextRange( &mut self, textPosition: ::UINT32, textLength: ::UINT32, originX: ::FLOAT, originY: ::FLOAT, hitTestMetrics: *mut DWRITE_HIT_TEST_METRICS, maxHitTestMetricsCount: ::UINT32, actualHitTestMetricsCount: *mut ::UINT32 ) -> ::HRESULT }} RIDL!{interface IDWriteBitmapRenderTarget(IDWriteBitmapRenderTargetVtbl): IUnknown(IUnknownVtbl) { fn DrawGlyphRun( &mut self, baselineOriginX: ::FLOAT, baselineOriginY: ::FLOAT, measuringMode: ::DWRITE_MEASURING_MODE, glyphRun: *const ::c_void, renderingParams: *mut IDWriteRenderingParams, textColor: ::COLORREF, blackBoxRect: *mut ::RECT ) -> ::HRESULT, fn GetMemoryDC(&mut self) -> ::HDC, fn GetPixelsPerDip(&mut self) -> ::FLOAT, fn SetPixelsPerDip(&mut self, pixelsPerDip: ::FLOAT) -> ::HRESULT, fn GetCurrentTransform(&mut self, transform: *mut DWRITE_MATRIX) -> ::HRESULT, fn SetCurrentTransform(&mut self, transform: *const DWRITE_MATRIX) -> ::HRESULT, fn GetSize(&mut self, size: *mut ::SIZE) -> ::HRESULT, fn Resize(&mut self, width: ::UINT32, height: ::UINT32) -> ::HRESULT }} RIDL!{interface IDWriteGdiInterop(IDWriteGdiInteropVtbl): IUnknown(IUnknownVtbl) { fn CreateFontFromLOGFONT( &mut self, logFont: *const ::LOGFONTW, font: *mut *mut IDWriteFont ) -> ::HRESULT, fn ConvertFontToLOGFONT( &mut self, font: *mut IDWriteFont, logFont: *mut ::LOGFONTW, isSystemFont: *mut ::BOOL ) -> ::HRESULT, fn ConvertFontFaceToLOGFONT( &mut self, font: *mut IDWriteFontFace, logFont: *mut ::LOGFONTW ) -> ::HRESULT, fn CreateFontFaceFromHdc( &mut self, hdc: ::HDC, fontFace: *mut *mut IDWriteFontFace ) -> ::HRESULT, fn CreateBitmapRenderTarget( &mut self, hdc: ::HDC, width: ::UINT32, height: ::UINT32, renderTarget: *mut *mut IDWriteBitmapRenderTarget ) -> ::HRESULT }} ENUM!{enum DWRITE_TEXTURE_TYPE { DWRITE_TEXTURE_ALIASED_1x1 = 0, DWRITE_TEXTURE_CLEARTYPE_3x1 = 1, }} pub const DWRITE_ALPHA_MAX: ::BYTE = 255; RIDL!{interface IDWriteGlyphRunAnalysis(IDWriteGlyphRunAnalysisVtbl): IUnknown(IUnknownVtbl) { fn GetAlphaTextureBounds( &mut self, textureType: DWRITE_TEXTURE_TYPE, textureBounds: *mut ::RECT ) -> ::HRESULT, fn CreateAlphaTexture( &mut self, textureType: DWRITE_TEXTURE_TYPE, textureBounds: *const ::RECT, alphaValues: *mut ::BYTE, bufferSize: ::UINT32 ) -> ::HRESULT, fn GetAlphaBlendParams( &mut self, renderingParams: *mut IDWriteRenderingParams, blendGamma: *mut ::FLOAT, blendEnhancedContrast: *mut ::FLOAT, blendClearTypeLevel: *mut ::FLOAT ) -> ::HRESULT }} RIDL!{interface IDWriteFactory(IDWriteFactoryVtbl): IUnknown(IUnknownVtbl) { fn GetSystemFontCollection( &mut self, fontCollection: *mut *mut IDWriteFontCollection, checkForUpdates: ::BOOL ) -> ::HRESULT, fn CreateCustomFontCollection( &mut self, collectionLoader: *mut IDWriteFontCollectionLoader, collectionKey: *const ::c_void, collectionKeySize: ::UINT32, fontCollection: *mut *mut IDWriteFontCollection ) -> ::HRESULT, fn RegisterFontCollectionLoader( &mut self, fontCollectionLoader: *mut IDWriteFontCollectionLoader ) -> ::HRESULT, fn UnregisterFontCollectionLoader( &mut self, fontCollectionLoader: *mut IDWriteFontCollectionLoader ) -> ::HRESULT, fn CreateFontFileReference( &mut self, filePath: *const ::WCHAR, lastWriteTime: *const ::FILETIME, fontFile: *mut *mut IDWriteFontFile ) -> ::HRESULT, fn CreateCustomFontFileReference( &mut self, fontFileReferenceKey: *const ::c_void, fontFileReferenceKeySize: ::UINT32, fontFileLoader: *mut IDWriteFontFileLoader, fontFile: *mut *mut IDWriteFontFile ) -> ::HRESULT, fn CreateFontFace( &mut self, fontFaceType: DWRITE_FONT_FACE_TYPE, numberOfFiles: ::UINT32, fontFiles: *const *mut IDWriteFontFile, faceIndex: ::UINT32, fontFaceSimulationFlags: DWRITE_FONT_SIMULATIONS, fontFace: *mut *mut IDWriteFontFace ) -> ::HRESULT, fn CreateRenderingParams( &mut self, renderingParams: *mut *mut IDWriteRenderingParams ) -> ::HRESULT, fn CreateMonitorRenderingParams( &mut self, monitor: ::HMONITOR, renderingParams: *mut *mut IDWriteRenderingParams ) -> ::HRESULT, fn CreateCustomRenderingParams( &mut self, gamma: ::FLOAT, enhancedContrast: ::FLOAT, clearTypeLevel: ::FLOAT, pixelGeometry: DWRITE_PIXEL_GEOMETRY, renderingMode: DWRITE_RENDERING_MODE, renderingParams: *mut *mut IDWriteRenderingParams ) -> ::HRESULT, fn RegisterFontFileLoader( &mut self, fontFileLoader: *mut IDWriteFontFileLoader ) -> ::HRESULT, fn UnregisterFontFileLoader( &mut self, fontFileLoader: *mut IDWriteFontFileLoader ) -> ::HRESULT, fn CreateTextFormat( &mut self, fontFamilyName: *const ::WCHAR, fontCollection: *mut IDWriteFontCollection, fontWeight: DWRITE_FONT_WEIGHT, fontStyle: DWRITE_FONT_STYLE, fontStretch: DWRITE_FONT_STRETCH, fontSize: ::FLOAT, localeName: *const ::WCHAR, textFormat: *mut *mut IDWriteTextFormat ) -> ::HRESULT, fn CreateTypography(&mut self, typography: *mut *mut IDWriteTypography) -> ::HRESULT, fn GetGdiInterop(&mut self, gdiInterop: *mut *mut IDWriteGdiInterop) -> ::HRESULT, fn CreateTextLayout( &mut self, string: *const ::WCHAR, stringLength: ::UINT32, textFormat: *mut IDWriteTextFormat, maxWidth: ::FLOAT, maxHeight: ::FLOAT, textLayout: *mut *mut IDWriteTextLayout ) -> ::HRESULT, fn CreateGdiCompatibleTextLayout( &mut self, string: *const ::WCHAR, stringLength: ::UINT32, textFormat: *mut IDWriteTextFormat, layoutWidth: ::FLOAT, layoutHeight: ::FLOAT, pixelsPerDip: ::FLOAT, transform: *const DWRITE_MATRIX, useGdiNatrual: ::BOOL, textLayout: *mut *mut IDWriteTextLayout ) -> ::HRESULT, fn CreateEllipsisTrimmingSign( &mut self, textFormat: *mut IDWriteTextFormat, trimmingSign: *mut *mut IDWriteInlineObject ) -> ::HRESULT, fn CreateTextAnalyzer(&mut self, textAnalyzer: *mut *mut IDWriteTextAnalyzer) -> ::HRESULT, fn CreateNumberSubstitution( &mut self, substitutionMethod: DWRITE_NUMBER_SUBSTITUTION_METHOD, localeName: *const ::WCHAR, ignoreUserOverride: ::BOOL, numberSubstitution: *mut *mut IDWriteNumberSubstitution ) -> ::HRESULT, fn CreateGlyphRunAnalysis( &mut self, glyphRun: *const DWRITE_GLYPH_RUN, pixelsPerDip: ::FLOAT, transform: *const DWRITE_MATRIX, renderingMode: DWRITE_RENDERING_MODE, measuringMode: ::DWRITE_MEASURING_MODE, baselineOriginX: ::FLOAT, baselineOriginY: ::FLOAT, glyphRunAnalysis: *mut *mut IDWriteGlyphRunAnalysis ) -> ::HRESULT }} pub const FACILITY_DWRITE: ::HRESULT = 0x898; pub const DWRITE_ERR_BASE: ::HRESULT = 0x5000; #[inline] pub fn MAKE_DWRITE_HR(severity: ::HRESULT, code: ::HRESULT) -> ::HRESULT { ::MAKE_HRESULT(severity, FACILITY_DWRITE, DWRITE_ERR_BASE + code) } #[inline] pub fn MAKE_DWRITE_HR_ERR(code: ::HRESULT) -> ::HRESULT { MAKE_DWRITE_HR(::SEVERITY_ERROR, code) } deps/winapi-0.2.5/src/vsserror.rs0000644000000000000000000001404512605021254015461 0ustar rootroot// Copyright © 2015, Brian Vincent // Licensed under the MIT License //! VSS Error header file pub const VSS_E_BAD_STATE: ::HRESULT = 0x80042301u32 as i32; pub const VSS_E_UNEXPECTED: ::HRESULT = 0x80042302u32 as i32; pub const VSS_E_PROVIDER_ALREADY_REGISTERED: ::HRESULT = 0x80042303u32 as i32; pub const VSS_E_PROVIDER_NOT_REGISTERED: ::HRESULT = 0x80042304u32 as i32; pub const VSS_E_PROVIDER_VETO: ::HRESULT = 0x80042306u32 as i32; pub const VSS_E_PROVIDER_IN_USE: ::HRESULT = 0x80042307u32 as i32; pub const VSS_E_OBJECT_NOT_FOUND: ::HRESULT = 0x80042308u32 as i32; pub const VSS_S_ASYNC_PENDING: ::HRESULT = 0x00042309u32 as i32; pub const VSS_S_ASYNC_FINISHED: ::HRESULT = 0x0004230Au32 as i32; pub const VSS_S_ASYNC_CANCELLED: ::HRESULT = 0x0004230Bu32 as i32; pub const VSS_E_VOLUME_NOT_SUPPORTED: ::HRESULT = 0x8004230Cu32 as i32; pub const VSS_E_VOLUME_NOT_SUPPORTED_BY_PROVIDER: ::HRESULT = 0x8004230Eu32 as i32; pub const VSS_E_OBJECT_ALREADY_EXISTS: ::HRESULT = 0x8004230Du32 as i32; pub const VSS_E_UNEXPECTED_PROVIDER_ERROR: ::HRESULT = 0x8004230Fu32 as i32; pub const VSS_E_CORRUPT_XML_DOCUMENT: ::HRESULT = 0x80042310u32 as i32; pub const VSS_E_INVALID_XML_DOCUMENT: ::HRESULT = 0x80042311u32 as i32; pub const VSS_E_MAXIMUM_NUMBER_OF_VOLUMES_REACHED: ::HRESULT = 0x80042312u32 as i32; pub const VSS_E_FLUSH_WRITES_TIMEOUT: ::HRESULT = 0x80042313u32 as i32; pub const VSS_E_HOLD_WRITES_TIMEOUT: ::HRESULT = 0x80042314u32 as i32; pub const VSS_E_UNEXPECTED_WRITER_ERROR: ::HRESULT = 0x80042315u32 as i32; pub const VSS_E_SNAPSHOT_SET_IN_PROGRESS: ::HRESULT = 0x80042316u32 as i32; pub const VSS_E_MAXIMUM_NUMBER_OF_SNAPSHOTS_REACHED: ::HRESULT = 0x80042317u32 as i32; pub const VSS_E_WRITER_INFRASTRUCTURE: ::HRESULT = 0x80042318u32 as i32; pub const VSS_E_WRITER_NOT_RESPONDING: ::HRESULT = 0x80042319u32 as i32; pub const VSS_E_WRITER_ALREADY_SUBSCRIBED: ::HRESULT = 0x8004231Au32 as i32; pub const VSS_E_UNSUPPORTED_CONTEXT: ::HRESULT = 0x8004231Bu32 as i32; pub const VSS_E_VOLUME_IN_USE: ::HRESULT = 0x8004231Du32 as i32; pub const VSS_E_MAXIMUM_DIFFAREA_ASSOCIATIONS_REACHED: ::HRESULT = 0x8004231Eu32 as i32; pub const VSS_E_INSUFFICIENT_STORAGE: ::HRESULT = 0x8004231Fu32 as i32; pub const VSS_E_NO_SNAPSHOTS_IMPORTED: ::HRESULT = 0x80042320u32 as i32; pub const VSS_S_SOME_SNAPSHOTS_NOT_IMPORTED: ::HRESULT = 0x00042321u32 as i32; pub const VSS_E_SOME_SNAPSHOTS_NOT_IMPORTED: ::HRESULT = 0x80042321u32 as i32; pub const VSS_E_MAXIMUM_NUMBER_OF_REMOTE_MACHINES_REACHED: ::HRESULT = 0x80042322u32 as i32; pub const VSS_E_REMOTE_SERVER_UNAVAILABLE: ::HRESULT = 0x80042323u32 as i32; pub const VSS_E_REMOTE_SERVER_UNSUPPORTED: ::HRESULT = 0x80042324u32 as i32; pub const VSS_E_REVERT_IN_PROGRESS: ::HRESULT = 0x80042325u32 as i32; pub const VSS_E_REVERT_VOLUME_LOST: ::HRESULT = 0x80042326u32 as i32; pub const VSS_E_REBOOT_REQUIRED: ::HRESULT = 0x80042327u32 as i32; pub const VSS_E_TRANSACTION_FREEZE_TIMEOUT: ::HRESULT = 0x80042328u32 as i32; pub const VSS_E_TRANSACTION_THAW_TIMEOUT: ::HRESULT = 0x80042329u32 as i32; pub const VSS_E_VOLUME_NOT_LOCAL: ::HRESULT = 0x8004232Du32 as i32; pub const VSS_E_CLUSTER_TIMEOUT: ::HRESULT = 0x8004232Eu32 as i32; pub const VSS_E_WRITERERROR_INCONSISTENTSNAPSHOT: ::HRESULT = 0x800423F0u32 as i32; pub const VSS_E_WRITERERROR_OUTOFRESOURCES: ::HRESULT = 0x800423F1u32 as i32; pub const VSS_E_WRITERERROR_TIMEOUT: ::HRESULT = 0x800423F2u32 as i32; pub const VSS_E_WRITERERROR_RETRYABLE: ::HRESULT = 0x800423F3u32 as i32; pub const VSS_E_WRITERERROR_NONRETRYABLE: ::HRESULT = 0x800423F4u32 as i32; pub const VSS_E_WRITERERROR_RECOVERY_FAILED: ::HRESULT = 0x800423F5u32 as i32; pub const VSS_E_BREAK_REVERT_ID_FAILED: ::HRESULT = 0x800423F6u32 as i32; pub const VSS_E_LEGACY_PROVIDER: ::HRESULT = 0x800423F7u32 as i32; pub const VSS_E_MISSING_DISK: ::HRESULT = 0x800423F8u32 as i32; pub const VSS_E_MISSING_HIDDEN_VOLUME: ::HRESULT = 0x800423F9u32 as i32; pub const VSS_E_MISSING_VOLUME: ::HRESULT = 0x800423FAu32 as i32; pub const VSS_E_AUTORECOVERY_FAILED: ::HRESULT = 0x800423FBu32 as i32; pub const VSS_E_DYNAMIC_DISK_ERROR: ::HRESULT = 0x800423FCu32 as i32; pub const VSS_E_NONTRANSPORTABLE_BCD: ::HRESULT = 0x800423FDu32 as i32; pub const VSS_E_CANNOT_REVERT_DISKID: ::HRESULT = 0x800423FEu32 as i32; pub const VSS_E_RESYNC_IN_PROGRESS: ::HRESULT = 0x800423FFu32 as i32; pub const VSS_E_CLUSTER_ERROR: ::HRESULT = 0x80042400u32 as i32; pub const VSS_E_UNSELECTED_VOLUME: ::HRESULT = 0x8004232Au32 as i32; pub const VSS_E_SNAPSHOT_NOT_IN_SET: ::HRESULT = 0x8004232Bu32 as i32; pub const VSS_E_NESTED_VOLUME_LIMIT: ::HRESULT = 0x8004232Cu32 as i32; pub const VSS_E_NOT_SUPPORTED: ::HRESULT = 0x8004232Fu32 as i32; pub const VSS_E_WRITERERROR_PARTIAL_FAILURE: ::HRESULT = 0x80042336u32 as i32; pub const VSS_E_ASRERROR_DISK_ASSIGNMENT_FAILED: ::HRESULT = 0x80042401u32 as i32; pub const VSS_E_ASRERROR_DISK_RECREATION_FAILED: ::HRESULT = 0x80042402u32 as i32; pub const VSS_E_ASRERROR_NO_ARCPATH: ::HRESULT = 0x80042403u32 as i32; pub const VSS_E_ASRERROR_MISSING_DYNDISK: ::HRESULT = 0x80042404u32 as i32; pub const VSS_E_ASRERROR_SHARED_CRIDISK: ::HRESULT = 0x80042405u32 as i32; pub const VSS_E_ASRERROR_DATADISK_RDISK0: ::HRESULT = 0x80042406u32 as i32; pub const VSS_E_ASRERROR_RDISK0_TOOSMALL: ::HRESULT = 0x80042407u32 as i32; pub const VSS_E_ASRERROR_CRITICAL_DISKS_TOO_SMALL: ::HRESULT = 0x80042408u32 as i32; pub const VSS_E_WRITER_STATUS_NOT_AVAILABLE: ::HRESULT = 0x80042409u32 as i32; pub const VSS_E_ASRERROR_DYNAMIC_VHD_NOT_SUPPORTED: ::HRESULT = 0x8004240Au32 as i32; pub const VSS_E_CRITICAL_VOLUME_ON_INVALID_DISK: ::HRESULT = 0x80042411u32 as i32; pub const VSS_E_ASRERROR_RDISK_FOR_SYSTEM_DISK_NOT_FOUND: ::HRESULT = 0x80042412u32 as i32; pub const VSS_E_ASRERROR_NO_PHYSICAL_DISK_AVAILABLE: ::HRESULT = 0x80042413u32 as i32; pub const VSS_E_ASRERROR_FIXED_PHYSICAL_DISK_AVAILABLE_AFTER_DISK_EXCLUSION: ::HRESULT = 0x80042414u32 as i32; pub const VSS_E_ASRERROR_CRITICAL_DISK_CANNOT_BE_EXCLUDED: ::HRESULT = 0x80042415u32 as i32; pub const VSS_E_ASRERROR_SYSTEM_PARTITION_HIDDEN: ::HRESULT = 0x80042416u32 as i32; pub const VSS_E_FSS_TIMEOUT: ::HRESULT = 0x80042417u32 as i32; deps/winapi-0.2.5/src/mscat.rs0000644000000000000000000000147212613167613014714 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Microsoft Internet Security Catalog API Prototypes and Definitions STRUCT!{struct CRYPTCATSTORE { cbStruct: ::DWORD, dwPublicVersion: ::DWORD, pwszP7File: ::LPWSTR, hProv: ::HCRYPTPROV, dwEncodingType: ::DWORD, fdwStoreFlags: ::DWORD, hReserved: ::HANDLE, hAttrs: ::HANDLE, hCryptMsg: ::HCRYPTMSG, hSorted: ::HANDLE, }} STRUCT!{struct CRYPTCATMEMBER { cbStruct: ::DWORD, pwszReferenceTag: ::LPWSTR, pwszFileName: ::LPWSTR, gSubjectType: ::GUID, fdwMemberFlags: ::DWORD, pIndirectData: *mut ::SIP_INDIRECT_DATA, dwCertVersion: ::DWORD, dwReserved: ::DWORD, hReserved: ::HANDLE, sEncodedIndirectData: ::CRYPT_ATTR_BLOB, sEncodedMemberInfo: ::CRYPT_ATTR_BLOB, }} deps/winapi-0.2.5/src/objidl.rs0000644000000000000000000000566112613167613015054 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! this ALWAYS GENERATED file contains the definitions for the interfaces //8402 STRUCT!{struct BIND_OPTS { cbStruct: ::DWORD, grfFlags: ::DWORD, grfMode: ::DWORD, dwTickCountDeadline: ::DWORD, }} pub type LPBIND_OPTS = *mut BIND_OPTS; //8479 RIDL!( interface IBindCtx(IBindCtxVtbl): IUnknown(IUnknownVtbl) { fn RegisterObjectBound(&mut self, punk: *mut ::IUnknown) -> ::HRESULT, fn RevokeObjectBound(&mut self, punk: *mut ::IUnknown) -> ::HRESULT, fn ReleaseBoundObjects(&mut self) -> ::HRESULT, fn SetBindOptions(&mut self, pbindopts: *mut BIND_OPTS) -> ::HRESULT, fn GetBindOptions(&mut self, pbindopts: *mut BIND_OPTS) -> ::HRESULT, fn GetRunningObjectTable(&mut self, pprot: *mut *mut IRunningObjectTable) -> ::HRESULT, fn RegisterObjectParam(&mut self, pszKey: ::LPOLESTR, punk: *mut ::IUnknown) -> ::HRESULT, fn GetObjectParam(&mut self, pszKey: ::LPOLESTR, ppunk: *mut *mut ::IUnknown) -> ::HRESULT, fn EnumObjectParam(&mut self, ppenum: *mut *mut ::IEnumString) -> ::HRESULT, fn RevokeObjectParam(&mut self, pszKey: ::LPOLESTR) -> ::HRESULT } ); //8681 pub type IEnumMoniker = ::IUnknown; // TODO //8958 RIDL!( interface IRunningObjectTable(IRunningObjectTableVtbl): IUnknown(IUnknownVtbl) { fn Register( &mut self, grfFlags: ::DWORD, punkObject: *mut ::IUnknown, pmkObjectName: *mut IMoniker, pdwRegister: *mut ::DWORD ) -> ::HRESULT, fn Revoke(&mut self, dwRegister: ::DWORD) -> ::HRESULT, fn IsRunning(&mut self, pmkObjectName: *mut IMoniker) -> ::HRESULT, fn GetObject( &mut self, pmkObjectName: *mut IMoniker, ppunkObject: *mut *mut ::IUnknown ) -> ::HRESULT, fn NoteChangeTime(&mut self, dwRegister: ::DWORD, pfiletime: *mut ::FILETIME) -> ::HRESULT, fn GetTimeOfLastChange( &mut self, pmkObjectName: *mut IMoniker, pfiletime: *mut ::FILETIME ) -> ::HRESULT, fn EnumRunning(&mut self, ppenumMoniker: *mut *mut IEnumMoniker) -> ::HRESULT } ); //9350 pub type IMoniker = ::IUnknown; // TODO pub type EOLE_AUTHENTICATION_CAPABILITIES = ::DWORD; pub const EOAC_NONE: ::DWORD = 0; pub const EOAC_MUTUAL_AUTH: ::DWORD = 0x1; pub const EOAC_STATIC_CLOAKING: ::DWORD = 0x20; pub const EOAC_DYNAMIC_CLOAKING: ::DWORD = 0x40; pub const EOAC_ANY_AUTHORITY: ::DWORD = 0x80; pub const EOAC_MAKE_FULLSIC: ::DWORD = 0x100; pub const EOAC_DEFAULT: ::DWORD = 0x800; pub const EOAC_SECURE_REFS: ::DWORD = 0x2; pub const EOAC_ACCESS_CONTROL: ::DWORD = 0x4; pub const EOAC_APPID: ::DWORD = 0x8; pub const EOAC_DYNAMIC: ::DWORD = 0x10; pub const EOAC_REQUIRE_FULLSIC: ::DWORD = 0x200; pub const EOAC_AUTO_IMPERSONATE: ::DWORD = 0x400; pub const EOAC_NO_CUSTOM_MARSHAL: ::DWORD = 0x2000; pub const EOAC_DISABLE_AAA: ::DWORD = 0x1000; STRUCT!{struct SOLE_AUTHENTICATION_SERVICE { dwAuthnSvc: ::DWORD, dwAuthzSvc: ::DWORD, pPrincipalName: *mut ::OLECHAR, hr: ::HRESULT, }} deps/winapi-0.2.5/src/mmdeviceapi.rs0000644000000000000000000000452612615662007016072 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! this ALWAYS GENERATED file contains the definitions for the interfaces pub const DEVICE_STATE_ACTIVE: ::DWORD = 0x00000001; pub const DEVICE_STATE_DISABLED: ::DWORD = 0x00000002; pub const DEVICE_STATE_NOTPRESENT: ::DWORD = 0x00000004; pub const DEVICE_STATE_UNPLUGGED: ::DWORD = 0x00000008; pub const DEVICE_STATEMASK_ALL: ::DWORD = 0x0000000F; ENUM!{enum EDataFlow { eRender, eCapture, eAll, EDataFlow_enum_count, }} ENUM!{enum ERole { eConsole, eMultimedia, eCommunications, ERole_enum_count, }} DEFINE_GUID!(CLSID_MMDeviceEnumerator, 0xBCDE0395, 0xE52F, 0x467C, 0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E); DEFINE_GUID!(IID_IMMDeviceEnumerator, 0xA95664D2, 0x9614, 0x4F35, 0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6); RIDL!( interface IMMDevice(IMMDeviceVtbl): IUnknown(IUnknownVtbl) { fn Activate( &mut self, iid: ::REFIID, dwClsCtx: ::DWORD, pActivationParams: *mut ::PROPVARIANT, ppInterface: *mut ::LPVOID ) -> ::HRESULT, fn OpenPropertyStore( &mut self, stgmAccess: ::DWORD, ppProperties: *mut *mut ::IPropertyStore ) -> ::HRESULT, fn GetId(&mut self, ppstrId: *mut ::LPWSTR) -> ::HRESULT, fn GetState(&mut self, pdwState: *mut ::DWORD) -> ::HRESULT } ); RIDL!( interface IMMDeviceEnumerator(IMMDeviceEnumeratorVtbl): IUnknown(IUnknownVtbl) { fn EnumAudioEndpoints( &mut self, dataFlow: EDataFlow, dwStateMask: ::DWORD, ppDevices: *mut *mut IMMDeviceCollection ) -> ::HRESULT, fn GetDefaultAudioEndpoint( &mut self, dataFlow: EDataFlow, role: ERole, ppEndpoint: *mut *mut IMMDevice ) -> ::HRESULT, fn GetDevice(&mut self, pwstrId: ::LPCWSTR, ppDevices: *mut *mut IMMDevice) -> ::HRESULT, fn RegisterEndpointNotificationCallback( &mut self, pClient: *mut IMMNotificationClient ) -> ::HRESULT, fn UnregisterEndpointNotificationCallback( &mut self, pClient: *mut IMMNotificationClient ) -> ::HRESULT } ); RIDL!( interface IMMDeviceCollection(IMMDeviceCollectionVtbl): IUnknown(IUnknownVtbl) { fn GetCount(&mut self, pcDevices: *const ::UINT) -> ::HRESULT, fn Item(&mut self, nDevice: ::UINT, ppDevice: *mut *mut IMMDevice) -> ::HRESULT } ); #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IMMNotificationClient; deps/winapi-0.2.5/src/ntstatus.rs0000644000000000000000000055262612605021253015474 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Constant definitions for the NTSTATUS values. pub const STATUS_WAIT_0: ::NTSTATUS = 0x00000000; pub const FACILITY_VSM: ::NTSTATUS = 0x45; pub const FACILITY_VOLSNAP: ::NTSTATUS = 0x50; pub const FACILITY_VOLMGR: ::NTSTATUS = 0x38; pub const FACILITY_VIRTUALIZATION: ::NTSTATUS = 0x37; pub const FACILITY_VIDEO: ::NTSTATUS = 0x1B; pub const FACILITY_USB_ERROR_CODE: ::NTSTATUS = 0x10; pub const FACILITY_TRANSACTION: ::NTSTATUS = 0x19; pub const FACILITY_TPM: ::NTSTATUS = 0x29; pub const FACILITY_TERMINAL_SERVER: ::NTSTATUS = 0xA; pub const FACILITY_SXS_ERROR_CODE: ::NTSTATUS = 0x15; pub const FACILITY_NTSSPI: ::NTSTATUS = 0x9; pub const FACILITY_SPACES: ::NTSTATUS = 0xE7; pub const FACILITY_SMB: ::NTSTATUS = 0x5D; pub const FACILITY_SYSTEM_INTEGRITY: ::NTSTATUS = 0xE9; pub const FACILITY_SHARED_VHDX: ::NTSTATUS = 0x5C; pub const FACILITY_SECUREBOOT: ::NTSTATUS = 0x43; pub const FACILITY_SECURITY_CORE: ::NTSTATUS = 0xE8; pub const FACILITY_SDBUS: ::NTSTATUS = 0x51; pub const FACILITY_RTPM: ::NTSTATUS = 0x2A; pub const FACILITY_RPC_STUBS: ::NTSTATUS = 0x3; pub const FACILITY_RPC_RUNTIME: ::NTSTATUS = 0x2; pub const FACILITY_RESUME_KEY_FILTER: ::NTSTATUS = 0x40; pub const FACILITY_RDBSS: ::NTSTATUS = 0x41; pub const FACILITY_NTWIN32: ::NTSTATUS = 0x7; pub const FACILITY_WIN32K_NTUSER: ::NTSTATUS = 0x3E; pub const FACILITY_WIN32K_NTGDI: ::NTSTATUS = 0x3F; pub const FACILITY_NDIS_ERROR_CODE: ::NTSTATUS = 0x23; pub const FACILTIY_MUI_ERROR_CODE: ::NTSTATUS = 0xB; pub const FACILITY_MONITOR: ::NTSTATUS = 0x1D; pub const FACILITY_MAXIMUM_VALUE: ::NTSTATUS = 0xEB; pub const FACILITY_LICENSING: ::NTSTATUS = 0xEA; pub const FACILITY_IPSEC: ::NTSTATUS = 0x36; pub const FACILITY_IO_ERROR_CODE: ::NTSTATUS = 0x4; pub const FACILITY_INTERIX: ::NTSTATUS = 0x99; pub const FACILITY_HYPERVISOR: ::NTSTATUS = 0x35; pub const FACILITY_HID_ERROR_CODE: ::NTSTATUS = 0x11; pub const FACILITY_GRAPHICS_KERNEL: ::NTSTATUS = 0x1E; pub const FACILITY_FWP_ERROR_CODE: ::NTSTATUS = 0x22; pub const FACILITY_FVE_ERROR_CODE: ::NTSTATUS = 0x21; pub const FACILITY_FIREWIRE_ERROR_CODE: ::NTSTATUS = 0x12; pub const FACILITY_FILTER_MANAGER: ::NTSTATUS = 0x1C; pub const FACILITY_DRIVER_FRAMEWORK: ::NTSTATUS = 0x20; pub const FACILITY_DEBUGGER: ::NTSTATUS = 0x1; pub const FACILITY_COMMONLOG: ::NTSTATUS = 0x1A; pub const FACILITY_CODCLASS_ERROR_CODE: ::NTSTATUS = 0x6; pub const FACILITY_CLUSTER_ERROR_CODE: ::NTSTATUS = 0x13; pub const FACILITY_NTCERT: ::NTSTATUS = 0x8; pub const FACILITY_BTH_ATT: ::NTSTATUS = 0x42; pub const FACILITY_BCD_ERROR_CODE: ::NTSTATUS = 0x39; pub const FACILITY_AUDIO_KERNEL: ::NTSTATUS = 0x44; pub const FACILITY_ACPI_ERROR_CODE: ::NTSTATUS = 0x14; pub const STATUS_SEVERITY_WARNING: ::NTSTATUS = 0x2; pub const STATUS_SEVERITY_SUCCESS: ::NTSTATUS = 0x0; pub const STATUS_SEVERITY_INFORMATIONAL: ::NTSTATUS = 0x1; pub const STATUS_SEVERITY_ERROR: ::NTSTATUS = 0x3; pub const STATUS_SUCCESS: ::NTSTATUS = 0x00000000; pub const STATUS_WAIT_1: ::NTSTATUS = 0x00000001; pub const STATUS_WAIT_2: ::NTSTATUS = 0x00000002; pub const STATUS_WAIT_3: ::NTSTATUS = 0x00000003; pub const STATUS_WAIT_63: ::NTSTATUS = 0x0000003F; pub const STATUS_ABANDONED: ::NTSTATUS = 0x00000080; pub const STATUS_ABANDONED_WAIT_0: ::NTSTATUS = 0x00000080; pub const STATUS_ABANDONED_WAIT_63: ::NTSTATUS = 0x000000BF; pub const STATUS_USER_APC: ::NTSTATUS = 0x000000C0; pub const STATUS_KERNEL_APC: ::NTSTATUS = 0x00000100; pub const STATUS_ALERTED: ::NTSTATUS = 0x00000101; pub const STATUS_TIMEOUT: ::NTSTATUS = 0x00000102; pub const STATUS_PENDING: ::NTSTATUS = 0x00000103; pub const STATUS_REPARSE: ::NTSTATUS = 0x00000104; pub const STATUS_MORE_ENTRIES: ::NTSTATUS = 0x00000105; pub const STATUS_NOT_ALL_ASSIGNED: ::NTSTATUS = 0x00000106; pub const STATUS_SOME_NOT_MAPPED: ::NTSTATUS = 0x00000107; pub const STATUS_OPLOCK_BREAK_IN_PROGRESS: ::NTSTATUS = 0x00000108; pub const STATUS_VOLUME_MOUNTED: ::NTSTATUS = 0x00000109; pub const STATUS_RXACT_COMMITTED: ::NTSTATUS = 0x0000010A; pub const STATUS_NOTIFY_CLEANUP: ::NTSTATUS = 0x0000010B; pub const STATUS_NOTIFY_ENUM_DIR: ::NTSTATUS = 0x0000010C; pub const STATUS_NO_QUOTAS_FOR_ACCOUNT: ::NTSTATUS = 0x0000010D; pub const STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED: ::NTSTATUS = 0x0000010E; pub const STATUS_PAGE_FAULT_TRANSITION: ::NTSTATUS = 0x00000110; pub const STATUS_PAGE_FAULT_DEMAND_ZERO: ::NTSTATUS = 0x00000111; pub const STATUS_PAGE_FAULT_COPY_ON_WRITE: ::NTSTATUS = 0x00000112; pub const STATUS_PAGE_FAULT_GUARD_PAGE: ::NTSTATUS = 0x00000113; pub const STATUS_PAGE_FAULT_PAGING_FILE: ::NTSTATUS = 0x00000114; pub const STATUS_CACHE_PAGE_LOCKED: ::NTSTATUS = 0x00000115; pub const STATUS_CRASH_DUMP: ::NTSTATUS = 0x00000116; pub const STATUS_BUFFER_ALL_ZEROS: ::NTSTATUS = 0x00000117; pub const STATUS_REPARSE_OBJECT: ::NTSTATUS = 0x00000118; pub const STATUS_RESOURCE_REQUIREMENTS_CHANGED: ::NTSTATUS = 0x00000119; pub const STATUS_TRANSLATION_COMPLETE: ::NTSTATUS = 0x00000120; pub const STATUS_DS_MEMBERSHIP_EVALUATED_LOCALLY: ::NTSTATUS = 0x00000121; pub const STATUS_NOTHING_TO_TERMINATE: ::NTSTATUS = 0x00000122; pub const STATUS_PROCESS_NOT_IN_JOB: ::NTSTATUS = 0x00000123; pub const STATUS_PROCESS_IN_JOB: ::NTSTATUS = 0x00000124; pub const STATUS_VOLSNAP_HIBERNATE_READY: ::NTSTATUS = 0x00000125; pub const STATUS_FSFILTER_OP_COMPLETED_SUCCESSFULLY: ::NTSTATUS = 0x00000126; pub const STATUS_INTERRUPT_VECTOR_ALREADY_CONNECTED: ::NTSTATUS = 0x00000127; pub const STATUS_INTERRUPT_STILL_CONNECTED: ::NTSTATUS = 0x00000128; pub const STATUS_PROCESS_CLONED: ::NTSTATUS = 0x00000129; pub const STATUS_FILE_LOCKED_WITH_ONLY_READERS: ::NTSTATUS = 0x0000012A; pub const STATUS_FILE_LOCKED_WITH_WRITERS: ::NTSTATUS = 0x0000012B; pub const STATUS_VALID_IMAGE_HASH: ::NTSTATUS = 0x0000012C; pub const STATUS_VALID_CATALOG_HASH: ::NTSTATUS = 0x0000012D; pub const STATUS_VALID_STRONG_CODE_HASH: ::NTSTATUS = 0x0000012E; pub const STATUS_RESOURCEMANAGER_READ_ONLY: ::NTSTATUS = 0x00000202; pub const STATUS_RING_PREVIOUSLY_EMPTY: ::NTSTATUS = 0x00000210; pub const STATUS_RING_PREVIOUSLY_FULL: ::NTSTATUS = 0x00000211; pub const STATUS_RING_PREVIOUSLY_ABOVE_QUOTA: ::NTSTATUS = 0x00000212; pub const STATUS_RING_NEWLY_EMPTY: ::NTSTATUS = 0x00000213; pub const STATUS_RING_SIGNAL_OPPOSITE_ENDPOINT: ::NTSTATUS = 0x00000214; pub const STATUS_OPLOCK_SWITCHED_TO_NEW_HANDLE: ::NTSTATUS = 0x00000215; pub const STATUS_OPLOCK_HANDLE_CLOSED: ::NTSTATUS = 0x00000216; pub const STATUS_WAIT_FOR_OPLOCK: ::NTSTATUS = 0x00000367; pub const DBG_EXCEPTION_HANDLED: ::NTSTATUS = 0x00010001; pub const DBG_CONTINUE: ::NTSTATUS = 0x00010002; pub const STATUS_FLT_IO_COMPLETE: ::NTSTATUS = 0x001C0001; pub const STATUS_OBJECT_NAME_EXISTS: ::NTSTATUS = 0x40000000; pub const STATUS_THREAD_WAS_SUSPENDED: ::NTSTATUS = 0x40000001; pub const STATUS_WORKING_SET_LIMIT_RANGE: ::NTSTATUS = 0x40000002; pub const STATUS_IMAGE_NOT_AT_BASE: ::NTSTATUS = 0x40000003; pub const STATUS_RXACT_STATE_CREATED: ::NTSTATUS = 0x40000004; pub const STATUS_SEGMENT_NOTIFICATION: ::NTSTATUS = 0x40000005; pub const STATUS_LOCAL_USER_SESSION_KEY: ::NTSTATUS = 0x40000006; pub const STATUS_BAD_CURRENT_DIRECTORY: ::NTSTATUS = 0x40000007; pub const STATUS_SERIAL_MORE_WRITES: ::NTSTATUS = 0x40000008; pub const STATUS_REGISTRY_RECOVERED: ::NTSTATUS = 0x40000009; pub const STATUS_FT_READ_RECOVERY_FROM_BACKUP: ::NTSTATUS = 0x4000000A; pub const STATUS_FT_WRITE_RECOVERY: ::NTSTATUS = 0x4000000B; pub const STATUS_SERIAL_COUNTER_TIMEOUT: ::NTSTATUS = 0x4000000C; pub const STATUS_NULL_LM_PASSWORD: ::NTSTATUS = 0x4000000D; pub const STATUS_IMAGE_MACHINE_TYPE_MISMATCH: ::NTSTATUS = 0x4000000E; pub const STATUS_RECEIVE_PARTIAL: ::NTSTATUS = 0x4000000F; pub const STATUS_RECEIVE_EXPEDITED: ::NTSTATUS = 0x40000010; pub const STATUS_RECEIVE_PARTIAL_EXPEDITED: ::NTSTATUS = 0x40000011; pub const STATUS_EVENT_DONE: ::NTSTATUS = 0x40000012; pub const STATUS_EVENT_PENDING: ::NTSTATUS = 0x40000013; pub const STATUS_CHECKING_FILE_SYSTEM: ::NTSTATUS = 0x40000014; pub const STATUS_FATAL_APP_EXIT: ::NTSTATUS = 0x40000015; pub const STATUS_PREDEFINED_HANDLE: ::NTSTATUS = 0x40000016; pub const STATUS_WAS_UNLOCKED: ::NTSTATUS = 0x40000017; pub const STATUS_SERVICE_NOTIFICATION: ::NTSTATUS = 0x40000018; pub const STATUS_WAS_LOCKED: ::NTSTATUS = 0x40000019; pub const STATUS_LOG_HARD_ERROR: ::NTSTATUS = 0x4000001A; pub const STATUS_ALREADY_WIN32: ::NTSTATUS = 0x4000001B; pub const STATUS_WX86_UNSIMULATE: ::NTSTATUS = 0x4000001C; pub const STATUS_WX86_CONTINUE: ::NTSTATUS = 0x4000001D; pub const STATUS_WX86_SINGLE_STEP: ::NTSTATUS = 0x4000001E; pub const STATUS_WX86_BREAKPOINT: ::NTSTATUS = 0x4000001F; pub const STATUS_WX86_EXCEPTION_CONTINUE: ::NTSTATUS = 0x40000020; pub const STATUS_WX86_EXCEPTION_LASTCHANCE: ::NTSTATUS = 0x40000021; pub const STATUS_WX86_EXCEPTION_CHAIN: ::NTSTATUS = 0x40000022; pub const STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE: ::NTSTATUS = 0x40000023; pub const STATUS_NO_YIELD_PERFORMED: ::NTSTATUS = 0x40000024; pub const STATUS_TIMER_RESUME_IGNORED: ::NTSTATUS = 0x40000025; pub const STATUS_ARBITRATION_UNHANDLED: ::NTSTATUS = 0x40000026; pub const STATUS_CARDBUS_NOT_SUPPORTED: ::NTSTATUS = 0x40000027; pub const STATUS_WX86_CREATEWX86TIB: ::NTSTATUS = 0x40000028; pub const STATUS_MP_PROCESSOR_MISMATCH: ::NTSTATUS = 0x40000029; pub const STATUS_HIBERNATED: ::NTSTATUS = 0x4000002A; pub const STATUS_RESUME_HIBERNATION: ::NTSTATUS = 0x4000002B; pub const STATUS_FIRMWARE_UPDATED: ::NTSTATUS = 0x4000002C; pub const STATUS_DRIVERS_LEAKING_LOCKED_PAGES: ::NTSTATUS = 0x4000002D; pub const STATUS_MESSAGE_RETRIEVED: ::NTSTATUS = 0x4000002E; pub const STATUS_SYSTEM_POWERSTATE_TRANSITION: ::NTSTATUS = 0x4000002F; pub const STATUS_ALPC_CHECK_COMPLETION_LIST: ::NTSTATUS = 0x40000030; pub const STATUS_SYSTEM_POWERSTATE_COMPLEX_TRANSITION: ::NTSTATUS = 0x40000031; pub const STATUS_ACCESS_AUDIT_BY_POLICY: ::NTSTATUS = 0x40000032; pub const STATUS_ABANDON_HIBERFILE: ::NTSTATUS = 0x40000033; pub const STATUS_BIZRULES_NOT_ENABLED: ::NTSTATUS = 0x40000034; pub const STATUS_FT_READ_FROM_COPY: ::NTSTATUS = 0x40000035; pub const STATUS_IMAGE_AT_DIFFERENT_BASE: ::NTSTATUS = 0x40000036; pub const DBG_REPLY_LATER: ::NTSTATUS = 0x40010001; pub const DBG_UNABLE_TO_PROVIDE_HANDLE: ::NTSTATUS = 0x40010002; pub const DBG_TERMINATE_THREAD: ::NTSTATUS = 0x40010003; pub const DBG_TERMINATE_PROCESS: ::NTSTATUS = 0x40010004; pub const DBG_CONTROL_C: ::NTSTATUS = 0x40010005; pub const DBG_PRINTEXCEPTION_C: ::NTSTATUS = 0x40010006; pub const DBG_RIPEXCEPTION: ::NTSTATUS = 0x40010007; pub const DBG_CONTROL_BREAK: ::NTSTATUS = 0x40010008; pub const DBG_COMMAND_EXCEPTION: ::NTSTATUS = 0x40010009; pub const DBG_PRINTEXCEPTION_WIDE_C: ::NTSTATUS = 0x4001000A; pub const STATUS_HEURISTIC_DAMAGE_POSSIBLE: ::NTSTATUS = 0x40190001; pub const STATUS_GUARD_PAGE_VIOLATION: ::NTSTATUS = 0x80000001u32 as i32; pub const STATUS_DATATYPE_MISALIGNMENT: ::NTSTATUS = 0x80000002u32 as i32; pub const STATUS_BREAKPOINT: ::NTSTATUS = 0x80000003u32 as i32; pub const STATUS_SINGLE_STEP: ::NTSTATUS = 0x80000004u32 as i32; pub const STATUS_BUFFER_OVERFLOW: ::NTSTATUS = 0x80000005u32 as i32; pub const STATUS_NO_MORE_FILES: ::NTSTATUS = 0x80000006u32 as i32; pub const STATUS_WAKE_SYSTEM_DEBUGGER: ::NTSTATUS = 0x80000007u32 as i32; pub const STATUS_HANDLES_CLOSED: ::NTSTATUS = 0x8000000Au32 as i32; pub const STATUS_NO_INHERITANCE: ::NTSTATUS = 0x8000000Bu32 as i32; pub const STATUS_GUID_SUBSTITUTION_MADE: ::NTSTATUS = 0x8000000Cu32 as i32; pub const STATUS_PARTIAL_COPY: ::NTSTATUS = 0x8000000Du32 as i32; pub const STATUS_DEVICE_PAPER_EMPTY: ::NTSTATUS = 0x8000000Eu32 as i32; pub const STATUS_DEVICE_POWERED_OFF: ::NTSTATUS = 0x8000000Fu32 as i32; pub const STATUS_DEVICE_OFF_LINE: ::NTSTATUS = 0x80000010u32 as i32; pub const STATUS_DEVICE_BUSY: ::NTSTATUS = 0x80000011u32 as i32; pub const STATUS_NO_MORE_EAS: ::NTSTATUS = 0x80000012u32 as i32; pub const STATUS_INVALID_EA_NAME: ::NTSTATUS = 0x80000013u32 as i32; pub const STATUS_EA_LIST_INCONSISTENT: ::NTSTATUS = 0x80000014u32 as i32; pub const STATUS_INVALID_EA_FLAG: ::NTSTATUS = 0x80000015u32 as i32; pub const STATUS_VERIFY_REQUIRED: ::NTSTATUS = 0x80000016u32 as i32; pub const STATUS_EXTRANEOUS_INFORMATION: ::NTSTATUS = 0x80000017u32 as i32; pub const STATUS_RXACT_COMMIT_NECESSARY: ::NTSTATUS = 0x80000018u32 as i32; pub const STATUS_NO_MORE_ENTRIES: ::NTSTATUS = 0x8000001Au32 as i32; pub const STATUS_FILEMARK_DETECTED: ::NTSTATUS = 0x8000001Bu32 as i32; pub const STATUS_MEDIA_CHANGED: ::NTSTATUS = 0x8000001Cu32 as i32; pub const STATUS_BUS_RESET: ::NTSTATUS = 0x8000001Du32 as i32; pub const STATUS_END_OF_MEDIA: ::NTSTATUS = 0x8000001Eu32 as i32; pub const STATUS_BEGINNING_OF_MEDIA: ::NTSTATUS = 0x8000001Fu32 as i32; pub const STATUS_MEDIA_CHECK: ::NTSTATUS = 0x80000020u32 as i32; pub const STATUS_SETMARK_DETECTED: ::NTSTATUS = 0x80000021u32 as i32; pub const STATUS_NO_DATA_DETECTED: ::NTSTATUS = 0x80000022u32 as i32; pub const STATUS_REDIRECTOR_HAS_OPEN_HANDLES: ::NTSTATUS = 0x80000023u32 as i32; pub const STATUS_SERVER_HAS_OPEN_HANDLES: ::NTSTATUS = 0x80000024u32 as i32; pub const STATUS_ALREADY_DISCONNECTED: ::NTSTATUS = 0x80000025u32 as i32; pub const STATUS_LONGJUMP: ::NTSTATUS = 0x80000026u32 as i32; pub const STATUS_CLEANER_CARTRIDGE_INSTALLED: ::NTSTATUS = 0x80000027u32 as i32; pub const STATUS_PLUGPLAY_QUERY_VETOED: ::NTSTATUS = 0x80000028u32 as i32; pub const STATUS_UNWIND_CONSOLIDATE: ::NTSTATUS = 0x80000029u32 as i32; pub const STATUS_REGISTRY_HIVE_RECOVERED: ::NTSTATUS = 0x8000002Au32 as i32; pub const STATUS_DLL_MIGHT_BE_INSECURE: ::NTSTATUS = 0x8000002Bu32 as i32; pub const STATUS_DLL_MIGHT_BE_INCOMPATIBLE: ::NTSTATUS = 0x8000002Cu32 as i32; pub const STATUS_STOPPED_ON_SYMLINK: ::NTSTATUS = 0x8000002Du32 as i32; pub const STATUS_CANNOT_GRANT_REQUESTED_OPLOCK: ::NTSTATUS = 0x8000002Eu32 as i32; pub const STATUS_NO_ACE_CONDITION: ::NTSTATUS = 0x8000002Fu32 as i32; pub const STATUS_DEVICE_SUPPORT_IN_PROGRESS: ::NTSTATUS = 0x80000030u32 as i32; pub const STATUS_DEVICE_POWER_CYCLE_REQUIRED: ::NTSTATUS = 0x80000031u32 as i32; pub const DBG_EXCEPTION_NOT_HANDLED: ::NTSTATUS = 0x80010001u32 as i32; pub const STATUS_CLUSTER_NODE_ALREADY_UP: ::NTSTATUS = 0x80130001u32 as i32; pub const STATUS_CLUSTER_NODE_ALREADY_DOWN: ::NTSTATUS = 0x80130002u32 as i32; pub const STATUS_CLUSTER_NETWORK_ALREADY_ONLINE: ::NTSTATUS = 0x80130003u32 as i32; pub const STATUS_CLUSTER_NETWORK_ALREADY_OFFLINE: ::NTSTATUS = 0x80130004u32 as i32; pub const STATUS_CLUSTER_NODE_ALREADY_MEMBER: ::NTSTATUS = 0x80130005u32 as i32; pub const STATUS_FLT_BUFFER_TOO_SMALL: ::NTSTATUS = 0x801C0001u32 as i32; pub const STATUS_FVE_PARTIAL_METADATA: ::NTSTATUS = 0x80210001u32 as i32; pub const STATUS_FVE_TRANSIENT_STATE: ::NTSTATUS = 0x80210002u32 as i32; pub const STATUS_UNSUCCESSFUL: ::NTSTATUS = 0xC0000001u32 as i32; pub const STATUS_NOT_IMPLEMENTED: ::NTSTATUS = 0xC0000002u32 as i32; pub const STATUS_INVALID_INFO_CLASS: ::NTSTATUS = 0xC0000003u32 as i32; pub const STATUS_INFO_LENGTH_MISMATCH: ::NTSTATUS = 0xC0000004u32 as i32; pub const STATUS_ACCESS_VIOLATION: ::NTSTATUS = 0xC0000005u32 as i32; pub const STATUS_IN_PAGE_ERROR: ::NTSTATUS = 0xC0000006u32 as i32; pub const STATUS_PAGEFILE_QUOTA: ::NTSTATUS = 0xC0000007u32 as i32; pub const STATUS_INVALID_HANDLE: ::NTSTATUS = 0xC0000008u32 as i32; pub const STATUS_BAD_INITIAL_STACK: ::NTSTATUS = 0xC0000009u32 as i32; pub const STATUS_BAD_INITIAL_PC: ::NTSTATUS = 0xC000000Au32 as i32; pub const STATUS_INVALID_CID: ::NTSTATUS = 0xC000000Bu32 as i32; pub const STATUS_TIMER_NOT_CANCELED: ::NTSTATUS = 0xC000000Cu32 as i32; pub const STATUS_INVALID_PARAMETER: ::NTSTATUS = 0xC000000Du32 as i32; pub const STATUS_NO_SUCH_DEVICE: ::NTSTATUS = 0xC000000Eu32 as i32; pub const STATUS_NO_SUCH_FILE: ::NTSTATUS = 0xC000000Fu32 as i32; pub const STATUS_INVALID_DEVICE_REQUEST: ::NTSTATUS = 0xC0000010u32 as i32; pub const STATUS_END_OF_FILE: ::NTSTATUS = 0xC0000011u32 as i32; pub const STATUS_WRONG_VOLUME: ::NTSTATUS = 0xC0000012u32 as i32; pub const STATUS_NO_MEDIA_IN_DEVICE: ::NTSTATUS = 0xC0000013u32 as i32; pub const STATUS_UNRECOGNIZED_MEDIA: ::NTSTATUS = 0xC0000014u32 as i32; pub const STATUS_NONEXISTENT_SECTOR: ::NTSTATUS = 0xC0000015u32 as i32; pub const STATUS_MORE_PROCESSING_REQUIRED: ::NTSTATUS = 0xC0000016u32 as i32; pub const STATUS_NO_MEMORY: ::NTSTATUS = 0xC0000017u32 as i32; pub const STATUS_CONFLICTING_ADDRESSES: ::NTSTATUS = 0xC0000018u32 as i32; pub const STATUS_NOT_MAPPED_VIEW: ::NTSTATUS = 0xC0000019u32 as i32; pub const STATUS_UNABLE_TO_FREE_VM: ::NTSTATUS = 0xC000001Au32 as i32; pub const STATUS_UNABLE_TO_DELETE_SECTION: ::NTSTATUS = 0xC000001Bu32 as i32; pub const STATUS_INVALID_SYSTEM_SERVICE: ::NTSTATUS = 0xC000001Cu32 as i32; pub const STATUS_ILLEGAL_INSTRUCTION: ::NTSTATUS = 0xC000001Du32 as i32; pub const STATUS_INVALID_LOCK_SEQUENCE: ::NTSTATUS = 0xC000001Eu32 as i32; pub const STATUS_INVALID_VIEW_SIZE: ::NTSTATUS = 0xC000001Fu32 as i32; pub const STATUS_INVALID_FILE_FOR_SECTION: ::NTSTATUS = 0xC0000020u32 as i32; pub const STATUS_ALREADY_COMMITTED: ::NTSTATUS = 0xC0000021u32 as i32; pub const STATUS_ACCESS_DENIED: ::NTSTATUS = 0xC0000022u32 as i32; pub const STATUS_BUFFER_TOO_SMALL: ::NTSTATUS = 0xC0000023u32 as i32; pub const STATUS_OBJECT_TYPE_MISMATCH: ::NTSTATUS = 0xC0000024u32 as i32; pub const STATUS_NONCONTINUABLE_EXCEPTION: ::NTSTATUS = 0xC0000025u32 as i32; pub const STATUS_INVALID_DISPOSITION: ::NTSTATUS = 0xC0000026u32 as i32; pub const STATUS_UNWIND: ::NTSTATUS = 0xC0000027u32 as i32; pub const STATUS_BAD_STACK: ::NTSTATUS = 0xC0000028u32 as i32; pub const STATUS_INVALID_UNWIND_TARGET: ::NTSTATUS = 0xC0000029u32 as i32; pub const STATUS_NOT_LOCKED: ::NTSTATUS = 0xC000002Au32 as i32; pub const STATUS_PARITY_ERROR: ::NTSTATUS = 0xC000002Bu32 as i32; pub const STATUS_UNABLE_TO_DECOMMIT_VM: ::NTSTATUS = 0xC000002Cu32 as i32; pub const STATUS_NOT_COMMITTED: ::NTSTATUS = 0xC000002Du32 as i32; pub const STATUS_INVALID_PORT_ATTRIBUTES: ::NTSTATUS = 0xC000002Eu32 as i32; pub const STATUS_PORT_MESSAGE_TOO_LONG: ::NTSTATUS = 0xC000002Fu32 as i32; pub const STATUS_INVALID_PARAMETER_MIX: ::NTSTATUS = 0xC0000030u32 as i32; pub const STATUS_INVALID_QUOTA_LOWER: ::NTSTATUS = 0xC0000031u32 as i32; pub const STATUS_DISK_CORRUPT_ERROR: ::NTSTATUS = 0xC0000032u32 as i32; pub const STATUS_OBJECT_NAME_INVALID: ::NTSTATUS = 0xC0000033u32 as i32; pub const STATUS_OBJECT_NAME_NOT_FOUND: ::NTSTATUS = 0xC0000034u32 as i32; pub const STATUS_OBJECT_NAME_COLLISION: ::NTSTATUS = 0xC0000035u32 as i32; pub const STATUS_PORT_DO_NOT_DISTURB: ::NTSTATUS = 0xC0000036u32 as i32; pub const STATUS_PORT_DISCONNECTED: ::NTSTATUS = 0xC0000037u32 as i32; pub const STATUS_DEVICE_ALREADY_ATTACHED: ::NTSTATUS = 0xC0000038u32 as i32; pub const STATUS_OBJECT_PATH_INVALID: ::NTSTATUS = 0xC0000039u32 as i32; pub const STATUS_OBJECT_PATH_NOT_FOUND: ::NTSTATUS = 0xC000003Au32 as i32; pub const STATUS_OBJECT_PATH_SYNTAX_BAD: ::NTSTATUS = 0xC000003Bu32 as i32; pub const STATUS_DATA_OVERRUN: ::NTSTATUS = 0xC000003Cu32 as i32; pub const STATUS_DATA_LATE_ERROR: ::NTSTATUS = 0xC000003Du32 as i32; pub const STATUS_DATA_ERROR: ::NTSTATUS = 0xC000003Eu32 as i32; pub const STATUS_CRC_ERROR: ::NTSTATUS = 0xC000003Fu32 as i32; pub const STATUS_SECTION_TOO_BIG: ::NTSTATUS = 0xC0000040u32 as i32; pub const STATUS_PORT_CONNECTION_REFUSED: ::NTSTATUS = 0xC0000041u32 as i32; pub const STATUS_INVALID_PORT_HANDLE: ::NTSTATUS = 0xC0000042u32 as i32; pub const STATUS_SHARING_VIOLATION: ::NTSTATUS = 0xC0000043u32 as i32; pub const STATUS_QUOTA_EXCEEDED: ::NTSTATUS = 0xC0000044u32 as i32; pub const STATUS_INVALID_PAGE_PROTECTION: ::NTSTATUS = 0xC0000045u32 as i32; pub const STATUS_MUTANT_NOT_OWNED: ::NTSTATUS = 0xC0000046u32 as i32; pub const STATUS_SEMAPHORE_LIMIT_EXCEEDED: ::NTSTATUS = 0xC0000047u32 as i32; pub const STATUS_PORT_ALREADY_SET: ::NTSTATUS = 0xC0000048u32 as i32; pub const STATUS_SECTION_NOT_IMAGE: ::NTSTATUS = 0xC0000049u32 as i32; pub const STATUS_SUSPEND_COUNT_EXCEEDED: ::NTSTATUS = 0xC000004Au32 as i32; pub const STATUS_THREAD_IS_TERMINATING: ::NTSTATUS = 0xC000004Bu32 as i32; pub const STATUS_BAD_WORKING_SET_LIMIT: ::NTSTATUS = 0xC000004Cu32 as i32; pub const STATUS_INCOMPATIBLE_FILE_MAP: ::NTSTATUS = 0xC000004Du32 as i32; pub const STATUS_SECTION_PROTECTION: ::NTSTATUS = 0xC000004Eu32 as i32; pub const STATUS_EAS_NOT_SUPPORTED: ::NTSTATUS = 0xC000004Fu32 as i32; pub const STATUS_EA_TOO_LARGE: ::NTSTATUS = 0xC0000050u32 as i32; pub const STATUS_NONEXISTENT_EA_ENTRY: ::NTSTATUS = 0xC0000051u32 as i32; pub const STATUS_NO_EAS_ON_FILE: ::NTSTATUS = 0xC0000052u32 as i32; pub const STATUS_EA_CORRUPT_ERROR: ::NTSTATUS = 0xC0000053u32 as i32; pub const STATUS_FILE_LOCK_CONFLICT: ::NTSTATUS = 0xC0000054u32 as i32; pub const STATUS_LOCK_NOT_GRANTED: ::NTSTATUS = 0xC0000055u32 as i32; pub const STATUS_DELETE_PENDING: ::NTSTATUS = 0xC0000056u32 as i32; pub const STATUS_CTL_FILE_NOT_SUPPORTED: ::NTSTATUS = 0xC0000057u32 as i32; pub const STATUS_UNKNOWN_REVISION: ::NTSTATUS = 0xC0000058u32 as i32; pub const STATUS_REVISION_MISMATCH: ::NTSTATUS = 0xC0000059u32 as i32; pub const STATUS_INVALID_OWNER: ::NTSTATUS = 0xC000005Au32 as i32; pub const STATUS_INVALID_PRIMARY_GROUP: ::NTSTATUS = 0xC000005Bu32 as i32; pub const STATUS_NO_IMPERSONATION_TOKEN: ::NTSTATUS = 0xC000005Cu32 as i32; pub const STATUS_CANT_DISABLE_MANDATORY: ::NTSTATUS = 0xC000005Du32 as i32; pub const STATUS_NO_LOGON_SERVERS: ::NTSTATUS = 0xC000005Eu32 as i32; pub const STATUS_NO_SUCH_LOGON_SESSION: ::NTSTATUS = 0xC000005Fu32 as i32; pub const STATUS_NO_SUCH_PRIVILEGE: ::NTSTATUS = 0xC0000060u32 as i32; pub const STATUS_PRIVILEGE_NOT_HELD: ::NTSTATUS = 0xC0000061u32 as i32; pub const STATUS_INVALID_ACCOUNT_NAME: ::NTSTATUS = 0xC0000062u32 as i32; pub const STATUS_USER_EXISTS: ::NTSTATUS = 0xC0000063u32 as i32; pub const STATUS_NO_SUCH_USER: ::NTSTATUS = 0xC0000064u32 as i32; pub const STATUS_GROUP_EXISTS: ::NTSTATUS = 0xC0000065u32 as i32; pub const STATUS_NO_SUCH_GROUP: ::NTSTATUS = 0xC0000066u32 as i32; pub const STATUS_MEMBER_IN_GROUP: ::NTSTATUS = 0xC0000067u32 as i32; pub const STATUS_MEMBER_NOT_IN_GROUP: ::NTSTATUS = 0xC0000068u32 as i32; pub const STATUS_LAST_ADMIN: ::NTSTATUS = 0xC0000069u32 as i32; pub const STATUS_WRONG_PASSWORD: ::NTSTATUS = 0xC000006Au32 as i32; pub const STATUS_ILL_FORMED_PASSWORD: ::NTSTATUS = 0xC000006Bu32 as i32; pub const STATUS_PASSWORD_RESTRICTION: ::NTSTATUS = 0xC000006Cu32 as i32; pub const STATUS_LOGON_FAILURE: ::NTSTATUS = 0xC000006Du32 as i32; pub const STATUS_ACCOUNT_RESTRICTION: ::NTSTATUS = 0xC000006Eu32 as i32; pub const STATUS_INVALID_LOGON_HOURS: ::NTSTATUS = 0xC000006Fu32 as i32; pub const STATUS_INVALID_WORKSTATION: ::NTSTATUS = 0xC0000070u32 as i32; pub const STATUS_PASSWORD_EXPIRED: ::NTSTATUS = 0xC0000071u32 as i32; pub const STATUS_ACCOUNT_DISABLED: ::NTSTATUS = 0xC0000072u32 as i32; pub const STATUS_NONE_MAPPED: ::NTSTATUS = 0xC0000073u32 as i32; pub const STATUS_TOO_MANY_LUIDS_REQUESTED: ::NTSTATUS = 0xC0000074u32 as i32; pub const STATUS_LUIDS_EXHAUSTED: ::NTSTATUS = 0xC0000075u32 as i32; pub const STATUS_INVALID_SUB_AUTHORITY: ::NTSTATUS = 0xC0000076u32 as i32; pub const STATUS_INVALID_ACL: ::NTSTATUS = 0xC0000077u32 as i32; pub const STATUS_INVALID_SID: ::NTSTATUS = 0xC0000078u32 as i32; pub const STATUS_INVALID_SECURITY_DESCR: ::NTSTATUS = 0xC0000079u32 as i32; pub const STATUS_PROCEDURE_NOT_FOUND: ::NTSTATUS = 0xC000007Au32 as i32; pub const STATUS_INVALID_IMAGE_FORMAT: ::NTSTATUS = 0xC000007Bu32 as i32; pub const STATUS_NO_TOKEN: ::NTSTATUS = 0xC000007Cu32 as i32; pub const STATUS_BAD_INHERITANCE_ACL: ::NTSTATUS = 0xC000007Du32 as i32; pub const STATUS_RANGE_NOT_LOCKED: ::NTSTATUS = 0xC000007Eu32 as i32; pub const STATUS_DISK_FULL: ::NTSTATUS = 0xC000007Fu32 as i32; pub const STATUS_SERVER_DISABLED: ::NTSTATUS = 0xC0000080u32 as i32; pub const STATUS_SERVER_NOT_DISABLED: ::NTSTATUS = 0xC0000081u32 as i32; pub const STATUS_TOO_MANY_GUIDS_REQUESTED: ::NTSTATUS = 0xC0000082u32 as i32; pub const STATUS_GUIDS_EXHAUSTED: ::NTSTATUS = 0xC0000083u32 as i32; pub const STATUS_INVALID_ID_AUTHORITY: ::NTSTATUS = 0xC0000084u32 as i32; pub const STATUS_AGENTS_EXHAUSTED: ::NTSTATUS = 0xC0000085u32 as i32; pub const STATUS_INVALID_VOLUME_LABEL: ::NTSTATUS = 0xC0000086u32 as i32; pub const STATUS_SECTION_NOT_EXTENDED: ::NTSTATUS = 0xC0000087u32 as i32; pub const STATUS_NOT_MAPPED_DATA: ::NTSTATUS = 0xC0000088u32 as i32; pub const STATUS_RESOURCE_DATA_NOT_FOUND: ::NTSTATUS = 0xC0000089u32 as i32; pub const STATUS_RESOURCE_TYPE_NOT_FOUND: ::NTSTATUS = 0xC000008Au32 as i32; pub const STATUS_RESOURCE_NAME_NOT_FOUND: ::NTSTATUS = 0xC000008Bu32 as i32; pub const STATUS_ARRAY_BOUNDS_EXCEEDED: ::NTSTATUS = 0xC000008Cu32 as i32; pub const STATUS_FLOAT_DENORMAL_OPERAND: ::NTSTATUS = 0xC000008Du32 as i32; pub const STATUS_FLOAT_DIVIDE_BY_ZERO: ::NTSTATUS = 0xC000008Eu32 as i32; pub const STATUS_FLOAT_INEXACT_RESULT: ::NTSTATUS = 0xC000008Fu32 as i32; pub const STATUS_FLOAT_INVALID_OPERATION: ::NTSTATUS = 0xC0000090u32 as i32; pub const STATUS_FLOAT_OVERFLOW: ::NTSTATUS = 0xC0000091u32 as i32; pub const STATUS_FLOAT_STACK_CHECK: ::NTSTATUS = 0xC0000092u32 as i32; pub const STATUS_FLOAT_UNDERFLOW: ::NTSTATUS = 0xC0000093u32 as i32; pub const STATUS_INTEGER_DIVIDE_BY_ZERO: ::NTSTATUS = 0xC0000094u32 as i32; pub const STATUS_INTEGER_OVERFLOW: ::NTSTATUS = 0xC0000095u32 as i32; pub const STATUS_PRIVILEGED_INSTRUCTION: ::NTSTATUS = 0xC0000096u32 as i32; pub const STATUS_TOO_MANY_PAGING_FILES: ::NTSTATUS = 0xC0000097u32 as i32; pub const STATUS_FILE_INVALID: ::NTSTATUS = 0xC0000098u32 as i32; pub const STATUS_ALLOTTED_SPACE_EXCEEDED: ::NTSTATUS = 0xC0000099u32 as i32; pub const STATUS_INSUFFICIENT_RESOURCES: ::NTSTATUS = 0xC000009Au32 as i32; pub const STATUS_DFS_EXIT_PATH_FOUND: ::NTSTATUS = 0xC000009Bu32 as i32; pub const STATUS_DEVICE_DATA_ERROR: ::NTSTATUS = 0xC000009Cu32 as i32; pub const STATUS_DEVICE_NOT_CONNECTED: ::NTSTATUS = 0xC000009Du32 as i32; pub const STATUS_DEVICE_POWER_FAILURE: ::NTSTATUS = 0xC000009Eu32 as i32; pub const STATUS_FREE_VM_NOT_AT_BASE: ::NTSTATUS = 0xC000009Fu32 as i32; pub const STATUS_MEMORY_NOT_ALLOCATED: ::NTSTATUS = 0xC00000A0u32 as i32; pub const STATUS_WORKING_SET_QUOTA: ::NTSTATUS = 0xC00000A1u32 as i32; pub const STATUS_MEDIA_WRITE_PROTECTED: ::NTSTATUS = 0xC00000A2u32 as i32; pub const STATUS_DEVICE_NOT_READY: ::NTSTATUS = 0xC00000A3u32 as i32; pub const STATUS_INVALID_GROUP_ATTRIBUTES: ::NTSTATUS = 0xC00000A4u32 as i32; pub const STATUS_BAD_IMPERSONATION_LEVEL: ::NTSTATUS = 0xC00000A5u32 as i32; pub const STATUS_CANT_OPEN_ANONYMOUS: ::NTSTATUS = 0xC00000A6u32 as i32; pub const STATUS_BAD_VALIDATION_CLASS: ::NTSTATUS = 0xC00000A7u32 as i32; pub const STATUS_BAD_TOKEN_TYPE: ::NTSTATUS = 0xC00000A8u32 as i32; pub const STATUS_BAD_MASTER_BOOT_RECORD: ::NTSTATUS = 0xC00000A9u32 as i32; pub const STATUS_INSTRUCTION_MISALIGNMENT: ::NTSTATUS = 0xC00000AAu32 as i32; pub const STATUS_INSTANCE_NOT_AVAILABLE: ::NTSTATUS = 0xC00000ABu32 as i32; pub const STATUS_PIPE_NOT_AVAILABLE: ::NTSTATUS = 0xC00000ACu32 as i32; pub const STATUS_INVALID_PIPE_STATE: ::NTSTATUS = 0xC00000ADu32 as i32; pub const STATUS_PIPE_BUSY: ::NTSTATUS = 0xC00000AEu32 as i32; pub const STATUS_ILLEGAL_FUNCTION: ::NTSTATUS = 0xC00000AFu32 as i32; pub const STATUS_PIPE_DISCONNECTED: ::NTSTATUS = 0xC00000B0u32 as i32; pub const STATUS_PIPE_CLOSING: ::NTSTATUS = 0xC00000B1u32 as i32; pub const STATUS_PIPE_CONNECTED: ::NTSTATUS = 0xC00000B2u32 as i32; pub const STATUS_PIPE_LISTENING: ::NTSTATUS = 0xC00000B3u32 as i32; pub const STATUS_INVALID_READ_MODE: ::NTSTATUS = 0xC00000B4u32 as i32; pub const STATUS_IO_TIMEOUT: ::NTSTATUS = 0xC00000B5u32 as i32; pub const STATUS_FILE_FORCED_CLOSED: ::NTSTATUS = 0xC00000B6u32 as i32; pub const STATUS_PROFILING_NOT_STARTED: ::NTSTATUS = 0xC00000B7u32 as i32; pub const STATUS_PROFILING_NOT_STOPPED: ::NTSTATUS = 0xC00000B8u32 as i32; pub const STATUS_COULD_NOT_INTERPRET: ::NTSTATUS = 0xC00000B9u32 as i32; pub const STATUS_FILE_IS_A_DIRECTORY: ::NTSTATUS = 0xC00000BAu32 as i32; pub const STATUS_NOT_SUPPORTED: ::NTSTATUS = 0xC00000BBu32 as i32; pub const STATUS_REMOTE_NOT_LISTENING: ::NTSTATUS = 0xC00000BCu32 as i32; pub const STATUS_DUPLICATE_NAME: ::NTSTATUS = 0xC00000BDu32 as i32; pub const STATUS_BAD_NETWORK_PATH: ::NTSTATUS = 0xC00000BEu32 as i32; pub const STATUS_NETWORK_BUSY: ::NTSTATUS = 0xC00000BFu32 as i32; pub const STATUS_DEVICE_DOES_NOT_EXIST: ::NTSTATUS = 0xC00000C0u32 as i32; pub const STATUS_TOO_MANY_COMMANDS: ::NTSTATUS = 0xC00000C1u32 as i32; pub const STATUS_ADAPTER_HARDWARE_ERROR: ::NTSTATUS = 0xC00000C2u32 as i32; pub const STATUS_INVALID_NETWORK_RESPONSE: ::NTSTATUS = 0xC00000C3u32 as i32; pub const STATUS_UNEXPECTED_NETWORK_ERROR: ::NTSTATUS = 0xC00000C4u32 as i32; pub const STATUS_BAD_REMOTE_ADAPTER: ::NTSTATUS = 0xC00000C5u32 as i32; pub const STATUS_PRINT_QUEUE_FULL: ::NTSTATUS = 0xC00000C6u32 as i32; pub const STATUS_NO_SPOOL_SPACE: ::NTSTATUS = 0xC00000C7u32 as i32; pub const STATUS_PRINT_CANCELLED: ::NTSTATUS = 0xC00000C8u32 as i32; pub const STATUS_NETWORK_NAME_DELETED: ::NTSTATUS = 0xC00000C9u32 as i32; pub const STATUS_NETWORK_ACCESS_DENIED: ::NTSTATUS = 0xC00000CAu32 as i32; pub const STATUS_BAD_DEVICE_TYPE: ::NTSTATUS = 0xC00000CBu32 as i32; pub const STATUS_BAD_NETWORK_NAME: ::NTSTATUS = 0xC00000CCu32 as i32; pub const STATUS_TOO_MANY_NAMES: ::NTSTATUS = 0xC00000CDu32 as i32; pub const STATUS_TOO_MANY_SESSIONS: ::NTSTATUS = 0xC00000CEu32 as i32; pub const STATUS_SHARING_PAUSED: ::NTSTATUS = 0xC00000CFu32 as i32; pub const STATUS_REQUEST_NOT_ACCEPTED: ::NTSTATUS = 0xC00000D0u32 as i32; pub const STATUS_REDIRECTOR_PAUSED: ::NTSTATUS = 0xC00000D1u32 as i32; pub const STATUS_NET_WRITE_FAULT: ::NTSTATUS = 0xC00000D2u32 as i32; pub const STATUS_PROFILING_AT_LIMIT: ::NTSTATUS = 0xC00000D3u32 as i32; pub const STATUS_NOT_SAME_DEVICE: ::NTSTATUS = 0xC00000D4u32 as i32; pub const STATUS_FILE_RENAMED: ::NTSTATUS = 0xC00000D5u32 as i32; pub const STATUS_VIRTUAL_CIRCUIT_CLOSED: ::NTSTATUS = 0xC00000D6u32 as i32; pub const STATUS_NO_SECURITY_ON_OBJECT: ::NTSTATUS = 0xC00000D7u32 as i32; pub const STATUS_CANT_WAIT: ::NTSTATUS = 0xC00000D8u32 as i32; pub const STATUS_PIPE_EMPTY: ::NTSTATUS = 0xC00000D9u32 as i32; pub const STATUS_CANT_ACCESS_DOMAIN_INFO: ::NTSTATUS = 0xC00000DAu32 as i32; pub const STATUS_CANT_TERMINATE_SELF: ::NTSTATUS = 0xC00000DBu32 as i32; pub const STATUS_INVALID_SERVER_STATE: ::NTSTATUS = 0xC00000DCu32 as i32; pub const STATUS_INVALID_DOMAIN_STATE: ::NTSTATUS = 0xC00000DDu32 as i32; pub const STATUS_INVALID_DOMAIN_ROLE: ::NTSTATUS = 0xC00000DEu32 as i32; pub const STATUS_NO_SUCH_DOMAIN: ::NTSTATUS = 0xC00000DFu32 as i32; pub const STATUS_DOMAIN_EXISTS: ::NTSTATUS = 0xC00000E0u32 as i32; pub const STATUS_DOMAIN_LIMIT_EXCEEDED: ::NTSTATUS = 0xC00000E1u32 as i32; pub const STATUS_OPLOCK_NOT_GRANTED: ::NTSTATUS = 0xC00000E2u32 as i32; pub const STATUS_INVALID_OPLOCK_PROTOCOL: ::NTSTATUS = 0xC00000E3u32 as i32; pub const STATUS_INTERNAL_DB_CORRUPTION: ::NTSTATUS = 0xC00000E4u32 as i32; pub const STATUS_INTERNAL_ERROR: ::NTSTATUS = 0xC00000E5u32 as i32; pub const STATUS_GENERIC_NOT_MAPPED: ::NTSTATUS = 0xC00000E6u32 as i32; pub const STATUS_BAD_DESCRIPTOR_FORMAT: ::NTSTATUS = 0xC00000E7u32 as i32; pub const STATUS_INVALID_USER_BUFFER: ::NTSTATUS = 0xC00000E8u32 as i32; pub const STATUS_UNEXPECTED_IO_ERROR: ::NTSTATUS = 0xC00000E9u32 as i32; pub const STATUS_UNEXPECTED_MM_CREATE_ERR: ::NTSTATUS = 0xC00000EAu32 as i32; pub const STATUS_UNEXPECTED_MM_MAP_ERROR: ::NTSTATUS = 0xC00000EBu32 as i32; pub const STATUS_UNEXPECTED_MM_EXTEND_ERR: ::NTSTATUS = 0xC00000ECu32 as i32; pub const STATUS_NOT_LOGON_PROCESS: ::NTSTATUS = 0xC00000EDu32 as i32; pub const STATUS_LOGON_SESSION_EXISTS: ::NTSTATUS = 0xC00000EEu32 as i32; pub const STATUS_INVALID_PARAMETER_1: ::NTSTATUS = 0xC00000EFu32 as i32; pub const STATUS_INVALID_PARAMETER_2: ::NTSTATUS = 0xC00000F0u32 as i32; pub const STATUS_INVALID_PARAMETER_3: ::NTSTATUS = 0xC00000F1u32 as i32; pub const STATUS_INVALID_PARAMETER_4: ::NTSTATUS = 0xC00000F2u32 as i32; pub const STATUS_INVALID_PARAMETER_5: ::NTSTATUS = 0xC00000F3u32 as i32; pub const STATUS_INVALID_PARAMETER_6: ::NTSTATUS = 0xC00000F4u32 as i32; pub const STATUS_INVALID_PARAMETER_7: ::NTSTATUS = 0xC00000F5u32 as i32; pub const STATUS_INVALID_PARAMETER_8: ::NTSTATUS = 0xC00000F6u32 as i32; pub const STATUS_INVALID_PARAMETER_9: ::NTSTATUS = 0xC00000F7u32 as i32; pub const STATUS_INVALID_PARAMETER_10: ::NTSTATUS = 0xC00000F8u32 as i32; pub const STATUS_INVALID_PARAMETER_11: ::NTSTATUS = 0xC00000F9u32 as i32; pub const STATUS_INVALID_PARAMETER_12: ::NTSTATUS = 0xC00000FAu32 as i32; pub const STATUS_REDIRECTOR_NOT_STARTED: ::NTSTATUS = 0xC00000FBu32 as i32; pub const STATUS_REDIRECTOR_STARTED: ::NTSTATUS = 0xC00000FCu32 as i32; pub const STATUS_STACK_OVERFLOW: ::NTSTATUS = 0xC00000FDu32 as i32; pub const STATUS_NO_SUCH_PACKAGE: ::NTSTATUS = 0xC00000FEu32 as i32; pub const STATUS_BAD_FUNCTION_TABLE: ::NTSTATUS = 0xC00000FFu32 as i32; pub const STATUS_VARIABLE_NOT_FOUND: ::NTSTATUS = 0xC0000100u32 as i32; pub const STATUS_DIRECTORY_NOT_EMPTY: ::NTSTATUS = 0xC0000101u32 as i32; pub const STATUS_FILE_CORRUPT_ERROR: ::NTSTATUS = 0xC0000102u32 as i32; pub const STATUS_NOT_A_DIRECTORY: ::NTSTATUS = 0xC0000103u32 as i32; pub const STATUS_BAD_LOGON_SESSION_STATE: ::NTSTATUS = 0xC0000104u32 as i32; pub const STATUS_LOGON_SESSION_COLLISION: ::NTSTATUS = 0xC0000105u32 as i32; pub const STATUS_NAME_TOO_LONG: ::NTSTATUS = 0xC0000106u32 as i32; pub const STATUS_FILES_OPEN: ::NTSTATUS = 0xC0000107u32 as i32; pub const STATUS_CONNECTION_IN_USE: ::NTSTATUS = 0xC0000108u32 as i32; pub const STATUS_MESSAGE_NOT_FOUND: ::NTSTATUS = 0xC0000109u32 as i32; pub const STATUS_PROCESS_IS_TERMINATING: ::NTSTATUS = 0xC000010Au32 as i32; pub const STATUS_INVALID_LOGON_TYPE: ::NTSTATUS = 0xC000010Bu32 as i32; pub const STATUS_NO_GUID_TRANSLATION: ::NTSTATUS = 0xC000010Cu32 as i32; pub const STATUS_CANNOT_IMPERSONATE: ::NTSTATUS = 0xC000010Du32 as i32; pub const STATUS_IMAGE_ALREADY_LOADED: ::NTSTATUS = 0xC000010Eu32 as i32; pub const STATUS_ABIOS_NOT_PRESENT: ::NTSTATUS = 0xC000010Fu32 as i32; pub const STATUS_ABIOS_LID_NOT_EXIST: ::NTSTATUS = 0xC0000110u32 as i32; pub const STATUS_ABIOS_LID_ALREADY_OWNED: ::NTSTATUS = 0xC0000111u32 as i32; pub const STATUS_ABIOS_NOT_LID_OWNER: ::NTSTATUS = 0xC0000112u32 as i32; pub const STATUS_ABIOS_INVALID_COMMAND: ::NTSTATUS = 0xC0000113u32 as i32; pub const STATUS_ABIOS_INVALID_LID: ::NTSTATUS = 0xC0000114u32 as i32; pub const STATUS_ABIOS_SELECTOR_NOT_AVAILABLE: ::NTSTATUS = 0xC0000115u32 as i32; pub const STATUS_ABIOS_INVALID_SELECTOR: ::NTSTATUS = 0xC0000116u32 as i32; pub const STATUS_NO_LDT: ::NTSTATUS = 0xC0000117u32 as i32; pub const STATUS_INVALID_LDT_SIZE: ::NTSTATUS = 0xC0000118u32 as i32; pub const STATUS_INVALID_LDT_OFFSET: ::NTSTATUS = 0xC0000119u32 as i32; pub const STATUS_INVALID_LDT_DESCRIPTOR: ::NTSTATUS = 0xC000011Au32 as i32; pub const STATUS_INVALID_IMAGE_NE_FORMAT: ::NTSTATUS = 0xC000011Bu32 as i32; pub const STATUS_RXACT_INVALID_STATE: ::NTSTATUS = 0xC000011Cu32 as i32; pub const STATUS_RXACT_COMMIT_FAILURE: ::NTSTATUS = 0xC000011Du32 as i32; pub const STATUS_MAPPED_FILE_SIZE_ZERO: ::NTSTATUS = 0xC000011Eu32 as i32; pub const STATUS_TOO_MANY_OPENED_FILES: ::NTSTATUS = 0xC000011Fu32 as i32; pub const STATUS_CANCELLED: ::NTSTATUS = 0xC0000120u32 as i32; pub const STATUS_CANNOT_DELETE: ::NTSTATUS = 0xC0000121u32 as i32; pub const STATUS_INVALID_COMPUTER_NAME: ::NTSTATUS = 0xC0000122u32 as i32; pub const STATUS_FILE_DELETED: ::NTSTATUS = 0xC0000123u32 as i32; pub const STATUS_SPECIAL_ACCOUNT: ::NTSTATUS = 0xC0000124u32 as i32; pub const STATUS_SPECIAL_GROUP: ::NTSTATUS = 0xC0000125u32 as i32; pub const STATUS_SPECIAL_USER: ::NTSTATUS = 0xC0000126u32 as i32; pub const STATUS_MEMBERS_PRIMARY_GROUP: ::NTSTATUS = 0xC0000127u32 as i32; pub const STATUS_FILE_CLOSED: ::NTSTATUS = 0xC0000128u32 as i32; pub const STATUS_TOO_MANY_THREADS: ::NTSTATUS = 0xC0000129u32 as i32; pub const STATUS_THREAD_NOT_IN_PROCESS: ::NTSTATUS = 0xC000012Au32 as i32; pub const STATUS_TOKEN_ALREADY_IN_USE: ::NTSTATUS = 0xC000012Bu32 as i32; pub const STATUS_PAGEFILE_QUOTA_EXCEEDED: ::NTSTATUS = 0xC000012Cu32 as i32; pub const STATUS_COMMITMENT_LIMIT: ::NTSTATUS = 0xC000012Du32 as i32; pub const STATUS_INVALID_IMAGE_LE_FORMAT: ::NTSTATUS = 0xC000012Eu32 as i32; pub const STATUS_INVALID_IMAGE_NOT_MZ: ::NTSTATUS = 0xC000012Fu32 as i32; pub const STATUS_INVALID_IMAGE_PROTECT: ::NTSTATUS = 0xC0000130u32 as i32; pub const STATUS_INVALID_IMAGE_WIN_16: ::NTSTATUS = 0xC0000131u32 as i32; pub const STATUS_LOGON_SERVER_CONFLICT: ::NTSTATUS = 0xC0000132u32 as i32; pub const STATUS_TIME_DIFFERENCE_AT_DC: ::NTSTATUS = 0xC0000133u32 as i32; pub const STATUS_SYNCHRONIZATION_REQUIRED: ::NTSTATUS = 0xC0000134u32 as i32; pub const STATUS_DLL_NOT_FOUND: ::NTSTATUS = 0xC0000135u32 as i32; pub const STATUS_OPEN_FAILED: ::NTSTATUS = 0xC0000136u32 as i32; pub const STATUS_IO_PRIVILEGE_FAILED: ::NTSTATUS = 0xC0000137u32 as i32; pub const STATUS_ORDINAL_NOT_FOUND: ::NTSTATUS = 0xC0000138u32 as i32; pub const STATUS_ENTRYPOINT_NOT_FOUND: ::NTSTATUS = 0xC0000139u32 as i32; pub const STATUS_CONTROL_C_EXIT: ::NTSTATUS = 0xC000013Au32 as i32; pub const STATUS_LOCAL_DISCONNECT: ::NTSTATUS = 0xC000013Bu32 as i32; pub const STATUS_REMOTE_DISCONNECT: ::NTSTATUS = 0xC000013Cu32 as i32; pub const STATUS_REMOTE_RESOURCES: ::NTSTATUS = 0xC000013Du32 as i32; pub const STATUS_LINK_FAILED: ::NTSTATUS = 0xC000013Eu32 as i32; pub const STATUS_LINK_TIMEOUT: ::NTSTATUS = 0xC000013Fu32 as i32; pub const STATUS_INVALID_CONNECTION: ::NTSTATUS = 0xC0000140u32 as i32; pub const STATUS_INVALID_ADDRESS: ::NTSTATUS = 0xC0000141u32 as i32; pub const STATUS_DLL_INIT_FAILED: ::NTSTATUS = 0xC0000142u32 as i32; pub const STATUS_MISSING_SYSTEMFILE: ::NTSTATUS = 0xC0000143u32 as i32; pub const STATUS_UNHANDLED_EXCEPTION: ::NTSTATUS = 0xC0000144u32 as i32; pub const STATUS_APP_INIT_FAILURE: ::NTSTATUS = 0xC0000145u32 as i32; pub const STATUS_PAGEFILE_CREATE_FAILED: ::NTSTATUS = 0xC0000146u32 as i32; pub const STATUS_NO_PAGEFILE: ::NTSTATUS = 0xC0000147u32 as i32; pub const STATUS_INVALID_LEVEL: ::NTSTATUS = 0xC0000148u32 as i32; pub const STATUS_WRONG_PASSWORD_CORE: ::NTSTATUS = 0xC0000149u32 as i32; pub const STATUS_ILLEGAL_FLOAT_CONTEXT: ::NTSTATUS = 0xC000014Au32 as i32; pub const STATUS_PIPE_BROKEN: ::NTSTATUS = 0xC000014Bu32 as i32; pub const STATUS_REGISTRY_CORRUPT: ::NTSTATUS = 0xC000014Cu32 as i32; pub const STATUS_REGISTRY_IO_FAILED: ::NTSTATUS = 0xC000014Du32 as i32; pub const STATUS_NO_EVENT_PAIR: ::NTSTATUS = 0xC000014Eu32 as i32; pub const STATUS_UNRECOGNIZED_VOLUME: ::NTSTATUS = 0xC000014Fu32 as i32; pub const STATUS_SERIAL_NO_DEVICE_INITED: ::NTSTATUS = 0xC0000150u32 as i32; pub const STATUS_NO_SUCH_ALIAS: ::NTSTATUS = 0xC0000151u32 as i32; pub const STATUS_MEMBER_NOT_IN_ALIAS: ::NTSTATUS = 0xC0000152u32 as i32; pub const STATUS_MEMBER_IN_ALIAS: ::NTSTATUS = 0xC0000153u32 as i32; pub const STATUS_ALIAS_EXISTS: ::NTSTATUS = 0xC0000154u32 as i32; pub const STATUS_LOGON_NOT_GRANTED: ::NTSTATUS = 0xC0000155u32 as i32; pub const STATUS_TOO_MANY_SECRETS: ::NTSTATUS = 0xC0000156u32 as i32; pub const STATUS_SECRET_TOO_LONG: ::NTSTATUS = 0xC0000157u32 as i32; pub const STATUS_INTERNAL_DB_ERROR: ::NTSTATUS = 0xC0000158u32 as i32; pub const STATUS_FULLSCREEN_MODE: ::NTSTATUS = 0xC0000159u32 as i32; pub const STATUS_TOO_MANY_CONTEXT_IDS: ::NTSTATUS = 0xC000015Au32 as i32; pub const STATUS_LOGON_TYPE_NOT_GRANTED: ::NTSTATUS = 0xC000015Bu32 as i32; pub const STATUS_NOT_REGISTRY_FILE: ::NTSTATUS = 0xC000015Cu32 as i32; pub const STATUS_NT_CROSS_ENCRYPTION_REQUIRED: ::NTSTATUS = 0xC000015Du32 as i32; pub const STATUS_DOMAIN_CTRLR_CONFIG_ERROR: ::NTSTATUS = 0xC000015Eu32 as i32; pub const STATUS_FT_MISSING_MEMBER: ::NTSTATUS = 0xC000015Fu32 as i32; pub const STATUS_ILL_FORMED_SERVICE_ENTRY: ::NTSTATUS = 0xC0000160u32 as i32; pub const STATUS_ILLEGAL_CHARACTER: ::NTSTATUS = 0xC0000161u32 as i32; pub const STATUS_UNMAPPABLE_CHARACTER: ::NTSTATUS = 0xC0000162u32 as i32; pub const STATUS_UNDEFINED_CHARACTER: ::NTSTATUS = 0xC0000163u32 as i32; pub const STATUS_FLOPPY_VOLUME: ::NTSTATUS = 0xC0000164u32 as i32; pub const STATUS_FLOPPY_ID_MARK_NOT_FOUND: ::NTSTATUS = 0xC0000165u32 as i32; pub const STATUS_FLOPPY_WRONG_CYLINDER: ::NTSTATUS = 0xC0000166u32 as i32; pub const STATUS_FLOPPY_UNKNOWN_ERROR: ::NTSTATUS = 0xC0000167u32 as i32; pub const STATUS_FLOPPY_BAD_REGISTERS: ::NTSTATUS = 0xC0000168u32 as i32; pub const STATUS_DISK_RECALIBRATE_FAILED: ::NTSTATUS = 0xC0000169u32 as i32; pub const STATUS_DISK_OPERATION_FAILED: ::NTSTATUS = 0xC000016Au32 as i32; pub const STATUS_DISK_RESET_FAILED: ::NTSTATUS = 0xC000016Bu32 as i32; pub const STATUS_SHARED_IRQ_BUSY: ::NTSTATUS = 0xC000016Cu32 as i32; pub const STATUS_FT_ORPHANING: ::NTSTATUS = 0xC000016Du32 as i32; pub const STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT: ::NTSTATUS = 0xC000016Eu32 as i32; pub const STATUS_PARTITION_FAILURE: ::NTSTATUS = 0xC0000172u32 as i32; pub const STATUS_INVALID_BLOCK_LENGTH: ::NTSTATUS = 0xC0000173u32 as i32; pub const STATUS_DEVICE_NOT_PARTITIONED: ::NTSTATUS = 0xC0000174u32 as i32; pub const STATUS_UNABLE_TO_LOCK_MEDIA: ::NTSTATUS = 0xC0000175u32 as i32; pub const STATUS_UNABLE_TO_UNLOAD_MEDIA: ::NTSTATUS = 0xC0000176u32 as i32; pub const STATUS_EOM_OVERFLOW: ::NTSTATUS = 0xC0000177u32 as i32; pub const STATUS_NO_MEDIA: ::NTSTATUS = 0xC0000178u32 as i32; pub const STATUS_NO_SUCH_MEMBER: ::NTSTATUS = 0xC000017Au32 as i32; pub const STATUS_INVALID_MEMBER: ::NTSTATUS = 0xC000017Bu32 as i32; pub const STATUS_KEY_DELETED: ::NTSTATUS = 0xC000017Cu32 as i32; pub const STATUS_NO_LOG_SPACE: ::NTSTATUS = 0xC000017Du32 as i32; pub const STATUS_TOO_MANY_SIDS: ::NTSTATUS = 0xC000017Eu32 as i32; pub const STATUS_LM_CROSS_ENCRYPTION_REQUIRED: ::NTSTATUS = 0xC000017Fu32 as i32; pub const STATUS_KEY_HAS_CHILDREN: ::NTSTATUS = 0xC0000180u32 as i32; pub const STATUS_CHILD_MUST_BE_VOLATILE: ::NTSTATUS = 0xC0000181u32 as i32; pub const STATUS_DEVICE_CONFIGURATION_ERROR: ::NTSTATUS = 0xC0000182u32 as i32; pub const STATUS_DRIVER_INTERNAL_ERROR: ::NTSTATUS = 0xC0000183u32 as i32; pub const STATUS_INVALID_DEVICE_STATE: ::NTSTATUS = 0xC0000184u32 as i32; pub const STATUS_IO_DEVICE_ERROR: ::NTSTATUS = 0xC0000185u32 as i32; pub const STATUS_DEVICE_PROTOCOL_ERROR: ::NTSTATUS = 0xC0000186u32 as i32; pub const STATUS_BACKUP_CONTROLLER: ::NTSTATUS = 0xC0000187u32 as i32; pub const STATUS_LOG_FILE_FULL: ::NTSTATUS = 0xC0000188u32 as i32; pub const STATUS_TOO_LATE: ::NTSTATUS = 0xC0000189u32 as i32; pub const STATUS_NO_TRUST_LSA_SECRET: ::NTSTATUS = 0xC000018Au32 as i32; pub const STATUS_NO_TRUST_SAM_ACCOUNT: ::NTSTATUS = 0xC000018Bu32 as i32; pub const STATUS_TRUSTED_DOMAIN_FAILURE: ::NTSTATUS = 0xC000018Cu32 as i32; pub const STATUS_TRUSTED_RELATIONSHIP_FAILURE: ::NTSTATUS = 0xC000018Du32 as i32; pub const STATUS_EVENTLOG_FILE_CORRUPT: ::NTSTATUS = 0xC000018Eu32 as i32; pub const STATUS_EVENTLOG_CANT_START: ::NTSTATUS = 0xC000018Fu32 as i32; pub const STATUS_TRUST_FAILURE: ::NTSTATUS = 0xC0000190u32 as i32; pub const STATUS_MUTANT_LIMIT_EXCEEDED: ::NTSTATUS = 0xC0000191u32 as i32; pub const STATUS_NETLOGON_NOT_STARTED: ::NTSTATUS = 0xC0000192u32 as i32; pub const STATUS_ACCOUNT_EXPIRED: ::NTSTATUS = 0xC0000193u32 as i32; pub const STATUS_POSSIBLE_DEADLOCK: ::NTSTATUS = 0xC0000194u32 as i32; pub const STATUS_NETWORK_CREDENTIAL_CONFLICT: ::NTSTATUS = 0xC0000195u32 as i32; pub const STATUS_REMOTE_SESSION_LIMIT: ::NTSTATUS = 0xC0000196u32 as i32; pub const STATUS_EVENTLOG_FILE_CHANGED: ::NTSTATUS = 0xC0000197u32 as i32; pub const STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT: ::NTSTATUS = 0xC0000198u32 as i32; pub const STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT: ::NTSTATUS = 0xC0000199u32 as i32; pub const STATUS_NOLOGON_SERVER_TRUST_ACCOUNT: ::NTSTATUS = 0xC000019Au32 as i32; pub const STATUS_DOMAIN_TRUST_INCONSISTENT: ::NTSTATUS = 0xC000019Bu32 as i32; pub const STATUS_FS_DRIVER_REQUIRED: ::NTSTATUS = 0xC000019Cu32 as i32; pub const STATUS_IMAGE_ALREADY_LOADED_AS_DLL: ::NTSTATUS = 0xC000019Du32 as i32; pub const STATUS_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING: ::NTSTATUS = 0xC000019Eu32 as i32; pub const STATUS_SHORT_NAMES_NOT_ENABLED_ON_VOLUME: ::NTSTATUS = 0xC000019Fu32 as i32; pub const STATUS_SECURITY_STREAM_IS_INCONSISTENT: ::NTSTATUS = 0xC00001A0u32 as i32; pub const STATUS_INVALID_LOCK_RANGE: ::NTSTATUS = 0xC00001A1u32 as i32; pub const STATUS_INVALID_ACE_CONDITION: ::NTSTATUS = 0xC00001A2u32 as i32; pub const STATUS_IMAGE_SUBSYSTEM_NOT_PRESENT: ::NTSTATUS = 0xC00001A3u32 as i32; pub const STATUS_NOTIFICATION_GUID_ALREADY_DEFINED: ::NTSTATUS = 0xC00001A4u32 as i32; pub const STATUS_INVALID_EXCEPTION_HANDLER: ::NTSTATUS = 0xC00001A5u32 as i32; pub const STATUS_DUPLICATE_PRIVILEGES: ::NTSTATUS = 0xC00001A6u32 as i32; pub const STATUS_NOT_ALLOWED_ON_SYSTEM_FILE: ::NTSTATUS = 0xC00001A7u32 as i32; pub const STATUS_REPAIR_NEEDED: ::NTSTATUS = 0xC00001A8u32 as i32; pub const STATUS_QUOTA_NOT_ENABLED: ::NTSTATUS = 0xC00001A9u32 as i32; pub const STATUS_NO_APPLICATION_PACKAGE: ::NTSTATUS = 0xC00001AAu32 as i32; pub const STATUS_FILE_METADATA_OPTIMIZATION_IN_PROGRESS: ::NTSTATUS = 0xC00001ABu32 as i32; pub const STATUS_NOT_SAME_OBJECT: ::NTSTATUS = 0xC00001ACu32 as i32; pub const STATUS_FATAL_MEMORY_EXHAUSTION: ::NTSTATUS = 0xC00001ADu32 as i32; pub const STATUS_ERROR_PROCESS_NOT_IN_JOB: ::NTSTATUS = 0xC00001AEu32 as i32; pub const STATUS_NETWORK_OPEN_RESTRICTION: ::NTSTATUS = 0xC0000201u32 as i32; pub const STATUS_NO_USER_SESSION_KEY: ::NTSTATUS = 0xC0000202u32 as i32; pub const STATUS_USER_SESSION_DELETED: ::NTSTATUS = 0xC0000203u32 as i32; pub const STATUS_RESOURCE_LANG_NOT_FOUND: ::NTSTATUS = 0xC0000204u32 as i32; pub const STATUS_INSUFF_SERVER_RESOURCES: ::NTSTATUS = 0xC0000205u32 as i32; pub const STATUS_INVALID_BUFFER_SIZE: ::NTSTATUS = 0xC0000206u32 as i32; pub const STATUS_INVALID_ADDRESS_COMPONENT: ::NTSTATUS = 0xC0000207u32 as i32; pub const STATUS_INVALID_ADDRESS_WILDCARD: ::NTSTATUS = 0xC0000208u32 as i32; pub const STATUS_TOO_MANY_ADDRESSES: ::NTSTATUS = 0xC0000209u32 as i32; pub const STATUS_ADDRESS_ALREADY_EXISTS: ::NTSTATUS = 0xC000020Au32 as i32; pub const STATUS_ADDRESS_CLOSED: ::NTSTATUS = 0xC000020Bu32 as i32; pub const STATUS_CONNECTION_DISCONNECTED: ::NTSTATUS = 0xC000020Cu32 as i32; pub const STATUS_CONNECTION_RESET: ::NTSTATUS = 0xC000020Du32 as i32; pub const STATUS_TOO_MANY_NODES: ::NTSTATUS = 0xC000020Eu32 as i32; pub const STATUS_TRANSACTION_ABORTED: ::NTSTATUS = 0xC000020Fu32 as i32; pub const STATUS_TRANSACTION_TIMED_OUT: ::NTSTATUS = 0xC0000210u32 as i32; pub const STATUS_TRANSACTION_NO_RELEASE: ::NTSTATUS = 0xC0000211u32 as i32; pub const STATUS_TRANSACTION_NO_MATCH: ::NTSTATUS = 0xC0000212u32 as i32; pub const STATUS_TRANSACTION_RESPONDED: ::NTSTATUS = 0xC0000213u32 as i32; pub const STATUS_TRANSACTION_INVALID_ID: ::NTSTATUS = 0xC0000214u32 as i32; pub const STATUS_TRANSACTION_INVALID_TYPE: ::NTSTATUS = 0xC0000215u32 as i32; pub const STATUS_NOT_SERVER_SESSION: ::NTSTATUS = 0xC0000216u32 as i32; pub const STATUS_NOT_CLIENT_SESSION: ::NTSTATUS = 0xC0000217u32 as i32; pub const STATUS_CANNOT_LOAD_REGISTRY_FILE: ::NTSTATUS = 0xC0000218u32 as i32; pub const STATUS_DEBUG_ATTACH_FAILED: ::NTSTATUS = 0xC0000219u32 as i32; pub const STATUS_SYSTEM_PROCESS_TERMINATED: ::NTSTATUS = 0xC000021Au32 as i32; pub const STATUS_DATA_NOT_ACCEPTED: ::NTSTATUS = 0xC000021Bu32 as i32; pub const STATUS_NO_BROWSER_SERVERS_FOUND: ::NTSTATUS = 0xC000021Cu32 as i32; pub const STATUS_VDM_HARD_ERROR: ::NTSTATUS = 0xC000021Du32 as i32; pub const STATUS_DRIVER_CANCEL_TIMEOUT: ::NTSTATUS = 0xC000021Eu32 as i32; pub const STATUS_REPLY_MESSAGE_MISMATCH: ::NTSTATUS = 0xC000021Fu32 as i32; pub const STATUS_MAPPED_ALIGNMENT: ::NTSTATUS = 0xC0000220u32 as i32; pub const STATUS_IMAGE_CHECKSUM_MISMATCH: ::NTSTATUS = 0xC0000221u32 as i32; pub const STATUS_LOST_WRITEBEHIND_DATA: ::NTSTATUS = 0xC0000222u32 as i32; pub const STATUS_CLIENT_SERVER_PARAMETERS_INVALID: ::NTSTATUS = 0xC0000223u32 as i32; pub const STATUS_PASSWORD_MUST_CHANGE: ::NTSTATUS = 0xC0000224u32 as i32; pub const STATUS_NOT_FOUND: ::NTSTATUS = 0xC0000225u32 as i32; pub const STATUS_NOT_TINY_STREAM: ::NTSTATUS = 0xC0000226u32 as i32; pub const STATUS_RECOVERY_FAILURE: ::NTSTATUS = 0xC0000227u32 as i32; pub const STATUS_STACK_OVERFLOW_READ: ::NTSTATUS = 0xC0000228u32 as i32; pub const STATUS_FAIL_CHECK: ::NTSTATUS = 0xC0000229u32 as i32; pub const STATUS_DUPLICATE_OBJECTID: ::NTSTATUS = 0xC000022Au32 as i32; pub const STATUS_OBJECTID_EXISTS: ::NTSTATUS = 0xC000022Bu32 as i32; pub const STATUS_CONVERT_TO_LARGE: ::NTSTATUS = 0xC000022Cu32 as i32; pub const STATUS_RETRY: ::NTSTATUS = 0xC000022Du32 as i32; pub const STATUS_FOUND_OUT_OF_SCOPE: ::NTSTATUS = 0xC000022Eu32 as i32; pub const STATUS_ALLOCATE_BUCKET: ::NTSTATUS = 0xC000022Fu32 as i32; pub const STATUS_PROPSET_NOT_FOUND: ::NTSTATUS = 0xC0000230u32 as i32; pub const STATUS_MARSHALL_OVERFLOW: ::NTSTATUS = 0xC0000231u32 as i32; pub const STATUS_INVALID_VARIANT: ::NTSTATUS = 0xC0000232u32 as i32; pub const STATUS_DOMAIN_CONTROLLER_NOT_FOUND: ::NTSTATUS = 0xC0000233u32 as i32; pub const STATUS_ACCOUNT_LOCKED_OUT: ::NTSTATUS = 0xC0000234u32 as i32; pub const STATUS_HANDLE_NOT_CLOSABLE: ::NTSTATUS = 0xC0000235u32 as i32; pub const STATUS_CONNECTION_REFUSED: ::NTSTATUS = 0xC0000236u32 as i32; pub const STATUS_GRACEFUL_DISCONNECT: ::NTSTATUS = 0xC0000237u32 as i32; pub const STATUS_ADDRESS_ALREADY_ASSOCIATED: ::NTSTATUS = 0xC0000238u32 as i32; pub const STATUS_ADDRESS_NOT_ASSOCIATED: ::NTSTATUS = 0xC0000239u32 as i32; pub const STATUS_CONNECTION_INVALID: ::NTSTATUS = 0xC000023Au32 as i32; pub const STATUS_CONNECTION_ACTIVE: ::NTSTATUS = 0xC000023Bu32 as i32; pub const STATUS_NETWORK_UNREACHABLE: ::NTSTATUS = 0xC000023Cu32 as i32; pub const STATUS_HOST_UNREACHABLE: ::NTSTATUS = 0xC000023Du32 as i32; pub const STATUS_PROTOCOL_UNREACHABLE: ::NTSTATUS = 0xC000023Eu32 as i32; pub const STATUS_PORT_UNREACHABLE: ::NTSTATUS = 0xC000023Fu32 as i32; pub const STATUS_REQUEST_ABORTED: ::NTSTATUS = 0xC0000240u32 as i32; pub const STATUS_CONNECTION_ABORTED: ::NTSTATUS = 0xC0000241u32 as i32; pub const STATUS_BAD_COMPRESSION_BUFFER: ::NTSTATUS = 0xC0000242u32 as i32; pub const STATUS_USER_MAPPED_FILE: ::NTSTATUS = 0xC0000243u32 as i32; pub const STATUS_AUDIT_FAILED: ::NTSTATUS = 0xC0000244u32 as i32; pub const STATUS_TIMER_RESOLUTION_NOT_SET: ::NTSTATUS = 0xC0000245u32 as i32; pub const STATUS_CONNECTION_COUNT_LIMIT: ::NTSTATUS = 0xC0000246u32 as i32; pub const STATUS_LOGIN_TIME_RESTRICTION: ::NTSTATUS = 0xC0000247u32 as i32; pub const STATUS_LOGIN_WKSTA_RESTRICTION: ::NTSTATUS = 0xC0000248u32 as i32; pub const STATUS_IMAGE_MP_UP_MISMATCH: ::NTSTATUS = 0xC0000249u32 as i32; pub const STATUS_INSUFFICIENT_LOGON_INFO: ::NTSTATUS = 0xC0000250u32 as i32; pub const STATUS_BAD_DLL_ENTRYPOINT: ::NTSTATUS = 0xC0000251u32 as i32; pub const STATUS_BAD_SERVICE_ENTRYPOINT: ::NTSTATUS = 0xC0000252u32 as i32; pub const STATUS_LPC_REPLY_LOST: ::NTSTATUS = 0xC0000253u32 as i32; pub const STATUS_IP_ADDRESS_CONFLICT1: ::NTSTATUS = 0xC0000254u32 as i32; pub const STATUS_IP_ADDRESS_CONFLICT2: ::NTSTATUS = 0xC0000255u32 as i32; pub const STATUS_REGISTRY_QUOTA_LIMIT: ::NTSTATUS = 0xC0000256u32 as i32; pub const STATUS_PATH_NOT_COVERED: ::NTSTATUS = 0xC0000257u32 as i32; pub const STATUS_NO_CALLBACK_ACTIVE: ::NTSTATUS = 0xC0000258u32 as i32; pub const STATUS_LICENSE_QUOTA_EXCEEDED: ::NTSTATUS = 0xC0000259u32 as i32; pub const STATUS_PWD_TOO_SHORT: ::NTSTATUS = 0xC000025Au32 as i32; pub const STATUS_PWD_TOO_RECENT: ::NTSTATUS = 0xC000025Bu32 as i32; pub const STATUS_PWD_HISTORY_CONFLICT: ::NTSTATUS = 0xC000025Cu32 as i32; pub const STATUS_PLUGPLAY_NO_DEVICE: ::NTSTATUS = 0xC000025Eu32 as i32; pub const STATUS_UNSUPPORTED_COMPRESSION: ::NTSTATUS = 0xC000025Fu32 as i32; pub const STATUS_INVALID_HW_PROFILE: ::NTSTATUS = 0xC0000260u32 as i32; pub const STATUS_INVALID_PLUGPLAY_DEVICE_PATH: ::NTSTATUS = 0xC0000261u32 as i32; pub const STATUS_DRIVER_ORDINAL_NOT_FOUND: ::NTSTATUS = 0xC0000262u32 as i32; pub const STATUS_DRIVER_ENTRYPOINT_NOT_FOUND: ::NTSTATUS = 0xC0000263u32 as i32; pub const STATUS_RESOURCE_NOT_OWNED: ::NTSTATUS = 0xC0000264u32 as i32; pub const STATUS_TOO_MANY_LINKS: ::NTSTATUS = 0xC0000265u32 as i32; pub const STATUS_QUOTA_LIST_INCONSISTENT: ::NTSTATUS = 0xC0000266u32 as i32; pub const STATUS_FILE_IS_OFFLINE: ::NTSTATUS = 0xC0000267u32 as i32; pub const STATUS_EVALUATION_EXPIRATION: ::NTSTATUS = 0xC0000268u32 as i32; pub const STATUS_ILLEGAL_DLL_RELOCATION: ::NTSTATUS = 0xC0000269u32 as i32; pub const STATUS_LICENSE_VIOLATION: ::NTSTATUS = 0xC000026Au32 as i32; pub const STATUS_DLL_INIT_FAILED_LOGOFF: ::NTSTATUS = 0xC000026Bu32 as i32; pub const STATUS_DRIVER_UNABLE_TO_LOAD: ::NTSTATUS = 0xC000026Cu32 as i32; pub const STATUS_DFS_UNAVAILABLE: ::NTSTATUS = 0xC000026Du32 as i32; pub const STATUS_VOLUME_DISMOUNTED: ::NTSTATUS = 0xC000026Eu32 as i32; pub const STATUS_WX86_INTERNAL_ERROR: ::NTSTATUS = 0xC000026Fu32 as i32; pub const STATUS_WX86_FLOAT_STACK_CHECK: ::NTSTATUS = 0xC0000270u32 as i32; pub const STATUS_VALIDATE_CONTINUE: ::NTSTATUS = 0xC0000271u32 as i32; pub const STATUS_NO_MATCH: ::NTSTATUS = 0xC0000272u32 as i32; pub const STATUS_NO_MORE_MATCHES: ::NTSTATUS = 0xC0000273u32 as i32; pub const STATUS_NOT_A_REPARSE_POINT: ::NTSTATUS = 0xC0000275u32 as i32; pub const STATUS_IO_REPARSE_TAG_INVALID: ::NTSTATUS = 0xC0000276u32 as i32; pub const STATUS_IO_REPARSE_TAG_MISMATCH: ::NTSTATUS = 0xC0000277u32 as i32; pub const STATUS_IO_REPARSE_DATA_INVALID: ::NTSTATUS = 0xC0000278u32 as i32; pub const STATUS_IO_REPARSE_TAG_NOT_HANDLED: ::NTSTATUS = 0xC0000279u32 as i32; pub const STATUS_PWD_TOO_LONG: ::NTSTATUS = 0xC000027Au32 as i32; pub const STATUS_STOWED_EXCEPTION: ::NTSTATUS = 0xC000027Bu32 as i32; pub const STATUS_REPARSE_POINT_NOT_RESOLVED: ::NTSTATUS = 0xC0000280u32 as i32; pub const STATUS_DIRECTORY_IS_A_REPARSE_POINT: ::NTSTATUS = 0xC0000281u32 as i32; pub const STATUS_RANGE_LIST_CONFLICT: ::NTSTATUS = 0xC0000282u32 as i32; pub const STATUS_SOURCE_ELEMENT_EMPTY: ::NTSTATUS = 0xC0000283u32 as i32; pub const STATUS_DESTINATION_ELEMENT_FULL: ::NTSTATUS = 0xC0000284u32 as i32; pub const STATUS_ILLEGAL_ELEMENT_ADDRESS: ::NTSTATUS = 0xC0000285u32 as i32; pub const STATUS_MAGAZINE_NOT_PRESENT: ::NTSTATUS = 0xC0000286u32 as i32; pub const STATUS_REINITIALIZATION_NEEDED: ::NTSTATUS = 0xC0000287u32 as i32; pub const STATUS_DEVICE_REQUIRES_CLEANING: ::NTSTATUS = 0x80000288u32 as i32; pub const STATUS_DEVICE_DOOR_OPEN: ::NTSTATUS = 0x80000289u32 as i32; pub const STATUS_ENCRYPTION_FAILED: ::NTSTATUS = 0xC000028Au32 as i32; pub const STATUS_DECRYPTION_FAILED: ::NTSTATUS = 0xC000028Bu32 as i32; pub const STATUS_RANGE_NOT_FOUND: ::NTSTATUS = 0xC000028Cu32 as i32; pub const STATUS_NO_RECOVERY_POLICY: ::NTSTATUS = 0xC000028Du32 as i32; pub const STATUS_NO_EFS: ::NTSTATUS = 0xC000028Eu32 as i32; pub const STATUS_WRONG_EFS: ::NTSTATUS = 0xC000028Fu32 as i32; pub const STATUS_NO_USER_KEYS: ::NTSTATUS = 0xC0000290u32 as i32; pub const STATUS_FILE_NOT_ENCRYPTED: ::NTSTATUS = 0xC0000291u32 as i32; pub const STATUS_NOT_EXPORT_FORMAT: ::NTSTATUS = 0xC0000292u32 as i32; pub const STATUS_FILE_ENCRYPTED: ::NTSTATUS = 0xC0000293u32 as i32; pub const STATUS_WAKE_SYSTEM: ::NTSTATUS = 0x40000294; pub const STATUS_WMI_GUID_NOT_FOUND: ::NTSTATUS = 0xC0000295u32 as i32; pub const STATUS_WMI_INSTANCE_NOT_FOUND: ::NTSTATUS = 0xC0000296u32 as i32; pub const STATUS_WMI_ITEMID_NOT_FOUND: ::NTSTATUS = 0xC0000297u32 as i32; pub const STATUS_WMI_TRY_AGAIN: ::NTSTATUS = 0xC0000298u32 as i32; pub const STATUS_SHARED_POLICY: ::NTSTATUS = 0xC0000299u32 as i32; pub const STATUS_POLICY_OBJECT_NOT_FOUND: ::NTSTATUS = 0xC000029Au32 as i32; pub const STATUS_POLICY_ONLY_IN_DS: ::NTSTATUS = 0xC000029Bu32 as i32; pub const STATUS_VOLUME_NOT_UPGRADED: ::NTSTATUS = 0xC000029Cu32 as i32; pub const STATUS_REMOTE_STORAGE_NOT_ACTIVE: ::NTSTATUS = 0xC000029Du32 as i32; pub const STATUS_REMOTE_STORAGE_MEDIA_ERROR: ::NTSTATUS = 0xC000029Eu32 as i32; pub const STATUS_NO_TRACKING_SERVICE: ::NTSTATUS = 0xC000029Fu32 as i32; pub const STATUS_SERVER_SID_MISMATCH: ::NTSTATUS = 0xC00002A0u32 as i32; pub const STATUS_DS_NO_ATTRIBUTE_OR_VALUE: ::NTSTATUS = 0xC00002A1u32 as i32; pub const STATUS_DS_INVALID_ATTRIBUTE_SYNTAX: ::NTSTATUS = 0xC00002A2u32 as i32; pub const STATUS_DS_ATTRIBUTE_TYPE_UNDEFINED: ::NTSTATUS = 0xC00002A3u32 as i32; pub const STATUS_DS_ATTRIBUTE_OR_VALUE_EXISTS: ::NTSTATUS = 0xC00002A4u32 as i32; pub const STATUS_DS_BUSY: ::NTSTATUS = 0xC00002A5u32 as i32; pub const STATUS_DS_UNAVAILABLE: ::NTSTATUS = 0xC00002A6u32 as i32; pub const STATUS_DS_NO_RIDS_ALLOCATED: ::NTSTATUS = 0xC00002A7u32 as i32; pub const STATUS_DS_NO_MORE_RIDS: ::NTSTATUS = 0xC00002A8u32 as i32; pub const STATUS_DS_INCORRECT_ROLE_OWNER: ::NTSTATUS = 0xC00002A9u32 as i32; pub const STATUS_DS_RIDMGR_INIT_ERROR: ::NTSTATUS = 0xC00002AAu32 as i32; pub const STATUS_DS_OBJ_CLASS_VIOLATION: ::NTSTATUS = 0xC00002ABu32 as i32; pub const STATUS_DS_CANT_ON_NON_LEAF: ::NTSTATUS = 0xC00002ACu32 as i32; pub const STATUS_DS_CANT_ON_RDN: ::NTSTATUS = 0xC00002ADu32 as i32; pub const STATUS_DS_CANT_MOD_OBJ_CLASS: ::NTSTATUS = 0xC00002AEu32 as i32; pub const STATUS_DS_CROSS_DOM_MOVE_FAILED: ::NTSTATUS = 0xC00002AFu32 as i32; pub const STATUS_DS_GC_NOT_AVAILABLE: ::NTSTATUS = 0xC00002B0u32 as i32; pub const STATUS_DIRECTORY_SERVICE_REQUIRED: ::NTSTATUS = 0xC00002B1u32 as i32; pub const STATUS_REPARSE_ATTRIBUTE_CONFLICT: ::NTSTATUS = 0xC00002B2u32 as i32; pub const STATUS_CANT_ENABLE_DENY_ONLY: ::NTSTATUS = 0xC00002B3u32 as i32; pub const STATUS_FLOAT_MULTIPLE_FAULTS: ::NTSTATUS = 0xC00002B4u32 as i32; pub const STATUS_FLOAT_MULTIPLE_TRAPS: ::NTSTATUS = 0xC00002B5u32 as i32; pub const STATUS_DEVICE_REMOVED: ::NTSTATUS = 0xC00002B6u32 as i32; pub const STATUS_JOURNAL_DELETE_IN_PROGRESS: ::NTSTATUS = 0xC00002B7u32 as i32; pub const STATUS_JOURNAL_NOT_ACTIVE: ::NTSTATUS = 0xC00002B8u32 as i32; pub const STATUS_NOINTERFACE: ::NTSTATUS = 0xC00002B9u32 as i32; pub const STATUS_DS_RIDMGR_DISABLED: ::NTSTATUS = 0xC00002BAu32 as i32; pub const STATUS_DS_ADMIN_LIMIT_EXCEEDED: ::NTSTATUS = 0xC00002C1u32 as i32; pub const STATUS_DRIVER_FAILED_SLEEP: ::NTSTATUS = 0xC00002C2u32 as i32; pub const STATUS_MUTUAL_AUTHENTICATION_FAILED: ::NTSTATUS = 0xC00002C3u32 as i32; pub const STATUS_CORRUPT_SYSTEM_FILE: ::NTSTATUS = 0xC00002C4u32 as i32; pub const STATUS_DATATYPE_MISALIGNMENT_ERROR: ::NTSTATUS = 0xC00002C5u32 as i32; pub const STATUS_WMI_READ_ONLY: ::NTSTATUS = 0xC00002C6u32 as i32; pub const STATUS_WMI_SET_FAILURE: ::NTSTATUS = 0xC00002C7u32 as i32; pub const STATUS_COMMITMENT_MINIMUM: ::NTSTATUS = 0xC00002C8u32 as i32; pub const STATUS_REG_NAT_CONSUMPTION: ::NTSTATUS = 0xC00002C9u32 as i32; pub const STATUS_TRANSPORT_FULL: ::NTSTATUS = 0xC00002CAu32 as i32; pub const STATUS_DS_SAM_INIT_FAILURE: ::NTSTATUS = 0xC00002CBu32 as i32; pub const STATUS_ONLY_IF_CONNECTED: ::NTSTATUS = 0xC00002CCu32 as i32; pub const STATUS_DS_SENSITIVE_GROUP_VIOLATION: ::NTSTATUS = 0xC00002CDu32 as i32; pub const STATUS_PNP_RESTART_ENUMERATION: ::NTSTATUS = 0xC00002CEu32 as i32; pub const STATUS_JOURNAL_ENTRY_DELETED: ::NTSTATUS = 0xC00002CFu32 as i32; pub const STATUS_DS_CANT_MOD_PRIMARYGROUPID: ::NTSTATUS = 0xC00002D0u32 as i32; pub const STATUS_SYSTEM_IMAGE_BAD_SIGNATURE: ::NTSTATUS = 0xC00002D1u32 as i32; pub const STATUS_PNP_REBOOT_REQUIRED: ::NTSTATUS = 0xC00002D2u32 as i32; pub const STATUS_POWER_STATE_INVALID: ::NTSTATUS = 0xC00002D3u32 as i32; pub const STATUS_DS_INVALID_GROUP_TYPE: ::NTSTATUS = 0xC00002D4u32 as i32; pub const STATUS_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN: ::NTSTATUS = 0xC00002D5u32 as i32; pub const STATUS_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN: ::NTSTATUS = 0xC00002D6u32 as i32; pub const STATUS_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER: ::NTSTATUS = 0xC00002D7u32 as i32; pub const STATUS_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER: ::NTSTATUS = 0xC00002D8u32 as i32; pub const STATUS_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER: ::NTSTATUS = 0xC00002D9u32 as i32; pub const STATUS_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER: ::NTSTATUS = 0xC00002DAu32 as i32; pub const STATUS_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER: ::NTSTATUS = 0xC00002DBu32 as i32; pub const STATUS_DS_HAVE_PRIMARY_MEMBERS: ::NTSTATUS = 0xC00002DCu32 as i32; pub const STATUS_WMI_NOT_SUPPORTED: ::NTSTATUS = 0xC00002DDu32 as i32; pub const STATUS_INSUFFICIENT_POWER: ::NTSTATUS = 0xC00002DEu32 as i32; pub const STATUS_SAM_NEED_BOOTKEY_PASSWORD: ::NTSTATUS = 0xC00002DFu32 as i32; pub const STATUS_SAM_NEED_BOOTKEY_FLOPPY: ::NTSTATUS = 0xC00002E0u32 as i32; pub const STATUS_DS_CANT_START: ::NTSTATUS = 0xC00002E1u32 as i32; pub const STATUS_DS_INIT_FAILURE: ::NTSTATUS = 0xC00002E2u32 as i32; pub const STATUS_SAM_INIT_FAILURE: ::NTSTATUS = 0xC00002E3u32 as i32; pub const STATUS_DS_GC_REQUIRED: ::NTSTATUS = 0xC00002E4u32 as i32; pub const STATUS_DS_LOCAL_MEMBER_OF_LOCAL_ONLY: ::NTSTATUS = 0xC00002E5u32 as i32; pub const STATUS_DS_NO_FPO_IN_UNIVERSAL_GROUPS: ::NTSTATUS = 0xC00002E6u32 as i32; pub const STATUS_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED: ::NTSTATUS = 0xC00002E7u32 as i32; pub const STATUS_MULTIPLE_FAULT_VIOLATION: ::NTSTATUS = 0xC00002E8u32 as i32; pub const STATUS_CURRENT_DOMAIN_NOT_ALLOWED: ::NTSTATUS = 0xC00002E9u32 as i32; pub const STATUS_CANNOT_MAKE: ::NTSTATUS = 0xC00002EAu32 as i32; pub const STATUS_SYSTEM_SHUTDOWN: ::NTSTATUS = 0xC00002EBu32 as i32; pub const STATUS_DS_INIT_FAILURE_CONSOLE: ::NTSTATUS = 0xC00002ECu32 as i32; pub const STATUS_DS_SAM_INIT_FAILURE_CONSOLE: ::NTSTATUS = 0xC00002EDu32 as i32; pub const STATUS_UNFINISHED_CONTEXT_DELETED: ::NTSTATUS = 0xC00002EEu32 as i32; pub const STATUS_NO_TGT_REPLY: ::NTSTATUS = 0xC00002EFu32 as i32; pub const STATUS_OBJECTID_NOT_FOUND: ::NTSTATUS = 0xC00002F0u32 as i32; pub const STATUS_NO_IP_ADDRESSES: ::NTSTATUS = 0xC00002F1u32 as i32; pub const STATUS_WRONG_CREDENTIAL_HANDLE: ::NTSTATUS = 0xC00002F2u32 as i32; pub const STATUS_CRYPTO_SYSTEM_INVALID: ::NTSTATUS = 0xC00002F3u32 as i32; pub const STATUS_MAX_REFERRALS_EXCEEDED: ::NTSTATUS = 0xC00002F4u32 as i32; pub const STATUS_MUST_BE_KDC: ::NTSTATUS = 0xC00002F5u32 as i32; pub const STATUS_STRONG_CRYPTO_NOT_SUPPORTED: ::NTSTATUS = 0xC00002F6u32 as i32; pub const STATUS_TOO_MANY_PRINCIPALS: ::NTSTATUS = 0xC00002F7u32 as i32; pub const STATUS_NO_PA_DATA: ::NTSTATUS = 0xC00002F8u32 as i32; pub const STATUS_PKINIT_NAME_MISMATCH: ::NTSTATUS = 0xC00002F9u32 as i32; pub const STATUS_SMARTCARD_LOGON_REQUIRED: ::NTSTATUS = 0xC00002FAu32 as i32; pub const STATUS_KDC_INVALID_REQUEST: ::NTSTATUS = 0xC00002FBu32 as i32; pub const STATUS_KDC_UNABLE_TO_REFER: ::NTSTATUS = 0xC00002FCu32 as i32; pub const STATUS_KDC_UNKNOWN_ETYPE: ::NTSTATUS = 0xC00002FDu32 as i32; pub const STATUS_SHUTDOWN_IN_PROGRESS: ::NTSTATUS = 0xC00002FEu32 as i32; pub const STATUS_SERVER_SHUTDOWN_IN_PROGRESS: ::NTSTATUS = 0xC00002FFu32 as i32; pub const STATUS_NOT_SUPPORTED_ON_SBS: ::NTSTATUS = 0xC0000300u32 as i32; pub const STATUS_WMI_GUID_DISCONNECTED: ::NTSTATUS = 0xC0000301u32 as i32; pub const STATUS_WMI_ALREADY_DISABLED: ::NTSTATUS = 0xC0000302u32 as i32; pub const STATUS_WMI_ALREADY_ENABLED: ::NTSTATUS = 0xC0000303u32 as i32; pub const STATUS_MFT_TOO_FRAGMENTED: ::NTSTATUS = 0xC0000304u32 as i32; pub const STATUS_COPY_PROTECTION_FAILURE: ::NTSTATUS = 0xC0000305u32 as i32; pub const STATUS_CSS_AUTHENTICATION_FAILURE: ::NTSTATUS = 0xC0000306u32 as i32; pub const STATUS_CSS_KEY_NOT_PRESENT: ::NTSTATUS = 0xC0000307u32 as i32; pub const STATUS_CSS_KEY_NOT_ESTABLISHED: ::NTSTATUS = 0xC0000308u32 as i32; pub const STATUS_CSS_SCRAMBLED_SECTOR: ::NTSTATUS = 0xC0000309u32 as i32; pub const STATUS_CSS_REGION_MISMATCH: ::NTSTATUS = 0xC000030Au32 as i32; pub const STATUS_CSS_RESETS_EXHAUSTED: ::NTSTATUS = 0xC000030Bu32 as i32; pub const STATUS_PASSWORD_CHANGE_REQUIRED: ::NTSTATUS = 0xC000030Cu32 as i32; pub const STATUS_PKINIT_FAILURE: ::NTSTATUS = 0xC0000320u32 as i32; pub const STATUS_SMARTCARD_SUBSYSTEM_FAILURE: ::NTSTATUS = 0xC0000321u32 as i32; pub const STATUS_NO_KERB_KEY: ::NTSTATUS = 0xC0000322u32 as i32; pub const STATUS_HOST_DOWN: ::NTSTATUS = 0xC0000350u32 as i32; pub const STATUS_UNSUPPORTED_PREAUTH: ::NTSTATUS = 0xC0000351u32 as i32; pub const STATUS_EFS_ALG_BLOB_TOO_BIG: ::NTSTATUS = 0xC0000352u32 as i32; pub const STATUS_PORT_NOT_SET: ::NTSTATUS = 0xC0000353u32 as i32; pub const STATUS_DEBUGGER_INACTIVE: ::NTSTATUS = 0xC0000354u32 as i32; pub const STATUS_DS_VERSION_CHECK_FAILURE: ::NTSTATUS = 0xC0000355u32 as i32; pub const STATUS_AUDITING_DISABLED: ::NTSTATUS = 0xC0000356u32 as i32; pub const STATUS_PRENT4_MACHINE_ACCOUNT: ::NTSTATUS = 0xC0000357u32 as i32; pub const STATUS_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER: ::NTSTATUS = 0xC0000358u32 as i32; pub const STATUS_INVALID_IMAGE_WIN_32: ::NTSTATUS = 0xC0000359u32 as i32; pub const STATUS_INVALID_IMAGE_WIN_64: ::NTSTATUS = 0xC000035Au32 as i32; pub const STATUS_BAD_BINDINGS: ::NTSTATUS = 0xC000035Bu32 as i32; pub const STATUS_NETWORK_SESSION_EXPIRED: ::NTSTATUS = 0xC000035Cu32 as i32; pub const STATUS_APPHELP_BLOCK: ::NTSTATUS = 0xC000035Du32 as i32; pub const STATUS_ALL_SIDS_FILTERED: ::NTSTATUS = 0xC000035Eu32 as i32; pub const STATUS_NOT_SAFE_MODE_DRIVER: ::NTSTATUS = 0xC000035Fu32 as i32; pub const STATUS_ACCESS_DISABLED_BY_POLICY_DEFAULT: ::NTSTATUS = 0xC0000361u32 as i32; pub const STATUS_ACCESS_DISABLED_BY_POLICY_PATH: ::NTSTATUS = 0xC0000362u32 as i32; pub const STATUS_ACCESS_DISABLED_BY_POLICY_PUBLISHER: ::NTSTATUS = 0xC0000363u32 as i32; pub const STATUS_ACCESS_DISABLED_BY_POLICY_OTHER: ::NTSTATUS = 0xC0000364u32 as i32; pub const STATUS_FAILED_DRIVER_ENTRY: ::NTSTATUS = 0xC0000365u32 as i32; pub const STATUS_DEVICE_ENUMERATION_ERROR: ::NTSTATUS = 0xC0000366u32 as i32; pub const STATUS_MOUNT_POINT_NOT_RESOLVED: ::NTSTATUS = 0xC0000368u32 as i32; pub const STATUS_INVALID_DEVICE_OBJECT_PARAMETER: ::NTSTATUS = 0xC0000369u32 as i32; pub const STATUS_MCA_OCCURED: ::NTSTATUS = 0xC000036Au32 as i32; pub const STATUS_DRIVER_BLOCKED_CRITICAL: ::NTSTATUS = 0xC000036Bu32 as i32; pub const STATUS_DRIVER_BLOCKED: ::NTSTATUS = 0xC000036Cu32 as i32; pub const STATUS_DRIVER_DATABASE_ERROR: ::NTSTATUS = 0xC000036Du32 as i32; pub const STATUS_SYSTEM_HIVE_TOO_LARGE: ::NTSTATUS = 0xC000036Eu32 as i32; pub const STATUS_INVALID_IMPORT_OF_NON_DLL: ::NTSTATUS = 0xC000036Fu32 as i32; pub const STATUS_DS_SHUTTING_DOWN: ::NTSTATUS = 0x40000370; pub const STATUS_NO_SECRETS: ::NTSTATUS = 0xC0000371u32 as i32; pub const STATUS_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY: ::NTSTATUS = 0xC0000372u32 as i32; pub const STATUS_FAILED_STACK_SWITCH: ::NTSTATUS = 0xC0000373u32 as i32; pub const STATUS_HEAP_CORRUPTION: ::NTSTATUS = 0xC0000374u32 as i32; pub const STATUS_SMARTCARD_WRONG_PIN: ::NTSTATUS = 0xC0000380u32 as i32; pub const STATUS_SMARTCARD_CARD_BLOCKED: ::NTSTATUS = 0xC0000381u32 as i32; pub const STATUS_SMARTCARD_CARD_NOT_AUTHENTICATED: ::NTSTATUS = 0xC0000382u32 as i32; pub const STATUS_SMARTCARD_NO_CARD: ::NTSTATUS = 0xC0000383u32 as i32; pub const STATUS_SMARTCARD_NO_KEY_CONTAINER: ::NTSTATUS = 0xC0000384u32 as i32; pub const STATUS_SMARTCARD_NO_CERTIFICATE: ::NTSTATUS = 0xC0000385u32 as i32; pub const STATUS_SMARTCARD_NO_KEYSET: ::NTSTATUS = 0xC0000386u32 as i32; pub const STATUS_SMARTCARD_IO_ERROR: ::NTSTATUS = 0xC0000387u32 as i32; pub const STATUS_DOWNGRADE_DETECTED: ::NTSTATUS = 0xC0000388u32 as i32; pub const STATUS_SMARTCARD_CERT_REVOKED: ::NTSTATUS = 0xC0000389u32 as i32; pub const STATUS_ISSUING_CA_UNTRUSTED: ::NTSTATUS = 0xC000038Au32 as i32; pub const STATUS_REVOCATION_OFFLINE_C: ::NTSTATUS = 0xC000038Bu32 as i32; pub const STATUS_PKINIT_CLIENT_FAILURE: ::NTSTATUS = 0xC000038Cu32 as i32; pub const STATUS_SMARTCARD_CERT_EXPIRED: ::NTSTATUS = 0xC000038Du32 as i32; pub const STATUS_DRIVER_FAILED_PRIOR_UNLOAD: ::NTSTATUS = 0xC000038Eu32 as i32; pub const STATUS_SMARTCARD_SILENT_CONTEXT: ::NTSTATUS = 0xC000038Fu32 as i32; pub const STATUS_PER_USER_TRUST_QUOTA_EXCEEDED: ::NTSTATUS = 0xC0000401u32 as i32; pub const STATUS_ALL_USER_TRUST_QUOTA_EXCEEDED: ::NTSTATUS = 0xC0000402u32 as i32; pub const STATUS_USER_DELETE_TRUST_QUOTA_EXCEEDED: ::NTSTATUS = 0xC0000403u32 as i32; pub const STATUS_DS_NAME_NOT_UNIQUE: ::NTSTATUS = 0xC0000404u32 as i32; pub const STATUS_DS_DUPLICATE_ID_FOUND: ::NTSTATUS = 0xC0000405u32 as i32; pub const STATUS_DS_GROUP_CONVERSION_ERROR: ::NTSTATUS = 0xC0000406u32 as i32; pub const STATUS_VOLSNAP_PREPARE_HIBERNATE: ::NTSTATUS = 0xC0000407u32 as i32; pub const STATUS_USER2USER_REQUIRED: ::NTSTATUS = 0xC0000408u32 as i32; pub const STATUS_STACK_BUFFER_OVERRUN: ::NTSTATUS = 0xC0000409u32 as i32; pub const STATUS_NO_S4U_PROT_SUPPORT: ::NTSTATUS = 0xC000040Au32 as i32; pub const STATUS_CROSSREALM_DELEGATION_FAILURE: ::NTSTATUS = 0xC000040Bu32 as i32; pub const STATUS_REVOCATION_OFFLINE_KDC: ::NTSTATUS = 0xC000040Cu32 as i32; pub const STATUS_ISSUING_CA_UNTRUSTED_KDC: ::NTSTATUS = 0xC000040Du32 as i32; pub const STATUS_KDC_CERT_EXPIRED: ::NTSTATUS = 0xC000040Eu32 as i32; pub const STATUS_KDC_CERT_REVOKED: ::NTSTATUS = 0xC000040Fu32 as i32; pub const STATUS_PARAMETER_QUOTA_EXCEEDED: ::NTSTATUS = 0xC0000410u32 as i32; pub const STATUS_HIBERNATION_FAILURE: ::NTSTATUS = 0xC0000411u32 as i32; pub const STATUS_DELAY_LOAD_FAILED: ::NTSTATUS = 0xC0000412u32 as i32; pub const STATUS_AUTHENTICATION_FIREWALL_FAILED: ::NTSTATUS = 0xC0000413u32 as i32; pub const STATUS_VDM_DISALLOWED: ::NTSTATUS = 0xC0000414u32 as i32; pub const STATUS_HUNG_DISPLAY_DRIVER_THREAD: ::NTSTATUS = 0xC0000415u32 as i32; pub const STATUS_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE: ::NTSTATUS = 0xC0000416u32 as i32; pub const STATUS_INVALID_CRUNTIME_PARAMETER: ::NTSTATUS = 0xC0000417u32 as i32; pub const STATUS_NTLM_BLOCKED: ::NTSTATUS = 0xC0000418u32 as i32; pub const STATUS_DS_SRC_SID_EXISTS_IN_FOREST: ::NTSTATUS = 0xC0000419u32 as i32; pub const STATUS_DS_DOMAIN_NAME_EXISTS_IN_FOREST: ::NTSTATUS = 0xC000041Au32 as i32; pub const STATUS_DS_FLAT_NAME_EXISTS_IN_FOREST: ::NTSTATUS = 0xC000041Bu32 as i32; pub const STATUS_INVALID_USER_PRINCIPAL_NAME: ::NTSTATUS = 0xC000041Cu32 as i32; pub const STATUS_FATAL_USER_CALLBACK_EXCEPTION: ::NTSTATUS = 0xC000041Du32 as i32; pub const STATUS_ASSERTION_FAILURE: ::NTSTATUS = 0xC0000420u32 as i32; pub const STATUS_VERIFIER_STOP: ::NTSTATUS = 0xC0000421u32 as i32; pub const STATUS_CALLBACK_POP_STACK: ::NTSTATUS = 0xC0000423u32 as i32; pub const STATUS_INCOMPATIBLE_DRIVER_BLOCKED: ::NTSTATUS = 0xC0000424u32 as i32; pub const STATUS_HIVE_UNLOADED: ::NTSTATUS = 0xC0000425u32 as i32; pub const STATUS_COMPRESSION_DISABLED: ::NTSTATUS = 0xC0000426u32 as i32; pub const STATUS_FILE_SYSTEM_LIMITATION: ::NTSTATUS = 0xC0000427u32 as i32; pub const STATUS_INVALID_IMAGE_HASH: ::NTSTATUS = 0xC0000428u32 as i32; pub const STATUS_NOT_CAPABLE: ::NTSTATUS = 0xC0000429u32 as i32; pub const STATUS_REQUEST_OUT_OF_SEQUENCE: ::NTSTATUS = 0xC000042Au32 as i32; pub const STATUS_IMPLEMENTATION_LIMIT: ::NTSTATUS = 0xC000042Bu32 as i32; pub const STATUS_ELEVATION_REQUIRED: ::NTSTATUS = 0xC000042Cu32 as i32; pub const STATUS_NO_SECURITY_CONTEXT: ::NTSTATUS = 0xC000042Du32 as i32; pub const STATUS_PKU2U_CERT_FAILURE: ::NTSTATUS = 0xC000042Fu32 as i32; pub const STATUS_BEYOND_VDL: ::NTSTATUS = 0xC0000432u32 as i32; pub const STATUS_ENCOUNTERED_WRITE_IN_PROGRESS: ::NTSTATUS = 0xC0000433u32 as i32; pub const STATUS_PTE_CHANGED: ::NTSTATUS = 0xC0000434u32 as i32; pub const STATUS_PURGE_FAILED: ::NTSTATUS = 0xC0000435u32 as i32; pub const STATUS_CRED_REQUIRES_CONFIRMATION: ::NTSTATUS = 0xC0000440u32 as i32; pub const STATUS_CS_ENCRYPTION_INVALID_SERVER_RESPONSE: ::NTSTATUS = 0xC0000441u32 as i32; pub const STATUS_CS_ENCRYPTION_UNSUPPORTED_SERVER: ::NTSTATUS = 0xC0000442u32 as i32; pub const STATUS_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE: ::NTSTATUS = 0xC0000443u32 as i32; pub const STATUS_CS_ENCRYPTION_NEW_ENCRYPTED_FILE: ::NTSTATUS = 0xC0000444u32 as i32; pub const STATUS_CS_ENCRYPTION_FILE_NOT_CSE: ::NTSTATUS = 0xC0000445u32 as i32; pub const STATUS_INVALID_LABEL: ::NTSTATUS = 0xC0000446u32 as i32; pub const STATUS_DRIVER_PROCESS_TERMINATED: ::NTSTATUS = 0xC0000450u32 as i32; pub const STATUS_AMBIGUOUS_SYSTEM_DEVICE: ::NTSTATUS = 0xC0000451u32 as i32; pub const STATUS_SYSTEM_DEVICE_NOT_FOUND: ::NTSTATUS = 0xC0000452u32 as i32; pub const STATUS_RESTART_BOOT_APPLICATION: ::NTSTATUS = 0xC0000453u32 as i32; pub const STATUS_INSUFFICIENT_NVRAM_RESOURCES: ::NTSTATUS = 0xC0000454u32 as i32; pub const STATUS_INVALID_SESSION: ::NTSTATUS = 0xC0000455u32 as i32; pub const STATUS_THREAD_ALREADY_IN_SESSION: ::NTSTATUS = 0xC0000456u32 as i32; pub const STATUS_THREAD_NOT_IN_SESSION: ::NTSTATUS = 0xC0000457u32 as i32; pub const STATUS_INVALID_WEIGHT: ::NTSTATUS = 0xC0000458u32 as i32; pub const STATUS_REQUEST_PAUSED: ::NTSTATUS = 0xC0000459u32 as i32; pub const STATUS_NO_RANGES_PROCESSED: ::NTSTATUS = 0xC0000460u32 as i32; pub const STATUS_DISK_RESOURCES_EXHAUSTED: ::NTSTATUS = 0xC0000461u32 as i32; pub const STATUS_NEEDS_REMEDIATION: ::NTSTATUS = 0xC0000462u32 as i32; pub const STATUS_DEVICE_FEATURE_NOT_SUPPORTED: ::NTSTATUS = 0xC0000463u32 as i32; pub const STATUS_DEVICE_UNREACHABLE: ::NTSTATUS = 0xC0000464u32 as i32; pub const STATUS_INVALID_TOKEN: ::NTSTATUS = 0xC0000465u32 as i32; pub const STATUS_SERVER_UNAVAILABLE: ::NTSTATUS = 0xC0000466u32 as i32; pub const STATUS_FILE_NOT_AVAILABLE: ::NTSTATUS = 0xC0000467u32 as i32; pub const STATUS_DEVICE_INSUFFICIENT_RESOURCES: ::NTSTATUS = 0xC0000468u32 as i32; pub const STATUS_PACKAGE_UPDATING: ::NTSTATUS = 0xC0000469u32 as i32; pub const STATUS_NOT_READ_FROM_COPY: ::NTSTATUS = 0xC000046Au32 as i32; pub const STATUS_FT_WRITE_FAILURE: ::NTSTATUS = 0xC000046Bu32 as i32; pub const STATUS_FT_DI_SCAN_REQUIRED: ::NTSTATUS = 0xC000046Cu32 as i32; pub const STATUS_OBJECT_NOT_EXTERNALLY_BACKED: ::NTSTATUS = 0xC000046Du32 as i32; pub const STATUS_EXTERNAL_BACKING_PROVIDER_UNKNOWN: ::NTSTATUS = 0xC000046Eu32 as i32; pub const STATUS_COMPRESSION_NOT_BENEFICIAL: ::NTSTATUS = 0xC000046Fu32 as i32; pub const STATUS_DATA_CHECKSUM_ERROR: ::NTSTATUS = 0xC0000470u32 as i32; pub const STATUS_INTERMIXED_KERNEL_EA_OPERATION: ::NTSTATUS = 0xC0000471u32 as i32; pub const STATUS_TRIM_READ_ZERO_NOT_SUPPORTED: ::NTSTATUS = 0xC0000472u32 as i32; pub const STATUS_TOO_MANY_SEGMENT_DESCRIPTORS: ::NTSTATUS = 0xC0000473u32 as i32; pub const STATUS_INVALID_OFFSET_ALIGNMENT: ::NTSTATUS = 0xC0000474u32 as i32; pub const STATUS_INVALID_FIELD_IN_PARAMETER_LIST: ::NTSTATUS = 0xC0000475u32 as i32; pub const STATUS_OPERATION_IN_PROGRESS: ::NTSTATUS = 0xC0000476u32 as i32; pub const STATUS_INVALID_INITIATOR_TARGET_PATH: ::NTSTATUS = 0xC0000477u32 as i32; pub const STATUS_SCRUB_DATA_DISABLED: ::NTSTATUS = 0xC0000478u32 as i32; pub const STATUS_NOT_REDUNDANT_STORAGE: ::NTSTATUS = 0xC0000479u32 as i32; pub const STATUS_RESIDENT_FILE_NOT_SUPPORTED: ::NTSTATUS = 0xC000047Au32 as i32; pub const STATUS_COMPRESSED_FILE_NOT_SUPPORTED: ::NTSTATUS = 0xC000047Bu32 as i32; pub const STATUS_DIRECTORY_NOT_SUPPORTED: ::NTSTATUS = 0xC000047Cu32 as i32; pub const STATUS_IO_OPERATION_TIMEOUT: ::NTSTATUS = 0xC000047Du32 as i32; pub const STATUS_SYSTEM_NEEDS_REMEDIATION: ::NTSTATUS = 0xC000047Eu32 as i32; pub const STATUS_APPX_INTEGRITY_FAILURE_CLR_NGEN: ::NTSTATUS = 0xC000047Fu32 as i32; pub const STATUS_SHARE_UNAVAILABLE: ::NTSTATUS = 0xC0000480u32 as i32; pub const STATUS_APISET_NOT_HOSTED: ::NTSTATUS = 0xC0000481u32 as i32; pub const STATUS_APISET_NOT_PRESENT: ::NTSTATUS = 0xC0000482u32 as i32; pub const STATUS_DEVICE_HARDWARE_ERROR: ::NTSTATUS = 0xC0000483u32 as i32; pub const STATUS_FIRMWARE_SLOT_INVALID: ::NTSTATUS = 0xC0000484u32 as i32; pub const STATUS_FIRMWARE_IMAGE_INVALID: ::NTSTATUS = 0xC0000485u32 as i32; pub const STATUS_STORAGE_TOPOLOGY_ID_MISMATCH: ::NTSTATUS = 0xC0000486u32 as i32; pub const STATUS_WIM_NOT_BOOTABLE: ::NTSTATUS = 0xC0000487u32 as i32; pub const STATUS_BLOCKED_BY_PARENTAL_CONTROLS: ::NTSTATUS = 0xC0000488u32 as i32; pub const STATUS_NEEDS_REGISTRATION: ::NTSTATUS = 0xC0000489u32 as i32; pub const STATUS_QUOTA_ACTIVITY: ::NTSTATUS = 0xC000048Au32 as i32; pub const STATUS_INVALID_TASK_NAME: ::NTSTATUS = 0xC0000500u32 as i32; pub const STATUS_INVALID_TASK_INDEX: ::NTSTATUS = 0xC0000501u32 as i32; pub const STATUS_THREAD_ALREADY_IN_TASK: ::NTSTATUS = 0xC0000502u32 as i32; pub const STATUS_CALLBACK_BYPASS: ::NTSTATUS = 0xC0000503u32 as i32; pub const STATUS_UNDEFINED_SCOPE: ::NTSTATUS = 0xC0000504u32 as i32; pub const STATUS_INVALID_CAP: ::NTSTATUS = 0xC0000505u32 as i32; pub const STATUS_NOT_GUI_PROCESS: ::NTSTATUS = 0xC0000506u32 as i32; pub const STATUS_DEVICE_HUNG: ::NTSTATUS = 0xC0000507u32 as i32; pub const STATUS_FAIL_FAST_EXCEPTION: ::NTSTATUS = 0xC0000602u32 as i32; pub const STATUS_IMAGE_CERT_REVOKED: ::NTSTATUS = 0xC0000603u32 as i32; pub const STATUS_DYNAMIC_CODE_BLOCKED: ::NTSTATUS = 0xC0000604u32 as i32; pub const STATUS_IMAGE_CERT_EXPIRED: ::NTSTATUS = 0xC0000605u32 as i32; pub const STATUS_PORT_CLOSED: ::NTSTATUS = 0xC0000700u32 as i32; pub const STATUS_MESSAGE_LOST: ::NTSTATUS = 0xC0000701u32 as i32; pub const STATUS_INVALID_MESSAGE: ::NTSTATUS = 0xC0000702u32 as i32; pub const STATUS_REQUEST_CANCELED: ::NTSTATUS = 0xC0000703u32 as i32; pub const STATUS_RECURSIVE_DISPATCH: ::NTSTATUS = 0xC0000704u32 as i32; pub const STATUS_LPC_RECEIVE_BUFFER_EXPECTED: ::NTSTATUS = 0xC0000705u32 as i32; pub const STATUS_LPC_INVALID_CONNECTION_USAGE: ::NTSTATUS = 0xC0000706u32 as i32; pub const STATUS_LPC_REQUESTS_NOT_ALLOWED: ::NTSTATUS = 0xC0000707u32 as i32; pub const STATUS_RESOURCE_IN_USE: ::NTSTATUS = 0xC0000708u32 as i32; pub const STATUS_HARDWARE_MEMORY_ERROR: ::NTSTATUS = 0xC0000709u32 as i32; pub const STATUS_THREADPOOL_HANDLE_EXCEPTION: ::NTSTATUS = 0xC000070Au32 as i32; pub const STATUS_THREADPOOL_SET_EVENT_ON_COMPLETION_FAILED: ::NTSTATUS = 0xC000070Bu32 as i32; pub const STATUS_THREADPOOL_RELEASE_SEMAPHORE_ON_COMPLETION_FAILED: ::NTSTATUS = 0xC000070Cu32 as i32; pub const STATUS_THREADPOOL_RELEASE_MUTEX_ON_COMPLETION_FAILED: ::NTSTATUS = 0xC000070Du32 as i32; pub const STATUS_THREADPOOL_FREE_LIBRARY_ON_COMPLETION_FAILED: ::NTSTATUS = 0xC000070Eu32 as i32; pub const STATUS_THREADPOOL_RELEASED_DURING_OPERATION: ::NTSTATUS = 0xC000070Fu32 as i32; pub const STATUS_CALLBACK_RETURNED_WHILE_IMPERSONATING: ::NTSTATUS = 0xC0000710u32 as i32; pub const STATUS_APC_RETURNED_WHILE_IMPERSONATING: ::NTSTATUS = 0xC0000711u32 as i32; pub const STATUS_PROCESS_IS_PROTECTED: ::NTSTATUS = 0xC0000712u32 as i32; pub const STATUS_MCA_EXCEPTION: ::NTSTATUS = 0xC0000713u32 as i32; pub const STATUS_CERTIFICATE_MAPPING_NOT_UNIQUE: ::NTSTATUS = 0xC0000714u32 as i32; pub const STATUS_SYMLINK_CLASS_DISABLED: ::NTSTATUS = 0xC0000715u32 as i32; pub const STATUS_INVALID_IDN_NORMALIZATION: ::NTSTATUS = 0xC0000716u32 as i32; pub const STATUS_NO_UNICODE_TRANSLATION: ::NTSTATUS = 0xC0000717u32 as i32; pub const STATUS_ALREADY_REGISTERED: ::NTSTATUS = 0xC0000718u32 as i32; pub const STATUS_CONTEXT_MISMATCH: ::NTSTATUS = 0xC0000719u32 as i32; pub const STATUS_PORT_ALREADY_HAS_COMPLETION_LIST: ::NTSTATUS = 0xC000071Au32 as i32; pub const STATUS_CALLBACK_RETURNED_THREAD_PRIORITY: ::NTSTATUS = 0xC000071Bu32 as i32; pub const STATUS_INVALID_THREAD: ::NTSTATUS = 0xC000071Cu32 as i32; pub const STATUS_CALLBACK_RETURNED_TRANSACTION: ::NTSTATUS = 0xC000071Du32 as i32; pub const STATUS_CALLBACK_RETURNED_LDR_LOCK: ::NTSTATUS = 0xC000071Eu32 as i32; pub const STATUS_CALLBACK_RETURNED_LANG: ::NTSTATUS = 0xC000071Fu32 as i32; pub const STATUS_CALLBACK_RETURNED_PRI_BACK: ::NTSTATUS = 0xC0000720u32 as i32; pub const STATUS_CALLBACK_RETURNED_THREAD_AFFINITY: ::NTSTATUS = 0xC0000721u32 as i32; pub const STATUS_DISK_REPAIR_DISABLED: ::NTSTATUS = 0xC0000800u32 as i32; pub const STATUS_DS_DOMAIN_RENAME_IN_PROGRESS: ::NTSTATUS = 0xC0000801u32 as i32; pub const STATUS_DISK_QUOTA_EXCEEDED: ::NTSTATUS = 0xC0000802u32 as i32; pub const STATUS_DATA_LOST_REPAIR: ::NTSTATUS = 0x80000803u32 as i32; pub const STATUS_CONTENT_BLOCKED: ::NTSTATUS = 0xC0000804u32 as i32; pub const STATUS_BAD_CLUSTERS: ::NTSTATUS = 0xC0000805u32 as i32; pub const STATUS_VOLUME_DIRTY: ::NTSTATUS = 0xC0000806u32 as i32; pub const STATUS_DISK_REPAIR_REDIRECTED: ::NTSTATUS = 0x40000807; pub const STATUS_DISK_REPAIR_UNSUCCESSFUL: ::NTSTATUS = 0xC0000808u32 as i32; pub const STATUS_CORRUPT_LOG_OVERFULL: ::NTSTATUS = 0xC0000809u32 as i32; pub const STATUS_CORRUPT_LOG_CORRUPTED: ::NTSTATUS = 0xC000080Au32 as i32; pub const STATUS_CORRUPT_LOG_UNAVAILABLE: ::NTSTATUS = 0xC000080Bu32 as i32; pub const STATUS_CORRUPT_LOG_DELETED_FULL: ::NTSTATUS = 0xC000080Cu32 as i32; pub const STATUS_CORRUPT_LOG_CLEARED: ::NTSTATUS = 0xC000080Du32 as i32; pub const STATUS_ORPHAN_NAME_EXHAUSTED: ::NTSTATUS = 0xC000080Eu32 as i32; pub const STATUS_PROACTIVE_SCAN_IN_PROGRESS: ::NTSTATUS = 0xC000080Fu32 as i32; pub const STATUS_ENCRYPTED_IO_NOT_POSSIBLE: ::NTSTATUS = 0xC0000810u32 as i32; pub const STATUS_CORRUPT_LOG_UPLEVEL_RECORDS: ::NTSTATUS = 0xC0000811u32 as i32; pub const STATUS_FILE_CHECKED_OUT: ::NTSTATUS = 0xC0000901u32 as i32; pub const STATUS_CHECKOUT_REQUIRED: ::NTSTATUS = 0xC0000902u32 as i32; pub const STATUS_BAD_FILE_TYPE: ::NTSTATUS = 0xC0000903u32 as i32; pub const STATUS_FILE_TOO_LARGE: ::NTSTATUS = 0xC0000904u32 as i32; pub const STATUS_FORMS_AUTH_REQUIRED: ::NTSTATUS = 0xC0000905u32 as i32; pub const STATUS_VIRUS_INFECTED: ::NTSTATUS = 0xC0000906u32 as i32; pub const STATUS_VIRUS_DELETED: ::NTSTATUS = 0xC0000907u32 as i32; pub const STATUS_BAD_MCFG_TABLE: ::NTSTATUS = 0xC0000908u32 as i32; pub const STATUS_CANNOT_BREAK_OPLOCK: ::NTSTATUS = 0xC0000909u32 as i32; pub const STATUS_BAD_KEY: ::NTSTATUS = 0xC000090Au32 as i32; pub const STATUS_BAD_DATA: ::NTSTATUS = 0xC000090Bu32 as i32; pub const STATUS_NO_KEY: ::NTSTATUS = 0xC000090Cu32 as i32; pub const STATUS_FILE_HANDLE_REVOKED: ::NTSTATUS = 0xC0000910u32 as i32; pub const STATUS_WOW_ASSERTION: ::NTSTATUS = 0xC0009898u32 as i32; pub const STATUS_INVALID_SIGNATURE: ::NTSTATUS = 0xC000A000u32 as i32; pub const STATUS_HMAC_NOT_SUPPORTED: ::NTSTATUS = 0xC000A001u32 as i32; pub const STATUS_AUTH_TAG_MISMATCH: ::NTSTATUS = 0xC000A002u32 as i32; pub const STATUS_INVALID_STATE_TRANSITION: ::NTSTATUS = 0xC000A003u32 as i32; pub const STATUS_INVALID_KERNEL_INFO_VERSION: ::NTSTATUS = 0xC000A004u32 as i32; pub const STATUS_INVALID_PEP_INFO_VERSION: ::NTSTATUS = 0xC000A005u32 as i32; pub const STATUS_HANDLE_REVOKED: ::NTSTATUS = 0xC000A006u32 as i32; pub const STATUS_IPSEC_QUEUE_OVERFLOW: ::NTSTATUS = 0xC000A010u32 as i32; pub const STATUS_ND_QUEUE_OVERFLOW: ::NTSTATUS = 0xC000A011u32 as i32; pub const STATUS_HOPLIMIT_EXCEEDED: ::NTSTATUS = 0xC000A012u32 as i32; pub const STATUS_PROTOCOL_NOT_SUPPORTED: ::NTSTATUS = 0xC000A013u32 as i32; pub const STATUS_FASTPATH_REJECTED: ::NTSTATUS = 0xC000A014u32 as i32; pub const STATUS_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED: ::NTSTATUS = 0xC000A080u32 as i32; pub const STATUS_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR: ::NTSTATUS = 0xC000A081u32 as i32; pub const STATUS_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR: ::NTSTATUS = 0xC000A082u32 as i32; pub const STATUS_XML_PARSE_ERROR: ::NTSTATUS = 0xC000A083u32 as i32; pub const STATUS_XMLDSIG_ERROR: ::NTSTATUS = 0xC000A084u32 as i32; pub const STATUS_WRONG_COMPARTMENT: ::NTSTATUS = 0xC000A085u32 as i32; pub const STATUS_AUTHIP_FAILURE: ::NTSTATUS = 0xC000A086u32 as i32; pub const STATUS_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS: ::NTSTATUS = 0xC000A087u32 as i32; pub const STATUS_DS_OID_NOT_FOUND: ::NTSTATUS = 0xC000A088u32 as i32; pub const STATUS_INCORRECT_ACCOUNT_TYPE: ::NTSTATUS = 0xC000A089u32 as i32; pub const STATUS_HASH_NOT_SUPPORTED: ::NTSTATUS = 0xC000A100u32 as i32; pub const STATUS_HASH_NOT_PRESENT: ::NTSTATUS = 0xC000A101u32 as i32; pub const STATUS_SECONDARY_IC_PROVIDER_NOT_REGISTERED: ::NTSTATUS = 0xC000A121u32 as i32; pub const STATUS_GPIO_CLIENT_INFORMATION_INVALID: ::NTSTATUS = 0xC000A122u32 as i32; pub const STATUS_GPIO_VERSION_NOT_SUPPORTED: ::NTSTATUS = 0xC000A123u32 as i32; pub const STATUS_GPIO_INVALID_REGISTRATION_PACKET: ::NTSTATUS = 0xC000A124u32 as i32; pub const STATUS_GPIO_OPERATION_DENIED: ::NTSTATUS = 0xC000A125u32 as i32; pub const STATUS_GPIO_INCOMPATIBLE_CONNECT_MODE: ::NTSTATUS = 0xC000A126u32 as i32; pub const STATUS_GPIO_INTERRUPT_ALREADY_UNMASKED: ::NTSTATUS = 0x8000A127u32 as i32; pub const STATUS_CANNOT_SWITCH_RUNLEVEL: ::NTSTATUS = 0xC000A141u32 as i32; pub const STATUS_INVALID_RUNLEVEL_SETTING: ::NTSTATUS = 0xC000A142u32 as i32; pub const STATUS_RUNLEVEL_SWITCH_TIMEOUT: ::NTSTATUS = 0xC000A143u32 as i32; pub const STATUS_SERVICES_FAILED_AUTOSTART: ::NTSTATUS = 0x4000A144; pub const STATUS_RUNLEVEL_SWITCH_AGENT_TIMEOUT: ::NTSTATUS = 0xC000A145u32 as i32; pub const STATUS_RUNLEVEL_SWITCH_IN_PROGRESS: ::NTSTATUS = 0xC000A146u32 as i32; pub const STATUS_NOT_APPCONTAINER: ::NTSTATUS = 0xC000A200u32 as i32; pub const STATUS_NOT_SUPPORTED_IN_APPCONTAINER: ::NTSTATUS = 0xC000A201u32 as i32; pub const STATUS_INVALID_PACKAGE_SID_LENGTH: ::NTSTATUS = 0xC000A202u32 as i32; pub const STATUS_APP_DATA_NOT_FOUND: ::NTSTATUS = 0xC000A281u32 as i32; pub const STATUS_APP_DATA_EXPIRED: ::NTSTATUS = 0xC000A282u32 as i32; pub const STATUS_APP_DATA_CORRUPT: ::NTSTATUS = 0xC000A283u32 as i32; pub const STATUS_APP_DATA_LIMIT_EXCEEDED: ::NTSTATUS = 0xC000A284u32 as i32; pub const STATUS_APP_DATA_REBOOT_REQUIRED: ::NTSTATUS = 0xC000A285u32 as i32; pub const STATUS_OFFLOAD_READ_FLT_NOT_SUPPORTED: ::NTSTATUS = 0xC000A2A1u32 as i32; pub const STATUS_OFFLOAD_WRITE_FLT_NOT_SUPPORTED: ::NTSTATUS = 0xC000A2A2u32 as i32; pub const STATUS_OFFLOAD_READ_FILE_NOT_SUPPORTED: ::NTSTATUS = 0xC000A2A3u32 as i32; pub const STATUS_OFFLOAD_WRITE_FILE_NOT_SUPPORTED: ::NTSTATUS = 0xC000A2A4u32 as i32; pub const DBG_NO_STATE_CHANGE: ::NTSTATUS = 0xC0010001u32 as i32; pub const DBG_APP_NOT_IDLE: ::NTSTATUS = 0xC0010002u32 as i32; pub const RPC_NT_INVALID_STRING_BINDING: ::NTSTATUS = 0xC0020001u32 as i32; pub const RPC_NT_WRONG_KIND_OF_BINDING: ::NTSTATUS = 0xC0020002u32 as i32; pub const RPC_NT_INVALID_BINDING: ::NTSTATUS = 0xC0020003u32 as i32; pub const RPC_NT_PROTSEQ_NOT_SUPPORTED: ::NTSTATUS = 0xC0020004u32 as i32; pub const RPC_NT_INVALID_RPC_PROTSEQ: ::NTSTATUS = 0xC0020005u32 as i32; pub const RPC_NT_INVALID_STRING_UUID: ::NTSTATUS = 0xC0020006u32 as i32; pub const RPC_NT_INVALID_ENDPOINT_FORMAT: ::NTSTATUS = 0xC0020007u32 as i32; pub const RPC_NT_INVALID_NET_ADDR: ::NTSTATUS = 0xC0020008u32 as i32; pub const RPC_NT_NO_ENDPOINT_FOUND: ::NTSTATUS = 0xC0020009u32 as i32; pub const RPC_NT_INVALID_TIMEOUT: ::NTSTATUS = 0xC002000Au32 as i32; pub const RPC_NT_OBJECT_NOT_FOUND: ::NTSTATUS = 0xC002000Bu32 as i32; pub const RPC_NT_ALREADY_REGISTERED: ::NTSTATUS = 0xC002000Cu32 as i32; pub const RPC_NT_TYPE_ALREADY_REGISTERED: ::NTSTATUS = 0xC002000Du32 as i32; pub const RPC_NT_ALREADY_LISTENING: ::NTSTATUS = 0xC002000Eu32 as i32; pub const RPC_NT_NO_PROTSEQS_REGISTERED: ::NTSTATUS = 0xC002000Fu32 as i32; pub const RPC_NT_NOT_LISTENING: ::NTSTATUS = 0xC0020010u32 as i32; pub const RPC_NT_UNKNOWN_MGR_TYPE: ::NTSTATUS = 0xC0020011u32 as i32; pub const RPC_NT_UNKNOWN_IF: ::NTSTATUS = 0xC0020012u32 as i32; pub const RPC_NT_NO_BINDINGS: ::NTSTATUS = 0xC0020013u32 as i32; pub const RPC_NT_NO_PROTSEQS: ::NTSTATUS = 0xC0020014u32 as i32; pub const RPC_NT_CANT_CREATE_ENDPOINT: ::NTSTATUS = 0xC0020015u32 as i32; pub const RPC_NT_OUT_OF_RESOURCES: ::NTSTATUS = 0xC0020016u32 as i32; pub const RPC_NT_SERVER_UNAVAILABLE: ::NTSTATUS = 0xC0020017u32 as i32; pub const RPC_NT_SERVER_TOO_BUSY: ::NTSTATUS = 0xC0020018u32 as i32; pub const RPC_NT_INVALID_NETWORK_OPTIONS: ::NTSTATUS = 0xC0020019u32 as i32; pub const RPC_NT_NO_CALL_ACTIVE: ::NTSTATUS = 0xC002001Au32 as i32; pub const RPC_NT_CALL_FAILED: ::NTSTATUS = 0xC002001Bu32 as i32; pub const RPC_NT_CALL_FAILED_DNE: ::NTSTATUS = 0xC002001Cu32 as i32; pub const RPC_NT_PROTOCOL_ERROR: ::NTSTATUS = 0xC002001Du32 as i32; pub const RPC_NT_UNSUPPORTED_TRANS_SYN: ::NTSTATUS = 0xC002001Fu32 as i32; pub const RPC_NT_UNSUPPORTED_TYPE: ::NTSTATUS = 0xC0020021u32 as i32; pub const RPC_NT_INVALID_TAG: ::NTSTATUS = 0xC0020022u32 as i32; pub const RPC_NT_INVALID_BOUND: ::NTSTATUS = 0xC0020023u32 as i32; pub const RPC_NT_NO_ENTRY_NAME: ::NTSTATUS = 0xC0020024u32 as i32; pub const RPC_NT_INVALID_NAME_SYNTAX: ::NTSTATUS = 0xC0020025u32 as i32; pub const RPC_NT_UNSUPPORTED_NAME_SYNTAX: ::NTSTATUS = 0xC0020026u32 as i32; pub const RPC_NT_UUID_NO_ADDRESS: ::NTSTATUS = 0xC0020028u32 as i32; pub const RPC_NT_DUPLICATE_ENDPOINT: ::NTSTATUS = 0xC0020029u32 as i32; pub const RPC_NT_UNKNOWN_AUTHN_TYPE: ::NTSTATUS = 0xC002002Au32 as i32; pub const RPC_NT_MAX_CALLS_TOO_SMALL: ::NTSTATUS = 0xC002002Bu32 as i32; pub const RPC_NT_STRING_TOO_LONG: ::NTSTATUS = 0xC002002Cu32 as i32; pub const RPC_NT_PROTSEQ_NOT_FOUND: ::NTSTATUS = 0xC002002Du32 as i32; pub const RPC_NT_PROCNUM_OUT_OF_RANGE: ::NTSTATUS = 0xC002002Eu32 as i32; pub const RPC_NT_BINDING_HAS_NO_AUTH: ::NTSTATUS = 0xC002002Fu32 as i32; pub const RPC_NT_UNKNOWN_AUTHN_SERVICE: ::NTSTATUS = 0xC0020030u32 as i32; pub const RPC_NT_UNKNOWN_AUTHN_LEVEL: ::NTSTATUS = 0xC0020031u32 as i32; pub const RPC_NT_INVALID_AUTH_IDENTITY: ::NTSTATUS = 0xC0020032u32 as i32; pub const RPC_NT_UNKNOWN_AUTHZ_SERVICE: ::NTSTATUS = 0xC0020033u32 as i32; pub const EPT_NT_INVALID_ENTRY: ::NTSTATUS = 0xC0020034u32 as i32; pub const EPT_NT_CANT_PERFORM_OP: ::NTSTATUS = 0xC0020035u32 as i32; pub const EPT_NT_NOT_REGISTERED: ::NTSTATUS = 0xC0020036u32 as i32; pub const RPC_NT_NOTHING_TO_EXPORT: ::NTSTATUS = 0xC0020037u32 as i32; pub const RPC_NT_INCOMPLETE_NAME: ::NTSTATUS = 0xC0020038u32 as i32; pub const RPC_NT_INVALID_VERS_OPTION: ::NTSTATUS = 0xC0020039u32 as i32; pub const RPC_NT_NO_MORE_MEMBERS: ::NTSTATUS = 0xC002003Au32 as i32; pub const RPC_NT_NOT_ALL_OBJS_UNEXPORTED: ::NTSTATUS = 0xC002003Bu32 as i32; pub const RPC_NT_INTERFACE_NOT_FOUND: ::NTSTATUS = 0xC002003Cu32 as i32; pub const RPC_NT_ENTRY_ALREADY_EXISTS: ::NTSTATUS = 0xC002003Du32 as i32; pub const RPC_NT_ENTRY_NOT_FOUND: ::NTSTATUS = 0xC002003Eu32 as i32; pub const RPC_NT_NAME_SERVICE_UNAVAILABLE: ::NTSTATUS = 0xC002003Fu32 as i32; pub const RPC_NT_INVALID_NAF_ID: ::NTSTATUS = 0xC0020040u32 as i32; pub const RPC_NT_CANNOT_SUPPORT: ::NTSTATUS = 0xC0020041u32 as i32; pub const RPC_NT_NO_CONTEXT_AVAILABLE: ::NTSTATUS = 0xC0020042u32 as i32; pub const RPC_NT_INTERNAL_ERROR: ::NTSTATUS = 0xC0020043u32 as i32; pub const RPC_NT_ZERO_DIVIDE: ::NTSTATUS = 0xC0020044u32 as i32; pub const RPC_NT_ADDRESS_ERROR: ::NTSTATUS = 0xC0020045u32 as i32; pub const RPC_NT_FP_DIV_ZERO: ::NTSTATUS = 0xC0020046u32 as i32; pub const RPC_NT_FP_UNDERFLOW: ::NTSTATUS = 0xC0020047u32 as i32; pub const RPC_NT_FP_OVERFLOW: ::NTSTATUS = 0xC0020048u32 as i32; pub const RPC_NT_NO_MORE_ENTRIES: ::NTSTATUS = 0xC0030001u32 as i32; pub const RPC_NT_SS_CHAR_TRANS_OPEN_FAIL: ::NTSTATUS = 0xC0030002u32 as i32; pub const RPC_NT_SS_CHAR_TRANS_SHORT_FILE: ::NTSTATUS = 0xC0030003u32 as i32; pub const RPC_NT_SS_IN_NULL_CONTEXT: ::NTSTATUS = 0xC0030004u32 as i32; pub const RPC_NT_SS_CONTEXT_MISMATCH: ::NTSTATUS = 0xC0030005u32 as i32; pub const RPC_NT_SS_CONTEXT_DAMAGED: ::NTSTATUS = 0xC0030006u32 as i32; pub const RPC_NT_SS_HANDLES_MISMATCH: ::NTSTATUS = 0xC0030007u32 as i32; pub const RPC_NT_SS_CANNOT_GET_CALL_HANDLE: ::NTSTATUS = 0xC0030008u32 as i32; pub const RPC_NT_NULL_REF_POINTER: ::NTSTATUS = 0xC0030009u32 as i32; pub const RPC_NT_ENUM_VALUE_OUT_OF_RANGE: ::NTSTATUS = 0xC003000Au32 as i32; pub const RPC_NT_BYTE_COUNT_TOO_SMALL: ::NTSTATUS = 0xC003000Bu32 as i32; pub const RPC_NT_BAD_STUB_DATA: ::NTSTATUS = 0xC003000Cu32 as i32; pub const RPC_NT_CALL_IN_PROGRESS: ::NTSTATUS = 0xC0020049u32 as i32; pub const RPC_NT_NO_MORE_BINDINGS: ::NTSTATUS = 0xC002004Au32 as i32; pub const RPC_NT_GROUP_MEMBER_NOT_FOUND: ::NTSTATUS = 0xC002004Bu32 as i32; pub const EPT_NT_CANT_CREATE: ::NTSTATUS = 0xC002004Cu32 as i32; pub const RPC_NT_INVALID_OBJECT: ::NTSTATUS = 0xC002004Du32 as i32; pub const RPC_NT_NO_INTERFACES: ::NTSTATUS = 0xC002004Fu32 as i32; pub const RPC_NT_CALL_CANCELLED: ::NTSTATUS = 0xC0020050u32 as i32; pub const RPC_NT_BINDING_INCOMPLETE: ::NTSTATUS = 0xC0020051u32 as i32; pub const RPC_NT_COMM_FAILURE: ::NTSTATUS = 0xC0020052u32 as i32; pub const RPC_NT_UNSUPPORTED_AUTHN_LEVEL: ::NTSTATUS = 0xC0020053u32 as i32; pub const RPC_NT_NO_PRINC_NAME: ::NTSTATUS = 0xC0020054u32 as i32; pub const RPC_NT_NOT_RPC_ERROR: ::NTSTATUS = 0xC0020055u32 as i32; pub const RPC_NT_UUID_LOCAL_ONLY: ::NTSTATUS = 0x40020056; pub const RPC_NT_SEC_PKG_ERROR: ::NTSTATUS = 0xC0020057u32 as i32; pub const RPC_NT_NOT_CANCELLED: ::NTSTATUS = 0xC0020058u32 as i32; pub const RPC_NT_INVALID_ES_ACTION: ::NTSTATUS = 0xC0030059u32 as i32; pub const RPC_NT_WRONG_ES_VERSION: ::NTSTATUS = 0xC003005Au32 as i32; pub const RPC_NT_WRONG_STUB_VERSION: ::NTSTATUS = 0xC003005Bu32 as i32; pub const RPC_NT_INVALID_PIPE_OBJECT: ::NTSTATUS = 0xC003005Cu32 as i32; pub const RPC_NT_INVALID_PIPE_OPERATION: ::NTSTATUS = 0xC003005Du32 as i32; pub const RPC_NT_WRONG_PIPE_VERSION: ::NTSTATUS = 0xC003005Eu32 as i32; pub const RPC_NT_PIPE_CLOSED: ::NTSTATUS = 0xC003005Fu32 as i32; pub const RPC_NT_PIPE_DISCIPLINE_ERROR: ::NTSTATUS = 0xC0030060u32 as i32; pub const RPC_NT_PIPE_EMPTY: ::NTSTATUS = 0xC0030061u32 as i32; pub const RPC_NT_INVALID_ASYNC_HANDLE: ::NTSTATUS = 0xC0020062u32 as i32; pub const RPC_NT_INVALID_ASYNC_CALL: ::NTSTATUS = 0xC0020063u32 as i32; pub const RPC_NT_PROXY_ACCESS_DENIED: ::NTSTATUS = 0xC0020064u32 as i32; pub const RPC_NT_COOKIE_AUTH_FAILED: ::NTSTATUS = 0xC0020065u32 as i32; pub const RPC_NT_SEND_INCOMPLETE: ::NTSTATUS = 0x400200AF; pub const STATUS_ACPI_INVALID_OPCODE: ::NTSTATUS = 0xC0140001u32 as i32; pub const STATUS_ACPI_STACK_OVERFLOW: ::NTSTATUS = 0xC0140002u32 as i32; pub const STATUS_ACPI_ASSERT_FAILED: ::NTSTATUS = 0xC0140003u32 as i32; pub const STATUS_ACPI_INVALID_INDEX: ::NTSTATUS = 0xC0140004u32 as i32; pub const STATUS_ACPI_INVALID_ARGUMENT: ::NTSTATUS = 0xC0140005u32 as i32; pub const STATUS_ACPI_FATAL: ::NTSTATUS = 0xC0140006u32 as i32; pub const STATUS_ACPI_INVALID_SUPERNAME: ::NTSTATUS = 0xC0140007u32 as i32; pub const STATUS_ACPI_INVALID_ARGTYPE: ::NTSTATUS = 0xC0140008u32 as i32; pub const STATUS_ACPI_INVALID_OBJTYPE: ::NTSTATUS = 0xC0140009u32 as i32; pub const STATUS_ACPI_INVALID_TARGETTYPE: ::NTSTATUS = 0xC014000Au32 as i32; pub const STATUS_ACPI_INCORRECT_ARGUMENT_COUNT: ::NTSTATUS = 0xC014000Bu32 as i32; pub const STATUS_ACPI_ADDRESS_NOT_MAPPED: ::NTSTATUS = 0xC014000Cu32 as i32; pub const STATUS_ACPI_INVALID_EVENTTYPE: ::NTSTATUS = 0xC014000Du32 as i32; pub const STATUS_ACPI_HANDLER_COLLISION: ::NTSTATUS = 0xC014000Eu32 as i32; pub const STATUS_ACPI_INVALID_DATA: ::NTSTATUS = 0xC014000Fu32 as i32; pub const STATUS_ACPI_INVALID_REGION: ::NTSTATUS = 0xC0140010u32 as i32; pub const STATUS_ACPI_INVALID_ACCESS_SIZE: ::NTSTATUS = 0xC0140011u32 as i32; pub const STATUS_ACPI_ACQUIRE_GLOBAL_LOCK: ::NTSTATUS = 0xC0140012u32 as i32; pub const STATUS_ACPI_ALREADY_INITIALIZED: ::NTSTATUS = 0xC0140013u32 as i32; pub const STATUS_ACPI_NOT_INITIALIZED: ::NTSTATUS = 0xC0140014u32 as i32; pub const STATUS_ACPI_INVALID_MUTEX_LEVEL: ::NTSTATUS = 0xC0140015u32 as i32; pub const STATUS_ACPI_MUTEX_NOT_OWNED: ::NTSTATUS = 0xC0140016u32 as i32; pub const STATUS_ACPI_MUTEX_NOT_OWNER: ::NTSTATUS = 0xC0140017u32 as i32; pub const STATUS_ACPI_RS_ACCESS: ::NTSTATUS = 0xC0140018u32 as i32; pub const STATUS_ACPI_INVALID_TABLE: ::NTSTATUS = 0xC0140019u32 as i32; pub const STATUS_ACPI_REG_HANDLER_FAILED: ::NTSTATUS = 0xC0140020u32 as i32; pub const STATUS_ACPI_POWER_REQUEST_FAILED: ::NTSTATUS = 0xC0140021u32 as i32; pub const STATUS_CTX_WINSTATION_NAME_INVALID: ::NTSTATUS = 0xC00A0001u32 as i32; pub const STATUS_CTX_INVALID_PD: ::NTSTATUS = 0xC00A0002u32 as i32; pub const STATUS_CTX_PD_NOT_FOUND: ::NTSTATUS = 0xC00A0003u32 as i32; pub const STATUS_CTX_CDM_CONNECT: ::NTSTATUS = 0x400A0004; pub const STATUS_CTX_CDM_DISCONNECT: ::NTSTATUS = 0x400A0005; pub const STATUS_CTX_CLOSE_PENDING: ::NTSTATUS = 0xC00A0006u32 as i32; pub const STATUS_CTX_NO_OUTBUF: ::NTSTATUS = 0xC00A0007u32 as i32; pub const STATUS_CTX_MODEM_INF_NOT_FOUND: ::NTSTATUS = 0xC00A0008u32 as i32; pub const STATUS_CTX_INVALID_MODEMNAME: ::NTSTATUS = 0xC00A0009u32 as i32; pub const STATUS_CTX_RESPONSE_ERROR: ::NTSTATUS = 0xC00A000Au32 as i32; pub const STATUS_CTX_MODEM_RESPONSE_TIMEOUT: ::NTSTATUS = 0xC00A000Bu32 as i32; pub const STATUS_CTX_MODEM_RESPONSE_NO_CARRIER: ::NTSTATUS = 0xC00A000Cu32 as i32; pub const STATUS_CTX_MODEM_RESPONSE_NO_DIALTONE: ::NTSTATUS = 0xC00A000Du32 as i32; pub const STATUS_CTX_MODEM_RESPONSE_BUSY: ::NTSTATUS = 0xC00A000Eu32 as i32; pub const STATUS_CTX_MODEM_RESPONSE_VOICE: ::NTSTATUS = 0xC00A000Fu32 as i32; pub const STATUS_CTX_TD_ERROR: ::NTSTATUS = 0xC00A0010u32 as i32; pub const STATUS_CTX_LICENSE_CLIENT_INVALID: ::NTSTATUS = 0xC00A0012u32 as i32; pub const STATUS_CTX_LICENSE_NOT_AVAILABLE: ::NTSTATUS = 0xC00A0013u32 as i32; pub const STATUS_CTX_LICENSE_EXPIRED: ::NTSTATUS = 0xC00A0014u32 as i32; pub const STATUS_CTX_WINSTATION_NOT_FOUND: ::NTSTATUS = 0xC00A0015u32 as i32; pub const STATUS_CTX_WINSTATION_NAME_COLLISION: ::NTSTATUS = 0xC00A0016u32 as i32; pub const STATUS_CTX_WINSTATION_BUSY: ::NTSTATUS = 0xC00A0017u32 as i32; pub const STATUS_CTX_BAD_VIDEO_MODE: ::NTSTATUS = 0xC00A0018u32 as i32; pub const STATUS_CTX_GRAPHICS_INVALID: ::NTSTATUS = 0xC00A0022u32 as i32; pub const STATUS_CTX_NOT_CONSOLE: ::NTSTATUS = 0xC00A0024u32 as i32; pub const STATUS_CTX_CLIENT_QUERY_TIMEOUT: ::NTSTATUS = 0xC00A0026u32 as i32; pub const STATUS_CTX_CONSOLE_DISCONNECT: ::NTSTATUS = 0xC00A0027u32 as i32; pub const STATUS_CTX_CONSOLE_CONNECT: ::NTSTATUS = 0xC00A0028u32 as i32; pub const STATUS_CTX_SHADOW_DENIED: ::NTSTATUS = 0xC00A002Au32 as i32; pub const STATUS_CTX_WINSTATION_ACCESS_DENIED: ::NTSTATUS = 0xC00A002Bu32 as i32; pub const STATUS_CTX_INVALID_WD: ::NTSTATUS = 0xC00A002Eu32 as i32; pub const STATUS_CTX_WD_NOT_FOUND: ::NTSTATUS = 0xC00A002Fu32 as i32; pub const STATUS_CTX_SHADOW_INVALID: ::NTSTATUS = 0xC00A0030u32 as i32; pub const STATUS_CTX_SHADOW_DISABLED: ::NTSTATUS = 0xC00A0031u32 as i32; pub const STATUS_RDP_PROTOCOL_ERROR: ::NTSTATUS = 0xC00A0032u32 as i32; pub const STATUS_CTX_CLIENT_LICENSE_NOT_SET: ::NTSTATUS = 0xC00A0033u32 as i32; pub const STATUS_CTX_CLIENT_LICENSE_IN_USE: ::NTSTATUS = 0xC00A0034u32 as i32; pub const STATUS_CTX_SHADOW_ENDED_BY_MODE_CHANGE: ::NTSTATUS = 0xC00A0035u32 as i32; pub const STATUS_CTX_SHADOW_NOT_RUNNING: ::NTSTATUS = 0xC00A0036u32 as i32; pub const STATUS_CTX_LOGON_DISABLED: ::NTSTATUS = 0xC00A0037u32 as i32; pub const STATUS_CTX_SECURITY_LAYER_ERROR: ::NTSTATUS = 0xC00A0038u32 as i32; pub const STATUS_TS_INCOMPATIBLE_SESSIONS: ::NTSTATUS = 0xC00A0039u32 as i32; pub const STATUS_TS_VIDEO_SUBSYSTEM_ERROR: ::NTSTATUS = 0xC00A003Au32 as i32; pub const STATUS_PNP_BAD_MPS_TABLE: ::NTSTATUS = 0xC0040035u32 as i32; pub const STATUS_PNP_TRANSLATION_FAILED: ::NTSTATUS = 0xC0040036u32 as i32; pub const STATUS_PNP_IRQ_TRANSLATION_FAILED: ::NTSTATUS = 0xC0040037u32 as i32; pub const STATUS_PNP_INVALID_ID: ::NTSTATUS = 0xC0040038u32 as i32; pub const STATUS_IO_REISSUE_AS_CACHED: ::NTSTATUS = 0xC0040039u32 as i32; pub const STATUS_MUI_FILE_NOT_FOUND: ::NTSTATUS = 0xC00B0001u32 as i32; pub const STATUS_MUI_INVALID_FILE: ::NTSTATUS = 0xC00B0002u32 as i32; pub const STATUS_MUI_INVALID_RC_CONFIG: ::NTSTATUS = 0xC00B0003u32 as i32; pub const STATUS_MUI_INVALID_LOCALE_NAME: ::NTSTATUS = 0xC00B0004u32 as i32; pub const STATUS_MUI_INVALID_ULTIMATEFALLBACK_NAME: ::NTSTATUS = 0xC00B0005u32 as i32; pub const STATUS_MUI_FILE_NOT_LOADED: ::NTSTATUS = 0xC00B0006u32 as i32; pub const STATUS_RESOURCE_ENUM_USER_STOP: ::NTSTATUS = 0xC00B0007u32 as i32; pub const STATUS_FLT_NO_HANDLER_DEFINED: ::NTSTATUS = 0xC01C0001u32 as i32; pub const STATUS_FLT_CONTEXT_ALREADY_DEFINED: ::NTSTATUS = 0xC01C0002u32 as i32; pub const STATUS_FLT_INVALID_ASYNCHRONOUS_REQUEST: ::NTSTATUS = 0xC01C0003u32 as i32; pub const STATUS_FLT_DISALLOW_FAST_IO: ::NTSTATUS = 0xC01C0004u32 as i32; pub const STATUS_FLT_INVALID_NAME_REQUEST: ::NTSTATUS = 0xC01C0005u32 as i32; pub const STATUS_FLT_NOT_SAFE_TO_POST_OPERATION: ::NTSTATUS = 0xC01C0006u32 as i32; pub const STATUS_FLT_NOT_INITIALIZED: ::NTSTATUS = 0xC01C0007u32 as i32; pub const STATUS_FLT_FILTER_NOT_READY: ::NTSTATUS = 0xC01C0008u32 as i32; pub const STATUS_FLT_POST_OPERATION_CLEANUP: ::NTSTATUS = 0xC01C0009u32 as i32; pub const STATUS_FLT_INTERNAL_ERROR: ::NTSTATUS = 0xC01C000Au32 as i32; pub const STATUS_FLT_DELETING_OBJECT: ::NTSTATUS = 0xC01C000Bu32 as i32; pub const STATUS_FLT_MUST_BE_NONPAGED_POOL: ::NTSTATUS = 0xC01C000Cu32 as i32; pub const STATUS_FLT_DUPLICATE_ENTRY: ::NTSTATUS = 0xC01C000Du32 as i32; pub const STATUS_FLT_CBDQ_DISABLED: ::NTSTATUS = 0xC01C000Eu32 as i32; pub const STATUS_FLT_DO_NOT_ATTACH: ::NTSTATUS = 0xC01C000Fu32 as i32; pub const STATUS_FLT_DO_NOT_DETACH: ::NTSTATUS = 0xC01C0010u32 as i32; pub const STATUS_FLT_INSTANCE_ALTITUDE_COLLISION: ::NTSTATUS = 0xC01C0011u32 as i32; pub const STATUS_FLT_INSTANCE_NAME_COLLISION: ::NTSTATUS = 0xC01C0012u32 as i32; pub const STATUS_FLT_FILTER_NOT_FOUND: ::NTSTATUS = 0xC01C0013u32 as i32; pub const STATUS_FLT_VOLUME_NOT_FOUND: ::NTSTATUS = 0xC01C0014u32 as i32; pub const STATUS_FLT_INSTANCE_NOT_FOUND: ::NTSTATUS = 0xC01C0015u32 as i32; pub const STATUS_FLT_CONTEXT_ALLOCATION_NOT_FOUND: ::NTSTATUS = 0xC01C0016u32 as i32; pub const STATUS_FLT_INVALID_CONTEXT_REGISTRATION: ::NTSTATUS = 0xC01C0017u32 as i32; pub const STATUS_FLT_NAME_CACHE_MISS: ::NTSTATUS = 0xC01C0018u32 as i32; pub const STATUS_FLT_NO_DEVICE_OBJECT: ::NTSTATUS = 0xC01C0019u32 as i32; pub const STATUS_FLT_VOLUME_ALREADY_MOUNTED: ::NTSTATUS = 0xC01C001Au32 as i32; pub const STATUS_FLT_ALREADY_ENLISTED: ::NTSTATUS = 0xC01C001Bu32 as i32; pub const STATUS_FLT_CONTEXT_ALREADY_LINKED: ::NTSTATUS = 0xC01C001Cu32 as i32; pub const STATUS_FLT_NO_WAITER_FOR_REPLY: ::NTSTATUS = 0xC01C0020u32 as i32; pub const STATUS_FLT_REGISTRATION_BUSY: ::NTSTATUS = 0xC01C0023u32 as i32; pub const STATUS_SXS_SECTION_NOT_FOUND: ::NTSTATUS = 0xC0150001u32 as i32; pub const STATUS_SXS_CANT_GEN_ACTCTX: ::NTSTATUS = 0xC0150002u32 as i32; pub const STATUS_SXS_INVALID_ACTCTXDATA_FORMAT: ::NTSTATUS = 0xC0150003u32 as i32; pub const STATUS_SXS_ASSEMBLY_NOT_FOUND: ::NTSTATUS = 0xC0150004u32 as i32; pub const STATUS_SXS_MANIFEST_FORMAT_ERROR: ::NTSTATUS = 0xC0150005u32 as i32; pub const STATUS_SXS_MANIFEST_PARSE_ERROR: ::NTSTATUS = 0xC0150006u32 as i32; pub const STATUS_SXS_ACTIVATION_CONTEXT_DISABLED: ::NTSTATUS = 0xC0150007u32 as i32; pub const STATUS_SXS_KEY_NOT_FOUND: ::NTSTATUS = 0xC0150008u32 as i32; pub const STATUS_SXS_VERSION_CONFLICT: ::NTSTATUS = 0xC0150009u32 as i32; pub const STATUS_SXS_WRONG_SECTION_TYPE: ::NTSTATUS = 0xC015000Au32 as i32; pub const STATUS_SXS_THREAD_QUERIES_DISABLED: ::NTSTATUS = 0xC015000Bu32 as i32; pub const STATUS_SXS_ASSEMBLY_MISSING: ::NTSTATUS = 0xC015000Cu32 as i32; pub const STATUS_SXS_RELEASE_ACTIVATION_CONTEXT: ::NTSTATUS = 0x4015000D; pub const STATUS_SXS_PROCESS_DEFAULT_ALREADY_SET: ::NTSTATUS = 0xC015000Eu32 as i32; pub const STATUS_SXS_EARLY_DEACTIVATION: ::NTSTATUS = 0xC015000Fu32 as i32; pub const STATUS_SXS_INVALID_DEACTIVATION: ::NTSTATUS = 0xC0150010u32 as i32; pub const STATUS_SXS_MULTIPLE_DEACTIVATION: ::NTSTATUS = 0xC0150011u32 as i32; pub const STATUS_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY: ::NTSTATUS = 0xC0150012u32 as i32; pub const STATUS_SXS_PROCESS_TERMINATION_REQUESTED: ::NTSTATUS = 0xC0150013u32 as i32; pub const STATUS_SXS_CORRUPT_ACTIVATION_STACK: ::NTSTATUS = 0xC0150014u32 as i32; pub const STATUS_SXS_CORRUPTION: ::NTSTATUS = 0xC0150015u32 as i32; pub const STATUS_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE: ::NTSTATUS = 0xC0150016u32 as i32; pub const STATUS_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME: ::NTSTATUS = 0xC0150017u32 as i32; pub const STATUS_SXS_IDENTITY_DUPLICATE_ATTRIBUTE: ::NTSTATUS = 0xC0150018u32 as i32; pub const STATUS_SXS_IDENTITY_PARSE_ERROR: ::NTSTATUS = 0xC0150019u32 as i32; pub const STATUS_SXS_COMPONENT_STORE_CORRUPT: ::NTSTATUS = 0xC015001Au32 as i32; pub const STATUS_SXS_FILE_HASH_MISMATCH: ::NTSTATUS = 0xC015001Bu32 as i32; pub const STATUS_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT: ::NTSTATUS = 0xC015001Cu32 as i32; pub const STATUS_SXS_IDENTITIES_DIFFERENT: ::NTSTATUS = 0xC015001Du32 as i32; pub const STATUS_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT: ::NTSTATUS = 0xC015001Eu32 as i32; pub const STATUS_SXS_FILE_NOT_PART_OF_ASSEMBLY: ::NTSTATUS = 0xC015001Fu32 as i32; pub const STATUS_ADVANCED_INSTALLER_FAILED: ::NTSTATUS = 0xC0150020u32 as i32; pub const STATUS_XML_ENCODING_MISMATCH: ::NTSTATUS = 0xC0150021u32 as i32; pub const STATUS_SXS_MANIFEST_TOO_BIG: ::NTSTATUS = 0xC0150022u32 as i32; pub const STATUS_SXS_SETTING_NOT_REGISTERED: ::NTSTATUS = 0xC0150023u32 as i32; pub const STATUS_SXS_TRANSACTION_CLOSURE_INCOMPLETE: ::NTSTATUS = 0xC0150024u32 as i32; pub const STATUS_SMI_PRIMITIVE_INSTALLER_FAILED: ::NTSTATUS = 0xC0150025u32 as i32; pub const STATUS_GENERIC_COMMAND_FAILED: ::NTSTATUS = 0xC0150026u32 as i32; pub const STATUS_SXS_FILE_HASH_MISSING: ::NTSTATUS = 0xC0150027u32 as i32; pub const STATUS_CLUSTER_INVALID_NODE: ::NTSTATUS = 0xC0130001u32 as i32; pub const STATUS_CLUSTER_NODE_EXISTS: ::NTSTATUS = 0xC0130002u32 as i32; pub const STATUS_CLUSTER_JOIN_IN_PROGRESS: ::NTSTATUS = 0xC0130003u32 as i32; pub const STATUS_CLUSTER_NODE_NOT_FOUND: ::NTSTATUS = 0xC0130004u32 as i32; pub const STATUS_CLUSTER_LOCAL_NODE_NOT_FOUND: ::NTSTATUS = 0xC0130005u32 as i32; pub const STATUS_CLUSTER_NETWORK_EXISTS: ::NTSTATUS = 0xC0130006u32 as i32; pub const STATUS_CLUSTER_NETWORK_NOT_FOUND: ::NTSTATUS = 0xC0130007u32 as i32; pub const STATUS_CLUSTER_NETINTERFACE_EXISTS: ::NTSTATUS = 0xC0130008u32 as i32; pub const STATUS_CLUSTER_NETINTERFACE_NOT_FOUND: ::NTSTATUS = 0xC0130009u32 as i32; pub const STATUS_CLUSTER_INVALID_REQUEST: ::NTSTATUS = 0xC013000Au32 as i32; pub const STATUS_CLUSTER_INVALID_NETWORK_PROVIDER: ::NTSTATUS = 0xC013000Bu32 as i32; pub const STATUS_CLUSTER_NODE_DOWN: ::NTSTATUS = 0xC013000Cu32 as i32; pub const STATUS_CLUSTER_NODE_UNREACHABLE: ::NTSTATUS = 0xC013000Du32 as i32; pub const STATUS_CLUSTER_NODE_NOT_MEMBER: ::NTSTATUS = 0xC013000Eu32 as i32; pub const STATUS_CLUSTER_JOIN_NOT_IN_PROGRESS: ::NTSTATUS = 0xC013000Fu32 as i32; pub const STATUS_CLUSTER_INVALID_NETWORK: ::NTSTATUS = 0xC0130010u32 as i32; pub const STATUS_CLUSTER_NO_NET_ADAPTERS: ::NTSTATUS = 0xC0130011u32 as i32; pub const STATUS_CLUSTER_NODE_UP: ::NTSTATUS = 0xC0130012u32 as i32; pub const STATUS_CLUSTER_NODE_PAUSED: ::NTSTATUS = 0xC0130013u32 as i32; pub const STATUS_CLUSTER_NODE_NOT_PAUSED: ::NTSTATUS = 0xC0130014u32 as i32; pub const STATUS_CLUSTER_NO_SECURITY_CONTEXT: ::NTSTATUS = 0xC0130015u32 as i32; pub const STATUS_CLUSTER_NETWORK_NOT_INTERNAL: ::NTSTATUS = 0xC0130016u32 as i32; pub const STATUS_CLUSTER_POISONED: ::NTSTATUS = 0xC0130017u32 as i32; pub const STATUS_CLUSTER_NON_CSV_PATH: ::NTSTATUS = 0xC0130018u32 as i32; pub const STATUS_CLUSTER_CSV_VOLUME_NOT_LOCAL: ::NTSTATUS = 0xC0130019u32 as i32; pub const STATUS_CLUSTER_CSV_READ_OPLOCK_BREAK_IN_PROGRESS: ::NTSTATUS = 0xC0130020u32 as i32; pub const STATUS_CLUSTER_CSV_AUTO_PAUSE_ERROR: ::NTSTATUS = 0xC0130021u32 as i32; pub const STATUS_CLUSTER_CSV_REDIRECTED: ::NTSTATUS = 0xC0130022u32 as i32; pub const STATUS_CLUSTER_CSV_NOT_REDIRECTED: ::NTSTATUS = 0xC0130023u32 as i32; pub const STATUS_CLUSTER_CSV_VOLUME_DRAINING: ::NTSTATUS = 0xC0130024u32 as i32; pub const STATUS_CLUSTER_CSV_SNAPSHOT_CREATION_IN_PROGRESS: ::NTSTATUS = 0xC0130025u32 as i32; pub const STATUS_CLUSTER_CSV_VOLUME_DRAINING_SUCCEEDED_DOWNLEVEL: ::NTSTATUS = 0xC0130026u32 as i32; pub const STATUS_CLUSTER_CSV_NO_SNAPSHOTS: ::NTSTATUS = 0xC0130027u32 as i32; pub const STATUS_CSV_IO_PAUSE_TIMEOUT: ::NTSTATUS = 0xC0130028u32 as i32; pub const STATUS_TRANSACTIONAL_CONFLICT: ::NTSTATUS = 0xC0190001u32 as i32; pub const STATUS_INVALID_TRANSACTION: ::NTSTATUS = 0xC0190002u32 as i32; pub const STATUS_TRANSACTION_NOT_ACTIVE: ::NTSTATUS = 0xC0190003u32 as i32; pub const STATUS_TM_INITIALIZATION_FAILED: ::NTSTATUS = 0xC0190004u32 as i32; pub const STATUS_RM_NOT_ACTIVE: ::NTSTATUS = 0xC0190005u32 as i32; pub const STATUS_RM_METADATA_CORRUPT: ::NTSTATUS = 0xC0190006u32 as i32; pub const STATUS_TRANSACTION_NOT_JOINED: ::NTSTATUS = 0xC0190007u32 as i32; pub const STATUS_DIRECTORY_NOT_RM: ::NTSTATUS = 0xC0190008u32 as i32; pub const STATUS_COULD_NOT_RESIZE_LOG: ::NTSTATUS = 0x80190009u32 as i32; pub const STATUS_TRANSACTIONS_UNSUPPORTED_REMOTE: ::NTSTATUS = 0xC019000Au32 as i32; pub const STATUS_LOG_RESIZE_INVALID_SIZE: ::NTSTATUS = 0xC019000Bu32 as i32; pub const STATUS_REMOTE_FILE_VERSION_MISMATCH: ::NTSTATUS = 0xC019000Cu32 as i32; pub const STATUS_CRM_PROTOCOL_ALREADY_EXISTS: ::NTSTATUS = 0xC019000Fu32 as i32; pub const STATUS_TRANSACTION_PROPAGATION_FAILED: ::NTSTATUS = 0xC0190010u32 as i32; pub const STATUS_CRM_PROTOCOL_NOT_FOUND: ::NTSTATUS = 0xC0190011u32 as i32; pub const STATUS_TRANSACTION_SUPERIOR_EXISTS: ::NTSTATUS = 0xC0190012u32 as i32; pub const STATUS_TRANSACTION_REQUEST_NOT_VALID: ::NTSTATUS = 0xC0190013u32 as i32; pub const STATUS_TRANSACTION_NOT_REQUESTED: ::NTSTATUS = 0xC0190014u32 as i32; pub const STATUS_TRANSACTION_ALREADY_ABORTED: ::NTSTATUS = 0xC0190015u32 as i32; pub const STATUS_TRANSACTION_ALREADY_COMMITTED: ::NTSTATUS = 0xC0190016u32 as i32; pub const STATUS_TRANSACTION_INVALID_MARSHALL_BUFFER: ::NTSTATUS = 0xC0190017u32 as i32; pub const STATUS_CURRENT_TRANSACTION_NOT_VALID: ::NTSTATUS = 0xC0190018u32 as i32; pub const STATUS_LOG_GROWTH_FAILED: ::NTSTATUS = 0xC0190019u32 as i32; pub const STATUS_OBJECT_NO_LONGER_EXISTS: ::NTSTATUS = 0xC0190021u32 as i32; pub const STATUS_STREAM_MINIVERSION_NOT_FOUND: ::NTSTATUS = 0xC0190022u32 as i32; pub const STATUS_STREAM_MINIVERSION_NOT_VALID: ::NTSTATUS = 0xC0190023u32 as i32; pub const STATUS_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION: ::NTSTATUS = 0xC0190024u32 as i32; pub const STATUS_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT: ::NTSTATUS = 0xC0190025u32 as i32; pub const STATUS_CANT_CREATE_MORE_STREAM_MINIVERSIONS: ::NTSTATUS = 0xC0190026u32 as i32; pub const STATUS_HANDLE_NO_LONGER_VALID: ::NTSTATUS = 0xC0190028u32 as i32; pub const STATUS_NO_TXF_METADATA: ::NTSTATUS = 0x80190029u32 as i32; pub const STATUS_LOG_CORRUPTION_DETECTED: ::NTSTATUS = 0xC0190030u32 as i32; pub const STATUS_CANT_RECOVER_WITH_HANDLE_OPEN: ::NTSTATUS = 0x80190031u32 as i32; pub const STATUS_RM_DISCONNECTED: ::NTSTATUS = 0xC0190032u32 as i32; pub const STATUS_ENLISTMENT_NOT_SUPERIOR: ::NTSTATUS = 0xC0190033u32 as i32; pub const STATUS_RECOVERY_NOT_NEEDED: ::NTSTATUS = 0x40190034; pub const STATUS_RM_ALREADY_STARTED: ::NTSTATUS = 0x40190035; pub const STATUS_FILE_IDENTITY_NOT_PERSISTENT: ::NTSTATUS = 0xC0190036u32 as i32; pub const STATUS_CANT_BREAK_TRANSACTIONAL_DEPENDENCY: ::NTSTATUS = 0xC0190037u32 as i32; pub const STATUS_CANT_CROSS_RM_BOUNDARY: ::NTSTATUS = 0xC0190038u32 as i32; pub const STATUS_TXF_DIR_NOT_EMPTY: ::NTSTATUS = 0xC0190039u32 as i32; pub const STATUS_INDOUBT_TRANSACTIONS_EXIST: ::NTSTATUS = 0xC019003Au32 as i32; pub const STATUS_TM_VOLATILE: ::NTSTATUS = 0xC019003Bu32 as i32; pub const STATUS_ROLLBACK_TIMER_EXPIRED: ::NTSTATUS = 0xC019003Cu32 as i32; pub const STATUS_TXF_ATTRIBUTE_CORRUPT: ::NTSTATUS = 0xC019003Du32 as i32; pub const STATUS_EFS_NOT_ALLOWED_IN_TRANSACTION: ::NTSTATUS = 0xC019003Eu32 as i32; pub const STATUS_TRANSACTIONAL_OPEN_NOT_ALLOWED: ::NTSTATUS = 0xC019003Fu32 as i32; pub const STATUS_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE: ::NTSTATUS = 0xC0190040u32 as i32; pub const STATUS_TXF_METADATA_ALREADY_PRESENT: ::NTSTATUS = 0x80190041u32 as i32; pub const STATUS_TRANSACTION_SCOPE_CALLBACKS_NOT_SET: ::NTSTATUS = 0x80190042u32 as i32; pub const STATUS_TRANSACTION_REQUIRED_PROMOTION: ::NTSTATUS = 0xC0190043u32 as i32; pub const STATUS_CANNOT_EXECUTE_FILE_IN_TRANSACTION: ::NTSTATUS = 0xC0190044u32 as i32; pub const STATUS_TRANSACTIONS_NOT_FROZEN: ::NTSTATUS = 0xC0190045u32 as i32; pub const STATUS_TRANSACTION_FREEZE_IN_PROGRESS: ::NTSTATUS = 0xC0190046u32 as i32; pub const STATUS_NOT_SNAPSHOT_VOLUME: ::NTSTATUS = 0xC0190047u32 as i32; pub const STATUS_NO_SAVEPOINT_WITH_OPEN_FILES: ::NTSTATUS = 0xC0190048u32 as i32; pub const STATUS_SPARSE_NOT_ALLOWED_IN_TRANSACTION: ::NTSTATUS = 0xC0190049u32 as i32; pub const STATUS_TM_IDENTITY_MISMATCH: ::NTSTATUS = 0xC019004Au32 as i32; pub const STATUS_FLOATED_SECTION: ::NTSTATUS = 0xC019004Bu32 as i32; pub const STATUS_CANNOT_ACCEPT_TRANSACTED_WORK: ::NTSTATUS = 0xC019004Cu32 as i32; pub const STATUS_CANNOT_ABORT_TRANSACTIONS: ::NTSTATUS = 0xC019004Du32 as i32; pub const STATUS_TRANSACTION_NOT_FOUND: ::NTSTATUS = 0xC019004Eu32 as i32; pub const STATUS_RESOURCEMANAGER_NOT_FOUND: ::NTSTATUS = 0xC019004Fu32 as i32; pub const STATUS_ENLISTMENT_NOT_FOUND: ::NTSTATUS = 0xC0190050u32 as i32; pub const STATUS_TRANSACTIONMANAGER_NOT_FOUND: ::NTSTATUS = 0xC0190051u32 as i32; pub const STATUS_TRANSACTIONMANAGER_NOT_ONLINE: ::NTSTATUS = 0xC0190052u32 as i32; pub const STATUS_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION: ::NTSTATUS = 0xC0190053u32 as i32; pub const STATUS_TRANSACTION_NOT_ROOT: ::NTSTATUS = 0xC0190054u32 as i32; pub const STATUS_TRANSACTION_OBJECT_EXPIRED: ::NTSTATUS = 0xC0190055u32 as i32; pub const STATUS_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION: ::NTSTATUS = 0xC0190056u32 as i32; pub const STATUS_TRANSACTION_RESPONSE_NOT_ENLISTED: ::NTSTATUS = 0xC0190057u32 as i32; pub const STATUS_TRANSACTION_RECORD_TOO_LONG: ::NTSTATUS = 0xC0190058u32 as i32; pub const STATUS_NO_LINK_TRACKING_IN_TRANSACTION: ::NTSTATUS = 0xC0190059u32 as i32; pub const STATUS_OPERATION_NOT_SUPPORTED_IN_TRANSACTION: ::NTSTATUS = 0xC019005Au32 as i32; pub const STATUS_TRANSACTION_INTEGRITY_VIOLATED: ::NTSTATUS = 0xC019005Bu32 as i32; pub const STATUS_TRANSACTIONMANAGER_IDENTITY_MISMATCH: ::NTSTATUS = 0xC019005Cu32 as i32; pub const STATUS_RM_CANNOT_BE_FROZEN_FOR_SNAPSHOT: ::NTSTATUS = 0xC019005Du32 as i32; pub const STATUS_TRANSACTION_MUST_WRITETHROUGH: ::NTSTATUS = 0xC019005Eu32 as i32; pub const STATUS_TRANSACTION_NO_SUPERIOR: ::NTSTATUS = 0xC019005Fu32 as i32; pub const STATUS_EXPIRED_HANDLE: ::NTSTATUS = 0xC0190060u32 as i32; pub const STATUS_TRANSACTION_NOT_ENLISTED: ::NTSTATUS = 0xC0190061u32 as i32; pub const STATUS_LOG_SECTOR_INVALID: ::NTSTATUS = 0xC01A0001u32 as i32; pub const STATUS_LOG_SECTOR_PARITY_INVALID: ::NTSTATUS = 0xC01A0002u32 as i32; pub const STATUS_LOG_SECTOR_REMAPPED: ::NTSTATUS = 0xC01A0003u32 as i32; pub const STATUS_LOG_BLOCK_INCOMPLETE: ::NTSTATUS = 0xC01A0004u32 as i32; pub const STATUS_LOG_INVALID_RANGE: ::NTSTATUS = 0xC01A0005u32 as i32; pub const STATUS_LOG_BLOCKS_EXHAUSTED: ::NTSTATUS = 0xC01A0006u32 as i32; pub const STATUS_LOG_READ_CONTEXT_INVALID: ::NTSTATUS = 0xC01A0007u32 as i32; pub const STATUS_LOG_RESTART_INVALID: ::NTSTATUS = 0xC01A0008u32 as i32; pub const STATUS_LOG_BLOCK_VERSION: ::NTSTATUS = 0xC01A0009u32 as i32; pub const STATUS_LOG_BLOCK_INVALID: ::NTSTATUS = 0xC01A000Au32 as i32; pub const STATUS_LOG_READ_MODE_INVALID: ::NTSTATUS = 0xC01A000Bu32 as i32; pub const STATUS_LOG_NO_RESTART: ::NTSTATUS = 0x401A000C; pub const STATUS_LOG_METADATA_CORRUPT: ::NTSTATUS = 0xC01A000Du32 as i32; pub const STATUS_LOG_METADATA_INVALID: ::NTSTATUS = 0xC01A000Eu32 as i32; pub const STATUS_LOG_METADATA_INCONSISTENT: ::NTSTATUS = 0xC01A000Fu32 as i32; pub const STATUS_LOG_RESERVATION_INVALID: ::NTSTATUS = 0xC01A0010u32 as i32; pub const STATUS_LOG_CANT_DELETE: ::NTSTATUS = 0xC01A0011u32 as i32; pub const STATUS_LOG_CONTAINER_LIMIT_EXCEEDED: ::NTSTATUS = 0xC01A0012u32 as i32; pub const STATUS_LOG_START_OF_LOG: ::NTSTATUS = 0xC01A0013u32 as i32; pub const STATUS_LOG_POLICY_ALREADY_INSTALLED: ::NTSTATUS = 0xC01A0014u32 as i32; pub const STATUS_LOG_POLICY_NOT_INSTALLED: ::NTSTATUS = 0xC01A0015u32 as i32; pub const STATUS_LOG_POLICY_INVALID: ::NTSTATUS = 0xC01A0016u32 as i32; pub const STATUS_LOG_POLICY_CONFLICT: ::NTSTATUS = 0xC01A0017u32 as i32; pub const STATUS_LOG_PINNED_ARCHIVE_TAIL: ::NTSTATUS = 0xC01A0018u32 as i32; pub const STATUS_LOG_RECORD_NONEXISTENT: ::NTSTATUS = 0xC01A0019u32 as i32; pub const STATUS_LOG_RECORDS_RESERVED_INVALID: ::NTSTATUS = 0xC01A001Au32 as i32; pub const STATUS_LOG_SPACE_RESERVED_INVALID: ::NTSTATUS = 0xC01A001Bu32 as i32; pub const STATUS_LOG_TAIL_INVALID: ::NTSTATUS = 0xC01A001Cu32 as i32; pub const STATUS_LOG_FULL: ::NTSTATUS = 0xC01A001Du32 as i32; pub const STATUS_LOG_MULTIPLEXED: ::NTSTATUS = 0xC01A001Eu32 as i32; pub const STATUS_LOG_DEDICATED: ::NTSTATUS = 0xC01A001Fu32 as i32; pub const STATUS_LOG_ARCHIVE_NOT_IN_PROGRESS: ::NTSTATUS = 0xC01A0020u32 as i32; pub const STATUS_LOG_ARCHIVE_IN_PROGRESS: ::NTSTATUS = 0xC01A0021u32 as i32; pub const STATUS_LOG_EPHEMERAL: ::NTSTATUS = 0xC01A0022u32 as i32; pub const STATUS_LOG_NOT_ENOUGH_CONTAINERS: ::NTSTATUS = 0xC01A0023u32 as i32; pub const STATUS_LOG_CLIENT_ALREADY_REGISTERED: ::NTSTATUS = 0xC01A0024u32 as i32; pub const STATUS_LOG_CLIENT_NOT_REGISTERED: ::NTSTATUS = 0xC01A0025u32 as i32; pub const STATUS_LOG_FULL_HANDLER_IN_PROGRESS: ::NTSTATUS = 0xC01A0026u32 as i32; pub const STATUS_LOG_CONTAINER_READ_FAILED: ::NTSTATUS = 0xC01A0027u32 as i32; pub const STATUS_LOG_CONTAINER_WRITE_FAILED: ::NTSTATUS = 0xC01A0028u32 as i32; pub const STATUS_LOG_CONTAINER_OPEN_FAILED: ::NTSTATUS = 0xC01A0029u32 as i32; pub const STATUS_LOG_CONTAINER_STATE_INVALID: ::NTSTATUS = 0xC01A002Au32 as i32; pub const STATUS_LOG_STATE_INVALID: ::NTSTATUS = 0xC01A002Bu32 as i32; pub const STATUS_LOG_PINNED: ::NTSTATUS = 0xC01A002Cu32 as i32; pub const STATUS_LOG_METADATA_FLUSH_FAILED: ::NTSTATUS = 0xC01A002Du32 as i32; pub const STATUS_LOG_INCONSISTENT_SECURITY: ::NTSTATUS = 0xC01A002Eu32 as i32; pub const STATUS_LOG_APPENDED_FLUSH_FAILED: ::NTSTATUS = 0xC01A002Fu32 as i32; pub const STATUS_LOG_PINNED_RESERVATION: ::NTSTATUS = 0xC01A0030u32 as i32; pub const STATUS_VIDEO_HUNG_DISPLAY_DRIVER_THREAD: ::NTSTATUS = 0xC01B00EAu32 as i32; pub const STATUS_VIDEO_HUNG_DISPLAY_DRIVER_THREAD_RECOVERED: ::NTSTATUS = 0x801B00EBu32 as i32; pub const STATUS_VIDEO_DRIVER_DEBUG_REPORT_REQUEST: ::NTSTATUS = 0x401B00EC; pub const STATUS_MONITOR_NO_DESCRIPTOR: ::NTSTATUS = 0xC01D0001u32 as i32; pub const STATUS_MONITOR_UNKNOWN_DESCRIPTOR_FORMAT: ::NTSTATUS = 0xC01D0002u32 as i32; pub const STATUS_MONITOR_INVALID_DESCRIPTOR_CHECKSUM: ::NTSTATUS = 0xC01D0003u32 as i32; pub const STATUS_MONITOR_INVALID_STANDARD_TIMING_BLOCK: ::NTSTATUS = 0xC01D0004u32 as i32; pub const STATUS_MONITOR_WMI_DATABLOCK_REGISTRATION_FAILED: ::NTSTATUS = 0xC01D0005u32 as i32; pub const STATUS_MONITOR_INVALID_SERIAL_NUMBER_MONDSC_BLOCK: ::NTSTATUS = 0xC01D0006u32 as i32; pub const STATUS_MONITOR_INVALID_USER_FRIENDLY_MONDSC_BLOCK: ::NTSTATUS = 0xC01D0007u32 as i32; pub const STATUS_MONITOR_NO_MORE_DESCRIPTOR_DATA: ::NTSTATUS = 0xC01D0008u32 as i32; pub const STATUS_MONITOR_INVALID_DETAILED_TIMING_BLOCK: ::NTSTATUS = 0xC01D0009u32 as i32; pub const STATUS_MONITOR_INVALID_MANUFACTURE_DATE: ::NTSTATUS = 0xC01D000Au32 as i32; pub const STATUS_GRAPHICS_NOT_EXCLUSIVE_MODE_OWNER: ::NTSTATUS = 0xC01E0000u32 as i32; pub const STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER: ::NTSTATUS = 0xC01E0001u32 as i32; pub const STATUS_GRAPHICS_INVALID_DISPLAY_ADAPTER: ::NTSTATUS = 0xC01E0002u32 as i32; pub const STATUS_GRAPHICS_ADAPTER_WAS_RESET: ::NTSTATUS = 0xC01E0003u32 as i32; pub const STATUS_GRAPHICS_INVALID_DRIVER_MODEL: ::NTSTATUS = 0xC01E0004u32 as i32; pub const STATUS_GRAPHICS_PRESENT_MODE_CHANGED: ::NTSTATUS = 0xC01E0005u32 as i32; pub const STATUS_GRAPHICS_PRESENT_OCCLUDED: ::NTSTATUS = 0xC01E0006u32 as i32; pub const STATUS_GRAPHICS_PRESENT_DENIED: ::NTSTATUS = 0xC01E0007u32 as i32; pub const STATUS_GRAPHICS_CANNOTCOLORCONVERT: ::NTSTATUS = 0xC01E0008u32 as i32; pub const STATUS_GRAPHICS_DRIVER_MISMATCH: ::NTSTATUS = 0xC01E0009u32 as i32; pub const STATUS_GRAPHICS_PARTIAL_DATA_POPULATED: ::NTSTATUS = 0x401E000A; pub const STATUS_GRAPHICS_PRESENT_REDIRECTION_DISABLED: ::NTSTATUS = 0xC01E000Bu32 as i32; pub const STATUS_GRAPHICS_PRESENT_UNOCCLUDED: ::NTSTATUS = 0xC01E000Cu32 as i32; pub const STATUS_GRAPHICS_WINDOWDC_NOT_AVAILABLE: ::NTSTATUS = 0xC01E000Du32 as i32; pub const STATUS_GRAPHICS_WINDOWLESS_PRESENT_DISABLED: ::NTSTATUS = 0xC01E000Eu32 as i32; pub const STATUS_GRAPHICS_NO_VIDEO_MEMORY: ::NTSTATUS = 0xC01E0100u32 as i32; pub const STATUS_GRAPHICS_CANT_LOCK_MEMORY: ::NTSTATUS = 0xC01E0101u32 as i32; pub const STATUS_GRAPHICS_ALLOCATION_BUSY: ::NTSTATUS = 0xC01E0102u32 as i32; pub const STATUS_GRAPHICS_TOO_MANY_REFERENCES: ::NTSTATUS = 0xC01E0103u32 as i32; pub const STATUS_GRAPHICS_TRY_AGAIN_LATER: ::NTSTATUS = 0xC01E0104u32 as i32; pub const STATUS_GRAPHICS_TRY_AGAIN_NOW: ::NTSTATUS = 0xC01E0105u32 as i32; pub const STATUS_GRAPHICS_ALLOCATION_INVALID: ::NTSTATUS = 0xC01E0106u32 as i32; pub const STATUS_GRAPHICS_UNSWIZZLING_APERTURE_UNAVAILABLE: ::NTSTATUS = 0xC01E0107u32 as i32; pub const STATUS_GRAPHICS_UNSWIZZLING_APERTURE_UNSUPPORTED: ::NTSTATUS = 0xC01E0108u32 as i32; pub const STATUS_GRAPHICS_CANT_EVICT_PINNED_ALLOCATION: ::NTSTATUS = 0xC01E0109u32 as i32; pub const STATUS_GRAPHICS_INVALID_ALLOCATION_USAGE: ::NTSTATUS = 0xC01E0110u32 as i32; pub const STATUS_GRAPHICS_CANT_RENDER_LOCKED_ALLOCATION: ::NTSTATUS = 0xC01E0111u32 as i32; pub const STATUS_GRAPHICS_ALLOCATION_CLOSED: ::NTSTATUS = 0xC01E0112u32 as i32; pub const STATUS_GRAPHICS_INVALID_ALLOCATION_INSTANCE: ::NTSTATUS = 0xC01E0113u32 as i32; pub const STATUS_GRAPHICS_INVALID_ALLOCATION_HANDLE: ::NTSTATUS = 0xC01E0114u32 as i32; pub const STATUS_GRAPHICS_WRONG_ALLOCATION_DEVICE: ::NTSTATUS = 0xC01E0115u32 as i32; pub const STATUS_GRAPHICS_ALLOCATION_CONTENT_LOST: ::NTSTATUS = 0xC01E0116u32 as i32; pub const STATUS_GRAPHICS_GPU_EXCEPTION_ON_DEVICE: ::NTSTATUS = 0xC01E0200u32 as i32; pub const STATUS_GRAPHICS_SKIP_ALLOCATION_PREPARATION: ::NTSTATUS = 0x401E0201; pub const STATUS_GRAPHICS_INVALID_VIDPN_TOPOLOGY: ::NTSTATUS = 0xC01E0300u32 as i32; pub const STATUS_GRAPHICS_VIDPN_TOPOLOGY_NOT_SUPPORTED: ::NTSTATUS = 0xC01E0301u32 as i32; pub const STATUS_GRAPHICS_VIDPN_TOPOLOGY_CURRENTLY_NOT_SUPPORTED: ::NTSTATUS = 0xC01E0302u32 as i32; pub const STATUS_GRAPHICS_INVALID_VIDPN: ::NTSTATUS = 0xC01E0303u32 as i32; pub const STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE: ::NTSTATUS = 0xC01E0304u32 as i32; pub const STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET: ::NTSTATUS = 0xC01E0305u32 as i32; pub const STATUS_GRAPHICS_VIDPN_MODALITY_NOT_SUPPORTED: ::NTSTATUS = 0xC01E0306u32 as i32; pub const STATUS_GRAPHICS_MODE_NOT_PINNED: ::NTSTATUS = 0x401E0307; pub const STATUS_GRAPHICS_INVALID_VIDPN_SOURCEMODESET: ::NTSTATUS = 0xC01E0308u32 as i32; pub const STATUS_GRAPHICS_INVALID_VIDPN_TARGETMODESET: ::NTSTATUS = 0xC01E0309u32 as i32; pub const STATUS_GRAPHICS_INVALID_FREQUENCY: ::NTSTATUS = 0xC01E030Au32 as i32; pub const STATUS_GRAPHICS_INVALID_ACTIVE_REGION: ::NTSTATUS = 0xC01E030Bu32 as i32; pub const STATUS_GRAPHICS_INVALID_TOTAL_REGION: ::NTSTATUS = 0xC01E030Cu32 as i32; pub const STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE_MODE: ::NTSTATUS = 0xC01E0310u32 as i32; pub const STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET_MODE: ::NTSTATUS = 0xC01E0311u32 as i32; pub const STATUS_GRAPHICS_PINNED_MODE_MUST_REMAIN_IN_SET: ::NTSTATUS = 0xC01E0312u32 as i32; pub const STATUS_GRAPHICS_PATH_ALREADY_IN_TOPOLOGY: ::NTSTATUS = 0xC01E0313u32 as i32; pub const STATUS_GRAPHICS_MODE_ALREADY_IN_MODESET: ::NTSTATUS = 0xC01E0314u32 as i32; pub const STATUS_GRAPHICS_INVALID_VIDEOPRESENTSOURCESET: ::NTSTATUS = 0xC01E0315u32 as i32; pub const STATUS_GRAPHICS_INVALID_VIDEOPRESENTTARGETSET: ::NTSTATUS = 0xC01E0316u32 as i32; pub const STATUS_GRAPHICS_SOURCE_ALREADY_IN_SET: ::NTSTATUS = 0xC01E0317u32 as i32; pub const STATUS_GRAPHICS_TARGET_ALREADY_IN_SET: ::NTSTATUS = 0xC01E0318u32 as i32; pub const STATUS_GRAPHICS_INVALID_VIDPN_PRESENT_PATH: ::NTSTATUS = 0xC01E0319u32 as i32; pub const STATUS_GRAPHICS_NO_RECOMMENDED_VIDPN_TOPOLOGY: ::NTSTATUS = 0xC01E031Au32 as i32; pub const STATUS_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGESET: ::NTSTATUS = 0xC01E031Bu32 as i32; pub const STATUS_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE: ::NTSTATUS = 0xC01E031Cu32 as i32; pub const STATUS_GRAPHICS_FREQUENCYRANGE_NOT_IN_SET: ::NTSTATUS = 0xC01E031Du32 as i32; pub const STATUS_GRAPHICS_NO_PREFERRED_MODE: ::NTSTATUS = 0x401E031E; pub const STATUS_GRAPHICS_FREQUENCYRANGE_ALREADY_IN_SET: ::NTSTATUS = 0xC01E031Fu32 as i32; pub const STATUS_GRAPHICS_STALE_MODESET: ::NTSTATUS = 0xC01E0320u32 as i32; pub const STATUS_GRAPHICS_INVALID_MONITOR_SOURCEMODESET: ::NTSTATUS = 0xC01E0321u32 as i32; pub const STATUS_GRAPHICS_INVALID_MONITOR_SOURCE_MODE: ::NTSTATUS = 0xC01E0322u32 as i32; pub const STATUS_GRAPHICS_NO_RECOMMENDED_FUNCTIONAL_VIDPN: ::NTSTATUS = 0xC01E0323u32 as i32; pub const STATUS_GRAPHICS_MODE_ID_MUST_BE_UNIQUE: ::NTSTATUS = 0xC01E0324u32 as i32; pub const STATUS_GRAPHICS_EMPTY_ADAPTER_MONITOR_MODE_SUPPORT_INTERSECTION: ::NTSTATUS = 0xC01E0325u32 as i32; pub const STATUS_GRAPHICS_VIDEO_PRESENT_TARGETS_LESS_THAN_SOURCES: ::NTSTATUS = 0xC01E0326u32 as i32; pub const STATUS_GRAPHICS_PATH_NOT_IN_TOPOLOGY: ::NTSTATUS = 0xC01E0327u32 as i32; pub const STATUS_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_SOURCE: ::NTSTATUS = 0xC01E0328u32 as i32; pub const STATUS_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_TARGET: ::NTSTATUS = 0xC01E0329u32 as i32; pub const STATUS_GRAPHICS_INVALID_MONITORDESCRIPTORSET: ::NTSTATUS = 0xC01E032Au32 as i32; pub const STATUS_GRAPHICS_INVALID_MONITORDESCRIPTOR: ::NTSTATUS = 0xC01E032Bu32 as i32; pub const STATUS_GRAPHICS_MONITORDESCRIPTOR_NOT_IN_SET: ::NTSTATUS = 0xC01E032Cu32 as i32; pub const STATUS_GRAPHICS_MONITORDESCRIPTOR_ALREADY_IN_SET: ::NTSTATUS = 0xC01E032Du32 as i32; pub const STATUS_GRAPHICS_MONITORDESCRIPTOR_ID_MUST_BE_UNIQUE: ::NTSTATUS = 0xC01E032Eu32 as i32; pub const STATUS_GRAPHICS_INVALID_VIDPN_TARGET_SUBSET_TYPE: ::NTSTATUS = 0xC01E032Fu32 as i32; pub const STATUS_GRAPHICS_RESOURCES_NOT_RELATED: ::NTSTATUS = 0xC01E0330u32 as i32; pub const STATUS_GRAPHICS_SOURCE_ID_MUST_BE_UNIQUE: ::NTSTATUS = 0xC01E0331u32 as i32; pub const STATUS_GRAPHICS_TARGET_ID_MUST_BE_UNIQUE: ::NTSTATUS = 0xC01E0332u32 as i32; pub const STATUS_GRAPHICS_NO_AVAILABLE_VIDPN_TARGET: ::NTSTATUS = 0xC01E0333u32 as i32; pub const STATUS_GRAPHICS_MONITOR_COULD_NOT_BE_ASSOCIATED_WITH_ADAPTER: ::NTSTATUS = 0xC01E0334u32 as i32; pub const STATUS_GRAPHICS_NO_VIDPNMGR: ::NTSTATUS = 0xC01E0335u32 as i32; pub const STATUS_GRAPHICS_NO_ACTIVE_VIDPN: ::NTSTATUS = 0xC01E0336u32 as i32; pub const STATUS_GRAPHICS_STALE_VIDPN_TOPOLOGY: ::NTSTATUS = 0xC01E0337u32 as i32; pub const STATUS_GRAPHICS_MONITOR_NOT_CONNECTED: ::NTSTATUS = 0xC01E0338u32 as i32; pub const STATUS_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY: ::NTSTATUS = 0xC01E0339u32 as i32; pub const STATUS_GRAPHICS_INVALID_PRIMARYSURFACE_SIZE: ::NTSTATUS = 0xC01E033Au32 as i32; pub const STATUS_GRAPHICS_INVALID_VISIBLEREGION_SIZE: ::NTSTATUS = 0xC01E033Bu32 as i32; pub const STATUS_GRAPHICS_INVALID_STRIDE: ::NTSTATUS = 0xC01E033Cu32 as i32; pub const STATUS_GRAPHICS_INVALID_PIXELFORMAT: ::NTSTATUS = 0xC01E033Du32 as i32; pub const STATUS_GRAPHICS_INVALID_COLORBASIS: ::NTSTATUS = 0xC01E033Eu32 as i32; pub const STATUS_GRAPHICS_INVALID_PIXELVALUEACCESSMODE: ::NTSTATUS = 0xC01E033Fu32 as i32; pub const STATUS_GRAPHICS_TARGET_NOT_IN_TOPOLOGY: ::NTSTATUS = 0xC01E0340u32 as i32; pub const STATUS_GRAPHICS_NO_DISPLAY_MODE_MANAGEMENT_SUPPORT: ::NTSTATUS = 0xC01E0341u32 as i32; pub const STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE: ::NTSTATUS = 0xC01E0342u32 as i32; pub const STATUS_GRAPHICS_CANT_ACCESS_ACTIVE_VIDPN: ::NTSTATUS = 0xC01E0343u32 as i32; pub const STATUS_GRAPHICS_INVALID_PATH_IMPORTANCE_ORDINAL: ::NTSTATUS = 0xC01E0344u32 as i32; pub const STATUS_GRAPHICS_INVALID_PATH_CONTENT_GEOMETRY_TRANSFORMATION: ::NTSTATUS = 0xC01E0345u32 as i32; pub const STATUS_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_SUPPORTED: ::NTSTATUS = 0xC01E0346u32 as i32; pub const STATUS_GRAPHICS_INVALID_GAMMA_RAMP: ::NTSTATUS = 0xC01E0347u32 as i32; pub const STATUS_GRAPHICS_GAMMA_RAMP_NOT_SUPPORTED: ::NTSTATUS = 0xC01E0348u32 as i32; pub const STATUS_GRAPHICS_MULTISAMPLING_NOT_SUPPORTED: ::NTSTATUS = 0xC01E0349u32 as i32; pub const STATUS_GRAPHICS_MODE_NOT_IN_MODESET: ::NTSTATUS = 0xC01E034Au32 as i32; pub const STATUS_GRAPHICS_DATASET_IS_EMPTY: ::NTSTATUS = 0x401E034B; pub const STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET: ::NTSTATUS = 0x401E034C; pub const STATUS_GRAPHICS_INVALID_VIDPN_TOPOLOGY_RECOMMENDATION_REASON: ::NTSTATUS = 0xC01E034Du32 as i32; pub const STATUS_GRAPHICS_INVALID_PATH_CONTENT_TYPE: ::NTSTATUS = 0xC01E034Eu32 as i32; pub const STATUS_GRAPHICS_INVALID_COPYPROTECTION_TYPE: ::NTSTATUS = 0xC01E034Fu32 as i32; pub const STATUS_GRAPHICS_UNASSIGNED_MODESET_ALREADY_EXISTS: ::NTSTATUS = 0xC01E0350u32 as i32; pub const STATUS_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_PINNED: ::NTSTATUS = 0x401E0351; pub const STATUS_GRAPHICS_INVALID_SCANLINE_ORDERING: ::NTSTATUS = 0xC01E0352u32 as i32; pub const STATUS_GRAPHICS_TOPOLOGY_CHANGES_NOT_ALLOWED: ::NTSTATUS = 0xC01E0353u32 as i32; pub const STATUS_GRAPHICS_NO_AVAILABLE_IMPORTANCE_ORDINALS: ::NTSTATUS = 0xC01E0354u32 as i32; pub const STATUS_GRAPHICS_INCOMPATIBLE_PRIVATE_FORMAT: ::NTSTATUS = 0xC01E0355u32 as i32; pub const STATUS_GRAPHICS_INVALID_MODE_PRUNING_ALGORITHM: ::NTSTATUS = 0xC01E0356u32 as i32; pub const STATUS_GRAPHICS_INVALID_MONITOR_CAPABILITY_ORIGIN: ::NTSTATUS = 0xC01E0357u32 as i32; pub const STATUS_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE_CONSTRAINT: ::NTSTATUS = 0xC01E0358u32 as i32; pub const STATUS_GRAPHICS_MAX_NUM_PATHS_REACHED: ::NTSTATUS = 0xC01E0359u32 as i32; pub const STATUS_GRAPHICS_CANCEL_VIDPN_TOPOLOGY_AUGMENTATION: ::NTSTATUS = 0xC01E035Au32 as i32; pub const STATUS_GRAPHICS_INVALID_CLIENT_TYPE: ::NTSTATUS = 0xC01E035Bu32 as i32; pub const STATUS_GRAPHICS_CLIENTVIDPN_NOT_SET: ::NTSTATUS = 0xC01E035Cu32 as i32; pub const STATUS_GRAPHICS_SPECIFIED_CHILD_ALREADY_CONNECTED: ::NTSTATUS = 0xC01E0400u32 as i32; pub const STATUS_GRAPHICS_CHILD_DESCRIPTOR_NOT_SUPPORTED: ::NTSTATUS = 0xC01E0401u32 as i32; pub const STATUS_GRAPHICS_UNKNOWN_CHILD_STATUS: ::NTSTATUS = 0x401E042F; pub const STATUS_GRAPHICS_NOT_A_LINKED_ADAPTER: ::NTSTATUS = 0xC01E0430u32 as i32; pub const STATUS_GRAPHICS_LEADLINK_NOT_ENUMERATED: ::NTSTATUS = 0xC01E0431u32 as i32; pub const STATUS_GRAPHICS_CHAINLINKS_NOT_ENUMERATED: ::NTSTATUS = 0xC01E0432u32 as i32; pub const STATUS_GRAPHICS_ADAPTER_CHAIN_NOT_READY: ::NTSTATUS = 0xC01E0433u32 as i32; pub const STATUS_GRAPHICS_CHAINLINKS_NOT_STARTED: ::NTSTATUS = 0xC01E0434u32 as i32; pub const STATUS_GRAPHICS_CHAINLINKS_NOT_POWERED_ON: ::NTSTATUS = 0xC01E0435u32 as i32; pub const STATUS_GRAPHICS_INCONSISTENT_DEVICE_LINK_STATE: ::NTSTATUS = 0xC01E0436u32 as i32; pub const STATUS_GRAPHICS_LEADLINK_START_DEFERRED: ::NTSTATUS = 0x401E0437; pub const STATUS_GRAPHICS_NOT_POST_DEVICE_DRIVER: ::NTSTATUS = 0xC01E0438u32 as i32; pub const STATUS_GRAPHICS_POLLING_TOO_FREQUENTLY: ::NTSTATUS = 0x401E0439; pub const STATUS_GRAPHICS_START_DEFERRED: ::NTSTATUS = 0x401E043A; pub const STATUS_GRAPHICS_ADAPTER_ACCESS_NOT_EXCLUDED: ::NTSTATUS = 0xC01E043Bu32 as i32; pub const STATUS_GRAPHICS_DEPENDABLE_CHILD_STATUS: ::NTSTATUS = 0x401E043C; pub const STATUS_GRAPHICS_OPM_NOT_SUPPORTED: ::NTSTATUS = 0xC01E0500u32 as i32; pub const STATUS_GRAPHICS_COPP_NOT_SUPPORTED: ::NTSTATUS = 0xC01E0501u32 as i32; pub const STATUS_GRAPHICS_UAB_NOT_SUPPORTED: ::NTSTATUS = 0xC01E0502u32 as i32; pub const STATUS_GRAPHICS_OPM_INVALID_ENCRYPTED_PARAMETERS: ::NTSTATUS = 0xC01E0503u32 as i32; pub const STATUS_GRAPHICS_OPM_NO_PROTECTED_OUTPUTS_EXIST: ::NTSTATUS = 0xC01E0505u32 as i32; pub const STATUS_GRAPHICS_OPM_INTERNAL_ERROR: ::NTSTATUS = 0xC01E050Bu32 as i32; pub const STATUS_GRAPHICS_OPM_INVALID_HANDLE: ::NTSTATUS = 0xC01E050Cu32 as i32; pub const STATUS_GRAPHICS_PVP_INVALID_CERTIFICATE_LENGTH: ::NTSTATUS = 0xC01E050Eu32 as i32; pub const STATUS_GRAPHICS_OPM_SPANNING_MODE_ENABLED: ::NTSTATUS = 0xC01E050Fu32 as i32; pub const STATUS_GRAPHICS_OPM_THEATER_MODE_ENABLED: ::NTSTATUS = 0xC01E0510u32 as i32; pub const STATUS_GRAPHICS_PVP_HFS_FAILED: ::NTSTATUS = 0xC01E0511u32 as i32; pub const STATUS_GRAPHICS_OPM_INVALID_SRM: ::NTSTATUS = 0xC01E0512u32 as i32; pub const STATUS_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_HDCP: ::NTSTATUS = 0xC01E0513u32 as i32; pub const STATUS_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_ACP: ::NTSTATUS = 0xC01E0514u32 as i32; pub const STATUS_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_CGMSA: ::NTSTATUS = 0xC01E0515u32 as i32; pub const STATUS_GRAPHICS_OPM_HDCP_SRM_NEVER_SET: ::NTSTATUS = 0xC01E0516u32 as i32; pub const STATUS_GRAPHICS_OPM_RESOLUTION_TOO_HIGH: ::NTSTATUS = 0xC01E0517u32 as i32; pub const STATUS_GRAPHICS_OPM_ALL_HDCP_HARDWARE_ALREADY_IN_USE: ::NTSTATUS = 0xC01E0518u32 as i32; pub const STATUS_GRAPHICS_OPM_PROTECTED_OUTPUT_NO_LONGER_EXISTS: ::NTSTATUS = 0xC01E051Au32 as i32; pub const STATUS_GRAPHICS_OPM_PROTECTED_OUTPUT_DOES_NOT_HAVE_COPP_SEMANTICS: ::NTSTATUS = 0xC01E051Cu32 as i32; pub const STATUS_GRAPHICS_OPM_INVALID_INFORMATION_REQUEST: ::NTSTATUS = 0xC01E051Du32 as i32; pub const STATUS_GRAPHICS_OPM_DRIVER_INTERNAL_ERROR: ::NTSTATUS = 0xC01E051Eu32 as i32; pub const STATUS_GRAPHICS_OPM_PROTECTED_OUTPUT_DOES_NOT_HAVE_OPM_SEMANTICS: ::NTSTATUS = 0xC01E051Fu32 as i32; pub const STATUS_GRAPHICS_OPM_SIGNALING_NOT_SUPPORTED: ::NTSTATUS = 0xC01E0520u32 as i32; pub const STATUS_GRAPHICS_OPM_INVALID_CONFIGURATION_REQUEST: ::NTSTATUS = 0xC01E0521u32 as i32; pub const STATUS_GRAPHICS_I2C_NOT_SUPPORTED: ::NTSTATUS = 0xC01E0580u32 as i32; pub const STATUS_GRAPHICS_I2C_DEVICE_DOES_NOT_EXIST: ::NTSTATUS = 0xC01E0581u32 as i32; pub const STATUS_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA: ::NTSTATUS = 0xC01E0582u32 as i32; pub const STATUS_GRAPHICS_I2C_ERROR_RECEIVING_DATA: ::NTSTATUS = 0xC01E0583u32 as i32; pub const STATUS_GRAPHICS_DDCCI_VCP_NOT_SUPPORTED: ::NTSTATUS = 0xC01E0584u32 as i32; pub const STATUS_GRAPHICS_DDCCI_INVALID_DATA: ::NTSTATUS = 0xC01E0585u32 as i32; pub const STATUS_GRAPHICS_DDCCI_MONITOR_RETURNED_INVALID_TIMING_STATUS_BYTE: ::NTSTATUS = 0xC01E0586u32 as i32; pub const STATUS_GRAPHICS_DDCCI_INVALID_CAPABILITIES_STRING: ::NTSTATUS = 0xC01E0587u32 as i32; pub const STATUS_GRAPHICS_MCA_INTERNAL_ERROR: ::NTSTATUS = 0xC01E0588u32 as i32; pub const STATUS_GRAPHICS_DDCCI_INVALID_MESSAGE_COMMAND: ::NTSTATUS = 0xC01E0589u32 as i32; pub const STATUS_GRAPHICS_DDCCI_INVALID_MESSAGE_LENGTH: ::NTSTATUS = 0xC01E058Au32 as i32; pub const STATUS_GRAPHICS_DDCCI_INVALID_MESSAGE_CHECKSUM: ::NTSTATUS = 0xC01E058Bu32 as i32; pub const STATUS_GRAPHICS_INVALID_PHYSICAL_MONITOR_HANDLE: ::NTSTATUS = 0xC01E058Cu32 as i32; pub const STATUS_GRAPHICS_MONITOR_NO_LONGER_EXISTS: ::NTSTATUS = 0xC01E058Du32 as i32; pub const STATUS_GRAPHICS_ONLY_CONSOLE_SESSION_SUPPORTED: ::NTSTATUS = 0xC01E05E0u32 as i32; pub const STATUS_GRAPHICS_NO_DISPLAY_DEVICE_CORRESPONDS_TO_NAME: ::NTSTATUS = 0xC01E05E1u32 as i32; pub const STATUS_GRAPHICS_DISPLAY_DEVICE_NOT_ATTACHED_TO_DESKTOP: ::NTSTATUS = 0xC01E05E2u32 as i32; pub const STATUS_GRAPHICS_MIRRORING_DEVICES_NOT_SUPPORTED: ::NTSTATUS = 0xC01E05E3u32 as i32; pub const STATUS_GRAPHICS_INVALID_POINTER: ::NTSTATUS = 0xC01E05E4u32 as i32; pub const STATUS_GRAPHICS_NO_MONITORS_CORRESPOND_TO_DISPLAY_DEVICE: ::NTSTATUS = 0xC01E05E5u32 as i32; pub const STATUS_GRAPHICS_PARAMETER_ARRAY_TOO_SMALL: ::NTSTATUS = 0xC01E05E6u32 as i32; pub const STATUS_GRAPHICS_INTERNAL_ERROR: ::NTSTATUS = 0xC01E05E7u32 as i32; pub const STATUS_GRAPHICS_SESSION_TYPE_CHANGE_IN_PROGRESS: ::NTSTATUS = 0xC01E05E8u32 as i32; pub const STATUS_FVE_LOCKED_VOLUME: ::NTSTATUS = 0xC0210000u32 as i32; pub const STATUS_FVE_NOT_ENCRYPTED: ::NTSTATUS = 0xC0210001u32 as i32; pub const STATUS_FVE_BAD_INFORMATION: ::NTSTATUS = 0xC0210002u32 as i32; pub const STATUS_FVE_TOO_SMALL: ::NTSTATUS = 0xC0210003u32 as i32; pub const STATUS_FVE_FAILED_WRONG_FS: ::NTSTATUS = 0xC0210004u32 as i32; pub const STATUS_FVE_BAD_PARTITION_SIZE: ::NTSTATUS = 0xC0210005u32 as i32; pub const STATUS_FVE_FS_NOT_EXTENDED: ::NTSTATUS = 0xC0210006u32 as i32; pub const STATUS_FVE_FS_MOUNTED: ::NTSTATUS = 0xC0210007u32 as i32; pub const STATUS_FVE_NO_LICENSE: ::NTSTATUS = 0xC0210008u32 as i32; pub const STATUS_FVE_ACTION_NOT_ALLOWED: ::NTSTATUS = 0xC0210009u32 as i32; pub const STATUS_FVE_BAD_DATA: ::NTSTATUS = 0xC021000Au32 as i32; pub const STATUS_FVE_VOLUME_NOT_BOUND: ::NTSTATUS = 0xC021000Bu32 as i32; pub const STATUS_FVE_NOT_DATA_VOLUME: ::NTSTATUS = 0xC021000Cu32 as i32; pub const STATUS_FVE_CONV_READ_ERROR: ::NTSTATUS = 0xC021000Du32 as i32; pub const STATUS_FVE_CONV_WRITE_ERROR: ::NTSTATUS = 0xC021000Eu32 as i32; pub const STATUS_FVE_OVERLAPPED_UPDATE: ::NTSTATUS = 0xC021000Fu32 as i32; pub const STATUS_FVE_FAILED_SECTOR_SIZE: ::NTSTATUS = 0xC0210010u32 as i32; pub const STATUS_FVE_FAILED_AUTHENTICATION: ::NTSTATUS = 0xC0210011u32 as i32; pub const STATUS_FVE_NOT_OS_VOLUME: ::NTSTATUS = 0xC0210012u32 as i32; pub const STATUS_FVE_KEYFILE_NOT_FOUND: ::NTSTATUS = 0xC0210013u32 as i32; pub const STATUS_FVE_KEYFILE_INVALID: ::NTSTATUS = 0xC0210014u32 as i32; pub const STATUS_FVE_KEYFILE_NO_VMK: ::NTSTATUS = 0xC0210015u32 as i32; pub const STATUS_FVE_TPM_DISABLED: ::NTSTATUS = 0xC0210016u32 as i32; pub const STATUS_FVE_TPM_SRK_AUTH_NOT_ZERO: ::NTSTATUS = 0xC0210017u32 as i32; pub const STATUS_FVE_TPM_INVALID_PCR: ::NTSTATUS = 0xC0210018u32 as i32; pub const STATUS_FVE_TPM_NO_VMK: ::NTSTATUS = 0xC0210019u32 as i32; pub const STATUS_FVE_PIN_INVALID: ::NTSTATUS = 0xC021001Au32 as i32; pub const STATUS_FVE_AUTH_INVALID_APPLICATION: ::NTSTATUS = 0xC021001Bu32 as i32; pub const STATUS_FVE_AUTH_INVALID_CONFIG: ::NTSTATUS = 0xC021001Cu32 as i32; pub const STATUS_FVE_DEBUGGER_ENABLED: ::NTSTATUS = 0xC021001Du32 as i32; pub const STATUS_FVE_DRY_RUN_FAILED: ::NTSTATUS = 0xC021001Eu32 as i32; pub const STATUS_FVE_BAD_METADATA_POINTER: ::NTSTATUS = 0xC021001Fu32 as i32; pub const STATUS_FVE_OLD_METADATA_COPY: ::NTSTATUS = 0xC0210020u32 as i32; pub const STATUS_FVE_REBOOT_REQUIRED: ::NTSTATUS = 0xC0210021u32 as i32; pub const STATUS_FVE_RAW_ACCESS: ::NTSTATUS = 0xC0210022u32 as i32; pub const STATUS_FVE_RAW_BLOCKED: ::NTSTATUS = 0xC0210023u32 as i32; pub const STATUS_FVE_NO_AUTOUNLOCK_MASTER_KEY: ::NTSTATUS = 0xC0210024u32 as i32; pub const STATUS_FVE_MOR_FAILED: ::NTSTATUS = 0xC0210025u32 as i32; pub const STATUS_FVE_NO_FEATURE_LICENSE: ::NTSTATUS = 0xC0210026u32 as i32; pub const STATUS_FVE_POLICY_USER_DISABLE_RDV_NOT_ALLOWED: ::NTSTATUS = 0xC0210027u32 as i32; pub const STATUS_FVE_CONV_RECOVERY_FAILED: ::NTSTATUS = 0xC0210028u32 as i32; pub const STATUS_FVE_VIRTUALIZED_SPACE_TOO_BIG: ::NTSTATUS = 0xC0210029u32 as i32; pub const STATUS_FVE_INVALID_DATUM_TYPE: ::NTSTATUS = 0xC021002Au32 as i32; pub const STATUS_FVE_VOLUME_TOO_SMALL: ::NTSTATUS = 0xC0210030u32 as i32; pub const STATUS_FVE_ENH_PIN_INVALID: ::NTSTATUS = 0xC0210031u32 as i32; pub const STATUS_FVE_FULL_ENCRYPTION_NOT_ALLOWED_ON_TP_STORAGE: ::NTSTATUS = 0xC0210032u32 as i32; pub const STATUS_FVE_WIPE_NOT_ALLOWED_ON_TP_STORAGE: ::NTSTATUS = 0xC0210033u32 as i32; pub const STATUS_FVE_NOT_ALLOWED_ON_CSV_STACK: ::NTSTATUS = 0xC0210034u32 as i32; pub const STATUS_FVE_NOT_ALLOWED_ON_CLUSTER: ::NTSTATUS = 0xC0210035u32 as i32; pub const STATUS_FVE_NOT_ALLOWED_TO_UPGRADE_WHILE_CONVERTING: ::NTSTATUS = 0xC0210036u32 as i32; pub const STATUS_FVE_WIPE_CANCEL_NOT_APPLICABLE: ::NTSTATUS = 0xC0210037u32 as i32; pub const STATUS_FVE_EDRIVE_DRY_RUN_FAILED: ::NTSTATUS = 0xC0210038u32 as i32; pub const STATUS_FVE_SECUREBOOT_DISABLED: ::NTSTATUS = 0xC0210039u32 as i32; pub const STATUS_FVE_SECUREBOOT_CONFIG_CHANGE: ::NTSTATUS = 0xC021003Au32 as i32; pub const STATUS_FVE_DEVICE_LOCKEDOUT: ::NTSTATUS = 0xC021003Bu32 as i32; pub const STATUS_FVE_VOLUME_EXTEND_PREVENTS_EOW_DECRYPT: ::NTSTATUS = 0xC021003Cu32 as i32; pub const STATUS_FVE_NOT_DE_VOLUME: ::NTSTATUS = 0xC021003Du32 as i32; pub const STATUS_FVE_PROTECTION_DISABLED: ::NTSTATUS = 0xC021003Eu32 as i32; pub const STATUS_FVE_PROTECTION_CANNOT_BE_DISABLED: ::NTSTATUS = 0xC021003Fu32 as i32; pub const STATUS_FWP_CALLOUT_NOT_FOUND: ::NTSTATUS = 0xC0220001u32 as i32; pub const STATUS_FWP_CONDITION_NOT_FOUND: ::NTSTATUS = 0xC0220002u32 as i32; pub const STATUS_FWP_FILTER_NOT_FOUND: ::NTSTATUS = 0xC0220003u32 as i32; pub const STATUS_FWP_LAYER_NOT_FOUND: ::NTSTATUS = 0xC0220004u32 as i32; pub const STATUS_FWP_PROVIDER_NOT_FOUND: ::NTSTATUS = 0xC0220005u32 as i32; pub const STATUS_FWP_PROVIDER_CONTEXT_NOT_FOUND: ::NTSTATUS = 0xC0220006u32 as i32; pub const STATUS_FWP_SUBLAYER_NOT_FOUND: ::NTSTATUS = 0xC0220007u32 as i32; pub const STATUS_FWP_NOT_FOUND: ::NTSTATUS = 0xC0220008u32 as i32; pub const STATUS_FWP_ALREADY_EXISTS: ::NTSTATUS = 0xC0220009u32 as i32; pub const STATUS_FWP_IN_USE: ::NTSTATUS = 0xC022000Au32 as i32; pub const STATUS_FWP_DYNAMIC_SESSION_IN_PROGRESS: ::NTSTATUS = 0xC022000Bu32 as i32; pub const STATUS_FWP_WRONG_SESSION: ::NTSTATUS = 0xC022000Cu32 as i32; pub const STATUS_FWP_NO_TXN_IN_PROGRESS: ::NTSTATUS = 0xC022000Du32 as i32; pub const STATUS_FWP_TXN_IN_PROGRESS: ::NTSTATUS = 0xC022000Eu32 as i32; pub const STATUS_FWP_TXN_ABORTED: ::NTSTATUS = 0xC022000Fu32 as i32; pub const STATUS_FWP_SESSION_ABORTED: ::NTSTATUS = 0xC0220010u32 as i32; pub const STATUS_FWP_INCOMPATIBLE_TXN: ::NTSTATUS = 0xC0220011u32 as i32; pub const STATUS_FWP_TIMEOUT: ::NTSTATUS = 0xC0220012u32 as i32; pub const STATUS_FWP_NET_EVENTS_DISABLED: ::NTSTATUS = 0xC0220013u32 as i32; pub const STATUS_FWP_INCOMPATIBLE_LAYER: ::NTSTATUS = 0xC0220014u32 as i32; pub const STATUS_FWP_KM_CLIENTS_ONLY: ::NTSTATUS = 0xC0220015u32 as i32; pub const STATUS_FWP_LIFETIME_MISMATCH: ::NTSTATUS = 0xC0220016u32 as i32; pub const STATUS_FWP_BUILTIN_OBJECT: ::NTSTATUS = 0xC0220017u32 as i32; pub const STATUS_FWP_TOO_MANY_CALLOUTS: ::NTSTATUS = 0xC0220018u32 as i32; pub const STATUS_FWP_NOTIFICATION_DROPPED: ::NTSTATUS = 0xC0220019u32 as i32; pub const STATUS_FWP_TRAFFIC_MISMATCH: ::NTSTATUS = 0xC022001Au32 as i32; pub const STATUS_FWP_INCOMPATIBLE_SA_STATE: ::NTSTATUS = 0xC022001Bu32 as i32; pub const STATUS_FWP_NULL_POINTER: ::NTSTATUS = 0xC022001Cu32 as i32; pub const STATUS_FWP_INVALID_ENUMERATOR: ::NTSTATUS = 0xC022001Du32 as i32; pub const STATUS_FWP_INVALID_FLAGS: ::NTSTATUS = 0xC022001Eu32 as i32; pub const STATUS_FWP_INVALID_NET_MASK: ::NTSTATUS = 0xC022001Fu32 as i32; pub const STATUS_FWP_INVALID_RANGE: ::NTSTATUS = 0xC0220020u32 as i32; pub const STATUS_FWP_INVALID_INTERVAL: ::NTSTATUS = 0xC0220021u32 as i32; pub const STATUS_FWP_ZERO_LENGTH_ARRAY: ::NTSTATUS = 0xC0220022u32 as i32; pub const STATUS_FWP_NULL_DISPLAY_NAME: ::NTSTATUS = 0xC0220023u32 as i32; pub const STATUS_FWP_INVALID_ACTION_TYPE: ::NTSTATUS = 0xC0220024u32 as i32; pub const STATUS_FWP_INVALID_WEIGHT: ::NTSTATUS = 0xC0220025u32 as i32; pub const STATUS_FWP_MATCH_TYPE_MISMATCH: ::NTSTATUS = 0xC0220026u32 as i32; pub const STATUS_FWP_TYPE_MISMATCH: ::NTSTATUS = 0xC0220027u32 as i32; pub const STATUS_FWP_OUT_OF_BOUNDS: ::NTSTATUS = 0xC0220028u32 as i32; pub const STATUS_FWP_RESERVED: ::NTSTATUS = 0xC0220029u32 as i32; pub const STATUS_FWP_DUPLICATE_CONDITION: ::NTSTATUS = 0xC022002Au32 as i32; pub const STATUS_FWP_DUPLICATE_KEYMOD: ::NTSTATUS = 0xC022002Bu32 as i32; pub const STATUS_FWP_ACTION_INCOMPATIBLE_WITH_LAYER: ::NTSTATUS = 0xC022002Cu32 as i32; pub const STATUS_FWP_ACTION_INCOMPATIBLE_WITH_SUBLAYER: ::NTSTATUS = 0xC022002Du32 as i32; pub const STATUS_FWP_CONTEXT_INCOMPATIBLE_WITH_LAYER: ::NTSTATUS = 0xC022002Eu32 as i32; pub const STATUS_FWP_CONTEXT_INCOMPATIBLE_WITH_CALLOUT: ::NTSTATUS = 0xC022002Fu32 as i32; pub const STATUS_FWP_INCOMPATIBLE_AUTH_METHOD: ::NTSTATUS = 0xC0220030u32 as i32; pub const STATUS_FWP_INCOMPATIBLE_DH_GROUP: ::NTSTATUS = 0xC0220031u32 as i32; pub const STATUS_FWP_EM_NOT_SUPPORTED: ::NTSTATUS = 0xC0220032u32 as i32; pub const STATUS_FWP_NEVER_MATCH: ::NTSTATUS = 0xC0220033u32 as i32; pub const STATUS_FWP_PROVIDER_CONTEXT_MISMATCH: ::NTSTATUS = 0xC0220034u32 as i32; pub const STATUS_FWP_INVALID_PARAMETER: ::NTSTATUS = 0xC0220035u32 as i32; pub const STATUS_FWP_TOO_MANY_SUBLAYERS: ::NTSTATUS = 0xC0220036u32 as i32; pub const STATUS_FWP_CALLOUT_NOTIFICATION_FAILED: ::NTSTATUS = 0xC0220037u32 as i32; pub const STATUS_FWP_INVALID_AUTH_TRANSFORM: ::NTSTATUS = 0xC0220038u32 as i32; pub const STATUS_FWP_INVALID_CIPHER_TRANSFORM: ::NTSTATUS = 0xC0220039u32 as i32; pub const STATUS_FWP_INCOMPATIBLE_CIPHER_TRANSFORM: ::NTSTATUS = 0xC022003Au32 as i32; pub const STATUS_FWP_INVALID_TRANSFORM_COMBINATION: ::NTSTATUS = 0xC022003Bu32 as i32; pub const STATUS_FWP_DUPLICATE_AUTH_METHOD: ::NTSTATUS = 0xC022003Cu32 as i32; pub const STATUS_FWP_INVALID_TUNNEL_ENDPOINT: ::NTSTATUS = 0xC022003Du32 as i32; pub const STATUS_FWP_L2_DRIVER_NOT_READY: ::NTSTATUS = 0xC022003Eu32 as i32; pub const STATUS_FWP_KEY_DICTATOR_ALREADY_REGISTERED: ::NTSTATUS = 0xC022003Fu32 as i32; pub const STATUS_FWP_KEY_DICTATION_INVALID_KEYING_MATERIAL: ::NTSTATUS = 0xC0220040u32 as i32; pub const STATUS_FWP_CONNECTIONS_DISABLED: ::NTSTATUS = 0xC0220041u32 as i32; pub const STATUS_FWP_INVALID_DNS_NAME: ::NTSTATUS = 0xC0220042u32 as i32; pub const STATUS_FWP_STILL_ON: ::NTSTATUS = 0xC0220043u32 as i32; pub const STATUS_FWP_IKEEXT_NOT_RUNNING: ::NTSTATUS = 0xC0220044u32 as i32; pub const STATUS_FWP_TCPIP_NOT_READY: ::NTSTATUS = 0xC0220100u32 as i32; pub const STATUS_FWP_INJECT_HANDLE_CLOSING: ::NTSTATUS = 0xC0220101u32 as i32; pub const STATUS_FWP_INJECT_HANDLE_STALE: ::NTSTATUS = 0xC0220102u32 as i32; pub const STATUS_FWP_CANNOT_PEND: ::NTSTATUS = 0xC0220103u32 as i32; pub const STATUS_FWP_DROP_NOICMP: ::NTSTATUS = 0xC0220104u32 as i32; pub const STATUS_NDIS_CLOSING: ::NTSTATUS = 0xC0230002u32 as i32; pub const STATUS_NDIS_BAD_VERSION: ::NTSTATUS = 0xC0230004u32 as i32; pub const STATUS_NDIS_BAD_CHARACTERISTICS: ::NTSTATUS = 0xC0230005u32 as i32; pub const STATUS_NDIS_ADAPTER_NOT_FOUND: ::NTSTATUS = 0xC0230006u32 as i32; pub const STATUS_NDIS_OPEN_FAILED: ::NTSTATUS = 0xC0230007u32 as i32; pub const STATUS_NDIS_DEVICE_FAILED: ::NTSTATUS = 0xC0230008u32 as i32; pub const STATUS_NDIS_MULTICAST_FULL: ::NTSTATUS = 0xC0230009u32 as i32; pub const STATUS_NDIS_MULTICAST_EXISTS: ::NTSTATUS = 0xC023000Au32 as i32; pub const STATUS_NDIS_MULTICAST_NOT_FOUND: ::NTSTATUS = 0xC023000Bu32 as i32; pub const STATUS_NDIS_REQUEST_ABORTED: ::NTSTATUS = 0xC023000Cu32 as i32; pub const STATUS_NDIS_RESET_IN_PROGRESS: ::NTSTATUS = 0xC023000Du32 as i32; pub const STATUS_NDIS_NOT_SUPPORTED: ::NTSTATUS = 0xC02300BBu32 as i32; pub const STATUS_NDIS_INVALID_PACKET: ::NTSTATUS = 0xC023000Fu32 as i32; pub const STATUS_NDIS_ADAPTER_NOT_READY: ::NTSTATUS = 0xC0230011u32 as i32; pub const STATUS_NDIS_INVALID_LENGTH: ::NTSTATUS = 0xC0230014u32 as i32; pub const STATUS_NDIS_INVALID_DATA: ::NTSTATUS = 0xC0230015u32 as i32; pub const STATUS_NDIS_BUFFER_TOO_SHORT: ::NTSTATUS = 0xC0230016u32 as i32; pub const STATUS_NDIS_INVALID_OID: ::NTSTATUS = 0xC0230017u32 as i32; pub const STATUS_NDIS_ADAPTER_REMOVED: ::NTSTATUS = 0xC0230018u32 as i32; pub const STATUS_NDIS_UNSUPPORTED_MEDIA: ::NTSTATUS = 0xC0230019u32 as i32; pub const STATUS_NDIS_GROUP_ADDRESS_IN_USE: ::NTSTATUS = 0xC023001Au32 as i32; pub const STATUS_NDIS_FILE_NOT_FOUND: ::NTSTATUS = 0xC023001Bu32 as i32; pub const STATUS_NDIS_ERROR_READING_FILE: ::NTSTATUS = 0xC023001Cu32 as i32; pub const STATUS_NDIS_ALREADY_MAPPED: ::NTSTATUS = 0xC023001Du32 as i32; pub const STATUS_NDIS_RESOURCE_CONFLICT: ::NTSTATUS = 0xC023001Eu32 as i32; pub const STATUS_NDIS_MEDIA_DISCONNECTED: ::NTSTATUS = 0xC023001Fu32 as i32; pub const STATUS_NDIS_INVALID_ADDRESS: ::NTSTATUS = 0xC0230022u32 as i32; pub const STATUS_NDIS_INVALID_DEVICE_REQUEST: ::NTSTATUS = 0xC0230010u32 as i32; pub const STATUS_NDIS_PAUSED: ::NTSTATUS = 0xC023002Au32 as i32; pub const STATUS_NDIS_INTERFACE_NOT_FOUND: ::NTSTATUS = 0xC023002Bu32 as i32; pub const STATUS_NDIS_UNSUPPORTED_REVISION: ::NTSTATUS = 0xC023002Cu32 as i32; pub const STATUS_NDIS_INVALID_PORT: ::NTSTATUS = 0xC023002Du32 as i32; pub const STATUS_NDIS_INVALID_PORT_STATE: ::NTSTATUS = 0xC023002Eu32 as i32; pub const STATUS_NDIS_LOW_POWER_STATE: ::NTSTATUS = 0xC023002Fu32 as i32; pub const STATUS_NDIS_REINIT_REQUIRED: ::NTSTATUS = 0xC0230030u32 as i32; pub const STATUS_NDIS_DOT11_AUTO_CONFIG_ENABLED: ::NTSTATUS = 0xC0232000u32 as i32; pub const STATUS_NDIS_DOT11_MEDIA_IN_USE: ::NTSTATUS = 0xC0232001u32 as i32; pub const STATUS_NDIS_DOT11_POWER_STATE_INVALID: ::NTSTATUS = 0xC0232002u32 as i32; pub const STATUS_NDIS_PM_WOL_PATTERN_LIST_FULL: ::NTSTATUS = 0xC0232003u32 as i32; pub const STATUS_NDIS_PM_PROTOCOL_OFFLOAD_LIST_FULL: ::NTSTATUS = 0xC0232004u32 as i32; pub const STATUS_NDIS_INDICATION_REQUIRED: ::NTSTATUS = 0x40230001; pub const STATUS_NDIS_OFFLOAD_POLICY: ::NTSTATUS = 0xC023100Fu32 as i32; pub const STATUS_NDIS_OFFLOAD_CONNECTION_REJECTED: ::NTSTATUS = 0xC0231012u32 as i32; pub const STATUS_NDIS_OFFLOAD_PATH_REJECTED: ::NTSTATUS = 0xC0231013u32 as i32; pub const STATUS_TPM_ERROR_MASK: ::NTSTATUS = 0xC0290000u32 as i32; pub const STATUS_TPM_AUTHFAIL: ::NTSTATUS = 0xC0290001u32 as i32; pub const STATUS_TPM_BADINDEX: ::NTSTATUS = 0xC0290002u32 as i32; pub const STATUS_TPM_BAD_PARAMETER: ::NTSTATUS = 0xC0290003u32 as i32; pub const STATUS_TPM_AUDITFAILURE: ::NTSTATUS = 0xC0290004u32 as i32; pub const STATUS_TPM_CLEAR_DISABLED: ::NTSTATUS = 0xC0290005u32 as i32; pub const STATUS_TPM_DEACTIVATED: ::NTSTATUS = 0xC0290006u32 as i32; pub const STATUS_TPM_DISABLED: ::NTSTATUS = 0xC0290007u32 as i32; pub const STATUS_TPM_DISABLED_CMD: ::NTSTATUS = 0xC0290008u32 as i32; pub const STATUS_TPM_FAIL: ::NTSTATUS = 0xC0290009u32 as i32; pub const STATUS_TPM_BAD_ORDINAL: ::NTSTATUS = 0xC029000Au32 as i32; pub const STATUS_TPM_INSTALL_DISABLED: ::NTSTATUS = 0xC029000Bu32 as i32; pub const STATUS_TPM_INVALID_KEYHANDLE: ::NTSTATUS = 0xC029000Cu32 as i32; pub const STATUS_TPM_KEYNOTFOUND: ::NTSTATUS = 0xC029000Du32 as i32; pub const STATUS_TPM_INAPPROPRIATE_ENC: ::NTSTATUS = 0xC029000Eu32 as i32; pub const STATUS_TPM_MIGRATEFAIL: ::NTSTATUS = 0xC029000Fu32 as i32; pub const STATUS_TPM_INVALID_PCR_INFO: ::NTSTATUS = 0xC0290010u32 as i32; pub const STATUS_TPM_NOSPACE: ::NTSTATUS = 0xC0290011u32 as i32; pub const STATUS_TPM_NOSRK: ::NTSTATUS = 0xC0290012u32 as i32; pub const STATUS_TPM_NOTSEALED_BLOB: ::NTSTATUS = 0xC0290013u32 as i32; pub const STATUS_TPM_OWNER_SET: ::NTSTATUS = 0xC0290014u32 as i32; pub const STATUS_TPM_RESOURCES: ::NTSTATUS = 0xC0290015u32 as i32; pub const STATUS_TPM_SHORTRANDOM: ::NTSTATUS = 0xC0290016u32 as i32; pub const STATUS_TPM_SIZE: ::NTSTATUS = 0xC0290017u32 as i32; pub const STATUS_TPM_WRONGPCRVAL: ::NTSTATUS = 0xC0290018u32 as i32; pub const STATUS_TPM_BAD_PARAM_SIZE: ::NTSTATUS = 0xC0290019u32 as i32; pub const STATUS_TPM_SHA_THREAD: ::NTSTATUS = 0xC029001Au32 as i32; pub const STATUS_TPM_SHA_ERROR: ::NTSTATUS = 0xC029001Bu32 as i32; pub const STATUS_TPM_FAILEDSELFTEST: ::NTSTATUS = 0xC029001Cu32 as i32; pub const STATUS_TPM_AUTH2FAIL: ::NTSTATUS = 0xC029001Du32 as i32; pub const STATUS_TPM_BADTAG: ::NTSTATUS = 0xC029001Eu32 as i32; pub const STATUS_TPM_IOERROR: ::NTSTATUS = 0xC029001Fu32 as i32; pub const STATUS_TPM_ENCRYPT_ERROR: ::NTSTATUS = 0xC0290020u32 as i32; pub const STATUS_TPM_DECRYPT_ERROR: ::NTSTATUS = 0xC0290021u32 as i32; pub const STATUS_TPM_INVALID_AUTHHANDLE: ::NTSTATUS = 0xC0290022u32 as i32; pub const STATUS_TPM_NO_ENDORSEMENT: ::NTSTATUS = 0xC0290023u32 as i32; pub const STATUS_TPM_INVALID_KEYUSAGE: ::NTSTATUS = 0xC0290024u32 as i32; pub const STATUS_TPM_WRONG_ENTITYTYPE: ::NTSTATUS = 0xC0290025u32 as i32; pub const STATUS_TPM_INVALID_POSTINIT: ::NTSTATUS = 0xC0290026u32 as i32; pub const STATUS_TPM_INAPPROPRIATE_SIG: ::NTSTATUS = 0xC0290027u32 as i32; pub const STATUS_TPM_BAD_KEY_PROPERTY: ::NTSTATUS = 0xC0290028u32 as i32; pub const STATUS_TPM_BAD_MIGRATION: ::NTSTATUS = 0xC0290029u32 as i32; pub const STATUS_TPM_BAD_SCHEME: ::NTSTATUS = 0xC029002Au32 as i32; pub const STATUS_TPM_BAD_DATASIZE: ::NTSTATUS = 0xC029002Bu32 as i32; pub const STATUS_TPM_BAD_MODE: ::NTSTATUS = 0xC029002Cu32 as i32; pub const STATUS_TPM_BAD_PRESENCE: ::NTSTATUS = 0xC029002Du32 as i32; pub const STATUS_TPM_BAD_VERSION: ::NTSTATUS = 0xC029002Eu32 as i32; pub const STATUS_TPM_NO_WRAP_TRANSPORT: ::NTSTATUS = 0xC029002Fu32 as i32; pub const STATUS_TPM_AUDITFAIL_UNSUCCESSFUL: ::NTSTATUS = 0xC0290030u32 as i32; pub const STATUS_TPM_AUDITFAIL_SUCCESSFUL: ::NTSTATUS = 0xC0290031u32 as i32; pub const STATUS_TPM_NOTRESETABLE: ::NTSTATUS = 0xC0290032u32 as i32; pub const STATUS_TPM_NOTLOCAL: ::NTSTATUS = 0xC0290033u32 as i32; pub const STATUS_TPM_BAD_TYPE: ::NTSTATUS = 0xC0290034u32 as i32; pub const STATUS_TPM_INVALID_RESOURCE: ::NTSTATUS = 0xC0290035u32 as i32; pub const STATUS_TPM_NOTFIPS: ::NTSTATUS = 0xC0290036u32 as i32; pub const STATUS_TPM_INVALID_FAMILY: ::NTSTATUS = 0xC0290037u32 as i32; pub const STATUS_TPM_NO_NV_PERMISSION: ::NTSTATUS = 0xC0290038u32 as i32; pub const STATUS_TPM_REQUIRES_SIGN: ::NTSTATUS = 0xC0290039u32 as i32; pub const STATUS_TPM_KEY_NOTSUPPORTED: ::NTSTATUS = 0xC029003Au32 as i32; pub const STATUS_TPM_AUTH_CONFLICT: ::NTSTATUS = 0xC029003Bu32 as i32; pub const STATUS_TPM_AREA_LOCKED: ::NTSTATUS = 0xC029003Cu32 as i32; pub const STATUS_TPM_BAD_LOCALITY: ::NTSTATUS = 0xC029003Du32 as i32; pub const STATUS_TPM_READ_ONLY: ::NTSTATUS = 0xC029003Eu32 as i32; pub const STATUS_TPM_PER_NOWRITE: ::NTSTATUS = 0xC029003Fu32 as i32; pub const STATUS_TPM_FAMILYCOUNT: ::NTSTATUS = 0xC0290040u32 as i32; pub const STATUS_TPM_WRITE_LOCKED: ::NTSTATUS = 0xC0290041u32 as i32; pub const STATUS_TPM_BAD_ATTRIBUTES: ::NTSTATUS = 0xC0290042u32 as i32; pub const STATUS_TPM_INVALID_STRUCTURE: ::NTSTATUS = 0xC0290043u32 as i32; pub const STATUS_TPM_KEY_OWNER_CONTROL: ::NTSTATUS = 0xC0290044u32 as i32; pub const STATUS_TPM_BAD_COUNTER: ::NTSTATUS = 0xC0290045u32 as i32; pub const STATUS_TPM_NOT_FULLWRITE: ::NTSTATUS = 0xC0290046u32 as i32; pub const STATUS_TPM_CONTEXT_GAP: ::NTSTATUS = 0xC0290047u32 as i32; pub const STATUS_TPM_MAXNVWRITES: ::NTSTATUS = 0xC0290048u32 as i32; pub const STATUS_TPM_NOOPERATOR: ::NTSTATUS = 0xC0290049u32 as i32; pub const STATUS_TPM_RESOURCEMISSING: ::NTSTATUS = 0xC029004Au32 as i32; pub const STATUS_TPM_DELEGATE_LOCK: ::NTSTATUS = 0xC029004Bu32 as i32; pub const STATUS_TPM_DELEGATE_FAMILY: ::NTSTATUS = 0xC029004Cu32 as i32; pub const STATUS_TPM_DELEGATE_ADMIN: ::NTSTATUS = 0xC029004Du32 as i32; pub const STATUS_TPM_TRANSPORT_NOTEXCLUSIVE: ::NTSTATUS = 0xC029004Eu32 as i32; pub const STATUS_TPM_OWNER_CONTROL: ::NTSTATUS = 0xC029004Fu32 as i32; pub const STATUS_TPM_DAA_RESOURCES: ::NTSTATUS = 0xC0290050u32 as i32; pub const STATUS_TPM_DAA_INPUT_DATA0: ::NTSTATUS = 0xC0290051u32 as i32; pub const STATUS_TPM_DAA_INPUT_DATA1: ::NTSTATUS = 0xC0290052u32 as i32; pub const STATUS_TPM_DAA_ISSUER_SETTINGS: ::NTSTATUS = 0xC0290053u32 as i32; pub const STATUS_TPM_DAA_TPM_SETTINGS: ::NTSTATUS = 0xC0290054u32 as i32; pub const STATUS_TPM_DAA_STAGE: ::NTSTATUS = 0xC0290055u32 as i32; pub const STATUS_TPM_DAA_ISSUER_VALIDITY: ::NTSTATUS = 0xC0290056u32 as i32; pub const STATUS_TPM_DAA_WRONG_W: ::NTSTATUS = 0xC0290057u32 as i32; pub const STATUS_TPM_BAD_HANDLE: ::NTSTATUS = 0xC0290058u32 as i32; pub const STATUS_TPM_BAD_DELEGATE: ::NTSTATUS = 0xC0290059u32 as i32; pub const STATUS_TPM_BADCONTEXT: ::NTSTATUS = 0xC029005Au32 as i32; pub const STATUS_TPM_TOOMANYCONTEXTS: ::NTSTATUS = 0xC029005Bu32 as i32; pub const STATUS_TPM_MA_TICKET_SIGNATURE: ::NTSTATUS = 0xC029005Cu32 as i32; pub const STATUS_TPM_MA_DESTINATION: ::NTSTATUS = 0xC029005Du32 as i32; pub const STATUS_TPM_MA_SOURCE: ::NTSTATUS = 0xC029005Eu32 as i32; pub const STATUS_TPM_MA_AUTHORITY: ::NTSTATUS = 0xC029005Fu32 as i32; pub const STATUS_TPM_PERMANENTEK: ::NTSTATUS = 0xC0290061u32 as i32; pub const STATUS_TPM_BAD_SIGNATURE: ::NTSTATUS = 0xC0290062u32 as i32; pub const STATUS_TPM_NOCONTEXTSPACE: ::NTSTATUS = 0xC0290063u32 as i32; pub const STATUS_TPM_COMMAND_BLOCKED: ::NTSTATUS = 0xC0290400u32 as i32; pub const STATUS_TPM_INVALID_HANDLE: ::NTSTATUS = 0xC0290401u32 as i32; pub const STATUS_TPM_DUPLICATE_VHANDLE: ::NTSTATUS = 0xC0290402u32 as i32; pub const STATUS_TPM_EMBEDDED_COMMAND_BLOCKED: ::NTSTATUS = 0xC0290403u32 as i32; pub const STATUS_TPM_EMBEDDED_COMMAND_UNSUPPORTED: ::NTSTATUS = 0xC0290404u32 as i32; pub const STATUS_TPM_RETRY: ::NTSTATUS = 0xC0290800u32 as i32; pub const STATUS_TPM_NEEDS_SELFTEST: ::NTSTATUS = 0xC0290801u32 as i32; pub const STATUS_TPM_DOING_SELFTEST: ::NTSTATUS = 0xC0290802u32 as i32; pub const STATUS_TPM_DEFEND_LOCK_RUNNING: ::NTSTATUS = 0xC0290803u32 as i32; pub const STATUS_TPM_COMMAND_CANCELED: ::NTSTATUS = 0xC0291001u32 as i32; pub const STATUS_TPM_TOO_MANY_CONTEXTS: ::NTSTATUS = 0xC0291002u32 as i32; pub const STATUS_TPM_NOT_FOUND: ::NTSTATUS = 0xC0291003u32 as i32; pub const STATUS_TPM_ACCESS_DENIED: ::NTSTATUS = 0xC0291004u32 as i32; pub const STATUS_TPM_INSUFFICIENT_BUFFER: ::NTSTATUS = 0xC0291005u32 as i32; pub const STATUS_TPM_PPI_FUNCTION_UNSUPPORTED: ::NTSTATUS = 0xC0291006u32 as i32; pub const STATUS_PCP_ERROR_MASK: ::NTSTATUS = 0xC0292000u32 as i32; pub const STATUS_PCP_DEVICE_NOT_READY: ::NTSTATUS = 0xC0292001u32 as i32; pub const STATUS_PCP_INVALID_HANDLE: ::NTSTATUS = 0xC0292002u32 as i32; pub const STATUS_PCP_INVALID_PARAMETER: ::NTSTATUS = 0xC0292003u32 as i32; pub const STATUS_PCP_FLAG_NOT_SUPPORTED: ::NTSTATUS = 0xC0292004u32 as i32; pub const STATUS_PCP_NOT_SUPPORTED: ::NTSTATUS = 0xC0292005u32 as i32; pub const STATUS_PCP_BUFFER_TOO_SMALL: ::NTSTATUS = 0xC0292006u32 as i32; pub const STATUS_PCP_INTERNAL_ERROR: ::NTSTATUS = 0xC0292007u32 as i32; pub const STATUS_PCP_AUTHENTICATION_FAILED: ::NTSTATUS = 0xC0292008u32 as i32; pub const STATUS_PCP_AUTHENTICATION_IGNORED: ::NTSTATUS = 0xC0292009u32 as i32; pub const STATUS_PCP_POLICY_NOT_FOUND: ::NTSTATUS = 0xC029200Au32 as i32; pub const STATUS_PCP_PROFILE_NOT_FOUND: ::NTSTATUS = 0xC029200Bu32 as i32; pub const STATUS_PCP_VALIDATION_FAILED: ::NTSTATUS = 0xC029200Cu32 as i32; pub const STATUS_PCP_DEVICE_NOT_FOUND: ::NTSTATUS = 0xC029200Du32 as i32; pub const STATUS_RTPM_CONTEXT_CONTINUE: ::NTSTATUS = 0x00293000; pub const STATUS_RTPM_CONTEXT_COMPLETE: ::NTSTATUS = 0x00293001; pub const STATUS_RTPM_NO_RESULT: ::NTSTATUS = 0xC0293002u32 as i32; pub const STATUS_RTPM_PCR_READ_INCOMPLETE: ::NTSTATUS = 0xC0293003u32 as i32; pub const STATUS_RTPM_INVALID_CONTEXT: ::NTSTATUS = 0xC0293004u32 as i32; pub const STATUS_RTPM_UNSUPPORTED_CMD: ::NTSTATUS = 0xC0293005u32 as i32; pub const STATUS_HV_INVALID_HYPERCALL_CODE: ::NTSTATUS = 0xC0350002u32 as i32; pub const STATUS_HV_INVALID_HYPERCALL_INPUT: ::NTSTATUS = 0xC0350003u32 as i32; pub const STATUS_HV_INVALID_ALIGNMENT: ::NTSTATUS = 0xC0350004u32 as i32; pub const STATUS_HV_INVALID_PARAMETER: ::NTSTATUS = 0xC0350005u32 as i32; pub const STATUS_HV_ACCESS_DENIED: ::NTSTATUS = 0xC0350006u32 as i32; pub const STATUS_HV_INVALID_PARTITION_STATE: ::NTSTATUS = 0xC0350007u32 as i32; pub const STATUS_HV_OPERATION_DENIED: ::NTSTATUS = 0xC0350008u32 as i32; pub const STATUS_HV_UNKNOWN_PROPERTY: ::NTSTATUS = 0xC0350009u32 as i32; pub const STATUS_HV_PROPERTY_VALUE_OUT_OF_RANGE: ::NTSTATUS = 0xC035000Au32 as i32; pub const STATUS_HV_INSUFFICIENT_MEMORY: ::NTSTATUS = 0xC035000Bu32 as i32; pub const STATUS_HV_PARTITION_TOO_DEEP: ::NTSTATUS = 0xC035000Cu32 as i32; pub const STATUS_HV_INVALID_PARTITION_ID: ::NTSTATUS = 0xC035000Du32 as i32; pub const STATUS_HV_INVALID_VP_INDEX: ::NTSTATUS = 0xC035000Eu32 as i32; pub const STATUS_HV_INVALID_PORT_ID: ::NTSTATUS = 0xC0350011u32 as i32; pub const STATUS_HV_INVALID_CONNECTION_ID: ::NTSTATUS = 0xC0350012u32 as i32; pub const STATUS_HV_INSUFFICIENT_BUFFERS: ::NTSTATUS = 0xC0350013u32 as i32; pub const STATUS_HV_NOT_ACKNOWLEDGED: ::NTSTATUS = 0xC0350014u32 as i32; pub const STATUS_HV_ACKNOWLEDGED: ::NTSTATUS = 0xC0350016u32 as i32; pub const STATUS_HV_INVALID_SAVE_RESTORE_STATE: ::NTSTATUS = 0xC0350017u32 as i32; pub const STATUS_HV_INVALID_SYNIC_STATE: ::NTSTATUS = 0xC0350018u32 as i32; pub const STATUS_HV_OBJECT_IN_USE: ::NTSTATUS = 0xC0350019u32 as i32; pub const STATUS_HV_INVALID_PROXIMITY_DOMAIN_INFO: ::NTSTATUS = 0xC035001Au32 as i32; pub const STATUS_HV_NO_DATA: ::NTSTATUS = 0xC035001Bu32 as i32; pub const STATUS_HV_INACTIVE: ::NTSTATUS = 0xC035001Cu32 as i32; pub const STATUS_HV_NO_RESOURCES: ::NTSTATUS = 0xC035001Du32 as i32; pub const STATUS_HV_FEATURE_UNAVAILABLE: ::NTSTATUS = 0xC035001Eu32 as i32; pub const STATUS_HV_INSUFFICIENT_BUFFER: ::NTSTATUS = 0xC0350033u32 as i32; pub const STATUS_HV_INSUFFICIENT_DEVICE_DOMAINS: ::NTSTATUS = 0xC0350038u32 as i32; pub const STATUS_HV_CPUID_FEATURE_VALIDATION_ERROR: ::NTSTATUS = 0xC035003Cu32 as i32; pub const STATUS_HV_CPUID_XSAVE_FEATURE_VALIDATION_ERROR: ::NTSTATUS = 0xC035003Du32 as i32; pub const STATUS_HV_PROCESSOR_STARTUP_TIMEOUT: ::NTSTATUS = 0xC035003Eu32 as i32; pub const STATUS_HV_SMX_ENABLED: ::NTSTATUS = 0xC035003Fu32 as i32; pub const STATUS_HV_INVALID_LP_INDEX: ::NTSTATUS = 0xC0350041u32 as i32; pub const STATUS_HV_INVALID_REGISTER_VALUE: ::NTSTATUS = 0xC0350050u32 as i32; pub const STATUS_HV_INVALID_VTL_STATE: ::NTSTATUS = 0xC0350051u32 as i32; pub const STATUS_HV_NX_NOT_DETECTED: ::NTSTATUS = 0xC0350055u32 as i32; pub const STATUS_HV_INVALID_DEVICE_ID: ::NTSTATUS = 0xC0350057u32 as i32; pub const STATUS_HV_INVALID_DEVICE_STATE: ::NTSTATUS = 0xC0350058u32 as i32; pub const STATUS_HV_PENDING_PAGE_REQUESTS: ::NTSTATUS = 0x00350059; pub const STATUS_HV_PAGE_REQUEST_INVALID: ::NTSTATUS = 0xC0350060u32 as i32; pub const STATUS_HV_NOT_PRESENT: ::NTSTATUS = 0xC0351000u32 as i32; pub const STATUS_VID_DUPLICATE_HANDLER: ::NTSTATUS = 0xC0370001u32 as i32; pub const STATUS_VID_TOO_MANY_HANDLERS: ::NTSTATUS = 0xC0370002u32 as i32; pub const STATUS_VID_QUEUE_FULL: ::NTSTATUS = 0xC0370003u32 as i32; pub const STATUS_VID_HANDLER_NOT_PRESENT: ::NTSTATUS = 0xC0370004u32 as i32; pub const STATUS_VID_INVALID_OBJECT_NAME: ::NTSTATUS = 0xC0370005u32 as i32; pub const STATUS_VID_PARTITION_NAME_TOO_LONG: ::NTSTATUS = 0xC0370006u32 as i32; pub const STATUS_VID_MESSAGE_QUEUE_NAME_TOO_LONG: ::NTSTATUS = 0xC0370007u32 as i32; pub const STATUS_VID_PARTITION_ALREADY_EXISTS: ::NTSTATUS = 0xC0370008u32 as i32; pub const STATUS_VID_PARTITION_DOES_NOT_EXIST: ::NTSTATUS = 0xC0370009u32 as i32; pub const STATUS_VID_PARTITION_NAME_NOT_FOUND: ::NTSTATUS = 0xC037000Au32 as i32; pub const STATUS_VID_MESSAGE_QUEUE_ALREADY_EXISTS: ::NTSTATUS = 0xC037000Bu32 as i32; pub const STATUS_VID_EXCEEDED_MBP_ENTRY_MAP_LIMIT: ::NTSTATUS = 0xC037000Cu32 as i32; pub const STATUS_VID_MB_STILL_REFERENCED: ::NTSTATUS = 0xC037000Du32 as i32; pub const STATUS_VID_CHILD_GPA_PAGE_SET_CORRUPTED: ::NTSTATUS = 0xC037000Eu32 as i32; pub const STATUS_VID_INVALID_NUMA_SETTINGS: ::NTSTATUS = 0xC037000Fu32 as i32; pub const STATUS_VID_INVALID_NUMA_NODE_INDEX: ::NTSTATUS = 0xC0370010u32 as i32; pub const STATUS_VID_NOTIFICATION_QUEUE_ALREADY_ASSOCIATED: ::NTSTATUS = 0xC0370011u32 as i32; pub const STATUS_VID_INVALID_MEMORY_BLOCK_HANDLE: ::NTSTATUS = 0xC0370012u32 as i32; pub const STATUS_VID_PAGE_RANGE_OVERFLOW: ::NTSTATUS = 0xC0370013u32 as i32; pub const STATUS_VID_INVALID_MESSAGE_QUEUE_HANDLE: ::NTSTATUS = 0xC0370014u32 as i32; pub const STATUS_VID_INVALID_GPA_RANGE_HANDLE: ::NTSTATUS = 0xC0370015u32 as i32; pub const STATUS_VID_NO_MEMORY_BLOCK_NOTIFICATION_QUEUE: ::NTSTATUS = 0xC0370016u32 as i32; pub const STATUS_VID_MEMORY_BLOCK_LOCK_COUNT_EXCEEDED: ::NTSTATUS = 0xC0370017u32 as i32; pub const STATUS_VID_INVALID_PPM_HANDLE: ::NTSTATUS = 0xC0370018u32 as i32; pub const STATUS_VID_MBPS_ARE_LOCKED: ::NTSTATUS = 0xC0370019u32 as i32; pub const STATUS_VID_MESSAGE_QUEUE_CLOSED: ::NTSTATUS = 0xC037001Au32 as i32; pub const STATUS_VID_VIRTUAL_PROCESSOR_LIMIT_EXCEEDED: ::NTSTATUS = 0xC037001Bu32 as i32; pub const STATUS_VID_STOP_PENDING: ::NTSTATUS = 0xC037001Cu32 as i32; pub const STATUS_VID_INVALID_PROCESSOR_STATE: ::NTSTATUS = 0xC037001Du32 as i32; pub const STATUS_VID_EXCEEDED_KM_CONTEXT_COUNT_LIMIT: ::NTSTATUS = 0xC037001Eu32 as i32; pub const STATUS_VID_KM_INTERFACE_ALREADY_INITIALIZED: ::NTSTATUS = 0xC037001Fu32 as i32; pub const STATUS_VID_MB_PROPERTY_ALREADY_SET_RESET: ::NTSTATUS = 0xC0370020u32 as i32; pub const STATUS_VID_MMIO_RANGE_DESTROYED: ::NTSTATUS = 0xC0370021u32 as i32; pub const STATUS_VID_INVALID_CHILD_GPA_PAGE_SET: ::NTSTATUS = 0xC0370022u32 as i32; pub const STATUS_VID_RESERVE_PAGE_SET_IS_BEING_USED: ::NTSTATUS = 0xC0370023u32 as i32; pub const STATUS_VID_RESERVE_PAGE_SET_TOO_SMALL: ::NTSTATUS = 0xC0370024u32 as i32; pub const STATUS_VID_MBP_ALREADY_LOCKED_USING_RESERVED_PAGE: ::NTSTATUS = 0xC0370025u32 as i32; pub const STATUS_VID_MBP_COUNT_EXCEEDED_LIMIT: ::NTSTATUS = 0xC0370026u32 as i32; pub const STATUS_VID_SAVED_STATE_CORRUPT: ::NTSTATUS = 0xC0370027u32 as i32; pub const STATUS_VID_SAVED_STATE_UNRECOGNIZED_ITEM: ::NTSTATUS = 0xC0370028u32 as i32; pub const STATUS_VID_SAVED_STATE_INCOMPATIBLE: ::NTSTATUS = 0xC0370029u32 as i32; pub const STATUS_VID_REMOTE_NODE_PARENT_GPA_PAGES_USED: ::NTSTATUS = 0x80370001u32 as i32; pub const STATUS_IPSEC_BAD_SPI: ::NTSTATUS = 0xC0360001u32 as i32; pub const STATUS_IPSEC_SA_LIFETIME_EXPIRED: ::NTSTATUS = 0xC0360002u32 as i32; pub const STATUS_IPSEC_WRONG_SA: ::NTSTATUS = 0xC0360003u32 as i32; pub const STATUS_IPSEC_REPLAY_CHECK_FAILED: ::NTSTATUS = 0xC0360004u32 as i32; pub const STATUS_IPSEC_INVALID_PACKET: ::NTSTATUS = 0xC0360005u32 as i32; pub const STATUS_IPSEC_INTEGRITY_CHECK_FAILED: ::NTSTATUS = 0xC0360006u32 as i32; pub const STATUS_IPSEC_CLEAR_TEXT_DROP: ::NTSTATUS = 0xC0360007u32 as i32; pub const STATUS_IPSEC_AUTH_FIREWALL_DROP: ::NTSTATUS = 0xC0360008u32 as i32; pub const STATUS_IPSEC_THROTTLE_DROP: ::NTSTATUS = 0xC0360009u32 as i32; pub const STATUS_IPSEC_DOSP_BLOCK: ::NTSTATUS = 0xC0368000u32 as i32; pub const STATUS_IPSEC_DOSP_RECEIVED_MULTICAST: ::NTSTATUS = 0xC0368001u32 as i32; pub const STATUS_IPSEC_DOSP_INVALID_PACKET: ::NTSTATUS = 0xC0368002u32 as i32; pub const STATUS_IPSEC_DOSP_STATE_LOOKUP_FAILED: ::NTSTATUS = 0xC0368003u32 as i32; pub const STATUS_IPSEC_DOSP_MAX_ENTRIES: ::NTSTATUS = 0xC0368004u32 as i32; pub const STATUS_IPSEC_DOSP_KEYMOD_NOT_ALLOWED: ::NTSTATUS = 0xC0368005u32 as i32; pub const STATUS_IPSEC_DOSP_MAX_PER_IP_RATELIMIT_QUEUES: ::NTSTATUS = 0xC0368006u32 as i32; pub const STATUS_VOLMGR_INCOMPLETE_REGENERATION: ::NTSTATUS = 0x80380001u32 as i32; pub const STATUS_VOLMGR_INCOMPLETE_DISK_MIGRATION: ::NTSTATUS = 0x80380002u32 as i32; pub const STATUS_VOLMGR_DATABASE_FULL: ::NTSTATUS = 0xC0380001u32 as i32; pub const STATUS_VOLMGR_DISK_CONFIGURATION_CORRUPTED: ::NTSTATUS = 0xC0380002u32 as i32; pub const STATUS_VOLMGR_DISK_CONFIGURATION_NOT_IN_SYNC: ::NTSTATUS = 0xC0380003u32 as i32; pub const STATUS_VOLMGR_PACK_CONFIG_UPDATE_FAILED: ::NTSTATUS = 0xC0380004u32 as i32; pub const STATUS_VOLMGR_DISK_CONTAINS_NON_SIMPLE_VOLUME: ::NTSTATUS = 0xC0380005u32 as i32; pub const STATUS_VOLMGR_DISK_DUPLICATE: ::NTSTATUS = 0xC0380006u32 as i32; pub const STATUS_VOLMGR_DISK_DYNAMIC: ::NTSTATUS = 0xC0380007u32 as i32; pub const STATUS_VOLMGR_DISK_ID_INVALID: ::NTSTATUS = 0xC0380008u32 as i32; pub const STATUS_VOLMGR_DISK_INVALID: ::NTSTATUS = 0xC0380009u32 as i32; pub const STATUS_VOLMGR_DISK_LAST_VOTER: ::NTSTATUS = 0xC038000Au32 as i32; pub const STATUS_VOLMGR_DISK_LAYOUT_INVALID: ::NTSTATUS = 0xC038000Bu32 as i32; pub const STATUS_VOLMGR_DISK_LAYOUT_NON_BASIC_BETWEEN_BASIC_PARTITIONS: ::NTSTATUS = 0xC038000Cu32 as i32; pub const STATUS_VOLMGR_DISK_LAYOUT_NOT_CYLINDER_ALIGNED: ::NTSTATUS = 0xC038000Du32 as i32; pub const STATUS_VOLMGR_DISK_LAYOUT_PARTITIONS_TOO_SMALL: ::NTSTATUS = 0xC038000Eu32 as i32; pub const STATUS_VOLMGR_DISK_LAYOUT_PRIMARY_BETWEEN_LOGICAL_PARTITIONS: ::NTSTATUS = 0xC038000Fu32 as i32; pub const STATUS_VOLMGR_DISK_LAYOUT_TOO_MANY_PARTITIONS: ::NTSTATUS = 0xC0380010u32 as i32; pub const STATUS_VOLMGR_DISK_MISSING: ::NTSTATUS = 0xC0380011u32 as i32; pub const STATUS_VOLMGR_DISK_NOT_EMPTY: ::NTSTATUS = 0xC0380012u32 as i32; pub const STATUS_VOLMGR_DISK_NOT_ENOUGH_SPACE: ::NTSTATUS = 0xC0380013u32 as i32; pub const STATUS_VOLMGR_DISK_REVECTORING_FAILED: ::NTSTATUS = 0xC0380014u32 as i32; pub const STATUS_VOLMGR_DISK_SECTOR_SIZE_INVALID: ::NTSTATUS = 0xC0380015u32 as i32; pub const STATUS_VOLMGR_DISK_SET_NOT_CONTAINED: ::NTSTATUS = 0xC0380016u32 as i32; pub const STATUS_VOLMGR_DISK_USED_BY_MULTIPLE_MEMBERS: ::NTSTATUS = 0xC0380017u32 as i32; pub const STATUS_VOLMGR_DISK_USED_BY_MULTIPLE_PLEXES: ::NTSTATUS = 0xC0380018u32 as i32; pub const STATUS_VOLMGR_DYNAMIC_DISK_NOT_SUPPORTED: ::NTSTATUS = 0xC0380019u32 as i32; pub const STATUS_VOLMGR_EXTENT_ALREADY_USED: ::NTSTATUS = 0xC038001Au32 as i32; pub const STATUS_VOLMGR_EXTENT_NOT_CONTIGUOUS: ::NTSTATUS = 0xC038001Bu32 as i32; pub const STATUS_VOLMGR_EXTENT_NOT_IN_PUBLIC_REGION: ::NTSTATUS = 0xC038001Cu32 as i32; pub const STATUS_VOLMGR_EXTENT_NOT_SECTOR_ALIGNED: ::NTSTATUS = 0xC038001Du32 as i32; pub const STATUS_VOLMGR_EXTENT_OVERLAPS_EBR_PARTITION: ::NTSTATUS = 0xC038001Eu32 as i32; pub const STATUS_VOLMGR_EXTENT_VOLUME_LENGTHS_DO_NOT_MATCH: ::NTSTATUS = 0xC038001Fu32 as i32; pub const STATUS_VOLMGR_FAULT_TOLERANT_NOT_SUPPORTED: ::NTSTATUS = 0xC0380020u32 as i32; pub const STATUS_VOLMGR_INTERLEAVE_LENGTH_INVALID: ::NTSTATUS = 0xC0380021u32 as i32; pub const STATUS_VOLMGR_MAXIMUM_REGISTERED_USERS: ::NTSTATUS = 0xC0380022u32 as i32; pub const STATUS_VOLMGR_MEMBER_IN_SYNC: ::NTSTATUS = 0xC0380023u32 as i32; pub const STATUS_VOLMGR_MEMBER_INDEX_DUPLICATE: ::NTSTATUS = 0xC0380024u32 as i32; pub const STATUS_VOLMGR_MEMBER_INDEX_INVALID: ::NTSTATUS = 0xC0380025u32 as i32; pub const STATUS_VOLMGR_MEMBER_MISSING: ::NTSTATUS = 0xC0380026u32 as i32; pub const STATUS_VOLMGR_MEMBER_NOT_DETACHED: ::NTSTATUS = 0xC0380027u32 as i32; pub const STATUS_VOLMGR_MEMBER_REGENERATING: ::NTSTATUS = 0xC0380028u32 as i32; pub const STATUS_VOLMGR_ALL_DISKS_FAILED: ::NTSTATUS = 0xC0380029u32 as i32; pub const STATUS_VOLMGR_NO_REGISTERED_USERS: ::NTSTATUS = 0xC038002Au32 as i32; pub const STATUS_VOLMGR_NO_SUCH_USER: ::NTSTATUS = 0xC038002Bu32 as i32; pub const STATUS_VOLMGR_NOTIFICATION_RESET: ::NTSTATUS = 0xC038002Cu32 as i32; pub const STATUS_VOLMGR_NUMBER_OF_MEMBERS_INVALID: ::NTSTATUS = 0xC038002Du32 as i32; pub const STATUS_VOLMGR_NUMBER_OF_PLEXES_INVALID: ::NTSTATUS = 0xC038002Eu32 as i32; pub const STATUS_VOLMGR_PACK_DUPLICATE: ::NTSTATUS = 0xC038002Fu32 as i32; pub const STATUS_VOLMGR_PACK_ID_INVALID: ::NTSTATUS = 0xC0380030u32 as i32; pub const STATUS_VOLMGR_PACK_INVALID: ::NTSTATUS = 0xC0380031u32 as i32; pub const STATUS_VOLMGR_PACK_NAME_INVALID: ::NTSTATUS = 0xC0380032u32 as i32; pub const STATUS_VOLMGR_PACK_OFFLINE: ::NTSTATUS = 0xC0380033u32 as i32; pub const STATUS_VOLMGR_PACK_HAS_QUORUM: ::NTSTATUS = 0xC0380034u32 as i32; pub const STATUS_VOLMGR_PACK_WITHOUT_QUORUM: ::NTSTATUS = 0xC0380035u32 as i32; pub const STATUS_VOLMGR_PARTITION_STYLE_INVALID: ::NTSTATUS = 0xC0380036u32 as i32; pub const STATUS_VOLMGR_PARTITION_UPDATE_FAILED: ::NTSTATUS = 0xC0380037u32 as i32; pub const STATUS_VOLMGR_PLEX_IN_SYNC: ::NTSTATUS = 0xC0380038u32 as i32; pub const STATUS_VOLMGR_PLEX_INDEX_DUPLICATE: ::NTSTATUS = 0xC0380039u32 as i32; pub const STATUS_VOLMGR_PLEX_INDEX_INVALID: ::NTSTATUS = 0xC038003Au32 as i32; pub const STATUS_VOLMGR_PLEX_LAST_ACTIVE: ::NTSTATUS = 0xC038003Bu32 as i32; pub const STATUS_VOLMGR_PLEX_MISSING: ::NTSTATUS = 0xC038003Cu32 as i32; pub const STATUS_VOLMGR_PLEX_REGENERATING: ::NTSTATUS = 0xC038003Du32 as i32; pub const STATUS_VOLMGR_PLEX_TYPE_INVALID: ::NTSTATUS = 0xC038003Eu32 as i32; pub const STATUS_VOLMGR_PLEX_NOT_RAID5: ::NTSTATUS = 0xC038003Fu32 as i32; pub const STATUS_VOLMGR_PLEX_NOT_SIMPLE: ::NTSTATUS = 0xC0380040u32 as i32; pub const STATUS_VOLMGR_STRUCTURE_SIZE_INVALID: ::NTSTATUS = 0xC0380041u32 as i32; pub const STATUS_VOLMGR_TOO_MANY_NOTIFICATION_REQUESTS: ::NTSTATUS = 0xC0380042u32 as i32; pub const STATUS_VOLMGR_TRANSACTION_IN_PROGRESS: ::NTSTATUS = 0xC0380043u32 as i32; pub const STATUS_VOLMGR_UNEXPECTED_DISK_LAYOUT_CHANGE: ::NTSTATUS = 0xC0380044u32 as i32; pub const STATUS_VOLMGR_VOLUME_CONTAINS_MISSING_DISK: ::NTSTATUS = 0xC0380045u32 as i32; pub const STATUS_VOLMGR_VOLUME_ID_INVALID: ::NTSTATUS = 0xC0380046u32 as i32; pub const STATUS_VOLMGR_VOLUME_LENGTH_INVALID: ::NTSTATUS = 0xC0380047u32 as i32; pub const STATUS_VOLMGR_VOLUME_LENGTH_NOT_SECTOR_SIZE_MULTIPLE: ::NTSTATUS = 0xC0380048u32 as i32; pub const STATUS_VOLMGR_VOLUME_NOT_MIRRORED: ::NTSTATUS = 0xC0380049u32 as i32; pub const STATUS_VOLMGR_VOLUME_NOT_RETAINED: ::NTSTATUS = 0xC038004Au32 as i32; pub const STATUS_VOLMGR_VOLUME_OFFLINE: ::NTSTATUS = 0xC038004Bu32 as i32; pub const STATUS_VOLMGR_VOLUME_RETAINED: ::NTSTATUS = 0xC038004Cu32 as i32; pub const STATUS_VOLMGR_NUMBER_OF_EXTENTS_INVALID: ::NTSTATUS = 0xC038004Du32 as i32; pub const STATUS_VOLMGR_DIFFERENT_SECTOR_SIZE: ::NTSTATUS = 0xC038004Eu32 as i32; pub const STATUS_VOLMGR_BAD_BOOT_DISK: ::NTSTATUS = 0xC038004Fu32 as i32; pub const STATUS_VOLMGR_PACK_CONFIG_OFFLINE: ::NTSTATUS = 0xC0380050u32 as i32; pub const STATUS_VOLMGR_PACK_CONFIG_ONLINE: ::NTSTATUS = 0xC0380051u32 as i32; pub const STATUS_VOLMGR_NOT_PRIMARY_PACK: ::NTSTATUS = 0xC0380052u32 as i32; pub const STATUS_VOLMGR_PACK_LOG_UPDATE_FAILED: ::NTSTATUS = 0xC0380053u32 as i32; pub const STATUS_VOLMGR_NUMBER_OF_DISKS_IN_PLEX_INVALID: ::NTSTATUS = 0xC0380054u32 as i32; pub const STATUS_VOLMGR_NUMBER_OF_DISKS_IN_MEMBER_INVALID: ::NTSTATUS = 0xC0380055u32 as i32; pub const STATUS_VOLMGR_VOLUME_MIRRORED: ::NTSTATUS = 0xC0380056u32 as i32; pub const STATUS_VOLMGR_PLEX_NOT_SIMPLE_SPANNED: ::NTSTATUS = 0xC0380057u32 as i32; pub const STATUS_VOLMGR_NO_VALID_LOG_COPIES: ::NTSTATUS = 0xC0380058u32 as i32; pub const STATUS_VOLMGR_PRIMARY_PACK_PRESENT: ::NTSTATUS = 0xC0380059u32 as i32; pub const STATUS_VOLMGR_NUMBER_OF_DISKS_INVALID: ::NTSTATUS = 0xC038005Au32 as i32; pub const STATUS_VOLMGR_MIRROR_NOT_SUPPORTED: ::NTSTATUS = 0xC038005Bu32 as i32; pub const STATUS_VOLMGR_RAID5_NOT_SUPPORTED: ::NTSTATUS = 0xC038005Cu32 as i32; pub const STATUS_BCD_NOT_ALL_ENTRIES_IMPORTED: ::NTSTATUS = 0x80390001u32 as i32; pub const STATUS_BCD_TOO_MANY_ELEMENTS: ::NTSTATUS = 0xC0390002u32 as i32; pub const STATUS_BCD_NOT_ALL_ENTRIES_SYNCHRONIZED: ::NTSTATUS = 0x80390003u32 as i32; pub const STATUS_VHD_DRIVE_FOOTER_MISSING: ::NTSTATUS = 0xC03A0001u32 as i32; pub const STATUS_VHD_DRIVE_FOOTER_CHECKSUM_MISMATCH: ::NTSTATUS = 0xC03A0002u32 as i32; pub const STATUS_VHD_DRIVE_FOOTER_CORRUPT: ::NTSTATUS = 0xC03A0003u32 as i32; pub const STATUS_VHD_FORMAT_UNKNOWN: ::NTSTATUS = 0xC03A0004u32 as i32; pub const STATUS_VHD_FORMAT_UNSUPPORTED_VERSION: ::NTSTATUS = 0xC03A0005u32 as i32; pub const STATUS_VHD_SPARSE_HEADER_CHECKSUM_MISMATCH: ::NTSTATUS = 0xC03A0006u32 as i32; pub const STATUS_VHD_SPARSE_HEADER_UNSUPPORTED_VERSION: ::NTSTATUS = 0xC03A0007u32 as i32; pub const STATUS_VHD_SPARSE_HEADER_CORRUPT: ::NTSTATUS = 0xC03A0008u32 as i32; pub const STATUS_VHD_BLOCK_ALLOCATION_FAILURE: ::NTSTATUS = 0xC03A0009u32 as i32; pub const STATUS_VHD_BLOCK_ALLOCATION_TABLE_CORRUPT: ::NTSTATUS = 0xC03A000Au32 as i32; pub const STATUS_VHD_INVALID_BLOCK_SIZE: ::NTSTATUS = 0xC03A000Bu32 as i32; pub const STATUS_VHD_BITMAP_MISMATCH: ::NTSTATUS = 0xC03A000Cu32 as i32; pub const STATUS_VHD_PARENT_VHD_NOT_FOUND: ::NTSTATUS = 0xC03A000Du32 as i32; pub const STATUS_VHD_CHILD_PARENT_ID_MISMATCH: ::NTSTATUS = 0xC03A000Eu32 as i32; pub const STATUS_VHD_CHILD_PARENT_TIMESTAMP_MISMATCH: ::NTSTATUS = 0xC03A000Fu32 as i32; pub const STATUS_VHD_METADATA_READ_FAILURE: ::NTSTATUS = 0xC03A0010u32 as i32; pub const STATUS_VHD_METADATA_WRITE_FAILURE: ::NTSTATUS = 0xC03A0011u32 as i32; pub const STATUS_VHD_INVALID_SIZE: ::NTSTATUS = 0xC03A0012u32 as i32; pub const STATUS_VHD_INVALID_FILE_SIZE: ::NTSTATUS = 0xC03A0013u32 as i32; pub const STATUS_VIRTDISK_PROVIDER_NOT_FOUND: ::NTSTATUS = 0xC03A0014u32 as i32; pub const STATUS_VIRTDISK_NOT_VIRTUAL_DISK: ::NTSTATUS = 0xC03A0015u32 as i32; pub const STATUS_VHD_PARENT_VHD_ACCESS_DENIED: ::NTSTATUS = 0xC03A0016u32 as i32; pub const STATUS_VHD_CHILD_PARENT_SIZE_MISMATCH: ::NTSTATUS = 0xC03A0017u32 as i32; pub const STATUS_VHD_DIFFERENCING_CHAIN_CYCLE_DETECTED: ::NTSTATUS = 0xC03A0018u32 as i32; pub const STATUS_VHD_DIFFERENCING_CHAIN_ERROR_IN_PARENT: ::NTSTATUS = 0xC03A0019u32 as i32; pub const STATUS_VIRTUAL_DISK_LIMITATION: ::NTSTATUS = 0xC03A001Au32 as i32; pub const STATUS_VHD_INVALID_TYPE: ::NTSTATUS = 0xC03A001Bu32 as i32; pub const STATUS_VHD_INVALID_STATE: ::NTSTATUS = 0xC03A001Cu32 as i32; pub const STATUS_VIRTDISK_UNSUPPORTED_DISK_SECTOR_SIZE: ::NTSTATUS = 0xC03A001Du32 as i32; pub const STATUS_VIRTDISK_DISK_ALREADY_OWNED: ::NTSTATUS = 0xC03A001Eu32 as i32; pub const STATUS_VIRTDISK_DISK_ONLINE_AND_WRITABLE: ::NTSTATUS = 0xC03A001Fu32 as i32; pub const STATUS_CTLOG_TRACKING_NOT_INITIALIZED: ::NTSTATUS = 0xC03A0020u32 as i32; pub const STATUS_CTLOG_LOGFILE_SIZE_EXCEEDED_MAXSIZE: ::NTSTATUS = 0xC03A0021u32 as i32; pub const STATUS_CTLOG_VHD_CHANGED_OFFLINE: ::NTSTATUS = 0xC03A0022u32 as i32; pub const STATUS_CTLOG_INVALID_TRACKING_STATE: ::NTSTATUS = 0xC03A0023u32 as i32; pub const STATUS_CTLOG_INCONSISTENT_TRACKING_FILE: ::NTSTATUS = 0xC03A0024u32 as i32; pub const STATUS_VHD_METADATA_FULL: ::NTSTATUS = 0xC03A0028u32 as i32; pub const STATUS_VHD_INVALID_CHANGE_TRACKING_ID: ::NTSTATUS = 0xC03A0029u32 as i32; pub const STATUS_VHD_CHANGE_TRACKING_DISABLED: ::NTSTATUS = 0xC03A002Au32 as i32; pub const STATUS_VHD_MISSING_CHANGE_TRACKING_INFORMATION: ::NTSTATUS = 0xC03A0030u32 as i32; pub const STATUS_VHD_RESIZE_WOULD_TRUNCATE_DATA: ::NTSTATUS = 0xC03A0031u32 as i32; pub const STATUS_VHD_COULD_NOT_COMPUTE_MINIMUM_VIRTUAL_SIZE: ::NTSTATUS = 0xC03A0032u32 as i32; pub const STATUS_VHD_ALREADY_AT_OR_BELOW_MINIMUM_VIRTUAL_SIZE: ::NTSTATUS = 0xC03A0033u32 as i32; pub const STATUS_QUERY_STORAGE_ERROR: ::NTSTATUS = 0x803A0001u32 as i32; pub const STATUS_RKF_KEY_NOT_FOUND: ::NTSTATUS = 0xC0400001u32 as i32; pub const STATUS_RKF_DUPLICATE_KEY: ::NTSTATUS = 0xC0400002u32 as i32; pub const STATUS_RKF_BLOB_FULL: ::NTSTATUS = 0xC0400003u32 as i32; pub const STATUS_RKF_STORE_FULL: ::NTSTATUS = 0xC0400004u32 as i32; pub const STATUS_RKF_FILE_BLOCKED: ::NTSTATUS = 0xC0400005u32 as i32; pub const STATUS_RKF_ACTIVE_KEY: ::NTSTATUS = 0xC0400006u32 as i32; pub const STATUS_RDBSS_RESTART_OPERATION: ::NTSTATUS = 0xC0410001u32 as i32; pub const STATUS_RDBSS_CONTINUE_OPERATION: ::NTSTATUS = 0xC0410002u32 as i32; pub const STATUS_RDBSS_POST_OPERATION: ::NTSTATUS = 0xC0410003u32 as i32; pub const STATUS_BTH_ATT_INVALID_HANDLE: ::NTSTATUS = 0xC0420001u32 as i32; pub const STATUS_BTH_ATT_READ_NOT_PERMITTED: ::NTSTATUS = 0xC0420002u32 as i32; pub const STATUS_BTH_ATT_WRITE_NOT_PERMITTED: ::NTSTATUS = 0xC0420003u32 as i32; pub const STATUS_BTH_ATT_INVALID_PDU: ::NTSTATUS = 0xC0420004u32 as i32; pub const STATUS_BTH_ATT_INSUFFICIENT_AUTHENTICATION: ::NTSTATUS = 0xC0420005u32 as i32; pub const STATUS_BTH_ATT_REQUEST_NOT_SUPPORTED: ::NTSTATUS = 0xC0420006u32 as i32; pub const STATUS_BTH_ATT_INVALID_OFFSET: ::NTSTATUS = 0xC0420007u32 as i32; pub const STATUS_BTH_ATT_INSUFFICIENT_AUTHORIZATION: ::NTSTATUS = 0xC0420008u32 as i32; pub const STATUS_BTH_ATT_PREPARE_QUEUE_FULL: ::NTSTATUS = 0xC0420009u32 as i32; pub const STATUS_BTH_ATT_ATTRIBUTE_NOT_FOUND: ::NTSTATUS = 0xC042000Au32 as i32; pub const STATUS_BTH_ATT_ATTRIBUTE_NOT_LONG: ::NTSTATUS = 0xC042000Bu32 as i32; pub const STATUS_BTH_ATT_INSUFFICIENT_ENCRYPTION_KEY_SIZE: ::NTSTATUS = 0xC042000Cu32 as i32; pub const STATUS_BTH_ATT_INVALID_ATTRIBUTE_VALUE_LENGTH: ::NTSTATUS = 0xC042000Du32 as i32; pub const STATUS_BTH_ATT_UNLIKELY: ::NTSTATUS = 0xC042000Eu32 as i32; pub const STATUS_BTH_ATT_INSUFFICIENT_ENCRYPTION: ::NTSTATUS = 0xC042000Fu32 as i32; pub const STATUS_BTH_ATT_UNSUPPORTED_GROUP_TYPE: ::NTSTATUS = 0xC0420010u32 as i32; pub const STATUS_BTH_ATT_INSUFFICIENT_RESOURCES: ::NTSTATUS = 0xC0420011u32 as i32; pub const STATUS_BTH_ATT_UNKNOWN_ERROR: ::NTSTATUS = 0xC0421000u32 as i32; pub const STATUS_SECUREBOOT_ROLLBACK_DETECTED: ::NTSTATUS = 0xC0430001u32 as i32; pub const STATUS_SECUREBOOT_POLICY_VIOLATION: ::NTSTATUS = 0xC0430002u32 as i32; pub const STATUS_SECUREBOOT_INVALID_POLICY: ::NTSTATUS = 0xC0430003u32 as i32; pub const STATUS_SECUREBOOT_POLICY_PUBLISHER_NOT_FOUND: ::NTSTATUS = 0xC0430004u32 as i32; pub const STATUS_SECUREBOOT_POLICY_NOT_SIGNED: ::NTSTATUS = 0xC0430005u32 as i32; pub const STATUS_SECUREBOOT_NOT_ENABLED: ::NTSTATUS = 0x80430006u32 as i32; pub const STATUS_SECUREBOOT_FILE_REPLACED: ::NTSTATUS = 0xC0430007u32 as i32; pub const STATUS_SYSTEM_INTEGRITY_ROLLBACK_DETECTED: ::NTSTATUS = 0xC0E90001u32 as i32; pub const STATUS_SYSTEM_INTEGRITY_POLICY_VIOLATION: ::NTSTATUS = 0xC0E90002u32 as i32; pub const STATUS_SYSTEM_INTEGRITY_INVALID_POLICY: ::NTSTATUS = 0xC0E90003u32 as i32; pub const STATUS_SYSTEM_INTEGRITY_POLICY_NOT_SIGNED: ::NTSTATUS = 0xC0E90004u32 as i32; pub const STATUS_NO_APPLICABLE_APP_LICENSES_FOUND: ::NTSTATUS = 0xC0EA0001u32 as i32; pub const STATUS_AUDIO_ENGINE_NODE_NOT_FOUND: ::NTSTATUS = 0xC0440001u32 as i32; pub const STATUS_HDAUDIO_EMPTY_CONNECTION_LIST: ::NTSTATUS = 0xC0440002u32 as i32; pub const STATUS_HDAUDIO_CONNECTION_LIST_NOT_SUPPORTED: ::NTSTATUS = 0xC0440003u32 as i32; pub const STATUS_HDAUDIO_NO_LOGICAL_DEVICES_CREATED: ::NTSTATUS = 0xC0440004u32 as i32; pub const STATUS_HDAUDIO_NULL_LINKED_LIST_ENTRY: ::NTSTATUS = 0xC0440005u32 as i32; pub const STATUS_SPACES_RESILIENCY_TYPE_INVALID: ::NTSTATUS = 0xC0E70003u32 as i32; pub const STATUS_SPACES_DRIVE_SECTOR_SIZE_INVALID: ::NTSTATUS = 0xC0E70004u32 as i32; pub const STATUS_SPACES_DRIVE_REDUNDANCY_INVALID: ::NTSTATUS = 0xC0E70006u32 as i32; pub const STATUS_SPACES_NUMBER_OF_DATA_COPIES_INVALID: ::NTSTATUS = 0xC0E70007u32 as i32; pub const STATUS_SPACES_INTERLEAVE_LENGTH_INVALID: ::NTSTATUS = 0xC0E70009u32 as i32; pub const STATUS_SPACES_NUMBER_OF_COLUMNS_INVALID: ::NTSTATUS = 0xC0E7000Au32 as i32; pub const STATUS_SPACES_NOT_ENOUGH_DRIVES: ::NTSTATUS = 0xC0E7000Bu32 as i32; pub const STATUS_SPACES_EXTENDED_ERROR: ::NTSTATUS = 0xC0E7000Cu32 as i32; pub const STATUS_SPACES_PROVISIONING_TYPE_INVALID: ::NTSTATUS = 0xC0E7000Du32 as i32; pub const STATUS_SPACES_ALLOCATION_SIZE_INVALID: ::NTSTATUS = 0xC0E7000Eu32 as i32; pub const STATUS_SPACES_ENCLOSURE_AWARE_INVALID: ::NTSTATUS = 0xC0E7000Fu32 as i32; pub const STATUS_SPACES_WRITE_CACHE_SIZE_INVALID: ::NTSTATUS = 0xC0E70010u32 as i32; pub const STATUS_SPACES_NUMBER_OF_GROUPS_INVALID: ::NTSTATUS = 0xC0E70011u32 as i32; pub const STATUS_SPACES_DRIVE_OPERATIONAL_STATE_INVALID: ::NTSTATUS = 0xC0E70012u32 as i32; pub const STATUS_SPACES_UPDATE_COLUMN_STATE: ::NTSTATUS = 0xC0E70013u32 as i32; pub const STATUS_SPACES_MAP_REQUIRED: ::NTSTATUS = 0xC0E70014u32 as i32; pub const STATUS_SPACES_UNSUPPORTED_VERSION: ::NTSTATUS = 0xC0E70015u32 as i32; pub const STATUS_SPACES_CORRUPT_METADATA: ::NTSTATUS = 0xC0E70016u32 as i32; pub const STATUS_SPACES_DRT_FULL: ::NTSTATUS = 0xC0E70017u32 as i32; pub const STATUS_SPACES_INCONSISTENCY: ::NTSTATUS = 0xC0E70018u32 as i32; pub const STATUS_SPACES_LOG_NOT_READY: ::NTSTATUS = 0xC0E70019u32 as i32; pub const STATUS_SPACES_NO_REDUNDANCY: ::NTSTATUS = 0xC0E7001Au32 as i32; pub const STATUS_SPACES_DRIVE_NOT_READY: ::NTSTATUS = 0xC0E7001Bu32 as i32; pub const STATUS_SPACES_REPAIRED: ::NTSTATUS = 0x00E7001C; pub const STATUS_SPACES_PAUSE: ::NTSTATUS = 0x00E7001D; pub const STATUS_SPACES_COMPLETE: ::NTSTATUS = 0x00E7001E; pub const STATUS_VOLSNAP_BOOTFILE_NOT_VALID: ::NTSTATUS = 0xC0500003u32 as i32; pub const STATUS_IO_PREEMPTED: ::NTSTATUS = 0xC0510001u32 as i32; pub const STATUS_SVHDX_ERROR_STORED: ::NTSTATUS = 0xC05C0000u32 as i32; pub const STATUS_SVHDX_ERROR_NOT_AVAILABLE: ::NTSTATUS = 0xC05CFF00u32 as i32; pub const STATUS_SVHDX_UNIT_ATTENTION_AVAILABLE: ::NTSTATUS = 0xC05CFF01u32 as i32; pub const STATUS_SVHDX_UNIT_ATTENTION_CAPACITY_DATA_CHANGED: ::NTSTATUS = 0xC05CFF02u32 as i32; pub const STATUS_SVHDX_UNIT_ATTENTION_RESERVATIONS_PREEMPTED: ::NTSTATUS = 0xC05CFF03u32 as i32; pub const STATUS_SVHDX_UNIT_ATTENTION_RESERVATIONS_RELEASED: ::NTSTATUS = 0xC05CFF04u32 as i32; pub const STATUS_SVHDX_UNIT_ATTENTION_REGISTRATIONS_PREEMPTED: ::NTSTATUS = 0xC05CFF05u32 as i32; pub const STATUS_SVHDX_UNIT_ATTENTION_OPERATING_DEFINITION_CHANGED: ::NTSTATUS = 0xC05CFF06u32 as i32; pub const STATUS_SVHDX_RESERVATION_CONFLICT: ::NTSTATUS = 0xC05CFF07u32 as i32; pub const STATUS_SVHDX_WRONG_FILE_TYPE: ::NTSTATUS = 0xC05CFF08u32 as i32; pub const STATUS_SVHDX_VERSION_MISMATCH: ::NTSTATUS = 0xC05CFF09u32 as i32; pub const STATUS_VHD_SHARED: ::NTSTATUS = 0xC05CFF0Au32 as i32; pub const STATUS_SVHDX_NO_INITIATOR: ::NTSTATUS = 0xC05CFF0Bu32 as i32; pub const STATUS_VHDSET_BACKING_STORAGE_NOT_FOUND: ::NTSTATUS = 0xC05CFF0Cu32 as i32; pub const STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP: ::NTSTATUS = 0xC05D0000u32 as i32; pub const STATUS_SMB_BAD_CLUSTER_DIALECT: ::NTSTATUS = 0xC05D0001u32 as i32; pub const STATUS_SMB_GUEST_LOGON_BLOCKED: ::NTSTATUS = 0xC05D0002u32 as i32; pub const STATUS_SECCORE_INVALID_COMMAND: ::NTSTATUS = 0xC0E80000u32 as i32; pub const STATUS_VSM_NOT_INITIALIZED: ::NTSTATUS = 0xC0450000u32 as i32; pub const STATUS_VSM_DMA_PROTECTION_NOT_IN_USE: ::NTSTATUS = 0xC0450001u32 as i32; deps/winapi-0.2.5/src/vsbackup.rs0000644000000000000000000003362712613167613015432 0ustar rootroot// Copyright © 2015, Brian Vincent // Licensed under the MIT License //! VSS backup interfaces DEFINE_GUID!(IID_IVssExamineWriterMetadata, 0x902fcf7f, 0xb7fd, 0x42f8, 0x81, 0xf1, 0xb2, 0xe4, 0x00, 0xb1, 0xe5, 0xbd); DEFINE_GUID!(IID_IVssExamineWriterMetadataEx, 0x0c0e5ec0, 0xca44, 0x472b, 0xb7, 0x02, 0xe6, 0x52, 0xdb, 0x1c, 0x04, 0x51); DEFINE_GUID!(IID_IVssBackupComponents, 0x665c1d5f, 0xc218, 0x414d, 0xa0, 0x5d, 0x7f, 0xef, 0x5f, 0x9d, 0x5c, 0x86); DEFINE_GUID!(IID_IVssBackupComponentsEx, 0x963f03ad, 0x9e4c, 0x4a34, 0xac, 0x15, 0xe4, 0xb6, 0x17, 0x4e, 0x50, 0x36); STRUCT!{struct VSS_COMPONENTINFO { type_: ::VSS_COMPONENT_TYPE, // type is a keyword in rust bstrLogicalPath: ::BSTR, bstrComponentName: ::BSTR, bstrCaption: ::BSTR, pbIcon: *mut ::BYTE, cbIcon: ::UINT, bRestoreMetadata: bool, bNotifyOnBackupComplete: bool, bSelectable: bool, bSelectableForRestore: bool, dwComponentFlags: ::DWORD, cFileCount: ::UINT, cDatabases: ::UINT, cLogFiles: ::UINT, cDependencies: ::UINT, }} pub type PVSSCOMPONENTINFO = *const ::VSS_COMPONENTINFO; RIDL!( interface IVssWMComponent(IVssWMComponentVtbl): IUnknown(IUnknownVtbl) { fn GetComponentInfo(&mut self, ppInfo: *mut ::PVSSCOMPONENTINFO) -> ::HRESULT, fn FreeComponentInfo(&mut self, pInfo: ::PVSSCOMPONENTINFO) -> ::HRESULT, fn GetFile(&mut self, iFile: ::UINT, ppFiledesc: *mut *mut ::IVssWMFiledesc) -> ::HRESULT, fn GetDatabaseFile( &mut self, iDBFile: ::UINT, ppFiledesc: *mut *mut ::IVssWMFiledesc ) -> ::HRESULT, fn GetDatabaseLogFile( &mut self, iDbLogFile: ::UINT, ppFiledesc: *mut *mut ::IVssWMFiledesc ) -> ::HRESULT, fn GetDependency( &mut self, iDependency: ::UINT, ppDependency: *mut *mut ::IVssWMDependency ) -> ::HRESULT } ); RIDL!( interface IVssExamineWriterMetadata(IVssExamineWriterMetadataVtbl): IUnknown(IUnknownVtbl) { fn GetIdentity( &mut self, pidInstance: *mut ::VSS_ID, pidWriter: *mut ::VSS_ID, pbstrWriterName: *mut ::BSTR, pUsage: *mut ::VSS_USAGE_TYPE, pSource: *mut ::VSS_SOURCE_TYPE ) -> ::HRESULT, fn GetFileCounts(&mut self, pcIncludeFiles: *mut ::UINT, pcExcludeFiles: *mut ::UINT, pcComponents: *mut ::UINT ) -> ::HRESULT, fn GetIncludeFile( &mut self, iFile: ::UINT, ppFiledesc: *mut *mut ::IVssWMFiledesc ) -> ::HRESULT, fn GetExcludeFile( &mut self, iFile: ::UINT, ppFiledesc: *mut *mut ::IVssWMFiledesc ) -> ::HRESULT, fn GetComponent( &mut self, iComponent: ::UINT, ppComponent: *mut *mut ::IVssWMComponent ) -> ::HRESULT, fn GetRestoreMethod( &mut self, pMethod: *mut ::VSS_RESTOREMETHOD_ENUM, pbstrService: *mut ::BSTR, pbstrUserProcedure: *mut ::BSTR, pwriterRestore: *mut ::VSS_WRITERRESTORE_ENUM, pbRebootRequired: *mut bool, pcMappings: *mut ::UINT ) -> ::HRESULT, fn GetAlternateLocationMapping( &mut self, iMapping: ::UINT, ppFiledesc: *mut *mut ::IVssWMFiledesc ) -> ::HRESULT, fn GetBackupSchema(&mut self, pdwSchemaMask: *mut ::DWORD) -> ::HRESULT, fn GetDocument(&mut self, pDoc: *mut ::c_void) -> ::HRESULT, //TODO IXMLDOMDocument fn SaveAsXML(&mut self, pbstrXML: *mut ::BSTR) -> ::HRESULT, fn LoadFromXML(&mut self, pbstrXML: *mut ::BSTR) -> ::HRESULT } ); RIDL!( interface IVssExamineWriterMetadataEx(IVssExamineWriterMetadataExVtbl): IVssExamineWriterMetadata(IVssExamineWriterMetadataVtbl) { fn GetIdentityEx( &mut self, pidInstance: *mut ::VSS_ID, pidWriter: *mut ::VSS_ID, pbstrWriterName: *mut ::BSTR, pbstrInstanceName: *mut ::BSTR, pUsage: *mut ::VSS_USAGE_TYPE, pSource: *mut ::VSS_SOURCE_TYPE ) -> ::HRESULT } ); RIDL!( interface IVssExamineWriterMetadataEx2(IVssExamineWriterMetadataEx2Vtbl): IVssExamineWriterMetadataEx(IVssExamineWriterMetadataExVtbl) { fn GetVersion( &mut self, pdwMajorVersion: *mut ::DWORD, pdwMinorVersion: *mut ::DWORD ) -> ::HRESULT, fn GetExcludeFromSnapshotCount(&mut self, pcExcludedFromSnapshot: *mut ::UINT) -> ::HRESULT, fn GetExcludeFromSnapshotFile( &mut self, iFile: ::UINT, ppFiledesc: *mut *mut ::IVssWMFiledesc ) -> ::HRESULT } ); #[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct IVssWriterComponentsExt { pub lpVtbl: *const IVssWriterComponentsExtVtbl, } #[repr(C)] #[allow(missing_copy_implementations)] pub struct IVssWriterComponentsExtVtbl { pub parent1: ::IVssWriterComponentsVtbl, pub parent2: ::IUnknownVtbl, } RIDL!( interface IVssBackupComponents(IVssBackupComponentsVtbl): IUnknown(IUnknownVtbl) { fn GetWriterComponentsCount(&mut self, pcComponents: *mut ::UINT) -> ::HRESULT, fn GetWriterComponents( &mut self, iWriter: ::UINT, ppWriter: *mut *mut IVssWriterComponentsExt ) -> ::HRESULT, fn InitializeForBackup(&mut self, bstrXML: ::BSTR) -> ::HRESULT, fn SetBackupState( &mut self, bSelectComponents: bool, bBackupBootableSystemState: bool, backupType: ::VSS_BACKUP_TYPE, bPartialFileSupport: bool ) -> ::HRESULT, fn InitializeForRestore(&mut self, bstrXML: ::BSTR) -> ::HRESULT, fn SetRestoreState(&mut self, restoreType: ::VSS_RESTORE_TYPE) -> ::HRESULT, fn GatherWriterMetadata(&mut self, pAsync: *mut *mut ::IVssAsync) -> ::HRESULT, fn GetWriterMetadataCount(&mut self, pcWriters: *mut ::UINT) -> ::HRESULT, fn GetWriterMetadata( &mut self, iWriter: ::UINT, pidInstance: *mut ::VSS_ID, ppMetadata: *mut *mut IVssExamineWriterMetadata ) -> ::HRESULT, fn FreeWriterMetadata(&mut self) -> ::HRESULT, fn AddComponent( &mut self, instanceId: ::VSS_ID, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR ) -> ::HRESULT, fn PrepareForBackup(&mut self, ppAsync: *mut *mut ::IVssAsync) -> ::HRESULT, fn AbortBackup(&mut self) -> ::HRESULT, fn GatherWriterStatus(&mut self, ppAsync: *mut *mut ::IVssAsync) -> ::HRESULT, fn GetWriterStatusCount(&mut self, pcWriters: *mut ::UINT) -> ::HRESULT, fn FreeWriterStatus(&mut self) -> ::HRESULT, fn GetWriterStatus( &mut self, iWriter: ::UINT, pidInstance: *mut ::VSS_ID, pidWriter: *mut ::VSS_ID, pbstrWriter: *mut ::BSTR, pnStatus: *mut ::VSS_WRITER_STATE, phResultFailure: *mut ::HRESULT ) -> ::HRESULT, fn SetBackupSucceeded( &mut self, instanceId: ::VSS_ID, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, bSucceded: bool ) -> ::HRESULT, fn SetBackupOptions( &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, wszBackupOptions: ::LPCWSTR ) -> ::HRESULT, fn SetSelectedForRestore( &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, bSelectedForRestore: bool ) -> ::HRESULT, fn SetRestoreOptions( &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, wszRestoreOptions: ::LPCWSTR ) -> ::HRESULT, fn SetAdditionalRestores( &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, bAdditionalRestores: bool ) -> ::HRESULT, fn SetPreviousBackupStamp( &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, wszPreviousBackupStamp: ::LPCWSTR ) -> ::HRESULT, fn SaveAsXML(&mut self, pbstrXML: *mut ::BSTR) -> ::HRESULT, fn BackupComplete(&mut self, ppAsync: *mut *mut ::IVssAsync) -> ::HRESULT, fn AddAlternativeLocationMapping( &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, wszPath: ::LPCWSTR, wszFilespec: ::LPCWSTR, bRecursive: bool, wszDestination: ::LPCWSTR ) -> ::HRESULT, fn AddRestoreSubcomponent( &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, wszSubComponentLogicalPath: ::LPCWSTR, wszSubComponentName: ::LPCWSTR, bRepair: bool ) -> ::HRESULT, fn SetFileRestoreStatus( &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, status: ::VSS_FILE_RESTORE_STATUS ) -> ::HRESULT, fn AddNewTarget( &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, wszPath: ::LPCWSTR, wszFileName: ::LPCWSTR, bRecursive: bool, wszAlternatePath: ::LPCWSTR ) -> ::HRESULT, fn SetRangesFilePath( &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, iPartialFile: ::UINT, wszRangesFile: ::LPCWSTR ) -> ::HRESULT, fn PreRestore(&mut self, ppAsync: *mut *mut ::IVssAsync) -> ::HRESULT, fn PostRestore(&mut self, ppAsync: *mut *mut ::IVssAsync) -> ::HRESULT, fn SetContext(&mut self, lContext: ::LONG) -> ::HRESULT, fn StartSnapshotSet(&mut self, pSnapshotSetId: *mut ::VSS_ID) -> ::HRESULT, fn AddToSnapshotSet( &mut self, pwszVolumeName: ::VSS_PWSZ, ProviderId: ::VSS_ID, pidSnapshot: *mut ::VSS_ID ) -> ::HRESULT, fn DoSnapshotSet(&mut self, ppAsync: *mut *mut ::IVssAsync) -> ::HRESULT, fn DeleteSnapshots( &mut self, SourceObjectId: ::VSS_ID, eSourceObjectType: ::VSS_OBJECT_TYPE, bForceDelete: ::BOOL, plDeletedSnapshots: *mut ::LONG, pNondeletedSnapshotID: *mut ::VSS_ID ) -> ::HRESULT, fn ImportSnapshots(&mut self, ppAsync: *mut *mut ::IVssAsync) -> ::HRESULT, fn BreakSnapshotSet(&mut self, SnapshotSetId: ::VSS_ID) -> ::HRESULT, fn GetSnapshotProperties( &mut self, SnapshotId: ::VSS_ID, pProp: *mut ::VSS_SNAPSHOT_PROP ) -> ::HRESULT, fn Query(&mut self, QueriedObjectId: ::VSS_ID, eQueriedObjectType: ::VSS_OBJECT_TYPE, eReturnedObjectsType: ::VSS_OBJECT_TYPE, ppEnum: *mut *mut ::IVssEnumObject) -> ::HRESULT, fn IsVolumeSupported( &mut self, ProviderId: ::VSS_ID, pwszVolumeName: ::VSS_PWSZ, pbSupportedByThisProvider: *mut ::BOOL ) -> ::HRESULT, fn DisableWriterClasses( &mut self, rgWriterClassId: *const ::VSS_ID, cClassId: ::UINT ) -> ::HRESULT, fn EnableWriterClasses( &mut self, rgWriterClassId: *const ::VSS_ID, cClassId: ::UINT ) -> ::HRESULT, fn DisableWriterInstances( &mut self, rgWriterInstanceId: *const ::VSS_ID, cInstanceId: ::UINT ) -> ::HRESULT, fn ExposeSnapshot(&mut self, SnapshotId: ::VSS_ID, wszPathFromRoot: ::VSS_PWSZ, lAttributes: ::LONG, wszExpose: ::VSS_PWSZ, pwszExposed: ::VSS_PWSZ ) -> ::HRESULT, fn RevertToSnapshot(&mut self, SnapshotId: ::VSS_ID, bForceDismount: ::BOOL) -> ::HRESULT, fn QueryRevertStatus( &mut self, pwszVolume: ::VSS_PWSZ, ppAsync: *mut *mut ::IVssAsync ) -> ::HRESULT } ); RIDL!( interface IVssBackupComponentsEx(IVssBackupComponentsExVtbl): IVssBackupComponents(IVssBackupComponentsVtbl) { fn GetWriterMetadataEx( &mut self, iWriter: ::UINT, pidInstance: *mut ::VSS_ID, ppMetadata: *mut *mut ::IVssExamineWriterMetadataEx ) -> ::HRESULT, fn SetSelectedForRestoreEx( &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, bSelectedForRestore: bool, instanceId: ::VSS_ID ) -> ::HRESULT } ); RIDL!( interface IVssBackupComponentsEx2(IVssBackupComponentsEx2Vtbl): IVssBackupComponentsEx(IVssBackupComponentsExVtbl) { fn UnexposeSnapshot(&mut self, snapshotId: ::VSS_ID) -> ::HRESULT, fn SetAuthoritativeRestore( &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, bAuth: bool ) -> ::HRESULT, fn SetRollForward( &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, rollType: ::VSS_ROLLFORWARD_TYPE, wszRollForwardPoint: ::LPCWSTR ) -> ::HRESULT, fn SetRestoreName( &mut self, writerId: ::VSS_ID, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, wszRestoreName: ::LPCWSTR ) -> ::HRESULT, fn BreakSnapshotSetEx( &mut self, SnapshotSetID: ::VSS_ID, dwBreakFlags: ::DWORD, ppAsync: *mut *mut ::IVssAsync ) -> ::HRESULT, fn PreFastRecovery( &mut self, SnapshotSetID: ::VSS_ID, dwPreFastRecoveryFlags: ::DWORD, ppAsync: *mut *mut ::IVssAsync ) -> ::HRESULT, fn FastRecovery( &mut self, SnapshotSetID: ::VSS_ID, dwFastRecoveryFlags: ::DWORD, ppAsync: *mut *mut ::IVssAsync ) -> ::HRESULT } ); RIDL!( interface IVssBackupComponentsEx3(IVssBackupComponentsEx3Vtbl): IVssBackupComponentsEx2(IVssBackupComponentsEx2Vtbl) { fn GetWriterStatusEx( &mut self, iWriter: ::UINT, pidInstance: *mut ::VSS_ID, pidWriter: *mut ::VSS_ID, pbstrWriter: *mut ::BSTR, pnStatus: *mut ::VSS_WRITER_STATE, phrFailureWriter: *mut ::HRESULT, phrApplication: *mut ::HRESULT, pbstrApplicationMessage: *mut ::BSTR ) -> ::HRESULT, fn AddSnapshotToRecoverySet( &mut self, snapshotId: ::VSS_ID, dwFlags: ::DWORD, pwszDestinationVolume: ::VSS_PWSZ ) -> ::HRESULT, fn RecoverSet(&mut self, dwFlags: ::DWORD, ppAsync: *mut *mut ::IVssAsync) -> ::HRESULT, fn GetSessionId(&mut self, idSession: *mut ::VSS_ID) -> ::HRESULT } ); RIDL!( interface IVssBackupComponentsEx4(IVssBackupComponentsEx4Vtbl): IVssBackupComponentsEx3(IVssBackupComponentsEx3Vtbl) { fn GetRootAndLogicalPrefixPaths( &mut self, pwszFilePath: ::VSS_PWSZ, ppwszRootPath: *mut ::VSS_PWSZ, ppwszLogicalPrefix: *mut ::VSS_PWSZ, bNormalizeFQDNforRootPath: ::BOOL ) -> ::HRESULT } ); pub const VSS_SW_BOOTABLE_STATE: ::DWORD = 1; deps/winapi-0.2.5/src/heapapi.rs0000644000000000000000000000056712613167613015220 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! ApiSet Contract for api-ms-win-core-heap-l1 STRUCT!{struct HEAP_SUMMARY { cb: ::DWORD, cbAllocated: ::SIZE_T, cbCommitted: ::SIZE_T, cbReserved: ::SIZE_T, cbMaxReserve: ::SIZE_T, }} pub type PHEAP_SUMMARY = *mut HEAP_SUMMARY; pub type LPHEAP_SUMMARY = PHEAP_SUMMARY; deps/winapi-0.2.5/src/lmjoin.rs0000644000000000000000000000713012613167613015072 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License // Definitions and prototypes for the Net setup apis ENUM!{enum NETSETUP_NAME_TYPE { NetSetupUnknown = 0, NetSetupMachine, NetSetupWorkgroup, NetSetupDomain, NetSetupNonExistentDomain, NetSetupDnsMachine, }} pub type PNETSETUP_NAME_TYPE = *mut NETSETUP_NAME_TYPE; ENUM!{enum NETSETUP_JOIN_STATUS { NetSetupUnknownStatus = 0, NetSetupUnjoined, NetSetupWorkgroupName, NetSetupDomainName, }} pub type PNETSETUP_JOIN_STATUS = *mut NETSETUP_JOIN_STATUS; pub const NETSETUP_JOIN_DOMAIN: ::DWORD = 0x00000001; pub const NETSETUP_ACCT_CREATE: ::DWORD = 0x00000002; pub const NETSETUP_ACCT_DELETE: ::DWORD = 0x00000004; pub const NETSETUP_WIN9X_UPGRADE: ::DWORD = 0x00000010; pub const NETSETUP_DOMAIN_JOIN_IF_JOINED: ::DWORD = 0x00000020; pub const NETSETUP_JOIN_UNSECURE: ::DWORD = 0x00000040; pub const NETSETUP_MACHINE_PWD_PASSED: ::DWORD = 0x00000080; pub const NETSETUP_DEFER_SPN_SET: ::DWORD = 0x00000100; pub const NETSETUP_JOIN_DC_ACCOUNT: ::DWORD = 0x00000200; pub const NETSETUP_JOIN_WITH_NEW_NAME: ::DWORD = 0x00000400; pub const NETSETUP_JOIN_READONLY: ::DWORD = 0x00000800; pub const NETSETUP_DNS_NAME_CHANGES_ONLY: ::DWORD = 0x00001000; pub const NETSETUP_INSTALL_INVOCATION: ::DWORD = 0x00040000; pub const NETSETUP_AMBIGUOUS_DC: ::DWORD = 0x00001000; pub const NETSETUP_NO_NETLOGON_CACHE: ::DWORD = 0x00002000; pub const NETSETUP_DONT_CONTROL_SERVICES: ::DWORD = 0x00004000; pub const NETSETUP_SET_MACHINE_NAME: ::DWORD = 0x00008000; pub const NETSETUP_FORCE_SPN_SET: ::DWORD = 0x00010000; pub const NETSETUP_NO_ACCT_REUSE: ::DWORD = 0x00020000; pub const NETSETUP_ALT_SAMACCOUNTNAME: ::DWORD = 0x00020000; pub const NETSETUP_IGNORE_UNSUPPORTED_FLAGS: ::DWORD = 0x10000000; pub const NETSETUP_VALID_UNJOIN_FLAGS: ::DWORD = NETSETUP_ACCT_DELETE | NETSETUP_IGNORE_UNSUPPORTED_FLAGS | NETSETUP_JOIN_DC_ACCOUNT; pub const NETSETUP_PROCESS_OFFLINE_FLAGS: ::DWORD = NETSETUP_JOIN_DOMAIN | NETSETUP_DOMAIN_JOIN_IF_JOINED | NETSETUP_JOIN_WITH_NEW_NAME | NETSETUP_DONT_CONTROL_SERVICES | NETSETUP_MACHINE_PWD_PASSED; pub const NETSETUP_PROVISION_DOWNLEVEL_PRIV_SUPPORT: ::DWORD = 0x00000001; pub const NETSETUP_PROVISION_REUSE_ACCOUNT: ::DWORD = 0x00000002; pub const NETSETUP_PROVISION_USE_DEFAULT_PASSWORD: ::DWORD = 0x00000004; pub const NETSETUP_PROVISION_SKIP_ACCOUNT_SEARCH: ::DWORD = 0x00000008; pub const NETSETUP_PROVISION_ROOT_CA_CERTS: ::DWORD = 0x00000010; pub const NETSETUP_PROVISION_PERSISTENTSITE: ::DWORD = 0x00000020; pub const NETSETUP_PROVISION_ONLINE_CALLER: ::DWORD = 0x40000000; pub const NETSETUP_PROVISION_CHECK_PWD_ONLY: ::DWORD = 0x80000000; pub const NETSETUP_PROVISIONING_PARAMS_WIN8_VERSION: ::DWORD = 0x00000001; pub const NETSETUP_PROVISIONING_PARAMS_CURRENT_VERSION: ::DWORD = 0x00000002; STRUCT!{struct NETSETUP_PROVISIONING_PARAMS { dwVersion: ::DWORD, lpDomain: ::LPCWSTR, lpHostName: ::LPCWSTR, lpMachineAccountOU: ::LPCWSTR, lpDcName: ::LPCWSTR, dwProvisionOptions: ::DWORD, aCertTemplateNames: *mut ::LPCWSTR, cCertTemplateNames: ::DWORD, aMachinePolicyNames: *mut ::LPCWSTR, cMachinePolicyNames: ::DWORD, aMachinePolicyPaths: *mut ::LPCWSTR, cMachinePolicyPaths: ::DWORD, lpNetbiosName: ::LPWSTR, lpSiteName: ::LPWSTR, lpPrimaryDNSDomain: ::LPWSTR, }} pub type PNETSETUP_PROVISIONING_PARAMS = *mut NETSETUP_PROVISIONING_PARAMS; ENUM!{enum NET_COMPUTER_NAME_TYPE { NetPrimaryComputerName, NetAlternateComputerNames, NetAllComputerNames, NetComputerNameTypeMax, }} pub type PNET_COMPUTER_NAME_TYPE = *mut NET_COMPUTER_NAME_TYPE; deps/winapi-0.2.5/src/lmaccess.rs0000644000000000000000000010331312613167613015374 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License // This file contains structures, function prototypes, and definitions // for the NetUser, NetUserModals, NetGroup, NetAccess, and NetLogon API. STRUCT!{struct USER_INFO_0 { usri0_name: ::LPWSTR, }} pub type PUSER_INFO_0 = *mut USER_INFO_0; pub type LPUSER_INFO_0 = *mut USER_INFO_0; STRUCT!{struct USER_INFO_1 { usri1_name: ::LPWSTR, usri1_password: ::LPWSTR, usri1_password_age: ::DWORD, usri1_priv: ::DWORD, usri1_home_dir: ::LPWSTR, usri1_comment: ::LPWSTR, usri1_flags: ::DWORD, usri1_script_path: ::LPWSTR, }} pub type PUSER_INFO_1 = *mut USER_INFO_1; pub type LPUSER_INFO_1 = *mut USER_INFO_1; STRUCT!{struct USER_INFO_2 { usri2_name: ::LPWSTR, usri2_password: ::LPWSTR, usri2_password_age: ::DWORD, usri2_priv: ::DWORD, usri2_home_dir: ::LPWSTR, usri2_comment: ::LPWSTR, usri2_flags: ::DWORD, usri2_script_path: ::LPWSTR, usri2_auth_flags: ::DWORD, usri2_full_name: ::LPWSTR, usri2_usr_comment: ::LPWSTR, usri2_parms: ::LPWSTR, usri2_workstations: ::LPWSTR, usri2_last_logon: ::DWORD, usri2_last_logoff: ::DWORD, usri2_acct_expires: ::DWORD, usri2_max_storage: ::DWORD, usri2_units_per_week: ::DWORD, usri2_logon_hours: ::PBYTE, usri2_bad_pw_count: ::DWORD, usri2_num_logons: ::DWORD, usri2_logon_server: ::LPWSTR, usri2_country_code: ::DWORD, usri2_code_page: ::DWORD, }} pub type PUSER_INFO_2 = *mut USER_INFO_2; pub type LPUSER_INFO_2 = *mut USER_INFO_2; STRUCT!{struct USER_INFO_3 { usri3_name: ::LPWSTR, usri3_password: ::LPWSTR, usri3_password_age: ::DWORD, usri3_priv: ::DWORD, usri3_home_dir: ::LPWSTR, usri3_comment: ::LPWSTR, usri3_flags: ::DWORD, usri3_script_path: ::LPWSTR, usri3_auth_flags: ::DWORD, usri3_full_name: ::LPWSTR, usri3_usr_comment: ::LPWSTR, usri3_parms: ::LPWSTR, usri3_workstations: ::LPWSTR, usri3_last_logon: ::DWORD, usri3_last_logoff: ::DWORD, usri3_acct_expires: ::DWORD, usri3_max_storage: ::DWORD, usri3_units_per_week: ::DWORD, usri3_logon_hours: ::PBYTE, usri3_bad_pw_count: ::DWORD, usri3_num_logons: ::DWORD, usri3_logon_server: ::LPWSTR, usri3_country_code: ::DWORD, usri3_code_page: ::DWORD, usri3_user_id: ::DWORD, usri3_primary_group_id: ::DWORD, usri3_profile: ::LPWSTR, usri3_home_dir_drive: ::LPWSTR, usri3_password_expired: ::DWORD, }} pub type PUSER_INFO_3 = *mut USER_INFO_3; pub type LPUSER_INFO_3 = *mut USER_INFO_3; STRUCT!{struct USER_INFO_4 { usri4_name: ::LPWSTR, usri4_password: ::LPWSTR, usri4_password_age: ::DWORD, usri4_priv: ::DWORD, usri4_home_dir: ::LPWSTR, usri4_comment: ::LPWSTR, usri4_flags: ::DWORD, usri4_script_path: ::LPWSTR, usri4_auth_flags: ::DWORD, usri4_full_name: ::LPWSTR, usri4_usr_comment: ::LPWSTR, usri4_parms: ::LPWSTR, usri4_workstations: ::LPWSTR, usri4_last_logon: ::DWORD, usri4_last_logoff: ::DWORD, usri4_acct_expires: ::DWORD, usri4_max_storage: ::DWORD, usri4_units_per_week: ::DWORD, usri4_logon_hours: ::PBYTE, usri4_bad_pw_count: ::DWORD, usri4_num_logons: ::DWORD, usri4_logon_server: ::LPWSTR, usri4_country_code: ::DWORD, usri4_code_page: ::DWORD, usri4_user_sid: ::PSID, usri4_primary_group_id: ::DWORD, usri4_profile: ::LPWSTR, usri4_home_dir_drive: ::LPWSTR, usri4_password_expired: ::DWORD, }} pub type PUSER_INFO_4 = *mut USER_INFO_4; pub type LPUSER_INFO_4 = *mut USER_INFO_4; STRUCT!{struct USER_INFO_10 { usri10_name: ::LPWSTR, usri10_comment: ::LPWSTR, usri10_usr_comment: ::LPWSTR, usri10_full_name: ::LPWSTR, }} pub type PUSER_INFO_10 = *mut USER_INFO_10; pub type LPUSER_INFO_10 = *mut USER_INFO_10; STRUCT!{struct USER_INFO_11 { usri11_name: ::LPWSTR, usri11_comment: ::LPWSTR, usri11_usr_comment: ::LPWSTR, usri11_full_name: ::LPWSTR, usri11_priv: ::DWORD, usri11_auth_flags: ::DWORD, usri11_password_age: ::DWORD, usri11_home_dir: ::LPWSTR, usri11_parms: ::LPWSTR, usri11_last_logon: ::DWORD, usri11_last_logoff: ::DWORD, usri11_bad_pw_count: ::DWORD, usri11_num_logons: ::DWORD, usri11_logon_server: ::LPWSTR, usri11_country_code: ::DWORD, usri11_workstations: ::LPWSTR, usri11_max_storage: ::DWORD, usri11_units_per_week: ::DWORD, usri11_logon_hours: ::PBYTE, usri11_code_page: ::DWORD, }} pub type PUSER_INFO_11 = *mut USER_INFO_11; pub type LPUSER_INFO_11 = *mut USER_INFO_11; STRUCT!{struct USER_INFO_20 { usri20_name: ::LPWSTR, usri20_full_name: ::LPWSTR, usri20_comment: ::LPWSTR, usri20_flags: ::DWORD, usri20_user_id: ::DWORD, }} pub type PUSER_INFO_20 = *mut USER_INFO_20; pub type LPUSER_INFO_20 = *mut USER_INFO_20; STRUCT!{struct USER_INFO_21 { usri21_password: [::BYTE; ::ENCRYPTED_PWLEN], }} pub type PUSER_INFO_21 = *mut USER_INFO_21; pub type LPUSER_INFO_21 = *mut USER_INFO_21; STRUCT!{struct USER_INFO_22 { usri22_name: ::LPWSTR, usri22_password: [::BYTE; ::ENCRYPTED_PWLEN], usri22_password_age: ::DWORD, usri22_priv: ::DWORD, usri22_home_dir: ::LPWSTR, usri22_comment: ::LPWSTR, usri22_flags: ::DWORD, usri22_script_path: ::LPWSTR, usri22_auth_flags: ::DWORD, usri22_full_name: ::LPWSTR, usri22_usr_comment: ::LPWSTR, usri22_parms: ::LPWSTR, usri22_workstations: ::LPWSTR, usri22_last_logon: ::DWORD, usri22_last_logoff: ::DWORD, usri22_acct_expires: ::DWORD, usri22_max_storage: ::DWORD, usri22_units_per_week: ::DWORD, usri22_logon_hours: ::PBYTE, usri22_bad_pw_count: ::DWORD, usri22_num_logons: ::DWORD, usri22_logon_server: ::LPWSTR, usri22_country_code: ::DWORD, usri22_code_page: ::DWORD, }} pub type PUSER_INFO_22 = *mut USER_INFO_22; pub type LPUSER_INFO_22 = *mut USER_INFO_22; STRUCT!{struct USER_INFO_23 { usri23_name: ::LPWSTR, usri23_full_name: ::LPWSTR, usri23_comment: ::LPWSTR, usri23_flags: ::DWORD, usri23_user_sid: ::PSID, }} pub type PUSER_INFO_23 = *mut USER_INFO_23; pub type LPUSER_INFO_23 = *mut USER_INFO_23; STRUCT!{struct USER_INFO_24 { usri24_internet_identity: ::BOOL, usri24_flags: ::DWORD, usri24_internet_provider_name: ::LPWSTR, usri24_internet_principal_name: ::LPWSTR, usri24_user_sid: ::PSID, }} pub type PUSER_INFO_24 = *mut USER_INFO_24; pub type LPUSER_INFO_24 = *mut USER_INFO_24; STRUCT!{struct USER_INFO_1003 { usri1003_password: ::LPWSTR, }} pub type PUSER_INFO_1003 = *mut USER_INFO_1003; pub type LPUSER_INFO_1003 = *mut USER_INFO_1003; STRUCT!{struct USER_INFO_1005 { usri1005_priv: ::DWORD, }} pub type PUSER_INFO_1005 = *mut USER_INFO_1005; pub type LPUSER_INFO_1005 = *mut USER_INFO_1005; STRUCT!{struct USER_INFO_1006 { usri1006_home_dir: ::LPWSTR, }} pub type PUSER_INFO_1006 = *mut USER_INFO_1006; pub type LPUSER_INFO_1006 = *mut USER_INFO_1006; STRUCT!{struct USER_INFO_1007 { usri1007_comment: ::LPWSTR, }} pub type PUSER_INFO_1007 = *mut USER_INFO_1007; pub type LPUSER_INFO_1007 = *mut USER_INFO_1007; STRUCT!{struct USER_INFO_1008 { usri1008_flags: ::DWORD, }} pub type PUSER_INFO_1008 = *mut USER_INFO_1008; pub type LPUSER_INFO_1008 = *mut USER_INFO_1008; STRUCT!{struct USER_INFO_1009 { usri1009_script_path: ::LPWSTR, }} pub type PUSER_INFO_1009 = *mut USER_INFO_1009; pub type LPUSER_INFO_1009 = *mut USER_INFO_1009; STRUCT!{struct USER_INFO_1010 { usri1010_auth_flags: ::DWORD, }} pub type PUSER_INFO_1010 = *mut USER_INFO_1010; pub type LPUSER_INFO_1010 = *mut USER_INFO_1010; STRUCT!{struct USER_INFO_1011 { usri1011_full_name: ::LPWSTR, }} pub type PUSER_INFO_1011 = *mut USER_INFO_1011; pub type LPUSER_INFO_1011 = *mut USER_INFO_1011; STRUCT!{struct USER_INFO_1012 { usri1012_usr_comment: ::LPWSTR, }} pub type PUSER_INFO_1012 = *mut USER_INFO_1012; pub type LPUSER_INFO_1012 = *mut USER_INFO_1012; STRUCT!{struct USER_INFO_1013 { usri1013_parms: ::LPWSTR, }} pub type PUSER_INFO_1013 = *mut USER_INFO_1013; pub type LPUSER_INFO_1013 = *mut USER_INFO_1013; STRUCT!{struct USER_INFO_1014 { usri1014_workstations: ::LPWSTR, }} pub type PUSER_INFO_1014 = *mut USER_INFO_1014; pub type LPUSER_INFO_1014 = *mut USER_INFO_1014; STRUCT!{struct USER_INFO_1017 { usri1017_acct_expires: ::DWORD, }} pub type PUSER_INFO_1017 = *mut USER_INFO_1017; pub type LPUSER_INFO_1017 = *mut USER_INFO_1017; STRUCT!{struct USER_INFO_1018 { usri1018_max_storage: ::DWORD, }} pub type PUSER_INFO_1018 = *mut USER_INFO_1018; pub type LPUSER_INFO_1018 = *mut USER_INFO_1018; STRUCT!{struct USER_INFO_1020 { usri1020_units_per_week: ::DWORD, usri1020_logon_hours: ::LPBYTE, }} pub type PUSER_INFO_1020 = *mut USER_INFO_1020; pub type LPUSER_INFO_1020 = *mut USER_INFO_1020; STRUCT!{struct USER_INFO_1023 { usri1023_logon_server: ::LPWSTR, }} pub type PUSER_INFO_1023 = *mut USER_INFO_1023; pub type LPUSER_INFO_1023 = *mut USER_INFO_1023; STRUCT!{struct USER_INFO_1024 { usri1024_country_code: ::DWORD, }} pub type PUSER_INFO_1024 = *mut USER_INFO_1024; pub type LPUSER_INFO_1024 = *mut USER_INFO_1024; STRUCT!{struct USER_INFO_1025 { usri1025_code_page: ::DWORD, }} pub type PUSER_INFO_1025 = *mut USER_INFO_1025; pub type LPUSER_INFO_1025 = *mut USER_INFO_1025; STRUCT!{struct USER_INFO_1051 { usri1051_primary_group_id: ::DWORD, }} pub type PUSER_INFO_1051 = *mut USER_INFO_1051; pub type LPUSER_INFO_1051 = *mut USER_INFO_1051; STRUCT!{struct USER_INFO_1052 { usri1052_profile: ::LPWSTR, }} pub type PUSER_INFO_1052 = *mut USER_INFO_1052; pub type LPUSER_INFO_1052 = *mut USER_INFO_1052; STRUCT!{struct USER_INFO_1053 { usri1053_home_dir_drive: ::LPWSTR, }} pub type PUSER_INFO_1053 = *mut USER_INFO_1053; pub type LPUSER_INFO_1053 = *mut USER_INFO_1053; STRUCT!{struct USER_MODALS_INFO_0 { usrmod0_min_passwd_len: ::DWORD, usrmod0_max_passwd_age: ::DWORD, usrmod0_min_passwd_age: ::DWORD, usrmod0_force_logoff: ::DWORD, usrmod0_password_hist_len: ::DWORD, }} pub type PUSER_MODALS_INFO_0 = *mut USER_MODALS_INFO_0; pub type LPUSER_MODALS_INFO_0 = *mut USER_MODALS_INFO_0; STRUCT!{struct USER_MODALS_INFO_1 { usrmod1_role: ::DWORD, usrmod1_primary: ::LPWSTR, }} pub type PUSER_MODALS_INFO_1 = *mut USER_MODALS_INFO_1; pub type LPUSER_MODALS_INFO_1 = *mut USER_MODALS_INFO_1; STRUCT!{struct USER_MODALS_INFO_2 { usrmod2_domain_name: ::LPWSTR, usrmod2_domain_id: ::PSID, }} pub type PUSER_MODALS_INFO_2 = *mut USER_MODALS_INFO_2; pub type LPUSER_MODALS_INFO_2 = *mut USER_MODALS_INFO_2; STRUCT!{struct USER_MODALS_INFO_3 { usrmod3_lockout_duration: ::DWORD, usrmod3_lockout_observation_window: ::DWORD, usrmod3_lockout_threshold: ::DWORD, }} pub type PUSER_MODALS_INFO_3 = *mut USER_MODALS_INFO_3; pub type LPUSER_MODALS_INFO_3 = *mut USER_MODALS_INFO_3; STRUCT!{struct USER_MODALS_INFO_1001 { usrmod1001_min_passwd_len: ::DWORD, }} pub type PUSER_MODALS_INFO_1001 = *mut USER_MODALS_INFO_1001; pub type LPUSER_MODALS_INFO_1001 = *mut USER_MODALS_INFO_1001; STRUCT!{struct USER_MODALS_INFO_1002 { usrmod1002_max_passwd_age: ::DWORD, }} pub type PUSER_MODALS_INFO_1002 = *mut USER_MODALS_INFO_1002; pub type LPUSER_MODALS_INFO_1002 = *mut USER_MODALS_INFO_1002; STRUCT!{struct USER_MODALS_INFO_1003 { usrmod1003_min_passwd_age: ::DWORD, }} pub type PUSER_MODALS_INFO_1003 = *mut USER_MODALS_INFO_1003; pub type LPUSER_MODALS_INFO_1003 = *mut USER_MODALS_INFO_1003; STRUCT!{struct USER_MODALS_INFO_1004 { usrmod1004_force_logoff: ::DWORD, }} pub type PUSER_MODALS_INFO_1004 = *mut USER_MODALS_INFO_1004; pub type LPUSER_MODALS_INFO_1004 = *mut USER_MODALS_INFO_1004; STRUCT!{struct USER_MODALS_INFO_1005 { usrmod1005_password_hist_len: ::DWORD, }} pub type PUSER_MODALS_INFO_1005 = *mut USER_MODALS_INFO_1005; pub type LPUSER_MODALS_INFO_1005 = *mut USER_MODALS_INFO_1005; STRUCT!{struct USER_MODALS_INFO_1006 { usrmod1006_role: ::DWORD, }} pub type PUSER_MODALS_INFO_1006 = *mut USER_MODALS_INFO_1006; pub type LPUSER_MODALS_INFO_1006 = *mut USER_MODALS_INFO_1006; STRUCT!{struct USER_MODALS_INFO_1007 { usrmod1007_primary: ::LPWSTR, }} pub type PUSER_MODALS_INFO_1007 = *mut USER_MODALS_INFO_1007; pub type LPUSER_MODALS_INFO_1007 = *mut USER_MODALS_INFO_1007; pub const UF_SCRIPT: ::DWORD = 0x0001; pub const UF_ACCOUNTDISABLE: ::DWORD = 0x0002; pub const UF_HOMEDIR_REQUIRED: ::DWORD = 0x0008; pub const UF_LOCKOUT: ::DWORD = 0x0010; pub const UF_PASSWD_NOTREQD: ::DWORD = 0x0020; pub const UF_PASSWD_CANT_CHANGE: ::DWORD = 0x0040; pub const UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED: ::DWORD = 0x0080; pub const UF_TEMP_DUPLICATE_ACCOUNT: ::DWORD = 0x0100; pub const UF_NORMAL_ACCOUNT: ::DWORD = 0x0200; pub const UF_INTERDOMAIN_TRUST_ACCOUNT: ::DWORD = 0x0800; pub const UF_WORKSTATION_TRUST_ACCOUNT: ::DWORD = 0x1000; pub const UF_SERVER_TRUST_ACCOUNT: ::DWORD = 0x2000; pub const UF_MACHINE_ACCOUNT_MASK: ::DWORD = UF_INTERDOMAIN_TRUST_ACCOUNT | UF_WORKSTATION_TRUST_ACCOUNT | UF_SERVER_TRUST_ACCOUNT; pub const UF_ACCOUNT_TYPE_MASK: ::DWORD = UF_TEMP_DUPLICATE_ACCOUNT | UF_NORMAL_ACCOUNT | UF_INTERDOMAIN_TRUST_ACCOUNT | UF_WORKSTATION_TRUST_ACCOUNT | UF_SERVER_TRUST_ACCOUNT; pub const UF_DONT_EXPIRE_PASSWD: ::DWORD = 0x10000; pub const UF_MNS_LOGON_ACCOUNT: ::DWORD = 0x20000; pub const UF_SMARTCARD_REQUIRED: ::DWORD = 0x40000; pub const UF_TRUSTED_FOR_DELEGATION: ::DWORD = 0x80000; pub const UF_NOT_DELEGATED: ::DWORD = 0x100000; pub const UF_USE_DES_KEY_ONLY: ::DWORD = 0x200000; pub const UF_DONT_REQUIRE_PREAUTH: ::DWORD = 0x400000; pub const UF_PASSWORD_EXPIRED: ::DWORD = 0x800000; pub const UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION: ::DWORD = 0x1000000; pub const UF_NO_AUTH_DATA_REQUIRED: ::DWORD = 0x2000000; pub const UF_PARTIAL_SECRETS_ACCOUNT: ::DWORD = 0x4000000; pub const UF_USE_AES_KEYS: ::DWORD = 0x8000000; pub const UF_SETTABLE_BITS: ::DWORD = UF_SCRIPT | UF_ACCOUNTDISABLE | UF_LOCKOUT | UF_HOMEDIR_REQUIRED | UF_PASSWD_NOTREQD | UF_PASSWD_CANT_CHANGE | UF_ACCOUNT_TYPE_MASK | UF_DONT_EXPIRE_PASSWD | UF_MNS_LOGON_ACCOUNT | UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED | UF_SMARTCARD_REQUIRED | UF_TRUSTED_FOR_DELEGATION | UF_NOT_DELEGATED | UF_USE_DES_KEY_ONLY | UF_DONT_REQUIRE_PREAUTH | UF_PASSWORD_EXPIRED | UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION | UF_NO_AUTH_DATA_REQUIRED | UF_USE_AES_KEYS | UF_PARTIAL_SECRETS_ACCOUNT; pub const FILTER_TEMP_DUPLICATE_ACCOUNT: ::DWORD = 0x0001; pub const FILTER_NORMAL_ACCOUNT: ::DWORD = 0x0002; pub const FILTER_INTERDOMAIN_TRUST_ACCOUNT: ::DWORD = 0x0008; pub const FILTER_WORKSTATION_TRUST_ACCOUNT: ::DWORD = 0x0010; pub const FILTER_SERVER_TRUST_ACCOUNT: ::DWORD = 0x0020; pub const LG_INCLUDE_INDIRECT: ::DWORD = 0x0001; pub const AF_OP_PRINT: ::DWORD = 0x1; pub const AF_OP_COMM: ::DWORD = 0x2; pub const AF_OP_SERVER: ::DWORD = 0x4; pub const AF_OP_ACCOUNTS: ::DWORD = 0x8; pub const AF_SETTABLE_BITS: ::DWORD = AF_OP_PRINT | AF_OP_COMM | AF_OP_SERVER | AF_OP_ACCOUNTS; pub const UAS_ROLE_STANDALONE: ::DWORD = 0; pub const UAS_ROLE_MEMBER: ::DWORD = 1; pub const UAS_ROLE_BACKUP: ::DWORD = 2; pub const UAS_ROLE_PRIMARY: ::DWORD = 3; pub const USER_NAME_PARMNUM: ::DWORD = 1; pub const USER_PASSWORD_PARMNUM: ::DWORD = 3; pub const USER_PASSWORD_AGE_PARMNUM: ::DWORD = 4; pub const USER_PRIV_PARMNUM: ::DWORD = 5; pub const USER_HOME_DIR_PARMNUM: ::DWORD = 6; pub const USER_COMMENT_PARMNUM: ::DWORD = 7; pub const USER_FLAGS_PARMNUM: ::DWORD = 8; pub const USER_SCRIPT_PATH_PARMNUM: ::DWORD = 9; pub const USER_AUTH_FLAGS_PARMNUM: ::DWORD = 10; pub const USER_FULL_NAME_PARMNUM: ::DWORD = 11; pub const USER_USR_COMMENT_PARMNUM: ::DWORD = 12; pub const USER_PARMS_PARMNUM: ::DWORD = 13; pub const USER_WORKSTATIONS_PARMNUM: ::DWORD = 14; pub const USER_LAST_LOGON_PARMNUM: ::DWORD = 15; pub const USER_LAST_LOGOFF_PARMNUM: ::DWORD = 16; pub const USER_ACCT_EXPIRES_PARMNUM: ::DWORD = 17; pub const USER_MAX_STORAGE_PARMNUM: ::DWORD = 18; pub const USER_UNITS_PER_WEEK_PARMNUM: ::DWORD = 19; pub const USER_LOGON_HOURS_PARMNUM: ::DWORD = 20; pub const USER_PAD_PW_COUNT_PARMNUM: ::DWORD = 21; pub const USER_NUM_LOGONS_PARMNUM: ::DWORD = 22; pub const USER_LOGON_SERVER_PARMNUM: ::DWORD = 23; pub const USER_COUNTRY_CODE_PARMNUM: ::DWORD = 24; pub const USER_CODE_PAGE_PARMNUM: ::DWORD = 25; pub const USER_PRIMARY_GROUP_PARMNUM: ::DWORD = 51; pub const USER_PROFILE: ::DWORD = 52; pub const USER_PROFILE_PARMNUM: ::DWORD = 52; pub const USER_HOME_DIR_DRIVE_PARMNUM: ::DWORD = 53; pub const USER_NAME_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_NAME_PARMNUM; pub const USER_PASSWORD_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_PASSWORD_PARMNUM; pub const USER_PASSWORD_AGE_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_PASSWORD_AGE_PARMNUM; pub const USER_PRIV_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_PRIV_PARMNUM; pub const USER_HOME_DIR_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_HOME_DIR_PARMNUM; pub const USER_COMMENT_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_COMMENT_PARMNUM; pub const USER_FLAGS_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_FLAGS_PARMNUM; pub const USER_SCRIPT_PATH_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_SCRIPT_PATH_PARMNUM; pub const USER_AUTH_FLAGS_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_AUTH_FLAGS_PARMNUM; pub const USER_FULL_NAME_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_FULL_NAME_PARMNUM; pub const USER_USR_COMMENT_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_USR_COMMENT_PARMNUM; pub const USER_PARMS_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_PARMS_PARMNUM; pub const USER_WORKSTATIONS_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_WORKSTATIONS_PARMNUM; pub const USER_LAST_LOGON_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_LAST_LOGON_PARMNUM; pub const USER_LAST_LOGOFF_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_LAST_LOGOFF_PARMNUM; pub const USER_ACCT_EXPIRES_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_ACCT_EXPIRES_PARMNUM; pub const USER_MAX_STORAGE_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_MAX_STORAGE_PARMNUM; pub const USER_UNITS_PER_WEEK_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_UNITS_PER_WEEK_PARMNUM; pub const USER_LOGON_HOURS_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_LOGON_HOURS_PARMNUM; pub const USER_PAD_PW_COUNT_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_PAD_PW_COUNT_PARMNUM; pub const USER_NUM_LOGONS_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_NUM_LOGONS_PARMNUM; pub const USER_LOGON_SERVER_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_LOGON_SERVER_PARMNUM; pub const USER_COUNTRY_CODE_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_COUNTRY_CODE_PARMNUM; pub const USER_CODE_PAGE_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_CODE_PAGE_PARMNUM; pub const USER_PRIMARY_GROUP_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_PRIMARY_GROUP_PARMNUM; pub const USER_HOME_DIR_DRIVE_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + USER_HOME_DIR_DRIVE_PARMNUM; pub const TIMEQ_FOREVER: ::DWORD = -1i32 as ::DWORD; pub const USER_MAXSTORAGE_UNLIMITED: ::DWORD = -1i32 as ::DWORD; pub const USER_NO_LOGOFF: ::DWORD = -1i32 as ::DWORD; pub const UNITS_PER_DAY: ::DWORD = 24; pub const UNITS_PER_WEEK: ::DWORD = UNITS_PER_DAY * 7; pub const USER_PRIV_MASK: ::DWORD = 0x3; pub const USER_PRIV_GUEST: ::DWORD = 0; pub const USER_PRIV_USER: ::DWORD = 1; pub const USER_PRIV_ADMIN: ::DWORD = 2; pub const MAX_PASSWD_LEN: ::DWORD = ::PWLEN; pub const DEF_MIN_PWLEN: ::DWORD = 6; pub const DEF_PWUNIQUENESS: ::DWORD = 5; pub const DEF_MAX_PWHIST: ::DWORD = 8; pub const DEF_MAX_PWAGE: ::DWORD = TIMEQ_FOREVER; pub const DEF_MIN_PWAGE: ::DWORD = 0; pub const DEF_FORCE_LOGOFF: ::DWORD = 0xffffffff; pub const DEF_MAX_BADPW: ::DWORD = 0; pub const ONE_DAY: ::DWORD = 1 * 24 * 3600; pub const VALIDATED_LOGON: ::DWORD = 0; pub const PASSWORD_EXPIRED: ::DWORD = 2; pub const NON_VALIDATED_LOGON: ::DWORD = 3; pub const VALID_LOGOFF: ::DWORD = 1; pub const MODALS_MIN_PASSWD_LEN_PARMNUM: ::DWORD = 1; pub const MODALS_MAX_PASSWD_AGE_PARMNUM: ::DWORD = 2; pub const MODALS_MIN_PASSWD_AGE_PARMNUM: ::DWORD = 3; pub const MODALS_FORCE_LOGOFF_PARMNUM: ::DWORD = 4; pub const MODALS_PASSWD_HIST_LEN_PARMNUM: ::DWORD = 5; pub const MODALS_ROLE_PARMNUM: ::DWORD = 6; pub const MODALS_PRIMARY_PARMNUM: ::DWORD = 7; pub const MODALS_DOMAIN_NAME_PARMNUM: ::DWORD = 8; pub const MODALS_DOMAIN_ID_PARMNUM: ::DWORD = 9; pub const MODALS_LOCKOUT_DURATION_PARMNUM: ::DWORD = 10; pub const MODALS_LOCKOUT_OBSERVATION_WINDOW_PARMNUM: ::DWORD = 11; pub const MODALS_LOCKOUT_THRESHOLD_PARMNUM: ::DWORD = 12; pub const MODALS_MIN_PASSWD_LEN_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + MODALS_MIN_PASSWD_LEN_PARMNUM; pub const MODALS_MAX_PASSWD_AGE_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + MODALS_MAX_PASSWD_AGE_PARMNUM; pub const MODALS_MIN_PASSWD_AGE_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + MODALS_MIN_PASSWD_AGE_PARMNUM; pub const MODALS_FORCE_LOGOFF_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + MODALS_FORCE_LOGOFF_PARMNUM; pub const MODALS_PASSWD_HIST_LEN_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + MODALS_PASSWD_HIST_LEN_PARMNUM; pub const MODALS_ROLE_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + MODALS_ROLE_PARMNUM; pub const MODALS_PRIMARY_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + MODALS_PRIMARY_PARMNUM; pub const MODALS_DOMAIN_NAME_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + MODALS_DOMAIN_NAME_PARMNUM; pub const MODALS_DOMAIN_ID_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + MODALS_DOMAIN_ID_PARMNUM; STRUCT!{struct GROUP_INFO_0 { grpi0_name: ::LPWSTR, }} pub type PGROUP_INFO_0 = *mut GROUP_INFO_0; pub type LPGROUP_INFO_0 = *mut GROUP_INFO_0; STRUCT!{struct GROUP_INFO_1 { grpi1_name: ::LPWSTR, grpi1_comment: ::LPWSTR, }} pub type PGROUP_INFO_1 = *mut GROUP_INFO_1; pub type LPGROUP_INFO_1 = *mut GROUP_INFO_1; STRUCT!{struct GROUP_INFO_2 { grpi2_name: ::LPWSTR, grpi2_comment: ::LPWSTR, grpi2_group_id: ::DWORD, grpi2_attributes: ::DWORD, }} pub type PGROUP_INFO_2 = *mut GROUP_INFO_2; STRUCT!{struct GROUP_INFO_3 { grpi3_name: ::LPWSTR, grpi3_comment: ::LPWSTR, grpi3_group_sid: ::PSID, grpi3_attributes: ::DWORD, }} pub type PGROUP_INFO_3 = *mut GROUP_INFO_3; STRUCT!{struct GROUP_INFO_1002 { grpi1002_comment: ::LPWSTR, }} pub type PGROUP_INFO_1002 = *mut GROUP_INFO_1002; pub type LPGROUP_INFO_1002 = *mut GROUP_INFO_1002; STRUCT!{struct GROUP_INFO_1005 { grpi1005_attributes: ::DWORD, }} pub type PGROUP_INFO_1005 = *mut GROUP_INFO_1005; pub type LPGROUP_INFO_1005 = *mut GROUP_INFO_1005; STRUCT!{struct GROUP_USERS_INFO_0 { grui0_name: ::LPWSTR, }} pub type PGROUP_USERS_INFO_0 = *mut GROUP_USERS_INFO_0; pub type LPGROUP_USERS_INFO_0 = *mut GROUP_USERS_INFO_0; STRUCT!{struct GROUP_USERS_INFO_1 { grui1_name: ::LPWSTR, grui1_attributes: ::DWORD, }} pub type PGROUP_USERS_INFO_1 = *mut GROUP_USERS_INFO_1; pub type LPGROUP_USERS_INFO_1 = *mut GROUP_USERS_INFO_1; pub const GROUPIDMASK: ::DWORD = 0x8000; pub const GROUP_SPECIALGRP_USERS: &'static str = "USERS"; pub const GROUP_SPECIALGRP_ADMINS: &'static str = "ADMINS"; pub const GROUP_SPECIALGRP_GUESTS: &'static str = "GUESTS"; pub const GROUP_SPECIALGRP_LOCAL: &'static str = "LOCAL"; pub const GROUP_ALL_PARMNUM: ::DWORD = 0; pub const GROUP_NAME_PARMNUM: ::DWORD = 1; pub const GROUP_COMMENT_PARMNUM: ::DWORD = 2; pub const GROUP_ATTRIBUTES_PARMNUM: ::DWORD = 3; pub const GROUP_ALL_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + GROUP_ALL_PARMNUM; pub const GROUP_NAME_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + GROUP_NAME_PARMNUM; pub const GROUP_COMMENT_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + GROUP_COMMENT_PARMNUM; pub const GROUP_ATTRIBUTES_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + GROUP_ATTRIBUTES_PARMNUM; STRUCT!{struct LOCALGROUP_INFO_0 { lgrpi0_name: ::LPWSTR, }} pub type PLOCALGROUP_INFO_0 = *mut LOCALGROUP_INFO_0; pub type LPLOCALGROUP_INFO_0 = *mut LOCALGROUP_INFO_0; STRUCT!{struct LOCALGROUP_INFO_1 { lgrpi1_name: ::LPWSTR, lgrpi1_comment: ::LPWSTR, }} pub type PLOCALGROUP_INFO_1 = *mut LOCALGROUP_INFO_1; pub type LPLOCALGROUP_INFO_1 = *mut LOCALGROUP_INFO_1; STRUCT!{struct LOCALGROUP_INFO_1002 { lgrpi1002_comment: ::LPWSTR, }} pub type PLOCALGROUP_INFO_1002 = *mut LOCALGROUP_INFO_1002; pub type LPLOCALGROUP_INFO_1002 = *mut LOCALGROUP_INFO_1002; STRUCT!{struct LOCALGROUP_MEMBERS_INFO_0 { lgrmi0_sid: ::PSID, }} pub type PLOCALGROUP_MEMBERS_INFO_0 = *mut LOCALGROUP_MEMBERS_INFO_0; pub type LPLOCALGROUP_MEMBERS_INFO_0 = *mut LOCALGROUP_MEMBERS_INFO_0; STRUCT!{struct LOCALGROUP_MEMBERS_INFO_1 { lgrmi1_sid: ::PSID, lgrmi1_sidusage: ::SID_NAME_USE, lgrmi1_name: ::LPWSTR, }} pub type PLOCALGROUP_MEMBERS_INFO_1 = *mut LOCALGROUP_MEMBERS_INFO_1; pub type LPLOCALGROUP_MEMBERS_INFO_1 = *mut LOCALGROUP_MEMBERS_INFO_1; STRUCT!{struct LOCALGROUP_MEMBERS_INFO_2 { lgrmi2_sid: ::PSID, lgrmi2_sidusage: ::SID_NAME_USE, lgrmi2_domainandname: ::LPWSTR, }} pub type PLOCALGROUP_MEMBERS_INFO_2 = *mut LOCALGROUP_MEMBERS_INFO_2; pub type LPLOCALGROUP_MEMBERS_INFO_2 = *mut LOCALGROUP_MEMBERS_INFO_2; STRUCT!{struct LOCALGROUP_MEMBERS_INFO_3 { lgrmi3_domainandname: ::LPWSTR, }} pub type PLOCALGROUP_MEMBERS_INFO_3 = *mut LOCALGROUP_MEMBERS_INFO_3; pub type LPLOCALGROUP_MEMBERS_INFO_3 = *mut LOCALGROUP_MEMBERS_INFO_3; STRUCT!{struct LOCALGROUP_USERS_INFO_0 { lgrui0_name: ::LPWSTR, }} pub type PLOCALGROUP_USERS_INFO_0 = *mut LOCALGROUP_USERS_INFO_0; pub type LPLOCALGROUP_USERS_INFO_0 = *mut LOCALGROUP_USERS_INFO_0; pub const LOCALGROUP_NAME_PARMNUM: ::DWORD = 1; pub const LOCALGROUP_COMMENT_PARMNUM: ::DWORD = 2; STRUCT!{struct NET_DISPLAY_USER { usri1_name: ::LPWSTR, usri1_comment: ::LPWSTR, usri1_flags: ::DWORD, usri1_full_name: ::LPWSTR, usri1_user_id: ::DWORD, usri1_next_index: ::DWORD, }} pub type PNET_DISPLAY_USER = *mut NET_DISPLAY_USER; STRUCT!{struct NET_DISPLAY_MACHINE { usri2_name: ::LPWSTR, usri2_comment: ::LPWSTR, usri2_flags: ::DWORD, usri2_user_id: ::DWORD, usri2_next_index: ::DWORD, }} pub type PNET_DISPLAY_MACHINE = *mut NET_DISPLAY_MACHINE; STRUCT!{struct NET_DISPLAY_GROUP { usri3_name: ::LPWSTR, usri3_comment: ::LPWSTR, grpi3_group_id: ::DWORD, grpi3_attributes: ::DWORD, grpi3_next_index: ::DWORD, }} pub type PNET_DISPLAY_GROUP = *mut NET_DISPLAY_GROUP; STRUCT!{struct ACCESS_INFO_0 { acc0_resource_name: ::LPWSTR, }} pub type PACCESS_INFO_0 = *mut ACCESS_INFO_0; pub type LPACCESS_INFO_0 = *mut ACCESS_INFO_0; STRUCT!{struct ACCESS_INFO_1 { acc1_resource_name: ::LPWSTR, acc1_attr: ::DWORD, acc1_count: ::DWORD, }} pub type PACCESS_INFO_1 = *mut ACCESS_INFO_1; pub type LPACCESS_INFO_1 = *mut ACCESS_INFO_1; STRUCT!{struct ACCESS_INFO_1002 { acc1002_attr: ::DWORD, }} pub type PACCESS_INFO_1002 = *mut ACCESS_INFO_1002; pub type LPACCESS_INFO_1002 = *mut ACCESS_INFO_1002; STRUCT!{struct ACCESS_LIST { acl_ugname: ::LPWSTR, acl_access: ::DWORD, }} pub type PACCESS_LIST = *mut ACCESS_LIST; pub type LPACCESS_LIST = *mut ACCESS_LIST; pub const ACCESS_NONE: ::DWORD = 0; pub const ACCESS_ALL: ::DWORD = ACCESS_READ | ACCESS_WRITE | ACCESS_CREATE | ACCESS_EXEC | ACCESS_DELETE | ACCESS_ATRIB | ACCESS_PERM; pub const ACCESS_READ: ::DWORD = 0x01; pub const ACCESS_WRITE: ::DWORD = 0x02; pub const ACCESS_CREATE: ::DWORD = 0x04; pub const ACCESS_EXEC: ::DWORD = 0x08; pub const ACCESS_DELETE: ::DWORD = 0x10; pub const ACCESS_ATRIB: ::DWORD = 0x20; pub const ACCESS_PERM: ::DWORD = 0x40; pub const ACCESS_GROUP: ::DWORD = 0x8000; pub const ACCESS_AUDIT: ::DWORD = 0x1; pub const ACCESS_SUCCESS_OPEN: ::DWORD = 0x10; pub const ACCESS_SUCCESS_WRITE: ::DWORD = 0x20; pub const ACCESS_SUCCESS_DELETE: ::DWORD = 0x40; pub const ACCESS_SUCCESS_ACL: ::DWORD = 0x80; pub const ACCESS_SUCCESS_MASK: ::DWORD = 0xF0; pub const ACCESS_FAIL_OPEN: ::DWORD = 0x100; pub const ACCESS_FAIL_WRITE: ::DWORD = 0x200; pub const ACCESS_FAIL_DELETE: ::DWORD = 0x400; pub const ACCESS_FAIL_ACL: ::DWORD = 0x800; pub const ACCESS_FAIL_MASK: ::DWORD = 0xF00; pub const ACCESS_FAIL_SHIFT: ::DWORD = 4; pub const ACCESS_RESOURCE_NAME_PARMNUM: ::DWORD = 1; pub const ACCESS_ATTR_PARMNUM: ::DWORD = 2; pub const ACCESS_COUNT_PARMNUM: ::DWORD = 3; pub const ACCESS_ACCESS_LIST_PARMNUM: ::DWORD = 4; pub const ACCESS_RESOURCE_NAME_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + ACCESS_RESOURCE_NAME_PARMNUM; pub const ACCESS_ATTR_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + ACCESS_ATTR_PARMNUM; pub const ACCESS_COUNT_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + ACCESS_COUNT_PARMNUM; pub const ACCESS_ACCESS_LIST_INFOLEVEL: ::DWORD = ::PARMNUM_BASE_INFOLEVEL + ACCESS_ACCESS_LIST_PARMNUM; ENUM!{enum NET_VALIDATE_PASSWORD_TYPE { NetValidateAuthentication = 1, NetValidatePasswordChange, NetValidatePasswordReset, }} pub type PNET_VALIDATE_PASSWORD_TYPE = *mut NET_VALIDATE_PASSWORD_TYPE; STRUCT!{struct NET_VALIDATE_PASSWORD_HASH { Length: ::ULONG, Hash: ::LPBYTE, }} pub type PNET_VALIDATE_PASSWORD_HASH = *mut NET_VALIDATE_PASSWORD_HASH; pub const NET_VALIDATE_PASSWORD_LAST_SET: ::ULONG = 0x00000001; pub const NET_VALIDATE_BAD_PASSWORD_TIME: ::ULONG = 0x00000002; pub const NET_VALIDATE_LOCKOUT_TIME: ::ULONG = 0x00000004; pub const NET_VALIDATE_BAD_PASSWORD_COUNT: ::ULONG = 0x00000008; pub const NET_VALIDATE_PASSWORD_HISTORY_LENGTH: ::ULONG = 0x00000010; pub const NET_VALIDATE_PASSWORD_HISTORY: ::ULONG = 0x00000020; STRUCT!{struct NET_VALIDATE_PERSISTED_FIELDS { PresentFields: ::ULONG, PasswordLastSet: ::FILETIME, BadPasswordTime: ::FILETIME, LockoutTime: ::FILETIME, BadPasswordCount: ::ULONG, PasswordHistoryLength: ::ULONG, PasswordHistory: PNET_VALIDATE_PASSWORD_HASH, }} pub type PNET_VALIDATE_PERSISTED_FIELDS = *mut NET_VALIDATE_PERSISTED_FIELDS; STRUCT!{struct NET_VALIDATE_OUTPUT_ARG { ChangedPersistedFields: NET_VALIDATE_PERSISTED_FIELDS, ValidationStatus: ::NET_API_STATUS, }} pub type PNET_VALIDATE_OUTPUT_ARG = *mut NET_VALIDATE_OUTPUT_ARG; STRUCT!{struct NET_VALIDATE_AUTHENTICATION_INPUT_ARG { InputPersistedFields: NET_VALIDATE_PERSISTED_FIELDS, PasswordMatched: ::BOOLEAN, }} pub type PNET_VALIDATE_AUTHENTICATION_INPUT_ARG = *mut NET_VALIDATE_AUTHENTICATION_INPUT_ARG; STRUCT!{struct NET_VALIDATE_PASSWORD_CHANGE_INPUT_ARG { InputPersistedFields: NET_VALIDATE_PERSISTED_FIELDS, ClearPassword: ::LPWSTR, UserAccountName: ::LPWSTR, HashedPassword: NET_VALIDATE_PASSWORD_HASH, PasswordMatch: ::BOOLEAN, }} pub type PNET_VALIDATE_PASSWORD_CHANGE_INPUT_ARG = *mut NET_VALIDATE_PASSWORD_CHANGE_INPUT_ARG; STRUCT!{struct NET_VALIDATE_PASSWORD_RESET_INPUT_ARG { InputPersistedFields: NET_VALIDATE_PERSISTED_FIELDS, ClearPassword: ::LPWSTR, UserAccountName: ::LPWSTR, HashedPassword: NET_VALIDATE_PASSWORD_HASH, PasswordMustChangeAtNextLogon: ::BOOLEAN, ClearLockout: ::BOOLEAN, }} pub type PNET_VALIDATE_PASSWORD_RESET_INPUT_ARG = *mut NET_VALIDATE_PASSWORD_RESET_INPUT_ARG; pub const NETLOGON_CONTROL_QUERY: ::DWORD = 1; pub const NETLOGON_CONTROL_REPLICATE: ::DWORD = 2; pub const NETLOGON_CONTROL_SYNCHRONIZE: ::DWORD = 3; pub const NETLOGON_CONTROL_PDC_REPLICATE: ::DWORD = 4; pub const NETLOGON_CONTROL_REDISCOVER: ::DWORD = 5; pub const NETLOGON_CONTROL_TC_QUERY: ::DWORD = 6; pub const NETLOGON_CONTROL_TRANSPORT_NOTIFY: ::DWORD = 7; pub const NETLOGON_CONTROL_FIND_USER: ::DWORD = 8; pub const NETLOGON_CONTROL_CHANGE_PASSWORD: ::DWORD = 9; pub const NETLOGON_CONTROL_TC_VERIFY: ::DWORD = 10; pub const NETLOGON_CONTROL_FORCE_DNS_REG: ::DWORD = 11; pub const NETLOGON_CONTROL_QUERY_DNS_REG: ::DWORD = 12; pub const NETLOGON_CONTROL_UNLOAD_NETLOGON_DLL: ::DWORD = 0xFFFB; pub const NETLOGON_CONTROL_BACKUP_CHANGE_LOG: ::DWORD = 0xFFFC; pub const NETLOGON_CONTROL_TRUNCATE_LOG: ::DWORD = 0xFFFD; pub const NETLOGON_CONTROL_SET_DBFLAG: ::DWORD = 0xFFFE; pub const NETLOGON_CONTROL_BREAKPOINT: ::DWORD = 0xFFFF; STRUCT!{struct NETLOGON_INFO_1 { netlog1_flags: ::DWORD, netlog1_pdc_connection_status: ::NET_API_STATUS, }} pub type PNETLOGON_INFO_1 = *mut NETLOGON_INFO_1; STRUCT!{struct NETLOGON_INFO_2 { netlog2_flags: ::DWORD, netlog2_pdc_connection_status: ::NET_API_STATUS, netlog2_trusted_dc_name: ::LPWSTR, netlog2_tc_connection_status: ::NET_API_STATUS, }} pub type PNETLOGON_INFO_2 = *mut NETLOGON_INFO_2; STRUCT!{struct NETLOGON_INFO_3 { netlog3_flags: ::DWORD, netlog3_logon_attempts: ::DWORD, netlog3_reserved1: ::DWORD, netlog3_reserved2: ::DWORD, netlog3_reserved3: ::DWORD, netlog3_reserved4: ::DWORD, netlog3_reserved5: ::DWORD, }} pub type PNETLOGON_INFO_3 = *mut NETLOGON_INFO_3; STRUCT!{struct NETLOGON_INFO_4 { netlog4_trusted_dc_name: ::LPWSTR, netlog4_trusted_domain_name: ::LPWSTR, }} pub type PNETLOGON_INFO_4 = *mut NETLOGON_INFO_4; pub const NETLOGON_REPLICATION_NEEDED: ::DWORD = 0x01; pub const NETLOGON_REPLICATION_IN_PROGRESS: ::DWORD = 0x02; pub const NETLOGON_FULL_SYNC_REPLICATION: ::DWORD = 0x04; pub const NETLOGON_REDO_NEEDED: ::DWORD = 0x08; pub const NETLOGON_HAS_IP: ::DWORD = 0x10; pub const NETLOGON_HAS_TIMESERV: ::DWORD = 0x20; pub const NETLOGON_DNS_UPDATE_FAILURE: ::DWORD = 0x40; pub const NETLOGON_VERIFY_STATUS_RETURNED: ::DWORD = 0x80; DEFINE_GUID!(ServiceAccountPasswordGUID, 0x262E99C9, 0x6160, 0x4871, 0xAC, 0xEC, 0x4E, 0x61, 0x73, 0x6B, 0x6F, 0x21); pub const SERVICE_ACCOUNT_FLAG_LINK_TO_HOST_ONLY: ::DWORD = 0x00000001; pub const SERVICE_ACCOUNT_FLAG_ADD_AGAINST_RODC: ::DWORD = 0x00000002; pub const SERVICE_ACCOUNT_FLAG_UNLINK_FROM_HOST_ONLY: ::DWORD = 0x00000001; pub const SERVICE_ACCOUNT_FLAG_REMOVE_OFFLINE: ::DWORD = 0x00000002; ENUM!{enum MSA_INFO_LEVEL { MsaInfoLevel0 = 0, MsaInfoLevelMax, }} pub type PMSA_INFO_LEVEL = *mut MSA_INFO_LEVEL; ENUM!{enum MSA_INFO_STATE { MsaInfoNotExist = 1, MsaInfoNotService, MsaInfoCannotInstall, MsaInfoCanInstall, MsaInfoInstalled, }} pub type PMSA_INFO_STATE = *mut MSA_INFO_STATE; STRUCT!{struct MSA_INFO_0 { State: MSA_INFO_STATE, }} pub type PMSA_INFO_0 = *mut MSA_INFO_0; pub type LPMSA_INFO_0 = *mut MSA_INFO_0; deps/winapi-0.2.5/src/docobj.rs0000644000000000000000000000126712613167613015047 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License STRUCT!{struct OLECMD { cmdID: ::ULONG, cmdf: ::DWORD, }} STRUCT!{struct OLECMDTEXT { cmdtextf: ::DWORD, cwActual: ::ULONG, cwBuf: ::ULONG, rgwz: [::wchar_t; 0], }} RIDL!{interface IOleCommandTarget(IOleCommandTargetVtbl): IUnknown(IUnknownVtbl) { fn QueryStatus( &mut self, pguidCmdGroup: *const ::GUID, cCmds: ::ULONG, prgCmds: *mut OLECMD, pCmdText: *mut OLECMDTEXT ) -> ::HRESULT, fn Exec( &mut self, pguidCmdGroup: *const :: GUID, nCmdID: ::DWORD, nCmdexecopt: ::DWORD, pvaIn: *mut ::VARIANT, pvaOut: *mut ::VARIANT ) -> ::HRESULT }} deps/winapi-0.2.5/src/winsmcrd.rs0000644000000000000000000002204712613167613015434 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License // Smart Card class/port IOCTL codes. pub type UWORD = ::WORD; DEFINE_GUID!(GUID_DEVINTERFACE_SMARTCARD_READER, 0x50DD5230, 0xBA8A, 0x11D1, 0xBF, 0x5D, 0x00, 0x00, 0xF8, 0x05, 0xF5, 0x30); pub const SCARD_ATR_LENGTHL: ::DWORD = 33; pub const SCARD_PROTOCOL_UNDEFINED: ::DWORD = 0x00000000; pub const SCARD_PROTOCOL_T0: ::DWORD = 0x00000001; pub const SCARD_PROTOCOL_T1: ::DWORD = 0x00000002; pub const SCARD_PROTOCOL_RAW: ::DWORD = 0x00010000; pub const SCARD_PROTOCOL_Tx: ::DWORD = SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1; pub const SCARD_PROTOCOL_DEFAULT: ::DWORD = 0x80000000; pub const SCARD_PROTOCOL_OPTIMAL: ::DWORD = 0x00000000; pub const SCARD_POWER_DOWN: ::DWORD = 0; pub const SCARD_COLD_RESET: ::DWORD = 1; pub const SCARD_WARM_RESET: ::DWORD = 2; pub const IOCTL_SMARTCARD_POWER: ::DWORD = CTL_CODE!(::FILE_DEVICE_SMARTCARD, 1, ::METHOD_BUFFERED, ::FILE_ANY_ACCESS); pub const IOCTL_SMARTCARD_GET_ATTRIBUTE: ::DWORD = CTL_CODE!(::FILE_DEVICE_SMARTCARD, 2, ::METHOD_BUFFERED, ::FILE_ANY_ACCESS); pub const IOCTL_SMARTCARD_SET_ATTRIBUTE: ::DWORD = CTL_CODE!(::FILE_DEVICE_SMARTCARD, 3, ::METHOD_BUFFERED, ::FILE_ANY_ACCESS); pub const IOCTL_SMARTCARD_CONFISCATE: ::DWORD = CTL_CODE!(::FILE_DEVICE_SMARTCARD, 4, ::METHOD_BUFFERED, ::FILE_ANY_ACCESS); pub const IOCTL_SMARTCARD_TRANSMIT: ::DWORD = CTL_CODE!(::FILE_DEVICE_SMARTCARD, 5, ::METHOD_BUFFERED, ::FILE_ANY_ACCESS); pub const IOCTL_SMARTCARD_EJECT: ::DWORD = CTL_CODE!(::FILE_DEVICE_SMARTCARD, 6, ::METHOD_BUFFERED, ::FILE_ANY_ACCESS); pub const IOCTL_SMARTCARD_SWALLOW: ::DWORD = CTL_CODE!(::FILE_DEVICE_SMARTCARD, 7, ::METHOD_BUFFERED, ::FILE_ANY_ACCESS); pub const IOCTL_SMARTCARD_IS_PRESENT: ::DWORD = CTL_CODE!(::FILE_DEVICE_SMARTCARD, 10, ::METHOD_BUFFERED, ::FILE_ANY_ACCESS); pub const IOCTL_SMARTCARD_IS_ABSENT: ::DWORD = CTL_CODE!(::FILE_DEVICE_SMARTCARD, 11, ::METHOD_BUFFERED, ::FILE_ANY_ACCESS); pub const IOCTL_SMARTCARD_SET_PROTOCOL: ::DWORD = CTL_CODE!(::FILE_DEVICE_SMARTCARD, 12, ::METHOD_BUFFERED, ::FILE_ANY_ACCESS); pub const IOCTL_SMARTCARD_GET_STATE: ::DWORD = CTL_CODE!(::FILE_DEVICE_SMARTCARD, 14, ::METHOD_BUFFERED, ::FILE_ANY_ACCESS); pub const IOCTL_SMARTCARD_GET_LAST_ERROR: ::DWORD = CTL_CODE!(::FILE_DEVICE_SMARTCARD, 15, ::METHOD_BUFFERED, ::FILE_ANY_ACCESS); pub const IOCTL_SMARTCARD_GET_PERF_CNTR: ::DWORD = CTL_CODE!(::FILE_DEVICE_SMARTCARD, 16, ::METHOD_BUFFERED, ::FILE_ANY_ACCESS); pub const MAXIMUM_ATTR_STRING_LENGTH: ::DWORD = 32; pub const MAXIMUM_SMARTCARD_READERS: ::DWORD = 10; pub const SCARD_CLASS_VENDOR_INFO: ::ULONG = 1; pub const SCARD_CLASS_COMMUNICATIONS: ::ULONG = 2; pub const SCARD_CLASS_PROTOCOL: ::ULONG = 3; pub const SCARD_CLASS_POWER_MGMT: ::ULONG = 4; pub const SCARD_CLASS_SECURITY: ::ULONG = 5; pub const SCARD_CLASS_MECHANICAL: ::ULONG = 6; pub const SCARD_CLASS_VENDOR_DEFINED: ::ULONG = 7; pub const SCARD_CLASS_IFD_PROTOCOL: ::ULONG = 8; pub const SCARD_CLASS_ICC_STATE: ::ULONG = 9; pub const SCARD_CLASS_PERF: ::ULONG = 0x7ffe; pub const SCARD_CLASS_SYSTEM: ::ULONG = 0x7fff; pub const SCARD_ATTR_VENDOR_NAME: ::ULONG = SCARD_CLASS_VENDOR_INFO << 16 | 0x0100; pub const SCARD_ATTR_VENDOR_IFD_TYPE: ::ULONG = SCARD_CLASS_VENDOR_INFO << 16 | 0x0101; pub const SCARD_ATTR_VENDOR_IFD_VERSION: ::ULONG = SCARD_CLASS_VENDOR_INFO << 16 | 0x0102; pub const SCARD_ATTR_VENDOR_IFD_SERIAL_NO: ::ULONG = SCARD_CLASS_VENDOR_INFO << 16 | 0x0103; pub const SCARD_ATTR_CHANNEL_ID: ::ULONG = SCARD_CLASS_COMMUNICATIONS << 16 | 0x0110; pub const SCARD_ATTR_PROTOCOL_TYPES: ::ULONG = SCARD_CLASS_PROTOCOL << 16 | 0x0120; pub const SCARD_ATTR_DEFAULT_CLK: ::ULONG = SCARD_CLASS_PROTOCOL << 16 | 0x0121; pub const SCARD_ATTR_MAX_CLK: ::ULONG = SCARD_CLASS_PROTOCOL << 16 | 0x0122; pub const SCARD_ATTR_DEFAULT_DATA_RATE: ::ULONG = SCARD_CLASS_PROTOCOL << 16 | 0x0123; pub const SCARD_ATTR_MAX_DATA_RATE: ::ULONG = SCARD_CLASS_PROTOCOL << 16 | 0x0124; pub const SCARD_ATTR_MAX_IFSD: ::ULONG = SCARD_CLASS_PROTOCOL << 16 | 0x0125; pub const SCARD_ATTR_POWER_MGMT_SUPPORT: ::ULONG = SCARD_CLASS_POWER_MGMT << 16 | 0x0131; pub const SCARD_ATTR_USER_TO_CARD_AUTH_DEVICE: ::ULONG = SCARD_CLASS_SECURITY << 16 | 0x0140; pub const SCARD_ATTR_USER_AUTH_INPUT_DEVICE: ::ULONG = SCARD_CLASS_SECURITY << 16 | 0x0142; pub const SCARD_ATTR_CHARACTERISTICS: ::ULONG = SCARD_CLASS_MECHANICAL << 16 | 0x0150; pub const SCARD_ATTR_CURRENT_PROTOCOL_TYPE: ::ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0201; pub const SCARD_ATTR_CURRENT_CLK: ::ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0202; pub const SCARD_ATTR_CURRENT_F: ::ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0203; pub const SCARD_ATTR_CURRENT_D: ::ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0204; pub const SCARD_ATTR_CURRENT_N: ::ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0205; pub const SCARD_ATTR_CURRENT_W: ::ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0206; pub const SCARD_ATTR_CURRENT_IFSC: ::ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0207; pub const SCARD_ATTR_CURRENT_IFSD: ::ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0208; pub const SCARD_ATTR_CURRENT_BWT: ::ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x0209; pub const SCARD_ATTR_CURRENT_CWT: ::ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x020a; pub const SCARD_ATTR_CURRENT_EBC_ENCODING: ::ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x020b; pub const SCARD_ATTR_EXTENDED_BWT: ::ULONG = SCARD_CLASS_IFD_PROTOCOL << 16 | 0x020c; pub const SCARD_ATTR_ICC_PRESENCE: ::ULONG = SCARD_CLASS_ICC_STATE << 16 | 0x0300; pub const SCARD_ATTR_ICC_INTERFACE_STATUS: ::ULONG = SCARD_CLASS_ICC_STATE << 16 | 0x0301; pub const SCARD_ATTR_CURRENT_IO_STATE: ::ULONG = SCARD_CLASS_ICC_STATE << 16 | 0x0302; pub const SCARD_ATTR_ATR_STRING: ::ULONG = SCARD_CLASS_ICC_STATE << 16 | 0x0303; pub const SCARD_ATTR_ICC_TYPE_PER_ATR: ::ULONG = SCARD_CLASS_ICC_STATE << 16 | 0x0304; pub const SCARD_ATTR_ESC_RESET: ::ULONG = SCARD_CLASS_VENDOR_DEFINED << 16 | 0xA000; pub const SCARD_ATTR_ESC_CANCEL: ::ULONG = SCARD_CLASS_VENDOR_DEFINED << 16 | 0xA003; pub const SCARD_ATTR_ESC_AUTHREQUEST: ::ULONG = SCARD_CLASS_VENDOR_DEFINED << 16 | 0xA005; pub const SCARD_ATTR_MAXINPUT: ::ULONG = SCARD_CLASS_VENDOR_DEFINED << 16 | 0xA007; pub const SCARD_ATTR_DEVICE_UNIT: ::ULONG = SCARD_CLASS_SYSTEM << 16 | 0x0001; pub const SCARD_ATTR_DEVICE_IN_USE: ::ULONG = SCARD_CLASS_SYSTEM << 16 | 0x0002; pub const SCARD_ATTR_DEVICE_FRIENDLY_NAME_A: ::ULONG = SCARD_CLASS_SYSTEM << 16 | 0x0003; pub const SCARD_ATTR_DEVICE_SYSTEM_NAME_A: ::ULONG = SCARD_CLASS_SYSTEM << 16 | 0x0004; pub const SCARD_ATTR_DEVICE_FRIENDLY_NAME_W: ::ULONG = SCARD_CLASS_SYSTEM << 16 | 0x0005; pub const SCARD_ATTR_DEVICE_SYSTEM_NAME_W: ::ULONG = SCARD_CLASS_SYSTEM << 16 | 0x0006; pub const SCARD_ATTR_SUPRESS_T1_IFS_REQUEST: ::ULONG = SCARD_CLASS_SYSTEM << 16 | 0x0007; pub const SCARD_PERF_NUM_TRANSMISSIONS: ::ULONG = SCARD_CLASS_PERF << 16 | 0x0001; pub const SCARD_PERF_BYTES_TRANSMITTED: ::ULONG = SCARD_CLASS_PERF << 16 | 0x0002; pub const SCARD_PERF_TRANSMISSION_TIME: ::ULONG = SCARD_CLASS_PERF << 16 | 0x0003; pub const SCARD_T0_HEADER_LENGTH: ::DWORD = 7; pub const SCARD_T0_CMD_LENGTH: ::DWORD = 5; pub const SCARD_T1_PROLOGUE_LENGTH: ::DWORD = 3; pub const SCARD_T1_EPILOGUE_LENGTH: ::DWORD = 2; pub const SCARD_T1_MAX_IFS: ::DWORD = 254; pub const SCARD_UNKNOWN: ::ULONG = 0; pub const SCARD_ABSENT: ::ULONG = 1; pub const SCARD_PRESENT: ::ULONG = 2; pub const SCARD_SWALLOWED: ::ULONG = 3; pub const SCARD_POWERED: ::ULONG = 4; pub const SCARD_NEGOTIABLE: ::ULONG = 5; pub const SCARD_SPECIFIC: ::ULONG = 6; STRUCT!{struct SCARD_IO_REQUEST { dwProtocol: ::DWORD, cbPciLength: ::DWORD, }} pub type PSCARD_IO_REQUEST = *mut SCARD_IO_REQUEST; pub type LPSCARD_IO_REQUEST = *mut SCARD_IO_REQUEST; pub type LPCSCARD_IO_REQUEST = *const SCARD_IO_REQUEST; STRUCT!{struct SCARD_T0_COMMAND { bCla: ::BYTE, bIns: ::BYTE, bP1: ::BYTE, bP2: ::BYTE, bP3: ::BYTE, }} pub type LPSCARD_T0_COMMAND = *mut SCARD_T0_COMMAND; STRUCT!{struct SCARD_T0_REQUEST { ioRequest: SCARD_IO_REQUEST, bSw1: ::BYTE, bSw2: ::BYTE, CmdBytes: SCARD_T0_COMMAND, }} UNION!(SCARD_T0_REQUEST, CmdBytes, rgbHeader, rgbHeader_mut, [::BYTE; 5]); pub type PSCARD_T0_REQUEST = *mut SCARD_T0_REQUEST; pub type LPSCARD_T0_REQUEST = *mut SCARD_T0_REQUEST; STRUCT!{struct SCARD_T1_REQUEST { ioRequest: SCARD_IO_REQUEST, }} pub type PSCARD_T1_REQUEST = *mut SCARD_T1_REQUEST; pub type LPSCARD_T1_REQUEST = *mut SCARD_T1_REQUEST; pub const SCARD_READER_SWALLOWS: ::ULONG = 0x00000001; pub const SCARD_READER_EJECTS: ::ULONG = 0x00000002; pub const SCARD_READER_CONFISCATES: ::ULONG = 0x00000004; pub const SCARD_READER_TYPE_SERIAL: ::ULONG = 0x01; pub const SCARD_READER_TYPE_PARALELL: ::ULONG = 0x02; pub const SCARD_READER_TYPE_KEYBOARD: ::ULONG = 0x04; pub const SCARD_READER_TYPE_SCSI: ::ULONG = 0x08; pub const SCARD_READER_TYPE_IDE: ::ULONG = 0x10; pub const SCARD_READER_TYPE_USB: ::ULONG = 0x20; pub const SCARD_READER_TYPE_PCMCIA: ::ULONG = 0x40; pub const SCARD_READER_TYPE_TPM: ::ULONG = 0x80; pub const SCARD_READER_TYPE_NFC: ::ULONG = 0x100; pub const SCARD_READER_TYPE_UICC: ::ULONG = 0x200; pub const SCARD_READER_TYPE_VENDOR: ::ULONG = 0xF0; deps/winapi-0.2.5/src/http.rs0000644000000000000000000007577612616155670014611 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! HTTP API specification pub const HTTP_INITIALIZE_SERVER: ::ULONG = 0x00000001; pub const HTTP_INITIALIZE_CONFIG: ::ULONG = 0x00000002; pub const HTTP_DEMAND_CBT: ::ULONG = 0x00000004; ENUM!{enum HTTP_SERVER_PROPERTY { HttpServerAuthenticationProperty, HttpServerLoggingProperty, HttpServerQosProperty, HttpServerTimeoutsProperty, HttpServerQueueLengthProperty, HttpServerStateProperty, HttpServer503VerbosityProperty, HttpServerBindingProperty, HttpServerExtendedAuthenticationProperty, HttpServerListenEndpointProperty, HttpServerChannelBindProperty, HttpServerProtectionLevelProperty, }} pub type PHTTP_SERVER_PROPERTY = *mut HTTP_SERVER_PROPERTY; STRUCT!{struct HTTP_PROPERTY_FLAGS { BitFields: ::ULONG, }} BITFIELD!(HTTP_PROPERTY_FLAGS BitFields: ::ULONG [ Present set_Present[0..1], ]); pub type PHTTP_PROPERTY_FLAGS = *mut HTTP_PROPERTY_FLAGS; ENUM!{enum HTTP_ENABLED_STATE { HttpEnabledStateActive, HttpEnabledStateInactive, }} pub type PHTTP_ENABLED_STATE = *mut HTTP_ENABLED_STATE; STRUCT!{struct HTTP_STATE_INFO { Flags: HTTP_PROPERTY_FLAGS, State: HTTP_ENABLED_STATE, }} pub type PHTTP_STATE_INFO = *mut HTTP_STATE_INFO; ENUM!{enum HTTP_503_RESPONSE_VERBOSITY { Http503ResponseVerbosityBasic, Http503ResponseVerbosityLimited, Http503ResponseVerbosityFull, }} pub type PHTTP_503_RESPONSE_VERBOSITY = *mut HTTP_503_RESPONSE_VERBOSITY; ENUM!{enum HTTP_QOS_SETTING_TYPE { HttpQosSettingTypeBandwidth, HttpQosSettingTypeConnectionLimit, HttpQosSettingTypeFlowRate, }} pub type PHTTP_QOS_SETTING_TYPE = *mut HTTP_QOS_SETTING_TYPE; STRUCT!{struct HTTP_QOS_SETTING_INFO { QosType: HTTP_QOS_SETTING_TYPE, QosSetting: ::PVOID, }} pub type PHTTP_QOS_SETTING_INFO = *mut HTTP_QOS_SETTING_INFO; STRUCT!{struct HTTP_CONNECTION_LIMIT_INFO { Flags: HTTP_PROPERTY_FLAGS, MaxConnections: ::ULONG, }} pub type PHTTP_CONNECTION_LIMIT_INFO = *mut HTTP_CONNECTION_LIMIT_INFO; STRUCT!{struct HTTP_BANDWIDTH_LIMIT_INFO { Flags: HTTP_PROPERTY_FLAGS, MaxBandwidth: ::ULONG, }} pub type PHTTP_BANDWIDTH_LIMIT_INFO = *mut HTTP_BANDWIDTH_LIMIT_INFO; STRUCT!{struct HTTP_FLOWRATE_INFO { Flags: HTTP_PROPERTY_FLAGS, MaxBandwidth: ::ULONG, MaxPeakBandwidth: ::ULONG, BurstSize: ::ULONG, }} pub type PHTTP_FLOWRATE_INFO = *mut HTTP_FLOWRATE_INFO; pub const HTTP_MIN_ALLOWED_BANDWIDTH_THROTTLING_RATE: ::ULONG = 1024; pub const HTTP_LIMIT_INFINITE: ::ULONG = !0; ENUM!{enum HTTP_SERVICE_CONFIG_TIMEOUT_KEY { IdleConnectionTimeout = 0, HeaderWaitTimeout, }} pub type PHTTP_SERVICE_CONFIG_TIMEOUT_KEY = *mut HTTP_SERVICE_CONFIG_TIMEOUT_KEY; pub type HTTP_SERVICE_CONFIG_TIMEOUT_PARAM = ::USHORT; pub type PHTTP_SERVICE_CONFIG_TIMEOUT_PARAM = *mut ::USHORT; STRUCT!{struct HTTP_SERVICE_CONFIG_TIMEOUT_SET { KeyDesc: HTTP_SERVICE_CONFIG_TIMEOUT_KEY, ParamDesc: HTTP_SERVICE_CONFIG_TIMEOUT_PARAM, }} pub type PHTTP_SERVICE_CONFIG_TIMEOUT_SET = *mut HTTP_SERVICE_CONFIG_TIMEOUT_SET; STRUCT!{struct HTTP_TIMEOUT_LIMIT_INFO { Flags: HTTP_PROPERTY_FLAGS, EntityBody: ::USHORT, DrainEntityBody: ::USHORT, RequestQueue: ::USHORT, IdleConnection: ::USHORT, HeaderWait: ::USHORT, MinSendRate: ::ULONG, }} pub type PHTTP_TIMEOUT_LIMIT_INFO = *mut HTTP_TIMEOUT_LIMIT_INFO; STRUCT!{struct HTTP_LISTEN_ENDPOINT_INFO { Flags: HTTP_PROPERTY_FLAGS, EnableSharing: ::BOOLEAN, }} pub type PHTTP_LISTEN_ENDPOINT_INFO = *mut HTTP_LISTEN_ENDPOINT_INFO; STRUCT!{struct HTTP_SERVER_AUTHENTICATION_DIGEST_PARAMS { DomainNameLength: ::USHORT, DomainName: ::PWSTR, RealmLength: ::USHORT, Realm: ::PWSTR, }} pub type PHTTP_SERVER_AUTHENTICATION_DIGEST_PARAMS = *mut HTTP_SERVER_AUTHENTICATION_DIGEST_PARAMS; STRUCT!{struct HTTP_SERVER_AUTHENTICATION_BASIC_PARAMS { RealmLength: ::USHORT, Realm: ::PWSTR, }} pub type PHTTP_SERVER_AUTHENTICATION_BASIC_PARAMS = *mut HTTP_SERVER_AUTHENTICATION_BASIC_PARAMS; pub const HTTP_AUTH_ENABLE_BASIC: ::ULONG = 0x00000001; pub const HTTP_AUTH_ENABLE_DIGEST: ::ULONG = 0x00000002; pub const HTTP_AUTH_ENABLE_NTLM: ::ULONG = 0x00000004; pub const HTTP_AUTH_ENABLE_NEGOTIATE: ::ULONG = 0x00000008; pub const HTTP_AUTH_ENABLE_KERBEROS: ::ULONG = 0x00000010; pub const HTTP_AUTH_ENABLE_ALL: ::ULONG = HTTP_AUTH_ENABLE_BASIC | HTTP_AUTH_ENABLE_DIGEST | HTTP_AUTH_ENABLE_NTLM | HTTP_AUTH_ENABLE_NEGOTIATE | HTTP_AUTH_ENABLE_KERBEROS; pub const HTTP_AUTH_EX_FLAG_ENABLE_KERBEROS_CREDENTIAL_CACHING: ::UCHAR = 0x01; pub const HTTP_AUTH_EX_FLAG_CAPTURE_CREDENTIAL: ::UCHAR = 0x02; STRUCT!{struct HTTP_SERVER_AUTHENTICATION_INFO { Flags: HTTP_PROPERTY_FLAGS, AuthSchemes: ::ULONG, ReceiveMutualAuth: ::BOOLEAN, ReceiveContextHandle: ::BOOLEAN, DisableNTLMCredentialCaching: ::BOOLEAN, ExFlags: ::UCHAR, DigestParams: HTTP_SERVER_AUTHENTICATION_DIGEST_PARAMS, BasicParams: HTTP_SERVER_AUTHENTICATION_BASIC_PARAMS, }} pub type PHTTP_SERVER_AUTHENTICATION_INFO = *mut HTTP_SERVER_AUTHENTICATION_INFO; ENUM!{enum HTTP_SERVICE_BINDING_TYPE { HttpServiceBindingTypeNone = 0, HttpServiceBindingTypeW, HttpServiceBindingTypeA, }} STRUCT!{struct HTTP_SERVICE_BINDING_BASE { Type: HTTP_SERVICE_BINDING_TYPE, }} pub type PHTTP_SERVICE_BINDING_BASE = *mut HTTP_SERVICE_BINDING_BASE; STRUCT!{struct HTTP_SERVICE_BINDING_A { Base: HTTP_SERVICE_BINDING_BASE, Buffer: ::PCHAR, BufferSize: ::ULONG, }} pub type PHTTP_SERVICE_BINDING_A = *mut HTTP_SERVICE_BINDING_A; STRUCT!{struct HTTP_SERVICE_BINDING_W { Base: HTTP_SERVICE_BINDING_BASE, Buffer: ::PWCHAR, BufferSize: ::ULONG, }} pub type PHTTP_SERVICE_BINDING_W = *mut HTTP_SERVICE_BINDING_W; ENUM!{enum HTTP_AUTHENTICATION_HARDENING_LEVELS { HttpAuthenticationHardeningLegacy = 0, HttpAuthenticationHardeningMedium, HttpAuthenticationHardeningStrict, }} pub const HTTP_CHANNEL_BIND_PROXY: ::ULONG = 0x1; pub const HTTP_CHANNEL_BIND_PROXY_COHOSTING: ::ULONG = 0x20; pub const HTTP_CHANNEL_BIND_NO_SERVICE_NAME_CHECK: ::ULONG = 0x2; pub const HTTP_CHANNEL_BIND_DOTLESS_SERVICE: ::ULONG = 0x4; pub const HTTP_CHANNEL_BIND_SECURE_CHANNEL_TOKEN: ::ULONG = 0x8; pub const HTTP_CHANNEL_BIND_CLIENT_SERVICE: ::ULONG = 0x10; STRUCT!{struct HTTP_CHANNEL_BIND_INFO { Hardening: HTTP_AUTHENTICATION_HARDENING_LEVELS, Flags: ::ULONG, ServiceNames: *mut PHTTP_SERVICE_BINDING_BASE, NumberOfServiceNames: ::ULONG, }} pub type PHTTP_CHANNEL_BIND_INFO = *mut HTTP_CHANNEL_BIND_INFO; STRUCT!{struct HTTP_REQUEST_CHANNEL_BIND_STATUS { ServiceName: PHTTP_SERVICE_BINDING_BASE, ChannelToken: ::PUCHAR, ChannelTokenSize: ::ULONG, Flags: ::ULONG, }} pub type PHTTP_REQUEST_CHANNEL_BIND_STATUS = *mut HTTP_REQUEST_CHANNEL_BIND_STATUS; pub const HTTP_LOG_FIELD_DATE: ::ULONG = 0x00000001; pub const HTTP_LOG_FIELD_TIME: ::ULONG = 0x00000002; pub const HTTP_LOG_FIELD_CLIENT_IP: ::ULONG = 0x00000004; pub const HTTP_LOG_FIELD_USER_NAME: ::ULONG = 0x00000008; pub const HTTP_LOG_FIELD_SITE_NAME: ::ULONG = 0x00000010; pub const HTTP_LOG_FIELD_COMPUTER_NAME: ::ULONG = 0x00000020; pub const HTTP_LOG_FIELD_SERVER_IP: ::ULONG = 0x00000040; pub const HTTP_LOG_FIELD_METHOD: ::ULONG = 0x00000080; pub const HTTP_LOG_FIELD_URI_STEM: ::ULONG = 0x00000100; pub const HTTP_LOG_FIELD_URI_QUERY: ::ULONG = 0x00000200; pub const HTTP_LOG_FIELD_STATUS: ::ULONG = 0x00000400; pub const HTTP_LOG_FIELD_WIN32_STATUS: ::ULONG = 0x00000800; pub const HTTP_LOG_FIELD_BYTES_SENT: ::ULONG = 0x00001000; pub const HTTP_LOG_FIELD_BYTES_RECV: ::ULONG = 0x00002000; pub const HTTP_LOG_FIELD_TIME_TAKEN: ::ULONG = 0x00004000; pub const HTTP_LOG_FIELD_SERVER_PORT: ::ULONG = 0x00008000; pub const HTTP_LOG_FIELD_USER_AGENT: ::ULONG = 0x00010000; pub const HTTP_LOG_FIELD_COOKIE: ::ULONG = 0x00020000; pub const HTTP_LOG_FIELD_REFERER: ::ULONG = 0x00040000; pub const HTTP_LOG_FIELD_VERSION: ::ULONG = 0x00080000; pub const HTTP_LOG_FIELD_HOST: ::ULONG = 0x00100000; pub const HTTP_LOG_FIELD_SUB_STATUS: ::ULONG = 0x00200000; pub const HTTP_LOG_FIELD_CLIENT_PORT: ::ULONG = 0x00400000; pub const HTTP_LOG_FIELD_URI: ::ULONG = 0x00800000; pub const HTTP_LOG_FIELD_SITE_ID: ::ULONG = 0x01000000; pub const HTTP_LOG_FIELD_REASON: ::ULONG = 0x02000000; pub const HTTP_LOG_FIELD_QUEUE_NAME: ::ULONG = 0x04000000; ENUM!{enum HTTP_LOGGING_TYPE { HttpLoggingTypeW3C, HttpLoggingTypeIIS, HttpLoggingTypeNCSA, HttpLoggingTypeRaw, }} ENUM!{enum HTTP_LOGGING_ROLLOVER_TYPE { HttpLoggingRolloverSize, HttpLoggingRolloverDaily, HttpLoggingRolloverWeekly, HttpLoggingRolloverMonthly, HttpLoggingRolloverHourly, }} pub const HTTP_MIN_ALLOWED_LOG_FILE_ROLLOVER_SIZE: ::ULONG = (1 * 1024 * 1024) as ::ULONG; pub const HTTP_LOGGING_FLAG_LOCAL_TIME_ROLLOVER: ::ULONG = 0x00000001; pub const HTTP_LOGGING_FLAG_USE_UTF8_CONVERSION: ::ULONG = 0x00000002; pub const HTTP_LOGGING_FLAG_LOG_ERRORS_ONLY: ::ULONG = 0x00000004; pub const HTTP_LOGGING_FLAG_LOG_SUCCESS_ONLY: ::ULONG = 0x00000008; STRUCT!{struct HTTP_LOGGING_INFO { Flags: HTTP_PROPERTY_FLAGS, LoggingFlags: ::ULONG, SoftwareName: ::PCWSTR, SoftwareNameLength: ::USHORT, DirectoryNameLength: ::USHORT, DirectoryName: ::PCWSTR, Format: HTTP_LOGGING_TYPE, Fields: ::ULONG, pExtFields: ::PVOID, NumOfExtFields: ::USHORT, MaxRecordSize: ::USHORT, RolloverType: HTTP_LOGGING_ROLLOVER_TYPE, RolloverSize: ::ULONG, pSecurityDescriptor: ::PSECURITY_DESCRIPTOR, }} pub type PHTTP_LOGGING_INFO = *mut HTTP_LOGGING_INFO; STRUCT!{struct HTTP_BINDING_INFO { Flags: HTTP_PROPERTY_FLAGS, RequestQueueHandle: ::HANDLE, }} pub type PHTTP_BINDING_INFO = *mut HTTP_BINDING_INFO; ENUM!{enum HTTP_PROTECTION_LEVEL_TYPE { HttpProtectionLevelUnrestricted, HttpProtectionLevelEdgeRestricted, HttpProtectionLevelRestricted, }} pub type PHTTP_PROTECTION_LEVEL_TYPE = *mut HTTP_PROTECTION_LEVEL_TYPE; STRUCT!{struct HTTP_PROTECTION_LEVEL_INFO { Flags: HTTP_PROPERTY_FLAGS, Level: HTTP_PROTECTION_LEVEL_TYPE, }} pub type PHTTP_PROTECTION_LEVEL_INFO = *mut HTTP_PROTECTION_LEVEL_INFO; pub const HTTP_CREATE_REQUEST_QUEUE_FLAG_OPEN_EXISTING: ::ULONG = 0x00000001; pub const HTTP_CREATE_REQUEST_QUEUE_FLAG_CONTROLLER: ::ULONG = 0x00000002; pub const HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY: ::ULONG = 0x00000001; pub const HTTP_RECEIVE_REQUEST_FLAG_FLUSH_BODY: ::ULONG = 0x00000002; pub const HTTP_RECEIVE_REQUEST_ENTITY_BODY_FLAG_FILL_BUFFER: ::ULONG = 0x00000001; pub const HTTP_SEND_RESPONSE_FLAG_DISCONNECT: ::ULONG = 0x00000001; pub const HTTP_SEND_RESPONSE_FLAG_MORE_DATA: ::ULONG = 0x00000002; pub const HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA: ::ULONG = 0x00000004; pub const HTTP_SEND_RESPONSE_FLAG_ENABLE_NAGLING: ::ULONG = 0x00000008; pub const HTTP_SEND_RESPONSE_FLAG_PROCESS_RANGES: ::ULONG = 0x00000020; pub const HTTP_SEND_RESPONSE_FLAG_OPAQUE: ::ULONG = 0x00000040; pub const HTTP_FLUSH_RESPONSE_FLAG_RECURSIVE: ::ULONG = 0x00000001; pub type HTTP_OPAQUE_ID = ::ULONGLONG; pub type PHTTP_OPAQUE_ID = *mut ::ULONGLONG; pub type HTTP_REQUEST_ID = HTTP_OPAQUE_ID; pub type PHTTP_REQUEST_ID = *mut HTTP_OPAQUE_ID; pub type HTTP_CONNECTION_ID = HTTP_OPAQUE_ID; pub type PHTTP_CONNECTION_ID = *mut HTTP_OPAQUE_ID; pub type HTTP_RAW_CONNECTION_ID = HTTP_OPAQUE_ID; pub type PHTTP_RAW_CONNECTION_ID = *mut HTTP_OPAQUE_ID; pub type HTTP_URL_GROUP_ID = HTTP_OPAQUE_ID; pub type PHTTP_URL_GROUP_ID = *mut HTTP_OPAQUE_ID; pub type HTTP_SERVER_SESSION_ID = HTTP_OPAQUE_ID; pub type PHTTP_SERVER_SESSION_ID = *mut HTTP_OPAQUE_ID; pub const HTTP_BYTE_RANGE_TO_EOF: ::ULONGLONG = !0; STRUCT!{struct HTTP_BYTE_RANGE { StartingOffset: ::ULARGE_INTEGER, Length: ::ULARGE_INTEGER, }} pub type PHTTP_BYTE_RANGE = *mut HTTP_BYTE_RANGE; STRUCT!{struct HTTP_VERSION { MajorVersion: ::USHORT, MinorVersion: ::USHORT, }} pub type PHTTP_VERSION = *mut HTTP_VERSION; pub const HTTP_VERSION_UNKNOWN: HTTP_VERSION = HTTP_VERSION { MajorVersion: 0, MinorVersion: 0 }; pub const HTTP_VERSION_0_9: HTTP_VERSION = HTTP_VERSION { MajorVersion: 0, MinorVersion: 9 }; pub const HTTP_VERSION_1_0: HTTP_VERSION = HTTP_VERSION { MajorVersion: 1, MinorVersion: 0 }; pub const HTTP_VERSION_1_1: HTTP_VERSION = HTTP_VERSION { MajorVersion: 1, MinorVersion: 1 }; #[inline] #[allow(dead_code)] pub fn HTTP_SET_VERSION(mut version: HTTP_VERSION, major: ::USHORT, minor: ::USHORT) { version.MajorVersion = major; version.MinorVersion = minor; } #[inline] #[allow(dead_code)] pub fn HTTP_EQUAL_VERSION(version: HTTP_VERSION, major: ::USHORT, minor: ::USHORT) -> bool { version.MajorVersion == major && version.MinorVersion == minor } #[inline] #[allow(dead_code)] pub fn HTTP_GREATER_VERSION(version: HTTP_VERSION, major: ::USHORT, minor: ::USHORT) -> bool { version.MajorVersion > major || (version.MajorVersion == major && version.MinorVersion > minor) } #[inline] #[allow(dead_code)] pub fn HTTP_LESS_VERSION(version: HTTP_VERSION, major: ::USHORT, minor: ::USHORT) -> bool { version.MajorVersion < major || (version.MajorVersion == major && version.MinorVersion < minor) } #[inline] #[allow(dead_code)] pub fn HTTP_NOT_EQUAL_VERSION(version: HTTP_VERSION, major: ::USHORT, minor: ::USHORT) -> bool { !HTTP_EQUAL_VERSION(version, major, minor) } #[inline] #[allow(dead_code)] pub fn HTTP_GREATER_EQUAL_VERSION(version: HTTP_VERSION, major: ::USHORT, minor: ::USHORT) -> bool { !HTTP_LESS_VERSION(version, major, minor) } #[inline] #[allow(dead_code)] pub fn HTTP_LESS_EQUAL_VERSION(version: HTTP_VERSION, major: ::USHORT, minor: ::USHORT) -> bool { !HTTP_GREATER_VERSION(version, major, minor) } ENUM!{enum HTTP_VERB { HttpVerbUnparsed, HttpVerbUnknown, HttpVerbInvalid, HttpVerbOPTIONS, HttpVerbGET, HttpVerbHEAD, HttpVerbPOST, HttpVerbPUT, HttpVerbDELETE, HttpVerbTRACE, HttpVerbCONNECT, HttpVerbTRACK, HttpVerbMOVE, HttpVerbCOPY, HttpVerbPROPFIND, HttpVerbPROPPATCH, HttpVerbMKCOL, HttpVerbLOCK, HttpVerbUNLOCK, HttpVerbSEARCH, HttpVerbMaximum, }} pub type PHTTP_VERB = *mut HTTP_VERB; ENUM!{enum HTTP_HEADER_ID { HttpHeaderCacheControl = 0, HttpHeaderConnection = 1, HttpHeaderDate = 2, HttpHeaderKeepAlive = 3, HttpHeaderPragma = 4, HttpHeaderTrailer = 5, HttpHeaderTransferEncoding = 6, HttpHeaderUpgrade = 7, HttpHeaderVia = 8, HttpHeaderWarning = 9, HttpHeaderAllow = 10, HttpHeaderContentLength = 11, HttpHeaderContentType = 12, HttpHeaderContentEncoding = 13, HttpHeaderContentLanguage = 14, HttpHeaderContentLocation = 15, HttpHeaderContentMd5 = 16, HttpHeaderContentRange = 17, HttpHeaderExpires = 18, HttpHeaderLastModified = 19, HttpHeaderAccept = 20, HttpHeaderAcceptCharset = 21, HttpHeaderAcceptEncoding = 22, HttpHeaderAcceptLanguage = 23, HttpHeaderAuthorization = 24, HttpHeaderCookie = 25, HttpHeaderExpect = 26, HttpHeaderFrom = 27, HttpHeaderHost = 28, HttpHeaderIfMatch = 29, HttpHeaderIfModifiedSince = 30, HttpHeaderIfNoneMatch = 31, HttpHeaderIfRange = 32, HttpHeaderIfUnmodifiedSince = 33, HttpHeaderMaxForwards = 34, HttpHeaderProxyAuthorization = 35, HttpHeaderReferer = 36, HttpHeaderRange = 37, HttpHeaderTe = 38, HttpHeaderTranslate = 39, HttpHeaderUserAgent = 40, HttpHeaderRequestMaximum = 41, HttpHeaderAcceptRanges = 20, HttpHeaderAge = 21, HttpHeaderEtag = 22, HttpHeaderLocation = 23, HttpHeaderProxyAuthenticate = 24, HttpHeaderRetryAfter = 25, HttpHeaderServer = 26, HttpHeaderSetCookie = 27, HttpHeaderVary = 28, HttpHeaderWwwAuthenticate = 29, HttpHeaderResponseMaximum = 30, HttpHeaderMaximum = 41, }} pub type PHTTP_HEADER_ID = *mut HTTP_HEADER_ID; STRUCT!{struct HTTP_KNOWN_HEADER { RawValueLength: ::USHORT, pRawValue: ::PCSTR, }} pub type PHTTP_KNOWN_HEADER = *mut HTTP_KNOWN_HEADER; STRUCT!{struct HTTP_UNKNOWN_HEADER { NameLength: ::USHORT, RawValueLength: ::USHORT, pName: ::PCSTR, pRawValue: ::PCSTR, }} pub type PHTTP_UNKNOWN_HEADER = *mut HTTP_UNKNOWN_HEADER; ENUM!{enum HTTP_LOG_DATA_TYPE { HttpLogDataTypeFields = 0, }} pub type PHTTP_LOG_DATA_TYPE = *mut HTTP_LOG_DATA_TYPE; STRUCT!{struct HTTP_LOG_DATA { Type: HTTP_LOG_DATA_TYPE, }} pub type PHTTP_LOG_DATA = *mut HTTP_LOG_DATA; STRUCT!{struct HTTP_LOG_FIELDS_DATA { Base: HTTP_LOG_DATA, UserNameLength: ::USHORT, UriStemLength: ::USHORT, ClientIpLength: ::USHORT, ServerNameLength: ::USHORT, ServiceNameLength: ::USHORT, ServerIpLength: ::USHORT, MethodLength: ::USHORT, UriQueryLength: ::USHORT, HostLength: ::USHORT, UserAgentLength: ::USHORT, CookieLength: ::USHORT, ReferrerLength: ::USHORT, UserName: ::PWCHAR, UriStem: ::PWCHAR, ClientIp: ::PCHAR, ServerName: ::PCHAR, ServiceName: ::PCHAR, ServerIp: ::PCHAR, Method: ::PCHAR, UriQuery: ::PCHAR, Host: ::PCHAR, UserAgent: ::PCHAR, Cookie: ::PCHAR, Referrer: ::PCHAR, ServerPort: ::USHORT, ProtocolStatus: ::USHORT, Win32Status: ::ULONG, MethodNum: HTTP_VERB, SubStatus: ::USHORT, }} pub type PHTTP_LOG_FIELDS_DATA = *mut HTTP_LOG_FIELDS_DATA; ENUM!{enum HTTP_DATA_CHUNK_TYPE { HttpDataChunkFromMemory, HttpDataChunkFromFileHandle, HttpDataChunkFromFragmentCache, HttpDataChunkFromFragmentCacheEx, HttpDataChunkMaximum, }} pub type PHTTP_DATA_CHUNK_TYPE = *mut HTTP_DATA_CHUNK_TYPE; STRUCT!{struct HTTP_DATA_CHUNK_FromMemory { pBuffer: ::PVOID, BufferLength: ::ULONG, }} STRUCT!{struct HTTP_DATA_CHUNK_FromFileHandle { ByteRange: HTTP_BYTE_RANGE, FileHandle: ::HANDLE, }} STRUCT!{struct HTTP_DATA_CHUNK_FromFragmentCache { FragmentNameLength: ::USHORT, pFragmentName: ::PCWSTR, }} STRUCT!{struct HTTP_DATA_CHUNK_FromFragmentCacheEx { ByteRange: HTTP_BYTE_RANGE, pFragmentName: ::PCWSTR, }} STRUCT!{struct HTTP_DATA_CHUNK { DataChunkType: HTTP_DATA_CHUNK_TYPE, FromFileHandle: HTTP_DATA_CHUNK_FromFileHandle, }} UNION!(HTTP_DATA_CHUNK, FromFileHandle, FromMemory, FromMemory_mut, HTTP_DATA_CHUNK_FromMemory); UNION!( HTTP_DATA_CHUNK, FromFileHandle, FromFragmentCache, FromFragmentCache_mut, HTTP_DATA_CHUNK_FromFragmentCache ); UNION!( HTTP_DATA_CHUNK, FromFileHandle, FromFragmentCacheEx, FromFragmentCacheEx_mut, HTTP_DATA_CHUNK_FromFragmentCacheEx ); pub type PHTTP_DATA_CHUNK = *mut HTTP_DATA_CHUNK; #[repr(C)] #[derive(Copy)] pub struct HTTP_REQUEST_HEADERS { pub UnknownHeaderCount: ::USHORT, pub pUnknownHeaders: PHTTP_UNKNOWN_HEADER, pub TrailerCount: ::USHORT, pub pTrailers: PHTTP_UNKNOWN_HEADER, pub KnownHeaders: [HTTP_KNOWN_HEADER; 41], // FIXME HttpHeaderRequestMaximum } impl Clone for HTTP_REQUEST_HEADERS { fn clone(&self) -> HTTP_REQUEST_HEADERS { *self } } pub type PHTTP_REQUEST_HEADERS = *mut HTTP_REQUEST_HEADERS; #[repr(C)] #[derive(Copy)] pub struct HTTP_RESPONSE_HEADERS { pub UnknownHeaderCount: ::USHORT, pub pUnknownHeaders: PHTTP_UNKNOWN_HEADER, pub TrailerCount: ::USHORT, pub pTrailers: PHTTP_UNKNOWN_HEADER, pub KnownHeaders: [HTTP_KNOWN_HEADER; 30], // FIXME HttpHeaderResponseMaximum } impl Clone for HTTP_RESPONSE_HEADERS { fn clone(&self) -> HTTP_RESPONSE_HEADERS { *self } } pub type PHTTP_RESPONSE_HEADERS = *mut HTTP_RESPONSE_HEADERS; STRUCT!{struct HTTP_TRANSPORT_ADDRESS { pRemoteAddress: ::PSOCKADDR, pLocalAddress: ::PSOCKADDR, }} pub type PHTTP_TRANSPORT_ADDRESS = *mut HTTP_TRANSPORT_ADDRESS; STRUCT!{struct HTTP_COOKED_URL { FullUrlLength: ::USHORT, HostLength: ::USHORT, AbsPathLength: ::USHORT, QueryStringLength: ::USHORT, pFullUrl: ::PCWSTR, pHost: ::PCWSTR, pAbsPath: ::PCWSTR, pQueryString: ::PCWSTR, }} pub type PHTTP_COOKED_URL = *mut HTTP_COOKED_URL; pub type HTTP_URL_CONTEXT = ::ULONGLONG; pub const HTTP_URL_FLAG_REMOVE_ALL: ::ULONG = 0x00000001; ENUM!{enum HTTP_AUTH_STATUS { HttpAuthStatusSuccess, HttpAuthStatusNotAuthenticated, HttpAuthStatusFailure, }} pub type PHTTP_AUTH_STATUS = *mut HTTP_AUTH_STATUS; ENUM!{enum HTTP_REQUEST_AUTH_TYPE { HttpRequestAuthTypeNone = 0, HttpRequestAuthTypeBasic, HttpRequestAuthTypeDigest, HttpRequestAuthTypeNTLM, HttpRequestAuthTypeNegotiate, HttpRequestAuthTypeKerberos, }} pub type PHTTP_REQUEST_AUTH_TYPE = *mut HTTP_REQUEST_AUTH_TYPE; STRUCT!{struct HTTP_SSL_CLIENT_CERT_INFO { CertFlags: ::ULONG, CertEncodedSize: ::ULONG, pCertEncoded: ::PUCHAR, Token: ::HANDLE, CertDeniedByMapper: ::BOOLEAN, }} pub type PHTTP_SSL_CLIENT_CERT_INFO = *mut HTTP_SSL_CLIENT_CERT_INFO; pub const HTTP_RECEIVE_SECURE_CHANNEL_TOKEN: ::ULONG = 0x1; STRUCT!{struct HTTP_SSL_INFO { ServerCertKeySize: ::USHORT, ConnectionKeySize: ::USHORT, ServerCertIssuerSize: ::ULONG, ServerCertSubjectSize: ::ULONG, pServerCertIssuer: ::PCSTR, pServerCertSubject: ::PCSTR, pClientCertInfo: PHTTP_SSL_CLIENT_CERT_INFO, SslClientCertNegotiated: ::ULONG, }} pub type PHTTP_SSL_INFO = *mut HTTP_SSL_INFO; ENUM!{enum HTTP_REQUEST_INFO_TYPE { HttpRequestInfoTypeAuth, HttpRequestInfoTypeChannelBind, }} STRUCT!{struct HTTP_REQUEST_INFO { InfoType: HTTP_REQUEST_INFO_TYPE, InfoLength: ::ULONG, pInfo: ::PVOID, }} pub type PHTTP_REQUEST_INFO = *mut HTTP_REQUEST_INFO; pub const HTTP_REQUEST_AUTH_FLAG_TOKEN_FOR_CACHED_CRED: ::ULONG = 0x00000001; STRUCT!{struct HTTP_REQUEST_AUTH_INFO { AuthStatus: HTTP_AUTH_STATUS, SecStatus: ::SECURITY_STATUS, Flags: ::ULONG, AuthType: HTTP_REQUEST_AUTH_TYPE, AccessToken: ::HANDLE, ContextAttributes: ::ULONG, PackedContextLength: ::ULONG, PackedContextType: ::ULONG, PackedContext: ::PVOID, MutualAuthDataLength: ::ULONG, pMutualAuthData: ::PCHAR, PackageNameLength: ::USHORT, pPackageName: ::PWSTR, }} pub type PHTTP_REQUEST_AUTH_INFO = *mut HTTP_REQUEST_AUTH_INFO; #[repr(C)] #[derive(Clone, Copy)] pub struct HTTP_REQUEST_V1 { pub Flags: ::ULONG, pub ConnectionId: HTTP_CONNECTION_ID, pub RequestId: HTTP_REQUEST_ID, pub UrlContext: HTTP_URL_CONTEXT, pub Version: HTTP_VERSION, pub Verb: HTTP_VERB, pub UnknownVerbLength: ::USHORT, pub RawUrlLength: ::USHORT, pub pUnknownVerb: ::PCSTR, pub pRawUrl: ::PCSTR, pub CookedUrl: HTTP_COOKED_URL, pub Address: HTTP_TRANSPORT_ADDRESS, pub Headers: HTTP_REQUEST_HEADERS, pub BytesReceived: ::ULONGLONG, pub EntityChunkCount: ::USHORT, pub pEntityChunks: PHTTP_DATA_CHUNK, pub RawConnectionId: HTTP_RAW_CONNECTION_ID, pub pSslInfo: PHTTP_SSL_INFO, } pub type PHTTP_REQUEST_V1 = *mut HTTP_REQUEST_V1; #[repr(C)] #[derive(Clone, Copy)] pub struct HTTP_REQUEST_V2 { pub Base: HTTP_REQUEST_V1, pub RequestInfoCount: ::USHORT, pub pRequestInfo: PHTTP_REQUEST_INFO, } pub type PHTTP_REQUEST_V2 = *mut HTTP_REQUEST_V2; pub type HTTP_REQUEST = HTTP_REQUEST_V2; pub type PHTTP_REQUEST = *mut HTTP_REQUEST; pub const HTTP_REQUEST_FLAG_MORE_ENTITY_BODY_EXISTS: ::ULONG = 0x00000001; pub const HTTP_REQUEST_FLAG_IP_ROUTED: ::ULONG = 0x00000002; #[repr(C)] #[derive(Clone, Copy)] pub struct HTTP_RESPONSE_V1 { pub Flags: ::ULONG, pub Version: HTTP_VERSION, pub StatusCode: ::USHORT, pub ReasonLength: ::USHORT, pub pReason: ::PCSTR, pub Headers: HTTP_RESPONSE_HEADERS, pub EntityChunkCount: ::USHORT, pub pEntityChunks: PHTTP_DATA_CHUNK, } pub type PHTTP_RESPONSE_V1 = *mut HTTP_RESPONSE_V1; pub const HTTP_RESPONSE_FLAG_MULTIPLE_ENCODINGS_AVAILABLE: ::ULONG = 0x00000001; ENUM!{enum HTTP_RESPONSE_INFO_TYPE { HttpResponseInfoTypeMultipleKnownHeaders, HttpResponseInfoTypeAuthenticationProperty, HttpResponseInfoTypeQoSProperty, HttpResponseInfoTypeChannelBind, }} pub type PHTTP_RESPONSE_INFO_TYPE = *mut HTTP_RESPONSE_INFO_TYPE; STRUCT!{struct HTTP_RESPONSE_INFO { Type: HTTP_RESPONSE_INFO_TYPE, Length: ::ULONG, pInfo: ::PVOID, }} pub type PHTTP_RESPONSE_INFO = *mut HTTP_RESPONSE_INFO; pub const HTTP_RESPONSE_INFO_FLAGS_PRESERVE_ORDER: ::ULONG = 0x00000001; STRUCT!{struct HTTP_MULTIPLE_KNOWN_HEADERS { HeaderId: HTTP_HEADER_ID, Flags: ::ULONG, KnownHeaderCount: ::USHORT, KnownHeaders: PHTTP_KNOWN_HEADER, }} pub type PHTTP_MULTIPLE_KNOWN_HEADERS = *mut HTTP_MULTIPLE_KNOWN_HEADERS; #[repr(C)] #[derive(Clone, Copy)] pub struct HTTP_RESPONSE_V2 { pub Base: HTTP_RESPONSE_V1, pub ResponseInfoCount: ::USHORT, pub pResponseInfo: PHTTP_RESPONSE_INFO, } pub type PHTTP_RESPONSE_V2 = *mut HTTP_RESPONSE_V2; pub type HTTP_RESPONSE = HTTP_RESPONSE_V2; pub type PHTTP_RESPONSE = *mut HTTP_RESPONSE; STRUCT!{struct HTTPAPI_VERSION { HttpApiMajorVersion: ::USHORT, HttpApiMinorVersion: ::USHORT, }} pub type PHTTPAPI_VERSION = *mut HTTPAPI_VERSION; pub const HTTPAPI_VERSION_2: HTTPAPI_VERSION = HTTPAPI_VERSION { HttpApiMajorVersion: 2, HttpApiMinorVersion: 0, }; pub const HTTPAPI_VERSION_1: HTTPAPI_VERSION = HTTPAPI_VERSION { HttpApiMajorVersion: 1, HttpApiMinorVersion: 0, }; #[inline] #[allow(dead_code)] pub fn HTTPAPI_EQUAL_VERSION(version: HTTPAPI_VERSION, major: ::USHORT, minor: ::USHORT) -> bool { version.HttpApiMajorVersion == major && version.HttpApiMinorVersion == minor } #[inline] #[allow(dead_code)] pub fn HTTPAPI_GREATER_VERSION(version: HTTPAPI_VERSION, major: ::USHORT, minor: ::USHORT) -> bool { version.HttpApiMajorVersion > major || (version.HttpApiMajorVersion == major && version.HttpApiMinorVersion > minor) } #[inline] #[allow(dead_code)] pub fn HTTPAPI_LESS_VERSION(version: HTTPAPI_VERSION, major: ::USHORT, minor: ::USHORT) -> bool { version.HttpApiMajorVersion < major || (version.HttpApiMajorVersion == major && version.HttpApiMinorVersion < minor) } #[inline] #[allow(dead_code)] pub fn HTTPAPI_VERSION_GREATER_OR_EQUAL( version: HTTPAPI_VERSION, major: ::USHORT, minor: ::USHORT ) -> bool { !HTTPAPI_LESS_VERSION(version, major, minor) } ENUM!{enum HTTP_CACHE_POLICY_TYPE { HttpCachePolicyNocache, HttpCachePolicyUserInvalidates, HttpCachePolicyTimeToLive, HttpCachePolicyMaximum, }} pub type PHTTP_CACHE_POLICY_TYPE = *mut HTTP_CACHE_POLICY_TYPE; STRUCT!{struct HTTP_CACHE_POLICY { Policy: HTTP_CACHE_POLICY_TYPE, SecondsToLive: ::ULONG, }} pub type PHTTP_CACHE_POLICY = *mut HTTP_CACHE_POLICY; ENUM!{enum HTTP_SERVICE_CONFIG_ID { HttpServiceConfigIPListenList, HttpServiceConfigSSLCertInfo, HttpServiceConfigUrlAclInfo, HttpServiceConfigTimeout, HttpServiceConfigCache, HttpServiceConfigSslSniCertInfo, HttpServiceConfigSslCcsCertInfo, HttpServiceConfigMax, }} pub type PHTTP_SERVICE_CONFIG_ID = *mut HTTP_SERVICE_CONFIG_ID; ENUM!{enum HTTP_SERVICE_CONFIG_QUERY_TYPE { HttpServiceConfigQueryExact, HttpServiceConfigQueryNext, HttpServiceConfigQueryMax, }} pub type PHTTP_SERVICE_CONFIG_QUERY_TYPE = *mut HTTP_SERVICE_CONFIG_QUERY_TYPE; STRUCT!{struct HTTP_SERVICE_CONFIG_SSL_KEY { pIpPort: ::PSOCKADDR, }} pub type PHTTP_SERVICE_CONFIG_SSL_KEY = *mut HTTP_SERVICE_CONFIG_SSL_KEY; #[repr(C)] #[derive(Clone, Copy)] pub struct HTTP_SERVICE_CONFIG_SSL_SNI_KEY { pub IpPort: ::SOCKADDR_STORAGE, pub Host: ::PWSTR, } pub type PHTTP_SERVICE_CONFIG_SSL_SNI_KEY = *mut HTTP_SERVICE_CONFIG_SSL_SNI_KEY; #[repr(C)] #[derive(Clone, Copy)] pub struct HTTP_SERVICE_CONFIG_SSL_CCS_KEY { pub LocalAddress: ::SOCKADDR_STORAGE, } pub type PHTTP_SERVICE_CONFIG_SSL_CCS_KEY = *mut HTTP_SERVICE_CONFIG_SSL_CCS_KEY; STRUCT!{struct HTTP_SERVICE_CONFIG_SSL_PARAM { SslHashLength: ::ULONG, pSslHash: ::PVOID, AppId: ::GUID, pSslCertStoreName: ::PWSTR, DefaultCertCheckMode: ::DWORD, DefaultRevocationFreshnessTime: ::DWORD, DefaultRevocationUrlRetrievalTimeout: ::DWORD, pDefaultSslCtlIdentifier: ::PWSTR, pDefaultSslCtlStoreName: ::PWSTR, DefaultFlags: ::DWORD, }} pub type PHTTP_SERVICE_CONFIG_SSL_PARAM = *mut HTTP_SERVICE_CONFIG_SSL_PARAM; pub const HTTP_SERVICE_CONFIG_SSL_FLAG_USE_DS_MAPPER: ::DWORD = 0x00000001; pub const HTTP_SERVICE_CONFIG_SSL_FLAG_NEGOTIATE_CLIENT_CERT: ::DWORD = 0x00000002; pub const HTTP_SERVICE_CONFIG_SSL_FLAG_NO_RAW_FILTER: ::DWORD = 0x00000004; STRUCT!{struct HTTP_SERVICE_CONFIG_SSL_SET { KeyDesc: HTTP_SERVICE_CONFIG_SSL_KEY, ParamDesc: HTTP_SERVICE_CONFIG_SSL_PARAM, }} pub type PHTTP_SERVICE_CONFIG_SSL_SET = *mut HTTP_SERVICE_CONFIG_SSL_SET; #[repr(C)] #[derive(Clone, Copy)] pub struct HTTP_SERVICE_CONFIG_SSL_SNI_SET { pub KeyDesc: HTTP_SERVICE_CONFIG_SSL_SNI_KEY, pub ParamDesc: HTTP_SERVICE_CONFIG_SSL_PARAM, } pub type PHTTP_SERVICE_CONFIG_SSL_SNI_SET = *mut HTTP_SERVICE_CONFIG_SSL_SNI_SET; #[repr(C)] #[derive(Clone, Copy)] pub struct HTTP_SERVICE_CONFIG_SSL_CCS_SET { pub KeyDesc: HTTP_SERVICE_CONFIG_SSL_CCS_KEY, pub ParamDesc: HTTP_SERVICE_CONFIG_SSL_PARAM, } pub type PHTTP_SERVICE_CONFIG_SSL_CCS_SET = *mut HTTP_SERVICE_CONFIG_SSL_CCS_SET; STRUCT!{struct HTTP_SERVICE_CONFIG_SSL_QUERY { QueryDesc: HTTP_SERVICE_CONFIG_QUERY_TYPE, KeyDesc: HTTP_SERVICE_CONFIG_SSL_KEY, dwToken: ::DWORD, }} pub type PHTTP_SERVICE_CONFIG_SSL_QUERY = *mut HTTP_SERVICE_CONFIG_SSL_QUERY; #[repr(C)] #[derive(Clone, Copy)] pub struct HTTP_SERVICE_CONFIG_SSL_SNI_QUERY { pub QueryDesc: HTTP_SERVICE_CONFIG_QUERY_TYPE, pub KeyDesc: HTTP_SERVICE_CONFIG_SSL_SNI_KEY, pub dwToken: ::DWORD, } pub type PHTTP_SERVICE_CONFIG_SSL_SNI_QUERY = *mut HTTP_SERVICE_CONFIG_SSL_SNI_QUERY; #[repr(C)] #[derive(Clone, Copy)] pub struct HTTP_SERVICE_CONFIG_SSL_CCS_QUERY { pub QueryDesc: HTTP_SERVICE_CONFIG_QUERY_TYPE, pub KeyDesc: HTTP_SERVICE_CONFIG_SSL_CCS_KEY, pub dwToken: ::DWORD, } pub type PHTTP_SERVICE_CONFIG_SSL_CCS_QUERY = *mut HTTP_SERVICE_CONFIG_SSL_CCS_QUERY; STRUCT!{struct HTTP_SERVICE_CONFIG_IP_LISTEN_PARAM { AddrLength: ::USHORT, pAddress: ::PSOCKADDR, }} pub type PHTTP_SERVICE_CONFIG_IP_LISTEN_PARAM = *mut HTTP_SERVICE_CONFIG_IP_LISTEN_PARAM; #[repr(C)] #[derive(Clone, Copy)] pub struct HTTP_SERVICE_CONFIG_IP_LISTEN_QUERY { pub AddrCount: ::ULONG, pub AddrList: [::SOCKADDR_STORAGE; ::ANYSIZE_ARRAY], } pub type PHTTP_SERVICE_CONFIG_IP_LISTEN_QUERY = *mut HTTP_SERVICE_CONFIG_IP_LISTEN_QUERY; STRUCT!{struct HTTP_SERVICE_CONFIG_URLACL_KEY { pUrlPrefix: ::PWSTR, }} pub type PHTTP_SERVICE_CONFIG_URLACL_KEY = *mut HTTP_SERVICE_CONFIG_URLACL_KEY; STRUCT!{struct HTTP_SERVICE_CONFIG_URLACL_PARAM { pStringSecurityDescriptor: ::PWSTR, }} pub type PHTTP_SERVICE_CONFIG_URLACL_PARAM = *mut HTTP_SERVICE_CONFIG_URLACL_PARAM; STRUCT!{struct HTTP_SERVICE_CONFIG_URLACL_SET { KeyDesc: HTTP_SERVICE_CONFIG_URLACL_KEY, ParamDesc: HTTP_SERVICE_CONFIG_URLACL_PARAM, }} pub type PHTTP_SERVICE_CONFIG_URLACL_SET = *mut HTTP_SERVICE_CONFIG_URLACL_SET; STRUCT!{struct HTTP_SERVICE_CONFIG_URLACL_QUERY { QueryDesc: HTTP_SERVICE_CONFIG_QUERY_TYPE, KeyDesc: HTTP_SERVICE_CONFIG_URLACL_KEY, dwToken: ::DWORD, }} pub type PHTTP_SERVICE_CONFIG_URLACL_QUERY = *mut HTTP_SERVICE_CONFIG_URLACL_QUERY; ENUM!{enum HTTP_SERVICE_CONFIG_CACHE_KEY { MaxCacheResponseSize = 0, CacheRangeChunkSize, }} pub type PHTTP_SERVICE_CONFIG_CACHE_KEY = *mut HTTP_SERVICE_CONFIG_CACHE_KEY; pub type HTTP_SERVICE_CONFIG_CACHE_PARAM = ::ULONG; pub type PHTTP_SERVICE_CONFIG_CACHE_PARAM = *mut ::ULONG; STRUCT!{struct HTTP_SERVICE_CONFIG_CACHE_SET { KeyDesc: HTTP_SERVICE_CONFIG_CACHE_KEY, ParamDesc: HTTP_SERVICE_CONFIG_CACHE_PARAM, }} pub type PHTTP_SERVICE_CONFIG_CACHE_SET = *mut HTTP_SERVICE_CONFIG_CACHE_SET; deps/winapi-0.2.5/src/prsht.rs0000644000000000000000000003000612613167613014740 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Interface for the Windows Property Sheet Pages #[repr(C)] #[allow(missing_copy_implementations)] pub struct PSP { unused: ::c_void, } pub type HPROPSHEETPAGE = *mut PSP; pub type LPFNPSPCALLBACKA = Option ::UINT>; pub type LPFNPSPCALLBACKW = Option ::UINT>; pub const PSP_DEFAULT: ::DWORD = 0x00000000; pub const PSP_DLGINDIRECT: ::DWORD = 0x00000001; pub const PSP_USEHICON: ::DWORD = 0x00000002; pub const PSP_USEICONID: ::DWORD = 0x00000004; pub const PSP_USETITLE: ::DWORD = 0x00000008; pub const PSP_RTLREADING: ::DWORD = 0x00000010; pub const PSP_HASHELP: ::DWORD = 0x00000020; pub const PSP_USEREFPARENT: ::DWORD = 0x00000040; pub const PSP_USECALLBACK: ::DWORD = 0x00000080; pub const PSP_PREMATURE: ::DWORD = 0x00000400; pub const PSP_HIDEHEADER: ::DWORD = 0x00000800; pub const PSP_USEHEADERTITLE: ::DWORD = 0x00001000; pub const PSP_USEHEADERSUBTITLE: ::DWORD = 0x00002000; pub const PSP_USEFUSIONCONTEXT: ::DWORD = 0x00004000; pub const PSPCB_ADDREF: ::UINT = 0; pub const PSPCB_RELEASE: ::UINT = 1; pub const PSPCB_CREATE: ::UINT = 2; pub type PROPSHEETPAGE_RESOURCE = ::LPCDLGTEMPLATEA; #[repr(C)] #[derive(Copy)] pub struct PROPSHEETPAGEA_V4 { pub dwSize: ::DWORD, pub dwFlags: ::DWORD, pub hInstance: ::HINSTANCE, pub pszTemplate: ::LPCSTR, pub hIcon: ::HICON, pub pszTitle: ::LPCSTR, pub pfnDlgProc: ::DLGPROC, pub lParam: ::LPARAM, pub pfnCallback: LPFNPSPCALLBACKA, pub pcRefParent: *mut ::UINT, pub pszHeaderTitle: ::LPCSTR, pub pszHeaderSubTitle: ::LPCSTR, pub hActCtx: ::HANDLE, pub hbmHeader: ::HBITMAP } impl Clone for PROPSHEETPAGEA_V4 { fn clone(&self) -> PROPSHEETPAGEA_V4 { *self } } UNION!(PROPSHEETPAGEA_V4, pszTemplate, pResource, pResource_mut, PROPSHEETPAGE_RESOURCE); UNION!(PROPSHEETPAGEA_V4, hIcon, pszIcon, pszIcon_mut, ::LPCSTR); UNION!(PROPSHEETPAGEA_V4, hbmHeader, pszbmHeader, pszbmHeader_mut, ::LPCSTR); pub type LPPROPSHEETPAGEA_V4 = *mut PROPSHEETPAGEA_V4; pub type LPCPROPSHEETPAGEA_V4 = *const PROPSHEETPAGEA_V4; #[repr(C)] #[derive(Copy)] pub struct PROPSHEETPAGEW_V4 { pub dwSize: ::DWORD, pub dwFlags: ::DWORD, pub hInstance: ::HINSTANCE, pub pszTemplate: ::LPCWSTR, pub hIcon: ::HICON, pub pszTitle: ::LPCWSTR, pub pfnDlgProc: ::DLGPROC, pub lParam: ::LPARAM, pub pfnCallback: LPFNPSPCALLBACKW, pub pcRefParent: *mut ::UINT, pub pszHeaderTitle: ::LPCWSTR, pub pszHeaderSubTitle: ::LPCWSTR, pub hActCtx: ::HANDLE, pub hbmHeader: ::HBITMAP } impl Clone for PROPSHEETPAGEW_V4 { fn clone(&self) -> PROPSHEETPAGEW_V4 { *self } } UNION!(PROPSHEETPAGEW_V4, pszTemplate, pResource, pResource_mut, PROPSHEETPAGE_RESOURCE); UNION!(PROPSHEETPAGEW_V4, hIcon, pszIcon, pszIcon_mut, ::LPCWSTR); UNION!(PROPSHEETPAGEW_V4, hbmHeader, pszbmHeader, pszbmHeader_mut, ::LPCWSTR); pub type LPPROPSHEETPAGEW_V4 = *mut PROPSHEETPAGEW_V4; pub type LPCPROPSHEETPAGEW_V4 = *const PROPSHEETPAGEW_V4; pub type PROPSHEETPAGEA_LATEST = PROPSHEETPAGEA_V4; pub type PROPSHEETPAGEW_LATEST = PROPSHEETPAGEW_V4; pub type LPPROPSHEETPAGEA_LATEST = LPPROPSHEETPAGEA_V4; pub type LPPROPSHEETPAGEW_LATEST = LPPROPSHEETPAGEW_V4; pub type LPCPROPSHEETPAGEA_LATEST = LPCPROPSHEETPAGEA_V4; pub type LPCPROPSHEETPAGEW_LATEST = LPCPROPSHEETPAGEW_V4; pub type PROPSHEETPAGEA = PROPSHEETPAGEA_V4; pub type PROPSHEETPAGEW = PROPSHEETPAGEW_V4; pub type LPPROPSHEETPAGEA = LPPROPSHEETPAGEA_V4; pub type LPPROPSHEETPAGEW = LPPROPSHEETPAGEW_V4; pub type LPCPROPSHEETPAGEA = LPCPROPSHEETPAGEA_V4; pub type LPCPROPSHEETPAGEW = LPCPROPSHEETPAGEW_V4; pub const PSH_DEFAULT: ::DWORD = 0x00000000; pub const PSH_PROPTITLE: ::DWORD = 0x00000001; pub const PSH_USEHICON: ::DWORD = 0x00000002; pub const PSH_USEICONID: ::DWORD = 0x00000004; pub const PSH_PROPSHEETPAGE: ::DWORD = 0x00000008; pub const PSH_WIZARDHASFINISH: ::DWORD = 0x00000010; pub const PSH_WIZARD: ::DWORD = 0x00000020; pub const PSH_USEPSTARTPAGE: ::DWORD = 0x00000040; pub const PSH_NOAPPLYNOW: ::DWORD = 0x00000080; pub const PSH_USECALLBACK: ::DWORD = 0x00000100; pub const PSH_HASHELP: ::DWORD = 0x00000200; pub const PSH_MODELESS: ::DWORD = 0x00000400; pub const PSH_RTLREADING: ::DWORD = 0x00000800; pub const PSH_WIZARDCONTEXTHELP: ::DWORD = 0x00001000; pub const PSH_WIZARD97: ::DWORD = 0x01000000; pub const PSH_WATERMARK: ::DWORD = 0x00008000; pub const PSH_USEHBMWATERMARK: ::DWORD = 0x00010000; pub const PSH_USEHPLWATERMARK: ::DWORD = 0x00020000; pub const PSH_STRETCHWATERMARK: ::DWORD = 0x00040000; pub const PSH_HEADER: ::DWORD = 0x00080000; pub const PSH_USEHBMHEADER: ::DWORD = 0x00100000; pub const PSH_USEPAGELANG: ::DWORD = 0x00200000; pub const PSH_WIZARD_LITE: ::DWORD = 0x00400000; pub const PSH_NOCONTEXTHELP: ::DWORD = 0x02000000; pub const PSH_AEROWIZARD: ::DWORD = 0x00004000; pub const PSH_RESIZABLE: ::DWORD = 0x04000000; pub const PSH_HEADERBITMAP: ::DWORD = 0x08000000; pub const PSH_NOMARGIN: ::DWORD = 0x10000000; pub type PFNPROPSHEETCALLBACK = Option ::c_int>; #[repr(C)] #[derive(Copy)] pub struct PROPSHEETHEADERA_V2 { pub dwSize: ::DWORD, pub dwFlags: ::DWORD, pub hwndParent: ::HWND, pub hInstance: ::HINSTANCE, pub hIcon: ::HICON, pub pszCaption: ::LPCSTR, pub nPages: ::UINT, pub pStartPage: ::LPCSTR, pub ppsp: LPCPROPSHEETPAGEA, pub pfnCallback: PFNPROPSHEETCALLBACK, pub hbmWatermark: ::HBITMAP, pub hplWatermark: ::HPALETTE, pub hbmHeader: ::HBITMAP, } impl Clone for PROPSHEETHEADERA_V2 { fn clone(&self) -> PROPSHEETHEADERA_V2 { *self } } UNION!(PROPSHEETHEADERA_V2, hIcon, pszIcon, pszIcon_mut, ::LPCSTR); UNION!(PROPSHEETHEADERA_V2, pStartPage, nStartPage, nStartPage_mut, ::UINT); UNION!(PROPSHEETHEADERA_V2, ppsp, phpage, phpage_mut, *mut HPROPSHEETPAGE); UNION!(PROPSHEETHEADERA_V2, hbmWatermark, pszbmWatermark, pszbmWatermark_mut, ::LPCSTR); UNION!(PROPSHEETHEADERA_V2, hbmHeader, pszbmHeader, pszbmHeader_mut, ::LPCSTR); pub type LPPROPSHEETHEADERA_V2 = *mut PROPSHEETHEADERA_V2; pub type LPCPROPSHEETHEADERA_V2 = *const PROPSHEETHEADERA_V2; #[repr(C)] #[derive(Copy)] pub struct PROPSHEETHEADERW_V2 { pub dwSize: ::DWORD, pub dwFlags: ::DWORD, pub hwndParent: ::HWND, pub hInstance: ::HINSTANCE, pub hIcon: ::HICON, pub pszCaption: ::LPCWSTR, pub nPages: ::UINT, pub pStartPage: ::LPCWSTR, pub ppsp: LPCPROPSHEETPAGEW, pub pfnCallback: PFNPROPSHEETCALLBACK, pub hbmWatermark: ::HBITMAP, pub hplWatermark: ::HPALETTE, pub hbmHeader: ::HBITMAP, } impl Clone for PROPSHEETHEADERW_V2 { fn clone(&self) -> PROPSHEETHEADERW_V2 { *self } } UNION!(PROPSHEETHEADERW_V2, hIcon, pszIcon, pszIcon_mut, ::LPCWSTR); UNION!(PROPSHEETHEADERW_V2, pStartPage, nStartPage, nStartPage_mut, ::UINT); UNION!(PROPSHEETHEADERW_V2, ppsp, phpage, phpage_mut, *mut HPROPSHEETPAGE); UNION!(PROPSHEETHEADERW_V2, hbmWatermark, pszbmWatermark, pszbmWatermark_mut, ::LPCWSTR); UNION!(PROPSHEETHEADERW_V2, hbmHeader, pszbmHeader, pszbmHeader_mut, ::LPCWSTR); pub type LPPROPSHEETHEADERW_V2 = *mut PROPSHEETHEADERW_V2; pub type LPCPROPSHEETHEADERW_V2 = *const PROPSHEETHEADERW_V2; pub type PROPSHEETHEADERA = PROPSHEETHEADERA_V2; pub type PROPSHEETHEADERW = PROPSHEETHEADERW_V2; pub type LPPROPSHEETHEADERA = LPPROPSHEETHEADERA_V2; pub type LPPROPSHEETHEADERW = LPPROPSHEETHEADERW_V2; pub type LPCPROPSHEETHEADERA = LPCPROPSHEETHEADERA_V2; pub type LPCPROPSHEETHEADERW = LPCPROPSHEETHEADERW_V2; pub const PSCB_INITIALIZED: ::UINT = 1; pub const PSCB_PRECREATE: ::UINT = 2; pub const PSCB_BUTTONPRESSED: ::UINT = 3; pub type LPFNADDPROPSHEETPAGE = Option ::BOOL>; pub type LPFNADDPROPSHEETPAGES = Option ::BOOL>; STRUCT!{struct PSHNOTIFY { hdr: ::NMHDR, lParam: ::LPARAM, }} pub type LPPSHNOTIFY = *mut PSHNOTIFY; pub const PSN_FIRST: ::UINT = (0 - 200); pub const PSN_LAST: ::UINT = (0 - 299); pub const PSN_SETACTIVE: ::UINT = PSN_FIRST - 0; pub const PSN_KILLACTIVE: ::UINT = PSN_FIRST - 1; pub const PSN_APPLY: ::UINT = PSN_FIRST - 2; pub const PSN_RESET: ::UINT = PSN_FIRST - 3; pub const PSN_HELP: ::UINT = PSN_FIRST - 5; pub const PSN_WIZBACK: ::UINT = PSN_FIRST - 6; pub const PSN_WIZNEXT: ::UINT = PSN_FIRST - 7; pub const PSN_WIZFINISH: ::UINT = PSN_FIRST - 8; pub const PSN_QUERYCANCEL: ::UINT = PSN_FIRST - 9; pub const PSN_GETOBJECT: ::UINT = PSN_FIRST - 10; pub const PSN_TRANSLATEACCELERATOR: ::UINT = PSN_FIRST - 12; pub const PSN_QUERYINITIALFOCUS: ::UINT = PSN_FIRST - 13; pub const PSNRET_NOERROR: ::LRESULT = 0; pub const PSNRET_INVALID: ::LRESULT = 1; pub const PSNRET_INVALID_NOCHANGEPAGE: ::LRESULT = 2; pub const PSNRET_MESSAGEHANDLED: ::LRESULT = 3; pub const PSM_SETCURSEL: ::UINT = ::WM_USER + 101; pub const PSM_REMOVEPAGE: ::UINT = ::WM_USER + 102; pub const PSM_ADDPAGE: ::UINT = ::WM_USER + 103; pub const PSM_CHANGED: ::UINT = ::WM_USER + 104; pub const PSM_RESTARTWINDOWS: ::UINT = ::WM_USER + 105; pub const PSM_REBOOTSYSTEM: ::UINT = ::WM_USER + 106; pub const PSM_CANCELTOCLOSE: ::UINT = ::WM_USER + 107; pub const PSM_QUERYSIBLINGS: ::UINT = ::WM_USER + 108; pub const PSM_UNCHANGED: ::UINT = ::WM_USER + 109; pub const PSM_APPLY: ::UINT = ::WM_USER + 110; pub const PSM_SETTITLEA: ::UINT = ::WM_USER + 111; pub const PSM_SETTITLEW: ::UINT = ::WM_USER + 120; pub const PSM_SETWIZBUTTONS: ::UINT = ::WM_USER + 112; pub const PSWIZB_BACK: ::DWORD = 0x00000001; pub const PSWIZB_NEXT: ::DWORD = 0x00000002; pub const PSWIZB_FINISH: ::DWORD = 0x00000004; pub const PSWIZB_DISABLEDFINISH: ::DWORD = 0x00000008; pub const PSWIZB_CANCEL: ::DWORD = 0x00000008; pub const PSWIZBF_ELEVATIONREQUIRED: ::WPARAM = 0x00000001; pub const PSBTN_BACK: ::c_int = 0; pub const PSBTN_NEXT: ::c_int = 1; pub const PSBTN_FINISH: ::c_int = 2; pub const PSBTN_OK: ::c_int = 3; pub const PSBTN_APPLYNOW: ::c_int = 4; pub const PSBTN_CANCEL: ::c_int = 5; pub const PSBTN_HELP: ::c_int = 6; pub const PSBTN_MAX: ::c_int = 6; pub const PSM_PRESSBUTTON: ::UINT = ::WM_USER + 113; pub const PSM_SETCURSELID: ::UINT = ::WM_USER + 114; pub const PSM_SETFINISHTEXTA: ::UINT = ::WM_USER + 115; pub const PSM_SETFINISHTEXTW: ::UINT = ::WM_USER + 121; pub const PSM_GETTABCONTROL: ::UINT = ::WM_USER + 116; pub const PSM_ISDIALOGMESSAGE: ::UINT = ::WM_USER + 117; pub const PSM_GETCURRENTPAGEHWND: ::UINT = ::WM_USER + 118; pub const PSM_INSERTPAGE: ::UINT = ::WM_USER + 119; pub const PSM_SETHEADERTITLEA: ::UINT = ::WM_USER + 125; pub const PSM_SETHEADERTITLEW: ::UINT = ::WM_USER + 126; pub const PSWIZF_SETCOLOR: ::UINT = (0 - 1) as ::UINT; pub const PSM_SETHEADERSUBTITLEA: ::UINT = ::WM_USER + 127; pub const PSM_SETHEADERSUBTITLEW: ::UINT = ::WM_USER + 128; pub const PSM_HWNDTOINDEX: ::UINT = ::WM_USER + 129; pub const PSM_INDEXTOHWND: ::UINT = ::WM_USER + 130; pub const PSM_PAGETOINDEX: ::UINT = ::WM_USER + 131; pub const PSM_INDEXTOPAGE: ::UINT = ::WM_USER + 132; pub const PSM_IDTOINDEX: ::UINT = ::WM_USER + 133; pub const PSM_INDEXTOID: ::UINT = ::WM_USER + 134; pub const PSM_GETRESULT: ::UINT = ::WM_USER + 135; pub const PSM_RECALCPAGESIZES: ::UINT = ::WM_USER + 136; pub const PSM_SETNEXTTEXTW: ::UINT = ::WM_USER + 137; pub const PSM_SHOWWIZBUTTONS: ::UINT = ::WM_USER + 138; pub const PSM_ENABLEWIZBUTTONS: ::UINT = ::WM_USER + 139; pub const PSM_SETBUTTONTEXTW: ::UINT = ::WM_USER + 140; pub const PSM_SETBUTTONTEXT: ::UINT = PSM_SETBUTTONTEXTW; pub const ID_PSRESTARTWINDOWS: ::INT_PTR = 0x2; pub const ID_PSREBOOTSYSTEM: ::INT_PTR = ID_PSRESTARTWINDOWS | 0x1; pub const WIZ_CXDLG: ::DWORD = 276; pub const WIZ_CYDLG: ::DWORD = 140; pub const WIZ_CXBMP: ::DWORD = 80; pub const WIZ_BODYX: ::DWORD = 92; pub const WIZ_BODYCX: ::DWORD = 184; pub const PROP_SM_CXDLG: ::c_short = 212; pub const PROP_SM_CYDLG: ::c_short = 188; pub const PROP_MED_CXDLG: ::c_short = 227; pub const PROP_MED_CYDLG: ::c_short = 215; pub const PROP_LG_CXDLG: ::c_short = 252; pub const PROP_LG_CYDLG: ::c_short = 218; deps/winapi-0.2.5/src/d3d9.rs0000644000000000000000000010455412605021351014342 0ustar rootroot// Copyright © 2015, Corey Richardson // Licensed under the MIT License //! Direct3D include file pub const D3D_SDK_VERSION: ::DWORD = 32; pub const D3D9b_SDK_VERSION: ::DWORD = 31; RIDL!( interface IDirect3D9(IDirect3D9Vtbl): IUnknown(IUnknownVtbl) { fn RegisterSoftwareDevice(&mut self, pInitializeFunction: *mut ::VOID) -> ::HRESULT, fn GetAdapterCount(&mut self) -> ::UINT, fn GetAdapterIdentifier( &mut self, Adapter: ::UINT, Flags: ::DWORD, pIdentifier: *mut ::D3DADAPTER_IDENTIFIER9 ) -> ::HRESULT, fn GetAdapterModeCount(&mut self, Adapter: ::UINT, Format: ::D3DFORMAT) -> ::UINT, fn EnumAdapterModes( &mut self, Adapter: ::UINT, Format: ::D3DFORMAT, Mode: ::UINT, pMode: *mut ::D3DDISPLAYMODE ) -> ::HRESULT, fn GetAdapterDisplayMode( &mut self, Adapter: ::UINT, pMode: *mut ::D3DDISPLAYMODE ) -> ::HRESULT, fn CheckDeviceType( &mut self, Adapter: ::UINT, DevType: ::D3DDEVTYPE, AdapterFormat: ::D3DFORMAT, BackBufferFormat: ::D3DFORMAT, bWindowed: ::BOOL ) -> ::HRESULT, fn CheckDeviceFormat( &mut self, Adapter: ::UINT, DeviceType: ::D3DDEVTYPE, AdapterFormat: ::D3DFORMAT, Usage: ::DWORD, RType: ::D3DRESOURCETYPE, CheckFormat: ::D3DFORMAT ) -> ::HRESULT, fn CheckDeviceMultiSampleType( &mut self, Adapter: ::UINT, DeviceType: ::D3DDEVTYPE, SurfaceFormat: ::D3DFORMAT, Windowed: ::BOOL, MultiSampleType: ::D3DMULTISAMPLE_TYPE, pQualityLevels: *mut ::DWORD ) -> ::HRESULT, fn CheckDepthStencilMatch( &mut self, Adapter: ::UINT, DeviceType: ::D3DDEVTYPE, AdapterFormat: ::D3DFORMAT, RenderTargetFormat: ::D3DFORMAT, DepthStencilFormat: ::D3DFORMAT ) -> ::HRESULT, fn CheckDeviceFormatConversion( &mut self, Adapter: ::UINT, DeviceType: ::D3DDEVTYPE, SourceFormat: ::D3DFORMAT, TargetFormat: ::D3DFORMAT ) -> ::HRESULT, fn GetDeviceCaps( &mut self, Adapter: ::UINT, DeviceType: ::D3DDEVTYPE, pCaps: *mut ::D3DCAPS9 ) -> ::HRESULT, fn GetAdapterMonitor(&mut self, Adapter: ::UINT) -> ::HMONITOR, fn CreateDevice( &mut self, Adapter: ::UINT, DeviceType: ::D3DDEVTYPE, hFocusWindow: ::HWND, BehaviorFlags: ::DWORD, pPresentationParameters: *mut ::D3DPRESENT_PARAMETERS, ppReturnedDeviceInterface: *mut *mut IDirect3DDevice9 ) -> ::HRESULT } ); pub type LPDIRECT3D9 = *mut IDirect3D9; pub type PDIRECT3D9 = *mut IDirect3D9; RIDL!( interface IDirect3DDevice9(IDirect3DDevice9Vtbl): IUnknown(IUnknownVtbl) { fn TestCooperativeLevel(&mut self) -> ::HRESULT, fn GetAvailableTextureMem(&mut self) -> ::UINT, fn EvictManagedResources(&mut self) -> ::HRESULT, fn GetDirect3D(&mut self, ppD3D9: *mut *mut IDirect3D9) -> ::HRESULT, fn GetDeviceCaps(&mut self, pCaps: *mut ::D3DCAPS9) -> ::HRESULT, fn GetDisplayMode(&mut self, iSwapChain: ::UINT, pMode: *mut ::D3DDISPLAYMODE) -> ::HRESULT, fn GetCreationParameters( &mut self, pParameters: *mut ::D3DDEVICE_CREATION_PARAMETERS ) -> ::HRESULT, fn SetCursorProperties( &mut self, XHotSpot: ::UINT, YHotSpot: ::UINT, pCursorBitmap: *mut IDirect3DSurface9 ) -> ::HRESULT, fn SetCursorPosition(&mut self, X: ::INT, Y: ::INT, Flags: ::DWORD) -> (), fn ShowCursor(&mut self, bShow: ::BOOL) -> ::BOOL, fn CreateAdditionalSwapChain( &mut self, pPresentationParameters: *mut ::D3DPRESENT_PARAMETERS, pSwapChain: *mut *mut IDirect3DSwapChain9 ) -> ::HRESULT, fn GetSwapChain( &mut self, iSwapChain: ::UINT, pSwapChain: *mut *mut IDirect3DSwapChain9 ) -> ::HRESULT, fn GetNumberOfSwapChains(&mut self) -> ::UINT, fn Reset(&mut self, pPresentationParameters: *mut ::D3DPRESENT_PARAMETERS) -> ::HRESULT, fn Present( &mut self, pSourceRect: *const ::RECT, pDestRect: *const ::RECT, hDestWindowOverride: ::HWND, pDirtyRegion: *const ::RGNDATA ) -> ::HRESULT, fn GetBackBuffer( &mut self, iSwapChain: ::UINT, iBackBuffer: ::UINT, Type: ::D3DBACKBUFFER_TYPE, ppBackBuffer: *mut *mut IDirect3DSurface9 ) -> ::HRESULT, fn GetRasterStatus( &mut self, iSwapChain: ::UINT, pRasterStatus: *mut ::D3DRASTER_STATUS ) -> ::HRESULT, fn SetDialogBoxMode(&mut self, bEnableDialogs: ::BOOL) -> ::HRESULT, fn SetGammaRamp( &mut self, iSwapChain: ::UINT, Flags: ::DWORD, pRamp: *const ::D3DGAMMARAMP ) -> (), fn GetGammaRamp(&mut self, iSwapChain: ::UINT, pRamp: *mut ::D3DGAMMARAMP) -> (), fn CreateTexture( &mut self, Width: ::UINT, Height: ::UINT, Levels: ::UINT, Usage: ::DWORD, Format: ::D3DFORMAT, Pool: ::D3DPOOL, ppTexture: *mut *mut IDirect3DTexture9, pSharedHandle: *mut ::HANDLE ) -> ::HRESULT, fn CreateVolumeTexture( &mut self, Width: ::UINT, Height: ::UINT, Depth: ::UINT, Levels: ::UINT, Usage: ::DWORD, Format: ::D3DFORMAT, Pool: ::D3DPOOL, ppVolumeTexture: *mut *mut IDirect3DVolumeTexture9, pSharedHandle: *mut ::HANDLE ) -> ::HRESULT, fn CreateCubeTexture( &mut self, EdgeLength: ::UINT, Levels: ::UINT, Usage: ::DWORD, Format: ::D3DFORMAT, Pool: ::D3DPOOL, ppCubeTexture: *mut *mut IDirect3DCubeTexture9, pSharedHandle: *mut ::HANDLE ) -> ::HRESULT, fn CreateVertexBuffer( &mut self, Length: ::UINT, Usage: ::DWORD, FVF: ::DWORD, Pool: ::D3DPOOL, ppVertexBuffer: *mut *mut IDirect3DVertexBuffer9, pSharedHandle: *mut ::HANDLE ) -> ::HRESULT, fn CreateIndexBuffer( &mut self, Length: ::UINT, Usage: ::DWORD, Format: ::D3DFORMAT, Pool: ::D3DPOOL, ppIndexBuffer: *mut *mut IDirect3DIndexBuffer9, pSharedHandle: *mut ::HANDLE ) -> ::HRESULT, fn CreateRenderTarget( &mut self, Width: ::UINT, Height: ::UINT, Format: ::D3DFORMAT, MultiSample: ::D3DMULTISAMPLE_TYPE, MultisampleQuality: ::DWORD, Lockable: ::BOOL, ppSurface: *mut *mut IDirect3DSurface9, pSharedHandle: *mut ::HANDLE ) -> ::HRESULT, fn CreateDepthStencilSurface( &mut self, Width: ::UINT, Height: ::UINT, Format: ::D3DFORMAT, MultiSample: ::D3DMULTISAMPLE_TYPE, MultisampleQuality: ::DWORD, Discard: ::BOOL, ppSurface: *mut *mut IDirect3DSurface9, pSharedHandle: *mut ::HANDLE ) -> ::HRESULT, fn UpdateSurface( &mut self, pSourceSurface: *mut IDirect3DSurface9, pSourceRect: *const ::RECT, pDestinationSurface: *mut IDirect3DSurface9, pDestPoint: *const ::POINT ) -> ::HRESULT, fn UpdateTexture( &mut self, pSourceTexture: *mut IDirect3DBaseTexture9, pDestinationTexture: *mut IDirect3DBaseTexture9 ) -> ::HRESULT, fn GetRenderTargetData( &mut self, pRenderTarget: *mut IDirect3DSurface9, pDestSurface: *mut IDirect3DSurface9 ) -> ::HRESULT, fn GetFrontBufferData( &mut self, iSwapChain: ::UINT, pDestSurface: *mut IDirect3DSurface9 ) -> ::HRESULT, fn StretchRect( &mut self, pSourceSurface: *mut IDirect3DSurface9, pSourceRect: *const ::RECT, pDestSurface: *mut IDirect3DSurface9, pDestRect: *const ::RECT, Filter: ::D3DTEXTUREFILTERTYPE ) -> ::HRESULT, fn ColorFill( &mut self, pSurface: *mut IDirect3DSurface9, pRect: *const ::RECT, color: ::D3DCOLOR ) -> ::HRESULT, fn CreateOffscreenPlainSurface( &mut self, Width: ::UINT, Height: ::UINT, Format: ::D3DFORMAT, Pool: ::D3DPOOL, ppSurface: *mut *mut IDirect3DSurface9, pSharedHandle: *mut ::HANDLE ) -> ::HRESULT, fn SetRenderTarget( &mut self, RenderTargetIndex: ::DWORD, pRenderTarget: *mut IDirect3DSurface9 ) -> ::HRESULT, fn GetRenderTarget( &mut self, RenderTargetIndex: ::DWORD, ppRenderTarget: *mut *mut IDirect3DSurface9 ) -> ::HRESULT, fn SetDepthStencilSurface(&mut self, pNewZStencil: *mut IDirect3DSurface9) -> ::HRESULT, fn GetDepthStencilSurface( &mut self, ppZStencilSurface: *mut *mut IDirect3DSurface9 ) -> ::HRESULT, fn BeginScene(&mut self) -> ::HRESULT, fn EndScene(&mut self) -> ::HRESULT, fn Clear( &mut self, Count: ::DWORD, pRects: *const ::D3DRECT, Flags: ::DWORD, Color: ::D3DCOLOR, Z: ::FLOAT, Stencil: ::DWORD ) -> ::HRESULT, fn SetTransform( &mut self, State: ::D3DTRANSFORMSTATETYPE, pMatrix: *const ::D3DMATRIX ) -> ::HRESULT, fn GetTransform( &mut self, State: ::D3DTRANSFORMSTATETYPE, pMatrix: *mut ::D3DMATRIX ) -> ::HRESULT, fn MultiplyTransform( &mut self, arg1: ::D3DTRANSFORMSTATETYPE, arg2: *const ::D3DMATRIX ) -> ::HRESULT, fn SetViewport(&mut self, pViewport: *const ::D3DVIEWPORT9) -> ::HRESULT, fn GetViewport(&mut self, pViewport: *mut ::D3DVIEWPORT9) -> ::HRESULT, fn SetMaterial(&mut self, pMaterial: *const ::D3DMATERIAL9) -> ::HRESULT, fn GetMaterial(&mut self, pMaterial: *mut ::D3DMATERIAL9) -> ::HRESULT, fn SetLight(&mut self, Index: ::DWORD, arg1: *const ::D3DLIGHT9) -> ::HRESULT, fn GetLight(&mut self, Index: ::DWORD, arg1: *mut ::D3DLIGHT9) -> ::HRESULT, fn LightEnable(&mut self, Index: ::DWORD, Enable: ::BOOL) -> ::HRESULT, fn GetLightEnable(&mut self, Index: ::DWORD, pEnable: *mut ::BOOL) -> ::HRESULT, fn SetClipPlane(&mut self, Index: ::DWORD, pPlane: *const ::FLOAT) -> ::HRESULT, fn GetClipPlane(&mut self, Index: ::DWORD, pPlane: *mut ::FLOAT) -> ::HRESULT, fn SetRenderState(&mut self, State: ::D3DRENDERSTATETYPE, Value: ::DWORD) -> ::HRESULT, fn GetRenderState(&mut self, State: ::D3DRENDERSTATETYPE, pValue: *mut ::DWORD) -> ::HRESULT, fn CreateStateBlock( &mut self, Type: ::D3DSTATEBLOCKTYPE, ppSB: *mut *mut IDirect3DStateBlock9 ) -> ::HRESULT, fn BeginStateBlock(&mut self) -> ::HRESULT, fn EndStateBlock(&mut self, ppSB: *mut *mut IDirect3DStateBlock9) -> ::HRESULT, fn SetClipStatus(&mut self, pClipStatus: *const ::D3DCLIPSTATUS9) -> ::HRESULT, fn GetClipStatus(&mut self, pClipStatus: *mut ::D3DCLIPSTATUS9) -> ::HRESULT, fn GetTexture( &mut self, Stage: ::DWORD, ppTexture: *mut *mut IDirect3DBaseTexture9 ) -> ::HRESULT, fn SetTexture(&mut self, Stage: ::DWORD, pTexture: *mut IDirect3DBaseTexture9) -> ::HRESULT, fn GetTextureStageState( &mut self, Stage: ::DWORD, Type: ::D3DTEXTURESTAGESTATETYPE, pValue: *mut ::DWORD ) -> ::HRESULT, fn SetTextureStageState( &mut self, Stage: ::DWORD, Type: ::D3DTEXTURESTAGESTATETYPE, Value: ::DWORD ) -> ::HRESULT, fn GetSamplerState( &mut self, Sampler: ::DWORD, Type: ::D3DSAMPLERSTATETYPE, pValue: *mut ::DWORD ) -> ::HRESULT, fn SetSamplerState( &mut self, Sampler: ::DWORD, Type: ::D3DSAMPLERSTATETYPE, Value: ::DWORD ) -> ::HRESULT, fn ValidateDevice(&mut self, pNumPasses: *mut ::DWORD) -> ::HRESULT, fn SetPaletteEntries( &mut self, PaletteNumber: ::UINT, pEntries: *const ::PALETTEENTRY ) -> ::HRESULT, fn GetPaletteEntries( &mut self, PaletteNumber: ::UINT, pEntries: *mut ::PALETTEENTRY ) -> ::HRESULT, fn SetCurrentTexturePalette(&mut self, PaletteNumber: ::UINT) -> ::HRESULT, fn GetCurrentTexturePalette(&mut self, PaletteNumber: *mut ::UINT) -> ::HRESULT, fn SetScissorRect(&mut self, pRect: *const ::RECT) -> ::HRESULT, fn GetScissorRect(&mut self, pRect: *mut ::RECT) -> ::HRESULT, fn SetSoftwareVertexProcessing(&mut self, bSoftware: ::BOOL) -> ::HRESULT, fn GetSoftwareVertexProcessing(&mut self) -> ::BOOL, fn SetNPatchMode(&mut self, nSegments: ::FLOAT) -> ::HRESULT, fn GetNPatchMode(&mut self) -> ::FLOAT, fn DrawPrimitive( &mut self, PrimitiveType: ::D3DPRIMITIVETYPE, StartVertex: ::UINT, PrimitiveCount: ::UINT ) -> ::HRESULT, fn DrawIndexedPrimitive( &mut self, arg1: ::D3DPRIMITIVETYPE, BaseVertexIndex: ::INT, MinVertexIndex: ::UINT, NumVertices: ::UINT, startIndex: ::UINT, primCount: ::UINT ) -> ::HRESULT, fn DrawPrimitiveUP( &mut self, PrimitiveType: ::D3DPRIMITIVETYPE, PrimitiveCount: ::UINT, pVertexStreamZeroData: *const ::VOID, VertexStreamZeroStride: ::UINT ) -> ::HRESULT, fn DrawIndexedPrimitiveUP( &mut self, PrimitiveType: ::D3DPRIMITIVETYPE, MinVertexIndex: ::UINT, NumVertices: ::UINT, PrimitiveCount: ::UINT, pIndexData: *const ::VOID, IndexDataFormat: ::D3DFORMAT, pVertexStreamZeroData: *const ::VOID, VertexStreamZeroStride: ::UINT ) -> ::HRESULT, fn ProcessVertices( &mut self, SrcStartIndex: ::UINT, DestIndex: ::UINT, VertexCount: ::UINT, pDestBuffer: *mut IDirect3DVertexBuffer9, pVertexDecl: *mut IDirect3DVertexDeclaration9, Flags: ::DWORD ) -> ::HRESULT, fn CreateVertexDeclaration( &mut self, pVertexElements: *const ::D3DVERTEXELEMENT9, ppDecl: *mut *mut IDirect3DVertexDeclaration9 ) -> ::HRESULT, fn SetVertexDeclaration(&mut self, pDecl: *mut IDirect3DVertexDeclaration9) -> ::HRESULT, fn GetVertexDeclaration(&mut self, ppDecl: *mut *mut IDirect3DVertexDeclaration9) -> ::HRESULT, fn SetFVF(&mut self, FVF: ::DWORD) -> ::HRESULT, fn GetFVF(&mut self, pFVF: *mut ::DWORD) -> ::HRESULT, fn CreateVertexShader( &mut self, pFunction: *const ::DWORD, ppShader: *mut *mut IDirect3DVertexShader9 ) -> ::HRESULT, fn SetVertexShader(&mut self, pShader: *mut IDirect3DVertexShader9) -> ::HRESULT, fn GetVertexShader(&mut self, ppShader: *mut *mut IDirect3DVertexShader9) -> ::HRESULT, fn SetVertexShaderConstantF( &mut self, StartRegister: ::UINT, pConstantData: *const ::FLOAT, Vector4fCount: ::UINT ) -> ::HRESULT, fn GetVertexShaderConstantF( &mut self, StartRegister: ::UINT, pConstantData: *mut ::FLOAT, Vector4fCount: ::UINT ) -> ::HRESULT, fn SetVertexShaderConstantI( &mut self, StartRegister: ::UINT, pConstantData: *const ::INT, Vector4iCount: ::UINT ) -> ::HRESULT, fn GetVertexShaderConstantI( &mut self, StartRegister: ::UINT, pConstantData: *mut ::INT, Vector4iCount: ::UINT ) -> ::HRESULT, fn SetVertexShaderConstantB( &mut self, StartRegister: ::UINT, pConstantData: *const ::BOOL, BoolCount: ::UINT ) -> ::HRESULT, fn GetVertexShaderConstantB( &mut self, StartRegister: ::UINT, pConstantData: *mut ::BOOL, BoolCount: ::UINT ) -> ::HRESULT, fn SetStreamSource( &mut self, StreamNumber: ::UINT, pStreamData: *mut IDirect3DVertexBuffer9, OffsetInBytes: ::UINT, Stride: ::UINT ) -> ::HRESULT, fn GetStreamSource( &mut self, StreamNumber: ::UINT, ppStreamData: *mut *mut IDirect3DVertexBuffer9, pOffsetInBytes: *mut ::UINT, pStride: *mut ::UINT ) -> ::HRESULT, fn SetStreamSourceFreq(&mut self, StreamNumber: ::UINT, Setting: ::UINT) -> ::HRESULT, fn GetStreamSourceFreq(&mut self, StreamNumber: ::UINT, pSetting: *mut ::UINT) -> ::HRESULT, fn SetIndices(&mut self, pIndexData: *mut IDirect3DIndexBuffer9) -> ::HRESULT, fn GetIndices(&mut self, ppIndexData: *mut *mut IDirect3DIndexBuffer9) -> ::HRESULT, fn CreatePixelShader( &mut self, pFunction: *const ::DWORD, ppShader: *mut *mut IDirect3DPixelShader9 ) -> ::HRESULT, fn SetPixelShader(&mut self, pShader: *mut IDirect3DPixelShader9) -> ::HRESULT, fn GetPixelShader(&mut self, ppShader: *mut *mut IDirect3DPixelShader9) -> ::HRESULT, fn SetPixelShaderConstantF( &mut self, StartRegister: ::UINT, pConstantData: *const ::FLOAT, Vector4fCount: ::UINT ) -> ::HRESULT, fn GetPixelShaderConstantF( &mut self, StartRegister: ::UINT, pConstantData: *mut ::FLOAT, Vector4fCount: ::UINT ) -> ::HRESULT, fn SetPixelShaderConstantI( &mut self, StartRegister: ::UINT, pConstantData: *const ::INT, Vector4iCount: ::UINT ) -> ::HRESULT, fn GetPixelShaderConstantI( &mut self, StartRegister: ::UINT, pConstantData: *mut ::INT, Vector4iCount: ::UINT ) -> ::HRESULT, fn SetPixelShaderConstantB( &mut self, StartRegister: ::UINT, pConstantData: *const ::BOOL, BoolCount: ::UINT ) -> ::HRESULT, fn GetPixelShaderConstantB( &mut self, StartRegister: ::UINT, pConstantData: *mut ::BOOL, BoolCount: ::UINT ) -> ::HRESULT, fn DrawRectPatch( &mut self, Handle: ::UINT, pNumSegs: *const ::FLOAT, pRectPatchInfo: *const ::D3DRECTPATCH_INFO ) -> ::HRESULT, fn DrawTriPatch( &mut self, Handle: ::UINT, pNumSegs: *const ::FLOAT, pTriPatchInfo: *const ::D3DTRIPATCH_INFO ) -> ::HRESULT, fn DeletePatch(&mut self, Handle: ::UINT) -> ::HRESULT, fn CreateQuery( &mut self, Type: ::D3DQUERYTYPE, ppQuery: *mut *mut IDirect3DQuery9 ) -> ::HRESULT } ); pub type LPDIRECT3DDEVICE9 = *mut IDirect3DDevice9; pub type PDIRECT3DDEVICE9 = *mut IDirect3DDevice9; RIDL!( interface IDirect3DStateBlock9(IDirect3DStateBlock9Vtbl): IUnknown(IUnknownVtbl) { fn GetDevice(&mut self, ppDevice: *mut *mut IDirect3DDevice9) -> ::HRESULT, fn Capture(&mut self) -> ::HRESULT, fn Apply(&mut self) -> ::HRESULT } ); pub type LPDIRECT3DSTATEBLOCK9 = *mut IDirect3DStateBlock9; pub type PDIRECT3DSTATEBLOCK9 = *mut IDirect3DStateBlock9; RIDL!( interface IDirect3DSwapChain9(IDirect3DSwapChain9Vtbl): IUnknown(IUnknownVtbl) { fn Present( &mut self, pSourceRect: *const ::RECT, pDestRect: *const ::RECT, hDestWindowOverride: ::HWND, pDirtyRegion: *const ::RGNDATA, dwFlags: ::DWORD ) -> ::HRESULT, fn GetFrontBufferData(&mut self, pDestSurface: *mut IDirect3DSurface9) -> ::HRESULT, fn GetBackBuffer( &mut self, iBackBuffer: ::UINT, Type: ::D3DBACKBUFFER_TYPE, ppBackBuffer: *mut *mut IDirect3DSurface9 ) -> ::HRESULT, fn GetRasterStatus(&mut self, pRasterStatus: *mut ::D3DRASTER_STATUS) -> ::HRESULT, fn GetDisplayMode(&mut self, pMode: *mut ::D3DDISPLAYMODE) -> ::HRESULT, fn GetDevice(&mut self, ppDevice: *mut *mut IDirect3DDevice9) -> ::HRESULT, fn GetPresentParameters( &mut self, pPresentationParameters: *mut ::D3DPRESENT_PARAMETERS ) -> ::HRESULT } ); pub type LPDIRECT3DSWAPCHAIN9 = *mut IDirect3DSwapChain9; pub type PDIRECT3DSWAPCHAIN9 = *mut IDirect3DSwapChain9; RIDL!( interface IDirect3DResource9(IDirect3DResource9Vtbl): IUnknown(IUnknownVtbl) { fn GetDevice(&mut self, ppDevice: *mut *mut IDirect3DDevice9) -> ::HRESULT, fn SetPrivateData( &mut self, refguid: *const ::GUID, pData: *const ::VOID, SizeOfData: ::DWORD, Flags: ::DWORD ) -> ::HRESULT, fn GetPrivateData( &mut self, refguid: *const ::GUID, pData: *mut ::VOID, pSizeOfData: *mut ::DWORD ) -> ::HRESULT, fn FreePrivateData(&mut self, refguid: *const ::GUID) -> ::HRESULT, fn SetPriority(&mut self, PriorityNew: ::DWORD) -> ::DWORD, fn GetPriority(&mut self) -> ::DWORD, fn PreLoad(&mut self) -> (), fn GetType(&mut self) -> ::D3DRESOURCETYPE } ); pub type LPDIRECT3DRESOURCE9 = *mut IDirect3DResource9; pub type PDIRECT3DRESOURCE9 = *mut IDirect3DResource9; RIDL!( interface IDirect3DVertexDeclaration9(IDirect3DVertexDeclaration9Vtbl): IUnknown(IUnknownVtbl) { fn GetDevice(&mut self, ppDevice: *mut *mut IDirect3DDevice9) -> ::HRESULT, fn GetDeclaration( &mut self, pElement: *mut ::D3DVERTEXELEMENT9, pNumElements: *mut ::UINT ) -> ::HRESULT } ); pub type LPDIRECT3DVERTEXDECLARATION9 = *mut IDirect3DVertexDeclaration9; pub type PDIRECT3DVERTEXDECLARATION9 = *mut IDirect3DVertexDeclaration9; RIDL!( interface IDirect3DVertexShader9(IDirect3DVertexShader9Vtbl): IUnknown(IUnknownVtbl) { fn GetDevice(&mut self, ppDevice: *mut *mut IDirect3DDevice9) -> ::HRESULT, fn GetFunction(&mut self, arg1: *mut ::VOID, pSizeOfData: *mut ::UINT) -> ::HRESULT } ); pub type LPDIRECT3DVERTEXSHADER9 = *mut IDirect3DVertexShader9; pub type PDIRECT3DVERTEXSHADER9 = *mut IDirect3DVertexShader9; RIDL!( interface IDirect3DPixelShader9(IDirect3DPixelShader9Vtbl): IUnknown(IUnknownVtbl) { fn GetDevice(&mut self, ppDevice: *mut *mut IDirect3DDevice9) -> ::HRESULT, fn GetFunction(&mut self, arg1: *mut ::VOID, pSizeOfData: *mut ::UINT) -> ::HRESULT } ); pub type LPDIRECT3DPIXELSHADER9 = *mut IDirect3DPixelShader9; pub type PDIRECT3DPIXELSHADER9 = *mut IDirect3DPixelShader9; RIDL!( interface IDirect3DBaseTexture9(IDirect3DBaseTexture9Vtbl): IDirect3DResource9(IDirect3DResource9Vtbl) { fn SetLOD(&mut self, LODNew: ::DWORD) -> ::DWORD, fn GetLOD(&mut self) -> ::DWORD, fn GetLevelCount(&mut self) -> ::DWORD, fn SetAutoGenFilterType(&mut self, FilterType: ::D3DTEXTUREFILTERTYPE) -> ::HRESULT, fn GetAutoGenFilterType(&mut self) -> ::D3DTEXTUREFILTERTYPE, fn GenerateMipSubLevels(&mut self) -> () } ); pub type LPDIRECT3DBASETEXTURE9 = *mut IDirect3DBaseTexture9; pub type PDIRECT3DBASETEXTURE9 = *mut IDirect3DBaseTexture9; RIDL!( interface IDirect3DTexture9(IDirect3DTexture9Vtbl): IDirect3DBaseTexture9(IDirect3DBaseTexture9Vtbl) { fn GetLevelDesc(&mut self, Level: ::UINT, pDesc: *mut ::D3DSURFACE_DESC) -> ::HRESULT, fn GetSurfaceLevel( &mut self, Level: ::UINT, ppSurfaceLevel: *mut *mut IDirect3DSurface9 ) -> ::HRESULT, fn LockRect( &mut self, Level: ::UINT, pLockedRect: *mut ::D3DLOCKED_RECT, pRect: *const ::RECT, Flags: ::DWORD ) -> ::HRESULT, fn UnlockRect(&mut self, Level: ::UINT) -> ::HRESULT, fn AddDirtyRect(&mut self, pDirtyRect: *const ::RECT) -> ::HRESULT } ); pub type LPDIRECT3DTEXTURE9 = *mut IDirect3DTexture9; pub type PDIRECT3DTEXTURE9 = *mut IDirect3DTexture9; RIDL!( interface IDirect3DVolumeTexture9(IDirect3DVolumeTexture9Vtbl): IDirect3DBaseTexture9(IDirect3DBaseTexture9Vtbl) { fn GetLevelDesc(&mut self, Level: ::UINT, pDesc: *mut ::D3DVOLUME_DESC) -> ::HRESULT, fn GetVolumeLevel( &mut self, Level: ::UINT, ppVolumeLevel: *mut *mut IDirect3DVolume9 ) -> ::HRESULT, fn LockBox( &mut self, Level: ::UINT, pLockedVolume: *mut ::D3DLOCKED_BOX, pBox: *const ::D3DBOX, Flags: ::DWORD ) -> ::HRESULT, fn UnlockBox(&mut self, Level: ::UINT) -> ::HRESULT, fn AddDirtyBox(&mut self, pDirtyBox: *const ::D3DBOX) -> ::HRESULT } ); pub type LPDIRECT3DVOLUMETEXTURE9 = *mut IDirect3DVolumeTexture9; pub type PDIRECT3DVOLUMETEXTURE9 = *mut IDirect3DVolumeTexture9; RIDL!( interface IDirect3DCubeTexture9(IDirect3DCubeTexture9Vtbl): IDirect3DBaseTexture9(IDirect3DBaseTexture9Vtbl) { fn GetLevelDesc(&mut self, Level: ::UINT, pDesc: *mut ::D3DSURFACE_DESC) -> ::HRESULT, fn GetCubeMapSurface( &mut self, FaceType: ::D3DCUBEMAP_FACES, Level: ::UINT, ppCubeMapSurface: *mut *mut IDirect3DSurface9 ) -> ::HRESULT, fn LockRect( &mut self, FaceType: ::D3DCUBEMAP_FACES, Level: ::UINT, pLockedRect: *mut ::D3DLOCKED_RECT, pRect: *const ::RECT, Flags: ::DWORD ) -> ::HRESULT, fn UnlockRect(&mut self, FaceType: ::D3DCUBEMAP_FACES, Level: ::UINT) -> ::HRESULT, fn AddDirtyRect( &mut self, FaceType: ::D3DCUBEMAP_FACES, pDirtyRect: *const ::RECT ) -> ::HRESULT } ); pub type LPDIRECT3DCUBETEXTURE9 = *mut IDirect3DCubeTexture9; pub type PDIRECT3DCUBETEXTURE9 = *mut IDirect3DCubeTexture9; RIDL!( interface IDirect3DVertexBuffer9(IDirect3DVertexBuffer9Vtbl): IDirect3DResource9(IDirect3DResource9Vtbl) { fn Lock( &mut self, OffsetToLock: ::UINT, SizeToLock: ::UINT, ppbData: *mut *mut ::VOID, Flags: ::DWORD ) -> ::HRESULT, fn Unlock(&mut self) -> ::HRESULT, fn GetDesc(&mut self, pDesc: *mut ::D3DVERTEXBUFFER_DESC) -> ::HRESULT } ); pub type LPDIRECT3DVERTEXBUFFER9 = *mut IDirect3DVertexBuffer9; pub type PDIRECT3DVERTEXBUFFER9 = *mut IDirect3DVertexBuffer9; RIDL!( interface IDirect3DIndexBuffer9(IDirect3DIndexBuffer9Vtbl): IDirect3DResource9(IDirect3DResource9Vtbl) { fn Lock( &mut self, OffsetToLock: ::UINT, SizeToLock: ::UINT, ppbData: *mut *mut ::VOID, Flags: ::DWORD ) -> ::HRESULT, fn Unlock(&mut self) -> ::HRESULT, fn GetDesc(&mut self, pDesc: *mut ::D3DINDEXBUFFER_DESC) -> ::HRESULT } ); pub type LPDIRECT3DINDEXBUFFER9 = *mut IDirect3DIndexBuffer9; pub type PDIRECT3DINDEXBUFFER9 = *mut IDirect3DIndexBuffer9; RIDL!( interface IDirect3DSurface9(IDirect3DSurface9Vtbl): IDirect3DResource9(IDirect3DResource9Vtbl) { fn GetContainer(&mut self, riid: *const ::IID, ppContainer: *mut *mut ::VOID) -> ::HRESULT, fn GetDesc(&mut self, pDesc: *mut ::D3DSURFACE_DESC) -> ::HRESULT, fn LockRect( &mut self, pLockedRect: *mut ::D3DLOCKED_RECT, pRect: *const ::RECT, Flags: ::DWORD ) -> ::HRESULT, fn UnlockRect(&mut self) -> ::HRESULT, fn GetDC(&mut self, phdc: *mut ::HDC) -> ::HRESULT, fn ReleaseDC(&mut self, hdc: ::HDC) -> ::HRESULT } ); pub type LPDIRECT3DSURFACE9 = *mut IDirect3DSurface9; pub type PDIRECT3DSURFACE9 = *mut IDirect3DSurface9; RIDL!( interface IDirect3DVolume9(IDirect3DVolume9Vtbl): IUnknown(IUnknownVtbl) { fn GetDevice(&mut self, ppDevice: *mut *mut IDirect3DDevice9) -> ::HRESULT, fn SetPrivateData( &mut self, refguid: *const ::GUID, pData: *const ::VOID, SizeOfData: ::DWORD, Flags: ::DWORD ) -> ::HRESULT, fn GetPrivateData( &mut self, refguid: *const ::GUID, pData: *mut ::VOID, pSizeOfData: *mut ::DWORD ) -> ::HRESULT, fn FreePrivateData(&mut self, refguid: *const ::GUID) -> ::HRESULT, fn GetContainer(&mut self, riid: *const ::IID, ppContainer: *mut *mut ::VOID) -> ::HRESULT, fn GetDesc(&mut self, pDesc: *mut ::D3DVOLUME_DESC) -> ::HRESULT, fn LockBox( &mut self, pLockedVolume: *mut ::D3DLOCKED_BOX, pBox: *const ::D3DBOX, Flags: ::DWORD ) -> ::HRESULT, fn UnlockBox(&mut self) -> ::HRESULT } ); pub type LPDIRECT3DVOLUME9 = *mut IDirect3DVolume9; pub type PDIRECT3DVOLUME9 = *mut IDirect3DVolume9; RIDL!( interface IDirect3DQuery9(IDirect3DQuery9Vtbl): IUnknown(IUnknownVtbl) { fn GetDevice(&mut self, ppDevice: *mut *mut IDirect3DDevice9) -> ::HRESULT, fn GetType(&mut self) -> ::D3DRESOURCETYPE, fn GetDataSize(&mut self) -> ::DWORD, fn Issue(&mut self, dwIssueFlags: ::DWORD) -> ::HRESULT, fn GetData( &mut self, pData: *mut ::VOID, dwSize: ::DWORD, dwGetDataFlags: ::DWORD ) -> ::HRESULT } ); pub type LPDIRECT3DQUERY9 = *mut IDirect3DQuery9; pub type PDIRECT3DQUERY9 = *mut IDirect3DQuery9; pub const D3DCREATE_FPU_PRESERVE: ::DWORD = 0x2; pub const D3DCREATE_MULTITHREADED: ::DWORD = 0x4; pub const D3DCREATE_PUREDEVICE: ::DWORD = 0x10; pub const D3DCREATE_SOFTWARE_VERTEXPROCESSING: ::DWORD = 0x20; pub const D3DCREATE_HARDWARE_VERTEXPROCESSING: ::DWORD = 0x40; pub const D3DCREATE_MIXED_VERTEXPROCESSING: ::DWORD = 0x80; pub const D3DCREATE_DISABLE_DRIVER_MANAGEMENT: ::DWORD = 0x100; pub const D3DCREATE_ADAPTERGROUP_DEVICE: ::DWORD = 0x200; pub const D3DCREATE_DISABLE_DRIVER_MANAGEMENT_EX: ::DWORD = 0x400; pub const D3DCREATE_NOWINDOWCHANGES: ::DWORD = 0x800; pub const D3DCREATE_DISABLE_PSGP_THREADING: ::DWORD = 0x2000; pub const D3DCREATE_ENABLE_PRESENTSTATS: ::DWORD = 0x4000; pub const D3DCREATE_DISABLE_PRESENTSTATS: ::DWORD = 0x8000; pub const D3DCREATE_SCREENSAVER: ::DWORD = 0x10000000; pub const D3DADAPTER_DEFAULT: ::DWORD = 0; RIDL!( interface IDirect3D9Ex(IDirect3D9ExVtbl): IDirect3D9(IDirect3D9Vtbl) { fn GetAdapterModeCountEx( &mut self, Adapter: ::UINT, pFilter: *const ::D3DDISPLAYMODEFILTER ) -> ::UINT, fn EnumAdapterModesEx( &mut self, Adapter: ::UINT, pFilter: *const ::D3DDISPLAYMODEFILTER, Mode: ::UINT, pMode: *mut ::D3DDISPLAYMODEEX ) -> ::HRESULT, fn GetAdapterDisplayModeEx( &mut self, Adapter: ::UINT, pMode: *mut ::D3DDISPLAYMODEEX, pRotation: *mut ::D3DDISPLAYROTATION ) -> ::HRESULT, fn CreateDeviceEx( &mut self, Adapter: ::UINT, DeviceType: ::D3DDEVTYPE, hFocusWindow: ::HWND, BehaviorFlags: ::DWORD, pPresentationParameters: *mut ::D3DPRESENT_PARAMETERS, pFullscreenDisplayMode: *mut ::D3DDISPLAYMODEEX, ppReturnedDeviceInterface: *mut *mut IDirect3DDevice9Ex ) -> ::HRESULT, fn GetAdapterLUID(&mut self, Adapter: ::UINT, pLUID: *mut ::LUID) -> ::HRESULT } ); pub type LPDIRECT3D9EX = *mut IDirect3D9Ex; pub type PDIRECT3D9EX = *mut IDirect3D9Ex; RIDL!( interface IDirect3DDevice9Ex(IDirect3DDevice9ExVtbl): IDirect3DDevice9(IDirect3DDevice9Vtbl) { fn SetConvolutionMonoKernel( &mut self, width: ::UINT, height: ::UINT, rows: *mut ::FLOAT, columns: *mut ::FLOAT ) -> ::HRESULT, fn ComposeRects( &mut self, pSrc: *mut IDirect3DSurface9, pDst: *mut IDirect3DSurface9, pSrcRectDescs: *mut IDirect3DVertexBuffer9, NumRects: ::UINT, pDstRectDescs: *mut IDirect3DVertexBuffer9, Operation: ::D3DCOMPOSERECTSOP, Xoffset: ::INT, Yoffset: ::INT ) -> ::HRESULT, fn PresentEx( &mut self, pSourceRect: *const ::RECT, pDestRect: *const ::RECT, hDestWindowOverride: ::HWND, pDirtyRegion: *const ::RGNDATA, dwFlags: ::DWORD ) -> ::HRESULT, fn GetGPUThreadPriority(&mut self, pPriority: *mut ::INT) -> ::HRESULT, fn SetGPUThreadPriority(&mut self, Priority: ::INT) -> ::HRESULT, fn WaitForVBlank(&mut self, iSwapChain: ::UINT) -> ::HRESULT, fn CheckResourceResidency( &mut self, pResourceArray: *mut *mut IDirect3DResource9, NumResources: ::UINT32 ) -> ::HRESULT, fn SetMaximumFrameLatency(&mut self, MaxLatency: ::UINT) -> ::HRESULT, fn GetMaximumFrameLatency(&mut self, pMaxLatency: *mut ::UINT) -> ::HRESULT, fn CheckDeviceState(&mut self, hDestinationWindow: ::HWND) -> ::HRESULT, fn CreateRenderTargetEx( &mut self, Width: ::UINT, Height: ::UINT, Format: ::D3DFORMAT, MultiSample: ::D3DMULTISAMPLE_TYPE, MultisampleQuality: ::DWORD, Lockable: ::BOOL, ppSurface: *mut *mut IDirect3DSurface9, pSharedHandle: *mut ::HANDLE, Usage: ::DWORD ) -> ::HRESULT, fn CreateOffscreenPlainSurfaceEx( &mut self, Width: ::UINT, Height: ::UINT, Format: ::D3DFORMAT, Pool: ::D3DPOOL, ppSurface: *mut *mut IDirect3DSurface9, pSharedHandle: *mut ::HANDLE, Usage: ::DWORD ) -> ::HRESULT, fn CreateDepthStencilSurfaceEx( &mut self, Width: ::UINT, Height: ::UINT, Format: ::D3DFORMAT, MultiSample: ::D3DMULTISAMPLE_TYPE, MultisampleQuality: ::DWORD, Discard: ::BOOL, ppSurface: *mut *mut IDirect3DSurface9, pSharedHandle: *mut ::HANDLE, Usage: ::DWORD ) -> ::HRESULT, fn ResetEx( &mut self, pPresentationParameters: *mut ::D3DPRESENT_PARAMETERS, pFullscreenDisplayMode: *mut ::D3DDISPLAYMODEEX ) -> ::HRESULT, fn GetDisplayModeEx( &mut self, iSwapChain: ::UINT, pMode: *mut ::D3DDISPLAYMODEEX, pRotation: *mut ::D3DDISPLAYROTATION ) -> ::HRESULT } ); pub type LPDIRECT3DDEVICE9EX = *mut IDirect3DDevice9Ex; pub type PDIRECT3DDEVICE9EX = *mut IDirect3DDevice9Ex; RIDL!( interface IDirect3DSwapChain9Ex(IDirect3DSwapChain9ExVtbl): IDirect3DSwapChain9(IDirect3DSwapChain9Vtbl) { fn GetLastPresentCount(&mut self, pLastPresentCount: *mut ::UINT) -> ::HRESULT, fn GetPresentStats(&mut self, pPresentationStatistics: *mut ::D3DPRESENTSTATS) -> ::HRESULT, fn GetDisplayModeEx( &mut self, pMode: *mut ::D3DDISPLAYMODEEX, pRotation: *mut ::D3DDISPLAYROTATION ) -> ::HRESULT } ); pub type LPDIRECT3DSWAPCHAIN9EX = *mut IDirect3DSwapChain9Ex; pub type PDIRECT3DSWAPCHAIN9EX = *mut IDirect3DSwapChain9Ex; RIDL!( interface IDirect3D9ExOverlayExtension(IDirect3D9ExOverlayExtensionVtbl): IUnknown(IUnknownVtbl) { fn CheckDeviceOverlayType( &mut self, Adapter: ::UINT, DevType: ::D3DDEVTYPE, OverlayWidth: ::UINT, OverlayHeight: ::UINT, OverlayFormat: ::D3DFORMAT, pDisplayMode: *mut ::D3DDISPLAYMODEEX, DisplayRotation: ::D3DDISPLAYROTATION, pOverlayCaps: *mut ::D3DOVERLAYCAPS ) -> ::HRESULT } ); pub type LPDIRECT3D9EXOVERLAYEXTENSION = *mut IDirect3D9ExOverlayExtension; pub type PDIRECT3D9EXOVERLAYEXTENSION = *mut IDirect3D9ExOverlayExtension; RIDL!( interface IDirect3DDevice9Video(IDirect3DDevice9VideoVtbl): IUnknown(IUnknownVtbl) { fn GetContentProtectionCaps( &mut self, pCryptoType: *const ::GUID, pDecodeProfile: *const ::GUID, pCaps: *mut ::D3DCONTENTPROTECTIONCAPS ) -> ::HRESULT, fn CreateAuthenticatedChannel( &mut self, ChannelType: ::D3DAUTHENTICATEDCHANNELTYPE, ppAuthenticatedChannel: *mut *mut IDirect3DAuthenticatedChannel9, pChannelHandle: *mut ::HANDLE ) -> ::HRESULT, fn CreateCryptoSession( &mut self, pCryptoType: *const ::GUID, pDecodeProfile: *const ::GUID, ppCryptoSession: *mut *mut IDirect3DCryptoSession9, pCryptoHandle: *mut ::HANDLE ) -> ::HRESULT } ); pub type LPDIRECT3DDEVICE9VIDEO = *mut IDirect3DDevice9Video; pub type PDIRECT3DDEVICE9VIDEO = *mut IDirect3DDevice9Video; RIDL!( interface IDirect3DAuthenticatedChannel9(IDirect3DAuthenticatedChannel9Vtbl): IUnknown(IUnknownVtbl) { fn GetCertificateSize(&mut self, pCertificateSize: *mut ::UINT) -> ::HRESULT, fn GetCertificate(&mut self, CertifacteSize: ::UINT, ppCertificate: *mut ::BYTE) -> ::HRESULT, fn NegotiateKeyExchange(&mut self, DataSize: ::UINT, pData: *mut ::VOID) -> ::HRESULT, fn Query( &mut self, InputSize: ::UINT, pInput: *const ::VOID, OutputSize: ::UINT, pOutput: *mut ::VOID ) -> ::HRESULT, fn Configure( &mut self, InputSize: ::UINT, pInput: *const ::VOID, pOutput: *mut ::D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT ) -> ::HRESULT } ); pub type LPDIRECT3DAUTHENTICATEDCHANNEL9 = *mut IDirect3DAuthenticatedChannel9; pub type PDIRECT3DAUTHENTICATEDCHANNEL9 = *mut IDirect3DAuthenticatedChannel9; RIDL!( interface IDirect3DCryptoSession9(IDirect3DCryptoSession9Vtbl): IUnknown(IUnknownVtbl) { fn GetCertificateSize(&mut self, pCertificateSize: *mut ::UINT) -> ::HRESULT, fn GetCertificate(&mut self, CertifacteSize: ::UINT, ppCertificate: *mut ::BYTE) -> ::HRESULT, fn NegotiateKeyExchange(&mut self, DataSize: ::UINT, pData: *mut ::VOID) -> ::HRESULT, fn EncryptionBlt( &mut self, pSrcSurface: *mut IDirect3DSurface9, pDstSurface: *mut IDirect3DSurface9, DstSurfaceSize: ::UINT, pIV: *mut ::VOID ) -> ::HRESULT, fn DecryptionBlt( &mut self, pSrcSurface: *mut IDirect3DSurface9, pDstSurface: *mut IDirect3DSurface9, SrcSurfaceSize: ::UINT, pEncryptedBlockInfo: *mut ::D3DENCRYPTED_BLOCK_INFO, pContentKey: *mut ::VOID, pIV: *mut ::VOID ) -> ::HRESULT, fn GetSurfacePitch( &mut self, pSrcSurface: *mut IDirect3DSurface9, pSurfacePitch: *mut ::UINT ) -> ::HRESULT, fn StartSessionKeyRefresh( &mut self, pRandomNumber: *mut ::VOID, RandomNumberSize: ::UINT ) -> ::HRESULT, fn FinishSessionKeyRefresh(&mut self) -> ::HRESULT, fn GetEncryptionBltKey(&mut self, pReadbackKey: *mut ::VOID, KeySize: ::UINT) -> ::HRESULT } ); pub type LPDIRECT3DCRYPTOSESSION9 = *mut IDirect3DCryptoSession9; pub type PDIRECT3DCRYPTOSESSION9 = *mut IDirect3DCryptoSession9; deps/winapi-0.2.5/src/ntdef.rs0000644000000000000000000000034512605021253014671 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Type definitions for the basic types. //909 pub type NTSTATUS = ::LONG; pub type PNTSTATUS = *mut NTSTATUS; pub type PCNTSTATUS = *const NTSTATUS; deps/winapi-0.2.5/src/sapi.rs0000644000000000000000000025054712616157663014561 0ustar rootroot// Copyright © 2015, Connor Hilarides // Licensed under the MIT License //! Mappings for the contents of sapi.h ENUM!{enum SPDATAKEYLOCATION { SPDKL_DefaultLocation = 0, SPDKL_CurrentUser = 1, SPDKL_LocalMachine = 2, SPDKL_CurrentConfig = 5, }} pub const SPDUI_EngineProperties: &'static str = "EngineProperties"; pub const SPDUI_AddRemoveWord: &'static str = "AddRemoveWord"; pub const SPDUI_UserTraining: &'static str = "UserTraining"; pub const SPDUI_MicTraining: &'static str = "MicTraining"; pub const SPDUI_RecoProfileProperties: &'static str = "RecoProfileProperties"; pub const SPDUI_AudioProperties: &'static str = "AudioProperties"; pub const SPDUI_AudioVolume: &'static str = "AudioVolume"; pub const SPDUI_UserEnrollment: &'static str = "UserEnrollment"; pub const SPDUI_ShareData: &'static str = "ShareData"; pub const SPDUI_Tutorial: &'static str = "Tutorial"; ENUM!{enum SPSTREAMFORMAT { SPSF_Default = -1i32 as u32, SPSF_NoAssignedFormat = 0, SPSF_Text = 1, SPSF_NonStandardFormat = 2, SPSF_ExtendedAudioFormat = 3, SPSF_8kHz8BitMono = 4, SPSF_8kHz8BitStereo = 5, SPSF_8kHz16BitMono = 6, SPSF_8kHz16BitStereo = 7, SPSF_11kHz8BitMono = 8, SPSF_11kHz8BitStereo = 9, SPSF_11kHz16BitMono = 10, SPSF_11kHz16BitStereo = 11, SPSF_12kHz8BitMono = 12, SPSF_12kHz8BitStereo = 13, SPSF_12kHz16BitMono = 14, SPSF_12kHz16BitStereo = 15, SPSF_16kHz8BitMono = 16, SPSF_16kHz8BitStereo = 17, SPSF_16kHz16BitMono = 18, SPSF_16kHz16BitStereo = 19, SPSF_22kHz8BitMono = 20, SPSF_22kHz8BitStereo = 21, SPSF_22kHz16BitMono = 22, SPSF_22kHz16BitStereo = 23, SPSF_24kHz8BitMono = 24, SPSF_24kHz8BitStereo = 25, SPSF_24kHz16BitMono = 26, SPSF_24kHz16BitStereo = 27, SPSF_32kHz8BitMono = 28, SPSF_32kHz8BitStereo = 29, SPSF_32kHz16BitMono = 30, SPSF_32kHz16BitStereo = 31, SPSF_44kHz8BitMono = 32, SPSF_44kHz8BitStereo = 33, SPSF_44kHz16BitMono = 34, SPSF_44kHz16BitStereo = 35, SPSF_48kHz8BitMono = 36, SPSF_48kHz8BitStereo = 37, SPSF_48kHz16BitMono = 38, SPSF_48kHz16BitStereo = 39, SPSF_TrueSpeech_8kHz1BitMono = 40, SPSF_CCITT_ALaw_8kHzMono = 41, SPSF_CCITT_ALaw_8kHzStereo = 42, SPSF_CCITT_ALaw_11kHzMono = 43, SPSF_CCITT_ALaw_11kHzStereo = 44, SPSF_CCITT_ALaw_22kHzMono = 45, SPSF_CCITT_ALaw_22kHzStereo = 46, SPSF_CCITT_ALaw_44kHzMono = 47, SPSF_CCITT_ALaw_44kHzStereo = 48, SPSF_CCITT_uLaw_8kHzMono = 49, SPSF_CCITT_uLaw_8kHzStereo = 50, SPSF_CCITT_uLaw_11kHzMono = 51, SPSF_CCITT_uLaw_11kHzStereo = 52, SPSF_CCITT_uLaw_22kHzMono = 53, SPSF_CCITT_uLaw_22kHzStereo = 54, SPSF_CCITT_uLaw_44kHzMono = 55, SPSF_CCITT_uLaw_44kHzStereo = 56, SPSF_ADPCM_8kHzMono = 57, SPSF_ADPCM_8kHzStereo = 58, SPSF_ADPCM_11kHzMono = 59, SPSF_ADPCM_11kHzStereo = 60, SPSF_ADPCM_22kHzMono = 61, SPSF_ADPCM_22kHzStereo = 62, SPSF_ADPCM_44kHzMono = 63, SPSF_ADPCM_44kHzStereo = 64, SPSF_GSM610_8kHzMono = 65, SPSF_GSM610_11kHzMono = 66, SPSF_GSM610_22kHzMono = 67, SPSF_GSM610_44kHzMono = 68, SPSF_NUM_FORMATS = 69, }} pub const SPREG_USER_ROOT: &'static str = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Speech"; pub const SPREG_LOCAL_MACHINE_ROOT: &'static str = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech"; pub const SPCAT_AUDIOOUT: &'static str = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\AudioOutput"; pub const SPCAT_AUDIOIN: &'static str = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\AudioInput"; pub const SPCAT_VOICES: &'static str = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\Voices"; pub const SPCAT_RECOGNIZERS: &'static str = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\Recognizers"; pub const SPCAT_APPLEXICONS: &'static str = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\AppLexicons"; pub const SPCAT_PHONECONVERTERS: &'static str = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\PhoneConverters"; pub const SPCAT_TEXTNORMALIZERS: &'static str = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\TextNormalizers"; pub const SPCAT_RECOPROFILES: &'static str = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Speech\\RecoProfiles"; pub const SPMMSYS_AUDIO_IN_TOKEN_ID: &'static str = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\AudioInput\\TokenEnums\\MMAudioIn\\"; pub const SPMMSYS_AUDIO_OUT_TOKEN_ID: &'static str = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\AudioOutput\\TokenEnums\\MMAudioOut\\"; pub const SPCURRENT_USER_LEXICON_TOKEN_ID: &'static str = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Speech\\CurrentUserLexicon"; pub const SPCURRENT_USER_SHORTCUT_TOKEN_ID: &'static str = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Speech\\CurrentUserShortcut"; pub const SPTOKENVALUE_CLSID: &'static str = "CLSID"; pub const SPTOKENKEY_FILES: &'static str = "Files"; pub const SPTOKENKEY_UI: &'static str = "UI"; pub const SPTOKENKEY_ATTRIBUTES: &'static str = "Attributes"; pub const SPTOKENKEY_RETAINEDAUDIO: &'static str = "SecondsPerRetainedAudioEvent"; pub const SPTOKENKEY_AUDIO_LATENCY_WARNING: &'static str = "LatencyWarningThreshold"; pub const SPTOKENKEY_AUDIO_LATENCY_TRUNCATE: &'static str = "LatencyTruncateThreshold"; pub const SPTOKENKEY_AUDIO_LATENCY_UPDATE_INTERVAL: &'static str = "LatencyUpdateInterval"; pub const SPVOICECATEGORY_TTSRATE: &'static str = "DefaultTTSRate"; pub const SPPROP_RESOURCE_USAGE: &'static str = "ResourceUsage"; pub const SPPROP_HIGH_CONFIDENCE_THRESHOLD: &'static str = "HighConfidenceThreshold"; pub const SPPROP_NORMAL_CONFIDENCE_THRESHOLD: &'static str = "NormalConfidenceThreshold"; pub const SPPROP_LOW_CONFIDENCE_THRESHOLD: &'static str = "LowConfidenceThreshold"; pub const SPPROP_RESPONSE_SPEED: &'static str = "ResponseSpeed"; pub const SPPROP_COMPLEX_RESPONSE_SPEED: &'static str = "ComplexResponseSpeed"; pub const SPPROP_ADAPTATION_ON: &'static str = "AdaptationOn"; pub const SPPROP_PERSISTED_BACKGROUND_ADAPTATION: &'static str = "PersistedBackgroundAdaptation"; pub const SPPROP_PERSISTED_LANGUAGE_MODEL_ADAPTATION: &'static str = "PersistedLanguageModelAdaptation"; pub const SPPROP_UX_IS_LISTENING: &'static str = "UXIsListening"; pub const SPTOPIC_SPELLING: &'static str = "Spelling"; pub const SPWILDCARD: &'static str = "..."; pub const SPDICTATION: &'static str = "*"; pub const SPINFDICTATION: &'static str = "*+"; pub const SPREG_SAFE_USER_TOKENS: &'static str = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\UserTokens"; pub const SP_LOW_CONFIDENCE: i32 = -1; pub const SP_NORMAL_CONFIDENCE: i32 = 0; pub const SP_HIGH_CONFIDENCE: i32 = 1; pub const DEFAULT_WEIGHT: i32 = 1; pub const SP_MAX_WORD_LENGTH: i32 = 128; pub const SP_MAX_PRON_LENGTH: i32 = 384; pub const SP_EMULATE_RESULT: i32 = 0x40000000; RIDL!( interface ISpNotifyCallback(ISpNotifyCallbackVtbl) { fn NotifyCallback(&mut self, wParam: ::WPARAM, lParam: ::LPARAM) -> ::HRESULT } ); pub type SPNOTIFYCALLBACK = unsafe extern "system" fn(wParam: ::WPARAM, lParam: ::LPARAM); RIDL!( interface ISpNotifySource(ISpNotifySourceVtbl): IUnknown(IUnknownVtbl) { fn SetNotifySink(&mut self, pNotifySink: *mut ISpNotifySink) -> ::HRESULT, fn SetNotifyWindowMessage( &mut self, hWnd: ::HWND, Msg: ::UINT, wParam: ::WPARAM, lParam: ::LPARAM ) -> ::HRESULT, fn SetNotifyCallbackFunction( &mut self, pfnCallback: SPNOTIFYCALLBACK, wParam: ::WPARAM, lParam: ::LPARAM ) -> ::HRESULT, fn SetNotifyCallbackInterface( &mut self, pSpCallback: *mut ISpNotifyCallback, wParam: ::WPARAM, lParam: ::LPARAM ) -> ::HRESULT, fn SetNotifyWin32Event(&mut self) -> ::HRESULT, fn WaitForNotifyEvent(&mut self, dwMilliseconds: ::DWORD) -> ::HRESULT, fn GetNotifyEventHandle(&mut self) -> ::HANDLE } ); RIDL!( interface ISpNotifySink(ISpNotifySinkVtbl): IUnknown(IUnknownVtbl) { fn Notify(&mut self) -> ::HRESULT } ); RIDL!( interface ISpNotifyTranslator(ISpNotifyTranslatorVtbl): ISpNotifySink(ISpNotifySinkVtbl) { fn InitWindowMessage( &mut self, hWnd: ::HWND, Msg: ::UINT, wParam: ::WPARAM, lParam: ::LPARAM ) -> ::HRESULT, fn InitCallback( &mut self, pfnCallback: SPNOTIFYCALLBACK, wParam: ::WPARAM, lParam: ::LPARAM ) -> ::HRESULT, fn InitSpNotifyCallback( &mut self, pSpCallback: *mut ISpNotifyCallback, wParam: ::WPARAM, lParam: ::LPARAM ) -> ::HRESULT, fn InitWin32Event(&mut self, hEvent: ::HANDLE, fCloseHandleOnRelease: ::BOOL) -> ::HRESULT, fn Wait(&mut self, dwMilliseconds: ::DWORD) -> ::HRESULT, fn GetEventHandle(&mut self) -> ::HANDLE } ); RIDL!( interface ISpDataKey(ISpDataKeyVtbl): IUnknown(IUnknownVtbl) { fn SetData( &mut self, pszValueName: ::LPCWSTR, cbData: ::ULONG, pData: *const ::BYTE ) -> ::HRESULT, fn GetData( &mut self, pszValueName: ::LPCWSTR, pcbData: *mut ::ULONG, pData: *mut ::BYTE ) -> ::HRESULT, fn SetStringValue(&mut self, pszValueName: ::LPCWSTR, pszValue: ::LPCWSTR) -> ::HRESULT, fn GetStringValue(&mut self, pszValueName: ::LPCWSTR, ppszValue: *mut ::LPWSTR) -> ::HRESULT, fn SetDWORD(&mut self, pszValueName: ::LPCWSTR, dwValue: ::DWORD) -> ::HRESULT, fn GetDWORD(&mut self, pszValueName: ::LPCWSTR, pdwValue: *mut ::DWORD) -> ::HRESULT, fn OpenKey(&mut self, pszSubKeyName: ::LPCWSTR, ppSubKey: *mut *mut ISpDataKey) -> ::HRESULT, fn CreateKey(&mut self, pszSubKey: ::LPCWSTR, ppSubKey: *mut *mut ISpDataKey) -> ::HRESULT, fn DeleteKey(&mut self, pszSubKey: ::LPCWSTR) -> ::HRESULT, fn DeleteValue(&mut self, pszValueName: ::LPCWSTR) -> ::HRESULT, fn EnumKeys(&mut self, Index: ::ULONG, ppszSubKeyName: *mut ::LPWSTR) -> ::HRESULT, fn EnumValues(&mut self, Index: ::ULONG, ppszValueName: *mut ::LPWSTR) -> ::HRESULT } ); RIDL!( interface ISpRegDataKey(ISpRegDataKeyVtbl): ISpDataKey(ISpDataKeyVtbl) { fn SetKey(&mut self, hkey: ::HKEY, fReadOnly: ::BOOL) -> ::HRESULT } ); RIDL!( interface ISpObjectTokenCategory(ISpObjectTokenCategoryVtbl): ISpDataKey(ISpDataKeyVtbl) { fn SetId(&mut self, pszCategoryId: ::LPCWSTR, fCreateIfNotExist: ::BOOL) -> ::HRESULT, fn GetId(&mut self, ppszCoMemCategoryId: *mut ::LPWSTR) -> ::HRESULT, fn GetDataKey( &mut self, spdkl: SPDATAKEYLOCATION, pppDataKey: *mut *mut ISpDataKey ) -> ::HRESULT, fn EnumTokens( &mut self, pzsReqAttribs: ::LPCWSTR, pszOptAttribs: ::LPCWSTR, ppEnum: *mut *mut IEnumSpObjectTokens ) -> ::HRESULT, fn SetDefaultTokenId(&mut self, pszTokenId: ::LPCWSTR) -> ::HRESULT, fn GetDefaultTokenId(&mut self, ppszCoMemTokenId: *mut ::LPWSTR) -> ::HRESULT } ); RIDL!( interface ISpObjectToken(ISpObjectTokenVtbl): ISpDataKey(ISpDataKeyVtbl) { fn SetId( &mut self, pszCategoryId: ::LPCWSTR, pszTokenId: ::LPCWSTR, fCreateIfNotExist: ::BOOL ) -> ::HRESULT, fn GetId(&mut self, ppszCoMemTokenId: *mut ::LPWSTR) -> ::HRESULT, fn GetCategory(&mut self, ppTokenCategory: *mut *mut ISpObjectTokenCategory) -> ::HRESULT, fn CreateInstance( &mut self, pUnkOuter: *mut ::IUnknown, dwClsContext: ::DWORD, riid: ::REFIID, ppvObject: *mut *mut ::c_void ) -> ::HRESULT, fn GetStorageFileName( &mut self, clsidCaller: ::REFCLSID, pszValueName: ::LPCWSTR, pszFileNameSpecifier: ::LPCWSTR, nFolder: ::ULONG, ppszFilePath: *mut ::LPWSTR ) -> ::HRESULT, fn RemoveStorageFileName(&mut self, pszKeyName: ::LPCWSTR, fDeleteFile: ::BOOL) -> ::HRESULT, fn Remove(&mut self, pclsidCaller: *const ::CLSID) -> ::HRESULT, fn IsUISupported( &mut self, pszTypeOfUI: ::LPCWSTR, pvExtraData: *mut ::c_void, cbExtraData: ::ULONG, punkObject: *mut ::IUnknown, pfSupported: *mut ::BOOL ) -> ::HRESULT, fn DisplayUI( &mut self, hwndParent: ::HWND, pszTitle: ::LPCWSTR, pszTypeOfUI: ::LPCWSTR, pvExtraData: *mut ::c_void, cbExtraData: ::ULONG, punkObject: *mut ::IUnknown ) -> ::HRESULT, fn MatchesAttributes(&mut self, pszAttributes: ::LPCWSTR, pfMatches: *mut ::BOOL) -> ::HRESULT } ); RIDL!( interface ISpObjectTokenInit(ISpObjectTokenInitVtbl): ISpObjectToken(ISpObjectTokenVtbl) { fn InitFromDataKey( &mut self, pszCategoryId: ::LPCWSTR, pszTokenId: ::LPCWSTR, pDataKey: *mut ISpDataKey ) -> ::HRESULT } ); RIDL!( interface IEnumSpObjectTokens(IEnumSpObjectTokensVtbl): IUnknown(IUnknownVtbl) { fn Next( &mut self, celt: ::ULONG, pelt: *mut *mut ISpObjectToken, pceltFetched: *mut ::ULONG ) -> ::HRESULT, fn Skip(&mut self, celt: ::ULONG) -> ::HRESULT, fn Reset(&mut self) -> ::HRESULT, fn Clone(&mut self, ppEnum: *mut *mut IEnumSpObjectTokens) -> ::HRESULT, fn Item(&mut self, Index: ::ULONG, ppToken: *mut *mut ISpObjectToken) -> ::HRESULT, fn GetCount(&mut self, pCount: *mut ::ULONG) -> ::HRESULT } ); RIDL!( interface ISpObjectWithToken(ISpObjectWithTokenVtbl): IUnknown(IUnknownVtbl) { fn SetObjectToken(&mut self, pToken: *mut ISpObjectToken) -> ::HRESULT, fn GetObjectToken(&mut self, ppToken: *mut *mut ISpObjectToken) -> ::HRESULT } ); RIDL!( interface ISpResourceManager(ISpResourceManagerVtbl): IServiceProvider(IServiceProviderVtbl) { fn SetObject(&mut self, guidServiceId: ::REFGUID, pUnkObject: *mut ::IUnknown) -> ::HRESULT, fn GetObject( &mut self, guidServiceId: ::REFGUID, ObjectCLSID: ::REFCLSID, ObjectIID: ::REFIID, fReleaseWhenLastExternalRefReleased: ::BOOL, ppObject: *mut *mut ::c_void ) -> ::HRESULT } ); ENUM!{enum SPEVENTLPARAMTYPE { SPET_LPARAM_IS_UNDEFINED = 0, SPET_LPARAM_IS_TOKEN, SPET_LPARAM_IS_OBJECT, SPET_LPARAM_IS_POINTER, SPET_LPARAM_IS_STRING, }} ENUM!{enum SPEVENTENUM { SPEI_UNDEFINED = 0, SPEI_START_INPUT_STREAM = 1, SPEI_END_INPUT_STREAM = 2, SPEI_VOICE_CHANGE = 3, SPEI_TTS_BOOKMARK = 4, SPEI_WORD_BOUNDARY = 5, SPEI_PHONEME = 6, SPEI_SENTENCE_BOUNDARY = 7, SPEI_VISEME = 8, SPEI_TTS_AUDIO_LEVEL = 9, SPEI_TTS_PRIVATE = 15, SPEI_END_SR_STREAM = 34, SPEI_SOUND_START = 35, SPEI_SOUND_END = 36, SPEI_PHRASE_START = 37, SPEI_RECOGNITION = 38, SPEI_HYPOTHESIS = 39, SPEI_SR_BOOKMARK = 40, SPEI_PROPERTY_NUM_CHANGE = 41, SPEI_PROPERTY_STRING_CHANGE = 42, SPEI_FALSE_RECOGNITION = 43, SPEI_INTERFERENCE = 44, SPEI_REQUEST_UI = 45, SPEI_RECO_STATE_CHANGE = 46, SPEI_ADAPTATION = 47, SPEI_START_SR_STREAM = 48, SPEI_RECO_OTHER_CONTEXT = 49, SPEI_SR_AUDIO_LEVEL = 50, SPEI_SR_RETAINEDAUDIO = 51, SPEI_SR_PRIVATE = 52, SPEI_ACTIVE_CATEGORY_CHANGED = 53, SPEI_RESERVED5 = 54, SPEI_RESERVED6 = 55, SPEI_RESERVED1 = 30, SPEI_RESERVED2 = 33, SPEI_RESERVED3 = 63, }} pub const SPEI_MIN_TTS: SPEVENTENUM = SPEI_START_INPUT_STREAM; pub const SPEI_MAX_TTS: SPEVENTENUM = SPEI_TTS_PRIVATE; pub const SPEI_MIN_SR: SPEVENTENUM = SPEI_END_SR_STREAM; pub const SPEI_MAX_SR: SPEVENTENUM = SPEI_RESERVED6; pub const SPFEI_FLAGCHECK: u64 = (1 << SPEI_RESERVED1.0 as u64) | (1 << SPEI_RESERVED2.0 as u64); pub const SPFEI_ALL_TTS_EVENTS: u64 = 0x000000000000FFFE | SPFEI_FLAGCHECK; pub const SPFEI_ALL_SR_EVENTS: u64 = 0x003FFFFC00000000 | SPFEI_FLAGCHECK; pub const SPFEI_ALL_EVENTS: u64 = 0xEFFFFFFFFFFFFFFF; #[inline] pub fn SPFEI(SPEI_ord: u64) -> u64 { (1 << SPEI_ord) | SPFEI_FLAGCHECK } STRUCT!{struct SPEVENT { eEventId: ::WORD, elParamType: ::WORD, ulStreamNum: ::ULONG, ullAudioStreamOffset: ::ULONGLONG, wParam: ::WPARAM, lParam: ::LPARAM, }} STRUCT!{struct SPSERIALIZEDEVENT { eEventId: ::WORD, elParamType: ::WORD, ulStreamNum: ::ULONG, ullAudioStreamOffset: ::ULONGLONG, SerializedwParam: ::ULONG, SerializedlParam: ::LONG, }} STRUCT!{struct SPSERIALIZEDEVENT64 { eEventId: ::WORD, elParamType: ::WORD, ulStreamNum: ::ULONG, ullAudioStreamOffset: ::ULONGLONG, SerializedwParam: ::ULONGLONG, SerializedlParam: ::LONGLONG, }} STRUCT!{struct SPEVENTEX { eEventId: ::WORD, elParamType: ::WORD, ulStreamNum: ::ULONG, ullAudioStreamOffset: ::ULONGLONG, wParam: ::WPARAM, lParam: ::LPARAM, ullAudioTimeOffset: ::ULONGLONG, }} ENUM!{enum SPINTERFERENCE { SPINTERFERENCE_NONE = 0, SPINTERFERENCE_NOISE = 1, SPINTERFERENCE_NOSIGNAL = 2, SPINTERFERENCE_TOOLOUD = 3, SPINTERFERENCE_TOOQUIET = 4, SPINTERFERENCE_TOOFAST = 5, SPINTERFERENCE_TOOSLOW = 6, SPINTERFERENCE_LATENCY_WARNING = 7, SPINTERFERENCE_LATENCY_TRUNCATE_BEGIN = 8, SPINTERFERENCE_LATENCY_TRUNCATE_END = 9, }} FLAGS!{enum SPENDSRSTREAMFLAGS { SPESF_NONE = 0, SPESF_STREAM_RELEASED = 1 << 0, SPESF_EMULATED = 1 << 1, }} FLAGS!{enum SPVFEATURE { SPVFEATURE_STRESSED = 1 << 0, SPVFEATURE_EMPHASIS = 1 << 1, }} ENUM!{enum SPVISEMES { SP_VISEME_0 = 0, SP_VISEME_1, SP_VISEME_2, SP_VISEME_3, SP_VISEME_4, SP_VISEME_5, SP_VISEME_6, SP_VISEME_7, SP_VISEME_8, SP_VISEME_9, SP_VISEME_10, SP_VISEME_11, SP_VISEME_12, SP_VISEME_13, SP_VISEME_14, SP_VISEME_15, SP_VISEME_16, SP_VISEME_17, SP_VISEME_18, SP_VISEME_19, SP_VISEME_20, SP_VISEME_21, }} STRUCT!{struct SPEVENTSOURCEINFO { ullEventInterest: ::ULONGLONG, ullQueuedInterest: ::ULONGLONG, ulCount: ::ULONG, }} RIDL!( interface ISpEventSource(ISpEventSourceVtbl): ISpNotifySource(ISpNotifySourceVtbl) { fn SetInterest( &mut self, ullEventInterest: ::ULONGLONG, ullQueuedInterest: ::ULONGLONG ) -> ::HRESULT, fn GetEvents( &mut self, ulCount: ::ULONG, pEventArray: *mut SPEVENT, pulFetched: *mut ::ULONG ) -> ::HRESULT, fn GetInfo(&mut self, pInfo: *mut SPEVENTSOURCEINFO) -> ::HRESULT } ); RIDL!( interface ISpEventSource2(ISpEventSource2Vtbl): ISpEventSource(ISpEventSourceVtbl) { fn GetEventsEx( &mut self, ulCount: ::ULONG, pEventArray: *mut SPEVENTEX, pulFetched: *mut ::ULONG ) -> ::HRESULT } ); RIDL!( interface ISpEventSink(ISpEventSinkVtbl): IUnknown(IUnknownVtbl) { fn AddEvents(&mut self, pEventArray: *const SPEVENT, ulCount: ::ULONG) -> ::HRESULT, fn GetEventInterest(&mut self, pullEventInterest: *mut ::ULONGLONG) -> ::HRESULT } ); RIDL!( interface ISpStreamFormat(ISpStreamFormatVtbl): IStream(IStreamVtbl) { fn GetFormat( &mut self, pguidFormatId: *mut ::GUID, ppCoMemWaveFormatEx: *mut *mut ::WAVEFORMATEX ) -> ::HRESULT } ); ENUM!{enum SPFILEMODE { SPFM_OPEN_READONLY = 0, SPFM_OPEN_READWRITE = 1, SPFM_CREATE = 2, SPFM_CREATE_ALWAYS = 3, SPFM_NUM_MODES = 4, }} RIDL!( interface ISpStream(ISpStreamVtbl): ISpStreamFormat(ISpStreamFormatVtbl) { fn SetBaseStream( &mut self, pStream: *mut ::IStream, rguidFormat: ::REFGUID, pWaveFormatEx: *const ::WAVEFORMATEX ) -> ::HRESULT, fn GetBaseStream(&mut self, ppStream: *mut *mut ::IStream) -> ::HRESULT, fn BindToFile( &mut self, pszFileName: ::LPCWSTR, eMode: SPFILEMODE, pFormatId: *const ::GUID, pWaveFormatEx: *const ::WAVEFORMATEX, ullEventInterest: ::ULONGLONG ) -> ::HRESULT, fn Close(&mut self) -> ::HRESULT } ); RIDL!( interface ISpStreamFormatConverter(ISpStreamFormatConverterVtbl) : ISpStreamFormat(ISpStreamFormatVtbl) { fn SetBaseStream( &mut self, pStream: *mut ISpStreamFormat, fSetFormatToBaseStreamFormat: ::BOOL, fWriteToBaseStream: ::BOOL ) -> ::HRESULT, fn GetBaseStream(&mut self, ppStream: *mut *mut ISpStreamFormat) -> ::HRESULT, fn SetFormat( &mut self, rguidFormatIdOfConvertedStream: ::REFGUID, pWaveFormatExOfConvertedStream: *const ::WAVEFORMATEX ) -> ::HRESULT, fn ResetSeekPosition(&mut self) -> ::HRESULT, fn ScaleConvertedToBaseOffset( &mut self, ullOffsetConvertedStream: ::ULONGLONG, pullOffsetBaseStream: *mut ::ULONGLONG ) -> ::HRESULT, fn ScaleBaseToConvertedOffset( &mut self, ullOffsetBaseStream: ::ULONGLONG, pullOffsetConvertedStream: *mut ::ULONGLONG ) -> ::HRESULT } ); ENUM!{enum SPAUDIOSTATE { SPAS_CLOSED = 0, SPAS_STOP = 1, SPAS_PAUSE = 2, SPAS_RUN = 3, }} STRUCT!{struct SPAUDIOSTATUS { cbFreeBuffSpace: ::LONG, cbNonBlockingIO: ::ULONG, State: SPAUDIOSTATE, CurSeekPos: ::ULONGLONG, CurDevicePos: ::ULONGLONG, dwAudioLevel: ::DWORD, dwReserved2: ::DWORD, }} STRUCT!{struct SPAUDIOBUFFERINFO { ulMsMinNotification: ::ULONG, ulMsBufferSize: ::ULONG, ulMsEventBias: ::ULONG, }} RIDL!( interface ISpAudio(ISpAudioVtbl): ISpStreamFormat(ISpStreamFormatVtbl) { fn SetState(&mut self, NewState: SPAUDIOSTATE, ullReserved: ::ULONGLONG) -> ::HRESULT, fn SetFormat( &mut self, rguidFmtId: ::REFGUID, pWaveFormatEx: *const ::WAVEFORMATEX ) -> ::HRESULT, fn GetStatus(&mut self, pStatus: *mut SPAUDIOSTATUS) -> ::HRESULT, fn SetBufferInfo(&mut self, pBuffInfo: *const SPAUDIOBUFFERINFO) -> ::HRESULT, fn GetBufferInfo(&mut self, pBuffInfo: *mut SPAUDIOBUFFERINFO) -> ::HRESULT, fn GetDefaultFormat( &mut self, pFormatId: *mut ::GUID, ppCoMemWaveFormatEx: *mut *mut ::WAVEFORMATEX ) -> ::HRESULT, fn EventHandle(&mut self) -> ::HANDLE, fn GetVolumeLevel(&mut self, pLevel: *mut ::ULONG) -> ::HRESULT, fn SetVolumeLevel(&mut self, Level: ::ULONG) -> ::HRESULT, fn GetBufferNotifySize(&mut self, pcbSize: *mut ::ULONG) -> ::HRESULT, fn SetBufferNotifySize(&mut self, cbSize: ::ULONG) -> ::HRESULT } ); RIDL!( interface ISpMMSysAudio(ISpMMSysAudioVtbl): ISpAudio(ISpAudioVtbl) { fn GetDeviceId(&mut self, puDeviceId: *mut ::UINT) -> ::HRESULT, fn SetDeviceId(&mut self, uDeviceId: ::UINT) -> ::HRESULT, fn GetMMHandle(&mut self, pHandle: *mut *mut ::c_void) -> ::HRESULT, fn GetLineId(&mut self, puLineId: *mut ::UINT) -> ::HRESULT, fn SetLineId(&mut self, uLineId: ::UINT) -> ::HRESULT } ); RIDL!( interface ISpTranscript(ISpTranscriptVtbl): IUnknown(IUnknownVtbl) { fn GetTranscript(&mut self, ppszTranscript: *mut ::LPWSTR) -> ::HRESULT, fn AppendTranscript(&mut self, pszTranscript: ::LPCWSTR) -> ::HRESULT } ); FLAGS!{enum SPDISPLYATTRIBUTES { SPAF_ONE_TRAILING_SPACE = 0x2, SPAF_TWO_TRAILING_SPACES = 0x4, SPAF_CONSUME_LEADING_SPACES = 0x8, SPAF_BUFFER_POSITION = 0x10, SPAF_ALL = 0x1f, SPAF_USER_SPECIFIED = 0x80, }} pub type SPPHONEID = ::WCHAR; pub type PSPPHONEID = ::LPWSTR; pub type PCSPPHONEID = ::LPCWSTR; STRUCT!{struct SPPHRASEELEMENT { ulAudioTimeOffset: ::ULONG, ulAudioSizeTime: ::ULONG, ulAudioStreamOffset: ::ULONG, ulAudioSizeBytes: ::ULONG, ulRetainedStreamOffset: ::ULONG, ulRetainedSizeBytes: ::ULONG, pszDisplayText: ::LPCWSTR, pszLexicalForm: ::LPCWSTR, pszPronunciation: *const SPPHONEID, bDisplayAttributes: ::BYTE, RequiredConfidence: ::c_char, ActualConfidence: ::c_char, Reserved: ::BYTE, SREngineConfidence: ::c_float, }} STRUCT!{struct SPPHRASERULE { pszName: ::LPCWSTR, ulId: ::ULONG, ulFirstElement: ::ULONG, ulCountOfElements: ::ULONG, pNextSibling: *const SPPHRASERULE, pFirstChild: *const SPPHRASERULE, SREngineConfidence: ::c_float, Confidence: ::c_char, }} ENUM!{enum SPPHRASEPROPERTYUNIONTYPE { SPPPUT_UNUSED = 0, SPPPUT_ARRAY_INDEX, }} STRUCT!{struct SPPHRASEPROPERTY { pszName: ::LPCWSTR, bType: ::BYTE, bReserved: ::BYTE, usArrayIndex: u16, pszValue: ::LPCWSTR, vValue: ::VARIANT, ulFirstElement: ::ULONG, ulCountOfElements: ::ULONG, pNextSibling: *const SPPHRASEPROPERTY, pFirstChild: *const SPPHRASEPROPERTY, SREngineConfidence: ::c_float, Confidence: ::c_char, }} UNION!(SPPHRASEPROPERTY, bType, ulId, ulId_mut, ::ULONG); STRUCT!{struct SPPHRASEREPLACEMENT { bDisplayAttributes: ::BYTE, pszReplacementText: ::LPCWSTR, ulFirstElement: ::ULONG, ulCountOfElements: ::ULONG, }} STRUCT!{struct SPSEMANTICERRORINFO { ulLineNumber: ::ULONG, pszScriptLine: ::LPWSTR, pszSource: ::LPWSTR, pszDescription: ::LPWSTR, hrResultCode: ::HRESULT, }} ENUM!{enum SPSEMANTICFORMAT { SPSMF_SAPI_PROPERTIES = 0, SPSMF_SRGS_SEMANTICINTERPRETATION_MS = 1, SPSMF_SRGS_SAPIPROPERTIES = 2, SPSMF_UPS = 4, SPSMF_SRGS_SEMANTICINTERPRETATION_W3C = 8, }} STRUCT!{struct SPPHRASE_50 { cbSize: ::ULONG, LangID: ::WORD, wHomophoneGroupId: ::WORD, ullGrammarID: ::ULONGLONG, ftStartTime: ::ULONGLONG, ullAudioStreamPosition: ::ULONGLONG, ulAudioSizeBytes: ::ULONG, ulRetainedSizeBytes: ::ULONG, ulAudioSizeTime: ::ULONG, Rule: ::SPPHRASERULE, pProperties: *const ::SPPHRASEPROPERTY, pElements: *const ::SPPHRASEELEMENT, cReplacements: ::ULONG, pReplacements: *const ::SPPHRASEREPLACEMENT, SREngineID: ::GUID, ulSREnginePrivateDataSize: ::ULONG, pSREnginePrivateData: *const ::BYTE, }} STRUCT!{struct SPPHRASE_53 { cbSize: ::ULONG, LangID: ::WORD, wHomophoneGroupId: ::WORD, ullGrammarID: ::ULONGLONG, ftStartTime: ::ULONGLONG, ullAudioStreamPosition: ::ULONGLONG, ulAudioSizeBytes: ::ULONG, ulRetainedSizeBytes: ::ULONG, ulAudioSizeTime: ::ULONG, Rule: ::SPPHRASERULE, pProperties: *const ::SPPHRASEPROPERTY, pElements: *const ::SPPHRASEELEMENT, cReplacements: ::ULONG, pReplacements: *const ::SPPHRASEREPLACEMENT, SREngineID: ::GUID, ulSREnginePrivateDataSize: ::ULONG, pSREnginePrivateData: *const ::BYTE, pSML: ::LPWSTR, pSemanticErrorInfo: *mut SPSEMANTICERRORINFO, }} STRUCT!{struct SPPHRASE { cbSize: ::ULONG, LangID: ::WORD, wHomophoneGroupId: ::WORD, ullGrammarID: ::ULONGLONG, ftStartTime: ::ULONGLONG, ullAudioStreamPosition: ::ULONGLONG, ulAudioSizeBytes: ::ULONG, ulRetainedSizeBytes: ::ULONG, ulAudioSizeTime: ::ULONG, Rule: ::SPPHRASERULE, pProperties: *const ::SPPHRASEPROPERTY, pElements: *const ::SPPHRASEELEMENT, cReplacements: ::ULONG, pReplacements: *const ::SPPHRASEREPLACEMENT, SREngineID: ::GUID, ulSREnginePrivateDataSize: ::ULONG, pSREnginePrivateData: *const ::BYTE, pSML: ::LPWSTR, pSemanticErrorInfo: *mut SPSEMANTICERRORINFO, SemanticTagFormat: SPSEMANTICFORMAT, }} STRUCT!{struct SPSERIALIZEDPHRASE { ulSerializedSize: ::ULONG, }} STRUCT!{struct SPRULE { pszRuleName: ::LPCWSTR, ulRuleId: ::ULONG, dwAttributes: ::DWORD, }} FLAGS!{enum SPVALUETYPE { SPDF_PROPERTY = 0x1, SPDF_REPLACEMENT = 0x2, SPDF_RULE = 0x4, SPDF_DISPLAYTEXT = 0x8, SPDF_LEXICALFORM = 0x10, SPDF_PRONUNCIATION = 0x20, SPDF_AUDIO = 0x40, SPDF_ALTERNATES = 0x80, SPDF_ALL = 0xff, }} STRUCT!{struct SPBINARYGRAMMAR { ulTotalSerializedSize: ::ULONG, }} ENUM!{enum SPPHRASERNG { SPPR_ALL_ELEMENTS = -1i32 as u32, }} pub const SP_GETWHOLEPHRASE: SPPHRASERNG = SPPR_ALL_ELEMENTS; pub const SPRR_ALL_ELEMENTS: SPPHRASERNG = SPPR_ALL_ELEMENTS; DECLARE_HANDLE!(SPSTATEHANDLE, SPSTATEHANDLE__); FLAGS!{enum SPRECOEVENTFLAGS { SPREF_AutoPause = 1 << 0, SPREF_Emulated = 1 << 1, SPREF_SMLTimeout = 1 << 2, SPREF_ExtendableParse = 1 << 3, SPREF_ReSent = 1 << 4, SPREF_Hypothesis = 1 << 5, SPREF_FalseRecognition = 1 << 6, }} ENUM!{enum SPPARTOFSPEECH { SPPS_NotOverriden = -1i32 as u32, SPPS_Unknown = 0, SPPS_Noun = 0x1000, SPPS_Verb = 0x2000, SPPS_Modifier = 0x3000, SPPS_Function = 0x4000, SPPS_Interjection = 0x5000, SPPS_Noncontent = 0x6000, SPPS_LMA = 0x7000, SPPS_SuppressWord = 0xf000, }} FLAGS!{enum SPLEXICONTYPE { eLEXTYPE_USER = 1 << 0, eLEXTYPE_APP = 1 << 1, eLEXTYPE_VENDORLEXICON = 1 << 2, eLEXTYPE_LETTERTOSOUND = 1 << 3, eLEXTYPE_MORPHOLOGY = 1 << 4, eLEXTYPE_RESERVED4 = 1 << 5, eLEXTYPE_USER_SHORTCUT = 1 << 6, eLEXTYPE_RESERVED6 = 1 << 7, eLEXTYPE_RESERVED7 = 1 << 8, eLEXTYPE_RESERVED8 = 1 << 9, eLEXTYPE_RESERVED9 = 1 << 10, eLEXTYPE_RESERVED10 = 1 << 11, eLEXTYPE_PRIVATE1 = 1 << 12, eLEXTYPE_PRIVATE2 = 1 << 13, eLEXTYPE_PRIVATE3 = 1 << 14, eLEXTYPE_PRIVATE4 = 1 << 15, eLEXTYPE_PRIVATE5 = 1 << 16, eLEXTYPE_PRIVATE6 = 1 << 17, eLEXTYPE_PRIVATE7 = 1 << 18, eLEXTYPE_PRIVATE8 = 1 << 19, eLEXTYPE_PRIVATE9 = 1 << 20, eLEXTYPE_PRIVATE10 = 1 << 21, eLEXTYPE_PRIVATE11 = 1 << 22, eLEXTYPE_PRIVATE12 = 1 << 23, eLEXTYPE_PRIVATE13 = 1 << 24, eLEXTYPE_PRIVATE14 = 1 << 25, eLEXTYPE_PRIVATE15 = 1 << 26, eLEXTYPE_PRIVATE16 = 1 << 27, eLEXTYPE_PRIVATE17 = 1 << 28, eLEXTYPE_PRIVATE18 = 1 << 29, eLEXTYPE_PRIVATE19 = 1 << 30, eLEXTYPE_PRIVATE20 = 1 << 31, }} FLAGS!{enum SPWORDTYPE { eWORDTYPE_ADDED = 1 << 0, eWORDTYPE_DELETED = 1 << 1, }} FLAGS!{enum SPPRONUNCIATIONFLAGS { ePRONFLAG_USED = 1 << 0, }} STRUCT!{struct SPWORDPRONUNCIATION { pNextWordPronunciation: *mut SPWORDPRONUNCIATION, eLexiconType: SPLEXICONTYPE, LangID: ::WORD, wPronunciationFlags: ::WORD, ePartOfSpeech: SPPARTOFSPEECH, szPronunciation: [SPPHONEID; 1], }} STRUCT!{struct SPWORDPRONUNCIATIONLIST { ulSize: ::ULONG, pvBuffer: *mut ::BYTE, pFirstWordPronunciation: *mut SPWORDPRONUNCIATION, }} STRUCT!{struct SPWORD { pNextWord: *mut SPWORD, LangID: ::WORD, wReserved: ::WORD, eWordType: SPWORDTYPE, pszWord: ::LPWSTR, pFirstWordPronunciation: *mut SPWORDPRONUNCIATION, }} STRUCT!{struct SPWORDLIST { ulSize: ::ULONG, pvBuffer: *mut ::BYTE, pFirstWord: *mut SPWORD, }} RIDL!( interface ISpLexicon(ISpLexiconVtbl): IUnknown(IUnknownVtbl) { fn GetPronunciations( &mut self, pszWord: ::LPCWSTR, LangID: ::WORD, dwFlags: ::DWORD, pWordPronunciationList: *mut SPWORDPRONUNCIATIONLIST ) -> ::HRESULT, fn AddPronunciation( &mut self, pszWord: ::LPCWSTR, LangID: ::WORD, ePartOfSpeech: SPPARTOFSPEECH, pszPronunciation: PCSPPHONEID ) -> ::HRESULT, fn RemovePronunciation( &mut self, pszWord: ::LPCWSTR, LangID: ::WORD, ePartOfSpeech: SPPARTOFSPEECH, pszPronunciation: PCSPPHONEID ) -> ::HRESULT, fn GetGeneration(&mut self, pdwGeneration: *mut ::DWORD) -> ::HRESULT, fn GetGenerationChange( &mut self, dwFlags: ::DWORD, pdwGeneration: *mut ::DWORD, pWordList: *mut SPWORDLIST ) -> ::HRESULT, fn GetWords( &mut self, dwFlags: ::DWORD, pdwGeneration: *mut ::DWORD, pdwCookie: *mut ::DWORD, pWordList: *mut SPWORDLIST ) -> ::HRESULT } ); RIDL!( interface ISpContainerLexicon(ISpContainerLexiconVtbl): ISpLexicon(ISpLexiconVtbl) { fn AddLexicon(&mut self, pAddLexicon: *mut ISpLexicon, dwFlags: ::DWORD) -> ::HRESULT } ); ENUM!{enum SPSHORTCUTTYPE { SPSHT_NotOverriden = -1i32 as u32, SPSHT_Unknown = 0, SPSHT_EMAIL = 0x1000, SPSHT_OTHER = 0x2000, SPPS_RESERVED1 = 0x3000, SPPS_RESERVED2 = 0x4000, SPPS_RESERVED3 = 0x5000, SPPS_RESERVED4 = 0xf000, }} STRUCT!{struct SPSHORTCUTPAIR { pNextSHORTCUTPAIR: *mut SPSHORTCUTPAIR, LangID: ::WORD, shType: SPSHORTCUTTYPE, pszDisplay: ::LPWSTR, pszSpoken: ::LPWSTR, }} STRUCT!{struct SPSHORTCUTPAIRLIST { ulSize: ::ULONG, pvBuffer: *mut ::BYTE, pFirstShortcutPair: *mut SPSHORTCUTPAIR, }} RIDL!( interface ISpShortcut(ISpShortcutVtbl): IUnknown(IUnknownVtbl) { fn AddShortcut( &mut self, pszDisplay: ::LPCWSTR, LangID: ::WORD, pszSpoken: ::LPCWSTR, shType: SPSHORTCUTTYPE ) -> ::HRESULT, fn RemoveShortcut( &mut self, pszDisplay: ::LPCWSTR, LangID: ::WORD, pszSpoken: ::LPCWSTR, shType: SPSHORTCUTTYPE ) -> ::HRESULT, fn GetShortcuts( &mut self, LangId: ::WORD, pShortcutpairList: *mut SPSHORTCUTPAIRLIST ) -> ::HRESULT, fn GetGeneration(&mut self, pdwGeneration: *mut ::DWORD) -> ::HRESULT, fn GetWordsFromGenerationChange( &mut self, pdwGeneration: *mut ::DWORD, pWordList: *mut SPWORDLIST ) -> ::HRESULT, fn GetWords( &mut self, pdwGeneration: *mut ::DWORD, pdwCookie: *mut ::DWORD, pWordList: *mut SPWORDLIST ) -> ::HRESULT, fn GetShortcutsForGeneration( &mut self, pdwGeneration: *mut ::DWORD, pdwCookie: *mut ::DWORD, pShortcutpairList: *mut SPSHORTCUTPAIRLIST ) -> ::HRESULT, fn GetGenerationChange( &mut self, pdwGeneration: *mut ::DWORD, pShortcutpairList: *mut SPSHORTCUTPAIRLIST ) -> ::HRESULT } ); RIDL!( interface ISpPhoneConverter(ISpPhoneConverterVtbl): ISpObjectWithToken(ISpObjectWithTokenVtbl) { fn PhoneToId(&mut self, pszPhone: ::LPCWSTR, pId: *mut SPPHONEID) -> ::HRESULT, fn IdToPhone(&mut self, pId: PCSPPHONEID, pszPhone: *mut ::WCHAR) -> ::HRESULT } ); RIDL!( interface ISpPhoneticAlphabetConverter(ISpPhoneticAlphabetConverterVtbl): IUnknown(IUnknownVtbl) { fn GetLangId(&mut self, pLangID: *mut ::WORD) -> ::HRESULT, fn SetLangId(&mut self, LangID: *mut ::WORD) -> ::HRESULT, fn SAPI2UPS( &mut self, pszSAPIId: *const SPPHONEID, pszUPSId: *mut SPPHONEID, cMaxLength: ::DWORD ) -> ::HRESULT, fn UPS2SAPI( &mut self, pszUPSId: *const SPPHONEID, pszSAPIId: *mut SPPHONEID, cMaxLength: ::DWORD ) -> ::HRESULT, fn GetMaxConvertLength( &mut self, cSrcLength: ::DWORD, bSAPI2UPS: ::BOOL, pcMaxDestLength: *mut ::DWORD ) -> ::HRESULT } ); RIDL!( interface ISpPhoneticAlphabetSelection(ISpPhoneticAlphabetSelectionVtbl): IUnknown(IUnknownVtbl) { fn IsAlphabetUPS(&mut self, pfIsUPS: *mut ::BOOL) -> ::HRESULT, fn SetAlphabetToUPS(&mut self, fForceUPS: ::BOOL) -> ::HRESULT } ); STRUCT!{struct SPVPITCH { MiddleAdj: ::c_long, RangeAdj: ::c_long, }} ENUM!{enum SPVACTIONS { SPVA_Speak = 0, SPVA_Silence, SPVA_Pronounce, SPVA_Bookmark, SPVA_SpellOut, SPVA_Section, SPVA_ParseUnknownTag, }} STRUCT!{struct SPVCONTEXT { pCategory: ::LPCWSTR, pBefore: ::LPCWSTR, pAfter: ::LPCWSTR, }} STRUCT!{struct SPVSTATE { eAction: SPVACTIONS, LangID: ::WORD, wReserved: ::WORD, EmphAdj: ::c_long, RateAdj: ::c_long, Volume: ::ULONG, PitchAdj: SPVPITCH, SilenceMSecs: ::ULONG, pPhoneIds: *mut SPPHONEID, ePartOfSpeech: SPPARTOFSPEECH, Context: SPVCONTEXT, }} ENUM!{enum SPRUNSTATE { SPRS_DONE = 1 << 0, SPRS_IS_SPEAKING = 1 << 1, }} ENUM!{enum SPVLIMITS { SPMIN_VOLUME = 0, SPMAX_VOLUME = 100, SPMIN_RATE = -10i32 as u32, SPMAX_RATE = 10, }} ENUM!{enum SPVPRIORITY { SPVPRI_NORMAL = 0, SPVPRI_ALERT = 1 << 0, SPVPRI_OVER = 1 << 1, }} STRUCT!{struct SPVOICESTATUS { ulCurrentStream: ::ULONG, ulLastStreamQueued: ::ULONG, hrLastResult: ::HRESULT, dwRunningState: ::DWORD, ulInputWordPos: ::ULONG, ulInputWordLen: ::ULONG, ulInputSentPos: ::ULONG, ulInputSentLen: ::ULONG, lBookmarkId: ::LONG, PhonemeId: SPPHONEID, VisemeId: SPVISEMES, dwReserved1: ::DWORD, dwReserved2: ::DWORD, }} FLAGS!{enum SPEAKFLAGS { SPF_DEFAULT = 0, SPF_ASYNC = 1 << 0, SPF_PURGEBEFORESPEAK = 1 << 1, SPF_IS_FILENAME = 1 << 2, SPF_IS_XML = 1 << 3, SPF_IS_NOT_XML = 1 << 4, SPF_PERSIST_XML = 1 << 5, SPF_NLP_SPEAK_PUNC = 1 << 6, SPF_PARSE_SAPI = 1 << 7, SPF_PARSE_SSML = 1 << 8, }} pub const SPF_PARSE_AUTODETECT: SPEAKFLAGS = SPF_DEFAULT; pub const SPF_NLP_MASK: SPEAKFLAGS = SPF_NLP_SPEAK_PUNC; pub const SPF_PARSE_MASK: i32 = SPF_PARSE_SAPI.0 as i32 | SPF_PARSE_SSML.0 as i32; pub const SPF_VOICE_MASK: i32 = SPF_ASYNC.0 as i32 | SPF_PURGEBEFORESPEAK.0 as i32 | SPF_IS_FILENAME.0 as i32 | SPF_IS_XML.0 as i32 | SPF_IS_NOT_XML.0 as i32 | SPF_NLP_MASK.0 as i32 | SPF_PERSIST_XML.0 as i32 | SPF_PARSE_MASK; pub const SPF_UNUSED_FLAGS: i32 = !SPF_VOICE_MASK; RIDL!( interface ISpVoice(ISpVoiceVtbl): ISpEventSource(ISpEventSourceVtbl) { fn SetOutput(&mut self, pUnkOutput: *mut ::IUnknown, fAllowFormatChanges: ::BOOL) -> ::HRESULT, fn GetOutputObjectToken(&mut self, ppObjectToken: *mut *mut ISpObjectToken) -> ::HRESULT, fn GetOutputStream(&mut self, ppStream: *mut *mut ISpStreamFormat) -> ::HRESULT, fn Pause(&mut self) -> ::HRESULT, fn Resume(&mut self) -> ::HRESULT, fn SetVoice(&mut self, pToken: *mut ISpObjectToken) -> ::HRESULT, fn GetVoice(&mut self, ppToken: *mut *mut ISpObjectToken) -> ::HRESULT, fn Speak( &mut self, pwcs: ::LPCWSTR, dwFlags: ::DWORD, pulStreamNumber: *mut ::ULONG ) -> ::HRESULT, fn SpeakStream( &mut self, pStream: *mut ::IStream, dwFlags: ::DWORD, pulStreamNumber: *mut ::ULONG ) -> ::HRESULT, fn GetStatus( &mut self, pStatus: *mut SPVOICESTATUS, ppszLastBookmark: *mut ::LPWSTR ) -> ::HRESULT, fn Skip( &mut self, pItemType: ::LPCWSTR, lNumItems: ::c_long, pulNumSkipped: *mut ::ULONG ) -> ::HRESULT, fn SetPriority(&mut self, ePriority: SPVPRIORITY) -> ::HRESULT, fn GetPriority(&mut self, pePriority: *mut SPVPRIORITY) -> ::HRESULT, fn SetAlertBoundary(&mut self, eBoundary: SPEVENTENUM) -> ::HRESULT, fn GetAlertBoundary(&mut self, peBoundary: *mut SPEVENTENUM) -> ::HRESULT, fn SetRate(&mut self, RateAdjust: ::c_long) -> ::HRESULT, fn GetRate(&mut self, pRateAdjust: *mut ::c_long) -> ::HRESULT, fn SetVolume(&mut self, usVolume: ::USHORT) -> ::HRESULT, fn GetVolume(&mut self, pusVolume: *mut ::USHORT) -> ::HRESULT, fn WaitUntilDone(&mut self, msTimeout: ::ULONG) -> ::HRESULT, fn SetSyncSpeakTimeout(&mut self, msTimeout: ::ULONG) -> ::HRESULT, fn GetSyncSpeakTimeout(&mut self, pmsTimeout: *mut ::ULONG) -> ::HRESULT, fn SpeakCompleteEvent(&mut self) -> ::HANDLE, fn IsUISupported( &mut self, pszTypeOfUI: ::LPCWSTR, pvExtraData: *mut ::c_void, cbExtraData: ::ULONG, pfSupported: *mut ::BOOL ) -> ::HRESULT, fn DisplayUI( &mut self, hwndParent: ::HWND, pszTitle: ::LPCWSTR, pszTypeOfUI: ::LPCWSTR, pvExtraData: *mut ::c_void, cbExtraData: ::ULONG ) -> ::HRESULT } ); DEFINE_GUID!( UuidOfISpVoice, 0x6C44DF74, 0x72B9, 0x4992, 0xA1, 0xEC, 0xEF, 0x99, 0x6E, 0x04, 0x22, 0xD4 ); RIDL!( interface ISpPhrase(ISpPhraseVtbl): IUnknown(IUnknownVtbl) { fn GetPhrase(&mut self, ppCoMemPhrase: *mut *mut SPPHRASE) -> ::HRESULT, fn GetSerializedPhrase(&mut self, ppCoMemPhrase: *mut *mut SPSERIALIZEDPHRASE) -> ::HRESULT, fn GetText( &mut self, ulStart: ::ULONG, ulCount: ::ULONG, fUseTextReplacements: ::BOOL, ppszCoMemText: *mut ::LPWSTR, pbDisplayAttributes: *mut ::BYTE ) -> ::HRESULT, fn Discard(&mut self, dwValueTypes: ::DWORD) -> ::HRESULT } ); RIDL!( interface ISpPhraseAlt(ISpPhraseAltVtbl): ISpPhrase(ISpPhraseVtbl) { fn GetAltInfo( &mut self, pParent: *mut *mut ISpPhrase, pulStartElementInParent: *mut ::ULONG, pcElementsInParent: *mut ::ULONG, pcElementsInAlt: *mut ::ULONG ) -> ::HRESULT, fn Commit(&mut self) -> ::HRESULT } ); ENUM!{enum SPXMLRESULTOPTIONS { SPXRO_SML = 0, SPXRO_Alternates_SML = 1, }} RIDL!( interface ISpPhrase2(ISpPhrase2Vtbl): ISpPhrase(ISpPhraseVtbl) { fn GetXMLResult( &mut self, ppszCoMemXMLResult: *mut ::LPWSTR, Options: SPXMLRESULTOPTIONS ) -> ::HRESULT, fn GetXMLErrorInfo(&mut self, pSemanticErrorInfo: *mut SPSEMANTICERRORINFO) -> ::HRESULT, fn GetAudio( &mut self, ulStartElement: ::ULONG, cElements: ::ULONG, ppStream: *mut *mut ISpStreamFormat ) -> ::HRESULT } ); STRUCT!{struct SPRECORESULTTIMES { ftStreamTime: ::FILETIME, ullLength: ::ULONGLONG, dwTickCount: ::DWORD, ullStart: ::ULONGLONG, }} STRUCT!{struct SPSERIALIZEDRESULT { ulSerializedSize: ::ULONG, }} RIDL!( interface ISpRecoResult(ISpRecoResultVtbl): ISpPhrase(ISpPhraseVtbl) { fn GetResultTimes(&mut self, pTimes: *mut SPRECORESULTTIMES) -> ::HRESULT, fn GetAlternates( &mut self, ulStartElement: ::ULONG, cElements: ::ULONG, ulRequestCount: ::ULONG, ppPhrases: *mut *mut ISpPhraseAlt, pcPhrasesReturned: *mut ::ULONG ) -> ::HRESULT, fn GetAudio( &mut self, ulStartElement: ::ULONG, cElements: ::ULONG, ppStream: *mut *mut ISpStreamFormat ) -> ::HRESULT, fn SpeakAudio( &mut self, ulStartElement: ::ULONG, cElements: ::ULONG, dwFlags: ::DWORD, pulStreamNumber: *mut ::ULONG ) -> ::HRESULT, fn Serialize(&mut self, ppCoMemSerializedResult: *mut *mut SPSERIALIZEDRESULT) -> ::HRESULT, fn ScaleAudio( &mut self, pAudioFormatId: *const ::GUID, pWaveFormatEx: *const ::WAVEFORMATEX ) -> ::HRESULT, fn GetRecoContext(&mut self, ppRecoContext: *mut *mut ISpRecoContext) -> ::HRESULT } ); FLAGS!{enum SPCOMMITFLAGS { SPCF_NONE = 0, SPCF_ADD_TO_USER_LEXICON = 1 << 0, SPCF_DEFINITE_CORRECTION = 1 << 1, }} RIDL!( interface ISpRecoResult2(ISpRecoResult2Vtbl): ISpRecoResult(ISpRecoResultVtbl) { fn CommitAlternate( &mut self, pPhraseAlt: *mut ISpPhraseAlt, ppNewResult: *mut *mut ISpRecoResult ) -> ::HRESULT, fn CommitText( &mut self, ulStartElement: ::ULONG, cElements: ::ULONG, pszCorrectedData: ::LPCWSTR, eCommitFlags: ::DWORD ) -> ::HRESULT, fn SetTextFeedback(&mut self, pszFeedback: ::LPCWSTR, fSuccessful: ::BOOL) -> ::HRESULT } ); RIDL!( interface ISpXMLRecoResult(ISpXMLRecoResultVtbl): ISpRecoResult(ISpRecoResultVtbl) { fn GetXMLResult( &mut self, ppszCoMemXMLResult: *mut ::LPWSTR, Options: SPXMLRESULTOPTIONS ) -> ::HRESULT, fn GetXMLErrorInfo(&mut self, pSemanticErrorInfo: *mut SPSEMANTICERRORINFO) -> ::HRESULT } ); STRUCT!{struct SPTEXTSELECTIONINFO { ulStartActiveOffset: ::ULONG, cchActiveChars: ::ULONG, ulStartSelection: ::ULONG, cchSelection: ::ULONG, }} ENUM!{enum SPWORDPRONOUNCEABLE { SPWP_UNKNOWN_WORD_UNPRONOUNCEABLE = 0, SPWP_UNKNOWN_WORD_PRONOUNCEABLE = 1, SPWP_KNOWN_WORD_PRONOUNCEABLE = 2, }} ENUM!{enum SPGRAMMARSTATE { SPGS_DISABLED = 0, SPGS_ENABLED = 1, SPGS_EXCLUSIVE = 3, }} ENUM!{enum SPCONTEXTSTATE { SPCS_DISABLED = 0, SPCS_ENABLED = 1, }} ENUM!{enum SPRULESTATE { SPRS_INACTIVE = 0, SPRS_ACTIVE = 1, SPRS_ACTIVE_WITH_AUTO_PAUSE = 3, SPRS_ACTIVE_USER_DELIMITED = 4, }} pub const SP_STREAMPOS_ASAP: ::INT = 0; pub const SP_STREAMPOS_REALTIME: ::INT = -1; pub const SPRULETRANS_TEXTBUFFER: SPSTATEHANDLE = -1isize as SPSTATEHANDLE; pub const SPRULETRANS_WILDCARD: SPSTATEHANDLE = -2isize as SPSTATEHANDLE; pub const SPRULETRANS_DICTATION: SPSTATEHANDLE = -3isize as SPSTATEHANDLE; ENUM!{enum SPGRAMMARWORDTYPE { SPWT_DISPLAY = 0, SPWT_LEXICAL = 1, SPWT_PRONUNCIATION = 2, SPWT_LEXICAL_NO_SPECIAL_CHARS = 3, }} STRUCT!{struct SPPROPERTYINFO { pszName: ::LPCWSTR, ulId: ::ULONG, pszValue: ::LPCWSTR, vValue: ::VARIANT, }} FLAGS!{enum SPCFGRULEATTRIBUTES { SPRAF_TopLevel = 1 << 0, SPRAF_Active = 1 << 1, SPRAF_Export = 1 << 2, SPRAF_Import = 1 << 3, SPRAF_Interpreter = 1 << 4, SPRAF_Dynamic = 1 << 5, SPRAF_Root = 1 << 6, SPRAF_AutoPause = 1 << 16, SPRAF_UserDelimited = 1 << 17, }} RIDL!( interface ISpGrammarBuilder(ISpGrammarBuilderVtbl): IUnknown(IUnknownVtbl) { fn ResetGrammar(&mut self, NewLanguage: ::WORD) -> ::HRESULT, fn GetRule( &mut self, pszRuleName: ::LPCWSTR, dwRuleId: ::DWORD, dwAttributes: ::DWORD, fCreateIfNotExist: ::BOOL, phInitialState: *mut SPSTATEHANDLE ) -> ::HRESULT, fn ClearRule(&mut self, hState: SPSTATEHANDLE) -> ::HRESULT, fn CreateNewState(&mut self, hState: SPSTATEHANDLE, phState: *mut SPSTATEHANDLE) -> ::HRESULT, fn AddWordTransition( &mut self, hFromState: SPSTATEHANDLE, hToState: SPSTATEHANDLE, psz: ::LPCWSTR, pszSeparators: ::LPCWSTR, eWordType: SPGRAMMARWORDTYPE, Weight: ::c_float, pPropInfo: *const SPPROPERTYINFO ) -> ::HRESULT, fn AddRuleTransition( &mut self, hFromState: SPSTATEHANDLE, hToState: SPSTATEHANDLE, hRule: SPSTATEHANDLE, Weight: ::c_float, pPropInfo: *const SPPROPERTYINFO ) -> ::HRESULT, fn AddResource( &mut self, hRuleState: SPSTATEHANDLE, pszResourceName: ::LPCWSTR, pszResourceValue: ::LPCWSTR ) -> ::HRESULT, fn Commit(&mut self, dwReserved: ::DWORD) -> ::HRESULT } ); ENUM!{enum SPLOADOPTIONS { SPLO_STATIC = 0, SPLO_DYNAMIC = 1, }} RIDL!( interface ISpRecoGrammar(ISpRecoGrammarVtbl): ISpGrammarBuilder(ISpGrammarBuilderVtbl) { fn GetGrammarId(&mut self, pullGrammarId: *mut ::ULONGLONG) -> ::HRESULT, fn GetRecoContext(&mut self, ppRecoCtxt: *mut *mut ISpRecoContext) -> ::HRESULT, fn LoadCmdFromFile(&mut self, pszFileName: ::LPCWSTR, Options: SPLOADOPTIONS) -> ::HRESULT, fn LoadCmdFromObject( &mut self, rcid: ::REFCLSID, pszGrammarName: ::LPCWSTR, Options: SPLOADOPTIONS ) -> ::HRESULT, fn LoadCmdFromResource( &mut self, hModule: ::HMODULE, pszResourceName: ::LPCWSTR, pszResourceType: ::LPCWSTR, wLanguage: ::WORD, Options: SPLOADOPTIONS ) -> ::HRESULT, fn LoadCmdFromMemory( &mut self, pGrammar: *const SPBINARYGRAMMAR, Options: SPLOADOPTIONS ) -> ::HRESULT, fn LoadCmdFromProprietaryGrammar( &mut self, rguidParam: ::REFGUID, pszStringParam: ::LPCWSTR, pvDataPrarm: *const ::c_void, cbDataSize: ::ULONG, Options: SPLOADOPTIONS ) -> ::HRESULT, fn SetRuleState( &mut self, pszName: ::LPCWSTR, pReserved: *mut ::c_void, NewState: SPRULESTATE ) -> ::HRESULT, fn SetRuleIdState(&mut self, ulRuleId: ::ULONG, NewState: SPRULESTATE) -> ::HRESULT, fn LoadDictation(&mut self, pszTopicName: ::LPCWSTR, Options: SPLOADOPTIONS) -> ::HRESULT, fn UnloadDictation(&mut self) -> ::HRESULT, fn SetDictationState(&mut self, NewState: SPRULESTATE) -> ::HRESULT, fn SetWordSequenceData( &mut self, pText: *const ::WCHAR, cchText: ::ULONG, pInfo: *const SPTEXTSELECTIONINFO ) -> ::HRESULT, fn SetTextSelection(&mut self, pInfo: *const SPTEXTSELECTIONINFO) -> ::HRESULT, fn IsPronounceable( &mut self, pszWord: ::LPCWSTR, pWordPronounceable: *mut SPWORDPRONOUNCEABLE ) -> ::HRESULT, fn SetGrammarState(&mut self, eGrammarState: SPGRAMMARSTATE) -> ::HRESULT, fn SaveCmd(&mut self, pStream: *mut ::IStream, ppszCoMemErrorText: *mut ::LPWSTR) -> ::HRESULT, fn GetGrammarState(&mut self, peGrammarState: *mut SPGRAMMARSTATE) -> ::HRESULT } ); ENUM!{enum SPMATCHINGMODE { AllWords = 0, Subsequence = 1, OrderedSubset = 3, SubsequenceContentRequired = 5, OrderedSubsetContentRequired = 7, }} ENUM!{enum PHONETICALPHABET { PA_Ipa = 0, PA_Ups = 1, PA_Sapi = 2, }} RIDL!( interface ISpGrammarBuilder2(ISpGrammarBuilder2Vtbl): IUnknown(IUnknownVtbl) { fn AddTextSubset( &mut self, hFromState: SPSTATEHANDLE, hToState: SPSTATEHANDLE, psz: ::LPCWSTR, eMatchMode: SPMATCHINGMODE ) -> ::HRESULT, fn SetPhoneticAlphabet(&mut self, phoneticALphabet: PHONETICALPHABET) -> ::HRESULT } ); RIDL!( interface ISpRecoGrammar2(ISpRecoGrammar2Vtbl): IUnknown(IUnknownVtbl) { fn GetRules(&mut self, ppCoMemRules: *mut *mut SPRULE, puNumRules: *mut ::UINT) -> ::HRESULT, fn LoadCmdFromFile2( &mut self, pszFileName: ::LPCWSTR, Options: SPLOADOPTIONS, pszSharingUri: ::LPCWSTR, pszBaseUri: ::LPCWSTR ) -> ::HRESULT, fn LoadCmdFromMemory2( &mut self, pGrammar: *const SPBINARYGRAMMAR, Options: SPLOADOPTIONS, pszSharingUri: ::LPCWSTR, pszBaseUri: ::LPCWSTR ) -> ::HRESULT, fn SetRulePriority( &mut self, pszRuleName: ::LPCWSTR, ulRuleId: ::ULONG, nRulePriority: ::c_int ) -> ::HRESULT, fn SetRuleWeight( &mut self, pszRuleName: ::LPCWSTR, ulRuleId: ::ULONG, flWeight: ::c_float ) -> ::HRESULT, fn SetDictationWeight(&mut self, flWeight: ::c_float) -> ::HRESULT, fn SetGrammarLoader(&mut self, pLoader: *mut ISpeechResourceLoader) -> ::HRESULT, fn SetSMLSecurityManager( &mut self, pSMLSecurityManager: *mut ::IInternetSecurityManager ) -> ::HRESULT } ); RIDL!( interface ISpeechResourceLoader(ISpeechResourceLoaderVtbl): IDispatch(IDispatchVtbl) { fn LoadResource( &mut self, bstrResourceUri: ::BSTR, fAlwaysReload: ::VARIANT_BOOL, pStream: *mut *mut ::IUnknown, pbstrMIMEType: *mut ::BSTR, pfModified: *mut ::VARIANT_BOOL, pbstrRedirectUrl: *mut ::BSTR ) -> ::HRESULT, fn GetLocalCopy( &mut self, bstrResourceUri: ::BSTR, pbstrLocalPath: *mut ::BSTR, pbstrMIMEType: *mut ::BSTR, pbstrRedirectUrl: *mut ::BSTR ) -> ::HRESULT, fn ReleaseLocalCopy(&mut self, pbstrLocalPath: ::BSTR) -> ::HRESULT } ); #[repr(C)] #[derive(Copy)] pub struct SPRECOCONTEXTSTATUS { pub eInterference: SPINTERFERENCE, pub szRequestTypeOfUI: [::WCHAR; 255], pub dwReserved1: ::DWORD, pub dwReserved2: ::DWORD, } impl Clone for SPRECOCONTEXTSTATUS { fn clone(&self) -> Self { *self } } FLAGS!{enum SPBOOKMARKOPTIONS { SPBO_NONE = 0, SPBO_PAUSE = 1 << 0, SPBO_AHEAD = 1 << 1, SPBO_TIME_UNITS = 1 << 2, }} FLAGS!{enum SPAUDIOOPTIONS { SPAO_NONE = 0, SPAO_RETAIN_AUDIO = 1 << 0, }} RIDL!( interface ISpRecoContext(ISpRecoContextVtbl): ISpEventSource(ISpEventSourceVtbl) { fn GetRecognizer(&mut self, ppRecognizer: *mut *mut ISpRecognizer) -> ::HRESULT, fn CreateGrammer( &mut self, ullGrammarId: ::ULONGLONG, ppGrammar: *mut *mut ISpRecoGrammar ) -> ::HRESULT, fn GetStatus(&mut self, pState: *mut SPRECOCONTEXTSTATUS) -> ::HRESULT, fn GetMaxAlternates(&mut self, pcAlternates: *mut ::ULONG) -> ::HRESULT, fn SetMaxAlternates(&mut self, cAlternates: ::ULONG) -> ::HRESULT, fn SetAudioOptions( &mut self, Options: SPAUDIOOPTIONS, pAudioFormatId: *const ::GUID, pWaveFormatEx: *const ::WAVEFORMATEX ) -> ::HRESULT, fn GetAudioOptions( &mut self, pOptions: *mut SPAUDIOOPTIONS, pAudioFormatId: *mut ::GUID, ppCoMemWFEX: *mut *mut ::WAVEFORMATEX ) -> ::HRESULT, fn DeserializeResult( &mut self, pSerializedResult: *const SPSERIALIZEDRESULT, ppResult: *mut *mut ISpRecoResult ) -> ::HRESULT, fn Bookmark( &mut self, Options: SPBOOKMARKOPTIONS, ullStreamPosition: ::ULONGLONG, lparamEvent: ::LPARAM ) -> ::HRESULT, fn SetAdaptionData(&mut self, pAdaptionData: ::LPCWSTR, cch: ::ULONG) -> ::HRESULT, fn Pause(&mut self, dwReserved: ::DWORD) -> ::HRESULT, fn Resume(&mut self, dwReserved: ::DWORD) -> ::HRESULT, fn SetVoice(&mut self, pVoice: *mut ISpVoice, fAllowFormatChanges: ::BOOL) -> ::HRESULT, fn GetVoice(&mut self, ppVoice: *mut *mut ISpVoice) -> ::HRESULT, fn SetVoicePurgeEvent(&mut self, ullEventIntereset: ::ULONGLONG) -> ::HRESULT, fn GetVoicePurgeEvent(&mut self, pullEventIntereset: *mut ::ULONGLONG) -> ::HRESULT, fn SetContextState(&mut self, eContextState: SPCONTEXTSTATE) -> ::HRESULT, fn GetContextState(&mut self, peContextState: *mut SPCONTEXTSTATE) -> ::HRESULT } ); FLAGS!{enum SPGRAMMAROPTIONS { SPGO_SAPI = 0x1, SPGO_SRGS = 0x2, SPGO_UPS = 0x4, SPGO_SRGS_MS_SCRIPT = 0x8, SPGO_SRGS_W3C_SCRIPT = 0x100, SPGO_SRGS_STG_SCRIPT = 0x200, SPGO_SRGS_SCRIPT = SPGO_SRGS.0 | SPGO_SRGS_MS_SCRIPT.0 | SPGO_SRGS_W3C_SCRIPT.0 | SPGO_SRGS_STG_SCRIPT.0, SPGO_FILE = 0x10, SPGO_HTTP = 0x20, SPGO_RES = 0x40, SPGO_OBJECT = 0x80, SPGO_DEFAULT = 0x3fb, SPGO_ALL = 0x3ff, }} FLAGS!{enum SPADAPTATIONSETTINGS { SPADS_Default = 0, SPADS_CurrentRecognizer = 0x1, SPADS_RecoProfile = 0x2, SPADS_Immediate = 0x4, SPADS_Reset = 0x8, SPADS_HighVolumeDataSource = 0x10, }} ENUM!{enum SPADAPTATIONRELEVANCE { SPAR_Unknown = 0, SPAR_Low = 1, SPAR_Medium = 2, SPAR_High = 3, }} RIDL!( interface ISpRecoContext2(ISpRecoContext2Vtbl): IUnknown(IUnknownVtbl) { fn SetGrammarOptions(&mut self, eGrammarOptions: ::DWORD) -> ::HRESULT, fn GetGrammarOptions(&mut self, peGrammarOptions: *mut ::DWORD) -> ::HRESULT, fn SetAdaptationData2( &mut self, pAdaptationData: ::LPCWSTR, cch: ::ULONG, pTopicName: ::LPCWSTR, eAdaptationSettings: ::DWORD, eRelevance: SPADAPTATIONRELEVANCE ) -> ::HRESULT } ); RIDL!( interface ISpProperties(ISpPropertiesVtbl): IUnknown(IUnknownVtbl) { fn SetPropertyNum(&mut self, pName: ::LPCWSTR, lValue: ::LONG) -> ::HRESULT, fn GetPropertyNum(&mut self, pName: ::LPCWSTR, plValue: *mut ::LONG) -> ::HRESULT, fn SetPropertyString(&mut self, pName: ::LPCWSTR, pValue: ::LPCWSTR) -> ::HRESULT, fn GetPropertyString(&mut self, pName: ::LPCWSTR, ppCoMemValue: *mut ::LPWSTR) -> ::HRESULT } ); STRUCT!{struct SPRECOGNIZERSTATUS { AudioStatus: SPAUDIOSTATUS, ullRecognitionStreamPos: ::ULONGLONG, ulStreamNumber: ::ULONG, ulNumActive: ::ULONG, clsidEngine: ::CLSID, cLangIDs: ::ULONG, aLangID: [::WORD; 20], ullRecognitionStreamTime: ::ULONGLONG, }} ENUM!{enum SPWAVEFORMATTYPE { SPWF_INPUT = 0, SPWF_SRENGINE = 1, }} pub type SPSTREAMFORMATTYPE = SPWAVEFORMATTYPE; ENUM!{enum SPRECOSTATE { SPRST_INACTIVE = 0, SPRST_ACTIVE = 1, SPRST_ACTIVE_ALWAYS = 2, SPRST_INACTIVE_WITH_PURGE = 3, SPRST_NUM_STATES = 4, }} RIDL!( interface ISpRecognizer(ISpRecognizerVtbl): ISpProperties(ISpPropertiesVtbl) { fn SetRecognizer(&mut self, pRecognizer: *mut ISpObjectToken) -> ::HRESULT, fn GetRecognizer(&mut self, ppRecognizer: *mut *mut ISpObjectToken) -> ::HRESULT, fn SetInput(&mut self, pUnkInput: *mut ::IUnknown, fAllowFormatChanges: ::BOOL) -> ::HRESULT, fn GetInputObjectToken(&mut self, ppToken: *mut *mut ISpObjectToken) -> ::HRESULT, fn GetInputStream(&mut self, ppStream: *mut *mut ISpStreamFormat) -> ::HRESULT, fn CreateRecoContext(&mut self, ppNewCtxt: *mut *mut ISpRecoContext) -> ::HRESULT, fn GetRecoProfile(&mut self, ppToken: *mut *mut ISpObjectToken) -> ::HRESULT, fn SetRecoProfile(&mut self, pToken: *mut ISpObjectToken) -> ::HRESULT, fn IsSharedInstance(&mut self) -> ::HRESULT, fn GetRecoState(&mut self, pState: *mut SPRECOSTATE) -> ::HRESULT, fn SetRecoState(&mut self, NewState: SPRECOSTATE) -> ::HRESULT, fn GetStatus(&mut self, pStatus: *mut SPRECOGNIZERSTATUS) -> ::HRESULT, fn GetFormat( &mut self, WaveFormatType: SPSTREAMFORMATTYPE, pFormatId: *mut ::GUID, ppCoMemWFEX: *mut ::WAVEFORMATEX ) -> ::HRESULT, fn IsUISupported( &mut self, pszTypeOfUI: ::LPCWSTR, pvExtraData: *mut ::c_void, cbExtraData: ::ULONG, pfSupported: *mut ::BOOL ) -> ::HRESULT, fn DisplayUI( &mut self, hwndParent: ::HWND, pszTitle: ::LPCWSTR, pszTypeOfUI: ::LPCWSTR, pvExtraData: *mut ::c_void, cbExtraData: ::ULONG ) -> ::HRESULT, fn EmulateRecognition(&mut self, pPhrase: *mut ISpPhrase) -> ::HRESULT } ); RIDL!( interface ISpSerializeState(ISpSerializeStateVtbl): IUnknown(IUnknownVtbl) { fn GetSerializedState( &mut self, ppbData: *mut *mut ::BYTE, pulSize: *mut ::ULONG, dwReserved: ::DWORD ) -> ::HRESULT, fn SetSerializedState( &mut self, pbData: *mut ::BYTE, ulSize: ::ULONG, dwReserved: ::DWORD ) -> ::HRESULT } ); RIDL!( interface ISpRecognizer2(ISpRecognizer2Vtbl): IUnknown(IUnknownVtbl) { fn EmulateRecognitionEx( &mut self, pPhrase: *mut ISpPhrase, dwCompareFlags: ::DWORD ) -> ::HRESULT, fn SetTrainingState( &mut self, fDoingTraining: ::BOOL, fAdaptFromTrainingData: ::BOOL ) -> ::HRESULT, fn ResetAcousticModelAdaptation(&mut self) -> ::HRESULT } ); ENUM!{enum SPCATEGORYTYPE { SPCT_COMMAND = 0, SPCT_DICTATION, SPCT_SLEEP, SPCT_SUB_COMMAND, SPCT_SUB_DICTATION, }} RIDL!( interface ISpRecoCategory(ISpRecoCategoryVtbl): IUnknown(IUnknownVtbl) { fn GetType(&mut self, peCategoryType: *mut SPCATEGORYTYPE) -> ::HRESULT } ); RIDL!( interface ISpRecognizer3(ISpRecognizer3Vtbl): IUnknown(IUnknownVtbl) { fn GetCategory( &mut self, categoryType: SPCATEGORYTYPE, ppCategory: *mut *mut ISpRecoCategory ) -> ::HRESULT, fn SetActiveCategory(&mut self, pCategory: *mut ISpRecoCategory) -> ::HRESULT, fn GetActiveCategory(&mut self, ppCategory: *mut *mut ISpRecoCategory) -> ::HRESULT } ); STRUCT!{struct SPNORMALIZATIONLIST { ulSize: ::ULONG, ppszzNormalizedList: *mut *mut ::WCHAR, }} RIDL!( interface ISpEnginePronunciation(ISpEnginePronunciationVtbl): IUnknown(IUnknownVtbl) { fn Normalize( &mut self, pszWord: ::LPCWSTR, pszLeftContext: ::LPCWSTR, pszRightContext: ::LPCWSTR, LangID: ::WORD, pNormalizationList: *mut SPNORMALIZATIONLIST ) -> ::HRESULT, fn GetPronunciations( &mut self, pszWord: ::LPCWSTR, pszLeftContext: ::LPCWSTR, pszRightContext: ::LPCWSTR, LangID: ::WORD, pEnginePronunciationList: *mut SPWORDPRONUNCIATIONLIST ) -> ::HRESULT } ); STRUCT!{struct SPDISPLAYTOKEN { pszLexical: *const ::WCHAR, pszDisplay: *const ::WCHAR, bDisplayAttributes: ::BYTE, }} STRUCT!{struct SPDISPLAYPHRASE { ulNumTokens: ::ULONG, pTokens: *mut SPDISPLAYTOKEN, }} RIDL!( interface ISpDisplayAlternates(ISpDisplayAlternatesVtbl): IUnknown(IUnknownVtbl) { fn GetDisplayAlternates( &mut self, pPhrase: *const SPDISPLAYPHRASE, cRequestCount: ::ULONG, ppCoMemPhrases: *mut *mut SPDISPLAYPHRASE, pcPhrasesReturned: *mut ::ULONG ) -> ::HRESULT, fn SetFullStopTrailSpace(&mut self, ulTrailSpace: ::ULONG) -> ::HRESULT } ); pub type SpeechLanguageId = ::c_long; ENUM!{enum DISPID_SpeechDataKey { DISPID_SDKSetBinaryValue = 1, DISPID_SDKGetBinaryValue, DISPID_SDKSetStringValue, DISPID_SDKGetStringValue, DISPID_SDKSetLongValue, DISPID_SDKGetlongValue, DISPID_SDKOpenKey, DISPID_SDKCreateKey, DISPID_SDKDeleteKey, DISPID_SDKDeleteValue, DISPID_SDKEnumKeys, DISPID_SDKEnumValues, }} ENUM!{enum DISPID_SpeechObjectToken { DISPID_SOTId = 1, DISPID_SOTDataKey, DISPID_SOTCategory, DISPID_SOTGetDescription, DISPID_SOTSetId, DISPID_SOTGetAttribute, DISPID_SOTCreateInstance, DISPID_SOTRemove, DISPID_SOTGetStorageFileName, DISPID_SOTRemoveStorageFileName, DISPID_SOTIsUISupported, DISPID_SOTDisplayUI, DISPID_SOTMatchesAttributes, }} ENUM!{enum SpeechDataKeyLocation { SDKLDefaultLocation = SPDKL_DefaultLocation.0, SDKLCurrentUser = SPDKL_CurrentUser.0, SDKLLocalMachine = SPDKL_LocalMachine.0, SDKLCurrentConfig = SPDKL_CurrentConfig.0, }} ENUM!{enum SpeechTokenContext { STCInprocServer = ::CLSCTX_INPROC_SERVER, STCInprocHandler = ::CLSCTX_INPROC_HANDLER, STCLocalServer = ::CLSCTX_LOCAL_SERVER, STCRemoteServer = ::CLSCTX_REMOTE_SERVER, STCAll = ::CLSCTX_INPROC_SERVER | ::CLSCTX_INPROC_HANDLER | ::CLSCTX_LOCAL_SERVER | ::CLSCTX_REMOTE_SERVER, }} ENUM!{enum SpeechTokenShellFolder { STSF_AppData = 0x1a, STSF_LocalAppData = 0x1c, STSF_CommonAppData = 0x23, STSF_FlagCreate = 0x8000, }} ENUM!{enum DISPID_SpeechObjectTokens { DISPID_SOTsCount = 1, DISPID_SOTsItem = ::DISPID_VALUE as u32, DISPID_SOTs_NewEnum = ::DISPID_NEWENUM as u32, }} ENUM!{enum DISPID_SpeechObjectTokenCategory { DISPID_SOTCId = 1, DISPID_SOTCDefault, DISPID_SOTCSetId, DISPID_SOTCGetDataKey, DISPID_SOTCEnumerateTokens, }} ENUM!{enum SpeechAudioFormatType { SAFTDefault = -1i32 as u32, SAFTNoAssignedFormat = 0, SAFTText = 1, SAFTNonStandardFormat = 2, SAFTExtendedAudioFormat = 3, SAFT8kHz8BitMono = 4, SAFT8kHz8BitStereo = 5, SAFT8kHz16BitMono = 6, SAFT8kHz16BitStereo = 7, SAFT11kHz8BitMono = 8, SAFT11kHz8BitStereo = 9, SAFT11kHz16BitMono = 10, SAFT11kHz16BitStereo = 11, SAFT12kHz8BitMono = 12, SAFT12kHz8BitStereo = 13, SAFT12kHz16BitMono = 14, SAFT12kHz16BitStereo = 15, SAFT16kHz8BitMono = 16, SAFT16kHz8BitStereo = 17, SAFT16kHz16BitMono = 18, SAFT16kHz16BitStereo = 19, SAFT22kHz8BitMono = 20, SAFT22kHz8BitStereo = 21, SAFT22kHz16BitMono = 22, SAFT22kHz16BitStereo = 23, SAFT24kHz8BitMono = 24, SAFT24kHz8BitStereo = 25, SAFT24kHz16BitMono = 26, SAFT24kHz16BitStereo = 27, SAFT32kHz8BitMono = 28, SAFT32kHz8BitStereo = 29, SAFT32kHz16BitMono = 30, SAFT32kHz16BitStereo = 31, SAFT44kHz8BitMono = 32, SAFT44kHz8BitStereo = 33, SAFT44kHz16BitMono = 34, SAFT44kHz16BitStereo = 35, SAFT48kHz8BitMono = 36, SAFT48kHz8BitStereo = 37, SAFT48kHz16BitMono = 38, SAFT48kHz16BitStereo = 39, SAFTTrueSpeech_8kHz1BitMono = 40, SAFTCCITT_ALaw_8kHzMono = 41, SAFTCCITT_ALaw_8kHzStereo = 42, SAFTCCITT_ALaw_11kHzMono = 43, SAFTCCITT_ALaw_11kHzStereo = 44, SAFTCCITT_ALaw_22kHzMono = 45, SAFTCCITT_ALaw_22kHzStereo = 46, SAFTCCITT_ALaw_44kHzMono = 47, SAFTCCITT_ALaw_44kHzStereo = 48, SAFTCCITT_uLaw_8kHzMono = 49, SAFTCCITT_uLaw_8kHzStereo = 50, SAFTCCITT_uLaw_11kHzMono = 51, SAFTCCITT_uLaw_11kHzStereo = 52, SAFTCCITT_uLaw_22kHzMono = 53, SAFTCCITT_uLaw_22kHzStereo = 54, SAFTCCITT_uLaw_44kHzMono = 55, SAFTCCITT_uLaw_44kHzStereo = 56, SAFTADPCM_8kHzMono = 57, SAFTADPCM_8kHzStereo = 58, SAFTADPCM_11kHzMono = 59, SAFTADPCM_11kHzStereo = 60, SAFTADPCM_22kHzMono = 61, SAFTADPCM_22kHzStereo = 62, SAFTADPCM_44kHzMono = 63, SAFTADPCM_44kHzStereo = 64, SAFTGSM610_8kHzMono = 65, SAFTGSM610_11kHzMono = 66, SAFTGSM610_22kHzMono = 67, SAFTGSM610_44kHzMono = 68, }} ENUM!{enum DISPID_SpeechAudioFormat { DISPID_SAFType = 1, DISPID_SAFGuid, DISPID_SAFGetWaveFormatEx, DISPID_SAFSetWaveFormatEx, }} ENUM!{enum DISPID_SpeechBaseStream { DISPID_SBSFormat = 1, DISPID_SBSRead, DISPID_SBSWrite, DISPID_SBSSeek, }} ENUM!{enum SpeechStreamSeekPositionType { SSSPTRelativeToStart = ::STREAM_SEEK_SET.0, SSSPTRelativeToCurrentPosition = ::STREAM_SEEK_CUR.0, SSSPTRelativeToEnd = ::STREAM_SEEK_END.0, }} ENUM!{enum DISPID_SpeechAudio { DISPID_SAStatus = 200, DISPID_SABufferInfo, DISPID_SADefaultFormat, DISPID_SAVolume, DISPID_SABufferNotifySize, DISPID_SAEventHandle, DISPID_SASetState, }} ENUM!{enum SpeechAudioState { SASClosed = SPAS_CLOSED.0, SASStop = SPAS_STOP.0, SASPause = SPAS_PAUSE.0, SASRun = SPAS_RUN.0, }} ENUM!{enum DISPID_SpeechMMSysAudio { DISPID_SMSADeviceId = 300, DISPID_SMSALineId, DISPID_SMSAMMHandle, }} ENUM!{enum DISPID_SpeechFileStream { DISPID_SFSOpen = 100, DISPID_SFSClose, }} ENUM!{enum SpeechStreamFileMode { SSFMOpenForRead = SPFM_OPEN_READONLY.0, SSFMOpenReadWrite = SPFM_OPEN_READWRITE.0, SSFMCreate = SPFM_CREATE.0, SSFMCreateForWrite = SPFM_CREATE_ALWAYS.0, }} ENUM!{enum DISPID_SpeechCustomStream { DISPID_SCSBaseStream = 100, }} ENUM!{enum DISPID_SpeechMemoryStream { DISPID_SMSSetData = 100, DISPID_SMSGetData, }} ENUM!{enum DISPID_SpeechAudioStatus { DISPID_SASFreeBufferSpace = 1, DISPID_SASNonBlockingIO, DISPID_SASState, DISPID_SASCurrentSeekPosition, DISPID_SASCurrentDevicePosition, }} ENUM!{enum DISPID_SpeechAudioBufferInfo { DISPID_SABIMinNotification = 1, DISPID_SABIBufferSize, DISPID_SABIEventBias, }} ENUM!{enum DISPID_SpeechWaveFormatEx { DISPID_SWFEFormatTag = 1, DISPID_SWFEChannels, DISPID_SWFESamplesPerSec, DISPID_SWFEAvgBytesPerSec, DISPID_SWFEBlockAlign, DISPID_SWFEBitsPerSample, DISPID_SWFEExtraData, }} ENUM!{enum DISPID_SpeechVoice { DISPID_SVStatus = 1, DISPID_SVVoice, DISPID_SVAudioOutput, DISPID_SVAudioOutputStream, DISPID_SVRate, DISPID_SVVolume, DISPID_SVAllowAudioOuputFormatChangesOnNextSet, DISPID_SVEventInterests, DISPID_SVPriority, DISPID_SVAlertBoundary, DISPID_SVSyncronousSpeakTimeout, DISPID_SVSpeak, DISPID_SVSpeakStream, DISPID_SVPause, DISPID_SVResume, DISPID_SVSkip, DISPID_SVGetVoices, DISPID_SVGetAudioOutputs, DISPID_SVWaitUntilDone, DISPID_SVSpeakCompleteEvent, DISPID_SVIsUISupported, DISPID_SVDisplayUI, }} ENUM!{enum SpeechVoicePriority { SVPNormal = SPVPRI_NORMAL.0, SVPAlert = SPVPRI_ALERT.0, SVPOver = SPVPRI_OVER.0, }} FLAGS!{enum SpeechVoiceSpeakFlags { SVSFDefault = SPF_DEFAULT.0, SVSFlagsAsync = SPF_ASYNC.0, SVSFPurgeBeforeSpeak = SPF_PURGEBEFORESPEAK.0, SVSFIsFilename = SPF_IS_FILENAME.0, SVSFIsXML = SPF_IS_XML.0, SVSFIsNotXML = SPF_IS_NOT_XML.0, SVSFPersistXML = SPF_PERSIST_XML.0, SVSFNLPSpeakPunc = SPF_NLP_SPEAK_PUNC.0, SVSFParseSapi = SPF_PARSE_SAPI.0, SVSFParseSsml = SPF_PARSE_SSML.0, SVSFParseMask = SPF_PARSE_MASK as u32, SVSFVoiceMask = SPF_VOICE_MASK as u32, SVSFUnusedFlags = SPF_UNUSED_FLAGS as u32, }} pub const SVSFParseAutodetect: SpeechVoiceSpeakFlags = SVSFDefault; pub const SVSFNLPMask: SpeechVoiceSpeakFlags = SVSFNLPSpeakPunc; FLAGS!{enum SpeechVoiceEvents { SVEStartInputStream = 1 << 1, SVEEndInputStream = 1 << 2, SVEVoiceChange = 1 << 3, SVEBookmark = 1 << 4, SVEWordBoundary = 1 << 5, SVEPhoneme = 1 << 6, SVESentenceBoundary = 1 << 7, SVEViseme = 1 << 8, SVEAudioLevel = 1 << 9, SVEPrivate = 1 << 15, SVEAllEvents = 0x83fe, }} ENUM!{enum DISPID_SpeechVoiceStatus { DISPID_SVSCurrentStreamNumber = 1, DISPID_SVSLastStreamNumberQueued, DISPID_SVSLastResult, DISPID_SVSRunningState, DISPID_SVSInputWordPosition, DISPID_SVSInputWordLength, DISPID_SVSInputSentencePosition, DISPID_SVSInputSentenceLength, DISPID_SVSLastBookmark, DISPID_SVSLastBookmarkId, DISPID_SVSPhonemeId, DISPID_SVSVisemeId, }} ENUM!{enum SpeechRunState { SRSEDone = SPRS_DONE.0, SRSEIsSpeaking = SPRS_IS_SPEAKING.0, }} ENUM!{enum SpeechVisemeType { SVP_0 = 0, SVP_1, SVP_2, SVP_3, SVP_4, SVP_5, SVP_6, SVP_7, SVP_8, SVP_9, SVP_10, SVP_11, SVP_12, SVP_13, SVP_14, SVP_15, SVP_16, SVP_17, SVP_18, SVP_19, SVP_20, SVP_21, }} ENUM!{enum SpeechVisemeFeature { SVF_None = 0, SVF_Stressed = SPVFEATURE_STRESSED.0, SVF_Emphasis = SPVFEATURE_EMPHASIS.0, }} ENUM!{enum DISPID_SpeechVoiceEvent { DISPID_SVEStreamStart = 1, DISPID_SVEStreamEnd, DISPID_SVEVoiceChange, DISPID_SVEBookmark, DISPID_SVEWord, DISPID_SVEPhoneme, DISPID_SVESentenceBoundary, DISPID_SVEViseme, DISPID_SVEAudioLevel, DISPID_SVEEnginePrivate, }} ENUM!{enum DISPID_SpeechRecognizer { DISPID_SRRecognizer = 1, DISPID_SRAllowAudioInputFormatChangesOnNextSet, DISPID_SRAudioInput, DISPID_SRAudioInputStream, DISPID_SRIsShared, DISPID_SRState, DISPID_SRStatus, DISPID_SRProfile, DISPID_SREmulateRecognition, DISPID_SRCreateRecoContext, DISPID_SRGetFormat, DISPID_SRSetPropertyNumber, DISPID_SRGetPropertyNumber, DISPID_SRSetPropertyString, DISPID_SRGetPropertyString, DISPID_SRIsUISupported, DISPID_SRDisplayUI, DISPID_SRGetRecognizers, DISPID_SVGetAudioInputs, DISPID_SVGetProfiles, }} ENUM!{enum SpeechRecognizerState { SRSInactive = SPRST_INACTIVE.0, SRSActive = SPRST_ACTIVE.0, SRSActiveAlways = SPRST_ACTIVE_ALWAYS.0, SRSInactiveWithPurge = SPRST_INACTIVE_WITH_PURGE.0, }} ENUM!{enum SpeechDisplayAttributes { SDA_No_Trailing_Space = 0, SDA_One_Trailing_Space = SPAF_ONE_TRAILING_SPACE.0, SDA_Two_Trailing_Spaces = SPAF_TWO_TRAILING_SPACES.0, SDA_Consume_Leading_Spaces = SPAF_CONSUME_LEADING_SPACES.0, }} ENUM!{enum SpeechFormatType { SFTInput = SPWF_INPUT.0, SFTSREngine = SPWF_SRENGINE.0, }} FLAGS!{enum SpeechEmulationCompareFlags { SECFIgnoreCase = 0x1, SECFIgnoreKanaType = 0x10000, SECFIgnoreWidth = 0x20000, SECFNoSpecialChars = 0x20000000, SECFEmulateResult = 0x40000000, SECFDefault = SECFIgnoreCase.0 | SECFIgnoreKanaType.0 | SECFIgnoreWidth.0, }} ENUM!{enum DISPID_SpeechRecognizerStatus { DISPID_SRSAudioStatus = 1, DISPID_SRSCurrentStreamPosition, DISPID_SRSCurrentStreamNumber, DISPID_SRSNumberOfActiveRules, DISPID_SRSClsidEngine, DISPID_SRSSupportedLanguages, }} ENUM!{enum DISPID_SpeechRecoContext { DISPID_SRCRecognizer = 1, DISPID_SRCAudioInInterferenceStatus, DISPID_SRCRequestedUIType, DISPID_SRCVoice, DISPID_SRAllowVoiceFormatMatchingOnNextSet, DISPID_SRCVoicePurgeEvent, DISPID_SRCEventInterests, DISPID_SRCCmdMaxAlternates, DISPID_SRCState, DISPID_SRCRetainedAudio, DISPID_SRCRetainedAudioFormat, DISPID_SRCPause, DISPID_SRCResume, DISPID_SRCCreateGrammar, DISPID_SRCCreateResultFromMemory, DISPID_SRCBookmark, DISPID_SRCSetAdaptationData, }} ENUM!{enum SpeechRetainedAudioOptions { SRAONone = SPAO_NONE.0, SRAORetainAudio = SPAO_RETAIN_AUDIO.0, }} ENUM!{enum SpeechBookmarkOptions { SBONone = SPBO_NONE.0, SBOPause = SPBO_PAUSE.0, }} ENUM!{enum SpeechInterference { SINone = SPINTERFERENCE_NONE.0, SINoise = SPINTERFERENCE_NOISE.0, SINoSignal = SPINTERFERENCE_NOSIGNAL.0, SITooLoud = SPINTERFERENCE_TOOLOUD.0, SITooQuiet = SPINTERFERENCE_TOOQUIET.0, SITooFast = SPINTERFERENCE_TOOFAST.0, SITooSlow = SPINTERFERENCE_TOOSLOW.0, }} FLAGS!{enum SpeechRecoEvents { SREStreamEnd = 1 << 0, SRESoundStart = 1 << 1, SRESoundEnd = 1 << 2, SREPhraseStart = 1 << 3, SRERecognition = 1 << 4, SREHypothesis = 1 << 5, SREBookmark = 1 << 6, SREPropertyNumChange = 1 << 7, SREPropertyStringChange = 1 << 8, SREFalseRecognition = 1 << 9, SREInterference = 1 << 10, SRERequestUI = 1 << 11, SREStateChange = 1 << 12, SREAdaptation = 1 << 13, SREStreamStart = 1 << 14, SRERecoOtherContext = 1 << 15, SREAudioLevel = 1 << 16, SREPrivate = 1 << 18, SREAllEvents = 0x5ffff, }} ENUM!{enum SpeechRecoContextState { SRCS_Disabled = SPCS_DISABLED.0, SRCS_Enabled = SPCS_ENABLED.0, }} ENUM!{enum DISPIDSPRG { DISPID_SRGId = 1, DISPID_SRGRecoContext, DISPID_SRGState, DISPID_SRGRules, DISPID_SRGReset, DISPID_SRGCommit, DISPID_SRGCmdLoadFromFile, DISPID_SRGCmdLoadFromObject, DISPID_SRGCmdLoadFromResource, DISPID_SRGCmdLoadFromMemory, DISPID_SRGCmdLoadFromProprietaryGrammar, DISPID_SRGCmdSetRuleState, DISPID_SRGCmdSetRuleIdState, DISPID_SRGDictationLoad, DISPID_SRGDictationUnload, DISPID_SRGDictationSetState, DISPID_SRGSetWordSequenceData, DISPID_SRGSetTextSelection, DISPID_SRGIsPronounceable, }} ENUM!{enum SpeechLoadOption { SLOStatic = SPLO_STATIC.0, SLODynamic = SPLO_DYNAMIC.0, }} ENUM!{enum SpeechWordPronounceable { SWPUnknownWordUnpronounceable = SPWP_UNKNOWN_WORD_UNPRONOUNCEABLE.0, SWPUnknownWordPronounceable = SPWP_UNKNOWN_WORD_PRONOUNCEABLE.0, SWPKnownWordPronounceable = SPWP_KNOWN_WORD_PRONOUNCEABLE.0, }} ENUM!{enum SpeechGrammarState { SGSEnabled = SPGS_ENABLED.0, SGSDisabled = SPGS_DISABLED.0, SGSExclusive = SPGS_EXCLUSIVE.0, }} ENUM!{enum SpeechRuleState { SGDSInactive = SPRS_INACTIVE.0, SGDSActive = SPRS_ACTIVE.0, SGDSActiveWithAutoPause = SPRS_ACTIVE_WITH_AUTO_PAUSE.0, SGDSActiveUserDelimited = SPRS_ACTIVE_USER_DELIMITED.0, }} ENUM!{enum SpeechRuleAttributes { SRATopLevel = SPRAF_TopLevel.0, SRADefaultToActive = SPRAF_Active.0, SRAExport = SPRAF_Export.0, SRAImport = SPRAF_Import.0, SRAInterpreter = SPRAF_Interpreter.0, SRADynamic = SPRAF_Dynamic.0, SRARoot = SPRAF_Root.0, }} ENUM!{enum SpeechGrammarWordType { SGDisplay = SPWT_DISPLAY.0, SGLexical = SPWT_LEXICAL.0, SGPronounciation = SPWT_PRONUNCIATION.0, SGLexicalNoSpecialChars = SPWT_LEXICAL_NO_SPECIAL_CHARS.0, }} ENUM!{enum DISPID_SpeechRecoContextEvents { DISPID_SRCEStartStream = 1, DISPID_SRCEEndStream, DISPID_SRCEBookmark, DISPID_SRCESoundStart, DISPID_SRCESoundEnd, DISPID_SRCEPhraseStart, DISPID_SRCERecognition, DISPID_SRCEHypothesis, DISPID_SRCEPropertyNumberChange, DISPID_SRCEPropertyStringChange, DISPID_SRCEFalseRecognition, DISPID_SRCEInterference, DISPID_SRCERequestUI, DISPID_SRCERecognizerStateChange, DISPID_SRCEAdaptation, DISPID_SRCERecognitionForOtherContext, DISPID_SRCEAudioLevel, DISPID_SRCEEnginePrivate, }} ENUM!{enum SpeechRecognitionType { SRTStandard = 0, SRTAutopause = SPREF_AutoPause.0, SRTEmulated = SPREF_Emulated.0, SRTSMLTimeout = SPREF_SMLTimeout.0, SRTExtendableParse = SPREF_ExtendableParse.0, SRTReSent = SPREF_ReSent.0, }} ENUM!{enum DISPID_SpeechGrammarRule { DISPID_SGRAttributes = 1, DISPID_SGRInitialState, DISPID_SGRName, DISPID_SGRId, DISPID_SGRClear, DISPID_SGRAddResource, DISPID_SGRAddState, }} ENUM!{enum DISPID_SpeechGrammarRules { DISPID_SGRsCount = 1, DISPID_SGRsDynamic, DISPID_SGRsAdd, DISPID_SGRsCommit, DISPID_SGRsCommitAndSave, DISPID_SGRsFindRule, DISPID_SGRsItem = ::DISPID_VALUE as u32, DISPID_SGRs_NewEnum = ::DISPID_NEWENUM as u32, }} ENUM!{enum DISPID_SpeechGrammarRuleState { DISPID_SGRSRule = 1, DISPID_SGRSTransitions, DISPID_SGRSAddWordTransition, DISPID_SGRSAddRuleTransition, DISPID_SGRSAddSpecialTransition, }} ENUM!{enum SpeechSpecialTransitionType { SSTTWildcard = 1, SSTTDictation, SSTTTextBuffer, }} ENUM!{enum DISPID_SpeechGrammarRuleStateTransitions { DISPID_SGRSTsCount = 1, DISPID_SGRSTsItem = ::DISPID_VALUE as u32, DISPID_SGRSTs_NewEnum = ::DISPID_NEWENUM as u32, }} ENUM!{enum DISPID_SpeechGrammarRuleStateTransition { DISPID_SGRSTType = 1, DISPID_SGRSTText, DISPID_SGRSTRule, DISPID_SGRSTWeight, DISPID_SGRSTPropertyName, DISPID_SGRSTPropertyId, DISPID_SGRSTPropertyValue, DISPID_SGRSTNextState, }} ENUM!{enum SpeechGrammarRuleStateTransitionType { SGRSTTEpsilon = 0, SGRSTTWord, SGRSTTRule, SGRSTTDictation, SGRSTTWildcard, SGRSTTTextBuffer, }} ENUM!{enum DISPIDSPTSI { DISPIDSPTSI_ActiveOffset = 1, DISPIDSPTSI_ActiveLength, DISPIDSPTSI_SelectionOffset, DISPIDSPTSI_SelectionLength, }} ENUM!{enum DISPID_SpeechRecoResult { DISPID_SRRRecoContext = 1, DISPID_SRRTimes, DISPID_SRRAudioFormat, DISPID_SRRPhraseInfo, DISPID_SRRAlternates, DISPID_SRRAudio, DISPID_SRRSpeakAudio, DISPID_SRRSaveToMemory, DISPID_SRRDiscardResultInfo, }} ENUM!{enum SpeechDiscardType { SDTProperty = SPDF_PROPERTY.0, SDTReplacement = SPDF_REPLACEMENT.0, SDTRule = SPDF_RULE.0, SDTDisplayText = SPDF_DISPLAYTEXT.0, SDTLexicalForm = SPDF_LEXICALFORM.0, SDTPronunciation = SPDF_PRONUNCIATION.0, SDTAudio = SPDF_AUDIO.0, SDTAlternates = SPDF_ALTERNATES.0, SDTAll = SPDF_ALL.0, }} ENUM!{enum DISPID_SpeechXMLRecoResult { DISPID_SRRGetXMLResult, DISPID_SRRGetXMLErrorInfo, }} ENUM!{enum DISPID_SpeechRecoResult2 { DISPID_SRRSetTextFeedback, }} ENUM!{enum DISPID_SpeechPhraseBuilder { DISPID_SPPBRestorePhraseFromMemory = 1, }} ENUM!{enum DISPID_SpeechRecoResultTimes { DISPID_SRRTStreamTime = 1, DISPID_SRRTLength, DISPID_SRRTTickCount, DISPID_SRRTOffsetFromStart, }} ENUM!{enum DISPID_SpeechPhraseAlternate { DISPID_SPARecoResult = 1, DISPID_SPAStartElementInResult, DISPID_SPANumberOfElementsInResult, DISPID_SPAPhraseInfo, DISPID_SPACommit, }} ENUM!{enum DISPID_SpeechPhraseAlternates { DISPID_SPAsCount = 1, DISPID_SPAsItem = ::DISPID_VALUE as u32, DISPID_SPAs_NewEnum = ::DISPID_NEWENUM as u32, }} ENUM!{enum DISPID_SpeechPhraseInfo { DISPID_SPILanguageId = 1, DISPID_SPIGrammarId, DISPID_SPIStartTime, DISPID_SPIAudioStreamPosition, DISPID_SPIAudioSizeBytes, DISPID_SPIRetainedSizeBytes, DISPID_SPIAudioSizeTime, DISPID_SPIRule, DISPID_SPIProperties, DISPID_SPIElements, DISPID_SPIReplacements, DISPID_SPIEngineId, DISPID_SPIEnginePrivateData, DISPID_SPISaveToMemory, DISPID_SPIGetText, DISPID_SPIGetDisplayAttributes, }} ENUM!{enum DISPID_SpeechPhraseElement { DISPID_SPEAudioTimeOffset = 1, DISPID_SPEAudioSizeTime, DISPID_SPEAudioStreamOffset, DISPID_SPEAudioSizeBytes, DISPID_SPERetainedStreamOffset, DISPID_SPERetainedSizeBytes, DISPID_SPEDisplayText, DISPID_SPELexicalForm, DISPID_SPEPronunciation, DISPID_SPEDisplayAttributes, DISPID_SPERequiredConfidence, DISPID_SPEActualConfidence, DISPID_SPEEngineConfidence, }} ENUM!{enum SpeechEngineConfidence { SECLowConfidence = -1i32 as u32, SECNormalConfidence = 0, SECHighConfidence = 1, }} ENUM!{enum DISPID_SpeechPhraseElements { DISPID_SPEsCount = 1, DISPID_SPEsItem = ::DISPID_VALUE as u32, DISPID_SPEs_NewEnum = ::DISPID_NEWENUM as u32, }} ENUM!{enum DISPID_SpeechPhraseReplacement { DISPID_SPRDisplayAttributes = 1, DISPID_SPRText, DISPID_SPRFirstElement, DISPID_SPRNumberOfElements, }} ENUM!{enum DISPID_SpeechPhraseReplacements { DISPID_SPRsCount = 1, DISPID_SPRsItem = ::DISPID_VALUE as u32, DISPID_SPRs_NewEnum = ::DISPID_NEWENUM as u32, }} ENUM!{enum DISPID_SpeechPhraseProperty { DISPID_SPPName = 1, DISPID_SPPId, DISPID_SPPValue, DISPID_SPPFirstElement, DISPID_SPPNumberOfElements, DISPID_SPPEngineConfidence, DISPID_SPPConfidence, DISPID_SPPParent, DISPID_SPPChildren, }} ENUM!{enum DISPID_SpeechPhraseProperties { DISPID_SPPsCount = 1, DISPID_SPPsItem = ::DISPID_VALUE as u32, DISPID_SPPs_NewEnum = ::DISPID_NEWENUM as u32, }} ENUM!{enum DISPID_SpeechPhraseRule { DISPID_SPRuleName = 1, DISPID_SPRuleId, DISPID_SPRuleFirstElement, DISPID_SPRuleNumberOfElements, DISPID_SPRuleParent, DISPID_SPRuleChildren, DISPID_SPRuleConfidence, DISPID_SPRuleEngineConfidence, }} ENUM!{enum DISPID_SpeechPhraseRules { DISPID_SPRulesCount = 1, DISPID_SPRulesItem = ::DISPID_VALUE as u32, DISPID_SPRules_NewEnum = ::DISPID_NEWENUM as u32, }} ENUM!{enum DISPID_SpeechLexicon { DISPID_SLGenerationId = 1, DISPID_SLGetWords, DISPID_SLAddPronunciation, DISPID_SLAddPronunciationByPhoneIds, DISPID_SLRemovePronunciation, DISPID_SLRemovePronunciationByPhoneIds, DISPID_SLGetPronunciations, DISPID_SLGetGenerationChange, }} ENUM!{enum SpeechLexiconType { SLTUser = eLEXTYPE_USER.0, SLTApp = eLEXTYPE_APP.0, }} ENUM!{enum SpeechPartOfSpeech { SPSNotOverriden = SPPS_NotOverriden.0, SPSUnknown = SPPS_Unknown.0, SPSNoun = SPPS_Noun.0, SPSVerb = SPPS_Verb.0, SPSModifier = SPPS_Modifier.0, SPSFunction = SPPS_Function.0, SPSInterjection = SPPS_Interjection.0, SPSLMA = SPPS_LMA.0, SPSSuppressWord = SPPS_SuppressWord.0, }} ENUM!{enum DISPID_SpeechLexiconWords { DISPID_SLWsCount = 1, DISPID_SLWsItem = ::DISPID_VALUE as u32, DISPID_SLWs_NewEnum = ::DISPID_NEWENUM as u32, }} ENUM!{enum SpeechWordType { SWTAdded = eWORDTYPE_ADDED.0, SWTDeleted = eWORDTYPE_DELETED.0, }} ENUM!{enum DISPID_SpeechLexiconWord { DISPID_SLWLangId = 1, DISPID_SLWType, DISPID_SLWWord, DISPID_SLWPronunciations, }} ENUM!{enum DISPID_SpeechLexiconProns { DISPID_SLPsCount = 1, DISPID_SLPsItem = ::DISPID_VALUE as u32, DISPID_SLPs_NewEnum = ::DISPID_NEWENUM as u32, }} ENUM!{enum DISPID_SpeechLexiconPronunciation { DISPID_SLPType = 1, DISPID_SLPLangId, DISPID_SLPPartOfSpeech, DISPID_SLPPhoneIds, DISPID_SLPSymbolic, }} ENUM!{enum DISPID_SpeechPhoneConverter { DISPID_SPCLangId = 1, DISPID_SPCPhoneToId, DISPID_SPCIdToPhone, }} RIDL!( interface ISpeechDataKey(ISpeechDataKeyVtbl): IDispatch(IDispatchVtbl) { fn SetBinaryValue(&mut self, ValueName: ::BSTR, Value: ::VARIANT) -> ::HRESULT, fn GetBinaryValue(&mut self, ValueName: ::BSTR, Value: *mut ::VARIANT) -> ::HRESULT, fn SetStringValue(&mut self, ValueName: ::BSTR, Value: ::BSTR) -> ::HRESULT, fn GetStringValue(&mut self, ValueName: ::BSTR, Value: *mut ::BSTR) -> ::HRESULT, fn SetLongValue(&mut self, ValueName: ::BSTR, Value: ::c_long) -> ::HRESULT, fn GetLongValue(&mut self, ValueName: ::BSTR, Value: *mut ::c_long) -> ::HRESULT, fn OpenKey(&mut self, SubKeyName: ::BSTR, SubKey: *mut *mut ISpeechDataKey) -> ::HRESULT, fn CreateKey(&mut self, SubKeyName: ::BSTR, SubKey: *mut *mut ISpeechDataKey) -> ::HRESULT, fn DeleteKey(&mut self, SubKeyName: ::BSTR) -> ::HRESULT, fn DeleteValue(&mut self, ValueName: ::BSTR) -> ::HRESULT, fn EnumKeys(&mut self, Index: ::c_long, SubKeyName: *mut ::BSTR) -> ::HRESULT, fn EnumValues(&mut self, Index: ::c_long, ValueName: *mut ::BSTR) -> ::HRESULT } ); RIDL!( interface ISpeechObjectToken(ISpeechObjectTokenVtbl): IDispatch(IDispatchVtbl) { fn get_Id(&mut self, ObjectId: *mut ::BSTR) -> ::HRESULT, fn get_DataKey(&mut self, DataKey: *mut *mut ISpeechDataKey) -> ::HRESULT, fn get_Category(&mut self, Category: *mut *mut ISpeechObjectTokenCategory) -> ::HRESULT, fn GetDescription(&mut self, Locale: ::c_long, Description: *mut ::BSTR) -> ::HRESULT, fn SetId( &mut self, Id: ::BSTR, CategoryId: ::BSTR, CreateIfNotExist: ::VARIANT_BOOL ) -> ::HRESULT, fn GetAttribute(&mut self, AttributeName: ::BSTR, AttributeValue: *mut ::BSTR) -> ::HRESULT, fn CreateInstance( &mut self, pUnkOuter: *mut ::IUnknown, ClsContext: SpeechTokenContext, Object: *mut *mut ::IUnknown ) -> ::HRESULT, fn Remove(&mut self, ObjectStorageCLSID: ::BSTR) -> ::HRESULT, fn GetStorageFileName( &mut self, ObjectStorageCLSID: ::BSTR, KeyName: ::BSTR, FileName: ::BSTR, Folder: ::BSTR, FilePath: *mut ::BSTR ) -> ::HRESULT, fn RemoveStorageFileName( &mut self, ObjectStorageCLSID: ::BSTR, KeyName: ::BSTR, DeleteFile: ::VARIANT_BOOL ) -> ::HRESULT, fn IsUISupported( &mut self, TypeOfUI: ::BSTR, ExtraData: *const ::VARIANT, Object: *mut ::IUnknown, Supported: *mut ::VARIANT_BOOL ) -> ::HRESULT, fn DisplayUI( &mut self, hWnd: ::c_long, Title: ::BSTR, TypeOfUI: ::BSTR, ExtraData: *const ::VARIANT, Object: *mut ::IUnknown ) -> ::HRESULT, fn MatchesAttributes(&mut self, Attributes: ::BSTR, Matches: *mut ::VARIANT_BOOL) -> ::HRESULT } ); RIDL!( interface ISpeechObjectTokens(ISpeechObjectTokensVtbl): IDispatch(IDispatchVtbl) { fn get_Count(&mut self, Count: *mut ::c_long) -> ::HRESULT, fn Item(&mut self, Index: ::c_long, Token: *mut *mut ISpeechObjectToken) -> ::HRESULT, fn get__NewEnum(&mut self, ppEnumVARIANT: *mut *mut ::IUnknown) -> ::HRESULT } ); RIDL!( interface ISpeechObjectTokenCategory(ISpeechObjectTokenCategoryVtbl): IDispatch(IDispatchVtbl) { fn get_Id(&mut self, Id: *mut ::BSTR) -> ::HRESULT, fn put_Default(&mut self, TokenId: ::BSTR) -> ::HRESULT, fn get_Default(&mut self, TokenId: *mut ::BSTR) -> ::HRESULT, fn SetId(&mut self, Id: ::BSTR, CreateIfNotExist: ::VARIANT_BOOL) -> ::HRESULT, fn GetDataKey( &mut self, Location: SpeechDataKeyLocation, DataKey: *mut *mut ISpeechDataKey ) -> ::HRESULT, fn EnumerateTokens( &mut self, RequiredAttributes: ::BSTR, OptionalAttributes: ::BSTR, Tokens: *mut *mut ISpeechObjectTokens ) -> ::HRESULT } ); RIDL!( interface ISpeechAudioBufferInfo(ISpeechAudioBufferInfoVtbl): IDispatch(IDispatchVtbl) { fn get_MinNotification(&mut self, MinNotification: *mut ::c_long) -> ::HRESULT, fn put_MinNotification(&mut self, MinNotification: ::c_long) -> ::HRESULT, fn get_BufferSize(&mut self, BufferSize: *mut ::c_long) -> ::HRESULT, fn put_BufferSize(&mut self, BufferSize: ::c_long) -> ::HRESULT, fn get_EventBias(&mut self, EventBias: *mut ::c_long) -> ::HRESULT, fn put_EventBias(&mut self, EventBias: ::c_long) -> ::HRESULT } ); RIDL!( interface ISpeechAudioStatus(ISpeechAudioStatusVtbl): IDispatch(IDispatchVtbl) { fn get_FreeBufferSpace(&mut self, FreeBufferSpace: *mut ::c_long) -> ::HRESULT, fn get_NonBlockingIO(&mut self, NonBlockingIO: *mut ::c_long) -> ::HRESULT, fn get_State(&mut self, State: *mut SpeechAudioState) -> ::HRESULT, fn get_CurrentSeekPosition(&mut self, CurrentSeekPosition: *mut ::VARIANT) -> ::HRESULT, fn get_CurrentDevicePosition(&mut self, CurrentDevicePosition: *mut ::VARIANT) -> ::HRESULT } ); RIDL!( interface ISpeechAudioFormat(ISpeechAudioFormatVtbl): IDispatch(IDispatchVtbl) { fn get_Type(&mut self, AudioFormat: *mut SpeechAudioFormatType) -> ::HRESULT, fn put_Type(&mut self, AudioFormat: SpeechAudioFormatType) -> ::HRESULT, fn get_Guid(&mut self, Guid: *mut ::BSTR) -> ::HRESULT, fn put_Guid(&mut self, Guid: ::BSTR) -> ::HRESULT, fn GetWaveFormatEx(&mut self, SpeechWaveFormatEx: *mut *mut ISpeechWaveFormatEx) -> ::HRESULT, fn SetWaveFormatEx(&mut self, SpeechWaveFormatEx: *mut ISpeechWaveFormatEx) -> ::HRESULT } ); RIDL!( interface ISpeechWaveFormatEx(ISpeechWaveFormatExVtbl): IDispatch(IDispatchVtbl) { fn get_FormatTag(&mut self, FormatTag: *mut ::c_short) -> ::HRESULT, fn put_FormatTag(&mut self, FormatTag: ::c_short) -> ::HRESULT, fn get_Channels(&mut self, Channels: *mut ::c_short) -> ::HRESULT, fn put_Channels(&mut self, Channels: ::c_short) -> ::HRESULT, fn get_SamplesPerSec(&mut self, SamplesPerSec: *mut ::c_long) -> ::HRESULT, fn put_SamplesPerSec(&mut self, SamplesPerSec: ::c_long) -> ::HRESULT, fn get_AvgBytesPerSec(&mut self, AvgBytesPerSec: *mut ::c_long) -> ::HRESULT, fn put_AvgBytesPerSec(&mut self, AvgBytesPerSec: ::c_long) -> ::HRESULT, fn get_BlockAlign(&mut self, BlockAlign: *mut ::c_short) -> ::HRESULT, fn put_BlockAlign(&mut self, BlockAlign: ::c_short) -> ::HRESULT, fn get_BitsPerSample(&mut self, BitsPerSample: *mut ::c_short) -> ::HRESULT, fn put_BitsPerSample(&mut self, BitsPerSample: ::c_short) -> ::HRESULT, fn get_ExtraData(&mut self, ExtraData: *mut ::VARIANT) -> ::HRESULT, fn put_ExtraData(&mut self, ExtraData: ::VARIANT) -> ::HRESULT } ); deps/winapi-0.2.5/src/dxgi1_2.rs0000644000000000000000000002700612617171043015037 0ustar rootroot// Copyright © 2015; Dmitry Roschin // Licensed under the MIT License //! Mappings for the contents of dxgi1_2.h ENUM!{ enum DXGI_ALPHA_MODE { DXGI_ALPHA_MODE_UNSPECIFIED = 0, DXGI_ALPHA_MODE_PREMULTIPLIED = 1, DXGI_ALPHA_MODE_STRAIGHT = 2, DXGI_ALPHA_MODE_IGNORE = 3, DXGI_ALPHA_MODE_FORCE_DWORD = 0xFFFFFFFF, }} ENUM!{ enum DXGI_COMPUTE_PREEMPTION_GRANULARITY { DXGI_COMPUTE_PREEMPTION_DMA_BUFFER_BOUNDARY = 0, DXGI_COMPUTE_PREEMPTION_DISPATCH_BOUNDARY = 1, DXGI_COMPUTE_PREEMPTION_THREAD_GROUP_BOUNDARY = 2, DXGI_COMPUTE_PREEMPTION_THREAD_BOUNDARY = 3, DXGI_COMPUTE_PREEMPTION_INSTRUCTION_BOUNDARY = 4, }} ENUM!{ enum DXGI_GRAPHICS_PREEMPTION_GRANULARITY { DXGI_GRAPHICS_PREEMPTION_DMA_BUFFER_BOUNDARY = 0, DXGI_GRAPHICS_PREEMPTION_PRIMITIVE_BOUNDARY = 1, DXGI_GRAPHICS_PREEMPTION_TRIANGLE_BOUNDARY = 2, DXGI_GRAPHICS_PREEMPTION_PIXEL_BOUNDARY = 3, DXGI_GRAPHICS_PREEMPTION_INSTRUCTION_BOUNDARY = 4, }} ENUM!{ enum DXGI_OUTDUPL_POINTER_SHAPE_TYPE { DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MONOCHROME = 1, DXGI_OUTDUPL_POINTER_SHAPE_TYPE_COLOR = 2, DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MASKED_COLOR = 4, }} ENUM!{ enum DXGI_SCALING { DXGI_SCALING_STRETCH = 0, DXGI_SCALING_NONE = 1, DXGI_SCALING_ASPECT_RATIO_STRETCH = 2, }} ENUM!{ enum _DXGI_OFFER_RESOURCE_PRIORITY { DXGI_OFFER_RESOURCE_PRIORITY_LOW = 1, DXGI_OFFER_RESOURCE_PRIORITY_NORMAL = 2, DXGI_OFFER_RESOURCE_PRIORITY_HIGH = 3, }} #[repr(C)] #[derive(Copy)] pub struct DXGI_ADAPTER_DESC2 { pub Description: [::WCHAR; 128], pub VendorId: ::UINT, pub DeviceId: ::UINT, pub SubSysId: ::UINT, pub Revision: ::UINT, pub DedicatedVideoMemory: ::SIZE_T, pub DedicatedSystemMemory: ::SIZE_T, pub SharedSystemMemory: ::SIZE_T, pub AdapterLuid: ::LUID, pub Flags: ::UINT, pub GraphicsPreemptionGranularity: ::DXGI_GRAPHICS_PREEMPTION_GRANULARITY, pub ComputePreemptionGranularity: ::DXGI_COMPUTE_PREEMPTION_GRANULARITY, } impl Clone for DXGI_ADAPTER_DESC2 { fn clone(&self) -> Self { *self } } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct DXGI_MODE_DESC1 { pub Width: ::UINT, pub Height: ::UINT, pub RefreshRate: ::DXGI_RATIONAL, pub Format: ::DXGI_FORMAT, pub ScanlineOrdering: ::DXGI_MODE_SCANLINE_ORDER, pub Scaling: ::DXGI_MODE_SCALING, pub Stereo: ::BOOL, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct DXGI_OUTDUPL_DESC { pub ModeDesc: ::DXGI_MODE_DESC, pub Rotation: ::DXGI_MODE_ROTATION, pub DesktopImageInSystemMemory: ::BOOL, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct DXGI_OUTDUPL_FRAME_INFO { pub LastPresentTime: ::LARGE_INTEGER, pub LastMouseUpdateTime: ::LARGE_INTEGER, pub AccumulatedFrames: ::UINT, pub RectsCoalesced: ::BOOL, pub ProtectedContentMaskedOut: ::BOOL, pub PointerPosition: ::DXGI_OUTDUPL_POINTER_POSITION, pub TotalMetadataBufferSize: ::UINT, pub PointerShapeBufferSize: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct DXGI_OUTDUPL_MOVE_RECT { pub SourcePoint: ::POINT, pub DestinationRect: ::RECT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct DXGI_OUTDUPL_POINTER_POSITION { pub Position: ::POINT, pub Visible: ::BOOL, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct DXGI_OUTDUPL_POINTER_SHAPE_INFO { pub Type: ::UINT, pub Width: ::UINT, pub Height: ::UINT, pub Pitch: ::UINT, pub HotSpot: ::POINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct DXGI_PRESENT_PARAMETERS { pub DirtyRectsCount: ::UINT, pub pDirtyRects: *mut ::RECT, pub pScrollRect: *mut ::RECT, pub pScrollOffset: *mut ::POINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct DXGI_SWAP_CHAIN_DESC1 { pub Width: ::UINT, pub Height: ::UINT, pub Format: ::DXGI_FORMAT, pub Stereo: ::BOOL, pub SampleDesc: ::DXGI_SAMPLE_DESC, pub BufferUsage: ::DXGI_USAGE, pub BufferCount: ::UINT, pub Scaling: ::DXGI_SCALING, pub SwapEffect: ::DXGI_SWAP_EFFECT, pub AlphaMode: ::DXGI_ALPHA_MODE, pub Flags: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct DXGI_SWAP_CHAIN_FULLSCREEN_DESC { pub RefreshRate: ::DXGI_RATIONAL, pub ScanlineOrdering: ::DXGI_MODE_SCANLINE_ORDER, pub Scaling: ::DXGI_MODE_SCALING, pub Windowed: ::BOOL, } RIDL!( interface IDXGIAdapter2(IDXGIAdapter2Vtbl): IDXGIAdapter1(IDXGIAdapter1Vtbl) { fn GetDesc2(&mut self, pDesc: *mut ::DXGI_ADAPTER_DESC2) -> ::HRESULT }); RIDL!( interface IDXGIDevice2(IDXGIDevice2Vtbl): IDXGIDevice1(IDXGIDevice1Vtbl) { fn OfferResources( &mut self, NumResources: ::UINT, ppResources: *mut *mut ::IDXGIResource, Priority: ::DXGI_OFFER_RESOURCE_PRIORITY ) -> ::HRESULT, fn ReclaimResources( &mut self, NumResources: ::UINT, ppResources: *mut *mut ::IDXGIResource, pDiscarded: *mut ::BOOL ) -> ::HRESULT, fn EnqueueSetEvent(&mut self, hEvent: ::HANDLE) -> ::HRESULT }); RIDL!( interface IDXGIDisplayControl(IDXGIDisplayControlVtbl): IUnknown(IUnknownVtbl) { fn IsStereoEnabled(&mut self) -> ::BOOL, fn SetStereoEnabled(&mut self, enabled: ::BOOL) -> () }); RIDL!( interface IDXGIFactory2(IDXGIFactory2Vtbl): IDXGIFactory1(IDXGIFactory1Vtbl) { fn IsWindowedStereoEnabled(&mut self) -> ::BOOL, fn CreateSwapChainForHwnd( &mut self, pDevice: *mut ::IUnknown, hWnd: ::HWND, pDesc: *const ::DXGI_SWAP_CHAIN_DESC1, pFullscreenDesc: *const ::DXGI_SWAP_CHAIN_FULLSCREEN_DESC, pRestrictToOutput: *mut ::IDXGIOutput, ppSwapChain: *mut *mut ::IDXGISwapChain1 ) -> ::HRESULT, fn CreateSwapChainForCoreWindow( &mut self, pDevice: *mut ::IUnknown, pWindow: *mut ::IUnknown, pDesc: *const ::DXGI_SWAP_CHAIN_DESC1, pRestrictToOutput: *mut ::IDXGIOutput, ppSwapChain: *mut *mut ::IDXGISwapChain1 ) -> ::HRESULT, fn GetSharedResourceAdapterLuid( &mut self, hResource: ::HANDLE, pLuid: *mut ::LUID ) -> ::HRESULT, fn RegisterStereoStatusWindow( &mut self, WindowHandle: ::HWND, wMsg: ::UINT, pdwCookie: *mut ::DWORD ) -> ::HRESULT, fn RegisterStereoStatusEvent( &mut self, hEvent: ::HANDLE, pdwCookie: *mut ::DWORD ) -> ::HRESULT, fn UnregisterStereoStatus(&mut self, dwCookie: ::DWORD) -> (), fn RegisterOcclusionStatusWindow( &mut self, WindowHandle: ::HWND, wMsg: ::UINT, pdwCookie: *mut ::DWORD ) -> ::HRESULT, fn RegisterOcclusionStatusEvent( &mut self, hEvent: ::HANDLE, pdwCookie: *mut ::DWORD ) -> ::HRESULT, fn UnregisterOcclusionStatus(&mut self, dwCookie: ::DWORD) -> (), fn CreateSwapChainForComposition( &mut self, pDevice: *mut ::IUnknown, pDesc: *const ::DXGI_SWAP_CHAIN_DESC1, pRestrictToOutput: *mut ::IDXGIOutput, ppSwapChain: *mut *mut ::IDXGISwapChain1 ) -> ::HRESULT }); RIDL!( interface IDXGIOutput1(IDXGIOutput1Vtbl): IDXGIOutput(IDXGIOutputVtbl) { fn GetDisplayModeList1( &mut self, EnumFormat: ::DXGI_FORMAT, Flags: ::UINT, pNumModes: *mut ::UINT, pDesc: *mut ::DXGI_MODE_DESC1 ) -> ::HRESULT, fn FindClosestMatchingMode1( &mut self, pModeToMatch: *const ::DXGI_MODE_DESC1, pClosestMatch: *mut ::DXGI_MODE_DESC1, pConcernedDevice: *mut ::IUnknown ) -> ::HRESULT, fn GetDisplaySurfaceData1( &mut self, pDestination: *mut ::IDXGIResource ) -> ::HRESULT, fn DuplicateOutput( &mut self, pDevice: *mut ::IUnknown, ppOutputDuplication: *mut *mut ::IDXGIOutputDuplication ) -> ::HRESULT }); RIDL!( interface IDXGIOutputDuplication(IDXGIOutputDuplicationVtbl): IDXGIObject(IDXGIObjectVtbl) { fn GetDesc(&mut self, pDesc: *mut ::DXGI_OUTDUPL_DESC) -> (), fn AcquireNextFrame( &mut self, TimeoutInMilliseconds: ::UINT, pFrameInfo: *mut ::DXGI_OUTDUPL_FRAME_INFO, ppDesktopResource: *mut *mut ::IDXGIResource ) -> ::HRESULT, fn GetFrameDirtyRects( &mut self, DirtyRectsBufferSize: ::UINT, pDirtyRectsBuffer: *mut ::RECT, pDirtyRectsBufferSizeRequired: *mut ::UINT ) -> ::HRESULT, fn GetFrameMoveRects( &mut self, MoveRectsBufferSize: ::UINT, pMoveRectBuffer: *mut ::DXGI_OUTDUPL_MOVE_RECT, pMoveRectsBufferSizeRequired: *mut ::UINT ) -> ::HRESULT, fn GetFramePointerShape( &mut self, PointerShapeBufferSize: ::UINT, pPointerShapeBuffer: *mut ::c_void, pPointerShapeBufferSizeRequired: *mut ::UINT, pPointerShapeInfo: *mut ::DXGI_OUTDUPL_POINTER_SHAPE_INFO ) -> ::HRESULT, fn MapDesktopSurface( &mut self, pLockedRect: *mut ::DXGI_MAPPED_RECT ) -> ::HRESULT, fn UnMapDesktopSurface(&mut self) -> ::HRESULT, fn ReleaseFrame(&mut self) -> ::HRESULT }); RIDL!( interface IDXGIResource1(IDXGIResource1Vtbl): IDXGIResource(IDXGIResourceVtbl) { fn CreateSubresourceSurface( &mut self, index: ::UINT, ppSurface: *mut *mut ::IDXGISurface2 ) -> ::HRESULT, fn CreateSharedHandle( &mut self, pAttributes: *const ::SECURITY_ATTRIBUTES, dwAccess: ::DWORD, lpName: ::LPCWSTR, pHandle: *mut ::HANDLE ) -> ::HRESULT }); RIDL!( interface IDXGISurface2(IDXGISurface2Vtbl): IDXGISurface1(IDXGISurface1Vtbl) { fn GetResource( &mut self, riid: ::REFGUID, ppParentResource: *mut *mut ::c_void, pSubresourceIndex: *mut ::UINT ) -> ::HRESULT }); RIDL!( interface IDXGISwapChain1(IDXGISwapChain1Vtbl): IDXGISwapChain(IDXGISwapChainVtbl) { fn GetDesc1(&mut self, pDesc: *mut ::DXGI_SWAP_CHAIN_DESC1) -> ::HRESULT, fn GetFullscreenDesc( &mut self, pDesc: *mut ::DXGI_SWAP_CHAIN_FULLSCREEN_DESC ) -> ::HRESULT, fn GetHwnd(&mut self, pHwnd: *mut ::HWND) -> ::HRESULT, fn GetCoreWindow( &mut self, refiid: ::REFGUID, ppUnk: *mut *mut ::c_void ) -> ::HRESULT, fn Present1( &mut self, SyncInterval: ::UINT, PresentFlags: ::UINT, pPresentParameters: *const ::DXGI_PRESENT_PARAMETERS ) -> ::HRESULT, fn IsTemporaryMonoSupported(&mut self) -> ::BOOL, fn GetRestrictToOutput( &mut self, ppRestrictToOutput: *mut *mut ::IDXGIOutput ) -> ::HRESULT, fn SetBackgroundColor(&mut self, pColor: *const ::DXGI_RGBA) -> ::HRESULT, fn GetBackgroundColor(&mut self, pColor: *mut ::DXGI_RGBA) -> ::HRESULT, fn SetRotation(&mut self, Rotation: ::DXGI_MODE_ROTATION) -> ::HRESULT, fn GetRotation(&mut self, pRotation: *mut ::DXGI_MODE_ROTATION) -> ::HRESULT }); pub type DXGI_OFFER_RESOURCE_PRIORITY = ::_DXGI_OFFER_RESOURCE_PRIORITY; pub const DXGI_ENUM_MODES_DISABLED_STEREO: ::UINT = 8; pub const DXGI_ENUM_MODES_STEREO: ::UINT = 4; pub const DXGI_SHARED_RESOURCE_READ: ::UINT = 0x80000000; pub const DXGI_SHARED_RESOURCE_WRITE: ::UINT = 1; DEFINE_GUID!(IID_IDXGIDisplayControl,0xea9dbf1a,0xc88e,0x4486,0x85,0x4a,0x98, 0xaa,0x01,0x38,0xf3,0x0c); DEFINE_GUID!(IID_IDXGIOutputDuplication,0x191cfac3,0xa341,0x470d,0xb2,0x6e, 0xa8,0x64,0xf4,0x28,0x31,0x9c); DEFINE_GUID!(IID_IDXGISurface2,0xaba496dd,0xb617,0x4cb8,0xa8,0x66,0xbc,0x44, 0xd7,0xeb,0x1f,0xa2); DEFINE_GUID!(IID_IDXGIResource1,0x30961379,0x4609,0x4a41,0x99,0x8e,0x54,0xfe, 0x56,0x7e,0xe0,0xc1); DEFINE_GUID!(IID_IDXGIDevice2,0x05008617,0xfbfd,0x4051,0xa7,0x90,0x14,0x48, 0x84,0xb4,0xf6,0xa9); DEFINE_GUID!(IID_IDXGISwapChain1,0x790a45f7,0x0d42,0x4876,0x98,0x3a,0x0a,0x55, 0xcf,0xe6,0xf4,0xaa); DEFINE_GUID!(IID_IDXGIFactory2,0x50c83a1c,0xe072,0x4c48,0x87,0xb0,0x36,0x30, 0xfa,0x36,0xa6,0xd0); DEFINE_GUID!(IID_IDXGIAdapter2,0x0AA1AE0A,0xFA0E,0x4B84,0x86,0x44,0xE0,0x5F, 0xF8,0xE5,0xAC,0xB5); DEFINE_GUID!(IID_IDXGIOutput1,0x00cddea8,0x939b,0x4b83,0xa3,0x40,0xa6,0x85, 0x22,0x66,0x66,0xcc); deps/winapi-0.2.5/src/shtypes.rs0000644000000000000000000000316312613167613015303 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! this ALWAYS GENERATED file contains the definitions for the interfaces #[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct SHITEMID { pub cb: ::USHORT, pub abID: [::BYTE; 0], } pub type LPSHITEMID = *mut SHITEMID; pub type LPCSHITEMID = *const SHITEMID; #[repr(C)] #[derive(Debug)] pub struct ITEMIDLIST { pub mkid: SHITEMID, } pub type ITEMIDLIST_RELATIVE = ITEMIDLIST; pub type ITEMID_CHILD = ITEMIDLIST; pub type ITEMIDLIST_ABSOLUTE = ITEMIDLIST; pub type LPITEMIDLIST = *mut ITEMIDLIST; pub type LPCITEMIDLIST = *const ITEMIDLIST; pub type PIDLIST_ABSOLUTE = *mut ITEMIDLIST_ABSOLUTE; pub type PCIDLIST_ABSOLUTE = *const ITEMIDLIST_ABSOLUTE; pub type PCUIDLIST_ABSOLUTE = *const ITEMIDLIST_ABSOLUTE; pub type PIDLIST_RELATIVE = *mut ITEMIDLIST_RELATIVE; pub type PCIDLIST_RELATIVE = *const ITEMIDLIST_RELATIVE; pub type PUIDLIST_RELATIVE = *mut ITEMIDLIST_RELATIVE; pub type PCUIDLIST_RELATIVE = *const ITEMIDLIST_RELATIVE; pub type PITEMID_CHILD = *mut ITEMID_CHILD; pub type PCITEMID_CHILD = *const ITEMID_CHILD; pub type PUITEMID_CHILD = *mut ITEMID_CHILD; pub type PCUITEMID_CHILD = *const ITEMID_CHILD; pub type PCUITEMID_CHILD_ARRAY = *const PCUITEMID_CHILD; pub type PCUIDLIST_RELATIVE_ARRAY = *const PCUIDLIST_RELATIVE; pub type PCIDLIST_ABSOLUTE_ARRAY = *const PCIDLIST_ABSOLUTE; pub type PCUIDLIST_ABSOLUTE_ARRAY = *const PCUIDLIST_ABSOLUTE; STRUCT!{struct COMDLG_FILTERSPEC { pszName: ::LPCWSTR, pszSpec: ::LPCWSTR, }} pub type KNOWNFOLDERID = ::GUID; pub type REFKNOWNFOLDERID = *const KNOWNFOLDERID; deps/winapi-0.2.5/src/vss.rs0000644000000000000000000002477512615662007014432 0ustar rootroot// Copyright © 2015, Brian Vincent // Licensed under the MIT License //! VSS header file ENUM!{enum VSS_OBJECT_TYPE { VSS_OBJECT_UNKNOWN = 0, VSS_OBJECT_NONE = 1, VSS_OBJECT_SNAPSHOT_SET = 2, VSS_OBJECT_SNAPSHOT = 3, VSS_OBJECT_PROVIDER = 4, VSS_OBJECT_TYPE_COUNT = 5, }} pub type PVSS_OBJECT_TYPE = *mut VSS_OBJECT_TYPE; ENUM!{enum VSS_SNAPSHOT_STATE { VSS_SS_UNKNOWN = 0x00, VSS_SS_PREPARING = 0x01, VSS_SS_PROCESSING_PREPARE = 0x02, VSS_SS_PREPARED = 0x03, VSS_SS_PROCESSING_PRECOMMIT = 0x04, VSS_SS_PRECOMMITTED = 0x05, VSS_SS_PROCESSING_COMMIT = 0x06, VSS_SS_COMMITTED = 0x07, VSS_SS_PROCESSING_POSTCOMMIT = 0x08, VSS_SS_PROCESSING_PREFINALCOMMIT = 0x09, VSS_SS_PREFINALCOMMITTED = 0x0a, VSS_SS_PROCESSING_POSTFINALCOMMIT = 0x0b, VSS_SS_CREATED = 0x0c, VSS_SS_ABORTED = 0x0d, VSS_SS_DELETED = 0x0e, VSS_SS_POSTCOMMITTED = 0x0f, VSS_SS_COUNT = 0x10, }} pub type PVSS_SNAPSHOT_STATE = *mut VSS_SNAPSHOT_STATE; pub type VSS_VOLUME_SNAPSHOT_ATTRIBUTES = ::LONG; pub const VSS_VOLSNAP_ATTR_PERSISTENT: ::LONG = 0x00000001; pub const VSS_VOLSNAP_ATTR_NO_AUTORECOVERY: ::LONG = 0x00000002; pub const VSS_VOLSNAP_ATTR_CLIENT_ACCESSIBLE: ::LONG = 0x00000004; pub const VSS_VOLSNAP_ATTR_NO_AUTO_RELEASE: ::LONG = 0x00000008; pub const VSS_VOLSNAP_ATTR_NO_WRITERS: ::LONG = 0x00000010; pub const VSS_VOLSNAP_ATTR_TRANSPORTABLE: ::LONG = 0x00000020; pub const VSS_VOLSNAP_ATTR_NOT_SURFACED: ::LONG = 0x00000040; pub const VSS_VOLSNAP_ATTR_NOT_TRANSACTED: ::LONG = 0x00000080; pub const VSS_VOLSNAP_ATTR_HARDWARE_ASSISTED: ::LONG = 0x00010000; pub const VSS_VOLSNAP_ATTR_DIFFERENTIAL: ::LONG = 0x00020000; pub const VSS_VOLSNAP_ATTR_PLEX: ::LONG = 0x00040000; pub const VSS_VOLSNAP_ATTR_IMPORTED: ::LONG = 0x00080000; pub const VSS_VOLSNAP_ATTR_EXPOSED_LOCALLY: ::LONG = 0x00100000; pub const VSS_VOLSNAP_ATTR_EXPOSED_REMOTELY: ::LONG = 0x00200000; pub const VSS_VOLSNAP_ATTR_AUTORECOVER: ::LONG = 0x00400000; pub const VSS_VOLSNAP_ATTR_ROLLBACK_RECOVERY: ::LONG = 0x00800000; pub const VSS_VOLSNAP_ATTR_DELAYED_POSTSNAPSHOT: ::LONG = 0x01000000; pub const VSS_VOLSNAP_ATTR_TXF_RECOVERY: ::LONG = 0x02000000; pub const VSS_VOLSNAP_ATTR_FILE_SHARE: ::LONG = 0x04000000; pub type PVSS_VOLUME_SNAPSHOT_ATTRIBUTES = *mut VSS_VOLUME_SNAPSHOT_ATTRIBUTES; pub type VSS_SNAPSHOT_CONTEXT = ::LONG; pub type PVSS_SNAPSHOT_CONTEXT = *mut VSS_SNAPSHOT_CONTEXT; pub const VSS_CTX_BACKUP: ::LONG = 0; pub const VSS_CTX_FILE_SHARE_BACKUP: ::LONG = VSS_VOLSNAP_ATTR_NO_WRITERS; pub const VSS_CTX_NAS_ROLLBACK: ::LONG = VSS_VOLSNAP_ATTR_PERSISTENT | VSS_VOLSNAP_ATTR_NO_AUTO_RELEASE | VSS_VOLSNAP_ATTR_NO_WRITERS; pub const VSS_CTX_APP_ROLLBACK: ::LONG = VSS_VOLSNAP_ATTR_PERSISTENT | VSS_VOLSNAP_ATTR_NO_AUTO_RELEASE; pub const VSS_CTX_CLIENT_ACCESSIBLE: ::LONG = VSS_VOLSNAP_ATTR_PERSISTENT | VSS_VOLSNAP_ATTR_CLIENT_ACCESSIBLE | VSS_VOLSNAP_ATTR_NO_AUTO_RELEASE | VSS_VOLSNAP_ATTR_NO_WRITERS; pub const VSS_CTX_CLIENT_ACCESSIBLE_WRITERS: ::LONG = VSS_VOLSNAP_ATTR_PERSISTENT | VSS_VOLSNAP_ATTR_CLIENT_ACCESSIBLE | VSS_VOLSNAP_ATTR_NO_AUTO_RELEASE; pub const VSS_CTX_ALL: ::LONG = 0xffffffffu32 as ::LONG; pub type VSS_PROVIDER_CAPABILITIES = ::DWORD; pub type PVSS_PROVIDER_CAPABILITIES = *mut VSS_PROVIDER_CAPABILITIES; pub const VSS_PRV_CAPABILITY_LEGACY: ::DWORD = 0x1; pub const VSS_PRV_CAPABILITY_COMPLIANT: ::DWORD = 0x2; pub const VSS_PRV_CAPABILITY_LUN_REPOINT: ::DWORD = 0x4; pub const VSS_PRV_CAPABILITY_LUN_RESYNC: ::DWORD = 0x8; pub const VSS_PRV_CAPABILITY_OFFLINE_CREATION: ::DWORD = 0x10; pub const VSS_PRV_CAPABILITY_MULTIPLE_IMPORT: ::DWORD = 0x20; pub const VSS_PRV_CAPABILITY_RECYCLING: ::DWORD = 0x40; pub const VSS_PRV_CAPABILITY_PLEX: ::DWORD = 0x80; pub const VSS_PRV_CAPABILITY_DIFFERENTIAL: ::DWORD = 0x100; pub const VSS_PRV_CAPABILITY_CLUSTERED: ::DWORD = 0x200; pub type VSS_HARDWARE_OPTIONS = ::DWORD; pub type PVSS_HARDWARE_OPTIONS = *mut VSS_HARDWARE_OPTIONS; pub const VSS_BREAKEX_FLAG_MASK_LUNS: ::DWORD = 0x1; pub const VSS_BREAKEX_FLAG_MAKE_READ_WRITE: ::DWORD = 0x2; pub const VSS_BREAKEX_FLAG_REVERT_IDENTITY_ALL: ::DWORD = 0x4; pub const VSS_BREAKEX_FLAG_REVERT_IDENTITY_NONE: ::DWORD = 0x8; pub const VSS_ONLUNSTATECHANGE_NOTIFY_READ_WRITE: ::DWORD = 0x100; pub const VSS_ONLUNSTATECHANGE_NOTIFY_LUN_PRE_RECOVERY: ::DWORD = 0x200; pub const VSS_ONLUNSTATECHANGE_NOTIFY_LUN_POST_RECOVERY: ::DWORD = 0x400; pub const VSS_ONLUNSTATECHANGE_DO_MASK_LUNS: ::DWORD = 0x800; pub type VSS_RECOVERY_OPTIONS = ::DWORD; pub type PVSS_RECOVERY_OPTIONS = *mut VSS_RECOVERY_OPTIONS; pub const VSS_RECOVERY_REVERT_IDENTITY_ALL: ::DWORD = 0x00000100; pub const VSS_RECOVERY_NO_VOLUME_CHECK: ::DWORD = 0x00000200; ENUM!{enum VSS_WRITER_STATE { VSS_WS_UNKNOWN = 0, VSS_WS_STABLE = 1, VSS_WS_WAITING_FOR_FREEZE = 2, VSS_WS_WAITING_FOR_THAW = 3, VSS_WS_WAITING_FOR_POST_SNAPSHOT = 4, VSS_WS_WAITING_FOR_BACKUP_COMPLETE = 5, VSS_WS_FAILED_AT_IDENTIFY = 6, VSS_WS_FAILED_AT_PREPARE_BACKUP = 7, VSS_WS_FAILED_AT_PREPARE_SNAPSHOT = 8, VSS_WS_FAILED_AT_FREEZE = 9, VSS_WS_FAILED_AT_THAW = 10, VSS_WS_FAILED_AT_POST_SNAPSHOT = 11, VSS_WS_FAILED_AT_BACKUP_COMPLETE = 12, VSS_WS_FAILED_AT_PRE_RESTORE = 13, VSS_WS_FAILED_AT_POST_RESTORE = 14, VSS_WS_FAILED_AT_BACKUPSHUTDOWN = 15, VSS_WS_COUNT = 16, }} pub type PVSS_WRITER_STATE = *mut VSS_WRITER_STATE; ENUM!{enum VSS_BACKUP_TYPE { VSS_BT_UNDEFINED = 0, VSS_BT_FULL = 1, VSS_BT_INCREMENTAL = 2, VSS_BT_DIFFERENTIAL = 3, VSS_BT_LOG = 4, VSS_BT_COPY = 5, VSS_BT_OTHER = 6, }} pub type PVSS_BACKUP_TYPE = *mut VSS_BACKUP_TYPE; ENUM!{enum VSS_RESTORE_TYPE { VSS_RTYPE_UNDEFINED = 0, VSS_RTYPE_BY_COPY = 1, VSS_RTYPE_IMPORT = 2, VSS_RTYPE_OTHER = 3, }} pub type PVSS_RESTORE_TYPE = *mut VSS_RESTORE_TYPE; ENUM!{enum VSS_ROLLFORWARD_TYPE { VSS_RF_UNDEFINED = 0, VSS_RF_NONE = 1, VSS_RF_ALL = 2, VSS_RF_PARTIAL = 3, }} pub type PVSS_ROLLFORWARD_TYPE = *mut VSS_ROLLFORWARD_TYPE; ENUM!{enum VSS_PROVIDER_TYPE { VSS_PROV_UNKNOWN = 0, VSS_PROV_SYSTEM = 1, VSS_PROV_SOFTWARE = 2, VSS_PROV_HARDWARE = 3, VSS_PROV_FILESHARE = 4, }} pub type PVSS_PROVIDER_TYPE = *mut VSS_PROVIDER_TYPE; ENUM!{enum VSS_APPLICATION_LEVEL { VSS_APP_UNKNOWN = 0, VSS_APP_SYSTEM = 1, VSS_APP_BACK_END = 2, VSS_APP_FRONT_END = 3, VSS_APP_SYSTEM_RM = 4, VSS_APP_AUTO = -1i32 as u32, }} pub type PVSS_APPLICATION_LEVEL = *mut VSS_APPLICATION_LEVEL; ENUM!{enum VSS_SNAPSHOT_PROPERTY_ID { VSS_SPROPID_UNKNOWN = 0, VSS_SPROPID_SNAPSHOT_ID = 0x1, VSS_SPROPID_SNAPSHOT_SET_ID = 0x2, VSS_SPROPID_SNAPSHOTS_COUNT = 0x3, VSS_SPROPID_SNAPSHOT_DEVICE = 0x4, VSS_SPROPID_ORIGINAL_VOLUME = 0x5, VSS_SPROPID_ORIGINATING_MACHINE = 0x6, VSS_SPROPID_SERVICE_MACHINE = 0x7, VSS_SPROPID_EXPOSED_NAME = 0x8, VSS_SPROPID_EXPOSED_PATH = 0x9, VSS_SPROPID_PROVIDER_ID = 0xa, VSS_SPROPID_SNAPSHOT_ATTRIBUTES = 0xb, VSS_SPROPID_CREATION_TIMESTAMP = 0xc, VSS_SPROPID_STATUS = 0xd, }} pub type PVSS_SNAPSHOT_PROPERTY_ID = *mut VSS_SNAPSHOT_PROPERTY_ID; pub type VSS_FILE_SPEC_BACKUP_TYPE = ::DWORD; pub type PVSS_FILE_SPEC_BACKUP_TYPE = *mut VSS_FILE_SPEC_BACKUP_TYPE; pub const VSS_FSBT_FULL_BACKUP_REQUIRED: ::DWORD = 0x1; pub const VSS_FSBT_DIFFERENTIAL_BACKUP_REQUIRED: ::DWORD = 0x2; pub const VSS_FSBT_INCREMENTAL_BACKUP_REQUIRED: ::DWORD = 0x4; pub const VSS_FSBT_LOG_BACKUP_REQUIRED: ::DWORD = 0x8; pub const VSS_FSBT_FULL_SNAPSHOT_REQUIRED: ::DWORD = 0x100; pub const VSS_FSBT_DIFFERENTIAL_SNAPSHOT_REQUIRED: ::DWORD = 0x200; pub const VSS_FSBT_INCREMENTAL_SNAPSHOT_REQUIRED: ::DWORD = 0x400; pub const VSS_FSBT_LOG_SNAPSHOT_REQUIRED: ::DWORD = 0x800; pub const VSS_FSBT_CREATED_DURING_BACKUP: ::DWORD = 0x10000; pub const VSS_FSBT_ALL_BACKUP_REQUIRED: ::DWORD = 0xf; pub const VSS_FSBT_ALL_SNAPSHOT_REQUIRED: ::DWORD = 0xf00; pub type VSS_BACKUP_SCHEMA = ::DWORD; pub type PVSS_BACKUP_SCHEMA = *mut VSS_BACKUP_SCHEMA; pub const VSS_BS_UNDEFINED: ::DWORD = 0; pub const VSS_BS_DIFFERENTIAL: ::DWORD = 0x1; pub const VSS_BS_INCREMENTAL: ::DWORD = 0x2; pub const VSS_BS_EXCLUSIVE_INCREMENTAL_DIFFERENTIAL: ::DWORD = 0x4; pub const VSS_BS_LOG: ::DWORD = 0x8; pub const VSS_BS_COPY: ::DWORD = 0x10; pub const VSS_BS_TIMESTAMPED: ::DWORD = 0x20; pub const VSS_BS_LAST_MODIFY: ::DWORD = 0x40; pub const VSS_BS_LSN: ::DWORD = 0x80; pub const VSS_BS_WRITER_SUPPORTS_NEW_TARGET: ::DWORD = 0x100; pub const VSS_BS_WRITER_SUPPORTS_RESTORE_WITH_MOVE: ::DWORD = 0x200; pub const VSS_BS_INDEPENDENT_SYSTEM_STATE: ::DWORD = 0x400; pub const VSS_BS_ROLLFORWARD_RESTORE: ::DWORD = 0x1000; pub const VSS_BS_RESTORE_RENAME: ::DWORD = 0x2000; pub const VSS_BS_AUTHORITATIVE_RESTORE: ::DWORD = 0x4000; pub const VSS_BS_WRITER_SUPPORTS_PARALLEL_RESTORES: ::DWORD = 0x8000; pub type VSS_ID = ::GUID; pub type VSS_PWSZ = *mut ::WCHAR; pub type VSS_TIMESTAMP = ::LONGLONG; STRUCT!{struct VSS_SNAPSHOT_PROP { m_SnapshotId: ::VSS_ID, m_SnapshotSetId: ::VSS_ID, m_lSnapshotsCount: ::LONG, m_pwszSnapshotDeviceObject: ::VSS_PWSZ, m_pwszOriginalVolumeName: ::VSS_PWSZ, m_pwszOriginatingMachine: ::VSS_PWSZ, m_pwszServiceMachine: ::VSS_PWSZ, m_pwszExposedName: ::VSS_PWSZ, m_pwszExposedPath: ::VSS_PWSZ, m_ProviderId: ::VSS_ID, m_lSnapshotAttributes: ::LONG, m_tsCreationTimestamp: ::VSS_TIMESTAMP, m_eStatus: ::VSS_SNAPSHOT_STATE, }} type PVSS_SNAPSHOT_PROP = *mut VSS_SNAPSHOT_PROP; STRUCT!{struct VSS_PROVIDER_PROP { m_ProviderId: ::VSS_ID, m_pwszProviderName: ::VSS_PWSZ, m_eProviderType: ::VSS_PROVIDER_TYPE, m_pwszProviderVersion: ::VSS_PWSZ, m_ProviderVersionId: ::VSS_ID, m_ClassId: ::CLSID, }} type PVSS_PROVIDER_PROP = *mut VSS_PROVIDER_PROP; STRUCT!{struct VSS_OBJECT_UNION { Snap: ::VSS_SNAPSHOT_PROP, }} UNION!(VSS_OBJECT_UNION, Snap, Prov, Prov_mut, VSS_PROVIDER_PROP); STRUCT!{struct VSS_OBJECT_PROP { Type: ::VSS_OBJECT_TYPE, Obj: ::VSS_OBJECT_UNION, }} type PVSS_OBJECT_PROP = *mut VSS_OBJECT_PROP; RIDL!( interface IVssEnumObject(IVssEnumObjectVtbl): IUnknown(IUnknownVtbl) { fn Next( &mut self, celt: ::ULONG, rgelt: *mut ::VSS_OBJECT_PROP, pceltFetched: *mut ::ULONG ) -> ::HRESULT, fn Skip(&mut self, celt: ::ULONG) -> ::HRESULT, fn Reset(&mut self) -> ::HRESULT, fn Clone(&mut self, ppenum: *mut *mut ::IVssEnumObject) -> ::HRESULT } ); RIDL!( interface IVssAsync(IVssAsyncVtbl): IUnknown(IUnknownVtbl) { fn Cancel(&mut self) -> ::HRESULT, fn Wait(&mut self, dwMilliseconds: ::DWORD) -> ::HRESULT, fn QueryStatus(&mut self, pHrResult: *mut ::HRESULT, pReserved: *mut ::INT) -> ::HRESULT } ); deps/winapi-0.2.5/src/winnt.rs0000644000000000000000000027103512615665217014755 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! This module defines the 32-Bit Windows types and constants that are defined by NT, but exposed //! through the Win32 API. pub const ANYSIZE_ARRAY: usize = 1; //341 pub type PVOID = *mut ::c_void; pub type PVOID64 = u64; // This is a 64-bit pointer, even when in 32-bit //382 pub type VOID = ::c_void; pub type CHAR = ::c_char; pub type SHORT = ::c_short; pub type LONG = ::c_long; // pub type INT = ::c_int; // Already defined by minwindef.h pub type WCHAR = ::wchar_t; pub type PWCHAR = *mut WCHAR; pub type LPWCH = *mut WCHAR; pub type PWCH = *mut WCHAR; pub type LPCWCH = *const WCHAR; pub type PCWCH = *const WCHAR; pub type NWPSTR = *mut WCHAR; pub type LPWSTR = *mut WCHAR; pub type PWSTR = *mut WCHAR; pub type PZPWSTR = *mut PWSTR; pub type PCZPWSTR = *const PWSTR; pub type LPUWSTR = *mut WCHAR; pub type PUWSTR = *mut WCHAR; pub type LPCWSTR = *const WCHAR; pub type PCWSTR = *const WCHAR; pub type PZPCWSTR= *mut PCWSTR; pub type PCZPCWSTR = *const PCWSTR; pub type LPCUWSTR = *const WCHAR; pub type PCUWSTR = *const WCHAR; pub type PZZWSTR= *mut WCHAR; pub type PCZZWSTR = *const WCHAR; pub type PUZZWSTR = *mut WCHAR; pub type PCUZZWSTR = *const WCHAR; pub type PNZWCH = *mut WCHAR; pub type PCNZWCH = *const WCHAR; pub type PUNZWCH = *mut WCHAR; pub type PCUNZWCH = *const WCHAR; pub type LPCWCHAR = *const WCHAR; pub type PCWCHAR = *const WCHAR; pub type LPCUWCHAR = *const WCHAR; pub type PCUWCHAR = *const WCHAR; pub type UCSCHAR = ::c_ulong; pub type PUCSCHAR = *mut UCSCHAR; pub type PCUCSCHAR = *const UCSCHAR; pub type PUCSSTR = *mut UCSCHAR; pub type PUUCSSTR = *mut UCSCHAR; pub type PCUCSSTR = *const UCSCHAR; pub type PCUUCSSTR = *const UCSCHAR; pub type PUUCSCHAR = *mut UCSCHAR; pub type PCUUCSCHAR = *const UCSCHAR; pub type PCHAR = *mut CHAR; pub type LPCH = *mut CHAR; pub type PCH = *mut CHAR; pub type LPCCH = *const CHAR; pub type PCCH = *const CHAR; pub type NPSTR = *mut CHAR; pub type LPSTR = *mut CHAR; pub type PSTR = *mut CHAR; pub type PZPSTR = *mut PSTR; pub type PCZPSTR = *const PSTR; pub type LPCSTR = *const CHAR; pub type PCSTR = *const CHAR; pub type PZPCSTR = *mut PCSTR; pub type PCZPCSTR = *const PCSTR; pub type PZZSTR = *mut CHAR; pub type PCZZSTR = *const CHAR; pub type PNZCH = *mut CHAR; pub type PCNZCH = *const CHAR; // Skipping TCHAR things pub type PSHORT = *mut SHORT; pub type PLONG = *mut LONG; STRUCT!{struct PROCESSOR_NUMBER { Group: ::WORD, Number: ::BYTE, Reserved: ::BYTE, }} pub type PPROCESSOR_NUMBER = *mut PROCESSOR_NUMBER; STRUCT!{struct GROUP_AFFINITY { Mask: ::KAFFINITY, Group: ::WORD, Reserved: [::WORD; 3], }} pub type PGROUP_AFFINITY = *mut GROUP_AFFINITY; pub type HANDLE = *mut ::c_void; pub type PHANDLE = *mut HANDLE; pub type FCHAR = ::BYTE; pub type FSHORT = ::WORD; pub type FLONG = ::DWORD; //667 pub type CCHAR = ::c_char; pub type LCID = ::DWORD; pub type PLCID = ::PDWORD; pub type LANGID = ::WORD; ENUM!{enum COMPARTMENT_ID { UNSPECIFIED_COMPARTMENT_ID = 0, DEFAULT_COMPARTMENT_ID = 1, }} pub type PCOMPARTMENT_ID = *mut COMPARTMENT_ID; pub const APPLICATION_ERROR_MASK: ::DWORD = 0x20000000; pub const ERROR_SEVERITY_SUCCESS: ::DWORD = 0x00000000; pub const ERROR_SEVERITY_INFORMATIONAL: ::DWORD = 0x40000000; pub const ERROR_SEVERITY_WARNING: ::DWORD = 0x80000000; pub const ERROR_SEVERITY_ERROR: ::DWORD = 0xC0000000; //710 STRUCT!{struct FLOAT128 { LowPart: ::__int64, HighPart: ::__int64, }} pub type PFLOAT128 = *mut FLOAT128; pub type LONGLONG = ::__int64; pub type ULONGLONG = ::__uint64; pub type PLONGLONG = *mut LONGLONG; pub type PULONGLONG = *mut ULONGLONG; pub type USN = LONGLONG; pub type LARGE_INTEGER = LONGLONG; pub type PLARGE_INTEGER = *mut LARGE_INTEGER; pub type ULARGE_INTEGER = ULONGLONG; pub type PULARGE_INTEGER= *mut ULARGE_INTEGER; pub type RTL_REFERENCE_COUNT = ::LONG_PTR; pub type PRTL_REFERENCE_COUNT = *mut ::LONG_PTR; STRUCT!{struct LUID { LowPart: ::DWORD, HighPart: LONG, }} pub type PLUID = *mut LUID; pub type DWORDLONG = ULONGLONG; pub type PDWORDLONG = *mut DWORDLONG; //1042 pub type BOOLEAN = ::BYTE; pub type PBOOLEAN = *mut BOOLEAN; STRUCT!{struct LIST_ENTRY { Flink: *mut LIST_ENTRY, Blink: *mut LIST_ENTRY, }} pub type PLIST_ENTRY = *mut LIST_ENTRY; STRUCT!{struct SINGLE_LIST_ENTRY { Next: *mut SINGLE_LIST_ENTRY, }} pub type PSINGLE_LIST_ENTRY = *mut SINGLE_LIST_ENTRY; STRUCT!{struct LIST_ENTRY32 { Flink: ::DWORD, Blink: ::DWORD, }} pub type PLIST_ENTRY32 = *mut LIST_ENTRY32; STRUCT!{struct LIST_ENTRY64 { Flink: ULONGLONG, Blink: ULONGLONG, }} pub type PLIST_ENTRY64 = *mut LIST_ENTRY64; STRUCT!{struct OBJECTID { Lineage: ::GUID, Uniquifier: ::DWORD, }} pub const MINCHAR: ::CHAR = 0x80u8 as ::CHAR; pub const MAXCHAR: ::CHAR = 0x7f; pub const MINSHORT: ::SHORT = 0x8000u16 as ::SHORT; pub const MAXSHORT: ::SHORT = 0x7fff; pub const MINLONG: ::LONG = 0x80000000u32 as ::LONG; pub const MAXLONG: ::LONG = 0x7fffffff; pub const MAXBYTE: ::BYTE = 0xff; pub const MAXWORD: ::WORD = 0xffff; pub const MAXDWORD: ::DWORD = 0xffffffff; //1300 pub type PEXCEPTION_ROUTINE = Option ::EXCEPTION_DISPOSITION>; //1498 pub const LANG_NEUTRAL: ::WORD = 0x00; pub const LANG_INVARIANT: ::WORD = 0x7f; pub const LANG_AFRIKAANS: ::WORD = 0x36; pub const LANG_ALBANIAN: ::WORD = 0x1c; pub const LANG_ALSATIAN: ::WORD = 0x84; pub const LANG_AMHARIC: ::WORD = 0x5e; pub const LANG_ARABIC: ::WORD = 0x01; pub const LANG_ARMENIAN: ::WORD = 0x2b; pub const LANG_ASSAMESE: ::WORD = 0x4d; pub const LANG_AZERI: ::WORD = 0x2c; pub const LANG_AZERBAIJANI: ::WORD = 0x2c; pub const LANG_BANGLA: ::WORD = 0x45; pub const LANG_BASHKIR: ::WORD = 0x6d; pub const LANG_BASQUE: ::WORD = 0x2d; pub const LANG_BELARUSIAN: ::WORD = 0x23; pub const LANG_BENGALI: ::WORD = 0x45; pub const LANG_BRETON: ::WORD = 0x7e; pub const LANG_BOSNIAN: ::WORD = 0x1a; pub const LANG_BOSNIAN_NEUTRAL: ::WORD = 0x781a; pub const LANG_BULGARIAN: ::WORD = 0x02; pub const LANG_CATALAN: ::WORD = 0x03; pub const LANG_CENTRAL_KURDISH: ::WORD = 0x92; pub const LANG_CHEROKEE: ::WORD = 0x5c; pub const LANG_CHINESE: ::WORD = 0x04; pub const LANG_CHINESE_SIMPLIFIED: ::WORD = 0x04; pub const LANG_CHINESE_TRADITIONAL: ::WORD = 0x7c04; pub const LANG_CORSICAN: ::WORD = 0x83; pub const LANG_CROATIAN: ::WORD = 0x1a; pub const LANG_CZECH: ::WORD = 0x05; pub const LANG_DANISH: ::WORD = 0x06; pub const LANG_DARI: ::WORD = 0x8c; pub const LANG_DIVEHI: ::WORD = 0x65; pub const LANG_DUTCH: ::WORD = 0x13; pub const LANG_ENGLISH: ::WORD = 0x09; pub const LANG_ESTONIAN: ::WORD = 0x25; pub const LANG_FAEROESE: ::WORD = 0x38; pub const LANG_FARSI: ::WORD = 0x29; pub const LANG_FILIPINO: ::WORD = 0x64; pub const LANG_FINNISH: ::WORD = 0x0b; pub const LANG_FRENCH: ::WORD = 0x0c; pub const LANG_FRISIAN: ::WORD = 0x62; pub const LANG_FULAH: ::WORD = 0x67; pub const LANG_GALICIAN: ::WORD = 0x56; pub const LANG_GEORGIAN: ::WORD = 0x37; pub const LANG_GERMAN: ::WORD = 0x07; pub const LANG_GREEK: ::WORD = 0x08; pub const LANG_GREENLANDIC: ::WORD = 0x6f; pub const LANG_GUJARATI: ::WORD = 0x47; pub const LANG_HAUSA: ::WORD = 0x68; pub const LANG_HAWAIIAN: ::WORD = 0x75; pub const LANG_HEBREW: ::WORD = 0x0d; pub const LANG_HINDI: ::WORD = 0x39; pub const LANG_HUNGARIAN: ::WORD = 0x0e; pub const LANG_ICELANDIC: ::WORD = 0x0f; pub const LANG_IGBO: ::WORD = 0x70; pub const LANG_INDONESIAN: ::WORD = 0x21; pub const LANG_INUKTITUT: ::WORD = 0x5d; pub const LANG_IRISH: ::WORD = 0x3c; pub const LANG_ITALIAN: ::WORD = 0x10; pub const LANG_JAPANESE: ::WORD = 0x11; pub const LANG_KANNADA: ::WORD = 0x4b; pub const LANG_KASHMIRI: ::WORD = 0x60; pub const LANG_KAZAK: ::WORD = 0x3f; pub const LANG_KHMER: ::WORD = 0x53; pub const LANG_KICHE: ::WORD = 0x86; pub const LANG_KINYARWANDA: ::WORD = 0x87; pub const LANG_KONKANI: ::WORD = 0x57; pub const LANG_KOREAN: ::WORD = 0x12; pub const LANG_KYRGYZ: ::WORD = 0x40; pub const LANG_LAO: ::WORD = 0x54; pub const LANG_LATVIAN: ::WORD = 0x26; pub const LANG_LITHUANIAN: ::WORD = 0x27; pub const LANG_LOWER_SORBIAN: ::WORD = 0x2e; pub const LANG_LUXEMBOURGISH: ::WORD = 0x6e; pub const LANG_MACEDONIAN: ::WORD = 0x2f; pub const LANG_MALAY: ::WORD = 0x3e; pub const LANG_MALAYALAM: ::WORD = 0x4c; pub const LANG_MALTESE: ::WORD = 0x3a; pub const LANG_MANIPURI: ::WORD = 0x58; pub const LANG_MAORI: ::WORD = 0x81; pub const LANG_MAPUDUNGUN: ::WORD = 0x7a; pub const LANG_MARATHI: ::WORD = 0x4e; pub const LANG_MOHAWK: ::WORD = 0x7c; pub const LANG_MONGOLIAN: ::WORD = 0x50; pub const LANG_NEPALI: ::WORD = 0x61; pub const LANG_NORWEGIAN: ::WORD = 0x14; pub const LANG_OCCITAN: ::WORD = 0x82; pub const LANG_ODIA: ::WORD = 0x48; pub const LANG_ORIYA: ::WORD = 0x48; pub const LANG_PASHTO: ::WORD = 0x63; pub const LANG_PERSIAN: ::WORD = 0x29; pub const LANG_POLISH: ::WORD = 0x15; pub const LANG_PORTUGUESE: ::WORD = 0x16; pub const LANG_PULAR: ::WORD = 0x67; pub const LANG_PUNJABI: ::WORD = 0x46; pub const LANG_QUECHUA: ::WORD = 0x6b; pub const LANG_ROMANIAN: ::WORD = 0x18; pub const LANG_ROMANSH: ::WORD = 0x17; pub const LANG_RUSSIAN: ::WORD = 0x19; pub const LANG_SAKHA: ::WORD = 0x85; pub const LANG_SAMI: ::WORD = 0x3b; pub const LANG_SANSKRIT: ::WORD = 0x4f; pub const LANG_SCOTTISH_GAELIC: ::WORD = 0x91; pub const LANG_SERBIAN: ::WORD = 0x1a; pub const LANG_SERBIAN_NEUTRAL: ::WORD = 0x7c1a; pub const LANG_SINDHI: ::WORD = 0x59; pub const LANG_SINHALESE: ::WORD = 0x5b; pub const LANG_SLOVAK: ::WORD = 0x1b; pub const LANG_SLOVENIAN: ::WORD = 0x24; pub const LANG_SOTHO: ::WORD = 0x6c; pub const LANG_SPANISH: ::WORD = 0x0a; pub const LANG_SWAHILI: ::WORD = 0x41; pub const LANG_SWEDISH: ::WORD = 0x1d; pub const LANG_SYRIAC: ::WORD = 0x5a; pub const LANG_TAJIK: ::WORD = 0x28; pub const LANG_TAMAZIGHT: ::WORD = 0x5f; pub const LANG_TAMIL: ::WORD = 0x49; pub const LANG_TATAR: ::WORD = 0x44; pub const LANG_TELUGU: ::WORD = 0x4a; pub const LANG_THAI: ::WORD = 0x1e; pub const LANG_TIBETAN: ::WORD = 0x51; pub const LANG_TIGRIGNA: ::WORD = 0x73; pub const LANG_TIGRINYA: ::WORD = 0x73; pub const LANG_TSWANA: ::WORD = 0x32; pub const LANG_TURKISH: ::WORD = 0x1f; pub const LANG_TURKMEN: ::WORD = 0x42; pub const LANG_UIGHUR: ::WORD = 0x80; pub const LANG_UKRAINIAN: ::WORD = 0x22; pub const LANG_UPPER_SORBIAN: ::WORD = 0x2e; pub const LANG_URDU: ::WORD = 0x20; pub const LANG_UZBEK: ::WORD = 0x43; pub const LANG_VALENCIAN: ::WORD = 0x03; pub const LANG_VIETNAMESE: ::WORD = 0x2a; pub const LANG_WELSH: ::WORD = 0x52; pub const LANG_WOLOF: ::WORD = 0x88; pub const LANG_XHOSA: ::WORD = 0x34; pub const LANG_YAKUT: ::WORD = 0x85; pub const LANG_YI: ::WORD = 0x78; pub const LANG_YORUBA: ::WORD = 0x6a; pub const LANG_ZULU: ::WORD = 0x35; //1651 pub const SUBLANG_NEUTRAL: ::WORD = 0x00; pub const SUBLANG_DEFAULT: ::WORD = 0x01; pub const SUBLANG_SYS_DEFAULT: ::WORD = 0x02; pub const SUBLANG_CUSTOM_DEFAULT: ::WORD = 0x03; pub const SUBLANG_CUSTOM_UNSPECIFIED: ::WORD = 0x04; pub const SUBLANG_UI_CUSTOM_DEFAULT: ::WORD = 0x05; pub const SUBLANG_AFRIKAANS_SOUTH_AFRICA: ::WORD = 0x01; pub const SUBLANG_ALBANIAN_ALBANIA: ::WORD = 0x01; pub const SUBLANG_ALSATIAN_FRANCE: ::WORD = 0x01; pub const SUBLANG_AMHARIC_ETHIOPIA: ::WORD = 0x01; pub const SUBLANG_ARABIC_SAUDI_ARABIA: ::WORD = 0x01; pub const SUBLANG_ARABIC_IRAQ: ::WORD = 0x02; pub const SUBLANG_ARABIC_EGYPT: ::WORD = 0x03; pub const SUBLANG_ARABIC_LIBYA: ::WORD = 0x04; pub const SUBLANG_ARABIC_ALGERIA: ::WORD = 0x05; pub const SUBLANG_ARABIC_MOROCCO: ::WORD = 0x06; pub const SUBLANG_ARABIC_TUNISIA: ::WORD = 0x07; pub const SUBLANG_ARABIC_OMAN: ::WORD = 0x08; pub const SUBLANG_ARABIC_YEMEN: ::WORD = 0x09; pub const SUBLANG_ARABIC_SYRIA: ::WORD = 0x0a; pub const SUBLANG_ARABIC_JORDAN: ::WORD = 0x0b; pub const SUBLANG_ARABIC_LEBANON: ::WORD = 0x0c; pub const SUBLANG_ARABIC_KUWAIT: ::WORD = 0x0d; pub const SUBLANG_ARABIC_UAE: ::WORD = 0x0e; pub const SUBLANG_ARABIC_BAHRAIN: ::WORD = 0x0f; pub const SUBLANG_ARABIC_QATAR: ::WORD = 0x10; pub const SUBLANG_ARMENIAN_ARMENIA: ::WORD = 0x01; pub const SUBLANG_ASSAMESE_INDIA: ::WORD = 0x01; pub const SUBLANG_AZERI_LATIN: ::WORD = 0x01; pub const SUBLANG_AZERI_CYRILLIC: ::WORD = 0x02; pub const SUBLANG_AZERBAIJANI_AZERBAIJAN_LATIN: ::WORD = 0x01; pub const SUBLANG_AZERBAIJANI_AZERBAIJAN_CYRILLIC: ::WORD = 0x02; pub const SUBLANG_BANGLA_INDIA: ::WORD = 0x01; pub const SUBLANG_BANGLA_BANGLADESH: ::WORD = 0x02; pub const SUBLANG_BASHKIR_RUSSIA: ::WORD = 0x01; pub const SUBLANG_BASQUE_BASQUE: ::WORD = 0x01; pub const SUBLANG_BELARUSIAN_BELARUS: ::WORD = 0x01; pub const SUBLANG_BENGALI_INDIA: ::WORD = 0x01; pub const SUBLANG_BENGALI_BANGLADESH: ::WORD = 0x02; pub const SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN: ::WORD = 0x05; pub const SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC: ::WORD = 0x08; pub const SUBLANG_BRETON_FRANCE: ::WORD = 0x01; pub const SUBLANG_BULGARIAN_BULGARIA: ::WORD = 0x01; pub const SUBLANG_CATALAN_CATALAN: ::WORD = 0x01; pub const SUBLANG_CENTRAL_KURDISH_IRAQ: ::WORD = 0x01; pub const SUBLANG_CHEROKEE_CHEROKEE: ::WORD = 0x01; pub const SUBLANG_CHINESE_TRADITIONAL: ::WORD = 0x01; pub const SUBLANG_CHINESE_SIMPLIFIED: ::WORD = 0x02; pub const SUBLANG_CHINESE_HONGKONG: ::WORD = 0x03; pub const SUBLANG_CHINESE_SINGAPORE: ::WORD = 0x04; pub const SUBLANG_CHINESE_MACAU: ::WORD = 0x05; pub const SUBLANG_CORSICAN_FRANCE: ::WORD = 0x01; pub const SUBLANG_CZECH_CZECH_REPUBLIC: ::WORD = 0x01; pub const SUBLANG_CROATIAN_CROATIA: ::WORD = 0x01; pub const SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN: ::WORD = 0x04; pub const SUBLANG_DANISH_DENMARK: ::WORD = 0x01; pub const SUBLANG_DARI_AFGHANISTAN: ::WORD = 0x01; pub const SUBLANG_DIVEHI_MALDIVES: ::WORD = 0x01; pub const SUBLANG_DUTCH: ::WORD = 0x01; pub const SUBLANG_DUTCH_BELGIAN: ::WORD = 0x02; pub const SUBLANG_ENGLISH_US: ::WORD = 0x01; pub const SUBLANG_ENGLISH_UK: ::WORD = 0x02; pub const SUBLANG_ENGLISH_AUS: ::WORD = 0x03; pub const SUBLANG_ENGLISH_CAN: ::WORD = 0x04; pub const SUBLANG_ENGLISH_NZ: ::WORD = 0x05; pub const SUBLANG_ENGLISH_EIRE: ::WORD = 0x06; pub const SUBLANG_ENGLISH_SOUTH_AFRICA: ::WORD = 0x07; pub const SUBLANG_ENGLISH_JAMAICA: ::WORD = 0x08; pub const SUBLANG_ENGLISH_CARIBBEAN: ::WORD = 0x09; pub const SUBLANG_ENGLISH_BELIZE: ::WORD = 0x0a; pub const SUBLANG_ENGLISH_TRINIDAD: ::WORD = 0x0b; pub const SUBLANG_ENGLISH_ZIMBABWE: ::WORD = 0x0c; pub const SUBLANG_ENGLISH_PHILIPPINES: ::WORD = 0x0d; pub const SUBLANG_ENGLISH_INDIA: ::WORD = 0x10; pub const SUBLANG_ENGLISH_MALAYSIA: ::WORD = 0x11; pub const SUBLANG_ENGLISH_SINGAPORE: ::WORD = 0x12; pub const SUBLANG_ESTONIAN_ESTONIA: ::WORD = 0x01; pub const SUBLANG_FAEROESE_FAROE_ISLANDS: ::WORD = 0x01; pub const SUBLANG_FILIPINO_PHILIPPINES: ::WORD = 0x01; pub const SUBLANG_FINNISH_FINLAND: ::WORD = 0x01; pub const SUBLANG_FRENCH: ::WORD = 0x01; pub const SUBLANG_FRENCH_BELGIAN: ::WORD = 0x02; pub const SUBLANG_FRENCH_CANADIAN: ::WORD = 0x03; pub const SUBLANG_FRENCH_SWISS: ::WORD = 0x04; pub const SUBLANG_FRENCH_LUXEMBOURG: ::WORD = 0x05; pub const SUBLANG_FRENCH_MONACO: ::WORD = 0x06; pub const SUBLANG_FRISIAN_NETHERLANDS: ::WORD = 0x01; pub const SUBLANG_FULAH_SENEGAL: ::WORD = 0x02; pub const SUBLANG_GALICIAN_GALICIAN: ::WORD = 0x01; pub const SUBLANG_GEORGIAN_GEORGIA: ::WORD = 0x01; pub const SUBLANG_GERMAN: ::WORD = 0x01; pub const SUBLANG_GERMAN_SWISS: ::WORD = 0x02; pub const SUBLANG_GERMAN_AUSTRIAN: ::WORD = 0x03; pub const SUBLANG_GERMAN_LUXEMBOURG: ::WORD = 0x04; pub const SUBLANG_GERMAN_LIECHTENSTEIN: ::WORD = 0x05; pub const SUBLANG_GREEK_GREECE: ::WORD = 0x01; pub const SUBLANG_GREENLANDIC_GREENLAND: ::WORD = 0x01; pub const SUBLANG_GUJARATI_INDIA: ::WORD = 0x01; pub const SUBLANG_HAUSA_NIGERIA_LATIN: ::WORD = 0x01; pub const SUBLANG_HAWAIIAN_US: ::WORD = 0x01; pub const SUBLANG_HEBREW_ISRAEL: ::WORD = 0x01; pub const SUBLANG_HINDI_INDIA: ::WORD = 0x01; pub const SUBLANG_HUNGARIAN_HUNGARY: ::WORD = 0x01; pub const SUBLANG_ICELANDIC_ICELAND: ::WORD = 0x01; pub const SUBLANG_IGBO_NIGERIA: ::WORD = 0x01; pub const SUBLANG_INDONESIAN_INDONESIA: ::WORD = 0x01; pub const SUBLANG_INUKTITUT_CANADA: ::WORD = 0x01; pub const SUBLANG_INUKTITUT_CANADA_LATIN: ::WORD = 0x02; pub const SUBLANG_IRISH_IRELAND: ::WORD = 0x02; pub const SUBLANG_ITALIAN: ::WORD = 0x01; pub const SUBLANG_ITALIAN_SWISS: ::WORD = 0x02; pub const SUBLANG_JAPANESE_JAPAN: ::WORD = 0x01; pub const SUBLANG_KANNADA_INDIA: ::WORD = 0x01; pub const SUBLANG_KASHMIRI_SASIA: ::WORD = 0x02; pub const SUBLANG_KASHMIRI_INDIA: ::WORD = 0x02; pub const SUBLANG_KAZAK_KAZAKHSTAN: ::WORD = 0x01; pub const SUBLANG_KHMER_CAMBODIA: ::WORD = 0x01; pub const SUBLANG_KICHE_GUATEMALA: ::WORD = 0x01; pub const SUBLANG_KINYARWANDA_RWANDA: ::WORD = 0x01; pub const SUBLANG_KONKANI_INDIA: ::WORD = 0x01; pub const SUBLANG_KOREAN: ::WORD = 0x01; pub const SUBLANG_KYRGYZ_KYRGYZSTAN: ::WORD = 0x01; pub const SUBLANG_LAO_LAO: ::WORD = 0x01; pub const SUBLANG_LATVIAN_LATVIA: ::WORD = 0x01; pub const SUBLANG_LITHUANIAN: ::WORD = 0x01; pub const SUBLANG_LOWER_SORBIAN_GERMANY: ::WORD = 0x02; pub const SUBLANG_LUXEMBOURGISH_LUXEMBOURG: ::WORD = 0x01; pub const SUBLANG_MACEDONIAN_MACEDONIA: ::WORD = 0x01; pub const SUBLANG_MALAY_MALAYSIA: ::WORD = 0x01; pub const SUBLANG_MALAY_BRUNEI_DARUSSALAM: ::WORD = 0x02; pub const SUBLANG_MALAYALAM_INDIA: ::WORD = 0x01; pub const SUBLANG_MALTESE_MALTA: ::WORD = 0x01; pub const SUBLANG_MAORI_NEW_ZEALAND: ::WORD = 0x01; pub const SUBLANG_MAPUDUNGUN_CHILE: ::WORD = 0x01; pub const SUBLANG_MARATHI_INDIA: ::WORD = 0x01; pub const SUBLANG_MOHAWK_MOHAWK: ::WORD = 0x01; pub const SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA: ::WORD = 0x01; pub const SUBLANG_MONGOLIAN_PRC: ::WORD = 0x02; pub const SUBLANG_NEPALI_INDIA: ::WORD = 0x02; pub const SUBLANG_NEPALI_NEPAL: ::WORD = 0x01; pub const SUBLANG_NORWEGIAN_BOKMAL: ::WORD = 0x01; pub const SUBLANG_NORWEGIAN_NYNORSK: ::WORD = 0x02; pub const SUBLANG_OCCITAN_FRANCE: ::WORD = 0x01; pub const SUBLANG_ODIA_INDIA: ::WORD = 0x01; pub const SUBLANG_ORIYA_INDIA: ::WORD = 0x01; pub const SUBLANG_PASHTO_AFGHANISTAN: ::WORD = 0x01; pub const SUBLANG_PERSIAN_IRAN: ::WORD = 0x01; pub const SUBLANG_POLISH_POLAND: ::WORD = 0x01; pub const SUBLANG_PORTUGUESE: ::WORD = 0x02; pub const SUBLANG_PORTUGUESE_BRAZILIAN: ::WORD = 0x01; pub const SUBLANG_PULAR_SENEGAL: ::WORD = 0x02; pub const SUBLANG_PUNJABI_INDIA: ::WORD = 0x01; pub const SUBLANG_PUNJABI_PAKISTAN: ::WORD = 0x02; pub const SUBLANG_QUECHUA_BOLIVIA: ::WORD = 0x01; pub const SUBLANG_QUECHUA_ECUADOR: ::WORD = 0x02; pub const SUBLANG_QUECHUA_PERU: ::WORD = 0x03; pub const SUBLANG_ROMANIAN_ROMANIA: ::WORD = 0x01; pub const SUBLANG_ROMANSH_SWITZERLAND: ::WORD = 0x01; pub const SUBLANG_RUSSIAN_RUSSIA: ::WORD = 0x01; pub const SUBLANG_SAKHA_RUSSIA: ::WORD = 0x01; pub const SUBLANG_SAMI_NORTHERN_NORWAY: ::WORD = 0x01; pub const SUBLANG_SAMI_NORTHERN_SWEDEN: ::WORD = 0x02; pub const SUBLANG_SAMI_NORTHERN_FINLAND: ::WORD = 0x03; pub const SUBLANG_SAMI_LULE_NORWAY: ::WORD = 0x04; pub const SUBLANG_SAMI_LULE_SWEDEN: ::WORD = 0x05; pub const SUBLANG_SAMI_SOUTHERN_NORWAY: ::WORD = 0x06; pub const SUBLANG_SAMI_SOUTHERN_SWEDEN: ::WORD = 0x07; pub const SUBLANG_SAMI_SKOLT_FINLAND: ::WORD = 0x08; pub const SUBLANG_SAMI_INARI_FINLAND: ::WORD = 0x09; pub const SUBLANG_SANSKRIT_INDIA: ::WORD = 0x01; pub const SUBLANG_SCOTTISH_GAELIC: ::WORD = 0x01; pub const SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN: ::WORD = 0x06; pub const SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC: ::WORD = 0x07; pub const SUBLANG_SERBIAN_MONTENEGRO_LATIN: ::WORD = 0x0b; pub const SUBLANG_SERBIAN_MONTENEGRO_CYRILLIC: ::WORD = 0x0c; pub const SUBLANG_SERBIAN_SERBIA_LATIN: ::WORD = 0x09; pub const SUBLANG_SERBIAN_SERBIA_CYRILLIC: ::WORD = 0x0a; pub const SUBLANG_SERBIAN_CROATIA: ::WORD = 0x01; pub const SUBLANG_SERBIAN_LATIN: ::WORD = 0x02; pub const SUBLANG_SERBIAN_CYRILLIC: ::WORD = 0x03; pub const SUBLANG_SINDHI_INDIA: ::WORD = 0x01; pub const SUBLANG_SINDHI_PAKISTAN: ::WORD = 0x02; pub const SUBLANG_SINDHI_AFGHANISTAN: ::WORD = 0x02; pub const SUBLANG_SINHALESE_SRI_LANKA: ::WORD = 0x01; pub const SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA: ::WORD = 0x01; pub const SUBLANG_SLOVAK_SLOVAKIA: ::WORD = 0x01; pub const SUBLANG_SLOVENIAN_SLOVENIA: ::WORD = 0x01; pub const SUBLANG_SPANISH: ::WORD = 0x01; pub const SUBLANG_SPANISH_MEXICAN: ::WORD = 0x02; pub const SUBLANG_SPANISH_MODERN: ::WORD = 0x03; pub const SUBLANG_SPANISH_GUATEMALA: ::WORD = 0x04; pub const SUBLANG_SPANISH_COSTA_RICA: ::WORD = 0x05; pub const SUBLANG_SPANISH_PANAMA: ::WORD = 0x06; pub const SUBLANG_SPANISH_DOMINICAN_REPUBLIC: ::WORD = 0x07; pub const SUBLANG_SPANISH_VENEZUELA: ::WORD = 0x08; pub const SUBLANG_SPANISH_COLOMBIA: ::WORD = 0x09; pub const SUBLANG_SPANISH_PERU: ::WORD = 0x0a; pub const SUBLANG_SPANISH_ARGENTINA: ::WORD = 0x0b; pub const SUBLANG_SPANISH_ECUADOR: ::WORD = 0x0c; pub const SUBLANG_SPANISH_CHILE: ::WORD = 0x0d; pub const SUBLANG_SPANISH_URUGUAY: ::WORD = 0x0e; pub const SUBLANG_SPANISH_PARAGUAY: ::WORD = 0x0f; pub const SUBLANG_SPANISH_BOLIVIA: ::WORD = 0x10; pub const SUBLANG_SPANISH_EL_SALVADOR: ::WORD = 0x11; pub const SUBLANG_SPANISH_HONDURAS: ::WORD = 0x12; pub const SUBLANG_SPANISH_NICARAGUA: ::WORD = 0x13; pub const SUBLANG_SPANISH_PUERTO_RICO: ::WORD = 0x14; pub const SUBLANG_SPANISH_US: ::WORD = 0x15; pub const SUBLANG_SWAHILI_KENYA: ::WORD = 0x01; pub const SUBLANG_SWEDISH: ::WORD = 0x01; pub const SUBLANG_SWEDISH_FINLAND: ::WORD = 0x02; pub const SUBLANG_SYRIAC_SYRIA: ::WORD = 0x01; pub const SUBLANG_TAJIK_TAJIKISTAN: ::WORD = 0x01; pub const SUBLANG_TAMAZIGHT_ALGERIA_LATIN: ::WORD = 0x02; pub const SUBLANG_TAMAZIGHT_MOROCCO_TIFINAGH: ::WORD = 0x04; pub const SUBLANG_TAMIL_INDIA: ::WORD = 0x01; pub const SUBLANG_TAMIL_SRI_LANKA: ::WORD = 0x02; pub const SUBLANG_TATAR_RUSSIA: ::WORD = 0x01; pub const SUBLANG_TELUGU_INDIA: ::WORD = 0x01; pub const SUBLANG_THAI_THAILAND: ::WORD = 0x01; pub const SUBLANG_TIBETAN_PRC: ::WORD = 0x01; pub const SUBLANG_TIGRIGNA_ERITREA: ::WORD = 0x02; pub const SUBLANG_TIGRINYA_ERITREA: ::WORD = 0x02; pub const SUBLANG_TIGRINYA_ETHIOPIA: ::WORD = 0x01; pub const SUBLANG_TSWANA_BOTSWANA: ::WORD = 0x02; pub const SUBLANG_TSWANA_SOUTH_AFRICA: ::WORD = 0x01; pub const SUBLANG_TURKISH_TURKEY: ::WORD = 0x01; pub const SUBLANG_TURKMEN_TURKMENISTAN: ::WORD = 0x01; pub const SUBLANG_UIGHUR_PRC: ::WORD = 0x01; pub const SUBLANG_UKRAINIAN_UKRAINE: ::WORD = 0x01; pub const SUBLANG_UPPER_SORBIAN_GERMANY: ::WORD = 0x01; pub const SUBLANG_URDU_PAKISTAN: ::WORD = 0x01; pub const SUBLANG_URDU_INDIA: ::WORD = 0x02; pub const SUBLANG_UZBEK_LATIN: ::WORD = 0x01; pub const SUBLANG_UZBEK_CYRILLIC: ::WORD = 0x02; pub const SUBLANG_VALENCIAN_VALENCIA: ::WORD = 0x02; pub const SUBLANG_VIETNAMESE_VIETNAM: ::WORD = 0x01; pub const SUBLANG_WELSH_UNITED_KINGDOM: ::WORD = 0x01; pub const SUBLANG_WOLOF_SENEGAL: ::WORD = 0x01; pub const SUBLANG_XHOSA_SOUTH_AFRICA: ::WORD = 0x01; pub const SUBLANG_YAKUT_RUSSIA: ::WORD = 0x01; pub const SUBLANG_YI_PRC: ::WORD = 0x01; pub const SUBLANG_YORUBA_NIGERIA: ::WORD = 0x01; pub const SUBLANG_ZULU_SOUTH_AFRICA: ::WORD = 0x01; //1962 // FIXME: Once feature(const_fn) or some CTFE alternative becomes stable, MAKELANGID! can go // unless we want to #[macro_export] it ... macro_rules! MAKELANGID { ($p:expr, $s:expr) => ($s << 10 | $p) } pub fn MAKELANGID(p: ::WORD, s: ::WORD) -> ::LANGID { MAKELANGID!(p, s) } pub fn PRIMARYLANGID(lgid: ::LANGID) -> ::WORD { lgid & 0x3ff } pub fn SUBLANGID(lgid: ::LANGID) -> ::WORD { lgid >> 10 } //2019 pub const LANG_SYSTEM_DEFAULT: LANGID = MAKELANGID!(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT); pub const LANG_USER_DEFAULT: LANGID = MAKELANGID!(LANG_NEUTRAL, SUBLANG_DEFAULT); //2214 pub const MAXIMUM_WAIT_OBJECTS: ::DWORD = 64; pub const MAXIMUM_SUSPEND_COUNT: ::CHAR = MAXCHAR; //2277 pub type KSPIN_LOCK = ::ULONG_PTR; pub type PKSPIN_LOCK = *mut KSPIN_LOCK; STRUCT!{struct M128A { // FIXME align 16 Low: ULONGLONG, High: LONGLONG, }} pub type PM128A = *mut M128A; #[cfg(target_arch = "x86")] #[repr(C)] #[derive(Copy)] pub struct XSAVE_FORMAT { // FIXME align 16 pub ControlWord: ::WORD, pub StatusWord: ::WORD, pub TagWord: ::BYTE, pub Reserved1: ::BYTE, pub ErrorOpcode: ::WORD, pub ErrorOffset: ::DWORD, pub ErrorSelector: ::WORD, pub Reserved2: ::WORD, pub DataOffset: ::DWORD, pub DataSelector: ::WORD, pub Reserved3: ::WORD, pub MxCsr: ::DWORD, pub MxCsr_Mask: ::DWORD, pub FloatRegisters: [M128A; 8], pub XmmRegisters: [M128A; 8], pub Reserved4: [::BYTE; 224], } #[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Copy)] pub struct XSAVE_FORMAT { // FIXME align 16 pub ControlWord: ::WORD, pub StatusWord: ::WORD, pub TagWord: ::BYTE, pub Reserved1: ::BYTE, pub ErrorOpcode: ::WORD, pub ErrorOffset: ::DWORD, pub ErrorSelector: ::WORD, pub Reserved2: ::WORD, pub DataOffset: ::DWORD, pub DataSelector: ::WORD, pub Reserved3: ::WORD, pub MxCsr: ::DWORD, pub MxCsr_Mask: ::DWORD, pub FloatRegisters: [M128A; 8], pub XmmRegisters: [M128A; 16], pub Reserved4: [::BYTE; 96], } impl Clone for XSAVE_FORMAT { fn clone(&self) -> XSAVE_FORMAT { *self } } //3563 #[cfg(target_arch = "x86")] pub const SIZE_OF_80387_REGISTERS: usize = 80; #[cfg(target_arch = "x86")] #[repr(C)] #[derive(Copy)] pub struct FLOATING_SAVE_AREA { pub ControlWord: ::DWORD, pub StatusWord: ::DWORD, pub TagWord: ::DWORD, pub ErrorOffset: ::DWORD, pub ErrorSelector: ::DWORD, pub DataOffset: ::DWORD, pub DataSelector: ::DWORD, pub RegisterArea: [::BYTE; SIZE_OF_80387_REGISTERS], pub Spare0: ::DWORD, } #[cfg(target_arch = "x86")] impl Clone for FLOATING_SAVE_AREA { fn clone(&self) -> FLOATING_SAVE_AREA { *self } } #[cfg(target_arch = "x86")] pub type PFLOATING_SAVE_AREA = *mut FLOATING_SAVE_AREA; #[cfg(target_arch = "x86")] pub const MAXIMUM_SUPPORTED_EXTENSION: usize = 512; #[cfg(target_arch = "x86")] #[repr(C)] #[derive(Copy)] pub struct CONTEXT { pub ContextFlags: ::DWORD, pub Dr0: ::DWORD, pub Dr1: ::DWORD, pub Dr2: ::DWORD, pub Dr3: ::DWORD, pub Dr6: ::DWORD, pub Dr7: ::DWORD, pub FloatSave: FLOATING_SAVE_AREA, pub SegGs: ::DWORD, pub SegFs: ::DWORD, pub SegEs: ::DWORD, pub SegDs: ::DWORD, pub Edi: ::DWORD, pub Esi: ::DWORD, pub Ebx: ::DWORD, pub Edx: ::DWORD, pub Ecx: ::DWORD, pub Eax: ::DWORD, pub Ebp: ::DWORD, pub Eip: ::DWORD, pub SegCs: ::DWORD, pub EFlags: ::DWORD, pub Esp: ::DWORD, pub SegSs: ::DWORD, pub ExtendedRegisters: [::BYTE; MAXIMUM_SUPPORTED_EXTENSION], } #[cfg(target_arch = "x86")] impl Clone for CONTEXT { fn clone(&self) -> CONTEXT { *self } } #[cfg(target_arch = "x86_64")] pub type XMM_SAVE_AREA32 = XSAVE_FORMAT; pub type PXMM_SAVE_AREA32 = *mut XSAVE_FORMAT; // FIXME - Align 16 #[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Clone, Copy)] pub struct CONTEXT { pub P1Home: ::DWORD64, pub P2Home: ::DWORD64, pub P3Home: ::DWORD64, pub P4Home: ::DWORD64, pub P5Home: ::DWORD64, pub P6Home: ::DWORD64, pub ContextFlags: ::DWORD, pub MxCsr: ::DWORD, pub SegCs: ::WORD, pub SegDs: ::WORD, pub SegEs: ::WORD, pub SegFs: ::WORD, pub SegGs: ::WORD, pub SegSs: ::WORD, pub EFlags: ::DWORD, pub Dr0: ::DWORD64, pub Dr1: ::DWORD64, pub Dr2: ::DWORD64, pub Dr3: ::DWORD64, pub Dr6: ::DWORD64, pub Dr7: ::DWORD64, pub Rax: ::DWORD64, pub Rcx: ::DWORD64, pub Rdx: ::DWORD64, pub Rbx: ::DWORD64, pub Rsp: ::DWORD64, pub Rbp: ::DWORD64, pub Rsi: ::DWORD64, pub Rdi: ::DWORD64, pub R8: ::DWORD64, pub R9: ::DWORD64, pub R10: ::DWORD64, pub R11: ::DWORD64, pub R12: ::DWORD64, pub R13: ::DWORD64, pub R14: ::DWORD64, pub R15: ::DWORD64, pub Rip: ::DWORD64, pub FltSave: XMM_SAVE_AREA32, pub VectorRegister: [::M128A; 26], pub VectorControl: ::DWORD64, pub DebugControl: ::DWORD64, pub LastBranchToRip: ::DWORD64, pub LastBranchFromRip: ::DWORD64, pub LastExceptionToRip: ::DWORD64, pub LastExceptionFromRip: ::DWORD64, } pub type PCONTEXT = *mut CONTEXT; #[test] fn test_CONTEXT_size() { use std::mem::size_of; if cfg!(target_arch = "x86_64") { assert_eq!(size_of::(), 1232) } else if cfg!(target_arch = "x86") { assert_eq!(size_of::(), 716) } } pub type RUNTIME_FUNCTION = IMAGE_RUNTIME_FUNCTION_ENTRY; pub type PRUNTIME_FUNCTION = *mut RUNTIME_FUNCTION; pub const UNWIND_HISTORY_TABLE_SIZE: usize = 12; STRUCT!{struct UNWIND_HISTORY_TABLE_ENTRY { ImageBase: ::DWORD64, FunctionEntry: PRUNTIME_FUNCTION, }} pub type PUNWIND_HISTORY_TABLE_ENTRY = *mut UNWIND_HISTORY_TABLE_ENTRY; STRUCT!{struct UNWIND_HISTORY_TABLE { Count: ::DWORD, LocalHint: ::BYTE, GlobalHint: ::BYTE, Search: ::BYTE, Once: ::BYTE, LowAddress: ::DWORD64, HighAddress: ::DWORD64, Entry: [UNWIND_HISTORY_TABLE_ENTRY; UNWIND_HISTORY_TABLE_SIZE], }} pub type PUNWIND_HISTORY_TABLE = *mut UNWIND_HISTORY_TABLE; pub type PGET_RUNTIME_FUNCTION_CALLBACK = Option PRUNTIME_FUNCTION>; STRUCT!{struct KNONVOLATILE_CONTEXT_POINTERS_u1 { Xmm0: PM128A, Xmm1: PM128A, Xmm2: PM128A, Xmm3: PM128A, Xmm4: PM128A, Xmm5: PM128A, Xmm6: PM128A, Xmm7: PM128A, Xmm8: PM128A, Xmm9: PM128A, Xmm10: PM128A, Xmm11: PM128A, Xmm12: PM128A, Xmm14: PM128A, Xmm15: PM128A, }} STRUCT!{struct KNONVOLATILE_CONTEXT_POINTERS_u2 { Rax: ::DWORD64, Rcx: ::DWORD64, Rdx: ::DWORD64, Rbx: ::DWORD64, Rsp: ::DWORD64, Rbp: ::DWORD64, Rsi: ::DWORD64, Rdi: ::DWORD64, R8: ::DWORD64, R9: ::DWORD64, R10: ::DWORD64, R11: ::DWORD64, R12: ::DWORD64, R13: ::DWORD64, R14: ::DWORD64, R15: ::DWORD64, }} STRUCT!{struct KNONVOLATILE_CONTEXT_POINTERS { FloatingContext: [PM128A; 16], IntegerContext: [::PDWORD64; 16], }} // FIXME: all unions are untagged UNION!( KNONVOLATILE_CONTEXT_POINTERS, FloatingContext, Xmms, Xmms_mut, KNONVOLATILE_CONTEXT_POINTERS_u1 ); UNION!( KNONVOLATILE_CONTEXT_POINTERS, IntegerContext, Regs, Regs_mut, KNONVOLATILE_CONTEXT_POINTERS_u2 ); pub type PKNONVOLATILE_CONTEXT_POINTERS = *mut KNONVOLATILE_CONTEXT_POINTERS; //8983 pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15; STRUCT!{struct EXCEPTION_RECORD { ExceptionCode: ::DWORD, ExceptionFlags: ::DWORD, ExceptionRecord: *mut EXCEPTION_RECORD, ExceptionAddress: ::PVOID, NumberParameters: ::DWORD, ExceptionInformation: [::ULONG_PTR; EXCEPTION_MAXIMUM_PARAMETERS], }} pub type PEXCEPTION_RECORD = *mut EXCEPTION_RECORD; //9023 STRUCT!{struct EXCEPTION_POINTERS { ExceptionRecord: PEXCEPTION_RECORD, ContextRecord: PCONTEXT, }} pub type PEXCEPTION_POINTERS = *mut EXCEPTION_POINTERS; pub type PACCESS_TOKEN = ::PVOID; pub type PSECURITY_DESCRIPTOR = ::PVOID; pub type PSID = ::PVOID; pub type PCLAIMS_BLOB = ::PVOID; //9091 pub type ACCESS_MASK = ::DWORD; pub type PACCESS_MASK = *mut ACCESS_MASK; pub const DELETE: ::DWORD = 0x00010000; pub const READ_CONTROL: ::DWORD = 0x00020000; pub const WRITE_DAC: ::DWORD = 0x00040000; pub const WRITE_OWNER: ::DWORD = 0x00080000; pub const SYNCHRONIZE: ::DWORD = 0x00100000; pub const STANDARD_RIGHTS_REQUIRED: ::DWORD = 0x000F0000; pub const STANDARD_RIGHTS_READ: ::DWORD = READ_CONTROL; pub const STANDARD_RIGHTS_WRITE: ::DWORD = READ_CONTROL; pub const STANDARD_RIGHTS_EXECUTE: ::DWORD = READ_CONTROL; pub const STANDARD_RIGHTS_ALL: ::DWORD = 0x001F0000; pub const SPECIFIC_RIGHTS_ALL: ::DWORD = 0x0000FFFF; pub const ACCESS_SYSTEM_SECURITY: ::DWORD = 0x01000000; pub const MAXIMUM_ALLOWED: ::DWORD = 0x02000000; pub const GENERIC_READ: ::DWORD = 0x80000000; pub const GENERIC_WRITE: ::DWORD = 0x40000000; pub const GENERIC_EXECUTE: ::DWORD = 0x20000000; pub const GENERIC_ALL: ::DWORD = 0x10000000; //9170 STRUCT!{struct LUID_AND_ATTRIBUTES { Luid: LUID, Attributes: ::DWORD, }} pub type PLUID_AND_ATTRIBUTES = *mut LUID_AND_ATTRIBUTES; //9243 ENUM!{enum SID_NAME_USE { SidTypeUser = 1, SidTypeGroup, SidTypeDomain, SidTypeAlias, SidTypeWellKnownGroup, SidTypeDeletedAccount, SidTypeInvalid, SidTypeUnknown, SidTypeComputer, SidTypeLabel, }} pub type PSID_NAME_USE = *mut SID_NAME_USE; STRUCT!{struct SID_AND_ATTRIBUTES { Sid: PSID, Attributes: ::DWORD, }} pub type PSID_AND_ATTRIBUTES = *mut SID_AND_ATTRIBUTES; //9802 pub const ACL_REVISION: ::BYTE = 2; pub const ACL_REVISION_DS: ::BYTE = 4; pub const ACL_REVISION1: ::BYTE = 1; pub const MIN_ACL_REVISION: ::BYTE = ACL_REVISION2; pub const ACL_REVISION2: ::BYTE = 2; pub const ACL_REVISION3: ::BYTE = 3; pub const ACL_REVISION4: ::BYTE = 4; pub const MAX_ACL_REVISION: ::BYTE = ACL_REVISION4; STRUCT!{struct ACL { AclRevision: ::BYTE, Sbz1: ::BYTE, AclSize: ::WORD, AceCount: ::WORD, Sbz2: ::WORD, }} pub type PACL = *mut ACL; //9888 pub const SE_PRIVILEGE_ENABLED_BY_DEFAULT: ::DWORD = 0x00000001; pub const SE_PRIVILEGE_ENABLED: ::DWORD = 0x00000002; pub const SE_PRIVILEGE_REMOVED: ::DWORD = 0x00000004; pub const SE_PRIVILEGE_USED_FOR_ACCESS: ::DWORD = 0x80000000; pub const SE_PRIVILEGE_VALID_ATTRIBUTES: ::DWORD = SE_PRIVILEGE_ENABLED_BY_DEFAULT | SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_REMOVED | SE_PRIVILEGE_USED_FOR_ACCESS; pub const PRIVILEGE_SET_ALL_NECESSARY: ::DWORD = 1; //10689 pub const TOKEN_ASSIGN_PRIMARY: ::DWORD = 0x0001; pub const TOKEN_DUPLICATE: ::DWORD = 0x0002; pub const TOKEN_IMPERSONATE: ::DWORD = 0x0004; pub const TOKEN_QUERY: ::DWORD = 0x0008; pub const TOKEN_QUERY_SOURCE: ::DWORD = 0x0010; pub const TOKEN_ADJUST_PRIVILEGES: ::DWORD = 0x0020; pub const TOKEN_ADJUST_GROUPS: ::DWORD = 0x0040; pub const TOKEN_ADJUST_DEFAULT: ::DWORD = 0x0080; pub const TOKEN_ADJUST_SESSIONID: ::DWORD = 0x0100; pub const TOKEN_ALL_ACCESS_P: ::DWORD = STANDARD_RIGHTS_REQUIRED | TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_QUERY_SOURCE | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT; pub const TOKEN_ALL_ACCESS: ::DWORD = TOKEN_ALL_ACCESS_P | TOKEN_ADJUST_SESSIONID; pub const TOKEN_READ: ::DWORD = STANDARD_RIGHTS_READ | TOKEN_QUERY; pub const TOKEN_WRITE: ::DWORD = STANDARD_RIGHTS_WRITE | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT; pub const TOKEN_EXECUTE: ::DWORD = STANDARD_RIGHTS_EXECUTE; //10823 #[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct TOKEN_PRIVILEGES { pub PrivilegeCount: ::DWORD, pub Privileges: [LUID_AND_ATTRIBUTES; 0], } pub type PTOKEN_PRIVILEGES = *mut TOKEN_PRIVILEGES; //10965 pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_INVALID: ::WORD = 0x00; pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_INT64: ::WORD = 0x01; pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_UINT64: ::WORD = 0x02; pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_STRING: ::WORD = 0x03; STRUCT!{struct CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE { Version: ::DWORD64, Name: ::PWSTR, }} pub type PCLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE = *mut CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE; pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_FQBN: ::WORD = 0x04; pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_SID: ::WORD = 0x05; pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_BOOLEAN: ::WORD = 0x06; STRUCT!{struct CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE { pValue: ::PVOID, ValueLength: ::DWORD, }} pub type PCLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE = *mut CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE; pub const CLAIM_SECURITY_ATTRIBUTE_TYPE_OCTET_STRING: ::WORD = 0x10; pub const CLAIM_SECURITY_ATTRIBUTE_NON_INHERITABLE: ::DWORD = 0x0001; pub const CLAIM_SECURITY_ATTRIBUTE_VALUE_CASE_SENSITIVE: ::DWORD = 0x0002; pub const CLAIM_SECURITY_ATTRIBUTE_USE_FOR_DENY_ONLY: ::DWORD = 0x0004; pub const CLAIM_SECURITY_ATTRIBUTE_DISABLED_BY_DEFAULT: ::DWORD = 0x0008; pub const CLAIM_SECURITY_ATTRIBUTE_DISABLED: ::DWORD = 0x0010; pub const CLAIM_SECURITY_ATTRIBUTE_MANDATORY: ::DWORD = 0x0020; pub const CLAIM_SECURITY_ATTRIBUTE_VALID_FLAGS: ::DWORD = CLAIM_SECURITY_ATTRIBUTE_NON_INHERITABLE | CLAIM_SECURITY_ATTRIBUTE_VALUE_CASE_SENSITIVE | CLAIM_SECURITY_ATTRIBUTE_USE_FOR_DENY_ONLY | CLAIM_SECURITY_ATTRIBUTE_DISABLED_BY_DEFAULT | CLAIM_SECURITY_ATTRIBUTE_DISABLED | CLAIM_SECURITY_ATTRIBUTE_MANDATORY; pub const CLAIM_SECURITY_ATTRIBUTE_CUSTOM_FLAGS: ::DWORD = 0xFFFF0000; STRUCT!{struct CLAIM_SECURITY_ATTRIBUTE_V1 { Name: ::PWSTR, ValueType: ::WORD, Reserved: ::WORD, Flags: ::DWORD, ValueCount: ::DWORD, // Put data here }} pub type PCLAIM_SECURITY_ATTRIBUTE_V1 = *mut CLAIM_SECURITY_ATTRIBUTE_V1; STRUCT!{struct CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1 { Name: ::DWORD, ValueType: ::WORD, Reserved: ::WORD, Flags: ::DWORD, ValueCount: ::DWORD, // Put array here }} pub type PCLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1 = *mut CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1; pub const CLAIM_SECURITY_ATTRIBUTES_INFORMATION_VERSION_V1: ::WORD = 1; pub const CLAIM_SECURITY_ATTRIBUTES_INFORMATION_VERSION: ::WORD = CLAIM_SECURITY_ATTRIBUTES_INFORMATION_VERSION_V1; STRUCT!{struct CLAIM_SECURITY_ATTRIBUTES_INFORMATION { Version: ::WORD, Reserved: ::WORD, AttributeCount: ::DWORD, pAttributeV1: PCLAIM_SECURITY_ATTRIBUTE_V1, }} pub type PCLAIM_SECURITY_ATTRIBUTES_INFORMATION = *mut CLAIM_SECURITY_ATTRIBUTES_INFORMATION; //11257 pub type SECURITY_INFORMATION = ::DWORD; pub type PSECURITY_INFORMATION = *mut ::DWORD; pub const OWNER_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000001; pub const GROUP_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000002; pub const DACL_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000004; pub const SACL_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000008; pub const LABEL_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000010; pub const ATTRIBUTE_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000020; pub const SCOPE_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000040; pub const PROCESS_TRUST_LABEL_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00000080; pub const BACKUP_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x00010000; pub const PROTECTED_DACL_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x80000000; pub const PROTECTED_SACL_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x40000000; pub const UNPROTECTED_DACL_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x20000000; pub const UNPROTECTED_SACL_SECURITY_INFORMATION: SECURITY_INFORMATION = 0x10000000; ENUM!{enum SE_LEARNING_MODE_DATA_TYPE { SeLearningModeInvalidType = 0, SeLearningModeSettings, SeLearningModeMax, }} STRUCT!{struct SECURITY_CAPABILITIES { AppContainerSid: PSID, Capabilities: PSID_AND_ATTRIBUTES, CapabilityCount: ::DWORD, Reserved: ::DWORD, }} pub type PSECURITY_CAPABILITIES = *mut SECURITY_CAPABILITIES; pub type LPSECURITY_CAPABILITIES = *mut SECURITY_CAPABILITIES; pub const PROCESS_TERMINATE: ::DWORD = 0x0001; pub const PROCESS_CREATE_THREAD: ::DWORD = 0x0002; pub const PROCESS_SET_SESSIONID: ::DWORD = 0x0004; pub const PROCESS_VM_OPERATION: ::DWORD = 0x0008; pub const PROCESS_VM_READ: ::DWORD = 0x0010; pub const PROCESS_VM_WRITE: ::DWORD = 0x0020; pub const PROCESS_DUP_HANDLE: ::DWORD = 0x0040; pub const PROCESS_CREATE_PROCESS: ::DWORD = 0x0080; pub const PROCESS_SET_QUOTA: ::DWORD = 0x0100; pub const PROCESS_SET_INFORMATION: ::DWORD = 0x0200; pub const PROCESS_QUERY_INFORMATION: ::DWORD = 0x0400; pub const PROCESS_SUSPEND_RESUME: ::DWORD = 0x0800; pub const PROCESS_QUERY_LIMITED_INFORMATION: ::DWORD = 0x1000; pub const PROCESS_SET_LIMITED_INFORMATION: ::DWORD = 0x2000; pub const PROCESS_ALL_ACCESS: ::DWORD = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF; //11007 pub const THREAD_BASE_PRIORITY_LOWRT: ::DWORD = 15; pub const THREAD_BASE_PRIORITY_MAX: ::DWORD = 2; pub const THREAD_BASE_PRIORITY_MIN: ::DWORD = -2i32 as ::DWORD; pub const THREAD_BASE_PRIORITY_IDLE: ::DWORD = -15i32 as ::DWORD; //11018 STRUCT!{struct QUOTA_LIMITS { PagedPoolLimit: ::SIZE_T, NonPagedPoolLimit: ::SIZE_T, MinimumWorkingSetSize: ::SIZE_T, MaximumWorkingSetSize: ::SIZE_T, PagefileLimit: ::SIZE_T, TimeLimit: ::LARGE_INTEGER, }} pub type PQUOTA_LIMITS = *mut QUOTA_LIMITS; pub const QUOTA_LIMITS_HARDWS_MIN_ENABLE: ::DWORD = 0x00000001; pub const QUOTA_LIMITS_HARDWS_MIN_DISABLE: ::DWORD = 0x00000002; pub const QUOTA_LIMITS_HARDWS_MAX_ENABLE: ::DWORD = 0x00000004; pub const QUOTA_LIMITS_HARDWS_MAX_DISABLE: ::DWORD = 0x00000008; pub const QUOTA_LIMITS_USE_DEFAULT_LIMITS: ::DWORD = 0x00000010; STRUCT!{struct RATE_QUOTA_LIMIT { RateData: ::DWORD, BitFields: ::DWORD, }} BITFIELD!(RATE_QUOTA_LIMIT BitFields: ::DWORD [ RatePercent set_RatePercent[0..7], Reserved0 set_Reserved0[7..32], ]); pub type PRATE_QUOTA_LIMIT = *mut RATE_QUOTA_LIMIT; STRUCT!{struct QUOTA_LIMITS_EX { PagedPoolLimit: ::SIZE_T, NonPagedPoolLimit: ::SIZE_T, MinimumWorkingSetSize: ::SIZE_T, MaximumWorkingSetSize: ::SIZE_T, PagefileLimit: ::SIZE_T, TimeLimit: ::LARGE_INTEGER, WorkingSetLimit: ::SIZE_T, Reserved2: ::SIZE_T, Reserved3: ::SIZE_T, Reserved4: ::SIZE_T, Flags: ::DWORD, CpuRateLimit: RATE_QUOTA_LIMIT, }} pub type PQUOTA_LIMITS_EX = *mut QUOTA_LIMITS_EX; STRUCT!{struct IO_COUNTERS { ReadOperationCount: ::ULONGLONG, WriteOperationCount: ::ULONGLONG, OtherOperationCount: ::ULONGLONG, ReadTransferCount: ::ULONGLONG, WriteTransferCount: ::ULONGLONG, OtherTransferCount: ::ULONGLONG, }} pub type PIO_COUNTERS = *mut IO_COUNTERS; //11192 STRUCT!{struct JOBOBJECT_BASIC_LIMIT_INFORMATION { PerProcessUserTimeLimit: ::LARGE_INTEGER, PerJobUserTimeLimit: ::LARGE_INTEGER, LimitFlags: ::DWORD, MinimumWorkingSetSize: ::SIZE_T, MaximumWorkingSetSize: ::SIZE_T, ActiveProcessLimit: ::DWORD, Affinity: ::ULONG_PTR, PriorityClass: ::DWORD, SchedulingClass: ::DWORD, }} pub type PJOBOBJECT_BASIC_LIMIT_INFORMATION = *mut JOBOBJECT_BASIC_LIMIT_INFORMATION; STRUCT!{struct JOBOBJECT_EXTENDED_LIMIT_INFORMATION { BasicLimitInformation: JOBOBJECT_BASIC_LIMIT_INFORMATION, IoInfo: IO_COUNTERS, ProcessMemoryLimit: ::SIZE_T, JobMemoryLimit: ::SIZE_T, PeakProcessMemoryUsed: ::SIZE_T, PeakJobMemoryUsed: ::SIZE_T, }} pub type PJOBOBJECT_EXTENDED_LIMIT_INFORMATION = *mut JOBOBJECT_EXTENDED_LIMIT_INFORMATION; #[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct JOBOBJECT_BASIC_PROCESS_ID_LIST { pub NumberOfAssignedProcesses: ::DWORD, pub NumberOfProcessIdsInList: ::DWORD, pub ProcessIdList: [::ULONG_PTR; 0], } pub type PJOBOBJECT_BASIC_PROCESS_ID_LIST = *mut JOBOBJECT_BASIC_PROCESS_ID_LIST; //11712 pub const JOB_OBJECT_TERMINATE_AT_END_OF_JOB: ::DWORD = 0; pub const JOB_OBJECT_POST_AT_END_OF_JOB: ::DWORD = 1; pub const JOB_OBJECT_MSG_END_OF_JOB_TIME: ::DWORD = 1; pub const JOB_OBJECT_MSG_END_OF_PROCESS_TIME: ::DWORD = 2; pub const JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT: ::DWORD = 3; pub const JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO: ::DWORD = 4; pub const JOB_OBJECT_MSG_NEW_PROCESS: ::DWORD = 6; pub const JOB_OBJECT_MSG_EXIT_PROCESS: ::DWORD = 7; pub const JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS: ::DWORD = 8; pub const JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT: ::DWORD = 9; pub const JOB_OBJECT_MSG_JOB_MEMORY_LIMIT: ::DWORD = 10; pub const JOB_OBJECT_MSG_NOTIFICATION_LIMIT: ::DWORD = 11; pub const JOB_OBJECT_MSG_JOB_CYCLE_TIME_LIMIT: ::DWORD = 12; pub const JOB_OBJECT_MSG_MINIMUM: ::DWORD = 1; pub const JOB_OBJECT_MSG_MAXIMUM: ::DWORD = 12; pub const JOB_OBJECT_VALID_COMPLETION_FILTER: ::DWORD = ((1 << (JOB_OBJECT_MSG_MAXIMUM + 1)) - 1) - ((1 << JOB_OBJECT_MSG_MINIMUM) - 1); pub const JOB_OBJECT_LIMIT_WORKINGSET: ::DWORD = 0x00000001; pub const JOB_OBJECT_LIMIT_PROCESS_TIME: ::DWORD = 0x00000002; pub const JOB_OBJECT_LIMIT_JOB_TIME: ::DWORD = 0x00000004; pub const JOB_OBJECT_LIMIT_ACTIVE_PROCESS: ::DWORD = 0x00000008; pub const JOB_OBJECT_LIMIT_AFFINITY: ::DWORD = 0x00000010; pub const JOB_OBJECT_LIMIT_PRIORITY_CLASS: ::DWORD = 0x00000020; pub const JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME: ::DWORD = 0x00000040; pub const JOB_OBJECT_LIMIT_SCHEDULING_CLASS: ::DWORD = 0x00000080; pub const JOB_OBJECT_LIMIT_PROCESS_MEMORY: ::DWORD = 0x00000100; pub const JOB_OBJECT_LIMIT_JOB_MEMORY: ::DWORD = 0x00000200; pub const JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION: ::DWORD = 0x00000400; pub const JOB_OBJECT_LIMIT_BREAKAWAY_OK: ::DWORD = 0x00000800; pub const JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK: ::DWORD = 0x00001000; pub const JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE: ::DWORD = 0x00002000; pub const JOB_OBJECT_LIMIT_SUBSET_AFFINITY: ::DWORD = 0x00004000; pub const JOB_OBJECT_LIMIT_JOB_READ_BYTES: ::DWORD = 0x00010000; pub const JOB_OBJECT_LIMIT_JOB_WRITE_BYTES: ::DWORD = 0x00020000; pub const JOB_OBJECT_LIMIT_RATE_CONTROL: ::DWORD = 0x00040000; pub const JOB_OBJECT_LIMIT_RESERVED3: ::DWORD = 0x00008000; pub const JOB_OBJECT_LIMIT_VALID_FLAGS: ::DWORD = 0x0007ffff; pub const JOB_OBJECT_BASIC_LIMIT_VALID_FLAGS: ::DWORD = 0x000000ff; pub const JOB_OBJECT_EXTENDED_LIMIT_VALID_FLAGS: ::DWORD = 0x00007fff; pub const JOB_OBJECT_NOTIFICATION_LIMIT_VALID_FLAGS: ::DWORD = 0x00070204; pub const JOB_OBJECT_RESERVED_LIMIT_VALID_FLAGS: ::DWORD = 0x0007ffff; pub const JOB_OBJECT_UILIMIT_NONE: ::DWORD = 0x00000000; pub const JOB_OBJECT_UILIMIT_HANDLES: ::DWORD = 0x00000001; pub const JOB_OBJECT_UILIMIT_READCLIPBOARD: ::DWORD = 0x00000002; pub const JOB_OBJECT_UILIMIT_WRITECLIPBOARD: ::DWORD = 0x00000004; pub const JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS: ::DWORD = 0x00000008; pub const JOB_OBJECT_UILIMIT_DISPLAYSETTINGS: ::DWORD = 0x00000010; pub const JOB_OBJECT_UILIMIT_GLOBALATOMS: ::DWORD = 0x00000020; pub const JOB_OBJECT_UILIMIT_DESKTOP: ::DWORD = 0x00000040; pub const JOB_OBJECT_UILIMIT_EXITWINDOWS: ::DWORD = 0x00000080; pub const JOB_OBJECT_UILIMIT_ALL: ::DWORD = 0x000000FF; pub const JOB_OBJECT_UI_VALID_FLAGS: ::DWORD = 0x000000FF; pub const JOB_OBJECT_SECURITY_NO_ADMIN: ::DWORD = 0x00000001; pub const JOB_OBJECT_SECURITY_RESTRICTED_TOKEN: ::DWORD = 0x00000002; pub const JOB_OBJECT_SECURITY_ONLY_TOKEN: ::DWORD = 0x00000004; pub const JOB_OBJECT_SECURITY_FILTER_TOKENS: ::DWORD = 0x00000008; pub const JOB_OBJECT_SECURITY_VALID_FLAGS: ::DWORD = 0x0000000f; pub const JOB_OBJECT_CPU_RATE_CONTROL_ENABLE: ::DWORD = 0x1; pub const JOB_OBJECT_CPU_RATE_CONTROL_WEIGHT_BASED: ::DWORD = 0x2; pub const JOB_OBJECT_CPU_RATE_CONTROL_HARD_CAP: ::DWORD = 0x4; pub const JOB_OBJECT_CPU_RATE_CONTROL_NOTIFY: ::DWORD = 0x8; pub const JOB_OBJECT_CPU_RATE_CONTROL_VALID_FLAGS: ::DWORD = 0xf; ENUM!{enum JOBOBJECTINFOCLASS { JobObjectBasicAccountingInformation = 1, JobObjectBasicLimitInformation, JobObjectBasicProcessIdList, JobObjectBasicUIRestrictions, JobObjectSecurityLimitInformation, JobObjectEndOfJobTimeInformation, JobObjectAssociateCompletionPortInformation, JobObjectBasicAndIoAccountingInformation, JobObjectExtendedLimitInformation, JobObjectJobSetInformation, JobObjectGroupInformation, JobObjectNotificationLimitInformation, JobObjectLimitViolationInformation, JobObjectGroupInformationEx, JobObjectCpuRateControlInformation, JobObjectCompletionFilter, JobObjectCompletionCounter, JobObjectReserved1Information = 18, JobObjectReserved2Information, JobObjectReserved3Information, JobObjectReserved4Information, JobObjectReserved5Information, JobObjectReserved6Information, JobObjectReserved7Information, JobObjectReserved8Information, JobObjectReserved9Information, MaxJobObjectInfoClass, }} //12063 pub const SECTION_QUERY: ::DWORD = 0x0001; pub const SECTION_MAP_WRITE: ::DWORD = 0x0002; pub const SECTION_MAP_READ: ::DWORD = 0x0004; pub const SECTION_MAP_EXECUTE: ::DWORD = 0x0008; pub const SECTION_EXTEND_SIZE: ::DWORD = 0x0010; pub const SECTION_MAP_EXECUTE_EXPLICIT: ::DWORD = 0x0020; pub const SECTION_ALL_ACCESS: ::DWORD = STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE; //12100 pub const PAGE_NOACCESS: ::DWORD = 0x01; pub const PAGE_READONLY: ::DWORD = 0x02; pub const PAGE_READWRITE: ::DWORD = 0x04; pub const PAGE_WRITECOPY: ::DWORD = 0x08; pub const PAGE_EXECUTE: ::DWORD = 0x10; pub const PAGE_EXECUTE_READ: ::DWORD = 0x20; pub const PAGE_EXECUTE_READWRITE: ::DWORD = 0x40; pub const PAGE_EXECUTE_WRITECOPY: ::DWORD = 0x80; pub const PAGE_GUARD: ::DWORD = 0x100; pub const PAGE_NOCACHE: ::DWORD = 0x200; pub const PAGE_WRITECOMBINE: ::DWORD = 0x400; pub const PAGE_REVERT_TO_FILE_MAP: ::DWORD = 0x80000000; pub const PAGE_TARGETS_NO_UPDATE: ::DWORD = 0x40000000; pub const PAGE_TARGETS_INVALID: ::DWORD = 0x40000000; pub const MEM_COMMIT: ::DWORD = 0x1000; pub const MEM_RESERVE: ::DWORD = 0x2000; pub const MEM_DECOMMIT: ::DWORD = 0x4000; pub const MEM_RELEASE: ::DWORD = 0x8000; pub const MEM_FREE: ::DWORD = 0x10000; pub const MEM_PRIVATE: ::DWORD = 0x20000; pub const MEM_MAPPED: ::DWORD = 0x40000; pub const MEM_RESET: ::DWORD = 0x80000; pub const MEM_TOP_DOWN: ::DWORD = 0x100000; pub const MEM_WRITE_WATCH: ::DWORD = 0x200000; pub const MEM_PHYSICAL: ::DWORD = 0x400000; pub const MEM_ROTATE: ::DWORD = 0x800000; pub const MEM_DIFFERENT_IMAGE_BASE_OK: ::DWORD = 0x800000; pub const MEM_RESET_UNDO: ::DWORD = 0x1000000; pub const MEM_LARGE_PAGES: ::DWORD = 0x20000000; pub const MEM_4MB_PAGES: ::DWORD = 0x80000000; pub const SEC_FILE: ::DWORD = 0x800000; pub const SEC_IMAGE: ::DWORD = 0x1000000; pub const SEC_PROTECTED_IMAGE: ::DWORD = 0x2000000; pub const SEC_RESERVE: ::DWORD = 0x4000000; pub const SEC_COMMIT: ::DWORD = 0x8000000; pub const SEC_NOCACHE: ::DWORD = 0x10000000; pub const SEC_WRITECOMBINE: ::DWORD = 0x40000000; pub const SEC_LARGE_PAGES: ::DWORD = 0x80000000; pub const SEC_IMAGE_NO_EXECUTE: ::DWORD = (SEC_IMAGE | SEC_NOCACHE); pub const MEM_IMAGE: ::DWORD = SEC_IMAGE; pub const WRITE_WATCH_FLAG_RESET: ::DWORD = 0x01; pub const MEM_UNMAP_WITH_TRANSIENT_BOOST: ::DWORD = 0x01; //12217 pub const FILE_READ_DATA: ::DWORD = 0x0001; pub const FILE_LIST_DIRECTORY: ::DWORD = 0x0001; pub const FILE_WRITE_DATA: ::DWORD = 0x0002; pub const FILE_ADD_FILE: ::DWORD = 0x0002; pub const FILE_APPEND_DATA: ::DWORD = 0x0004; pub const FILE_ADD_SUBDIRECTORY: ::DWORD = 0x0004; pub const FILE_CREATE_PIPE_INSTANCE: ::DWORD = 0x0004; pub const FILE_READ_EA: ::DWORD = 0x0008; pub const FILE_WRITE_EA: ::DWORD = 0x0010; pub const FILE_EXECUTE: ::DWORD = 0x0020; pub const FILE_TRAVERSE: ::DWORD = 0x0020; pub const FILE_DELETE_CHILD: ::DWORD = 0x0040; pub const FILE_READ_ATTRIBUTES: ::DWORD = 0x0080; pub const FILE_WRITE_ATTRIBUTES: ::DWORD = 0x0100; pub const FILE_ALL_ACCESS: ::DWORD = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF; pub const FILE_GENERIC_READ: ::DWORD = STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE; pub const FILE_GENERIC_WRITE: ::DWORD = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE; pub const FILE_GENERIC_EXECUTE: ::DWORD = STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE; pub const FILE_SHARE_READ: ::DWORD = 0x00000001; pub const FILE_SHARE_WRITE: ::DWORD = 0x00000002; pub const FILE_SHARE_DELETE: ::DWORD = 0x00000004; pub const FILE_ATTRIBUTE_READONLY: ::DWORD = 0x00000001; pub const FILE_ATTRIBUTE_HIDDEN: ::DWORD = 0x00000002; pub const FILE_ATTRIBUTE_SYSTEM: ::DWORD = 0x00000004; pub const FILE_ATTRIBUTE_DIRECTORY: ::DWORD = 0x00000010; pub const FILE_ATTRIBUTE_ARCHIVE: ::DWORD = 0x00000020; pub const FILE_ATTRIBUTE_DEVICE: ::DWORD = 0x00000040; pub const FILE_ATTRIBUTE_NORMAL: ::DWORD = 0x00000080; pub const FILE_ATTRIBUTE_TEMPORARY: ::DWORD = 0x00000100; pub const FILE_ATTRIBUTE_SPARSE_FILE: ::DWORD = 0x00000200; pub const FILE_ATTRIBUTE_REPARSE_POINT: ::DWORD = 0x00000400; pub const FILE_ATTRIBUTE_COMPRESSED: ::DWORD = 0x00000800; pub const FILE_ATTRIBUTE_OFFLINE: ::DWORD = 0x00001000; pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: ::DWORD = 0x00002000; pub const FILE_ATTRIBUTE_ENCRYPTED: ::DWORD = 0x00004000; pub const FILE_ATTRIBUTE_INTEGRITY_STREAM: ::DWORD = 0x00008000; pub const FILE_ATTRIBUTE_VIRTUAL: ::DWORD = 0x00010000; pub const FILE_ATTRIBUTE_NO_SCRUB_DATA: ::DWORD = 0x00020000; pub const FILE_ATTRIBUTE_EA: ::DWORD = 0x00040000; pub const FILE_NOTIFY_CHANGE_FILE_NAME: ::DWORD = 0x00000001; pub const FILE_NOTIFY_CHANGE_DIR_NAME: ::DWORD = 0x00000002; pub const FILE_NOTIFY_CHANGE_ATTRIBUTES: ::DWORD = 0x00000004; pub const FILE_NOTIFY_CHANGE_SIZE: ::DWORD = 0x00000008; pub const FILE_NOTIFY_CHANGE_LAST_WRITE: ::DWORD = 0x00000010; pub const FILE_NOTIFY_CHANGE_LAST_ACCESS: ::DWORD = 0x00000020; pub const FILE_NOTIFY_CHANGE_CREATION: ::DWORD = 0x00000040; pub const FILE_NOTIFY_CHANGE_SECURITY: ::DWORD = 0x00000100; pub const FILE_ACTION_ADDED: ::DWORD = 0x00000001; pub const FILE_ACTION_REMOVED: ::DWORD = 0x00000002; pub const FILE_ACTION_MODIFIED: ::DWORD = 0x00000003; pub const FILE_ACTION_RENAMED_OLD_NAME: ::DWORD = 0x00000004; pub const FILE_ACTION_RENAMED_NEW_NAME: ::DWORD = 0x00000005; pub const MAILSLOT_NO_MESSAGE: ::DWORD = 0xFFFFFFFF; pub const MAILSLOT_WAIT_FOREVER: ::DWORD = 0xFFFFFFFF; pub const FILE_CASE_SENSITIVE_SEARCH: ::DWORD = 0x00000001; pub const FILE_CASE_PRESERVED_NAMES: ::DWORD = 0x00000002; pub const FILE_UNICODE_ON_DISK: ::DWORD = 0x00000004; pub const FILE_PERSISTENT_ACLS: ::DWORD = 0x00000008; pub const FILE_FILE_COMPRESSION: ::DWORD = 0x00000010; pub const FILE_VOLUME_QUOTAS: ::DWORD = 0x00000020; pub const FILE_SUPPORTS_SPARSE_FILES: ::DWORD = 0x00000040; pub const FILE_SUPPORTS_REPARSE_POINTS: ::DWORD = 0x00000080; pub const FILE_SUPPORTS_REMOTE_STORAGE: ::DWORD = 0x00000100; pub const FILE_VOLUME_IS_COMPRESSED: ::DWORD = 0x00008000; pub const FILE_SUPPORTS_OBJECT_IDS: ::DWORD = 0x00010000; pub const FILE_SUPPORTS_ENCRYPTION: ::DWORD = 0x00020000; pub const FILE_NAMED_STREAMS: ::DWORD = 0x00040000; pub const FILE_READ_ONLY_VOLUME: ::DWORD = 0x00080000; pub const FILE_SEQUENTIAL_WRITE_ONCE: ::DWORD = 0x00100000; pub const FILE_SUPPORTS_TRANSACTIONS: ::DWORD = 0x00200000; pub const FILE_SUPPORTS_HARD_LINKS: ::DWORD = 0x00400000; pub const FILE_SUPPORTS_EXTENDED_ATTRIBUTES: ::DWORD = 0x00800000; pub const FILE_SUPPORTS_OPEN_BY_FILE_ID: ::DWORD = 0x01000000; pub const FILE_SUPPORTS_USN_JOURNAL: ::DWORD = 0x02000000; pub const FILE_SUPPORTS_INTEGRITY_STREAMS: ::DWORD = 0x04000000; pub const FILE_INVALID_FILE_ID: ::LONGLONG = -1; STRUCT!{struct FILE_ID_128 { Identifier: [::BYTE; 16], }} pub type PFILE_ID_128 = *mut FILE_ID_128; #[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct FILE_NOTIFY_INFORMATION { pub NextEntryOffset: ::DWORD, pub Action: ::DWORD, pub FileNameLength: ::DWORD, pub FileName: [::WCHAR; 0], } STRUCT!{struct FILE_SEGMENT_ELEMENT { Buffer: ::PVOID64, Alignment: ::ULONGLONG, }} pub type PFILE_SEGMENT_ELEMENT = *mut FILE_SEGMENT_ELEMENT; //12475 pub const IO_REPARSE_TAG_MOUNT_POINT: ::DWORD = 0xA0000003; pub const IO_REPARSE_TAG_HSM: ::DWORD = 0xC0000004; pub const IO_REPARSE_TAG_HSM2: ::DWORD = 0x80000006; pub const IO_REPARSE_TAG_SIS: ::DWORD = 0x80000007; pub const IO_REPARSE_TAG_WIM: ::DWORD = 0x80000008; pub const IO_REPARSE_TAG_CSV: ::DWORD = 0x80000009; pub const IO_REPARSE_TAG_DFS: ::DWORD = 0x8000000A; pub const IO_REPARSE_TAG_SYMLINK: ::DWORD = 0xA000000C; pub const IO_REPARSE_TAG_DFSR: ::DWORD = 0x80000012; pub const IO_REPARSE_TAG_DEDUP: ::DWORD = 0x80000013; pub const IO_REPARSE_TAG_NFS: ::DWORD = 0x80000014; pub const IO_REPARSE_TAG_FILE_PLACEHOLDER: ::DWORD = 0x80000015; pub const IO_REPARSE_TAG_WOF: ::DWORD = 0x80000017; //12788 pub const DUPLICATE_CLOSE_SOURCE: ::DWORD = 0x00000001; pub const DUPLICATE_SAME_ACCESS: ::DWORD = 0x00000002; //14708 STRUCT!{struct PROCESSOR_POWER_POLICY_INFO { TimeCheck: ::DWORD, DemoteLimit: ::DWORD, PromoteLimit: ::DWORD, DemotePercent: ::BYTE, PromotePercent: ::BYTE, Spare: [::BYTE; 2], Reserved: ::DWORD, }} BITFIELD!(PROCESSOR_POWER_POLICY_INFO Reserved: ::DWORD [ AllowDemotion set_AllowDemotion[0..1], AllowPromotion set_AllowPromotion[1..2], ]); pub type PPROCESSOR_POWER_POLICY_INFO = *mut PROCESSOR_POWER_POLICY_INFO; //15000 STRUCT!{struct IMAGE_FILE_HEADER { Machine: ::WORD, NumberOfSections: ::WORD, TimeDateStamp: ::DWORD, PointerToSymbolTable: ::DWORD, NumberOfSymbols: ::DWORD, SizeOfOptionalHeader: ::WORD, Characteristics: ::WORD, }} pub type PIMAGE_FILE_HEADER = *mut IMAGE_FILE_HEADER; pub const IMAGE_SIZEOF_FILE_HEADER: usize = 20; pub const IMAGE_FILE_RELOCS_STRIPPED: ::WORD = 0x0001; pub const IMAGE_FILE_EXECUTABLE_IMAGE: ::WORD = 0x0002; pub const IMAGE_FILE_LINE_NUMS_STRIPPED: ::WORD = 0x0004; pub const IMAGE_FILE_LOCAL_SYMS_STRIPPED: ::WORD = 0x0008; pub const IMAGE_FILE_AGGRESIVE_WS_TRIM: ::WORD = 0x0010; pub const IMAGE_FILE_LARGE_ADDRESS_AWARE: ::WORD = 0x0020; pub const IMAGE_FILE_BYTES_REVERSED_LO: ::WORD = 0x0080; pub const IMAGE_FILE_32BIT_MACHINE: ::WORD = 0x0100; pub const IMAGE_FILE_DEBUG_STRIPPED: ::WORD = 0x0200; pub const IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP: ::WORD = 0x0400; pub const IMAGE_FILE_NET_RUN_FROM_SWAP: ::WORD = 0x0800; pub const IMAGE_FILE_SYSTEM: ::WORD = 0x1000; pub const IMAGE_FILE_DLL: ::WORD = 0x2000; pub const IMAGE_FILE_UP_SYSTEM_ONLY: ::WORD = 0x4000; pub const IMAGE_FILE_BYTES_REVERSED_HI: ::WORD = 0x8000; pub const IMAGE_FILE_MACHINE_UNKNOWN: ::WORD = 0; pub const IMAGE_FILE_MACHINE_I386: ::WORD = 0x014c; pub const IMAGE_FILE_MACHINE_R3000: ::WORD = 0x0162; pub const IMAGE_FILE_MACHINE_R4000: ::WORD = 0x0166; pub const IMAGE_FILE_MACHINE_R10000: ::WORD = 0x0168; pub const IMAGE_FILE_MACHINE_WCEMIPSV2: ::WORD = 0x0169; pub const IMAGE_FILE_MACHINE_ALPHA: ::WORD = 0x0184; pub const IMAGE_FILE_MACHINE_SH3: ::WORD = 0x01a2; pub const IMAGE_FILE_MACHINE_SH3DSP: ::WORD = 0x01a3; pub const IMAGE_FILE_MACHINE_SH3E: ::WORD = 0x01a4; pub const IMAGE_FILE_MACHINE_SH4: ::WORD = 0x01a6; pub const IMAGE_FILE_MACHINE_SH5: ::WORD = 0x01a8; pub const IMAGE_FILE_MACHINE_ARM: ::WORD = 0x01c0; pub const IMAGE_FILE_MACHINE_THUMB: ::WORD = 0x01c2; pub const IMAGE_FILE_MACHINE_ARMNT: ::WORD = 0x01c4; pub const IMAGE_FILE_MACHINE_AM33: ::WORD = 0x01d3; pub const IMAGE_FILE_MACHINE_POWERPC: ::WORD = 0x01F0; pub const IMAGE_FILE_MACHINE_POWERPCFP: ::WORD = 0x01f1; pub const IMAGE_FILE_MACHINE_IA64: ::WORD = 0x0200; pub const IMAGE_FILE_MACHINE_MIPS16: ::WORD = 0x0266; pub const IMAGE_FILE_MACHINE_ALPHA64: ::WORD = 0x0284; pub const IMAGE_FILE_MACHINE_MIPSFPU: ::WORD = 0x0366; pub const IMAGE_FILE_MACHINE_MIPSFPU16: ::WORD = 0x0466; pub const IMAGE_FILE_MACHINE_AXP64: ::WORD = IMAGE_FILE_MACHINE_ALPHA64; pub const IMAGE_FILE_MACHINE_TRICORE: ::WORD = 0x0520; pub const IMAGE_FILE_MACHINE_CEF: ::WORD = 0x0CEF; pub const IMAGE_FILE_MACHINE_EBC: ::WORD = 0x0EBC; pub const IMAGE_FILE_MACHINE_AMD64: ::WORD = 0x8664; pub const IMAGE_FILE_MACHINE_M32R: ::WORD = 0x9041; pub const IMAGE_FILE_MACHINE_CEE: ::WORD = 0xC0EE; STRUCT!{struct IMAGE_DATA_DIRECTORY { VirtualAddress: ::DWORD, Size: ::DWORD, }} pub type PIMAGE_DATA_DIRECTORY = *mut IMAGE_DATA_DIRECTORY; pub const IMAGE_NUMBEROF_DIRECTORY_ENTRIES: usize = 16; STRUCT!{struct IMAGE_OPTIONAL_HEADER32 { Magic: ::WORD, MajorLinkerVersion: ::BYTE, MinorLinkerVersion: ::BYTE, SizeOfCode: ::DWORD, SizeOfInitializedData: ::DWORD, SizeOfUninitializedData: ::DWORD, AddressOfEntryPoint: ::DWORD, BaseOfCode: ::DWORD, BaseOfData: ::DWORD, ImageBase: ::DWORD, SectionAlignment: ::DWORD, FileAlignment: ::DWORD, MajorOperatingSystemVersion: ::WORD, MinorOperatingSystemVersion: ::WORD, MajorImageVersion: ::WORD, MinorImageVersion: ::WORD, MajorSubsystemVersion: ::WORD, MinorSubsystemVersion: ::WORD, Win32VersionValue: ::DWORD, SizeOfImage: ::DWORD, SizeOfHeaders: ::DWORD, CheckSum: ::DWORD, Subsystem: ::WORD, DllCharacteristics: ::WORD, SizeOfStackReserve: ::DWORD, SizeOfStackCommit: ::DWORD, SizeOfHeapReserve: ::DWORD, SizeOfHeapCommit: ::DWORD, LoaderFlags: ::DWORD, NumberOfRvaAndSizes: ::DWORD, DataDirectory: [IMAGE_DATA_DIRECTORY; IMAGE_NUMBEROF_DIRECTORY_ENTRIES], }} pub type PIMAGE_OPTIONAL_HEADER32 = *mut IMAGE_OPTIONAL_HEADER32; STRUCT!{struct IMAGE_ROM_OPTIONAL_HEADER { Magic: ::WORD, MajorLinkerVersion: ::BYTE, MinorLinkerVersion: ::BYTE, SizeOfCode: ::DWORD, SizeOfInitializedData: ::DWORD, SizeOfUninitializedData: ::DWORD, AddressOfEntryPoint: ::DWORD, BaseOfCode: ::DWORD, BaseOfData: ::DWORD, BaseOfBss: ::DWORD, GprMask: ::DWORD, CprMask: [::DWORD; 4], GpValue: ::DWORD, }} pub type PIMAGE_ROM_OPTIONAL_HEADER = *mut IMAGE_ROM_OPTIONAL_HEADER; STRUCT!{struct IMAGE_OPTIONAL_HEADER64 { Magic: ::WORD, MajorLinkerVersion: ::BYTE, MinorLinkerVersion: ::BYTE, SizeOfCode: ::DWORD, SizeOfInitializedData: ::DWORD, SizeOfUninitializedData: ::DWORD, AddressOfEntryPoint: ::DWORD, BaseOfCode: ::DWORD, ImageBase: ::ULONGLONG, SectionAlignment: ::DWORD, FileAlignment: ::DWORD, MajorOperatingSystemVersion: ::WORD, MinorOperatingSystemVersion: ::WORD, MajorImageVersion: ::WORD, MinorImageVersion: ::WORD, MajorSubsystemVersion: ::WORD, MinorSubsystemVersion: ::WORD, Win32VersionValue: ::DWORD, SizeOfImage: ::DWORD, SizeOfHeaders: ::DWORD, CheckSum: ::DWORD, Subsystem: ::WORD, DllCharacteristics: ::WORD, SizeOfStackReserve: ULONGLONG, SizeOfStackCommit: ULONGLONG, SizeOfHeapReserve: ULONGLONG, SizeOfHeapCommit: ULONGLONG, LoaderFlags: ::DWORD, NumberOfRvaAndSizes: ::DWORD, DataDirectory: [IMAGE_DATA_DIRECTORY; IMAGE_NUMBEROF_DIRECTORY_ENTRIES], }} pub type PIMAGE_OPTIONAL_HEADER64 = *mut IMAGE_OPTIONAL_HEADER64; pub const IMAGE_NT_OPTIONAL_HDR32_MAGIC: ::WORD = 0x10b; pub const IMAGE_NT_OPTIONAL_HDR64_MAGIC: ::WORD = 0x20b; pub const IMAGE_ROM_OPTIONAL_HDR_MAGIC: ::WORD = 0x107; #[cfg(target_arch = "x86_64")] pub type IMAGE_OPTIONAL_HEADER = IMAGE_OPTIONAL_HEADER64; #[cfg(target_arch = "x86_64")] pub type PIMAGE_OPTIONAL_HEADER = PIMAGE_OPTIONAL_HEADER64; #[cfg(target_arch = "x86")] pub type IMAGE_OPTIONAL_HEADER = IMAGE_OPTIONAL_HEADER32; #[cfg(target_arch = "x86")] pub type PIMAGE_OPTIONAL_HEADER = PIMAGE_OPTIONAL_HEADER32; STRUCT!{struct IMAGE_NT_HEADERS64 { Signature: ::DWORD, FileHeader: IMAGE_FILE_HEADER, OptionalHeader: IMAGE_OPTIONAL_HEADER64, }} pub type PIMAGE_NT_HEADERS64 = *mut IMAGE_NT_HEADERS64; STRUCT!{struct IMAGE_NT_HEADERS32 { Signature: ::DWORD, FileHeader: IMAGE_FILE_HEADER, OptionalHeader: IMAGE_OPTIONAL_HEADER32, }} pub type PIMAGE_NT_HEADERS32 = *mut IMAGE_NT_HEADERS32; STRUCT!{struct IMAGE_ROM_HEADERS { FileHeader: IMAGE_FILE_HEADER, OptionalHeader: IMAGE_ROM_OPTIONAL_HEADER, }} pub type PIMAGE_ROM_HEADERS = *mut IMAGE_ROM_HEADERS; #[cfg(target_arch = "x86_64")] pub type IMAGE_NT_HEADERS = IMAGE_NT_HEADERS64; #[cfg(target_arch = "x86_64")] pub type PIMAGE_NT_HEADERS = PIMAGE_NT_HEADERS64; #[cfg(target_arch = "x86")] pub type IMAGE_NT_HEADERS = IMAGE_NT_HEADERS32; #[cfg(target_arch = "x86")] pub type PIMAGE_NT_HEADERS = PIMAGE_NT_HEADERS32; pub const IMAGE_SUBSYSTEM_UNKNOWN: ::WORD = 0; pub const IMAGE_SUBSYSTEM_NATIVE: ::WORD = 1; pub const IMAGE_SUBSYSTEM_WINDOWS_GUI: ::WORD = 2; pub const IMAGE_SUBSYSTEM_WINDOWS_CUI: ::WORD = 3; pub const IMAGE_SUBSYSTEM_OS2_CUI: ::WORD = 5; pub const IMAGE_SUBSYSTEM_POSIX_CUI: ::WORD = 7; pub const IMAGE_SUBSYSTEM_NATIVE_WINDOWS: ::WORD = 8; pub const IMAGE_SUBSYSTEM_WINDOWS_CE_GUI: ::WORD = 9; pub const IMAGE_SUBSYSTEM_EFI_APPLICATION: ::WORD = 10; pub const IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER: ::WORD = 11; pub const IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER: ::WORD = 12; pub const IMAGE_SUBSYSTEM_EFI_ROM: ::WORD = 13; pub const IMAGE_SUBSYSTEM_XBOX: ::WORD = 14; pub const IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION: ::WORD = 16; pub const IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA: ::WORD = 0x0020; pub const IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE: ::WORD = 0x0040; pub const IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY: ::WORD = 0x0080; pub const IMAGE_DLLCHARACTERISTICS_NX_COMPAT: ::WORD = 0x0100; pub const IMAGE_DLLCHARACTERISTICS_NO_ISOLATION: ::WORD = 0x0200; pub const IMAGE_DLLCHARACTERISTICS_NO_SEH: ::WORD = 0x0400; pub const IMAGE_DLLCHARACTERISTICS_NO_BIND: ::WORD = 0x0800; pub const IMAGE_DLLCHARACTERISTICS_APPCONTAINER: ::WORD = 0x1000; pub const IMAGE_DLLCHARACTERISTICS_WDM_DRIVER: ::WORD = 0x2000; pub const IMAGE_DLLCHARACTERISTICS_GUARD_CF: ::WORD = 0x4000; pub const IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE: ::WORD = 0x8000; pub const IMAGE_DIRECTORY_ENTRY_EXPORT: ::WORD = 0; pub const IMAGE_DIRECTORY_ENTRY_IMPORT: ::WORD = 1; pub const IMAGE_DIRECTORY_ENTRY_RESOURCE: ::WORD = 2; pub const IMAGE_DIRECTORY_ENTRY_EXCEPTION: ::WORD = 3; pub const IMAGE_DIRECTORY_ENTRY_SECURITY: ::WORD = 4; pub const IMAGE_DIRECTORY_ENTRY_BASERELOC: ::WORD = 5; pub const IMAGE_DIRECTORY_ENTRY_DEBUG: ::WORD = 6; pub const IMAGE_DIRECTORY_ENTRY_ARCHITECTURE: ::WORD = 7; pub const IMAGE_DIRECTORY_ENTRY_GLOBALPTR: ::WORD = 8; pub const IMAGE_DIRECTORY_ENTRY_TLS: ::WORD = 9; pub const IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG: ::WORD = 10; pub const IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT: ::WORD = 11; pub const IMAGE_DIRECTORY_ENTRY_IAT: ::WORD = 12; pub const IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT: ::WORD = 13; pub const IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR: ::WORD = 14; STRUCT!{struct ANON_OBJECT_HEADER { Sig1: ::WORD, Sig2: ::WORD, Version: ::WORD, Machine: ::WORD, TimeDateStamp: ::DWORD, ClassID: ::CLSID, SizeOfData: ::DWORD, }} STRUCT!{struct ANON_OBJECT_HEADER_V2 { Sig1: ::WORD, Sig2: ::WORD, Version: ::WORD, Machine: ::WORD, TimeDateStamp: ::DWORD, ClassID: ::CLSID, SizeOfData: ::DWORD, Flags: ::DWORD, MetaDataSize: ::DWORD, MetaDataOffset: ::DWORD, }} STRUCT!{struct ANON_OBJECT_HEADER_BIGOBJ { Sig1: ::WORD, Sig2: ::WORD, Version: ::WORD, Machine: ::WORD, TimeDateStamp: ::DWORD, ClassID: ::CLSID, SizeOfData: ::DWORD, Flags: ::DWORD, MetaDataSize: ::DWORD, MetaDataOffset: ::DWORD, NumberOfSections: ::DWORD, PointerToSymbolTable: ::DWORD, NumberOfSymbols: ::DWORD, }} pub const IMAGE_SIZEOF_SHORT_NAME: usize = 8; STRUCT!{struct IMAGE_SECTION_HEADER { Name: [::BYTE; IMAGE_SIZEOF_SHORT_NAME], PhysicalAddressOrVirtualSize: ::DWORD, VirtualAddress: ::DWORD, SizeOfRawData: ::DWORD, PointerToRawData: ::DWORD, PointerToRelocations: ::DWORD, PointerToLinenumbers: ::DWORD, NumberOfRelocations: ::WORD, NumberOfLinenumbers: ::WORD, Characteristics: ::DWORD, }} pub type PIMAGE_SECTION_HEADER = *mut IMAGE_SECTION_HEADER; pub const IMAGE_SIZEOF_SECTION_HEADER: usize = 40; pub const IMAGE_SCN_TYPE_NO_PAD: ::DWORD = 0x00000008; pub const IMAGE_SCN_CNT_CODE: ::DWORD = 0x00000020; pub const IMAGE_SCN_CNT_INITIALIZED_DATA: ::DWORD = 0x00000040; pub const IMAGE_SCN_CNT_UNINITIALIZED_DATA: ::DWORD = 0x00000080; pub const IMAGE_SCN_LNK_OTHER: ::DWORD = 0x00000100; pub const IMAGE_SCN_LNK_INFO: ::DWORD = 0x00000200; pub const IMAGE_SCN_LNK_REMOVE: ::DWORD = 0x00000800; pub const IMAGE_SCN_LNK_COMDAT: ::DWORD = 0x00001000; pub const IMAGE_SCN_NO_DEFER_SPEC_EXC: ::DWORD = 0x00004000; pub const IMAGE_SCN_GPREL: ::DWORD = 0x00008000; pub const IMAGE_SCN_MEM_FARDATA: ::DWORD = 0x00008000; pub const IMAGE_SCN_MEM_PURGEABLE: ::DWORD = 0x00020000; pub const IMAGE_SCN_MEM_16BIT: ::DWORD = 0x00020000; pub const IMAGE_SCN_MEM_LOCKED: ::DWORD = 0x00040000; pub const IMAGE_SCN_MEM_PRELOAD: ::DWORD = 0x00080000; pub const IMAGE_SCN_ALIGN_1BYTES: ::DWORD = 0x00100000; pub const IMAGE_SCN_ALIGN_2BYTES: ::DWORD = 0x00200000; pub const IMAGE_SCN_ALIGN_4BYTES: ::DWORD = 0x00300000; pub const IMAGE_SCN_ALIGN_8BYTES: ::DWORD = 0x00400000; pub const IMAGE_SCN_ALIGN_16BYTES: ::DWORD = 0x00500000; pub const IMAGE_SCN_ALIGN_32BYTES: ::DWORD = 0x00600000; pub const IMAGE_SCN_ALIGN_64BYTES: ::DWORD = 0x00700000; pub const IMAGE_SCN_ALIGN_128BYTES: ::DWORD = 0x00800000; pub const IMAGE_SCN_ALIGN_256BYTES: ::DWORD = 0x00900000; pub const IMAGE_SCN_ALIGN_512BYTES: ::DWORD = 0x00A00000; pub const IMAGE_SCN_ALIGN_1024BYTES: ::DWORD = 0x00B00000; pub const IMAGE_SCN_ALIGN_2048BYTES: ::DWORD = 0x00C00000; pub const IMAGE_SCN_ALIGN_4096BYTES: ::DWORD = 0x00D00000; pub const IMAGE_SCN_ALIGN_8192BYTES: ::DWORD = 0x00E00000; pub const IMAGE_SCN_ALIGN_MASK: ::DWORD = 0x00F00000; pub const IMAGE_SCN_LNK_NRELOC_OVFL: ::DWORD = 0x01000000; pub const IMAGE_SCN_MEM_DISCARDABLE: ::DWORD = 0x02000000; pub const IMAGE_SCN_MEM_NOT_CACHED: ::DWORD = 0x04000000; pub const IMAGE_SCN_MEM_NOT_PAGED: ::DWORD = 0x08000000; pub const IMAGE_SCN_MEM_SHARED: ::DWORD = 0x10000000; pub const IMAGE_SCN_MEM_EXECUTE: ::DWORD = 0x20000000; pub const IMAGE_SCN_MEM_READ: ::DWORD = 0x40000000; pub const IMAGE_SCN_MEM_WRITE: ::DWORD = 0x80000000; pub const IMAGE_SCN_SCALE_INDEX: ::DWORD = 0x00000001; //16590 STRUCT!{struct IMAGE_DEBUG_DIRECTORY { Characteristics: ::DWORD, TimeDateStamp: ::DWORD, MajorVersion: ::WORD, MinorVersion: ::WORD, Type: ::DWORD, SizeOfData: ::DWORD, AddressOfRawData: ::DWORD, PointerToRawData: ::DWORD, }} pub type PIMAGE_DEBUG_DIRECTORY = *mut IMAGE_DEBUG_DIRECTORY; pub const IMAGE_DEBUG_TYPE_UNKNOWN: ::DWORD = 0; pub const IMAGE_DEBUG_TYPE_COFF: ::DWORD = 1; pub const IMAGE_DEBUG_TYPE_CODEVIEW: ::DWORD = 2; pub const IMAGE_DEBUG_TYPE_FPO: ::DWORD = 3; pub const IMAGE_DEBUG_TYPE_MISC: ::DWORD = 4; pub const IMAGE_DEBUG_TYPE_EXCEPTION: ::DWORD = 5; pub const IMAGE_DEBUG_TYPE_FIXUP: ::DWORD = 6; pub const IMAGE_DEBUG_TYPE_OMAP_TO_SRC: ::DWORD = 7; pub const IMAGE_DEBUG_TYPE_OMAP_FROM_SRC: ::DWORD = 8; pub const IMAGE_DEBUG_TYPE_BORLAND: ::DWORD = 9; pub const IMAGE_DEBUG_TYPE_RESERVED10: ::DWORD = 10; pub const IMAGE_DEBUG_TYPE_CLSID: ::DWORD = 11; STRUCT!{struct IMAGE_COFF_SYMBOLS_HEADER { NumberOfSymbols: ::DWORD, LvaToFirstSymbol: ::DWORD, NumberOfLinenumbers: ::DWORD, LvaToFirstLinenumber: ::DWORD, RvaToFirstByteOfCode: ::DWORD, RvaToLastByteOfCode: ::DWORD, RvaToFirstByteOfData: ::DWORD, RvaToLastByteOfData: ::DWORD, }} pub type PIMAGE_COFF_SYMBOLS_HEADER = *mut IMAGE_COFF_SYMBOLS_HEADER; STRUCT!{struct IMAGE_RUNTIME_FUNCTION_ENTRY { BeginAddress: ::DWORD, EndAddress: ::DWORD, UnwindInfoAddress: ::DWORD, }} UNION!(IMAGE_RUNTIME_FUNCTION_ENTRY, UnwindInfoAddress, UnwindData, UnwindData_mut, ::DWORD); pub type PIMAGE_RUNTIME_FUNCTION_ENTRY = *mut IMAGE_RUNTIME_FUNCTION_ENTRY; pub const FRAME_FPO: ::WORD = 0; pub const FRAME_TRAP: ::WORD = 1; pub const FRAME_TSS: ::WORD = 2; pub const FRAME_NONFPO: ::WORD = 3; STRUCT!{struct FPO_DATA { ulOffStart: ::DWORD, cbProcSize: ::DWORD, cdwLocals: ::DWORD, cdwParams: ::WORD, bitfield: ::WORD, }} pub type PFPO_DATA = *mut FPO_DATA; pub const SIZEOF_RFPO_DATA: usize = 16; pub const IMAGE_DEBUG_MISC_EXENAME: ::DWORD = 1; STRUCT!{struct IMAGE_DEBUG_MISC { DataType: ::DWORD, Length: ::DWORD, Unicode: ::BOOLEAN, Reserved: [::BYTE; 3], Data: [::BYTE; 0], }} pub type PIMAGE_DEBUG_MISC = *mut IMAGE_DEBUG_MISC; STRUCT!{struct IMAGE_FUNCTION_ENTRY { StartingAddress: ::DWORD, EndingAddress: ::DWORD, EndOfPrologue: ::DWORD, }} pub type PIMAGE_FUNCTION_ENTRY = *mut IMAGE_FUNCTION_ENTRY; STRUCT!{struct IMAGE_FUNCTION_ENTRY64 { StartingAddress: ::ULONGLONG, EndingAddress: ::ULONGLONG, EndOfPrologueOrUnwindInfoAddress: ::ULONGLONG, }} pub type PIMAGE_FUNCTION_ENTRY64 = *mut IMAGE_FUNCTION_ENTRY64; //18245 pub const HEAP_NO_SERIALIZE: ::DWORD = 0x00000001; pub const HEAP_GROWABLE: ::DWORD = 0x00000002; pub const HEAP_GENERATE_EXCEPTIONS: ::DWORD = 0x00000004; pub const HEAP_ZERO_MEMORY: ::DWORD = 0x00000008; pub const HEAP_REALLOC_IN_PLACE_ONLY: ::DWORD = 0x00000010; pub const HEAP_TAIL_CHECKING_ENABLED: ::DWORD = 0x00000020; pub const HEAP_FREE_CHECKING_ENABLED: ::DWORD = 0x00000040; pub const HEAP_DISABLE_COALESCE_ON_FREE: ::DWORD = 0x00000080; pub const HEAP_CREATE_ALIGN_16: ::DWORD = 0x00010000; pub const HEAP_CREATE_ENABLE_TRACING: ::DWORD = 0x00020000; pub const HEAP_CREATE_ENABLE_EXECUTE: ::DWORD = 0x00040000; pub const HEAP_MAXIMUM_TAG: ::DWORD = 0x0FFF; pub const HEAP_PSEUDO_TAG_FLAG: ::DWORD = 0x8000; pub const HEAP_TAG_SHIFT: ::DWORD = 18; //18145 STRUCT!{struct RTL_CRITICAL_SECTION_DEBUG { Type: ::WORD, CreatorBackTraceIndex: ::WORD, CriticalSection: *mut ::RTL_CRITICAL_SECTION, ProcessLocksList: ::LIST_ENTRY, EntryCount: ::DWORD, ContentionCount: ::DWORD, Flags: ::DWORD, CreatorBackTraceIndexHigh: ::WORD, SpareWORD: ::WORD, }} pub type PRTL_CRITICAL_SECTION_DEBUG = *mut RTL_CRITICAL_SECTION_DEBUG; pub type RTL_RESOURCE_DEBUG = RTL_CRITICAL_SECTION_DEBUG; pub type PRTL_RESOURCE_DEBUG = *mut RTL_CRITICAL_SECTION_DEBUG; pub const RTL_CRITSECT_TYPE: ::WORD = 0; pub const RTL_RESOURCE_TYPE: ::WORD = 1; pub const RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO: ::ULONG_PTR = 0x01000000; pub const RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN: ::ULONG_PTR = 0x02000000; pub const RTL_CRITICAL_SECTION_FLAG_STATIC_INIT: ::ULONG_PTR = 0x04000000; pub const RTL_CRITICAL_SECTION_FLAG_RESOURCE_TYPE: ::ULONG_PTR = 0x08000000; pub const RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO: ::ULONG_PTR = 0x10000000; pub const RTL_CRITICAL_SECTION_ALL_FLAG_BITS: ::ULONG_PTR = 0xFF000000; pub const RTL_CRITICAL_SECTION_FLAG_RESERVED: ::ULONG_PTR = RTL_CRITICAL_SECTION_ALL_FLAG_BITS & !(RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO | RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN | RTL_CRITICAL_SECTION_FLAG_STATIC_INIT | RTL_CRITICAL_SECTION_FLAG_RESOURCE_TYPE | RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO); pub const RTL_CRITICAL_SECTION_DEBUG_FLAG_STATIC_INIT: ::DWORD = 0x00000001; STRUCT!{struct RTL_CRITICAL_SECTION { DebugInfo: ::PRTL_CRITICAL_SECTION_DEBUG, LockCount: ::LONG, RecursionCount: ::LONG, OwningThread: ::HANDLE, LockSemaphore: ::HANDLE, SpinCount: ::ULONG_PTR, }} pub type PRTL_CRITICAL_SECTION = *mut RTL_CRITICAL_SECTION; STRUCT!{struct RTL_SRWLOCK { Ptr: ::PVOID, }} pub type PRTL_SRWLOCK = *mut RTL_SRWLOCK; pub const RTL_SRWLOCK_INIT: RTL_SRWLOCK = RTL_SRWLOCK { Ptr: 0 as PVOID }; STRUCT!{struct RTL_CONDITION_VARIABLE { Ptr: ::PVOID, }} pub type PRTL_CONDITION_VARIABLE = *mut RTL_CONDITION_VARIABLE; pub const RTL_CONDITION_VARIABLE_INIT: RTL_CONDITION_VARIABLE = RTL_CONDITION_VARIABLE { Ptr: 0 as PVOID }; //18204 pub type PAPCFUNC = Option; pub type PVECTORED_EXCEPTION_HANDLER = Option ::LONG>; ENUM!{enum HEAP_INFORMATION_CLASS { HeapCompatibilityInformation = 0, HeapEnableTerminationOnCorruption = 1, HeapOptimizeResources = 3, }} //pub use self::HEAP_INFORMATION_CLASS::*; pub const HEAP_OPTIMIZE_RESOURCES_CURRENT_VERSION: ::DWORD = 1; STRUCT!{struct HEAP_OPTIMIZE_RESOURCES_INFORMATION { Version: ::DWORD, Flags: ::DWORD, }} pub type PHEAP_OPTIMIZE_RESOURCES_INFORMATION = *mut HEAP_OPTIMIZE_RESOURCES_INFORMATION; pub const WT_EXECUTEDEFAULT: ::ULONG = 0x00000000; pub const WT_EXECUTEINIOTHREAD: ::ULONG = 0x00000001; pub const WT_EXECUTEINUITHREAD: ::ULONG = 0x00000002; pub const WT_EXECUTEINWAITTHREAD: ::ULONG = 0x00000004; pub const WT_EXECUTEONLYONCE: ::ULONG = 0x00000008; pub const WT_EXECUTEINTIMERTHREAD: ::ULONG = 0x00000020; pub const WT_EXECUTELONGFUNCTION: ::ULONG = 0x00000010; pub const WT_EXECUTEINPERSISTENTIOTHREAD: ::ULONG = 0x00000040; pub const WT_EXECUTEINPERSISTENTTHREAD: ::ULONG = 0x00000080; pub const WT_TRANSFER_IMPERSONATION: ::ULONG = 0x00000100; pub type WAITORTIMERCALLBACKFUNC = Option; pub type WORKERCALLBACKFUNC = Option; pub type APC_CALLBACK_FUNCTION = Option; pub type WAITORTIMERCALLBACK = WAITORTIMERCALLBACKFUNC; pub type PFLS_CALLBACK_FUNCTION = Option; pub type PSECURE_MEMORY_CACHE_CALLBACK = Option ::BOOLEAN>; pub const WT_EXECUTEINLONGTHREAD: ::ULONG = 0x00000010; pub const WT_EXECUTEDELETEWAIT: ::ULONG = 0x00000008; //18570 pub const KEY_QUERY_VALUE: ::REGSAM = 0x0001; pub const KEY_SET_VALUE: ::REGSAM = 0x0002; pub const KEY_CREATE_SUB_KEY: ::REGSAM = 0x0004; pub const KEY_ENUMERATE_SUB_KEYS: ::REGSAM = 0x0008; pub const KEY_NOTIFY: ::REGSAM = 0x0010; pub const KEY_CREATE_LINK: ::REGSAM = 0x0020; pub const KEY_WOW64_32KEY: ::REGSAM = 0x0200; pub const KEY_WOW64_64KEY: ::REGSAM = 0x0100; pub const KEY_WOW64_RES: ::REGSAM = 0x0300; pub const KEY_READ: ::REGSAM = ( STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY ) & (!SYNCHRONIZE); pub const KEY_WRITE: ::REGSAM = (STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & (!SYNCHRONIZE); pub const KEY_EXECUTE: ::REGSAM = KEY_READ & (!SYNCHRONIZE); pub const KEY_ALL_ACCESS: ::REGSAM = ( STANDARD_RIGHTS_ALL | KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK ) & (!SYNCHRONIZE); pub const REG_CREATED_NEW_KEY: ::DWORD = 0x00000001; pub const REG_OPENED_EXISTING_KEY: ::DWORD = 0x00000002; pub const REG_NOTIFY_CHANGE_NAME: ::DWORD = 0x00000001; pub const REG_NOTIFY_CHANGE_ATTRIBUTES: ::DWORD = 0x00000002; pub const REG_NOTIFY_CHANGE_LAST_SET: ::DWORD = 0x00000004; pub const REG_NOTIFY_CHANGE_SECURITY: ::DWORD = 0x00000008; pub const REG_LEGAL_CHANGE_FILTER: ::DWORD = REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_ATTRIBUTES | REG_NOTIFY_CHANGE_LAST_SET | REG_NOTIFY_CHANGE_SECURITY; pub const REG_NOTIFY_THREAD_AGNOSTIC: ::DWORD = 0x10000000; //supported only on Windows 8 and later pub const REG_OPTION_RESERVED: ::DWORD = 0x00000000; pub const REG_OPTION_NON_VOLATILE: ::DWORD = 0x00000000; pub const REG_OPTION_VOLATILE: ::DWORD = 0x00000001; pub const REG_OPTION_CREATE_LINK: ::DWORD = 0x00000002; pub const REG_OPTION_BACKUP_RESTORE: ::DWORD = 0x00000004; pub const REG_OPTION_OPEN_LINK: ::DWORD = 0x00000008; pub const REG_NONE: ::DWORD = 0; pub const REG_SZ: ::DWORD = 1; pub const REG_EXPAND_SZ: ::DWORD = 2; pub const REG_BINARY: ::DWORD = 3; pub const REG_DWORD: ::DWORD = 4; pub const REG_DWORD_LITTLE_ENDIAN: ::DWORD = 4; pub const REG_DWORD_BIG_ENDIAN: ::DWORD = 5; pub const REG_LINK: ::DWORD = 6; pub const REG_MULTI_SZ: ::DWORD = 7; pub const REG_RESOURCE_LIST: ::DWORD = 8; pub const REG_FULL_RESOURCE_DESCRIPTOR: ::DWORD = 9; pub const REG_RESOURCE_REQUIREMENTS_LIST: ::DWORD = 10; pub const REG_QWORD: ::DWORD = 11; pub const REG_QWORD_LITTLE_ENDIAN: ::DWORD = 11; //18720 pub const SERVICE_KERNEL_DRIVER: ::DWORD = 0x00000001; pub const SERVICE_FILE_SYSTEM_DRIVER: ::DWORD = 0x00000002; pub const SERVICE_ADAPTER: ::DWORD = 0x00000004; pub const SERVICE_RECOGNIZER_DRIVER: ::DWORD = 0x00000008; pub const SERVICE_DRIVER: ::DWORD = SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | SERVICE_RECOGNIZER_DRIVER; pub const SERVICE_WIN32_OWN_PROCESS: ::DWORD = 0x00000010; pub const SERVICE_WIN32_SHARE_PROCESS: ::DWORD = 0x00000020; pub const SERVICE_WIN32: ::DWORD = SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS; pub const SERVICE_INTERACTIVE_PROCESS: ::DWORD = 0x00000100; pub const SERVICE_TYPE_ALL: ::DWORD = SERVICE_WIN32 | SERVICE_ADAPTER | SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS; STRUCT!{struct TP_CALLBACK_INSTANCE { dummy: *mut ::c_void, }} pub type PTP_CALLBACK_INSTANCE = *mut TP_CALLBACK_INSTANCE; STRUCT!{struct TP_IO { dummy: *mut ::c_void, }} pub type PTP_IO = *mut TP_IO; STRUCT!{struct TP_POOL { dummy: *mut ::c_void, }} pub type PTP_POOL = *mut TP_POOL; STRUCT!{struct TP_CLEANUP_GROUP { dummy: *mut ::c_void, }} pub type PTP_CLEANUP_GROUP = *mut TP_CLEANUP_GROUP; STRUCT!{struct TP_TIMER { dummy: *mut ::c_void, }} pub type PTP_TIMER = *mut TP_TIMER; STRUCT!{struct TP_WAIT { dummy: *mut ::c_void, }} pub type PTP_WAIT = *mut TP_WAIT; STRUCT!{struct TP_WORK { dummy: *mut ::c_void, }} pub type PTP_WORK = *mut TP_WORK; STRUCT!{struct ACTIVATION_CONTEXT { dummy: *mut ::c_void, }} ENUM!{enum TP_CALLBACK_PRIORITY { TP_CALLBACK_PRIORITY_HIGH, TP_CALLBACK_PRIORITY_NORMAL, TP_CALLBACK_PRIORITY_LOW, TP_CALLBACK_PRIORITY_INVALID, TP_CALLBACK_PRIORITY_COUNT = 4, }} pub type PTP_CLEANUP_GROUP_CANCEL_CALLBACK = Option; pub type PTP_SIMPLE_CALLBACK = Option; pub type PTP_WORK_CALLBACK = Option; pub type PTP_TIMER_CALLBACK = Option; pub type TP_WAIT_RESULT = ::DWORD; pub type PTP_WAIT_CALLBACK = Option; pub type TP_VERSION = ::DWORD; pub type PTP_VERSION = *mut ::DWORD; STRUCT!{struct TP_POOL_STACK_INFORMATION { StackReserve: ::SIZE_T, StackCommit: ::SIZE_T, }} pub type PTP_POOL_STACK_INFORMATION = *mut TP_POOL_STACK_INFORMATION; STRUCT!{struct TP_CALLBACK_ENVIRON_V3_s { BitFields: ::DWORD, }} BITFIELD!(TP_CALLBACK_ENVIRON_V3_s BitFields: ::DWORD [ LongFunction set_LongFunction[0..1], Persistent set_Persistent[1..2], Private set_Private[2..32], ]); #[repr(C)] #[derive(Copy)] pub struct TP_CALLBACK_ENVIRON_V3 { pub Version: TP_VERSION, pub Pool: PTP_POOL, pub CleanupGroup: PTP_CLEANUP_GROUP, pub CleanupGroupCancelCallback: PTP_CLEANUP_GROUP_CANCEL_CALLBACK, pub RaceDll: ::PVOID, pub ActivationContext: *mut ACTIVATION_CONTEXT, pub FinalizationCallback: PTP_SIMPLE_CALLBACK, pub u: ::DWORD, pub CallbackPriority: TP_CALLBACK_PRIORITY, pub Size: ::DWORD, } impl Clone for TP_CALLBACK_ENVIRON_V3 { fn clone(&self) -> TP_CALLBACK_ENVIRON_V3 { *self } } UNION!(TP_CALLBACK_ENVIRON_V3, u, Flags, Flags_mut, ::DWORD); UNION!(TP_CALLBACK_ENVIRON_V3, u, s, s_mut, TP_CALLBACK_ENVIRON_V3_s); pub type TP_CALLBACK_ENVIRON = TP_CALLBACK_ENVIRON_V3; pub type PTP_CALLBACK_ENVIRON = *mut TP_CALLBACK_ENVIRON_V3; STRUCT!{struct JOB_SET_ARRAY { JobHandle: ::HANDLE, MemberLevel: ::DWORD, Flags: ::DWORD, }} pub type PJOB_SET_ARRAY = *mut JOB_SET_ARRAY; STRUCT!{struct RTL_BARRIER { Reserved1: ::DWORD, Reserved2: ::DWORD, Reserved3: [::ULONG_PTR; 2], Reserved4: ::DWORD, Reserved5: ::DWORD, }} pub type PRTL_BARRIER = *mut RTL_BARRIER; STRUCT!{struct RTL_RUN_ONCE { Ptr: ::PVOID, }} pub type PRTL_RUN_ONCE = *mut RTL_RUN_ONCE; ENUM!{enum RTL_UMS_THREAD_INFO_CLASS { UmsThreadInvalidInfoClass = 0, UmsThreadUserContext, UmsThreadPriority, // Reserved UmsThreadAffinity, // Reserved UmsThreadTeb, UmsThreadIsSuspended, UmsThreadIsTerminated, UmsThreadMaxInfoClass, }} ENUM!{enum RTL_UMS_SCHEDULER_REASON { UmsSchedulerStartup = 0, UmsSchedulerThreadBlocked, UmsSchedulerThreadYield, }} pub type PRTL_UMS_SCHEDULER_ENTRY_POINT = Option; ENUM!{enum FIRMWARE_TYPE { FirmwareTypeUnknown, FirmwareTypeBios, FirmwareTypeUefi, FirmwareTypeMax, }} pub type PFIRMWARE_TYPE = *mut FIRMWARE_TYPE; ENUM!{enum LOGICAL_PROCESSOR_RELATIONSHIP { RelationProcessorCore, RelationNumaNode, RelationCache, RelationProcessorPackage, RelationGroup, RelationAll = 0xffff, }} ENUM!{enum PROCESSOR_CACHE_TYPE { CacheUnified, CacheInstruction, CacheData, CacheTrace, }} STRUCT!{struct CACHE_DESCRIPTOR { Level: ::BYTE, Associativity: ::BYTE, LineSize: ::WORD, Size: ::DWORD, Type: PROCESSOR_CACHE_TYPE, }} pub type PCACHE_DESCRIPTOR = *mut CACHE_DESCRIPTOR; STRUCT!{struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION_ProcessorCore { Flags: ::BYTE, }} STRUCT!{struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION_NumaNode { NodeNumber: ::DWORD, }} STRUCT!{struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION { ProcessorMask: ::ULONG_PTR, Relationship: LOGICAL_PROCESSOR_RELATIONSHIP, Reserved: [::ULONGLONG; 2], }} UNION!( SYSTEM_LOGICAL_PROCESSOR_INFORMATION, Reserved, ProcessorCore, ProcessorCore_mut, SYSTEM_LOGICAL_PROCESSOR_INFORMATION_ProcessorCore ); UNION!( SYSTEM_LOGICAL_PROCESSOR_INFORMATION, Reserved, NumaNode, NumaNode_mut, SYSTEM_LOGICAL_PROCESSOR_INFORMATION_NumaNode ); UNION!(SYSTEM_LOGICAL_PROCESSOR_INFORMATION, Reserved, Cache, Cache_mut, CACHE_DESCRIPTOR); pub type PSYSTEM_LOGICAL_PROCESSOR_INFORMATION = *mut SYSTEM_LOGICAL_PROCESSOR_INFORMATION; STRUCT!{struct SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION { CycleTime: ::DWORD64, }} pub type PSYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION = *mut SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION; ENUM!{enum HARDWARE_COUNTER_TYPE { PMCCounter, MaxHardwareCounterType, }} pub type PHARDWARE_COUNTER_TYPE = *mut HARDWARE_COUNTER_TYPE; ENUM!{enum PROCESS_MITIGATION_POLICY { ProcessDEPPolicy, ProcessASLRPolicy, ProcessDynamicCodePolicy, ProcessStrictHandleCheckPolicy, ProcessSystemCallDisablePolicy, ProcessMitigationOptionsMask, ProcessExtensionPointDisablePolicy, ProcessReserved1Policy, ProcessSignaturePolicy, MaxProcessMitigationPolicy, }} #[repr(C)] #[derive(Copy)] pub struct OSVERSIONINFOA { pub dwOSVersionInfoSize: ::DWORD, pub dwMajorVersion: ::DWORD, pub dwMinorVersion: ::DWORD, pub dwBuildNumber: ::DWORD, pub dwPlatformId: ::DWORD, pub szCSDVersion: [::CHAR; 128], } impl Clone for OSVERSIONINFOA { fn clone(&self) -> OSVERSIONINFOA { *self } } pub type POSVERSIONINFOA = *mut OSVERSIONINFOA; pub type LPOSVERSIONINFOA = *mut OSVERSIONINFOA; #[repr(C)] #[derive(Copy)] pub struct OSVERSIONINFOW { pub dwOSVersionInfoSize: ::DWORD, pub dwMajorVersion: ::DWORD, pub dwMinorVersion: ::DWORD, pub dwBuildNumber: ::DWORD, pub dwPlatformId: ::DWORD, pub szCSDVersion: [::WCHAR; 128], } impl Clone for OSVERSIONINFOW { fn clone(&self) -> OSVERSIONINFOW { *self } } pub type POSVERSIONINFOW = *mut OSVERSIONINFOW; pub type LPOSVERSIONINFOW = *mut OSVERSIONINFOW; #[repr(C)] #[derive(Copy)] pub struct OSVERSIONINFOEXA { pub dwOSVersionInfoSize: ::DWORD, pub dwMajorVersion: ::DWORD, pub dwMinorVersion: ::DWORD, pub dwBuildNumber: ::DWORD, pub dwPlatformId: ::DWORD, pub szCSDVersion: [::CHAR; 128], pub wServicePackMajor: ::WORD, pub wServicePackMinor: ::WORD, pub wSuiteMask: ::WORD, pub wProductType: ::BYTE, pub wReserved: ::BYTE, } impl Clone for OSVERSIONINFOEXA { fn clone(&self) -> OSVERSIONINFOEXA { *self } } pub type POSVERSIONINFOEXA = *mut OSVERSIONINFOEXA; pub type LPOSVERSIONINFOEXA = *mut OSVERSIONINFOEXA; #[repr(C)] #[derive(Copy)] pub struct OSVERSIONINFOEXW { pub dwOSVersionInfoSize: ::DWORD, pub dwMajorVersion: ::DWORD, pub dwMinorVersion: ::DWORD, pub dwBuildNumber: ::DWORD, pub dwPlatformId: ::DWORD, pub szCSDVersion: [::WCHAR; 128], pub wServicePackMajor: ::WORD, pub wServicePackMinor: ::WORD, pub wSuiteMask: ::WORD, pub wProductType: ::BYTE, pub wReserved: ::BYTE, } impl Clone for OSVERSIONINFOEXW { fn clone(&self) -> OSVERSIONINFOEXW { *self } } pub type POSVERSIONINFOEXW = *mut OSVERSIONINFOEXW; pub type LPOSVERSIONINFOEXW = *mut OSVERSIONINFOEXW; STRUCT!{struct SLIST_ENTRY { Next: *mut SLIST_ENTRY, }} pub type PSLIST_ENTRY = *mut SLIST_ENTRY; STRUCT!{struct SLIST_HEADER_HeaderX64 { BitFields1: ::ULONGLONG, BitFields2: ::ULONGLONG, }} BITFIELD!(SLIST_HEADER_HeaderX64 BitFields1: ::ULONGLONG [ Depth set_Depth[0..16], Sequence set_Sequence[16..64], ]); BITFIELD!(SLIST_HEADER_HeaderX64 BitFields2: ::ULONGLONG [ Reserved set_Reserved[0..4], NextEntry set_NextEntry[4..64], ]); STRUCT!{struct SLIST_HEADER { Alignment: ::ULONGLONG, Region: ::ULONGLONG, }} UNION!(SLIST_HEADER, Alignment, HeaderX64, HeaderX64_mut, SLIST_HEADER_HeaderX64); pub type PSLIST_HEADER = *mut SLIST_HEADER; ENUM!{enum SYSTEM_POWER_STATE { PowerSystemUnspecified = 0, PowerSystemWorking = 1, PowerSystemSleeping1 = 2, PowerSystemSleeping2 = 3, PowerSystemSleeping3 = 4, PowerSystemHibernate = 5, PowerSystemShutdown = 6, PowerSystemMaximum = 7, }} pub type PSYSTEM_POWER_STATE = *mut SYSTEM_POWER_STATE; ENUM!{enum POWER_ACTION { PowerActionNone = 0, PowerActionReserved, PowerActionSleep, PowerActionHibernate, PowerActionShutdown, PowerActionShutdownReset, PowerActionShutdownOff, PowerActionWarmEject, }} pub type PPOWER_ACTION = *mut POWER_ACTION; ENUM!{enum DEVICE_POWER_STATE { PowerDeviceUnspecified = 0, PowerDeviceD0, PowerDeviceD1, PowerDeviceD2, PowerDeviceD3, PowerDeviceMaximum, }} pub type PDEVICE_POWER_STATE = *mut DEVICE_POWER_STATE; ENUM!{enum MONITOR_DISPLAY_STATE { PowerMonitorOff = 0, PowerMonitorOn, PowerMonitorDim, }} pub type PMONITOR_DISPLAY_STATE = *mut MONITOR_DISPLAY_STATE; ENUM!{enum USER_ACTIVITY_PRESENCE { PowerUserPresent = 0, PowerUserNotPresent, PowerUserInactive, PowerUserMaximum, //PowerUserInvalid = 3, }} pub type PUSER_ACTIVITY_PRESENCE = *mut USER_ACTIVITY_PRESENCE; pub type EXECUTION_STATE = ::DWORD; pub type PEXECUTION_STATE = *mut ::DWORD; ENUM!{enum LATENCY_TIME { LT_DONT_CARE, LT_LOWEST_LATENCY, }} ENUM!{enum POWER_REQUEST_TYPE { PowerRequestDisplayRequired, PowerRequestSystemRequired, PowerRequestAwayModeRequired, PowerRequestExecutionRequired, }} pub type PPOWER_REQUEST_TYPE = *mut POWER_REQUEST_TYPE; pub const MAX_HW_COUNTERS: usize = 16; STRUCT!{struct HARDWARE_COUNTER_DATA { Type: HARDWARE_COUNTER_TYPE, Reserved: ::DWORD, Value: ::DWORD64, }} pub type PHARDWARE_COUNTER_DATA = *mut HARDWARE_COUNTER_DATA; STRUCT!{struct PERFORMANCE_DATA { Size: ::WORD, Version: ::BYTE, HwCountersCount: ::BYTE, ContextSwitchCount: ::DWORD, WaitReasonBitMap: ::DWORD64, CycleTime: ::DWORD64, RetryCount: ::DWORD, Reserved: ::DWORD, HwCounters: [HARDWARE_COUNTER_DATA; MAX_HW_COUNTERS], }} pub type PPERFORMANCE_DATA = *mut PERFORMANCE_DATA; STRUCT!{struct MEMORY_BASIC_INFORMATION { BaseAddress: ::PVOID, AllocationBase: ::PVOID, AllocationProtect: ::DWORD, RegionSize: ::SIZE_T, State: ::DWORD, Protect: ::DWORD, Type: ::DWORD, }} pub type PMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION; STRUCT!{struct MEMORY_BASIC_INFORMATION32 { BaseAddress: ::DWORD, AllocationBase: ::DWORD, AllocationProtect: ::DWORD, RegionSize: ::DWORD, State: ::DWORD, Protect: ::DWORD, Type: ::DWORD, }} pub type PMEMORY_BASIC_INFORMATION32 = *mut MEMORY_BASIC_INFORMATION32; STRUCT!{struct MEMORY_BASIC_INFORMATION64 { // FIXME: align 16 BaseAddress: ::ULONGLONG, AllocationBase: ::ULONGLONG, AllocationProtect: ::DWORD, __alignment1: ::DWORD, RegionSize: ::ULONGLONG, State: ::DWORD, Protect: ::DWORD, Type: ::DWORD, __alignment2: ::DWORD, }} pub type PMEMORY_BASIC_INFORMATION64 = *mut MEMORY_BASIC_INFORMATION64; pub const WOW64_SIZE_OF_80387_REGISTERS: usize = 80; pub const WOW64_MAXIMUM_SUPPORTED_EXTENSION: usize = 512; #[repr(C)] #[derive(Copy)] pub struct WOW64_FLOATING_SAVE_AREA { pub ControlWord: ::DWORD, pub StatusWord: ::DWORD, pub TagWord: ::DWORD, pub ErrorOffset: ::DWORD, pub ErrorSelector: ::DWORD, pub DataOffset: ::DWORD, pub DataSelector: ::DWORD, pub RegisterArea: [::BYTE; WOW64_SIZE_OF_80387_REGISTERS], pub Cr0NpxState: ::DWORD, } impl Clone for WOW64_FLOATING_SAVE_AREA { fn clone(&self) -> WOW64_FLOATING_SAVE_AREA { *self } } pub type PWOW64_FLOATING_SAVE_AREA = *mut WOW64_FLOATING_SAVE_AREA; #[repr(C)] #[derive(Copy)] pub struct WOW64_CONTEXT { pub ContextFlags: ::DWORD, pub Dr0: ::DWORD, pub Dr1: ::DWORD, pub Dr2: ::DWORD, pub Dr3: ::DWORD, pub Dr4: ::DWORD, pub Dr5: ::DWORD, pub Dr6: ::DWORD, pub Dr7: ::DWORD, pub FloatSave: WOW64_FLOATING_SAVE_AREA, pub SegGs: ::DWORD, pub SegFs: ::DWORD, pub SegEs: ::DWORD, pub SegDs: ::DWORD, pub Edi: ::DWORD, pub Esi: ::DWORD, pub Ebx: ::DWORD, pub Edx: ::DWORD, pub Ecx: ::DWORD, pub Eax: ::DWORD, pub Ebp: ::DWORD, pub Eip: ::DWORD, pub SegCs: ::DWORD, pub EFlags: ::DWORD, pub Esp: ::DWORD, pub SegSs: ::DWORD, pub ExtendedRegisters: [::BYTE; WOW64_MAXIMUM_SUPPORTED_EXTENSION], } impl Clone for WOW64_CONTEXT { fn clone(&self) -> WOW64_CONTEXT { *self } } pub type PWOW64_CONTEXT = *mut WOW64_CONTEXT; STRUCT!{struct WOW64_LDT_ENTRY_Bytes { BaseMid: ::BYTE, Flags1: ::BYTE, Flags2: ::BYTE, BaseHi: ::BYTE, }} STRUCT!{struct WOW64_LDT_ENTRY_Bits { BitFields: ::DWORD, }} BITFIELD!(WOW64_LDT_ENTRY_Bits BitFields: ::DWORD [ BaseMid set_BaseMid[0..8], Type set_Type[8..13], Dpl set_Dpl[13..15], Pres set_Pres[15..16], LimitHi set_LimitHi[16..20], Sys set_Sys[20..21], Reserved_0 set_Reserved_0[21..22], Default_Big set_Default_Big[22..23], Granularity set_Granularity[23..24], BaseHi set_BaseHi[24..32], ]); STRUCT!{struct WOW64_LDT_ENTRY { LimitLow: ::WORD, BaseLow: ::WORD, HighWord: ::DWORD, }} UNION!(WOW64_LDT_ENTRY, HighWord, Bytes, Bytes_mut, WOW64_LDT_ENTRY_Bytes); UNION!(WOW64_LDT_ENTRY, HighWord, Bits, Bits_mut, WOW64_LDT_ENTRY_Bits); pub type PWOW64_LDT_ENTRY = *mut WOW64_LDT_ENTRY; deps/winapi-0.2.5/src/minwindef.rs0000644000000000000000000000526012613167613015564 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Basic Windows Type Definitions for minwin partition pub type ULONG = ::c_ulong; pub type PULONG = *mut ULONG; pub type USHORT = ::c_ushort; pub type PUSHORT = *mut USHORT; pub type UCHAR = ::c_uchar; pub type PUCHAR = *mut UCHAR; pub type PSZ = *mut ::c_char; pub const MAX_PATH: usize = 260; pub const FALSE: BOOL = 0; pub const TRUE: BOOL = 1; pub type DWORD = ::c_ulong; pub type BOOL = ::c_int; pub type BYTE = ::c_uchar; pub type WORD = ::c_ushort; pub type FLOAT = ::c_float; pub type PFLOAT = *mut FLOAT; pub type PBOOL = *mut BOOL; pub type LPBOOL = *mut BOOL; pub type PBYTE = *mut BYTE; pub type LPBYTE = *mut BYTE; pub type PINT = *mut ::c_int; pub type LPINT = *mut ::c_int; pub type PWORD = *mut WORD; pub type LPWORD = *mut WORD; pub type LPLONG = *mut ::c_long; pub type PDWORD = *mut DWORD; pub type LPDWORD = *mut DWORD; pub type LPVOID = *mut ::c_void; pub type LPCVOID = *const ::c_void; pub type INT = ::c_int; pub type UINT = ::c_uint; pub type PUINT = *mut ::c_uint; pub type WPARAM = ::UINT_PTR; pub type LPARAM = ::LONG_PTR; pub type LRESULT = ::LONG_PTR; pub fn MAKEWORD(a: BYTE, b: BYTE) -> WORD { (a as WORD) | ((b as WORD) << 8) } pub fn MAKELONG(a: WORD, b: WORD) -> ::LONG { ((a as DWORD) | ((b as DWORD) << 16)) as ::LONG } pub fn LOWORD(l: DWORD) -> WORD { (l & 0xffff) as WORD } pub fn HIWORD(l: DWORD) -> WORD { ((l >> 16) & 0xffff) as WORD } pub fn LOBYTE(l: WORD) -> BYTE { (l & 0xff) as BYTE } pub fn HIBYTE(l: WORD) -> BYTE { ((l >> 8) & 0xff) as BYTE } pub type SPHANDLE = *mut ::HANDLE; pub type LPHANDLE = *mut ::HANDLE; pub type HGLOBAL = ::HANDLE; pub type HLOCAL = ::HANDLE; pub type GLOBALHANDLE = ::HANDLE; pub type LOCALHANDLE = ::HANDLE; /// Pointer to probably a function with unknown type signature. pub type FARPROC = *const ::c_void; /// Pointer to probably a function with unknown type signature. pub type NEARPROC = *const ::c_void; /// Pointer to probably a function with unknown type signature. pub type PROC = *const ::c_void; pub type ATOM = WORD; DECLARE_HANDLE!(HKEY, HKEY__); pub type PHKEY = *mut HKEY; DECLARE_HANDLE!(HMETAFILE, HMETAFILE__); DECLARE_HANDLE!(HINSTANCE, HINSTANCE__); pub type HMODULE = HINSTANCE; DECLARE_HANDLE!(HRGN, HRGN__); DECLARE_HANDLE!(HRSRC, HRSRC__); DECLARE_HANDLE!(HSPRITE, HSPRITE__); DECLARE_HANDLE!(HLSURF, HLSURF__); DECLARE_HANDLE!(HSTR, HSTR__); DECLARE_HANDLE!(HTASK, HTASK__); DECLARE_HANDLE!(HWINSTA, HWINSTA__); DECLARE_HANDLE!(HKL, HKL__); pub type HFILE = ::c_int; STRUCT!{struct FILETIME { dwLowDateTime: DWORD, dwHighDateTime: DWORD, }} pub type PFILETIME = *mut FILETIME; pub type LPFILETIME = *mut FILETIME; deps/winapi-0.2.5/src/nb30.rs0000644000000000000000000001412112613167613014342 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License // This module contains the definitions for portable NetBIOS 3.0 support. pub const NCBNAMSZ: usize = 16; pub const MAX_LANA: usize = 254; pub type PFPOST = Option; #[repr(C)] #[derive(Copy)] pub struct NCB { pub ncb_command: ::UCHAR, pub ncb_retcode: ::UCHAR, pub ncb_lsn: ::UCHAR, pub ncb_num: ::UCHAR, pub ncb_buffer: ::PUCHAR, pub ncb_length: ::WORD, pub ncb_callname: [::UCHAR; NCBNAMSZ], pub ncb_name: [::UCHAR; NCBNAMSZ], pub ncb_rto: ::UCHAR, pub ncb_sto: ::UCHAR, pub ncb_post: PFPOST, pub ncb_lana_num: ::UCHAR, pub ncb_cmd_cplt: ::UCHAR, #[cfg(target_arch="x86")] pub ncb_reserve: [::UCHAR; 10], #[cfg(target_arch="x86_64")] pub ncb_reserve: [::UCHAR; 18], pub ncb_event: ::HANDLE, } impl Clone for NCB { fn clone(&self) -> NCB { *self } } pub type PNCB = *mut NCB; STRUCT!{struct ADAPTER_STATUS { adapter_address: [::UCHAR; 6], rev_major: ::UCHAR, reserved0: ::UCHAR, adapter_type: ::UCHAR, rev_minor: ::UCHAR, duration: ::WORD, frmr_recv: ::WORD, frmr_xmit: ::WORD, iframe_recv_err: ::WORD, xmit_aborts: ::WORD, xmit_success: ::DWORD, recv_success: ::DWORD, iframe_xmit_err: ::WORD, recv_buff_unavail: ::WORD, t1_timeouts: ::WORD, ti_timeouts: ::WORD, reserved1: ::DWORD, free_ncbs: ::WORD, max_cfg_ncbs: ::WORD, max_ncbs: ::WORD, xmit_buf_unavail: ::WORD, max_dgram_size: ::WORD, pending_sess: ::WORD, max_cfg_sess: ::WORD, max_sess: ::WORD, max_sess_pkt_size: ::WORD, name_count: ::WORD, }} pub type PADAPTER_STATUS = *mut ADAPTER_STATUS; STRUCT!{struct NAME_BUFFER { name: [::UCHAR; NCBNAMSZ], name_num: ::UCHAR, name_flags: ::UCHAR, }} pub type PNAME_BUFFER = *mut NAME_BUFFER; pub const NAME_FLAGS_MASK: ::UCHAR = 0x87; pub const GROUP_NAME: ::UCHAR = 0x80; pub const UNIQUE_NAME: ::UCHAR = 0x00; pub const REGISTERING: ::UCHAR = 0x00; pub const REGISTERED: ::UCHAR = 0x04; pub const DEREGISTERED: ::UCHAR = 0x05; pub const DUPLICATE: ::UCHAR = 0x06; pub const DUPLICATE_DEREG: ::UCHAR = 0x07; STRUCT!{struct SESSION_HEADER { sess_name: ::UCHAR, num_sess: ::UCHAR, rcv_dg_outstanding: ::UCHAR, rcv_any_outstanding: ::UCHAR, }} pub type PSESSION_HEADER = *mut SESSION_HEADER; STRUCT!{struct SESSION_BUFFER { lsn: ::UCHAR, state: ::UCHAR, local_name: [::UCHAR; NCBNAMSZ], remote_name: [::UCHAR; NCBNAMSZ], rcvs_outstanding: ::UCHAR, sends_outstanding: ::UCHAR, }} pub type PSESSION_BUFFER = *mut SESSION_BUFFER; pub const LISTEN_OUTSTANDING: ::UCHAR = 0x01; pub const CALL_PENDING: ::UCHAR = 0x02; pub const SESSION_ESTABLISHED: ::UCHAR = 0x03; pub const HANGUP_PENDING: ::UCHAR = 0x04; pub const HANGUP_COMPLETE: ::UCHAR = 0x05; pub const SESSION_ABORTED: ::UCHAR = 0x06; #[repr(C)] #[derive(Copy)] pub struct LANA_ENUM { pub length: ::UCHAR, pub lana: [::UCHAR; MAX_LANA + 1], } impl Clone for LANA_ENUM { fn clone(&self) -> LANA_ENUM { *self } } pub type PLANA_ENUM = *mut LANA_ENUM; STRUCT!{struct FIND_NAME_HEADER { node_count: ::WORD, reserved: ::UCHAR, unique_group: ::UCHAR, }} pub type PFIND_NAME_HEADER = *mut FIND_NAME_HEADER; STRUCT!{struct FIND_NAME_BUFFER { length: ::UCHAR, access_control: ::UCHAR, frame_control: ::UCHAR, destination_addr: [::UCHAR; 6], source_addr: [::UCHAR; 6], routing_info: [::UCHAR; 18], }} pub type PFIND_NAME_BUFFER = *mut FIND_NAME_BUFFER; STRUCT!{struct ACTION_HEADER { transport_id: ::ULONG, action_code: ::USHORT, reserved: ::USHORT, }} pub type PACTION_HEADER = *mut ACTION_HEADER; pub const NCBCALL: ::UCHAR = 0x10; pub const NCBLISTEN: ::UCHAR = 0x11; pub const NCBHANGUP: ::UCHAR = 0x12; pub const NCBSEND: ::UCHAR = 0x14; pub const NCBRECV: ::UCHAR = 0x15; pub const NCBRECVANY: ::UCHAR = 0x16; pub const NCBCHAINSEND: ::UCHAR = 0x17; pub const NCBDGSEND: ::UCHAR = 0x20; pub const NCBDGRECV: ::UCHAR = 0x21; pub const NCBDGSENDBC: ::UCHAR = 0x22; pub const NCBADDNAME: ::UCHAR = 0x30; pub const NCBDELNAME: ::UCHAR = 0x31; pub const NCBRESET: ::UCHAR = 0x32; pub const NCBASTAT: ::UCHAR = 0x33; pub const NCBSSTAT: ::UCHAR = 0x34; pub const NCBCANCEL: ::UCHAR = 0x35; pub const NCBADDGRNAME: ::UCHAR = 0x36; pub const NCBENUM: ::UCHAR = 0x37; pub const NCBUNLINK: ::UCHAR = 0x70; pub const NCBSENDNA: ::UCHAR = 0x71; pub const NCBCHAINSENDNA: ::UCHAR = 0x72; pub const NCBLANSTALERT: ::UCHAR = 0x73; pub const NCBACTION: ::UCHAR = 0x77; pub const NCBFINDNAME: ::UCHAR = 0x78; pub const NCBTRACE: ::UCHAR = 0x79; pub const ASYNCH: ::UCHAR = 0x80; pub const NRC_GOODRET: ::UCHAR = 0x00; pub const NRC_BUFLEN: ::UCHAR = 0x01; pub const NRC_ILLCMD: ::UCHAR = 0x03; pub const NRC_CMDTMO: ::UCHAR = 0x05; pub const NRC_INCOMP: ::UCHAR = 0x06; pub const NRC_BADDR: ::UCHAR = 0x07; pub const NRC_SNUMOUT: ::UCHAR = 0x08; pub const NRC_NORES: ::UCHAR = 0x09; pub const NRC_SCLOSED: ::UCHAR = 0x0a; pub const NRC_CMDCAN: ::UCHAR = 0x0b; pub const NRC_DUPNAME: ::UCHAR = 0x0d; pub const NRC_NAMTFUL: ::UCHAR = 0x0e; pub const NRC_ACTSES: ::UCHAR = 0x0f; pub const NRC_LOCTFUL: ::UCHAR = 0x11; pub const NRC_REMTFUL: ::UCHAR = 0x12; pub const NRC_ILLNN: ::UCHAR = 0x13; pub const NRC_NOCALL: ::UCHAR = 0x14; pub const NRC_NOWILD: ::UCHAR = 0x15; pub const NRC_INUSE: ::UCHAR = 0x16; pub const NRC_NAMERR: ::UCHAR = 0x17; pub const NRC_SABORT: ::UCHAR = 0x18; pub const NRC_NAMCONF: ::UCHAR = 0x19; pub const NRC_IFBUSY: ::UCHAR = 0x21; pub const NRC_TOOMANY: ::UCHAR = 0x22; pub const NRC_BRIDGE: ::UCHAR = 0x23; pub const NRC_CANOCCR: ::UCHAR = 0x24; pub const NRC_CANCEL: ::UCHAR = 0x26; pub const NRC_DUPENV: ::UCHAR = 0x30; pub const NRC_ENVNOTDEF: ::UCHAR = 0x34; pub const NRC_OSRESNOTAV: ::UCHAR = 0x35; pub const NRC_MAXAPPS: ::UCHAR = 0x36; pub const NRC_NOSAPS: ::UCHAR = 0x37; pub const NRC_NORESOURCES: ::UCHAR = 0x38; pub const NRC_INVADDRESS: ::UCHAR = 0x39; pub const NRC_INVDDID: ::UCHAR = 0x3B; pub const NRC_LOCKFAIL: ::UCHAR = 0x3C; pub const NRC_OPENERR: ::UCHAR = 0x3f; pub const NRC_SYSTEM: ::UCHAR = 0x40; pub const NRC_PENDING: ::UCHAR = 0xff; deps/winapi-0.2.5/src/propsys.rs0000644000000000000000000000027212605021253015307 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License pub type IPropertyDescriptionList = ::IUnknown; // TODO pub type IPropertyStore = ::IUnknown; // TODO deps/winapi-0.2.5/src/hidusage.rs0000644000000000000000000000025112605021351015355 0ustar rootroot// Copyright © 2015, Alex Daniel Jones // Licensed under the MIT License // Taken from hidusage.h pub type USAGE = ::USHORT; pub type PUSAGE = *mut USAGE; deps/winapi-0.2.5/src/ksmedia.rs0000644000000000000000000000204412605021253015204 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License DEFINE_GUID!(KSDATAFORMAT_SUBTYPE_ANALOG, 0x6DBA3190, 0x67BD, 0x11CF, 0xA0, 0xF7, 0x00, 0x20, 0xAF, 0xD1, 0x56, 0xE4); DEFINE_GUID!(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71); DEFINE_GUID!(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71); DEFINE_GUID!(KSDATAFORMAT_SUBTYPE_DRM, 0x00000009, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71); DEFINE_GUID!(KSDATAFORMAT_SUBTYPE_ALAW, 0x00000006, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71); DEFINE_GUID!(KSDATAFORMAT_SUBTYPE_MULAW, 0x00000007, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71); DEFINE_GUID!(KSDATAFORMAT_SUBTYPE_ADPCM, 0x00000002, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71); DEFINE_GUID!(KSDATAFORMAT_SUBTYPE_MPEG, 0x00000050, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71); deps/winapi-0.2.5/src/objidlbase.rs0000644000000000000000000000570212615662007015702 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! this ALWAYS GENERATED file contains the definitions for the interfaces RIDL!( interface IMalloc(IMallocVtbl): IUnknown(IUnknownVtbl) { fn Alloc(&mut self, cb: ::SIZE_T) -> *mut ::c_void, fn Realloc(&mut self, pv: *mut ::c_void, cb: ::SIZE_T) -> *mut ::c_void, fn Free(&mut self, pv: *mut ::c_void) -> (), fn GetSize(&mut self, pv: *mut ::c_void) -> ::SIZE_T, fn DidAlloc(&mut self, pv: *mut ::c_void) -> ::c_int, fn HeapMinimize(&mut self) -> () } ); pub type LPMALLOC = *mut IMalloc; STRUCT!{struct STATSTG { pwcsName: ::LPOLESTR, type_: ::DWORD, cbSize: ::ULARGE_INTEGER, mtime: ::FILETIME, ctime: ::FILETIME, atime: ::FILETIME, grfMode: ::DWORD, grfLocksSupported: ::DWORD, clsid: ::CLSID, grfStateBits: ::DWORD, reserved: ::DWORD, }} //1945 pub type IEnumString = ::IUnknown; // TODO //2075 RIDL!( interface ISequentialStream(ISequentialStreamVtbl): IUnknown(IUnknownVtbl) { fn Read(&mut self, pv: *mut ::c_void, cb: ::ULONG, pcbRead: *mut ::ULONG) -> ::HRESULT, fn Write(&mut self, pv: *const ::c_void, cb: ::ULONG, pcbWritten: *mut ::ULONG) -> ::HRESULT } ); ENUM!{enum STGTY { STGTY_STORAGE = 1, STGTY_STREAM = 2, STGTY_LOCKBYTES = 3, STGTY_PROPERTY = 4, }} ENUM!{enum STREAM_SEEK { STREAM_SEEK_SET = 0, STREAM_SEEK_CUR = 1, STREAM_SEEK_END = 2, }} ENUM!{enum LOCKTYPE { LOCK_WRITE = 1, LOCK_EXCLUSIVE = 2, LOCK_ONLYONCE = 4, }} //2255 RIDL!( interface IStream(IStreamVtbl): ISequentialStream(ISequentialStreamVtbl) { fn Seek( &mut self, dlibMove: ::LARGE_INTEGER, dwOrigin: ::DWORD, plibNewPosition: *mut ::ULARGE_INTEGER ) -> ::HRESULT, fn SetSize(&mut self, libNewSize: ::ULARGE_INTEGER) -> ::HRESULT, fn CopyTo( &mut self, pstm: *mut IStream, cb: ::ULARGE_INTEGER, pcbRead: *mut ::ULARGE_INTEGER, pcbWritten: *mut ::ULARGE_INTEGER ) -> ::HRESULT, fn Commit(&mut self, grfCommitFlags: ::DWORD) -> ::HRESULT, fn Revert(&mut self) -> ::HRESULT, fn LockRegion( &mut self, libOffset: ::ULARGE_INTEGER, cb: ::ULARGE_INTEGER, dwLockType: ::DWORD ) -> ::HRESULT, fn UnlockRegion( &mut self, libOffset: ::ULARGE_INTEGER, cb: ::ULARGE_INTEGER, dwLockType: ::DWORD ) -> ::HRESULT, fn Stat(&mut self, pstatstg: *mut STATSTG, grfStatFlag: ::DWORD) -> ::HRESULT, fn Clone(&mut self, ppstm: *mut *mut IStream) -> ::HRESULT } ); pub type LPSTREAM = *mut IStream; ENUM!{enum APTTYPEQUALIFIER { APTTYPEQUALIFIER_NONE = 0, APTTYPEQUALIFIER_IMPLICIT_MTA = 1, APTTYPEQUALIFIER_NA_ON_MTA = 2, APTTYPEQUALIFIER_NA_ON_STA = 3, APTTYPEQUALIFIER_NA_ON_IMPLICIT_MTA = 4, APTTYPEQUALIFIER_NA_ON_MAINSTA = 5, APTTYPEQUALIFIER_APPLICATION_STA= 6, }} ENUM!{enum APTTYPE { APTTYPE_CURRENT = -1i32 as u32, APTTYPE_STA = 0, APTTYPE_MTA = 1, APTTYPE_NA = 2, APTTYPE_MAINSTA = 3, }} deps/winapi-0.2.5/src/d2dbasetypes.rs0000644000000000000000000000234712613167613016200 0ustar rootroot// Copyright © 2015, Connor Hilarides // Licensed under the MIT License //! Mappings for the contents of d2dbasetypes.h STRUCT!{struct D2D_POINT_2U { x: ::UINT32, y: ::UINT32, }} STRUCT!{struct D2D_POINT_2F { x: ::FLOAT, y: ::FLOAT, }} pub type D2D_POINT_2L = ::POINT; STRUCT!{struct D2D_VECTOR_2F { x: ::FLOAT, y: ::FLOAT, }} STRUCT!{struct D2D_VECTOR_3F { x: ::FLOAT, y: ::FLOAT, z: ::FLOAT, }} STRUCT!{struct D2D_VECTOR_4F { x: ::FLOAT, y: ::FLOAT, z: ::FLOAT, w: ::FLOAT, }} STRUCT!{struct D2D_RECT_F { left: ::FLOAT, top: ::FLOAT, right: ::FLOAT, bottom: ::FLOAT, }} STRUCT!{struct D2D_RECT_U { left: ::UINT32, top: ::UINT32, right: ::UINT32, bottom: ::UINT32, }} pub type D2D_RECT_L = ::RECT; STRUCT!{struct D2D_SIZE_F { width: ::FLOAT, height: ::FLOAT, }} STRUCT!{struct D2D_SIZE_U { width: ::UINT32, height: ::UINT32, }} pub type D2D_COLOR_F = ::D3DCOLORVALUE; STRUCT!{struct D2D_MATRIX_3X2_F { matrix: [[::FLOAT; 3]; 2], }} STRUCT!{struct D2D_MATRIX_4X3_F { matrix: [[::FLOAT; 4]; 3], }} STRUCT!{struct D2D_MATRIX_4X4_F { matrix: [[::FLOAT; 4]; 4], }} STRUCT!{struct D2D_MATRIX_5X4_F { matrix: [[::FLOAT; 5]; 4], }} deps/winapi-0.2.5/src/lib.rs0000644000000000000000000002550512617171130014347 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Types and constants for WinAPI bindings. #![allow(bad_style, raw_pointer_derive)] #![warn(missing_copy_implementations, trivial_casts, trivial_numeric_casts)] #![warn(unused_qualifications, unused)] #![cfg(windows)] //------------------------------------------------------------------------------------------------- // Imports //------------------------------------------------------------------------------------------------- pub use std::os::raw::{ c_void, c_char, c_schar, c_uchar, c_short, c_ushort, c_int, c_uint, c_long, c_ulong, c_longlong, c_ulonglong, c_float, c_double, }; pub use audioclient::*; pub use audiosessiontypes::*; pub use basetsd::*; pub use bcrypt::*; pub use cfg::*; pub use cfgmgr32::*; pub use commctrl::*; pub use commdlg::*; pub use corsym::*; pub use d2d1::*; pub use d2dbasetypes::*; pub use d3d9::*; pub use d3d9caps::*; pub use d3d9types::*; pub use d3d11::*; pub use d3d12::*; pub use d3d12sdklayers::*; pub use d3dcommon::*; pub use dbghelp::*; pub use dcommon::*; pub use devpropdef::*; pub use docobj::*; pub use dpapi::*; pub use dsgetdc::*; pub use dsound::*; pub use dsrole::*; pub use dwmapi::*; pub use dwrite::*; pub use dxgi::*; pub use dxgi1_2::*; pub use dxgi1_3::*; pub use dxgi1_4::*; pub use dxgiformat::*; pub use dxgitype::*; pub use errhandlingapi::*; pub use excpt::*; pub use fileapi::*; pub use gl::*; pub use guiddef::*; pub use heapapi::*; pub use hidclass::*; pub use hidpi::*; pub use hidsdi::*; pub use hidusage::*; pub use hstring::*; pub use http::*; pub use imm::*; pub use inaddr::*; pub use inspectable::*; pub use ksmedia::*; pub use libloaderapi::*; pub use lmaccess::*; pub use lmcons::*; pub use lmdfs::*; pub use lmerrlog::*; pub use lmjoin::*; pub use lsalookup::*; pub use memoryapi::*; pub use minwinbase::*; pub use minwindef::*; pub use mmdeviceapi::*; pub use mmreg::*; pub use mmsystem::*; pub use mscat::*; pub use mssip::*; pub use nb30::*; pub use ncrypt::*; pub use ntdef::*; pub use ntsecapi::*; pub use ntstatus::*; pub use oaidl::*; pub use objbase::*; pub use objidl::*; pub use objidlbase::*; pub use olectl::*; pub use processsnapshot::*; pub use processthreadsapi::*; pub use propsys::*; pub use prsht::*; pub use psapi::*; pub use qos::*; pub use reason::*; pub use rpc::*; pub use rpcdce::*; pub use sapi::*; pub use schannel::*; pub use servprov::*; pub use setupapi::*; pub use shellapi::*; pub use shellscalingapi::*; pub use shlguid::*; pub use shlobj::*; pub use shobjidl::*; pub use shtypes::*; pub use spapidef::*; pub use sspi::*; pub use subauth::*; pub use synchapi::*; pub use sysinfoapi::*; pub use threadpoolapi::*; pub use timezoneapi::*; pub use tlhelp32::*; pub use unknwnbase::*; pub use urlhist::*; pub use urlmon::*; pub use usp10::*; pub use vadefs::*; pub use vsbackup::*; pub use vss::*; pub use vsserror::*; pub use vswriter::*; pub use werapi::*; pub use winbase::*; pub use wincon::*; pub use wincred::*; pub use wincrypt::*; pub use windowsx::*; pub use windef::*; pub use windowscodecs::*; pub use winerror::*; pub use winevt::*; pub use wingdi::*; pub use winhttp::*; pub use winioctl::*; pub use winnetwk::*; pub use winnls::*; pub use winnt::*; pub use winscard::*; pub use winsmcrd::*; pub use winsock2::*; pub use winspool::*; pub use winsvc::*; pub use winuser::*; pub use ws2def::*; pub use ws2ipdef::*; pub use ws2spi::*; pub use ws2tcpip::*; pub use wtypes::*; pub use wtypesbase::*; pub use xinput::*; //------------------------------------------------------------------------------------------------- // Modules //------------------------------------------------------------------------------------------------- #[macro_use] mod macros; pub mod audioclient; pub mod audiosessiontypes; pub mod basetsd; pub mod bcrypt; pub mod cfg; pub mod cfgmgr32; pub mod commctrl; pub mod commdlg; pub mod corsym; pub mod d2d1; pub mod d2dbasetypes; pub mod d3d9; pub mod d3d9caps; pub mod d3d9types; pub mod d3d11; pub mod d3d12; pub mod d3d12sdklayers; pub mod d3dcommon; pub mod dbghelp; pub mod dcommon; pub mod devpropdef; pub mod docobj; pub mod dpapi; pub mod dsgetdc; pub mod dsound; pub mod dsrole; pub mod dwmapi; pub mod dwrite; pub mod dxgi; pub mod dxgi1_2; pub mod dxgi1_3; pub mod dxgi1_4; pub mod dxgiformat; pub mod dxgitype; pub mod errhandlingapi; pub mod excpt; pub mod fileapi; pub mod gl; pub mod guiddef; pub mod heapapi; pub mod hidclass; pub mod hidpi; pub mod hidsdi; pub mod hidusage; pub mod hstring; pub mod http; pub mod imm; pub mod inaddr; pub mod inspectable; pub mod ksmedia; pub mod libloaderapi; pub mod lmaccess; pub mod lmcons; pub mod lmdfs; pub mod lmerrlog; pub mod lmjoin; pub mod lsalookup; pub mod memoryapi; pub mod minwinbase; pub mod minwindef; pub mod mmdeviceapi; pub mod mmreg; pub mod mmsystem; pub mod mscat; pub mod mssip; pub mod nb30; pub mod ncrypt; pub mod ntdef; pub mod ntsecapi; pub mod ntstatus; pub mod oaidl; pub mod objbase; pub mod objidl; pub mod objidlbase; pub mod olectl; pub mod processsnapshot; pub mod processthreadsapi; pub mod propsys; pub mod prsht; pub mod psapi; pub mod qos; pub mod reason; pub mod rpc; pub mod rpcdce; pub mod sapi; pub mod schannel; pub mod servprov; pub mod setupapi; pub mod shellapi; pub mod shellscalingapi; pub mod shlguid; pub mod shlobj; pub mod shobjidl; pub mod shtypes; pub mod spapidef; pub mod sspi; pub mod subauth; pub mod synchapi; pub mod sysinfoapi; pub mod threadpoolapi; pub mod timezoneapi; pub mod tlhelp32; pub mod unknwnbase; pub mod urlhist; pub mod urlmon; pub mod usp10; pub mod vadefs; pub mod vsbackup; pub mod vss; pub mod vsserror; pub mod vswriter; pub mod werapi; pub mod winbase; pub mod wincon; pub mod wincred; pub mod wincrypt; pub mod windef; pub mod windowscodecs; pub mod windowsx; pub mod winerror; pub mod winevt; pub mod wingdi; pub mod winhttp; pub mod winioctl; pub mod winnetwk; pub mod winnls; pub mod winnt; pub mod winscard; pub mod winsmcrd; pub mod winsock2; pub mod winspool; pub mod winsvc; pub mod winuser; pub mod ws2def; pub mod ws2ipdef; pub mod ws2spi; pub mod ws2tcpip; pub mod wtypes; pub mod wtypesbase; pub mod xinput; //------------------------------------------------------------------------------------------------- // Primitive types not provided by std //------------------------------------------------------------------------------------------------- pub type __int8 = i8; pub type __uint8 = u8; pub type __int16 = i16; pub type __uint16 = u16; pub type __int32 = i32; pub type __uint32 = u32; pub type __int64 = i64; pub type __uint64 = u64; pub type wchar_t = c_ushort; #[cfg(target_arch = "x86")] pub type size_t = c_uint; #[cfg(target_arch = "x86_64")] pub type size_t = __uint64; //------------------------------------------------------------------------------------------------- // strmif.h //------------------------------------------------------------------------------------------------- pub type REFERENCE_TIME = LONGLONG; //------------------------------------------------------------------------------------------------- // propidl.h //------------------------------------------------------------------------------------------------- STRUCT!{struct PROPVARIANT { vt: VARTYPE, wReserved1: WORD, wReserved2: WORD, wReserved3: WORD, data: [u8; 16], }} //------------------------------------------------------------------------------------------------- // combaseapi.h // Base Component Object Model defintions. //------------------------------------------------------------------------------------------------- pub const CLSCTX_INPROC_SERVER: DWORD = 0x1; pub const CLSCTX_INPROC_HANDLER: DWORD = 0x2; pub const CLSCTX_LOCAL_SERVER: DWORD = 0x4; pub const CLSCTX_REMOTE_SERVER: DWORD = 0x10; pub const CLSCTX_SERVER: DWORD = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER; pub const CLSCTX_ALL: DWORD = CLSCTX_INPROC_HANDLER | CLSCTX_SERVER; STRUCT!{struct ServerInformation { dwServerPid: DWORD, dwServerTid: DWORD, ui64ServerAddress: UINT64, }} pub type PServerInformation = *mut ServerInformation; DECLARE_HANDLE!(CO_MTA_USAGE_COOKIE, CO_MTA_USAGE_COOKIE__); //------------------------------------------------------------------------------------------------- // playsoundapi.h // ApiSet Contract for api-ms-win-mm-playsound-l1-1-0 //------------------------------------------------------------------------------------------------- pub const SND_SYNC: DWORD = 0x0000; pub const SND_ASYNC: DWORD = 0x0001; pub const SND_NODEFAULT: DWORD = 0x0002; pub const SND_MEMORY: DWORD = 0x0004; pub const SND_LOOP: DWORD = 0x0008; pub const SND_NOSTOP: DWORD = 0x0010; pub const SND_NOWAIT: DWORD = 0x00002000; pub const SND_ALIAS: DWORD = 0x00010000; pub const SND_ALIAS_ID: DWORD = 0x00110000; pub const SND_FILENAME: DWORD = 0x00020000; pub const SND_RESOURCE: DWORD = 0x00040004; pub const SND_PURGE: DWORD = 0x0040; pub const SND_APPLICATION: DWORD = 0x0080; pub const SND_SENTRY: DWORD = 0x00080000; pub const SND_RING: DWORD = 0x00100000; pub const SND_SYSTEM: DWORD = 0x00200000; //------------------------------------------------------------------------------------------------- // winreg.h // Registry API procedure declarations, constant definitions and macros //------------------------------------------------------------------------------------------------- pub type REGSAM = ACCESS_MASK; STRUCT!{struct VALENTA { ve_valuename: LPSTR, ve_valuelen: DWORD, ve_valueptr: DWORD_PTR, ve_type: DWORD, }} pub type PVALENTA = *mut VALENTA; STRUCT!{struct VALENTW { ve_valuename: LPWSTR, ve_valuelen: DWORD, ve_valueptr: DWORD_PTR, ve_type: DWORD, }} pub type PVALENTW = *mut VALENTW; pub const HKEY_CLASSES_ROOT: HKEY = 0x80000000 as HKEY; pub const HKEY_CURRENT_USER: HKEY = 0x80000001 as HKEY; pub const HKEY_LOCAL_MACHINE: HKEY = 0x80000002 as HKEY; pub const HKEY_USERS: HKEY = 0x80000003 as HKEY; pub const HKEY_PERFORMANCE_DATA: HKEY = 0x80000004 as HKEY; pub const HKEY_PERFORMANCE_TEXT: HKEY = 0x80000050 as HKEY; pub const HKEY_PERFORMANCE_NLSTEXT: HKEY = 0x80000060 as HKEY; pub const HKEY_CURRENT_CONFIG: HKEY = 0x80000005 as HKEY; pub const HKEY_DYN_DATA: HKEY = 0x80000006 as HKEY; pub const HKEY_CURRENT_USER_LOCAL_SETTINGS: HKEY = 0x80000007 as HKEY; pub const REG_MUI_STRING_TRUNCATE: DWORD = 0x00000001; pub const RRF_RT_REG_NONE: DWORD = 0x00000001; pub const RRF_RT_REG_SZ: DWORD = 0x00000002; pub const RRF_RT_REG_EXPAND_SZ: DWORD = 0x00000004; pub const RRF_RT_REG_BINARY: DWORD = 0x00000008; pub const RRF_RT_REG_DWORD: DWORD = 0x00000010; pub const RRF_RT_REG_MULTI_SZ: DWORD = 0x00000020; pub const RRF_RT_REG_QWORD: DWORD = 0x00000040; pub const RRF_RT_DWORD: DWORD = RRF_RT_REG_BINARY|RRF_RT_REG_DWORD; pub const RRF_RT_QWORD: DWORD = RRF_RT_REG_BINARY|RRF_RT_REG_QWORD; pub const RRF_RT_ANY: DWORD = 0x0000ffff; pub const RRF_NOEXPAND: DWORD = 0x10000000; pub const RRF_ZEROONFAILURE: DWORD = 0x20000000; deps/winapi-0.2.5/src/windowscodecs.rs0000644000000000000000000003161012615662007016454 0ustar rootroot// Copyright © 2015; Connor Hilarides // Licensed under the MIT License //! Mappings for the contents of wincodec.h pub type WICColor = ::UINT32; pub type WICInProcPointer = *mut ::BYTE; pub type REFWICPixelFormatGUID = ::REFGUID; pub type WICPixelFormatGUID = ::GUID; STRUCT!{struct WICRect { X: ::INT, Y: ::INT, Width: ::INT, Height: ::INT, }} ENUM!{enum WICColorContextType { WICColorContextUninitialized = 0, WICColorContextProfile = 0x1, WICColorContextExifColorSpace = 0x2, }} ENUM!{enum WICBitmapCreateCacheOption { WICBitmapNoCache = 0, WICBitmapCacheOnDemand = 0x1, WICBitmapCacheOnLoad = 0x2, }} ENUM!{enum WICDecodeOptions { WICDecodeMetadataCacheOnDemand = 0, WICDecodeMetadataCacheOnLoad = 0x1, }} ENUM!{enum WICBitmapEncoderCacheOption { WICBitmapEncoderCacheInMemory = 0, WICBitmapEncoderCacheTempFile = 0x1, WICBitmapEncoderNoCache = 0x2, }} FLAGS!{enum WICComponentType { WICDecoder = 0x1, WICEncoder = 0x2, WICPixelFormatConverter = 0x4, WICMetadataReader = 0x8, WICMetadataWriter = 0x10, WICPixelFormat = 0x20, WICAllComponents = 0x3f, }} FLAGS!{enum WICComponentEnumerateOptions { WICComponentEnumerateDefault = 0, WICComponentEnumerateRefresh = 0x1, WICComponentEnumerateDisabled = 0x80000000, WICComponentEnumerateUnsigned = 0x40000000, WICComponentEnumerateBuiltInOnly = 0x20000000, }} #[allow(unused_qualifications)] STRUCT!{struct WICBitmapPattern { Position: ::ULARGE_INTEGER, Length: ::ULONG, Pattern: *mut ::BYTE, Mask: *mut ::BYTE, EndOfStream: ::BOOL, }} ENUM!{enum WICBitmapInterpolationMode { WICBitmapInterpolationModeNearestNeighbor = 0, WICBitmapInterpolationModeLinear = 0x1, WICBitmapInterpolationModeCubic = 0x2, WICBitmapInterpolationModeFant = 0x3, }} ENUM!{enum WICBitmapPaletteType { WICBitmapPaletteTypeCustom = 0, WICBitmapPaletteTypeMedianCut = 0x1, WICBitmapPaletteTypeFixedBW = 0x2, WICBitmapPaletteTypeFixedHalftone8 = 0x3, WICBitmapPaletteTypeFixedHalftone27 = 0x4, WICBitmapPaletteTypeFixedHalftone64 = 0x5, WICBitmapPaletteTypeFixedHalftone125 = 0x6, WICBitmapPaletteTypeFixedHalftone216 = 0x7, WICBitmapPaletteTypeFixedHalftone252 = 0x8, WICBitmapPaletteTypeFixedHalftone256 = 0x9, WICBitmapPaletteTypeFixedGray4 = 0xa, WICBitmapPaletteTypeFixedGray16 = 0xb, WICBitmapPaletteTypeFixedGray256 = 0xc, }} pub const WICBitmapPaletteTypeFixedWebPalette: WICBitmapPaletteType = WICBitmapPaletteTypeFixedHalftone216; ENUM!{enum WICBitmapDitherType { WICBitmapDitherTypeSolid = 0, WICBitmapDitherTypeOrdered4x4 = 0x1, WICBitmapDitherTypeOrdered8x8 = 0x2, WICBitmapDitherTypeOrdered16x16 = 0x3, WICBitmapDitherTypeSpiral4x4 = 0x4, WICBitmapDitherTypeSpiral8x8 = 0x5, WICBitmapDitherTypeDualSpiral4x4 = 0x6, WICBitmapDitherTypeDualSpiral8x8 = 0x7, WICBitmapDitherTypeErrorDiffusion = 0x8, }} pub const WICBitmapDitherTypeNone: WICBitmapDitherType = WICBitmapDitherTypeSolid; ENUM!{enum WICBitmapAlphaChannelOption { WICBitmapUseAlpha = 0, WICBitmapUsePremultipliedAlpha = 0x1, WICBitmapIgnoreAlpha = 0x2, }} FLAGS!{enum WICBitmapTransformOptions { WICBitmapTransformRotate0 = 0, WICBitmapTransformRotate90 = 0x1, WICBitmapTransformRotate180 = 0x2, WICBitmapTransformRotate270 = 0x3, WICBitmapTransformFlipHorizontal = 0x8, WICBitmapTransformFlipVertical = 0x10, }} FLAGS!{enum WICBitmapLockFlags { WICBitmapLockRead = 0x1, WICBitmapLockWrite = 0x2, }} FLAGS!{enum WICBitmapDecoderCapabilities { WICBitmapDecoderCapabilitySameEncoder = 0x1, WICBitmapDecoderCapabilityCanDecodeAllImages = 0x2, WICBitmapDecoderCapabilityCanDecodeSomeImages = 0x4, WICBitmapDecoderCapabilityCanEnumerateMetadata = 0x8, WICBitmapDecoderCapabilityCanDecodeThumbnail = 0x10, }} FLAGS!{enum WICProgressOperation { WICProgressOperationCopyPixels = 0x1, WICProgressOperationWritePixels = 0x2, WICProgressOperationAll = 0xffff, }} FLAGS!{enum WICProgressNotification { WICProgressNotificationBegin = 0x10000, WICProgressNotificationEnd = 0x20000, WICProgressNotificationFrequent = 0x40000, WICProgressNotificationAll = 0xffff0000, }} FLAGS!{enum WICComponentSigning { WICComponentSigned = 0x1, WICComponentUnsigned = 0x2, WICComponentSafe = 0x4, WICComponentDisabled = 0x80000000, }} ENUM!{enum WICGifLogicalScreenDescriptorProperties { WICGifLogicalScreenSignature = 0x1, WICGifLogicalScreenDescriptorWidth = 0x2, WICGifLogicalScreenDescriptorHeight = 0x3, WICGifLogicalScreenDescriptorGlobalColorTableFlag = 0x4, WICGifLogicalScreenDescriptorColorResolution = 0x5, WICGifLogicalScreenDescriptorSortFlag = 0x6, WICGifLogicalScreenDescriptorGlobalColorTableSize = 0x7, WICGifLogicalScreenDescriptorBackgroundColorIndex = 0x8, WICGifLogicalScreenDescriptorPixelAspectRatio = 0x9, }} ENUM!{enum WICGifImageDescriptorProperties { WICGifImageDescriptorLeft = 0x1, WICGifImageDescriptorTop = 0x2, WICGifImageDescriptorWidth = 0x3, WICGifImageDescriptorHeight = 0x4, WICGifImageDescriptorLocalColorTableFlag = 0x5, WICGifImageDescriptorInterlaceFlag = 0x6, WICGifImageDescriptorSortFlag = 0x7, WICGifImageDescriptorLocalColorTableSize = 0x8, }} ENUM!{enum WICGifGraphicControlExtensionProperties { WICGifGraphicControlExtensionDisposal = 0x1, WICGifGraphicControlExtensionUserInputFlag = 0x2, WICGifGraphicControlExtensionTransparencyFlag = 0x3, WICGifGraphicControlExtensionDelay = 0x4, WICGifGraphicControlExtensionTransparentColorIndex = 0x5, }} ENUM!{enum WICGifApplicationExtensionProperties { WICGifApplicationExtensionApplication = 0x1, WICGifApplicationExtensionData = 0x2, }} ENUM!{enum WICGifCommentExtensionProperties { WICGifCommentExtensionText = 0x1, }} ENUM!{enum WICJpegCommentProperties { WICJpegCommentText = 0x1, }} ENUM!{enum WICJpegLuminanceProperties { WICJpegLuminanceTable = 0x1, }} ENUM!{enum WICJpegChrominanceProperties { WICJpegChrominanceTable = 0x1, }} ENUM!{enum WIC8BIMIptcProperties { WIC8BIMIptcPString = 0, WIC8BIMIptcEmbeddedIPTC = 0x1, }} ENUM!{enum WIC8BIMResolutionInfoProperties { WIC8BIMResolutionInfoPString = 0x1, WIC8BIMResolutionInfoHResolution = 0x2, WIC8BIMResolutionInfoHResolutionUnit = 0x3, WIC8BIMResolutionInfoWidthUnit = 0x4, WIC8BIMResolutionInfoVResolution = 0x5, WIC8BIMResolutionInfoVResolutionUnit = 0x6, WIC8BIMResolutionInfoHeightUnit = 0x7, }} ENUM!{enum WIC8BIMIptcDigestProperties { WIC8BIMIptcDigestPString = 0x1, WIC8BIMIptcDigestIptcDigest = 0x2, }} ENUM!{enum WICPngGamaProperties { WICPngGamaGamma = 0x1, }} ENUM!{enum WICPngBkgdProperties { WICPngBkgdBackgroundColor = 0x1, }} ENUM!{enum WICPngItxtProperties { WICPngItxtKeyword = 0x1, WICPngItxtCompressionFlag = 0x2, WICPngItxtLanguageTag = 0x3, WICPngItxtTranslatedKeyword = 0x4, WICPngItxtText = 0x5, }} ENUM!{enum WICPngChrmProperties { WICPngChrmWhitePointX = 0x1, WICPngChrmWhitePointY = 0x2, WICPngChrmRedX = 0x3, WICPngChrmRedY = 0x4, WICPngChrmGreenX = 0x5, WICPngChrmGreenY = 0x6, WICPngChrmBlueX = 0x7, WICPngChrmBlueY = 0x8, }} ENUM!{enum WICPngHistProperties { WICPngHistFrequencies = 0x1, }} ENUM!{enum WICPngIccpProperties { WICPngIccpProfileName = 0x1, WICPngIccpProfileData = 0x2, }} ENUM!{enum WICPngSrgbProperties { WICPngSrgbRenderingIntent = 0x1, }} ENUM!{enum WICPngTimeProperties { WICPngTimeYear = 0x1, WICPngTimeMonth = 0x2, WICPngTimeDay = 0x3, WICPngTimeHour = 0x4, WICPngTimeMinute = 0x5, WICPngTimeSecond = 0x6, }} ENUM!{enum WICSectionAccessLevel { WICSectionAccessLevelRead = 0x1, WICSectionAccessLevelReadWrite = 0x3, }} ENUM!{enum WICPixelFormatNumericRepresentation { WICPixelFormatNumericRepresentationUnspecified = 0, WICPixelFormatNumericRepresentationIndexed = 0x1, WICPixelFormatNumericRepresentationUnsignedInteger = 0x2, WICPixelFormatNumericRepresentationSignedInteger = 0x3, WICPixelFormatNumericRepresentationFixed = 0x4, WICPixelFormatNumericRepresentationFloat = 0x5, }} ENUM!{enum WICPlanarOptions { WICPlanarOptionsDefault = 0, WICPlanarOptionsPreserveSubsampling = 0x1, }} #[allow(unused_qualifications)] STRUCT!{struct WICImageParameters { PixelFormat: ::D2D1_PIXEL_FORMAT, DpiX: ::FLOAT, DpiY: ::FLOAT, Top: ::FLOAT, Left: ::FLOAT, PixelWidth: ::FLOAT, PixelHeight: ::FLOAT, }} #[allow(unused_qualifications)] STRUCT!{struct WICBitmapPlaneDescription { Format: WICPixelFormatGUID, Width: ::UINT, Height: ::UINT, }} #[allow(unused_qualifications)] STRUCT!{struct WICBitmapPlane { Format: WICPixelFormatGUID, pbBuffer: *mut ::BYTE, cbStride: ::UINT, cbBufferSize: ::UINT, }} RIDL!( interface IWICPalette(IWICPaletteVtbl): IUnknown(IUnknownVtbl) { fn InitializePredefined( &mut self, ePaletteType: WICBitmapPaletteType, fAddTransparentColor: ::BOOL ) -> ::HRESULT, fn InitializeCustom(&mut self, pColors: *mut WICColor, cCount: ::UINT) -> ::HRESULT, fn InitializeFromBitmap( &mut self, pISurface: *mut IWICBitmapSource, cCount: ::UINT, fAddTransparentColor: ::BOOL ) -> ::HRESULT, fn InitializeFromPalette(&mut self, pIPalette: *mut IWICPalette) -> ::HRESULT, fn GetType(&mut self, pePaletteType: *mut WICBitmapPaletteType) -> ::HRESULT, fn GetColorCount(&mut self, pcCount: *mut ::UINT) -> ::HRESULT, fn GetColors( &mut self, cCount: ::UINT, pColros: *mut WICColor, pcActualColors: *mut ::UINT ) -> ::HRESULT, fn IsBlackWhite(&mut self, pfIsBlackWhite: *mut ::BOOL) -> ::HRESULT, fn IsGrayscale(&mut self, pfIsGrayscale: *mut ::BOOL) -> ::HRESULT, fn HasAlpha(&mut self, pfHasAlpha: *mut ::BOOL) -> ::HRESULT }); RIDL!( interface IWICBitmapSource(IWICBitmapSourceVtbl): IUnknown(IUnknownVtbl) { fn GetSize(&mut self, puiWidth: *mut ::UINT, puiHeight: ::UINT) -> ::HRESULT, fn GetPixelFormat(&mut self, pPixelFormat: *mut WICPixelFormatGUID) -> ::HRESULT, fn GetResolution(&mut self, pDpiX: *mut f64, pDpiY: *mut f64) -> ::HRESULT, fn CopyPalette(&mut self, pIPalette: *mut IWICPalette) -> ::HRESULT, fn CopyPixels( &mut self, prc: *const WICRect, cbStride: ::UINT, cbBufferSize: ::UINT, pbBuffer: *mut ::BYTE ) -> ::HRESULT }); RIDL!( interface IWICFormatConverter(IWICFormatConverterVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { fn Initialize( &mut self, pISource: *mut IWICBitmapSource, dstFormat: REFWICPixelFormatGUID, dither: WICBitmapDitherType, pIPalette: *mut IWICPalette, alphaThreasholdPercent: f64, paletteTranslate: WICBitmapPaletteType ) -> ::HRESULT, fn CanConvert( &mut self, srcPixelFormat: REFWICPixelFormatGUID, dstPixelFormat: REFWICPixelFormatGUID, pfCanConvert: *mut ::BOOL ) -> ::HRESULT }); RIDL!( interface IWICPlanarFormatConverter(IWICPlanarFormatConverterVtbl) : IWICBitmapSource(IWICBitmapSourceVtbl) { fn Initialize( &mut self, ppPlanes: *mut *mut IWICBitmapSource, cPlanes: ::UINT, dstFormat: REFWICPixelFormatGUID, dither: WICBitmapDitherType, pIPalette: *mut IWICPalette, alphaThreasholdPercent: f64, paletteTranslate: WICBitmapPaletteType ) -> ::HRESULT, fn CanConvert( &mut self, pSrcPixelFormats: *const WICPixelFormatGUID, cSrcPlanes: ::UINT, dstPixelFormat: REFWICPixelFormatGUID, pfCanConvert: *mut ::BOOL ) -> ::HRESULT }); RIDL!( interface IWICBitmapScaler(IWICBitmapScalerVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { fn Initialize( &mut self, pISource: *mut IWICBitmapSource, uiWidth: ::UINT, uiHeight: ::UINT, mode: WICBitmapInterpolationMode ) -> ::HRESULT }); RIDL!( interface IWICBitmapClipper(IWICBitmapClipperVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { fn Initialize(&mut self, pISource: *mut IWICBitmapSource, prc: *const WICRect) -> ::HRESULT }); RIDL!( interface IWICBitmapFlipRotator(IWICBitmapFlipRotatorVtbl) : IWICBitmapSource(IWICBitmapSourceVtbl) { fn Initialize( &mut self, pISource: *mut IWICBitmapSource, options: WICBitmapTransformOptions ) -> ::HRESULT }); RIDL!( interface IWICBitmapLock(IWICBitmapLockVtbl): IUnknown(IUnknownVtbl) { fn GetSize(&mut self, puiWidth: *mut ::UINT, puiHeight: *mut ::UINT) -> ::HRESULT, fn GetStride(&mut self, pcbStride: *mut ::UINT) -> ::HRESULT, fn GetDataPointer( &mut self, pcbBufferSize: *mut ::UINT, ppbData: *mut WICInProcPointer ) -> ::HRESULT, fn GetPixelFormat(&mut self, pPixelFormat: *mut WICPixelFormatGUID) -> ::HRESULT }); RIDL!( interface IWICBitmap(IWICBitmapVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { fn Lock( &mut self, prcLock: *const WICRect, flags: ::DWORD, ppILock: *mut *mut IWICBitmapLock ) -> ::HRESULT, fn SetPalette(&mut self, pIPalette: *mut IWICPalette) -> ::HRESULT, fn SetResolution(&mut self, dpiX: f64, dpiY: f64) -> ::HRESULT }); deps/winapi-0.2.5/src/dpapi.rs0000644000000000000000000000063312613167613014700 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Data Protection API Prototypes and Definitions pub const szFORCE_KEY_PROTECTION: &'static str = "ForceKeyProtection"; STRUCT!{struct CRYPTPROTECT_PROMPTSTRUCT { cbSize: ::DWORD, dwPromptFlags: ::DWORD, hwndApp: ::HWND, szPrompt: ::LPCWSTR, }} pub type PCRYPTPROTECT_PROMPTSTRUCT = *mut CRYPTPROTECT_PROMPTSTRUCT; deps/winapi-0.2.5/src/commctrl.rs0000644000000000000000000041346712615662007015437 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //138 STRUCT!{struct INITCOMMONCONTROLSEX { dwSize: ::DWORD, dwICC: ::DWORD, }} pub type LPINITCOMMONCONTROLSEX = *mut INITCOMMONCONTROLSEX; pub const ICC_LISTVIEW_CLASSES: ::DWORD = 0x1; pub const ICC_TREEVIEW_CLASSES: ::DWORD = 0x2; pub const ICC_BAR_CLASSES: ::DWORD = 0x4; pub const ICC_TAB_CLASSES: ::DWORD = 0x8; pub const ICC_UPDOWN_CLASS: ::DWORD = 0x10; pub const ICC_PROGRESS_CLASS: ::DWORD = 0x20; pub const ICC_HOTKEY_CLASS: ::DWORD = 0x40; pub const ICC_ANIMATE_CLASS: ::DWORD = 0x80; pub const ICC_WIN95_CLASSES: ::DWORD = 0xFF; pub const ICC_DATE_CLASSES: ::DWORD = 0x100; pub const ICC_USEREX_CLASSES: ::DWORD = 0x200; pub const ICC_COOL_CLASSES: ::DWORD = 0x400; pub const ICC_INTERNET_CLASSES: ::DWORD = 0x800; pub const ICC_PAGESCROLLER_CLASS: ::DWORD = 0x1000; pub const ICC_NATIVEFNTCTL_CLASS: ::DWORD = 0x2000; pub const ICC_STANDARD_CLASSES: ::DWORD = 0x4000; pub const ICC_LINK_CLASS: ::DWORD = 0x8000; pub const ODT_HEADER: ::UINT = 100; pub const ODT_TAB: ::UINT = 101; pub const ODT_LISTVIEW: ::UINT = 102; pub const LVM_FIRST: ::UINT = 0x1000; pub const TV_FIRST: ::UINT = 0x1100; pub const HDM_FIRST: ::UINT = 0x1200; pub const TCM_FIRST: ::UINT = 0x1300; pub const PGM_FIRST: ::UINT = 0x1400; pub const ECM_FIRST: ::UINT = 0x1500; pub const BCM_FIRST: ::UINT = 0x1600; pub const CBM_FIRST: ::UINT = 0x1700; pub const CCM_FIRST: ::UINT = 0x2000; pub const CCM_LAST: ::UINT = CCM_FIRST + 0x200; pub const CCM_SETBKCOLOR: ::UINT = CCM_FIRST + 1; STRUCT!{struct COLORSCHEME { dwSize: ::DWORD, clrBtnHighlight: ::COLORREF, clrBtnShadow: ::COLORREF, }} pub type LPCOLORSCHEME = *mut COLORSCHEME; pub const CCM_SETCOLORSCHEME: ::UINT = CCM_FIRST + 2; pub const CCM_GETCOLORSCHEME: ::UINT = CCM_FIRST + 3; pub const CCM_GETDROPTARGET: ::UINT = CCM_FIRST + 4; pub const CCM_SETUNICODEFORMAT: ::UINT = CCM_FIRST + 5; pub const CCM_GETUNICODEFORMAT: ::UINT = CCM_FIRST + 6; pub const CCM_SETVERSION: ::UINT = CCM_FIRST + 7; pub const CCM_GETVERSION: ::UINT = CCM_FIRST + 8; pub const CCM_SETNOTIFYWINDOW: ::UINT = CCM_FIRST + 9; pub const CCM_SETWINDOWTHEME: ::UINT = CCM_FIRST + 0xb; pub const CCM_DPISCALE: ::UINT = CCM_FIRST + 0xc; pub const INFOTIPSIZE: ::c_int = 1024; pub const NM_OUTOFMEMORY: ::UINT = NM_FIRST-1; pub const NM_CLICK: ::UINT = NM_FIRST-2; pub const NM_DBLCLK: ::UINT = NM_FIRST-3; pub const NM_RETURN: ::UINT = NM_FIRST-4; pub const NM_RCLICK: ::UINT = NM_FIRST-5; pub const NM_RDBLCLK: ::UINT = NM_FIRST-6; pub const NM_SETFOCUS: ::UINT = NM_FIRST-7; pub const NM_KILLFOCUS: ::UINT = NM_FIRST-8; pub const NM_CUSTOMDRAW: ::UINT = NM_FIRST-12; pub const NM_HOVER: ::UINT = NM_FIRST-13; pub const NM_NCHITTEST: ::UINT = NM_FIRST-14; pub const NM_KEYDOWN: ::UINT = NM_FIRST-15; pub const NM_RELEASEDCAPTURE: ::UINT = NM_FIRST-16; pub const NM_SETCURSOR: ::UINT = NM_FIRST-17; pub const NM_CHAR: ::UINT = NM_FIRST-18; pub const NM_TOOLTIPSCREATED: ::UINT = NM_FIRST-19; pub const NM_LDOWN: ::UINT = NM_FIRST-20; pub const NM_RDOWN: ::UINT = NM_FIRST-21; pub const NM_THEMECHANGED: ::UINT = NM_FIRST-22; pub const NM_FONTCHANGED: ::UINT = NM_FIRST-23; pub const NM_CUSTOMTEXT: ::UINT = NM_FIRST-24; pub const NM_TVSTATEIMAGECHANGING: ::UINT = NM_FIRST-24; STRUCT!{struct NMTOOLTIPSCREATED { hdr: ::NMHDR, hwndToolTips: ::HWND, }} pub type LPNMTOOLTIPSCREATED = *mut NMTOOLTIPSCREATED; STRUCT!{struct NMMOUSE { hdr : ::NMHDR, dwItemSpec: ::DWORD_PTR, dwItemData: ::DWORD_PTR, pt: ::POINT, dwHitInfo: ::LPARAM, }} pub type LPNMMOUSE = *mut NMMOUSE; pub type NMCLICK = NMMOUSE; pub type LPNMCLICK = LPNMMOUSE; STRUCT!{struct NMOBJECTNOTIFY { hdr: ::NMHDR, iItem: ::c_int, piid: *const ::IID, pObject: *mut ::c_void, hResult: ::HRESULT, dwFlags: ::DWORD, }} pub type LPNMOBJECTNOTIFY = *mut NMOBJECTNOTIFY; STRUCT!{struct NMKEY { hdr: ::NMHDR, nVKey: ::UINT, uFlags: ::UINT, }} pub type LPNMKEY = *mut NMKEY; STRUCT!{struct NMCHAR { hdr: ::NMHDR, ch: ::UINT, dwItemPrev: ::DWORD, dwItemNext: ::DWORD, }} pub type LPNMCHAR = *mut NMCHAR; STRUCT!{struct NMCUSTOMTEXT { hdr: ::NMHDR, hDC: ::HDC, lpString: ::LPCWSTR, nCount: ::c_int, lpRect: ::LPRECT, uFormat: ::UINT, fLink: ::BOOL, }} pub type LPNMCUSTOMTEXT = *mut NMCUSTOMTEXT; pub const NM_FIRST: ::UINT = 0; pub const NM_LAST: ::UINT = 0 - 99; pub const LVN_FIRST: ::UINT = 0 - 100; pub const LVN_LAST: ::UINT = 0 - 199; pub const HDN_FIRST: ::UINT = 0 - 300; pub const HDN_LAST: ::UINT = 0 - 399; pub const TVN_FIRST: ::UINT = 0 - 400; pub const TVN_LAST: ::UINT = 0 - 499; pub const TTN_FIRST: ::UINT = 0 - 520; pub const TTN_LAST: ::UINT = 0 - 549; pub const TCN_FIRST: ::UINT = 0 - 550; pub const TCN_LAST: ::UINT = 0 - 580; // pub const CDN_FIRST: ::UINT = 0 - 601; // pub const CDN_LAST: ::UINT = 0 - 699; pub const TBN_FIRST: ::UINT = 0 - 700; pub const TBN_LAST: ::UINT = 0 - 720; pub const UDN_FIRST: ::UINT = 0 - 721; pub const UDN_LAST: ::UINT = 0 - 729; pub const DTN_FIRST: ::UINT = 0 - 740; pub const DTN_LAST: ::UINT = 0 - 745; pub const MCN_FIRST: ::UINT = 0 - 746; pub const MCN_LAST: ::UINT = 0 - 752; pub const DTN_FIRST2: ::UINT = 0 - 753; pub const DTN_LAST2: ::UINT = 0 - 799; pub const CBEN_FIRST: ::UINT = 0 - 800; pub const CBEN_LAST: ::UINT = 0 - 830; pub const RBN_FIRST: ::UINT = 0 - 831; pub const RBN_LAST: ::UINT = 0 - 859; pub const IPN_FIRST: ::UINT = 0 - 860; pub const IPN_LAST: ::UINT = 0 - 879; pub const SBN_FIRST: ::UINT = 0 - 880; pub const SBN_LAST: ::UINT = 0 - 899; pub const PGN_FIRST: ::UINT = 0 - 900; pub const PGN_LAST: ::UINT = 0 - 950; pub const WMN_FIRST: ::UINT = 0 - 1000; pub const WMN_LAST: ::UINT = 0 - 1200; pub const BCN_FIRST: ::UINT = 0 - 1250; pub const BCN_LAST: ::UINT = 0 - 1350; pub const TRBN_FIRST: ::UINT = 0 - 1501; pub const TRBN_LAST: ::UINT = 0 - 1519; pub const CDRF_DODEFAULT: ::LRESULT = 0x00000000; pub const CDRF_NEWFONT: ::LRESULT = 0x00000002; pub const CDRF_SKIPDEFAULT: ::LRESULT = 0x00000004; pub const CDRF_DOERASE: ::LRESULT = 0x00000008; pub const CDRF_SKIPPOSTPAINT: ::LRESULT = 0x00000100; pub const CDRF_NOTIFYPOSTPAINT: ::LRESULT = 0x00000010; pub const CDRF_NOTIFYITEMDRAW: ::LRESULT = 0x00000020; pub const CDRF_NOTIFYSUBITEMDRAW: ::LRESULT = 0x00000020; pub const CDRF_NOTIFYPOSTERASE: ::LRESULT = 0x00000040; pub const CDDS_PREPAINT: ::DWORD = 0x00000001; pub const CDDS_POSTPAINT: ::DWORD = 0x00000002; pub const CDDS_PREERASE: ::DWORD = 0x00000003; pub const CDDS_POSTERASE: ::DWORD = 0x00000004; pub const CDDS_ITEM: ::DWORD = 0x00010000; pub const CDDS_ITEMPREPAINT: ::DWORD = CDDS_ITEM | CDDS_PREPAINT; pub const CDDS_ITEMPOSTPAINT: ::DWORD = CDDS_ITEM | CDDS_POSTPAINT; pub const CDDS_ITEMPREERASE: ::DWORD = CDDS_ITEM | CDDS_PREERASE; pub const CDDS_ITEMPOSTERASE: ::DWORD = CDDS_ITEM | CDDS_POSTERASE; pub const CDDS_SUBITEM: ::DWORD = 0x00020000; pub const CDIS_SELECTED: ::UINT = 0x0001; pub const CDIS_GRAYED: ::UINT = 0x0002; pub const CDIS_DISABLED: ::UINT = 0x0004; pub const CDIS_CHECKED: ::UINT = 0x0008; pub const CDIS_FOCUS: ::UINT = 0x0010; pub const CDIS_DEFAULT: ::UINT = 0x0020; pub const CDIS_HOT: ::UINT = 0x0040; pub const CDIS_MARKED: ::UINT = 0x0080; pub const CDIS_INDETERMINATE: ::UINT = 0x0100; pub const CDIS_SHOWKEYBOARDCUES: ::UINT = 0x0200; pub const CDIS_NEARHOT: ::UINT = 0x0400; pub const CDIS_OTHERSIDEHOT: ::UINT = 0x0800; pub const CDIS_DROPHILITED: ::UINT = 0x1000; STRUCT!{struct NMCUSTOMDRAW { hdr: ::NMHDR, dwDrawStage: ::DWORD, hdc: ::HDC, rc: ::RECT, dwItemSpec: ::DWORD_PTR, uItemState: ::UINT, lItemlParam: ::LPARAM, }} pub type LPNMCUSTOMDRAW = *mut NMCUSTOMDRAW; STRUCT!{struct NMTTCUSTOMDRAW { nmcd: NMCUSTOMDRAW, uDrawFlags: ::UINT, }} pub type LPNMTTCUSTOMDRAW = *mut NMTTCUSTOMDRAW; STRUCT!{struct NMCUSTOMSPLITRECTINFO { hdr: ::NMHDR, rcClient: ::RECT, rcButton: ::RECT, rcSplit: ::RECT, }} pub type LPNMCUSTOMSPLITRECTINFO = *mut NMCUSTOMSPLITRECTINFO; pub const NM_GETCUSTOMSPLITRECT: ::UINT = BCN_FIRST + 0x0003; pub const CLR_NONE: ::DWORD = 0xFFFFFFFF; pub const CLR_DEFAULT: ::DWORD = 0xFF000000; #[repr(C)] #[allow(missing_copy_implementations)] pub struct IMAGELIST { unused: ::c_void, } pub type HIMAGELIST = *mut IMAGELIST; STRUCT!{struct IMAGELISTDRAWPARAMS { cbSize: ::DWORD, himl: HIMAGELIST, i: ::c_int, hdcDst: ::HDC, x: ::c_int, y: ::c_int, cx: ::c_int, cy: ::c_int, xBitmap: ::c_int, yBitmap: ::c_int, rgbBk: ::COLORREF, rgbFg: ::COLORREF, fStyle: ::UINT, dwRop: ::DWORD, fState: ::DWORD, Frame: ::DWORD, crEffect: ::COLORREF, }} pub type LPIMAGELISTDRAWPARAMS = *mut IMAGELISTDRAWPARAMS; pub const ILC_MASK: ::UINT = 0x00000001; pub const ILC_COLOR: ::UINT = 0x00000000; pub const ILC_COLORDDB: ::UINT = 0x000000FE; pub const ILC_COLOR4: ::UINT = 0x00000004; pub const ILC_COLOR8: ::UINT = 0x00000008; pub const ILC_COLOR16: ::UINT = 0x00000010; pub const ILC_COLOR24: ::UINT = 0x00000018; pub const ILC_COLOR32: ::UINT = 0x00000020; pub const ILC_PALETTE: ::UINT = 0x00000800; pub const ILC_MIRROR: ::UINT = 0x00002000; pub const ILC_PERITEMMIRROR: ::UINT = 0x00008000; pub const ILC_ORIGINALSIZE: ::UINT = 0x00010000; pub const ILC_HIGHQUALITYSCALE: ::UINT = 0x00020000; pub const ILD_NORMAL: ::UINT = 0x00000000; pub const ILD_TRANSPARENT: ::UINT = 0x00000001; pub const ILD_MASK: ::UINT = 0x00000010; pub const ILD_IMAGE: ::UINT = 0x00000020; pub const ILD_ROP: ::UINT = 0x00000040; pub const ILD_BLEND25: ::UINT = 0x00000002; pub const ILD_BLEND50: ::UINT = 0x00000004; pub const ILD_OVERLAYMASK: ::UINT = 0x00000F00; #[inline] #[allow(dead_code)] pub fn INDEXTOOVERLAYMASK(i: ::UINT) -> ::UINT { i << 8 } pub const ILD_PRESERVEALPHA: ::UINT = 0x00001000; pub const ILD_SCALE: ::UINT = 0x00002000; pub const ILD_DPISCALE: ::UINT = 0x00004000; pub const ILD_ASYNC: ::UINT = 0x00008000; pub const ILD_SELECTED: ::UINT = ILD_BLEND50; pub const ILD_FOCUS: ::UINT = ILD_BLEND25; pub const ILD_BLEND: ::UINT = ILD_BLEND50; pub const CLR_HILIGHT: ::DWORD = CLR_DEFAULT; pub const ILS_NORMAL: ::DWORD = 0x00000000; pub const ILS_GLOW: ::DWORD = 0x00000001; pub const ILS_SHADOW: ::DWORD = 0x00000002; pub const ILS_SATURATE: ::DWORD = 0x00000004; pub const ILS_ALPHA: ::DWORD = 0x00000008; pub const HBITMAP_CALLBACK: ::HBITMAP = (0-1) as ::HBITMAP; pub const ILCF_MOVE: ::UINT = 0x00000000; pub const ILCF_SWAP: ::UINT = 0x00000001; STRUCT!{struct IMAGEINFO { hbmImage: ::HBITMAP, hbmMask: ::HBITMAP, Unused1: ::c_int, Unused2: ::c_int, rcImage: ::RECT, }} pub type LPIMAGEINFO = *mut IMAGEINFO; pub const HDS_HORZ: ::DWORD = 0x0000; pub const HDS_BUTTONS: ::DWORD = 0x0002; pub const HDS_HOTTRACK: ::DWORD = 0x0004; pub const HDS_HIDDEN: ::DWORD = 0x0008; pub const HDS_DRAGDROP: ::DWORD = 0x0040; pub const HDS_FULLDRAG: ::DWORD = 0x0080; pub const HDS_FILTERBAR: ::DWORD = 0x0100; pub const HDS_FLAT: ::DWORD = 0x0200; pub const HDS_CHECKBOXES: ::DWORD = 0x0400; pub const HDS_NOSIZING: ::DWORD = 0x0800; pub const HDS_OVERFLOW: ::DWORD = 0x1000; pub const HDFT_ISSTRING: ::UINT = 0x0000; pub const HDFT_ISNUMBER: ::UINT = 0x0001; pub const HDFT_ISDATE: ::UINT = 0x0002; pub const HDFT_HASNOVALUE: ::UINT = 0x8000; STRUCT!{struct HD_TEXTFILTERA { pszText: ::LPSTR, cchTextMax: ::INT, }} pub type LPHD_TEXTFILTERA = *mut HD_TEXTFILTERA; STRUCT!{struct HD_TEXTFILTERW { pszText: ::LPWSTR, cchTextMax: ::INT, }} pub type LPHD_TEXTFILTERW = *mut HD_TEXTFILTERW; STRUCT!{struct HDITEMA { mask: ::UINT, cxy: ::c_int, pszText: ::LPSTR, hbm: ::HBITMAP, cchTextMax: ::c_int, fmt: ::c_int, lParam: ::LPARAM, iImage: ::c_int, iOrder: ::c_int, _type: ::UINT, pvFilter: *mut ::c_void, state: ::UINT, }} pub type LPHDITEMA = *mut HDITEMA; STRUCT!{struct HDITEMW { mask: ::UINT, cxy: ::c_int, pszText: ::LPWSTR, hbm: ::HBITMAP, cchTextMax: ::c_int, fmt: ::c_int, lParam: ::LPARAM, iImage: ::c_int, iOrder: ::c_int, _type: ::UINT, pvFilter: *mut ::c_void, state: ::UINT, }} pub type LPHDITEMW = *mut HDITEMW; pub const HDI_WIDTH: ::UINT = 0x0001; pub const HDI_HEIGHT: ::UINT = HDI_WIDTH; pub const HDI_TEXT: ::UINT = 0x0002; pub const HDI_FORMAT: ::UINT = 0x0004; pub const HDI_LPARAM: ::UINT = 0x0008; pub const HDI_BITMAP: ::UINT = 0x0010; pub const HDI_IMAGE: ::UINT = 0x0020; pub const HDI_DI_SETITEM: ::UINT = 0x0040; pub const HDI_ORDER: ::UINT = 0x0080; pub const HDI_FILTER: ::UINT = 0x0100; pub const HDI_STATE: ::UINT = 0x0200; pub const HDF_LEFT: ::c_int = 0x0000; pub const HDF_RIGHT: ::c_int = 0x0001; pub const HDF_CENTER: ::c_int = 0x0002; pub const HDF_JUSTIFYMASK: ::c_int = 0x0003; pub const HDF_RTLREADING: ::c_int = 0x0004; pub const HDF_BITMAP: ::c_int = 0x2000; pub const HDF_STRING: ::c_int = 0x4000; pub const HDF_OWNERDRAW: ::c_int = 0x8000; pub const HDF_IMAGE: ::c_int = 0x0800; pub const HDF_BITMAP_ON_RIGHT: ::c_int = 0x1000; pub const HDF_SORTUP: ::c_int = 0x0400; pub const HDF_SORTDOWN: ::c_int = 0x0200; pub const HDF_CHECKBOX: ::c_int = 0x0040; pub const HDF_CHECKED: ::c_int = 0x0080; pub const HDF_FIXEDWIDTH: ::c_int = 0x0100; pub const HDF_SPLITBUTTON: ::c_int = 0x1000000; pub const HDIS_FOCUSED: ::UINT = 0x00000001; pub const HDM_GETITEMCOUNT: ::UINT = HDM_FIRST + 0; pub const HDM_INSERTITEMA: ::UINT = HDM_FIRST + 1; pub const HDM_INSERTITEMW: ::UINT = HDM_FIRST + 10; pub const HDM_DELETEITEM: ::UINT = HDM_FIRST + 2; pub const HDM_GETITEMA: ::UINT = HDM_FIRST + 3; pub const HDM_GETITEMW: ::UINT = HDM_FIRST + 11; pub const HDM_SETITEMA: ::UINT = HDM_FIRST + 4; pub const HDM_SETITEMW: ::UINT = HDM_FIRST + 12; STRUCT!{struct HDLAYOUT { prc: *mut ::RECT, pwpos: *mut ::WINDOWPOS, }} pub type LPHDLAYOUT = *mut HDLAYOUT; pub const HDM_LAYOUT: ::UINT = HDM_FIRST + 5; pub const HHT_NOWHERE: ::UINT = 0x0001; pub const HHT_ONHEADER: ::UINT = 0x0002; pub const HHT_ONDIVIDER: ::UINT = 0x0004; pub const HHT_ONDIVOPEN: ::UINT = 0x0008; pub const HHT_ONFILTER: ::UINT = 0x0010; pub const HHT_ONFILTERBUTTON: ::UINT = 0x0020; pub const HHT_ABOVE: ::UINT = 0x0100; pub const HHT_BELOW: ::UINT = 0x0200; pub const HHT_TORIGHT: ::UINT = 0x0400; pub const HHT_TOLEFT: ::UINT = 0x0800; pub const HHT_ONITEMSTATEICON: ::UINT = 0x1000; pub const HHT_ONDROPDOWN: ::UINT = 0x2000; pub const HHT_ONOVERFLOW: ::UINT = 0x4000; STRUCT!{struct HDHITTESTINFO { pt: ::POINT, flags: ::UINT, iItem: ::c_int, }} pub type LPHDHITTESTINFO = *mut HDHITTESTINFO; pub const HDSIL_NORMAL: ::WPARAM = 0; pub const HDSIL_STATE: ::WPARAM = 1; pub const HDM_HITTEST: ::UINT = HDM_FIRST + 6; pub const HDM_GETITEMRECT: ::UINT = HDM_FIRST + 7; pub const HDM_SETIMAGELIST: ::UINT = HDM_FIRST + 8; pub const HDM_GETIMAGELIST: ::UINT = HDM_FIRST + 9; pub const HDM_ORDERTOINDEX: ::UINT = HDM_FIRST + 15; pub const HDM_CREATEDRAGIMAGE: ::UINT = HDM_FIRST + 16; pub const HDM_GETORDERARRAY: ::UINT = HDM_FIRST + 17; pub const HDM_SETORDERARRAY: ::UINT = HDM_FIRST + 18; pub const HDM_SETHOTDIVIDER: ::UINT = HDM_FIRST + 19; pub const HDM_SETBITMAPMARGIN: ::UINT = HDM_FIRST + 20; pub const HDM_GETBITMAPMARGIN: ::UINT = HDM_FIRST + 21; pub const HDM_SETFILTERCHANGETIMEOUT: ::UINT = HDM_FIRST + 22; pub const HDM_EDITFILTER: ::UINT = HDM_FIRST + 23; pub const HDM_CLEARFILTER: ::UINT = HDM_FIRST + 24; pub const HDM_GETITEMDROPDOWNRECT: ::UINT = HDM_FIRST + 25; pub const HDM_GETOVERFLOWRECT: ::UINT = HDM_FIRST + 26; pub const HDM_GETFOCUSEDITEM: ::UINT = HDM_FIRST + 27; pub const HDM_SETFOCUSEDITEM: ::UINT = HDM_FIRST + 28; pub const HDN_ITEMCHANGINGA: ::UINT = HDN_FIRST-0; pub const HDN_ITEMCHANGINGW: ::UINT = HDN_FIRST-20; pub const HDN_ITEMCHANGEDA: ::UINT = HDN_FIRST-1; pub const HDN_ITEMCHANGEDW: ::UINT = HDN_FIRST-21; pub const HDN_ITEMCLICKA: ::UINT = HDN_FIRST-2; pub const HDN_ITEMCLICKW: ::UINT = HDN_FIRST-22; pub const HDN_ITEMDBLCLICKA: ::UINT = HDN_FIRST-3; pub const HDN_ITEMDBLCLICKW: ::UINT = HDN_FIRST-23; pub const HDN_DIVIDERDBLCLICKA: ::UINT = HDN_FIRST-5; pub const HDN_DIVIDERDBLCLICKW: ::UINT = HDN_FIRST-25; pub const HDN_BEGINTRACKA: ::UINT = HDN_FIRST-6; pub const HDN_BEGINTRACKW: ::UINT = HDN_FIRST-26; pub const HDN_ENDTRACKA: ::UINT = HDN_FIRST-7; pub const HDN_ENDTRACKW: ::UINT = HDN_FIRST-27; pub const HDN_TRACKA: ::UINT = HDN_FIRST-8; pub const HDN_TRACKW: ::UINT = HDN_FIRST-28; pub const HDN_GETDISPINFOA: ::UINT = HDN_FIRST-9; pub const HDN_GETDISPINFOW: ::UINT = HDN_FIRST-29; pub const HDN_BEGINDRAG: ::UINT = HDN_FIRST-10; pub const HDN_ENDDRAG: ::UINT = HDN_FIRST-11; pub const HDN_FILTERCHANGE: ::UINT = HDN_FIRST-12; pub const HDN_FILTERBTNCLICK: ::UINT = HDN_FIRST-13; pub const HDN_BEGINFILTEREDIT: ::UINT = HDN_FIRST-14; pub const HDN_ENDFILTEREDIT: ::UINT = HDN_FIRST-15; pub const HDN_ITEMSTATEICONCLICK: ::UINT = HDN_FIRST-16; pub const HDN_ITEMKEYDOWN: ::UINT = HDN_FIRST-17; pub const HDN_DROPDOWN: ::UINT = HDN_FIRST-18; pub const HDN_OVERFLOWCLICK: ::UINT = HDN_FIRST-19; STRUCT!{struct NMHEADERA { hdr: ::NMHDR, iItem: ::c_int, iButton: ::c_int, pitem: *mut HDITEMA, }} pub type LPNMHEADERA = *mut NMHEADERA; STRUCT!{struct NMHEADERW { hdr: ::NMHDR, iItem: ::c_int, iButton: ::c_int, pitem: *mut HDITEMW, }} pub type LPNMHEADERW = *mut NMHEADERW; STRUCT!{struct NMHDDISPINFOW { hdr: ::NMHDR, iItem: ::c_int, mask: ::UINT, pszText: ::LPWSTR, cchTextMax: ::c_int, iImage: ::c_int, lParam: ::LPARAM, }} pub type LPNMHDDISPINFOW = *mut NMHDDISPINFOW; STRUCT!{struct NMHDDISPINFOA { hdr: ::NMHDR, iItem: ::c_int, mask: ::UINT, pszText: ::LPSTR, cchTextMax: ::c_int, iImage: ::c_int, lParam: ::LPARAM, }} pub type LPNMHDDISPINFOA = *mut NMHDDISPINFOA; STRUCT!{struct NMHDFILTERBTNCLICK { hdr: ::NMHDR, iItem: ::INT, rc: ::RECT, }} pub type LPNMHDFILTERBTNCLICK = *mut NMHDFILTERBTNCLICK; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct TBBUTTON { pub iBitmap: ::c_int, pub idCommand: ::c_int, pub fsState: ::BYTE, pub fsStyle: ::BYTE, #[cfg(target_arch="x86_64")] pub bReserved: [::BYTE; 6], #[cfg(target_arch="x86")] pub bReserved: [::BYTE; 2], pub dwData: ::DWORD_PTR, pub iString: ::INT_PTR, } pub type PTBBUTTON = *mut TBBUTTON; pub type LPTBBUTTON = *mut TBBUTTON; pub type LPCTBBUTTON = *const TBBUTTON; STRUCT!{struct COLORMAP { from: ::COLORREF, to: ::COLORREF, }} pub type LPCOLORMAP = *mut COLORMAP; pub const CMB_MASKED: ::UINT = 0x02; pub const TBSTATE_CHECKED: ::BYTE = 0x01; pub const TBSTATE_PRESSED: ::BYTE = 0x02; pub const TBSTATE_ENABLED: ::BYTE = 0x04; pub const TBSTATE_HIDDEN: ::BYTE = 0x08; pub const TBSTATE_INDETERMINATE: ::BYTE = 0x10; pub const TBSTATE_WRAP: ::BYTE = 0x20; pub const TBSTATE_ELLIPSES: ::BYTE = 0x40; pub const TBSTATE_MARKED: ::BYTE = 0x80; pub const TBSTYLE_BUTTON: ::DWORD = 0x0000; pub const TBSTYLE_SEP: ::DWORD = 0x0001; pub const TBSTYLE_CHECK: ::DWORD = 0x0002; pub const TBSTYLE_GROUP: ::DWORD = 0x0004; pub const TBSTYLE_CHECKGROUP: ::DWORD = TBSTYLE_GROUP | TBSTYLE_CHECK; pub const TBSTYLE_DROPDOWN: ::DWORD = 0x0008; pub const TBSTYLE_AUTOSIZE: ::DWORD = 0x0010; pub const TBSTYLE_NOPREFIX: ::DWORD = 0x0020; pub const TBSTYLE_TOOLTIPS: ::DWORD = 0x0100; pub const TBSTYLE_WRAPABLE: ::DWORD = 0x0200; pub const TBSTYLE_ALTDRAG: ::DWORD = 0x0400; pub const TBSTYLE_FLAT: ::DWORD = 0x0800; pub const TBSTYLE_LIST: ::DWORD = 0x1000; pub const TBSTYLE_CUSTOMERASE: ::DWORD = 0x2000; pub const TBSTYLE_REGISTERDROP: ::DWORD = 0x4000; pub const TBSTYLE_TRANSPARENT: ::DWORD = 0x8000; pub const TBSTYLE_EX_DRAWDDARROWS: ::DWORD = 0x00000001; pub const BTNS_BUTTON: ::DWORD = TBSTYLE_BUTTON; pub const BTNS_SEP: ::DWORD = TBSTYLE_SEP; pub const BTNS_CHECK: ::DWORD = TBSTYLE_CHECK; pub const BTNS_GROUP: ::DWORD = TBSTYLE_GROUP; pub const BTNS_CHECKGROUP: ::DWORD = TBSTYLE_CHECKGROUP; pub const BTNS_DROPDOWN: ::DWORD = TBSTYLE_DROPDOWN; pub const BTNS_AUTOSIZE: ::DWORD = TBSTYLE_AUTOSIZE; pub const BTNS_NOPREFIX: ::DWORD = TBSTYLE_NOPREFIX; pub const BTNS_SHOWTEXT: ::DWORD = 0x0040; pub const BTNS_WHOLEDROPDOWN: ::DWORD = 0x0080; pub const TBSTYLE_EX_MIXEDBUTTONS: ::DWORD = 0x00000008; pub const TBSTYLE_EX_HIDECLIPPEDBUTTONS: ::DWORD = 0x00000010; pub const TBSTYLE_EX_MULTICOLUMN: ::DWORD = 0x00000002; pub const TBSTYLE_EX_VERTICAL: ::DWORD = 0x00000004; pub const TBSTYLE_EX_DOUBLEBUFFER: ::DWORD = 0x00000080; STRUCT!{struct NMTBCUSTOMDRAW { nmcd: NMCUSTOMDRAW, hbrMonoDither: ::HBRUSH, hbrLines: ::HBRUSH, hpenLines: ::HPEN, clrText: ::COLORREF, clrMark: ::COLORREF, clrTextHighlight: ::COLORREF, clrBtnFace: ::COLORREF, clrBtnHighlight: ::COLORREF, clrHighlightHotTrack: ::COLORREF, rcText: ::RECT, nStringBkMode: ::c_int, nHLStringBkMode: ::c_int, iListGap: ::c_int, }} pub type LPNMTBCUSTOMDRAW = *mut NMTBCUSTOMDRAW; pub const TBCDRF_NOEDGES: ::LRESULT = 0x00010000; pub const TBCDRF_HILITEHOTTRACK: ::LRESULT = 0x00020000; pub const TBCDRF_NOOFFSET: ::LRESULT = 0x00040000; pub const TBCDRF_NOMARK: ::LRESULT = 0x00080000; pub const TBCDRF_NOETCHEDEFFECT: ::LRESULT = 0x00100000; pub const TBCDRF_BLENDICON: ::LRESULT = 0x00200000; pub const TBCDRF_NOBACKGROUND: ::LRESULT = 0x00400000; pub const TBCDRF_USECDCOLORS: ::LRESULT = 0x00800000; pub const TB_ENABLEBUTTON: ::UINT = ::WM_USER + 1; pub const TB_CHECKBUTTON: ::UINT = ::WM_USER + 2; pub const TB_PRESSBUTTON: ::UINT = ::WM_USER + 3; pub const TB_HIDEBUTTON: ::UINT = ::WM_USER + 4; pub const TB_INDETERMINATE: ::UINT = ::WM_USER + 5; pub const TB_MARKBUTTON: ::UINT = ::WM_USER + 6; pub const TB_ISBUTTONENABLED: ::UINT = ::WM_USER + 9; pub const TB_ISBUTTONCHECKED: ::UINT = ::WM_USER + 10; pub const TB_ISBUTTONPRESSED: ::UINT = ::WM_USER + 11; pub const TB_ISBUTTONHIDDEN: ::UINT = ::WM_USER + 12; pub const TB_ISBUTTONINDETERMINATE : ::UINT = ::WM_USER + 13; pub const TB_ISBUTTONHIGHLIGHTED: ::UINT = ::WM_USER + 14; pub const TB_SETSTATE: ::UINT = ::WM_USER + 17; pub const TB_GETSTATE: ::UINT = ::WM_USER + 18; pub const TB_ADDBITMAP: ::UINT = ::WM_USER + 19; STRUCT!{struct TBADDBITMAP { hInst: ::HINSTANCE, nID: ::UINT_PTR, }} pub type LPTBADDBITMAP = *mut TBADDBITMAP; pub const HINST_COMMCTRL: ::HINSTANCE = (0 - 1) as ::HINSTANCE; pub const IDB_STD_SMALL_COLOR: ::WPARAM = 0; pub const IDB_STD_LARGE_COLOR: ::WPARAM = 1; pub const IDB_VIEW_SMALL_COLOR: ::WPARAM = 4; pub const IDB_VIEW_LARGE_COLOR: ::WPARAM = 5; pub const IDB_HIST_SMALL_COLOR: ::WPARAM = 8; pub const IDB_HIST_LARGE_COLOR: ::WPARAM = 9; pub const IDB_HIST_NORMAL: ::WPARAM = 12; pub const IDB_HIST_HOT: ::WPARAM = 13; pub const IDB_HIST_DISABLED: ::WPARAM = 14; pub const IDB_HIST_PRESSED: ::WPARAM = 15; pub const STD_CUT: ::c_int = 0; pub const STD_COPY: ::c_int = 1; pub const STD_PASTE: ::c_int = 2; pub const STD_UNDO: ::c_int = 3; pub const STD_REDOW: ::c_int = 4; pub const STD_DELETE: ::c_int = 5; pub const STD_FILENEW: ::c_int = 6; pub const STD_FILEOPEN: ::c_int = 7; pub const STD_FILESAVE: ::c_int = 8; pub const STD_PRINTPRE: ::c_int = 9; pub const STD_PROPERTIES: ::c_int = 10; pub const STD_HELP: ::c_int = 11; pub const STD_FIND: ::c_int = 12; pub const STD_REPLACE: ::c_int = 13; pub const STD_PRINT: ::c_int = 14; pub const VIEW_LARGEICONS: ::c_int = 0; pub const VIEW_SMALLICONS: ::c_int = 1; pub const VIEW_LIST: ::c_int = 2; pub const VIEW_DETAILS: ::c_int = 3; pub const VIEW_SORTNAME: ::c_int = 4; pub const VIEW_SORTSIZE: ::c_int = 5; pub const VIEW_SORTDATE: ::c_int = 6; pub const VIEW_SORTTYPE: ::c_int = 7; pub const VIEW_PARENTFOLDER: ::c_int = 8; pub const VIEW_NETCONNECT: ::c_int = 9; pub const VIEW_NETDISCONNECT: ::c_int = 10; pub const VIEW_NEWFOLDER: ::c_int = 11; pub const VIEW_VIEWMENU: ::c_int = 12; pub const HIST_BACK: ::c_int = 0; pub const HIST_FORWARD: ::c_int = 1; pub const HIST_FAVORITES: ::c_int = 2; pub const HIST_ADDTOFAVORITES: ::c_int = 3; pub const HIST_VIEWTREE: ::c_int = 4; pub const TB_ADDBUTTONSA: ::UINT = ::WM_USER + 20; pub const TB_INSERTBUTTONA: ::UINT = ::WM_USER + 21; pub const TB_DELETEBUTTON: ::UINT = ::WM_USER + 22; pub const TB_GETBUTTON: ::UINT = ::WM_USER + 23; pub const TB_BUTTONCOUNT: ::UINT = ::WM_USER + 24; pub const TB_COMMANDTOINDEX: ::UINT = ::WM_USER + 25; STRUCT!{struct TBSAVEPARAMSA { hkr: ::HKEY, pszSubKey: ::LPCSTR, pszValueName: ::LPCSTR, }} pub type LPTBSAVEPARAMSA = *mut TBSAVEPARAMSA; STRUCT!{struct TBSAVEPARAMSW { hkr: ::HKEY, pszSubKey: ::LPCWSTR, pszValueName: ::LPCWSTR, }} pub type LPTBSAVEPARAMSW = *mut TBSAVEPARAMSW; pub const TB_SAVERESTOREA: ::UINT = ::WM_USER + 26; pub const TB_SAVERESTOREW: ::UINT = ::WM_USER + 76; pub const TB_CUSTOMIZE: ::UINT = ::WM_USER + 27; pub const TB_ADDSTRINGA: ::UINT = ::WM_USER + 28; pub const TB_ADDSTRINGW: ::UINT = ::WM_USER + 77; pub const TB_GETITEMRECT: ::UINT = ::WM_USER + 29; pub const TB_BUTTONSTRUCTSIZE: ::UINT = ::WM_USER + 30; pub const TB_SETBUTTONSIZE: ::UINT = ::WM_USER + 31; pub const TB_SETBITMAPSIZE: ::UINT = ::WM_USER + 32; pub const TB_AUTOSIZE: ::UINT = ::WM_USER + 33; pub const TB_GETTOOLTIPS: ::UINT = ::WM_USER + 35; pub const TB_SETTOOLTIPS: ::UINT = ::WM_USER + 36; pub const TB_SETPARENT: ::UINT = ::WM_USER + 37; pub const TB_SETROWS: ::UINT = ::WM_USER + 39; pub const TB_GETROWS: ::UINT = ::WM_USER + 40; pub const TB_SETCMDID: ::UINT = ::WM_USER + 42; pub const TB_CHANGEBITMAP: ::UINT = ::WM_USER + 43; pub const TB_GETBITMAP: ::UINT = ::WM_USER + 44; pub const TB_GETBUTTONTEXTA: ::UINT = ::WM_USER + 45; pub const TB_GETBUTTONTEXTW: ::UINT = ::WM_USER + 75; pub const TB_REPLACEBITMAP: ::UINT = ::WM_USER + 46; pub const TB_SETINDENT: ::UINT = ::WM_USER + 47; pub const TB_SETIMAGELIST: ::UINT = ::WM_USER + 48; pub const TB_GETIMAGELIST: ::UINT = ::WM_USER + 49; pub const TB_LOADIMAGES: ::UINT = ::WM_USER + 50; pub const TB_GETRECT: ::UINT = ::WM_USER + 51; pub const TB_SETHOTIMAGELIST: ::UINT = ::WM_USER + 52; pub const TB_GETHOTIMAGELIST: ::UINT = ::WM_USER + 53; pub const TB_SETDISABLEDIMAGELIST: ::UINT = ::WM_USER + 54; pub const TB_GETDISABLEDIMAGELIST: ::UINT = ::WM_USER + 55; pub const TB_SETSTYLE: ::UINT = ::WM_USER + 56; pub const TB_GETSTYLE: ::UINT = ::WM_USER + 57; pub const TB_GETBUTTONSIZE: ::UINT = ::WM_USER + 58; pub const TB_SETBUTTONWIDTH: ::UINT = ::WM_USER + 59; pub const TB_SETMAXTEXTROWS: ::UINT = ::WM_USER + 60; pub const TB_GETTEXTROWS: ::UINT = ::WM_USER + 61; pub const TB_GETOBJECT: ::UINT = ::WM_USER + 62; pub const TB_GETHOTITEM: ::UINT = ::WM_USER + 71; pub const TB_SETHOTITEM: ::UINT = ::WM_USER + 72; pub const TB_SETANCHORHIGHLIGHT: ::UINT = ::WM_USER + 73; pub const TB_GETANCHORHIGHLIGHT: ::UINT = ::WM_USER + 74; pub const TB_MAPACCELERATORA: ::UINT = ::WM_USER + 78; STRUCT!{struct TBINSERTMARK { iButton: ::c_int, dwFlags: ::DWORD, }} pub type LPTBINSERTMARK = *mut TBINSERTMARK; pub const TBIMHT_AFTER: ::DWORD = 0x00000001; pub const TBIMHT_BACKGROUND: ::DWORD = 0x00000002; pub const TB_GETINSERTMARK: ::UINT = ::WM_USER + 79; pub const TB_SETINSERTMARK: ::UINT = ::WM_USER + 80; pub const TB_INSERTMARKHITTEST: ::UINT = ::WM_USER + 81; pub const TB_MOVEBUTTON: ::UINT = ::WM_USER + 82; pub const TB_GETMAXSIZE: ::UINT = ::WM_USER + 83; pub const TB_SETEXTENDEDSTYLE: ::UINT = ::WM_USER + 84; pub const TB_GETEXTENDEDSTYLE: ::UINT = ::WM_USER + 85; pub const TB_GETPADDING: ::UINT = ::WM_USER + 86; pub const TB_SETPADDING: ::UINT = ::WM_USER + 87; pub const TB_SETINSERTMARKCOLOR: ::UINT = ::WM_USER + 88; pub const TB_GETINSERTMARKCOLOR: ::UINT = ::WM_USER + 89; pub const TB_SETCOLORSCHEME: ::UINT = CCM_SETCOLORSCHEME; pub const TB_GETCOLORSCHEME: ::UINT = CCM_GETCOLORSCHEME; pub const TB_SETUNICODEFORMAT: ::UINT = CCM_SETUNICODEFORMAT; pub const TB_GETUNICODEFORMAT: ::UINT = CCM_GETUNICODEFORMAT; pub const TB_MAPACCELERATORW: ::UINT = ::WM_USER + 90; STRUCT!{struct TBREPLACEBITMAP { hInstOld: ::HINSTANCE, nIDOld: ::UINT_PTR, hInstNew: ::HINSTANCE, nIDNew: ::UINT_PTR, nButtons: ::c_int, }} pub type LPTBREPLACEBITMAP = *mut TBREPLACEBITMAP; pub const TBBF_LARGE: ::DWORD = 0x0001; pub const TB_GETBITMAPFLAGS: ::UINT = ::WM_USER + 41; pub const TBIF_IMAGE: ::DWORD = 0x00000001; pub const TBIF_TEXT: ::DWORD = 0x00000002; pub const TBIF_STATE: ::DWORD = 0x00000004; pub const TBIF_STYLE: ::DWORD = 0x00000008; pub const TBIF_LPARAM: ::DWORD = 0x00000010; pub const TBIF_COMMAND: ::DWORD = 0x00000020; pub const TBIF_SIZE: ::DWORD = 0x00000040; pub const TBIF_BYINDEX: ::DWORD = 0x80000000; STRUCT!{struct TBBUTTONINFOA { cbSize: ::UINT, dwMask: ::DWORD, idCommand: ::c_int, iImage: ::c_int, fsState: ::BYTE, fsStyle: ::BYTE, cx: ::WORD, lParam: ::DWORD_PTR, pszText: ::LPSTR, cchText: ::c_int, }} pub type LPTBBUTTONINFOA = *mut TBBUTTONINFOA; STRUCT!{struct TBBUTTONINFOW { cbSize: ::UINT, dwMask: ::DWORD, idCommand: ::c_int, iImage: ::c_int, fsState: ::BYTE, fsStyle: ::BYTE, cx: ::WORD, lParam: ::DWORD_PTR, pszText: ::LPWSTR, cchText: ::c_int, }} pub type LPTBBUTTONINFOW = *mut TBBUTTONINFOW; pub const TB_GETBUTTONINFOW: ::UINT = ::WM_USER + 63; pub const TB_SETBUTTONINFOW: ::UINT = ::WM_USER + 64; pub const TB_GETBUTTONINFOA: ::UINT = ::WM_USER + 65; pub const TB_SETBUTTONINFOA: ::UINT = ::WM_USER + 66; pub const TB_INSERTBUTTONW: ::UINT = ::WM_USER + 67; pub const TB_ADDBUTTONSW: ::UINT = ::WM_USER + 68; pub const TB_HITTEST: ::UINT = ::WM_USER + 69; pub const TB_SETDRAWTEXTFLAGS: ::UINT = ::WM_USER + 70; pub const TB_GETSTRINGW: ::UINT = ::WM_USER + 91; pub const TB_GETSTRINGA: ::UINT = ::WM_USER + 92; pub const TB_SETBOUNDINGSIZE: ::UINT = ::WM_USER + 93; pub const TB_SETHOTITEM2: ::UINT = ::WM_USER + 94; pub const TB_HASACCELERATOR: ::UINT = ::WM_USER + 95; pub const TB_SETLISTGAP: ::UINT = ::WM_USER + 96; pub const TB_GETIMAGELISTCOUNT: ::UINT = ::WM_USER + 98; pub const TB_GETIDEALSIZE: ::UINT = ::WM_USER + 99; pub const TBMF_PAD: ::DWORD = 0x00000001; pub const TBMF_BARPAD: ::DWORD = 0x00000002; pub const TBMF_BUTTONSPACING: ::DWORD = 0x00000004; STRUCT!{struct TBMETRICS { cbSize: ::UINT, dwMask: ::DWORD, cxPad: ::c_int, cyPad: ::c_int, cxBarPad: ::c_int, cyBarPad: ::c_int, cxButtonSpacing: ::c_int, cyButtonSpacing: ::c_int, }} pub type LPTBMETRICS = *mut TBMETRICS; pub const TB_GETMETRICS: ::UINT = ::WM_USER + 101; pub const TB_SETMETRICS: ::UINT = ::WM_USER + 102; pub const TB_GETITEMDROPDOWNRECT: ::UINT = ::WM_USER + 103; pub const TB_SETPRESSEDIMAGELIST: ::UINT = ::WM_USER + 104; pub const TB_GETPRESSEDIMAGELIST: ::UINT = ::WM_USER + 105; pub const TB_SETWINDOWTHEME: ::UINT = CCM_SETWINDOWTHEME; pub const TBN_GETBUTTONINFOA: ::UINT = TBN_FIRST - 0; pub const TBN_BEGINDRAG: ::UINT = TBN_FIRST - 1; pub const TBN_ENDDRAG: ::UINT = TBN_FIRST - 2; pub const TBN_BEGINADJUST: ::UINT = TBN_FIRST - 3; pub const TBN_ENDADJUST: ::UINT = TBN_FIRST - 4; pub const TBN_RESET: ::UINT = TBN_FIRST - 5; pub const TBN_QUERYINSERT: ::UINT = TBN_FIRST - 6; pub const TBN_QUERYDELETE: ::UINT = TBN_FIRST - 7; pub const TBN_TOOLBARCHANGE: ::UINT = TBN_FIRST - 8; pub const TBN_CUSTHELP: ::UINT = TBN_FIRST - 9; pub const TBN_DROPDOWN: ::UINT = TBN_FIRST - 10; pub const TBN_GETOBJECT: ::UINT = TBN_FIRST - 12; STRUCT!{struct NMTBHOTITEM { hdr: ::NMHDR, idOld: ::c_int, idNew: ::c_int, dwFlags: ::DWORD, }} pub type LPNMTBHOTITEM = *mut NMTBHOTITEM; pub const HICF_OTHER: ::DWORD = 0x00000000; pub const HICF_MOUSE: ::DWORD = 0x00000001; pub const HICF_ARROWKEYS: ::DWORD = 0x00000002; pub const HICF_ACCELERATOR: ::DWORD = 0x00000004; pub const HICF_DUPACCEL: ::DWORD = 0x00000008; pub const HICF_ENTERING: ::DWORD = 0x00000010; pub const HICF_LEAVING: ::DWORD = 0x00000020; pub const HICF_RESELECT: ::DWORD = 0x00000040; pub const HICF_LMOUSE: ::DWORD = 0x00000080; pub const HICF_TOGGLEDROPDOWN: ::DWORD = 0x00000100; pub const TBN_HOTITEMCHANGE: ::UINT = TBN_FIRST - 13; pub const TBN_DRAGOUT: ::UINT = TBN_FIRST - 14; pub const TBN_DELETINGBUTTON: ::UINT = TBN_FIRST - 15; pub const TBN_GETDISPINFOA: ::UINT = TBN_FIRST - 16; pub const TBN_GETDISPINFOW: ::UINT = TBN_FIRST - 17; pub const TBN_GETINFOTIPA: ::UINT = TBN_FIRST - 18; pub const TBN_GETINFOTIPW: ::UINT = TBN_FIRST - 19; pub const TBN_GETBUTTONINFOW: ::UINT = TBN_FIRST - 20; pub const TBN_RESTORE: ::UINT = TBN_FIRST - 21; pub const TBN_SAVE: ::UINT = TBN_FIRST - 22; pub const TBN_INITCUSTOMIZE: ::UINT = TBN_FIRST - 23; pub const TBN_WRAPHOTITEM: ::UINT = TBN_FIRST - 24; pub const TBN_DUPACCELERATOR: ::UINT = TBN_FIRST - 25; pub const TBN_WRAPACCELERATOR: ::UINT = TBN_FIRST - 26; pub const TBN_DRAGOVER: ::UINT = TBN_FIRST - 27; pub const TBN_MAPACCELERATOR: ::UINT = TBN_FIRST - 28; pub const TBNRF_HIDEHELP: ::LRESULT = 0x00000001; pub const TBNRF_ENDCUSTOMIZE: ::LRESULT = 0x00000002; STRUCT!{struct NMTBSAVE { hdr: ::NMHDR, pData: *mut ::DWORD, pCurrent: *mut ::DWORD, cbData: ::UINT, iItem: ::c_int, cButtons: ::c_int, tbButton: TBBUTTON, }} pub type LPNMTBSAVE = *mut NMTBSAVE; STRUCT!{struct NMTBRESTORE { hdr: ::NMHDR, pData: *mut ::DWORD, pCurrent: *mut ::DWORD, cbData: ::UINT, iItem: ::c_int, cButtons: ::c_int, cbBytesPerRecord: ::c_int, tbButton: TBBUTTON, }} pub type LPNMTBRESTORE = *mut NMTBRESTORE; STRUCT!{struct NMTBGETINFOTIPA { hdr: ::NMHDR, pszText: ::LPSTR, cchTextMax: ::c_int, iItem: ::c_int, lParal: ::LPARAM, }} pub type LPNMTBGETINFOTIPA = *mut NMTBGETINFOTIPA; STRUCT!{struct NMTBGETINFOTIPW { hdr: ::NMHDR, pszText: ::LPWSTR, cchTextMax: ::c_int, iItem: ::c_int, lParal: ::LPARAM, }} pub type LPNMTBGETINFOTIPW = *mut NMTBGETINFOTIPW; pub const TBNF_IMAGE: ::DWORD = 0x00000001; pub const TBNF_TEXT: ::DWORD = 0x00000002; pub const TBNF_DI_SETITEM: ::DWORD = 0x10000000; STRUCT!{struct NMTBDISPINFOA { hdr: ::NMHDR, dwMask: ::DWORD, idCommand: ::c_int, lParam: ::DWORD_PTR, iImage: ::c_int, pszText: ::LPSTR, cchText: ::c_int, }} pub type LPNMTBDISPINFOA = *mut NMTBDISPINFOA; STRUCT!{struct NMTBDISPINFOW { hdr: ::NMHDR, dwMask: ::DWORD, idCommand: ::c_int, lParam: ::DWORD_PTR, iImage: ::c_int, pszText: ::LPWSTR, cchText: ::c_int, }} pub type LPNMTBDISPINFOW = *mut NMTBDISPINFOW; pub const TBDDRET_DEFAULT: ::LRESULT = 0; pub const TBDDRET_NODEFAULT: ::LRESULT = 1; pub const TBDDRET_TREATPRESSED: ::LRESULT = 2; pub type TBNOTIFYA = NMTOOLBARA; pub type TBNOTIFYW = NMTOOLBARW; pub type LPTBNOTIFYA = LPNMTOOLBARA; pub type LPTBNOTIFYW = LPNMTOOLBARW; STRUCT!{struct NMTOOLBARA { hdr: ::NMHDR, iItem: ::c_int, tbButton: TBBUTTON, cchText: ::c_int, pszText: ::LPSTR, rcButton: ::RECT, }} pub type LPNMTOOLBARA = *mut NMTOOLBARA; STRUCT!{struct NMTOOLBARW { hdr: ::NMHDR, iItem: ::c_int, tbButton: TBBUTTON, cchText: ::c_int, pszText: ::LPWSTR, rcButton: ::RECT, }} pub type LPNMTOOLBARW = *mut NMTOOLBARW; pub const RBIM_IMAGELIST: ::UINT = 0x00000001; pub const RBS_TOOLTIPS: ::DWORD = 0x00000100; pub const RBS_VARHEIGHT: ::DWORD = 0x00000200; pub const RBS_BANDBORDERS: ::DWORD = 0x00000400; pub const RBS_FIXEDORDER: ::DWORD = 0x00000800; pub const RBS_REGISTERDROP: ::DWORD = 0x00001000; pub const RBS_AUTOSIZE: ::DWORD = 0x00002000; pub const RBS_VERTICALGRIPPER: ::DWORD = 0x00004000; pub const RBS_DBLCLKTOGGLE: ::DWORD = 0x00008000; STRUCT!{struct REBARINFO { cbSize: ::UINT, fMask: ::UINT, himl: HIMAGELIST, }} pub type LPREBARINFO = *mut REBARINFO; pub const RBBS_BREAK: ::UINT = 0x00000001; pub const RBBS_FIXEDSIZE: ::UINT = 0x00000002; pub const RBBS_CHILDEDGE: ::UINT = 0x00000004; pub const RBBS_HIDDEN: ::UINT = 0x00000008; pub const RBBS_NOVERT: ::UINT = 0x00000010; pub const RBBS_FIXEDBMP: ::UINT = 0x00000020; pub const RBBS_VARIABLEHEIGHT: ::UINT = 0x00000040; pub const RBBS_GRIPPERALWAYS: ::UINT = 0x00000080; pub const RBBS_NOGRIPPER: ::UINT = 0x00000100; pub const RBBS_USECHEVRON: ::UINT = 0x00000200; pub const RBBS_HIDETITLE: ::UINT = 0x00000400; pub const RBBS_TOPALIGN: ::UINT = 0x00000800; pub const RBBIM_STYLE: ::UINT = 0x00000001; pub const RBBIM_COLORS: ::UINT = 0x00000002; pub const RBBIM_TEXT: ::UINT = 0x00000004; pub const RBBIM_IMAGE: ::UINT = 0x00000008; pub const RBBIM_CHILD: ::UINT = 0x00000010; pub const RBBIM_CHILDSIZE: ::UINT = 0x00000020; pub const RBBIM_SIZE: ::UINT = 0x00000040; pub const RBBIM_BACKGROUND: ::UINT = 0x00000080; pub const RBBIM_ID: ::UINT = 0x00000100; pub const RBBIM_IDEALSIZE: ::UINT = 0x00000200; pub const RBBIM_LPARAM: ::UINT = 0x00000400; pub const RBBIM_HEADERSIZE: ::UINT = 0x00000800; pub const RBBIM_CHEVRONLOCATION: ::UINT = 0x00001000; pub const RBBIM_CHEVRONSTATE: ::UINT = 0x00002000; STRUCT!{struct REBARBANDINFOA { cbSize: ::UINT, fMask: ::UINT, fStyle: ::UINT, clrFore: ::COLORREF, clrBack: ::COLORREF, lpText: ::LPSTR, cch: ::UINT, iImage: ::c_int, hwndChild: ::HWND, cxMinChild: ::UINT, cyMinChild: ::UINT, cx: ::UINT, hbmBack: ::HBITMAP, wID: ::UINT, cyChild: ::UINT, cyMaxChild: ::UINT, cyIntegral: ::UINT, cxIdeal: ::UINT, lParam: ::LPARAM, cxHeader: ::UINT, rcChevronLocation: ::RECT, uChevronState: ::UINT, }} pub type LPREBARBANDINFOA = *mut REBARBANDINFOA; pub type LPCREBARBANDINFOA = *const REBARBANDINFOA; STRUCT!{struct REBARBANDINFOW { cbSize: ::UINT, fMask: ::UINT, fStyle: ::UINT, clrFore: ::COLORREF, clrBack: ::COLORREF, lpText: ::LPWSTR, cch: ::UINT, iImage: ::c_int, hwndChild: ::HWND, cxMinChild: ::UINT, cyMinChild: ::UINT, cx: ::UINT, hbmBack: ::HBITMAP, wID: ::UINT, cyChild: ::UINT, cyMaxChild: ::UINT, cyIntegral: ::UINT, cxIdeal: ::UINT, lParam: ::LPARAM, cxHeader: ::UINT, rcChevronLocation: ::RECT, uChevronState: ::UINT, }} pub type LPREBARBANDINFOW = *mut REBARBANDINFOW; pub type LPCREBARBANDINFOW = *const REBARBANDINFOW; pub const RB_INSERTBANDA: ::UINT = ::WM_USER + 1; pub const RB_DELETEBAND: ::UINT = ::WM_USER + 2; pub const RB_GETBARINFO: ::UINT = ::WM_USER + 3; pub const RB_SETBARINFO: ::UINT = ::WM_USER + 4; pub const RB_SETBANDINFOA: ::UINT = ::WM_USER + 6; pub const RB_SETPARENT: ::UINT = ::WM_USER + 7; pub const RB_HITTEST: ::UINT = ::WM_USER + 8; pub const RB_GETRECT: ::UINT = ::WM_USER + 9; pub const RB_INSERTBANDW: ::UINT = ::WM_USER + 10; pub const RB_SETBANDINFOW: ::UINT = ::WM_USER + 11; pub const RB_GETBANDCOUNT: ::UINT = ::WM_USER + 12; pub const RB_GETROWCOUNT: ::UINT = ::WM_USER + 13; pub const RB_GETROWHEIGHT: ::UINT = ::WM_USER + 14; pub const RB_IDTOINDEX: ::UINT = ::WM_USER + 16; pub const RB_GETTOOLTIPS: ::UINT = ::WM_USER + 17; pub const RB_SETTOOLTIPS: ::UINT = ::WM_USER + 18; pub const RB_SETBKCOLOR: ::UINT = ::WM_USER + 19; pub const RB_GETBKCOLOR: ::UINT = ::WM_USER + 20; pub const RB_SETTEXTCOLOR: ::UINT = ::WM_USER + 21; pub const RB_GETTEXTCOLOR: ::UINT = ::WM_USER + 22; pub const RBSTR_CHANGERECT: ::WPARAM = 0x0001; pub const RB_SIZETORECT: ::UINT = ::WM_USER + 23; pub const RB_SETCOLORSCHEME: ::UINT = CCM_SETCOLORSCHEME; pub const RB_GETCOLORSCHEME: ::UINT = CCM_GETCOLORSCHEME; pub const RB_BEGINDRAG: ::UINT = ::WM_USER + 24; pub const RB_ENDDRAG: ::UINT = ::WM_USER + 25; pub const RB_DRAGMOVE: ::UINT = ::WM_USER + 26; pub const RB_GETBARHEIGHT: ::UINT = ::WM_USER + 27; pub const RB_GETBANDINFOW: ::UINT = ::WM_USER + 28; pub const RB_GETBANDINFOA: ::UINT = ::WM_USER + 29; pub const RB_MINIMIZEBAND: ::UINT = ::WM_USER + 30; pub const RB_MAXIMIZEBAND: ::UINT = ::WM_USER + 31; pub const RB_GETDROPTARGET: ::UINT = CCM_GETDROPTARGET; pub const RB_GETBANDBORDERS: ::UINT = ::WM_USER + 34; pub const RB_SHOWBAND: ::UINT = ::WM_USER + 35; pub const RB_SETPALETTE: ::UINT = ::WM_USER + 37; pub const RB_GETPALETTE: ::UINT = ::WM_USER + 38; pub const RB_MOVEBAND: ::UINT = ::WM_USER + 39; pub const RB_SETUNICODEFORMAT: ::UINT = CCM_SETUNICODEFORMAT; pub const RB_GETUNICODEFORMAT: ::UINT = CCM_GETUNICODEFORMAT; pub const RB_GETBANDMARGINS: ::UINT = ::WM_USER + 40; pub const RB_SETWINDOWTHEME: ::UINT = CCM_SETWINDOWTHEME; pub const RB_SETEXTENDEDSTYLE: ::UINT = ::WM_USER + 41; pub const RB_GETEXTENDEDSTYLE: ::UINT = ::WM_USER + 42; pub const RB_PUSHCHEVRON: ::UINT = ::WM_USER + 43; pub const RB_SETBANDWIDTH: ::UINT = ::WM_USER + 44; pub const RBN_HEIGHTCHANGE: ::UINT = RBN_FIRST - 0; pub const RBN_GETOBJECT: ::UINT = RBN_FIRST - 1; pub const RBN_LAYOUTCHANGED: ::UINT = RBN_FIRST - 2; pub const RBN_AUTOSIZE: ::UINT = RBN_FIRST - 3; pub const RBN_BEGINDRAG: ::UINT = RBN_FIRST - 4; pub const RBN_ENDDRAG: ::UINT = RBN_FIRST - 5; pub const RBN_DELETINGBAND: ::UINT = RBN_FIRST - 6; pub const RBN_DELETEDBAND: ::UINT = RBN_FIRST - 7; pub const RBN_CHILDSIZE: ::UINT = RBN_FIRST - 8; pub const RBN_CHEVRONPUSHED: ::UINT = RBN_FIRST - 10; pub const RBN_SPLITTERDRAG: ::UINT = RBN_FIRST - 11; pub const RBN_MINMAX: ::UINT = RBN_FIRST - 21; pub const RBN_AUTOBREAK: ::UINT = RBN_FIRST - 22; STRUCT!{struct NMREBARCHILDSIZE { hdr: ::NMHDR, uBand: ::UINT, wID: ::UINT, rcChild: ::RECT, rcBand: ::RECT, }} pub type LPNMREBARCHILDSIZE = *mut NMREBARCHILDSIZE; STRUCT!{struct NMREBAR { hdr: ::NMHDR, dwMask: ::DWORD, uBand: ::UINT, fStyle: ::UINT, wID: ::UINT, lParam: ::LPARAM, }} pub type LPNMREBAR = *mut NMREBAR; pub const RBNM_ID: ::DWORD = 0x00000001; pub const RBNM_STYLE: ::DWORD = 0x00000002; pub const RBNM_LPARAM: ::DWORD = 0x00000004; STRUCT!{struct NMRBAUTOSIZE { hdr: ::NMHDR, fChanged: ::BOOL, rcTarget: ::RECT, rcActual: ::RECT, }} pub type LPNMRBAUTOSIZE = *mut NMRBAUTOSIZE; STRUCT!{struct NMREBARCHEVRON { hdr: ::NMHDR, uBand: ::UINT, wID: ::UINT, lParam: ::LPARAM, rc: ::RECT, lParamNM: ::LPARAM, }} pub type LPNMREBARCHEVRON = *mut NMREBARCHEVRON; STRUCT!{struct NMREBARSPLITTER { hdr: ::NMHDR, rcSizing: ::RECT, }} pub type LPNMREBARSPLITTER = *mut NMREBARSPLITTER; pub const RBAB_AUTOSIZE: ::UINT = 0x0001; pub const RBAB_ADDBAND: ::UINT = 0x0002; STRUCT!{struct NMREBARAUTOBREAK { hdr: ::NMHDR, uBand: ::UINT, wID: ::UINT, lParam: ::LPARAM, uMsg: ::UINT, fStyleCurrent: ::UINT, fAutoBreak: ::UINT, }} pub type LPNMREBARAUTOBREAK = *mut NMREBARAUTOBREAK; pub const RBHT_NOWHERE: ::UINT = 0x0001; pub const RBHT_CAPTION: ::UINT = 0x0002; pub const RBHT_CLIENT: ::UINT = 0x0003; pub const RBHT_GRABBER: ::UINT = 0x0004; pub const RBHT_CHEVRON: ::UINT = 0x0008; pub const RBHT_SPLITTER: ::UINT = 0x0010; STRUCT!{struct RBHITTESTINFO { pt: ::POINT, flags: ::UINT, iBand: ::c_int, }} pub type LPRBHITTESTINFO = *mut RBHITTESTINFO; pub type LPTOOLINFOA = LPTTTOOLINFOA; pub type LPTOOLINFOW = LPTTTOOLINFOW; pub type TOOLINFOA = TTTOOLINFOA; pub type TOOLINFOW = TTTOOLINFOW; STRUCT!{struct TTTOOLINFOA { cbSize: ::UINT, uFlags: ::UINT, hwnd: ::HWND, uId: ::UINT_PTR, rect: ::RECT, hinst: ::HINSTANCE, lpszText: ::LPSTR, lParam: ::LPARAM, lpReserved: *mut ::c_void, }} pub type PTTTOOLINFOA = *mut TTTOOLINFOA; pub type LPTTTOOLINFOA = *mut TTTOOLINFOA; STRUCT!{struct TTTOOLINFOW { cbSize: ::UINT, uFlags: ::UINT, hwnd: ::HWND, uId: ::UINT_PTR, rect: ::RECT, hinst: ::HINSTANCE, lpszText: ::LPSTR, lParam: ::LPARAM, lpReserved: *mut ::c_void, }} pub type PTTTOOLINFOW = *mut TTTOOLINFOW; pub type LPTTTOOLINFOW = *mut TTTOOLINFOW; pub const TTS_ALWAYSTIP: ::DWORD = 0x01; pub const TTS_NOPREFIX: ::DWORD = 0x02; pub const TTS_NOANIMATE: ::DWORD = 0x10; pub const TTS_NOFADE: ::DWORD = 0x20; pub const TTS_BALLOON: ::DWORD = 0x40; pub const TTS_CLOSE: ::DWORD = 0x80; pub const TTS_USEVISUALSTYLE: ::DWORD = 0x100; pub const TTF_IDISHWND: ::UINT = 0x0001; pub const TTF_CENTERTIP: ::UINT = 0x0002; pub const TTF_RTLREADING: ::UINT = 0x0004; pub const TTF_SUBCLASS: ::UINT = 0x0010; pub const TTF_TRACK: ::UINT = 0x0020; pub const TTF_ABSOLUTE: ::UINT = 0x0080; pub const TTF_TRANSPARENT: ::UINT = 0x0100; pub const TTF_PARSELINKS: ::UINT = 0x1000; pub const TTF_DI_SETITEM: ::UINT = 0x8000; pub const TTDT_AUTOMATIC: ::WPARAM = 0; pub const TTDT_RESHOW: ::WPARAM = 1; pub const TTDT_AUTOPOP: ::WPARAM = 2; pub const TTDT_INITIAL: ::WPARAM = 3; pub const TTI_NONE: ::WPARAM = 0; pub const TTI_INFO: ::WPARAM = 1; pub const TTI_WARNING: ::WPARAM = 2; pub const TTI_ERROR: ::WPARAM = 3; pub const TTI_INFO_LARGE: ::WPARAM = 4; pub const TTI_WARNING_LARGE: ::WPARAM = 5; pub const TTI_ERROR_LARGE: ::WPARAM = 6; pub const TTM_ACTIVATE: ::UINT = ::WM_USER + 1; pub const TTM_SETDELAYTIME: ::UINT = ::WM_USER + 3; pub const TTM_ADDTOOLA: ::UINT = ::WM_USER + 4; pub const TTM_ADDTOOLW: ::UINT = ::WM_USER + 50; pub const TTM_DELTOOLA: ::UINT = ::WM_USER + 5; pub const TTM_DELTOOLW: ::UINT = ::WM_USER + 51; pub const TTM_NEWTOOLRECTA: ::UINT = ::WM_USER + 6; pub const TTM_NEWTOOLRECTW: ::UINT = ::WM_USER + 52; pub const TTM_RELAYEVENT: ::UINT = ::WM_USER + 7; pub const TTM_GETTOOLINFOA: ::UINT = ::WM_USER + 8; pub const TTM_GETTOOLINFOW: ::UINT = ::WM_USER + 53; pub const TTM_SETTOOLINFOA: ::UINT = ::WM_USER + 9; pub const TTM_SETTOOLINFOW: ::UINT = ::WM_USER + 54; pub const TTM_HITTESTA: ::UINT = ::WM_USER + 10; pub const TTM_HITTESTW: ::UINT = ::WM_USER + 55; pub const TTM_GETTEXTA: ::UINT = ::WM_USER + 11; pub const TTM_GETTEXTW: ::UINT = ::WM_USER + 56; pub const TTM_UPDATETIPTEXTA: ::UINT = ::WM_USER + 12; pub const TTM_UPDATETIPTEXTW: ::UINT = ::WM_USER + 57; pub const TTM_GETTOOLCOUNT: ::UINT = ::WM_USER + 13; pub const TTM_ENUMTOOLSA: ::UINT = ::WM_USER + 14; pub const TTM_ENUMTOOLSW: ::UINT = ::WM_USER + 58; pub const TTM_GETCURRENTTOOLA: ::UINT = ::WM_USER + 15; pub const TTM_GETCURRENTTOOLW: ::UINT = ::WM_USER + 59; pub const TTM_WINDOWFROMPOINT: ::UINT = ::WM_USER + 16; pub const TTM_TRACKACTIVATE: ::UINT = ::WM_USER + 17; pub const TTM_TRACKPOSITION: ::UINT = ::WM_USER + 18; pub const TTM_SETTIPBKCOLOR: ::UINT = ::WM_USER + 19; pub const TTM_SETTIPTEXTCOLOR: ::UINT = ::WM_USER + 20; pub const TTM_GETDELAYTIME: ::UINT = ::WM_USER + 21; pub const TTM_GETTIPBKCOLOR: ::UINT = ::WM_USER + 22; pub const TTM_GETTIPTEXTCOLOR: ::UINT = ::WM_USER + 23; pub const TTM_SETMAXTIPWIDTH: ::UINT = ::WM_USER + 24; pub const TTM_GETMAXTIPWIDTH: ::UINT = ::WM_USER + 25; pub const TTM_SETMARGIN: ::UINT = ::WM_USER + 26; pub const TTM_GETMARGIN: ::UINT = ::WM_USER + 27; pub const TTM_POP: ::UINT = ::WM_USER + 28; pub const TTM_UPDATE: ::UINT = ::WM_USER + 29; pub const TTM_GETBUBBLESIZE: ::UINT = ::WM_USER + 30; pub const TTM_ADJUSTRECT: ::UINT = ::WM_USER + 31; pub const TTM_SETTITLEA: ::UINT = ::WM_USER + 32; pub const TTM_SETTITLEW: ::UINT = ::WM_USER + 33; pub const TTM_POPUP: ::UINT = ::WM_USER + 34; pub const TTM_GETTITLE: ::UINT = ::WM_USER + 35; STRUCT!{struct TTGETTITLE { dwSize: ::DWORD, uTitleBitmap: ::UINT, cch: ::UINT, pszTitle: *mut ::WCHAR, }} pub type LPTTGETTITLE = *mut TTGETTITLE; pub const TTM_SETWINDOWTHEME: ::UINT = CCM_SETWINDOWTHEME; pub type LPHITTESTINFOW = LPTTHITTESTINFOW; pub type LPHITTESTINFOA = LPTTHITTESTINFOA; STRUCT!{struct TTHITTESTINFOA { hwnd: ::HWND, pt: ::POINT, ti: TTTOOLINFOA, }} pub type LPTTHITTESTINFOA = *mut TTHITTESTINFOA; STRUCT!{struct TTHITTESTINFOW { hwnd: ::HWND, pt: ::POINT, ti: TTTOOLINFOW, }} pub type LPTTHITTESTINFOW = *mut TTHITTESTINFOW; pub const TTN_GETDISPINFOA: ::UINT = TTN_FIRST - 0; pub const TTN_GETDISPINFOW: ::UINT = TTN_FIRST - 10; pub const TTN_SHOW: ::UINT = TTN_FIRST - 1; pub const TTN_POP: ::UINT = TTN_FIRST - 2; pub const TTN_LINKCLICK: ::UINT = TTN_FIRST - 3; pub const TTN_NEEDTEXTA: ::UINT = TTN_GETDISPINFOA; pub const TTN_NEEDTEXTW: ::UINT = TTN_GETDISPINFOW; pub type TOOLTIPTEXTW = NMTTDISPINFOW; pub type TOOLTIPTEXTA = NMTTDISPINFOA; pub type LPTOOLTIPTEXTA = LPNMTTDISPINFOA; pub type LPTOOLTIPTEXTW = LPNMTTDISPINFOW; #[repr(C)] #[derive(Copy)] pub struct NMTTDISPINFOA { pub hdr: ::NMHDR, pub lpszText: ::LPSTR, pub szText: [::c_char; 80], pub hinst: ::HINSTANCE, pub uFlags: ::UINT, pub lParam: ::LPARAM, } impl Clone for NMTTDISPINFOA { fn clone(&self) -> NMTTDISPINFOA { *self } } pub type LPNMTTDISPINFOA = *mut NMTTDISPINFOA; #[repr(C)] #[derive(Copy)] pub struct NMTTDISPINFOW { pub hdr: ::NMHDR, pub lpszText: ::LPWSTR, pub szText: [::WCHAR; 80], pub hinst: ::HINSTANCE, pub uFlags: ::UINT, pub lParam: ::LPARAM, } impl Clone for NMTTDISPINFOW { fn clone(&self) -> NMTTDISPINFOW { *self } } pub type LPNMTTDISPINFOW = *mut NMTTDISPINFOW; pub const SBARS_SIZEGRIP: ::DWORD = 0x0100; pub const SBARS_TOOLTIPS: ::DWORD = 0x0800; pub const SBT_TOOLTIPS: ::DWORD = 0x0800; pub const SB_SETTEXTA: ::UINT = ::WM_USER + 1; pub const SB_SETTEXTW: ::UINT = ::WM_USER + 11; pub const SB_GETTEXTA: ::UINT = ::WM_USER + 2; pub const SB_GETTEXTW: ::UINT = ::WM_USER + 13; pub const SB_GETTEXTLENGTHA: ::UINT = ::WM_USER + 3; pub const SB_GETTEXTLENGTHW: ::UINT = ::WM_USER + 12; pub const SB_SETPARTS: ::UINT = ::WM_USER + 4; pub const SB_GETPARTS: ::UINT = ::WM_USER + 6; pub const SB_GETBORDERS: ::UINT = ::WM_USER + 7; pub const SB_SETMINHEIGHT: ::UINT = ::WM_USER + 8; pub const SB_SIMPLE: ::UINT = ::WM_USER + 9; pub const SB_GETRECT: ::UINT = ::WM_USER + 10; pub const SB_ISSIMPLE: ::UINT = ::WM_USER + 14; pub const SB_SETICON: ::UINT = ::WM_USER + 15; pub const SB_SETTIPTEXTA: ::UINT = ::WM_USER + 16; pub const SB_SETTIPTEXTW: ::UINT = ::WM_USER + 17; pub const SB_GETTIPTEXTA: ::UINT = ::WM_USER + 18; pub const SB_GETTIPTEXTW: ::UINT = ::WM_USER + 19; pub const SB_GETICON: ::UINT = ::WM_USER + 20; pub const SB_SETUNICODEFORMAT: ::UINT = CCM_SETUNICODEFORMAT; pub const SB_GETUNICODEFORMAT: ::UINT = CCM_GETUNICODEFORMAT; pub const SBT_OWNERDRAW: ::WPARAM = 0x1000; pub const SBT_NOBORDERS: ::WPARAM = 0x0100; pub const SBT_POPOUT: ::WPARAM = 0x0200; pub const SBT_RTLREADING: ::WPARAM = 0x0400; pub const SBT_NOTABPARSING: ::WPARAM = 0x0800; pub const SB_SETBKCOLOR: ::UINT = CCM_SETBKCOLOR; pub const SBN_SIMPLEMODECHANGE: ::UINT = SBN_FIRST - 0; pub const SB_SIMPLEID: ::WPARAM = 0x00ff; pub const TBS_AUTOTICKS: ::DWORD = 0x0001; pub const TBS_VERT: ::DWORD = 0x0002; pub const TBS_HORZ: ::DWORD = 0x0000; pub const TBS_TOP: ::DWORD = 0x0004; pub const TBS_BOTTOM: ::DWORD = 0x0000; pub const TBS_LEFT: ::DWORD = 0x0004; pub const TBS_RIGHT: ::DWORD = 0x0000; pub const TBS_BOTH: ::DWORD = 0x0008; pub const TBS_NOTICKS: ::DWORD = 0x0010; pub const TBS_ENABLESELRANGE: ::DWORD = 0x0020; pub const TBS_FIXEDLENGTH: ::DWORD = 0x0040; pub const TBS_NOTHUMB: ::DWORD = 0x0080; pub const TBS_TOOLTIPS: ::DWORD = 0x0100; pub const TBS_REVERSED: ::DWORD = 0x0200; pub const TBS_DOWNISLEFT: ::DWORD = 0x0400; pub const TBS_NOTIFYBEFOREMOVE: ::DWORD = 0x0800; pub const TBS_TRANSPARENTBKGND: ::DWORD = 0x1000; pub const TBM_GETPOS: ::UINT = ::WM_USER; pub const TBM_GETRANGEMIN: ::UINT = ::WM_USER + 1; pub const TBM_GETRANGEMAX: ::UINT = ::WM_USER + 2; pub const TBM_GETTIC: ::UINT = ::WM_USER + 3; pub const TBM_SETTIC: ::UINT = ::WM_USER + 4; pub const TBM_SETPOS: ::UINT = ::WM_USER + 5; pub const TBM_SETRANGE: ::UINT = ::WM_USER + 6; pub const TBM_SETRANGEMIN: ::UINT = ::WM_USER + 7; pub const TBM_SETRANGEMAX: ::UINT = ::WM_USER + 8; pub const TBM_CLEARTICS: ::UINT = ::WM_USER + 9; pub const TBM_SETSEL: ::UINT = ::WM_USER + 10; pub const TBM_SETSELSTART: ::UINT = ::WM_USER + 11; pub const TBM_SETSELEND: ::UINT = ::WM_USER + 12; pub const TBM_GETPTICS: ::UINT = ::WM_USER + 14; pub const TBM_GETTICPOS: ::UINT = ::WM_USER + 15; pub const TBM_GETNUMTICS: ::UINT = ::WM_USER + 16; pub const TBM_GETSELSTART: ::UINT = ::WM_USER + 17; pub const TBM_GETSELEND: ::UINT = ::WM_USER + 18; pub const TBM_CLEARSEL: ::UINT = ::WM_USER + 19; pub const TBM_SETTICFREQ: ::UINT = ::WM_USER + 20; pub const TBM_SETPAGESIZE: ::UINT = ::WM_USER + 21; pub const TBM_GETPAGESIZE: ::UINT = ::WM_USER + 22; pub const TBM_SETLINESIZE: ::UINT = ::WM_USER + 23; pub const TBM_GETLINESIZE: ::UINT = ::WM_USER + 24; pub const TBM_GETTHUMBRECT: ::UINT = ::WM_USER + 25; pub const TBM_GETCHANNELRECT: ::UINT = ::WM_USER + 26; pub const TBM_SETTHUMBLENGTH: ::UINT = ::WM_USER + 27; pub const TBM_GETTHUMBLENGTH: ::UINT = ::WM_USER + 28; pub const TBM_SETTOOLTIPS: ::UINT = ::WM_USER + 29; pub const TBM_GETTOOLTIPS: ::UINT = ::WM_USER + 30; pub const TBM_SETTIPSIDE: ::UINT = ::WM_USER + 31; pub const TBTS_TOP: ::WPARAM = 0; pub const TBTS_LEFT: ::WPARAM = 1; pub const TBTS_BOTTOM: ::WPARAM = 2; pub const TBTS_RIGHT: ::WPARAM = 3; pub const TBM_SETBUDDY: ::UINT = ::WM_USER + 32; pub const TBM_GETBUDDY: ::UINT = ::WM_USER + 33; pub const TBM_SETPOSNOTIFY: ::UINT = ::WM_USER + 34; pub const TBM_SETUNICODEFORMAT: ::UINT = CCM_SETUNICODEFORMAT; pub const TBM_GETUNICODEFORMAT: ::UINT = CCM_GETUNICODEFORMAT; pub const TBCD_TICS: ::DWORD_PTR = 0x0001; pub const TBCD_THUMB: ::DWORD_PTR = 0x0001; pub const TBCD_CHANNEL: ::DWORD_PTR = 0x0001; pub const TB_LINEUP: ::WPARAM = 0; pub const TB_LINEDOWN: ::WPARAM = 1; pub const TB_PAGEUP: ::WPARAM = 2; pub const TB_PAGEDOWN: ::WPARAM = 3; pub const TB_THUMBPOSITION: ::WPARAM = 4; pub const TB_THUMBTRACK: ::WPARAM = 5; pub const TB_TOP: ::WPARAM = 6; pub const TB_BOTTOM: ::WPARAM = 7; pub const TB_ENDTRACK: ::WPARAM = 8; pub const TRBN_THUMBPOSCHANGING: ::UINT = TRBN_FIRST - 1; STRUCT!{struct NMTRBTHUMBPOSCHANGING { hdr: ::NMHDR, dwPos: ::DWORD, nReason: ::c_int, }} STRUCT!{struct DRAGLISTINFO { uNotification: ::UINT, hWnd: ::HWND, ptCursor: ::POINT, }} pub type LPDRAGLISTINFO = *mut DRAGLISTINFO; pub const DL_BEGINDRAG: ::UINT = ::WM_USER + 133; pub const DL_DRAGGING: ::UINT = ::WM_USER + 134; pub const DL_DROPPED: ::UINT = ::WM_USER + 135; pub const DL_CANCELDRAG: ::UINT = ::WM_USER + 136; pub const DL_CURSORSET: ::UINT = 0; pub const DL_STOPCURSOR: ::UINT = 1; pub const DL_COPYCURSOR: ::UINT = 2; pub const DL_MOVECURSOR: ::UINT = 3; STRUCT!{struct UDACCEL { nSec: ::UINT, nInc: ::UINT, }} pub type LPUDACCEL = *mut UDACCEL; pub const UD_MAXVAL: ::c_short = 0x7fff; pub const UD_MINVAL: ::c_short = 0 - UD_MAXVAL; pub const UDS_WRAP: ::DWORD = 0x0001; pub const UDS_SETBUDDYINT: ::DWORD = 0x0002; pub const UDS_ALIGNRIGHT: ::DWORD = 0x0004; pub const UDS_ALIGNLEFT: ::DWORD = 0x0008; pub const UDS_AUTOBUDDY: ::DWORD = 0x0010; pub const UDS_ARROWKEYS: ::DWORD = 0x0020; pub const UDS_HORZ: ::DWORD = 0x0040; pub const UDS_NOTHOUSANDS: ::DWORD = 0x0080; pub const UDS_HOTTRACK: ::DWORD = 0x0100; pub const UDM_SETRANGE: ::UINT = ::WM_USER + 101; pub const UDM_GETRANGE: ::UINT = ::WM_USER + 102; pub const UDM_SETPOS: ::UINT = ::WM_USER + 103; pub const UDM_GETPOS: ::UINT = ::WM_USER + 104; pub const UDM_SETBUDDY: ::UINT = ::WM_USER + 105; pub const UDM_GETBUDDY: ::UINT = ::WM_USER + 106; pub const UDM_SETACCEL: ::UINT = ::WM_USER + 107; pub const UDM_GETACCEL: ::UINT = ::WM_USER + 108; pub const UDM_SETBASE: ::UINT = ::WM_USER + 109; pub const UDM_GETBASE: ::UINT = ::WM_USER + 110; pub const UDM_SETRANGE32: ::UINT = ::WM_USER + 111; pub const UDM_GETRANGE32: ::UINT = ::WM_USER + 112; pub const UDM_SETUNICODEFORMAT: ::UINT = CCM_SETUNICODEFORMAT; pub const UDM_GETUNICODEFORMAT: ::UINT = CCM_GETUNICODEFORMAT; pub const UDM_SETPOS32: ::UINT = ::WM_USER + 113; pub const UDM_GETPOS32: ::UINT = ::WM_USER + 114; pub type NM_UPDOWN = NMUPDOWN; pub type LPNM_UPDOWN = LPNMUPDOWN; STRUCT!{struct NMUPDOWN { hdr: ::NMHDR, iPos: ::c_int, iDelta: ::c_int, }} pub type LPNMUPDOWN = *mut NMUPDOWN; pub const UDN_DELTAPOS: ::UINT = UDN_FIRST - 1; pub const PBS_SMOOTH: ::DWORD = 0x01; pub const PBS_VERTICAL: ::DWORD = 0x04; pub const PBM_SETRANGE: ::UINT = ::WM_USER + 1; pub const PBM_SETPOS: ::UINT = ::WM_USER + 2; pub const PBM_DELTAPOS: ::UINT = ::WM_USER + 3; pub const PBM_SETSTEP: ::UINT = ::WM_USER + 4; pub const PBM_STEPIT: ::UINT = ::WM_USER + 5; pub const PBM_SETRANGE32: ::UINT = ::WM_USER + 6; STRUCT!{struct PBRANGE { iLow: ::c_int, iHigh: ::c_int, }} pub type LPPBRANGE = *mut PBRANGE; pub const PBM_GETRANGE: ::UINT = ::WM_USER + 7; pub const PBM_GETPOS: ::UINT = ::WM_USER + 8; pub const PBM_SETBARCOLOR: ::UINT = ::WM_USER + 9; pub const PBM_SETBKCOLOR: ::UINT = CCM_SETBKCOLOR; pub const PBM_SETMARQUEE: ::UINT = ::WM_USER + 10; pub const PBS_MARQUEE: ::DWORD = 0x08; pub const PBS_SMOOTHREVERSE: ::DWORD = 0x10; pub const PBM_GETSTEP: ::UINT = ::WM_USER + 13; pub const PBM_GETBKCOLOR: ::UINT = ::WM_USER + 14; pub const PBM_GETBARCOLOR: ::UINT = ::WM_USER + 15; pub const PBM_SETSTATE: ::UINT = ::WM_USER + 16; pub const PBM_GETSTATE: ::UINT = ::WM_USER + 17; pub const PBST_NORMAL: ::c_int = 0x0001; pub const PBST_ERROR: ::c_int = 0x0002; pub const PBST_PAUSED: ::c_int = 0x0003; pub const HOTKEYF_SHIFT: ::BYTE = 0x01; pub const HOTKEYF_CONTROL: ::BYTE = 0x02; pub const HOTKEYF_ALT: ::BYTE = 0x04; pub const HOTKEYF_EXT: ::BYTE = 0x08; pub const HKCOMB_NONE: ::WPARAM = 0x0001; pub const HKCOMB_S: ::WPARAM = 0x0002; pub const HKCOMB_C: ::WPARAM = 0x0004; pub const HKCOMB_A: ::WPARAM = 0x0008; pub const HKCOMB_SC: ::WPARAM = 0x0010; pub const HKCOMB_SA: ::WPARAM = 0x0020; pub const HKCOMB_CA: ::WPARAM = 0x0040; pub const HKCOMB_SCA: ::WPARAM = 0x0080; pub const HKM_SETHOTKEY: ::UINT = ::WM_USER + 1; pub const HKM_GETHOTKEY: ::UINT = ::WM_USER + 2; pub const HKM_SETRULES: ::UINT = ::WM_USER + 3; pub const CCS_TOP: ::DWORD = 0x00000001; pub const CCS_NOMOVEY: ::DWORD = 0x00000002; pub const CCS_BOTTOM: ::DWORD = 0x00000003; pub const CCS_NORESIZE: ::DWORD = 0x00000004; pub const CCS_NOPARENTALIGN: ::DWORD = 0x00000008; pub const CCS_ADJUSTABLE: ::DWORD = 0x00000020; pub const CCS_NODIVIDER: ::DWORD = 0x00000040; pub const CCS_VERT: ::DWORD = 0x00000080; pub const CCS_LEFT: ::DWORD = CCS_VERT | CCS_TOP; pub const CCS_RIGHT: ::DWORD = CCS_VERT | CCS_BOTTOM; pub const CCS_NOMOVEX: ::DWORD = CCS_VERT | CCS_NOMOVEY; pub const MAX_LINKID_TEXT: usize = 48; pub const L_MAX_URL_LENGTH: usize = 2048 + 32 + 4; pub const LWS_TRANSPARENT: ::DWORD = 0x0001; pub const LWS_IGNORERETURN: ::DWORD = 0x0002; pub const LWS_NOPREFIX: ::DWORD = 0x0004; pub const LWS_USEVISUALSTYLE: ::DWORD = 0x0008; pub const LWS_USECUSTOMTEXT: ::DWORD = 0x0010; pub const LWS_RIGHT: ::DWORD = 0x0020; pub const LIF_ITEMINDEX: ::UINT = 0x00000001; pub const LIF_STATE: ::UINT = 0x00000002; pub const LIF_ITEMID: ::UINT = 0x00000004; pub const LIF_URL: ::UINT = 0x00000008; pub const LIS_FOCUSED: ::UINT = 0x00000001; pub const LIS_ENABLED: ::UINT = 0x00000002; pub const LIS_VISITED: ::UINT = 0x00000004; pub const LIS_HOTTRACK: ::UINT = 0x00000008; pub const LIS_DEFAULTCOLORS: ::UINT = 0x00000010; #[repr(C)] #[derive(Copy)] pub struct LITEM { pub mask: ::UINT, pub iLink: ::c_int, pub state: ::UINT, pub stateMask: ::UINT, pub szID: [::WCHAR; MAX_LINKID_TEXT], pub szUrl: [::WCHAR; L_MAX_URL_LENGTH], } impl Clone for LITEM { fn clone(&self) -> LITEM { *self } } pub type PLITEM = *mut LITEM; #[repr(C)] #[derive(Copy)] pub struct LHITTESTINFO { pub pt: ::POINT, pub item: LITEM, } impl Clone for LHITTESTINFO { fn clone(&self) -> LHITTESTINFO { *self } } pub type PLHITTESTINFO = *mut LHITTESTINFO; #[repr(C)] #[derive(Copy)] pub struct NMLINK { pub hdr: ::NMHDR, pub item: LITEM, } impl Clone for NMLINK { fn clone(&self) -> NMLINK { *self } } pub type PNMLINK = *mut NMLINK; pub const LM_HITTEST: ::UINT = ::WM_USER + 0x300; pub const LM_GETIDEALHEIGHT: ::UINT = ::WM_USER + 0x301; pub const LM_SETITEM: ::UINT = ::WM_USER + 0x302; pub const LM_GETITEM: ::UINT = ::WM_USER + 0x303; pub const LM_GETIDEALSIZE: ::UINT = LM_GETIDEALHEIGHT; pub const LVS_ICON: ::DWORD = 0x0000; pub const LVS_REPORT: ::DWORD = 0x0001; pub const LVS_SMALLICON: ::DWORD = 0x0002; pub const LVS_LIST: ::DWORD = 0x0003; pub const LVS_TYPEMASK: ::DWORD = 0x0003; pub const LVS_SINGLESEL: ::DWORD = 0x0004; pub const LVS_SHOWSELALWAYS: ::DWORD = 0x0008; pub const LVS_SORTASCENDING: ::DWORD = 0x0010; pub const LVS_SORTDESCENDING: ::DWORD = 0x0020; pub const LVS_SHAREIMAGELISTS: ::DWORD = 0x0040; pub const LVS_NOLABELWRAP: ::DWORD = 0x0080; pub const LVS_AUTOARRANGE: ::DWORD = 0x0100; pub const LVS_EDITLABELS: ::DWORD = 0x0200; pub const LVS_OWNERDATA: ::DWORD = 0x1000; pub const LVS_NOSCROLL: ::DWORD = 0x2000; pub const LVS_TYPESTYLEMASK: ::DWORD = 0xfc00; pub const LVS_ALIGNTOP: ::DWORD = 0x0000; pub const LVS_ALIGNLEFT: ::DWORD = 0x0800; pub const LVS_ALIGNMASK: ::DWORD = 0x0c00; pub const LVS_OWNERDRAWFIXED: ::DWORD = 0x0400; pub const LVS_NOCOLUMNHEADER: ::DWORD = 0x4000; pub const LVS_NOSORTHEADER: ::DWORD = 0x8000; pub const LVM_SETUNICODEFORMAT: ::UINT = CCM_SETUNICODEFORMAT; pub const LVM_GETUNICODEFORMAT: ::UINT = CCM_GETUNICODEFORMAT; pub const LVM_GETBKCOLOR: ::UINT = LVM_FIRST + 0; pub const LVM_SETBKCOLOR: ::UINT = LVM_FIRST + 1; pub const LVM_GETIMAGELIST: ::UINT = LVM_FIRST + 2; pub const LVM_SETIMAGELIST: ::UINT = LVM_FIRST + 3; pub const LVM_GETITEMCOUNT: ::UINT = LVM_FIRST + 4; pub const LVSIL_NORMAL: ::c_int = 0; pub const LVSIL_SMALL: ::c_int = 1; pub const LVSIL_STATE: ::c_int = 2; pub const LVSIL_GROUPHEADER: ::c_int = 3; pub const LVIF_TEXT: ::UINT = 0x00000001; pub const LVIF_IMAGE: ::UINT = 0x00000002; pub const LVIF_PARAM: ::UINT = 0x00000004; pub const LVIF_STATE: ::UINT = 0x00000008; pub const LVIF_INDENT: ::UINT = 0x00000010; pub const LVIF_NORECOMPUTE: ::UINT = 0x00000800; pub const LVIF_GROUPID: ::UINT = 0x00000100; pub const LVIF_COLUMNS: ::UINT = 0x00000200; pub const LVIF_COLFMT: ::UINT = 0x00010000; pub const LVIS_FOCUSED: ::UINT = 0x0001; pub const LVIS_SELECTED: ::UINT = 0x0002; pub const LVIS_CUT: ::UINT = 0x0004; pub const LVIS_DROPHILITED: ::UINT = 0x0008; pub const LVIS_GLOW: ::UINT = 0x0010; pub const LVIS_ACTIVATING: ::UINT = 0x0020; pub const LVIS_OVERLAYMASK: ::UINT = 0x0F00; pub const LVIS_STATEIMAGEMASK: ::UINT = 0xF000; #[inline] #[allow(dead_code)] pub fn INDEXTOSTATEIMAGEMASK(i: ::UINT) -> ::UINT { i << 12 } pub const I_INDENTCALLBACK: ::c_int = -1; pub type LV_ITEMA = LVITEMA; pub type LV_ITEMW = LVITEMW; pub const I_GROUPIDCALLBACK: ::c_int = -1; pub const I_GROUPIDNONE: ::c_int = -2; STRUCT!{struct LVITEMA { mask: ::UINT, iItem: ::c_int, iSubItem: ::c_int, state: ::UINT, stateMask: ::UINT, pszText: ::LPSTR, cchTextMax: ::c_int, iImage: ::c_int, lParam: ::LPARAM, iIndent: ::c_int, iGroupId: ::c_int, cColumns: ::UINT, puColumns: ::PUINT, piColFmt: *mut ::c_int, iGroup: ::c_int, }} pub type LPLVITEMA = *mut LVITEMA; STRUCT!{struct LVITEMW { mask: ::UINT, iItem: ::c_int, iSubItem: ::c_int, state: ::UINT, stateMask: ::UINT, pszText: ::LPWSTR, cchTextMax: ::c_int, iImage: ::c_int, lParam: ::LPARAM, iIndent: ::c_int, iGroupId: ::c_int, cColumns: ::UINT, puColumns: ::PUINT, piColFmt: *mut ::c_int, iGroup: ::c_int, }} pub type LPLVITEMW = *mut LVITEMW; pub const LPSTR_TEXTCALLBACKW: ::LPWSTR = (0 - 1) as ::LPWSTR; pub const LPSTR_TEXTCALLBACKA: ::LPSTR = (0 - 1) as ::LPSTR; pub const I_IMAGECALLBACK: ::c_int = -1; pub const I_IMAGENONE: ::c_int = -2; pub const I_COLUMNSCALLBACK: ::UINT = 0 - 1; pub const LVM_GETITEMA: ::UINT = LVM_FIRST + 5; pub const LVM_GETITEMW: ::UINT = LVM_FIRST + 75; pub const LVM_SETITEMA: ::UINT = LVM_FIRST + 6; pub const LVM_SETITEMW: ::UINT = LVM_FIRST + 76; pub const LVM_INSERTITEMA: ::UINT = LVM_FIRST + 7; pub const LVM_INSERTITEMW: ::UINT = LVM_FIRST + 77; pub const LVM_DELETEITEM: ::UINT = LVM_FIRST + 8; pub const LVM_DELETEALLITEMS: ::UINT = LVM_FIRST + 9; pub const LVM_GETCALLBACKMASK: ::UINT = LVM_FIRST + 10; pub const LVM_SETCALLBACKMASK: ::UINT = LVM_FIRST + 11; pub const LVM_GETNEXTITEM: ::UINT = LVM_FIRST + 12; pub const LVNI_ALL: ::LPARAM = 0x0000; pub const LVNI_FOCUSED: ::LPARAM = 0x0001; pub const LVNI_SELECTED: ::LPARAM = 0x0002; pub const LVNI_CUT: ::LPARAM = 0x0004; pub const LVNI_DROPHILITED: ::LPARAM = 0x0008; pub const LVNI_STATEMASK: ::LPARAM = LVNI_FOCUSED | LVNI_SELECTED | LVNI_CUT | LVNI_DROPHILITED; pub const LVNI_VISIBLEORDER: ::LPARAM = 0x0010; pub const LVNI_PREVIOUS: ::LPARAM = 0x0020; pub const LVNI_VISIBLEONLY: ::LPARAM = 0x0040; pub const LVNI_SAMEGROUPONLY: ::LPARAM = 0x0080; pub const LVNI_ABOVE: ::LPARAM = 0x0100; pub const LVNI_BELOW: ::LPARAM = 0x0200; pub const LVNI_TOLEFT: ::LPARAM = 0x0400; pub const LVNI_TORIGHT: ::LPARAM = 0x0800; pub const LVNI_DIRECTIONMASK: ::LPARAM = LVNI_ABOVE | LVNI_BELOW | LVNI_TOLEFT | LVNI_TORIGHT; pub const LVFI_PARAM: ::UINT = 0x0001; pub const LVFI_STRING: ::UINT = 0x0002; pub const LVFI_SUBSTRING: ::UINT = 0x0004; pub const LVFI_PARTIAL: ::UINT = 0x0008; pub const LVFI_WRAP: ::UINT = 0x0020; pub const LVFI_NEARESTXY: ::UINT = 0x0040; pub type LV_FINDINFOA = LVFINDINFOA; pub type LV_FINDINFOW = LVFINDINFOW; STRUCT!{struct LVFINDINFOA { flags: ::UINT, psz: ::LPCSTR, lParam: ::LPARAM, pt: ::POINT, vkDirection: ::UINT, }} pub type LPLVFINDINFOA = *mut LVFINDINFOA; STRUCT!{struct LVFINDINFOW { flags: ::UINT, psz: ::LPCWSTR, lParam: ::LPARAM, pt: ::POINT, vkDirection: ::UINT, }} pub type LPLVFINDINFOW = *mut LVFINDINFOW; pub const LVM_FINDITEMA: ::UINT = LVM_FIRST + 13; pub const LVM_FINDITEMW: ::UINT = LVM_FIRST + 83; pub const LVIR_BOUNDS: ::c_int = 0; pub const LVIR_ICON: ::c_int = 1; pub const LVIR_LABEL: ::c_int = 2; pub const LVIR_SELECTBOUNDS: ::c_int = 3; pub const LVM_GETITEMRECT: ::UINT = LVM_FIRST + 14; pub const LVM_SETITEMPOSITION: ::UINT = LVM_FIRST + 15; pub const LVM_GETITEMPOSITION: ::UINT = LVM_FIRST + 16; pub const LVM_GETSTRINGWIDTHA: ::UINT = LVM_FIRST + 17; pub const LVM_GETSTRINGWIDTHW: ::UINT = LVM_FIRST + 87; pub const LVHT_NOWHERE: ::UINT = 0x00000001; pub const LVHT_ONITEMICON: ::UINT = 0x00000002; pub const LVHT_ONITEMLABEL: ::UINT = 0x00000004; pub const LVHT_ONITEMSTATEICON: ::UINT = 0x00000008; pub const LVHT_ONITEM: ::UINT = LVHT_ONITEMICON | LVHT_ONITEMLABEL | LVHT_ONITEMSTATEICON; pub const LVHT_ABOVE: ::UINT = 0x00000008; pub const LVHT_BELOW: ::UINT = 0x00000010; pub const LVHT_TORIGHT: ::UINT = 0x00000020; pub const LVHT_TOLEFT: ::UINT = 0x00000040; pub const LVHT_EX_GROUP_HEADER: ::UINT = 0x10000000; pub const LVHT_EX_GROUP_FOOTER: ::UINT = 0x20000000; pub const LVHT_EX_GROUP_COLLAPSE: ::UINT = 0x40000000; pub const LVHT_EX_GROUP_BACKGROUND: ::UINT = 0x80000000; pub const LVHT_EX_GROUP_STATEICON: ::UINT = 0x01000000; pub const LVHT_EX_GROUP_SUBSETLINK: ::UINT = 0x02000000; pub const LVHT_EX_GROUP: ::UINT = LVHT_EX_GROUP_BACKGROUND | LVHT_EX_GROUP_COLLAPSE | LVHT_EX_GROUP_FOOTER | LVHT_EX_GROUP_HEADER | LVHT_EX_GROUP_STATEICON | LVHT_EX_GROUP_SUBSETLINK; pub const LVHT_EX_ONCONTENTS: ::UINT = 0x04000000; pub const LVHT_EX_FOOTER: ::UINT = 0x08000000; pub type LV_HITTESTINFO = LVHITTESTINFO; STRUCT!{struct LVHITTESTINFO { pt: ::POINT, flags: ::UINT, iItem: ::c_int, iSubItem: ::c_int, iGroup: ::c_int, }} pub type LPLVHITTESTINFO = *mut LVHITTESTINFO; pub const LVM_HITTEST: ::UINT = LVM_FIRST + 18; pub const LVM_ENSUREVISIBLE: ::UINT = LVM_FIRST + 19; pub const LVM_SCROLL: ::UINT = LVM_FIRST + 20; pub const LVM_REDRAWITEMS: ::UINT = LVM_FIRST + 21; pub const LVA_DEFAULT: ::WPARAM = 0x0000; pub const LVA_ALIGNLEFT: ::WPARAM = 0x0001; pub const LVA_ALIGNTOP: ::WPARAM = 0x0002; pub const LVA_SNAPTOGRID: ::WPARAM = 0x0005; pub const LVM_ARRANGE: ::UINT = LVM_FIRST + 22; pub const LVM_EDITLABELA: ::UINT = LVM_FIRST + 23; pub const LVM_EDITLABELW: ::UINT = LVM_FIRST + 118; pub const LVM_GETEDITCONTROL: ::UINT = LVM_FIRST + 24; pub type LV_COLUMNA = LVCOLUMNA; pub type LV_COLUMNW = LVCOLUMNW; STRUCT!{struct LVCOLUMNA { mask: ::UINT, fmt: ::c_int, cx: ::c_int, pszText: ::LPSTR, cchTextMax: ::c_int, iSubItem: ::c_int, iImage: ::c_int, iOrder: ::c_int, cxMin: ::c_int, cxDefault: ::c_int, cxIdeal: ::c_int, }} pub type LPLVCOLUMNA = *mut LVCOLUMNA; STRUCT!{struct LVCOLUMNW { mask: ::UINT, fmt: ::c_int, cx: ::c_int, pszText: ::LPWSTR, cchTextMax: ::c_int, iSubItem: ::c_int, iImage: ::c_int, iOrder: ::c_int, cxMin: ::c_int, cxDefault: ::c_int, cxIdeal: ::c_int, }} pub type LPLVCOLUMNW = *mut LVCOLUMNW; pub const LVCF_FMT: ::UINT = 0x0001; pub const LVCF_WIDTH: ::UINT = 0x0002; pub const LVCF_TEXT: ::UINT = 0x0004; pub const LVCF_SUBITEM: ::UINT = 0x0008; pub const LVCF_IMAGE: ::UINT = 0x0010; pub const LVCF_ORDER: ::UINT = 0x0020; pub const LVCF_MINWIDTH: ::UINT = 0x0040; pub const LVCF_DEFAULTWIDTH: ::UINT = 0x0080; pub const LVCF_IDEALWIDTH: ::UINT = 0x0100; pub const LVCFMT_LEFT: ::c_int = 0x0000; pub const LVCFMT_RIGHT: ::c_int = 0x0001; pub const LVCFMT_CENTER: ::c_int = 0x0002; pub const LVCFMT_JUSTIFYMASK: ::c_int = 0x0003; pub const LVCFMT_IMAGE: ::c_int = 0x0800; pub const LVCFMT_BITMAP_ON_RIGHT: ::c_int = 0x1000; pub const LVCFMT_COL_HAS_IMAGES: ::c_int = 0x8000; pub const LVCFMT_FIXED_WIDTH: ::c_int = 0x00100; pub const LVCFMT_NO_DPI_SCALE: ::c_int = 0x40000; pub const LVCFMT_FIXED_RATIO: ::c_int = 0x80000; pub const LVCFMT_LINE_BREAK: ::c_int = 0x100000; pub const LVCFMT_FILL: ::c_int = 0x200000; pub const LVCFMT_WRAP: ::c_int = 0x400000; pub const LVCFMT_NO_TITLE: ::c_int = 0x800000; pub const LVCFMT_TILE_PLACEMENTMASK: ::c_int = LVCFMT_LINE_BREAK | LVCFMT_FILL; pub const LVCFMT_SPLITBUTTON: ::c_int = 0x1000000; pub const LVM_GETCOLUMNA: ::UINT = LVM_FIRST + 25; pub const LVM_GETCOLUMNW: ::UINT = LVM_FIRST + 95; pub const LVM_SETCOLUMNA: ::UINT = LVM_FIRST + 26; pub const LVM_SETCOLUMNW: ::UINT = LVM_FIRST + 96; pub const LVM_INSERTCOLUMNA: ::UINT = LVM_FIRST + 27; pub const LVM_INSERTCOLUMNW: ::UINT = LVM_FIRST + 97; pub const LVM_DELETECOLUMN: ::UINT = LVM_FIRST + 28; pub const LVM_GETCOLUMNWIDTH: ::UINT = LVM_FIRST + 29; pub const LVM_SETCOLUMNWIDTH: ::UINT = LVM_FIRST + 30; pub const LVM_GETHEADER: ::UINT = LVM_FIRST + 31; pub const LVM_CREATEDRAGIMAGE: ::UINT = LVM_FIRST + 33; pub const LVM_GETVIEWRECT: ::UINT = LVM_FIRST + 34; pub const LVM_GETTEXTCOLOR: ::UINT = LVM_FIRST + 35; pub const LVM_SETTEXTCOLOR: ::UINT = LVM_FIRST + 36; pub const LVM_GETTEXTBKCOLOR: ::UINT = LVM_FIRST + 37; pub const LVM_SETTEXTBKCOLOR: ::UINT = LVM_FIRST + 38; pub const LVM_GETTOPINDEX: ::UINT = LVM_FIRST + 39; pub const LVM_GETCOUNTPERPAGE: ::UINT = LVM_FIRST + 40; pub const LVM_GETORIGIN: ::UINT = LVM_FIRST + 41; pub const LVM_UPDATE: ::UINT = LVM_FIRST + 42; pub const LVM_SETITEMSTATE: ::UINT = LVM_FIRST + 43; pub const LVM_GETITEMSTATE: ::UINT = LVM_FIRST + 44; pub const LVM_GETITEMTEXTA: ::UINT = LVM_FIRST + 45; pub const LVM_GETITEMTEXTW: ::UINT = LVM_FIRST + 115; pub const LVM_SETITEMTEXTA: ::UINT = LVM_FIRST + 46; pub const LVM_SETITEMTEXTW: ::UINT = LVM_FIRST + 116; pub const LVM_SETITEMCOUNT: ::UINT = LVM_FIRST + 47; pub const LVM_SORTITEMS: ::UINT = LVM_FIRST + 48; pub const LVM_SETITEMPOSITION32: ::UINT = LVM_FIRST + 49; pub const LVM_GETSELECTEDCOUNT: ::UINT = LVM_FIRST + 50; pub const LVM_GETITEMSPACING: ::UINT = LVM_FIRST + 51; pub const LVM_GETISEARCHSTRINGA: ::UINT = LVM_FIRST + 52; pub const LVM_GETISEARCHSTRINGW: ::UINT = LVM_FIRST + 117; pub const LVM_SETICONSPACING: ::UINT = LVM_FIRST + 53; pub const LVM_SETEXTENDEDLISTVIEWSTYLE: ::UINT = LVM_FIRST + 54; pub const LVM_GETEXTENDEDLISTVIEWSTYLE: ::UINT = LVM_FIRST + 55; pub const LVSICF_NOINVALIDATEALL: ::LPARAM = 0x00000001; pub const LVSICF_NOSCROLL: ::LPARAM = 0x00000002; pub const LVS_EX_GRIDLINES: ::DWORD = 0x00000001; pub const LVS_EX_SUBITEMIMAGES: ::DWORD = 0x00000002; pub const LVS_EX_CHECKBOXES: ::DWORD = 0x00000004; pub const LVS_EX_TRACKSELECT: ::DWORD = 0x00000008; pub const LVS_EX_HEADERDRAGDROP: ::DWORD = 0x00000010; pub const LVS_EX_FULLROWSELECT: ::DWORD = 0x00000020; pub const LVS_EX_ONECLICKACTIVATE: ::DWORD = 0x00000040; pub const LVS_EX_TWOCLICKACTIVATE: ::DWORD = 0x00000080; pub const LVS_EX_FLATSB: ::DWORD = 0x00000100; pub const LVS_EX_REGIONAL: ::DWORD = 0x00000200; pub const LVS_EX_INFOTIP: ::DWORD = 0x00000400; pub const LVS_EX_UNDERLINEHOT: ::DWORD = 0x00000800; pub const LVS_EX_UNDERLINECOLD: ::DWORD = 0x00001000; pub const LVS_EX_MULTIWORKAREAS: ::DWORD = 0x00002000; pub const LVS_EX_LABELTIP: ::DWORD = 0x00004000; pub const LVS_EX_BORDERSELECT: ::DWORD = 0x00008000; pub const LVS_EX_DOUBLEBUFFER: ::DWORD = 0x00010000; pub const LVS_EX_HIDELABELS: ::DWORD = 0x00020000; pub const LVS_EX_SINGLEROW: ::DWORD = 0x00040000; pub const LVS_EX_SNAPTOGRID: ::DWORD = 0x00080000; pub const LVS_EX_SIMPLESELECT: ::DWORD = 0x00100000; pub const LVS_EX_JUSTIFYCOLUMNS: ::DWORD = 0x00200000; pub const LVS_EX_TRANSPARENTBKGND: ::DWORD = 0x00400000; pub const LVS_EX_TRANSPARENTSHADOWTEXT: ::DWORD = 0x00800000; pub const LVS_EX_AUTOAUTOARRANGE: ::DWORD = 0x01000000; pub const LVS_EX_HEADERINALLVIEWS: ::DWORD = 0x02000000; pub const LVS_EX_AUTOCHECKSELECT: ::DWORD = 0x08000000; pub const LVS_EX_AUTOSIZECOLUMNS: ::DWORD = 0x10000000; pub const LVS_EX_COLUMNSNAPPOINTS: ::DWORD = 0x40000000; pub const LVS_EX_COLUMNOVERFLOW: ::DWORD = 0x80000000; pub const LVM_GETSUBITEMRECT: ::UINT = LVM_FIRST + 56; pub const LVM_SUBITEMHITTEST: ::UINT = LVM_FIRST + 57; pub const LVM_SETCOLUMNORDERARRAY: ::UINT = LVM_FIRST + 58; pub const LVM_GETCOLUMNORDERARRAY: ::UINT = LVM_FIRST + 59; pub const LVM_SETHOTITEM: ::UINT = LVM_FIRST + 60; pub const LVM_GETHOTITEM: ::UINT = LVM_FIRST + 61; pub const LVM_SETHOTCURSOR: ::UINT = LVM_FIRST + 62; pub const LVM_GETHOTCURSOR: ::UINT = LVM_FIRST + 63; pub const LVM_APPROXIMATEVIEWRECT: ::UINT = LVM_FIRST + 64; pub const LV_MAX_WORKAREAS: ::WPARAM = 16; pub const LVM_SETWORKAREAS: ::UINT = LVM_FIRST + 65; pub const LVM_GETWORKAREAS: ::UINT = LVM_FIRST + 70; pub const LVM_GETNUMBEROFWORKAREAS: ::UINT = LVM_FIRST + 73; pub const LVM_GETSELECTIONMARK: ::UINT = LVM_FIRST + 66; pub const LVM_SETSELECTIONMARK: ::UINT = LVM_FIRST + 67; pub const LVM_SETHOVERTIME: ::UINT = LVM_FIRST + 71; pub const LVM_GETHOVERTIME: ::UINT = LVM_FIRST + 72; pub const LVM_SETTOOLTIPS: ::UINT = LVM_FIRST + 74; pub const LVM_GETTOOLTIPS: ::UINT = LVM_FIRST + 78; pub const LVM_SORTITEMSEX: ::UINT = LVM_FIRST + 81; STRUCT!{struct LVBKIMAGEA { ulFlags: ::ULONG, hbm: ::HBITMAP, pszImage: ::LPSTR, cchImageMax: ::UINT, xOffsetPercent: ::c_int, yOffsetPercent: ::c_int, }} pub type LPLVBKIMAGEA = *mut LVBKIMAGEA; STRUCT!{struct LVBKIMAGEW { ulFlags: ::ULONG, hbm: ::HBITMAP, pszImage: ::LPWSTR, cchImageMax: ::UINT, xOffsetPercent: ::c_int, yOffsetPercent: ::c_int, }} pub type LPLVBKIMAGEW = *mut LVBKIMAGEW; pub const LVBKIF_SOURCE_NONE: ::ULONG = 0x00000000; pub const LVBKIF_SOURCE_HBITMAP: ::ULONG = 0x00000001; pub const LVBKIF_SOURCE_URL: ::ULONG = 0x00000002; pub const LVBKIF_SOURCE_MASK: ::ULONG = 0x00000003; pub const LVBKIF_STYLE_NORMAL: ::ULONG = 0x00000000; pub const LVBKIF_STYLE_TILE: ::ULONG = 0x00000010; pub const LVBKIF_STYLE_MASK: ::ULONG = 0x00000010; pub const LVBKIF_FLAG_TILEOFFSET: ::ULONG = 0x00000100; pub const LVBKIF_TYPE_WATERMARK: ::ULONG = 0x10000000; pub const LVBKIF_FLAG_ALPHABLEND: ::ULONG = 0x20000000; pub const LVM_SETBKIMAGEA: ::UINT = LVM_FIRST + 68; pub const LVM_SETBKIMAGEW: ::UINT = LVM_FIRST + 138; pub const LVM_GETBKIMAGEA: ::UINT = LVM_FIRST + 69; pub const LVM_GETBKIMAGEW: ::UINT = LVM_FIRST + 139; pub const LVM_SETSELECTEDCOLUMN: ::UINT = LVM_FIRST + 140; pub const LV_VIEW_ICON: ::DWORD = 0x0000; pub const LV_VIEW_DETAILS: ::DWORD = 0x0001; pub const LV_VIEW_SMALLICON: ::DWORD = 0x0002; pub const LV_VIEW_LIST: ::DWORD = 0x0003; pub const LV_VIEW_TILE: ::DWORD = 0x0004; pub const LV_VIEW_MAX: ::DWORD = 0x0004; pub const LVM_SETVIEW: ::UINT = LVM_FIRST + 142; pub const LVM_GETVIEW: ::UINT = LVM_FIRST + 143; pub const LVGF_NONE: ::UINT = 0x00000000; pub const LVGF_HEADER: ::UINT = 0x00000001; pub const LVGF_FOOTER: ::UINT = 0x00000002; pub const LVGF_STATE: ::UINT = 0x00000004; pub const LVGF_ALIGN: ::UINT = 0x00000008; pub const LVGF_GROUPID: ::UINT = 0x00000010; pub const LVGF_SUBTITLE: ::UINT = 0x00000100; pub const LVGF_TASK: ::UINT = 0x00000200; pub const LVGF_DESCRIPTIONTOP: ::UINT = 0x00000400; pub const LVGF_DESCRIPTIONBOTTOM: ::UINT = 0x00000800; pub const LVGF_TITLEIMAGE: ::UINT = 0x00001000; pub const LVGF_EXTENDEDIMAGE: ::UINT = 0x00002000; pub const LVGF_ITEMS: ::UINT = 0x00004000; pub const LVGF_SUBSET: ::UINT = 0x00008000; pub const LVGF_SUBSETITEMS: ::UINT = 0x00010000; pub const LVGS_NORMAL: ::UINT = 0x00000000; pub const LVGS_COLLAPSED: ::UINT = 0x00000001; pub const LVGS_HIDDEN: ::UINT = 0x00000002; pub const LVGS_NOHEADER: ::UINT = 0x00000004; pub const LVGS_COLLAPSIBLE: ::UINT = 0x00000008; pub const LVGS_FOCUSED: ::UINT = 0x00000010; pub const LVGS_SELECTED: ::UINT = 0x00000020; pub const LVGS_SUBSETED: ::UINT = 0x00000040; pub const LVGS_SUBSETLINKFOCUSED: ::UINT = 0x00000080; pub const LVGA_HEADER_LEFT: ::UINT = 0x00000001; pub const LVGA_HEADER_CENTER: ::UINT = 0x00000002; pub const LVGA_HEADER_RIGHT: ::UINT = 0x00000004; pub const LVGA_FOOTER_LEFT: ::UINT = 0x00000008; pub const LVGA_FOOTER_CENTER: ::UINT = 0x00000010; pub const LVGA_FOOTER_RIGHT: ::UINT = 0x00000020; STRUCT!{struct LVGROUP { cbSize: ::UINT, mask: ::UINT, pszHeader: ::LPWSTR, cchHeader: ::c_int, pszFooter: ::LPWSTR, cchFooter: ::c_int, iGroupId: ::c_int, stateMask: ::UINT, state: ::UINT, uAlign: ::UINT, pszSubtitle: ::LPWSTR, cchSubtitle: ::UINT, pszTask: ::LPWSTR, cchTask: ::UINT, pszDescriptionTop: ::LPWSTR, cchDescriptionTop: ::UINT, pszDescriptionBottom: ::LPWSTR, cchDescriptionBottom: ::UINT, iTitleImage: ::c_int, iExtendedImage: ::c_int, iFirstItem: ::c_int, cItems: ::UINT, pszSubsetTitle: ::LPWSTR, cchSubsetTitle: ::UINT, }} pub type PLVGROUP = *mut LVGROUP; pub const LVM_INSERTGROUP: ::UINT = LVM_FIRST + 145; pub const LVM_SETGROUPINFO: ::UINT = LVM_FIRST + 147; pub const LVM_GETGROUPINFO: ::UINT = LVM_FIRST + 149; pub const LVM_REMOVEGROUP: ::UINT = LVM_FIRST + 150; pub const LVM_MOVEGROUP: ::UINT = LVM_FIRST + 151; pub const LVM_GETGROUPCOUNT: ::UINT = LVM_FIRST + 152; pub const LVM_GETGROUPINFOBYINDEX: ::UINT = LVM_FIRST + 153; pub const LVM_MOVEITEMTOGROUP: ::UINT = LVM_FIRST + 154; pub const LVM_GETGROUPRECT: ::UINT = LVM_FIRST + 98; pub const LVGGR_GROUP: ::LPARAM = 0; pub const LVGGR_HEADER: ::LPARAM = 1; pub const LVGGR_LABEL: ::LPARAM = 2; pub const LVGGR_SUBSETLINK: ::LPARAM = 3; pub const LVGMF_NONE: ::UINT = 0x00000000; pub const LVGMF_BORDERSIZE: ::UINT = 0x00000001; pub const LVGMF_BORDERCOLOR: ::UINT = 0x00000002; pub const LVGMF_TEXTCOLOR: ::UINT = 0x00000004; STRUCT!{struct LVGROUPMETRICS { cbSize: ::UINT, mask: ::UINT, Left: ::UINT, Top: ::UINT, Right: ::UINT, Bottom: ::UINT, crLeft: ::COLORREF, crTop: ::COLORREF, crRight: ::COLORREF, crBottom: ::COLORREF, crHeader: ::COLORREF, crFooter: ::COLORREF, }} pub type PLVGROUPMETRICS = *mut LVGROUPMETRICS; pub const LVM_SETGROUPMETRICS: ::UINT = LVM_FIRST + 155; pub const LVM_GETGROUPMETRICS: ::UINT = LVM_FIRST + 156; pub const LVM_ENABLEGROUPVIEW: ::UINT = LVM_FIRST + 157; pub const LVM_SORTGROUPS: ::UINT = LVM_FIRST + 158; pub type PFNLVGROUPCOMPARE = Option ::c_int>; #[repr(C)] #[derive(Copy)] pub struct LVINSERTGROUPSORTED { pub pfnGroupCompare: PFNLVGROUPCOMPARE, pub pvData: *mut ::c_void, pub lvGroup: LVGROUP, } impl Clone for LVINSERTGROUPSORTED { fn clone(&self) -> LVINSERTGROUPSORTED { *self } } pub type PLVINSERTGROUPSORTED = *mut LVINSERTGROUPSORTED; pub const LVM_INSERTGROUPSORTED: ::UINT = LVM_FIRST + 159; pub const LVM_REMOVEALLGROUPS: ::UINT = LVM_FIRST + 160; pub const LVM_HASGROUP: ::UINT = LVM_FIRST + 161; pub const LVM_GETGROUPSTATE: ::UINT = LVM_FIRST + 92; pub const LVM_GETFOCUSEDGROUP: ::UINT = LVM_FIRST + 93; pub const LVTVIF_AUTOSIZE: ::DWORD = 0x00000000; pub const LVTVIF_FIXEDWIDTH: ::DWORD = 0x00000001; pub const LVTVIF_FIXEDHEIGHT: ::DWORD = 0x00000002; pub const LVTVIF_FIXEDSIZE: ::DWORD = 0x00000003; pub const LVTVIF_EXTENDED: ::DWORD = 0x00000004; pub const LVTVIM_TILESIZE: ::DWORD = 0x00000001; pub const LVTVIM_COLUMNS: ::DWORD = 0x00000002; pub const LVTVIM_LABELMARGIN: ::DWORD = 0x00000004; STRUCT!{struct LVTILEVIEWINFO { cbSize: ::UINT, dwMask: ::DWORD, dwFlags: ::DWORD, sizeTile: ::SIZE, cLines: ::c_int, rcLabelMargin: ::RECT, }} pub type PLVTILEVIEWINFO = *mut LVTILEVIEWINFO; STRUCT!{struct LVTILEINFO { cbSize: ::UINT, iItem: ::c_int, cColumns: ::UINT, puColumns: ::PUINT, piColFmt: *mut ::c_int, }} pub type PLVTILEINFO = *mut LVTILEINFO; pub const LVM_SETTILEVIEWINFO: ::UINT = LVM_FIRST + 162; pub const LVM_GETTILEVIEWINFO: ::UINT = LVM_FIRST + 163; pub const LVM_SETTILEINFO: ::UINT = LVM_FIRST + 164; pub const LVM_GETTILEINFO: ::UINT = LVM_FIRST + 165; STRUCT!{struct LVINSERTMARK { cbSize: ::UINT, dwFlags: ::DWORD, iItem: ::c_int, dwReserved: ::DWORD, }} pub type LPLVINSERTMARK = *mut LVINSERTMARK; pub const LVIM_AFTER: ::DWORD = 0x00000001; pub const LVM_SETINSERTMARK: ::UINT = LVM_FIRST + 166; pub const LVM_GETINSERTMARK: ::UINT = LVM_FIRST + 167; pub const LVM_INSERTMARKHITTEST: ::UINT = LVM_FIRST + 168; pub const LVM_GETINSERTMARKRECT: ::UINT = LVM_FIRST + 169; pub const LVM_SETINSERTMARKCOLOR: ::UINT = LVM_FIRST + 170; pub const LVM_GETINSERTMARKCOLOR: ::UINT = LVM_FIRST + 171; STRUCT!{struct LVSETINFOTIP { cbSize: ::UINT, dwFlags: ::DWORD, pszText: ::LPWSTR, iItem: ::c_int, iSubItem: ::c_int, }} pub type PLVSETINFOTIP = *mut LVSETINFOTIP; pub const LVM_SETINFOTIP: ::UINT = LVM_FIRST + 173; pub const LVM_GETSELECTEDCOLUMN: ::UINT = LVM_FIRST + 174; pub const LVM_ISGROUPVIEWENABLED: ::UINT = LVM_FIRST + 175; pub const LVM_GETOUTLINECOLOR: ::UINT = LVM_FIRST + 176; pub const LVM_SETOUTLINECOLOR: ::UINT = LVM_FIRST + 177; pub const LVM_CANCELEDITLABEL: ::UINT = LVM_FIRST + 179; pub const LVM_MAPINDEXTOID: ::UINT = LVM_FIRST + 180; pub const LVM_MAPIDTOINDEX: ::UINT = LVM_FIRST + 181; pub const LVM_ISITEMVISIBLE: ::UINT = LVM_FIRST + 182; pub const LVM_GETEMPTYTEXT: ::UINT = LVM_FIRST + 204; pub const LVM_GETFOOTERRECT: ::UINT = LVM_FIRST + 205; pub const LVFF_ITEMCOUNT: ::UINT = 0x00000001; STRUCT!{struct LVFOOTERINFO { mask: ::UINT, pszText: ::LPWSTR, cchTextMax: ::c_int, cItems: ::UINT, }} pub type LPLVFOOTERINFO = *mut LVFOOTERINFO; pub const LVM_GETFOOTERINFO: ::UINT = LVM_FIRST + 206; pub const LVM_GETFOOTERITEMRECT: ::UINT = LVM_FIRST + 207; pub const LVFIF_TEXT: ::UINT = 0x00000001; pub const LVFIF_STATE: ::UINT = 0x00000002; pub const LVFIS_FOCUSED: ::UINT = 0x0001; STRUCT!{struct LVFOOTERITEM { mask: ::UINT, iItem: ::c_int, pszText: ::LPWSTR, cchTextMax: ::c_int, state: ::UINT, stateMask: ::UINT, }} pub type LPLVFOOTERITEM = *mut LVFOOTERITEM; pub const LVM_GETFOOTERITEM: ::UINT = LVM_FIRST + 208; STRUCT!{struct LVITEMINDEX { iItem: ::c_int, iGroup: ::c_int, }} pub type PLVITEMINDEX = *mut LVITEMINDEX; pub const LVM_GETITEMINDEXRECT: ::UINT = LVM_FIRST + 209; pub const LVM_SETITEMINDEXSTATE: ::UINT = LVM_FIRST + 210; pub const LVM_GETNEXTITEMINDEX: ::UINT = LVM_FIRST + 211; pub type LPNM_LISTVIEW = LPNMLISTVIEW; pub type NM_LISTVIEW = NMLISTVIEW; STRUCT!{struct NMLISTVIEW { hdr: ::NMHDR, iItem: ::c_int, iSubItem: ::c_int, uNewState: ::UINT, uOldState: ::UINT, uChanged: ::UINT, ptAction: ::POINT, lParam: ::LPARAM, }} pub type LPNMLISTVIEW = *mut NMLISTVIEW; STRUCT!{struct NMITEMACTIVATE { hdr: ::NMHDR, iItem: ::c_int, iSubItem: ::c_int, uNewState: ::UINT, uOldState: ::UINT, uChanged: ::UINT, ptAction: ::POINT, lParam: ::LPARAM, uKeyFlags: ::UINT, }} pub type LPNMITEMACTIVATE = *mut NMITEMACTIVATE; pub const LVKF_ALT: ::UINT = 0x0001; pub const LVKF_CONTROL: ::UINT = 0x0002; pub const LVKF_SHIFT: ::UINT = 0x0004; STRUCT!{struct NMLVCUSTOMDRAW { nmcd: NMCUSTOMDRAW, clrText: ::COLORREF, clrTextBk: ::COLORREF, iSubItem: ::c_int, dwItemType: ::DWORD, clrFace: ::COLORREF, iIconEffect: ::c_int, iIconPhase: ::c_int, iPartId: ::c_int, iStateId: ::c_int, rcText: ::RECT, uAlign: ::UINT, }} pub type LPNMLVCUSTOMDRAW = *mut NMLVCUSTOMDRAW; pub const LVCDI_ITEM: ::DWORD = 0x00000000; pub const LVCDI_GROUP: ::DWORD = 0x00000001; pub const LVCDI_ITEMSLIST: ::DWORD = 0x00000002; pub const LVCDRF_NOSELECT: ::LRESULT = 0x00010000; pub const LVCDRF_NOGROUPFRAME: ::LRESULT = 0x00020000; STRUCT!{struct NMLVCACHEHINT { hdr: ::NMHDR, iFrom: ::c_int, iTo: ::c_int, }} pub type LPNMLVCACHEHINT = *mut NMLVCACHEHINT; pub type LPNM_CACHEHINT = LPNMLVCACHEHINT; pub type PNM_CACHEHINT = LPNMLVCACHEHINT; pub type NM_CACHEHINT = NMLVCACHEHINT; STRUCT!{struct NMLVFINDITEMA { hdr: ::NMHDR, iStart: ::c_int, lvfi: LVFINDINFOA, }} pub type LPNMLVFINDITEMA = *mut NMLVFINDITEMA; STRUCT!{struct NMLVFINDITEMW { hdr: ::NMHDR, iStart: ::c_int, lvfi: LVFINDINFOW, }} pub type LPNMLVFINDITEMW = *mut NMLVFINDITEMW; pub type PNM_FINDITEMA = LPNMLVFINDITEMA; pub type LPNM_FINDITEMA = LPNMLVFINDITEMA; pub type NM_FINDITEMA = NMLVFINDITEMA; pub type PNM_FINDITEMW = LPNMLVFINDITEMW; pub type LPNM_FINDITEMW = LPNMLVFINDITEMW; pub type NM_FINDITEMW = NMLVFINDITEMW; STRUCT!{struct NMLVODSTATECHANGE { hdr: ::NMHDR, iFrom: ::c_int, iTo: ::c_int, uNewState: ::UINT, uOldState: ::UINT, }} pub type LPNMLVODSTATECHANGE = *mut NMLVODSTATECHANGE; pub type PNM_ODSTATECHANGE = LPNMLVODSTATECHANGE; pub type LPNM_ODSTATECHANGE = LPNMLVODSTATECHANGE; pub type NM_ODSTATECHANGE = NMLVODSTATECHANGE; pub const LVN_ITEMCHANGING: ::UINT = LVN_FIRST - 0; pub const LVN_ITEMCHANGED: ::UINT = LVN_FIRST - 1; pub const LVN_INSERTITEM: ::UINT = LVN_FIRST - 2; pub const LVN_DELETEITEM: ::UINT = LVN_FIRST - 3; pub const LVN_DELETEALLITEMS: ::UINT = LVN_FIRST - 4; pub const LVN_BEGINLABELEDITA: ::UINT = LVN_FIRST - 5; pub const LVN_BEGINLABELEDITW: ::UINT = LVN_FIRST - 75; pub const LVN_ENDLABELEDITA: ::UINT = LVN_FIRST - 6; pub const LVN_ENDLABELEDITW: ::UINT = LVN_FIRST - 76; pub const LVN_COLUMNCLICK: ::UINT = LVN_FIRST - 8; pub const LVN_BEGINDRAG: ::UINT = LVN_FIRST - 9; pub const LVN_BEGINRDRAG: ::UINT = LVN_FIRST - 11; pub const LVN_ODCACHEHINT: ::UINT = LVN_FIRST - 13; pub const LVN_ODFINDITEMA: ::UINT = LVN_FIRST - 52; pub const LVN_ODFINDITEMW: ::UINT = LVN_FIRST - 79; pub const LVN_ITEMACTIVATE: ::UINT = LVN_FIRST - 14; pub const LVN_ODSTATECHANGED: ::UINT = LVN_FIRST - 15; pub const LVN_HOTTRACK: ::UINT = LVN_FIRST - 21; pub const LVN_GETDISPINFOA: ::UINT = LVN_FIRST - 50; pub const LVN_GETDISPINFOW: ::UINT = LVN_FIRST - 77; pub const LVN_SETDISPINFOA: ::UINT = LVN_FIRST - 51; pub const LVN_SETDISPINFOW: ::UINT = LVN_FIRST - 78; pub const LVIF_DI_SETITEM: ::UINT = 0x1000; pub type LV_DISPINFOA = NMLVDISPINFOA; pub type LV_DISPINFOW = NMLVDISPINFOW; STRUCT!{struct NMLVDISPINFOA { hdr: ::NMHDR, item: LVITEMA, }} pub type LPNMLVDISPINFOA = *mut NMLVDISPINFOA; STRUCT!{struct NMLVDISPINFOW { hdr: ::NMHDR, item: LVITEMW, }} pub type LPNMLVDISPINFOW = *mut NMLVDISPINFOW; pub const LVN_KEYDOWN: ::UINT = LVN_FIRST - 55; pub type LV_KEYDOWN = NMLVKEYDOWN; STRUCT!{struct NMLVKEYDOWN { hdr: ::NMHDR, wVKey: ::WORD, flags: ::UINT, }} pub type LPNMLVKEYDOWN = *mut NMLVKEYDOWN; pub const LVN_MARQUEEBEGIN: ::UINT = LVN_FIRST - 56; #[repr(C)] #[derive(Clone, Copy)] pub struct NMLVLINK { pub hdr: ::NMHDR, pub link: LITEM, pub iItem: ::c_int, pub iSubItem: ::c_int, } pub type PNMLVLINK = *mut NMLVLINK; STRUCT!{struct NMLVGETINFOTIPA { hdr: ::NMHDR, dwFlags: ::DWORD, pszText: ::LPSTR, cchTextMax: ::c_int, iItem: ::c_int, iSubItem: ::c_int, lParam: ::LPARAM, }} pub type LPNMLVGETINFOTIPA = *mut NMLVGETINFOTIPA; STRUCT!{struct NMLVGETINFOTIPW { hdr: ::NMHDR, dwFlags: ::DWORD, pszText: ::LPWSTR, cchTextMax: ::c_int, iItem: ::c_int, iSubItem: ::c_int, lParam: ::LPARAM, }} pub type LPNMLVGETINFOTIPW = *mut NMLVGETINFOTIPW; pub const LVGIT_UNFOLDED: ::DWORD = 0x0001; pub const LVN_GETINFOTIPA: ::UINT = LVN_FIRST - 57; pub const LVN_GETINFOTIPW: ::UINT = LVN_FIRST - 58; pub const LVNSCH_DEFAULT: ::LPARAM = -1; pub const LVNSCH_ERROR: ::LPARAM = -2; pub const LVNSCH_IGNORE: ::LPARAM = -3; pub const LVN_INCREMENTALSEARCHA: ::UINT = LVN_FIRST - 62; pub const LVN_INCREMENTALSEARCHW: ::UINT = LVN_FIRST - 63; pub const LVN_COLUMNDROPDOWN: ::UINT = LVN_FIRST - 64; pub const LVN_COLUMNOVERFLOWCLICK: ::UINT = LVN_FIRST - 66; STRUCT!{struct NMLVSCROLL { hdr: ::NMHDR, dx: ::c_int, dy: ::c_int, }} pub type LPNMLVSCROLL = *mut NMLVSCROLL; pub const LVN_BEGINSCROLL: ::UINT = LVN_FIRST - 80; pub const LVN_ENDSCROLL: ::UINT = LVN_FIRST - 81; pub const LVN_LINKCLICK: ::UINT = LVN_FIRST - 84; pub const EMF_CENTERED: ::DWORD = 0x00000001; #[repr(C)] #[derive(Copy)] pub struct NMLVEMPTYMARKUP { pub hdr: ::NMHDR, pub dwFlags: ::DWORD, pub szMarkup: [::WCHAR; L_MAX_URL_LENGTH], } impl Clone for NMLVEMPTYMARKUP { fn clone(&self) -> NMLVEMPTYMARKUP { *self } } pub const LVN_GETEMPTYMARKUP: ::UINT = LVN_FIRST - 87; pub const TVS_HASBUTTONS: ::DWORD = 0x0001; pub const TVS_HASLINES: ::DWORD = 0x0002; pub const TVS_LINESATROOT: ::DWORD = 0x0004; pub const TVS_EDITLABELS: ::DWORD = 0x0008; pub const TVS_DISABLEDRAGDROP: ::DWORD = 0x0010; pub const TVS_SHOWSELALWAYS: ::DWORD = 0x0020; pub const TVS_RTLREADING: ::DWORD = 0x0040; pub const TVS_NOTOOLTIPS: ::DWORD = 0x0080; pub const TVS_CHECKBOXES: ::DWORD = 0x0100; pub const TVS_TRACKSELECT: ::DWORD = 0x0200; pub const TVS_SINGLEEXPAND: ::DWORD = 0x0400; pub const TVS_INFOTIP: ::DWORD = 0x0800; pub const TVS_FULLROWSELECT: ::DWORD = 0x1000; pub const TVS_NOSCROLL: ::DWORD = 0x2000; pub const TVS_NONEVENHEIGHT: ::DWORD = 0x4000; pub const TVS_NOHSCROLL: ::DWORD = 0x8000; pub const TVS_EX_NOSINGLECOLLAPSE: ::DWORD = 0x0001; pub const TVS_EX_MULTISELECT: ::DWORD = 0x0002; pub const TVS_EX_DOUBLEBUFFER: ::DWORD = 0x0004; pub const TVS_EX_NOINDENTSTATE: ::DWORD = 0x0008; pub const TVS_EX_RICHTOOLTIP: ::DWORD = 0x0010; pub const TVS_EX_AUTOHSCROLL: ::DWORD = 0x0020; pub const TVS_EX_FADEINOUTEXPANDOS: ::DWORD = 0x0040; pub const TVS_EX_PARTIALCHECKBOXES: ::DWORD = 0x0080; pub const TVS_EX_EXCLUSIONCHECKBOXES: ::DWORD = 0x0100; pub const TVS_EX_DIMMEDCHECKBOXES: ::DWORD = 0x0200; pub const TVS_EX_DRAWIMAGEASYNC: ::DWORD = 0x0400; #[repr(C)] #[allow(missing_copy_implementations)] pub struct TREEITEM { unused: ::c_void, } pub type HTREEITEM = *mut TREEITEM; pub const TVIF_TEXT: ::UINT = 0x0001; pub const TVIF_IMAGE: ::UINT = 0x0002; pub const TVIF_PARAM: ::UINT = 0x0004; pub const TVIF_STATE: ::UINT = 0x0008; pub const TVIF_HANDLE: ::UINT = 0x0010; pub const TVIF_SELECTEDIMAGE: ::UINT = 0x0020; pub const TVIF_CHILDREN: ::UINT = 0x0040; pub const TVIF_INTEGRAL: ::UINT = 0x0080; pub const TVIF_STATEEX: ::UINT = 0x0100; pub const TVIF_EXPANDEDIMAGE: ::UINT = 0x0200; pub const TVIS_SELECTED: ::UINT = 0x0002; pub const TVIS_CUT: ::UINT = 0x0004; pub const TVIS_DROPHILITED: ::UINT = 0x0008; pub const TVIS_BOLD: ::UINT = 0x0010; pub const TVIS_EXPANDED: ::UINT = 0x0020; pub const TVIS_EXPANDEDONCE: ::UINT = 0x0040; pub const TVIS_EXPANDPARTIAL: ::UINT = 0x0080; pub const TVIS_OVERLAYMASK: ::UINT = 0x0F00; pub const TVIS_STATEIMAGEMASK: ::UINT = 0xF000; pub const TVIS_USERMASK: ::UINT = 0xF000; pub const TVIS_EX_FLAT: ::UINT = 0x0001; pub const TVIS_EX_DISABLED: ::UINT = 0x0002; pub const TVIS_EX_ALL: ::UINT = 0x0002; STRUCT!{struct NMTVSTATEIMAGECHANGING { hdr: ::NMHDR, hti: HTREEITEM, iOldStateImageIndex: ::c_int, iNewStateImageIndex: ::c_int, }} pub type LPNMTVSTATEIMAGECHANGING = *mut NMTVSTATEIMAGECHANGING; pub const I_CHILDRENCALLBACK: ::c_int = -1; pub const I_CHILDRENAUTO: ::c_int = -2; pub type LPTV_ITEMW = LPTVITEMW; pub type LPTV_ITEMA = LPTVITEMA; pub type TV_ITEMW = TVITEMW; pub type TV_ITEMA = TVITEMA; STRUCT!{struct TVITEMA { mask: ::UINT, hItem: HTREEITEM, state: ::UINT, stateMask: ::UINT, pszText: ::LPSTR, cchTextMax: ::c_int, iImage: ::c_int, iSelectedImage: ::c_int, cChildren: ::c_int, lParam: ::LPARAM, }} pub type LPTVITEMA = *mut TVITEMA; STRUCT!{struct TVITEMW { mask: ::UINT, hItem: HTREEITEM, state: ::UINT, stateMask: ::UINT, pszText: ::LPWSTR, cchTextMax: ::c_int, iImage: ::c_int, iSelectedImage: ::c_int, cChildren: ::c_int, lParam: ::LPARAM, }} pub type LPTVITEMW = *mut TVITEMW; STRUCT!{struct TVITEMEXA { mask: ::UINT, hItem: HTREEITEM, state: ::UINT, stateMask: ::UINT, pszText: ::LPSTR, cchTextMax: ::c_int, iImage: ::c_int, iSelectedImage: ::c_int, cChildren: ::c_int, lParam: ::LPARAM, iIntegral: ::c_int, uStateEx: ::UINT, hwnd: ::HWND, iExpandedImage: ::c_int, iReserved: ::c_int, }} pub type LPTVITEMEXA = *mut TVITEMEXA; STRUCT!{struct TVITEMEXW { mask: ::UINT, hItem: HTREEITEM, state: ::UINT, stateMask: ::UINT, pszText: ::LPWSTR, cchTextMax: ::c_int, iImage: ::c_int, iSelectedImage: ::c_int, cChildren: ::c_int, lParam: ::LPARAM, iIntegral: ::c_int, uStateEx: ::UINT, hwnd: ::HWND, iExpandedImage: ::c_int, iReserved: ::c_int, }} pub type LPTVITEMEXW = *mut TVITEMEXW; pub const TVI_ROOT: HTREEITEM = (0 - 0x10000) as HTREEITEM; pub const TVI_FIRST: HTREEITEM = (0 - 0x0FFFF) as HTREEITEM; pub const TVI_LAST: HTREEITEM = (0 - 0x0FFFE) as HTREEITEM; pub const TVI_SORT: HTREEITEM = (0 - 0x0FFFD) as HTREEITEM; pub type LPTV_INSERTSTRUCTA = LPTVINSERTSTRUCTA; pub type LPTV_INSERTSTRUCTW = LPTVINSERTSTRUCTW; pub type TV_INSERTSTRUCTA = TVINSERTSTRUCTA; pub type TV_INSERTSTRUCTW = TVINSERTSTRUCTW; STRUCT!{struct TVINSERTSTRUCTA { hParent: HTREEITEM, hInsertAfter: HTREEITEM, itemex: TVITEMEXA, }} UNION!(TVINSERTSTRUCTA, itemex, item, item_mut, TV_ITEMA); pub type LPTVINSERTSTRUCTA = *mut TVINSERTSTRUCTA; STRUCT!{struct TVINSERTSTRUCTW { hParent: HTREEITEM, hInsertAfter: HTREEITEM, itemex: TVITEMEXW, }} UNION!(TVINSERTSTRUCTA, itemex, item, item_mut, TV_ITEMW); pub type LPTVINSERTSTRUCTW = *mut TVINSERTSTRUCTW; pub const TVM_INSERTITEMA: ::UINT = TV_FIRST + 0; pub const TVM_INSERTITEMW: ::UINT = TV_FIRST + 50; pub const TVM_DELETEITEM: ::UINT = TV_FIRST + 1; pub const TVM_EXPAND: ::UINT = TV_FIRST + 2; pub const TVM_GETITEMRECT: ::UINT = TV_FIRST + 4; pub const TVE_COLLAPSE: ::WPARAM = 0x0001; pub const TVE_EXPAND: ::WPARAM = 0x0002; pub const TVE_TOGGLE: ::WPARAM = 0x0003; pub const TVE_EXPANDPARTIAL: ::WPARAM = 0x4000; pub const TVE_COLLAPSERESET: ::WPARAM = 0x8000; pub const TVM_GETCOUNT: ::UINT = TV_FIRST + 5; pub const TVM_GETINDENT: ::UINT = TV_FIRST + 6; pub const TVM_SETINDENT: ::UINT = TV_FIRST + 7; pub const TVM_GETIMAGELIST: ::UINT = TV_FIRST + 8; pub const TVM_SETIMAGELIST: ::UINT = TV_FIRST + 9; pub const TVM_GETNEXTITEM: ::UINT = TV_FIRST + 10; pub const TVSIL_NORMAL: ::WPARAM = 0; pub const TVSIL_STATE: ::WPARAM = 2; pub const TVGN_ROOT: ::WPARAM = 0x0000; pub const TVGN_NEXT: ::WPARAM = 0x0001; pub const TVGN_PREVIOUS: ::WPARAM = 0x0002; pub const TVGN_PARENT: ::WPARAM = 0x0003; pub const TVGN_CHILD: ::WPARAM = 0x0004; pub const TVGN_FIRSTVISIBLE: ::WPARAM = 0x0005; pub const TVGN_NEXTVISIBLE: ::WPARAM = 0x0006; pub const TVGN_PREVIOUSVISIBLE: ::WPARAM = 0x0007; pub const TVGN_DROPHILITE: ::WPARAM = 0x0008; pub const TVGN_CARET: ::WPARAM = 0x0009; pub const TVGN_LASTVISIBLE: ::WPARAM = 0x000A; pub const TVGN_NEXTSELECTED: ::WPARAM = 0x000B; pub const TVSI_NOSINGLEEXPAND: ::WPARAM = 0x8000; pub const TVM_SELECTITEM: ::UINT = TV_FIRST + 11; pub const TVM_GETITEMA: ::UINT = TV_FIRST + 12; pub const TVM_GETITEMW: ::UINT = TV_FIRST + 62; pub const TVM_SETITEMA: ::UINT = TV_FIRST + 13; pub const TVM_SETITEMW: ::UINT = TV_FIRST + 63; pub const TVM_EDITLABELA: ::UINT = TV_FIRST + 14; pub const TVM_EDITLABELW: ::UINT = TV_FIRST + 65; pub const TVM_GETEDITCONTROL: ::UINT = TV_FIRST + 15; pub const TVM_GETVISIBLECOUNT: ::UINT = TV_FIRST + 16; pub const TVM_HITTEST: ::UINT = TV_FIRST + 17; pub type LPTV_HITTESTINFO = LPTVHITTESTINFO; pub type TV_HITTESTINFO = TVHITTESTINFO; STRUCT!{struct TVHITTESTINFO { pt: ::POINT, flags: ::UINT, hItem: HTREEITEM, }} pub type LPTVHITTESTINFO = *mut TVHITTESTINFO; pub const TVHT_NOWHERE: ::UINT = 0x0001; pub const TVHT_ONITEMICON: ::UINT = 0x0002; pub const TVHT_ONITEMLABEL: ::UINT = 0x0004; pub const TVHT_ONITEM: ::UINT = TVHT_ONITEMICON | TVHT_ONITEMLABEL | TVHT_ONITEMSTATEICON; pub const TVHT_ONITEMINDENT: ::UINT = 0x0008; pub const TVHT_ONITEMBUTTON: ::UINT = 0x0010; pub const TVHT_ONITEMRIGHT: ::UINT = 0x0020; pub const TVHT_ONITEMSTATEICON: ::UINT = 0x0040; pub const TVHT_ABOVE: ::UINT = 0x0100; pub const TVHT_BELOW: ::UINT = 0x0200; pub const TVHT_TORIGHT: ::UINT = 0x0400; pub const TVHT_TOLEFT: ::UINT = 0x0800; pub const TVM_CREATEDRAGIMAGE: ::UINT = TV_FIRST + 18; pub const TVM_SORTCHILDREN: ::UINT = TV_FIRST + 19; pub const TVM_ENSUREVISIBLE: ::UINT = TV_FIRST + 20; pub const TVM_SORTCHILDRENCB: ::UINT = TV_FIRST + 21; pub const TVM_ENDEDITLABELNOW: ::UINT = TV_FIRST + 22; pub const TVM_GETISEARCHSTRINGA: ::UINT = TV_FIRST + 23; pub const TVM_GETISEARCHSTRINGW: ::UINT = TV_FIRST + 64; pub const TVM_SETTOOLTIPS: ::UINT = TV_FIRST + 24; pub const TVM_GETTOOLTIPS: ::UINT = TV_FIRST + 25; pub const TVM_SETINSERTMARK: ::UINT = TV_FIRST + 26; pub const TVM_SETUNICODEFORMAT: ::UINT = CCM_SETUNICODEFORMAT; pub const TVM_GETUNICODEFORMAT: ::UINT = CCM_GETUNICODEFORMAT; pub const TVM_SETITEMHEIGHT: ::UINT = TV_FIRST + 27; pub const TVM_GETITEMHEIGHT: ::UINT = TV_FIRST + 28; pub const TVM_SETBKCOLOR: ::UINT = TV_FIRST + 29; pub const TVM_SETTEXTCOLOR: ::UINT = TV_FIRST + 30; pub const TVM_GETBKCOLOR: ::UINT = TV_FIRST + 31; pub const TVM_GETTEXTCOLOR: ::UINT = TV_FIRST + 32; pub const TVM_SETSCROLLTIME: ::UINT = TV_FIRST + 33; pub const TVM_GETSCROLLTIME: ::UINT = TV_FIRST + 34; pub const TVM_SETINSERTMARKCOLOR: ::UINT = TV_FIRST + 37; pub const TVM_GETINSERTMARKCOLOR: ::UINT = TV_FIRST + 38; pub const TVM_SETBORDER: ::UINT = TV_FIRST + 35; pub const TVSBF_XBORDER: ::WPARAM = 0x00000001; pub const TVSBF_YBORDER: ::WPARAM = 0x00000002; pub const TVM_GETITEMSTATE: ::UINT = TV_FIRST + 39; pub const TVM_SETLINECOLOR: ::UINT = TV_FIRST + 40; pub const TVM_GETLINECOLOR: ::UINT = TV_FIRST + 41; pub const TVM_MAPACCIDTOHTREEITEM: ::UINT = TV_FIRST + 42; pub const TVM_MAPHTREEITEMTOACCID: ::UINT = TV_FIRST + 43; pub const TVM_SETEXTENDEDSTYLE: ::UINT = TV_FIRST + 44; pub const TVM_GETEXTENDEDSTYLE: ::UINT = TV_FIRST + 45; pub const TVM_SETAUTOSCROLLINFO: ::UINT = TV_FIRST + 59; pub const TVM_SETHOT: ::UINT = TV_FIRST + 58; pub const TVM_GETSELECTEDCOUNT: ::UINT = TV_FIRST + 70; pub const TVM_SHOWINFOTIP: ::UINT = TV_FIRST + 71; ENUM!{enum TVITEMPART { TVGIPR_BUTTON = 0x0001, }} STRUCT!{struct TVGETITEMPARTRECTINFO { hti: HTREEITEM, prc: *mut ::RECT, partID: TVITEMPART, }} pub const TVM_GETITEMPARTRECT: ::UINT = TV_FIRST + 72; pub type PFNTVCOMPARE = Option ::c_int>; pub type LPTV_SORTCB = LPTVSORTCB; pub type TV_SORTCB = TVSORTCB; #[repr(C)] #[derive(Copy)] pub struct TVSORTCB { pub hParent: HTREEITEM, pub lpfnCompare: PFNTVCOMPARE, pub lParam: ::LPARAM, } impl Clone for TVSORTCB { fn clone(&self) -> TVSORTCB { *self } } pub type LPTVSORTCB = *mut TVSORTCB; pub type LPNM_TREEVIEWA = LPNMTREEVIEWA; pub type LPNM_TREEVIEWW = LPNMTREEVIEWW; pub type NM_TREEVIEWA = NMTREEVIEWA; pub type NM_TREEVIEWW = NMTREEVIEWW; STRUCT!{struct NMTREEVIEWA { hdr: ::NMHDR, action: ::UINT, itemOld: TVITEMA, itemNew: TVITEMA, ptDrag: ::POINT, }} pub type LPNMTREEVIEWA = *mut NMTREEVIEWA; STRUCT!{struct NMTREEVIEWW { hdr: ::NMHDR, action: ::UINT, itemOld: TVITEMW, itemNew: TVITEMW, ptDrag: ::POINT, }} pub type LPNMTREEVIEWW = *mut NMTREEVIEWW; pub const TVN_SELCHANGINGA: ::UINT = TVN_FIRST - 1; pub const TVN_SELCHANGINGW: ::UINT = TVN_FIRST - 50; pub const TVN_SELCHANGEDA: ::UINT = TVN_FIRST - 2; pub const TVN_SELCHANGEDW: ::UINT = TVN_FIRST - 51; pub const TVN_GETDISPINFOA: ::UINT = TVN_FIRST - 3; pub const TVN_GETDISPINFOW: ::UINT = TVN_FIRST - 52; pub const TVN_SETDISPINFOA: ::UINT = TVN_FIRST - 4; pub const TVN_SETDISPINFOW: ::UINT = TVN_FIRST - 53; pub const TVC_UNKNOWN: ::LPARAM = 0x0000; pub const TVC_BYMOUSE: ::LPARAM = 0x0001; pub const TVC_BYKEYBOARD: ::LPARAM = 0x0002; pub const TVIF_DI_SETITEM: ::UINT = 0x1000; pub type TV_DISPINFOA = NMTVDISPINFOA; pub type TV_DISPINFOW = NMTVDISPINFOW; STRUCT!{struct NMTVDISPINFOA { hdr: ::NMHDR, item: TVITEMA, }} pub type LPNMTVDISPINFOA = *mut NMTVDISPINFOA; STRUCT!{struct NMTVDISPINFOW { hdr: ::NMHDR, item: TVITEMW, }} pub type LPNMTVDISPINFOW = *mut NMTVDISPINFOW; STRUCT!{struct NMTVDISPINFOEXA { hdr: ::NMHDR, item: TVITEMEXA, }} pub type LPNMTVDISPINFOEXA = *mut NMTVDISPINFOEXA; STRUCT!{struct NMTVDISPINFOEXW { hdr: ::NMHDR, item: TVITEMEXW, }} pub type LPNMTVDISPINFOEXW = *mut NMTVDISPINFOEXW; pub type TV_DISPINFOEXA = NMTVDISPINFOEXA; pub type TV_DISPINFOEXW = NMTVDISPINFOEXW; pub const TVN_ITEMEXPANDINGA: ::UINT = TVN_FIRST - 5; pub const TVN_ITEMEXPANDINGW: ::UINT = TVN_FIRST - 54; pub const TVN_ITEMEXPANDEDA: ::UINT = TVN_FIRST - 6; pub const TVN_ITEMEXPANDEDW: ::UINT = TVN_FIRST - 55; pub const TVN_BEGINDRAGA: ::UINT = TVN_FIRST - 7; pub const TVN_BEGINDRAGW: ::UINT = TVN_FIRST - 56; pub const TVN_BEGINRDRAGA: ::UINT = TVN_FIRST - 8; pub const TVN_BEGINRDRAGW: ::UINT = TVN_FIRST - 57; pub const TVN_DELETEITEMA: ::UINT = TVN_FIRST - 9; pub const TVN_DELETEITEMW: ::UINT = TVN_FIRST - 58; pub const TVN_BEGINLABELEDITA: ::UINT = TVN_FIRST - 10; pub const TVN_BEGINLABELEDITW: ::UINT = TVN_FIRST - 59; pub const TVN_ENDLABELEDITA: ::UINT = TVN_FIRST - 11; pub const TVN_ENDLABELEDITW: ::UINT = TVN_FIRST - 60; pub const TVN_KEYDOWN: ::UINT = TVN_FIRST - 12; pub const TVN_GETINFOTIPA: ::UINT = TVN_FIRST - 13; pub const TVN_GETINFOTIPW: ::UINT = TVN_FIRST - 14; pub const TVN_SINGLEEXPAND: ::UINT = TVN_FIRST - 15; pub const TVN_ITEMCHANGINGA: ::UINT = TVN_FIRST - 16; pub const TVN_ITEMCHANGINGW: ::UINT = TVN_FIRST - 17; pub const TVN_ITEMCHANGEDA: ::UINT = TVN_FIRST - 18; pub const TVN_ITEMCHANGEDW: ::UINT = TVN_FIRST - 19; pub const TVN_ASYNCDRAW: ::UINT = TVN_FIRST - 20; pub const TVNRET_DEFAULT: ::LRESULT = 0; pub const TVNRET_SKIPOLD: ::LRESULT = 1; pub const TVNRET_SKIPNEW: ::LRESULT = 2; pub type TV_KEYDOWN = NMTVKEYDOWN; STRUCT!{struct NMTVKEYDOWN { hdr: ::NMHDR, wVKey: ::WORD, flags: ::UINT, }} pub type LPNMTVKEYDOWN = *mut NMTVKEYDOWN; STRUCT!{struct NMTVCUSTOMDRAW { nmcd: NMCUSTOMDRAW, clrText: ::COLORREF, clrTextBk: ::COLORREF, iLevel: ::c_int, }} pub type LPNMTVCUSTOMDRAW = *mut NMTVCUSTOMDRAW; STRUCT!{struct NMTVGETINFOTIPA { hdr: ::NMHDR, pszText: ::LPSTR, cchTextMax: ::c_int, hItem: HTREEITEM, lParam: ::LPARAM, }} pub type LPNMTVGETINFOTIPA = *mut NMTVGETINFOTIPA; STRUCT!{struct NMTVGETINFOTIPW { hdr: ::NMHDR, pszText: ::LPWSTR, cchTextMax: ::c_int, hItem: HTREEITEM, lParam: ::LPARAM, }} pub type LPNMTVGETINFOTIPW = *mut NMTVGETINFOTIPW; pub const TVCDRF_NOIMAGES: ::LRESULT = 0x00010000; STRUCT!{struct NMTVITEMCHANGE { hdr: ::NMHDR, uChanged: ::UINT, hItem: HTREEITEM, uStateNew: ::UINT, uStateOld: ::UINT, lParam: ::LPARAM, }} STRUCT!{struct NMTVASYNCDRAW { hdr: ::NMHDR, pimldp: *mut IMAGELISTDRAWPARAMS, hr: ::HRESULT, hItem: HTREEITEM, lParam: ::LPARAM, dwRetFlags: ::DWORD, iRetImageIndex: ::c_int, }} pub const CBEIF_TEXT: ::UINT = 0x00000001; pub const CBEIF_IMAGE: ::UINT = 0x00000002; pub const CBEIF_SELECTEDIMAGE: ::UINT = 0x00000004; pub const CBEIF_OVERLAY: ::UINT = 0x00000008; pub const CBEIF_INDENT: ::UINT = 0x00000010; pub const CBEIF_LPARAM: ::UINT = 0x00000020; pub const CBEIF_DI_SETITEM: ::UINT = 0x10000000; STRUCT!{struct COMBOBOXEXITEMA { mask: ::UINT, iItem: ::INT_PTR, pszText: ::LPSTR, cchTextMax: ::c_int, iImage: ::c_int, iSelectedImage: ::c_int, iOverlay: ::c_int, iIndent: ::c_int, lParam: ::LPARAM, }} pub type PCOMBOBOXEXITEMA = *mut COMBOBOXEXITEMA; pub type PCCOMBOBOXEXITEMA = *const COMBOBOXEXITEMA; STRUCT!{struct COMBOBOXEXITEMW { mask: ::UINT, iItem: ::INT_PTR, pszText: ::LPWSTR, cchTextMax: ::c_int, iImage: ::c_int, iSelectedImage: ::c_int, iOverlay: ::c_int, iIndent: ::c_int, lParam: ::LPARAM, }} pub type PCOMBOBOXEXITEMW = *mut COMBOBOXEXITEMW; pub type PCCOMBOBOXEXITEMW = *const COMBOBOXEXITEMW; pub const CBEM_INSERTITEMA: ::UINT = ::WM_USER + 1; pub const CBEM_SETIMAGELIST: ::UINT = ::WM_USER + 2; pub const CBEM_GETIMAGELIST: ::UINT = ::WM_USER + 3; pub const CBEM_GETITEMA: ::UINT = ::WM_USER + 4; pub const CBEM_SETITEMA: ::UINT = ::WM_USER + 5; pub const CBEM_DELETEITEM: ::UINT = ::CB_DELETESTRING; pub const CBEM_GETCOMBOCONTROL: ::UINT = ::WM_USER + 6; pub const CBEM_GETEDITCONTROL: ::UINT = ::WM_USER + 7; pub const CBEM_SETEXSTYLE: ::UINT = ::WM_USER + 8; pub const CBEM_SETEXTENDEDSTYLE: ::UINT = ::WM_USER + 14; pub const CBEM_GETEXSTYLE: ::UINT = ::WM_USER + 9; pub const CBEM_GETEXTENDEDSTYLE: ::UINT = ::WM_USER + 9; pub const CBEM_SETUNICODEFORMAT: ::UINT = CCM_SETUNICODEFORMAT; pub const CBEM_GETUNICODEFORMAT: ::UINT = CCM_GETUNICODEFORMAT; pub const CBEM_HASEDITCHANGED: ::UINT = ::WM_USER + 10; pub const CBEM_INSERTITEMW: ::UINT = ::WM_USER + 11; pub const CBEM_SETITEMW: ::UINT = ::WM_USER + 12; pub const CBEM_GETITEMW: ::UINT = ::WM_USER + 13; pub const CBEM_SETWINDOWTHEME: ::UINT = CCM_SETWINDOWTHEME; pub const CBES_EX_NOEDITIMAGE: ::DWORD = 0x00000001; pub const CBES_EX_NOEDITIMAGEINDENT: ::DWORD = 0x00000002; pub const CBES_EX_PATHWORDBREAKPROC: ::DWORD = 0x00000004; pub const CBES_EX_NOSIZELIMIT: ::DWORD = 0x00000008; pub const CBES_EX_CASESENSITIVE: ::DWORD = 0x00000010; pub const CBES_EX_TEXTENDELLIPSIS: ::DWORD = 0x00000020; STRUCT!{struct NMCOMBOBOXEXA { hdr: ::NMHDR, ceItem: COMBOBOXEXITEMA, }} pub type PNMCOMBOBOXEXA = *mut NMCOMBOBOXEXA; STRUCT!{struct NMCOMBOBOXEXW { hdr: ::NMHDR, ceItem: COMBOBOXEXITEMW, }} pub type PNMCOMBOBOXEXW = *mut NMCOMBOBOXEXW; pub const CBEN_GETDISPINFOA: ::UINT = CBEN_FIRST - 0; pub const CBEN_INSERTITEM: ::UINT = CBEN_FIRST - 1; pub const CBEN_DELETEITEM: ::UINT = CBEN_FIRST - 2; pub const CBEN_BEGINEDIT: ::UINT = CBEN_FIRST - 4; pub const CBEN_ENDEDITA: ::UINT = CBEN_FIRST - 5; pub const CBEN_ENDEDITW: ::UINT = CBEN_FIRST - 6; pub const CBEN_GETDISPINFOW: ::UINT = CBEN_FIRST - 7; pub const CBEN_DRAGBEGINA: ::UINT = CBEN_FIRST - 8; pub const CBEN_DRAGBEGINW: ::UINT = CBEN_FIRST - 9; pub const CBENF_KILLFOCUS: ::c_int = 1; pub const CBENF_RETURN: ::c_int = 2; pub const CBENF_ESCAPE: ::c_int = 3; pub const CBENF_DROPDOWN: ::c_int = 4; pub const CBEMAXSTRLEN: usize = 260; #[repr(C)] #[derive(Copy)] pub struct NMCBEDRAGBEGINW { pub hdr: ::NMHDR, pub iItemid: ::c_int, pub szText: [::WCHAR; CBEMAXSTRLEN], } impl Clone for NMCBEDRAGBEGINW { fn clone(&self) -> NMCBEDRAGBEGINW { *self } } pub type PNMCBEDRAGBEGINW = *mut NMCBEDRAGBEGINW; pub type LPNMCBEDRAGBEGINW = *mut NMCBEDRAGBEGINW; #[repr(C)] #[derive(Copy)] pub struct NMCBEDRAGBEGINA { pub hdr: ::NMHDR, pub iItemid: ::c_int, pub szText: [::c_char; CBEMAXSTRLEN], } impl Clone for NMCBEDRAGBEGINA { fn clone(&self) -> NMCBEDRAGBEGINA { *self } } pub type PNMCBEDRAGBEGINA = *mut NMCBEDRAGBEGINA; pub type LPNMCBEDRAGBEGINA = *mut NMCBEDRAGBEGINA; #[repr(C)] #[derive(Copy)] pub struct NMCBEENDEDITW { pub hdr: ::NMHDR, pub fChanged: ::BOOL, pub iNewSelection: ::c_int, pub szText: [::WCHAR; CBEMAXSTRLEN], pub iWhy: ::c_int, } impl Clone for NMCBEENDEDITW { fn clone(&self) -> NMCBEENDEDITW { *self } } pub type PNMCBEENDEDITW = *mut NMCBEENDEDITW; pub type LPNMCBEENDEDITW = *mut NMCBEENDEDITW; #[repr(C)] #[derive(Copy)] pub struct NMCBEENDEDITA { pub hdr: ::NMHDR, pub fChanged: ::BOOL, pub iNewSelection: ::c_int, pub szText: [::c_char; CBEMAXSTRLEN], pub iWhy: ::c_int, } impl Clone for NMCBEENDEDITA { fn clone(&self) -> NMCBEENDEDITA { *self } } pub type PNMCBEENDEDITA = *mut NMCBEENDEDITA; pub type LPNMCBEENDEDITA = *mut NMCBEENDEDITA; pub const TCS_SCROLLOPPOSITE: ::DWORD = 0x0001; pub const TCS_BOTTOM: ::DWORD = 0x0002; pub const TCS_RIGHT: ::DWORD = 0x0002; pub const TCS_MULTISELECT: ::DWORD = 0x0004; pub const TCS_FLATBUTTONS: ::DWORD = 0x0008; pub const TCS_FORCEICONLEFT: ::DWORD = 0x0010; pub const TCS_FORCELABELLEFT: ::DWORD = 0x0020; pub const TCS_HOTTRACK: ::DWORD = 0x0040; pub const TCS_VERTICAL: ::DWORD = 0x0080; pub const TCS_TABS: ::DWORD = 0x0000; pub const TCS_BUTTONS: ::DWORD = 0x0100; pub const TCS_SINGLELINE: ::DWORD = 0x0000; pub const TCS_MULTILINE: ::DWORD = 0x0200; pub const TCS_RIGHTJUSTIFY: ::DWORD = 0x0000; pub const TCS_FIXEDWIDTH: ::DWORD = 0x0400; pub const TCS_RAGGEDRIGHT: ::DWORD = 0x0800; pub const TCS_FOCUSONBUTTONDOWN: ::DWORD = 0x1000; pub const TCS_OWNERDRAWFIXED: ::DWORD = 0x2000; pub const TCS_TOOLTIPS: ::DWORD = 0x4000; pub const TCS_FOCUSNEVER: ::DWORD = 0x8000; pub const TCS_EX_FLATSEPARATORS: ::DWORD = 0x00000001; pub const TCS_EX_REGISTERDROP: ::DWORD = 0x00000002; pub const TCM_GETIMAGELIST: ::UINT = TCM_FIRST + 2; pub const TCM_SETIMAGELIST: ::UINT = TCM_FIRST + 3; pub const TCM_GETITEMCOUNT: ::UINT = TCM_FIRST + 4; pub const TCIF_TEXT: ::UINT = 0x0001; pub const TCIF_IMAGE: ::UINT = 0x0002; pub const TCIF_RTLREADING: ::UINT = 0x0004; pub const TCIF_PARAM: ::UINT = 0x0008; pub const TCIF_STATE: ::UINT = 0x0010; pub const TCIS_BUTTONPRESSED: ::DWORD = 0x0001; pub const TCIS_HIGHLIGHTED: ::DWORD = 0x0002; pub type TC_ITEMHEADERA = TCITEMHEADERA; pub type TC_ITEMHEADERW = TCITEMHEADERW; STRUCT!{struct TCITEMHEADERA { mask: ::UINT, lpReserved1: ::UINT, lpReserved2: ::UINT, pszText: ::LPSTR, cchTextMax: ::c_int, iImage: ::c_int, }} pub type LPTCITEMHEADERA = *mut TCITEMHEADERA; STRUCT!{struct TCITEMHEADERW { mask: ::UINT, lpReserved1: ::UINT, lpReserved2: ::UINT, pszText: ::LPWSTR, cchTextMax: ::c_int, iImage: ::c_int, }} pub type LPTCITEMHEADERW = *mut TCITEMHEADERW; pub type TC_ITEMA = TCITEMA; pub type TC_ITEMW = TCITEMW; STRUCT!{struct TCITEMA { mask: ::UINT, dwState: ::DWORD, dwStateMask: ::DWORD, pszText: ::LPSTR, cchTextMax: ::c_int, iImage: ::c_int, lParam: ::LPARAM, }} pub type LPTCITEMA = *mut TCITEMA; STRUCT!{struct TCITEMW { mask: ::UINT, dwState: ::DWORD, dwStateMask: ::DWORD, pszText: ::LPWSTR, cchTextMax: ::c_int, iImage: ::c_int, lParam: ::LPARAM, }} pub type LPTCITEMW = *mut TCITEMW; pub const TCM_GETITEMA: ::UINT = TCM_FIRST + 5; pub const TCM_GETITEMW: ::UINT = TCM_FIRST + 60; pub const TCM_SETITEMA: ::UINT = TCM_FIRST + 6; pub const TCM_SETITEMW: ::UINT = TCM_FIRST + 61; pub const TCM_INSERTITEMA: ::UINT = TCM_FIRST + 7; pub const TCM_INSERTITEMW: ::UINT = TCM_FIRST + 62; pub const TCM_DELETEITEM: ::UINT = TCM_FIRST + 8; pub const TCM_DELETEALLITEMS: ::UINT = TCM_FIRST + 9; pub const TCM_GETITEMRECT: ::UINT = TCM_FIRST + 10; pub const TCM_GETCURSEL: ::UINT = TCM_FIRST + 11; pub const TCM_SETCURSEL: ::UINT = TCM_FIRST + 12; pub const TCHT_NOWHERE: ::UINT = 0x0001; pub const TCHT_ONITEMICON: ::UINT = 0x0002; pub const TCHT_ONITEMLABEL: ::UINT = 0x0004; pub const TCHT_ONITEM: ::UINT = TCHT_ONITEMICON | TCHT_ONITEMLABEL; pub type LPTC_HITTESTINFO = LPTCHITTESTINFO; pub type TC_HITTESTINFO = TCHITTESTINFO; STRUCT!{struct TCHITTESTINFO { pt: ::POINT, flags: ::UINT, }} pub type LPTCHITTESTINFO = *mut TCHITTESTINFO; pub const TCM_HITTEST: ::UINT = TCM_FIRST + 13; pub const TCM_SETITEMEXTRA: ::UINT = TCM_FIRST + 14; pub const TCM_ADJUSTRECT: ::UINT = TCM_FIRST + 40; pub const TCM_SETITEMSIZE: ::UINT = TCM_FIRST + 41; pub const TCM_REMOVEIMAGE: ::UINT = TCM_FIRST + 42; pub const TCM_SETPADDING: ::UINT = TCM_FIRST + 43; pub const TCM_GETROWCOUNT: ::UINT = TCM_FIRST + 44; pub const TCM_GETTOOLTIPS: ::UINT = TCM_FIRST + 45; pub const TCM_SETTOOLTIPS: ::UINT = TCM_FIRST + 46; pub const TCM_GETCURFOCUS: ::UINT = TCM_FIRST + 47; pub const TCM_SETCURFOCUS: ::UINT = TCM_FIRST + 48; pub const TCM_SETMINTABWIDTH: ::UINT = TCM_FIRST + 49; pub const TCM_DESELECTALL: ::UINT = TCM_FIRST + 50; pub const TCM_HIGHLIGHTITEM: ::UINT = TCM_FIRST + 51; pub const TCM_SETEXTENDEDSTYLE: ::UINT = TCM_FIRST + 52; pub const TCM_GETEXTENDEDSTYLE: ::UINT = TCM_FIRST + 53; pub const TCM_SETUNICODEFORMAT: ::UINT = CCM_SETUNICODEFORMAT; pub const TCM_GETUNICODEFORMAT: ::UINT = CCM_GETUNICODEFORMAT; pub const TCN_KEYDOWN: ::UINT = TCN_FIRST - 0; pub type TC_KEYDOWN = NMTCKEYDOWN; STRUCT!{struct NMTCKEYDOWN { hdr: ::NMHDR, wVKey: ::WORD, flags: ::UINT, }} pub const TCN_SELCHANGE: ::UINT = TCN_FIRST - 1; pub const TCN_SELCHANGING: ::UINT = TCN_FIRST - 2; pub const TCN_GETOBJECT: ::UINT = TCN_FIRST - 3; pub const TCN_FOCUSCHANGE: ::UINT = TCN_FIRST - 4; pub const ACS_CENTER: ::DWORD = 0x0001; pub const ACS_TRANSPARENT: ::DWORD = 0x0002; pub const ACS_AUTOPLAY: ::DWORD = 0x0004; pub const ACS_TIMER: ::DWORD = 0x0008; pub const ACM_OPENA: ::UINT = ::WM_USER + 100; pub const ACM_OPENW: ::UINT = ::WM_USER + 103; pub const ACM_PLAY: ::UINT = ::WM_USER + 101; pub const ACM_STOP: ::UINT = ::WM_USER + 102; pub const ACM_ISPLAYING: ::UINT = ::WM_USER + 104; pub const ACN_START: ::WPARAM = 1; pub const ACN_STOP: ::WPARAM = 2; pub type MONTHDAYSTATE = ::DWORD; pub type LPMONTHDAYSTATE = *mut ::DWORD; pub const MCM_FIRST: ::UINT = 0x1000; pub const MCM_GETCURSEL: ::UINT = MCM_FIRST + 1; pub const MCM_SETCURSEL: ::UINT = MCM_FIRST + 2; pub const MCM_GETMAXSELCOUNT: ::UINT = MCM_FIRST + 3; pub const MCM_SETMAXSELCOUNT: ::UINT = MCM_FIRST + 4; pub const MCM_GETSELRANGE: ::UINT = MCM_FIRST + 5; pub const MCM_SETSELRANGE: ::UINT = MCM_FIRST + 6; pub const MCM_GETMONTHRANGE: ::UINT = MCM_FIRST + 7; pub const MCM_SETDAYSTATE: ::UINT = MCM_FIRST + 8; pub const MCM_GETMINREQRECT: ::UINT = MCM_FIRST + 9; pub const MCM_SETCOLOR: ::UINT = MCM_FIRST + 10; pub const MCM_GETCOLOR: ::UINT = MCM_FIRST + 11; pub const MCM_SETTODAY: ::UINT = MCM_FIRST + 12; pub const MCM_GETTODAY: ::UINT = MCM_FIRST + 13; pub const MCM_HITTEST: ::UINT = MCM_FIRST + 14; pub const MCSC_BACKGROUND: ::WPARAM = 0; pub const MCSC_TEXT: ::WPARAM = 1; pub const MCSC_TITLEBK: ::WPARAM = 2; pub const MCSC_TITLETEXT: ::WPARAM = 3; pub const MCSC_MONTHBK: ::WPARAM = 4; pub const MCSC_TRAILINGTEXT: ::WPARAM = 5; STRUCT!{struct MCHITTESTINFO { cbSize: ::UINT, pt: ::POINT, uHit: ::UINT, st: ::SYSTEMTIME, rc: ::RECT, iOffset: ::c_int, iRow: ::c_int, iCol: ::c_int, }} pub type PMCHITTESTINFO = *mut MCHITTESTINFO; pub const MCHT_TITLE: ::UINT = 0x00010000; pub const MCHT_CALENDAR: ::UINT = 0x00020000; pub const MCHT_TODAYLINK: ::UINT = 0x00030000; pub const MCHT_CALENDARCONTROL: ::UINT = 0x00100000; pub const MCHT_NEXT: ::UINT = 0x01000000; pub const MCHT_PREV: ::UINT = 0x02000000; pub const MCHT_NOWHERE: ::UINT = 0x00000000; pub const MCHT_TITLEBK: ::UINT = MCHT_TITLE; pub const MCHT_TITLEMONTH: ::UINT = MCHT_TITLE | 0x0001; pub const MCHT_TITLEYEAR: ::UINT = MCHT_TITLE | 0x0002; pub const MCHT_TITLEBTNNEXT: ::UINT = MCHT_TITLE | MCHT_NEXT | 0x0003; pub const MCHT_TITLEBTNPREV: ::UINT = MCHT_TITLE | MCHT_PREV | 0x0003; pub const MCHT_CALENDARBK: ::UINT = MCHT_CALENDAR; pub const MCHT_CALENDARDATE: ::UINT = MCHT_CALENDAR | 0x0001; pub const MCHT_CALENDARDATENEXT: ::UINT = MCHT_CALENDARDATE | MCHT_NEXT; pub const MCHT_CALENDARDATEPREV: ::UINT = MCHT_CALENDARDATE | MCHT_PREV; pub const MCHT_CALENDARDAY: ::UINT = MCHT_CALENDAR | 0x0002; pub const MCHT_CALENDARWEEKNUM: ::UINT = MCHT_CALENDAR | 0x0003; pub const MCHT_CALENDARDATEMIN: ::UINT = MCHT_CALENDAR | 0x0004; pub const MCHT_CALENDARDATEMAX: ::UINT = MCHT_CALENDAR | 0x0005; pub const MCM_SETFIRSTDAYOFWEEK: ::UINT = MCM_FIRST + 15; pub const MCM_GETFIRSTDAYOFWEEK: ::UINT = MCM_FIRST + 16; pub const MCM_GETRANGE: ::UINT = MCM_FIRST + 17; pub const MCM_SETRANGE: ::UINT = MCM_FIRST + 18; pub const MCM_GETMONTHDELTA: ::UINT = MCM_FIRST + 19; pub const MCM_SETMONTHDELTA: ::UINT = MCM_FIRST + 20; pub const MCM_GETMAXTODAYWIDTH: ::UINT = MCM_FIRST + 21; pub const MCM_SETUNICODEFORMAT: ::UINT = CCM_SETUNICODEFORMAT; pub const MCM_GETUNICODEFORMAT: ::UINT = CCM_GETUNICODEFORMAT; pub const MCM_GETCURRENTVIEW: ::UINT = MCM_FIRST + 22; pub const MCM_GETCALENDARCOUNT: ::UINT = MCM_FIRST + 23; pub const MCMV_MONTH: ::DWORD = 0; pub const MCMV_YEAR: ::DWORD = 1; pub const MCMV_DECADE: ::DWORD = 2; pub const MCMV_CENTURY: ::DWORD = 3; pub const MCMV_MAX: ::DWORD = MCMV_CENTURY; pub const MCGIP_CALENDARCONTROL: ::DWORD = 0; pub const MCGIP_NEXT: ::DWORD = 1; pub const MCGIP_PREV: ::DWORD = 2; pub const MCGIP_FOOTER: ::DWORD = 3; pub const MCGIP_CALENDAR: ::DWORD = 4; pub const MCGIP_CALENDARHEADER: ::DWORD = 5; pub const MCGIP_CALENDARBODY: ::DWORD = 6; pub const MCGIP_CALENDARROW: ::DWORD = 7; pub const MCGIP_CALENDARCELL: ::DWORD = 8; pub const MCGIF_DATE: ::DWORD = 0x00000001; pub const MCGIF_RECT: ::DWORD = 0x00000002; pub const MCGIF_NAME: ::DWORD = 0x00000004; STRUCT!{struct MCGRIDINFO { cbSize: ::UINT, dwPart: ::DWORD, dwFlags: ::DWORD, iCalendar: ::c_int, iRow: ::c_int, iCol: ::c_int, bSelected: ::BOOL, stStart: ::SYSTEMTIME, stEnd: ::SYSTEMTIME, rc: ::RECT, pszName: ::PWSTR, cchName: ::size_t, }} pub type PMCGRIDINFO = *mut MCGRIDINFO; pub const MCM_GETCALENDARGRIDINFO: ::UINT = MCM_FIRST + 24; pub const MCM_GETCALID: ::UINT = MCM_FIRST + 27; pub const MCM_SETCALID: ::UINT = MCM_FIRST + 28; pub const MCM_SIZERECTTOMIN: ::UINT = MCM_FIRST + 29; pub const MCM_SETCALENDARBORDER: ::UINT = MCM_FIRST + 30; pub const MCM_GETCALENDARBORDER: ::UINT = MCM_FIRST + 31; pub const MCM_SETCURRENTVIEW: ::UINT = MCM_FIRST + 32; STRUCT!{struct NMSELCHANGE { nmhdr: ::NMHDR, stSelStart: ::SYSTEMTIME, stSelEnd: ::SYSTEMTIME, }} pub type LPNMSELCHANGE = *mut NMSELCHANGE; pub const MCN_SELCHANGE: ::UINT = MCN_FIRST - 3; STRUCT!{struct NMDAYSTATE { nmhdr: ::NMHDR, stStart: ::SYSTEMTIME, cDayState: ::c_int, prgDayState: LPMONTHDAYSTATE, }} pub type LPNMDAYSTATE = *mut NMDAYSTATE; pub const MCN_GETDAYSTATE: ::UINT = MCN_FIRST - 1; pub type NMSELECT = NMSELCHANGE; pub type LPNMSELECT = *mut NMSELCHANGE; pub const MCN_SELECT: ::UINT = MCN_FIRST; STRUCT!{struct NMVIEWCHANGE { nmhdr: ::NMHDR, dwOldView: ::DWORD, dwNewView: ::DWORD, }} pub type LPNMVIEWCHANGE = *mut NMVIEWCHANGE; pub const MCN_VIEWCHANGE: ::UINT = MCN_FIRST - 4; pub const MCS_DAYSTATE: ::DWORD = 0x0001; pub const MCS_MULTISELECT: ::DWORD = 0x0002; pub const MCS_WEEKNUMBERS: ::DWORD = 0x0004; pub const MCS_NOTODAYCIRCLE: ::DWORD = 0x0008; pub const MCS_NOTODAY: ::DWORD = 0x0010; pub const MCS_NOTRAILINGDATES: ::DWORD = 0x0040; pub const MCS_SHORTDAYSOFWEEK: ::DWORD = 0x0080; pub const MCS_NOSELCHANGEONNAV: ::DWORD = 0x0100; pub const GMR_VISIBLE: ::DWORD = 0; pub const GMR_DAYSTATE: ::DWORD = 1; STRUCT!{struct DATETIMEPICKERINFO { cbSize: ::UINT, rcCheck: ::RECT, stateCheck: ::DWORD, rcButton: ::RECT, stateButton: ::DWORD, hwndEdit: ::HWND, hwndUD: ::HWND, hwndDropDown: ::HWND, }} pub type LPDATETIMEPICKERINFO = *mut DATETIMEPICKERINFO; pub const DTM_FIRST: ::UINT = 0x1000; pub const DTM_GETSYSTEMTIME: ::UINT = DTM_FIRST + 1; pub const DTM_SETSYSTEMTIME: ::UINT = DTM_FIRST + 2; pub const DTM_GETRANGE: ::UINT = DTM_FIRST + 3; pub const DTM_SETRANGE: ::UINT = DTM_FIRST + 4; pub const DTM_SETFORMATA: ::UINT = DTM_FIRST + 5; pub const DTM_SETFORMATW: ::UINT = DTM_FIRST + 50; pub const DTM_SETMCCOLOR: ::UINT = DTM_FIRST + 6; pub const DTM_GETMCCOLOR: ::UINT = DTM_FIRST + 7; pub const DTM_GETMONTHCAL: ::UINT = DTM_FIRST + 8; pub const DTM_SETMCFONT: ::UINT = DTM_FIRST + 9; pub const DTM_GETMCFONT: ::UINT = DTM_FIRST + 10; pub const DTM_SETMCSTYLE: ::UINT = DTM_FIRST + 11; pub const DTM_GETMCSTYLE: ::UINT = DTM_FIRST + 12; pub const DTM_CLOSEMONTHCAL: ::UINT = DTM_FIRST + 13; pub const DTM_GETDATETIMEPICKERINFO: ::UINT = DTM_FIRST + 14; pub const DTM_GETIDEALSIZE: ::UINT = DTM_FIRST + 15; pub const DTS_UPDOWN: ::DWORD = 0x0001; pub const DTS_SHOWNONE: ::DWORD = 0x0002; pub const DTS_SHORTDATEFORMAT: ::DWORD = 0x0000; pub const DTS_LONGDATEFORMAT: ::DWORD = 0x0004; pub const DTS_SHORTDATECENTURYFORMAT: ::DWORD = 0x000C; pub const DTS_TIMEFORMAT: ::DWORD = 0x0009; pub const DTS_APPCANPARSE: ::DWORD = 0x0010; pub const DTS_RIGHTALIGN: ::DWORD = 0x0020; pub const DTN_DATETIMECHANGE: ::UINT = DTN_FIRST2 - 6; STRUCT!{struct NMDATETIMECHANGE { nmhdr: ::NMHDR, dwFlags: ::DWORD, st: ::SYSTEMTIME, }} pub type LPNMDATETIMECHANGE = *mut NMDATETIMECHANGE; pub const DTN_USERSTRINGA: ::UINT = DTN_FIRST2 - 5; pub const DTN_USERSTRINGW: ::UINT = DTN_FIRST - 5; STRUCT!{struct NMDATETIMESTRINGA { nmhdr: ::NMHDR, pszUserString: ::LPCSTR, st: ::SYSTEMTIME, dwFlags: ::DWORD, }} pub type LPNMDATETIMESTRINGA = *mut NMDATETIMESTRINGA; STRUCT!{struct NMDATETIMESTRINGW { nmhdr: ::NMHDR, pszUserString: ::LPCWSTR, st: ::SYSTEMTIME, dwFlags: ::DWORD, }} pub type LPNMDATETIMESTRINGW = *mut NMDATETIMESTRINGW; pub const DTN_WMKEYDOWNA: ::UINT = DTN_FIRST2 - 4; pub const DTN_WMKEYDOWNW: ::UINT = DTN_FIRST - 4; STRUCT!{struct NMDATETIMEWMKEYDOWNA { nmhdr: ::NMHDR, nVirtKey: ::c_int, pszFormat: ::LPCSTR, st: ::SYSTEMTIME, }} pub type LPNMDATETIMEWMKEYDOWNA = *mut NMDATETIMEWMKEYDOWNA; STRUCT!{struct NMDATETIMEWMKEYDOWNW { nmhdr: ::NMHDR, nVirtKey: ::c_int, pszFormat: ::LPCWSTR, st: ::SYSTEMTIME, }} pub type LPNMDATETIMEWMKEYDOWNW = *mut NMDATETIMEWMKEYDOWNW; pub const DTN_FORMATA: ::UINT = DTN_FIRST2 - 3; pub const DTN_FORMATW: ::UINT = DTN_FIRST - 3; #[repr(C)] #[derive(Copy)] pub struct NMDATETIMEFORMATA { pub nmhdr: ::NMHDR, pub pszFormat: ::LPCSTR, pub st: ::SYSTEMTIME, pub pszDisplay: ::LPCSTR, pub szDisplay: [::CHAR; 64], } impl Clone for NMDATETIMEFORMATA { fn clone(&self) -> NMDATETIMEFORMATA { *self } } pub type LPNMDATETIMEFORMATA = *mut NMDATETIMEFORMATA; #[repr(C)] #[derive(Copy)] pub struct NMDATETIMEFORMATW { pub nmhdr: ::NMHDR, pub pszFormat: ::LPCWSTR, pub st: ::SYSTEMTIME, pub pszDisplay: ::LPCWSTR, pub szDisplay: [::WCHAR; 64], } impl Clone for NMDATETIMEFORMATW { fn clone(&self) -> NMDATETIMEFORMATW { *self } } pub type LPNMDATETIMEFORMATW = *mut NMDATETIMEFORMATW; pub const DTN_FORMATQUERYA: ::UINT = DTN_FIRST2 - 2; pub const DTN_FORMATQUERYW: ::UINT = DTN_FIRST - 2; STRUCT!{struct NMDATETIMEFORMATQUERYA { nmhdr: ::NMHDR, pszFormat: ::LPCSTR, szMax: ::SIZE, }} pub type LPNMDATETIMEFORMATQUERYA = *mut NMDATETIMEFORMATQUERYA; STRUCT!{struct NMDATETIMEFORMATQUERYW { nmhdr: ::NMHDR, pszFormat: ::LPCWSTR, szMax: ::SIZE, }} pub type LPNMDATETIMEFORMATQUERYW = *mut NMDATETIMEFORMATQUERYW; pub const DTN_DROPDOWN: ::UINT = DTN_FIRST2 - 1; pub const DTN_CLOSEUP: ::UINT = DTN_FIRST2; pub const GDTR_MIN: ::WPARAM = 0x0001; pub const GDTR_MAX: ::WPARAM = 0x0002; pub const GDT_ERROR: ::LRESULT = -1; pub const GDT_VALID: ::LRESULT = 0; pub const GDT_NONE: ::LRESULT = 1; pub const IPM_CLEARADDRESS: ::UINT = ::WM_USER + 100; pub const IPM_SETADDRESS: ::UINT = ::WM_USER + 101; pub const IPM_GETADDRESS: ::UINT = ::WM_USER + 102; pub const IPM_SETRANGE: ::UINT = ::WM_USER + 103; pub const IPM_SETFOCUS: ::UINT = ::WM_USER + 104; pub const IPM_ISBLANK: ::UINT = ::WM_USER + 105; pub const IPN_FIELDCHANGED: ::UINT = IPN_FIRST - 0; STRUCT!{struct NMIPADDRESS { hdr: ::NMHDR, iField: ::c_int, iValue: ::c_int, }} pub type LPNMIPADDRESS = *mut NMIPADDRESS; #[inline] #[allow(dead_code)] pub fn MAKEIPRANGE(low: ::BYTE, high: ::BYTE) -> ::LPARAM { (high << 8 + low) as ::LPARAM } #[inline] #[allow(dead_code)] pub fn MAKEIPADDRESS(b1: ::DWORD, b2: ::DWORD, b3: ::DWORD, b4: ::DWORD) -> ::LPARAM { ((b1 << 24) + (b2 << 16) + (b3 << 8) + b4) as ::LPARAM } pub const PGS_VERT: ::DWORD = 0x00000000; pub const PGS_HORZ: ::DWORD = 0x00000001; pub const PGS_AUTOSCROLL: ::DWORD = 0x00000002; pub const PGS_DRAGNDROP: ::DWORD = 0x00000004; pub const PGF_INVISIBLE: ::DWORD = 0; pub const PGF_NORMAL: ::DWORD = 1; pub const PGF_GRAYED: ::DWORD = 2; pub const PGF_DEPRESSED: ::DWORD = 4; pub const PGF_HOT: ::DWORD = 8; pub const PGB_TOPORLEFT: ::c_int = 0; pub const PGB_BOTTOMORRIGHT: ::c_int = 1; pub const PGM_SETCHILD: ::UINT = PGM_FIRST + 1; pub const PGM_RECALCSIZE: ::UINT = PGM_FIRST + 2; pub const PGM_FORWARDMOUSE: ::UINT = PGM_FIRST + 3; pub const PGM_SETBKCOLOR: ::UINT = PGM_FIRST + 4; pub const PGM_GETBKCOLOR: ::UINT = PGM_FIRST + 5; pub const PGM_SETBORDER: ::UINT = PGM_FIRST + 6; pub const PGM_GETBORDER: ::UINT = PGM_FIRST + 7; pub const PGM_SETPOS: ::UINT = PGM_FIRST + 8; pub const PGM_GETPOS: ::UINT = PGM_FIRST + 9; pub const PGM_SETBUTTONSIZE: ::UINT = PGM_FIRST + 10; pub const PGM_GETBUTTONSIZE: ::UINT = PGM_FIRST + 11; pub const PGM_GETBUTTONSTATE: ::UINT = PGM_FIRST + 12; pub const PGM_GETDROPTARGET: ::UINT = CCM_GETDROPTARGET; pub const PGM_SETSCROLLINFO: ::UINT = PGM_FIRST + 13; pub const PGN_SCROLL: ::UINT = PGN_FIRST - 1; pub const PGF_SCROLLUP: ::c_int = 1; pub const PGF_SCROLLDOWN: ::c_int = 2; pub const PGF_SCROLLLEFT: ::c_int = 4; pub const PGF_SCROLLRIGHT: ::c_int = 8; pub const PGK_SHIFT: ::BOOL = 1; pub const PGK_CONTROL: ::BOOL = 2; pub const PGK_MENU: ::BOOL = 4; STRUCT!{struct NMPGSCROLL { hdr: ::NMHDR, fwKeys: ::BOOL, rcParent: ::RECT, iDir: ::c_int, iXpos: ::c_int, iYpos: ::c_int, iScroll: ::c_int, }} pub type LPNMPGSCROLL = *mut NMPGSCROLL; pub const PGN_CALCSIZE: ::UINT = PGN_FIRST - 2; pub const PGF_CALCWIDTH: ::DWORD = 1; pub const PGF_CALCHEIGHT: ::DWORD = 2; STRUCT!{struct NMPGCALCSIZE { hdr: ::NMHDR, dwFlag: ::DWORD, iWidth: ::c_int, iHeight: ::c_int, }} pub type LPNMPGCALCSIZE = *mut NMPGCALCSIZE; pub const PGN_HOTITEMCHANGE: ::UINT = PGN_FIRST - 3; STRUCT!{struct NMPGHOTITEM { hdr: ::NMHDR, idOld: ::c_int, idNew: ::c_int, dwFlags: ::DWORD, }} pub type LPNMPGHOTITEM = *mut NMPGHOTITEM; pub const NFS_EDIT: ::DWORD = 0x0001; pub const NFS_STATIC: ::DWORD = 0x0002; pub const NFS_LISTCOMBO: ::DWORD = 0x0004; pub const NFS_BUTTON: ::DWORD = 0x0008; pub const NFS_ALL: ::DWORD = 0x0010; pub const NFS_USEFONTASSOC: ::DWORD = 0x0020; pub const BUTTON_IMAGELIST_ALIGN_LEFT: ::UINT = 0; pub const BUTTON_IMAGELIST_ALIGN_RIGHT: ::UINT = 1; pub const BUTTON_IMAGELIST_ALIGN_TOP: ::UINT = 2; pub const BUTTON_IMAGELIST_ALIGN_BOTTOM: ::UINT = 3; pub const BUTTON_IMAGELIST_ALIGN_CENTER: ::UINT = 4; STRUCT!{struct BUTTON_IMAGELIST { himl: HIMAGELIST, margin: ::RECT, uAlign: ::UINT, }} pub type PBUTTON_IMAGELIST = *mut BUTTON_IMAGELIST; pub const BCM_GETIDEALSIZE: ::UINT = BCM_FIRST + 0x0001; pub const BCM_SETIMAGELIST: ::UINT = BCM_FIRST + 0x0002; pub const BCM_GETIMAGELIST: ::UINT = BCM_FIRST + 0x0003; pub const BCM_SETTEXTMARGIN: ::UINT = BCM_FIRST + 0x0004; pub const BCM_GETTEXTMARGIN: ::UINT = BCM_FIRST + 0x0005; STRUCT!{struct NMBCHOTITEM { hdr: ::NMHDR, dwFlags: ::DWORD, }} pub type LPNMBCHOTITEM = *mut NMBCHOTITEM; pub const BCN_HOTITEMCHANGE: ::UINT = BCN_FIRST + 0x0001; pub const BS_SPLITBUTTON: ::UINT = 0x0000000C; pub const BS_DEFSPLITBUTTON: ::UINT = 0x0000000D; pub const BS_COMMANDLINK: ::UINT = 0x0000000E; pub const BS_DEFCOMMANDLINK: ::UINT = 0x0000000F; pub const BCSIF_GLYPH: ::UINT = 0x0001; pub const BCSIF_IMAGE: ::UINT = 0x0002; pub const BCSIF_STYLE: ::UINT = 0x0004; pub const BCSIF_SIZE: ::UINT = 0x0008; pub const BCSS_NOSPLIT: ::UINT = 0x0001; pub const BCSS_STRETCH: ::UINT = 0x0002; pub const BCSS_ALIGNLEFT: ::UINT = 0x0004; pub const BCSS_IMAGE: ::UINT = 0x0008; STRUCT!{struct BUTTON_SPLITINFO { mask: ::UINT, himlGlyph: HIMAGELIST, uSplitStyle: ::UINT, size: ::SIZE, }} pub type PBUTTON_SPLITINFO = *mut BUTTON_SPLITINFO; pub const BCM_SETDROPDOWNSTATE: ::UINT = BCM_FIRST + 0x0006; pub const BCM_SETSPLITINFO: ::UINT = BCM_FIRST + 0x0007; pub const BCM_GETSPLITINFO: ::UINT = BCM_FIRST + 0x0008; pub const BCM_SETNOTE: ::UINT = BCM_FIRST + 0x0009; pub const BCM_GETNOTE: ::UINT = BCM_FIRST + 0x000A; pub const BCM_GETNOTELENGTH: ::UINT = BCM_FIRST + 0x000B; pub const BCM_SETSHIELD: ::UINT = BCM_FIRST + 0x000C; pub const BCCL_NOGLYPH: HIMAGELIST = (0 - 1) as HIMAGELIST; STRUCT!{struct NMBCDROPDOWN { hdr: ::NMHDR, rcButton: ::RECT, }} pub type LPNMBCDROPDOWN = *mut NMBCDROPDOWN; pub const BCN_DROPDOWN: ::UINT = BCN_FIRST + 0x0002; pub const EM_SETCUEBANNER: ::UINT = ECM_FIRST + 1; pub const EM_GETCUEBANNER: ::UINT = ECM_FIRST + 2; pub const EM_SHOWBALLOONTIP: ::UINT = ECM_FIRST + 3; pub const EM_HIDEBALLOONTIP: ::UINT = ECM_FIRST + 4; pub const EM_SETHILITE: ::UINT = ECM_FIRST + 5; pub const EM_GETHILITE: ::UINT = ECM_FIRST + 6; pub const EM_NOSETFOCUS: ::UINT = ECM_FIRST + 7; pub const EM_TAKEFOCUS: ::UINT = ECM_FIRST + 8; STRUCT!{struct EDITBALLOONTIP { cbStruct: ::DWORD, pszTitle: ::LPCWSTR, pszText: ::LPCWSTR, ttiIcon: ::INT, }} pub type PEDITBALLOONTIP = *mut EDITBALLOONTIP; pub const CB_SETMINVISIBLE: ::UINT = CBM_FIRST + 1; pub const CB_GETMINVISIBLE: ::UINT = CBM_FIRST + 2; pub const CB_SETCUEBANNER: ::UINT = CBM_FIRST + 3; pub const CB_GETCUEBANNER: ::UINT = CBM_FIRST + 4; pub type PFTASKDIALOGCALLBACK = Option ::HRESULT>; FLAGS!{enum TASKDIALOG_FLAGS { TDF_ENABLE_HYPERLINKS = 0x0001, TDF_USE_HICON_MAIN = 0x0002, TDF_USE_HICON_FOOTER = 0x0004, TDF_ALLOW_DIALOG_CANCELLATION = 0x0008, TDF_USE_COMMAND_LINKS = 0x0010, TDF_USE_COMMAND_LINKS_NO_ICON = 0x0020, TDF_EXPAND_FOOTER_AREA = 0x0040, TDF_EXPANDED_BY_DEFAULT = 0x0080, TDF_VERIFICATION_FLAG_CHECKED = 0x0100, TDF_SHOW_PROGRESS_BAR = 0x0200, TDF_SHOW_MARQUEE_PROGRESS_BAR = 0x0400, TDF_CALLBACK_TIMER = 0x0800, TDF_POSITION_RELATIVE_TO_WINDOW = 0x1000, TDF_RTL_LAYOUT = 0x2000, TDF_NO_DEFAULT_RADIO_BUTTON = 0x4000, TDF_CAN_BE_MINIMIZED = 0x8000, TDF_NO_SET_FOREGROUND = 0x00010000, TDF_SIZE_TO_CONTENT = 0x01000000, }} ENUM!{enum TASKDIALOG_MESSAGES { TDM_NAVIGATE_PAGE = ::WM_USER + 101, TDM_CLICK_BUTTON = ::WM_USER + 102, TDM_SET_MARQUEE_PROGRESS_BAR = ::WM_USER + 103, TDM_SET_PROGRESS_BAR_STATE = ::WM_USER + 104, TDM_SET_PROGRESS_BAR_RANGE = ::WM_USER + 105, TDM_SET_PROGRESS_BAR_POS = ::WM_USER + 106, TDM_SET_PROGRESS_BAR_MARQUEE = ::WM_USER + 107, TDM_SET_ELEMENT_TEXT = ::WM_USER + 108, TDM_CLICK_RADIO_BUTTON = ::WM_USER + 110, TDM_ENABLE_BUTTON = ::WM_USER + 111, TDM_ENABLE_RADIO_BUTTON = ::WM_USER + 112, TDM_CLICK_VERIFICATION = ::WM_USER + 113, TDM_UPDATE_ELEMENT_TEXT = ::WM_USER + 114, TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = ::WM_USER + 115, TDM_UPDATE_ICON = ::WM_USER + 116, }} ENUM!{enum TASKDIALOG_NOTIFICATIONS { TDN_CREATED = 0, TDN_NAVIGATED = 1, TDN_BUTTON_CLICKED = 2, TDN_HYPERLINK_CLICKED = 3, TDN_TIMER = 4, TDN_DESTROYED = 5, TDN_RADIO_BUTTON_CLICKED = 6, TDN_DIALOG_CONSTRUCTED = 7, TDN_VERIFICATION_CLICKED = 8, TDN_HELP = 9, TDN_EXPANDO_BUTTON_CLICKED = 10, }} STRUCT!{struct TASKDIALOG_BUTTON { nButtonID: ::c_int, pszButtonText: ::PCWSTR, }} ENUM!{enum TASKDIALOG_ELEMENTS { TDE_CONTENT, TDE_EXPANDED_INFORMATION, TDE_FOOTER, TDE_MAIN_INSTRUCTION, }} ENUM!{enum TASKDIALOG_ICON_ELEMENTS { TDIE_ICON_MAIN, TDIE_ICON_FOOTER, }} FLAGS!{enum TASKDIALOG_COMMON_BUTTON_FLAGS { TDCBF_OK_BUTTON = 0x0001, TDCBF_YES_BUTTON = 0x0002, TDCBF_NO_BUTTON = 0x0004, TDCBF_CANCEL_BUTTON = 0x0008, TDCBF_RETRY_BUTTON = 0x0010, TDCBF_CLOSE_BUTTON = 0x0020, }} #[repr(C)] #[derive(Copy)] pub struct TASKDIALOGCONFIG { pub cbSize: ::UINT, pub hwndParent: ::HWND, pub hInstance: ::HINSTANCE, pub dwFlags: TASKDIALOG_FLAGS, pub dwCommonButtons: TASKDIALOG_COMMON_BUTTON_FLAGS, pub pszWindowTitle: ::PCWSTR, pub hMainIcon: ::HICON, pub pszMainInstruction: ::PCWSTR, pub pszContent: ::PCWSTR, pub cButtons: ::UINT, pub pButtons: *const TASKDIALOG_BUTTON, pub nDefaultButton: ::c_int, pub cRadioButtons: ::UINT, pub pRadioButtons: *const TASKDIALOG_BUTTON, pub nDefaultRadioButton: ::c_int, pub pszVerificationText: ::PCWSTR, pub pszExpandedInformation: ::PCWSTR, pub pszExpandedControlText: ::PCWSTR, pub pszCollapsedControlText: ::PCWSTR, pub hFooterIcon: ::HICON, pub pszFooter: ::PCWSTR, pub pfCallback: PFTASKDIALOGCALLBACK, pub lpCallbackData: ::LONG_PTR, pub cxWidth: ::UINT, } impl Clone for TASKDIALOGCONFIG { fn clone(&self) -> TASKDIALOGCONFIG { *self } } UNION!(TASKDIALOGCONFIG, hMainIcon, pszMainIcon, pszMainIcon_mut, ::PCWSTR); UNION!(TASKDIALOGCONFIG, hFooterIcon, pszFooterIcon, pszFooterIcon_mut, ::PCWSTR); pub const DA_LAST: ::c_int = 0x7FFFFFFF; pub const DA_ERR: ::c_int = -1; pub type PFNDAENUMCALLBACK = Option ::c_int>; pub type PFNDAENUMCALLBACKCONST = Option ::c_int>; pub type PFNDACOMPARE = Option ::c_int>; pub type PFNDACOMPARECONST = Option ::c_int>; #[repr(C)] #[allow(missing_copy_implementations)] pub struct DSA { unused: ::c_void, } pub type HDSA = *mut DSA; pub const DSA_APPEND: ::c_int = DA_LAST; pub const DSA_ERR: ::c_int = DA_ERR; pub type PFNDSAENUMCALLBACK = PFNDAENUMCALLBACK; pub type PFNDSAENUMCALLBACKCONST = PFNDAENUMCALLBACKCONST; pub type PFNDSACOMPARE = PFNDACOMPARE; pub type PFNDSACOMPARECONST = PFNDACOMPARECONST; #[repr(C)] #[allow(missing_copy_implementations)] pub struct DPA { unused: ::c_void, } pub type HDPA = *mut DPA; STRUCT!{struct DPASTREAMINFO { iPos: ::c_int, pvItem: *mut ::c_void, }} pub type PFNDPASTREAM = Option ::HRESULT>; pub const DPAM_SORTED: ::DWORD = 0x00000001; pub const DPAM_NORMAL: ::DWORD = 0x00000002; pub const DPAM_UNION: ::DWORD = 0x00000004; pub const DPAM_INTERSECT: ::DWORD = 0x00000008; pub type PFNDPAMERGE = Option *mut ::c_void>; pub type PFNDPAMERGECONST = Option *const ::c_void>; pub const DPAMM_MERGE: ::UINT = 1; pub const DPAMM_DELETE: ::UINT = 2; pub const DPAMM_INSERT: ::UINT = 3; pub const DPAS_SORTED: ::UINT = 0x0001; pub const DPAS_INSERTBEFORE: ::UINT = 0x0002; pub const DPAS_INSERTAFTER: ::UINT = 0x0004; pub const DPA_APPEND: ::c_int = DA_LAST; pub const DPA_ERR: ::c_int = DA_ERR; pub type PFNDPAENUMCALLBACK = PFNDAENUMCALLBACK; pub type PFNDPAENUMCALLBACKCONST = PFNDAENUMCALLBACKCONST; pub type PFNDPACOMPARE = PFNDACOMPARE; pub type PFNDPACOMPARECONST = PFNDACOMPARECONST; pub const WSB_PROP_CYVSCROLL: ::UINT = 0x00000001; pub const WSB_PROP_CXHSCROLL: ::UINT = 0x00000002; pub const WSB_PROP_CYHSCROLL: ::UINT = 0x00000004; pub const WSB_PROP_CXVSCROLL: ::UINT = 0x00000008; pub const WSB_PROP_CXHTHUMB: ::UINT = 0x00000010; pub const WSB_PROP_CYVTHUMB: ::UINT = 0x00000020; pub const WSB_PROP_VBKGCOLOR: ::UINT = 0x00000040; pub const WSB_PROP_HBKGCOLOR: ::UINT = 0x00000080; pub const WSB_PROP_VSTYLE: ::UINT = 0x00000100; pub const WSB_PROP_HSTYLE: ::UINT = 0x00000200; pub const WSB_PROP_WINSTYLE: ::UINT = 0x00000400; pub const WSB_PROP_PALETTE: ::UINT = 0x00000800; pub const WSB_PROP_MASK: ::UINT = 0x00000FFF; pub const FSB_FLAT_MODE: ::INT_PTR = 2; pub const FSB_ENCARTA_MODE: ::INT_PTR = 1; pub const FSB_REGULAR_MODE: ::INT_PTR = 0; pub type SUBCLASSPROC = Option ::LRESULT>; deps/winapi-0.2.5/src/macros.rs0000644000000000000000000002006112615667040015065 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Macros to make things easier to define macro_rules! DECLARE_HANDLE { ($name:ident, $inner:ident) => { #[repr(C)] #[allow(missing_copy_implementations)] struct $inner { unused: ::c_void } pub type $name = *mut $inner; }; } macro_rules! MAKE_HRESULT { ($sev:expr, $fac:expr, $code:expr) => { ($sev << 31) | ($fac << 16) | $code } } macro_rules! MAKE_SCODE { ($sev:expr, $fac:expr, $code:expr) => { ($sev << 31) | ($fac << 16) | $code } } macro_rules! MAKEFOURCC { ($a:expr, $b:expr, $c:expr, $d:expr) => { ($a as i32) | (($b as i32) << 8) | (($c as i32) << 16) | (($d as i32) << 24) } } macro_rules! DEFINE_GUID { ( $name:ident, $l:expr, $w1:expr, $w2:expr, $b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr ) => { pub const $name: ::GUID = ::GUID { Data1: $l, Data2: $w1, Data3: $w2, Data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8], }; } } macro_rules! CTL_CODE { ($DeviceType:expr, $Function:expr, $Method:expr, $Access:expr) => { ($DeviceType << 16) | ($Access << 14) | ($Function << 2) | $Method } } macro_rules! AUDCLNT_ERR { ($n:expr) => { MAKE_HRESULT!(::SEVERITY_ERROR, ::FACILITY_AUDCLNT, $n) }; } macro_rules! AUDCLNT_SUCCESS { ($n:expr) => { MAKE_SCODE!(::SEVERITY_SUCCESS, ::FACILITY_AUDCLNT, $n) }; } macro_rules! BCRYPT_MAKE_INTERFACE_VERSION { ($major:expr, $minor:expr) => { ::BCRYPT_INTERFACE_VERSION { MajorVersion: $major, MinorVersion: $minor } } } macro_rules! RIDL { (interface $interface:ident ($vtbl:ident) {$( fn $method:ident(&mut self $(,$p:ident : $t:ty)*) -> $rtr:ty ),+} ) => { #[repr(C)] #[allow(missing_copy_implementations)] pub struct $vtbl { $(pub $method: unsafe extern "system" fn( This: *mut $interface $(,$p: $t)* ) -> $rtr),+ } #[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct $interface { pub lpVtbl: *const $vtbl } impl $interface { #[inline] $(pub unsafe fn $method(&mut self $(,$p: $t)*) -> $rtr { ((*self.lpVtbl).$method)(self $(,$p)*) })+ } }; (interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident) { }) => { #[repr(C)] #[allow(missing_copy_implementations)] pub struct $vtbl { pub parent: ::$pvtbl } #[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct $interface { pub lpVtbl: *const $vtbl } impl ::std::ops::Deref for $interface { type Target = ::$pinterface; #[inline] fn deref(&self) -> &::$pinterface { unsafe { ::std::mem::transmute(self) } } } impl ::std::ops::DerefMut for $interface { #[inline] fn deref_mut(&mut self) -> &mut ::$pinterface { unsafe { ::std::mem::transmute(self) } } } }; (interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident) {$( fn $method:ident(&mut self $(,$p:ident : $t:ty)*) -> $rtr:ty ),+} ) => { #[repr(C)] #[allow(missing_copy_implementations)] pub struct $vtbl { pub parent: ::$pvtbl $(,pub $method: unsafe extern "system" fn( This: *mut $interface $(,$p: $t)* ) -> $rtr)+ } #[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct $interface { pub lpVtbl: *const $vtbl } impl $interface { #[inline] $(pub unsafe fn $method(&mut self $(,$p: $t)*) -> $rtr { ((*self.lpVtbl).$method)(self $(,$p)*) })+ } impl ::std::ops::Deref for $interface { type Target = ::$pinterface; #[inline] fn deref(&self) -> &::$pinterface { unsafe { ::std::mem::transmute(self) } } } impl ::std::ops::DerefMut for $interface { #[inline] fn deref_mut(&mut self) -> &mut ::$pinterface { unsafe { ::std::mem::transmute(self) } } } }; } macro_rules! UNION { ($base:ident, $field:ident, $variant:ident, $variantmut: ident, $fieldtype:ty) => { impl $base { #[inline] pub unsafe fn $variant(&self) -> &$fieldtype { ::std::mem::transmute(&self.$field) } #[inline] pub unsafe fn $variantmut(&mut self) -> &mut $fieldtype { ::std::mem::transmute(&mut self.$field) } } } } macro_rules! BITFIELD { ($base:ident $field:ident: $fieldtype:ty [ $($thing:ident $set_thing:ident[$r:expr],)+ ]) => { impl $base {$( #[inline] pub fn $thing(&self) -> $fieldtype { let size = ::std::mem::size_of::<$fieldtype>() * 8; self.$field << (size - $r.end) >> (size - $r.end + $r.start) } #[inline] pub fn $set_thing(&mut self, val: $fieldtype) { let mask = ((1 << ($r.end - $r.start)) - 1) << $r.start; self.$field &= !mask; self.$field |= (val << $r.start) & mask; } )+} } } macro_rules! ENUM { {enum $name:ident { $($variant:ident = $value:expr,)+ }} => { #[repr(C)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub struct $name(pub u32); $(pub const $variant: $name = $name($value);)+ }; {enum $name:ident { $variant:ident = $value:expr, $($rest:tt)* }} => { #[repr(C)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub struct $name(pub u32); pub const $variant: $name = $name($value); ENUM!{@gen $name, $variant, $($rest)*} }; {enum $name:ident { $variant:ident, $($rest:tt)* }} => { ENUM!{enum $name { $variant = 0, $($rest)* }} }; {@gen $name:ident, $base:ident,} => {}; {@gen $name:ident, $base:ident, $variant:ident = $value:expr, $($rest:tt)*} => { pub const $variant: $name = $name($value); ENUM!{@gen $name, $variant, $($rest)*} }; {@gen $name:ident, $base:ident, $variant:ident, $($rest:tt)*} => { pub const $variant: $name = $name($base.0 + 1u32); ENUM!{@gen $name, $variant, $($rest)*} }; } macro_rules! FLAGS { {enum $name:ident { $($variant:ident = $value:expr,)+ }} => { #[repr(C)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub struct $name(pub u32); $(pub const $variant: $name = $name($value);)+ impl ::std::ops::BitAnd<$name> for $name { type Output = $name; fn bitand(self, o: $name) -> $name { $name(self.0 & o.0) } } impl ::std::ops::BitOr<$name> for $name { type Output = $name; fn bitor(self, o: $name) -> $name { $name(self.0 | o.0) } } impl ::std::ops::BitXor<$name> for $name { type Output = $name; fn bitxor(self, o: $name) -> $name { $name(self.0 ^ o.0) } } impl ::std::ops::Not for $name { type Output = $name; fn not(self) -> $name { $name(!self.0) } } } } macro_rules! STRUCT { {nodebug struct $name:ident { $($field:ident: $ftype:ty,)+ }} => { #[repr(C)] pub struct $name { $(pub $field: $ftype,)+ } impl Copy for $name {} impl Clone for $name { fn clone(&self) -> $name { *self } } }; {struct $name:ident { $($field:ident: $ftype:ty,)+ }} => { #[repr(C)] #[derive(Debug)] pub struct $name { $(pub $field: $ftype,)+ } impl Copy for $name {} impl Clone for $name { fn clone(&self) -> $name { *self } } }; } deps/winapi-0.2.5/src/mssip.rs0000644000000000000000000000757312613167613014750 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Microsoft SIP Provider Prototypes and Definitions STRUCT!{struct SIP_SUBJECTINFO { cbSize: ::DWORD, pgSubjectType: *mut ::GUID, hFile: ::HANDLE, pwsFileName: ::LPCWSTR, pwsDisplayName: ::LPCWSTR, dwReserved1: ::DWORD, dwIntVersion: ::DWORD, hProv: ::HCRYPTPROV, DigestAlgorithm: ::CRYPT_ALGORITHM_IDENTIFIER, dwFlags: ::DWORD, dwEncodingType: ::DWORD, dwReserved2: ::DWORD, fdwCAPISettings: ::DWORD, fdwSecuritySettings: ::DWORD, dwIndex: ::DWORD, dwUnionChoice: ::DWORD, psFlat: *mut MS_ADDINFO_FLAT, pClientData: ::LPVOID, }} UNION!(SIP_SUBJECTINFO, psFlat, psCatMember, psCatMember_mut, *mut MS_ADDINFO_CATALOGMEMBER); UNION!(SIP_SUBJECTINFO, psFlat, psBlob, psBlob_mut, *mut MS_ADDINFO_BLOB); pub type LPSIP_SUBJECTINFO = *mut SIP_SUBJECTINFO; STRUCT!{struct MS_ADDINFO_FLAT { cbStruct: ::DWORD, pIndirectData: *mut SIP_INDIRECT_DATA, }} pub type PMS_ADDINFO_FLAT = *mut MS_ADDINFO_FLAT; STRUCT!{struct MS_ADDINFO_CATALOGMEMBER { cbStruct: ::DWORD, pStore: *mut ::CRYPTCATSTORE, pMember: *mut ::CRYPTCATMEMBER, }} pub type PMS_ADDINFO_CATALOGMEMBER = *mut MS_ADDINFO_CATALOGMEMBER; STRUCT!{struct MS_ADDINFO_BLOB { cbStruct: ::DWORD, cbMemObject: ::DWORD, pbMemObject: *mut ::BYTE, cbMemSignedMsg: ::DWORD, pbMemSignedMsg: *mut ::BYTE, }} pub type PMS_ADDINFO_BLOB = *mut MS_ADDINFO_BLOB; STRUCT!{struct SIP_INDIRECT_DATA { Data: ::CRYPT_ATTRIBUTE_TYPE_VALUE, DigestAlgorithm: ::CRYPT_ALGORITHM_IDENTIFIER, Digest: ::CRYPT_HASH_BLOB, }} pub type PSIP_INDIRECT_DATA = *mut SIP_INDIRECT_DATA; STRUCT!{struct SIP_ADD_NEWPROVIDER { cbStruct: ::DWORD, pgSubject: *mut ::GUID, pwszDLLFileName: *mut ::WCHAR, pwszMagicNumber: *mut ::WCHAR, pwszIsFunctionName: *mut ::WCHAR, pwszGetFuncName: *mut ::WCHAR, pwszPutFuncName: *mut ::WCHAR, pwszCreateFuncName: *mut ::WCHAR, pwszVerifyFuncName: *mut ::WCHAR, pwszRemoveFuncName: *mut ::WCHAR, pwszIsFunctionNameFmt2: *mut ::WCHAR, pwszGetCapFuncName: ::PWSTR, }} pub type PSIP_ADD_NEWPROVIDER = *mut SIP_ADD_NEWPROVIDER; STRUCT!{struct SIP_CAP_SET_V3 { cbSize: ::DWORD, dwVersion: ::DWORD, isMultiSign: ::BOOL, dwFlags: ::DWORD, }} UNION!(SIP_CAP_SET_V3, dwFlags, dwReserved, dwReserved_mut, ::DWORD); pub type PSIP_CAP_SET_V3 = *mut SIP_CAP_SET_V3; pub type SIP_CAP_SET = PSIP_CAP_SET_V3; pub type pCryptSIPGetSignedDataMsg = Option ::BOOL>; pub type pCryptSIPPutSignedDataMsg = Option ::BOOL>; pub type pCryptSIPCreateIndirectData = Option ::BOOL>; pub type pCryptSIPVerifyIndirectData = Option ::BOOL>; pub type pCryptSIPRemoveSignedDataMsg = Option ::BOOL>; #[repr(C)] #[derive(Copy)] pub struct SIP_DISPATCH_INFO { pub cbSize: ::DWORD, pub hSIP: ::HANDLE, pub pfGet: pCryptSIPGetSignedDataMsg, pub pfPut: pCryptSIPPutSignedDataMsg, pub pfCreate: pCryptSIPCreateIndirectData, pub pfVerify: pCryptSIPVerifyIndirectData, pub pfRemove: pCryptSIPRemoveSignedDataMsg, } impl Clone for SIP_DISPATCH_INFO { fn clone(&self) -> SIP_DISPATCH_INFO { *self } } pub type LPSIP_DISPATCH_INFO = *mut SIP_DISPATCH_INFO; deps/winapi-0.2.5/src/devpropdef.rs0000644000000000000000000000616712615662007015750 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Defines property types and keys for the Plug and Play Device Property API pub type DEVPROPTYPE = ::ULONG; pub type PDEVPROPTYPE = *mut ::ULONG; pub const DEVPROP_TYPEMOD_ARRAY: DEVPROPTYPE = 0x00001000; pub const DEVPROP_TYPEMOD_LIST: DEVPROPTYPE = 0x00002000; pub const DEVPROP_TYPE_EMPTY: DEVPROPTYPE = 0x00000000; pub const DEVPROP_TYPE_NULL: DEVPROPTYPE = 0x00000001; pub const DEVPROP_TYPE_SBYTE: DEVPROPTYPE = 0x00000002; pub const DEVPROP_TYPE_BYTE: DEVPROPTYPE = 0x00000003; pub const DEVPROP_TYPE_INT16: DEVPROPTYPE = 0x00000004; pub const DEVPROP_TYPE_UINT16: DEVPROPTYPE = 0x00000005; pub const DEVPROP_TYPE_INT32: DEVPROPTYPE = 0x00000006; pub const DEVPROP_TYPE_UINT32: DEVPROPTYPE = 0x00000007; pub const DEVPROP_TYPE_INT64: DEVPROPTYPE = 0x00000008; pub const DEVPROP_TYPE_UINT64: DEVPROPTYPE = 0x00000009; pub const DEVPROP_TYPE_FLOAT: DEVPROPTYPE = 0x0000000A; pub const DEVPROP_TYPE_DOUBLE: DEVPROPTYPE = 0x0000000B; pub const DEVPROP_TYPE_DECIMAL: DEVPROPTYPE = 0x0000000C; pub const DEVPROP_TYPE_GUID: DEVPROPTYPE = 0x0000000D; pub const DEVPROP_TYPE_CURRENCY: DEVPROPTYPE = 0x0000000E; pub const DEVPROP_TYPE_DATE: DEVPROPTYPE = 0x0000000F; pub const DEVPROP_TYPE_FILETIME: DEVPROPTYPE = 0x00000010; pub const DEVPROP_TYPE_BOOLEAN: DEVPROPTYPE = 0x00000011; pub const DEVPROP_TYPE_STRING: DEVPROPTYPE = 0x00000012; pub const DEVPROP_TYPE_STRING_LIST: DEVPROPTYPE = DEVPROP_TYPE_STRING | DEVPROP_TYPEMOD_LIST; pub const DEVPROP_TYPE_SECURITY_DESCRIPTOR: DEVPROPTYPE = 0x00000013; pub const DEVPROP_TYPE_SECURITY_DESCRIPTOR_STRING: DEVPROPTYPE = 0x00000014; pub const DEVPROP_TYPE_DEVPROPKEY: DEVPROPTYPE = 0x00000015; pub const DEVPROP_TYPE_DEVPROPTYPE: DEVPROPTYPE = 0x00000016; pub const DEVPROP_TYPE_BINARY: DEVPROPTYPE = DEVPROP_TYPE_BYTE | DEVPROP_TYPEMOD_ARRAY; pub const DEVPROP_TYPE_ERROR: DEVPROPTYPE = 0x00000017; pub const DEVPROP_TYPE_NTSTATUS: DEVPROPTYPE = 0x00000018; pub const DEVPROP_TYPE_STRING_INDIRECT: DEVPROPTYPE = 0x00000019; pub const MAX_DEVPROP_TYPE: DEVPROPTYPE = 0x00000019; pub const MAX_DEVPROP_TYPEMOD: DEVPROPTYPE = 0x00002000; pub const DEVPROP_MASK_TYPE: DEVPROPTYPE = 0x00000FFF; pub const DEVPROP_MASK_TYPEMOD: DEVPROPTYPE = 0x0000F000; pub type DEVPROP_BOOLEAN = ::CHAR; pub type PDEVPROP_BOOLEAN = *mut ::CHAR; pub const DEVPROP_TRUE: DEVPROP_BOOLEAN = -1; pub const DEVPROP_FALSE: DEVPROP_BOOLEAN = 0; pub type DEVPROPGUID = ::GUID; pub type PDEVPROPGUID = *mut ::GUID; pub type DEVPROPID = ::ULONG; pub type PDEVPROPID = *mut ::ULONG; STRUCT!{struct DEVPROPKEY { fmtid: DEVPROPGUID, pid: DEVPROPID, }} pub type PDEVPROPKEY = *mut DEVPROPKEY; ENUM!{enum DEVPROPSTORE { DEVPROP_STORE_SYSTEM, DEVPROP_STORE_USER, }} pub type PDEVPROPSTORE = *mut DEVPROPSTORE; STRUCT!{struct DEVPROPCOMPKEY { Key: DEVPROPKEY, Store: DEVPROPSTORE, LocaleName: ::PCWSTR, }} pub type PDEVPROPCOMPKEY = *mut DEVPROPCOMPKEY; STRUCT!{struct DEVPROPERTY { CompKey: DEVPROPCOMPKEY, Type: DEVPROPTYPE, BufferSize: ::ULONG, Buffer: ::PVOID, }} pub type PDEVPROPERTY = *mut DEVPROPERTY; pub const DEVPROPID_FIRST_USABLE: DEVPROPID = 2; deps/winapi-0.2.5/src/shlobj.rs0000644000000000000000000001027712605021253015057 0ustar rootroot// Copyright © 2015, Peter Atashian, skdltmxn // Licensed under the MIT License pub const INVALID_HANDLE_VALUE: ::HANDLE = -1isize as ::HANDLE; pub type GPFIDL_FLAGS = ::c_int; ENUM!{enum KNOWN_FOLDER_FLAG { KF_FLAG_DEFAULT = 0x00000000, KF_FLAG_NO_APPCONTAINER_REDIRECTION = 0x00010000, KF_FLAG_CREATE = 0x00008000, KF_FLAG_DONT_VERIFY = 0x00004000, KF_FLAG_DONT_UNEXPAND = 0x00002000, KF_FLAG_NO_ALIAS = 0x00001000, KF_FLAG_INIT = 0x00000800, KF_FLAG_DEFAULT_PATH = 0x00000400, KF_FLAG_NOT_PARENT_RELATIVE = 0x00000200, KF_FLAG_SIMPLE_IDLIST = 0x00000100, KF_FLAG_ALIAS_ONLY = 0x80000000, }} pub const IDO_SHGIOI_SHARE: ::c_int = 0x0FFFFFFF; pub const IDO_SHGIOI_LINK: ::c_int = 0x0FFFFFFE; // Yes, these values are supposed to overflow. Blame Microsoft. pub const IDO_SHGIOI_SLOWFILE: ::c_int = 0xFFFFFFFDu32 as ::c_int; pub const IDO_SHGIOI_DEFAULT: ::c_int = 0xFFFFFFFCu32 as ::c_int; pub const GPFIDL_DEFAULT: GPFIDL_FLAGS = 0x0000; pub const GPFIDL_ALTNAME: GPFIDL_FLAGS = 0x0001; pub const GPFIDL_UNCPRINTER: GPFIDL_FLAGS = 0x0002; pub const OFASI_EDIT: ::DWORD = 0x0001; pub const OFASI_OPENDESKTOP: ::DWORD = 0x0002; // 1204 pub const CSIDL_DESKTOP: ::c_int = 0x0000; pub const CSIDL_INTERNET: ::c_int = 0x0001; pub const CSIDL_PROGRAMS: ::c_int = 0x0002; pub const CSIDL_CONTROLS: ::c_int = 0x0003; pub const CSIDL_PRINTERS: ::c_int = 0x0004; pub const CSIDL_PERSONAL: ::c_int = 0x0005; pub const CSIDL_FAVORITES: ::c_int = 0x0006; pub const CSIDL_STARTUP: ::c_int = 0x0007; pub const CSIDL_RECENT: ::c_int = 0x0008; pub const CSIDL_SENDTO: ::c_int = 0x0009; pub const CSIDL_BITBUCKET: ::c_int = 0x000a; pub const CSIDL_STARTMENU: ::c_int = 0x000b; pub const CSIDL_MYDOCUMENTS: ::c_int = CSIDL_PERSONAL; pub const CSIDL_MYMUSIC: ::c_int = 0x000d; pub const CSIDL_MYVIDEO: ::c_int = 0x000e; pub const CSIDL_DESKTOPDIRECTORY: ::c_int = 0x0010; pub const CSIDL_DRIVES: ::c_int = 0x0011; pub const CSIDL_NETWORK: ::c_int = 0x0012; pub const CSIDL_NETHOOD: ::c_int = 0x0013; pub const CSIDL_FONTS: ::c_int = 0x0014; pub const CSIDL_TEMPLATES: ::c_int = 0x0015; pub const CSIDL_COMMON_STARTMENU: ::c_int = 0x0016; pub const CSIDL_COMMON_PROGRAMS: ::c_int = 0x0017; pub const CSIDL_COMMON_STARTUP: ::c_int = 0x0018; pub const CSIDL_COMMON_DESKTOPDIRECTORY: ::c_int = 0x0019; pub const CSIDL_APPDATA: ::c_int = 0x001a; pub const CSIDL_PRINTHOOD: ::c_int = 0x001b; pub const CSIDL_LOCAL_APPDATA: ::c_int = 0x001c; pub const CSIDL_ALTSTARTUP: ::c_int = 0x001d; pub const CSIDL_COMMON_ALTSTARTUP: ::c_int = 0x001e; pub const CSIDL_COMMON_FAVORITES: ::c_int = 0x001f; pub const CSIDL_INTERNET_CACHE: ::c_int = 0x0020; pub const CSIDL_COOKIES: ::c_int = 0x0021; pub const CSIDL_HISTORY: ::c_int = 0x0022; pub const CSIDL_COMMON_APPDATA: ::c_int = 0x0023; pub const CSIDL_WINDOWS: ::c_int = 0x0024; pub const CSIDL_SYSTEM: ::c_int = 0x0025; pub const CSIDL_PROGRAM_FILES: ::c_int = 0x0026; pub const CSIDL_MYPICTURES: ::c_int = 0x0027; pub const CSIDL_PROFILE: ::c_int = 0x0028; pub const CSIDL_SYSTEMX86: ::c_int = 0x0029; pub const CSIDL_PROGRAM_FILESX86: ::c_int = 0x002a; pub const CSIDL_PROGRAM_FILES_COMMON: ::c_int = 0x002b; pub const CSIDL_PROGRAM_FILES_COMMONX86: ::c_int = 0x002c; pub const CSIDL_COMMON_TEMPLATES: ::c_int = 0x002d; pub const CSIDL_COMMON_DOCUMENTS: ::c_int = 0x002e; pub const CSIDL_COMMON_ADMINTOOLS: ::c_int = 0x002f; pub const CSIDL_ADMINTOOLS: ::c_int = 0x0030; pub const CSIDL_CONNECTIONS: ::c_int = 0x0031; pub const CSIDL_COMMON_MUSIC: ::c_int = 0x0035; pub const CSIDL_COMMON_PICTURES: ::c_int = 0x0036; pub const CSIDL_COMMON_VIDEO: ::c_int = 0x0037; pub const CSIDL_RESOURCES: ::c_int = 0x0038; pub const CSIDL_RESOURCES_LOCALIZED: ::c_int = 0x0039; pub const CSIDL_COMMON_OEM_LINKS: ::c_int = 0x003a; pub const CSIDL_CDBURN_AREA: ::c_int = 0x003b; pub const CSIDL_COMPUTERSNEARME: ::c_int = 0x003d; pub const CSIDL_FLAG_CREATE: ::c_int = 0x8000; pub const CSIDL_FLAG_DONT_VERIFY: ::c_int = 0x4000; pub const CSIDL_FLAG_DONT_UNEXPAND: ::c_int = 0x2000; pub const CSIDL_FLAG_NO_ALIAS: ::c_int = 0x1000; pub const CSIDL_FLAG_PER_USER_INIT: ::c_int = 0x0800; pub const CSIDL_FLAG_MASK: ::c_int = 0xff00; //1312 pub const SHGFP_TYPE_CURRENT: ::DWORD = 0; pub const SHGFP_TYPE_DEFAULT: ::DWORD = 1; deps/winapi-0.2.5/src/psapi.rs0000644000000000000000000001317412613167613014723 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! API Prototypes and Definitions for PSAPI.DLL pub const LIST_MODULES_DEFAULT: ::DWORD = 0x0; pub const LIST_MODULES_32BIT: ::DWORD = 0x01; pub const LIST_MODULES_64BIT: ::DWORD = 0x02; pub const LIST_MODULES_ALL: ::DWORD = LIST_MODULES_32BIT | LIST_MODULES_64BIT; STRUCT!{struct MODULEINFO { lpBaseOfDll: ::LPVOID, SizeOfImage: ::DWORD, EntryPoint: ::LPVOID, }} pub type LPMODULEINFO = *mut MODULEINFO; STRUCT!{struct PSAPI_WORKING_SET_BLOCK { Flags: ::ULONG_PTR, BitFields: ::ULONG_PTR, }} #[cfg(target_arch="x86")] BITFIELD!(PSAPI_WORKING_SET_BLOCK BitFields: ::ULONG_PTR [ Protection set_Protection[0..5], ShareCount set_ShareCount[5..8], Shared set_Shared[8..9], Reserved set_Reserved[9..12], VirtualPage set_VirtualPage[12..32], ]); #[cfg(target_arch="x86_64")] BITFIELD!(PSAPI_WORKING_SET_BLOCK BitFields: ::ULONG_PTR [ Protection set_Protection[0..5], ShareCount set_ShareCount[5..8], Shared set_Shared[8..9], Reserved set_Reserved[9..12], VirtualPage set_VirtualPage[12..64], ]); pub type PPSAPI_WORKING_SET_BLOCK = *mut PSAPI_WORKING_SET_BLOCK; STRUCT!{struct PSAPI_WORKING_SET_INFORMATION { NumberOfEntries: ::ULONG_PTR, WorkingSetInfo: [PSAPI_WORKING_SET_BLOCK; 1], }} pub type PPSAPI_WORKING_SET_INFORMATION = *mut PSAPI_WORKING_SET_INFORMATION; STRUCT!{struct PSAPI_WORKING_SET_EX_BLOCK_Invalid { BitFields: ::ULONG_PTR, }} #[cfg(target_arch="x86")] BITFIELD!(PSAPI_WORKING_SET_EX_BLOCK_Invalid BitFields: ::ULONG_PTR [ Valid set_Valid[0..1], Reserved0 set_Reserved0[1..15], Shared set_Shared[15..16], Reserved1 set_Reserved1[16..31], Bad set_Bad[31..32], ]); #[cfg(target_arch="x86_64")] BITFIELD!(PSAPI_WORKING_SET_EX_BLOCK_Invalid BitFields: ::ULONG_PTR [ Valid set_Valid[0..1], Reserved0 set_Reserved0[1..15], Shared set_Shared[15..16], Reserved1 set_Reserved1[16..31], Bad set_Bad[31..32], ReservedUlong set_ReservedUlong[32..64], ]); STRUCT!{struct PSAPI_WORKING_SET_EX_BLOCK { Flags: ::ULONG_PTR, BitFields: ::ULONG_PTR, }} #[cfg(target_arch="x86")] BITFIELD!(PSAPI_WORKING_SET_EX_BLOCK BitFields: ::ULONG_PTR [ Valid set_Valid[0..1], ShareCount set_ShareCount[1..4], Win32Protection set_Win32Protection[4..15], Shared set_Shared[15..16], Node set_Node[16..22], Locked set_Locked[22..23], LargePage set_LargePage[23..24], Reserved set_Reserved[24..31], Bad set_Bad[31..32], ]); #[cfg(target_arch="x86_64")] BITFIELD!(PSAPI_WORKING_SET_EX_BLOCK BitFields: ::ULONG_PTR [ Valid set_Valid[0..1], ShareCount set_ShareCount[1..4], Win32Protection set_Win32Protection[4..15], Shared set_Shared[15..16], Node set_Node[16..22], Locked set_Locked[22..23], LargePage set_LargePage[23..24], Reserved set_Reserved[24..31], Bad set_Bad[31..32], ReservedUlong set_ReservedUlong[32..64], ]); UNION!( PSAPI_WORKING_SET_EX_BLOCK, BitFields, Invalid, Invalid_mut, PSAPI_WORKING_SET_EX_BLOCK_Invalid ); pub type PPSAPI_WORKING_SET_EX_BLOCK = *mut PSAPI_WORKING_SET_EX_BLOCK; STRUCT!{struct PSAPI_WORKING_SET_EX_INFORMATION { VirtualAddress: ::PVOID, VirtualAttributes: PSAPI_WORKING_SET_EX_BLOCK, }} pub type PPSAPI_WORKING_SET_EX_INFORMATION = *mut PSAPI_WORKING_SET_EX_INFORMATION; STRUCT!{struct PSAPI_WS_WATCH_INFORMATION { FaultingPc: ::LPVOID, FaultingVa: ::LPVOID, }} pub type PPSAPI_WS_WATCH_INFORMATION = *mut PSAPI_WS_WATCH_INFORMATION; STRUCT!{struct PSAPI_WS_WATCH_INFORMATION_EX { BasicInfo: PSAPI_WS_WATCH_INFORMATION, FaultingThreadId: ::ULONG_PTR, Flags: ::ULONG_PTR, }} pub type PPSAPI_WS_WATCH_INFORMATION_EX = *mut PSAPI_WS_WATCH_INFORMATION_EX; STRUCT!{struct PROCESS_MEMORY_COUNTERS { cb: ::DWORD, PageFaultCount: ::DWORD, PeakWorkingSetSize: ::SIZE_T, WorkingSetSize: ::SIZE_T, QuotaPeakPagedPoolUsage: ::SIZE_T, QuotaPagedPoolUsage: ::SIZE_T, QuotaPeakNonPagedPoolUsage: ::SIZE_T, QuotaNonPagedPoolUsage: ::SIZE_T, PagefileUsage: ::SIZE_T, PeakPagefileUsage: ::SIZE_T, }} pub type PPROCESS_MEMORY_COUNTERS = *mut PROCESS_MEMORY_COUNTERS; STRUCT!{struct PROCESS_MEMORY_COUNTERS_EX { cb: ::DWORD, PageFaultCount: ::DWORD, PeakWorkingSetSize: ::SIZE_T, WorkingSetSize: ::SIZE_T, QuotaPeakPagedPoolUsage: ::SIZE_T, QuotaPagedPoolUsage: ::SIZE_T, QuotaPeakNonPagedPoolUsage: ::SIZE_T, QuotaNonPagedPoolUsage: ::SIZE_T, PagefileUsage: ::SIZE_T, PeakPagefileUsage: ::SIZE_T, PrivateUsage: ::SIZE_T, }} pub type PPROCESS_MEMORY_COUNTERS_EX = *mut PROCESS_MEMORY_COUNTERS_EX; STRUCT!{struct PERFORMANCE_INFORMATION { cb: ::DWORD, CommitTotal: ::SIZE_T, CommitLimit: ::SIZE_T, CommitPeak: ::SIZE_T, PhysicalTotal: ::SIZE_T, PhysicalAvailable: ::SIZE_T, SystemCache: ::SIZE_T, KernelTotal: ::SIZE_T, KernelPaged: ::SIZE_T, KernelNonpaged: ::SIZE_T, PageSize: ::SIZE_T, HandleCount: ::DWORD, ProcessCount: ::DWORD, ThreadCount: ::DWORD, }} pub type PPERFORMANCE_INFORMATION = *mut PERFORMANCE_INFORMATION; STRUCT!{struct ENUM_PAGE_FILE_INFORMATION { cb: ::DWORD, Reserved: ::DWORD, TotalSize: ::SIZE_T, TotalInUse: ::SIZE_T, PeakUsage: ::SIZE_T, }} pub type PENUM_PAGE_FILE_INFORMATION = *mut ENUM_PAGE_FILE_INFORMATION; pub type PENUM_PAGE_FILE_CALLBACKA = Option ::BOOL>; pub type PENUM_PAGE_FILE_CALLBACKW = Option ::BOOL>; deps/winapi-0.2.5/src/ws2ipdef.rs0000644000000000000000000000272412616503465015333 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License pub const IPV6_HOPOPTS: ::c_int = 1; pub const IPV6_HDRINCL: ::c_int = 2; pub const IPV6_UNICAST_HOPS: ::c_int = 4; pub const IPV6_MULTICAST_IF: ::c_int = 9; pub const IPV6_MULTICAST_HOPS: ::c_int = 10; pub const IPV6_MULTICAST_LOOP: ::c_int = 11; pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12; pub const IPV6_JOIN_GROUP: ::c_int = IPV6_ADD_MEMBERSHIP; pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13; pub const IPV6_LEAVE_GROUP: ::c_int = IPV6_DROP_MEMBERSHIP; pub const IPV6_DONTFRAG: ::c_int = 14; pub const IPV6_PKTINFO: ::c_int = 19; pub const IPV6_HOPLIMIT: ::c_int = 21; pub const IPV6_PROTECTION_LEVEL: ::c_int = 23; pub const IPV6_RECVIF: ::c_int = 24; pub const IPV6_RECVDSTADDR: ::c_int = 25; pub const IPV6_CHECKSUM: ::c_int = 26; pub const IPV6_V6ONLY: ::c_int = 27; pub const IPV6_IFLIST: ::c_int = 28; pub const IPV6_ADD_IFLIST: ::c_int = 29; pub const IPV6_DEL_IFLIST: ::c_int = 30; pub const IPV6_UNICAST_IF: ::c_int = 31; pub const IPV6_RTHDR: ::c_int = 32; pub const IPV6_RECVRTHDR: ::c_int = 38; pub const IPV6_TCLASS: ::c_int = 39; pub const IPV6_RECVTCLASS: ::c_int = 40; STRUCT!{struct ipv6_mreq { ipv6mr_multiaddr: in6_addr, ipv6mr_interface: ::c_uint, }} STRUCT!{struct in6_addr { s6_addr: [u8; 16], }} STRUCT!{struct sockaddr_in6 { sin6_family: ::c_short, sin6_port: ::c_ushort, sin6_flowinfo: ::c_ulong, sin6_addr: in6_addr, sin6_scope_id: ::c_ulong, }} deps/winapi-0.2.5/src/urlmon.rs0000644000000000000000000000036312605021352015105 0ustar rootroot// Copyright © 2015, Connor Hilarides // Licensed under the MIT License //! Mappings for the contents of Urlmon.h // FIXME: Implement these interfaces #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IInternetSecurityManager; deps/winapi-0.2.5/src/dbghelp.rs0000644000000000000000000002621412615662007015212 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! DbgHelp include file #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct LOADED_IMAGE { pub ModuleName: ::PSTR, pub hFile: ::HANDLE, pub MappedAddress: ::PUCHAR, #[cfg(target_arch = "x86_64")] pub FileHeader: ::PIMAGE_NT_HEADERS64, #[cfg(not(target_arch = "x86_64"))] pub FileHeader: ::PIMAGE_NT_HEADERS32, pub LastRvaSection: ::PIMAGE_SECTION_HEADER, pub NumberOfSections: ::ULONG, pub Sections: ::PIMAGE_SECTION_HEADER, pub Characteristics: ::ULONG, pub fSystemImage: ::BOOLEAN, pub fDOSImage: ::BOOLEAN, pub fReadOnly: ::BOOLEAN, pub Version: ::UCHAR, pub Links: ::LIST_ENTRY, pub SizeOfImage: ::ULONG, } pub const MAX_SYM_NAME: usize = 2000; pub const ERROR_IMAGE_NOT_STRIPPED: ::DWORD = 0x8800; pub const ERROR_NO_DBG_POINTER: ::DWORD = 0x8801; pub const ERROR_NO_PDB_POINTER: ::DWORD = 0x8802; pub type PFIND_DEBUG_FILE_CALLBACK = Option ::BOOL>; pub type PFIND_DEBUG_FILE_CALLBACKW = Option ::BOOL>; pub type PFINDFILEINPATHCALLBACK = Option ::BOOL>; pub type PFINDFILEINPATHCALLBACKW = Option ::BOOL>; pub type PFIND_EXE_FILE_CALLBACK = Option ::BOOL>; pub type PFIND_EXE_FILE_CALLBACKW = Option ::BOOL>; #[repr(C)] #[derive(Clone, Copy, Debug)] #[cfg(target_arch = "x86")] pub struct IMAGE_DEBUG_INFORMATION { pub List: ::LIST_ENTRY, pub ReservedSize: ::DWORD, pub ReservedMappedBase: ::PVOID, pub ReservedMachine: ::USHORT, pub ReservedCharacteristics: ::USHORT, pub ReservedCheckSum: ::DWORD, pub ImageBase: ::DWORD, pub SizeOfImage: ::DWORD, pub ReservedNumberOfSections: ::DWORD, pub ReservedSections: ::PIMAGE_SECTION_HEADER, pub ReservedExportedNamesSize: ::DWORD, pub ReservedExportedNames: ::PSTR, pub ReservedNumberOfFunctionTableEntries: ::DWORD, pub ReservedFunctionTableEntries: ::PIMAGE_FUNCTION_ENTRY, pub ReservedLowestFunctionStartingAddress: ::DWORD, pub ReservedHighestFunctionEndingAddress: ::DWORD, pub ReservedNumberOfFpoTableEntries: ::DWORD, pub ReservedFpoTableEntries: ::PFPO_DATA, pub SizeOfCoffSymbols: ::DWORD, pub CoffSymbols: ::PIMAGE_COFF_SYMBOLS_HEADER, pub ReservedSizeOfCodeViewSymbols: ::DWORD, pub ReservedCodeViewSymbols: ::PVOID, pub ImageFilePath: ::PSTR, pub ImageFileName: ::PSTR, pub ReservedDebugFilePath: ::PSTR, pub ReservedTimeDateStamp: ::DWORD, pub ReservedRomImage: ::BOOL, pub ReservedDebugDirectory: ::PIMAGE_DEBUG_DIRECTORY, pub ReservedNumberOfDebugDirectories: ::DWORD, pub ReservedOriginalFunctionTableBaseAddress: ::DWORD, pub Reserved: [::DWORD; 2], } #[cfg(target_arch = "x86")] pub type PIMAGE_DEBUG_INFORMATION = *mut IMAGE_DEBUG_INFORMATION; pub type PENUMDIRTREE_CALLBACK = Option ::BOOL>; pub type PENUMDIRTREE_CALLBACKW = Option ::BOOL>; pub const UNDNAME_COMPLETE: ::DWORD = 0x0000; pub const UNDNAME_NO_LEADING_UNDERSCORES: ::DWORD = 0x0001; pub const UNDNAME_NO_MS_KEYWORDS: ::DWORD = 0x0002; pub const UNDNAME_NO_FUNCTION_RETURNS: ::DWORD = 0x0004; pub const UNDNAME_NO_ALLOCATION_MODEL: ::DWORD = 0x0008; pub const UNDNAME_NO_ALLOCATION_LANGUAGE: ::DWORD = 0x0010; pub const UNDNAME_NO_MS_THISTYPE: ::DWORD = 0x0020; pub const UNDNAME_NO_CV_THISTYPE: ::DWORD = 0x0040; pub const UNDNAME_NO_THISTYPE: ::DWORD = 0x0060; pub const UNDNAME_NO_ACCESS_SPECIFIERS: ::DWORD = 0x0080; pub const UNDNAME_NO_THROW_SIGNATURES: ::DWORD = 0x0100; pub const UNDNAME_NO_MEMBER_TYPE: ::DWORD = 0x0200; pub const UNDNAME_NO_RETURN_UDT_MODEL: ::DWORD = 0x0400; pub const UNDNAME_32_BIT_DECODE: ::DWORD = 0x0800; pub const UNDNAME_NAME_ONLY: ::DWORD = 0x1000; pub const UNDNAME_NO_ARGUMENTS: ::DWORD = 0x2000; pub const UNDNAME_NO_SPECIAL_SYMS: ::DWORD = 0x4000; pub const DBHHEADER_DEBUGDIRS: ::DWORD = 0x1; pub const DBHHEADER_CVMISC: ::DWORD = 0x2; pub const DBHHEADER_PDBGUID: ::DWORD = 0x3; STRUCT!{struct MODLOAD_DATA { ssize: ::DWORD, ssig: ::DWORD, data: ::PVOID, size: ::DWORD, flags: ::DWORD, }} pub type PMODLOAD_DATA = *mut MODLOAD_DATA; STRUCT!{struct MODLOAD_CVMISC { oCV: ::DWORD, cCV: ::size_t, oMisc: ::DWORD, cMisc: ::size_t, dtImage: ::DWORD, cImage: ::DWORD, }} pub type PMODLOAD_CVMISC = *mut MODLOAD_CVMISC; STRUCT!{struct MODLOAD_PDBGUID_PDBAGE { PdbGuid: ::GUID, PdbAge: ::DWORD, }} pub type PMODLOAD_PDBGUID_PDBAGE = *mut MODLOAD_PDBGUID_PDBAGE; ENUM!{enum ADDRESS_MODE { AddrMode1616, AddrMode1632, AddrModeReal, AddrModeFlat, }} STRUCT!{struct ADDRESS64 { Offset: ::DWORD64, Segment: ::WORD, Mode: ::ADDRESS_MODE, }} pub type LPADDRESS64 = *mut ADDRESS64; #[cfg(target_arch = "x86_64")] pub type ADDRESS = ADDRESS64; #[cfg(target_arch = "x86_64")] pub type LPADDRESS = LPADDRESS64; #[repr(C)] #[derive(Clone, Copy, Debug)] #[cfg(target_arch = "x86")] pub struct ADDRESS { pub Offset: ::DWORD, pub Segment: ::WORD, pub Mode: ::ADDRESS_MODE, } #[cfg(target_arch = "x86")] pub type LPADDRESS = *mut ADDRESS; STRUCT!{struct KDHELP64 { Thread: ::DWORD64, ThCallbackStack: ::DWORD, ThCallbackBStore: ::DWORD, NextCallback: ::DWORD, FramePointer: ::DWORD, KiCallUserMode: ::DWORD64, KeUserCallbackDispatcher: ::DWORD64, SystemRangeStart: ::DWORD64, KiUserExceptionDispatcher: ::DWORD64, StackBase: ::DWORD64, StackLimit: ::DWORD64, BuildVersion: ::DWORD, Reserved0: ::DWORD, Reserved1: [::DWORD64; 4], }} pub type PKDHELP64 = *mut KDHELP64; #[cfg(target_arch = "x86_64")] pub type KDHELP = KDHELP64; #[cfg(target_arch = "x86_64")] pub type PKDHELP = PKDHELP64; #[repr(C)] #[derive(Clone, Copy, Debug)] #[cfg(target_arch = "x86")] pub struct KDHELP { pub Thread: ::DWORD, pub ThCallbackStack: ::DWORD, pub NextCallback: ::DWORD, pub FramePointer: ::DWORD, pub KiCallUserMode: ::DWORD, pub KeUserCallbackDispatcher: ::DWORD, pub SystemRangeStart: ::DWORD, pub ThCallbackBStore: ::DWORD, pub KiUserExceptionDispatcher: ::DWORD, pub StackBase: ::DWORD, pub StackLimit: ::DWORD, pub Reserved: [::DWORD; 5], } #[cfg(target_arch = "x86")] pub type PKDHELP = *mut KDHELP; STRUCT!{struct STACKFRAME64 { AddrPC: ::ADDRESS64, AddrReturn: ::ADDRESS64, AddrFrame: ::ADDRESS64, AddrStack: ::ADDRESS64, AddrBStore: ::ADDRESS64, FuncTableEntry: ::PVOID, Params: [::DWORD64; 4], Far: ::BOOL, Virtual: ::BOOL, Reserved: [::DWORD64; 3], KdHelp: ::KDHELP64, }} pub type LPSTACKFRAME64 = *mut STACKFRAME64; pub const INLINE_FRAME_CONTEXT_INIT: ::DWORD = 0; pub const INLINE_FRAME_CONTEXT_IGNORE: ::DWORD = 0xFFFFFFFF; STRUCT!{struct STACKFRAME_EX { AddrPC: ::ADDRESS64, AddrReturn: ::ADDRESS64, AddrFrame: ::ADDRESS64, AddrStack: ::ADDRESS64, AddrBStore: ::ADDRESS64, FuncTableEntry: ::PVOID, Params: [::DWORD64; 4], Far: ::BOOL, Virtual: ::BOOL, Reserved: [::DWORD64; 3], KdHelp: ::KDHELP64, StackFrameSize: ::DWORD, InlineFrameContext: ::DWORD, }} pub type LPSTACKFRAME_EX = *mut STACKFRAME_EX; #[cfg(target_arch = "x86_64")] pub type STACKFRAME = STACKFRAME64; #[cfg(target_arch = "x86_64")] pub type LPSTACKFRAME = LPSTACKFRAME64; #[repr(C)] #[derive(Clone, Copy, Debug)] #[cfg(target_arch = "x86")] pub struct STACKFRAME { pub AddrPC: ::ADDRESS, pub AddrReturn: ::ADDRESS, pub AddrFrame: ::ADDRESS, pub AddrStack: ::ADDRESS, pub FuncTableEntry: ::PVOID, pub Params: [::DWORD; 4], pub Far: ::BOOL, pub Virtual: ::BOOL, pub Reserved: [::DWORD; 3], pub KdHelp: ::KDHELP, pub AddrBStore: ::ADDRESS, } #[cfg(target_arch = "x86")] pub type LPSTACKFRAME = *mut STACKFRAME; pub type PREAD_PROCESS_MEMORY_ROUTINE64 = Option ::BOOL>; pub type PFUNCTION_TABLE_ACCESS_ROUTINE64 = Option ::PVOID>; pub type PGET_MODULE_BASE_ROUTINE64 = Option ::DWORD64>; pub type PTRANSLATE_ADDRESS_ROUTINE64 = Option ::DWORD64>; pub const SYM_STKWALK_DEFAULT: ::DWORD = 0x00000000; pub const SYM_STKWALK_FORCE_FRAMEPTR: ::DWORD = 0x00000001; #[cfg(target_arch = "x86_64")] pub type PREAD_PROCESS_MEMORY_ROUTINE = PREAD_PROCESS_MEMORY_ROUTINE64; #[cfg(target_arch = "x86_64")] pub type PFUNCTION_TABLE_ACCESS_ROUTINE = PFUNCTION_TABLE_ACCESS_ROUTINE64; #[cfg(target_arch = "x86_64")] pub type PGET_MODULE_BASE_ROUTINE = PGET_MODULE_BASE_ROUTINE64; #[cfg(target_arch = "x86_64")] pub type PTRANSLATE_ADDRESS_ROUTINE = PTRANSLATE_ADDRESS_ROUTINE64; #[cfg(target_arch = "x86")] pub type PREAD_PROCESS_MEMORY_ROUTINE = Option ::BOOL>; #[cfg(target_arch = "x86")] pub type PFUNCTION_TABLE_ACCESS_ROUTINE = Option ::PVOID>; #[cfg(target_arch = "x86")] pub type PGET_MODULE_BASE_ROUTINE = Option ::DWORD>; #[cfg(target_arch = "x86")] pub type PTRANSLATE_ADDRESS_ROUTINE = Option ::DWORD>; pub const API_VERSION_NUMBER: ::USHORT = 12; STRUCT!{struct API_VERSION { MajorVersion: ::USHORT, MinorVersion: ::USHORT, Revision: ::USHORT, Reserved: ::USHORT, }} pub type LPAPI_VERSION = *mut API_VERSION; STRUCT!{struct SYMBOL_INFOW { SizeOfStruct: ::ULONG, TypeIndex: ::ULONG, Reserved: [::ULONG64; 2], Index: ::ULONG, Size: ::ULONG, ModBase: ::ULONG64, Flags: ::ULONG, Value: ::ULONG64, Address: ::ULONG64, Register: ::ULONG, Scope: ::ULONG, Tag: ::ULONG, NameLen: ::ULONG, MaxNameLen: ::ULONG, Name: [::WCHAR; 1], }} pub type PSYMBOL_INFOW = *mut SYMBOL_INFOW; STRUCT!{struct IMAGEHLP_SYMBOL64 { SizeOfStruct: ::DWORD, Address: ::DWORD64, Size: ::DWORD, Flags: ::DWORD, MaxNameLength: ::DWORD, Name: [::CHAR; 1], }} pub type PIMAGEHLP_SYMBOL64 = *mut IMAGEHLP_SYMBOL64; STRUCT!{struct IMAGEHLP_LINEW64 { SizeOfStruct: ::DWORD, Key: ::PVOID, LineNumber: ::DWORD, FileName: ::PWSTR, Address: ::DWORD64, }} pub type PIMAGEHLP_LINEW64 = *mut IMAGEHLP_LINEW64; deps/winapi-0.2.5/src/d3d11.rs0000644000000000000000000040620512613172672014425 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License pub const D3D11_16BIT_INDEX_STRIP_CUT_VALUE: ::DWORD = 0xffff; pub const D3D11_32BIT_INDEX_STRIP_CUT_VALUE: ::DWORD = 0xffffffff; pub const D3D11_8BIT_INDEX_STRIP_CUT_VALUE: ::DWORD = 0xff; pub const D3D11_ARRAY_AXIS_ADDRESS_RANGE_BIT_COUNT: ::DWORD = 9; pub const D3D11_CLIP_OR_CULL_DISTANCE_COUNT: ::DWORD = 8; pub const D3D11_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT: ::DWORD = 2; pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT: ::DWORD = 14; pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_COMPONENTS: ::DWORD = 4; pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_HW_SLOT_COUNT: ::DWORD = 15; pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_PARTIAL_UPDATE_EXTENTS_BYTE_ALIGNMENT: ::DWORD = 16; pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COMPONENTS: ::DWORD = 4; pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COUNT: ::DWORD = 15; pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READS_PER_INST: ::DWORD = 1; pub const D3D11_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_COMMONSHADER_FLOWCONTROL_NESTING_LIMIT: ::DWORD = 64; pub const D3D11_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COMPONENTS: ::DWORD = 4; pub const D3D11_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COUNT: ::DWORD = 1; pub const D3D11_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READS_PER_INST: ::DWORD = 1; pub const D3D11_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_COMMONSHADER_IMMEDIATE_VALUE_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_COMPONENTS: ::DWORD = 1; pub const D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_COUNT: ::DWORD = 128; pub const D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_READS_PER_INST: ::DWORD = 1; pub const D3D11_COMMONSHADER_INPUT_RESOURCE_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT: ::DWORD = 128; pub const D3D11_COMMONSHADER_SAMPLER_REGISTER_COMPONENTS: ::DWORD = 1; pub const D3D11_COMMONSHADER_SAMPLER_REGISTER_COUNT: ::DWORD = 16; pub const D3D11_COMMONSHADER_SAMPLER_REGISTER_READS_PER_INST: ::DWORD = 1; pub const D3D11_COMMONSHADER_SAMPLER_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT: ::DWORD = 16; pub const D3D11_COMMONSHADER_SUBROUTINE_NESTING_LIMIT: ::DWORD = 32; pub const D3D11_COMMONSHADER_TEMP_REGISTER_COMPONENTS: ::DWORD = 4; pub const D3D11_COMMONSHADER_TEMP_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_COMMONSHADER_TEMP_REGISTER_COUNT: ::DWORD = 4096; pub const D3D11_COMMONSHADER_TEMP_REGISTER_READS_PER_INST: ::DWORD = 3; pub const D3D11_COMMONSHADER_TEMP_REGISTER_READ_PORTS: ::DWORD = 3; pub const D3D11_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MAX: ::DWORD = 10; pub const D3D11_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MIN: ::c_long = -10; pub const D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE: ::c_long = -8; pub const D3D11_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE: ::DWORD = 7; pub const D3D11_CS_4_X_BUCKET00_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::DWORD = 256; pub const D3D11_CS_4_X_BUCKET00_MAX_NUM_THREADS_PER_GROUP: ::DWORD = 64; pub const D3D11_CS_4_X_BUCKET01_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::DWORD = 240; pub const D3D11_CS_4_X_BUCKET01_MAX_NUM_THREADS_PER_GROUP: ::DWORD = 68; pub const D3D11_CS_4_X_BUCKET02_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::DWORD = 224; pub const D3D11_CS_4_X_BUCKET02_MAX_NUM_THREADS_PER_GROUP: ::DWORD = 72; pub const D3D11_CS_4_X_BUCKET03_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::DWORD = 208; pub const D3D11_CS_4_X_BUCKET03_MAX_NUM_THREADS_PER_GROUP: ::DWORD = 76; pub const D3D11_CS_4_X_BUCKET04_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::DWORD = 192; pub const D3D11_CS_4_X_BUCKET04_MAX_NUM_THREADS_PER_GROUP: ::DWORD = 84; pub const D3D11_CS_4_X_BUCKET05_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::DWORD = 176; pub const D3D11_CS_4_X_BUCKET05_MAX_NUM_THREADS_PER_GROUP: ::DWORD = 92; pub const D3D11_CS_4_X_BUCKET06_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::DWORD = 160; pub const D3D11_CS_4_X_BUCKET06_MAX_NUM_THREADS_PER_GROUP: ::DWORD = 100; pub const D3D11_CS_4_X_BUCKET07_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::DWORD = 144; pub const D3D11_CS_4_X_BUCKET07_MAX_NUM_THREADS_PER_GROUP: ::DWORD = 112; pub const D3D11_CS_4_X_BUCKET08_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::DWORD = 128; pub const D3D11_CS_4_X_BUCKET08_MAX_NUM_THREADS_PER_GROUP: ::DWORD = 128; pub const D3D11_CS_4_X_BUCKET09_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::DWORD = 112; pub const D3D11_CS_4_X_BUCKET09_MAX_NUM_THREADS_PER_GROUP: ::DWORD = 144; pub const D3D11_CS_4_X_BUCKET10_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::DWORD = 96; pub const D3D11_CS_4_X_BUCKET10_MAX_NUM_THREADS_PER_GROUP: ::DWORD = 168; pub const D3D11_CS_4_X_BUCKET11_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::DWORD = 80; pub const D3D11_CS_4_X_BUCKET11_MAX_NUM_THREADS_PER_GROUP: ::DWORD = 204; pub const D3D11_CS_4_X_BUCKET12_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::DWORD = 64; pub const D3D11_CS_4_X_BUCKET12_MAX_NUM_THREADS_PER_GROUP: ::DWORD = 256; pub const D3D11_CS_4_X_BUCKET13_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::DWORD = 48; pub const D3D11_CS_4_X_BUCKET13_MAX_NUM_THREADS_PER_GROUP: ::DWORD = 340; pub const D3D11_CS_4_X_BUCKET14_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::DWORD = 32; pub const D3D11_CS_4_X_BUCKET14_MAX_NUM_THREADS_PER_GROUP: ::DWORD = 512; pub const D3D11_CS_4_X_BUCKET15_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::DWORD = 16; pub const D3D11_CS_4_X_BUCKET15_MAX_NUM_THREADS_PER_GROUP: ::DWORD = 768; pub const D3D11_CS_4_X_DISPATCH_MAX_THREAD_GROUPS_IN_Z_DIMENSION: ::DWORD = 1; pub const D3D11_CS_4_X_RAW_UAV_BYTE_ALIGNMENT: ::DWORD = 256; pub const D3D11_CS_4_X_THREAD_GROUP_MAX_THREADS_PER_GROUP: ::DWORD = 768; pub const D3D11_CS_4_X_THREAD_GROUP_MAX_X: ::DWORD = 768; pub const D3D11_CS_4_X_THREAD_GROUP_MAX_Y: ::DWORD = 768; pub const D3D11_CS_4_X_UAV_REGISTER_COUNT: ::DWORD = 1; pub const D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION: ::DWORD = 65535; pub const D3D11_CS_TGSM_REGISTER_COUNT: ::DWORD = 8192; pub const D3D11_CS_TGSM_REGISTER_READS_PER_INST: ::DWORD = 1; pub const D3D11_CS_TGSM_RESOURCE_REGISTER_COMPONENTS: ::DWORD = 1; pub const D3D11_CS_TGSM_RESOURCE_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_CS_THREADGROUPID_REGISTER_COMPONENTS: ::DWORD = 3; pub const D3D11_CS_THREADGROUPID_REGISTER_COUNT: ::DWORD = 1; pub const D3D11_CS_THREADIDINGROUPFLATTENED_REGISTER_COMPONENTS: ::DWORD = 1; pub const D3D11_CS_THREADIDINGROUPFLATTENED_REGISTER_COUNT: ::DWORD = 1; pub const D3D11_CS_THREADIDINGROUP_REGISTER_COMPONENTS: ::DWORD = 3; pub const D3D11_CS_THREADIDINGROUP_REGISTER_COUNT: ::DWORD = 1; pub const D3D11_CS_THREADID_REGISTER_COMPONENTS: ::DWORD = 3; pub const D3D11_CS_THREADID_REGISTER_COUNT: ::DWORD = 1; pub const D3D11_CS_THREAD_GROUP_MAX_THREADS_PER_GROUP: ::DWORD = 1024; pub const D3D11_CS_THREAD_GROUP_MAX_X: ::DWORD = 1024; pub const D3D11_CS_THREAD_GROUP_MAX_Y: ::DWORD = 1024; pub const D3D11_CS_THREAD_GROUP_MAX_Z: ::DWORD = 64; pub const D3D11_CS_THREAD_GROUP_MIN_X: ::DWORD = 1; pub const D3D11_CS_THREAD_GROUP_MIN_Y: ::DWORD = 1; pub const D3D11_CS_THREAD_GROUP_MIN_Z: ::DWORD = 1; pub const D3D11_CS_THREAD_LOCAL_TEMP_REGISTER_POOL: ::DWORD = 16384; pub const D3D11_DEFAULT_BLEND_FACTOR_ALPHA: ::FLOAT = 1.0; pub const D3D11_DEFAULT_BLEND_FACTOR_BLUE: ::FLOAT = 1.0; pub const D3D11_DEFAULT_BLEND_FACTOR_GREEN: ::FLOAT = 1.0; pub const D3D11_DEFAULT_BLEND_FACTOR_RED: ::FLOAT = 1.0; pub const D3D11_DEFAULT_BORDER_COLOR_COMPONENT: ::FLOAT = 0.0; pub const D3D11_DEFAULT_DEPTH_BIAS: ::DWORD = 0; pub const D3D11_DEFAULT_DEPTH_BIAS_CLAMP: ::FLOAT = 0.0; pub const D3D11_DEFAULT_MAX_ANISOTROPY: ::DWORD = 16; pub const D3D11_DEFAULT_MIP_LOD_BIAS: ::FLOAT = 0.0; pub const D3D11_DEFAULT_RENDER_TARGET_ARRAY_INDEX: ::DWORD = 0; pub const D3D11_DEFAULT_SAMPLE_MASK: ::DWORD = 0xffffffff; pub const D3D11_DEFAULT_SCISSOR_ENDX: ::DWORD = 0; pub const D3D11_DEFAULT_SCISSOR_ENDY: ::DWORD = 0; pub const D3D11_DEFAULT_SCISSOR_STARTX: ::DWORD = 0; pub const D3D11_DEFAULT_SCISSOR_STARTY: ::DWORD = 0; pub const D3D11_DEFAULT_SLOPE_SCALED_DEPTH_BIAS: ::FLOAT = 0.0; pub const D3D11_DEFAULT_STENCIL_READ_MASK: ::DWORD = 0xff; pub const D3D11_DEFAULT_STENCIL_REFERENCE: ::DWORD = 0; pub const D3D11_DEFAULT_STENCIL_WRITE_MASK: ::DWORD = 0xff; pub const D3D11_DEFAULT_VIEWPORT_AND_SCISSORRECT_INDEX: ::DWORD = 0; pub const D3D11_DEFAULT_VIEWPORT_HEIGHT: ::DWORD = 0; pub const D3D11_DEFAULT_VIEWPORT_MAX_DEPTH: ::FLOAT = 0.0; pub const D3D11_DEFAULT_VIEWPORT_MIN_DEPTH: ::FLOAT = 0.0; pub const D3D11_DEFAULT_VIEWPORT_TOPLEFTX: ::DWORD = 0; pub const D3D11_DEFAULT_VIEWPORT_TOPLEFTY: ::DWORD = 0; pub const D3D11_DEFAULT_VIEWPORT_WIDTH: ::DWORD = 0; pub const D3D11_DS_INPUT_CONTROL_POINTS_MAX_TOTAL_SCALARS: ::DWORD = 3968; pub const D3D11_DS_INPUT_CONTROL_POINT_REGISTER_COMPONENTS: ::DWORD = 4; pub const D3D11_DS_INPUT_CONTROL_POINT_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_DS_INPUT_CONTROL_POINT_REGISTER_COUNT: ::DWORD = 32; pub const D3D11_DS_INPUT_CONTROL_POINT_REGISTER_READS_PER_INST: ::DWORD = 2; pub const D3D11_DS_INPUT_CONTROL_POINT_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_COMPONENTS: ::DWORD = 3; pub const D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_COUNT: ::DWORD = 1; pub const D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_READS_PER_INST: ::DWORD = 2; pub const D3D11_DS_INPUT_DOMAIN_POINT_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_COMPONENTS: ::DWORD = 4; pub const D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_COUNT: ::DWORD = 32; pub const D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_READS_PER_INST: ::DWORD = 2; pub const D3D11_DS_INPUT_PATCH_CONSTANT_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_DS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENTS: ::DWORD = 1; pub const D3D11_DS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_DS_INPUT_PRIMITIVE_ID_REGISTER_COUNT: ::DWORD = 1; pub const D3D11_DS_INPUT_PRIMITIVE_ID_REGISTER_READS_PER_INST: ::DWORD = 2; pub const D3D11_DS_INPUT_PRIMITIVE_ID_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_DS_OUTPUT_REGISTER_COMPONENTS: ::DWORD = 4; pub const D3D11_DS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_DS_OUTPUT_REGISTER_COUNT: ::DWORD = 32; pub const D3D11_FLOAT16_FUSED_TOLERANCE_IN_ULP: ::FLOAT = 0.6; pub const D3D11_FLOAT32_MAX: ::FLOAT = 3.402823466E+38; pub const D3D11_FLOAT32_TO_INTEGER_TOLERANCE_IN_ULP: ::FLOAT = 0.6; pub const D3D11_FLOAT_TO_SRGB_EXPONENT_DENOMINATOR: ::FLOAT = 2.4; pub const D3D11_FLOAT_TO_SRGB_EXPONENT_NUMERATOR: ::FLOAT = 1.0; pub const D3D11_FLOAT_TO_SRGB_OFFSET: ::FLOAT = 0.055; pub const D3D11_FLOAT_TO_SRGB_SCALE_1: ::FLOAT = 12.92; pub const D3D11_FLOAT_TO_SRGB_SCALE_2: ::FLOAT = 1.055; pub const D3D11_FLOAT_TO_SRGB_THRESHOLD: ::FLOAT = 0.0031308; pub const D3D11_FTOI_INSTRUCTION_MAX_INPUT: ::FLOAT = 2147483647.999; pub const D3D11_FTOI_INSTRUCTION_MIN_INPUT: ::FLOAT = -2147483648.999; pub const D3D11_FTOU_INSTRUCTION_MAX_INPUT: ::FLOAT = 4294967295.999; pub const D3D11_FTOU_INSTRUCTION_MIN_INPUT: ::FLOAT = 0.0; pub const D3D11_GS_INPUT_INSTANCE_ID_READS_PER_INST: ::DWORD = 2; pub const D3D11_GS_INPUT_INSTANCE_ID_READ_PORTS: ::DWORD = 1; pub const D3D11_GS_INPUT_INSTANCE_ID_REGISTER_COMPONENTS: ::DWORD = 1; pub const D3D11_GS_INPUT_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_GS_INPUT_INSTANCE_ID_REGISTER_COUNT: ::DWORD = 1; pub const D3D11_GS_INPUT_PRIM_CONST_REGISTER_COMPONENTS: ::DWORD = 1; pub const D3D11_GS_INPUT_PRIM_CONST_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_GS_INPUT_PRIM_CONST_REGISTER_COUNT: ::DWORD = 1; pub const D3D11_GS_INPUT_PRIM_CONST_REGISTER_READS_PER_INST: ::DWORD = 2; pub const D3D11_GS_INPUT_PRIM_CONST_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_GS_INPUT_REGISTER_COMPONENTS: ::DWORD = 4; pub const D3D11_GS_INPUT_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_GS_INPUT_REGISTER_COUNT: ::DWORD = 32; pub const D3D11_GS_INPUT_REGISTER_READS_PER_INST: ::DWORD = 2; pub const D3D11_GS_INPUT_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_GS_INPUT_REGISTER_VERTICES: ::DWORD = 32; pub const D3D11_GS_MAX_INSTANCE_COUNT: ::DWORD = 32; pub const D3D11_GS_MAX_OUTPUT_VERTEX_COUNT_ACROSS_INSTANCES: ::DWORD = 1024; pub const D3D11_GS_OUTPUT_ELEMENTS: ::DWORD = 32; pub const D3D11_GS_OUTPUT_REGISTER_COMPONENTS: ::DWORD = 4; pub const D3D11_GS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_GS_OUTPUT_REGISTER_COUNT: ::DWORD = 32; pub const D3D11_HS_CONTROL_POINT_PHASE_INPUT_REGISTER_COUNT: ::DWORD = 32; pub const D3D11_HS_CONTROL_POINT_PHASE_OUTPUT_REGISTER_COUNT: ::DWORD = 32; pub const D3D11_HS_CONTROL_POINT_REGISTER_COMPONENTS: ::DWORD = 4; pub const D3D11_HS_CONTROL_POINT_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_HS_CONTROL_POINT_REGISTER_READS_PER_INST: ::DWORD = 2; pub const D3D11_HS_CONTROL_POINT_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_HS_FORK_PHASE_INSTANCE_COUNT_UPPER_BOUND: ::DWORD = 0xffffffff; pub const D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COMPONENTS: ::DWORD = 1; pub const D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COUNT: ::DWORD = 1; pub const D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_READS_PER_INST: ::DWORD = 2; pub const D3D11_HS_INPUT_FORK_INSTANCE_ID_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COMPONENTS: ::DWORD = 1; pub const D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COUNT: ::DWORD = 1; pub const D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_READS_PER_INST: ::DWORD = 2; pub const D3D11_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENTS: ::DWORD = 1; pub const D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_COUNT: ::DWORD = 1; pub const D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_READS_PER_INST: ::DWORD = 2; pub const D3D11_HS_INPUT_PRIMITIVE_ID_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_HS_JOIN_PHASE_INSTANCE_COUNT_UPPER_BOUND: ::DWORD = 0xffffffff; pub const D3D11_HS_MAXTESSFACTOR_LOWER_BOUND: ::FLOAT = 1.0; pub const D3D11_HS_MAXTESSFACTOR_UPPER_BOUND: ::FLOAT = 64.0; pub const D3D11_HS_OUTPUT_CONTROL_POINTS_MAX_TOTAL_SCALARS: ::DWORD = 3968; pub const D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COMPONENTS: ::DWORD = 1; pub const D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COUNT: ::DWORD = 1; pub const D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_READS_PER_INST: ::DWORD = 2; pub const D3D11_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COMPONENTS: ::DWORD = 4; pub const D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COUNT: ::DWORD = 32; pub const D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_READS_PER_INST: ::DWORD = 2; pub const D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_HS_OUTPUT_PATCH_CONSTANT_REGISTER_SCALAR_COMPONENTS: ::DWORD = 128; pub const D3D11_IA_DEFAULT_INDEX_BUFFER_OFFSET_IN_BYTES: ::DWORD = 0; pub const D3D11_IA_DEFAULT_PRIMITIVE_TOPOLOGY: ::DWORD = 0; pub const D3D11_IA_DEFAULT_VERTEX_BUFFER_OFFSET_IN_BYTES: ::DWORD = 0; pub const D3D11_IA_INDEX_INPUT_RESOURCE_SLOT_COUNT: ::DWORD = 1; pub const D3D11_IA_INSTANCE_ID_BIT_COUNT: ::DWORD = 32; pub const D3D11_IA_INTEGER_ARITHMETIC_BIT_COUNT: ::DWORD = 32; pub const D3D11_IA_PATCH_MAX_CONTROL_POINT_COUNT: ::DWORD = 32; pub const D3D11_IA_PRIMITIVE_ID_BIT_COUNT: ::DWORD = 32; pub const D3D11_IA_VERTEX_ID_BIT_COUNT: ::DWORD = 32; pub const D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT: ::DWORD = 32; pub const D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENTS_COMPONENTS: ::DWORD = 128; pub const D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT: ::DWORD = 32; pub const D3D11_INTEGER_DIVIDE_BY_ZERO_QUOTIENT: ::DWORD = 0xffffffff; pub const D3D11_INTEGER_DIVIDE_BY_ZERO_REMAINDER: ::DWORD = 0xffffffff; pub const D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL: ::DWORD = 0xffffffff; pub const D3D11_KEEP_UNORDERED_ACCESS_VIEWS: ::DWORD = 0xffffffff; pub const D3D11_LINEAR_GAMMA: ::FLOAT = 1.0; pub const D3D11_MAJOR_VERSION: ::DWORD = 11; pub const D3D11_MAX_BORDER_COLOR_COMPONENT: ::FLOAT = 1.0; pub const D3D11_MAX_DEPTH: ::FLOAT = 1.0; pub const D3D11_MAX_MAXANISOTROPY: ::DWORD = 16; pub const D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT: ::DWORD = 32; pub const D3D11_MAX_POSITION_VALUE: ::FLOAT = 3.402823466E+34; pub const D3D11_MAX_TEXTURE_DIMENSION_2_TO_EXP: ::DWORD = 17; pub const D3D11_MINOR_VERSION: ::DWORD = 0; pub const D3D11_MIN_BORDER_COLOR_COMPONENT: ::FLOAT = 0.0; pub const D3D11_MIN_DEPTH: ::FLOAT = 0.0; pub const D3D11_MIN_MAXANISOTROPY: ::DWORD = 0; pub const D3D11_MIP_LOD_BIAS_MAX: ::FLOAT = 15.99; pub const D3D11_MIP_LOD_BIAS_MIN: ::FLOAT = -16.0; pub const D3D11_MIP_LOD_FRACTIONAL_BIT_COUNT: ::DWORD = 8; pub const D3D11_MIP_LOD_RANGE_BIT_COUNT: ::DWORD = 8; pub const D3D11_MULTISAMPLE_ANTIALIAS_LINE_WIDTH: ::FLOAT = 1.4; pub const D3D11_NONSAMPLE_FETCH_OUT_OF_RANGE_ACCESS_RESULT: ::DWORD = 0; pub const D3D11_PIXEL_ADDRESS_RANGE_BIT_COUNT: ::DWORD = 15; pub const D3D11_PRE_SCISSOR_PIXEL_ADDRESS_RANGE_BIT_COUNT: ::DWORD = 16; pub const D3D11_PS_CS_UAV_REGISTER_COMPONENTS: ::DWORD = 1; pub const D3D11_PS_CS_UAV_REGISTER_COUNT: ::DWORD = 8; pub const D3D11_PS_CS_UAV_REGISTER_READS_PER_INST: ::DWORD = 1; pub const D3D11_PS_CS_UAV_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_PS_FRONTFACING_DEFAULT_VALUE: ::DWORD = 0xffffffff; pub const D3D11_PS_FRONTFACING_FALSE_VALUE: ::DWORD = 0; pub const D3D11_PS_FRONTFACING_TRUE_VALUE: ::DWORD = 0xffffffff; pub const D3D11_PS_INPUT_REGISTER_COMPONENTS: ::DWORD = 4; pub const D3D11_PS_INPUT_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_PS_INPUT_REGISTER_COUNT: ::DWORD = 32; pub const D3D11_PS_INPUT_REGISTER_READS_PER_INST: ::DWORD = 2; pub const D3D11_PS_INPUT_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_PS_LEGACY_PIXEL_CENTER_FRACTIONAL_COMPONENT: ::FLOAT = 0.0; pub const D3D11_PS_OUTPUT_DEPTH_REGISTER_COMPONENTS: ::DWORD = 1; pub const D3D11_PS_OUTPUT_DEPTH_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_PS_OUTPUT_DEPTH_REGISTER_COUNT: ::DWORD = 1; pub const D3D11_PS_OUTPUT_MASK_REGISTER_COMPONENTS: ::DWORD = 1; pub const D3D11_PS_OUTPUT_MASK_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_PS_OUTPUT_MASK_REGISTER_COUNT: ::DWORD = 1; pub const D3D11_PS_OUTPUT_REGISTER_COMPONENTS: ::DWORD = 4; pub const D3D11_PS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_PS_OUTPUT_REGISTER_COUNT: ::DWORD = 8; pub const D3D11_PS_PIXEL_CENTER_FRACTIONAL_COMPONENT: ::FLOAT = 0.5; pub const D3D11_RAW_UAV_SRV_BYTE_ALIGNMENT: ::DWORD = 16; pub const D3D11_REQ_BLEND_OBJECT_COUNT_PER_DEVICE: ::DWORD = 4096; pub const D3D11_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP: ::DWORD = 27; pub const D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT: ::DWORD = 4096; pub const D3D11_REQ_DEPTH_STENCIL_OBJECT_COUNT_PER_DEVICE: ::DWORD = 4096; pub const D3D11_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP: ::DWORD = 32; pub const D3D11_REQ_DRAW_VERTEX_COUNT_2_TO_EXP: ::DWORD = 32; pub const D3D11_REQ_FILTERING_HW_ADDRESSABLE_RESOURCE_DIMENSION: ::DWORD = 16384; pub const D3D11_REQ_GS_INVOCATION_32BIT_OUTPUT_COMPONENT_LIMIT: ::DWORD = 1024; pub const D3D11_REQ_IMMEDIATE_CONSTANT_BUFFER_ELEMENT_COUNT: ::DWORD = 4096; pub const D3D11_REQ_MAXANISOTROPY: ::DWORD = 16; pub const D3D11_REQ_MIP_LEVELS: ::DWORD = 15; pub const D3D11_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES: ::DWORD = 2048; pub const D3D11_REQ_RASTERIZER_OBJECT_COUNT_PER_DEVICE: ::DWORD = 4096; pub const D3D11_REQ_RENDER_TO_BUFFER_WINDOW_WIDTH: ::DWORD = 16384; pub const D3D11_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_A_TERM: ::DWORD = 128; pub const D3D11_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_B_TERM: ::FLOAT = 0.25; pub const D3D11_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_C_TERM: ::DWORD = 2048; pub const D3D11_REQ_RESOURCE_VIEW_COUNT_PER_DEVICE_2_TO_EXP: ::DWORD = 20; pub const D3D11_REQ_SAMPLER_OBJECT_COUNT_PER_DEVICE: ::DWORD = 4096; pub const D3D11_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION: ::DWORD = 2048; pub const D3D11_REQ_TEXTURE1D_U_DIMENSION: ::DWORD = 16384; pub const D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION: ::DWORD = 2048; pub const D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION: ::DWORD = 16384; pub const D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION: ::DWORD = 2048; pub const D3D11_REQ_TEXTURECUBE_DIMENSION: ::DWORD = 16384; pub const D3D11_RESINFO_INSTRUCTION_MISSING_COMPONENT_RETVAL: ::DWORD = 0; pub const D3D11_SHADER_MAJOR_VERSION: ::DWORD = 5; pub const D3D11_SHADER_MAX_INSTANCES: ::DWORD = 65535; pub const D3D11_SHADER_MAX_INTERFACES: ::DWORD = 253; pub const D3D11_SHADER_MAX_INTERFACE_CALL_SITES: ::DWORD = 4096; pub const D3D11_SHADER_MAX_TYPES: ::DWORD = 65535; pub const D3D11_SHADER_MINOR_VERSION: ::DWORD = 0; pub const D3D11_SHIFT_INSTRUCTION_PAD_VALUE: ::DWORD = 0; pub const D3D11_SHIFT_INSTRUCTION_SHIFT_VALUE_BIT_COUNT: ::DWORD = 5; pub const D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT: ::DWORD = 8; pub const D3D11_SO_BUFFER_MAX_STRIDE_IN_BYTES: ::DWORD = 2048; pub const D3D11_SO_BUFFER_MAX_WRITE_WINDOW_IN_BYTES: ::DWORD = 512; pub const D3D11_SO_BUFFER_SLOT_COUNT: ::DWORD = 4; pub const D3D11_SO_DDI_REGISTER_INDEX_DENOTING_GAP: ::DWORD = 0xffffffff; pub const D3D11_SO_NO_RASTERIZED_STREAM: ::DWORD = 0xffffffff; pub const D3D11_SO_OUTPUT_COMPONENT_COUNT: ::DWORD = 128; pub const D3D11_SO_STREAM_COUNT: ::DWORD = 4; pub const D3D11_SPEC_DATE_DAY: ::DWORD = 16; pub const D3D11_SPEC_DATE_MONTH: ::DWORD = 05; pub const D3D11_SPEC_DATE_YEAR: ::DWORD = 2011; pub const D3D11_SPEC_VERSION: ::FLOAT = 1.07; pub const D3D11_SRGB_GAMMA: ::FLOAT = 2.2; pub const D3D11_SRGB_TO_FLOAT_DENOMINATOR_1: ::FLOAT = 12.92; pub const D3D11_SRGB_TO_FLOAT_DENOMINATOR_2: ::FLOAT = 1.055; pub const D3D11_SRGB_TO_FLOAT_EXPONENT: ::FLOAT = 2.4; pub const D3D11_SRGB_TO_FLOAT_OFFSET: ::FLOAT = 0.055; pub const D3D11_SRGB_TO_FLOAT_THRESHOLD: ::FLOAT = 0.04045; pub const D3D11_SRGB_TO_FLOAT_TOLERANCE_IN_ULP: ::FLOAT = 0.5; pub const D3D11_STANDARD_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_STANDARD_COMPONENT_BIT_COUNT_DOUBLED: ::DWORD = 64; pub const D3D11_STANDARD_MAXIMUM_ELEMENT_ALIGNMENT_BYTE_MULTIPLE: ::DWORD = 4; pub const D3D11_STANDARD_PIXEL_COMPONENT_COUNT: ::DWORD = 128; pub const D3D11_STANDARD_PIXEL_ELEMENT_COUNT: ::DWORD = 32; pub const D3D11_STANDARD_VECTOR_SIZE: ::DWORD = 4; pub const D3D11_STANDARD_VERTEX_ELEMENT_COUNT: ::DWORD = 32; pub const D3D11_STANDARD_VERTEX_TOTAL_COMPONENT_COUNT: ::DWORD = 64; pub const D3D11_SUBPIXEL_FRACTIONAL_BIT_COUNT: ::DWORD = 8; pub const D3D11_SUBTEXEL_FRACTIONAL_BIT_COUNT: ::DWORD = 8; pub const D3D11_TESSELLATOR_MAX_EVEN_TESSELLATION_FACTOR: ::DWORD = 64; pub const D3D11_TESSELLATOR_MAX_ISOLINE_DENSITY_TESSELLATION_FACTOR: ::DWORD = 64; pub const D3D11_TESSELLATOR_MAX_ODD_TESSELLATION_FACTOR: ::DWORD = 63; pub const D3D11_TESSELLATOR_MAX_TESSELLATION_FACTOR: ::DWORD = 64; pub const D3D11_TESSELLATOR_MIN_EVEN_TESSELLATION_FACTOR: ::DWORD = 2; pub const D3D11_TESSELLATOR_MIN_ISOLINE_DENSITY_TESSELLATION_FACTOR: ::DWORD = 1; pub const D3D11_TESSELLATOR_MIN_ODD_TESSELLATION_FACTOR: ::DWORD = 1; pub const D3D11_TEXEL_ADDRESS_RANGE_BIT_COUNT: ::DWORD = 16; pub const D3D11_UNBOUND_MEMORY_ACCESS_RESULT: ::DWORD = 0; pub const D3D11_VIEWPORT_AND_SCISSORRECT_MAX_INDEX: ::DWORD = 15; pub const D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE: ::DWORD = 16; pub const D3D11_VIEWPORT_BOUNDS_MAX: ::DWORD = 32767; pub const D3D11_VIEWPORT_BOUNDS_MIN: ::c_long = -32768; pub const D3D11_VS_INPUT_REGISTER_COMPONENTS: ::DWORD = 4; pub const D3D11_VS_INPUT_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_VS_INPUT_REGISTER_COUNT: ::DWORD = 32; pub const D3D11_VS_INPUT_REGISTER_READS_PER_INST: ::DWORD = 2; pub const D3D11_VS_INPUT_REGISTER_READ_PORTS: ::DWORD = 1; pub const D3D11_VS_OUTPUT_REGISTER_COMPONENTS: ::DWORD = 4; pub const D3D11_VS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT: ::DWORD = 32; pub const D3D11_VS_OUTPUT_REGISTER_COUNT: ::DWORD = 32; pub const D3D11_WHQL_CONTEXT_COUNT_FOR_RESOURCE_LIMIT: ::DWORD = 10; pub const D3D11_WHQL_DRAWINDEXED_INDEX_COUNT_2_TO_EXP: ::DWORD = 25; pub const D3D11_WHQL_DRAW_VERTEX_COUNT_2_TO_EXP: ::DWORD = 25; ENUM!{enum D3D11_INPUT_CLASSIFICATION { D3D11_INPUT_PER_VERTEX_DATA = 0, D3D11_INPUT_PER_INSTANCE_DATA = 1, }} pub const D3D11_APPEND_ALIGNED_ELEMENT: ::DWORD = 0xffffffff; STRUCT!{struct D3D11_INPUT_ELEMENT_DESC { SemanticName: ::LPCSTR, SemanticIndex: ::UINT, Format: ::DXGI_FORMAT, InputSlot: ::UINT, AlignedByteOffset: ::UINT, InputSlotClass: ::D3D11_INPUT_CLASSIFICATION, InstanceDataStepRate: ::UINT, }} ENUM!{enum D3D11_FILL_MODE { D3D11_FILL_WIREFRAME = 2, D3D11_FILL_SOLID = 3, }} pub type D3D11_PRIMITIVE_TOPOLOGY = ::D3D_PRIMITIVE_TOPOLOGY; pub type D3D11_PRIMITIVE = ::D3D_PRIMITIVE; ENUM!{enum D3D11_CULL_MODE { D3D11_CULL_NONE = 1, D3D11_CULL_FRONT = 2, D3D11_CULL_BACK = 3, }} STRUCT!{struct D3D11_SO_DECLARATION_ENTRY { Stream: ::UINT, SemanticName: ::LPCSTR, SemanticIndex: ::UINT, StartComponent: ::BYTE, ComponentCount: ::BYTE, OutputSlot: ::BYTE, }} STRUCT!{struct D3D11_VIEWPORT { TopLeftX: ::FLOAT, TopLeftY: ::FLOAT, Width: ::FLOAT, Height: ::FLOAT, MinDepth: ::FLOAT, MaxDepth: ::FLOAT, }} STRUCT!{struct D3D11_DRAW_INSTANCED_INDIRECT_ARGS { VertexCountPerInstance: ::UINT, InstanceCount: ::UINT, StartVertexLocation: ::UINT, StartInstanceLocation: ::UINT, }} STRUCT!{struct D3D11_DRAW_INDEXED_INSTANCED_INDIRECT_ARGS { IndexCountPerInstance: ::UINT, InstanceCount: ::UINT, StartIndexLocation: ::UINT, BaseVertexLocation: ::INT, StartInstanceLocation: ::UINT, }} ENUM!{enum D3D11_RESOURCE_DIMENSION { D3D11_RESOURCE_DIMENSION_UNKNOWN = 0, D3D11_RESOURCE_DIMENSION_BUFFER = 1, D3D11_RESOURCE_DIMENSION_TEXTURE1D = 2, D3D11_RESOURCE_DIMENSION_TEXTURE2D = 3, D3D11_RESOURCE_DIMENSION_TEXTURE3D = 4, }} pub type D3D11_SRV_DIMENSION = ::D3D_SRV_DIMENSION; ENUM!{enum D3D11_DSV_DIMENSION { D3D11_DSV_DIMENSION_UNKNOWN = 0, D3D11_DSV_DIMENSION_TEXTURE1D = 1, D3D11_DSV_DIMENSION_TEXTURE1DARRAY = 2, D3D11_DSV_DIMENSION_TEXTURE2D = 3, D3D11_DSV_DIMENSION_TEXTURE2DARRAY = 4, D3D11_DSV_DIMENSION_TEXTURE2DMS = 5, D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY = 6, }} ENUM!{enum D3D11_RTV_DIMENSION { D3D11_RTV_DIMENSION_UNKNOWN = 0, D3D11_RTV_DIMENSION_BUFFER = 1, D3D11_RTV_DIMENSION_TEXTURE1D = 2, D3D11_RTV_DIMENSION_TEXTURE1DARRAY = 3, D3D11_RTV_DIMENSION_TEXTURE2D = 4, D3D11_RTV_DIMENSION_TEXTURE2DARRAY = 5, D3D11_RTV_DIMENSION_TEXTURE2DMS = 6, D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY = 7, D3D11_RTV_DIMENSION_TEXTURE3D = 8, }} ENUM!{enum D3D11_UAV_DIMENSION { D3D11_UAV_DIMENSION_UNKNOWN = 0, D3D11_UAV_DIMENSION_BUFFER = 1, D3D11_UAV_DIMENSION_TEXTURE1D = 2, D3D11_UAV_DIMENSION_TEXTURE1DARRAY = 3, D3D11_UAV_DIMENSION_TEXTURE2D = 4, D3D11_UAV_DIMENSION_TEXTURE2DARRAY = 5, D3D11_UAV_DIMENSION_TEXTURE3D = 8, }} ENUM!{enum D3D11_USAGE { D3D11_USAGE_DEFAULT = 0, D3D11_USAGE_IMMUTABLE = 1, D3D11_USAGE_DYNAMIC = 2, D3D11_USAGE_STAGING = 3, }} FLAGS!{enum D3D11_BIND_FLAG { D3D11_BIND_VERTEX_BUFFER = 0x1, D3D11_BIND_INDEX_BUFFER = 0x2, D3D11_BIND_CONSTANT_BUFFER = 0x4, D3D11_BIND_SHADER_RESOURCE = 0x8, D3D11_BIND_STREAM_OUTPUT = 0x10, D3D11_BIND_RENDER_TARGET = 0x20, D3D11_BIND_DEPTH_STENCIL = 0x40, D3D11_BIND_UNORDERED_ACCESS = 0x80, D3D11_BIND_DECODER = 0x200, D3D11_BIND_VIDEO_ENCODER = 0x400, }} FLAGS!{enum D3D11_CPU_ACCESS_FLAG { D3D11_CPU_ACCESS_WRITE = 0x10000, D3D11_CPU_ACCESS_READ = 0x20000, }} FLAGS!{enum D3D11_RESOURCE_MISC_FLAG { D3D11_RESOURCE_MISC_GENERATE_MIPS = 0x1, D3D11_RESOURCE_MISC_SHARED = 0x2, D3D11_RESOURCE_MISC_TEXTURECUBE = 0x4, D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS = 0x10, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS = 0x20, D3D11_RESOURCE_MISC_BUFFER_STRUCTURED = 0x40, D3D11_RESOURCE_MISC_RESOURCE_CLAMP = 0x80, D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX = 0x100, D3D11_RESOURCE_MISC_GDI_COMPATIBLE = 0x200, D3D11_RESOURCE_MISC_SHARED_NTHANDLE = 0x800, D3D11_RESOURCE_MISC_RESTRICTED_CONTENT = 0x1000, D3D11_RESOURCE_MISC_RESTRICT_SHARED_RESOURCE = 0x2000, D3D11_RESOURCE_MISC_RESTRICT_SHARED_RESOURCE_DRIVER = 0x4000, D3D11_RESOURCE_MISC_GUARDED = 0x8000, D3D11_RESOURCE_MISC_TILE_POOL = 0x20000, D3D11_RESOURCE_MISC_TILED = 0x40000, D3D11_RESOURCE_MISC_HW_PROTECTED = 0x80000, }} ENUM!{enum D3D11_MAP { D3D11_MAP_READ = 1, D3D11_MAP_WRITE = 2, D3D11_MAP_READ_WRITE = 3, D3D11_MAP_WRITE_DISCARD = 4, D3D11_MAP_WRITE_NO_OVERWRITE = 5, }} pub const D3D11_MAP_FLAG_DO_NOT_WAIT: ::DWORD = 0x100000; pub const D3D11_RAISE_FLAG_DRIVER_INTERNAL_ERROR: ::DWORD = 0x1; FLAGS!{enum D3D11_CLEAR_FLAG { DEPTH = 0x1, STENCIL = 0x2, }} pub type D3D11_RECT = ::RECT; STRUCT!{struct D3D11_BOX { left: ::UINT, top: ::UINT, front: ::UINT, right: ::UINT, bottom: ::UINT, back: ::UINT, }} RIDL!( interface ID3D11DeviceChild(ID3D11DeviceChildVtbl): IUnknown(IUnknownVtbl) { fn GetDevice(&mut self, ppDevice: *mut *mut ID3D11Device) -> (), fn GetPrivateData( &mut self, guid: ::REFGUID, pDataSize: *mut ::UINT, pData: *mut ::c_void ) -> ::HRESULT, fn SetPrivateData( &mut self, guid: ::REFGUID, DataSize: ::UINT, pData: *const ::c_void ) -> ::HRESULT, fn SetPrivateDataInterface(&mut self, guid: ::REFGUID, pData: *const ::IUnknown) -> ::HRESULT } ); ENUM!{enum D3D11_COMPARISON_FUNC { D3D11_COMPARISON_NEVER = 1, D3D11_COMPARISON_LESS = 2, D3D11_COMPARISON_EQUAL = 3, D3D11_COMPARISON_LESS_EQUAL = 4, D3D11_COMPARISON_GREATER = 5, D3D11_COMPARISON_NOT_EQUAL = 6, D3D11_COMPARISON_GREATER_EQUAL = 7, D3D11_COMPARISON_ALWAYS = 8, }} ENUM!{enum D3D11_DEPTH_WRITE_MASK { D11_DEPTH_WRITE_MASK_ZERO = 0, D11_DEPTH_WRITE_MASK_ALL = 1, }} ENUM!{enum D3D11_STENCIL_OP { D3D11_STENCIL_OP_KEEP = 1, D3D11_STENCIL_OP_ZERO = 2, D3D11_STENCIL_OP_REPLACE = 3, D3D11_STENCIL_OP_INCR_SAT = 4, D3D11_STENCIL_OP_DECR_SAT = 5, D3D11_STENCIL_OP_INVERT = 6, D3D11_STENCIL_OP_INCR = 7, D3D11_STENCIL_OP_DECR = 8, }} STRUCT!{struct D3D11_DEPTH_STENCILOP_DESC { StencilFailOp: D3D11_STENCIL_OP, StencilDepthFailOp: D3D11_STENCIL_OP, StencilPassOp: D3D11_STENCIL_OP, StencilFunc: D3D11_COMPARISON_FUNC, }} STRUCT!{struct D3D11_DEPTH_STENCIL_DESC { DepthEnable: ::BOOL, DepthWriteMask: D3D11_DEPTH_WRITE_MASK, DepthFunc: D3D11_COMPARISON_FUNC, StencilEnable: ::BOOL, StencilReadMask: ::UINT8, StencilWriteMask: ::UINT8, FrontFace: D3D11_DEPTH_STENCILOP_DESC, BackFace: D3D11_DEPTH_STENCILOP_DESC, }} RIDL!( interface ID3D11DepthStencilState(ID3D11DepthStencilStateVtbl) : ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_DEPTH_STENCIL_DESC) -> () } ); ENUM!{enum D3D11_BLEND { D3D11_BLEND_ZERO = 1, D3D11_BLEND_ONE = 2, D3D11_BLEND_SRC_COLOR = 3, D3D11_BLEND_INV_SRC_COLOR = 4, D3D11_BLEND_SRC_ALPHA = 5, D3D11_BLEND_INV_SRC_ALPHA = 6, D3D11_BLEND_DEST_ALPHA = 7, D3D11_BLEND_INV_DEST_ALPHA = 8, D3D11_BLEND_DEST_COLOR = 9, D3D11_BLEND_INV_DEST_COLOR = 10, D3D11_BLEND_SRC_ALPHA_SAT = 11, D3D11_BLEND_BLEND_FACTOR = 14, D3D11_BLEND_INV_BLEND_FACTOR = 15, D3D11_BLEND_SRC1_COLOR = 16, D3D11_BLEND_INV_SRC1_COLOR = 17, D3D11_BLEND_SRC1_ALPHA = 18, D3D11_BLEND_INV_SRC1_ALPHA = 19, }} ENUM!{enum D3D11_BLEND_OP { D3D11_BLEND_OP_ADD = 1, D3D11_BLEND_OP_SUBTRACT = 2, D3D11_BLEND_OP_REV_SUBTRACT = 3, D3D11_BLEND_OP_MIN = 4, D3D11_BLEND_OP_MAX = 5, }} FLAGS!{enum D3D11_COLOR_WRITE_ENABLE { D3D11_COLOR_WRITE_ENABLE_RED = 1, D3D11_COLOR_WRITE_ENABLE_GREEN = 2, D3D11_COLOR_WRITE_ENABLE_BLUE = 4, D3D11_COLOR_WRITE_ENABLE_ALPHA = 8, D3D11_COLOR_WRITE_ENABLE_ALL = D3D11_COLOR_WRITE_ENABLE_RED.0 | D3D11_COLOR_WRITE_ENABLE_GREEN.0 | D3D11_COLOR_WRITE_ENABLE_BLUE.0 | D3D11_COLOR_WRITE_ENABLE_ALPHA.0, }} STRUCT!{struct D3D11_RENDER_TARGET_BLEND_DESC { BlendEnable: ::BOOL, SrcBlend: D3D11_BLEND, DestBlend: D3D11_BLEND, BlendOp: D3D11_BLEND_OP, SrcBlendAlpha: D3D11_BLEND, DestBlendAlpha: D3D11_BLEND, BlendOpAlpha: D3D11_BLEND_OP, RenderTargetWriteMask: ::UINT8, }} STRUCT!{struct D3D11_BLEND_DESC { AlphaToCoverageEnable: ::BOOL, IndependentBlendEnable: ::BOOL, RenderTarget: [D3D11_RENDER_TARGET_BLEND_DESC; 8], }} RIDL!( interface ID3D11BlendState(ID3D11BlendStateVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_BLEND_DESC) -> () } ); STRUCT!{struct D3D11_RASTERIZER_DESC { FillMode: D3D11_FILL_MODE, CullMode: D3D11_CULL_MODE, FrontCounterClockwise: ::BOOL, DepthBias: ::INT, DepthBiasClamp: ::FLOAT, SlopeScaledDepthBias: ::FLOAT, DepthClipEnable: ::BOOL, ScissorEnable: ::BOOL, MultisampleEnable: ::BOOL, AntialiasedLineEnable: ::BOOL, }} RIDL!( interface ID3D11RasterizerState(ID3D11RasterizerStateVtbl) : ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_RASTERIZER_DESC) -> () } ); STRUCT!{struct D3D11_SUBRESOURCE_DATA { pSysMem: *const ::c_void, SysMemPitch: ::UINT, SysMemSlicePitch: ::UINT, }} STRUCT!{struct D3D11_MAPPED_SUBRESOURCE { pData: *mut ::c_void, RowPitch: ::UINT, DepthPitch: ::UINT, }} RIDL!( interface ID3D11Resource(ID3D11ResourceVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn GetType(&mut self, pResourceDimension: *mut D3D11_RESOURCE_DIMENSION) -> (), fn SetEvictionPriority(&mut self, EvictionPriority: ::UINT) -> (), fn GetEvictionPriority(&mut self) -> ::UINT } ); STRUCT!{struct D3D11_BUFFER_DESC { ByteWidth: ::UINT, Usage: D3D11_USAGE, BindFlags: ::UINT, CPUAccessFlags: ::UINT, MiscFlags: ::UINT, StructureByteStride: ::UINT, }} RIDL!( interface ID3D11Buffer(ID3D11BufferVtbl): ID3D11Resource(ID3D11ResourceVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_BUFFER_DESC) -> () } ); STRUCT!{struct D3D11_TEXTURE1D_DESC { Width: ::UINT, MipLevels: ::UINT, ArraySize: ::UINT, Format: ::DXGI_FORMAT, Usage: D3D11_USAGE, BindFlags: ::UINT, CPUAccessFlags: ::UINT, MiscFlags: ::UINT, }} RIDL!( interface ID3D11Texture1D(ID3D11Texture1DVtbl): ID3D11Resource(ID3D11ResourceVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_TEXTURE1D_DESC) -> () } ); STRUCT!{struct D3D11_TEXTURE2D_DESC { Width: ::UINT, Height: ::UINT, MipLevels: ::UINT, ArraySize: ::UINT, Format: ::DXGI_FORMAT, SampleDesc: ::DXGI_SAMPLE_DESC, Usage: D3D11_USAGE, BindFlags: ::UINT, CPUAccessFlags: ::UINT, MiscFlags: ::UINT, }} RIDL!( interface ID3D11Texture2D(ID3D11Texture2DVtbl): ID3D11Resource(ID3D11ResourceVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_TEXTURE2D_DESC) -> () } ); STRUCT!{struct D3D11_TEXTURE3D_DESC { Width: ::UINT, Height: ::UINT, Depth: ::UINT, MipLevels: ::UINT, Format: ::DXGI_FORMAT, Usage: D3D11_USAGE, BindFlags: ::UINT, CPUAccessFlags: ::UINT, MiscFlags: ::UINT, }} RIDL!( interface ID3D11Texture3D(ID3D11Texture3DVtbl): ID3D11Resource(ID3D11ResourceVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_TEXTURE3D_DESC) -> () } ); ENUM!{enum D3D11_TEXTURECUBE_FACE { D3D11_TEXTURECUBE_FACE_POSITIVE_X = 0, D3D11_TEXTURECUBE_FACE_NEGATIVE_X = 1, D3D11_TEXTURECUBE_FACE_POSITIVE_Y = 2, D3D11_TEXTURECUBE_FACE_NEGATIVE_Y = 3, D3D11_TEXTURECUBE_FACE_POSITIVE_Z = 4, D3D11_TEXTURECUBE_FACE_NEGATIVE_Z = 5, }} RIDL!( interface ID3D11View(ID3D11ViewVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn GetResource(&mut self, ppResource: *mut *mut ID3D11Resource) -> () } ); STRUCT!{struct D3D11_BUFFER_SRV { u1: ::UINT, u2: ::UINT, }} UNION!(D3D11_BUFFER_SRV, u1, FirstElement, FirstElement_mut, ::UINT); UNION!(D3D11_BUFFER_SRV, u1, ElementOffset, ElementOffset_mut, ::UINT); UNION!(D3D11_BUFFER_SRV, u2, ElementWidth, ElementWidth_mut, ::UINT); UNION!(D3D11_BUFFER_SRV, u2, NumElements, NumElements_mut, ::UINT); FLAGS!{enum D3D11_BUFFEREX_SRV_FLAG { D3D11_BUFFEREX_SRV_FLAG_RAW = 0x1, }} STRUCT!{struct D3D11_BUFFEREX_SRV { FirstElement: ::UINT, NumElements: ::UINT, Flags: ::UINT, }} STRUCT!{struct D3D11_TEX1D_SRV { MostDetailedMip: ::UINT, MipLevels: ::UINT, }} STRUCT!{struct D3D11_TEX1D_ARRAY_SRV { MostDetailedMip: ::UINT, MipLevels: ::UINT, FirstArraySlice: ::UINT, ArraySize: ::UINT, }} STRUCT!{struct D3D11_TEX2D_SRV { MostDetailedMip: ::UINT, MipLevels: ::UINT, }} STRUCT!{struct D3D11_TEX2D_ARRAY_SRV { MostDetailedMip: ::UINT, MipLevels: ::UINT, FirstArraySlice: ::UINT, ArraySize: ::UINT, }} STRUCT!{struct D3D11_TEX3D_SRV { MostDetailedMip: ::UINT, MipLevels: ::UINT, }} STRUCT!{struct D3D11_TEXCUBE_SRV { MostDetailedMip: ::UINT, MipLevels: ::UINT, }} STRUCT!{struct D3D11_TEXCUBE_ARRAY_SRV { MostDetailedMip: ::UINT, MipLevels: ::UINT, First2DArrayFace: ::UINT, NumCubes: ::UINT, }} STRUCT!{struct D3D11_TEX2DMS_SRV { UnusedField_NothingToDefine: ::UINT, }} STRUCT!{struct D3D11_TEX2DMS_ARRAY_SRV { FirstArraySlice: ::UINT, ArraySize: ::UINT, }} STRUCT!{struct D3D11_SHADER_RESOURCE_VIEW_DESC { Format: ::DXGI_FORMAT, ViewDimension: D3D11_SRV_DIMENSION, u: [::UINT; 4], }} UNION!(D3D11_SHADER_RESOURCE_VIEW_DESC, u, Buffer, Buffer_mut, D3D11_BUFFER_SRV); UNION!(D3D11_SHADER_RESOURCE_VIEW_DESC, u, Texture1D, Texture1D_mut, D3D11_TEX1D_SRV); UNION!(D3D11_SHADER_RESOURCE_VIEW_DESC, u, Texture1DArray, Texture1DArray_mut, D3D11_TEX1D_ARRAY_SRV); UNION!(D3D11_SHADER_RESOURCE_VIEW_DESC, u, Texture2D, Texture2D_mut, D3D11_TEX2D_SRV); UNION!(D3D11_SHADER_RESOURCE_VIEW_DESC, u, Texture2DArray, Texture2DArray_mut, D3D11_TEX2D_ARRAY_SRV); UNION!(D3D11_SHADER_RESOURCE_VIEW_DESC, u, Texture2DMS, Texture2DMS_mut, D3D11_TEX2DMS_SRV); UNION!(D3D11_SHADER_RESOURCE_VIEW_DESC, u, Texture2DMSArray, Texture2DMSArray_mut, D3D11_TEX2DMS_ARRAY_SRV); UNION!(D3D11_SHADER_RESOURCE_VIEW_DESC, u, Texture3D, Texture3D_mut, D3D11_TEX3D_SRV); UNION!(D3D11_SHADER_RESOURCE_VIEW_DESC, u, TextureCube, TextureCube_mut, D3D11_TEXCUBE_SRV); UNION!(D3D11_SHADER_RESOURCE_VIEW_DESC, u, TextureCubeArray, TextureCubeArray_mut, D3D11_TEXCUBE_ARRAY_SRV); UNION!(D3D11_SHADER_RESOURCE_VIEW_DESC, u, BufferEx, BufferEx_mut, D3D11_BUFFEREX_SRV); RIDL!( interface ID3D11ShaderResourceView(ID3D11ShaderResourceViewVtbl): ID3D11View(ID3D11ViewVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_SHADER_RESOURCE_VIEW_DESC) -> () } ); STRUCT!{struct D3D11_BUFFER_RTV { u1: ::UINT, u2: ::UINT, }} UNION!(D3D11_BUFFER_RTV, u1, FirstElement, FirstElement_mut, ::UINT); UNION!(D3D11_BUFFER_RTV, u1, ElementOffset, ElementOffset_mut, ::UINT); UNION!(D3D11_BUFFER_RTV, u2, NumElements, NumElements_mut, ::UINT); UNION!(D3D11_BUFFER_RTV, u2, ElementWidth, ElementWidth_mut, ::UINT); STRUCT!{struct D3D11_TEX1D_RTV { MipSlice: ::UINT, }} STRUCT!{struct D3D11_TEX1D_ARRAY_RTV { MipSlice: ::UINT, FirstArraySlice: ::UINT, ArraySize: ::UINT, }} STRUCT!{struct D3D11_TEX2D_RTV { MipSlice: ::UINT, }} STRUCT!{struct D3D11_TEX2DMS_RTV { UnusedField_NothingToDefine: ::UINT, }} STRUCT!{struct D3D11_TEX2D_ARRAY_RTV { MipSlice: ::UINT, FirstArraySlice: ::UINT, ArraySize: ::UINT, }} STRUCT!{struct D3D11_TEX2DMS_ARRAY_RTV { FirstArraySlice: ::UINT, ArraySize: ::UINT, }} STRUCT!{struct D3D11_TEX3D_RTV { MipSlice: ::UINT, FirstWSlice: ::UINT, WSize: ::UINT, }} STRUCT!{struct D3D11_RENDER_TARGET_VIEW_DESC { Format: ::DXGI_FORMAT, ViewDimension: D3D11_RTV_DIMENSION, u: [::UINT; 3], }} UNION!(D3D11_RENDER_TARGET_VIEW_DESC, u, Buffer, Buffer_mut, D3D11_BUFFER_RTV); UNION!(D3D11_RENDER_TARGET_VIEW_DESC, u, Texture1D, Texture1D_mut, D3D11_TEX1D_RTV); UNION!(D3D11_RENDER_TARGET_VIEW_DESC, u, Texture1DArray, Texture1DArray_mut, D3D11_TEX1D_ARRAY_RTV); UNION!(D3D11_RENDER_TARGET_VIEW_DESC, u, Texture2D, Texture2D_mut, D3D11_TEX2D_RTV); UNION!(D3D11_RENDER_TARGET_VIEW_DESC, u, Texture2DArray, Texture2DArray_mut, D3D11_TEX2D_ARRAY_RTV); UNION!(D3D11_RENDER_TARGET_VIEW_DESC, u, Texture2DMS, Texture2DMS_mut, D3D11_TEX2DMS_RTV); UNION!(D3D11_RENDER_TARGET_VIEW_DESC, u, Texture2DMSArray,Texture2DMSArray_mut, D3D11_TEX2DMS_ARRAY_RTV); UNION!(D3D11_RENDER_TARGET_VIEW_DESC, u, Texture3D, Texture3D_mut, D3D11_TEX3D_RTV); RIDL!( interface ID3D11RenderTargetView(ID3D11RenderTargetViewVtbl): ID3D11View(ID3D11ViewVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_RENDER_TARGET_VIEW_DESC) -> () } ); STRUCT!{struct D3D11_TEX1D_DSV { MipSlice: ::UINT, }} STRUCT!{struct D3D11_TEX1D_ARRAY_DSV { MipSlice: ::UINT, FirstArraySlice: ::UINT, ArraySize: ::UINT, }} STRUCT!{struct D3D11_TEX2D_DSV { MipSlice: ::UINT, }} STRUCT!{struct D3D11_TEX2D_ARRAY_DSV { MipSlice: ::UINT, FirstArraySlice: ::UINT, ArraySize: ::UINT, }} STRUCT!{struct D3D11_TEX2DMS_DSV { UnusedField_NothingToDefine: ::UINT, }} STRUCT!{struct D3D11_TEX2DMS_ARRAY_DSV { FirstArraySlice: ::UINT, ArraySize: ::UINT, }} FLAGS!{enum D3D11_DSV_FLAG{ D3D11_DSV_READ_ONLY_DEPTH = 0x1, D3D11_DSV_READ_ONLY_STENCIL = 0x2, }} STRUCT!{struct D3D11_DEPTH_STENCIL_VIEW_DESC { Format: ::DXGI_FORMAT, ViewDimension: D3D11_DSV_DIMENSION, u: [::UINT; 3], }} UNION!(D3D11_DEPTH_STENCIL_VIEW_DESC, u, Texture1D, Texture1D_mut, D3D11_TEX1D_DSV); UNION!(D3D11_DEPTH_STENCIL_VIEW_DESC, u, Texture1DArray, Texture1DArray_mut, D3D11_TEX1D_ARRAY_DSV); UNION!(D3D11_DEPTH_STENCIL_VIEW_DESC, u, Texture2D, Texture2D_mut, D3D11_TEX2D_DSV); UNION!(D3D11_DEPTH_STENCIL_VIEW_DESC, u, Texture2DArray, Texture2DArray_mut, D3D11_TEX2D_ARRAY_DSV); UNION!(D3D11_DEPTH_STENCIL_VIEW_DESC, u, Texture2DMS, Texture2DMS_mut, D3D11_TEX2DMS_DSV); UNION!(D3D11_DEPTH_STENCIL_VIEW_DESC, u, Texture2DMSArray, Texture2DMSArray_mut, D3D11_TEX2DMS_ARRAY_DSV); RIDL!( interface ID3D11DepthStencilView(ID3D11DepthStencilViewVtbl): ID3D11View(ID3D11ViewVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_DEPTH_STENCIL_VIEW_DESC) -> () } ); FLAGS!{enum D3D11_BUFFER_UAV_FLAG { D3D11_BUFFER_UAV_FLAG_RAW = 0x1, D3D11_BUFFER_UAV_FLAG_APPEND = 0x2, D3D11_BUFFER_UAV_FLAG_COUNTER = 0x4, }} STRUCT!{struct D3D11_BUFFER_UAV { FirstElement: ::UINT, NumElements: ::UINT, Flags: ::UINT, }} STRUCT!{struct D3D11_TEX1D_UAV { MipSlice: ::UINT, }} STRUCT!{struct D3D11_TEX1D_ARRAY_UAV { MipSlice: ::UINT, FirstArraySlice: ::UINT, ArraySize: ::UINT, }} STRUCT!{struct D3D11_TEX2D_UAV { MipSlice: ::UINT, }} STRUCT!{struct D3D11_TEX2D_ARRAY_UAV { MipSlice: ::UINT, FirstArraySlice: ::UINT, ArraySize: ::UINT, }} STRUCT!{struct D3D11_TEX3D_UAV { MipSlice: ::UINT, FirstWSlice: ::UINT, WSize: ::UINT, }} STRUCT!{struct D3D11_UNORDERED_ACCESS_VIEW_DESC { Format: ::DXGI_FORMAT, ViewDimension: D3D11_UAV_DIMENSION, u: [::UINT; 3], }} UNION!(D3D11_UNORDERED_ACCESS_VIEW_DESC, u, Buffer, Buffer_mut, D3D11_BUFFER_UAV); UNION!(D3D11_UNORDERED_ACCESS_VIEW_DESC, u, Texture1D, Texture1D_mut, D3D11_TEX1D_UAV); UNION!(D3D11_UNORDERED_ACCESS_VIEW_DESC, u, Texture1DArray, Texture1DArray_mut, D3D11_TEX1D_ARRAY_UAV); UNION!(D3D11_UNORDERED_ACCESS_VIEW_DESC, u, Texture2D, Texture2D_mut, D3D11_TEX2D_UAV); UNION!(D3D11_UNORDERED_ACCESS_VIEW_DESC, u, Texture2DArray, Texture2DArray_mut, D3D11_TEX2D_ARRAY_UAV); UNION!(D3D11_UNORDERED_ACCESS_VIEW_DESC, u, Texture3D, Texture3D_mut, D3D11_TEX3D_UAV); RIDL!( interface ID3D11UnorderedAccessView(ID3D11UnorderedAccessViewVtbl): ID3D11View(ID3D11ViewVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_UNORDERED_ACCESS_VIEW_DESC) -> () } ); RIDL!( interface ID3D11VertexShader(ID3D11VertexShaderVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { } ); RIDL!( interface ID3D11HullShader(ID3D11HullShaderVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { } ); RIDL!( interface ID3D11DomainShader(ID3D11DomainShaderVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { } ); RIDL!( interface ID3D11GeometryShader(ID3D11GeometryShaderVtbl) : ID3D11DeviceChild(ID3D11DeviceChildVtbl) { } ); RIDL!( interface ID3D11PixelShader(ID3D11PixelShaderVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { } ); RIDL!( interface ID3D11ComputeShader(ID3D11ComputeShaderVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { } ); RIDL!( interface ID3D11InputLayout(ID3D11InputLayoutVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { } ); ENUM!{enum D3D11_FILTER { D3D11_FILTER_MIN_MAG_MIP_POINT = 0, D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR = 0x1, D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x4, D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR = 0x5, D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT = 0x10, D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x11, D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT = 0x14, D3D11_FILTER_MIN_MAG_MIP_LINEAR = 0x15, D3D11_FILTER_ANISOTROPIC = 0x55, D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT = 0x80, D3D11_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR = 0x81, D3D11_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x84, D3D11_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR = 0x85, D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT = 0x90, D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x91, D3D11_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT = 0x94, D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR = 0x95, D3D11_FILTER_COMPARISON_ANISOTROPIC = 0xd5, D3D11_FILTER_MINIMUM_MIN_MAG_MIP_POINT = 0x100, D3D11_FILTER_MINIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x101, D3D11_FILTER_MINIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x104, D3D11_FILTER_MINIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x105, D3D11_FILTER_MINIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x110, D3D11_FILTER_MINIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x111, D3D11_FILTER_MINIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x114, D3D11_FILTER_MINIMUM_MIN_MAG_MIP_LINEAR = 0x115, D3D11_FILTER_MINIMUM_ANISOTROPIC = 0x155, D3D11_FILTER_MAXIMUM_MIN_MAG_MIP_POINT = 0x180, D3D11_FILTER_MAXIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x181, D3D11_FILTER_MAXIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x184, D3D11_FILTER_MAXIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x185, D3D11_FILTER_MAXIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x190, D3D11_FILTER_MAXIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x191, D3D11_FILTER_MAXIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x194, D3D11_FILTER_MAXIMUM_MIN_MAG_MIP_LINEAR = 0x195, D3D11_FILTER_MAXIMUM_ANISOTROPIC = 0x1d5, }} ENUM!{enum D3D11_FILTER_TYPE { D3D11_FILTER_TYPE_POINT = 0, D3D11_FILTER_TYPE_LINEAR = 1, }} ENUM!{enum D3D11_FILTER_REDUCTION_TYPE { D3D11_FILTER_REDUCTION_TYPE_STANDARD = 0, D3D11_FILTER_REDUCTION_TYPE_COMPARISON = 1, D3D11_FILTER_REDUCTION_TYPE_MINIMUM = 2, D3D11_FILTER_REDUCTION_TYPE_MAXIMUM = 3, }} pub const D3D11_FILTER_REDUCTION_TYPE_MASK: ::DWORD = 0x3; pub const D3D11_FILTER_REDUCTION_TYPE_SHIFT: ::DWORD = 7; pub const D3D11_FILTER_TYPE_MASK: ::DWORD = 0x3; pub const D3D11_MIN_FILTER_SHIFT: ::DWORD = 4; pub const D3D11_MAG_FILTER_SHIFT: ::DWORD = 2; pub const D3D11_MIP_FILTER_SHIFT: ::DWORD = 0; pub const D3D11_COMPARISON_FILTERING_BIT: ::DWORD = 0x80; pub const D3D11_ANISOTROPIC_FILTERING_BIT: ::DWORD = 0x40; ENUM!{enum D3D11_TEXTURE_ADDRESS_MODE { D3D11_TEXTURE_ADDRESS_WRAP = 1, D3D11_TEXTURE_ADDRESS_MIRROR = 2, D3D11_TEXTURE_ADDRESS_CLAMP = 3, D3D11_TEXTURE_ADDRESS_BORDER = 4, D3D11_TEXTURE_ADDRESS_MIRROR_ONCE = 5, }} STRUCT!{struct D3D11_SAMPLER_DESC { Filter: D3D11_FILTER, AddressU: D3D11_FILTER, AddressV: D3D11_FILTER, AddressW: D3D11_FILTER, MipLODBias: ::FLOAT, MaxAnisotropy: ::UINT, ComparisonFunc: D3D11_COMPARISON_FUNC, BorderColor: [::FLOAT; 4], MinLOD: ::FLOAT, MaxLOD: ::FLOAT, }} RIDL!( interface ID3D11SamplerState(ID3D11SamplerStateVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_SAMPLER_DESC) -> () } ); FLAGS!{enum D3D11_FORMAT_SUPPORT { D3D11_FORMAT_SUPPORT_BUFFER = 0x1, D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER = 0x2, D3D11_FORMAT_SUPPORT_IA_INDEX_BUFFER = 0x4, D3D11_FORMAT_SUPPORT_SO_BUFFER = 0x8, D3D11_FORMAT_SUPPORT_TEXTURE1D = 0x10, D3D11_FORMAT_SUPPORT_TEXTURE2D = 0x20, D3D11_FORMAT_SUPPORT_TEXTURE3D = 0x40, D3D11_FORMAT_SUPPORT_TEXTURECUBE = 0x80, D3D11_FORMAT_SUPPORT_SHADER_LOAD = 0x100, D3D11_FORMAT_SUPPORT_SHADER_SAMPLE = 0x200, D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON = 0x400, D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_MONO_TEXT = 0x800, D3D11_FORMAT_SUPPORT_MIP = 0x1000, D3D11_FORMAT_SUPPORT_MIP_AUTOGEN = 0x2000, D3D11_FORMAT_SUPPORT_RENDER_TARGET = 0x4000, D3D11_FORMAT_SUPPORT_BLENDABLE = 0x8000, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL = 0x10000, D3D11_FORMAT_SUPPORT_CPU_LOCKABLE = 0x20000, D3D11_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE = 0x40000, D3D11_FORMAT_SUPPORT_DISPLAY = 0x80000, D3D11_FORMAT_SUPPORT_CAST_WITHIN_BIT_LAYOUT = 0x100000, D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET = 0x200000, D3D11_FORMAT_SUPPORT_MULTISAMPLE_LOAD = 0x400000, D3D11_FORMAT_SUPPORT_SHADER_GATHER = 0x800000, D3D11_FORMAT_SUPPORT_BACK_BUFFER_CAST = 0x1000000, D3D11_FORMAT_SUPPORT_TYPED_UNORDERED_ACCESS_VIEW = 0x2000000, D3D11_FORMAT_SUPPORT_SHADER_GATHER_COMPARISON = 0x4000000, D3D11_FORMAT_SUPPORT_DECODER_OUTPUT = 0x8000000, D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_OUTPUT = 0x10000000, D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_INPUT = 0x20000000, D3D11_FORMAT_SUPPORT_VIDEO_ENCODER = 0x40000000, }} FLAGS!{enum D3D11_FORMAT_SUPPORT2 { D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_ADD = 0x1, D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_BITWISE_OPS = 0x2, D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_COMPARE_STORE_OR_COMPARE_EXCHANGE = 0x4, D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_EXCHANGE = 0x8, D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_SIGNED_MIN_OR_MAX = 0x10, D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_UNSIGNED_MIN_OR_MAX = 0x20, D3D11_FORMAT_SUPPORT2_UAV_TYPED_LOAD = 0x40, D3D11_FORMAT_SUPPORT2_UAV_TYPED_STORE = 0x80, D3D11_FORMAT_SUPPORT2_OUTPUT_MERGER_LOGIC_OP = 0x100, D3D11_FORMAT_SUPPORT2_TILED = 0x200, D3D11_FORMAT_SUPPORT2_SHAREABLE = 0x400, D3D11_FORMAT_SUPPORT2_MULTIPLANE_OVERLAY = 0x4000, }} RIDL!( interface ID3D11Asynchronous(ID3D11AsynchronousVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn GetDataSize(&mut self) -> ::UINT } ); FLAGS!{enum D3D11_ASYNC_GETDATA_FLAG { D3D11_ASYNC_GETDATA_DONOTFLUSH = 0x1, }} ENUM!{enum D3D11_QUERY { D3D11_QUERY_EVENT = 0, D3D11_QUERY_OCCLUSION = D3D11_QUERY_EVENT.0 + 1, D3D11_QUERY_TIMESTAMP = D3D11_QUERY_OCCLUSION.0 + 1, D3D11_QUERY_TIMESTAMP_DISJOINT = D3D11_QUERY_TIMESTAMP.0 + 1, D3D11_QUERY_PIPELINE_STATISTICS = D3D11_QUERY_TIMESTAMP_DISJOINT.0 + 1, D3D11_QUERY_OCCLUSION_PREDICATE = D3D11_QUERY_PIPELINE_STATISTICS.0 + 1, D3D11_QUERY_SO_STATISTICS = D3D11_QUERY_OCCLUSION_PREDICATE.0 + 1, D3D11_QUERY_SO_OVERFLOW_PREDICATE = D3D11_QUERY_SO_STATISTICS.0 + 1, D3D11_QUERY_SO_STATISTICS_STREAM0 = D3D11_QUERY_SO_OVERFLOW_PREDICATE.0 + 1, D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM0 = D3D11_QUERY_SO_STATISTICS_STREAM0.0 + 1, D3D11_QUERY_SO_STATISTICS_STREAM1 = D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM0.0 + 1, D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM1 = D3D11_QUERY_SO_STATISTICS_STREAM1.0 + 1, D3D11_QUERY_SO_STATISTICS_STREAM2 = D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM1.0 + 1, D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM2 = D3D11_QUERY_SO_STATISTICS_STREAM2.0 + 1, D3D11_QUERY_SO_STATISTICS_STREAM3 = D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM2.0 + 1, D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM3 = D3D11_QUERY_SO_STATISTICS_STREAM3.0 + 1, }} FLAGS!{enum D3D11_QUERY_MISC_FLAG { D3D11_QUERY_MISC_PREDICATEHINT = 0x1, }} STRUCT!{struct D3D11_QUERY_DESC { Query: D3D11_QUERY, MiscFlags: ::UINT, }} RIDL!( interface ID3D11Query(ID3D11QueryVtbl): ID3D11Asynchronous(ID3D11AsynchronousVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_QUERY_DESC) -> () } ); RIDL!( interface ID3D11Predicate(ID3D11PredicateVtbl): ID3D11Query(ID3D11QueryVtbl) { } ); STRUCT!{struct D3D11_QUERY_DATA_TIMESTAMP_DISJOINT { Frequency: ::UINT64, Disjoint: ::BOOL, }} STRUCT!{struct D3D11_QUERY_DATA_PIPELINE_STATISTICS { IAVertices: ::UINT64, IAPrimitives: ::UINT64, VSInvocations: ::UINT64, GSInvocations: ::UINT64, GSPrimitives: ::UINT64, CInvocations: ::UINT64, CPrimitives: ::UINT64, PSInvocations: ::UINT64, HSInvocations: ::UINT64, DSInvocations: ::UINT64, CSInvocations: ::UINT64, }} STRUCT!{struct D3D11_QUERY_DATA_SO_STATISTICS { NumPrimitivesWritten: ::UINT64, PrimitivesStorageNeeded: ::UINT64, }} FLAGS!{enum D3D11_COUNTER { D3D11_COUNTER_DEVICE_DEPENDENT_0 = 0x40000000, }} ENUM!{enum D3D11_COUNTER_TYPE { D3D11_COUNTER_TYPE_FLOAT32 = 0, D3D11_COUNTER_TYPE_UINT16 = D3D11_COUNTER_TYPE_FLOAT32.0 + 1, D3D11_COUNTER_TYPE_UINT32 = D3D11_COUNTER_TYPE_UINT16.0 + 1, D3D11_COUNTER_TYPE_UINT64 = D3D11_COUNTER_TYPE_UINT32.0 + 1, }} STRUCT!{struct D3D11_COUNTER_DESC { Counter: D3D11_COUNTER, MiscFlags: ::UINT, }} STRUCT!{struct D3D11_COUNTER_INFO { LastDeviceDependentCounter: D3D11_COUNTER, NumSimultaneousCounters: ::UINT, NumDetectableParallelUnits: ::UINT8, }} RIDL!( interface ID3D11Counter(ID3D11CounterVtbl): ID3D11Asynchronous(ID3D11AsynchronousVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_COUNTER_DESC) -> () } ); ENUM!{enum D3D11_STANDARD_MULTISAMPLE_QUALITY_LEVELS { D3D11_STANDARD_MULTISAMPLE_PATTERN = 0xffffffff, D3D11_CENTER_MULTISAMPLE_PATTERN = 0xfffffffe, }} ENUM!{enum D3D11_DEVICE_CONTEXT_TYPE { D3D11_DEVICE_CONTEXT_IMMEDIATE = 0, D3D11_DEVICE_CONTEXT_DEFERRED = D3D11_DEVICE_CONTEXT_IMMEDIATE.0 + 1, }} STRUCT!{struct D3D11_CLASS_INSTANCE_DESC { InstanceId: ::UINT, InstanceIndex: ::UINT, TypeId: ::UINT, ConstantBuffer: ::UINT, BaseConstantBufferOffset: ::UINT, BaseTexture: ::UINT, BaseSampler: ::UINT, Created: ::BOOL, }} RIDL!( interface ID3D11ClassInstance(ID3D11ClassInstanceVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn GetClassLinkage(&mut self, ppLinkage: *mut *mut ID3D11ClassLinkage) -> (), fn GetDesc(&mut self, pDesc: *mut D3D11_CLASS_INSTANCE_DESC) -> (), fn GetInstanceName(&mut self, pInstanceName: ::LPSTR, pBufferLength: *mut ::SIZE_T) -> (), fn GetTypeName(&mut self, pTypeName: ::LPSTR, pBufferLength: *mut ::SIZE_T) -> () } ); RIDL!( interface ID3D11ClassLinkage(ID3D11ClassLinkageVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn GetClassInstance( &mut self, GetClassInstance: ::LPCSTR, InstanceIndex: ::UINT, ppInstance: *mut *mut ID3D11ClassInstance ) -> ::HRESULT, fn CreateClassInstance( &mut self, pClassTypeName: ::LPCSTR, ConstantBufferOffset: ::UINT, ConstantVectorOffset: ::UINT, TextureOffset: ::UINT, SamplerOffset: ::UINT, ppInstance: *mut *mut ID3D11ClassInstance ) -> ::HRESULT } ); RIDL!( interface ID3D11CommandList(ID3D11CommandListVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn GetContextFlags(&mut self) -> ::UINT } ); ENUM!{enum D3D11_FEATURE { D3D11_FEATURE_THREADING = 0, D3D11_FEATURE_DOUBLES = D3D11_FEATURE_THREADING.0 + 1, D3D11_FEATURE_FORMAT_SUPPORT = D3D11_FEATURE_DOUBLES.0 + 1, D3D11_FEATURE_FORMAT_SUPPORT2 = D3D11_FEATURE_FORMAT_SUPPORT.0 + 1, D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS = D3D11_FEATURE_FORMAT_SUPPORT2.0 + 1, D3D11_FEATURE_D3D11_OPTIONS = D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS.0 + 1, D3D11_FEATURE_ARCHITECTURE_INFO = D3D11_FEATURE_D3D11_OPTIONS.0 + 1, D3D11_FEATURE_D3D9_OPTIONS = D3D11_FEATURE_ARCHITECTURE_INFO.0 + 1, D3D11_FEATURE_SHADER_MIN_PRECISION_SUPPORT = D3D11_FEATURE_D3D9_OPTIONS.0 + 1, D3D11_FEATURE_D3D9_SHADOW_SUPPORT = D3D11_FEATURE_SHADER_MIN_PRECISION_SUPPORT.0 + 1, D3D11_FEATURE_D3D11_OPTIONS1 = D3D11_FEATURE_D3D9_SHADOW_SUPPORT.0 + 1, D3D11_FEATURE_D3D9_SIMPLE_INSTANCING_SUPPORT = D3D11_FEATURE_D3D11_OPTIONS1.0 + 1, D3D11_FEATURE_MARKER_SUPPORT = D3D11_FEATURE_D3D9_SIMPLE_INSTANCING_SUPPORT.0 + 1, D3D11_FEATURE_D3D9_OPTIONS1 = D3D11_FEATURE_MARKER_SUPPORT.0 + 1, D3D11_FEATURE_D3D11_OPTIONS2 = D3D11_FEATURE_D3D9_OPTIONS1.0 + 1, D3D11_FEATURE_D3D11_OPTIONS3 = D3D11_FEATURE_D3D11_OPTIONS2.0 + 1, D3D11_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT = D3D11_FEATURE_D3D11_OPTIONS3.0 + 1, }} STRUCT!{struct D3D11_FEATURE_DATA_THREADING { DriverConcurrentCreates: ::BOOL, DriverCommandLists: ::BOOL, }} STRUCT!{struct D3D11_FEATURE_DATA_DOUBLES { DoublePrecisionFloatShaderOps: ::BOOL, }} STRUCT!{struct D3D11_FEATURE_DATA_FORMAT_SUPPORT { InFormat: ::DXGI_FORMAT, OutFormatSupport: ::UINT, }} STRUCT!{struct D3D11_FEATURE_DATA_FORMAT_SUPPORT2 { InFormat: ::DXGI_FORMAT, OutFormatSupport2: ::UINT, }} STRUCT!{struct D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS { ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x: ::BOOL, }} STRUCT!{struct D3D11_FEATURE_DATA_D3D11_OPTIONS { OutputMergerLogicOp: ::BOOL, UAVOnlyRenderingForcedSampleCount: ::BOOL, DiscardAPIsSeenByDriver: ::BOOL, FlagsForUpdateAndCopySeenByDriver: ::BOOL, ClearView: ::BOOL, CopyWithOverlap: ::BOOL, ConstantBufferPartialUpdate: ::BOOL, ConstantBufferOffsetting: ::BOOL, MapNoOverwriteOnDynamicConstantBuffer: ::BOOL, MapNoOverwriteOnDynamicBufferSRV: ::BOOL, MultisampleRTVWithForcedSampleCountOne: ::BOOL, SAD4ShaderInstructions: ::BOOL, ExtendedDoublesShaderInstructions: ::BOOL, ExtendedResourceSharing: ::BOOL, }} STRUCT!{struct D3D11_FEATURE_DATA_ARCHITECTURE_INFO { TileBasedDeferredRenderer: ::BOOL, }} STRUCT!{struct D3D11_FEATURE_DATA_D3D9_OPTIONS { FullNonPow2TextureSupport: ::BOOL, }} STRUCT!{struct D3D11_FEATURE_DATA_D3D9_SHADOW_SUPPORT { SupportsDepthAsTextureWithLessEqualComparisonFilter: ::BOOL, }} FLAGS!{enum D3D11_SHADER_MIN_PRECISION_SUPPORT { D3D11_SHADER_MIN_PRECISION_10_BIT = 0x1, D3D11_SHADER_MIN_PRECISION_16_BIT = 0x2, }} STRUCT!{struct D3D11_FEATURE_DATA_SHADER_MIN_PRECISION_SUPPORT { PixelShaderMinPrecision: ::UINT, AllOtherShaderStagesMinPrecision: ::UINT, }} ENUM!{enum D3D11_TILED_RESOURCES_TIER { D3D11_TILED_RESOURCES_NOT_SUPPORTED = 0, D3D11_TILED_RESOURCES_TIER_1 = 1, D3D11_TILED_RESOURCES_TIER_2 = 2, D3D11_TILED_RESOURCES_TIER_3 = 3, }} STRUCT!{struct D3D11_FEATURE_DATA_D3D11_OPTIONS1 { TiledResourcesTier: D3D11_TILED_RESOURCES_TIER, MinMaxFiltering: ::BOOL, ClearViewAlsoSupportsDepthOnlyFormats: ::BOOL, MapOnDefaultBuffers: ::BOOL, }} STRUCT!{struct D3D11_FEATURE_DATA_D3D9_SIMPLE_INSTANCING_SUPPORT { SimpleInstancingSupported: ::BOOL, }} STRUCT!{struct D3D11_FEATURE_DATA_MARKER_SUPPORT { Profile: ::BOOL, }} STRUCT!{struct D3D11_FEATURE_DATA_D3D9_OPTIONS1 { FullNonPow2TextureSupported: ::BOOL, DepthAsTextureWithLessEqualComparisonFilterSupported: ::BOOL, SimpleInstancingSupported: ::BOOL, TextureCubeFaceRenderTargetWithNonCubeDepthStencilSupported: ::BOOL, }} ENUM!{enum D3D11_CONSERVATIVE_RASTERIZATION_TIER { D3D11_CONSERVATIVE_RASTERIZATION_NOT_SUPPORTED = 0, D3D11_CONSERVATIVE_RASTERIZATION_TIER_1 = 1, D3D11_CONSERVATIVE_RASTERIZATION_TIER_2 = 2, D3D11_CONSERVATIVE_RASTERIZATION_TIER_3 = 3, }} STRUCT!{struct D3D11_FEATURE_DATA_D3D11_OPTIONS2 { PSSpecifiedStencilRefSupported: ::BOOL, TypedUAVLoadAdditionalFormats: ::BOOL, ROVsSupported: ::BOOL, ConservativeRasterizationTier: D3D11_CONSERVATIVE_RASTERIZATION_TIER, TiledResourcesTier: D3D11_TILED_RESOURCES_TIER, MapOnDefaultTextures: ::BOOL, StandardSwizzle: ::BOOL, UnifiedMemoryArchitecture: ::BOOL, }} STRUCT!{struct D3D11_FEATURE_DATA_D3D11_OPTIONS3 { VPAndRTArrayIndexFromAnyShaderFeedingRasterizer: ::BOOL, }} STRUCT!{struct D3D11_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT { MaxGPUVirtualAddressBitsPerResource: ::UINT, MaxGPUVirtualAddressBitsPerProcess: ::UINT, }} RIDL!( interface ID3D11DeviceContext(ID3D11DeviceContextVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn VSSetConstantBuffers( &mut self, StartSlot: ::UINT, NumBuffers: ::UINT, ppConstantBuffers: *const *mut ID3D11Buffer ) -> (), fn PSSetShaderResources( &mut self, StartSlot: ::UINT, NumViews: ::UINT, ppShaderResourceViews: *const *mut ID3D11ShaderResourceView ) -> (), fn PSSetShader( &mut self, pPixelShader: *mut ID3D11PixelShader, ppClassInstances: *const *mut ID3D11ClassInstance, NumClassInstances: ::UINT ) -> (), fn PSSetSamplers( &mut self, StartSlot: ::UINT, NumSamplers: ::UINT, ppSamplers: *const *mut ID3D11SamplerState ) -> (), fn VSSetShader( &mut self, pVertexShader: *mut ID3D11VertexShader, ppClassInstances: *const *mut ID3D11ClassInstance, NumClassInstances: ::UINT ) -> (), fn DrawIndexed( &mut self, IndexCount: ::UINT, StartIndexLocation: ::UINT, BaseVertexLocation: ::INT ) -> (), fn Draw(&mut self, VertexCount: ::UINT, StartVertexLocation: ::UINT) -> (), fn Map( &mut self, pResource: *mut ID3D11Resource, Subresource: ::UINT, MapType: D3D11_MAP, MapFlags: ::UINT, pMappedResource: *mut D3D11_MAPPED_SUBRESOURCE ) -> ::HRESULT, fn Unmap(&mut self, pResource: *mut ID3D11Resource, Subresource: ::UINT) -> (), fn PSSetConstantBuffers( &mut self, StartSlot: ::UINT, NumBuffers: ::UINT, ppConstantBuffers: *const *mut ID3D11Buffer ) -> (), fn IASetInputLayout(&mut self, pInputLayout: *mut ID3D11InputLayout) -> (), fn IASetVertexBuffers( &mut self, StartSlot: ::UINT, NumBuffers: ::UINT, ppVertexBuffers: *const *mut ID3D11Buffer, pStrides: *const ::UINT, pOffsets: *const ::UINT ) -> (), fn IASetIndexBuffer( &mut self, pIndexBuffer: *mut ID3D11Buffer, Format: ::DXGI_FORMAT, Offset: ::UINT ) -> (), fn DrawIndexedInstanced( &mut self, IndexCountPerInstance: ::UINT, InstanceCount: ::UINT, StartIndexLocation: ::UINT, BaseVertexLocation: ::INT, StartInstanceLocation: ::UINT ) -> (), fn DrawInstanced( &mut self, VertexCountPerInstance: ::UINT, InstanceCount: ::UINT, StartVertexLocation: ::UINT, StartInstanceLocation: ::UINT ) -> (), fn GSSetConstantBuffers( &mut self, StartSlot: ::UINT, NumBuffers: ::UINT, ppConstantBuffers: *const *mut ID3D11Buffer ) -> (), fn GSSetShader( &mut self, pShader: *mut ID3D11GeometryShader, ppClassInstances: *const *mut ID3D11ClassInstance, NumClassInstances: ::UINT ) -> (), fn IASetPrimitiveTopology(&mut self, Topology: D3D11_PRIMITIVE_TOPOLOGY) -> (), fn VSSetShaderResources( &mut self, StartSlot: ::UINT, NumViews: ::UINT, ppShaderResourceViews: *const *mut ID3D11ShaderResourceView ) -> (), fn VSSetSamplers( &mut self, StartSlot: ::UINT, NumSamplers: ::UINT, ppSamplers: *const *mut ID3D11SamplerState ) -> (), fn Begin(&mut self, pAsync: *mut ID3D11Asynchronous) -> (), fn End(&mut self, pAsync: *mut ID3D11Asynchronous) -> (), fn GetData( &mut self, pAsync: *mut ID3D11Asynchronous, pData: *mut ::c_void, DataSize: ::UINT, GetDataFlags: ::UINT ) -> ::HRESULT, fn SetPredication( &mut self, pPredicate: *mut ID3D11Predicate, PredicateValue: ::BOOL ) -> (), fn GSSetShaderResources( &mut self, StartSlot: ::UINT, NumViews: ::UINT, ppShaderResourceViews: *const *mut ID3D11ShaderResourceView ) -> (), fn GSSetSamplers( &mut self, StartSlot: ::UINT, NumSamplers: ::UINT, ppSamplers: *const *mut ID3D11SamplerState ) -> (), fn OMSetRenderTargets( &mut self, NumViews: ::UINT, ppRenderTargetViews: *const *mut ID3D11RenderTargetView, pDepthStencilView: *mut ID3D11DepthStencilView ) -> (), fn OMSetRenderTargetsAndUnorderedAccessViews( &mut self, NumRTVs: ::UINT, ppRenderTargetViews: *const *mut ID3D11RenderTargetView, pDepthStencilView: *mut ID3D11DepthStencilView, UAVStartSlot: ::UINT, NumUAVs: ::UINT, ppUnorderedAccessViews: *const *mut ID3D11UnorderedAccessView, pUAVInitialCounts: *const ::UINT ) -> (), fn OMSetBlendState( &mut self, pBlendState: *mut ID3D11BlendState, BlendFactor: &[::FLOAT; 4], SampleMask: ::UINT ) -> (), fn OMSetDepthStencilState( &mut self, pDepthStencilState: *mut ID3D11DepthStencilState, StencilRef: ::UINT ) -> (), fn SOSetTargets( &mut self, NumBuffers: ::UINT, ppSOTargets: *const *mut ID3D11Buffer, pOffsets: *const ::UINT ) -> (), fn DrawAuto(&mut self) -> (), fn DrawIndexedInstancedIndirect( &mut self, pBufferForArgs: *mut ID3D11Buffer, AlignedByteOffsetForArgs: ::UINT ) -> (), fn DrawInstancedIndirect( &mut self, pBufferForArgs: *mut ID3D11Buffer, AlignedByteOffsetForArgs: ::UINT ) -> (), fn Dispatch( &mut self, ThreadGroupCountX: ::UINT, ThreadGroupCountY: ::UINT, ThreadGroupCountZ: ::UINT ) -> (), fn DispatchIndirect( &mut self, pBufferForArgs: *mut ID3D11Buffer, AlignedByteOffsetForArgs: ::UINT ) -> (), fn RSSetState(&mut self, pRasterizerState: *mut ID3D11RasterizerState) -> (), fn RSSetViewports(&mut self, NumViewports: ::UINT, pViewports: *const D3D11_VIEWPORT) -> (), fn RSSetScissorRects(&mut self, NumRects: ::UINT, pRects: *const D3D11_RECT) -> (), fn CopySubresourceRegion( &mut self, pDstResource: *mut ID3D11Resource, DstSubresource: ::UINT, DstX: ::UINT, DstY: ::UINT, DstZ: ::UINT, pSrcResource: *mut ID3D11Resource, SrcSubresource: ::UINT, pSrcBox: *const D3D11_BOX ) -> (), fn CopyResource( &mut self, pDstResource: *mut ID3D11Resource, pSrcResource: *mut ID3D11Resource ) -> (), fn UpdateSubresource( &mut self, pDstResource: *mut ID3D11Resource, DstSubresource: ::UINT, pDstBox: *const D3D11_BOX, pSrcData: *const ::c_void, SrcRowPitch: ::UINT, SrcDepthPitch: ::UINT ) -> (), fn CopyStructureCount( &mut self, pDstBuffer: *mut ID3D11Buffer, DstAlignedByteOffset: ::UINT, pSrcView: *mut ID3D11UnorderedAccessView ) -> (), fn ClearRenderTargetView( &mut self, pRenderTargetView: *mut ID3D11RenderTargetView, ColorRGBA: &[::FLOAT; 4] ) -> (), fn ClearUnorderedAccessViewUint( &mut self, pUnorderedAccessView: *mut ID3D11UnorderedAccessView, Values: &[::UINT; 4] ) -> (), fn ClearUnorderedAccessViewFloat( &mut self, pUnorderedAccessView: *mut ID3D11UnorderedAccessView, Values: &[::FLOAT; 4] ) -> (), fn ClearDepthStencilView( &mut self, pDepthStencilView: *mut ID3D11DepthStencilView, ClearFlags: ::UINT, Depth: ::FLOAT, Stencil: ::UINT8 ) -> (), fn GenerateMips(&mut self, pShaderResourceView: *mut ID3D11ShaderResourceView) -> (), fn SetResourceMinLOD(&mut self, pResource: *mut ID3D11Resource, MinLOD: ::FLOAT) -> (), fn GetResourceMinLOD(&mut self, pResource: *mut ID3D11Resource) -> ::FLOAT, fn ResolveSubresource( &mut self, pDstResource: *mut ID3D11Resource, DstSubresource: ::UINT, pSrcResource: *mut ID3D11Resource, SrcSubresource: ::UINT, Format: ::DXGI_FORMAT ) -> (), fn ExecuteCommandList(&mut self, pCommandList: *mut ID3D11CommandList) -> (), fn HSSetShaderResources( &mut self, StartSlot: ::UINT, NumViews: ::UINT, ppShaderResourceViews: *const *mut ID3D11ShaderResourceView ) -> (), fn HSSetShader( &mut self, pHullShader: *mut ID3D11HullShader, ppClassInstances: *const *mut ID3D11ClassInstance, NumClassInstances: ::UINT ) -> (), fn HSSetSamplers( &mut self, StartSlot: ::UINT, NumSamplers: ::UINT, ppSamplers: *const *mut ID3D11SamplerState ) -> (), fn HSSetConstantBuffers( &mut self, StartSlot: ::UINT, NumBuffers: ::UINT, ppConstantBuffers: *const *mut ID3D11Buffer ) -> (), fn DSSetShaderResources( &mut self, StartSlot: ::UINT, NumViews: ::UINT, ppShaderResourceViews: *const *mut ID3D11ShaderResourceView ) -> (), fn DSSetShader( &mut self, pDomainShader: *mut ID3D11DomainShader, ppClassInstances: *const *mut ID3D11ClassInstance, NumClassInstances: ::UINT ) -> (), fn DSSetSamplers( &mut self, StartSlot: ::UINT, NumSamplers: ::UINT, ppSamplers: *const *mut ID3D11SamplerState ) -> (), fn DSSetConstantBuffers( &mut self, StartSlot: ::UINT, NumBuffers: ::UINT, ppConstantBuffers: *const *mut ID3D11Buffer ) -> (), fn CSSetShaderResources( &mut self, StartSlot: ::UINT, NumViews: ::UINT, ppShaderResourceViews: *const *mut ID3D11ShaderResourceView ) -> (), fn CSSetUnorderedAccessViews( &mut self, StartSlot: ::UINT, NumUAVs: ::UINT, ppUnorderedAccessViews: *const *mut ID3D11UnorderedAccessView ) -> (), fn CSSetShader( &mut self, pComputeShader: *mut ID3D11ComputeShader, ppClassInstances: *const *mut ID3D11ClassInstance, NumClassInstances: ::UINT ) -> (), fn CSSetSamplers( &mut self, StartSlot: ::UINT, NumSamplers: ::UINT, ppSamplers: *const *mut ID3D11SamplerState ) -> (), fn CSSetConstantBuffers( &mut self, StartSlot: ::UINT, NumBuffers: ::UINT, ppConstantBuffers: *const *mut ID3D11Buffer ) -> (), fn VSGetConstantBuffers( &mut self, StartSlot: ::UINT, NumBuffers: ::UINT, ppConstantBuffers: *mut *mut ID3D11Buffer ) -> (), fn PSGetShaderResources( &mut self, StartSlot: ::UINT, NumViews: ::UINT, ppShaderResourceViews: *mut *mut ID3D11ShaderResourceView ) -> (), fn PSGetShader( &mut self, ppPixelShader: *mut *mut ID3D11PixelShader, ppClassInstances: *mut *mut ID3D11ClassInstance, pNumClassInstances: *mut ::UINT ) -> (), fn PSGetSamplers( &mut self, StartSlot: ::UINT, NumSamplers: ::UINT, ppSamplers: *mut *mut ID3D11SamplerState ) -> (), fn VSGetShader( &mut self, ppVertexShader: *mut *mut ID3D11VertexShader, ppClassInstances: *mut *mut ID3D11ClassInstance, pNumClassInstances: *mut ::UINT ) -> (), fn PSGetConstantBuffers( &mut self, StartSlot: ::UINT, NumBuffers: ::UINT, ppConstantBuffers: *mut *mut ID3D11Buffer ) -> (), fn IAGetInputLayout(&mut self, ppInputLayout: *mut *mut ID3D11InputLayout) -> (), fn IAGetVertexBuffers( &mut self, StartSlot: ::UINT, NumBuffers: ::UINT, ppVertexBuffers: *mut *mut ID3D11Buffer, pStrides: *mut ::UINT, pOffsets: *mut ::UINT ) -> (), fn IAGetIndexBuffer( &mut self, pIndexBuffer: *mut *mut ID3D11Buffer, Format: *mut ::DXGI_FORMAT, Offset: *mut ::UINT ) -> (), fn GSGetConstantBuffers( &mut self, StartSlot: ::UINT, NumBuffers: ::UINT, ppConstantBuffers: *mut *mut ID3D11Buffer ) -> (), fn GSGetShader( &mut self, ppGeometryShader: *mut *mut ID3D11GeometryShader, ppClassInstances: *mut *mut ID3D11ClassInstance, pNumClassInstances: *mut ::UINT ) -> (), fn IAGetPrimitiveTopology(&mut self, pTopology: *mut D3D11_PRIMITIVE_TOPOLOGY) -> (), fn VSGetShaderResources( &mut self, StartSlot: ::UINT, NumViews: ::UINT, ppShaderResourceViews: *mut *mut ID3D11ShaderResourceView ) -> (), fn VSGetSamplers( &mut self, StartSlot: ::UINT, NumSamplers: ::UINT, ppSamplers: *mut *mut ID3D11SamplerState ) -> (), fn GetPredication( &mut self, ppPredicate: *mut *mut ID3D11Predicate, pPredicateValue: *mut ::BOOL ) -> (), fn GSGetShaderResources( &mut self, StartSlot: ::UINT, NumViews: ::UINT, ppShaderResourceViews: *mut *mut ID3D11ShaderResourceView ) -> (), fn GSGetSamplers( &mut self, StartSlot: ::UINT, NumSamplers: ::UINT, ppSamplers: *mut *mut ID3D11SamplerState ) -> (), fn OMGetRenderTargets( &mut self, NumViews: ::UINT, ppRenderTargetViews: *mut *mut ID3D11RenderTargetView, ppDepthStencilView: *mut *mut ID3D11DepthStencilView ) -> (), fn OMGetRenderTargetsAndUnorderedAccessViews( &mut self, NumRTVs: ::UINT, ppRenderTargetViews: *mut *mut ID3D11RenderTargetView, ppDepthStencilView: *mut *mut ID3D11DepthStencilView, UAVStartSlot: ::UINT, ppUnorderedAccessViews: *mut *mut ID3D11UnorderedAccessView ) -> (), fn OMGetBlendState( &mut self, ppBlendState: *mut *mut ID3D11BlendState, BlendFactor: &mut [::FLOAT; 4], pSampleMask: *mut ::UINT ) -> (), fn OMGetDepthStencilState( &mut self, ppDepthStencilState: *mut *mut ID3D11DepthStencilState, pStencilRef: *mut ::UINT ) -> (), fn SOGetTargets(&mut self, NumBuffers: ::UINT, ppSOTargets: *mut *mut ID3D11Buffer) -> (), fn RSGetState(&mut self, ppRasterizerState: *mut *mut ID3D11RasterizerState) -> (), fn RSGetViewports(&mut self, pNumViewports: *mut ::UINT, pViewports: *mut D3D11_VIEWPORT ) -> (), fn RSGetScissorRects(&mut self, pNumRects: *mut ::UINT, pRects: *mut D3D11_RECT) -> (), fn HSGetShaderResources( &mut self, StartSlot: ::UINT, NumViews: ::UINT, ppShaderResourceViews: *mut *mut ID3D11ShaderResourceView ) -> (), fn HSGetShader( &mut self, ppHullShader: *mut *mut ID3D11HullShader, ppClassInstances: *mut *mut ID3D11ClassInstance, pNumClassInstances: *mut ::UINT ) -> (), fn HSGetSamplers( &mut self, StartSlot: ::UINT, NumSamplers: ::UINT, ppSamplers: *mut *mut ID3D11SamplerState ) -> (), fn HSGetConstantBuffers( &mut self, StartSlot: ::UINT, NumBuffers: ::UINT, ppConstantBuffers: *mut *mut ID3D11Buffer ) -> (), fn DSGetShaderResources( &mut self, StartSlot: ::UINT, NumViews: ::UINT, ppShaderResourceViews: *mut *mut ID3D11ShaderResourceView ) -> (), fn DSGetShader( &mut self, ppDomainShader: *mut *mut ID3D11DomainShader, ppClassInstances: *mut *mut ID3D11ClassInstance, pNumClassInstances: *mut ::UINT ) -> (), fn DSGetSamplers( &mut self, StartSlot: ::UINT, NumSamplers: ::UINT, ppSamplers: *mut *mut ID3D11SamplerState ) -> (), fn DSGetConstantBuffers( &mut self, StartSlot: ::UINT, NumBuffers: ::UINT, ppConstantBuffers: *mut *mut ID3D11Buffer ) -> (), fn CSGetShaderResources( &mut self, StartSlot: ::UINT, NumViews: ::UINT, ppShaderResourceViews: *mut *mut ID3D11ShaderResourceView ) -> (), fn CSGetUnorderedAccessViews( &mut self, StartSlot: ::UINT, NumUAVs: ::UINT, ppUnorderedAccessViews: *mut *mut ID3D11UnorderedAccessView ) -> (), fn CSGetShader( &mut self, ppComputeShader: *mut *mut ID3D11ComputeShader, ppClassInstances: *mut *mut ID3D11ClassInstance, pNumClassInstances: *mut ::UINT ) -> (), fn CSGetSamplers( &mut self, StartSlot: ::UINT, NumSamplers: ::UINT, ppSamplers: *mut *mut ID3D11SamplerState ) -> (), fn CSGetConstantBuffers( &mut self, StartSlot: ::UINT, NumBuffers: ::UINT, ppConstantBuffers: *mut *mut ID3D11Buffer ) -> (), fn ClearState(&mut self) -> (), fn Flush(&mut self) -> (), fn GetType(&mut self) -> D3D11_DEVICE_CONTEXT_TYPE, fn GetContextFlags(&mut self) -> ::UINT, fn FinishCommandList( &mut self, RestoreDeferredContextState: ::BOOL, ppCommandList: *mut *mut ID3D11CommandList ) -> ::HRESULT } ); DEFINE_GUID!(D3D11_DECODER_PROFILE_MPEG2_MOCOMP, 0xe6a9f44b, 0x61b0, 0x4563, 0x9e, 0xa4, 0x63, 0xd2, 0xa3, 0xc6, 0xfe, 0x66); DEFINE_GUID!(D3D11_DECODER_PROFILE_MPEG2_IDCT, 0xbf22ad00, 0x03ea, 0x4690, 0x80, 0x77, 0x47,0x33, 0x46, 0x20, 0x9b, 0x7e); DEFINE_GUID!(D3D11_DECODER_PROFILE_MPEG2_VLD, 0xee27417f, 0x5e28, 0x4e65, 0xbe, 0xea, 0x1d, 0x26, 0xb5, 0x08, 0xad, 0xc9); DEFINE_GUID!(D3D11_DECODER_PROFILE_MPEG1_VLD, 0x6f3ec719, 0x3735, 0x42cc, 0x80, 0x63, 0x65, 0xcc, 0x3c, 0xb3, 0x66, 0x16); DEFINE_GUID!(D3D11_DECODER_PROFILE_MPEG2and1_VLD, 0x86695f12, 0x340e, 0x4f04, 0x9f, 0xd3, 0x92, 0x53, 0xdd, 0x32, 0x74, 0x60); DEFINE_GUID!(D3D11_DECODER_PROFILE_H264_MOCOMP_NOFGT, 0x1b81be64, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5); DEFINE_GUID!(D3D11_DECODER_PROFILE_H264_MOCOMP_FGT, 0x1b81be65, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5); DEFINE_GUID!(D3D11_DECODER_PROFILE_H264_IDCT_NOFGT, 0x1b81be66, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5); DEFINE_GUID!(D3D11_DECODER_PROFILE_H264_IDCT_FGT, 0x1b81be67, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5); DEFINE_GUID!(D3D11_DECODER_PROFILE_H264_VLD_NOFGT, 0x1b81be68, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5); DEFINE_GUID!(D3D11_DECODER_PROFILE_H264_VLD_FGT, 0x1b81be69, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5); DEFINE_GUID!(D3D11_DECODER_PROFILE_H264_VLD_WITHFMOASO_NOFGT, 0xd5f04ff9, 0x3418, 0x45d8, 0x95, 0x61, 0x32, 0xa7, 0x6a, 0xae, 0x2d, 0xdd); DEFINE_GUID!(D3D11_DECODER_PROFILE_H264_VLD_STEREO_PROGRESSIVE_NOFGT, 0xd79be8da, 0x0cf1, 0x4c81, 0xb8, 0x2a, 0x69, 0xa4, 0xe2, 0x36, 0xf4, 0x3d); DEFINE_GUID!(D3D11_DECODER_PROFILE_H264_VLD_STEREO_NOFGT, 0xf9aaccbb, 0xc2b6, 0x4cfc, 0x87, 0x79, 0x57, 0x07, 0xb1, 0x76, 0x05, 0x52); DEFINE_GUID!(D3D11_DECODER_PROFILE_H264_VLD_MULTIVIEW_NOFGT, 0x705b9d82, 0x76cf, 0x49d6, 0xb7, 0xe6, 0xac, 0x88, 0x72, 0xdb, 0x01, 0x3c); DEFINE_GUID!(D3D11_DECODER_PROFILE_WMV8_POSTPROC, 0x1b81be80, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5); DEFINE_GUID!(D3D11_DECODER_PROFILE_WMV8_MOCOMP, 0x1b81be81, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5); DEFINE_GUID!(D3D11_DECODER_PROFILE_WMV9_POSTPROC, 0x1b81be90, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5); DEFINE_GUID!(D3D11_DECODER_PROFILE_WMV9_MOCOMP, 0x1b81be91, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5); DEFINE_GUID!(D3D11_DECODER_PROFILE_WMV9_IDCT, 0x1b81be94, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5); DEFINE_GUID!(D3D11_DECODER_PROFILE_VC1_POSTPROC, 0x1b81beA0, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5); DEFINE_GUID!(D3D11_DECODER_PROFILE_VC1_MOCOMP, 0x1b81beA1, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5); DEFINE_GUID!(D3D11_DECODER_PROFILE_VC1_IDCT, 0x1b81beA2, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5); DEFINE_GUID!(D3D11_DECODER_PROFILE_VC1_VLD, 0x1b81beA3, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5); DEFINE_GUID!(D3D11_DECODER_PROFILE_VC1_D2010, 0x1b81beA4, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5); DEFINE_GUID!(D3D11_DECODER_PROFILE_MPEG4PT2_VLD_SIMPLE, 0xefd64d74, 0xc9e8, 0x41d7, 0xa5, 0xe9, 0xe9, 0xb0, 0xe3, 0x9f, 0xa3, 0x19); DEFINE_GUID!(D3D11_DECODER_PROFILE_MPEG4PT2_VLD_ADVSIMPLE_NOGMC, 0xed418a9f, 0x010d, 0x4eda, 0x9a, 0xe3, 0x9a, 0x65, 0x35, 0x8d, 0x8d, 0x2e); DEFINE_GUID!(D3D11_DECODER_PROFILE_MPEG4PT2_VLD_ADVSIMPLE_GMC, 0xab998b5b, 0x4258, 0x44a9, 0x9f, 0xeb, 0x94, 0xe5, 0x97, 0xa6, 0xba, 0xae); DEFINE_GUID!(D3D11_DECODER_PROFILE_HEVC_VLD_MAIN, 0x5b11d51b, 0x2f4c, 0x4452, 0xbc, 0xc3, 0x09, 0xf2, 0xa1, 0x16, 0x0c, 0xc0); DEFINE_GUID!(D3D11_DECODER_PROFILE_HEVC_VLD_MAIN10, 0x107af0e0, 0xef1a, 0x4d19, 0xab, 0xa8, 0x67, 0xa1, 0x63, 0x07, 0x3d, 0x13); STRUCT!{struct D3D11_VIDEO_DECODER_DESC { Guid: ::GUID, SampleWidth: ::UINT, SampleHeight: ::UINT, OutputFormat: ::DXGI_FORMAT, }} STRUCT!{struct D3D11_VIDEO_DECODER_CONFIG { guidConfigBitstreamEncryption: ::GUID, guidConfigMBcontrolEncryption: ::GUID, guidConfigResidDiffEncryption: ::GUID, ConfigBitstreamRaw: ::UINT, ConfigMBcontrolRasterOrder: ::UINT, ConfigResidDiffHost: ::UINT, ConfigSpatialResid8: ::UINT, ConfigResid8Subtraction: ::UINT, ConfigSpatialHost8or9Clipping: ::UINT, ConfigSpatialResidInterleaved: ::UINT, ConfigIntraResidUnsigned: ::UINT, ConfigResidDiffAccelerator: ::UINT, ConfigHostInverseScan: ::UINT, ConfigSpecificIDCT: ::UINT, Config4GroupedCoefs: ::UINT, ConfigMinRenderTargetBuffCount: ::USHORT, ConfigDecoderSpecific: ::USHORT, }} ENUM!{enum D3D11_VIDEO_DECODER_BUFFER_TYPE { D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS = 0, D3D11_VIDEO_DECODER_BUFFER_MACROBLOCK_CONTROL = 1, D3D11_VIDEO_DECODER_BUFFER_RESIDUAL_DIFFERENCE = 2, D3D11_VIDEO_DECODER_BUFFER_DEBLOCKING_CONTROL = 3, D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX = 4, D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL = 5, D3D11_VIDEO_DECODER_BUFFER_BITSTREAM = 6, D3D11_VIDEO_DECODER_BUFFER_MOTION_VECTOR = 7, D3D11_VIDEO_DECODER_BUFFER_FILM_GRAIN = 8, }} STRUCT!{struct D3D11_AES_CTR_IV { IV: ::UINT64, Count: ::UINT64, }} STRUCT!{struct D3D11_ENCRYPTED_BLOCK_INFO { NumEncryptedBytesAtBeginning: ::UINT, NumBytesInSkipPattern: ::UINT, NumBytesInEncryptPattern: ::UINT, }} STRUCT!{struct D3D11_VIDEO_DECODER_BUFFER_DESC { BufferType: D3D11_VIDEO_DECODER_BUFFER_TYPE, BufferIndex: ::UINT, DataOffset: ::UINT, DataSize: ::UINT, FirstMBaddress: ::UINT, NumMBsInBuffer: ::UINT, Width: ::UINT, Height: ::UINT, Stride: ::UINT, ReservedBits: ::UINT, pIV: *mut ::c_void, IVSize: ::UINT, PartialEncryption: ::BOOL, EncryptedBlockInfo: D3D11_ENCRYPTED_BLOCK_INFO, }} STRUCT!{struct D3D11_VIDEO_DECODER_EXTENSION { Function: ::UINT, pPrivateInputData: *mut ::c_void, PrivateInputDataSize: ::UINT, pPrivateOutputData: *mut ::c_void, PrivateOutputDataSize: ::UINT, ResourceCount: ::UINT, ppResourceList: *mut *mut ID3D11Resource, }} RIDL!( interface ID3D11VideoDecoder(ID3D11VideoDecoderVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn GetCreationParameters( &mut self, pVideoDesc: *mut D3D11_VIDEO_DECODER_DESC, pConfig: *mut D3D11_VIDEO_DECODER_CONFIG ) -> ::HRESULT, fn GetDriverHandle(&mut self, pDriverHandle: *mut ::HANDLE) -> ::HRESULT } ); FLAGS!{enum D3D11_VIDEO_PROCESSOR_FORMAT_SUPPORT { D3D11_VIDEO_PROCESSOR_FORMAT_SUPPORT_INPUT = 0x1, D3D11_VIDEO_PROCESSOR_FORMAT_SUPPORT_OUTPUT = 0x2, }} FLAGS!{enum D3D11_VIDEO_PROCESSOR_DEVICE_CAPS { D3D11_VIDEO_PROCESSOR_DEVICE_CAPS_LINEAR_SPACE = 0x1, D3D11_VIDEO_PROCESSOR_DEVICE_CAPS_xvYCC = 0x2, D3D11_VIDEO_PROCESSOR_DEVICE_CAPS_RGB_RANGE_CONVERSION = 0x4, D3D11_VIDEO_PROCESSOR_DEVICE_CAPS_YCbCr_MATRIX_CONVERSION = 0x8, D3D11_VIDEO_PROCESSOR_DEVICE_CAPS_NOMINAL_RANGE = 0x10, }} FLAGS!{enum D3D11_VIDEO_PROCESSOR_FEATURE_CAPS { D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_ALPHA_FILL = 0x1, D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_CONSTRICTION = 0x2, D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_LUMA_KEY = 0x4, D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_ALPHA_PALETTE = 0x8, D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_LEGACY = 0x10, D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_STEREO = 0x20, D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_ROTATION = 0x40, D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_ALPHA_STREAM = 0x80, D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_PIXEL_ASPECT_RATIO = 0x100, D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_MIRROR = 0x200, D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_SHADER_USAGE = 0x400, }} FLAGS!{enum D3D11_VIDEO_PROCESSOR_FILTER_CAPS { D3D11_VIDEO_PROCESSOR_FILTER_CAPS_BRIGHTNESS = 0x1, D3D11_VIDEO_PROCESSOR_FILTER_CAPS_CONTRAST = 0x2, D3D11_VIDEO_PROCESSOR_FILTER_CAPS_HUE = 0x4, D3D11_VIDEO_PROCESSOR_FILTER_CAPS_SATURATION = 0x8, D3D11_VIDEO_PROCESSOR_FILTER_CAPS_NOISE_REDUCTION = 0x10, D3D11_VIDEO_PROCESSOR_FILTER_CAPS_EDGE_ENHANCEMENT = 0x20, D3D11_VIDEO_PROCESSOR_FILTER_CAPS_ANAMORPHIC_SCALING = 0x40, D3D11_VIDEO_PROCESSOR_FILTER_CAPS_STEREO_ADJUSTMENT = 0x80, }} FLAGS!{enum D3D11_VIDEO_PROCESSOR_FORMAT_CAPS { D3D11_VIDEO_PROCESSOR_FORMAT_CAPS_RGB_INTERLACED = 0x1, D3D11_VIDEO_PROCESSOR_FORMAT_CAPS_RGB_PROCAMP = 0x2, D3D11_VIDEO_PROCESSOR_FORMAT_CAPS_RGB_LUMA_KEY = 0x4, D3D11_VIDEO_PROCESSOR_FORMAT_CAPS_PALETTE_INTERLACED = 0x8, }} FLAGS!{enum D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS { D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_DENOISE = 0x1, D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_DERINGING = 0x2, D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_EDGE_ENHANCEMENT = 0x4, D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_COLOR_CORRECTION = 0x8, D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_FLESH_TONE_MAPPING = 0x10, D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_IMAGE_STABILIZATION = 0x20, D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_SUPER_RESOLUTION = 0x40, D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_ANAMORPHIC_SCALING = 0x80, }} FLAGS!{enum D3D11_VIDEO_PROCESSOR_STEREO_CAPS { D3D11_VIDEO_PROCESSOR_STEREO_CAPS_MONO_OFFSET = 0x1, D3D11_VIDEO_PROCESSOR_STEREO_CAPS_ROW_INTERLEAVED = 0x2, D3D11_VIDEO_PROCESSOR_STEREO_CAPS_COLUMN_INTERLEAVED = 0x4, D3D11_VIDEO_PROCESSOR_STEREO_CAPS_CHECKERBOARD = 0x8, D3D11_VIDEO_PROCESSOR_STEREO_CAPS_FLIP_MODE = 0x10, }} STRUCT!{struct D3D11_VIDEO_PROCESSOR_CAPS { DeviceCaps: ::UINT, FeatureCaps: ::UINT, FilterCaps: ::UINT, InputFormatCaps: ::UINT, AutoStreamCaps: ::UINT, StereoCaps: ::UINT, RateConversionCapsCount: ::UINT, MaxInputStreams: ::UINT, MaxStreamStates: ::UINT, }} FLAGS!{enum D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS { D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_BLEND = 0x1, D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_BOB = 0x2, D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_ADAPTIVE = 0x4, D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_MOTION_COMPENSATION = 0x8, D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_INVERSE_TELECINE = 0x10, D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_FRAME_RATE_CONVERSION = 0x20, }} FLAGS!{enum D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS { D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_32 = 0x1, D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_22 = 0x2, D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_2224 = 0x4, D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_2332 = 0x8, D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_32322 = 0x10, D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_55 = 0x20, D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_64 = 0x40, D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_87 = 0x80, D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_222222222223 = 0x100, D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_OTHER = 0x80000000, }} STRUCT!{struct D3D11_VIDEO_PROCESSOR_RATE_CONVERSION_CAPS { PastFrames: ::UINT, FutureFrames: ::UINT, ProcessorCaps: ::UINT, ITelecineCaps: ::UINT, CustomRateCount: ::UINT, }} FLAGS!{enum D3D11_CONTENT_PROTECTION_CAPS { D3D11_CONTENT_PROTECTION_CAPS_SOFTWARE = 0x1, D3D11_CONTENT_PROTECTION_CAPS_HARDWARE = 0x2, D3D11_CONTENT_PROTECTION_CAPS_PROTECTION_ALWAYS_ON = 0x4, D3D11_CONTENT_PROTECTION_CAPS_PARTIAL_DECRYPTION = 0x8, D3D11_CONTENT_PROTECTION_CAPS_CONTENT_KEY = 0x10, D3D11_CONTENT_PROTECTION_CAPS_FRESHEN_SESSION_KEY = 0x20, D3D11_CONTENT_PROTECTION_CAPS_ENCRYPTED_READ_BACK = 0x40, D3D11_CONTENT_PROTECTION_CAPS_ENCRYPTED_READ_BACK_KEY = 0x80, D3D11_CONTENT_PROTECTION_CAPS_SEQUENTIAL_CTR_IV = 0x100, D3D11_CONTENT_PROTECTION_CAPS_ENCRYPT_SLICEDATA_ONLY = 0x200, D3D11_CONTENT_PROTECTION_CAPS_DECRYPTION_BLT = 0x400, D3D11_CONTENT_PROTECTION_CAPS_HARDWARE_PROTECT_UNCOMPRESSED = 0x800, D3D11_CONTENT_PROTECTION_CAPS_HARDWARE_PROTECTED_MEMORY_PAGEABLE = 0x1000, D3D11_CONTENT_PROTECTION_CAPS_HARDWARE_TEARDOWN = 0x2000, D3D11_CONTENT_PROTECTION_CAPS_HARDWARE_DRM_COMMUNICATION = 0x4000, }} DEFINE_GUID!(D3D11_CRYPTO_TYPE_AES128_CTR, 0x9b6bd711, 0x4f74, 0x41c9, 0x9e, 0x7b, 0xb, 0xe2, 0xd7, 0xd9, 0x3b, 0x4f); DEFINE_GUID!(D3D11_DECODER_ENCRYPTION_HW_CENC, 0x89d6ac4f, 0x9f2, 0x4229, 0xb2, 0xcd, 0x37, 0x74, 0xa, 0x6d, 0xfd, 0x81); DEFINE_GUID!(D3D11_KEY_EXCHANGE_HW_PROTECTION, 0xb1170d8a, 0x628d, 0x4da3, 0xad, 0x3b, 0x82, 0xdd, 0xb0, 0x8b, 0x49, 0x70); STRUCT!{struct D3D11_VIDEO_CONTENT_PROTECTION_CAPS { Caps: ::UINT, KeyExchangeTypeCount: ::UINT, BlockAlignmentSize: ::UINT, ProtectedMemorySize: ::ULONGLONG, }} STRUCT!{struct D3D11_VIDEO_PROCESSOR_CUSTOM_RATE { CustomRate: ::DXGI_RATIONAL, OutputFrames: ::UINT, InputInterlaced: ::BOOL, InputFramesOrFields: ::UINT, }} ENUM!{enum D3D11_VIDEO_PROCESSOR_FILTER { D3D11_VIDEO_PROCESSOR_FILTER_BRIGHTNESS = 0, D3D11_VIDEO_PROCESSOR_FILTER_CONTRAST = 1, D3D11_VIDEO_PROCESSOR_FILTER_HUE = 2, D3D11_VIDEO_PROCESSOR_FILTER_SATURATION = 3, D3D11_VIDEO_PROCESSOR_FILTER_NOISE_REDUCTION = 4, D3D11_VIDEO_PROCESSOR_FILTER_EDGE_ENHANCEMENT = 5, D3D11_VIDEO_PROCESSOR_FILTER_ANAMORPHIC_SCALING = 6, D3D11_VIDEO_PROCESSOR_FILTER_STEREO_ADJUSTMENT = 7, }} STRUCT!{struct D3D11_VIDEO_PROCESSOR_FILTER_RANGE { Minimum: ::c_int, Maximum: ::c_int, Default: ::c_int, Multiplier: ::c_float, }} ENUM!{enum D3D11_VIDEO_FRAME_FORMAT { D3D11_VIDEO_FRAME_FORMAT_PROGRESSIVE = 0, D3D11_VIDEO_FRAME_FORMAT_INTERLACED_TOP_FIELD_FIRST = 1, D3D11_VIDEO_FRAME_FORMAT_INTERLACED_BOTTOM_FIELD_FIRST = 2, }} ENUM!{enum D3D11_VIDEO_USAGE { PLAYBACK_NORMAL = 0, OPTIMAL_SPEED = 1, OPTIMAL_QUALITY = 2, }} STRUCT!{struct D3D11_VIDEO_PROCESSOR_CONTENT_DESC { InputFrameFormat: D3D11_VIDEO_FRAME_FORMAT, InputFrameRate: ::DXGI_RATIONAL, InputWidth: ::UINT, InputHeight: ::UINT, OutputFrameRate: ::DXGI_RATIONAL, OutputWidth: ::UINT, OutputHeight: ::UINT, Usage: D3D11_VIDEO_USAGE, }} RIDL!( interface ID3D11VideoProcessorEnumerator(ID3D11VideoProcessorEnumeratorVtbl) : ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn GetVideoProcessorContentDesc( &mut self, pContentDesc: *mut D3D11_VIDEO_PROCESSOR_CONTENT_DESC ) -> ::HRESULT, fn CheckVideoProcessorFormat( &mut self, Format: ::DXGI_FORMAT, pFlags: *mut ::UINT ) -> ::HRESULT, fn GetVideoProcessorCaps( &mut self, pCaps: *mut D3D11_VIDEO_PROCESSOR_CAPS ) -> ::HRESULT, fn GetVideoProcessorRateConversionCaps( &mut self, TypeIndex: ::UINT, pCaps: *mut D3D11_VIDEO_PROCESSOR_RATE_CONVERSION_CAPS ) -> ::HRESULT, fn GetVideoProcessorCustomRate( &mut self, TypeIndex: ::UINT, CustomRateIndex: ::UINT, pRate: *mut D3D11_VIDEO_PROCESSOR_CUSTOM_RATE ) -> ::HRESULT, fn GetVideoProcessorFilterRange( &mut self, Filter: D3D11_VIDEO_PROCESSOR_FILTER, pRange: *mut D3D11_VIDEO_PROCESSOR_FILTER_RANGE ) -> ::HRESULT } ); STRUCT!{struct D3D11_VIDEO_COLOR_RGBA { R: ::c_float, G: ::c_float, B: ::c_float, A: ::c_float, }} STRUCT!{struct D3D11_VIDEO_COLOR_YCbCrA { Y: ::c_float, Cb: ::c_float, Cr: ::c_float, A: ::c_float, }} STRUCT!{struct D3D11_VIDEO_COLOR { u: [::c_float; 4], }} UNION!(D3D11_VIDEO_COLOR, u, YCbCr, YCbCr_mut, D3D11_VIDEO_COLOR_YCbCrA); UNION!(D3D11_VIDEO_COLOR, u, RGBA, RGBA_mut, D3D11_VIDEO_COLOR_RGBA); ENUM!{enum D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE { D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE_UNDEFINED = 0, D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE_16_235 = 1, D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE_0_255 = 2, }} STRUCT!{struct D3D11_VIDEO_PROCESSOR_COLOR_SPACE { bit_fields: ::UINT, }} BITFIELD!(D3D11_VIDEO_PROCESSOR_COLOR_SPACE bit_fields: ::UINT [ Usage set_Usage[0..1], RGB_Range set_RGB_Range[1..2], YCbCr_Matrix set_YCbCr_Matrix[2..3], YCbCr_xvYCC set_YCbCr_xvYCC[3..4], Nominal_Range set_Nominal_Range[4..6], Reserved set_Reserved[27..32], ]); ENUM!{enum D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE { D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE_OPAQUE = 0, D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE_BACKGROUND = 1, D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE_DESTINATION = 2, D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE_SOURCE_STREAM = 3, }} ENUM!{enum D3D11_VIDEO_PROCESSOR_OUTPUT_RATE { D3D11_VIDEO_PROCESSOR_OUTPUT_RATE_NORMAL = 0, D3D11_VIDEO_PROCESSOR_OUTPUT_RATE_HALF = 1, D3D11_VIDEO_PROCESSOR_OUTPUT_RATE_CUSTOM = 2, }} ENUM!{enum D3D11_VIDEO_PROCESSOR_STEREO_FORMAT { D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_MONO = 0, D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_HORIZONTAL = 1, D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_VERTICAL = 2, D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_SEPARATE = 3, D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_MONO_OFFSET = 4, D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_ROW_INTERLEAVED = 5, D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_COLUMN_INTERLEAVED = 6, D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_CHECKERBOARD = 7, }} ENUM!{enum D3D11_VIDEO_PROCESSOR_STEREO_FLIP_MODE { D3D11_VIDEO_PROCESSOR_STEREO_FLIP_NONE = 0, D3D11_VIDEO_PROCESSOR_STEREO_FLIP_FRAME0 = 1, D3D11_VIDEO_PROCESSOR_STEREO_FLIP_FRAME1 = 2, }} ENUM!{enum D3D11_VIDEO_PROCESSOR_ROTATION { D3D11_VIDEO_PROCESSOR_ROTATION_IDENTITY = 0, D3D11_VIDEO_PROCESSOR_ROTATION_90 = 1, D3D11_VIDEO_PROCESSOR_ROTATION_180 = 2, D3D11_VIDEO_PROCESSOR_ROTATION_270 = 3, }} STRUCT!{struct D3D11_VIDEO_PROCESSOR_STREAM { Enable: ::BOOL, OutputIndex: ::UINT, InputFrameOrField: ::UINT, PastFrames: ::UINT, FutureFrames: ::UINT, ppPastSurfaces: *mut *mut ID3D11VideoProcessorInputView, pInputSurface: *mut ID3D11VideoProcessorInputView, ppFutureSurfaces: *mut *mut ID3D11VideoProcessorInputView, ppPastSurfacesRight: *mut *mut ID3D11VideoProcessorInputView, pInputSurfaceRight: *mut ID3D11VideoProcessorInputView, ppFutureSurfacesRight: *mut *mut ID3D11VideoProcessorInputView, }} RIDL!( interface ID3D11VideoProcessor(ID3D11VideoProcessorVtbl) : ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn GetContentDesc(&mut self, pDesc: *mut D3D11_VIDEO_PROCESSOR_CONTENT_DESC) -> (), fn GetRateConversionCaps(&mut self, pCaps: *mut D3D11_VIDEO_PROCESSOR_RATE_CONVERSION_CAPS ) -> () } ); STRUCT!{struct D3D11_OMAC { Omac: [::BYTE; 16], }} ENUM!{enum D3D11_AUTHENTICATED_CHANNEL_TYPE { D3D11_AUTHENTICATED_CHANNEL_D3D11 = 1, D3D11_AUTHENTICATED_CHANNEL_DRIVER_SOFTWARE = 2, D3D11_AUTHENTICATED_CHANNEL_DRIVER_HARDWARE = 3, }} RIDL!( interface ID3D11AuthenticatedChannel(ID3D11AuthenticatedChannelVtbl) : ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn GetCertificateSize(&mut self, pCertificateSize: *mut ::UINT) -> ::HRESULT, fn GetCertificate(&mut self, CertificateSize: ::UINT, pCertificate: *mut ::BYTE) -> ::HRESULT, fn GetChannelHandle(&mut self, pChannelHandle: *mut ::HANDLE) -> () } ); DEFINE_GUID!(D3D11_AUTHENTICATED_QUERY_PROTECTION, 0xa84eb584, 0xc495, 0x48aa, 0xb9, 0x4d, 0x8b, 0xd2, 0xd6, 0xfb, 0xce, 0x5); DEFINE_GUID!(D3D11_AUTHENTICATED_QUERY_CHANNEL_TYPE, 0xbc1b18a5, 0xb1fb, 0x42ab, 0xbd, 0x94, 0xb5, 0x82, 0x8b, 0x4b, 0xf7, 0xbe); DEFINE_GUID!(D3D11_AUTHENTICATED_QUERY_DEVICE_HANDLE, 0xec1c539d, 0x8cff, 0x4e2a, 0xbc, 0xc4, 0xf5, 0x69, 0x2f, 0x99, 0xf4, 0x80); DEFINE_GUID!(D3D11_AUTHENTICATED_QUERY_CRYPTO_SESSION, 0x2634499e, 0xd018, 0x4d74, 0xac, 0x17, 0x7f, 0x72, 0x40, 0x59, 0x52, 0x8d); DEFINE_GUID!(D3D11_AUTHENTICATED_QUERY_RESTRICTED_SHARED_RESOURCE_PROCESS_COUNT, 0xdb207b3, 0x9450, 0x46a6, 0x82, 0xde, 0x1b, 0x96, 0xd4, 0x4f, 0x9c, 0xf2); DEFINE_GUID!(D3D11_AUTHENTICATED_QUERY_RESTRICTED_SHARED_RESOURCE_PROCESS, 0x649bbadb, 0xf0f4, 0x4639, 0xa1, 0x5b, 0x24, 0x39, 0x3f, 0xc3, 0xab, 0xac); DEFINE_GUID!(D3D11_AUTHENTICATED_QUERY_UNRESTRICTED_PROTECTED_SHARED_RESOURCE_COUNT, 0x12f0bd6, 0xe662, 0x4474, 0xbe, 0xfd, 0xaa, 0x53, 0xe5, 0x14, 0x3c, 0x6d); DEFINE_GUID!(D3D11_AUTHENTICATED_QUERY_OUTPUT_ID_COUNT, 0x2c042b5e, 0x8c07, 0x46d5, 0xaa, 0xbe, 0x8f, 0x75, 0xcb, 0xad, 0x4c, 0x31); DEFINE_GUID!(D3D11_AUTHENTICATED_QUERY_OUTPUT_ID, 0x839ddca3, 0x9b4e, 0x41e4, 0xb0, 0x53, 0x89, 0x2b, 0xd2, 0xa1, 0x1e, 0xe7); DEFINE_GUID!(D3D11_AUTHENTICATED_QUERY_ACCESSIBILITY_ATTRIBUTES, 0x6214d9d2, 0x432c, 0x4abb, 0x9f, 0xce, 0x21, 0x6e, 0xea, 0x26, 0x9e, 0x3b); DEFINE_GUID!(D3D11_AUTHENTICATED_QUERY_ENCRYPTION_WHEN_ACCESSIBLE_GUID_COUNT, 0xb30f7066, 0x203c, 0x4b07, 0x93, 0xfc, 0xce, 0xaa, 0xfd, 0x61, 0x24, 0x1e); DEFINE_GUID!(D3D11_AUTHENTICATED_QUERY_ENCRYPTION_WHEN_ACCESSIBLE_GUID, 0xf83a5958, 0xe986, 0x4bda, 0xbe, 0xb0, 0x41, 0x1f, 0x6a, 0x7a, 0x1, 0xb7); DEFINE_GUID!(D3D11_AUTHENTICATED_QUERY_CURRENT_ENCRYPTION_WHEN_ACCESSIBLE, 0xec1791c7, 0xdad3, 0x4f15, 0x9e, 0xc3, 0xfa, 0xa9, 0x3d, 0x60, 0xd4, 0xf0); DEFINE_GUID!(D3D11_AUTHENTICATED_CONFIGURE_INITIALIZE, 0x6114bdb, 0x3523, 0x470a, 0x8d, 0xca, 0xfb, 0xc2, 0x84, 0x51, 0x54, 0xf0); DEFINE_GUID!(D3D11_AUTHENTICATED_CONFIGURE_PROTECTION, 0x50455658, 0x3f47, 0x4362, 0xbf, 0x99, 0xbf, 0xdf, 0xcd, 0xe9, 0xed, 0x29); DEFINE_GUID!(D3D11_AUTHENTICATED_CONFIGURE_CRYPTO_SESSION, 0x6346cc54, 0x2cfc, 0x4ad4, 0x82, 0x24, 0xd1, 0x58, 0x37, 0xde, 0x77, 0x0); DEFINE_GUID!(D3D11_AUTHENTICATED_CONFIGURE_SHARED_RESOURCE, 0x772d047, 0x1b40, 0x48e8, 0x9c, 0xa6, 0xb5, 0xf5, 0x10, 0xde, 0x9f, 0x1); DEFINE_GUID!(D3D11_AUTHENTICATED_CONFIGURE_ENCRYPTION_WHEN_ACCESSIBLE, 0x41fff286, 0x6ae0, 0x4d43, 0x9d, 0x55, 0xa4, 0x6e, 0x9e, 0xfd, 0x15, 0x8a); STRUCT!{struct D3D11_AUTHENTICATED_QUERY_INPUT { QueryType: ::GUID, hChannel: ::HANDLE, SequenceNumber: ::UINT, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_OUTPUT { omac: D3D11_OMAC, QueryType: ::GUID, hChannel: ::HANDLE, SequenceNumber: ::UINT, ReturnCode: ::HRESULT, }} STRUCT!{struct D3D11_AUTHENTICATED_PROTECTION_FLAGS { u: ::UINT, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_PROTECTION_OUTPUT { Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, ProtectionFlags: D3D11_AUTHENTICATED_PROTECTION_FLAGS, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_CHANNEL_TYPE_OUTPUT { Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, ChannelType: D3D11_AUTHENTICATED_CHANNEL_TYPE, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_DEVICE_HANDLE_OUTPUT { Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, DeviceHandle: ::HANDLE, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_CRYPTO_SESSION_INPUT { Input: D3D11_AUTHENTICATED_QUERY_INPUT, DecoderHandle: ::HANDLE, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_CRYPTO_SESSION_OUTPUT { Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, DecoderHandle: ::HANDLE, CryptoSessionHandle: ::HANDLE, DeviceHandle: ::HANDLE, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_RESTRICTED_SHARED_RESOURCE_PROCESS_COUNT_OUTPUT { Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, RestrictedSharedResourceProcessCount: ::UINT, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_RESTRICTED_SHARED_RESOURCE_PROCESS_INPUT { Input: D3D11_AUTHENTICATED_QUERY_INPUT, ProcessIndex: ::UINT, }} ENUM!{enum D3D11_AUTHENTICATED_PROCESS_IDENTIFIER_TYPE { DD3D11_PROCESSIDTYPE_UNKNOWN = 0, DD3D11_PROCESSIDTYPE_DWM = 1, DD3D11_PROCESSIDTYPE_HANDLE = 2, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_RESTRICTED_SHARED_RESOURCE_PROCESS_OUTPUT { Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, ProcessIndex: ::UINT, ProcessIdentifier: D3D11_AUTHENTICATED_PROCESS_IDENTIFIER_TYPE, ProcessHandle: ::HANDLE, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_UNRESTRICTED_PROTECTED_SHARED_RESOURCE_COUNT_OUTPUT { Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, UnrestrictedProtectedSharedResourceCount: ::UINT, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_OUTPUT_ID_COUNT_INPUT { Input: D3D11_AUTHENTICATED_QUERY_INPUT, DeviceHandle: ::HANDLE, CryptoSessionHandle: ::HANDLE, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_OUTPUT_ID_COUNT_OUTPUT { Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, DeviceHandle: ::HANDLE, CryptoSessionHandle: ::HANDLE, OutputIDCount: ::UINT, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_OUTPUT_ID_INPUT { Input: D3D11_AUTHENTICATED_QUERY_INPUT, DeviceHandle: ::HANDLE, CryptoSessionHandle: ::HANDLE, OutputIDIndex: ::UINT, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_OUTPUT_ID_OUTPUT { Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, DeviceHandle: ::HANDLE, CryptoSessionHandle: ::HANDLE, OutputIDIndex: ::UINT, OutputID: ::UINT64, }} ENUM!{enum D3D11_BUS_TYPE { D3D11_BUS_TYPE_OTHER = 0, D3D11_BUS_TYPE_PCI = 0x1, D3D11_BUS_TYPE_PCIX = 0x2, D3D11_BUS_TYPE_PCIEXPRESS = 0x3, D3D11_BUS_TYPE_AGP = 0x4, D3D11_BUS_IMPL_MODIFIER_INSIDE_OF_CHIPSET = 0x10000, D3D11_BUS_IMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_CHIP = 0x20000, D3D11_BUS_IMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_SOCKET = 0x30000, D3D11_BUS_IMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR = 0x40000, D3D11_BUS_IMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR_INSIDE_OF_NUAE = 0x50000, D3D11_BUS_IMPL_MODIFIER_NON_STANDARD = 0x80000000, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_ACESSIBILITY_OUTPUT { Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, BusType: D3D11_BUS_TYPE, AccessibleInContiguousBlocks: ::BOOL, AccessibleInNonContiguousBlocks: ::BOOL, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_ACCESSIBILITY_ENCRYPTION_GUID_COUNT_OUTPUT { Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, EncryptionGuidCount: ::UINT, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_ACCESSIBILITY_ENCRYPTION_GUID_INPUT { Input: D3D11_AUTHENTICATED_QUERY_INPUT, EncryptionGuidIndex: ::UINT, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_ACCESSIBILITY_ENCRYPTION_GUID_OUTPUT { Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, EncryptionGuidIndex: ::UINT, EncryptionGuid: ::GUID, }} STRUCT!{struct D3D11_AUTHENTICATED_QUERY_CURRENT_ACCESSIBILITY_ENCRYPTION_OUTPUT { Output: D3D11_AUTHENTICATED_QUERY_OUTPUT, EncryptionGuid: ::GUID, }} STRUCT!{struct D3D11_AUTHENTICATED_CONFIGURE_INPUT { omac: D3D11_OMAC, ConfigureType: ::GUID, hChannel: ::HANDLE, SequenceNumber: ::UINT, }} STRUCT!{struct D3D11_AUTHENTICATED_CONFIGURE_OUTPUT { omac: D3D11_OMAC, ConfigureType: ::GUID, hChannel: ::HANDLE, SequenceNumber: ::UINT, ReturnCode: ::HRESULT, }} STRUCT!{struct D3D11_AUTHENTICATED_CONFIGURE_INITIALIZE_INPUT { Parameters: D3D11_AUTHENTICATED_CONFIGURE_INPUT, StartSequenceQuery: ::UINT, StartSequenceConfigure: ::UINT, }} STRUCT!{struct D3D11_AUTHENTICATED_CONFIGURE_PROTECTION_INPUT { Parameters: D3D11_AUTHENTICATED_CONFIGURE_INPUT, Protections: D3D11_AUTHENTICATED_PROTECTION_FLAGS, }} STRUCT!{struct D3D11_AUTHENTICATED_CONFIGURE_CRYPTO_SESSION_INPUT { Parameters: D3D11_AUTHENTICATED_CONFIGURE_INPUT, DecoderHandle: ::HANDLE, CryptoSessionHandle: ::HANDLE, DeviceHandle: ::HANDLE, }} STRUCT!{struct D3D11_AUTHENTICATED_CONFIGURE_SHARED_RESOURCE_INPUT { Parameters: D3D11_AUTHENTICATED_CONFIGURE_INPUT, ProcessType: D3D11_AUTHENTICATED_PROCESS_IDENTIFIER_TYPE, ProcessHandle: ::HANDLE, AllowAccess: ::BOOL, }} STRUCT!{struct D3D11_AUTHENTICATED_CONFIGURE_ACCESSIBLE_ENCRYPTION_INPUT { Parameters: D3D11_AUTHENTICATED_CONFIGURE_INPUT, EncryptionGuid: ::GUID, }} DEFINE_GUID!(D3D11_KEY_EXCHANGE_RSAES_OAEP, 0xc1949895, 0xd72a, 0x4a1d, 0x8e, 0x5d, 0xed, 0x85, 0x7d, 0x17, 0x15, 0x20); RIDL!( interface ID3D11CryptoSession(ID3D11CryptoSessionVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn GetCryptoType(&mut self, pCryptoType: *mut ::GUID) -> (), fn GetDecoderProfile(&mut self, pDecoderProfile: *mut ::GUID) -> (), fn GetCertificateSize(&mut self, pCertificateSize: *mut ::UINT) -> ::HRESULT, fn GetCertificate(&mut self, CertificateSize: ::UINT, pCertificate: *mut ::BYTE) -> ::HRESULT, fn GetCryptoSessionHandle(&mut self, pCertificate: *mut ::HANDLE) -> () } ); ENUM!{enum D3D11_VDOV_DIMENSION { D3D11_VDOV_DIMENSION_UNKNOWN = 0, D3D11_VDOV_DIMENSION_TEXTURE2D = 1, }} STRUCT!{struct D3D11_TEX2D_VDOV { ArraySlice: ::UINT, }} STRUCT!{struct D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC { DecodeProfile: ::GUID, ViewDimension: D3D11_VDOV_DIMENSION, Texture2D: D3D11_TEX2D_VDOV, }} RIDL!( interface ID3D11VideoDecoderOutputView(ID3D11VideoDecoderOutputViewVtbl) : ID3D11View(ID3D11ViewVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC) -> () } ); ENUM!{enum D3D11_VPIV_DIMENSION { D3D11_VPIV_DIMENSION_UNKNOWN = 0, D3D11_VPIV_DIMENSION_TEXTURE2D = 1, }} STRUCT!{struct D3D11_TEX2D_VPIV { MipSlice: ::UINT, ArraySlice: ::UINT, }} STRUCT!{struct D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC { FourCC: ::UINT, ViewDimension: D3D11_VPIV_DIMENSION, Texture2D: D3D11_TEX2D_VPIV, }} RIDL!( interface ID3D11VideoProcessorInputView(ID3D11VideoProcessorInputViewVtbl) : ID3D11View(ID3D11ViewVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC) -> () } ); ENUM!{enum D3D11_VPOV_DIMENSION { D3D11_VPOV_DIMENSION_UNKNOWN = 0, D3D11_VPOV_DIMENSION_TEXTURE2D = 1, D3D11_VPOV_DIMENSION_TEXTURE2DARRAY = 2, }} STRUCT!{struct D3D11_TEX2D_VPOV { MipSlice: ::UINT, }} STRUCT!{struct D3D11_TEX2D_ARRAY_VPOV { MipSlice: ::UINT, FirstArraySlice: ::UINT, ArraySize: ::UINT, }} STRUCT!{struct D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC { ViewDimension: D3D11_VPOV_DIMENSION, u: [::UINT; 3], }} UNION!(D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC, u, Texture2D, Texture2D_mut, D3D11_TEX2D_VPOV); UNION!(D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC, u, Texture2DArray, Texture2DArray_mut, D3D11_TEX2D_ARRAY_VPOV); RIDL!( interface ID3D11VideoProcessorOutputView(ID3D11VideoProcessorOutputViewVtbl) : ID3D11View(ID3D11ViewVtbl) { fn GetDesc(&mut self, pDesc: *mut D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC) -> () } ); RIDL!( interface ID3D11VideoContext(ID3D11VideoContextVtbl): ID3D11DeviceChild(ID3D11DeviceChildVtbl) { fn GetDecoderBuffer( &mut self, pDecoder: *mut ID3D11VideoDecoder, Type: D3D11_VIDEO_DECODER_BUFFER_TYPE, pBufferSize: *mut ::UINT, ppBuffer: *mut *mut ::c_void ) -> ::HRESULT, fn ReleaseDecoderBuffer( &mut self, pDecoder: *mut ID3D11VideoDecoder, Type: D3D11_VIDEO_DECODER_BUFFER_TYPE ) -> ::HRESULT, fn DecoderBeginFrame( &mut self, pDecoder: *mut ID3D11VideoDecoder, pView: *mut ID3D11VideoDecoderOutputView, ContentKeySize: ::UINT, pContentKey: *const ::c_void ) -> ::HRESULT, fn DecoderEndFrame(&mut self, pDecoder: *mut ID3D11VideoDecoder) -> ::HRESULT, fn SubmitDecoderBuffers( &mut self, pDecoder: *mut ID3D11VideoDecoder, NumBuffers: ::UINT, pBufferDesc: *const D3D11_VIDEO_DECODER_BUFFER_DESC ) -> ::HRESULT, fn DecoderExtension( &mut self, pDecoder: *mut ID3D11VideoDecoder, pExtensionData: *const D3D11_VIDEO_DECODER_EXTENSION ) -> ::HRESULT, fn VideoProcessorSetOutputTargetRect( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, Enable: ::BOOL, pRect: *const ::RECT ) -> (), fn VideoProcessorSetOutputBackgroundColor( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, YCbCr: ::BOOL, pRect: *const ::RECT ) -> (), fn VideoProcessorSetOutputColorSpace( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, pColorSpace: *const D3D11_VIDEO_PROCESSOR_COLOR_SPACE ) -> ::HRESULT, fn VideoProcessorSetOutputAlphaFillMode( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, AlphaFillMode: D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE, StreamIndex: ::UINT ) -> (), fn VideoProcessorSetOutputConstriction( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, Enable: ::BOOL, Size: ::SIZE ) -> (), fn VideoProcessorSetOutputStereoMode( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, Enable: ::BOOL ) -> (), fn VideoProcessorSetOutputExtension( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, pExtensionGuid: *const ::GUID, DataSize: ::UINT, pData: *mut ::c_void ) -> ::HRESULT, fn VideoProcessorGetOutputTargetRect( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, Enabled: *mut ::BOOL, pRect: *mut ::RECT ) -> (), fn VideoProcessorGetOutputBackgroundColor( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, pYCbCr: *mut ::BOOL, pColor: *mut D3D11_VIDEO_COLOR ) -> (), fn VideoProcessorGetOutputColorSpace( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, pColorSpace: *mut D3D11_VIDEO_PROCESSOR_COLOR_SPACE ) -> (), fn VideoProcessorGetOutputAlphaFillMode( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, pAlphaFillMode: *mut D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE, pStreamIndex: *mut ::UINT ) -> (), fn VideoProcessorGetOutputConstriction( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, pEnabled: *mut ::BOOL, pSize: *mut ::SIZE ) -> (), fn VideoProcessorGetOutputStereoMode( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, pEnabled: *mut ::BOOL ) -> (), fn VideoProcessorGetOutputExtension( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, pExtensionGuid: *const ::GUID, DataSize: ::UINT, pData: *mut ::c_void ) -> ::HRESULT, fn VideoProcessorSetStreamFrameFormat( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, FrameFormat: D3D11_VIDEO_FRAME_FORMAT ) -> (), fn VideoProcessorSetStreamColorSpace( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, pColorSpace: *const D3D11_VIDEO_PROCESSOR_COLOR_SPACE ) -> (), fn VideoProcessorSetStreamOutputRate( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, OutputRate: D3D11_VIDEO_PROCESSOR_OUTPUT_RATE, RepeatFrame: ::BOOL, pCustomRate: *const ::DXGI_RATIONAL ) -> (), fn VideoProcessorSetStreamSourceRect( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, Enable: ::BOOL, pRect: *const ::RECT ) -> (), fn VideoProcessorSetStreamDestRect( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, Enable: ::BOOL, pRect: *const ::RECT ) -> (), fn VideoProcessorSetStreamAlpha( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, Enable: ::BOOL, Alpha: ::FLOAT ) -> (), fn VideoProcessorSetStreamPalette( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, Count: ::UINT, pEntries: *const ::UINT ) -> (), fn VideoProcessorSetStreamPixelAspectRatio( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, Enable: ::BOOL, pSourceAspectRatio: *const ::DXGI_RATIONAL, pDestinationAspectRatio: *const ::DXGI_RATIONAL ) -> (), fn VideoProcessorSetStreamLumaKey( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, Enable: ::BOOL, Lower: ::FLOAT, Upper: ::FLOAT ) -> (), fn VideoProcessorSetStreamStereoFormat( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, Enable: ::BOOL, Format: D3D11_VIDEO_PROCESSOR_STEREO_FORMAT, LeftViewFrame0: ::BOOL, BaseViewFrame0: ::BOOL, FlipMode: D3D11_VIDEO_PROCESSOR_STEREO_FLIP_MODE ) -> (), fn VideoProcessorSetStreamAutoProcessingMode( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, Enable: ::BOOL ) -> (), fn VideoProcessorSetStreamFilter( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, Filter: D3D11_VIDEO_PROCESSOR_FILTER, Enable: ::BOOL, Level: ::c_int ) -> (), fn VideoProcessorSetStreamExtension( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, pExtensionGuid: *const ::GUID, DataSize: ::UINT, pData: *mut ::c_void ) -> ::HRESULT, fn VideoProcessorGetStreamFrameFormat( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, pFrameFormat: *mut D3D11_VIDEO_FRAME_FORMAT ) -> (), fn VideoProcessorGetStreamColorSpace( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, pColorSpace: *mut D3D11_VIDEO_PROCESSOR_COLOR_SPACE ) -> (), fn VideoProcessorGetStreamOutputRate( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, pOutputRate: *mut D3D11_VIDEO_PROCESSOR_OUTPUT_RATE, pRepeatFrame: *mut ::BOOL, pCustomRate: *mut ::DXGI_RATIONAL ) -> (), fn VideoProcessorGetStreamSourceRect( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, pEnabled: *mut ::BOOL, pRect: *mut ::RECT ) -> (), fn VideoProcessorGetStreamDestRect( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, pEnabled: *mut ::BOOL, pRect: *mut ::RECT ) -> (), fn VideoProcessorGetStreamAlpha( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, pEnabled: *mut ::BOOL, pAlpha: *mut ::FLOAT ) -> (), fn VideoProcessorGetStreamPalette( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, Count: ::UINT, pEntries: *mut ::UINT ) -> (), fn VideoProcessorGetStreamPixelAspectRatio( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, pEnabled: *mut ::BOOL, pSourceAspectRatio: *mut ::DXGI_RATIONAL, pDestinationAspectRatio: *mut ::DXGI_RATIONAL ) -> (), fn VideoProcessorGetStreamLumaKey( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, pEnabled: *mut ::BOOL, pLower: *mut ::FLOAT, pUpper: *mut ::FLOAT ) -> (), fn VideoProcessorGetStreamStereoFormat( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, pEnabled: *mut ::BOOL, pFormat: *mut D3D11_VIDEO_PROCESSOR_STEREO_FORMAT, pLeftViewFrame0: *mut ::BOOL, pBaseViewFrame0: *mut ::BOOL, pFlipMode: *mut D3D11_VIDEO_PROCESSOR_STEREO_FLIP_MODE, MonoOffset: *mut ::c_int ) -> (), fn VideoProcessorGetStreamAutoProcessingMode( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, pEnabled: *mut ::BOOL ) -> (), fn VideoProcessorGetStreamFilter( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, Filter: D3D11_VIDEO_PROCESSOR_FILTER, pEnabled: *mut ::BOOL, pLevel: *mut ::c_int ) -> (), fn VideoProcessorGetStreamExtension( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, pExtensionGuid: *const ::GUID, DataSize: ::UINT, pData: *mut ::c_void ) -> ::HRESULT, fn VideoProcessorBlt( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, pView: *mut ID3D11VideoProcessorOutputView, OutputFrame: ::UINT, StreamCount: ::UINT, pStreams: *const D3D11_VIDEO_PROCESSOR_STREAM ) -> ::HRESULT, fn NegotiateCryptoSessionKeyExchange( &mut self, pCryptoSession: *mut ID3D11CryptoSession, DataSize: ::UINT, pData: *mut ::c_void ) -> ::HRESULT, fn EncryptionBlt( &mut self, pCryptoSession: *mut ID3D11CryptoSession, pSrcSurface: *mut ID3D11Texture2D, pDstSurface: *mut ID3D11Texture2D, IVSize: ::UINT, pIV: *mut ::c_void ) -> ::HRESULT, fn DecryptionBlt( &mut self, pCryptoSession: *mut ID3D11CryptoSession, pSrcSurface: *mut ID3D11Texture2D, pDstSurface: *mut ID3D11Texture2D, pEncryptedBlockInfo: *mut D3D11_ENCRYPTED_BLOCK_INFO, ContentKeySize: ::UINT, pContentKey: *const ::c_void, IVSize: ::UINT, pIV: *mut ::c_void ) -> ::HRESULT, fn StartSessionKeyRefresh( &mut self, pCryptoSession: *mut ID3D11CryptoSession, RandomNumberSize: ::UINT, pRandomNumber: *mut ::c_void ) -> ::HRESULT, fn FinishSessionKeyRefresh(&mut self, pCryptoSession: *mut ID3D11CryptoSession) -> ::HRESULT, fn GetEncryptionBltKey( &mut self, pCryptoSession: *mut ID3D11CryptoSession, KeySize: ::UINT, pReadbackKey: *mut ::c_void ) -> ::HRESULT, fn NegotiateAuthenticatedChannelKeyExchange( &mut self, pChannel: *mut ID3D11AuthenticatedChannel, DataSize: ::UINT, pData: *mut ::c_void ) -> ::HRESULT, fn QueryAuthenticatedChannel( &mut self, pChannel: *mut ID3D11AuthenticatedChannel, InputSize: ::UINT, pInput: *const ::c_void, OutputSize: ::UINT, pOutput: *mut ::c_void ) -> ::HRESULT, fn ConfigureAuthenticatedChannel( &mut self, pChannel: *mut ID3D11AuthenticatedChannel, InputSize: ::UINT, pInput: *const ::c_void, pOutput: *mut D3D11_AUTHENTICATED_CONFIGURE_OUTPUT ) -> ::HRESULT, fn VideoProcessorSetStreamRotation( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, Enable: ::BOOL, Rotation: D3D11_VIDEO_PROCESSOR_ROTATION ) -> ::HRESULT, fn VideoProcessorGetStreamRotation( &mut self, pVideoProcessor: *mut ID3D11VideoProcessor, StreamIndex: ::UINT, pEnable: *mut ::BOOL, pRotation: *mut D3D11_VIDEO_PROCESSOR_ROTATION ) -> ::HRESULT } ); RIDL!( interface ID3D11VideoDevice(ID3D11VideoDeviceVtbl): IUnknown(IUnknownVtbl) { fn CreateVideoDecoder( &mut self, pVideoDesc: *const D3D11_VIDEO_DECODER_DESC, pConfig: *const D3D11_VIDEO_DECODER_CONFIG, ppDecoder: *mut *mut ID3D11VideoDecoder ) -> ::HRESULT, fn CreateVideoProcessor( &mut self, pEnum: *mut ID3D11VideoProcessorEnumerator, RateConversionIndex: ::UINT, ppVideoProcessor: *mut *mut ID3D11VideoProcessor ) -> ::HRESULT, fn CreateAuthenticatedChannel( &mut self, ChannelType: D3D11_AUTHENTICATED_CHANNEL_TYPE, ppAuthenticatedChannel: *mut *mut ID3D11AuthenticatedChannel ) -> ::HRESULT, fn CreateCryptoSession( &mut self, pCryptoType: *const ::GUID, pDecoderProfile: *const ::GUID, pKeyExchangeType: *const ::GUID, ppCryptoSession: *mut *mut ID3D11CryptoSession ) -> ::HRESULT, fn CreateVideoDecoderOutputView( &mut self, pResource: *mut ID3D11Resource, pDesc: *const D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC, ppVDOVView: *mut *mut ID3D11VideoDecoderOutputView ) -> ::HRESULT, fn CreateVideoProcessorInputView( &mut self, pResource: *mut ID3D11Resource, pEnum: *mut ID3D11VideoProcessorEnumerator, pDesc: *const D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC, ppVPIView: *mut *mut ID3D11VideoProcessorInputView ) -> ::HRESULT, fn CreateVideoProcessorOutputView( &mut self, pResource: *mut ID3D11Resource, pEnum: *mut ID3D11VideoProcessorEnumerator, pDesc: *const D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC, ppVPOView: *mut *mut ID3D11VideoProcessorOutputView ) -> ::HRESULT, fn CreateVideoProcessorEnumerator( &mut self, pDesc: *const D3D11_VIDEO_PROCESSOR_CONTENT_DESC, ppEnum: *mut *mut ID3D11VideoProcessorEnumerator ) -> ::HRESULT, fn GetVideoDecoderProfileCount(&mut self) -> ::UINT, fn GetVideoDecoderProfile( &mut self, Index: ::UINT, pDecoderProfile: *mut ::GUID ) -> ::HRESULT, fn CheckVideoDecoderFormat( &mut self, pDecoderProfile: *const ::GUID, Format: ::DXGI_FORMAT, pSupported: *mut ::BOOL ) -> ::HRESULT, fn GetVideoDecoderConfigCount( &mut self, pDesc: *const D3D11_VIDEO_DECODER_DESC, pCount: *mut ::UINT ) -> ::HRESULT, fn GetVideoDecoderConfig( &mut self, pDesc: *const D3D11_VIDEO_DECODER_DESC, Index: ::UINT, pConfig: *mut D3D11_VIDEO_DECODER_CONFIG ) -> ::HRESULT, fn GetContentProtectionCaps( &mut self, pCryptoType: *const ::GUID, pDecoderProfile: *const ::GUID, pCaps: *mut D3D11_VIDEO_CONTENT_PROTECTION_CAPS ) -> ::HRESULT, fn CheckCryptoKeyExchange( &mut self, pCryptoType: *const ::GUID, pDecoderProfile: *const ::GUID, Index: ::UINT, pKeyExchangeType: *mut ::GUID ) -> ::HRESULT, fn SetPrivateData( &mut self, guid: ::REFGUID, DataSize: ::UINT, pData: *const ::c_void ) -> ::HRESULT, fn SetPrivateDataInterface( &mut self, guid: ::REFGUID, pData: *const ::IUnknown ) -> ::HRESULT } ); RIDL!( interface ID3D11Device(ID3D11DeviceVtbl): IUnknown(IUnknownVtbl) { fn CreateBuffer( &mut self, pDesc: *const D3D11_BUFFER_DESC, pInitialData: *const D3D11_SUBRESOURCE_DATA, ppBuffer: *mut *mut ID3D11Buffer ) -> ::HRESULT, fn CreateTexture1D( &mut self, pDesc: *const D3D11_TEXTURE1D_DESC, pInitialData: *const D3D11_SUBRESOURCE_DATA, ppTexture1D: *mut *mut ID3D11Texture1D ) -> ::HRESULT, fn CreateTexture2D( &mut self, pDesc: *const D3D11_TEXTURE2D_DESC, pInitialData: *const D3D11_SUBRESOURCE_DATA, ppTexture2D: *mut *mut ID3D11Texture2D ) -> ::HRESULT, fn CreateTexture3D( &mut self, pDesc: *const D3D11_TEXTURE3D_DESC, pInitialData: *const D3D11_SUBRESOURCE_DATA, ppTexture3D: *mut *mut ID3D11Texture3D ) -> ::HRESULT, fn CreateShaderResourceView( &mut self, pResource: *mut ID3D11Resource, pDesc: *const D3D11_SHADER_RESOURCE_VIEW_DESC, ppSRView: *mut *mut ID3D11ShaderResourceView ) -> ::HRESULT, fn CreateUnorderedAccessView( &mut self, pResource: *mut ID3D11Resource, pDesc: *const D3D11_UNORDERED_ACCESS_VIEW_DESC, ppUAView: *mut *mut ID3D11UnorderedAccessView ) -> ::HRESULT, fn CreateRenderTargetView( &mut self, pResource: *mut ID3D11Resource, pDesc: *const D3D11_RENDER_TARGET_VIEW_DESC, ppRTView: *mut *mut ID3D11RenderTargetView ) -> ::HRESULT, fn CreateDepthStencilView( &mut self, pResource: *mut ID3D11Resource, pDesc: *const D3D11_DEPTH_STENCIL_VIEW_DESC, ppDepthStencilView: *mut *mut ID3D11DepthStencilView ) -> ::HRESULT, fn CreateInputLayout( &mut self, pInputElementDescs: *const D3D11_INPUT_ELEMENT_DESC, NumElements: ::UINT, pShaderBytecodeWithInputSignature: *const ::c_void, BytecodeLength: ::SIZE_T, ppInputLayout: *mut *mut ID3D11InputLayout ) -> ::HRESULT, fn CreateVertexShader( &mut self, pShaderBytecode: *const ::c_void, BytecodeLength: ::SIZE_T, pClassLinkage: *mut ID3D11ClassLinkage, ppVertexShader: *mut *mut ID3D11VertexShader ) -> ::HRESULT, fn CreateGeometryShader( &mut self, pShaderBytecode: *const ::c_void, BytecodeLength: ::SIZE_T, pClassLinkage: *mut ID3D11ClassLinkage, ppGeometryShader: *mut *mut ID3D11GeometryShader ) -> ::HRESULT, fn CreateGeometryShaderWithStreamOutput( &mut self, pShaderBytecode: *const ::c_void, BytecodeLength: ::SIZE_T, pSODeclaration: *const D3D11_SO_DECLARATION_ENTRY, NumEntries: ::UINT, pBufferStrides: *const ::UINT, NumStrides: ::UINT, RasterizedStream: ::UINT, pClassLinkage: *mut ID3D11ClassLinkage, ppGeometryShader: *mut *mut ID3D11GeometryShader ) -> ::HRESULT, fn CreatePixelShader( &mut self, pShaderBytecode: *const ::c_void, BytecodeLength: ::SIZE_T, pClassLinkage: *mut ID3D11ClassLinkage, ppPixelShader: *mut *mut ID3D11PixelShader ) -> ::HRESULT, fn CreateHullShader( &mut self, pShaderBytecode: *const ::c_void, BytecodeLength: ::SIZE_T, pClassLinkage: *mut ID3D11ClassLinkage, ppHullShader: *mut *mut ID3D11HullShader ) -> ::HRESULT, fn CreateDomainShader( &mut self, pShaderBytecode: *const ::c_void, BytecodeLength: ::SIZE_T, pClassLinkage: *mut ID3D11ClassLinkage, ppDomainShader: *mut *mut ID3D11DomainShader ) -> ::HRESULT, fn CreateComputeShader( &mut self, pShaderBytecode: *const ::c_void, BytecodeLength: ::SIZE_T, pClassLinkage: *mut ID3D11ClassLinkage, ppComputeShader: *mut *mut ID3D11ComputeShader ) -> ::HRESULT, fn CreateClassLinkage(&mut self, ppLinkage: *mut *mut ID3D11ClassLinkage) -> ::HRESULT, fn CreateBlendState( &mut self, pBlendStateDesc: *const D3D11_BLEND_DESC, ppBlendState: *mut *mut ID3D11BlendState ) -> ::HRESULT, fn CreateDepthStencilState( &mut self, pDepthStencilDesc: *const D3D11_DEPTH_STENCIL_DESC, ppDepthStencilState: *mut *mut ID3D11DepthStencilState ) -> ::HRESULT, fn CreateRasterizerState( &mut self, pRasterizerDesc: *const D3D11_RASTERIZER_DESC, ppRasterizerState: *mut *mut ID3D11RasterizerState ) -> ::HRESULT, fn CreateSamplerState( &mut self, pSamplerDesc: *const D3D11_SAMPLER_DESC, ppSamplerState: *mut *mut ID3D11SamplerState ) -> ::HRESULT, fn CreateQuery( &mut self, pQueryDesc: *const D3D11_QUERY_DESC, ppQuery: *mut *mut ID3D11Query ) -> ::HRESULT, fn CreatePredicate( &mut self, pPredicateDesc: *const D3D11_QUERY_DESC, ppPredicate: *mut *mut ID3D11Predicate ) -> ::HRESULT, fn CreateCounter( &mut self, pCounterDesc: *const D3D11_COUNTER_DESC, ppCounter: *mut *mut ID3D11Counter ) -> ::HRESULT, fn CreateDeferredContext( &mut self, ContextFlags: ::UINT, ppDeferredContext: *mut *mut ID3D11DeviceContext ) -> ::HRESULT, fn OpenSharedResource( &mut self, hResource: ::HANDLE, ReturnedInterface: ::REFIID, ppResource: *mut *mut ::c_void ) -> ::HRESULT, fn CheckFormatSupport( &mut self, Format: ::DXGI_FORMAT, pFormatSupport: *mut ::UINT ) -> ::HRESULT, fn CheckMultisampleQualityLevels( &mut self, Format: ::DXGI_FORMAT, SampleCount: ::UINT, pNumQualityLevels: *mut ::UINT ) -> ::HRESULT, fn CheckCounterInfo(&mut self, pCounterInfo: *mut D3D11_COUNTER_INFO) -> (), fn CheckCounter( &mut self, pDesc: *const D3D11_COUNTER_DESC, pType: *mut D3D11_COUNTER_TYPE, pActiveCounters: *mut ::UINT, szName: ::LPSTR, pNameLength: *mut ::UINT, szUnits: ::LPSTR, pUnitsLength: *mut ::UINT, szDescription: ::LPSTR, pDescriptionLength: *mut ::UINT ) -> ::HRESULT, fn CheckFeatureSupport( &mut self, Feature: D3D11_FEATURE, pFeatureSupportData: *mut ::c_void, FeatureSupportDataSize: ::UINT ) -> ::HRESULT, fn GetPrivateData( &mut self, guid: ::REFGUID, pDataSize: *mut ::UINT, pData: *mut ::c_void ) -> ::HRESULT, fn SetPrivateData( &mut self, guid: ::REFGUID, DataSize: ::UINT, pData: *const ::c_void ) -> ::HRESULT, fn SetPrivateDataInterface(&mut self, guid: ::REFGUID, pData: *const ::IUnknown) -> ::HRESULT, fn GetFeatureLevel(&mut self) -> ::D3D_FEATURE_LEVEL, fn GetCreationFlags(&mut self) -> ::UINT, fn GetDeviceRemovedReason(&mut self) -> ::HRESULT, fn GetImmediateContext(&mut self, ppImmediateContext: *mut *mut ID3D11DeviceContext) -> (), fn SetExceptionMode(&mut self, RaiseFlags: ::UINT) -> ::HRESULT, fn GetExceptionMode(&mut self) -> ::UINT } ); FLAGS!{enum D3D11_CREATE_DEVICE_FLAG { D3D11_CREATE_DEVICE_SINGLETHREADED = 0x1, D3D11_CREATE_DEVICE_DEBUG = 0x2, D3D11_CREATE_DEVICE_SWITCH_TO_REF = 0x4, D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS = 0x8, D3D11_CREATE_DEVICE_BGRA_SUPPORT = 0x20, D3D11_CREATE_DEVICE_DEBUGGABLE = 0x40, D3D11_CREATE_DEVICE_PREVENT_ALTERING_LAYER_SETTINGS_FROM_REGISTRY = 0x80, D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT = 0x100, D3D11_CREATE_DEVICE_VIDEO_SUPPORT = 0x800, }} pub const D3D11_SDK_VERSION: ::DWORD = 7; DEFINE_GUID!(IID_ID3D11DeviceChild, 0x1841e5c8, 0x16b0, 0x489b, 0xbc, 0xc8, 0x44, 0xcf, 0xb0, 0xd5, 0xde, 0xae); DEFINE_GUID!(IID_ID3D11DepthStencilState, 0x03823efb, 0x8d8f, 0x4e1c, 0x9a, 0xa2, 0xf6, 0x4b, 0xb2, 0xcb, 0xfd, 0xf1); DEFINE_GUID!(IID_ID3D11BlendState, 0x75b68faa, 0x347d, 0x4159, 0x8f, 0x45, 0xa0, 0x64, 0x0f, 0x01, 0xcd, 0x9a); DEFINE_GUID!(IID_ID3D11RasterizerState, 0x9bb4ab81, 0xab1a, 0x4d8f, 0xb5, 0x06, 0xfc, 0x04, 0x20, 0x0b, 0x6e, 0xe7); DEFINE_GUID!(IID_ID3D11Resource, 0xdc8e63f3, 0xd12b, 0x4952, 0xb4, 0x7b, 0x5e, 0x45, 0x02, 0x6a, 0x86, 0x2d); DEFINE_GUID!(IID_ID3D11Buffer, 0x48570b85, 0xd1ee, 0x4fcd, 0xa2, 0x50, 0xeb, 0x35, 0x07, 0x22, 0xb0, 0x37); DEFINE_GUID!(IID_ID3D11Texture1D, 0xf8fb5c27, 0xc6b3, 0x4f75, 0xa4, 0xc8, 0x43, 0x9a, 0xf2, 0xef, 0x56, 0x4c); DEFINE_GUID!(IID_ID3D11Texture2D, 0x6f15aaf2, 0xd208, 0x4e89, 0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c); DEFINE_GUID!(IID_ID3D11Texture3D, 0x037e866e, 0xf56d, 0x4357, 0xa8, 0xaf, 0x9d, 0xab, 0xbe, 0x6e, 0x25, 0x0e); DEFINE_GUID!(IID_ID3D11View, 0x839d1216, 0xbb2e, 0x412b, 0xb7, 0xf4, 0xa9, 0xdb, 0xeb, 0xe0, 0x8e, 0xd1); DEFINE_GUID!(IID_ID3D11ShaderResourceView, 0xb0e06fe0, 0x8192, 0x4e1a, 0xb1, 0xca, 0x36, 0xd7, 0x41, 0x47, 0x10, 0xb2); DEFINE_GUID!(IID_ID3D11RenderTargetView, 0xdfdba067, 0x0b8d, 0x4865, 0x87, 0x5b, 0xd7, 0xb4, 0x51, 0x6c, 0xc1, 0x64); DEFINE_GUID!(IID_ID3D11DepthStencilView, 0x9fdac92a, 0x1876, 0x48c3, 0xaf, 0xad, 0x25, 0xb9, 0x4f, 0x84, 0xa9, 0xb6); DEFINE_GUID!(IID_ID3D11UnorderedAccessView, 0x28acf509, 0x7f5c, 0x48f6, 0x86, 0x11, 0xf3, 0x16, 0x01, 0x0a, 0x63, 0x80); DEFINE_GUID!(IID_ID3D11VertexShader, 0x3b301d64, 0xd678, 0x4289, 0x88, 0x97, 0x22, 0xf8, 0x92, 0x8b, 0x72, 0xf3); DEFINE_GUID!(IID_ID3D11HullShader, 0x8e5c6061, 0x628a, 0x4c8e, 0x82, 0x64, 0xbb, 0xe4, 0x5c, 0xb3, 0xd5, 0xdd); DEFINE_GUID!(IID_ID3D11DomainShader, 0xf582c508, 0x0f36, 0x490c, 0x99, 0x77, 0x31, 0xee, 0xce, 0x26, 0x8c, 0xfa); DEFINE_GUID!(IID_ID3D11GeometryShader, 0x38325b96, 0xeffb, 0x4022, 0xba, 0x02, 0x2e, 0x79, 0x5b, 0x70, 0x27, 0x5c); DEFINE_GUID!(IID_ID3D11PixelShader, 0xea82e40d, 0x51dc, 0x4f33, 0x93, 0xd4, 0xdb, 0x7c, 0x91, 0x25, 0xae, 0x8c); DEFINE_GUID!(IID_ID3D11ComputeShader, 0x4f5b196e, 0xc2bd, 0x495e, 0xbd, 0x01, 0x1f, 0xde, 0xd3, 0x8e, 0x49, 0x69); DEFINE_GUID!(IID_ID3D11InputLayout, 0xe4819ddc, 0x4cf0, 0x4025, 0xbd, 0x26, 0x5d, 0xe8, 0x2a, 0x3e, 0x07, 0xb7); DEFINE_GUID!(IID_ID3D11SamplerState, 0xda6fea51, 0x564c, 0x4487, 0x98, 0x10, 0xf0, 0xd0, 0xf9, 0xb4, 0xe3, 0xa5); DEFINE_GUID!(IID_ID3D11Asynchronous, 0x4b35d0cd, 0x1e15, 0x4258, 0x9c, 0x98, 0x1b, 0x13, 0x33, 0xf6, 0xdd, 0x3b); DEFINE_GUID!(IID_ID3D11Query, 0xd6c00747, 0x87b7, 0x425e, 0xb8, 0x4d, 0x44, 0xd1, 0x08, 0x56, 0x0a, 0xfd); DEFINE_GUID!(IID_ID3D11Predicate, 0x9eb576dd, 0x9f77, 0x4d86, 0x81, 0xaa, 0x8b, 0xab, 0x5f, 0xe4, 0x90, 0xe2); DEFINE_GUID!(IID_ID3D11Counter, 0x6e8c49fb, 0xa371, 0x4770, 0xb4, 0x40, 0x29, 0x08, 0x60, 0x22, 0xb7, 0x41); DEFINE_GUID!(IID_ID3D11ClassInstance, 0xa6cd7faa, 0xb0b7, 0x4a2f, 0x94, 0x36, 0x86, 0x62, 0xa6, 0x57, 0x97, 0xcb); DEFINE_GUID!(IID_ID3D11ClassLinkage, 0xddf57cba, 0x9543, 0x46e4, 0xa1, 0x2b, 0xf2, 0x07, 0xa0, 0xfe, 0x7f, 0xed); DEFINE_GUID!(IID_ID3D11CommandList, 0xa24bc4d1, 0x769e, 0x43f7, 0x80, 0x13, 0x98, 0xff, 0x56, 0x6c, 0x18, 0xe2); DEFINE_GUID!(IID_ID3D11DeviceContext, 0xc0bfa96c, 0xe089, 0x44fb, 0x8e, 0xaf, 0x26, 0xf8, 0x79, 0x61, 0x90, 0xda); DEFINE_GUID!(IID_ID3D11VideoDecoder, 0x3C9C5B51, 0x995D, 0x48d1, 0x9B, 0x8D, 0xFA, 0x5C, 0xAE, 0xDE, 0xD6, 0x5C); DEFINE_GUID!(IID_ID3D11VideoProcessorEnumerator, 0x31627037, 0x53AB, 0x4200, 0x90, 0x61, 0x05, 0xFA, 0xA9, 0xAB, 0x45, 0xF9); DEFINE_GUID!(IID_ID3D11VideoProcessor, 0x1D7B0652, 0x185F, 0x41c6, 0x85, 0xCE, 0x0C, 0x5B, 0xE3, 0xD4, 0xAE, 0x6C); DEFINE_GUID!(IID_ID3D11AuthenticatedChannel, 0x3015A308, 0xDCBD, 0x47aa, 0xA7, 0x47, 0x19, 0x24, 0x86, 0xD1, 0x4D, 0x4A); DEFINE_GUID!(IID_ID3D11CryptoSession, 0x9B32F9AD, 0xBDCC, 0x40a6, 0xA3, 0x9D, 0xD5, 0xC8, 0x65, 0x84, 0x57, 0x20); DEFINE_GUID!(IID_ID3D11VideoDecoderOutputView, 0xC2931AEA, 0x2A85, 0x4f20, 0x86, 0x0F, 0xFB, 0xA1, 0xFD, 0x25, 0x6E, 0x18); DEFINE_GUID!(IID_ID3D11VideoProcessorInputView, 0x11EC5A5F, 0x51DC, 0x4945, 0xAB, 0x34, 0x6E, 0x8C, 0x21, 0x30, 0x0E, 0xA5); DEFINE_GUID!(IID_ID3D11VideoProcessorOutputView, 0xA048285E, 0x25A9, 0x4527, 0xBD, 0x93, 0xD6, 0x8B, 0x68, 0xC4, 0x42, 0x54); DEFINE_GUID!(IID_ID3D11VideoContext, 0x61F21C45, 0x3C0E, 0x4a74, 0x9C, 0xEA, 0x67, 0x10, 0x0D, 0x9A, 0xD5, 0xE4); DEFINE_GUID!(IID_ID3D11VideoDevice, 0x10EC4D5B, 0x975A, 0x4689, 0xB9, 0xE4, 0xD0, 0xAA, 0xC3, 0x0F, 0xE3, 0x33); DEFINE_GUID!(IID_ID3D11Device, 0xdb6f6ddb, 0xac77, 0x4e88, 0x82, 0x53, 0x81, 0x9d, 0xf9, 0xbb, 0xf1, 0x40); deps/winapi-0.2.5/src/rpcdce.rs0000644000000000000000000005202712613167613015047 0ustar rootroot// Copyright © 2015, Brian Vincent // Licensed under the MIT License // This module contains the DCE RPC runtime APIs. pub type RPC_CSTR = *mut ::c_uchar; pub type RPC_WSTR = *mut ::wchar_t; pub type RPC_CWSTR = *const ::wchar_t; pub type RPC_BINDING_HANDLE = ::I_RPC_HANDLE; pub type handle_t = RPC_BINDING_HANDLE; pub type rpc_binding_handle_t = RPC_BINDING_HANDLE; pub type UUID = ::GUID; pub type uuid_t = UUID; STRUCT!{struct RPC_BINDING_VECTOR { Count: ::c_ulong, BindingH: [RPC_BINDING_HANDLE; 1], }} pub type rpc_binding_vector_t = RPC_BINDING_VECTOR; STRUCT!{struct UUID_VECTOR { Count: ::c_ulong, Uuid: [*mut UUID; 1], }} pub type uuid_vector_t = UUID_VECTOR; pub type RPC_IF_HANDLE = *mut ::c_void; STRUCT!{struct RPC_IF_ID { Uuid: UUID, VersMajor: ::c_ushort, VersMinor: ::c_ushort, }} pub const RPC_C_BINDING_INFINITE_TIMEOUT: ::DWORD = 10; pub const RPC_C_BINDING_MIN_TIMEOUT: ::DWORD = 0; pub const RPC_C_BINDING_DEFAULT_TIMEOUT: ::DWORD = 5; pub const RPC_C_BINDING_MAX_TIMEOUT: ::DWORD = 9; pub const RPC_C_CANCEL_INFINITE_TIMEOUT: ::c_int = -1; pub const RPC_C_LISTEN_MAX_CALLS_DEFAULT: ::DWORD = 1234; pub const RPC_C_PROTSEQ_MAX_REQS_DEFAULT: ::DWORD = 10; pub const RPC_C_BIND_TO_ALL_NICS: ::DWORD = 1; pub const RPC_C_USE_INTERNET_PORT: ::DWORD = 0x1; pub const RPC_C_USE_INTRANET_PORT: ::DWORD = 0x2; pub const RPC_C_DONT_FAIL: ::DWORD = 0x4; pub const RPC_C_RPCHTTP_USE_LOAD_BALANCE: ::DWORD = 0x8; pub const RPC_C_MQ_TEMPORARY: ::DWORD = 0x0000; pub const RPC_C_MQ_PERMANENT: ::DWORD = 0x0001; pub const RPC_C_MQ_CLEAR_ON_OPEN: ::DWORD = 0x0002; pub const RPC_C_MQ_USE_EXISTING_SECURITY: ::DWORD = 0x0004; pub const RPC_C_MQ_AUTHN_LEVEL_NONE: ::DWORD = 0x0000; pub const RPC_C_MQ_AUTHN_LEVEL_PKT_INTEGRITY: ::DWORD = 0x0008; pub const RPC_C_MQ_AUTHN_LEVEL_PKT_PRIVACY: ::DWORD = 0x0010; pub const RPC_C_OPT_MQ_DELIVERY: ::DWORD = 1; pub const RPC_C_OPT_MQ_PRIORITY: ::DWORD = 2; pub const RPC_C_OPT_MQ_JOURNAL: ::DWORD = 3; pub const RPC_C_OPT_MQ_ACKNOWLEDGE: ::DWORD = 4; pub const RPC_C_OPT_MQ_AUTHN_SERVICE: ::DWORD = 5; pub const RPC_C_OPT_MQ_AUTHN_LEVEL: ::DWORD = 6; pub const RPC_C_OPT_MQ_TIME_TO_REACH_QUEUE: ::DWORD = 7; pub const RPC_C_OPT_MQ_TIME_TO_BE_RECEIVED: ::DWORD = 8; pub const RPC_C_OPT_BINDING_NONCAUSAL: ::DWORD = 9; pub const RPC_C_OPT_SECURITY_CALLBACK: ::DWORD = 10; pub const RPC_C_OPT_UNIQUE_BINDING: ::DWORD = 11; pub const RPC_C_OPT_CALL_TIMEOUT: ::DWORD = 12; pub const RPC_C_OPT_DONT_LINGER: ::DWORD = 13; pub const RPC_C_OPT_TRUST_PEER: ::DWORD = 14; pub const RPC_C_OPT_ASYNC_BLOCK: ::DWORD = 15; pub const RPC_C_OPT_OPTIMIZE_TIME: ::DWORD = 16; pub const RPC_C_OPT_MAX_OPTIONS: ::DWORD = 17; pub const RPC_C_MQ_EXPRESS: ::DWORD = 0; pub const RPC_C_MQ_RECOVERABLE: ::DWORD = 1; pub const RPC_C_MQ_JOURNAL_NONE: ::DWORD = 0; pub const RPC_C_MQ_JOURNAL_DEADLETTER: ::DWORD = 1; pub const RPC_C_MQ_JOURNAL_ALWAYS: ::DWORD = 2; pub const RPC_C_FULL_CERT_CHAIN: ::DWORD = 0x0001; STRUCT!{struct RPC_PROTSEQ_VECTORA { Count: ::c_uint, Protseq: [*mut ::c_uchar; 1], }} STRUCT!{struct RPC_PROTSEQ_VECTORW { Count: ::c_uint, Protseq: [*mut ::c_ushort; 1], }} STRUCT!{struct RPC_POLICY { Length: ::c_uint, EndpointFlags: ::c_ulong, NICFlags: ::c_ulong, }} pub type PRPC_POLICY = *mut RPC_POLICY; pub type RPC_OBJECT_INQ_FN = Option; pub type RPC_IF_CALLBACK_FN = Option ::RPC_STATUS>; pub type RPC_SECURITY_CALLBACK_FN = Option; pub type RPC_MGR_EPV = ::c_void; STRUCT!{struct RPC_STATS_VECTOR { Count: ::c_uint, Stats: [::c_ulong; 1], }} pub const RPC_C_STATS_CALLS_IN: ::c_ulong = 0; pub const RPC_C_STATS_CALLS_OUT: ::c_ulong = 1; pub const RPC_C_STATS_PKTS_IN: ::c_ulong = 2; pub const RPC_C_STATS_PKTS_OUT: ::c_ulong = 3; STRUCT!{struct RPC_IF_ID_VECTOR { Count: ::c_ulong, IfId: [*mut RPC_IF_ID; 1], }} pub type RPC_AUTH_IDENTITY_HANDLE = *mut ::c_void; pub type RPC_AUTHZ_HANDLE = *mut ::c_void; pub const RPC_C_AUTHN_LEVEL_DEFAULT: ::DWORD = 0; pub const RPC_C_AUTHN_LEVEL_NONE: ::DWORD = 1; pub const RPC_C_AUTHN_LEVEL_CONNECT: ::DWORD = 2; pub const RPC_C_AUTHN_LEVEL_CALL: ::DWORD = 3; pub const RPC_C_AUTHN_LEVEL_PKT: ::DWORD = 4; pub const RPC_C_AUTHN_LEVEL_PKT_INTEGRITY: ::DWORD = 5; pub const RPC_C_AUTHN_LEVEL_PKT_PRIVACY: ::DWORD = 6; pub const RPC_C_IMP_LEVEL_DEFAULT: ::DWORD = 0; pub const RPC_C_IMP_LEVEL_ANONYMOUS: ::DWORD = 1; pub const RPC_C_IMP_LEVEL_IDENTIFY: ::DWORD = 2; pub const RPC_C_IMP_LEVEL_IMPERSONATE: ::DWORD = 3; pub const RPC_C_IMP_LEVEL_DELEGATE: ::DWORD = 4; pub const RPC_C_QOS_IDENTITY_STATIC: ::DWORD = 0; pub const RPC_C_QOS_IDENTITY_DYNAMIC: ::DWORD = 1; pub const RPC_C_QOS_CAPABILITIES_DEFAULT: ::DWORD = 0x0; pub const RPC_C_QOS_CAPABILITIES_MUTUAL_AUTH: ::DWORD = 0x1; pub const RPC_C_QOS_CAPABILITIES_MAKE_FULLSIC: ::DWORD = 0x2; pub const RPC_C_QOS_CAPABILITIES_ANY_AUTHORITY: ::DWORD = 0x4; pub const RPC_C_QOS_CAPABILITIES_IGNORE_DELEGATE_FAILURE: ::DWORD = 0x8; pub const RPC_C_QOS_CAPABILITIES_LOCAL_MA_HINT: ::DWORD = 0x10; pub const RPC_C_QOS_CAPABILITIES_SCHANNEL_FULL_AUTH_IDENTITY: ::DWORD = 0x20; pub const RPC_C_PROTECT_LEVEL_DEFAULT: ::DWORD = RPC_C_AUTHN_LEVEL_DEFAULT; pub const RPC_C_PROTECT_LEVEL_NONE: ::DWORD = RPC_C_AUTHN_LEVEL_NONE; pub const RPC_C_PROTECT_LEVEL_CONNECT: ::DWORD = RPC_C_AUTHN_LEVEL_CONNECT; pub const RPC_C_PROTECT_LEVEL_CALL: ::DWORD = RPC_C_AUTHN_LEVEL_CALL; pub const RPC_C_PROTECT_LEVEL_PKT: ::DWORD = RPC_C_AUTHN_LEVEL_PKT; pub const RPC_C_PROTECT_LEVEL_PKT_INTEGRITY: ::DWORD = RPC_C_AUTHN_LEVEL_PKT_INTEGRITY; pub const RPC_C_PROTECT_LEVEL_PKT_PRIVACY: ::DWORD = RPC_C_AUTHN_LEVEL_PKT_PRIVACY; pub const RPC_C_AUTHN_NONE: ::DWORD = 0; pub const RPC_C_AUTHN_DCE_PRIVATE: ::DWORD = 1; pub const RPC_C_AUTHN_DCE_PUBLIC: ::DWORD = 2; pub const RPC_C_AUTHN_DEC_PUBLIC: ::DWORD = 4; pub const RPC_C_AUTHN_GSS_NEGOTIATE: ::DWORD = 9; pub const RPC_C_AUTHN_WINNT: ::DWORD = 10; pub const RPC_C_AUTHN_GSS_SCHANNEL: ::DWORD = 14; pub const RPC_C_AUTHN_GSS_KERBEROS: ::DWORD = 16; pub const RPC_C_AUTHN_DPA: ::DWORD = 17; pub const RPC_C_AUTHN_MSN: ::DWORD = 18; pub const RPC_C_AUTHN_DIGEST: ::DWORD = 21; pub const RPC_C_AUTHN_KERNEL: ::DWORD = 20; pub const RPC_C_AUTHN_NEGO_EXTENDER: ::DWORD = 30; pub const RPC_C_AUTHN_PKU2U: ::DWORD = 31; pub const RPC_C_AUTHN_LIVE_SSP: ::DWORD = 32; pub const RPC_C_AUTHN_LIVEXP_SSP: ::DWORD = 35; pub const RPC_C_AUTHN_MSONLINE: ::DWORD = 82; pub const RPC_C_AUTHN_MQ: ::DWORD = 100; pub const RPC_C_AUTHN_DEFAULT: ::DWORD = 0xFFFFFFFF; pub const RPC_C_NO_CREDENTIALS: ::DWORD = 0xFFFFFFFF; pub const RPC_C_SECURITY_QOS_VERSION: ::DWORD = 1; pub const RPC_C_SECURITY_QOS_VERSION_1: ::DWORD = 1; STRUCT!{struct RPC_SECURITY_QOS { Version: ::c_ulong, Capabilities: ::c_ulong, IdentityTracking: ::c_ulong, ImpersonationType: ::c_ulong, }} pub type PRPC_SECURITY_QOS = *mut RPC_SECURITY_QOS; STRUCT!{struct SEC_WINNT_AUTH_IDENTITY_W { User: *mut ::c_ushort, UserLength: ::c_ulong, Domain: *mut ::c_ushort, DomainLength: ::c_ulong, Password: *mut ::c_ushort, PasswordLength: ::c_ulong, Flags: ::c_ulong, }} pub type PSEC_WINNT_AUTH_IDENTITY_W = *mut SEC_WINNT_AUTH_IDENTITY_W; STRUCT!{struct SEC_WINNT_AUTH_IDENTITY_A { User: *mut ::c_uchar, UserLength: ::c_ulong, Domain: *mut ::c_uchar, DomainLength: ::c_ulong, Password: *mut ::c_uchar, PasswordLength: ::c_ulong, Flags: ::c_ulong, }} pub type PSEC_WINNT_AUTH_IDENTITY_A = *mut SEC_WINNT_AUTH_IDENTITY_A; pub const RPC_C_AUTHN_INFO_TYPE_HTTP: ::c_ulong = 1; pub const RPC_C_HTTP_AUTHN_TARGET_SERVER: ::c_ulong = 1; pub const RPC_C_HTTP_AUTHN_TARGET_PROXY: ::c_ulong = 2; pub const RPC_C_HTTP_AUTHN_SCHEME_BASIC: ::c_ulong = 0x00000001; pub const RPC_C_HTTP_AUTHN_SCHEME_NTLM: ::c_ulong = 0x00000002; pub const RPC_C_HTTP_AUTHN_SCHEME_PASSPORT: ::c_ulong = 0x00000004; pub const RPC_C_HTTP_AUTHN_SCHEME_DIGEST: ::c_ulong = 0x00000008; pub const RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE: ::c_ulong = 0x00000010; pub const RPC_C_HTTP_AUTHN_SCHEME_CERT: ::c_ulong = 0x00010000; pub const RPC_C_HTTP_FLAG_USE_SSL: ::c_ulong = 1; pub const RPC_C_HTTP_FLAG_USE_FIRST_AUTH_SCHEME: ::c_ulong = 2; pub const RPC_C_HTTP_FLAG_IGNORE_CERT_CN_INVALID: ::c_ulong = 8; pub const RPC_C_HTTP_FLAG_ENABLE_CERT_REVOCATION_CHECK: ::c_ulong = 16; STRUCT!{struct RPC_HTTP_TRANSPORT_CREDENTIALS_W { TransportCredentials: *mut SEC_WINNT_AUTH_IDENTITY_W, Flags: ::c_ulong, AuthenticationTarget: ::c_ulong, NumberOfAuthnSchemes: ::c_ulong, AuthnSchemes: *mut ::c_ulong, ServerCertificateSubject: *mut ::c_ushort, }} pub type PRPC_HTTP_TRANSPORT_CREDENTIALS_W = *mut RPC_HTTP_TRANSPORT_CREDENTIALS_W; STRUCT!{struct RPC_HTTP_TRANSPORT_CREDENTIALS_A { TransportCredentials: *mut SEC_WINNT_AUTH_IDENTITY_A, Flags: ::c_ulong, AuthenticationTarget: ::c_ulong, NumberOfAuthnSchemes: ::c_ulong, AuthnSchemes: *mut ::c_ulong, ServerCertificateSubject: *mut ::c_uchar, }} pub type PRPC_HTTP_TRANSPORT_CREDENTIALS_A = *mut RPC_HTTP_TRANSPORT_CREDENTIALS_A; STRUCT!{struct RPC_HTTP_TRANSPORT_CREDENTIALS_V2_W { TransportCredentials: *mut SEC_WINNT_AUTH_IDENTITY_W, Flags: ::c_ulong, AuthenticationTarget: ::c_ulong, NumberOfAuthnSchemes: ::c_ulong, AuthnSchemes: *mut ::c_ulong, ServerCertificateSubject: *mut ::c_ushort, ProxyCredentials: *mut SEC_WINNT_AUTH_IDENTITY_W, NumberOfProxyAuthnSchemes: ::c_ulong, ProxyAuthnSchemes: *mut ::c_ulong, }} pub type PRPC_HTTP_TRANSPORT_CREDENTIALS_V2_W = *mut RPC_HTTP_TRANSPORT_CREDENTIALS_V2_W; STRUCT!{struct RPC_HTTP_TRANSPORT_CREDENTIALS_V2_A { TransportCredentials: *mut SEC_WINNT_AUTH_IDENTITY_A, Flags: ::c_ulong, AuthenticationTarget: ::c_ulong, NumberOfAuthnSchemes: ::c_ulong, AuthnSchemes: *mut ::c_ulong, ServerCertificateSubject: *mut ::c_uchar, ProxyCredentials: *mut SEC_WINNT_AUTH_IDENTITY_A, NumberOfProxyAuthnSchemes: ::c_ulong, ProxyAuthnSchemes: *mut ::c_ulong, }} pub type PRPC_HTTP_TRANSPORT_CREDENTIALS_V2_A = *mut RPC_HTTP_TRANSPORT_CREDENTIALS_V2_A; STRUCT!{struct RPC_HTTP_TRANSPORT_CREDENTIALS_V3_W { TransportCredentials: RPC_AUTH_IDENTITY_HANDLE, Flags: ::c_ulong, AuthenticationTarget: ::c_ulong, NumberOfAuthnSchemes: ::c_ulong, AuthnSchemes: *mut ::c_ulong, ServerCertificateSubject: *mut ::c_ushort, ProxyCredentials: *mut RPC_AUTH_IDENTITY_HANDLE, NumberOfProxyAuthnSchemes: ::c_ulong, ProxyAuthnSchemes: *mut ::c_ulong, }} pub type PRPC_HTTP_TRANSPORT_CREDENTIALS_V3_W = *mut RPC_HTTP_TRANSPORT_CREDENTIALS_V3_W; STRUCT!{struct RPC_HTTP_TRANSPORT_CREDENTIALS_V3_A { TransportCredentials: RPC_AUTH_IDENTITY_HANDLE, Flags: ::c_ulong, AuthenticationTarget: ::c_ulong, NumberOfAuthnSchemes: ::c_ulong, AuthnSchemes: *mut ::c_ulong, ServerCertificateSubject: *mut ::c_uchar, ProxyCredentials: *mut RPC_AUTH_IDENTITY_HANDLE, NumberOfProxyAuthnSchemes: ::c_ulong, ProxyAuthnSchemes: *mut ::c_ulong, }} pub type PRPC_HTTP_TRANSPORT_CREDENTIALS_V3_A = *mut RPC_HTTP_TRANSPORT_CREDENTIALS_V3_A; STRUCT!{struct RPC_SECURITY_QOS_V2_W_union { HttpCredentials: *mut RPC_HTTP_TRANSPORT_CREDENTIALS_W, }} STRUCT!{struct RPC_SECURITY_QOS_V2_W { Version: ::c_ulong, Capabilities: ::c_ulong, IdentityTracking: ::c_ulong, ImpersonationType: ::c_ulong, AdditionalSecurityInfoType: ::c_ulong, u: RPC_SECURITY_QOS_V2_W_union, }} pub type PRPC_SECURITY_QOS_V2_W = *mut RPC_SECURITY_QOS_V2_W; STRUCT!{struct RPC_SECURITY_QOS_V2_A_union { HttpCredentials: *mut RPC_HTTP_TRANSPORT_CREDENTIALS_A, }} STRUCT!{struct RPC_SECURITY_QOS_V2_A { Version: ::c_ulong, Capabilities: ::c_ulong, IdentityTracking: ::c_ulong, ImpersonationType: ::c_ulong, AdditionalSecurityInfoType: ::c_ulong, u: RPC_SECURITY_QOS_V2_A_union, }} pub type PRPC_SECURITY_QOS_V2_A = *mut RPC_SECURITY_QOS_V2_A; STRUCT!{struct RPC_SECURITY_QOS_V3_W_union { HttpCredentials: *mut RPC_HTTP_TRANSPORT_CREDENTIALS_W, }} STRUCT!{struct RPC_SECURITY_QOS_V3_W { Version: ::c_ulong, Capabilities: ::c_ulong, IdentityTracking: ::c_ulong, ImpersonationType: ::c_ulong, AdditionalSecurityInfoType: ::c_ulong, u: RPC_SECURITY_QOS_V3_W_union, Sid: *mut ::c_void, }} pub type PRPC_SECURITY_QOS_V3_W = *mut RPC_SECURITY_QOS_V3_W; STRUCT!{struct RPC_SECURITY_QOS_V3_A_union { HttpCredentials: *mut RPC_HTTP_TRANSPORT_CREDENTIALS_A, }} STRUCT!{struct RPC_SECURITY_QOS_V3_A { Version: ::c_ulong, Capabilities: ::c_ulong, IdentityTracking: ::c_ulong, ImpersonationType: ::c_ulong, AdditionalSecurityInfoType: ::c_ulong, u: RPC_SECURITY_QOS_V3_A_union, Sid: *mut ::c_void, }} pub type PRPC_SECURITY_QOS_V3_A = *mut RPC_SECURITY_QOS_V3_A; STRUCT!{struct RPC_SECURITY_QOS_V4_W_union { HttpCredentials: *mut RPC_HTTP_TRANSPORT_CREDENTIALS_W, }} STRUCT!{struct RPC_SECURITY_QOS_V4_W { Version: ::c_ulong, Capabilities: ::c_ulong, IdentityTracking: ::c_ulong, ImpersonationType: ::c_ulong, AdditionalSecurityInfoType: ::c_ulong, u: RPC_SECURITY_QOS_V4_W_union, Sid: *mut ::c_void, EffectiveOnly: ::c_uint, }} pub type PRPC_SECURITY_QOS_V4_W = *mut RPC_SECURITY_QOS_V4_W; STRUCT!{struct RPC_SECURITY_QOS_V4_A_union { HttpCredentials: *mut RPC_HTTP_TRANSPORT_CREDENTIALS_A, }} STRUCT!{struct RPC_SECURITY_QOS_V4_A { Version: ::c_ulong, Capabilities: ::c_ulong, IdentityTracking: ::c_ulong, ImpersonationType: ::c_ulong, AdditionalSecurityInfoType: ::c_ulong, u: RPC_SECURITY_QOS_V4_A_union, Sid: *mut ::c_void, EffectiveOnly: ::c_uint, }} pub type PRPC_SECURITY_QOS_V4_A = *mut RPC_SECURITY_QOS_V4_A; STRUCT!{struct RPC_SECURITY_QOS_V5_W_union { HttpCredentials: *mut RPC_HTTP_TRANSPORT_CREDENTIALS_W, }} STRUCT!{struct RPC_SECURITY_QOS_V5_W { Version: ::c_ulong, Capabilities: ::c_ulong, IdentityTracking: ::c_ulong, ImpersonationType: ::c_ulong, AdditionalSecurityInfoType: ::c_ulong, u: RPC_SECURITY_QOS_V5_W_union, Sid: *mut ::c_void, EffectiveOnly: ::c_uint, ServerSecurityDescriptor: *mut ::c_void, }} pub type PRPC_SECURITY_QOS_V5_W = *mut RPC_SECURITY_QOS_V5_W; STRUCT!{struct RPC_SECURITY_QOS_V5_A_union { HttpCredentials: *mut RPC_HTTP_TRANSPORT_CREDENTIALS_A, }} STRUCT!{struct RPC_SECURITY_QOS_V5_A { Version: ::c_ulong, Capabilities: ::c_ulong, IdentityTracking: ::c_ulong, ImpersonationType: ::c_ulong, AdditionalSecurityInfoType: ::c_ulong, u: RPC_SECURITY_QOS_V5_A_union, Sid: *mut ::c_void, EffectiveOnly: ::c_uint, ServerSecurityDescriptor: *mut ::c_void, }} pub type PRPC_SECURITY_QOS_V5_A = *mut RPC_SECURITY_QOS_V5_A; pub const RPC_PROTSEQ_TCP: ::c_ulong = 0x1; pub const RPC_PROTSEQ_NMP: ::c_ulong = 0x2; pub const RPC_PROTSEQ_LRPC: ::c_ulong = 0x3; pub const RPC_PROTSEQ_HTTP: ::c_ulong = 0x4; pub const RPC_BHT_OBJECT_UUID_VALID: ::c_ulong = 0x1; pub const RPC_BHO_NONCAUSAL: ::c_ulong = 0x1; pub const RPC_BHO_DONTLINGER: ::c_ulong = 0x2; pub const RPC_BHO_EXCLUSIVE_AND_GUARANTEED: ::c_ulong = 0x4; STRUCT!{struct RPC_BINDING_HANDLE_TEMPLATE_V1_W_union { Reserved: *mut ::c_ushort, }} STRUCT!{struct RPC_BINDING_HANDLE_TEMPLATE_V1_W { Version: ::c_ulong, Flags: ::c_ulong, ProtocolSequence: ::c_ulong, NetworkAddress: *mut ::c_ushort, StringEndpoint: *mut ::c_ushort, u1: RPC_BINDING_HANDLE_TEMPLATE_V1_W_union, ObjectUuid: UUID, }} pub type PRPC_BINDING_HANDLE_TEMPLATE_V1_W = *mut RPC_BINDING_HANDLE_TEMPLATE_V1_W; STRUCT!{struct RPC_BINDING_HANDLE_TEMPLATE_V1_A_union { Reserved: *mut ::c_uchar, }} STRUCT!{struct RPC_BINDING_HANDLE_TEMPLATE_V1_A { Version: ::c_ulong, Flags: ::c_ulong, ProtocolSequence: ::c_ulong, NetworkAddress: *mut ::c_uchar, StringEndpoint: *mut ::c_uchar, u1: RPC_BINDING_HANDLE_TEMPLATE_V1_A_union, ObjectUuid: UUID, }} pub type PRPC_BINDING_HANDLE_TEMPLATE_V1_A = *mut RPC_BINDING_HANDLE_TEMPLATE_V1_A; STRUCT!{struct RPC_BINDING_HANDLE_SECURITY_V1_W { Version: ::c_ulong, ServerPrincName: *mut ::c_ushort, AuthnLevel: ::c_ulong, AuthnSvc: ::c_ulong, AuthIdentity: *mut SEC_WINNT_AUTH_IDENTITY_W, SecurityQos: *mut RPC_SECURITY_QOS, }} pub type PRPC_BINDING_HANDLE_SECURITY_V1_W = *mut RPC_BINDING_HANDLE_SECURITY_V1_W; STRUCT!{struct RPC_BINDING_HANDLE_SECURITY_V1_A { Version: ::c_ulong, ServerPrincName: *mut ::c_uchar, AuthnLevel: ::c_ulong, AuthnSvc: ::c_ulong, AuthIdentity: *mut SEC_WINNT_AUTH_IDENTITY_A, SecurityQos: *mut RPC_SECURITY_QOS, }} pub type PRPC_BINDING_HANDLE_SECURITY_V1_A = *mut RPC_BINDING_HANDLE_SECURITY_V1_A; STRUCT!{struct RPC_BINDING_HANDLE_OPTIONS_V1 { Version: ::c_ulong, Flags: ::c_ulong, ComTimeout: ::c_ulong, CallTimeout: ::c_ulong, }} pub type PRPC_BINDING_HANDLE_OPTIONS_V1 = *mut RPC_BINDING_HANDLE_OPTIONS_V1; ENUM!{enum RPC_HTTP_REDIRECTOR_STAGE { RPCHTTP_RS_REDIRECT = 1, RPCHTTP_RS_ACCESS_1, RPCHTTP_RS_SESSION, RPCHTTP_RS_ACCESS_2, RPCHTTP_RS_INTERFACE, }} pub type RPC_NEW_HTTP_PROXY_CHANNEL = Option ::RPC_STATUS>; pub type RPC_HTTP_PROXY_FREE_STRING = Option; pub const RPC_C_AUTHZ_NONE: ::DWORD = 0; pub const RPC_C_AUTHZ_NAME: ::DWORD = 1; pub const RPC_C_AUTHZ_DCE: ::DWORD = 2; pub const RPC_C_AUTHZ_DEFAULT: ::DWORD = 0xffffffff; pub type RPC_AUTH_KEY_RETRIEVAL_FN = Option; STRUCT!{struct RPC_CLIENT_INFORMATION1 { UserName: *mut ::c_uchar, ComputerName: *mut ::c_uchar, Privilege: ::c_ushort, AuthFlags: ::c_ulong, }} pub type PRPC_CLIENT_INFORMATION1 = *mut RPC_CLIENT_INFORMATION1; pub type RPC_EP_INQ_HANDLE = *mut ::I_RPC_HANDLE; pub const RPC_C_EP_ALL_ELTS: ::c_ulong = 0; pub const RPC_C_EP_MATCH_BY_IF: ::c_ulong = 1; pub const RPC_C_EP_MATCH_BY_OBJ: ::c_ulong = 2; pub const RPC_C_EP_MATCH_BY_BOTH: ::c_ulong = 3; pub const RPC_C_VERS_ALL: ::c_ulong = 1; pub const RPC_C_VERS_COMPATIBLE: ::c_ulong = 2; pub const RPC_C_VERS_EXACT: ::c_ulong = 3; pub const RPC_C_VERS_MAJOR_ONLY: ::c_ulong = 4; pub const RPC_C_VERS_UPTO: ::c_ulong = 5; pub type RPC_MGMT_AUTHORIZATION_FN = Option ::c_int>; pub const RPC_C_MGMT_INQ_IF_IDS: ::c_ulong = 0; pub const RPC_C_MGMT_INQ_PRINC_NAME: ::c_ulong = 1; pub const RPC_C_MGMT_INQ_STATS: ::c_ulong = 2; pub const RPC_C_MGMT_IS_SERVER_LISTEN: ::c_ulong = 3; pub const RPC_C_MGMT_STOP_SERVER_LISTEN: ::c_ulong = 4; pub const RPC_IF_AUTOLISTEN: ::c_uint = 0x0001; pub const RPC_IF_OLE: ::c_uint = 0x0002; pub const RPC_IF_ALLOW_UNKNOWN_AUTHORITY: ::c_uint = 0x0004; pub const RPC_IF_ALLOW_SECURE_ONLY: ::c_uint = 0x0008; pub const RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH: ::c_uint = 0x0010; pub const RPC_IF_ALLOW_LOCAL_ONLY: ::c_uint = 0x0020; pub const RPC_IF_SEC_NO_CACHE: ::c_uint = 0x0040; pub const RPC_IF_SEC_CACHE_PER_PROC: ::c_uint = 0x0080; pub const RPC_IF_ASYNC_CALLBACK: ::c_uint = 0x0100; pub const RPC_FW_IF_FLAG_DCOM: ::c_uint = 0x0001; pub type RPC_INTERFACE_GROUP = *mut ::c_void; pub type PRPC_INTERFACE_GROUP = *mut *mut ::c_void; STRUCT!{struct RPC_ENDPOINT_TEMPLATEW { Version: ::c_ulong, ProtSeq: RPC_WSTR, Endpoint: RPC_WSTR, SecurityDescriptor: *mut ::c_void, Backlog: ::c_ulong, }} pub type PRPC_ENDPOINT_TEMPLATEW = *mut RPC_ENDPOINT_TEMPLATEW; STRUCT!{struct RPC_ENDPOINT_TEMPLATEA { Version: ::c_ulong, ProtSeq: RPC_CSTR, Endpoint: RPC_CSTR, SecurityDescriptor: *mut ::c_void, Backlog: ::c_ulong, }} pub type PRPC_ENDPOINT_TEMPLATEA = *mut RPC_ENDPOINT_TEMPLATEA; STRUCT!{struct RPC_INTERFACE_TEMPLATEA { Version: ::c_ulong, IfSpec: RPC_IF_HANDLE, MgrTypeUuid: *mut UUID, MgrEpv: *mut RPC_MGR_EPV, Flags: ::c_uint, MaxCalls: ::c_uint, MaxRpcSize: ::c_uint, IfCallback: *mut RPC_IF_CALLBACK_FN, UuidVector: *mut UUID_VECTOR, Annotation: RPC_CSTR, SecurityDescriptor: *mut ::c_void, }} pub type PRPC_INTERFACE_TEMPLATEA = *mut RPC_INTERFACE_TEMPLATEA; STRUCT!{struct RPC_INTERFACE_TEMPLATEW { Version: ::c_ulong, IfSpec: RPC_IF_HANDLE, MgrTypeUuid: *mut UUID, MgrEpv: *mut RPC_MGR_EPV, Flags: ::c_uint, MaxCalls: ::c_uint, MaxRpcSize: ::c_uint, IfCallback: *mut RPC_IF_CALLBACK_FN, UuidVector: *mut UUID_VECTOR, Annotation: RPC_WSTR, SecurityDescriptor: *mut ::c_void, }} pub type PRPC_INTERFACE_TEMPLATEW = *mut RPC_INTERFACE_TEMPLATEW; pub type RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN = Option; deps/winapi-0.2.5/src/shellscalingapi.rs0000644000000000000000000000106712615662007016746 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License // ShellScalingApi.h ENUM!{enum PROCESS_DPI_AWARENESS { Process_DPI_Unaware = 0, Process_System_DPI_Aware = 1, Process_Per_Monitor_DPI_Aware = 2, }} ENUM!{enum SHELL_UI_COMPONENT { SHELL_UI_COMPONENT_TASKBARS = 0, SHELL_UI_COMPONENT_NOTIFICATIONAREA = 1, SHELL_UI_COMPONENT_DESKBAND = 2, }} ENUM!{enum MONITOR_DPI_TYPE { MDT_EFFECTIVE_DPI = 0, MDT_ANGULAR_DPI = 1, MDT_RAW_DPI = 2, }} pub const MDT_DEFAULT: MONITOR_DPI_TYPE = MDT_EFFECTIVE_DPI; deps/winapi-0.2.5/src/audioclient.rs0000644000000000000000000001070312612751552016102 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! this ALWAYS GENERATED file contains the definitions for the interfaces //1627 pub const AUDCLNT_E_NOT_INITIALIZED: ::HRESULT = AUDCLNT_ERR!(0x001); pub const AUDCLNT_E_ALREADY_INITIALIZED: ::HRESULT = AUDCLNT_ERR!(0x002); pub const AUDCLNT_E_WRONG_ENDPOINT_TYPE: ::HRESULT = AUDCLNT_ERR!(0x003); pub const AUDCLNT_E_DEVICE_INVALIDATED: ::HRESULT = AUDCLNT_ERR!(0x004); pub const AUDCLNT_E_NOT_STOPPED: ::HRESULT = AUDCLNT_ERR!(0x005); pub const AUDCLNT_E_BUFFER_TOO_LARGE: ::HRESULT = AUDCLNT_ERR!(0x006); pub const AUDCLNT_E_OUT_OF_ORDER: ::HRESULT = AUDCLNT_ERR!(0x007); pub const AUDCLNT_E_UNSUPPORTED_FORMAT: ::HRESULT = AUDCLNT_ERR!(0x008); pub const AUDCLNT_E_INVALID_SIZE: ::HRESULT = AUDCLNT_ERR!(0x009); pub const AUDCLNT_E_DEVICE_IN_USE: ::HRESULT = AUDCLNT_ERR!(0x00a); pub const AUDCLNT_E_BUFFER_OPERATION_PENDING: ::HRESULT = AUDCLNT_ERR!(0x00b); pub const AUDCLNT_E_THREAD_NOT_REGISTERED: ::HRESULT = AUDCLNT_ERR!(0x00c); pub const AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED: ::HRESULT = AUDCLNT_ERR!(0x00e); pub const AUDCLNT_E_ENDPOINT_CREATE_FAILED: ::HRESULT = AUDCLNT_ERR!(0x00f); pub const AUDCLNT_E_SERVICE_NOT_RUNNING: ::HRESULT = AUDCLNT_ERR!(0x010); pub const AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED: ::HRESULT = AUDCLNT_ERR!(0x011); pub const AUDCLNT_E_EXCLUSIVE_MODE_ONLY: ::HRESULT = AUDCLNT_ERR!(0x012); pub const AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL: ::HRESULT = AUDCLNT_ERR!(0x013); pub const AUDCLNT_E_EVENTHANDLE_NOT_SET: ::HRESULT = AUDCLNT_ERR!(0x014); pub const AUDCLNT_E_INCORRECT_BUFFER_SIZE: ::HRESULT = AUDCLNT_ERR!(0x015); pub const AUDCLNT_E_BUFFER_SIZE_ERROR: ::HRESULT = AUDCLNT_ERR!(0x016); pub const AUDCLNT_E_CPUUSAGE_EXCEEDED: ::HRESULT = AUDCLNT_ERR!(0x017); pub const AUDCLNT_E_BUFFER_ERROR: ::HRESULT = AUDCLNT_ERR!(0x018); pub const AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED: ::HRESULT = AUDCLNT_ERR!(0x019); pub const AUDCLNT_E_INVALID_DEVICE_PERIOD: ::HRESULT = AUDCLNT_ERR!(0x020); pub const AUDCLNT_E_INVALID_STREAM_FLAG: ::HRESULT = AUDCLNT_ERR!(0x021); pub const AUDCLNT_E_ENDPOINT_OFFLOAD_NOT_CAPABLE: ::HRESULT = AUDCLNT_ERR!(0x022); pub const AUDCLNT_E_OUT_OF_OFFLOAD_RESOURCES: ::HRESULT = AUDCLNT_ERR!(0x023); pub const AUDCLNT_E_OFFLOAD_MODE_ONLY: ::HRESULT = AUDCLNT_ERR!(0x024); pub const AUDCLNT_E_NONOFFLOAD_MODE_ONLY: ::HRESULT = AUDCLNT_ERR!(0x025); pub const AUDCLNT_E_RESOURCES_INVALIDATED: ::HRESULT = AUDCLNT_ERR!(0x026); pub const AUDCLNT_E_RAW_MODE_UNSUPPORTED: ::HRESULT = AUDCLNT_ERR!(0x027); pub const AUDCLNT_S_BUFFER_EMPTY: ::SCODE = AUDCLNT_SUCCESS!(0x001); pub const AUDCLNT_S_THREAD_ALREADY_REGISTERED: ::SCODE = AUDCLNT_SUCCESS!(0x002); pub const AUDCLNT_S_POSITION_STALLED: ::SCODE = AUDCLNT_SUCCESS!(0x003); DEFINE_GUID!(IID_IAudioClient, 0x1CB9AD4C, 0xDBFA, 0x4c32, 0xB1, 0x78, 0xC2, 0xF5, 0x68, 0xA7, 0x03, 0xB2); DEFINE_GUID!(IID_IAudioRenderClient, 0xF294ACFC, 0x3146, 0x4483, 0xA7, 0xBF, 0xAD, 0xDC, 0xA7, 0xC2, 0x60, 0xE2); RIDL!{interface IAudioClient(IAudioClientVtbl): IUnknown(IUnknownVtbl) { fn Initialize( &mut self, ShareMode: ::AUDCLNT_SHAREMODE, StreamFlags: ::DWORD, hnsBufferDuration: ::REFERENCE_TIME, hnsPeriodicity: ::REFERENCE_TIME, pFormat: *const ::WAVEFORMATEX, AudioSessionGuid: ::LPCGUID ) -> ::HRESULT, fn GetBufferSize(&mut self, pNumBufferFrames: *mut ::UINT32) -> ::HRESULT, fn GetStreamLatency(&mut self, phnsLatency: *mut ::REFERENCE_TIME) -> ::HRESULT, fn GetCurrentPadding(&mut self, pNumPaddingFrames: *mut ::UINT32) -> ::HRESULT, fn IsFormatSupported( &mut self, ShareMode: ::AUDCLNT_SHAREMODE, pFormat: *const ::WAVEFORMATEX, ppClosestMatch: *mut *mut ::WAVEFORMATEX ) -> ::HRESULT, fn GetMixFormat(&mut self, ppDeviceFormat: *mut *mut ::WAVEFORMATEX) -> ::HRESULT, fn GetDevicePeriod( &mut self, phnsDefaultDevicePeriod: *mut ::REFERENCE_TIME, phnsMinimumDevicePeriod: *mut ::REFERENCE_TIME ) -> ::HRESULT, fn Start(&mut self) -> ::HRESULT, fn Stop(&mut self) -> ::HRESULT, fn Reset(&mut self) -> ::HRESULT, fn SetEventHandle(&mut self, eventHandle: ::HANDLE) -> ::HRESULT, fn GetService(&mut self, riid: ::REFIID, ppv: *mut ::LPVOID) -> ::HRESULT }} RIDL!{interface IAudioRenderClient(IAudioRenderClientVtbl): IUnknown(IUnknownVtbl) { fn GetBuffer(&mut self, NumFramesRequested: ::UINT32, ppData: *mut *mut ::BYTE) -> ::HRESULT, fn ReleaseBuffer(&mut self, NumFramesWritten: ::UINT32, dwFlags: ::DWORD) -> ::HRESULT }} deps/winapi-0.2.5/src/urlhist.rs0000644000000000000000000000464512613167613015304 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Url History Interfaces pub const STATURL_QUERYFLAG_ISCACHED: ::DWORD = 0x00010000; pub const STATURL_QUERYFLAG_NOURL: ::DWORD = 0x00020000; pub const STATURL_QUERYFLAG_NOTITLE: ::DWORD = 0x00040000; pub const STATURL_QUERYFLAG_TOPLEVEL: ::DWORD = 0x00080000; pub const STATURLFLAG_ISCACHED: ::DWORD = 0x00000001; pub const STATURLFLAG_ISTOPLEVEL: ::DWORD = 0x00000002; ENUM!{enum ADDURL_FLAG { ADDURL_FIRST = 0, ADDURL_ADDTOHISTORYANDCACHE = 0, ADDURL_ADDTOCACHE = 1, ADDURL_Max = 2147483647, }} pub type LPENUMSTATURL = *mut IEnumSTATURL; STRUCT!{struct STATURL { cbSize: ::DWORD, pwcsUrl: ::LPWSTR, pwcsTitle: ::LPWSTR, ftLastVisited: ::FILETIME, ftLastUpdated: ::FILETIME, ftExpires: ::FILETIME, dwFlags: ::DWORD, }} pub type LPSTATURL = *mut STATURL; RIDL!{interface IEnumSTATURL(IEnumSTATURLVtbl): IUnknown(IUnknownVtbl) { fn Next(&mut self, celt: ::ULONG, rgelt: LPSTATURL, pceltFetched: *mut ::ULONG) -> ::HRESULT, fn Skip(&mut self, celt: ::ULONG) -> ::HRESULT, fn Reset(&mut self) -> ::HRESULT, fn Clone(&mut self, ppenum: *mut *mut ::IEnumSTATURL) -> ::HRESULT, fn SetFilter(&mut self, poszFilter: ::LPCOLESTR, dwFlags: ::DWORD) -> ::HRESULT }} pub type LPURLHISTORYSTG = *mut IUrlHistoryStg; RIDL!{interface IUrlHistoryStg(IUrlHistoryStgVtbl): IUnknown(IUnknownVtbl) { fn AddUrl(&mut self, pocsUrl: ::LPCOLESTR) -> ::HRESULT, fn DeleteUrl(&mut self, pocsUrl: ::LPCOLESTR, dwFlags: ::DWORD) -> ::HRESULT, fn QueryUrl( &mut self, pocsUrl: ::LPCOLESTR, dwFlags: ::DWORD, lpSTATURL: LPSTATURL ) -> ::HRESULT, fn BindToObject( &mut self, pocsUrl: ::LPCOLESTR, riid: ::REFIID, ppvOut: *mut *mut ::c_void ) -> ::HRESULT, fn EnumUrls(&mut self, ppEnum: *mut *mut ::IEnumSTATURL) -> ::HRESULT }} pub type LPURLHISTORYSTG2 = *mut IUrlHistoryStg2; RIDL!{interface IUrlHistoryStg2(IUrlHistoryStg2Vtbl): IUrlHistoryStg(IUrlHistoryStgVtbl) { fn AddUrlAndNotify( &mut self, pocsUrl: ::LPCOLESTR, pocsTitle: ::LPCOLESTR, dwFlags: ::DWORD, fWriteHistory: ::BOOL, poctNotify: *mut ::IOleCommandTarget, punkISFolder: *mut ::IUnknown ) -> ::HRESULT, fn ClearHistory(&mut self) -> ::HRESULT }} pub type LPURLHISTORYNOTIFY = *mut IUrlHistoryNotify; RIDL!{interface IUrlHistoryNotify(IUrlHistoryNotifyVtbl): IOleCommandTarget(IOleCommandTargetVtbl) {}} deps/winapi-0.2.5/src/wincred.rs0000644000000000000000000002125312615662007015236 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Authentication API Prototypes and Definitions pub const NERR_BASE: ::DWORD = 2100; pub const NERR_PasswordExpired: ::DWORD = NERR_BASE+142; pub const CRED_MAX_STRING_LENGTH: ::DWORD = 256; pub const CRED_MAX_USERNAME_LENGTH: ::DWORD = 256+1+256; pub const CRED_MAX_GENERIC_TARGET_NAME_LENGTH: ::DWORD = 32767; pub const CRED_MAX_DOMAIN_TARGET_NAME_LENGTH: ::DWORD = 256+1+80; pub const CRED_MAX_TARGETNAME_NAMESPACE_LENGTH: ::DWORD = 256; pub const CRED_MAX_TARGETNAME_ATTRIBUTE_LENGTH: ::DWORD = 256; pub const CRED_MAX_VALUE_SIZE: ::DWORD = 256; pub const CRED_MAX_ATTRIBUTES: ::DWORD = 64; pub const CRED_LOGON_TYPES_MASK: ::DWORD = 0xF000; pub const CRED_FLAGS_PASSWORD_FOR_CERT: ::DWORD = 0x0001; pub const CRED_FLAGS_PROMPT_NOW: ::DWORD = 0x0002; pub const CRED_FLAGS_USERNAME_TARGET: ::DWORD = 0x0004; pub const CRED_FLAGS_OWF_CRED_BLOB: ::DWORD = 0x0008; pub const CRED_FLAGS_REQUIRE_CONFIRMATION: ::DWORD = 0x0010; pub const CRED_FLAGS_WILDCARD_MATCH: ::DWORD = 0x0020; pub const CRED_FLAGS_VALID_FLAGS: ::DWORD = 0xF03F; pub const CRED_FLAGS_VALID_INPUT_FLAGS: ::DWORD = 0xF01F; pub const CRED_TYPE_GENERIC: ::DWORD = 1; pub const CRED_TYPE_DOMAIN_PASSWORD: ::DWORD = 2; pub const CRED_TYPE_DOMAIN_CERTIFICATE: ::DWORD = 3; pub const CRED_TYPE_DOMAIN_VISIBLE_PASSWORD: ::DWORD = 4; pub const CRED_TYPE_GENERIC_CERTIFICATE: ::DWORD = 5; pub const CRED_TYPE_DOMAIN_EXTENDED: ::DWORD = 6; pub const CRED_TYPE_MAXIMUM: ::DWORD = 7; pub const CRED_TYPE_MAXIMUM_EX: ::DWORD = CRED_TYPE_MAXIMUM+1000; pub const CRED_MAX_CREDENTIAL_BLOB_SIZE: ::DWORD = 5*512; pub const CRED_PERSIST_NONE: ::DWORD = 0; pub const CRED_PERSIST_SESSION: ::DWORD = 1; pub const CRED_PERSIST_LOCAL_MACHINE: ::DWORD = 2; pub const CRED_PERSIST_ENTERPRISE: ::DWORD = 3; STRUCT!{struct CREDENTIAL_ATTRIBUTEA { Keyword: ::LPSTR, Flags: ::DWORD, ValueSize: ::DWORD, Value: ::LPBYTE, }} pub type PCREDENTIAL_ATTRIBUTEA = *mut CREDENTIAL_ATTRIBUTEA; STRUCT!{struct CREDENTIAL_ATTRIBUTEW { Keyword: ::LPWSTR, Flags: ::DWORD, ValueSize: ::DWORD, Value: ::LPBYTE, }} pub type PCREDENTIAL_ATTRIBUTEW = *mut CREDENTIAL_ATTRIBUTEW; STRUCT!{struct CREDENTIALA { Flags: ::DWORD, Type: ::DWORD, TargetName: ::LPSTR, Comment: ::LPSTR, LastWritten: ::FILETIME, CredentialBlobSize: ::DWORD, CredentialBlob: ::LPBYTE, Persist: ::DWORD, AttributeCount: ::DWORD, Attributes: PCREDENTIAL_ATTRIBUTEA, TargetAlias: ::LPSTR, UserName: ::LPSTR, }} pub type PCREDENTIALA = *mut CREDENTIALA; STRUCT!{struct CREDENTIALW { Flags: ::DWORD, Type: ::DWORD, TargetName: ::LPWSTR, Comment: ::LPWSTR, LastWritten: ::FILETIME, CredentialBlobSize: ::DWORD, CredentialBlob: ::LPBYTE, Persist: ::DWORD, AttributeCount: ::DWORD, Attributes: PCREDENTIAL_ATTRIBUTEW, TargetAlias: ::LPWSTR, UserName: ::LPWSTR, }} pub type PCREDENTIALW = *mut CREDENTIALW; pub const CRED_TI_SERVER_FORMAT_UNKNOWN: ::ULONG = 0x0001; pub const CRED_TI_DOMAIN_FORMAT_UNKNOWN: ::ULONG = 0x0002; pub const CRED_TI_ONLY_PASSWORD_REQUIRED: ::ULONG = 0x0004; pub const CRED_TI_USERNAME_TARGET: ::ULONG = 0x0008; pub const CRED_TI_CREATE_EXPLICIT_CRED: ::ULONG = 0x0010; pub const CRED_TI_WORKGROUP_MEMBER: ::ULONG = 0x0020; pub const CRED_TI_VALID_FLAGS: ::ULONG = 0xF07F; STRUCT!{struct CREDENTIAL_TARGET_INFORMATIONA { TargetName: ::LPSTR, NetbiosServerName: ::LPSTR, DnsServerName: ::LPSTR, NetbiosDomainName: ::LPSTR, DnsDomainName: ::LPSTR, DnsTreeName: ::LPSTR, PackageName: ::LPSTR, Flags: ::ULONG, CredTypeCount: ::DWORD, CredTypes: ::LPDWORD, }} pub type PCREDENTIAL_TARGET_INFORMATIONA = *mut CREDENTIAL_TARGET_INFORMATIONA; STRUCT!{struct CREDENTIAL_TARGET_INFORMATIONW { TargetName: ::LPWSTR, NetbiosServerName: ::LPWSTR, DnsServerName: ::LPWSTR, NetbiosDomainName: ::LPWSTR, DnsDomainName: ::LPWSTR, DnsTreeName: ::LPWSTR, PackageName: ::LPWSTR, Flags: ::ULONG, CredTypeCount: ::DWORD, CredTypes: ::LPDWORD, }} pub type PCREDENTIAL_TARGET_INFORMATIONW = *mut CREDENTIAL_TARGET_INFORMATIONW; pub const CERT_HASH_LENGTH: usize = 20; STRUCT!{struct CERT_CREDENTIAL_INFO { cbSize: ::ULONG, rgbHashOfCert: [::UCHAR; CERT_HASH_LENGTH], }} pub type PCERT_CREDENTIAL_INFO = *mut CERT_CREDENTIAL_INFO; STRUCT!{struct USERNAME_TARGET_CREDENTIAL_INFO { UserName: ::LPWSTR, }} pub type PUSERNAME_TARGET_CREDENTIAL_INFO = *mut USERNAME_TARGET_CREDENTIAL_INFO; STRUCT!{struct BINARY_BLOB_CREDENTIAL_INFO { cbBlob: ::ULONG, pbBlob: ::LPBYTE, }} pub type PBINARY_BLOB_CREDENTIAL_INFO = *mut BINARY_BLOB_CREDENTIAL_INFO; ENUM!{enum CRED_MARSHAL_TYPE { CertCredential = 1, UsernameTargetCredential, BinaryBlobCredential, UsernameForPackedCredentials, }} pub type PCRED_MARSHAL_TYPE = *mut CRED_MARSHAL_TYPE; ENUM!{enum CRED_PROTECTION_TYPE { CredUnprotected, CredUserProtection, CredTrustedProtection, }} pub type PCRED_PROTECTION_TYPE = *mut CRED_PROTECTION_TYPE; pub const CRED_PACK_PROTECTED_CREDENTIALS: ::DWORD = 0x1; pub const CRED_PACK_WOW_BUFFER: ::DWORD = 0x2; pub const CRED_PACK_GENERIC_CREDENTIALS: ::DWORD = 0x4; pub const CRED_PACK_ID_PROVIDER_CREDENTIALS: ::DWORD = 0x8; STRUCT!{struct CREDUI_INFOA { cbSize: ::DWORD, hwndParent: ::HWND, pszMessageText: ::PCSTR, pszCaptionText: ::PCSTR, hbmBanner: ::HBITMAP, }} pub type PCREDUI_INFOA = *mut CREDUI_INFOA; STRUCT!{struct CREDUI_INFOW { cbSize: ::DWORD, hwndParent: ::HWND, pszMessageText: ::PCWSTR, pszCaptionText: ::PCWSTR, hbmBanner: ::HBITMAP, }} pub type PCREDUI_INFOW = *mut CREDUI_INFOW; pub const CREDUI_MAX_MESSAGE_LENGTH: ::DWORD = 1024; pub const CREDUI_MAX_CAPTION_LENGTH: ::DWORD = 128; pub const CREDUI_MAX_GENERIC_TARGET_LENGTH: ::DWORD = CRED_MAX_GENERIC_TARGET_NAME_LENGTH; pub const CREDUI_MAX_DOMAIN_TARGET_LENGTH: ::DWORD = CRED_MAX_DOMAIN_TARGET_NAME_LENGTH; pub const CREDUI_MAX_USERNAME_LENGTH: ::DWORD = CRED_MAX_USERNAME_LENGTH; pub const CREDUI_MAX_PASSWORD_LENGTH: ::DWORD = 512 / 2; pub const CREDUI_FLAGS_INCORRECT_PASSWORD: ::DWORD = 0x00001; pub const CREDUI_FLAGS_DO_NOT_PERSIST: ::DWORD = 0x00002; pub const CREDUI_FLAGS_REQUEST_ADMINISTRATOR: ::DWORD = 0x00004; pub const CREDUI_FLAGS_EXCLUDE_CERTIFICATES: ::DWORD = 0x00008; pub const CREDUI_FLAGS_REQUIRE_CERTIFICATE: ::DWORD = 0x00010; pub const CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX: ::DWORD = 0x00040; pub const CREDUI_FLAGS_ALWAYS_SHOW_UI: ::DWORD = 0x00080; pub const CREDUI_FLAGS_REQUIRE_SMARTCARD: ::DWORD = 0x00100; pub const CREDUI_FLAGS_PASSWORD_ONLY_OK: ::DWORD = 0x00200; pub const CREDUI_FLAGS_VALIDATE_USERNAME: ::DWORD = 0x00400; pub const CREDUI_FLAGS_COMPLETE_USERNAME: ::DWORD = 0x00800; pub const CREDUI_FLAGS_PERSIST: ::DWORD = 0x01000; pub const CREDUI_FLAGS_SERVER_CREDENTIAL: ::DWORD = 0x04000; pub const CREDUI_FLAGS_EXPECT_CONFIRMATION: ::DWORD = 0x20000; pub const CREDUI_FLAGS_GENERIC_CREDENTIALS: ::DWORD = 0x40000; pub const CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS: ::DWORD = 0x80000; pub const CREDUI_FLAGS_KEEP_USERNAME: ::DWORD = 0x100000; pub const CREDUI_FLAGS_PROMPT_VALID: ::DWORD = CREDUI_FLAGS_INCORRECT_PASSWORD | CREDUI_FLAGS_DO_NOT_PERSIST | CREDUI_FLAGS_REQUEST_ADMINISTRATOR | CREDUI_FLAGS_EXCLUDE_CERTIFICATES | CREDUI_FLAGS_REQUIRE_CERTIFICATE | CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX | CREDUI_FLAGS_ALWAYS_SHOW_UI | CREDUI_FLAGS_REQUIRE_SMARTCARD | CREDUI_FLAGS_PASSWORD_ONLY_OK | CREDUI_FLAGS_VALIDATE_USERNAME | CREDUI_FLAGS_COMPLETE_USERNAME | CREDUI_FLAGS_PERSIST | CREDUI_FLAGS_SERVER_CREDENTIAL | CREDUI_FLAGS_EXPECT_CONFIRMATION | CREDUI_FLAGS_GENERIC_CREDENTIALS | CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS | CREDUI_FLAGS_KEEP_USERNAME; pub const CREDUIWIN_GENERIC: ::DWORD = 0x00000001; pub const CREDUIWIN_CHECKBOX: ::DWORD = 0x00000002; pub const CREDUIWIN_AUTHPACKAGE_ONLY: ::DWORD = 0x00000010; pub const CREDUIWIN_IN_CRED_ONLY: ::DWORD = 0x00000020; pub const CREDUIWIN_ENUMERATE_ADMINS: ::DWORD = 0x00000100; pub const CREDUIWIN_ENUMERATE_CURRENT_USER: ::DWORD = 0x00000200; pub const CREDUIWIN_SECURE_PROMPT: ::DWORD = 0x00001000; pub const CREDUIWIN_PREPROMPTING: ::DWORD = 0x00002000; pub const CREDUIWIN_PACK_32_WOW: ::DWORD = 0x10000000; pub const CREDUIWIN_VALID_FLAGS: ::DWORD = CREDUIWIN_GENERIC | CREDUIWIN_CHECKBOX | CREDUIWIN_AUTHPACKAGE_ONLY | CREDUIWIN_IN_CRED_ONLY | CREDUIWIN_ENUMERATE_ADMINS | CREDUIWIN_ENUMERATE_CURRENT_USER | CREDUIWIN_SECURE_PROMPT | CREDUIWIN_PREPROMPTING | CREDUIWIN_PACK_32_WOW; pub const CRED_PRESERVE_CREDENTIAL_BLOB: ::DWORD = 0x1; pub const CRED_ENUMERATE_ALL_CREDENTIALS: ::DWORD = 0x1; pub const CRED_CACHE_TARGET_INFORMATION: ::DWORD = 0x1; pub const CRED_ALLOW_NAME_RESOLUTION: ::DWORD = 0x1; deps/winapi-0.2.5/src/olectl.rs0000644000000000000000000000115112605021352015047 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! OLE Control interfaces //299 pub const SELFREG_E_FIRST: ::HRESULT = MAKE_SCODE!(::SEVERITY_ERROR, ::FACILITY_ITF, 0x0200); pub const SELFREG_E_LAST: ::HRESULT = MAKE_SCODE!(::SEVERITY_ERROR, ::FACILITY_ITF, 0x020F); pub const SELFREG_S_FIRST: ::HRESULT = MAKE_SCODE!(::SEVERITY_SUCCESS, ::FACILITY_ITF, 0x0200); pub const SELFREG_S_LAST: ::HRESULT = MAKE_SCODE!(::SEVERITY_SUCCESS, ::FACILITY_ITF, 0x020F); pub const SELFREG_E_TYPELIB: ::HRESULT = SELFREG_E_FIRST + 0; pub const SELFREG_E_CLASS: ::HRESULT = SELFREG_E_FIRST + 1; deps/winapi-0.2.5/src/processthreadsapi.rs0000644000000000000000000000324712615662007017331 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License STRUCT!{struct PROCESS_INFORMATION { hProcess: ::HANDLE, hThread: ::HANDLE, dwProcessId: ::DWORD, dwThreadId: ::DWORD, }} pub type PPROCESS_INFORMATION = *mut PROCESS_INFORMATION; pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION; STRUCT!{struct STARTUPINFOA { cb: ::DWORD, lpReserved: ::LPSTR, lpDesktop: ::LPSTR, lpTitle: ::LPSTR, dwX: ::DWORD, dwY: ::DWORD, dwXSize: ::DWORD, dwYSize: ::DWORD, dwXCountChars: ::DWORD, dwYCountChars: ::DWORD, dwFillAttribute: ::DWORD, dwFlags: ::DWORD, wShowWindow: ::WORD, cbReserved2: ::WORD, lpReserved2: ::LPBYTE, hStdInput: ::HANDLE, hStdOutput: ::HANDLE, hStdError: ::HANDLE, }} pub type LPSTARTUPINFOA = *mut STARTUPINFOA; STRUCT!{struct STARTUPINFOW { cb: ::DWORD, lpReserved: ::LPWSTR, lpDesktop: ::LPWSTR, lpTitle: ::LPWSTR, dwX: ::DWORD, dwY: ::DWORD, dwXSize: ::DWORD, dwYSize: ::DWORD, dwXCountChars: ::DWORD, dwYCountChars: ::DWORD, dwFillAttribute: ::DWORD, dwFlags: ::DWORD, wShowWindow: ::WORD, cbReserved2: ::WORD, lpReserved2: ::LPBYTE, hStdInput: ::HANDLE, hStdOutput: ::HANDLE, hStdError: ::HANDLE, }} pub type LPSTARTUPINFOW = *mut STARTUPINFOW; STRUCT!{struct PROC_THREAD_ATTRIBUTE_LIST { dummy: *mut ::c_void, }} pub type PPROC_THREAD_ATTRIBUTE_LIST = *mut PROC_THREAD_ATTRIBUTE_LIST; pub type LPPROC_THREAD_ATTRIBUTE_LIST = *mut PROC_THREAD_ATTRIBUTE_LIST; ENUM!{enum THREAD_INFORMATION_CLASS { ThreadMemoryPriority, ThreadAbsoluteCpuPriority, ThreadInformationClassMax, }} deps/winapi-0.2.5/src/processsnapshot.rs0000644000000000000000000000433512615662007017043 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Defines the process snapshot API FLAGS!{enum PSS_CAPTURE_FLAGS { PSS_CAPTURE_NONE = 0x00000000, PSS_CAPTURE_VA_CLONE = 0x00000001, PSS_CAPTURE_RESERVED_00000002 = 0x00000002, PSS_CAPTURE_HANDLES = 0x00000004, PSS_CAPTURE_HANDLE_NAME_INFORMATION = 0x00000008, PSS_CAPTURE_HANDLE_BASIC_INFORMATION = 0x00000010, PSS_CAPTURE_HANDLE_TYPE_SPECIFIC_INFORMATION = 0x00000020, PSS_CAPTURE_HANDLE_TRACE = 0x00000040, PSS_CAPTURE_THREADS = 0x00000080, PSS_CAPTURE_THREAD_CONTEXT = 0x00000100, PSS_CAPTURE_THREAD_CONTEXT_EXTENDED = 0x00000200, PSS_CAPTURE_RESERVED_00000400 = 0x00000400, PSS_CAPTURE_VA_SPACE = 0x00000800, PSS_CAPTURE_VA_SPACE_SECTION_INFORMATION = 0x00001000, PSS_CREATE_BREAKAWAY_OPTIONAL = 0x04000000, PSS_CREATE_BREAKAWAY = 0x08000000, PSS_CREATE_FORCE_BREAKAWAY = 0x10000000, PSS_CREATE_USE_VM_ALLOCATIONS = 0x20000000, PSS_CREATE_MEASURE_PERFORMANCE = 0x40000000, PSS_CREATE_RELEASE_SECTION = -2147483648i32 as u32, }} ENUM!{enum PSS_QUERY_INFORMATION_CLASS { PSS_QUERY_PROCESS_INFORMATION = 0, PSS_QUERY_VA_CLONE_INFORMATION = 1, PSS_QUERY_AUXILIARY_PAGES_INFORMATION = 2, PSS_QUERY_VA_SPACE_INFORMATION = 3, PSS_QUERY_HANDLE_INFORMATION = 4, PSS_QUERY_THREAD_INFORMATION = 5, PSS_QUERY_HANDLE_TRACE_INFORMATION = 6, PSS_QUERY_PERFORMANCE_COUNTERS = 7, }} ENUM!{enum PSS_WALK_INFORMATION_CLASS { PSS_WALK_AUXILIARY_PAGES = 0, PSS_WALK_VA_SPACE = 1, PSS_WALK_HANDLES = 2, PSS_WALK_THREADS = 3, }} FLAGS!{enum PSS_DUPLICATE_FLAGS { PSS_DUPLICATE_NONE = 0x00, PSS_DUPLICATE_CLOSE_SOURCE = 0x01, }} DECLARE_HANDLE!(HPSS, HPSS__); DECLARE_HANDLE!(HPSSWALK, HPSSWALK__); pub type pAllocRoutine = Option *mut ::c_void>; pub type pFreeRoutine = Option; #[repr(C)] #[derive(Copy)] pub struct PSS_ALLOCATOR { pub Context: *mut ::c_void, pub AllocRoutine: pAllocRoutine, pub FreeRoutine: pFreeRoutine, } impl Clone for PSS_ALLOCATOR { fn clone(&self) -> PSS_ALLOCATOR { *self } } deps/winapi-0.2.5/src/d3d12sdklayers.rs0000644000000000000000000020363512617203501016340 0ustar rootroot// Copyright © 2015, Dmitry Roschin // Licensed under the MIT License RIDL!{interface ID3D12Debug(ID3D12DebugVtbl): IUnknown(IUnknownVtbl) { fn EnableDebugLayer(&mut self) -> () }} FLAGS!{enum D3D12_DEBUG_FEATURE { D3D12_DEBUG_FEATURE_NONE = 0, D3D12_DEBUG_FEATURE_TREAT_BUNDLE_AS_DRAW = 0x1, D3D12_DEBUG_FEATURE_TREAT_BUNDLE_AS_DISPATCH = 0x2, }} FLAGS!{enum D3D12_RLDO_FLAGS { D3D12_RLDO_NONE = 0x0, D3D12_RLDO_SUMMARY = 0x1, D3D12_RLDO_DETAIL = 0x2, D3D12_RLDO_IGNORE_INTERNAL = 0x4, }} RIDL!{interface ID3D12DebugDevice(ID3D12DebugDeviceVtbl): IUnknown(IUnknownVtbl) { fn SetFeatureMask(&mut self, Mask: ::D3D12_DEBUG_FEATURE) -> ::HRESULT, fn GetFeatureMask(&mut self) -> ::D3D12_DEBUG_FEATURE, fn ReportLiveDeviceObjects(&mut self, Flags: ::D3D12_RLDO_FLAGS) -> ::HRESULT }} DEFINE_GUID!{DXGI_DEBUG_D3D12, 0xcf59a98c, 0xa950, 0x4326, 0x91, 0xef, 0x9b, 0xba, 0xa1, 0x7b, 0xfd, 0x95} RIDL!{interface ID3D12DebugCommandQueue(ID3D12DebugCommandQueueVtbl): IUnknown(IUnknownVtbl) { fn AssertResourceState( &mut self, pResource: *mut ::ID3D12Resource, Subresource: ::UINT, State: ::UINT ) -> ::BOOL }} RIDL!{interface ID3D12DebugCommandList(ID3D12DebugCommandListVtbl): IUnknown(IUnknownVtbl) { fn AssertResourceState( &mut self, pResource: *mut ::ID3D12Resource, Subresource: ::UINT, State: ::UINT ) -> ::BOOL, fn SetFeatureMask(&mut self, Mask: ::D3D12_DEBUG_FEATURE) -> ::HRESULT, fn GetFeatureMask(&mut self) -> ::D3D12_DEBUG_FEATURE }} ENUM!{enum D3D12_MESSAGE_CATEGORY { D3D12_MESSAGE_CATEGORY_APPLICATION_DEFINED = 0, D3D12_MESSAGE_CATEGORY_MISCELLANEOUS = 1, D3D12_MESSAGE_CATEGORY_INITIALIZATION = 2, D3D12_MESSAGE_CATEGORY_CLEANUP = 3, D3D12_MESSAGE_CATEGORY_COMPILATION = 4, D3D12_MESSAGE_CATEGORY_STATE_CREATION = 5, D3D12_MESSAGE_CATEGORY_STATE_SETTING = 6, D3D12_MESSAGE_CATEGORY_STATE_GETTING = 7, D3D12_MESSAGE_CATEGORY_RESOURCE_MANIPULATION = 8, D3D12_MESSAGE_CATEGORY_EXECUTION = 9, D3D12_MESSAGE_CATEGORY_SHADER = 10, }} ENUM!{enum D3D12_MESSAGE_SEVERITY { D3D12_MESSAGE_SEVERITY_CORRUPTION = 0, D3D12_MESSAGE_SEVERITY_ERROR = 1, D3D12_MESSAGE_SEVERITY_WARNING = 2, D3D12_MESSAGE_SEVERITY_INFO = 3, D3D12_MESSAGE_SEVERITY_MESSAGE = 4, }} ENUM!{enum D3D12_MESSAGE_ID { D3D12_MESSAGE_ID_UNKNOWN = 0, D3D12_MESSAGE_ID_STRING_FROM_APPLICATION = 1, D3D12_MESSAGE_ID_CORRUPTED_THIS = 2, D3D12_MESSAGE_ID_CORRUPTED_PARAMETER1 = 3, D3D12_MESSAGE_ID_CORRUPTED_PARAMETER2 = 4, D3D12_MESSAGE_ID_CORRUPTED_PARAMETER3 = 5, D3D12_MESSAGE_ID_CORRUPTED_PARAMETER4 = 6, D3D12_MESSAGE_ID_CORRUPTED_PARAMETER5 = 7, D3D12_MESSAGE_ID_CORRUPTED_PARAMETER6 = 8, D3D12_MESSAGE_ID_CORRUPTED_PARAMETER7 = 9, D3D12_MESSAGE_ID_CORRUPTED_PARAMETER8 = 10, D3D12_MESSAGE_ID_CORRUPTED_PARAMETER9 = 11, D3D12_MESSAGE_ID_CORRUPTED_PARAMETER10 = 12, D3D12_MESSAGE_ID_CORRUPTED_PARAMETER11 = 13, D3D12_MESSAGE_ID_CORRUPTED_PARAMETER12 = 14, D3D12_MESSAGE_ID_CORRUPTED_PARAMETER13 = 15, D3D12_MESSAGE_ID_CORRUPTED_PARAMETER14 = 16, D3D12_MESSAGE_ID_CORRUPTED_PARAMETER15 = 17, D3D12_MESSAGE_ID_CORRUPTED_MULTITHREADING = 18, D3D12_MESSAGE_ID_MESSAGE_REPORTING_OUTOFMEMORY = 19, D3D12_MESSAGE_ID_GETPRIVATEDATA_MOREDATA = 20, D3D12_MESSAGE_ID_SETPRIVATEDATA_INVALIDFREEDATA = 21, D3D12_MESSAGE_ID_SETPRIVATEDATA_INVALIDIUNKNOWN = 22, D3D12_MESSAGE_ID_SETPRIVATEDATA_INVALIDFLAGS = 23, D3D12_MESSAGE_ID_SETPRIVATEDATA_CHANGINGPARAMS = 24, D3D12_MESSAGE_ID_SETPRIVATEDATA_OUTOFMEMORY = 25, D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_UNRECOGNIZEDFORMAT = 26, D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDESC = 27, D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDFORMAT = 28, D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDVIDEOPLANESLICE = 29, D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDPLANESLICE = 30, D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDIMENSIONS = 31, D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDRESOURCE = 32, D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDARG_RETURN = 33, D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_OUTOFMEMORY_RETURN = 34, D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_UNRECOGNIZEDFORMAT = 35, D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_UNSUPPORTEDFORMAT = 36, D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDESC = 37, D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDFORMAT = 38, D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDVIDEOPLANESLICE = 39, D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDPLANESLICE = 40, D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDIMENSIONS = 41, D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDRESOURCE = 42, D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDARG_RETURN = 43, D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_OUTOFMEMORY_RETURN = 44, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_UNRECOGNIZEDFORMAT = 45, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDESC = 46, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFORMAT = 47, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDIMENSIONS = 48, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDRESOURCE = 49, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDARG_RETURN = 50, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_OUTOFMEMORY_RETURN = 51, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_OUTOFMEMORY = 52, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_TOOMANYELEMENTS = 53, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDFORMAT = 54, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INCOMPATIBLEFORMAT = 55, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOT = 56, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDINPUTSLOTCLASS = 57, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_STEPRATESLOTCLASSMISMATCH = 58, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOTCLASSCHANGE = 59, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSTEPRATECHANGE = 60, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDALIGNMENT = 61, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_DUPLICATESEMANTIC = 62, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_UNPARSEABLEINPUTSIGNATURE = 63, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_NULLSEMANTIC = 64, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_MISSINGELEMENT = 65, D3D12_MESSAGE_ID_CREATEVERTEXSHADER_OUTOFMEMORY = 66, D3D12_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERBYTECODE = 67, D3D12_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERTYPE = 68, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADER_OUTOFMEMORY = 69, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERBYTECODE = 70, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERTYPE = 71, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTOFMEMORY = 72, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERBYTECODE = 73, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERTYPE = 74, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMENTRIES = 75, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSTREAMSTRIDEUNUSED = 76, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDDECL = 77, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_EXPECTEDDECL = 78, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSLOT0EXPECTED = 79, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSLOT = 80, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_ONLYONEELEMENTPERSLOT = 81, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDCOMPONENTCOUNT = 82, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTARTCOMPONENTANDCOMPONENTCOUNT = 83, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDGAPDEFINITION = 84, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_REPEATEDOUTPUT = 85, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSTREAMSTRIDE = 86, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGSEMANTIC = 87, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MASKMISMATCH = 88, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_CANTHAVEONLYGAPS = 89, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DECLTOOCOMPLEX = 90, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGOUTPUTSIGNATURE = 91, D3D12_MESSAGE_ID_CREATEPIXELSHADER_OUTOFMEMORY = 92, D3D12_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERBYTECODE = 93, D3D12_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERTYPE = 94, D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDFILLMODE = 95, D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDCULLMODE = 96, D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDDEPTHBIASCLAMP = 97, D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDSLOPESCALEDDEPTHBIAS = 98, D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_NULLDESC = 99, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHWRITEMASK = 100, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHFUNC = 101, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFAILOP = 102, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILZFAILOP = 103, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILPASSOP = 104, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFUNC = 105, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFAILOP = 106, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILZFAILOP = 107, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILPASSOP = 108, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFUNC = 109, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_NULLDESC = 110, D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLEND = 111, D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLEND = 112, D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOP = 113, D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLENDALPHA = 114, D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLENDALPHA = 115, D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOPALPHA = 116, D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDRENDERTARGETWRITEMASK = 117, D3D12_MESSAGE_ID_CREATEBLENDSTATE_NULLDESC = 118, D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDFILTER = 119, D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSU = 120, D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSV = 121, D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSW = 122, D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMIPLODBIAS = 123, D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXANISOTROPY = 124, D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDCOMPARISONFUNC = 125, D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMINLOD = 126, D3D12_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXLOD = 127, D3D12_MESSAGE_ID_CREATESAMPLERSTATE_NULLDESC = 128, D3D12_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNRECOGNIZED = 129, D3D12_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNDEFINED = 130, D3D12_MESSAGE_ID_DEVICE_RSSETVIEWPORTS_INVALIDVIEWPORT = 131, D3D12_MESSAGE_ID_DEVICE_RSSETSCISSORRECTS_INVALIDSCISSOR = 132, D3D12_MESSAGE_ID_CLEARRENDERTARGETVIEW_DENORMFLUSH = 133, D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_DENORMFLUSH = 134, D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_INVALID = 135, D3D12_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCE = 136, D3D12_MESSAGE_ID_COPYRESOURCE_INVALIDDESTINATIONSTATE = 137, D3D12_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCESTATE = 138, D3D12_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSUBRESOURCE = 139, D3D12_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONBOX = 140, D3D12_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSTATE = 141, D3D12_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_DESTINATION_INVALID = 142, D3D12_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_DESTINATION_SUBRESOURCE_INVALID = 143, D3D12_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_SOURCE_INVALID = 144, D3D12_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_SOURCE_SUBRESOURCE_INVALID = 145, D3D12_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_FORMAT_INVALID = 146, D3D12_MESSAGE_ID_BUFFER_MAP_INVALIDMAPTYPE = 147, D3D12_MESSAGE_ID_BUFFER_MAP_INVALIDFLAGS = 148, D3D12_MESSAGE_ID_BUFFER_MAP_ALREADYMAPPED = 149, D3D12_MESSAGE_ID_BUFFER_MAP_DEVICEREMOVED_RETURN = 150, D3D12_MESSAGE_ID_BUFFER_UNMAP_NOTMAPPED = 151, D3D12_MESSAGE_ID_TEXTURE1D_MAP_INVALIDMAPTYPE = 152, D3D12_MESSAGE_ID_TEXTURE1D_MAP_INVALIDSUBRESOURCE = 153, D3D12_MESSAGE_ID_TEXTURE1D_MAP_INVALIDFLAGS = 154, D3D12_MESSAGE_ID_TEXTURE1D_MAP_ALREADYMAPPED = 155, D3D12_MESSAGE_ID_TEXTURE1D_MAP_DEVICEREMOVED_RETURN = 156, D3D12_MESSAGE_ID_TEXTURE1D_UNMAP_INVALIDSUBRESOURCE = 157, D3D12_MESSAGE_ID_TEXTURE1D_UNMAP_NOTMAPPED = 158, D3D12_MESSAGE_ID_TEXTURE2D_MAP_INVALIDMAPTYPE = 159, D3D12_MESSAGE_ID_TEXTURE2D_MAP_INVALIDSUBRESOURCE = 160, D3D12_MESSAGE_ID_TEXTURE2D_MAP_INVALIDFLAGS = 161, D3D12_MESSAGE_ID_TEXTURE2D_MAP_ALREADYMAPPED = 162, D3D12_MESSAGE_ID_TEXTURE2D_MAP_DEVICEREMOVED_RETURN = 163, D3D12_MESSAGE_ID_TEXTURE2D_UNMAP_INVALIDSUBRESOURCE = 164, D3D12_MESSAGE_ID_TEXTURE2D_UNMAP_NOTMAPPED = 165, D3D12_MESSAGE_ID_TEXTURE3D_MAP_INVALIDMAPTYPE = 166, D3D12_MESSAGE_ID_TEXTURE3D_MAP_INVALIDSUBRESOURCE = 167, D3D12_MESSAGE_ID_TEXTURE3D_MAP_INVALIDFLAGS = 168, D3D12_MESSAGE_ID_TEXTURE3D_MAP_ALREADYMAPPED = 169, D3D12_MESSAGE_ID_TEXTURE3D_MAP_DEVICEREMOVED_RETURN = 170, D3D12_MESSAGE_ID_TEXTURE3D_UNMAP_INVALIDSUBRESOURCE = 171, D3D12_MESSAGE_ID_TEXTURE3D_UNMAP_NOTMAPPED = 172, D3D12_MESSAGE_ID_CHECKFORMATSUPPORT_FORMAT_DEPRECATED = 173, D3D12_MESSAGE_ID_CHECKMULTISAMPLEQUALITYLEVELS_FORMAT_DEPRECATED = 174, D3D12_MESSAGE_ID_SETEXCEPTIONMODE_UNRECOGNIZEDFLAGS = 175, D3D12_MESSAGE_ID_SETEXCEPTIONMODE_INVALIDARG_RETURN = 176, D3D12_MESSAGE_ID_SETEXCEPTIONMODE_DEVICEREMOVED_RETURN = 177, D3D12_MESSAGE_ID_REF_SIMULATING_INFINITELY_FAST_HARDWARE = 178, D3D12_MESSAGE_ID_REF_THREADING_MODE = 179, D3D12_MESSAGE_ID_REF_UMDRIVER_EXCEPTION = 180, D3D12_MESSAGE_ID_REF_KMDRIVER_EXCEPTION = 181, D3D12_MESSAGE_ID_REF_HARDWARE_EXCEPTION = 182, D3D12_MESSAGE_ID_REF_ACCESSING_INDEXABLE_TEMP_OUT_OF_RANGE = 183, D3D12_MESSAGE_ID_REF_PROBLEM_PARSING_SHADER = 184, D3D12_MESSAGE_ID_REF_OUT_OF_MEMORY = 185, D3D12_MESSAGE_ID_REF_INFO = 186, D3D12_MESSAGE_ID_DEVICE_DRAW_VERTEXPOS_OVERFLOW = 187, D3D12_MESSAGE_ID_DEVICE_DRAWINDEXED_INDEXPOS_OVERFLOW = 188, D3D12_MESSAGE_ID_DEVICE_DRAWINSTANCED_VERTEXPOS_OVERFLOW = 189, D3D12_MESSAGE_ID_DEVICE_DRAWINSTANCED_INSTANCEPOS_OVERFLOW = 190, D3D12_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INSTANCEPOS_OVERFLOW = 191, D3D12_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INDEXPOS_OVERFLOW = 192, D3D12_MESSAGE_ID_DEVICE_DRAW_VERTEX_SHADER_NOT_SET = 193, D3D12_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND = 194, D3D12_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERINDEX = 195, D3D12_MESSAGE_ID_DEVICE_SHADER_LINKAGE_COMPONENTTYPE = 196, D3D12_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERMASK = 197, D3D12_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SYSTEMVALUE = 198, D3D12_MESSAGE_ID_DEVICE_SHADER_LINKAGE_NEVERWRITTEN_ALWAYSREADS = 199, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_ROOT_SIGNATURE_NOT_SET = 200, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_ROOT_SIGNATURE_MISMATCH = 201, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_BUFFER_NOT_SET = 202, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INPUTLAYOUT_NOT_SET = 203, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_CONSTANT_BUFFER_NOT_SET = 204, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_CONSTANT_BUFFER_TOO_SMALL = 205, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_SAMPLER_NOT_SET = 206, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_SHADERRESOURCEVIEW_NOT_SET = 207, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VIEW_DIMENSION_MISMATCH = 208, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_BUFFER_STRIDE_TOO_SMALL = 209, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_BUFFER_TOO_SMALL = 210, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INDEX_BUFFER_NOT_SET = 211, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INDEX_BUFFER_FORMAT_INVALID = 212, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INDEX_BUFFER_TOO_SMALL = 213, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_GS_INPUT_PRIMITIVE_MISMATCH = 214, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_RESOURCE_RETURN_TYPE_MISMATCH = 215, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_POSITION_NOT_PRESENT = 216, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_OUTPUT_STREAM_NOT_SET = 217, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_BOUND_RESOURCE_MAPPED = 218, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INVALID_PRIMITIVETOPOLOGY = 219, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_OFFSET_UNALIGNED = 220, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_STRIDE_UNALIGNED = 221, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INDEX_OFFSET_UNALIGNED = 222, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_OUTPUT_STREAM_OFFSET_UNALIGNED = 223, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_RESOURCE_FORMAT_LD_UNSUPPORTED = 224, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_RESOURCE_FORMAT_SAMPLE_UNSUPPORTED = 225, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_RESOURCE_FORMAT_SAMPLE_C_UNSUPPORTED = 226, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_RESOURCE_MULTISAMPLE_UNSUPPORTED = 227, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_SO_TARGETS_BOUND_WITHOUT_SOURCE = 228, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_SO_STRIDE_LARGER_THAN_BUFFER = 229, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_OM_RENDER_TARGET_DOES_NOT_SUPPORT_BLENDING = 230, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_OM_DUAL_SOURCE_BLENDING_CAN_ONLY_HAVE_RENDER_TARGET_0 = 231, D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_AT_FAULT = 232, D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_POSSIBLY_AT_FAULT = 233, D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_NOT_AT_FAULT = 234, D3D12_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_INVALIDARG_RETURN = 235, D3D12_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_OUTOFMEMORY_RETURN = 236, D3D12_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_BADINTERFACE_RETURN = 237, D3D12_MESSAGE_ID_DEVICE_DRAW_VIEWPORT_NOT_SET = 238, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_TRAILING_DIGIT_IN_SEMANTIC = 239, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_TRAILING_DIGIT_IN_SEMANTIC = 240, D3D12_MESSAGE_ID_DEVICE_RSSETVIEWPORTS_DENORMFLUSH = 241, D3D12_MESSAGE_ID_OMSETRENDERTARGETS_INVALIDVIEW = 242, D3D12_MESSAGE_ID_DEVICE_SETTEXTFILTERSIZE_INVALIDDIMENSIONS = 243, D3D12_MESSAGE_ID_DEVICE_DRAW_SAMPLER_MISMATCH = 244, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_TYPE_MISMATCH = 245, D3D12_MESSAGE_ID_BLENDSTATE_GETDESC_LEGACY = 246, D3D12_MESSAGE_ID_SHADERRESOURCEVIEW_GETDESC_LEGACY = 247, D3D12_MESSAGE_ID_DEVICE_DRAW_PS_OUTPUT_TYPE_MISMATCH = 248, D3D12_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_GATHER_UNSUPPORTED = 249, D3D12_MESSAGE_ID_DEVICE_DRAW_INVALID_USE_OF_CENTER_MULTISAMPLE_PATTERN = 250, D3D12_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_STRIDE_TOO_LARGE = 251, D3D12_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_INVALIDRANGE = 252, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_EMPTY_LAYOUT = 253, D3D12_MESSAGE_ID_DEVICE_DRAW_RESOURCE_SAMPLE_COUNT_MISMATCH = 254, D3D12_MESSAGE_ID_LIVE_OBJECT_SUMMARY = 255, D3D12_MESSAGE_ID_LIVE_BUFFER = 256, D3D12_MESSAGE_ID_LIVE_TEXTURE1D = 257, D3D12_MESSAGE_ID_LIVE_TEXTURE2D = 258, D3D12_MESSAGE_ID_LIVE_TEXTURE3D = 259, D3D12_MESSAGE_ID_LIVE_SHADERRESOURCEVIEW = 260, D3D12_MESSAGE_ID_LIVE_RENDERTARGETVIEW = 261, D3D12_MESSAGE_ID_LIVE_DEPTHSTENCILVIEW = 262, D3D12_MESSAGE_ID_LIVE_VERTEXSHADER = 263, D3D12_MESSAGE_ID_LIVE_GEOMETRYSHADER = 264, D3D12_MESSAGE_ID_LIVE_PIXELSHADER = 265, D3D12_MESSAGE_ID_LIVE_INPUTLAYOUT = 266, D3D12_MESSAGE_ID_LIVE_SAMPLER = 267, D3D12_MESSAGE_ID_LIVE_BLENDSTATE = 268, D3D12_MESSAGE_ID_LIVE_DEPTHSTENCILSTATE = 269, D3D12_MESSAGE_ID_LIVE_RASTERIZERSTATE = 270, D3D12_MESSAGE_ID_LIVE_QUERY = 271, D3D12_MESSAGE_ID_LIVE_PREDICATE = 272, D3D12_MESSAGE_ID_LIVE_COUNTER = 273, D3D12_MESSAGE_ID_LIVE_DEVICE = 274, D3D12_MESSAGE_ID_LIVE_SWAPCHAIN = 275, D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFLAGS = 276, D3D12_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDCLASSLINKAGE = 277, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDCLASSLINKAGE = 278, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMSTREAMS = 279, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTREAMTORASTERIZER = 280, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDSTREAMS = 281, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDCLASSLINKAGE = 282, D3D12_MESSAGE_ID_CREATEPIXELSHADER_INVALIDCLASSLINKAGE = 283, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTREAM = 284, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDENTRIES = 285, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDSTRIDES = 286, D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMSTRIDES = 287, D3D12_MESSAGE_ID_CREATEHULLSHADER_INVALIDCALL = 288, D3D12_MESSAGE_ID_CREATEHULLSHADER_OUTOFMEMORY = 289, D3D12_MESSAGE_ID_CREATEHULLSHADER_INVALIDSHADERBYTECODE = 290, D3D12_MESSAGE_ID_CREATEHULLSHADER_INVALIDSHADERTYPE = 291, D3D12_MESSAGE_ID_CREATEHULLSHADER_INVALIDCLASSLINKAGE = 292, D3D12_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDCALL = 293, D3D12_MESSAGE_ID_CREATEDOMAINSHADER_OUTOFMEMORY = 294, D3D12_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDSHADERBYTECODE = 295, D3D12_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDSHADERTYPE = 296, D3D12_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDCLASSLINKAGE = 297, D3D12_MESSAGE_ID_DEVICE_DRAW_HS_XOR_DS_MISMATCH = 298, D3D12_MESSAGE_ID_DEVICE_DRAWINDIRECT_INVALID_ARG_BUFFER = 299, D3D12_MESSAGE_ID_DEVICE_DRAWINDIRECT_OFFSET_UNALIGNED = 300, D3D12_MESSAGE_ID_DEVICE_DRAWINDIRECT_OFFSET_OVERFLOW = 301, D3D12_MESSAGE_ID_RESOURCE_MAP_INVALIDMAPTYPE = 302, D3D12_MESSAGE_ID_RESOURCE_MAP_INVALIDSUBRESOURCE = 303, D3D12_MESSAGE_ID_RESOURCE_MAP_INVALIDFLAGS = 304, D3D12_MESSAGE_ID_RESOURCE_MAP_ALREADYMAPPED = 305, D3D12_MESSAGE_ID_RESOURCE_MAP_DEVICEREMOVED_RETURN = 306, D3D12_MESSAGE_ID_RESOURCE_MAP_OUTOFMEMORY_RETURN = 307, D3D12_MESSAGE_ID_RESOURCE_MAP_WITHOUT_INITIAL_DISCARD = 308, D3D12_MESSAGE_ID_RESOURCE_UNMAP_INVALIDSUBRESOURCE = 309, D3D12_MESSAGE_ID_RESOURCE_UNMAP_NOTMAPPED = 310, D3D12_MESSAGE_ID_DEVICE_DRAW_RASTERIZING_CONTROL_POINTS = 311, D3D12_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNSUPPORTED = 312, D3D12_MESSAGE_ID_DEVICE_DRAW_HS_DS_SIGNATURE_MISMATCH = 313, D3D12_MESSAGE_ID_DEVICE_DRAW_HULL_SHADER_INPUT_TOPOLOGY_MISMATCH = 314, D3D12_MESSAGE_ID_DEVICE_DRAW_HS_DS_CONTROL_POINT_COUNT_MISMATCH = 315, D3D12_MESSAGE_ID_DEVICE_DRAW_HS_DS_TESSELLATOR_DOMAIN_MISMATCH = 316, D3D12_MESSAGE_ID_DEVICE_CHECKFEATURESUPPORT_UNRECOGNIZED_FEATURE = 317, D3D12_MESSAGE_ID_DEVICE_CHECKFEATURESUPPORT_MISMATCHED_DATA_SIZE = 318, D3D12_MESSAGE_ID_DEVICE_CHECKFEATURESUPPORT_INVALIDARG_RETURN = 319, D3D12_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDCALL = 320, D3D12_MESSAGE_ID_CREATECOMPUTESHADER_OUTOFMEMORY = 321, D3D12_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDSHADERBYTECODE = 322, D3D12_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDCLASSLINKAGE = 323, D3D12_MESSAGE_ID_DEVICE_CSSETSHADERRESOURCES_VIEWS_EMPTY = 324, D3D12_MESSAGE_ID_CSSETCONSTANTBUFFERS_INVALIDBUFFER = 325, D3D12_MESSAGE_ID_DEVICE_CSSETCONSTANTBUFFERS_BUFFERS_EMPTY = 326, D3D12_MESSAGE_ID_DEVICE_CSSETSAMPLERS_SAMPLERS_EMPTY = 327, D3D12_MESSAGE_ID_DEVICE_CSGETSHADERRESOURCES_VIEWS_EMPTY = 328, D3D12_MESSAGE_ID_DEVICE_CSGETCONSTANTBUFFERS_BUFFERS_EMPTY = 329, D3D12_MESSAGE_ID_DEVICE_CSGETSAMPLERS_SAMPLERS_EMPTY = 330, D3D12_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_DOUBLEFLOATOPSNOTSUPPORTED = 331, D3D12_MESSAGE_ID_DEVICE_CREATEHULLSHADER_DOUBLEFLOATOPSNOTSUPPORTED = 332, D3D12_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_DOUBLEFLOATOPSNOTSUPPORTED = 333, D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_DOUBLEFLOATOPSNOTSUPPORTED = 334, D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DOUBLEFLOATOPSNOTSUPPORTED = 335, D3D12_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_DOUBLEFLOATOPSNOTSUPPORTED = 336, D3D12_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_DOUBLEFLOATOPSNOTSUPPORTED = 337, D3D12_MESSAGE_ID_CREATEBUFFER_INVALIDSTRUCTURESTRIDE = 338, D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDFLAGS = 339, D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDRESOURCE = 340, D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDDESC = 341, D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDFORMAT = 342, D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDVIDEOPLANESLICE = 343, D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDPLANESLICE = 344, D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDDIMENSIONS = 345, D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_UNRECOGNIZEDFORMAT = 346, D3D12_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_OVERLAPPING_OLD_SLOTS = 347, D3D12_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_NO_OP = 348, D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDARG_RETURN = 349, D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_OUTOFMEMORY_RETURN = 350, D3D12_MESSAGE_ID_CLEARUNORDEREDACCESSVIEW_DENORMFLUSH = 351, D3D12_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSS_VIEWS_EMPTY = 352, D3D12_MESSAGE_ID_DEVICE_CSGETUNORDEREDACCESSS_VIEWS_EMPTY = 353, D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDFLAGS = 354, D3D12_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_INVALID_ARG_BUFFER = 355, D3D12_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_OFFSET_UNALIGNED = 356, D3D12_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_OFFSET_OVERFLOW = 357, D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_DEPTH_READONLY = 358, D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_STENCIL_READONLY = 359, D3D12_MESSAGE_ID_CHECKFEATURESUPPORT_FORMAT_DEPRECATED = 360, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_RETURN_TYPE_MISMATCH = 361, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_NOT_SET = 362, D3D12_MESSAGE_ID_DEVICE_DRAW_UNORDEREDACCESSVIEW_RENDERTARGETVIEW_OVERLAP = 363, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_DIMENSION_MISMATCH = 364, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_APPEND_UNSUPPORTED = 365, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMICS_UNSUPPORTED = 366, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_STRUCTURE_STRIDE_MISMATCH = 367, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_BUFFER_TYPE_MISMATCH = 368, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_RAW_UNSUPPORTED = 369, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_FORMAT_LD_UNSUPPORTED = 370, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_FORMAT_STORE_UNSUPPORTED = 371, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_ADD_UNSUPPORTED = 372, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_BITWISE_OPS_UNSUPPORTED = 373, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_CMPSTORE_CMPEXCHANGE_UNSUPPORTED = 374, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_EXCHANGE_UNSUPPORTED = 375, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_SIGNED_MINMAX_UNSUPPORTED = 376, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_UNSIGNED_MINMAX_UNSUPPORTED = 377, D3D12_MESSAGE_ID_DEVICE_DISPATCH_BOUND_RESOURCE_MAPPED = 378, D3D12_MESSAGE_ID_DEVICE_DISPATCH_THREADGROUPCOUNT_OVERFLOW = 379, D3D12_MESSAGE_ID_DEVICE_DISPATCH_THREADGROUPCOUNT_ZERO = 380, D3D12_MESSAGE_ID_DEVICE_SHADERRESOURCEVIEW_STRUCTURE_STRIDE_MISMATCH = 381, D3D12_MESSAGE_ID_DEVICE_SHADERRESOURCEVIEW_BUFFER_TYPE_MISMATCH = 382, D3D12_MESSAGE_ID_DEVICE_SHADERRESOURCEVIEW_RAW_UNSUPPORTED = 383, D3D12_MESSAGE_ID_DEVICE_DISPATCH_UNSUPPORTED = 384, D3D12_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_UNSUPPORTED = 385, D3D12_MESSAGE_ID_COPYSTRUCTURECOUNT_INVALIDOFFSET = 386, D3D12_MESSAGE_ID_COPYSTRUCTURECOUNT_LARGEOFFSET = 387, D3D12_MESSAGE_ID_COPYSTRUCTURECOUNT_INVALIDDESTINATIONSTATE = 388, D3D12_MESSAGE_ID_COPYSTRUCTURECOUNT_INVALIDSOURCESTATE = 389, D3D12_MESSAGE_ID_CHECKFORMATSUPPORT_FORMAT_NOT_SUPPORTED = 390, D3D12_MESSAGE_ID_CLEARUNORDEREDACCESSVIEWFLOAT_INVALIDFORMAT = 391, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_COUNTER_UNSUPPORTED = 392, D3D12_MESSAGE_ID_DEVICE_DRAW_PIXEL_SHADER_WITHOUT_RTV_OR_DSV = 393, D3D12_MESSAGE_ID_SHADER_ABORT = 394, D3D12_MESSAGE_ID_SHADER_MESSAGE = 395, D3D12_MESSAGE_ID_SHADER_ERROR = 396, D3D12_MESSAGE_ID_OFFERRESOURCES_INVALIDRESOURCE = 397, D3D12_MESSAGE_ID_ENQUEUESETEVENT_INVALIDARG_RETURN = 398, D3D12_MESSAGE_ID_ENQUEUESETEVENT_OUTOFMEMORY_RETURN = 399, D3D12_MESSAGE_ID_ENQUEUESETEVENT_ACCESSDENIED_RETURN = 400, D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDFORCEDSAMPLECOUNT = 401, D3D12_MESSAGE_ID_DEVICE_DRAW_INVALID_USE_OF_FORCED_SAMPLE_COUNT = 402, D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDLOGICOPS = 403, D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDARRAYWITHDECODER = 404, D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDDARRAYWITHDECODER = 405, D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDARRAYWITHDECODER = 406, D3D12_MESSAGE_ID_DEVICE_LOCKEDOUT_INTERFACE = 407, D3D12_MESSAGE_ID_OFFERRESOURCES_INVALIDPRIORITY = 408, D3D12_MESSAGE_ID_DEVICE_CLEARVIEW_INVALIDVIEW = 409, D3D12_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 410, D3D12_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_SHADEREXTENSIONSNOTSUPPORTED = 411, D3D12_MESSAGE_ID_DEVICE_CREATEHULLSHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 412, D3D12_MESSAGE_ID_DEVICE_CREATEHULLSHADER_SHADEREXTENSIONSNOTSUPPORTED = 413, D3D12_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 414, D3D12_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_SHADEREXTENSIONSNOTSUPPORTED = 415, D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 416, D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_SHADEREXTENSIONSNOTSUPPORTED = 417, D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DOUBLEEXTENSIONSNOTSUPPORTED = 418, D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_SHADEREXTENSIONSNOTSUPPORTED = 419, D3D12_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 420, D3D12_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_SHADEREXTENSIONSNOTSUPPORTED = 421, D3D12_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 422, D3D12_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_SHADEREXTENSIONSNOTSUPPORTED = 423, D3D12_MESSAGE_ID_DEVICE_SHADER_LINKAGE_MINPRECISION = 424, D3D12_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_UAVSNOTSUPPORTED = 425, D3D12_MESSAGE_ID_DEVICE_CREATEHULLSHADER_UAVSNOTSUPPORTED = 426, D3D12_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_UAVSNOTSUPPORTED = 427, D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_UAVSNOTSUPPORTED = 428, D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UAVSNOTSUPPORTED = 429, D3D12_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_UAVSNOTSUPPORTED = 430, D3D12_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_UAVSNOTSUPPORTED = 431, D3D12_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_INVALIDOFFSET = 432, D3D12_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_TOOMANYVIEWS = 433, D3D12_MESSAGE_ID_DEVICE_CLEARVIEW_NOTSUPPORTED = 434, D3D12_MESSAGE_ID_SWAPDEVICECONTEXTSTATE_NOTSUPPORTED = 435, D3D12_MESSAGE_ID_UPDATESUBRESOURCE_PREFERUPDATESUBRESOURCE1 = 436, D3D12_MESSAGE_ID_GETDC_INACCESSIBLE = 437, D3D12_MESSAGE_ID_DEVICE_CLEARVIEW_INVALIDRECT = 438, D3D12_MESSAGE_ID_DEVICE_DRAW_SAMPLE_MASK_IGNORED_ON_FL9 = 439, D3D12_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE1_NOT_SUPPORTED = 440, D3D12_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_BY_NAME_NOT_SUPPORTED = 441, D3D12_MESSAGE_ID_ENQUEUESETEVENT_NOT_SUPPORTED = 442, D3D12_MESSAGE_ID_OFFERRELEASE_NOT_SUPPORTED = 443, D3D12_MESSAGE_ID_OFFERRESOURCES_INACCESSIBLE = 444, D3D12_MESSAGE_ID_CREATEVIDEOPROCESSORINPUTVIEW_INVALIDMSAA = 445, D3D12_MESSAGE_ID_CREATEVIDEOPROCESSOROUTPUTVIEW_INVALIDMSAA = 446, D3D12_MESSAGE_ID_DEVICE_CLEARVIEW_INVALIDSOURCERECT = 447, D3D12_MESSAGE_ID_DEVICE_CLEARVIEW_EMPTYRECT = 448, D3D12_MESSAGE_ID_UPDATESUBRESOURCE_EMPTYDESTBOX = 449, D3D12_MESSAGE_ID_COPYSUBRESOURCEREGION_EMPTYSOURCEBOX = 450, D3D12_MESSAGE_ID_DEVICE_DRAW_OM_RENDER_TARGET_DOES_NOT_SUPPORT_LOGIC_OPS = 451, D3D12_MESSAGE_ID_DEVICE_DRAW_DEPTHSTENCILVIEW_NOT_SET = 452, D3D12_MESSAGE_ID_DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET = 453, D3D12_MESSAGE_ID_DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET_DUE_TO_FLIP_PRESENT = 454, D3D12_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_NOT_SET_DUE_TO_FLIP_PRESENT = 455, D3D12_MESSAGE_ID_GETDATAFORNEWHARDWAREKEY_NULLPARAM = 456, D3D12_MESSAGE_ID_CHECKCRYPTOSESSIONSTATUS_NULLPARAM = 457, D3D12_MESSAGE_ID_SETEVENTONHARDWARECONTENTPROTECTIONTILT_NULLPARAM = 458, D3D12_MESSAGE_ID_GETVIDEODECODERCAPS_NULLPARAM = 459, D3D12_MESSAGE_ID_GETVIDEODECODERCAPS_ZEROWIDTHHEIGHT = 460, D3D12_MESSAGE_ID_CHECKVIDEODECODERDOWNSAMPLING_NULLPARAM = 461, D3D12_MESSAGE_ID_CHECKVIDEODECODERDOWNSAMPLING_INVALIDCOLORSPACE = 462, D3D12_MESSAGE_ID_CHECKVIDEODECODERDOWNSAMPLING_ZEROWIDTHHEIGHT = 463, D3D12_MESSAGE_ID_VIDEODECODERENABLEDOWNSAMPLING_NULLPARAM = 464, D3D12_MESSAGE_ID_VIDEODECODERENABLEDOWNSAMPLING_UNSUPPORTED = 465, D3D12_MESSAGE_ID_VIDEODECODERUPDATEDOWNSAMPLING_NULLPARAM = 466, D3D12_MESSAGE_ID_VIDEODECODERUPDATEDOWNSAMPLING_UNSUPPORTED = 467, D3D12_MESSAGE_ID_CHECKVIDEOPROCESSORFORMATCONVERSION_NULLPARAM = 468, D3D12_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTCOLORSPACE1_NULLPARAM = 469, D3D12_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTCOLORSPACE1_NULLPARAM = 470, D3D12_MESSAGE_ID_VIDEOPROCESSORSETSTREAMCOLORSPACE1_NULLPARAM = 471, D3D12_MESSAGE_ID_VIDEOPROCESSORSETSTREAMCOLORSPACE1_INVALIDSTREAM = 472, D3D12_MESSAGE_ID_VIDEOPROCESSORSETSTREAMMIRROR_NULLPARAM = 473, D3D12_MESSAGE_ID_VIDEOPROCESSORSETSTREAMMIRROR_INVALIDSTREAM = 474, D3D12_MESSAGE_ID_VIDEOPROCESSORSETSTREAMMIRROR_UNSUPPORTED = 475, D3D12_MESSAGE_ID_VIDEOPROCESSORGETSTREAMCOLORSPACE1_NULLPARAM = 476, D3D12_MESSAGE_ID_VIDEOPROCESSORGETSTREAMMIRROR_NULLPARAM = 477, D3D12_MESSAGE_ID_RECOMMENDVIDEODECODERDOWNSAMPLING_NULLPARAM = 478, D3D12_MESSAGE_ID_RECOMMENDVIDEODECODERDOWNSAMPLING_INVALIDCOLORSPACE = 479, D3D12_MESSAGE_ID_RECOMMENDVIDEODECODERDOWNSAMPLING_ZEROWIDTHHEIGHT = 480, D3D12_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTSHADERUSAGE_NULLPARAM = 481, D3D12_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTSHADERUSAGE_NULLPARAM = 482, D3D12_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_NULLPARAM = 483, D3D12_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDSTREAMCOUNT = 484, D3D12_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_TARGETRECT = 485, D3D12_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDSOURCERECT = 486, D3D12_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDDESTRECT = 487, D3D12_MESSAGE_ID_CREATEBUFFER_INVALIDUSAGE = 488, D3D12_MESSAGE_ID_CREATETEXTURE1D_INVALIDUSAGE = 489, D3D12_MESSAGE_ID_CREATETEXTURE2D_INVALIDUSAGE = 490, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_LEVEL9_STEPRATE_NOT_1 = 491, D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_LEVEL9_INSTANCING_NOT_SUPPORTED = 492, D3D12_MESSAGE_ID_UPDATETILEMAPPINGS_INVALID_PARAMETER = 493, D3D12_MESSAGE_ID_COPYTILEMAPPINGS_INVALID_PARAMETER = 494, D3D12_MESSAGE_ID_COPYTILES_INVALID_PARAMETER = 495, D3D12_MESSAGE_ID_NULL_TILE_MAPPING_ACCESS_WARNING = 496, D3D12_MESSAGE_ID_NULL_TILE_MAPPING_ACCESS_ERROR = 497, D3D12_MESSAGE_ID_DIRTY_TILE_MAPPING_ACCESS = 498, D3D12_MESSAGE_ID_DUPLICATE_TILE_MAPPINGS_IN_COVERED_AREA = 499, D3D12_MESSAGE_ID_TILE_MAPPINGS_IN_COVERED_AREA_DUPLICATED_OUTSIDE = 500, D3D12_MESSAGE_ID_TILE_MAPPINGS_SHARED_BETWEEN_INCOMPATIBLE_RESOURCES = 501, D3D12_MESSAGE_ID_TILE_MAPPINGS_SHARED_BETWEEN_INPUT_AND_OUTPUT = 502, D3D12_MESSAGE_ID_CHECKMULTISAMPLEQUALITYLEVELS_INVALIDFLAGS = 503, D3D12_MESSAGE_ID_GETRESOURCETILING_NONTILED_RESOURCE = 504, D3D12_MESSAGE_ID_NEED_TO_CALL_TILEDRESOURCEBARRIER = 505, D3D12_MESSAGE_ID_CREATEDEVICE_INVALIDARGS = 506, D3D12_MESSAGE_ID_CREATEDEVICE_WARNING = 507, D3D12_MESSAGE_ID_TILED_RESOURCE_TIER_1_BUFFER_TEXTURE_MISMATCH = 508, D3D12_MESSAGE_ID_CREATE_CRYPTOSESSION = 509, D3D12_MESSAGE_ID_CREATE_AUTHENTICATEDCHANNEL = 510, D3D12_MESSAGE_ID_LIVE_CRYPTOSESSION = 511, D3D12_MESSAGE_ID_LIVE_AUTHENTICATEDCHANNEL = 512, D3D12_MESSAGE_ID_DESTROY_CRYPTOSESSION = 513, D3D12_MESSAGE_ID_DESTROY_AUTHENTICATEDCHANNEL = 514, D3D12_MESSAGE_ID_MAP_INVALID_SUBRESOURCE = 515, D3D12_MESSAGE_ID_MAP_INVALID_TYPE = 516, D3D12_MESSAGE_ID_MAP_UNSUPPORTED_TYPE = 517, D3D12_MESSAGE_ID_UNMAP_INVALID_SUBRESOURCE = 518, D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_TYPE = 519, D3D12_MESSAGE_ID_RESOURCE_BARRIER_NULL_POINTER = 520, D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_SUBRESOURCE = 521, D3D12_MESSAGE_ID_RESOURCE_BARRIER_RESERVED_BITS = 522, D3D12_MESSAGE_ID_RESOURCE_BARRIER_MISSING_BIND_FLAGS = 523, D3D12_MESSAGE_ID_RESOURCE_BARRIER_MISMATCHING_MISC_FLAGS = 524, D3D12_MESSAGE_ID_RESOURCE_BARRIER_MATCHING_STATES = 525, D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_COMBINATION = 526, D3D12_MESSAGE_ID_RESOURCE_BARRIER_BEFORE_AFTER_MISMATCH = 527, D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_RESOURCE = 528, D3D12_MESSAGE_ID_RESOURCE_BARRIER_SAMPLE_COUNT = 529, D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_FLAGS = 530, D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_COMBINED_FLAGS = 531, D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_FLAGS_FOR_FORMAT = 532, D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_SPLIT_BARRIER = 533, D3D12_MESSAGE_ID_RESOURCE_BARRIER_UNMATCHED_END = 534, D3D12_MESSAGE_ID_RESOURCE_BARRIER_UNMATCHED_BEGIN = 535, D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_FLAG = 536, D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_COMMAND_LIST_TYPE = 537, D3D12_MESSAGE_ID_INVALID_SUBRESOURCE_STATE = 538, D3D12_MESSAGE_ID_INEFFICIENT_PRESENT = 539, D3D12_MESSAGE_ID_COMMAND_ALLOCATOR_CONTENTION = 540, D3D12_MESSAGE_ID_COMMAND_ALLOCATOR_RESET = 541, D3D12_MESSAGE_ID_COMMAND_ALLOCATOR_RESET_BUNDLE = 542, D3D12_MESSAGE_ID_COMMAND_ALLOCATOR_CANNOT_RESET = 543, D3D12_MESSAGE_ID_COMMAND_LIST_OPEN = 544, D3D12_MESSAGE_ID_QUERY_STATE_MISMATCH = 545, D3D12_MESSAGE_ID_INVALID_BUNDLE_API = 546, D3D12_MESSAGE_ID_COMMAND_LIST_CLOSED = 547, D3D12_MESSAGE_ID_COMMAND_LIST_CLOSED_WITH_INVALID_RESOURCE = 548, D3D12_MESSAGE_ID_WRONG_COMMAND_ALLOCATOR_TYPE = 549, D3D12_MESSAGE_ID_INVALID_INDIRECT_ARGUMENT_BUFFER = 550, D3D12_MESSAGE_ID_COMPUTE_AND_GRAPHICS_PIPELINE = 551, D3D12_MESSAGE_ID_COMMAND_ALLOCATOR_SYNC = 552, D3D12_MESSAGE_ID_COMMAND_LIST_SYNC = 553, D3D12_MESSAGE_ID_SET_DESCRIPTOR_HEAP_INVALID = 554, D3D12_MESSAGE_ID_CREATE_QUEUE_IMAGE_NOT_SUPPORTED = 555, D3D12_MESSAGE_ID_CREATE_COMMAND_ALLOCATOR_IMAGE_NOT_SUPPORTED = 556, D3D12_MESSAGE_ID_CREATE_COMMANDQUEUE = 557, D3D12_MESSAGE_ID_CREATE_COMMANDALLOCATOR = 558, D3D12_MESSAGE_ID_CREATE_PIPELINESTATE = 559, D3D12_MESSAGE_ID_CREATE_COMMANDLIST12 = 560, D3D12_MESSAGE_ID_CREATE_IMAGECOMMANDLIST = 561, D3D12_MESSAGE_ID_CREATE_RESOURCE = 562, D3D12_MESSAGE_ID_CREATE_DESCRIPTORHEAP = 563, D3D12_MESSAGE_ID_CREATE_ROOTSIGNATURE = 564, D3D12_MESSAGE_ID_CREATE_LIBRARY = 565, D3D12_MESSAGE_ID_CREATE_HEAP = 566, D3D12_MESSAGE_ID_CREATE_MONITOREDFENCE = 567, D3D12_MESSAGE_ID_CREATE_QUERYHEAP = 568, D3D12_MESSAGE_ID_CREATE_COMMANDSIGNATURE = 569, D3D12_MESSAGE_ID_LIVE_COMMANDQUEUE = 570, D3D12_MESSAGE_ID_LIVE_COMMANDALLOCATOR = 571, D3D12_MESSAGE_ID_LIVE_PIPELINESTATE = 572, D3D12_MESSAGE_ID_LIVE_COMMANDLIST12 = 573, D3D12_MESSAGE_ID_LIVE_IMAGECOMMANDLIST = 574, D3D12_MESSAGE_ID_LIVE_RESOURCE = 575, D3D12_MESSAGE_ID_LIVE_DESCRIPTORHEAP = 576, D3D12_MESSAGE_ID_LIVE_ROOTSIGNATURE = 577, D3D12_MESSAGE_ID_LIVE_LIBRARY = 578, D3D12_MESSAGE_ID_LIVE_HEAP = 579, D3D12_MESSAGE_ID_LIVE_MONITOREDFENCE = 580, D3D12_MESSAGE_ID_LIVE_QUERYHEAP = 581, D3D12_MESSAGE_ID_LIVE_COMMANDSIGNATURE = 582, D3D12_MESSAGE_ID_DESTROY_COMMANDQUEUE = 583, D3D12_MESSAGE_ID_DESTROY_COMMANDALLOCATOR = 584, D3D12_MESSAGE_ID_DESTROY_PIPELINESTATE = 585, D3D12_MESSAGE_ID_DESTROY_COMMANDLIST12 = 586, D3D12_MESSAGE_ID_DESTROY_IMAGECOMMANDLIST = 587, D3D12_MESSAGE_ID_DESTROY_RESOURCE = 588, D3D12_MESSAGE_ID_DESTROY_DESCRIPTORHEAP = 589, D3D12_MESSAGE_ID_DESTROY_ROOTSIGNATURE = 590, D3D12_MESSAGE_ID_DESTROY_LIBRARY = 591, D3D12_MESSAGE_ID_DESTROY_HEAP = 592, D3D12_MESSAGE_ID_DESTROY_MONITOREDFENCE = 593, D3D12_MESSAGE_ID_DESTROY_QUERYHEAP = 594, D3D12_MESSAGE_ID_DESTROY_COMMANDSIGNATURE = 595, D3D12_MESSAGE_ID_CREATERESOURCE_UNRECOGNIZEDHEAPTYPE = 596, D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDDIMENSIONS = 597, D3D12_MESSAGE_ID_CREATERESOURCE_UNRECOGNIZEDMISCFLAGS = 598, D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDMISCFLAGS = 599, D3D12_MESSAGE_ID_CREATERESOURCE_LARGEALLOCATION = 600, D3D12_MESSAGE_ID_CREATERESOURCE_SMALLALLOCATION = 601, D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDARG_RETURN = 602, D3D12_MESSAGE_ID_CREATERESOURCE_OUTOFMEMORY_RETURN = 603, D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDDESC = 604, D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDINITIALSTATE = 605, D3D12_MESSAGE_ID_RESOURCE_HAS_PENDING_INITIAL_DATA = 606, D3D12_MESSAGE_ID_POSSIBLY_INVALID_SUBRESOURCE_STATE = 607, D3D12_MESSAGE_ID_INVALID_USE_OF_NON_RESIDENT_RESOURCE = 608, D3D12_MESSAGE_ID_POSSIBLE_INVALID_USE_OF_NON_RESIDENT_RESOURCE = 609, D3D12_MESSAGE_ID_BUNDLE_PIPELINE_STATE_MISMATCH = 610, D3D12_MESSAGE_ID_PRIMITIVE_TOPOLOGY_MISMATCH_PIPELINE_STATE = 611, D3D12_MESSAGE_ID_RENDER_TARGET_NUMBER_MISMATCH_PIPELINE_STATE = 612, D3D12_MESSAGE_ID_RENDER_TARGET_FORMAT_MISMATCH_PIPELINE_STATE = 613, D3D12_MESSAGE_ID_RENDER_TARGET_SAMPLE_DESC_MISMATCH_PIPELINE_STATE = 614, D3D12_MESSAGE_ID_DEPTH_STENCIL_FORMAT_MISMATCH_PIPELINE_STATE = 615, D3D12_MESSAGE_ID_DEPTH_STENCIL_SAMPLE_DESC_MISMATCH_PIPELINE_STATE = 616, D3D12_MESSAGE_ID_RENDER_TARGET_NUMBER_MISMATCH_BUNDLE_PIPELINE_STATE = 617, D3D12_MESSAGE_ID_RENDER_TARGET_FORMAT_MISMATCH_BUNDLE_PIPELINE_STATE = 618, D3D12_MESSAGE_ID_RENDER_TARGET_SAMPLE_DESC_MISMATCH_BUNDLE_PIPELINE_STATE = 619, D3D12_MESSAGE_ID_DEPTH_STENCIL_FORMAT_MISMATCH_BUNDLE_PIPELINE_STATE = 620, D3D12_MESSAGE_ID_DEPTH_STENCIL_SAMPLE_DESC_MISMATCH_BUNDLE_PIPELINE_STATE = 621, D3D12_MESSAGE_ID_CREATESHADER_INVALIDBYTECODE = 622, D3D12_MESSAGE_ID_CREATEHEAP_NULLDESC = 623, D3D12_MESSAGE_ID_CREATEHEAP_INVALIDSIZE = 624, D3D12_MESSAGE_ID_CREATEHEAP_UNRECOGNIZEDHEAPTYPE = 625, D3D12_MESSAGE_ID_CREATEHEAP_UNRECOGNIZEDCPUPAGEPROPERTIES = 626, D3D12_MESSAGE_ID_CREATEHEAP_UNRECOGNIZEDMEMORYPOOL = 627, D3D12_MESSAGE_ID_CREATEHEAP_INVALIDPROPERTIES = 628, D3D12_MESSAGE_ID_CREATEHEAP_INVALIDALIGNMENT = 629, D3D12_MESSAGE_ID_CREATEHEAP_UNRECOGNIZEDMISCFLAGS = 630, D3D12_MESSAGE_ID_CREATEHEAP_INVALIDMISCFLAGS = 631, D3D12_MESSAGE_ID_CREATEHEAP_INVALIDARG_RETURN = 632, D3D12_MESSAGE_ID_CREATEHEAP_OUTOFMEMORY_RETURN = 633, D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_NULLHEAPPROPERTIES = 634, D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_UNRECOGNIZEDHEAPTYPE = 635, D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_UNRECOGNIZEDCPUPAGEPROPERTIES = 636, D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_UNRECOGNIZEDMEMORYPOOL = 637, D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_INVALIDHEAPPROPERTIES = 638, D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_UNRECOGNIZEDHEAPMISCFLAGS = 639, D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_INVALIDHEAPMISCFLAGS = 640, D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_INVALIDARG_RETURN = 641, D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_OUTOFMEMORY_RETURN = 642, D3D12_MESSAGE_ID_GETCUSTOMHEAPPROPERTIES_UNRECOGNIZEDHEAPTYPE = 643, D3D12_MESSAGE_ID_GETCUSTOMHEAPPROPERTIES_INVALIDHEAPTYPE = 644, D3D12_MESSAGE_ID_CREATE_DESCRIPTOR_HEAP_INVALID_DESC = 645, D3D12_MESSAGE_ID_INVALID_DESCRIPTOR_HANDLE = 646, D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALID_CONSERVATIVERASTERMODE = 647, D3D12_MESSAGE_ID_DEVICE_DRAW_INVALID_SYSTEMVALUE = 648, D3D12_MESSAGE_ID_CREATE_CONSTANT_BUFFER_VIEW_INVALID_RESOURCE = 649, D3D12_MESSAGE_ID_CREATE_CONSTANT_BUFFER_VIEW_INVALID_DESC = 650, D3D12_MESSAGE_ID_CREATE_CONSTANT_BUFFER_VIEW_LARGE_OFFSET = 651, D3D12_MESSAGE_ID_CREATE_UNORDEREDACCESS_VIEW_INVALID_COUNTER_USAGE = 652, D3D12_MESSAGE_ID_COPY_DESCRIPTORS_INVALID_RANGES = 653, D3D12_MESSAGE_ID_COPY_DESCRIPTORS_WRITE_ONLY_DESCRIPTOR = 654, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_RTV_FORMAT_NOT_UNKNOWN = 655, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_RENDER_TARGET_COUNT = 656, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_VERTEX_SHADER_NOT_SET = 657, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INPUTLAYOUT_NOT_SET = 658, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_HS_DS_SIGNATURE_MISMATCH = 659, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_REGISTERINDEX = 660, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_COMPONENTTYPE = 661, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_REGISTERMASK = 662, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_SYSTEMVALUE = 663, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_NEVERWRITTEN_ALWAYSREADS = 664, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_MINPRECISION = 665, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND = 666, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_HS_XOR_DS_MISMATCH = 667, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_HULL_SHADER_INPUT_TOPOLOGY_MISMATCH = 668, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_HS_DS_CONTROL_POINT_COUNT_MISMATCH = 669, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_HS_DS_TESSELLATOR_DOMAIN_MISMATCH = 670, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_USE_OF_CENTER_MULTISAMPLE_PATTERN = 671, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_USE_OF_FORCED_SAMPLE_COUNT = 672, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_PRIMITIVETOPOLOGY = 673, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_SYSTEMVALUE = 674, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_OM_DUAL_SOURCE_BLENDING_CAN_ONLY_HAVE_RENDER_TARGET_0 = 675, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_OM_RENDER_TARGET_DOES_NOT_SUPPORT_BLENDING = 676, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_PS_OUTPUT_TYPE_MISMATCH = 677, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_OM_RENDER_TARGET_DOES_NOT_SUPPORT_LOGIC_OPS = 678, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_RENDERTARGETVIEW_NOT_SET = 679, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_DEPTHSTENCILVIEW_NOT_SET = 680, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_GS_INPUT_PRIMITIVE_MISMATCH = 681, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_POSITION_NOT_PRESENT = 682, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_MISSING_ROOT_SIGNATURE_FLAGS = 683, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_INDEX_BUFFER_PROPERTIES = 684, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_SAMPLE_DESC = 685, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_HS_ROOT_SIGNATURE_MISMATCH = 686, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_DS_ROOT_SIGNATURE_MISMATCH = 687, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_VS_ROOT_SIGNATURE_MISMATCH = 688, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_GS_ROOT_SIGNATURE_MISMATCH = 689, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_PS_ROOT_SIGNATURE_MISMATCH = 690, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_MISSING_ROOT_SIGNATURE = 691, D3D12_MESSAGE_ID_EXECUTE_BUNDLE_OPEN_BUNDLE = 692, D3D12_MESSAGE_ID_EXECUTE_BUNDLE_DESCRIPTOR_HEAP_MISMATCH = 693, D3D12_MESSAGE_ID_EXECUTE_BUNDLE_TYPE = 694, D3D12_MESSAGE_ID_DRAW_EMPTY_SCISSOR_RECTANGLE = 695, D3D12_MESSAGE_ID_CREATE_ROOT_SIGNATURE_BLOB_NOT_FOUND = 696, D3D12_MESSAGE_ID_CREATE_ROOT_SIGNATURE_DESERIALIZE_FAILED = 697, D3D12_MESSAGE_ID_CREATE_ROOT_SIGNATURE_INVALID_CONFIGURATION = 698, D3D12_MESSAGE_ID_CREATE_ROOT_SIGNATURE_NOT_SUPPORTED_ON_DEVICE = 699, D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_NULLRESOURCEPROPERTIES = 700, D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_NULLHEAP = 701, D3D12_MESSAGE_ID_GETRESOURCEALLOCATIONINFO_INVALIDRDESCS = 702, D3D12_MESSAGE_ID_MAKERESIDENT_NULLOBJECTARRAY = 703, D3D12_MESSAGE_ID_MAKERESIDENT_INVALIDOBJECT = 704, D3D12_MESSAGE_ID_EVICT_NULLOBJECTARRAY = 705, D3D12_MESSAGE_ID_EVICT_INVALIDOBJECT = 706, D3D12_MESSAGE_ID_HEAPS_UNSUPPORTED = 707, D3D12_MESSAGE_ID_SET_DESCRIPTOR_TABLE_INVALID = 708, D3D12_MESSAGE_ID_SET_ROOT_CONSTANT_INVALID = 709, D3D12_MESSAGE_ID_SET_ROOT_CONSTANT_BUFFER_VIEW_INVALID = 710, D3D12_MESSAGE_ID_SET_ROOT_SHADER_RESOURCE_VIEW_INVALID = 711, D3D12_MESSAGE_ID_SET_ROOT_UNORDERED_ACCESS_VIEW_INVALID = 712, D3D12_MESSAGE_ID_SET_VERTEX_BUFFERS_INVALID_DESC = 713, D3D12_MESSAGE_ID_SET_VERTEX_BUFFERS_LARGE_OFFSET = 714, D3D12_MESSAGE_ID_SET_INDEX_BUFFER_INVALID_DESC = 715, D3D12_MESSAGE_ID_SET_INDEX_BUFFER_LARGE_OFFSET = 716, D3D12_MESSAGE_ID_SET_STREAM_OUTPUT_BUFFERS_INVALID_DESC = 717, D3D12_MESSAGE_ID_CREATERESOURCE_UNRECOGNIZEDDIMENSIONALITY = 718, D3D12_MESSAGE_ID_CREATERESOURCE_UNRECOGNIZEDLAYOUT = 719, D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDDIMENSIONALITY = 720, D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDALIGNMENT = 721, D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDMIPLEVELS = 722, D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDSAMPLEDESC = 723, D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDLAYOUT = 724, D3D12_MESSAGE_ID_SET_INDEX_BUFFER_INVALID = 725, D3D12_MESSAGE_ID_SET_VERTEX_BUFFERS_INVALID = 726, D3D12_MESSAGE_ID_SET_STREAM_OUTPUT_BUFFERS_INVALID = 727, D3D12_MESSAGE_ID_SET_RENDER_TARGETS_INVALID = 728, D3D12_MESSAGE_ID_CREATEQUERY_HEAP_INVALID_PARAMETERS = 729, D3D12_MESSAGE_ID_CREATEQUERY_HEAP_JPEG_NOT_SUPPORTED = 730, D3D12_MESSAGE_ID_BEGIN_END_QUERY_INVALID_PARAMETERS = 731, D3D12_MESSAGE_ID_CLOSE_COMMAND_LIST_OPEN_QUERY = 732, D3D12_MESSAGE_ID_RESOLVE_QUERY_DATA_INVALID_PARAMETERS = 733, D3D12_MESSAGE_ID_SET_PREDICATION_INVALID_PARAMETERS = 734, D3D12_MESSAGE_ID_TIMESTAMPS_NOT_SUPPORTED = 735, D3D12_MESSAGE_ID_UNSTABLE_POWER_STATE = 736, D3D12_MESSAGE_ID_CREATERESOURCE_UNRECOGNIZEDFORMAT = 737, D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDFORMAT = 738, D3D12_MESSAGE_ID_GETCOPYABLELAYOUT_INVALIDSUBRESOURCERANGE = 739, D3D12_MESSAGE_ID_GETCOPYABLELAYOUT_INVALIDBASEOFFSET = 740, D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_HEAP = 741, D3D12_MESSAGE_ID_CREATE_SAMPLER_INVALID = 742, D3D12_MESSAGE_ID_CREATECOMMANDSIGNATURE_INVALID = 743, D3D12_MESSAGE_ID_EXECUTE_INDIRECT_INVALID_PARAMETERS = 744, D3D12_MESSAGE_ID_GETGPUVIRTUALADDRESS_INVALID_RESOURCE_DIMENSION = 745, D3D12_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDCONTEXTTYPE = 746, D3D12_MESSAGE_ID_CREATEQUERYORPREDICATE_DECODENOTSUPPORTED = 747, D3D12_MESSAGE_ID_CREATEQUERYORPREDICATE_ENCODENOTSUPPORTED = 748, D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDPLANEINDEX = 749, D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDVIDEOPLANEINDEX = 750, D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_AMBIGUOUSVIDEOPLANEINDEX = 751, D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDPLANEINDEX = 752, D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDVIDEOPLANEINDEX = 753, D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_AMBIGUOUSVIDEOPLANEINDEX = 754, D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDPLANEINDEX = 755, D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDVIDEOPLANEINDEX = 756, D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_AMBIGUOUSVIDEOPLANEINDEX = 757, D3D12_MESSAGE_ID_JPEGDECODE_INVALIDSCANDATAOFFSET = 758, D3D12_MESSAGE_ID_JPEGDECODE_NOTSUPPORTED = 759, D3D12_MESSAGE_ID_JPEGDECODE_DIMENSIONSTOOLARGE = 760, D3D12_MESSAGE_ID_JPEGDECODE_INVALIDCOMPONENTS = 761, D3D12_MESSAGE_ID_JPEGDECODE_UNSUPPORTEDCOMPONENTS = 762, D3D12_MESSAGE_ID_JPEGDECODE_DESTINATIONNOT2D = 763, D3D12_MESSAGE_ID_JPEGDECODE_TILEDRESOURCESUNSUPPORTED = 764, D3D12_MESSAGE_ID_JPEGDECODE_GUARDRECTSUNSUPPORTED = 765, D3D12_MESSAGE_ID_JPEGDECODE_FORMATUNSUPPORTED = 766, D3D12_MESSAGE_ID_JPEGDECODE_INVALIDSUBRESOURCE = 767, D3D12_MESSAGE_ID_JPEGDECODE_INVALIDMIPLEVEL = 768, D3D12_MESSAGE_ID_JPEGDECODE_EMPTYDESTBOX = 769, D3D12_MESSAGE_ID_JPEGDECODE_DESTBOXNOT2D = 770, D3D12_MESSAGE_ID_JPEGDECODE_DESTBOXNOTSUB = 771, D3D12_MESSAGE_ID_JPEGDECODE_DESTBOXESINTERSECT = 772, D3D12_MESSAGE_ID_JPEGDECODE_XSUBSAMPLEMISMATCH = 773, D3D12_MESSAGE_ID_JPEGDECODE_YSUBSAMPLEMISMATCH = 774, D3D12_MESSAGE_ID_JPEGDECODE_XSUBSAMPLEODD = 775, D3D12_MESSAGE_ID_JPEGDECODE_YSUBSAMPLEODD = 776, D3D12_MESSAGE_ID_JPEGDECODE_UPSCALEUNSUPPORTED = 777, D3D12_MESSAGE_ID_JPEGDECODE_TIER4DOWNSCALETOLARGE = 778, D3D12_MESSAGE_ID_JPEGDECODE_TIER3DOWNSCALEUNSUPPORTED = 779, D3D12_MESSAGE_ID_JPEGDECODE_CHROMASIZEMISMATCH = 780, D3D12_MESSAGE_ID_JPEGDECODE_LUMACHROMASIZEMISMATCH = 781, D3D12_MESSAGE_ID_JPEGDECODE_INVALIDNUMDESTINATIONS = 782, D3D12_MESSAGE_ID_JPEGDECODE_SUBBOXUNSUPPORTED = 783, D3D12_MESSAGE_ID_JPEGDECODE_1DESTUNSUPPORTEDFORMAT = 784, D3D12_MESSAGE_ID_JPEGDECODE_3DESTUNSUPPORTEDFORMAT = 785, D3D12_MESSAGE_ID_JPEGDECODE_SCALEUNSUPPORTED = 786, D3D12_MESSAGE_ID_JPEGDECODE_INVALIDSOURCESIZE = 787, D3D12_MESSAGE_ID_JPEGDECODE_INVALIDCOPYFLAGS = 788, D3D12_MESSAGE_ID_JPEGDECODE_HAZARD = 789, D3D12_MESSAGE_ID_JPEGDECODE_UNSUPPORTEDSRCBUFFERUSAGE = 790, D3D12_MESSAGE_ID_JPEGDECODE_UNSUPPORTEDSRCBUFFERMISCFLAGS = 791, D3D12_MESSAGE_ID_JPEGDECODE_UNSUPPORTEDDSTTEXTUREUSAGE = 792, D3D12_MESSAGE_ID_JPEGDECODE_BACKBUFFERNOTSUPPORTED = 793, D3D12_MESSAGE_ID_JPEGDECODE_UNSUPPRTEDCOPYFLAGS = 794, D3D12_MESSAGE_ID_JPEGENCODE_NOTSUPPORTED = 795, D3D12_MESSAGE_ID_JPEGENCODE_INVALIDSCANDATAOFFSET = 796, D3D12_MESSAGE_ID_JPEGENCODE_INVALIDCOMPONENTS = 797, D3D12_MESSAGE_ID_JPEGENCODE_SOURCENOT2D = 798, D3D12_MESSAGE_ID_JPEGENCODE_TILEDRESOURCESUNSUPPORTED = 799, D3D12_MESSAGE_ID_JPEGENCODE_GUARDRECTSUNSUPPORTED = 800, D3D12_MESSAGE_ID_JPEGENCODE_XSUBSAMPLEMISMATCH = 801, D3D12_MESSAGE_ID_JPEGENCODE_YSUBSAMPLEMISMATCH = 802, D3D12_MESSAGE_ID_JPEGENCODE_UNSUPPORTEDCOMPONENTS = 803, D3D12_MESSAGE_ID_JPEGENCODE_FORMATUNSUPPORTED = 804, D3D12_MESSAGE_ID_JPEGENCODE_INVALIDSUBRESOURCE = 805, D3D12_MESSAGE_ID_JPEGENCODE_INVALIDMIPLEVEL = 806, D3D12_MESSAGE_ID_JPEGENCODE_DIMENSIONSTOOLARGE = 807, D3D12_MESSAGE_ID_JPEGENCODE_HAZARD = 808, D3D12_MESSAGE_ID_JPEGENCODE_UNSUPPORTEDDSTBUFFERUSAGE = 809, D3D12_MESSAGE_ID_JPEGENCODE_UNSUPPORTEDDSTBUFFERMISCFLAGS = 810, D3D12_MESSAGE_ID_JPEGENCODE_UNSUPPORTEDSRCTEXTUREUSAGE = 811, D3D12_MESSAGE_ID_JPEGENCODE_BACKBUFFERNOTSUPPORTED = 812, D3D12_MESSAGE_ID_CREATEQUERYORPREDICATE_UNSUPPORTEDCONTEXTTTYPEFORQUERY = 813, D3D12_MESSAGE_ID_FLUSH1_INVALIDCONTEXTTYPE = 814, D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDCLEARVALUE = 815, D3D12_MESSAGE_ID_CREATERESOURCE_UNRECOGNIZEDCLEARVALUEFORMAT = 816, D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDCLEARVALUEFORMAT = 817, D3D12_MESSAGE_ID_CREATERESOURCE_CLEARVALUEDENORMFLUSH = 818, D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_INVALIDDEPTH = 819, D3D12_MESSAGE_ID_CLEARRENDERTARGETVIEW_MISMATCHINGCLEARVALUE = 820, D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_MISMATCHINGCLEARVALUE = 821, D3D12_MESSAGE_ID_MAP_INVALIDHEAP = 822, D3D12_MESSAGE_ID_UNMAP_INVALIDHEAP = 823, D3D12_MESSAGE_ID_MAP_INVALIDRESOURCE = 824, D3D12_MESSAGE_ID_UNMAP_INVALIDRESOURCE = 825, D3D12_MESSAGE_ID_MAP_INVALIDSUBRESOURCE = 826, D3D12_MESSAGE_ID_UNMAP_INVALIDSUBRESOURCE = 827, D3D12_MESSAGE_ID_MAP_INVALIDRANGE = 828, D3D12_MESSAGE_ID_UNMAP_INVALIDRANGE = 829, D3D12_MESSAGE_ID_MAP_NULLRANGE = 830, D3D12_MESSAGE_ID_UNMAP_NULLRANGE = 831, D3D12_MESSAGE_ID_MAP_INVALIDDATAPOINTER = 832, D3D12_MESSAGE_ID_MAP_INVALIDARG_RETURN = 833, D3D12_MESSAGE_ID_MAP_OUTOFMEMORY_RETURN = 834, D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_BUNDLENOTSUPPORTED = 835, D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_COMMANDLISTMISMATCH = 836, D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_OPENCOMMANDLIST = 837, D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_FAILEDCOMMANDLIST = 838, D3D12_MESSAGE_ID_COPYBUFFERREGION_NULLDST = 839, D3D12_MESSAGE_ID_COPYBUFFERREGION_INVALIDDSTRESOURCEDIMENSION = 840, D3D12_MESSAGE_ID_COPYBUFFERREGION_DSTRANGEOUTOFBOUNDS = 841, D3D12_MESSAGE_ID_COPYBUFFERREGION_NULLSRC = 842, D3D12_MESSAGE_ID_COPYBUFFERREGION_INVALIDSRCRESOURCEDIMENSION = 843, D3D12_MESSAGE_ID_COPYBUFFERREGION_SRCRANGEOUTOFBOUNDS = 844, D3D12_MESSAGE_ID_COPYBUFFERREGION_INVALIDCOPYFLAGS = 845, D3D12_MESSAGE_ID_COPYTEXTUREREGION_NULLDST = 846, D3D12_MESSAGE_ID_COPYTEXTUREREGION_UNRECOGNIZEDDSTTYPE = 847, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTRESOURCEDIMENSION = 848, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTRESOURCE = 849, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTSUBRESOURCE = 850, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTOFFSET = 851, D3D12_MESSAGE_ID_COPYTEXTUREREGION_UNRECOGNIZEDDSTFORMAT = 852, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTFORMAT = 853, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTDIMENSIONS = 854, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTROWPITCH = 855, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTPLACEMENT = 856, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTDSPLACEDFOOTPRINTFORMAT = 857, D3D12_MESSAGE_ID_COPYTEXTUREREGION_DSTREGIONOUTOFBOUNDS = 858, D3D12_MESSAGE_ID_COPYTEXTUREREGION_NULLSRC = 859, D3D12_MESSAGE_ID_COPYTEXTUREREGION_UNRECOGNIZEDSRCTYPE = 860, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCRESOURCEDIMENSION = 861, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCRESOURCE = 862, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCSUBRESOURCE = 863, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCOFFSET = 864, D3D12_MESSAGE_ID_COPYTEXTUREREGION_UNRECOGNIZEDSRCFORMAT = 865, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCFORMAT = 866, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCDIMENSIONS = 867, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCROWPITCH = 868, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCPLACEMENT = 869, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCDSPLACEDFOOTPRINTFORMAT = 870, D3D12_MESSAGE_ID_COPYTEXTUREREGION_SRCREGIONOUTOFBOUNDS = 871, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTCOORDINATES = 872, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCBOX = 873, D3D12_MESSAGE_ID_COPYTEXTUREREGION_FORMATMISMATCH = 874, D3D12_MESSAGE_ID_COPYTEXTUREREGION_EMPTYBOX = 875, D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDCOPYFLAGS = 876, D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_INVALID_SUBRESOURCE_INDEX = 877, D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_INVALID_FORMAT = 878, D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_RESOURCE_MISMATCH = 879, D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_INVALID_SAMPLE_COUNT = 880, D3D12_MESSAGE_ID_CREATECOMPUTEPIPELINESTATE_INVALID_SHADER = 881, D3D12_MESSAGE_ID_CREATECOMPUTEPIPELINESTATE_CS_ROOT_SIGNATURE_MISMATCH = 882, D3D12_MESSAGE_ID_CREATECOMPUTEPIPELINESTATE_MISSING_ROOT_SIGNATURE = 883, D3D12_MESSAGE_ID_CREATEPIPELINESTATE_INVALIDCACHEDBLOB = 884, D3D12_MESSAGE_ID_CREATEPIPELINESTATE_CACHEDBLOBADAPTERMISMATCH = 885, D3D12_MESSAGE_ID_CREATEPIPELINESTATE_CACHEDBLOBDRIVERVERSIONMISMATCH = 886, D3D12_MESSAGE_ID_CREATEPIPELINESTATE_CACHEDBLOBDESCMISMATCH = 887, D3D12_MESSAGE_ID_CREATEPIPELINESTATE_CACHEDBLOBIGNORED = 888, D3D12_MESSAGE_ID_WRITETOSUBRESOURCE_INVALIDHEAP = 889, D3D12_MESSAGE_ID_WRITETOSUBRESOURCE_INVALIDRESOURCE = 890, D3D12_MESSAGE_ID_WRITETOSUBRESOURCE_INVALIDBOX = 891, D3D12_MESSAGE_ID_WRITETOSUBRESOURCE_INVALIDSUBRESOURCE = 892, D3D12_MESSAGE_ID_WRITETOSUBRESOURCE_EMPTYBOX = 893, D3D12_MESSAGE_ID_READFROMSUBRESOURCE_INVALIDHEAP = 894, D3D12_MESSAGE_ID_READFROMSUBRESOURCE_INVALIDRESOURCE = 895, D3D12_MESSAGE_ID_READFROMSUBRESOURCE_INVALIDBOX = 896, D3D12_MESSAGE_ID_READFROMSUBRESOURCE_INVALIDSUBRESOURCE = 897, D3D12_MESSAGE_ID_READFROMSUBRESOURCE_EMPTYBOX = 898, D3D12_MESSAGE_ID_TOO_MANY_NODES_SPECIFIED = 899, D3D12_MESSAGE_ID_INVALID_NODE_INDEX = 900, D3D12_MESSAGE_ID_GETHEAPPROPERTIES_INVALIDRESOURCE = 901, D3D12_MESSAGE_ID_NODE_MASK_MISMATCH = 902, D3D12_MESSAGE_ID_COMMAND_LIST_OUTOFMEMORY = 903, D3D12_MESSAGE_ID_COMMAND_LIST_MULTIPLE_SWAPCHAIN_BUFFER_REFERENCES = 904, D3D12_MESSAGE_ID_COMMAND_LIST_TOO_MANY_SWAPCHAIN_REFERENCES = 905, D3D12_MESSAGE_ID_COMMAND_QUEUE_TOO_MANY_SWAPCHAIN_REFERENCES = 906, D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_WRONGSWAPCHAINBUFFERREFERENCE = 907, D3D12_MESSAGE_ID_COMMAND_LIST_SETRENDERTARGETS_INVALIDNUMRENDERTARGETS = 908, D3D12_MESSAGE_ID_CREATE_QUEUE_INVALID_TYPE = 909, D3D12_MESSAGE_ID_CREATE_QUEUE_INVALID_FLAGS = 910, D3D12_MESSAGE_ID_CREATESHAREDRESOURCE_INVALIDFLAGS = 911, D3D12_MESSAGE_ID_CREATESHAREDRESOURCE_INVALIDFORMAT = 912, D3D12_MESSAGE_ID_CREATESHAREDHEAP_INVALIDFLAGS = 913, D3D12_MESSAGE_ID_REFLECTSHAREDPROPERTIES_UNRECOGNIZEDPROPERTIES = 914, D3D12_MESSAGE_ID_REFLECTSHAREDPROPERTIES_INVALIDSIZE = 915, D3D12_MESSAGE_ID_REFLECTSHAREDPROPERTIES_INVALIDOBJECT = 916, D3D12_MESSAGE_ID_KEYEDMUTEX_INVALIDOBJECT = 917, D3D12_MESSAGE_ID_KEYEDMUTEX_INVALIDKEY = 918, D3D12_MESSAGE_ID_KEYEDMUTEX_WRONGSTATE = 919, D3D12_MESSAGE_ID_CREATE_QUEUE_INVALID_PRIORITY = 920, D3D12_MESSAGE_ID_OBJECT_DELETED_WHILE_STILL_IN_USE = 921, D3D12_MESSAGE_ID_CREATEPIPELINESTATE_INVALID_FLAGS = 922, D3D12_MESSAGE_ID_HEAP_ADDRESS_RANGE_HAS_NO_RESOURCE = 923, D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_RENDER_TARGET_DELETED = 924, D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_ALL_RENDER_TARGETS_HAVE_UNKNOWN_FORMAT = 925, D3D12_MESSAGE_ID_HEAP_ADDRESS_RANGE_INTERSECTS_MULTIPLE_BUFFERS = 926, D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_GPU_WRITTEN_READBACK_RESOURCE_MAPPED = 927, D3D12_MESSAGE_ID_UNMAP_RANGE_NOT_NEEDED = 928, D3D12_MESSAGE_ID_UNMAP_RANGE_NOT_EMPTY = 929, D3D12_MESSAGE_ID_MAP_INVALID_NULLRANGE = 930, D3D12_MESSAGE_ID_UNMAP_INVALID_NULLRANGE = 931, D3D12_MESSAGE_ID_NO_GRAPHICS_API_SUPPORT = 932, D3D12_MESSAGE_ID_NO_COMPUTE_API_SUPPORT = 933, D3D12_MESSAGE_ID_D3D12_MESSAGES_END = 934, }} STRUCT!{struct D3D12_MESSAGE { Category: D3D12_MESSAGE_CATEGORY, Severity: D3D12_MESSAGE_SEVERITY, ID: D3D12_MESSAGE_ID, pDescription: *const ::c_char, DescriptionByteLength: ::SIZE_T, }} STRUCT!{struct D3D12_INFO_QUEUE_FILTER_DESC { NumCategories: ::UINT, pCategoryList: *mut D3D12_MESSAGE_CATEGORY, NumSeverities: ::UINT, pSeverityList: *mut D3D12_MESSAGE_SEVERITY, NumIDs: ::UINT, pIDList: *mut D3D12_MESSAGE_ID, }} STRUCT!{struct D3D12_INFO_QUEUE_FILTER { AllowList: D3D12_INFO_QUEUE_FILTER_DESC, DenyList: D3D12_INFO_QUEUE_FILTER_DESC, }} pub const D3D12_INFO_QUEUE_DEFAULT_MESSAGE_COUNT_LIMIT: ::UINT = 1024; RIDL!{interface ID3D12InfoQueue(ID3D12InfoQueueVtbl): IUnknown(IUnknownVtbl) { fn SetMessageCountLimit(&mut self, MessageCountLimit: ::UINT64) -> ::HRESULT, fn ClearStoredMessages(&mut self) -> (), fn GetMessage( &mut self, MessageIndex: ::UINT64, pMessage: *mut ::D3D12_MESSAGE, pMessageByteLength: *mut ::SIZE_T ) -> ::HRESULT, fn GetNumMessagesAllowedByStorageFilter(&mut self) -> ::UINT64, fn GetNumMessagesDeniedByStorageFilter(&mut self) -> ::UINT64, fn GetNumStoredMessages(&mut self) -> ::UINT64, fn GetNumStoredMessagesAllowedByRetrievalFilter(&mut self) -> ::UINT64, fn GetNumMessagesDiscardedByMessageCountLimit(&mut self) -> ::UINT64, fn GetMessageCountLimit(&mut self) -> ::UINT64, fn AddStorageFilterEntries(&mut self, pFilter: *mut ::D3D12_INFO_QUEUE_FILTER) -> ::HRESULT, fn GetStorageFilter( &mut self, pFilter: *mut ::D3D12_INFO_QUEUE_FILTER, pFilterByteLength: *mut ::SIZE_T ) -> ::HRESULT, fn ClearStorageFilter(&mut self) -> (), fn PushEmptyStorageFilter(&mut self) -> ::HRESULT, fn PushCopyOfStorageFilter(&mut self) -> ::HRESULT, fn PushStorageFilter(&mut self, pFilter: *mut ::D3D12_INFO_QUEUE_FILTER) -> ::HRESULT, fn PopStorageFilter(&mut self) -> (), fn GetStorageFilterStackSize(&mut self) -> ::UINT, fn AddRetrievalFilterEntries(&mut self, pFilter: *mut ::D3D12_INFO_QUEUE_FILTER) -> ::HRESULT, fn GetRetrievalFilter( &mut self, pFilter: *mut ::D3D12_INFO_QUEUE_FILTER, pFilterByteLength: *mut ::SIZE_T ) -> ::HRESULT, fn ClearRetrievalFilter(&mut self) -> (), fn PushEmptyRetrievalFilter(&mut self) -> ::HRESULT, fn PushCopyOfRetrievalFilter(&mut self) -> ::HRESULT, fn PushRetrievalFilter(&mut self, pFilter: *mut ::D3D12_INFO_QUEUE_FILTER) -> ::HRESULT, fn PopRetrievalFilter(&mut self) -> (), fn GetRetrievalFilterStackSize(&mut self) -> ::UINT, fn AddMessage( &mut self, Category: ::D3D12_MESSAGE_CATEGORY, Severity: ::D3D12_MESSAGE_SEVERITY, ID: ::D3D12_MESSAGE_ID, pDescription: ::LPCSTR ) -> ::HRESULT, fn AddApplicationMessage( &mut self, Severity: ::D3D12_MESSAGE_SEVERITY, pDescription: ::LPCSTR ) -> ::HRESULT, fn SetBreakOnCategory( &mut self, Category: ::D3D12_MESSAGE_CATEGORY, bEnable: ::BOOL ) -> ::HRESULT, fn SetBreakOnSeverity( &mut self, Severity: ::D3D12_MESSAGE_SEVERITY, bEnable: ::BOOL ) -> ::HRESULT, fn SetBreakOnID(&mut self, ID: ::D3D12_MESSAGE_ID, bEnable: ::BOOL) -> ::HRESULT, fn GetBreakOnCategory(&mut self, Category: ::D3D12_MESSAGE_CATEGORY) -> ::BOOL, fn GetBreakOnSeverity(&mut self, Severity: ::D3D12_MESSAGE_SEVERITY) -> ::BOOL, fn GetBreakOnID(&mut self, ID: ::D3D12_MESSAGE_ID) -> ::BOOL, fn SetMuteDebugOutput(&mut self, bMute: ::BOOL) -> (), fn GetMuteDebugOutput(&mut self) -> ::BOOL }} DEFINE_GUID!{IID_ID3D12Debug, 0x344488b7, 0x6846, 0x474b, 0xb9, 0x89, 0xf0, 0x27, 0x44, 0x82, 0x45, 0xe0} DEFINE_GUID!{IID_ID3D12DebugDevice, 0x3febd6dd, 0x4973, 0x4787, 0x81, 0x94, 0xe4, 0x5f, 0x9e, 0x28, 0x92, 0x3e} DEFINE_GUID!{IID_ID3D12DebugCommandQueue, 0x09e0bf36, 0x54ac, 0x484f, 0x88, 0x47, 0x4b, 0xae, 0xea, 0xb6, 0x05, 0x3a} DEFINE_GUID!{IID_ID3D12DebugCommandList, 0x09e0bf36, 0x54ac, 0x484f, 0x88, 0x47, 0x4b, 0xae, 0xea, 0xb6, 0x05, 0x3f} DEFINE_GUID!{IID_ID3D12InfoQueue, 0x0742a90b, 0xc387, 0x483f, 0xb9, 0x46, 0x30, 0xa7, 0xe4, 0xe6, 0x14, 0x58} deps/winapi-0.2.5/src/d3dcommon.rs0000644000000000000000000011447112617171733015476 0ustar rootroot// Copyright © 2015; Connor Hilarides // Licensed under the MIT License //! Mappings for the contents of d3dcommon.h ENUM!{enum D3D_DRIVER_TYPE { D3D_DRIVER_TYPE_UNKNOWN, D3D_DRIVER_TYPE_HARDWARE, D3D_DRIVER_TYPE_REFERENCE, D3D_DRIVER_TYPE_NULL, D3D_DRIVER_TYPE_SOFTWARE, D3D_DRIVER_TYPE_WARP, }} ENUM!{enum D3D_FEATURE_LEVEL { D3D_FEATURE_LEVEL_9_1 = 0x9100, D3D_FEATURE_LEVEL_9_2 = 0x9200, D3D_FEATURE_LEVEL_9_3 = 0x9300, D3D_FEATURE_LEVEL_10_0 = 0xa000, D3D_FEATURE_LEVEL_10_1 = 0xa100, D3D_FEATURE_LEVEL_11_0 = 0xb000, D3D_FEATURE_LEVEL_11_1 = 0xb100, }} ENUM!{enum D3D_PRIMITIVE_TOPOLOGY { D3D_PRIMITIVE_TOPOLOGY_UNDEFINED = 0, D3D_PRIMITIVE_TOPOLOGY_POINTLIST = 1, D3D_PRIMITIVE_TOPOLOGY_LINELIST = 2, D3D_PRIMITIVE_TOPOLOGY_LINESTRIP = 3, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST = 4, D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP = 5, D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ = 10, D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ = 11, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ = 12, D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ = 13, D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST = 33, D3D_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST = 34, D3D_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST = 35, D3D_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST = 36, D3D_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST = 37, D3D_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST = 38, D3D_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST = 39, D3D_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST = 40, D3D_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST = 41, D3D_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST = 42, D3D_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST = 43, D3D_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST = 44, D3D_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST = 45, D3D_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST = 46, D3D_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST = 47, D3D_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST = 48, D3D_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST = 49, D3D_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST = 50, D3D_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST = 51, D3D_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST = 52, D3D_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST = 53, D3D_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST = 54, D3D_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST = 55, D3D_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST = 56, D3D_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST = 57, D3D_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST = 58, D3D_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST = 59, D3D_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST = 60, D3D_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST = 61, D3D_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST = 62, D3D_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST = 63, D3D_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST = 64, }} pub const D3D10_PRIMITIVE_TOPOLOGY_UNDEFINED: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; pub const D3D10_PRIMITIVE_TOPOLOGY_POINTLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_POINTLIST; pub const D3D10_PRIMITIVE_TOPOLOGY_LINELIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_LINELIST; pub const D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; pub const D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; pub const D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; pub const D3D10_PRIMITIVE_TOPOLOGY_LINELIST_ADJ: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ; pub const D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ; pub const D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ; pub const D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ; pub const D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; pub const D3D11_PRIMITIVE_TOPOLOGY_POINTLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_POINTLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_LINELIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_LINELIST; pub const D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; pub const D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; pub const D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; pub const D3D11_PRIMITIVE_TOPOLOGY_LINELIST_ADJ: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ; pub const D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ; pub const D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ; pub const D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ; pub const D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST; pub const D3D11_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST: ::D3D_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST; ENUM!{enum D3D_PRIMITIVE { D3D_PRIMITIVE_UNDEFINED = 0, D3D_PRIMITIVE_POINT = 1, D3D_PRIMITIVE_LINE = 2, D3D_PRIMITIVE_TRIANGLE = 3, D3D_PRIMITIVE_LINE_ADJ = 6, D3D_PRIMITIVE_TRIANGLE_ADJ = 7, D3D_PRIMITIVE_1_CONTROL_POINT_PATCH = 8, D3D_PRIMITIVE_2_CONTROL_POINT_PATCH = 9, D3D_PRIMITIVE_3_CONTROL_POINT_PATCH = 10, D3D_PRIMITIVE_4_CONTROL_POINT_PATCH = 11, D3D_PRIMITIVE_5_CONTROL_POINT_PATCH = 12, D3D_PRIMITIVE_6_CONTROL_POINT_PATCH = 13, D3D_PRIMITIVE_7_CONTROL_POINT_PATCH = 14, D3D_PRIMITIVE_8_CONTROL_POINT_PATCH = 15, D3D_PRIMITIVE_9_CONTROL_POINT_PATCH = 16, D3D_PRIMITIVE_10_CONTROL_POINT_PATCH = 17, D3D_PRIMITIVE_11_CONTROL_POINT_PATCH = 18, D3D_PRIMITIVE_12_CONTROL_POINT_PATCH = 19, D3D_PRIMITIVE_13_CONTROL_POINT_PATCH = 20, D3D_PRIMITIVE_14_CONTROL_POINT_PATCH = 21, D3D_PRIMITIVE_15_CONTROL_POINT_PATCH = 22, D3D_PRIMITIVE_16_CONTROL_POINT_PATCH = 23, D3D_PRIMITIVE_17_CONTROL_POINT_PATCH = 24, D3D_PRIMITIVE_18_CONTROL_POINT_PATCH = 25, D3D_PRIMITIVE_19_CONTROL_POINT_PATCH = 26, D3D_PRIMITIVE_20_CONTROL_POINT_PATCH = 28, D3D_PRIMITIVE_21_CONTROL_POINT_PATCH = 29, D3D_PRIMITIVE_22_CONTROL_POINT_PATCH = 30, D3D_PRIMITIVE_23_CONTROL_POINT_PATCH = 31, D3D_PRIMITIVE_24_CONTROL_POINT_PATCH = 32, D3D_PRIMITIVE_25_CONTROL_POINT_PATCH = 33, D3D_PRIMITIVE_26_CONTROL_POINT_PATCH = 34, D3D_PRIMITIVE_27_CONTROL_POINT_PATCH = 35, D3D_PRIMITIVE_28_CONTROL_POINT_PATCH = 36, D3D_PRIMITIVE_29_CONTROL_POINT_PATCH = 37, D3D_PRIMITIVE_30_CONTROL_POINT_PATCH = 38, D3D_PRIMITIVE_31_CONTROL_POINT_PATCH = 39, D3D_PRIMITIVE_32_CONTROL_POINT_PATCH = 40, }} pub const D3D10_PRIMITIVE_UNDEFINED: ::D3D_PRIMITIVE = D3D_PRIMITIVE_UNDEFINED; pub const D3D10_PRIMITIVE_POINT: ::D3D_PRIMITIVE = D3D_PRIMITIVE_POINT; pub const D3D10_PRIMITIVE_LINE: ::D3D_PRIMITIVE = D3D_PRIMITIVE_LINE; pub const D3D10_PRIMITIVE_TRIANGLE: ::D3D_PRIMITIVE = D3D_PRIMITIVE_TRIANGLE; pub const D3D10_PRIMITIVE_LINE_ADJ: ::D3D_PRIMITIVE = D3D_PRIMITIVE_LINE_ADJ; pub const D3D10_PRIMITIVE_TRIANGLE_ADJ: ::D3D_PRIMITIVE = D3D_PRIMITIVE_TRIANGLE_ADJ; pub const D3D11_PRIMITIVE_UNDEFINED: ::D3D_PRIMITIVE = D3D_PRIMITIVE_UNDEFINED; pub const D3D11_PRIMITIVE_POINT: ::D3D_PRIMITIVE = D3D_PRIMITIVE_POINT; pub const D3D11_PRIMITIVE_LINE: ::D3D_PRIMITIVE = D3D_PRIMITIVE_LINE; pub const D3D11_PRIMITIVE_TRIANGLE: ::D3D_PRIMITIVE = D3D_PRIMITIVE_TRIANGLE; pub const D3D11_PRIMITIVE_LINE_ADJ: ::D3D_PRIMITIVE = D3D_PRIMITIVE_LINE_ADJ; pub const D3D11_PRIMITIVE_TRIANGLE_ADJ: ::D3D_PRIMITIVE = D3D_PRIMITIVE_TRIANGLE_ADJ; pub const D3D11_PRIMITIVE_1_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_1_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_2_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_2_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_3_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_3_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_4_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_4_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_5_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_5_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_6_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_6_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_7_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_7_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_8_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_8_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_9_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_9_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_10_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_10_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_11_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_11_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_12_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_12_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_13_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_13_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_14_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_14_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_15_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_15_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_16_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_16_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_17_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_17_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_18_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_18_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_19_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_19_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_20_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_20_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_21_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_21_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_22_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_22_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_23_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_23_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_24_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_24_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_25_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_25_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_26_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_26_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_27_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_27_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_28_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_28_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_29_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_29_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_30_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_30_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_31_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_31_CONTROL_POINT_PATCH; pub const D3D11_PRIMITIVE_32_CONTROL_POINT_PATCH: ::D3D_PRIMITIVE = D3D_PRIMITIVE_32_CONTROL_POINT_PATCH; ENUM!{enum D3D_SRV_DIMENSION { D3D_SRV_DIMENSION_UNKNOWN = 0, D3D_SRV_DIMENSION_BUFFER = 1, D3D_SRV_DIMENSION_TEXTURE1D = 2, D3D_SRV_DIMENSION_TEXTURE1DARRAY = 3, D3D_SRV_DIMENSION_TEXTURE2D = 4, D3D_SRV_DIMENSION_TEXTURE2DARRAY = 5, D3D_SRV_DIMENSION_TEXTURE2DMS = 6, D3D_SRV_DIMENSION_TEXTURE2DMSARRAY = 7, D3D_SRV_DIMENSION_TEXTURE3D = 8, D3D_SRV_DIMENSION_TEXTURECUBE = 9, D3D_SRV_DIMENSION_TEXTURECUBEARRAY = 10, D3D_SRV_DIMENSION_BUFFEREX = 11, }} pub const D3D10_SRV_DIMENSION_UNKNOWN: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_UNKNOWN; pub const D3D10_SRV_DIMENSION_BUFFER: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_BUFFER; pub const D3D10_SRV_DIMENSION_TEXTURE1D: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE1D; pub const D3D10_SRV_DIMENSION_TEXTURE1DARRAY: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE1DARRAY; pub const D3D10_SRV_DIMENSION_TEXTURE2D: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2D; pub const D3D10_SRV_DIMENSION_TEXTURE2DARRAY: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2DARRAY; pub const D3D10_SRV_DIMENSION_TEXTURE2DMS: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2DMS; pub const D3D10_SRV_DIMENSION_TEXTURE2DMSARRAY: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2DMSARRAY; pub const D3D10_SRV_DIMENSION_TEXTURE3D: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE3D; pub const D3D10_SRV_DIMENSION_TEXTURECUBE: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURECUBE; pub const D3D10_1_SRV_DIMENSION_UNKNOWN: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_UNKNOWN; pub const D3D10_1_SRV_DIMENSION_BUFFER: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_BUFFER; pub const D3D10_1_SRV_DIMENSION_TEXTURE1D: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE1D; pub const D3D10_1_SRV_DIMENSION_TEXTURE1DARRAY: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE1DARRAY; pub const D3D10_1_SRV_DIMENSION_TEXTURE2D: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2D; pub const D3D10_1_SRV_DIMENSION_TEXTURE2DARRAY: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2DARRAY; pub const D3D10_1_SRV_DIMENSION_TEXTURE2DMS: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2DMS; pub const D3D10_1_SRV_DIMENSION_TEXTURE2DMSARRAY: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2DMSARRAY; pub const D3D10_1_SRV_DIMENSION_TEXTURE3D: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE3D; pub const D3D10_1_SRV_DIMENSION_TEXTURECUBE: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURECUBE; pub const D3D10_1_SRV_DIMENSION_TEXTURECUBEARRAY: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURECUBEARRAY; pub const D3D11_SRV_DIMENSION_UNKNOWN: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_UNKNOWN; pub const D3D11_SRV_DIMENSION_BUFFER: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_BUFFER; pub const D3D11_SRV_DIMENSION_TEXTURE1D: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE1D; pub const D3D11_SRV_DIMENSION_TEXTURE1DARRAY: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE1DARRAY; pub const D3D11_SRV_DIMENSION_TEXTURE2D: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2D; pub const D3D11_SRV_DIMENSION_TEXTURE2DARRAY: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2DARRAY; pub const D3D11_SRV_DIMENSION_TEXTURE2DMS: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2DMS; pub const D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE2DMSARRAY; pub const D3D11_SRV_DIMENSION_TEXTURE3D: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURE3D; pub const D3D11_SRV_DIMENSION_TEXTURECUBE: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURECUBE; pub const D3D11_SRV_DIMENSION_TEXTURECUBEARRAY: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_TEXTURECUBEARRAY; pub const D3D11_SRV_DIMENSION_BUFFEREX: ::D3D_SRV_DIMENSION = D3D_SRV_DIMENSION_BUFFEREX; STRUCT!{struct D3D_SHADER_MACRO { Name: ::LPCSTR, Definition: ::LPCSTR, }} pub type LPD3D_SHADER_MACRO = *mut D3D_SHADER_MACRO; DEFINE_GUID!( IID_ID3D10Blob, 0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2 ); RIDL!( interface ID3D10Blob(ID3D10BlobVtbl): IUnknown(IUnknownVtbl) { fn GetBufferPointer(&mut self) -> ::LPVOID, fn GetBufferSize(&mut self) -> ::SIZE_T } ); pub type LPD3D10BLOB = *mut ID3D10Blob; pub type ID3DBlob = ID3D10Blob; pub type LPD3DBLOB = *mut ID3DBlob; ENUM!{enum D3D_INCLUDE_TYPE { D3D_INCLUDE_LOCAL = 0, D3D_INCLUDE_SYSTEM, }} pub const D3D10_INCLUDE_LOCAL: ::D3D_INCLUDE_TYPE = D3D_INCLUDE_LOCAL; pub const D3D10_INCLUDE_SYSTEM: ::D3D_INCLUDE_TYPE = D3D_INCLUDE_SYSTEM; RIDL!( interface ID3DInclude(ID3DIncludeVtbl) { fn Open( &mut self, IncludeType: D3D_INCLUDE_TYPE, pFileName: ::LPCSTR, pParentData: ::LPCVOID, ppData: *mut ::LPCVOID, pBytes: *mut ::UINT ) -> ::HRESULT, fn Close(&mut self, pData: ::LPCVOID) -> ::HRESULT } ); pub type LPD3DINCLUDE = *mut ID3DInclude; ENUM!{enum D3D_SHADER_VARIABLE_CLASS { D3D_SVC_SCALAR = 0, D3D_SVC_VECTOR, D3D_SVC_MATRIX_ROWS, D3D_SVC_MATRIX_COLUMNS, D3D_SVC_OBJECT, D3D_SVC_STRUCT, D3D_SVC_INTERFACE_CLASS, D3D_SVC_INTERFACE_POINTER, }} pub const D3D10_SVC_SCALAR: ::D3D_SHADER_VARIABLE_CLASS = D3D_SVC_SCALAR; pub const D3D10_SVC_VECTOR: ::D3D_SHADER_VARIABLE_CLASS = D3D_SVC_VECTOR; pub const D3D10_SVC_MATRIX_ROWS: ::D3D_SHADER_VARIABLE_CLASS = D3D_SVC_MATRIX_ROWS; pub const D3D10_SVC_MATRIX_COLUMNS: ::D3D_SHADER_VARIABLE_CLASS = D3D_SVC_MATRIX_COLUMNS; pub const D3D10_SVC_OBJECT: ::D3D_SHADER_VARIABLE_CLASS = D3D_SVC_OBJECT; pub const D3D10_SVC_STRUCT: ::D3D_SHADER_VARIABLE_CLASS = D3D_SVC_STRUCT; pub const D3D11_SVC_INTERFACE_CLASS: ::D3D_SHADER_VARIABLE_CLASS = D3D_SVC_INTERFACE_CLASS; pub const D3D11_SVC_INTERFACE_POINTER: ::D3D_SHADER_VARIABLE_CLASS = D3D_SVC_INTERFACE_POINTER; FLAGS!{enum D3D_SHADER_VARIABLE_FLAGS { D3D_SVF_USERPACKED = 1, D3D_SVF_USED = 2, D3D_SVF_INTERFACE_POINTER = 4, D3D_SVF_INTERFACE_PARAMETER = 8, }} pub const D3D10_SVF_USERPACKED: ::D3D_SHADER_VARIABLE_FLAGS = D3D_SVF_USERPACKED; pub const D3D10_SVF_USED: ::D3D_SHADER_VARIABLE_FLAGS = D3D_SVF_USED; pub const D3D11_SVF_INTERFACE_POINTER: ::D3D_SHADER_VARIABLE_FLAGS = D3D_SVF_INTERFACE_POINTER; pub const D3D11_SVF_INTERFACE_PARAMETER: ::D3D_SHADER_VARIABLE_FLAGS = D3D_SVF_INTERFACE_PARAMETER; ENUM!{enum D3D_SHADER_VARIABLE_TYPE { D3D_SVT_VOID = 0, D3D_SVT_BOOL = 1, D3D_SVT_INT = 2, D3D_SVT_FLOAT = 3, D3D_SVT_STRING = 4, D3D_SVT_TEXTURE = 5, D3D_SVT_TEXTURE1D = 6, D3D_SVT_TEXTURE2D = 7, D3D_SVT_TEXTURE3D = 8, D3D_SVT_TEXTURECUBE = 9, D3D_SVT_SAMPLER = 10, D3D_SVT_SAMPLER1D = 11, D3D_SVT_SAMPLER2D = 12, D3D_SVT_SAMPLER3D = 13, D3D_SVT_SAMPLERCUBE = 14, D3D_SVT_PIXELSHADER = 15, D3D_SVT_VERTEXSHADER = 16, D3D_SVT_PIXELFRAGMENT = 17, D3D_SVT_VERTEXFRAGMENT = 18, D3D_SVT_UINT = 19, D3D_SVT_UINT8 = 20, D3D_SVT_GEOMETRYSHADER = 21, D3D_SVT_RASTERIZER = 22, D3D_SVT_DEPTHSTENCIL = 23, D3D_SVT_BLEND = 24, D3D_SVT_BUFFER = 25, D3D_SVT_CBUFFER = 26, D3D_SVT_TBUFFER = 27, D3D_SVT_TEXTURE1DARRAY = 28, D3D_SVT_TEXTURE2DARRAY = 29, D3D_SVT_RENDERTARGETVIEW = 30, D3D_SVT_DEPTHSTENCILVIEW = 31, D3D_SVT_TEXTURE2DMS = 32, D3D_SVT_TEXTURE2DMSARRAY = 33, D3D_SVT_TEXTURECUBEARRAY = 34, D3D_SVT_HULLSHADER = 35, D3D_SVT_DOMAINSHADER = 36, D3D_SVT_INTERFACE_POINTER = 37, D3D_SVT_COMPUTESHADER = 38, D3D_SVT_DOUBLE = 39, D3D_SVT_RWTEXTURE1D = 40, D3D_SVT_RWTEXTURE1DARRAY = 41, D3D_SVT_RWTEXTURE2D = 42, D3D_SVT_RWTEXTURE2DARRAY = 43, D3D_SVT_RWTEXTURE3D = 44, D3D_SVT_RWBUFFER = 45, D3D_SVT_BYTEADDRESS_BUFFER = 46, D3D_SVT_RWBYTEADDRESS_BUFFER = 47, D3D_SVT_STRUCTURED_BUFFER = 48, D3D_SVT_RWSTRUCTURED_BUFFER = 49, D3D_SVT_APPEND_STRUCTURED_BUFFER = 50, D3D_SVT_CONSUME_STRUCTURED_BUFFER = 51, D3D_SVT_MIN8FLOAT = 52, D3D_SVT_MIN10FLOAT = 53, D3D_SVT_MIN16FLOAT = 54, D3D_SVT_MIN12INT = 55, D3D_SVT_MIN16INT = 56, D3D_SVT_MIN16UINT = 57, }} pub const D3D10_SVT_VOID: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_VOID; pub const D3D10_SVT_BOOL: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_BOOL; pub const D3D10_SVT_INT: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_INT; pub const D3D10_SVT_FLOAT: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_FLOAT; pub const D3D10_SVT_STRING: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_STRING; pub const D3D10_SVT_TEXTURE: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURE; pub const D3D10_SVT_TEXTURE1D: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURE1D; pub const D3D10_SVT_TEXTURE2D: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURE2D; pub const D3D10_SVT_TEXTURE3D: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURE3D; pub const D3D10_SVT_TEXTURECUBE: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURECUBE; pub const D3D10_SVT_SAMPLER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_SAMPLER; pub const D3D10_SVT_SAMPLER1D: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_SAMPLER1D; pub const D3D10_SVT_SAMPLER2D: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_SAMPLER2D; pub const D3D10_SVT_SAMPLER3D: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_SAMPLER3D; pub const D3D10_SVT_SAMPLERCUBE: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_SAMPLERCUBE; pub const D3D10_SVT_PIXELSHADER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_PIXELSHADER; pub const D3D10_SVT_VERTEXSHADER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_VERTEXSHADER; pub const D3D10_SVT_PIXELFRAGMENT: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_PIXELFRAGMENT; pub const D3D10_SVT_VERTEXFRAGMENT: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_VERTEXFRAGMENT; pub const D3D10_SVT_UINT: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_UINT; pub const D3D10_SVT_UINT8: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_UINT8; pub const D3D10_SVT_GEOMETRYSHADER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_GEOMETRYSHADER; pub const D3D10_SVT_RASTERIZER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RASTERIZER; pub const D3D10_SVT_DEPTHSTENCIL: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_DEPTHSTENCIL; pub const D3D10_SVT_BLEND: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_BLEND; pub const D3D10_SVT_BUFFER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_BUFFER; pub const D3D10_SVT_CBUFFER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_CBUFFER; pub const D3D10_SVT_TBUFFER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TBUFFER; pub const D3D10_SVT_TEXTURE1DARRAY: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURE1DARRAY; pub const D3D10_SVT_TEXTURE2DARRAY: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURE2DARRAY; pub const D3D10_SVT_RENDERTARGETVIEW: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RENDERTARGETVIEW; pub const D3D10_SVT_DEPTHSTENCILVIEW: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_DEPTHSTENCILVIEW; pub const D3D10_SVT_TEXTURE2DMS: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURE2DMS; pub const D3D10_SVT_TEXTURE2DMSARRAY: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURE2DMSARRAY; pub const D3D10_SVT_TEXTURECUBEARRAY: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_TEXTURECUBEARRAY; pub const D3D11_SVT_HULLSHADER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_HULLSHADER; pub const D3D11_SVT_DOMAINSHADER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_DOMAINSHADER; pub const D3D11_SVT_INTERFACE_POINTER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_INTERFACE_POINTER; pub const D3D11_SVT_COMPUTESHADER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_COMPUTESHADER; pub const D3D11_SVT_DOUBLE: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_DOUBLE; pub const D3D11_SVT_RWTEXTURE1D: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RWTEXTURE1D; pub const D3D11_SVT_RWTEXTURE1DARRAY: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RWTEXTURE1DARRAY; pub const D3D11_SVT_RWTEXTURE2D: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RWTEXTURE2D; pub const D3D11_SVT_RWTEXTURE2DARRAY: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RWTEXTURE2DARRAY; pub const D3D11_SVT_RWTEXTURE3D: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RWTEXTURE3D; pub const D3D11_SVT_RWBUFFER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RWBUFFER; pub const D3D11_SVT_BYTEADDRESS_BUFFER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_BYTEADDRESS_BUFFER; pub const D3D11_SVT_RWBYTEADDRESS_BUFFER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RWBYTEADDRESS_BUFFER; pub const D3D11_SVT_STRUCTURED_BUFFER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_STRUCTURED_BUFFER; pub const D3D11_SVT_RWSTRUCTURED_BUFFER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_RWSTRUCTURED_BUFFER; pub const D3D11_SVT_APPEND_STRUCTURED_BUFFER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_APPEND_STRUCTURED_BUFFER; pub const D3D11_SVT_CONSUME_STRUCTURED_BUFFER: ::D3D_SHADER_VARIABLE_TYPE = D3D_SVT_CONSUME_STRUCTURED_BUFFER; FLAGS!{enum D3D_SHADER_INPUT_FLAGS { D3D_SIF_USERPACKED = 0x1, D3D_SIF_COMPARISON_SAMPLER = 0x2, D3D_SIF_TEXTURE_COMPONENT_0 = 0x4, D3D_SIF_TEXTURE_COMPONENT_1 = 0x8, D3D_SIF_TEXTURE_COMPONENTS = 0xc, D3D_SIF_UNUSED = 0x10, }} pub const D3D10_SIF_USERPACKED: ::D3D_SHADER_INPUT_FLAGS = D3D_SIF_USERPACKED; pub const D3D10_SIF_COMPARISON_SAMPLER: ::D3D_SHADER_INPUT_FLAGS = D3D_SIF_COMPARISON_SAMPLER; pub const D3D10_SIF_TEXTURE_COMPONENT_0: ::D3D_SHADER_INPUT_FLAGS = D3D_SIF_TEXTURE_COMPONENT_0; pub const D3D10_SIF_TEXTURE_COMPONENT_1: ::D3D_SHADER_INPUT_FLAGS = D3D_SIF_TEXTURE_COMPONENT_1; pub const D3D10_SIF_TEXTURE_COMPONENTS: ::D3D_SHADER_INPUT_FLAGS = D3D_SIF_TEXTURE_COMPONENTS; ENUM!{enum D3D_SHADER_INPUT_TYPE { D3D_SIT_CBUFFER, D3D_SIT_TBUFFER, D3D_SIT_TEXTURE, D3D_SIT_SAMPLER, D3D_SIT_UAV_RWTYPED, D3D_SIT_STRUCTURED, D3D_SIT_UAV_RWSTRUCTURED, D3D_SIT_BYTEADDRESS, D3D_SIT_UAV_RWBYTEADDRESS, D3D_SIT_UAV_APPEND_STRUCTURED, D3D_SIT_UAV_CONSUME_STRUCTURED, D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER, }} pub const D3D10_SIT_CBUFFER: ::D3D_SHADER_INPUT_TYPE = D3D_SIT_CBUFFER; pub const D3D10_SIT_TBUFFER: ::D3D_SHADER_INPUT_TYPE = D3D_SIT_TBUFFER; pub const D3D10_SIT_TEXTURE: ::D3D_SHADER_INPUT_TYPE = D3D_SIT_TEXTURE; pub const D3D10_SIT_SAMPLER: ::D3D_SHADER_INPUT_TYPE = D3D_SIT_SAMPLER; pub const D3D11_SIT_UAV_RWTYPED: ::D3D_SHADER_INPUT_TYPE = D3D_SIT_UAV_RWTYPED; pub const D3D11_SIT_STRUCTURED: ::D3D_SHADER_INPUT_TYPE = D3D_SIT_STRUCTURED; pub const D3D11_SIT_UAV_RWSTRUCTURED: ::D3D_SHADER_INPUT_TYPE = D3D_SIT_UAV_RWSTRUCTURED; pub const D3D11_SIT_BYTEADDRESS: ::D3D_SHADER_INPUT_TYPE = D3D_SIT_BYTEADDRESS; pub const D3D11_SIT_UAV_RWBYTEADDRESS: ::D3D_SHADER_INPUT_TYPE = D3D_SIT_UAV_RWBYTEADDRESS; pub const D3D11_SIT_UAV_APPEND_STRUCTURED: ::D3D_SHADER_INPUT_TYPE = D3D_SIT_UAV_APPEND_STRUCTURED; pub const D3D11_SIT_UAV_CONSUME_STRUCTURED: ::D3D_SHADER_INPUT_TYPE = D3D_SIT_UAV_CONSUME_STRUCTURED; pub const D3D11_SIT_UAV_RWSTRUCTURED_WITH_COUNTER: ::D3D_SHADER_INPUT_TYPE = D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER; FLAGS!{enum D3D_SHADER_CBUFFER_FLAGS { D3D_CBF_USERPACKED = 1, }} pub const D3D10_CBF_USERPACKED: ::D3D_SHADER_CBUFFER_FLAGS = D3D_CBF_USERPACKED; ENUM!{enum D3D_CBUFFER_TYPE { D3D_CT_CBUFFER, D3D_CT_TBUFFER, D3D_CT_INTERFACE_POINTERS, D3D_CT_RESOURCE_BIND_INFO, }} pub const D3D10_CT_CBUFFER: ::D3D_CBUFFER_TYPE = D3D_CT_CBUFFER; pub const D3D10_CT_TBUFFER: ::D3D_CBUFFER_TYPE = D3D_CT_TBUFFER; pub const D3D11_CT_CBUFFER: ::D3D_CBUFFER_TYPE = D3D_CT_CBUFFER; pub const D3D11_CT_TBUFFER: ::D3D_CBUFFER_TYPE = D3D_CT_TBUFFER; pub const D3D11_CT_INTERFACE_POINTERS: ::D3D_CBUFFER_TYPE = D3D_CT_INTERFACE_POINTERS; pub const D3D11_CT_RESOURCE_BIND_INFO: ::D3D_CBUFFER_TYPE = D3D_CT_RESOURCE_BIND_INFO; ENUM!{enum D3D_NAME { D3D_NAME_UNDEFINED = 0, D3D_NAME_POSITION = 1, D3D_NAME_CLIP_DISTANCE = 2, D3D_NAME_CULL_DISTANCE = 3, D3D_NAME_RENDER_TARGET_ARRAY_INDEX = 4, D3D_NAME_VIEWPORT_ARRAY_INDEX = 5, D3D_NAME_VERTEX_ID = 6, D3D_NAME_PRIMITIVE_ID = 7, D3D_NAME_INSTANCE_ID = 8, D3D_NAME_IS_FRONT_FACE = 9, D3D_NAME_SAMPLE_INDEX = 10, D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR = 11, D3D_NAME_FINAL_QUAD_INSIDE_TESSFACTOR = 12, D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR = 13, D3D_NAME_FINAL_TRI_INSIDE_TESSFACTOR = 14, D3D_NAME_FINAL_LINE_DETAIL_TESSFACTOR = 15, D3D_NAME_FINAL_LINE_DENSITY_TESSFACTOR = 16, D3D_NAME_TARGET = 64, D3D_NAME_DEPTH = 65, D3D_NAME_COVERAGE = 66, D3D_NAME_DEPTH_GREATER_EQUAL = 67, D3D_NAME_DEPTH_LESS_EQUAL = 68, }} pub const D3D10_NAME_UNDEFINED: D3D_NAME = D3D_NAME_UNDEFINED; pub const D3D10_NAME_POSITION: D3D_NAME = D3D_NAME_POSITION; pub const D3D10_NAME_CLIP_DISTANCE: D3D_NAME = D3D_NAME_CLIP_DISTANCE; pub const D3D10_NAME_CULL_DISTANCE: D3D_NAME = D3D_NAME_CULL_DISTANCE; pub const D3D10_NAME_RENDER_TARGET_ARRAY_INDEX: D3D_NAME = D3D_NAME_RENDER_TARGET_ARRAY_INDEX; pub const D3D10_NAME_VIEWPORT_ARRAY_INDEX: D3D_NAME = D3D_NAME_VIEWPORT_ARRAY_INDEX; pub const D3D10_NAME_VERTEX_ID: D3D_NAME = D3D_NAME_VERTEX_ID; pub const D3D10_NAME_PRIMITIVE_ID: D3D_NAME = D3D_NAME_PRIMITIVE_ID; pub const D3D10_NAME_INSTANCE_ID: D3D_NAME = D3D_NAME_INSTANCE_ID; pub const D3D10_NAME_IS_FRONT_FACE: D3D_NAME = D3D_NAME_IS_FRONT_FACE; pub const D3D10_NAME_SAMPLE_INDEX: D3D_NAME = D3D_NAME_SAMPLE_INDEX; pub const D3D10_NAME_TARGET: D3D_NAME = D3D_NAME_TARGET; pub const D3D10_NAME_DEPTH: D3D_NAME = D3D_NAME_DEPTH; pub const D3D10_NAME_COVERAGE: D3D_NAME = D3D_NAME_COVERAGE; pub const D3D11_NAME_FINAL_QUAD_EDGE_TESSFACTOR: D3D_NAME = D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR; pub const D3D11_NAME_FINAL_QUAD_INSIDE_TESSFACTOR: D3D_NAME = D3D_NAME_FINAL_QUAD_INSIDE_TESSFACTOR; pub const D3D11_NAME_FINAL_TRI_EDGE_TESSFACTOR: D3D_NAME = D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR; pub const D3D11_NAME_FINAL_TRI_INSIDE_TESSFACTOR: D3D_NAME = D3D_NAME_FINAL_TRI_INSIDE_TESSFACTOR; pub const D3D11_NAME_FINAL_LINE_DETAIL_TESSFACTOR: D3D_NAME = D3D_NAME_FINAL_LINE_DETAIL_TESSFACTOR; pub const D3D11_NAME_FINAL_LINE_DENSITY_TESSFACTOR: D3D_NAME = D3D_NAME_FINAL_LINE_DENSITY_TESSFACTOR; pub const D3D11_NAME_DEPTH_GREATER_EQUAL: D3D_NAME = D3D_NAME_DEPTH_GREATER_EQUAL; pub const D3D11_NAME_DEPTH_LESS_EQUAL: D3D_NAME = D3D_NAME_DEPTH_LESS_EQUAL; ENUM!{enum D3D_RESOURCE_RETURN_TYPE { D3D_RETURN_TYPE_UNORM = 1, D3D_RETURN_TYPE_SNORM = 2, D3D_RETURN_TYPE_SINT = 3, D3D_RETURN_TYPE_UINT = 4, D3D_RETURN_TYPE_FLOAT = 5, D3D_RETURN_TYPE_MIXED = 6, D3D_RETURN_TYPE_DOUBLE = 7, D3D_RETURN_TYPE_CONTINUED = 8, }} pub const D3D10_RETURN_TYPE_UNORM: ::D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_UNORM; pub const D3D10_RETURN_TYPE_SNORM: ::D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_SNORM; pub const D3D10_RETURN_TYPE_SINT: ::D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_SINT; pub const D3D10_RETURN_TYPE_UINT: ::D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_UINT; pub const D3D10_RETURN_TYPE_FLOAT: ::D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_FLOAT; pub const D3D10_RETURN_TYPE_MIXED: ::D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_MIXED; pub const D3D11_RETURN_TYPE_UNORM: ::D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_UNORM; pub const D3D11_RETURN_TYPE_SNORM: ::D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_SNORM; pub const D3D11_RETURN_TYPE_SINT: ::D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_SINT; pub const D3D11_RETURN_TYPE_UINT: ::D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_UINT; pub const D3D11_RETURN_TYPE_FLOAT: ::D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_FLOAT; pub const D3D11_RETURN_TYPE_MIXED: ::D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_MIXED; pub const D3D11_RETURN_TYPE_DOUBLE: ::D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_DOUBLE; pub const D3D11_RETURN_TYPE_CONTINUED: ::D3D_RESOURCE_RETURN_TYPE = D3D_RETURN_TYPE_CONTINUED; ENUM!{enum D3D_REGISTER_COMPONENT_TYPE { D3D_REGISTER_COMPONENT_UNKNOWN = 0, D3D_REGISTER_COMPONENT_UINT32 = 1, D3D_REGISTER_COMPONENT_SINT32 = 2, D3D_REGISTER_COMPONENT_FLOAT32 = 3, }} pub const D3D10_REGISTER_COMPONENT_UNKNOWN: ::D3D_REGISTER_COMPONENT_TYPE = D3D_REGISTER_COMPONENT_UNKNOWN; pub const D3D10_REGISTER_COMPONENT_UINT32: ::D3D_REGISTER_COMPONENT_TYPE = D3D_REGISTER_COMPONENT_UINT32; pub const D3D10_REGISTER_COMPONENT_SINT32: ::D3D_REGISTER_COMPONENT_TYPE = D3D_REGISTER_COMPONENT_SINT32; pub const D3D10_REGISTER_COMPONENT_FLOAT32: ::D3D_REGISTER_COMPONENT_TYPE = D3D_REGISTER_COMPONENT_FLOAT32; ENUM!{enum D3D_TESSELLATOR_DOMAIN { D3D_TESSELLATOR_DOMAIN_UNDEFINED, D3D_TESSELLATOR_DOMAIN_ISOLINE, D3D_TESSELLATOR_DOMAIN_TRI, D3D_TESSELLATOR_DOMAIN_QUAD, }} pub const D3D11_TESSELLATOR_DOMAIN_UNDEFINED: ::D3D_TESSELLATOR_DOMAIN = D3D_TESSELLATOR_DOMAIN_UNDEFINED; pub const D3D11_TESSELLATOR_DOMAIN_ISOLINE: ::D3D_TESSELLATOR_DOMAIN = D3D_TESSELLATOR_DOMAIN_ISOLINE; pub const D3D11_TESSELLATOR_DOMAIN_TRI: ::D3D_TESSELLATOR_DOMAIN = D3D_TESSELLATOR_DOMAIN_TRI; pub const D3D11_TESSELLATOR_DOMAIN_QUAD: ::D3D_TESSELLATOR_DOMAIN = D3D_TESSELLATOR_DOMAIN_QUAD; ENUM!{enum D3D_TESSELLATOR_PARTITIONING { D3D_TESSELLATOR_PARTITIONING_UNDEFINED, D3D_TESSELLATOR_PARTITIONING_INTEGER, D3D_TESSELLATOR_PARTITIONING_POW2, D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD, D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN, }} pub const D3D11_TESSELLATOR_PARTITIONING_UNDEFINED: ::D3D_TESSELLATOR_PARTITIONING = D3D_TESSELLATOR_PARTITIONING_UNDEFINED; pub const D3D11_TESSELLATOR_PARTITIONING_INTEGER: ::D3D_TESSELLATOR_PARTITIONING = D3D_TESSELLATOR_PARTITIONING_INTEGER; pub const D3D11_TESSELLATOR_PARTITIONING_POW2: ::D3D_TESSELLATOR_PARTITIONING = D3D_TESSELLATOR_PARTITIONING_POW2; pub const D3D11_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD: ::D3D_TESSELLATOR_PARTITIONING = D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD; pub const D3D11_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN: ::D3D_TESSELLATOR_PARTITIONING = D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN; ENUM!{enum D3D_TESSELLATOR_OUTPUT_PRIMITIVE { D3D_TESSELLATOR_OUTPUT_UNDEFINED, D3D_TESSELLATOR_OUTPUT_POINT, D3D_TESSELLATOR_OUTPUT_LINE, D3D_TESSELLATOR_OUTPUT_TRIANGLE_CW, D3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW, }} pub const D3D11_TESSELLATOR_OUTPUT_UNDEFINED: ::D3D_TESSELLATOR_OUTPUT_PRIMITIVE = D3D_TESSELLATOR_OUTPUT_UNDEFINED; pub const D3D11_TESSELLATOR_OUTPUT_POINT: ::D3D_TESSELLATOR_OUTPUT_PRIMITIVE = D3D_TESSELLATOR_OUTPUT_POINT; pub const D3D11_TESSELLATOR_OUTPUT_LINE: ::D3D_TESSELLATOR_OUTPUT_PRIMITIVE = D3D_TESSELLATOR_OUTPUT_LINE; pub const D3D11_TESSELLATOR_OUTPUT_TRIANGLE_CW: ::D3D_TESSELLATOR_OUTPUT_PRIMITIVE = D3D_TESSELLATOR_OUTPUT_TRIANGLE_CW; pub const D3D11_TESSELLATOR_OUTPUT_TRIANGLE_CCW: ::D3D_TESSELLATOR_OUTPUT_PRIMITIVE = D3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW; ENUM!{enum D3D_MIN_PRECISION { D3D_MIN_PRECISION_DEFAULT, D3D_MIN_PRECISION_FLOAT_16, D3D_MIN_PRECISION_FLOAT_2_8, D3D_MIN_PRECISION_RESERVED, D3D_MIN_PRECISION_SINT_16, D3D_MIN_PRECISION_UINT_16, D3D_MIN_PRECISION_ANY_16 = 0xf0, D3D_MIN_PRECISION_ANY_10 = 0xf1, }} ENUM!{enum D3D_INTERPOLATION_MODE { D3D_INTERPOLATION_UNDEFINED, D3D_INTERPOLATION_CONSTANT, D3D_INTERPOLATION_LINEAR, D3D_INTERPOLATION_LINEAR_CENTROID, D3D_INTERPOLATION_LINEAR_NOPERSPECTIVE, D3D_INTERPOLATION_LINEAR_NOPERSPECTIVE_CENTROID, D3D_INTERPOLATION_LINEAR_SAMPLE, D3D_INTERPOLATION_LINEAR_NOPERSPECTIVE_SAMPLE, }} DEFINE_GUID!( WKPDID_D3DDebugObjectName, 0x429b8c22, 0x9188, 0x4b0c, 0x87, 0x42, 0xac, 0xb0, 0xbf, 0x85, 0xc2, 0x00 ); deps/winapi-0.2.5/src/schannel.rs0000644000000000000000000003660212615662007015402 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Public Definitions for SCHANNEL Security Provider pub const UNISP_NAME: &'static str = "Microsoft Unified Security Protocol Provider"; pub const SSL2SP_NAME: &'static str = "Microsoft SSL 2.0"; pub const SSL3SP_NAME: &'static str = "Microsoft SSL 3.0"; pub const TLS1SP_NAME: &'static str = "Microsoft TLS 1.0"; pub const PCT1SP_NAME: &'static str = "Microsoft PCT 1.0"; pub const SCHANNEL_NAME: &'static str = "Schannel"; ENUM!{enum eTlsSignatureAlgorithm { TlsSignatureAlgorithm_Anonymous = 0, TlsSignatureAlgorithm_Rsa = 1, TlsSignatureAlgorithm_Dsa = 2, TlsSignatureAlgorithm_Ecdsa = 3, }} ENUM!{enum eTlsHashAlgorithm { TlsHashAlgorithm_None = 0, TlsHashAlgorithm_Md5 = 1, TlsHashAlgorithm_Sha1 = 2, TlsHashAlgorithm_Sha224 = 3, TlsHashAlgorithm_Sha256 = 4, TlsHashAlgorithm_Sha384 = 5, TlsHashAlgorithm_Sha512 = 6, }} pub const UNISP_RPC_ID: ::DWORD = 14; STRUCT!{struct SecPkgContext_RemoteCredentialInfo { cbCertificateChain: ::DWORD, pbCertificateChain: ::PBYTE, cCertificates: ::DWORD, fFlags: ::DWORD, dwBits: ::DWORD, }} pub type PSecPkgContext_RemoteCredentialInfo = *mut SecPkgContext_RemoteCredentialInfo; pub type SecPkgContext_RemoteCredenitalInfo = SecPkgContext_RemoteCredentialInfo; pub type PSecPkgContext_RemoteCredenitalInfo = *mut SecPkgContext_RemoteCredentialInfo; pub const RCRED_STATUS_NOCRED: ::DWORD = 0x00000000; pub const RCRED_CRED_EXISTS: ::DWORD = 0x00000001; pub const RCRED_STATUS_UNKNOWN_ISSUER: ::DWORD = 0x00000002; STRUCT!{struct SecPkgContext_LocalCredentialInfo { cbCertificateChain: ::DWORD, pbCertificateChain: ::PBYTE, cCertificates: ::DWORD, fFlags: ::DWORD, dwBits: ::DWORD, }} pub type PSecPkgContext_LocalCredentialInfo = *mut SecPkgContext_LocalCredentialInfo; pub type SecPkgContext_LocalCredenitalInfo = SecPkgContext_LocalCredentialInfo; pub type PSecPkgContext_LocalCredenitalInfo = *mut SecPkgContext_LocalCredentialInfo; pub const LCRED_STATUS_NOCRED: ::DWORD = 0x00000000; pub const LCRED_CRED_EXISTS: ::DWORD = 0x00000001; pub const LCRED_STATUS_UNKNOWN_ISSUER: ::DWORD = 0x00000002; STRUCT!{struct SecPkgContext_ClientCertPolicyResult { dwPolicyResult: ::HRESULT, guidPolicyId: ::GUID, }} pub type PSecPkgContext_ClientCertPolicyResult = *mut SecPkgContext_ClientCertPolicyResult; STRUCT!{struct SecPkgContext_IssuerListInfoEx { aIssuers: ::PCERT_NAME_BLOB, cIssuers: ::DWORD, }} pub type PSecPkgContext_IssuerListInfoEx = *mut SecPkgContext_IssuerListInfoEx; STRUCT!{struct SecPkgContext_ConnectionInfo { dwProtocol: ::DWORD, aiCipher: ::ALG_ID, dwCipherStrength: ::DWORD, aiHash: ::ALG_ID, dwHashStrength: ::DWORD, aiExch: ::ALG_ID, dwExchStrength: ::DWORD, }} pub type PSecPkgContext_ConnectionInfo = *mut SecPkgContext_ConnectionInfo; pub const SZ_ALG_MAX_SIZE: usize = 64; pub const SECPKGCONTEXT_CIPHERINFO_V1: ::DWORD = 1; #[repr(C)] #[derive(Copy)] pub struct SecPkgContext_CipherInfo { pub dwVersion: ::DWORD, pub dwProtocol: ::DWORD, pub dwCipherSuite: ::DWORD, pub dwBaseCipherSuite: ::DWORD, pub szCipherSuite: [::WCHAR; SZ_ALG_MAX_SIZE], pub szCipher: [::WCHAR; SZ_ALG_MAX_SIZE], pub dwCipherLen: ::DWORD, pub dwCipherBlockLen: ::DWORD, pub szHash: [::WCHAR; SZ_ALG_MAX_SIZE], pub dwHashLen: ::DWORD, pub szExchange: [::WCHAR; SZ_ALG_MAX_SIZE], pub dwMinExchangeLen: ::DWORD, pub dwMaxExchangeLen: ::DWORD, pub szCertificate: [::WCHAR; SZ_ALG_MAX_SIZE], pub dwKeyType: ::DWORD, } impl Clone for SecPkgContext_CipherInfo { fn clone(&self) -> SecPkgContext_CipherInfo { *self } } pub type PSecPkgContext_CipherInfo = *mut SecPkgContext_CipherInfo; #[repr(C)] #[derive(Copy)] pub struct SecPkgContext_EapKeyBlock { pub rgbKeys: [::BYTE; 128], pub rgbIVs: [::BYTE; 64], } impl Clone for SecPkgContext_EapKeyBlock { fn clone(&self) -> SecPkgContext_EapKeyBlock { *self } } pub type PSecPkgContext_EapKeyBlock = *mut SecPkgContext_EapKeyBlock; STRUCT!{struct SecPkgContext_MappedCredAttr { dwAttribute: ::DWORD, pvBuffer: ::PVOID, }} pub type PSecPkgContext_MappedCredAttr = *mut SecPkgContext_MappedCredAttr; pub const SSL_SESSION_RECONNECT: ::DWORD = 1; STRUCT!{struct SecPkgContext_SessionInfo { dwFlags: ::DWORD, cbSessionId: ::DWORD, rgbSessionId: [::BYTE; 32], }} pub type PSecPkgContext_SessionInfo = *mut SecPkgContext_SessionInfo; STRUCT!{struct SecPkgContext_SessionAppData { dwFlags: ::DWORD, cbAppData: ::DWORD, pbAppData: ::PBYTE, }} pub type PSecPkgContext_SessionAppData = *mut SecPkgContext_SessionAppData; STRUCT!{struct SecPkgContext_EapPrfInfo { dwVersion: ::DWORD, cbPrfData: ::DWORD, pbPrfData: ::PBYTE, }} pub type PSecPkgContext_EapPrfInfo = *mut SecPkgContext_EapPrfInfo; STRUCT!{struct SecPkgContext_SupportedSignatures { cSignatureAndHashAlgorithms: ::WORD, pSignatureAndHashAlgorithms: *mut ::WORD, }} pub type PSecPkgContext_SupportedSignatures = *mut SecPkgContext_SupportedSignatures; STRUCT!{struct SecPkgContext_Certificates { cCertificates: ::DWORD, cbCertificateChain: ::DWORD, pbCertificateChain: ::PBYTE, }} pub type PSecPkgContext_Certificates = *mut SecPkgContext_Certificates; STRUCT!{struct SecPkgContext_CertInfo { dwVersion: ::DWORD, cbSubjectName: ::DWORD, pwszSubjectName: ::LPWSTR, cbIssuerName: ::DWORD, pwszIssuerName: ::LPWSTR, dwKeySize: ::DWORD, }} pub type PSecPkgContext_CertInfo = *mut SecPkgContext_CertInfo; pub const KERN_CONTEXT_CERT_INFO_V1: ::DWORD = 0x00000000; STRUCT!{struct SecPkgContext_UiInfo { hParentWindow: ::HWND, }} pub type PSecPkgContext_UiInfo = *mut SecPkgContext_UiInfo; STRUCT!{struct SecPkgContext_EarlyStart { dwEarlyStartFlags: ::DWORD, }} pub type PSecPkgContext_EarlyStart = *mut SecPkgContext_EarlyStart; pub const ENABLE_TLS_CLIENT_EARLY_START: ::DWORD = 0x00000001; pub const SCH_CRED_V1: ::DWORD = 0x00000001; pub const SCH_CRED_V2: ::DWORD = 0x00000002; pub const SCH_CRED_VERSION: ::DWORD = 0x00000002; pub const SCH_CRED_V3: ::DWORD = 0x00000003; pub const SCHANNEL_CRED_VERSION: ::DWORD = 0x00000004; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct _HMAPPER; STRUCT!{struct SCHANNEL_CRED { dwVersion: ::DWORD, cCreds: ::DWORD, paCred: *mut ::PCCERT_CONTEXT, hRootStore: ::HCERTSTORE, cMappers: ::DWORD, aphMappers: *mut *mut _HMAPPER, cSupportedAlgs: ::DWORD, palgSupportedAlgs: *mut ::ALG_ID, grbitEnabledProtocols: ::DWORD, dwMinimumCipherStrength: ::DWORD, dwMaximumCipherStrength: ::DWORD, dwSessionLifespan: ::DWORD, dwFlags: ::DWORD, dwCredFormat: ::DWORD, }} pub type PSCHANNEL_CRED = *mut SCHANNEL_CRED; pub const SCH_CRED_FORMAT_CERT_CONTEXT: ::DWORD = 0x00000000; pub const SCH_CRED_FORMAT_CERT_HASH: ::DWORD = 0x00000001; pub const SCH_CRED_FORMAT_CERT_HASH_STORE: ::DWORD = 0x00000002; pub const SCH_CRED_MAX_STORE_NAME_SIZE: usize = 128; pub const SCH_CRED_MAX_SUPPORTED_ALGS: ::DWORD = 256; pub const SCH_CRED_MAX_SUPPORTED_CERTS: ::DWORD = 100; STRUCT!{struct SCHANNEL_CERT_HASH { dwLength: ::DWORD, dwFlags: ::DWORD, hProv: ::HCRYPTPROV, ShaHash: [::BYTE; 20], }} pub type PSCHANNEL_CERT_HASH = *mut SCHANNEL_CERT_HASH; #[repr(C)] #[derive(Copy)] pub struct SCHANNEL_CERT_HASH_STORE { pub dwLength: ::DWORD, pub dwFlags: ::DWORD, pub hProv: ::HCRYPTPROV, pub ShaHash: [::BYTE; 20], pub pwszStoreName: [::WCHAR; SCH_CRED_MAX_STORE_NAME_SIZE], } impl Clone for SCHANNEL_CERT_HASH_STORE { fn clone(&self) -> SCHANNEL_CERT_HASH_STORE { *self } } pub type PSCHANNEL_CERT_HASH_STORE = *mut SCHANNEL_CERT_HASH_STORE; pub const SCH_MACHINE_CERT_HASH: ::DWORD = 0x00000001; pub const SCH_CRED_NO_SYSTEM_MAPPER: ::DWORD = 0x00000002; pub const SCH_CRED_NO_SERVERNAME_CHECK: ::DWORD = 0x00000004; pub const SCH_CRED_MANUAL_CRED_VALIDATION: ::DWORD = 0x00000008; pub const SCH_CRED_NO_DEFAULT_CREDS: ::DWORD = 0x00000010; pub const SCH_CRED_AUTO_CRED_VALIDATION: ::DWORD = 0x00000020; pub const SCH_CRED_USE_DEFAULT_CREDS: ::DWORD = 0x00000040; pub const SCH_CRED_DISABLE_RECONNECTS: ::DWORD = 0x00000080; pub const SCH_CRED_REVOCATION_CHECK_END_CERT: ::DWORD = 0x00000100; pub const SCH_CRED_REVOCATION_CHECK_CHAIN: ::DWORD = 0x00000200; pub const SCH_CRED_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT: ::DWORD = 0x00000400; pub const SCH_CRED_IGNORE_NO_REVOCATION_CHECK: ::DWORD = 0x00000800; pub const SCH_CRED_IGNORE_REVOCATION_OFFLINE: ::DWORD = 0x00001000; pub const SCH_CRED_RESTRICTED_ROOTS: ::DWORD = 0x00002000; pub const SCH_CRED_REVOCATION_CHECK_CACHE_ONLY: ::DWORD = 0x00004000; pub const SCH_CRED_CACHE_ONLY_URL_RETRIEVAL: ::DWORD = 0x00008000; pub const SCH_CRED_MEMORY_STORE_CERT: ::DWORD = 0x00010000; pub const SCH_CRED_CACHE_ONLY_URL_RETRIEVAL_ON_CREATE: ::DWORD = 0x00020000; pub const SCH_SEND_ROOT_CERT: ::DWORD = 0x00040000; pub const SCH_CRED_SNI_CREDENTIAL: ::DWORD = 0x00080000; pub const SCH_CRED_SNI_ENABLE_OCSP: ::DWORD = 0x00100000; pub const SCH_SEND_AUX_RECORD: ::DWORD = 0x00200000; pub const SCH_USE_STRONG_CRYPTO: ::DWORD = 0x00400000; pub const SCHANNEL_RENEGOTIATE: ::DWORD = 0; pub const SCHANNEL_SHUTDOWN: ::DWORD = 1; pub const SCHANNEL_ALERT: ::DWORD = 2; pub const SCHANNEL_SESSION: ::DWORD = 3; STRUCT!{struct SCHANNEL_ALERT_TOKEN { dwTokenType: ::DWORD, dwAlertType: ::DWORD, dwAlertNumber: ::DWORD, }} pub const TLS1_ALERT_WARNING: ::DWORD = 1; pub const TLS1_ALERT_FATAL: ::DWORD = 2; pub const TLS1_ALERT_CLOSE_NOTIFY: ::DWORD = 0; pub const TLS1_ALERT_UNEXPECTED_MESSAGE: ::DWORD = 10; pub const TLS1_ALERT_BAD_RECORD_MAC: ::DWORD = 20; pub const TLS1_ALERT_DECRYPTION_FAILED: ::DWORD = 21; pub const TLS1_ALERT_RECORD_OVERFLOW: ::DWORD = 22; pub const TLS1_ALERT_DECOMPRESSION_FAIL: ::DWORD = 30; pub const TLS1_ALERT_HANDSHAKE_FAILURE: ::DWORD = 40; pub const TLS1_ALERT_BAD_CERTIFICATE: ::DWORD = 42; pub const TLS1_ALERT_UNSUPPORTED_CERT: ::DWORD = 43; pub const TLS1_ALERT_CERTIFICATE_REVOKED: ::DWORD = 44; pub const TLS1_ALERT_CERTIFICATE_EXPIRED: ::DWORD = 45; pub const TLS1_ALERT_CERTIFICATE_UNKNOWN: ::DWORD = 46; pub const TLS1_ALERT_ILLEGAL_PARAMETER: ::DWORD = 47; pub const TLS1_ALERT_UNKNOWN_CA: ::DWORD = 48; pub const TLS1_ALERT_ACCESS_DENIED: ::DWORD = 49; pub const TLS1_ALERT_DECODE_ERROR: ::DWORD = 50; pub const TLS1_ALERT_DECRYPT_ERROR: ::DWORD = 51; pub const TLS1_ALERT_EXPORT_RESTRICTION: ::DWORD = 60; pub const TLS1_ALERT_PROTOCOL_VERSION: ::DWORD = 70; pub const TLS1_ALERT_INSUFFIENT_SECURITY: ::DWORD = 71; pub const TLS1_ALERT_INTERNAL_ERROR: ::DWORD = 80; pub const TLS1_ALERT_USER_CANCELED: ::DWORD = 90; pub const TLS1_ALERT_NO_RENEGOTIATION: ::DWORD = 100; pub const TLS1_ALERT_UNSUPPORTED_EXT: ::DWORD = 110; pub const TLS1_ALERT_NO_APP_PROTOCOL: ::DWORD = 120; pub const SSL_SESSION_ENABLE_RECONNECTS: ::DWORD = 1; pub const SSL_SESSION_DISABLE_RECONNECTS: ::DWORD = 2; STRUCT!{struct SCHANNEL_SESSION_TOKEN { dwTokenType: ::DWORD, dwFlags: ::DWORD, }} #[repr(C)] #[derive(Copy)] pub struct SCHANNEL_CLIENT_SIGNATURE { pub cbLength: ::DWORD, pub aiHash: ::ALG_ID, pub cbHash: ::DWORD, pub HashValue: [::BYTE; 36], pub CertThumbprint: [::BYTE; 20], } impl Clone for SCHANNEL_CLIENT_SIGNATURE { fn clone(&self) -> SCHANNEL_CLIENT_SIGNATURE { *self } } pub type PSCHANNEL_CLIENT_SIGNATURE = *mut SCHANNEL_CLIENT_SIGNATURE; pub const SP_PROT_PCT1_SERVER: ::DWORD = 0x00000001; pub const SP_PROT_PCT1_CLIENT: ::DWORD = 0x00000002; pub const SP_PROT_PCT1: ::DWORD = SP_PROT_PCT1_SERVER | SP_PROT_PCT1_CLIENT; pub const SP_PROT_SSL2_SERVER: ::DWORD = 0x00000004; pub const SP_PROT_SSL2_CLIENT: ::DWORD = 0x00000008; pub const SP_PROT_SSL2: ::DWORD = SP_PROT_SSL2_SERVER | SP_PROT_SSL2_CLIENT; pub const SP_PROT_SSL3_SERVER: ::DWORD = 0x00000010; pub const SP_PROT_SSL3_CLIENT: ::DWORD = 0x00000020; pub const SP_PROT_SSL3: ::DWORD = SP_PROT_SSL3_SERVER | SP_PROT_SSL3_CLIENT; pub const SP_PROT_TLS1_SERVER: ::DWORD = 0x00000040; pub const SP_PROT_TLS1_CLIENT: ::DWORD = 0x00000080; pub const SP_PROT_TLS1: ::DWORD = SP_PROT_TLS1_SERVER | SP_PROT_TLS1_CLIENT; pub const SP_PROT_SSL3TLS1_CLIENTS: ::DWORD = SP_PROT_TLS1_CLIENT | SP_PROT_SSL3_CLIENT; pub const SP_PROT_SSL3TLS1_SERVERS: ::DWORD = SP_PROT_TLS1_SERVER | SP_PROT_SSL3_SERVER; pub const SP_PROT_SSL3TLS1: ::DWORD = SP_PROT_SSL3 | SP_PROT_TLS1; pub const SP_PROT_UNI_SERVER: ::DWORD = 0x40000000; pub const SP_PROT_UNI_CLIENT: ::DWORD = 0x80000000; pub const SP_PROT_UNI: ::DWORD = SP_PROT_UNI_SERVER | SP_PROT_UNI_CLIENT; pub const SP_PROT_ALL: ::DWORD = 0xffffffff; pub const SP_PROT_NONE: ::DWORD = 0; pub const SP_PROT_CLIENTS: ::DWORD = SP_PROT_PCT1_CLIENT | SP_PROT_SSL2_CLIENT | SP_PROT_SSL3_CLIENT | SP_PROT_UNI_CLIENT | SP_PROT_TLS1_CLIENT; pub const SP_PROT_SERVERS: ::DWORD = SP_PROT_PCT1_SERVER | SP_PROT_SSL2_SERVER | SP_PROT_SSL3_SERVER | SP_PROT_UNI_SERVER | SP_PROT_TLS1_SERVER; pub const SP_PROT_TLS1_0_SERVER: ::DWORD = SP_PROT_TLS1_SERVER; pub const SP_PROT_TLS1_0_CLIENT: ::DWORD = SP_PROT_TLS1_CLIENT; pub const SP_PROT_TLS1_0: ::DWORD = SP_PROT_TLS1_0_SERVER | SP_PROT_TLS1_0_CLIENT; pub const SP_PROT_TLS1_1_SERVER: ::DWORD = 0x00000100; pub const SP_PROT_TLS1_1_CLIENT: ::DWORD = 0x00000200; pub const SP_PROT_TLS1_1: ::DWORD = SP_PROT_TLS1_1_SERVER | SP_PROT_TLS1_1_CLIENT; pub const SP_PROT_TLS1_2_SERVER: ::DWORD = 0x00000400; pub const SP_PROT_TLS1_2_CLIENT: ::DWORD = 0x00000800; pub const SP_PROT_TLS1_2: ::DWORD = SP_PROT_TLS1_2_SERVER | SP_PROT_TLS1_2_CLIENT; pub const SP_PROT_DTLS_SERVER: ::DWORD = 0x00010000; pub const SP_PROT_DTLS_CLIENT: ::DWORD = 0x00020000; pub const SP_PROT_DTLS: ::DWORD = SP_PROT_DTLS_SERVER | SP_PROT_DTLS_CLIENT; pub const SP_PROT_DTLS1_0_SERVER: ::DWORD = SP_PROT_DTLS_SERVER; pub const SP_PROT_DTLS1_0_CLIENT: ::DWORD = SP_PROT_DTLS_CLIENT; pub const SP_PROT_DTLS1_0: ::DWORD = SP_PROT_DTLS1_0_SERVER | SP_PROT_DTLS1_0_CLIENT; pub const SP_PROT_DTLS1_X_SERVER: ::DWORD = SP_PROT_DTLS1_0_SERVER; pub const SP_PROT_DTLS1_X_CLIENT: ::DWORD = SP_PROT_DTLS1_0_CLIENT; pub const SP_PROT_DTLS1_X: ::DWORD = SP_PROT_DTLS1_X_SERVER | SP_PROT_DTLS1_X_CLIENT; pub const SP_PROT_TLS1_1PLUS_SERVER: ::DWORD = SP_PROT_TLS1_1_SERVER | SP_PROT_TLS1_2_SERVER; pub const SP_PROT_TLS1_1PLUS_CLIENT: ::DWORD = SP_PROT_TLS1_1_CLIENT | SP_PROT_TLS1_2_CLIENT; pub const SP_PROT_TLS1_1PLUS: ::DWORD = SP_PROT_TLS1_1PLUS_SERVER | SP_PROT_TLS1_1PLUS_CLIENT; pub const SP_PROT_TLS1_X_SERVER: ::DWORD = SP_PROT_TLS1_0_SERVER | SP_PROT_TLS1_1_SERVER | SP_PROT_TLS1_2_SERVER; pub const SP_PROT_TLS1_X_CLIENT: ::DWORD = SP_PROT_TLS1_0_CLIENT | SP_PROT_TLS1_1_CLIENT | SP_PROT_TLS1_2_CLIENT; pub const SP_PROT_TLS1_X: ::DWORD = SP_PROT_TLS1_X_SERVER | SP_PROT_TLS1_X_CLIENT; pub const SP_PROT_SSL3TLS1_X_CLIENTS: ::DWORD = SP_PROT_TLS1_X_CLIENT | SP_PROT_SSL3_CLIENT; pub const SP_PROT_SSL3TLS1_X_SERVERS: ::DWORD = SP_PROT_TLS1_X_SERVER | SP_PROT_SSL3_SERVER; pub const SP_PROT_SSL3TLS1_X: ::DWORD = SP_PROT_SSL3 | SP_PROT_TLS1_X; pub const SP_PROT_X_CLIENTS: ::DWORD = SP_PROT_CLIENTS | SP_PROT_TLS1_X_CLIENT | SP_PROT_DTLS1_X_CLIENT; pub const SP_PROT_X_SERVERS: ::DWORD = SP_PROT_SERVERS | SP_PROT_TLS1_X_SERVER | SP_PROT_DTLS1_X_SERVER; //716 pub const SCHANNEL_SECRET_TYPE_CAPI: ::DWORD = 0x00000001; pub const SCHANNEL_SECRET_PRIVKEY: ::DWORD = 0x00000002; pub const SCH_CRED_X509_CERTCHAIN: ::DWORD = 0x00000001; pub const SCH_CRED_X509_CAPI: ::DWORD = 0x00000002; pub const SCH_CRED_CERT_CONTEXT: ::DWORD = 0x00000003; //838 pub const SSL_CRACK_CERTIFICATE_NAME: &'static str = "SslCrackCertificate"; pub const SSL_FREE_CERTIFICATE_NAME: &'static str = "SslFreeCertificate"; deps/winapi-0.2.5/src/xinput.rs0000644000000000000000000001145112613167613015132 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! XInput procedure declarations, constant definitions and macros pub const XINPUT_DEVTYPE_GAMEPAD: ::BYTE = 0x01; pub const XINPUT_DEVSUBTYPE_GAMEPAD: ::BYTE = 0x01; pub const XINPUT_DEVSUBTYPE_WHEEL: ::BYTE = 0x02; pub const XINPUT_DEVSUBTYPE_ARCADE_STICK: ::BYTE = 0x03; pub const XINPUT_DEVSUBTYPE_FLIGHT_SICK: ::BYTE = 0x04; pub const XINPUT_DEVSUBTYPE_DANCE_PAD: ::BYTE = 0x05; pub const XINPUT_DEVSUBTYPE_GUITAR: ::BYTE = 0x06; pub const XINPUT_DEVSUBTYPE_DRUM_KIT: ::BYTE = 0x08; pub const XINPUT_CAPS_VOICE_SUPPORTED: ::WORD = 0x0004; pub const XINPUT_GAMEPAD_DPAD_UP: ::WORD = 0x0001; pub const XINPUT_GAMEPAD_DPAD_DOWN: ::WORD = 0x0002; pub const XINPUT_GAMEPAD_DPAD_LEFT: ::WORD = 0x0004; pub const XINPUT_GAMEPAD_DPAD_RIGHT: ::WORD = 0x0008; pub const XINPUT_GAMEPAD_START: ::WORD = 0x0010; pub const XINPUT_GAMEPAD_BACK: ::WORD = 0x0020; pub const XINPUT_GAMEPAD_LEFT_THUMB: ::WORD = 0x0040; pub const XINPUT_GAMEPAD_RIGHT_THUMB: ::WORD = 0x0080; pub const XINPUT_GAMEPAD_LEFT_SHOULDER: ::WORD = 0x0100; pub const XINPUT_GAMEPAD_RIGHT_SHOULDER: ::WORD = 0x0200; pub const XINPUT_GAMEPAD_A: ::WORD = 0x1000; pub const XINPUT_GAMEPAD_B: ::WORD = 0x2000; pub const XINPUT_GAMEPAD_X: ::WORD = 0x4000; pub const XINPUT_GAMEPAD_Y: ::WORD = 0x8000; pub const XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE: ::SHORT = 7849; pub const XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE: ::SHORT = 8689; pub const XINPUT_GAMEPAD_TRIGGER_THRESHOLD: ::BYTE = 30; pub const XINPUT_FLAG_GAMEPAD: ::DWORD = 0x00000001; pub const BATTERY_DEVTYPE_GAMEPAD: ::BYTE = 0x00; pub const BATTERY_DEVTYPE_HEADSET: ::BYTE = 0x01; pub const BATTERY_TYPE_DISCONNECTED: ::BYTE = 0x00; pub const BATTERY_TYPE_WIRED: ::BYTE = 0x01; pub const BATTERY_TYPE_ALKALINE: ::BYTE = 0x02; pub const BATTERY_TYPE_NIMH: ::BYTE = 0x03; pub const BATTERY_TYPE_UNKNOWN: ::BYTE = 0xFF; pub const BATTERY_LEVEL_EMPTY: ::BYTE = 0x00; pub const BATTERY_LEVEL_LOW: ::BYTE = 0x01; pub const BATTERY_LEVEL_MEDIUM: ::BYTE = 0x02; pub const BATTERY_LEVEL_FULL: ::BYTE = 0x03; pub const XUSER_MAX_COUNT: ::DWORD = 4; pub const XUSER_INDEX_ANY: ::DWORD = 0x000000FF; pub const VK_PAD_A: ::WORD = 0x5800; pub const VK_PAD_B: ::WORD = 0x5801; pub const VK_PAD_X: ::WORD = 0x5802; pub const VK_PAD_Y: ::WORD = 0x5803; pub const VK_PAD_RSHOULDER: ::WORD = 0x5804; pub const VK_PAD_LSHOULDER: ::WORD = 0x5805; pub const VK_PAD_LTRIGGER: ::WORD = 0x5806; pub const VK_PAD_RTRIGGER: ::WORD = 0x5807; pub const VK_PAD_DPAD_UP: ::WORD = 0x5810; pub const VK_PAD_DPAD_DOWN: ::WORD = 0x5811; pub const VK_PAD_DPAD_LEFT: ::WORD = 0x5812; pub const VK_PAD_DPAD_RIGHT: ::WORD = 0x5813; pub const VK_PAD_START: ::WORD = 0x5814; pub const VK_PAD_BACK: ::WORD = 0x5815; pub const VK_PAD_LTHUMB_PRESS: ::WORD = 0x5816; pub const VK_PAD_RTHUMB_PRESS: ::WORD = 0x5817; pub const VK_PAD_LTHUMB_UP: ::WORD = 0x5820; pub const VK_PAD_LTHUMB_DOWN: ::WORD = 0x5821; pub const VK_PAD_LTHUMB_RIGHT: ::WORD = 0x5822; pub const VK_PAD_LTHUMB_LEFT: ::WORD = 0x5823; pub const VK_PAD_LTHUMB_UPLEFT: ::WORD = 0x5824; pub const VK_PAD_LTHUMB_UPRIGHT: ::WORD = 0x5825; pub const VK_PAD_LTHUMB_DOWNRIGHT: ::WORD = 0x5826; pub const VK_PAD_LTHUMB_DOWNLEFT: ::WORD = 0x5827; pub const VK_PAD_RTHUMB_UP: ::WORD = 0x5830; pub const VK_PAD_RTHUMB_DOWN: ::WORD = 0x5831; pub const VK_PAD_RTHUMB_RIGHT: ::WORD = 0x5832; pub const VK_PAD_RTHUMB_LEFT: ::WORD = 0x5833; pub const VK_PAD_RTHUMB_UPLEFT: ::WORD = 0x5834; pub const VK_PAD_RTHUMB_UPRIGHT: ::WORD = 0x5835; pub const VK_PAD_RTHUMB_DOWNRIGHT: ::WORD = 0x5836; pub const VK_PAD_RTHUMB_DOWNLEFT: ::WORD = 0x5837; pub const XINPUT_KEYSTROKE_KEYDOWN: ::WORD = 0x0001; pub const XINPUT_KEYSTROKE_KEYUP: ::WORD = 0x0002; pub const XINPUT_KEYSTROKE_REPEAT: ::WORD = 0x0004; STRUCT!{struct XINPUT_GAMEPAD { wButtons: ::WORD, bLeftTrigger: ::BYTE, bRightTrigger: ::BYTE, sThumbLX: ::SHORT, sThumbLY: ::SHORT, sThumbRX: ::SHORT, sThumbRY: ::SHORT, }} pub type PXINPUT_GAMEPAD = *mut XINPUT_GAMEPAD; STRUCT!{struct XINPUT_STATE { dwPacketNumber: ::DWORD, Gamepad: ::XINPUT_GAMEPAD, }} pub type PXINPUT_STATE = *mut XINPUT_STATE; STRUCT!{struct XINPUT_VIBRATION { wLeftMotorSpeed: ::WORD, wRightMotorSpeed: ::WORD, }} pub type PXINPUT_VIBRATION = *mut XINPUT_VIBRATION; STRUCT!{struct XINPUT_CAPABILITIES { Type: ::BYTE, SubType: ::BYTE, Flags: ::WORD, Gamepad: ::XINPUT_GAMEPAD, Vibration: ::XINPUT_VIBRATION, }} pub type PXINPUT_CAPABILITIES = *mut XINPUT_CAPABILITIES; STRUCT!{struct XINPUT_BATTERY_INFORMATION { BatteryType: ::BYTE, BatteryLevel: ::BYTE, }} pub type PXINPUT_BATTERY_INFORMATION = *mut XINPUT_BATTERY_INFORMATION; STRUCT!{struct XINPUT_KEYSTROKE { VirtualKey: ::WORD, Unicode: ::WCHAR, UserIndex: ::BYTE, HidCode: ::BYTE, }} pub type PXINPUT_KEYSTROKE = *mut XINPUT_KEYSTROKE; deps/winapi-0.2.5/src/windowsx.rs0000644000000000000000000000144112605021254015452 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Macro APIs, window message crackers, and control APIs //1233 pub fn GET_X_LPARAM(lp: ::LPARAM) -> ::c_int { ::LOWORD(lp as ::DWORD) as ::c_short as ::c_int } pub fn GET_Y_LPARAM(lp: ::LPARAM) -> ::c_int { ::HIWORD(lp as ::DWORD) as ::c_short as ::c_int } #[test] fn test_get_x_lparam() { assert_eq!(GET_X_LPARAM(0xDEAD1234u32 as ::LPARAM), 0x1234); assert_eq!(GET_X_LPARAM(0xBEEFffffu32 as ::LPARAM), -1); assert_eq!(GET_X_LPARAM(0xCAFEFB2Eu32 as ::LPARAM), -1234); } #[test] fn test_get_y_lparam() { assert_eq!(GET_Y_LPARAM(0x1234DEADu32 as ::LPARAM), 0x1234); assert_eq!(GET_Y_LPARAM(0xffffBEEFu32 as ::LPARAM), -1); assert_eq!(GET_Y_LPARAM(0xFB2ECAFEu32 as ::LPARAM), -1234); } deps/winapi-0.2.5/src/imm.rs0000644000000000000000000000016512605021253014353 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License pub type LPUINT = *mut ::c_uint; deps/winapi-0.2.5/src/wincon.rs0000644000000000000000000001674012615457243015111 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! This module contains the public data structures, data types, and procedures exported by the NT //! console subsystem. STRUCT!{struct COORD { X: ::SHORT, Y: ::SHORT, }} pub type PCOORD = *mut COORD; STRUCT!{struct SMALL_RECT { Left: ::SHORT, Top: ::SHORT, Right: ::SHORT, Bottom: ::SHORT, }} pub type PSMALL_RECT = *mut SMALL_RECT; STRUCT!{struct KEY_EVENT_RECORD { bKeyDown: ::BOOL, wRepeatCount: ::WORD, wVirtualKeyCode: ::WORD, wVirtualScanCode: ::WORD, UnicodeChar: ::WCHAR, dwControlKeyState: ::DWORD, }} UNION!{KEY_EVENT_RECORD, UnicodeChar, AsciiChar, AsciiChar_mut, ::CHAR} pub type PKEY_EVENT_RECORD = *mut KEY_EVENT_RECORD; pub const RIGHT_ALT_PRESSED: ::DWORD = 0x0001; pub const LEFT_ALT_PRESSED: ::DWORD = 0x0002; pub const RIGHT_CTRL_PRESSED: ::DWORD = 0x0004; pub const LEFT_CTRL_PRESSED: ::DWORD = 0x0008; pub const SHIFT_PRESSED: ::DWORD = 0x0010; pub const NUMLOCK_ON: ::DWORD = 0x0020; pub const SCROLLLOCK_ON: ::DWORD = 0x0040; pub const CAPSLOCK_ON: ::DWORD = 0x0080; pub const ENHANCED_KEY: ::DWORD = 0x0100; pub const NLS_DBCSCHAR: ::DWORD = 0x00010000; pub const NLS_ALPHANUMERIC: ::DWORD = 0x00000000; pub const NLS_KATAKANA: ::DWORD = 0x00020000; pub const NLS_HIRAGANA: ::DWORD = 0x00040000; pub const NLS_ROMAN: ::DWORD = 0x00400000; pub const NLS_IME_CONVERSION: ::DWORD = 0x00800000; pub const NLS_IME_DISABLE: ::DWORD = 0x20000000; STRUCT!{struct MOUSE_EVENT_RECORD { dwMousePosition: COORD, dwButtonState: ::DWORD, dwControlKeyState: ::DWORD, dwEventFlags: ::DWORD, }} pub type PMOUSE_EVENT_RECORD = *mut MOUSE_EVENT_RECORD; pub const FROM_LEFT_1ST_BUTTON_PRESSED: ::DWORD = 0x0001; pub const RIGHTMOST_BUTTON_PRESSED: ::DWORD = 0x0002; pub const FROM_LEFT_2ND_BUTTON_PRESSED: ::DWORD = 0x0004; pub const FROM_LEFT_3RD_BUTTON_PRESSED: ::DWORD = 0x0008; pub const FROM_LEFT_4TH_BUTTON_PRESSED: ::DWORD = 0x0010; pub const MOUSE_MOVED: ::DWORD = 0x0001; pub const DOUBLE_CLICK: ::DWORD = 0x0002; pub const MOUSE_WHEELED: ::DWORD = 0x0004; pub const MOUSE_HWHEELED: ::DWORD = 0x0008; STRUCT!{struct WINDOW_BUFFER_SIZE_RECORD { dwSize: COORD, }} pub type PWINDOW_BUFFER_SIZE_RECORD = *mut WINDOW_BUFFER_SIZE_RECORD; STRUCT!{struct MENU_EVENT_RECORD { dwCommandId: ::UINT, }} pub type PMENU_EVENT_RECORD = *mut MENU_EVENT_RECORD; STRUCT!{struct FOCUS_EVENT_RECORD { bSetFocus: ::BOOL, }} pub type PFOCUS_EVENT_RECORD = *mut FOCUS_EVENT_RECORD; STRUCT!{struct INPUT_RECORD { EventType: ::WORD, Event: [u32; 4], }} UNION!{INPUT_RECORD, Event, KeyEvent, KeyEvent_mut, KEY_EVENT_RECORD} UNION!{INPUT_RECORD, Event, MouseEvent, MouseEvent_mut, MOUSE_EVENT_RECORD} UNION!{INPUT_RECORD, Event, WindowBufferSizeEvent, WindowBufferSizeEvent_mut, WINDOW_BUFFER_SIZE_RECORD} UNION!{INPUT_RECORD, Event, MenuEvent, MenuEvent_mut, MENU_EVENT_RECORD} UNION!{INPUT_RECORD, Event, FocusEvent, FocusEvent_mut, FOCUS_EVENT_RECORD} pub type PINPUT_RECORD = *mut INPUT_RECORD; pub const KEY_EVENT: ::WORD = 0x0001; pub const MOUSE_EVENT: ::WORD = 0x0002; pub const WINDOW_BUFFER_SIZE_EVENT: ::WORD = 0x0004; pub const MENU_EVENT: ::WORD = 0x0008; pub const FOCUS_EVENT: ::WORD = 0x0010; STRUCT!{struct CHAR_INFO { UnicodeChar: ::WCHAR, Attributes: ::WORD, }} UNION!{CHAR_INFO, UnicodeChar, AsciiChar, AsciiChar_mut, ::CHAR} pub type PCHAR_INFO = *mut CHAR_INFO; pub const FOREGROUND_BLUE: ::DWORD = 0x0001; pub const FOREGROUND_GREEN: ::DWORD = 0x0002; pub const FOREGROUND_RED: ::DWORD = 0x0004; pub const FOREGROUND_INTENSITY: ::DWORD = 0x0008; pub const BACKGROUND_BLUE: ::DWORD = 0x0010; pub const BACKGROUND_GREEN: ::DWORD = 0x0020; pub const BACKGROUND_RED: ::DWORD = 0x0040; pub const BACKGROUND_INTENSITY: ::DWORD = 0x0080; pub const COMMON_LVB_LEADING_BYTE: ::DWORD = 0x0100; pub const COMMON_LVB_TRAILING_BYTE: ::DWORD = 0x0200; pub const COMMON_LVB_GRID_HORIZONTAL: ::DWORD = 0x0400; pub const COMMON_LVB_GRID_LVERTICAL: ::DWORD = 0x0800; pub const COMMON_LVB_GRID_RVERTICAL: ::DWORD = 0x1000; pub const COMMON_LVB_REVERSE_VIDEO: ::DWORD = 0x4000; pub const COMMON_LVB_UNDERSCORE: ::DWORD = 0x8000; pub const COMMON_LVB_SBCSDBCS: ::DWORD = 0x0300; STRUCT!{struct CONSOLE_SCREEN_BUFFER_INFO { dwSize: COORD, dwCursorPosition: COORD, wAttributes: ::WORD, srWindow: SMALL_RECT, dwMaximumWindowSize: COORD, }} pub type PCONSOLE_SCREEN_BUFFER_INFO = *mut CONSOLE_SCREEN_BUFFER_INFO; STRUCT!{struct CONSOLE_SCREEN_BUFFER_INFOEX { cbSize: ::ULONG, dwSize: COORD, dwCursorPosition: COORD, wAttributes: ::WORD, srWindow: SMALL_RECT, dwMaximumWindowSize: COORD, wPopupAttributes: ::WORD, bFullscreenSupported: ::BOOL, ColorTable: [::COLORREF; 16], }} pub type PCONSOLE_SCREEN_BUFFER_INFOEX = *mut CONSOLE_SCREEN_BUFFER_INFOEX; STRUCT!{struct CONSOLE_CURSOR_INFO { dwSize: ::DWORD, bVisible: ::BOOL, }} pub type PCONSOLE_CURSOR_INFO = *mut CONSOLE_CURSOR_INFO; STRUCT!{struct CONSOLE_FONT_INFO { nFont: ::DWORD, dwFontSize: ::COORD, }} pub type PCONSOLE_FONT_INFO = *mut CONSOLE_FONT_INFO; STRUCT!{struct CONSOLE_FONT_INFOEX { cbSize: ::ULONG, nFont: ::DWORD, dwFontSize: COORD, FontFamily: ::UINT, FontWeight: ::UINT, FaceName: [::WCHAR; ::LF_FACESIZE], }} pub type PCONSOLE_FONT_INFOEX = *mut CONSOLE_FONT_INFOEX; pub const HISTORY_NO_DUP_FLAG: ::DWORD = 0x1; STRUCT!{struct CONSOLE_HISTORY_INFO { cbSize: ::UINT, HistoryBufferSize: ::UINT, NumberOfHistoryBuffers: ::UINT, dwFlags: ::DWORD, }} pub type PCONSOLE_HISTORY_INFO = *mut CONSOLE_HISTORY_INFO; STRUCT!{struct CONSOLE_SELECTION_INFO { dwFlags: ::DWORD, dwSelectionAnchor: COORD, srSelection: SMALL_RECT, }} pub type PCONSOLE_SELECTION_INFO = *mut CONSOLE_SELECTION_INFO; pub const CONSOLE_NO_SELECTION: ::DWORD = 0x0000; pub const CONSOLE_SELECTION_IN_PROGRESS: ::DWORD = 0x0001; pub const CONSOLE_SELECTION_NOT_EMPTY: ::DWORD = 0x0002; pub const CONSOLE_MOUSE_SELECTION: ::DWORD = 0x0004; pub const CONSOLE_MOUSE_DOWN: ::DWORD = 0x0008; pub type PHANDLER_ROUTINE = Option ::BOOL>; pub const CTRL_C_EVENT: ::DWORD = 0; pub const CTRL_BREAK_EVENT: ::DWORD = 1; pub const CTRL_CLOSE_EVENT: ::DWORD = 2; pub const CTRL_LOGOFF_EVENT: ::DWORD = 5; pub const CTRL_SHUTDOWN_EVENT: ::DWORD = 6; pub const ENABLE_PROCESSED_INPUT: ::DWORD = 0x0001; pub const ENABLE_LINE_INPUT: ::DWORD = 0x0002; pub const ENABLE_ECHO_INPUT: ::DWORD = 0x0004; pub const ENABLE_WINDOW_INPUT: ::DWORD = 0x0008; pub const ENABLE_MOUSE_INPUT: ::DWORD = 0x0010; pub const ENABLE_INSERT_MODE: ::DWORD = 0x0020; pub const ENABLE_QUICK_EDIT_MODE: ::DWORD = 0x0040; pub const ENABLE_EXTENDED_FLAGS: ::DWORD = 0x0080; pub const ENABLE_AUTO_POSITION: ::DWORD = 0x0100; pub const ENABLE_PROCESSED_OUTPUT: ::DWORD = 0x0001; pub const ENABLE_WRAP_AT_EOL_OUTPUT: ::DWORD = 0x0002; pub const CONSOLE_REAL_OUTPUT_HANDLE: *mut ::c_void = -2isize as *mut ::c_void; pub const CONSOLE_REAL_INPUT_HANDLE: *mut ::c_void = -3isize as *mut ::c_void; pub const ATTACH_PARENT_PROCESS: ::DWORD = 0xFFFFFFFF; STRUCT!{struct CONSOLE_READCONSOLE_CONTROL { nLength: ::ULONG, nInitialChars: ::ULONG, dwCtrlWakeupMask: ::ULONG, dwControlKeyState: ::ULONG, }} pub type PCONSOLE_READCONSOLE_CONTROL = *mut CONSOLE_READCONSOLE_CONTROL; pub const CONSOLE_TEXTMODE_BUFFER: ::DWORD = 1; pub const CONSOLE_FULLSCREEN: ::DWORD = 1; pub const CONSOLE_FULLSCREEN_HARDWARE: ::DWORD = 2; pub const CONSOLE_FULLSCREEN_MODE: ::DWORD = 1; pub const CONSOLE_WINDOWED_MODE: ::DWORD = 2; deps/winapi-0.2.5/src/bcrypt.rs0000644000000000000000000003134712613002520015075 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Cryptographic Primitive API Prototypes and Definitions pub const KDF_HASH_ALGORITHM: ::ULONG = 0x0; pub const KDF_SECRET_PREPEND: ::ULONG = 0x1; pub const KDF_SECRET_APPEND: ::ULONG = 0x2; pub const KDF_HMAC_KEY: ::ULONG = 0x3; pub const KDF_TLS_PRF_LABEL: ::ULONG = 0x4; pub const KDF_TLS_PRF_SEED: ::ULONG = 0x5; pub const KDF_SECRET_HANDLE: ::ULONG = 0x6; pub const KDF_TLS_PRF_PROTOCOL: ::ULONG = 0x7; pub const KDF_ALGORITHMID: ::ULONG = 0x8; pub const KDF_PARTYUINFO: ::ULONG = 0x9; pub const KDF_PARTYVINFO: ::ULONG = 0xA; pub const KDF_SUPPPUBINFO: ::ULONG = 0xB; pub const KDF_SUPPPRIVINFO: ::ULONG = 0xC; pub const KDF_LABEL: ::ULONG = 0xD; pub const KDF_CONTEXT: ::ULONG = 0xE; pub const KDF_SALT: ::ULONG = 0xF; pub const KDF_ITERATION_COUNT: ::ULONG = 0x10; pub const KDF_GENERIC_PARAMETER: ::ULONG = 0x11; pub const KDF_KEYBITLENGTH: ::ULONG = 0x12; pub const KDF_USE_SECRET_AS_HMAC_KEY_FLAG: ::ULONG = 0x1; STRUCT!{struct BCRYPT_KEY_LENGTHS_STRUCT { dwMinLength: ::ULONG, dwMaxLength: ::ULONG, dwIncrement: ::ULONG, }} pub type BCRYPT_AUTH_TAG_LENGTHS_STRUCT = BCRYPT_KEY_LENGTHS_STRUCT; STRUCT!{struct BCRYPT_OID { cbOID: ::ULONG, pbOID: ::PUCHAR, }} STRUCT!{struct BCRYPT_OID_LIST { dwOIDCount: ::ULONG, pOIDs: *mut BCRYPT_OID, }} STRUCT!{struct BCRYPT_PKCS1_PADDING_INFO { pszAlgId: ::LPCWSTR, }} STRUCT!{struct BCRYPT_PSS_PADDING_INFO { pszAlgId: ::LPCWSTR, cbSalt: ::ULONG, }} STRUCT!{struct BCRYPT_OAEP_PADDING_INFO { pszAlgId: ::LPCWSTR, pbLabel: ::PUCHAR, cbLabel: ::ULONG, }} pub const BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO_VERSION: ::ULONG = 1; pub const BCRYPT_AUTH_MODE_CHAIN_CALLS_FLAG: ::ULONG = 0x00000001; pub const BCRYPT_AUTH_MODE_IN_PROGRESS_FLAG: ::ULONG = 0x00000002; STRUCT!{struct BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO { cbSize: ::ULONG, dwInfoVersion: ::ULONG, pbNonce: ::PUCHAR, cbNonce: ::ULONG, pbAuthData: ::PUCHAR, cbAuthData: ::ULONG, pbTag: ::PUCHAR, cbTag: ::ULONG, pbMacContext: ::PUCHAR, cbMacContext: ::ULONG, cbAAD: ::ULONG, cbData: ::ULONGLONG, dwFlags: ::ULONG, }} pub type PBCRYPT_AUTHENTICATED_CIPHER_MODE_INFO = *mut BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO; pub const BCRYPT_PROV_DISPATCH: ::ULONG = 0x00000001; pub const BCRYPT_BLOCK_PADDING: ::ULONG = 0x00000001; pub const BCRYPT_PAD_NONE: ::ULONG = 0x00000001; pub const BCRYPT_PAD_PKCS1: ::ULONG = 0x00000002; pub const BCRYPT_PAD_OAEP: ::ULONG = 0x00000004; pub const BCRYPT_PAD_PSS: ::ULONG = 0x00000008; pub const BCRYPT_PAD_PKCS1_OPTIONAL_HASH_OID: ::ULONG = 0x00000010; pub const BCRYPTBUFFER_VERSION: ::ULONG = 0; STRUCT!{struct BCryptBuffer { cbBuffer: ::ULONG, BufferType: ::ULONG, pvBuffer: ::PVOID, }} pub type PBCryptBuffer = *mut BCryptBuffer; STRUCT!{struct BCryptBufferDesc { ulVersion: ::ULONG, cBuffers: ::ULONG, pBuffers: PBCryptBuffer, }} pub type PBCryptBufferDesc = *mut BCryptBufferDesc; //321 pub type BCRYPT_HANDLE = ::PVOID; pub type BCRYPT_ALG_HANDLE = ::PVOID; pub type BCRYPT_KEY_HANDLE = ::PVOID; pub type BCRYPT_HASH_HANDLE = ::PVOID; pub type BCRYPT_SECRET_HANDLE = ::PVOID; STRUCT!{struct BCRYPT_KEY_BLOB { Magic: ::ULONG, }} pub const BCRYPT_RSAPUBLIC_MAGIC: ::ULONG = 0x31415352; pub const BCRYPT_RSAPRIVATE_MAGIC: ::ULONG = 0x32415352; STRUCT!{struct BCRYPT_RSAKEY_BLOB { Magic: ::ULONG, BitLength: ::ULONG, cbPublicExp: ::ULONG, cbModulus: ::ULONG, cbPrime1: ::ULONG, cbPrime2: ::ULONG, }} pub const BCRYPT_RSAFULLPRIVATE_MAGIC: ::ULONG = 0x33415352; pub const BCRYPT_ECDH_PUBLIC_P256_MAGIC: ::ULONG = 0x314B4345; pub const BCRYPT_ECDH_PRIVATE_P256_MAGIC: ::ULONG = 0x324B4345; pub const BCRYPT_ECDH_PUBLIC_P384_MAGIC: ::ULONG = 0x334B4345; pub const BCRYPT_ECDH_PRIVATE_P384_MAGIC: ::ULONG = 0x344B4345; pub const BCRYPT_ECDH_PUBLIC_P521_MAGIC: ::ULONG = 0x354B4345; pub const BCRYPT_ECDH_PRIVATE_P521_MAGIC: ::ULONG = 0x364B4345; pub const BCRYPT_ECDSA_PUBLIC_P256_MAGIC: ::ULONG = 0x31534345; pub const BCRYPT_ECDSA_PRIVATE_P256_MAGIC: ::ULONG = 0x32534345; pub const BCRYPT_ECDSA_PUBLIC_P384_MAGIC: ::ULONG = 0x33534345; pub const BCRYPT_ECDSA_PRIVATE_P384_MAGIC: ::ULONG = 0x34534345; pub const BCRYPT_ECDSA_PUBLIC_P521_MAGIC: ::ULONG = 0x35534345; pub const BCRYPT_ECDSA_PRIVATE_P521_MAGIC: ::ULONG = 0x36534345; STRUCT!{struct BCRYPT_ECCKEY_BLOB { dwMagic: ::ULONG, cbKey: ::ULONG, }} pub type PBCRYPT_ECCKEY_BLOB = *mut BCRYPT_ECCKEY_BLOB; pub const BCRYPT_DH_PUBLIC_MAGIC: ::ULONG = 0x42504844; pub const BCRYPT_DH_PRIVATE_MAGIC: ::ULONG = 0x56504844; STRUCT!{struct BCRYPT_DH_KEY_BLOB { dwMagic: ::ULONG, cbKey: ::ULONG, }} pub type PBCRYPT_DH_KEY_BLOB = *mut BCRYPT_DH_KEY_BLOB; pub const BCRYPT_DH_PARAMETERS_MAGIC: ::ULONG = 0x4d504844; STRUCT!{struct BCRYPT_DH_PARAMETER_HEADER { cbLength: ::ULONG, dwMagic: ::ULONG, cbKeyLength: ::ULONG, }} pub const BCRYPT_DSA_PUBLIC_MAGIC: ::ULONG = 0x42505344; pub const BCRYPT_DSA_PRIVATE_MAGIC: ::ULONG = 0x56505344; pub const BCRYPT_DSA_PUBLIC_MAGIC_V2: ::ULONG = 0x32425044; pub const BCRYPT_DSA_PRIVATE_MAGIC_V2: ::ULONG = 0x32565044; STRUCT!{struct BCRYPT_DSA_KEY_BLOB { dwMagic: ::ULONG, cbKey: ::ULONG, Count: [::UCHAR; 4], Seed: [::UCHAR; 20], q: [::UCHAR; 20], }} pub type PBCRYPT_DSA_KEY_BLOB = *mut BCRYPT_DSA_KEY_BLOB; ENUM!{enum HASHALGORITHM_ENUM { DSA_HASH_ALGORITHM_SHA1, DSA_HASH_ALGORITHM_SHA256, DSA_HASH_ALGORITHM_SHA512, }} ENUM!{enum DSAFIPSVERSION_ENUM { DSA_FIPS186_2, DSA_FIPS186_3, }} STRUCT!{struct BCRYPT_DSA_KEY_BLOB_V2 { dwMagic: ::ULONG, cbKey: ::ULONG, hashAlgorithm: HASHALGORITHM_ENUM, standardVersion: DSAFIPSVERSION_ENUM, cbSeedLength: ::ULONG, cbGroupSize: ::ULONG, Count: [::UCHAR; 4], }} pub type PBCRYPT_DSA_KEY_BLOB_V2 = *mut BCRYPT_DSA_KEY_BLOB_V2; STRUCT!{struct BCRYPT_KEY_DATA_BLOB_HEADER { dwMagic: ::ULONG, dwVersion: ::ULONG, cbKeyData: ::ULONG, }} pub type PBCRYPT_KEY_DATA_BLOB_HEADER = *mut BCRYPT_KEY_DATA_BLOB_HEADER; pub const BCRYPT_KEY_DATA_BLOB_MAGIC: ::ULONG = 0x4d42444b; pub const BCRYPT_KEY_DATA_BLOB_VERSION1: ::ULONG = 0x1; pub const BCRYPT_DSA_PARAMETERS_MAGIC: ::ULONG = 0x4d505344; pub const BCRYPT_DSA_PARAMETERS_MAGIC_V2: ::ULONG = 0x324d5044; STRUCT!{struct BCRYPT_DSA_PARAMETER_HEADER { cbLength: ::ULONG, dwMagic: ::ULONG, cbKeyLength: ::ULONG, Count: [::UCHAR; 4], Seed: [::UCHAR; 20], q: [::UCHAR; 20], }} STRUCT!{struct BCRYPT_DSA_PARAMETER_HEADER_V2 { cbLength: ::ULONG, dwMagic: ::ULONG, cbKeyLength: ::ULONG, hashAlgorithm: HASHALGORITHM_ENUM, standardVersion: DSAFIPSVERSION_ENUM, cbSeedLength: ::ULONG, cbGroupSize: ::ULONG, Count: [::UCHAR; 4], }} ENUM!{enum BCRYPT_HASH_OPERATION_TYPE { BCRYPT_HASH_OPERATION_HASH_DATA = 1, BCRYPT_HASH_OPERATION_FINISH_HASH = 2, }} STRUCT!{struct BCRYPT_MULTI_HASH_OPERATION { iHash: ::ULONG, hashOperation: BCRYPT_HASH_OPERATION_TYPE, pbBuffer: ::PUCHAR, cbBuffer: ::ULONG, }} ENUM!{enum BCRYPT_MULTI_OPERATION_TYPE { BCRYPT_OPERATION_TYPE_HASH = 1, }} STRUCT!{struct BCRYPT_MULTI_OBJECT_LENGTH_STRUCT { cbPerObject: ::ULONG, cbPerElement: ::ULONG, }} pub const BCRYPT_CIPHER_INTERFACE: ::ULONG = 0x00000001; pub const BCRYPT_HASH_INTERFACE: ::ULONG = 0x00000002; pub const BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE: ::ULONG = 0x00000003; pub const BCRYPT_SECRET_AGREEMENT_INTERFACE: ::ULONG = 0x00000004; pub const BCRYPT_SIGNATURE_INTERFACE: ::ULONG = 0x00000005; pub const BCRYPT_RNG_INTERFACE: ::ULONG = 0x00000006; pub const BCRYPT_KEY_DERIVATION_INTERFACE: ::ULONG = 0x00000007; pub const BCRYPT_ALG_HANDLE_HMAC_FLAG: ::ULONG = 0x00000008; pub const BCRYPT_CAPI_AES_FLAG: ::ULONG = 0x00000010; pub const BCRYPT_HASH_REUSABLE_FLAG: ::ULONG = 0x00000020; pub const BCRYPT_BUFFERS_LOCKED_FLAG: ::ULONG = 0x00000040; pub const BCRYPT_EXTENDED_KEYSIZE: ::ULONG = 0x00000080; pub const BCRYPT_CIPHER_OPERATION: ::ULONG = 0x00000001; pub const BCRYPT_HASH_OPERATION: ::ULONG = 0x00000002; pub const BCRYPT_ASYMMETRIC_ENCRYPTION_OPERATION: ::ULONG = 0x00000004; pub const BCRYPT_SECRET_AGREEMENT_OPERATION: ::ULONG = 0x00000008; pub const BCRYPT_SIGNATURE_OPERATION: ::ULONG = 0x00000010; pub const BCRYPT_RNG_OPERATION: ::ULONG = 0x00000020; pub const BCRYPT_KEY_DERIVATION_OPERATION: ::ULONG = 0x00000040; STRUCT!{struct BCRYPT_ALGORITHM_IDENTIFIER { pszName: ::LPWSTR, dwClass: ::ULONG, dwFlags: ::ULONG, }} STRUCT!{struct BCRYPT_PROVIDER_NAME { pszProviderName: ::LPWSTR, }} pub const BCRYPT_PUBLIC_KEY_FLAG: ::ULONG = 0x00000001; pub const BCRYPT_PRIVATE_KEY_FLAG: ::ULONG = 0x00000002; pub const BCRYPT_RNG_USE_ENTROPY_IN_BUFFER: ::ULONG = 0x00000001; pub const BCRYPT_USE_SYSTEM_PREFERRED_RNG: ::ULONG = 0x00000002; STRUCT!{struct BCRYPT_INTERFACE_VERSION { MajorVersion: ::USHORT, MinorVersion: ::USHORT, }} pub type PBCRYPT_INTERFACE_VERSION = *mut BCRYPT_INTERFACE_VERSION; pub const BCRYPT_CIPHER_INTERFACE_VERSION_1: BCRYPT_INTERFACE_VERSION = BCRYPT_MAKE_INTERFACE_VERSION!(1, 0); pub const BCRYPT_HASH_INTERFACE_VERSION_1: BCRYPT_INTERFACE_VERSION = BCRYPT_MAKE_INTERFACE_VERSION!(1, 0); pub const BCRYPT_HASH_INTERFACE_MAJORVERSION_2: ::USHORT = 2; pub const BCRYPT_HASH_INTERFACE_VERSION_2: BCRYPT_INTERFACE_VERSION = BCRYPT_MAKE_INTERFACE_VERSION!(BCRYPT_HASH_INTERFACE_MAJORVERSION_2, 0); pub const BCRYPT_ASYMMETRIC_ENCRYPTION_INTERFACE_VERSION_1: BCRYPT_INTERFACE_VERSION = BCRYPT_MAKE_INTERFACE_VERSION!(1, 0); pub const BCRYPT_SECRET_AGREEMENT_INTERFACE_VERSION_1: BCRYPT_INTERFACE_VERSION = BCRYPT_MAKE_INTERFACE_VERSION!(1, 0); pub const BCRYPT_SIGNATURE_INTERFACE_VERSION_1: BCRYPT_INTERFACE_VERSION = BCRYPT_MAKE_INTERFACE_VERSION!(1, 0); pub const BCRYPT_RNG_INTERFACE_VERSION_1: BCRYPT_INTERFACE_VERSION = BCRYPT_MAKE_INTERFACE_VERSION!(1, 0); pub const CRYPT_MIN_DEPENDENCIES: ::ULONG = 0x00000001; pub const CRYPT_PROCESS_ISOLATE: ::ULONG = 0x00010000; pub const CRYPT_UM: ::ULONG = 0x00000001; pub const CRYPT_KM: ::ULONG = 0x00000002; pub const CRYPT_MM: ::ULONG = 0x00000003; pub const CRYPT_ANY: ::ULONG = 0x00000004; pub const CRYPT_OVERWRITE: ::ULONG = 0x00000001; pub const CRYPT_LOCAL: ::ULONG = 0x00000001; pub const CRYPT_DOMAIN: ::ULONG = 0x00000002; pub const CRYPT_EXCLUSIVE: ::ULONG = 0x00000001; pub const CRYPT_OVERRIDE: ::ULONG = 0x00010000; pub const CRYPT_ALL_FUNCTIONS: ::ULONG = 0x00000001; pub const CRYPT_ALL_PROVIDERS: ::ULONG = 0x00000002; pub const CRYPT_PRIORITY_TOP: ::ULONG = 0x00000000; pub const CRYPT_PRIORITY_BOTTOM: ::ULONG = 0xFFFFFFFF; STRUCT!{struct CRYPT_INTERFACE_REG { dwInterface: ::ULONG, dwFlags: ::ULONG, cFunctions: ::ULONG, rgpszFunctions: *mut ::PWSTR, }} pub type PCRYPT_INTERFACE_REG = *mut CRYPT_INTERFACE_REG; STRUCT!{struct CRYPT_IMAGE_REG { pszImage: ::PWSTR, cInterfaces: ::ULONG, rgpInterfaces: *mut PCRYPT_INTERFACE_REG, }} pub type PCRYPT_IMAGE_REG = *mut CRYPT_IMAGE_REG; STRUCT!{struct CRYPT_PROVIDER_REG { cAliases: ::ULONG, rgpszAliases: *mut ::PWSTR, pUM: PCRYPT_IMAGE_REG, pKM: PCRYPT_IMAGE_REG, }} pub type PCRYPT_PROVIDER_REG = *mut CRYPT_PROVIDER_REG; STRUCT!{struct CRYPT_PROVIDERS { cProviders: ::ULONG, rgpszProviders: *mut ::PWSTR, }} pub type PCRYPT_PROVIDERS = *mut CRYPT_PROVIDERS; STRUCT!{struct CRYPT_CONTEXT_CONFIG { dwFlags: ::ULONG, dwReserved: ::ULONG, }} pub type PCRYPT_CONTEXT_CONFIG = *mut CRYPT_CONTEXT_CONFIG; STRUCT!{struct CRYPT_CONTEXT_FUNCTION_CONFIG { dwFlags: ::ULONG, dwReserved: ::ULONG, }} pub type PCRYPT_CONTEXT_FUNCTION_CONFIG = *mut CRYPT_CONTEXT_FUNCTION_CONFIG; STRUCT!{struct CRYPT_CONTEXTS { cContexts: ::ULONG, rgpszContexts: *mut ::PWSTR, }} pub type PCRYPT_CONTEXTS = *mut CRYPT_CONTEXTS; STRUCT!{struct CRYPT_CONTEXT_FUNCTIONS { cFunctions: ::ULONG, rgpszFunctions: *mut ::PWSTR, }} pub type PCRYPT_CONTEXT_FUNCTIONS = *mut CRYPT_CONTEXT_FUNCTIONS; STRUCT!{struct CRYPT_CONTEXT_FUNCTION_PROVIDERS { cProviders: ::ULONG, rgpszProviders: *mut ::PWSTR, }} pub type PCRYPT_CONTEXT_FUNCTION_PROVIDERS = *mut CRYPT_CONTEXT_FUNCTION_PROVIDERS; STRUCT!{struct CRYPT_PROPERTY_REF { pszProperty: ::PWSTR, cbValue: ::ULONG, pbValue: ::PUCHAR, }} pub type PCRYPT_PROPERTY_REF = *mut CRYPT_PROPERTY_REF; STRUCT!{struct CRYPT_IMAGE_REF { pszImage: ::PWSTR, dwFlags: ::ULONG, }} pub type PCRYPT_IMAGE_REF = *mut CRYPT_IMAGE_REF; STRUCT!{struct CRYPT_PROVIDER_REF { dwInterface: ::ULONG, pszFunction: ::PWSTR, pszProvider: ::PWSTR, cProperties: ::ULONG, rgpProperties: *mut PCRYPT_PROPERTY_REF, pUM: PCRYPT_IMAGE_REF, pKM: PCRYPT_IMAGE_REF, }} pub type PCRYPT_PROVIDER_REF = *mut CRYPT_PROVIDER_REF; STRUCT!{struct CRYPT_PROVIDER_REFS { cProviders: ::ULONG, rgpProviders: *mut PCRYPT_PROVIDER_REF, }} pub type PCRYPT_PROVIDER_REFS = *mut CRYPT_PROVIDER_REFS; deps/winapi-0.2.5/src/sspi.rs0000644000000000000000000007007012615662007014562 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Security Support Provider Interface Prototypes and structure definitions pub type SEC_WCHAR = ::WCHAR; pub type SEC_CHAR = ::CHAR; pub type SECURITY_STATUS = ::LONG; STRUCT!{struct SecHandle { dwLower: ::ULONG_PTR, dwUpper: ::ULONG_PTR, }} pub type PSecHandle = *mut SecHandle; pub const SEC_DELETED_HANDLE: ::ULONG_PTR = 2; pub type CredHandle = SecHandle; pub type PCredHandle = PSecHandle; pub type CtxtHandle = SecHandle; pub type PCtxtHandle = PSecHandle; pub type SECURITY_INTEGER = ::LARGE_INTEGER; pub type PSECURITY_INTEGER = *mut ::LARGE_INTEGER; pub type TimeStamp = SECURITY_INTEGER; pub type PTimeStamp = *mut SECURITY_INTEGER; STRUCT!{struct SECURITY_STRING { Length: ::c_ushort, MaximumLength: ::c_ushort, Buffer: *mut ::c_ushort, }} pub type PSECURITY_STRING = *mut SECURITY_STRING; STRUCT!{struct SecPkgInfoW { fCapabilities: ::c_ulong, wVersion: ::c_ushort, wRPCID: ::c_ushort, cbMaxToken: ::c_ulong, Name: *mut SEC_WCHAR, Comment: *mut SEC_WCHAR, }} pub type PSecPkgInfoW = *mut SecPkgInfoW; STRUCT!{struct SecPkgInfoA { fCapabilities: ::c_ulong, wVersion: ::c_ushort, wRPCID: ::c_ushort, cbMaxToken: ::c_ulong, Name: *mut SEC_CHAR, Comment: *mut SEC_CHAR, }} pub type PSecPkgInfoA = *mut SecPkgInfoA; pub const SECPKG_FLAG_INTEGRITY: ::c_ulong = 0x00000001; pub const SECPKG_FLAG_PRIVACY: ::c_ulong = 0x00000002; pub const SECPKG_FLAG_TOKEN_ONLY: ::c_ulong = 0x00000004; pub const SECPKG_FLAG_DATAGRAM: ::c_ulong = 0x00000008; pub const SECPKG_FLAG_CONNECTION: ::c_ulong = 0x00000010; pub const SECPKG_FLAG_MULTI_REQUIRED: ::c_ulong = 0x00000020; pub const SECPKG_FLAG_CLIENT_ONLY: ::c_ulong = 0x00000040; pub const SECPKG_FLAG_EXTENDED_ERROR: ::c_ulong = 0x00000080; pub const SECPKG_FLAG_IMPERSONATION: ::c_ulong = 0x00000100; pub const SECPKG_FLAG_ACCEPT_WIN32_NAME: ::c_ulong = 0x00000200; pub const SECPKG_FLAG_STREAM: ::c_ulong = 0x00000400; pub const SECPKG_FLAG_NEGOTIABLE: ::c_ulong = 0x00000800; pub const SECPKG_FLAG_GSS_COMPATIBLE: ::c_ulong = 0x00001000; pub const SECPKG_FLAG_LOGON: ::c_ulong = 0x00002000; pub const SECPKG_FLAG_ASCII_BUFFERS: ::c_ulong = 0x00004000; pub const SECPKG_FLAG_FRAGMENT: ::c_ulong = 0x00008000; pub const SECPKG_FLAG_MUTUAL_AUTH: ::c_ulong = 0x00010000; pub const SECPKG_FLAG_DELEGATION: ::c_ulong = 0x00020000; pub const SECPKG_FLAG_READONLY_WITH_CHECKSUM: ::c_ulong = 0x00040000; pub const SECPKG_FLAG_RESTRICTED_TOKENS: ::c_ulong = 0x00080000; pub const SECPKG_FLAG_NEGO_EXTENDER: ::c_ulong = 0x00100000; pub const SECPKG_FLAG_NEGOTIABLE2: ::c_ulong = 0x00200000; pub const SECPKG_FLAG_APPCONTAINER_PASSTHROUGH: ::c_ulong = 0x00400000; pub const SECPKG_FLAG_APPCONTAINER_CHECKS: ::c_ulong = 0x00800000; pub const SECPKG_ID_NONE: ::c_ulong = 0xFFFF; pub const SECPKG_CALLFLAGS_APPCONTAINER: ::c_ulong = 0x00000001; pub const SECPKG_CALLFLAGS_APPCONTAINER_AUTHCAPABLE: ::c_ulong = 0x00000002; pub const SECPKG_CALLFLAGS_FORCE_SUPPLIED: ::c_ulong = 0x00000004; STRUCT!{struct SecBuffer { cbBuffer: ::c_ulong, BufferType: ::c_ulong, pvBuffer: *mut ::c_void, }} pub type PSecBuffer = *mut SecBuffer; STRUCT!{struct SecBufferDesc { ulVersion: ::c_ulong, cBuffers: ::c_ulong, pBuffers: PSecBuffer, }} pub type PSecBufferDesc = *mut SecBufferDesc; pub const SECBUFFER_VERSION: ::c_ulong = 0; pub const SECBUFFER_EMPTY: ::c_ulong = 0; pub const SECBUFFER_DATA: ::c_ulong = 1; pub const SECBUFFER_TOKEN: ::c_ulong = 2; pub const SECBUFFER_PKG_PARAMS: ::c_ulong = 3; pub const SECBUFFER_MISSING: ::c_ulong = 4; pub const SECBUFFER_EXTRA: ::c_ulong = 5; pub const SECBUFFER_STREAM_TRAILER: ::c_ulong = 6; pub const SECBUFFER_STREAM_HEADER: ::c_ulong = 7; pub const SECBUFFER_NEGOTIATION_INFO: ::c_ulong = 8; pub const SECBUFFER_PADDING: ::c_ulong = 9; pub const SECBUFFER_STREAM: ::c_ulong = 10; pub const SECBUFFER_MECHLIST: ::c_ulong = 11; pub const SECBUFFER_MECHLIST_SIGNATURE: ::c_ulong = 12; pub const SECBUFFER_TARGET: ::c_ulong = 13; pub const SECBUFFER_CHANNEL_BINDINGS: ::c_ulong = 14; pub const SECBUFFER_CHANGE_PASS_RESPONSE: ::c_ulong = 15; pub const SECBUFFER_TARGET_HOST: ::c_ulong = 16; pub const SECBUFFER_ALERT: ::c_ulong = 17; pub const SECBUFFER_APPLICATION_PROTOCOLS: ::c_ulong = 18; pub const SECBUFFER_ATTRMASK: ::c_ulong = 0xF0000000; pub const SECBUFFER_READONLY: ::c_ulong = 0x80000000; pub const SECBUFFER_READONLY_WITH_CHECKSUM: ::c_ulong = 0x10000000; pub const SECBUFFER_RESERVED: ::c_ulong = 0x60000000; STRUCT!{struct SEC_NEGOTIATION_INFO { Size: ::c_ulong, NameLength: ::c_ulong, Name: *mut SEC_WCHAR, Reserved: *mut ::c_void, }} pub type PSEC_NEGOTIATION_INFO = *mut SEC_NEGOTIATION_INFO; STRUCT!{struct SEC_CHANNEL_BINDINGS { dwInitiatorAddrType: ::c_ulong, cbInitiatorLength: ::c_ulong, dwInitiatorOffset: ::c_ulong, dwAcceptorAddrType: ::c_ulong, cbAcceptorLength: ::c_ulong, dwAcceptorOffset: ::c_ulong, cbApplicationDataLength: ::c_ulong, dwApplicationDataOffset: ::c_ulong, }} pub type PSEC_CHANNEL_BINDINGS = *mut SEC_CHANNEL_BINDINGS; ENUM!{enum SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT { SecApplicationProtocolNegotiationExt_None, SecApplicationProtocolNegotiationExt_NPN, SecApplicationProtocolNegotiationExt_ALPN, }} pub type PSEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT = *mut SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT; STRUCT!{struct SEC_APPLICATION_PROTOCOL_LIST { ProtoNegoExt: ::SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT, ProtocolListSize: ::c_ushort, ProtocolList: [::c_uchar; 0], }} STRUCT!{struct SEC_APPLICATION_PROTOCOLS { ProtocolListsSize: ::c_ulong, ProtocolLists: [SEC_APPLICATION_PROTOCOL_LIST; 0], }} pub type PSEC_APPLICATION_PROTOCOLS = *mut SEC_APPLICATION_PROTOCOLS; pub const SECURITY_NATIVE_DREP: ::c_ulong = 0x00000010; pub const SECURITY_NETWORK_DREP: ::c_ulong = 0x00000000; pub const SECPKG_CRED_INBOUND: ::c_ulong = 0x00000001; pub const SECPKG_CRED_OUTBOUND: ::c_ulong = 0x00000002; pub const SECPKG_CRED_BOTH: ::c_ulong = 0x00000003; pub const SECPKG_CRED_DEFAULT: ::c_ulong = 0x00000004; pub const SECPKG_CRED_RESERVED: ::c_ulong = 0xF0000000; pub const SECPKG_CRED_AUTOLOGON_RESTRICTED: ::c_ulong = 0x00000010; pub const SECPKG_CRED_PROCESS_POLICY_ONLY: ::c_ulong = 0x00000020; pub const ISC_REQ_DELEGATE: ::c_ulong = 0x00000001; pub const ISC_REQ_MUTUAL_AUTH: ::c_ulong = 0x00000002; pub const ISC_REQ_REPLAY_DETECT: ::c_ulong = 0x00000004; pub const ISC_REQ_SEQUENCE_DETECT: ::c_ulong = 0x00000008; pub const ISC_REQ_CONFIDENTIALITY: ::c_ulong = 0x00000010; pub const ISC_REQ_USE_SESSION_KEY: ::c_ulong = 0x00000020; pub const ISC_REQ_PROMPT_FOR_CREDS: ::c_ulong = 0x00000040; pub const ISC_REQ_USE_SUPPLIED_CREDS: ::c_ulong = 0x00000080; pub const ISC_REQ_ALLOCATE_MEMORY: ::c_ulong = 0x00000100; pub const ISC_REQ_USE_DCE_STYLE: ::c_ulong = 0x00000200; pub const ISC_REQ_DATAGRAM: ::c_ulong = 0x00000400; pub const ISC_REQ_CONNECTION: ::c_ulong = 0x00000800; pub const ISC_REQ_CALL_LEVEL: ::c_ulong = 0x00001000; pub const ISC_REQ_FRAGMENT_SUPPLIED: ::c_ulong = 0x00002000; pub const ISC_REQ_EXTENDED_ERROR: ::c_ulong = 0x00004000; pub const ISC_REQ_STREAM: ::c_ulong = 0x00008000; pub const ISC_REQ_INTEGRITY: ::c_ulong = 0x00010000; pub const ISC_REQ_IDENTIFY: ::c_ulong = 0x00020000; pub const ISC_REQ_NULL_SESSION: ::c_ulong = 0x00040000; pub const ISC_REQ_MANUAL_CRED_VALIDATION: ::c_ulong = 0x00080000; pub const ISC_REQ_RESERVED1: ::c_ulong = 0x00100000; pub const ISC_REQ_FRAGMENT_TO_FIT: ::c_ulong = 0x00200000; pub const ISC_REQ_FORWARD_CREDENTIALS: ::c_ulong = 0x00400000; pub const ISC_REQ_NO_INTEGRITY: ::c_ulong = 0x00800000; pub const ISC_REQ_USE_HTTP_STYLE: ::c_ulong = 0x01000000; pub const ISC_REQ_UNVERIFIED_TARGET_NAME: ::c_ulong = 0x20000000; pub const ISC_REQ_CONFIDENTIALITY_ONLY: ::c_ulong = 0x40000000; pub const ISC_RET_DELEGATE: ::c_ulong = 0x00000001; pub const ISC_RET_MUTUAL_AUTH: ::c_ulong = 0x00000002; pub const ISC_RET_REPLAY_DETECT: ::c_ulong = 0x00000004; pub const ISC_RET_SEQUENCE_DETECT: ::c_ulong = 0x00000008; pub const ISC_RET_CONFIDENTIALITY: ::c_ulong = 0x00000010; pub const ISC_RET_USE_SESSION_KEY: ::c_ulong = 0x00000020; pub const ISC_RET_USED_COLLECTED_CREDS: ::c_ulong = 0x00000040; pub const ISC_RET_USED_SUPPLIED_CREDS: ::c_ulong = 0x00000080; pub const ISC_RET_ALLOCATED_MEMORY: ::c_ulong = 0x00000100; pub const ISC_RET_USED_DCE_STYLE: ::c_ulong = 0x00000200; pub const ISC_RET_DATAGRAM: ::c_ulong = 0x00000400; pub const ISC_RET_CONNECTION: ::c_ulong = 0x00000800; pub const ISC_RET_INTERMEDIATE_RETURN: ::c_ulong = 0x00001000; pub const ISC_RET_CALL_LEVEL: ::c_ulong = 0x00002000; pub const ISC_RET_EXTENDED_ERROR: ::c_ulong = 0x00004000; pub const ISC_RET_STREAM: ::c_ulong = 0x00008000; pub const ISC_RET_INTEGRITY: ::c_ulong = 0x00010000; pub const ISC_RET_IDENTIFY: ::c_ulong = 0x00020000; pub const ISC_RET_NULL_SESSION: ::c_ulong = 0x00040000; pub const ISC_RET_MANUAL_CRED_VALIDATION: ::c_ulong = 0x00080000; pub const ISC_RET_RESERVED1: ::c_ulong = 0x00100000; pub const ISC_RET_FRAGMENT_ONLY: ::c_ulong = 0x00200000; pub const ISC_RET_FORWARD_CREDENTIALS: ::c_ulong = 0x00400000; pub const ISC_RET_USED_HTTP_STYLE: ::c_ulong = 0x01000000; pub const ISC_RET_NO_ADDITIONAL_TOKEN: ::c_ulong = 0x02000000; pub const ISC_RET_REAUTHENTICATION: ::c_ulong = 0x08000000; pub const ISC_RET_CONFIDENTIALITY_ONLY: ::c_ulong = 0x40000000; pub const ASC_REQ_DELEGATE: ::c_ulong = 0x00000001; pub const ASC_REQ_MUTUAL_AUTH: ::c_ulong = 0x00000002; pub const ASC_REQ_REPLAY_DETECT: ::c_ulong = 0x00000004; pub const ASC_REQ_SEQUENCE_DETECT: ::c_ulong = 0x00000008; pub const ASC_REQ_CONFIDENTIALITY: ::c_ulong = 0x00000010; pub const ASC_REQ_USE_SESSION_KEY: ::c_ulong = 0x00000020; pub const ASC_REQ_SESSION_TICKET: ::c_ulong = 0x00000040; pub const ASC_REQ_ALLOCATE_MEMORY: ::c_ulong = 0x00000100; pub const ASC_REQ_USE_DCE_STYLE: ::c_ulong = 0x00000200; pub const ASC_REQ_DATAGRAM: ::c_ulong = 0x00000400; pub const ASC_REQ_CONNECTION: ::c_ulong = 0x00000800; pub const ASC_REQ_CALL_LEVEL: ::c_ulong = 0x00001000; pub const ASC_REQ_EXTENDED_ERROR: ::c_ulong = 0x00008000; pub const ASC_REQ_STREAM: ::c_ulong = 0x00010000; pub const ASC_REQ_INTEGRITY: ::c_ulong = 0x00020000; pub const ASC_REQ_LICENSING: ::c_ulong = 0x00040000; pub const ASC_REQ_IDENTIFY: ::c_ulong = 0x00080000; pub const ASC_REQ_ALLOW_NULL_SESSION: ::c_ulong = 0x00100000; pub const ASC_REQ_ALLOW_NON_USER_LOGONS: ::c_ulong = 0x00200000; pub const ASC_REQ_ALLOW_CONTEXT_REPLAY: ::c_ulong = 0x00400000; pub const ASC_REQ_FRAGMENT_TO_FIT: ::c_ulong = 0x00800000; pub const ASC_REQ_FRAGMENT_SUPPLIED: ::c_ulong = 0x00002000; pub const ASC_REQ_NO_TOKEN: ::c_ulong = 0x01000000; pub const ASC_REQ_PROXY_BINDINGS: ::c_ulong = 0x04000000; pub const ASC_REQ_ALLOW_MISSING_BINDINGS: ::c_ulong = 0x10000000; pub const ASC_RET_DELEGATE: ::c_ulong = 0x00000001; pub const ASC_RET_MUTUAL_AUTH: ::c_ulong = 0x00000002; pub const ASC_RET_REPLAY_DETECT: ::c_ulong = 0x00000004; pub const ASC_RET_SEQUENCE_DETECT: ::c_ulong = 0x00000008; pub const ASC_RET_CONFIDENTIALITY: ::c_ulong = 0x00000010; pub const ASC_RET_USE_SESSION_KEY: ::c_ulong = 0x00000020; pub const ASC_RET_SESSION_TICKET: ::c_ulong = 0x00000040; pub const ASC_RET_ALLOCATED_MEMORY: ::c_ulong = 0x00000100; pub const ASC_RET_USED_DCE_STYLE: ::c_ulong = 0x00000200; pub const ASC_RET_DATAGRAM: ::c_ulong = 0x00000400; pub const ASC_RET_CONNECTION: ::c_ulong = 0x00000800; pub const ASC_RET_CALL_LEVEL: ::c_ulong = 0x00002000; pub const ASC_RET_THIRD_LEG_FAILED: ::c_ulong = 0x00004000; pub const ASC_RET_EXTENDED_ERROR: ::c_ulong = 0x00008000; pub const ASC_RET_STREAM: ::c_ulong = 0x00010000; pub const ASC_RET_INTEGRITY: ::c_ulong = 0x00020000; pub const ASC_RET_LICENSING: ::c_ulong = 0x00040000; pub const ASC_RET_IDENTIFY: ::c_ulong = 0x00080000; pub const ASC_RET_NULL_SESSION: ::c_ulong = 0x00100000; pub const ASC_RET_ALLOW_NON_USER_LOGONS: ::c_ulong = 0x00200000; pub const ASC_RET_ALLOW_CONTEXT_REPLAY: ::c_ulong = 0x00400000; pub const ASC_RET_FRAGMENT_ONLY: ::c_ulong = 0x00800000; pub const ASC_RET_NO_TOKEN: ::c_ulong = 0x01000000; pub const ASC_RET_NO_ADDITIONAL_TOKEN: ::c_ulong = 0x02000000; pub const SECPKG_CRED_ATTR_NAMES: ::c_ulong = 1; pub const SECPKG_CRED_ATTR_SSI_PROVIDER: ::c_ulong = 2; pub const SECPKG_CRED_ATTR_KDC_PROXY_SETTINGS: ::c_ulong = 3; pub const SECPKG_CRED_ATTR_CERT: ::c_ulong = 4; STRUCT!{struct SecPkgCredentials_NamesW { sUserName: *mut SEC_WCHAR, }} pub type PSecPkgCredentials_NamesW = *mut SecPkgCredentials_NamesW; STRUCT!{struct SecPkgCredentials_NamesA { sUserName: *mut SEC_CHAR, }} pub type PSecPkgCredentials_NamesA = *mut SecPkgCredentials_NamesA; STRUCT!{struct SecPkgCredentials_SSIProviderW { sProviderName: *mut SEC_WCHAR, ProviderInfoLength: ::c_ulong, ProviderInfo: *mut ::c_char, }} pub type PSecPkgCredentials_SSIProviderW = *mut SecPkgCredentials_SSIProviderW; STRUCT!{struct SecPkgCredentials_SSIProviderA { sProviderName: *mut SEC_CHAR, ProviderInfoLength: ::c_ulong, ProviderInfo: *mut ::c_char, }} pub type PSecPkgCredentials_SSIProviderA = *mut SecPkgCredentials_SSIProviderA; pub const KDC_PROXY_SETTINGS_V1: ::ULONG = 1; pub const KDC_PROXY_SETTINGS_FLAGS_FORCEPROXY: ::ULONG = 0x1; STRUCT!{struct SecPkgCredentials_KdcProxySettingsW { Version: ::ULONG, Flags: ::ULONG, ProxyServerOffset: ::USHORT, ProxyServerLength: ::USHORT, ClientTlsCredOffset: ::USHORT, ClientTlsCredLength: ::USHORT, }} pub type PSecPkgCredentials_KdcProxySettingsW = *mut SecPkgCredentials_KdcProxySettingsW; STRUCT!{struct SecPkgCredentials_Cert { EncodedCertSize: ::c_ulong, EncodedCert: *mut ::c_uchar, }} pub type PSecPkgCredentials_Cert = *mut SecPkgCredentials_Cert; pub const SECPKG_ATTR_SIZES: ::c_ulong = 0; pub const SECPKG_ATTR_NAMES: ::c_ulong = 1; pub const SECPKG_ATTR_LIFESPAN: ::c_ulong = 2; pub const SECPKG_ATTR_DCE_INFO: ::c_ulong = 3; pub const SECPKG_ATTR_STREAM_SIZES: ::c_ulong = 4; pub const SECPKG_ATTR_KEY_INFO: ::c_ulong = 5; pub const SECPKG_ATTR_AUTHORITY: ::c_ulong = 6; pub const SECPKG_ATTR_PROTO_INFO: ::c_ulong = 7; pub const SECPKG_ATTR_PASSWORD_EXPIRY: ::c_ulong = 8; pub const SECPKG_ATTR_SESSION_KEY: ::c_ulong = 9; pub const SECPKG_ATTR_PACKAGE_INFO: ::c_ulong = 10; pub const SECPKG_ATTR_USER_FLAGS: ::c_ulong = 11; pub const SECPKG_ATTR_NEGOTIATION_INFO: ::c_ulong = 12; pub const SECPKG_ATTR_NATIVE_NAMES: ::c_ulong = 13; pub const SECPKG_ATTR_FLAGS: ::c_ulong = 14; pub const SECPKG_ATTR_USE_VALIDATED: ::c_ulong = 15; pub const SECPKG_ATTR_CREDENTIAL_NAME: ::c_ulong = 16; pub const SECPKG_ATTR_TARGET_INFORMATION: ::c_ulong = 17; pub const SECPKG_ATTR_ACCESS_TOKEN: ::c_ulong = 18; pub const SECPKG_ATTR_TARGET: ::c_ulong = 19; pub const SECPKG_ATTR_AUTHENTICATION_ID: ::c_ulong = 20; pub const SECPKG_ATTR_LOGOFF_TIME: ::c_ulong = 21; pub const SECPKG_ATTR_NEGO_KEYS: ::c_ulong = 22; pub const SECPKG_ATTR_PROMPTING_NEEDED: ::c_ulong = 24; pub const SECPKG_ATTR_UNIQUE_BINDINGS: ::c_ulong = 25; pub const SECPKG_ATTR_ENDPOINT_BINDINGS: ::c_ulong = 26; pub const SECPKG_ATTR_CLIENT_SPECIFIED_TARGET: ::c_ulong = 27; pub const SECPKG_ATTR_LAST_CLIENT_TOKEN_STATUS: ::c_ulong = 30; pub const SECPKG_ATTR_NEGO_PKG_INFO: ::c_ulong = 31; pub const SECPKG_ATTR_NEGO_STATUS: ::c_ulong = 32; pub const SECPKG_ATTR_CONTEXT_DELETED: ::c_ulong = 33; pub const SECPKG_ATTR_DTLS_MTU: ::c_ulong = 34; pub const SECPKG_ATTR_DATAGRAM_SIZES: ::c_ulong = SECPKG_ATTR_STREAM_SIZES; pub const SECPKG_ATTR_SUBJECT_SECURITY_ATTRIBUTES: ::c_ulong = 128; pub const SECPKG_ATTR_APPLICATION_PROTOCOL: ::c_ulong = 35; STRUCT!{struct SecPkgContext_SubjectAttributes { AttributeInfo: *mut ::c_void, }} pub type PSecPkgContext_SubjectAttributes = *mut SecPkgContext_SubjectAttributes; pub const SECPKG_ATTR_NEGO_INFO_FLAG_NO_KERBEROS: ::c_ulong = 0x1; pub const SECPKG_ATTR_NEGO_INFO_FLAG_NO_NTLM: ::c_ulong = 0x2; ENUM!{enum SECPKG_CRED_CLASS { SecPkgCredClass_None = 0, SecPkgCredClass_Ephemeral = 10, SecPkgCredClass_PersistedGeneric = 20, SecPkgCredClass_PersistedSpecific = 30, SecPkgCredClass_Explicit = 40, }} pub type PSECPKG_CRED_CLASS = *mut SECPKG_CRED_CLASS; STRUCT!{struct SecPkgContext_CredInfo { CredClass: SECPKG_CRED_CLASS, IsPromptingNeeded: ::c_ulong, }} pub type PSecPkgContext_CredInfo = *mut SecPkgContext_CredInfo; STRUCT!{struct SecPkgContext_NegoPackageInfo { PackageMask: ::c_ulong, }} pub type PSecPkgContext_NegoPackageInfo = *mut SecPkgContext_NegoPackageInfo; STRUCT!{struct SecPkgContext_NegoStatus { LastStatus: ::c_ulong, }} pub type PSecPkgContext_NegoStatus = *mut SecPkgContext_NegoStatus; STRUCT!{struct SecPkgContext_Sizes { cbMaxToken: ::c_ulong, cbMaxSignature: ::c_ulong, cbBlockSize: ::c_ulong, cbSecurityTrailer: ::c_ulong, }} pub type PSecPkgContext_Sizes = *mut SecPkgContext_Sizes; STRUCT!{struct SecPkgContext_StreamSizes { cbHeader: ::c_ulong, cbTrailer: ::c_ulong, cbMaximumMessage: ::c_ulong, cBuffers: ::c_ulong, cbBlockSize: ::c_ulong, }} pub type PSecPkgContext_StreamSizes = *mut SecPkgContext_StreamSizes; pub type SecPkgContext_DatagramSizes = SecPkgContext_StreamSizes; pub type PSecPkgContext_DatagramSizes = PSecPkgContext_StreamSizes; STRUCT!{struct SecPkgContext_NamesW { sUserName: *mut SEC_WCHAR, }} pub type PSecPkgContext_NamesW = *mut SecPkgContext_NamesW; ENUM!{enum SECPKG_ATTR_LCT_STATUS { SecPkgAttrLastClientTokenYes, SecPkgAttrLastClientTokenNo, SecPkgAttrLastClientTokenMaybe, }} pub type PSECPKG_ATTR_LCT_STATUS = *mut SECPKG_ATTR_LCT_STATUS; STRUCT!{struct SecPkgContext_LastClientTokenStatus { LastClientTokenStatus: SECPKG_ATTR_LCT_STATUS, }} pub type PSecPkgContext_LastClientTokenStatus = *mut SecPkgContext_LastClientTokenStatus; STRUCT!{struct SecPkgContext_NamesA { sUserName: *mut SEC_CHAR, }} pub type PSecPkgContext_NamesA = *mut SecPkgContext_NamesA; STRUCT!{struct SecPkgContext_Lifespan { tsStart: TimeStamp, tsExpiry: TimeStamp, }} pub type PSecPkgContext_Lifespan = *mut SecPkgContext_Lifespan; STRUCT!{struct SecPkgContext_DceInfo { AuthzSvc: ::c_ulong, pPac: *mut ::c_void, }} pub type PSecPkgContext_DceInfo = *mut SecPkgContext_DceInfo; STRUCT!{struct SecPkgContext_KeyInfoA { sSignatureAlgorithmName: *mut ::SEC_CHAR, sEncryptAlgorithmName: *mut ::SEC_CHAR, KeySize: ::c_ulong, SignatureAlgorithm: ::c_ulong, EncryptAlgorithm: ::c_ulong, }} pub type PSecPkgContext_KeyInfoA = *mut SecPkgContext_KeyInfoA; STRUCT!{struct SecPkgContext_KeyInfoW { sSignatureAlgorithmName: *mut ::SEC_WCHAR, sEncryptAlgorithmName: *mut ::SEC_WCHAR, KeySize: ::c_ulong, SignatureAlgorithm: ::c_ulong, EncryptAlgorithm: ::c_ulong, }} pub type PSecPkgContext_KeyInfoW = *mut SecPkgContext_KeyInfoW; STRUCT!{struct SecPkgContext_AuthorityA { sAuthorityName: *mut SEC_CHAR, }} pub type PSecPkgContext_AuthorityA = *mut SecPkgContext_AuthorityA; STRUCT!{struct SecPkgContext_AuthorityW { sAuthorityName: *mut SEC_WCHAR, }} pub type PSecPkgContext_AuthorityW = *mut SecPkgContext_AuthorityW; STRUCT!{struct SecPkgContext_ProtoInfoA { sProtocolName: *mut SEC_CHAR, majorVersion: ::c_ulong, minorVersion: ::c_ulong, }} pub type PSecPkgContext_ProtoInfoA = *mut SecPkgContext_ProtoInfoA; STRUCT!{struct SecPkgContext_ProtoInfoW { sProtocolName: *mut SEC_WCHAR, majorVersion: ::c_ulong, minorVersion: ::c_ulong, }} pub type PSecPkgContext_ProtoInfoW = *mut SecPkgContext_ProtoInfoW; STRUCT!{struct SecPkgContext_PasswordExpiry { tsPasswordExpires: TimeStamp, }} pub type PSecPkgContext_PasswordExpiry = *mut SecPkgContext_PasswordExpiry; STRUCT!{struct SecPkgContext_LogoffTime { tsLogoffTime: TimeStamp, }} pub type PSecPkgContext_LogoffTime = *mut SecPkgContext_LogoffTime; STRUCT!{struct SecPkgContext_SessionKey { SessionKeyLength: ::c_ulong, SessionKey: *mut ::c_uchar, }} pub type PSecPkgContext_SessionKey = *mut SecPkgContext_SessionKey; STRUCT!{struct SecPkgContext_NegoKeys { KeyType: ::c_ulong, KeyLength: ::c_ushort, KeyValue: *mut ::c_uchar, VerifyKeyType: ::c_ulong, VerifyKeyLength: ::c_ushort, VerifyKeyValue: *mut ::c_uchar, }} pub type PSecPkgContext_NegoKeys = *mut SecPkgContext_NegoKeys; STRUCT!{struct SecPkgContext_PackageInfoW { PackageInfo: PSecPkgInfoW, }} pub type PSecPkgContext_PackageInfoW = *mut SecPkgContext_PackageInfoW; STRUCT!{struct SecPkgContext_PackageInfoA { PackageInfo: PSecPkgInfoA, }} pub type PSecPkgContext_PackageInfoA = *mut SecPkgContext_PackageInfoA; STRUCT!{struct SecPkgContext_UserFlags { UserFlags: ::c_ulong, }} pub type PSecPkgContext_UserFlags = *mut SecPkgContext_UserFlags; STRUCT!{struct SecPkgContext_Flags { Flags: ::c_ulong, }} pub type PSecPkgContext_Flags = *mut SecPkgContext_Flags; STRUCT!{struct SecPkgContext_NegotiationInfoA { PackageInfo: PSecPkgInfoA, NegotiationState: ::c_ulong, }} pub type PSecPkgContext_NegotiationInfoA = *mut SecPkgContext_NegotiationInfoA; STRUCT!{struct SecPkgContext_NegotiationInfoW { PackageInfo: PSecPkgInfoW, NegotiationState: ::c_ulong, }} pub type PSecPkgContext_NegotiationInfoW = *mut SecPkgContext_NegotiationInfoW; pub const SECPKG_NEGOTIATION_COMPLETE: ::c_ulong = 0; pub const SECPKG_NEGOTIATION_OPTIMISTIC: ::c_ulong = 1; pub const SECPKG_NEGOTIATION_IN_PROGRESS: ::c_ulong = 2; pub const SECPKG_NEGOTIATION_DIRECT: ::c_ulong = 3; pub const SECPKG_NEGOTIATION_TRY_MULTICRED: ::c_ulong = 4; STRUCT!{struct SecPkgContext_NativeNamesW { sClientName: SEC_WCHAR, sServerName: SEC_WCHAR, }} pub type PSecPkgContext_NativeNamesW = *mut SecPkgContext_NativeNamesW; STRUCT!{struct SecPkgContext_NativeNamesA { sClientName: SEC_CHAR, sServerName: SEC_CHAR, }} pub type PSecPkgContext_NativeNamesA = *mut SecPkgContext_NativeNamesA; STRUCT!{struct SecPkgContext_CredentialNameW { CredentialType: ::c_ulong, sCredentialName: *mut SEC_WCHAR, }} pub type PSecPkgContext_CredentialNameW = *mut SecPkgContext_CredentialNameW; STRUCT!{struct SecPkgContext_CredentialNameA { CredentialType: ::c_ulong, sCredentialName: *mut SEC_CHAR, }} pub type PSecPkgContext_CredentialNameA = *mut SecPkgContext_CredentialNameA; STRUCT!{struct SecPkgContext_AccessToken { AccessToken: *mut ::c_void, }} pub type PSecPkgContext_AccessToken = *mut SecPkgContext_AccessToken; STRUCT!{struct SecPkgContext_TargetInformation { MarshalledTargetInfoLength: ::c_ulong, MarshalledTargetInfo: *mut ::c_uchar, }} pub type PSecPkgContext_TargetInformation = *mut SecPkgContext_TargetInformation; STRUCT!{struct SecPkgContext_AuthzID { AuthzIDLength: ::c_ulong, AuthzID: *mut ::c_char, }} pub type PSecPkgContext_AuthzID = *mut SecPkgContext_AuthzID; STRUCT!{struct SecPkgContext_Target { TargetLength: ::c_ulong, Target: *mut ::c_char, }} pub type PSecPkgContext_Target = *mut SecPkgContext_Target; STRUCT!{struct SecPkgContext_ClientSpecifiedTarget { sTargetName: *mut SEC_WCHAR, }} pub type PSecPkgContext_ClientSpecifiedTarget = *mut SecPkgContext_ClientSpecifiedTarget; STRUCT!{struct SecPkgContext_Bindings { BindingsLength: ::c_ulong, Bindings: *mut SEC_CHANNEL_BINDINGS, }} pub type PSecPkgContext_Bindings = *mut SecPkgContext_Bindings; ENUM!{enum SEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS { SecApplicationProtocolNegotiationStatus_None, SecApplicationProtocolNegotiationStatus_Success, SecApplicationProtocolNegotiationStatus_SelectedClientOnly, }} pub type PSEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS = *mut SEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS; pub const MAX_PROTOCOL_ID_SIZE: usize = 0xff; #[repr(C)] #[derive(Copy)] pub struct SecPkgContext_ApplicationProtocol { pub ProtoNegoStatus: SEC_APPLICATION_PROTOCOL_NEGOTIATION_STATUS, pub ProtoNegoExt: SEC_APPLICATION_PROTOCOL_NEGOTIATION_EXT, pub ProtocolIdSize: ::c_uchar, pub ProtocolId: [::c_uchar; MAX_PROTOCOL_ID_SIZE], } impl Clone for SecPkgContext_ApplicationProtocol { fn clone(&self) -> SecPkgContext_ApplicationProtocol { *self } } pub type PSecPkgContext_ApplicationProtocol = *mut SecPkgContext_ApplicationProtocol; pub type SEC_GET_KEY_FN = Option; pub const SECPKG_CONTEXT_EXPORT_RESET_NEW: ::c_ulong = 0x00000001; pub const SECPKG_CONTEXT_EXPORT_DELETE_OLD: ::c_ulong = 0x00000002; pub const SECPKG_CONTEXT_EXPORT_TO_KERNEL: ::c_ulong = 0x00000004; pub type ACQUIRE_CREDENTIALS_HANDLE_FN_W = Option SECURITY_STATUS>; pub type ACQUIRE_CREDENTIALS_HANDLE_FN_A = Option SECURITY_STATUS>; pub type FREE_CREDENTIALS_HANDLE_FN = Option SECURITY_STATUS>; pub type ADD_CREDENTIALS_FN_W = Option SECURITY_STATUS>; pub type ADD_CREDENTIALS_FN_A = Option SECURITY_STATUS>; pub type CHANGE_PASSWORD_FN_W = Option SECURITY_STATUS>; pub type CHANGE_PASSWORD_FN_A = Option SECURITY_STATUS>; //1844 ENUM!{enum SecDelegationType { SecFull, SecService, SecTree, SecDirectory, SecObject, }} pub type PSecDelegationType = *mut SecDelegationType; STRUCT!{struct SEC_WINNT_AUTH_BYTE_VECTOR { ByteArrayOffset: ::c_ulong, ByteArrayLength: ::c_ushort, }} pub type PSEC_WINNT_AUTH_BYTE_VECTOR = *mut SEC_WINNT_AUTH_BYTE_VECTOR; STRUCT!{struct SEC_WINNT_AUTH_DATA { CredType: ::GUID, CredData: SEC_WINNT_AUTH_BYTE_VECTOR, }} pub type PSEC_WINNT_AUTH_DATA = *mut SEC_WINNT_AUTH_DATA; STRUCT!{struct SEC_WINNT_AUTH_PACKED_CREDENTIALS { cbHeaderLength: ::c_ushort, cbStructureLength: ::c_ushort, AuthData: SEC_WINNT_AUTH_DATA, }} pub type PSEC_WINNT_AUTH_PACKED_CREDENTIALS = *mut SEC_WINNT_AUTH_PACKED_CREDENTIALS; DEFINE_GUID!(SEC_WINNT_AUTH_DATA_TYPE_PASSWORD, 0x28bfc32f, 0x10f6, 0x4738, 0x98, 0xd1, 0x1a, 0xc0, 0x61, 0xdf, 0x71, 0x6a); DEFINE_GUID!(SEC_WINNT_AUTH_DATA_TYPE_CERT, 0x235f69ad, 0x73fb, 0x4dbc, 0x82, 0x3, 0x6, 0x29, 0xe7, 0x39, 0x33, 0x9b); STRUCT!{struct SEC_WINNT_AUTH_DATA_PASSWORD { UnicodePassword: SEC_WINNT_AUTH_BYTE_VECTOR, }} pub type PSEC_WINNT_AUTH_DATA_PASSWORD = *mut SEC_WINNT_AUTH_DATA_PASSWORD; DEFINE_GUID!(SEC_WINNT_AUTH_DATA_TYPE_CSP_DATA, 0x68fd9879, 0x79c, 0x4dfe, 0x82, 0x81, 0x57, 0x8a, 0xad, 0xc1, 0xc1, 0x0); STRUCT!{struct SEC_WINNT_AUTH_CERTIFICATE_DATA { cbHeaderLength: ::c_ushort, cbStructureLength: ::c_ushort, Certificate: SEC_WINNT_AUTH_BYTE_VECTOR, }} pub type PSEC_WINNT_AUTH_CERTIFICATE_DATA = *mut SEC_WINNT_AUTH_CERTIFICATE_DATA; STRUCT!{struct SEC_WINNT_CREDUI_CONTEXT_VECTOR { CredUIContextArrayOffset: ::ULONG, CredUIContextCount: ::USHORT, }} pub type PSEC_WINNT_CREDUI_CONTEXT_VECTOR = *mut SEC_WINNT_CREDUI_CONTEXT_VECTOR; STRUCT!{struct SEC_WINNT_AUTH_SHORT_VECTOR { ShortArrayOffset: ::ULONG, ShortArrayCount: ::USHORT, }} pub type PSEC_WINNT_AUTH_SHORT_VECTOR = *mut SEC_WINNT_AUTH_SHORT_VECTOR; STRUCT!{struct CREDUIWIN_MARSHALED_CONTEXT { StructureType: ::GUID, cbHeaderLength: ::USHORT, LogonId: ::LUID, MarshaledDataType: ::GUID, MarshaledDataOffset: ::ULONG, MarshaledDataLength: ::USHORT, }} pub type PCREDUIWIN_MARSHALED_CONTEXT = *mut CREDUIWIN_MARSHALED_CONTEXT; STRUCT!{struct SEC_WINNT_CREDUI_CONTEXT { cbHeaderLength: ::USHORT, CredUIContextHandle: ::HANDLE, UIInfo: ::PCREDUI_INFOW, dwAuthError: ::ULONG, pInputAuthIdentity: PSEC_WINNT_AUTH_IDENTITY_OPAQUE, TargetName: ::PUNICODE_STRING, }} pub type PSEC_WINNT_CREDUI_CONTEXT = *mut SEC_WINNT_CREDUI_CONTEXT; pub type PSEC_WINNT_AUTH_IDENTITY_OPAQUE = ::PVOID; deps/winapi-0.2.5/src/dxgi.rs0000644000000000000000000002465312617171733014550 0ustar rootroot// Copyright © 2015; Connor Hilarides // Licensed under the MIT License //! Mappings for the contents of dxgi.h STRUCT!{struct DXGI_FRAME_STATISTICS { PresentCount: ::UINT, PresentRefreshCount: ::UINT, SyncRefreshCount: ::UINT, SyncQPCTime: ::LARGE_INTEGER, SyncGPUTime: ::LARGE_INTEGER, }} STRUCT!{struct DXGI_MAPPED_RECT { Pitch: ::INT, pBits: *mut ::BYTE, }} #[repr(C)] #[derive(Copy)] pub struct DXGI_ADAPTER_DESC { pub Description: [::WCHAR; 128], pub VectorId: ::UINT, pub DeviceId: ::UINT, pub SubSysId: ::UINT, pub Revision: ::UINT, pub DedicatedVideoMemory: ::SIZE_T, pub DedicatedSystemMemory: ::SIZE_T, pub SharedSystemMemory: ::SIZE_T, pub AdapterLuid: ::LUID, } impl Clone for DXGI_ADAPTER_DESC { fn clone(&self) -> DXGI_ADAPTER_DESC { *self } } #[repr(C)] #[derive(Copy)] pub struct DXGI_OUTPUT_DESC { pub DeviceName: [::WCHAR; 32], pub DesktopCoordinates: ::RECT, pub AttachedToDesktop: ::BOOL, pub Rotation: ::DXGI_MODE_ROTATION, pub Monitor: ::HMONITOR, } impl Clone for DXGI_OUTPUT_DESC { fn clone(&self) -> DXGI_OUTPUT_DESC { *self } } STRUCT!{struct DXGI_SHARED_RESOURCE { Handle: ::HANDLE, }} pub const DXGI_RESOURCE_PRIORITY_MINIMUM: ::DWORD = 0x28000000; pub const DXGI_RESOURCE_PRIORITY_LOW: ::DWORD = 0x50000000; pub const DXGI_RESOURCE_PRIORITY_NORMAL: ::DWORD = 0x78000000; pub const DXGI_RESOURCE_PRIORITY_HIGH: ::DWORD = 0xa0000000; pub const DXGI_RESOURCE_PRIORITY_MAXIMUM: ::DWORD = 0xc8000000; ENUM!{enum DXGI_RESIDENCY { DXGI_RESIDENCY_FULLY_RESIDENT = 1, DXGI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY = 2, DXGI_RESIDENCY_EVICTED_TO_DISK = 3, }} STRUCT!{struct DXGI_SURFACE_DESC { Width: ::UINT, Height: ::UINT, Format: ::DXGI_FORMAT, SampleDesc: ::DXGI_SAMPLE_DESC, }} ENUM!{enum DXGI_SWAP_EFFECT { DXGI_SWAP_EFFECT_DISCARD = 0, DXGI_SWAP_EFFECT_SEQUENTIAL = 1, DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL = 3, }} FLAGS!{enum DXGI_SWAP_CHAIN_FLAG { DXGI_SWAP_CHAIN_FLAG_NONPREROTATED = 1, DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH = 2, DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE = 4, DXGI_SWAP_CHAIN_FLAG_RESTRICTED_CONTENT = 8, DXGI_SWAP_CHAIN_FLAG_RESTRICT_SHARED_RESOURCE_DRIVER = 16, DXGI_SWAP_CHAIN_FLAG_DISPLAY_ONLY = 32, DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT = 64, DXGI_SWAP_CHAIN_FLAG_FOREGROUND_LAYER = 128, DXGI_SWAP_CHAIN_FLAG_FULLSCREEN_VIDEO = 256, DXGI_SWAP_CHAIN_FLAG_YUV_VIDEO = 512, }} STRUCT!{struct DXGI_SWAP_CHAIN_DESC { BufferDesc: ::DXGI_MODE_DESC, SampleDesc: ::DXGI_SAMPLE_DESC, BufferUsage: ::DXGI_USAGE, BufferCount: ::UINT, OutputWindow: ::HWND, Windowed: ::BOOL, SwapEffect: DXGI_SWAP_EFFECT, Flags: ::UINT, }} RIDL!( interface IDXGIObject(IDXGIObjectVtbl): IUnknown(IUnknownVtbl) { fn SetPrivateData( &mut self, Name: ::REFGUID, DataSize: ::UINT, pData: *const ::c_void ) -> ::HRESULT, fn SetPrivateDataInterface(&mut self, Name: ::REFGUID, pUnknown: *const ::IUnknown) -> ::HRESULT, fn GetPrivateData( &mut self, Name: ::REFGUID, pDataSize: *mut ::UINT, pData: *mut ::c_void ) -> ::HRESULT, fn GetParent( &mut self, riid: ::REFIID, ppParent: *mut *mut ::c_void ) -> ::HRESULT }); RIDL!( interface IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl): IDXGIObject(IDXGIObjectVtbl) { fn GetDevice(&mut self, riid: ::REFIID, ppDevice: *mut *mut ::c_void) -> ::HRESULT }); RIDL!( interface IDXGIResource(IDXGIResourceVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) { fn GetSharedHandle(&mut self, pSharedHandle: *mut ::HANDLE) -> ::HRESULT, fn GetUsage(&mut self, pUsage: *mut ::DXGI_USAGE) -> ::HRESULT, fn SetEvictionPriority(&mut self, EvictionPriority: ::UINT) -> ::HRESULT, fn GetEvictionPriority(&mut self, pEvictionPriority: *mut ::UINT) -> ::HRESULT }); RIDL!( interface IDXGIKeyedMutex(IDXGIKeyedMutexVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) { fn AcquireSync(&mut self, Key: ::UINT64, dwMilliseconds: ::DWORD) -> ::HRESULT, fn ReleaseSync(&mut self, Key: ::UINT64) -> ::HRESULT }); RIDL!( interface IDXGISurface(IDXGISurfaceVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) { fn GetDesc(&mut self, pDesc: *mut DXGI_SURFACE_DESC) -> ::HRESULT, fn Map(&mut self, pLockedRect: *mut DXGI_MAPPED_RECT, MapFlags: ::UINT) -> ::HRESULT, fn Unmap(&mut self) -> ::HRESULT }); RIDL!( interface IDXGISurface1(IDXGISurface1Vtbl): IDXGISurface(IDXGISurfaceVtbl) { fn GetDC(&mut self, Discard: ::BOOL, phdc: *mut ::HDC) -> ::HRESULT, fn ReleaseDC(&mut self, pDirtyRect: *mut ::RECT) -> ::HRESULT }); RIDL!( interface IDXGIAdapter(IDXGIAdapterVtbl): IDXGIObject(IDXGIObjectVtbl) { fn EnumOutputs(&mut self, Output: ::UINT, ppOutput: *mut *mut IDXGIOutput) -> ::HRESULT, fn GetDesc(&mut self, pDesc: *mut DXGI_ADAPTER_DESC) -> ::HRESULT, fn CheckInterfaceSupport( &mut self, InterfaceName: ::REFGUID, pUMDVersion: *mut ::LARGE_INTEGER ) -> ::HRESULT }); RIDL!( interface IDXGIOutput(IDXGIOutputVtbl): IDXGIObject(IDXGIObjectVtbl) { fn GetDesc(&mut self, pDesc: *mut DXGI_OUTPUT_DESC) -> ::HRESULT, fn GetDisplayModeList( &mut self, EnumFormat: ::DXGI_FORMAT, Flags: ::UINT, pNumModes: *mut ::UINT, pDesc: *mut ::DXGI_MODE_DESC ) -> ::HRESULT, fn FindClosestMatchingMode( &mut self, pModeToMatch: *const ::DXGI_MODE_DESC, pClosestMatch: *mut ::DXGI_MODE_DESC, pConcernedDevice: *mut ::IUnknown ) -> ::HRESULT, fn WaitForVBlank(&mut self) -> ::HRESULT, fn TakeOwnership(&mut self, pDevice: *mut ::IUnknown, Exclusive: ::BOOL) -> ::HRESULT, fn ReleaseOwnership(&mut self) -> (), fn GetGammaControlCapabilities( &mut self, pGammaCaps: *mut ::DXGI_GAMMA_CONTROL_CAPABILITIES ) -> ::HRESULT, fn SetGammaControl(&mut self, pArray: *const ::DXGI_GAMMA_CONTROL) -> ::HRESULT, fn GetGammaControl(&mut self, pArray: *mut ::DXGI_GAMMA_CONTROL) -> ::HRESULT, fn SetDisplaySurface(&mut self, pScanoutSurface: *mut IDXGISurface) -> ::HRESULT, fn GetDisplaySurfaceData(&mut self, pDestination: *mut IDXGISurface) -> ::HRESULT, fn GetFrameStatistics(&mut self, pStats: *mut DXGI_FRAME_STATISTICS) -> ::HRESULT }); pub const DXGI_MAX_SWAP_CHAIN_BUFFERS: ::DWORD = 16; pub const DXGI_PRESENT_TEST: ::DWORD = 0x00000001; pub const DXGI_PRESENT_DO_NOT_SEQUENCE: ::DWORD = 0x00000002; pub const DXGI_PRESENT_RESTART: ::DWORD = 0x00000004; pub const DXGI_PRESENT_DO_NOT_WAIT: ::DWORD = 0x00000008; pub const DXGI_PRESENT_STEREO_PREFER_RIGHT: ::DWORD = 0x00000010; pub const DXGI_PRESENT_STEREO_TEMPORARY_MONO: ::DWORD = 0x00000020; pub const DXGI_PRESENT_RESTRICT_TO_OUTPUT: ::DWORD = 0x00000040; pub const DXGI_PRESENT_USE_DURATION: ::DWORD = 0x00000100; RIDL!( interface IDXGISwapChain(IDXGISwapChainVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) { fn Present(&mut self, SyncInterval: ::UINT, Flags: ::UINT) -> ::HRESULT, fn GetBuffer( &mut self, Buffer: ::UINT, riid: ::REFIID, ppSurface: *mut *mut ::c_void ) -> ::HRESULT, fn SetFullscreenState(&mut self, Fullscreen: ::BOOL, pTarget: *mut IDXGIOutput) -> ::HRESULT, fn GetFullscreenState( &mut self, pFullscreen: *mut ::BOOL, ppTarget: *mut *mut IDXGIOutput ) -> ::HRESULT, fn GetDesc(&mut self, pDesc: *mut DXGI_SWAP_CHAIN_DESC) -> ::HRESULT, fn ResizeBuffers( &mut self, BufferCount: ::UINT, Width: ::UINT, Height: ::UINT, NewFormat: ::DXGI_FORMAT, SwapChainFlags: ::UINT ) -> ::HRESULT, fn ResizeTarget(&mut self, pNewTargetParameters: *const ::DXGI_MODE_DESC) -> ::HRESULT, fn GetContainingOutput(&mut self, ppOutput: *mut *mut IDXGIOutput) -> ::HRESULT, fn GetFrameStatistics(&mut self, pStats: *mut DXGI_FRAME_STATISTICS) -> ::HRESULT, fn GetLastPresentCount(&mut self, pLastPresentCount: *mut ::UINT) -> ::HRESULT }); RIDL!( interface IDXGIFactory(IDXGIFactoryVtbl): IDXGIObject(IDXGIObjectVtbl) { fn EnumAdapters(&mut self, Adapter: ::UINT, ppAdapter: *mut *mut IDXGIAdapter) -> ::HRESULT, fn MakeWindowAssociation(&mut self, WindowHandle: ::HWND, Flags: ::UINT) -> ::HRESULT, fn GetWindowAssociation(&mut self, pWindowHandle: *mut ::HWND) -> ::HRESULT, fn CreateSwapChan( &mut self, pDevice: *mut ::IUnknown, pDesc: *mut DXGI_SWAP_CHAIN_DESC, ppSwapChain: *mut *mut IDXGISwapChain ) -> ::HRESULT, fn CreateSoftwareAdapter( &mut self, Module: ::HMODULE, ppAdapter: *mut *mut IDXGIAdapter ) -> ::HRESULT }); RIDL!( interface IDXGIDevice(IDXGIDeviceVtbl): IDXGIObject(IDXGIObjectVtbl) { fn GetAdapter(&mut self, pAdapter: *mut *mut IDXGIAdapter) -> ::HRESULT, fn CreateSurface( &mut self, pDesc: *const DXGI_SURFACE_DESC, NumSurfaces: ::UINT, Usage: ::DXGI_USAGE, pSharedResource: *const DXGI_SHARED_RESOURCE, ppSurface: *mut *mut IDXGISurface ) -> ::HRESULT, fn QueryResourceResidency( &mut self, ppResources: *const *mut ::IUnknown, pResidencyStatus: *mut DXGI_RESIDENCY, NumResources: ::UINT ) -> ::HRESULT, fn SetGPUThreadPriority(&mut self, Priority: ::INT) -> ::HRESULT, fn GetGPUThreadPriority(&mut self, pPriority: *mut ::INT) -> ::HRESULT }); ENUM!{enum DXGI_ADAPTER_FLAG { DXGI_ADAPTER_FLAG_NONE, DXGI_ADAPTER_FLAG_REMOTE, DXGI_ADAPTER_FLAG_SOFTWARE, }} #[repr(C)] #[derive(Copy)] pub struct DXGI_ADAPTER_DESC1 { pub Description: [::WCHAR; 128], pub VendorId: ::UINT, pub DeviceId: ::UINT, pub SubSysId: ::UINT, pub Revision: ::UINT, pub DedicatedVideoMemory: ::SIZE_T, pub DedicatedSystemMemory: ::SIZE_T, pub SharedSystemMemory: ::SIZE_T, pub AdapterLuid: ::LUID, pub Flags: ::UINT, } impl Clone for DXGI_ADAPTER_DESC1 { fn clone(&self) -> DXGI_ADAPTER_DESC1 { *self } } STRUCT!{struct DXGI_DISPLAY_COLOR_SPACE { PrimaryCoordinates: [[::FLOAT; 2]; 8], WhitePoints: [[::FLOAT; 2]; 16], }} RIDL!( interface IDXGIFactory1(IDXGIFactory1Vtbl): IDXGIFactory(IDXGIFactoryVtbl) { fn EnumAdapters1(&mut self, Adapter: ::UINT, ppAdapter: *mut *mut IDXGIAdapter1) -> ::HRESULT, fn IsCurrent(&mut self) -> ::BOOL }); RIDL!( interface IDXGIAdapter1(IDXGIAdapter1Vtbl): IDXGIAdapter(IDXGIAdapterVtbl) { fn GetDesc1(&mut self, pDesc: *mut DXGI_ADAPTER_DESC1) -> ::HRESULT }); RIDL!( interface IDXGIDevice1(IDXGIDevice1Vtbl): IDXGIDevice(IDXGIDeviceVtbl) { fn SetMaximumFrameLatency(&mut self, MaxLatency: ::UINT) -> ::HRESULT, fn GetMaximumFrameLatency(&mut self, pMaxLatency: *mut ::UINT) -> ::HRESULT }); deps/winapi-0.2.5/src/synchapi.rs0000644000000000000000000000123112605021352015402 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! ApiSet Contract for api-ms-win-core-synch-l1 pub type SRWLOCK = ::RTL_SRWLOCK; pub type PSRWLOCK = *mut ::RTL_SRWLOCK; pub type SYNCHRONIZATION_BARRIER = ::RTL_BARRIER; pub type PSYNCHRONIZATION_BARRIER = ::PRTL_BARRIER; pub type LPSYNCHRONIZATION_BARRIER = ::PRTL_BARRIER; pub type PINIT_ONCE_FN = Option ::BOOL>; pub type PTIMERAPCROUTINE = Option; deps/winapi-0.2.5/src/usp10.rs0000644000000000000000000001576312613167613014565 0ustar rootroot// Copyright © 2015, Jordan Miner // Licensed under the MIT License //! Uniscribe structure declarations and constant definitions pub const SCRIPT_UNDEFINED: ::WORD = 0; pub const USP_E_SCRIPT_NOT_IN_FONT: ::HRESULT = MAKE_HRESULT!( ::SEVERITY_ERROR, ::FACILITY_ITF, 0x200 ); DECLARE_HANDLE!(SCRIPT_CACHE, SCRIPT_CACHE__); STRUCT!{struct SCRIPT_CONTROL { bit_fields: ::DWORD, }} BITFIELD!(SCRIPT_CONTROL bit_fields: ::DWORD [ uDefaultLanguage set_uDefaultLanguage[0..16], fContextDigits set_fContextDigits[16..17], fInvertPreBoundDir set_fInvertPreBoundDir[17..18], fInvertPostBoundDir set_fInvertPostBoundDir[18..19], fLinkStringBefore set_fLinkStringBefore[19..20], fLinkStringAfter set_fLinkStringAfter[20..21], fNeutralOverride set_fNeutralOverride[21..22], fNumericOverride set_fNumericOverride[22..23], fLegacyBidiClass set_fLegacyBidiClass[23..24], fMergeNeutralItems set_fMergeNeutralItems[24..25], fReserved set_fReserved[25..32], ]); STRUCT!{struct SCRIPT_STATE { bit_fields: ::WORD, }} BITFIELD!(SCRIPT_STATE bit_fields: ::WORD [ uBidiLevel set_uBidiLevel[0..5], fOverrideDirection set_fOverrideDirection[5..6], fInhibitSymSwap set_fInhibitSymSwap[6..7], fCharShape set_fCharShape[7..8], fDigitSubstitute set_fDigitSubstitute[8..9], fInhibitLigate set_fInhibitLigate[9..10], fDisplayZWG set_fDisplayZWG[10..11], fArabicNumContext set_fArabicNumContext[11..12], fGcpClusters set_fGcpClusters[12..13], fReserved set_fReserved[13..14], fEngineReserved set_fEngineReserved[14..16], ]); STRUCT!{struct SCRIPT_ANALYSIS { bit_fields: ::WORD, s: SCRIPT_STATE, }} BITFIELD!(SCRIPT_ANALYSIS bit_fields: ::WORD [ eScript set_eScript[0..10], fRTL set_fRTL[10..11], fLayoutRTL set_fLayoutRTL[11..12], fLinkBefore set_fLinkBefore[12..13], fLinkAfter set_fLinkAfter[13..14], fLogicalOrder set_fLogicalOrder[14..15], fNoGlyphIndex set_fNoGlyphIndex[15..16], ]); STRUCT!{struct SCRIPT_ITEM { iCharPos: ::c_int, a: SCRIPT_ANALYSIS, }} //490 pub const SCRIPT_JUSTIFY_NONE: ::WORD = 0; pub const SCRIPT_JUSTIFY_ARABIC_BLANK: ::WORD = 1; pub const SCRIPT_JUSTIFY_CHARACTER: ::WORD = 2; pub const SCRIPT_JUSTIFY_RESERVED1: ::WORD = 3; pub const SCRIPT_JUSTIFY_BLANK: ::WORD = 4; pub const SCRIPT_JUSTIFY_RESERVED2: ::WORD = 5; pub const SCRIPT_JUSTIFY_RESERVED3: ::WORD = 6; pub const SCRIPT_JUSTIFY_ARABIC_NORMAL: ::WORD = 7; pub const SCRIPT_JUSTIFY_ARABIC_KASHIDA: ::WORD = 8; pub const SCRIPT_JUSTIFY_ARABIC_ALEF: ::WORD = 9; pub const SCRIPT_JUSTIFY_ARABIC_HA: ::WORD = 10; pub const SCRIPT_JUSTIFY_ARABIC_RA: ::WORD = 11; pub const SCRIPT_JUSTIFY_ARABIC_BA: ::WORD = 12; pub const SCRIPT_JUSTIFY_ARABIC_BARA: ::WORD = 13; pub const SCRIPT_JUSTIFY_ARABIC_SEEN: ::WORD = 14; pub const SCRIPT_JUSTIFY_ARABIC_SEEN_M: ::WORD = 15; STRUCT!{struct SCRIPT_VISATTR { bit_fields: ::WORD, }} BITFIELD!(SCRIPT_VISATTR bit_fields: ::WORD [ uJustification set_uJustification[0..4], fClusterStart set_fClusterStart[4..5], fDiacritic set_fDiacritic[5..6], fZeroWidth set_fZeroWidth[6..7], fReserved set_fReserved[7..8], fShapeReserved set_fShapeReserved[8..16], ]); STRUCT!{struct GOFFSET { du: ::LONG, dv: ::LONG, }} STRUCT!{struct SCRIPT_LOGATTR { bit_fields: ::BYTE, }} BITFIELD!(SCRIPT_LOGATTR bit_fields: ::BYTE [ fSoftBreak set_fSoftBreak[0..1], fWhiteSpace set_fWhiteSpace[1..2], fCharStop set_fCharStop[2..3], fWordStop set_fWordStop[3..4], fInvalid set_fInvalid[4..5], fReserved set_fReserved[5..8], ]); pub const SGCM_RTL: ::DWORD = 0x00000001; STRUCT!{struct SCRIPT_PROPERTIES { bit_fields1: ::DWORD, bit_fields2: ::DWORD, }} BITFIELD!(SCRIPT_PROPERTIES bit_fields1: ::DWORD [ langid set_langid[0..16], fNumeric set_fNumeric[16..17], fComplex set_fComplex[17..18], fNeedsWordBreaking set_fNeedsWordBreaking[18..19], fNeedsCaretInfo set_fNeedsCaretInfo[19..20], bCharSet set_bCharSet[20..28], fControl set_fControl[28..29], fPrivateUseArea set_fPrivateUseArea[29..30], fNeedsCharacterJustify set_fNeedsCharacterJustify[30..31], fInvalidGlyph set_fInvalidGlyph[31..32], ]); BITFIELD!(SCRIPT_PROPERTIES bit_fields2: ::DWORD [ fInvalidLogAttr set_fInvalidLogAttr[0..1], fCDM set_fCDM[1..2], fAmbiguousCharSet set_fAmbiguousCharSet[2..3], fClusterSizeVaries set_fClusterSizeVaries[3..4], fRejectInvalid set_fRejectInvalid[4..5], ]); STRUCT!{struct SCRIPT_FONTPROPERTIES { cBytes: ::c_int, wgBlank: ::WORD, wgDefault: ::WORD, wgInvalid: ::WORD, wgKashida: ::WORD, iKashidaWidth: ::c_int, }} //1440 pub const SSA_PASSWORD: ::DWORD = 0x00000001; pub const SSA_TAB: ::DWORD = 0x00000002; pub const SSA_CLIP: ::DWORD = 0x00000004; pub const SSA_FIT: ::DWORD = 0x00000008; pub const SSA_DZWG: ::DWORD = 0x00000010; pub const SSA_FALLBACK: ::DWORD = 0x00000020; pub const SSA_BREAK: ::DWORD = 0x00000040; pub const SSA_GLYPHS: ::DWORD = 0x00000080; pub const SSA_RTL: ::DWORD = 0x00000100; pub const SSA_GCP: ::DWORD = 0x00000200; pub const SSA_HOTKEY: ::DWORD = 0x00000400; pub const SSA_METAFILE: ::DWORD = 0x00000800; pub const SSA_LINK: ::DWORD = 0x00001000; pub const SSA_HIDEHOTKEY: ::DWORD = 0x00002000; pub const SSA_HOTKEYONLY: ::DWORD = 0x00002400; pub const SSA_FULLMEASURE: ::DWORD = 0x04000000; pub const SSA_LPKANSIFALLBACK: ::DWORD = 0x08000000; pub const SSA_PIDX: ::DWORD = 0x10000000; pub const SSA_LAYOUTRTL: ::DWORD = 0x20000000; pub const SSA_DONTGLYPH: ::DWORD = 0x40000000; pub const SSA_NOKASHIDA: ::DWORD = 0x80000000; STRUCT!{struct SCRIPT_TABDEF { cTabStops: ::c_int, iScale: ::c_int, pTabStops: *mut ::c_int, iTabOrigin: ::c_int, }} DECLARE_HANDLE!(SCRIPT_STRING_ANALYSIS, SCRIPT_STRING_ANALYSIS__); pub const SIC_COMPLEX: ::DWORD = 1; pub const SIC_ASCIIDIGIT: ::DWORD = 2; pub const SIC_NEUTRAL: ::DWORD = 4; STRUCT!{struct SCRIPT_DIGITSUBSTITUTE { bit_fields1: ::DWORD, bit_fields2: ::DWORD, dwReserved: ::DWORD, }} BITFIELD!(SCRIPT_DIGITSUBSTITUTE bit_fields1: ::DWORD [ NationalDigitLanguage set_NationalDigitLanguage[0..16], TraditionalDigitLanguage set_TraditionalDigitLanguage[16..32], ]); BITFIELD!(SCRIPT_DIGITSUBSTITUTE bit_fields2: ::DWORD [ DigitSubstitute set_DigitSubstitute[0..8], ]); pub const SCRIPT_DIGITSUBSTITUTE_CONTEXT: ::BYTE = 0; pub const SCRIPT_DIGITSUBSTITUTE_NONE: ::BYTE = 1; pub const SCRIPT_DIGITSUBSTITUTE_NATIONAL: ::BYTE = 2; pub const SCRIPT_DIGITSUBSTITUTE_TRADITIONAL: ::BYTE = 3; pub type OPENTYPE_TAG = ::ULONG; pub const SCRIPT_TAG_UNKNOWN: OPENTYPE_TAG = 0x00000000; STRUCT!{struct OPENTYPE_FEATURE_RECORD { tagFeature: OPENTYPE_TAG, lParameter: ::LONG, }} STRUCT!{struct TEXTRANGE_PROPERTIES { potfRecords: *mut OPENTYPE_FEATURE_RECORD, cotfRecords: ::c_int, }} STRUCT!{struct SCRIPT_CHARPROP { bit_fields: ::WORD, }} BITFIELD!(SCRIPT_CHARPROP bit_fields: ::WORD [ fCanGlyphAlone set_fCanGlyphAlone[0..1], reserved set_reserved[1..16], ]); STRUCT!{struct SCRIPT_GLYPHPROP { sva: SCRIPT_VISATTR, reserved: ::WORD, }} deps/winapi-0.2.5/src/servprov.rs0000644000000000000000000000061612605021352015460 0ustar rootroot// Copyright © 2015, Connor Hilarides // Licensed under the MIT License //! Mappings for the contents of servprov.h pub type LPSERVICEPROVIDER = *mut IServiceProvider; RIDL!( interface IServiceProvider(IServiceProviderVtbl): IUnknown(IUnknownVtbl) { fn QueryService( &mut self, guidService: ::REFGUID, riid: ::REFIID, ppvObject: *mut *mut ::c_void ) -> ::HRESULT } ); deps/winapi-0.2.5/src/inspectable.rs0000644000000000000000000000101612615662007016067 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License pub type LPINSPECTABLE = *mut IInspectable; ENUM!{enum TrustLevel { BaseTrust = 0, PartialTrust, FullTrust, }} RIDL!( interface IInspectable(IInspectableVtbl): IUnknown(IUnknownVtbl) { fn GetIids(&mut self, iidCount: *mut ::ULONG, iids: *mut *mut ::IID) -> ::HRESULT, fn GetRuntimeClassName(&mut self, className: *mut ::HSTRING) -> ::HRESULT, fn GetTrustLevel(&mut self, trustLevel: *mut TrustLevel) -> ::HRESULT } ); deps/winapi-0.2.5/src/guiddef.rs0000644000000000000000000000104312613167613015206 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License STRUCT!{struct GUID { Data1: ::c_ulong, Data2: ::c_ushort, Data3: ::c_ushort, Data4: [::c_uchar; 8], }} pub type LPGUID = *mut GUID; pub type LPCGUID = *const GUID; pub type IID = GUID; pub type LPIID = *mut IID; pub type CLSID = GUID; pub type LPCLSID = *mut CLSID; pub type FMTID = GUID; pub type LPFMTID = *mut FMTID; pub type REFGUID = *const GUID; pub type REFIID = *const IID; pub type REFCLSID = *const IID; pub type REFFMTID = *const IID; deps/winapi-0.2.5/src/rpc.rs0000644000000000000000000000030212605021253014346 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License // Master include file for RPC applications. pub type I_RPC_HANDLE = *mut ::c_void; pub type RPC_STATUS = ::c_long; deps/winapi-0.2.5/src/vswriter.rs0000644000000000000000000002557512615662007015503 0ustar rootroot// Copyright © 2015, Brian Vincent // Licensed under the MIT License //! VSS Writer header file ENUM!{enum VSS_USAGE_TYPE { VSS_UT_UNDEFINED = 0, VSS_UT_BOOTABLESYSTEMSTATE = 1, VSS_UT_SYSTEMSERVICE = 2, VSS_UT_USERDATA = 3, VSS_UT_OTHER = 4, }} ENUM!{enum VSS_SOURCE_TYPE { VSS_ST_UNDEFINED = 0, VSS_ST_TRANSACTEDDB = 1, VSS_ST_NONTRANSACTEDDB = 2, VSS_ST_OTHER = 3, }} ENUM!{enum VSS_RESTOREMETHOD_ENUM { VSS_RME_UNDEFINED = 0, VSS_RME_RESTORE_IF_NOT_THERE = 1, VSS_RME_RESTORE_IF_CAN_REPLACE = 2, VSS_RME_STOP_RESTORE_START = 3, VSS_RME_RESTORE_TO_ALTERNATE_LOCATION = 4, VSS_RME_RESTORE_AT_REBOOT = 5, VSS_RME_RESTORE_AT_REBOOT_IF_CANNOT_REPLACE = 6, VSS_RME_CUSTOM = 7, VSS_RME_RESTORE_STOP_START = 8, }} ENUM!{enum VSS_WRITERRESTORE_ENUM { VSS_WRE_UNDEFINED = 0, VSS_WRE_NEVER = 1, VSS_WRE_IF_REPLACE_FAILS = 2, VSS_WRE_ALWAYS = 3, }} ENUM!{enum VSS_COMPONENT_TYPE { VSS_CT_UNDEFINED = 0, VSS_CT_DATABASE = 1, VSS_CT_FILEGROUP = 2, }} ENUM!{enum VSS_ALTERNATE_WRITER_STATE { VSS_AWS_UNDEFINED = 0, VSS_AWS_NO_ALTERNATE_WRITER = 1, VSS_AWS_ALTERNATE_WRITER_EXISTS = 2, VSS_AWS_THIS_IS_ALTERNATE_WRITER = 3, }} pub type VSS_SUBSCRIBE_MASK = ::DWORD; pub const VSS_SM_POST_SNAPSHOT_FLAG: ::DWORD = 0x00000001; pub const VSS_SM_BACKUP_EVENTS_FLAG: ::DWORD = 0x00000002; pub const VSS_SM_RESTORE_EVENTS_FLAG: ::DWORD = 0x00000004; pub const VSS_SM_IO_THROTTLING_FLAG: ::DWORD = 0x00000008; pub const VSS_SM_ALL_FLAGS: ::DWORD = 0xffffffff; ENUM!{enum VSS_RESTORE_TARGET { VSS_RT_UNDEFINED = 0, VSS_RT_ORIGINAL = 1, VSS_RT_ALTERNATE = 2, VSS_RT_DIRECTED = 3, VSS_RT_ORIGINAL_LOCATION = 4, }} ENUM!{enum VSS_FILE_RESTORE_STATUS { VSS_RS_UNDEFINED = 0, VSS_RS_NONE = 1, VSS_RS_ALL = 2, VSS_RS_FAILED = 3, }} pub type VSS_COMPONENT_FLAGS = ::DWORD; pub const VSS_CF_BACKUP_RECOVERY: ::DWORD = 0x00000001; pub const VSS_CF_APP_ROLLBACK_RECOVERY: ::DWORD = 0x00000002; pub const VSS_CF_NOT_SYSTEM_STATE: ::DWORD = 0x00000004; RIDL!( interface IVssWMFiledesc(IVssWMFiledescVtbl): IUnknown(IUnknownVtbl) { fn GetPath(&mut self, pbstrPath: *mut ::BSTR) -> ::HRESULT, fn GetFilespec(&mut self, pbstrFilespec: *mut ::BSTR) -> ::HRESULT, fn GetRecursive(&mut self, pbRecursive: *mut bool) -> ::HRESULT, fn GetAlternateLocation(&mut self, pbstrAlternateLocation: *mut ::BSTR) -> ::HRESULT, fn GetBackupTypeMask(&mut self, pdwTypeMask: *mut ::DWORD) -> ::HRESULT } ); RIDL!( interface IVssWMDependency(IVssWMDependencyVtbl): IUnknown(IUnknownVtbl) { fn GetWriterId(&mut self, pWriterId: *mut ::VSS_ID) -> ::HRESULT, fn GetLogicalPath(&mut self, pbstrLogicalPath: *mut ::BSTR) -> ::HRESULT, fn GetComponentName(&mut self, pbstrComponentName: *mut ::BSTR) -> ::HRESULT } ); RIDL!( interface IVssComponent(IVssComponentVtbl): IUnknown(IUnknownVtbl) { fn GetLogicalPath(&mut self, pbstrPath: *mut ::BSTR) -> ::HRESULT, fn GetComponentType(&mut self, pct: *mut ::VSS_COMPONENT_TYPE) -> ::HRESULT, fn GetComponentName(&mut self, pbstrName: *mut ::BSTR) -> ::HRESULT, fn GetBackupSucceeded(&mut self, pbSucceeded: *mut bool) -> ::HRESULT, fn GetAlternateLocationMappingCount(&mut self, pcMappings: *mut ::UINT) -> ::HRESULT, fn GetAlternateLocationMapping( &mut self, iMapping: ::UINT, ppFiledesc: *mut *mut ::IVssWMFiledesc ) -> ::HRESULT, fn SetBackupMetadata(&mut self, wszData: ::LPCWSTR) -> ::HRESULT, fn GetBackupMetadata(&mut self, pbstrData: *mut ::BSTR) -> ::HRESULT, fn AddPartialFile( &mut self, wszPath: ::LPCWSTR, wszFilename: ::LPCWSTR, wszRanges: ::LPCWSTR, wszMetadata: ::LPCWSTR ) -> ::HRESULT, fn GetPartialFileCount(&mut self, pcPartialFiles: *mut ::UINT) -> ::HRESULT, fn GetPartialFile( &mut self, iPartialFile: ::UINT, pbstrPath: *mut ::BSTR, pbstrFilename: *mut ::BSTR, pbstrRange: *mut ::BSTR, pbstrMetadata: *mut ::BSTR ) -> ::HRESULT, fn IsSelectedForRestore(&mut self, pbSelectedForRestore: *mut bool) -> ::HRESULT, fn GetAdditionalRestores(&mut self, pbAdditionalRestores: *mut bool) -> ::HRESULT, fn GetNewTargetCount(&mut self, pcNewTarget: *mut ::UINT) -> ::HRESULT, fn GetNewTarget( &mut self, iNewTarget: ::UINT, ppFiledesc: *mut *mut ::IVssWMFiledesc ) -> ::HRESULT, fn AddDirectedTarget( &mut self, wszSourcePath: ::LPCWSTR, wszSourceFilename: ::LPCWSTR, wszSourceRangeList: ::LPCWSTR, wszDestinationPath: ::LPCWSTR, wszDestinationFilename: ::LPCWSTR, wszDestinationRangeList: ::LPCWSTR ) -> ::HRESULT, fn GetDirectedTargetCount(&mut self, pcDirectedTarget: *mut ::UINT) -> ::HRESULT, fn GetDirectedTarget( &mut self, iDirectedTarget: ::UINT, pbstrSourcePath: *mut ::BSTR, pbstrSourceFileName: *mut ::BSTR, pbstrSourceRangeList: *mut ::BSTR, pbstrDestinationPath: *mut ::BSTR, pbstrDestinationFilename: *mut ::BSTR, pbstrDestinationRangeList: *mut ::BSTR ) -> ::HRESULT, fn SetRestoreMetadata(&mut self, wszRestoreMetadata: ::LPCWSTR) -> ::HRESULT, fn GetRestoreMetadata(&mut self, pbstrRestoreMetadata: *mut ::BSTR) -> ::HRESULT, fn SetRestoreTarget(&mut self, target: ::VSS_RESTORE_TARGET) -> ::HRESULT, fn GetRestoreTarget(&mut self, pTarget: *mut ::VSS_RESTORE_TARGET) -> ::HRESULT, fn SetPreRestoreFailureMsg(&mut self, wszPreRestoreFailureMsg: ::LPCWSTR) -> ::HRESULT, fn GetPreRestoreFailureMsg(&mut self, pbstrPreRestoreFailureMsg: *mut ::BSTR) -> ::HRESULT, fn SetPostRestoreFailureMsg(&mut self, wszPostRestoreFailureMsg: ::LPCWSTR) -> ::HRESULT, fn GetPostRestoreFailureMsg(&mut self, pbstrPostRestoreFailureMsg: *mut ::BSTR) -> ::HRESULT, fn SetBackupStamp(&mut self, wszBackupStamp: ::LPCWSTR) -> ::HRESULT, fn GetBackupStamp(&mut self, pbstrBackupStamp: *mut ::BSTR) -> ::HRESULT, fn GetPreviousBackupStamp(&mut self, pbstrBackupStamp: *mut ::BSTR) -> ::HRESULT, fn GetBackupOptions(&mut self, pbstrBackupOptions: *mut ::BSTR) -> ::HRESULT, fn GetRestoreOptions(&mut self, pbstrRestoreOptions: *mut ::BSTR) -> ::HRESULT, fn GetRestoreSubcomponentCount(&mut self, pcRestoreSubcomponent: *mut ::UINT) -> ::HRESULT, fn GetRestoreSubcomponent( &mut self, iComponent: ::UINT, pbstrLogicalPath: *mut ::BSTR, pbstrComponentName: *mut ::BSTR, pbRepair: *mut bool ) -> ::HRESULT, fn GetFileRestoreStatus(&mut self, pStatus: *mut VSS_FILE_RESTORE_STATUS) -> ::HRESULT, fn AddDifferencedFilesByLastModifyTime( &mut self, wszPath: ::LPCWSTR, wszFilespec: ::LPCWSTR, bRecursive: ::BOOL, ftLastModifyTime: ::FILETIME ) -> ::HRESULT, fn AddDifferencedFilesByLastModifyLSN( &mut self, wszPath: ::LPCWSTR, wszFilespec: ::LPCWSTR, bRecursive: ::BOOL, bstrLsnString: ::BSTR ) -> ::HRESULT, fn GetDifferencedFilesCount(&mut self, pcDifferencedFiles: *mut ::UINT) -> ::HRESULT, fn GetDifferencedFile( &mut self, iDifferencedFile: ::UINT, pbstrPath: *mut ::BSTR, pbstrFilespec: *mut ::BSTR, pbRecursive: *mut ::BOOL, pbstrLsnString: *mut ::BSTR, pftLastModifyTime: *mut ::FILETIME ) -> ::HRESULT } ); RIDL!( interface IVssWriterComponents(IVssWriterComponentsVtbl) { fn GetComponentCount(&mut self, pcComponents: *mut ::UINT) -> ::HRESULT, fn GetWriterInfo( &mut self, pidInstance: *mut ::VSS_ID, pidWriter: *mut ::VSS_ID ) -> ::HRESULT, fn GetComponent( &mut self, iComponent: ::UINT, ppComponent: *mut *mut ::IVssComponent ) -> ::HRESULT } ); RIDL!( interface IVssComponentEx(IVssComponentExVtbl): IVssComponent(IVssComponentVtbl) { fn SetPrepareForBackupFailureMsg(&mut self, wszFailureMsg: ::LPCWSTR) -> ::HRESULT, fn SetPostSnapshotFailureMsg(&mut self, wszFailureMsg: ::LPCWSTR) -> ::HRESULT, fn GetPrepareForBackupFailureMsg(&mut self, pbstrFailureMsg: *mut ::BSTR) -> ::HRESULT, fn GetPostSnapshotFailureMsg(&mut self, pbstrFailureMsg: *mut ::BSTR) -> ::HRESULT, fn GetAuthoritativeRestore(&mut self, pbAuth: *mut bool) -> ::HRESULT, fn GetRollForward( &mut self, pRollType: *mut ::VSS_ROLLFORWARD_TYPE, pbstrPoint: *mut ::BSTR ) -> ::HRESULT, fn GetRestoreName(&mut self, pbstrName: *mut ::BSTR) -> ::HRESULT } ); RIDL!( interface IVssComponentEx2(IVssComponentEx2Vtbl): IVssComponentEx(IVssComponentExVtbl) { fn SetFailure( &mut self, hr: ::HRESULT, hrApplication: ::HRESULT, wszApplicationMessage: ::LPCWSTR, dwReserved: ::DWORD ) -> ::HRESULT, fn GetFailure( &mut self, phr: *mut ::HRESULT, phrApplication: *mut ::HRESULT, pbstrApplicationMessage: *mut ::BSTR, pdwReserved: *mut ::DWORD ) -> ::HRESULT } ); RIDL!( interface IVssCreateWriterMetadata(IVssCreateWriterMetadataVtbl) { fn AddIncludeFiles( &mut self, wszPath: ::LPCWSTR, wszFilespec: ::LPCWSTR, bRecursive: bool, wszAlternateLocation: ::LPCWSTR ) -> ::HRESULT, fn AddExcludeFiles( &mut self, wszPath: ::LPCWSTR, wszFilespec: ::LPCWSTR, bRecursive: bool ) -> ::HRESULT, fn AddComponent( &mut self, ct: ::VSS_COMPONENT_TYPE, wszLogicalPath: ::LPCWSTR, wszComponentName: ::LPCWSTR, wszCaption: ::LPCWSTR, pbIcon: *const ::BYTE, cbIcon: ::UINT, bRestoreMetadata: bool, bNotifyOnBackupComplete: bool, bSelectableForRestore: bool, dwComponentFlags: ::DWORD ) -> ::HRESULT, fn AddDatabaseFiles( &mut self, wszLogicalPath: ::LPCWSTR, wszDatabaseName: ::LPCWSTR, wszPath: ::LPCWSTR, wszFilespec: ::LPCWSTR, dwBackupTypeMask: ::DWORD ) -> ::HRESULT, fn AddDatabaseLogFiles(&mut self, wszLogicalPath: ::LPCWSTR, wszDatabaseName: ::LPCWSTR, wszPath: ::LPCWSTR, wszFilespec: ::LPCWSTR, dwBackupTypeMask: ::DWORD ) -> ::HRESULT, fn AddFilesToFileGroup(&mut self, wszLogicalPath: ::LPCWSTR, wszGroupName: ::LPCWSTR, wszPath: ::LPCWSTR, wszFilespec: ::LPCWSTR, bRecursive: bool, wszAlternateLocation: ::LPCWSTR, dwBackupTypeMask: ::DWORD ) -> ::HRESULT, fn SetRestoreMethod(&mut self, method: ::VSS_RESTOREMETHOD_ENUM, wszService: ::LPCWSTR, wszUserProcedure: ::LPCWSTR, writerRestore: ::VSS_WRITERRESTORE_ENUM, bRebootRequired: bool ) -> ::HRESULT, fn AddAlternateLocationMapping(&mut self, wszSourcePath: ::LPCWSTR, wszSourceFilespec: ::LPCWSTR, bRecursive: bool, wszDestination: ::LPCWSTR ) -> ::HRESULT, fn AddComponentDependency(&mut self, wszForLogicalPath: ::LPCWSTR, wszForComponentName: ::LPCWSTR, onWriterId: ::VSS_ID, wszOnLogicalPath: ::LPCWSTR, wszOnComponentName: ::LPCWSTR ) -> ::HRESULT, fn SetBackupSchema(&mut self, dwSchemaMask: ::DWORD) -> ::HRESULT, fn GetDocument(&mut self, pDoc: *mut *mut ::VOID) -> ::HRESULT, //TODO IXMLDOMDocument fn SaveAsXML(&mut self, pbstrXML: *mut ::BSTR) -> ::HRESULT } ); //IVssCreateWriterMetadataEx //IVssWriterImpl //IVssCreateExpressWriterMetadata //IVssExpressWriter //CVssWriter //CVssWriterEx //CVssWriterEx2 deps/winapi-0.2.5/src/threadpoolapi.rs0000644000000000000000000000054612605021253016427 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! ApiSet Contract for api-ms-win-core-threadpool-l1. pub type PTP_WIN32_IO_CALLBACK = Option; deps/winapi-0.2.5/src/qos.rs0000644000000000000000000000073212613167613014405 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! QoS definitions for NDIS components. pub type SERVICETYPE = ::ULONG; STRUCT!{struct FLOWSPEC { TokenRate: ::ULONG, TokenBucketSize: ::ULONG, PeakBandwidth: ::ULONG, Latency: ::ULONG, DelayVariation: ::ULONG, ServiceType: SERVICETYPE, MaxSduSize: ::ULONG, MinimumPolicedSize: ::ULONG, }} pub type PFLOWSPEC = *mut FLOWSPEC; pub type LPFLOWSPEC = *mut FLOWSPEC; deps/winapi-0.2.5/src/winscard.rs0000644000000000000000000002550712613167613015424 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Data Protection API Prototypes and Definitions // This header file provides the definitions and symbols necessary for an // Application or Smart Card Service Provider to access the Smartcard Subsystem. pub type LPCBYTE = *const ::BYTE; pub type SCARDCONTEXT = ::ULONG_PTR; pub type PSCARDCONTEXT = *mut SCARDCONTEXT; pub type LPSCARDCONTEXT = *mut SCARDCONTEXT; pub type SCARDHANDLE = ::ULONG_PTR; pub type PSCARDHANDLE = *mut SCARDHANDLE; pub type LPSCARDHANDLE = *mut SCARDHANDLE; pub const SCARD_AUTOALLOCATE: ::DWORD = -1i32 as ::DWORD; pub const SCARD_SCOPE_USER: ::DWORD = 0; pub const SCARD_SCOPE_TERMINAL: ::DWORD = 1; pub const SCARD_SCOPE_SYSTEM: ::DWORD = 2; pub const SCARD_PROVIDER_PRIMARY: ::DWORD = 1; pub const SCARD_PROVIDER_CSP: ::DWORD = 2; pub const SCARD_PROVIDER_KSP: ::DWORD = 3; #[repr(C)] #[derive(Copy)] pub struct SCARD_READERSTATEA { pub szReader: ::LPCSTR, pub pvUserData: ::LPVOID, pub dwCurrentState: ::DWORD, pub dwEventState: ::DWORD, pub cbAtr: ::DWORD, pub rgbAtr: [::BYTE; 36], } impl Clone for SCARD_READERSTATEA { fn clone(&self) -> SCARD_READERSTATEA { *self } } pub type PSCARD_READERSTATEA = *mut SCARD_READERSTATEA; pub type LPSCARD_READERSTATEA = *mut SCARD_READERSTATEA; #[repr(C)] #[derive(Copy)] pub struct SCARD_READERSTATEW { pub szReader: ::LPCWSTR, pub pvUserData: ::LPVOID, pub dwCurrentState: ::DWORD, pub dwEventState: ::DWORD, pub cbAtr: ::DWORD, pub rgbAtr: [::BYTE; 36], } impl Clone for SCARD_READERSTATEW { fn clone(&self) -> SCARD_READERSTATEW { *self } } pub type PSCARD_READERSTATEW = *mut SCARD_READERSTATEW; pub type LPSCARD_READERSTATEW = *mut SCARD_READERSTATEW; pub type SCARD_READERSTATE_A = SCARD_READERSTATEA; pub type SCARD_READERSTATE_W = SCARD_READERSTATEW; pub type PSCARD_READERSTATE_A = PSCARD_READERSTATEA; pub type PSCARD_READERSTATE_W = PSCARD_READERSTATEW; pub type LPSCARD_READERSTATE_A = LPSCARD_READERSTATEA; pub type LPSCARD_READERSTATE_W = LPSCARD_READERSTATEW; pub const SCARD_STATE_UNAWARE: ::DWORD = 0x00000000; pub const SCARD_STATE_IGNORE: ::DWORD = 0x00000001; pub const SCARD_STATE_CHANGED: ::DWORD = 0x00000002; pub const SCARD_STATE_UNKNOWN: ::DWORD = 0x00000004; pub const SCARD_STATE_UNAVAILABLE: ::DWORD = 0x00000008; pub const SCARD_STATE_EMPTY: ::DWORD = 0x00000010; pub const SCARD_STATE_PRESENT: ::DWORD = 0x00000020; pub const SCARD_STATE_ATRMATCH: ::DWORD = 0x00000040; pub const SCARD_STATE_EXCLUSIVE: ::DWORD = 0x00000080; pub const SCARD_STATE_INUSE: ::DWORD = 0x00000100; pub const SCARD_STATE_MUTE: ::DWORD = 0x00000200; pub const SCARD_STATE_UNPOWERED: ::DWORD = 0x00000400; #[repr(C)] #[derive(Copy)] pub struct SCARD_ATRMASK { pub cbAtr: ::DWORD, pub rgbAtr: [::BYTE; 36], pub rgbMask: [::BYTE; 36], } impl Clone for SCARD_ATRMASK { fn clone(&self) -> SCARD_ATRMASK { *self } } pub type PSCARD_ATRMASK = *mut SCARD_ATRMASK; pub type LPSCARD_ATRMASK = *mut SCARD_ATRMASK; pub const SCARD_SHARE_EXCLUSIVE: ::DWORD = 1; pub const SCARD_SHARE_SHARED: ::DWORD = 2; pub const SCARD_SHARE_DIRECT: ::DWORD = 3; pub const SCARD_LEAVE_CARD: ::DWORD = 0; pub const SCARD_RESET_CARD: ::DWORD = 1; pub const SCARD_UNPOWER_CARD: ::DWORD = 2; pub const SCARD_EJECT_CARD: ::DWORD = 3; pub const SC_DLG_MINIMAL_UI: ::DWORD = 0x01; pub const SC_DLG_NO_UI: ::DWORD = 0x02; pub const SC_DLG_FORCE_UI: ::DWORD = 0x04; pub const SCERR_NOCARDNAME: ::DWORD = 0x4000; pub const SCERR_NOGUIDS: ::DWORD = 0x8000; pub type LPOCNCONNPROCA = Option SCARDHANDLE>; pub type LPOCNCONNPROCW = Option SCARDHANDLE>; pub type LPOCNCHKPROC = Option ::BOOL>; pub type LPOCNDSCPROC = Option; #[repr(C)] #[derive(Copy)] pub struct OPENCARD_SEARCH_CRITERIAA { pub dwStructSize: ::DWORD, pub lpstrGroupNames: ::LPSTR, pub nMaxGroupNames: ::DWORD, pub rgguidInterfaces: ::LPCGUID, pub cguidInterfaces: ::DWORD, pub lpstrCardNames: ::LPSTR, pub nMaxCardNames: ::DWORD, pub lpfnCheck: LPOCNCHKPROC, pub lpfnConnect: LPOCNCONNPROCA, pub lpfnDisconnect: LPOCNDSCPROC, pub pvUserData: ::LPVOID, pub dwShareMode: ::DWORD, pub dwPreferredProtocols: ::DWORD, } impl Clone for OPENCARD_SEARCH_CRITERIAA { fn clone(&self) -> OPENCARD_SEARCH_CRITERIAA { *self } } pub type POPENCARD_SEARCH_CRITERIAA = *mut OPENCARD_SEARCH_CRITERIAA; pub type LPOPENCARD_SEARCH_CRITERIAA = *mut OPENCARD_SEARCH_CRITERIAA; #[repr(C)] #[derive(Copy)] pub struct OPENCARD_SEARCH_CRITERIAW { pub dwStructSize: ::DWORD, pub lpstrGroupNames: ::LPWSTR, pub nMaxGroupNames: ::DWORD, pub rgguidInterfaces: ::LPCGUID, pub cguidInterfaces: ::DWORD, pub lpstrCardNames: ::LPWSTR, pub nMaxCardNames: ::DWORD, pub lpfnCheck: LPOCNCHKPROC, pub lpfnConnect: LPOCNCONNPROCW, pub lpfnDisconnect: LPOCNDSCPROC, pub pvUserData: ::LPVOID, pub dwShareMode: ::DWORD, pub dwPreferredProtocols: ::DWORD, } impl Clone for OPENCARD_SEARCH_CRITERIAW { fn clone(&self) -> OPENCARD_SEARCH_CRITERIAW { *self } } pub type POPENCARD_SEARCH_CRITERIAW = *mut OPENCARD_SEARCH_CRITERIAW; pub type LPOPENCARD_SEARCH_CRITERIAW = *mut OPENCARD_SEARCH_CRITERIAW; #[repr(C)] #[derive(Copy)] pub struct OPENCARDNAME_EXA { pub dwStructSize: ::DWORD, pub hSCardContext: SCARDCONTEXT, pub hwndOwner: ::HWND, pub dwFlags: ::DWORD, pub lpstrTitle: ::LPCSTR, pub lpstrSearchDesc: ::LPCSTR, pub hIcon: ::HICON, pub pOpenCardSearchCriteria: POPENCARD_SEARCH_CRITERIAA, pub lpfnConnect: LPOCNCONNPROCA, pub pvUserData: ::LPVOID, pub dwShareMode: ::DWORD, pub dwPreferredProtocols: ::DWORD, pub lpstrRdr: ::LPSTR, pub nMaxRdr: ::DWORD, pub lpstrCard: ::LPSTR, pub nMaxCard: ::DWORD, pub dwActiveProtocol: ::DWORD, pub hCardHandle: SCARDHANDLE, } impl Clone for OPENCARDNAME_EXA { fn clone(&self) -> OPENCARDNAME_EXA { *self } } pub type POPENCARDNAME_EXA = *mut OPENCARDNAME_EXA; pub type LPOPENCARDNAME_EXA = *mut OPENCARDNAME_EXA; #[repr(C)] #[derive(Copy)] pub struct OPENCARDNAME_EXW { pub dwStructSize: ::DWORD, pub hSCardContext: SCARDCONTEXT, pub hwndOwner: ::HWND, pub dwFlags: ::DWORD, pub lpstrTitle: ::LPCWSTR, pub lpstrSearchDesc: ::LPCWSTR, pub hIcon: ::HICON, pub pOpenCardSearchCriteria: POPENCARD_SEARCH_CRITERIAW, pub lpfnConnect: LPOCNCONNPROCW, pub pvUserData: ::LPVOID, pub dwShareMode: ::DWORD, pub dwPreferredProtocols: ::DWORD, pub lpstrRdr: ::LPWSTR, pub nMaxRdr: ::DWORD, pub lpstrCard: ::LPWSTR, pub nMaxCard: ::DWORD, pub dwActiveProtocol: ::DWORD, pub hCardHandle: SCARDHANDLE, } impl Clone for OPENCARDNAME_EXW { fn clone(&self) -> OPENCARDNAME_EXW { *self } } pub type POPENCARDNAME_EXW = *mut OPENCARDNAME_EXW; pub type LPOPENCARDNAME_EXW = *mut OPENCARDNAME_EXW; pub type OPENCARDNAMEA_EX = OPENCARDNAME_EXA; pub type OPENCARDNAMEW_EX = OPENCARDNAME_EXW; pub type POPENCARDNAMEA_EX = POPENCARDNAME_EXA; pub type POPENCARDNAMEW_EX = POPENCARDNAME_EXW; pub type LPOPENCARDNAMEA_EX = LPOPENCARDNAME_EXA; pub type LPOPENCARDNAMEW_EX = LPOPENCARDNAME_EXW; pub const SCARD_READER_SEL_AUTH_PACKAGE: ::DWORD = -629i32 as ::DWORD; ENUM!{enum READER_SEL_REQUEST_MATCH_TYPE { RSR_MATCH_TYPE_READER_AND_CONTAINER = 1, RSR_MATCH_TYPE_SERIAL_NUMBER, RSR_MATCH_TYPE_ALL_CARDS, }} STRUCT!{struct READER_SEL_REQUEST_ReaderAndContainerParameter { cbReaderNameOffset: ::DWORD, cchReaderNameLength: ::DWORD, cbContainerNameOffset: ::DWORD, cchContainerNameLength: ::DWORD, dwDesiredCardModuleVersion: ::DWORD, dwCspFlags: ::DWORD, }} STRUCT!{struct READER_SEL_REQUEST_SerialNumberParameter { cbSerialNumberOffset: ::DWORD, cbSerialNumberLength: ::DWORD, dwDesiredCardModuleVersion: ::DWORD, }} STRUCT!{struct READER_SEL_REQUEST { dwShareMode: ::DWORD, dwPreferredProtocols: ::DWORD, MatchType: READER_SEL_REQUEST_MATCH_TYPE, ReaderAndContainerParameter: READER_SEL_REQUEST_ReaderAndContainerParameter, }} UNION!( READER_SEL_REQUEST, ReaderAndContainerParameter, SerialNumberParameter, SerialNumberParameter_mut, READER_SEL_REQUEST_SerialNumberParameter ); pub type PREADER_SEL_REQUEST = *mut READER_SEL_REQUEST; STRUCT!{struct READER_SEL_RESPONSE { cbReaderNameOffset: ::DWORD, cchReaderNameLength: ::DWORD, cbCardNameOffset: ::DWORD, cchCardNameLength: ::DWORD, }} pub type PREADER_SEL_RESPONSE = *mut READER_SEL_RESPONSE; #[repr(C)] #[derive(Copy)] pub struct OPENCARDNAMEA { pub dwStructSize: ::DWORD, pub hwndOwner: ::HWND, pub hSCardContext: SCARDCONTEXT, pub lpstrGroupNames: ::LPSTR, pub nMaxGroupNames: ::DWORD, pub lpstrCardNames: ::LPSTR, pub nMaxCardNames: ::DWORD, pub rgguidInterfaces: ::LPCGUID, pub cguidInterfaces: ::DWORD, pub lpstrRdr: ::LPSTR, pub nMaxRdr: ::DWORD, pub lpstrCard: ::LPSTR, pub nMaxCard: ::DWORD, pub lpstrTitle: ::LPCSTR, pub dwFlags: ::DWORD, pub pvUserData: ::LPVOID, pub dwShareMode: ::DWORD, pub dwPreferredProtocols: ::DWORD, pub dwActiveProtocol: ::DWORD, pub lpfnConnect: LPOCNCONNPROCA, pub lpfnCheck: LPOCNCHKPROC, pub lpfnDisconnect: LPOCNDSCPROC, pub hCardHandle: SCARDHANDLE, } impl Clone for OPENCARDNAMEA { fn clone(&self) -> OPENCARDNAMEA { *self } } pub type POPENCARDNAMEA = *mut OPENCARDNAMEA; pub type LPOPENCARDNAMEA = *mut OPENCARDNAMEA; #[repr(C)] #[derive(Copy)] pub struct OPENCARDNAMEW { pub dwStructSize: ::DWORD, pub hwndOwner: ::HWND, pub hSCardContext: SCARDCONTEXT, pub lpstrGroupNames: ::LPWSTR, pub nMaxGroupNames: ::DWORD, pub lpstrCardNames: ::LPWSTR, pub nMaxCardNames: ::DWORD, pub rgguidInterfaces: ::LPCGUID, pub cguidInterfaces: ::DWORD, pub lpstrRdr: ::LPWSTR, pub nMaxRdr: ::DWORD, pub lpstrCard: ::LPWSTR, pub nMaxCard: ::DWORD, pub lpstrTitle: ::LPCWSTR, pub dwFlags: ::DWORD, pub pvUserData: ::LPVOID, pub dwShareMode: ::DWORD, pub dwPreferredProtocols: ::DWORD, pub dwActiveProtocol: ::DWORD, pub lpfnConnect: LPOCNCONNPROCW, pub lpfnCheck: LPOCNCHKPROC, pub lpfnDisconnect: LPOCNDSCPROC, pub hCardHandle: SCARDHANDLE, } impl Clone for OPENCARDNAMEW { fn clone(&self) -> OPENCARDNAMEW { *self } } pub type POPENCARDNAMEW = *mut OPENCARDNAMEW; pub type LPOPENCARDNAMEW = *mut OPENCARDNAMEW; pub type OPENCARDNAME_A = OPENCARDNAMEA; pub type OPENCARDNAME_W = OPENCARDNAMEW; pub type POPENCARDNAME_A = POPENCARDNAMEA; pub type POPENCARDNAME_W = POPENCARDNAMEW; pub type LPOPENCARDNAME_A = LPOPENCARDNAMEA; pub type LPOPENCARDNAME_W = LPOPENCARDNAMEW; pub const SCARD_AUDIT_CHV_FAILURE: ::DWORD = 0x0; pub const SCARD_AUDIT_CHV_SUCCESS: ::DWORD = 0x1; deps/winapi-0.2.5/src/wincrypt.rs0000644000000000000000000031764212613167613015475 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Cryptographic API Prototypes and Definitions //108 pub const ALG_CLASS_ANY: ALG_ID = 0; pub const ALG_CLASS_SIGNATURE: ALG_ID = 1 << 13; pub const ALG_CLASS_MSG_ENCRYPT: ALG_ID = 2 << 13; pub const ALG_CLASS_DATA_ENCRYPT: ALG_ID = 3 << 13; pub const ALG_CLASS_HASH: ALG_ID = 4 << 13; pub const ALG_CLASS_KEY_EXCHANGE: ALG_ID = 5 << 13; pub const ALG_CLASS_ALL: ALG_ID = 7 << 13; pub const ALG_TYPE_ANY: ALG_ID = 0; pub const ALG_TYPE_DSS: ALG_ID = 1 << 9; pub const ALG_TYPE_RSA: ALG_ID = 2 << 9; pub const ALG_TYPE_BLOCK: ALG_ID = 3 << 9; pub const ALG_TYPE_STREAM: ALG_ID = 4 << 9; pub const ALG_TYPE_DH: ALG_ID = 5 << 9; pub const ALG_TYPE_SECURECHANNEL: ALG_ID = 6 << 9; pub const ALG_SID_ANY: ALG_ID = 0; pub const ALG_SID_RSA_ANY: ALG_ID = 0; pub const ALG_SID_RSA_PKCS: ALG_ID = 1; pub const ALG_SID_RSA_MSATWORK: ALG_ID = 2; pub const ALG_SID_RSA_ENTRUST: ALG_ID = 3; pub const ALG_SID_RSA_PGP: ALG_ID = 4; pub const ALG_SID_DSS_ANY: ALG_ID = 0; pub const ALG_SID_DSS_PKCS: ALG_ID = 1; pub const ALG_SID_DSS_DMS: ALG_ID = 2; pub const ALG_SID_ECDSA: ALG_ID = 3; pub const ALG_SID_DES: ALG_ID = 1; pub const ALG_SID_3DES: ALG_ID = 3; pub const ALG_SID_DESX: ALG_ID = 4; pub const ALG_SID_IDEA: ALG_ID = 5; pub const ALG_SID_CAST: ALG_ID = 6; pub const ALG_SID_SAFERSK64: ALG_ID = 7; pub const ALG_SID_SAFERSK128: ALG_ID = 8; pub const ALG_SID_3DES_112: ALG_ID = 9; pub const ALG_SID_CYLINK_MEK: ALG_ID = 12; pub const ALG_SID_RC5: ALG_ID = 13; pub const ALG_SID_AES_128: ALG_ID = 14; pub const ALG_SID_AES_192: ALG_ID = 15; pub const ALG_SID_AES_256: ALG_ID = 16; pub const ALG_SID_AES: ALG_ID = 17; pub const ALG_SID_SKIPJACK: ALG_ID = 10; pub const ALG_SID_TEK: ALG_ID = 11; pub const CRYPT_MODE_CBCI: ALG_ID = 6; pub const CRYPT_MODE_CFBP: ALG_ID = 7; pub const CRYPT_MODE_OFBP: ALG_ID = 8; pub const CRYPT_MODE_CBCOFM: ALG_ID = 9; pub const CRYPT_MODE_CBCOFMI: ALG_ID = 10; pub const ALG_SID_RC2: ALG_ID = 2; pub const ALG_SID_RC4: ALG_ID = 1; pub const ALG_SID_SEAL: ALG_ID = 2; pub const ALG_SID_DH_SANDF: ALG_ID = 1; pub const ALG_SID_DH_EPHEM: ALG_ID = 2; pub const ALG_SID_AGREED_KEY_ANY: ALG_ID = 3; pub const ALG_SID_KEA: ALG_ID = 4; pub const ALG_SID_ECDH: ALG_ID = 5; pub const ALG_SID_MD2: ALG_ID = 1; pub const ALG_SID_MD4: ALG_ID = 2; pub const ALG_SID_MD5: ALG_ID = 3; pub const ALG_SID_SHA: ALG_ID = 4; pub const ALG_SID_SHA1: ALG_ID = 4; pub const ALG_SID_MAC: ALG_ID = 5; pub const ALG_SID_RIPEMD: ALG_ID = 6; pub const ALG_SID_RIPEMD160: ALG_ID = 7; pub const ALG_SID_SSL3SHAMD5: ALG_ID = 8; pub const ALG_SID_HMAC: ALG_ID = 9; pub const ALG_SID_TLS1PRF: ALG_ID = 10; pub const ALG_SID_HASH_REPLACE_OWF: ALG_ID = 11; pub const ALG_SID_SHA_256: ALG_ID = 12; pub const ALG_SID_SHA_384: ALG_ID = 13; pub const ALG_SID_SHA_512: ALG_ID = 14; pub const ALG_SID_SSL3_MASTER: ALG_ID = 1; pub const ALG_SID_SCHANNEL_MASTER_HASH: ALG_ID = 2; pub const ALG_SID_SCHANNEL_MAC_KEY: ALG_ID = 3; pub const ALG_SID_PCT1_MASTER: ALG_ID = 4; pub const ALG_SID_SSL2_MASTER: ALG_ID = 5; pub const ALG_SID_TLS1_MASTER: ALG_ID = 6; pub const ALG_SID_SCHANNEL_ENC_KEY: ALG_ID = 7; pub const ALG_SID_ECMQV: ALG_ID = 1; pub const ALG_SID_EXAMPLE: ALG_ID = 80; pub type ALG_ID = ::c_uint; pub const CALG_MD2: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD2; pub const CALG_MD4: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD4; pub const CALG_MD5: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD5; pub const CALG_SHA: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA; pub const CALG_SHA1: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA1; pub const CALG_MAC: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MAC; pub const CALG_RSA_SIGN: ALG_ID = ALG_CLASS_SIGNATURE | ALG_TYPE_RSA | ALG_SID_RSA_ANY; pub const CALG_DSS_SIGN: ALG_ID = ALG_CLASS_SIGNATURE | ALG_TYPE_DSS | ALG_SID_DSS_ANY; pub const CALG_NO_SIGN: ALG_ID = ALG_CLASS_SIGNATURE | ALG_TYPE_ANY | ALG_SID_ANY; pub const CALG_RSA_KEYX: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_RSA | ALG_SID_RSA_ANY; pub const CALG_DES: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_DES; pub const CALG_3DES_112: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_3DES_112; pub const CALG_3DES: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_3DES; pub const CALG_DESX: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_DESX; pub const CALG_RC2: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_RC2; pub const CALG_RC4: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM | ALG_SID_RC4; pub const CALG_SEAL: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM | ALG_SID_SEAL; pub const CALG_DH_SF: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_DH_SANDF; pub const CALG_DH_EPHEM: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_DH_EPHEM; pub const CALG_AGREEDKEY_ANY: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_AGREED_KEY_ANY; pub const CALG_KEA_KEYX: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_KEA; pub const CALG_HUGHES_MD5: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_ANY | ALG_SID_MD5; pub const CALG_SKIPJACK: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_SKIPJACK; pub const CALG_TEK: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_TEK; pub const CALG_CYLINK_MEK: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_CYLINK_MEK; pub const CALG_SSL3_SHAMD5: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SSL3SHAMD5; pub const CALG_SSL3_MASTER: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_SSL3_MASTER; pub const CALG_SCHANNEL_MASTER_HASH: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_SCHANNEL_MASTER_HASH; pub const CALG_SCHANNEL_MAC_KEY: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_SCHANNEL_MAC_KEY; pub const CALG_SCHANNEL_ENC_KEY: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_SCHANNEL_ENC_KEY; pub const CALG_PCT1_MASTER: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_PCT1_MASTER; pub const CALG_SSL2_MASTER: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_SSL2_MASTER; pub const CALG_TLS1_MASTER: ALG_ID = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_TLS1_MASTER; pub const CALG_RC5: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_RC5; pub const CALG_HMAC: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_HMAC; pub const CALG_TLS1PRF: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_TLS1PRF; pub const CALG_HASH_REPLACE_OWF: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_HASH_REPLACE_OWF; pub const CALG_AES_128: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_128; pub const CALG_AES_192: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_192; pub const CALG_AES_256: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_256; pub const CALG_AES: ALG_ID = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES; pub const CALG_SHA_256: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_256; pub const CALG_SHA_384: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_384; pub const CALG_SHA_512: ALG_ID = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_512; pub const CALG_ECDH: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_ECDH; pub const CALG_ECMQV: ALG_ID = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_ANY | ALG_SID_ECMQV; pub const CALG_ECDSA: ALG_ID = ALG_CLASS_SIGNATURE | ALG_TYPE_DSS | ALG_SID_ECDSA; pub type HCRYPTPROV = ::ULONG_PTR; pub type HCRYPTKEY = ::ULONG_PTR; pub type HCRYPTHASH = ::ULONG_PTR; pub const CRYPT_VERIFYCONTEXT: ::DWORD = 0xF0000000; pub const CRYPT_NEWKEYSET: ::DWORD = 0x00000008; pub const CRYPT_DELETEKEYSET: ::DWORD = 0x00000010; pub const CRYPT_MACHINE_KEYSET: ::DWORD = 0x00000020; pub const CRYPT_SILENT: ::DWORD = 0x00000040; pub const CRYPT_DEFAULT_CONTAINER_OPTIONAL: ::DWORD = 0x00000080; pub const CRYPT_EXPORTABLE: ::DWORD = 0x00000001; pub const CRYPT_USER_PROTECTED: ::DWORD = 0x00000002; pub const CRYPT_CREATE_SALT: ::DWORD = 0x00000004; pub const CRYPT_UPDATE_KEY: ::DWORD = 0x00000008; pub const CRYPT_NO_SALT: ::DWORD = 0x00000010; pub const CRYPT_PREGEN: ::DWORD = 0x00000040; pub const CRYPT_RECIPIENT: ::DWORD = 0x00000010; pub const CRYPT_INITIATOR: ::DWORD = 0x00000040; pub const CRYPT_ONLINE: ::DWORD = 0x00000080; pub const CRYPT_SF: ::DWORD = 0x00000100; pub const CRYPT_CREATE_IV: ::DWORD = 0x00000200; pub const CRYPT_KEK: ::DWORD = 0x00000400; pub const CRYPT_DATA_KEY: ::DWORD = 0x00000800; pub const CRYPT_VOLATILE: ::DWORD = 0x00001000; pub const CRYPT_SGCKEY: ::DWORD = 0x00002000; pub const CRYPT_USER_PROTECTED_STRONG: ::DWORD = 0x00100000; pub const CRYPT_ARCHIVABLE: ::DWORD = 0x00004000; pub const CRYPT_FORCE_KEY_PROTECTION_HIGH: ::DWORD = 0x00008000; pub const RSA1024BIT_KEY: ::DWORD = 0x04000000; pub const CRYPT_SERVER: ::DWORD = 0x00000400; pub const KEY_LENGTH_MASK: ::DWORD = 0xFFFF0000; pub const CRYPT_Y_ONLY: ::DWORD = 0x00000001; pub const CRYPT_SSL2_FALLBACK: ::DWORD = 0x00000002; pub const CRYPT_DESTROYKEY: ::DWORD = 0x00000004; pub const CRYPT_OAEP: ::DWORD = 0x00000040; pub const CRYPT_BLOB_VER3: ::DWORD = 0x00000080; pub const CRYPT_IPSEC_HMAC_KEY: ::DWORD = 0x00000100; pub const CRYPT_DECRYPT_RSA_NO_PADDING_CHECK: ::DWORD = 0x00000020; pub const CRYPT_SECRETDIGEST: ::DWORD = 0x00000001; pub const CRYPT_OWF_REPL_LM_HASH: ::DWORD = 0x00000001; pub const CRYPT_LITTLE_ENDIAN: ::DWORD = 0x00000001; pub const CRYPT_NOHASHOID: ::DWORD = 0x00000001; pub const CRYPT_TYPE2_FORMAT: ::DWORD = 0x00000002; pub const CRYPT_X931_FORMAT: ::DWORD = 0x00000004; pub const CRYPT_MACHINE_DEFAULT: ::DWORD = 0x00000001; pub const CRYPT_USER_DEFAULT: ::DWORD = 0x00000002; pub const CRYPT_DELETE_DEFAULT: ::DWORD = 0x00000004; pub const SIMPLEBLOB: ::DWORD = 0x1; pub const PUBLICKEYBLOB: ::DWORD = 0x6; pub const PRIVATEKEYBLOB: ::DWORD = 0x7; pub const PLAINTEXTKEYBLOB: ::DWORD = 0x8; pub const OPAQUEKEYBLOB: ::DWORD = 0x9; pub const PUBLICKEYBLOBEX: ::DWORD = 0xA; pub const SYMMETRICWRAPKEYBLOB: ::DWORD = 0xB; pub const KEYSTATEBLOB: ::DWORD = 0xC; pub const AT_KEYEXCHANGE: ::DWORD = 1; pub const AT_SIGNATURE: ::DWORD = 2; pub const CRYPT_USERDATA: ::DWORD = 1; pub const KP_IV: ::DWORD = 1; pub const KP_SALT: ::DWORD = 2; pub const KP_PADDING: ::DWORD = 3; pub const KP_MODE: ::DWORD = 4; pub const KP_MODE_BITS: ::DWORD = 5; pub const KP_PERMISSIONS: ::DWORD = 6; pub const KP_ALGID: ::DWORD = 7; pub const KP_BLOCKLEN: ::DWORD = 8; pub const KP_KEYLEN: ::DWORD = 9; pub const KP_SALT_EX: ::DWORD = 10; pub const KP_P: ::DWORD = 11; pub const KP_G: ::DWORD = 12; pub const KP_Q: ::DWORD = 13; pub const KP_X: ::DWORD = 14; pub const KP_Y: ::DWORD = 15; pub const KP_RA: ::DWORD = 16; pub const KP_RB: ::DWORD = 17; pub const KP_INFO: ::DWORD = 18; pub const KP_EFFECTIVE_KEYLEN: ::DWORD = 19; pub const KP_SCHANNEL_ALG: ::DWORD = 20; pub const KP_CLIENT_RANDOM: ::DWORD = 21; pub const KP_SERVER_RANDOM: ::DWORD = 22; pub const KP_RP: ::DWORD = 23; pub const KP_PRECOMP_MD5: ::DWORD = 24; pub const KP_PRECOMP_SHA: ::DWORD = 25; pub const KP_CERTIFICATE: ::DWORD = 26; pub const KP_CLEAR_KEY: ::DWORD = 27; pub const KP_PUB_EX_LEN: ::DWORD = 28; pub const KP_PUB_EX_VAL: ::DWORD = 29; pub const KP_KEYVAL: ::DWORD = 30; pub const KP_ADMIN_PIN: ::DWORD = 31; pub const KP_KEYEXCHANGE_PIN: ::DWORD = 32; pub const KP_SIGNATURE_PIN: ::DWORD = 33; pub const KP_PREHASH: ::DWORD = 34; pub const KP_ROUNDS: ::DWORD = 35; pub const KP_OAEP_PARAMS: ::DWORD = 36; pub const KP_CMS_KEY_INFO: ::DWORD = 37; pub const KP_CMS_DH_KEY_INFO: ::DWORD = 38; pub const KP_PUB_PARAMS: ::DWORD = 39; pub const KP_VERIFY_PARAMS: ::DWORD = 40; pub const KP_HIGHEST_VERSION: ::DWORD = 41; pub const KP_GET_USE_COUNT: ::DWORD = 42; pub const KP_PIN_ID: ::DWORD = 43; pub const KP_PIN_INFO: ::DWORD = 44; pub const PKCS5_PADDING: ::DWORD = 1; pub const RANDOM_PADDING: ::DWORD = 2; pub const ZERO_PADDING: ::DWORD = 3; pub const CRYPT_MODE_CBC: ::DWORD = 1; pub const CRYPT_MODE_ECB: ::DWORD = 2; pub const CRYPT_MODE_OFB: ::DWORD = 3; pub const CRYPT_MODE_CFB: ::DWORD = 4; pub const CRYPT_MODE_CTS: ::DWORD = 5; pub const CRYPT_ENCRYPT: ::DWORD = 0x0001; pub const CRYPT_DECRYPT: ::DWORD = 0x0002; pub const CRYPT_EXPORT: ::DWORD = 0x0004; pub const CRYPT_READ: ::DWORD = 0x0008; pub const CRYPT_WRITE: ::DWORD = 0x0010; pub const CRYPT_MAC: ::DWORD = 0x0020; pub const CRYPT_EXPORT_KEY: ::DWORD = 0x0040; pub const CRYPT_IMPORT_KEY: ::DWORD = 0x0080; pub const CRYPT_ARCHIVE: ::DWORD = 0x0100; pub const HP_ALGID: ::DWORD = 0x0001; pub const HP_HASHVAL: ::DWORD = 0x0002; pub const HP_HASHSIZE: ::DWORD = 0x0004; pub const HP_HMAC_INFO: ::DWORD = 0x0005; pub const HP_TLS1PRF_LABEL: ::DWORD = 0x0006; pub const HP_TLS1PRF_SEED: ::DWORD = 0x0007; pub const CRYPT_FAILED: ::BOOL = ::FALSE; pub const CRYPT_SUCCEED: ::BOOL = ::TRUE; pub const PP_ENUMALGS: ::DWORD = 1; pub const PP_ENUMCONTAINERS: ::DWORD = 2; pub const PP_IMPTYPE: ::DWORD = 3; pub const PP_NAME: ::DWORD = 4; pub const PP_VERSION: ::DWORD = 5; pub const PP_CONTAINER: ::DWORD = 6; pub const PP_CHANGE_PASSWORD: ::DWORD = 7; pub const PP_KEYSET_SEC_DESCR: ::DWORD = 8; pub const PP_CERTCHAIN: ::DWORD = 9; pub const PP_KEY_TYPE_SUBTYPE: ::DWORD = 10; pub const PP_PROVTYPE: ::DWORD = 16; pub const PP_KEYSTORAGE: ::DWORD = 17; pub const PP_APPLI_CERT: ::DWORD = 18; pub const PP_SYM_KEYSIZE: ::DWORD = 19; pub const PP_SESSION_KEYSIZE: ::DWORD = 20; pub const PP_UI_PROMPT: ::DWORD = 21; pub const PP_ENUMALGS_EX: ::DWORD = 22; pub const PP_ENUMMANDROOTS: ::DWORD = 25; pub const PP_ENUMELECTROOTS: ::DWORD = 26; pub const PP_KEYSET_TYPE: ::DWORD = 27; pub const PP_ADMIN_PIN: ::DWORD = 31; pub const PP_KEYEXCHANGE_PIN: ::DWORD = 32; pub const PP_SIGNATURE_PIN: ::DWORD = 33; pub const PP_SIG_KEYSIZE_INC: ::DWORD = 34; pub const PP_KEYX_KEYSIZE_INC: ::DWORD = 35; pub const PP_UNIQUE_CONTAINER: ::DWORD = 36; pub const PP_SGC_INFO: ::DWORD = 37; pub const PP_USE_HARDWARE_RNG: ::DWORD = 38; pub const PP_KEYSPEC: ::DWORD = 39; pub const PP_ENUMEX_SIGNING_PROT: ::DWORD = 40; pub const PP_CRYPT_COUNT_KEY_USE: ::DWORD = 41; pub const PP_USER_CERTSTORE: ::DWORD = 42; pub const PP_SMARTCARD_READER: ::DWORD = 43; pub const PP_SMARTCARD_GUID: ::DWORD = 45; pub const PP_ROOT_CERTSTORE: ::DWORD = 46; pub const PP_SMARTCARD_READER_ICON: ::DWORD = 47; pub const CRYPT_FIRST: ::DWORD = 1; pub const CRYPT_NEXT: ::DWORD = 2; pub const CRYPT_SGC_ENUM: ::DWORD = 4; pub const CRYPT_IMPL_HARDWARE: ::DWORD = 1; pub const CRYPT_IMPL_SOFTWARE: ::DWORD = 2; pub const CRYPT_IMPL_MIXED: ::DWORD = 3; pub const CRYPT_IMPL_UNKNOWN: ::DWORD = 4; pub const CRYPT_IMPL_REMOVABLE: ::DWORD = 8; pub const CRYPT_SEC_DESCR: ::DWORD = 0x00000001; pub const CRYPT_PSTORE: ::DWORD = 0x00000002; pub const CRYPT_UI_PROMPT: ::DWORD = 0x00000004; pub const CRYPT_FLAG_PCT1: ::DWORD = 0x0001; pub const CRYPT_FLAG_SSL2: ::DWORD = 0x0002; pub const CRYPT_FLAG_SSL3: ::DWORD = 0x0004; pub const CRYPT_FLAG_TLS1: ::DWORD = 0x0008; pub const CRYPT_FLAG_IPSEC: ::DWORD = 0x0010; pub const CRYPT_FLAG_SIGNING: ::DWORD = 0x0020; pub const CRYPT_SGC: ::DWORD = 0x0001; pub const CRYPT_FASTSGC: ::DWORD = 0x0002; pub const PP_CLIENT_HWND: ::DWORD = 1; pub const PP_CONTEXT_INFO: ::DWORD = 11; pub const PP_KEYEXCHANGE_KEYSIZE: ::DWORD = 12; pub const PP_SIGNATURE_KEYSIZE: ::DWORD = 13; pub const PP_KEYEXCHANGE_ALG: ::DWORD = 14; pub const PP_SIGNATURE_ALG: ::DWORD = 15; pub const PP_DELETEKEY: ::DWORD = 24; pub const PP_PIN_PROMPT_STRING: ::DWORD = 44; pub const PP_SECURE_KEYEXCHANGE_PIN: ::DWORD = 47; pub const PP_SECURE_SIGNATURE_PIN: ::DWORD = 48; pub const PROV_RSA_FULL: ::DWORD = 1; pub const PROV_RSA_SIG: ::DWORD = 2; pub const PROV_DSS: ::DWORD = 3; pub const PROV_FORTEZZA: ::DWORD = 4; pub const PROV_MS_EXCHANGE: ::DWORD = 5; pub const PROV_SSL: ::DWORD = 6; pub const PROV_RSA_SCHANNEL: ::DWORD = 12; pub const PROV_DSS_DH: ::DWORD = 13; pub const PROV_EC_ECDSA_SIG: ::DWORD = 14; pub const PROV_EC_ECNRA_SIG: ::DWORD = 15; pub const PROV_EC_ECDSA_FULL: ::DWORD = 16; pub const PROV_EC_ECNRA_FULL: ::DWORD = 17; pub const PROV_DH_SCHANNEL: ::DWORD = 18; pub const PROV_SPYRUS_LYNKS: ::DWORD = 20; pub const PROV_RNG: ::DWORD = 21; pub const PROV_INTEL_SEC: ::DWORD = 22; pub const PROV_REPLACE_OWF: ::DWORD = 23; pub const PROV_RSA_AES: ::DWORD = 24; pub const MS_DEF_PROV: &'static str = "Microsoft Base Cryptographic Provider v1.0"; pub const MS_ENHANCED_PROV: &'static str = "Microsoft Enhanced Cryptographic Provider v1.0"; pub const MS_STRONG_PROV: &'static str = "Microsoft Strong Cryptographic Provider"; pub const MS_DEF_RSA_SIG_PROV: &'static str = "Microsoft RSA Signature Cryptographic Provider"; pub const MS_DEF_RSA_SCHANNEL_PROV: &'static str = "Microsoft RSA SChannel Cryptographic Provider"; pub const MS_DEF_DSS_PROV: &'static str = "Microsoft Base DSS Cryptographic Provider"; pub const MS_DEF_DSS_DH_PROV: &'static str = "Microsoft Base DSS and Diffie-Hellman Cryptographic Provider"; pub const MS_ENH_DSS_DH_PROV: &'static str = "Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider"; pub const MS_DEF_DH_SCHANNEL_PROV: &'static str = "Microsoft DH SChannel Cryptographic Provider"; pub const MS_SCARD_PROV: &'static str = "Microsoft Base Smart Card Crypto Provider"; pub const MS_ENH_RSA_AES_PROV: &'static str = "Microsoft Enhanced RSA and AES Cryptographic Provider"; pub const MS_ENH_RSA_AES_PROV_XP: &'static str = "Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)"; pub const MAXUIDLEN: usize = 64; pub const EXPO_OFFLOAD_REG_VALUE: &'static str = "ExpoOffload"; pub const EXPO_OFFLOAD_FUNC_NAME: &'static str = "OffloadModExpo"; pub const szKEY_CRYPTOAPI_PRIVATE_KEY_OPTIONS: &'static str = "Software\\Policies\\Microsoft\\Cryptography"; pub const szKEY_CACHE_ENABLED: &'static str = "CachePrivateKeys"; pub const szKEY_CACHE_SECONDS: &'static str = "PrivateKeyLifetimeSeconds"; pub const szPRIV_KEY_CACHE_MAX_ITEMS: &'static str = "PrivKeyCacheMaxItems"; pub const cPRIV_KEY_CACHE_MAX_ITEMS_DEFAULT: ::DWORD = 20; pub const szPRIV_KEY_CACHE_PURGE_INTERVAL_SECONDS: &'static str = "PrivKeyCachePurgeIntervalSeconds"; pub const cPRIV_KEY_CACHE_PURGE_INTERVAL_SECONDS_DEFAULT: ::DWORD = 86400; pub const CUR_BLOB_VERSION: ::DWORD = 2; STRUCT!{struct CMS_KEY_INFO { dwVersion: ::DWORD, Algid: ALG_ID, pbOID: *mut ::BYTE, cbOID: ::DWORD, }} pub type PCMS_KEY_INFO = *mut CMS_KEY_INFO; STRUCT!{struct HMAC_INFO { HashAlgid: ALG_ID, pbInnerString: *mut ::BYTE, cbInnerString: ::DWORD, pbOuterString: *mut ::BYTE, cbOuterString: ::DWORD, }} pub type PHMAC_INFO = *mut HMAC_INFO; STRUCT!{struct SCHANNEL_ALG { dwUse: ::DWORD, Algid: ALG_ID, cBits: ::DWORD, dwFlags: ::DWORD, dwReserved: ::DWORD, }} pub type PSCHANNEL_ALG = *mut SCHANNEL_ALG; pub const SCHANNEL_MAC_KEY: ::DWORD = 0x00000000; pub const SCHANNEL_ENC_KEY: ::DWORD = 0x00000001; pub const INTERNATIONAL_USAGE: ::DWORD = 0x00000001; STRUCT!{struct PROV_ENUMALGS { aiAlgid: ALG_ID, dwBitLen: ::DWORD, dwNameLen: ::DWORD, szName: [::CHAR; 20], }} #[repr(C)] #[derive(Copy)] pub struct PROV_ENUMALGS_EX { pub aiAlgid: ALG_ID, pub dwDefaultLen: ::DWORD, pub dwMinLen: ::DWORD, pub dwMaxLen: ::DWORD, pub dwProtocols: ::DWORD, pub dwNameLen: ::DWORD, pub szName: [::CHAR; 20], pub dwLongNameLen: ::DWORD, pub szLongName: [::CHAR; 40], } impl Clone for PROV_ENUMALGS_EX { fn clone(&self) -> PROV_ENUMALGS_EX { *self } } STRUCT!{struct BLOBHEADER { bType: ::BYTE, bVersion: ::BYTE, reserved: ::WORD, aiKeyAlg: ::ALG_ID, }} pub type PUBLICKEYSTRUC = BLOBHEADER; STRUCT!{struct RSAPUBKEY { magic: ::DWORD, bitlen: ::DWORD, pubexp: ::DWORD, }} STRUCT!{struct DHPUBKEY { magic: ::DWORD, bitlen: ::DWORD, }} pub type DSSPUBKEY = DHPUBKEY; pub type KEAPUBKEY = DHPUBKEY; pub type TEKPUBKEY = DHPUBKEY; STRUCT!{struct DSSSEED { counter: ::DWORD, seed: [::BYTE; 20], }} STRUCT!{struct DHPUBKEY_VER3 { magic: ::DWORD, bitlenP: ::DWORD, bitlenQ: ::DWORD, bitlenJ: ::DWORD, DSSSeed: DSSSEED, }} pub type DSSPUBKEY_VER3 = DHPUBKEY_VER3; STRUCT!{struct DHPRIVKEY_VER3 { magic: ::DWORD, bitlenP: ::DWORD, bitlenQ: ::DWORD, bitlenJ: ::DWORD, bitlenX: ::DWORD, DSSSeed: DSSSEED, }} pub type DSSPRIVKEY_VER3 = DHPRIVKEY_VER3; STRUCT!{struct KEY_TYPE_SUBTYPE { dwKeySpec: ::DWORD, Type: ::GUID, Subtype: ::GUID, }} pub type PKEY_TYPE_SUBTYPE = *mut KEY_TYPE_SUBTYPE; #[repr(C)] #[derive(Copy)] pub struct CERT_FORTEZZA_DATA_PROP { pub SerialNumber: [::c_uchar; 8], pub CertIndex: ::c_int, pub CertLabel: [::c_uchar; 36], } impl Clone for CERT_FORTEZZA_DATA_PROP { fn clone(&self) -> CERT_FORTEZZA_DATA_PROP { *self } } #[repr(C)] #[derive(Copy)] pub struct CRYPT_RC4_KEY_STATE { pub Key: [::c_uchar; 16], pub SBox: [::c_uchar; 256], pub i: ::c_uchar, pub j: ::c_uchar, } impl Clone for CRYPT_RC4_KEY_STATE { fn clone(&self) -> CRYPT_RC4_KEY_STATE { *self } } pub type PCRYPT_RC4_KEY_STATE = *mut CRYPT_RC4_KEY_STATE; STRUCT!{struct CRYPT_DES_KEY_STATE { Key: [::c_uchar; 8], IV: [::c_uchar; 8], Feedback: [::c_uchar; 8], }} pub type PCRYPT_DES_KEY_STATE = *mut CRYPT_DES_KEY_STATE; STRUCT!{struct CRYPT_3DES_KEY_STATE { Key: [::c_uchar; 24], IV: [::c_uchar; 8], Feedback: [::c_uchar; 8], }} pub type PCRYPT_3DES_KEY_STATE = *mut CRYPT_3DES_KEY_STATE; STRUCT!{struct CRYPT_AES_128_KEY_STATE { Key: [::c_uchar; 16], IV: [::c_uchar; 16], EncryptionState: [[::c_uchar; 16]; 11], DecryptionState: [[::c_uchar; 16]; 11], Feedback: [::c_uchar; 16], }} pub type PCRYPT_AES_128_KEY_STATE = *mut CRYPT_AES_128_KEY_STATE; STRUCT!{struct CRYPT_AES_256_KEY_STATE { Key: [::c_uchar; 32], IV: [::c_uchar; 16], EncryptionState: [[::c_uchar; 16]; 15], DecryptionState: [[::c_uchar; 16]; 15], Feedback: [::c_uchar; 16], }} pub type PCRYPT_AES_256_KEY_STATE = *mut CRYPT_AES_256_KEY_STATE; STRUCT!{struct CRYPTOAPI_BLOB { cbData: ::DWORD, pbData: *mut ::BYTE, }} pub type CRYPT_INTEGER_BLOB = CRYPTOAPI_BLOB; pub type PCRYPT_INTEGER_BLOB = *mut CRYPTOAPI_BLOB; pub type CRYPT_UINT_BLOB = CRYPTOAPI_BLOB; pub type PCRYPT_UINT_BLOB = *mut CRYPTOAPI_BLOB; pub type CRYPT_OBJID_BLOB = CRYPTOAPI_BLOB; pub type PCRYPT_OBJID_BLOB = *mut CRYPTOAPI_BLOB; pub type CERT_NAME_BLOB = CRYPTOAPI_BLOB; pub type PCERT_NAME_BLOB = *mut CRYPTOAPI_BLOB; pub type CERT_RDN_VALUE_BLOB = CRYPTOAPI_BLOB; pub type PCERT_RDN_VALUE_BLOB = *mut CRYPTOAPI_BLOB; pub type CERT_BLOB = CRYPTOAPI_BLOB; pub type PCERT_BLOB = *mut CRYPTOAPI_BLOB; pub type CRL_BLOB = CRYPTOAPI_BLOB; pub type PCRL_BLOB = *mut CRYPTOAPI_BLOB; pub type DATA_BLOB = CRYPTOAPI_BLOB; pub type PDATA_BLOB = *mut CRYPTOAPI_BLOB; pub type CRYPT_DATA_BLOB = CRYPTOAPI_BLOB; pub type PCRYPT_DATA_BLOB = *mut CRYPTOAPI_BLOB; pub type CRYPT_HASH_BLOB = CRYPTOAPI_BLOB; pub type PCRYPT_HASH_BLOB = *mut CRYPTOAPI_BLOB; pub type CRYPT_DIGEST_BLOB = CRYPTOAPI_BLOB; pub type PCRYPT_DIGEST_BLOB = *mut CRYPTOAPI_BLOB; pub type CRYPT_DER_BLOB = CRYPTOAPI_BLOB; pub type PCRYPT_DER_BLOB = *mut CRYPTOAPI_BLOB; pub type CRYPT_ATTR_BLOB = CRYPTOAPI_BLOB; pub type PCRYPT_ATTR_BLOB = *mut CRYPTOAPI_BLOB; STRUCT!{struct CMS_DH_KEY_INFO { dwVersion: ::DWORD, Algid: ALG_ID, pszContentEncObjId: ::LPSTR, PubInfo: CRYPT_DATA_BLOB, pReserved: *mut ::c_void, }} pub type PCMS_DH_KEY_INFO = *mut CMS_DH_KEY_INFO; pub type HCRYPTPROV_OR_NCRYPT_KEY_HANDLE = ::ULONG_PTR; pub type HCRYPTPROV_LEGACY = ::ULONG_PTR; STRUCT!{struct CRYPT_BIT_BLOB { cbData: ::DWORD, pbData: *mut ::BYTE, cUnusedBits: ::DWORD, }} pub type PCRYPT_BIT_BLOB = *mut CRYPT_BIT_BLOB; STRUCT!{struct CRYPT_ALGORITHM_IDENTIFIER { pszObjId: ::LPSTR, Parameters: CRYPT_OBJID_BLOB, }} pub type PCRYPT_ALGORITHM_IDENTIFIER = *mut CRYPT_ALGORITHM_IDENTIFIER; pub const szOID_RSA: &'static str = "1.2.840.113549"; pub const szOID_PKCS: &'static str = "1.2.840.113549.1"; pub const szOID_RSA_HASH: &'static str = "1.2.840.113549.2"; pub const szOID_RSA_ENCRYPT: &'static str = "1.2.840.113549.3"; pub const szOID_PKCS_1: &'static str = "1.2.840.113549.1.1"; pub const szOID_PKCS_2: &'static str = "1.2.840.113549.1.2"; pub const szOID_PKCS_3: &'static str = "1.2.840.113549.1.3"; pub const szOID_PKCS_4: &'static str = "1.2.840.113549.1.4"; pub const szOID_PKCS_5: &'static str = "1.2.840.113549.1.5"; pub const szOID_PKCS_6: &'static str = "1.2.840.113549.1.6"; pub const szOID_PKCS_7: &'static str = "1.2.840.113549.1.7"; pub const szOID_PKCS_8: &'static str = "1.2.840.113549.1.8"; pub const szOID_PKCS_9: &'static str = "1.2.840.113549.1.9"; pub const szOID_PKCS_10: &'static str = "1.2.840.113549.1.10"; pub const szOID_PKCS_12: &'static str = "1.2.840.113549.1.12"; pub const szOID_RSA_RSA: &'static str = "1.2.840.113549.1.1.1"; pub const szOID_RSA_MD2RSA: &'static str = "1.2.840.113549.1.1.2"; pub const szOID_RSA_MD4RSA: &'static str = "1.2.840.113549.1.1.3"; pub const szOID_RSA_MD5RSA: &'static str = "1.2.840.113549.1.1.4"; pub const szOID_RSA_SHA1RSA: &'static str = "1.2.840.113549.1.1.5"; pub const szOID_RSA_SETOAEP_RSA: &'static str = "1.2.840.113549.1.1.6"; pub const szOID_RSAES_OAEP: &'static str = "1.2.840.113549.1.1.7"; pub const szOID_RSA_MGF1: &'static str = "1.2.840.113549.1.1.8"; pub const szOID_RSA_PSPECIFIED: &'static str = "1.2.840.113549.1.1.9"; pub const szOID_RSA_SSA_PSS: &'static str = "1.2.840.113549.1.1.10"; pub const szOID_RSA_SHA256RSA: &'static str = "1.2.840.113549.1.1.11"; pub const szOID_RSA_SHA384RSA: &'static str = "1.2.840.113549.1.1.12"; pub const szOID_RSA_SHA512RSA: &'static str = "1.2.840.113549.1.1.13"; pub const szOID_RSA_DH: &'static str = "1.2.840.113549.1.3.1"; pub const szOID_RSA_data: &'static str = "1.2.840.113549.1.7.1"; pub const szOID_RSA_signedData: &'static str = "1.2.840.113549.1.7.2"; pub const szOID_RSA_envelopedData: &'static str = "1.2.840.113549.1.7.3"; pub const szOID_RSA_signEnvData: &'static str = "1.2.840.113549.1.7.4"; pub const szOID_RSA_digestedData: &'static str = "1.2.840.113549.1.7.5"; pub const szOID_RSA_hashedData: &'static str = "1.2.840.113549.1.7.5"; pub const szOID_RSA_encryptedData: &'static str = "1.2.840.113549.1.7.6"; pub const szOID_RSA_emailAddr: &'static str = "1.2.840.113549.1.9.1"; pub const szOID_RSA_unstructName: &'static str = "1.2.840.113549.1.9.2"; pub const szOID_RSA_contentType: &'static str = "1.2.840.113549.1.9.3"; pub const szOID_RSA_messageDigest: &'static str = "1.2.840.113549.1.9.4"; pub const szOID_RSA_signingTime: &'static str = "1.2.840.113549.1.9.5"; pub const szOID_RSA_counterSign: &'static str = "1.2.840.113549.1.9.6"; pub const szOID_RSA_challengePwd: &'static str = "1.2.840.113549.1.9.7"; pub const szOID_RSA_unstructAddr: &'static str = "1.2.840.113549.1.9.8"; pub const szOID_RSA_extCertAttrs: &'static str = "1.2.840.113549.1.9.9"; pub const szOID_RSA_certExtensions: &'static str = "1.2.840.113549.1.9.14"; pub const szOID_RSA_SMIMECapabilities: &'static str = "1.2.840.113549.1.9.15"; pub const szOID_RSA_preferSignedData: &'static str = "1.2.840.113549.1.9.15.1"; pub const szOID_TIMESTAMP_TOKEN: &'static str = "1.2.840.113549.1.9.16.1.4"; pub const szOID_RFC3161_counterSign: &'static str = "1.3.6.1.4.1.311.3.3.1"; pub const szOID_RSA_SMIMEalg: &'static str = "1.2.840.113549.1.9.16.3"; pub const szOID_RSA_SMIMEalgESDH: &'static str = "1.2.840.113549.1.9.16.3.5"; pub const szOID_RSA_SMIMEalgCMS3DESwrap: &'static str = "1.2.840.113549.1.9.16.3.6"; pub const szOID_RSA_SMIMEalgCMSRC2wrap: &'static str = "1.2.840.113549.1.9.16.3.7"; pub const szOID_RSA_MD2: &'static str = "1.2.840.113549.2.2"; pub const szOID_RSA_MD4: &'static str = "1.2.840.113549.2.4"; pub const szOID_RSA_MD5: &'static str = "1.2.840.113549.2.5"; pub const szOID_RSA_RC2CBC: &'static str = "1.2.840.113549.3.2"; pub const szOID_RSA_RC4: &'static str = "1.2.840.113549.3.4"; pub const szOID_RSA_DES_EDE3_CBC: &'static str = "1.2.840.113549.3.7"; pub const szOID_RSA_RC5_CBCPad: &'static str = "1.2.840.113549.3.9"; pub const szOID_ANSI_X942: &'static str = "1.2.840.10046"; pub const szOID_ANSI_X942_DH: &'static str = "1.2.840.10046.2.1"; pub const szOID_X957: &'static str = "1.2.840.10040"; pub const szOID_X957_DSA: &'static str = "1.2.840.10040.4.1"; pub const szOID_X957_SHA1DSA: &'static str = "1.2.840.10040.4.3"; pub const szOID_ECC_PUBLIC_KEY: &'static str = "1.2.840.10045.2.1"; pub const szOID_ECC_CURVE_P256: &'static str = "1.2.840.10045.3.1.7"; pub const szOID_ECC_CURVE_P384: &'static str = "1.3.132.0.34"; pub const szOID_ECC_CURVE_P521: &'static str = "1.3.132.0.35"; pub const szOID_ECDSA_SHA1: &'static str = "1.2.840.10045.4.1"; pub const szOID_ECDSA_SPECIFIED: &'static str = "1.2.840.10045.4.3"; pub const szOID_ECDSA_SHA256: &'static str = "1.2.840.10045.4.3.2"; pub const szOID_ECDSA_SHA384: &'static str = "1.2.840.10045.4.3.3"; pub const szOID_ECDSA_SHA512: &'static str = "1.2.840.10045.4.3.4"; pub const szOID_NIST_AES128_CBC: &'static str = "2.16.840.1.101.3.4.1.2"; pub const szOID_NIST_AES192_CBC: &'static str = "2.16.840.1.101.3.4.1.22"; pub const szOID_NIST_AES256_CBC: &'static str = "2.16.840.1.101.3.4.1.42"; pub const szOID_NIST_AES128_WRAP: &'static str = "2.16.840.1.101.3.4.1.5"; pub const szOID_NIST_AES192_WRAP: &'static str = "2.16.840.1.101.3.4.1.25"; pub const szOID_NIST_AES256_WRAP: &'static str = "2.16.840.1.101.3.4.1.45"; pub const szOID_DH_SINGLE_PASS_STDDH_SHA1_KDF: &'static str = "1.3.133.16.840.63.0.2"; pub const szOID_DH_SINGLE_PASS_STDDH_SHA256_KDF: &'static str = "1.3.132.1.11.1"; pub const szOID_DH_SINGLE_PASS_STDDH_SHA384_KDF: &'static str = "1.3.132.1.11.2"; pub const szOID_DS: &'static str = "2.5"; pub const szOID_DSALG: &'static str = "2.5.8"; pub const szOID_DSALG_CRPT: &'static str = "2.5.8.1"; pub const szOID_DSALG_HASH: &'static str = "2.5.8.2"; pub const szOID_DSALG_SIGN: &'static str = "2.5.8.3"; pub const szOID_DSALG_RSA: &'static str = "2.5.8.1.1"; pub const szOID_OIW: &'static str = "1.3.14"; pub const szOID_OIWSEC: &'static str = "1.3.14.3.2"; pub const szOID_OIWSEC_md4RSA: &'static str = "1.3.14.3.2.2"; pub const szOID_OIWSEC_md5RSA: &'static str = "1.3.14.3.2.3"; pub const szOID_OIWSEC_md4RSA2: &'static str = "1.3.14.3.2.4"; pub const szOID_OIWSEC_desECB: &'static str = "1.3.14.3.2.6"; pub const szOID_OIWSEC_desCBC: &'static str = "1.3.14.3.2.7"; pub const szOID_OIWSEC_desOFB: &'static str = "1.3.14.3.2.8"; pub const szOID_OIWSEC_desCFB: &'static str = "1.3.14.3.2.9"; pub const szOID_OIWSEC_desMAC: &'static str = "1.3.14.3.2.10"; pub const szOID_OIWSEC_rsaSign: &'static str = "1.3.14.3.2.11"; pub const szOID_OIWSEC_dsa: &'static str = "1.3.14.3.2.12"; pub const szOID_OIWSEC_shaDSA: &'static str = "1.3.14.3.2.13"; pub const szOID_OIWSEC_mdc2RSA: &'static str = "1.3.14.3.2.14"; pub const szOID_OIWSEC_shaRSA: &'static str = "1.3.14.3.2.15"; pub const szOID_OIWSEC_dhCommMod: &'static str = "1.3.14.3.2.16"; pub const szOID_OIWSEC_desEDE: &'static str = "1.3.14.3.2.17"; pub const szOID_OIWSEC_sha: &'static str = "1.3.14.3.2.18"; pub const szOID_OIWSEC_mdc2: &'static str = "1.3.14.3.2.19"; pub const szOID_OIWSEC_dsaComm: &'static str = "1.3.14.3.2.20"; pub const szOID_OIWSEC_dsaCommSHA: &'static str = "1.3.14.3.2.21"; pub const szOID_OIWSEC_rsaXchg: &'static str = "1.3.14.3.2.22"; pub const szOID_OIWSEC_keyHashSeal: &'static str = "1.3.14.3.2.23"; pub const szOID_OIWSEC_md2RSASign: &'static str = "1.3.14.3.2.24"; pub const szOID_OIWSEC_md5RSASign: &'static str = "1.3.14.3.2.25"; pub const szOID_OIWSEC_sha1: &'static str = "1.3.14.3.2.26"; pub const szOID_OIWSEC_dsaSHA1: &'static str = "1.3.14.3.2.27"; pub const szOID_OIWSEC_dsaCommSHA1: &'static str = "1.3.14.3.2.28"; pub const szOID_OIWSEC_sha1RSASign: &'static str = "1.3.14.3.2.29"; pub const szOID_OIWDIR: &'static str = "1.3.14.7.2"; pub const szOID_OIWDIR_CRPT: &'static str = "1.3.14.7.2.1"; pub const szOID_OIWDIR_HASH: &'static str = "1.3.14.7.2.2"; pub const szOID_OIWDIR_SIGN: &'static str = "1.3.14.7.2.3"; pub const szOID_OIWDIR_md2: &'static str = "1.3.14.7.2.2.1"; pub const szOID_OIWDIR_md2RSA: &'static str = "1.3.14.7.2.3.1"; pub const szOID_INFOSEC: &'static str = "2.16.840.1.101.2.1"; pub const szOID_INFOSEC_sdnsSignature: &'static str = "2.16.840.1.101.2.1.1.1"; pub const szOID_INFOSEC_mosaicSignature: &'static str = "2.16.840.1.101.2.1.1.2"; pub const szOID_INFOSEC_sdnsConfidentiality: &'static str = "2.16.840.1.101.2.1.1.3"; pub const szOID_INFOSEC_mosaicConfidentiality: &'static str = "2.16.840.1.101.2.1.1.4"; pub const szOID_INFOSEC_sdnsIntegrity: &'static str = "2.16.840.1.101.2.1.1.5"; pub const szOID_INFOSEC_mosaicIntegrity: &'static str = "2.16.840.1.101.2.1.1.6"; pub const szOID_INFOSEC_sdnsTokenProtection: &'static str = "2.16.840.1.101.2.1.1.7"; pub const szOID_INFOSEC_mosaicTokenProtection: &'static str = "2.16.840.1.101.2.1.1.8"; pub const szOID_INFOSEC_sdnsKeyManagement: &'static str = "2.16.840.1.101.2.1.1.9"; pub const szOID_INFOSEC_mosaicKeyManagement: &'static str = "2.16.840.1.101.2.1.1.10"; pub const szOID_INFOSEC_sdnsKMandSig: &'static str = "2.16.840.1.101.2.1.1.11"; pub const szOID_INFOSEC_mosaicKMandSig: &'static str = "2.16.840.1.101.2.1.1.12"; pub const szOID_INFOSEC_SuiteASignature: &'static str = "2.16.840.1.101.2.1.1.13"; pub const szOID_INFOSEC_SuiteAConfidentiality: &'static str = "2.16.840.1.101.2.1.1.14"; pub const szOID_INFOSEC_SuiteAIntegrity: &'static str = "2.16.840.1.101.2.1.1.15"; pub const szOID_INFOSEC_SuiteATokenProtection: &'static str = "2.16.840.1.101.2.1.1.16"; pub const szOID_INFOSEC_SuiteAKeyManagement: &'static str = "2.16.840.1.101.2.1.1.17"; pub const szOID_INFOSEC_SuiteAKMandSig: &'static str = "2.16.840.1.101.2.1.1.18"; pub const szOID_INFOSEC_mosaicUpdatedSig: &'static str = "2.16.840.1.101.2.1.1.19"; pub const szOID_INFOSEC_mosaicKMandUpdSig: &'static str = "2.16.840.1.101.2.1.1.20"; pub const szOID_INFOSEC_mosaicUpdatedInteg: &'static str = "2.16.840.1.101.2.1.1.21"; pub const szOID_NIST_sha256: &'static str = "2.16.840.1.101.3.4.2.1"; pub const szOID_NIST_sha384: &'static str = "2.16.840.1.101.3.4.2.2"; pub const szOID_NIST_sha512: &'static str = "2.16.840.1.101.3.4.2.3"; STRUCT!{struct CRYPT_OBJID_TABLE { dwAlgId: ::DWORD, pszObjId: ::LPCSTR, }} pub type PCRYPT_OBJID_TABLE = *mut CRYPT_OBJID_TABLE; STRUCT!{struct CRYPT_HASH_INFO { HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, Hash: CRYPT_HASH_BLOB, }} pub type PCRYPT_HASH_INFO = *mut CRYPT_HASH_INFO; STRUCT!{struct CERT_EXTENSION { pszObjId: ::LPSTR, fCritical: ::BOOL, Value: CRYPT_OBJID_BLOB, }} pub type PCERT_EXTENSION = *mut CERT_EXTENSION; pub type PCCERT_EXTENSION = *const CERT_EXTENSION; STRUCT!{struct CRYPT_ATTRIBUTE_TYPE_VALUE { pszObjId: ::LPSTR, Value: CRYPT_OBJID_BLOB, }} pub type PCRYPT_ATTRIBUTE_TYPE_VALUE = *mut CRYPT_ATTRIBUTE_TYPE_VALUE; STRUCT!{struct CRYPT_ATTRIBUTE { pszObjId: ::LPSTR, cValue: ::DWORD, rgValue: PCRYPT_ATTR_BLOB, }} pub type PCRYPT_ATTRIBUTE = *mut CRYPT_ATTRIBUTE; STRUCT!{struct CRYPT_ATTRIBUTES { cAttr: ::DWORD, rgAttr: PCRYPT_ATTRIBUTE, }} pub type PCRYPT_ATTRIBUTES = *mut CRYPT_ATTRIBUTES; STRUCT!{struct CERT_RDN_ATTR { pszObjId: ::LPSTR, dwValueType: ::DWORD, Value: CERT_RDN_VALUE_BLOB, }} pub type PCERT_RDN_ATTR = *mut CERT_RDN_ATTR; pub const szOID_COMMON_NAME: &'static str = "2.5.4.3"; pub const szOID_SUR_NAME: &'static str = "2.5.4.4"; pub const szOID_DEVICE_SERIAL_NUMBER: &'static str = "2.5.4.5"; pub const szOID_COUNTRY_NAME: &'static str = "2.5.4.6"; pub const szOID_LOCALITY_NAME: &'static str = "2.5.4.7"; pub const szOID_STATE_OR_PROVINCE_NAME: &'static str = "2.5.4.8"; pub const szOID_STREET_ADDRESS: &'static str = "2.5.4.9"; pub const szOID_ORGANIZATION_NAME: &'static str = "2.5.4.10"; pub const szOID_ORGANIZATIONAL_UNIT_NAME: &'static str = "2.5.4.11"; pub const szOID_TITLE: &'static str = "2.5.4.12"; pub const szOID_DESCRIPTION: &'static str = "2.5.4.13"; pub const szOID_SEARCH_GUIDE: &'static str = "2.5.4.14"; pub const szOID_BUSINESS_CATEGORY: &'static str = "2.5.4.15"; pub const szOID_POSTAL_ADDRESS: &'static str = "2.5.4.16"; pub const szOID_POSTAL_CODE: &'static str = "2.5.4.17"; pub const szOID_POST_OFFICE_BOX: &'static str = "2.5.4.18"; pub const szOID_PHYSICAL_DELIVERY_OFFICE_NAME: &'static str = "2.5.4.19"; pub const szOID_TELEPHONE_NUMBER: &'static str = "2.5.4.20"; pub const szOID_TELEX_NUMBER: &'static str = "2.5.4.21"; pub const szOID_TELETEXT_TERMINAL_IDENTIFIER: &'static str = "2.5.4.22"; pub const szOID_FACSIMILE_TELEPHONE_NUMBER: &'static str = "2.5.4.23"; pub const szOID_X21_ADDRESS: &'static str = "2.5.4.24"; pub const szOID_INTERNATIONAL_ISDN_NUMBER: &'static str = "2.5.4.25"; pub const szOID_REGISTERED_ADDRESS: &'static str = "2.5.4.26"; pub const szOID_DESTINATION_INDICATOR: &'static str = "2.5.4.27"; pub const szOID_PREFERRED_DELIVERY_METHOD: &'static str = "2.5.4.28"; pub const szOID_PRESENTATION_ADDRESS: &'static str = "2.5.4.29"; pub const szOID_SUPPORTED_APPLICATION_CONTEXT: &'static str = "2.5.4.30"; pub const szOID_MEMBER: &'static str = "2.5.4.31"; pub const szOID_OWNER: &'static str = "2.5.4.32"; pub const szOID_ROLE_OCCUPANT: &'static str = "2.5.4.33"; pub const szOID_SEE_ALSO: &'static str = "2.5.4.34"; pub const szOID_USER_PASSWORD: &'static str = "2.5.4.35"; pub const szOID_USER_CERTIFICATE: &'static str = "2.5.4.36"; pub const szOID_CA_CERTIFICATE: &'static str = "2.5.4.37"; pub const szOID_AUTHORITY_REVOCATION_LIST: &'static str = "2.5.4.38"; pub const szOID_CERTIFICATE_REVOCATION_LIST: &'static str = "2.5.4.39"; pub const szOID_CROSS_CERTIFICATE_PAIR: &'static str = "2.5.4.40"; pub const szOID_GIVEN_NAME: &'static str = "2.5.4.42"; pub const szOID_INITIALS: &'static str = "2.5.4.43"; pub const szOID_DN_QUALIFIER: &'static str = "2.5.4.46"; pub const szOID_DOMAIN_COMPONENT: &'static str = "0.9.2342.19200300.100.1.25"; pub const szOID_PKCS_12_FRIENDLY_NAME_ATTR: &'static str = "1.2.840.113549.1.9.20"; pub const szOID_PKCS_12_LOCAL_KEY_ID: &'static str = "1.2.840.113549.1.9.21"; pub const szOID_PKCS_12_KEY_PROVIDER_NAME_ATTR: &'static str = "1.3.6.1.4.1.311.17.1"; pub const szOID_LOCAL_MACHINE_KEYSET: &'static str = "1.3.6.1.4.1.311.17.2"; pub const szOID_PKCS_12_EXTENDED_ATTRIBUTES: &'static str = "1.3.6.1.4.1.311.17.3"; pub const szOID_PKCS_12_PROTECTED_PASSWORD_SECRET_BAG_TYPE_ID: &'static str = "1.3.6.1.4.1.311.17.4"; pub const szOID_KEYID_RDN: &'static str = "1.3.6.1.4.1.311.10.7.1"; pub const szOID_EV_RDN_LOCALE: &'static str = "1.3.6.1.4.1.311.60.2.1.1"; pub const szOID_EV_RDN_STATE_OR_PROVINCE: &'static str = "1.3.6.1.4.1.311.60.2.1.2"; pub const szOID_EV_RDN_COUNTRY: &'static str = "1.3.6.1.4.1.311.60.2.1.3"; pub const CERT_RDN_ANY_TYPE: ::DWORD = 0; pub const CERT_RDN_ENCODED_BLOB: ::DWORD = 1; pub const CERT_RDN_OCTET_STRING: ::DWORD = 2; pub const CERT_RDN_NUMERIC_STRING: ::DWORD = 3; pub const CERT_RDN_PRINTABLE_STRING: ::DWORD = 4; pub const CERT_RDN_TELETEX_STRING: ::DWORD = 5; pub const CERT_RDN_T61_STRING: ::DWORD = 5; pub const CERT_RDN_VIDEOTEX_STRING: ::DWORD = 6; pub const CERT_RDN_IA5_STRING: ::DWORD = 7; pub const CERT_RDN_GRAPHIC_STRING: ::DWORD = 8; pub const CERT_RDN_VISIBLE_STRING: ::DWORD = 9; pub const CERT_RDN_ISO646_STRING: ::DWORD = 9; pub const CERT_RDN_GENERAL_STRING: ::DWORD = 10; pub const CERT_RDN_UNIVERSAL_STRING: ::DWORD = 11; pub const CERT_RDN_INT4_STRING: ::DWORD = 11; pub const CERT_RDN_BMP_STRING: ::DWORD = 12; pub const CERT_RDN_UNICODE_STRING: ::DWORD = 12; pub const CERT_RDN_UTF8_STRING: ::DWORD = 13; pub const CERT_RDN_TYPE_MASK: ::DWORD = 0x000000FF; pub const CERT_RDN_FLAGS_MASK: ::DWORD = 0xFF000000; pub const CERT_RDN_ENABLE_T61_UNICODE_FLAG: ::DWORD = 0x80000000; pub const CERT_RDN_ENABLE_UTF8_UNICODE_FLAG: ::DWORD = 0x20000000; pub const CERT_RDN_FORCE_UTF8_UNICODE_FLAG: ::DWORD = 0x10000000; pub const CERT_RDN_DISABLE_CHECK_TYPE_FLAG: ::DWORD = 0x40000000; pub const CERT_RDN_DISABLE_IE4_UTF8_FLAG: ::DWORD = 0x01000000; pub const CERT_RDN_ENABLE_PUNYCODE_FLAG: ::DWORD = 0x02000000; STRUCT!{struct CERT_RDN { cRDNAttr: ::DWORD, rgRDNAttr: PCERT_RDN_ATTR, }} pub type PCERT_RDN = *mut CERT_RDN; STRUCT!{struct CERT_NAME_INFO { cRDN: ::DWORD, rgRDN: PCERT_RDN, }} pub type PCERT_NAME_INFO = *mut CERT_NAME_INFO; STRUCT!{struct CERT_NAME_VALUE { dwValueType: ::DWORD, Value: CERT_RDN_VALUE_BLOB, }} pub type PCERT_NAME_VALUE = *mut CERT_NAME_VALUE; STRUCT!{struct CERT_PUBLIC_KEY_INFO { Algorithm: CRYPT_ALGORITHM_IDENTIFIER, PublicKey: CRYPT_BIT_BLOB, }} pub type PCERT_PUBLIC_KEY_INFO = *mut CERT_PUBLIC_KEY_INFO; pub const CERT_RSA_PUBLIC_KEY_OBJID: &'static str = szOID_RSA_RSA; pub const CERT_DEFAULT_OID_PUBLIC_KEY_SIGN: &'static str = szOID_RSA_RSA; pub const CERT_DEFAULT_OID_PUBLIC_KEY_XCHG: &'static str = szOID_RSA_RSA; STRUCT!{struct CRYPT_ECC_PRIVATE_KEY_INFO { dwVersion: ::DWORD, PrivateKey: CRYPT_DER_BLOB, szCurveOid: ::LPSTR, PublicKey: CRYPT_BIT_BLOB, }} pub type PCRYPT_ECC_PRIVATE_KEY_INFO = *mut CRYPT_ECC_PRIVATE_KEY_INFO; pub const CRYPT_ECC_PRIVATE_KEY_INFO_v1: ::DWORD = 1; STRUCT!{struct CRYPT_PRIVATE_KEY_INFO { Version: ::DWORD, Algorithm: CRYPT_ALGORITHM_IDENTIFIER, PrivateKey: CRYPT_DER_BLOB, pAttributes: PCRYPT_ATTRIBUTES, }} pub type PCRYPT_PRIVATE_KEY_INFO = *mut CRYPT_PRIVATE_KEY_INFO; STRUCT!{struct CRYPT_ENCRYPTED_PRIVATE_KEY_INFO { EncryptionAlgorithm: ::CRYPT_ALGORITHM_IDENTIFIER, EncryptedPrivateKey: ::CRYPT_DATA_BLOB, }} pub type PCRYPT_ENCRYPTED_PRIVATE_KEY_INFO = *mut CRYPT_ENCRYPTED_PRIVATE_KEY_INFO; pub type PCRYPT_DECRYPT_PRIVATE_KEY_FUNC = Option ::BOOL>; pub type PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC = Option ::BOOL>; pub type PCRYPT_RESOLVE_HCRYPTPROV_FUNC = Option ::BOOL>; #[repr(C)] #[derive(Copy)] pub struct CRYPT_PKCS8_IMPORT_PARAMS { pub PrivateKey: CRYPT_DIGEST_BLOB, pub pResolvehCryptProvFunc: PCRYPT_RESOLVE_HCRYPTPROV_FUNC, pub pVoidResolveFunc: ::LPVOID, pub pDecryptPrivateKeyFunc: PCRYPT_DECRYPT_PRIVATE_KEY_FUNC, pub pVoidDecryptFunc: ::LPVOID, } impl Clone for CRYPT_PKCS8_IMPORT_PARAMS { fn clone(&self) -> CRYPT_PKCS8_IMPORT_PARAMS { *self } } pub type PCRYPT_PKCS8_IMPORT_PARAMS = *mut CRYPT_PKCS8_IMPORT_PARAMS; pub type CRYPT_PRIVATE_KEY_BLOB_AND_PARAMS = CRYPT_PKCS8_IMPORT_PARAMS; pub type PPCRYPT_PRIVATE_KEY_BLOB_AND_PARAMS = *mut CRYPT_PKCS8_IMPORT_PARAMS; #[repr(C)] #[derive(Copy)] pub struct CRYPT_PKCS8_EXPORT_PARAMS { pub hCryptProv: HCRYPTPROV, pub dwKeySpec: ::DWORD, pub pszPrivateKeyObjId: ::LPSTR, pub pEncryptPrivateKeyFunc: PCRYPT_ENCRYPT_PRIVATE_KEY_FUNC, pub pVoidEncryptFunc: ::LPVOID, } impl Clone for CRYPT_PKCS8_EXPORT_PARAMS { fn clone(&self) -> CRYPT_PKCS8_EXPORT_PARAMS { *self } } pub type PCRYPT_PKCS8_EXPORT_PARAMS = *mut CRYPT_PKCS8_EXPORT_PARAMS; STRUCT!{struct CERT_INFO { dwVersion: ::DWORD, SerialNumber: CRYPT_INTEGER_BLOB, SignatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, Issuer: CERT_NAME_BLOB, NotBefore: ::FILETIME, NotAfter: ::FILETIME, Subject: CERT_NAME_BLOB, SubjectPublicKeyInfo: CERT_PUBLIC_KEY_INFO, IssuerUniqueId: CRYPT_BIT_BLOB, SubjectUniqueId: CRYPT_BIT_BLOB, cExtension: ::DWORD, rgExtension: PCERT_EXTENSION, }} pub type PCERT_INFO = *mut CERT_INFO; pub const CERT_V1: ::DWORD = 0; pub const CERT_V2: ::DWORD = 1; pub const CERT_V3: ::DWORD = 2; pub const CERT_INFO_VERSION_FLAG: ::DWORD = 1; pub const CERT_INFO_SERIAL_NUMBER_FLAG: ::DWORD = 2; pub const CERT_INFO_SIGNATURE_ALGORITHM_FLAG: ::DWORD = 3; pub const CERT_INFO_ISSUER_FLAG: ::DWORD = 4; pub const CERT_INFO_NOT_BEFORE_FLAG: ::DWORD = 5; pub const CERT_INFO_NOT_AFTER_FLAG: ::DWORD = 6; pub const CERT_INFO_SUBJECT_FLAG: ::DWORD = 7; pub const CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG: ::DWORD = 8; pub const CERT_INFO_ISSUER_UNIQUE_ID_FLAG: ::DWORD = 9; pub const CERT_INFO_SUBJECT_UNIQUE_ID_FLAG: ::DWORD = 10; pub const CERT_INFO_EXTENSION_FLAG: ::DWORD = 11; STRUCT!{struct CRL_ENTRY { SerialNumber: CRYPT_INTEGER_BLOB, RevocationDate: ::FILETIME, cExtension: ::DWORD, rgExtension: PCERT_EXTENSION, }} pub type PCRL_ENTRY = *mut CRL_ENTRY; STRUCT!{struct CRL_INFO { dwVersion: ::DWORD, SignatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, Issuer: CERT_NAME_BLOB, ThisUpdate: ::FILETIME, NextUpdate: ::FILETIME, cCRLEntry: ::DWORD, rgCRLEntry: PCRL_ENTRY, cExtension: ::DWORD, rgExtension: PCERT_EXTENSION, }} pub type PCRL_INFO = *mut CRL_INFO; pub const CRL_V1: ::DWORD = 0; pub const CRL_V2: ::DWORD = 1; pub const CERT_BUNDLE_CERTIFICATE: ::DWORD = 0; pub const CERT_BUNDLE_CRL: ::DWORD = 1; STRUCT!{struct CERT_OR_CRL_BLOB { dwChoice: ::DWORD, cbEncoded: ::DWORD, pbEncoded: *mut ::BYTE, }} pub type PCERT_OR_CRL_BLOB = *mut CERT_OR_CRL_BLOB; STRUCT!{struct CERT_OR_CRL_BUNDLE { cItem: ::DWORD, rgItem: PCERT_OR_CRL_BLOB, }} pub type PCERT_OR_CRL_BUNDLE = *mut CERT_OR_CRL_BUNDLE; STRUCT!{struct CERT_REQUEST_INFO { dwVersion: ::DWORD, Subject: CERT_NAME_BLOB, SubjectPublicKeyInfo: CERT_PUBLIC_KEY_INFO, cAttribute: ::DWORD, rgAttribute: PCRYPT_ATTRIBUTE, }} pub type PCERT_REQUEST_INFO = *mut CERT_REQUEST_INFO; pub const CERT_REQUEST_V1: ::DWORD = 0; STRUCT!{struct CERT_KEYGEN_REQUEST_INFO { dwVersion: ::DWORD, SubjectPublicKeyInfo: CERT_PUBLIC_KEY_INFO, pwszChallengeString: ::LPWSTR, }} pub type PCERT_KEYGEN_REQUEST_INFO = *mut CERT_KEYGEN_REQUEST_INFO; pub const CERT_KEYGEN_REQUEST_V1: ::DWORD = 0; STRUCT!{struct CERT_SIGNED_CONTENT_INFO { ToBeSigned: CRYPT_DER_BLOB, SignatureAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, Signature: CRYPT_BIT_BLOB, }} pub type PCERT_SIGNED_CONTENT_INFO = *mut CERT_SIGNED_CONTENT_INFO; STRUCT!{struct CTL_USAGE { cUsageIdentifier: ::DWORD, rgpszUsageIdentifier: *mut ::LPSTR, }} pub type PCTL_USAGE = *mut CTL_USAGE; pub type CERT_ENHKEY_USAGE = CTL_USAGE; pub type PCERT_ENHKEY_USAGE = *mut CERT_ENHKEY_USAGE; pub type PCCTL_USAGE = *const CTL_USAGE; pub type PCCERT_ENHKEY_USAGE = *const CERT_ENHKEY_USAGE; STRUCT!{struct CTL_ENTRY { SubjectIdentifier: CRYPT_DATA_BLOB, cAttribute: ::DWORD, rgAttribute: PCRYPT_ATTRIBUTE, }} pub type PCTL_ENTRY = *mut CTL_ENTRY; STRUCT!{struct CTL_INFO { dwVersion: ::DWORD, SubjectUsage: CTL_USAGE, ListIdentifier: CRYPT_DATA_BLOB, SequenceNumber: CRYPT_INTEGER_BLOB, ThisUpdate: ::FILETIME, NextUpdate: ::FILETIME, SubjectAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, cCTLEntry: ::DWORD, rgCTLEntry: PCTL_ENTRY, cExtension: ::DWORD, rgExtension: PCERT_EXTENSION, }} pub type PCTL_INFO = *mut CTL_INFO; pub const CTL_V1: ::DWORD = 0; STRUCT!{struct CRYPT_TIME_STAMP_REQUEST_INFO { pszTimeStampAlgorithm: ::LPSTR, pszContentType: ::LPSTR, Content: CRYPT_OBJID_BLOB, cAttribute: ::DWORD, rgAttribute: PCRYPT_ATTRIBUTE, }} pub type PCRYPT_TIME_STAMP_REQUEST_INFO = *mut CRYPT_TIME_STAMP_REQUEST_INFO; STRUCT!{struct CRYPT_ENROLLMENT_NAME_VALUE_PAIR { pwszName: ::LPWSTR, pwszValue: ::LPWSTR, }} pub type PCRYPT_ENROLLMENT_NAME_VALUE_PAIR = *mut CRYPT_ENROLLMENT_NAME_VALUE_PAIR; STRUCT!{struct CRYPT_CSP_PROVIDER { dwKeySpec: ::DWORD, pwszProviderName: ::LPWSTR, Signature: CRYPT_BIT_BLOB, }} pub type PCRYPT_CSP_PROVIDER = *mut CRYPT_CSP_PROVIDER; pub const CERT_ENCODING_TYPE_MASK: ::DWORD = 0x0000FFFF; pub const CMSG_ENCODING_TYPE_MASK: ::DWORD = 0xFFFF0000; pub const CRYPT_ASN_ENCODING: ::DWORD = 0x00000001; pub const CRYPT_NDR_ENCODING: ::DWORD = 0x00000002; pub const X509_ASN_ENCODING: ::DWORD = 0x00000001; pub const X509_NDR_ENCODING: ::DWORD = 0x00000002; pub const PKCS_7_ASN_ENCODING: ::DWORD = 0x00010000; pub const PKCS_7_NDR_ENCODING: ::DWORD = 0x00020000; pub const CRYPT_FORMAT_STR_MULTI_LINE: ::DWORD = 0x0001; pub const CRYPT_FORMAT_STR_NO_HEX: ::DWORD = 0x0010; pub const CRYPT_FORMAT_SIMPLE: ::DWORD = 0x0001; pub const CRYPT_FORMAT_X509: ::DWORD = 0x0002; pub const CRYPT_FORMAT_OID: ::DWORD = 0x0004; pub const CRYPT_FORMAT_RDN_SEMICOLON: ::DWORD = 0x0100; pub const CRYPT_FORMAT_RDN_CRLF: ::DWORD = 0x0200; pub const CRYPT_FORMAT_RDN_UNQUOTE: ::DWORD = 0x0400; pub const CRYPT_FORMAT_RDN_REVERSE: ::DWORD = 0x0800; pub const CRYPT_FORMAT_COMMA: ::DWORD = 0x1000; pub const CRYPT_FORMAT_SEMICOLON: ::DWORD = CRYPT_FORMAT_RDN_SEMICOLON; pub const CRYPT_FORMAT_CRLF: ::DWORD = CRYPT_FORMAT_RDN_CRLF; pub type PFN_CRYPT_ALLOC = Option; pub type PFN_CRYPT_FREE = Option; #[repr(C)] #[derive(Copy)] pub struct CRYPT_ENCODE_PARA { pub cbSize: ::DWORD, pub pfnAlloc: PFN_CRYPT_ALLOC, pub pfnFree: PFN_CRYPT_FREE, } impl Clone for CRYPT_ENCODE_PARA { fn clone(&self) -> CRYPT_ENCODE_PARA { *self } } pub type PCRYPT_ENCODE_PARA = *mut CRYPT_ENCODE_PARA; pub const CRYPT_ENCODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG: ::DWORD = 0x8; pub const CRYPT_ENCODE_ALLOC_FLAG: ::DWORD = 0x8000; pub const CRYPT_UNICODE_NAME_ENCODE_ENABLE_T61_UNICODE_FLAG: ::DWORD = CERT_RDN_ENABLE_T61_UNICODE_FLAG; pub const CRYPT_UNICODE_NAME_ENCODE_ENABLE_UTF8_UNICODE_FLAG: ::DWORD = CERT_RDN_ENABLE_UTF8_UNICODE_FLAG; pub const CRYPT_UNICODE_NAME_ENCODE_FORCE_UTF8_UNICODE_FLAG: ::DWORD = CERT_RDN_FORCE_UTF8_UNICODE_FLAG; pub const CRYPT_UNICODE_NAME_ENCODE_DISABLE_CHECK_TYPE_FLAG: ::DWORD = CERT_RDN_DISABLE_CHECK_TYPE_FLAG; pub const CRYPT_SORTED_CTL_ENCODE_HASHED_SUBJECT_IDENTIFIER_FLAG: ::DWORD = 0x10000; pub const CRYPT_ENCODE_ENABLE_PUNYCODE_FLAG: ::DWORD = 0x20000; pub const CRYPT_ENCODE_ENABLE_UTF8PERCENT_FLAG: ::DWORD = 0x40000; pub const CRYPT_ENCODE_ENABLE_IA5CONVERSION_FLAG: ::DWORD = CRYPT_ENCODE_ENABLE_PUNYCODE_FLAG | CRYPT_ENCODE_ENABLE_UTF8PERCENT_FLAG; #[repr(C)] #[derive(Copy)] pub struct CRYPT_DECODE_PARA { pub cbSize: ::DWORD, pub pfnAlloc: PFN_CRYPT_ALLOC, pub pfnFree: PFN_CRYPT_FREE, } impl Clone for CRYPT_DECODE_PARA { fn clone(&self) -> CRYPT_DECODE_PARA { *self } } pub type PCRYPT_DECODE_PARA = *mut CRYPT_DECODE_PARA; pub const CRYPT_DECODE_NOCOPY_FLAG: ::DWORD = 0x1; pub const CRYPT_DECODE_TO_BE_SIGNED_FLAG: ::DWORD = 0x2; pub const CRYPT_DECODE_SHARE_OID_STRING_FLAG: ::DWORD = 0x4; pub const CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG: ::DWORD = 0x8; pub const CRYPT_DECODE_ALLOC_FLAG: ::DWORD = 0x8000; pub const CRYPT_UNICODE_NAME_DECODE_DISABLE_IE4_UTF8_FLAG: ::DWORD = CERT_RDN_DISABLE_IE4_UTF8_FLAG; pub const CRYPT_DECODE_ENABLE_PUNYCODE_FLAG: ::DWORD = 0x02000000; pub const CRYPT_DECODE_ENABLE_UTF8PERCENT_FLAG: ::DWORD = 0x04000000; pub const CRYPT_DECODE_ENABLE_IA5CONVERSION_FLAG: ::DWORD = CRYPT_DECODE_ENABLE_PUNYCODE_FLAG | CRYPT_DECODE_ENABLE_UTF8PERCENT_FLAG; pub const CRYPT_ENCODE_DECODE_NONE: ::LPCSTR = 0 as ::LPCSTR; pub const X509_CERT: ::LPCSTR = 1 as ::LPCSTR; pub const X509_CERT_TO_BE_SIGNED: ::LPCSTR = 2 as ::LPCSTR; pub const X509_CERT_CRL_TO_BE_SIGNED: ::LPCSTR = 3 as ::LPCSTR; pub const X509_CERT_REQUEST_TO_BE_SIGNED: ::LPCSTR = 4 as ::LPCSTR; pub const X509_EXTENSIONS: ::LPCSTR = 5 as ::LPCSTR; pub const X509_NAME_VALUE: ::LPCSTR = 6 as ::LPCSTR; pub const X509_NAME: ::LPCSTR = 7 as ::LPCSTR; pub const X509_PUBLIC_KEY_INFO: ::LPCSTR = 8 as ::LPCSTR; pub const X509_AUTHORITY_KEY_ID: ::LPCSTR = 9 as ::LPCSTR; pub const X509_KEY_ATTRIBUTES: ::LPCSTR = 10 as ::LPCSTR; pub const X509_KEY_USAGE_RESTRICTION: ::LPCSTR = 11 as ::LPCSTR; pub const X509_ALTERNATE_NAME: ::LPCSTR = 12 as ::LPCSTR; pub const X509_BASIC_CONSTRAINTS: ::LPCSTR = 13 as ::LPCSTR; pub const X509_KEY_USAGE: ::LPCSTR = 14 as ::LPCSTR; pub const X509_BASIC_CONSTRAINTS2: ::LPCSTR = 15 as ::LPCSTR; pub const X509_CERT_POLICIES: ::LPCSTR = 16 as ::LPCSTR; pub const PKCS_UTC_TIME: ::LPCSTR = 17 as ::LPCSTR; pub const PKCS_TIME_REQUEST: ::LPCSTR = 18 as ::LPCSTR; pub const RSA_CSP_PUBLICKEYBLOB: ::LPCSTR = 19 as ::LPCSTR; pub const X509_UNICODE_NAME: ::LPCSTR = 20 as ::LPCSTR; pub const X509_KEYGEN_REQUEST_TO_BE_SIGNED: ::LPCSTR = 21 as ::LPCSTR; pub const PKCS_ATTRIBUTE: ::LPCSTR = 22 as ::LPCSTR; pub const PKCS_CONTENT_INFO_SEQUENCE_OF_ANY: ::LPCSTR = 23 as ::LPCSTR; pub const X509_UNICODE_NAME_VALUE: ::LPCSTR = 24 as ::LPCSTR; pub const X509_ANY_STRING: ::LPCSTR = X509_NAME_VALUE; pub const X509_UNICODE_ANY_STRING: ::LPCSTR = X509_UNICODE_NAME_VALUE; pub const X509_OCTET_STRING: ::LPCSTR = 25 as ::LPCSTR; pub const X509_BITS: ::LPCSTR = 26 as ::LPCSTR; pub const X509_INTEGER: ::LPCSTR = 27 as ::LPCSTR; pub const X509_MULTI_BYTE_INTEGER: ::LPCSTR = 28 as ::LPCSTR; pub const X509_ENUMERATED: ::LPCSTR = 29 as ::LPCSTR; pub const X509_CHOICE_OF_TIME: ::LPCSTR = 30 as ::LPCSTR; pub const X509_AUTHORITY_KEY_ID2: ::LPCSTR = 31 as ::LPCSTR; pub const X509_AUTHORITY_INFO_ACCESS: ::LPCSTR = 32 as ::LPCSTR; pub const X509_SUBJECT_INFO_ACCESS: ::LPCSTR = X509_AUTHORITY_INFO_ACCESS; pub const X509_CRL_REASON_CODE: ::LPCSTR = X509_ENUMERATED; pub const PKCS_CONTENT_INFO: ::LPCSTR = 33 as ::LPCSTR; pub const X509_SEQUENCE_OF_ANY: ::LPCSTR = 34 as ::LPCSTR; pub const X509_CRL_DIST_POINTS: ::LPCSTR = 35 as ::LPCSTR; pub const X509_ENHANCED_KEY_USAGE: ::LPCSTR = 36 as ::LPCSTR; pub const PKCS_CTL: ::LPCSTR = 37 as ::LPCSTR; pub const X509_MULTI_BYTE_UINT: ::LPCSTR = 38 as ::LPCSTR; pub const X509_DSS_PUBLICKEY: ::LPCSTR = X509_MULTI_BYTE_UINT; pub const X509_DSS_PARAMETERS: ::LPCSTR = 39 as ::LPCSTR; pub const X509_DSS_SIGNATURE: ::LPCSTR = 40 as ::LPCSTR; pub const PKCS_RC2_CBC_PARAMETERS: ::LPCSTR = 41 as ::LPCSTR; pub const PKCS_SMIME_CAPABILITIES: ::LPCSTR = 42 as ::LPCSTR; pub const X509_QC_STATEMENTS_EXT: ::LPCSTR = 42 as ::LPCSTR; pub const PKCS_RSA_PRIVATE_KEY: ::LPCSTR = 43 as ::LPCSTR; pub const PKCS_PRIVATE_KEY_INFO: ::LPCSTR = 44 as ::LPCSTR; pub const PKCS_ENCRYPTED_PRIVATE_KEY_INFO: ::LPCSTR = 45 as ::LPCSTR; pub const X509_PKIX_POLICY_QUALIFIER_USERNOTICE: ::LPCSTR = 46 as ::LPCSTR; pub const X509_DH_PUBLICKEY: ::LPCSTR = X509_MULTI_BYTE_UINT; pub const X509_DH_PARAMETERS: ::LPCSTR = 47 as ::LPCSTR; pub const PKCS_ATTRIBUTES: ::LPCSTR = 48 as ::LPCSTR; pub const PKCS_SORTED_CTL: ::LPCSTR = 49 as ::LPCSTR; pub const X509_ECC_SIGNATURE: ::LPCSTR = 47 as ::LPCSTR; pub const X942_DH_PARAMETERS: ::LPCSTR = 50 as ::LPCSTR; pub const X509_BITS_WITHOUT_TRAILING_ZEROES: ::LPCSTR = 51 as ::LPCSTR; pub const X942_OTHER_INFO: ::LPCSTR = 52 as ::LPCSTR; pub const X509_CERT_PAIR: ::LPCSTR = 53 as ::LPCSTR; pub const X509_ISSUING_DIST_POINT: ::LPCSTR = 54 as ::LPCSTR; pub const X509_NAME_CONSTRAINTS: ::LPCSTR = 55 as ::LPCSTR; pub const X509_POLICY_MAPPINGS: ::LPCSTR = 56 as ::LPCSTR; pub const X509_POLICY_CONSTRAINTS: ::LPCSTR = 57 as ::LPCSTR; pub const X509_CROSS_CERT_DIST_POINTS: ::LPCSTR = 58 as ::LPCSTR; pub const CMC_DATA: ::LPCSTR = 59 as ::LPCSTR; pub const CMC_RESPONSE: ::LPCSTR = 60 as ::LPCSTR; pub const CMC_STATUS: ::LPCSTR = 61 as ::LPCSTR; pub const CMC_ADD_EXTENSIONS: ::LPCSTR = 62 as ::LPCSTR; pub const CMC_ADD_ATTRIBUTES: ::LPCSTR = 63 as ::LPCSTR; pub const X509_CERTIFICATE_TEMPLATE: ::LPCSTR = 64 as ::LPCSTR; pub const OCSP_SIGNED_REQUEST: ::LPCSTR = 65 as ::LPCSTR; pub const OCSP_REQUEST: ::LPCSTR = 66 as ::LPCSTR; pub const OCSP_RESPONSE: ::LPCSTR = 67 as ::LPCSTR; pub const OCSP_BASIC_SIGNED_RESPONSE: ::LPCSTR = 68 as ::LPCSTR; pub const OCSP_BASIC_RESPONSE: ::LPCSTR = 69 as ::LPCSTR; pub const X509_LOGOTYPE_EXT: ::LPCSTR = 70 as ::LPCSTR; pub const X509_BIOMETRIC_EXT: ::LPCSTR = 71 as ::LPCSTR; pub const CNG_RSA_PUBLIC_KEY_BLOB: ::LPCSTR = 72 as ::LPCSTR; pub const X509_OBJECT_IDENTIFIER: ::LPCSTR = 73 as ::LPCSTR; pub const X509_ALGORITHM_IDENTIFIER: ::LPCSTR = 74 as ::LPCSTR; pub const PKCS_RSA_SSA_PSS_PARAMETERS: ::LPCSTR = 75 as ::LPCSTR; pub const PKCS_RSAES_OAEP_PARAMETERS: ::LPCSTR = 76 as ::LPCSTR; pub const ECC_CMS_SHARED_INFO: ::LPCSTR = 77 as ::LPCSTR; pub const TIMESTAMP_REQUEST: ::LPCSTR = 78 as ::LPCSTR; pub const TIMESTAMP_RESPONSE: ::LPCSTR = 79 as ::LPCSTR; pub const TIMESTAMP_INFO: ::LPCSTR = 80 as ::LPCSTR; pub const X509_CERT_BUNDLE: ::LPCSTR = 81 as ::LPCSTR; pub const X509_ECC_PRIVATE_KEY: ::LPCSTR = 82 as ::LPCSTR; pub const CNG_RSA_PRIVATE_KEY_BLOB: ::LPCSTR = 83 as ::LPCSTR; pub const X509_SUBJECT_DIR_ATTRS: ::LPCSTR = 84 as ::LPCSTR; pub const PKCS7_SIGNER_INFO: ::LPCSTR = 500 as ::LPCSTR; pub const CMS_SIGNER_INFO: ::LPCSTR = 501 as ::LPCSTR; pub const szOID_AUTHORITY_KEY_IDENTIFIER: &'static str = "2.5.29.1"; pub const szOID_KEY_ATTRIBUTES: &'static str = "2.5.29.2"; pub const szOID_CERT_POLICIES_95: &'static str = "2.5.29.3"; pub const szOID_KEY_USAGE_RESTRICTION: &'static str = "2.5.29.4"; pub const szOID_SUBJECT_ALT_NAME: &'static str = "2.5.29.7"; pub const szOID_ISSUER_ALT_NAME: &'static str = "2.5.29.8"; pub const szOID_BASIC_CONSTRAINTS: &'static str = "2.5.29.10"; pub const szOID_KEY_USAGE: &'static str = "2.5.29.15"; pub const szOID_PRIVATEKEY_USAGE_PERIOD: &'static str = "2.5.29.16"; pub const szOID_BASIC_CONSTRAINTS2: &'static str = "2.5.29.19"; pub const szOID_CERT_POLICIES: &'static str = "2.5.29.32"; pub const szOID_ANY_CERT_POLICY: &'static str = "2.5.29.32.0"; pub const szOID_INHIBIT_ANY_POLICY: &'static str = "2.5.29.54"; pub const szOID_AUTHORITY_KEY_IDENTIFIER2: &'static str = "2.5.29.35"; pub const szOID_SUBJECT_KEY_IDENTIFIER: &'static str = "2.5.29.14"; pub const szOID_SUBJECT_ALT_NAME2: &'static str = "2.5.29.17"; pub const szOID_ISSUER_ALT_NAME2: &'static str = "2.5.29.18"; pub const szOID_CRL_REASON_CODE: &'static str = "2.5.29.21"; pub const szOID_REASON_CODE_HOLD: &'static str = "2.5.29.23"; pub const szOID_CRL_DIST_POINTS: &'static str = "2.5.29.31"; pub const szOID_ENHANCED_KEY_USAGE: &'static str = "2.5.29.37"; pub const szOID_ANY_ENHANCED_KEY_USAGE: &'static str = "2.5.29.37.0"; pub const szOID_CRL_NUMBER: &'static str = "2.5.29.20"; pub const szOID_DELTA_CRL_INDICATOR: &'static str = "2.5.29.27"; pub const szOID_ISSUING_DIST_POINT: &'static str = "2.5.29.28"; pub const szOID_FRESHEST_CRL: &'static str = "2.5.29.46"; pub const szOID_NAME_CONSTRAINTS: &'static str = "2.5.29.30"; pub const szOID_POLICY_MAPPINGS: &'static str = "2.5.29.33"; pub const szOID_LEGACY_POLICY_MAPPINGS: &'static str = "2.5.29.5"; pub const szOID_POLICY_CONSTRAINTS: &'static str = "2.5.29.36"; pub const szOID_RENEWAL_CERTIFICATE: &'static str = "1.3.6.1.4.1.311.13.1"; pub const szOID_ENROLLMENT_NAME_VALUE_PAIR: &'static str = "1.3.6.1.4.1.311.13.2.1"; pub const szOID_ENROLLMENT_CSP_PROVIDER: &'static str = "1.3.6.1.4.1.311.13.2.2"; pub const szOID_OS_VERSION: &'static str = "1.3.6.1.4.1.311.13.2.3"; pub const szOID_ENROLLMENT_AGENT: &'static str = "1.3.6.1.4.1.311.20.2.1"; pub const szOID_PKIX: &'static str = "1.3.6.1.5.5.7"; pub const szOID_PKIX_PE: &'static str = "1.3.6.1.5.5.7.1"; pub const szOID_AUTHORITY_INFO_ACCESS: &'static str = "1.3.6.1.5.5.7.1.1"; pub const szOID_SUBJECT_INFO_ACCESS: &'static str = "1.3.6.1.5.5.7.1.11"; pub const szOID_BIOMETRIC_EXT: &'static str = "1.3.6.1.5.5.7.1.2"; pub const szOID_QC_STATEMENTS_EXT: &'static str = "1.3.6.1.5.5.7.1.3"; pub const szOID_LOGOTYPE_EXT: &'static str = "1.3.6.1.5.5.7.1.12"; pub const szOID_CERT_EXTENSIONS: &'static str = "1.3.6.1.4.1.311.2.1.14"; pub const szOID_NEXT_UPDATE_LOCATION: &'static str = "1.3.6.1.4.1.311.10.2"; pub const szOID_REMOVE_CERTIFICATE: &'static str = "1.3.6.1.4.1.311.10.8.1"; pub const szOID_CROSS_CERT_DIST_POINTS: &'static str = "1.3.6.1.4.1.311.10.9.1"; pub const szOID_CTL: &'static str = "1.3.6.1.4.1.311.10.1"; pub const szOID_SORTED_CTL: &'static str = "1.3.6.1.4.1.311.10.1.1"; pub const szOID_SERIALIZED: &'static str = "1.3.6.1.4.1.311.10.3.3.1"; pub const szOID_NT_PRINCIPAL_NAME: &'static str = "1.3.6.1.4.1.311.20.2.3"; pub const szOID_INTERNATIONALIZED_EMAIL_ADDRESS: &'static str = "1.3.6.1.4.1.311.20.2.4"; pub const szOID_PRODUCT_UPDATE: &'static str = "1.3.6.1.4.1.311.31.1"; pub const szOID_ANY_APPLICATION_POLICY: &'static str = "1.3.6.1.4.1.311.10.12.1"; pub const szOID_AUTO_ENROLL_CTL_USAGE: &'static str = "1.3.6.1.4.1.311.20.1"; pub const szOID_ENROLL_CERTTYPE_EXTENSION: &'static str = "1.3.6.1.4.1.311.20.2"; pub const szOID_CERT_MANIFOLD: &'static str = "1.3.6.1.4.1.311.20.3"; pub const szOID_CERTSRV_CA_VERSION: &'static str = "1.3.6.1.4.1.311.21.1"; pub const szOID_CERTSRV_PREVIOUS_CERT_HASH: &'static str = "1.3.6.1.4.1.311.21.2"; pub const szOID_CRL_VIRTUAL_BASE: &'static str = "1.3.6.1.4.1.311.21.3"; pub const szOID_CRL_NEXT_PUBLISH: &'static str = "1.3.6.1.4.1.311.21.4"; pub const szOID_KP_CA_EXCHANGE: &'static str = "1.3.6.1.4.1.311.21.5"; pub const szOID_KP_KEY_RECOVERY_AGENT: &'static str = "1.3.6.1.4.1.311.21.6"; pub const szOID_CERTIFICATE_TEMPLATE: &'static str = "1.3.6.1.4.1.311.21.7"; pub const szOID_ENTERPRISE_OID_ROOT: &'static str = "1.3.6.1.4.1.311.21.8"; pub const szOID_RDN_DUMMY_SIGNER: &'static str = "1.3.6.1.4.1.311.21.9"; pub const szOID_APPLICATION_CERT_POLICIES: &'static str = "1.3.6.1.4.1.311.21.10"; pub const szOID_APPLICATION_POLICY_MAPPINGS: &'static str = "1.3.6.1.4.1.311.21.11"; pub const szOID_APPLICATION_POLICY_CONSTRAINTS: &'static str = "1.3.6.1.4.1.311.21.12"; pub const szOID_ARCHIVED_KEY_ATTR: &'static str = "1.3.6.1.4.1.311.21.13"; pub const szOID_CRL_SELF_CDP: &'static str = "1.3.6.1.4.1.311.21.14"; pub const szOID_REQUIRE_CERT_CHAIN_POLICY: &'static str = "1.3.6.1.4.1.311.21.15"; pub const szOID_ARCHIVED_KEY_CERT_HASH: &'static str = "1.3.6.1.4.1.311.21.16"; pub const szOID_ISSUED_CERT_HASH: &'static str = "1.3.6.1.4.1.311.21.17"; pub const szOID_DS_EMAIL_REPLICATION: &'static str = "1.3.6.1.4.1.311.21.19"; pub const szOID_REQUEST_CLIENT_INFO: &'static str = "1.3.6.1.4.1.311.21.20"; pub const szOID_ENCRYPTED_KEY_HASH: &'static str = "1.3.6.1.4.1.311.21.21"; pub const szOID_CERTSRV_CROSSCA_VERSION: &'static str = "1.3.6.1.4.1.311.21.22"; pub const szOID_NTDS_REPLICATION: &'static str = "1.3.6.1.4.1.311.25.1"; pub const szOID_SUBJECT_DIR_ATTRS: &'static str = "2.5.29.9"; pub const szOID_PKIX_KP: &'static str = "1.3.6.1.5.5.7.3"; pub const szOID_PKIX_KP_SERVER_AUTH: &'static str = "1.3.6.1.5.5.7.3.1"; pub const szOID_PKIX_KP_CLIENT_AUTH: &'static str = "1.3.6.1.5.5.7.3.2"; pub const szOID_PKIX_KP_CODE_SIGNING: &'static str = "1.3.6.1.5.5.7.3.3"; pub const szOID_PKIX_KP_EMAIL_PROTECTION: &'static str = "1.3.6.1.5.5.7.3.4"; pub const szOID_PKIX_KP_IPSEC_END_SYSTEM: &'static str = "1.3.6.1.5.5.7.3.5"; pub const szOID_PKIX_KP_IPSEC_TUNNEL: &'static str = "1.3.6.1.5.5.7.3.6"; pub const szOID_PKIX_KP_IPSEC_USER: &'static str = "1.3.6.1.5.5.7.3.7"; pub const szOID_PKIX_KP_TIMESTAMP_SIGNING: &'static str = "1.3.6.1.5.5.7.3.8"; pub const szOID_PKIX_KP_OCSP_SIGNING: &'static str = "1.3.6.1.5.5.7.3.9"; pub const szOID_PKIX_OCSP_NOCHECK: &'static str = "1.3.6.1.5.5.7.48.1.5"; pub const szOID_PKIX_OCSP_NONCE: &'static str = "1.3.6.1.5.5.7.48.1.2"; pub const szOID_IPSEC_KP_IKE_INTERMEDIATE: &'static str = "1.3.6.1.5.5.8.2.2"; pub const szOID_PKINIT_KP_KDC: &'static str = "1.3.6.1.5.2.3.5"; pub const szOID_KP_CTL_USAGE_SIGNING: &'static str = "1.3.6.1.4.1.311.10.3.1"; pub const szOID_KP_TIME_STAMP_SIGNING: &'static str = "1.3.6.1.4.1.311.10.3.2"; pub const szOID_SERVER_GATED_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.3"; pub const szOID_SGC_NETSCAPE: &'static str = "2.16.840.1.113730.4.1"; pub const szOID_KP_EFS: &'static str = "1.3.6.1.4.1.311.10.3.4"; pub const szOID_EFS_RECOVERY: &'static str = "1.3.6.1.4.1.311.10.3.4.1"; pub const szOID_WHQL_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.5"; pub const szOID_NT5_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.6"; pub const szOID_OEM_WHQL_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.7"; pub const szOID_EMBEDDED_NT_CRYPTO: &'static str = "1.3.6.1.4.1.311.10.3.8"; pub const szOID_ROOT_LIST_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.9"; pub const szOID_KP_QUALIFIED_SUBORDINATION: &'static str = "1.3.6.1.4.1.311.10.3.10"; pub const szOID_KP_KEY_RECOVERY: &'static str = "1.3.6.1.4.1.311.10.3.11"; pub const szOID_KP_DOCUMENT_SIGNING: &'static str = "1.3.6.1.4.1.311.10.3.12"; pub const szOID_KP_LIFETIME_SIGNING: &'static str = "1.3.6.1.4.1.311.10.3.13"; pub const szOID_KP_MOBILE_DEVICE_SOFTWARE: &'static str = "1.3.6.1.4.1.311.10.3.14"; pub const szOID_KP_SMART_DISPLAY: &'static str = "1.3.6.1.4.1.311.10.3.15"; pub const szOID_KP_CSP_SIGNATURE: &'static str = "1.3.6.1.4.1.311.10.3.16"; pub const szOID_DRM: &'static str = "1.3.6.1.4.1.311.10.5.1"; pub const szOID_DRM_INDIVIDUALIZATION: &'static str = "1.3.6.1.4.1.311.10.5.2"; pub const szOID_LICENSES: &'static str = "1.3.6.1.4.1.311.10.6.1"; pub const szOID_LICENSE_SERVER: &'static str = "1.3.6.1.4.1.311.10.6.2"; pub const szOID_KP_SMARTCARD_LOGON: &'static str = "1.3.6.1.4.1.311.20.2.2"; pub const szOID_KP_KERNEL_MODE_CODE_SIGNING: &'static str = "1.3.6.1.4.1.311.61.1.1"; pub const szOID_KP_KERNEL_MODE_TRUSTED_BOOT_SIGNING: &'static str = "1.3.6.1.4.1.311.61.4.1"; pub const szOID_REVOKED_LIST_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.19"; pub const szOID_WINDOWS_KITS_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.20"; pub const szOID_WINDOWS_RT_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.21"; pub const szOID_PROTECTED_PROCESS_LIGHT_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.22"; pub const szOID_WINDOWS_TCB_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.23"; pub const szOID_PROTECTED_PROCESS_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.24"; pub const szOID_WINDOWS_THIRD_PARTY_COMPONENT_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.25"; pub const szOID_WINDOWS_SOFTWARE_EXTENSION_SIGNER: &'static str = "1.3.6.1.4.1.311.10.3.26"; pub const szOID_DISALLOWED_LIST: &'static str = "1.3.6.1.4.1.311.10.3.30"; pub const szOID_SYNC_ROOT_CTL_EXT: &'static str = "1.3.6.1.4.1.311.10.3.50"; pub const szOID_KP_KERNEL_MODE_HAL_EXTENSION_SIGNING: &'static str = "1.3.6.1.4.1.311.61.5.1"; pub const szOID_WINDOWS_STORE_SIGNER: &'static str = "1.3.6.1.4.1.311.76.3.1"; pub const szOID_DYNAMIC_CODE_GEN_SIGNER: &'static str = "1.3.6.1.4.1.311.76.5.1"; pub const szOID_MICROSOFT_PUBLISHER_SIGNER: &'static str = "1.3.6.1.4.1.311.76.8.1"; pub const szOID_YESNO_TRUST_ATTR: &'static str = "1.3.6.1.4.1.311.10.4.1"; pub const szOID_PKIX_POLICY_QUALIFIER_CPS: &'static str = "1.3.6.1.5.5.7.2.1"; pub const szOID_PKIX_POLICY_QUALIFIER_USERNOTICE: &'static str = "1.3.6.1.5.5.7.2.2"; pub const szOID_ROOT_PROGRAM_FLAGS: &'static str = "1.3.6.1.4.1.311.60.1.1"; //6992 pub type HCRYPTMSG = *mut ::c_void; //9353 pub type HCERTSTORE = *mut ::c_void; STRUCT!{struct CERT_CONTEXT { dwCertEncodingType: ::DWORD, pbCertEncoded: *mut ::BYTE, cbCertEncoded: ::DWORD, pCertInfo: ::PCERT_INFO, hCertStore: HCERTSTORE, }} pub type PCERT_CONTEXT = *mut CERT_CONTEXT; pub type PCCERT_CONTEXT = *const CERT_CONTEXT; STRUCT!{struct CRL_CONTEXT { dwCertEncodingType: ::DWORD, pbCrlEncoded: *mut ::BYTE, cbCrlEncoded: ::DWORD, pCrlInfo: ::PCRL_INFO, hCertStore: HCERTSTORE, }} pub type PCRL_CONTEXT = *mut CRL_CONTEXT; pub type PCCRL_CONTEXT = *const CRL_CONTEXT; STRUCT!{struct CTL_CONTEXT { dwMsgAndCertEncodingType: ::DWORD, pbCtlEncoded: *mut ::BYTE, cbCtlEncoded: ::DWORD, pCtlInfo: ::PCTL_INFO, hCertStore: HCERTSTORE, hCryptMsg: HCRYPTMSG, pbCtlContent: *mut ::BYTE, cbCtlContent: ::DWORD, }} pub type PCTL_CONTEXT = *mut CTL_CONTEXT; pub type PCCTL_CONTEXT = *const CTL_CONTEXT; pub const CERT_STORE_PROV_MSG: ::DWORD = 1; pub const CERT_STORE_PROV_MEMORY: ::DWORD = 2; pub const CERT_STORE_PROV_FILE: ::DWORD = 3; pub const CERT_STORE_PROV_REG: ::DWORD = 4; pub const CERT_STORE_PROV_PKCS7: ::DWORD = 5; pub const CERT_STORE_PROV_SERIALIZED: ::DWORD = 6; pub const CERT_STORE_PROV_FILENAME_A: ::DWORD = 7; pub const CERT_STORE_PROV_FILENAME_W: ::DWORD = 8; pub const CERT_STORE_PROV_FILENAME: ::DWORD = CERT_STORE_PROV_FILENAME_W; pub const CERT_STORE_PROV_SYSTEM_A: ::DWORD = 9; pub const CERT_STORE_PROV_SYSTEM_W: ::DWORD = 10; pub const CERT_STORE_PROV_SYSTEM: ::DWORD = CERT_STORE_PROV_SYSTEM_W; pub const CERT_STORE_PROV_COLLECTION: ::DWORD = 11; pub const CERT_STORE_PROV_SYSTEM_REGISTRY_A: ::DWORD = 12; pub const CERT_STORE_PROV_SYSTEM_REGISTRY_W: ::DWORD = 13; pub const CERT_STORE_PROV_SYSTEM_REGISTRY: ::DWORD = CERT_STORE_PROV_SYSTEM_REGISTRY_W; pub const CERT_STORE_PROV_PHYSICAL_W: ::DWORD = 14; pub const CERT_STORE_PROV_PHYSICAL: ::DWORD = CERT_STORE_PROV_PHYSICAL_W; pub const CERT_STORE_PROV_SMART_CARD_W: ::DWORD = 15; pub const CERT_STORE_PROV_SMART_CARD: ::DWORD = CERT_STORE_PROV_SMART_CARD_W; pub const CERT_STORE_PROV_LDAP_W: ::DWORD = 16; pub const CERT_STORE_PROV_LDAP: ::DWORD = CERT_STORE_PROV_LDAP_W; pub const CERT_STORE_NO_CRYPT_RELEASE_FLAG: ::DWORD = 0x00000001; pub const CERT_STORE_SET_LOCALIZED_NAME_FLAG: ::DWORD = 0x00000002; pub const CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG: ::DWORD = 0x00000004; pub const CERT_STORE_DELETE_FLAG: ::DWORD = 0x00000010; pub const CERT_STORE_SHARE_STORE_FLAG: ::DWORD = 0x00000040; pub const CERT_STORE_SHARE_CONTEXT_FLAG: ::DWORD = 0x00000080; pub const CERT_STORE_MANIFOLD_FLAG: ::DWORD = 0x00000100; pub const CERT_STORE_ENUM_ARCHIVED_FLAG: ::DWORD = 0x00000200; pub const CERT_STORE_UPDATE_KEYID_FLAG: ::DWORD = 0x00000400; pub const CERT_STORE_BACKUP_RESTORE_FLAG: ::DWORD = 0x00000800; pub const CERT_STORE_READONLY_FLAG: ::DWORD = 0x00008000; pub const CERT_STORE_OPEN_EXISTING_FLAG: ::DWORD = 0x00004000; pub const CERT_STORE_CREATE_NEW_FLAG: ::DWORD = 0x00002000; pub const CERT_STORE_MAXIMUM_ALLOWED_FLAG: ::DWORD = 0x00001000; pub const CERT_SYSTEM_STORE_UNPROTECTED_FLAG: ::DWORD = 0x40000000; pub const CERT_SYSTEM_STORE_LOCATION_MASK: ::DWORD = 0x00FF0000; pub const CERT_SYSTEM_STORE_LOCATION_SHIFT: ::DWORD = 16; pub const CERT_SYSTEM_STORE_CURRENT_USER_ID: ::DWORD = 1; pub const CERT_SYSTEM_STORE_LOCAL_MACHINE_ID: ::DWORD = 2; pub const CERT_SYSTEM_STORE_CURRENT_SERVICE_ID: ::DWORD = 4; pub const CERT_SYSTEM_STORE_SERVICES_ID: ::DWORD = 5; pub const CERT_SYSTEM_STORE_USERS_ID: ::DWORD = 6; pub const CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID: ::DWORD = 7; pub const CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID: ::DWORD = 8; pub const CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID: ::DWORD = 9; pub const CERT_SYSTEM_STORE_CURRENT_USER: ::DWORD = CERT_SYSTEM_STORE_CURRENT_USER_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT; pub const CERT_SYSTEM_STORE_LOCAL_MACHINE: ::DWORD = CERT_SYSTEM_STORE_LOCAL_MACHINE_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT; pub const CERT_SYSTEM_STORE_CURRENT_SERVICE: ::DWORD = CERT_SYSTEM_STORE_CURRENT_SERVICE_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT; pub const CERT_SYSTEM_STORE_SERVICES: ::DWORD = CERT_SYSTEM_STORE_SERVICES_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT; pub const CERT_SYSTEM_STORE_USERS: ::DWORD = CERT_SYSTEM_STORE_USERS_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT; pub const CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY: ::DWORD = CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT; pub const CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY: ::DWORD = CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT; pub const CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE: ::DWORD = CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT; pub const CERT_NAME_EMAIL_TYPE: ::DWORD = 1; pub const CERT_NAME_RDN_TYPE: ::DWORD = 2; pub const CERT_NAME_ATTR_TYPE: ::DWORD = 3; pub const CERT_NAME_SIMPLE_DISPLAY_TYPE: ::DWORD = 4; pub const CERT_NAME_FRIENDLY_DISPLAY_TYPE: ::DWORD = 5; pub const CERT_NAME_DNS_TYPE: ::DWORD = 6; pub const CERT_NAME_URL_TYPE: ::DWORD = 7; pub const CERT_NAME_UPN_TYPE: ::DWORD = 8; pub const CERT_SIMPLE_NAME_STR: ::DWORD = 1; pub const CERT_OID_NAME_STR: ::DWORD = 2; pub const CERT_X500_NAME_STR: ::DWORD = 3; pub const CERT_NAME_STR_SEMICOLON_FLAG: ::DWORD = 0x40000000; pub const CERT_NAME_STR_NO_PLUS_FLAG: ::DWORD = 0x20000000; pub const CERT_NAME_STR_NO_QUOTING_FLAG: ::DWORD = 0x10000000; pub const CERT_NAME_STR_CRLF_FLAG: ::DWORD = 0x08000000; pub const CERT_NAME_STR_COMMA_FLAG: ::DWORD = 0x04000000; pub const CERT_NAME_STR_REVERSE_FLAG: ::DWORD = 0x02000000; pub const CERT_NAME_ISSUER_FLAG: ::DWORD = 0x1; pub const CERT_NAME_STR_DISABLE_IE4_UTF8_FLAG: ::DWORD = 0x00010000; pub const CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG: ::DWORD = 0x00020000; pub const CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG: ::DWORD = 0x00040000; pub const CERT_NAME_STR_FORCE_UTF8_DIR_STR_FLAG: ::DWORD = 0x00080000; pub const CERT_DELETE_KEYSET_PROP_ID: ::DWORD = 101; pub const CERT_COMPARE_MASK: ::DWORD = 0xFFFF; pub const CERT_COMPARE_SHIFT: ::DWORD = 16; pub const CERT_COMPARE_ANY: ::DWORD = 0; pub const CERT_COMPARE_SHA1_HASH: ::DWORD = 1; pub const CERT_COMPARE_NAME: ::DWORD = 2; pub const CERT_COMPARE_ATTR: ::DWORD = 3; pub const CERT_COMPARE_MD5_HASH: ::DWORD = 4; pub const CERT_COMPARE_PROPERTY: ::DWORD = 5; pub const CERT_COMPARE_PUBLIC_KEY: ::DWORD = 6; pub const CERT_COMPARE_HASH: ::DWORD = CERT_COMPARE_SHA1_HASH; pub const CERT_COMPARE_NAME_STR_A: ::DWORD = 7; pub const CERT_COMPARE_NAME_STR_W: ::DWORD = 8; pub const CERT_COMPARE_KEY_SPEC: ::DWORD = 9; pub const CERT_COMPARE_ENHKEY_USAGE: ::DWORD = 10; pub const CERT_COMPARE_CTL_USAGE: ::DWORD = CERT_COMPARE_ENHKEY_USAGE; pub const CERT_COMPARE_SUBJECT_CERT: ::DWORD = 11; pub const CERT_COMPARE_ISSUER_OF: ::DWORD = 12; pub const CERT_COMPARE_EXISTING: ::DWORD = 13; pub const CERT_COMPARE_SIGNATURE_HASH: ::DWORD = 14; pub const CERT_COMPARE_KEY_IDENTIFIER: ::DWORD = 15; pub const CERT_COMPARE_CERT_ID: ::DWORD = 16; pub const CERT_COMPARE_CROSS_CERT_DIST_POINTS: ::DWORD = 17; pub const CERT_COMPARE_PUBKEY_MD5_HASH: ::DWORD = 18; pub const CERT_FIND_ANY: ::DWORD = CERT_COMPARE_ANY << CERT_COMPARE_SHIFT; pub const CERT_FIND_SHA1_HASH: ::DWORD = CERT_COMPARE_SHA1_HASH << CERT_COMPARE_SHIFT; pub const CERT_FIND_MD5_HASH: ::DWORD = CERT_COMPARE_MD5_HASH << CERT_COMPARE_SHIFT; pub const CERT_FIND_SIGNATURE_HASH: ::DWORD = CERT_COMPARE_SIGNATURE_HASH << CERT_COMPARE_SHIFT; pub const CERT_FIND_KEY_IDENTIFIER: ::DWORD = CERT_COMPARE_KEY_IDENTIFIER << CERT_COMPARE_SHIFT; pub const CERT_FIND_HASH: ::DWORD = CERT_FIND_SHA1_HASH; pub const CERT_FIND_PROPERTY: ::DWORD = CERT_COMPARE_PROPERTY << CERT_COMPARE_SHIFT; pub const CERT_FIND_PUBLIC_KEY: ::DWORD = CERT_COMPARE_PUBLIC_KEY << CERT_COMPARE_SHIFT; pub const CERT_FIND_SUBJECT_NAME: ::DWORD = (CERT_COMPARE_NAME << CERT_COMPARE_SHIFT) | CERT_INFO_SUBJECT_FLAG; pub const CERT_FIND_SUBJECT_ATTR: ::DWORD = (CERT_COMPARE_ATTR << CERT_COMPARE_SHIFT) | CERT_INFO_SUBJECT_FLAG; pub const CERT_FIND_ISSUER_NAME: ::DWORD = (CERT_COMPARE_NAME << CERT_COMPARE_SHIFT) | CERT_INFO_ISSUER_FLAG; pub const CERT_FIND_ISSUER_ATTR: ::DWORD = (CERT_COMPARE_ATTR << CERT_COMPARE_SHIFT) | CERT_INFO_ISSUER_FLAG; pub const CERT_FIND_SUBJECT_STR_A: ::DWORD = (CERT_COMPARE_NAME_STR_A << CERT_COMPARE_SHIFT) | CERT_INFO_SUBJECT_FLAG; pub const CERT_FIND_SUBJECT_STR_W: ::DWORD = (CERT_COMPARE_NAME_STR_W << CERT_COMPARE_SHIFT) | CERT_INFO_SUBJECT_FLAG; pub const CERT_FIND_SUBJECT_STR: ::DWORD = CERT_FIND_SUBJECT_STR_W; pub const CERT_FIND_ISSUER_STR_A: ::DWORD = (CERT_COMPARE_NAME_STR_A << CERT_COMPARE_SHIFT) | CERT_INFO_ISSUER_FLAG; pub const CERT_FIND_ISSUER_STR_W: ::DWORD = (CERT_COMPARE_NAME_STR_W << CERT_COMPARE_SHIFT) | CERT_INFO_ISSUER_FLAG; pub const CERT_FIND_ISSUER_STR: ::DWORD = CERT_FIND_ISSUER_STR_W; pub const CERT_FIND_KEY_SPEC: ::DWORD = CERT_COMPARE_KEY_SPEC << CERT_COMPARE_SHIFT; pub const CERT_FIND_ENHKEY_USAGE: ::DWORD = CERT_COMPARE_ENHKEY_USAGE << CERT_COMPARE_SHIFT; pub const CERT_FIND_CTL_USAGE: ::DWORD = CERT_FIND_ENHKEY_USAGE; pub const CERT_FIND_SUBJECT_CERT: ::DWORD = CERT_COMPARE_SUBJECT_CERT << CERT_COMPARE_SHIFT; pub const CERT_FIND_ISSUER_OF: ::DWORD = CERT_COMPARE_ISSUER_OF << CERT_COMPARE_SHIFT; pub const CERT_FIND_EXISTING: ::DWORD = CERT_COMPARE_EXISTING << CERT_COMPARE_SHIFT; pub const CERT_FIND_CERT_ID: ::DWORD = CERT_COMPARE_CERT_ID << CERT_COMPARE_SHIFT; pub const CERT_FIND_CROSS_CERT_DIST_POINTS: ::DWORD = CERT_COMPARE_CROSS_CERT_DIST_POINTS << CERT_COMPARE_SHIFT; pub const CERT_FIND_PUBKEY_MD5_HASH: ::DWORD = CERT_COMPARE_PUBKEY_MD5_HASH << CERT_COMPARE_SHIFT; pub const CERT_ENCIPHER_ONLY_KEY_USAGE: ::DWORD = 0x0001; pub const CERT_CRL_SIGN_KEY_USAGE: ::DWORD = 0x0002; pub const CERT_KEY_CERT_SIGN_KEY_USAGE: ::DWORD = 0x0004; pub const CERT_KEY_AGREEMENT_KEY_USAGE: ::DWORD = 0x0008; pub const CERT_DATA_ENCIPHERMENT_KEY_USAGE: ::DWORD = 0x0010; pub const CERT_KEY_ENCIPHERMENT_KEY_USAGE: ::DWORD = 0x0020; pub const CERT_NON_REPUDIATION_KEY_USAGE: ::DWORD = 0x0040; pub const CERT_DIGITAL_SIGNATURE_KEY_USAGE: ::DWORD = 0x0080; pub const CERT_DECIPHER_ONLY_KEY_USAGE: ::DWORD = 0x8000; pub const CERT_STORE_ADD_NEW: ::DWORD = 1; pub const CERT_STORE_ADD_USE_EXISTING: ::DWORD = 2; pub const CERT_STORE_ADD_REPLACE_EXISTING: ::DWORD = 3; pub const CERT_STORE_ADD_ALWAYS: ::DWORD = 4; pub const CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES: ::DWORD = 5; pub const CERT_STORE_ADD_NEWER: ::DWORD = 6; pub const CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES: ::DWORD = 7; pub const CERT_STORE_SAVE_AS_STORE: ::DWORD = 1; pub const CERT_STORE_SAVE_AS_PKCS7: ::DWORD = 2; pub const CERT_STORE_SAVE_TO_FILE: ::DWORD = 1; pub const CERT_STORE_SAVE_TO_MEMORY: ::DWORD = 2; pub const CERT_STORE_SAVE_TO_FILENAME_A: ::DWORD = 3; pub const CERT_STORE_SAVE_TO_FILENAME_W: ::DWORD = 4; pub const CERT_STORE_SAVE_TO_FILENAME: ::DWORD = CERT_STORE_SAVE_TO_FILENAME_W; pub const CERT_CA_SUBJECT_FLAG: ::DWORD = 0x80; pub const CERT_END_ENTITY_SUBJECT_FLAG: ::DWORD = 0x40; pub const CERT_CHAIN_POLICY_BASE: ::DWORD = 1; pub const CERT_CHAIN_POLICY_AUTHENTICODE: ::DWORD = 2; pub const CERT_CHAIN_POLICY_AUTHENTICODE_TS: ::DWORD = 3; pub const CERT_CHAIN_POLICY_SSL: ::DWORD = 4; pub const CERT_CHAIN_POLICY_BASIC_CONSTRAINTS: ::DWORD = 5; pub const CERT_CHAIN_POLICY_NT_AUTH: ::DWORD = 6; pub const CERT_CHAIN_POLICY_MICROSOFT_ROOT: ::DWORD = 7; pub const CERT_CHAIN_REVOCATION_CHECK_END_CERT: ::DWORD = 0x10000000; pub const CERT_CHAIN_REVOCATION_CHECK_CHAIN: ::DWORD = 0x20000000; pub const CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT: ::DWORD = 0x40000000; pub const CERT_CHAIN_REVOCATION_CHECK_CACHE_ONLY: ::DWORD = 0x80000000; pub const CERT_CHAIN_REVOCATION_ACCUMULATIVE_TIMEOUT: ::DWORD = 0x08000000; pub const CERT_TRUST_NO_ERROR: ::DWORD = 0x00000000; pub const CERT_TRUST_IS_NOT_TIME_VALID: ::DWORD = 0x00000001; pub const CERT_TRUST_IS_NOT_TIME_NESTED: ::DWORD = 0x00000002; pub const CERT_TRUST_IS_REVOKED: ::DWORD = 0x00000004; pub const CERT_TRUST_IS_NOT_SIGNATURE_VALID: ::DWORD = 0x00000008; pub const CERT_TRUST_IS_NOT_VALID_FOR_USAGE: ::DWORD = 0x00000010; pub const CERT_TRUST_IS_UNTRUSTED_ROOT: ::DWORD = 0x00000020; pub const CERT_TRUST_REVOCATION_STATUS_UNKNOWN: ::DWORD = 0x00000040; pub const CERT_TRUST_IS_CYCLIC: ::DWORD = 0x00000080; pub const CERT_TRUST_INVALID_EXTENSION: ::DWORD = 0x00000100; pub const CERT_TRUST_INVALID_POLICY_CONSTRAINTS: ::DWORD = 0x00000200; pub const CERT_TRUST_INVALID_BASIC_CONSTRAINTS: ::DWORD = 0x00000400; pub const CERT_TRUST_INVALID_NAME_CONSTRAINTS: ::DWORD = 0x00000800; pub const CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT: ::DWORD = 0x00001000; pub const CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT: ::DWORD = 0x00002000; pub const CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT: ::DWORD = 0x00004000; pub const CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT: ::DWORD = 0x00008000; pub const CERT_TRUST_IS_OFFLINE_REVOCATION: ::DWORD = 0x01000000; pub const CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY: ::DWORD = 0x02000000; pub const CERT_TRUST_IS_PARTIAL_CHAIN: ::DWORD = 0x00010000; pub const CERT_TRUST_CTL_IS_NOT_TIME_VALID: ::DWORD = 0x00020000; pub const CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID: ::DWORD = 0x00040000; pub const CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE: ::DWORD = 0x00080000; pub const CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG: ::DWORD = 0x00000001; pub const CERT_CHAIN_POLICY_IGNORE_CTL_NOT_TIME_VALID_FLAG: ::DWORD = 0x00000002; pub const CERT_CHAIN_POLICY_IGNORE_NOT_TIME_NESTED_FLAG: ::DWORD = 0x00000004; pub const CERT_CHAIN_POLICY_IGNORE_INVALID_BASIC_CONSTRAINTS_FLAG: ::DWORD = 0x00000008; pub const CERT_CHAIN_POLICY_ALLOW_UNKNOWN_CA_FLAG: ::DWORD = 0x00000010; pub const CERT_CHAIN_POLICY_IGNORE_WRONG_USAGE_FLAG: ::DWORD = 0x00000020; pub const CERT_CHAIN_POLICY_IGNORE_INVALID_NAME_FLAG: ::DWORD = 0x00000040; pub const CERT_CHAIN_POLICY_IGNORE_INVALID_POLICY_FLAG: ::DWORD = 0x00000080; pub const CERT_CHAIN_POLICY_IGNORE_END_REV_UNKNOWN_FLAG: ::DWORD = 0x00000100; pub const CERT_CHAIN_POLICY_IGNORE_CTL_SIGNER_REV_UNKNOWN_FLAG: ::DWORD = 0x00000200; pub const CERT_CHAIN_POLICY_IGNORE_CA_REV_UNKNOWN_FLAG: ::DWORD = 0x00000400; pub const CERT_CHAIN_POLICY_IGNORE_ROOT_REV_UNKNOWN_FLAG: ::DWORD = 0x00000800; pub const CERT_CHAIN_POLICY_IGNORE_ALL_REV_UNKNOWN_FLAGS: ::DWORD = CERT_CHAIN_POLICY_IGNORE_END_REV_UNKNOWN_FLAG | CERT_CHAIN_POLICY_IGNORE_CTL_SIGNER_REV_UNKNOWN_FLAG | CERT_CHAIN_POLICY_IGNORE_CA_REV_UNKNOWN_FLAG | CERT_CHAIN_POLICY_IGNORE_ROOT_REV_UNKNOWN_FLAG; pub const CERT_TRUST_HAS_EXACT_MATCH_ISSUER: ::DWORD = 0x00000001; pub const CERT_TRUST_HAS_KEY_MATCH_ISSUER: ::DWORD = 0x00000002; pub const CERT_TRUST_HAS_NAME_MATCH_ISSUER: ::DWORD = 0x00000004; pub const CERT_TRUST_IS_SELF_SIGNED: ::DWORD = 0x00000008; pub const CERT_TRUST_HAS_PREFERRED_ISSUER: ::DWORD = 0x00000100; pub const CERT_TRUST_HAS_ISSUANCE_CHAIN_POLICY: ::DWORD = 0x00000200; pub const CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS: ::DWORD = 0x00000400; pub const CERT_TRUST_IS_COMPLEX_CHAIN: ::DWORD = 0x00010000; pub const CERT_ALT_NAME_OTHER_NAME: ::DWORD = 1; pub const CERT_ALT_NAME_RFC822_NAME: ::DWORD = 2; pub const CERT_ALT_NAME_DNS_NAME: ::DWORD = 3; pub const CERT_ALT_NAME_X400_ADDRESS: ::DWORD = 4; pub const CERT_ALT_NAME_DIRECTORY_NAME: ::DWORD = 5; pub const CERT_ALT_NAME_EDI_PARTY_NAME: ::DWORD = 6; pub const CERT_ALT_NAME_URL: ::DWORD = 7; pub const CERT_ALT_NAME_IP_ADDRESS: ::DWORD = 8; pub const CERT_ALT_NAME_REGISTERED_ID: ::DWORD = 9; pub const CERT_STORE_CTRL_RESYNC: ::DWORD = 1; pub const CERT_STORE_CTRL_NOTIFY_CHANGE: ::DWORD = 2; pub const CERT_STORE_CTRL_COMMIT: ::DWORD = 3; pub const CERT_STORE_CTRL_AUTO_RESYNC: ::DWORD = 4; pub const CERT_STORE_CTRL_CANCEL_NOTIFY: ::DWORD = 5; pub const CERT_ID_ISSUER_SERIAL_NUMBER: ::DWORD = 1; pub const CERT_ID_KEY_IDENTIFIER: ::DWORD = 2; pub const CERT_ID_SHA1_HASH: ::DWORD = 3; pub const CERT_KEY_PROV_HANDLE_PROP_ID: ::DWORD = 1; pub const CERT_KEY_PROV_INFO_PROP_ID: ::DWORD = 2; pub const CERT_SHA1_HASH_PROP_ID: ::DWORD = 3; pub const CERT_MD5_HASH_PROP_ID: ::DWORD = 4; pub const CERT_HASH_PROP_ID: ::DWORD = CERT_SHA1_HASH_PROP_ID; pub const CERT_KEY_CONTEXT_PROP_ID: ::DWORD = 5; pub const CERT_KEY_SPEC_PROP_ID: ::DWORD = 6; pub const CERT_IE30_RESERVED_PROP_ID: ::DWORD = 7; pub const CERT_PUBKEY_HASH_RESERVED_PROP_ID: ::DWORD = 8; pub const CERT_ENHKEY_USAGE_PROP_ID: ::DWORD = 9; pub const CERT_CTL_USAGE_PROP_ID: ::DWORD = CERT_ENHKEY_USAGE_PROP_ID; pub const CERT_NEXT_UPDATE_LOCATION_PROP_ID: ::DWORD = 10; pub const CERT_FRIENDLY_NAME_PROP_ID: ::DWORD = 11; pub const CERT_PVK_FILE_PROP_ID: ::DWORD = 12; pub const CERT_DESCRIPTION_PROP_ID: ::DWORD = 13; pub const CERT_ACCESS_STATE_PROP_ID: ::DWORD = 14; pub const CERT_SIGNATURE_HASH_PROP_ID: ::DWORD = 15; pub const CERT_SMART_CARD_DATA_PROP_ID: ::DWORD = 16; pub const CERT_EFS_PROP_ID: ::DWORD = 17; pub const CERT_FORTEZZA_DATA_PROP_ID: ::DWORD = 18; pub const CERT_ARCHIVED_PROP_ID: ::DWORD = 19; pub const CERT_KEY_IDENTIFIER_PROP_ID: ::DWORD = 20; pub const CERT_AUTO_ENROLL_PROP_ID: ::DWORD = 21; pub const CERT_PUBKEY_ALG_PARA_PROP_ID: ::DWORD = 22; pub const CERT_CROSS_CERT_DIST_POINTS_PROP_ID: ::DWORD = 23; pub const CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID: ::DWORD = 24; pub const CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID: ::DWORD = 25; pub const CERT_ENROLLMENT_PROP_ID: ::DWORD = 26; pub const CERT_DATE_STAMP_PROP_ID: ::DWORD = 27; pub const CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID: ::DWORD = 28; pub const CERT_SUBJECT_NAME_MD5_HASH_PROP_ID: ::DWORD = 29; pub const CERT_EXTENDED_ERROR_INFO_PROP_ID: ::DWORD = 30; pub const CERT_RENEWAL_PROP_ID: ::DWORD = 64; pub const CERT_ARCHIVED_KEY_HASH_PROP_ID: ::DWORD = 65; pub const CERT_AUTO_ENROLL_RETRY_PROP_ID: ::DWORD = 66; pub const CERT_AIA_URL_RETRIEVED_PROP_ID: ::DWORD = 67; pub const CERT_AUTHORITY_INFO_ACCESS_PROP_ID: ::DWORD = 68; pub const CERT_BACKED_UP_PROP_ID: ::DWORD = 69; pub const CERT_OCSP_RESPONSE_PROP_ID: ::DWORD = 70; pub const CERT_REQUEST_ORIGINATOR_PROP_ID: ::DWORD = 71; pub const CERT_SOURCE_LOCATION_PROP_ID: ::DWORD = 72; pub const CERT_SOURCE_URL_PROP_ID: ::DWORD = 73; pub const CERT_NEW_KEY_PROP_ID: ::DWORD = 74; pub const CERT_OCSP_CACHE_PREFIX_PROP_ID: ::DWORD = 75; pub const CERT_SMART_CARD_ROOT_INFO_PROP_ID: ::DWORD = 76; pub const CERT_NO_AUTO_EXPIRE_CHECK_PROP_ID: ::DWORD = 77; pub const CERT_NCRYPT_KEY_HANDLE_PROP_ID: ::DWORD = 78; pub const CERT_HCRYPTPROV_OR_NCRYPT_KEY_HANDLE_PROP_ID: ::DWORD = 79; pub const CERT_SUBJECT_INFO_ACCESS_PROP_ID: ::DWORD = 80; pub const CERT_CA_OCSP_AUTHORITY_INFO_ACCESS_PROP_ID: ::DWORD = 81; pub const CERT_CA_DISABLE_CRL_PROP_ID: ::DWORD = 82; pub const CERT_ROOT_PROGRAM_CERT_POLICIES_PROP_ID: ::DWORD = 83; pub const CERT_ROOT_PROGRAM_NAME_CONSTRAINTS_PROP_ID: ::DWORD = 84; pub const CERT_SUBJECT_OCSP_AUTHORITY_INFO_ACCESS_PROP_ID: ::DWORD = 85; pub const CERT_SUBJECT_DISABLE_CRL_PROP_ID: ::DWORD = 86; pub const CERT_CEP_PROP_ID: ::DWORD = 87; pub const CERT_SIGN_HASH_CNG_ALG_PROP_ID: ::DWORD = 89; pub const CERT_SCARD_PIN_ID_PROP_ID: ::DWORD = 90; pub const CERT_SCARD_PIN_INFO_PROP_ID: ::DWORD = 91; pub const CERT_SUBJECT_PUB_KEY_BIT_LENGTH_PROP_ID: ::DWORD = 92; pub const CERT_PUB_KEY_CNG_ALG_BIT_LENGTH_PROP_ID: ::DWORD = 93; pub const CERT_ISSUER_PUB_KEY_BIT_LENGTH_PROP_ID: ::DWORD = 94; pub const CERT_ISSUER_CHAIN_SIGN_HASH_CNG_ALG_PROP_ID: ::DWORD = 95; pub const CERT_ISSUER_CHAIN_PUB_KEY_CNG_ALG_BIT_LENGTH_PROP_ID: ::DWORD = 96; pub const CERT_NO_EXPIRE_NOTIFICATION_PROP_ID: ::DWORD = 97; pub const CERT_AUTH_ROOT_SHA256_HASH_PROP_ID: ::DWORD = 98; pub const CERT_NCRYPT_KEY_HANDLE_TRANSFER_PROP_ID: ::DWORD = 99; pub const CERT_HCRYPTPROV_TRANSFER_PROP_ID: ::DWORD = 100; pub const CERT_SMART_CARD_READER_PROP_ID: ::DWORD = 101; pub const CERT_SEND_AS_TRUSTED_ISSUER_PROP_ID: ::DWORD = 102; pub const CERT_KEY_REPAIR_ATTEMPTED_PROP_ID: ::DWORD = 103; pub const CERT_DISALLOWED_FILETIME_PROP_ID: ::DWORD = 104; pub const CERT_ROOT_PROGRAM_CHAIN_POLICIES_PROP_ID: ::DWORD = 105; pub const CERT_SMART_CARD_READER_NON_REMOVABLE_PROP_ID: ::DWORD = 106; pub const CERT_SHA256_HASH_PROP_ID: ::DWORD = 107; pub const CERT_SCEP_SERVER_CERTS_PROP_ID: ::DWORD = 108; pub const CERT_SCEP_RA_SIGNATURE_CERT_PROP_ID: ::DWORD = 109; pub const CERT_SCEP_RA_ENCRYPTION_CERT_PROP_ID: ::DWORD = 110; pub const CERT_SCEP_CA_CERT_PROP_ID: ::DWORD = 111; pub const CERT_SCEP_SIGNER_CERT_PROP_ID: ::DWORD = 112; pub const CERT_SCEP_NONCE_PROP_ID: ::DWORD = 113; pub const CERT_SCEP_ENCRYPT_HASH_CNG_ALG_PROP_ID: ::DWORD = 114; pub const CERT_SCEP_FLAGS_PROP_ID: ::DWORD = 115; pub const CERT_SCEP_GUID_PROP_ID: ::DWORD = 116; pub const CERT_SERIALIZABLE_KEY_CONTEXT_PROP_ID: ::DWORD = 117; pub const CERT_ISOLATED_KEY_PROP_ID: ::DWORD = 118; pub const CERT_FIRST_RESERVED_PROP_ID: ::DWORD = 119; pub const CERT_LAST_RESERVED_PROP_ID: ::DWORD = 0x00007FFF; pub const CERT_FIRST_USER_PROP_ID: ::DWORD = 0x00008000; pub const CERT_LAST_USER_PROP_ID: ::DWORD = 0x0000FFFF; pub const szOID_CERT_PROP_ID_PREFIX: &'static str = "1.3.6.1.4.1.311.10.11."; pub const szOID_CERT_KEY_IDENTIFIER_PROP_ID: &'static str = "1.3.6.1.4.1.311.10.11.20"; pub const szOID_CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID: &'static str = "1.3.6.1.4.1.311.10.11.28"; pub const szOID_CERT_SUBJECT_NAME_MD5_HASH_PROP_ID: &'static str = "1.3.6.1.4.1.311.10.11.29"; pub const szOID_CERT_MD5_HASH_PROP_ID: &'static str = "1.3.6.1.4.1.311.10.11.4"; pub const szOID_CERT_SIGNATURE_HASH_PROP_ID: &'static str = "1.3.6.1.4.1.311.10.11.15"; pub const szOID_DISALLOWED_HASH: &'static str = szOID_CERT_SIGNATURE_HASH_PROP_ID; pub const szOID_CERT_DISALLOWED_FILETIME_PROP_ID: &'static str = "1.3.6.1.4.1.311.10.11.104"; pub const CERT_ACCESS_STATE_WRITE_PERSIST_FLAG: ::DWORD = 0x1; pub const CERT_ACCESS_STATE_SYSTEM_STORE_FLAG: ::DWORD = 0x2; pub const CERT_ACCESS_STATE_LM_SYSTEM_STORE_FLAG: ::DWORD = 0x4; pub const CERT_ACCESS_STATE_GP_SYSTEM_STORE_FLAG: ::DWORD = 0x8; pub const CERT_ACCESS_STATE_SHARED_USER_FLAG: ::DWORD = 0x10; pub const szOID_ROOT_PROGRAM_AUTO_UPDATE_CA_REVOCATION: &'static str = "1.3.6.1.4.1.311.60.3.1"; pub const szOID_ROOT_PROGRAM_AUTO_UPDATE_END_REVOCATION: &'static str = "1.3.6.1.4.1.311.60.3.2"; pub const szOID_ROOT_PROGRAM_NO_OCSP_FAILOVER_TO_CRL: &'static str = "1.3.6.1.4.1.311.60.3.3"; STRUCT!{struct CRYPT_KEY_PROV_PARAM { dwParam: ::DWORD, pbData: *mut ::BYTE, cbData: ::DWORD, dwFlags: ::DWORD, }} pub type PCRYPT_KEY_PROV_PARAM = *mut CRYPT_KEY_PROV_PARAM; STRUCT!{struct CRYPT_KEY_PROV_INFO { pwszContainerName: ::LPWSTR, pwszProvName: ::LPWSTR, dwProvType: ::DWORD, dwFlags: ::DWORD, cProvParam: ::DWORD, rgProvParam: PCRYPT_KEY_PROV_PARAM, dwKeySpec: ::DWORD, }} pub type PCRYPT_KEY_PROV_INFO = *mut CRYPT_KEY_PROV_INFO; pub const CERT_SET_KEY_PROV_HANDLE_PROP_ID: ::DWORD = 0x00000001; pub const CERT_SET_KEY_CONTEXT_PROP_ID: ::DWORD = 0x00000001; pub const CERT_NCRYPT_KEY_SPEC: ::DWORD = 0xFFFFFFFF; //20213 pub type HCERT_SERVER_OCSP_RESPONSE = *mut ::c_void; STRUCT!{struct CERT_SERVER_OCSP_RESPONSE_CONTEXT { cbSize: ::DWORD, pbEncodedOcspResponse: *mut ::BYTE, cbEncodedOcspResponse: ::DWORD, }} pub type PCERT_SERVER_OCSP_RESPONSE_CONTEXT = *mut CERT_SERVER_OCSP_RESPONSE_CONTEXT; pub type PCCERT_SERVER_OCSP_RESPONSE_CONTEXT = *const CERT_SERVER_OCSP_RESPONSE_CONTEXT; STRUCT!{struct CERT_CHAIN_ENGINE_CONFIG { cbSize: ::DWORD, hRestrictedRoot: HCERTSTORE, hRestrictedTrust: HCERTSTORE, hRestrictedOther: HCERTSTORE, cAdditionalStore: ::DWORD, rghAdditionalStore: *mut HCERTSTORE, dwFlags: ::DWORD, dwUrlRetrievalTimeout: ::DWORD, MaximumCachedCertificates: ::DWORD, CycleDetectionModulus: ::DWORD, // #if (NTDDI_VERSION >= NTDDI_WIN7) hExclusiveRoot: HCERTSTORE, hExclusiveTrustedPeople: HCERTSTORE, // #if (NTDDI_VERSION >= NTDDI_WIN8) dwExclusiveFlags: ::DWORD, }} pub type PCERT_CHAIN_ENGINE_CONFIG = *mut CERT_CHAIN_ENGINE_CONFIG; // 18748 pub type HCERTCHAINENGINE = ::HANDLE; pub type PFN_CERT_CREATE_CONTEXT_SORT_FUNC = Option ::BOOL>; #[repr(C)] #[derive(Copy)] pub struct CERT_CREATE_CONTEXT_PARA { pub cbSize: ::DWORD, pub pfnFree: PFN_CRYPT_FREE, pub pvFree: *mut ::c_void, pub pfnSort: PFN_CERT_CREATE_CONTEXT_SORT_FUNC, pub pvSort: *mut ::c_void, } impl Clone for CERT_CREATE_CONTEXT_PARA { fn clone(&self) -> CERT_CREATE_CONTEXT_PARA { *self } } pub type PCERT_CREATE_CONTEXT_PARA = *mut CERT_CREATE_CONTEXT_PARA; STRUCT!{struct CERT_EXTENSIONS { cExtension: ::DWORD, rgExtension: PCERT_EXTENSION, }} pub type PCERT_EXTENSIONS = *mut CERT_EXTENSIONS; STRUCT!{struct CERT_REVOCATION_CRL_INFO { cbSize: ::DWORD, pBaseCrlContext: PCCRL_CONTEXT, pDeltaCrlContext: PCCRL_CONTEXT, pCrlEntry: PCRL_ENTRY, fDeltaCrlEntry: ::BOOL, }} pub type PCERT_REVOCATION_CRL_INFO = *mut CERT_REVOCATION_CRL_INFO; STRUCT!{struct CERT_TRUST_STATUS { dwErrorStatus: ::DWORD, dwInfoStatus: ::DWORD, }} pub type PCERT_TRUST_STATUS = *mut CERT_TRUST_STATUS; STRUCT!{struct CERT_REVOCATION_INFO { cbSize: ::DWORD, dwRevocationResult: ::DWORD, pszRevocationOid: ::LPCSTR, pvOidSpecificInfo: ::LPVOID, fHasFreshnessTime: ::BOOL, dwFreshnessTime: ::DWORD, pCrlInfo: PCERT_REVOCATION_CRL_INFO, }} pub type PCERT_REVOCATION_INFO = *mut CERT_REVOCATION_INFO; STRUCT!{struct CERT_TRUST_LIST_INFO { cbSize: ::DWORD, pCtlEntry: PCTL_ENTRY, pCtlContext: PCCTL_CONTEXT, }} pub type PCERT_TRUST_LIST_INFO = *mut CERT_TRUST_LIST_INFO; STRUCT!{struct CERT_CHAIN_ELEMENT { cbSize: ::DWORD, pCertContext: PCCERT_CONTEXT, TrustStatus: CERT_TRUST_STATUS, pRevocationInfo: PCERT_REVOCATION_INFO, pIssuanceUsage: PCERT_ENHKEY_USAGE, pApplicationUsage: PCERT_ENHKEY_USAGE, pwszExtendedErrorInfo: ::LPWSTR, }} pub type PCERT_CHAIN_ELEMENT = *mut CERT_CHAIN_ELEMENT; pub type PCCERT_CHAIN_ELEMENT = *const CERT_CHAIN_ELEMENT; STRUCT!{struct CERT_SIMPLE_CHAIN { cbSize: ::DWORD, TrustStatus: CERT_TRUST_STATUS, cElement: ::DWORD, rgpElement: *mut PCERT_CHAIN_ELEMENT, pTrustListInfo: PCERT_TRUST_LIST_INFO, fHasRevocationFreshnessTime: ::BOOL, dwRevocationFreshnessTime: ::DWORD, }} pub type PCERT_SIMPLE_CHAIN = *mut CERT_SIMPLE_CHAIN; pub type PCCERT_SIMPLE_CHAIN = *const CERT_SIMPLE_CHAIN; STRUCT!{struct CERT_CHAIN_CONTEXT { cbSize: ::DWORD, TrustStatus: CERT_TRUST_STATUS, cChain: ::DWORD, rgpChain: *mut PCERT_SIMPLE_CHAIN, cLowerQualityChainContext: ::DWORD, rgpLowerQualityChainContext: *mut PCCERT_CHAIN_CONTEXT, fHasRevocationFreshnessTime: ::BOOL, dwRevocationFreshnessTime: ::DWORD, dwCreateFlags: ::DWORD, ChainId: ::GUID, }} pub type PCERT_CHAIN_CONTEXT = *mut CERT_CHAIN_CONTEXT; pub type PCCERT_CHAIN_CONTEXT = *const CERT_CHAIN_CONTEXT; STRUCT!{struct CERT_PHYSICAL_STORE_INFO { cbSize: ::DWORD, pszOpenStoreProvider: ::LPSTR, dwOpenEncodingType: ::DWORD, dwOpenFlags: ::DWORD, OpenParameters: CRYPT_DATA_BLOB, dwFlags: ::DWORD, dwPriority: ::DWORD, }} pub type PCERT_PHYSICAL_STORE_INFO = *mut CERT_PHYSICAL_STORE_INFO; STRUCT!{struct CERT_SYSTEM_STORE_INFO { cbSize: ::DWORD, }} pub type PCERT_SYSTEM_STORE_INFO = *mut CERT_SYSTEM_STORE_INFO; //13401 pub type PFN_CERT_ENUM_SYSTEM_STORE_LOCATION = Option ::BOOL>; //13408 pub type PFN_CERT_ENUM_SYSTEM_STORE = Option ::BOOL>; //13416 pub type PFN_CERT_ENUM_PHYSICAL_STORE = Option ::BOOL>; STRUCT!{struct CERT_STRONG_SIGN_SERIALIZED_INFO { dwFlags: ::DWORD, pwszCNGSignHashAlgids: ::LPWSTR, pwszCNGPubKeyMinBitLengths: ::LPWSTR, }} pub type PCERT_STRONG_SIGN_SERIALIZED_INFO = *mut CERT_STRONG_SIGN_SERIALIZED_INFO; STRUCT!{struct CERT_STRONG_SIGN_PARA { cbSize: ::DWORD, dwInfoChoice: ::DWORD, pvInfo: *mut ::c_void, }} UNION!( CERT_STRONG_SIGN_PARA, pvInfo, pSerializedInfo, pSerializedInfo_mut, PCERT_STRONG_SIGN_SERIALIZED_INFO ); UNION!(CERT_STRONG_SIGN_PARA, pvInfo, pszOID, pszOID_mut, ::LPSTR); pub type PCERT_STRONG_SIGN_PARA = *mut CERT_STRONG_SIGN_PARA; pub type PCCERT_STRONG_SIGN_PARA = *const CERT_STRONG_SIGN_PARA; STRUCT!{struct CERT_USAGE_MATCH { dwType: ::DWORD, Usage: CERT_ENHKEY_USAGE, }} pub type PCERT_USAGE_MATCH = *mut CERT_USAGE_MATCH; STRUCT!{struct CERT_CHAIN_PARA { cbSize: ::DWORD, RequestedUsage: CERT_USAGE_MATCH, RequestedIssuancePolicy: CERT_USAGE_MATCH, dwUrlRetrievalTimeout: ::DWORD, fCheckRevocationFreshnessTime: ::BOOL, dwRevocationFreshnessTime: ::DWORD, pftCacheResync: ::LPFILETIME, pStrongSignPara: PCCERT_STRONG_SIGN_PARA, dwStrongSignFlags: ::DWORD, }} pub type PCERT_CHAIN_PARA = *mut CERT_CHAIN_PARA; STRUCT!{struct CERT_SELECT_CHAIN_PARA { hChainEngine: HCERTCHAINENGINE, pTime: ::PFILETIME, hAdditionalStore: HCERTSTORE, pChainPara: PCERT_CHAIN_PARA, dwFlags: ::DWORD, }} pub type PCERT_SELECT_CHAIN_PARA = *mut CERT_SELECT_CHAIN_PARA; pub type PCCERT_SELECT_CHAIN_PARA = *const CERT_SELECT_CHAIN_PARA; STRUCT!{struct CERT_SELECT_CRITERIA { dwType: ::DWORD, cPara: ::DWORD, ppPara: *mut *mut ::c_void, }} pub type PCERT_SELECT_CRITERIA = *mut CERT_SELECT_CRITERIA; pub type PCCERT_SELECT_CRITERIA = *const CERT_SELECT_CRITERIA; STRUCT!{struct CTL_VERIFY_USAGE_PARA { cbSize: ::DWORD, ListIdentifier: CRYPT_DATA_BLOB, cCtlStore: ::DWORD, rghCtlStore: *mut HCERTSTORE, cSignerStore: ::DWORD, rghSignerStore: *mut HCERTSTORE, }} pub type PCTL_VERIFY_USAGE_PARA = *mut CTL_VERIFY_USAGE_PARA; STRUCT!{struct CTL_VERIFY_USAGE_STATUS { cbSize: ::DWORD, dwError: ::DWORD, dwFlags: ::DWORD, ppCtl: *mut PCCTL_CONTEXT, dwCtlEntryIndex: ::DWORD, ppSigner: *mut PCCERT_CONTEXT, dwSignerIndex: ::DWORD, }} pub type PCTL_VERIFY_USAGE_STATUS = *mut CTL_VERIFY_USAGE_STATUS; STRUCT!{struct CERT_CHAIN_POLICY_PARA { cbSize: ::DWORD, dwFlags: ::DWORD, pvExtraPolicyPara: *mut ::c_void, }} pub type PCERT_CHAIN_POLICY_PARA = *mut CERT_CHAIN_POLICY_PARA; STRUCT!{struct CERT_CHAIN_POLICY_STATUS { cbSize: ::DWORD, dwError: ::DWORD, lChainIndex: ::LONG, lElementIndex: ::LONG, pvExtraPolicyStatus: *mut ::c_void, }} pub type PCERT_CHAIN_POLICY_STATUS = *mut CERT_CHAIN_POLICY_STATUS; STRUCT!{struct CERT_REVOCATION_CHAIN_PARA { cbSize: ::DWORD, hChainEngine: HCERTCHAINENGINE, hAdditionalStore: HCERTSTORE, dwChainFlags: ::DWORD, dwUrlRetrievalTimeout: ::DWORD, pftCurrentTime: ::LPFILETIME, pftCacheResync: ::LPFILETIME, }} pub type PCERT_REVOCATION_CHAIN_PARA = *mut CERT_REVOCATION_CHAIN_PARA; STRUCT!{struct CERT_REVOCATION_PARA { cbSize: ::DWORD, pIssuerCert: PCCERT_CONTEXT, cCertStore: ::DWORD, rgCertStore: *mut HCERTSTORE, hCrlStore: HCERTSTORE, pftTimeToUse: ::LPFILETIME, dwUrlRetrievalTimeout: ::DWORD, fCheckFreshnessTime: ::BOOL, dwFreshnessTime: ::DWORD, pftCurrentTime: ::LPFILETIME, pCrlInfo: PCERT_REVOCATION_CRL_INFO, pftCacheResync: ::LPFILETIME, pChainPara: PCERT_REVOCATION_CHAIN_PARA, }} pub type PCERT_REVOCATION_PARA = *mut CERT_REVOCATION_PARA; STRUCT!{struct CERT_REVOCATION_STATUS { cbSize: ::DWORD, dwIndex: ::DWORD, dwError: ::DWORD, dwReason: ::DWORD, fHasFreshnessTime: ::BOOL, dwFreshnessTime: ::DWORD, }} pub type PCERT_REVOCATION_STATUS = *mut CERT_REVOCATION_STATUS; //16990 pub type HCRYPTASYNC = ::HANDLE; pub type PHCRYPTASYNC = *mut ::HANDLE; STRUCT!{struct CRYPT_ENCRYPT_MESSAGE_PARA { cbSize: ::DWORD, dwMsgEncodingType: ::DWORD, hCryptProv: HCRYPTPROV_LEGACY, ContentEncryptionAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, pvEncryptionAuxInfo: *mut ::c_void, dwFlags: ::DWORD, dwInnerContentType: ::DWORD, }} pub type PCRYPT_ENCRYPT_MESSAGE_PARA = *mut CRYPT_DECRYPT_MESSAGE_PARA; STRUCT!{struct CRYPT_DECRYPT_MESSAGE_PARA { cbSize: ::DWORD, dwMsgAndCertEncodingType: ::DWORD, cCertStore: ::DWORD, rghCertStore: *mut HCERTSTORE, dwFlags: ::DWORD, }} pub type PCRYPT_DECRYPT_MESSAGE_PARA = *mut CRYPT_DECRYPT_MESSAGE_PARA; pub type PFN_CRYPT_GET_SIGNER_CERTIFICATE = Option PCCERT_CONTEXT>; #[repr(C)] #[derive(Copy)] pub struct CRYPT_VERIFY_MESSAGE_PARA { pub cbSize: ::DWORD, pub dwMsgAndCertEncodingType: ::DWORD, pub hCryptProv: HCRYPTPROV_LEGACY, pub pfnGetSignerCertificate: PFN_CRYPT_GET_SIGNER_CERTIFICATE, pub pvGetArg: *mut ::c_void, pub pStrongSignPara: PCCERT_STRONG_SIGN_PARA, } impl Clone for CRYPT_VERIFY_MESSAGE_PARA { fn clone(&self) -> CRYPT_VERIFY_MESSAGE_PARA { *self } } pub type PCRYPT_VERIFY_MESSAGE_PARA = *mut CRYPT_VERIFY_MESSAGE_PARA; STRUCT!{struct CRYPT_OID_INFO { cbSize: ::DWORD, oszOID: ::LPCSTR, pwszName: ::LPCWSTR, dwGroupId: ::DWORD, dwValue: ::DWORD, ExtraInfo: CRYPT_DATA_BLOB, pwszCNGAlgid: ::LPCWSTR, pwszCNGExtraAlgid: ::LPCWSTR, }} UNION!(CRYPT_OID_INFO, dwValue, Algid, Algid_mut, ALG_ID); UNION!(CRYPT_OID_INFO, dwValue, dwLength, dwLength_mut, ::DWORD); pub type PCRYPT_OID_INFO = *mut CRYPT_OID_INFO; pub type PCCRYPT_OID_INFO = *const CRYPT_OID_INFO; //18004 pub type PFN_CRYPT_ENUM_KEYID_PROP = Option ::BOOL>; //6379 pub type PFN_CRYPT_ENUM_OID_FUNC = Option ::BOOL>; //6675 pub type PFN_CRYPT_ENUM_OID_INFO = Option ::BOOL>; //6022 pub type HCRYPTOIDFUNCSET = *mut ::c_void; pub type HCRYPTOIDFUNCADDR = *mut ::c_void; pub type PFN_CRYPT_ASYNC_PARAM_FREE_FUNC = Option; STRUCT!{struct CRYPT_HASH_MESSAGE_PARA { cbSize: ::DWORD, dwMsgEncodingType: ::DWORD, hCryptProv: HCRYPTPROV_LEGACY, HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, pvHashAuxInfo: *mut ::c_void, }} pub type PCRYPT_HASH_MESSAGE_PARA = *mut CRYPT_HASH_MESSAGE_PARA; //14750 pub type HCRYPTDEFAULTCONTEXT = *mut ::c_void; STRUCT!{struct CRYPT_OID_FUNC_ENTRY { pszOID: ::LPCSTR, pvFuncAddr: *mut ::c_void, }} pub type PCRYPT_OID_FUNC_ENTRY = *mut CRYPT_OID_FUNC_ENTRY; STRUCT!{struct CMSG_SIGNER_ENCODE_INFO { cbSize: ::DWORD, pCertInfo: PCERT_INFO, hCryptProv: HCRYPTPROV, dwKeySpec: ::DWORD, HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, pvHashAuxInfo: *mut ::c_void, cAuthAttr: ::DWORD, rgAuthAttr: PCRYPT_ATTRIBUTE, cUnauthAttr: ::DWORD, rgUnauthAttr: PCRYPT_ATTRIBUTE, }} UNION!(CMSG_SIGNER_ENCODE_INFO, hCryptProv, hNCryptKey, hNCryptKey_mut, ::NCRYPT_KEY_HANDLE); pub type PCMSG_SIGNER_ENCODE_INFO = *mut CMSG_SIGNER_ENCODE_INFO; STRUCT!{struct CMSG_SIGNED_ENCODE_INFO { cbSize: ::DWORD, cSigners: ::DWORD, rgSigners: PCMSG_SIGNER_ENCODE_INFO, cCertEncoded: ::DWORD, rgCertEncoded: PCERT_BLOB, cCrlEncoded: ::DWORD, rgCrlEncoded: PCRL_BLOB, }} pub type PCMSG_SIGNED_ENCODE_INFO = *mut CMSG_SIGNED_ENCODE_INFO; //7393 pub type PFN_CMSG_STREAM_OUTPUT = Option ::BOOL>; #[repr(C)] #[derive(Copy)] pub struct CMSG_STREAM_INFO { pub cbContent: ::DWORD, pub pfnStreamOutput: PFN_CMSG_STREAM_OUTPUT, pub pvArg: *mut ::c_void, } impl Clone for CMSG_STREAM_INFO { fn clone(&self) -> CMSG_STREAM_INFO { *self } } pub type PCMSG_STREAM_INFO = *mut CMSG_STREAM_INFO; STRUCT!{struct CRYPT_TIMESTAMP_ACCURACY { dwSeconds: ::DWORD, dwMillis: ::DWORD, dwMicros: ::DWORD, }} pub type PCRYPT_TIMESTAMP_ACCURACY = *mut CRYPT_TIMESTAMP_ACCURACY; STRUCT!{struct CRYPT_TIMESTAMP_INFO { dwVersion: ::DWORD, pszTSAPolicyId: ::LPSTR, HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, HashedMessage: CRYPT_DER_BLOB, SerialNumber: CRYPT_INTEGER_BLOB, ftTime: ::FILETIME, pvAccuracy: PCRYPT_TIMESTAMP_ACCURACY, fOrdering: ::BOOL, Nonce: CRYPT_DER_BLOB, Tsa: CRYPT_DER_BLOB, cExtension: ::DWORD, rgExtension: PCERT_EXTENSION, }} pub type PCRYPT_TIMESTAMP_INFO = *mut CRYPT_TIMESTAMP_INFO; STRUCT!{struct CRYPT_TIMESTAMP_CONTEXT { cbEncoded: ::DWORD, pbEncoded: *mut ::BYTE, pTimeStamp: PCRYPT_TIMESTAMP_INFO, }} pub type PCRYPT_TIMESTAMP_CONTEXT = *mut CRYPT_TIMESTAMP_CONTEXT; STRUCT!{struct CRYPT_TIMESTAMP_PARA { pszTSAPolicyId: ::LPCSTR, fRequestCerts: ::BOOL, Nonce: CRYPT_INTEGER_BLOB, cExtension: ::DWORD, rgExtension: PCERT_EXTENSION, }} pub type PCRYPT_TIMESTAMP_PARA = *mut CRYPT_TIMESTAMP_PARA; STRUCT!{struct CRYPT_SIGN_MESSAGE_PARA { cbSize: ::DWORD, dwMsgEncodingType: ::DWORD, pSigningCert: PCCERT_CONTEXT, HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, pvHashAuxInfo: *mut ::c_void, cMsgCert: ::DWORD, rgpMsgCert: *mut PCCERT_CONTEXT, cMsgCrl: ::DWORD, rgpMsgCrl: *mut PCCRL_CONTEXT, cAuthAttr: ::DWORD, rgAuthAttr: PCRYPT_ATTRIBUTE, cUnauthAttr: ::DWORD, rgUnauthAttr: PCRYPT_ATTRIBUTE, dwFlags: ::DWORD, dwInnerContentType: ::DWORD, }} pub type PCRYPT_SIGN_MESSAGE_PARA = *mut CRYPT_SIGN_MESSAGE_PARA; STRUCT!{struct CRYPT_KEY_SIGN_MESSAGE_PARA { cbSize: ::DWORD, dwMsgAndCertEncodingType: ::DWORD, hCryptProv: HCRYPTPROV, dwKeySpec: ::DWORD, HashAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, pvHashAuxInfo: *mut ::c_void, PubKeyAlgorithm: CRYPT_ALGORITHM_IDENTIFIER, }} UNION!(CRYPT_KEY_SIGN_MESSAGE_PARA, hCryptProv, hNCryptKey, hNCryptKey_mut, ::NCRYPT_KEY_HANDLE); pub type PCRYPT_KEY_SIGN_MESSAGE_PARA = *mut CRYPT_KEY_SIGN_MESSAGE_PARA; STRUCT!{struct CRYPT_KEY_VERIFY_MESSAGE_PARA { cbSize: ::DWORD, dwMsgEncodingType: ::DWORD, hCryptProv: HCRYPTPROV_LEGACY, }} pub type PCRYPT_KEY_VERIFY_MESSAGE_PARA = *mut CRYPT_KEY_VERIFY_MESSAGE_PARA; deps/winapi-0.2.5/src/winnetwk.rs0000644000000000000000000003003212613167613015445 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Standard WINNET Header File for WIN32 pub const WNNC_NET_MSNET: ::DWORD = 0x00010000; pub const WNNC_NET_SMB: ::DWORD = 0x00020000; pub const WNNC_NET_NETWARE: ::DWORD = 0x00030000; pub const WNNC_NET_VINES: ::DWORD = 0x00040000; pub const WNNC_NET_10NET: ::DWORD = 0x00050000; pub const WNNC_NET_LOCUS: ::DWORD = 0x00060000; pub const WNNC_NET_SUN_PC_NFS: ::DWORD = 0x00070000; pub const WNNC_NET_LANSTEP: ::DWORD = 0x00080000; pub const WNNC_NET_9TILES: ::DWORD = 0x00090000; pub const WNNC_NET_LANTASTIC: ::DWORD = 0x000A0000; pub const WNNC_NET_AS400: ::DWORD = 0x000B0000; pub const WNNC_NET_FTP_NFS: ::DWORD = 0x000C0000; pub const WNNC_NET_PATHWORKS: ::DWORD = 0x000D0000; pub const WNNC_NET_LIFENET: ::DWORD = 0x000E0000; pub const WNNC_NET_POWERLAN: ::DWORD = 0x000F0000; pub const WNNC_NET_BWNFS: ::DWORD = 0x00100000; pub const WNNC_NET_COGENT: ::DWORD = 0x00110000; pub const WNNC_NET_FARALLON: ::DWORD = 0x00120000; pub const WNNC_NET_APPLETALK: ::DWORD = 0x00130000; pub const WNNC_NET_INTERGRAPH: ::DWORD = 0x00140000; pub const WNNC_NET_SYMFONET: ::DWORD = 0x00150000; pub const WNNC_NET_CLEARCASE: ::DWORD = 0x00160000; pub const WNNC_NET_FRONTIER: ::DWORD = 0x00170000; pub const WNNC_NET_BMC: ::DWORD = 0x00180000; pub const WNNC_NET_DCE: ::DWORD = 0x00190000; pub const WNNC_NET_AVID: ::DWORD = 0x001A0000; pub const WNNC_NET_DOCUSPACE: ::DWORD = 0x001B0000; pub const WNNC_NET_MANGOSOFT: ::DWORD = 0x001C0000; pub const WNNC_NET_SERNET: ::DWORD = 0x001D0000; pub const WNNC_NET_RIVERFRONT1: ::DWORD = 0x001E0000; pub const WNNC_NET_RIVERFRONT2: ::DWORD = 0x001F0000; pub const WNNC_NET_DECORB: ::DWORD = 0x00200000; pub const WNNC_NET_PROTSTOR: ::DWORD = 0x00210000; pub const WNNC_NET_FJ_REDIR: ::DWORD = 0x00220000; pub const WNNC_NET_DISTINCT: ::DWORD = 0x00230000; pub const WNNC_NET_TWINS: ::DWORD = 0x00240000; pub const WNNC_NET_RDR2SAMPLE: ::DWORD = 0x00250000; pub const WNNC_NET_CSC: ::DWORD = 0x00260000; pub const WNNC_NET_3IN1: ::DWORD = 0x00270000; pub const WNNC_NET_EXTENDNET: ::DWORD = 0x00290000; pub const WNNC_NET_STAC: ::DWORD = 0x002A0000; pub const WNNC_NET_FOXBAT: ::DWORD = 0x002B0000; pub const WNNC_NET_YAHOO: ::DWORD = 0x002C0000; pub const WNNC_NET_EXIFS: ::DWORD = 0x002D0000; pub const WNNC_NET_DAV: ::DWORD = 0x002E0000; pub const WNNC_NET_KNOWARE: ::DWORD = 0x002F0000; pub const WNNC_NET_OBJECT_DIRE: ::DWORD = 0x00300000; pub const WNNC_NET_MASFAX: ::DWORD = 0x00310000; pub const WNNC_NET_HOB_NFS: ::DWORD = 0x00320000; pub const WNNC_NET_SHIVA: ::DWORD = 0x00330000; pub const WNNC_NET_IBMAL: ::DWORD = 0x00340000; pub const WNNC_NET_LOCK: ::DWORD = 0x00350000; pub const WNNC_NET_TERMSRV: ::DWORD = 0x00360000; pub const WNNC_NET_SRT: ::DWORD = 0x00370000; pub const WNNC_NET_QUINCY: ::DWORD = 0x00380000; pub const WNNC_NET_OPENAFS: ::DWORD = 0x00390000; pub const WNNC_NET_AVID1: ::DWORD = 0x003A0000; pub const WNNC_NET_DFS: ::DWORD = 0x003B0000; pub const WNNC_NET_KWNP: ::DWORD = 0x003C0000; pub const WNNC_NET_ZENWORKS: ::DWORD = 0x003D0000; pub const WNNC_NET_DRIVEONWEB: ::DWORD = 0x003E0000; pub const WNNC_NET_VMWARE: ::DWORD = 0x003F0000; pub const WNNC_NET_RSFX: ::DWORD = 0x00400000; pub const WNNC_NET_MFILES: ::DWORD = 0x00410000; pub const WNNC_NET_MS_NFS: ::DWORD = 0x00420000; pub const WNNC_NET_GOOGLE: ::DWORD = 0x00430000; pub const WNNC_NET_NDFS: ::DWORD = 0x00440000; pub const WNNC_NET_DOCUSHARE: ::DWORD = 0x00450000; pub const WNNC_CRED_MANAGER: ::DWORD = 0xFFFF0000; pub const WNNC_NET_LANMAN: ::DWORD = WNNC_NET_SMB; pub const RESOURCE_CONNECTED: ::DWORD = 0x00000001; pub const RESOURCE_GLOBALNET: ::DWORD = 0x00000002; pub const RESOURCE_REMEMBERED: ::DWORD = 0x00000003; pub const RESOURCE_RECENT: ::DWORD = 0x00000004; pub const RESOURCE_CONTEXT: ::DWORD = 0x00000005; pub const RESOURCETYPE_ANY: ::DWORD = 0x00000000; pub const RESOURCETYPE_DISK: ::DWORD = 0x00000001; pub const RESOURCETYPE_PRINT: ::DWORD = 0x00000002; pub const RESOURCETYPE_RESERVED: ::DWORD = 0x00000008; pub const RESOURCETYPE_UNKNOWN: ::DWORD = 0xFFFFFFFF; pub const RESOURCEUSAGE_CONNECTABLE: ::DWORD = 0x00000001; pub const RESOURCEUSAGE_CONTAINER: ::DWORD = 0x00000002; pub const RESOURCEUSAGE_NOLOCALDEVICE: ::DWORD = 0x00000004; pub const RESOURCEUSAGE_SIBLING: ::DWORD = 0x00000008; pub const RESOURCEUSAGE_ATTACHED: ::DWORD = 0x00000010; pub const RESOURCEUSAGE_ALL: ::DWORD = RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED; pub const RESOURCEUSAGE_RESERVED: ::DWORD = 0x80000000; pub const RESOURCEDISPLAYTYPE_GENERIC: ::DWORD = 0x00000000; pub const RESOURCEDISPLAYTYPE_DOMAIN: ::DWORD = 0x00000001; pub const RESOURCEDISPLAYTYPE_SERVER: ::DWORD = 0x00000002; pub const RESOURCEDISPLAYTYPE_SHARE: ::DWORD = 0x00000003; pub const RESOURCEDISPLAYTYPE_FILE: ::DWORD = 0x00000004; pub const RESOURCEDISPLAYTYPE_GROUP: ::DWORD = 0x00000005; pub const RESOURCEDISPLAYTYPE_NETWORK: ::DWORD = 0x00000006; pub const RESOURCEDISPLAYTYPE_ROOT: ::DWORD = 0x00000007; pub const RESOURCEDISPLAYTYPE_SHAREADMIN: ::DWORD = 0x00000008; pub const RESOURCEDISPLAYTYPE_DIRECTORY: ::DWORD = 0x00000009; pub const RESOURCEDISPLAYTYPE_TREE: ::DWORD = 0x0000000A; pub const RESOURCEDISPLAYTYPE_NDSCONTAINER: ::DWORD = 0x0000000B; STRUCT!{struct NETRESOURCEA { dwScope: ::DWORD, dwType: ::DWORD, dwDisplayType: ::DWORD, dwUsage: ::DWORD, lpLocalName: ::LPSTR, lpRemoteName: ::LPSTR, lpComment: ::LPSTR, lpProvider: ::LPSTR, }} pub type LPNETRESOURCEA = *mut NETRESOURCEA; STRUCT!{struct NETRESOURCEW { dwScope: ::DWORD, dwType: ::DWORD, dwDisplayType: ::DWORD, dwUsage: ::DWORD, lpLocalName: ::LPWSTR, lpRemoteName: ::LPWSTR, lpComment: ::LPWSTR, lpProvider: ::LPWSTR, }} pub type LPNETRESOURCEW = *mut NETRESOURCEW; pub const NETPROPERTY_PERSISTENT: ::DWORD = 1; pub const CONNECT_UPDATE_PROFILE: ::DWORD = 0x00000001; pub const CONNECT_UPDATE_RECENT: ::DWORD = 0x00000002; pub const CONNECT_TEMPORARY: ::DWORD = 0x00000004; pub const CONNECT_INTERACTIVE: ::DWORD = 0x00000008; pub const CONNECT_PROMPT: ::DWORD = 0x00000010; pub const CONNECT_NEED_DRIVE: ::DWORD = 0x00000020; pub const CONNECT_REFCOUNT: ::DWORD = 0x00000040; pub const CONNECT_REDIRECT: ::DWORD = 0x00000080; pub const CONNECT_LOCALDRIVE: ::DWORD = 0x00000100; pub const CONNECT_CURRENT_MEDIA: ::DWORD = 0x00000200; pub const CONNECT_DEFERRED: ::DWORD = 0x00000400; pub const CONNECT_RESERVED: ::DWORD = 0xFF000000; pub const CONNECT_COMMANDLINE: ::DWORD = 0x00000800; pub const CONNECT_CMD_SAVECRED: ::DWORD = 0x00001000; pub const CONNECT_CRED_RESET: ::DWORD = 0x00002000; STRUCT!{struct CONNECTDLGSTRUCTA { cbStructure: ::DWORD, hwndOwner: ::HWND, lpConnRes: ::LPNETRESOURCEA, dwFlags: ::DWORD, dwDevNum: ::DWORD, }} pub type LPCONNECTDLGSTRUCTA = *mut CONNECTDLGSTRUCTA; STRUCT!{struct CONNECTDLGSTRUCTW { cbStructure: ::DWORD, hwndOwner: ::HWND, lpConnRes: ::LPNETRESOURCEW, dwFlags: ::DWORD, dwDevNum: ::DWORD, }} pub type LPCONNECTDLGSTRUCTW = *mut CONNECTDLGSTRUCTW; pub const CONNDLG_RO_PATH: ::DWORD = 0x00000001; pub const CONNDLG_CONN_POINT: ::DWORD = 0x00000002; pub const CONNDLG_USE_MRU: ::DWORD = 0x00000004; pub const CONNDLG_HIDE_BOX: ::DWORD = 0x00000008; pub const CONNDLG_PERSIST: ::DWORD = 0x00000010; pub const CONNDLG_NOT_PERSIST: ::DWORD = 0x00000020; STRUCT!{struct DISCDLGSTRUCTA { cbStructure: ::DWORD, hwndOwner: ::HWND, lpLocalName: ::LPSTR, lpRemoteName: ::LPSTR, dwFlags: ::DWORD, }} pub type LPDISCDLGSTRUCTA = *mut DISCDLGSTRUCTA; STRUCT!{struct DISCDLGSTRUCTW { cbStructure: ::DWORD, hwndOwner: ::HWND, lpLocalName: ::LPWSTR, lpRemoteName: ::LPWSTR, dwFlags: ::DWORD, }} pub type LPDISCDLGSTRUCTW = *mut DISCDLGSTRUCTW; pub const DISC_UPDATE_PROFILE: ::DWORD = 0x00000001; pub const DISC_NO_FORCE: ::DWORD = 0x00000040; pub const UNIVERSAL_NAME_INFO_LEVEL: ::DWORD = 0x00000001; pub const REMOTE_NAME_INFO_LEVEL: ::DWORD = 0x00000002; STRUCT!{struct UNIVERSAL_NAME_INFOA { lpUniversalName: ::LPSTR, }} pub type LPUNIVERSAL_NAME_INFOA = *mut UNIVERSAL_NAME_INFOA; STRUCT!{struct UNIVERSAL_NAME_INFOW { lpUniversalName: ::LPWSTR, }} pub type LPUNIVERSAL_NAME_INFOW = *mut UNIVERSAL_NAME_INFOW; STRUCT!{struct REMOTE_NAME_INFOA { lpUniversalName: ::LPSTR, lpConnectionName: ::LPSTR, lpRemainingPath: ::LPSTR, }} pub type LPREMOTE_NAME_INFOA = *mut REMOTE_NAME_INFOA; STRUCT!{struct REMOTE_NAME_INFOW { lpUniversalName: ::LPWSTR, lpConnectionName: ::LPWSTR, lpRemainingPath: ::LPWSTR, }} pub type LPREMOTE_NAME_INFOW = *mut REMOTE_NAME_INFOW; pub const WNFMT_MULTILINE: ::DWORD = 0x01; pub const WNFMT_ABBREVIATED: ::DWORD = 0x02; pub const WNFMT_INENUM: ::DWORD = 0x10; pub const WNFMT_CONNECTION: ::DWORD = 0x20; STRUCT!{struct NETINFOSTRUCT { cbStructure: ::DWORD, dwProviderVersion: ::DWORD, dwStatus: ::DWORD, dwCharacteristics: ::DWORD, dwHandle: ::ULONG_PTR, wNetType: ::WORD, dwPrinters: ::DWORD, dwDrives: ::DWORD, }} pub type LPNETINFOSTRUCT = *mut NETINFOSTRUCT; pub const NETINFO_DLL16: ::DWORD = 0x00000001; pub const NETINFO_DISKRED: ::DWORD = 0x00000004; pub const NETINFO_PRINTERRED: ::DWORD = 0x00000008; pub const WN_SUCCESS: ::DWORD = ::NO_ERROR; pub const WN_NO_ERROR: ::DWORD = ::NO_ERROR; pub const WN_NOT_SUPPORTED: ::DWORD = ::ERROR_NOT_SUPPORTED; pub const WN_CANCEL: ::DWORD = ::ERROR_CANCELLED; pub const WN_RETRY: ::DWORD = ::ERROR_RETRY; pub const WN_NET_ERROR: ::DWORD = ::ERROR_UNEXP_NET_ERR; pub const WN_MORE_DATA: ::DWORD = ::ERROR_MORE_DATA; pub const WN_BAD_POINTER: ::DWORD = ::ERROR_INVALID_ADDRESS; pub const WN_BAD_VALUE: ::DWORD = ::ERROR_INVALID_PARAMETER; pub const WN_BAD_USER: ::DWORD = ::ERROR_BAD_USERNAME; pub const WN_BAD_PASSWORD: ::DWORD = ::ERROR_INVALID_PASSWORD; pub const WN_ACCESS_DENIED: ::DWORD = ::ERROR_ACCESS_DENIED; pub const WN_FUNCTION_BUSY: ::DWORD = ::ERROR_BUSY; pub const WN_WINDOWS_ERROR: ::DWORD = ::ERROR_UNEXP_NET_ERR; pub const WN_OUT_OF_MEMORY: ::DWORD = ::ERROR_NOT_ENOUGH_MEMORY; pub const WN_NO_NETWORK: ::DWORD = ::ERROR_NO_NETWORK; pub const WN_EXTENDED_ERROR: ::DWORD = ::ERROR_EXTENDED_ERROR; pub const WN_BAD_LEVEL: ::DWORD = ::ERROR_INVALID_LEVEL; pub const WN_BAD_HANDLE: ::DWORD = ::ERROR_INVALID_HANDLE; pub const WN_NOT_INITIALIZING: ::DWORD = ::ERROR_ALREADY_INITIALIZED; pub const WN_NO_MORE_DEVICES: ::DWORD = ::ERROR_NO_MORE_DEVICES; pub const WN_NOT_CONNECTED: ::DWORD = ::ERROR_NOT_CONNECTED; pub const WN_OPEN_FILES: ::DWORD = ::ERROR_OPEN_FILES; pub const WN_DEVICE_IN_USE: ::DWORD = ::ERROR_DEVICE_IN_USE; pub const WN_BAD_NETNAME: ::DWORD = ::ERROR_BAD_NET_NAME; pub const WN_BAD_LOCALNAME: ::DWORD = ::ERROR_BAD_DEVICE; pub const WN_ALREADY_CONNECTED: ::DWORD = ::ERROR_ALREADY_ASSIGNED; pub const WN_DEVICE_ERROR: ::DWORD = ::ERROR_GEN_FAILURE; pub const WN_CONNECTION_CLOSED: ::DWORD = ::ERROR_CONNECTION_UNAVAIL; pub const WN_NO_NET_OR_BAD_PATH: ::DWORD = ::ERROR_NO_NET_OR_BAD_PATH; pub const WN_BAD_PROVIDER: ::DWORD = ::ERROR_BAD_PROVIDER; pub const WN_CANNOT_OPEN_PROFILE: ::DWORD = ::ERROR_CANNOT_OPEN_PROFILE; pub const WN_BAD_PROFILE: ::DWORD = ::ERROR_BAD_PROFILE; pub const WN_BAD_DEV_TYPE: ::DWORD = ::ERROR_BAD_DEV_TYPE; pub const WN_DEVICE_ALREADY_REMEMBERED: ::DWORD = ::ERROR_DEVICE_ALREADY_REMEMBERED; pub const WN_CONNECTED_OTHER_PASSWORD: ::DWORD = ::ERROR_CONNECTED_OTHER_PASSWORD; pub const WN_CONNECTED_OTHER_PASSWORD_DEFAULT: ::DWORD = ::ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT; pub const WN_NO_MORE_ENTRIES: ::DWORD = ::ERROR_NO_MORE_ITEMS; pub const WN_NOT_CONTAINER: ::DWORD = ::ERROR_NOT_CONTAINER; pub const WN_NOT_AUTHENTICATED: ::DWORD = ::ERROR_NOT_AUTHENTICATED; pub const WN_NOT_LOGGED_ON: ::DWORD = ::ERROR_NOT_LOGGED_ON; pub const WN_NOT_VALIDATED: ::DWORD = ::ERROR_NO_LOGON_SERVERS; STRUCT!{struct NETCONNECTINFOSTRUCT { cbStructure: ::DWORD, dwFlags: ::DWORD, dwSpeed: ::DWORD, dwDelay: ::DWORD, dwOptDataSize: ::DWORD, }} pub type LPNETCONNECTINFOSTRUCT = *mut NETCONNECTINFOSTRUCT; pub const WNCON_FORNETCARD: ::DWORD = 0x00000001; pub const WNCON_NOTROUTED: ::DWORD = 0x00000002; pub const WNCON_SLOWLINK: ::DWORD = 0x00000004; pub const WNCON_DYNAMIC: ::DWORD = 0x00000008; deps/winapi-0.2.5/src/lmdfs.rs0000644000000000000000000002414512613167613014714 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License // This file contains structures, function prototypes, and definitions for the NetDfs API pub const DFS_VOLUME_STATES: ::DWORD = 0xF; pub const DFS_VOLUME_STATE_OK: ::DWORD = 1; pub const DFS_VOLUME_STATE_INCONSISTENT: ::DWORD = 2; pub const DFS_VOLUME_STATE_OFFLINE: ::DWORD = 3; pub const DFS_VOLUME_STATE_ONLINE: ::DWORD = 4; pub const DFS_VOLUME_STATE_RESYNCHRONIZE: ::DWORD = 0x10; pub const DFS_VOLUME_STATE_STANDBY: ::DWORD = 0x20; pub const DFS_VOLUME_STATE_FORCE_SYNC: ::DWORD = 0x40; pub const DFS_VOLUME_FLAVORS: ::DWORD = 0x0300; pub const DFS_VOLUME_FLAVOR_UNUSED1: ::DWORD = 0x0000; pub const DFS_VOLUME_FLAVOR_STANDALONE: ::DWORD = 0x0100; pub const DFS_VOLUME_FLAVOR_AD_BLOB: ::DWORD = 0x0200; pub const DFS_STORAGE_FLAVOR_UNUSED2: ::DWORD = 0x0300; pub const DFS_STORAGE_STATES: ::ULONG = 0xF; pub const DFS_STORAGE_STATE_OFFLINE: ::ULONG = 1; pub const DFS_STORAGE_STATE_ONLINE: ::ULONG = 2; pub const DFS_STORAGE_STATE_ACTIVE: ::ULONG = 4; ENUM!{enum DFS_TARGET_PRIORITY_CLASS { DfsInvalidPriorityClass = -1i32 as u32, DfsSiteCostNormalPriorityClass = 0, DfsGlobalHighPriorityClass, DfsSiteCostHighPriorityClass, DfsSiteCostLowPriorityClass, DfsGlobalLowPriorityClass, }} STRUCT!{struct DFS_TARGET_PRIORITY { TargetPriorityClass: DFS_TARGET_PRIORITY_CLASS, TargetPriorityRank: ::USHORT, Reserved: ::USHORT, }} pub type PDFS_TARGET_PRIORITY = *mut DFS_TARGET_PRIORITY; STRUCT!{struct DFS_INFO_1 { EntryPath: ::LPWSTR, }} pub type PDFS_INFO_1 = *mut DFS_INFO_1; pub type LPDFS_INFO_1 = *mut DFS_INFO_1; #[cfg(target_arch="x86_64")] STRUCT!{struct DFS_INFO_1_32 { EntryPath: ::ULONG, }} #[cfg(target_arch="x86_64")] pub type PDFS_INFO_1_32 = *mut DFS_INFO_1_32; #[cfg(target_arch="x86_64")] pub type LPDFS_INFO_1_32 = *mut DFS_INFO_1_32; STRUCT!{struct DFS_INFO_2 { EntryPath: ::LPWSTR, Comment: ::LPWSTR, State: ::DWORD, NumberOfStorages: ::DWORD, }} pub type PDFS_INFO_2 = *mut DFS_INFO_2; pub type LPDFS_INFO_2 = *mut DFS_INFO_2; #[cfg(target_arch="x86_64")] STRUCT!{struct DFS_INFO_2_32 { EntryPath: ::ULONG, Comment: ::ULONG, State: ::DWORD, NumberOfStorages: ::DWORD, }} #[cfg(target_arch="x86_64")] pub type PDFS_INFO_2_32 = *mut DFS_INFO_2_32; #[cfg(target_arch="x86_64")] pub type LPDFS_INFO_2_32 = *mut DFS_INFO_2_32; STRUCT!{struct DFS_STORAGE_INFO { State: ::ULONG, ServerName: ::LPWSTR, ShareName: ::LPWSTR, }} pub type PDFS_STORAGE_INFO = *mut DFS_STORAGE_INFO; pub type LPDFS_STORAGE_INFO = *mut DFS_STORAGE_INFO; #[cfg(target_arch="x86_64")] STRUCT!{struct DFS_STORAGE_INFO_0_32 { State: ::ULONG, ServerName: ::ULONG, ShareName: ::ULONG, }} #[cfg(target_arch="x86_64")] pub type PDFS_STORAGE_INFO_0_32 = *mut DFS_STORAGE_INFO_0_32; #[cfg(target_arch="x86_64")] pub type LPDFS_STORAGE_INFO_0_32 = *mut DFS_STORAGE_INFO_0_32; STRUCT!{struct DFS_STORAGE_INFO_1 { State: ::ULONG, ServerName: ::LPWSTR, ShareName: ::LPWSTR, TargetPriority: DFS_TARGET_PRIORITY, }} pub type PDFS_STORAGE_INFO_1 = *mut DFS_STORAGE_INFO_1; pub type LPDFS_STORAGE_INFO_1 = *mut DFS_STORAGE_INFO_1; STRUCT!{struct DFS_INFO_3 { EntryPath: ::LPWSTR, Comment: ::LPWSTR, State: ::DWORD, NumberOfStorages: ::DWORD, Storage: LPDFS_STORAGE_INFO, }} pub type PDFS_INFO_3 = *mut DFS_INFO_3; pub type LPDFS_INFO_3 = *mut DFS_INFO_3; #[cfg(target_arch="x86_64")] STRUCT!{struct DFS_INFO_3_32 { EntryPath: ::ULONG, Comment: ::ULONG, State: ::DWORD, NumberOfStorages: ::DWORD, Storage: ::ULONG, }} #[cfg(target_arch="x86_64")] pub type PDFS_INFO_3_32 = *mut DFS_INFO_3_32; #[cfg(target_arch="x86_64")] pub type LPDFS_INFO_3_32 = *mut DFS_INFO_3_32; STRUCT!{struct DFS_INFO_4 { EntryPath: ::LPWSTR, Comment: ::LPWSTR, State: ::DWORD, Timeout: ::ULONG, Guid: ::GUID, NumberOfStorages: ::DWORD, Storage: LPDFS_STORAGE_INFO, }} pub type PDFS_INFO_4 = *mut DFS_INFO_4; pub type LPDFS_INFO_4 = *mut DFS_INFO_4; #[cfg(target_arch="x86_64")] STRUCT!{struct DFS_INFO_4_32 { EntryPath: ::ULONG, Comment: ::ULONG, State: ::DWORD, Timeout: ::ULONG, Guid: ::GUID, NumberOfStorages: ::DWORD, Storage: ::ULONG, }} #[cfg(target_arch="x86_64")] pub type PDFS_INFO_4_32 = *mut DFS_INFO_4_32; #[cfg(target_arch="x86_64")] pub type LPDFS_INFO_4_32 = *mut DFS_INFO_4_32; STRUCT!{struct DFS_INFO_5 { EntryPath: ::LPWSTR, Comment: ::LPWSTR, State: ::DWORD, Timeout: ::ULONG, Guid: ::GUID, PropertyFlags: ::ULONG, MetadataSize: ::ULONG, NumberOfStorages: ::DWORD, }} pub type PDFS_INFO_5 = *mut DFS_INFO_5; pub type LPDFS_INFO_5 = *mut DFS_INFO_5; STRUCT!{struct DFS_INFO_6 { EntryPath: ::LPWSTR, Comment: ::LPWSTR, State: ::DWORD, Timeout: ::ULONG, Guid: ::GUID, PropertyFlags: ::ULONG, MetadataSize: ::ULONG, NumberOfStorages: ::DWORD, Storage: LPDFS_STORAGE_INFO, }} pub type PDFS_INFO_6 = *mut DFS_INFO_6; pub type LPDFS_INFO_6 = *mut DFS_INFO_6; STRUCT!{struct DFS_INFO_7 { GenerationGuid: ::GUID, }} pub type PDFS_INFO_7 = *mut DFS_INFO_7; pub type LPDFS_INFO_7 = *mut DFS_INFO_7; STRUCT!{struct DFS_INFO_8 { EntryPath: ::LPWSTR, Comment: ::LPWSTR, State: ::DWORD, Timeout: ::ULONG, Guid: ::GUID, PropertyFlags: ::ULONG, MetadataSize: ::ULONG, SdLengthReserved: ::ULONG, pSecurityDescriptor: ::PSECURITY_DESCRIPTOR, NumberOfStorages: ::DWORD, }} pub type PDFS_INFO_8 = *mut DFS_INFO_8; pub type LPDFS_INFO_8 = *mut DFS_INFO_8; STRUCT!{struct DFS_INFO_9 { EntryPath: ::LPWSTR, Comment: ::LPWSTR, State: ::DWORD, Timeout: ::ULONG, Guid: ::GUID, PropertyFlags: ::ULONG, MetadataSize: ::ULONG, SdLengthReserved: ::ULONG, pSecurityDescriptor: ::PSECURITY_DESCRIPTOR, NumberOfStorages: ::DWORD, Storage: LPDFS_STORAGE_INFO, }} pub type PDFS_INFO_9 = *mut DFS_INFO_9; pub type LPDFS_INFO_9 = *mut DFS_INFO_9; pub const DFS_PROPERTY_FLAG_INSITE_REFERRALS: ::ULONG = 0x00000001; pub const DFS_PROPERTY_FLAG_ROOT_SCALABILITY: ::ULONG = 0x00000002; pub const DFS_PROPERTY_FLAG_SITE_COSTING: ::ULONG = 0x00000004; pub const DFS_PROPERTY_FLAG_TARGET_FAILBACK: ::ULONG = 0x00000008; pub const DFS_PROPERTY_FLAG_CLUSTER_ENABLED: ::ULONG = 0x00000010; pub const DFS_PROPERTY_FLAG_ABDE: ::ULONG = 0x00000020; pub const DFS_VALID_PROPERTY_FLAGS: ::ULONG = DFS_PROPERTY_FLAG_INSITE_REFERRALS | DFS_PROPERTY_FLAG_ROOT_SCALABILITY | DFS_PROPERTY_FLAG_SITE_COSTING | DFS_PROPERTY_FLAG_TARGET_FAILBACK | DFS_PROPERTY_FLAG_CLUSTER_ENABLED | DFS_PROPERTY_FLAG_ABDE; STRUCT!{struct DFS_INFO_50 { NamespaceMajorVersion: ::ULONG, NamespaceMinorVersion: ::ULONG, NamespaceCapabilities: ::ULONGLONG, }} pub type PDFS_INFO_50 = *mut DFS_INFO_50; pub type LPDFS_INFO_50 = *mut DFS_INFO_50; STRUCT!{struct DFS_INFO_100 { Comment: ::LPWSTR, }} pub type PDFS_INFO_100 = *mut DFS_INFO_100; pub type LPDFS_INFO_100 = *mut DFS_INFO_100; STRUCT!{struct DFS_INFO_101 { State: ::DWORD, }} pub type PDFS_INFO_101 = *mut DFS_INFO_101; pub type LPDFS_INFO_101 = *mut DFS_INFO_101; STRUCT!{struct DFS_INFO_102 { Timeout: ::ULONG, }} pub type PDFS_INFO_102 = *mut DFS_INFO_102; pub type LPDFS_INFO_102 = *mut DFS_INFO_102; STRUCT!{struct DFS_INFO_103 { PropertyFlagMask: ::ULONG, PropertyFlags: ::ULONG, }} pub type PDFS_INFO_103 = *mut DFS_INFO_103; pub type LPDFS_INFO_103 = *mut DFS_INFO_103; STRUCT!{struct DFS_INFO_104 { TargetPriority: DFS_TARGET_PRIORITY, }} pub type PDFS_INFO_104 = *mut DFS_INFO_104; pub type LPDFS_INFO_104 = *mut DFS_INFO_104; STRUCT!{struct DFS_INFO_105 { Comment: ::LPWSTR, State: ::DWORD, Timeout: ::ULONG, PropertyFlagMask: ::ULONG, PropertyFlags: ::ULONG, }} pub type PDFS_INFO_105 = *mut DFS_INFO_105; pub type LPDFS_INFO_105 = *mut DFS_INFO_105; STRUCT!{struct DFS_INFO_106 { State: ::DWORD, TargetPriority: DFS_TARGET_PRIORITY, }} pub type PDFS_INFO_106 = *mut DFS_INFO_106; pub type LPDFS_INFO_106 = *mut DFS_INFO_106; STRUCT!{struct DFS_INFO_107 { Comment: ::LPWSTR, State: ::DWORD, Timeout: ::ULONG, PropertyFlagMask: ::ULONG, PropertyFlags: ::ULONG, SdLengthReserved: ::ULONG, pSecurityDescriptor: ::PSECURITY_DESCRIPTOR, }} pub type PDFS_INFO_107 = *mut DFS_INFO_107; pub type LPDFS_INFO_107 = *mut DFS_INFO_107; STRUCT!{struct DFS_INFO_150 { SdLengthReserved: ::ULONG, pSecurityDescriptor: ::PSECURITY_DESCRIPTOR, }} pub type PDFS_INFO_150 = *mut DFS_INFO_150; pub type LPDFS_INFO_150 = *mut DFS_INFO_150; STRUCT!{struct DFS_INFO_200 { FtDfsName: ::LPWSTR, }} pub type PDFS_INFO_200 = *mut DFS_INFO_200; pub type LPDFS_INFO_200 = *mut DFS_INFO_200; STRUCT!{struct DFS_INFO_300 { Flags: ::DWORD, DfsName: ::LPWSTR, }} pub type PDFS_INFO_300 = *mut DFS_INFO_300; pub type LPDFS_INFO_300 = *mut DFS_INFO_300; pub const DFS_ADD_VOLUME: ::DWORD = 1; pub const DFS_RESTORE_VOLUME: ::DWORD = 2; pub const NET_DFS_SETDC_FLAGS: ::DWORD = 0x00000000; pub const NET_DFS_SETDC_TIMEOUT: ::DWORD = 0x00000001; pub const NET_DFS_SETDC_INITPKT: ::DWORD = 0x00000002; STRUCT!{struct DFS_SITENAME_INFO { SiteFlags: ::ULONG, SiteName: ::LPWSTR, }} pub type PDFS_SITENAME_INFO = *mut DFS_SITENAME_INFO; pub type LPDFS_SITENAME_INFO = *mut DFS_SITENAME_INFO; pub const DFS_SITE_PRIMARY: ::ULONG = 0x1; STRUCT!{struct DFS_SITELIST_INFO { cSites: ::ULONG, Site: [DFS_SITENAME_INFO; 1], }} pub type PDFS_SITELIST_INFO = *mut DFS_SITELIST_INFO; pub type LPDFS_SITELIST_INFO = *mut DFS_SITELIST_INFO; ENUM!{enum DFS_NAMESPACE_VERSION_ORIGIN { DFS_NAMESPACE_VERSION_ORIGIN_COMBINED = 0, DFS_NAMESPACE_VERSION_ORIGIN_SERVER, DFS_NAMESPACE_VERSION_ORIGIN_DOMAIN, }} pub type PDFS_NAMESPACE_VERSION_ORIGIN = *mut DFS_NAMESPACE_VERSION_ORIGIN; pub const DFS_NAMESPACE_CAPABILITY_ABDE: ::ULONGLONG = 0x0000000000000001; STRUCT!{struct DFS_SUPPORTED_NAMESPACE_VERSION_INFO { DomainDfsMajorVersion: ::ULONG, DomainDfsMinorVersion: ::ULONG, DomainDfsCapabilities: ::ULONGLONG, StandaloneDfsMajorVersion: ::ULONG, StandaloneDfsMinorVersion: ::ULONG, StandaloneDfsCapabilities: ::ULONGLONG, }} pub type PDFS_SUPPORTED_NAMESPACE_VERSION_INFO = *mut DFS_SUPPORTED_NAMESPACE_VERSION_INFO; deps/winapi-0.2.5/src/fileapi.rs0000644000000000000000000001120512613167613015211 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! ApiSet Contract for api-ms-win-core-file-l1 pub const CREATE_NEW: ::DWORD = 1; pub const CREATE_ALWAYS: ::DWORD = 2; pub const OPEN_EXISTING: ::DWORD = 3; pub const OPEN_ALWAYS: ::DWORD = 4; pub const TRUNCATE_EXISTING: ::DWORD = 5; pub const INVALID_FILE_SIZE: ::DWORD = 0xFFFFFFFF; pub const INVALID_SET_FILE_POINTER: ::DWORD = 0xFFFFFFFF; pub const INVALID_FILE_ATTRIBUTES: ::DWORD = 0xFFFFFFFF; STRUCT!{struct WIN32_FILE_ATTRIBUTE_DATA { dwFileAttributes: ::DWORD, ftCreationTime: ::FILETIME, ftLastAccessTime: ::FILETIME, ftLastWriteTime: ::FILETIME, nFileSizeHigh: ::DWORD, nFileSizeLow: ::DWORD, }} pub type LPWIN32_FILE_ATTRIBUTE_DATA = *mut WIN32_FILE_ATTRIBUTE_DATA; STRUCT!{struct BY_HANDLE_FILE_INFORMATION { dwFileAttributes: ::DWORD, ftCreationTime: ::FILETIME, ftLastAccessTime: ::FILETIME, ftLastWriteTime: ::FILETIME, dwVolumeSerialNumber: ::DWORD, nFileSizeHigh: ::DWORD, nFileSizeLow: ::DWORD, nNumberOfLinks: ::DWORD, nFileIndexHigh: ::DWORD, nFileIndexLow: ::DWORD, }} pub type PBY_HANDLE_FILE_INFORMATION = *mut BY_HANDLE_FILE_INFORMATION; pub type LPBY_HANDLE_FILE_INFORMATION = *mut BY_HANDLE_FILE_INFORMATION; STRUCT!{struct CREATEFILE2_EXTENDED_PARAMETERS { dwSize: ::DWORD, dwFileAttributes: ::DWORD, dwFileFlags: ::DWORD, dwSecurityQosFlags: ::DWORD, lpSecurityAttributes: ::LPSECURITY_ATTRIBUTES, hTemplateFile: ::HANDLE, }} pub type PCREATEFILE2_EXTENDED_PARAMETERS = *mut CREATEFILE2_EXTENDED_PARAMETERS; pub type LPCREATEFILE2_EXTENDED_PARAMETERS = *mut CREATEFILE2_EXTENDED_PARAMETERS; ENUM!{enum PRIORITY_HINT { IoPriorityHintVeryLow = 0, IoPriorityHintLow = 1, IoPriorityHintNormal = 2, MaximumIoPriorityHintType = 3, }} STRUCT!{struct FILE_BASIC_INFO { CreationTime: ::LARGE_INTEGER, LastAccessTime: ::LARGE_INTEGER, LastWriteTime: ::LARGE_INTEGER, ChangeTime: ::LARGE_INTEGER, FileAttributes: ::DWORD, }} STRUCT!{struct FILE_STANDARD_INFO { AllocationSize: ::LARGE_INTEGER, EndOfFile: ::LARGE_INTEGER, NumberOfLinks: ::DWORD, DeletePending: ::BOOLEAN, Directory: ::BOOLEAN, }} STRUCT!{struct FILE_NAME_INFO { FileNameLength: ::DWORD, FileName: [::WCHAR; 0], }} STRUCT!{struct FILE_RENAME_INFO { ReplaceIfExists: ::BOOL, RootDirectory: ::HANDLE, FileNameLength: ::DWORD, FileName: [::WCHAR; 0], }} STRUCT!{struct FILE_DISPOSITION_INFO { DeleteFile: ::BOOL, }} STRUCT!{struct FILE_ALLOCATION_INFO { AllocationSize: ::LARGE_INTEGER, }} STRUCT!{struct FILE_END_OF_FILE_INFO { EndOfFile: ::LARGE_INTEGER, }} STRUCT!{struct FILE_STREAM_INFO { NextEntryOffset: ::DWORD, StreamNameLength: ::DWORD, StreamSize: ::DWORD, StreamAllocationSize: ::DWORD, StreamName: [::WCHAR; 0], }} STRUCT!{struct FILE_COMPRESSION_INFO { CompressedFileSize: ::LARGE_INTEGER, CompressionFormat: ::WORD, CompressionUnitShift: ::UCHAR, ChunkShift: ::UCHAR, ClusterShift: ::UCHAR, Reserved: [::UCHAR; 3], }} STRUCT!{struct FILE_ATTRIBUTE_TAG_INFO { NextEntryOffset: ::DWORD, ReparseTag: ::DWORD, }} STRUCT!{struct FILE_ID_BOTH_DIR_INFO { NextEntryOffset: ::DWORD, FileIndex: ::DWORD, CreationTime: ::LARGE_INTEGER, LastAccessTime: ::LARGE_INTEGER, LastWriteTime: ::LARGE_INTEGER, ChangeTime: ::LARGE_INTEGER, EndOfFile: ::LARGE_INTEGER, AllocationSize: ::LARGE_INTEGER, FileAttributes: ::DWORD, FileNameLength: ::DWORD, EaSize: ::DWORD, ShortNameLength: ::CCHAR, ShortName: [::WCHAR; 12], FileId: ::LARGE_INTEGER, FileName: [::WCHAR; 0], }} STRUCT!{struct FILE_IO_PRIORITY_HINT_INFO { PriorityHint: ::PRIORITY_HINT, }} STRUCT!{struct FILE_FULL_DIR_INFO { NextEntryOffset: ::ULONG, FileIndex: ::ULONG, CreationTime: ::LARGE_INTEGER, LastAccessTime: ::LARGE_INTEGER, LastWriteTime: ::LARGE_INTEGER, ChangeTime: ::LARGE_INTEGER, EndOfFile: ::LARGE_INTEGER, AllocationSize: ::LARGE_INTEGER, FileAttributes: ::ULONG, FileNameLength: ::ULONG, EaSize: ::ULONG, FileName: [::WCHAR; 0], }} STRUCT!{struct FILE_STORAGE_INFO { LogicalBytesPerSector: ::ULONG, PhysicalBytesPerSectorForAtomicity: ::ULONG, PhysicalBytesPerSectorForPerformance: ::ULONG, FileSystemEffectivePhysicalBytesPerSectorForAtomicity: ::ULONG, Flags: ::ULONG, ByteOffsetForSectorAlignment: ::ULONG, ByteOffsetForPartitionAlignment: ::ULONG, }} STRUCT!{struct FILE_ALIGNMENT_INFO { AlignmentRequirement: ::ULONG, }} STRUCT!{struct FILE_ID_INFO { VolumeSerialNumber: ::ULONGLONG, FileId: ::FILE_ID_128, }} deps/winapi-0.2.5/src/excpt.rs0000644000000000000000000000075712615662007014734 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License ENUM!{enum EXCEPTION_DISPOSITION { ExceptionContinueExecution = 0, ExceptionContinueSearch = 1, ExceptionNestedException = 2, ExceptionCollidedUnwind = 3, }} #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct _EXCEPTION_RECORD; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct _CONTEXT; #[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct _DISPATCHER_CONTEXT; deps/winapi-0.2.5/src/hstring.rs0000644000000000000000000000110312605021253015240 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! This interface definition contains typedefs for Windows Runtime data types. DECLARE_HANDLE!(HSTRING, HSTRING__); #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct HSTRING_HEADER { pub Reserved: [::PVOID; 0], // For alignment #[cfg(target_arch = "x86_64")] pub Reserved2: [::c_char; 24], #[cfg(target_arch = "x86")] pub Reserved2: [::c_char; 20], } UNION!(HSTRING_HEADER, Reserved2, Reserved1, Reserved1_mut, ::PVOID); DECLARE_HANDLE!(HSTRING_BUFFER, HSTRING_BUFFER__); deps/winapi-0.2.5/src/ntsecapi.rs0000644000000000000000000020142312613167613015411 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! This module defines the Local Security Authority APIs. DEFINE_GUID!(Audit_System_SecurityStateChange, 0x0cce9210, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_System_SecuritySubsystemExtension, 0x0cce9211, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_System_Integrity, 0x0cce9212, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_System_IPSecDriverEvents, 0x0cce9213, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_System_Others, 0x0cce9214, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_Logon_Logon, 0x0cce9215, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_Logon_Logoff, 0x0cce9216, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_Logon_AccountLockout, 0x0cce9217, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_Logon_IPSecMainMode, 0x0cce9218, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_Logon_IPSecQuickMode, 0x0cce9219, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_Logon_IPSecUserMode, 0x0cce921a, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_Logon_SpecialLogon, 0x0cce921b, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_Logon_Others, 0x0cce921c, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_ObjectAccess_FileSystem, 0x0cce921d, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_ObjectAccess_Registry, 0x0cce921e, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_ObjectAccess_Kernel, 0x0cce921f, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_ObjectAccess_Sam, 0x0cce9220, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_ObjectAccess_CertificationServices, 0x0cce9221, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_ObjectAccess_ApplicationGenerated, 0x0cce9222, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_ObjectAccess_Handle, 0x0cce9223, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_ObjectAccess_Share, 0x0cce9224, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_ObjectAccess_FirewallPacketDrops, 0x0cce9225, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_ObjectAccess_FirewallConnection, 0x0cce9226, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_ObjectAccess_Other, 0x0cce9227, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_PrivilegeUse_Sensitive, 0x0cce9228, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_PrivilegeUse_NonSensitive, 0x0cce9229, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_PrivilegeUse_Others, 0x0cce922a, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_DetailedTracking_ProcessCreation, 0x0cce922b, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_DetailedTracking_ProcessTermination, 0x0cce922c, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_DetailedTracking_DpapiActivity, 0x0cce922d, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_DetailedTracking_RpcCall, 0x0cce922e, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_PolicyChange_AuditPolicy, 0x0cce922f, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_PolicyChange_AuthenticationPolicy, 0x0cce9230, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_PolicyChange_AuthorizationPolicy, 0x0cce9231, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_PolicyChange_MpsscvRulePolicy, 0x0cce9232, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_PolicyChange_WfpIPSecPolicy, 0x0cce9233, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_PolicyChange_Others, 0x0cce9234, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_AccountManagement_UserAccount, 0x0cce9235, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_AccountManagement_ComputerAccount, 0x0cce9236, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_AccountManagement_SecurityGroup, 0x0cce9237, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_AccountManagement_DistributionGroup, 0x0cce9238, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_AccountManagement_ApplicationGroup, 0x0cce9239, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_AccountManagement_Others, 0x0cce923a, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_DSAccess_DSAccess, 0x0cce923b, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_DsAccess_AdAuditChanges, 0x0cce923c, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_Ds_Replication, 0x0cce923d, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_Ds_DetailedReplication, 0x0cce923e, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_AccountLogon_CredentialValidation, 0x0cce923f, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_AccountLogon_Kerberos, 0x0cce9240, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_AccountLogon_Others, 0x0cce9241, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_AccountLogon_KerbCredentialValidation, 0x0cce9242, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_Logon_NPS, 0x0cce9243, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_ObjectAccess_DetailedFileShare, 0x0cce9244, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_ObjectAccess_RemovableStorage, 0x0cce9245, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_ObjectAccess_CbacStaging, 0x0cce9246, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_Logon_Claims, 0x0cce9247, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_System, 0x69979848, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_Logon, 0x69979849, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_ObjectAccess, 0x6997984a, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_PrivilegeUse, 0x6997984b, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_DetailedTracking, 0x6997984c, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_PolicyChange, 0x6997984d, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_AccountManagement, 0x6997984e, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_DirectoryServiceAccess, 0x6997984f, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); DEFINE_GUID!(Audit_AccountLogon, 0x69979850, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); ENUM!{enum POLICY_AUDIT_EVENT_TYPE { AuditCategorySystem = 0, AuditCategoryLogon, AuditCategoryObjectAccess, AuditCategoryPrivilegeUse, AuditCategoryDetailedTracking, AuditCategoryPolicyChange, AuditCategoryAccountManagement, AuditCategoryDirectoryServiceAccess, AuditCategoryAccountLogon, }} pub type PPOLICY_AUDIT_EVENT_TYPE = *mut POLICY_AUDIT_EVENT_TYPE; pub const POLICY_AUDIT_EVENT_UNCHANGED: POLICY_AUDIT_EVENT_OPTIONS = 0x00000000; pub const POLICY_AUDIT_EVENT_SUCCESS: POLICY_AUDIT_EVENT_OPTIONS = 0x00000001; pub const POLICY_AUDIT_EVENT_FAILURE: POLICY_AUDIT_EVENT_OPTIONS = 0x00000002; pub const POLICY_AUDIT_EVENT_NONE: POLICY_AUDIT_EVENT_OPTIONS = 0x00000004; pub const POLICY_AUDIT_EVENT_MASK: POLICY_AUDIT_EVENT_OPTIONS = POLICY_AUDIT_EVENT_SUCCESS | POLICY_AUDIT_EVENT_FAILURE | POLICY_AUDIT_EVENT_UNCHANGED | POLICY_AUDIT_EVENT_NONE; pub const POLICY_VIEW_LOCAL_INFORMATION: ::ACCESS_MASK = 0x00000001; pub const POLICY_VIEW_AUDIT_INFORMATION: ::ACCESS_MASK = 0x00000002; pub const POLICY_GET_PRIVATE_INFORMATION: ::ACCESS_MASK = 0x00000004; pub const POLICY_TRUST_ADMIN: ::ACCESS_MASK = 0x00000008; pub const POLICY_CREATE_ACCOUNT: ::ACCESS_MASK = 0x00000010; pub const POLICY_CREATE_SECRET: ::ACCESS_MASK = 0x00000020; pub const POLICY_CREATE_PRIVILEGE: ::ACCESS_MASK = 0x00000040; pub const POLICY_SET_DEFAULT_QUOTA_LIMITS: ::ACCESS_MASK = 0x00000080; pub const POLICY_SET_AUDIT_REQUIREMENTS: ::ACCESS_MASK = 0x00000100; pub const POLICY_AUDIT_LOG_ADMIN: ::ACCESS_MASK = 0x00000200; pub const POLICY_SERVER_ADMIN: ::ACCESS_MASK = 0x00000400; pub const POLICY_LOOKUP_NAMES: ::ACCESS_MASK = 0x00000800; pub const POLICY_NOTIFICATION: ::ACCESS_MASK = 0x00001000; pub const POLICY_ALL_ACCESS: ::ACCESS_MASK = ::STANDARD_RIGHTS_REQUIRED | POLICY_VIEW_LOCAL_INFORMATION | POLICY_VIEW_AUDIT_INFORMATION | POLICY_GET_PRIVATE_INFORMATION | POLICY_TRUST_ADMIN | POLICY_CREATE_ACCOUNT | POLICY_CREATE_SECRET | POLICY_CREATE_PRIVILEGE | POLICY_SET_DEFAULT_QUOTA_LIMITS | POLICY_SET_AUDIT_REQUIREMENTS | POLICY_AUDIT_LOG_ADMIN | POLICY_SERVER_ADMIN | POLICY_LOOKUP_NAMES; pub const POLICY_READ: ::ACCESS_MASK = ::STANDARD_RIGHTS_READ | POLICY_VIEW_AUDIT_INFORMATION | POLICY_GET_PRIVATE_INFORMATION; pub const POLICY_WRITE: ::ACCESS_MASK = ::STANDARD_RIGHTS_WRITE | POLICY_TRUST_ADMIN | POLICY_CREATE_ACCOUNT | POLICY_CREATE_SECRET | POLICY_CREATE_PRIVILEGE | POLICY_SET_DEFAULT_QUOTA_LIMITS | POLICY_SET_AUDIT_REQUIREMENTS | POLICY_AUDIT_LOG_ADMIN | POLICY_SERVER_ADMIN; pub const POLICY_EXECUTE: ::ACCESS_MASK = ::STANDARD_RIGHTS_EXECUTE | POLICY_VIEW_LOCAL_INFORMATION | POLICY_LOOKUP_NAMES; STRUCT!{struct LSA_TRANSLATED_SID { Use: ::SID_NAME_USE, RelativeId: ::ULONG, DomainIndex: ::LONG, }} pub type PLSA_TRANSLATED_SID = *mut LSA_TRANSLATED_SID; ENUM!{enum POLICY_LSA_SERVER_ROLE { PolicyServerRoleBackup = 2, PolicyServerRolePrimary, }} pub type PPOLICY_LSA_SERVER_ROLE = *mut POLICY_LSA_SERVER_ROLE; pub type POLICY_AUDIT_EVENT_OPTIONS = ::ULONG; pub type PPOLICY_AUDIT_EVENT_OPTIONS = *mut ::ULONG; ENUM!{enum POLICY_INFORMATION_CLASS { PolicyAuditLogInformation = 1, PolicyAuditEventsInformation, PolicyPrimaryDomainInformation, PolicyPdAccountInformation, PolicyAccountDomainInformation, PolicyLsaServerRoleInformation, PolicyReplicaSourceInformation, PolicyDefaultQuotaInformation, PolicyModificationInformation, PolicyAuditFullSetInformation, PolicyAuditFullQueryInformation, PolicyDnsDomainInformation, PolicyDnsDomainInformationInt, PolicyLocalAccountDomainInformation, PolicyLastEntry, }} pub type PPOLICY_INFORMATION_CLASS = *mut POLICY_INFORMATION_CLASS; STRUCT!{struct POLICY_AUDIT_LOG_INFO { AuditLogPercentFull: ::ULONG, MaximumLogSize: ::ULONG, AuditRetentionPeriod: ::LARGE_INTEGER, AuditLogFullShutdownInProgress: ::BOOLEAN, TimeToShutdown: ::LARGE_INTEGER, NextAuditRecordId: ::ULONG, }} pub type PPOLICY_AUDIT_LOG_INFO = *mut POLICY_AUDIT_LOG_INFO; STRUCT!{struct POLICY_AUDIT_EVENTS_INFO { AuditingMode: ::BOOLEAN, EventAuditingOptions: PPOLICY_AUDIT_EVENT_OPTIONS, MaximumAuditEventCount: ::ULONG, }} pub type PPOLICY_AUDIT_EVENTS_INFO = *mut POLICY_AUDIT_EVENTS_INFO; STRUCT!{struct POLICY_AUDIT_SUBCATEGORIES_INFO { MaximumSubCategoryCount: ::ULONG, EventAuditingOptions: PPOLICY_AUDIT_EVENT_OPTIONS, }} pub type PPOLICY_AUDIT_SUBCATEGORIES_INFO = *mut POLICY_AUDIT_SUBCATEGORIES_INFO; STRUCT!{struct POLICY_AUDIT_CATEGORIES_INFO { MaximumSubCategoryCount: ::ULONG, SubCategoriesInfo: PPOLICY_AUDIT_SUBCATEGORIES_INFO, }} pub type PPOLICY_AUDIT_CATEGORIES_INFO = *mut POLICY_AUDIT_CATEGORIES_INFO; pub const PER_USER_POLICY_UNCHANGED: ::ULONG = 0x00; pub const PER_USER_AUDIT_SUCCESS_INCLUDE: ::ULONG = 0x01; pub const PER_USER_AUDIT_SUCCESS_EXCLUDE: ::ULONG = 0x02; pub const PER_USER_AUDIT_FAILURE_INCLUDE: ::ULONG = 0x04; pub const PER_USER_AUDIT_FAILURE_EXCLUDE: ::ULONG = 0x08; pub const PER_USER_AUDIT_NONE: ::ULONG = 0x10; pub const VALID_PER_USER_AUDIT_POLICY_FLAG: ::ULONG = PER_USER_AUDIT_SUCCESS_INCLUDE | PER_USER_AUDIT_SUCCESS_EXCLUDE | PER_USER_AUDIT_FAILURE_INCLUDE | PER_USER_AUDIT_FAILURE_EXCLUDE | PER_USER_AUDIT_NONE; STRUCT!{struct POLICY_PRIMARY_DOMAIN_INFO { Name: ::LSA_UNICODE_STRING, Sid: ::PSID, }} pub type PPOLICY_PRIMARY_DOMAIN_INFO = *mut POLICY_PRIMARY_DOMAIN_INFO; STRUCT!{struct POLICY_PD_ACCOUNT_INFO { Name: ::LSA_UNICODE_STRING, }} pub type PPOLICY_PD_ACCOUNT_INFO = *mut POLICY_PD_ACCOUNT_INFO; STRUCT!{struct POLICY_LSA_SERVER_ROLE_INFO { LsaServerRole: POLICY_LSA_SERVER_ROLE, }} pub type PPOLICY_LSA_SERVER_ROLE_INFO = *mut POLICY_LSA_SERVER_ROLE_INFO; STRUCT!{struct POLICY_REPLICA_SOURCE_INFO { ReplicaSource: ::LSA_UNICODE_STRING, ReplicaAccountName: ::LSA_UNICODE_STRING, }} pub type PPOLICY_REPLICA_SOURCE_INFO = *mut POLICY_REPLICA_SOURCE_INFO; STRUCT!{struct POLICY_DEFAULT_QUOTA_INFO { QuotaLimits: ::QUOTA_LIMITS, }} pub type PPOLICY_DEFAULT_QUOTA_INFO = *mut POLICY_DEFAULT_QUOTA_INFO; STRUCT!{struct POLICY_MODIFICATION_INFO { ModifiedId: ::LARGE_INTEGER, DatabaseCreationTime: ::LARGE_INTEGER, }} pub type PPOLICY_MODIFICATION_INFO = *mut POLICY_MODIFICATION_INFO; STRUCT!{struct POLICY_AUDIT_FULL_SET_INFO { ShutDownOnFull: ::BOOLEAN, }} pub type PPOLICY_AUDIT_FULL_SET_INFO = *mut POLICY_AUDIT_FULL_SET_INFO; STRUCT!{struct POLICY_AUDIT_FULL_QUERY_INFO { ShutDownOnFull: ::BOOLEAN, LogIsFull: ::BOOLEAN, }} pub type PPOLICY_AUDIT_FULL_QUERY_INFO = *mut POLICY_AUDIT_FULL_QUERY_INFO; ENUM!{enum POLICY_DOMAIN_INFORMATION_CLASS { PolicyDomainEfsInformation = 2, PolicyDomainKerberosTicketInformation, }} pub type PPOLICY_DOMAIN_INFORMATION_CLASS = *mut POLICY_DOMAIN_INFORMATION_CLASS; STRUCT!{struct POLICY_DOMAIN_EFS_INFO { InfoLength: ::ULONG, EfsBlob: ::PUCHAR, }} pub type PPOLICY_DOMAIN_EFS_INFO = *mut POLICY_DOMAIN_EFS_INFO; STRUCT!{struct POLICY_DOMAIN_KERBEROS_TICKET_INFO { AuthenticationOptions: ::ULONG, MaxServiceTicketAge: ::LARGE_INTEGER, MaxTicketAge: ::LARGE_INTEGER, MaxRenewAge: ::LARGE_INTEGER, MaxClockSkew: ::LARGE_INTEGER, Reserved: ::LARGE_INTEGER, }} pub type PPOLICY_DOMAIN_KERBEROS_TICKET_INFO = *mut POLICY_DOMAIN_KERBEROS_TICKET_INFO; ENUM!{enum POLICY_NOTIFICATION_INFORMATION_CLASS { PolicyNotifyAuditEventsInformation = 1, PolicyNotifyAccountDomainInformation, PolicyNotifyServerRoleInformation, PolicyNotifyDnsDomainInformation, PolicyNotifyDomainEfsInformation, PolicyNotifyDomainKerberosTicketInformation, PolicyNotifyMachineAccountPasswordInformation, PolicyNotifyGlobalSaclInformation, PolicyNotifyMax, }} pub type PPOLICY_NOTIFICATION_INFORMATION_CLASS = *mut POLICY_NOTIFICATION_INFORMATION_CLASS; pub type LSA_HANDLE = ::PVOID; pub type PLSA_HANDLE = *mut ::PVOID; ENUM!{enum TRUSTED_INFORMATION_CLASS { TrustedDomainNameInformation = 1, TrustedControllersInformation, TrustedPosixOffsetInformation, TrustedPasswordInformation, TrustedDomainInformationBasic, TrustedDomainInformationEx, TrustedDomainAuthInformation, TrustedDomainFullInformation, TrustedDomainAuthInformationInternal, TrustedDomainFullInformationInternal, TrustedDomainInformationEx2Internal, TrustedDomainFullInformation2Internal, TrustedDomainSupportedEncryptionTypes, }} pub type PTRUSTED_INFORMATION_CLASS = *mut TRUSTED_INFORMATION_CLASS; STRUCT!{struct TRUSTED_DOMAIN_NAME_INFO { Name: ::LSA_UNICODE_STRING, }} pub type PTRUSTED_DOMAIN_NAME_INFO = *mut TRUSTED_DOMAIN_NAME_INFO; STRUCT!{struct TRUSTED_CONTROLLERS_INFO { Entries: ::ULONG, Names: ::PLSA_UNICODE_STRING, }} pub type PTRUSTED_CONTROLLERS_INFO = *mut TRUSTED_CONTROLLERS_INFO; STRUCT!{struct TRUSTED_POSIX_OFFSET_INFO { Offset: ::ULONG, }} pub type PTRUSTED_POSIX_OFFSET_INFO = *mut TRUSTED_POSIX_OFFSET_INFO; STRUCT!{struct TRUSTED_PASSWORD_INFO { Password: ::LSA_UNICODE_STRING, OldPassword: ::LSA_UNICODE_STRING, }} pub type PTRUSTED_PASSWORD_INFO = *mut TRUSTED_PASSWORD_INFO; pub type TRUSTED_DOMAIN_INFORMATION_BASIC = ::LSA_TRUST_INFORMATION; pub type PTRUSTED_DOMAIN_INFORMATION_BASIC = ::PLSA_TRUST_INFORMATION; pub const TRUST_DIRECTION_DISABLED: ::ULONG = 0x00000000; pub const TRUST_DIRECTION_INBOUND: ::ULONG = 0x00000001; pub const TRUST_DIRECTION_OUTBOUND: ::ULONG = 0x00000002; pub const TRUST_DIRECTION_BIDIRECTIONAL: ::ULONG = TRUST_DIRECTION_INBOUND | TRUST_DIRECTION_OUTBOUND; pub const TRUST_TYPE_DOWNLEVEL: ::ULONG = 0x00000001; pub const TRUST_TYPE_UPLEVEL: ::ULONG = 0x00000002; pub const TRUST_TYPE_MIT: ::ULONG = 0x00000003; pub const TRUST_ATTRIBUTE_NON_TRANSITIVE: ::ULONG = 0x00000001; pub const TRUST_ATTRIBUTE_UPLEVEL_ONLY: ::ULONG = 0x00000002; pub const TRUST_ATTRIBUTE_QUARANTINED_DOMAIN: ::ULONG = 0x00000004; pub const TRUST_ATTRIBUTE_FOREST_TRANSITIVE: ::ULONG = 0x00000008; pub const TRUST_ATTRIBUTE_CROSS_ORGANIZATION: ::ULONG = 0x00000010; pub const TRUST_ATTRIBUTE_WITHIN_FOREST: ::ULONG = 0x00000020; pub const TRUST_ATTRIBUTE_TREAT_AS_EXTERNAL: ::ULONG = 0x00000040; pub const TRUST_ATTRIBUTE_TRUST_USES_RC4_ENCRYPTION: ::ULONG = 0x00000080; pub const TRUST_ATTRIBUTE_TRUST_USES_AES_KEYS: ::ULONG = 0x00000100; pub const TRUST_ATTRIBUTE_CROSS_ORGANIZATION_NO_TGT_DELEGATION: ::ULONG = 0x00000200; pub const TRUST_ATTRIBUTES_VALID: ::ULONG = 0xFF03FFFF; pub const TRUST_ATTRIBUTES_USER: ::ULONG = 0xFF000000; STRUCT!{struct TRUSTED_DOMAIN_INFORMATION_EX { Name: ::LSA_UNICODE_STRING, FlatName: ::LSA_UNICODE_STRING, Sid: ::PSID, TrustDirection: ::ULONG, TrustType: ::ULONG, TrustAttributes: ::ULONG, }} pub type PTRUSTED_DOMAIN_INFORMATION_EX = *mut TRUSTED_DOMAIN_INFORMATION_EX; STRUCT!{struct TRUSTED_DOMAIN_INFORMATION_EX2 { Name: ::LSA_UNICODE_STRING, FlatName: ::LSA_UNICODE_STRING, Sid: ::PSID, TrustDirection: ::ULONG, TrustType: ::ULONG, TrustAttributes: ::ULONG, ForestTrustLength: ::ULONG, ForestTrustInfo: ::PUCHAR, }} pub type PTRUSTED_DOMAIN_INFORMATION_EX2 = *mut TRUSTED_DOMAIN_INFORMATION_EX2; pub const TRUST_AUTH_TYPE_NONE: ::ULONG = 0; pub const TRUST_AUTH_TYPE_NT4OWF: ::ULONG = 1; pub const TRUST_AUTH_TYPE_CLEAR: ::ULONG = 2; pub const TRUST_AUTH_TYPE_VERSION: ::ULONG = 3; STRUCT!{struct LSA_AUTH_INFORMATION { LastUpdateTime: ::LARGE_INTEGER, AuthType: ::ULONG, AuthInfoLength: ::ULONG, AuthInfo: ::PUCHAR, }} pub type PLSA_AUTH_INFORMATION = *mut LSA_AUTH_INFORMATION; STRUCT!{struct TRUSTED_DOMAIN_AUTH_INFORMATION { IncomingAuthInfos: ::ULONG, IncomingAuthenticationInformation: PLSA_AUTH_INFORMATION, IncomingPreviousAuthenticationInformation: PLSA_AUTH_INFORMATION, OutgoingAuthInfos: ::ULONG, OutgoingAuthenticationInformation: PLSA_AUTH_INFORMATION, OutgoingPreviousAuthenticationInformation: PLSA_AUTH_INFORMATION, }} pub type PTRUSTED_DOMAIN_AUTH_INFORMATION = *mut TRUSTED_DOMAIN_AUTH_INFORMATION; STRUCT!{struct TRUSTED_DOMAIN_FULL_INFORMATION { Information: TRUSTED_DOMAIN_INFORMATION_EX, PosixOffset: TRUSTED_POSIX_OFFSET_INFO, AuthInformation: TRUSTED_DOMAIN_AUTH_INFORMATION, }} pub type PTRUSTED_DOMAIN_FULL_INFORMATION = *mut TRUSTED_DOMAIN_FULL_INFORMATION; STRUCT!{struct TRUSTED_DOMAIN_FULL_INFORMATION2 { Information: TRUSTED_DOMAIN_INFORMATION_EX2, PosixOffset: TRUSTED_POSIX_OFFSET_INFO, AuthInformation: TRUSTED_DOMAIN_AUTH_INFORMATION, }} pub type PTRUSTED_DOMAIN_FULL_INFORMATION2 = *mut TRUSTED_DOMAIN_FULL_INFORMATION2; STRUCT!{struct TRUSTED_DOMAIN_SUPPORTED_ENCRYPTION_TYPES { SupportedEncryptionTypes: ::ULONG, }} pub type PTRUSTED_DOMAIN_SUPPORTED_ENCRYPTION_TYPES = *mut TRUSTED_DOMAIN_SUPPORTED_ENCRYPTION_TYPES; ENUM!{enum LSA_FOREST_TRUST_RECORD_TYPE { ForestTrustTopLevelName, ForestTrustTopLevelNameEx, ForestTrustDomainInfo, ForestTrustRecordTypeLast, // = ForestTrustDomainInfo, }} pub const LSA_FTRECORD_DISABLED_REASONS: ::ULONG = 0x0000FFFF; pub const LSA_TLN_DISABLED_NEW: ::ULONG = 0x00000001; pub const LSA_TLN_DISABLED_ADMIN: ::ULONG = 0x00000002; pub const LSA_TLN_DISABLED_CONFLICT: ::ULONG = 0x00000004; pub const LSA_SID_DISABLED_ADMIN: ::ULONG = 0x00000001; pub const LSA_SID_DISABLED_CONFLICT: ::ULONG = 0x00000002; pub const LSA_NB_DISABLED_ADMIN: ::ULONG = 0x00000004; pub const LSA_NB_DISABLED_CONFLICT: ::ULONG = 0x00000008; STRUCT!{struct LSA_FOREST_TRUST_DOMAIN_INFO { Sid: ::PSID, DnsName: ::LSA_UNICODE_STRING, NetbiosName: ::LSA_UNICODE_STRING, }} pub type PLSA_FOREST_TRUST_DOMAIN_INFO = *mut LSA_FOREST_TRUST_DOMAIN_INFO; pub const MAX_FOREST_TRUST_BINARY_DATA_SIZE: ::ULONG = 128 * 1024; STRUCT!{struct LSA_FOREST_TRUST_BINARY_DATA { Length: ::ULONG, Buffer: ::PUCHAR, }} pub type PLSA_FOREST_TRUST_BINARY_DATA = *mut LSA_FOREST_TRUST_BINARY_DATA; STRUCT!{struct LSA_FOREST_TRUST_RECORD_ForestTrustData { DomainInfo: LSA_FOREST_TRUST_DOMAIN_INFO, }} UNION!( LSA_FOREST_TRUST_RECORD_ForestTrustData, DomainInfo, TopLevelName, TopLevelName_mut, ::LSA_UNICODE_STRING ); UNION!( LSA_FOREST_TRUST_RECORD_ForestTrustData, DomainInfo, Data, Data_mut, LSA_FOREST_TRUST_BINARY_DATA ); STRUCT!{struct LSA_FOREST_TRUST_RECORD { Flags: ::ULONG, ForestTrustType: LSA_FOREST_TRUST_RECORD_TYPE, Time: ::LARGE_INTEGER, ForestTrustData: LSA_FOREST_TRUST_RECORD_ForestTrustData, }} pub type PLSA_FOREST_TRUST_RECORD = *mut LSA_FOREST_TRUST_RECORD; pub const MAX_RECORDS_IN_FOREST_TRUST_INFO: ::ULONG = 4000; STRUCT!{struct LSA_FOREST_TRUST_INFORMATION { RecordCount: ::ULONG, Entries: *mut PLSA_FOREST_TRUST_RECORD, }} pub type PLSA_FOREST_TRUST_INFORMATION = *mut LSA_FOREST_TRUST_INFORMATION; ENUM!{enum LSA_FOREST_TRUST_COLLISION_RECORD_TYPE { CollisionTdo, CollisionXref, CollisionOther, }} STRUCT!{struct LSA_FOREST_TRUST_COLLISION_RECORD { Index: ::ULONG, Type: LSA_FOREST_TRUST_COLLISION_RECORD_TYPE, Flags: ::ULONG, Name: ::LSA_UNICODE_STRING, }} pub type PLSA_FOREST_TRUST_COLLISION_RECORD = *mut LSA_FOREST_TRUST_COLLISION_RECORD; STRUCT!{struct LSA_FOREST_TRUST_COLLISION_INFORMATION { RecordCount: ::ULONG, Entries: *mut PLSA_FOREST_TRUST_COLLISION_RECORD, }} pub type PLSA_FOREST_TRUST_COLLISION_INFORMATION = *mut LSA_FOREST_TRUST_COLLISION_INFORMATION; pub type LSA_ENUMERATION_HANDLE = ::ULONG; pub type PLSA_ENUMERATION_HANDLE = *mut ::ULONG; STRUCT!{struct LSA_ENUMERATION_INFORMATION { Sid: ::PSID, }} pub type PLSA_ENUMERATION_INFORMATION = *mut LSA_ENUMERATION_INFORMATION; STRUCT!{struct LSA_LAST_INTER_LOGON_INFO { LastSuccessfulLogon: ::LARGE_INTEGER, LastFailedLogon: ::LARGE_INTEGER, FailedAttemptCountSinceLastSuccessfulLogon: ::ULONG, }} pub type PLSA_LAST_INTER_LOGON_INFO = *mut LSA_LAST_INTER_LOGON_INFO; STRUCT!{struct SECURITY_LOGON_SESSION_DATA { Size: ::ULONG, LogonId: ::LUID, UserName: ::LSA_UNICODE_STRING, LogonDomain: ::LSA_UNICODE_STRING, AuthenticationPackage: ::LSA_UNICODE_STRING, LogonType: ::ULONG, Session: ::ULONG, Sid: ::PSID, LogonTime: ::LARGE_INTEGER, LogonServer: ::LSA_UNICODE_STRING, DnsDomainName: ::LSA_UNICODE_STRING, Upn: ::LSA_UNICODE_STRING, UserFlags: ::ULONG, LastLogonInfo: LSA_LAST_INTER_LOGON_INFO, LogonScript: ::LSA_UNICODE_STRING, ProfilePath: ::LSA_UNICODE_STRING, HomeDirectory: ::LSA_UNICODE_STRING, HomeDirectoryDrive: ::LSA_UNICODE_STRING, LogoffTime: ::LARGE_INTEGER, KickOffTime: ::LARGE_INTEGER, PasswordLastSet: ::LARGE_INTEGER, PasswordCanChange: ::LARGE_INTEGER, PasswordMustChange: ::LARGE_INTEGER, }} pub type PSECURITY_LOGON_SESSION_DATA = *mut SECURITY_LOGON_SESSION_DATA; pub const CENTRAL_ACCESS_POLICY_OWNER_RIGHTS_PRESENT_FLAG: ::ULONG = 0x00000001; pub const CENTRAL_ACCESS_POLICY_STAGED_OWNER_RIGHTS_PRESENT_FLAG: ::ULONG = 0x00000100; pub const CENTRAL_ACCESS_POLICY_STAGED_FLAG: ::ULONG = 0x00010000; pub const CENTRAL_ACCESS_POLICY_VALID_FLAG_MASK: ::ULONG = CENTRAL_ACCESS_POLICY_OWNER_RIGHTS_PRESENT_FLAG | CENTRAL_ACCESS_POLICY_STAGED_OWNER_RIGHTS_PRESENT_FLAG | CENTRAL_ACCESS_POLICY_STAGED_FLAG; pub const LSASETCAPS_RELOAD_FLAG: ::ULONG = 0x00000001; pub const LSASETCAPS_VALID_FLAG_MASK: ::ULONG = LSASETCAPS_RELOAD_FLAG; STRUCT!{struct CENTRAL_ACCESS_POLICY_ENTRY { Name: ::LSA_UNICODE_STRING, Description: ::LSA_UNICODE_STRING, ChangeId: ::LSA_UNICODE_STRING, LengthAppliesTo: ::ULONG, AppliesTo: ::PUCHAR, LengthSD: ::ULONG, SD: ::PSECURITY_DESCRIPTOR, LengthStagedSD: ::ULONG, StagedSD: ::PSECURITY_DESCRIPTOR, Flags: ::ULONG, }} pub type PCENTRAL_ACCESS_POLICY_ENTRY = *mut CENTRAL_ACCESS_POLICY_ENTRY; pub type PCCENTRAL_ACCESS_POLICY_ENTRY = *const CENTRAL_ACCESS_POLICY_ENTRY; STRUCT!{struct CENTRAL_ACCESS_POLICY { CAPID: ::PSID, Name: ::LSA_UNICODE_STRING, Description: ::LSA_UNICODE_STRING, ChangeId: ::LSA_UNICODE_STRING, Flags: ::ULONG, CAPECount: ::ULONG, CAPEs: *mut PCENTRAL_ACCESS_POLICY_ENTRY, }} pub type PCENTRAL_ACCESS_POLICY = *mut CENTRAL_ACCESS_POLICY; pub type PCCENTRAL_ACCESS_POLICY = *const CENTRAL_ACCESS_POLICY; ENUM!{enum NEGOTIATE_MESSAGES { NegEnumPackagePrefixes = 0, NegGetCallerName = 1, NegTransferCredentials = 2, NegCallPackageMax, }} pub const NEGOTIATE_MAX_PREFIX: usize = 32; STRUCT!{struct NEGOTIATE_PACKAGE_PREFIX { PackageId: ::ULONG_PTR, PackageDataA: ::PVOID, PackageDataW: ::PVOID, PrefixLen: ::ULONG_PTR, Prefix: [::UCHAR; NEGOTIATE_MAX_PREFIX], }} pub type PNEGOTIATE_PACKAGE_PREFIX = *mut NEGOTIATE_PACKAGE_PREFIX; STRUCT!{struct NEGOTIATE_PACKAGE_PREFIXES { MessageType: ::ULONG, PrefixCount: ::ULONG, Offset: ::ULONG, Pad: ::ULONG, }} pub type PNEGOTIATE_PACKAGE_PREFIXES = *mut NEGOTIATE_PACKAGE_PREFIXES; STRUCT!{struct NEGOTIATE_CALLER_NAME_REQUEST { MessageType: ::ULONG, LogonId: ::LUID, }} pub type PNEGOTIATE_CALLER_NAME_REQUEST = *mut NEGOTIATE_CALLER_NAME_REQUEST; STRUCT!{struct NEGOTIATE_CALLER_NAME_RESPONSE { MessageType: ::ULONG, CallerName: ::PWSTR, }} pub type PNEGOTIATE_CALLER_NAME_RESPONSE = *mut NEGOTIATE_CALLER_NAME_RESPONSE; STRUCT!{struct DOMAIN_PASSWORD_INFORMATION { MinPasswordLength: ::USHORT, PasswordHistoryLength: ::USHORT, PasswordProperties: ::ULONG, MaxPasswordAge: ::LARGE_INTEGER, MinPasswordAge: ::LARGE_INTEGER, }} pub type PDOMAIN_PASSWORD_INFORMATION = *mut DOMAIN_PASSWORD_INFORMATION; pub const DOMAIN_PASSWORD_COMPLEX: ::ULONG = 0x00000001; pub const DOMAIN_PASSWORD_NO_ANON_CHANGE: ::ULONG = 0x00000002; pub const DOMAIN_PASSWORD_NO_CLEAR_CHANGE: ::ULONG = 0x00000004; pub const DOMAIN_LOCKOUT_ADMINS: ::ULONG = 0x00000008; pub const DOMAIN_PASSWORD_STORE_CLEARTEXT: ::ULONG = 0x00000010; pub const DOMAIN_REFUSE_PASSWORD_CHANGE: ::ULONG = 0x00000020; pub const DOMAIN_NO_LM_OWF_CHANGE: ::ULONG = 0x00000040; pub type PSAM_PASSWORD_NOTIFICATION_ROUTINE = Option ::NTSTATUS>; pub type PSAM_INIT_NOTIFICATION_ROUTINE = Option ::BOOLEAN>; pub type PSAM_PASSWORD_FILTER_ROUTINE = Option ::BOOLEAN>; ENUM!{enum MSV1_0_LOGON_SUBMIT_TYPE { MsV1_0InteractiveLogon = 2, MsV1_0Lm20Logon, MsV1_0NetworkLogon, MsV1_0SubAuthLogon, MsV1_0WorkstationUnlockLogon = 7, MsV1_0S4ULogon = 12, MsV1_0VirtualLogon = 82, MsV1_0NoElevationLogon = 83, MsV1_0LuidLogon = 84, }} pub type PMSV1_0_LOGON_SUBMIT_TYPE = *mut MSV1_0_LOGON_SUBMIT_TYPE; ENUM!{enum MSV1_0_PROFILE_BUFFER_TYPE { MsV1_0InteractiveProfile = 2, MsV1_0Lm20LogonProfile, MsV1_0SmartCardProfile, }} pub type PMSV1_0_PROFILE_BUFFER_TYPE = *mut MSV1_0_PROFILE_BUFFER_TYPE; STRUCT!{struct MSV1_0_INTERACTIVE_LOGON { MessageType: MSV1_0_LOGON_SUBMIT_TYPE, LogonDomainName: ::UNICODE_STRING, UserName: ::UNICODE_STRING, Password: ::UNICODE_STRING, }} pub type PMSV1_0_INTERACTIVE_LOGON = *mut MSV1_0_INTERACTIVE_LOGON; STRUCT!{struct MSV1_0_INTERACTIVE_PROFILE { MessageType: MSV1_0_PROFILE_BUFFER_TYPE, LogonCount: ::USHORT, BadPasswordCount: ::USHORT, LogonTime: ::LARGE_INTEGER, LogoffTime: ::LARGE_INTEGER, KickOffTime: ::LARGE_INTEGER, PasswordLastSet: ::LARGE_INTEGER, PasswordCanChange: ::LARGE_INTEGER, PasswordMustChange: ::LARGE_INTEGER, LogonScript: ::UNICODE_STRING, HomeDirectory: ::UNICODE_STRING, FullName: ::UNICODE_STRING, ProfilePath: ::UNICODE_STRING, HomeDirectoryDrive: ::UNICODE_STRING, LogonServer: ::UNICODE_STRING, UserFlags: ::ULONG, }} pub type PMSV1_0_INTERACTIVE_PROFILE = *mut MSV1_0_INTERACTIVE_PROFILE; pub const MSV1_0_CHALLENGE_LENGTH: usize = 8; pub const MSV1_0_USER_SESSION_KEY_LENGTH: usize = 16; pub const MSV1_0_LANMAN_SESSION_KEY_LENGTH: usize = 8; pub const MSV1_0_CLEARTEXT_PASSWORD_ALLOWED: ::ULONG = 0x02; pub const MSV1_0_UPDATE_LOGON_STATISTICS: ::ULONG = 0x04; pub const MSV1_0_RETURN_USER_PARAMETERS: ::ULONG = 0x08; pub const MSV1_0_DONT_TRY_GUEST_ACCOUNT: ::ULONG = 0x10; pub const MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT: ::ULONG = 0x20; pub const MSV1_0_RETURN_PASSWORD_EXPIRY: ::ULONG = 0x40; pub const MSV1_0_USE_CLIENT_CHALLENGE: ::ULONG = 0x80; pub const MSV1_0_TRY_GUEST_ACCOUNT_ONLY: ::ULONG = 0x100; pub const MSV1_0_RETURN_PROFILE_PATH: ::ULONG = 0x200; pub const MSV1_0_TRY_SPECIFIED_DOMAIN_ONLY: ::ULONG = 0x400; pub const MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT: ::ULONG = 0x800; pub const MSV1_0_DISABLE_PERSONAL_FALLBACK: ::ULONG = 0x00001000; pub const MSV1_0_ALLOW_FORCE_GUEST: ::ULONG = 0x00002000; pub const MSV1_0_CLEARTEXT_PASSWORD_SUPPLIED: ::ULONG = 0x00004000; pub const MSV1_0_USE_DOMAIN_FOR_ROUTING_ONLY: ::ULONG = 0x00008000; pub const MSV1_0_SUBAUTHENTICATION_DLL_EX: ::ULONG = 0x00100000; pub const MSV1_0_ALLOW_MSVCHAPV2: ::ULONG = 0x00010000; pub const MSV1_0_S4U2SELF: ::ULONG = 0x00020000; pub const MSV1_0_CHECK_LOGONHOURS_FOR_S4U: ::ULONG = 0x00040000; pub const MSV1_0_INTERNET_DOMAIN: ::ULONG = 0x00080000; pub const MSV1_0_SUBAUTHENTICATION_DLL: ::ULONG = 0xFF000000; pub const MSV1_0_SUBAUTHENTICATION_DLL_SHIFT: ::ULONG = 24; pub const MSV1_0_MNS_LOGON: ::ULONG = 0x01000000; pub const MSV1_0_SUBAUTHENTICATION_DLL_RAS: ::ULONG = 2; pub const MSV1_0_SUBAUTHENTICATION_DLL_IIS: ::ULONG = 132; STRUCT!{struct MSV1_0_LM20_LOGON { MessageType: MSV1_0_LOGON_SUBMIT_TYPE, LogonDomainName: ::UNICODE_STRING, UserName: ::UNICODE_STRING, Workstation: ::UNICODE_STRING, ChallengeToClient: [::UCHAR; MSV1_0_CHALLENGE_LENGTH], CaseSensitiveChallengeResponse: ::STRING, CaseInsensitiveChallengeResponse: ::STRING, ParameterControl: ::ULONG, }} pub type PMSV1_0_LM20_LOGON = *mut MSV1_0_LM20_LOGON; STRUCT!{struct MSV1_0_SUBAUTH_LOGON { MessageType: MSV1_0_LOGON_SUBMIT_TYPE, LogonDomainName: ::UNICODE_STRING, UserName: ::UNICODE_STRING, Workstation: ::UNICODE_STRING, ChallengeToClient: [::UCHAR; MSV1_0_CHALLENGE_LENGTH], AuthenticationInfo1: ::STRING, AuthenticationInfo2: ::STRING, ParameterControl: ::ULONG, SubAuthPackageId: ::ULONG, }} pub type PMSV1_0_SUBAUTH_LOGON = *mut MSV1_0_SUBAUTH_LOGON; STRUCT!{struct MSV1_0_S4U_LOGON { MessageType: MSV1_0_LOGON_SUBMIT_TYPE, MSV1_0_LOGON_SUBMIT_TYPE: ::ULONG, UserPrincipalName: ::UNICODE_STRING, DomainName: ::UNICODE_STRING, }} pub type PMSV1_0_S4U_LOGON = *mut MSV1_0_S4U_LOGON; pub const LOGON_GUEST: ::ULONG = 0x01; pub const LOGON_NOENCRYPTION: ::ULONG = 0x02; pub const LOGON_CACHED_ACCOUNT: ::ULONG = 0x04; pub const LOGON_USED_LM_PASSWORD: ::ULONG = 0x08; pub const LOGON_EXTRA_SIDS: ::ULONG = 0x20; pub const LOGON_SUBAUTH_SESSION_KEY: ::ULONG = 0x40; pub const LOGON_SERVER_TRUST_ACCOUNT: ::ULONG = 0x80; pub const LOGON_NTLMV2_ENABLED: ::ULONG = 0x100; pub const LOGON_RESOURCE_GROUPS: ::ULONG = 0x200; pub const LOGON_PROFILE_PATH_RETURNED: ::ULONG = 0x400; pub const LOGON_NT_V2: ::ULONG = 0x800; pub const LOGON_LM_V2: ::ULONG = 0x1000; pub const LOGON_NTLM_V2: ::ULONG = 0x2000; pub const LOGON_OPTIMIZED: ::ULONG = 0x4000; pub const LOGON_WINLOGON: ::ULONG = 0x8000; pub const LOGON_PKINIT: ::ULONG = 0x10000; pub const LOGON_NO_OPTIMIZED: ::ULONG = 0x20000; pub const LOGON_NO_ELEVATION: ::ULONG = 0x40000; pub const LOGON_MANAGED_SERVICE: ::ULONG = 0x80000; pub const LOGON_GRACE_LOGON: ::ULONG = 0x01000000; STRUCT!{struct MSV1_0_LM20_LOGON_PROFILE { MessageType: MSV1_0_PROFILE_BUFFER_TYPE, KickOffTime: ::LARGE_INTEGER, LogoffTime: ::LARGE_INTEGER, UserFlags: ::ULONG, UserSessionKey: [::UCHAR; MSV1_0_USER_SESSION_KEY_LENGTH], LogonDomainName: ::UNICODE_STRING, LanmanSessionKey: [::UCHAR; MSV1_0_LANMAN_SESSION_KEY_LENGTH], LogonServer: ::UNICODE_STRING, UserParameters: ::UNICODE_STRING, }} pub type PMSV1_0_LM20_LOGON_PROFILE = *mut MSV1_0_LM20_LOGON_PROFILE; pub const MSV1_0_OWF_PASSWORD_LENGTH: usize = 16; STRUCT!{struct MSV1_0_SUPPLEMENTAL_CREDENTIAL { Version: ::ULONG, Flags: ::ULONG, LmPassword: [::UCHAR; MSV1_0_OWF_PASSWORD_LENGTH], NtPassword: [::UCHAR; MSV1_0_OWF_PASSWORD_LENGTH], }} pub type PMSV1_0_SUPPLEMENTAL_CREDENTIAL = *mut MSV1_0_SUPPLEMENTAL_CREDENTIAL; pub const MSV1_0_NTLM3_RESPONSE_LENGTH: usize = 16; pub const MSV1_0_NTLM3_OWF_LENGTH: usize = 16; STRUCT!{struct MSV1_0_NTLM3_RESPONSE { Response: [::UCHAR; MSV1_0_NTLM3_RESPONSE_LENGTH], RespType: ::UCHAR, HiRespType: ::UCHAR, Flags: ::USHORT, MsgWord: ::ULONG, TimeStamp: ::ULONGLONG, ChallengeFromClient: [::UCHAR; MSV1_0_CHALLENGE_LENGTH], AvPairsOff: ::ULONG, Buffer: [::UCHAR; 1], }} pub type PMSV1_0_NTLM3_RESPONSE = *mut MSV1_0_NTLM3_RESPONSE; ENUM!{enum MSV1_0_AVID { MsvAvEOL, MsvAvNbComputerName, MsvAvNbDomainName, MsvAvDnsComputerName, MsvAvDnsDomainName, MsvAvDnsTreeName, MsvAvFlags, MsvAvTimestamp, MsvAvRestrictions, MsvAvTargetName, MsvAvChannelBindings, }} STRUCT!{struct MSV1_0_AV_PAIR { AvId: ::USHORT, AvLen: ::USHORT, }} pub type PMSV1_0_AV_PAIR = *mut MSV1_0_AV_PAIR; ENUM!{enum MSV1_0_PROTOCOL_MESSAGE_TYPE { MsV1_0Lm20ChallengeRequest = 0, MsV1_0Lm20GetChallengeResponse, MsV1_0EnumerateUsers, MsV1_0GetUserInfo, MsV1_0ReLogonUsers, MsV1_0ChangePassword, MsV1_0ChangeCachedPassword, MsV1_0GenericPassthrough, MsV1_0CacheLogon, MsV1_0SubAuth, MsV1_0DeriveCredential, MsV1_0CacheLookup, MsV1_0SetProcessOption, MsV1_0ConfigLocalAliases, MsV1_0ClearCachedCredentials, MsV1_0LookupToken, MsV1_0ValidateAuth, MsV1_0CacheLookupEx, MsV1_0GetCredentialKey, MsV1_0SetThreadOption, }} pub type PMSV1_0_PROTOCOL_MESSAGE_TYPE = *mut MSV1_0_PROTOCOL_MESSAGE_TYPE; STRUCT!{struct MSV1_0_CHANGEPASSWORD_REQUEST { MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE, DomainName: ::UNICODE_STRING, AccountName: ::UNICODE_STRING, OldPassword: ::UNICODE_STRING, NewPassword: ::UNICODE_STRING, Impersonating: ::BOOLEAN, }} pub type PMSV1_0_CHANGEPASSWORD_REQUEST = *mut MSV1_0_CHANGEPASSWORD_REQUEST; STRUCT!{struct MSV1_0_CHANGEPASSWORD_RESPONSE { MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE, PasswordInfoValid: ::BOOLEAN, DomainPasswordInfo: DOMAIN_PASSWORD_INFORMATION, }} pub type PMSV1_0_CHANGEPASSWORD_RESPONSE = *mut MSV1_0_CHANGEPASSWORD_RESPONSE; STRUCT!{struct MSV1_0_PASSTHROUGH_REQUEST { MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE, DomainName: ::UNICODE_STRING, PackageName: ::UNICODE_STRING, DataLength: ::ULONG, LogonData: ::PUCHAR, Pad: ::ULONG, }} pub type PMSV1_0_PASSTHROUGH_REQUEST = *mut MSV1_0_PASSTHROUGH_REQUEST; STRUCT!{struct MSV1_0_PASSTHROUGH_RESPONSE { MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE, Pad: ::ULONG, DataLength: ::ULONG, ValidationData: ::PUCHAR, }} pub type PMSV1_0_PASSTHROUGH_RESPONSE = *mut MSV1_0_PASSTHROUGH_RESPONSE; STRUCT!{struct MSV1_0_SUBAUTH_REQUEST { MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE, SubAuthPackageId: ::ULONG, SubAuthInfoLength: ::ULONG, SubAuthSubmitBuffer: ::PUCHAR, }} pub type PMSV1_0_SUBAUTH_REQUEST = *mut MSV1_0_SUBAUTH_REQUEST; STRUCT!{struct MSV1_0_SUBAUTH_RESPONSE { MessageType: MSV1_0_PROTOCOL_MESSAGE_TYPE, SubAuthInfoLength: ::ULONG, SubAuthReturnBuffer: ::PUCHAR, }} pub type PMSV1_0_SUBAUTH_RESPONSE = *mut MSV1_0_SUBAUTH_RESPONSE; pub const RTL_ENCRYPT_MEMORY_SIZE: ::ULONG = 8; pub const RTL_ENCRYPT_OPTION_CROSS_PROCESS: ::ULONG = 0x01; pub const RTL_ENCRYPT_OPTION_SAME_LOGON: ::ULONG = 0x02; pub const KERB_ETYPE_NULL: ::LONG = 0; pub const KERB_ETYPE_DES_CBC_CRC: ::LONG = 1; pub const KERB_ETYPE_DES_CBC_MD4: ::LONG = 2; pub const KERB_ETYPE_DES_CBC_MD5: ::LONG = 3; pub const KERB_ETYPE_AES128_CTS_HMAC_SHA1_96: ::LONG = 17; pub const KERB_ETYPE_AES256_CTS_HMAC_SHA1_96: ::LONG = 18; pub const KERB_ETYPE_RC4_MD4: ::LONG = -128; pub const KERB_ETYPE_RC4_PLAIN2: ::LONG = -129; pub const KERB_ETYPE_RC4_LM: ::LONG = -130; pub const KERB_ETYPE_RC4_SHA: ::LONG = -131; pub const KERB_ETYPE_DES_PLAIN: ::LONG = -132; pub const KERB_ETYPE_RC4_HMAC_OLD: ::LONG = -133; pub const KERB_ETYPE_RC4_PLAIN_OLD: ::LONG = -134; pub const KERB_ETYPE_RC4_HMAC_OLD_EXP: ::LONG = -135; pub const KERB_ETYPE_RC4_PLAIN_OLD_EXP: ::LONG = -136; pub const KERB_ETYPE_RC4_PLAIN: ::LONG = -140; pub const KERB_ETYPE_RC4_PLAIN_EXP: ::LONG = -141; pub const KERB_ETYPE_AES128_CTS_HMAC_SHA1_96_PLAIN: ::LONG = -148; pub const KERB_ETYPE_AES256_CTS_HMAC_SHA1_96_PLAIN: ::LONG = -149; pub const KERB_ETYPE_DSA_SHA1_CMS: ::LONG = 9; pub const KERB_ETYPE_RSA_MD5_CMS: ::LONG = 10; pub const KERB_ETYPE_RSA_SHA1_CMS: ::LONG = 11; pub const KERB_ETYPE_RC2_CBC_ENV: ::LONG = 12; pub const KERB_ETYPE_RSA_ENV: ::LONG = 13; pub const KERB_ETYPE_RSA_ES_OEAP_ENV: ::LONG = 14; pub const KERB_ETYPE_DES_EDE3_CBC_ENV: ::LONG = 15; pub const KERB_ETYPE_DSA_SIGN: ::LONG = 8; pub const KERB_ETYPE_RSA_PRIV: ::LONG = 9; pub const KERB_ETYPE_RSA_PUB: ::LONG = 10; pub const KERB_ETYPE_RSA_PUB_MD5: ::LONG = 11; pub const KERB_ETYPE_RSA_PUB_SHA1: ::LONG = 12; pub const KERB_ETYPE_PKCS7_PUB: ::LONG = 13; pub const KERB_ETYPE_DES3_CBC_MD5: ::LONG = 5; pub const KERB_ETYPE_DES3_CBC_SHA1: ::LONG = 7; pub const KERB_ETYPE_DES3_CBC_SHA1_KD: ::LONG = 16; pub const KERB_ETYPE_DES_CBC_MD5_NT: ::LONG = 20; pub const KERB_ETYPE_RC4_HMAC_NT: ::LONG = 23; pub const KERB_ETYPE_RC4_HMAC_NT_EXP: ::LONG = 24; pub const KERB_CHECKSUM_NONE: ::LONG = 0; pub const KERB_CHECKSUM_CRC32: ::LONG = 1; pub const KERB_CHECKSUM_MD4: ::LONG = 2; pub const KERB_CHECKSUM_KRB_DES_MAC: ::LONG = 4; pub const KERB_CHECKSUM_KRB_DES_MAC_K: ::LONG = 5; pub const KERB_CHECKSUM_MD5: ::LONG = 7; pub const KERB_CHECKSUM_MD5_DES: ::LONG = 8; pub const KERB_CHECKSUM_SHA1_NEW: ::LONG = 14; pub const KERB_CHECKSUM_HMAC_SHA1_96_AES128: ::LONG = 15; pub const KERB_CHECKSUM_HMAC_SHA1_96_AES256: ::LONG = 16; pub const KERB_CHECKSUM_LM: ::LONG = -130; pub const KERB_CHECKSUM_SHA1: ::LONG = -131; pub const KERB_CHECKSUM_REAL_CRC32: ::LONG = -132; pub const KERB_CHECKSUM_DES_MAC: ::LONG = -133; pub const KERB_CHECKSUM_DES_MAC_MD5: ::LONG = -134; pub const KERB_CHECKSUM_MD25: ::LONG = -135; pub const KERB_CHECKSUM_RC4_MD5: ::LONG = -136; pub const KERB_CHECKSUM_MD5_HMAC: ::LONG = -137; pub const KERB_CHECKSUM_HMAC_MD5: ::LONG = -138; pub const KERB_CHECKSUM_HMAC_SHA1_96_AES128_Ki: ::LONG = -150; pub const KERB_CHECKSUM_HMAC_SHA1_96_AES256_Ki: ::LONG = -151; pub const KERB_TICKET_FLAGS_reserved: ::ULONG = 0x80000000; pub const KERB_TICKET_FLAGS_forwardable: ::ULONG = 0x40000000; pub const KERB_TICKET_FLAGS_forwarded: ::ULONG = 0x20000000; pub const KERB_TICKET_FLAGS_proxiable: ::ULONG = 0x10000000; pub const KERB_TICKET_FLAGS_proxy: ::ULONG = 0x08000000; pub const KERB_TICKET_FLAGS_may_postdate: ::ULONG = 0x04000000; pub const KERB_TICKET_FLAGS_postdated: ::ULONG = 0x02000000; pub const KERB_TICKET_FLAGS_invalid: ::ULONG = 0x01000000; pub const KERB_TICKET_FLAGS_renewable: ::ULONG = 0x00800000; pub const KERB_TICKET_FLAGS_initial: ::ULONG = 0x00400000; pub const KERB_TICKET_FLAGS_pre_authent: ::ULONG = 0x00200000; pub const KERB_TICKET_FLAGS_hw_authent: ::ULONG = 0x00100000; pub const KERB_TICKET_FLAGS_ok_as_delegate: ::ULONG = 0x00040000; pub const KERB_TICKET_FLAGS_name_canonicalize: ::ULONG = 0x00010000; pub const KERB_TICKET_FLAGS_cname_in_pa_data: ::ULONG = 0x00040000; pub const KERB_TICKET_FLAGS_enc_pa_rep: ::ULONG = 0x00010000; pub const KERB_TICKET_FLAGS_reserved1: ::ULONG = 0x00000001; pub const KRB_NT_UNKNOWN: ::LONG = 0; pub const KRB_NT_PRINCIPAL: ::LONG = 1; pub const KRB_NT_PRINCIPAL_AND_ID: ::LONG = -131; pub const KRB_NT_SRV_INST: ::LONG = 2; pub const KRB_NT_SRV_INST_AND_ID: ::LONG = -132; pub const KRB_NT_SRV_HST: ::LONG = 3; pub const KRB_NT_SRV_XHST: ::LONG = 4; pub const KRB_NT_UID: ::LONG = 5; pub const KRB_NT_ENTERPRISE_PRINCIPAL: ::LONG = 10; pub const KRB_NT_WELLKNOWN: ::LONG = 11; pub const KRB_NT_ENT_PRINCIPAL_AND_ID: ::LONG = -130; pub const KRB_NT_MS_PRINCIPAL: ::LONG = -128; pub const KRB_NT_MS_PRINCIPAL_AND_ID: ::LONG = -129; pub const KRB_NT_MS_BRANCH_ID: ::LONG = -133; pub const KRB_NT_X500_PRINCIPAL: ::LONG = 6; pub const KERB_WRAP_NO_ENCRYPT: ::ULONG = 0x80000001; ENUM!{enum KERB_LOGON_SUBMIT_TYPE { KerbInteractiveLogon = 2, KerbSmartCardLogon = 6, KerbWorkstationUnlockLogon = 7, KerbSmartCardUnlockLogon = 8, KerbProxyLogon = 9, KerbTicketLogon = 10, KerbTicketUnlockLogon = 11, KerbS4ULogon = 12, KerbCertificateLogon = 13, KerbCertificateS4ULogon = 14, KerbCertificateUnlockLogon = 15, KerbNoElevationLogon = 83, KerbLuidLogon = 84, }} pub type PKERB_LOGON_SUBMIT_TYPE = *mut KERB_LOGON_SUBMIT_TYPE; STRUCT!{struct KERB_INTERACTIVE_LOGON { MessageType: KERB_LOGON_SUBMIT_TYPE, LogonDomainName: ::UNICODE_STRING, UserName: ::UNICODE_STRING, Password: ::UNICODE_STRING, }} pub type PKERB_INTERACTIVE_LOGON = *mut KERB_INTERACTIVE_LOGON; STRUCT!{struct KERB_INTERACTIVE_UNLOCK_LOGON { Logon: KERB_INTERACTIVE_LOGON, LogonId: ::LUID, }} pub type PKERB_INTERACTIVE_UNLOCK_LOGON = *mut KERB_INTERACTIVE_UNLOCK_LOGON; STRUCT!{struct KERB_SMART_CARD_LOGON { MessageType: KERB_LOGON_SUBMIT_TYPE, Pin: ::UNICODE_STRING, CspDataLength: ::ULONG, CspData: ::PUCHAR, }} pub type PKERB_SMART_CARD_LOGON = *mut KERB_SMART_CARD_LOGON; STRUCT!{struct KERB_SMART_CARD_UNLOCK_LOGON { Logon: KERB_SMART_CARD_LOGON, LogonId: ::LUID, }} pub type PKERB_SMART_CARD_UNLOCK_LOGON = *mut KERB_SMART_CARD_UNLOCK_LOGON; pub const KERB_CERTIFICATE_LOGON_FLAG_CHECK_DUPLICATES: ::ULONG = 0x1; pub const KERB_CERTIFICATE_LOGON_FLAG_USE_CERTIFICATE_INFO: ::ULONG = 0x2; STRUCT!{struct KERB_CERTIFICATE_LOGON { MessageType: KERB_LOGON_SUBMIT_TYPE, DomainName: ::UNICODE_STRING, UserName: ::UNICODE_STRING, Pin: ::UNICODE_STRING, Flags: ::ULONG, CspDataLength: ::ULONG, CspData: ::PUCHAR, }} pub type PKERB_CERTIFICATE_LOGON = *mut KERB_CERTIFICATE_LOGON; STRUCT!{struct KERB_CERTIFICATE_UNLOCK_LOGON { Logon: KERB_CERTIFICATE_LOGON, LogonId: ::LUID, }} pub type PKERB_CERTIFICATE_UNLOCK_LOGON = *mut KERB_CERTIFICATE_UNLOCK_LOGON; pub const KERB_CERTIFICATE_S4U_LOGON_FLAG_CHECK_DUPLICATES: ::ULONG = 0x1; pub const KERB_CERTIFICATE_S4U_LOGON_FLAG_CHECK_LOGONHOURS: ::ULONG = 0x2; pub const KERB_CERTIFICATE_S4U_LOGON_FLAG_FAIL_IF_NT_AUTH_POLICY_REQUIRED: ::ULONG = 0x4; pub const KERB_CERTIFICATE_S4U_LOGON_FLAG_IDENTIFY: ::ULONG = 0x8; STRUCT!{struct KERB_CERTIFICATE_S4U_LOGON { MessageType: KERB_LOGON_SUBMIT_TYPE, Flags: ::ULONG, UserPrincipalName: ::UNICODE_STRING, DomainName: ::UNICODE_STRING, CertificateLength: ::ULONG, Certificate: ::PUCHAR, }} pub type PKERB_CERTIFICATE_S4U_LOGON = *mut KERB_CERTIFICATE_S4U_LOGON; STRUCT!{struct KERB_TICKET_LOGON { MessageType: KERB_LOGON_SUBMIT_TYPE, Flags: ::ULONG, ServiceTicketLength: ::ULONG, TicketGrantingTicketLength: ::ULONG, ServiceTicket: ::PUCHAR, TicketGrantingTicket: ::PUCHAR, }} pub type PKERB_TICKET_LOGON = *mut KERB_TICKET_LOGON; STRUCT!{struct KERB_TICKET_UNLOCK_LOGON { Logon: KERB_TICKET_LOGON, LogonId: ::LUID, }} pub type PKERB_TICKET_UNLOCK_LOGON = *mut KERB_TICKET_UNLOCK_LOGON; pub const KERB_S4U_LOGON_FLAG_CHECK_LOGONHOURS: ::ULONG = 0x2; pub const KERB_S4U_LOGON_FLAG_IDENTIFY: ::ULONG = 0x8; STRUCT!{struct KERB_S4U_LOGON { MessageType: KERB_LOGON_SUBMIT_TYPE, Flags: ::ULONG, ClientUpn: ::UNICODE_STRING, ClientRealm: ::UNICODE_STRING, }} pub type PKERB_S4U_LOGON = *mut KERB_S4U_LOGON; ENUM!{enum KERB_PROFILE_BUFFER_TYPE { KerbInteractiveProfile = 2, KerbSmartCardProfile = 4, KerbTicketProfile = 6, }} pub type PKERB_PROFILE_BUFFER_TYPE = *mut KERB_PROFILE_BUFFER_TYPE; STRUCT!{struct KERB_INTERACTIVE_PROFILE { MessageType: KERB_PROFILE_BUFFER_TYPE, LogonCount: ::USHORT, BadPasswordCount: ::USHORT, LogonTime: ::LARGE_INTEGER, LogoffTime: ::LARGE_INTEGER, KickOffTime: ::LARGE_INTEGER, PasswordLastSet: ::LARGE_INTEGER, PasswordCanChange: ::LARGE_INTEGER, PasswordMustChange: ::LARGE_INTEGER, LogonScript: ::UNICODE_STRING, HomeDirectory: ::UNICODE_STRING, FullName: ::UNICODE_STRING, ProfilePath: ::UNICODE_STRING, HomeDirectoryDrive: ::UNICODE_STRING, LogonServer: ::UNICODE_STRING, UserFlags: ::ULONG, }} pub type PKERB_INTERACTIVE_PROFILE = *mut KERB_INTERACTIVE_PROFILE; STRUCT!{struct KERB_SMART_CARD_PROFILE { Profile: KERB_INTERACTIVE_PROFILE, CertificateSize: ::ULONG, CertificateData: ::PUCHAR, }} pub type PKERB_SMART_CARD_PROFILE = *mut KERB_SMART_CARD_PROFILE; STRUCT!{struct KERB_CRYPTO_KEY { KeyType: ::LONG, Length: ::ULONG, Value: ::PUCHAR, }} pub type PKERB_CRYPTO_KEY = *mut KERB_CRYPTO_KEY; STRUCT!{struct KERB_CRYPTO_KEY32 { KeyType: ::LONG, Length: ::ULONG, Offset: ::ULONG, }} pub type PKERB_CRYPTO_KEY32 = *mut KERB_CRYPTO_KEY32; STRUCT!{struct KERB_TICKET_PROFILE { Profile: KERB_INTERACTIVE_PROFILE, SessionKey: KERB_CRYPTO_KEY, }} pub type PKERB_TICKET_PROFILE = *mut KERB_TICKET_PROFILE; ENUM!{enum KERB_PROTOCOL_MESSAGE_TYPE { KerbDebugRequestMessage = 0, KerbQueryTicketCacheMessage, KerbChangeMachinePasswordMessage, KerbVerifyPacMessage, KerbRetrieveTicketMessage, KerbUpdateAddressesMessage, KerbPurgeTicketCacheMessage, KerbChangePasswordMessage, KerbRetrieveEncodedTicketMessage, KerbDecryptDataMessage, KerbAddBindingCacheEntryMessage, KerbSetPasswordMessage, KerbSetPasswordExMessage, KerbVerifyCredentialsMessage, KerbQueryTicketCacheExMessage, KerbPurgeTicketCacheExMessage, KerbRefreshSmartcardCredentialsMessage, KerbAddExtraCredentialsMessage, KerbQuerySupplementalCredentialsMessage, KerbTransferCredentialsMessage, KerbQueryTicketCacheEx2Message, KerbSubmitTicketMessage, KerbAddExtraCredentialsExMessage, KerbQueryKdcProxyCacheMessage, KerbPurgeKdcProxyCacheMessage, KerbQueryTicketCacheEx3Message, KerbCleanupMachinePkinitCredsMessage, KerbAddBindingCacheEntryExMessage, KerbQueryBindingCacheMessage, KerbPurgeBindingCacheMessage, KerbPinKdcMessage, KerbUnpinAllKdcsMessage, KerbQueryDomainExtendedPoliciesMessage, KerbQueryS4U2ProxyCacheMessage, }} pub type PKERB_PROTOCOL_MESSAGE_TYPE = *mut KERB_PROTOCOL_MESSAGE_TYPE; STRUCT!{struct KERB_QUERY_TKT_CACHE_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, LogonId: ::LUID, }} pub type PKERB_QUERY_TKT_CACHE_REQUEST = *mut KERB_QUERY_TKT_CACHE_REQUEST; STRUCT!{struct KERB_TICKET_CACHE_INFO { ServerName: ::UNICODE_STRING, RealmName: ::UNICODE_STRING, StartTime: ::LARGE_INTEGER, EndTime: ::LARGE_INTEGER, RenewTime: ::LARGE_INTEGER, EncryptionType: ::LONG, TicketFlags: ::ULONG, }} pub type PKERB_TICKET_CACHE_INFO = *mut KERB_TICKET_CACHE_INFO; STRUCT!{struct KERB_TICKET_CACHE_INFO_EX { ClientName: ::UNICODE_STRING, ClientRealm: ::UNICODE_STRING, ServerName: ::UNICODE_STRING, ServerRealm: ::UNICODE_STRING, StartTime: ::LARGE_INTEGER, EndTime: ::LARGE_INTEGER, RenewTime: ::LARGE_INTEGER, EncryptionType: ::LONG, TicketFlags: ::ULONG, }} pub type PKERB_TICKET_CACHE_INFO_EX = *mut KERB_TICKET_CACHE_INFO_EX; STRUCT!{struct KERB_TICKET_CACHE_INFO_EX2 { ClientName: ::UNICODE_STRING, ClientRealm: ::UNICODE_STRING, ServerName: ::UNICODE_STRING, ServerRealm: ::UNICODE_STRING, StartTime: ::LARGE_INTEGER, EndTime: ::LARGE_INTEGER, RenewTime: ::LARGE_INTEGER, EncryptionType: ::LONG, TicketFlags: ::ULONG, SessionKeyType: ::ULONG, BranchId: ::ULONG, }} pub type PKERB_TICKET_CACHE_INFO_EX2 = *mut KERB_TICKET_CACHE_INFO_EX2; STRUCT!{struct KERB_TICKET_CACHE_INFO_EX3 { ClientName: ::UNICODE_STRING, ClientRealm: ::UNICODE_STRING, ServerName: ::UNICODE_STRING, ServerRealm: ::UNICODE_STRING, StartTime: ::LARGE_INTEGER, EndTime: ::LARGE_INTEGER, RenewTime: ::LARGE_INTEGER, EncryptionType: ::LONG, TicketFlags: ::ULONG, SessionKeyType: ::ULONG, BranchId: ::ULONG, CacheFlags: ::ULONG, KdcCalled: ::UNICODE_STRING, }} pub type PKERB_TICKET_CACHE_INFO_EX3 = *mut KERB_TICKET_CACHE_INFO_EX3; STRUCT!{struct KERB_QUERY_TKT_CACHE_RESPONSE { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, CountOfTickets: ::ULONG, Tickets: [KERB_TICKET_CACHE_INFO; ::ANYSIZE_ARRAY], }} pub type PKERB_QUERY_TKT_CACHE_RESPONSE = *mut KERB_QUERY_TKT_CACHE_RESPONSE; STRUCT!{struct KERB_QUERY_TKT_CACHE_EX_RESPONSE { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, CountOfTickets: ::ULONG, Tickets: [KERB_TICKET_CACHE_INFO_EX; ::ANYSIZE_ARRAY], }} pub type PKERB_QUERY_TKT_CACHE_EX_RESPONSE = *mut KERB_QUERY_TKT_CACHE_EX_RESPONSE; STRUCT!{struct KERB_QUERY_TKT_CACHE_EX2_RESPONSE { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, CountOfTickets: ::ULONG, Tickets: [KERB_TICKET_CACHE_INFO_EX2; ::ANYSIZE_ARRAY], }} pub type PKERB_QUERY_TKT_CACHE_EX2_RESPONSE = *mut KERB_QUERY_TKT_CACHE_EX2_RESPONSE; STRUCT!{struct KERB_QUERY_TKT_CACHE_EX3_RESPONSE { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, CountOfTickets: ::ULONG, Tickets: [KERB_TICKET_CACHE_INFO_EX3; ::ANYSIZE_ARRAY], }} pub type PKERB_QUERY_TKT_CACHE_EX3_RESPONSE = *mut KERB_QUERY_TKT_CACHE_EX3_RESPONSE; pub const KERB_USE_DEFAULT_TICKET_FLAGS: ::ULONG = 0x0; pub const KERB_RETRIEVE_TICKET_DEFAULT: ::ULONG = 0x0; pub const KERB_RETRIEVE_TICKET_DONT_USE_CACHE: ::ULONG = 0x1; pub const KERB_RETRIEVE_TICKET_USE_CACHE_ONLY: ::ULONG = 0x2; pub const KERB_RETRIEVE_TICKET_USE_CREDHANDLE: ::ULONG = 0x4; pub const KERB_RETRIEVE_TICKET_AS_KERB_CRED: ::ULONG = 0x8; pub const KERB_RETRIEVE_TICKET_WITH_SEC_CRED: ::ULONG = 0x10; pub const KERB_RETRIEVE_TICKET_CACHE_TICKET: ::ULONG = 0x20; pub const KERB_RETRIEVE_TICKET_MAX_LIFETIME: ::ULONG = 0x40; STRUCT!{struct KERB_AUTH_DATA { Type: ::ULONG, Length: ::ULONG, Data: ::PUCHAR, }} pub type PKERB_AUTH_DATA = *mut KERB_AUTH_DATA; STRUCT!{struct KERB_NET_ADDRESS { Family: ::ULONG, Length: ::ULONG, Address: ::PUCHAR, }} pub type PKERB_NET_ADDRESS = *mut KERB_NET_ADDRESS; STRUCT!{struct KERB_NET_ADDRESSES { Number: ::ULONG, Addresses: [KERB_NET_ADDRESS; ::ANYSIZE_ARRAY], }} pub type PKERB_NET_ADDRESSES = *mut KERB_NET_ADDRESSES; STRUCT!{struct KERB_EXTERNAL_NAME { NameType: ::SHORT, NameCount: ::USHORT, Names: [::UNICODE_STRING; ::ANYSIZE_ARRAY], }} pub type PKERB_EXTERNAL_NAME = *mut KERB_EXTERNAL_NAME; STRUCT!{struct KERB_EXTERNAL_TICKET { ServiceName: PKERB_EXTERNAL_NAME, TargetName: PKERB_EXTERNAL_NAME, ClientName: PKERB_EXTERNAL_NAME, DomainName: ::UNICODE_STRING, TargetDomainName: ::UNICODE_STRING, AltTargetDomainName: ::UNICODE_STRING, SessionKey: KERB_CRYPTO_KEY, TicketFlags: ::ULONG, Flags: ::ULONG, KeyExpirationTime: ::LARGE_INTEGER, StartTime: ::LARGE_INTEGER, EndTime: ::LARGE_INTEGER, RenewUntil: ::LARGE_INTEGER, TimeSkew: ::LARGE_INTEGER, EncodedTicketSize: ::ULONG, EncodedTicket: ::PUCHAR, }} pub type PKERB_EXTERNAL_TICKET = *mut KERB_EXTERNAL_TICKET; STRUCT!{struct KERB_RETRIEVE_TKT_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, LogonId: ::LUID, TargetName: ::UNICODE_STRING, TicketFlags: ::ULONG, CacheOptions: ::ULONG, EncryptionType: ::LONG, CredentialsHandle: ::SecHandle, }} pub type PKERB_RETRIEVE_TKT_REQUEST = *mut KERB_RETRIEVE_TKT_REQUEST; STRUCT!{struct KERB_RETRIEVE_TKT_RESPONSE { Ticket: KERB_EXTERNAL_TICKET, }} pub type PKERB_RETRIEVE_TKT_RESPONSE = *mut KERB_RETRIEVE_TKT_RESPONSE; STRUCT!{struct KERB_PURGE_TKT_CACHE_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, LogonId: ::LUID, ServerName: ::UNICODE_STRING, RealmName: ::UNICODE_STRING, }} pub type PKERB_PURGE_TKT_CACHE_REQUEST = *mut KERB_PURGE_TKT_CACHE_REQUEST; pub const KERB_PURGE_ALL_TICKETS: ::ULONG = 1; STRUCT!{struct KERB_PURGE_TKT_CACHE_EX_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, LogonId: ::LUID, Flags: ::ULONG, TicketTemplate: KERB_TICKET_CACHE_INFO_EX, }} pub type PKERB_PURGE_TKT_CACHE_EX_REQUEST = *mut KERB_PURGE_TKT_CACHE_EX_REQUEST; STRUCT!{struct KERB_SUBMIT_TKT_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, LogonId: ::LUID, Flags: ::ULONG, Key: KERB_CRYPTO_KEY32, KerbCredSize: ::ULONG, KerbCredOffset: ::ULONG, }} pub type PKERB_SUBMIT_TKT_REQUEST = *mut KERB_SUBMIT_TKT_REQUEST; STRUCT!{struct KERB_QUERY_KDC_PROXY_CACHE_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, Flags: ::ULONG, LogonId: ::LUID, }} pub type PKERB_QUERY_KDC_PROXY_CACHE_REQUEST = *mut KERB_QUERY_KDC_PROXY_CACHE_REQUEST; STRUCT!{struct KDC_PROXY_CACHE_ENTRY_DATA { SinceLastUsed: ::ULONG64, DomainName: ::UNICODE_STRING, ProxyServerName: ::UNICODE_STRING, ProxyServerVdir: ::UNICODE_STRING, ProxyServerPort: ::USHORT, LogonId: ::LUID, CredUserName: ::UNICODE_STRING, CredDomainName: ::UNICODE_STRING, GlobalCache: ::BOOLEAN, }} pub type PKDC_PROXY_CACHE_ENTRY_DATA = *mut KDC_PROXY_CACHE_ENTRY_DATA; STRUCT!{struct KERB_QUERY_KDC_PROXY_CACHE_RESPONSE { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, CountOfEntries: ::ULONG, Entries: PKDC_PROXY_CACHE_ENTRY_DATA, }} pub type PKERB_QUERY_KDC_PROXY_CACHE_RESPONSE = *mut KERB_QUERY_KDC_PROXY_CACHE_RESPONSE; STRUCT!{struct KERB_PURGE_KDC_PROXY_CACHE_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, Flags: ::ULONG, LogonId: ::LUID, }} pub type PKERB_PURGE_KDC_PROXY_CACHE_REQUEST = *mut KERB_PURGE_KDC_PROXY_CACHE_REQUEST; STRUCT!{struct KERB_PURGE_KDC_PROXY_CACHE_RESPONSE { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, CountOfPurged: ::ULONG, }} pub type PKERB_PURGE_KDC_PROXY_CACHE_RESPONSE = *mut KERB_PURGE_KDC_PROXY_CACHE_RESPONSE; pub const KERB_S4U2PROXY_CACHE_ENTRY_INFO_FLAG_NEGATIVE: ::ULONG = 0x1; STRUCT!{struct KERB_S4U2PROXY_CACHE_ENTRY_INFO { ServerName: ::UNICODE_STRING, Flags: ::ULONG, LastStatus: ::NTSTATUS, Expiry: ::LARGE_INTEGER, }} pub type PKERB_S4U2PROXY_CACHE_ENTRY_INFO = *mut KERB_S4U2PROXY_CACHE_ENTRY_INFO; pub const KERB_S4U2PROXY_CRED_FLAG_NEGATIVE: ::ULONG = 0x1; STRUCT!{struct KERB_S4U2PROXY_CRED { UserName: ::UNICODE_STRING, DomainName: ::UNICODE_STRING, Flags: ::ULONG, LastStatus: ::NTSTATUS, Expiry: ::LARGE_INTEGER, CountOfEntries: ::ULONG, Entries: PKERB_S4U2PROXY_CACHE_ENTRY_INFO, }} pub type PKERB_S4U2PROXY_CRED = *mut KERB_S4U2PROXY_CRED; STRUCT!{struct KERB_QUERY_S4U2PROXY_CACHE_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, Flags: ::ULONG, LogonId: ::LUID, }} pub type PKERB_QUERY_S4U2PROXY_CACHE_REQUEST = *mut KERB_QUERY_S4U2PROXY_CACHE_REQUEST; STRUCT!{struct KERB_QUERY_S4U2PROXY_CACHE_RESPONSE { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, CountOfCreds: ::ULONG, Creds: PKERB_S4U2PROXY_CRED, }} pub type PKERB_QUERY_S4U2PROXY_CACHE_RESPONSE = *mut KERB_QUERY_S4U2PROXY_CACHE_RESPONSE; STRUCT!{struct KERB_CHANGEPASSWORD_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, DomainName: ::UNICODE_STRING, AccountName: ::UNICODE_STRING, OldPassword: ::UNICODE_STRING, NewPassword: ::UNICODE_STRING, Impersonating: ::BOOLEAN, }} pub type PKERB_CHANGEPASSWORD_REQUEST = *mut KERB_CHANGEPASSWORD_REQUEST; STRUCT!{struct KERB_SETPASSWORD_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, LogonId: ::LUID, CredentialsHandle: ::SecHandle, Flags: ::ULONG, DomainName: ::UNICODE_STRING, AccountName: ::UNICODE_STRING, Password: ::UNICODE_STRING, }} pub type PKERB_SETPASSWORD_REQUEST = *mut KERB_SETPASSWORD_REQUEST; STRUCT!{struct KERB_SETPASSWORD_EX_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, LogonId: ::LUID, CredentialsHandle: ::SecHandle, Flags: ::ULONG, AccountRealm: ::UNICODE_STRING, AccountName: ::UNICODE_STRING, Password: ::UNICODE_STRING, ClientRealm: ::UNICODE_STRING, ClientName: ::UNICODE_STRING, Impersonating: ::BOOLEAN, KdcAddress: ::UNICODE_STRING, KdcAddressType: ::ULONG, }} pub type PKERB_SETPASSWORD_EX_REQUEST = *mut KERB_SETPASSWORD_EX_REQUEST; pub const DS_UNKNOWN_ADDRESS_TYPE: ::ULONG = 0; pub const KERB_SETPASS_USE_LOGONID: ::ULONG = 1; pub const KERB_SETPASS_USE_CREDHANDLE: ::ULONG = 2; STRUCT!{struct KERB_DECRYPT_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, LogonId: ::LUID, Flags: ::ULONG, CryptoType: ::LONG, KeyUsage: ::LONG, Key: KERB_CRYPTO_KEY, EncryptedDataSize: ::ULONG, InitialVectorSize: ::ULONG, InitialVector: ::PUCHAR, EncryptedData: ::PUCHAR, }} pub type PKERB_DECRYPT_REQUEST = *mut KERB_DECRYPT_REQUEST; pub const KERB_DECRYPT_FLAG_DEFAULT_KEY: ::ULONG = 0x00000001; STRUCT!{struct KERB_DECRYPT_RESPONSE { DecryptedData: [::UCHAR; ::ANYSIZE_ARRAY], }} pub type PKERB_DECRYPT_RESPONSE = *mut KERB_DECRYPT_RESPONSE; STRUCT!{struct KERB_ADD_BINDING_CACHE_ENTRY_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, RealmName: ::UNICODE_STRING, KdcAddress: ::UNICODE_STRING, AddressType: ::ULONG, }} pub type PKERB_ADD_BINDING_CACHE_ENTRY_REQUEST = *mut KERB_ADD_BINDING_CACHE_ENTRY_REQUEST; STRUCT!{struct KERB_REFRESH_SCCRED_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, CredentialBlob: ::UNICODE_STRING, LogonId: ::LUID, Flags: ::ULONG, }} pub type PKERB_REFRESH_SCCRED_REQUEST = *mut KERB_REFRESH_SCCRED_REQUEST; pub const KERB_REFRESH_SCCRED_RELEASE: ::ULONG = 0x0; pub const KERB_REFRESH_SCCRED_GETTGT: ::ULONG = 0x1; STRUCT!{struct KERB_ADD_CREDENTIALS_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, UserName: ::UNICODE_STRING, DomainName: ::UNICODE_STRING, Password: ::UNICODE_STRING, LogonId: ::LUID, Flags: ::ULONG, }} pub type PKERB_ADD_CREDENTIALS_REQUEST = *mut KERB_ADD_CREDENTIALS_REQUEST; pub const KERB_REQUEST_ADD_CREDENTIAL: ::ULONG = 1; pub const KERB_REQUEST_REPLACE_CREDENTIAL: ::ULONG = 2; pub const KERB_REQUEST_REMOVE_CREDENTIAL: ::ULONG = 4; STRUCT!{struct KERB_ADD_CREDENTIALS_REQUEST_EX { Credentials: KERB_ADD_CREDENTIALS_REQUEST, PrincipalNameCount: ::ULONG, PrincipalNames: [::UNICODE_STRING; ::ANYSIZE_ARRAY], }} pub type PKERB_ADD_CREDENTIALS_REQUEST_EX = *mut KERB_ADD_CREDENTIALS_REQUEST_EX; STRUCT!{struct KERB_TRANSFER_CRED_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, OriginLogonId: ::LUID, DestinationLogonId: ::LUID, Flags: ::ULONG, }} pub type PKERB_TRANSFER_CRED_REQUEST = *mut KERB_TRANSFER_CRED_REQUEST; pub const KERB_TRANSFER_CRED_WITH_TICKETS: ::ULONG = 0x1; pub const KERB_TRANSFER_CRED_CLEANUP_CREDENTIALS: ::ULONG = 0x2; STRUCT!{struct KERB_CLEANUP_MACHINE_PKINIT_CREDS_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, LogonId: ::LUID, }} pub type PKERB_CLEANUP_MACHINE_PKINIT_CREDS_REQUEST = *mut KERB_CLEANUP_MACHINE_PKINIT_CREDS_REQUEST; STRUCT!{struct KERB_BINDING_CACHE_ENTRY_DATA { DiscoveryTime: ::ULONG64, RealmName: ::UNICODE_STRING, KdcAddress: ::UNICODE_STRING, AddressType: ::ULONG, Flags: ::ULONG, DcFlags: ::ULONG, CacheFlags: ::ULONG, KdcName: ::UNICODE_STRING, }} pub type PKERB_BINDING_CACHE_ENTRY_DATA = *mut KERB_BINDING_CACHE_ENTRY_DATA; STRUCT!{struct KERB_QUERY_BINDING_CACHE_RESPONSE { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, CountOfEntries: ::ULONG, Entries: PKERB_BINDING_CACHE_ENTRY_DATA, }} pub type PKERB_QUERY_BINDING_CACHE_RESPONSE = *mut KERB_QUERY_BINDING_CACHE_RESPONSE; STRUCT!{struct KERB_ADD_BINDING_CACHE_ENTRY_EX_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, RealmName: ::UNICODE_STRING, KdcAddress: ::UNICODE_STRING, AddressType: ::ULONG, DcFlags: ::ULONG, }} pub type PKERB_ADD_BINDING_CACHE_ENTRY_EX_REQUEST = *mut KERB_ADD_BINDING_CACHE_ENTRY_EX_REQUEST; STRUCT!{struct KERB_QUERY_BINDING_CACHE_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, }} pub type PKERB_QUERY_BINDING_CACHE_REQUEST = *mut KERB_QUERY_BINDING_CACHE_REQUEST; STRUCT!{struct KERB_PURGE_BINDING_CACHE_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, }} pub type PKERB_PURGE_BINDING_CACHE_REQUEST = *mut KERB_PURGE_BINDING_CACHE_REQUEST; STRUCT!{struct KERB_QUERY_DOMAIN_EXTENDED_POLICIES_REQUEST { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, Flags: ::ULONG, DomainName: ::UNICODE_STRING, }} pub type PKERB_QUERY_DOMAIN_EXTENDED_POLICIES_REQUEST = *mut KERB_QUERY_DOMAIN_EXTENDED_POLICIES_REQUEST; STRUCT!{struct KERB_QUERY_DOMAIN_EXTENDED_POLICIES_RESPONSE { MessageType: KERB_PROTOCOL_MESSAGE_TYPE, Flags: ::ULONG, ExtendedPolicies: ::ULONG, DsFlags: ::ULONG, }} pub type PKERB_QUERY_DOMAIN_EXTENDED_POLICIES_RESPONSE = *mut KERB_QUERY_DOMAIN_EXTENDED_POLICIES_RESPONSE; ENUM!{enum KERB_CERTIFICATE_INFO_TYPE { CertHashInfo = 1, }} pub type PKERB_CERTIFICATE_INFO_TYPE = *mut KERB_CERTIFICATE_INFO_TYPE; STRUCT!{struct KERB_CERTIFICATE_HASHINFO { StoreNameLength: ::USHORT, HashLength: ::USHORT, }} pub type PKERB_CERTIFICATE_HASHINFO = *mut KERB_CERTIFICATE_HASHINFO; STRUCT!{struct KERB_CERTIFICATE_INFO { CertInfoSize: ::ULONG, InfoType: ::ULONG, }} pub type PKERB_CERTIFICATE_INFO = *mut KERB_CERTIFICATE_INFO; STRUCT!{struct POLICY_AUDIT_SID_ARRAY { UsersCount: ::ULONG, UserSidArray: *mut ::PSID, }} pub type PPOLICY_AUDIT_SID_ARRAY = *mut POLICY_AUDIT_SID_ARRAY; STRUCT!{struct AUDIT_POLICY_INFORMATION { AuditSubCategoryGuid: ::GUID, AuditingInformation: ::ULONG, AuditCategoryGuid: ::GUID, }} pub type PAUDIT_POLICY_INFORMATION = *mut AUDIT_POLICY_INFORMATION; pub type LPAUDIT_POLICY_INFORMATION = PAUDIT_POLICY_INFORMATION; pub type PCAUDIT_POLICY_INFORMATION = *const AUDIT_POLICY_INFORMATION; pub const AUDIT_SET_SYSTEM_POLICY: ::ULONG = 0x0001; pub const AUDIT_QUERY_SYSTEM_POLICY: ::ULONG = 0x0002; pub const AUDIT_SET_USER_POLICY: ::ULONG = 0x0004; pub const AUDIT_QUERY_USER_POLICY: ::ULONG = 0x0008; pub const AUDIT_ENUMERATE_USERS: ::ULONG = 0x0010; pub const AUDIT_SET_MISC_POLICY: ::ULONG = 0x0020; pub const AUDIT_QUERY_MISC_POLICY: ::ULONG = 0x0040; pub const AUDIT_GENERIC_ALL: ::ULONG = ::STANDARD_RIGHTS_REQUIRED | AUDIT_SET_SYSTEM_POLICY | AUDIT_QUERY_SYSTEM_POLICY | AUDIT_SET_USER_POLICY | AUDIT_QUERY_USER_POLICY | AUDIT_ENUMERATE_USERS | AUDIT_SET_MISC_POLICY | AUDIT_QUERY_MISC_POLICY; pub const AUDIT_GENERIC_READ: ::ULONG = ::STANDARD_RIGHTS_READ | AUDIT_QUERY_SYSTEM_POLICY | AUDIT_QUERY_USER_POLICY | AUDIT_ENUMERATE_USERS | AUDIT_QUERY_MISC_POLICY; pub const AUDIT_GENERIC_WRITE: ::ULONG = ::STANDARD_RIGHTS_WRITE | AUDIT_SET_USER_POLICY | AUDIT_SET_MISC_POLICY | AUDIT_SET_SYSTEM_POLICY; pub const AUDIT_GENERIC_EXECUTE: ::ULONG = ::STANDARD_RIGHTS_EXECUTE; STRUCT!{struct PKU2U_CERT_BLOB { CertOffset: ::ULONG, CertLength: ::USHORT, }} pub type PPKU2U_CERT_BLOB = *mut PKU2U_CERT_BLOB; pub const PKU2U_CREDUI_CONTEXT_VERSION: ::ULONG64 = 0x4154414454524543; STRUCT!{struct PKU2U_CREDUI_CONTEXT { Version: ::ULONG64, cbHeaderLength: ::USHORT, cbStructureLength: ::ULONG, CertArrayCount: ::USHORT, CertArrayOffset: ::ULONG, }} pub type PPKU2U_CREDUI_CONTEXT = *mut PKU2U_CREDUI_CONTEXT; ENUM!{enum PKU2U_LOGON_SUBMIT_TYPE { Pku2uCertificateS4ULogon = 14, }} pub type PPKU2U_LOGON_SUBMIT_TYPE = *mut PKU2U_LOGON_SUBMIT_TYPE; STRUCT!{struct PKU2U_CERTIFICATE_S4U_LOGON { MessageType: PKU2U_LOGON_SUBMIT_TYPE, Flags: ::ULONG, UserPrincipalName: ::UNICODE_STRING, DomainName: ::UNICODE_STRING, CertificateLength: ::ULONG, Certificate: ::PUCHAR, }} pub type PPKU2U_CERTIFICATE_S4U_LOGON = *mut PKU2U_CERTIFICATE_S4U_LOGON; deps/winapi-0.2.5/src/dsound.rs0000644000000000000000000001276012613167613015103 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! DSound procedure declarations, constant definitions and macros STRUCT!{struct DSCAPS { dwSize: ::DWORD, dwFlags: ::DWORD, dwMinSecondarySampleRate: ::DWORD, dwMaxSecondarySampleRate: ::DWORD, dwPrimaryBuffers: ::DWORD, dwMaxHwMixingAllBuffers: ::DWORD, dwMaxHwMixingStaticBuffers: ::DWORD, dwMaxHwMixingStreamingBuffers: ::DWORD, dwFreeHwMixingAllBuffers: ::DWORD, dwFreeHwMixingStaticBuffers: ::DWORD, dwFreeHwMixingStreamingBuffers: ::DWORD, dwMaxHw3DAllBuffers: ::DWORD, dwMaxHw3DStaticBuffers: ::DWORD, dwMaxHw3DStreamingBuffers: ::DWORD, dwFreeHw3DAllBuffers: ::DWORD, dwFreeHw3DStaticBuffers: ::DWORD, dwFreeHw3DStreamingBuffers: ::DWORD, dwTotalHwMemBytes: ::DWORD, dwFreeHwMemBytes: ::DWORD, dwMaxContigFreeHwMemBytes: ::DWORD, dwUnlockTransferRateHwBuffers: ::DWORD, dwPlayCpuOverheadSwBuffers: ::DWORD, dwReserved1: ::DWORD, dwReserved2: ::DWORD, }} pub type LPDSCAPS = *mut DSCAPS; STRUCT!{struct DSBCAPS { dwSize: ::DWORD, dwFlags: ::DWORD, dwBufferBytes: ::DWORD, dwUnlockTransferRate: ::DWORD, dwPlayCpuOverhead: ::DWORD, }} pub type LPDSBCAPS = *mut DSBCAPS; STRUCT!{struct DSBUFFERDESC { dwSize: ::DWORD, dwFlags: ::DWORD, dwBufferBytes: ::DWORD, dwReserved: ::DWORD, lpwfxFormat: ::LPWAVEFORMATEX, guid3DAlgorithm: ::GUID, }} pub type LPCDSBUFFERDESC = *const DSBUFFERDESC; RIDL!( interface IDirectSoundBuffer(IDirectSoundBufferVtbl): IUnknown(IUnknownVtbl) { fn GetCaps(&mut self, pDSBufferCaps: ::LPDSBCAPS) -> ::HRESULT, fn GetCurrentPosition( &mut self, pdwCurrentPlayCursor: ::LPDWORD, pdwCurrentWriteCursor: ::LPDWORD ) -> ::HRESULT, fn GetFormat( &mut self, pwfxFormat: ::LPWAVEFORMATEX, dwSizeAllocated: ::DWORD, pdwSizeWritten: ::LPDWORD ) -> ::HRESULT, fn GetVolume(&mut self, plVolume: ::LPLONG) -> ::HRESULT, fn GetPan(&mut self, plPan: ::LPLONG) -> ::HRESULT, fn GetFrequency(&mut self, pdwFrequency: ::LPDWORD) -> ::HRESULT, fn GetStatus(&mut self, pdwStatus: ::LPDWORD) -> ::HRESULT, fn Initialize( &mut self, pDirectSound: ::LPDIRECTSOUND, pcDSBufferDesc: ::LPCDSBUFFERDESC ) -> ::HRESULT, fn Lock( &mut self, dwOffset: ::DWORD, dwBytes: ::DWORD, ppvAudioPtr1: *mut ::LPVOID, pdwAudioBytes1: ::LPDWORD, ppvAudioPtr2: *mut ::LPVOID, pdwAudioBytes2: ::LPDWORD, dwFlags: ::DWORD ) -> ::HRESULT, fn Play(&mut self, dwReserved1: ::DWORD, dwPriority: ::DWORD, dwFlags: ::DWORD) -> ::HRESULT, fn SetCurrentPosition(&mut self, dwNewPosition: ::DWORD) -> ::HRESULT, fn SetFormat(&mut self, pcfxFormat: ::LPCWAVEFORMATEX) -> ::HRESULT, fn SetVolume(&mut self, lVolume: ::LONG) -> ::HRESULT, fn SetPan(&mut self, lPan: ::LONG) -> ::HRESULT, fn SetFrequency(&mut self, dwFrequency: ::DWORD) -> ::HRESULT, fn Stop(&mut self) -> ::HRESULT, fn Unlock( &mut self, pvAudioPtr1: ::LPVOID, dwAudioBytes1: ::DWORD, pvAudioPtr2: ::LPVOID, dwAudioBytes2: ::DWORD ) -> ::HRESULT, fn Restore(&mut self) -> ::HRESULT } ); pub type LPDIRECTSOUNDBUFFER = *mut IDirectSoundBuffer; RIDL!( interface IDirectSound(IDirectSoundVtbl): IUnknown(IUnknownVtbl) { fn CreateSoundBuffer( &mut self, pcDSBufferDesc: ::LPCDSBUFFERDESC, ppDSBuffer: *mut ::LPDIRECTSOUNDBUFFER, pUnkOuter: ::LPUNKNOWN ) -> ::HRESULT, fn GetCaps(&mut self, pDSCaps: ::LPDSCAPS) -> ::HRESULT, fn DuplicateSoundBuffer( &mut self, pDSBufferOriginal: LPDIRECTSOUNDBUFFER, ppDSBufferDuplicate: *mut ::LPDIRECTSOUNDBUFFER ) -> ::HRESULT, fn SetCooperativeLevel(&mut self, hWnd: ::HWND, dwLevel: ::DWORD) -> ::HRESULT, fn Compact(&mut self) -> ::HRESULT, fn GetSpeakerConfig(&mut self, pdwSpeakerConfig: ::LPDWORD) -> ::HRESULT, fn SetSpeakerConfig(&mut self, dwSpeakerConfig: ::DWORD) -> ::HRESULT, fn Initialize(&mut self, pcGuidDevice: ::LPCGUID) -> ::HRESULT } ); pub type LPDIRECTSOUND = *mut IDirectSound; pub const DS_OK: ::HRESULT = ::S_OK; pub const DSERR_GENERIC: ::HRESULT = ::E_FAIL; pub const DSSCL_NORMAL: ::DWORD = 0x00000001; pub const DSSCL_PRIORITY: ::DWORD = 0x00000002; pub const DSSCL_EXCLUSIVE: ::DWORD = 0x00000003; pub const DSSCL_WRITEPRIMARY: ::DWORD = 0x00000004; pub const DSBCAPS_PRIMARYBUFFER: ::DWORD = 0x00000001; pub const DSBCAPS_STATIC: ::DWORD = 0x00000002; pub const DSBCAPS_LOCHARDWARE: ::DWORD = 0x00000004; pub const DSBCAPS_LOCSOFTWARE: ::DWORD = 0x00000008; pub const DSBCAPS_CTRL3D: ::DWORD = 0x00000010; pub const DSBCAPS_CTRLFREQUENCY: ::DWORD = 0x00000020; pub const DSBCAPS_CTRLPAN: ::DWORD = 0x00000040; pub const DSBCAPS_CTRLVOLUME: ::DWORD = 0x00000080; pub const DSBCAPS_CTRLPOSITIONNOTIFY: ::DWORD = 0x00000100; pub const DSBCAPS_CTRLFX: ::DWORD = 0x00000200; pub const DSBCAPS_STICKYFOCUS: ::DWORD = 0x00004000; pub const DSBCAPS_GLOBALFOCUS: ::DWORD = 0x00008000; pub const DSBCAPS_GETCURRENTPOSITION2: ::DWORD = 0x00010000; pub const DSBCAPS_MUTE3DATMAXDISTANCE: ::DWORD = 0x00020000; pub const DSBCAPS_LOCDEFER: ::DWORD = 0x00040000; pub const DSBCAPS_TRUEPLAYPOSITION: ::DWORD = 0x00080000; pub const DSBPLAY_LOOPING: ::DWORD = 0x00000001; pub const DSBPLAY_LOCHARDWARE: ::DWORD = 0x00000002; pub const DSBPLAY_LOCSOFTWARE: ::DWORD = 0x00000004; pub const DSBPLAY_TERMINATEBY_TIME: ::DWORD = 0x00000008; pub const DSBPLAY_TERMINATEBY_DISTANCE: ::DWORD = 0x000000010; pub const DSBPLAY_TERMINATEBY_PRIORITY: ::DWORD = 0x000000020; deps/winapi-0.2.5/src/tlhelp32.rs0000644000000000000000000000743312613167613015245 0ustar rootroot// Copyright © 2015, Gigih Aji Ibrahim // Licensed under the MIT License pub const MAX_MODULE_NAME32: usize = 255; pub const TH32CS_SNAPHEAPLIST: ::DWORD = 0x00000001; pub const TH32CS_SNAPPROCESS: ::DWORD = 0x00000002; pub const TH32CS_SNAPTHREAD: ::DWORD = 0x00000004; pub const TH32CS_SNAPMODULE: ::DWORD = 0x00000008; pub const TH32CS_SNAPMODULE32: ::DWORD = 0x00000010; pub const TH32CS_SNAPALL: ::DWORD = (TH32CS_SNAPHEAPLIST | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD | TH32CS_SNAPMODULE); pub const TH32CS_INHERIT: ::DWORD = 0x80000000; STRUCT!{struct HEAPLIST32 { dwSize: ::SIZE_T, th32ProcessID: ::DWORD, th32HeapID: :: ULONG_PTR, dwFlags: ::DWORD, }} pub type PHEAPLIST32 = *mut HEAPLIST32; pub type LPHEAPLIST32 = *mut HEAPLIST32; pub const HF32_DEFAULT: ::DWORD = 1; pub const HF32_SHARED: ::DWORD = 2; STRUCT!{struct HEAPENTRY32 { dwSize: ::SIZE_T, hHandle: ::HANDLE, dwAddress: ::ULONG_PTR, dwBlockSize: ::SIZE_T, dwFlags: ::DWORD, dwLockCount: ::DWORD, dwResvd: ::DWORD, th32ProcessID: ::DWORD, th32HeapID: ::ULONG_PTR, }} pub type PHEAPENTRY32 = *mut HEAPENTRY32; pub type LPHEAPENTRY32 = *mut HEAPENTRY32; pub const LF32_FIXED: ::DWORD = 0x00000001; pub const LF32_FREE: ::DWORD = 0x00000002; pub const LF32_MOVEABLE: ::DWORD = 0x00000004; #[repr(C)] #[derive(Copy)] pub struct PROCESSENTRY32W { pub dwSize: ::DWORD, pub cntUsage: ::DWORD, pub th32ProcessID: ::DWORD, pub th32DefaultHeapID: ::ULONG_PTR, pub th32ModuleID: ::DWORD, pub cntThreads: ::DWORD, pub th32ParentProcessID: ::DWORD, pub pcPriClassBase: ::LONG, pub dwFlags: ::DWORD, pub szExeFile: [::WCHAR; ::MAX_PATH], } impl Clone for PROCESSENTRY32W{ fn clone(&self) -> PROCESSENTRY32W { *self } } pub type PPROCESSENTRY32W = *mut PROCESSENTRY32W; pub type LPPROCESSENTRY32W = *mut PROCESSENTRY32W; #[repr(C)] #[derive(Copy)] pub struct PROCESSENTRY32 { pub dwSize: ::DWORD, pub cntUsage: ::DWORD, pub th32ProcessID: ::DWORD, pub th32DefaultHeapID: ::ULONG_PTR, pub th32ModuleID: ::DWORD, pub cntThreads: ::DWORD, pub th32ParentProcessID: ::DWORD, pub pcPriClassBase: ::LONG, pub dwFlags: ::DWORD, pub szExeFile: [::CHAR; ::MAX_PATH], } impl Clone for PROCESSENTRY32{ fn clone(&self) -> PROCESSENTRY32 { *self } } pub type PPROCESSENTRY32 = *mut PROCESSENTRY32; pub type LPPROCESSENTRY32 = *mut PROCESSENTRY32; STRUCT!{struct THREADENTRY32 { dwSize: ::DWORD, cntUsage: ::DWORD, th32ThreadID: ::DWORD, th32OwnerProcessID: ::DWORD, tpBasePri: ::LONG, tpDeltaPri: ::LONG, dwFlags: ::DWORD, }} pub type PTHREADENTRY32 = *mut THREADENTRY32; pub type LPTHREADENTRY32 = *mut THREADENTRY32; #[repr(C)] #[derive(Copy)] pub struct MODULEENTRY32W { pub dwSize: ::DWORD, pub th32ModuleID: ::DWORD, pub th32ProcessID: ::DWORD, pub GlblcntUsage: ::DWORD, pub ProccntUsage: ::DWORD, pub modBaseAddr: *mut ::BYTE, pub modBaseSize: ::DWORD, pub hModule: ::HMODULE, pub szModule: [::WCHAR; ::MAX_MODULE_NAME32 + 1], pub szExePath: [::WCHAR; ::MAX_PATH], } impl Clone for MODULEENTRY32W{ fn clone(&self) -> MODULEENTRY32W { *self } } pub type PMODULEENTRY32W = *mut MODULEENTRY32W; pub type LPMODULEENTRY32W = *mut MODULEENTRY32W; #[repr(C)] #[derive(Copy)] pub struct MODULEENTRY32 { pub dwSize: ::DWORD, pub th32ModuleID: ::DWORD, pub th32ProcessID: ::DWORD, pub GlblcntUsage: ::DWORD, pub ProccntUsage: ::DWORD, pub modBaseAddr: *mut ::BYTE, pub modBaseSize: ::DWORD, pub hModule: ::HMODULE, pub szModule: [::CHAR; ::MAX_MODULE_NAME32 + 1], pub szExePath: [::CHAR; ::MAX_PATH], } impl Clone for MODULEENTRY32{ fn clone(&self) -> MODULEENTRY32 { *self } } pub type PMODULEENTRY32 = *mut MODULEENTRY32; pub type LPMODULEENTRY32 = *mut MODULEENTRY32; deps/winapi-0.2.5/src/dsrole.rs0000644000000000000000000000345212613167613015075 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Contains public interfaces to query the network roles of workstations, servers, and DCs ENUM!{enum DSROLE_MACHINE_ROLE { DsRole_RoleStandaloneWorkstation, DsRole_RoleMemberWorkstation, DsRole_RoleStandaloneServer, DsRole_RoleMemberServer, DsRole_RoleBackupDomainController, DsRole_RolePrimaryDomainController, }} ENUM!{enum DSROLE_SERVER_STATE { DsRoleServerUnknown = 0, DsRoleServerPrimary, DsRoleServerBackup, }} pub type PDSROLE_SERVER_STATE = *mut DSROLE_SERVER_STATE; ENUM!{enum DSROLE_PRIMARY_DOMAIN_INFO_LEVEL { DsRolePrimaryDomainInfoBasic = 1, DsRoleUpgradeStatus, DsRoleOperationState, }} pub const DSROLE_PRIMARY_DS_RUNNING: ::ULONG = 0x00000001; pub const DSROLE_PRIMARY_DS_MIXED_MODE: ::ULONG = 0x00000002; pub const DSROLE_UPGRADE_IN_PROGRESS: ::ULONG = 0x00000004; pub const DSROLE_PRIMARY_DS_READONLY: ::ULONG = 0x00000008; pub const DSROLE_PRIMARY_DOMAIN_GUID_PRESENT: ::ULONG = 0x01000000; STRUCT!{struct DSROLE_PRIMARY_DOMAIN_INFO_BASIC { MachineRole: DSROLE_MACHINE_ROLE, Flags: ::ULONG, DomainNameFlat: ::LPWSTR, DomainNameDns: ::LPWSTR, DomainForestName: ::LPWSTR, DomainGuid: ::GUID, }} pub type PDSROLE_PRIMARY_DOMAIN_INFO_BASIC = *mut DSROLE_PRIMARY_DOMAIN_INFO_BASIC; STRUCT!{struct DSROLE_UPGRADE_STATUS_INFO { OperationState: ::ULONG, PreviousServerState: DSROLE_SERVER_STATE, }} pub type PDSROLE_UPGRADE_STATUS_INFO = *mut DSROLE_UPGRADE_STATUS_INFO; ENUM!{enum DSROLE_OPERATION_STATE { DsRoleOperationIdle = 0, DsRoleOperationActive, DsRoleOperationNeedReboot, }} STRUCT!{struct DSROLE_OPERATION_STATE_INFO { OperationState: DSROLE_OPERATION_STATE, }} pub type PDSROLE_OPERATION_STATE_INFO = *mut DSROLE_OPERATION_STATE_INFO; deps/winapi-0.2.5/src/dsgetdc.rs0000644000000000000000000001217212613167613015221 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! This file contains structures, function prototypes, and definitions for the DsGetDcName API. pub const DS_FORCE_REDISCOVERY: ::ULONG = 0x00000001; pub const DS_DIRECTORY_SERVICE_REQUIRED: ::ULONG = 0x00000010; pub const DS_DIRECTORY_SERVICE_PREFERRED: ::ULONG = 0x00000020; pub const DS_GC_SERVER_REQUIRED: ::ULONG = 0x00000040; pub const DS_PDC_REQUIRED: ::ULONG = 0x00000080; pub const DS_BACKGROUND_ONLY: ::ULONG = 0x00000100; pub const DS_IP_REQUIRED: ::ULONG = 0x00000200; pub const DS_KDC_REQUIRED: ::ULONG = 0x00000400; pub const DS_TIMESERV_REQUIRED: ::ULONG = 0x00000800; pub const DS_WRITABLE_REQUIRED: ::ULONG = 0x00001000; pub const DS_GOOD_TIMESERV_PREFERRED: ::ULONG = 0x00002000; pub const DS_AVOID_SELF: ::ULONG = 0x00004000; pub const DS_ONLY_LDAP_NEEDED: ::ULONG = 0x00008000; pub const DS_IS_FLAT_NAME: ::ULONG = 0x00010000; pub const DS_IS_DNS_NAME: ::ULONG = 0x00020000; pub const DS_TRY_NEXTCLOSEST_SITE: ::ULONG = 0x00040000; pub const DS_DIRECTORY_SERVICE_6_REQUIRED: ::ULONG = 0x00080000; pub const DS_WEB_SERVICE_REQUIRED: ::ULONG = 0x00100000; pub const DS_DIRECTORY_SERVICE_8_REQUIRED: ::ULONG = 0x00200000; pub const DS_DIRECTORY_SERVICE_9_REQUIRED: ::ULONG = 0x00400000; pub const DS_RETURN_DNS_NAME: ::ULONG = 0x40000000; pub const DS_RETURN_FLAT_NAME: ::ULONG = 0x80000000; pub const DSGETDC_VALID_FLAGS: ::ULONG = DS_FORCE_REDISCOVERY | DS_DIRECTORY_SERVICE_REQUIRED | DS_DIRECTORY_SERVICE_PREFERRED | DS_GC_SERVER_REQUIRED | DS_PDC_REQUIRED | DS_BACKGROUND_ONLY | DS_IP_REQUIRED | DS_KDC_REQUIRED | DS_TIMESERV_REQUIRED | DS_WRITABLE_REQUIRED | DS_GOOD_TIMESERV_PREFERRED | DS_AVOID_SELF | DS_ONLY_LDAP_NEEDED | DS_IS_FLAT_NAME | DS_IS_DNS_NAME | DS_TRY_NEXTCLOSEST_SITE | DS_DIRECTORY_SERVICE_6_REQUIRED | DS_DIRECTORY_SERVICE_8_REQUIRED | DS_DIRECTORY_SERVICE_9_REQUIRED | DS_WEB_SERVICE_REQUIRED | DS_RETURN_FLAT_NAME | DS_RETURN_DNS_NAME; STRUCT!{struct DOMAIN_CONTROLLER_INFOA { DomainControllerName: ::LPSTR, DomainControllerAddress: ::LPSTR, DomainControllerAddressType: ::ULONG, DomainGuid: ::GUID, DomainName: ::LPSTR, DnsForestName: ::LPSTR, Flags: ::ULONG, DcSiteName: ::LPSTR, ClientSiteName: ::LPSTR, }} pub type PDOMAIN_CONTROLLER_INFOA = *mut DOMAIN_CONTROLLER_INFOA; STRUCT!{struct DOMAIN_CONTROLLER_INFOW { DomainControllerName: ::LPWSTR, DomainControllerAddress: ::LPWSTR, DomainControllerAddressType: ::ULONG, DomainGuid: ::GUID, DomainName: ::LPWSTR, DnsForestName: ::LPWSTR, Flags: ::ULONG, DcSiteName: ::LPWSTR, ClientSiteName: ::LPWSTR, }} pub type PDOMAIN_CONTROLLER_INFOW = *mut DOMAIN_CONTROLLER_INFOW; pub const DS_INET_ADDRESS: ::ULONG = 1; pub const DS_NETBIOS_ADDRESS: ::ULONG = 2; pub const DS_PDC_FLAG: ::ULONG = 0x00000001; pub const DS_GC_FLAG: ::ULONG = 0x00000004; pub const DS_LDAP_FLAG: ::ULONG = 0x00000008; pub const DS_DS_FLAG: ::ULONG = 0x00000010; pub const DS_KDC_FLAG: ::ULONG = 0x00000020; pub const DS_TIMESERV_FLAG: ::ULONG = 0x00000040; pub const DS_CLOSEST_FLAG: ::ULONG = 0x00000080; pub const DS_WRITABLE_FLAG: ::ULONG = 0x00000100; pub const DS_GOOD_TIMESERV_FLAG: ::ULONG = 0x00000200; pub const DS_NDNC_FLAG: ::ULONG = 0x00000400; pub const DS_SELECT_SECRET_DOMAIN_6_FLAG: ::ULONG = 0x00000800; pub const DS_FULL_SECRET_DOMAIN_6_FLAG: ::ULONG = 0x00001000; pub const DS_WS_FLAG: ::ULONG = 0x00002000; pub const DS_DS_8_FLAG: ::ULONG = 0x00004000; pub const DS_DS_9_FLAG: ::ULONG = 0x00008000; pub const DS_PING_FLAGS: ::ULONG = 0x000FFFFF; pub const DS_DNS_CONTROLLER_FLAG: ::ULONG = 0x20000000; pub const DS_DNS_DOMAIN_FLAG: ::ULONG = 0x40000000; pub const DS_DNS_FOREST_FLAG: ::ULONG = 0x80000000; pub const DS_DOMAIN_IN_FOREST: ::ULONG = 0x0001; pub const DS_DOMAIN_DIRECT_OUTBOUND: ::ULONG = 0x0002; pub const DS_DOMAIN_TREE_ROOT: ::ULONG = 0x0004; pub const DS_DOMAIN_PRIMARY: ::ULONG = 0x0008; pub const DS_DOMAIN_NATIVE_MODE: ::ULONG = 0x0010; pub const DS_DOMAIN_DIRECT_INBOUND: ::ULONG = 0x0020; pub const DS_DOMAIN_VALID_FLAGS: ::ULONG = DS_DOMAIN_IN_FOREST | DS_DOMAIN_DIRECT_OUTBOUND | DS_DOMAIN_TREE_ROOT | DS_DOMAIN_PRIMARY | DS_DOMAIN_NATIVE_MODE | DS_DOMAIN_DIRECT_INBOUND; STRUCT!{struct DS_DOMAIN_TRUSTSW { NetbiosDomainName: ::LPWSTR, DnsDomainName: ::LPWSTR, Flags: ::ULONG, ParentIndex: ::ULONG, TrustType: ::ULONG, TrustAttributes: ::ULONG, DomainSid: ::PSID, DomainGuid: ::GUID, }} pub type PDS_DOMAIN_TRUSTSW = *mut DS_DOMAIN_TRUSTSW; STRUCT!{struct DS_DOMAIN_TRUSTSA { NetbiosDomainName: ::LPSTR, DnsDomainName: ::LPSTR, Flags: ::ULONG, ParentIndex: ::ULONG, TrustType: ::ULONG, TrustAttributes: ::ULONG, DomainSid: ::PSID, DomainGuid: ::GUID, }} pub type PDS_DOMAIN_TRUSTSA = *mut DS_DOMAIN_TRUSTSA; pub const DS_ONLY_DO_SITE_NAME: ::ULONG = 0x01; pub const DS_NOTIFY_AFTER_SITE_RECORDS: ::ULONG = 0x02; pub const DS_OPEN_VALID_OPTION_FLAGS: ::ULONG = DS_ONLY_DO_SITE_NAME | DS_NOTIFY_AFTER_SITE_RECORDS; pub const DS_OPEN_VALID_FLAGS: ::ULONG = DS_FORCE_REDISCOVERY | DS_ONLY_LDAP_NEEDED | DS_KDC_REQUIRED | DS_PDC_REQUIRED | DS_GC_SERVER_REQUIRED | DS_WRITABLE_REQUIRED; deps/winapi-0.2.5/src/cfg.rs0000644000000000000000000001577612605021351014345 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! common Configuration Manager definitions for both user mode and kernel mode code ENUM!{enum PNP_VETO_TYPE { PNP_VetoTypeUnknown, PNP_VetoLegacyDevice, PNP_VetoPendingClose, PNP_VetoWindowsApp, PNP_VetoWindowsService, PNP_VetoOutstandingOpen, PNP_VetoDevice, PNP_VetoDriver, PNP_VetoIllegalDeviceRequest, PNP_VetoInsufficientPower, PNP_VetoNonDisableable, PNP_VetoLegacyDriver, PNP_VetoInsufficientRights, }} pub type PPNP_VETO_TYPE = *mut PNP_VETO_TYPE; pub const CM_PROB_NOT_CONFIGURED: ::CONFIGRET = 0x00000001; pub const CM_PROB_DEVLOADER_FAILED: ::CONFIGRET = 0x00000002; pub const CM_PROB_OUT_OF_MEMORY: ::CONFIGRET = 0x00000003; pub const CM_PROB_ENTRY_IS_WRONG_TYPE: ::CONFIGRET = 0x00000004; pub const CM_PROB_LACKED_ARBITRATOR: ::CONFIGRET = 0x00000005; pub const CM_PROB_BOOT_CONFIG_CONFLICT: ::CONFIGRET = 0x00000006; pub const CM_PROB_FAILED_FILTER: ::CONFIGRET = 0x00000007; pub const CM_PROB_DEVLOADER_NOT_FOUND: ::CONFIGRET = 0x00000008; pub const CM_PROB_INVALID_DATA: ::CONFIGRET = 0x00000009; pub const CM_PROB_FAILED_START: ::CONFIGRET = 0x0000000A; pub const CM_PROB_LIAR: ::CONFIGRET = 0x0000000B; pub const CM_PROB_NORMAL_CONFLICT: ::CONFIGRET = 0x0000000C; pub const CM_PROB_NOT_VERIFIED: ::CONFIGRET = 0x0000000D; pub const CM_PROB_NEED_RESTART: ::CONFIGRET = 0x0000000E; pub const CM_PROB_REENUMERATION: ::CONFIGRET = 0x0000000F; pub const CM_PROB_PARTIAL_LOG_CONF: ::CONFIGRET = 0x00000010; pub const CM_PROB_UNKNOWN_RESOURCE: ::CONFIGRET = 0x00000011; pub const CM_PROB_REINSTALL: ::CONFIGRET = 0x00000012; pub const CM_PROB_REGISTRY: ::CONFIGRET = 0x00000013; pub const CM_PROB_VXDLDR: ::CONFIGRET = 0x00000014; pub const CM_PROB_WILL_BE_REMOVED: ::CONFIGRET = 0x00000015; pub const CM_PROB_DISABLED: ::CONFIGRET = 0x00000016; pub const CM_PROB_DEVLOADER_NOT_READY: ::CONFIGRET = 0x00000017; pub const CM_PROB_DEVICE_NOT_THERE: ::CONFIGRET = 0x00000018; pub const CM_PROB_MOVED: ::CONFIGRET = 0x00000019; pub const CM_PROB_TOO_EARLY: ::CONFIGRET = 0x0000001A; pub const CM_PROB_NO_VALID_LOG_CONF: ::CONFIGRET = 0x0000001B; pub const CM_PROB_FAILED_INSTALL: ::CONFIGRET = 0x0000001C; pub const CM_PROB_HARDWARE_DISABLED: ::CONFIGRET = 0x0000001D; pub const CM_PROB_CANT_SHARE_IRQ: ::CONFIGRET = 0x0000001E; pub const CM_PROB_FAILED_ADD: ::CONFIGRET = 0x0000001F; pub const CM_PROB_DISABLED_SERVICE: ::CONFIGRET = 0x00000020; pub const CM_PROB_TRANSLATION_FAILED: ::CONFIGRET = 0x00000021; pub const CM_PROB_NO_SOFTCONFIG: ::CONFIGRET = 0x00000022; pub const CM_PROB_BIOS_TABLE: ::CONFIGRET = 0x00000023; pub const CM_PROB_IRQ_TRANSLATION_FAILED: ::CONFIGRET = 0x00000024; pub const CM_PROB_FAILED_DRIVER_ENTRY: ::CONFIGRET = 0x00000025; pub const CM_PROB_DRIVER_FAILED_PRIOR_UNLOAD: ::CONFIGRET = 0x00000026; pub const CM_PROB_DRIVER_FAILED_LOAD: ::CONFIGRET = 0x00000027; pub const CM_PROB_DRIVER_SERVICE_KEY_INVALID: ::CONFIGRET = 0x00000028; pub const CM_PROB_LEGACY_SERVICE_NO_DEVICES: ::CONFIGRET = 0x00000029; pub const CM_PROB_DUPLICATE_DEVICE: ::CONFIGRET = 0x0000002A; pub const CM_PROB_FAILED_POST_START: ::CONFIGRET = 0x0000002B; pub const CM_PROB_HALTED: ::CONFIGRET = 0x0000002C; pub const CM_PROB_PHANTOM: ::CONFIGRET = 0x0000002D; pub const CM_PROB_SYSTEM_SHUTDOWN: ::CONFIGRET = 0x0000002E; pub const CM_PROB_HELD_FOR_EJECT: ::CONFIGRET = 0x0000002F; pub const CM_PROB_DRIVER_BLOCKED: ::CONFIGRET = 0x00000030; pub const CM_PROB_REGISTRY_TOO_LARGE: ::CONFIGRET = 0x00000031; pub const CM_PROB_SETPROPERTIES_FAILED: ::CONFIGRET = 0x00000032; pub const CM_PROB_WAITING_ON_DEPENDENCY: ::CONFIGRET = 0x00000033; pub const CM_PROB_UNSIGNED_DRIVER: ::CONFIGRET = 0x00000034; pub const CM_PROB_USED_BY_DEBUGGER: ::CONFIGRET = 0x00000035; pub const NUM_CM_PROB_V1: ::CONFIGRET = 0x00000025; pub const NUM_CM_PROB_V2: ::CONFIGRET = 0x00000032; pub const NUM_CM_PROB_V3: ::CONFIGRET = 0x00000033; pub const NUM_CM_PROB_V4: ::CONFIGRET = 0x00000034; pub const NUM_CM_PROB_V5: ::CONFIGRET = 0x00000035; pub const NUM_CM_PROB_V6: ::CONFIGRET = 0x00000036; pub const DN_ROOT_ENUMERATED: ::CONFIGRET = 0x00000001; pub const DN_DRIVER_LOADED: ::CONFIGRET = 0x00000002; pub const DN_ENUM_LOADED: ::CONFIGRET = 0x00000004; pub const DN_STARTED: ::CONFIGRET = 0x00000008; pub const DN_MANUAL: ::CONFIGRET = 0x00000010; pub const DN_NEED_TO_ENUM: ::CONFIGRET = 0x00000020; pub const DN_NOT_FIRST_TIME: ::CONFIGRET = 0x00000040; pub const DN_HARDWARE_ENUM: ::CONFIGRET = 0x00000080; pub const DN_LIAR: ::CONFIGRET = 0x00000100; pub const DN_HAS_MARK: ::CONFIGRET = 0x00000200; pub const DN_HAS_PROBLEM: ::CONFIGRET = 0x00000400; pub const DN_FILTERED: ::CONFIGRET = 0x00000800; pub const DN_MOVED: ::CONFIGRET = 0x00001000; pub const DN_DISABLEABLE: ::CONFIGRET = 0x00002000; pub const DN_REMOVABLE: ::CONFIGRET = 0x00004000; pub const DN_PRIVATE_PROBLEM: ::CONFIGRET = 0x00008000; pub const DN_MF_PARENT: ::CONFIGRET = 0x00010000; pub const DN_MF_CHILD: ::CONFIGRET = 0x00020000; pub const DN_WILL_BE_REMOVED: ::CONFIGRET = 0x00040000; pub const DN_NOT_FIRST_TIMEE: ::CONFIGRET = 0x00080000; pub const DN_STOP_FREE_RES: ::CONFIGRET = 0x00100000; pub const DN_REBAL_CANDIDATE: ::CONFIGRET = 0x00200000; pub const DN_BAD_PARTIAL: ::CONFIGRET = 0x00400000; pub const DN_NT_ENUMERATOR: ::CONFIGRET = 0x00800000; pub const DN_NT_DRIVER: ::CONFIGRET = 0x01000000; pub const DN_NEEDS_LOCKING: ::CONFIGRET = 0x02000000; pub const DN_ARM_WAKEUP: ::CONFIGRET = 0x04000000; pub const DN_APM_ENUMERATOR: ::CONFIGRET = 0x08000000; pub const DN_APM_DRIVER: ::CONFIGRET = 0x10000000; pub const DN_SILENT_INSTALL: ::CONFIGRET = 0x20000000; pub const DN_NO_SHOW_IN_DM: ::CONFIGRET = 0x40000000; pub const DN_BOOT_LOG_PROB: ::CONFIGRET = 0x80000000; pub const DN_NEED_RESTART: ::CONFIGRET = DN_LIAR; pub const DN_DRIVER_BLOCKED: ::CONFIGRET = DN_NOT_FIRST_TIME; pub const DN_LEGACY_DRIVER: ::CONFIGRET = DN_MOVED; pub const DN_CHILD_WITH_INVALID_ID: ::CONFIGRET = DN_HAS_MARK; pub const DN_DEVICE_DISCONNECTED: ::CONFIGRET = DN_NEEDS_LOCKING; pub const DN_CHANGEABLE_FLAGS: ::CONFIGRET = DN_NOT_FIRST_TIME + DN_HARDWARE_ENUM + DN_HAS_MARK + DN_DISABLEABLE + DN_REMOVABLE + DN_MF_CHILD + DN_MF_PARENT + DN_NOT_FIRST_TIMEE + DN_STOP_FREE_RES + DN_REBAL_CANDIDATE + DN_NT_ENUMERATOR + DN_NT_DRIVER + DN_SILENT_INSTALL + DN_NO_SHOW_IN_DM; pub const LCPRI_FORCECONFIG: ::PRIORITY = 0x00000000; pub const LCPRI_BOOTCONFIG: ::PRIORITY = 0x00000001; pub const LCPRI_DESIRED: ::PRIORITY = 0x00002000; pub const LCPRI_NORMAL: ::PRIORITY = 0x00003000; pub const LCPRI_LASTBESTCONFIG: ::PRIORITY = 0x00003FFF; pub const LCPRI_SUBOPTIMAL: ::PRIORITY = 0x00005000; pub const LCPRI_LASTSOFTCONFIG: ::PRIORITY = 0x00007FFF; pub const LCPRI_RESTART: ::PRIORITY = 0x00008000; pub const LCPRI_REBOOT: ::PRIORITY = 0x00009000; pub const LCPRI_POWEROFF: ::PRIORITY = 0x0000A000; pub const LCPRI_HARDRECONFIG: ::PRIORITY = 0x0000C000; pub const LCPRI_HARDWIRED: ::PRIORITY = 0x0000E000; pub const LCPRI_IMPOSSIBLE: ::PRIORITY = 0x0000F000; pub const LCPRI_DISABLED: ::PRIORITY = 0x0000FFFF; pub const MAX_LCPRI: ::PRIORITY = 0x0000FFFF; deps/winapi-0.2.5/src/ws2def.rs0000644000000000000000000002410312615662007014772 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! This file contains the core definitions for the Winsock2 specification that can be used by //! both user-mode and kernel mode modules. pub type ADDRESS_FAMILY = ::USHORT; pub const AF_UNSPEC: ::c_int = 0; pub const AF_UNIX: ::c_int = 1; pub const AF_INET: ::c_int = 2; pub const AF_IMPLINK: ::c_int = 3; pub const AF_PUP: ::c_int = 4; pub const AF_CHAOS: ::c_int = 5; pub const AF_NS: ::c_int = 6; pub const AF_IPX: ::c_int = AF_NS; pub const AF_ISO: ::c_int = 7; pub const AF_OSI: ::c_int = AF_ISO; pub const AF_ECMA: ::c_int = 8; pub const AF_DATAKIT: ::c_int = 9; pub const AF_CCITT: ::c_int = 10; pub const AF_SNA: ::c_int = 11; pub const AF_DECnet: ::c_int = 12; pub const AF_DLI: ::c_int = 13; pub const AF_LAT: ::c_int = 14; pub const AF_HYLINK: ::c_int = 15; pub const AF_APPLETALK: ::c_int = 16; pub const AF_NETBIOS: ::c_int = 17; pub const AF_VOICEVIEW: ::c_int = 18; pub const AF_FIREFOX: ::c_int = 19; pub const AF_UNKNOWN1: ::c_int = 20; pub const AF_BAN: ::c_int = 21; pub const AF_ATM: ::c_int = 22; pub const AF_INET6: ::c_int = 23; pub const AF_CLUSTER: ::c_int = 24; pub const AF_12844: ::c_int = 25; pub const AF_IRDA: ::c_int = 26; pub const AF_NETDES: ::c_int = 28; pub const AF_TCNPROCESS: ::c_int = 29; pub const AF_TCNMESSAGE: ::c_int = 30; pub const AF_ICLFXBM: ::c_int = 31; pub const AF_BTH: ::c_int = 32; pub const AF_LINK: ::c_int = 33; pub const AF_MAX: ::c_int = 34; pub const SOCK_STREAM: ::c_int = 1; pub const SOCK_DGRAM: ::c_int = 2; pub const SOCK_RAW: ::c_int = 3; pub const SOCK_RDM: ::c_int = 4; pub const SOCK_SEQPACKET: ::c_int = 5; pub const SOL_SOCKET: ::c_int = 0xffff; pub const SO_DEBUG: ::c_int = 0x0001; pub const SO_ACCEPTCONN: ::c_int = 0x0002; pub const SO_REUSEADDR: ::c_int = 0x0004; pub const SO_KEEPALIVE: ::c_int = 0x0008; pub const SO_DONTROUTE: ::c_int = 0x0010; pub const SO_BROADCAST: ::c_int = 0x0020; pub const SO_USELOOPBACK: ::c_int = 0x0040; pub const SO_LINGER: ::c_int = 0x0080; pub const SO_OOBINLINE: ::c_int = 0x0100; pub const SO_DONTLINGER: ::c_int = !SO_LINGER; pub const SO_EXCLUSIVEADDRUSE: ::c_int = !SO_REUSEADDR; pub const SO_SNDBUF: ::c_int = 0x1001; pub const SO_RCVBUF: ::c_int = 0x1002; pub const SO_SNDLOWAT: ::c_int = 0x1003; pub const SO_RCVLOWAT: ::c_int = 0x1004; pub const SO_SNDTIMEO: ::c_int = 0x1005; pub const SO_RCVTIMEO: ::c_int = 0x1006; pub const SO_ERROR: ::c_int = 0x1007; pub const SO_TYPE: ::c_int = 0x1008; pub const SO_BSP_STATE: ::c_int = 0x1009; pub const SO_GROUP_ID: ::c_int = 0x2001; pub const SO_GROUP_PRIORITY: ::c_int = 0x2002; pub const SO_MAX_MSG_SIZE: ::c_int = 0x2003; pub const SO_CONDITIONAL_ACCEPT: ::c_int = 0x3002; pub const SO_PAUSE_ACCEPT: ::c_int = 0x3003; pub const SO_COMPARTMENT_ID: ::c_int = 0x3004; pub const SO_RANDOMIZE_PORT: ::c_int = 0x3005; pub const SO_PORT_SCALABILITY: ::c_int = 0x3006; pub const WSK_SO_BASE: ::c_int = 0x4000; pub const TCP_NODELAY: ::c_int = 0x0001; STRUCT!{struct SOCKADDR { sa_family: ADDRESS_FAMILY, sa_data: [::CHAR; 14], }} pub type PSOCKADDR = *mut SOCKADDR; pub type LPSOCKADDR = *mut SOCKADDR; STRUCT!{struct SOCKET_ADDRESS { lpSockaddr: LPSOCKADDR, iSockaddrLength: ::INT, }} pub type PSOCKET_ADDRESS = *mut SOCKET_ADDRESS; pub type LPSOCKET_ADDRESS = *mut SOCKET_ADDRESS; #[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct SOCKET_ADDRESS_LIST { pub iAddressCount: ::INT, pub Address: [SOCKET_ADDRESS; 0], } pub type PSOCKET_ADDRESS_LIST = *mut SOCKET_ADDRESS_LIST; pub type LPSOCKET_ADDRESS_LIST = *mut SOCKET_ADDRESS_LIST; STRUCT!{struct CSADDR_INFO { LocalAddr: SOCKET_ADDRESS, RemoteAddr: SOCKET_ADDRESS, iSocketType: ::INT, iProtocol: ::INT, }} pub type PCSADDR_INFO = *mut CSADDR_INFO; pub type LPCSADDR_INFO = *mut CSADDR_INFO; #[repr(C)] #[derive(Copy)] pub struct SOCKADDR_STORAGE_LH { pub ss_family: ADDRESS_FAMILY, pub __ss_pad1: [::CHAR; 6], pub __ss_align: ::__int64, pub __ss_pad2: [::CHAR; 112], } impl Clone for SOCKADDR_STORAGE_LH { fn clone(&self) -> SOCKADDR_STORAGE_LH { *self } } pub type PSOCKADDR_STORAGE_LH = *mut SOCKADDR_STORAGE_LH; pub type LPSOCKADDR_STORAGE_LH = *mut SOCKADDR_STORAGE_LH; #[repr(C)] #[derive(Copy)] pub struct SOCKADDR_STORAGE_XP { pub ss_family: ::c_short, pub __ss_pad1: [::CHAR; 6], pub __ss_align: ::__int64, pub __ss_pad2: [::CHAR; 112], } impl Clone for SOCKADDR_STORAGE_XP { fn clone(&self) -> SOCKADDR_STORAGE_XP { *self } } pub type PSOCKADDR_STORAGE_XP = *mut SOCKADDR_STORAGE_XP; pub type LPSOCKADDR_STORAGE_XP = *mut SOCKADDR_STORAGE_XP; pub type SOCKADDR_STORAGE = SOCKADDR_STORAGE_LH; pub type PSOCKADDR_STORAGE = *mut SOCKADDR_STORAGE; pub type LPSOCKADDR_STORAGE = *mut SOCKADDR_STORAGE; STRUCT!{struct SOCKET_PROCESSOR_AFFINITY { Processor: ::PROCESSOR_NUMBER, NumaNodeId: ::USHORT, Reserved: ::USHORT, }} pub type PSOCKET_PROCESSOR_AFFINITY = *mut SOCKET_PROCESSOR_AFFINITY; pub const IOC_UNIX: ::DWORD = 0x00000000; pub const IOC_WS2: ::DWORD = 0x08000000; pub const IOC_PROTOCOL: ::DWORD = 0x10000000; pub const IOC_VENDOR: ::DWORD = 0x18000000; pub const IOC_WSK: ::DWORD = IOC_WS2 | 0x07000000; macro_rules! _WSAIO { ($x:expr, $y:expr) => { IOC_VOID | $x | $y } } macro_rules! _WSAIOR { ($x:expr, $y:expr) => { IOC_OUT | $x | $y } } macro_rules! _WSAIOW { ($x:expr, $y:expr) => { IOC_IN | $x | $y } } macro_rules! _WSAIORW { ($x:expr, $y:expr) => { IOC_INOUT | $x | $y } } pub const SIO_ASSOCIATE_HANDLE: ::DWORD = _WSAIOW!(IOC_WS2, 1); pub const SIO_ENABLE_CIRCULAR_QUEUEING: ::DWORD = _WSAIO!(IOC_WS2, 2); pub const SIO_FIND_ROUTE: ::DWORD = _WSAIOR!(IOC_WS2, 3); pub const SIO_FLUSH: ::DWORD = _WSAIO!(IOC_WS2, 4); pub const SIO_GET_BROADCAST_ADDRESS: ::DWORD = _WSAIOR!(IOC_WS2, 5); pub const SIO_GET_EXTENSION_FUNCTION_POINTER: ::DWORD = _WSAIORW!(IOC_WS2, 6); pub const SIO_GET_QOS: ::DWORD = _WSAIORW!(IOC_WS2, 7); pub const SIO_GET_GROUP_QOS: ::DWORD = _WSAIORW!(IOC_WS2, 8); pub const SIO_MULTIPOINT_LOOPBACK: ::DWORD = _WSAIOW!(IOC_WS2, 9); pub const SIO_MULTICAST_SCOPE: ::DWORD = _WSAIOW!(IOC_WS2, 10); pub const SIO_SET_QOS: ::DWORD = _WSAIOW!(IOC_WS2, 11); pub const SIO_SET_GROUP_QOS: ::DWORD = _WSAIOW!(IOC_WS2, 12); pub const SIO_TRANSLATE_HANDLE: ::DWORD = _WSAIORW!(IOC_WS2, 13); pub const SIO_ROUTING_INTERFACE_QUERY: ::DWORD = _WSAIORW!(IOC_WS2, 20); pub const SIO_ROUTING_INTERFACE_CHANGE: ::DWORD = _WSAIOW!(IOC_WS2, 21); pub const SIO_ADDRESS_LIST_QUERY: ::DWORD = _WSAIOR!(IOC_WS2, 22); pub const SIO_ADDRESS_LIST_CHANGE: ::DWORD = _WSAIO!(IOC_WS2, 23); pub const SIO_QUERY_TARGET_PNP_HANDLE: ::DWORD = _WSAIOR!(IOC_WS2, 24); pub const SIO_QUERY_RSS_PROCESSOR_INFO: ::DWORD = _WSAIOR!(IOC_WS2, 37); pub const SIO_ADDRESS_LIST_SORT: ::DWORD = _WSAIORW!(IOC_WS2, 25); pub const SIO_RESERVED_1: ::DWORD = _WSAIOW!(IOC_WS2, 26); pub const SIO_RESERVED_2: ::DWORD = _WSAIOW!(IOC_WS2, 33); pub const SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER: ::DWORD = _WSAIORW!(IOC_WS2, 36); pub const IPPROTO_IP: ::c_int = 0; ENUM!{enum IPPROTO { IPPROTO_HOPOPTS = 0, // IPv6 Hop-by-Hop options IPPROTO_ICMP = 1, IPPROTO_IGMP = 2, IPPROTO_GGP = 3, IPPROTO_IPV4 = 4, IPPROTO_ST = 5, IPPROTO_TCP = 6, IPPROTO_CBT = 7, IPPROTO_EGP = 8, IPPROTO_IGP = 9, IPPROTO_PUP = 12, IPPROTO_UDP = 17, IPPROTO_IDP = 22, IPPROTO_RDP = 27, IPPROTO_IPV6 = 41, // IPv6 header IPPROTO_ROUTING = 43, // IPv6 Routing header IPPROTO_FRAGMENT = 44, // IPv6 fragmentation header IPPROTO_ESP = 50, // encapsulating security payload IPPROTO_AH = 51, // authentication header IPPROTO_ICMPV6 = 58, // ICMPv6 IPPROTO_NONE = 59, // IPv6 no next header IPPROTO_DSTOPTS = 60, // IPv6 Destination options IPPROTO_ND = 77, IPPROTO_ICLFXBM = 78, IPPROTO_PIM = 103, IPPROTO_PGM = 113, IPPROTO_L2TP = 115, IPPROTO_SCTP = 132, IPPROTO_RAW = 255, IPPROTO_MAX = 256, IPPROTO_RESERVED_RAW = 257, IPPROTO_RESERVED_IPSEC = 258, IPPROTO_RESERVED_IPSECOFFLOAD = 259, IPPROTO_RESERVED_WNV = 260, IPPROTO_RESERVED_MAX = 261, }} pub type PIPPROTO = *mut IPPROTO; STRUCT!{struct SOCKADDR_IN { sin_family: ADDRESS_FAMILY, sin_port: ::USHORT, sin_addr: ::IN_ADDR, sin_zero: [::CHAR; 8], }} pub type PSOCKADDR_IN = *mut SOCKADDR_IN; //645 pub const IOCPARM_MASK: ::DWORD = 0x7f; pub const IOC_VOID: ::DWORD = 0x20000000; pub const IOC_OUT: ::DWORD = 0x40000000; pub const IOC_IN: ::DWORD = 0x80000000; pub const IOC_INOUT: ::DWORD = IOC_IN | IOC_OUT; STRUCT!{struct WSABUF { len: ::ULONG, buf: *mut ::CHAR, }} pub type LPWSABUF = *mut WSABUF; STRUCT!{struct WSAMSG { name: LPSOCKADDR, namelen: ::INT, lpBuffers: LPWSABUF, dwBufferCount: ::ULONG, Control: WSABUF, dwFlags: ::ULONG, }} pub type PWSAMSG = *mut WSAMSG; pub type LPWSAMSG = *mut WSAMSG; STRUCT!{struct ADDRINFOA { ai_flags: ::c_int, ai_family: ::c_int, ai_socktype: ::c_int, ai_protocol: ::c_int, ai_addrlen: ::size_t, ai_canonname: *mut ::c_char, ai_addr: *mut SOCKADDR, ai_next: *mut ADDRINFOA, }} pub type PADDRINFOA = *mut ADDRINFOA; STRUCT!{struct ADDRINFOW { ai_flags: ::c_int, ai_family: ::c_int, ai_socktype: ::c_int, ai_protocol: ::c_int, ai_addrlen: ::size_t, ai_canonname: ::PWSTR, ai_addr: *mut SOCKADDR, ai_next: *mut ADDRINFOW, }} pub type PADDRINFOW = *mut ADDRINFOW; STRUCT!{struct ADDRINFOEXA { ai_flags: ::c_int, ai_family: ::c_int, ai_socktype: ::c_int, ai_protocol: ::c_int, ai_addrlen: ::size_t, ai_canonname: *mut ::c_char, ai_addr: *mut SOCKADDR, ai_blob: *mut ::c_void, ai_bloblen: ::size_t, ai_provider: ::LPGUID, ai_next: *mut ADDRINFOEXW, }} pub type PADDRINFOEXA = *mut ADDRINFOEXA; pub type LPADDRINFOEXA = *mut ADDRINFOEXA; STRUCT!{struct ADDRINFOEXW { ai_flags: ::c_int, ai_family: ::c_int, ai_socktype: ::c_int, ai_protocol: ::c_int, ai_addrlen: ::size_t, ai_canonname: ::PWSTR, ai_addr: *mut SOCKADDR, ai_blob: *mut ::c_void, ai_bloblen: ::size_t, ai_provider: ::LPGUID, ai_next: *mut ADDRINFOEXW, }} pub type PADDRINFOEXW = *mut ADDRINFOEXW; pub type LPADDRINFOEXW = *mut ADDRINFOEXW; deps/winapi-0.2.5/src/unknwnbase.rs0000644000000000000000000000211012605021253015734 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! this ALWAYS GENERATED file contains the definitions for the interfaces RIDL!( interface IUnknown(IUnknownVtbl) { fn QueryInterface(&mut self, riid: ::REFIID, ppvObject: *mut *mut ::c_void) -> ::HRESULT, fn AddRef(&mut self) -> ::ULONG, fn Release(&mut self) -> ::ULONG } ); pub type LPUNKNOWN = *mut IUnknown; RIDL!( interface AsyncIUnknown(AsyncIUnknownVtbl): IUnknown(IUnknownVtbl) { fn Begin_QueryInterface(&mut self, riid: ::REFIID) -> ::HRESULT, fn Finish_QueryInterface(&mut self, ppvObject: *mut *mut ::c_void) -> ::HRESULT, fn Begin_AddRef(&mut self) -> ::HRESULT, fn Finish_AddRef(&mut self) -> ::ULONG, fn Begin_Release(&mut self) -> ::HRESULT, fn Finish_Release(&mut self) -> ::ULONG } ); RIDL!( interface IClassFactory(IClassFactoryVtbl): IUnknown(IUnknownVtbl) { fn CreateInstance( &mut self, pUnkOuter: *mut IUnknown, riid: ::REFIID, ppvObject: *mut *mut ::c_void ) -> ::HRESULT, fn LockServer(&mut self, fLock: ::BOOL) -> ::HRESULT } ); deps/winapi-0.2.5/src/d3d9types.rs0000644000000000000000000013606512616155403015441 0ustar rootroot// Copyright © 2015, Corey Richardson // Licensed under the MIT License //! Direct3D capabilities include file pub type D3DCOLOR = ::DWORD; STRUCT!{struct D3DVECTOR { x: ::c_float, y: ::c_float, z: ::c_float, }} STRUCT!{struct D3DCOLORVALUE { r: ::c_float, g: ::c_float, b: ::c_float, a: ::c_float, }} STRUCT!{struct D3DRECT { x1: ::LONG, y1: ::LONG, x2: ::LONG, y2: ::LONG, }} STRUCT!{struct D3DMATRIX { m: [[::c_float; 4]; 4], }} STRUCT!{struct D3DVIEWPORT9 { X: ::DWORD, Y: ::DWORD, Width: ::DWORD, Height: ::DWORD, MinZ: ::c_float, MaxZ: ::c_float, }} pub const D3DMAXUSERCLIPPLANES: ::DWORD = 32; pub const D3DCLIPPLANE0: ::DWORD = (1 << 0); pub const D3DCLIPPLANE1: ::DWORD = (1 << 1); pub const D3DCLIPPLANE2: ::DWORD = (1 << 2); pub const D3DCLIPPLANE3: ::DWORD = (1 << 3); pub const D3DCLIPPLANE4: ::DWORD = (1 << 4); pub const D3DCLIPPLANE5: ::DWORD = (1 << 5); pub const D3DCS_LEFT: ::DWORD = 0x00000001; pub const D3DCS_RIGHT: ::DWORD = 0x00000002; pub const D3DCS_TOP: ::DWORD = 0x00000004; pub const D3DCS_BOTTOM: ::DWORD = 0x00000008; pub const D3DCS_FRONT: ::DWORD = 0x00000010; pub const D3DCS_BACK: ::DWORD = 0x00000020; pub const D3DCS_PLANE0: ::DWORD = 0x00000040; pub const D3DCS_PLANE1: ::DWORD = 0x00000080; pub const D3DCS_PLANE2: ::DWORD = 0x00000100; pub const D3DCS_PLANE3: ::DWORD = 0x00000200; pub const D3DCS_PLANE4: ::DWORD = 0x00000400; pub const D3DCS_PLANE5: ::DWORD = 0x00000800; pub const D3DCS_ALL: ::DWORD = D3DCS_LEFT | D3DCS_RIGHT | D3DCS_TOP | D3DCS_BOTTOM | D3DCS_FRONT | D3DCS_BACK | D3DCS_PLANE0 | D3DCS_PLANE1 | D3DCS_PLANE2 | D3DCS_PLANE3 | D3DCS_PLANE4 | D3DCS_PLANE5; STRUCT!{struct D3DCLIPSTATUS9 { ClipUnion: ::DWORD, ClipIntersection: ::DWORD, }} STRUCT!{struct D3DMATERIAL9 { Diffuse: D3DCOLORVALUE, Ambient: D3DCOLORVALUE, Specular: D3DCOLORVALUE, Emissive: D3DCOLORVALUE, Power: ::c_float, }} ENUM!{enum D3DLIGHTTYPE { D3DLIGHT_POINT = 1, D3DLIGHT_SPOT = 2, D3DLIGHT_DIRECTIONAL = 3, }} STRUCT!{struct D3DLIGHT9 { Type: D3DLIGHTTYPE, Diffuse: D3DCOLORVALUE, Specular: D3DCOLORVALUE, Ambient: D3DCOLORVALUE, Position: D3DVECTOR, Direction: D3DVECTOR, Range: ::c_float, Falloff: ::c_float, Attenuation0: ::c_float, Attenuation1: ::c_float, Attenuation2: ::c_float, Theta: ::c_float, Phi: ::c_float, }} pub const D3DCLEAR_TARGET: ::DWORD = 0x1; pub const D3DCLEAR_ZBUFFER: ::DWORD = 0x2; pub const D3DCLEAR_STENCIL: ::DWORD = 0x4; ENUM!{enum D3DSHADEMODE { D3DSHADE_FLAT = 1, D3DSHADE_GOURAUD = 2, D3DSHADE_PHONG = 3, }} ENUM!{enum D3DFILLMODE { D3DFILL_POINT = 1, D3DFILL_WIREFRAME = 2, D3DFILL_SOLID = 3, }} ENUM!{enum D3DBLEND { D3DBLEND_ZERO = 1, D3DBLEND_ONE = 2, D3DBLEND_SRCCOLOR = 3, D3DBLEND_INVSRCCOLOR = 4, D3DBLEND_SRCALPHA = 5, D3DBLEND_INVSRCALPHA = 6, D3DBLEND_DESTALPHA = 7, D3DBLEND_INVDESTALPHA = 8, D3DBLEND_DESTCOLOR = 9, D3DBLEND_INVDESTCOLOR = 10, D3DBLEND_SRCALPHASAT = 11, D3DBLEND_BOTHSRCALPHA = 12, D3DBLEND_BOTHINVSRCALPHA = 13, D3DBLEND_BLENDFACTOR = 14, D3DBLEND_INVBLENDFACTOR = 15, }} ENUM!{enum D3DBLENDOP { D3DBLENDOP_ADD = 1, D3DBLENDOP_SUBTRACT = 2, D3DBLENDOP_REVSUBTRACT = 3, D3DBLENDOP_MIN = 4, D3DBLENDOP_MAX = 5, }} ENUM!{enum D3DTEXTUREADDRESS { D3DTADDRESS_WRAP = 1, D3DTADDRESS_MIRROR = 2, D3DTADDRESS_CLAMP = 3, D3DTADDRESS_BORDER = 4, D3DTADDRESS_MIRRORONCE = 5, }} ENUM!{enum D3DCULL { D3DCULL_NONE = 1, D3DCULL_CW = 2, D3DCULL_CCW = 3, }} ENUM!{enum D3DCMPFUNC { D3DCMP_NEVER = 1, D3DCMP_LESS = 2, D3DCMP_EQUAL = 3, D3DCMP_LESSEQUAL = 4, D3DCMP_GREATER = 5, D3DCMP_NOTEQUAL = 6, D3DCMP_GREATEREQUAL = 7, D3DCMP_ALWAYS = 8, }} ENUM!{enum D3DSTENCILOP { D3DSTENCILOP_KEEP = 1, D3DSTENCILOP_ZERO = 2, D3DSTENCILOP_REPLACE = 3, D3DSTENCILOP_INCRSAT = 4, D3DSTENCILOP_DECRSAT = 5, D3DSTENCILOP_INVERT = 6, D3DSTENCILOP_INCR = 7, D3DSTENCILOP_DECR = 8, }} ENUM!{enum D3DFOGMODE { D3DFOG_NONE = 0, D3DFOG_EXP = 1, D3DFOG_EXP2 = 2, D3DFOG_LINEAR = 3, }} ENUM!{enum D3DZBUFFERTYPE { D3DZB_FALSE = 0, D3DZB_TRUE = 1, D3DZB_USEW = 2, }} ENUM!{enum D3DPRIMITIVETYPE { D3DPT_POINTLIST = 1, D3DPT_LINELIST = 2, D3DPT_LINESTRIP = 3, D3DPT_TRIANGLELIST = 4, D3DPT_TRIANGLESTRIP = 5, D3DPT_TRIANGLEFAN = 6, }} ENUM!{enum D3DTRANSFORMSTATETYPE { D3DTS_VIEW = 2, D3DTS_PROJECTION = 3, D3DTS_TEXTURE0 = 16, D3DTS_TEXTURE1 = 17, D3DTS_TEXTURE2 = 18, D3DTS_TEXTURE3 = 19, D3DTS_TEXTURE4 = 20, D3DTS_TEXTURE5 = 21, D3DTS_TEXTURE6 = 22, D3DTS_TEXTURE7 = 23, }} ENUM!{enum D3DRENDERSTATETYPE { D3DRS_ZENABLE = 7, D3DRS_FILLMODE = 8, D3DRS_SHADEMODE = 9, D3DRS_ZWRITEENABLE = 14, D3DRS_ALPHATESTENABLE = 15, D3DRS_LASTPIXEL = 16, D3DRS_SRCBLEND = 19, D3DRS_DESTBLEND = 20, D3DRS_CULLMODE = 22, D3DRS_ZFUNC = 23, D3DRS_ALPHAREF = 24, D3DRS_ALPHAFUNC = 25, D3DRS_DITHERENABLE = 26, D3DRS_ALPHABLENDENABLE = 27, D3DRS_FOGENABLE = 28, D3DRS_SPECULARENABLE = 29, D3DRS_FOGCOLOR = 34, D3DRS_FOGTABLEMODE = 35, D3DRS_FOGSTART = 36, D3DRS_FOGEND = 37, D3DRS_FOGDENSITY = 38, D3DRS_RANGEFOGENABLE = 48, D3DRS_STENCILENABLE = 52, D3DRS_STENCILFAIL = 53, D3DRS_STENCILZFAIL = 54, D3DRS_STENCILPASS = 55, D3DRS_STENCILFUNC = 56, D3DRS_STENCILREF = 57, D3DRS_STENCILMASK = 58, D3DRS_STENCILWRITEMASK = 59, D3DRS_TEXTUREFACTOR = 60, D3DRS_WRAP0 = 128, D3DRS_WRAP1 = 129, D3DRS_WRAP2 = 130, D3DRS_WRAP3 = 131, D3DRS_WRAP4 = 132, D3DRS_WRAP5 = 133, D3DRS_WRAP6 = 134, D3DRS_WRAP7 = 135, D3DRS_CLIPPING = 136, D3DRS_LIGHTING = 137, D3DRS_AMBIENT = 139, D3DRS_FOGVERTEXMODE = 140, D3DRS_COLORVERTEX = 141, D3DRS_LOCALVIEWER = 142, D3DRS_NORMALIZENORMALS = 143, D3DRS_DIFFUSEMATERIALSOURCE = 145, D3DRS_SPECULARMATERIALSOURCE = 146, D3DRS_AMBIENTMATERIALSOURCE = 147, D3DRS_EMISSIVEMATERIALSOURCE = 148, D3DRS_VERTEXBLEND = 151, D3DRS_CLIPPLANEENABLE = 152, D3DRS_POINTSIZE = 154, D3DRS_POINTSIZE_MIN = 155, D3DRS_POINTSPRITEENABLE = 156, D3DRS_POINTSCALEENABLE = 157, D3DRS_POINTSCALE_A = 158, D3DRS_POINTSCALE_B = 159, D3DRS_POINTSCALE_C = 160, D3DRS_MULTISAMPLEANTIALIAS = 161, D3DRS_MULTISAMPLEMASK = 162, D3DRS_PATCHEDGESTYLE = 163, D3DRS_DEBUGMONITORTOKEN = 165, D3DRS_POINTSIZE_MAX = 166, D3DRS_INDEXEDVERTEXBLENDENABLE = 167, D3DRS_COLORWRITEENABLE = 168, D3DRS_TWEENFACTOR = 170, D3DRS_BLENDOP = 171, D3DRS_POSITIONDEGREE = 172, D3DRS_NORMALDEGREE = 173, D3DRS_SCISSORTESTENABLE = 174, D3DRS_SLOPESCALEDEPTHBIAS = 175, D3DRS_ANTIALIASEDLINEENABLE = 176, D3DRS_MINTESSELLATIONLEVEL = 178, D3DRS_MAXTESSELLATIONLEVEL = 179, D3DRS_ADAPTIVETESS_X = 180, D3DRS_ADAPTIVETESS_Y = 181, D3DRS_ADAPTIVETESS_Z = 182, D3DRS_ADAPTIVETESS_W = 183, D3DRS_ENABLEADAPTIVETESSELLATION = 184, D3DRS_TWOSIDEDSTENCILMODE = 185, D3DRS_CCW_STENCILFAIL = 186, D3DRS_CCW_STENCILZFAIL = 187, D3DRS_CCW_STENCILPASS = 188, D3DRS_CCW_STENCILFUNC = 189, D3DRS_COLORWRITEENABLE1 = 190, D3DRS_COLORWRITEENABLE2 = 191, D3DRS_COLORWRITEENABLE3 = 192, D3DRS_BLENDFACTOR = 193, D3DRS_SRGBWRITEENABLE = 194, D3DRS_DEPTHBIAS = 195, D3DRS_WRAP8 = 198, D3DRS_WRAP9 = 199, D3DRS_WRAP10 = 200, D3DRS_WRAP11 = 201, D3DRS_WRAP12 = 202, D3DRS_WRAP13 = 203, D3DRS_WRAP14 = 204, D3DRS_WRAP15 = 205, D3DRS_SEPARATEALPHABLENDENABLE = 206, D3DRS_SRCBLENDALPHA = 207, D3DRS_DESTBLENDALPHA = 208, D3DRS_BLENDOPALPHA = 209, }} pub const D3D_MAX_SIMULTANEOUS_RENDERTARGETS: ::DWORD = 4; ENUM!{enum D3DMATERIALCOLORSOURCE { D3DMCS_MATERIAL = 0, D3DMCS_COLOR1 = 1, D3DMCS_COLOR2 = 2, }} pub const D3DRENDERSTATE_WRAPBIAS: ::DWORD = 128; pub const D3DWRAP_U: ::DWORD = 0x00000001; pub const D3DWRAP_V: ::DWORD = 0x00000002; pub const D3DWRAP_W: ::DWORD = 0x00000004; pub const D3DWRAPCOORD_0: ::DWORD = 0x00000001; pub const D3DWRAPCOORD_1: ::DWORD = 0x00000002; pub const D3DWRAPCOORD_2: ::DWORD = 0x00000004; pub const D3DWRAPCOORD_3: ::DWORD = 0x00000008; pub const D3DCOLORWRITEENABLE_RED: ::DWORD = 1 << 0; pub const D3DCOLORWRITEENABLE_GREEN: ::DWORD = 1 << 1; pub const D3DCOLORWRITEENABLE_BLUE: ::DWORD = 1 << 2; pub const D3DCOLORWRITEENABLE_ALPHA: ::DWORD = 1 << 3; ENUM!{enum D3DTEXTURESTAGESTATETYPE { D3DTSS_COLOROP = 1, D3DTSS_COLORARG1 = 2, D3DTSS_COLORARG2 = 3, D3DTSS_ALPHAOP = 4, D3DTSS_ALPHAARG1 = 5, D3DTSS_ALPHAARG2 = 6, D3DTSS_BUMPENVMAT00 = 7, D3DTSS_BUMPENVMAT01 = 8, D3DTSS_BUMPENVMAT10 = 9, D3DTSS_BUMPENVMAT11 = 10, D3DTSS_TEXCOORDINDEX = 11, D3DTSS_BUMPENVLSCALE = 22, D3DTSS_BUMPENVLOFFSET = 23, D3DTSS_TEXTURETRANSFORMFLAGS = 24, D3DTSS_COLORARG0 = 26, D3DTSS_ALPHAARG0 = 27, D3DTSS_RESULTARG = 28, D3DTSS_CONSTANT = 32, }} ENUM!{enum D3DSAMPLERSTATETYPE { D3DSAMP_ADDRESSU = 1, D3DSAMP_ADDRESSV = 2, D3DSAMP_ADDRESSW = 3, D3DSAMP_BORDERCOLOR = 4, D3DSAMP_MAGFILTER = 5, D3DSAMP_MINFILTER = 6, D3DSAMP_MIPFILTER = 7, D3DSAMP_MIPMAPLODBIAS = 8, D3DSAMP_MAXMIPLEVEL = 9, D3DSAMP_MAXANISOTROPY = 10, D3DSAMP_SRGBTEXTURE = 11, D3DSAMP_ELEMENTINDEX = 12, D3DSAMP_DMAPOFFSET = 13, }} pub const D3DDMAPSAMPLER: ::DWORD = 256; pub const D3DVERTEXTEXTURESAMPLER0: ::DWORD = D3DDMAPSAMPLER + 1; pub const D3DVERTEXTEXTURESAMPLER1: ::DWORD = D3DDMAPSAMPLER + 2; pub const D3DVERTEXTEXTURESAMPLER2: ::DWORD = D3DDMAPSAMPLER + 3; pub const D3DVERTEXTEXTURESAMPLER3: ::DWORD = D3DDMAPSAMPLER + 4; pub const D3DTSS_TCI_PASSTHRU: ::DWORD = 0x00000000; pub const D3DTSS_TCI_CAMERASPACENORMAL: ::DWORD = 0x00010000; pub const D3DTSS_TCI_CAMERASPACEPOSITION: ::DWORD = 0x00020000; pub const D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR: ::DWORD = 0x00030000; pub const D3DTSS_TCI_SPHEREMAP: ::DWORD = 0x00040000; ENUM!{enum D3DTEXTUREOP { D3DTOP_DISABLE = 1, D3DTOP_SELECTARG1 = 2, D3DTOP_SELECTARG2 = 3, D3DTOP_MODULATE = 4, D3DTOP_MODULATE2X = 5, D3DTOP_MODULATE4X = 6, D3DTOP_ADD = 7, D3DTOP_ADDSIGNED = 8, D3DTOP_ADDSIGNED2X = 9, D3DTOP_SUBTRACT = 10, D3DTOP_ADDSMOOTH = 11, D3DTOP_BLENDDIFFUSEALPHA = 12, D3DTOP_BLENDTEXTUREALPHA = 13, D3DTOP_BLENDFACTORALPHA = 14, D3DTOP_BLENDTEXTUREALPHAPM = 15, D3DTOP_BLENDCURRENTALPHA = 16, D3DTOP_PREMODULATE = 17, D3DTOP_MODULATEALPHA_ADDCOLOR = 18, D3DTOP_MODULATECOLOR_ADDALPHA = 19, D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20, D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21, D3DTOP_BUMPENVMAP = 22, D3DTOP_BUMPENVMAPLUMINANCE = 23, D3DTOP_DOTPRODUCT3 = 24, D3DTOP_MULTIPLYADD = 25, D3DTOP_LERP = 26, }} pub const D3DTA_SELECTMASK: ::DWORD = 0x0000000f; pub const D3DTA_DIFFUSE: ::DWORD = 0x00000000; pub const D3DTA_CURRENT: ::DWORD = 0x00000001; pub const D3DTA_TEXTURE: ::DWORD = 0x00000002; pub const D3DTA_TFACTOR: ::DWORD = 0x00000003; pub const D3DTA_SPECULAR: ::DWORD = 0x00000004; pub const D3DTA_TEMP: ::DWORD = 0x00000005; pub const D3DTA_CONSTANT: ::DWORD = 0x00000006; pub const D3DTA_COMPLEMENT: ::DWORD = 0x00000010; pub const D3DTA_ALPHAREPLICATE: ::DWORD = 0x00000020; ENUM!{enum D3DTEXTUREFILTERTYPE { D3DTEXF_NONE = 0, D3DTEXF_POINT = 1, D3DTEXF_LINEAR = 2, D3DTEXF_ANISOTROPIC = 3, D3DTEXF_PYRAMIDALQUAD = 6, D3DTEXF_GAUSSIANQUAD = 7, D3DTEXF_CONVOLUTIONMONO = 8, }} pub const D3DPV_DONOTCOPYDATA: ::DWORD = 1 << 0; pub const D3DFVF_RESERVED0: ::DWORD = 0x001; pub const D3DFVF_POSITION_MASK: ::DWORD = 0x400E; pub const D3DFVF_XYZ: ::DWORD = 0x002; pub const D3DFVF_XYZRHW: ::DWORD = 0x004; pub const D3DFVF_XYZB1: ::DWORD = 0x006; pub const D3DFVF_XYZB2: ::DWORD = 0x008; pub const D3DFVF_XYZB3: ::DWORD = 0x00a; pub const D3DFVF_XYZB4: ::DWORD = 0x00c; pub const D3DFVF_XYZB5: ::DWORD = 0x00e; pub const D3DFVF_XYZW: ::DWORD = 0x4002; pub const D3DFVF_NORMAL: ::DWORD = 0x010; pub const D3DFVF_PSIZE: ::DWORD = 0x020; pub const D3DFVF_DIFFUSE: ::DWORD = 0x040; pub const D3DFVF_SPECULAR: ::DWORD = 0x080; pub const D3DFVF_TEXCOUNT_MASK: ::DWORD = 0xf00; pub const D3DFVF_TEXCOUNT_SHIFT: ::DWORD = 8; pub const D3DFVF_TEX0: ::DWORD = 0x000; pub const D3DFVF_TEX1: ::DWORD = 0x100; pub const D3DFVF_TEX2: ::DWORD = 0x200; pub const D3DFVF_TEX3: ::DWORD = 0x300; pub const D3DFVF_TEX4: ::DWORD = 0x400; pub const D3DFVF_TEX5: ::DWORD = 0x500; pub const D3DFVF_TEX6: ::DWORD = 0x600; pub const D3DFVF_TEX7: ::DWORD = 0x700; pub const D3DFVF_TEX8: ::DWORD = 0x800; pub const D3DFVF_LASTBETA_UBYTE4: ::DWORD = 0x1000; pub const D3DFVF_LASTBETA_D3DCOLOR: ::DWORD = 0x8000; pub const D3DFVF_RESERVED2: ::DWORD = 0x6000; ENUM!{enum D3DDECLUSAGE { D3DDECLUSAGE_POSITION = 0, D3DDECLUSAGE_BLENDWEIGHT, D3DDECLUSAGE_BLENDINDICES, D3DDECLUSAGE_NORMAL, D3DDECLUSAGE_PSIZE, D3DDECLUSAGE_TEXCOORD, D3DDECLUSAGE_TANGENT, D3DDECLUSAGE_BINORMAL, D3DDECLUSAGE_TESSFACTOR, D3DDECLUSAGE_POSITIONT, D3DDECLUSAGE_COLOR, D3DDECLUSAGE_FOG, D3DDECLUSAGE_DEPTH, D3DDECLUSAGE_SAMPLE, }} pub const MAXD3DDECLUSAGE: D3DDECLUSAGE = D3DDECLUSAGE_SAMPLE; pub const MAXD3DDECLUSAGEINDEX: ::DWORD = 15; pub const MAXD3DDECLLENGTH: ::DWORD = 64; ENUM!{enum D3DDECLMETHOD { D3DDECLMETHOD_DEFAULT = 0, D3DDECLMETHOD_PARTIALU, D3DDECLMETHOD_PARTIALV, D3DDECLMETHOD_CROSSUV, D3DDECLMETHOD_UV, D3DDECLMETHOD_LOOKUP, D3DDECLMETHOD_LOOKUPPRESAMPLED, }} pub const MAXD3DDECLMETHOD: D3DDECLMETHOD = D3DDECLMETHOD_LOOKUPPRESAMPLED; ENUM!{enum D3DDECLTYPE { D3DDECLTYPE_FLOAT1 = 0, D3DDECLTYPE_FLOAT2 = 1, D3DDECLTYPE_FLOAT3 = 2, D3DDECLTYPE_FLOAT4 = 3, D3DDECLTYPE_D3DCOLOR = 4, D3DDECLTYPE_UBYTE4 = 5, D3DDECLTYPE_SHORT2 = 6, D3DDECLTYPE_SHORT4 = 7, D3DDECLTYPE_UBYTE4N = 8, D3DDECLTYPE_SHORT2N = 9, D3DDECLTYPE_SHORT4N = 10, D3DDECLTYPE_USHORT2N = 11, D3DDECLTYPE_USHORT4N = 12, D3DDECLTYPE_UDEC3 = 13, D3DDECLTYPE_DEC3N = 14, D3DDECLTYPE_FLOAT16_2 = 15, D3DDECLTYPE_FLOAT16_4 = 16, D3DDECLTYPE_UNUSED = 17, }} pub const MAXD3DDECLTYPE: D3DDECLTYPE = D3DDECLTYPE_UNUSED; STRUCT!{struct D3DVERTEXELEMENT9 { Stream: ::WORD, Offset: ::WORD, Type: ::BYTE, Method: ::BYTE, Usage: ::BYTE, UsageIndex: ::BYTE, }} pub type LPD3DVERTEXELEMENT9 = *mut D3DVERTEXELEMENT9; pub const D3DDECL_END: D3DVERTEXELEMENT9 = D3DVERTEXELEMENT9 { Stream: 0xFF, Offset: 0, Type: D3DDECLTYPE_UNUSED.0 as ::BYTE, Method: 0, Usage: 0, UsageIndex: 0, }; pub const D3DDP_MAXTEXCOORD: ::DWORD = 8; pub const D3DSTREAMSOURCE_INDEXEDDATA: ::DWORD = 1 << 30; pub const D3DSTREAMSOURCE_INSTANCEDATA: ::DWORD = 2 << 30; pub const D3DSI_OPCODE_MASK: ::DWORD = 0x0000FFFF; pub const D3DSI_INSTLENGTH_MASK: ::DWORD = 0x0F000000; pub const D3DSI_INSTLENGTH_SHIFT: ::DWORD = 24; ENUM!{enum D3DSHADER_INSTRUCTION_OPCODE_TYPE { D3DSIO_NOP = 0, D3DSIO_MOV = 1, D3DSIO_ADD = 2, D3DSIO_SUB = 3, D3DSIO_MAD = 4, D3DSIO_MUL = 5, D3DSIO_RCP = 6, D3DSIO_RSQ = 7, D3DSIO_DP3 = 8, D3DSIO_DP4 = 9, D3DSIO_MIN = 10, D3DSIO_MAX = 11, D3DSIO_SLT = 12, D3DSIO_SGE = 13, D3DSIO_EXP = 14, D3DSIO_LOG = 15, D3DSIO_LIT = 16, D3DSIO_DST = 17, D3DSIO_LRP = 18, D3DSIO_FRC = 18, D3DSIO_M4x4 = 20, D3DSIO_M4x3 = 21, D3DSIO_M3x4 = 22, D3DSIO_M3x3 = 23, D3DSIO_M3x2 = 24, D3DSIO_CALL = 25, D3DSIO_CALLNZ = 26, D3DSIO_LOOP = 27, D3DSIO_RET = 28, D3DSIO_ENDLOOP = 29, D3DSIO_LABEL = 30, D3DSIO_DCL = 31, D3DSIO_POW = 32, D3DSIO_CRS = 33, D3DSIO_SGN = 34, D3DSIO_ABS = 35, D3DSIO_NRM = 36, D3DSIO_SINCOS = 37, D3DSIO_REP = 38, D3DSIO_ENDREP = 39, D3DSIO_IF = 40, D3DSIO_IFC = 41, D3DSIO_ELSE = 42, D3DSIO_ENDIF = 43, D3DSIO_BREAK = 44, D3DSIO_BREAKC = 45, D3DSIO_MOVA = 46, D3DSIO_DEFB = 47, D3DSIO_DEFI = 48, D3DSIO_TEXCOORD = 64, D3DSIO_TEXKILL = 65, D3DSIO_TEX = 66, D3DSIO_TEXBEM = 67, D3DSIO_TEXBEML = 68, D3DSIO_TEXREG2AR = 69, D3DSIO_TEXREG2GB = 70, D3DSIO_TEXM3x2PAD = 71, D3DSIO_TEXM3x2TEX = 72, D3DSIO_TEXM3x3PAD = 73, D3DSIO_TEXM3x3TEX = 74, D3DSIO_RESERVED0 = 75, D3DSIO_TEXM3x3SPEC = 76, D3DSIO_TEXM3x3VSPEC = 77, D3DSIO_EXPP = 78, D3DSIO_LOGP = 79, D3DSIO_CND = 80, D3DSIO_DEF = 81, D3DSIO_TEXREG2RGB = 82, D3DSIO_TEXDP3TEX = 83, D3DSIO_TEXM3x2DEPTH = 84, D3DSIO_TEXDP3 = 85, D3DSIO_TEXM3x3 = 86, D3DSIO_TEXDEPTH = 87, D3DSIO_CMP = 88, D3DSIO_BEM = 89, D3DSIO_DP2ADD = 90, D3DSIO_DSX = 91, D3DSIO_DSY = 92, D3DSIO_TEXLDD = 93, D3DSIO_SETP = 94, D3DSIO_TEXLDL = 95, D3DSIO_BREAKP = 96, D3DSIO_PHASE = 0xFFFD, D3DSIO_COMMENT = 0xFFFE, D3DSIO_END = 0xFFFF, }} pub const D3DSI_COISSUE: ::DWORD = 0x40000000; pub const D3DSP_OPCODESPECIFICCONTROL_MASK: ::DWORD = 0x00ff0000; pub const D3DSP_OPCODESPECIFICCONTROL_SHIFT: ::DWORD = 16; pub const D3DSI_TEXLD_PROJECT: ::DWORD = 0x01 << D3DSP_OPCODESPECIFICCONTROL_SHIFT; pub const D3DSI_TEXLD_BIAS: ::DWORD = 0x02 << D3DSP_OPCODESPECIFICCONTROL_SHIFT; ENUM!{enum D3DSHADER_COMPARISON { D3DSPC_RESERVED0 = 0, D3DSPC_GT = 1, D3DSPC_EQ = 2, D3DSPC_GE = 3, D3DSPC_LT = 4, D3DSPC_NE = 5, D3DSPC_LE = 6, D3DSPC_RESERVED1 = 7, }} pub const D3DSHADER_COMPARISON_SHIFT: ::DWORD = D3DSP_OPCODESPECIFICCONTROL_SHIFT; pub const D3DSHADER_COMPARISON_MASK: ::DWORD = 0x7 << D3DSHADER_COMPARISON_SHIFT; pub const D3DSHADER_INSTRUCTION_PREDICATED: ::DWORD = 0x1 << 28; pub const D3DSP_DCL_USAGE_SHIFT: ::DWORD = 0; pub const D3DSP_DCL_USAGE_MASK: ::DWORD = 0x0000000f; pub const D3DSP_DCL_USAGEINDEX_SHIFT: ::DWORD = 16; pub const D3DSP_DCL_USAGEINDEX_MASK: ::DWORD = 0x000f0000; pub const D3DSP_TEXTURETYPE_SHIFT: ::DWORD = 27; pub const D3DSP_TEXTURETYPE_MASK: ::DWORD = 0x78000000; ENUM!{enum D3DSAMPLER_TEXTURE_TYPE { D3DSTT_UNKNOWN = 0 << D3DSP_TEXTURETYPE_SHIFT, D3DSTT_2D = 2 << D3DSP_TEXTURETYPE_SHIFT, D3DSTT_CUBE = 3 << D3DSP_TEXTURETYPE_SHIFT, D3DSTT_VOLUME = 4 << D3DSP_TEXTURETYPE_SHIFT, }} pub const D3DSP_REGNUM_MASK: ::DWORD = 0x000007FF; pub const D3DSP_WRITEMASK_0: ::DWORD = 0x00010000; pub const D3DSP_WRITEMASK_1: ::DWORD = 0x00020000; pub const D3DSP_WRITEMASK_2: ::DWORD = 0x00040000; pub const D3DSP_WRITEMASK_3: ::DWORD = 0x00080000; pub const D3DSP_WRITEMASK_ALL: ::DWORD = 0x000F0000; pub const D3DSP_DSTMOD_SHIFT: ::DWORD = 20; pub const D3DSP_DSTMOD_MASK: ::DWORD = 0x00F00000; pub const D3DSPDM_NONE: ::DWORD = 0 << D3DSP_DSTMOD_SHIFT; pub const D3DSPDM_SATURATE: ::DWORD = 1 << D3DSP_DSTMOD_SHIFT; pub const D3DSPDM_PARTIALPRECISION: ::DWORD = 2 << D3DSP_DSTMOD_SHIFT; pub const D3DSPDM_MSAMPCENTROID: ::DWORD = 4 << D3DSP_DSTMOD_SHIFT; pub const D3DSP_DSTSHIFT_SHIFT: ::DWORD = 24; pub const D3DSP_DSTSHIFT_MASK: ::DWORD = 0x0F000000; pub const D3DSP_REGTYPE_SHIFT: ::DWORD = 28; pub const D3DSP_REGTYPE_SHIFT2: ::DWORD = 8; pub const D3DSP_REGTYPE_MASK: ::DWORD = 0x70000000; pub const D3DSP_REGTYPE_MASK2: ::DWORD = 0x00001800; ENUM!{enum D3DSHADER_PARAM_REGISTER_TYPE { D3DSPR_TEMP = 0, D3DSPR_INPUT = 1, D3DSPR_CONST = 2, D3DSPR_ADDR = 3, D3DSPR_TEXTURE = 3, D3DSPR_RASTOUT = 4, D3DSPR_ATTROUT = 5, D3DSPR_TEXCRDOUT = 6, D3DSPR_OUTPUT = 6, D3DSPR_CONSTINT = 7, D3DSPR_COLOROUT = 8, D3DSPR_DEPTHOUT = 9, D3DSPR_SAMPLER = 10, D3DSPR_CONST2 = 11, D3DSPR_CONST3 = 12, D3DSPR_CONST4 = 13, D3DSPR_CONSTBOOL = 14, D3DSPR_LOOP = 15, D3DSPR_TEMPFLOAT16 = 16, D3DSPR_MISCTYPE = 17, D3DSPR_LABEL = 18, D3DSPR_PREDICATE = 19, }} ENUM!{enum D3DSHADER_MISCTYPE_OFFSETS { D3DSMO_POSITION = 0, D3DSMO_FACE = 1, }} ENUM!{enum D3DVS_RASTOUT_OFFSETS { D3DSRO_POSITION = 0, D3DSRO_FOG, D3DSRO_POINT_SIZE, }} pub const D3DVS_ADDRESSMODE_SHIFT: ::DWORD = 13; pub const D3DVS_ADDRESSMODE_MASK: ::DWORD = 1 << D3DVS_ADDRESSMODE_SHIFT; ENUM!{enum D3DVS_ADDRESSMODE_TYPE { D3DVS_ADDRMODE_ABSOLUTE = 0 << D3DVS_ADDRESSMODE_SHIFT, D3DVS_ADDRMODE_RELATIVE = 1 << D3DVS_ADDRESSMODE_SHIFT, }} pub const D3DSHADER_ADDRESSMODE_SHIFT: ::DWORD = 13; pub const D3DSHADER_ADDRESSMODE_MASK: ::DWORD = 1 << D3DSHADER_ADDRESSMODE_SHIFT; ENUM!{enum D3DSHADER_ADDRESSMODE_TYPE { D3DSHADER_ADDRMODE_ABSOLUTE = 0 << D3DSHADER_ADDRESSMODE_SHIFT, D3DSHADER_ADDRMODE_RELATIVE = 1 << D3DSHADER_ADDRESSMODE_SHIFT, }} pub const D3DVS_SWIZZLE_SHIFT: ::DWORD = 16; pub const D3DVS_SWIZZLE_MASK: ::DWORD = 0x00FF0000; pub const D3DVS_X_X: ::DWORD = 0 << D3DVS_SWIZZLE_SHIFT; pub const D3DVS_X_Y: ::DWORD = 1 << D3DVS_SWIZZLE_SHIFT; pub const D3DVS_X_Z: ::DWORD = 2 << D3DVS_SWIZZLE_SHIFT; pub const D3DVS_X_W: ::DWORD = 3 << D3DVS_SWIZZLE_SHIFT; pub const D3DVS_Y_X: ::DWORD = 0 << (D3DVS_SWIZZLE_SHIFT + 2); pub const D3DVS_Y_Y: ::DWORD = 1 << (D3DVS_SWIZZLE_SHIFT + 2); pub const D3DVS_Y_Z: ::DWORD = 2 << (D3DVS_SWIZZLE_SHIFT + 2); pub const D3DVS_Y_W: ::DWORD = 3 << (D3DVS_SWIZZLE_SHIFT + 2); pub const D3DVS_Z_X: ::DWORD = 0 << (D3DVS_SWIZZLE_SHIFT + 4); pub const D3DVS_Z_Y: ::DWORD = 1 << (D3DVS_SWIZZLE_SHIFT + 4); pub const D3DVS_Z_Z: ::DWORD = 2 << (D3DVS_SWIZZLE_SHIFT + 4); pub const D3DVS_Z_W: ::DWORD = 3 << (D3DVS_SWIZZLE_SHIFT + 4); pub const D3DVS_W_X: ::DWORD = 0 << (D3DVS_SWIZZLE_SHIFT + 6); pub const D3DVS_W_Y: ::DWORD = 1 << (D3DVS_SWIZZLE_SHIFT + 6); pub const D3DVS_W_Z: ::DWORD = 2 << (D3DVS_SWIZZLE_SHIFT + 6); pub const D3DVS_W_W: ::DWORD = 3 << (D3DVS_SWIZZLE_SHIFT + 6); pub const D3DVS_NOSWIZZLE: ::DWORD = D3DVS_X_X | D3DVS_Y_Y | D3DVS_Z_Z | D3DVS_W_W; pub const D3DSP_SWIZZLE_SHIFT: ::DWORD = 16; pub const D3DSP_SWIZZLE_MASK: ::DWORD = 0x00FF0000; pub const D3DSP_NOSWIZZLE: ::DWORD = (0 << (D3DSP_SWIZZLE_SHIFT + 0)) | (1 << (D3DSP_SWIZZLE_SHIFT + 2)) | (2 << (D3DSP_SWIZZLE_SHIFT + 4)) | (3 << (D3DSP_SWIZZLE_SHIFT + 6)); pub const D3DSP_REPLICATERED: ::DWORD = (0 << (D3DSP_SWIZZLE_SHIFT + 0)) | (0 << (D3DSP_SWIZZLE_SHIFT + 2)) | (0 << (D3DSP_SWIZZLE_SHIFT + 4)) | (0 << (D3DSP_SWIZZLE_SHIFT + 6)); pub const D3DSP_REPLICATEGREEN: ::DWORD = (1 << (D3DSP_SWIZZLE_SHIFT + 0)) | (1 << (D3DSP_SWIZZLE_SHIFT + 2)) | (1 << (D3DSP_SWIZZLE_SHIFT + 4)) | (1 << (D3DSP_SWIZZLE_SHIFT + 6)); pub const D3DSP_REPLICATEBLUE: ::DWORD = (2 << (D3DSP_SWIZZLE_SHIFT + 0)) | (2 << (D3DSP_SWIZZLE_SHIFT + 2)) | (2 << (D3DSP_SWIZZLE_SHIFT + 4)) | (2 << (D3DSP_SWIZZLE_SHIFT + 6)); pub const D3DSP_REPLICATEALPHA: ::DWORD = (3 << (D3DSP_SWIZZLE_SHIFT + 0)) | (3 << (D3DSP_SWIZZLE_SHIFT + 2)) | (3 << (D3DSP_SWIZZLE_SHIFT + 4)) | (3 << (D3DSP_SWIZZLE_SHIFT + 6)); pub const D3DSP_SRCMOD_SHIFT: ::DWORD = 24; pub const D3DSP_SRCMOD_MASK: ::DWORD = 0x0F000000; ENUM!{enum D3DSHADER_PARAM_SRCMOD_TYPE { D3DSPSM_NONE = 0 << D3DSP_SRCMOD_SHIFT, D3DSPSM_NEG = 1 << D3DSP_SRCMOD_SHIFT, D3DSPSM_BIAS = 2 << D3DSP_SRCMOD_SHIFT, D3DSPSM_BIASNEG = 3 << D3DSP_SRCMOD_SHIFT, D3DSPSM_SIGN = 4 << D3DSP_SRCMOD_SHIFT, D3DSPSM_SIGNNEG = 5 << D3DSP_SRCMOD_SHIFT, D3DSPSM_COMP = 6 << D3DSP_SRCMOD_SHIFT, D3DSPSM_X2 = 7 << D3DSP_SRCMOD_SHIFT, D3DSPSM_X2NEG = 8 << D3DSP_SRCMOD_SHIFT, D3DSPSM_DZ = 9 << D3DSP_SRCMOD_SHIFT, D3DSPSM_DW = 10 << D3DSP_SRCMOD_SHIFT, D3DSPSM_ABS = 11 << D3DSP_SRCMOD_SHIFT, D3DSPSM_ABSNEG = 12 << D3DSP_SRCMOD_SHIFT, D3DSPSM_NOT = 13 << D3DSP_SRCMOD_SHIFT, }} pub const D3DSP_MIN_PRECISION_SHIFT: ::DWORD = 14; pub const D3DSP_MIN_PRECISION_MASK: ::DWORD = 0x0000C000; ENUM!{enum D3DSHADER_MIN_PRECISION { D3DMP_DEFAULT = 0, D3DMP_16 = 1, D3DMP_2_8 = 2, }} pub const D3DSI_COMMENTSIZE_SHIFT: ::DWORD = 16; pub const D3DSI_COMMENTSIZE_MASK: ::DWORD = 0x7FFF0000; pub const D3DPS_END: ::DWORD = 0x0000FFFF; pub const D3DVS_END: ::DWORD = 0x0000FFFF; ENUM!{enum D3DBASISTYPE { D3DBASIS_BEZIER = 0, D3DBASIS_BSPLINE = 1, D3DBASIS_CATMULL_ROM = 2, }} ENUM!{enum D3DDEGREETYPE { D3DDEGREE_LINEAR = 1, D3DDEGREE_QUADRATIC = 2, D3DDEGREE_CUBIC = 3, D3DDEGREE_QUINTIC = 5, }} ENUM!{enum D3DPATCHEDGESTYLE { D3DPATCHEDGE_DISCRETE = 0, D3DPATCHEDGE_CONTINUOUS = 1, }} ENUM!{enum D3DSTATEBLOCKTYPE { D3DSBT_ALL = 1, D3DSBT_PIXELSTATE = 2, D3DSBT_VERTEXSTATE = 3, }} FLAGS!{enum D3DVERTEXBLENDFLAGS { D3DVBF_DISABLE = 0, D3DVBF_1WEIGHTS = 1, D3DVBF_2WEIGHTS = 2, D3DVBF_3WEIGHTS = 3, D3DVBF_TWEENING = 255, D3DVBF_0WEIGHTS = 256, }} ENUM!{enum D3DTEXTURETRANSFORMFLAGS { D3DTTFF_DISABLE = 0, D3DTTFF_COUNT1 = 1, D3DTTFF_COUNT2 = 2, D3DTTFF_COUNT3 = 3, D3DTTFF_COUNT4 = 4, D3DTTFF_PROJECTED = 256, }} pub const D3DFVF_TEXTUREFORMAT2: ::DWORD = 0; pub const D3DFVF_TEXTUREFORMAT1: ::DWORD = 3; pub const D3DFVF_TEXTUREFORMAT3: ::DWORD = 1; pub const D3DFVF_TEXTUREFORMAT4: ::DWORD = 2; ENUM!{enum D3DDEVTYPE { D3DDEVTYPE_HAL = 1, D3DDEVTYPE_REF = 2, D3DDEVTYPE_SW = 3, D3DDEVTYPE_NULLREF = 4, }} ENUM!{enum D3DMULTISAMPLE_TYPE { D3DMULTISAMPLE_NONE = 0, D3DMULTISAMPLE_NONMASKABLE = 1, D3DMULTISAMPLE_2_SAMPLES = 2, D3DMULTISAMPLE_3_SAMPLES = 3, D3DMULTISAMPLE_4_SAMPLES = 4, D3DMULTISAMPLE_5_SAMPLES = 5, D3DMULTISAMPLE_6_SAMPLES = 6, D3DMULTISAMPLE_7_SAMPLES = 7, D3DMULTISAMPLE_8_SAMPLES = 8, D3DMULTISAMPLE_9_SAMPLES = 9, D3DMULTISAMPLE_10_SAMPLES = 10, D3DMULTISAMPLE_11_SAMPLES = 11, D3DMULTISAMPLE_12_SAMPLES = 12, D3DMULTISAMPLE_13_SAMPLES = 13, D3DMULTISAMPLE_14_SAMPLES = 14, D3DMULTISAMPLE_15_SAMPLES = 15, D3DMULTISAMPLE_16_SAMPLES = 16, }} ENUM!{enum D3DFORMAT { D3DFMT_UNKNOWN = 0, D3DFMT_R8G8B8 = 20, D3DFMT_A8R8G8B8 = 21, D3DFMT_X8R8G8B8 = 22, D3DFMT_R5G6B5 = 23, D3DFMT_X1R5G5B5 = 24, D3DFMT_A1R5G5B5 = 25, D3DFMT_A4R4G4B4 = 26, D3DFMT_R3G3B2 = 27, D3DFMT_A8 = 28, D3DFMT_A8R3G3B2 = 29, D3DFMT_X4R4G4B4 = 30, D3DFMT_A2B10G10R10 = 31, D3DFMT_A8B8G8R8 = 32, D3DFMT_X8B8G8R8 = 33, D3DFMT_G16R16 = 34, D3DFMT_A2R10G10B10 = 35, D3DFMT_A16B16G16R16 = 36, D3DFMT_A8P8 = 40, D3DFMT_P8 = 41, D3DFMT_L8 = 50, D3DFMT_A8L8 = 51, D3DFMT_A4L4 = 52, D3DFMT_V8U8 = 60, D3DFMT_L6V5U5 = 61, D3DFMT_X8L8V8U8 = 62, D3DFMT_Q8W8V8U8 = 63, D3DFMT_V16U16 = 64, D3DFMT_A2W10V10U10 = 67, D3DFMT_UYVY = MAKEFOURCC!(b'U', b'Y', b'V', b'Y') as u32, D3DFMT_R8G8_B8G8 = MAKEFOURCC!(b'R', b'G', b'B', b'G') as u32, D3DFMT_YUY2 = MAKEFOURCC!(b'Y', b'U', b'Y', b'2') as u32, D3DFMT_G8R8_G8B8 = MAKEFOURCC!(b'G', b'R', b'G', b'B') as u32, D3DFMT_DXT1 = MAKEFOURCC!(b'D', b'X', b'T', b'1') as u32, D3DFMT_DXT2 = MAKEFOURCC!(b'D', b'X', b'T', b'2') as u32, D3DFMT_DXT3 = MAKEFOURCC!(b'D', b'X', b'T', b'3') as u32, D3DFMT_DXT4 = MAKEFOURCC!(b'D', b'X', b'T', b'4') as u32, D3DFMT_DXT5 = MAKEFOURCC!(b'D', b'X', b'T', b'5') as u32, D3DFMT_D16_LOCKABLE = 70, D3DFMT_D32 = 71, D3DFMT_D15S1 = 73, D3DFMT_D24S8 = 75, D3DFMT_D24X8 = 77, D3DFMT_D24X4S4 = 79, D3DFMT_D16 = 80, D3DFMT_D32F_LOCKABLE = 82, D3DFMT_D24FS8 = 83, D3DFMT_D32_LOCKABLE = 84, D3DFMT_S8_LOCKABLE = 85, D3DFMT_L16 = 81, D3DFMT_VERTEXDATA = 100, D3DFMT_INDEX16 = 101, D3DFMT_INDEX32 = 102, D3DFMT_Q16W16V16U16 = 110, D3DFMT_MULTI2_ARGB8 = MAKEFOURCC!(b'M', b'E', b'T', b'1') as u32, D3DFMT_R16F = 111, D3DFMT_G16R16F = 112, D3DFMT_A16B16G16R16F = 113, D3DFMT_R32F = 114, D3DFMT_G32R32F = 115, D3DFMT_A32B32G32R32F = 116, D3DFMT_CxV8U8 = 117, D3DFMT_A1 = 118, D3DFMT_A2B10G10R10_XR_BIAS = 119, D3DFMT_BINARYBUFFER = 199, }} STRUCT!{struct D3DDISPLAYMODE { Width: ::UINT, Height: ::UINT, RefreshRate: ::UINT, Format: D3DFORMAT, }} STRUCT!{struct D3DDEVICE_CREATION_PARAMETERS { AdapterOrdinal: ::UINT, DeviceType: D3DDEVTYPE, hFocusWindow: ::HWND, BehaviorFlags: ::DWORD, }} ENUM!{enum D3DSWAPEFFECT { D3DSWAPEFFECT_DISCARD = 1, D3DSWAPEFFECT_FLIP = 2, D3DSWAPEFFECT_COPY = 3, D3DSWAPEFFECT_OVERLAY = 4, D3DSWAPEFFECT_FLIPEX = 5, }} ENUM!{enum D3DPOOL { D3DPOOL_DEFAULT = 0, D3DPOOL_MANAGED = 1, D3DPOOL_SYSTEMMEM = 2, D3DPOOL_SCRATCH = 3, }} pub const D3DPRESENT_RATE_DEFAULT: ::DWORD = 0x00000000; STRUCT!{struct D3DPRESENT_PARAMETERS { BackBufferWidth: ::UINT, BackBufferHeight: ::UINT, BackBufferFormat: D3DFORMAT, BackBufferCount: ::UINT, MultiSampleType: D3DMULTISAMPLE_TYPE, MultiSampleQuality: ::DWORD, SwapEffect: D3DSWAPEFFECT, hDeviceWindow: ::HWND, Windowed: ::BOOL, EnableAutoDepthStencil: ::BOOL, AutoDepthStencilFormat: D3DFORMAT, Flags: ::DWORD, FullScreen_RefreshRateInHz: ::UINT, PresentationInterval: ::UINT, }} pub const D3DPRESENTFLAG_LOCKABLE_BACKBUFFER: ::DWORD = 0x00000001; pub const D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL: ::DWORD = 0x00000002; pub const D3DPRESENTFLAG_DEVICECLIP: ::DWORD = 0x00000004; pub const D3DPRESENTFLAG_VIDEO: ::DWORD = 0x00000010; pub const D3DPRESENTFLAG_NOAUTOROTATE: ::DWORD = 0x00000020; pub const D3DPRESENTFLAG_UNPRUNEDMODE: ::DWORD = 0x00000040; pub const D3DPRESENTFLAG_OVERLAY_LIMITEDRGB: ::DWORD = 0x00000080; pub const D3DPRESENTFLAG_OVERLAY_YCbCr_BT709: ::DWORD = 0x00000100; pub const D3DPRESENTFLAG_OVERLAY_YCbCr_xvYCC: ::DWORD = 0x00000200; pub const D3DPRESENTFLAG_RESTRICTED_CONTENT: ::DWORD = 0x00000400; pub const D3DPRESENTFLAG_RESTRICT_SHARED_RESOURCE_DRIVER: ::DWORD = 0x00000800; #[repr(C)] #[derive(Copy)] pub struct D3DGAMMARAMP { pub red: [::WORD; 256], pub green: [::WORD; 256], pub blue: [::WORD; 256], } impl Clone for D3DGAMMARAMP { fn clone(&self) -> D3DGAMMARAMP { *self } } ENUM!{enum D3DBACKBUFFER_TYPE { D3DBACKBUFFER_TYPE_MONO = 0, D3DBACKBUFFER_TYPE_LEFT = 1, D3DBACKBUFFER_TYPE_RIGHT = 2, }} ENUM!{enum D3DRESOURCETYPE { D3DRTYPE_SURFACE = 1, D3DRTYPE_VOLUME = 2, D3DRTYPE_TEXTURE = 3, D3DRTYPE_VOLUMETEXTURE = 4, D3DRTYPE_CUBETEXTURE = 5, D3DRTYPE_VERTEXBUFFER = 6, D3DRTYPE_INDEXBUFFER = 7, }} pub const D3DUSAGE_RENDERTARGET: ::DWORD = 0x00000001; pub const D3DUSAGE_DEPTHSTENCIL: ::DWORD = 0x00000002; pub const D3DUSAGE_DYNAMIC: ::DWORD = 0x00000200; pub const D3DUSAGE_NONSECURE: ::DWORD = 0x00800000; pub const D3DUSAGE_AUTOGENMIPMAP: ::DWORD = 0x00000400; pub const D3DUSAGE_DMAP: ::DWORD = 0x00004000; pub const D3DUSAGE_QUERY_LEGACYBUMPMAP: ::DWORD = 0x00008000; pub const D3DUSAGE_QUERY_SRGBREAD: ::DWORD = 0x00010000; pub const D3DUSAGE_QUERY_FILTER: ::DWORD = 0x00020000; pub const D3DUSAGE_QUERY_SRGBWRITE: ::DWORD = 0x00040000; pub const D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING: ::DWORD = 0x00080000; pub const D3DUSAGE_QUERY_VERTEXTEXTURE: ::DWORD = 0x00100000; pub const D3DUSAGE_QUERY_WRAPANDMIP: ::DWORD = 0x00200000; pub const D3DUSAGE_WRITEONLY: ::DWORD = 0x00000008; pub const D3DUSAGE_SOFTWAREPROCESSING: ::DWORD = 0x00000010; pub const D3DUSAGE_DONOTCLIP: ::DWORD = 0x00000020; pub const D3DUSAGE_POINTS: ::DWORD = 0x00000040; pub const D3DUSAGE_RTPATCHES: ::DWORD = 0x00000080; pub const D3DUSAGE_NPATCHES: ::DWORD = 0x00000100; pub const D3DUSAGE_TEXTAPI: ::DWORD = 0x10000000; pub const D3DUSAGE_RESTRICTED_CONTENT: ::DWORD = 0x00000800; pub const D3DUSAGE_RESTRICT_SHARED_RESOURCE: ::DWORD = 0x00002000; pub const D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER: ::DWORD = 0x00001000; ENUM!{enum D3DCUBEMAP_FACES { D3DCUBEMAP_FACE_POSITIVE_X = 0, D3DCUBEMAP_FACE_NEGATIVE_X = 1, D3DCUBEMAP_FACE_POSITIVE_Y = 2, D3DCUBEMAP_FACE_NEGATIVE_Y = 3, D3DCUBEMAP_FACE_POSITIVE_Z = 4, D3DCUBEMAP_FACE_NEGATIVE_Z = 5, }} pub const D3DLOCK_READONLY: ::DWORD = 0x00000010; pub const D3DLOCK_DISCARD: ::DWORD = 0x00002000; pub const D3DLOCK_NOOVERWRITE: ::DWORD = 0x00001000; pub const D3DLOCK_NOSYSLOCK: ::DWORD = 0x00000800; pub const D3DLOCK_DONOTWAIT: ::DWORD = 0x00004000; pub const D3DLOCK_NO_DIRTY_UPDATE: ::DWORD = 0x00008000; STRUCT!{struct D3DVERTEXBUFFER_DESC { Format: D3DFORMAT, Type: D3DRESOURCETYPE, Usage: ::DWORD, Pool: D3DPOOL, Size: ::UINT, FVF: ::DWORD, }} STRUCT!{struct D3DINDEXBUFFER_DESC { Format: D3DFORMAT, Type: D3DRESOURCETYPE, Usage: ::DWORD, Pool: D3DPOOL, Size: ::UINT, }} STRUCT!{struct D3DSURFACE_DESC { Format: D3DFORMAT, Type: D3DRESOURCETYPE, Usage: ::DWORD, Pool: D3DPOOL, MultiSampleType: D3DMULTISAMPLE_TYPE, MultiSampleQuality: ::DWORD, Width: ::UINT, Height: ::UINT, }} STRUCT!{struct D3DVOLUME_DESC { Format: D3DFORMAT, Type: D3DRESOURCETYPE, Usage: ::DWORD, Pool: D3DPOOL, Width: ::UINT, Height: ::UINT, Depth: ::UINT, }} STRUCT!{struct D3DLOCKED_RECT { Pitch: ::INT, pBits: *mut ::c_void, }} STRUCT!{struct D3DBOX { Left: ::UINT, Top: ::UINT, Right: ::UINT, Bottom: ::UINT, Front: ::UINT, Back: ::UINT, }} STRUCT!{struct D3DLOCKED_BOX { RowPitch: ::INT, SlicePitch: ::INT, pBits: *mut ::c_void, }} STRUCT!{struct D3DRANGE { Offset: ::UINT, Size: ::UINT, }} STRUCT!{struct D3DRECTPATCH_INFO { StartVertexOffsetWidth: ::UINT, StartVertexOffsetHeight: ::UINT, Width: ::UINT, Height: ::UINT, Stride: ::UINT, Basis: D3DBASISTYPE, Degree: D3DDEGREETYPE, }} STRUCT!{struct D3DTRIPATCH_INFO { StartVertexOffset: ::UINT, NumVertices: ::UINT, Basis: D3DBASISTYPE, Degree: D3DDEGREETYPE, }} pub const MAX_DEVICE_IDENTIFIER_STRING: usize = 512; #[repr(C)] #[derive(Copy)] pub struct D3DADAPTER_IDENTIFIER9 { pub Driver: [::c_char; MAX_DEVICE_IDENTIFIER_STRING], pub Description: [::c_char; MAX_DEVICE_IDENTIFIER_STRING], pub DeviceName: [::c_char; 32], pub DriverVersion: ::LARGE_INTEGER, pub VendorId: ::DWORD, pub DeviceId: ::DWORD, pub SubSysId: ::DWORD, pub Revision: ::DWORD, pub DeviceIdentifier: ::GUID, pub WHQLLevel: ::DWORD, } impl Clone for D3DADAPTER_IDENTIFIER9 { fn clone(&self) -> D3DADAPTER_IDENTIFIER9 { *self } } STRUCT!{struct D3DRASTER_STATUS { InVBlank: ::BOOL, ScanLine: ::UINT, }} ENUM!{enum D3DDEBUGMONITORTOKENS { D3DDMT_ENABLE = 0, D3DDMT_DISABLE = 1, }} ENUM!{enum D3DQUERYTYPE { D3DQUERYTYPE_VCACHE = 4, D3DQUERYTYPE_RESOURCEMANAGER = 5, D3DQUERYTYPE_VERTEXSTATS = 6, D3DQUERYTYPE_EVENT = 8, D3DQUERYTYPE_OCCLUSION = 9, D3DQUERYTYPE_TIMESTAMP = 10, D3DQUERYTYPE_TIMESTAMPDISJOINT = 11, D3DQUERYTYPE_TIMESTAMPFREQ = 12, D3DQUERYTYPE_PIPELINETIMINGS = 13, D3DQUERYTYPE_INTERFACETIMINGS = 14, D3DQUERYTYPE_VERTEXTIMINGS = 15, D3DQUERYTYPE_PIXELTIMINGS = 16, D3DQUERYTYPE_BANDWIDTHTIMINGS = 17, D3DQUERYTYPE_CACHEUTILIZATION = 18, D3DQUERYTYPE_MEMORYPRESSURE = 19, }} pub const D3DISSUE_END: ::DWORD = 1 << 0; pub const D3DISSUE_BEGIN: ::DWORD = 1 << 1; pub const D3DGETDATA_FLUSH: ::DWORD = 1 << 0; STRUCT!{struct D3DRESOURCESTATS { bThrashing: ::BOOL, ApproxBytesDownloaded: ::DWORD, NumEvicts: ::DWORD, NumVidCreates: ::DWORD, LastPri: ::DWORD, NumUsed: ::DWORD, NumUsedInVidMem: ::DWORD, WorkingSet: ::DWORD, WorkingSetBytes: ::DWORD, TotalManaged: ::DWORD, TotalBytes: ::DWORD, }} pub const D3DRTYPECOUNT: usize = 8; STRUCT!{struct D3DDEVINFO_RESOURCEMANAGER { stats: [D3DRESOURCESTATS; 8 /*D3DRTYPECOUNT, rust bug?*/], }} pub type LPD3DDEVINFO_RESOURCEMANAGER = *mut D3DDEVINFO_RESOURCEMANAGER; STRUCT!{struct D3DDEVINFO_D3DVERTEXSTATS { NumRenderedTriangles: ::DWORD, NumExtraClippingTriangles: ::DWORD, }} pub type LPD3DDEVINFO_D3DVERTEXSTATS = *mut D3DDEVINFO_D3DVERTEXSTATS; STRUCT!{struct D3DDEVINFO_VCACHE { Pattern: ::DWORD, OptMethod: ::DWORD, CacheSize: ::DWORD, MagicNumber: ::DWORD, }} pub type LPD3DDEVINFO_VCACHE = *mut D3DDEVINFO_VCACHE; STRUCT!{struct D3DDEVINFO_D3D9PIPELINETIMINGS { VertexProcessingTimePercent: ::FLOAT, PixelProcessingTimePercent: ::FLOAT, OtherGPUProcessingTimePercent: ::FLOAT, GPUIdleTimePercent: ::FLOAT, }} STRUCT!{struct D3DDEVINFO_D3D9INTERFACETIMINGS { WaitingForGPUToUseApplicationResourceTimePercent: ::FLOAT, WaitingForGPUToAcceptMoreCommandsTimePercent: ::FLOAT, WaitingForGPUToStayWithinLatencyTimePercent: ::FLOAT, WaitingForGPUExclusiveResourceTimePercent: ::FLOAT, WaitingForGPUOtherTimePercent: ::FLOAT, }} STRUCT!{struct D3DDEVINFO_D3D9STAGETIMINGS { MemoryProcessingPercent: ::FLOAT, ComputationProcessingPercent: ::FLOAT, }} STRUCT!{struct D3DDEVINFO_D3D9BANDWIDTHTIMINGS { MaxBandwidthUtilized: ::FLOAT, FrontEndUploadMemoryUtilizedPercent: ::FLOAT, VertexRateUtilizedPercent: ::FLOAT, TriangleSetupRateUtilizedPercent: ::FLOAT, FillRateUtilizedPercent: ::FLOAT, }} STRUCT!{struct D3DDEVINFO_D3D9CACHEUTILIZATION { TextureCacheHitRate: ::FLOAT, PostTransformVertexCacheHitRate: ::FLOAT, }} STRUCT!{struct D3DMEMORYPRESSURE { BytesEvictedFromProcess: ::UINT64, SizeOfInefficientAllocation: ::UINT64, LevelOfEfficiency: ::DWORD, }} ENUM!{enum D3DCOMPOSERECTSOP { D3DCOMPOSERECTS_COPY = 1, D3DCOMPOSERECTS_OR = 2, D3DCOMPOSERECTS_AND = 3, D3DCOMPOSERECTS_NEG = 4, }} STRUCT!{struct D3DCOMPOSERECTDESC { X: ::USHORT, Y: ::USHORT, Width: ::USHORT, Height: ::USHORT, }} STRUCT!{struct D3DCOMPOSERECTDESTINATION { SrcRectIndex: ::USHORT, Reserved: ::USHORT, X: ::SHORT, Y: ::SHORT, }} pub const D3DCOMPOSERECTS_MAXNUMRECTS: ::DWORD = 0xFFFF; pub const D3DCONVOLUTIONMONO_MAXWIDTH: ::DWORD = 7; pub const D3DCONVOLUTIONMONO_MAXHEIGHT: ::DWORD = D3DCONVOLUTIONMONO_MAXWIDTH; pub const D3DFMT_A1_SURFACE_MAXWIDTH: ::DWORD = 8192; pub const D3DFMT_A1_SURFACE_MAXHEIGHT: ::DWORD = 2048; STRUCT!{struct D3DPRESENTSTATS { PresentCount: ::UINT, PresentRefreshCount: ::UINT, SyncRefreshCount: ::UINT, SyncQPCTime: ::LARGE_INTEGER, SyncGPUTime: ::LARGE_INTEGER, }} ENUM!{enum D3DSCANLINEORDERING { D3DSCANLINEORDERING_UNKNOWN = 0, D3DSCANLINEORDERING_PROGRESSIVE = 1, D3DSCANLINEORDERING_INTERLACED = 2, }} STRUCT!{struct D3DDISPLAYMODEEX { Size: ::UINT, Width: ::UINT, Height: ::UINT, RefreshRate: ::UINT, Format: D3DFORMAT, ScanLineOrdering: D3DSCANLINEORDERING, }} STRUCT!{struct D3DDISPLAYMODEFILTER { Size: ::UINT, Format: D3DFORMAT, ScanLineOrdering: D3DSCANLINEORDERING, }} ENUM!{enum D3DDISPLAYROTATION { D3DDISPLAYROTATION_IDENTITY = 1, D3DDISPLAYROTATION_90 = 2, D3DDISPLAYROTATION_180 = 3, D3DDISPLAYROTATION_270 = 4, }} pub const D3D9_RESOURCE_PRIORITY_MINIMUM: ::DWORD = 0x28000000; pub const D3D9_RESOURCE_PRIORITY_LOW: ::DWORD = 0x50000000; pub const D3D9_RESOURCE_PRIORITY_NORMAL: ::DWORD = 0x78000000; pub const D3D9_RESOURCE_PRIORITY_HIGH: ::DWORD = 0xa0000000; pub const D3D9_RESOURCE_PRIORITY_MAXIMUM: ::DWORD = 0xc8000000; pub const D3D_OMAC_SIZE: usize = 16; STRUCT!{struct D3D_OMAC { Omac: [::BYTE; D3D_OMAC_SIZE], }} ENUM!{enum D3DAUTHENTICATEDCHANNELTYPE { D3DAUTHENTICATEDCHANNEL_D3D9 = 1, D3DAUTHENTICATEDCHANNEL_DRIVER_SOFTWARE = 2, D3DAUTHENTICATEDCHANNEL_DRIVER_HARDWARE = 3, }} STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERY_INPUT { QueryType: ::GUID, hChannel: ::HANDLE, SequenceNumber: ::UINT, }} STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT { omac: D3D_OMAC, QueryType: ::GUID, hChannel: ::HANDLE, SequenceNumber: ::UINT, ReturnCode: ::HRESULT, }} DEFINE_GUID!(D3DAUTHENTICATEDQUERY_PROTECTION, 0xa84eb584, 0xc495, 0x48aa, 0xb9, 0x4d, 0x8b, 0xd2, 0xd6, 0xfb, 0xce, 0x5); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS { Value: ::UINT, }} STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT { Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, ProtectionFlags: D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS, }} DEFINE_GUID!(D3DAUTHENTICATEDQUERY_CHANNELTYPE, 0xbc1b18a5, 0xb1fb, 0x42ab, 0xbd, 0x94, 0xb5, 0x82, 0x8b, 0x4b, 0xf7, 0xbe); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT { Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, ChannelType: D3DAUTHENTICATEDCHANNELTYPE, }} DEFINE_GUID!(D3DAUTHENTICATEDQUERY_DEVICEHANDLE, 0xec1c539d, 0x8cff, 0x4e2a, 0xbc, 0xc4, 0xf5, 0x69, 0x2f, 0x99, 0xf4, 0x80); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT { Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, DeviceHandle: ::HANDLE, }} DEFINE_GUID!(D3DAUTHENTICATEDQUERY_CRYPTOSESSION, 0x2634499e, 0xd018, 0x4d74, 0xac, 0x17, 0x7f, 0x72, 0x40, 0x59, 0x52, 0x8d); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_INPUT { Input: D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, DXVA2DecodeHandle: ::HANDLE, }} STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT { Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, DXVA2DecodeHandle: ::HANDLE, CryptoSessionHandle: ::HANDLE, DeviceHandle: ::HANDLE, }} DEFINE_GUID!(D3DAUTHENTICATEDQUERY_RESTRICTEDSHAREDRESOURCEPROCESSCOUNT, 0xdb207b3, 0x9450, 0x46a6, 0x82, 0xde, 0x1b, 0x96, 0xd4, 0x4f, 0x9c, 0xf2); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT { Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, NumRestrictedSharedResourceProcesses: ::UINT, }} DEFINE_GUID!(D3DAUTHENTICATEDQUERY_RESTRICTEDSHAREDRESOURCEPROCESS, 0x649bbadb, 0xf0f4, 0x4639, 0xa1, 0x5b, 0x24, 0x39, 0x3f, 0xc3, 0xab, 0xac); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_INPUT { Input: D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, ProcessIndex: ::UINT, }} ENUM!{enum D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE { PROCESSIDTYPE_UNKNOWN = 0, PROCESSIDTYPE_DWM = 1, PROCESSIDTYPE_HANDLE = 2, }} STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUTPUT { Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, ProcessIndex: ::UINT, ProcessIdentifer: D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE, ProcessHandle: ::HANDLE, }} DEFINE_GUID!(D3DAUTHENTICATEDQUERY_UNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT, 0x12f0bd6, 0xe662, 0x4474, 0xbe, 0xfd, 0xaa, 0x53, 0xe5, 0x14, 0x3c, 0x6d); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT { Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, NumUnrestrictedProtectedSharedResources: ::UINT, }} DEFINE_GUID!(D3DAUTHENTICATEDQUERY_OUTPUTIDCOUNT, 0x2c042b5e, 0x8c07, 0x46d5, 0xaa, 0xbe, 0x8f, 0x75, 0xcb, 0xad, 0x4c, 0x31); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT { Input: D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, DeviceHandle: ::HANDLE, CryptoSessionHandle: ::HANDLE, }} STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT { Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, DeviceHandle: ::HANDLE, CryptoSessionHandle: ::HANDLE, NumOutputIDs: ::UINT, }} DEFINE_GUID!(D3DAUTHENTICATEDQUERY_OUTPUTID, 0x839ddca3, 0x9b4e, 0x41e4, 0xb0, 0x53, 0x89, 0x2b, 0xd2, 0xa1, 0x1e, 0xe7); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT { Input: D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, DeviceHandle: ::HANDLE, CryptoSessionHandle: ::HANDLE, OutputIDIndex: ::UINT, }} STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT { Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, DeviceHandle: ::HANDLE, CryptoSessionHandle: ::HANDLE, OutputIDIndex: ::UINT, OutputID: ::UINT64, }} DEFINE_GUID!(D3DAUTHENTICATEDQUERY_ACCESSIBILITYATTRIBUTES, 0x6214d9d2, 0x432c, 0x4abb, 0x9f, 0xce, 0x21, 0x6e, 0xea, 0x26, 0x9e, 0x3b); FLAGS!{enum D3DBUSTYPE { D3DBUSTYPE_OTHER = 0x00000000, D3DBUSTYPE_PCI = 0x00000001, D3DBUSTYPE_PCIX = 0x00000002, D3DBUSTYPE_PCIEXPRESS = 0x00000003, D3DBUSTYPE_AGP = 0x00000004, D3DBUSIMPL_MODIFIER_INSIDE_OF_CHIPSET = 0x00010000, MD3DBUSIMPL_ODIFIER_TRACKS_ON_MOTHER_BOARD_TO_CHIP = 0x00020000, D3DBUSIMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_SOCKET = 0x00030000, D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR = 0x00040000, D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR_INSIDE_OF_NUAE = 0x00050000, D3DBUSIMPL_MODIFIER_NON_STANDARD = 0x80000000, }} STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT { Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, BusType: D3DBUSTYPE, bAccessibleInContiguousBlocks: ::BOOL, bAccessibleInNonContiguousBlocks: ::BOOL, }} DEFINE_GUID!(D3DAUTHENTICATEDQUERY_ENCRYPTIONWHENACCESSIBLEGUIDCOUNT, 0xb30f7066, 0x203c, 0x4b07, 0x93, 0xfc, 0xce, 0xaa, 0xfd, 0x61, 0x24, 0x1e); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT { Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, NumEncryptionGuids: ::UINT, }} DEFINE_GUID!(D3DAUTHENTICATEDQUERY_ENCRYPTIONWHENACCESSIBLEGUID, 0xf83a5958, 0xe986, 0x4bda, 0xbe, 0xb0, 0x41, 0x1f, 0x6a, 0x7a, 0x1, 0xb7); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_INPUT { Input: D3DAUTHENTICATEDCHANNEL_QUERY_INPUT, EncryptionGuidIndex: ::UINT, }} STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT { Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, EncryptionGuidIndex: ::UINT, EncryptionGuid: ::GUID, }} DEFINE_GUID!(D3DAUTHENTICATEDQUERY_CURRENTENCRYPTIONWHENACCESSIBLE, 0xec1791c7, 0xdad3, 0x4f15, 0x9e, 0xc3, 0xfa, 0xa9, 0x3d, 0x60, 0xd4, 0xf0); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT { Output: D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT, EncryptionGuid: ::GUID, }} STRUCT!{struct D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT { omac: D3D_OMAC, ConfigureType: ::GUID, hChannel: ::HANDLE, SequenceNumber: ::UINT, }} STRUCT!{struct D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT { omac: D3D_OMAC, ConfigureType: ::GUID, hChannel: ::HANDLE, SequenceNumber: ::UINT, ReturnCode: ::HRESULT, }} DEFINE_GUID!(D3DAUTHENTICATEDCONFIGURE_INITIALIZE, 0x6114bdb, 0x3523, 0x470a, 0x8d, 0xca, 0xfb, 0xc2, 0x84, 0x51, 0x54, 0xf0); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE { Parameters: D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, StartSequenceQuery: ::UINT, StartSequenceConfigure: ::UINT, }} DEFINE_GUID!(D3DAUTHENTICATEDCONFIGURE_PROTECTION, 0x50455658, 0x3f47, 0x4362, 0xbf, 0x99, 0xbf, 0xdf, 0xcd, 0xe9, 0xed, 0x29); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION { Parameters: D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, Protections: D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS, }} DEFINE_GUID!(D3DAUTHENTICATEDCONFIGURE_CRYPTOSESSION, 0x6346cc54, 0x2cfc, 0x4ad4, 0x82, 0x24, 0xd1, 0x58, 0x37, 0xde, 0x77, 0x0); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION { Parameters: D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, DXVA2DecodeHandle: ::HANDLE, CryptoSessionHandle: ::HANDLE, DeviceHandle: ::HANDLE, }} DEFINE_GUID!(D3DAUTHENTICATEDCONFIGURE_SHAREDRESOURCE, 0x772d047, 0x1b40, 0x48e8, 0x9c, 0xa6, 0xb5, 0xf5, 0x10, 0xde, 0x9f, 0x1); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE { Parameters: D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, ProcessIdentiferType: D3DAUTHENTICATEDCHANNEL_PROCESSIDENTIFIERTYPE, ProcessHandle: ::HANDLE, AllowAccess: ::BOOL, }} DEFINE_GUID!(D3DAUTHENTICATEDCONFIGURE_ENCRYPTIONWHENACCESSIBLE, 0x41fff286, 0x6ae0, 0x4d43, 0x9d, 0x55, 0xa4, 0x6e, 0x9e, 0xfd, 0x15, 0x8a); STRUCT!{struct D3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION { Parameters: D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT, EncryptionGuid: ::GUID, }} STRUCT!{struct D3DENCRYPTED_BLOCK_INFO { NumEncryptedBytesAtBeginning: ::UINT, NumBytesInSkipPattern: ::UINT, NumBytesInEncryptPattern: ::UINT, }} STRUCT!{struct D3DAES_CTR_IV { IV: ::UINT64, Count: ::UINT64, }} deps/winapi-0.2.5/src/winbase.rs0000644000000000000000000005103312615667647015251 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! This module defines the 32-Bit Windows Base APIs pub const FILE_BEGIN: ::DWORD = 0; pub const FILE_CURRENT: ::DWORD = 1; pub const FILE_END: ::DWORD = 2; pub const WAIT_FAILED: ::DWORD = 0xFFFFFFFF; pub const WAIT_OBJECT_0: ::DWORD = ::STATUS_WAIT_0 as ::DWORD; pub const WAIT_ABANDONED: ::DWORD = ::STATUS_ABANDONED_WAIT_0 as ::DWORD; pub const WAIT_ABANDONED_0: ::DWORD = ::STATUS_ABANDONED_WAIT_0 as ::DWORD; pub const WAIT_IO_COMPLETION: ::DWORD = ::STATUS_USER_APC as ::DWORD; pub const FILE_FLAG_WRITE_THROUGH: ::DWORD = 0x80000000; pub const FILE_FLAG_OVERLAPPED: ::DWORD = 0x40000000; pub const FILE_FLAG_NO_BUFFERING: ::DWORD = 0x20000000; pub const FILE_FLAG_RANDOM_ACCESS: ::DWORD = 0x10000000; pub const FILE_FLAG_SEQUENTIAL_SCAN: ::DWORD = 0x08000000; pub const FILE_FLAG_DELETE_ON_CLOSE: ::DWORD = 0x04000000; pub const FILE_FLAG_BACKUP_SEMANTICS: ::DWORD = 0x02000000; pub const FILE_FLAG_POSIX_SEMANTICS: ::DWORD = 0x01000000; pub const FILE_FLAG_SESSION_AWARE: ::DWORD = 0x00800000; pub const FILE_FLAG_OPEN_REPARSE_POINT: ::DWORD = 0x00200000; pub const FILE_FLAG_OPEN_NO_RECALL: ::DWORD = 0x00100000; pub const FILE_FLAG_FIRST_PIPE_INSTANCE: ::DWORD = 0x00080000; pub const FILE_FLAG_OPEN_REQUIRING_OPLOCK: ::DWORD = 0x00040000; pub const PROGRESS_CONTINUE: ::DWORD = 0; pub const PROGRESS_CANCEL: ::DWORD = 1; pub const PROGRESS_STOP: ::DWORD = 2; pub const PROGRESS_QUIET: ::DWORD = 3; pub const CALLBACK_CHUNK_FINISHED: ::DWORD = 0x00000000; pub const CALLBACK_STREAM_SWITCH: ::DWORD = 0x00000001; pub const COPY_FILE_FAIL_IF_EXISTS: ::DWORD = 0x00000001; pub const COPY_FILE_RESTARTABLE: ::DWORD = 0x00000002; pub const COPY_FILE_OPEN_SOURCE_FOR_WRITE: ::DWORD = 0x00000004; pub const COPY_FILE_ALLOW_DECRYPTED_DESTINATION: ::DWORD = 0x00000008; pub const COPY_FILE_COPY_SYMLINK: ::DWORD = 0x00000800; pub const COPY_FILE_NO_BUFFERING: ::DWORD = 0x00001000; pub const COPY_FILE_REQUEST_SECURITY_PRIVILEGES: ::DWORD = 0x00002000; pub const COPY_FILE_RESUME_FROM_PAUSE: ::DWORD = 0x00004000; pub const COPY_FILE_NO_OFFLOAD: ::DWORD = 0x00040000; pub const REPLACEFILE_WRITE_THROUGH: ::DWORD = 0x00000001; pub const REPLACEFILE_IGNORE_MERGE_ERRORS: ::DWORD = 0x00000002; pub const REPLACEFILE_IGNORE_ACL_ERRORS: ::DWORD = 0x00000004; pub const PIPE_ACCESS_INBOUND: ::DWORD = 0x00000001; pub const PIPE_ACCESS_OUTBOUND: ::DWORD = 0x00000002; pub const PIPE_ACCESS_DUPLEX: ::DWORD = 0x00000003; pub const PIPE_CLIENT_END: ::DWORD = 0x00000000; pub const PIPE_SERVER_END: ::DWORD = 0x00000001; pub const PIPE_WAIT: ::DWORD = 0x00000000; pub const PIPE_NOWAIT: ::DWORD = 0x00000001; pub const PIPE_READMODE_BYTE: ::DWORD = 0x00000000; pub const PIPE_READMODE_MESSAGE: ::DWORD = 0x00000002; pub const PIPE_TYPE_BYTE: ::DWORD = 0x00000000; pub const PIPE_TYPE_MESSAGE: ::DWORD = 0x00000004; pub const PIPE_ACCEPT_REMOTE_CLIENTS: ::DWORD = 0x00000000; pub const PIPE_REJECT_REMOTE_CLIENTS: ::DWORD = 0x00000008; pub const PIPE_UNLIMITED_INSTANCES: ::DWORD = 255; //270 pub const SECURITY_CONTEXT_TRACKING: ::DWORD = 0x00040000; pub const SECURITY_EFFECTIVE_ONLY: ::DWORD = 0x00080000; pub const SECURITY_SQOS_PRESENT: ::DWORD = 0x00100000; pub const SECURITY_VALID_SQOS_FLAGS: ::DWORD = 0x001F0000; //282 pub type PFIBER_START_ROUTINE = Option; pub type LPFIBER_START_ROUTINE = PFIBER_START_ROUTINE; pub type PFIBER_CALLOUT_ROUTINE = Option ::LPVOID>; //299 pub type LPLDT_ENTRY = ::LPVOID; // TODO - fix this for 32-bit //405 STRUCT!{struct COMMPROP { wPacketLength: ::WORD, wPacketVersion: ::WORD, dwServiceMask: ::DWORD, dwReserved1: ::DWORD, dwMaxTxQueue: ::DWORD, dwMaxRxQueue: ::DWORD, dwMaxBaud: ::DWORD, dwProvSubType: ::DWORD, dwProvCapabilities: ::DWORD, dwSettableParams: ::DWORD, dwSettableBaud: ::DWORD, wSettableData: ::WORD, wSettableStopParity: ::WORD, dwCurrentTxQueue: ::DWORD, dwCurrentRxQueue: ::DWORD, dwProvSpec1: ::DWORD, dwProvSpec2: ::DWORD, wcProvChar: [::WCHAR; 1], }} pub type LPCOMMPROP = *mut COMMPROP; //432 STRUCT!{struct COMSTAT { BitFields: ::DWORD, cbInQue: ::DWORD, cbOutQue : ::DWORD, }} BITFIELD!(COMSTAT BitFields: ::DWORD [ fCtsHold set_fCtsHold[0..1], fDsrHold set_fDsrHold[1..2], fRlsdHold set_fRlsdHold[2..3], fXoffHold set_fXoffHold[3..4], fXoffSent set_fXoffSent[4..5], fEof set_fEof[5..6], fTxim set_fTxim[6..7], fReserved set_fReserved[7..32], ]); pub type LPCOMSTAT = *mut COMSTAT; //460 STRUCT!{struct DCB { DCBlength: ::DWORD, BaudRate: ::DWORD, BitFields: ::DWORD, wReserved: ::WORD, XonLim: ::WORD, XoffLim: ::WORD, ByteSize: ::BYTE, Parity: ::BYTE, StopBits: ::BYTE, XonChar: ::c_char, XoffChar: ::c_char, ErrorChar: ::c_char, EofChar: ::c_char, EvtChar: ::c_char, wReserved1: ::WORD, }} BITFIELD!(DCB BitFields: ::DWORD [ fBinary set_fBinary[0..1], fParity set_fParity[1..2], fOutxCtsFlow set_fOutxCtsFlow[2..3], fOutxDsrFlow set_fOutxDsrFlow[3..4], fDtrControl set_fDtrControl[4..6], fDsrSensitivity set_fDsrSensitivity[6..7], fTXContinueOnXoff set_fTXContinueOnXoff[7..8], fOutX set_fOutX[8..9], fInX set_fInX[9..10], fErrorChar set_fErrorChar[10..11], fNull set_fNull[11..12], fRtsControl set_fRtsControl[12..14], fAbortOnError set_fAbortOnError[14..15], fDummy2 set_fDummy2[15..32], ]); pub type LPDCB = *mut DCB; STRUCT!{struct COMMTIMEOUTS { ReadIntervalTimeout: ::DWORD, ReadTotalTimeoutMultiplier: ::DWORD, ReadTotalTimeoutConstant: ::DWORD, WriteTotalTimeoutMultiplier: ::DWORD, WriteTotalTimeoutConstant: ::DWORD, }} pub type LPCOMMTIMEOUTS = *mut COMMTIMEOUTS; STRUCT!{struct COMMCONFIG { dwSize: ::DWORD, wVersion: ::WORD, wReserved: ::WORD, dcb: DCB, dwProviderSubType: ::DWORD, dwProviderOffset: ::DWORD, dwProviderSize: ::DWORD, wcProviderData: [::WCHAR; 1], }} pub type LPCOMMCONFIG = *mut COMMCONFIG; //547 STRUCT!{struct MEMORYSTATUS { dwLength: ::DWORD, dwMemoryLoad: ::DWORD, dwTotalPhys: ::SIZE_T, dwAvailPhys: ::SIZE_T, dwTotalPageFile: ::SIZE_T, dwAvailPageFile: ::SIZE_T, dwTotalVirtual: ::SIZE_T, dwAvailVirtual: ::SIZE_T, }} pub type LPMEMORYSTATUS = *mut MEMORYSTATUS; //568 pub const DEBUG_PROCESS: ::DWORD = 0x00000001; pub const DEBUG_ONLY_THIS_PROCESS: ::DWORD = 0x00000002; pub const CREATE_SUSPENDED: ::DWORD = 0x00000004; pub const DETACHED_PROCESS: ::DWORD = 0x00000008; pub const CREATE_NEW_CONSOLE: ::DWORD = 0x00000010; pub const NORMAL_PRIORITY_CLASS: ::DWORD = 0x00000020; pub const IDLE_PRIORITY_CLASS: ::DWORD = 0x00000040; pub const HIGH_PRIORITY_CLASS: ::DWORD = 0x00000080; pub const REALTIME_PRIORITY_CLASS: ::DWORD = 0x00000100; pub const CREATE_NEW_PROCESS_GROUP: ::DWORD = 0x00000200; pub const CREATE_UNICODE_ENVIRONMENT: ::DWORD = 0x00000400; pub const CREATE_SEPARATE_WOW_VDM: ::DWORD = 0x00000800; pub const CREATE_SHARED_WOW_VDM: ::DWORD = 0x00001000; pub const CREATE_FORCEDOS: ::DWORD = 0x00002000; pub const BELOW_NORMAL_PRIORITY_CLASS: ::DWORD = 0x00004000; pub const ABOVE_NORMAL_PRIORITY_CLASS: ::DWORD = 0x00008000; pub const INHERIT_PARENT_AFFINITY: ::DWORD = 0x00010000; pub const INHERIT_CALLER_PRIORITY: ::DWORD = 0x00020000; pub const CREATE_PROTECTED_PROCESS: ::DWORD = 0x00040000; pub const EXTENDED_STARTUPINFO_PRESENT: ::DWORD = 0x00080000; pub const PROCESS_MODE_BACKGROUND_BEGIN: ::DWORD = 0x00100000; pub const PROCESS_MODE_BACKGROUND_END: ::DWORD = 0x00200000; pub const CREATE_BREAKAWAY_FROM_JOB: ::DWORD = 0x01000000; pub const CREATE_PRESERVE_CODE_AUTHZ_LEVEL: ::DWORD = 0x02000000; pub const CREATE_DEFAULT_ERROR_MODE: ::DWORD = 0x04000000; pub const CREATE_NO_WINDOW: ::DWORD = 0x08000000; pub const PROFILE_USER: ::DWORD = 0x10000000; pub const PROFILE_KERNEL: ::DWORD = 0x20000000; pub const PROFILE_SERVER: ::DWORD = 0x40000000; pub const CREATE_IGNORE_SYSTEM_DEFAULT: ::DWORD = 0x80000000; //618 pub const THREAD_PRIORITY_LOWEST: ::DWORD = ::THREAD_BASE_PRIORITY_MIN; pub const THREAD_PRIORITY_BELOW_NORMAL: ::DWORD = THREAD_PRIORITY_LOWEST + 1; pub const THREAD_PRIORITY_NORMAL: ::DWORD = 0; pub const THREAD_PRIORITY_HIGHEST: ::DWORD = ::THREAD_BASE_PRIORITY_MAX; pub const THREAD_PRIORITY_ABOVE_NORMAL: ::DWORD = THREAD_PRIORITY_HIGHEST - 1; pub const THREAD_PRIORITY_ERROR_RETURN: ::DWORD = ::MAXLONG as ::DWORD; pub const THREAD_PRIORITY_TIME_CRITICAL: ::DWORD = ::THREAD_BASE_PRIORITY_LOWRT; pub const THREAD_PRIORITY_IDLE: ::DWORD = ::THREAD_BASE_PRIORITY_IDLE; pub const THREAD_MODE_BACKGROUND_BEGIN: ::DWORD = 0x00010000; pub const THREAD_MODE_BACKGROUND_END: ::DWORD = 0x00020000; //666 pub const DRIVE_UNKNOWN: ::DWORD = 0; pub const DRIVE_NO_ROOT_DIR: ::DWORD = 1; pub const DRIVE_REMOVABLE: ::DWORD = 2; pub const DRIVE_FIXED: ::DWORD = 3; pub const DRIVE_REMOTE: ::DWORD = 4; pub const DRIVE_CDROM: ::DWORD = 5; pub const DRIVE_RAMDISK: ::DWORD = 6; pub const FILE_TYPE_UNKNOWN: ::DWORD = 0x0000; pub const FILE_TYPE_DISK: ::DWORD = 0x0001; pub const FILE_TYPE_CHAR: ::DWORD = 0x0002; pub const FILE_TYPE_PIPE: ::DWORD = 0x0003; pub const FILE_TYPE_REMOTE: ::DWORD = 0x8000; pub const STD_INPUT_HANDLE: ::DWORD = 0xFFFFFFF6; pub const STD_OUTPUT_HANDLE: ::DWORD = 0xFFFFFFF5; pub const STD_ERROR_HANDLE: ::DWORD = 0xFFFFFFF4; pub const NOPARITY: ::DWORD = 0; pub const ODDPARITY: ::DWORD = 1; pub const EVENPARITY: ::DWORD = 2; pub const MARKPARITY: ::DWORD = 3; pub const SPACEPARITY: ::DWORD = 4; pub const ONESTOPBIT: ::DWORD = 0; pub const ONE5STOPBITS: ::DWORD = 1; pub const TWOSTOPBITS: ::DWORD = 2; pub const IGNORE: ::DWORD = 0; pub const INFINITE: ::DWORD = 0xFFFFFFFF; //1729 pub const SEM_FAILCRITICALERRORS: ::UINT = 0x0001; pub const SEM_NOGPFAULTERRORBOX: ::UINT = 0x0002; pub const SEM_NOALIGNMENTFAULTEXCEPT: ::UINT = 0x0004; pub const SEM_NOOPENFILEERRORBOX: ::UINT = 0x8000; //2320 pub const FORMAT_MESSAGE_IGNORE_INSERTS: ::DWORD = 0x00000200; pub const FORMAT_MESSAGE_FROM_STRING: ::DWORD = 0x00000400; pub const FORMAT_MESSAGE_FROM_HMODULE: ::DWORD = 0x00000800; pub const FORMAT_MESSAGE_FROM_SYSTEM: ::DWORD = 0x00001000; pub const FORMAT_MESSAGE_ARGUMENT_ARRAY: ::DWORD = 0x00002000; pub const FORMAT_MESSAGE_MAX_WIDTH_MASK: ::DWORD = 0x000000FF; pub const FORMAT_MESSAGE_ALLOCATE_BUFFER: ::DWORD = 0x00000100; //2873 pub const STARTF_USESHOWWINDOW: ::DWORD = 0x00000001; pub const STARTF_USESIZE: ::DWORD = 0x00000002; pub const STARTF_USEPOSITION: ::DWORD = 0x00000004; pub const STARTF_USECOUNTCHARS: ::DWORD = 0x00000008; pub const STARTF_USEFILLATTRIBUTE: ::DWORD = 0x00000010; pub const STARTF_RUNFULLSCREEN: ::DWORD = 0x00000020; pub const STARTF_FORCEONFEEDBACK: ::DWORD = 0x00000040; pub const STARTF_FORCEOFFFEEDBACK: ::DWORD = 0x00000080; pub const STARTF_USESTDHANDLES: ::DWORD = 0x00000100; pub const STARTF_USEHOTKEY: ::DWORD = 0x00000200; pub const STARTF_TITLEISLINKNAME: ::DWORD = 0x00000800; pub const STARTF_TITLEISAPPID: ::DWORD = 0x00001000; pub const STARTF_PREVENTPINNING: ::DWORD = 0x00002000; pub const STARTF_UNTRUSTEDSOURCE: ::DWORD = 0x00008000; //5002 pub type LPPROGRESS_ROUTINE = Option ::DWORD>; //5095 ENUM!{enum COPYFILE2_MESSAGE_TYPE { COPYFILE2_CALLBACK_NONE = 0, COPYFILE2_CALLBACK_CHUNK_STARTED, COPYFILE2_CALLBACK_CHUNK_FINISHED, COPYFILE2_CALLBACK_STREAM_STARTED, COPYFILE2_CALLBACK_STREAM_FINISHED, COPYFILE2_CALLBACK_POLL_CONTINUE, COPYFILE2_CALLBACK_ERROR, COPYFILE2_CALLBACK_MAX, }} ENUM!{enum COPYFILE2_MESSAGE_ACTION { COPYFILE2_PROGRESS_CONTINUE = 0, COPYFILE2_PROGRESS_CANCEL, COPYFILE2_PROGRESS_STOP, COPYFILE2_PROGRESS_QUIET, COPYFILE2_PROGRESS_PAUSE, }} ENUM!{enum COPYFILE2_COPY_PHASE { COPYFILE2_PHASE_NONE = 0, COPYFILE2_PHASE_PREPARE_SOURCE, COPYFILE2_PHASE_PREPARE_DEST, COPYFILE2_PHASE_READ_SOURCE, COPYFILE2_PHASE_WRITE_DESTINATION, COPYFILE2_PHASE_SERVER_COPY, COPYFILE2_PHASE_NAMEGRAFT_COPY, COPYFILE2_PHASE_MAX, }} //5129 STRUCT!{struct COPYFILE2_MESSAGE_ChunkStarted { dwStreamNumber: ::DWORD, dwReserved: ::DWORD, hSourceFile: ::HANDLE, hDestinationFile: ::HANDLE, uliChunkNumber: ::ULARGE_INTEGER, uliChunkSize: ::ULARGE_INTEGER, uliStreamSize: ::ULARGE_INTEGER, uliTotalFileSize: ::ULARGE_INTEGER, }} STRUCT!{struct COPYFILE2_MESSAGE_ChunkFinished { dwStreamNumber: ::DWORD, dwFlags: ::DWORD, hSourceFile: ::HANDLE, hDestinationFile: ::HANDLE, uliChunkNumber: ::ULARGE_INTEGER, uliChunkSize: ::ULARGE_INTEGER, uliStreamSize: ::ULARGE_INTEGER, uliStreamBytesTransferred: ::ULARGE_INTEGER, uliTotalFileSize: ::ULARGE_INTEGER, uliTotalBytesTransferred: ::ULARGE_INTEGER, }} STRUCT!{struct COPYFILE2_MESSAGE_StreamStarted { dwStreamNumber: ::DWORD, dwReserved: ::DWORD, hSourceFile: ::HANDLE, hDestinationFile: ::HANDLE, uliStreamSize: ::ULARGE_INTEGER, uliTotalFileSize: ::ULARGE_INTEGER, }} STRUCT!{struct COPYFILE2_MESSAGE_StreamFinished { dwStreamNumber: ::DWORD, dwReserved: ::DWORD, hSourceFile: ::HANDLE, hDestinationFile: ::HANDLE, uliStreamSize: ::ULARGE_INTEGER, uliStreamBytesTransferred: ::ULARGE_INTEGER, uliTotalFileSize: ::ULARGE_INTEGER, uliTotalBytesTransferred: ::ULARGE_INTEGER, }} STRUCT!{struct COPYFILE2_MESSAGE_PollContinue { dwReserved: ::DWORD, }} STRUCT!{struct COPYFILE2_MESSAGE_Error { CopyPhase: COPYFILE2_COPY_PHASE, dwStreamNumber: ::DWORD, hrFailure: ::HRESULT, dwReserved: ::DWORD, uliChunkNumber: ::ULARGE_INTEGER, uliStreamSize: ::ULARGE_INTEGER, uliStreamBytesTransferred: ::ULARGE_INTEGER, uliTotalFileSize: ::ULARGE_INTEGER, uliTotalBytesTransferred: ::ULARGE_INTEGER, }} #[cfg(target_arch="x86")] STRUCT!{struct COPYFILE2_MESSAGE { Type: COPYFILE2_MESSAGE_TYPE, dwPadding: ::DWORD, Info: [u64; 8], }} #[cfg(target_arch="x86_64")] STRUCT!{struct COPYFILE2_MESSAGE { Type: COPYFILE2_MESSAGE_TYPE, dwPadding: ::DWORD, Info: [u64; 9], }} UNION!{COPYFILE2_MESSAGE, Info, ChunkStarted, ChunkStarted_mut, COPYFILE2_MESSAGE_ChunkStarted} UNION!{COPYFILE2_MESSAGE, Info, ChunkFinished, ChunkFinished_mut, COPYFILE2_MESSAGE_ChunkFinished} UNION!{COPYFILE2_MESSAGE, Info, StreamStarted, StreamStarted_mut, COPYFILE2_MESSAGE_StreamStarted} UNION!{COPYFILE2_MESSAGE, Info, StreamFinished, StreamFinished_mut, COPYFILE2_MESSAGE_StreamFinished} UNION!{COPYFILE2_MESSAGE, Info, PollContinue, PollContinue_mut, COPYFILE2_MESSAGE_PollContinue} UNION!{COPYFILE2_MESSAGE, Info, Error, Error_mut, COPYFILE2_MESSAGE_Error} pub type PCOPYFILE2_PROGRESS_ROUTINE = Option COPYFILE2_MESSAGE_ACTION>; STRUCT!{nodebug struct COPYFILE2_EXTENDED_PARAMETERS { dwSize: ::DWORD, dwCopyFlags: ::DWORD, pfCancel: *mut ::BOOL, pProgressRoutine: PCOPYFILE2_PROGRESS_ROUTINE, pvCallbackContext: ::PVOID, }} //5377 pub const MOVEFILE_REPLACE_EXISTING: ::DWORD = 0x00000001; pub const MOVEFILE_COPY_ALLOWED: ::DWORD = 0x00000002; pub const MOVEFILE_DELAY_UNTIL_REBOOT: ::DWORD = 0x00000004; pub const MOVEFILE_WRITE_THROUGH: ::DWORD = 0x00000008; pub const MOVEFILE_CREATE_HARDLINK: ::DWORD = 0x00000010; pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE: ::DWORD = 0x00000020; //7176 pub const HW_PROFILE_GUIDLEN: usize = 39; //pub const MAX_PROFILE_LEN: usize = 80; pub const DOCKINFO_UNDOCKED: ::DWORD = 0x1; pub const DOCKINFO_DOCKED: ::DWORD = 0x2; pub const DOCKINFO_USER_SUPPLIED: ::DWORD = 0x4; pub const DOCKINFO_USER_UNDOCKED: ::DWORD = DOCKINFO_USER_SUPPLIED | DOCKINFO_UNDOCKED; pub const DOCKINFO_USER_DOCKED: ::DWORD = DOCKINFO_USER_SUPPLIED | DOCKINFO_DOCKED; STRUCT!{nodebug struct HW_PROFILE_INFOA { dwDockInfo: ::DWORD, szHwProfileGuid: [::CHAR; HW_PROFILE_GUIDLEN], szHwProfileName: [::CHAR; ::MAX_PROFILE_LEN], }} pub type LPHW_PROFILE_INFOA = *mut HW_PROFILE_INFOA; STRUCT!{nodebug struct HW_PROFILE_INFOW { dwDockInfo: ::DWORD, szHwProfileGuid: [::WCHAR; HW_PROFILE_GUIDLEN], szHwProfileName: [::WCHAR; ::MAX_PROFILE_LEN], }} pub type LPHW_PROFILE_INFOW = *mut HW_PROFILE_INFOW; //7574 STRUCT!{struct ACTCTXA { cbSize: ::ULONG, dwFlags: ::DWORD, lpSource: ::LPCSTR, wProcessorArchitecture: ::USHORT, wLangId: ::LANGID, lpAssemblyDirectory: ::LPCSTR, lpResourceName: ::LPCSTR, lpApplicationName: ::LPCSTR, hModule: ::HMODULE, }} pub type PACTCTXA = *mut ACTCTXA; STRUCT!{struct ACTCTXW { cbSize: ::ULONG, dwFlags: ::DWORD, lpSource: ::LPCWSTR, wProcessorArchitecture: ::USHORT, wLangId: ::LANGID, lpAssemblyDirectory: ::LPCWSTR, lpResourceName: ::LPCWSTR, lpApplicationName: ::LPCWSTR, hModule: ::HMODULE, }} pub type PACTCTXW = *mut ACTCTXW; pub type PCACTCTXA = *const ACTCTXA; pub type PCACTCTXW = *const ACTCTXW; // pub type PUMS_CONTEXT = *mut ::c_void; pub type PUMS_COMPLETION_LIST = *mut ::c_void; pub type UMS_THREAD_INFO_CLASS = ::RTL_UMS_THREAD_INFO_CLASS; pub type PUMS_THREAD_INFO_CLASS = *mut UMS_THREAD_INFO_CLASS; pub type PUMS_SCHEDULER_ENTRY_POINT = ::PRTL_UMS_SCHEDULER_ENTRY_POINT; STRUCT!{nodebug struct UMS_SCHEDULER_STARTUP_INFO { UmsVersion: ::ULONG, CompletionList: PUMS_COMPLETION_LIST, SchedulerProc: PUMS_SCHEDULER_ENTRY_POINT, SchedulerParam: ::PVOID, }} pub type PUMS_SCHEDULER_STARTUP_INFO = *mut UMS_SCHEDULER_STARTUP_INFO; STRUCT!{struct UMS_SYSTEM_THREAD_INFORMATION { UmsVersion: ::ULONG, BitFields: ::ULONG, }} BITFIELD!(UMS_SYSTEM_THREAD_INFORMATION BitFields: ::ULONG [ IsUmsSchedulerThread set_IsUmsSchedulerThread[0..1], IsUmsWorkerThread set_IsUmsWorkerThread[1..2], ]); UNION!( UMS_SYSTEM_THREAD_INFORMATION, BitFields, ThreadUmsFlags, ThreadUmsFlags_mut, ::ULONG ); pub type PUMS_SYSTEM_THREAD_INFORMATION = *mut UMS_SYSTEM_THREAD_INFORMATION; STRUCT!{struct ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA { lpInformation: ::PVOID, lpSectionBase: ::PVOID, ulSectionLength: ::ULONG, lpSectionGlobalDataBase: ::PVOID, ulSectionGlobalDataLength: ::ULONG, }} pub type PACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA = *mut ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA; pub type PCACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA = *const ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA; STRUCT!{struct ACTCTX_SECTION_KEYED_DATA { cbSize: ::ULONG, ulDataFormatVersion: ::ULONG, lpData: ::PVOID, ulLength: ::ULONG, lpSectionGlobalData: ::PVOID, ulSectionGlobalDataLength: ::ULONG, lpSectionBase: ::PVOID, ulSectionTotalLength: ::ULONG, hActCtx: ::HANDLE, ulAssemblyRosterIndex: ::ULONG, ulFlags: ::ULONG, AssemblyMetadata: ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA, }} pub type PACTCTX_SECTION_KEYED_DATA = *mut ACTCTX_SECTION_KEYED_DATA; pub type PCACTCTX_SECTION_KEYED_DATA = *const ACTCTX_SECTION_KEYED_DATA; ENUM!{enum STREAM_INFO_LEVELS { FindStreamInfoStandard, FindStreamInfoMaxInfoLevel, }} ENUM!{enum PROCESS_INFORMATION_CLASS { ProcessMemoryPriority, ProcessInformationClassMax, }} ENUM!{enum DEP_SYSTEM_POLICY_TYPE { DEPPolicyAlwaysOff = 0, DEPPolicyAlwaysOn, DEPPolicyOptIn, DEPPolicyOptOut, DEPTotalPolicyCount, }} ENUM!{enum PIPE_ATTRIBUTE_TYPE { PipeAttribute, PipeConnectionAttribute, PipeHandleAttribute, }} pub type APPLICATION_RECOVERY_CALLBACK = Option ::DWORD>; STRUCT!{struct SYSTEM_POWER_STATUS { ACLineStatus: ::BYTE, BatteryFlag: ::BYTE, BatteryLifePercent: ::BYTE, Reserved1: ::BYTE, BatteryLifeTime: ::DWORD, BatteryFullLifeTime: ::DWORD, }} pub type LPSYSTEM_POWER_STATUS = *mut SYSTEM_POWER_STATUS; pub const OFS_MAXPATHNAME: usize = 128; STRUCT!{nodebug struct OFSTRUCT { cBytes: ::BYTE, fFixedDisk: ::BYTE, nErrCode: ::WORD, Reserved1: ::WORD, Reserved2: ::WORD, szPathName: [::CHAR; OFS_MAXPATHNAME], }} pub type POFSTRUCT = *mut OFSTRUCT; pub type LPOFSTRUCT = *mut OFSTRUCT; ENUM!{enum FILE_ID_TYPE { FileIdType, ObjectIdType, ExtendedFileIdType, MaximumFileIdType, }} STRUCT!{struct FILE_ID_DESCRIPTOR { dwSize: ::DWORD, Type: FILE_ID_TYPE, ObjectId: ::GUID, }} UNION!(FILE_ID_DESCRIPTOR, ObjectId, FileId, FileId_mut, ::LARGE_INTEGER); UNION!(FILE_ID_DESCRIPTOR, ObjectId, ExtendedFileId, ExtendedFileId_mut, ::FILE_ID_128); pub type LPFILE_ID_DESCRIPTOR = *mut FILE_ID_DESCRIPTOR; deps/winapi-0.2.5/src/winerror.rs0000644000000000000000000137131612605021352015452 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! error code definitions for the Win32 API functions #[inline] pub fn SUCCEEDED(hr: HRESULT) -> bool { hr >= 0 } pub const FACILITY_XPS: HRESULT = 82; pub const FACILITY_XAML: HRESULT = 43; pub const FACILITY_USN: HRESULT = 129; pub const FACILITY_BLBUI: HRESULT = 128; pub const FACILITY_SPP: HRESULT = 256; pub const FACILITY_WSB_ONLINE: HRESULT = 133; pub const FACILITY_DLS: HRESULT = 153; pub const FACILITY_BLB_CLI: HRESULT = 121; pub const FACILITY_BLB: HRESULT = 120; pub const FACILITY_WSBAPP: HRESULT = 122; pub const FACILITY_WPN: HRESULT = 62; pub const FACILITY_WMAAECMA: HRESULT = 1996; pub const FACILITY_WINRM: HRESULT = 51; pub const FACILITY_WINPE: HRESULT = 61; pub const FACILITY_WINDOWSUPDATE: HRESULT = 36; pub const FACILITY_WINDOWS_STORE: HRESULT = 63; pub const FACILITY_WINDOWS_SETUP: HRESULT = 48; pub const FACILITY_WINDOWS_DEFENDER: HRESULT = 80; pub const FACILITY_WINDOWS_CE: HRESULT = 24; pub const FACILITY_WINDOWS: HRESULT = 8; pub const FACILITY_WINCODEC_DWRITE_DWM: HRESULT = 2200; pub const FACILITY_WIA: HRESULT = 33; pub const FACILITY_WER: HRESULT = 27; pub const FACILITY_WEP: HRESULT = 2049; pub const FACILITY_WEB_SOCKET: HRESULT = 886; pub const FACILITY_WEB: HRESULT = 885; pub const FACILITY_USERMODE_VOLSNAP: HRESULT = 130; pub const FACILITY_USERMODE_VOLMGR: HRESULT = 56; pub const FACILITY_VISUALCPP: HRESULT = 109; pub const FACILITY_USERMODE_VIRTUALIZATION: HRESULT = 55; pub const FACILITY_USERMODE_VHD: HRESULT = 58; pub const FACILITY_URT: HRESULT = 19; pub const FACILITY_UMI: HRESULT = 22; pub const FACILITY_UI: HRESULT = 42; pub const FACILITY_TPM_SOFTWARE: HRESULT = 41; pub const FACILITY_TPM_SERVICES: HRESULT = 40; pub const FACILITY_TIERING: HRESULT = 131; pub const FACILITY_SYNCENGINE: HRESULT = 2050; pub const FACILITY_SXS: HRESULT = 23; pub const FACILITY_STORAGE: HRESULT = 3; pub const FACILITY_STATE_MANAGEMENT: HRESULT = 34; pub const FACILITY_SSPI: HRESULT = 9; pub const FACILITY_USERMODE_SPACES: HRESULT = 231; pub const FACILITY_SOS: HRESULT = 160; pub const FACILITY_SCARD: HRESULT = 16; pub const FACILITY_SHELL: HRESULT = 39; pub const FACILITY_SETUPAPI: HRESULT = 15; pub const FACILITY_SECURITY: HRESULT = 9; pub const FACILITY_SDIAG: HRESULT = 60; pub const FACILITY_USERMODE_SDBUS: HRESULT = 2305; pub const FACILITY_RPC: HRESULT = 1; pub const FACILITY_RESTORE: HRESULT = 256; pub const FACILITY_SCRIPT: HRESULT = 112; pub const FACILITY_PARSE: HRESULT = 113; pub const FACILITY_RAS: HRESULT = 83; pub const FACILITY_POWERSHELL: HRESULT = 84; pub const FACILITY_PLA: HRESULT = 48; pub const FACILITY_PIDGENX: HRESULT = 2561; pub const FACILITY_P2P_INT: HRESULT = 98; pub const FACILITY_P2P: HRESULT = 99; pub const FACILITY_OPC: HRESULT = 81; pub const FACILITY_ONLINE_ID: HRESULT = 134; pub const FACILITY_WIN32: HRESULT = 7; pub const FACILITY_CONTROL: HRESULT = 10; pub const FACILITY_WEBSERVICES: HRESULT = 61; pub const FACILITY_NULL: HRESULT = 0; pub const FACILITY_NDIS: HRESULT = 52; pub const FACILITY_NAP: HRESULT = 39; pub const FACILITY_MOBILE: HRESULT = 1793; pub const FACILITY_METADIRECTORY: HRESULT = 35; pub const FACILITY_MSMQ: HRESULT = 14; pub const FACILITY_MEDIASERVER: HRESULT = 13; pub const FACILITY_MBN: HRESULT = 84; pub const FACILITY_LINGUISTIC_SERVICES: HRESULT = 305; pub const FACILITY_LEAP: HRESULT = 2184; pub const FACILITY_JSCRIPT: HRESULT = 2306; pub const FACILITY_INTERNET: HRESULT = 12; pub const FACILITY_ITF: HRESULT = 4; pub const FACILITY_INPUT: HRESULT = 64; pub const FACILITY_USERMODE_HYPERVISOR: HRESULT = 53; pub const FACILITY_ACCELERATOR: HRESULT = 1536; pub const FACILITY_HTTP: HRESULT = 25; pub const FACILITY_GRAPHICS: HRESULT = 38; pub const FACILITY_FWP: HRESULT = 50; pub const FACILITY_FVE: HRESULT = 49; pub const FACILITY_USERMODE_FILTER_MANAGER: HRESULT = 31; pub const FACILITY_EAS: HRESULT = 85; pub const FACILITY_EAP: HRESULT = 66; pub const FACILITY_DXGI_DDI: HRESULT = 2171; pub const FACILITY_DXGI: HRESULT = 2170; pub const FACILITY_DPLAY: HRESULT = 21; pub const FACILITY_DMSERVER: HRESULT = 256; pub const FACILITY_DISPATCH: HRESULT = 2; pub const FACILITY_DIRECTORYSERVICE: HRESULT = 37; pub const FACILITY_DIRECTMUSIC: HRESULT = 2168; pub const FACILITY_DIRECT3D11: HRESULT = 2172; pub const FACILITY_DIRECT3D10: HRESULT = 2169; pub const FACILITY_DIRECT2D: HRESULT = 2201; pub const FACILITY_DAF: HRESULT = 100; pub const FACILITY_DEPLOYMENT_SERVICES_UTIL: HRESULT = 260; pub const FACILITY_DEPLOYMENT_SERVICES_TRANSPORT_MANAGEMENT: HRESULT = 272; pub const FACILITY_DEPLOYMENT_SERVICES_TFTP: HRESULT = 264; pub const FACILITY_DEPLOYMENT_SERVICES_PXE: HRESULT = 263; pub const FACILITY_DEPLOYMENT_SERVICES_MULTICAST_SERVER: HRESULT = 289; pub const FACILITY_DEPLOYMENT_SERVICES_MULTICAST_CLIENT: HRESULT = 290; pub const FACILITY_DEPLOYMENT_SERVICES_MANAGEMENT: HRESULT = 259; pub const FACILITY_DEPLOYMENT_SERVICES_IMAGING: HRESULT = 258; pub const FACILITY_DEPLOYMENT_SERVICES_DRIVER_PROVISIONING: HRESULT = 278; pub const FACILITY_DEPLOYMENT_SERVICES_SERVER: HRESULT = 257; pub const FACILITY_DEPLOYMENT_SERVICES_CONTENT_PROVIDER: HRESULT = 293; pub const FACILITY_DEPLOYMENT_SERVICES_BINLSVC: HRESULT = 261; pub const FACILITY_DEFRAG: HRESULT = 2304; pub const FACILITY_DEBUGGERS: HRESULT = 176; pub const FACILITY_CONFIGURATION: HRESULT = 33; pub const FACILITY_COMPLUS: HRESULT = 17; pub const FACILITY_USERMODE_COMMONLOG: HRESULT = 26; pub const FACILITY_CMI: HRESULT = 54; pub const FACILITY_CERT: HRESULT = 11; pub const FACILITY_BLUETOOTH_ATT: HRESULT = 101; pub const FACILITY_BCD: HRESULT = 57; pub const FACILITY_BACKGROUNDCOPY: HRESULT = 32; pub const FACILITY_AUDIOSTREAMING: HRESULT = 1094; pub const FACILITY_AUDCLNT: HRESULT = 2185; pub const FACILITY_AUDIO: HRESULT = 102; pub const FACILITY_ACTION_QUEUE: HRESULT = 44; pub const FACILITY_ACS: HRESULT = 20; pub const FACILITY_AAF: HRESULT = 18; pub const ERROR_SUCCESS: ::DWORD = 0; pub const NO_ERROR: ::DWORD = 0; pub const SEC_E_OK: HRESULT = 0; pub const ERROR_INVALID_FUNCTION: ::DWORD = 1; pub const ERROR_FILE_NOT_FOUND: ::DWORD = 2; pub const ERROR_PATH_NOT_FOUND: ::DWORD = 3; pub const ERROR_TOO_MANY_OPEN_FILES: ::DWORD = 4; pub const ERROR_ACCESS_DENIED: ::DWORD = 5; pub const ERROR_INVALID_HANDLE: ::DWORD = 6; pub const ERROR_ARENA_TRASHED: ::DWORD = 7; pub const ERROR_NOT_ENOUGH_MEMORY: ::DWORD = 8; pub const ERROR_INVALID_BLOCK: ::DWORD = 9; pub const ERROR_BAD_ENVIRONMENT: ::DWORD = 10; pub const ERROR_BAD_FORMAT: ::DWORD = 11; pub const ERROR_INVALID_ACCESS: ::DWORD = 12; pub const ERROR_INVALID_DATA: ::DWORD = 13; pub const ERROR_OUTOFMEMORY: ::DWORD = 14; pub const ERROR_INVALID_DRIVE: ::DWORD = 15; pub const ERROR_CURRENT_DIRECTORY: ::DWORD = 16; pub const ERROR_NOT_SAME_DEVICE: ::DWORD = 17; pub const ERROR_NO_MORE_FILES: ::DWORD = 18; pub const ERROR_WRITE_PROTECT: ::DWORD = 19; pub const ERROR_BAD_UNIT: ::DWORD = 20; pub const ERROR_NOT_READY: ::DWORD = 21; pub const ERROR_BAD_COMMAND: ::DWORD = 22; pub const ERROR_CRC: ::DWORD = 23; pub const ERROR_BAD_LENGTH: ::DWORD = 24; pub const ERROR_SEEK: ::DWORD = 25; pub const ERROR_NOT_DOS_DISK: ::DWORD = 26; pub const ERROR_SECTOR_NOT_FOUND: ::DWORD = 27; pub const ERROR_OUT_OF_PAPER: ::DWORD = 28; pub const ERROR_WRITE_FAULT: ::DWORD = 29; pub const ERROR_READ_FAULT: ::DWORD = 30; pub const ERROR_GEN_FAILURE: ::DWORD = 31; pub const ERROR_SHARING_VIOLATION: ::DWORD = 32; pub const ERROR_LOCK_VIOLATION: ::DWORD = 33; pub const ERROR_WRONG_DISK: ::DWORD = 34; pub const ERROR_SHARING_BUFFER_EXCEEDED: ::DWORD = 36; pub const ERROR_HANDLE_EOF: ::DWORD = 38; pub const ERROR_HANDLE_DISK_FULL: ::DWORD = 39; pub const ERROR_NOT_SUPPORTED: ::DWORD = 50; pub const ERROR_REM_NOT_LIST: ::DWORD = 51; pub const ERROR_DUP_NAME: ::DWORD = 52; pub const ERROR_BAD_NETPATH: ::DWORD = 53; pub const ERROR_NETWORK_BUSY: ::DWORD = 54; pub const ERROR_DEV_NOT_EXIST: ::DWORD = 55; pub const ERROR_TOO_MANY_CMDS: ::DWORD = 56; pub const ERROR_ADAP_HDW_ERR: ::DWORD = 57; pub const ERROR_BAD_NET_RESP: ::DWORD = 58; pub const ERROR_UNEXP_NET_ERR: ::DWORD = 59; pub const ERROR_BAD_REM_ADAP: ::DWORD = 60; pub const ERROR_PRINTQ_FULL: ::DWORD = 61; pub const ERROR_NO_SPOOL_SPACE: ::DWORD = 62; pub const ERROR_PRINT_CANCELLED: ::DWORD = 63; pub const ERROR_NETNAME_DELETED: ::DWORD = 64; pub const ERROR_NETWORK_ACCESS_DENIED: ::DWORD = 65; pub const ERROR_BAD_DEV_TYPE: ::DWORD = 66; pub const ERROR_BAD_NET_NAME: ::DWORD = 67; pub const ERROR_TOO_MANY_NAMES: ::DWORD = 68; pub const ERROR_TOO_MANY_SESS: ::DWORD = 69; pub const ERROR_SHARING_PAUSED: ::DWORD = 70; pub const ERROR_REQ_NOT_ACCEP: ::DWORD = 71; pub const ERROR_REDIR_PAUSED: ::DWORD = 72; pub const ERROR_FILE_EXISTS: ::DWORD = 80; pub const ERROR_CANNOT_MAKE: ::DWORD = 82; pub const ERROR_FAIL_I24: ::DWORD = 83; pub const ERROR_OUT_OF_STRUCTURES: ::DWORD = 84; pub const ERROR_ALREADY_ASSIGNED: ::DWORD = 85; pub const ERROR_INVALID_PASSWORD: ::DWORD = 86; pub const ERROR_INVALID_PARAMETER: ::DWORD = 87; pub const ERROR_NET_WRITE_FAULT: ::DWORD = 88; pub const ERROR_NO_PROC_SLOTS: ::DWORD = 89; pub const ERROR_TOO_MANY_SEMAPHORES: ::DWORD = 100; pub const ERROR_EXCL_SEM_ALREADY_OWNED: ::DWORD = 101; pub const ERROR_SEM_IS_SET: ::DWORD = 102; pub const ERROR_TOO_MANY_SEM_REQUESTS: ::DWORD = 103; pub const ERROR_INVALID_AT_INTERRUPT_TIME: ::DWORD = 104; pub const ERROR_SEM_OWNER_DIED: ::DWORD = 105; pub const ERROR_SEM_USER_LIMIT: ::DWORD = 106; pub const ERROR_DISK_CHANGE: ::DWORD = 107; pub const ERROR_DRIVE_LOCKED: ::DWORD = 108; pub const ERROR_BROKEN_PIPE: ::DWORD = 109; pub const ERROR_OPEN_FAILED: ::DWORD = 110; pub const ERROR_BUFFER_OVERFLOW: ::DWORD = 111; pub const ERROR_DISK_FULL: ::DWORD = 112; pub const ERROR_NO_MORE_SEARCH_HANDLES: ::DWORD = 113; pub const ERROR_INVALID_TARGET_HANDLE: ::DWORD = 114; pub const ERROR_INVALID_CATEGORY: ::DWORD = 117; pub const ERROR_INVALID_VERIFY_SWITCH: ::DWORD = 118; pub const ERROR_BAD_DRIVER_LEVEL: ::DWORD = 119; pub const ERROR_CALL_NOT_IMPLEMENTED: ::DWORD = 120; pub const ERROR_SEM_TIMEOUT: ::DWORD = 121; pub const ERROR_INSUFFICIENT_BUFFER: ::DWORD = 122; pub const ERROR_INVALID_NAME: ::DWORD = 123; pub const ERROR_INVALID_LEVEL: ::DWORD = 124; pub const ERROR_NO_VOLUME_LABEL: ::DWORD = 125; pub const ERROR_MOD_NOT_FOUND: ::DWORD = 126; pub const ERROR_PROC_NOT_FOUND: ::DWORD = 127; pub const ERROR_WAIT_NO_CHILDREN: ::DWORD = 128; pub const ERROR_CHILD_NOT_COMPLETE: ::DWORD = 129; pub const ERROR_DIRECT_ACCESS_HANDLE: ::DWORD = 130; pub const ERROR_NEGATIVE_SEEK: ::DWORD = 131; pub const ERROR_SEEK_ON_DEVICE: ::DWORD = 132; pub const ERROR_IS_JOIN_TARGET: ::DWORD = 133; pub const ERROR_IS_JOINED: ::DWORD = 134; pub const ERROR_IS_SUBSTED: ::DWORD = 135; pub const ERROR_NOT_JOINED: ::DWORD = 136; pub const ERROR_NOT_SUBSTED: ::DWORD = 137; pub const ERROR_JOIN_TO_JOIN: ::DWORD = 138; pub const ERROR_SUBST_TO_SUBST: ::DWORD = 139; pub const ERROR_JOIN_TO_SUBST: ::DWORD = 140; pub const ERROR_SUBST_TO_JOIN: ::DWORD = 141; pub const ERROR_BUSY_DRIVE: ::DWORD = 142; pub const ERROR_SAME_DRIVE: ::DWORD = 143; pub const ERROR_DIR_NOT_ROOT: ::DWORD = 144; pub const ERROR_DIR_NOT_EMPTY: ::DWORD = 145; pub const ERROR_IS_SUBST_PATH: ::DWORD = 146; pub const ERROR_IS_JOIN_PATH: ::DWORD = 147; pub const ERROR_PATH_BUSY: ::DWORD = 148; pub const ERROR_IS_SUBST_TARGET: ::DWORD = 149; pub const ERROR_SYSTEM_TRACE: ::DWORD = 150; pub const ERROR_INVALID_EVENT_COUNT: ::DWORD = 151; pub const ERROR_TOO_MANY_MUXWAITERS: ::DWORD = 152; pub const ERROR_INVALID_LIST_FORMAT: ::DWORD = 153; pub const ERROR_LABEL_TOO_LONG: ::DWORD = 154; pub const ERROR_TOO_MANY_TCBS: ::DWORD = 155; pub const ERROR_SIGNAL_REFUSED: ::DWORD = 156; pub const ERROR_DISCARDED: ::DWORD = 157; pub const ERROR_NOT_LOCKED: ::DWORD = 158; pub const ERROR_BAD_THREADID_ADDR: ::DWORD = 159; pub const ERROR_BAD_ARGUMENTS: ::DWORD = 160; pub const ERROR_BAD_PATHNAME: ::DWORD = 161; pub const ERROR_SIGNAL_PENDING: ::DWORD = 162; pub const ERROR_MAX_THRDS_REACHED: ::DWORD = 164; pub const ERROR_LOCK_FAILED: ::DWORD = 167; pub const ERROR_BUSY: ::DWORD = 170; pub const ERROR_DEVICE_SUPPORT_IN_PROGRESS: ::DWORD = 171; pub const ERROR_CANCEL_VIOLATION: ::DWORD = 173; pub const ERROR_ATOMIC_LOCKS_NOT_SUPPORTED: ::DWORD = 174; pub const ERROR_INVALID_SEGMENT_NUMBER: ::DWORD = 180; pub const ERROR_INVALID_ORDINAL: ::DWORD = 182; pub const ERROR_ALREADY_EXISTS: ::DWORD = 183; pub const ERROR_INVALID_FLAG_NUMBER: ::DWORD = 186; pub const ERROR_SEM_NOT_FOUND: ::DWORD = 187; pub const ERROR_INVALID_STARTING_CODESEG: ::DWORD = 188; pub const ERROR_INVALID_STACKSEG: ::DWORD = 189; pub const ERROR_INVALID_MODULETYPE: ::DWORD = 190; pub const ERROR_INVALID_EXE_SIGNATURE: ::DWORD = 191; pub const ERROR_EXE_MARKED_INVALID: ::DWORD = 192; pub const ERROR_BAD_EXE_FORMAT: ::DWORD = 193; pub const ERROR_ITERATED_DATA_EXCEEDS_64k: ::DWORD = 194; pub const ERROR_INVALID_MINALLOCSIZE: ::DWORD = 195; pub const ERROR_DYNLINK_FROM_INVALID_RING: ::DWORD = 196; pub const ERROR_IOPL_NOT_ENABLED: ::DWORD = 197; pub const ERROR_INVALID_SEGDPL: ::DWORD = 198; pub const ERROR_AUTODATASEG_EXCEEDS_64k: ::DWORD = 199; pub const ERROR_RING2SEG_MUST_BE_MOVABLE: ::DWORD = 200; pub const ERROR_RELOC_CHAIN_XEEDS_SEGLIM: ::DWORD = 201; pub const ERROR_INFLOOP_IN_RELOC_CHAIN: ::DWORD = 202; pub const ERROR_ENVVAR_NOT_FOUND: ::DWORD = 203; pub const ERROR_NO_SIGNAL_SENT: ::DWORD = 205; pub const ERROR_FILENAME_EXCED_RANGE: ::DWORD = 206; pub const ERROR_RING2_STACK_IN_USE: ::DWORD = 207; pub const ERROR_META_EXPANSION_TOO_LONG: ::DWORD = 208; pub const ERROR_INVALID_SIGNAL_NUMBER: ::DWORD = 209; pub const ERROR_THREAD_1_INACTIVE: ::DWORD = 210; pub const ERROR_LOCKED: ::DWORD = 212; pub const ERROR_TOO_MANY_MODULES: ::DWORD = 214; pub const ERROR_NESTING_NOT_ALLOWED: ::DWORD = 215; pub const ERROR_EXE_MACHINE_TYPE_MISMATCH: ::DWORD = 216; pub const ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY: ::DWORD = 217; pub const ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY: ::DWORD = 218; pub const ERROR_FILE_CHECKED_OUT: ::DWORD = 220; pub const ERROR_CHECKOUT_REQUIRED: ::DWORD = 221; pub const ERROR_BAD_FILE_TYPE: ::DWORD = 222; pub const ERROR_FILE_TOO_LARGE: ::DWORD = 223; pub const ERROR_FORMS_AUTH_REQUIRED: ::DWORD = 224; pub const ERROR_VIRUS_INFECTED: ::DWORD = 225; pub const ERROR_VIRUS_DELETED: ::DWORD = 226; pub const ERROR_PIPE_LOCAL: ::DWORD = 229; pub const ERROR_BAD_PIPE: ::DWORD = 230; pub const ERROR_PIPE_BUSY: ::DWORD = 231; pub const ERROR_NO_DATA: ::DWORD = 232; pub const ERROR_PIPE_NOT_CONNECTED: ::DWORD = 233; pub const ERROR_MORE_DATA: ::DWORD = 234; pub const ERROR_VC_DISCONNECTED: ::DWORD = 240; pub const ERROR_INVALID_EA_NAME: ::DWORD = 254; pub const ERROR_EA_LIST_INCONSISTENT: ::DWORD = 255; pub const WAIT_TIMEOUT: ::DWORD = 258; pub const ERROR_NO_MORE_ITEMS: ::DWORD = 259; pub const ERROR_CANNOT_COPY: ::DWORD = 266; pub const ERROR_DIRECTORY: ::DWORD = 267; pub const ERROR_EAS_DIDNT_FIT: ::DWORD = 275; pub const ERROR_EA_FILE_CORRUPT: ::DWORD = 276; pub const ERROR_EA_TABLE_FULL: ::DWORD = 277; pub const ERROR_INVALID_EA_HANDLE: ::DWORD = 278; pub const ERROR_EAS_NOT_SUPPORTED: ::DWORD = 282; pub const ERROR_NOT_OWNER: ::DWORD = 288; pub const ERROR_TOO_MANY_POSTS: ::DWORD = 298; pub const ERROR_PARTIAL_COPY: ::DWORD = 299; pub const ERROR_OPLOCK_NOT_GRANTED: ::DWORD = 300; pub const ERROR_INVALID_OPLOCK_PROTOCOL: ::DWORD = 301; pub const ERROR_DISK_TOO_FRAGMENTED: ::DWORD = 302; pub const ERROR_DELETE_PENDING: ::DWORD = 303; pub const ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING: ::DWORD = 304; pub const ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME: ::DWORD = 305; pub const ERROR_SECURITY_STREAM_IS_INCONSISTENT: ::DWORD = 306; pub const ERROR_INVALID_LOCK_RANGE: ::DWORD = 307; pub const ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT: ::DWORD = 308; pub const ERROR_NOTIFICATION_GUID_ALREADY_DEFINED: ::DWORD = 309; pub const ERROR_INVALID_EXCEPTION_HANDLER: ::DWORD = 310; pub const ERROR_DUPLICATE_PRIVILEGES: ::DWORD = 311; pub const ERROR_NO_RANGES_PROCESSED: ::DWORD = 312; pub const ERROR_NOT_ALLOWED_ON_SYSTEM_FILE: ::DWORD = 313; pub const ERROR_DISK_RESOURCES_EXHAUSTED: ::DWORD = 314; pub const ERROR_INVALID_TOKEN: ::DWORD = 315; pub const ERROR_DEVICE_FEATURE_NOT_SUPPORTED: ::DWORD = 316; pub const ERROR_MR_MID_NOT_FOUND: ::DWORD = 317; pub const ERROR_SCOPE_NOT_FOUND: ::DWORD = 318; pub const ERROR_UNDEFINED_SCOPE: ::DWORD = 319; pub const ERROR_INVALID_CAP: ::DWORD = 320; pub const ERROR_DEVICE_UNREACHABLE: ::DWORD = 321; pub const ERROR_DEVICE_NO_RESOURCES: ::DWORD = 322; pub const ERROR_DATA_CHECKSUM_ERROR: ::DWORD = 323; pub const ERROR_INTERMIXED_KERNEL_EA_OPERATION: ::DWORD = 324; pub const ERROR_FILE_LEVEL_TRIM_NOT_SUPPORTED: ::DWORD = 326; pub const ERROR_OFFSET_ALIGNMENT_VIOLATION: ::DWORD = 327; pub const ERROR_INVALID_FIELD_IN_PARAMETER_LIST: ::DWORD = 328; pub const ERROR_OPERATION_IN_PROGRESS: ::DWORD = 329; pub const ERROR_BAD_DEVICE_PATH: ::DWORD = 330; pub const ERROR_TOO_MANY_DESCRIPTORS: ::DWORD = 331; pub const ERROR_SCRUB_DATA_DISABLED: ::DWORD = 332; pub const ERROR_NOT_REDUNDANT_STORAGE: ::DWORD = 333; pub const ERROR_RESIDENT_FILE_NOT_SUPPORTED: ::DWORD = 334; pub const ERROR_COMPRESSED_FILE_NOT_SUPPORTED: ::DWORD = 335; pub const ERROR_DIRECTORY_NOT_SUPPORTED: ::DWORD = 336; pub const ERROR_NOT_READ_FROM_COPY: ::DWORD = 337; pub const ERROR_FT_WRITE_FAILURE: ::DWORD = 338; pub const ERROR_FT_DI_SCAN_REQUIRED: ::DWORD = 339; pub const ERROR_INVALID_KERNEL_INFO_VERSION: ::DWORD = 340; pub const ERROR_INVALID_PEP_INFO_VERSION: ::DWORD = 341; pub const ERROR_OBJECT_NOT_EXTERNALLY_BACKED: ::DWORD = 342; pub const ERROR_EXTERNAL_BACKING_PROVIDER_UNKNOWN: ::DWORD = 343; pub const ERROR_FAIL_NOACTION_REBOOT: ::DWORD = 350; pub const ERROR_FAIL_SHUTDOWN: ::DWORD = 351; pub const ERROR_FAIL_RESTART: ::DWORD = 352; pub const ERROR_MAX_SESSIONS_REACHED: ::DWORD = 353; pub const ERROR_THREAD_MODE_ALREADY_BACKGROUND: ::DWORD = 400; pub const ERROR_THREAD_MODE_NOT_BACKGROUND: ::DWORD = 401; pub const ERROR_PROCESS_MODE_ALREADY_BACKGROUND: ::DWORD = 402; pub const ERROR_PROCESS_MODE_NOT_BACKGROUND: ::DWORD = 403; pub const ERROR_DEVICE_HARDWARE_ERROR: ::DWORD = 483; pub const ERROR_INVALID_ADDRESS: ::DWORD = 487; pub const ERROR_USER_PROFILE_LOAD: ::DWORD = 500; pub const ERROR_ARITHMETIC_OVERFLOW: ::DWORD = 534; pub const ERROR_PIPE_CONNECTED: ::DWORD = 535; pub const ERROR_PIPE_LISTENING: ::DWORD = 536; pub const ERROR_VERIFIER_STOP: ::DWORD = 537; pub const ERROR_ABIOS_ERROR: ::DWORD = 538; pub const ERROR_WX86_WARNING: ::DWORD = 539; pub const ERROR_WX86_ERROR: ::DWORD = 540; pub const ERROR_TIMER_NOT_CANCELED: ::DWORD = 541; pub const ERROR_UNWIND: ::DWORD = 542; pub const ERROR_BAD_STACK: ::DWORD = 543; pub const ERROR_INVALID_UNWIND_TARGET: ::DWORD = 544; pub const ERROR_INVALID_PORT_ATTRIBUTES: ::DWORD = 545; pub const ERROR_PORT_MESSAGE_TOO_LONG: ::DWORD = 546; pub const ERROR_INVALID_QUOTA_LOWER: ::DWORD = 547; pub const ERROR_DEVICE_ALREADY_ATTACHED: ::DWORD = 548; pub const ERROR_INSTRUCTION_MISALIGNMENT: ::DWORD = 549; pub const ERROR_PROFILING_NOT_STARTED: ::DWORD = 550; pub const ERROR_PROFILING_NOT_STOPPED: ::DWORD = 551; pub const ERROR_COULD_NOT_INTERPRET: ::DWORD = 552; pub const ERROR_PROFILING_AT_LIMIT: ::DWORD = 553; pub const ERROR_CANT_WAIT: ::DWORD = 554; pub const ERROR_CANT_TERMINATE_SELF: ::DWORD = 555; pub const ERROR_UNEXPECTED_MM_CREATE_ERR: ::DWORD = 556; pub const ERROR_UNEXPECTED_MM_MAP_ERROR: ::DWORD = 557; pub const ERROR_UNEXPECTED_MM_EXTEND_ERR: ::DWORD = 558; pub const ERROR_BAD_FUNCTION_TABLE: ::DWORD = 559; pub const ERROR_NO_GUID_TRANSLATION: ::DWORD = 560; pub const ERROR_INVALID_LDT_SIZE: ::DWORD = 561; pub const ERROR_INVALID_LDT_OFFSET: ::DWORD = 563; pub const ERROR_INVALID_LDT_DESCRIPTOR: ::DWORD = 564; pub const ERROR_TOO_MANY_THREADS: ::DWORD = 565; pub const ERROR_THREAD_NOT_IN_PROCESS: ::DWORD = 566; pub const ERROR_PAGEFILE_QUOTA_EXCEEDED: ::DWORD = 567; pub const ERROR_LOGON_SERVER_CONFLICT: ::DWORD = 568; pub const ERROR_SYNCHRONIZATION_REQUIRED: ::DWORD = 569; pub const ERROR_NET_OPEN_FAILED: ::DWORD = 570; pub const ERROR_IO_PRIVILEGE_FAILED: ::DWORD = 571; pub const ERROR_CONTROL_C_EXIT: ::DWORD = 572; pub const ERROR_MISSING_SYSTEMFILE: ::DWORD = 573; pub const ERROR_UNHANDLED_EXCEPTION: ::DWORD = 574; pub const ERROR_APP_INIT_FAILURE: ::DWORD = 575; pub const ERROR_PAGEFILE_CREATE_FAILED: ::DWORD = 576; pub const ERROR_INVALID_IMAGE_HASH: ::DWORD = 577; pub const ERROR_NO_PAGEFILE: ::DWORD = 578; pub const ERROR_ILLEGAL_FLOAT_CONTEXT: ::DWORD = 579; pub const ERROR_NO_EVENT_PAIR: ::DWORD = 580; pub const ERROR_DOMAIN_CTRLR_CONFIG_ERROR: ::DWORD = 581; pub const ERROR_ILLEGAL_CHARACTER: ::DWORD = 582; pub const ERROR_UNDEFINED_CHARACTER: ::DWORD = 583; pub const ERROR_FLOPPY_VOLUME: ::DWORD = 584; pub const ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT: ::DWORD = 585; pub const ERROR_BACKUP_CONTROLLER: ::DWORD = 586; pub const ERROR_MUTANT_LIMIT_EXCEEDED: ::DWORD = 587; pub const ERROR_FS_DRIVER_REQUIRED: ::DWORD = 588; pub const ERROR_CANNOT_LOAD_REGISTRY_FILE: ::DWORD = 589; pub const ERROR_DEBUG_ATTACH_FAILED: ::DWORD = 590; pub const ERROR_SYSTEM_PROCESS_TERMINATED: ::DWORD = 591; pub const ERROR_DATA_NOT_ACCEPTED: ::DWORD = 592; pub const ERROR_VDM_HARD_ERROR: ::DWORD = 593; pub const ERROR_DRIVER_CANCEL_TIMEOUT: ::DWORD = 594; pub const ERROR_REPLY_MESSAGE_MISMATCH: ::DWORD = 595; pub const ERROR_LOST_WRITEBEHIND_DATA: ::DWORD = 596; pub const ERROR_CLIENT_SERVER_PARAMETERS_INVALID: ::DWORD = 597; pub const ERROR_NOT_TINY_STREAM: ::DWORD = 598; pub const ERROR_STACK_OVERFLOW_READ: ::DWORD = 599; pub const ERROR_CONVERT_TO_LARGE: ::DWORD = 600; pub const ERROR_FOUND_OUT_OF_SCOPE: ::DWORD = 601; pub const ERROR_ALLOCATE_BUCKET: ::DWORD = 602; pub const ERROR_MARSHALL_OVERFLOW: ::DWORD = 603; pub const ERROR_INVALID_VARIANT: ::DWORD = 604; pub const ERROR_BAD_COMPRESSION_BUFFER: ::DWORD = 605; pub const ERROR_AUDIT_FAILED: ::DWORD = 606; pub const ERROR_TIMER_RESOLUTION_NOT_SET: ::DWORD = 607; pub const ERROR_INSUFFICIENT_LOGON_INFO: ::DWORD = 608; pub const ERROR_BAD_DLL_ENTRYPOINT: ::DWORD = 609; pub const ERROR_BAD_SERVICE_ENTRYPOINT: ::DWORD = 610; pub const ERROR_IP_ADDRESS_CONFLICT1: ::DWORD = 611; pub const ERROR_IP_ADDRESS_CONFLICT2: ::DWORD = 612; pub const ERROR_REGISTRY_QUOTA_LIMIT: ::DWORD = 613; pub const ERROR_NO_CALLBACK_ACTIVE: ::DWORD = 614; pub const ERROR_PWD_TOO_SHORT: ::DWORD = 615; pub const ERROR_PWD_TOO_RECENT: ::DWORD = 616; pub const ERROR_PWD_HISTORY_CONFLICT: ::DWORD = 617; pub const ERROR_UNSUPPORTED_COMPRESSION: ::DWORD = 618; pub const ERROR_INVALID_HW_PROFILE: ::DWORD = 619; pub const ERROR_INVALID_PLUGPLAY_DEVICE_PATH: ::DWORD = 620; pub const ERROR_QUOTA_LIST_INCONSISTENT: ::DWORD = 621; pub const ERROR_EVALUATION_EXPIRATION: ::DWORD = 622; pub const ERROR_ILLEGAL_DLL_RELOCATION: ::DWORD = 623; pub const ERROR_DLL_INIT_FAILED_LOGOFF: ::DWORD = 624; pub const ERROR_VALIDATE_CONTINUE: ::DWORD = 625; pub const ERROR_NO_MORE_MATCHES: ::DWORD = 626; pub const ERROR_RANGE_LIST_CONFLICT: ::DWORD = 627; pub const ERROR_SERVER_SID_MISMATCH: ::DWORD = 628; pub const ERROR_CANT_ENABLE_DENY_ONLY: ::DWORD = 629; pub const ERROR_FLOAT_MULTIPLE_FAULTS: ::DWORD = 630; pub const ERROR_FLOAT_MULTIPLE_TRAPS: ::DWORD = 631; pub const ERROR_NOINTERFACE: ::DWORD = 632; pub const ERROR_DRIVER_FAILED_SLEEP: ::DWORD = 633; pub const ERROR_CORRUPT_SYSTEM_FILE: ::DWORD = 634; pub const ERROR_COMMITMENT_MINIMUM: ::DWORD = 635; pub const ERROR_PNP_RESTART_ENUMERATION: ::DWORD = 636; pub const ERROR_SYSTEM_IMAGE_BAD_SIGNATURE: ::DWORD = 637; pub const ERROR_PNP_REBOOT_REQUIRED: ::DWORD = 638; pub const ERROR_INSUFFICIENT_POWER: ::DWORD = 639; pub const ERROR_MULTIPLE_FAULT_VIOLATION: ::DWORD = 640; pub const ERROR_SYSTEM_SHUTDOWN: ::DWORD = 641; pub const ERROR_PORT_NOT_SET: ::DWORD = 642; pub const ERROR_DS_VERSION_CHECK_FAILURE: ::DWORD = 643; pub const ERROR_RANGE_NOT_FOUND: ::DWORD = 644; pub const ERROR_NOT_SAFE_MODE_DRIVER: ::DWORD = 646; pub const ERROR_FAILED_DRIVER_ENTRY: ::DWORD = 647; pub const ERROR_DEVICE_ENUMERATION_ERROR: ::DWORD = 648; pub const ERROR_MOUNT_POINT_NOT_RESOLVED: ::DWORD = 649; pub const ERROR_INVALID_DEVICE_OBJECT_PARAMETER: ::DWORD = 650; pub const ERROR_MCA_OCCURED: ::DWORD = 651; pub const ERROR_DRIVER_DATABASE_ERROR: ::DWORD = 652; pub const ERROR_SYSTEM_HIVE_TOO_LARGE: ::DWORD = 653; pub const ERROR_DRIVER_FAILED_PRIOR_UNLOAD: ::DWORD = 654; pub const ERROR_VOLSNAP_PREPARE_HIBERNATE: ::DWORD = 655; pub const ERROR_HIBERNATION_FAILURE: ::DWORD = 656; pub const ERROR_PWD_TOO_LONG: ::DWORD = 657; pub const ERROR_FILE_SYSTEM_LIMITATION: ::DWORD = 665; pub const ERROR_ASSERTION_FAILURE: ::DWORD = 668; pub const ERROR_ACPI_ERROR: ::DWORD = 669; pub const ERROR_WOW_ASSERTION: ::DWORD = 670; pub const ERROR_PNP_BAD_MPS_TABLE: ::DWORD = 671; pub const ERROR_PNP_TRANSLATION_FAILED: ::DWORD = 672; pub const ERROR_PNP_IRQ_TRANSLATION_FAILED: ::DWORD = 673; pub const ERROR_PNP_INVALID_ID: ::DWORD = 674; pub const ERROR_WAKE_SYSTEM_DEBUGGER: ::DWORD = 675; pub const ERROR_HANDLES_CLOSED: ::DWORD = 676; pub const ERROR_EXTRANEOUS_INFORMATION: ::DWORD = 677; pub const ERROR_RXACT_COMMIT_NECESSARY: ::DWORD = 678; pub const ERROR_MEDIA_CHECK: ::DWORD = 679; pub const ERROR_GUID_SUBSTITUTION_MADE: ::DWORD = 680; pub const ERROR_STOPPED_ON_SYMLINK: ::DWORD = 681; pub const ERROR_LONGJUMP: ::DWORD = 682; pub const ERROR_PLUGPLAY_QUERY_VETOED: ::DWORD = 683; pub const ERROR_UNWIND_CONSOLIDATE: ::DWORD = 684; pub const ERROR_REGISTRY_HIVE_RECOVERED: ::DWORD = 685; pub const ERROR_DLL_MIGHT_BE_INSECURE: ::DWORD = 686; pub const ERROR_DLL_MIGHT_BE_INCOMPATIBLE: ::DWORD = 687; pub const ERROR_DBG_EXCEPTION_NOT_HANDLED: ::DWORD = 688; pub const ERROR_DBG_REPLY_LATER: ::DWORD = 689; pub const ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE: ::DWORD = 690; pub const ERROR_DBG_TERMINATE_THREAD: ::DWORD = 691; pub const ERROR_DBG_TERMINATE_PROCESS: ::DWORD = 692; pub const ERROR_DBG_CONTROL_C: ::DWORD = 693; pub const ERROR_DBG_PRINTEXCEPTION_C: ::DWORD = 694; pub const ERROR_DBG_RIPEXCEPTION: ::DWORD = 695; pub const ERROR_DBG_CONTROL_BREAK: ::DWORD = 696; pub const ERROR_DBG_COMMAND_EXCEPTION: ::DWORD = 697; pub const ERROR_OBJECT_NAME_EXISTS: ::DWORD = 698; pub const ERROR_THREAD_WAS_SUSPENDED: ::DWORD = 699; pub const ERROR_IMAGE_NOT_AT_BASE: ::DWORD = 700; pub const ERROR_RXACT_STATE_CREATED: ::DWORD = 701; pub const ERROR_SEGMENT_NOTIFICATION: ::DWORD = 702; pub const ERROR_BAD_CURRENT_DIRECTORY: ::DWORD = 703; pub const ERROR_FT_READ_RECOVERY_FROM_BACKUP: ::DWORD = 704; pub const ERROR_FT_WRITE_RECOVERY: ::DWORD = 705; pub const ERROR_IMAGE_MACHINE_TYPE_MISMATCH: ::DWORD = 706; pub const ERROR_RECEIVE_PARTIAL: ::DWORD = 707; pub const ERROR_RECEIVE_EXPEDITED: ::DWORD = 708; pub const ERROR_RECEIVE_PARTIAL_EXPEDITED: ::DWORD = 709; pub const ERROR_EVENT_DONE: ::DWORD = 710; pub const ERROR_EVENT_PENDING: ::DWORD = 711; pub const ERROR_CHECKING_FILE_SYSTEM: ::DWORD = 712; pub const ERROR_FATAL_APP_EXIT: ::DWORD = 713; pub const ERROR_PREDEFINED_HANDLE: ::DWORD = 714; pub const ERROR_WAS_UNLOCKED: ::DWORD = 715; pub const ERROR_SERVICE_NOTIFICATION: ::DWORD = 716; pub const ERROR_WAS_LOCKED: ::DWORD = 717; pub const ERROR_LOG_HARD_ERROR: ::DWORD = 718; pub const ERROR_ALREADY_WIN32: ::DWORD = 719; pub const ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE: ::DWORD = 720; pub const ERROR_NO_YIELD_PERFORMED: ::DWORD = 721; pub const ERROR_TIMER_RESUME_IGNORED: ::DWORD = 722; pub const ERROR_ARBITRATION_UNHANDLED: ::DWORD = 723; pub const ERROR_CARDBUS_NOT_SUPPORTED: ::DWORD = 724; pub const ERROR_MP_PROCESSOR_MISMATCH: ::DWORD = 725; pub const ERROR_HIBERNATED: ::DWORD = 726; pub const ERROR_RESUME_HIBERNATION: ::DWORD = 727; pub const ERROR_FIRMWARE_UPDATED: ::DWORD = 728; pub const ERROR_DRIVERS_LEAKING_LOCKED_PAGES: ::DWORD = 729; pub const ERROR_WAKE_SYSTEM: ::DWORD = 730; pub const ERROR_WAIT_1: ::DWORD = 731; pub const ERROR_WAIT_2: ::DWORD = 732; pub const ERROR_WAIT_3: ::DWORD = 733; pub const ERROR_WAIT_63: ::DWORD = 734; pub const ERROR_ABANDONED_WAIT_0: ::DWORD = 735; pub const ERROR_ABANDONED_WAIT_63: ::DWORD = 736; pub const ERROR_USER_APC: ::DWORD = 737; pub const ERROR_KERNEL_APC: ::DWORD = 738; pub const ERROR_ALERTED: ::DWORD = 739; pub const ERROR_ELEVATION_REQUIRED: ::DWORD = 740; pub const ERROR_REPARSE: ::DWORD = 741; pub const ERROR_OPLOCK_BREAK_IN_PROGRESS: ::DWORD = 742; pub const ERROR_VOLUME_MOUNTED: ::DWORD = 743; pub const ERROR_RXACT_COMMITTED: ::DWORD = 744; pub const ERROR_NOTIFY_CLEANUP: ::DWORD = 745; pub const ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED: ::DWORD = 746; pub const ERROR_PAGE_FAULT_TRANSITION: ::DWORD = 747; pub const ERROR_PAGE_FAULT_DEMAND_ZERO: ::DWORD = 748; pub const ERROR_PAGE_FAULT_COPY_ON_WRITE: ::DWORD = 749; pub const ERROR_PAGE_FAULT_GUARD_PAGE: ::DWORD = 750; pub const ERROR_PAGE_FAULT_PAGING_FILE: ::DWORD = 751; pub const ERROR_CACHE_PAGE_LOCKED: ::DWORD = 752; pub const ERROR_CRASH_DUMP: ::DWORD = 753; pub const ERROR_BUFFER_ALL_ZEROS: ::DWORD = 754; pub const ERROR_REPARSE_OBJECT: ::DWORD = 755; pub const ERROR_RESOURCE_REQUIREMENTS_CHANGED: ::DWORD = 756; pub const ERROR_TRANSLATION_COMPLETE: ::DWORD = 757; pub const ERROR_NOTHING_TO_TERMINATE: ::DWORD = 758; pub const ERROR_PROCESS_NOT_IN_JOB: ::DWORD = 759; pub const ERROR_PROCESS_IN_JOB: ::DWORD = 760; pub const ERROR_VOLSNAP_HIBERNATE_READY: ::DWORD = 761; pub const ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY: ::DWORD = 762; pub const ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED: ::DWORD = 763; pub const ERROR_INTERRUPT_STILL_CONNECTED: ::DWORD = 764; pub const ERROR_WAIT_FOR_OPLOCK: ::DWORD = 765; pub const ERROR_DBG_EXCEPTION_HANDLED: ::DWORD = 766; pub const ERROR_DBG_CONTINUE: ::DWORD = 767; pub const ERROR_CALLBACK_POP_STACK: ::DWORD = 768; pub const ERROR_COMPRESSION_DISABLED: ::DWORD = 769; pub const ERROR_CANTFETCHBACKWARDS: ::DWORD = 770; pub const ERROR_CANTSCROLLBACKWARDS: ::DWORD = 771; pub const ERROR_ROWSNOTRELEASED: ::DWORD = 772; pub const ERROR_BAD_ACCESSOR_FLAGS: ::DWORD = 773; pub const ERROR_ERRORS_ENCOUNTERED: ::DWORD = 774; pub const ERROR_NOT_CAPABLE: ::DWORD = 775; pub const ERROR_REQUEST_OUT_OF_SEQUENCE: ::DWORD = 776; pub const ERROR_VERSION_PARSE_ERROR: ::DWORD = 777; pub const ERROR_BADSTARTPOSITION: ::DWORD = 778; pub const ERROR_MEMORY_HARDWARE: ::DWORD = 779; pub const ERROR_DISK_REPAIR_DISABLED: ::DWORD = 780; pub const ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE: ::DWORD = 781; pub const ERROR_SYSTEM_POWERSTATE_TRANSITION: ::DWORD = 782; pub const ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION: ::DWORD = 783; pub const ERROR_MCA_EXCEPTION: ::DWORD = 784; pub const ERROR_ACCESS_AUDIT_BY_POLICY: ::DWORD = 785; pub const ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY: ::DWORD = 786; pub const ERROR_ABANDON_HIBERFILE: ::DWORD = 787; pub const ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED: ::DWORD = 788; pub const ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR: ::DWORD = 789; pub const ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR: ::DWORD = 790; pub const ERROR_BAD_MCFG_TABLE: ::DWORD = 791; pub const ERROR_DISK_REPAIR_REDIRECTED: ::DWORD = 792; pub const ERROR_DISK_REPAIR_UNSUCCESSFUL: ::DWORD = 793; pub const ERROR_CORRUPT_LOG_OVERFULL: ::DWORD = 794; pub const ERROR_CORRUPT_LOG_CORRUPTED: ::DWORD = 795; pub const ERROR_CORRUPT_LOG_UNAVAILABLE: ::DWORD = 796; pub const ERROR_CORRUPT_LOG_DELETED_FULL: ::DWORD = 797; pub const ERROR_CORRUPT_LOG_CLEARED: ::DWORD = 798; pub const ERROR_ORPHAN_NAME_EXHAUSTED: ::DWORD = 799; pub const ERROR_OPLOCK_SWITCHED_TO_NEW_HANDLE: ::DWORD = 800; pub const ERROR_CANNOT_GRANT_REQUESTED_OPLOCK: ::DWORD = 801; pub const ERROR_CANNOT_BREAK_OPLOCK: ::DWORD = 802; pub const ERROR_OPLOCK_HANDLE_CLOSED: ::DWORD = 803; pub const ERROR_NO_ACE_CONDITION: ::DWORD = 804; pub const ERROR_INVALID_ACE_CONDITION: ::DWORD = 805; pub const ERROR_FILE_HANDLE_REVOKED: ::DWORD = 806; pub const ERROR_IMAGE_AT_DIFFERENT_BASE: ::DWORD = 807; pub const ERROR_ENCRYPTED_IO_NOT_POSSIBLE: ::DWORD = 808; pub const ERROR_EA_ACCESS_DENIED: ::DWORD = 994; pub const ERROR_OPERATION_ABORTED: ::DWORD = 995; pub const ERROR_IO_INCOMPLETE: ::DWORD = 996; pub const ERROR_IO_PENDING: ::DWORD = 997; pub const ERROR_NOACCESS: ::DWORD = 998; pub const ERROR_SWAPERROR: ::DWORD = 999; pub const ERROR_STACK_OVERFLOW: ::DWORD = 1001; pub const ERROR_INVALID_MESSAGE: ::DWORD = 1002; pub const ERROR_CAN_NOT_COMPLETE: ::DWORD = 1003; pub const ERROR_INVALID_FLAGS: ::DWORD = 1004; pub const ERROR_UNRECOGNIZED_VOLUME: ::DWORD = 1005; pub const ERROR_FILE_INVALID: ::DWORD = 1006; pub const ERROR_FULLSCREEN_MODE: ::DWORD = 1007; pub const ERROR_NO_TOKEN: ::DWORD = 1008; pub const ERROR_BADDB: ::DWORD = 1009; pub const ERROR_BADKEY: ::DWORD = 1010; pub const ERROR_CANTOPEN: ::DWORD = 1011; pub const ERROR_CANTREAD: ::DWORD = 1012; pub const ERROR_CANTWRITE: ::DWORD = 1013; pub const ERROR_REGISTRY_RECOVERED: ::DWORD = 1014; pub const ERROR_REGISTRY_CORRUPT: ::DWORD = 1015; pub const ERROR_REGISTRY_IO_FAILED: ::DWORD = 1016; pub const ERROR_NOT_REGISTRY_FILE: ::DWORD = 1017; pub const ERROR_KEY_DELETED: ::DWORD = 1018; pub const ERROR_NO_LOG_SPACE: ::DWORD = 1019; pub const ERROR_KEY_HAS_CHILDREN: ::DWORD = 1020; pub const ERROR_CHILD_MUST_BE_VOLATILE: ::DWORD = 1021; pub const ERROR_NOTIFY_ENUM_DIR: ::DWORD = 1022; pub const ERROR_DEPENDENT_SERVICES_RUNNING: ::DWORD = 1051; pub const ERROR_INVALID_SERVICE_CONTROL: ::DWORD = 1052; pub const ERROR_SERVICE_REQUEST_TIMEOUT: ::DWORD = 1053; pub const ERROR_SERVICE_NO_THREAD: ::DWORD = 1054; pub const ERROR_SERVICE_DATABASE_LOCKED: ::DWORD = 1055; pub const ERROR_SERVICE_ALREADY_RUNNING: ::DWORD = 1056; pub const ERROR_INVALID_SERVICE_ACCOUNT: ::DWORD = 1057; pub const ERROR_SERVICE_DISABLED: ::DWORD = 1058; pub const ERROR_CIRCULAR_DEPENDENCY: ::DWORD = 1059; pub const ERROR_SERVICE_DOES_NOT_EXIST: ::DWORD = 1060; pub const ERROR_SERVICE_CANNOT_ACCEPT_CTRL: ::DWORD = 1061; pub const ERROR_SERVICE_NOT_ACTIVE: ::DWORD = 1062; pub const ERROR_FAILED_SERVICE_CONTROLLER_CONNECT: ::DWORD = 1063; pub const ERROR_EXCEPTION_IN_SERVICE: ::DWORD = 1064; pub const ERROR_DATABASE_DOES_NOT_EXIST: ::DWORD = 1065; pub const ERROR_SERVICE_SPECIFIC_ERROR: ::DWORD = 1066; pub const ERROR_PROCESS_ABORTED: ::DWORD = 1067; pub const ERROR_SERVICE_DEPENDENCY_FAIL: ::DWORD = 1068; pub const ERROR_SERVICE_LOGON_FAILED: ::DWORD = 1069; pub const ERROR_SERVICE_START_HANG: ::DWORD = 1070; pub const ERROR_INVALID_SERVICE_LOCK: ::DWORD = 1071; pub const ERROR_SERVICE_MARKED_FOR_DELETE: ::DWORD = 1072; pub const ERROR_SERVICE_EXISTS: ::DWORD = 1073; pub const ERROR_ALREADY_RUNNING_LKG: ::DWORD = 1074; pub const ERROR_SERVICE_DEPENDENCY_DELETED: ::DWORD = 1075; pub const ERROR_BOOT_ALREADY_ACCEPTED: ::DWORD = 1076; pub const ERROR_SERVICE_NEVER_STARTED: ::DWORD = 1077; pub const ERROR_DUPLICATE_SERVICE_NAME: ::DWORD = 1078; pub const ERROR_DIFFERENT_SERVICE_ACCOUNT: ::DWORD = 1079; pub const ERROR_CANNOT_DETECT_DRIVER_FAILURE: ::DWORD = 1080; pub const ERROR_CANNOT_DETECT_PROCESS_ABORT: ::DWORD = 1081; pub const ERROR_NO_RECOVERY_PROGRAM: ::DWORD = 1082; pub const ERROR_SERVICE_NOT_IN_EXE: ::DWORD = 1083; pub const ERROR_NOT_SAFEBOOT_SERVICE: ::DWORD = 1084; pub const ERROR_END_OF_MEDIA: ::DWORD = 1100; pub const ERROR_FILEMARK_DETECTED: ::DWORD = 1101; pub const ERROR_BEGINNING_OF_MEDIA: ::DWORD = 1102; pub const ERROR_SETMARK_DETECTED: ::DWORD = 1103; pub const ERROR_NO_DATA_DETECTED: ::DWORD = 1104; pub const ERROR_PARTITION_FAILURE: ::DWORD = 1105; pub const ERROR_INVALID_BLOCK_LENGTH: ::DWORD = 1106; pub const ERROR_DEVICE_NOT_PARTITIONED: ::DWORD = 1107; pub const ERROR_UNABLE_TO_LOCK_MEDIA: ::DWORD = 1108; pub const ERROR_UNABLE_TO_UNLOAD_MEDIA: ::DWORD = 1109; pub const ERROR_MEDIA_CHANGED: ::DWORD = 1110; pub const ERROR_BUS_RESET: ::DWORD = 1111; pub const ERROR_NO_MEDIA_IN_DRIVE: ::DWORD = 1112; pub const ERROR_NO_UNICODE_TRANSLATION: ::DWORD = 1113; pub const ERROR_DLL_INIT_FAILED: ::DWORD = 1114; pub const ERROR_SHUTDOWN_IN_PROGRESS: ::DWORD = 1115; pub const ERROR_NO_SHUTDOWN_IN_PROGRESS: ::DWORD = 1116; pub const ERROR_IO_DEVICE: ::DWORD = 1117; pub const ERROR_SERIAL_NO_DEVICE: ::DWORD = 1118; pub const ERROR_IRQ_BUSY: ::DWORD = 1119; pub const ERROR_MORE_WRITES: ::DWORD = 1120; pub const ERROR_COUNTER_TIMEOUT: ::DWORD = 1121; pub const ERROR_FLOPPY_ID_MARK_NOT_FOUND: ::DWORD = 1122; pub const ERROR_FLOPPY_WRONG_CYLINDER: ::DWORD = 1123; pub const ERROR_FLOPPY_UNKNOWN_ERROR: ::DWORD = 1124; pub const ERROR_FLOPPY_BAD_REGISTERS: ::DWORD = 1125; pub const ERROR_DISK_RECALIBRATE_FAILED: ::DWORD = 1126; pub const ERROR_DISK_OPERATION_FAILED: ::DWORD = 1127; pub const ERROR_DISK_RESET_FAILED: ::DWORD = 1128; pub const ERROR_EOM_OVERFLOW: ::DWORD = 1129; pub const ERROR_NOT_ENOUGH_SERVER_MEMORY: ::DWORD = 1130; pub const ERROR_POSSIBLE_DEADLOCK: ::DWORD = 1131; pub const ERROR_MAPPED_ALIGNMENT: ::DWORD = 1132; pub const ERROR_SET_POWER_STATE_VETOED: ::DWORD = 1140; pub const ERROR_SET_POWER_STATE_FAILED: ::DWORD = 1141; pub const ERROR_TOO_MANY_LINKS: ::DWORD = 1142; pub const ERROR_OLD_WIN_VERSION: ::DWORD = 1150; pub const ERROR_APP_WRONG_OS: ::DWORD = 1151; pub const ERROR_SINGLE_INSTANCE_APP: ::DWORD = 1152; pub const ERROR_RMODE_APP: ::DWORD = 1153; pub const ERROR_INVALID_DLL: ::DWORD = 1154; pub const ERROR_NO_ASSOCIATION: ::DWORD = 1155; pub const ERROR_DDE_FAIL: ::DWORD = 1156; pub const ERROR_DLL_NOT_FOUND: ::DWORD = 1157; pub const ERROR_NO_MORE_USER_HANDLES: ::DWORD = 1158; pub const ERROR_MESSAGE_SYNC_ONLY: ::DWORD = 1159; pub const ERROR_SOURCE_ELEMENT_EMPTY: ::DWORD = 1160; pub const ERROR_DESTINATION_ELEMENT_FULL: ::DWORD = 1161; pub const ERROR_ILLEGAL_ELEMENT_ADDRESS: ::DWORD = 1162; pub const ERROR_MAGAZINE_NOT_PRESENT: ::DWORD = 1163; pub const ERROR_DEVICE_REINITIALIZATION_NEEDED: ::DWORD = 1164; pub const ERROR_DEVICE_REQUIRES_CLEANING: ::DWORD = 1165; pub const ERROR_DEVICE_DOOR_OPEN: ::DWORD = 1166; pub const ERROR_DEVICE_NOT_CONNECTED: ::DWORD = 1167; pub const ERROR_NOT_FOUND: ::DWORD = 1168; pub const ERROR_NO_MATCH: ::DWORD = 1169; pub const ERROR_SET_NOT_FOUND: ::DWORD = 1170; pub const ERROR_POINT_NOT_FOUND: ::DWORD = 1171; pub const ERROR_NO_TRACKING_SERVICE: ::DWORD = 1172; pub const ERROR_NO_VOLUME_ID: ::DWORD = 1173; pub const ERROR_UNABLE_TO_REMOVE_REPLACED: ::DWORD = 1175; pub const ERROR_UNABLE_TO_MOVE_REPLACEMENT: ::DWORD = 1176; pub const ERROR_UNABLE_TO_MOVE_REPLACEMENT_2: ::DWORD = 1177; pub const ERROR_JOURNAL_DELETE_IN_PROGRESS: ::DWORD = 1178; pub const ERROR_JOURNAL_NOT_ACTIVE: ::DWORD = 1179; pub const ERROR_POTENTIAL_FILE_FOUND: ::DWORD = 1180; pub const ERROR_JOURNAL_ENTRY_DELETED: ::DWORD = 1181; pub const ERROR_SHUTDOWN_IS_SCHEDULED: ::DWORD = 1190; pub const ERROR_SHUTDOWN_USERS_LOGGED_ON: ::DWORD = 1191; pub const ERROR_BAD_DEVICE: ::DWORD = 1200; pub const ERROR_CONNECTION_UNAVAIL: ::DWORD = 1201; pub const ERROR_DEVICE_ALREADY_REMEMBERED: ::DWORD = 1202; pub const ERROR_NO_NET_OR_BAD_PATH: ::DWORD = 1203; pub const ERROR_BAD_PROVIDER: ::DWORD = 1204; pub const ERROR_CANNOT_OPEN_PROFILE: ::DWORD = 1205; pub const ERROR_BAD_PROFILE: ::DWORD = 1206; pub const ERROR_NOT_CONTAINER: ::DWORD = 1207; pub const ERROR_EXTENDED_ERROR: ::DWORD = 1208; pub const ERROR_INVALID_GROUPNAME: ::DWORD = 1209; pub const ERROR_INVALID_COMPUTERNAME: ::DWORD = 1210; pub const ERROR_INVALID_EVENTNAME: ::DWORD = 1211; pub const ERROR_INVALID_DOMAINNAME: ::DWORD = 1212; pub const ERROR_INVALID_SERVICENAME: ::DWORD = 1213; pub const ERROR_INVALID_NETNAME: ::DWORD = 1214; pub const ERROR_INVALID_SHARENAME: ::DWORD = 1215; pub const ERROR_INVALID_PASSWORDNAME: ::DWORD = 1216; pub const ERROR_INVALID_MESSAGENAME: ::DWORD = 1217; pub const ERROR_INVALID_MESSAGEDEST: ::DWORD = 1218; pub const ERROR_SESSION_CREDENTIAL_CONFLICT: ::DWORD = 1219; pub const ERROR_REMOTE_SESSION_LIMIT_EXCEEDED: ::DWORD = 1220; pub const ERROR_DUP_DOMAINNAME: ::DWORD = 1221; pub const ERROR_NO_NETWORK: ::DWORD = 1222; pub const ERROR_CANCELLED: ::DWORD = 1223; pub const ERROR_USER_MAPPED_FILE: ::DWORD = 1224; pub const ERROR_CONNECTION_REFUSED: ::DWORD = 1225; pub const ERROR_GRACEFUL_DISCONNECT: ::DWORD = 1226; pub const ERROR_ADDRESS_ALREADY_ASSOCIATED: ::DWORD = 1227; pub const ERROR_ADDRESS_NOT_ASSOCIATED: ::DWORD = 1228; pub const ERROR_CONNECTION_INVALID: ::DWORD = 1229; pub const ERROR_CONNECTION_ACTIVE: ::DWORD = 1230; pub const ERROR_NETWORK_UNREACHABLE: ::DWORD = 1231; pub const ERROR_HOST_UNREACHABLE: ::DWORD = 1232; pub const ERROR_PROTOCOL_UNREACHABLE: ::DWORD = 1233; pub const ERROR_PORT_UNREACHABLE: ::DWORD = 1234; pub const ERROR_REQUEST_ABORTED: ::DWORD = 1235; pub const ERROR_CONNECTION_ABORTED: ::DWORD = 1236; pub const ERROR_RETRY: ::DWORD = 1237; pub const ERROR_CONNECTION_COUNT_LIMIT: ::DWORD = 1238; pub const ERROR_LOGIN_TIME_RESTRICTION: ::DWORD = 1239; pub const ERROR_LOGIN_WKSTA_RESTRICTION: ::DWORD = 1240; pub const ERROR_INCORRECT_ADDRESS: ::DWORD = 1241; pub const ERROR_ALREADY_REGISTERED: ::DWORD = 1242; pub const ERROR_SERVICE_NOT_FOUND: ::DWORD = 1243; pub const ERROR_NOT_AUTHENTICATED: ::DWORD = 1244; pub const ERROR_NOT_LOGGED_ON: ::DWORD = 1245; pub const ERROR_CONTINUE: ::DWORD = 1246; pub const ERROR_ALREADY_INITIALIZED: ::DWORD = 1247; pub const ERROR_NO_MORE_DEVICES: ::DWORD = 1248; pub const ERROR_NO_SUCH_SITE: ::DWORD = 1249; pub const ERROR_DOMAIN_CONTROLLER_EXISTS: ::DWORD = 1250; pub const ERROR_ONLY_IF_CONNECTED: ::DWORD = 1251; pub const ERROR_OVERRIDE_NOCHANGES: ::DWORD = 1252; pub const ERROR_BAD_USER_PROFILE: ::DWORD = 1253; pub const ERROR_NOT_SUPPORTED_ON_SBS: ::DWORD = 1254; pub const ERROR_SERVER_SHUTDOWN_IN_PROGRESS: ::DWORD = 1255; pub const ERROR_HOST_DOWN: ::DWORD = 1256; pub const ERROR_NON_ACCOUNT_SID: ::DWORD = 1257; pub const ERROR_NON_DOMAIN_SID: ::DWORD = 1258; pub const ERROR_APPHELP_BLOCK: ::DWORD = 1259; pub const ERROR_ACCESS_DISABLED_BY_POLICY: ::DWORD = 1260; pub const ERROR_REG_NAT_CONSUMPTION: ::DWORD = 1261; pub const ERROR_CSCSHARE_OFFLINE: ::DWORD = 1262; pub const ERROR_PKINIT_FAILURE: ::DWORD = 1263; pub const ERROR_SMARTCARD_SUBSYSTEM_FAILURE: ::DWORD = 1264; pub const ERROR_DOWNGRADE_DETECTED: ::DWORD = 1265; pub const ERROR_MACHINE_LOCKED: ::DWORD = 1271; pub const ERROR_CALLBACK_SUPPLIED_INVALID_DATA: ::DWORD = 1273; pub const ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED: ::DWORD = 1274; pub const ERROR_DRIVER_BLOCKED: ::DWORD = 1275; pub const ERROR_INVALID_IMPORT_OF_NON_DLL: ::DWORD = 1276; pub const ERROR_ACCESS_DISABLED_WEBBLADE: ::DWORD = 1277; pub const ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER: ::DWORD = 1278; pub const ERROR_RECOVERY_FAILURE: ::DWORD = 1279; pub const ERROR_ALREADY_FIBER: ::DWORD = 1280; pub const ERROR_ALREADY_THREAD: ::DWORD = 1281; pub const ERROR_STACK_BUFFER_OVERRUN: ::DWORD = 1282; pub const ERROR_PARAMETER_QUOTA_EXCEEDED: ::DWORD = 1283; pub const ERROR_DEBUGGER_INACTIVE: ::DWORD = 1284; pub const ERROR_DELAY_LOAD_FAILED: ::DWORD = 1285; pub const ERROR_VDM_DISALLOWED: ::DWORD = 1286; pub const ERROR_UNIDENTIFIED_ERROR: ::DWORD = 1287; pub const ERROR_INVALID_CRUNTIME_PARAMETER: ::DWORD = 1288; pub const ERROR_BEYOND_VDL: ::DWORD = 1289; pub const ERROR_INCOMPATIBLE_SERVICE_SID_TYPE: ::DWORD = 1290; pub const ERROR_DRIVER_PROCESS_TERMINATED: ::DWORD = 1291; pub const ERROR_IMPLEMENTATION_LIMIT: ::DWORD = 1292; pub const ERROR_PROCESS_IS_PROTECTED: ::DWORD = 1293; pub const ERROR_SERVICE_NOTIFY_CLIENT_LAGGING: ::DWORD = 1294; pub const ERROR_DISK_QUOTA_EXCEEDED: ::DWORD = 1295; pub const ERROR_CONTENT_BLOCKED: ::DWORD = 1296; pub const ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE: ::DWORD = 1297; pub const ERROR_APP_HANG: ::DWORD = 1298; pub const ERROR_INVALID_LABEL: ::DWORD = 1299; pub const ERROR_NOT_ALL_ASSIGNED: ::DWORD = 1300; pub const ERROR_SOME_NOT_MAPPED: ::DWORD = 1301; pub const ERROR_NO_QUOTAS_FOR_ACCOUNT: ::DWORD = 1302; pub const ERROR_LOCAL_USER_SESSION_KEY: ::DWORD = 1303; pub const ERROR_NULL_LM_PASSWORD: ::DWORD = 1304; pub const ERROR_UNKNOWN_REVISION: ::DWORD = 1305; pub const ERROR_REVISION_MISMATCH: ::DWORD = 1306; pub const ERROR_INVALID_OWNER: ::DWORD = 1307; pub const ERROR_INVALID_PRIMARY_GROUP: ::DWORD = 1308; pub const ERROR_NO_IMPERSONATION_TOKEN: ::DWORD = 1309; pub const ERROR_CANT_DISABLE_MANDATORY: ::DWORD = 1310; pub const ERROR_NO_LOGON_SERVERS: ::DWORD = 1311; pub const ERROR_NO_SUCH_LOGON_SESSION: ::DWORD = 1312; pub const ERROR_NO_SUCH_PRIVILEGE: ::DWORD = 1313; pub const ERROR_PRIVILEGE_NOT_HELD: ::DWORD = 1314; pub const ERROR_INVALID_ACCOUNT_NAME: ::DWORD = 1315; pub const ERROR_USER_EXISTS: ::DWORD = 1316; pub const ERROR_NO_SUCH_USER: ::DWORD = 1317; pub const ERROR_GROUP_EXISTS: ::DWORD = 1318; pub const ERROR_NO_SUCH_GROUP: ::DWORD = 1319; pub const ERROR_MEMBER_IN_GROUP: ::DWORD = 1320; pub const ERROR_MEMBER_NOT_IN_GROUP: ::DWORD = 1321; pub const ERROR_LAST_ADMIN: ::DWORD = 1322; pub const ERROR_WRONG_PASSWORD: ::DWORD = 1323; pub const ERROR_ILL_FORMED_PASSWORD: ::DWORD = 1324; pub const ERROR_PASSWORD_RESTRICTION: ::DWORD = 1325; pub const ERROR_LOGON_FAILURE: ::DWORD = 1326; pub const ERROR_ACCOUNT_RESTRICTION: ::DWORD = 1327; pub const ERROR_INVALID_LOGON_HOURS: ::DWORD = 1328; pub const ERROR_INVALID_WORKSTATION: ::DWORD = 1329; pub const ERROR_PASSWORD_EXPIRED: ::DWORD = 1330; pub const ERROR_ACCOUNT_DISABLED: ::DWORD = 1331; pub const ERROR_NONE_MAPPED: ::DWORD = 1332; pub const ERROR_TOO_MANY_LUIDS_REQUESTED: ::DWORD = 1333; pub const ERROR_LUIDS_EXHAUSTED: ::DWORD = 1334; pub const ERROR_INVALID_SUB_AUTHORITY: ::DWORD = 1335; pub const ERROR_INVALID_ACL: ::DWORD = 1336; pub const ERROR_INVALID_SID: ::DWORD = 1337; pub const ERROR_INVALID_SECURITY_DESCR: ::DWORD = 1338; pub const ERROR_BAD_INHERITANCE_ACL: ::DWORD = 1340; pub const ERROR_SERVER_DISABLED: ::DWORD = 1341; pub const ERROR_SERVER_NOT_DISABLED: ::DWORD = 1342; pub const ERROR_INVALID_ID_AUTHORITY: ::DWORD = 1343; pub const ERROR_ALLOTTED_SPACE_EXCEEDED: ::DWORD = 1344; pub const ERROR_INVALID_GROUP_ATTRIBUTES: ::DWORD = 1345; pub const ERROR_BAD_IMPERSONATION_LEVEL: ::DWORD = 1346; pub const ERROR_CANT_OPEN_ANONYMOUS: ::DWORD = 1347; pub const ERROR_BAD_VALIDATION_CLASS: ::DWORD = 1348; pub const ERROR_BAD_TOKEN_TYPE: ::DWORD = 1349; pub const ERROR_NO_SECURITY_ON_OBJECT: ::DWORD = 1350; pub const ERROR_CANT_ACCESS_DOMAIN_INFO: ::DWORD = 1351; pub const ERROR_INVALID_SERVER_STATE: ::DWORD = 1352; pub const ERROR_INVALID_DOMAIN_STATE: ::DWORD = 1353; pub const ERROR_INVALID_DOMAIN_ROLE: ::DWORD = 1354; pub const ERROR_NO_SUCH_DOMAIN: ::DWORD = 1355; pub const ERROR_DOMAIN_EXISTS: ::DWORD = 1356; pub const ERROR_DOMAIN_LIMIT_EXCEEDED: ::DWORD = 1357; pub const ERROR_INTERNAL_DB_CORRUPTION: ::DWORD = 1358; pub const ERROR_INTERNAL_ERROR: ::DWORD = 1359; pub const ERROR_GENERIC_NOT_MAPPED: ::DWORD = 1360; pub const ERROR_BAD_DESCRIPTOR_FORMAT: ::DWORD = 1361; pub const ERROR_NOT_LOGON_PROCESS: ::DWORD = 1362; pub const ERROR_LOGON_SESSION_EXISTS: ::DWORD = 1363; pub const ERROR_NO_SUCH_PACKAGE: ::DWORD = 1364; pub const ERROR_BAD_LOGON_SESSION_STATE: ::DWORD = 1365; pub const ERROR_LOGON_SESSION_COLLISION: ::DWORD = 1366; pub const ERROR_INVALID_LOGON_TYPE: ::DWORD = 1367; pub const ERROR_CANNOT_IMPERSONATE: ::DWORD = 1368; pub const ERROR_RXACT_INVALID_STATE: ::DWORD = 1369; pub const ERROR_RXACT_COMMIT_FAILURE: ::DWORD = 1370; pub const ERROR_SPECIAL_ACCOUNT: ::DWORD = 1371; pub const ERROR_SPECIAL_GROUP: ::DWORD = 1372; pub const ERROR_SPECIAL_USER: ::DWORD = 1373; pub const ERROR_MEMBERS_PRIMARY_GROUP: ::DWORD = 1374; pub const ERROR_TOKEN_ALREADY_IN_USE: ::DWORD = 1375; pub const ERROR_NO_SUCH_ALIAS: ::DWORD = 1376; pub const ERROR_MEMBER_NOT_IN_ALIAS: ::DWORD = 1377; pub const ERROR_MEMBER_IN_ALIAS: ::DWORD = 1378; pub const ERROR_ALIAS_EXISTS: ::DWORD = 1379; pub const ERROR_LOGON_NOT_GRANTED: ::DWORD = 1380; pub const ERROR_TOO_MANY_SECRETS: ::DWORD = 1381; pub const ERROR_SECRET_TOO_LONG: ::DWORD = 1382; pub const ERROR_INTERNAL_DB_ERROR: ::DWORD = 1383; pub const ERROR_TOO_MANY_CONTEXT_IDS: ::DWORD = 1384; pub const ERROR_LOGON_TYPE_NOT_GRANTED: ::DWORD = 1385; pub const ERROR_NT_CROSS_ENCRYPTION_REQUIRED: ::DWORD = 1386; pub const ERROR_NO_SUCH_MEMBER: ::DWORD = 1387; pub const ERROR_INVALID_MEMBER: ::DWORD = 1388; pub const ERROR_TOO_MANY_SIDS: ::DWORD = 1389; pub const ERROR_LM_CROSS_ENCRYPTION_REQUIRED: ::DWORD = 1390; pub const ERROR_NO_INHERITANCE: ::DWORD = 1391; pub const ERROR_FILE_CORRUPT: ::DWORD = 1392; pub const ERROR_DISK_CORRUPT: ::DWORD = 1393; pub const ERROR_NO_USER_SESSION_KEY: ::DWORD = 1394; pub const ERROR_LICENSE_QUOTA_EXCEEDED: ::DWORD = 1395; pub const ERROR_WRONG_TARGET_NAME: ::DWORD = 1396; pub const ERROR_MUTUAL_AUTH_FAILED: ::DWORD = 1397; pub const ERROR_TIME_SKEW: ::DWORD = 1398; pub const ERROR_CURRENT_DOMAIN_NOT_ALLOWED: ::DWORD = 1399; pub const ERROR_INVALID_WINDOW_HANDLE: ::DWORD = 1400; pub const ERROR_INVALID_MENU_HANDLE: ::DWORD = 1401; pub const ERROR_INVALID_CURSOR_HANDLE: ::DWORD = 1402; pub const ERROR_INVALID_ACCEL_HANDLE: ::DWORD = 1403; pub const ERROR_INVALID_HOOK_HANDLE: ::DWORD = 1404; pub const ERROR_INVALID_DWP_HANDLE: ::DWORD = 1405; pub const ERROR_TLW_WITH_WSCHILD: ::DWORD = 1406; pub const ERROR_CANNOT_FIND_WND_CLASS: ::DWORD = 1407; pub const ERROR_WINDOW_OF_OTHER_THREAD: ::DWORD = 1408; pub const ERROR_HOTKEY_ALREADY_REGISTERED: ::DWORD = 1409; pub const ERROR_CLASS_ALREADY_EXISTS: ::DWORD = 1410; pub const ERROR_CLASS_DOES_NOT_EXIST: ::DWORD = 1411; pub const ERROR_CLASS_HAS_WINDOWS: ::DWORD = 1412; pub const ERROR_INVALID_INDEX: ::DWORD = 1413; pub const ERROR_INVALID_ICON_HANDLE: ::DWORD = 1414; pub const ERROR_PRIVATE_DIALOG_INDEX: ::DWORD = 1415; pub const ERROR_LISTBOX_ID_NOT_FOUND: ::DWORD = 1416; pub const ERROR_NO_WILDCARD_CHARACTERS: ::DWORD = 1417; pub const ERROR_CLIPBOARD_NOT_OPEN: ::DWORD = 1418; pub const ERROR_HOTKEY_NOT_REGISTERED: ::DWORD = 1419; pub const ERROR_WINDOW_NOT_DIALOG: ::DWORD = 1420; pub const ERROR_CONTROL_ID_NOT_FOUND: ::DWORD = 1421; pub const ERROR_INVALID_COMBOBOX_MESSAGE: ::DWORD = 1422; pub const ERROR_WINDOW_NOT_COMBOBOX: ::DWORD = 1423; pub const ERROR_INVALID_EDIT_HEIGHT: ::DWORD = 1424; pub const ERROR_DC_NOT_FOUND: ::DWORD = 1425; pub const ERROR_INVALID_HOOK_FILTER: ::DWORD = 1426; pub const ERROR_INVALID_FILTER_PROC: ::DWORD = 1427; pub const ERROR_HOOK_NEEDS_HMOD: ::DWORD = 1428; pub const ERROR_GLOBAL_ONLY_HOOK: ::DWORD = 1429; pub const ERROR_JOURNAL_HOOK_SET: ::DWORD = 1430; pub const ERROR_HOOK_NOT_INSTALLED: ::DWORD = 1431; pub const ERROR_INVALID_LB_MESSAGE: ::DWORD = 1432; pub const ERROR_SETCOUNT_ON_BAD_LB: ::DWORD = 1433; pub const ERROR_LB_WITHOUT_TABSTOPS: ::DWORD = 1434; pub const ERROR_DESTROY_OBJECT_OF_OTHER_THREAD: ::DWORD = 1435; pub const ERROR_CHILD_WINDOW_MENU: ::DWORD = 1436; pub const ERROR_NO_SYSTEM_MENU: ::DWORD = 1437; pub const ERROR_INVALID_MSGBOX_STYLE: ::DWORD = 1438; pub const ERROR_INVALID_SPI_VALUE: ::DWORD = 1439; pub const ERROR_SCREEN_ALREADY_LOCKED: ::DWORD = 1440; pub const ERROR_HWNDS_HAVE_DIFF_PARENT: ::DWORD = 1441; pub const ERROR_NOT_CHILD_WINDOW: ::DWORD = 1442; pub const ERROR_INVALID_GW_COMMAND: ::DWORD = 1443; pub const ERROR_INVALID_THREAD_ID: ::DWORD = 1444; pub const ERROR_NON_MDICHILD_WINDOW: ::DWORD = 1445; pub const ERROR_POPUP_ALREADY_ACTIVE: ::DWORD = 1446; pub const ERROR_NO_SCROLLBARS: ::DWORD = 1447; pub const ERROR_INVALID_SCROLLBAR_RANGE: ::DWORD = 1448; pub const ERROR_INVALID_SHOWWIN_COMMAND: ::DWORD = 1449; pub const ERROR_NO_SYSTEM_RESOURCES: ::DWORD = 1450; pub const ERROR_NONPAGED_SYSTEM_RESOURCES: ::DWORD = 1451; pub const ERROR_PAGED_SYSTEM_RESOURCES: ::DWORD = 1452; pub const ERROR_WORKING_SET_QUOTA: ::DWORD = 1453; pub const ERROR_PAGEFILE_QUOTA: ::DWORD = 1454; pub const ERROR_COMMITMENT_LIMIT: ::DWORD = 1455; pub const ERROR_MENU_ITEM_NOT_FOUND: ::DWORD = 1456; pub const ERROR_INVALID_KEYBOARD_HANDLE: ::DWORD = 1457; pub const ERROR_HOOK_TYPE_NOT_ALLOWED: ::DWORD = 1458; pub const ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION: ::DWORD = 1459; pub const ERROR_TIMEOUT: ::DWORD = 1460; pub const ERROR_INVALID_MONITOR_HANDLE: ::DWORD = 1461; pub const ERROR_INCORRECT_SIZE: ::DWORD = 1462; pub const ERROR_SYMLINK_CLASS_DISABLED: ::DWORD = 1463; pub const ERROR_SYMLINK_NOT_SUPPORTED: ::DWORD = 1464; pub const ERROR_XML_PARSE_ERROR: ::DWORD = 1465; pub const ERROR_XMLDSIG_ERROR: ::DWORD = 1466; pub const ERROR_RESTART_APPLICATION: ::DWORD = 1467; pub const ERROR_WRONG_COMPARTMENT: ::DWORD = 1468; pub const ERROR_AUTHIP_FAILURE: ::DWORD = 1469; pub const ERROR_NO_NVRAM_RESOURCES: ::DWORD = 1470; pub const ERROR_NOT_GUI_PROCESS: ::DWORD = 1471; pub const ERROR_EVENTLOG_FILE_CORRUPT: ::DWORD = 1500; pub const ERROR_EVENTLOG_CANT_START: ::DWORD = 1501; pub const ERROR_LOG_FILE_FULL: ::DWORD = 1502; pub const ERROR_EVENTLOG_FILE_CHANGED: ::DWORD = 1503; pub const ERROR_INVALID_TASK_NAME: ::DWORD = 1550; pub const ERROR_INVALID_TASK_INDEX: ::DWORD = 1551; pub const ERROR_THREAD_ALREADY_IN_TASK: ::DWORD = 1552; pub const ERROR_INSTALL_SERVICE_FAILURE: ::DWORD = 1601; pub const ERROR_INSTALL_USEREXIT: ::DWORD = 1602; pub const ERROR_INSTALL_FAILURE: ::DWORD = 1603; pub const ERROR_INSTALL_SUSPEND: ::DWORD = 1604; pub const ERROR_UNKNOWN_PRODUCT: ::DWORD = 1605; pub const ERROR_UNKNOWN_FEATURE: ::DWORD = 1606; pub const ERROR_UNKNOWN_COMPONENT: ::DWORD = 1607; pub const ERROR_UNKNOWN_PROPERTY: ::DWORD = 1608; pub const ERROR_INVALID_HANDLE_STATE: ::DWORD = 1609; pub const ERROR_BAD_CONFIGURATION: ::DWORD = 1610; pub const ERROR_INDEX_ABSENT: ::DWORD = 1611; pub const ERROR_INSTALL_SOURCE_ABSENT: ::DWORD = 1612; pub const ERROR_INSTALL_PACKAGE_VERSION: ::DWORD = 1613; pub const ERROR_PRODUCT_UNINSTALLED: ::DWORD = 1614; pub const ERROR_BAD_QUERY_SYNTAX: ::DWORD = 1615; pub const ERROR_INVALID_FIELD: ::DWORD = 1616; pub const ERROR_DEVICE_REMOVED: ::DWORD = 1617; pub const ERROR_INSTALL_ALREADY_RUNNING: ::DWORD = 1618; pub const ERROR_INSTALL_PACKAGE_OPEN_FAILED: ::DWORD = 1619; pub const ERROR_INSTALL_PACKAGE_INVALID: ::DWORD = 1620; pub const ERROR_INSTALL_UI_FAILURE: ::DWORD = 1621; pub const ERROR_INSTALL_LOG_FAILURE: ::DWORD = 1622; pub const ERROR_INSTALL_LANGUAGE_UNSUPPORTED: ::DWORD = 1623; pub const ERROR_INSTALL_TRANSFORM_FAILURE: ::DWORD = 1624; pub const ERROR_INSTALL_PACKAGE_REJECTED: ::DWORD = 1625; pub const ERROR_FUNCTION_NOT_CALLED: ::DWORD = 1626; pub const ERROR_FUNCTION_FAILED: ::DWORD = 1627; pub const ERROR_INVALID_TABLE: ::DWORD = 1628; pub const ERROR_DATATYPE_MISMATCH: ::DWORD = 1629; pub const ERROR_UNSUPPORTED_TYPE: ::DWORD = 1630; pub const ERROR_CREATE_FAILED: ::DWORD = 1631; pub const ERROR_INSTALL_TEMP_UNWRITABLE: ::DWORD = 1632; pub const ERROR_INSTALL_PLATFORM_UNSUPPORTED: ::DWORD = 1633; pub const ERROR_INSTALL_NOTUSED: ::DWORD = 1634; pub const ERROR_PATCH_PACKAGE_OPEN_FAILED: ::DWORD = 1635; pub const ERROR_PATCH_PACKAGE_INVALID: ::DWORD = 1636; pub const ERROR_PATCH_PACKAGE_UNSUPPORTED: ::DWORD = 1637; pub const ERROR_PRODUCT_VERSION: ::DWORD = 1638; pub const ERROR_INVALID_COMMAND_LINE: ::DWORD = 1639; pub const ERROR_INSTALL_REMOTE_DISALLOWED: ::DWORD = 1640; pub const ERROR_SUCCESS_REBOOT_INITIATED: ::DWORD = 1641; pub const ERROR_PATCH_TARGET_NOT_FOUND: ::DWORD = 1642; pub const ERROR_PATCH_PACKAGE_REJECTED: ::DWORD = 1643; pub const ERROR_INSTALL_TRANSFORM_REJECTED: ::DWORD = 1644; pub const ERROR_INSTALL_REMOTE_PROHIBITED: ::DWORD = 1645; pub const ERROR_PATCH_REMOVAL_UNSUPPORTED: ::DWORD = 1646; pub const ERROR_UNKNOWN_PATCH: ::DWORD = 1647; pub const ERROR_PATCH_NO_SEQUENCE: ::DWORD = 1648; pub const ERROR_PATCH_REMOVAL_DISALLOWED: ::DWORD = 1649; pub const ERROR_INVALID_PATCH_XML: ::DWORD = 1650; pub const ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT: ::DWORD = 1651; pub const ERROR_INSTALL_SERVICE_SAFEBOOT: ::DWORD = 1652; pub const ERROR_FAIL_FAST_EXCEPTION: ::DWORD = 1653; pub const ERROR_INSTALL_REJECTED: ::DWORD = 1654; pub const ERROR_DYNAMIC_CODE_BLOCKED: ::DWORD = 1655; pub const RPC_S_INVALID_STRING_BINDING: ::DWORD = 1700; pub const RPC_S_WRONG_KIND_OF_BINDING: ::DWORD = 1701; pub const RPC_S_INVALID_BINDING: ::DWORD = 1702; pub const RPC_S_PROTSEQ_NOT_SUPPORTED: ::DWORD = 1703; pub const RPC_S_INVALID_RPC_PROTSEQ: ::DWORD = 1704; pub const RPC_S_INVALID_STRING_UUID: ::DWORD = 1705; pub const RPC_S_INVALID_ENDPOINT_FORMAT: ::DWORD = 1706; pub const RPC_S_INVALID_NET_ADDR: ::DWORD = 1707; pub const RPC_S_NO_ENDPOINT_FOUND: ::DWORD = 1708; pub const RPC_S_INVALID_TIMEOUT: ::DWORD = 1709; pub const RPC_S_OBJECT_NOT_FOUND: ::DWORD = 1710; pub const RPC_S_ALREADY_REGISTERED: ::DWORD = 1711; pub const RPC_S_TYPE_ALREADY_REGISTERED: ::DWORD = 1712; pub const RPC_S_ALREADY_LISTENING: ::DWORD = 1713; pub const RPC_S_NO_PROTSEQS_REGISTERED: ::DWORD = 1714; pub const RPC_S_NOT_LISTENING: ::DWORD = 1715; pub const RPC_S_UNKNOWN_MGR_TYPE: ::DWORD = 1716; pub const RPC_S_UNKNOWN_IF: ::DWORD = 1717; pub const RPC_S_NO_BINDINGS: ::DWORD = 1718; pub const RPC_S_NO_PROTSEQS: ::DWORD = 1719; pub const RPC_S_CANT_CREATE_ENDPOINT: ::DWORD = 1720; pub const RPC_S_OUT_OF_RESOURCES: ::DWORD = 1721; pub const RPC_S_SERVER_UNAVAILABLE: ::DWORD = 1722; pub const RPC_S_SERVER_TOO_BUSY: ::DWORD = 1723; pub const RPC_S_INVALID_NETWORK_OPTIONS: ::DWORD = 1724; pub const RPC_S_NO_CALL_ACTIVE: ::DWORD = 1725; pub const RPC_S_CALL_FAILED: ::DWORD = 1726; pub const RPC_S_CALL_FAILED_DNE: ::DWORD = 1727; pub const RPC_S_PROTOCOL_ERROR: ::DWORD = 1728; pub const RPC_S_PROXY_ACCESS_DENIED: ::DWORD = 1729; pub const RPC_S_UNSUPPORTED_TRANS_SYN: ::DWORD = 1730; pub const RPC_S_UNSUPPORTED_TYPE: ::DWORD = 1732; pub const RPC_S_INVALID_TAG: ::DWORD = 1733; pub const RPC_S_INVALID_BOUND: ::DWORD = 1734; pub const RPC_S_NO_ENTRY_NAME: ::DWORD = 1735; pub const RPC_S_INVALID_NAME_SYNTAX: ::DWORD = 1736; pub const RPC_S_UNSUPPORTED_NAME_SYNTAX: ::DWORD = 1737; pub const RPC_S_UUID_NO_ADDRESS: ::DWORD = 1739; pub const RPC_S_DUPLICATE_ENDPOINT: ::DWORD = 1740; pub const RPC_S_UNKNOWN_AUTHN_TYPE: ::DWORD = 1741; pub const RPC_S_MAX_CALLS_TOO_SMALL: ::DWORD = 1742; pub const RPC_S_STRING_TOO_LONG: ::DWORD = 1743; pub const RPC_S_PROTSEQ_NOT_FOUND: ::DWORD = 1744; pub const RPC_S_PROCNUM_OUT_OF_RANGE: ::DWORD = 1745; pub const RPC_S_BINDING_HAS_NO_AUTH: ::DWORD = 1746; pub const RPC_S_UNKNOWN_AUTHN_SERVICE: ::DWORD = 1747; pub const RPC_S_UNKNOWN_AUTHN_LEVEL: ::DWORD = 1748; pub const RPC_S_INVALID_AUTH_IDENTITY: ::DWORD = 1749; pub const RPC_S_UNKNOWN_AUTHZ_SERVICE: ::DWORD = 1750; pub const EPT_S_INVALID_ENTRY: ::DWORD = 1751; pub const EPT_S_CANT_PERFORM_OP: ::DWORD = 1752; pub const EPT_S_NOT_REGISTERED: ::DWORD = 1753; pub const RPC_S_NOTHING_TO_EXPORT: ::DWORD = 1754; pub const RPC_S_INCOMPLETE_NAME: ::DWORD = 1755; pub const RPC_S_INVALID_VERS_OPTION: ::DWORD = 1756; pub const RPC_S_NO_MORE_MEMBERS: ::DWORD = 1757; pub const RPC_S_NOT_ALL_OBJS_UNEXPORTED: ::DWORD = 1758; pub const RPC_S_INTERFACE_NOT_FOUND: ::DWORD = 1759; pub const RPC_S_ENTRY_ALREADY_EXISTS: ::DWORD = 1760; pub const RPC_S_ENTRY_NOT_FOUND: ::DWORD = 1761; pub const RPC_S_NAME_SERVICE_UNAVAILABLE: ::DWORD = 1762; pub const RPC_S_INVALID_NAF_ID: ::DWORD = 1763; pub const RPC_S_CANNOT_SUPPORT: ::DWORD = 1764; pub const RPC_S_NO_CONTEXT_AVAILABLE: ::DWORD = 1765; pub const RPC_S_INTERNAL_ERROR: ::DWORD = 1766; pub const RPC_S_ZERO_DIVIDE: ::DWORD = 1767; pub const RPC_S_ADDRESS_ERROR: ::DWORD = 1768; pub const RPC_S_FP_DIV_ZERO: ::DWORD = 1769; pub const RPC_S_FP_UNDERFLOW: ::DWORD = 1770; pub const RPC_S_FP_OVERFLOW: ::DWORD = 1771; pub const RPC_X_NO_MORE_ENTRIES: ::DWORD = 1772; pub const RPC_X_SS_CHAR_TRANS_OPEN_FAIL: ::DWORD = 1773; pub const RPC_X_SS_CHAR_TRANS_SHORT_FILE: ::DWORD = 1774; pub const RPC_X_SS_IN_NULL_CONTEXT: ::DWORD = 1775; pub const RPC_X_SS_CONTEXT_DAMAGED: ::DWORD = 1777; pub const RPC_X_SS_HANDLES_MISMATCH: ::DWORD = 1778; pub const RPC_X_SS_CANNOT_GET_CALL_HANDLE: ::DWORD = 1779; pub const RPC_X_NULL_REF_POINTER: ::DWORD = 1780; pub const RPC_X_ENUM_VALUE_OUT_OF_RANGE: ::DWORD = 1781; pub const RPC_X_BYTE_COUNT_TOO_SMALL: ::DWORD = 1782; pub const RPC_X_BAD_STUB_DATA: ::DWORD = 1783; pub const ERROR_INVALID_USER_BUFFER: ::DWORD = 1784; pub const ERROR_UNRECOGNIZED_MEDIA: ::DWORD = 1785; pub const ERROR_NO_TRUST_LSA_SECRET: ::DWORD = 1786; pub const ERROR_NO_TRUST_SAM_ACCOUNT: ::DWORD = 1787; pub const ERROR_TRUSTED_DOMAIN_FAILURE: ::DWORD = 1788; pub const ERROR_TRUSTED_RELATIONSHIP_FAILURE: ::DWORD = 1789; pub const ERROR_TRUST_FAILURE: ::DWORD = 1790; pub const RPC_S_CALL_IN_PROGRESS: ::DWORD = 1791; pub const ERROR_NETLOGON_NOT_STARTED: ::DWORD = 1792; pub const ERROR_ACCOUNT_EXPIRED: ::DWORD = 1793; pub const ERROR_REDIRECTOR_HAS_OPEN_HANDLES: ::DWORD = 1794; pub const ERROR_PRINTER_DRIVER_ALREADY_INSTALLED: ::DWORD = 1795; pub const ERROR_UNKNOWN_PORT: ::DWORD = 1796; pub const ERROR_UNKNOWN_PRINTER_DRIVER: ::DWORD = 1797; pub const ERROR_UNKNOWN_PRINTPROCESSOR: ::DWORD = 1798; pub const ERROR_INVALID_SEPARATOR_FILE: ::DWORD = 1799; pub const ERROR_INVALID_PRIORITY: ::DWORD = 1800; pub const ERROR_INVALID_PRINTER_NAME: ::DWORD = 1801; pub const ERROR_PRINTER_ALREADY_EXISTS: ::DWORD = 1802; pub const ERROR_INVALID_PRINTER_COMMAND: ::DWORD = 1803; pub const ERROR_INVALID_DATATYPE: ::DWORD = 1804; pub const ERROR_INVALID_ENVIRONMENT: ::DWORD = 1805; pub const RPC_S_NO_MORE_BINDINGS: ::DWORD = 1806; pub const ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT: ::DWORD = 1807; pub const ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT: ::DWORD = 1808; pub const ERROR_NOLOGON_SERVER_TRUST_ACCOUNT: ::DWORD = 1809; pub const ERROR_DOMAIN_TRUST_INCONSISTENT: ::DWORD = 1810; pub const ERROR_SERVER_HAS_OPEN_HANDLES: ::DWORD = 1811; pub const ERROR_RESOURCE_DATA_NOT_FOUND: ::DWORD = 1812; pub const ERROR_RESOURCE_TYPE_NOT_FOUND: ::DWORD = 1813; pub const ERROR_RESOURCE_NAME_NOT_FOUND: ::DWORD = 1814; pub const ERROR_RESOURCE_LANG_NOT_FOUND: ::DWORD = 1815; pub const ERROR_NOT_ENOUGH_QUOTA: ::DWORD = 1816; pub const RPC_S_NO_INTERFACES: ::DWORD = 1817; pub const RPC_S_CALL_CANCELLED: ::DWORD = 1818; pub const RPC_S_BINDING_INCOMPLETE: ::DWORD = 1819; pub const RPC_S_COMM_FAILURE: ::DWORD = 1820; pub const RPC_S_UNSUPPORTED_AUTHN_LEVEL: ::DWORD = 1821; pub const RPC_S_NO_PRINC_NAME: ::DWORD = 1822; pub const RPC_S_NOT_RPC_ERROR: ::DWORD = 1823; pub const RPC_S_UUID_LOCAL_ONLY: ::DWORD = 1824; pub const RPC_S_SEC_PKG_ERROR: ::DWORD = 1825; pub const RPC_S_NOT_CANCELLED: ::DWORD = 1826; pub const RPC_X_INVALID_ES_ACTION: ::DWORD = 1827; pub const RPC_X_WRONG_ES_VERSION: ::DWORD = 1828; pub const RPC_X_WRONG_STUB_VERSION: ::DWORD = 1829; pub const RPC_X_INVALID_PIPE_OBJECT: ::DWORD = 1830; pub const RPC_X_WRONG_PIPE_ORDER: ::DWORD = 1831; pub const RPC_X_WRONG_PIPE_VERSION: ::DWORD = 1832; pub const RPC_S_COOKIE_AUTH_FAILED: ::DWORD = 1833; pub const RPC_S_GROUP_MEMBER_NOT_FOUND: ::DWORD = 1898; pub const EPT_S_CANT_CREATE: ::DWORD = 1899; pub const RPC_S_INVALID_OBJECT: ::DWORD = 1900; pub const ERROR_INVALID_TIME: ::DWORD = 1901; pub const ERROR_INVALID_FORM_NAME: ::DWORD = 1902; pub const ERROR_INVALID_FORM_SIZE: ::DWORD = 1903; pub const ERROR_ALREADY_WAITING: ::DWORD = 1904; pub const ERROR_PRINTER_DELETED: ::DWORD = 1905; pub const ERROR_INVALID_PRINTER_STATE: ::DWORD = 1906; pub const ERROR_PASSWORD_MUST_CHANGE: ::DWORD = 1907; pub const ERROR_DOMAIN_CONTROLLER_NOT_FOUND: ::DWORD = 1908; pub const ERROR_ACCOUNT_LOCKED_OUT: ::DWORD = 1909; pub const OR_INVALID_OXID: ::DWORD = 1910; pub const OR_INVALID_OID: ::DWORD = 1911; pub const OR_INVALID_SET: ::DWORD = 1912; pub const RPC_S_SEND_INCOMPLETE: ::DWORD = 1913; pub const RPC_S_INVALID_ASYNC_HANDLE: ::DWORD = 1914; pub const RPC_S_INVALID_ASYNC_CALL: ::DWORD = 1915; pub const RPC_X_PIPE_CLOSED: ::DWORD = 1916; pub const RPC_X_PIPE_DISCIPLINE_ERROR: ::DWORD = 1917; pub const RPC_X_PIPE_EMPTY: ::DWORD = 1918; pub const ERROR_NO_SITENAME: ::DWORD = 1919; pub const ERROR_CANT_ACCESS_FILE: ::DWORD = 1920; pub const ERROR_CANT_RESOLVE_FILENAME: ::DWORD = 1921; pub const RPC_S_ENTRY_TYPE_MISMATCH: ::DWORD = 1922; pub const RPC_S_NOT_ALL_OBJS_EXPORTED: ::DWORD = 1923; pub const RPC_S_INTERFACE_NOT_EXPORTED: ::DWORD = 1924; pub const RPC_S_PROFILE_NOT_ADDED: ::DWORD = 1925; pub const RPC_S_PRF_ELT_NOT_ADDED: ::DWORD = 1926; pub const RPC_S_PRF_ELT_NOT_REMOVED: ::DWORD = 1927; pub const RPC_S_GRP_ELT_NOT_ADDED: ::DWORD = 1928; pub const RPC_S_GRP_ELT_NOT_REMOVED: ::DWORD = 1929; pub const ERROR_KM_DRIVER_BLOCKED: ::DWORD = 1930; pub const ERROR_CONTEXT_EXPIRED: ::DWORD = 1931; pub const ERROR_PER_USER_TRUST_QUOTA_EXCEEDED: ::DWORD = 1932; pub const ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED: ::DWORD = 1933; pub const ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED: ::DWORD = 1934; pub const ERROR_AUTHENTICATION_FIREWALL_FAILED: ::DWORD = 1935; pub const ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED: ::DWORD = 1936; pub const ERROR_NTLM_BLOCKED: ::DWORD = 1937; pub const ERROR_PASSWORD_CHANGE_REQUIRED: ::DWORD = 1938; pub const ERROR_INVALID_PIXEL_FORMAT: ::DWORD = 2000; pub const ERROR_BAD_DRIVER: ::DWORD = 2001; pub const ERROR_INVALID_WINDOW_STYLE: ::DWORD = 2002; pub const ERROR_METAFILE_NOT_SUPPORTED: ::DWORD = 2003; pub const ERROR_TRANSFORM_NOT_SUPPORTED: ::DWORD = 2004; pub const ERROR_CLIPPING_NOT_SUPPORTED: ::DWORD = 2005; pub const ERROR_INVALID_CMM: ::DWORD = 2010; pub const ERROR_INVALID_PROFILE: ::DWORD = 2011; pub const ERROR_TAG_NOT_FOUND: ::DWORD = 2012; pub const ERROR_TAG_NOT_PRESENT: ::DWORD = 2013; pub const ERROR_DUPLICATE_TAG: ::DWORD = 2014; pub const ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE: ::DWORD = 2015; pub const ERROR_PROFILE_NOT_FOUND: ::DWORD = 2016; pub const ERROR_INVALID_COLORSPACE: ::DWORD = 2017; pub const ERROR_ICM_NOT_ENABLED: ::DWORD = 2018; pub const ERROR_DELETING_ICM_XFORM: ::DWORD = 2019; pub const ERROR_INVALID_TRANSFORM: ::DWORD = 2020; pub const ERROR_COLORSPACE_MISMATCH: ::DWORD = 2021; pub const ERROR_INVALID_COLORINDEX: ::DWORD = 2022; pub const ERROR_PROFILE_DOES_NOT_MATCH_DEVICE: ::DWORD = 2023; pub const ERROR_CONNECTED_OTHER_PASSWORD: ::DWORD = 2108; pub const ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT: ::DWORD = 2109; pub const ERROR_BAD_USERNAME: ::DWORD = 2202; pub const ERROR_NOT_CONNECTED: ::DWORD = 2250; pub const ERROR_OPEN_FILES: ::DWORD = 2401; pub const ERROR_ACTIVE_CONNECTIONS: ::DWORD = 2402; pub const ERROR_DEVICE_IN_USE: ::DWORD = 2404; pub const ERROR_UNKNOWN_PRINT_MONITOR: ::DWORD = 3000; pub const ERROR_PRINTER_DRIVER_IN_USE: ::DWORD = 3001; pub const ERROR_SPOOL_FILE_NOT_FOUND: ::DWORD = 3002; pub const ERROR_SPL_NO_STARTDOC: ::DWORD = 3003; pub const ERROR_SPL_NO_ADDJOB: ::DWORD = 3004; pub const ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED: ::DWORD = 3005; pub const ERROR_PRINT_MONITOR_ALREADY_INSTALLED: ::DWORD = 3006; pub const ERROR_INVALID_PRINT_MONITOR: ::DWORD = 3007; pub const ERROR_PRINT_MONITOR_IN_USE: ::DWORD = 3008; pub const ERROR_PRINTER_HAS_JOBS_QUEUED: ::DWORD = 3009; pub const ERROR_SUCCESS_REBOOT_REQUIRED: ::DWORD = 3010; pub const ERROR_SUCCESS_RESTART_REQUIRED: ::DWORD = 3011; pub const ERROR_PRINTER_NOT_FOUND: ::DWORD = 3012; pub const ERROR_PRINTER_DRIVER_WARNED: ::DWORD = 3013; pub const ERROR_PRINTER_DRIVER_BLOCKED: ::DWORD = 3014; pub const ERROR_PRINTER_DRIVER_PACKAGE_IN_USE: ::DWORD = 3015; pub const ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND: ::DWORD = 3016; pub const ERROR_FAIL_REBOOT_REQUIRED: ::DWORD = 3017; pub const ERROR_FAIL_REBOOT_INITIATED: ::DWORD = 3018; pub const ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED: ::DWORD = 3019; pub const ERROR_PRINT_JOB_RESTART_REQUIRED: ::DWORD = 3020; pub const ERROR_INVALID_PRINTER_DRIVER_MANIFEST: ::DWORD = 3021; pub const ERROR_PRINTER_NOT_SHAREABLE: ::DWORD = 3022; pub const ERROR_REQUEST_PAUSED: ::DWORD = 3050; pub const ERROR_IO_REISSUE_AS_CACHED: ::DWORD = 3950; pub const ERROR_WINS_INTERNAL: ::DWORD = 4000; pub const ERROR_CAN_NOT_DEL_LOCAL_WINS: ::DWORD = 4001; pub const ERROR_STATIC_INIT: ::DWORD = 4002; pub const ERROR_INC_BACKUP: ::DWORD = 4003; pub const ERROR_FULL_BACKUP: ::DWORD = 4004; pub const ERROR_REC_NON_EXISTENT: ::DWORD = 4005; pub const ERROR_RPL_NOT_ALLOWED: ::DWORD = 4006; pub const PEERDIST_ERROR_CONTENTINFO_VERSION_UNSUPPORTED: ::DWORD = 4050; pub const PEERDIST_ERROR_CANNOT_PARSE_CONTENTINFO: ::DWORD = 4051; pub const PEERDIST_ERROR_MISSING_DATA: ::DWORD = 4052; pub const PEERDIST_ERROR_NO_MORE: ::DWORD = 4053; pub const PEERDIST_ERROR_NOT_INITIALIZED: ::DWORD = 4054; pub const PEERDIST_ERROR_ALREADY_INITIALIZED: ::DWORD = 4055; pub const PEERDIST_ERROR_SHUTDOWN_IN_PROGRESS: ::DWORD = 4056; pub const PEERDIST_ERROR_INVALIDATED: ::DWORD = 4057; pub const PEERDIST_ERROR_ALREADY_EXISTS: ::DWORD = 4058; pub const PEERDIST_ERROR_OPERATION_NOTFOUND: ::DWORD = 4059; pub const PEERDIST_ERROR_ALREADY_COMPLETED: ::DWORD = 4060; pub const PEERDIST_ERROR_OUT_OF_BOUNDS: ::DWORD = 4061; pub const PEERDIST_ERROR_VERSION_UNSUPPORTED: ::DWORD = 4062; pub const PEERDIST_ERROR_INVALID_CONFIGURATION: ::DWORD = 4063; pub const PEERDIST_ERROR_NOT_LICENSED: ::DWORD = 4064; pub const PEERDIST_ERROR_SERVICE_UNAVAILABLE: ::DWORD = 4065; pub const PEERDIST_ERROR_TRUST_FAILURE: ::DWORD = 4066; pub const ERROR_DHCP_ADDRESS_CONFLICT: ::DWORD = 4100; pub const ERROR_WMI_GUID_NOT_FOUND: ::DWORD = 4200; pub const ERROR_WMI_INSTANCE_NOT_FOUND: ::DWORD = 4201; pub const ERROR_WMI_ITEMID_NOT_FOUND: ::DWORD = 4202; pub const ERROR_WMI_TRY_AGAIN: ::DWORD = 4203; pub const ERROR_WMI_DP_NOT_FOUND: ::DWORD = 4204; pub const ERROR_WMI_UNRESOLVED_INSTANCE_REF: ::DWORD = 4205; pub const ERROR_WMI_ALREADY_ENABLED: ::DWORD = 4206; pub const ERROR_WMI_GUID_DISCONNECTED: ::DWORD = 4207; pub const ERROR_WMI_SERVER_UNAVAILABLE: ::DWORD = 4208; pub const ERROR_WMI_DP_FAILED: ::DWORD = 4209; pub const ERROR_WMI_INVALID_MOF: ::DWORD = 4210; pub const ERROR_WMI_INVALID_REGINFO: ::DWORD = 4211; pub const ERROR_WMI_ALREADY_DISABLED: ::DWORD = 4212; pub const ERROR_WMI_READ_ONLY: ::DWORD = 4213; pub const ERROR_WMI_SET_FAILURE: ::DWORD = 4214; pub const ERROR_NOT_APPCONTAINER: ::DWORD = 4250; pub const ERROR_APPCONTAINER_REQUIRED: ::DWORD = 4251; pub const ERROR_NOT_SUPPORTED_IN_APPCONTAINER: ::DWORD = 4252; pub const ERROR_INVALID_PACKAGE_SID_LENGTH: ::DWORD = 4253; pub const ERROR_INVALID_MEDIA: ::DWORD = 4300; pub const ERROR_INVALID_LIBRARY: ::DWORD = 4301; pub const ERROR_INVALID_MEDIA_POOL: ::DWORD = 4302; pub const ERROR_DRIVE_MEDIA_MISMATCH: ::DWORD = 4303; pub const ERROR_MEDIA_OFFLINE: ::DWORD = 4304; pub const ERROR_LIBRARY_OFFLINE: ::DWORD = 4305; pub const ERROR_EMPTY: ::DWORD = 4306; pub const ERROR_NOT_EMPTY: ::DWORD = 4307; pub const ERROR_MEDIA_UNAVAILABLE: ::DWORD = 4308; pub const ERROR_RESOURCE_DISABLED: ::DWORD = 4309; pub const ERROR_INVALID_CLEANER: ::DWORD = 4310; pub const ERROR_UNABLE_TO_CLEAN: ::DWORD = 4311; pub const ERROR_OBJECT_NOT_FOUND: ::DWORD = 4312; pub const ERROR_DATABASE_FAILURE: ::DWORD = 4313; pub const ERROR_DATABASE_FULL: ::DWORD = 4314; pub const ERROR_MEDIA_INCOMPATIBLE: ::DWORD = 4315; pub const ERROR_RESOURCE_NOT_PRESENT: ::DWORD = 4316; pub const ERROR_INVALID_OPERATION: ::DWORD = 4317; pub const ERROR_MEDIA_NOT_AVAILABLE: ::DWORD = 4318; pub const ERROR_DEVICE_NOT_AVAILABLE: ::DWORD = 4319; pub const ERROR_REQUEST_REFUSED: ::DWORD = 4320; pub const ERROR_INVALID_DRIVE_OBJECT: ::DWORD = 4321; pub const ERROR_LIBRARY_FULL: ::DWORD = 4322; pub const ERROR_MEDIUM_NOT_ACCESSIBLE: ::DWORD = 4323; pub const ERROR_UNABLE_TO_LOAD_MEDIUM: ::DWORD = 4324; pub const ERROR_UNABLE_TO_INVENTORY_DRIVE: ::DWORD = 4325; pub const ERROR_UNABLE_TO_INVENTORY_SLOT: ::DWORD = 4326; pub const ERROR_UNABLE_TO_INVENTORY_TRANSPORT: ::DWORD = 4327; pub const ERROR_TRANSPORT_FULL: ::DWORD = 4328; pub const ERROR_CONTROLLING_IEPORT: ::DWORD = 4329; pub const ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA: ::DWORD = 4330; pub const ERROR_CLEANER_SLOT_SET: ::DWORD = 4331; pub const ERROR_CLEANER_SLOT_NOT_SET: ::DWORD = 4332; pub const ERROR_CLEANER_CARTRIDGE_SPENT: ::DWORD = 4333; pub const ERROR_UNEXPECTED_OMID: ::DWORD = 4334; pub const ERROR_CANT_DELETE_LAST_ITEM: ::DWORD = 4335; pub const ERROR_MESSAGE_EXCEEDS_MAX_SIZE: ::DWORD = 4336; pub const ERROR_VOLUME_CONTAINS_SYS_FILES: ::DWORD = 4337; pub const ERROR_INDIGENOUS_TYPE: ::DWORD = 4338; pub const ERROR_NO_SUPPORTING_DRIVES: ::DWORD = 4339; pub const ERROR_CLEANER_CARTRIDGE_INSTALLED: ::DWORD = 4340; pub const ERROR_IEPORT_FULL: ::DWORD = 4341; pub const ERROR_FILE_OFFLINE: ::DWORD = 4350; pub const ERROR_REMOTE_STORAGE_NOT_ACTIVE: ::DWORD = 4351; pub const ERROR_REMOTE_STORAGE_MEDIA_ERROR: ::DWORD = 4352; pub const ERROR_NOT_A_REPARSE_POINT: ::DWORD = 4390; pub const ERROR_REPARSE_ATTRIBUTE_CONFLICT: ::DWORD = 4391; pub const ERROR_INVALID_REPARSE_DATA: ::DWORD = 4392; pub const ERROR_REPARSE_TAG_INVALID: ::DWORD = 4393; pub const ERROR_REPARSE_TAG_MISMATCH: ::DWORD = 4394; pub const ERROR_APP_DATA_NOT_FOUND: ::DWORD = 4400; pub const ERROR_APP_DATA_EXPIRED: ::DWORD = 4401; pub const ERROR_APP_DATA_CORRUPT: ::DWORD = 4402; pub const ERROR_APP_DATA_LIMIT_EXCEEDED: ::DWORD = 4403; pub const ERROR_APP_DATA_REBOOT_REQUIRED: ::DWORD = 4404; pub const ERROR_SECUREBOOT_ROLLBACK_DETECTED: ::DWORD = 4420; pub const ERROR_SECUREBOOT_POLICY_VIOLATION: ::DWORD = 4421; pub const ERROR_SECUREBOOT_INVALID_POLICY: ::DWORD = 4422; pub const ERROR_SECUREBOOT_POLICY_PUBLISHER_NOT_FOUND: ::DWORD = 4423; pub const ERROR_SECUREBOOT_POLICY_NOT_SIGNED: ::DWORD = 4424; pub const ERROR_SECUREBOOT_NOT_ENABLED: ::DWORD = 4425; pub const ERROR_SECUREBOOT_FILE_REPLACED: ::DWORD = 4426; pub const ERROR_OFFLOAD_READ_FLT_NOT_SUPPORTED: ::DWORD = 4440; pub const ERROR_OFFLOAD_WRITE_FLT_NOT_SUPPORTED: ::DWORD = 4441; pub const ERROR_OFFLOAD_READ_FILE_NOT_SUPPORTED: ::DWORD = 4442; pub const ERROR_OFFLOAD_WRITE_FILE_NOT_SUPPORTED: ::DWORD = 4443; pub const ERROR_VOLUME_NOT_SIS_ENABLED: ::DWORD = 4500; pub const ERROR_DEPENDENT_RESOURCE_EXISTS: ::DWORD = 5001; pub const ERROR_DEPENDENCY_NOT_FOUND: ::DWORD = 5002; pub const ERROR_DEPENDENCY_ALREADY_EXISTS: ::DWORD = 5003; pub const ERROR_RESOURCE_NOT_ONLINE: ::DWORD = 5004; pub const ERROR_HOST_NODE_NOT_AVAILABLE: ::DWORD = 5005; pub const ERROR_RESOURCE_NOT_AVAILABLE: ::DWORD = 5006; pub const ERROR_RESOURCE_NOT_FOUND: ::DWORD = 5007; pub const ERROR_SHUTDOWN_CLUSTER: ::DWORD = 5008; pub const ERROR_CANT_EVICT_ACTIVE_NODE: ::DWORD = 5009; pub const ERROR_OBJECT_ALREADY_EXISTS: ::DWORD = 5010; pub const ERROR_OBJECT_IN_LIST: ::DWORD = 5011; pub const ERROR_GROUP_NOT_AVAILABLE: ::DWORD = 5012; pub const ERROR_GROUP_NOT_FOUND: ::DWORD = 5013; pub const ERROR_GROUP_NOT_ONLINE: ::DWORD = 5014; pub const ERROR_HOST_NODE_NOT_RESOURCE_OWNER: ::DWORD = 5015; pub const ERROR_HOST_NODE_NOT_GROUP_OWNER: ::DWORD = 5016; pub const ERROR_RESMON_CREATE_FAILED: ::DWORD = 5017; pub const ERROR_RESMON_ONLINE_FAILED: ::DWORD = 5018; pub const ERROR_RESOURCE_ONLINE: ::DWORD = 5019; pub const ERROR_QUORUM_RESOURCE: ::DWORD = 5020; pub const ERROR_NOT_QUORUM_CAPABLE: ::DWORD = 5021; pub const ERROR_CLUSTER_SHUTTING_DOWN: ::DWORD = 5022; pub const ERROR_INVALID_STATE: ::DWORD = 5023; pub const ERROR_RESOURCE_PROPERTIES_STORED: ::DWORD = 5024; pub const ERROR_NOT_QUORUM_CLASS: ::DWORD = 5025; pub const ERROR_CORE_RESOURCE: ::DWORD = 5026; pub const ERROR_QUORUM_RESOURCE_ONLINE_FAILED: ::DWORD = 5027; pub const ERROR_QUORUMLOG_OPEN_FAILED: ::DWORD = 5028; pub const ERROR_CLUSTERLOG_CORRUPT: ::DWORD = 5029; pub const ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE: ::DWORD = 5030; pub const ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE: ::DWORD = 5031; pub const ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND: ::DWORD = 5032; pub const ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE: ::DWORD = 5033; pub const ERROR_QUORUM_OWNER_ALIVE: ::DWORD = 5034; pub const ERROR_NETWORK_NOT_AVAILABLE: ::DWORD = 5035; pub const ERROR_NODE_NOT_AVAILABLE: ::DWORD = 5036; pub const ERROR_ALL_NODES_NOT_AVAILABLE: ::DWORD = 5037; pub const ERROR_RESOURCE_FAILED: ::DWORD = 5038; pub const ERROR_CLUSTER_INVALID_NODE: ::DWORD = 5039; pub const ERROR_CLUSTER_NODE_EXISTS: ::DWORD = 5040; pub const ERROR_CLUSTER_JOIN_IN_PROGRESS: ::DWORD = 5041; pub const ERROR_CLUSTER_NODE_NOT_FOUND: ::DWORD = 5042; pub const ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND: ::DWORD = 5043; pub const ERROR_CLUSTER_NETWORK_EXISTS: ::DWORD = 5044; pub const ERROR_CLUSTER_NETWORK_NOT_FOUND: ::DWORD = 5045; pub const ERROR_CLUSTER_NETINTERFACE_EXISTS: ::DWORD = 5046; pub const ERROR_CLUSTER_NETINTERFACE_NOT_FOUND: ::DWORD = 5047; pub const ERROR_CLUSTER_INVALID_REQUEST: ::DWORD = 5048; pub const ERROR_CLUSTER_INVALID_NETWORK_PROVIDER: ::DWORD = 5049; pub const ERROR_CLUSTER_NODE_DOWN: ::DWORD = 5050; pub const ERROR_CLUSTER_NODE_UNREACHABLE: ::DWORD = 5051; pub const ERROR_CLUSTER_NODE_NOT_MEMBER: ::DWORD = 5052; pub const ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS: ::DWORD = 5053; pub const ERROR_CLUSTER_INVALID_NETWORK: ::DWORD = 5054; pub const ERROR_CLUSTER_NODE_UP: ::DWORD = 5056; pub const ERROR_CLUSTER_IPADDR_IN_USE: ::DWORD = 5057; pub const ERROR_CLUSTER_NODE_NOT_PAUSED: ::DWORD = 5058; pub const ERROR_CLUSTER_NO_SECURITY_CONTEXT: ::DWORD = 5059; pub const ERROR_CLUSTER_NETWORK_NOT_INTERNAL: ::DWORD = 5060; pub const ERROR_CLUSTER_NODE_ALREADY_UP: ::DWORD = 5061; pub const ERROR_CLUSTER_NODE_ALREADY_DOWN: ::DWORD = 5062; pub const ERROR_CLUSTER_NETWORK_ALREADY_ONLINE: ::DWORD = 5063; pub const ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE: ::DWORD = 5064; pub const ERROR_CLUSTER_NODE_ALREADY_MEMBER: ::DWORD = 5065; pub const ERROR_CLUSTER_LAST_INTERNAL_NETWORK: ::DWORD = 5066; pub const ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS: ::DWORD = 5067; pub const ERROR_INVALID_OPERATION_ON_QUORUM: ::DWORD = 5068; pub const ERROR_DEPENDENCY_NOT_ALLOWED: ::DWORD = 5069; pub const ERROR_CLUSTER_NODE_PAUSED: ::DWORD = 5070; pub const ERROR_NODE_CANT_HOST_RESOURCE: ::DWORD = 5071; pub const ERROR_CLUSTER_NODE_NOT_READY: ::DWORD = 5072; pub const ERROR_CLUSTER_NODE_SHUTTING_DOWN: ::DWORD = 5073; pub const ERROR_CLUSTER_JOIN_ABORTED: ::DWORD = 5074; pub const ERROR_CLUSTER_INCOMPATIBLE_VERSIONS: ::DWORD = 5075; pub const ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED: ::DWORD = 5076; pub const ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED: ::DWORD = 5077; pub const ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND: ::DWORD = 5078; pub const ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED: ::DWORD = 5079; pub const ERROR_CLUSTER_RESNAME_NOT_FOUND: ::DWORD = 5080; pub const ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED: ::DWORD = 5081; pub const ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST: ::DWORD = 5082; pub const ERROR_CLUSTER_DATABASE_SEQMISMATCH: ::DWORD = 5083; pub const ERROR_RESMON_INVALID_STATE: ::DWORD = 5084; pub const ERROR_CLUSTER_GUM_NOT_LOCKER: ::DWORD = 5085; pub const ERROR_QUORUM_DISK_NOT_FOUND: ::DWORD = 5086; pub const ERROR_DATABASE_BACKUP_CORRUPT: ::DWORD = 5087; pub const ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT: ::DWORD = 5088; pub const ERROR_RESOURCE_PROPERTY_UNCHANGEABLE: ::DWORD = 5089; pub const ERROR_NO_ADMIN_ACCESS_POINT: ::DWORD = 5090; pub const ERROR_CLUSTER_MEMBERSHIP_INVALID_STATE: ::DWORD = 5890; pub const ERROR_CLUSTER_QUORUMLOG_NOT_FOUND: ::DWORD = 5891; pub const ERROR_CLUSTER_MEMBERSHIP_HALT: ::DWORD = 5892; pub const ERROR_CLUSTER_INSTANCE_ID_MISMATCH: ::DWORD = 5893; pub const ERROR_CLUSTER_NETWORK_NOT_FOUND_FOR_IP: ::DWORD = 5894; pub const ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH: ::DWORD = 5895; pub const ERROR_CLUSTER_EVICT_WITHOUT_CLEANUP: ::DWORD = 5896; pub const ERROR_CLUSTER_PARAMETER_MISMATCH: ::DWORD = 5897; pub const ERROR_NODE_CANNOT_BE_CLUSTERED: ::DWORD = 5898; pub const ERROR_CLUSTER_WRONG_OS_VERSION: ::DWORD = 5899; pub const ERROR_CLUSTER_CANT_CREATE_DUP_CLUSTER_NAME: ::DWORD = 5900; pub const ERROR_CLUSCFG_ALREADY_COMMITTED: ::DWORD = 5901; pub const ERROR_CLUSCFG_ROLLBACK_FAILED: ::DWORD = 5902; pub const ERROR_CLUSCFG_SYSTEM_DISK_DRIVE_LETTER_CONFLICT: ::DWORD = 5903; pub const ERROR_CLUSTER_OLD_VERSION: ::DWORD = 5904; pub const ERROR_CLUSTER_MISMATCHED_COMPUTER_ACCT_NAME: ::DWORD = 5905; pub const ERROR_CLUSTER_NO_NET_ADAPTERS: ::DWORD = 5906; pub const ERROR_CLUSTER_POISONED: ::DWORD = 5907; pub const ERROR_CLUSTER_GROUP_MOVING: ::DWORD = 5908; pub const ERROR_CLUSTER_RESOURCE_TYPE_BUSY: ::DWORD = 5909; pub const ERROR_RESOURCE_CALL_TIMED_OUT: ::DWORD = 5910; pub const ERROR_INVALID_CLUSTER_IPV6_ADDRESS: ::DWORD = 5911; pub const ERROR_CLUSTER_INTERNAL_INVALID_FUNCTION: ::DWORD = 5912; pub const ERROR_CLUSTER_PARAMETER_OUT_OF_BOUNDS: ::DWORD = 5913; pub const ERROR_CLUSTER_PARTIAL_SEND: ::DWORD = 5914; pub const ERROR_CLUSTER_REGISTRY_INVALID_FUNCTION: ::DWORD = 5915; pub const ERROR_CLUSTER_INVALID_STRING_TERMINATION: ::DWORD = 5916; pub const ERROR_CLUSTER_INVALID_STRING_FORMAT: ::DWORD = 5917; pub const ERROR_CLUSTER_DATABASE_TRANSACTION_IN_PROGRESS: ::DWORD = 5918; pub const ERROR_CLUSTER_DATABASE_TRANSACTION_NOT_IN_PROGRESS: ::DWORD = 5919; pub const ERROR_CLUSTER_NULL_DATA: ::DWORD = 5920; pub const ERROR_CLUSTER_PARTIAL_READ: ::DWORD = 5921; pub const ERROR_CLUSTER_PARTIAL_WRITE: ::DWORD = 5922; pub const ERROR_CLUSTER_CANT_DESERIALIZE_DATA: ::DWORD = 5923; pub const ERROR_DEPENDENT_RESOURCE_PROPERTY_CONFLICT: ::DWORD = 5924; pub const ERROR_CLUSTER_NO_QUORUM: ::DWORD = 5925; pub const ERROR_CLUSTER_INVALID_IPV6_NETWORK: ::DWORD = 5926; pub const ERROR_CLUSTER_INVALID_IPV6_TUNNEL_NETWORK: ::DWORD = 5927; pub const ERROR_QUORUM_NOT_ALLOWED_IN_THIS_GROUP: ::DWORD = 5928; pub const ERROR_DEPENDENCY_TREE_TOO_COMPLEX: ::DWORD = 5929; pub const ERROR_EXCEPTION_IN_RESOURCE_CALL: ::DWORD = 5930; pub const ERROR_CLUSTER_RHS_FAILED_INITIALIZATION: ::DWORD = 5931; pub const ERROR_CLUSTER_NOT_INSTALLED: ::DWORD = 5932; pub const ERROR_CLUSTER_RESOURCES_MUST_BE_ONLINE_ON_THE_SAME_NODE: ::DWORD = 5933; pub const ERROR_CLUSTER_MAX_NODES_IN_CLUSTER: ::DWORD = 5934; pub const ERROR_CLUSTER_TOO_MANY_NODES: ::DWORD = 5935; pub const ERROR_CLUSTER_OBJECT_ALREADY_USED: ::DWORD = 5936; pub const ERROR_NONCORE_GROUPS_FOUND: ::DWORD = 5937; pub const ERROR_FILE_SHARE_RESOURCE_CONFLICT: ::DWORD = 5938; pub const ERROR_CLUSTER_EVICT_INVALID_REQUEST: ::DWORD = 5939; pub const ERROR_CLUSTER_SINGLETON_RESOURCE: ::DWORD = 5940; pub const ERROR_CLUSTER_GROUP_SINGLETON_RESOURCE: ::DWORD = 5941; pub const ERROR_CLUSTER_RESOURCE_PROVIDER_FAILED: ::DWORD = 5942; pub const ERROR_CLUSTER_RESOURCE_CONFIGURATION_ERROR: ::DWORD = 5943; pub const ERROR_CLUSTER_GROUP_BUSY: ::DWORD = 5944; pub const ERROR_CLUSTER_NOT_SHARED_VOLUME: ::DWORD = 5945; pub const ERROR_CLUSTER_INVALID_SECURITY_DESCRIPTOR: ::DWORD = 5946; pub const ERROR_CLUSTER_SHARED_VOLUMES_IN_USE: ::DWORD = 5947; pub const ERROR_CLUSTER_USE_SHARED_VOLUMES_API: ::DWORD = 5948; pub const ERROR_CLUSTER_BACKUP_IN_PROGRESS: ::DWORD = 5949; pub const ERROR_NON_CSV_PATH: ::DWORD = 5950; pub const ERROR_CSV_VOLUME_NOT_LOCAL: ::DWORD = 5951; pub const ERROR_CLUSTER_WATCHDOG_TERMINATING: ::DWORD = 5952; pub const ERROR_CLUSTER_RESOURCE_VETOED_MOVE_INCOMPATIBLE_NODES: ::DWORD = 5953; pub const ERROR_CLUSTER_INVALID_NODE_WEIGHT: ::DWORD = 5954; pub const ERROR_CLUSTER_RESOURCE_VETOED_CALL: ::DWORD = 5955; pub const ERROR_RESMON_SYSTEM_RESOURCES_LACKING: ::DWORD = 5956; pub const ERROR_CLUSTER_RESOURCE_VETOED_MOVE_NOT_ENOUGH_RESOURCES_ON_DESTINATION: ::DWORD = 5957; pub const ERROR_CLUSTER_RESOURCE_VETOED_MOVE_NOT_ENOUGH_RESOURCES_ON_SOURCE: ::DWORD = 5958; pub const ERROR_CLUSTER_GROUP_QUEUED: ::DWORD = 5959; pub const ERROR_CLUSTER_RESOURCE_LOCKED_STATUS: ::DWORD = 5960; pub const ERROR_CLUSTER_SHARED_VOLUME_FAILOVER_NOT_ALLOWED: ::DWORD = 5961; pub const ERROR_CLUSTER_NODE_DRAIN_IN_PROGRESS: ::DWORD = 5962; pub const ERROR_CLUSTER_DISK_NOT_CONNECTED: ::DWORD = 5963; pub const ERROR_DISK_NOT_CSV_CAPABLE: ::DWORD = 5964; pub const ERROR_RESOURCE_NOT_IN_AVAILABLE_STORAGE: ::DWORD = 5965; pub const ERROR_CLUSTER_SHARED_VOLUME_REDIRECTED: ::DWORD = 5966; pub const ERROR_CLUSTER_SHARED_VOLUME_NOT_REDIRECTED: ::DWORD = 5967; pub const ERROR_CLUSTER_CANNOT_RETURN_PROPERTIES: ::DWORD = 5968; pub const ERROR_CLUSTER_RESOURCE_CONTAINS_UNSUPPORTED_DIFF_AREA_FOR_SHARED_VOLUMES: ::DWORD = 5969; pub const ERROR_CLUSTER_RESOURCE_IS_IN_MAINTENANCE_MODE: ::DWORD = 5970; pub const ERROR_CLUSTER_AFFINITY_CONFLICT: ::DWORD = 5971; pub const ERROR_CLUSTER_RESOURCE_IS_REPLICA_VIRTUAL_MACHINE: ::DWORD = 5972; pub const ERROR_ENCRYPTION_FAILED: ::DWORD = 6000; pub const ERROR_DECRYPTION_FAILED: ::DWORD = 6001; pub const ERROR_FILE_ENCRYPTED: ::DWORD = 6002; pub const ERROR_NO_RECOVERY_POLICY: ::DWORD = 6003; pub const ERROR_NO_EFS: ::DWORD = 6004; pub const ERROR_WRONG_EFS: ::DWORD = 6005; pub const ERROR_NO_USER_KEYS: ::DWORD = 6006; pub const ERROR_FILE_NOT_ENCRYPTED: ::DWORD = 6007; pub const ERROR_NOT_EXPORT_FORMAT: ::DWORD = 6008; pub const ERROR_FILE_READ_ONLY: ::DWORD = 6009; pub const ERROR_DIR_EFS_DISALLOWED: ::DWORD = 6010; pub const ERROR_EFS_SERVER_NOT_TRUSTED: ::DWORD = 6011; pub const ERROR_BAD_RECOVERY_POLICY: ::DWORD = 6012; pub const ERROR_EFS_ALG_BLOB_TOO_BIG: ::DWORD = 6013; pub const ERROR_VOLUME_NOT_SUPPORT_EFS: ::DWORD = 6014; pub const ERROR_EFS_DISABLED: ::DWORD = 6015; pub const ERROR_EFS_VERSION_NOT_SUPPORT: ::DWORD = 6016; pub const ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE: ::DWORD = 6017; pub const ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER: ::DWORD = 6018; pub const ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE: ::DWORD = 6019; pub const ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE: ::DWORD = 6020; pub const ERROR_CS_ENCRYPTION_FILE_NOT_CSE: ::DWORD = 6021; pub const ERROR_ENCRYPTION_POLICY_DENIES_OPERATION: ::DWORD = 6022; pub const ERROR_NO_BROWSER_SERVERS_FOUND: ::DWORD = 6118; pub const SCHED_E_SERVICE_NOT_LOCALSYSTEM: ::DWORD = 6200; pub const ERROR_LOG_SECTOR_INVALID: ::DWORD = 6600; pub const ERROR_LOG_SECTOR_PARITY_INVALID: ::DWORD = 6601; pub const ERROR_LOG_SECTOR_REMAPPED: ::DWORD = 6602; pub const ERROR_LOG_BLOCK_INCOMPLETE: ::DWORD = 6603; pub const ERROR_LOG_INVALID_RANGE: ::DWORD = 6604; pub const ERROR_LOG_BLOCKS_EXHAUSTED: ::DWORD = 6605; pub const ERROR_LOG_READ_CONTEXT_INVALID: ::DWORD = 6606; pub const ERROR_LOG_RESTART_INVALID: ::DWORD = 6607; pub const ERROR_LOG_BLOCK_VERSION: ::DWORD = 6608; pub const ERROR_LOG_BLOCK_INVALID: ::DWORD = 6609; pub const ERROR_LOG_READ_MODE_INVALID: ::DWORD = 6610; pub const ERROR_LOG_NO_RESTART: ::DWORD = 6611; pub const ERROR_LOG_METADATA_CORRUPT: ::DWORD = 6612; pub const ERROR_LOG_METADATA_INVALID: ::DWORD = 6613; pub const ERROR_LOG_METADATA_INCONSISTENT: ::DWORD = 6614; pub const ERROR_LOG_RESERVATION_INVALID: ::DWORD = 6615; pub const ERROR_LOG_CANT_DELETE: ::DWORD = 6616; pub const ERROR_LOG_CONTAINER_LIMIT_EXCEEDED: ::DWORD = 6617; pub const ERROR_LOG_START_OF_LOG: ::DWORD = 6618; pub const ERROR_LOG_POLICY_ALREADY_INSTALLED: ::DWORD = 6619; pub const ERROR_LOG_POLICY_NOT_INSTALLED: ::DWORD = 6620; pub const ERROR_LOG_POLICY_INVALID: ::DWORD = 6621; pub const ERROR_LOG_POLICY_CONFLICT: ::DWORD = 6622; pub const ERROR_LOG_PINNED_ARCHIVE_TAIL: ::DWORD = 6623; pub const ERROR_LOG_RECORD_NONEXISTENT: ::DWORD = 6624; pub const ERROR_LOG_RECORDS_RESERVED_INVALID: ::DWORD = 6625; pub const ERROR_LOG_SPACE_RESERVED_INVALID: ::DWORD = 6626; pub const ERROR_LOG_TAIL_INVALID: ::DWORD = 6627; pub const ERROR_LOG_FULL: ::DWORD = 6628; pub const ERROR_COULD_NOT_RESIZE_LOG: ::DWORD = 6629; pub const ERROR_LOG_MULTIPLEXED: ::DWORD = 6630; pub const ERROR_LOG_DEDICATED: ::DWORD = 6631; pub const ERROR_LOG_ARCHIVE_NOT_IN_PROGRESS: ::DWORD = 6632; pub const ERROR_LOG_ARCHIVE_IN_PROGRESS: ::DWORD = 6633; pub const ERROR_LOG_EPHEMERAL: ::DWORD = 6634; pub const ERROR_LOG_NOT_ENOUGH_CONTAINERS: ::DWORD = 6635; pub const ERROR_LOG_CLIENT_ALREADY_REGISTERED: ::DWORD = 6636; pub const ERROR_LOG_CLIENT_NOT_REGISTERED: ::DWORD = 6637; pub const ERROR_LOG_FULL_HANDLER_IN_PROGRESS: ::DWORD = 6638; pub const ERROR_LOG_CONTAINER_READ_FAILED: ::DWORD = 6639; pub const ERROR_LOG_CONTAINER_WRITE_FAILED: ::DWORD = 6640; pub const ERROR_LOG_CONTAINER_OPEN_FAILED: ::DWORD = 6641; pub const ERROR_LOG_CONTAINER_STATE_INVALID: ::DWORD = 6642; pub const ERROR_LOG_STATE_INVALID: ::DWORD = 6643; pub const ERROR_LOG_PINNED: ::DWORD = 6644; pub const ERROR_LOG_METADATA_FLUSH_FAILED: ::DWORD = 6645; pub const ERROR_LOG_INCONSISTENT_SECURITY: ::DWORD = 6646; pub const ERROR_LOG_APPENDED_FLUSH_FAILED: ::DWORD = 6647; pub const ERROR_LOG_PINNED_RESERVATION: ::DWORD = 6648; pub const ERROR_INVALID_TRANSACTION: ::DWORD = 6700; pub const ERROR_TRANSACTION_NOT_ACTIVE: ::DWORD = 6701; pub const ERROR_TRANSACTION_REQUEST_NOT_VALID: ::DWORD = 6702; pub const ERROR_TRANSACTION_NOT_REQUESTED: ::DWORD = 6703; pub const ERROR_TRANSACTION_ALREADY_ABORTED: ::DWORD = 6704; pub const ERROR_TRANSACTION_ALREADY_COMMITTED: ::DWORD = 6705; pub const ERROR_TM_INITIALIZATION_FAILED: ::DWORD = 6706; pub const ERROR_RESOURCEMANAGER_READ_ONLY: ::DWORD = 6707; pub const ERROR_TRANSACTION_NOT_JOINED: ::DWORD = 6708; pub const ERROR_TRANSACTION_SUPERIOR_EXISTS: ::DWORD = 6709; pub const ERROR_CRM_PROTOCOL_ALREADY_EXISTS: ::DWORD = 6710; pub const ERROR_TRANSACTION_PROPAGATION_FAILED: ::DWORD = 6711; pub const ERROR_CRM_PROTOCOL_NOT_FOUND: ::DWORD = 6712; pub const ERROR_TRANSACTION_INVALID_MARSHALL_BUFFER: ::DWORD = 6713; pub const ERROR_CURRENT_TRANSACTION_NOT_VALID: ::DWORD = 6714; pub const ERROR_TRANSACTION_NOT_FOUND: ::DWORD = 6715; pub const ERROR_RESOURCEMANAGER_NOT_FOUND: ::DWORD = 6716; pub const ERROR_ENLISTMENT_NOT_FOUND: ::DWORD = 6717; pub const ERROR_TRANSACTIONMANAGER_NOT_FOUND: ::DWORD = 6718; pub const ERROR_TRANSACTIONMANAGER_NOT_ONLINE: ::DWORD = 6719; pub const ERROR_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION: ::DWORD = 6720; pub const ERROR_TRANSACTION_NOT_ROOT: ::DWORD = 6721; pub const ERROR_TRANSACTION_OBJECT_EXPIRED: ::DWORD = 6722; pub const ERROR_TRANSACTION_RESPONSE_NOT_ENLISTED: ::DWORD = 6723; pub const ERROR_TRANSACTION_RECORD_TOO_LONG: ::DWORD = 6724; pub const ERROR_IMPLICIT_TRANSACTION_NOT_SUPPORTED: ::DWORD = 6725; pub const ERROR_TRANSACTION_INTEGRITY_VIOLATED: ::DWORD = 6726; pub const ERROR_TRANSACTIONMANAGER_IDENTITY_MISMATCH: ::DWORD = 6727; pub const ERROR_RM_CANNOT_BE_FROZEN_FOR_SNAPSHOT: ::DWORD = 6728; pub const ERROR_TRANSACTION_MUST_WRITETHROUGH: ::DWORD = 6729; pub const ERROR_TRANSACTION_NO_SUPERIOR: ::DWORD = 6730; pub const ERROR_HEURISTIC_DAMAGE_POSSIBLE: ::DWORD = 6731; pub const ERROR_TRANSACTIONAL_CONFLICT: ::DWORD = 6800; pub const ERROR_RM_NOT_ACTIVE: ::DWORD = 6801; pub const ERROR_RM_METADATA_CORRUPT: ::DWORD = 6802; pub const ERROR_DIRECTORY_NOT_RM: ::DWORD = 6803; pub const ERROR_TRANSACTIONS_UNSUPPORTED_REMOTE: ::DWORD = 6805; pub const ERROR_LOG_RESIZE_INVALID_SIZE: ::DWORD = 6806; pub const ERROR_OBJECT_NO_LONGER_EXISTS: ::DWORD = 6807; pub const ERROR_STREAM_MINIVERSION_NOT_FOUND: ::DWORD = 6808; pub const ERROR_STREAM_MINIVERSION_NOT_VALID: ::DWORD = 6809; pub const ERROR_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION: ::DWORD = 6810; pub const ERROR_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT: ::DWORD = 6811; pub const ERROR_CANT_CREATE_MORE_STREAM_MINIVERSIONS: ::DWORD = 6812; pub const ERROR_REMOTE_FILE_VERSION_MISMATCH: ::DWORD = 6814; pub const ERROR_HANDLE_NO_LONGER_VALID: ::DWORD = 6815; pub const ERROR_NO_TXF_METADATA: ::DWORD = 6816; pub const ERROR_LOG_CORRUPTION_DETECTED: ::DWORD = 6817; pub const ERROR_CANT_RECOVER_WITH_HANDLE_OPEN: ::DWORD = 6818; pub const ERROR_RM_DISCONNECTED: ::DWORD = 6819; pub const ERROR_ENLISTMENT_NOT_SUPERIOR: ::DWORD = 6820; pub const ERROR_RECOVERY_NOT_NEEDED: ::DWORD = 6821; pub const ERROR_RM_ALREADY_STARTED: ::DWORD = 6822; pub const ERROR_FILE_IDENTITY_NOT_PERSISTENT: ::DWORD = 6823; pub const ERROR_CANT_BREAK_TRANSACTIONAL_DEPENDENCY: ::DWORD = 6824; pub const ERROR_CANT_CROSS_RM_BOUNDARY: ::DWORD = 6825; pub const ERROR_TXF_DIR_NOT_EMPTY: ::DWORD = 6826; pub const ERROR_INDOUBT_TRANSACTIONS_EXIST: ::DWORD = 6827; pub const ERROR_TM_VOLATILE: ::DWORD = 6828; pub const ERROR_ROLLBACK_TIMER_EXPIRED: ::DWORD = 6829; pub const ERROR_TXF_ATTRIBUTE_CORRUPT: ::DWORD = 6830; pub const ERROR_EFS_NOT_ALLOWED_IN_TRANSACTION: ::DWORD = 6831; pub const ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED: ::DWORD = 6832; pub const ERROR_LOG_GROWTH_FAILED: ::DWORD = 6833; pub const ERROR_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE: ::DWORD = 6834; pub const ERROR_TXF_METADATA_ALREADY_PRESENT: ::DWORD = 6835; pub const ERROR_TRANSACTION_SCOPE_CALLBACKS_NOT_SET: ::DWORD = 6836; pub const ERROR_TRANSACTION_REQUIRED_PROMOTION: ::DWORD = 6837; pub const ERROR_CANNOT_EXECUTE_FILE_IN_TRANSACTION: ::DWORD = 6838; pub const ERROR_TRANSACTIONS_NOT_FROZEN: ::DWORD = 6839; pub const ERROR_TRANSACTION_FREEZE_IN_PROGRESS: ::DWORD = 6840; pub const ERROR_NOT_SNAPSHOT_VOLUME: ::DWORD = 6841; pub const ERROR_NO_SAVEPOINT_WITH_OPEN_FILES: ::DWORD = 6842; pub const ERROR_DATA_LOST_REPAIR: ::DWORD = 6843; pub const ERROR_SPARSE_NOT_ALLOWED_IN_TRANSACTION: ::DWORD = 6844; pub const ERROR_TM_IDENTITY_MISMATCH: ::DWORD = 6845; pub const ERROR_FLOATED_SECTION: ::DWORD = 6846; pub const ERROR_CANNOT_ACCEPT_TRANSACTED_WORK: ::DWORD = 6847; pub const ERROR_CANNOT_ABORT_TRANSACTIONS: ::DWORD = 6848; pub const ERROR_BAD_CLUSTERS: ::DWORD = 6849; pub const ERROR_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION: ::DWORD = 6850; pub const ERROR_VOLUME_DIRTY: ::DWORD = 6851; pub const ERROR_NO_LINK_TRACKING_IN_TRANSACTION: ::DWORD = 6852; pub const ERROR_OPERATION_NOT_SUPPORTED_IN_TRANSACTION: ::DWORD = 6853; pub const ERROR_EXPIRED_HANDLE: ::DWORD = 6854; pub const ERROR_TRANSACTION_NOT_ENLISTED: ::DWORD = 6855; pub const ERROR_CTX_WINSTATION_NAME_INVALID: ::DWORD = 7001; pub const ERROR_CTX_INVALID_PD: ::DWORD = 7002; pub const ERROR_CTX_PD_NOT_FOUND: ::DWORD = 7003; pub const ERROR_CTX_WD_NOT_FOUND: ::DWORD = 7004; pub const ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY: ::DWORD = 7005; pub const ERROR_CTX_SERVICE_NAME_COLLISION: ::DWORD = 7006; pub const ERROR_CTX_CLOSE_PENDING: ::DWORD = 7007; pub const ERROR_CTX_NO_OUTBUF: ::DWORD = 7008; pub const ERROR_CTX_MODEM_INF_NOT_FOUND: ::DWORD = 7009; pub const ERROR_CTX_INVALID_MODEMNAME: ::DWORD = 7010; pub const ERROR_CTX_MODEM_RESPONSE_ERROR: ::DWORD = 7011; pub const ERROR_CTX_MODEM_RESPONSE_TIMEOUT: ::DWORD = 7012; pub const ERROR_CTX_MODEM_RESPONSE_NO_CARRIER: ::DWORD = 7013; pub const ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE: ::DWORD = 7014; pub const ERROR_CTX_MODEM_RESPONSE_BUSY: ::DWORD = 7015; pub const ERROR_CTX_MODEM_RESPONSE_VOICE: ::DWORD = 7016; pub const ERROR_CTX_TD_ERROR: ::DWORD = 7017; pub const ERROR_CTX_WINSTATION_NOT_FOUND: ::DWORD = 7022; pub const ERROR_CTX_WINSTATION_ALREADY_EXISTS: ::DWORD = 7023; pub const ERROR_CTX_WINSTATION_BUSY: ::DWORD = 7024; pub const ERROR_CTX_BAD_VIDEO_MODE: ::DWORD = 7025; pub const ERROR_CTX_GRAPHICS_INVALID: ::DWORD = 7035; pub const ERROR_CTX_LOGON_DISABLED: ::DWORD = 7037; pub const ERROR_CTX_NOT_CONSOLE: ::DWORD = 7038; pub const ERROR_CTX_CLIENT_QUERY_TIMEOUT: ::DWORD = 7040; pub const ERROR_CTX_CONSOLE_DISCONNECT: ::DWORD = 7041; pub const ERROR_CTX_CONSOLE_CONNECT: ::DWORD = 7042; pub const ERROR_CTX_SHADOW_DENIED: ::DWORD = 7044; pub const ERROR_CTX_WINSTATION_ACCESS_DENIED: ::DWORD = 7045; pub const ERROR_CTX_INVALID_WD: ::DWORD = 7049; pub const ERROR_CTX_SHADOW_INVALID: ::DWORD = 7050; pub const ERROR_CTX_SHADOW_DISABLED: ::DWORD = 7051; pub const ERROR_CTX_CLIENT_LICENSE_IN_USE: ::DWORD = 7052; pub const ERROR_CTX_CLIENT_LICENSE_NOT_SET: ::DWORD = 7053; pub const ERROR_CTX_LICENSE_NOT_AVAILABLE: ::DWORD = 7054; pub const ERROR_CTX_LICENSE_CLIENT_INVALID: ::DWORD = 7055; pub const ERROR_CTX_LICENSE_EXPIRED: ::DWORD = 7056; pub const ERROR_CTX_SHADOW_NOT_RUNNING: ::DWORD = 7057; pub const ERROR_CTX_SHADOW_ENDED_BY_MODE_CHANGE: ::DWORD = 7058; pub const ERROR_ACTIVATION_COUNT_EXCEEDED: ::DWORD = 7059; pub const ERROR_CTX_WINSTATIONS_DISABLED: ::DWORD = 7060; pub const ERROR_CTX_ENCRYPTION_LEVEL_REQUIRED: ::DWORD = 7061; pub const ERROR_CTX_SESSION_IN_USE: ::DWORD = 7062; pub const ERROR_CTX_NO_FORCE_LOGOFF: ::DWORD = 7063; pub const ERROR_CTX_ACCOUNT_RESTRICTION: ::DWORD = 7064; pub const ERROR_RDP_PROTOCOL_ERROR: ::DWORD = 7065; pub const ERROR_CTX_CDM_CONNECT: ::DWORD = 7066; pub const ERROR_CTX_CDM_DISCONNECT: ::DWORD = 7067; pub const ERROR_CTX_SECURITY_LAYER_ERROR: ::DWORD = 7068; pub const ERROR_TS_INCOMPATIBLE_SESSIONS: ::DWORD = 7069; pub const ERROR_TS_VIDEO_SUBSYSTEM_ERROR: ::DWORD = 7070; pub const FRS_ERR_INVALID_API_SEQUENCE: ::DWORD = 8001; pub const FRS_ERR_STARTING_SERVICE: ::DWORD = 8002; pub const FRS_ERR_STOPPING_SERVICE: ::DWORD = 8003; pub const FRS_ERR_INTERNAL_API: ::DWORD = 8004; pub const FRS_ERR_INTERNAL: ::DWORD = 8005; pub const FRS_ERR_SERVICE_COMM: ::DWORD = 8006; pub const FRS_ERR_INSUFFICIENT_PRIV: ::DWORD = 8007; pub const FRS_ERR_AUTHENTICATION: ::DWORD = 8008; pub const FRS_ERR_PARENT_INSUFFICIENT_PRIV: ::DWORD = 8009; pub const FRS_ERR_PARENT_AUTHENTICATION: ::DWORD = 8010; pub const FRS_ERR_CHILD_TO_PARENT_COMM: ::DWORD = 8011; pub const FRS_ERR_PARENT_TO_CHILD_COMM: ::DWORD = 8012; pub const FRS_ERR_SYSVOL_POPULATE: ::DWORD = 8013; pub const FRS_ERR_SYSVOL_POPULATE_TIMEOUT: ::DWORD = 8014; pub const FRS_ERR_SYSVOL_IS_BUSY: ::DWORD = 8015; pub const FRS_ERR_SYSVOL_DEMOTE: ::DWORD = 8016; pub const FRS_ERR_INVALID_SERVICE_PARAMETER: ::DWORD = 8017; pub const DS_S_SUCCESS: ::DWORD = NO_ERROR; pub const ERROR_DS_NOT_INSTALLED: ::DWORD = 8200; pub const ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY: ::DWORD = 8201; pub const ERROR_DS_NO_ATTRIBUTE_OR_VALUE: ::DWORD = 8202; pub const ERROR_DS_INVALID_ATTRIBUTE_SYNTAX: ::DWORD = 8203; pub const ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED: ::DWORD = 8204; pub const ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS: ::DWORD = 8205; pub const ERROR_DS_BUSY: ::DWORD = 8206; pub const ERROR_DS_UNAVAILABLE: ::DWORD = 8207; pub const ERROR_DS_NO_RIDS_ALLOCATED: ::DWORD = 8208; pub const ERROR_DS_NO_MORE_RIDS: ::DWORD = 8209; pub const ERROR_DS_INCORRECT_ROLE_OWNER: ::DWORD = 8210; pub const ERROR_DS_RIDMGR_INIT_ERROR: ::DWORD = 8211; pub const ERROR_DS_OBJ_CLASS_VIOLATION: ::DWORD = 8212; pub const ERROR_DS_CANT_ON_NON_LEAF: ::DWORD = 8213; pub const ERROR_DS_CANT_ON_RDN: ::DWORD = 8214; pub const ERROR_DS_CANT_MOD_OBJ_CLASS: ::DWORD = 8215; pub const ERROR_DS_CROSS_DOM_MOVE_ERROR: ::DWORD = 8216; pub const ERROR_DS_GC_NOT_AVAILABLE: ::DWORD = 8217; pub const ERROR_SHARED_POLICY: ::DWORD = 8218; pub const ERROR_POLICY_OBJECT_NOT_FOUND: ::DWORD = 8219; pub const ERROR_POLICY_ONLY_IN_DS: ::DWORD = 8220; pub const ERROR_PROMOTION_ACTIVE: ::DWORD = 8221; pub const ERROR_NO_PROMOTION_ACTIVE: ::DWORD = 8222; pub const ERROR_DS_OPERATIONS_ERROR: ::DWORD = 8224; pub const ERROR_DS_PROTOCOL_ERROR: ::DWORD = 8225; pub const ERROR_DS_TIMELIMIT_EXCEEDED: ::DWORD = 8226; pub const ERROR_DS_SIZELIMIT_EXCEEDED: ::DWORD = 8227; pub const ERROR_DS_ADMIN_LIMIT_EXCEEDED: ::DWORD = 8228; pub const ERROR_DS_COMPARE_FALSE: ::DWORD = 8229; pub const ERROR_DS_COMPARE_TRUE: ::DWORD = 8230; pub const ERROR_DS_AUTH_METHOD_NOT_SUPPORTED: ::DWORD = 8231; pub const ERROR_DS_STRONG_AUTH_REQUIRED: ::DWORD = 8232; pub const ERROR_DS_INAPPROPRIATE_AUTH: ::DWORD = 8233; pub const ERROR_DS_AUTH_UNKNOWN: ::DWORD = 8234; pub const ERROR_DS_REFERRAL: ::DWORD = 8235; pub const ERROR_DS_UNAVAILABLE_CRIT_EXTENSION: ::DWORD = 8236; pub const ERROR_DS_CONFIDENTIALITY_REQUIRED: ::DWORD = 8237; pub const ERROR_DS_INAPPROPRIATE_MATCHING: ::DWORD = 8238; pub const ERROR_DS_CONSTRAINT_VIOLATION: ::DWORD = 8239; pub const ERROR_DS_NO_SUCH_OBJECT: ::DWORD = 8240; pub const ERROR_DS_ALIAS_PROBLEM: ::DWORD = 8241; pub const ERROR_DS_INVALID_DN_SYNTAX: ::DWORD = 8242; pub const ERROR_DS_IS_LEAF: ::DWORD = 8243; pub const ERROR_DS_ALIAS_DEREF_PROBLEM: ::DWORD = 8244; pub const ERROR_DS_UNWILLING_TO_PERFORM: ::DWORD = 8245; pub const ERROR_DS_LOOP_DETECT: ::DWORD = 8246; pub const ERROR_DS_NAMING_VIOLATION: ::DWORD = 8247; pub const ERROR_DS_OBJECT_RESULTS_TOO_LARGE: ::DWORD = 8248; pub const ERROR_DS_AFFECTS_MULTIPLE_DSAS: ::DWORD = 8249; pub const ERROR_DS_SERVER_DOWN: ::DWORD = 8250; pub const ERROR_DS_LOCAL_ERROR: ::DWORD = 8251; pub const ERROR_DS_ENCODING_ERROR: ::DWORD = 8252; pub const ERROR_DS_DECODING_ERROR: ::DWORD = 8253; pub const ERROR_DS_FILTER_UNKNOWN: ::DWORD = 8254; pub const ERROR_DS_PARAM_ERROR: ::DWORD = 8255; pub const ERROR_DS_NOT_SUPPORTED: ::DWORD = 8256; pub const ERROR_DS_NO_RESULTS_RETURNED: ::DWORD = 8257; pub const ERROR_DS_CONTROL_NOT_FOUND: ::DWORD = 8258; pub const ERROR_DS_CLIENT_LOOP: ::DWORD = 8259; pub const ERROR_DS_REFERRAL_LIMIT_EXCEEDED: ::DWORD = 8260; pub const ERROR_DS_SORT_CONTROL_MISSING: ::DWORD = 8261; pub const ERROR_DS_OFFSET_RANGE_ERROR: ::DWORD = 8262; pub const ERROR_DS_RIDMGR_DISABLED: ::DWORD = 8263; pub const ERROR_DS_ROOT_MUST_BE_NC: ::DWORD = 8301; pub const ERROR_DS_ADD_REPLICA_INHIBITED: ::DWORD = 8302; pub const ERROR_DS_ATT_NOT_DEF_IN_SCHEMA: ::DWORD = 8303; pub const ERROR_DS_MAX_OBJ_SIZE_EXCEEDED: ::DWORD = 8304; pub const ERROR_DS_OBJ_STRING_NAME_EXISTS: ::DWORD = 8305; pub const ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA: ::DWORD = 8306; pub const ERROR_DS_RDN_DOESNT_MATCH_SCHEMA: ::DWORD = 8307; pub const ERROR_DS_NO_REQUESTED_ATTS_FOUND: ::DWORD = 8308; pub const ERROR_DS_USER_BUFFER_TO_SMALL: ::DWORD = 8309; pub const ERROR_DS_ATT_IS_NOT_ON_OBJ: ::DWORD = 8310; pub const ERROR_DS_ILLEGAL_MOD_OPERATION: ::DWORD = 8311; pub const ERROR_DS_OBJ_TOO_LARGE: ::DWORD = 8312; pub const ERROR_DS_BAD_INSTANCE_TYPE: ::DWORD = 8313; pub const ERROR_DS_MASTERDSA_REQUIRED: ::DWORD = 8314; pub const ERROR_DS_OBJECT_CLASS_REQUIRED: ::DWORD = 8315; pub const ERROR_DS_MISSING_REQUIRED_ATT: ::DWORD = 8316; pub const ERROR_DS_ATT_NOT_DEF_FOR_CLASS: ::DWORD = 8317; pub const ERROR_DS_ATT_ALREADY_EXISTS: ::DWORD = 8318; pub const ERROR_DS_CANT_ADD_ATT_VALUES: ::DWORD = 8320; pub const ERROR_DS_SINGLE_VALUE_CONSTRAINT: ::DWORD = 8321; pub const ERROR_DS_RANGE_CONSTRAINT: ::DWORD = 8322; pub const ERROR_DS_ATT_VAL_ALREADY_EXISTS: ::DWORD = 8323; pub const ERROR_DS_CANT_REM_MISSING_ATT: ::DWORD = 8324; pub const ERROR_DS_CANT_REM_MISSING_ATT_VAL: ::DWORD = 8325; pub const ERROR_DS_ROOT_CANT_BE_SUBREF: ::DWORD = 8326; pub const ERROR_DS_NO_CHAINING: ::DWORD = 8327; pub const ERROR_DS_NO_CHAINED_EVAL: ::DWORD = 8328; pub const ERROR_DS_NO_PARENT_OBJECT: ::DWORD = 8329; pub const ERROR_DS_PARENT_IS_AN_ALIAS: ::DWORD = 8330; pub const ERROR_DS_CANT_MIX_MASTER_AND_REPS: ::DWORD = 8331; pub const ERROR_DS_CHILDREN_EXIST: ::DWORD = 8332; pub const ERROR_DS_OBJ_NOT_FOUND: ::DWORD = 8333; pub const ERROR_DS_ALIASED_OBJ_MISSING: ::DWORD = 8334; pub const ERROR_DS_BAD_NAME_SYNTAX: ::DWORD = 8335; pub const ERROR_DS_ALIAS_POINTS_TO_ALIAS: ::DWORD = 8336; pub const ERROR_DS_CANT_DEREF_ALIAS: ::DWORD = 8337; pub const ERROR_DS_OUT_OF_SCOPE: ::DWORD = 8338; pub const ERROR_DS_OBJECT_BEING_REMOVED: ::DWORD = 8339; pub const ERROR_DS_CANT_DELETE_DSA_OBJ: ::DWORD = 8340; pub const ERROR_DS_GENERIC_ERROR: ::DWORD = 8341; pub const ERROR_DS_DSA_MUST_BE_INT_MASTER: ::DWORD = 8342; pub const ERROR_DS_CLASS_NOT_DSA: ::DWORD = 8343; pub const ERROR_DS_INSUFF_ACCESS_RIGHTS: ::DWORD = 8344; pub const ERROR_DS_ILLEGAL_SUPERIOR: ::DWORD = 8345; pub const ERROR_DS_ATTRIBUTE_OWNED_BY_SAM: ::DWORD = 8346; pub const ERROR_DS_NAME_TOO_MANY_PARTS: ::DWORD = 8347; pub const ERROR_DS_NAME_TOO_LONG: ::DWORD = 8348; pub const ERROR_DS_NAME_VALUE_TOO_LONG: ::DWORD = 8349; pub const ERROR_DS_NAME_UNPARSEABLE: ::DWORD = 8350; pub const ERROR_DS_NAME_TYPE_UNKNOWN: ::DWORD = 8351; pub const ERROR_DS_NOT_AN_OBJECT: ::DWORD = 8352; pub const ERROR_DS_SEC_DESC_TOO_SHORT: ::DWORD = 8353; pub const ERROR_DS_SEC_DESC_INVALID: ::DWORD = 8354; pub const ERROR_DS_NO_DELETED_NAME: ::DWORD = 8355; pub const ERROR_DS_SUBREF_MUST_HAVE_PARENT: ::DWORD = 8356; pub const ERROR_DS_NCNAME_MUST_BE_NC: ::DWORD = 8357; pub const ERROR_DS_CANT_ADD_SYSTEM_ONLY: ::DWORD = 8358; pub const ERROR_DS_CLASS_MUST_BE_CONCRETE: ::DWORD = 8359; pub const ERROR_DS_INVALID_DMD: ::DWORD = 8360; pub const ERROR_DS_OBJ_GUID_EXISTS: ::DWORD = 8361; pub const ERROR_DS_NOT_ON_BACKLINK: ::DWORD = 8362; pub const ERROR_DS_NO_CROSSREF_FOR_NC: ::DWORD = 8363; pub const ERROR_DS_SHUTTING_DOWN: ::DWORD = 8364; pub const ERROR_DS_UNKNOWN_OPERATION: ::DWORD = 8365; pub const ERROR_DS_INVALID_ROLE_OWNER: ::DWORD = 8366; pub const ERROR_DS_COULDNT_CONTACT_FSMO: ::DWORD = 8367; pub const ERROR_DS_CROSS_NC_DN_RENAME: ::DWORD = 8368; pub const ERROR_DS_CANT_MOD_SYSTEM_ONLY: ::DWORD = 8369; pub const ERROR_DS_REPLICATOR_ONLY: ::DWORD = 8370; pub const ERROR_DS_OBJ_CLASS_NOT_DEFINED: ::DWORD = 8371; pub const ERROR_DS_OBJ_CLASS_NOT_SUBCLASS: ::DWORD = 8372; pub const ERROR_DS_NAME_REFERENCE_INVALID: ::DWORD = 8373; pub const ERROR_DS_CROSS_REF_EXISTS: ::DWORD = 8374; pub const ERROR_DS_CANT_DEL_MASTER_CROSSREF: ::DWORD = 8375; pub const ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD: ::DWORD = 8376; pub const ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX: ::DWORD = 8377; pub const ERROR_DS_DUP_RDN: ::DWORD = 8378; pub const ERROR_DS_DUP_OID: ::DWORD = 8379; pub const ERROR_DS_DUP_MAPI_ID: ::DWORD = 8380; pub const ERROR_DS_DUP_SCHEMA_ID_GUID: ::DWORD = 8381; pub const ERROR_DS_DUP_LDAP_DISPLAY_NAME: ::DWORD = 8382; pub const ERROR_DS_SEMANTIC_ATT_TEST: ::DWORD = 8383; pub const ERROR_DS_SYNTAX_MISMATCH: ::DWORD = 8384; pub const ERROR_DS_EXISTS_IN_MUST_HAVE: ::DWORD = 8385; pub const ERROR_DS_EXISTS_IN_MAY_HAVE: ::DWORD = 8386; pub const ERROR_DS_NONEXISTENT_MAY_HAVE: ::DWORD = 8387; pub const ERROR_DS_NONEXISTENT_MUST_HAVE: ::DWORD = 8388; pub const ERROR_DS_AUX_CLS_TEST_FAIL: ::DWORD = 8389; pub const ERROR_DS_NONEXISTENT_POSS_SUP: ::DWORD = 8390; pub const ERROR_DS_SUB_CLS_TEST_FAIL: ::DWORD = 8391; pub const ERROR_DS_BAD_RDN_ATT_ID_SYNTAX: ::DWORD = 8392; pub const ERROR_DS_EXISTS_IN_AUX_CLS: ::DWORD = 8393; pub const ERROR_DS_EXISTS_IN_SUB_CLS: ::DWORD = 8394; pub const ERROR_DS_EXISTS_IN_POSS_SUP: ::DWORD = 8395; pub const ERROR_DS_RECALCSCHEMA_FAILED: ::DWORD = 8396; pub const ERROR_DS_TREE_DELETE_NOT_FINISHED: ::DWORD = 8397; pub const ERROR_DS_CANT_DELETE: ::DWORD = 8398; pub const ERROR_DS_ATT_SCHEMA_REQ_ID: ::DWORD = 8399; pub const ERROR_DS_BAD_ATT_SCHEMA_SYNTAX: ::DWORD = 8400; pub const ERROR_DS_CANT_CACHE_ATT: ::DWORD = 8401; pub const ERROR_DS_CANT_CACHE_CLASS: ::DWORD = 8402; pub const ERROR_DS_CANT_REMOVE_ATT_CACHE: ::DWORD = 8403; pub const ERROR_DS_CANT_REMOVE_CLASS_CACHE: ::DWORD = 8404; pub const ERROR_DS_CANT_RETRIEVE_DN: ::DWORD = 8405; pub const ERROR_DS_MISSING_SUPREF: ::DWORD = 8406; pub const ERROR_DS_CANT_RETRIEVE_INSTANCE: ::DWORD = 8407; pub const ERROR_DS_CODE_INCONSISTENCY: ::DWORD = 8408; pub const ERROR_DS_DATABASE_ERROR: ::DWORD = 8409; pub const ERROR_DS_GOVERNSID_MISSING: ::DWORD = 8410; pub const ERROR_DS_MISSING_EXPECTED_ATT: ::DWORD = 8411; pub const ERROR_DS_NCNAME_MISSING_CR_REF: ::DWORD = 8412; pub const ERROR_DS_SECURITY_CHECKING_ERROR: ::DWORD = 8413; pub const ERROR_DS_SCHEMA_NOT_LOADED: ::DWORD = 8414; pub const ERROR_DS_SCHEMA_ALLOC_FAILED: ::DWORD = 8415; pub const ERROR_DS_ATT_SCHEMA_REQ_SYNTAX: ::DWORD = 8416; pub const ERROR_DS_GCVERIFY_ERROR: ::DWORD = 8417; pub const ERROR_DS_DRA_SCHEMA_MISMATCH: ::DWORD = 8418; pub const ERROR_DS_CANT_FIND_DSA_OBJ: ::DWORD = 8419; pub const ERROR_DS_CANT_FIND_EXPECTED_NC: ::DWORD = 8420; pub const ERROR_DS_CANT_FIND_NC_IN_CACHE: ::DWORD = 8421; pub const ERROR_DS_CANT_RETRIEVE_CHILD: ::DWORD = 8422; pub const ERROR_DS_SECURITY_ILLEGAL_MODIFY: ::DWORD = 8423; pub const ERROR_DS_CANT_REPLACE_HIDDEN_REC: ::DWORD = 8424; pub const ERROR_DS_BAD_HIERARCHY_FILE: ::DWORD = 8425; pub const ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED: ::DWORD = 8426; pub const ERROR_DS_CONFIG_PARAM_MISSING: ::DWORD = 8427; pub const ERROR_DS_COUNTING_AB_INDICES_FAILED: ::DWORD = 8428; pub const ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED: ::DWORD = 8429; pub const ERROR_DS_INTERNAL_FAILURE: ::DWORD = 8430; pub const ERROR_DS_UNKNOWN_ERROR: ::DWORD = 8431; pub const ERROR_DS_ROOT_REQUIRES_CLASS_TOP: ::DWORD = 8432; pub const ERROR_DS_REFUSING_FSMO_ROLES: ::DWORD = 8433; pub const ERROR_DS_MISSING_FSMO_SETTINGS: ::DWORD = 8434; pub const ERROR_DS_UNABLE_TO_SURRENDER_ROLES: ::DWORD = 8435; pub const ERROR_DS_DRA_GENERIC: ::DWORD = 8436; pub const ERROR_DS_DRA_INVALID_PARAMETER: ::DWORD = 8437; pub const ERROR_DS_DRA_BUSY: ::DWORD = 8438; pub const ERROR_DS_DRA_BAD_DN: ::DWORD = 8439; pub const ERROR_DS_DRA_BAD_NC: ::DWORD = 8440; pub const ERROR_DS_DRA_DN_EXISTS: ::DWORD = 8441; pub const ERROR_DS_DRA_INTERNAL_ERROR: ::DWORD = 8442; pub const ERROR_DS_DRA_INCONSISTENT_DIT: ::DWORD = 8443; pub const ERROR_DS_DRA_CONNECTION_FAILED: ::DWORD = 8444; pub const ERROR_DS_DRA_BAD_INSTANCE_TYPE: ::DWORD = 8445; pub const ERROR_DS_DRA_OUT_OF_MEM: ::DWORD = 8446; pub const ERROR_DS_DRA_MAIL_PROBLEM: ::DWORD = 8447; pub const ERROR_DS_DRA_REF_ALREADY_EXISTS: ::DWORD = 8448; pub const ERROR_DS_DRA_REF_NOT_FOUND: ::DWORD = 8449; pub const ERROR_DS_DRA_OBJ_IS_REP_SOURCE: ::DWORD = 8450; pub const ERROR_DS_DRA_DB_ERROR: ::DWORD = 8451; pub const ERROR_DS_DRA_NO_REPLICA: ::DWORD = 8452; pub const ERROR_DS_DRA_ACCESS_DENIED: ::DWORD = 8453; pub const ERROR_DS_DRA_NOT_SUPPORTED: ::DWORD = 8454; pub const ERROR_DS_DRA_RPC_CANCELLED: ::DWORD = 8455; pub const ERROR_DS_DRA_SOURCE_DISABLED: ::DWORD = 8456; pub const ERROR_DS_DRA_SINK_DISABLED: ::DWORD = 8457; pub const ERROR_DS_DRA_NAME_COLLISION: ::DWORD = 8458; pub const ERROR_DS_DRA_SOURCE_REINSTALLED: ::DWORD = 8459; pub const ERROR_DS_DRA_MISSING_PARENT: ::DWORD = 8460; pub const ERROR_DS_DRA_PREEMPTED: ::DWORD = 8461; pub const ERROR_DS_DRA_ABANDON_SYNC: ::DWORD = 8462; pub const ERROR_DS_DRA_SHUTDOWN: ::DWORD = 8463; pub const ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET: ::DWORD = 8464; pub const ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA: ::DWORD = 8465; pub const ERROR_DS_DRA_EXTN_CONNECTION_FAILED: ::DWORD = 8466; pub const ERROR_DS_INSTALL_SCHEMA_MISMATCH: ::DWORD = 8467; pub const ERROR_DS_DUP_LINK_ID: ::DWORD = 8468; pub const ERROR_DS_NAME_ERROR_RESOLVING: ::DWORD = 8469; pub const ERROR_DS_NAME_ERROR_NOT_FOUND: ::DWORD = 8470; pub const ERROR_DS_NAME_ERROR_NOT_UNIQUE: ::DWORD = 8471; pub const ERROR_DS_NAME_ERROR_NO_MAPPING: ::DWORD = 8472; pub const ERROR_DS_NAME_ERROR_DOMAIN_ONLY: ::DWORD = 8473; pub const ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING: ::DWORD = 8474; pub const ERROR_DS_CONSTRUCTED_ATT_MOD: ::DWORD = 8475; pub const ERROR_DS_WRONG_OM_OBJ_CLASS: ::DWORD = 8476; pub const ERROR_DS_DRA_REPL_PENDING: ::DWORD = 8477; pub const ERROR_DS_DS_REQUIRED: ::DWORD = 8478; pub const ERROR_DS_INVALID_LDAP_DISPLAY_NAME: ::DWORD = 8479; pub const ERROR_DS_NON_BASE_SEARCH: ::DWORD = 8480; pub const ERROR_DS_CANT_RETRIEVE_ATTS: ::DWORD = 8481; pub const ERROR_DS_BACKLINK_WITHOUT_LINK: ::DWORD = 8482; pub const ERROR_DS_EPOCH_MISMATCH: ::DWORD = 8483; pub const ERROR_DS_SRC_NAME_MISMATCH: ::DWORD = 8484; pub const ERROR_DS_SRC_AND_DST_NC_IDENTICAL: ::DWORD = 8485; pub const ERROR_DS_DST_NC_MISMATCH: ::DWORD = 8486; pub const ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC: ::DWORD = 8487; pub const ERROR_DS_SRC_GUID_MISMATCH: ::DWORD = 8488; pub const ERROR_DS_CANT_MOVE_DELETED_OBJECT: ::DWORD = 8489; pub const ERROR_DS_PDC_OPERATION_IN_PROGRESS: ::DWORD = 8490; pub const ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD: ::DWORD = 8491; pub const ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION: ::DWORD = 8492; pub const ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS: ::DWORD = 8493; pub const ERROR_DS_NC_MUST_HAVE_NC_PARENT: ::DWORD = 8494; pub const ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE: ::DWORD = 8495; pub const ERROR_DS_DST_DOMAIN_NOT_NATIVE: ::DWORD = 8496; pub const ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER: ::DWORD = 8497; pub const ERROR_DS_CANT_MOVE_ACCOUNT_GROUP: ::DWORD = 8498; pub const ERROR_DS_CANT_MOVE_RESOURCE_GROUP: ::DWORD = 8499; pub const ERROR_DS_INVALID_SEARCH_FLAG: ::DWORD = 8500; pub const ERROR_DS_NO_TREE_DELETE_ABOVE_NC: ::DWORD = 8501; pub const ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE: ::DWORD = 8502; pub const ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE: ::DWORD = 8503; pub const ERROR_DS_SAM_INIT_FAILURE: ::DWORD = 8504; pub const ERROR_DS_SENSITIVE_GROUP_VIOLATION: ::DWORD = 8505; pub const ERROR_DS_CANT_MOD_PRIMARYGROUPID: ::DWORD = 8506; pub const ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD: ::DWORD = 8507; pub const ERROR_DS_NONSAFE_SCHEMA_CHANGE: ::DWORD = 8508; pub const ERROR_DS_SCHEMA_UPDATE_DISALLOWED: ::DWORD = 8509; pub const ERROR_DS_CANT_CREATE_UNDER_SCHEMA: ::DWORD = 8510; pub const ERROR_DS_INSTALL_NO_SRC_SCH_VERSION: ::DWORD = 8511; pub const ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE: ::DWORD = 8512; pub const ERROR_DS_INVALID_GROUP_TYPE: ::DWORD = 8513; pub const ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN: ::DWORD = 8514; pub const ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN: ::DWORD = 8515; pub const ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER: ::DWORD = 8516; pub const ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER: ::DWORD = 8517; pub const ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER: ::DWORD = 8518; pub const ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER: ::DWORD = 8519; pub const ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER: ::DWORD = 8520; pub const ERROR_DS_HAVE_PRIMARY_MEMBERS: ::DWORD = 8521; pub const ERROR_DS_STRING_SD_CONVERSION_FAILED: ::DWORD = 8522; pub const ERROR_DS_NAMING_MASTER_GC: ::DWORD = 8523; pub const ERROR_DS_DNS_LOOKUP_FAILURE: ::DWORD = 8524; pub const ERROR_DS_COULDNT_UPDATE_SPNS: ::DWORD = 8525; pub const ERROR_DS_CANT_RETRIEVE_SD: ::DWORD = 8526; pub const ERROR_DS_KEY_NOT_UNIQUE: ::DWORD = 8527; pub const ERROR_DS_WRONG_LINKED_ATT_SYNTAX: ::DWORD = 8528; pub const ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD: ::DWORD = 8529; pub const ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY: ::DWORD = 8530; pub const ERROR_DS_CANT_START: ::DWORD = 8531; pub const ERROR_DS_INIT_FAILURE: ::DWORD = 8532; pub const ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION: ::DWORD = 8533; pub const ERROR_DS_SOURCE_DOMAIN_IN_FOREST: ::DWORD = 8534; pub const ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST: ::DWORD = 8535; pub const ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED: ::DWORD = 8536; pub const ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN: ::DWORD = 8537; pub const ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER: ::DWORD = 8538; pub const ERROR_DS_SRC_SID_EXISTS_IN_FOREST: ::DWORD = 8539; pub const ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH: ::DWORD = 8540; pub const ERROR_SAM_INIT_FAILURE: ::DWORD = 8541; pub const ERROR_DS_DRA_SCHEMA_INFO_SHIP: ::DWORD = 8542; pub const ERROR_DS_DRA_SCHEMA_CONFLICT: ::DWORD = 8543; pub const ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT: ::DWORD = 8544; pub const ERROR_DS_DRA_OBJ_NC_MISMATCH: ::DWORD = 8545; pub const ERROR_DS_NC_STILL_HAS_DSAS: ::DWORD = 8546; pub const ERROR_DS_GC_REQUIRED: ::DWORD = 8547; pub const ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY: ::DWORD = 8548; pub const ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS: ::DWORD = 8549; pub const ERROR_DS_CANT_ADD_TO_GC: ::DWORD = 8550; pub const ERROR_DS_NO_CHECKPOINT_WITH_PDC: ::DWORD = 8551; pub const ERROR_DS_SOURCE_AUDITING_NOT_ENABLED: ::DWORD = 8552; pub const ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC: ::DWORD = 8553; pub const ERROR_DS_INVALID_NAME_FOR_SPN: ::DWORD = 8554; pub const ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS: ::DWORD = 8555; pub const ERROR_DS_UNICODEPWD_NOT_IN_QUOTES: ::DWORD = 8556; pub const ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED: ::DWORD = 8557; pub const ERROR_DS_MUST_BE_RUN_ON_DST_DC: ::DWORD = 8558; pub const ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER: ::DWORD = 8559; pub const ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ: ::DWORD = 8560; pub const ERROR_DS_INIT_FAILURE_CONSOLE: ::DWORD = 8561; pub const ERROR_DS_SAM_INIT_FAILURE_CONSOLE: ::DWORD = 8562; pub const ERROR_DS_FOREST_VERSION_TOO_HIGH: ::DWORD = 8563; pub const ERROR_DS_DOMAIN_VERSION_TOO_HIGH: ::DWORD = 8564; pub const ERROR_DS_FOREST_VERSION_TOO_LOW: ::DWORD = 8565; pub const ERROR_DS_DOMAIN_VERSION_TOO_LOW: ::DWORD = 8566; pub const ERROR_DS_INCOMPATIBLE_VERSION: ::DWORD = 8567; pub const ERROR_DS_LOW_DSA_VERSION: ::DWORD = 8568; pub const ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN: ::DWORD = 8569; pub const ERROR_DS_NOT_SUPPORTED_SORT_ORDER: ::DWORD = 8570; pub const ERROR_DS_NAME_NOT_UNIQUE: ::DWORD = 8571; pub const ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4: ::DWORD = 8572; pub const ERROR_DS_OUT_OF_VERSION_STORE: ::DWORD = 8573; pub const ERROR_DS_INCOMPATIBLE_CONTROLS_USED: ::DWORD = 8574; pub const ERROR_DS_NO_REF_DOMAIN: ::DWORD = 8575; pub const ERROR_DS_RESERVED_LINK_ID: ::DWORD = 8576; pub const ERROR_DS_LINK_ID_NOT_AVAILABLE: ::DWORD = 8577; pub const ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER: ::DWORD = 8578; pub const ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE: ::DWORD = 8579; pub const ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC: ::DWORD = 8580; pub const ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG: ::DWORD = 8581; pub const ERROR_DS_MODIFYDN_WRONG_GRANDPARENT: ::DWORD = 8582; pub const ERROR_DS_NAME_ERROR_TRUST_REFERRAL: ::DWORD = 8583; pub const ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER: ::DWORD = 8584; pub const ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD: ::DWORD = 8585; pub const ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2: ::DWORD = 8586; pub const ERROR_DS_THREAD_LIMIT_EXCEEDED: ::DWORD = 8587; pub const ERROR_DS_NOT_CLOSEST: ::DWORD = 8588; pub const ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF: ::DWORD = 8589; pub const ERROR_DS_SINGLE_USER_MODE_FAILED: ::DWORD = 8590; pub const ERROR_DS_NTDSCRIPT_SYNTAX_ERROR: ::DWORD = 8591; pub const ERROR_DS_NTDSCRIPT_PROCESS_ERROR: ::DWORD = 8592; pub const ERROR_DS_DIFFERENT_REPL_EPOCHS: ::DWORD = 8593; pub const ERROR_DS_DRS_EXTENSIONS_CHANGED: ::DWORD = 8594; pub const ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR: ::DWORD = 8595; pub const ERROR_DS_NO_MSDS_INTID: ::DWORD = 8596; pub const ERROR_DS_DUP_MSDS_INTID: ::DWORD = 8597; pub const ERROR_DS_EXISTS_IN_RDNATTID: ::DWORD = 8598; pub const ERROR_DS_AUTHORIZATION_FAILED: ::DWORD = 8599; pub const ERROR_DS_INVALID_SCRIPT: ::DWORD = 8600; pub const ERROR_DS_REMOTE_CROSSREF_OP_FAILED: ::DWORD = 8601; pub const ERROR_DS_CROSS_REF_BUSY: ::DWORD = 8602; pub const ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN: ::DWORD = 8603; pub const ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC: ::DWORD = 8604; pub const ERROR_DS_DUPLICATE_ID_FOUND: ::DWORD = 8605; pub const ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT: ::DWORD = 8606; pub const ERROR_DS_GROUP_CONVERSION_ERROR: ::DWORD = 8607; pub const ERROR_DS_CANT_MOVE_APP_BASIC_GROUP: ::DWORD = 8608; pub const ERROR_DS_CANT_MOVE_APP_QUERY_GROUP: ::DWORD = 8609; pub const ERROR_DS_ROLE_NOT_VERIFIED: ::DWORD = 8610; pub const ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL: ::DWORD = 8611; pub const ERROR_DS_DOMAIN_RENAME_IN_PROGRESS: ::DWORD = 8612; pub const ERROR_DS_EXISTING_AD_CHILD_NC: ::DWORD = 8613; pub const ERROR_DS_REPL_LIFETIME_EXCEEDED: ::DWORD = 8614; pub const ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER: ::DWORD = 8615; pub const ERROR_DS_LDAP_SEND_QUEUE_FULL: ::DWORD = 8616; pub const ERROR_DS_DRA_OUT_SCHEDULE_WINDOW: ::DWORD = 8617; pub const ERROR_DS_POLICY_NOT_KNOWN: ::DWORD = 8618; pub const ERROR_NO_SITE_SETTINGS_OBJECT: ::DWORD = 8619; pub const ERROR_NO_SECRETS: ::DWORD = 8620; pub const ERROR_NO_WRITABLE_DC_FOUND: ::DWORD = 8621; pub const ERROR_DS_NO_SERVER_OBJECT: ::DWORD = 8622; pub const ERROR_DS_NO_NTDSA_OBJECT: ::DWORD = 8623; pub const ERROR_DS_NON_ASQ_SEARCH: ::DWORD = 8624; pub const ERROR_DS_AUDIT_FAILURE: ::DWORD = 8625; pub const ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE: ::DWORD = 8626; pub const ERROR_DS_INVALID_SEARCH_FLAG_TUPLE: ::DWORD = 8627; pub const ERROR_DS_HIERARCHY_TABLE_TOO_DEEP: ::DWORD = 8628; pub const ERROR_DS_DRA_CORRUPT_UTD_VECTOR: ::DWORD = 8629; pub const ERROR_DS_DRA_SECRETS_DENIED: ::DWORD = 8630; pub const ERROR_DS_RESERVED_MAPI_ID: ::DWORD = 8631; pub const ERROR_DS_MAPI_ID_NOT_AVAILABLE: ::DWORD = 8632; pub const ERROR_DS_DRA_MISSING_KRBTGT_SECRET: ::DWORD = 8633; pub const ERROR_DS_DOMAIN_NAME_EXISTS_IN_FOREST: ::DWORD = 8634; pub const ERROR_DS_FLAT_NAME_EXISTS_IN_FOREST: ::DWORD = 8635; pub const ERROR_INVALID_USER_PRINCIPAL_NAME: ::DWORD = 8636; pub const ERROR_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS: ::DWORD = 8637; pub const ERROR_DS_OID_NOT_FOUND: ::DWORD = 8638; pub const ERROR_DS_DRA_RECYCLED_TARGET: ::DWORD = 8639; pub const ERROR_DS_DISALLOWED_NC_REDIRECT: ::DWORD = 8640; pub const ERROR_DS_HIGH_ADLDS_FFL: ::DWORD = 8641; pub const ERROR_DS_HIGH_DSA_VERSION: ::DWORD = 8642; pub const ERROR_DS_LOW_ADLDS_FFL: ::DWORD = 8643; pub const ERROR_DOMAIN_SID_SAME_AS_LOCAL_WORKSTATION: ::DWORD = 8644; pub const ERROR_DS_UNDELETE_SAM_VALIDATION_FAILED: ::DWORD = 8645; pub const ERROR_INCORRECT_ACCOUNT_TYPE: ::DWORD = 8646; pub const ERROR_DS_SPN_VALUE_NOT_UNIQUE_IN_FOREST: ::DWORD = 8647; pub const ERROR_DS_UPN_VALUE_NOT_UNIQUE_IN_FOREST: ::DWORD = 8648; pub const DNS_ERROR_RESPONSE_CODES_BASE: ::DWORD = 9000; pub const DNS_ERROR_RCODE_NO_ERROR: ::DWORD = NO_ERROR; pub const DNS_ERROR_MASK: ::DWORD = 0x00002328; pub const DNS_ERROR_RCODE_FORMAT_ERROR: ::DWORD = 9001; pub const DNS_ERROR_RCODE_SERVER_FAILURE: ::DWORD = 9002; pub const DNS_ERROR_RCODE_NAME_ERROR: ::DWORD = 9003; pub const DNS_ERROR_RCODE_NOT_IMPLEMENTED: ::DWORD = 9004; pub const DNS_ERROR_RCODE_REFUSED: ::DWORD = 9005; pub const DNS_ERROR_RCODE_YXDOMAIN: ::DWORD = 9006; pub const DNS_ERROR_RCODE_YXRRSET: ::DWORD = 9007; pub const DNS_ERROR_RCODE_NXRRSET: ::DWORD = 9008; pub const DNS_ERROR_RCODE_NOTAUTH: ::DWORD = 9009; pub const DNS_ERROR_RCODE_NOTZONE: ::DWORD = 9010; pub const DNS_ERROR_RCODE_BADSIG: ::DWORD = 9016; pub const DNS_ERROR_RCODE_BADKEY: ::DWORD = 9017; pub const DNS_ERROR_RCODE_BADTIME: ::DWORD = 9018; pub const DNS_ERROR_RCODE_LAST: ::DWORD = DNS_ERROR_RCODE_BADTIME; pub const DNS_ERROR_DNSSEC_BASE: ::DWORD = 9100; pub const DNS_ERROR_KEYMASTER_REQUIRED: ::DWORD = 9101; pub const DNS_ERROR_NOT_ALLOWED_ON_SIGNED_ZONE: ::DWORD = 9102; pub const DNS_ERROR_NSEC3_INCOMPATIBLE_WITH_RSA_SHA1: ::DWORD = 9103; pub const DNS_ERROR_NOT_ENOUGH_SIGNING_KEY_DESCRIPTORS: ::DWORD = 9104; pub const DNS_ERROR_UNSUPPORTED_ALGORITHM: ::DWORD = 9105; pub const DNS_ERROR_INVALID_KEY_SIZE: ::DWORD = 9106; pub const DNS_ERROR_SIGNING_KEY_NOT_ACCESSIBLE: ::DWORD = 9107; pub const DNS_ERROR_KSP_DOES_NOT_SUPPORT_PROTECTION: ::DWORD = 9108; pub const DNS_ERROR_UNEXPECTED_DATA_PROTECTION_ERROR: ::DWORD = 9109; pub const DNS_ERROR_UNEXPECTED_CNG_ERROR: ::DWORD = 9110; pub const DNS_ERROR_UNKNOWN_SIGNING_PARAMETER_VERSION: ::DWORD = 9111; pub const DNS_ERROR_KSP_NOT_ACCESSIBLE: ::DWORD = 9112; pub const DNS_ERROR_TOO_MANY_SKDS: ::DWORD = 9113; pub const DNS_ERROR_INVALID_ROLLOVER_PERIOD: ::DWORD = 9114; pub const DNS_ERROR_INVALID_INITIAL_ROLLOVER_OFFSET: ::DWORD = 9115; pub const DNS_ERROR_ROLLOVER_IN_PROGRESS: ::DWORD = 9116; pub const DNS_ERROR_STANDBY_KEY_NOT_PRESENT: ::DWORD = 9117; pub const DNS_ERROR_NOT_ALLOWED_ON_ZSK: ::DWORD = 9118; pub const DNS_ERROR_NOT_ALLOWED_ON_ACTIVE_SKD: ::DWORD = 9119; pub const DNS_ERROR_ROLLOVER_ALREADY_QUEUED: ::DWORD = 9120; pub const DNS_ERROR_NOT_ALLOWED_ON_UNSIGNED_ZONE: ::DWORD = 9121; pub const DNS_ERROR_BAD_KEYMASTER: ::DWORD = 9122; pub const DNS_ERROR_INVALID_SIGNATURE_VALIDITY_PERIOD: ::DWORD = 9123; pub const DNS_ERROR_INVALID_NSEC3_ITERATION_COUNT: ::DWORD = 9124; pub const DNS_ERROR_DNSSEC_IS_DISABLED: ::DWORD = 9125; pub const DNS_ERROR_INVALID_XML: ::DWORD = 9126; pub const DNS_ERROR_NO_VALID_TRUST_ANCHORS: ::DWORD = 9127; pub const DNS_ERROR_ROLLOVER_NOT_POKEABLE: ::DWORD = 9128; pub const DNS_ERROR_NSEC3_NAME_COLLISION: ::DWORD = 9129; pub const DNS_ERROR_NSEC_INCOMPATIBLE_WITH_NSEC3_RSA_SHA1: ::DWORD = 9130; pub const DNS_ERROR_PACKET_FMT_BASE: ::DWORD = 9500; pub const DNS_INFO_NO_RECORDS: ::DWORD = 9501; pub const DNS_ERROR_BAD_PACKET: ::DWORD = 9502; pub const DNS_ERROR_NO_PACKET: ::DWORD = 9503; pub const DNS_ERROR_RCODE: ::DWORD = 9504; pub const DNS_ERROR_UNSECURE_PACKET: ::DWORD = 9505; pub const DNS_STATUS_PACKET_UNSECURE: ::DWORD = DNS_ERROR_UNSECURE_PACKET; pub const DNS_REQUEST_PENDING: ::DWORD = 9506; pub const DNS_ERROR_NO_MEMORY: ::DWORD = ERROR_OUTOFMEMORY; pub const DNS_ERROR_INVALID_NAME: ::DWORD = ERROR_INVALID_NAME; pub const DNS_ERROR_INVALID_DATA: ::DWORD = ERROR_INVALID_DATA; pub const DNS_ERROR_GENERAL_API_BASE: ::DWORD = 9550; pub const DNS_ERROR_INVALID_TYPE: ::DWORD = 9551; pub const DNS_ERROR_INVALID_IP_ADDRESS: ::DWORD = 9552; pub const DNS_ERROR_INVALID_PROPERTY: ::DWORD = 9553; pub const DNS_ERROR_TRY_AGAIN_LATER: ::DWORD = 9554; pub const DNS_ERROR_NOT_UNIQUE: ::DWORD = 9555; pub const DNS_ERROR_NON_RFC_NAME: ::DWORD = 9556; pub const DNS_STATUS_FQDN: ::DWORD = 9557; pub const DNS_STATUS_DOTTED_NAME: ::DWORD = 9558; pub const DNS_STATUS_SINGLE_PART_NAME: ::DWORD = 9559; pub const DNS_ERROR_INVALID_NAME_CHAR: ::DWORD = 9560; pub const DNS_ERROR_NUMERIC_NAME: ::DWORD = 9561; pub const DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER: ::DWORD = 9562; pub const DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION: ::DWORD = 9563; pub const DNS_ERROR_CANNOT_FIND_ROOT_HINTS: ::DWORD = 9564; pub const DNS_ERROR_INCONSISTENT_ROOT_HINTS: ::DWORD = 9565; pub const DNS_ERROR_DWORD_VALUE_TOO_SMALL: ::DWORD = 9566; pub const DNS_ERROR_DWORD_VALUE_TOO_LARGE: ::DWORD = 9567; pub const DNS_ERROR_BACKGROUND_LOADING: ::DWORD = 9568; pub const DNS_ERROR_NOT_ALLOWED_ON_RODC: ::DWORD = 9569; pub const DNS_ERROR_NOT_ALLOWED_UNDER_DNAME: ::DWORD = 9570; pub const DNS_ERROR_DELEGATION_REQUIRED: ::DWORD = 9571; pub const DNS_ERROR_INVALID_POLICY_TABLE: ::DWORD = 9572; pub const DNS_ERROR_ZONE_BASE: ::DWORD = 9600; pub const DNS_ERROR_ZONE_DOES_NOT_EXIST: ::DWORD = 9601; pub const DNS_ERROR_NO_ZONE_INFO: ::DWORD = 9602; pub const DNS_ERROR_INVALID_ZONE_OPERATION: ::DWORD = 9603; pub const DNS_ERROR_ZONE_CONFIGURATION_ERROR: ::DWORD = 9604; pub const DNS_ERROR_ZONE_HAS_NO_SOA_RECORD: ::DWORD = 9605; pub const DNS_ERROR_ZONE_HAS_NO_NS_RECORDS: ::DWORD = 9606; pub const DNS_ERROR_ZONE_LOCKED: ::DWORD = 9607; pub const DNS_ERROR_ZONE_CREATION_FAILED: ::DWORD = 9608; pub const DNS_ERROR_ZONE_ALREADY_EXISTS: ::DWORD = 9609; pub const DNS_ERROR_AUTOZONE_ALREADY_EXISTS: ::DWORD = 9610; pub const DNS_ERROR_INVALID_ZONE_TYPE: ::DWORD = 9611; pub const DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP: ::DWORD = 9612; pub const DNS_ERROR_ZONE_NOT_SECONDARY: ::DWORD = 9613; pub const DNS_ERROR_NEED_SECONDARY_ADDRESSES: ::DWORD = 9614; pub const DNS_ERROR_WINS_INIT_FAILED: ::DWORD = 9615; pub const DNS_ERROR_NEED_WINS_SERVERS: ::DWORD = 9616; pub const DNS_ERROR_NBSTAT_INIT_FAILED: ::DWORD = 9617; pub const DNS_ERROR_SOA_DELETE_INVALID: ::DWORD = 9618; pub const DNS_ERROR_FORWARDER_ALREADY_EXISTS: ::DWORD = 9619; pub const DNS_ERROR_ZONE_REQUIRES_MASTER_IP: ::DWORD = 9620; pub const DNS_ERROR_ZONE_IS_SHUTDOWN: ::DWORD = 9621; pub const DNS_ERROR_ZONE_LOCKED_FOR_SIGNING: ::DWORD = 9622; pub const DNS_ERROR_DATAFILE_BASE: ::DWORD = 9650; pub const DNS_ERROR_PRIMARY_REQUIRES_DATAFILE: ::DWORD = 9651; pub const DNS_ERROR_INVALID_DATAFILE_NAME: ::DWORD = 9652; pub const DNS_ERROR_DATAFILE_OPEN_FAILURE: ::DWORD = 9653; pub const DNS_ERROR_FILE_WRITEBACK_FAILED: ::DWORD = 9654; pub const DNS_ERROR_DATAFILE_PARSING: ::DWORD = 9655; pub const DNS_ERROR_DATABASE_BASE: ::DWORD = 9700; pub const DNS_ERROR_RECORD_DOES_NOT_EXIST: ::DWORD = 9701; pub const DNS_ERROR_RECORD_FORMAT: ::DWORD = 9702; pub const DNS_ERROR_NODE_CREATION_FAILED: ::DWORD = 9703; pub const DNS_ERROR_UNKNOWN_RECORD_TYPE: ::DWORD = 9704; pub const DNS_ERROR_RECORD_TIMED_OUT: ::DWORD = 9705; pub const DNS_ERROR_NAME_NOT_IN_ZONE: ::DWORD = 9706; pub const DNS_ERROR_CNAME_LOOP: ::DWORD = 9707; pub const DNS_ERROR_NODE_IS_CNAME: ::DWORD = 9708; pub const DNS_ERROR_CNAME_COLLISION: ::DWORD = 9709; pub const DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT: ::DWORD = 9710; pub const DNS_ERROR_RECORD_ALREADY_EXISTS: ::DWORD = 9711; pub const DNS_ERROR_SECONDARY_DATA: ::DWORD = 9712; pub const DNS_ERROR_NO_CREATE_CACHE_DATA: ::DWORD = 9713; pub const DNS_ERROR_NAME_DOES_NOT_EXIST: ::DWORD = 9714; pub const DNS_WARNING_PTR_CREATE_FAILED: ::DWORD = 9715; pub const DNS_WARNING_DOMAIN_UNDELETED: ::DWORD = 9716; pub const DNS_ERROR_DS_UNAVAILABLE: ::DWORD = 9717; pub const DNS_ERROR_DS_ZONE_ALREADY_EXISTS: ::DWORD = 9718; pub const DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE: ::DWORD = 9719; pub const DNS_ERROR_NODE_IS_DNAME: ::DWORD = 9720; pub const DNS_ERROR_DNAME_COLLISION: ::DWORD = 9721; pub const DNS_ERROR_ALIAS_LOOP: ::DWORD = 9722; pub const DNS_ERROR_OPERATION_BASE: ::DWORD = 9750; pub const DNS_INFO_AXFR_COMPLETE: ::DWORD = 9751; pub const DNS_ERROR_AXFR: ::DWORD = 9752; pub const DNS_INFO_ADDED_LOCAL_WINS: ::DWORD = 9753; pub const DNS_ERROR_SECURE_BASE: ::DWORD = 9800; pub const DNS_STATUS_CONTINUE_NEEDED: ::DWORD = 9801; pub const DNS_ERROR_SETUP_BASE: ::DWORD = 9850; pub const DNS_ERROR_NO_TCPIP: ::DWORD = 9851; pub const DNS_ERROR_NO_DNS_SERVERS: ::DWORD = 9852; pub const DNS_ERROR_DP_BASE: ::DWORD = 9900; pub const DNS_ERROR_DP_DOES_NOT_EXIST: ::DWORD = 9901; pub const DNS_ERROR_DP_ALREADY_EXISTS: ::DWORD = 9902; pub const DNS_ERROR_DP_NOT_ENLISTED: ::DWORD = 9903; pub const DNS_ERROR_DP_ALREADY_ENLISTED: ::DWORD = 9904; pub const DNS_ERROR_DP_NOT_AVAILABLE: ::DWORD = 9905; pub const DNS_ERROR_DP_FSMO_ERROR: ::DWORD = 9906; pub const DNS_ERROR_ZONESCOPE_ALREADY_EXISTS: ::DWORD = 9951; pub const DNS_ERROR_ZONESCOPE_DOES_NOT_EXIST: ::DWORD = 9952; pub const DNS_ERROR_DEFAULT_ZONESCOPE: ::DWORD = 9953; pub const DNS_ERROR_INVALID_ZONESCOPE_NAME: ::DWORD = 9954; pub const DNS_ERROR_NOT_ALLOWED_WITH_ZONESCOPES: ::DWORD = 9955; pub const DNS_ERROR_LOAD_ZONESCOPE_FAILED: ::DWORD = 9956; pub const DNS_ERROR_ZONESCOPE_FILE_WRITEBACK_FAILED: ::DWORD = 9957; pub const DNS_ERROR_INVALID_SCOPE_NAME: ::DWORD = 9958; pub const DNS_ERROR_SCOPE_DOES_NOT_EXIST: ::DWORD = 9959; pub const DNS_ERROR_DEFAULT_SCOPE: ::DWORD = 9960; pub const DNS_ERROR_INVALID_SCOPE_OPERATION: ::DWORD = 9961; pub const DNS_ERROR_SCOPE_LOCKED: ::DWORD = 9962; pub const DNS_ERROR_SCOPE_ALREADY_EXISTS: ::DWORD = 9963; pub const WSABASEERR: ::DWORD = 10000; pub const WSAEINTR: ::DWORD = 10004; pub const WSAEBADF: ::DWORD = 10009; pub const WSAEACCES: ::DWORD = 10013; pub const WSAEFAULT: ::DWORD = 10014; pub const WSAEINVAL: ::DWORD = 10022; pub const WSAEMFILE: ::DWORD = 10024; pub const WSAEWOULDBLOCK: ::DWORD = 10035; pub const WSAEINPROGRESS: ::DWORD = 10036; pub const WSAEALREADY: ::DWORD = 10037; pub const WSAENOTSOCK: ::DWORD = 10038; pub const WSAEDESTADDRREQ: ::DWORD = 10039; pub const WSAEMSGSIZE: ::DWORD = 10040; pub const WSAEPROTOTYPE: ::DWORD = 10041; pub const WSAENOPROTOOPT: ::DWORD = 10042; pub const WSAEPROTONOSUPPORT: ::DWORD = 10043; pub const WSAESOCKTNOSUPPORT: ::DWORD = 10044; pub const WSAEOPNOTSUPP: ::DWORD = 10045; pub const WSAEPFNOSUPPORT: ::DWORD = 10046; pub const WSAEAFNOSUPPORT: ::DWORD = 10047; pub const WSAEADDRINUSE: ::DWORD = 10048; pub const WSAEADDRNOTAVAIL: ::DWORD = 10049; pub const WSAENETDOWN: ::DWORD = 10050; pub const WSAENETUNREACH: ::DWORD = 10051; pub const WSAENETRESET: ::DWORD = 10052; pub const WSAECONNABORTED: ::DWORD = 10053; pub const WSAECONNRESET: ::DWORD = 10054; pub const WSAENOBUFS: ::DWORD = 10055; pub const WSAEISCONN: ::DWORD = 10056; pub const WSAENOTCONN: ::DWORD = 10057; pub const WSAESHUTDOWN: ::DWORD = 10058; pub const WSAETOOMANYREFS: ::DWORD = 10059; pub const WSAETIMEDOUT: ::DWORD = 10060; pub const WSAECONNREFUSED: ::DWORD = 10061; pub const WSAELOOP: ::DWORD = 10062; pub const WSAENAMETOOLONG: ::DWORD = 10063; pub const WSAEHOSTDOWN: ::DWORD = 10064; pub const WSAEHOSTUNREACH: ::DWORD = 10065; pub const WSAENOTEMPTY: ::DWORD = 10066; pub const WSAEPROCLIM: ::DWORD = 10067; pub const WSAEUSERS: ::DWORD = 10068; pub const WSAEDQUOT: ::DWORD = 10069; pub const WSAESTALE: ::DWORD = 10070; pub const WSAEREMOTE: ::DWORD = 10071; pub const WSASYSNOTREADY: ::DWORD = 10091; pub const WSAVERNOTSUPPORTED: ::DWORD = 10092; pub const WSANOTINITIALISED: ::DWORD = 10093; pub const WSAEDISCON: ::DWORD = 10101; pub const WSAENOMORE: ::DWORD = 10102; pub const WSAECANCELLED: ::DWORD = 10103; pub const WSAEINVALIDPROCTABLE: ::DWORD = 10104; pub const WSAEINVALIDPROVIDER: ::DWORD = 10105; pub const WSAEPROVIDERFAILEDINIT: ::DWORD = 10106; pub const WSASYSCALLFAILURE: ::DWORD = 10107; pub const WSASERVICE_NOT_FOUND: ::DWORD = 10108; pub const WSATYPE_NOT_FOUND: ::DWORD = 10109; pub const WSA_E_NO_MORE: ::DWORD = 10110; pub const WSA_E_CANCELLED: ::DWORD = 10111; pub const WSAEREFUSED: ::DWORD = 10112; pub const WSAHOST_NOT_FOUND: ::DWORD = 11001; pub const WSATRY_AGAIN: ::DWORD = 11002; pub const WSANO_RECOVERY: ::DWORD = 11003; pub const WSANO_DATA: ::DWORD = 11004; pub const WSA_QOS_RECEIVERS: ::DWORD = 11005; pub const WSA_QOS_SENDERS: ::DWORD = 11006; pub const WSA_QOS_NO_SENDERS: ::DWORD = 11007; pub const WSA_QOS_NO_RECEIVERS: ::DWORD = 11008; pub const WSA_QOS_REQUEST_CONFIRMED: ::DWORD = 11009; pub const WSA_QOS_ADMISSION_FAILURE: ::DWORD = 11010; pub const WSA_QOS_POLICY_FAILURE: ::DWORD = 11011; pub const WSA_QOS_BAD_STYLE: ::DWORD = 11012; pub const WSA_QOS_BAD_OBJECT: ::DWORD = 11013; pub const WSA_QOS_TRAFFIC_CTRL_ERROR: ::DWORD = 11014; pub const WSA_QOS_GENERIC_ERROR: ::DWORD = 11015; pub const WSA_QOS_ESERVICETYPE: ::DWORD = 11016; pub const WSA_QOS_EFLOWSPEC: ::DWORD = 11017; pub const WSA_QOS_EPROVSPECBUF: ::DWORD = 11018; pub const WSA_QOS_EFILTERSTYLE: ::DWORD = 11019; pub const WSA_QOS_EFILTERTYPE: ::DWORD = 11020; pub const WSA_QOS_EFILTERCOUNT: ::DWORD = 11021; pub const WSA_QOS_EOBJLENGTH: ::DWORD = 11022; pub const WSA_QOS_EFLOWCOUNT: ::DWORD = 11023; pub const WSA_QOS_EUNKOWNPSOBJ: ::DWORD = 11024; pub const WSA_QOS_EPOLICYOBJ: ::DWORD = 11025; pub const WSA_QOS_EFLOWDESC: ::DWORD = 11026; pub const WSA_QOS_EPSFLOWSPEC: ::DWORD = 11027; pub const WSA_QOS_EPSFILTERSPEC: ::DWORD = 11028; pub const WSA_QOS_ESDMODEOBJ: ::DWORD = 11029; pub const WSA_QOS_ESHAPERATEOBJ: ::DWORD = 11030; pub const WSA_QOS_RESERVED_PETYPE: ::DWORD = 11031; pub const WSA_SECURE_HOST_NOT_FOUND: ::DWORD = 11032; pub const WSA_IPSEC_NAME_POLICY_ERROR: ::DWORD = 11033; pub const ERROR_IPSEC_QM_POLICY_EXISTS: ::DWORD = 13000; pub const ERROR_IPSEC_QM_POLICY_NOT_FOUND: ::DWORD = 13001; pub const ERROR_IPSEC_QM_POLICY_IN_USE: ::DWORD = 13002; pub const ERROR_IPSEC_MM_POLICY_EXISTS: ::DWORD = 13003; pub const ERROR_IPSEC_MM_POLICY_NOT_FOUND: ::DWORD = 13004; pub const ERROR_IPSEC_MM_POLICY_IN_USE: ::DWORD = 13005; pub const ERROR_IPSEC_MM_FILTER_EXISTS: ::DWORD = 13006; pub const ERROR_IPSEC_MM_FILTER_NOT_FOUND: ::DWORD = 13007; pub const ERROR_IPSEC_TRANSPORT_FILTER_EXISTS: ::DWORD = 13008; pub const ERROR_IPSEC_TRANSPORT_FILTER_NOT_FOUND: ::DWORD = 13009; pub const ERROR_IPSEC_MM_AUTH_EXISTS: ::DWORD = 13010; pub const ERROR_IPSEC_MM_AUTH_NOT_FOUND: ::DWORD = 13011; pub const ERROR_IPSEC_MM_AUTH_IN_USE: ::DWORD = 13012; pub const ERROR_IPSEC_DEFAULT_MM_POLICY_NOT_FOUND: ::DWORD = 13013; pub const ERROR_IPSEC_DEFAULT_MM_AUTH_NOT_FOUND: ::DWORD = 13014; pub const ERROR_IPSEC_DEFAULT_QM_POLICY_NOT_FOUND: ::DWORD = 13015; pub const ERROR_IPSEC_TUNNEL_FILTER_EXISTS: ::DWORD = 13016; pub const ERROR_IPSEC_TUNNEL_FILTER_NOT_FOUND: ::DWORD = 13017; pub const ERROR_IPSEC_MM_FILTER_PENDING_DELETION: ::DWORD = 13018; pub const ERROR_IPSEC_TRANSPORT_FILTER_PENDING_DELETION: ::DWORD = 13019; pub const ERROR_IPSEC_TUNNEL_FILTER_PENDING_DELETION: ::DWORD = 13020; pub const ERROR_IPSEC_MM_POLICY_PENDING_DELETION: ::DWORD = 13021; pub const ERROR_IPSEC_MM_AUTH_PENDING_DELETION: ::DWORD = 13022; pub const ERROR_IPSEC_QM_POLICY_PENDING_DELETION: ::DWORD = 13023; pub const WARNING_IPSEC_MM_POLICY_PRUNED: ::DWORD = 13024; pub const WARNING_IPSEC_QM_POLICY_PRUNED: ::DWORD = 13025; pub const ERROR_IPSEC_IKE_NEG_STATUS_BEGIN: ::DWORD = 13800; pub const ERROR_IPSEC_IKE_AUTH_FAIL: ::DWORD = 13801; pub const ERROR_IPSEC_IKE_ATTRIB_FAIL: ::DWORD = 13802; pub const ERROR_IPSEC_IKE_NEGOTIATION_PENDING: ::DWORD = 13803; pub const ERROR_IPSEC_IKE_GENERAL_PROCESSING_ERROR: ::DWORD = 13804; pub const ERROR_IPSEC_IKE_TIMED_OUT: ::DWORD = 13805; pub const ERROR_IPSEC_IKE_NO_CERT: ::DWORD = 13806; pub const ERROR_IPSEC_IKE_SA_DELETED: ::DWORD = 13807; pub const ERROR_IPSEC_IKE_SA_REAPED: ::DWORD = 13808; pub const ERROR_IPSEC_IKE_MM_ACQUIRE_DROP: ::DWORD = 13809; pub const ERROR_IPSEC_IKE_QM_ACQUIRE_DROP: ::DWORD = 13810; pub const ERROR_IPSEC_IKE_QUEUE_DROP_MM: ::DWORD = 13811; pub const ERROR_IPSEC_IKE_QUEUE_DROP_NO_MM: ::DWORD = 13812; pub const ERROR_IPSEC_IKE_DROP_NO_RESPONSE: ::DWORD = 13813; pub const ERROR_IPSEC_IKE_MM_DELAY_DROP: ::DWORD = 13814; pub const ERROR_IPSEC_IKE_QM_DELAY_DROP: ::DWORD = 13815; pub const ERROR_IPSEC_IKE_ERROR: ::DWORD = 13816; pub const ERROR_IPSEC_IKE_CRL_FAILED: ::DWORD = 13817; pub const ERROR_IPSEC_IKE_INVALID_KEY_USAGE: ::DWORD = 13818; pub const ERROR_IPSEC_IKE_INVALID_CERT_TYPE: ::DWORD = 13819; pub const ERROR_IPSEC_IKE_NO_PRIVATE_KEY: ::DWORD = 13820; pub const ERROR_IPSEC_IKE_SIMULTANEOUS_REKEY: ::DWORD = 13821; pub const ERROR_IPSEC_IKE_DH_FAIL: ::DWORD = 13822; pub const ERROR_IPSEC_IKE_CRITICAL_PAYLOAD_NOT_RECOGNIZED: ::DWORD = 13823; pub const ERROR_IPSEC_IKE_INVALID_HEADER: ::DWORD = 13824; pub const ERROR_IPSEC_IKE_NO_POLICY: ::DWORD = 13825; pub const ERROR_IPSEC_IKE_INVALID_SIGNATURE: ::DWORD = 13826; pub const ERROR_IPSEC_IKE_KERBEROS_ERROR: ::DWORD = 13827; pub const ERROR_IPSEC_IKE_NO_PUBLIC_KEY: ::DWORD = 13828; pub const ERROR_IPSEC_IKE_PROCESS_ERR: ::DWORD = 13829; pub const ERROR_IPSEC_IKE_PROCESS_ERR_SA: ::DWORD = 13830; pub const ERROR_IPSEC_IKE_PROCESS_ERR_PROP: ::DWORD = 13831; pub const ERROR_IPSEC_IKE_PROCESS_ERR_TRANS: ::DWORD = 13832; pub const ERROR_IPSEC_IKE_PROCESS_ERR_KE: ::DWORD = 13833; pub const ERROR_IPSEC_IKE_PROCESS_ERR_ID: ::DWORD = 13834; pub const ERROR_IPSEC_IKE_PROCESS_ERR_CERT: ::DWORD = 13835; pub const ERROR_IPSEC_IKE_PROCESS_ERR_CERT_REQ: ::DWORD = 13836; pub const ERROR_IPSEC_IKE_PROCESS_ERR_HASH: ::DWORD = 13837; pub const ERROR_IPSEC_IKE_PROCESS_ERR_SIG: ::DWORD = 13838; pub const ERROR_IPSEC_IKE_PROCESS_ERR_NONCE: ::DWORD = 13839; pub const ERROR_IPSEC_IKE_PROCESS_ERR_NOTIFY: ::DWORD = 13840; pub const ERROR_IPSEC_IKE_PROCESS_ERR_DELETE: ::DWORD = 13841; pub const ERROR_IPSEC_IKE_PROCESS_ERR_VENDOR: ::DWORD = 13842; pub const ERROR_IPSEC_IKE_INVALID_PAYLOAD: ::DWORD = 13843; pub const ERROR_IPSEC_IKE_LOAD_SOFT_SA: ::DWORD = 13844; pub const ERROR_IPSEC_IKE_SOFT_SA_TORN_DOWN: ::DWORD = 13845; pub const ERROR_IPSEC_IKE_INVALID_COOKIE: ::DWORD = 13846; pub const ERROR_IPSEC_IKE_NO_PEER_CERT: ::DWORD = 13847; pub const ERROR_IPSEC_IKE_PEER_CRL_FAILED: ::DWORD = 13848; pub const ERROR_IPSEC_IKE_POLICY_CHANGE: ::DWORD = 13849; pub const ERROR_IPSEC_IKE_NO_MM_POLICY: ::DWORD = 13850; pub const ERROR_IPSEC_IKE_NOTCBPRIV: ::DWORD = 13851; pub const ERROR_IPSEC_IKE_SECLOADFAIL: ::DWORD = 13852; pub const ERROR_IPSEC_IKE_FAILSSPINIT: ::DWORD = 13853; pub const ERROR_IPSEC_IKE_FAILQUERYSSP: ::DWORD = 13854; pub const ERROR_IPSEC_IKE_SRVACQFAIL: ::DWORD = 13855; pub const ERROR_IPSEC_IKE_SRVQUERYCRED: ::DWORD = 13856; pub const ERROR_IPSEC_IKE_GETSPIFAIL: ::DWORD = 13857; pub const ERROR_IPSEC_IKE_INVALID_FILTER: ::DWORD = 13858; pub const ERROR_IPSEC_IKE_OUT_OF_MEMORY: ::DWORD = 13859; pub const ERROR_IPSEC_IKE_ADD_UPDATE_KEY_FAILED: ::DWORD = 13860; pub const ERROR_IPSEC_IKE_INVALID_POLICY: ::DWORD = 13861; pub const ERROR_IPSEC_IKE_UNKNOWN_DOI: ::DWORD = 13862; pub const ERROR_IPSEC_IKE_INVALID_SITUATION: ::DWORD = 13863; pub const ERROR_IPSEC_IKE_DH_FAILURE: ::DWORD = 13864; pub const ERROR_IPSEC_IKE_INVALID_GROUP: ::DWORD = 13865; pub const ERROR_IPSEC_IKE_ENCRYPT: ::DWORD = 13866; pub const ERROR_IPSEC_IKE_DECRYPT: ::DWORD = 13867; pub const ERROR_IPSEC_IKE_POLICY_MATCH: ::DWORD = 13868; pub const ERROR_IPSEC_IKE_UNSUPPORTED_ID: ::DWORD = 13869; pub const ERROR_IPSEC_IKE_INVALID_HASH: ::DWORD = 13870; pub const ERROR_IPSEC_IKE_INVALID_HASH_ALG: ::DWORD = 13871; pub const ERROR_IPSEC_IKE_INVALID_HASH_SIZE: ::DWORD = 13872; pub const ERROR_IPSEC_IKE_INVALID_ENCRYPT_ALG: ::DWORD = 13873; pub const ERROR_IPSEC_IKE_INVALID_AUTH_ALG: ::DWORD = 13874; pub const ERROR_IPSEC_IKE_INVALID_SIG: ::DWORD = 13875; pub const ERROR_IPSEC_IKE_LOAD_FAILED: ::DWORD = 13876; pub const ERROR_IPSEC_IKE_RPC_DELETE: ::DWORD = 13877; pub const ERROR_IPSEC_IKE_BENIGN_REINIT: ::DWORD = 13878; pub const ERROR_IPSEC_IKE_INVALID_RESPONDER_LIFETIME_NOTIFY: ::DWORD = 13879; pub const ERROR_IPSEC_IKE_INVALID_MAJOR_VERSION: ::DWORD = 13880; pub const ERROR_IPSEC_IKE_INVALID_CERT_KEYLEN: ::DWORD = 13881; pub const ERROR_IPSEC_IKE_MM_LIMIT: ::DWORD = 13882; pub const ERROR_IPSEC_IKE_NEGOTIATION_DISABLED: ::DWORD = 13883; pub const ERROR_IPSEC_IKE_QM_LIMIT: ::DWORD = 13884; pub const ERROR_IPSEC_IKE_MM_EXPIRED: ::DWORD = 13885; pub const ERROR_IPSEC_IKE_PEER_MM_ASSUMED_INVALID: ::DWORD = 13886; pub const ERROR_IPSEC_IKE_CERT_CHAIN_POLICY_MISMATCH: ::DWORD = 13887; pub const ERROR_IPSEC_IKE_UNEXPECTED_MESSAGE_ID: ::DWORD = 13888; pub const ERROR_IPSEC_IKE_INVALID_AUTH_PAYLOAD: ::DWORD = 13889; pub const ERROR_IPSEC_IKE_DOS_COOKIE_SENT: ::DWORD = 13890; pub const ERROR_IPSEC_IKE_SHUTTING_DOWN: ::DWORD = 13891; pub const ERROR_IPSEC_IKE_CGA_AUTH_FAILED: ::DWORD = 13892; pub const ERROR_IPSEC_IKE_PROCESS_ERR_NATOA: ::DWORD = 13893; pub const ERROR_IPSEC_IKE_INVALID_MM_FOR_QM: ::DWORD = 13894; pub const ERROR_IPSEC_IKE_QM_EXPIRED: ::DWORD = 13895; pub const ERROR_IPSEC_IKE_TOO_MANY_FILTERS: ::DWORD = 13896; pub const ERROR_IPSEC_IKE_NEG_STATUS_END: ::DWORD = 13897; pub const ERROR_IPSEC_IKE_KILL_DUMMY_NAP_TUNNEL: ::DWORD = 13898; pub const ERROR_IPSEC_IKE_INNER_IP_ASSIGNMENT_FAILURE: ::DWORD = 13899; pub const ERROR_IPSEC_IKE_REQUIRE_CP_PAYLOAD_MISSING: ::DWORD = 13900; pub const ERROR_IPSEC_KEY_MODULE_IMPERSONATION_NEGOTIATION_PENDING: ::DWORD = 13901; pub const ERROR_IPSEC_IKE_COEXISTENCE_SUPPRESS: ::DWORD = 13902; pub const ERROR_IPSEC_IKE_RATELIMIT_DROP: ::DWORD = 13903; pub const ERROR_IPSEC_IKE_PEER_DOESNT_SUPPORT_MOBIKE: ::DWORD = 13904; pub const ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE: ::DWORD = 13905; pub const ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_FAILURE: ::DWORD = 13906; pub const ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE_WITH_OPTIONAL_RETRY: ::DWORD = 13907; pub const ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_AND_CERTMAP_FAILURE: ::DWORD = 13908; pub const ERROR_IPSEC_IKE_NEG_STATUS_EXTENDED_END: ::DWORD = 13909; pub const ERROR_IPSEC_BAD_SPI: ::DWORD = 13910; pub const ERROR_IPSEC_SA_LIFETIME_EXPIRED: ::DWORD = 13911; pub const ERROR_IPSEC_WRONG_SA: ::DWORD = 13912; pub const ERROR_IPSEC_REPLAY_CHECK_FAILED: ::DWORD = 13913; pub const ERROR_IPSEC_INVALID_PACKET: ::DWORD = 13914; pub const ERROR_IPSEC_INTEGRITY_CHECK_FAILED: ::DWORD = 13915; pub const ERROR_IPSEC_CLEAR_TEXT_DROP: ::DWORD = 13916; pub const ERROR_IPSEC_AUTH_FIREWALL_DROP: ::DWORD = 13917; pub const ERROR_IPSEC_THROTTLE_DROP: ::DWORD = 13918; pub const ERROR_IPSEC_DOSP_BLOCK: ::DWORD = 13925; pub const ERROR_IPSEC_DOSP_RECEIVED_MULTICAST: ::DWORD = 13926; pub const ERROR_IPSEC_DOSP_INVALID_PACKET: ::DWORD = 13927; pub const ERROR_IPSEC_DOSP_STATE_LOOKUP_FAILED: ::DWORD = 13928; pub const ERROR_IPSEC_DOSP_MAX_ENTRIES: ::DWORD = 13929; pub const ERROR_IPSEC_DOSP_KEYMOD_NOT_ALLOWED: ::DWORD = 13930; pub const ERROR_IPSEC_DOSP_NOT_INSTALLED: ::DWORD = 13931; pub const ERROR_IPSEC_DOSP_MAX_PER_IP_RATELIMIT_QUEUES: ::DWORD = 13932; pub const ERROR_SXS_SECTION_NOT_FOUND: ::DWORD = 14000; pub const ERROR_SXS_CANT_GEN_ACTCTX: ::DWORD = 14001; pub const ERROR_SXS_INVALID_ACTCTXDATA_FORMAT: ::DWORD = 14002; pub const ERROR_SXS_ASSEMBLY_NOT_FOUND: ::DWORD = 14003; pub const ERROR_SXS_MANIFEST_FORMAT_ERROR: ::DWORD = 14004; pub const ERROR_SXS_MANIFEST_PARSE_ERROR: ::DWORD = 14005; pub const ERROR_SXS_ACTIVATION_CONTEXT_DISABLED: ::DWORD = 14006; pub const ERROR_SXS_KEY_NOT_FOUND: ::DWORD = 14007; pub const ERROR_SXS_VERSION_CONFLICT: ::DWORD = 14008; pub const ERROR_SXS_WRONG_SECTION_TYPE: ::DWORD = 14009; pub const ERROR_SXS_THREAD_QUERIES_DISABLED: ::DWORD = 14010; pub const ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET: ::DWORD = 14011; pub const ERROR_SXS_UNKNOWN_ENCODING_GROUP: ::DWORD = 14012; pub const ERROR_SXS_UNKNOWN_ENCODING: ::DWORD = 14013; pub const ERROR_SXS_INVALID_XML_NAMESPACE_URI: ::DWORD = 14014; pub const ERROR_SXS_ROOT_MANIFEST_DEPENDENCY_NOT_INSTALLED: ::DWORD = 14015; pub const ERROR_SXS_LEAF_MANIFEST_DEPENDENCY_NOT_INSTALLED: ::DWORD = 14016; pub const ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE: ::DWORD = 14017; pub const ERROR_SXS_MANIFEST_MISSING_REQUIRED_DEFAULT_NAMESPACE: ::DWORD = 14018; pub const ERROR_SXS_MANIFEST_INVALID_REQUIRED_DEFAULT_NAMESPACE: ::DWORD = 14019; pub const ERROR_SXS_PRIVATE_MANIFEST_CROSS_PATH_WITH_REPARSE_POINT: ::DWORD = 14020; pub const ERROR_SXS_DUPLICATE_DLL_NAME: ::DWORD = 14021; pub const ERROR_SXS_DUPLICATE_WINDOWCLASS_NAME: ::DWORD = 14022; pub const ERROR_SXS_DUPLICATE_CLSID: ::DWORD = 14023; pub const ERROR_SXS_DUPLICATE_IID: ::DWORD = 14024; pub const ERROR_SXS_DUPLICATE_TLBID: ::DWORD = 14025; pub const ERROR_SXS_DUPLICATE_PROGID: ::DWORD = 14026; pub const ERROR_SXS_DUPLICATE_ASSEMBLY_NAME: ::DWORD = 14027; pub const ERROR_SXS_FILE_HASH_MISMATCH: ::DWORD = 14028; pub const ERROR_SXS_POLICY_PARSE_ERROR: ::DWORD = 14029; pub const ERROR_SXS_XML_E_MISSINGQUOTE: ::DWORD = 14030; pub const ERROR_SXS_XML_E_COMMENTSYNTAX: ::DWORD = 14031; pub const ERROR_SXS_XML_E_BADSTARTNAMECHAR: ::DWORD = 14032; pub const ERROR_SXS_XML_E_BADNAMECHAR: ::DWORD = 14033; pub const ERROR_SXS_XML_E_BADCHARINSTRING: ::DWORD = 14034; pub const ERROR_SXS_XML_E_XMLDECLSYNTAX: ::DWORD = 14035; pub const ERROR_SXS_XML_E_BADCHARDATA: ::DWORD = 14036; pub const ERROR_SXS_XML_E_MISSINGWHITESPACE: ::DWORD = 14037; pub const ERROR_SXS_XML_E_EXPECTINGTAGEND: ::DWORD = 14038; pub const ERROR_SXS_XML_E_MISSINGSEMICOLON: ::DWORD = 14039; pub const ERROR_SXS_XML_E_UNBALANCEDPAREN: ::DWORD = 14040; pub const ERROR_SXS_XML_E_INTERNALERROR: ::DWORD = 14041; pub const ERROR_SXS_XML_E_UNEXPECTED_WHITESPACE: ::DWORD = 14042; pub const ERROR_SXS_XML_E_INCOMPLETE_ENCODING: ::DWORD = 14043; pub const ERROR_SXS_XML_E_MISSING_PAREN: ::DWORD = 14044; pub const ERROR_SXS_XML_E_EXPECTINGCLOSEQUOTE: ::DWORD = 14045; pub const ERROR_SXS_XML_E_MULTIPLE_COLONS: ::DWORD = 14046; pub const ERROR_SXS_XML_E_INVALID_DECIMAL: ::DWORD = 14047; pub const ERROR_SXS_XML_E_INVALID_HEXIDECIMAL: ::DWORD = 14048; pub const ERROR_SXS_XML_E_INVALID_UNICODE: ::DWORD = 14049; pub const ERROR_SXS_XML_E_WHITESPACEORQUESTIONMARK: ::DWORD = 14050; pub const ERROR_SXS_XML_E_UNEXPECTEDENDTAG: ::DWORD = 14051; pub const ERROR_SXS_XML_E_UNCLOSEDTAG: ::DWORD = 14052; pub const ERROR_SXS_XML_E_DUPLICATEATTRIBUTE: ::DWORD = 14053; pub const ERROR_SXS_XML_E_MULTIPLEROOTS: ::DWORD = 14054; pub const ERROR_SXS_XML_E_INVALIDATROOTLEVEL: ::DWORD = 14055; pub const ERROR_SXS_XML_E_BADXMLDECL: ::DWORD = 14056; pub const ERROR_SXS_XML_E_MISSINGROOT: ::DWORD = 14057; pub const ERROR_SXS_XML_E_UNEXPECTEDEOF: ::DWORD = 14058; pub const ERROR_SXS_XML_E_BADPEREFINSUBSET: ::DWORD = 14059; pub const ERROR_SXS_XML_E_UNCLOSEDSTARTTAG: ::DWORD = 14060; pub const ERROR_SXS_XML_E_UNCLOSEDENDTAG: ::DWORD = 14061; pub const ERROR_SXS_XML_E_UNCLOSEDSTRING: ::DWORD = 14062; pub const ERROR_SXS_XML_E_UNCLOSEDCOMMENT: ::DWORD = 14063; pub const ERROR_SXS_XML_E_UNCLOSEDDECL: ::DWORD = 14064; pub const ERROR_SXS_XML_E_UNCLOSEDCDATA: ::DWORD = 14065; pub const ERROR_SXS_XML_E_RESERVEDNAMESPACE: ::DWORD = 14066; pub const ERROR_SXS_XML_E_INVALIDENCODING: ::DWORD = 14067; pub const ERROR_SXS_XML_E_INVALIDSWITCH: ::DWORD = 14068; pub const ERROR_SXS_XML_E_BADXMLCASE: ::DWORD = 14069; pub const ERROR_SXS_XML_E_INVALID_STANDALONE: ::DWORD = 14070; pub const ERROR_SXS_XML_E_UNEXPECTED_STANDALONE: ::DWORD = 14071; pub const ERROR_SXS_XML_E_INVALID_VERSION: ::DWORD = 14072; pub const ERROR_SXS_XML_E_MISSINGEQUALS: ::DWORD = 14073; pub const ERROR_SXS_PROTECTION_RECOVERY_FAILED: ::DWORD = 14074; pub const ERROR_SXS_PROTECTION_PUBLIC_KEY_TOO_SHORT: ::DWORD = 14075; pub const ERROR_SXS_PROTECTION_CATALOG_NOT_VALID: ::DWORD = 14076; pub const ERROR_SXS_UNTRANSLATABLE_HRESULT: ::DWORD = 14077; pub const ERROR_SXS_PROTECTION_CATALOG_FILE_MISSING: ::DWORD = 14078; pub const ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE: ::DWORD = 14079; pub const ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME: ::DWORD = 14080; pub const ERROR_SXS_ASSEMBLY_MISSING: ::DWORD = 14081; pub const ERROR_SXS_CORRUPT_ACTIVATION_STACK: ::DWORD = 14082; pub const ERROR_SXS_CORRUPTION: ::DWORD = 14083; pub const ERROR_SXS_EARLY_DEACTIVATION: ::DWORD = 14084; pub const ERROR_SXS_INVALID_DEACTIVATION: ::DWORD = 14085; pub const ERROR_SXS_MULTIPLE_DEACTIVATION: ::DWORD = 14086; pub const ERROR_SXS_PROCESS_TERMINATION_REQUESTED: ::DWORD = 14087; pub const ERROR_SXS_RELEASE_ACTIVATION_CONTEXT: ::DWORD = 14088; pub const ERROR_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY: ::DWORD = 14089; pub const ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE: ::DWORD = 14090; pub const ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME: ::DWORD = 14091; pub const ERROR_SXS_IDENTITY_DUPLICATE_ATTRIBUTE: ::DWORD = 14092; pub const ERROR_SXS_IDENTITY_PARSE_ERROR: ::DWORD = 14093; pub const ERROR_MALFORMED_SUBSTITUTION_STRING: ::DWORD = 14094; pub const ERROR_SXS_INCORRECT_PUBLIC_KEY_TOKEN: ::DWORD = 14095; pub const ERROR_UNMAPPED_SUBSTITUTION_STRING: ::DWORD = 14096; pub const ERROR_SXS_ASSEMBLY_NOT_LOCKED: ::DWORD = 14097; pub const ERROR_SXS_COMPONENT_STORE_CORRUPT: ::DWORD = 14098; pub const ERROR_ADVANCED_INSTALLER_FAILED: ::DWORD = 14099; pub const ERROR_XML_ENCODING_MISMATCH: ::DWORD = 14100; pub const ERROR_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT: ::DWORD = 14101; pub const ERROR_SXS_IDENTITIES_DIFFERENT: ::DWORD = 14102; pub const ERROR_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT: ::DWORD = 14103; pub const ERROR_SXS_FILE_NOT_PART_OF_ASSEMBLY: ::DWORD = 14104; pub const ERROR_SXS_MANIFEST_TOO_BIG: ::DWORD = 14105; pub const ERROR_SXS_SETTING_NOT_REGISTERED: ::DWORD = 14106; pub const ERROR_SXS_TRANSACTION_CLOSURE_INCOMPLETE: ::DWORD = 14107; pub const ERROR_SMI_PRIMITIVE_INSTALLER_FAILED: ::DWORD = 14108; pub const ERROR_GENERIC_COMMAND_FAILED: ::DWORD = 14109; pub const ERROR_SXS_FILE_HASH_MISSING: ::DWORD = 14110; pub const ERROR_EVT_INVALID_CHANNEL_PATH: ::DWORD = 15000; pub const ERROR_EVT_INVALID_QUERY: ::DWORD = 15001; pub const ERROR_EVT_PUBLISHER_METADATA_NOT_FOUND: ::DWORD = 15002; pub const ERROR_EVT_EVENT_TEMPLATE_NOT_FOUND: ::DWORD = 15003; pub const ERROR_EVT_INVALID_PUBLISHER_NAME: ::DWORD = 15004; pub const ERROR_EVT_INVALID_EVENT_DATA: ::DWORD = 15005; pub const ERROR_EVT_CHANNEL_NOT_FOUND: ::DWORD = 15007; pub const ERROR_EVT_MALFORMED_XML_TEXT: ::DWORD = 15008; pub const ERROR_EVT_SUBSCRIPTION_TO_DIRECT_CHANNEL: ::DWORD = 15009; pub const ERROR_EVT_CONFIGURATION_ERROR: ::DWORD = 15010; pub const ERROR_EVT_QUERY_RESULT_STALE: ::DWORD = 15011; pub const ERROR_EVT_QUERY_RESULT_INVALID_POSITION: ::DWORD = 15012; pub const ERROR_EVT_NON_VALIDATING_MSXML: ::DWORD = 15013; pub const ERROR_EVT_FILTER_ALREADYSCOPED: ::DWORD = 15014; pub const ERROR_EVT_FILTER_NOTELTSET: ::DWORD = 15015; pub const ERROR_EVT_FILTER_INVARG: ::DWORD = 15016; pub const ERROR_EVT_FILTER_INVTEST: ::DWORD = 15017; pub const ERROR_EVT_FILTER_INVTYPE: ::DWORD = 15018; pub const ERROR_EVT_FILTER_PARSEERR: ::DWORD = 15019; pub const ERROR_EVT_FILTER_UNSUPPORTEDOP: ::DWORD = 15020; pub const ERROR_EVT_FILTER_UNEXPECTEDTOKEN: ::DWORD = 15021; pub const ERROR_EVT_INVALID_OPERATION_OVER_ENABLED_DIRECT_CHANNEL: ::DWORD = 15022; pub const ERROR_EVT_INVALID_CHANNEL_PROPERTY_VALUE: ::DWORD = 15023; pub const ERROR_EVT_INVALID_PUBLISHER_PROPERTY_VALUE: ::DWORD = 15024; pub const ERROR_EVT_CHANNEL_CANNOT_ACTIVATE: ::DWORD = 15025; pub const ERROR_EVT_FILTER_TOO_COMPLEX: ::DWORD = 15026; pub const ERROR_EVT_MESSAGE_NOT_FOUND: ::DWORD = 15027; pub const ERROR_EVT_MESSAGE_ID_NOT_FOUND: ::DWORD = 15028; pub const ERROR_EVT_UNRESOLVED_VALUE_INSERT: ::DWORD = 15029; pub const ERROR_EVT_UNRESOLVED_PARAMETER_INSERT: ::DWORD = 15030; pub const ERROR_EVT_MAX_INSERTS_REACHED: ::DWORD = 15031; pub const ERROR_EVT_EVENT_DEFINITION_NOT_FOUND: ::DWORD = 15032; pub const ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND: ::DWORD = 15033; pub const ERROR_EVT_VERSION_TOO_OLD: ::DWORD = 15034; pub const ERROR_EVT_VERSION_TOO_NEW: ::DWORD = 15035; pub const ERROR_EVT_CANNOT_OPEN_CHANNEL_OF_QUERY: ::DWORD = 15036; pub const ERROR_EVT_PUBLISHER_DISABLED: ::DWORD = 15037; pub const ERROR_EVT_FILTER_OUT_OF_RANGE: ::DWORD = 15038; pub const ERROR_EC_SUBSCRIPTION_CANNOT_ACTIVATE: ::DWORD = 15080; pub const ERROR_EC_LOG_DISABLED: ::DWORD = 15081; pub const ERROR_EC_CIRCULAR_FORWARDING: ::DWORD = 15082; pub const ERROR_EC_CREDSTORE_FULL: ::DWORD = 15083; pub const ERROR_EC_CRED_NOT_FOUND: ::DWORD = 15084; pub const ERROR_EC_NO_ACTIVE_CHANNEL: ::DWORD = 15085; pub const ERROR_MUI_FILE_NOT_FOUND: ::DWORD = 15100; pub const ERROR_MUI_INVALID_FILE: ::DWORD = 15101; pub const ERROR_MUI_INVALID_RC_CONFIG: ::DWORD = 15102; pub const ERROR_MUI_INVALID_LOCALE_NAME: ::DWORD = 15103; pub const ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME: ::DWORD = 15104; pub const ERROR_MUI_FILE_NOT_LOADED: ::DWORD = 15105; pub const ERROR_RESOURCE_ENUM_USER_STOP: ::DWORD = 15106; pub const ERROR_MUI_INTLSETTINGS_UILANG_NOT_INSTALLED: ::DWORD = 15107; pub const ERROR_MUI_INTLSETTINGS_INVALID_LOCALE_NAME: ::DWORD = 15108; pub const ERROR_MRM_RUNTIME_NO_DEFAULT_OR_NEUTRAL_RESOURCE: ::DWORD = 15110; pub const ERROR_MRM_INVALID_PRICONFIG: ::DWORD = 15111; pub const ERROR_MRM_INVALID_FILE_TYPE: ::DWORD = 15112; pub const ERROR_MRM_UNKNOWN_QUALIFIER: ::DWORD = 15113; pub const ERROR_MRM_INVALID_QUALIFIER_VALUE: ::DWORD = 15114; pub const ERROR_MRM_NO_CANDIDATE: ::DWORD = 15115; pub const ERROR_MRM_NO_MATCH_OR_DEFAULT_CANDIDATE: ::DWORD = 15116; pub const ERROR_MRM_RESOURCE_TYPE_MISMATCH: ::DWORD = 15117; pub const ERROR_MRM_DUPLICATE_MAP_NAME: ::DWORD = 15118; pub const ERROR_MRM_DUPLICATE_ENTRY: ::DWORD = 15119; pub const ERROR_MRM_INVALID_RESOURCE_IDENTIFIER: ::DWORD = 15120; pub const ERROR_MRM_FILEPATH_TOO_LONG: ::DWORD = 15121; pub const ERROR_MRM_UNSUPPORTED_DIRECTORY_TYPE: ::DWORD = 15122; pub const ERROR_MRM_INVALID_PRI_FILE: ::DWORD = 15126; pub const ERROR_MRM_NAMED_RESOURCE_NOT_FOUND: ::DWORD = 15127; pub const ERROR_MRM_MAP_NOT_FOUND: ::DWORD = 15135; pub const ERROR_MRM_UNSUPPORTED_PROFILE_TYPE: ::DWORD = 15136; pub const ERROR_MRM_INVALID_QUALIFIER_OPERATOR: ::DWORD = 15137; pub const ERROR_MRM_INDETERMINATE_QUALIFIER_VALUE: ::DWORD = 15138; pub const ERROR_MRM_AUTOMERGE_ENABLED: ::DWORD = 15139; pub const ERROR_MRM_TOO_MANY_RESOURCES: ::DWORD = 15140; pub const ERROR_MRM_UNSUPPORTED_FILE_TYPE_FOR_MERGE: ::DWORD = 15141; pub const ERROR_MRM_UNSUPPORTED_FILE_TYPE_FOR_LOAD_UNLOAD_PRI_FILE: ::DWORD = 15142; pub const ERROR_MRM_NO_CURRENT_VIEW_ON_THREAD: ::DWORD = 15143; pub const ERROR_DIFFERENT_PROFILE_RESOURCE_MANAGER_EXIST: ::DWORD = 15144; pub const ERROR_OPERATION_NOT_ALLOWED_FROM_SYSTEM_COMPONENT: ::DWORD = 15145; pub const ERROR_MRM_DIRECT_REF_TO_NON_DEFAULT_RESOURCE: ::DWORD = 15146; pub const ERROR_MRM_GENERATION_COUNT_MISMATCH: ::DWORD = 15147; pub const ERROR_MCA_INVALID_CAPABILITIES_STRING: ::DWORD = 15200; pub const ERROR_MCA_INVALID_VCP_VERSION: ::DWORD = 15201; pub const ERROR_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION: ::DWORD = 15202; pub const ERROR_MCA_MCCS_VERSION_MISMATCH: ::DWORD = 15203; pub const ERROR_MCA_UNSUPPORTED_MCCS_VERSION: ::DWORD = 15204; pub const ERROR_MCA_INTERNAL_ERROR: ::DWORD = 15205; pub const ERROR_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED: ::DWORD = 15206; pub const ERROR_MCA_UNSUPPORTED_COLOR_TEMPERATURE: ::DWORD = 15207; pub const ERROR_AMBIGUOUS_SYSTEM_DEVICE: ::DWORD = 15250; pub const ERROR_SYSTEM_DEVICE_NOT_FOUND: ::DWORD = 15299; pub const ERROR_HASH_NOT_SUPPORTED: ::DWORD = 15300; pub const ERROR_HASH_NOT_PRESENT: ::DWORD = 15301; pub const ERROR_SECONDARY_IC_PROVIDER_NOT_REGISTERED: ::DWORD = 15321; pub const ERROR_GPIO_CLIENT_INFORMATION_INVALID: ::DWORD = 15322; pub const ERROR_GPIO_VERSION_NOT_SUPPORTED: ::DWORD = 15323; pub const ERROR_GPIO_INVALID_REGISTRATION_PACKET: ::DWORD = 15324; pub const ERROR_GPIO_OPERATION_DENIED: ::DWORD = 15325; pub const ERROR_GPIO_INCOMPATIBLE_CONNECT_MODE: ::DWORD = 15326; pub const ERROR_GPIO_INTERRUPT_ALREADY_UNMASKED: ::DWORD = 15327; pub const ERROR_CANNOT_SWITCH_RUNLEVEL: ::DWORD = 15400; pub const ERROR_INVALID_RUNLEVEL_SETTING: ::DWORD = 15401; pub const ERROR_RUNLEVEL_SWITCH_TIMEOUT: ::DWORD = 15402; pub const ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT: ::DWORD = 15403; pub const ERROR_RUNLEVEL_SWITCH_IN_PROGRESS: ::DWORD = 15404; pub const ERROR_SERVICES_FAILED_AUTOSTART: ::DWORD = 15405; pub const ERROR_COM_TASK_STOP_PENDING: ::DWORD = 15501; pub const ERROR_INSTALL_OPEN_PACKAGE_FAILED: ::DWORD = 15600; pub const ERROR_INSTALL_PACKAGE_NOT_FOUND: ::DWORD = 15601; pub const ERROR_INSTALL_INVALID_PACKAGE: ::DWORD = 15602; pub const ERROR_INSTALL_RESOLVE_DEPENDENCY_FAILED: ::DWORD = 15603; pub const ERROR_INSTALL_OUT_OF_DISK_SPACE: ::DWORD = 15604; pub const ERROR_INSTALL_NETWORK_FAILURE: ::DWORD = 15605; pub const ERROR_INSTALL_REGISTRATION_FAILURE: ::DWORD = 15606; pub const ERROR_INSTALL_DEREGISTRATION_FAILURE: ::DWORD = 15607; pub const ERROR_INSTALL_CANCEL: ::DWORD = 15608; pub const ERROR_INSTALL_FAILED: ::DWORD = 15609; pub const ERROR_REMOVE_FAILED: ::DWORD = 15610; pub const ERROR_PACKAGE_ALREADY_EXISTS: ::DWORD = 15611; pub const ERROR_NEEDS_REMEDIATION: ::DWORD = 15612; pub const ERROR_INSTALL_PREREQUISITE_FAILED: ::DWORD = 15613; pub const ERROR_PACKAGE_REPOSITORY_CORRUPTED: ::DWORD = 15614; pub const ERROR_INSTALL_POLICY_FAILURE: ::DWORD = 15615; pub const ERROR_PACKAGE_UPDATING: ::DWORD = 15616; pub const ERROR_DEPLOYMENT_BLOCKED_BY_POLICY: ::DWORD = 15617; pub const ERROR_PACKAGES_IN_USE: ::DWORD = 15618; pub const ERROR_RECOVERY_FILE_CORRUPT: ::DWORD = 15619; pub const ERROR_INVALID_STAGED_SIGNATURE: ::DWORD = 15620; pub const ERROR_DELETING_EXISTING_APPLICATIONDATA_STORE_FAILED: ::DWORD = 15621; pub const ERROR_INSTALL_PACKAGE_DOWNGRADE: ::DWORD = 15622; pub const ERROR_SYSTEM_NEEDS_REMEDIATION: ::DWORD = 15623; pub const ERROR_APPX_INTEGRITY_FAILURE_CLR_NGEN: ::DWORD = 15624; pub const ERROR_RESILIENCY_FILE_CORRUPT: ::DWORD = 15625; pub const ERROR_INSTALL_FIREWALL_SERVICE_NOT_RUNNING: ::DWORD = 15626; pub const APPMODEL_ERROR_NO_PACKAGE: ::DWORD = 15700; pub const APPMODEL_ERROR_PACKAGE_RUNTIME_CORRUPT: ::DWORD = 15701; pub const APPMODEL_ERROR_PACKAGE_IDENTITY_CORRUPT: ::DWORD = 15702; pub const APPMODEL_ERROR_NO_APPLICATION: ::DWORD = 15703; pub const APPMODEL_ERROR_DYNAMIC_PROPERTY_READ_FAILED: ::DWORD = 15704; pub const APPMODEL_ERROR_DYNAMIC_PROPERTY_INVALID: ::DWORD = 15705; pub const ERROR_STATE_LOAD_STORE_FAILED: ::DWORD = 15800; pub const ERROR_STATE_GET_VERSION_FAILED: ::DWORD = 15801; pub const ERROR_STATE_SET_VERSION_FAILED: ::DWORD = 15802; pub const ERROR_STATE_STRUCTURED_RESET_FAILED: ::DWORD = 15803; pub const ERROR_STATE_OPEN_CONTAINER_FAILED: ::DWORD = 15804; pub const ERROR_STATE_CREATE_CONTAINER_FAILED: ::DWORD = 15805; pub const ERROR_STATE_DELETE_CONTAINER_FAILED: ::DWORD = 15806; pub const ERROR_STATE_READ_SETTING_FAILED: ::DWORD = 15807; pub const ERROR_STATE_WRITE_SETTING_FAILED: ::DWORD = 15808; pub const ERROR_STATE_DELETE_SETTING_FAILED: ::DWORD = 15809; pub const ERROR_STATE_QUERY_SETTING_FAILED: ::DWORD = 15810; pub const ERROR_STATE_READ_COMPOSITE_SETTING_FAILED: ::DWORD = 15811; pub const ERROR_STATE_WRITE_COMPOSITE_SETTING_FAILED: ::DWORD = 15812; pub const ERROR_STATE_ENUMERATE_CONTAINER_FAILED: ::DWORD = 15813; pub const ERROR_STATE_ENUMERATE_SETTINGS_FAILED: ::DWORD = 15814; pub const ERROR_STATE_COMPOSITE_SETTING_VALUE_SIZE_LIMIT_EXCEEDED: ::DWORD = 15815; pub const ERROR_STATE_SETTING_VALUE_SIZE_LIMIT_EXCEEDED: ::DWORD = 15816; pub const ERROR_STATE_SETTING_NAME_SIZE_LIMIT_EXCEEDED: ::DWORD = 15817; pub const ERROR_STATE_CONTAINER_NAME_SIZE_LIMIT_EXCEEDED: ::DWORD = 15818; pub const ERROR_API_UNAVAILABLE: ::DWORD = 15841; pub const STORE_ERROR_UNLICENSED: ::DWORD = 15861; pub const STORE_ERROR_UNLICENSED_USER: ::DWORD = 15862; pub const STORE_ERROR_PENDING_COM_TRANSACTION: ::DWORD = 15863; pub const STORE_ERROR_LICENSE_REVOKED: ::DWORD = 15864; pub const SEVERITY_SUCCESS: HRESULT = 0; pub const SEVERITY_ERROR: HRESULT = 1; #[inline] pub fn MAKE_HRESULT(sev: HRESULT, fac: HRESULT, code: HRESULT) -> HRESULT { (sev << 31) | (fac << 16) | code } pub type HRESULT = ::c_long; pub const NOERROR: HRESULT = 0; pub const E_UNEXPECTED: HRESULT = 0x8000FFFFu32 as HRESULT; pub const E_NOTIMPL: HRESULT = 0x80004001u32 as HRESULT; pub const E_OUTOFMEMORY: HRESULT = 0x8007000Eu32 as HRESULT; pub const E_INVALIDARG: HRESULT = 0x80070057u32 as HRESULT; pub const E_NOINTERFACE: HRESULT = 0x80004002u32 as HRESULT; pub const E_POINTER: HRESULT = 0x80004003u32 as HRESULT; pub const E_HANDLE: HRESULT = 0x80070006u32 as HRESULT; pub const E_ABORT: HRESULT = 0x80004004u32 as HRESULT; pub const E_FAIL: HRESULT = 0x80004005u32 as HRESULT; pub const E_ACCESSDENIED: HRESULT = 0x80070005u32 as HRESULT; pub const E_PENDING: HRESULT = 0x8000000Au32 as HRESULT; pub const E_BOUNDS: HRESULT = 0x8000000Bu32 as HRESULT; pub const E_CHANGED_STATE: HRESULT = 0x8000000Cu32 as HRESULT; pub const E_ILLEGAL_STATE_CHANGE: HRESULT = 0x8000000Du32 as HRESULT; pub const E_ILLEGAL_METHOD_CALL: HRESULT = 0x8000000Eu32 as HRESULT; pub const RO_E_METADATA_NAME_NOT_FOUND: HRESULT = 0x8000000Fu32 as HRESULT; pub const RO_E_METADATA_NAME_IS_NAMESPACE: HRESULT = 0x80000010u32 as HRESULT; pub const RO_E_METADATA_INVALID_TYPE_FORMAT: HRESULT = 0x80000011u32 as HRESULT; pub const RO_E_INVALID_METADATA_FILE: HRESULT = 0x80000012u32 as HRESULT; pub const RO_E_CLOSED: HRESULT = 0x80000013u32 as HRESULT; pub const RO_E_EXCLUSIVE_WRITE: HRESULT = 0x80000014u32 as HRESULT; pub const RO_E_CHANGE_NOTIFICATION_IN_PROGRESS: HRESULT = 0x80000015u32 as HRESULT; pub const RO_E_ERROR_STRING_NOT_FOUND: HRESULT = 0x80000016u32 as HRESULT; pub const E_STRING_NOT_NULL_TERMINATED: HRESULT = 0x80000017u32 as HRESULT; pub const E_ILLEGAL_DELEGATE_ASSIGNMENT: HRESULT = 0x80000018u32 as HRESULT; pub const E_ASYNC_OPERATION_NOT_STARTED: HRESULT = 0x80000019u32 as HRESULT; pub const E_APPLICATION_EXITING: HRESULT = 0x8000001Au32 as HRESULT; pub const E_APPLICATION_VIEW_EXITING: HRESULT = 0x8000001Bu32 as HRESULT; pub const RO_E_MUST_BE_AGILE: HRESULT = 0x8000001Cu32 as HRESULT; pub const RO_E_UNSUPPORTED_FROM_MTA: HRESULT = 0x8000001Du32 as HRESULT; pub const RO_E_COMMITTED: HRESULT = 0x8000001Eu32 as HRESULT; pub const RO_E_BLOCKED_CROSS_ASTA_CALL: HRESULT = 0x8000001Fu32 as HRESULT; pub const CO_E_INIT_TLS: HRESULT = 0x80004006u32 as HRESULT; pub const CO_E_INIT_SHARED_ALLOCATOR: HRESULT = 0x80004007u32 as HRESULT; pub const CO_E_INIT_MEMORY_ALLOCATOR: HRESULT = 0x80004008u32 as HRESULT; pub const CO_E_INIT_CLASS_CACHE: HRESULT = 0x80004009u32 as HRESULT; pub const CO_E_INIT_RPC_CHANNEL: HRESULT = 0x8000400Au32 as HRESULT; pub const CO_E_INIT_TLS_SET_CHANNEL_CONTROL: HRESULT = 0x8000400Bu32 as HRESULT; pub const CO_E_INIT_TLS_CHANNEL_CONTROL: HRESULT = 0x8000400Cu32 as HRESULT; pub const CO_E_INIT_UNACCEPTED_USER_ALLOCATOR: HRESULT = 0x8000400Du32 as HRESULT; pub const CO_E_INIT_SCM_MUTEX_EXISTS: HRESULT = 0x8000400Eu32 as HRESULT; pub const CO_E_INIT_SCM_FILE_MAPPING_EXISTS: HRESULT = 0x8000400Fu32 as HRESULT; pub const CO_E_INIT_SCM_MAP_VIEW_OF_FILE: HRESULT = 0x80004010u32 as HRESULT; pub const CO_E_INIT_SCM_EXEC_FAILURE: HRESULT = 0x80004011u32 as HRESULT; pub const CO_E_INIT_ONLY_SINGLE_THREADED: HRESULT = 0x80004012u32 as HRESULT; pub const CO_E_CANT_REMOTE: HRESULT = 0x80004013u32 as HRESULT; pub const CO_E_BAD_SERVER_NAME: HRESULT = 0x80004014u32 as HRESULT; pub const CO_E_WRONG_SERVER_IDENTITY: HRESULT = 0x80004015u32 as HRESULT; pub const CO_E_OLE1DDE_DISABLED: HRESULT = 0x80004016u32 as HRESULT; pub const CO_E_RUNAS_SYNTAX: HRESULT = 0x80004017u32 as HRESULT; pub const CO_E_CREATEPROCESS_FAILURE: HRESULT = 0x80004018u32 as HRESULT; pub const CO_E_RUNAS_CREATEPROCESS_FAILURE: HRESULT = 0x80004019u32 as HRESULT; pub const CO_E_RUNAS_LOGON_FAILURE: HRESULT = 0x8000401Au32 as HRESULT; pub const CO_E_LAUNCH_PERMSSION_DENIED: HRESULT = 0x8000401Bu32 as HRESULT; pub const CO_E_START_SERVICE_FAILURE: HRESULT = 0x8000401Cu32 as HRESULT; pub const CO_E_REMOTE_COMMUNICATION_FAILURE: HRESULT = 0x8000401Du32 as HRESULT; pub const CO_E_SERVER_START_TIMEOUT: HRESULT = 0x8000401Eu32 as HRESULT; pub const CO_E_CLSREG_INCONSISTENT: HRESULT = 0x8000401Fu32 as HRESULT; pub const CO_E_IIDREG_INCONSISTENT: HRESULT = 0x80004020u32 as HRESULT; pub const CO_E_NOT_SUPPORTED: HRESULT = 0x80004021u32 as HRESULT; pub const CO_E_RELOAD_DLL: HRESULT = 0x80004022u32 as HRESULT; pub const CO_E_MSI_ERROR: HRESULT = 0x80004023u32 as HRESULT; pub const CO_E_ATTEMPT_TO_CREATE_OUTSIDE_CLIENT_CONTEXT: HRESULT = 0x80004024u32 as HRESULT; pub const CO_E_SERVER_PAUSED: HRESULT = 0x80004025u32 as HRESULT; pub const CO_E_SERVER_NOT_PAUSED: HRESULT = 0x80004026u32 as HRESULT; pub const CO_E_CLASS_DISABLED: HRESULT = 0x80004027u32 as HRESULT; pub const CO_E_CLRNOTAVAILABLE: HRESULT = 0x80004028u32 as HRESULT; pub const CO_E_ASYNC_WORK_REJECTED: HRESULT = 0x80004029u32 as HRESULT; pub const CO_E_SERVER_INIT_TIMEOUT: HRESULT = 0x8000402Au32 as HRESULT; pub const CO_E_NO_SECCTX_IN_ACTIVATE: HRESULT = 0x8000402Bu32 as HRESULT; pub const CO_E_TRACKER_CONFIG: HRESULT = 0x80004030u32 as HRESULT; pub const CO_E_THREADPOOL_CONFIG: HRESULT = 0x80004031u32 as HRESULT; pub const CO_E_SXS_CONFIG: HRESULT = 0x80004032u32 as HRESULT; pub const CO_E_MALFORMED_SPN: HRESULT = 0x80004033u32 as HRESULT; pub const CO_E_UNREVOKED_REGISTRATION_ON_APARTMENT_SHUTDOWN: HRESULT = 0x80004034u32 as HRESULT; pub const CO_E_PREMATURE_STUB_RUNDOWN: HRESULT = 0x80004035u32 as HRESULT; pub const S_OK: HRESULT = 0; pub const S_FALSE: HRESULT = 1; pub const OLE_E_FIRST: HRESULT = 0x80040000u32 as HRESULT; pub const OLE_E_LAST: HRESULT = 0x800400FFu32 as HRESULT; pub const OLE_S_FIRST: HRESULT = 0x00040000; pub const OLE_S_LAST: HRESULT = 0x000400FF; pub const OLE_E_OLEVERB: HRESULT = 0x80040000u32 as HRESULT; pub const OLE_E_ADVF: HRESULT = 0x80040001u32 as HRESULT; pub const OLE_E_ENUM_NOMORE: HRESULT = 0x80040002u32 as HRESULT; pub const OLE_E_ADVISENOTSUPPORTED: HRESULT = 0x80040003u32 as HRESULT; pub const OLE_E_NOCONNECTION: HRESULT = 0x80040004u32 as HRESULT; pub const OLE_E_NOTRUNNING: HRESULT = 0x80040005u32 as HRESULT; pub const OLE_E_NOCACHE: HRESULT = 0x80040006u32 as HRESULT; pub const OLE_E_BLANK: HRESULT = 0x80040007u32 as HRESULT; pub const OLE_E_CLASSDIFF: HRESULT = 0x80040008u32 as HRESULT; pub const OLE_E_CANT_GETMONIKER: HRESULT = 0x80040009u32 as HRESULT; pub const OLE_E_CANT_BINDTOSOURCE: HRESULT = 0x8004000Au32 as HRESULT; pub const OLE_E_STATIC: HRESULT = 0x8004000Bu32 as HRESULT; pub const OLE_E_PROMPTSAVECANCELLED: HRESULT = 0x8004000Cu32 as HRESULT; pub const OLE_E_INVALIDRECT: HRESULT = 0x8004000Du32 as HRESULT; pub const OLE_E_WRONGCOMPOBJ: HRESULT = 0x8004000Eu32 as HRESULT; pub const OLE_E_INVALIDHWND: HRESULT = 0x8004000Fu32 as HRESULT; pub const OLE_E_NOT_INPLACEACTIVE: HRESULT = 0x80040010u32 as HRESULT; pub const OLE_E_CANTCONVERT: HRESULT = 0x80040011u32 as HRESULT; pub const OLE_E_NOSTORAGE: HRESULT = 0x80040012u32 as HRESULT; pub const DV_E_FORMATETC: HRESULT = 0x80040064u32 as HRESULT; pub const DV_E_DVTARGETDEVICE: HRESULT = 0x80040065u32 as HRESULT; pub const DV_E_STGMEDIUM: HRESULT = 0x80040066u32 as HRESULT; pub const DV_E_STATDATA: HRESULT = 0x80040067u32 as HRESULT; pub const DV_E_LINDEX: HRESULT = 0x80040068u32 as HRESULT; pub const DV_E_TYMED: HRESULT = 0x80040069u32 as HRESULT; pub const DV_E_CLIPFORMAT: HRESULT = 0x8004006Au32 as HRESULT; pub const DV_E_DVASPECT: HRESULT = 0x8004006Bu32 as HRESULT; pub const DV_E_DVTARGETDEVICE_SIZE: HRESULT = 0x8004006Cu32 as HRESULT; pub const DV_E_NOIVIEWOBJECT: HRESULT = 0x8004006Du32 as HRESULT; pub const DRAGDROP_E_FIRST: HRESULT = 0x80040100u32 as HRESULT; pub const DRAGDROP_E_LAST: HRESULT = 0x8004010Fu32 as HRESULT; pub const DRAGDROP_S_FIRST: HRESULT = 0x00040100; pub const DRAGDROP_S_LAST: HRESULT = 0x0004010F; pub const DRAGDROP_E_NOTREGISTERED: HRESULT = 0x80040100u32 as HRESULT; pub const DRAGDROP_E_ALREADYREGISTERED: HRESULT = 0x80040101u32 as HRESULT; pub const DRAGDROP_E_INVALIDHWND: HRESULT = 0x80040102u32 as HRESULT; pub const DRAGDROP_E_CONCURRENT_DRAG_ATTEMPTED: HRESULT = 0x80040103u32 as HRESULT; pub const CLASSFACTORY_E_FIRST: HRESULT = 0x80040110u32 as HRESULT; pub const CLASSFACTORY_E_LAST: HRESULT = 0x8004011Fu32 as HRESULT; pub const CLASSFACTORY_S_FIRST: HRESULT = 0x00040110; pub const CLASSFACTORY_S_LAST: HRESULT = 0x0004011F; pub const CLASS_E_NOAGGREGATION: HRESULT = 0x80040110u32 as HRESULT; pub const CLASS_E_CLASSNOTAVAILABLE: HRESULT = 0x80040111u32 as HRESULT; pub const CLASS_E_NOTLICENSED: HRESULT = 0x80040112u32 as HRESULT; pub const MARSHAL_E_FIRST: HRESULT = 0x80040120u32 as HRESULT; pub const MARSHAL_E_LAST: HRESULT = 0x8004012Fu32 as HRESULT; pub const MARSHAL_S_FIRST: HRESULT = 0x00040120; pub const MARSHAL_S_LAST: HRESULT = 0x0004012F; pub const DATA_E_FIRST: HRESULT = 0x80040130u32 as HRESULT; pub const DATA_E_LAST: HRESULT = 0x8004013Fu32 as HRESULT; pub const DATA_S_FIRST: HRESULT = 0x00040130; pub const DATA_S_LAST: HRESULT = 0x0004013F; pub const VIEW_E_FIRST: HRESULT = 0x80040140u32 as HRESULT; pub const VIEW_E_LAST: HRESULT = 0x8004014Fu32 as HRESULT; pub const VIEW_S_FIRST: HRESULT = 0x00040140; pub const VIEW_S_LAST: HRESULT = 0x0004014F; pub const VIEW_E_DRAW: HRESULT = 0x80040140u32 as HRESULT; pub const REGDB_E_FIRST: HRESULT = 0x80040150u32 as HRESULT; pub const REGDB_E_LAST: HRESULT = 0x8004015Fu32 as HRESULT; pub const REGDB_S_FIRST: HRESULT = 0x00040150; pub const REGDB_S_LAST: HRESULT = 0x0004015F; pub const REGDB_E_READREGDB: HRESULT = 0x80040150u32 as HRESULT; pub const REGDB_E_WRITEREGDB: HRESULT = 0x80040151u32 as HRESULT; pub const REGDB_E_KEYMISSING: HRESULT = 0x80040152u32 as HRESULT; pub const REGDB_E_INVALIDVALUE: HRESULT = 0x80040153u32 as HRESULT; pub const REGDB_E_CLASSNOTREG: HRESULT = 0x80040154u32 as HRESULT; pub const REGDB_E_IIDNOTREG: HRESULT = 0x80040155u32 as HRESULT; pub const REGDB_E_BADTHREADINGMODEL: HRESULT = 0x80040156u32 as HRESULT; pub const CAT_E_FIRST: HRESULT = 0x80040160u32 as HRESULT; pub const CAT_E_LAST: HRESULT = 0x80040161u32 as HRESULT; pub const CAT_E_CATIDNOEXIST: HRESULT = 0x80040160u32 as HRESULT; pub const CAT_E_NODESCRIPTION: HRESULT = 0x80040161u32 as HRESULT; pub const CS_E_FIRST: HRESULT = 0x80040164u32 as HRESULT; pub const CS_E_LAST: HRESULT = 0x8004016Fu32 as HRESULT; pub const CS_E_PACKAGE_NOTFOUND: HRESULT = 0x80040164u32 as HRESULT; pub const CS_E_NOT_DELETABLE: HRESULT = 0x80040165u32 as HRESULT; pub const CS_E_CLASS_NOTFOUND: HRESULT = 0x80040166u32 as HRESULT; pub const CS_E_INVALID_VERSION: HRESULT = 0x80040167u32 as HRESULT; pub const CS_E_NO_CLASSSTORE: HRESULT = 0x80040168u32 as HRESULT; pub const CS_E_OBJECT_NOTFOUND: HRESULT = 0x80040169u32 as HRESULT; pub const CS_E_OBJECT_ALREADY_EXISTS: HRESULT = 0x8004016Au32 as HRESULT; pub const CS_E_INVALID_PATH: HRESULT = 0x8004016Bu32 as HRESULT; pub const CS_E_NETWORK_ERROR: HRESULT = 0x8004016Cu32 as HRESULT; pub const CS_E_ADMIN_LIMIT_EXCEEDED: HRESULT = 0x8004016Du32 as HRESULT; pub const CS_E_SCHEMA_MISMATCH: HRESULT = 0x8004016Eu32 as HRESULT; pub const CS_E_INTERNAL_ERROR: HRESULT = 0x8004016Fu32 as HRESULT; pub const CACHE_E_FIRST: HRESULT = 0x80040170u32 as HRESULT; pub const CACHE_E_LAST: HRESULT = 0x8004017Fu32 as HRESULT; pub const CACHE_S_FIRST: HRESULT = 0x00040170; pub const CACHE_S_LAST: HRESULT = 0x0004017F; pub const CACHE_E_NOCACHE_UPDATED: HRESULT = 0x80040170u32 as HRESULT; pub const OLEOBJ_E_FIRST: HRESULT = 0x80040180u32 as HRESULT; pub const OLEOBJ_E_LAST: HRESULT = 0x8004018Fu32 as HRESULT; pub const OLEOBJ_S_FIRST: HRESULT = 0x00040180; pub const OLEOBJ_S_LAST: HRESULT = 0x0004018F; pub const OLEOBJ_E_NOVERBS: HRESULT = 0x80040180u32 as HRESULT; pub const OLEOBJ_E_INVALIDVERB: HRESULT = 0x80040181u32 as HRESULT; pub const CLIENTSITE_E_FIRST: HRESULT = 0x80040190u32 as HRESULT; pub const CLIENTSITE_E_LAST: HRESULT = 0x8004019Fu32 as HRESULT; pub const CLIENTSITE_S_FIRST: HRESULT = 0x00040190; pub const CLIENTSITE_S_LAST: HRESULT = 0x0004019F; pub const INPLACE_E_NOTUNDOABLE: HRESULT = 0x800401A0u32 as HRESULT; pub const INPLACE_E_NOTOOLSPACE: HRESULT = 0x800401A1u32 as HRESULT; pub const INPLACE_E_FIRST: HRESULT = 0x800401A0u32 as HRESULT; pub const INPLACE_E_LAST: HRESULT = 0x800401AFu32 as HRESULT; pub const INPLACE_S_FIRST: HRESULT = 0x000401A0; pub const INPLACE_S_LAST: HRESULT = 0x000401AF; pub const ENUM_E_FIRST: HRESULT = 0x800401B0u32 as HRESULT; pub const ENUM_E_LAST: HRESULT = 0x800401BFu32 as HRESULT; pub const ENUM_S_FIRST: HRESULT = 0x000401B0; pub const ENUM_S_LAST: HRESULT = 0x000401BF; pub const CONVERT10_E_FIRST: HRESULT = 0x800401C0u32 as HRESULT; pub const CONVERT10_E_LAST: HRESULT = 0x800401CFu32 as HRESULT; pub const CONVERT10_S_FIRST: HRESULT = 0x000401C0; pub const CONVERT10_S_LAST: HRESULT = 0x000401CF; pub const CONVERT10_E_OLESTREAM_GET: HRESULT = 0x800401C0u32 as HRESULT; pub const CONVERT10_E_OLESTREAM_PUT: HRESULT = 0x800401C1u32 as HRESULT; pub const CONVERT10_E_OLESTREAM_FMT: HRESULT = 0x800401C2u32 as HRESULT; pub const CONVERT10_E_OLESTREAM_BITMAP_TO_DIB: HRESULT = 0x800401C3u32 as HRESULT; pub const CONVERT10_E_STG_FMT: HRESULT = 0x800401C4u32 as HRESULT; pub const CONVERT10_E_STG_NO_STD_STREAM: HRESULT = 0x800401C5u32 as HRESULT; pub const CONVERT10_E_STG_DIB_TO_BITMAP: HRESULT = 0x800401C6u32 as HRESULT; pub const CLIPBRD_E_FIRST: HRESULT = 0x800401D0u32 as HRESULT; pub const CLIPBRD_E_LAST: HRESULT = 0x800401DFu32 as HRESULT; pub const CLIPBRD_S_FIRST: HRESULT = 0x000401D0; pub const CLIPBRD_S_LAST: HRESULT = 0x000401DF; pub const CLIPBRD_E_CANT_OPEN: HRESULT = 0x800401D0u32 as HRESULT; pub const CLIPBRD_E_CANT_EMPTY: HRESULT = 0x800401D1u32 as HRESULT; pub const CLIPBRD_E_CANT_SET: HRESULT = 0x800401D2u32 as HRESULT; pub const CLIPBRD_E_BAD_DATA: HRESULT = 0x800401D3u32 as HRESULT; pub const CLIPBRD_E_CANT_CLOSE: HRESULT = 0x800401D4u32 as HRESULT; pub const MK_E_FIRST: HRESULT = 0x800401E0u32 as HRESULT; pub const MK_E_LAST: HRESULT = 0x800401EFu32 as HRESULT; pub const MK_S_FIRST: HRESULT = 0x000401E0; pub const MK_S_LAST: HRESULT = 0x000401EF; pub const MK_E_CONNECTMANUALLY: HRESULT = 0x800401E0u32 as HRESULT; pub const MK_E_EXCEEDEDDEADLINE: HRESULT = 0x800401E1u32 as HRESULT; pub const MK_E_NEEDGENERIC: HRESULT = 0x800401E2u32 as HRESULT; pub const MK_E_UNAVAILABLE: HRESULT = 0x800401E3u32 as HRESULT; pub const MK_E_SYNTAX: HRESULT = 0x800401E4u32 as HRESULT; pub const MK_E_NOOBJECT: HRESULT = 0x800401E5u32 as HRESULT; pub const MK_E_INVALIDEXTENSION: HRESULT = 0x800401E6u32 as HRESULT; pub const MK_E_INTERMEDIATEINTERFACENOTSUPPORTED: HRESULT = 0x800401E7u32 as HRESULT; pub const MK_E_NOTBINDABLE: HRESULT = 0x800401E8u32 as HRESULT; pub const MK_E_NOTBOUND: HRESULT = 0x800401E9u32 as HRESULT; pub const MK_E_CANTOPENFILE: HRESULT = 0x800401EAu32 as HRESULT; pub const MK_E_MUSTBOTHERUSER: HRESULT = 0x800401EBu32 as HRESULT; pub const MK_E_NOINVERSE: HRESULT = 0x800401ECu32 as HRESULT; pub const MK_E_NOSTORAGE: HRESULT = 0x800401EDu32 as HRESULT; pub const MK_E_NOPREFIX: HRESULT = 0x800401EEu32 as HRESULT; pub const MK_E_ENUMERATION_FAILED: HRESULT = 0x800401EFu32 as HRESULT; pub const CO_E_FIRST: HRESULT = 0x800401F0u32 as HRESULT; pub const CO_E_LAST: HRESULT = 0x800401FFu32 as HRESULT; pub const CO_S_FIRST: HRESULT = 0x000401F0; pub const CO_S_LAST: HRESULT = 0x000401FF; pub const CO_E_NOTINITIALIZED: HRESULT = 0x800401F0u32 as HRESULT; pub const CO_E_ALREADYINITIALIZED: HRESULT = 0x800401F1u32 as HRESULT; pub const CO_E_CANTDETERMINECLASS: HRESULT = 0x800401F2u32 as HRESULT; pub const CO_E_CLASSSTRING: HRESULT = 0x800401F3u32 as HRESULT; pub const CO_E_IIDSTRING: HRESULT = 0x800401F4u32 as HRESULT; pub const CO_E_APPNOTFOUND: HRESULT = 0x800401F5u32 as HRESULT; pub const CO_E_APPSINGLEUSE: HRESULT = 0x800401F6u32 as HRESULT; pub const CO_E_ERRORINAPP: HRESULT = 0x800401F7u32 as HRESULT; pub const CO_E_DLLNOTFOUND: HRESULT = 0x800401F8u32 as HRESULT; pub const CO_E_ERRORINDLL: HRESULT = 0x800401F9u32 as HRESULT; pub const CO_E_WRONGOSFORAPP: HRESULT = 0x800401FAu32 as HRESULT; pub const CO_E_OBJNOTREG: HRESULT = 0x800401FBu32 as HRESULT; pub const CO_E_OBJISREG: HRESULT = 0x800401FCu32 as HRESULT; pub const CO_E_OBJNOTCONNECTED: HRESULT = 0x800401FDu32 as HRESULT; pub const CO_E_APPDIDNTREG: HRESULT = 0x800401FEu32 as HRESULT; pub const CO_E_RELEASED: HRESULT = 0x800401FFu32 as HRESULT; pub const EVENT_E_FIRST: HRESULT = 0x80040200u32 as HRESULT; pub const EVENT_E_LAST: HRESULT = 0x8004021Fu32 as HRESULT; pub const EVENT_S_FIRST: HRESULT = 0x00040200; pub const EVENT_S_LAST: HRESULT = 0x0004021F; pub const EVENT_S_SOME_SUBSCRIBERS_FAILED: HRESULT = 0x00040200; pub const EVENT_E_ALL_SUBSCRIBERS_FAILED: HRESULT = 0x80040201u32 as HRESULT; pub const EVENT_S_NOSUBSCRIBERS: HRESULT = 0x00040202; pub const EVENT_E_QUERYSYNTAX: HRESULT = 0x80040203u32 as HRESULT; pub const EVENT_E_QUERYFIELD: HRESULT = 0x80040204u32 as HRESULT; pub const EVENT_E_INTERNALEXCEPTION: HRESULT = 0x80040205u32 as HRESULT; pub const EVENT_E_INTERNALERROR: HRESULT = 0x80040206u32 as HRESULT; pub const EVENT_E_INVALID_PER_USER_SID: HRESULT = 0x80040207u32 as HRESULT; pub const EVENT_E_USER_EXCEPTION: HRESULT = 0x80040208u32 as HRESULT; pub const EVENT_E_TOO_MANY_METHODS: HRESULT = 0x80040209u32 as HRESULT; pub const EVENT_E_MISSING_EVENTCLASS: HRESULT = 0x8004020Au32 as HRESULT; pub const EVENT_E_NOT_ALL_REMOVED: HRESULT = 0x8004020Bu32 as HRESULT; pub const EVENT_E_COMPLUS_NOT_INSTALLED: HRESULT = 0x8004020Cu32 as HRESULT; pub const EVENT_E_CANT_MODIFY_OR_DELETE_UNCONFIGURED_OBJECT: HRESULT = 0x8004020Du32 as HRESULT; pub const EVENT_E_CANT_MODIFY_OR_DELETE_CONFIGURED_OBJECT: HRESULT = 0x8004020Eu32 as HRESULT; pub const EVENT_E_INVALID_EVENT_CLASS_PARTITION: HRESULT = 0x8004020Fu32 as HRESULT; pub const EVENT_E_PER_USER_SID_NOT_LOGGED_ON: HRESULT = 0x80040210u32 as HRESULT; pub const TPC_E_INVALID_PROPERTY: HRESULT = 0x80040241u32 as HRESULT; pub const TPC_E_NO_DEFAULT_TABLET: HRESULT = 0x80040212u32 as HRESULT; pub const TPC_E_UNKNOWN_PROPERTY: HRESULT = 0x8004021Bu32 as HRESULT; pub const TPC_E_INVALID_INPUT_RECT: HRESULT = 0x80040219u32 as HRESULT; pub const TPC_E_INVALID_STROKE: HRESULT = 0x80040222u32 as HRESULT; pub const TPC_E_INITIALIZE_FAIL: HRESULT = 0x80040223u32 as HRESULT; pub const TPC_E_NOT_RELEVANT: HRESULT = 0x80040232u32 as HRESULT; pub const TPC_E_INVALID_PACKET_DESCRIPTION: HRESULT = 0x80040233u32 as HRESULT; pub const TPC_E_RECOGNIZER_NOT_REGISTERED: HRESULT = 0x80040235u32 as HRESULT; pub const TPC_E_INVALID_RIGHTS: HRESULT = 0x80040236u32 as HRESULT; pub const TPC_E_OUT_OF_ORDER_CALL: HRESULT = 0x80040237u32 as HRESULT; pub const TPC_E_QUEUE_FULL: HRESULT = 0x80040238u32 as HRESULT; pub const TPC_E_INVALID_CONFIGURATION: HRESULT = 0x80040239u32 as HRESULT; pub const TPC_E_INVALID_DATA_FROM_RECOGNIZER: HRESULT = 0x8004023Au32 as HRESULT; pub const TPC_S_TRUNCATED: HRESULT = 0x00040252; pub const TPC_S_INTERRUPTED: HRESULT = 0x00040253; pub const TPC_S_NO_DATA_TO_PROCESS: HRESULT = 0x00040254; pub const XACT_E_FIRST: HRESULT = 0x8004D000u32 as HRESULT; pub const XACT_E_LAST: HRESULT = 0x8004D02Bu32 as HRESULT; pub const XACT_S_FIRST: HRESULT = 0x0004D000; pub const XACT_S_LAST: HRESULT = 0x0004D010; pub const XACT_E_ALREADYOTHERSINGLEPHASE: HRESULT = 0x8004D000u32 as HRESULT; pub const XACT_E_CANTRETAIN: HRESULT = 0x8004D001u32 as HRESULT; pub const XACT_E_COMMITFAILED: HRESULT = 0x8004D002u32 as HRESULT; pub const XACT_E_COMMITPREVENTED: HRESULT = 0x8004D003u32 as HRESULT; pub const XACT_E_HEURISTICABORT: HRESULT = 0x8004D004u32 as HRESULT; pub const XACT_E_HEURISTICCOMMIT: HRESULT = 0x8004D005u32 as HRESULT; pub const XACT_E_HEURISTICDAMAGE: HRESULT = 0x8004D006u32 as HRESULT; pub const XACT_E_HEURISTICDANGER: HRESULT = 0x8004D007u32 as HRESULT; pub const XACT_E_ISOLATIONLEVEL: HRESULT = 0x8004D008u32 as HRESULT; pub const XACT_E_NOASYNC: HRESULT = 0x8004D009u32 as HRESULT; pub const XACT_E_NOENLIST: HRESULT = 0x8004D00Au32 as HRESULT; pub const XACT_E_NOISORETAIN: HRESULT = 0x8004D00Bu32 as HRESULT; pub const XACT_E_NORESOURCE: HRESULT = 0x8004D00Cu32 as HRESULT; pub const XACT_E_NOTCURRENT: HRESULT = 0x8004D00Du32 as HRESULT; pub const XACT_E_NOTRANSACTION: HRESULT = 0x8004D00Eu32 as HRESULT; pub const XACT_E_NOTSUPPORTED: HRESULT = 0x8004D00Fu32 as HRESULT; pub const XACT_E_UNKNOWNRMGRID: HRESULT = 0x8004D010u32 as HRESULT; pub const XACT_E_WRONGSTATE: HRESULT = 0x8004D011u32 as HRESULT; pub const XACT_E_WRONGUOW: HRESULT = 0x8004D012u32 as HRESULT; pub const XACT_E_XTIONEXISTS: HRESULT = 0x8004D013u32 as HRESULT; pub const XACT_E_NOIMPORTOBJECT: HRESULT = 0x8004D014u32 as HRESULT; pub const XACT_E_INVALIDCOOKIE: HRESULT = 0x8004D015u32 as HRESULT; pub const XACT_E_INDOUBT: HRESULT = 0x8004D016u32 as HRESULT; pub const XACT_E_NOTIMEOUT: HRESULT = 0x8004D017u32 as HRESULT; pub const XACT_E_ALREADYINPROGRESS: HRESULT = 0x8004D018u32 as HRESULT; pub const XACT_E_ABORTED: HRESULT = 0x8004D019u32 as HRESULT; pub const XACT_E_LOGFULL: HRESULT = 0x8004D01Au32 as HRESULT; pub const XACT_E_TMNOTAVAILABLE: HRESULT = 0x8004D01Bu32 as HRESULT; pub const XACT_E_CONNECTION_DOWN: HRESULT = 0x8004D01Cu32 as HRESULT; pub const XACT_E_CONNECTION_DENIED: HRESULT = 0x8004D01Du32 as HRESULT; pub const XACT_E_REENLISTTIMEOUT: HRESULT = 0x8004D01Eu32 as HRESULT; pub const XACT_E_TIP_CONNECT_FAILED: HRESULT = 0x8004D01Fu32 as HRESULT; pub const XACT_E_TIP_PROTOCOL_ERROR: HRESULT = 0x8004D020u32 as HRESULT; pub const XACT_E_TIP_PULL_FAILED: HRESULT = 0x8004D021u32 as HRESULT; pub const XACT_E_DEST_TMNOTAVAILABLE: HRESULT = 0x8004D022u32 as HRESULT; pub const XACT_E_TIP_DISABLED: HRESULT = 0x8004D023u32 as HRESULT; pub const XACT_E_NETWORK_TX_DISABLED: HRESULT = 0x8004D024u32 as HRESULT; pub const XACT_E_PARTNER_NETWORK_TX_DISABLED: HRESULT = 0x8004D025u32 as HRESULT; pub const XACT_E_XA_TX_DISABLED: HRESULT = 0x8004D026u32 as HRESULT; pub const XACT_E_UNABLE_TO_READ_DTC_CONFIG: HRESULT = 0x8004D027u32 as HRESULT; pub const XACT_E_UNABLE_TO_LOAD_DTC_PROXY: HRESULT = 0x8004D028u32 as HRESULT; pub const XACT_E_ABORTING: HRESULT = 0x8004D029u32 as HRESULT; pub const XACT_E_PUSH_COMM_FAILURE: HRESULT = 0x8004D02Au32 as HRESULT; pub const XACT_E_PULL_COMM_FAILURE: HRESULT = 0x8004D02Bu32 as HRESULT; pub const XACT_E_LU_TX_DISABLED: HRESULT = 0x8004D02Cu32 as HRESULT; pub const XACT_E_CLERKNOTFOUND: HRESULT = 0x8004D080u32 as HRESULT; pub const XACT_E_CLERKEXISTS: HRESULT = 0x8004D081u32 as HRESULT; pub const XACT_E_RECOVERYINPROGRESS: HRESULT = 0x8004D082u32 as HRESULT; pub const XACT_E_TRANSACTIONCLOSED: HRESULT = 0x8004D083u32 as HRESULT; pub const XACT_E_INVALIDLSN: HRESULT = 0x8004D084u32 as HRESULT; pub const XACT_E_REPLAYREQUEST: HRESULT = 0x8004D085u32 as HRESULT; pub const XACT_S_ASYNC: HRESULT = 0x0004D000; pub const XACT_S_DEFECT: HRESULT = 0x0004D001; pub const XACT_S_READONLY: HRESULT = 0x0004D002; pub const XACT_S_SOMENORETAIN: HRESULT = 0x0004D003; pub const XACT_S_OKINFORM: HRESULT = 0x0004D004; pub const XACT_S_MADECHANGESCONTENT: HRESULT = 0x0004D005; pub const XACT_S_MADECHANGESINFORM: HRESULT = 0x0004D006; pub const XACT_S_ALLNORETAIN: HRESULT = 0x0004D007; pub const XACT_S_ABORTING: HRESULT = 0x0004D008; pub const XACT_S_SINGLEPHASE: HRESULT = 0x0004D009; pub const XACT_S_LOCALLY_OK: HRESULT = 0x0004D00A; pub const XACT_S_LASTRESOURCEMANAGER: HRESULT = 0x0004D010; pub const CONTEXT_E_FIRST: HRESULT = 0x8004E000u32 as HRESULT; pub const CONTEXT_E_LAST: HRESULT = 0x8004E02Fu32 as HRESULT; pub const CONTEXT_S_FIRST: HRESULT = 0x0004E000; pub const CONTEXT_S_LAST: HRESULT = 0x0004E02F; pub const CONTEXT_E_ABORTED: HRESULT = 0x8004E002u32 as HRESULT; pub const CONTEXT_E_ABORTING: HRESULT = 0x8004E003u32 as HRESULT; pub const CONTEXT_E_NOCONTEXT: HRESULT = 0x8004E004u32 as HRESULT; pub const CONTEXT_E_WOULD_DEADLOCK: HRESULT = 0x8004E005u32 as HRESULT; pub const CONTEXT_E_SYNCH_TIMEOUT: HRESULT = 0x8004E006u32 as HRESULT; pub const CONTEXT_E_OLDREF: HRESULT = 0x8004E007u32 as HRESULT; pub const CONTEXT_E_ROLENOTFOUND: HRESULT = 0x8004E00Cu32 as HRESULT; pub const CONTEXT_E_TMNOTAVAILABLE: HRESULT = 0x8004E00Fu32 as HRESULT; pub const CO_E_ACTIVATIONFAILED: HRESULT = 0x8004E021u32 as HRESULT; pub const CO_E_ACTIVATIONFAILED_EVENTLOGGED: HRESULT = 0x8004E022u32 as HRESULT; pub const CO_E_ACTIVATIONFAILED_CATALOGERROR: HRESULT = 0x8004E023u32 as HRESULT; pub const CO_E_ACTIVATIONFAILED_TIMEOUT: HRESULT = 0x8004E024u32 as HRESULT; pub const CO_E_INITIALIZATIONFAILED: HRESULT = 0x8004E025u32 as HRESULT; pub const CONTEXT_E_NOJIT: HRESULT = 0x8004E026u32 as HRESULT; pub const CONTEXT_E_NOTRANSACTION: HRESULT = 0x8004E027u32 as HRESULT; pub const CO_E_THREADINGMODEL_CHANGED: HRESULT = 0x8004E028u32 as HRESULT; pub const CO_E_NOIISINTRINSICS: HRESULT = 0x8004E029u32 as HRESULT; pub const CO_E_NOCOOKIES: HRESULT = 0x8004E02Au32 as HRESULT; pub const CO_E_DBERROR: HRESULT = 0x8004E02Bu32 as HRESULT; pub const CO_E_NOTPOOLED: HRESULT = 0x8004E02Cu32 as HRESULT; pub const CO_E_NOTCONSTRUCTED: HRESULT = 0x8004E02Du32 as HRESULT; pub const CO_E_NOSYNCHRONIZATION: HRESULT = 0x8004E02Eu32 as HRESULT; pub const CO_E_ISOLEVELMISMATCH: HRESULT = 0x8004E02Fu32 as HRESULT; pub const CO_E_CALL_OUT_OF_TX_SCOPE_NOT_ALLOWED: HRESULT = 0x8004E030u32 as HRESULT; pub const CO_E_EXIT_TRANSACTION_SCOPE_NOT_CALLED: HRESULT = 0x8004E031u32 as HRESULT; pub const OLE_S_USEREG: HRESULT = 0x00040000; pub const OLE_S_STATIC: HRESULT = 0x00040001; pub const OLE_S_MAC_CLIPFORMAT: HRESULT = 0x00040002; pub const DRAGDROP_S_DROP: HRESULT = 0x00040100; pub const DRAGDROP_S_CANCEL: HRESULT = 0x00040101; pub const DRAGDROP_S_USEDEFAULTCURSORS: HRESULT = 0x00040102; pub const DATA_S_SAMEFORMATETC: HRESULT = 0x00040130; pub const VIEW_S_ALREADY_FROZEN: HRESULT = 0x00040140; pub const CACHE_S_FORMATETC_NOTSUPPORTED: HRESULT = 0x00040170; pub const CACHE_S_SAMECACHE: HRESULT = 0x00040171; pub const CACHE_S_SOMECACHES_NOTUPDATED: HRESULT = 0x00040172; pub const OLEOBJ_S_INVALIDVERB: HRESULT = 0x00040180; pub const OLEOBJ_S_CANNOT_DOVERB_NOW: HRESULT = 0x00040181; pub const OLEOBJ_S_INVALIDHWND: HRESULT = 0x00040182; pub const INPLACE_S_TRUNCATED: HRESULT = 0x000401A0; pub const CONVERT10_S_NO_PRESENTATION: HRESULT = 0x000401C0; pub const MK_S_REDUCED_TO_SELF: HRESULT = 0x000401E2; pub const MK_S_ME: HRESULT = 0x000401E4; pub const MK_S_HIM: HRESULT = 0x000401E5; pub const MK_S_US: HRESULT = 0x000401E6; pub const MK_S_MONIKERALREADYREGISTERED: HRESULT = 0x000401E7; pub const SCHED_S_TASK_READY: HRESULT = 0x00041300; pub const SCHED_S_TASK_RUNNING: HRESULT = 0x00041301; pub const SCHED_S_TASK_DISABLED: HRESULT = 0x00041302; pub const SCHED_S_TASK_HAS_NOT_RUN: HRESULT = 0x00041303; pub const SCHED_S_TASK_NO_MORE_RUNS: HRESULT = 0x00041304; pub const SCHED_S_TASK_NOT_SCHEDULED: HRESULT = 0x00041305; pub const SCHED_S_TASK_TERMINATED: HRESULT = 0x00041306; pub const SCHED_S_TASK_NO_VALID_TRIGGERS: HRESULT = 0x00041307; pub const SCHED_S_EVENT_TRIGGER: HRESULT = 0x00041308; pub const SCHED_E_TRIGGER_NOT_FOUND: HRESULT = 0x80041309u32 as HRESULT; pub const SCHED_E_TASK_NOT_READY: HRESULT = 0x8004130Au32 as HRESULT; pub const SCHED_E_TASK_NOT_RUNNING: HRESULT = 0x8004130Bu32 as HRESULT; pub const SCHED_E_SERVICE_NOT_INSTALLED: HRESULT = 0x8004130Cu32 as HRESULT; pub const SCHED_E_CANNOT_OPEN_TASK: HRESULT = 0x8004130Du32 as HRESULT; pub const SCHED_E_INVALID_TASK: HRESULT = 0x8004130Eu32 as HRESULT; pub const SCHED_E_ACCOUNT_INFORMATION_NOT_SET: HRESULT = 0x8004130Fu32 as HRESULT; pub const SCHED_E_ACCOUNT_NAME_NOT_FOUND: HRESULT = 0x80041310u32 as HRESULT; pub const SCHED_E_ACCOUNT_DBASE_CORRUPT: HRESULT = 0x80041311u32 as HRESULT; pub const SCHED_E_NO_SECURITY_SERVICES: HRESULT = 0x80041312u32 as HRESULT; pub const SCHED_E_UNKNOWN_OBJECT_VERSION: HRESULT = 0x80041313u32 as HRESULT; pub const SCHED_E_UNSUPPORTED_ACCOUNT_OPTION: HRESULT = 0x80041314u32 as HRESULT; pub const SCHED_E_SERVICE_NOT_RUNNING: HRESULT = 0x80041315u32 as HRESULT; pub const SCHED_E_UNEXPECTEDNODE: HRESULT = 0x80041316u32 as HRESULT; pub const SCHED_E_NAMESPACE: HRESULT = 0x80041317u32 as HRESULT; pub const SCHED_E_INVALIDVALUE: HRESULT = 0x80041318u32 as HRESULT; pub const SCHED_E_MISSINGNODE: HRESULT = 0x80041319u32 as HRESULT; pub const SCHED_E_MALFORMEDXML: HRESULT = 0x8004131Au32 as HRESULT; pub const SCHED_S_SOME_TRIGGERS_FAILED: HRESULT = 0x0004131B; pub const SCHED_S_BATCH_LOGON_PROBLEM: HRESULT = 0x0004131C; pub const SCHED_E_TOO_MANY_NODES: HRESULT = 0x8004131Du32 as HRESULT; pub const SCHED_E_PAST_END_BOUNDARY: HRESULT = 0x8004131Eu32 as HRESULT; pub const SCHED_E_ALREADY_RUNNING: HRESULT = 0x8004131Fu32 as HRESULT; pub const SCHED_E_USER_NOT_LOGGED_ON: HRESULT = 0x80041320u32 as HRESULT; pub const SCHED_E_INVALID_TASK_HASH: HRESULT = 0x80041321u32 as HRESULT; pub const SCHED_E_SERVICE_NOT_AVAILABLE: HRESULT = 0x80041322u32 as HRESULT; pub const SCHED_E_SERVICE_TOO_BUSY: HRESULT = 0x80041323u32 as HRESULT; pub const SCHED_E_TASK_ATTEMPTED: HRESULT = 0x80041324u32 as HRESULT; pub const SCHED_S_TASK_QUEUED: HRESULT = 0x00041325; pub const SCHED_E_TASK_DISABLED: HRESULT = 0x80041326u32 as HRESULT; pub const SCHED_E_TASK_NOT_V1_COMPAT: HRESULT = 0x80041327u32 as HRESULT; pub const SCHED_E_START_ON_DEMAND: HRESULT = 0x80041328u32 as HRESULT; pub const SCHED_E_TASK_NOT_UBPM_COMPAT: HRESULT = 0x80041329u32 as HRESULT; pub const SCHED_E_DEPRECATED_FEATURE_USED: HRESULT = 0x80041330u32 as HRESULT; pub const CO_E_CLASS_CREATE_FAILED: HRESULT = 0x80080001u32 as HRESULT; pub const CO_E_SCM_ERROR: HRESULT = 0x80080002u32 as HRESULT; pub const CO_E_SCM_RPC_FAILURE: HRESULT = 0x80080003u32 as HRESULT; pub const CO_E_BAD_PATH: HRESULT = 0x80080004u32 as HRESULT; pub const CO_E_SERVER_EXEC_FAILURE: HRESULT = 0x80080005u32 as HRESULT; pub const CO_E_OBJSRV_RPC_FAILURE: HRESULT = 0x80080006u32 as HRESULT; pub const MK_E_NO_NORMALIZED: HRESULT = 0x80080007u32 as HRESULT; pub const CO_E_SERVER_STOPPING: HRESULT = 0x80080008u32 as HRESULT; pub const MEM_E_INVALID_ROOT: HRESULT = 0x80080009u32 as HRESULT; pub const MEM_E_INVALID_LINK: HRESULT = 0x80080010u32 as HRESULT; pub const MEM_E_INVALID_SIZE: HRESULT = 0x80080011u32 as HRESULT; pub const CO_S_NOTALLINTERFACES: HRESULT = 0x00080012; pub const CO_S_MACHINENAMENOTFOUND: HRESULT = 0x00080013; pub const CO_E_MISSING_DISPLAYNAME: HRESULT = 0x80080015u32 as HRESULT; pub const CO_E_RUNAS_VALUE_MUST_BE_AAA: HRESULT = 0x80080016u32 as HRESULT; pub const CO_E_ELEVATION_DISABLED: HRESULT = 0x80080017u32 as HRESULT; pub const APPX_E_PACKAGING_INTERNAL: HRESULT = 0x80080200u32 as HRESULT; pub const APPX_E_INTERLEAVING_NOT_ALLOWED: HRESULT = 0x80080201u32 as HRESULT; pub const APPX_E_RELATIONSHIPS_NOT_ALLOWED: HRESULT = 0x80080202u32 as HRESULT; pub const APPX_E_MISSING_REQUIRED_FILE: HRESULT = 0x80080203u32 as HRESULT; pub const APPX_E_INVALID_MANIFEST: HRESULT = 0x80080204u32 as HRESULT; pub const APPX_E_INVALID_BLOCKMAP: HRESULT = 0x80080205u32 as HRESULT; pub const APPX_E_CORRUPT_CONTENT: HRESULT = 0x80080206u32 as HRESULT; pub const APPX_E_BLOCK_HASH_INVALID: HRESULT = 0x80080207u32 as HRESULT; pub const APPX_E_REQUESTED_RANGE_TOO_LARGE: HRESULT = 0x80080208u32 as HRESULT; pub const APPX_E_INVALID_SIP_CLIENT_DATA: HRESULT = 0x80080209u32 as HRESULT; pub const BT_E_SPURIOUS_ACTIVATION: HRESULT = 0x80080300u32 as HRESULT; pub const DISP_E_UNKNOWNINTERFACE: HRESULT = 0x80020001u32 as HRESULT; pub const DISP_E_MEMBERNOTFOUND: HRESULT = 0x80020003u32 as HRESULT; pub const DISP_E_PARAMNOTFOUND: HRESULT = 0x80020004u32 as HRESULT; pub const DISP_E_TYPEMISMATCH: HRESULT = 0x80020005u32 as HRESULT; pub const DISP_E_UNKNOWNNAME: HRESULT = 0x80020006u32 as HRESULT; pub const DISP_E_NONAMEDARGS: HRESULT = 0x80020007u32 as HRESULT; pub const DISP_E_BADVARTYPE: HRESULT = 0x80020008u32 as HRESULT; pub const DISP_E_EXCEPTION: HRESULT = 0x80020009u32 as HRESULT; pub const DISP_E_OVERFLOW: HRESULT = 0x8002000Au32 as HRESULT; pub const DISP_E_BADINDEX: HRESULT = 0x8002000Bu32 as HRESULT; pub const DISP_E_UNKNOWNLCID: HRESULT = 0x8002000Cu32 as HRESULT; pub const DISP_E_ARRAYISLOCKED: HRESULT = 0x8002000Du32 as HRESULT; pub const DISP_E_BADPARAMCOUNT: HRESULT = 0x8002000Eu32 as HRESULT; pub const DISP_E_PARAMNOTOPTIONAL: HRESULT = 0x8002000Fu32 as HRESULT; pub const DISP_E_BADCALLEE: HRESULT = 0x80020010u32 as HRESULT; pub const DISP_E_NOTACOLLECTION: HRESULT = 0x80020011u32 as HRESULT; pub const DISP_E_DIVBYZERO: HRESULT = 0x80020012u32 as HRESULT; pub const DISP_E_BUFFERTOOSMALL: HRESULT = 0x80020013u32 as HRESULT; pub const TYPE_E_BUFFERTOOSMALL: HRESULT = 0x80028016u32 as HRESULT; pub const TYPE_E_FIELDNOTFOUND: HRESULT = 0x80028017u32 as HRESULT; pub const TYPE_E_INVDATAREAD: HRESULT = 0x80028018u32 as HRESULT; pub const TYPE_E_UNSUPFORMAT: HRESULT = 0x80028019u32 as HRESULT; pub const TYPE_E_REGISTRYACCESS: HRESULT = 0x8002801Cu32 as HRESULT; pub const TYPE_E_LIBNOTREGISTERED: HRESULT = 0x8002801Du32 as HRESULT; pub const TYPE_E_UNDEFINEDTYPE: HRESULT = 0x80028027u32 as HRESULT; pub const TYPE_E_QUALIFIEDNAMEDISALLOWED: HRESULT = 0x80028028u32 as HRESULT; pub const TYPE_E_INVALIDSTATE: HRESULT = 0x80028029u32 as HRESULT; pub const TYPE_E_WRONGTYPEKIND: HRESULT = 0x8002802Au32 as HRESULT; pub const TYPE_E_ELEMENTNOTFOUND: HRESULT = 0x8002802Bu32 as HRESULT; pub const TYPE_E_AMBIGUOUSNAME: HRESULT = 0x8002802Cu32 as HRESULT; pub const TYPE_E_NAMECONFLICT: HRESULT = 0x8002802Du32 as HRESULT; pub const TYPE_E_UNKNOWNLCID: HRESULT = 0x8002802Eu32 as HRESULT; pub const TYPE_E_DLLFUNCTIONNOTFOUND: HRESULT = 0x8002802Fu32 as HRESULT; pub const TYPE_E_BADMODULEKIND: HRESULT = 0x800288BDu32 as HRESULT; pub const TYPE_E_SIZETOOBIG: HRESULT = 0x800288C5u32 as HRESULT; pub const TYPE_E_DUPLICATEID: HRESULT = 0x800288C6u32 as HRESULT; pub const TYPE_E_INVALIDID: HRESULT = 0x800288CFu32 as HRESULT; pub const TYPE_E_TYPEMISMATCH: HRESULT = 0x80028CA0u32 as HRESULT; pub const TYPE_E_OUTOFBOUNDS: HRESULT = 0x80028CA1u32 as HRESULT; pub const TYPE_E_IOERROR: HRESULT = 0x80028CA2u32 as HRESULT; pub const TYPE_E_CANTCREATETMPFILE: HRESULT = 0x80028CA3u32 as HRESULT; pub const TYPE_E_CANTLOADLIBRARY: HRESULT = 0x80029C4Au32 as HRESULT; pub const TYPE_E_INCONSISTENTPROPFUNCS: HRESULT = 0x80029C83u32 as HRESULT; pub const TYPE_E_CIRCULARTYPE: HRESULT = 0x80029C84u32 as HRESULT; pub const STG_E_INVALIDFUNCTION: HRESULT = 0x80030001u32 as HRESULT; pub const STG_E_FILENOTFOUND: HRESULT = 0x80030002u32 as HRESULT; pub const STG_E_PATHNOTFOUND: HRESULT = 0x80030003u32 as HRESULT; pub const STG_E_TOOMANYOPENFILES: HRESULT = 0x80030004u32 as HRESULT; pub const STG_E_ACCESSDENIED: HRESULT = 0x80030005u32 as HRESULT; pub const STG_E_INVALIDHANDLE: HRESULT = 0x80030006u32 as HRESULT; pub const STG_E_INSUFFICIENTMEMORY: HRESULT = 0x80030008u32 as HRESULT; pub const STG_E_INVALIDPOINTER: HRESULT = 0x80030009u32 as HRESULT; pub const STG_E_NOMOREFILES: HRESULT = 0x80030012u32 as HRESULT; pub const STG_E_DISKISWRITEPROTECTED: HRESULT = 0x80030013u32 as HRESULT; pub const STG_E_SEEKERROR: HRESULT = 0x80030019u32 as HRESULT; pub const STG_E_WRITEFAULT: HRESULT = 0x8003001Du32 as HRESULT; pub const STG_E_READFAULT: HRESULT = 0x8003001Eu32 as HRESULT; pub const STG_E_SHAREVIOLATION: HRESULT = 0x80030020u32 as HRESULT; pub const STG_E_LOCKVIOLATION: HRESULT = 0x80030021u32 as HRESULT; pub const STG_E_FILEALREADYEXISTS: HRESULT = 0x80030050u32 as HRESULT; pub const STG_E_INVALIDPARAMETER: HRESULT = 0x80030057u32 as HRESULT; pub const STG_E_MEDIUMFULL: HRESULT = 0x80030070u32 as HRESULT; pub const STG_E_PROPSETMISMATCHED: HRESULT = 0x800300F0u32 as HRESULT; pub const STG_E_ABNORMALAPIEXIT: HRESULT = 0x800300FAu32 as HRESULT; pub const STG_E_INVALIDHEADER: HRESULT = 0x800300FBu32 as HRESULT; pub const STG_E_INVALIDNAME: HRESULT = 0x800300FCu32 as HRESULT; pub const STG_E_UNKNOWN: HRESULT = 0x800300FDu32 as HRESULT; pub const STG_E_UNIMPLEMENTEDFUNCTION: HRESULT = 0x800300FEu32 as HRESULT; pub const STG_E_INVALIDFLAG: HRESULT = 0x800300FFu32 as HRESULT; pub const STG_E_INUSE: HRESULT = 0x80030100u32 as HRESULT; pub const STG_E_NOTCURRENT: HRESULT = 0x80030101u32 as HRESULT; pub const STG_E_REVERTED: HRESULT = 0x80030102u32 as HRESULT; pub const STG_E_CANTSAVE: HRESULT = 0x80030103u32 as HRESULT; pub const STG_E_OLDFORMAT: HRESULT = 0x80030104u32 as HRESULT; pub const STG_E_OLDDLL: HRESULT = 0x80030105u32 as HRESULT; pub const STG_E_SHAREREQUIRED: HRESULT = 0x80030106u32 as HRESULT; pub const STG_E_NOTFILEBASEDSTORAGE: HRESULT = 0x80030107u32 as HRESULT; pub const STG_E_EXTANTMARSHALLINGS: HRESULT = 0x80030108u32 as HRESULT; pub const STG_E_DOCFILECORRUPT: HRESULT = 0x80030109u32 as HRESULT; pub const STG_E_BADBASEADDRESS: HRESULT = 0x80030110u32 as HRESULT; pub const STG_E_DOCFILETOOLARGE: HRESULT = 0x80030111u32 as HRESULT; pub const STG_E_NOTSIMPLEFORMAT: HRESULT = 0x80030112u32 as HRESULT; pub const STG_E_INCOMPLETE: HRESULT = 0x80030201u32 as HRESULT; pub const STG_E_TERMINATED: HRESULT = 0x80030202u32 as HRESULT; pub const STG_S_CONVERTED: HRESULT = 0x00030200; pub const STG_S_BLOCK: HRESULT = 0x00030201; pub const STG_S_RETRYNOW: HRESULT = 0x00030202; pub const STG_S_MONITORING: HRESULT = 0x00030203; pub const STG_S_MULTIPLEOPENS: HRESULT = 0x00030204; pub const STG_S_CONSOLIDATIONFAILED: HRESULT = 0x00030205; pub const STG_S_CANNOTCONSOLIDATE: HRESULT = 0x00030206; pub const STG_E_STATUS_COPY_PROTECTION_FAILURE: HRESULT = 0x80030305u32 as HRESULT; pub const STG_E_CSS_AUTHENTICATION_FAILURE: HRESULT = 0x80030306u32 as HRESULT; pub const STG_E_CSS_KEY_NOT_PRESENT: HRESULT = 0x80030307u32 as HRESULT; pub const STG_E_CSS_KEY_NOT_ESTABLISHED: HRESULT = 0x80030308u32 as HRESULT; pub const STG_E_CSS_SCRAMBLED_SECTOR: HRESULT = 0x80030309u32 as HRESULT; pub const STG_E_CSS_REGION_MISMATCH: HRESULT = 0x8003030Au32 as HRESULT; pub const STG_E_RESETS_EXHAUSTED: HRESULT = 0x8003030Bu32 as HRESULT; pub const RPC_E_CALL_REJECTED: HRESULT = 0x80010001u32 as HRESULT; pub const RPC_E_CALL_CANCELED: HRESULT = 0x80010002u32 as HRESULT; pub const RPC_E_CANTPOST_INSENDCALL: HRESULT = 0x80010003u32 as HRESULT; pub const RPC_E_CANTCALLOUT_INASYNCCALL: HRESULT = 0x80010004u32 as HRESULT; pub const RPC_E_CANTCALLOUT_INEXTERNALCALL: HRESULT = 0x80010005u32 as HRESULT; pub const RPC_E_CONNECTION_TERMINATED: HRESULT = 0x80010006u32 as HRESULT; pub const RPC_E_SERVER_DIED: HRESULT = 0x80010007u32 as HRESULT; pub const RPC_E_CLIENT_DIED: HRESULT = 0x80010008u32 as HRESULT; pub const RPC_E_INVALID_DATAPACKET: HRESULT = 0x80010009u32 as HRESULT; pub const RPC_E_CANTTRANSMIT_CALL: HRESULT = 0x8001000Au32 as HRESULT; pub const RPC_E_CLIENT_CANTMARSHAL_DATA: HRESULT = 0x8001000Bu32 as HRESULT; pub const RPC_E_CLIENT_CANTUNMARSHAL_DATA: HRESULT = 0x8001000Cu32 as HRESULT; pub const RPC_E_SERVER_CANTMARSHAL_DATA: HRESULT = 0x8001000Du32 as HRESULT; pub const RPC_E_SERVER_CANTUNMARSHAL_DATA: HRESULT = 0x8001000Eu32 as HRESULT; pub const RPC_E_INVALID_DATA: HRESULT = 0x8001000Fu32 as HRESULT; pub const RPC_E_INVALID_PARAMETER: HRESULT = 0x80010010u32 as HRESULT; pub const RPC_E_CANTCALLOUT_AGAIN: HRESULT = 0x80010011u32 as HRESULT; pub const RPC_E_SERVER_DIED_DNE: HRESULT = 0x80010012u32 as HRESULT; pub const RPC_E_SYS_CALL_FAILED: HRESULT = 0x80010100u32 as HRESULT; pub const RPC_E_OUT_OF_RESOURCES: HRESULT = 0x80010101u32 as HRESULT; pub const RPC_E_ATTEMPTED_MULTITHREAD: HRESULT = 0x80010102u32 as HRESULT; pub const RPC_E_NOT_REGISTERED: HRESULT = 0x80010103u32 as HRESULT; pub const RPC_E_FAULT: HRESULT = 0x80010104u32 as HRESULT; pub const RPC_E_SERVERFAULT: HRESULT = 0x80010105u32 as HRESULT; pub const RPC_E_CHANGED_MODE: HRESULT = 0x80010106u32 as HRESULT; pub const RPC_E_INVALIDMETHOD: HRESULT = 0x80010107u32 as HRESULT; pub const RPC_E_DISCONNECTED: HRESULT = 0x80010108u32 as HRESULT; pub const RPC_E_RETRY: HRESULT = 0x80010109u32 as HRESULT; pub const RPC_E_SERVERCALL_RETRYLATER: HRESULT = 0x8001010Au32 as HRESULT; pub const RPC_E_SERVERCALL_REJECTED: HRESULT = 0x8001010Bu32 as HRESULT; pub const RPC_E_INVALID_CALLDATA: HRESULT = 0x8001010Cu32 as HRESULT; pub const RPC_E_CANTCALLOUT_ININPUTSYNCCALL: HRESULT = 0x8001010Du32 as HRESULT; pub const RPC_E_WRONG_THREAD: HRESULT = 0x8001010Eu32 as HRESULT; pub const RPC_E_THREAD_NOT_INIT: HRESULT = 0x8001010Fu32 as HRESULT; pub const RPC_E_VERSION_MISMATCH: HRESULT = 0x80010110u32 as HRESULT; pub const RPC_E_INVALID_HEADER: HRESULT = 0x80010111u32 as HRESULT; pub const RPC_E_INVALID_EXTENSION: HRESULT = 0x80010112u32 as HRESULT; pub const RPC_E_INVALID_IPID: HRESULT = 0x80010113u32 as HRESULT; pub const RPC_E_INVALID_OBJECT: HRESULT = 0x80010114u32 as HRESULT; pub const RPC_S_CALLPENDING: HRESULT = 0x80010115u32 as HRESULT; pub const RPC_S_WAITONTIMER: HRESULT = 0x80010116u32 as HRESULT; pub const RPC_E_CALL_COMPLETE: HRESULT = 0x80010117u32 as HRESULT; pub const RPC_E_UNSECURE_CALL: HRESULT = 0x80010118u32 as HRESULT; pub const RPC_E_TOO_LATE: HRESULT = 0x80010119u32 as HRESULT; pub const RPC_E_NO_GOOD_SECURITY_PACKAGES: HRESULT = 0x8001011Au32 as HRESULT; pub const RPC_E_ACCESS_DENIED: HRESULT = 0x8001011Bu32 as HRESULT; pub const RPC_E_REMOTE_DISABLED: HRESULT = 0x8001011Cu32 as HRESULT; pub const RPC_E_INVALID_OBJREF: HRESULT = 0x8001011Du32 as HRESULT; pub const RPC_E_NO_CONTEXT: HRESULT = 0x8001011Eu32 as HRESULT; pub const RPC_E_TIMEOUT: HRESULT = 0x8001011Fu32 as HRESULT; pub const RPC_E_NO_SYNC: HRESULT = 0x80010120u32 as HRESULT; pub const RPC_E_FULLSIC_REQUIRED: HRESULT = 0x80010121u32 as HRESULT; pub const RPC_E_INVALID_STD_NAME: HRESULT = 0x80010122u32 as HRESULT; pub const CO_E_FAILEDTOIMPERSONATE: HRESULT = 0x80010123u32 as HRESULT; pub const CO_E_FAILEDTOGETSECCTX: HRESULT = 0x80010124u32 as HRESULT; pub const CO_E_FAILEDTOOPENTHREADTOKEN: HRESULT = 0x80010125u32 as HRESULT; pub const CO_E_FAILEDTOGETTOKENINFO: HRESULT = 0x80010126u32 as HRESULT; pub const CO_E_TRUSTEEDOESNTMATCHCLIENT: HRESULT = 0x80010127u32 as HRESULT; pub const CO_E_FAILEDTOQUERYCLIENTBLANKET: HRESULT = 0x80010128u32 as HRESULT; pub const CO_E_FAILEDTOSETDACL: HRESULT = 0x80010129u32 as HRESULT; pub const CO_E_ACCESSCHECKFAILED: HRESULT = 0x8001012Au32 as HRESULT; pub const CO_E_NETACCESSAPIFAILED: HRESULT = 0x8001012Bu32 as HRESULT; pub const CO_E_WRONGTRUSTEENAMESYNTAX: HRESULT = 0x8001012Cu32 as HRESULT; pub const CO_E_INVALIDSID: HRESULT = 0x8001012Du32 as HRESULT; pub const CO_E_CONVERSIONFAILED: HRESULT = 0x8001012Eu32 as HRESULT; pub const CO_E_NOMATCHINGSIDFOUND: HRESULT = 0x8001012Fu32 as HRESULT; pub const CO_E_LOOKUPACCSIDFAILED: HRESULT = 0x80010130u32 as HRESULT; pub const CO_E_NOMATCHINGNAMEFOUND: HRESULT = 0x80010131u32 as HRESULT; pub const CO_E_LOOKUPACCNAMEFAILED: HRESULT = 0x80010132u32 as HRESULT; pub const CO_E_SETSERLHNDLFAILED: HRESULT = 0x80010133u32 as HRESULT; pub const CO_E_FAILEDTOGETWINDIR: HRESULT = 0x80010134u32 as HRESULT; pub const CO_E_PATHTOOLONG: HRESULT = 0x80010135u32 as HRESULT; pub const CO_E_FAILEDTOGENUUID: HRESULT = 0x80010136u32 as HRESULT; pub const CO_E_FAILEDTOCREATEFILE: HRESULT = 0x80010137u32 as HRESULT; pub const CO_E_FAILEDTOCLOSEHANDLE: HRESULT = 0x80010138u32 as HRESULT; pub const CO_E_EXCEEDSYSACLLIMIT: HRESULT = 0x80010139u32 as HRESULT; pub const CO_E_ACESINWRONGORDER: HRESULT = 0x8001013Au32 as HRESULT; pub const CO_E_INCOMPATIBLESTREAMVERSION: HRESULT = 0x8001013Bu32 as HRESULT; pub const CO_E_FAILEDTOOPENPROCESSTOKEN: HRESULT = 0x8001013Cu32 as HRESULT; pub const CO_E_DECODEFAILED: HRESULT = 0x8001013Du32 as HRESULT; pub const CO_E_ACNOTINITIALIZED: HRESULT = 0x8001013Fu32 as HRESULT; pub const CO_E_CANCEL_DISABLED: HRESULT = 0x80010140u32 as HRESULT; pub const RPC_E_UNEXPECTED: HRESULT = 0x8001FFFFu32 as HRESULT; pub const ERROR_AUDITING_DISABLED: HRESULT = 0xC0090001u32 as HRESULT; pub const ERROR_ALL_SIDS_FILTERED: HRESULT = 0xC0090002u32 as HRESULT; pub const ERROR_BIZRULES_NOT_ENABLED: HRESULT = 0xC0090003u32 as HRESULT; pub const NTE_BAD_UID: HRESULT = 0x80090001u32 as HRESULT; pub const NTE_BAD_HASH: HRESULT = 0x80090002u32 as HRESULT; pub const NTE_BAD_KEY: HRESULT = 0x80090003u32 as HRESULT; pub const NTE_BAD_LEN: HRESULT = 0x80090004u32 as HRESULT; pub const NTE_BAD_DATA: HRESULT = 0x80090005u32 as HRESULT; pub const NTE_BAD_SIGNATURE: HRESULT = 0x80090006u32 as HRESULT; pub const NTE_BAD_VER: HRESULT = 0x80090007u32 as HRESULT; pub const NTE_BAD_ALGID: HRESULT = 0x80090008u32 as HRESULT; pub const NTE_BAD_FLAGS: HRESULT = 0x80090009u32 as HRESULT; pub const NTE_BAD_TYPE: HRESULT = 0x8009000Au32 as HRESULT; pub const NTE_BAD_KEY_STATE: HRESULT = 0x8009000Bu32 as HRESULT; pub const NTE_BAD_HASH_STATE: HRESULT = 0x8009000Cu32 as HRESULT; pub const NTE_NO_KEY: HRESULT = 0x8009000Du32 as HRESULT; pub const NTE_NO_MEMORY: HRESULT = 0x8009000Eu32 as HRESULT; pub const NTE_EXISTS: HRESULT = 0x8009000Fu32 as HRESULT; pub const NTE_PERM: HRESULT = 0x80090010u32 as HRESULT; pub const NTE_NOT_FOUND: HRESULT = 0x80090011u32 as HRESULT; pub const NTE_DOUBLE_ENCRYPT: HRESULT = 0x80090012u32 as HRESULT; pub const NTE_BAD_PROVIDER: HRESULT = 0x80090013u32 as HRESULT; pub const NTE_BAD_PROV_TYPE: HRESULT = 0x80090014u32 as HRESULT; pub const NTE_BAD_PUBLIC_KEY: HRESULT = 0x80090015u32 as HRESULT; pub const NTE_BAD_KEYSET: HRESULT = 0x80090016u32 as HRESULT; pub const NTE_PROV_TYPE_NOT_DEF: HRESULT = 0x80090017u32 as HRESULT; pub const NTE_PROV_TYPE_ENTRY_BAD: HRESULT = 0x80090018u32 as HRESULT; pub const NTE_KEYSET_NOT_DEF: HRESULT = 0x80090019u32 as HRESULT; pub const NTE_KEYSET_ENTRY_BAD: HRESULT = 0x8009001Au32 as HRESULT; pub const NTE_PROV_TYPE_NO_MATCH: HRESULT = 0x8009001Bu32 as HRESULT; pub const NTE_SIGNATURE_FILE_BAD: HRESULT = 0x8009001Cu32 as HRESULT; pub const NTE_PROVIDER_DLL_FAIL: HRESULT = 0x8009001Du32 as HRESULT; pub const NTE_PROV_DLL_NOT_FOUND: HRESULT = 0x8009001Eu32 as HRESULT; pub const NTE_BAD_KEYSET_PARAM: HRESULT = 0x8009001Fu32 as HRESULT; pub const NTE_FAIL: HRESULT = 0x80090020u32 as HRESULT; pub const NTE_SYS_ERR: HRESULT = 0x80090021u32 as HRESULT; pub const NTE_SILENT_CONTEXT: HRESULT = 0x80090022u32 as HRESULT; pub const NTE_TOKEN_KEYSET_STORAGE_FULL: HRESULT = 0x80090023u32 as HRESULT; pub const NTE_TEMPORARY_PROFILE: HRESULT = 0x80090024u32 as HRESULT; pub const NTE_FIXEDPARAMETER: HRESULT = 0x80090025u32 as HRESULT; pub const NTE_INVALID_HANDLE: HRESULT = 0x80090026u32 as HRESULT; pub const NTE_INVALID_PARAMETER: HRESULT = 0x80090027u32 as HRESULT; pub const NTE_BUFFER_TOO_SMALL: HRESULT = 0x80090028u32 as HRESULT; pub const NTE_NOT_SUPPORTED: HRESULT = 0x80090029u32 as HRESULT; pub const NTE_NO_MORE_ITEMS: HRESULT = 0x8009002Au32 as HRESULT; pub const NTE_BUFFERS_OVERLAP: HRESULT = 0x8009002Bu32 as HRESULT; pub const NTE_DECRYPTION_FAILURE: HRESULT = 0x8009002Cu32 as HRESULT; pub const NTE_INTERNAL_ERROR: HRESULT = 0x8009002Du32 as HRESULT; pub const NTE_UI_REQUIRED: HRESULT = 0x8009002Eu32 as HRESULT; pub const NTE_HMAC_NOT_SUPPORTED: HRESULT = 0x8009002Fu32 as HRESULT; pub const NTE_DEVICE_NOT_READY: HRESULT = 0x80090030u32 as HRESULT; pub const NTE_AUTHENTICATION_IGNORED: HRESULT = 0x80090031u32 as HRESULT; pub const NTE_VALIDATION_FAILED: HRESULT = 0x80090032u32 as HRESULT; pub const NTE_INCORRECT_PASSWORD: HRESULT = 0x80090033u32 as HRESULT; pub const NTE_ENCRYPTION_FAILURE: HRESULT = 0x80090034u32 as HRESULT; pub const NTE_DEVICE_NOT_FOUND: HRESULT = 0x80090035u32 as HRESULT; pub const SEC_E_INSUFFICIENT_MEMORY: HRESULT = 0x80090300u32 as HRESULT; pub const SEC_E_INVALID_HANDLE: HRESULT = 0x80090301u32 as HRESULT; pub const SEC_E_UNSUPPORTED_FUNCTION: HRESULT = 0x80090302u32 as HRESULT; pub const SEC_E_TARGET_UNKNOWN: HRESULT = 0x80090303u32 as HRESULT; pub const SEC_E_INTERNAL_ERROR: HRESULT = 0x80090304u32 as HRESULT; pub const SEC_E_SECPKG_NOT_FOUND: HRESULT = 0x80090305u32 as HRESULT; pub const SEC_E_NOT_OWNER: HRESULT = 0x80090306u32 as HRESULT; pub const SEC_E_CANNOT_INSTALL: HRESULT = 0x80090307u32 as HRESULT; pub const SEC_E_INVALID_TOKEN: HRESULT = 0x80090308u32 as HRESULT; pub const SEC_E_CANNOT_PACK: HRESULT = 0x80090309u32 as HRESULT; pub const SEC_E_QOP_NOT_SUPPORTED: HRESULT = 0x8009030Au32 as HRESULT; pub const SEC_E_NO_IMPERSONATION: HRESULT = 0x8009030Bu32 as HRESULT; pub const SEC_E_LOGON_DENIED: HRESULT = 0x8009030Cu32 as HRESULT; pub const SEC_E_UNKNOWN_CREDENTIALS: HRESULT = 0x8009030Du32 as HRESULT; pub const SEC_E_NO_CREDENTIALS: HRESULT = 0x8009030Eu32 as HRESULT; pub const SEC_E_MESSAGE_ALTERED: HRESULT = 0x8009030Fu32 as HRESULT; pub const SEC_E_OUT_OF_SEQUENCE: HRESULT = 0x80090310u32 as HRESULT; pub const SEC_E_NO_AUTHENTICATING_AUTHORITY: HRESULT = 0x80090311u32 as HRESULT; pub const SEC_I_CONTINUE_NEEDED: HRESULT = 0x00090312; pub const SEC_I_COMPLETE_NEEDED: HRESULT = 0x00090313; pub const SEC_I_COMPLETE_AND_CONTINUE: HRESULT = 0x00090314; pub const SEC_I_LOCAL_LOGON: HRESULT = 0x00090315; pub const SEC_E_BAD_PKGID: HRESULT = 0x80090316u32 as HRESULT; pub const SEC_E_CONTEXT_EXPIRED: HRESULT = 0x80090317u32 as HRESULT; pub const SEC_I_CONTEXT_EXPIRED: HRESULT = 0x00090317; pub const SEC_E_INCOMPLETE_MESSAGE: HRESULT = 0x80090318u32 as HRESULT; pub const SEC_E_INCOMPLETE_CREDENTIALS: HRESULT = 0x80090320u32 as HRESULT; pub const SEC_E_BUFFER_TOO_SMALL: HRESULT = 0x80090321u32 as HRESULT; pub const SEC_I_INCOMPLETE_CREDENTIALS: HRESULT = 0x00090320; pub const SEC_I_RENEGOTIATE: HRESULT = 0x00090321; pub const SEC_E_WRONG_PRINCIPAL: HRESULT = 0x80090322u32 as HRESULT; pub const SEC_I_NO_LSA_CONTEXT: HRESULT = 0x00090323; pub const SEC_E_TIME_SKEW: HRESULT = 0x80090324u32 as HRESULT; pub const SEC_E_UNTRUSTED_ROOT: HRESULT = 0x80090325u32 as HRESULT; pub const SEC_E_ILLEGAL_MESSAGE: HRESULT = 0x80090326u32 as HRESULT; pub const SEC_E_CERT_UNKNOWN: HRESULT = 0x80090327u32 as HRESULT; pub const SEC_E_CERT_EXPIRED: HRESULT = 0x80090328u32 as HRESULT; pub const SEC_E_ENCRYPT_FAILURE: HRESULT = 0x80090329u32 as HRESULT; pub const SEC_E_DECRYPT_FAILURE: HRESULT = 0x80090330u32 as HRESULT; pub const SEC_E_ALGORITHM_MISMATCH: HRESULT = 0x80090331u32 as HRESULT; pub const SEC_E_SECURITY_QOS_FAILED: HRESULT = 0x80090332u32 as HRESULT; pub const SEC_E_UNFINISHED_CONTEXT_DELETED: HRESULT = 0x80090333u32 as HRESULT; pub const SEC_E_NO_TGT_REPLY: HRESULT = 0x80090334u32 as HRESULT; pub const SEC_E_NO_IP_ADDRESSES: HRESULT = 0x80090335u32 as HRESULT; pub const SEC_E_WRONG_CREDENTIAL_HANDLE: HRESULT = 0x80090336u32 as HRESULT; pub const SEC_E_CRYPTO_SYSTEM_INVALID: HRESULT = 0x80090337u32 as HRESULT; pub const SEC_E_MAX_REFERRALS_EXCEEDED: HRESULT = 0x80090338u32 as HRESULT; pub const SEC_E_MUST_BE_KDC: HRESULT = 0x80090339u32 as HRESULT; pub const SEC_E_STRONG_CRYPTO_NOT_SUPPORTED: HRESULT = 0x8009033Au32 as HRESULT; pub const SEC_E_TOO_MANY_PRINCIPALS: HRESULT = 0x8009033Bu32 as HRESULT; pub const SEC_E_NO_PA_DATA: HRESULT = 0x8009033Cu32 as HRESULT; pub const SEC_E_PKINIT_NAME_MISMATCH: HRESULT = 0x8009033Du32 as HRESULT; pub const SEC_E_SMARTCARD_LOGON_REQUIRED: HRESULT = 0x8009033Eu32 as HRESULT; pub const SEC_E_SHUTDOWN_IN_PROGRESS: HRESULT = 0x8009033Fu32 as HRESULT; pub const SEC_E_KDC_INVALID_REQUEST: HRESULT = 0x80090340u32 as HRESULT; pub const SEC_E_KDC_UNABLE_TO_REFER: HRESULT = 0x80090341u32 as HRESULT; pub const SEC_E_KDC_UNKNOWN_ETYPE: HRESULT = 0x80090342u32 as HRESULT; pub const SEC_E_UNSUPPORTED_PREAUTH: HRESULT = 0x80090343u32 as HRESULT; pub const SEC_E_DELEGATION_REQUIRED: HRESULT = 0x80090345u32 as HRESULT; pub const SEC_E_BAD_BINDINGS: HRESULT = 0x80090346u32 as HRESULT; pub const SEC_E_MULTIPLE_ACCOUNTS: HRESULT = 0x80090347u32 as HRESULT; pub const SEC_E_NO_KERB_KEY: HRESULT = 0x80090348u32 as HRESULT; pub const SEC_E_CERT_WRONG_USAGE: HRESULT = 0x80090349u32 as HRESULT; pub const SEC_E_DOWNGRADE_DETECTED: HRESULT = 0x80090350u32 as HRESULT; pub const SEC_E_SMARTCARD_CERT_REVOKED: HRESULT = 0x80090351u32 as HRESULT; pub const SEC_E_ISSUING_CA_UNTRUSTED: HRESULT = 0x80090352u32 as HRESULT; pub const SEC_E_REVOCATION_OFFLINE_C: HRESULT = 0x80090353u32 as HRESULT; pub const SEC_E_PKINIT_CLIENT_FAILURE: HRESULT = 0x80090354u32 as HRESULT; pub const SEC_E_SMARTCARD_CERT_EXPIRED: HRESULT = 0x80090355u32 as HRESULT; pub const SEC_E_NO_S4U_PROT_SUPPORT: HRESULT = 0x80090356u32 as HRESULT; pub const SEC_E_CROSSREALM_DELEGATION_FAILURE: HRESULT = 0x80090357u32 as HRESULT; pub const SEC_E_REVOCATION_OFFLINE_KDC: HRESULT = 0x80090358u32 as HRESULT; pub const SEC_E_ISSUING_CA_UNTRUSTED_KDC: HRESULT = 0x80090359u32 as HRESULT; pub const SEC_E_KDC_CERT_EXPIRED: HRESULT = 0x8009035Au32 as HRESULT; pub const SEC_E_KDC_CERT_REVOKED: HRESULT = 0x8009035Bu32 as HRESULT; pub const SEC_I_SIGNATURE_NEEDED: HRESULT = 0x0009035C; pub const SEC_E_INVALID_PARAMETER: HRESULT = 0x8009035Du32 as HRESULT; pub const SEC_E_DELEGATION_POLICY: HRESULT = 0x8009035Eu32 as HRESULT; pub const SEC_E_POLICY_NLTM_ONLY: HRESULT = 0x8009035Fu32 as HRESULT; pub const SEC_I_NO_RENEGOTIATION: HRESULT = 0x00090360; pub const SEC_E_NO_CONTEXT: HRESULT = 0x80090361u32 as HRESULT; pub const SEC_E_PKU2U_CERT_FAILURE: HRESULT = 0x80090362u32 as HRESULT; pub const SEC_E_MUTUAL_AUTH_FAILED: HRESULT = 0x80090363u32 as HRESULT; pub const SEC_I_MESSAGE_FRAGMENT: HRESULT = 0x00090364; pub const SEC_E_ONLY_HTTPS_ALLOWED: HRESULT = 0x80090365u32 as HRESULT; pub const SEC_I_CONTINUE_NEEDED_MESSAGE_OK: HRESULT = 0x00090366; pub const SEC_E_APPLICATION_PROTOCOL_MISMATCH: HRESULT = 0x80090367u32 as HRESULT; pub const SEC_E_NO_SPM: HRESULT = SEC_E_INTERNAL_ERROR; pub const SEC_E_NOT_SUPPORTED: HRESULT = SEC_E_UNSUPPORTED_FUNCTION; pub const CRYPT_E_MSG_ERROR: HRESULT = 0x80091001u32 as HRESULT; pub const CRYPT_E_UNKNOWN_ALGO: HRESULT = 0x80091002u32 as HRESULT; pub const CRYPT_E_OID_FORMAT: HRESULT = 0x80091003u32 as HRESULT; pub const CRYPT_E_INVALID_MSG_TYPE: HRESULT = 0x80091004u32 as HRESULT; pub const CRYPT_E_UNEXPECTED_ENCODING: HRESULT = 0x80091005u32 as HRESULT; pub const CRYPT_E_AUTH_ATTR_MISSING: HRESULT = 0x80091006u32 as HRESULT; pub const CRYPT_E_HASH_VALUE: HRESULT = 0x80091007u32 as HRESULT; pub const CRYPT_E_INVALID_INDEX: HRESULT = 0x80091008u32 as HRESULT; pub const CRYPT_E_ALREADY_DECRYPTED: HRESULT = 0x80091009u32 as HRESULT; pub const CRYPT_E_NOT_DECRYPTED: HRESULT = 0x8009100Au32 as HRESULT; pub const CRYPT_E_RECIPIENT_NOT_FOUND: HRESULT = 0x8009100Bu32 as HRESULT; pub const CRYPT_E_CONTROL_TYPE: HRESULT = 0x8009100Cu32 as HRESULT; pub const CRYPT_E_ISSUER_SERIALNUMBER: HRESULT = 0x8009100Du32 as HRESULT; pub const CRYPT_E_SIGNER_NOT_FOUND: HRESULT = 0x8009100Eu32 as HRESULT; pub const CRYPT_E_ATTRIBUTES_MISSING: HRESULT = 0x8009100Fu32 as HRESULT; pub const CRYPT_E_STREAM_MSG_NOT_READY: HRESULT = 0x80091010u32 as HRESULT; pub const CRYPT_E_STREAM_INSUFFICIENT_DATA: HRESULT = 0x80091011u32 as HRESULT; pub const CRYPT_I_NEW_PROTECTION_REQUIRED: HRESULT = 0x00091012; pub const CRYPT_E_BAD_LEN: HRESULT = 0x80092001u32 as HRESULT; pub const CRYPT_E_BAD_ENCODE: HRESULT = 0x80092002u32 as HRESULT; pub const CRYPT_E_FILE_ERROR: HRESULT = 0x80092003u32 as HRESULT; pub const CRYPT_E_NOT_FOUND: HRESULT = 0x80092004u32 as HRESULT; pub const CRYPT_E_EXISTS: HRESULT = 0x80092005u32 as HRESULT; pub const CRYPT_E_NO_PROVIDER: HRESULT = 0x80092006u32 as HRESULT; pub const CRYPT_E_SELF_SIGNED: HRESULT = 0x80092007u32 as HRESULT; pub const CRYPT_E_DELETED_PREV: HRESULT = 0x80092008u32 as HRESULT; pub const CRYPT_E_NO_MATCH: HRESULT = 0x80092009u32 as HRESULT; pub const CRYPT_E_UNEXPECTED_MSG_TYPE: HRESULT = 0x8009200Au32 as HRESULT; pub const CRYPT_E_NO_KEY_PROPERTY: HRESULT = 0x8009200Bu32 as HRESULT; pub const CRYPT_E_NO_DECRYPT_CERT: HRESULT = 0x8009200Cu32 as HRESULT; pub const CRYPT_E_BAD_MSG: HRESULT = 0x8009200Du32 as HRESULT; pub const CRYPT_E_NO_SIGNER: HRESULT = 0x8009200Eu32 as HRESULT; pub const CRYPT_E_PENDING_CLOSE: HRESULT = 0x8009200Fu32 as HRESULT; pub const CRYPT_E_REVOKED: HRESULT = 0x80092010u32 as HRESULT; pub const CRYPT_E_NO_REVOCATION_DLL: HRESULT = 0x80092011u32 as HRESULT; pub const CRYPT_E_NO_REVOCATION_CHECK: HRESULT = 0x80092012u32 as HRESULT; pub const CRYPT_E_REVOCATION_OFFLINE: HRESULT = 0x80092013u32 as HRESULT; pub const CRYPT_E_NOT_IN_REVOCATION_DATABASE: HRESULT = 0x80092014u32 as HRESULT; pub const CRYPT_E_INVALID_NUMERIC_STRING: HRESULT = 0x80092020u32 as HRESULT; pub const CRYPT_E_INVALID_PRINTABLE_STRING: HRESULT = 0x80092021u32 as HRESULT; pub const CRYPT_E_INVALID_IA5_STRING: HRESULT = 0x80092022u32 as HRESULT; pub const CRYPT_E_INVALID_X500_STRING: HRESULT = 0x80092023u32 as HRESULT; pub const CRYPT_E_NOT_CHAR_STRING: HRESULT = 0x80092024u32 as HRESULT; pub const CRYPT_E_FILERESIZED: HRESULT = 0x80092025u32 as HRESULT; pub const CRYPT_E_SECURITY_SETTINGS: HRESULT = 0x80092026u32 as HRESULT; pub const CRYPT_E_NO_VERIFY_USAGE_DLL: HRESULT = 0x80092027u32 as HRESULT; pub const CRYPT_E_NO_VERIFY_USAGE_CHECK: HRESULT = 0x80092028u32 as HRESULT; pub const CRYPT_E_VERIFY_USAGE_OFFLINE: HRESULT = 0x80092029u32 as HRESULT; pub const CRYPT_E_NOT_IN_CTL: HRESULT = 0x8009202Au32 as HRESULT; pub const CRYPT_E_NO_TRUSTED_SIGNER: HRESULT = 0x8009202Bu32 as HRESULT; pub const CRYPT_E_MISSING_PUBKEY_PARA: HRESULT = 0x8009202Cu32 as HRESULT; pub const CRYPT_E_OBJECT_LOCATOR_OBJECT_NOT_FOUND: HRESULT = 0x8009202Du32 as HRESULT; pub const CRYPT_E_OSS_ERROR: HRESULT = 0x80093000u32 as HRESULT; pub const OSS_MORE_BUF: HRESULT = 0x80093001u32 as HRESULT; pub const OSS_NEGATIVE_UINTEGER: HRESULT = 0x80093002u32 as HRESULT; pub const OSS_PDU_RANGE: HRESULT = 0x80093003u32 as HRESULT; pub const OSS_MORE_INPUT: HRESULT = 0x80093004u32 as HRESULT; pub const OSS_DATA_ERROR: HRESULT = 0x80093005u32 as HRESULT; pub const OSS_BAD_ARG: HRESULT = 0x80093006u32 as HRESULT; pub const OSS_BAD_VERSION: HRESULT = 0x80093007u32 as HRESULT; pub const OSS_OUT_MEMORY: HRESULT = 0x80093008u32 as HRESULT; pub const OSS_PDU_MISMATCH: HRESULT = 0x80093009u32 as HRESULT; pub const OSS_LIMITED: HRESULT = 0x8009300Au32 as HRESULT; pub const OSS_BAD_PTR: HRESULT = 0x8009300Bu32 as HRESULT; pub const OSS_BAD_TIME: HRESULT = 0x8009300Cu32 as HRESULT; pub const OSS_INDEFINITE_NOT_SUPPORTED: HRESULT = 0x8009300Du32 as HRESULT; pub const OSS_MEM_ERROR: HRESULT = 0x8009300Eu32 as HRESULT; pub const OSS_BAD_TABLE: HRESULT = 0x8009300Fu32 as HRESULT; pub const OSS_TOO_LONG: HRESULT = 0x80093010u32 as HRESULT; pub const OSS_CONSTRAINT_VIOLATED: HRESULT = 0x80093011u32 as HRESULT; pub const OSS_FATAL_ERROR: HRESULT = 0x80093012u32 as HRESULT; pub const OSS_ACCESS_SERIALIZATION_ERROR: HRESULT = 0x80093013u32 as HRESULT; pub const OSS_NULL_TBL: HRESULT = 0x80093014u32 as HRESULT; pub const OSS_NULL_FCN: HRESULT = 0x80093015u32 as HRESULT; pub const OSS_BAD_ENCRULES: HRESULT = 0x80093016u32 as HRESULT; pub const OSS_UNAVAIL_ENCRULES: HRESULT = 0x80093017u32 as HRESULT; pub const OSS_CANT_OPEN_TRACE_WINDOW: HRESULT = 0x80093018u32 as HRESULT; pub const OSS_UNIMPLEMENTED: HRESULT = 0x80093019u32 as HRESULT; pub const OSS_OID_DLL_NOT_LINKED: HRESULT = 0x8009301Au32 as HRESULT; pub const OSS_CANT_OPEN_TRACE_FILE: HRESULT = 0x8009301Bu32 as HRESULT; pub const OSS_TRACE_FILE_ALREADY_OPEN: HRESULT = 0x8009301Cu32 as HRESULT; pub const OSS_TABLE_MISMATCH: HRESULT = 0x8009301Du32 as HRESULT; pub const OSS_TYPE_NOT_SUPPORTED: HRESULT = 0x8009301Eu32 as HRESULT; pub const OSS_REAL_DLL_NOT_LINKED: HRESULT = 0x8009301Fu32 as HRESULT; pub const OSS_REAL_CODE_NOT_LINKED: HRESULT = 0x80093020u32 as HRESULT; pub const OSS_OUT_OF_RANGE: HRESULT = 0x80093021u32 as HRESULT; pub const OSS_COPIER_DLL_NOT_LINKED: HRESULT = 0x80093022u32 as HRESULT; pub const OSS_CONSTRAINT_DLL_NOT_LINKED: HRESULT = 0x80093023u32 as HRESULT; pub const OSS_COMPARATOR_DLL_NOT_LINKED: HRESULT = 0x80093024u32 as HRESULT; pub const OSS_COMPARATOR_CODE_NOT_LINKED: HRESULT = 0x80093025u32 as HRESULT; pub const OSS_MEM_MGR_DLL_NOT_LINKED: HRESULT = 0x80093026u32 as HRESULT; pub const OSS_PDV_DLL_NOT_LINKED: HRESULT = 0x80093027u32 as HRESULT; pub const OSS_PDV_CODE_NOT_LINKED: HRESULT = 0x80093028u32 as HRESULT; pub const OSS_API_DLL_NOT_LINKED: HRESULT = 0x80093029u32 as HRESULT; pub const OSS_BERDER_DLL_NOT_LINKED: HRESULT = 0x8009302Au32 as HRESULT; pub const OSS_PER_DLL_NOT_LINKED: HRESULT = 0x8009302Bu32 as HRESULT; pub const OSS_OPEN_TYPE_ERROR: HRESULT = 0x8009302Cu32 as HRESULT; pub const OSS_MUTEX_NOT_CREATED: HRESULT = 0x8009302Du32 as HRESULT; pub const OSS_CANT_CLOSE_TRACE_FILE: HRESULT = 0x8009302Eu32 as HRESULT; pub const CRYPT_E_ASN1_ERROR: HRESULT = 0x80093100u32 as HRESULT; pub const CRYPT_E_ASN1_INTERNAL: HRESULT = 0x80093101u32 as HRESULT; pub const CRYPT_E_ASN1_EOD: HRESULT = 0x80093102u32 as HRESULT; pub const CRYPT_E_ASN1_CORRUPT: HRESULT = 0x80093103u32 as HRESULT; pub const CRYPT_E_ASN1_LARGE: HRESULT = 0x80093104u32 as HRESULT; pub const CRYPT_E_ASN1_CONSTRAINT: HRESULT = 0x80093105u32 as HRESULT; pub const CRYPT_E_ASN1_MEMORY: HRESULT = 0x80093106u32 as HRESULT; pub const CRYPT_E_ASN1_OVERFLOW: HRESULT = 0x80093107u32 as HRESULT; pub const CRYPT_E_ASN1_BADPDU: HRESULT = 0x80093108u32 as HRESULT; pub const CRYPT_E_ASN1_BADARGS: HRESULT = 0x80093109u32 as HRESULT; pub const CRYPT_E_ASN1_BADREAL: HRESULT = 0x8009310Au32 as HRESULT; pub const CRYPT_E_ASN1_BADTAG: HRESULT = 0x8009310Bu32 as HRESULT; pub const CRYPT_E_ASN1_CHOICE: HRESULT = 0x8009310Cu32 as HRESULT; pub const CRYPT_E_ASN1_RULE: HRESULT = 0x8009310Du32 as HRESULT; pub const CRYPT_E_ASN1_UTF8: HRESULT = 0x8009310Eu32 as HRESULT; pub const CRYPT_E_ASN1_PDU_TYPE: HRESULT = 0x80093133u32 as HRESULT; pub const CRYPT_E_ASN1_NYI: HRESULT = 0x80093134u32 as HRESULT; pub const CRYPT_E_ASN1_EXTENDED: HRESULT = 0x80093201u32 as HRESULT; pub const CRYPT_E_ASN1_NOEOD: HRESULT = 0x80093202u32 as HRESULT; pub const CERTSRV_E_BAD_REQUESTSUBJECT: HRESULT = 0x80094001u32 as HRESULT; pub const CERTSRV_E_NO_REQUEST: HRESULT = 0x80094002u32 as HRESULT; pub const CERTSRV_E_BAD_REQUESTSTATUS: HRESULT = 0x80094003u32 as HRESULT; pub const CERTSRV_E_PROPERTY_EMPTY: HRESULT = 0x80094004u32 as HRESULT; pub const CERTSRV_E_INVALID_CA_CERTIFICATE: HRESULT = 0x80094005u32 as HRESULT; pub const CERTSRV_E_SERVER_SUSPENDED: HRESULT = 0x80094006u32 as HRESULT; pub const CERTSRV_E_ENCODING_LENGTH: HRESULT = 0x80094007u32 as HRESULT; pub const CERTSRV_E_ROLECONFLICT: HRESULT = 0x80094008u32 as HRESULT; pub const CERTSRV_E_RESTRICTEDOFFICER: HRESULT = 0x80094009u32 as HRESULT; pub const CERTSRV_E_KEY_ARCHIVAL_NOT_CONFIGURED: HRESULT = 0x8009400Au32 as HRESULT; pub const CERTSRV_E_NO_VALID_KRA: HRESULT = 0x8009400Bu32 as HRESULT; pub const CERTSRV_E_BAD_REQUEST_KEY_ARCHIVAL: HRESULT = 0x8009400Cu32 as HRESULT; pub const CERTSRV_E_NO_CAADMIN_DEFINED: HRESULT = 0x8009400Du32 as HRESULT; pub const CERTSRV_E_BAD_RENEWAL_CERT_ATTRIBUTE: HRESULT = 0x8009400Eu32 as HRESULT; pub const CERTSRV_E_NO_DB_SESSIONS: HRESULT = 0x8009400Fu32 as HRESULT; pub const CERTSRV_E_ALIGNMENT_FAULT: HRESULT = 0x80094010u32 as HRESULT; pub const CERTSRV_E_ENROLL_DENIED: HRESULT = 0x80094011u32 as HRESULT; pub const CERTSRV_E_TEMPLATE_DENIED: HRESULT = 0x80094012u32 as HRESULT; pub const CERTSRV_E_DOWNLEVEL_DC_SSL_OR_UPGRADE: HRESULT = 0x80094013u32 as HRESULT; pub const CERTSRV_E_ADMIN_DENIED_REQUEST: HRESULT = 0x80094014u32 as HRESULT; pub const CERTSRV_E_NO_POLICY_SERVER: HRESULT = 0x80094015u32 as HRESULT; pub const CERTSRV_E_WEAK_SIGNATURE_OR_KEY: HRESULT = 0x80094016u32 as HRESULT; pub const CERTSRV_E_KEY_ATTESTATION_NOT_SUPPORTED: HRESULT = 0x80094017u32 as HRESULT; pub const CERTSRV_E_ENCRYPTION_CERT_REQUIRED: HRESULT = 0x80094018u32 as HRESULT; pub const CERTSRV_E_UNSUPPORTED_CERT_TYPE: HRESULT = 0x80094800u32 as HRESULT; pub const CERTSRV_E_NO_CERT_TYPE: HRESULT = 0x80094801u32 as HRESULT; pub const CERTSRV_E_TEMPLATE_CONFLICT: HRESULT = 0x80094802u32 as HRESULT; pub const CERTSRV_E_SUBJECT_ALT_NAME_REQUIRED: HRESULT = 0x80094803u32 as HRESULT; pub const CERTSRV_E_ARCHIVED_KEY_REQUIRED: HRESULT = 0x80094804u32 as HRESULT; pub const CERTSRV_E_SMIME_REQUIRED: HRESULT = 0x80094805u32 as HRESULT; pub const CERTSRV_E_BAD_RENEWAL_SUBJECT: HRESULT = 0x80094806u32 as HRESULT; pub const CERTSRV_E_BAD_TEMPLATE_VERSION: HRESULT = 0x80094807u32 as HRESULT; pub const CERTSRV_E_TEMPLATE_POLICY_REQUIRED: HRESULT = 0x80094808u32 as HRESULT; pub const CERTSRV_E_SIGNATURE_POLICY_REQUIRED: HRESULT = 0x80094809u32 as HRESULT; pub const CERTSRV_E_SIGNATURE_COUNT: HRESULT = 0x8009480Au32 as HRESULT; pub const CERTSRV_E_SIGNATURE_REJECTED: HRESULT = 0x8009480Bu32 as HRESULT; pub const CERTSRV_E_ISSUANCE_POLICY_REQUIRED: HRESULT = 0x8009480Cu32 as HRESULT; pub const CERTSRV_E_SUBJECT_UPN_REQUIRED: HRESULT = 0x8009480Du32 as HRESULT; pub const CERTSRV_E_SUBJECT_DIRECTORY_GUID_REQUIRED: HRESULT = 0x8009480Eu32 as HRESULT; pub const CERTSRV_E_SUBJECT_DNS_REQUIRED: HRESULT = 0x8009480Fu32 as HRESULT; pub const CERTSRV_E_ARCHIVED_KEY_UNEXPECTED: HRESULT = 0x80094810u32 as HRESULT; pub const CERTSRV_E_KEY_LENGTH: HRESULT = 0x80094811u32 as HRESULT; pub const CERTSRV_E_SUBJECT_EMAIL_REQUIRED: HRESULT = 0x80094812u32 as HRESULT; pub const CERTSRV_E_UNKNOWN_CERT_TYPE: HRESULT = 0x80094813u32 as HRESULT; pub const CERTSRV_E_CERT_TYPE_OVERLAP: HRESULT = 0x80094814u32 as HRESULT; pub const CERTSRV_E_TOO_MANY_SIGNATURES: HRESULT = 0x80094815u32 as HRESULT; pub const CERTSRV_E_RENEWAL_BAD_PUBLIC_KEY: HRESULT = 0x80094816u32 as HRESULT; pub const CERTSRV_E_INVALID_EK: HRESULT = 0x80094817u32 as HRESULT; pub const CERTSRV_E_INVALID_IDBINDING: HRESULT = 0x80094818u32 as HRESULT; pub const CERTSRV_E_INVALID_ATTESTATION: HRESULT = 0x80094819u32 as HRESULT; pub const CERTSRV_E_KEY_ATTESTATION: HRESULT = 0x8009481Au32 as HRESULT; pub const CERTSRV_E_CORRUPT_KEY_ATTESTATION: HRESULT = 0x8009481Bu32 as HRESULT; pub const CERTSRV_E_EXPIRED_CHALLENGE: HRESULT = 0x8009481Cu32 as HRESULT; pub const CERTSRV_E_INVALID_RESPONSE: HRESULT = 0x8009481Du32 as HRESULT; pub const CERTSRV_E_INVALID_REQUESTID: HRESULT = 0x8009481Eu32 as HRESULT; pub const XENROLL_E_KEY_NOT_EXPORTABLE: HRESULT = 0x80095000u32 as HRESULT; pub const XENROLL_E_CANNOT_ADD_ROOT_CERT: HRESULT = 0x80095001u32 as HRESULT; pub const XENROLL_E_RESPONSE_KA_HASH_NOT_FOUND: HRESULT = 0x80095002u32 as HRESULT; pub const XENROLL_E_RESPONSE_UNEXPECTED_KA_HASH: HRESULT = 0x80095003u32 as HRESULT; pub const XENROLL_E_RESPONSE_KA_HASH_MISMATCH: HRESULT = 0x80095004u32 as HRESULT; pub const XENROLL_E_KEYSPEC_SMIME_MISMATCH: HRESULT = 0x80095005u32 as HRESULT; pub const TRUST_E_SYSTEM_ERROR: HRESULT = 0x80096001u32 as HRESULT; pub const TRUST_E_NO_SIGNER_CERT: HRESULT = 0x80096002u32 as HRESULT; pub const TRUST_E_COUNTER_SIGNER: HRESULT = 0x80096003u32 as HRESULT; pub const TRUST_E_CERT_SIGNATURE: HRESULT = 0x80096004u32 as HRESULT; pub const TRUST_E_TIME_STAMP: HRESULT = 0x80096005u32 as HRESULT; pub const TRUST_E_BAD_DIGEST: HRESULT = 0x80096010u32 as HRESULT; pub const TRUST_E_BASIC_CONSTRAINTS: HRESULT = 0x80096019u32 as HRESULT; pub const TRUST_E_FINANCIAL_CRITERIA: HRESULT = 0x8009601Eu32 as HRESULT; pub const MSSIPOTF_E_OUTOFMEMRANGE: HRESULT = 0x80097001u32 as HRESULT; pub const MSSIPOTF_E_CANTGETOBJECT: HRESULT = 0x80097002u32 as HRESULT; pub const MSSIPOTF_E_NOHEADTABLE: HRESULT = 0x80097003u32 as HRESULT; pub const MSSIPOTF_E_BAD_MAGICNUMBER: HRESULT = 0x80097004u32 as HRESULT; pub const MSSIPOTF_E_BAD_OFFSET_TABLE: HRESULT = 0x80097005u32 as HRESULT; pub const MSSIPOTF_E_TABLE_TAGORDER: HRESULT = 0x80097006u32 as HRESULT; pub const MSSIPOTF_E_TABLE_LONGWORD: HRESULT = 0x80097007u32 as HRESULT; pub const MSSIPOTF_E_BAD_FIRST_TABLE_PLACEMENT: HRESULT = 0x80097008u32 as HRESULT; pub const MSSIPOTF_E_TABLES_OVERLAP: HRESULT = 0x80097009u32 as HRESULT; pub const MSSIPOTF_E_TABLE_PADBYTES: HRESULT = 0x8009700Au32 as HRESULT; pub const MSSIPOTF_E_FILETOOSMALL: HRESULT = 0x8009700Bu32 as HRESULT; pub const MSSIPOTF_E_TABLE_CHECKSUM: HRESULT = 0x8009700Cu32 as HRESULT; pub const MSSIPOTF_E_FILE_CHECKSUM: HRESULT = 0x8009700Du32 as HRESULT; pub const MSSIPOTF_E_FAILED_POLICY: HRESULT = 0x80097010u32 as HRESULT; pub const MSSIPOTF_E_FAILED_HINTS_CHECK: HRESULT = 0x80097011u32 as HRESULT; pub const MSSIPOTF_E_NOT_OPENTYPE: HRESULT = 0x80097012u32 as HRESULT; pub const MSSIPOTF_E_FILE: HRESULT = 0x80097013u32 as HRESULT; pub const MSSIPOTF_E_CRYPT: HRESULT = 0x80097014u32 as HRESULT; pub const MSSIPOTF_E_BADVERSION: HRESULT = 0x80097015u32 as HRESULT; pub const MSSIPOTF_E_DSIG_STRUCTURE: HRESULT = 0x80097016u32 as HRESULT; pub const MSSIPOTF_E_PCONST_CHECK: HRESULT = 0x80097017u32 as HRESULT; pub const MSSIPOTF_E_STRUCTURE: HRESULT = 0x80097018u32 as HRESULT; pub const ERROR_CRED_REQUIRES_CONFIRMATION: HRESULT = 0x80097019u32 as HRESULT; pub const NTE_OP_OK: HRESULT = 0; pub const TRUST_E_PROVIDER_UNKNOWN: HRESULT = 0x800B0001u32 as HRESULT; pub const TRUST_E_ACTION_UNKNOWN: HRESULT = 0x800B0002u32 as HRESULT; pub const TRUST_E_SUBJECT_FORM_UNKNOWN: HRESULT = 0x800B0003u32 as HRESULT; pub const TRUST_E_SUBJECT_NOT_TRUSTED: HRESULT = 0x800B0004u32 as HRESULT; pub const DIGSIG_E_ENCODE: HRESULT = 0x800B0005u32 as HRESULT; pub const DIGSIG_E_DECODE: HRESULT = 0x800B0006u32 as HRESULT; pub const DIGSIG_E_EXTENSIBILITY: HRESULT = 0x800B0007u32 as HRESULT; pub const DIGSIG_E_CRYPTO: HRESULT = 0x800B0008u32 as HRESULT; pub const PERSIST_E_SIZEDEFINITE: HRESULT = 0x800B0009u32 as HRESULT; pub const PERSIST_E_SIZEINDEFINITE: HRESULT = 0x800B000Au32 as HRESULT; pub const PERSIST_E_NOTSELFSIZING: HRESULT = 0x800B000Bu32 as HRESULT; pub const TRUST_E_NOSIGNATURE: HRESULT = 0x800B0100u32 as HRESULT; pub const CERT_E_EXPIRED: HRESULT = 0x800B0101u32 as HRESULT; pub const CERT_E_VALIDITYPERIODNESTING: HRESULT = 0x800B0102u32 as HRESULT; pub const CERT_E_ROLE: HRESULT = 0x800B0103u32 as HRESULT; pub const CERT_E_PATHLENCONST: HRESULT = 0x800B0104u32 as HRESULT; pub const CERT_E_CRITICAL: HRESULT = 0x800B0105u32 as HRESULT; pub const CERT_E_PURPOSE: HRESULT = 0x800B0106u32 as HRESULT; pub const CERT_E_ISSUERCHAINING: HRESULT = 0x800B0107u32 as HRESULT; pub const CERT_E_MALFORMED: HRESULT = 0x800B0108u32 as HRESULT; pub const CERT_E_UNTRUSTEDROOT: HRESULT = 0x800B0109u32 as HRESULT; pub const CERT_E_CHAINING: HRESULT = 0x800B010Au32 as HRESULT; pub const TRUST_E_FAIL: HRESULT = 0x800B010Bu32 as HRESULT; pub const CERT_E_REVOKED: HRESULT = 0x800B010Cu32 as HRESULT; pub const CERT_E_UNTRUSTEDTESTROOT: HRESULT = 0x800B010Du32 as HRESULT; pub const CERT_E_REVOCATION_FAILURE: HRESULT = 0x800B010Eu32 as HRESULT; pub const CERT_E_CN_NO_MATCH: HRESULT = 0x800B010Fu32 as HRESULT; pub const CERT_E_WRONG_USAGE: HRESULT = 0x800B0110u32 as HRESULT; pub const TRUST_E_EXPLICIT_DISTRUST: HRESULT = 0x800B0111u32 as HRESULT; pub const CERT_E_UNTRUSTEDCA: HRESULT = 0x800B0112u32 as HRESULT; pub const CERT_E_INVALID_POLICY: HRESULT = 0x800B0113u32 as HRESULT; pub const CERT_E_INVALID_NAME: HRESULT = 0x800B0114u32 as HRESULT; pub const SPAPI_E_EXPECTED_SECTION_NAME: HRESULT = 0x800F0000u32 as HRESULT; pub const SPAPI_E_BAD_SECTION_NAME_LINE: HRESULT = 0x800F0001u32 as HRESULT; pub const SPAPI_E_SECTION_NAME_TOO_LONG: HRESULT = 0x800F0002u32 as HRESULT; pub const SPAPI_E_GENERAL_SYNTAX: HRESULT = 0x800F0003u32 as HRESULT; pub const SPAPI_E_WRONG_INF_STYLE: HRESULT = 0x800F0100u32 as HRESULT; pub const SPAPI_E_SECTION_NOT_FOUND: HRESULT = 0x800F0101u32 as HRESULT; pub const SPAPI_E_LINE_NOT_FOUND: HRESULT = 0x800F0102u32 as HRESULT; pub const SPAPI_E_NO_BACKUP: HRESULT = 0x800F0103u32 as HRESULT; pub const SPAPI_E_NO_ASSOCIATED_CLASS: HRESULT = 0x800F0200u32 as HRESULT; pub const SPAPI_E_CLASS_MISMATCH: HRESULT = 0x800F0201u32 as HRESULT; pub const SPAPI_E_DUPLICATE_FOUND: HRESULT = 0x800F0202u32 as HRESULT; pub const SPAPI_E_NO_DRIVER_SELECTED: HRESULT = 0x800F0203u32 as HRESULT; pub const SPAPI_E_KEY_DOES_NOT_EXIST: HRESULT = 0x800F0204u32 as HRESULT; pub const SPAPI_E_INVALID_DEVINST_NAME: HRESULT = 0x800F0205u32 as HRESULT; pub const SPAPI_E_INVALID_CLASS: HRESULT = 0x800F0206u32 as HRESULT; pub const SPAPI_E_DEVINST_ALREADY_EXISTS: HRESULT = 0x800F0207u32 as HRESULT; pub const SPAPI_E_DEVINFO_NOT_REGISTERED: HRESULT = 0x800F0208u32 as HRESULT; pub const SPAPI_E_INVALID_REG_PROPERTY: HRESULT = 0x800F0209u32 as HRESULT; pub const SPAPI_E_NO_INF: HRESULT = 0x800F020Au32 as HRESULT; pub const SPAPI_E_NO_SUCH_DEVINST: HRESULT = 0x800F020Bu32 as HRESULT; pub const SPAPI_E_CANT_LOAD_CLASS_ICON: HRESULT = 0x800F020Cu32 as HRESULT; pub const SPAPI_E_INVALID_CLASS_INSTALLER: HRESULT = 0x800F020Du32 as HRESULT; pub const SPAPI_E_DI_DO_DEFAULT: HRESULT = 0x800F020Eu32 as HRESULT; pub const SPAPI_E_DI_NOFILECOPY: HRESULT = 0x800F020Fu32 as HRESULT; pub const SPAPI_E_INVALID_HWPROFILE: HRESULT = 0x800F0210u32 as HRESULT; pub const SPAPI_E_NO_DEVICE_SELECTED: HRESULT = 0x800F0211u32 as HRESULT; pub const SPAPI_E_DEVINFO_LIST_LOCKED: HRESULT = 0x800F0212u32 as HRESULT; pub const SPAPI_E_DEVINFO_DATA_LOCKED: HRESULT = 0x800F0213u32 as HRESULT; pub const SPAPI_E_DI_BAD_PATH: HRESULT = 0x800F0214u32 as HRESULT; pub const SPAPI_E_NO_CLASSINSTALL_PARAMS: HRESULT = 0x800F0215u32 as HRESULT; pub const SPAPI_E_FILEQUEUE_LOCKED: HRESULT = 0x800F0216u32 as HRESULT; pub const SPAPI_E_BAD_SERVICE_INSTALLSECT: HRESULT = 0x800F0217u32 as HRESULT; pub const SPAPI_E_NO_CLASS_DRIVER_LIST: HRESULT = 0x800F0218u32 as HRESULT; pub const SPAPI_E_NO_ASSOCIATED_SERVICE: HRESULT = 0x800F0219u32 as HRESULT; pub const SPAPI_E_NO_DEFAULT_DEVICE_INTERFACE: HRESULT = 0x800F021Au32 as HRESULT; pub const SPAPI_E_DEVICE_INTERFACE_ACTIVE: HRESULT = 0x800F021Bu32 as HRESULT; pub const SPAPI_E_DEVICE_INTERFACE_REMOVED: HRESULT = 0x800F021Cu32 as HRESULT; pub const SPAPI_E_BAD_INTERFACE_INSTALLSECT: HRESULT = 0x800F021Du32 as HRESULT; pub const SPAPI_E_NO_SUCH_INTERFACE_CLASS: HRESULT = 0x800F021Eu32 as HRESULT; pub const SPAPI_E_INVALID_REFERENCE_STRING: HRESULT = 0x800F021Fu32 as HRESULT; pub const SPAPI_E_INVALID_MACHINENAME: HRESULT = 0x800F0220u32 as HRESULT; pub const SPAPI_E_REMOTE_COMM_FAILURE: HRESULT = 0x800F0221u32 as HRESULT; pub const SPAPI_E_MACHINE_UNAVAILABLE: HRESULT = 0x800F0222u32 as HRESULT; pub const SPAPI_E_NO_CONFIGMGR_SERVICES: HRESULT = 0x800F0223u32 as HRESULT; pub const SPAPI_E_INVALID_PROPPAGE_PROVIDER: HRESULT = 0x800F0224u32 as HRESULT; pub const SPAPI_E_NO_SUCH_DEVICE_INTERFACE: HRESULT = 0x800F0225u32 as HRESULT; pub const SPAPI_E_DI_POSTPROCESSING_REQUIRED: HRESULT = 0x800F0226u32 as HRESULT; pub const SPAPI_E_INVALID_COINSTALLER: HRESULT = 0x800F0227u32 as HRESULT; pub const SPAPI_E_NO_COMPAT_DRIVERS: HRESULT = 0x800F0228u32 as HRESULT; pub const SPAPI_E_NO_DEVICE_ICON: HRESULT = 0x800F0229u32 as HRESULT; pub const SPAPI_E_INVALID_INF_LOGCONFIG: HRESULT = 0x800F022Au32 as HRESULT; pub const SPAPI_E_DI_DONT_INSTALL: HRESULT = 0x800F022Bu32 as HRESULT; pub const SPAPI_E_INVALID_FILTER_DRIVER: HRESULT = 0x800F022Cu32 as HRESULT; pub const SPAPI_E_NON_WINDOWS_NT_DRIVER: HRESULT = 0x800F022Du32 as HRESULT; pub const SPAPI_E_NON_WINDOWS_DRIVER: HRESULT = 0x800F022Eu32 as HRESULT; pub const SPAPI_E_NO_CATALOG_FOR_OEM_INF: HRESULT = 0x800F022Fu32 as HRESULT; pub const SPAPI_E_DEVINSTALL_QUEUE_NONNATIVE: HRESULT = 0x800F0230u32 as HRESULT; pub const SPAPI_E_NOT_DISABLEABLE: HRESULT = 0x800F0231u32 as HRESULT; pub const SPAPI_E_CANT_REMOVE_DEVINST: HRESULT = 0x800F0232u32 as HRESULT; pub const SPAPI_E_INVALID_TARGET: HRESULT = 0x800F0233u32 as HRESULT; pub const SPAPI_E_DRIVER_NONNATIVE: HRESULT = 0x800F0234u32 as HRESULT; pub const SPAPI_E_IN_WOW64: HRESULT = 0x800F0235u32 as HRESULT; pub const SPAPI_E_SET_SYSTEM_RESTORE_POINT: HRESULT = 0x800F0236u32 as HRESULT; pub const SPAPI_E_INCORRECTLY_COPIED_INF: HRESULT = 0x800F0237u32 as HRESULT; pub const SPAPI_E_SCE_DISABLED: HRESULT = 0x800F0238u32 as HRESULT; pub const SPAPI_E_UNKNOWN_EXCEPTION: HRESULT = 0x800F0239u32 as HRESULT; pub const SPAPI_E_PNP_REGISTRY_ERROR: HRESULT = 0x800F023Au32 as HRESULT; pub const SPAPI_E_REMOTE_REQUEST_UNSUPPORTED: HRESULT = 0x800F023Bu32 as HRESULT; pub const SPAPI_E_NOT_AN_INSTALLED_OEM_INF: HRESULT = 0x800F023Cu32 as HRESULT; pub const SPAPI_E_INF_IN_USE_BY_DEVICES: HRESULT = 0x800F023Du32 as HRESULT; pub const SPAPI_E_DI_FUNCTION_OBSOLETE: HRESULT = 0x800F023Eu32 as HRESULT; pub const SPAPI_E_NO_AUTHENTICODE_CATALOG: HRESULT = 0x800F023Fu32 as HRESULT; pub const SPAPI_E_AUTHENTICODE_DISALLOWED: HRESULT = 0x800F0240u32 as HRESULT; pub const SPAPI_E_AUTHENTICODE_TRUSTED_PUBLISHER: HRESULT = 0x800F0241u32 as HRESULT; pub const SPAPI_E_AUTHENTICODE_TRUST_NOT_ESTABLISHED: HRESULT = 0x800F0242u32 as HRESULT; pub const SPAPI_E_AUTHENTICODE_PUBLISHER_NOT_TRUSTED: HRESULT = 0x800F0243u32 as HRESULT; pub const SPAPI_E_SIGNATURE_OSATTRIBUTE_MISMATCH: HRESULT = 0x800F0244u32 as HRESULT; pub const SPAPI_E_ONLY_VALIDATE_VIA_AUTHENTICODE: HRESULT = 0x800F0245u32 as HRESULT; pub const SPAPI_E_DEVICE_INSTALLER_NOT_READY: HRESULT = 0x800F0246u32 as HRESULT; pub const SPAPI_E_DRIVER_STORE_ADD_FAILED: HRESULT = 0x800F0247u32 as HRESULT; pub const SPAPI_E_DEVICE_INSTALL_BLOCKED: HRESULT = 0x800F0248u32 as HRESULT; pub const SPAPI_E_DRIVER_INSTALL_BLOCKED: HRESULT = 0x800F0249u32 as HRESULT; pub const SPAPI_E_WRONG_INF_TYPE: HRESULT = 0x800F024Au32 as HRESULT; pub const SPAPI_E_FILE_HASH_NOT_IN_CATALOG: HRESULT = 0x800F024Bu32 as HRESULT; pub const SPAPI_E_DRIVER_STORE_DELETE_FAILED: HRESULT = 0x800F024Cu32 as HRESULT; pub const SPAPI_E_UNRECOVERABLE_STACK_OVERFLOW: HRESULT = 0x800F0300u32 as HRESULT; pub const SPAPI_E_ERROR_NOT_INSTALLED: HRESULT = 0x800F1000u32 as HRESULT; pub const SCARD_S_SUCCESS: HRESULT = NO_ERROR as HRESULT; pub const SCARD_F_INTERNAL_ERROR: HRESULT = 0x80100001u32 as HRESULT; pub const SCARD_E_CANCELLED: HRESULT = 0x80100002u32 as HRESULT; pub const SCARD_E_INVALID_HANDLE: HRESULT = 0x80100003u32 as HRESULT; pub const SCARD_E_INVALID_PARAMETER: HRESULT = 0x80100004u32 as HRESULT; pub const SCARD_E_INVALID_TARGET: HRESULT = 0x80100005u32 as HRESULT; pub const SCARD_E_NO_MEMORY: HRESULT = 0x80100006u32 as HRESULT; pub const SCARD_F_WAITED_TOO_LONG: HRESULT = 0x80100007u32 as HRESULT; pub const SCARD_E_INSUFFICIENT_BUFFER: HRESULT = 0x80100008u32 as HRESULT; pub const SCARD_E_UNKNOWN_READER: HRESULT = 0x80100009u32 as HRESULT; pub const SCARD_E_TIMEOUT: HRESULT = 0x8010000Au32 as HRESULT; pub const SCARD_E_SHARING_VIOLATION: HRESULT = 0x8010000Bu32 as HRESULT; pub const SCARD_E_NO_SMARTCARD: HRESULT = 0x8010000Cu32 as HRESULT; pub const SCARD_E_UNKNOWN_CARD: HRESULT = 0x8010000Du32 as HRESULT; pub const SCARD_E_CANT_DISPOSE: HRESULT = 0x8010000Eu32 as HRESULT; pub const SCARD_E_PROTO_MISMATCH: HRESULT = 0x8010000Fu32 as HRESULT; pub const SCARD_E_NOT_READY: HRESULT = 0x80100010u32 as HRESULT; pub const SCARD_E_INVALID_VALUE: HRESULT = 0x80100011u32 as HRESULT; pub const SCARD_E_SYSTEM_CANCELLED: HRESULT = 0x80100012u32 as HRESULT; pub const SCARD_F_COMM_ERROR: HRESULT = 0x80100013u32 as HRESULT; pub const SCARD_F_UNKNOWN_ERROR: HRESULT = 0x80100014u32 as HRESULT; pub const SCARD_E_INVALID_ATR: HRESULT = 0x80100015u32 as HRESULT; pub const SCARD_E_NOT_TRANSACTED: HRESULT = 0x80100016u32 as HRESULT; pub const SCARD_E_READER_UNAVAILABLE: HRESULT = 0x80100017u32 as HRESULT; pub const SCARD_P_SHUTDOWN: HRESULT = 0x80100018u32 as HRESULT; pub const SCARD_E_PCI_TOO_SMALL: HRESULT = 0x80100019u32 as HRESULT; pub const SCARD_E_READER_UNSUPPORTED: HRESULT = 0x8010001Au32 as HRESULT; pub const SCARD_E_DUPLICATE_READER: HRESULT = 0x8010001Bu32 as HRESULT; pub const SCARD_E_CARD_UNSUPPORTED: HRESULT = 0x8010001Cu32 as HRESULT; pub const SCARD_E_NO_SERVICE: HRESULT = 0x8010001Du32 as HRESULT; pub const SCARD_E_SERVICE_STOPPED: HRESULT = 0x8010001Eu32 as HRESULT; pub const SCARD_E_UNEXPECTED: HRESULT = 0x8010001Fu32 as HRESULT; pub const SCARD_E_ICC_INSTALLATION: HRESULT = 0x80100020u32 as HRESULT; pub const SCARD_E_ICC_CREATEORDER: HRESULT = 0x80100021u32 as HRESULT; pub const SCARD_E_UNSUPPORTED_FEATURE: HRESULT = 0x80100022u32 as HRESULT; pub const SCARD_E_DIR_NOT_FOUND: HRESULT = 0x80100023u32 as HRESULT; pub const SCARD_E_FILE_NOT_FOUND: HRESULT = 0x80100024u32 as HRESULT; pub const SCARD_E_NO_DIR: HRESULT = 0x80100025u32 as HRESULT; pub const SCARD_E_NO_FILE: HRESULT = 0x80100026u32 as HRESULT; pub const SCARD_E_NO_ACCESS: HRESULT = 0x80100027u32 as HRESULT; pub const SCARD_E_WRITE_TOO_MANY: HRESULT = 0x80100028u32 as HRESULT; pub const SCARD_E_BAD_SEEK: HRESULT = 0x80100029u32 as HRESULT; pub const SCARD_E_INVALID_CHV: HRESULT = 0x8010002Au32 as HRESULT; pub const SCARD_E_UNKNOWN_RES_MNG: HRESULT = 0x8010002Bu32 as HRESULT; pub const SCARD_E_NO_SUCH_CERTIFICATE: HRESULT = 0x8010002Cu32 as HRESULT; pub const SCARD_E_CERTIFICATE_UNAVAILABLE: HRESULT = 0x8010002Du32 as HRESULT; pub const SCARD_E_NO_READERS_AVAILABLE: HRESULT = 0x8010002Eu32 as HRESULT; pub const SCARD_E_COMM_DATA_LOST: HRESULT = 0x8010002Fu32 as HRESULT; pub const SCARD_E_NO_KEY_CONTAINER: HRESULT = 0x80100030u32 as HRESULT; pub const SCARD_E_SERVER_TOO_BUSY: HRESULT = 0x80100031u32 as HRESULT; pub const SCARD_E_PIN_CACHE_EXPIRED: HRESULT = 0x80100032u32 as HRESULT; pub const SCARD_E_NO_PIN_CACHE: HRESULT = 0x80100033u32 as HRESULT; pub const SCARD_E_READ_ONLY_CARD: HRESULT = 0x80100034u32 as HRESULT; pub const SCARD_W_UNSUPPORTED_CARD: HRESULT = 0x80100065u32 as HRESULT; pub const SCARD_W_UNRESPONSIVE_CARD: HRESULT = 0x80100066u32 as HRESULT; pub const SCARD_W_UNPOWERED_CARD: HRESULT = 0x80100067u32 as HRESULT; pub const SCARD_W_RESET_CARD: HRESULT = 0x80100068u32 as HRESULT; pub const SCARD_W_REMOVED_CARD: HRESULT = 0x80100069u32 as HRESULT; pub const SCARD_W_SECURITY_VIOLATION: HRESULT = 0x8010006Au32 as HRESULT; pub const SCARD_W_WRONG_CHV: HRESULT = 0x8010006Bu32 as HRESULT; pub const SCARD_W_CHV_BLOCKED: HRESULT = 0x8010006Cu32 as HRESULT; pub const SCARD_W_EOF: HRESULT = 0x8010006Du32 as HRESULT; pub const SCARD_W_CANCELLED_BY_USER: HRESULT = 0x8010006Eu32 as HRESULT; pub const SCARD_W_CARD_NOT_AUTHENTICATED: HRESULT = 0x8010006Fu32 as HRESULT; pub const SCARD_W_CACHE_ITEM_NOT_FOUND: HRESULT = 0x80100070u32 as HRESULT; pub const SCARD_W_CACHE_ITEM_STALE: HRESULT = 0x80100071u32 as HRESULT; pub const SCARD_W_CACHE_ITEM_TOO_BIG: HRESULT = 0x80100072u32 as HRESULT; pub const COMADMIN_E_OBJECTERRORS: HRESULT = 0x80110401u32 as HRESULT; pub const COMADMIN_E_OBJECTINVALID: HRESULT = 0x80110402u32 as HRESULT; pub const COMADMIN_E_KEYMISSING: HRESULT = 0x80110403u32 as HRESULT; pub const COMADMIN_E_ALREADYINSTALLED: HRESULT = 0x80110404u32 as HRESULT; pub const COMADMIN_E_APP_FILE_WRITEFAIL: HRESULT = 0x80110407u32 as HRESULT; pub const COMADMIN_E_APP_FILE_READFAIL: HRESULT = 0x80110408u32 as HRESULT; pub const COMADMIN_E_APP_FILE_VERSION: HRESULT = 0x80110409u32 as HRESULT; pub const COMADMIN_E_BADPATH: HRESULT = 0x8011040Au32 as HRESULT; pub const COMADMIN_E_APPLICATIONEXISTS: HRESULT = 0x8011040Bu32 as HRESULT; pub const COMADMIN_E_ROLEEXISTS: HRESULT = 0x8011040Cu32 as HRESULT; pub const COMADMIN_E_CANTCOPYFILE: HRESULT = 0x8011040Du32 as HRESULT; pub const COMADMIN_E_NOUSER: HRESULT = 0x8011040Fu32 as HRESULT; pub const COMADMIN_E_INVALIDUSERIDS: HRESULT = 0x80110410u32 as HRESULT; pub const COMADMIN_E_NOREGISTRYCLSID: HRESULT = 0x80110411u32 as HRESULT; pub const COMADMIN_E_BADREGISTRYPROGID: HRESULT = 0x80110412u32 as HRESULT; pub const COMADMIN_E_AUTHENTICATIONLEVEL: HRESULT = 0x80110413u32 as HRESULT; pub const COMADMIN_E_USERPASSWDNOTVALID: HRESULT = 0x80110414u32 as HRESULT; pub const COMADMIN_E_CLSIDORIIDMISMATCH: HRESULT = 0x80110418u32 as HRESULT; pub const COMADMIN_E_REMOTEINTERFACE: HRESULT = 0x80110419u32 as HRESULT; pub const COMADMIN_E_DLLREGISTERSERVER: HRESULT = 0x8011041Au32 as HRESULT; pub const COMADMIN_E_NOSERVERSHARE: HRESULT = 0x8011041Bu32 as HRESULT; pub const COMADMIN_E_DLLLOADFAILED: HRESULT = 0x8011041Du32 as HRESULT; pub const COMADMIN_E_BADREGISTRYLIBID: HRESULT = 0x8011041Eu32 as HRESULT; pub const COMADMIN_E_APPDIRNOTFOUND: HRESULT = 0x8011041Fu32 as HRESULT; pub const COMADMIN_E_REGISTRARFAILED: HRESULT = 0x80110423u32 as HRESULT; pub const COMADMIN_E_COMPFILE_DOESNOTEXIST: HRESULT = 0x80110424u32 as HRESULT; pub const COMADMIN_E_COMPFILE_LOADDLLFAIL: HRESULT = 0x80110425u32 as HRESULT; pub const COMADMIN_E_COMPFILE_GETCLASSOBJ: HRESULT = 0x80110426u32 as HRESULT; pub const COMADMIN_E_COMPFILE_CLASSNOTAVAIL: HRESULT = 0x80110427u32 as HRESULT; pub const COMADMIN_E_COMPFILE_BADTLB: HRESULT = 0x80110428u32 as HRESULT; pub const COMADMIN_E_COMPFILE_NOTINSTALLABLE: HRESULT = 0x80110429u32 as HRESULT; pub const COMADMIN_E_NOTCHANGEABLE: HRESULT = 0x8011042Au32 as HRESULT; pub const COMADMIN_E_NOTDELETEABLE: HRESULT = 0x8011042Bu32 as HRESULT; pub const COMADMIN_E_SESSION: HRESULT = 0x8011042Cu32 as HRESULT; pub const COMADMIN_E_COMP_MOVE_LOCKED: HRESULT = 0x8011042Du32 as HRESULT; pub const COMADMIN_E_COMP_MOVE_BAD_DEST: HRESULT = 0x8011042Eu32 as HRESULT; pub const COMADMIN_E_REGISTERTLB: HRESULT = 0x80110430u32 as HRESULT; pub const COMADMIN_E_SYSTEMAPP: HRESULT = 0x80110433u32 as HRESULT; pub const COMADMIN_E_COMPFILE_NOREGISTRAR: HRESULT = 0x80110434u32 as HRESULT; pub const COMADMIN_E_COREQCOMPINSTALLED: HRESULT = 0x80110435u32 as HRESULT; pub const COMADMIN_E_SERVICENOTINSTALLED: HRESULT = 0x80110436u32 as HRESULT; pub const COMADMIN_E_PROPERTYSAVEFAILED: HRESULT = 0x80110437u32 as HRESULT; pub const COMADMIN_E_OBJECTEXISTS: HRESULT = 0x80110438u32 as HRESULT; pub const COMADMIN_E_COMPONENTEXISTS: HRESULT = 0x80110439u32 as HRESULT; pub const COMADMIN_E_REGFILE_CORRUPT: HRESULT = 0x8011043Bu32 as HRESULT; pub const COMADMIN_E_PROPERTY_OVERFLOW: HRESULT = 0x8011043Cu32 as HRESULT; pub const COMADMIN_E_NOTINREGISTRY: HRESULT = 0x8011043Eu32 as HRESULT; pub const COMADMIN_E_OBJECTNOTPOOLABLE: HRESULT = 0x8011043Fu32 as HRESULT; pub const COMADMIN_E_APPLID_MATCHES_CLSID: HRESULT = 0x80110446u32 as HRESULT; pub const COMADMIN_E_ROLE_DOES_NOT_EXIST: HRESULT = 0x80110447u32 as HRESULT; pub const COMADMIN_E_START_APP_NEEDS_COMPONENTS: HRESULT = 0x80110448u32 as HRESULT; pub const COMADMIN_E_REQUIRES_DIFFERENT_PLATFORM: HRESULT = 0x80110449u32 as HRESULT; pub const COMADMIN_E_CAN_NOT_EXPORT_APP_PROXY: HRESULT = 0x8011044Au32 as HRESULT; pub const COMADMIN_E_CAN_NOT_START_APP: HRESULT = 0x8011044Bu32 as HRESULT; pub const COMADMIN_E_CAN_NOT_EXPORT_SYS_APP: HRESULT = 0x8011044Cu32 as HRESULT; pub const COMADMIN_E_CANT_SUBSCRIBE_TO_COMPONENT: HRESULT = 0x8011044Du32 as HRESULT; pub const COMADMIN_E_EVENTCLASS_CANT_BE_SUBSCRIBER: HRESULT = 0x8011044Eu32 as HRESULT; pub const COMADMIN_E_LIB_APP_PROXY_INCOMPATIBLE: HRESULT = 0x8011044Fu32 as HRESULT; pub const COMADMIN_E_BASE_PARTITION_ONLY: HRESULT = 0x80110450u32 as HRESULT; pub const COMADMIN_E_START_APP_DISABLED: HRESULT = 0x80110451u32 as HRESULT; pub const COMADMIN_E_CAT_DUPLICATE_PARTITION_NAME: HRESULT = 0x80110457u32 as HRESULT; pub const COMADMIN_E_CAT_INVALID_PARTITION_NAME: HRESULT = 0x80110458u32 as HRESULT; pub const COMADMIN_E_CAT_PARTITION_IN_USE: HRESULT = 0x80110459u32 as HRESULT; pub const COMADMIN_E_FILE_PARTITION_DUPLICATE_FILES: HRESULT = 0x8011045Au32 as HRESULT; pub const COMADMIN_E_CAT_IMPORTED_COMPONENTS_NOT_ALLOWED: HRESULT = 0x8011045Bu32 as HRESULT; pub const COMADMIN_E_AMBIGUOUS_APPLICATION_NAME: HRESULT = 0x8011045Cu32 as HRESULT; pub const COMADMIN_E_AMBIGUOUS_PARTITION_NAME: HRESULT = 0x8011045Du32 as HRESULT; pub const COMADMIN_E_REGDB_NOTINITIALIZED: HRESULT = 0x80110472u32 as HRESULT; pub const COMADMIN_E_REGDB_NOTOPEN: HRESULT = 0x80110473u32 as HRESULT; pub const COMADMIN_E_REGDB_SYSTEMERR: HRESULT = 0x80110474u32 as HRESULT; pub const COMADMIN_E_REGDB_ALREADYRUNNING: HRESULT = 0x80110475u32 as HRESULT; pub const COMADMIN_E_MIG_VERSIONNOTSUPPORTED: HRESULT = 0x80110480u32 as HRESULT; pub const COMADMIN_E_MIG_SCHEMANOTFOUND: HRESULT = 0x80110481u32 as HRESULT; pub const COMADMIN_E_CAT_BITNESSMISMATCH: HRESULT = 0x80110482u32 as HRESULT; pub const COMADMIN_E_CAT_UNACCEPTABLEBITNESS: HRESULT = 0x80110483u32 as HRESULT; pub const COMADMIN_E_CAT_WRONGAPPBITNESS: HRESULT = 0x80110484u32 as HRESULT; pub const COMADMIN_E_CAT_PAUSE_RESUME_NOT_SUPPORTED: HRESULT = 0x80110485u32 as HRESULT; pub const COMADMIN_E_CAT_SERVERFAULT: HRESULT = 0x80110486u32 as HRESULT; pub const COMQC_E_APPLICATION_NOT_QUEUED: HRESULT = 0x80110600u32 as HRESULT; pub const COMQC_E_NO_QUEUEABLE_INTERFACES: HRESULT = 0x80110601u32 as HRESULT; pub const COMQC_E_QUEUING_SERVICE_NOT_AVAILABLE: HRESULT = 0x80110602u32 as HRESULT; pub const COMQC_E_NO_IPERSISTSTREAM: HRESULT = 0x80110603u32 as HRESULT; pub const COMQC_E_BAD_MESSAGE: HRESULT = 0x80110604u32 as HRESULT; pub const COMQC_E_UNAUTHENTICATED: HRESULT = 0x80110605u32 as HRESULT; pub const COMQC_E_UNTRUSTED_ENQUEUER: HRESULT = 0x80110606u32 as HRESULT; pub const MSDTC_E_DUPLICATE_RESOURCE: HRESULT = 0x80110701u32 as HRESULT; pub const COMADMIN_E_OBJECT_PARENT_MISSING: HRESULT = 0x80110808u32 as HRESULT; pub const COMADMIN_E_OBJECT_DOES_NOT_EXIST: HRESULT = 0x80110809u32 as HRESULT; pub const COMADMIN_E_APP_NOT_RUNNING: HRESULT = 0x8011080Au32 as HRESULT; pub const COMADMIN_E_INVALID_PARTITION: HRESULT = 0x8011080Bu32 as HRESULT; pub const COMADMIN_E_SVCAPP_NOT_POOLABLE_OR_RECYCLABLE: HRESULT = 0x8011080Du32 as HRESULT; pub const COMADMIN_E_USER_IN_SET: HRESULT = 0x8011080Eu32 as HRESULT; pub const COMADMIN_E_CANTRECYCLELIBRARYAPPS: HRESULT = 0x8011080Fu32 as HRESULT; pub const COMADMIN_E_CANTRECYCLESERVICEAPPS: HRESULT = 0x80110811u32 as HRESULT; pub const COMADMIN_E_PROCESSALREADYRECYCLED: HRESULT = 0x80110812u32 as HRESULT; pub const COMADMIN_E_PAUSEDPROCESSMAYNOTBERECYCLED: HRESULT = 0x80110813u32 as HRESULT; pub const COMADMIN_E_CANTMAKEINPROCSERVICE: HRESULT = 0x80110814u32 as HRESULT; pub const COMADMIN_E_PROGIDINUSEBYCLSID: HRESULT = 0x80110815u32 as HRESULT; pub const COMADMIN_E_DEFAULT_PARTITION_NOT_IN_SET: HRESULT = 0x80110816u32 as HRESULT; pub const COMADMIN_E_RECYCLEDPROCESSMAYNOTBEPAUSED: HRESULT = 0x80110817u32 as HRESULT; pub const COMADMIN_E_PARTITION_ACCESSDENIED: HRESULT = 0x80110818u32 as HRESULT; pub const COMADMIN_E_PARTITION_MSI_ONLY: HRESULT = 0x80110819u32 as HRESULT; pub const COMADMIN_E_LEGACYCOMPS_NOT_ALLOWED_IN_1_0_FORMAT: HRESULT = 0x8011081Au32 as HRESULT; pub const COMADMIN_E_LEGACYCOMPS_NOT_ALLOWED_IN_NONBASE_PARTITIONS: HRESULT = 0x8011081Bu32 as HRESULT; pub const COMADMIN_E_COMP_MOVE_SOURCE: HRESULT = 0x8011081Cu32 as HRESULT; pub const COMADMIN_E_COMP_MOVE_DEST: HRESULT = 0x8011081Du32 as HRESULT; pub const COMADMIN_E_COMP_MOVE_PRIVATE: HRESULT = 0x8011081Eu32 as HRESULT; pub const COMADMIN_E_BASEPARTITION_REQUIRED_IN_SET: HRESULT = 0x8011081Fu32 as HRESULT; pub const COMADMIN_E_CANNOT_ALIAS_EVENTCLASS: HRESULT = 0x80110820u32 as HRESULT; pub const COMADMIN_E_PRIVATE_ACCESSDENIED: HRESULT = 0x80110821u32 as HRESULT; pub const COMADMIN_E_SAFERINVALID: HRESULT = 0x80110822u32 as HRESULT; pub const COMADMIN_E_REGISTRY_ACCESSDENIED: HRESULT = 0x80110823u32 as HRESULT; pub const COMADMIN_E_PARTITIONS_DISABLED: HRESULT = 0x80110824u32 as HRESULT; pub const WER_S_REPORT_DEBUG: HRESULT = 0x001B0000; pub const WER_S_REPORT_UPLOADED: HRESULT = 0x001B0001; pub const WER_S_REPORT_QUEUED: HRESULT = 0x001B0002; pub const WER_S_DISABLED: HRESULT = 0x001B0003; pub const WER_S_SUSPENDED_UPLOAD: HRESULT = 0x001B0004; pub const WER_S_DISABLED_QUEUE: HRESULT = 0x001B0005; pub const WER_S_DISABLED_ARCHIVE: HRESULT = 0x001B0006; pub const WER_S_REPORT_ASYNC: HRESULT = 0x001B0007; pub const WER_S_IGNORE_ASSERT_INSTANCE: HRESULT = 0x001B0008; pub const WER_S_IGNORE_ALL_ASSERTS: HRESULT = 0x001B0009; pub const WER_S_ASSERT_CONTINUE: HRESULT = 0x001B000A; pub const WER_S_THROTTLED: HRESULT = 0x001B000B; pub const WER_E_CRASH_FAILURE: HRESULT = 0x801B8000u32 as HRESULT; pub const WER_E_CANCELED: HRESULT = 0x801B8001u32 as HRESULT; pub const WER_E_NETWORK_FAILURE: HRESULT = 0x801B8002u32 as HRESULT; pub const WER_E_NOT_INITIALIZED: HRESULT = 0x801B8003u32 as HRESULT; pub const WER_E_ALREADY_REPORTING: HRESULT = 0x801B8004u32 as HRESULT; pub const WER_E_DUMP_THROTTLED: HRESULT = 0x801B8005u32 as HRESULT; pub const ERROR_FLT_IO_COMPLETE: HRESULT = 0x001F0001; pub const ERROR_FLT_NO_HANDLER_DEFINED: HRESULT = 0x801F0001u32 as HRESULT; pub const ERROR_FLT_CONTEXT_ALREADY_DEFINED: HRESULT = 0x801F0002u32 as HRESULT; pub const ERROR_FLT_INVALID_ASYNCHRONOUS_REQUEST: HRESULT = 0x801F0003u32 as HRESULT; pub const ERROR_FLT_DISALLOW_FAST_IO: HRESULT = 0x801F0004u32 as HRESULT; pub const ERROR_FLT_INVALID_NAME_REQUEST: HRESULT = 0x801F0005u32 as HRESULT; pub const ERROR_FLT_NOT_SAFE_TO_POST_OPERATION: HRESULT = 0x801F0006u32 as HRESULT; pub const ERROR_FLT_NOT_INITIALIZED: HRESULT = 0x801F0007u32 as HRESULT; pub const ERROR_FLT_FILTER_NOT_READY: HRESULT = 0x801F0008u32 as HRESULT; pub const ERROR_FLT_POST_OPERATION_CLEANUP: HRESULT = 0x801F0009u32 as HRESULT; pub const ERROR_FLT_INTERNAL_ERROR: HRESULT = 0x801F000Au32 as HRESULT; pub const ERROR_FLT_DELETING_OBJECT: HRESULT = 0x801F000Bu32 as HRESULT; pub const ERROR_FLT_MUST_BE_NONPAGED_POOL: HRESULT = 0x801F000Cu32 as HRESULT; pub const ERROR_FLT_DUPLICATE_ENTRY: HRESULT = 0x801F000Du32 as HRESULT; pub const ERROR_FLT_CBDQ_DISABLED: HRESULT = 0x801F000Eu32 as HRESULT; pub const ERROR_FLT_DO_NOT_ATTACH: HRESULT = 0x801F000Fu32 as HRESULT; pub const ERROR_FLT_DO_NOT_DETACH: HRESULT = 0x801F0010u32 as HRESULT; pub const ERROR_FLT_INSTANCE_ALTITUDE_COLLISION: HRESULT = 0x801F0011u32 as HRESULT; pub const ERROR_FLT_INSTANCE_NAME_COLLISION: HRESULT = 0x801F0012u32 as HRESULT; pub const ERROR_FLT_FILTER_NOT_FOUND: HRESULT = 0x801F0013u32 as HRESULT; pub const ERROR_FLT_VOLUME_NOT_FOUND: HRESULT = 0x801F0014u32 as HRESULT; pub const ERROR_FLT_INSTANCE_NOT_FOUND: HRESULT = 0x801F0015u32 as HRESULT; pub const ERROR_FLT_CONTEXT_ALLOCATION_NOT_FOUND: HRESULT = 0x801F0016u32 as HRESULT; pub const ERROR_FLT_INVALID_CONTEXT_REGISTRATION: HRESULT = 0x801F0017u32 as HRESULT; pub const ERROR_FLT_NAME_CACHE_MISS: HRESULT = 0x801F0018u32 as HRESULT; pub const ERROR_FLT_NO_DEVICE_OBJECT: HRESULT = 0x801F0019u32 as HRESULT; pub const ERROR_FLT_VOLUME_ALREADY_MOUNTED: HRESULT = 0x801F001Au32 as HRESULT; pub const ERROR_FLT_ALREADY_ENLISTED: HRESULT = 0x801F001Bu32 as HRESULT; pub const ERROR_FLT_CONTEXT_ALREADY_LINKED: HRESULT = 0x801F001Cu32 as HRESULT; pub const ERROR_FLT_NO_WAITER_FOR_REPLY: HRESULT = 0x801F0020u32 as HRESULT; pub const ERROR_FLT_REGISTRATION_BUSY: HRESULT = 0x801F0023u32 as HRESULT; pub const ERROR_HUNG_DISPLAY_DRIVER_THREAD: HRESULT = 0x80260001u32 as HRESULT; pub const DWM_E_COMPOSITIONDISABLED: HRESULT = 0x80263001u32 as HRESULT; pub const DWM_E_REMOTING_NOT_SUPPORTED: HRESULT = 0x80263002u32 as HRESULT; pub const DWM_E_NO_REDIRECTION_SURFACE_AVAILABLE: HRESULT = 0x80263003u32 as HRESULT; pub const DWM_E_NOT_QUEUING_PRESENTS: HRESULT = 0x80263004u32 as HRESULT; pub const DWM_E_ADAPTER_NOT_FOUND: HRESULT = 0x80263005u32 as HRESULT; pub const DWM_S_GDI_REDIRECTION_SURFACE: HRESULT = 0x00263005; pub const DWM_E_TEXTURE_TOO_LARGE: HRESULT = 0x80263007u32 as HRESULT; pub const ERROR_MONITOR_NO_DESCRIPTOR: HRESULT = 0x80261001u32 as HRESULT; pub const ERROR_MONITOR_UNKNOWN_DESCRIPTOR_FORMAT: HRESULT = 0x80261002u32 as HRESULT; pub const ERROR_MONITOR_INVALID_DESCRIPTOR_CHECKSUM: HRESULT = 0xC0261003u32 as HRESULT; pub const ERROR_MONITOR_INVALID_STANDARD_TIMING_BLOCK: HRESULT = 0xC0261004u32 as HRESULT; pub const ERROR_MONITOR_WMI_DATABLOCK_REGISTRATION_FAILED: HRESULT = 0xC0261005u32 as HRESULT; pub const ERROR_MONITOR_INVALID_SERIAL_NUMBER_MONDSC_BLOCK: HRESULT = 0xC0261006u32 as HRESULT; pub const ERROR_MONITOR_INVALID_USER_FRIENDLY_MONDSC_BLOCK: HRESULT = 0xC0261007u32 as HRESULT; pub const ERROR_MONITOR_NO_MORE_DESCRIPTOR_DATA: HRESULT = 0xC0261008u32 as HRESULT; pub const ERROR_MONITOR_INVALID_DETAILED_TIMING_BLOCK: HRESULT = 0xC0261009u32 as HRESULT; pub const ERROR_MONITOR_INVALID_MANUFACTURE_DATE: HRESULT = 0xC026100Au32 as HRESULT; pub const ERROR_GRAPHICS_NOT_EXCLUSIVE_MODE_OWNER: HRESULT = 0xC0262000u32 as HRESULT; pub const ERROR_GRAPHICS_INSUFFICIENT_DMA_BUFFER: HRESULT = 0xC0262001u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_DISPLAY_ADAPTER: HRESULT = 0xC0262002u32 as HRESULT; pub const ERROR_GRAPHICS_ADAPTER_WAS_RESET: HRESULT = 0xC0262003u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_DRIVER_MODEL: HRESULT = 0xC0262004u32 as HRESULT; pub const ERROR_GRAPHICS_PRESENT_MODE_CHANGED: HRESULT = 0xC0262005u32 as HRESULT; pub const ERROR_GRAPHICS_PRESENT_OCCLUDED: HRESULT = 0xC0262006u32 as HRESULT; pub const ERROR_GRAPHICS_PRESENT_DENIED: HRESULT = 0xC0262007u32 as HRESULT; pub const ERROR_GRAPHICS_CANNOTCOLORCONVERT: HRESULT = 0xC0262008u32 as HRESULT; pub const ERROR_GRAPHICS_DRIVER_MISMATCH: HRESULT = 0xC0262009u32 as HRESULT; pub const ERROR_GRAPHICS_PARTIAL_DATA_POPULATED: HRESULT = 0x4026200A; pub const ERROR_GRAPHICS_PRESENT_REDIRECTION_DISABLED: HRESULT = 0xC026200Bu32 as HRESULT; pub const ERROR_GRAPHICS_PRESENT_UNOCCLUDED: HRESULT = 0xC026200Cu32 as HRESULT; pub const ERROR_GRAPHICS_WINDOWDC_NOT_AVAILABLE: HRESULT = 0xC026200Du32 as HRESULT; pub const ERROR_GRAPHICS_WINDOWLESS_PRESENT_DISABLED: HRESULT = 0xC026200Eu32 as HRESULT; pub const ERROR_GRAPHICS_NO_VIDEO_MEMORY: HRESULT = 0xC0262100u32 as HRESULT; pub const ERROR_GRAPHICS_CANT_LOCK_MEMORY: HRESULT = 0xC0262101u32 as HRESULT; pub const ERROR_GRAPHICS_ALLOCATION_BUSY: HRESULT = 0xC0262102u32 as HRESULT; pub const ERROR_GRAPHICS_TOO_MANY_REFERENCES: HRESULT = 0xC0262103u32 as HRESULT; pub const ERROR_GRAPHICS_TRY_AGAIN_LATER: HRESULT = 0xC0262104u32 as HRESULT; pub const ERROR_GRAPHICS_TRY_AGAIN_NOW: HRESULT = 0xC0262105u32 as HRESULT; pub const ERROR_GRAPHICS_ALLOCATION_INVALID: HRESULT = 0xC0262106u32 as HRESULT; pub const ERROR_GRAPHICS_UNSWIZZLING_APERTURE_UNAVAILABLE: HRESULT = 0xC0262107u32 as HRESULT; pub const ERROR_GRAPHICS_UNSWIZZLING_APERTURE_UNSUPPORTED: HRESULT = 0xC0262108u32 as HRESULT; pub const ERROR_GRAPHICS_CANT_EVICT_PINNED_ALLOCATION: HRESULT = 0xC0262109u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_ALLOCATION_USAGE: HRESULT = 0xC0262110u32 as HRESULT; pub const ERROR_GRAPHICS_CANT_RENDER_LOCKED_ALLOCATION: HRESULT = 0xC0262111u32 as HRESULT; pub const ERROR_GRAPHICS_ALLOCATION_CLOSED: HRESULT = 0xC0262112u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_ALLOCATION_INSTANCE: HRESULT = 0xC0262113u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_ALLOCATION_HANDLE: HRESULT = 0xC0262114u32 as HRESULT; pub const ERROR_GRAPHICS_WRONG_ALLOCATION_DEVICE: HRESULT = 0xC0262115u32 as HRESULT; pub const ERROR_GRAPHICS_ALLOCATION_CONTENT_LOST: HRESULT = 0xC0262116u32 as HRESULT; pub const ERROR_GRAPHICS_GPU_EXCEPTION_ON_DEVICE: HRESULT = 0xC0262200u32 as HRESULT; pub const ERROR_GRAPHICS_SKIP_ALLOCATION_PREPARATION: HRESULT = 0x40262201; pub const ERROR_GRAPHICS_INVALID_VIDPN_TOPOLOGY: HRESULT = 0xC0262300u32 as HRESULT; pub const ERROR_GRAPHICS_VIDPN_TOPOLOGY_NOT_SUPPORTED: HRESULT = 0xC0262301u32 as HRESULT; pub const ERROR_GRAPHICS_VIDPN_TOPOLOGY_CURRENTLY_NOT_SUPPORTED: HRESULT = 0xC0262302u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_VIDPN: HRESULT = 0xC0262303u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE: HRESULT = 0xC0262304u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET: HRESULT = 0xC0262305u32 as HRESULT; pub const ERROR_GRAPHICS_VIDPN_MODALITY_NOT_SUPPORTED: HRESULT = 0xC0262306u32 as HRESULT; pub const ERROR_GRAPHICS_MODE_NOT_PINNED: HRESULT = 0x00262307; pub const ERROR_GRAPHICS_INVALID_VIDPN_SOURCEMODESET: HRESULT = 0xC0262308u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_VIDPN_TARGETMODESET: HRESULT = 0xC0262309u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_FREQUENCY: HRESULT = 0xC026230Au32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_ACTIVE_REGION: HRESULT = 0xC026230Bu32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_TOTAL_REGION: HRESULT = 0xC026230Cu32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE_MODE: HRESULT = 0xC0262310u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_VIDEO_PRESENT_TARGET_MODE: HRESULT = 0xC0262311u32 as HRESULT; pub const ERROR_GRAPHICS_PINNED_MODE_MUST_REMAIN_IN_SET: HRESULT = 0xC0262312u32 as HRESULT; pub const ERROR_GRAPHICS_PATH_ALREADY_IN_TOPOLOGY: HRESULT = 0xC0262313u32 as HRESULT; pub const ERROR_GRAPHICS_MODE_ALREADY_IN_MODESET: HRESULT = 0xC0262314u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_VIDEOPRESENTSOURCESET: HRESULT = 0xC0262315u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_VIDEOPRESENTTARGETSET: HRESULT = 0xC0262316u32 as HRESULT; pub const ERROR_GRAPHICS_SOURCE_ALREADY_IN_SET: HRESULT = 0xC0262317u32 as HRESULT; pub const ERROR_GRAPHICS_TARGET_ALREADY_IN_SET: HRESULT = 0xC0262318u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_VIDPN_PRESENT_PATH: HRESULT = 0xC0262319u32 as HRESULT; pub const ERROR_GRAPHICS_NO_RECOMMENDED_VIDPN_TOPOLOGY: HRESULT = 0xC026231Au32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGESET: HRESULT = 0xC026231Bu32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE: HRESULT = 0xC026231Cu32 as HRESULT; pub const ERROR_GRAPHICS_FREQUENCYRANGE_NOT_IN_SET: HRESULT = 0xC026231Du32 as HRESULT; pub const ERROR_GRAPHICS_NO_PREFERRED_MODE: HRESULT = 0x0026231E; pub const ERROR_GRAPHICS_FREQUENCYRANGE_ALREADY_IN_SET: HRESULT = 0xC026231Fu32 as HRESULT; pub const ERROR_GRAPHICS_STALE_MODESET: HRESULT = 0xC0262320u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_MONITOR_SOURCEMODESET: HRESULT = 0xC0262321u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_MONITOR_SOURCE_MODE: HRESULT = 0xC0262322u32 as HRESULT; pub const ERROR_GRAPHICS_NO_RECOMMENDED_FUNCTIONAL_VIDPN: HRESULT = 0xC0262323u32 as HRESULT; pub const ERROR_GRAPHICS_MODE_ID_MUST_BE_UNIQUE: HRESULT = 0xC0262324u32 as HRESULT; pub const ERROR_GRAPHICS_EMPTY_ADAPTER_MONITOR_MODE_SUPPORT_INTERSECTION: HRESULT = 0xC0262325u32 as HRESULT; pub const ERROR_GRAPHICS_VIDEO_PRESENT_TARGETS_LESS_THAN_SOURCES: HRESULT = 0xC0262326u32 as HRESULT; pub const ERROR_GRAPHICS_PATH_NOT_IN_TOPOLOGY: HRESULT = 0xC0262327u32 as HRESULT; pub const ERROR_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_SOURCE: HRESULT = 0xC0262328u32 as HRESULT; pub const ERROR_GRAPHICS_ADAPTER_MUST_HAVE_AT_LEAST_ONE_TARGET: HRESULT = 0xC0262329u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_MONITORDESCRIPTORSET: HRESULT = 0xC026232Au32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_MONITORDESCRIPTOR: HRESULT = 0xC026232Bu32 as HRESULT; pub const ERROR_GRAPHICS_MONITORDESCRIPTOR_NOT_IN_SET: HRESULT = 0xC026232Cu32 as HRESULT; pub const ERROR_GRAPHICS_MONITORDESCRIPTOR_ALREADY_IN_SET: HRESULT = 0xC026232Du32 as HRESULT; pub const ERROR_GRAPHICS_MONITORDESCRIPTOR_ID_MUST_BE_UNIQUE: HRESULT = 0xC026232Eu32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_VIDPN_TARGET_SUBSET_TYPE: HRESULT = 0xC026232Fu32 as HRESULT; pub const ERROR_GRAPHICS_RESOURCES_NOT_RELATED: HRESULT = 0xC0262330u32 as HRESULT; pub const ERROR_GRAPHICS_SOURCE_ID_MUST_BE_UNIQUE: HRESULT = 0xC0262331u32 as HRESULT; pub const ERROR_GRAPHICS_TARGET_ID_MUST_BE_UNIQUE: HRESULT = 0xC0262332u32 as HRESULT; pub const ERROR_GRAPHICS_NO_AVAILABLE_VIDPN_TARGET: HRESULT = 0xC0262333u32 as HRESULT; pub const ERROR_GRAPHICS_MONITOR_COULD_NOT_BE_ASSOCIATED_WITH_ADAPTER: HRESULT = 0xC0262334u32 as HRESULT; pub const ERROR_GRAPHICS_NO_VIDPNMGR: HRESULT = 0xC0262335u32 as HRESULT; pub const ERROR_GRAPHICS_NO_ACTIVE_VIDPN: HRESULT = 0xC0262336u32 as HRESULT; pub const ERROR_GRAPHICS_STALE_VIDPN_TOPOLOGY: HRESULT = 0xC0262337u32 as HRESULT; pub const ERROR_GRAPHICS_MONITOR_NOT_CONNECTED: HRESULT = 0xC0262338u32 as HRESULT; pub const ERROR_GRAPHICS_SOURCE_NOT_IN_TOPOLOGY: HRESULT = 0xC0262339u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_PRIMARYSURFACE_SIZE: HRESULT = 0xC026233Au32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_VISIBLEREGION_SIZE: HRESULT = 0xC026233Bu32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_STRIDE: HRESULT = 0xC026233Cu32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_PIXELFORMAT: HRESULT = 0xC026233Du32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_COLORBASIS: HRESULT = 0xC026233Eu32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_PIXELVALUEACCESSMODE: HRESULT = 0xC026233Fu32 as HRESULT; pub const ERROR_GRAPHICS_TARGET_NOT_IN_TOPOLOGY: HRESULT = 0xC0262340u32 as HRESULT; pub const ERROR_GRAPHICS_NO_DISPLAY_MODE_MANAGEMENT_SUPPORT: HRESULT = 0xC0262341u32 as HRESULT; pub const ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE: HRESULT = 0xC0262342u32 as HRESULT; pub const ERROR_GRAPHICS_CANT_ACCESS_ACTIVE_VIDPN: HRESULT = 0xC0262343u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_PATH_IMPORTANCE_ORDINAL: HRESULT = 0xC0262344u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_PATH_CONTENT_GEOMETRY_TRANSFORMATION: HRESULT = 0xC0262345u32 as HRESULT; pub const ERROR_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_SUPPORTED: HRESULT = 0xC0262346u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_GAMMA_RAMP: HRESULT = 0xC0262347u32 as HRESULT; pub const ERROR_GRAPHICS_GAMMA_RAMP_NOT_SUPPORTED: HRESULT = 0xC0262348u32 as HRESULT; pub const ERROR_GRAPHICS_MULTISAMPLING_NOT_SUPPORTED: HRESULT = 0xC0262349u32 as HRESULT; pub const ERROR_GRAPHICS_MODE_NOT_IN_MODESET: HRESULT = 0xC026234Au32 as HRESULT; pub const ERROR_GRAPHICS_DATASET_IS_EMPTY: HRESULT = 0x0026234B; pub const ERROR_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET: HRESULT = 0x0026234C; pub const ERROR_GRAPHICS_INVALID_VIDPN_TOPOLOGY_RECOMMENDATION_REASON: HRESULT = 0xC026234Du32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_PATH_CONTENT_TYPE: HRESULT = 0xC026234Eu32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_COPYPROTECTION_TYPE: HRESULT = 0xC026234Fu32 as HRESULT; pub const ERROR_GRAPHICS_UNASSIGNED_MODESET_ALREADY_EXISTS: HRESULT = 0xC0262350u32 as HRESULT; pub const ERROR_GRAPHICS_PATH_CONTENT_GEOMETRY_TRANSFORMATION_NOT_PINNED: HRESULT = 0x00262351; pub const ERROR_GRAPHICS_INVALID_SCANLINE_ORDERING: HRESULT = 0xC0262352u32 as HRESULT; pub const ERROR_GRAPHICS_TOPOLOGY_CHANGES_NOT_ALLOWED: HRESULT = 0xC0262353u32 as HRESULT; pub const ERROR_GRAPHICS_NO_AVAILABLE_IMPORTANCE_ORDINALS: HRESULT = 0xC0262354u32 as HRESULT; pub const ERROR_GRAPHICS_INCOMPATIBLE_PRIVATE_FORMAT: HRESULT = 0xC0262355u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_MODE_PRUNING_ALGORITHM: HRESULT = 0xC0262356u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_MONITOR_CAPABILITY_ORIGIN: HRESULT = 0xC0262357u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_MONITOR_FREQUENCYRANGE_CONSTRAINT: HRESULT = 0xC0262358u32 as HRESULT; pub const ERROR_GRAPHICS_MAX_NUM_PATHS_REACHED: HRESULT = 0xC0262359u32 as HRESULT; pub const ERROR_GRAPHICS_CANCEL_VIDPN_TOPOLOGY_AUGMENTATION: HRESULT = 0xC026235Au32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_CLIENT_TYPE: HRESULT = 0xC026235Bu32 as HRESULT; pub const ERROR_GRAPHICS_CLIENTVIDPN_NOT_SET: HRESULT = 0xC026235Cu32 as HRESULT; pub const ERROR_GRAPHICS_SPECIFIED_CHILD_ALREADY_CONNECTED: HRESULT = 0xC0262400u32 as HRESULT; pub const ERROR_GRAPHICS_CHILD_DESCRIPTOR_NOT_SUPPORTED: HRESULT = 0xC0262401u32 as HRESULT; pub const ERROR_GRAPHICS_UNKNOWN_CHILD_STATUS: HRESULT = 0x4026242F; pub const ERROR_GRAPHICS_NOT_A_LINKED_ADAPTER: HRESULT = 0xC0262430u32 as HRESULT; pub const ERROR_GRAPHICS_LEADLINK_NOT_ENUMERATED: HRESULT = 0xC0262431u32 as HRESULT; pub const ERROR_GRAPHICS_CHAINLINKS_NOT_ENUMERATED: HRESULT = 0xC0262432u32 as HRESULT; pub const ERROR_GRAPHICS_ADAPTER_CHAIN_NOT_READY: HRESULT = 0xC0262433u32 as HRESULT; pub const ERROR_GRAPHICS_CHAINLINKS_NOT_STARTED: HRESULT = 0xC0262434u32 as HRESULT; pub const ERROR_GRAPHICS_CHAINLINKS_NOT_POWERED_ON: HRESULT = 0xC0262435u32 as HRESULT; pub const ERROR_GRAPHICS_INCONSISTENT_DEVICE_LINK_STATE: HRESULT = 0xC0262436u32 as HRESULT; pub const ERROR_GRAPHICS_LEADLINK_START_DEFERRED: HRESULT = 0x40262437; pub const ERROR_GRAPHICS_NOT_POST_DEVICE_DRIVER: HRESULT = 0xC0262438u32 as HRESULT; pub const ERROR_GRAPHICS_POLLING_TOO_FREQUENTLY: HRESULT = 0x40262439; pub const ERROR_GRAPHICS_START_DEFERRED: HRESULT = 0x4026243A; pub const ERROR_GRAPHICS_ADAPTER_ACCESS_NOT_EXCLUDED: HRESULT = 0xC026243Bu32 as HRESULT; pub const ERROR_GRAPHICS_OPM_NOT_SUPPORTED: HRESULT = 0xC0262500u32 as HRESULT; pub const ERROR_GRAPHICS_COPP_NOT_SUPPORTED: HRESULT = 0xC0262501u32 as HRESULT; pub const ERROR_GRAPHICS_UAB_NOT_SUPPORTED: HRESULT = 0xC0262502u32 as HRESULT; pub const ERROR_GRAPHICS_OPM_INVALID_ENCRYPTED_PARAMETERS: HRESULT = 0xC0262503u32 as HRESULT; pub const ERROR_GRAPHICS_OPM_NO_VIDEO_OUTPUTS_EXIST: HRESULT = 0xC0262505u32 as HRESULT; pub const ERROR_GRAPHICS_OPM_INTERNAL_ERROR: HRESULT = 0xC026250Bu32 as HRESULT; pub const ERROR_GRAPHICS_OPM_INVALID_HANDLE: HRESULT = 0xC026250Cu32 as HRESULT; pub const ERROR_GRAPHICS_PVP_INVALID_CERTIFICATE_LENGTH: HRESULT = 0xC026250Eu32 as HRESULT; pub const ERROR_GRAPHICS_OPM_SPANNING_MODE_ENABLED: HRESULT = 0xC026250Fu32 as HRESULT; pub const ERROR_GRAPHICS_OPM_THEATER_MODE_ENABLED: HRESULT = 0xC0262510u32 as HRESULT; pub const ERROR_GRAPHICS_PVP_HFS_FAILED: HRESULT = 0xC0262511u32 as HRESULT; pub const ERROR_GRAPHICS_OPM_INVALID_SRM: HRESULT = 0xC0262512u32 as HRESULT; pub const ERROR_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_HDCP: HRESULT = 0xC0262513u32 as HRESULT; pub const ERROR_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_ACP: HRESULT = 0xC0262514u32 as HRESULT; pub const ERROR_GRAPHICS_OPM_OUTPUT_DOES_NOT_SUPPORT_CGMSA: HRESULT = 0xC0262515u32 as HRESULT; pub const ERROR_GRAPHICS_OPM_HDCP_SRM_NEVER_SET: HRESULT = 0xC0262516u32 as HRESULT; pub const ERROR_GRAPHICS_OPM_RESOLUTION_TOO_HIGH: HRESULT = 0xC0262517u32 as HRESULT; pub const ERROR_GRAPHICS_OPM_ALL_HDCP_HARDWARE_ALREADY_IN_USE: HRESULT = 0xC0262518u32 as HRESULT; pub const ERROR_GRAPHICS_OPM_VIDEO_OUTPUT_NO_LONGER_EXISTS: HRESULT = 0xC026251Au32 as HRESULT; pub const ERROR_GRAPHICS_OPM_SESSION_TYPE_CHANGE_IN_PROGRESS: HRESULT = 0xC026251Bu32 as HRESULT; pub const ERROR_GRAPHICS_OPM_VIDEO_OUTPUT_DOES_NOT_HAVE_COPP_SEMANTICS: HRESULT = 0xC026251Cu32 as HRESULT; pub const ERROR_GRAPHICS_OPM_INVALID_INFORMATION_REQUEST: HRESULT = 0xC026251Du32 as HRESULT; pub const ERROR_GRAPHICS_OPM_DRIVER_INTERNAL_ERROR: HRESULT = 0xC026251Eu32 as HRESULT; pub const ERROR_GRAPHICS_OPM_VIDEO_OUTPUT_DOES_NOT_HAVE_OPM_SEMANTICS: HRESULT = 0xC026251Fu32 as HRESULT; pub const ERROR_GRAPHICS_OPM_SIGNALING_NOT_SUPPORTED: HRESULT = 0xC0262520u32 as HRESULT; pub const ERROR_GRAPHICS_OPM_INVALID_CONFIGURATION_REQUEST: HRESULT = 0xC0262521u32 as HRESULT; pub const ERROR_GRAPHICS_I2C_NOT_SUPPORTED: HRESULT = 0xC0262580u32 as HRESULT; pub const ERROR_GRAPHICS_I2C_DEVICE_DOES_NOT_EXIST: HRESULT = 0xC0262581u32 as HRESULT; pub const ERROR_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA: HRESULT = 0xC0262582u32 as HRESULT; pub const ERROR_GRAPHICS_I2C_ERROR_RECEIVING_DATA: HRESULT = 0xC0262583u32 as HRESULT; pub const ERROR_GRAPHICS_DDCCI_VCP_NOT_SUPPORTED: HRESULT = 0xC0262584u32 as HRESULT; pub const ERROR_GRAPHICS_DDCCI_INVALID_DATA: HRESULT = 0xC0262585u32 as HRESULT; pub const ERROR_GRAPHICS_DDCCI_MONITOR_RETURNED_INVALID_TIMING_STATUS_BYTE: HRESULT = 0xC0262586u32 as HRESULT; pub const ERROR_GRAPHICS_MCA_INVALID_CAPABILITIES_STRING: HRESULT = 0xC0262587u32 as HRESULT; pub const ERROR_GRAPHICS_MCA_INTERNAL_ERROR: HRESULT = 0xC0262588u32 as HRESULT; pub const ERROR_GRAPHICS_DDCCI_INVALID_MESSAGE_COMMAND: HRESULT = 0xC0262589u32 as HRESULT; pub const ERROR_GRAPHICS_DDCCI_INVALID_MESSAGE_LENGTH: HRESULT = 0xC026258Au32 as HRESULT; pub const ERROR_GRAPHICS_DDCCI_INVALID_MESSAGE_CHECKSUM: HRESULT = 0xC026258Bu32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_PHYSICAL_MONITOR_HANDLE: HRESULT = 0xC026258Cu32 as HRESULT; pub const ERROR_GRAPHICS_MONITOR_NO_LONGER_EXISTS: HRESULT = 0xC026258Du32 as HRESULT; pub const ERROR_GRAPHICS_DDCCI_CURRENT_CURRENT_VALUE_GREATER_THAN_MAXIMUM_VALUE: HRESULT = 0xC02625D8u32 as HRESULT; pub const ERROR_GRAPHICS_MCA_INVALID_VCP_VERSION: HRESULT = 0xC02625D9u32 as HRESULT; pub const ERROR_GRAPHICS_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION: HRESULT = 0xC02625DAu32 as HRESULT; pub const ERROR_GRAPHICS_MCA_MCCS_VERSION_MISMATCH: HRESULT = 0xC02625DBu32 as HRESULT; pub const ERROR_GRAPHICS_MCA_UNSUPPORTED_MCCS_VERSION: HRESULT = 0xC02625DCu32 as HRESULT; pub const ERROR_GRAPHICS_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED: HRESULT = 0xC02625DEu32 as HRESULT; pub const ERROR_GRAPHICS_MCA_UNSUPPORTED_COLOR_TEMPERATURE: HRESULT = 0xC02625DFu32 as HRESULT; pub const ERROR_GRAPHICS_ONLY_CONSOLE_SESSION_SUPPORTED: HRESULT = 0xC02625E0u32 as HRESULT; pub const ERROR_GRAPHICS_NO_DISPLAY_DEVICE_CORRESPONDS_TO_NAME: HRESULT = 0xC02625E1u32 as HRESULT; pub const ERROR_GRAPHICS_DISPLAY_DEVICE_NOT_ATTACHED_TO_DESKTOP: HRESULT = 0xC02625E2u32 as HRESULT; pub const ERROR_GRAPHICS_MIRRORING_DEVICES_NOT_SUPPORTED: HRESULT = 0xC02625E3u32 as HRESULT; pub const ERROR_GRAPHICS_INVALID_POINTER: HRESULT = 0xC02625E4u32 as HRESULT; pub const ERROR_GRAPHICS_NO_MONITORS_CORRESPOND_TO_DISPLAY_DEVICE: HRESULT = 0xC02625E5u32 as HRESULT; pub const ERROR_GRAPHICS_PARAMETER_ARRAY_TOO_SMALL: HRESULT = 0xC02625E6u32 as HRESULT; pub const ERROR_GRAPHICS_INTERNAL_ERROR: HRESULT = 0xC02625E7u32 as HRESULT; pub const ERROR_GRAPHICS_SESSION_TYPE_CHANGE_IN_PROGRESS: HRESULT = 0xC02605E8u32 as HRESULT; pub const NAP_E_INVALID_PACKET: HRESULT = 0x80270001u32 as HRESULT; pub const NAP_E_MISSING_SOH: HRESULT = 0x80270002u32 as HRESULT; pub const NAP_E_CONFLICTING_ID: HRESULT = 0x80270003u32 as HRESULT; pub const NAP_E_NO_CACHED_SOH: HRESULT = 0x80270004u32 as HRESULT; pub const NAP_E_STILL_BOUND: HRESULT = 0x80270005u32 as HRESULT; pub const NAP_E_NOT_REGISTERED: HRESULT = 0x80270006u32 as HRESULT; pub const NAP_E_NOT_INITIALIZED: HRESULT = 0x80270007u32 as HRESULT; pub const NAP_E_MISMATCHED_ID: HRESULT = 0x80270008u32 as HRESULT; pub const NAP_E_NOT_PENDING: HRESULT = 0x80270009u32 as HRESULT; pub const NAP_E_ID_NOT_FOUND: HRESULT = 0x8027000Au32 as HRESULT; pub const NAP_E_MAXSIZE_TOO_SMALL: HRESULT = 0x8027000Bu32 as HRESULT; pub const NAP_E_SERVICE_NOT_RUNNING: HRESULT = 0x8027000Cu32 as HRESULT; pub const NAP_S_CERT_ALREADY_PRESENT: HRESULT = 0x0027000D; pub const NAP_E_ENTITY_DISABLED: HRESULT = 0x8027000Eu32 as HRESULT; pub const NAP_E_NETSH_GROUPPOLICY_ERROR: HRESULT = 0x8027000Fu32 as HRESULT; pub const NAP_E_TOO_MANY_CALLS: HRESULT = 0x80270010u32 as HRESULT; pub const NAP_E_SHV_CONFIG_EXISTED: HRESULT = 0x80270011u32 as HRESULT; pub const NAP_E_SHV_CONFIG_NOT_FOUND: HRESULT = 0x80270012u32 as HRESULT; pub const NAP_E_SHV_TIMEOUT: HRESULT = 0x80270013u32 as HRESULT; pub const TPM_E_ERROR_MASK: HRESULT = 0x80280000u32 as HRESULT; pub const TPM_E_AUTHFAIL: HRESULT = 0x80280001u32 as HRESULT; pub const TPM_E_BADINDEX: HRESULT = 0x80280002u32 as HRESULT; pub const TPM_E_BAD_PARAMETER: HRESULT = 0x80280003u32 as HRESULT; pub const TPM_E_AUDITFAILURE: HRESULT = 0x80280004u32 as HRESULT; pub const TPM_E_CLEAR_DISABLED: HRESULT = 0x80280005u32 as HRESULT; pub const TPM_E_DEACTIVATED: HRESULT = 0x80280006u32 as HRESULT; pub const TPM_E_DISABLED: HRESULT = 0x80280007u32 as HRESULT; pub const TPM_E_DISABLED_CMD: HRESULT = 0x80280008u32 as HRESULT; pub const TPM_E_FAIL: HRESULT = 0x80280009u32 as HRESULT; pub const TPM_E_BAD_ORDINAL: HRESULT = 0x8028000Au32 as HRESULT; pub const TPM_E_INSTALL_DISABLED: HRESULT = 0x8028000Bu32 as HRESULT; pub const TPM_E_INVALID_KEYHANDLE: HRESULT = 0x8028000Cu32 as HRESULT; pub const TPM_E_KEYNOTFOUND: HRESULT = 0x8028000Du32 as HRESULT; pub const TPM_E_INAPPROPRIATE_ENC: HRESULT = 0x8028000Eu32 as HRESULT; pub const TPM_E_MIGRATEFAIL: HRESULT = 0x8028000Fu32 as HRESULT; pub const TPM_E_INVALID_PCR_INFO: HRESULT = 0x80280010u32 as HRESULT; pub const TPM_E_NOSPACE: HRESULT = 0x80280011u32 as HRESULT; pub const TPM_E_NOSRK: HRESULT = 0x80280012u32 as HRESULT; pub const TPM_E_NOTSEALED_BLOB: HRESULT = 0x80280013u32 as HRESULT; pub const TPM_E_OWNER_SET: HRESULT = 0x80280014u32 as HRESULT; pub const TPM_E_RESOURCES: HRESULT = 0x80280015u32 as HRESULT; pub const TPM_E_SHORTRANDOM: HRESULT = 0x80280016u32 as HRESULT; pub const TPM_E_SIZE: HRESULT = 0x80280017u32 as HRESULT; pub const TPM_E_WRONGPCRVAL: HRESULT = 0x80280018u32 as HRESULT; pub const TPM_E_BAD_PARAM_SIZE: HRESULT = 0x80280019u32 as HRESULT; pub const TPM_E_SHA_THREAD: HRESULT = 0x8028001Au32 as HRESULT; pub const TPM_E_SHA_ERROR: HRESULT = 0x8028001Bu32 as HRESULT; pub const TPM_E_FAILEDSELFTEST: HRESULT = 0x8028001Cu32 as HRESULT; pub const TPM_E_AUTH2FAIL: HRESULT = 0x8028001Du32 as HRESULT; pub const TPM_E_BADTAG: HRESULT = 0x8028001Eu32 as HRESULT; pub const TPM_E_IOERROR: HRESULT = 0x8028001Fu32 as HRESULT; pub const TPM_E_ENCRYPT_ERROR: HRESULT = 0x80280020u32 as HRESULT; pub const TPM_E_DECRYPT_ERROR: HRESULT = 0x80280021u32 as HRESULT; pub const TPM_E_INVALID_AUTHHANDLE: HRESULT = 0x80280022u32 as HRESULT; pub const TPM_E_NO_ENDORSEMENT: HRESULT = 0x80280023u32 as HRESULT; pub const TPM_E_INVALID_KEYUSAGE: HRESULT = 0x80280024u32 as HRESULT; pub const TPM_E_WRONG_ENTITYTYPE: HRESULT = 0x80280025u32 as HRESULT; pub const TPM_E_INVALID_POSTINIT: HRESULT = 0x80280026u32 as HRESULT; pub const TPM_E_INAPPROPRIATE_SIG: HRESULT = 0x80280027u32 as HRESULT; pub const TPM_E_BAD_KEY_PROPERTY: HRESULT = 0x80280028u32 as HRESULT; pub const TPM_E_BAD_MIGRATION: HRESULT = 0x80280029u32 as HRESULT; pub const TPM_E_BAD_SCHEME: HRESULT = 0x8028002Au32 as HRESULT; pub const TPM_E_BAD_DATASIZE: HRESULT = 0x8028002Bu32 as HRESULT; pub const TPM_E_BAD_MODE: HRESULT = 0x8028002Cu32 as HRESULT; pub const TPM_E_BAD_PRESENCE: HRESULT = 0x8028002Du32 as HRESULT; pub const TPM_E_BAD_VERSION: HRESULT = 0x8028002Eu32 as HRESULT; pub const TPM_E_NO_WRAP_TRANSPORT: HRESULT = 0x8028002Fu32 as HRESULT; pub const TPM_E_AUDITFAIL_UNSUCCESSFUL: HRESULT = 0x80280030u32 as HRESULT; pub const TPM_E_AUDITFAIL_SUCCESSFUL: HRESULT = 0x80280031u32 as HRESULT; pub const TPM_E_NOTRESETABLE: HRESULT = 0x80280032u32 as HRESULT; pub const TPM_E_NOTLOCAL: HRESULT = 0x80280033u32 as HRESULT; pub const TPM_E_BAD_TYPE: HRESULT = 0x80280034u32 as HRESULT; pub const TPM_E_INVALID_RESOURCE: HRESULT = 0x80280035u32 as HRESULT; pub const TPM_E_NOTFIPS: HRESULT = 0x80280036u32 as HRESULT; pub const TPM_E_INVALID_FAMILY: HRESULT = 0x80280037u32 as HRESULT; pub const TPM_E_NO_NV_PERMISSION: HRESULT = 0x80280038u32 as HRESULT; pub const TPM_E_REQUIRES_SIGN: HRESULT = 0x80280039u32 as HRESULT; pub const TPM_E_KEY_NOTSUPPORTED: HRESULT = 0x8028003Au32 as HRESULT; pub const TPM_E_AUTH_CONFLICT: HRESULT = 0x8028003Bu32 as HRESULT; pub const TPM_E_AREA_LOCKED: HRESULT = 0x8028003Cu32 as HRESULT; pub const TPM_E_BAD_LOCALITY: HRESULT = 0x8028003Du32 as HRESULT; pub const TPM_E_READ_ONLY: HRESULT = 0x8028003Eu32 as HRESULT; pub const TPM_E_PER_NOWRITE: HRESULT = 0x8028003Fu32 as HRESULT; pub const TPM_E_FAMILYCOUNT: HRESULT = 0x80280040u32 as HRESULT; pub const TPM_E_WRITE_LOCKED: HRESULT = 0x80280041u32 as HRESULT; pub const TPM_E_BAD_ATTRIBUTES: HRESULT = 0x80280042u32 as HRESULT; pub const TPM_E_INVALID_STRUCTURE: HRESULT = 0x80280043u32 as HRESULT; pub const TPM_E_KEY_OWNER_CONTROL: HRESULT = 0x80280044u32 as HRESULT; pub const TPM_E_BAD_COUNTER: HRESULT = 0x80280045u32 as HRESULT; pub const TPM_E_NOT_FULLWRITE: HRESULT = 0x80280046u32 as HRESULT; pub const TPM_E_CONTEXT_GAP: HRESULT = 0x80280047u32 as HRESULT; pub const TPM_E_MAXNVWRITES: HRESULT = 0x80280048u32 as HRESULT; pub const TPM_E_NOOPERATOR: HRESULT = 0x80280049u32 as HRESULT; pub const TPM_E_RESOURCEMISSING: HRESULT = 0x8028004Au32 as HRESULT; pub const TPM_E_DELEGATE_LOCK: HRESULT = 0x8028004Bu32 as HRESULT; pub const TPM_E_DELEGATE_FAMILY: HRESULT = 0x8028004Cu32 as HRESULT; pub const TPM_E_DELEGATE_ADMIN: HRESULT = 0x8028004Du32 as HRESULT; pub const TPM_E_TRANSPORT_NOTEXCLUSIVE: HRESULT = 0x8028004Eu32 as HRESULT; pub const TPM_E_OWNER_CONTROL: HRESULT = 0x8028004Fu32 as HRESULT; pub const TPM_E_DAA_RESOURCES: HRESULT = 0x80280050u32 as HRESULT; pub const TPM_E_DAA_INPUT_DATA0: HRESULT = 0x80280051u32 as HRESULT; pub const TPM_E_DAA_INPUT_DATA1: HRESULT = 0x80280052u32 as HRESULT; pub const TPM_E_DAA_ISSUER_SETTINGS: HRESULT = 0x80280053u32 as HRESULT; pub const TPM_E_DAA_TPM_SETTINGS: HRESULT = 0x80280054u32 as HRESULT; pub const TPM_E_DAA_STAGE: HRESULT = 0x80280055u32 as HRESULT; pub const TPM_E_DAA_ISSUER_VALIDITY: HRESULT = 0x80280056u32 as HRESULT; pub const TPM_E_DAA_WRONG_W: HRESULT = 0x80280057u32 as HRESULT; pub const TPM_E_BAD_HANDLE: HRESULT = 0x80280058u32 as HRESULT; pub const TPM_E_BAD_DELEGATE: HRESULT = 0x80280059u32 as HRESULT; pub const TPM_E_BADCONTEXT: HRESULT = 0x8028005Au32 as HRESULT; pub const TPM_E_TOOMANYCONTEXTS: HRESULT = 0x8028005Bu32 as HRESULT; pub const TPM_E_MA_TICKET_SIGNATURE: HRESULT = 0x8028005Cu32 as HRESULT; pub const TPM_E_MA_DESTINATION: HRESULT = 0x8028005Du32 as HRESULT; pub const TPM_E_MA_SOURCE: HRESULT = 0x8028005Eu32 as HRESULT; pub const TPM_E_MA_AUTHORITY: HRESULT = 0x8028005Fu32 as HRESULT; pub const TPM_E_PERMANENTEK: HRESULT = 0x80280061u32 as HRESULT; pub const TPM_E_BAD_SIGNATURE: HRESULT = 0x80280062u32 as HRESULT; pub const TPM_E_NOCONTEXTSPACE: HRESULT = 0x80280063u32 as HRESULT; pub const TPM_E_COMMAND_BLOCKED: HRESULT = 0x80280400u32 as HRESULT; pub const TPM_E_INVALID_HANDLE: HRESULT = 0x80280401u32 as HRESULT; pub const TPM_E_DUPLICATE_VHANDLE: HRESULT = 0x80280402u32 as HRESULT; pub const TPM_E_EMBEDDED_COMMAND_BLOCKED: HRESULT = 0x80280403u32 as HRESULT; pub const TPM_E_EMBEDDED_COMMAND_UNSUPPORTED: HRESULT = 0x80280404u32 as HRESULT; pub const TPM_E_RETRY: HRESULT = 0x80280800u32 as HRESULT; pub const TPM_E_NEEDS_SELFTEST: HRESULT = 0x80280801u32 as HRESULT; pub const TPM_E_DOING_SELFTEST: HRESULT = 0x80280802u32 as HRESULT; pub const TPM_E_DEFEND_LOCK_RUNNING: HRESULT = 0x80280803u32 as HRESULT; pub const TBS_E_INTERNAL_ERROR: HRESULT = 0x80284001u32 as HRESULT; pub const TBS_E_BAD_PARAMETER: HRESULT = 0x80284002u32 as HRESULT; pub const TBS_E_INVALID_OUTPUT_POINTER: HRESULT = 0x80284003u32 as HRESULT; pub const TBS_E_INVALID_CONTEXT: HRESULT = 0x80284004u32 as HRESULT; pub const TBS_E_INSUFFICIENT_BUFFER: HRESULT = 0x80284005u32 as HRESULT; pub const TBS_E_IOERROR: HRESULT = 0x80284006u32 as HRESULT; pub const TBS_E_INVALID_CONTEXT_PARAM: HRESULT = 0x80284007u32 as HRESULT; pub const TBS_E_SERVICE_NOT_RUNNING: HRESULT = 0x80284008u32 as HRESULT; pub const TBS_E_TOO_MANY_TBS_CONTEXTS: HRESULT = 0x80284009u32 as HRESULT; pub const TBS_E_TOO_MANY_RESOURCES: HRESULT = 0x8028400Au32 as HRESULT; pub const TBS_E_SERVICE_START_PENDING: HRESULT = 0x8028400Bu32 as HRESULT; pub const TBS_E_PPI_NOT_SUPPORTED: HRESULT = 0x8028400Cu32 as HRESULT; pub const TBS_E_COMMAND_CANCELED: HRESULT = 0x8028400Du32 as HRESULT; pub const TBS_E_BUFFER_TOO_LARGE: HRESULT = 0x8028400Eu32 as HRESULT; pub const TBS_E_TPM_NOT_FOUND: HRESULT = 0x8028400Fu32 as HRESULT; pub const TBS_E_SERVICE_DISABLED: HRESULT = 0x80284010u32 as HRESULT; pub const TBS_E_NO_EVENT_LOG: HRESULT = 0x80284011u32 as HRESULT; pub const TBS_E_ACCESS_DENIED: HRESULT = 0x80284012u32 as HRESULT; pub const TBS_E_PROVISIONING_NOT_ALLOWED: HRESULT = 0x80284013u32 as HRESULT; pub const TBS_E_PPI_FUNCTION_UNSUPPORTED: HRESULT = 0x80284014u32 as HRESULT; pub const TBS_E_OWNERAUTH_NOT_FOUND: HRESULT = 0x80284015u32 as HRESULT; pub const TBS_E_PROVISIONING_INCOMPLETE: HRESULT = 0x80284016u32 as HRESULT; pub const TPMAPI_E_INVALID_STATE: HRESULT = 0x80290100u32 as HRESULT; pub const TPMAPI_E_NOT_ENOUGH_DATA: HRESULT = 0x80290101u32 as HRESULT; pub const TPMAPI_E_TOO_MUCH_DATA: HRESULT = 0x80290102u32 as HRESULT; pub const TPMAPI_E_INVALID_OUTPUT_POINTER: HRESULT = 0x80290103u32 as HRESULT; pub const TPMAPI_E_INVALID_PARAMETER: HRESULT = 0x80290104u32 as HRESULT; pub const TPMAPI_E_OUT_OF_MEMORY: HRESULT = 0x80290105u32 as HRESULT; pub const TPMAPI_E_BUFFER_TOO_SMALL: HRESULT = 0x80290106u32 as HRESULT; pub const TPMAPI_E_INTERNAL_ERROR: HRESULT = 0x80290107u32 as HRESULT; pub const TPMAPI_E_ACCESS_DENIED: HRESULT = 0x80290108u32 as HRESULT; pub const TPMAPI_E_AUTHORIZATION_FAILED: HRESULT = 0x80290109u32 as HRESULT; pub const TPMAPI_E_INVALID_CONTEXT_HANDLE: HRESULT = 0x8029010Au32 as HRESULT; pub const TPMAPI_E_TBS_COMMUNICATION_ERROR: HRESULT = 0x8029010Bu32 as HRESULT; pub const TPMAPI_E_TPM_COMMAND_ERROR: HRESULT = 0x8029010Cu32 as HRESULT; pub const TPMAPI_E_MESSAGE_TOO_LARGE: HRESULT = 0x8029010Du32 as HRESULT; pub const TPMAPI_E_INVALID_ENCODING: HRESULT = 0x8029010Eu32 as HRESULT; pub const TPMAPI_E_INVALID_KEY_SIZE: HRESULT = 0x8029010Fu32 as HRESULT; pub const TPMAPI_E_ENCRYPTION_FAILED: HRESULT = 0x80290110u32 as HRESULT; pub const TPMAPI_E_INVALID_KEY_PARAMS: HRESULT = 0x80290111u32 as HRESULT; pub const TPMAPI_E_INVALID_MIGRATION_AUTHORIZATION_BLOB: HRESULT = 0x80290112u32 as HRESULT; pub const TPMAPI_E_INVALID_PCR_INDEX: HRESULT = 0x80290113u32 as HRESULT; pub const TPMAPI_E_INVALID_DELEGATE_BLOB: HRESULT = 0x80290114u32 as HRESULT; pub const TPMAPI_E_INVALID_CONTEXT_PARAMS: HRESULT = 0x80290115u32 as HRESULT; pub const TPMAPI_E_INVALID_KEY_BLOB: HRESULT = 0x80290116u32 as HRESULT; pub const TPMAPI_E_INVALID_PCR_DATA: HRESULT = 0x80290117u32 as HRESULT; pub const TPMAPI_E_INVALID_OWNER_AUTH: HRESULT = 0x80290118u32 as HRESULT; pub const TPMAPI_E_FIPS_RNG_CHECK_FAILED: HRESULT = 0x80290119u32 as HRESULT; pub const TPMAPI_E_EMPTY_TCG_LOG: HRESULT = 0x8029011Au32 as HRESULT; pub const TPMAPI_E_INVALID_TCG_LOG_ENTRY: HRESULT = 0x8029011Bu32 as HRESULT; pub const TPMAPI_E_TCG_SEPARATOR_ABSENT: HRESULT = 0x8029011Cu32 as HRESULT; pub const TPMAPI_E_TCG_INVALID_DIGEST_ENTRY: HRESULT = 0x8029011Du32 as HRESULT; pub const TPMAPI_E_POLICY_DENIES_OPERATION: HRESULT = 0x8029011Eu32 as HRESULT; pub const TBSIMP_E_BUFFER_TOO_SMALL: HRESULT = 0x80290200u32 as HRESULT; pub const TBSIMP_E_CLEANUP_FAILED: HRESULT = 0x80290201u32 as HRESULT; pub const TBSIMP_E_INVALID_CONTEXT_HANDLE: HRESULT = 0x80290202u32 as HRESULT; pub const TBSIMP_E_INVALID_CONTEXT_PARAM: HRESULT = 0x80290203u32 as HRESULT; pub const TBSIMP_E_TPM_ERROR: HRESULT = 0x80290204u32 as HRESULT; pub const TBSIMP_E_HASH_BAD_KEY: HRESULT = 0x80290205u32 as HRESULT; pub const TBSIMP_E_DUPLICATE_VHANDLE: HRESULT = 0x80290206u32 as HRESULT; pub const TBSIMP_E_INVALID_OUTPUT_POINTER: HRESULT = 0x80290207u32 as HRESULT; pub const TBSIMP_E_INVALID_PARAMETER: HRESULT = 0x80290208u32 as HRESULT; pub const TBSIMP_E_RPC_INIT_FAILED: HRESULT = 0x80290209u32 as HRESULT; pub const TBSIMP_E_SCHEDULER_NOT_RUNNING: HRESULT = 0x8029020Au32 as HRESULT; pub const TBSIMP_E_COMMAND_CANCELED: HRESULT = 0x8029020Bu32 as HRESULT; pub const TBSIMP_E_OUT_OF_MEMORY: HRESULT = 0x8029020Cu32 as HRESULT; pub const TBSIMP_E_LIST_NO_MORE_ITEMS: HRESULT = 0x8029020Du32 as HRESULT; pub const TBSIMP_E_LIST_NOT_FOUND: HRESULT = 0x8029020Eu32 as HRESULT; pub const TBSIMP_E_NOT_ENOUGH_SPACE: HRESULT = 0x8029020Fu32 as HRESULT; pub const TBSIMP_E_NOT_ENOUGH_TPM_CONTEXTS: HRESULT = 0x80290210u32 as HRESULT; pub const TBSIMP_E_COMMAND_FAILED: HRESULT = 0x80290211u32 as HRESULT; pub const TBSIMP_E_UNKNOWN_ORDINAL: HRESULT = 0x80290212u32 as HRESULT; pub const TBSIMP_E_RESOURCE_EXPIRED: HRESULT = 0x80290213u32 as HRESULT; pub const TBSIMP_E_INVALID_RESOURCE: HRESULT = 0x80290214u32 as HRESULT; pub const TBSIMP_E_NOTHING_TO_UNLOAD: HRESULT = 0x80290215u32 as HRESULT; pub const TBSIMP_E_HASH_TABLE_FULL: HRESULT = 0x80290216u32 as HRESULT; pub const TBSIMP_E_TOO_MANY_TBS_CONTEXTS: HRESULT = 0x80290217u32 as HRESULT; pub const TBSIMP_E_TOO_MANY_RESOURCES: HRESULT = 0x80290218u32 as HRESULT; pub const TBSIMP_E_PPI_NOT_SUPPORTED: HRESULT = 0x80290219u32 as HRESULT; pub const TBSIMP_E_TPM_INCOMPATIBLE: HRESULT = 0x8029021Au32 as HRESULT; pub const TBSIMP_E_NO_EVENT_LOG: HRESULT = 0x8029021Bu32 as HRESULT; pub const TPM_E_PPI_ACPI_FAILURE: HRESULT = 0x80290300u32 as HRESULT; pub const TPM_E_PPI_USER_ABORT: HRESULT = 0x80290301u32 as HRESULT; pub const TPM_E_PPI_BIOS_FAILURE: HRESULT = 0x80290302u32 as HRESULT; pub const TPM_E_PPI_NOT_SUPPORTED: HRESULT = 0x80290303u32 as HRESULT; pub const TPM_E_PPI_BLOCKED_IN_BIOS: HRESULT = 0x80290304u32 as HRESULT; pub const TPM_E_PCP_ERROR_MASK: HRESULT = 0x80290400u32 as HRESULT; pub const TPM_E_PCP_DEVICE_NOT_READY: HRESULT = 0x80290401u32 as HRESULT; pub const TPM_E_PCP_INVALID_HANDLE: HRESULT = 0x80290402u32 as HRESULT; pub const TPM_E_PCP_INVALID_PARAMETER: HRESULT = 0x80290403u32 as HRESULT; pub const TPM_E_PCP_FLAG_NOT_SUPPORTED: HRESULT = 0x80290404u32 as HRESULT; pub const TPM_E_PCP_NOT_SUPPORTED: HRESULT = 0x80290405u32 as HRESULT; pub const TPM_E_PCP_BUFFER_TOO_SMALL: HRESULT = 0x80290406u32 as HRESULT; pub const TPM_E_PCP_INTERNAL_ERROR: HRESULT = 0x80290407u32 as HRESULT; pub const TPM_E_PCP_AUTHENTICATION_FAILED: HRESULT = 0x80290408u32 as HRESULT; pub const TPM_E_PCP_AUTHENTICATION_IGNORED: HRESULT = 0x80290409u32 as HRESULT; pub const TPM_E_PCP_POLICY_NOT_FOUND: HRESULT = 0x8029040Au32 as HRESULT; pub const TPM_E_PCP_PROFILE_NOT_FOUND: HRESULT = 0x8029040Bu32 as HRESULT; pub const TPM_E_PCP_VALIDATION_FAILED: HRESULT = 0x8029040Cu32 as HRESULT; pub const PLA_E_DCS_NOT_FOUND: HRESULT = 0x80300002u32 as HRESULT; pub const PLA_E_DCS_IN_USE: HRESULT = 0x803000AAu32 as HRESULT; pub const PLA_E_TOO_MANY_FOLDERS: HRESULT = 0x80300045u32 as HRESULT; pub const PLA_E_NO_MIN_DISK: HRESULT = 0x80300070u32 as HRESULT; pub const PLA_E_DCS_ALREADY_EXISTS: HRESULT = 0x803000B7u32 as HRESULT; pub const PLA_S_PROPERTY_IGNORED: HRESULT = 0x00300100; pub const PLA_E_PROPERTY_CONFLICT: HRESULT = 0x80300101u32 as HRESULT; pub const PLA_E_DCS_SINGLETON_REQUIRED: HRESULT = 0x80300102u32 as HRESULT; pub const PLA_E_CREDENTIALS_REQUIRED: HRESULT = 0x80300103u32 as HRESULT; pub const PLA_E_DCS_NOT_RUNNING: HRESULT = 0x80300104u32 as HRESULT; pub const PLA_E_CONFLICT_INCL_EXCL_API: HRESULT = 0x80300105u32 as HRESULT; pub const PLA_E_NETWORK_EXE_NOT_VALID: HRESULT = 0x80300106u32 as HRESULT; pub const PLA_E_EXE_ALREADY_CONFIGURED: HRESULT = 0x80300107u32 as HRESULT; pub const PLA_E_EXE_PATH_NOT_VALID: HRESULT = 0x80300108u32 as HRESULT; pub const PLA_E_DC_ALREADY_EXISTS: HRESULT = 0x80300109u32 as HRESULT; pub const PLA_E_DCS_START_WAIT_TIMEOUT: HRESULT = 0x8030010Au32 as HRESULT; pub const PLA_E_DC_START_WAIT_TIMEOUT: HRESULT = 0x8030010Bu32 as HRESULT; pub const PLA_E_REPORT_WAIT_TIMEOUT: HRESULT = 0x8030010Cu32 as HRESULT; pub const PLA_E_NO_DUPLICATES: HRESULT = 0x8030010Du32 as HRESULT; pub const PLA_E_EXE_FULL_PATH_REQUIRED: HRESULT = 0x8030010Eu32 as HRESULT; pub const PLA_E_INVALID_SESSION_NAME: HRESULT = 0x8030010Fu32 as HRESULT; pub const PLA_E_PLA_CHANNEL_NOT_ENABLED: HRESULT = 0x80300110u32 as HRESULT; pub const PLA_E_TASKSCHED_CHANNEL_NOT_ENABLED: HRESULT = 0x80300111u32 as HRESULT; pub const PLA_E_RULES_MANAGER_FAILED: HRESULT = 0x80300112u32 as HRESULT; pub const PLA_E_CABAPI_FAILURE: HRESULT = 0x80300113u32 as HRESULT; pub const FVE_E_LOCKED_VOLUME: HRESULT = 0x80310000u32 as HRESULT; pub const FVE_E_NOT_ENCRYPTED: HRESULT = 0x80310001u32 as HRESULT; pub const FVE_E_NO_TPM_BIOS: HRESULT = 0x80310002u32 as HRESULT; pub const FVE_E_NO_MBR_METRIC: HRESULT = 0x80310003u32 as HRESULT; pub const FVE_E_NO_BOOTSECTOR_METRIC: HRESULT = 0x80310004u32 as HRESULT; pub const FVE_E_NO_BOOTMGR_METRIC: HRESULT = 0x80310005u32 as HRESULT; pub const FVE_E_WRONG_BOOTMGR: HRESULT = 0x80310006u32 as HRESULT; pub const FVE_E_SECURE_KEY_REQUIRED: HRESULT = 0x80310007u32 as HRESULT; pub const FVE_E_NOT_ACTIVATED: HRESULT = 0x80310008u32 as HRESULT; pub const FVE_E_ACTION_NOT_ALLOWED: HRESULT = 0x80310009u32 as HRESULT; pub const FVE_E_AD_SCHEMA_NOT_INSTALLED: HRESULT = 0x8031000Au32 as HRESULT; pub const FVE_E_AD_INVALID_DATATYPE: HRESULT = 0x8031000Bu32 as HRESULT; pub const FVE_E_AD_INVALID_DATASIZE: HRESULT = 0x8031000Cu32 as HRESULT; pub const FVE_E_AD_NO_VALUES: HRESULT = 0x8031000Du32 as HRESULT; pub const FVE_E_AD_ATTR_NOT_SET: HRESULT = 0x8031000Eu32 as HRESULT; pub const FVE_E_AD_GUID_NOT_FOUND: HRESULT = 0x8031000Fu32 as HRESULT; pub const FVE_E_BAD_INFORMATION: HRESULT = 0x80310010u32 as HRESULT; pub const FVE_E_TOO_SMALL: HRESULT = 0x80310011u32 as HRESULT; pub const FVE_E_SYSTEM_VOLUME: HRESULT = 0x80310012u32 as HRESULT; pub const FVE_E_FAILED_WRONG_FS: HRESULT = 0x80310013u32 as HRESULT; pub const FVE_E_BAD_PARTITION_SIZE: HRESULT = 0x80310014u32 as HRESULT; pub const FVE_E_NOT_SUPPORTED: HRESULT = 0x80310015u32 as HRESULT; pub const FVE_E_BAD_DATA: HRESULT = 0x80310016u32 as HRESULT; pub const FVE_E_VOLUME_NOT_BOUND: HRESULT = 0x80310017u32 as HRESULT; pub const FVE_E_TPM_NOT_OWNED: HRESULT = 0x80310018u32 as HRESULT; pub const FVE_E_NOT_DATA_VOLUME: HRESULT = 0x80310019u32 as HRESULT; pub const FVE_E_AD_INSUFFICIENT_BUFFER: HRESULT = 0x8031001Au32 as HRESULT; pub const FVE_E_CONV_READ: HRESULT = 0x8031001Bu32 as HRESULT; pub const FVE_E_CONV_WRITE: HRESULT = 0x8031001Cu32 as HRESULT; pub const FVE_E_KEY_REQUIRED: HRESULT = 0x8031001Du32 as HRESULT; pub const FVE_E_CLUSTERING_NOT_SUPPORTED: HRESULT = 0x8031001Eu32 as HRESULT; pub const FVE_E_VOLUME_BOUND_ALREADY: HRESULT = 0x8031001Fu32 as HRESULT; pub const FVE_E_OS_NOT_PROTECTED: HRESULT = 0x80310020u32 as HRESULT; pub const FVE_E_PROTECTION_DISABLED: HRESULT = 0x80310021u32 as HRESULT; pub const FVE_E_RECOVERY_KEY_REQUIRED: HRESULT = 0x80310022u32 as HRESULT; pub const FVE_E_FOREIGN_VOLUME: HRESULT = 0x80310023u32 as HRESULT; pub const FVE_E_OVERLAPPED_UPDATE: HRESULT = 0x80310024u32 as HRESULT; pub const FVE_E_TPM_SRK_AUTH_NOT_ZERO: HRESULT = 0x80310025u32 as HRESULT; pub const FVE_E_FAILED_SECTOR_SIZE: HRESULT = 0x80310026u32 as HRESULT; pub const FVE_E_FAILED_AUTHENTICATION: HRESULT = 0x80310027u32 as HRESULT; pub const FVE_E_NOT_OS_VOLUME: HRESULT = 0x80310028u32 as HRESULT; pub const FVE_E_AUTOUNLOCK_ENABLED: HRESULT = 0x80310029u32 as HRESULT; pub const FVE_E_WRONG_BOOTSECTOR: HRESULT = 0x8031002Au32 as HRESULT; pub const FVE_E_WRONG_SYSTEM_FS: HRESULT = 0x8031002Bu32 as HRESULT; pub const FVE_E_POLICY_PASSWORD_REQUIRED: HRESULT = 0x8031002Cu32 as HRESULT; pub const FVE_E_CANNOT_SET_FVEK_ENCRYPTED: HRESULT = 0x8031002Du32 as HRESULT; pub const FVE_E_CANNOT_ENCRYPT_NO_KEY: HRESULT = 0x8031002Eu32 as HRESULT; pub const FVE_E_BOOTABLE_CDDVD: HRESULT = 0x80310030u32 as HRESULT; pub const FVE_E_PROTECTOR_EXISTS: HRESULT = 0x80310031u32 as HRESULT; pub const FVE_E_RELATIVE_PATH: HRESULT = 0x80310032u32 as HRESULT; pub const FVE_E_PROTECTOR_NOT_FOUND: HRESULT = 0x80310033u32 as HRESULT; pub const FVE_E_INVALID_KEY_FORMAT: HRESULT = 0x80310034u32 as HRESULT; pub const FVE_E_INVALID_PASSWORD_FORMAT: HRESULT = 0x80310035u32 as HRESULT; pub const FVE_E_FIPS_RNG_CHECK_FAILED: HRESULT = 0x80310036u32 as HRESULT; pub const FVE_E_FIPS_PREVENTS_RECOVERY_PASSWORD: HRESULT = 0x80310037u32 as HRESULT; pub const FVE_E_FIPS_PREVENTS_EXTERNAL_KEY_EXPORT: HRESULT = 0x80310038u32 as HRESULT; pub const FVE_E_NOT_DECRYPTED: HRESULT = 0x80310039u32 as HRESULT; pub const FVE_E_INVALID_PROTECTOR_TYPE: HRESULT = 0x8031003Au32 as HRESULT; pub const FVE_E_NO_PROTECTORS_TO_TEST: HRESULT = 0x8031003Bu32 as HRESULT; pub const FVE_E_KEYFILE_NOT_FOUND: HRESULT = 0x8031003Cu32 as HRESULT; pub const FVE_E_KEYFILE_INVALID: HRESULT = 0x8031003Du32 as HRESULT; pub const FVE_E_KEYFILE_NO_VMK: HRESULT = 0x8031003Eu32 as HRESULT; pub const FVE_E_TPM_DISABLED: HRESULT = 0x8031003Fu32 as HRESULT; pub const FVE_E_NOT_ALLOWED_IN_SAFE_MODE: HRESULT = 0x80310040u32 as HRESULT; pub const FVE_E_TPM_INVALID_PCR: HRESULT = 0x80310041u32 as HRESULT; pub const FVE_E_TPM_NO_VMK: HRESULT = 0x80310042u32 as HRESULT; pub const FVE_E_PIN_INVALID: HRESULT = 0x80310043u32 as HRESULT; pub const FVE_E_AUTH_INVALID_APPLICATION: HRESULT = 0x80310044u32 as HRESULT; pub const FVE_E_AUTH_INVALID_CONFIG: HRESULT = 0x80310045u32 as HRESULT; pub const FVE_E_FIPS_DISABLE_PROTECTION_NOT_ALLOWED: HRESULT = 0x80310046u32 as HRESULT; pub const FVE_E_FS_NOT_EXTENDED: HRESULT = 0x80310047u32 as HRESULT; pub const FVE_E_FIRMWARE_TYPE_NOT_SUPPORTED: HRESULT = 0x80310048u32 as HRESULT; pub const FVE_E_NO_LICENSE: HRESULT = 0x80310049u32 as HRESULT; pub const FVE_E_NOT_ON_STACK: HRESULT = 0x8031004Au32 as HRESULT; pub const FVE_E_FS_MOUNTED: HRESULT = 0x8031004Bu32 as HRESULT; pub const FVE_E_TOKEN_NOT_IMPERSONATED: HRESULT = 0x8031004Cu32 as HRESULT; pub const FVE_E_DRY_RUN_FAILED: HRESULT = 0x8031004Du32 as HRESULT; pub const FVE_E_REBOOT_REQUIRED: HRESULT = 0x8031004Eu32 as HRESULT; pub const FVE_E_DEBUGGER_ENABLED: HRESULT = 0x8031004Fu32 as HRESULT; pub const FVE_E_RAW_ACCESS: HRESULT = 0x80310050u32 as HRESULT; pub const FVE_E_RAW_BLOCKED: HRESULT = 0x80310051u32 as HRESULT; pub const FVE_E_BCD_APPLICATIONS_PATH_INCORRECT: HRESULT = 0x80310052u32 as HRESULT; pub const FVE_E_NOT_ALLOWED_IN_VERSION: HRESULT = 0x80310053u32 as HRESULT; pub const FVE_E_NO_AUTOUNLOCK_MASTER_KEY: HRESULT = 0x80310054u32 as HRESULT; pub const FVE_E_MOR_FAILED: HRESULT = 0x80310055u32 as HRESULT; pub const FVE_E_HIDDEN_VOLUME: HRESULT = 0x80310056u32 as HRESULT; pub const FVE_E_TRANSIENT_STATE: HRESULT = 0x80310057u32 as HRESULT; pub const FVE_E_PUBKEY_NOT_ALLOWED: HRESULT = 0x80310058u32 as HRESULT; pub const FVE_E_VOLUME_HANDLE_OPEN: HRESULT = 0x80310059u32 as HRESULT; pub const FVE_E_NO_FEATURE_LICENSE: HRESULT = 0x8031005Au32 as HRESULT; pub const FVE_E_INVALID_STARTUP_OPTIONS: HRESULT = 0x8031005Bu32 as HRESULT; pub const FVE_E_POLICY_RECOVERY_PASSWORD_NOT_ALLOWED: HRESULT = 0x8031005Cu32 as HRESULT; pub const FVE_E_POLICY_RECOVERY_PASSWORD_REQUIRED: HRESULT = 0x8031005Du32 as HRESULT; pub const FVE_E_POLICY_RECOVERY_KEY_NOT_ALLOWED: HRESULT = 0x8031005Eu32 as HRESULT; pub const FVE_E_POLICY_RECOVERY_KEY_REQUIRED: HRESULT = 0x8031005Fu32 as HRESULT; pub const FVE_E_POLICY_STARTUP_PIN_NOT_ALLOWED: HRESULT = 0x80310060u32 as HRESULT; pub const FVE_E_POLICY_STARTUP_PIN_REQUIRED: HRESULT = 0x80310061u32 as HRESULT; pub const FVE_E_POLICY_STARTUP_KEY_NOT_ALLOWED: HRESULT = 0x80310062u32 as HRESULT; pub const FVE_E_POLICY_STARTUP_KEY_REQUIRED: HRESULT = 0x80310063u32 as HRESULT; pub const FVE_E_POLICY_STARTUP_PIN_KEY_NOT_ALLOWED: HRESULT = 0x80310064u32 as HRESULT; pub const FVE_E_POLICY_STARTUP_PIN_KEY_REQUIRED: HRESULT = 0x80310065u32 as HRESULT; pub const FVE_E_POLICY_STARTUP_TPM_NOT_ALLOWED: HRESULT = 0x80310066u32 as HRESULT; pub const FVE_E_POLICY_STARTUP_TPM_REQUIRED: HRESULT = 0x80310067u32 as HRESULT; pub const FVE_E_POLICY_INVALID_PIN_LENGTH: HRESULT = 0x80310068u32 as HRESULT; pub const FVE_E_KEY_PROTECTOR_NOT_SUPPORTED: HRESULT = 0x80310069u32 as HRESULT; pub const FVE_E_POLICY_PASSPHRASE_NOT_ALLOWED: HRESULT = 0x8031006Au32 as HRESULT; pub const FVE_E_POLICY_PASSPHRASE_REQUIRED: HRESULT = 0x8031006Bu32 as HRESULT; pub const FVE_E_FIPS_PREVENTS_PASSPHRASE: HRESULT = 0x8031006Cu32 as HRESULT; pub const FVE_E_OS_VOLUME_PASSPHRASE_NOT_ALLOWED: HRESULT = 0x8031006Du32 as HRESULT; pub const FVE_E_INVALID_BITLOCKER_OID: HRESULT = 0x8031006Eu32 as HRESULT; pub const FVE_E_VOLUME_TOO_SMALL: HRESULT = 0x8031006Fu32 as HRESULT; pub const FVE_E_DV_NOT_SUPPORTED_ON_FS: HRESULT = 0x80310070u32 as HRESULT; pub const FVE_E_DV_NOT_ALLOWED_BY_GP: HRESULT = 0x80310071u32 as HRESULT; pub const FVE_E_POLICY_USER_CERTIFICATE_NOT_ALLOWED: HRESULT = 0x80310072u32 as HRESULT; pub const FVE_E_POLICY_USER_CERTIFICATE_REQUIRED: HRESULT = 0x80310073u32 as HRESULT; pub const FVE_E_POLICY_USER_CERT_MUST_BE_HW: HRESULT = 0x80310074u32 as HRESULT; pub const FVE_E_POLICY_USER_CONFIGURE_FDV_AUTOUNLOCK_NOT_ALLOWED: HRESULT = 0x80310075u32 as HRESULT; pub const FVE_E_POLICY_USER_CONFIGURE_RDV_AUTOUNLOCK_NOT_ALLOWED: HRESULT = 0x80310076u32 as HRESULT; pub const FVE_E_POLICY_USER_CONFIGURE_RDV_NOT_ALLOWED: HRESULT = 0x80310077u32 as HRESULT; pub const FVE_E_POLICY_USER_ENABLE_RDV_NOT_ALLOWED: HRESULT = 0x80310078u32 as HRESULT; pub const FVE_E_POLICY_USER_DISABLE_RDV_NOT_ALLOWED: HRESULT = 0x80310079u32 as HRESULT; pub const FVE_E_POLICY_INVALID_PASSPHRASE_LENGTH: HRESULT = 0x80310080u32 as HRESULT; pub const FVE_E_POLICY_PASSPHRASE_TOO_SIMPLE: HRESULT = 0x80310081u32 as HRESULT; pub const FVE_E_RECOVERY_PARTITION: HRESULT = 0x80310082u32 as HRESULT; pub const FVE_E_POLICY_CONFLICT_FDV_RK_OFF_AUK_ON: HRESULT = 0x80310083u32 as HRESULT; pub const FVE_E_POLICY_CONFLICT_RDV_RK_OFF_AUK_ON: HRESULT = 0x80310084u32 as HRESULT; pub const FVE_E_NON_BITLOCKER_OID: HRESULT = 0x80310085u32 as HRESULT; pub const FVE_E_POLICY_PROHIBITS_SELFSIGNED: HRESULT = 0x80310086u32 as HRESULT; pub const FVE_E_POLICY_CONFLICT_RO_AND_STARTUP_KEY_REQUIRED: HRESULT = 0x80310087u32 as HRESULT; pub const FVE_E_CONV_RECOVERY_FAILED: HRESULT = 0x80310088u32 as HRESULT; pub const FVE_E_VIRTUALIZED_SPACE_TOO_BIG: HRESULT = 0x80310089u32 as HRESULT; pub const FVE_E_POLICY_CONFLICT_OSV_RP_OFF_ADB_ON: HRESULT = 0x80310090u32 as HRESULT; pub const FVE_E_POLICY_CONFLICT_FDV_RP_OFF_ADB_ON: HRESULT = 0x80310091u32 as HRESULT; pub const FVE_E_POLICY_CONFLICT_RDV_RP_OFF_ADB_ON: HRESULT = 0x80310092u32 as HRESULT; pub const FVE_E_NON_BITLOCKER_KU: HRESULT = 0x80310093u32 as HRESULT; pub const FVE_E_PRIVATEKEY_AUTH_FAILED: HRESULT = 0x80310094u32 as HRESULT; pub const FVE_E_REMOVAL_OF_DRA_FAILED: HRESULT = 0x80310095u32 as HRESULT; pub const FVE_E_OPERATION_NOT_SUPPORTED_ON_VISTA_VOLUME: HRESULT = 0x80310096u32 as HRESULT; pub const FVE_E_CANT_LOCK_AUTOUNLOCK_ENABLED_VOLUME: HRESULT = 0x80310097u32 as HRESULT; pub const FVE_E_FIPS_HASH_KDF_NOT_ALLOWED: HRESULT = 0x80310098u32 as HRESULT; pub const FVE_E_ENH_PIN_INVALID: HRESULT = 0x80310099u32 as HRESULT; pub const FVE_E_INVALID_PIN_CHARS: HRESULT = 0x8031009Au32 as HRESULT; pub const FVE_E_INVALID_DATUM_TYPE: HRESULT = 0x8031009Bu32 as HRESULT; pub const FVE_E_EFI_ONLY: HRESULT = 0x8031009Cu32 as HRESULT; pub const FVE_E_MULTIPLE_NKP_CERTS: HRESULT = 0x8031009Du32 as HRESULT; pub const FVE_E_REMOVAL_OF_NKP_FAILED: HRESULT = 0x8031009Eu32 as HRESULT; pub const FVE_E_INVALID_NKP_CERT: HRESULT = 0x8031009Fu32 as HRESULT; pub const FVE_E_NO_EXISTING_PIN: HRESULT = 0x803100A0u32 as HRESULT; pub const FVE_E_PROTECTOR_CHANGE_PIN_MISMATCH: HRESULT = 0x803100A1u32 as HRESULT; pub const FVE_E_PIN_PROTECTOR_CHANGE_BY_STD_USER_DISALLOWED: HRESULT = 0x803100A2u32 as HRESULT; pub const FVE_E_PROTECTOR_CHANGE_MAX_PIN_CHANGE_ATTEMPTS_REACHED: HRESULT = 0x803100A3u32 as HRESULT; pub const FVE_E_POLICY_PASSPHRASE_REQUIRES_ASCII: HRESULT = 0x803100A4u32 as HRESULT; pub const FVE_E_FULL_ENCRYPTION_NOT_ALLOWED_ON_TP_STORAGE: HRESULT = 0x803100A5u32 as HRESULT; pub const FVE_E_WIPE_NOT_ALLOWED_ON_TP_STORAGE: HRESULT = 0x803100A6u32 as HRESULT; pub const FVE_E_KEY_LENGTH_NOT_SUPPORTED_BY_EDRIVE: HRESULT = 0x803100A7u32 as HRESULT; pub const FVE_E_NO_EXISTING_PASSPHRASE: HRESULT = 0x803100A8u32 as HRESULT; pub const FVE_E_PROTECTOR_CHANGE_PASSPHRASE_MISMATCH: HRESULT = 0x803100A9u32 as HRESULT; pub const FVE_E_PASSPHRASE_TOO_LONG: HRESULT = 0x803100AAu32 as HRESULT; pub const FVE_E_NO_PASSPHRASE_WITH_TPM: HRESULT = 0x803100ABu32 as HRESULT; pub const FVE_E_NO_TPM_WITH_PASSPHRASE: HRESULT = 0x803100ACu32 as HRESULT; pub const FVE_E_NOT_ALLOWED_ON_CSV_STACK: HRESULT = 0x803100ADu32 as HRESULT; pub const FVE_E_NOT_ALLOWED_ON_CLUSTER: HRESULT = 0x803100AEu32 as HRESULT; pub const FVE_E_EDRIVE_NO_FAILOVER_TO_SW: HRESULT = 0x803100AFu32 as HRESULT; pub const FVE_E_EDRIVE_BAND_IN_USE: HRESULT = 0x803100B0u32 as HRESULT; pub const FVE_E_EDRIVE_DISALLOWED_BY_GP: HRESULT = 0x803100B1u32 as HRESULT; pub const FVE_E_EDRIVE_INCOMPATIBLE_VOLUME: HRESULT = 0x803100B2u32 as HRESULT; pub const FVE_E_NOT_ALLOWED_TO_UPGRADE_WHILE_CONVERTING: HRESULT = 0x803100B3u32 as HRESULT; pub const FVE_E_EDRIVE_DV_NOT_SUPPORTED: HRESULT = 0x803100B4u32 as HRESULT; pub const FVE_E_NO_PREBOOT_KEYBOARD_DETECTED: HRESULT = 0x803100B5u32 as HRESULT; pub const FVE_E_NO_PREBOOT_KEYBOARD_OR_WINRE_DETECTED: HRESULT = 0x803100B6u32 as HRESULT; pub const FVE_E_POLICY_REQUIRES_STARTUP_PIN_ON_TOUCH_DEVICE: HRESULT = 0x803100B7u32 as HRESULT; pub const FVE_E_POLICY_REQUIRES_RECOVERY_PASSWORD_ON_TOUCH_DEVICE: HRESULT = 0x803100B8u32 as HRESULT; pub const FVE_E_WIPE_CANCEL_NOT_APPLICABLE: HRESULT = 0x803100B9u32 as HRESULT; pub const FVE_E_SECUREBOOT_DISABLED: HRESULT = 0x803100BAu32 as HRESULT; pub const FVE_E_SECUREBOOT_CONFIGURATION_INVALID: HRESULT = 0x803100BBu32 as HRESULT; pub const FVE_E_EDRIVE_DRY_RUN_FAILED: HRESULT = 0x803100BCu32 as HRESULT; pub const FVE_E_SHADOW_COPY_PRESENT: HRESULT = 0x803100BDu32 as HRESULT; pub const FVE_E_POLICY_INVALID_ENHANCED_BCD_SETTINGS: HRESULT = 0x803100BEu32 as HRESULT; pub const FVE_E_EDRIVE_INCOMPATIBLE_FIRMWARE: HRESULT = 0x803100BFu32 as HRESULT; pub const FVE_E_PROTECTOR_CHANGE_MAX_PASSPHRASE_CHANGE_ATTEMPTS_REACHED: HRESULT = 0x803100C0u32 as HRESULT; pub const FVE_E_PASSPHRASE_PROTECTOR_CHANGE_BY_STD_USER_DISALLOWED: HRESULT = 0x803100C1u32 as HRESULT; pub const FVE_E_LIVEID_ACCOUNT_SUSPENDED: HRESULT = 0x803100C2u32 as HRESULT; pub const FVE_E_LIVEID_ACCOUNT_BLOCKED: HRESULT = 0x803100C3u32 as HRESULT; pub const FVE_E_NOT_PROVISIONED_ON_ALL_VOLUMES: HRESULT = 0x803100C4u32 as HRESULT; pub const FVE_E_DE_FIXED_DATA_NOT_SUPPORTED: HRESULT = 0x803100C5u32 as HRESULT; pub const FVE_E_DE_HARDWARE_NOT_COMPLIANT: HRESULT = 0x803100C6u32 as HRESULT; pub const FVE_E_DE_WINRE_NOT_CONFIGURED: HRESULT = 0x803100C7u32 as HRESULT; pub const FVE_E_DE_PROTECTION_SUSPENDED: HRESULT = 0x803100C8u32 as HRESULT; pub const FVE_E_DE_OS_VOLUME_NOT_PROTECTED: HRESULT = 0x803100C9u32 as HRESULT; pub const FVE_E_DE_DEVICE_LOCKEDOUT: HRESULT = 0x803100CAu32 as HRESULT; pub const FVE_E_DE_PROTECTION_NOT_YET_ENABLED: HRESULT = 0x803100CBu32 as HRESULT; pub const FVE_E_INVALID_PIN_CHARS_DETAILED: HRESULT = 0x803100CCu32 as HRESULT; pub const FVE_E_DEVICE_LOCKOUT_COUNTER_UNAVAILABLE: HRESULT = 0x803100CDu32 as HRESULT; pub const FVE_E_DEVICELOCKOUT_COUNTER_MISMATCH: HRESULT = 0x803100CEu32 as HRESULT; pub const FVE_E_BUFFER_TOO_LARGE: HRESULT = 0x803100CFu32 as HRESULT; pub const FVE_E_NO_SUCH_CAPABILITY_ON_TARGET: HRESULT = 0x803100D0u32 as HRESULT; pub const FVE_E_DE_PREVENTED_FOR_OS: HRESULT = 0x803100D1u32 as HRESULT; pub const FVE_E_DE_VOLUME_OPTED_OUT: HRESULT = 0x803100D2u32 as HRESULT; pub const FVE_E_DE_VOLUME_NOT_SUPPORTED: HRESULT = 0x803100D3u32 as HRESULT; pub const FVE_E_EOW_NOT_SUPPORTED_IN_VERSION: HRESULT = 0x803100D4u32 as HRESULT; pub const FVE_E_ADBACKUP_NOT_ENABLED: HRESULT = 0x803100D5u32 as HRESULT; pub const FVE_E_VOLUME_EXTEND_PREVENTS_EOW_DECRYPT: HRESULT = 0x803100D6u32 as HRESULT; pub const FVE_E_NOT_DE_VOLUME: HRESULT = 0x803100D7u32 as HRESULT; pub const FVE_E_PROTECTION_CANNOT_BE_DISABLED: HRESULT = 0x803100D8u32 as HRESULT; pub const FWP_E_CALLOUT_NOT_FOUND: HRESULT = 0x80320001u32 as HRESULT; pub const FWP_E_CONDITION_NOT_FOUND: HRESULT = 0x80320002u32 as HRESULT; pub const FWP_E_FILTER_NOT_FOUND: HRESULT = 0x80320003u32 as HRESULT; pub const FWP_E_LAYER_NOT_FOUND: HRESULT = 0x80320004u32 as HRESULT; pub const FWP_E_PROVIDER_NOT_FOUND: HRESULT = 0x80320005u32 as HRESULT; pub const FWP_E_PROVIDER_CONTEXT_NOT_FOUND: HRESULT = 0x80320006u32 as HRESULT; pub const FWP_E_SUBLAYER_NOT_FOUND: HRESULT = 0x80320007u32 as HRESULT; pub const FWP_E_NOT_FOUND: HRESULT = 0x80320008u32 as HRESULT; pub const FWP_E_ALREADY_EXISTS: HRESULT = 0x80320009u32 as HRESULT; pub const FWP_E_IN_USE: HRESULT = 0x8032000Au32 as HRESULT; pub const FWP_E_DYNAMIC_SESSION_IN_PROGRESS: HRESULT = 0x8032000Bu32 as HRESULT; pub const FWP_E_WRONG_SESSION: HRESULT = 0x8032000Cu32 as HRESULT; pub const FWP_E_NO_TXN_IN_PROGRESS: HRESULT = 0x8032000Du32 as HRESULT; pub const FWP_E_TXN_IN_PROGRESS: HRESULT = 0x8032000Eu32 as HRESULT; pub const FWP_E_TXN_ABORTED: HRESULT = 0x8032000Fu32 as HRESULT; pub const FWP_E_SESSION_ABORTED: HRESULT = 0x80320010u32 as HRESULT; pub const FWP_E_INCOMPATIBLE_TXN: HRESULT = 0x80320011u32 as HRESULT; pub const FWP_E_TIMEOUT: HRESULT = 0x80320012u32 as HRESULT; pub const FWP_E_NET_EVENTS_DISABLED: HRESULT = 0x80320013u32 as HRESULT; pub const FWP_E_INCOMPATIBLE_LAYER: HRESULT = 0x80320014u32 as HRESULT; pub const FWP_E_KM_CLIENTS_ONLY: HRESULT = 0x80320015u32 as HRESULT; pub const FWP_E_LIFETIME_MISMATCH: HRESULT = 0x80320016u32 as HRESULT; pub const FWP_E_BUILTIN_OBJECT: HRESULT = 0x80320017u32 as HRESULT; pub const FWP_E_TOO_MANY_CALLOUTS: HRESULT = 0x80320018u32 as HRESULT; pub const FWP_E_NOTIFICATION_DROPPED: HRESULT = 0x80320019u32 as HRESULT; pub const FWP_E_TRAFFIC_MISMATCH: HRESULT = 0x8032001Au32 as HRESULT; pub const FWP_E_INCOMPATIBLE_SA_STATE: HRESULT = 0x8032001Bu32 as HRESULT; pub const FWP_E_NULL_POINTER: HRESULT = 0x8032001Cu32 as HRESULT; pub const FWP_E_INVALID_ENUMERATOR: HRESULT = 0x8032001Du32 as HRESULT; pub const FWP_E_INVALID_FLAGS: HRESULT = 0x8032001Eu32 as HRESULT; pub const FWP_E_INVALID_NET_MASK: HRESULT = 0x8032001Fu32 as HRESULT; pub const FWP_E_INVALID_RANGE: HRESULT = 0x80320020u32 as HRESULT; pub const FWP_E_INVALID_INTERVAL: HRESULT = 0x80320021u32 as HRESULT; pub const FWP_E_ZERO_LENGTH_ARRAY: HRESULT = 0x80320022u32 as HRESULT; pub const FWP_E_NULL_DISPLAY_NAME: HRESULT = 0x80320023u32 as HRESULT; pub const FWP_E_INVALID_ACTION_TYPE: HRESULT = 0x80320024u32 as HRESULT; pub const FWP_E_INVALID_WEIGHT: HRESULT = 0x80320025u32 as HRESULT; pub const FWP_E_MATCH_TYPE_MISMATCH: HRESULT = 0x80320026u32 as HRESULT; pub const FWP_E_TYPE_MISMATCH: HRESULT = 0x80320027u32 as HRESULT; pub const FWP_E_OUT_OF_BOUNDS: HRESULT = 0x80320028u32 as HRESULT; pub const FWP_E_RESERVED: HRESULT = 0x80320029u32 as HRESULT; pub const FWP_E_DUPLICATE_CONDITION: HRESULT = 0x8032002Au32 as HRESULT; pub const FWP_E_DUPLICATE_KEYMOD: HRESULT = 0x8032002Bu32 as HRESULT; pub const FWP_E_ACTION_INCOMPATIBLE_WITH_LAYER: HRESULT = 0x8032002Cu32 as HRESULT; pub const FWP_E_ACTION_INCOMPATIBLE_WITH_SUBLAYER: HRESULT = 0x8032002Du32 as HRESULT; pub const FWP_E_CONTEXT_INCOMPATIBLE_WITH_LAYER: HRESULT = 0x8032002Eu32 as HRESULT; pub const FWP_E_CONTEXT_INCOMPATIBLE_WITH_CALLOUT: HRESULT = 0x8032002Fu32 as HRESULT; pub const FWP_E_INCOMPATIBLE_AUTH_METHOD: HRESULT = 0x80320030u32 as HRESULT; pub const FWP_E_INCOMPATIBLE_DH_GROUP: HRESULT = 0x80320031u32 as HRESULT; pub const FWP_E_EM_NOT_SUPPORTED: HRESULT = 0x80320032u32 as HRESULT; pub const FWP_E_NEVER_MATCH: HRESULT = 0x80320033u32 as HRESULT; pub const FWP_E_PROVIDER_CONTEXT_MISMATCH: HRESULT = 0x80320034u32 as HRESULT; pub const FWP_E_INVALID_PARAMETER: HRESULT = 0x80320035u32 as HRESULT; pub const FWP_E_TOO_MANY_SUBLAYERS: HRESULT = 0x80320036u32 as HRESULT; pub const FWP_E_CALLOUT_NOTIFICATION_FAILED: HRESULT = 0x80320037u32 as HRESULT; pub const FWP_E_INVALID_AUTH_TRANSFORM: HRESULT = 0x80320038u32 as HRESULT; pub const FWP_E_INVALID_CIPHER_TRANSFORM: HRESULT = 0x80320039u32 as HRESULT; pub const FWP_E_INCOMPATIBLE_CIPHER_TRANSFORM: HRESULT = 0x8032003Au32 as HRESULT; pub const FWP_E_INVALID_TRANSFORM_COMBINATION: HRESULT = 0x8032003Bu32 as HRESULT; pub const FWP_E_DUPLICATE_AUTH_METHOD: HRESULT = 0x8032003Cu32 as HRESULT; pub const FWP_E_INVALID_TUNNEL_ENDPOINT: HRESULT = 0x8032003Du32 as HRESULT; pub const FWP_E_L2_DRIVER_NOT_READY: HRESULT = 0x8032003Eu32 as HRESULT; pub const FWP_E_KEY_DICTATOR_ALREADY_REGISTERED: HRESULT = 0x8032003Fu32 as HRESULT; pub const FWP_E_KEY_DICTATION_INVALID_KEYING_MATERIAL: HRESULT = 0x80320040u32 as HRESULT; pub const FWP_E_CONNECTIONS_DISABLED: HRESULT = 0x80320041u32 as HRESULT; pub const FWP_E_INVALID_DNS_NAME: HRESULT = 0x80320042u32 as HRESULT; pub const FWP_E_STILL_ON: HRESULT = 0x80320043u32 as HRESULT; pub const FWP_E_IKEEXT_NOT_RUNNING: HRESULT = 0x80320044u32 as HRESULT; pub const FWP_E_DROP_NOICMP: HRESULT = 0x80320104u32 as HRESULT; pub const WS_S_ASYNC: HRESULT = 0x003D0000; pub const WS_S_END: HRESULT = 0x003D0001; pub const WS_E_INVALID_FORMAT: HRESULT = 0x803D0000u32 as HRESULT; pub const WS_E_OBJECT_FAULTED: HRESULT = 0x803D0001u32 as HRESULT; pub const WS_E_NUMERIC_OVERFLOW: HRESULT = 0x803D0002u32 as HRESULT; pub const WS_E_INVALID_OPERATION: HRESULT = 0x803D0003u32 as HRESULT; pub const WS_E_OPERATION_ABORTED: HRESULT = 0x803D0004u32 as HRESULT; pub const WS_E_ENDPOINT_ACCESS_DENIED: HRESULT = 0x803D0005u32 as HRESULT; pub const WS_E_OPERATION_TIMED_OUT: HRESULT = 0x803D0006u32 as HRESULT; pub const WS_E_OPERATION_ABANDONED: HRESULT = 0x803D0007u32 as HRESULT; pub const WS_E_QUOTA_EXCEEDED: HRESULT = 0x803D0008u32 as HRESULT; pub const WS_E_NO_TRANSLATION_AVAILABLE: HRESULT = 0x803D0009u32 as HRESULT; pub const WS_E_SECURITY_VERIFICATION_FAILURE: HRESULT = 0x803D000Au32 as HRESULT; pub const WS_E_ADDRESS_IN_USE: HRESULT = 0x803D000Bu32 as HRESULT; pub const WS_E_ADDRESS_NOT_AVAILABLE: HRESULT = 0x803D000Cu32 as HRESULT; pub const WS_E_ENDPOINT_NOT_FOUND: HRESULT = 0x803D000Du32 as HRESULT; pub const WS_E_ENDPOINT_NOT_AVAILABLE: HRESULT = 0x803D000Eu32 as HRESULT; pub const WS_E_ENDPOINT_FAILURE: HRESULT = 0x803D000Fu32 as HRESULT; pub const WS_E_ENDPOINT_UNREACHABLE: HRESULT = 0x803D0010u32 as HRESULT; pub const WS_E_ENDPOINT_ACTION_NOT_SUPPORTED: HRESULT = 0x803D0011u32 as HRESULT; pub const WS_E_ENDPOINT_TOO_BUSY: HRESULT = 0x803D0012u32 as HRESULT; pub const WS_E_ENDPOINT_FAULT_RECEIVED: HRESULT = 0x803D0013u32 as HRESULT; pub const WS_E_ENDPOINT_DISCONNECTED: HRESULT = 0x803D0014u32 as HRESULT; pub const WS_E_PROXY_FAILURE: HRESULT = 0x803D0015u32 as HRESULT; pub const WS_E_PROXY_ACCESS_DENIED: HRESULT = 0x803D0016u32 as HRESULT; pub const WS_E_NOT_SUPPORTED: HRESULT = 0x803D0017u32 as HRESULT; pub const WS_E_PROXY_REQUIRES_BASIC_AUTH: HRESULT = 0x803D0018u32 as HRESULT; pub const WS_E_PROXY_REQUIRES_DIGEST_AUTH: HRESULT = 0x803D0019u32 as HRESULT; pub const WS_E_PROXY_REQUIRES_NTLM_AUTH: HRESULT = 0x803D001Au32 as HRESULT; pub const WS_E_PROXY_REQUIRES_NEGOTIATE_AUTH: HRESULT = 0x803D001Bu32 as HRESULT; pub const WS_E_SERVER_REQUIRES_BASIC_AUTH: HRESULT = 0x803D001Cu32 as HRESULT; pub const WS_E_SERVER_REQUIRES_DIGEST_AUTH: HRESULT = 0x803D001Du32 as HRESULT; pub const WS_E_SERVER_REQUIRES_NTLM_AUTH: HRESULT = 0x803D001Eu32 as HRESULT; pub const WS_E_SERVER_REQUIRES_NEGOTIATE_AUTH: HRESULT = 0x803D001Fu32 as HRESULT; pub const WS_E_INVALID_ENDPOINT_URL: HRESULT = 0x803D0020u32 as HRESULT; pub const WS_E_OTHER: HRESULT = 0x803D0021u32 as HRESULT; pub const WS_E_SECURITY_TOKEN_EXPIRED: HRESULT = 0x803D0022u32 as HRESULT; pub const WS_E_SECURITY_SYSTEM_FAILURE: HRESULT = 0x803D0023u32 as HRESULT; pub const ERROR_NDIS_INTERFACE_CLOSING: HRESULT = 0x80340002u32 as HRESULT; pub const ERROR_NDIS_BAD_VERSION: HRESULT = 0x80340004u32 as HRESULT; pub const ERROR_NDIS_BAD_CHARACTERISTICS: HRESULT = 0x80340005u32 as HRESULT; pub const ERROR_NDIS_ADAPTER_NOT_FOUND: HRESULT = 0x80340006u32 as HRESULT; pub const ERROR_NDIS_OPEN_FAILED: HRESULT = 0x80340007u32 as HRESULT; pub const ERROR_NDIS_DEVICE_FAILED: HRESULT = 0x80340008u32 as HRESULT; pub const ERROR_NDIS_MULTICAST_FULL: HRESULT = 0x80340009u32 as HRESULT; pub const ERROR_NDIS_MULTICAST_EXISTS: HRESULT = 0x8034000Au32 as HRESULT; pub const ERROR_NDIS_MULTICAST_NOT_FOUND: HRESULT = 0x8034000Bu32 as HRESULT; pub const ERROR_NDIS_REQUEST_ABORTED: HRESULT = 0x8034000Cu32 as HRESULT; pub const ERROR_NDIS_RESET_IN_PROGRESS: HRESULT = 0x8034000Du32 as HRESULT; pub const ERROR_NDIS_NOT_SUPPORTED: HRESULT = 0x803400BBu32 as HRESULT; pub const ERROR_NDIS_INVALID_PACKET: HRESULT = 0x8034000Fu32 as HRESULT; pub const ERROR_NDIS_ADAPTER_NOT_READY: HRESULT = 0x80340011u32 as HRESULT; pub const ERROR_NDIS_INVALID_LENGTH: HRESULT = 0x80340014u32 as HRESULT; pub const ERROR_NDIS_INVALID_DATA: HRESULT = 0x80340015u32 as HRESULT; pub const ERROR_NDIS_BUFFER_TOO_SHORT: HRESULT = 0x80340016u32 as HRESULT; pub const ERROR_NDIS_INVALID_OID: HRESULT = 0x80340017u32 as HRESULT; pub const ERROR_NDIS_ADAPTER_REMOVED: HRESULT = 0x80340018u32 as HRESULT; pub const ERROR_NDIS_UNSUPPORTED_MEDIA: HRESULT = 0x80340019u32 as HRESULT; pub const ERROR_NDIS_GROUP_ADDRESS_IN_USE: HRESULT = 0x8034001Au32 as HRESULT; pub const ERROR_NDIS_FILE_NOT_FOUND: HRESULT = 0x8034001Bu32 as HRESULT; pub const ERROR_NDIS_ERROR_READING_FILE: HRESULT = 0x8034001Cu32 as HRESULT; pub const ERROR_NDIS_ALREADY_MAPPED: HRESULT = 0x8034001Du32 as HRESULT; pub const ERROR_NDIS_RESOURCE_CONFLICT: HRESULT = 0x8034001Eu32 as HRESULT; pub const ERROR_NDIS_MEDIA_DISCONNECTED: HRESULT = 0x8034001Fu32 as HRESULT; pub const ERROR_NDIS_INVALID_ADDRESS: HRESULT = 0x80340022u32 as HRESULT; pub const ERROR_NDIS_INVALID_DEVICE_REQUEST: HRESULT = 0x80340010u32 as HRESULT; pub const ERROR_NDIS_PAUSED: HRESULT = 0x8034002Au32 as HRESULT; pub const ERROR_NDIS_INTERFACE_NOT_FOUND: HRESULT = 0x8034002Bu32 as HRESULT; pub const ERROR_NDIS_UNSUPPORTED_REVISION: HRESULT = 0x8034002Cu32 as HRESULT; pub const ERROR_NDIS_INVALID_PORT: HRESULT = 0x8034002Du32 as HRESULT; pub const ERROR_NDIS_INVALID_PORT_STATE: HRESULT = 0x8034002Eu32 as HRESULT; pub const ERROR_NDIS_LOW_POWER_STATE: HRESULT = 0x8034002Fu32 as HRESULT; pub const ERROR_NDIS_REINIT_REQUIRED: HRESULT = 0x80340030u32 as HRESULT; pub const ERROR_NDIS_DOT11_AUTO_CONFIG_ENABLED: HRESULT = 0x80342000u32 as HRESULT; pub const ERROR_NDIS_DOT11_MEDIA_IN_USE: HRESULT = 0x80342001u32 as HRESULT; pub const ERROR_NDIS_DOT11_POWER_STATE_INVALID: HRESULT = 0x80342002u32 as HRESULT; pub const ERROR_NDIS_PM_WOL_PATTERN_LIST_FULL: HRESULT = 0x80342003u32 as HRESULT; pub const ERROR_NDIS_PM_PROTOCOL_OFFLOAD_LIST_FULL: HRESULT = 0x80342004u32 as HRESULT; pub const ERROR_NDIS_INDICATION_REQUIRED: HRESULT = 0x00340001; pub const ERROR_NDIS_OFFLOAD_POLICY: HRESULT = 0xC034100Fu32 as HRESULT; pub const ERROR_NDIS_OFFLOAD_CONNECTION_REJECTED: HRESULT = 0xC0341012u32 as HRESULT; pub const ERROR_NDIS_OFFLOAD_PATH_REJECTED: HRESULT = 0xC0341013u32 as HRESULT; pub const ERROR_HV_INVALID_HYPERCALL_CODE: HRESULT = 0xC0350002u32 as HRESULT; pub const ERROR_HV_INVALID_HYPERCALL_INPUT: HRESULT = 0xC0350003u32 as HRESULT; pub const ERROR_HV_INVALID_ALIGNMENT: HRESULT = 0xC0350004u32 as HRESULT; pub const ERROR_HV_INVALID_PARAMETER: HRESULT = 0xC0350005u32 as HRESULT; pub const ERROR_HV_ACCESS_DENIED: HRESULT = 0xC0350006u32 as HRESULT; pub const ERROR_HV_INVALID_PARTITION_STATE: HRESULT = 0xC0350007u32 as HRESULT; pub const ERROR_HV_OPERATION_DENIED: HRESULT = 0xC0350008u32 as HRESULT; pub const ERROR_HV_UNKNOWN_PROPERTY: HRESULT = 0xC0350009u32 as HRESULT; pub const ERROR_HV_PROPERTY_VALUE_OUT_OF_RANGE: HRESULT = 0xC035000Au32 as HRESULT; pub const ERROR_HV_INSUFFICIENT_MEMORY: HRESULT = 0xC035000Bu32 as HRESULT; pub const ERROR_HV_PARTITION_TOO_DEEP: HRESULT = 0xC035000Cu32 as HRESULT; pub const ERROR_HV_INVALID_PARTITION_ID: HRESULT = 0xC035000Du32 as HRESULT; pub const ERROR_HV_INVALID_VP_INDEX: HRESULT = 0xC035000Eu32 as HRESULT; pub const ERROR_HV_INVALID_PORT_ID: HRESULT = 0xC0350011u32 as HRESULT; pub const ERROR_HV_INVALID_CONNECTION_ID: HRESULT = 0xC0350012u32 as HRESULT; pub const ERROR_HV_INSUFFICIENT_BUFFERS: HRESULT = 0xC0350013u32 as HRESULT; pub const ERROR_HV_NOT_ACKNOWLEDGED: HRESULT = 0xC0350014u32 as HRESULT; pub const ERROR_HV_ACKNOWLEDGED: HRESULT = 0xC0350016u32 as HRESULT; pub const ERROR_HV_INVALID_SAVE_RESTORE_STATE: HRESULT = 0xC0350017u32 as HRESULT; pub const ERROR_HV_INVALID_SYNIC_STATE: HRESULT = 0xC0350018u32 as HRESULT; pub const ERROR_HV_OBJECT_IN_USE: HRESULT = 0xC0350019u32 as HRESULT; pub const ERROR_HV_INVALID_PROXIMITY_DOMAIN_INFO: HRESULT = 0xC035001Au32 as HRESULT; pub const ERROR_HV_NO_DATA: HRESULT = 0xC035001Bu32 as HRESULT; pub const ERROR_HV_INACTIVE: HRESULT = 0xC035001Cu32 as HRESULT; pub const ERROR_HV_NO_RESOURCES: HRESULT = 0xC035001Du32 as HRESULT; pub const ERROR_HV_FEATURE_UNAVAILABLE: HRESULT = 0xC035001Eu32 as HRESULT; pub const ERROR_HV_INSUFFICIENT_BUFFER: HRESULT = 0xC0350033u32 as HRESULT; pub const ERROR_HV_INSUFFICIENT_DEVICE_DOMAINS: HRESULT = 0xC0350038u32 as HRESULT; pub const ERROR_HV_INVALID_LP_INDEX: HRESULT = 0xC0350041u32 as HRESULT; pub const ERROR_HV_NOT_PRESENT: HRESULT = 0xC0351000u32 as HRESULT; pub const ERROR_VID_DUPLICATE_HANDLER: HRESULT = 0xC0370001u32 as HRESULT; pub const ERROR_VID_TOO_MANY_HANDLERS: HRESULT = 0xC0370002u32 as HRESULT; pub const ERROR_VID_QUEUE_FULL: HRESULT = 0xC0370003u32 as HRESULT; pub const ERROR_VID_HANDLER_NOT_PRESENT: HRESULT = 0xC0370004u32 as HRESULT; pub const ERROR_VID_INVALID_OBJECT_NAME: HRESULT = 0xC0370005u32 as HRESULT; pub const ERROR_VID_PARTITION_NAME_TOO_LONG: HRESULT = 0xC0370006u32 as HRESULT; pub const ERROR_VID_MESSAGE_QUEUE_NAME_TOO_LONG: HRESULT = 0xC0370007u32 as HRESULT; pub const ERROR_VID_PARTITION_ALREADY_EXISTS: HRESULT = 0xC0370008u32 as HRESULT; pub const ERROR_VID_PARTITION_DOES_NOT_EXIST: HRESULT = 0xC0370009u32 as HRESULT; pub const ERROR_VID_PARTITION_NAME_NOT_FOUND: HRESULT = 0xC037000Au32 as HRESULT; pub const ERROR_VID_MESSAGE_QUEUE_ALREADY_EXISTS: HRESULT = 0xC037000Bu32 as HRESULT; pub const ERROR_VID_EXCEEDED_MBP_ENTRY_MAP_LIMIT: HRESULT = 0xC037000Cu32 as HRESULT; pub const ERROR_VID_MB_STILL_REFERENCED: HRESULT = 0xC037000Du32 as HRESULT; pub const ERROR_VID_CHILD_GPA_PAGE_SET_CORRUPTED: HRESULT = 0xC037000Eu32 as HRESULT; pub const ERROR_VID_INVALID_NUMA_SETTINGS: HRESULT = 0xC037000Fu32 as HRESULT; pub const ERROR_VID_INVALID_NUMA_NODE_INDEX: HRESULT = 0xC0370010u32 as HRESULT; pub const ERROR_VID_NOTIFICATION_QUEUE_ALREADY_ASSOCIATED: HRESULT = 0xC0370011u32 as HRESULT; pub const ERROR_VID_INVALID_MEMORY_BLOCK_HANDLE: HRESULT = 0xC0370012u32 as HRESULT; pub const ERROR_VID_PAGE_RANGE_OVERFLOW: HRESULT = 0xC0370013u32 as HRESULT; pub const ERROR_VID_INVALID_MESSAGE_QUEUE_HANDLE: HRESULT = 0xC0370014u32 as HRESULT; pub const ERROR_VID_INVALID_GPA_RANGE_HANDLE: HRESULT = 0xC0370015u32 as HRESULT; pub const ERROR_VID_NO_MEMORY_BLOCK_NOTIFICATION_QUEUE: HRESULT = 0xC0370016u32 as HRESULT; pub const ERROR_VID_MEMORY_BLOCK_LOCK_COUNT_EXCEEDED: HRESULT = 0xC0370017u32 as HRESULT; pub const ERROR_VID_INVALID_PPM_HANDLE: HRESULT = 0xC0370018u32 as HRESULT; pub const ERROR_VID_MBPS_ARE_LOCKED: HRESULT = 0xC0370019u32 as HRESULT; pub const ERROR_VID_MESSAGE_QUEUE_CLOSED: HRESULT = 0xC037001Au32 as HRESULT; pub const ERROR_VID_VIRTUAL_PROCESSOR_LIMIT_EXCEEDED: HRESULT = 0xC037001Bu32 as HRESULT; pub const ERROR_VID_STOP_PENDING: HRESULT = 0xC037001Cu32 as HRESULT; pub const ERROR_VID_INVALID_PROCESSOR_STATE: HRESULT = 0xC037001Du32 as HRESULT; pub const ERROR_VID_EXCEEDED_KM_CONTEXT_COUNT_LIMIT: HRESULT = 0xC037001Eu32 as HRESULT; pub const ERROR_VID_KM_INTERFACE_ALREADY_INITIALIZED: HRESULT = 0xC037001Fu32 as HRESULT; pub const ERROR_VID_MB_PROPERTY_ALREADY_SET_RESET: HRESULT = 0xC0370020u32 as HRESULT; pub const ERROR_VID_MMIO_RANGE_DESTROYED: HRESULT = 0xC0370021u32 as HRESULT; pub const ERROR_VID_INVALID_CHILD_GPA_PAGE_SET: HRESULT = 0xC0370022u32 as HRESULT; pub const ERROR_VID_RESERVE_PAGE_SET_IS_BEING_USED: HRESULT = 0xC0370023u32 as HRESULT; pub const ERROR_VID_RESERVE_PAGE_SET_TOO_SMALL: HRESULT = 0xC0370024u32 as HRESULT; pub const ERROR_VID_MBP_ALREADY_LOCKED_USING_RESERVED_PAGE: HRESULT = 0xC0370025u32 as HRESULT; pub const ERROR_VID_MBP_COUNT_EXCEEDED_LIMIT: HRESULT = 0xC0370026u32 as HRESULT; pub const ERROR_VID_SAVED_STATE_CORRUPT: HRESULT = 0xC0370027u32 as HRESULT; pub const ERROR_VID_SAVED_STATE_UNRECOGNIZED_ITEM: HRESULT = 0xC0370028u32 as HRESULT; pub const ERROR_VID_SAVED_STATE_INCOMPATIBLE: HRESULT = 0xC0370029u32 as HRESULT; pub const ERROR_VID_REMOTE_NODE_PARENT_GPA_PAGES_USED: HRESULT = 0x80370001u32 as HRESULT; pub const ERROR_VOLMGR_INCOMPLETE_REGENERATION: HRESULT = 0x80380001u32 as HRESULT; pub const ERROR_VOLMGR_INCOMPLETE_DISK_MIGRATION: HRESULT = 0x80380002u32 as HRESULT; pub const ERROR_VOLMGR_DATABASE_FULL: HRESULT = 0xC0380001u32 as HRESULT; pub const ERROR_VOLMGR_DISK_CONFIGURATION_CORRUPTED: HRESULT = 0xC0380002u32 as HRESULT; pub const ERROR_VOLMGR_DISK_CONFIGURATION_NOT_IN_SYNC: HRESULT = 0xC0380003u32 as HRESULT; pub const ERROR_VOLMGR_PACK_CONFIG_UPDATE_FAILED: HRESULT = 0xC0380004u32 as HRESULT; pub const ERROR_VOLMGR_DISK_CONTAINS_NON_SIMPLE_VOLUME: HRESULT = 0xC0380005u32 as HRESULT; pub const ERROR_VOLMGR_DISK_DUPLICATE: HRESULT = 0xC0380006u32 as HRESULT; pub const ERROR_VOLMGR_DISK_DYNAMIC: HRESULT = 0xC0380007u32 as HRESULT; pub const ERROR_VOLMGR_DISK_ID_INVALID: HRESULT = 0xC0380008u32 as HRESULT; pub const ERROR_VOLMGR_DISK_INVALID: HRESULT = 0xC0380009u32 as HRESULT; pub const ERROR_VOLMGR_DISK_LAST_VOTER: HRESULT = 0xC038000Au32 as HRESULT; pub const ERROR_VOLMGR_DISK_LAYOUT_INVALID: HRESULT = 0xC038000Bu32 as HRESULT; pub const ERROR_VOLMGR_DISK_LAYOUT_NON_BASIC_BETWEEN_BASIC_PARTITIONS: HRESULT = 0xC038000Cu32 as HRESULT; pub const ERROR_VOLMGR_DISK_LAYOUT_NOT_CYLINDER_ALIGNED: HRESULT = 0xC038000Du32 as HRESULT; pub const ERROR_VOLMGR_DISK_LAYOUT_PARTITIONS_TOO_SMALL: HRESULT = 0xC038000Eu32 as HRESULT; pub const ERROR_VOLMGR_DISK_LAYOUT_PRIMARY_BETWEEN_LOGICAL_PARTITIONS: HRESULT = 0xC038000Fu32 as HRESULT; pub const ERROR_VOLMGR_DISK_LAYOUT_TOO_MANY_PARTITIONS: HRESULT = 0xC0380010u32 as HRESULT; pub const ERROR_VOLMGR_DISK_MISSING: HRESULT = 0xC0380011u32 as HRESULT; pub const ERROR_VOLMGR_DISK_NOT_EMPTY: HRESULT = 0xC0380012u32 as HRESULT; pub const ERROR_VOLMGR_DISK_NOT_ENOUGH_SPACE: HRESULT = 0xC0380013u32 as HRESULT; pub const ERROR_VOLMGR_DISK_REVECTORING_FAILED: HRESULT = 0xC0380014u32 as HRESULT; pub const ERROR_VOLMGR_DISK_SECTOR_SIZE_INVALID: HRESULT = 0xC0380015u32 as HRESULT; pub const ERROR_VOLMGR_DISK_SET_NOT_CONTAINED: HRESULT = 0xC0380016u32 as HRESULT; pub const ERROR_VOLMGR_DISK_USED_BY_MULTIPLE_MEMBERS: HRESULT = 0xC0380017u32 as HRESULT; pub const ERROR_VOLMGR_DISK_USED_BY_MULTIPLE_PLEXES: HRESULT = 0xC0380018u32 as HRESULT; pub const ERROR_VOLMGR_DYNAMIC_DISK_NOT_SUPPORTED: HRESULT = 0xC0380019u32 as HRESULT; pub const ERROR_VOLMGR_EXTENT_ALREADY_USED: HRESULT = 0xC038001Au32 as HRESULT; pub const ERROR_VOLMGR_EXTENT_NOT_CONTIGUOUS: HRESULT = 0xC038001Bu32 as HRESULT; pub const ERROR_VOLMGR_EXTENT_NOT_IN_PUBLIC_REGION: HRESULT = 0xC038001Cu32 as HRESULT; pub const ERROR_VOLMGR_EXTENT_NOT_SECTOR_ALIGNED: HRESULT = 0xC038001Du32 as HRESULT; pub const ERROR_VOLMGR_EXTENT_OVERLAPS_EBR_PARTITION: HRESULT = 0xC038001Eu32 as HRESULT; pub const ERROR_VOLMGR_EXTENT_VOLUME_LENGTHS_DO_NOT_MATCH: HRESULT = 0xC038001Fu32 as HRESULT; pub const ERROR_VOLMGR_FAULT_TOLERANT_NOT_SUPPORTED: HRESULT = 0xC0380020u32 as HRESULT; pub const ERROR_VOLMGR_INTERLEAVE_LENGTH_INVALID: HRESULT = 0xC0380021u32 as HRESULT; pub const ERROR_VOLMGR_MAXIMUM_REGISTERED_USERS: HRESULT = 0xC0380022u32 as HRESULT; pub const ERROR_VOLMGR_MEMBER_IN_SYNC: HRESULT = 0xC0380023u32 as HRESULT; pub const ERROR_VOLMGR_MEMBER_INDEX_DUPLICATE: HRESULT = 0xC0380024u32 as HRESULT; pub const ERROR_VOLMGR_MEMBER_INDEX_INVALID: HRESULT = 0xC0380025u32 as HRESULT; pub const ERROR_VOLMGR_MEMBER_MISSING: HRESULT = 0xC0380026u32 as HRESULT; pub const ERROR_VOLMGR_MEMBER_NOT_DETACHED: HRESULT = 0xC0380027u32 as HRESULT; pub const ERROR_VOLMGR_MEMBER_REGENERATING: HRESULT = 0xC0380028u32 as HRESULT; pub const ERROR_VOLMGR_ALL_DISKS_FAILED: HRESULT = 0xC0380029u32 as HRESULT; pub const ERROR_VOLMGR_NO_REGISTERED_USERS: HRESULT = 0xC038002Au32 as HRESULT; pub const ERROR_VOLMGR_NO_SUCH_USER: HRESULT = 0xC038002Bu32 as HRESULT; pub const ERROR_VOLMGR_NOTIFICATION_RESET: HRESULT = 0xC038002Cu32 as HRESULT; pub const ERROR_VOLMGR_NUMBER_OF_MEMBERS_INVALID: HRESULT = 0xC038002Du32 as HRESULT; pub const ERROR_VOLMGR_NUMBER_OF_PLEXES_INVALID: HRESULT = 0xC038002Eu32 as HRESULT; pub const ERROR_VOLMGR_PACK_DUPLICATE: HRESULT = 0xC038002Fu32 as HRESULT; pub const ERROR_VOLMGR_PACK_ID_INVALID: HRESULT = 0xC0380030u32 as HRESULT; pub const ERROR_VOLMGR_PACK_INVALID: HRESULT = 0xC0380031u32 as HRESULT; pub const ERROR_VOLMGR_PACK_NAME_INVALID: HRESULT = 0xC0380032u32 as HRESULT; pub const ERROR_VOLMGR_PACK_OFFLINE: HRESULT = 0xC0380033u32 as HRESULT; pub const ERROR_VOLMGR_PACK_HAS_QUORUM: HRESULT = 0xC0380034u32 as HRESULT; pub const ERROR_VOLMGR_PACK_WITHOUT_QUORUM: HRESULT = 0xC0380035u32 as HRESULT; pub const ERROR_VOLMGR_PARTITION_STYLE_INVALID: HRESULT = 0xC0380036u32 as HRESULT; pub const ERROR_VOLMGR_PARTITION_UPDATE_FAILED: HRESULT = 0xC0380037u32 as HRESULT; pub const ERROR_VOLMGR_PLEX_IN_SYNC: HRESULT = 0xC0380038u32 as HRESULT; pub const ERROR_VOLMGR_PLEX_INDEX_DUPLICATE: HRESULT = 0xC0380039u32 as HRESULT; pub const ERROR_VOLMGR_PLEX_INDEX_INVALID: HRESULT = 0xC038003Au32 as HRESULT; pub const ERROR_VOLMGR_PLEX_LAST_ACTIVE: HRESULT = 0xC038003Bu32 as HRESULT; pub const ERROR_VOLMGR_PLEX_MISSING: HRESULT = 0xC038003Cu32 as HRESULT; pub const ERROR_VOLMGR_PLEX_REGENERATING: HRESULT = 0xC038003Du32 as HRESULT; pub const ERROR_VOLMGR_PLEX_TYPE_INVALID: HRESULT = 0xC038003Eu32 as HRESULT; pub const ERROR_VOLMGR_PLEX_NOT_RAID5: HRESULT = 0xC038003Fu32 as HRESULT; pub const ERROR_VOLMGR_PLEX_NOT_SIMPLE: HRESULT = 0xC0380040u32 as HRESULT; pub const ERROR_VOLMGR_STRUCTURE_SIZE_INVALID: HRESULT = 0xC0380041u32 as HRESULT; pub const ERROR_VOLMGR_TOO_MANY_NOTIFICATION_REQUESTS: HRESULT = 0xC0380042u32 as HRESULT; pub const ERROR_VOLMGR_TRANSACTION_IN_PROGRESS: HRESULT = 0xC0380043u32 as HRESULT; pub const ERROR_VOLMGR_UNEXPECTED_DISK_LAYOUT_CHANGE: HRESULT = 0xC0380044u32 as HRESULT; pub const ERROR_VOLMGR_VOLUME_CONTAINS_MISSING_DISK: HRESULT = 0xC0380045u32 as HRESULT; pub const ERROR_VOLMGR_VOLUME_ID_INVALID: HRESULT = 0xC0380046u32 as HRESULT; pub const ERROR_VOLMGR_VOLUME_LENGTH_INVALID: HRESULT = 0xC0380047u32 as HRESULT; pub const ERROR_VOLMGR_VOLUME_LENGTH_NOT_SECTOR_SIZE_MULTIPLE: HRESULT = 0xC0380048u32 as HRESULT; pub const ERROR_VOLMGR_VOLUME_NOT_MIRRORED: HRESULT = 0xC0380049u32 as HRESULT; pub const ERROR_VOLMGR_VOLUME_NOT_RETAINED: HRESULT = 0xC038004Au32 as HRESULT; pub const ERROR_VOLMGR_VOLUME_OFFLINE: HRESULT = 0xC038004Bu32 as HRESULT; pub const ERROR_VOLMGR_VOLUME_RETAINED: HRESULT = 0xC038004Cu32 as HRESULT; pub const ERROR_VOLMGR_NUMBER_OF_EXTENTS_INVALID: HRESULT = 0xC038004Du32 as HRESULT; pub const ERROR_VOLMGR_DIFFERENT_SECTOR_SIZE: HRESULT = 0xC038004Eu32 as HRESULT; pub const ERROR_VOLMGR_BAD_BOOT_DISK: HRESULT = 0xC038004Fu32 as HRESULT; pub const ERROR_VOLMGR_PACK_CONFIG_OFFLINE: HRESULT = 0xC0380050u32 as HRESULT; pub const ERROR_VOLMGR_PACK_CONFIG_ONLINE: HRESULT = 0xC0380051u32 as HRESULT; pub const ERROR_VOLMGR_NOT_PRIMARY_PACK: HRESULT = 0xC0380052u32 as HRESULT; pub const ERROR_VOLMGR_PACK_LOG_UPDATE_FAILED: HRESULT = 0xC0380053u32 as HRESULT; pub const ERROR_VOLMGR_NUMBER_OF_DISKS_IN_PLEX_INVALID: HRESULT = 0xC0380054u32 as HRESULT; pub const ERROR_VOLMGR_NUMBER_OF_DISKS_IN_MEMBER_INVALID: HRESULT = 0xC0380055u32 as HRESULT; pub const ERROR_VOLMGR_VOLUME_MIRRORED: HRESULT = 0xC0380056u32 as HRESULT; pub const ERROR_VOLMGR_PLEX_NOT_SIMPLE_SPANNED: HRESULT = 0xC0380057u32 as HRESULT; pub const ERROR_VOLMGR_NO_VALID_LOG_COPIES: HRESULT = 0xC0380058u32 as HRESULT; pub const ERROR_VOLMGR_PRIMARY_PACK_PRESENT: HRESULT = 0xC0380059u32 as HRESULT; pub const ERROR_VOLMGR_NUMBER_OF_DISKS_INVALID: HRESULT = 0xC038005Au32 as HRESULT; pub const ERROR_VOLMGR_MIRROR_NOT_SUPPORTED: HRESULT = 0xC038005Bu32 as HRESULT; pub const ERROR_VOLMGR_RAID5_NOT_SUPPORTED: HRESULT = 0xC038005Cu32 as HRESULT; pub const ERROR_BCD_NOT_ALL_ENTRIES_IMPORTED: HRESULT = 0x80390001u32 as HRESULT; pub const ERROR_BCD_TOO_MANY_ELEMENTS: HRESULT = 0xC0390002u32 as HRESULT; pub const ERROR_BCD_NOT_ALL_ENTRIES_SYNCHRONIZED: HRESULT = 0x80390003u32 as HRESULT; pub const ERROR_VHD_DRIVE_FOOTER_MISSING: HRESULT = 0xC03A0001u32 as HRESULT; pub const ERROR_VHD_DRIVE_FOOTER_CHECKSUM_MISMATCH: HRESULT = 0xC03A0002u32 as HRESULT; pub const ERROR_VHD_DRIVE_FOOTER_CORRUPT: HRESULT = 0xC03A0003u32 as HRESULT; pub const ERROR_VHD_FORMAT_UNKNOWN: HRESULT = 0xC03A0004u32 as HRESULT; pub const ERROR_VHD_FORMAT_UNSUPPORTED_VERSION: HRESULT = 0xC03A0005u32 as HRESULT; pub const ERROR_VHD_SPARSE_HEADER_CHECKSUM_MISMATCH: HRESULT = 0xC03A0006u32 as HRESULT; pub const ERROR_VHD_SPARSE_HEADER_UNSUPPORTED_VERSION: HRESULT = 0xC03A0007u32 as HRESULT; pub const ERROR_VHD_SPARSE_HEADER_CORRUPT: HRESULT = 0xC03A0008u32 as HRESULT; pub const ERROR_VHD_BLOCK_ALLOCATION_FAILURE: HRESULT = 0xC03A0009u32 as HRESULT; pub const ERROR_VHD_BLOCK_ALLOCATION_TABLE_CORRUPT: HRESULT = 0xC03A000Au32 as HRESULT; pub const ERROR_VHD_INVALID_BLOCK_SIZE: HRESULT = 0xC03A000Bu32 as HRESULT; pub const ERROR_VHD_BITMAP_MISMATCH: HRESULT = 0xC03A000Cu32 as HRESULT; pub const ERROR_VHD_PARENT_VHD_NOT_FOUND: HRESULT = 0xC03A000Du32 as HRESULT; pub const ERROR_VHD_CHILD_PARENT_ID_MISMATCH: HRESULT = 0xC03A000Eu32 as HRESULT; pub const ERROR_VHD_CHILD_PARENT_TIMESTAMP_MISMATCH: HRESULT = 0xC03A000Fu32 as HRESULT; pub const ERROR_VHD_METADATA_READ_FAILURE: HRESULT = 0xC03A0010u32 as HRESULT; pub const ERROR_VHD_METADATA_WRITE_FAILURE: HRESULT = 0xC03A0011u32 as HRESULT; pub const ERROR_VHD_INVALID_SIZE: HRESULT = 0xC03A0012u32 as HRESULT; pub const ERROR_VHD_INVALID_FILE_SIZE: HRESULT = 0xC03A0013u32 as HRESULT; pub const ERROR_VIRTDISK_PROVIDER_NOT_FOUND: HRESULT = 0xC03A0014u32 as HRESULT; pub const ERROR_VIRTDISK_NOT_VIRTUAL_DISK: HRESULT = 0xC03A0015u32 as HRESULT; pub const ERROR_VHD_PARENT_VHD_ACCESS_DENIED: HRESULT = 0xC03A0016u32 as HRESULT; pub const ERROR_VHD_CHILD_PARENT_SIZE_MISMATCH: HRESULT = 0xC03A0017u32 as HRESULT; pub const ERROR_VHD_DIFFERENCING_CHAIN_CYCLE_DETECTED: HRESULT = 0xC03A0018u32 as HRESULT; pub const ERROR_VHD_DIFFERENCING_CHAIN_ERROR_IN_PARENT: HRESULT = 0xC03A0019u32 as HRESULT; pub const ERROR_VIRTUAL_DISK_LIMITATION: HRESULT = 0xC03A001Au32 as HRESULT; pub const ERROR_VHD_INVALID_TYPE: HRESULT = 0xC03A001Bu32 as HRESULT; pub const ERROR_VHD_INVALID_STATE: HRESULT = 0xC03A001Cu32 as HRESULT; pub const ERROR_VIRTDISK_UNSUPPORTED_DISK_SECTOR_SIZE: HRESULT = 0xC03A001Du32 as HRESULT; pub const ERROR_VIRTDISK_DISK_ALREADY_OWNED: HRESULT = 0xC03A001Eu32 as HRESULT; pub const ERROR_VIRTDISK_DISK_ONLINE_AND_WRITABLE: HRESULT = 0xC03A001Fu32 as HRESULT; pub const ERROR_CTLOG_TRACKING_NOT_INITIALIZED: HRESULT = 0xC03A0020u32 as HRESULT; pub const ERROR_CTLOG_LOGFILE_SIZE_EXCEEDED_MAXSIZE: HRESULT = 0xC03A0021u32 as HRESULT; pub const ERROR_CTLOG_VHD_CHANGED_OFFLINE: HRESULT = 0xC03A0022u32 as HRESULT; pub const ERROR_CTLOG_INVALID_TRACKING_STATE: HRESULT = 0xC03A0023u32 as HRESULT; pub const ERROR_CTLOG_INCONSISTENT_TRACKING_FILE: HRESULT = 0xC03A0024u32 as HRESULT; pub const ERROR_VHD_RESIZE_WOULD_TRUNCATE_DATA: HRESULT = 0xC03A0025u32 as HRESULT; pub const ERROR_VHD_COULD_NOT_COMPUTE_MINIMUM_VIRTUAL_SIZE: HRESULT = 0xC03A0026u32 as HRESULT; pub const ERROR_VHD_ALREADY_AT_OR_BELOW_MINIMUM_VIRTUAL_SIZE: HRESULT = 0xC03A0027u32 as HRESULT; pub const ERROR_VHD_METADATA_FULL: HRESULT = 0xC03A0028u32 as HRESULT; pub const ERROR_QUERY_STORAGE_ERROR: HRESULT = 0x803A0001u32 as HRESULT; pub const SDIAG_E_CANCELLED: HRESULT = 0x803C0100u32 as HRESULT; pub const SDIAG_E_SCRIPT: HRESULT = 0x803C0101u32 as HRESULT; pub const SDIAG_E_POWERSHELL: HRESULT = 0x803C0102u32 as HRESULT; pub const SDIAG_E_MANAGEDHOST: HRESULT = 0x803C0103u32 as HRESULT; pub const SDIAG_E_NOVERIFIER: HRESULT = 0x803C0104u32 as HRESULT; pub const SDIAG_S_CANNOTRUN: HRESULT = 0x003C0105; pub const SDIAG_E_DISABLED: HRESULT = 0x803C0106u32 as HRESULT; pub const SDIAG_E_TRUST: HRESULT = 0x803C0107u32 as HRESULT; pub const SDIAG_E_CANNOTRUN: HRESULT = 0x803C0108u32 as HRESULT; pub const SDIAG_E_VERSION: HRESULT = 0x803C0109u32 as HRESULT; pub const SDIAG_E_RESOURCE: HRESULT = 0x803C010Au32 as HRESULT; pub const SDIAG_E_ROOTCAUSE: HRESULT = 0x803C010Bu32 as HRESULT; pub const WPN_E_CHANNEL_CLOSED: HRESULT = 0x803E0100u32 as HRESULT; pub const WPN_E_CHANNEL_REQUEST_NOT_COMPLETE: HRESULT = 0x803E0101u32 as HRESULT; pub const WPN_E_INVALID_APP: HRESULT = 0x803E0102u32 as HRESULT; pub const WPN_E_OUTSTANDING_CHANNEL_REQUEST: HRESULT = 0x803E0103u32 as HRESULT; pub const WPN_E_DUPLICATE_CHANNEL: HRESULT = 0x803E0104u32 as HRESULT; pub const WPN_E_PLATFORM_UNAVAILABLE: HRESULT = 0x803E0105u32 as HRESULT; pub const WPN_E_NOTIFICATION_POSTED: HRESULT = 0x803E0106u32 as HRESULT; pub const WPN_E_NOTIFICATION_HIDDEN: HRESULT = 0x803E0107u32 as HRESULT; pub const WPN_E_NOTIFICATION_NOT_POSTED: HRESULT = 0x803E0108u32 as HRESULT; pub const WPN_E_CLOUD_DISABLED: HRESULT = 0x803E0109u32 as HRESULT; pub const WPN_E_CLOUD_INCAPABLE: HRESULT = 0x803E0110u32 as HRESULT; pub const WPN_E_CLOUD_AUTH_UNAVAILABLE: HRESULT = 0x803E011Au32 as HRESULT; pub const WPN_E_CLOUD_SERVICE_UNAVAILABLE: HRESULT = 0x803E011Bu32 as HRESULT; pub const WPN_E_FAILED_LOCK_SCREEN_UPDATE_INTIALIZATION: HRESULT = 0x803E011Cu32 as HRESULT; pub const WPN_E_NOTIFICATION_DISABLED: HRESULT = 0x803E0111u32 as HRESULT; pub const WPN_E_NOTIFICATION_INCAPABLE: HRESULT = 0x803E0112u32 as HRESULT; pub const WPN_E_INTERNET_INCAPABLE: HRESULT = 0x803E0113u32 as HRESULT; pub const WPN_E_NOTIFICATION_TYPE_DISABLED: HRESULT = 0x803E0114u32 as HRESULT; pub const WPN_E_NOTIFICATION_SIZE: HRESULT = 0x803E0115u32 as HRESULT; pub const WPN_E_TAG_SIZE: HRESULT = 0x803E0116u32 as HRESULT; pub const WPN_E_ACCESS_DENIED: HRESULT = 0x803E0117u32 as HRESULT; pub const WPN_E_DUPLICATE_REGISTRATION: HRESULT = 0x803E0118u32 as HRESULT; pub const WPN_E_PUSH_NOTIFICATION_INCAPABLE: HRESULT = 0x803E0119u32 as HRESULT; pub const WPN_E_DEV_ID_SIZE: HRESULT = 0x803E0120u32 as HRESULT; pub const WPN_E_TAG_ALPHANUMERIC: HRESULT = 0x803E012Au32 as HRESULT; pub const WPN_E_INVALID_HTTP_STATUS_CODE: HRESULT = 0x803E012Bu32 as HRESULT; pub const WPN_E_OUT_OF_SESSION: HRESULT = 0x803E0200u32 as HRESULT; pub const WPN_E_POWER_SAVE: HRESULT = 0x803E0201u32 as HRESULT; pub const WPN_E_IMAGE_NOT_FOUND_IN_CACHE: HRESULT = 0x803E0202u32 as HRESULT; pub const WPN_E_ALL_URL_NOT_COMPLETED: HRESULT = 0x803E0203u32 as HRESULT; pub const WPN_E_INVALID_CLOUD_IMAGE: HRESULT = 0x803E0204u32 as HRESULT; pub const WPN_E_NOTIFICATION_ID_MATCHED: HRESULT = 0x803E0205u32 as HRESULT; pub const WPN_E_CALLBACK_ALREADY_REGISTERED: HRESULT = 0x803E0206u32 as HRESULT; pub const WPN_E_TOAST_NOTIFICATION_DROPPED: HRESULT = 0x803E0207u32 as HRESULT; pub const WPN_E_STORAGE_LOCKED: HRESULT = 0x803E0208u32 as HRESULT; pub const E_MBN_CONTEXT_NOT_ACTIVATED: HRESULT = 0x80548201u32 as HRESULT; pub const E_MBN_BAD_SIM: HRESULT = 0x80548202u32 as HRESULT; pub const E_MBN_DATA_CLASS_NOT_AVAILABLE: HRESULT = 0x80548203u32 as HRESULT; pub const E_MBN_INVALID_ACCESS_STRING: HRESULT = 0x80548204u32 as HRESULT; pub const E_MBN_MAX_ACTIVATED_CONTEXTS: HRESULT = 0x80548205u32 as HRESULT; pub const E_MBN_PACKET_SVC_DETACHED: HRESULT = 0x80548206u32 as HRESULT; pub const E_MBN_PROVIDER_NOT_VISIBLE: HRESULT = 0x80548207u32 as HRESULT; pub const E_MBN_RADIO_POWER_OFF: HRESULT = 0x80548208u32 as HRESULT; pub const E_MBN_SERVICE_NOT_ACTIVATED: HRESULT = 0x80548209u32 as HRESULT; pub const E_MBN_SIM_NOT_INSERTED: HRESULT = 0x8054820Au32 as HRESULT; pub const E_MBN_VOICE_CALL_IN_PROGRESS: HRESULT = 0x8054820Bu32 as HRESULT; pub const E_MBN_INVALID_CACHE: HRESULT = 0x8054820Cu32 as HRESULT; pub const E_MBN_NOT_REGISTERED: HRESULT = 0x8054820Du32 as HRESULT; pub const E_MBN_PROVIDERS_NOT_FOUND: HRESULT = 0x8054820Eu32 as HRESULT; pub const E_MBN_PIN_NOT_SUPPORTED: HRESULT = 0x8054820Fu32 as HRESULT; pub const E_MBN_PIN_REQUIRED: HRESULT = 0x80548210u32 as HRESULT; pub const E_MBN_PIN_DISABLED: HRESULT = 0x80548211u32 as HRESULT; pub const E_MBN_FAILURE: HRESULT = 0x80548212u32 as HRESULT; pub const E_MBN_INVALID_PROFILE: HRESULT = 0x80548218u32 as HRESULT; pub const E_MBN_DEFAULT_PROFILE_EXIST: HRESULT = 0x80548219u32 as HRESULT; pub const E_MBN_SMS_ENCODING_NOT_SUPPORTED: HRESULT = 0x80548220u32 as HRESULT; pub const E_MBN_SMS_FILTER_NOT_SUPPORTED: HRESULT = 0x80548221u32 as HRESULT; pub const E_MBN_SMS_INVALID_MEMORY_INDEX: HRESULT = 0x80548222u32 as HRESULT; pub const E_MBN_SMS_LANG_NOT_SUPPORTED: HRESULT = 0x80548223u32 as HRESULT; pub const E_MBN_SMS_MEMORY_FAILURE: HRESULT = 0x80548224u32 as HRESULT; pub const E_MBN_SMS_NETWORK_TIMEOUT: HRESULT = 0x80548225u32 as HRESULT; pub const E_MBN_SMS_UNKNOWN_SMSC_ADDRESS: HRESULT = 0x80548226u32 as HRESULT; pub const E_MBN_SMS_FORMAT_NOT_SUPPORTED: HRESULT = 0x80548227u32 as HRESULT; pub const E_MBN_SMS_OPERATION_NOT_ALLOWED: HRESULT = 0x80548228u32 as HRESULT; pub const E_MBN_SMS_MEMORY_FULL: HRESULT = 0x80548229u32 as HRESULT; pub const PEER_E_IPV6_NOT_INSTALLED: HRESULT = 0x80630001u32 as HRESULT; pub const PEER_E_NOT_INITIALIZED: HRESULT = 0x80630002u32 as HRESULT; pub const PEER_E_CANNOT_START_SERVICE: HRESULT = 0x80630003u32 as HRESULT; pub const PEER_E_NOT_LICENSED: HRESULT = 0x80630004u32 as HRESULT; pub const PEER_E_INVALID_GRAPH: HRESULT = 0x80630010u32 as HRESULT; pub const PEER_E_DBNAME_CHANGED: HRESULT = 0x80630011u32 as HRESULT; pub const PEER_E_DUPLICATE_GRAPH: HRESULT = 0x80630012u32 as HRESULT; pub const PEER_E_GRAPH_NOT_READY: HRESULT = 0x80630013u32 as HRESULT; pub const PEER_E_GRAPH_SHUTTING_DOWN: HRESULT = 0x80630014u32 as HRESULT; pub const PEER_E_GRAPH_IN_USE: HRESULT = 0x80630015u32 as HRESULT; pub const PEER_E_INVALID_DATABASE: HRESULT = 0x80630016u32 as HRESULT; pub const PEER_E_TOO_MANY_ATTRIBUTES: HRESULT = 0x80630017u32 as HRESULT; pub const PEER_E_CONNECTION_NOT_FOUND: HRESULT = 0x80630103u32 as HRESULT; pub const PEER_E_CONNECT_SELF: HRESULT = 0x80630106u32 as HRESULT; pub const PEER_E_ALREADY_LISTENING: HRESULT = 0x80630107u32 as HRESULT; pub const PEER_E_NODE_NOT_FOUND: HRESULT = 0x80630108u32 as HRESULT; pub const PEER_E_CONNECTION_FAILED: HRESULT = 0x80630109u32 as HRESULT; pub const PEER_E_CONNECTION_NOT_AUTHENTICATED: HRESULT = 0x8063010Au32 as HRESULT; pub const PEER_E_CONNECTION_REFUSED: HRESULT = 0x8063010Bu32 as HRESULT; pub const PEER_E_CLASSIFIER_TOO_LONG: HRESULT = 0x80630201u32 as HRESULT; pub const PEER_E_TOO_MANY_IDENTITIES: HRESULT = 0x80630202u32 as HRESULT; pub const PEER_E_NO_KEY_ACCESS: HRESULT = 0x80630203u32 as HRESULT; pub const PEER_E_GROUPS_EXIST: HRESULT = 0x80630204u32 as HRESULT; pub const PEER_E_RECORD_NOT_FOUND: HRESULT = 0x80630301u32 as HRESULT; pub const PEER_E_DATABASE_ACCESSDENIED: HRESULT = 0x80630302u32 as HRESULT; pub const PEER_E_DBINITIALIZATION_FAILED: HRESULT = 0x80630303u32 as HRESULT; pub const PEER_E_MAX_RECORD_SIZE_EXCEEDED: HRESULT = 0x80630304u32 as HRESULT; pub const PEER_E_DATABASE_ALREADY_PRESENT: HRESULT = 0x80630305u32 as HRESULT; pub const PEER_E_DATABASE_NOT_PRESENT: HRESULT = 0x80630306u32 as HRESULT; pub const PEER_E_IDENTITY_NOT_FOUND: HRESULT = 0x80630401u32 as HRESULT; pub const PEER_E_EVENT_HANDLE_NOT_FOUND: HRESULT = 0x80630501u32 as HRESULT; pub const PEER_E_INVALID_SEARCH: HRESULT = 0x80630601u32 as HRESULT; pub const PEER_E_INVALID_ATTRIBUTES: HRESULT = 0x80630602u32 as HRESULT; pub const PEER_E_INVITATION_NOT_TRUSTED: HRESULT = 0x80630701u32 as HRESULT; pub const PEER_E_CHAIN_TOO_LONG: HRESULT = 0x80630703u32 as HRESULT; pub const PEER_E_INVALID_TIME_PERIOD: HRESULT = 0x80630705u32 as HRESULT; pub const PEER_E_CIRCULAR_CHAIN_DETECTED: HRESULT = 0x80630706u32 as HRESULT; pub const PEER_E_CERT_STORE_CORRUPTED: HRESULT = 0x80630801u32 as HRESULT; pub const PEER_E_NO_CLOUD: HRESULT = 0x80631001u32 as HRESULT; pub const PEER_E_CLOUD_NAME_AMBIGUOUS: HRESULT = 0x80631005u32 as HRESULT; pub const PEER_E_INVALID_RECORD: HRESULT = 0x80632010u32 as HRESULT; pub const PEER_E_NOT_AUTHORIZED: HRESULT = 0x80632020u32 as HRESULT; pub const PEER_E_PASSWORD_DOES_NOT_MEET_POLICY: HRESULT = 0x80632021u32 as HRESULT; pub const PEER_E_DEFERRED_VALIDATION: HRESULT = 0x80632030u32 as HRESULT; pub const PEER_E_INVALID_GROUP_PROPERTIES: HRESULT = 0x80632040u32 as HRESULT; pub const PEER_E_INVALID_PEER_NAME: HRESULT = 0x80632050u32 as HRESULT; pub const PEER_E_INVALID_CLASSIFIER: HRESULT = 0x80632060u32 as HRESULT; pub const PEER_E_INVALID_FRIENDLY_NAME: HRESULT = 0x80632070u32 as HRESULT; pub const PEER_E_INVALID_ROLE_PROPERTY: HRESULT = 0x80632071u32 as HRESULT; pub const PEER_E_INVALID_CLASSIFIER_PROPERTY: HRESULT = 0x80632072u32 as HRESULT; pub const PEER_E_INVALID_RECORD_EXPIRATION: HRESULT = 0x80632080u32 as HRESULT; pub const PEER_E_INVALID_CREDENTIAL_INFO: HRESULT = 0x80632081u32 as HRESULT; pub const PEER_E_INVALID_CREDENTIAL: HRESULT = 0x80632082u32 as HRESULT; pub const PEER_E_INVALID_RECORD_SIZE: HRESULT = 0x80632083u32 as HRESULT; pub const PEER_E_UNSUPPORTED_VERSION: HRESULT = 0x80632090u32 as HRESULT; pub const PEER_E_GROUP_NOT_READY: HRESULT = 0x80632091u32 as HRESULT; pub const PEER_E_GROUP_IN_USE: HRESULT = 0x80632092u32 as HRESULT; pub const PEER_E_INVALID_GROUP: HRESULT = 0x80632093u32 as HRESULT; pub const PEER_E_NO_MEMBERS_FOUND: HRESULT = 0x80632094u32 as HRESULT; pub const PEER_E_NO_MEMBER_CONNECTIONS: HRESULT = 0x80632095u32 as HRESULT; pub const PEER_E_UNABLE_TO_LISTEN: HRESULT = 0x80632096u32 as HRESULT; pub const PEER_E_IDENTITY_DELETED: HRESULT = 0x806320A0u32 as HRESULT; pub const PEER_E_SERVICE_NOT_AVAILABLE: HRESULT = 0x806320A1u32 as HRESULT; pub const PEER_E_CONTACT_NOT_FOUND: HRESULT = 0x80636001u32 as HRESULT; pub const PEER_S_GRAPH_DATA_CREATED: HRESULT = 0x00630001; pub const PEER_S_NO_EVENT_DATA: HRESULT = 0x00630002; pub const PEER_S_ALREADY_CONNECTED: HRESULT = 0x00632000; pub const PEER_S_SUBSCRIPTION_EXISTS: HRESULT = 0x00636000; pub const PEER_S_NO_CONNECTIVITY: HRESULT = 0x00630005; pub const PEER_S_ALREADY_A_MEMBER: HRESULT = 0x00630006; pub const PEER_E_CANNOT_CONVERT_PEER_NAME: HRESULT = 0x80634001u32 as HRESULT; pub const PEER_E_INVALID_PEER_HOST_NAME: HRESULT = 0x80634002u32 as HRESULT; pub const PEER_E_NO_MORE: HRESULT = 0x80634003u32 as HRESULT; pub const PEER_E_PNRP_DUPLICATE_PEER_NAME: HRESULT = 0x80634005u32 as HRESULT; pub const PEER_E_INVITE_CANCELLED: HRESULT = 0x80637000u32 as HRESULT; pub const PEER_E_INVITE_RESPONSE_NOT_AVAILABLE: HRESULT = 0x80637001u32 as HRESULT; pub const PEER_E_NOT_SIGNED_IN: HRESULT = 0x80637003u32 as HRESULT; pub const PEER_E_PRIVACY_DECLINED: HRESULT = 0x80637004u32 as HRESULT; pub const PEER_E_TIMEOUT: HRESULT = 0x80637005u32 as HRESULT; pub const PEER_E_INVALID_ADDRESS: HRESULT = 0x80637007u32 as HRESULT; pub const PEER_E_FW_EXCEPTION_DISABLED: HRESULT = 0x80637008u32 as HRESULT; pub const PEER_E_FW_BLOCKED_BY_POLICY: HRESULT = 0x80637009u32 as HRESULT; pub const PEER_E_FW_BLOCKED_BY_SHIELDS_UP: HRESULT = 0x8063700Au32 as HRESULT; pub const PEER_E_FW_DECLINED: HRESULT = 0x8063700Bu32 as HRESULT; pub const UI_E_CREATE_FAILED: HRESULT = 0x802A0001u32 as HRESULT; pub const UI_E_SHUTDOWN_CALLED: HRESULT = 0x802A0002u32 as HRESULT; pub const UI_E_ILLEGAL_REENTRANCY: HRESULT = 0x802A0003u32 as HRESULT; pub const UI_E_OBJECT_SEALED: HRESULT = 0x802A0004u32 as HRESULT; pub const UI_E_VALUE_NOT_SET: HRESULT = 0x802A0005u32 as HRESULT; pub const UI_E_VALUE_NOT_DETERMINED: HRESULT = 0x802A0006u32 as HRESULT; pub const UI_E_INVALID_OUTPUT: HRESULT = 0x802A0007u32 as HRESULT; pub const UI_E_BOOLEAN_EXPECTED: HRESULT = 0x802A0008u32 as HRESULT; pub const UI_E_DIFFERENT_OWNER: HRESULT = 0x802A0009u32 as HRESULT; pub const UI_E_AMBIGUOUS_MATCH: HRESULT = 0x802A000Au32 as HRESULT; pub const UI_E_FP_OVERFLOW: HRESULT = 0x802A000Bu32 as HRESULT; pub const UI_E_WRONG_THREAD: HRESULT = 0x802A000Cu32 as HRESULT; pub const UI_E_STORYBOARD_ACTIVE: HRESULT = 0x802A0101u32 as HRESULT; pub const UI_E_STORYBOARD_NOT_PLAYING: HRESULT = 0x802A0102u32 as HRESULT; pub const UI_E_START_KEYFRAME_AFTER_END: HRESULT = 0x802A0103u32 as HRESULT; pub const UI_E_END_KEYFRAME_NOT_DETERMINED: HRESULT = 0x802A0104u32 as HRESULT; pub const UI_E_LOOPS_OVERLAP: HRESULT = 0x802A0105u32 as HRESULT; pub const UI_E_TRANSITION_ALREADY_USED: HRESULT = 0x802A0106u32 as HRESULT; pub const UI_E_TRANSITION_NOT_IN_STORYBOARD: HRESULT = 0x802A0107u32 as HRESULT; pub const UI_E_TRANSITION_ECLIPSED: HRESULT = 0x802A0108u32 as HRESULT; pub const UI_E_TIME_BEFORE_LAST_UPDATE: HRESULT = 0x802A0109u32 as HRESULT; pub const UI_E_TIMER_CLIENT_ALREADY_CONNECTED: HRESULT = 0x802A010Au32 as HRESULT; pub const UI_E_INVALID_DIMENSION: HRESULT = 0x802A010Bu32 as HRESULT; pub const UI_E_PRIMITIVE_OUT_OF_BOUNDS: HRESULT = 0x802A010Cu32 as HRESULT; pub const UI_E_WINDOW_CLOSED: HRESULT = 0x802A0201u32 as HRESULT; pub const E_BLUETOOTH_ATT_INVALID_HANDLE: HRESULT = 0x80650001u32 as HRESULT; pub const E_BLUETOOTH_ATT_READ_NOT_PERMITTED: HRESULT = 0x80650002u32 as HRESULT; pub const E_BLUETOOTH_ATT_WRITE_NOT_PERMITTED: HRESULT = 0x80650003u32 as HRESULT; pub const E_BLUETOOTH_ATT_INVALID_PDU: HRESULT = 0x80650004u32 as HRESULT; pub const E_BLUETOOTH_ATT_INSUFFICIENT_AUTHENTICATION: HRESULT = 0x80650005u32 as HRESULT; pub const E_BLUETOOTH_ATT_REQUEST_NOT_SUPPORTED: HRESULT = 0x80650006u32 as HRESULT; pub const E_BLUETOOTH_ATT_INVALID_OFFSET: HRESULT = 0x80650007u32 as HRESULT; pub const E_BLUETOOTH_ATT_INSUFFICIENT_AUTHORIZATION: HRESULT = 0x80650008u32 as HRESULT; pub const E_BLUETOOTH_ATT_PREPARE_QUEUE_FULL: HRESULT = 0x80650009u32 as HRESULT; pub const E_BLUETOOTH_ATT_ATTRIBUTE_NOT_FOUND: HRESULT = 0x8065000Au32 as HRESULT; pub const E_BLUETOOTH_ATT_ATTRIBUTE_NOT_LONG: HRESULT = 0x8065000Bu32 as HRESULT; pub const E_BLUETOOTH_ATT_INSUFFICIENT_ENCRYPTION_KEY_SIZE: HRESULT = 0x8065000Cu32 as HRESULT; pub const E_BLUETOOTH_ATT_INVALID_ATTRIBUTE_VALUE_LENGTH: HRESULT = 0x8065000Du32 as HRESULT; pub const E_BLUETOOTH_ATT_UNLIKELY: HRESULT = 0x8065000Eu32 as HRESULT; pub const E_BLUETOOTH_ATT_INSUFFICIENT_ENCRYPTION: HRESULT = 0x8065000Fu32 as HRESULT; pub const E_BLUETOOTH_ATT_UNSUPPORTED_GROUP_TYPE: HRESULT = 0x80650010u32 as HRESULT; pub const E_BLUETOOTH_ATT_INSUFFICIENT_RESOURCES: HRESULT = 0x80650011u32 as HRESULT; pub const E_BLUETOOTH_ATT_UNKNOWN_ERROR: HRESULT = 0x80651000u32 as HRESULT; pub const E_AUDIO_ENGINE_NODE_NOT_FOUND: HRESULT = 0x80660001u32 as HRESULT; pub const E_HDAUDIO_EMPTY_CONNECTION_LIST: HRESULT = 0x80660002u32 as HRESULT; pub const E_HDAUDIO_CONNECTION_LIST_NOT_SUPPORTED: HRESULT = 0x80660003u32 as HRESULT; pub const E_HDAUDIO_NO_LOGICAL_DEVICES_CREATED: HRESULT = 0x80660004u32 as HRESULT; pub const E_HDAUDIO_NULL_LINKED_LIST_ENTRY: HRESULT = 0x80660005u32 as HRESULT; pub const ERROR_SPACES_POOL_WAS_DELETED: HRESULT = 0x00E70001; pub const ERROR_SPACES_RESILIENCY_TYPE_INVALID: HRESULT = 0x80E70003u32 as HRESULT; pub const ERROR_SPACES_DRIVE_SECTOR_SIZE_INVALID: HRESULT = 0x80E70004u32 as HRESULT; pub const ERROR_SPACES_DRIVE_REDUNDANCY_INVALID: HRESULT = 0x80E70006u32 as HRESULT; pub const ERROR_SPACES_NUMBER_OF_DATA_COPIES_INVALID: HRESULT = 0x80E70007u32 as HRESULT; pub const ERROR_SPACES_PARITY_LAYOUT_INVALID: HRESULT = 0x80E70008u32 as HRESULT; pub const ERROR_SPACES_INTERLEAVE_LENGTH_INVALID: HRESULT = 0x80E70009u32 as HRESULT; pub const ERROR_SPACES_NUMBER_OF_COLUMNS_INVALID: HRESULT = 0x80E7000Au32 as HRESULT; pub const ERROR_SPACES_NOT_ENOUGH_DRIVES: HRESULT = 0x80E7000Bu32 as HRESULT; pub const ERROR_VOLSNAP_BOOTFILE_NOT_VALID: HRESULT = 0x80820001u32 as HRESULT; pub const ERROR_TIERING_NOT_SUPPORTED_ON_VOLUME: HRESULT = 0x80830001u32 as HRESULT; pub const ERROR_TIERING_VOLUME_DISMOUNT_IN_PROGRESS: HRESULT = 0x80830002u32 as HRESULT; pub const ERROR_TIERING_STORAGE_TIER_NOT_FOUND: HRESULT = 0x80830003u32 as HRESULT; pub const ERROR_TIERING_INVALID_FILE_ID: HRESULT = 0x80830004u32 as HRESULT; pub const ERROR_TIERING_WRONG_CLUSTER_NODE: HRESULT = 0x80830005u32 as HRESULT; pub const ERROR_TIERING_ALREADY_PROCESSING: HRESULT = 0x80830006u32 as HRESULT; pub const ERROR_TIERING_CANNOT_PIN_OBJECT: HRESULT = 0x80830007u32 as HRESULT; pub const DXGI_STATUS_OCCLUDED: HRESULT = 0x087A0001; pub const DXGI_STATUS_CLIPPED: HRESULT = 0x087A0002; pub const DXGI_STATUS_NO_REDIRECTION: HRESULT = 0x087A0004; pub const DXGI_STATUS_NO_DESKTOP_ACCESS: HRESULT = 0x087A0005; pub const DXGI_STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE: HRESULT = 0x087A0006; pub const DXGI_STATUS_MODE_CHANGED: HRESULT = 0x087A0007; pub const DXGI_STATUS_MODE_CHANGE_IN_PROGRESS: HRESULT = 0x087A0008; pub const DXGI_ERROR_INVALID_CALL: HRESULT = 0x887A0001u32 as HRESULT; pub const DXGI_ERROR_NOT_FOUND: HRESULT = 0x887A0002u32 as HRESULT; pub const DXGI_ERROR_MORE_DATA: HRESULT = 0x887A0003u32 as HRESULT; pub const DXGI_ERROR_UNSUPPORTED: HRESULT = 0x887A0004u32 as HRESULT; pub const DXGI_ERROR_DEVICE_REMOVED: HRESULT = 0x887A0005u32 as HRESULT; pub const DXGI_ERROR_DEVICE_HUNG: HRESULT = 0x887A0006u32 as HRESULT; pub const DXGI_ERROR_DEVICE_RESET: HRESULT = 0x887A0007u32 as HRESULT; pub const DXGI_ERROR_WAS_STILL_DRAWING: HRESULT = 0x887A000Au32 as HRESULT; pub const DXGI_ERROR_FRAME_STATISTICS_DISJOINT: HRESULT = 0x887A000Bu32 as HRESULT; pub const DXGI_ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE: HRESULT = 0x887A000Cu32 as HRESULT; pub const DXGI_ERROR_DRIVER_INTERNAL_ERROR: HRESULT = 0x887A0020u32 as HRESULT; pub const DXGI_ERROR_NONEXCLUSIVE: HRESULT = 0x887A0021u32 as HRESULT; pub const DXGI_ERROR_NOT_CURRENTLY_AVAILABLE: HRESULT = 0x887A0022u32 as HRESULT; pub const DXGI_ERROR_REMOTE_CLIENT_DISCONNECTED: HRESULT = 0x887A0023u32 as HRESULT; pub const DXGI_ERROR_REMOTE_OUTOFMEMORY: HRESULT = 0x887A0024u32 as HRESULT; pub const DXGI_ERROR_ACCESS_LOST: HRESULT = 0x887A0026u32 as HRESULT; pub const DXGI_ERROR_WAIT_TIMEOUT: HRESULT = 0x887A0027u32 as HRESULT; pub const DXGI_ERROR_SESSION_DISCONNECTED: HRESULT = 0x887A0028u32 as HRESULT; pub const DXGI_ERROR_RESTRICT_TO_OUTPUT_STALE: HRESULT = 0x887A0029u32 as HRESULT; pub const DXGI_ERROR_CANNOT_PROTECT_CONTENT: HRESULT = 0x887A002Au32 as HRESULT; pub const DXGI_ERROR_ACCESS_DENIED: HRESULT = 0x887A002Bu32 as HRESULT; pub const DXGI_ERROR_NAME_ALREADY_EXISTS: HRESULT = 0x887A002Cu32 as HRESULT; pub const DXGI_ERROR_SDK_COMPONENT_MISSING: HRESULT = 0x887A002Du32 as HRESULT; pub const DXGI_STATUS_UNOCCLUDED: HRESULT = 0x087A0009; pub const DXGI_STATUS_DDA_WAS_STILL_DRAWING: HRESULT = 0x087A000A; pub const DXGI_ERROR_MODE_CHANGE_IN_PROGRESS: HRESULT = 0x887A0025u32 as HRESULT; pub const DXGI_DDI_ERR_WASSTILLDRAWING: HRESULT = 0x887B0001u32 as HRESULT; pub const DXGI_DDI_ERR_UNSUPPORTED: HRESULT = 0x887B0002u32 as HRESULT; pub const DXGI_DDI_ERR_NONEXCLUSIVE: HRESULT = 0x887B0003u32 as HRESULT; pub const D3D10_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS: HRESULT = 0x88790001u32 as HRESULT; pub const D3D10_ERROR_FILE_NOT_FOUND: HRESULT = 0x88790002u32 as HRESULT; pub const D3D11_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS: HRESULT = 0x887C0001u32 as HRESULT; pub const D3D11_ERROR_FILE_NOT_FOUND: HRESULT = 0x887C0002u32 as HRESULT; pub const D3D11_ERROR_TOO_MANY_UNIQUE_VIEW_OBJECTS: HRESULT = 0x887C0003u32 as HRESULT; pub const D3D11_ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD: HRESULT = 0x887C0004u32 as HRESULT; pub const D2DERR_WRONG_STATE: HRESULT = 0x88990001u32 as HRESULT; pub const D2DERR_NOT_INITIALIZED: HRESULT = 0x88990002u32 as HRESULT; pub const D2DERR_UNSUPPORTED_OPERATION: HRESULT = 0x88990003u32 as HRESULT; pub const D2DERR_SCANNER_FAILED: HRESULT = 0x88990004u32 as HRESULT; pub const D2DERR_SCREEN_ACCESS_DENIED: HRESULT = 0x88990005u32 as HRESULT; pub const D2DERR_DISPLAY_STATE_INVALID: HRESULT = 0x88990006u32 as HRESULT; pub const D2DERR_ZERO_VECTOR: HRESULT = 0x88990007u32 as HRESULT; pub const D2DERR_INTERNAL_ERROR: HRESULT = 0x88990008u32 as HRESULT; pub const D2DERR_DISPLAY_FORMAT_NOT_SUPPORTED: HRESULT = 0x88990009u32 as HRESULT; pub const D2DERR_INVALID_CALL: HRESULT = 0x8899000Au32 as HRESULT; pub const D2DERR_NO_HARDWARE_DEVICE: HRESULT = 0x8899000Bu32 as HRESULT; pub const D2DERR_RECREATE_TARGET: HRESULT = 0x8899000Cu32 as HRESULT; pub const D2DERR_TOO_MANY_SHADER_ELEMENTS: HRESULT = 0x8899000Du32 as HRESULT; pub const D2DERR_SHADER_COMPILE_FAILED: HRESULT = 0x8899000Eu32 as HRESULT; pub const D2DERR_MAX_TEXTURE_SIZE_EXCEEDED: HRESULT = 0x8899000Fu32 as HRESULT; pub const D2DERR_UNSUPPORTED_VERSION: HRESULT = 0x88990010u32 as HRESULT; pub const D2DERR_BAD_NUMBER: HRESULT = 0x88990011u32 as HRESULT; pub const D2DERR_WRONG_FACTORY: HRESULT = 0x88990012u32 as HRESULT; pub const D2DERR_LAYER_ALREADY_IN_USE: HRESULT = 0x88990013u32 as HRESULT; pub const D2DERR_POP_CALL_DID_NOT_MATCH_PUSH: HRESULT = 0x88990014u32 as HRESULT; pub const D2DERR_WRONG_RESOURCE_DOMAIN: HRESULT = 0x88990015u32 as HRESULT; pub const D2DERR_PUSH_POP_UNBALANCED: HRESULT = 0x88990016u32 as HRESULT; pub const D2DERR_RENDER_TARGET_HAS_LAYER_OR_CLIPRECT: HRESULT = 0x88990017u32 as HRESULT; pub const D2DERR_INCOMPATIBLE_BRUSH_TYPES: HRESULT = 0x88990018u32 as HRESULT; pub const D2DERR_WIN32_ERROR: HRESULT = 0x88990019u32 as HRESULT; pub const D2DERR_TARGET_NOT_GDI_COMPATIBLE: HRESULT = 0x8899001Au32 as HRESULT; pub const D2DERR_TEXT_EFFECT_IS_WRONG_TYPE: HRESULT = 0x8899001Bu32 as HRESULT; pub const D2DERR_TEXT_RENDERER_NOT_RELEASED: HRESULT = 0x8899001Cu32 as HRESULT; pub const D2DERR_EXCEEDS_MAX_BITMAP_SIZE: HRESULT = 0x8899001Du32 as HRESULT; pub const D2DERR_INVALID_GRAPH_CONFIGURATION: HRESULT = 0x8899001Eu32 as HRESULT; pub const D2DERR_INVALID_INTERNAL_GRAPH_CONFIGURATION: HRESULT = 0x8899001Fu32 as HRESULT; pub const D2DERR_CYCLIC_GRAPH: HRESULT = 0x88990020u32 as HRESULT; pub const D2DERR_BITMAP_CANNOT_DRAW: HRESULT = 0x88990021u32 as HRESULT; pub const D2DERR_OUTSTANDING_BITMAP_REFERENCES: HRESULT = 0x88990022u32 as HRESULT; pub const D2DERR_ORIGINAL_TARGET_NOT_BOUND: HRESULT = 0x88990023u32 as HRESULT; pub const D2DERR_INVALID_TARGET: HRESULT = 0x88990024u32 as HRESULT; pub const D2DERR_BITMAP_BOUND_AS_TARGET: HRESULT = 0x88990025u32 as HRESULT; pub const D2DERR_INSUFFICIENT_DEVICE_CAPABILITIES: HRESULT = 0x88990026u32 as HRESULT; pub const D2DERR_INTERMEDIATE_TOO_LARGE: HRESULT = 0x88990027u32 as HRESULT; pub const D2DERR_EFFECT_IS_NOT_REGISTERED: HRESULT = 0x88990028u32 as HRESULT; pub const D2DERR_INVALID_PROPERTY: HRESULT = 0x88990029u32 as HRESULT; pub const D2DERR_NO_SUBPROPERTIES: HRESULT = 0x8899002Au32 as HRESULT; pub const D2DERR_PRINT_JOB_CLOSED: HRESULT = 0x8899002Bu32 as HRESULT; pub const D2DERR_PRINT_FORMAT_NOT_SUPPORTED: HRESULT = 0x8899002Cu32 as HRESULT; pub const D2DERR_TOO_MANY_TRANSFORM_INPUTS: HRESULT = 0x8899002Du32 as HRESULT; pub const DWRITE_E_FILEFORMAT: HRESULT = 0x88985000u32 as HRESULT; pub const DWRITE_E_UNEXPECTED: HRESULT = 0x88985001u32 as HRESULT; pub const DWRITE_E_NOFONT: HRESULT = 0x88985002u32 as HRESULT; pub const DWRITE_E_FILENOTFOUND: HRESULT = 0x88985003u32 as HRESULT; pub const DWRITE_E_FILEACCESS: HRESULT = 0x88985004u32 as HRESULT; pub const DWRITE_E_FONTCOLLECTIONOBSOLETE: HRESULT = 0x88985005u32 as HRESULT; pub const DWRITE_E_ALREADYREGISTERED: HRESULT = 0x88985006u32 as HRESULT; pub const DWRITE_E_CACHEFORMAT: HRESULT = 0x88985007u32 as HRESULT; pub const DWRITE_E_CACHEVERSION: HRESULT = 0x88985008u32 as HRESULT; pub const DWRITE_E_UNSUPPORTEDOPERATION: HRESULT = 0x88985009u32 as HRESULT; pub const DWRITE_E_TEXTRENDERERINCOMPATIBLE: HRESULT = 0x8898500Au32 as HRESULT; pub const DWRITE_E_FLOWDIRECTIONCONFLICTS: HRESULT = 0x8898500Bu32 as HRESULT; pub const DWRITE_E_NOCOLOR: HRESULT = 0x8898500Cu32 as HRESULT; pub const WINCODEC_ERR_WRONGSTATE: HRESULT = 0x88982F04u32 as HRESULT; pub const WINCODEC_ERR_VALUEOUTOFRANGE: HRESULT = 0x88982F05u32 as HRESULT; pub const WINCODEC_ERR_UNKNOWNIMAGEFORMAT: HRESULT = 0x88982F07u32 as HRESULT; pub const WINCODEC_ERR_UNSUPPORTEDVERSION: HRESULT = 0x88982F0Bu32 as HRESULT; pub const WINCODEC_ERR_NOTINITIALIZED: HRESULT = 0x88982F0Cu32 as HRESULT; pub const WINCODEC_ERR_ALREADYLOCKED: HRESULT = 0x88982F0Du32 as HRESULT; pub const WINCODEC_ERR_PROPERTYNOTFOUND: HRESULT = 0x88982F40u32 as HRESULT; pub const WINCODEC_ERR_PROPERTYNOTSUPPORTED: HRESULT = 0x88982F41u32 as HRESULT; pub const WINCODEC_ERR_PROPERTYSIZE: HRESULT = 0x88982F42u32 as HRESULT; pub const WINCODEC_ERR_CODECPRESENT: HRESULT = 0x88982F43u32 as HRESULT; pub const WINCODEC_ERR_CODECNOTHUMBNAIL: HRESULT = 0x88982F44u32 as HRESULT; pub const WINCODEC_ERR_PALETTEUNAVAILABLE: HRESULT = 0x88982F45u32 as HRESULT; pub const WINCODEC_ERR_CODECTOOMANYSCANLINES: HRESULT = 0x88982F46u32 as HRESULT; pub const WINCODEC_ERR_INTERNALERROR: HRESULT = 0x88982F48u32 as HRESULT; pub const WINCODEC_ERR_SOURCERECTDOESNOTMATCHDIMENSIONS: HRESULT = 0x88982F49u32 as HRESULT; pub const WINCODEC_ERR_COMPONENTNOTFOUND: HRESULT = 0x88982F50u32 as HRESULT; pub const WINCODEC_ERR_IMAGESIZEOUTOFRANGE: HRESULT = 0x88982F51u32 as HRESULT; pub const WINCODEC_ERR_TOOMUCHMETADATA: HRESULT = 0x88982F52u32 as HRESULT; pub const WINCODEC_ERR_BADIMAGE: HRESULT = 0x88982F60u32 as HRESULT; pub const WINCODEC_ERR_BADHEADER: HRESULT = 0x88982F61u32 as HRESULT; pub const WINCODEC_ERR_FRAMEMISSING: HRESULT = 0x88982F62u32 as HRESULT; pub const WINCODEC_ERR_BADMETADATAHEADER: HRESULT = 0x88982F63u32 as HRESULT; pub const WINCODEC_ERR_BADSTREAMDATA: HRESULT = 0x88982F70u32 as HRESULT; pub const WINCODEC_ERR_STREAMWRITE: HRESULT = 0x88982F71u32 as HRESULT; pub const WINCODEC_ERR_STREAMREAD: HRESULT = 0x88982F72u32 as HRESULT; pub const WINCODEC_ERR_STREAMNOTAVAILABLE: HRESULT = 0x88982F73u32 as HRESULT; pub const WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT: HRESULT = 0x88982F80u32 as HRESULT; pub const WINCODEC_ERR_UNSUPPORTEDOPERATION: HRESULT = 0x88982F81u32 as HRESULT; pub const WINCODEC_ERR_INVALIDREGISTRATION: HRESULT = 0x88982F8Au32 as HRESULT; pub const WINCODEC_ERR_COMPONENTINITIALIZEFAILURE: HRESULT = 0x88982F8Bu32 as HRESULT; pub const WINCODEC_ERR_INSUFFICIENTBUFFER: HRESULT = 0x88982F8Cu32 as HRESULT; pub const WINCODEC_ERR_DUPLICATEMETADATAPRESENT: HRESULT = 0x88982F8Du32 as HRESULT; pub const WINCODEC_ERR_PROPERTYUNEXPECTEDTYPE: HRESULT = 0x88982F8Eu32 as HRESULT; pub const WINCODEC_ERR_UNEXPECTEDSIZE: HRESULT = 0x88982F8Fu32 as HRESULT; pub const WINCODEC_ERR_INVALIDQUERYREQUEST: HRESULT = 0x88982F90u32 as HRESULT; pub const WINCODEC_ERR_UNEXPECTEDMETADATATYPE: HRESULT = 0x88982F91u32 as HRESULT; pub const WINCODEC_ERR_REQUESTONLYVALIDATMETADATAROOT: HRESULT = 0x88982F92u32 as HRESULT; pub const WINCODEC_ERR_INVALIDQUERYCHARACTER: HRESULT = 0x88982F93u32 as HRESULT; pub const WINCODEC_ERR_WIN32ERROR: HRESULT = 0x88982F94u32 as HRESULT; pub const WINCODEC_ERR_INVALIDPROGRESSIVELEVEL: HRESULT = 0x88982F95u32 as HRESULT; pub const MILERR_OBJECTBUSY: HRESULT = 0x88980001u32 as HRESULT; pub const MILERR_INSUFFICIENTBUFFER: HRESULT = 0x88980002u32 as HRESULT; pub const MILERR_WIN32ERROR: HRESULT = 0x88980003u32 as HRESULT; pub const MILERR_SCANNER_FAILED: HRESULT = 0x88980004u32 as HRESULT; pub const MILERR_SCREENACCESSDENIED: HRESULT = 0x88980005u32 as HRESULT; pub const MILERR_DISPLAYSTATEINVALID: HRESULT = 0x88980006u32 as HRESULT; pub const MILERR_NONINVERTIBLEMATRIX: HRESULT = 0x88980007u32 as HRESULT; pub const MILERR_ZEROVECTOR: HRESULT = 0x88980008u32 as HRESULT; pub const MILERR_TERMINATED: HRESULT = 0x88980009u32 as HRESULT; pub const MILERR_BADNUMBER: HRESULT = 0x8898000Au32 as HRESULT; pub const MILERR_INTERNALERROR: HRESULT = 0x88980080u32 as HRESULT; pub const MILERR_DISPLAYFORMATNOTSUPPORTED: HRESULT = 0x88980084u32 as HRESULT; pub const MILERR_INVALIDCALL: HRESULT = 0x88980085u32 as HRESULT; pub const MILERR_ALREADYLOCKED: HRESULT = 0x88980086u32 as HRESULT; pub const MILERR_NOTLOCKED: HRESULT = 0x88980087u32 as HRESULT; pub const MILERR_DEVICECANNOTRENDERTEXT: HRESULT = 0x88980088u32 as HRESULT; pub const MILERR_GLYPHBITMAPMISSED: HRESULT = 0x88980089u32 as HRESULT; pub const MILERR_MALFORMEDGLYPHCACHE: HRESULT = 0x8898008Au32 as HRESULT; pub const MILERR_GENERIC_IGNORE: HRESULT = 0x8898008Bu32 as HRESULT; pub const MILERR_MALFORMED_GUIDELINE_DATA: HRESULT = 0x8898008Cu32 as HRESULT; pub const MILERR_NO_HARDWARE_DEVICE: HRESULT = 0x8898008Du32 as HRESULT; pub const MILERR_NEED_RECREATE_AND_PRESENT: HRESULT = 0x8898008Eu32 as HRESULT; pub const MILERR_ALREADY_INITIALIZED: HRESULT = 0x8898008Fu32 as HRESULT; pub const MILERR_MISMATCHED_SIZE: HRESULT = 0x88980090u32 as HRESULT; pub const MILERR_NO_REDIRECTION_SURFACE_AVAILABLE: HRESULT = 0x88980091u32 as HRESULT; pub const MILERR_REMOTING_NOT_SUPPORTED: HRESULT = 0x88980092u32 as HRESULT; pub const MILERR_QUEUED_PRESENT_NOT_SUPPORTED: HRESULT = 0x88980093u32 as HRESULT; pub const MILERR_NOT_QUEUING_PRESENTS: HRESULT = 0x88980094u32 as HRESULT; pub const MILERR_NO_REDIRECTION_SURFACE_RETRY_LATER: HRESULT = 0x88980095u32 as HRESULT; pub const MILERR_TOOMANYSHADERELEMNTS: HRESULT = 0x88980096u32 as HRESULT; pub const MILERR_MROW_READLOCK_FAILED: HRESULT = 0x88980097u32 as HRESULT; pub const MILERR_MROW_UPDATE_FAILED: HRESULT = 0x88980098u32 as HRESULT; pub const MILERR_SHADER_COMPILE_FAILED: HRESULT = 0x88980099u32 as HRESULT; pub const MILERR_MAX_TEXTURE_SIZE_EXCEEDED: HRESULT = 0x8898009Au32 as HRESULT; pub const MILERR_QPC_TIME_WENT_BACKWARD: HRESULT = 0x8898009Bu32 as HRESULT; pub const MILERR_DXGI_ENUMERATION_OUT_OF_SYNC: HRESULT = 0x8898009Du32 as HRESULT; pub const MILERR_ADAPTER_NOT_FOUND: HRESULT = 0x8898009Eu32 as HRESULT; pub const MILERR_COLORSPACE_NOT_SUPPORTED: HRESULT = 0x8898009Fu32 as HRESULT; pub const MILERR_PREFILTER_NOT_SUPPORTED: HRESULT = 0x889800A0u32 as HRESULT; pub const MILERR_DISPLAYID_ACCESS_DENIED: HRESULT = 0x889800A1u32 as HRESULT; pub const UCEERR_INVALIDPACKETHEADER: HRESULT = 0x88980400u32 as HRESULT; pub const UCEERR_UNKNOWNPACKET: HRESULT = 0x88980401u32 as HRESULT; pub const UCEERR_ILLEGALPACKET: HRESULT = 0x88980402u32 as HRESULT; pub const UCEERR_MALFORMEDPACKET: HRESULT = 0x88980403u32 as HRESULT; pub const UCEERR_ILLEGALHANDLE: HRESULT = 0x88980404u32 as HRESULT; pub const UCEERR_HANDLELOOKUPFAILED: HRESULT = 0x88980405u32 as HRESULT; pub const UCEERR_RENDERTHREADFAILURE: HRESULT = 0x88980406u32 as HRESULT; pub const UCEERR_CTXSTACKFRSTTARGETNULL: HRESULT = 0x88980407u32 as HRESULT; pub const UCEERR_CONNECTIONIDLOOKUPFAILED: HRESULT = 0x88980408u32 as HRESULT; pub const UCEERR_BLOCKSFULL: HRESULT = 0x88980409u32 as HRESULT; pub const UCEERR_MEMORYFAILURE: HRESULT = 0x8898040Au32 as HRESULT; pub const UCEERR_PACKETRECORDOUTOFRANGE: HRESULT = 0x8898040Bu32 as HRESULT; pub const UCEERR_ILLEGALRECORDTYPE: HRESULT = 0x8898040Cu32 as HRESULT; pub const UCEERR_OUTOFHANDLES: HRESULT = 0x8898040Du32 as HRESULT; pub const UCEERR_UNCHANGABLE_UPDATE_ATTEMPTED: HRESULT = 0x8898040Eu32 as HRESULT; pub const UCEERR_NO_MULTIPLE_WORKER_THREADS: HRESULT = 0x8898040Fu32 as HRESULT; pub const UCEERR_REMOTINGNOTSUPPORTED: HRESULT = 0x88980410u32 as HRESULT; pub const UCEERR_MISSINGENDCOMMAND: HRESULT = 0x88980411u32 as HRESULT; pub const UCEERR_MISSINGBEGINCOMMAND: HRESULT = 0x88980412u32 as HRESULT; pub const UCEERR_CHANNELSYNCTIMEDOUT: HRESULT = 0x88980413u32 as HRESULT; pub const UCEERR_CHANNELSYNCABANDONED: HRESULT = 0x88980414u32 as HRESULT; pub const UCEERR_UNSUPPORTEDTRANSPORTVERSION: HRESULT = 0x88980415u32 as HRESULT; pub const UCEERR_TRANSPORTUNAVAILABLE: HRESULT = 0x88980416u32 as HRESULT; pub const UCEERR_FEEDBACK_UNSUPPORTED: HRESULT = 0x88980417u32 as HRESULT; pub const UCEERR_COMMANDTRANSPORTDENIED: HRESULT = 0x88980418u32 as HRESULT; pub const UCEERR_GRAPHICSSTREAMUNAVAILABLE: HRESULT = 0x88980419u32 as HRESULT; pub const UCEERR_GRAPHICSSTREAMALREADYOPEN: HRESULT = 0x88980420u32 as HRESULT; pub const UCEERR_TRANSPORTDISCONNECTED: HRESULT = 0x88980421u32 as HRESULT; pub const UCEERR_TRANSPORTOVERLOADED: HRESULT = 0x88980422u32 as HRESULT; pub const UCEERR_PARTITION_ZOMBIED: HRESULT = 0x88980423u32 as HRESULT; pub const MILAVERR_NOCLOCK: HRESULT = 0x88980500u32 as HRESULT; pub const MILAVERR_NOMEDIATYPE: HRESULT = 0x88980501u32 as HRESULT; pub const MILAVERR_NOVIDEOMIXER: HRESULT = 0x88980502u32 as HRESULT; pub const MILAVERR_NOVIDEOPRESENTER: HRESULT = 0x88980503u32 as HRESULT; pub const MILAVERR_NOREADYFRAMES: HRESULT = 0x88980504u32 as HRESULT; pub const MILAVERR_MODULENOTLOADED: HRESULT = 0x88980505u32 as HRESULT; pub const MILAVERR_WMPFACTORYNOTREGISTERED: HRESULT = 0x88980506u32 as HRESULT; pub const MILAVERR_INVALIDWMPVERSION: HRESULT = 0x88980507u32 as HRESULT; pub const MILAVERR_INSUFFICIENTVIDEORESOURCES: HRESULT = 0x88980508u32 as HRESULT; pub const MILAVERR_VIDEOACCELERATIONNOTAVAILABLE: HRESULT = 0x88980509u32 as HRESULT; pub const MILAVERR_REQUESTEDTEXTURETOOBIG: HRESULT = 0x8898050Au32 as HRESULT; pub const MILAVERR_SEEKFAILED: HRESULT = 0x8898050Bu32 as HRESULT; pub const MILAVERR_UNEXPECTEDWMPFAILURE: HRESULT = 0x8898050Cu32 as HRESULT; pub const MILAVERR_MEDIAPLAYERCLOSED: HRESULT = 0x8898050Du32 as HRESULT; pub const MILAVERR_UNKNOWNHARDWAREERROR: HRESULT = 0x8898050Eu32 as HRESULT; pub const MILEFFECTSERR_UNKNOWNPROPERTY: HRESULT = 0x8898060Eu32 as HRESULT; pub const MILEFFECTSERR_EFFECTNOTPARTOFGROUP: HRESULT = 0x8898060Fu32 as HRESULT; pub const MILEFFECTSERR_NOINPUTSOURCEATTACHED: HRESULT = 0x88980610u32 as HRESULT; pub const MILEFFECTSERR_CONNECTORNOTCONNECTED: HRESULT = 0x88980611u32 as HRESULT; pub const MILEFFECTSERR_CONNECTORNOTASSOCIATEDWITHEFFECT: HRESULT = 0x88980612u32 as HRESULT; pub const MILEFFECTSERR_RESERVED: HRESULT = 0x88980613u32 as HRESULT; pub const MILEFFECTSERR_CYCLEDETECTED: HRESULT = 0x88980614u32 as HRESULT; pub const MILEFFECTSERR_EFFECTINMORETHANONEGRAPH: HRESULT = 0x88980615u32 as HRESULT; pub const MILEFFECTSERR_EFFECTALREADYINAGRAPH: HRESULT = 0x88980616u32 as HRESULT; pub const MILEFFECTSERR_EFFECTHASNOCHILDREN: HRESULT = 0x88980617u32 as HRESULT; pub const MILEFFECTSERR_ALREADYATTACHEDTOLISTENER: HRESULT = 0x88980618u32 as HRESULT; pub const MILEFFECTSERR_NOTAFFINETRANSFORM: HRESULT = 0x88980619u32 as HRESULT; pub const MILEFFECTSERR_EMPTYBOUNDS: HRESULT = 0x8898061Au32 as HRESULT; pub const MILEFFECTSERR_OUTPUTSIZETOOLARGE: HRESULT = 0x8898061Bu32 as HRESULT; pub const DWMERR_STATE_TRANSITION_FAILED: HRESULT = 0x88980700u32 as HRESULT; pub const DWMERR_THEME_FAILED: HRESULT = 0x88980701u32 as HRESULT; pub const DWMERR_CATASTROPHIC_FAILURE: HRESULT = 0x88980702u32 as HRESULT; pub const DCOMPOSITION_ERROR_WINDOW_ALREADY_COMPOSED: HRESULT = 0x88980800u32 as HRESULT; pub const DCOMPOSITION_ERROR_SURFACE_BEING_RENDERED: HRESULT = 0x88980801u32 as HRESULT; pub const DCOMPOSITION_ERROR_SURFACE_NOT_BEING_RENDERED: HRESULT = 0x88980802u32 as HRESULT; pub const ONL_E_INVALID_AUTHENTICATION_TARGET: HRESULT = 0x80860001u32 as HRESULT; pub const ONL_E_ACCESS_DENIED_BY_TOU: HRESULT = 0x80860002u32 as HRESULT; pub const ONL_E_INVALID_APPLICATION: HRESULT = 0x80860003u32 as HRESULT; pub const ONL_E_PASSWORD_UPDATE_REQUIRED: HRESULT = 0x80860004u32 as HRESULT; pub const ONL_E_ACCOUNT_UPDATE_REQUIRED: HRESULT = 0x80860005u32 as HRESULT; pub const ONL_E_FORCESIGNIN: HRESULT = 0x80860006u32 as HRESULT; pub const ONL_E_ACCOUNT_LOCKED: HRESULT = 0x80860007u32 as HRESULT; pub const ONL_E_PARENTAL_CONSENT_REQUIRED: HRESULT = 0x80860008u32 as HRESULT; pub const ONL_E_EMAIL_VERIFICATION_REQUIRED: HRESULT = 0x80860009u32 as HRESULT; pub const ONL_E_ACCOUNT_SUSPENDED_COMPROIMISE: HRESULT = 0x8086000Au32 as HRESULT; pub const ONL_E_ACCOUNT_SUSPENDED_ABUSE: HRESULT = 0x8086000Bu32 as HRESULT; pub const ONL_E_ACTION_REQUIRED: HRESULT = 0x8086000Cu32 as HRESULT; pub const ONL_CONNECTION_COUNT_LIMIT: HRESULT = 0x8086000Du32 as HRESULT; pub const ONL_E_CONNECTED_ACCOUNT_CAN_NOT_SIGNOUT: HRESULT = 0x8086000Eu32 as HRESULT; pub const ONL_E_USER_AUTHENTICATION_REQUIRED: HRESULT = 0x8086000Fu32 as HRESULT; pub const ONL_E_REQUEST_THROTTLED: HRESULT = 0x80860010u32 as HRESULT; pub const FA_E_MAX_PERSISTED_ITEMS_REACHED: HRESULT = 0x80270220u32 as HRESULT; pub const FA_E_HOMEGROUP_NOT_AVAILABLE: HRESULT = 0x80270222u32 as HRESULT; pub const E_MONITOR_RESOLUTION_TOO_LOW: HRESULT = 0x80270250u32 as HRESULT; pub const E_ELEVATED_ACTIVATION_NOT_SUPPORTED: HRESULT = 0x80270251u32 as HRESULT; pub const E_UAC_DISABLED: HRESULT = 0x80270252u32 as HRESULT; pub const E_FULL_ADMIN_NOT_SUPPORTED: HRESULT = 0x80270253u32 as HRESULT; pub const E_APPLICATION_NOT_REGISTERED: HRESULT = 0x80270254u32 as HRESULT; pub const E_MULTIPLE_EXTENSIONS_FOR_APPLICATION: HRESULT = 0x80270255u32 as HRESULT; pub const E_MULTIPLE_PACKAGES_FOR_FAMILY: HRESULT = 0x80270256u32 as HRESULT; pub const E_APPLICATION_MANAGER_NOT_RUNNING: HRESULT = 0x80270257u32 as HRESULT; pub const S_STORE_LAUNCHED_FOR_REMEDIATION: HRESULT = 0x00270258; pub const S_APPLICATION_ACTIVATION_ERROR_HANDLED_BY_DIALOG: HRESULT = 0x00270259; pub const E_APPLICATION_ACTIVATION_TIMED_OUT: HRESULT = 0x8027025Au32 as HRESULT; pub const E_APPLICATION_ACTIVATION_EXEC_FAILURE: HRESULT = 0x8027025Bu32 as HRESULT; pub const E_APPLICATION_TEMPORARY_LICENSE_ERROR: HRESULT = 0x8027025Cu32 as HRESULT; pub const E_APPLICATION_TRIAL_LICENSE_EXPIRED: HRESULT = 0x8027025Du32 as HRESULT; pub const E_SKYDRIVE_ROOT_TARGET_FILE_SYSTEM_NOT_SUPPORTED: HRESULT = 0x80270260u32 as HRESULT; pub const E_SKYDRIVE_ROOT_TARGET_OVERLAP: HRESULT = 0x80270261u32 as HRESULT; pub const E_SKYDRIVE_ROOT_TARGET_CANNOT_INDEX: HRESULT = 0x80270262u32 as HRESULT; pub const E_SKYDRIVE_FILE_NOT_UPLOADED: HRESULT = 0x80270263u32 as HRESULT; pub const E_SKYDRIVE_UPDATE_AVAILABILITY_FAIL: HRESULT = 0x80270264u32 as HRESULT; pub const E_SKYDRIVE_ROOT_TARGET_VOLUME_ROOT_NOT_SUPPORTED: HRESULT = 0x80270265u32 as HRESULT; pub const E_SYNCENGINE_FILE_SIZE_OVER_LIMIT: HRESULT = 0x8802B001u32 as HRESULT; pub const E_SYNCENGINE_FILE_SIZE_EXCEEDS_REMAINING_QUOTA: HRESULT = 0x8802B002u32 as HRESULT; pub const E_SYNCENGINE_UNSUPPORTED_FILE_NAME: HRESULT = 0x8802B003u32 as HRESULT; pub const E_SYNCENGINE_FOLDER_ITEM_COUNT_LIMIT_EXCEEDED: HRESULT = 0x8802B004u32 as HRESULT; pub const E_SYNCENGINE_FILE_SYNC_PARTNER_ERROR: HRESULT = 0x8802B005u32 as HRESULT; pub const E_SYNCENGINE_SYNC_PAUSED_BY_SERVICE: HRESULT = 0x8802B006u32 as HRESULT; pub const E_SYNCENGINE_FILE_IDENTIFIER_UNKNOWN: HRESULT = 0x8802C002u32 as HRESULT; pub const E_SYNCENGINE_SERVICE_AUTHENTICATION_FAILED: HRESULT = 0x8802C003u32 as HRESULT; pub const E_SYNCENGINE_UNKNOWN_SERVICE_ERROR: HRESULT = 0x8802C004u32 as HRESULT; pub const E_SYNCENGINE_SERVICE_RETURNED_UNEXPECTED_SIZE: HRESULT = 0x8802C005u32 as HRESULT; pub const E_SYNCENGINE_REQUEST_BLOCKED_BY_SERVICE: HRESULT = 0x8802C006u32 as HRESULT; pub const E_SYNCENGINE_REQUEST_BLOCKED_DUE_TO_CLIENT_ERROR: HRESULT = 0x8802C007u32 as HRESULT; pub const E_SYNCENGINE_FOLDER_INACCESSIBLE: HRESULT = 0x8802D001u32 as HRESULT; pub const E_SYNCENGINE_UNSUPPORTED_FOLDER_NAME: HRESULT = 0x8802D002u32 as HRESULT; pub const E_SYNCENGINE_UNSUPPORTED_MARKET: HRESULT = 0x8802D003u32 as HRESULT; pub const E_SYNCENGINE_PATH_LENGTH_LIMIT_EXCEEDED: HRESULT = 0x8802D004u32 as HRESULT; pub const E_SYNCENGINE_REMOTE_PATH_LENGTH_LIMIT_EXCEEDED: HRESULT = 0x8802D005u32 as HRESULT; pub const E_SYNCENGINE_CLIENT_UPDATE_NEEDED: HRESULT = 0x8802D006u32 as HRESULT; pub const E_SYNCENGINE_PROXY_AUTHENTICATION_REQUIRED: HRESULT = 0x8802D007u32 as HRESULT; pub const E_SYNCENGINE_STORAGE_SERVICE_PROVISIONING_FAILED: HRESULT = 0x8802D008u32 as HRESULT; pub const E_SYNCENGINE_UNSUPPORTED_REPARSE_POINT: HRESULT = 0x8802D009u32 as HRESULT; pub const E_SYNCENGINE_STORAGE_SERVICE_BLOCKED: HRESULT = 0x8802D00Au32 as HRESULT; pub const E_SYNCENGINE_FOLDER_IN_REDIRECTION: HRESULT = 0x8802D00Bu32 as HRESULT; pub const EAS_E_POLICY_NOT_MANAGED_BY_OS: HRESULT = 0x80550001u32 as HRESULT; pub const EAS_E_POLICY_COMPLIANT_WITH_ACTIONS: HRESULT = 0x80550002u32 as HRESULT; pub const EAS_E_REQUESTED_POLICY_NOT_ENFORCEABLE: HRESULT = 0x80550003u32 as HRESULT; pub const EAS_E_CURRENT_USER_HAS_BLANK_PASSWORD: HRESULT = 0x80550004u32 as HRESULT; pub const EAS_E_REQUESTED_POLICY_PASSWORD_EXPIRATION_INCOMPATIBLE: HRESULT = 0x80550005u32 as HRESULT; pub const EAS_E_USER_CANNOT_CHANGE_PASSWORD: HRESULT = 0x80550006u32 as HRESULT; pub const EAS_E_ADMINS_HAVE_BLANK_PASSWORD: HRESULT = 0x80550007u32 as HRESULT; pub const EAS_E_ADMINS_CANNOT_CHANGE_PASSWORD: HRESULT = 0x80550008u32 as HRESULT; pub const EAS_E_LOCAL_CONTROLLED_USERS_CANNOT_CHANGE_PASSWORD: HRESULT = 0x80550009u32 as HRESULT; pub const EAS_E_PASSWORD_POLICY_NOT_ENFORCEABLE_FOR_CONNECTED_ADMINS: HRESULT = 0x8055000Au32 as HRESULT; pub const EAS_E_CONNECTED_ADMINS_NEED_TO_CHANGE_PASSWORD: HRESULT = 0x8055000Bu32 as HRESULT; pub const EAS_E_PASSWORD_POLICY_NOT_ENFORCEABLE_FOR_CURRENT_CONNECTED_USER: HRESULT = 0x8055000Cu32 as HRESULT; pub const EAS_E_CURRENT_CONNECTED_USER_NEED_TO_CHANGE_PASSWORD: HRESULT = 0x8055000Du32 as HRESULT; pub const WEB_E_UNSUPPORTED_FORMAT: HRESULT = 0x83750001u32 as HRESULT; pub const WEB_E_INVALID_XML: HRESULT = 0x83750002u32 as HRESULT; pub const WEB_E_MISSING_REQUIRED_ELEMENT: HRESULT = 0x83750003u32 as HRESULT; pub const WEB_E_MISSING_REQUIRED_ATTRIBUTE: HRESULT = 0x83750004u32 as HRESULT; pub const WEB_E_UNEXPECTED_CONTENT: HRESULT = 0x83750005u32 as HRESULT; pub const WEB_E_RESOURCE_TOO_LARGE: HRESULT = 0x83750006u32 as HRESULT; pub const WEB_E_INVALID_JSON_STRING: HRESULT = 0x83750007u32 as HRESULT; pub const WEB_E_INVALID_JSON_NUMBER: HRESULT = 0x83750008u32 as HRESULT; pub const WEB_E_JSON_VALUE_NOT_FOUND: HRESULT = 0x83750009u32 as HRESULT; pub const HTTP_E_STATUS_UNEXPECTED: HRESULT = 0x80190001u32 as HRESULT; pub const HTTP_E_STATUS_UNEXPECTED_REDIRECTION: HRESULT = 0x80190003u32 as HRESULT; pub const HTTP_E_STATUS_UNEXPECTED_CLIENT_ERROR: HRESULT = 0x80190004u32 as HRESULT; pub const HTTP_E_STATUS_UNEXPECTED_SERVER_ERROR: HRESULT = 0x80190005u32 as HRESULT; pub const HTTP_E_STATUS_AMBIGUOUS: HRESULT = 0x8019012Cu32 as HRESULT; pub const HTTP_E_STATUS_MOVED: HRESULT = 0x8019012Du32 as HRESULT; pub const HTTP_E_STATUS_REDIRECT: HRESULT = 0x8019012Eu32 as HRESULT; pub const HTTP_E_STATUS_REDIRECT_METHOD: HRESULT = 0x8019012Fu32 as HRESULT; pub const HTTP_E_STATUS_NOT_MODIFIED: HRESULT = 0x80190130u32 as HRESULT; pub const HTTP_E_STATUS_USE_PROXY: HRESULT = 0x80190131u32 as HRESULT; pub const HTTP_E_STATUS_REDIRECT_KEEP_VERB: HRESULT = 0x80190133u32 as HRESULT; pub const HTTP_E_STATUS_BAD_REQUEST: HRESULT = 0x80190190u32 as HRESULT; pub const HTTP_E_STATUS_DENIED: HRESULT = 0x80190191u32 as HRESULT; pub const HTTP_E_STATUS_PAYMENT_REQ: HRESULT = 0x80190192u32 as HRESULT; pub const HTTP_E_STATUS_FORBIDDEN: HRESULT = 0x80190193u32 as HRESULT; pub const HTTP_E_STATUS_NOT_FOUND: HRESULT = 0x80190194u32 as HRESULT; pub const HTTP_E_STATUS_BAD_METHOD: HRESULT = 0x80190195u32 as HRESULT; pub const HTTP_E_STATUS_NONE_ACCEPTABLE: HRESULT = 0x80190196u32 as HRESULT; pub const HTTP_E_STATUS_PROXY_AUTH_REQ: HRESULT = 0x80190197u32 as HRESULT; pub const HTTP_E_STATUS_REQUEST_TIMEOUT: HRESULT = 0x80190198u32 as HRESULT; pub const HTTP_E_STATUS_CONFLICT: HRESULT = 0x80190199u32 as HRESULT; pub const HTTP_E_STATUS_GONE: HRESULT = 0x8019019Au32 as HRESULT; pub const HTTP_E_STATUS_LENGTH_REQUIRED: HRESULT = 0x8019019Bu32 as HRESULT; pub const HTTP_E_STATUS_PRECOND_FAILED: HRESULT = 0x8019019Cu32 as HRESULT; pub const HTTP_E_STATUS_REQUEST_TOO_LARGE: HRESULT = 0x8019019Du32 as HRESULT; pub const HTTP_E_STATUS_URI_TOO_LONG: HRESULT = 0x8019019Eu32 as HRESULT; pub const HTTP_E_STATUS_UNSUPPORTED_MEDIA: HRESULT = 0x8019019Fu32 as HRESULT; pub const HTTP_E_STATUS_RANGE_NOT_SATISFIABLE: HRESULT = 0x801901A0u32 as HRESULT; pub const HTTP_E_STATUS_EXPECTATION_FAILED: HRESULT = 0x801901A1u32 as HRESULT; pub const HTTP_E_STATUS_SERVER_ERROR: HRESULT = 0x801901F4u32 as HRESULT; pub const HTTP_E_STATUS_NOT_SUPPORTED: HRESULT = 0x801901F5u32 as HRESULT; pub const HTTP_E_STATUS_BAD_GATEWAY: HRESULT = 0x801901F6u32 as HRESULT; pub const HTTP_E_STATUS_SERVICE_UNAVAIL: HRESULT = 0x801901F7u32 as HRESULT; pub const HTTP_E_STATUS_GATEWAY_TIMEOUT: HRESULT = 0x801901F8u32 as HRESULT; pub const HTTP_E_STATUS_VERSION_NOT_SUP: HRESULT = 0x801901F9u32 as HRESULT; pub const E_INVALID_PROTOCOL_OPERATION: HRESULT = 0x83760001u32 as HRESULT; pub const E_INVALID_PROTOCOL_FORMAT: HRESULT = 0x83760002u32 as HRESULT; pub const E_PROTOCOL_EXTENSIONS_NOT_SUPPORTED: HRESULT = 0x83760003u32 as HRESULT; pub const E_SUBPROTOCOL_NOT_SUPPORTED: HRESULT = 0x83760004u32 as HRESULT; pub const E_PROTOCOL_VERSION_NOT_SUPPORTED: HRESULT = 0x83760005u32 as HRESULT; pub const INPUT_E_OUT_OF_ORDER: HRESULT = 0x80400000u32 as HRESULT; pub const INPUT_E_REENTRANCY: HRESULT = 0x80400001u32 as HRESULT; pub const INPUT_E_MULTIMODAL: HRESULT = 0x80400002u32 as HRESULT; pub const INPUT_E_PACKET: HRESULT = 0x80400003u32 as HRESULT; pub const INPUT_E_FRAME: HRESULT = 0x80400004u32 as HRESULT; pub const INPUT_E_HISTORY: HRESULT = 0x80400005u32 as HRESULT; pub const INPUT_E_DEVICE_INFO: HRESULT = 0x80400006u32 as HRESULT; pub const INPUT_E_TRANSFORM: HRESULT = 0x80400007u32 as HRESULT; pub const INPUT_E_DEVICE_PROPERTY: HRESULT = 0x80400008u32 as HRESULT; pub const INET_E_INVALID_URL: HRESULT = 0x800C0002u32 as HRESULT; pub const INET_E_NO_SESSION: HRESULT = 0x800C0003u32 as HRESULT; pub const INET_E_CANNOT_CONNECT: HRESULT = 0x800C0004u32 as HRESULT; pub const INET_E_RESOURCE_NOT_FOUND: HRESULT = 0x800C0005u32 as HRESULT; pub const INET_E_OBJECT_NOT_FOUND: HRESULT = 0x800C0006u32 as HRESULT; pub const INET_E_DATA_NOT_AVAILABLE: HRESULT = 0x800C0007u32 as HRESULT; pub const INET_E_DOWNLOAD_FAILURE: HRESULT = 0x800C0008u32 as HRESULT; pub const INET_E_AUTHENTICATION_REQUIRED: HRESULT = 0x800C0009u32 as HRESULT; pub const INET_E_NO_VALID_MEDIA: HRESULT = 0x800C000Au32 as HRESULT; pub const INET_E_CONNECTION_TIMEOUT: HRESULT = 0x800C000Bu32 as HRESULT; pub const INET_E_INVALID_REQUEST: HRESULT = 0x800C000Cu32 as HRESULT; pub const INET_E_UNKNOWN_PROTOCOL: HRESULT = 0x800C000Du32 as HRESULT; pub const INET_E_SECURITY_PROBLEM: HRESULT = 0x800C000Eu32 as HRESULT; pub const INET_E_CANNOT_LOAD_DATA: HRESULT = 0x800C000Fu32 as HRESULT; pub const INET_E_CANNOT_INSTANTIATE_OBJECT: HRESULT = 0x800C0010u32 as HRESULT; pub const INET_E_INVALID_CERTIFICATE: HRESULT = 0x800C0019u32 as HRESULT; pub const INET_E_REDIRECT_FAILED: HRESULT = 0x800C0014u32 as HRESULT; pub const INET_E_REDIRECT_TO_DIR: HRESULT = 0x800C0015u32 as HRESULT; pub const ERROR_DBG_CREATE_PROCESS_FAILURE_LOCKDOWN: HRESULT = 0x80B00001u32 as HRESULT; pub const ERROR_DBG_ATTACH_PROCESS_FAILURE_LOCKDOWN: HRESULT = 0x80B00002u32 as HRESULT; pub const ERROR_DBG_CONNECT_SERVER_FAILURE_LOCKDOWN: HRESULT = 0x80B00003u32 as HRESULT; pub const ERROR_DBG_START_SERVER_FAILURE_LOCKDOWN: HRESULT = 0x80B00004u32 as HRESULT; pub const ERROR_IO_PREEMPTED: HRESULT = 0x89010001u32 as HRESULT; pub const JSCRIPT_E_CANTEXECUTE: HRESULT = 0x89020001u32 as HRESULT; pub const WEP_E_NOT_PROVISIONED_ON_ALL_VOLUMES: HRESULT = 0x88010001u32 as HRESULT; pub const WEP_E_FIXED_DATA_NOT_SUPPORTED: HRESULT = 0x88010002u32 as HRESULT; pub const WEP_E_HARDWARE_NOT_COMPLIANT: HRESULT = 0x88010003u32 as HRESULT; pub const WEP_E_LOCK_NOT_CONFIGURED: HRESULT = 0x88010004u32 as HRESULT; pub const WEP_E_PROTECTION_SUSPENDED: HRESULT = 0x88010005u32 as HRESULT; pub const WEP_E_NO_LICENSE: HRESULT = 0x88010006u32 as HRESULT; pub const WEP_E_OS_NOT_PROTECTED: HRESULT = 0x88010007u32 as HRESULT; pub const WEP_E_UNEXPECTED_FAIL: HRESULT = 0x88010008u32 as HRESULT; pub const WEP_E_BUFFER_TOO_LARGE: HRESULT = 0x88010009u32 as HRESULT; pub const ERROR_SVHDX_ERROR_STORED: HRESULT = 0xC05C0000u32 as HRESULT; pub const ERROR_SVHDX_ERROR_NOT_AVAILABLE: HRESULT = 0xC05CFF00u32 as HRESULT; pub const ERROR_SVHDX_UNIT_ATTENTION_AVAILABLE: HRESULT = 0xC05CFF01u32 as HRESULT; pub const ERROR_SVHDX_UNIT_ATTENTION_CAPACITY_DATA_CHANGED: HRESULT = 0xC05CFF02u32 as HRESULT; pub const ERROR_SVHDX_UNIT_ATTENTION_RESERVATIONS_PREEMPTED: HRESULT = 0xC05CFF03u32 as HRESULT; pub const ERROR_SVHDX_UNIT_ATTENTION_RESERVATIONS_RELEASED: HRESULT = 0xC05CFF04u32 as HRESULT; pub const ERROR_SVHDX_UNIT_ATTENTION_REGISTRATIONS_PREEMPTED: HRESULT = 0xC05CFF05u32 as HRESULT; pub const ERROR_SVHDX_UNIT_ATTENTION_OPERATING_DEFINITION_CHANGED: HRESULT = 0xC05CFF06u32 as HRESULT; pub const ERROR_SVHDX_RESERVATION_CONFLICT: HRESULT = 0xC05CFF07u32 as HRESULT; pub const ERROR_SVHDX_WRONG_FILE_TYPE: HRESULT = 0xC05CFF08u32 as HRESULT; pub const ERROR_SVHDX_VERSION_MISMATCH: HRESULT = 0xC05CFF09u32 as HRESULT; pub const ERROR_VHD_SHARED: HRESULT = 0xC05CFF0Au32 as HRESULT; pub const WININET_E_OUT_OF_HANDLES: HRESULT = 0x80072EE1u32 as HRESULT; pub const WININET_E_TIMEOUT: HRESULT = 0x80072EE2u32 as HRESULT; pub const WININET_E_EXTENDED_ERROR: HRESULT = 0x80072EE3u32 as HRESULT; pub const WININET_E_INTERNAL_ERROR: HRESULT = 0x80072EE4u32 as HRESULT; pub const WININET_E_INVALID_URL: HRESULT = 0x80072EE5u32 as HRESULT; pub const WININET_E_UNRECOGNIZED_SCHEME: HRESULT = 0x80072EE6u32 as HRESULT; pub const WININET_E_NAME_NOT_RESOLVED: HRESULT = 0x80072EE7u32 as HRESULT; pub const WININET_E_PROTOCOL_NOT_FOUND: HRESULT = 0x80072EE8u32 as HRESULT; pub const WININET_E_INVALID_OPTION: HRESULT = 0x80072EE9u32 as HRESULT; pub const WININET_E_BAD_OPTION_LENGTH: HRESULT = 0x80072EEAu32 as HRESULT; pub const WININET_E_OPTION_NOT_SETTABLE: HRESULT = 0x80072EEBu32 as HRESULT; pub const WININET_E_SHUTDOWN: HRESULT = 0x80072EECu32 as HRESULT; pub const WININET_E_INCORRECT_USER_NAME: HRESULT = 0x80072EEDu32 as HRESULT; pub const WININET_E_INCORRECT_PASSWORD: HRESULT = 0x80072EEEu32 as HRESULT; pub const WININET_E_LOGIN_FAILURE: HRESULT = 0x80072EEFu32 as HRESULT; pub const WININET_E_INVALID_OPERATION: HRESULT = 0x80072EF0u32 as HRESULT; pub const WININET_E_OPERATION_CANCELLED: HRESULT = 0x80072EF1u32 as HRESULT; pub const WININET_E_INCORRECT_HANDLE_TYPE: HRESULT = 0x80072EF2u32 as HRESULT; pub const WININET_E_INCORRECT_HANDLE_STATE: HRESULT = 0x80072EF3u32 as HRESULT; pub const WININET_E_NOT_PROXY_REQUEST: HRESULT = 0x80072EF4u32 as HRESULT; pub const WININET_E_REGISTRY_VALUE_NOT_FOUND: HRESULT = 0x80072EF5u32 as HRESULT; pub const WININET_E_BAD_REGISTRY_PARAMETER: HRESULT = 0x80072EF6u32 as HRESULT; pub const WININET_E_NO_DIRECT_ACCESS: HRESULT = 0x80072EF7u32 as HRESULT; pub const WININET_E_NO_CONTEXT: HRESULT = 0x80072EF8u32 as HRESULT; pub const WININET_E_NO_CALLBACK: HRESULT = 0x80072EF9u32 as HRESULT; pub const WININET_E_REQUEST_PENDING: HRESULT = 0x80072EFAu32 as HRESULT; pub const WININET_E_INCORRECT_FORMAT: HRESULT = 0x80072EFBu32 as HRESULT; pub const WININET_E_ITEM_NOT_FOUND: HRESULT = 0x80072EFCu32 as HRESULT; pub const WININET_E_CANNOT_CONNECT: HRESULT = 0x80072EFDu32 as HRESULT; pub const WININET_E_CONNECTION_ABORTED: HRESULT = 0x80072EFEu32 as HRESULT; pub const WININET_E_CONNECTION_RESET: HRESULT = 0x80072EFFu32 as HRESULT; pub const WININET_E_FORCE_RETRY: HRESULT = 0x80072F00u32 as HRESULT; pub const WININET_E_INVALID_PROXY_REQUEST: HRESULT = 0x80072F01u32 as HRESULT; pub const WININET_E_NEED_UI: HRESULT = 0x80072F02u32 as HRESULT; pub const WININET_E_HANDLE_EXISTS: HRESULT = 0x80072F04u32 as HRESULT; pub const WININET_E_SEC_CERT_DATE_INVALID: HRESULT = 0x80072F05u32 as HRESULT; pub const WININET_E_SEC_CERT_CN_INVALID: HRESULT = 0x80072F06u32 as HRESULT; pub const WININET_E_HTTP_TO_HTTPS_ON_REDIR: HRESULT = 0x80072F07u32 as HRESULT; pub const WININET_E_HTTPS_TO_HTTP_ON_REDIR: HRESULT = 0x80072F08u32 as HRESULT; pub const WININET_E_MIXED_SECURITY: HRESULT = 0x80072F09u32 as HRESULT; pub const WININET_E_CHG_POST_IS_NON_SECURE: HRESULT = 0x80072F0Au32 as HRESULT; pub const WININET_E_POST_IS_NON_SECURE: HRESULT = 0x80072F0Bu32 as HRESULT; pub const WININET_E_CLIENT_AUTH_CERT_NEEDED: HRESULT = 0x80072F0Cu32 as HRESULT; pub const WININET_E_INVALID_CA: HRESULT = 0x80072F0Du32 as HRESULT; pub const WININET_E_CLIENT_AUTH_NOT_SETUP: HRESULT = 0x80072F0Eu32 as HRESULT; pub const WININET_E_ASYNC_THREAD_FAILED: HRESULT = 0x80072F0Fu32 as HRESULT; pub const WININET_E_REDIRECT_SCHEME_CHANGE: HRESULT = 0x80072F10u32 as HRESULT; pub const WININET_E_DIALOG_PENDING: HRESULT = 0x80072F11u32 as HRESULT; pub const WININET_E_RETRY_DIALOG: HRESULT = 0x80072F12u32 as HRESULT; pub const WININET_E_NO_NEW_CONTAINERS: HRESULT = 0x80072F13u32 as HRESULT; pub const WININET_E_HTTPS_HTTP_SUBMIT_REDIR: HRESULT = 0x80072F14u32 as HRESULT; pub const WININET_E_SEC_CERT_ERRORS: HRESULT = 0x80072F17u32 as HRESULT; pub const WININET_E_SEC_CERT_REV_FAILED: HRESULT = 0x80072F19u32 as HRESULT; pub const WININET_E_HEADER_NOT_FOUND: HRESULT = 0x80072F76u32 as HRESULT; pub const WININET_E_DOWNLEVEL_SERVER: HRESULT = 0x80072F77u32 as HRESULT; pub const WININET_E_INVALID_SERVER_RESPONSE: HRESULT = 0x80072F78u32 as HRESULT; pub const WININET_E_INVALID_HEADER: HRESULT = 0x80072F79u32 as HRESULT; pub const WININET_E_INVALID_QUERY_REQUEST: HRESULT = 0x80072F7Au32 as HRESULT; pub const WININET_E_HEADER_ALREADY_EXISTS: HRESULT = 0x80072F7Bu32 as HRESULT; pub const WININET_E_REDIRECT_FAILED: HRESULT = 0x80072F7Cu32 as HRESULT; pub const WININET_E_SECURITY_CHANNEL_ERROR: HRESULT = 0x80072F7Du32 as HRESULT; pub const WININET_E_UNABLE_TO_CACHE_FILE: HRESULT = 0x80072F7Eu32 as HRESULT; pub const WININET_E_TCPIP_NOT_INSTALLED: HRESULT = 0x80072F7Fu32 as HRESULT; pub const WININET_E_DISCONNECTED: HRESULT = 0x80072F83u32 as HRESULT; pub const WININET_E_SERVER_UNREACHABLE: HRESULT = 0x80072F84u32 as HRESULT; pub const WININET_E_PROXY_SERVER_UNREACHABLE: HRESULT = 0x80072F85u32 as HRESULT; pub const WININET_E_BAD_AUTO_PROXY_SCRIPT: HRESULT = 0x80072F86u32 as HRESULT; pub const WININET_E_UNABLE_TO_DOWNLOAD_SCRIPT: HRESULT = 0x80072F87u32 as HRESULT; pub const WININET_E_SEC_INVALID_CERT: HRESULT = 0x80072F89u32 as HRESULT; pub const WININET_E_SEC_CERT_REVOKED: HRESULT = 0x80072F8Au32 as HRESULT; pub const WININET_E_FAILED_DUETOSECURITYCHECK: HRESULT = 0x80072F8Bu32 as HRESULT; pub const WININET_E_NOT_INITIALIZED: HRESULT = 0x80072F8Cu32 as HRESULT; pub const WININET_E_LOGIN_FAILURE_DISPLAY_ENTITY_BODY: HRESULT = 0x80072F8Eu32 as HRESULT; pub const WININET_E_DECODING_FAILED: HRESULT = 0x80072F8Fu32 as HRESULT; pub const WININET_E_NOT_REDIRECTED: HRESULT = 0x80072F80u32 as HRESULT; pub const WININET_E_COOKIE_NEEDS_CONFIRMATION: HRESULT = 0x80072F81u32 as HRESULT; pub const WININET_E_COOKIE_DECLINED: HRESULT = 0x80072F82u32 as HRESULT; pub const WININET_E_REDIRECT_NEEDS_CONFIRMATION: HRESULT = 0x80072F88u32 as HRESULT; deps/winapi-0.2.5/src/inaddr.rs0000644000000000000000000000114212613167613015040 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! IPv4 Internet address STRUCT!{struct in_addr_S_un_b { s_b1: ::UCHAR, s_b2: ::UCHAR, s_b3: ::UCHAR, s_b4: ::UCHAR, }} STRUCT!{struct in_addr_S_un_w { s_w1: ::USHORT, s_w2: ::USHORT, }} STRUCT!{struct in_addr { S_un: ::ULONG, }} UNION!(in_addr, S_un, S_un_b, S_un_b_mut, in_addr_S_un_b); UNION!(in_addr, S_un, S_un_w, S_un_w_mut, in_addr_S_un_w); UNION!(in_addr, S_un, S_addr, S_addr_mut, ::ULONG); pub type IN_ADDR = in_addr; pub type PIN_ADDR = *mut in_addr; pub type LPIN_ADDR = *mut in_addr; deps/winapi-0.2.5/src/hidpi.rs0000644000000000000000000001215612615662007014702 0ustar rootroot// Copyright © 2015, Alex Daniel Jones // Licensed under the MIT License // Taken from hidpi.h ENUM!{enum HIDP_REPORT_TYPE { HidP_Input, HidP_Output, HidP_Feature, }} STRUCT!{struct USAGE_AND_PAGE { Usage: ::USAGE, UsagePage: ::USAGE, }} pub type PUSAGE_AND_PAGE = *mut USAGE_AND_PAGE; STRUCT!{struct HIDP_BUTTON_CAPS { UsagePage: ::USAGE, ReportID: ::UCHAR, IsAlias: ::BOOLEAN, BitField: ::USHORT, LinkCollection: ::USHORT, LinkUsage: ::USAGE, LinkUsagePage: ::USAGE, IsRange: ::BOOLEAN, IsStringRange: ::BOOLEAN, IsDesignatorRange: ::BOOLEAN, IsAbsolute: ::BOOLEAN, Reserved: [::ULONG; 10], S_un: [u8; 16], }} UNION!(HIDP_BUTTON_CAPS, S_un, Range, Range_mut, HIDP_RANGE_STRUCT); UNION!(HIDP_BUTTON_CAPS, S_un, NotRange, NotRange_mut, HIDP_NOTRANGE_STRUCT); pub type PHIDP_BUTTON_CAPS = *mut HIDP_BUTTON_CAPS; STRUCT!{struct HIDP_RANGE_STRUCT { UsageMin: ::USAGE, UsageMax: ::USAGE, StringMin: ::USHORT, StringMax: ::USHORT, DesignatorMin: ::USHORT, DesignatorMax: ::USHORT, DataIndexMin: ::USHORT, DataIndexMax: ::USHORT, }} STRUCT!{struct HIDP_NOTRANGE_STRUCT { Usage: ::USAGE, Reserved1: ::USAGE, StringIndex: ::USHORT, Reserved2: ::USHORT, DesignatorIndex: ::USHORT, Reserved3: ::USHORT, DataIndex: ::USHORT, Reserved4: ::USHORT, }} STRUCT!{struct HIDP_VALUE_CAPS { UsagePage: ::USAGE, ReportID: ::UCHAR, IsAlias: ::BOOLEAN, BitField: ::USHORT, LinkCollection: ::USHORT, LinkUsage: ::USAGE, LinkUsagePage: ::USAGE, IsRange: ::BOOLEAN, IsStringRange: ::BOOLEAN, IsDesignatorRange: ::BOOLEAN, IsAbsolute: ::BOOLEAN, HasNull: ::BOOLEAN, Reserved: ::UCHAR, BitSize: ::USHORT, ReportCount: ::USHORT, Reserved2: [::USHORT; 5], UnitsExp: ::ULONG, Units: ::ULONG, LogicalMin: ::LONG, LogicalMax: ::LONG, PhysicalMin: ::LONG, PhysicalMax: ::LONG, S_un: [u8; 16], }} UNION!(HIDP_VALUE_CAPS, S_un, Range, Range_mut, HIDP_RANGE_STRUCT); UNION!(HIDP_VALUE_CAPS, S_un, NotRange, NotRange_mut, HIDP_NOTRANGE_STRUCT); pub type PHIDP_VALUE_CAPS = *mut HIDP_VALUE_CAPS; STRUCT!{struct HIDP_LINK_COLLECTION_NODE { LinkUsage: ::USAGE, LinkUsagePage: ::USAGE, Parent: ::USHORT, NumberOfChildren: ::USHORT, NextSibling: ::USHORT, FirstChild: ::USHORT, bit_fields: ::ULONG, UserContext: ::PVOID, }} BITFIELD!(HIDP_LINK_COLLECTION_NODE bit_fields: ::ULONG [ CollectionType set_CollectionType[0..8], IsAlias set_IsAlias[8..9], Reserved set_Reserved[9..32], ]); pub type PHIDP_LINK_COLLECTION_NODE = *mut HIDP_LINK_COLLECTION_NODE; STRUCT!{struct HIDP_CAPS { Usage: ::USAGE, UsagePage: ::USAGE, InputReportByteLength: ::USHORT, OutputReportByteLength: ::USHORT, FeatureReportByteLength: ::USHORT, Reserved: [::USHORT; 17], NumberLinkCollectionNodes: ::USHORT, NumberInputButtonCaps: ::USHORT, NumberInputValueCaps: ::USHORT, NumberInputDataIndices: ::USHORT, NumberOutputButtonCaps: ::USHORT, NumberOutputValueCaps: ::USHORT, NumberOutputDataIndices: ::USHORT, NumberFeatureButtonCaps: ::USHORT, NumberFeatureValueCaps: ::USHORT, NumberFeatureDataIndices: ::USHORT, }} pub type PHIDP_CAPS = *mut HIDP_CAPS; STRUCT!{struct HIDP_DATA { DataIndex: ::USHORT, Reserved: ::USHORT, S_un: [u8; 4], }} UNION!(HIDP_DATA, S_un, RawValue, RawValue_mut, ::ULONG); UNION!(HIDP_DATA, S_un, On, On_mut, ::BOOLEAN); pub type PHIDP_DATA = *mut HIDP_DATA; STRUCT!{struct HIDP_UNKNOWN_TOKEN { Token: ::UCHAR, Reserved: [::UCHAR; 3], BitField: ::ULONG, }} pub type PHIDP_UNKNOWN_TOKEN = *mut HIDP_UNKNOWN_TOKEN; STRUCT!{struct HIDP_EXTENDED_ATTRIBUTES { NumGlobalUnknowns: ::UCHAR, Reserved: [::UCHAR; 3], GlobalUnknowns: ::PHIDP_UNKNOWN_TOKEN, Data: [::ULONG; 1], }} pub type PHIDP_EXTENDED_ATTRIBUTES = *mut HIDP_EXTENDED_ATTRIBUTES; pub const HIDP_STATUS_SUCCESS: ::NTSTATUS = 0x00110000; pub const HIDP_STATUS_NULL: ::NTSTATUS = 0x08110001; pub const HIDP_STATUS_INVALID_PREPARSED_DATA: ::NTSTATUS = 0x0C110001; pub const HIDP_STATUS_INVALID_REPORT_TYPE: ::NTSTATUS = 0x0C110002; pub const HIDP_STATUS_INVALID_REPORT_LENGTH: ::NTSTATUS = 0x0C110003; pub const HIDP_STATUS_USAGE_NOT_FOUND: ::NTSTATUS = 0x0C110004; pub const HIDP_STATUS_VALUE_OUT_OF_RANGE: ::NTSTATUS = 0x0C110005; pub const HIDP_STATUS_BAD_LOG_PHY_VALUES: ::NTSTATUS = 0x0C110006; pub const HIDP_STATUS_BUFFER_TOO_SMALL: ::NTSTATUS = 0x0C110007; pub const HIDP_STATUS_INTERNAL_ERROR: ::NTSTATUS = 0x0C110008; pub const HIDP_STATUS_I8042_TRANS_UNKNOWN: ::NTSTATUS = 0x0C110009; pub const HIDP_STATUS_INCOMPATIBLE_REPORT_ID: ::NTSTATUS = 0x0C11000A; pub const HIDP_STATUS_NOT_VALUE_ARRAY: ::NTSTATUS = 0x0C11000B; pub const HIDP_STATUS_IS_VALUE_ARRAY: ::NTSTATUS = 0x0C11000C; pub const HIDP_STATUS_DATA_INDEX_NOT_FOUND: ::NTSTATUS = 0x0C11000D; pub const HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE: ::NTSTATUS = 0x0C11000E; pub const HIDP_STATUS_BUTTON_NOT_PRESSED: ::NTSTATUS = 0x0C11000F; pub const HIDP_STATUS_REPORT_DOES_NOT_EXIST: ::NTSTATUS = 0x0C110010; pub const HIDP_STATUS_NOT_IMPLEMENTED: ::NTSTATUS = 0x0C110020; deps/winapi-0.2.5/src/d3d12.rs0000644000000000000000000030012712620206246014413 0ustar rootroot// Copyright © 2015, Dmitry Roschin // Licensed under the MIT License pub const D3D12_16BIT_INDEX_STRIP_CUT_VALUE: ::UINT = 0xffff; pub const D3D12_32BIT_INDEX_STRIP_CUT_VALUE: ::UINT = 0xffffffff; pub const D3D12_8BIT_INDEX_STRIP_CUT_VALUE: ::UINT = 0xff; pub const D3D12_ANISOTROPIC_FILTERING_BIT: ::UINT = 0x40; pub const D3D12_APPEND_ALIGNED_ELEMENT: ::UINT = 0xffffffff; pub const D3D12_ARRAY_AXIS_ADDRESS_RANGE_BIT_COUNT: ::UINT = 9; pub const D3D12_CLIP_OR_CULL_DISTANCE_COUNT: ::UINT = 8; pub const D3D12_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT: ::UINT = 2; pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT: ::UINT = 14; pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_COMPONENTS: ::UINT = 4; pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_HW_SLOT_COUNT: ::UINT = 15; pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_PARTIAL_UPDATE_EXTENTS_BYTE_ALIGNMENT: ::UINT = 16; pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COMPONENTS: ::UINT = 4; pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COUNT: ::UINT = 15; pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READS_PER_INST: ::UINT = 1; pub const D3D12_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_COMMONSHADER_FLOWCONTROL_NESTING_LIMIT: ::UINT = 64; pub const D3D12_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COMPONENTS: ::UINT = 4; pub const D3D12_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COUNT: ::UINT = 1; pub const D3D12_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READS_PER_INST: ::UINT = 1; pub const D3D12_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_COMMONSHADER_IMMEDIATE_VALUE_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_COMMONSHADER_INPUT_RESOURCE_REGISTER_COMPONENTS: ::UINT = 1; pub const D3D12_COMMONSHADER_INPUT_RESOURCE_REGISTER_COUNT: ::UINT = 128; pub const D3D12_COMMONSHADER_INPUT_RESOURCE_REGISTER_READS_PER_INST: ::UINT = 1; pub const D3D12_COMMONSHADER_INPUT_RESOURCE_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT: ::UINT = 128; pub const D3D12_COMMONSHADER_SAMPLER_REGISTER_COMPONENTS: ::UINT = 1; pub const D3D12_COMMONSHADER_SAMPLER_REGISTER_COUNT: ::UINT = 16; pub const D3D12_COMMONSHADER_SAMPLER_REGISTER_READS_PER_INST: ::UINT = 1; pub const D3D12_COMMONSHADER_SAMPLER_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_COMMONSHADER_SAMPLER_SLOT_COUNT: ::UINT = 16; pub const D3D12_COMMONSHADER_SUBROUTINE_NESTING_LIMIT: ::UINT = 32; pub const D3D12_COMMONSHADER_TEMP_REGISTER_COMPONENTS: ::UINT = 4; pub const D3D12_COMMONSHADER_TEMP_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_COMMONSHADER_TEMP_REGISTER_COUNT: ::UINT = 4096; pub const D3D12_COMMONSHADER_TEMP_REGISTER_READS_PER_INST: ::UINT = 3; pub const D3D12_COMMONSHADER_TEMP_REGISTER_READ_PORTS: ::UINT = 3; pub const D3D12_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MAX: ::UINT = 10; pub const D3D12_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MIN: ::INT = -10; pub const D3D12_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE: ::INT = -8; pub const D3D12_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE: ::UINT = 7; pub const D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT: ::UINT = 256; pub const D3D12_CS_4_X_BUCKET00_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::UINT = 256; pub const D3D12_CS_4_X_BUCKET00_MAX_NUM_THREADS_PER_GROUP: ::UINT = 64; pub const D3D12_CS_4_X_BUCKET01_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::UINT = 240; pub const D3D12_CS_4_X_BUCKET01_MAX_NUM_THREADS_PER_GROUP: ::UINT = 68; pub const D3D12_CS_4_X_BUCKET02_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::UINT = 224; pub const D3D12_CS_4_X_BUCKET02_MAX_NUM_THREADS_PER_GROUP: ::UINT = 72; pub const D3D12_CS_4_X_BUCKET03_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::UINT = 208; pub const D3D12_CS_4_X_BUCKET03_MAX_NUM_THREADS_PER_GROUP: ::UINT = 76; pub const D3D12_CS_4_X_BUCKET04_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::UINT = 192; pub const D3D12_CS_4_X_BUCKET04_MAX_NUM_THREADS_PER_GROUP: ::UINT = 84; pub const D3D12_CS_4_X_BUCKET05_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::UINT = 176; pub const D3D12_CS_4_X_BUCKET05_MAX_NUM_THREADS_PER_GROUP: ::UINT = 92; pub const D3D12_CS_4_X_BUCKET06_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::UINT = 160; pub const D3D12_CS_4_X_BUCKET06_MAX_NUM_THREADS_PER_GROUP: ::UINT = 100; pub const D3D12_CS_4_X_BUCKET07_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::UINT = 144; pub const D3D12_CS_4_X_BUCKET07_MAX_NUM_THREADS_PER_GROUP: ::UINT = 112; pub const D3D12_CS_4_X_BUCKET08_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::UINT = 128; pub const D3D12_CS_4_X_BUCKET08_MAX_NUM_THREADS_PER_GROUP: ::UINT = 128; pub const D3D12_CS_4_X_BUCKET09_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::UINT = 112; pub const D3D12_CS_4_X_BUCKET09_MAX_NUM_THREADS_PER_GROUP: ::UINT = 144; pub const D3D12_CS_4_X_BUCKET10_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::UINT = 96; pub const D3D12_CS_4_X_BUCKET10_MAX_NUM_THREADS_PER_GROUP: ::UINT = 168; pub const D3D12_CS_4_X_BUCKET11_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::UINT = 80; pub const D3D12_CS_4_X_BUCKET11_MAX_NUM_THREADS_PER_GROUP: ::UINT = 204; pub const D3D12_CS_4_X_BUCKET12_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::UINT = 64; pub const D3D12_CS_4_X_BUCKET12_MAX_NUM_THREADS_PER_GROUP: ::UINT = 256; pub const D3D12_CS_4_X_BUCKET13_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::UINT = 48; pub const D3D12_CS_4_X_BUCKET13_MAX_NUM_THREADS_PER_GROUP: ::UINT = 340; pub const D3D12_CS_4_X_BUCKET14_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::UINT = 32; pub const D3D12_CS_4_X_BUCKET14_MAX_NUM_THREADS_PER_GROUP: ::UINT = 512; pub const D3D12_CS_4_X_BUCKET15_MAX_BYTES_TGSM_WRITABLE_PER_THREAD: ::UINT = 16; pub const D3D12_CS_4_X_BUCKET15_MAX_NUM_THREADS_PER_GROUP: ::UINT = 768; pub const D3D12_CS_4_X_DISPATCH_MAX_THREAD_GROUPS_IN_Z_DIMENSION: ::UINT = 1; pub const D3D12_CS_4_X_RAW_UAV_BYTE_ALIGNMENT: ::UINT = 256; pub const D3D12_CS_4_X_THREAD_GROUP_MAX_THREADS_PER_GROUP: ::UINT = 768; pub const D3D12_CS_4_X_THREAD_GROUP_MAX_X: ::UINT = 768; pub const D3D12_CS_4_X_THREAD_GROUP_MAX_Y: ::UINT = 768; pub const D3D12_CS_4_X_UAV_REGISTER_COUNT: ::UINT = 1; pub const D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION: ::UINT = 65535; pub const D3D12_CS_TGSM_REGISTER_COUNT: ::UINT = 8192; pub const D3D12_CS_TGSM_REGISTER_READS_PER_INST: ::UINT = 1; pub const D3D12_CS_TGSM_RESOURCE_REGISTER_COMPONENTS: ::UINT = 1; pub const D3D12_CS_TGSM_RESOURCE_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_CS_THREADGROUPID_REGISTER_COMPONENTS: ::UINT = 3; pub const D3D12_CS_THREADGROUPID_REGISTER_COUNT: ::UINT = 1; pub const D3D12_CS_THREADIDINGROUPFLATTENED_REGISTER_COMPONENTS: ::UINT = 1; pub const D3D12_CS_THREADIDINGROUPFLATTENED_REGISTER_COUNT: ::UINT = 1; pub const D3D12_CS_THREADIDINGROUP_REGISTER_COMPONENTS: ::UINT = 3; pub const D3D12_CS_THREADIDINGROUP_REGISTER_COUNT: ::UINT = 1; pub const D3D12_CS_THREADID_REGISTER_COMPONENTS: ::UINT = 3; pub const D3D12_CS_THREADID_REGISTER_COUNT: ::UINT = 1; pub const D3D12_CS_THREAD_GROUP_MAX_THREADS_PER_GROUP: ::UINT = 1024; pub const D3D12_CS_THREAD_GROUP_MAX_X: ::UINT = 1024; pub const D3D12_CS_THREAD_GROUP_MAX_Y: ::UINT = 1024; pub const D3D12_CS_THREAD_GROUP_MAX_Z: ::UINT = 64; pub const D3D12_CS_THREAD_GROUP_MIN_X: ::UINT = 1; pub const D3D12_CS_THREAD_GROUP_MIN_Y: ::UINT = 1; pub const D3D12_CS_THREAD_GROUP_MIN_Z: ::UINT = 1; pub const D3D12_CS_THREAD_LOCAL_TEMP_REGISTER_POOL: ::UINT = 16384; pub const D3D12_DEFAULT_BLEND_FACTOR_ALPHA: ::FLOAT = 1.0; pub const D3D12_DEFAULT_BLEND_FACTOR_BLUE: ::FLOAT = 1.0; pub const D3D12_DEFAULT_BLEND_FACTOR_GREEN: ::FLOAT = 1.0; pub const D3D12_DEFAULT_BLEND_FACTOR_RED: ::FLOAT = 1.0; pub const D3D12_DEFAULT_BORDER_COLOR_COMPONENT: ::FLOAT = 0.0; pub const D3D12_DEFAULT_DEPTH_BIAS: ::UINT = 0; pub const D3D12_DEFAULT_DEPTH_BIAS_CLAMP: ::FLOAT = 0.0; pub const D3D12_DEFAULT_MAX_ANISOTROPY: ::UINT = 16; pub const D3D12_DEFAULT_MIP_LOD_BIAS: ::FLOAT = 0.0; pub const D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT: ::UINT = 4194304; pub const D3D12_DEFAULT_RENDER_TARGET_ARRAY_INDEX: ::UINT = 0; pub const D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT: ::UINT = 65536; pub const D3D12_DEFAULT_SAMPLE_MASK: ::UINT = 0xffffffff; pub const D3D12_DEFAULT_SCISSOR_ENDX: ::UINT = 0; pub const D3D12_DEFAULT_SCISSOR_ENDY: ::UINT = 0; pub const D3D12_DEFAULT_SCISSOR_STARTX: ::UINT = 0; pub const D3D12_DEFAULT_SCISSOR_STARTY: ::UINT = 0; pub const D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS: ::FLOAT = 0.0; pub const D3D12_DEFAULT_STENCIL_READ_MASK: ::UINT = 0xff; pub const D3D12_DEFAULT_STENCIL_REFERENCE: ::UINT = 0; pub const D3D12_DEFAULT_STENCIL_WRITE_MASK: ::UINT = 0xff; pub const D3D12_DEFAULT_VIEWPORT_AND_SCISSORRECT_INDEX: ::UINT = 0; pub const D3D12_DEFAULT_VIEWPORT_HEIGHT: ::UINT = 0; pub const D3D12_DEFAULT_VIEWPORT_MAX_DEPTH: ::FLOAT = 0.0; pub const D3D12_DEFAULT_VIEWPORT_MIN_DEPTH: ::FLOAT = 0.0; pub const D3D12_DEFAULT_VIEWPORT_TOPLEFTX: ::UINT = 0; pub const D3D12_DEFAULT_VIEWPORT_TOPLEFTY: ::UINT = 0; pub const D3D12_DEFAULT_VIEWPORT_WIDTH: ::UINT = 0; pub const D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND: ::UINT = 0xffffffff; pub const D3D12_DRIVER_RESERVED_REGISTER_SPACE_VALUES_END: ::UINT = 0xfffffff7; pub const D3D12_DRIVER_RESERVED_REGISTER_SPACE_VALUES_START: ::UINT = 0xfffffff0; pub const D3D12_DS_INPUT_CONTROL_POINTS_MAX_TOTAL_SCALARS: ::UINT = 3968; pub const D3D12_DS_INPUT_CONTROL_POINT_REGISTER_COMPONENTS: ::UINT = 4; pub const D3D12_DS_INPUT_CONTROL_POINT_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_DS_INPUT_CONTROL_POINT_REGISTER_COUNT: ::UINT = 32; pub const D3D12_DS_INPUT_CONTROL_POINT_REGISTER_READS_PER_INST: ::UINT = 2; pub const D3D12_DS_INPUT_CONTROL_POINT_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_DS_INPUT_DOMAIN_POINT_REGISTER_COMPONENTS: ::UINT = 3; pub const D3D12_DS_INPUT_DOMAIN_POINT_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_DS_INPUT_DOMAIN_POINT_REGISTER_COUNT: ::UINT = 1; pub const D3D12_DS_INPUT_DOMAIN_POINT_REGISTER_READS_PER_INST: ::UINT = 2; pub const D3D12_DS_INPUT_DOMAIN_POINT_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_DS_INPUT_PATCH_CONSTANT_REGISTER_COMPONENTS: ::UINT = 4; pub const D3D12_DS_INPUT_PATCH_CONSTANT_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_DS_INPUT_PATCH_CONSTANT_REGISTER_COUNT: ::UINT = 32; pub const D3D12_DS_INPUT_PATCH_CONSTANT_REGISTER_READS_PER_INST: ::UINT = 2; pub const D3D12_DS_INPUT_PATCH_CONSTANT_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_DS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENTS: ::UINT = 1; pub const D3D12_DS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_DS_INPUT_PRIMITIVE_ID_REGISTER_COUNT: ::UINT = 1; pub const D3D12_DS_INPUT_PRIMITIVE_ID_REGISTER_READS_PER_INST: ::UINT = 2; pub const D3D12_DS_INPUT_PRIMITIVE_ID_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_DS_OUTPUT_REGISTER_COMPONENTS: ::UINT = 4; pub const D3D12_DS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_DS_OUTPUT_REGISTER_COUNT: ::UINT = 32; pub const D3D12_FILTER_REDUCTION_TYPE_MASK: ::UINT = 0x3; pub const D3D12_FILTER_REDUCTION_TYPE_SHIFT: ::UINT = 7; pub const D3D12_FILTER_TYPE_MASK: ::UINT = 0x3; pub const D3D12_FLOAT16_FUSED_TOLERANCE_IN_ULP: ::DOUBLE = 0.6; pub const D3D12_FLOAT32_MAX: ::FLOAT = 3.402823466e+38; pub const D3D12_FLOAT32_TO_INTEGER_TOLERANCE_IN_ULP: ::FLOAT = 0.6; pub const D3D12_FLOAT_TO_SRGB_EXPONENT_DENOMINATOR: ::FLOAT = 2.4; pub const D3D12_FLOAT_TO_SRGB_EXPONENT_NUMERATOR: ::FLOAT = 1.0; pub const D3D12_FLOAT_TO_SRGB_OFFSET: ::FLOAT = 0.055; pub const D3D12_FLOAT_TO_SRGB_SCALE_1: ::FLOAT = 12.92; pub const D3D12_FLOAT_TO_SRGB_SCALE_2: ::FLOAT = 1.055; pub const D3D12_FLOAT_TO_SRGB_THRESHOLD: ::FLOAT = 0.0031308; pub const D3D12_FTOI_INSTRUCTION_MAX_INPUT: ::FLOAT = 2147483647.999; pub const D3D12_FTOI_INSTRUCTION_MIN_INPUT: ::FLOAT = -2147483648.999; pub const D3D12_FTOU_INSTRUCTION_MAX_INPUT: ::FLOAT = 4294967295.999; pub const D3D12_FTOU_INSTRUCTION_MIN_INPUT: ::FLOAT = 0.0; pub const D3D12_GS_INPUT_INSTANCE_ID_READS_PER_INST: ::UINT = 2; pub const D3D12_GS_INPUT_INSTANCE_ID_READ_PORTS: ::UINT = 1; pub const D3D12_GS_INPUT_INSTANCE_ID_REGISTER_COMPONENTS: ::UINT = 1; pub const D3D12_GS_INPUT_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_GS_INPUT_INSTANCE_ID_REGISTER_COUNT: ::UINT = 1; pub const D3D12_GS_INPUT_PRIM_CONST_REGISTER_COMPONENTS: ::UINT = 1; pub const D3D12_GS_INPUT_PRIM_CONST_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_GS_INPUT_PRIM_CONST_REGISTER_COUNT: ::UINT = 1; pub const D3D12_GS_INPUT_PRIM_CONST_REGISTER_READS_PER_INST: ::UINT = 2; pub const D3D12_GS_INPUT_PRIM_CONST_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_GS_INPUT_REGISTER_COMPONENTS: ::UINT = 4; pub const D3D12_GS_INPUT_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_GS_INPUT_REGISTER_COUNT: ::UINT = 32; pub const D3D12_GS_INPUT_REGISTER_READS_PER_INST: ::UINT = 2; pub const D3D12_GS_INPUT_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_GS_INPUT_REGISTER_VERTICES: ::UINT = 32; pub const D3D12_GS_MAX_INSTANCE_COUNT: ::UINT = 32; pub const D3D12_GS_MAX_OUTPUT_VERTEX_COUNT_ACROSS_INSTANCES: ::UINT = 1024; pub const D3D12_GS_OUTPUT_ELEMENTS: ::UINT = 32; pub const D3D12_GS_OUTPUT_REGISTER_COMPONENTS: ::UINT = 4; pub const D3D12_GS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_GS_OUTPUT_REGISTER_COUNT: ::UINT = 32; pub const D3D12_HS_CONTROL_POINT_PHASE_INPUT_REGISTER_COUNT: ::UINT = 32; pub const D3D12_HS_CONTROL_POINT_PHASE_OUTPUT_REGISTER_COUNT: ::UINT = 32; pub const D3D12_HS_CONTROL_POINT_REGISTER_COMPONENTS: ::UINT = 4; pub const D3D12_HS_CONTROL_POINT_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_HS_CONTROL_POINT_REGISTER_READS_PER_INST: ::UINT = 2; pub const D3D12_HS_CONTROL_POINT_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_HS_FORK_PHASE_INSTANCE_COUNT_UPPER_BOUND: ::UINT = 0xffffffff; pub const D3D12_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COMPONENTS: ::UINT = 1; pub const D3D12_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COUNT: ::UINT = 1; pub const D3D12_HS_INPUT_FORK_INSTANCE_ID_REGISTER_READS_PER_INST: ::UINT = 2; pub const D3D12_HS_INPUT_FORK_INSTANCE_ID_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COMPONENTS: ::UINT = 1; pub const D3D12_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COUNT: ::UINT = 1; pub const D3D12_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_READS_PER_INST: ::UINT = 2; pub const D3D12_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_HS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENTS: ::UINT = 1; pub const D3D12_HS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_HS_INPUT_PRIMITIVE_ID_REGISTER_COUNT: ::UINT = 1; pub const D3D12_HS_INPUT_PRIMITIVE_ID_REGISTER_READS_PER_INST: ::UINT = 2; pub const D3D12_HS_INPUT_PRIMITIVE_ID_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_HS_JOIN_PHASE_INSTANCE_COUNT_UPPER_BOUND: ::UINT = 0xffffffff; pub const D3D12_HS_MAXTESSFACTOR_LOWER_BOUND: ::FLOAT = 1.0; pub const D3D12_HS_MAXTESSFACTOR_UPPER_BOUND: ::FLOAT = 64.0; pub const D3D12_HS_OUTPUT_CONTROL_POINTS_MAX_TOTAL_SCALARS: ::UINT = 3968; pub const D3D12_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COMPONENTS: ::UINT = 1; pub const D3D12_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COUNT: ::UINT = 1; pub const D3D12_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_READS_PER_INST: ::UINT = 2; pub const D3D12_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COMPONENTS: ::UINT = 4; pub const D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COUNT: ::UINT = 32; pub const D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_READS_PER_INST: ::UINT = 2; pub const D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_SCALAR_COMPONENTS: ::UINT = 128; pub const D3D12_IA_DEFAULT_INDEX_BUFFER_OFFSET_IN_BYTES: ::UINT = 0; pub const D3D12_IA_DEFAULT_PRIMITIVE_TOPOLOGY: ::UINT = 0; pub const D3D12_IA_DEFAULT_VERTEX_BUFFER_OFFSET_IN_BYTES: ::UINT = 0; pub const D3D12_IA_INDEX_INPUT_RESOURCE_SLOT_COUNT: ::UINT = 1; pub const D3D12_IA_INSTANCE_ID_BIT_COUNT: ::UINT = 32; pub const D3D12_IA_INTEGER_ARITHMETIC_BIT_COUNT: ::UINT = 32; pub const D3D12_IA_PATCH_MAX_CONTROL_POINT_COUNT: ::UINT = 32; pub const D3D12_IA_PRIMITIVE_ID_BIT_COUNT: ::UINT = 32; pub const D3D12_IA_VERTEX_ID_BIT_COUNT: ::UINT = 32; pub const D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT: ::UINT = 32; pub const D3D12_IA_VERTEX_INPUT_STRUCTURE_ELEMENTS_COMPONENTS: ::UINT = 128; pub const D3D12_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT: ::UINT = 32; pub const D3D12_INTEGER_DIVIDE_BY_ZERO_QUOTIENT: ::UINT = 0xffffffff; pub const D3D12_INTEGER_DIVIDE_BY_ZERO_REMAINDER: ::UINT = 0xffffffff; pub const D3D12_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL: ::UINT = 0xffffffff; pub const D3D12_KEEP_UNORDERED_ACCESS_VIEWS: ::UINT = 0xffffffff; pub const D3D12_LINEAR_GAMMA: ::FLOAT = 1.0; pub const D3D12_MAG_FILTER_SHIFT: ::UINT = 2; pub const D3D12_MAJOR_VERSION: ::UINT = 12; pub const D3D12_MAX_BORDER_COLOR_COMPONENT: ::FLOAT = 1.0; pub const D3D12_MAX_DEPTH: ::FLOAT = 1.0; pub const D3D12_MAX_LIVE_STATIC_SAMPLERS: ::UINT = 2032; pub const D3D12_MAX_MAXANISOTROPY: ::UINT = 16; pub const D3D12_MAX_MULTISAMPLE_SAMPLE_COUNT: ::UINT = 32; pub const D3D12_MAX_POSITION_VALUE: ::FLOAT = 3.402823466e+34; pub const D3D12_MAX_ROOT_COST: ::UINT = 64; pub const D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_1: ::UINT = 1000000; pub const D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_2: ::UINT = 1000000; pub const D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE: ::UINT = 2048; pub const D3D12_MAX_TEXTURE_DIMENSION_2_TO_EXP: ::UINT = 17; pub const D3D12_MINOR_VERSION: ::UINT = 0; pub const D3D12_MIN_BORDER_COLOR_COMPONENT: ::FLOAT = 0.0; pub const D3D12_MIN_DEPTH: ::FLOAT = 0.0; pub const D3D12_MIN_FILTER_SHIFT: ::UINT = 4; pub const D3D12_MIN_MAXANISOTROPY: ::UINT = 0; pub const D3D12_MIP_FILTER_SHIFT: ::UINT = 0; pub const D3D12_MIP_LOD_BIAS_MAX: ::FLOAT = 15.99; pub const D3D12_MIP_LOD_BIAS_MIN: ::FLOAT = -16.0; pub const D3D12_MIP_LOD_FRACTIONAL_BIT_COUNT: ::UINT = 8; pub const D3D12_MIP_LOD_RANGE_BIT_COUNT: ::UINT = 8; pub const D3D12_MULTISAMPLE_ANTIALIAS_LINE_WIDTH: ::FLOAT = 1.4; pub const D3D12_NONSAMPLE_FETCH_OUT_OF_RANGE_ACCESS_RESULT: ::UINT = 0; pub const D3D12_OS_RESERVED_REGISTER_SPACE_VALUES_END: ::UINT = 0xffffffff; pub const D3D12_OS_RESERVED_REGISTER_SPACE_VALUES_START: ::UINT = 0xfffffff8; pub const D3D12_PACKED_TILE: ::UINT = 0xffffffff; pub const D3D12_PIXEL_ADDRESS_RANGE_BIT_COUNT: ::UINT = 15; pub const D3D12_PRE_SCISSOR_PIXEL_ADDRESS_RANGE_BIT_COUNT: ::UINT = 16; pub const D3D12_PS_CS_UAV_REGISTER_COMPONENTS: ::UINT = 1; pub const D3D12_PS_CS_UAV_REGISTER_COUNT: ::UINT = 8; pub const D3D12_PS_CS_UAV_REGISTER_READS_PER_INST: ::UINT = 1; pub const D3D12_PS_CS_UAV_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_PS_FRONTFACING_DEFAULT_VALUE: ::UINT = 0xffffffff; pub const D3D12_PS_FRONTFACING_FALSE_VALUE: ::UINT = 0; pub const D3D12_PS_FRONTFACING_TRUE_VALUE: ::UINT = 0xffffffff; pub const D3D12_PS_INPUT_REGISTER_COMPONENTS: ::UINT = 4; pub const D3D12_PS_INPUT_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_PS_INPUT_REGISTER_COUNT: ::UINT = 32; pub const D3D12_PS_INPUT_REGISTER_READS_PER_INST: ::UINT = 2; pub const D3D12_PS_INPUT_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_PS_LEGACY_PIXEL_CENTER_FRACTIONAL_COMPONENT: ::FLOAT = 0.0; pub const D3D12_PS_OUTPUT_DEPTH_REGISTER_COMPONENTS: ::UINT = 1; pub const D3D12_PS_OUTPUT_DEPTH_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_PS_OUTPUT_DEPTH_REGISTER_COUNT: ::UINT = 1; pub const D3D12_PS_OUTPUT_MASK_REGISTER_COMPONENTS: ::UINT = 1; pub const D3D12_PS_OUTPUT_MASK_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_PS_OUTPUT_MASK_REGISTER_COUNT: ::UINT = 1; pub const D3D12_PS_OUTPUT_REGISTER_COMPONENTS: ::UINT = 4; pub const D3D12_PS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_PS_OUTPUT_REGISTER_COUNT: ::UINT = 8; pub const D3D12_PS_PIXEL_CENTER_FRACTIONAL_COMPONENT: ::FLOAT = 0.5; pub const D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT: ::UINT = 16; pub const D3D12_REQ_BLEND_OBJECT_COUNT_PER_DEVICE: ::UINT = 4096; pub const D3D12_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP: ::UINT = 27; pub const D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT: ::UINT = 4096; pub const D3D12_REQ_DEPTH_STENCIL_OBJECT_COUNT_PER_DEVICE: ::UINT = 4096; pub const D3D12_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP: ::UINT = 32; pub const D3D12_REQ_DRAW_VERTEX_COUNT_2_TO_EXP: ::UINT = 32; pub const D3D12_REQ_FILTERING_HW_ADDRESSABLE_RESOURCE_DIMENSION: ::UINT = 16384; pub const D3D12_REQ_GS_INVOCATION_32BIT_OUTPUT_COMPONENT_LIMIT: ::UINT = 1024; pub const D3D12_REQ_IMMEDIATE_CONSTANT_BUFFER_ELEMENT_COUNT: ::UINT = 4096; pub const D3D12_REQ_MAXANISOTROPY: ::UINT = 16; pub const D3D12_REQ_MIP_LEVELS: ::UINT = 15; pub const D3D12_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES: ::UINT = 2048; pub const D3D12_REQ_RASTERIZER_OBJECT_COUNT_PER_DEVICE: ::UINT = 4096; pub const D3D12_REQ_RENDER_TO_BUFFER_WINDOW_WIDTH: ::UINT = 16384; pub const D3D12_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_A_TERM: ::UINT = 128; pub const D3D12_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_B_TERM: ::FLOAT = 0.25; pub const D3D12_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_C_TERM: ::UINT = 2048; pub const D3D12_REQ_RESOURCE_VIEW_COUNT_PER_DEVICE_2_TO_EXP: ::UINT = 20; pub const D3D12_REQ_SAMPLER_OBJECT_COUNT_PER_DEVICE: ::UINT = 4096; pub const D3D12_REQ_SUBRESOURCES: ::UINT = 30720; pub const D3D12_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION: ::UINT = 2048; pub const D3D12_REQ_TEXTURE1D_U_DIMENSION: ::UINT = 16384; pub const D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION: ::UINT = 2048; pub const D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION: ::UINT = 16384; pub const D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION: ::UINT = 2048; pub const D3D12_REQ_TEXTURECUBE_DIMENSION: ::UINT = 16384; pub const D3D12_RESINFO_INSTRUCTION_MISSING_COMPONENT_RETVAL: ::UINT = 0; pub const D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES: ::UINT = 0xffffffff; pub const D3D12_SHADER_COMPONENT_MAPPING_MASK: ::UINT = 0x7; pub const D3D12_SHADER_COMPONENT_MAPPING_SHIFT: ::UINT = 3; pub const D3D12_SHADER_MAJOR_VERSION: ::UINT = 5; pub const D3D12_SHADER_MAX_INSTANCES: ::UINT = 65535; pub const D3D12_SHADER_MAX_INTERFACES: ::UINT = 253; pub const D3D12_SHADER_MAX_INTERFACE_CALL_SITES: ::UINT = 4096; pub const D3D12_SHADER_MAX_TYPES: ::UINT = 65535; pub const D3D12_SHADER_MINOR_VERSION: ::UINT = 1; pub const D3D12_SHIFT_INSTRUCTION_PAD_VALUE: ::UINT = 0; pub const D3D12_SHIFT_INSTRUCTION_SHIFT_VALUE_BIT_COUNT: ::UINT = 5; pub const D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT: ::UINT = 8; pub const D3D12_SMALL_MSAA_RESOURCE_PLACEMENT_ALIGNMENT: ::UINT = 65536; pub const D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT: ::UINT = 4096; pub const D3D12_SO_BUFFER_MAX_STRIDE_IN_BYTES: ::UINT = 2048; pub const D3D12_SO_BUFFER_MAX_WRITE_WINDOW_IN_BYTES: ::UINT = 512; pub const D3D12_SO_BUFFER_SLOT_COUNT: ::UINT = 4; pub const D3D12_SO_DDI_REGISTER_INDEX_DENOTING_GAP: ::UINT = 0xffffffff; pub const D3D12_SO_NO_RASTERIZED_STREAM: ::UINT = 0xffffffff; pub const D3D12_SO_OUTPUT_COMPONENT_COUNT: ::UINT = 128; pub const D3D12_SO_STREAM_COUNT: ::UINT = 4; pub const D3D12_SPEC_DATE_DAY: ::UINT = 14; pub const D3D12_SPEC_DATE_MONTH: ::UINT = 11; pub const D3D12_SPEC_DATE_YEAR: ::UINT = 2014; pub const D3D12_SPEC_VERSION: ::DOUBLE = 1.16; pub const D3D12_SRGB_GAMMA: ::FLOAT = 2.2; pub const D3D12_SRGB_TO_FLOAT_DENOMINATOR_1: ::FLOAT = 12.92; pub const D3D12_SRGB_TO_FLOAT_DENOMINATOR_2: ::FLOAT = 1.055; pub const D3D12_SRGB_TO_FLOAT_EXPONENT: ::FLOAT = 2.4; pub const D3D12_SRGB_TO_FLOAT_OFFSET: ::FLOAT = 0.055; pub const D3D12_SRGB_TO_FLOAT_THRESHOLD: ::FLOAT = 0.04045; pub const D3D12_SRGB_TO_FLOAT_TOLERANCE_IN_ULP: ::FLOAT = 0.5; pub const D3D12_STANDARD_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_STANDARD_COMPONENT_BIT_COUNT_DOUBLED: ::UINT = 64; pub const D3D12_STANDARD_MAXIMUM_ELEMENT_ALIGNMENT_BYTE_MULTIPLE: ::UINT = 4; pub const D3D12_STANDARD_PIXEL_COMPONENT_COUNT: ::UINT = 128; pub const D3D12_STANDARD_PIXEL_ELEMENT_COUNT: ::UINT = 32; pub const D3D12_STANDARD_VECTOR_SIZE: ::UINT = 4; pub const D3D12_STANDARD_VERTEX_ELEMENT_COUNT: ::UINT = 32; pub const D3D12_STANDARD_VERTEX_TOTAL_COMPONENT_COUNT: ::UINT = 64; pub const D3D12_SUBPIXEL_FRACTIONAL_BIT_COUNT: ::UINT = 8; pub const D3D12_SUBTEXEL_FRACTIONAL_BIT_COUNT: ::UINT = 8; pub const D3D12_SYSTEM_RESERVED_REGISTER_SPACE_VALUES_END: ::UINT = 0xffffffff; pub const D3D12_SYSTEM_RESERVED_REGISTER_SPACE_VALUES_START: ::UINT = 0xfffffff0; pub const D3D12_TESSELLATOR_MAX_EVEN_TESSELLATION_FACTOR: ::UINT = 64; pub const D3D12_TESSELLATOR_MAX_ISOLINE_DENSITY_TESSELLATION_FACTOR: ::UINT = 64; pub const D3D12_TESSELLATOR_MAX_ODD_TESSELLATION_FACTOR: ::UINT = 63; pub const D3D12_TESSELLATOR_MAX_TESSELLATION_FACTOR: ::UINT = 64; pub const D3D12_TESSELLATOR_MIN_EVEN_TESSELLATION_FACTOR: ::UINT = 2; pub const D3D12_TESSELLATOR_MIN_ISOLINE_DENSITY_TESSELLATION_FACTOR: ::UINT = 1; pub const D3D12_TESSELLATOR_MIN_ODD_TESSELLATION_FACTOR: ::UINT = 1; pub const D3D12_TEXEL_ADDRESS_RANGE_BIT_COUNT: ::UINT = 16; pub const D3D12_TEXTURE_DATA_PITCH_ALIGNMENT: ::UINT = 256; pub const D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT: ::UINT = 512; pub const D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES: ::UINT = 65536; pub const D3D12_UAV_COUNTER_PLACEMENT_ALIGNMENT: ::UINT = 4096; pub const D3D12_UAV_SLOT_COUNT: ::UINT = 64; pub const D3D12_UNBOUND_MEMORY_ACCESS_RESULT: ::UINT = 0; pub const D3D12_VIEWPORT_AND_SCISSORRECT_MAX_INDEX: ::UINT = 15; pub const D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE: ::UINT = 16; pub const D3D12_VIEWPORT_BOUNDS_MAX: ::UINT = 32767; pub const D3D12_VIEWPORT_BOUNDS_MIN: ::INT = -32768; pub const D3D12_VS_INPUT_REGISTER_COMPONENTS: ::UINT = 4; pub const D3D12_VS_INPUT_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_VS_INPUT_REGISTER_COUNT: ::UINT = 32; pub const D3D12_VS_INPUT_REGISTER_READS_PER_INST: ::UINT = 2; pub const D3D12_VS_INPUT_REGISTER_READ_PORTS: ::UINT = 1; pub const D3D12_VS_OUTPUT_REGISTER_COMPONENTS: ::UINT = 4; pub const D3D12_VS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT: ::UINT = 32; pub const D3D12_VS_OUTPUT_REGISTER_COUNT: ::UINT = 32; pub const D3D12_WHQL_CONTEXT_COUNT_FOR_RESOURCE_LIMIT: ::UINT = 10; pub const D3D12_WHQL_DRAWINDEXED_INDEX_COUNT_2_TO_EXP: ::UINT = 25; pub const D3D12_WHQL_DRAW_VERTEX_COUNT_2_TO_EXP: ::UINT = 25; pub type D3D12_GPU_VIRTUAL_ADDRESS = ::UINT64; ENUM!{enum D3D12_COMMAND_LIST_TYPE { D3D12_COMMAND_LIST_TYPE_DIRECT = 0, D3D12_COMMAND_LIST_TYPE_BUNDLE = 1, D3D12_COMMAND_LIST_TYPE_COMPUTE = 2, D3D12_COMMAND_LIST_TYPE_COPY = 3, }} FLAGS!{enum D3D12_COMMAND_QUEUE_FLAGS { D3D12_COMMAND_QUEUE_FLAG_NONE = 0x0, D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT = 0x1, }} ENUM!{enum D3D12_COMMAND_QUEUE_PRIORITY { D3D12_COMMAND_QUEUE_PRIORITY_NORMAL = 0, D3D12_COMMAND_QUEUE_PRIORITY_HIGH = 100, }} STRUCT!{struct D3D12_COMMAND_QUEUE_DESC { Type: D3D12_COMMAND_LIST_TYPE, Priority: ::INT, Flags: D3D12_COMMAND_QUEUE_FLAGS, NodeMask: ::UINT, }} ENUM!{enum D3D12_PRIMITIVE_TOPOLOGY_TYPE { D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED = 0, D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT = 1, D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE = 2, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE = 3, D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH = 4, }} ENUM!{enum D3D12_INPUT_CLASSIFICATION { D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA = 0, D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA = 1, }} STRUCT!{struct D3D12_INPUT_ELEMENT_DESC { SemanticName: ::LPCSTR, SemanticIndex: ::UINT, Format: ::DXGI_FORMAT, InputSlot: ::UINT, AlignedByteOffset: ::UINT, InputSlotClass: D3D12_INPUT_CLASSIFICATION, InstanceDataStepRate: ::UINT, }} ENUM!{enum D3D12_FILL_MODE { D3D12_FILL_MODE_WIREFRAME = 2, D3D12_FILL_MODE_SOLID = 3, }} pub type D3D12_PRIMITIVE_TOPOLOGY = ::D3D_PRIMITIVE_TOPOLOGY; pub type D3D12_PRIMITIVE = ::D3D_PRIMITIVE; ENUM!{enum D3D12_CULL_MODE { D3D12_CULL_MODE_NONE = 1, D3D12_CULL_MODE_FRONT = 2, D3D12_CULL_MODE_BACK = 3, }} STRUCT!{struct D3D12_SO_DECLARATION_ENTRY { Stream: ::UINT, SemanticName: ::LPCSTR, SemanticIndex: ::UINT, StartComponent: ::BYTE, ComponentCount: ::BYTE, OutputSlot: ::BYTE, }} STRUCT!{struct D3D12_VIEWPORT { TopLeftX: ::FLOAT, TopLeftY: ::FLOAT, Width: ::FLOAT, Height: ::FLOAT, MinDepth: ::FLOAT, MaxDepth: ::FLOAT, }} pub type D3D12_RECT = ::RECT; STRUCT!{struct D3D12_BOX { left: ::UINT, top: ::UINT, front: ::UINT, right: ::UINT, bottom: ::UINT, back: ::UINT, }} ENUM!{enum D3D12_COMPARISON_FUNC { D3D12_COMPARISON_FUNC_NEVER = 1, D3D12_COMPARISON_FUNC_LESS = 2, D3D12_COMPARISON_FUNC_EQUAL = 3, D3D12_COMPARISON_FUNC_LESS_EQUAL = 4, D3D12_COMPARISON_FUNC_GREATER = 5, D3D12_COMPARISON_FUNC_NOT_EQUAL = 6, D3D12_COMPARISON_FUNC_GREATER_EQUAL = 7, D3D12_COMPARISON_FUNC_ALWAYS = 8, }} ENUM!{enum D3D12_DEPTH_WRITE_MASK { D3D12_DEPTH_WRITE_MASK_ZERO = 0, D3D12_DEPTH_WRITE_MASK_ALL = 1, }} ENUM!{enum D3D12_STENCIL_OP { D3D12_STENCIL_OP_KEEP = 1, D3D12_STENCIL_OP_ZERO = 2, D3D12_STENCIL_OP_REPLACE = 3, D3D12_STENCIL_OP_INCR_SAT = 4, D3D12_STENCIL_OP_DECR_SAT = 5, D3D12_STENCIL_OP_INVERT = 6, D3D12_STENCIL_OP_INCR = 7, D3D12_STENCIL_OP_DECR = 8, }} STRUCT!{struct D3D12_DEPTH_STENCILOP_DESC { StencilFailOp: D3D12_STENCIL_OP, StencilDepthFailOp: D3D12_STENCIL_OP, StencilPassOp: D3D12_STENCIL_OP, StencilFunc: D3D12_COMPARISON_FUNC, }} STRUCT!{struct D3D12_DEPTH_STENCIL_DESC { DepthEnable: ::BOOL, DepthWriteMask: D3D12_DEPTH_WRITE_MASK, DepthFunc: D3D12_COMPARISON_FUNC, StencilEnable: ::BOOL, StencilReadMask: ::UINT8, StencilWriteMask: ::UINT8, FrontFace: D3D12_DEPTH_STENCILOP_DESC, BackFace: D3D12_DEPTH_STENCILOP_DESC, }} ENUM!{enum D3D12_BLEND { D3D12_BLEND_ZERO = 1, D3D12_BLEND_ONE = 2, D3D12_BLEND_SRC_COLOR = 3, D3D12_BLEND_INV_SRC_COLOR = 4, D3D12_BLEND_SRC_ALPHA = 5, D3D12_BLEND_INV_SRC_ALPHA = 6, D3D12_BLEND_DEST_ALPHA = 7, D3D12_BLEND_INV_DEST_ALPHA = 8, D3D12_BLEND_DEST_COLOR = 9, D3D12_BLEND_INV_DEST_COLOR = 10, D3D12_BLEND_SRC_ALPHA_SAT = 11, D3D12_BLEND_BLEND_FACTOR = 14, D3D12_BLEND_INV_BLEND_FACTOR = 15, D3D12_BLEND_SRC1_COLOR = 16, D3D12_BLEND_INV_SRC1_COLOR = 17, D3D12_BLEND_SRC1_ALPHA = 18, D3D12_BLEND_INV_SRC1_ALPHA = 19, }} ENUM!{enum D3D12_BLEND_OP { D3D12_BLEND_OP_ADD = 1, D3D12_BLEND_OP_SUBTRACT = 2, D3D12_BLEND_OP_REV_SUBTRACT = 3, D3D12_BLEND_OP_MIN = 4, D3D12_BLEND_OP_MAX = 5, }} FLAGS!{enum D3D12_COLOR_WRITE_ENABLE { D3D12_COLOR_WRITE_ENABLE_RED = 0x1, D3D12_COLOR_WRITE_ENABLE_GREEN = 0x2, D3D12_COLOR_WRITE_ENABLE_BLUE = 0x4, D3D12_COLOR_WRITE_ENABLE_ALPHA = 0x8, D3D12_COLOR_WRITE_ENABLE_ALL = 0xF, }} ENUM!{enum D3D12_LOGIC_OP { D3D12_LOGIC_OP_CLEAR = 0, D3D12_LOGIC_OP_SET = 1, D3D12_LOGIC_OP_COPY = 2, D3D12_LOGIC_OP_COPY_INVERTED = 3, D3D12_LOGIC_OP_NOOP = 4, D3D12_LOGIC_OP_INVERT = 5, D3D12_LOGIC_OP_AND = 6, D3D12_LOGIC_OP_NAND = 7, D3D12_LOGIC_OP_OR = 8, D3D12_LOGIC_OP_NOR = 9, D3D12_LOGIC_OP_XOR = 10, D3D12_LOGIC_OP_EQUIV = 11, D3D12_LOGIC_OP_AND_REVERSE = 12, D3D12_LOGIC_OP_AND_INVERTED = 13, D3D12_LOGIC_OP_OR_REVERSE = 14, D3D12_LOGIC_OP_OR_INVERTED = 15, }} STRUCT!{struct D3D12_RENDER_TARGET_BLEND_DESC { BlendEnable: ::BOOL, LogicOpEnable: ::BOOL, SrcBlend: D3D12_BLEND, DestBlend: D3D12_BLEND, BlendOp: D3D12_BLEND_OP, SrcBlendAlpha: D3D12_BLEND, DestBlendAlpha: D3D12_BLEND, BlendOpAlpha: D3D12_BLEND_OP, LogicOp: D3D12_LOGIC_OP, RenderTargetWriteMask: ::UINT8, }} STRUCT!{struct D3D12_BLEND_DESC { AlphaToCoverageEnable: ::BOOL, IndependentBlendEnable: ::BOOL, RenderTarget: [D3D12_RENDER_TARGET_BLEND_DESC; 8], }} ENUM!{enum D3D12_CONSERVATIVE_RASTERIZATION_MODE { D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF = 0, D3D12_CONSERVATIVE_RASTERIZATION_MODE_ON = 1, }} STRUCT!{struct D3D12_RASTERIZER_DESC { FillMode: D3D12_FILL_MODE, CullMode: D3D12_CULL_MODE, FrontCounterClockwise: ::BOOL, DepthBias: ::INT, DepthBiasClamp: ::FLOAT, SlopeScaledDepthBias: ::FLOAT, DepthClipEnable: ::BOOL, MultisampleEnable: ::BOOL, AntialiasedLineEnable: ::BOOL, ForcedSampleCount: ::UINT, ConservativeRaster: D3D12_CONSERVATIVE_RASTERIZATION_MODE, }} RIDL!{interface ID3D12Object(ID3D12ObjectVtbl): IUnknown(IUnknownVtbl) { fn GetPrivateData( &mut self, guid: ::REFGUID, pDataSize: *mut ::UINT, pData: *mut ::c_void ) -> ::HRESULT, fn SetPrivateData( &mut self, guid: ::REFGUID, DataSize: ::UINT, pData: *const ::c_void ) -> ::HRESULT, fn SetPrivateDataInterface( &mut self, guid: ::REFGUID, pData: *const ::IUnknown ) -> ::HRESULT, fn SetName(&mut self, Name: ::LPCWSTR) -> ::HRESULT }} RIDL!{interface ID3D12DeviceChild(ID3D12DeviceChildVtbl): ID3D12Object(ID3D12ObjectVtbl) { fn GetDevice( &mut self, riid: ::REFGUID, ppvDevice: *mut *mut ::c_void ) -> ::HRESULT }} RIDL!{interface ID3D12RootSignature(ID3D12RootSignatureVtbl): ID3D12DeviceChild(ID3D12DeviceChildVtbl) { }} STRUCT!{struct D3D12_SHADER_BYTECODE { pShaderBytecode: *const ::c_void, BytecodeLength: ::SIZE_T, }} STRUCT!{struct D3D12_STREAM_OUTPUT_DESC { pSODeclaration: *const D3D12_SO_DECLARATION_ENTRY, NumEntries: ::UINT, pBufferStrides: *const ::UINT, NumStrides: ::UINT, RasterizedStream: ::UINT, }} STRUCT!{struct D3D12_INPUT_LAYOUT_DESC { pInputElementDescs: *const D3D12_INPUT_ELEMENT_DESC, NumElements: ::UINT, }} ENUM!{enum D3D12_INDEX_BUFFER_STRIP_CUT_VALUE { D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_DISABLED = 0, D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFF = 1, D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFFFFFF = 2, }} STRUCT!{struct D3D12_CACHED_PIPELINE_STATE { pCachedBlob: *const ::c_void, CachedBlobSizeInBytes: ::SIZE_T, }} FLAGS!{enum D3D12_PIPELINE_STATE_FLAGS { D3D12_PIPELINE_STATE_FLAG_NONE = 0x0, D3D12_PIPELINE_STATE_FLAG_TOOL_DEBUG = 0x1, }} STRUCT!{struct D3D12_GRAPHICS_PIPELINE_STATE_DESC { pRootSignature: *mut ID3D12RootSignature, VS: D3D12_SHADER_BYTECODE, PS: D3D12_SHADER_BYTECODE, DS: D3D12_SHADER_BYTECODE, HS: D3D12_SHADER_BYTECODE, GS: D3D12_SHADER_BYTECODE, StreamOutput: D3D12_STREAM_OUTPUT_DESC, BlendState: D3D12_BLEND_DESC, SampleMask: ::UINT, RasterizerState: D3D12_RASTERIZER_DESC, DepthStencilState: D3D12_DEPTH_STENCIL_DESC, InputLayout: D3D12_INPUT_LAYOUT_DESC, IBStripCutValue: D3D12_INDEX_BUFFER_STRIP_CUT_VALUE, PrimitiveTopologyType: D3D12_PRIMITIVE_TOPOLOGY_TYPE, NumRenderTargets: ::UINT, RTVFormats: [::DXGI_FORMAT; 8], DSVFormat: ::DXGI_FORMAT, SampleDesc: ::DXGI_SAMPLE_DESC, NodeMask: ::UINT, CachedPSO: D3D12_CACHED_PIPELINE_STATE, Flags: D3D12_PIPELINE_STATE_FLAGS, }} STRUCT!{struct D3D12_COMPUTE_PIPELINE_STATE_DESC { pRootSignature: *mut ID3D12RootSignature, CS: D3D12_SHADER_BYTECODE, NodeMask: ::UINT, CachedPSO: D3D12_CACHED_PIPELINE_STATE, Flags: D3D12_PIPELINE_STATE_FLAGS, }} ENUM!{enum D3D12_FEATURE { D3D12_FEATURE_D3D12_OPTIONS = 0, D3D12_FEATURE_ARCHITECTURE = 1, D3D12_FEATURE_FEATURE_LEVELS = 2, D3D12_FEATURE_FORMAT_SUPPORT = 3, D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS = 4, D3D12_FEATURE_FORMAT_INFO = 5, D3D12_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT = 6, }} FLAGS!{enum D3D12_SHADER_MIN_PRECISION_SUPPORT { D3D12_SHADER_MIN_PRECISION_SUPPORT_NONE = 0, D3D12_SHADER_MIN_PRECISION_SUPPORT_10_BIT = 0x1, D3D12_SHADER_MIN_PRECISION_SUPPORT_16_BIT = 0x2, }} ENUM!{enum D3D12_TILED_RESOURCES_TIER { D3D12_TILED_RESOURCES_TIER_NOT_SUPPORTED = 0, D3D12_TILED_RESOURCES_TIER_1 = 1, D3D12_TILED_RESOURCES_TIER_2 = 2, D3D12_TILED_RESOURCES_TIER_3 = 3, }} ENUM!{enum D3D12_RESOURCE_BINDING_TIER { D3D12_RESOURCE_BINDING_TIER_1 = 1, D3D12_RESOURCE_BINDING_TIER_2 = 2, D3D12_RESOURCE_BINDING_TIER_3 = 3, }} ENUM!{enum D3D12_CONSERVATIVE_RASTERIZATION_TIER { D3D12_CONSERVATIVE_RASTERIZATION_TIER_NOT_SUPPORTED = 0, D3D12_CONSERVATIVE_RASTERIZATION_TIER_1 = 1, D3D12_CONSERVATIVE_RASTERIZATION_TIER_2 = 2, D3D12_CONSERVATIVE_RASTERIZATION_TIER_3 = 3, }} FLAGS!{enum D3D12_FORMAT_SUPPORT1 { D3D12_FORMAT_SUPPORT1_NONE = 0x0, D3D12_FORMAT_SUPPORT1_BUFFER = 0x1, D3D12_FORMAT_SUPPORT1_IA_VERTEX_BUFFER = 0x2, D3D12_FORMAT_SUPPORT1_IA_INDEX_BUFFER = 0x4, D3D12_FORMAT_SUPPORT1_SO_BUFFER = 0x8, D3D12_FORMAT_SUPPORT1_TEXTURE1D = 0x10, D3D12_FORMAT_SUPPORT1_TEXTURE2D = 0x20, D3D12_FORMAT_SUPPORT1_TEXTURE3D = 0x40, D3D12_FORMAT_SUPPORT1_TEXTURECUBE = 0x80, D3D12_FORMAT_SUPPORT1_SHADER_LOAD = 0x100, D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE = 0x200, D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE_COMPARISON = 0x400, D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE_MONO_TEXT = 0x800, D3D12_FORMAT_SUPPORT1_MIP = 0x1000, D3D12_FORMAT_SUPPORT1_RENDER_TARGET = 0x4000, D3D12_FORMAT_SUPPORT1_BLENDABLE = 0x8000, D3D12_FORMAT_SUPPORT1_DEPTH_STENCIL = 0x10000, D3D12_FORMAT_SUPPORT1_MULTISAMPLE_RESOLVE = 0x40000, D3D12_FORMAT_SUPPORT1_DISPLAY = 0x80000, D3D12_FORMAT_SUPPORT1_CAST_WITHIN_BIT_LAYOUT = 0x100000, D3D12_FORMAT_SUPPORT1_MULTISAMPLE_RENDERTARGET = 0x200000, D3D12_FORMAT_SUPPORT1_MULTISAMPLE_LOAD = 0x400000, D3D12_FORMAT_SUPPORT1_SHADER_GATHER = 0x800000, D3D12_FORMAT_SUPPORT1_BACK_BUFFER_CAST = 0x1000000, D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW = 0x2000000, D3D12_FORMAT_SUPPORT1_SHADER_GATHER_COMPARISON = 0x4000000, D3D12_FORMAT_SUPPORT1_DECODER_OUTPUT = 0x8000000, D3D12_FORMAT_SUPPORT1_VIDEO_PROCESSOR_OUTPUT = 0x10000000, D3D12_FORMAT_SUPPORT1_VIDEO_PROCESSOR_INPUT = 0x20000000, D3D12_FORMAT_SUPPORT1_VIDEO_ENCODER = 0x40000000, }} FLAGS!{enum D3D12_FORMAT_SUPPORT2 { D3D12_FORMAT_SUPPORT2_NONE = 0x0, D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_ADD = 0x1, D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_BITWISE_OPS = 0x2, D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_COMPARE_STORE_OR_COMPARE_EXCHANGE = 0x4, D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_EXCHANGE = 0x8, D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_SIGNED_MIN_OR_MAX = 0x10, D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_UNSIGNED_MIN_OR_MAX = 0x20, D3D12_FORMAT_SUPPORT2_UAV_TYPED_LOAD = 0x40, D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE = 0x80, D3D12_FORMAT_SUPPORT2_OUTPUT_MERGER_LOGIC_OP = 0x100, D3D12_FORMAT_SUPPORT2_TILED = 0x200, D3D12_FORMAT_SUPPORT2_MULTIPLANE_OVERLAY = 0x4000, }} FLAGS!{enum D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS { D3D12_MULTISAMPLE_QUALITY_LEVELS_FLAG_NONE = 0x0, D3D12_MULTISAMPLE_QUALITY_LEVELS_FLAG_TILED_RESOURCE = 0x1, }} ENUM!{enum D3D12_CROSS_NODE_SHARING_TIER { D3D12_CROSS_NODE_SHARING_TIER_NOT_SUPPORTED = 0, D3D12_CROSS_NODE_SHARING_TIER_1_EMULATED = 1, D3D12_CROSS_NODE_SHARING_TIER_1 = 2, D3D12_CROSS_NODE_SHARING_TIER_2 = 3, }} ENUM!{enum D3D12_RESOURCE_HEAP_TIER { D3D12_RESOURCE_HEAP_TIER_1 = 1, D3D12_RESOURCE_HEAP_TIER_2 = 2, }} STRUCT!{struct D3D12_FEATURE_DATA_D3D12_OPTIONS { DoublePrecisionFloatShaderOps: ::BOOL, OutputMergerLogicOp: ::BOOL, MinPrecisionSupport: D3D12_SHADER_MIN_PRECISION_SUPPORT, TiledResourcesTier: D3D12_TILED_RESOURCES_TIER, ResourceBindingTier: D3D12_RESOURCE_BINDING_TIER, PSSpecifiedStencilRefSupported: ::BOOL, TypedUAVLoadAdditionalFormats: ::BOOL, ROVsSupported: ::BOOL, ConservativeRasterizationTier: D3D12_CONSERVATIVE_RASTERIZATION_TIER, MaxGPUVirtualAddressBitsPerResource: ::UINT, StandardSwizzle64KBSupported: ::BOOL, CrossNodeSharingTier: D3D12_CROSS_NODE_SHARING_TIER, CrossAdapterRowMajorTextureSupported: ::BOOL, VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation: ::BOOL, ResourceHeapTier: D3D12_RESOURCE_HEAP_TIER, }} FLAGS!{ enum D3D12_BUFFER_SRV_FLAGS { D3D12_BUFFER_SRV_FLAG_NONE = 0x0, D3D12_BUFFER_SRV_FLAG_RAW = 0x1, }} FLAGS!{ enum D3D12_BUFFER_UAV_FLAGS { D3D12_BUFFER_UAV_FLAG_NONE = 0x0, D3D12_BUFFER_UAV_FLAG_RAW = 0x1, }} FLAGS!{ enum D3D12_CLEAR_FLAGS { D3D12_CLEAR_FLAG_DEPTH = 0x1, D3D12_CLEAR_FLAG_STENCIL = 0x2, }} ENUM!{ enum D3D12_CPU_PAGE_PROPERTY { D3D12_CPU_PAGE_PROPERTY_UNKNOWN = 0, D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE = 1, D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE = 2, D3D12_CPU_PAGE_PROPERTY_WRITE_BACK = 3, }} FLAGS!{ enum D3D12_DESCRIPTOR_HEAP_FLAGS { D3D12_DESCRIPTOR_HEAP_FLAG_NONE = 0x0, D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE = 0x1, }} ENUM!{ enum D3D12_DESCRIPTOR_HEAP_TYPE { D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV = 0, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER = 1, D3D12_DESCRIPTOR_HEAP_TYPE_RTV = 2, D3D12_DESCRIPTOR_HEAP_TYPE_DSV = 3, D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES = 4, }} ENUM!{ enum D3D12_DESCRIPTOR_RANGE_TYPE { D3D12_DESCRIPTOR_RANGE_TYPE_SRV = 0, D3D12_DESCRIPTOR_RANGE_TYPE_UAV = 1, D3D12_DESCRIPTOR_RANGE_TYPE_CBV = 2, D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER = 3, }} ENUM!{ enum D3D12_DSV_DIMENSION { D3D12_DSV_DIMENSION_UNKNOWN = 0, D3D12_DSV_DIMENSION_TEXTURE1D = 1, D3D12_DSV_DIMENSION_TEXTURE1DARRAY = 2, D3D12_DSV_DIMENSION_TEXTURE2D = 3, D3D12_DSV_DIMENSION_TEXTURE2DARRAY = 4, D3D12_DSV_DIMENSION_TEXTURE2DMS = 5, D3D12_DSV_DIMENSION_TEXTURE2DMSARRAY = 6, }} FLAGS!{ enum D3D12_DSV_FLAGS { D3D12_DSV_FLAG_NONE = 0x0, D3D12_DSV_FLAG_READ_ONLY_DEPTH = 0x1, D3D12_DSV_FLAG_READ_ONLY_STENCIL = 0x2, }} FLAGS!{ enum D3D12_FENCE_FLAGS { D3D12_FENCE_FLAG_NONE = 0x0, D3D12_FENCE_FLAG_SHARED = 0x1, D3D12_FENCE_FLAG_SHARED_CROSS_ADAPTER = 0x2, }} ENUM!{ enum D3D12_FILTER { D3D12_FILTER_MIN_MAG_MIP_POINT = 0, D3D12_FILTER_MIN_MAG_POINT_MIP_LINEAR = 1, D3D12_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = 4, D3D12_FILTER_MIN_POINT_MAG_MIP_LINEAR = 5, D3D12_FILTER_MIN_LINEAR_MAG_MIP_POINT = 16, D3D12_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 17, D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT = 20, D3D12_FILTER_MIN_MAG_MIP_LINEAR = 21, D3D12_FILTER_ANISOTROPIC = 85, D3D12_FILTER_COMPARISON_MIN_MAG_MIP_POINT = 128, D3D12_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR = 129, D3D12_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT = 132, D3D12_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR = 133, D3D12_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT = 144, D3D12_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 145, D3D12_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT = 148, D3D12_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR = 149, D3D12_FILTER_COMPARISON_ANISOTROPIC = 213, D3D12_FILTER_MINIMUM_MIN_MAG_MIP_POINT = 256, D3D12_FILTER_MINIMUM_MIN_MAG_POINT_MIP_LINEAR = 257, D3D12_FILTER_MINIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 260, D3D12_FILTER_MINIMUM_MIN_POINT_MAG_MIP_LINEAR = 261, D3D12_FILTER_MINIMUM_MIN_LINEAR_MAG_MIP_POINT = 272, D3D12_FILTER_MINIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 273, D3D12_FILTER_MINIMUM_MIN_MAG_LINEAR_MIP_POINT = 276, D3D12_FILTER_MINIMUM_MIN_MAG_MIP_LINEAR = 277, D3D12_FILTER_MINIMUM_ANISOTROPIC = 341, D3D12_FILTER_MAXIMUM_MIN_MAG_MIP_POINT = 384, D3D12_FILTER_MAXIMUM_MIN_MAG_POINT_MIP_LINEAR = 385, D3D12_FILTER_MAXIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 388, D3D12_FILTER_MAXIMUM_MIN_POINT_MAG_MIP_LINEAR = 389, D3D12_FILTER_MAXIMUM_MIN_LINEAR_MAG_MIP_POINT = 400, D3D12_FILTER_MAXIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 401, D3D12_FILTER_MAXIMUM_MIN_MAG_LINEAR_MIP_POINT = 404, D3D12_FILTER_MAXIMUM_MIN_MAG_MIP_LINEAR = 405, D3D12_FILTER_MAXIMUM_ANISOTROPIC = 469, }} ENUM!{ enum D3D12_FILTER_REDUCTION_TYPE { D3D12_FILTER_REDUCTION_TYPE_STANDARD = 0, D3D12_FILTER_REDUCTION_TYPE_COMPARISON = 1, D3D12_FILTER_REDUCTION_TYPE_MINIMUM = 2, D3D12_FILTER_REDUCTION_TYPE_MAXIMUM = 3, }} ENUM!{ enum D3D12_FILTER_TYPE { D3D12_FILTER_TYPE_POINT = 0, D3D12_FILTER_TYPE_LINEAR = 1, }} FLAGS!{ enum D3D12_HEAP_FLAGS { D3D12_HEAP_FLAG_NONE = 0x0, D3D12_HEAP_FLAG_SHARED = 0x1, D3D12_HEAP_FLAG_DENY_BUFFERS = 0x4, D3D12_HEAP_FLAG_ALLOW_DISPLAY = 0x8, D3D12_HEAP_FLAG_SHARED_CROSS_ADAPTER = 0x20, D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES = 0x40, D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES = 0x80, D3D12_HEAP_FLAG_ALLOW_ALL_BUFFERS_AND_TEXTURES = 0x0, D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS = 0xC0, D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES = 0x44, D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES = 0x84, }} ENUM!{ enum D3D12_HEAP_TYPE { D3D12_HEAP_TYPE_DEFAULT = 1, D3D12_HEAP_TYPE_UPLOAD = 2, D3D12_HEAP_TYPE_READBACK = 3, D3D12_HEAP_TYPE_CUSTOM = 4, }} ENUM!{ enum D3D12_INDIRECT_ARGUMENT_TYPE { D3D12_INDIRECT_ARGUMENT_TYPE_DRAW = 0, D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED = 1, D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH = 2, D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW = 3, D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW = 4, D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT = 5, D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW = 6, D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW = 7, D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW = 8, }} ENUM!{ enum D3D12_MEMORY_POOL { D3D12_MEMORY_POOL_UNKNOWN = 0, D3D12_MEMORY_POOL_L0 = 1, D3D12_MEMORY_POOL_L1 = 2, }} ENUM!{ enum D3D12_PREDICATION_OP { D3D12_PREDICATION_OP_EQUAL_ZERO = 0, D3D12_PREDICATION_OP_NOT_EQUAL_ZERO = 1, }} ENUM!{ enum D3D12_QUERY_HEAP_TYPE { D3D12_QUERY_HEAP_TYPE_OCCLUSION = 0, D3D12_QUERY_HEAP_TYPE_TIMESTAMP = 1, D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS = 2, D3D12_QUERY_HEAP_TYPE_SO_STATISTICS = 3, }} ENUM!{ enum D3D12_QUERY_TYPE { D3D12_QUERY_TYPE_OCCLUSION = 0, D3D12_QUERY_TYPE_BINARY_OCCLUSION = 1, D3D12_QUERY_TYPE_TIMESTAMP = 2, D3D12_QUERY_TYPE_PIPELINE_STATISTICS = 3, D3D12_QUERY_TYPE_SO_STATISTICS_STREAM0 = 4, D3D12_QUERY_TYPE_SO_STATISTICS_STREAM1 = 5, D3D12_QUERY_TYPE_SO_STATISTICS_STREAM2 = 6, D3D12_QUERY_TYPE_SO_STATISTICS_STREAM3 = 7, }} FLAGS!{ enum D3D12_RESOURCE_BARRIER_FLAGS { D3D12_RESOURCE_BARRIER_FLAG_NONE = 0x0, D3D12_RESOURCE_BARRIER_FLAG_BEGIN_ONLY = 0x1, D3D12_RESOURCE_BARRIER_FLAG_END_ONLY = 0x2, }} ENUM!{ enum D3D12_RESOURCE_BARRIER_TYPE { D3D12_RESOURCE_BARRIER_TYPE_TRANSITION = 0, D3D12_RESOURCE_BARRIER_TYPE_ALIASING = 1, D3D12_RESOURCE_BARRIER_TYPE_UAV = 2, }} ENUM!{ enum D3D12_RESOURCE_DIMENSION { D3D12_RESOURCE_DIMENSION_UNKNOWN = 0, D3D12_RESOURCE_DIMENSION_BUFFER = 1, D3D12_RESOURCE_DIMENSION_TEXTURE1D = 2, D3D12_RESOURCE_DIMENSION_TEXTURE2D = 3, D3D12_RESOURCE_DIMENSION_TEXTURE3D = 4, }} FLAGS!{ enum D3D12_RESOURCE_FLAGS { D3D12_RESOURCE_FLAG_NONE = 0x0, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET = 0x1, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL = 0x2, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS = 0x4, D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE = 0x8, D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER = 0x10, D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS = 0x20, }} FLAGS!{ enum D3D12_RESOURCE_STATES { D3D12_RESOURCE_STATE_COMMON = 0x0, D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER = 0x1, D3D12_RESOURCE_STATE_INDEX_BUFFER = 0x2, D3D12_RESOURCE_STATE_RENDER_TARGET = 0x4, D3D12_RESOURCE_STATE_UNORDERED_ACCESS = 0x8, D3D12_RESOURCE_STATE_DEPTH_WRITE = 0x10, D3D12_RESOURCE_STATE_DEPTH_READ = 0x20, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE = 0x40, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE = 0x80, D3D12_RESOURCE_STATE_STREAM_OUT = 0x100, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT = 0x200, D3D12_RESOURCE_STATE_COPY_DEST = 0x400, D3D12_RESOURCE_STATE_COPY_SOURCE = 0x800, D3D12_RESOURCE_STATE_RESOLVE_DEST = 0x1000, D3D12_RESOURCE_STATE_RESOLVE_SOURCE = 0x2000, D3D12_RESOURCE_STATE_GENERIC_READ = 0xAC3, D3D12_RESOURCE_STATE_PRESENT = 0x0, D3D12_RESOURCE_STATE_PREDICATION = 0x200, }} ENUM!{ enum D3D12_ROOT_PARAMETER_TYPE { D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE = 0, D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS = 1, D3D12_ROOT_PARAMETER_TYPE_CBV = 2, D3D12_ROOT_PARAMETER_TYPE_SRV = 3, D3D12_ROOT_PARAMETER_TYPE_UAV = 4, }} FLAGS!{ enum D3D12_ROOT_SIGNATURE_FLAGS { D3D12_ROOT_SIGNATURE_FLAG_NONE = 0x0, D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT = 0x1, D3D12_ROOT_SIGNATURE_FLAG_DENY_VERTEX_SHADER_ROOT_ACCESS = 0x2, D3D12_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS = 0x4, D3D12_ROOT_SIGNATURE_FLAG_DENY_DOMAIN_SHADER_ROOT_ACCESS = 0x8, D3D12_ROOT_SIGNATURE_FLAG_DENY_GEOMETRY_SHADER_ROOT_ACCESS = 0x10, D3D12_ROOT_SIGNATURE_FLAG_DENY_PIXEL_SHADER_ROOT_ACCESS = 0x20, D3D12_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT = 0x40, }} ENUM!{ enum D3D12_RTV_DIMENSION { D3D12_RTV_DIMENSION_UNKNOWN = 0, D3D12_RTV_DIMENSION_BUFFER = 1, D3D12_RTV_DIMENSION_TEXTURE1D = 2, D3D12_RTV_DIMENSION_TEXTURE1DARRAY = 3, D3D12_RTV_DIMENSION_TEXTURE2D = 4, D3D12_RTV_DIMENSION_TEXTURE2DARRAY = 5, D3D12_RTV_DIMENSION_TEXTURE2DMS = 6, D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY = 7, D3D12_RTV_DIMENSION_TEXTURE3D = 8, }} ENUM!{ enum D3D12_SHADER_COMPONENT_MAPPING { D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_0 = 0, D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1 = 1, D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2 = 2, D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_3 = 3, D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_0 = 4, D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1 = 5, }} ENUM!{ enum D3D12_SHADER_VISIBILITY { D3D12_SHADER_VISIBILITY_ALL = 0, D3D12_SHADER_VISIBILITY_VERTEX = 1, D3D12_SHADER_VISIBILITY_HULL = 2, D3D12_SHADER_VISIBILITY_DOMAIN = 3, D3D12_SHADER_VISIBILITY_GEOMETRY = 4, D3D12_SHADER_VISIBILITY_PIXEL = 5, }} ENUM!{ enum D3D12_SRV_DIMENSION { D3D12_SRV_DIMENSION_UNKNOWN = 0, D3D12_SRV_DIMENSION_BUFFER = 1, D3D12_SRV_DIMENSION_TEXTURE1D = 2, D3D12_SRV_DIMENSION_TEXTURE1DARRAY = 3, D3D12_SRV_DIMENSION_TEXTURE2D = 4, D3D12_SRV_DIMENSION_TEXTURE2DARRAY = 5, D3D12_SRV_DIMENSION_TEXTURE2DMS = 6, D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY = 7, D3D12_SRV_DIMENSION_TEXTURE3D = 8, D3D12_SRV_DIMENSION_TEXTURECUBE = 9, D3D12_SRV_DIMENSION_TEXTURECUBEARRAY = 10, }} ENUM!{ enum D3D12_STATIC_BORDER_COLOR { D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK = 0, D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK = 1, D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE = 2, }} ENUM!{ enum D3D12_TEXTURE_ADDRESS_MODE { D3D12_TEXTURE_ADDRESS_MODE_WRAP = 1, D3D12_TEXTURE_ADDRESS_MODE_MIRROR = 2, D3D12_TEXTURE_ADDRESS_MODE_CLAMP = 3, D3D12_TEXTURE_ADDRESS_MODE_BORDER = 4, D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE = 5, }} ENUM!{ enum D3D12_TEXTURE_COPY_TYPE { D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX = 0, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT = 1, }} ENUM!{ enum D3D12_TEXTURE_LAYOUT { D3D12_TEXTURE_LAYOUT_UNKNOWN = 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR = 1, D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE = 2, D3D12_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE = 3, }} FLAGS!{ enum D3D12_TILE_COPY_FLAGS { D3D12_TILE_COPY_FLAG_NONE = 0x0, D3D12_TILE_COPY_FLAG_NO_HAZARD = 0x1, D3D12_TILE_COPY_FLAG_LINEAR_BUFFER_TO_SWIZZLED_TILED_RESOURCE = 0x2, D3D12_TILE_COPY_FLAG_SWIZZLED_TILED_RESOURCE_TO_LINEAR_BUFFER = 0x4, }} FLAGS!{ enum D3D12_TILE_MAPPING_FLAGS { D3D12_TILE_MAPPING_FLAG_NONE = 0x0, D3D12_TILE_MAPPING_FLAG_NO_HAZARD = 0x1, }} FLAGS!{ enum D3D12_TILE_RANGE_FLAGS { D3D12_TILE_RANGE_FLAG_NONE = 0x0, D3D12_TILE_RANGE_FLAG_NULL = 0x1, D3D12_TILE_RANGE_FLAG_SKIP = 0x2, D3D12_TILE_RANGE_FLAG_REUSE_SINGLE_TILE = 0x4, }} ENUM!{ enum D3D12_UAV_DIMENSION { D3D12_UAV_DIMENSION_UNKNOWN = 0, D3D12_UAV_DIMENSION_BUFFER = 1, D3D12_UAV_DIMENSION_TEXTURE1D = 2, D3D12_UAV_DIMENSION_TEXTURE1DARRAY = 3, D3D12_UAV_DIMENSION_TEXTURE2D = 4, D3D12_UAV_DIMENSION_TEXTURE2DARRAY = 5, D3D12_UAV_DIMENSION_TEXTURE3D = 8, }} ENUM!{ enum D3D_ROOT_SIGNATURE_VERSION { D3D_ROOT_SIGNATURE_VERSION_1 = 1, }} #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_BUFFER_RTV { pub FirstElement: ::UINT64, pub NumElements: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_BUFFER_SRV { pub FirstElement: ::UINT64, pub NumElements: ::UINT, pub StructureByteStride: ::UINT, pub Flags: ::D3D12_BUFFER_SRV_FLAGS, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_BUFFER_UAV { pub FirstElement: ::UINT64, pub NumElements: ::UINT, pub StructureByteStride: ::UINT, pub CounterOffsetInBytes: ::UINT64, pub Flags: ::D3D12_BUFFER_UAV_FLAGS, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_CLEAR_VALUE { pub Format: ::DXGI_FORMAT, pub u: [::FLOAT; 4], } UNION!(D3D12_CLEAR_VALUE, u, DepthStencil, DepthStencil_mut, ::D3D12_DEPTH_STENCIL_VALUE); UNION!(D3D12_CLEAR_VALUE, u, Color, Color_mut, [::FLOAT; 4]); #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_COMMAND_SIGNATURE_DESC { pub ByteStride: ::UINT, pub NumArgumentDescs: ::UINT, pub pArgumentDescs: *const ::D3D12_INDIRECT_ARGUMENT_DESC, pub NodeMask: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_CONSTANT_BUFFER_VIEW_DESC { pub BufferLocation: ::D3D12_GPU_VIRTUAL_ADDRESS, pub SizeInBytes: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_CPU_DESCRIPTOR_HANDLE { pub ptr: ::SIZE_T, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_DEPTH_STENCIL_VALUE { pub Depth: ::FLOAT, pub Stencil: ::UINT8, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_DEPTH_STENCIL_VIEW_DESC { pub Format: ::DXGI_FORMAT, pub ViewDimension: ::D3D12_DSV_DIMENSION, pub Flags: ::D3D12_DSV_FLAGS, pub u: ::D3D12_TEX1D_ARRAY_DSV, } UNION!(D3D12_DEPTH_STENCIL_VIEW_DESC, u, Texture2DMSArray, Texture2DMSArray_mut, ::D3D12_TEX2DMS_ARRAY_DSV); UNION!(D3D12_DEPTH_STENCIL_VIEW_DESC, u, Texture2DMS, Texture2DMS_mut, ::D3D12_TEX2DMS_DSV); UNION!(D3D12_DEPTH_STENCIL_VIEW_DESC, u, Texture2DArray, Texture2DArray_mut, ::D3D12_TEX2D_ARRAY_DSV); UNION!(D3D12_DEPTH_STENCIL_VIEW_DESC, u, Texture2D, Texture2D_mut, ::D3D12_TEX2D_DSV); UNION!(D3D12_DEPTH_STENCIL_VIEW_DESC, u, Texture1DArray, Texture1DArray_mut, ::D3D12_TEX1D_ARRAY_DSV); UNION!(D3D12_DEPTH_STENCIL_VIEW_DESC, u, Texture1D, Texture1D_mut, ::D3D12_TEX1D_DSV); #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_DESCRIPTOR_HEAP_DESC { pub Type: ::D3D12_DESCRIPTOR_HEAP_TYPE, pub NumDescriptors: ::UINT, pub Flags: ::D3D12_DESCRIPTOR_HEAP_FLAGS, pub NodeMask: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_DESCRIPTOR_RANGE { pub RangeType: ::D3D12_DESCRIPTOR_RANGE_TYPE, pub NumDescriptors: ::UINT, pub BaseShaderRegister: ::UINT, pub RegisterSpace: ::UINT, pub OffsetInDescriptorsFromTableStart: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_DISCARD_REGION { pub NumRects: ::UINT, pub pRects: *const ::D3D12_RECT, pub FirstSubresource: ::UINT, pub NumSubresources: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_DISPATCH_ARGUMENTS { pub ThreadGroupCountX: ::UINT, pub ThreadGroupCountY: ::UINT, pub ThreadGroupCountZ: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_DRAW_ARGUMENTS { pub VertexCountPerInstance: ::UINT, pub InstanceCount: ::UINT, pub StartVertexLocation: ::UINT, pub StartInstanceLocation: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_DRAW_INDEXED_ARGUMENTS { pub IndexCountPerInstance: ::UINT, pub InstanceCount: ::UINT, pub StartIndexLocation: ::UINT, pub BaseVertexLocation: ::INT, pub StartInstanceLocation: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_FEATURE_DATA_ARCHITECTURE { pub NodeIndex: ::UINT, pub TileBasedRenderer: ::BOOL, pub UMA: ::BOOL, pub CacheCoherentUMA: ::BOOL, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_FEATURE_DATA_FEATURE_LEVELS { pub NumFeatureLevels: ::UINT, pub pFeatureLevelsRequested: *const ::D3D_FEATURE_LEVEL, pub MaxSupportedFeatureLevel: ::D3D_FEATURE_LEVEL, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_FEATURE_DATA_FORMAT_INFO { pub Format: ::DXGI_FORMAT, pub PlaneCount: ::UINT8, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_FEATURE_DATA_FORMAT_SUPPORT { pub Format: ::DXGI_FORMAT, pub Support1: ::D3D12_FORMAT_SUPPORT1, pub Support2: ::D3D12_FORMAT_SUPPORT2, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT { pub MaxGPUVirtualAddressBitsPerResource: ::UINT, pub MaxGPUVirtualAddressBitsPerProcess: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS { pub Format: ::DXGI_FORMAT, pub SampleCount: ::UINT, pub Flags: ::D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS, pub NumQualityLevels: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_GPU_DESCRIPTOR_HANDLE { pub ptr: ::UINT64, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_HEAP_DESC { pub SizeInBytes: ::UINT64, pub Properties: ::D3D12_HEAP_PROPERTIES, pub Alignment: ::UINT64, pub Flags: ::D3D12_HEAP_FLAGS, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_HEAP_PROPERTIES { pub Type: ::D3D12_HEAP_TYPE, pub CPUPageProperty: ::D3D12_CPU_PAGE_PROPERTY, pub MemoryPoolPreference: ::D3D12_MEMORY_POOL, pub CreationNodeMask: ::UINT, pub VisibleNodeMask: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_INDEX_BUFFER_VIEW { pub BufferLocation: ::D3D12_GPU_VIRTUAL_ADDRESS, pub SizeInBytes: ::UINT, pub Format: ::DXGI_FORMAT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_INDIRECT_ARGUMENT_DESC_VertexBuffer { pub Slot: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_INDIRECT_ARGUMENT_DESC_Constant { pub RootParameterIndex: ::UINT, pub DestOffsetIn32BitValues: ::UINT, pub Num32BitValuesToSet: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_INDIRECT_ARGUMENT_DESC_ConstantBufferView { pub RootParameterIndex: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_INDIRECT_ARGUMENT_DESC_ShaderResourceView { pub RootParameterIndex: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_INDIRECT_ARGUMENT_DESC_UnorderedAccessView { pub RootParameterIndex: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_INDIRECT_ARGUMENT_DESC { pub Type: ::D3D12_INDIRECT_ARGUMENT_TYPE, pub u: ::D3D12_INDIRECT_ARGUMENT_DESC_Constant, } UNION!(D3D12_INDIRECT_ARGUMENT_DESC, u, UnorderedAccessView, UnorderedAccessView_mut, D3D12_INDIRECT_ARGUMENT_DESC_UnorderedAccessView); UNION!(D3D12_INDIRECT_ARGUMENT_DESC, u, ShaderResourceView, ShaderResourceView_mut, D3D12_INDIRECT_ARGUMENT_DESC_ShaderResourceView); UNION!(D3D12_INDIRECT_ARGUMENT_DESC, u, ConstantBufferView, ConstantBufferView_mut, D3D12_INDIRECT_ARGUMENT_DESC_ConstantBufferView); UNION!(D3D12_INDIRECT_ARGUMENT_DESC, u, Constant, Constant_mut, D3D12_INDIRECT_ARGUMENT_DESC_Constant); UNION!(D3D12_INDIRECT_ARGUMENT_DESC, u, VertexBuffer, VertexBuffer_mut, D3D12_INDIRECT_ARGUMENT_DESC_VertexBuffer); #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_MEMCPY_DEST { pub pData: *mut ::c_void, pub RowPitch: ::SIZE_T, pub SlicePitch: ::SIZE_T, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_PACKED_MIP_INFO { pub NumStandardMips: ::UINT8, pub NumPackedMips: ::UINT8, pub NumTilesForPackedMips: ::UINT, pub StartTileIndexInOverallResource: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_PLACED_SUBRESOURCE_FOOTPRINT { pub Offset: ::UINT64, pub Footprint: ::D3D12_SUBRESOURCE_FOOTPRINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_QUERY_DATA_PIPELINE_STATISTICS { pub IAVertices: ::UINT64, pub IAPrimitives: ::UINT64, pub VSInvocations: ::UINT64, pub GSInvocations: ::UINT64, pub GSPrimitives: ::UINT64, pub CInvocations: ::UINT64, pub CPrimitives: ::UINT64, pub PSInvocations: ::UINT64, pub HSInvocations: ::UINT64, pub DSInvocations: ::UINT64, pub CSInvocations: ::UINT64, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_QUERY_DATA_SO_STATISTICS { pub NumPrimitivesWritten: ::UINT64, pub PrimitivesStorageNeeded: ::UINT64, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_QUERY_HEAP_DESC { pub Type: ::D3D12_QUERY_HEAP_TYPE, pub Count: ::UINT, pub NodeMask: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_RANGE { pub Begin: ::SIZE_T, pub End: ::SIZE_T, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_RENDER_TARGET_VIEW_DESC { pub Format: ::DXGI_FORMAT, pub ViewDimension: ::D3D12_RTV_DIMENSION, pub u: ::D3D12_BUFFER_RTV, } UNION!(D3D12_RENDER_TARGET_VIEW_DESC, u, Texture3D, Texture3D_mut, ::D3D12_TEX3D_RTV); UNION!(D3D12_RENDER_TARGET_VIEW_DESC, u, Texture2DMSArray, Texture2DMSArray_mut, ::D3D12_TEX2DMS_ARRAY_RTV); UNION!(D3D12_RENDER_TARGET_VIEW_DESC, u, Texture2DMS, Texture2DMS_mut, ::D3D12_TEX2DMS_RTV); UNION!(D3D12_RENDER_TARGET_VIEW_DESC, u, Texture2DArray, Texture2DArray_mut, ::D3D12_TEX2D_ARRAY_RTV); UNION!(D3D12_RENDER_TARGET_VIEW_DESC, u, Texture2D, Texture2D_mut, ::D3D12_TEX2D_RTV); UNION!(D3D12_RENDER_TARGET_VIEW_DESC, u, Texture1DArray, Texture1DArray_mut, ::D3D12_TEX1D_ARRAY_RTV); UNION!(D3D12_RENDER_TARGET_VIEW_DESC, u, Texture1D, Texture1D_mut, ::D3D12_TEX1D_RTV); UNION!(D3D12_RENDER_TARGET_VIEW_DESC, u, Buffer, Buffer_mut, ::D3D12_BUFFER_RTV); #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_RESOURCE_ALIASING_BARRIER { pub pResourceBefore: *mut ::ID3D12Resource, pub pResourceAfter: *mut ::ID3D12Resource, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_RESOURCE_ALLOCATION_INFO { pub SizeInBytes: ::UINT64, pub Alignment: ::UINT64, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_RESOURCE_BARRIER { pub Type: ::D3D12_RESOURCE_BARRIER_TYPE, pub Flags: ::D3D12_RESOURCE_BARRIER_FLAGS, pub u: ::D3D12_RESOURCE_TRANSITION_BARRIER, } UNION!(D3D12_RESOURCE_BARRIER, u, UAV, UAV_mut, ::D3D12_RESOURCE_UAV_BARRIER); UNION!(D3D12_RESOURCE_BARRIER, u, Aliasing, Aliasing_mut, ::D3D12_RESOURCE_ALIASING_BARRIER); UNION!(D3D12_RESOURCE_BARRIER, u, Transition, Transition_mut, ::D3D12_RESOURCE_TRANSITION_BARRIER); #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_RESOURCE_DESC { pub Dimension: ::D3D12_RESOURCE_DIMENSION, pub Alignment: ::UINT64, pub Width: ::UINT64, pub Height: ::UINT, pub DepthOrArraySize: ::UINT16, pub MipLevels: ::UINT16, pub Format: ::DXGI_FORMAT, pub SampleDesc: ::DXGI_SAMPLE_DESC, pub Layout: ::D3D12_TEXTURE_LAYOUT, pub Flags: ::D3D12_RESOURCE_FLAGS, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_RESOURCE_TRANSITION_BARRIER { pub pResource: *mut ::ID3D12Resource, pub Subresource: ::UINT, pub StateBefore: ::D3D12_RESOURCE_STATES, pub StateAfter: ::D3D12_RESOURCE_STATES, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_RESOURCE_UAV_BARRIER { pub pResource: *mut ::ID3D12Resource, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_ROOT_CONSTANTS { pub ShaderRegister: ::UINT, pub RegisterSpace: ::UINT, pub Num32BitValues: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_ROOT_DESCRIPTOR { pub ShaderRegister: ::UINT, pub RegisterSpace: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_ROOT_DESCRIPTOR_TABLE { pub NumDescriptorRanges: ::UINT, pub pDescriptorRanges: *const ::D3D12_DESCRIPTOR_RANGE, } #[cfg(target_pointer_width = "64")] #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_ROOT_PARAMETER { pub ParameterType: ::D3D12_ROOT_PARAMETER_TYPE, pub u: ::D3D12_ROOT_DESCRIPTOR_TABLE, pub ShaderVisibility: ::D3D12_SHADER_VISIBILITY, } #[cfg(target_pointer_width = "32")] #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_ROOT_PARAMETER { pub ParameterType: ::D3D12_ROOT_PARAMETER_TYPE, pub u: ::D3D12_ROOT_CONSTANTS, pub ShaderVisibility: ::D3D12_SHADER_VISIBILITY, } UNION!(D3D12_ROOT_PARAMETER, u, Descriptor, Descriptor_mut, ::D3D12_ROOT_DESCRIPTOR); UNION!(D3D12_ROOT_PARAMETER, u, Constants, Constants_mut, ::D3D12_ROOT_CONSTANTS); UNION!(D3D12_ROOT_PARAMETER, u, DescriptorTable, DescriptorTable_mut, ::D3D12_ROOT_DESCRIPTOR_TABLE); #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_ROOT_SIGNATURE_DESC { pub NumParameters: ::UINT, pub pParameters: *const ::D3D12_ROOT_PARAMETER, pub NumStaticSamplers: ::UINT, pub pStaticSamplers: *const ::D3D12_STATIC_SAMPLER_DESC, pub Flags: ::D3D12_ROOT_SIGNATURE_FLAGS, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_SAMPLER_DESC { pub Filter: ::D3D12_FILTER, pub AddressU: ::D3D12_TEXTURE_ADDRESS_MODE, pub AddressV: ::D3D12_TEXTURE_ADDRESS_MODE, pub AddressW: ::D3D12_TEXTURE_ADDRESS_MODE, pub MipLODBias: ::FLOAT, pub MaxAnisotropy: ::UINT, pub ComparisonFunc: ::D3D12_COMPARISON_FUNC, pub BorderColor: [::FLOAT; 4], pub MinLOD: ::FLOAT, pub MaxLOD: ::FLOAT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_SHADER_RESOURCE_VIEW_DESC { pub Format: ::DXGI_FORMAT, pub ViewDimension: ::D3D12_SRV_DIMENSION, pub Shader4ComponentMapping: ::UINT, pub u: ::D3D12_BUFFER_SRV, } UNION!(D3D12_SHADER_RESOURCE_VIEW_DESC, u, TextureCubeArray, TextureCubeArray_mut, ::D3D12_TEXCUBE_ARRAY_SRV); UNION!(D3D12_SHADER_RESOURCE_VIEW_DESC, u, TextureCube, TextureCube_mut, ::D3D12_TEXCUBE_SRV); UNION!(D3D12_SHADER_RESOURCE_VIEW_DESC, u, Texture3D, Texture3D_mut, ::D3D12_TEX3D_SRV); UNION!(D3D12_SHADER_RESOURCE_VIEW_DESC, u, Texture2DMSArray, Texture2DMSArray_mut, ::D3D12_TEX2DMS_ARRAY_SRV); UNION!(D3D12_SHADER_RESOURCE_VIEW_DESC, u, Texture2DMS, Texture2DMS_mut, ::D3D12_TEX2DMS_SRV); UNION!(D3D12_SHADER_RESOURCE_VIEW_DESC, u, Texture2DArray, Texture2DArray_mut, ::D3D12_TEX2D_ARRAY_SRV); UNION!(D3D12_SHADER_RESOURCE_VIEW_DESC, u, Texture2D, Texture2D_mut, ::D3D12_TEX2D_SRV); UNION!(D3D12_SHADER_RESOURCE_VIEW_DESC, u, Texture1DArray, Texture1DArray_mut, ::D3D12_TEX1D_ARRAY_SRV); UNION!(D3D12_SHADER_RESOURCE_VIEW_DESC, u, Texture1D, Texture1D_mut, ::D3D12_TEX1D_SRV); UNION!(D3D12_SHADER_RESOURCE_VIEW_DESC, u, Buffer, Buffer_mut, ::D3D12_BUFFER_SRV); #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_STATIC_SAMPLER_DESC { pub Filter: ::D3D12_FILTER, pub AddressU: ::D3D12_TEXTURE_ADDRESS_MODE, pub AddressV: ::D3D12_TEXTURE_ADDRESS_MODE, pub AddressW: ::D3D12_TEXTURE_ADDRESS_MODE, pub MipLODBias: ::FLOAT, pub MaxAnisotropy: ::UINT, pub ComparisonFunc: ::D3D12_COMPARISON_FUNC, pub BorderColor: ::D3D12_STATIC_BORDER_COLOR, pub MinLOD: ::FLOAT, pub MaxLOD: ::FLOAT, pub ShaderRegister: ::UINT, pub RegisterSpace: ::UINT, pub ShaderVisibility: ::D3D12_SHADER_VISIBILITY, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_STREAM_OUTPUT_BUFFER_VIEW { pub BufferLocation: ::D3D12_GPU_VIRTUAL_ADDRESS, pub SizeInBytes: ::UINT64, pub BufferFilledSizeLocation: ::D3D12_GPU_VIRTUAL_ADDRESS, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_SUBRESOURCE_DATA { pub pData: *const ::c_void, pub RowPitch: ::LONG_PTR, pub SlicePitch: ::LONG_PTR, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_SUBRESOURCE_FOOTPRINT { pub Format: ::DXGI_FORMAT, pub Width: ::UINT, pub Height: ::UINT, pub Depth: ::UINT, pub RowPitch: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_SUBRESOURCE_INFO { pub Offset: ::UINT64, pub RowPitch: ::UINT, pub DepthPitch: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_SUBRESOURCE_TILING { pub WidthInTiles: ::UINT, pub HeightInTiles: ::UINT16, pub DepthInTiles: ::UINT16, pub StartTileIndexInOverallResource: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX1D_ARRAY_DSV { pub MipSlice: ::UINT, pub FirstArraySlice: ::UINT, pub ArraySize: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX1D_ARRAY_RTV { pub MipSlice: ::UINT, pub FirstArraySlice: ::UINT, pub ArraySize: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX1D_ARRAY_SRV { pub MostDetailedMip: ::UINT, pub MipLevels: ::UINT, pub FirstArraySlice: ::UINT, pub ArraySize: ::UINT, pub ResourceMinLODClamp: ::FLOAT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX1D_ARRAY_UAV { pub MipSlice: ::UINT, pub FirstArraySlice: ::UINT, pub ArraySize: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX1D_DSV { pub MipSlice: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX1D_RTV { pub MipSlice: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX1D_SRV { pub MostDetailedMip: ::UINT, pub MipLevels: ::UINT, pub ResourceMinLODClamp: ::FLOAT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX1D_UAV { pub MipSlice: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX2DMS_ARRAY_DSV { pub FirstArraySlice: ::UINT, pub ArraySize: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX2DMS_ARRAY_RTV { pub FirstArraySlice: ::UINT, pub ArraySize: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX2DMS_ARRAY_SRV { pub FirstArraySlice: ::UINT, pub ArraySize: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX2DMS_DSV { pub UnusedField_NothingToDefine: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX2DMS_RTV { pub UnusedField_NothingToDefine: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX2DMS_SRV { pub UnusedField_NothingToDefine: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX2D_ARRAY_DSV { pub MipSlice: ::UINT, pub FirstArraySlice: ::UINT, pub ArraySize: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX2D_ARRAY_RTV { pub MipSlice: ::UINT, pub FirstArraySlice: ::UINT, pub ArraySize: ::UINT, pub PlaneSlice: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX2D_ARRAY_SRV { pub MostDetailedMip: ::UINT, pub MipLevels: ::UINT, pub FirstArraySlice: ::UINT, pub ArraySize: ::UINT, pub PlaneSlice: ::UINT, pub ResourceMinLODClamp: ::FLOAT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX2D_ARRAY_UAV { pub MipSlice: ::UINT, pub FirstArraySlice: ::UINT, pub ArraySize: ::UINT, pub PlaneSlice: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX2D_DSV { pub MipSlice: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX2D_RTV { pub MipSlice: ::UINT, pub PlaneSlice: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX2D_SRV { pub MostDetailedMip: ::UINT, pub MipLevels: ::UINT, pub PlaneSlice: ::UINT, pub ResourceMinLODClamp: ::FLOAT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX2D_UAV { pub MipSlice: ::UINT, pub PlaneSlice: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX3D_RTV { pub MipSlice: ::UINT, pub FirstWSlice: ::UINT, pub WSize: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX3D_SRV { pub MostDetailedMip: ::UINT, pub MipLevels: ::UINT, pub ResourceMinLODClamp: ::FLOAT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEX3D_UAV { pub MipSlice: ::UINT, pub FirstWSlice: ::UINT, pub WSize: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEXCUBE_ARRAY_SRV { pub MostDetailedMip: ::UINT, pub MipLevels: ::UINT, pub First2DArrayFace: ::UINT, pub NumCubes: ::UINT, pub ResourceMinLODClamp: ::FLOAT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEXCUBE_SRV { pub MostDetailedMip: ::UINT, pub MipLevels: ::UINT, pub ResourceMinLODClamp: ::FLOAT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TEXTURE_COPY_LOCATION { pub pResource: *mut ::ID3D12Resource, pub Type: ::D3D12_TEXTURE_COPY_TYPE, pub u: ::D3D12_PLACED_SUBRESOURCE_FOOTPRINT, } UNION!(D3D12_TEXTURE_COPY_LOCATION, u, SubresourceIndex, SubresourceIndex_mut, ::UINT); UNION!(D3D12_TEXTURE_COPY_LOCATION, u, PlacedFootprint, PlacedFootprint_mut, ::D3D12_PLACED_SUBRESOURCE_FOOTPRINT); #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TILED_RESOURCE_COORDINATE { pub X: ::UINT, pub Y: ::UINT, pub Z: ::UINT, pub Subresource: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TILE_REGION_SIZE { pub NumTiles: ::UINT, pub UseBox: ::BOOL, pub Width: ::UINT, pub Height: ::UINT16, pub Depth: ::UINT16, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_TILE_SHAPE { pub WidthInTexels: ::UINT, pub HeightInTexels: ::UINT, pub DepthInTexels: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_UNORDERED_ACCESS_VIEW_DESC { pub Format: ::DXGI_FORMAT, pub ViewDimension: ::D3D12_UAV_DIMENSION, pub u: ::D3D12_BUFFER_UAV, } UNION!(D3D12_UNORDERED_ACCESS_VIEW_DESC, u, Texture3D, Texture3D_mut, ::D3D12_TEX3D_UAV); UNION!(D3D12_UNORDERED_ACCESS_VIEW_DESC, u, Texture2DArray, Texture2DArray_mut, ::D3D12_TEX2D_ARRAY_UAV); UNION!(D3D12_UNORDERED_ACCESS_VIEW_DESC, u, Texture2D, Texture2D_mut, ::D3D12_TEX2D_UAV); UNION!(D3D12_UNORDERED_ACCESS_VIEW_DESC, u, Texture1DArray, Texture1DArray_mut, ::D3D12_TEX1D_ARRAY_UAV); UNION!(D3D12_UNORDERED_ACCESS_VIEW_DESC, u, Texture1D, Texture1D_mut, ::D3D12_TEX1D_UAV); UNION!(D3D12_UNORDERED_ACCESS_VIEW_DESC, u, Buffer, Buffer_mut, ::D3D12_BUFFER_UAV); #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct D3D12_VERTEX_BUFFER_VIEW { pub BufferLocation: ::D3D12_GPU_VIRTUAL_ADDRESS, pub SizeInBytes: ::UINT, pub StrideInBytes: ::UINT, } RIDL!( interface ID3D12CommandAllocator(ID3D12CommandAllocatorVtbl): ID3D12Pageable(ID3D12PageableVtbl) { fn Reset(&mut self) -> ::HRESULT }); RIDL!( interface ID3D12CommandList(ID3D12CommandListVtbl): ID3D12DeviceChild(ID3D12DeviceChildVtbl) { fn GetType(&mut self) -> ::D3D12_COMMAND_LIST_TYPE }); RIDL!( interface ID3D12CommandQueue(ID3D12CommandQueueVtbl): ID3D12Pageable(ID3D12PageableVtbl) { fn UpdateTileMappings( &mut self, pResource: *mut ::ID3D12Resource, NumResourceRegions: ::UINT, pResourceRegionStartCoordinates: *const ::D3D12_TILED_RESOURCE_COORDINATE, pResourceRegionSizes: *const ::D3D12_TILE_REGION_SIZE, pHeap: *mut ::ID3D12Heap, NumRanges: ::UINT, pRangeFlags: *const ::D3D12_TILE_RANGE_FLAGS, pHeapRangeStartOffsets: *const ::UINT, pRangeTileCounts: *const ::UINT, Flags: ::D3D12_TILE_MAPPING_FLAGS ) -> (), fn CopyTileMappings( &mut self, pDstResource: *mut ::ID3D12Resource, pDstRegionStartCoordinate: *const ::D3D12_TILED_RESOURCE_COORDINATE, pSrcResource: *mut ::ID3D12Resource, pSrcRegionStartCoordinate: *const ::D3D12_TILED_RESOURCE_COORDINATE, pRegionSize: *const ::D3D12_TILE_REGION_SIZE, Flags: ::D3D12_TILE_MAPPING_FLAGS ) -> (), fn ExecuteCommandLists( &mut self, NumCommandLists: ::UINT, ppCommandLists: *mut *mut ::ID3D12CommandList ) -> (), fn SetMarker( &mut self, Metadata: ::UINT, pData: *const ::c_void, Size: ::UINT ) -> (), fn BeginEvent( &mut self, Metadata: ::UINT, pData: *const ::c_void, Size: ::UINT ) -> (), fn EndEvent(&mut self) -> (), fn Signal( &mut self, pFence: *mut ::ID3D12Fence, Value: ::UINT64 ) -> ::HRESULT, fn Wait( &mut self, pFence: *mut ::ID3D12Fence, Value: ::UINT64 ) -> ::HRESULT, fn GetTimestampFrequency(&mut self, pFrequency: *mut ::UINT64) -> ::HRESULT, fn GetClockCalibration( &mut self, pGpuTimestamp: *mut ::UINT64, pCpuTimestamp: *mut ::UINT64 ) -> ::HRESULT, fn GetDesc( &mut self, __ret_val: *mut ::D3D12_COMMAND_QUEUE_DESC ) -> *mut ::D3D12_COMMAND_QUEUE_DESC }); RIDL!( interface ID3D12CommandSignature(ID3D12CommandSignatureVtbl): ID3D12Pageable(ID3D12PageableVtbl) { }); RIDL!( interface ID3D12DescriptorHeap(ID3D12DescriptorHeapVtbl): ID3D12Pageable(ID3D12PageableVtbl) { fn GetDesc( &mut self, __ret_val: *mut ::D3D12_DESCRIPTOR_HEAP_DESC ) -> *mut ::D3D12_DESCRIPTOR_HEAP_DESC, fn GetCPUDescriptorHandleForHeapStart( &mut self, __ret_val: *mut ::D3D12_CPU_DESCRIPTOR_HANDLE ) -> *mut ::D3D12_CPU_DESCRIPTOR_HANDLE, fn GetGPUDescriptorHandleForHeapStart( &mut self, __ret_val: *mut ::D3D12_GPU_DESCRIPTOR_HANDLE ) -> *mut ::D3D12_GPU_DESCRIPTOR_HANDLE }); RIDL!( interface ID3D12Device(ID3D12DeviceVtbl): ID3D12Object(ID3D12ObjectVtbl) { fn GetNodeCount(&mut self) -> ::UINT, fn CreateCommandQueue( &mut self, pDesc: *const ::D3D12_COMMAND_QUEUE_DESC, riid: ::REFGUID, ppCommandQueue: *mut *mut ::c_void ) -> ::HRESULT, fn CreateCommandAllocator( &mut self, type_: ::D3D12_COMMAND_LIST_TYPE, riid: ::REFGUID, ppCommandAllocator: *mut *mut ::c_void ) -> ::HRESULT, fn CreateGraphicsPipelineState( &mut self, pDesc: *const ::D3D12_GRAPHICS_PIPELINE_STATE_DESC, riid: ::REFGUID, ppPipelineState: *mut *mut ::c_void ) -> ::HRESULT, fn CreateComputePipelineState( &mut self, pDesc: *const ::D3D12_COMPUTE_PIPELINE_STATE_DESC, riid: ::REFGUID, ppPipelineState: *mut *mut ::c_void ) -> ::HRESULT, fn CreateCommandList( &mut self, nodeMask: ::UINT, type_: ::D3D12_COMMAND_LIST_TYPE, pCommandAllocator: *mut ::ID3D12CommandAllocator, pInitialState: *mut ::ID3D12PipelineState, riid: ::REFGUID, ppCommandList: *mut *mut ::c_void ) -> ::HRESULT, fn CheckFeatureSupport( &mut self, Feature: ::D3D12_FEATURE, pFeatureSupportData: *mut ::c_void, FeatureSupportDataSize: ::UINT ) -> ::HRESULT, fn CreateDescriptorHeap( &mut self, pDescriptorHeapDesc: *const ::D3D12_DESCRIPTOR_HEAP_DESC, riid: ::REFGUID, ppvHeap: *mut *mut ::c_void ) -> ::HRESULT, fn GetDescriptorHandleIncrementSize( &mut self, DescriptorHeapType: ::D3D12_DESCRIPTOR_HEAP_TYPE ) -> ::UINT, fn CreateRootSignature( &mut self, nodeMask: ::UINT, pBlobWithRootSignature: *const ::c_void, blobLengthInBytes: ::SIZE_T, riid: ::REFGUID, ppvRootSignature: *mut *mut ::c_void ) -> ::HRESULT, fn CreateConstantBufferView( &mut self, pDesc: *const ::D3D12_CONSTANT_BUFFER_VIEW_DESC, DestDescriptor: ::D3D12_CPU_DESCRIPTOR_HANDLE ) -> (), fn CreateShaderResourceView( &mut self, pResource: *mut ::ID3D12Resource, pDesc: *const ::D3D12_SHADER_RESOURCE_VIEW_DESC, DestDescriptor: ::D3D12_CPU_DESCRIPTOR_HANDLE ) -> (), fn CreateUnorderedAccessView( &mut self, pResource: *mut ::ID3D12Resource, pCounterResource: *mut ::ID3D12Resource, pDesc: *const ::D3D12_UNORDERED_ACCESS_VIEW_DESC, DestDescriptor: ::D3D12_CPU_DESCRIPTOR_HANDLE ) -> (), fn CreateRenderTargetView( &mut self, pResource: *mut ::ID3D12Resource, pDesc: *const ::D3D12_RENDER_TARGET_VIEW_DESC, DestDescriptor: ::D3D12_CPU_DESCRIPTOR_HANDLE ) -> (), fn CreateDepthStencilView( &mut self, pResource: *mut ::ID3D12Resource, pDesc: *const ::D3D12_DEPTH_STENCIL_VIEW_DESC, DestDescriptor: ::D3D12_CPU_DESCRIPTOR_HANDLE ) -> (), fn CreateSampler( &mut self, pDesc: *const ::D3D12_SAMPLER_DESC, DestDescriptor: ::D3D12_CPU_DESCRIPTOR_HANDLE ) -> (), fn CopyDescriptors( &mut self, NumDestDescriptorRanges: ::UINT, pDestDescriptorRangeStarts: *const ::D3D12_CPU_DESCRIPTOR_HANDLE, pDestDescriptorRangeSizes: *const ::UINT, NumSrcDescriptorRanges: ::UINT, pSrcDescriptorRangeStarts: *const ::D3D12_CPU_DESCRIPTOR_HANDLE, pSrcDescriptorRangeSizes: *const ::UINT, DescriptorHeapsType: ::D3D12_DESCRIPTOR_HEAP_TYPE ) -> (), fn CopyDescriptorsSimple( &mut self, NumDescriptors: ::UINT, DestDescriptorRangeStart: ::D3D12_CPU_DESCRIPTOR_HANDLE, SrcDescriptorRangeStart: ::D3D12_CPU_DESCRIPTOR_HANDLE, DescriptorHeapsType: ::D3D12_DESCRIPTOR_HEAP_TYPE ) -> (), fn GetResourceAllocationInfo( &mut self, visibleMask: ::UINT, numResourceDescs: ::UINT, pResourceDescs: *const ::D3D12_RESOURCE_DESC, __ret_val: *mut ::D3D12_RESOURCE_ALLOCATION_INFO ) -> *mut ::D3D12_RESOURCE_ALLOCATION_INFO, fn GetCustomHeapProperties( &mut self, nodeMask: ::UINT, heapType: ::D3D12_HEAP_TYPE, __ret_val: *mut ::D3D12_HEAP_PROPERTIES ) -> *mut ::D3D12_HEAP_PROPERTIES, fn CreateCommittedResource( &mut self, pHeapProperties: *const ::D3D12_HEAP_PROPERTIES, HeapFlags: ::D3D12_HEAP_FLAGS, pResourceDesc: *const ::D3D12_RESOURCE_DESC, InitialResourceState: ::D3D12_RESOURCE_STATES, pOptimizedClearValue: *const ::D3D12_CLEAR_VALUE, riidResource: ::REFGUID, ppvResource: *mut *mut ::c_void ) -> ::HRESULT, fn CreateHeap( &mut self, pDesc: *const ::D3D12_HEAP_DESC, riid: ::REFGUID, ppvHeap: *mut *mut ::c_void ) -> ::HRESULT, fn CreatePlacedResource( &mut self, pHeap: *mut ::ID3D12Heap, HeapOffset: ::UINT64, pDesc: *const ::D3D12_RESOURCE_DESC, InitialState: ::D3D12_RESOURCE_STATES, pOptimizedClearValue: *const ::D3D12_CLEAR_VALUE, riid: ::REFGUID, ppvResource: *mut *mut ::c_void ) -> ::HRESULT, fn CreateReservedResource( &mut self, pDesc: *const ::D3D12_RESOURCE_DESC, InitialState: ::D3D12_RESOURCE_STATES, pOptimizedClearValue: *const ::D3D12_CLEAR_VALUE, riid: ::REFGUID, ppvResource: *mut *mut ::c_void ) -> ::HRESULT, fn CreateSharedHandle( &mut self, pObject: *mut ::ID3D12DeviceChild, pAttributes: *const ::SECURITY_ATTRIBUTES, Access: ::DWORD, Name: ::LPCWSTR, pHandle: *mut ::HANDLE ) -> ::HRESULT, fn OpenSharedHandle( &mut self, NTHandle: ::HANDLE, riid: ::REFGUID, ppvObj: *mut *mut ::c_void ) -> ::HRESULT, fn OpenSharedHandleByName( &mut self, Name: ::LPCWSTR, Access: ::DWORD, pNTHandle: *mut ::HANDLE ) -> ::HRESULT, fn MakeResident( &mut self, NumObjects: ::UINT, ppObjects: *mut *mut ::ID3D12Pageable ) -> ::HRESULT, fn Evict( &mut self, NumObjects: ::UINT, ppObjects: *mut *mut ::ID3D12Pageable ) -> ::HRESULT, fn CreateFence( &mut self, InitialValue: ::UINT64, Flags: ::D3D12_FENCE_FLAGS, riid: ::REFGUID, ppFence: *mut *mut ::c_void ) -> ::HRESULT, fn GetDeviceRemovedReason(&mut self) -> ::HRESULT, fn GetCopyableFootprints( &mut self, pResourceDesc: *const ::D3D12_RESOURCE_DESC, FirstSubresource: ::UINT, NumSubresources: ::UINT, BaseOffset: ::UINT64, pLayouts: *mut ::D3D12_PLACED_SUBRESOURCE_FOOTPRINT, pNumRows: *mut ::UINT, pRowSizeInBytes: *mut ::UINT64, pTotalBytes: *mut ::UINT64 ) -> (), fn CreateQueryHeap( &mut self, pDesc: *const ::D3D12_QUERY_HEAP_DESC, riid: ::REFGUID, ppvHeap: *mut *mut ::c_void ) -> ::HRESULT, fn SetStablePowerState(&mut self, Enable: ::BOOL) -> ::HRESULT, fn CreateCommandSignature( &mut self, pDesc: *const ::D3D12_COMMAND_SIGNATURE_DESC, pRootSignature: *mut ::ID3D12RootSignature, riid: ::REFGUID, ppvCommandSignature: *mut *mut ::c_void ) -> ::HRESULT, fn GetResourceTiling( &mut self, pTiledResource: *mut ::ID3D12Resource, pNumTilesForEntireResource: *mut ::UINT, pPackedMipDesc: *mut ::D3D12_PACKED_MIP_INFO, pStandardTileShapeForNonPackedMips: *mut ::D3D12_TILE_SHAPE, pNumSubresourceTilings: *mut ::UINT, FirstSubresourceTilingToGet: ::UINT, pSubresourceTilingsForNonPackedMips: *mut ::D3D12_SUBRESOURCE_TILING ) -> (), fn GetAdapterLuid(&mut self, __ret_val: *mut ::LUID) -> *mut ::LUID }); RIDL!( interface ID3D12Fence(ID3D12FenceVtbl): ID3D12Pageable(ID3D12PageableVtbl) { fn GetCompletedValue(&mut self) -> ::UINT64, fn SetEventOnCompletion( &mut self, Value: ::UINT64, hEvent: ::HANDLE ) -> ::HRESULT, fn Signal(&mut self, Value: ::UINT64) -> ::HRESULT }); RIDL!( interface ID3D12GraphicsCommandList(ID3D12GraphicsCommandListVtbl): ID3D12CommandList(ID3D12CommandListVtbl) { fn Close(&mut self) -> ::HRESULT, fn Reset( &mut self, pAllocator: *mut ::ID3D12CommandAllocator, pInitialState: *mut ::ID3D12PipelineState ) -> ::HRESULT, fn ClearState(&mut self, pPipelineState: *mut ::ID3D12PipelineState) -> (), fn DrawInstanced( &mut self, VertexCountPerInstance: ::UINT, InstanceCount: ::UINT, StartVertexLocation: ::UINT, StartInstanceLocation: ::UINT ) -> (), fn DrawIndexedInstanced( &mut self, IndexCountPerInstance: ::UINT, InstanceCount: ::UINT, StartIndexLocation: ::UINT, BaseVertexLocation: ::INT, StartInstanceLocation: ::UINT ) -> (), fn Dispatch( &mut self, ThreadGroupCountX: ::UINT, ThreadGroupCountY: ::UINT, ThreadGroupCountZ: ::UINT ) -> (), fn CopyBufferRegion( &mut self, pDstBuffer: *mut ::ID3D12Resource, DstOffset: ::UINT64, pSrcBuffer: *mut ::ID3D12Resource, SrcOffset: ::UINT64, NumBytes: ::UINT64 ) -> (), fn CopyTextureRegion( &mut self, pDst: *const ::D3D12_TEXTURE_COPY_LOCATION, DstX: ::UINT, DstY: ::UINT, DstZ: ::UINT, pSrc: *const ::D3D12_TEXTURE_COPY_LOCATION, pSrcBox: *const ::D3D12_BOX ) -> (), fn CopyResource( &mut self, pDstResource: *mut ::ID3D12Resource, pSrcResource: *mut ::ID3D12Resource ) -> (), fn CopyTiles( &mut self, pTiledResource: *mut ::ID3D12Resource, pTileRegionStartCoordinate: *const ::D3D12_TILED_RESOURCE_COORDINATE, pTileRegionSize: *const ::D3D12_TILE_REGION_SIZE, pBuffer: *mut ::ID3D12Resource, BufferStartOffsetInBytes: ::UINT64, Flags: ::D3D12_TILE_COPY_FLAGS ) -> (), fn ResolveSubresource( &mut self, pDstResource: *mut ::ID3D12Resource, DstSubresource: ::UINT, pSrcResource: *mut ::ID3D12Resource, SrcSubresource: ::UINT, Format: ::DXGI_FORMAT ) -> (), fn IASetPrimitiveTopology( &mut self, PrimitiveTopology: ::D3D12_PRIMITIVE_TOPOLOGY ) -> (), fn RSSetViewports( &mut self, NumViewports: ::UINT, pViewports: *const ::D3D12_VIEWPORT ) -> (), fn RSSetScissorRects( &mut self, NumRects: ::UINT, pRects: *const ::D3D12_RECT ) -> (), fn OMSetBlendFactor(&mut self, BlendFactor: *const [::FLOAT; 4]) -> (), fn OMSetStencilRef(&mut self, StencilRef: ::UINT) -> (), fn SetPipelineState( &mut self, pPipelineState: *mut ::ID3D12PipelineState ) -> (), fn ResourceBarrier( &mut self, NumBarriers: ::UINT, pBarriers: *const ::D3D12_RESOURCE_BARRIER ) -> (), fn ExecuteBundle( &mut self, pCommandList: *mut ::ID3D12GraphicsCommandList ) -> (), fn SetDescriptorHeaps( &mut self, NumDescriptorHeaps: ::UINT, ppDescriptorHeaps: *mut *mut ::ID3D12DescriptorHeap ) -> (), fn SetComputeRootSignature( &mut self, pRootSignature: *mut ::ID3D12RootSignature ) -> (), fn SetGraphicsRootSignature( &mut self, pRootSignature: *mut ::ID3D12RootSignature ) -> (), fn SetComputeRootDescriptorTable( &mut self, RootParameterIndex: ::UINT, BaseDescriptor: ::D3D12_GPU_DESCRIPTOR_HANDLE ) -> (), fn SetGraphicsRootDescriptorTable( &mut self, RootParameterIndex: ::UINT, BaseDescriptor: ::D3D12_GPU_DESCRIPTOR_HANDLE ) -> (), fn SetComputeRoot32BitConstant( &mut self, RootParameterIndex: ::UINT, SrcData: ::UINT, DestOffsetIn32BitValues: ::UINT ) -> (), fn SetGraphicsRoot32BitConstant( &mut self, RootParameterIndex: ::UINT, SrcData: ::UINT, DestOffsetIn32BitValues: ::UINT ) -> (), fn SetComputeRoot32BitConstants( &mut self, RootParameterIndex: ::UINT, Num32BitValuesToSet: ::UINT, pSrcData: *const ::c_void, DestOffsetIn32BitValues: ::UINT ) -> (), fn SetGraphicsRoot32BitConstants( &mut self, RootParameterIndex: ::UINT, Num32BitValuesToSet: ::UINT, pSrcData: *const ::c_void, DestOffsetIn32BitValues: ::UINT ) -> (), fn SetComputeRootConstantBufferView( &mut self, RootParameterIndex: ::UINT, BufferLocation: ::D3D12_GPU_VIRTUAL_ADDRESS ) -> (), fn SetGraphicsRootConstantBufferView( &mut self, RootParameterIndex: ::UINT, BufferLocation: ::D3D12_GPU_VIRTUAL_ADDRESS ) -> (), fn SetComputeRootShaderResourceView( &mut self, RootParameterIndex: ::UINT, BufferLocation: ::D3D12_GPU_VIRTUAL_ADDRESS ) -> (), fn SetGraphicsRootShaderResourceView( &mut self, RootParameterIndex: ::UINT, BufferLocation: ::D3D12_GPU_VIRTUAL_ADDRESS ) -> (), fn SetComputeRootUnorderedAccessView( &mut self, RootParameterIndex: ::UINT, BufferLocation: ::D3D12_GPU_VIRTUAL_ADDRESS ) -> (), fn SetGraphicsRootUnorderedAccessView( &mut self, RootParameterIndex: ::UINT, BufferLocation: ::D3D12_GPU_VIRTUAL_ADDRESS ) -> (), fn IASetIndexBuffer( &mut self, pView: *const ::D3D12_INDEX_BUFFER_VIEW ) -> (), fn IASetVertexBuffers( &mut self, StartSlot: ::UINT, NumViews: ::UINT, pViews: *const ::D3D12_VERTEX_BUFFER_VIEW ) -> (), fn SOSetTargets( &mut self, StartSlot: ::UINT, NumViews: ::UINT, pViews: *const ::D3D12_STREAM_OUTPUT_BUFFER_VIEW ) -> (), fn OMSetRenderTargets( &mut self, NumRenderTargetDescriptors: ::UINT, pRenderTargetDescriptors: *const ::D3D12_CPU_DESCRIPTOR_HANDLE, RTsSingleHandleToDescriptorRange: ::BOOL, pDepthStencilDescriptor: *const ::D3D12_CPU_DESCRIPTOR_HANDLE ) -> (), fn ClearDepthStencilView( &mut self, DepthStencilView: ::D3D12_CPU_DESCRIPTOR_HANDLE, ClearFlags: ::D3D12_CLEAR_FLAGS, Depth: ::FLOAT, Stencil: ::UINT8, NumRects: ::UINT, pRects: *const ::D3D12_RECT ) -> (), fn ClearRenderTargetView( &mut self, RenderTargetView: ::D3D12_CPU_DESCRIPTOR_HANDLE, ColorRGBA: *const [::FLOAT; 4], NumRects: ::UINT, pRects: *const ::D3D12_RECT ) -> (), fn ClearUnorderedAccessViewUint( &mut self, ViewGPUHandleInCurrentHeap: ::D3D12_GPU_DESCRIPTOR_HANDLE, ViewCPUHandle: ::D3D12_CPU_DESCRIPTOR_HANDLE, pResource: *mut ::ID3D12Resource, Values: *const [::UINT; 4], NumRects: ::UINT, pRects: *const ::D3D12_RECT ) -> (), fn ClearUnorderedAccessViewFloat( &mut self, ViewGPUHandleInCurrentHeap: ::D3D12_GPU_DESCRIPTOR_HANDLE, ViewCPUHandle: ::D3D12_CPU_DESCRIPTOR_HANDLE, pResource: *mut ::ID3D12Resource, Values: *const [::FLOAT; 4], NumRects: ::UINT, pRects: *const ::D3D12_RECT ) -> (), fn DiscardResource( &mut self, pResource: *mut ::ID3D12Resource, pRegion: *const ::D3D12_DISCARD_REGION ) -> (), fn BeginQuery( &mut self, pQueryHeap: *mut ::ID3D12QueryHeap, Type: ::D3D12_QUERY_TYPE, Index: ::UINT ) -> (), fn EndQuery( &mut self, pQueryHeap: *mut ::ID3D12QueryHeap, Type: ::D3D12_QUERY_TYPE, Index: ::UINT ) -> (), fn ResolveQueryData( &mut self, pQueryHeap: *mut ::ID3D12QueryHeap, Type: ::D3D12_QUERY_TYPE, StartIndex: ::UINT, NumQueries: ::UINT, pDestinationBuffer: *mut ::ID3D12Resource, AlignedDestinationBufferOffset: ::UINT64 ) -> (), fn SetPredication( &mut self, pBuffer: *mut ::ID3D12Resource, AlignedBufferOffset: ::UINT64, Operation: ::D3D12_PREDICATION_OP ) -> (), fn SetMarker( &mut self, Metadata: ::UINT, pData: *const ::c_void, Size: ::UINT ) -> (), fn BeginEvent( &mut self, Metadata: ::UINT, pData: *const ::c_void, Size: ::UINT ) -> (), fn EndEvent(&mut self) -> (), fn ExecuteIndirect( &mut self, pCommandSignature: *mut ::ID3D12CommandSignature, MaxCommandCount: ::UINT, pArgumentBuffer: *mut ::ID3D12Resource, ArgumentBufferOffset: ::UINT64, pCountBuffer: *mut ::ID3D12Resource, CountBufferOffset: ::UINT64 ) -> () }); RIDL!( interface ID3D12Heap(ID3D12HeapVtbl): ID3D12Pageable(ID3D12PageableVtbl) { fn GetDesc( &mut self, __ret_val: *mut ::D3D12_HEAP_DESC ) -> *mut ::D3D12_HEAP_DESC }); RIDL!( interface ID3D12Pageable(ID3D12PageableVtbl): ID3D12DeviceChild(ID3D12DeviceChildVtbl) { }); RIDL!( interface ID3D12PipelineState(ID3D12PipelineStateVtbl): ID3D12Pageable(ID3D12PageableVtbl) { fn GetCachedBlob(&mut self, ppBlob: *mut *mut ::ID3DBlob) -> ::HRESULT }); RIDL!( interface ID3D12QueryHeap(ID3D12QueryHeapVtbl): ID3D12Pageable(ID3D12PageableVtbl) { }); RIDL!( interface ID3D12Resource(ID3D12ResourceVtbl): ID3D12Pageable(ID3D12PageableVtbl) { fn Map( &mut self, Subresource: ::UINT, pReadRange: *const ::D3D12_RANGE, ppData: *mut *mut ::c_void ) -> ::HRESULT, fn Unmap( &mut self, Subresource: ::UINT, pWrittenRange: *const ::D3D12_RANGE ) -> (), fn GetDesc( &mut self, __ret_val: *mut ::D3D12_RESOURCE_DESC ) -> *mut ::D3D12_RESOURCE_DESC, fn GetGPUVirtualAddress(&mut self) -> ::D3D12_GPU_VIRTUAL_ADDRESS, fn WriteToSubresource( &mut self, DstSubresource: ::UINT, pDstBox: *const ::D3D12_BOX, pSrcData: *const ::c_void, SrcRowPitch: ::UINT, SrcDepthPitch: ::UINT ) -> ::HRESULT, fn ReadFromSubresource( &mut self, pDstData: *mut ::c_void, DstRowPitch: ::UINT, DstDepthPitch: ::UINT, SrcSubresource: ::UINT, pSrcBox: *const ::D3D12_BOX ) -> ::HRESULT, fn GetHeapProperties( &mut self, pHeapProperties: *mut ::D3D12_HEAP_PROPERTIES, pHeapFlags: *mut ::D3D12_HEAP_FLAGS ) -> ::HRESULT }); RIDL!( interface ID3D12RootSignatureDeserializer(ID3D12RootSignatureDeserializerVtbl): IUnknown(IUnknownVtbl) { fn GetRootSignatureDesc(&mut self) -> *const ::D3D12_ROOT_SIGNATURE_DESC }); pub type PFN_D3D12_CREATE_DEVICE = extern "system" fn (_ : *mut ::IUnknown, _ : ::D3D_FEATURE_LEVEL, _ : ::REFGUID, _ : *mut *mut ::c_void) -> ::HRESULT; pub type PFN_D3D12_CREATE_ROOT_SIGNATURE_DESERIALIZER = extern "system" fn (pSrcData: ::LPCVOID, SrcDataSizeInBytes: ::SIZE_T, pRootSignatureDeserializerInterface: ::REFGUID, ppRootSignatureDeserializer: *mut *mut ::c_void) -> ::HRESULT; pub type PFN_D3D12_GET_DEBUG_INTERFACE = extern "system" fn (_ : ::REFGUID, _ : *mut *mut ::c_void) -> ::HRESULT; pub type PFN_D3D12_SERIALIZE_ROOT_SIGNATURE = extern "system" fn (pRootSignature: *const ::D3D12_ROOT_SIGNATURE_DESC, Version: ::D3D_ROOT_SIGNATURE_VERSION, ppBlob: *mut *mut ::ID3DBlob, ppErrorBlob: *mut *mut ::ID3DBlob) -> ::HRESULT; DEFINE_GUID!(IID_ID3D12Object,0xc4fec28f,0x7966,0x4e95,0x9f,0x94,0xf4,0x31,0xcb, 0x56,0xc3,0xb8); DEFINE_GUID!(IID_ID3D12DeviceChild,0x905db94b,0xa00c,0x4140,0x9d,0xf5,0x2b,0x64, 0xca,0x9e,0xa3,0x57); DEFINE_GUID!(IID_ID3D12RootSignature,0xc54a6b66,0x72df,0x4ee8,0x8b,0xe5,0xa9, 0x46,0xa1,0x42,0x92,0x14); DEFINE_GUID!(IID_ID3D12RootSignatureDeserializer,0x34AB647B,0x3CC8,0x46AC,0x84, 0x1B,0xC0,0x96,0x56,0x45,0xC0,0x46); DEFINE_GUID!(IID_ID3D12Pageable,0x63ee58fb,0x1268,0x4835,0x86,0xda,0xf0,0x08, 0xce,0x62,0xf0,0xd6); DEFINE_GUID!(IID_ID3D12Heap,0x6b3b2502,0x6e51,0x45b3,0x90,0xee,0x98,0x84,0x26, 0x5e,0x8d,0xf3); DEFINE_GUID!(IID_ID3D12Resource,0x696442be,0xa72e,0x4059,0xbc,0x79,0x5b,0x5c, 0x98,0x04,0x0f,0xad); DEFINE_GUID!(IID_ID3D12CommandAllocator,0x6102dee4,0xaf59,0x4b09,0xb9,0x99,0xb4, 0x4d,0x73,0xf0,0x9b,0x24); DEFINE_GUID!(IID_ID3D12Fence,0x0a753dcf,0xc4d8,0x4b91,0xad,0xf6,0xbe,0x5a,0x60, 0xd9,0x5a,0x76); DEFINE_GUID!(IID_ID3D12PipelineState,0x765a30f3,0xf624,0x4c6f,0xa8,0x28,0xac, 0xe9,0x48,0x62,0x24,0x45); DEFINE_GUID!(IID_ID3D12DescriptorHeap,0x8efb471d,0x616c,0x4f49,0x90,0xf7,0x12, 0x7b,0xb7,0x63,0xfa,0x51); DEFINE_GUID!(IID_ID3D12QueryHeap,0x0d9658ae,0xed45,0x469e,0xa6,0x1d,0x97,0x0e, 0xc5,0x83,0xca,0xb4); DEFINE_GUID!(IID_ID3D12CommandSignature,0xc36a797c,0xec80,0x4f0a,0x89,0x85,0xa7, 0xb2,0x47,0x50,0x82,0xd1); DEFINE_GUID!(IID_ID3D12CommandList,0x7116d91c,0xe7e4,0x47ce,0xb8,0xc6,0xec,0x81, 0x68,0xf4,0x37,0xe5); DEFINE_GUID!(IID_ID3D12GraphicsCommandList,0x5b160d0f,0xac1b,0x4185,0x8b,0xa8, 0xb3,0xae,0x42,0xa5,0xa4,0x55); DEFINE_GUID!(IID_ID3D12CommandQueue,0x0ec870a6,0x5d7e,0x4c22,0x8c,0xfc,0x5b, 0xaa,0xe0,0x76,0x16,0xed); DEFINE_GUID!(IID_ID3D12Device,0x189819f1,0x1db6,0x4b57,0xbe,0x54,0x18,0x21,0x33, 0x9b,0x85,0xf7); deps/winapi-0.2.5/src/dwmapi.rs0000644000000000000000000000046012613167613015062 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Procedure declarations, constant definitions, and macros for the NLS component. STRUCT!{struct DWM_BLURBEHIND { dwFlags: ::DWORD, fEnable: ::BOOL, hRgnBlur: ::HRGN, fTransitionOnMaximized: ::BOOL, }} deps/winapi-0.2.5/src/winsvc.rs0000644000000000000000000002631212615662007015115 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Header file for the Service Control Manager //80 pub const SERVICE_NO_CHANGE: ::DWORD = 0xffffffff; pub const SERVICE_ACTIVE: ::DWORD = 0x00000001; pub const SERVICE_INACTIVE: ::DWORD = 0x00000002; pub const SERVICE_STATE_ALL: ::DWORD = SERVICE_ACTIVE | SERVICE_INACTIVE; pub const SERVICE_CONTROL_STOP: ::DWORD = 0x00000001; pub const SERVICE_CONTROL_PAUSE: ::DWORD = 0x00000002; pub const SERVICE_CONTROL_CONTINUE: ::DWORD = 0x00000003; pub const SERVICE_CONTROL_INTERROGATE: ::DWORD = 0x00000004; pub const SERVICE_CONTROL_SHUTDOWN: ::DWORD = 0x00000005; pub const SERVICE_CONTROL_PARAMCHANGE: ::DWORD = 0x00000006; pub const SERVICE_CONTROL_NETBINDADD: ::DWORD = 0x00000007; pub const SERVICE_CONTROL_NETBINDREMOVE: ::DWORD = 0x00000008; pub const SERVICE_CONTROL_NETBINDENABLE: ::DWORD = 0x00000009; pub const SERVICE_CONTROL_NETBINDDISABLE: ::DWORD = 0x0000000A; pub const SERVICE_CONTROL_DEVICEEVENT: ::DWORD = 0x0000000B; pub const SERVICE_CONTROL_HARDWAREPROFILECHANGE: ::DWORD = 0x0000000C; pub const SERVICE_CONTROL_POWEREVENT: ::DWORD = 0x0000000D; pub const SERVICE_CONTROL_SESSIONCHANGE: ::DWORD = 0x0000000E; pub const SERVICE_CONTROL_PRESHUTDOWN: ::DWORD = 0x0000000F; pub const SERVICE_CONTROL_TIMECHANGE: ::DWORD = 0x00000010; pub const SERVICE_CONTROL_TRIGGEREVENT: ::DWORD = 0x00000020; pub const SERVICE_STOPPED: ::DWORD = 0x00000001; pub const SERVICE_START_PENDING: ::DWORD = 0x00000002; pub const SERVICE_STOP_PENDING: ::DWORD = 0x00000003; pub const SERVICE_RUNNING: ::DWORD = 0x00000004; pub const SERVICE_CONTINUE_PENDING: ::DWORD = 0x00000005; pub const SERVICE_PAUSE_PENDING: ::DWORD = 0x00000006; pub const SERVICE_PAUSED: ::DWORD = 0x00000007; pub const SERVICE_ACCEPT_STOP: ::DWORD = 0x00000001; pub const SERVICE_ACCEPT_PAUSE_CONTINUE: ::DWORD = 0x00000002; pub const SERVICE_ACCEPT_SHUTDOWN: ::DWORD = 0x00000004; pub const SERVICE_ACCEPT_PARAMCHANGE: ::DWORD = 0x00000008; pub const SERVICE_ACCEPT_NETBINDCHANGE: ::DWORD = 0x00000010; pub const SERVICE_ACCEPT_HARDWAREPROFILECHANGE: ::DWORD = 0x00000020; pub const SERVICE_ACCEPT_POWEREVENT: ::DWORD = 0x00000040; pub const SERVICE_ACCEPT_SESSIONCHANGE: ::DWORD = 0x00000080; pub const SERVICE_ACCEPT_PRESHUTDOWN: ::DWORD = 0x00000100; pub const SERVICE_ACCEPT_TIMECHANGE: ::DWORD = 0x00000200; pub const SERVICE_ACCEPT_TRIGGEREVENT: ::DWORD = 0x00000400; pub const SC_MANAGER_CONNECT: ::DWORD = 0x0001; pub const SC_MANAGER_CREATE_SERVICE: ::DWORD = 0x0002; pub const SC_MANAGER_ENUMERATE_SERVICE: ::DWORD = 0x0004; pub const SC_MANAGER_LOCK: ::DWORD = 0x0008; pub const SC_MANAGER_QUERY_LOCK_STATUS: ::DWORD = 0x0010; pub const SC_MANAGER_MODIFY_BOOT_CONFIG: ::DWORD = 0x0020; pub const SC_MANAGER_ALL_ACCESS: ::DWORD = ::STANDARD_RIGHTS_REQUIRED | SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_LOCK | SC_MANAGER_QUERY_LOCK_STATUS | SC_MANAGER_MODIFY_BOOT_CONFIG; pub const SERVICE_QUERY_CONFIG: ::DWORD = 0x0001; pub const SERVICE_CHANGE_CONFIG: ::DWORD = 0x0002; pub const SERVICE_QUERY_STATUS: ::DWORD = 0x0004; pub const SERVICE_ENUMERATE_DEPENDENTS: ::DWORD = 0x0008; pub const SERVICE_START: ::DWORD = 0x0010; pub const SERVICE_STOP: ::DWORD = 0x0020; pub const SERVICE_PAUSE_CONTINUE: ::DWORD = 0x0040; pub const SERVICE_INTERROGATE: ::DWORD = 0x0080; pub const SERVICE_USER_DEFINED_CONTROL: ::DWORD = 0x0100; pub const SERVICE_ALL_ACCESS: ::DWORD = ::STANDARD_RIGHTS_REQUIRED | SERVICE_QUERY_CONFIG | SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_START | SERVICE_STOP | SERVICE_PAUSE_CONTINUE | SERVICE_INTERROGATE | SERVICE_USER_DEFINED_CONTROL; pub const SERVICE_RUNS_IN_SYSTEM_PROCESS: ::DWORD = 0x00000001; pub const SERVICE_CONFIG_DESCRIPTION: ::DWORD = 1; pub const SERVICE_CONFIG_FAILURE_ACTIONS: ::DWORD = 2; pub const SERVICE_CONFIG_DELAYED_AUTO_START_INFO: ::DWORD = 3; pub const SERVICE_CONFIG_FAILURE_ACTIONS_FLAG: ::DWORD = 4; pub const SERVICE_CONFIG_SERVICE_SID_INFO: ::DWORD = 5; pub const SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO: ::DWORD = 6; pub const SERVICE_CONFIG_PRESHUTDOWN_INFO: ::DWORD = 7; pub const SERVICE_CONFIG_TRIGGER_INFO: ::DWORD = 8; pub const SERVICE_CONFIG_PREFERRED_NODE: ::DWORD = 9; pub const SERVICE_CONFIG_LAUNCH_PROTECTED: ::DWORD = 12; pub const SERVICE_NOTIFY_STATUS_CHANGE_1: ::DWORD = 1; pub const SERVICE_NOTIFY_STATUS_CHANGE_2: ::DWORD = 2; pub const SERVICE_NOTIFY_STATUS_CHANGE: ::DWORD = SERVICE_NOTIFY_STATUS_CHANGE_2; pub const SERVICE_NOTIFY_STOPPED: ::DWORD = 0x00000001; pub const SERVICE_NOTIFY_START_PENDING: ::DWORD = 0x00000002; pub const SERVICE_NOTIFY_STOP_PENDING: ::DWORD = 0x00000004; pub const SERVICE_NOTIFY_RUNNING: ::DWORD = 0x00000008; pub const SERVICE_NOTIFY_CONTINUE_PENDING: ::DWORD = 0x00000010; pub const SERVICE_NOTIFY_PAUSE_PENDING: ::DWORD = 0x00000020; pub const SERVICE_NOTIFY_PAUSED: ::DWORD = 0x00000040; pub const SERVICE_NOTIFY_CREATED: ::DWORD = 0x00000080; pub const SERVICE_NOTIFY_DELETED: ::DWORD = 0x00000100; pub const SERVICE_NOTIFY_DELETE_PENDING: ::DWORD = 0x00000200; pub const SERVICE_STOP_REASON_FLAG_MIN: ::DWORD = 0x00000000; pub const SERVICE_STOP_REASON_FLAG_UNPLANNED: ::DWORD = 0x10000000; pub const SERVICE_STOP_REASON_FLAG_CUSTOM: ::DWORD = 0x20000000; pub const SERVICE_STOP_REASON_FLAG_PLANNED: ::DWORD = 0x40000000; pub const SERVICE_STOP_REASON_FLAG_MAX: ::DWORD = 0x80000000; pub const SERVICE_STOP_REASON_MAJOR_MIN: ::DWORD = 0x00000000; pub const SERVICE_STOP_REASON_MAJOR_OTHER: ::DWORD = 0x00010000; pub const SERVICE_STOP_REASON_MAJOR_HARDWARE: ::DWORD = 0x00020000; pub const SERVICE_STOP_REASON_MAJOR_OPERATINGSYSTEM: ::DWORD = 0x00030000; pub const SERVICE_STOP_REASON_MAJOR_SOFTWARE: ::DWORD = 0x00040000; pub const SERVICE_STOP_REASON_MAJOR_APPLICATION: ::DWORD = 0x00050000; pub const SERVICE_STOP_REASON_MAJOR_NONE: ::DWORD = 0x00060000; pub const SERVICE_STOP_REASON_MAJOR_MAX: ::DWORD = 0x00070000; pub const SERVICE_STOP_REASON_MAJOR_MIN_CUSTOM: ::DWORD = 0x00400000; pub const SERVICE_STOP_REASON_MAJOR_MAX_CUSTOM: ::DWORD = 0x00ff0000; pub const SERVICE_STOP_REASON_MINOR_MIN: ::DWORD = 0x00000000; pub const SERVICE_STOP_REASON_MINOR_OTHER: ::DWORD = 0x00000001; pub const SERVICE_STOP_REASON_MINOR_MAINTENANCE: ::DWORD = 0x00000002; pub const SERVICE_STOP_REASON_MINOR_INSTALLATION: ::DWORD = 0x00000003; pub const SERVICE_STOP_REASON_MINOR_UPGRADE: ::DWORD = 0x00000004; pub const SERVICE_STOP_REASON_MINOR_RECONFIG: ::DWORD = 0x00000005; pub const SERVICE_STOP_REASON_MINOR_HUNG: ::DWORD = 0x00000006; pub const SERVICE_STOP_REASON_MINOR_UNSTABLE: ::DWORD = 0x00000007; pub const SERVICE_STOP_REASON_MINOR_DISK: ::DWORD = 0x00000008; pub const SERVICE_STOP_REASON_MINOR_NETWORKCARD: ::DWORD = 0x00000009; pub const SERVICE_STOP_REASON_MINOR_ENVIRONMENT: ::DWORD = 0x0000000a; pub const SERVICE_STOP_REASON_MINOR_HARDWARE_DRIVER: ::DWORD = 0x0000000b; pub const SERVICE_STOP_REASON_MINOR_OTHERDRIVER: ::DWORD = 0x0000000c; pub const SERVICE_STOP_REASON_MINOR_SERVICEPACK: ::DWORD = 0x0000000d; pub const SERVICE_STOP_REASON_MINOR_SOFTWARE_UPDATE: ::DWORD = 0x0000000e; pub const SERVICE_STOP_REASON_MINOR_SECURITYFIX: ::DWORD = 0x0000000f; pub const SERVICE_STOP_REASON_MINOR_SECURITY: ::DWORD = 0x00000010; pub const SERVICE_STOP_REASON_MINOR_NETWORK_CONNECTIVITY: ::DWORD = 0x00000011; pub const SERVICE_STOP_REASON_MINOR_WMI: ::DWORD = 0x00000012; pub const SERVICE_STOP_REASON_MINOR_SERVICEPACK_UNINSTALL: ::DWORD = 0x00000013; pub const SERVICE_STOP_REASON_MINOR_SOFTWARE_UPDATE_UNINSTALL: ::DWORD = 0x00000014; pub const SERVICE_STOP_REASON_MINOR_SECURITYFIX_UNINSTALL: ::DWORD = 0x00000015; pub const SERVICE_STOP_REASON_MINOR_MMC: ::DWORD = 0x00000016; pub const SERVICE_STOP_REASON_MINOR_NONE: ::DWORD = 0x00000017; pub const SERVICE_STOP_REASON_MINOR_MAX: ::DWORD = 0x00000018; pub const SERVICE_STOP_REASON_MINOR_MIN_CUSTOM: ::DWORD = 0x00000100; pub const SERVICE_STOP_REASON_MINOR_MAX_CUSTOM: ::DWORD = 0x0000FFFF; pub const SERVICE_CONTROL_STATUS_REASON_INFO: ::DWORD = 1; pub const SERVICE_SID_TYPE_NONE: ::DWORD = 0x00000000; pub const SERVICE_SID_TYPE_UNRESTRICTED: ::DWORD = 0x00000001; pub const SERVICE_SID_TYPE_RESTRICTED: ::DWORD = 0x00000002 | SERVICE_SID_TYPE_UNRESTRICTED; pub const SERVICE_TRIGGER_TYPE_DEVICE_INTERFACE_ARRIVAL: ::DWORD = 1; pub const SERVICE_TRIGGER_TYPE_IP_ADDRESS_AVAILABILITY: ::DWORD = 2; pub const SERVICE_TRIGGER_TYPE_DOMAIN_JOIN: ::DWORD = 3; pub const SERVICE_TRIGGER_TYPE_FIREWALL_PORT_EVENT: ::DWORD = 4; pub const SERVICE_TRIGGER_TYPE_GROUP_POLICY: ::DWORD = 5; pub const SERVICE_TRIGGER_TYPE_NETWORK_ENDPOINT: ::DWORD = 6; pub const SERVICE_TRIGGER_TYPE_CUSTOM_SYSTEM_STATE_CHANGE: ::DWORD = 7; pub const SERVICE_TRIGGER_TYPE_CUSTOM: ::DWORD = 20; pub const SERVICE_TRIGGER_DATA_TYPE_BINARY: ::DWORD = 1; pub const SERVICE_TRIGGER_DATA_TYPE_STRING: ::DWORD = 2; pub const SERVICE_TRIGGER_DATA_TYPE_LEVEL: ::DWORD = 3; pub const SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ANY: ::DWORD = 4; pub const SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ALL: ::DWORD = 5; pub const SERVICE_START_REASON_DEMAND: ::DWORD = 0x00000001; pub const SERVICE_START_REASON_AUTO: ::DWORD = 0x00000002; pub const SERVICE_START_REASON_TRIGGER: ::DWORD = 0x00000004; pub const SERVICE_START_REASON_RESTART_ON_FAILURE: ::DWORD = 0x00000008; pub const SERVICE_START_REASON_DELAYEDAUTO: ::DWORD = 0x00000010; pub const SERVICE_DYNAMIC_INFORMATION_LEVEL_START_REASON: ::DWORD = 1; pub const SERVICE_LAUNCH_PROTECTED_NONE: ::DWORD = 0; pub const SERVICE_LAUNCH_PROTECTED_WINDOWS: ::DWORD = 1; pub const SERVICE_LAUNCH_PROTECTED_WINDOWS_LIGHT: ::DWORD = 2; pub const SERVICE_LAUNCH_PROTECTED_ANTIMALWARE_LIGHT: ::DWORD = 3; //678 DECLARE_HANDLE!(SC_HANDLE, SC_HANDLE__); pub type LPSC_HANDLE = *mut SC_HANDLE; DECLARE_HANDLE!(SERVICE_STATUS_HANDLE, SERVICE_STATUS_HANDLE__); ENUM!{enum SC_STATUS_TYPE { SC_STATUS_PROCESS_INFO = 0, }} ENUM!{enum _SC_ENUM_TYPE { SC_ENUM_PROCESS_INFO = 0, }} //700 STRUCT!{struct SERVICE_STATUS { dwServiceType: ::DWORD, dwCurrentState: ::DWORD, dwControlsAccepted: ::DWORD, dwWin32ExitCode: ::DWORD, dwServiceSpecificExitCode: ::DWORD, dwCheckPoint: ::DWORD, dwWaitHint: ::DWORD, }} pub type LPSERVICE_STATUS = *mut SERVICE_STATUS; //848 pub type LPSERVICE_MAIN_FUNCTIONW = Option; pub type LPSERVICE_MAIN_FUNCTIONA = Option; #[repr(C)] #[derive(Copy)] pub struct SERVICE_TABLE_ENTRYA { pub lpServiceName: ::LPCSTR, pub lpServiceProc: LPSERVICE_MAIN_FUNCTIONA, } impl Clone for SERVICE_TABLE_ENTRYA { fn clone(&self) -> SERVICE_TABLE_ENTRYA { *self } } pub type LPSERVICE_TABLE_ENTRYA = *mut SERVICE_TABLE_ENTRYA; #[repr(C)] #[derive(Copy)] pub struct SERVICE_TABLE_ENTRYW { pub lpServiceName: ::LPCWSTR, pub lpServiceProc: LPSERVICE_MAIN_FUNCTIONW, } impl Clone for SERVICE_TABLE_ENTRYW { fn clone(&self) -> SERVICE_TABLE_ENTRYW { *self } } pub type LPSERVICE_TABLE_ENTRYW = *mut SERVICE_TABLE_ENTRYW; //900 pub type LPHANDLER_FUNCTION = Option; pub type LPHANDLER_FUNCTION_EX = Option ::DWORD>; deps/winapi-0.2.5/src/oaidl.rs0000644000000000000000000005315612615662007014702 0ustar rootroot// Copyright © 2015, Connor Hilarides // Licensed under the MIT License //! Mappings for the contents of OAIdl.h pub type wireBRECORD = *mut _wireBRECORD; pub type wireVARIANT = *mut _wireVARIANT; STRUCT!{struct SAFEARRAYBOUND { cElements: ::ULONG, lLbound: ::LONG, }} STRUCT!{struct SAFEARR_BSTR { Size: ::ULONG, aBstr: *mut ::wireBSTR, }} STRUCT!{struct SAFEARR_UNKNOWN { Size: ::ULONG, apUnknown: *mut *mut ::IUnknown, }} STRUCT!{struct SAFEARR_DISPATCH { Size: ::ULONG, apDispatch: *mut *mut IDispatch, }} STRUCT!{struct SAFEARR_VARIANT { Size: ::ULONG, aVariant: *mut wireVARIANT, }} STRUCT!{struct SAFEARR_BRECORD { Size: ::ULONG, aRecord: *mut wireBRECORD, }} STRUCT!{struct SAFEARR_HAVEIID { Size: ::ULONG, apUnknown: *mut *mut ::IUnknown, iid: ::IID, }} ENUM!{enum SF_TYPE { SF_ERROR = ::VT_ERROR.0, SF_I1 = ::VT_I1.0, SF_I2 = ::VT_I2.0, SF_I4 = ::VT_I4.0, SF_I8 = ::VT_I8.0, SF_BSTR = ::VT_BSTR.0, SF_UNKNOWN = ::VT_UNKNOWN.0, SF_DISPATCH = ::VT_DISPATCH.0, SF_VARIANT = ::VT_VARIANT.0, SF_RECORD = ::VT_RECORD.0, SF_HAVEIID = ::VT_UNKNOWN.0 | ::VT_RESERVED.0, }} STRUCT!{struct SAFEARRAYUNION { sfType: ::ULONG, u: __MIDL_IOleAutomationTypes_0001, }} #[cfg(target_arch = "x86_64")] STRUCT!{struct __MIDL_IOleAutomationTypes_0001 { data0: u32, data1: [u32; 6], }} #[cfg(target_arch = "x86")] STRUCT!{struct __MIDL_IOleAutomationTypes_0001 { data0: u32, data1: [u32; 5], }} UNION!(__MIDL_IOleAutomationTypes_0001, data0, BstrStr, BstrStr_mut, SAFEARR_BSTR); UNION!(__MIDL_IOleAutomationTypes_0001, data0, UnknownStr, UnknownStr_mut, SAFEARR_UNKNOWN); UNION!(__MIDL_IOleAutomationTypes_0001, data0, DispatchStr, DispatchStr_mut, SAFEARR_DISPATCH); UNION!(__MIDL_IOleAutomationTypes_0001, data0, VariantStr, VariantStr_mut, SAFEARR_VARIANT); UNION!(__MIDL_IOleAutomationTypes_0001, data0, RecordStr, RecordStr_mut, SAFEARR_BRECORD); UNION!(__MIDL_IOleAutomationTypes_0001, data0, HaveIidStr, HaveIidStr_mut, SAFEARR_HAVEIID); UNION!(__MIDL_IOleAutomationTypes_0001, data0, ByteStr, ByteStr_mut, ::BYTE_SIZEDARR); UNION!(__MIDL_IOleAutomationTypes_0001, data0, WordStr, WordStr_mut, ::WORD_SIZEDARR); UNION!(__MIDL_IOleAutomationTypes_0001, data0, LongStr, LongStr_mut, ::DWORD_SIZEDARR); UNION!(__MIDL_IOleAutomationTypes_0001, data0, HyperStr, HyperStr_mut, ::HYPER_SIZEDARR); STRUCT!{struct _wireSAFEARRAY { cDims: ::USHORT, fFeatures: ::USHORT, cbElements: ::ULONG, cLocks: ::ULONG, uArrayStructs: SAFEARRAYUNION, rgsaBound: [SAFEARRAYBOUND; 1], }} pub type wireSAFEARRAY = *mut _wireSAFEARRAY; pub type wirePSAFEARRAY = *mut wireSAFEARRAY; STRUCT!{struct SAFEARRAY { cDims: ::USHORT, fFeatures: ::USHORT, cbElements: ::ULONG, cLocks: ::ULONG, pvData: ::PVOID, rgsabound: [SAFEARRAYBOUND; 1], }} pub type LPSAFEARRAY = *mut SAFEARRAY; pub const FADF_AUTO: ::DWORD = 0x1; pub const FADF_STATIC: ::DWORD = 0x2; pub const FADF_EMBEDDED: ::DWORD = 0x4; pub const FADF_FIXEDSIZE: ::DWORD = 0x10; pub const FADF_RECORD: ::DWORD = 0x20; pub const FADF_HAVEIID: ::DWORD = 0x40; pub const FADF_HAVEVARTYPE: ::DWORD = 0x80; pub const FADF_BSTR: ::DWORD = 0x100; pub const FADF_UNKNOWN: ::DWORD = 0x200; pub const FADF_DISPATCH: ::DWORD = 0x400; pub const FADF_VARIANT: ::DWORD = 0x800; pub const FADF_RESERVED: ::DWORD = 0xf008; #[cfg(target_arch = "x86_64")] STRUCT!{struct VARIANT { data0: u64, data1: u64, data2: u64, }} #[cfg(target_arch = "x86")] STRUCT!{struct VARIANT { data0: u64, data1: u32, data2: u32, }} UNION!(VARIANT, data0, vt, vt_mut, ::VARTYPE); UNION!(VARIANT, data1, llVal, llVal_mut, ::LONGLONG); UNION!(VARIANT, data1, lVal, lVal_mut, ::LONG); UNION!(VARIANT, data1, bVal, bVal_mut, ::BYTE); UNION!(VARIANT, data1, iVal, iVal_mut, ::SHORT); UNION!(VARIANT, data1, fltVal, fltVal_mut, ::FLOAT); UNION!(VARIANT, data1, dblVal, dblVal_mut, ::DOUBLE); UNION!(VARIANT, data1, boolVal, boolVal_mut, ::VARIANT_BOOL); UNION!(VARIANT, data1, scode, scode_mut, ::SCODE); UNION!(VARIANT, data1, cyVal, cyVal_mut, ::CY); UNION!(VARIANT, data1, date, date_mut, ::DATE); UNION!(VARIANT, data1, bstrVal, bstrVal_mut, ::BSTR); UNION!(VARIANT, data1, punkVal, punkVal_mut, *mut ::IUnknown); UNION!(VARIANT, data1, pdispVal, pdispVal_mut, *mut IDispatch); UNION!(VARIANT, data1, parray, parray_mut, *mut SAFEARRAY); UNION!(VARIANT, data1, pllVal, pllVal_mut, *mut ::LONGLONG); UNION!(VARIANT, data1, plVal, plVal_mut, *mut ::LONG); UNION!(VARIANT, data1, pbVal, pbVal_mut, *mut ::BYTE); UNION!(VARIANT, data1, piVal, piVal_mut, *mut ::SHORT); UNION!(VARIANT, data1, pfltVal, pfltVal_mut, *mut ::FLOAT); UNION!(VARIANT, data1, pdblVal, pdblVal_mut, *mut ::DOUBLE); UNION!(VARIANT, data1, pboolVal, pboolVal_mut, *mut ::VARIANT_BOOL); UNION!(VARIANT, data1, pscode, pscode_mut, *mut ::SCODE); UNION!(VARIANT, data1, pcyVal, pcyVal_mut, *mut ::CY); UNION!(VARIANT, data1, pdate, pdate_mut, *mut ::DATE); UNION!(VARIANT, data1, pbstrVal, pbstrVal_mut, *mut ::BSTR); UNION!(VARIANT, data1, ppunkVal, ppunkVal_mut, *mut *mut ::IUnknown); UNION!(VARIANT, data1, ppdispVal, ppdispVal_mut, *mut *mut IDispatch); UNION!(VARIANT, data1, pparray, pparray_mut, *mut *mut SAFEARRAY); UNION!(VARIANT, data1, pvarVal, pvarVal_mut, *mut VARIANT); UNION!(VARIANT, data1, byref, byref_mut, ::PVOID); UNION!(VARIANT, data1, cVal, cVal_mut, ::CHAR); UNION!(VARIANT, data1, uiVal, uiVal_mut, ::USHORT); UNION!(VARIANT, data1, ulVal, ulVal_mut, ::ULONG); UNION!(VARIANT, data1, ullVal, ullVal_mut, ::ULONGLONG); UNION!(VARIANT, data1, intVal, intVal_mut, ::INT); UNION!(VARIANT, data1, uintVal, uintVal_mut, ::UINT); UNION!(VARIANT, data1, pdecVal, pdecVal_mut, *mut ::DECIMAL); UNION!(VARIANT, data1, pcVal, pcVal_mut, *mut ::CHAR); UNION!(VARIANT, data1, puiVal, puiVal_mut, *mut ::USHORT); UNION!(VARIANT, data1, pulVal, pulVal_mut, *mut ::ULONG); UNION!(VARIANT, data1, pullVal, pullVal_mut, *mut ::ULONGLONG); UNION!(VARIANT, data1, pintVal, pintVal_mut, *mut ::INT); UNION!(VARIANT, data1, puintVal, puintVal_mut, *mut ::UINT); UNION!(VARIANT, data1, pvRecord, pvRecord_mut, ::PVOID); UNION!(VARIANT, data2, pRecInfo, pRecInfo_mut, *mut IRecordInfo); UNION!(VARIANT, data0, decVal, decVal_mut, ::DECIMAL); pub type LPVARIANT = *mut VARIANT; pub type VARIANTARG = VARIANT; pub type LPVARIANTARG = *mut VARIANT; pub type REFVARIANT = *const VARIANT; STRUCT!{struct _wireBRECORD { fFlags: ::ULONG, clSize: ::ULONG, pRecInfo: *mut IRecordInfo, pRecord: *mut ::BYTE, }} STRUCT!{struct _wireVARIANT { clSize: ::DWORD, rpcReserved: ::DWORD, vt: ::USHORT, wReserved1: ::USHORT, wReserved2: ::USHORT, wReserved3: ::USHORT, data0: u64, data1: u64, }} UNION!(_wireVARIANT, data0, llVal, llVal_mut, ::LONGLONG); UNION!(_wireVARIANT, data0, lVal, lVal_mut, ::LONG); UNION!(_wireVARIANT, data0, bVal, bVal_mut, ::BYTE); UNION!(_wireVARIANT, data0, iVal, iVal_mut, ::SHORT); UNION!(_wireVARIANT, data0, fltVal, fltVal_mut, ::FLOAT); UNION!(_wireVARIANT, data0, dblVal, dblVal_mut, ::DOUBLE); UNION!(_wireVARIANT, data0, boolVal, boolVal_mut, ::VARIANT_BOOL); UNION!(_wireVARIANT, data0, scode, scode_mut, ::SCODE); UNION!(_wireVARIANT, data0, cyVal, cyVal_mut, ::CY); UNION!(_wireVARIANT, data0, date, date_mut, ::DATE); UNION!(_wireVARIANT, data0, bstrVal, bstrVal_mut, ::wireBSTR); UNION!(_wireVARIANT, data0, punkVal, punkVal_mut, *mut ::IUnknown); UNION!(_wireVARIANT, data0, pdispVal, pdispVal_mut, *mut IDispatch); UNION!(_wireVARIANT, data0, parray, parray_mut, wirePSAFEARRAY); UNION!(_wireVARIANT, data0, brecVal, brecVal_mut, wireBRECORD); UNION!(_wireVARIANT, data0, pllVal, pllVal_mut, *mut ::LONGLONG); UNION!(_wireVARIANT, data0, plVal, plVal_mut, *mut ::LONG); UNION!(_wireVARIANT, data0, pbVal, pbVal_mut, *mut ::BYTE); UNION!(_wireVARIANT, data0, piVal, piVal_mut, *mut ::SHORT); UNION!(_wireVARIANT, data0, pfltVal, pfltVal_mut, *mut ::FLOAT); UNION!(_wireVARIANT, data0, pdblVal, pdblVal_mut, *mut ::DOUBLE); UNION!(_wireVARIANT, data0, pboolVal, pboolVal_mut, *mut ::VARIANT_BOOL); UNION!(_wireVARIANT, data0, pscode, pscode_mut, *mut ::SCODE); UNION!(_wireVARIANT, data0, pcyVal, pcyVal_mut, *mut ::CY); UNION!(_wireVARIANT, data0, pdate, pdate_mut, *mut ::DATE); UNION!(_wireVARIANT, data0, pbstrVal, pbstrVal_mut, *mut ::wireBSTR); UNION!(_wireVARIANT, data0, ppunkVal, ppunkVal_mut, *mut *mut ::IUnknown); UNION!(_wireVARIANT, data0, ppdispVal, ppdispVal_mut, *mut *mut IDispatch); UNION!(_wireVARIANT, data0, pparray, pparray_mut, *mut wirePSAFEARRAY); UNION!(_wireVARIANT, data0, pvarVal, pvarVal_mut, *mut wireVARIANT); UNION!(_wireVARIANT, data0, cVal, cVal_mut, ::CHAR); UNION!(_wireVARIANT, data0, uiVal, uiVal_mut, ::USHORT); UNION!(_wireVARIANT, data0, ulVal, ulVal_mut, ::ULONG); UNION!(_wireVARIANT, data0, ullVal, ullVal_mut, ::ULONGLONG); UNION!(_wireVARIANT, data0, intVal, intVal_mut, ::INT); UNION!(_wireVARIANT, data0, uintVal, uintVal_mut, ::UINT); UNION!(_wireVARIANT, data0, decVal, decVal_mut, ::DECIMAL); UNION!(_wireVARIANT, data0, pcVal, pcVal_mut, *mut ::CHAR); UNION!(_wireVARIANT, data0, puiVal, puiVal_mut, *mut ::USHORT); UNION!(_wireVARIANT, data0, pulVal, pulVal_mut, *mut ::ULONG); UNION!(_wireVARIANT, data0, pullVal, pullVal_mut, *mut ::ULONGLONG); UNION!(_wireVARIANT, data0, pintVal, pintVal_mut, *mut ::INT); UNION!(_wireVARIANT, data0, puintVal, puintVal_mut, *mut ::UINT); UNION!(_wireVARIANT, data0, pdecVal, pdecVal_mut, *mut ::DECIMAL); pub type DISPID = ::LONG; pub type MEMBERID = DISPID; pub type HREFTYPE = ::DWORD; ENUM!{enum TYPEKIND { TKIND_ENUM = 0, TKIND_RECORD, TKIND_MODULE, TKIND_INTERFACE, TKIND_DISPATCH, TKIND_COCLASS, TKIND_ALIAS, TKIND_UNION, TKIND_MAX, }} #[cfg(target_arch = "x86_64")] STRUCT!{struct TYPEDESC { data: u64, vt: ::VARTYPE, }} #[cfg(target_arch = "x86")] STRUCT!{struct TYPEDESC { data: u32, vt: ::VARTYPE, }} UNION!(TYPEDESC, data, lptdesc, lptdesc_mut, *mut TYPEDESC); UNION!(TYPEDESC, data, lpadesc, lpadesc_mut, *mut ARRAYDESC); UNION!(TYPEDESC, data, hreftype, hreftype_mut, HREFTYPE); STRUCT!{struct ARRAYDESC { tdescElem: TYPEDESC, cDims: ::USHORT, rgbounds: [SAFEARRAYBOUND; 1], }} STRUCT!{struct PARAMDESCEX { cBytes: ::ULONG, varDefaultValue: VARIANTARG, }} pub type LPPARAMDESCEX = *mut PARAMDESCEX; STRUCT!{struct PARAMDESC { pparamdescex: LPPARAMDESCEX, wParamFlags: ::USHORT, }} pub type LPPARAMDESC = *mut PARAMDESC; pub const PARAMFLAG_NONE: ::DWORD = 0; pub const PARAMFLAG_FIN: ::DWORD = 0x1; pub const PARAMFLAG_FOUT: ::DWORD = 0x2; pub const PARAMFLAG_FLCID: ::DWORD = 0x4; pub const PARAMFLAG_FRETVAL: ::DWORD = 0x8; pub const PARAMFLAG_FOPT: ::DWORD = 0x10; pub const PARAMFLAG_FHASDEFAULT: ::DWORD = 0x20; pub const PARAMFLAG_FHASCUSTDATA: ::DWORD = 0x40; STRUCT!{struct IDLDESC { dwReserved: ::ULONG_PTR, wIDLFlags: ::USHORT, }} pub type LPIDLDESC = *mut IDLDESC; pub const IDLFLAG_NONE: ::DWORD = PARAMFLAG_NONE; pub const IDLFLAG_FIN: ::DWORD = PARAMFLAG_FIN; pub const IDLFLAG_FOUT: ::DWORD = PARAMFLAG_FOUT; pub const IDLFLAG_FLCID: ::DWORD = PARAMFLAG_FLCID; pub const IDLFLAG_FRETVAL: ::DWORD = PARAMFLAG_FRETVAL; STRUCT!{struct ELEMDESC { tdesc: TYPEDESC, idldesc: IDLDESC, }} UNION!(ELEMDESC, idldesc, paramdesc, paramdesc_mut, PARAMDESC); pub type LPELEMDESC = *mut ELEMDESC; STRUCT!{struct TYPEATTR { guid: ::GUID, lcid: ::LCID, dwReserved: ::DWORD, memidConstructor: ::MEMBERID, memidDestructor: ::MEMBERID, lpstrSchema: ::LPOLESTR, cbSizeInstance: ::ULONG, typekind: ::TYPEKIND, cFuncs: ::WORD, cVars: ::WORD, cImplTypes: ::WORD, cbSizeVft: ::WORD, cbAlignment: ::WORD, wTypeFlags: ::WORD, wMajorVerNum: ::WORD, wMinorVerNum: ::WORD, tdescAlias: ::TYPEDESC, idldescType: ::IDLDESC, }} pub type LPTYPEATTR = *mut TYPEATTR; STRUCT!{struct DISPPARAMS { rgvarg: *mut VARIANTARG, rgdispidNamedArgs: *mut DISPID, cArgs: ::UINT, cNamedArgs: ::UINT, }} #[repr(C)] #[derive(Copy)] pub struct EXCEPINFO { pub wCode: ::WORD, pub wReserved: ::WORD, pub bstrSource: ::BSTR, pub bstrDescription: ::BSTR, pub bstrHelpFile: ::BSTR, pub dwHelpContext: ::DWORD, pub pvReserved: ::PVOID, pub pfnDeferredFillIn: Option ::HRESULT>, pub scode: ::SCODE, } impl Clone for EXCEPINFO { fn clone(&self) -> Self { *self } } ENUM!{enum CALLCONV { CC_FASTCALL = 0, CC_CDECL = 1, CC_MSCPASCAL, CC_PASCAL, CC_MACPASCAL, CC_STDCALL, CC_FPFASTCALL, CC_SYSCALL, CC_MPWCDECL, CC_MPWPASCAL, CC_MAX, }} ENUM!{enum FUNCKIND { FUNC_VIRTUAL = 0, FUNC_PUREVIRTUAL, FUNC_NONVIRTUAL, FUNC_STATIC, FUNC_DISPATCH, }} FLAGS!{enum INVOKEKIND { INVOKE_FUNC = 1, INVOKE_PROPERTYGET = 2, INVOKE_PROPERTYPUT = 4, INVOKE_PROPERTYPUTREF = 8, }} STRUCT!{struct FUNCDESC { memid: ::MEMBERID, lprgscode: *mut ::SCODE, lprgelemdescParam: *mut ::ELEMDESC, funckind: ::FUNCKIND, invkind: ::INVOKEKIND, callconv: ::CALLCONV, cParams: ::SHORT, cParamsOpt: ::SHORT, oVft: ::SHORT, cScodes: ::SHORT, elemdescFunc: ::ELEMDESC, wFuncFlags: ::WORD, }} pub type LPFUNCDESC = *mut FUNCDESC; ENUM!{enum VARKIND { VAR_PERINSTANCE = 0, VAR_STATIC, VAR_CONST, VAR_DISPATCH, }} pub const IMPLTYPEFLAG_FDEFAULT: ::DWORD = 0x1; pub const IMPLTYPEFLAG_FSOURCE: ::DWORD = 0x2; pub const IMPLTYPEFLAG_FRESTRICTED: ::DWORD = 0x4; pub const IMPLTYPEFLAG_FDEFAULTVTABLE: ::DWORD = 0x8; STRUCT!{struct VARDESC { memid: MEMBERID, lpstrSchema: ::LPOLESTR, lpvarValue: *mut VARIANT, elemdescVar: ::ELEMDESC, wVarFlags: ::WORD, varkind: VARKIND, }} UNION!(VARDESC, lpvarValue, oInst, oInst_mut, ::ULONG); pub type LPVARDESC = *mut VARDESC; FLAGS!{enum TYPEFLAGS { TYPEFLAG_FAPPOBJECT = 0x1, TYPEFLAG_FCANCREATE = 0x2, TYPEFLAG_FLICENSED = 0x4, TYPEFLAG_FPREDECLID = 0x8, TYPEFLAG_FHIDDEN = 0x10, TYPEFLAG_FCONTROL = 0x20, TYPEFLAG_FDUAL = 0x40, TYPEFLAG_FNONEXTENSIBLE = 0x80, TYPEFLAG_FOLEAUTOMATION = 0x100, TYPEFLAG_FRESTRICTED = 0x200, TYPEFLAG_FAGGREGATABLE = 0x400, TYPEFLAG_FREPLACEABLE = 0x800, TYPEFLAG_FDISPATCHABLE = 0x1000, TYPEFLAG_FREVERSEBIND = 0x2000, TYPEFLAG_FPROXY = 0x4000, }} FLAGS!{enum FUNCFLAGS { FUNCFLAG_FRESTRICTED = 0x1, FUNCFLAG_FSOURCE = 0x2, FUNCFLAG_FBINDABLE = 0x4, FUNCFLAG_FREQUESTEDIT = 0x8, FUNCFLAG_FDISPLAYBIND = 0x10, FUNCFLAG_FDEFAULTBIND = 0x20, FUNCFLAG_FHIDDEN = 0x40, FUNCFLAG_FUSESGETLASTERROR = 0x80, FUNCFLAG_FDEFAULTCOLLELEM = 0x100, FUNCFLAG_FUIDEFAULT = 0x200, FUNCFLAG_FNONBROWSABLE = 0x400, FUNCFLAG_FREPLACEABLE = 0x800, FUNCFLAG_FIMMEDIATEBIND = 0x1000, }} FLAGS!{enum VARFLAGS { VARFLAG_FREADONLY = 0x1, VARFLAG_FSOURCE = 0x2, VARFLAG_FBINDABLE = 0x4, VARFLAG_FREQUESTEDIT = 0x8, VARFLAG_FDISPLAYBIND = 0x10, VARFLAG_FDEFAULTBIND = 0x20, VARFLAG_FHIDDEN = 0x40, VARFLAG_FRESTRICTED = 0x80, VARFLAG_FDEFAULTCOLLELEM = 0x100, VARFLAG_FUIDEFAULT = 0x200, VARFLAG_FNONBROWSABLE = 0x400, VARFLAG_FREPLACEABLE = 0x800, VARFLAG_FIMMEDIATEBIND = 0x1000, }} STRUCT!{struct CLEANLOCALSTORAGE { pInterface: *mut ::IUnknown, pStorage: ::PVOID, flags: ::DWORD, }} STRUCT!{struct CUSTDATAITEM { guid: ::GUID, varValue: VARIANTARG, }} pub type LPCUSTDATAITEM = *mut CUSTDATAITEM; STRUCT!{struct CUSTDATA { cCustData: ::DWORD, prgCustData: LPCUSTDATAITEM, }} pub type LPCUSTDATA = *mut CUSTDATA; pub type LPCREATETYPEINFO = *mut ICreateTypeInfo; RIDL!( interface ICreateTypeInfo(ICreateTypeInfoVtbl): IUnknown(IUnknownVtbl) { fn SetGuid(&mut self, guid: ::REFGUID) -> ::HRESULT, fn SetTypeFlags(&mut self, uTypeFlags: ::UINT) -> ::HRESULT, fn SetDocString(&mut self, pStrDoc: ::LPOLESTR) -> ::HRESULT, fn SetHelpContext(&mut self, dwHelpContext: ::DWORD) -> ::HRESULT, fn SetVersion(&mut self, wMajorVerNum: ::WORD, wMinorVerNum: ::WORD) -> ::HRESULT, fn AddRefTypeInfo(&mut self, pTInfo: *mut ITypeInfo) -> ::HRESULT, fn AddFuncDesc(&mut self, index: ::UINT, pFuncDesc: *mut FUNCDESC) -> ::HRESULT, fn SetImplTypeFlags(&mut self, index: ::UINT, implTypeFlags: ::INT) -> ::HRESULT, fn SetAlignment(&mut self, cbAlignment: ::WORD) -> ::HRESULT, fn SetSchema(&mut self, pStrSchema: ::LPOLESTR) -> ::HRESULT, fn AddVarDesc(&mut self, index: ::UINT, pVarDesc: *mut VARDESC) -> ::HRESULT, fn SetFuncAndParamNames( &mut self, index: ::UINT, rgszNames: *mut ::LPOLESTR, cNames: ::UINT ) -> ::HRESULT, fn SetVarName(&mut self, index: ::UINT, szName: ::LPOLESTR) -> ::HRESULT, fn SetTypeDescAlias(&mut self, pTDescAlias: *mut TYPEDESC) -> ::HRESULT, fn DefineFuncAsDllEntry( &mut self, index: ::UINT, szDllName: ::LPOLESTR, szProcName: ::LPOLESTR ) -> ::HRESULT, fn SetFuncDocString(&mut self, index: ::UINT, szDocString: ::LPOLESTR) -> ::HRESULT, fn SetVarDocString(&mut self, index: ::UINT, szDocString: ::LPOLESTR) -> ::HRESULT, fn SetFuncHelpContext(&mut self, index: ::UINT, dwHelpContext: ::DWORD) -> ::HRESULT, fn SetVarHelpContext(&mut self, index: ::UINT, dwHelpContext: ::DWORD) -> ::HRESULT, fn SetMops(&mut self, index: ::UINT, bstrMops: ::BSTR) -> ::HRESULT, fn SetTypeIdldesc(&mut self, pIdlDesc: *mut IDLDESC) -> ::HRESULT, fn LayOut(&mut self) -> ::HRESULT } ); // FIXME: Implement these interfaces #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ICreateTypeInfo2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ICreateTypeLib; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ICreateTypeLib2; pub type LPDISPATCH = *mut IDispatch; pub const DISPID_UNKNOWN: ::INT = -1; pub const DISPID_VALUE: ::INT = 0; pub const DISPID_PROPERTYPUT: ::INT = -3; pub const DISPID_NEWENUM: ::INT = -4; pub const DISPID_EVALUATE: ::INT = -5; pub const DISPID_CONSTRUCTOR: ::INT = -6; pub const DISPID_DESTRUCTOR: ::INT = -7; pub const DISPID_COLLECT: ::INT = -8; RIDL!( interface IDispatch(IDispatchVtbl): IUnknown(IUnknownVtbl) { fn GetTypeInfoCount(&mut self, pctinfo: *mut ::UINT) -> ::HRESULT, fn GetTypeInfo( &mut self, iTInfo: ::UINT, lcid: ::LCID, ppTInfo: *mut *mut ITypeInfo ) -> ::HRESULT, fn GetIDsOfNames( &mut self, riid: ::REFIID, rgszNames: *mut ::LPOLESTR, cNames: ::UINT, lcid: ::LCID, rgDispId: *mut ::DISPID ) -> ::HRESULT, fn Invoke( &mut self, dispIdMember: ::DISPID, riid: ::REFIID, lcid: ::LCID, wFlags: ::WORD, pDispParams: *mut ::DISPPARAMS, pVarResult: *mut VARIANT, pExcepInfo: *mut ::EXCEPINFO, puArgErr: *mut ::UINT ) -> ::HRESULT } ); // FIXME: Implement these interfaces #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IEnumVARIANT; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ITypeComp; RIDL!( interface ITypeInfo(ITypeInfoVtbl): IUnknown(IUnknownVtbl) { fn GetTypeAttr(&mut self, ppTypeAttr: *mut *mut TYPEATTR) -> ::HRESULT, fn GetTypeComp(&mut self, ppTComp: *mut *mut ITypeComp) -> ::HRESULT, fn GetFuncDesc(&mut self, index: ::UINT, ppFunDesc: *mut *mut FUNCDESC) -> ::HRESULT, fn GetVarDesc(&mut self, index: ::UINT, pPVarDesc: *mut *mut VARDESC) -> ::HRESULT, fn GetNames( &mut self, memid: MEMBERID, rgBstrNames: *mut ::BSTR, cMaxNames: ::UINT, pcNames: *mut ::UINT ) -> ::HRESULT, fn GetRefTypeOfImplType(&mut self, index: ::UINT, pRefType: *mut HREFTYPE) -> ::HRESULT, fn GetImplTypeFlags(&mut self, index: ::UINT, pImplTypeFlags: *mut ::INT) -> ::HRESULT, fn GetIDsOfNames( &mut self, rgszNames: *mut ::LPOLESTR, cNames: ::UINT, pMemId: *mut MEMBERID ) -> ::HRESULT, fn Invoke( &mut self, pvInstance: ::PVOID, memid: MEMBERID, wFlags: ::WORD, pDispParams: *mut DISPPARAMS, pVarResult: *mut VARIANT, pExcepInfo: *mut EXCEPINFO, puArgErr: *mut ::UINT ) -> ::HRESULT, fn GetDocumentation( &mut self, memid: MEMBERID, pBstrName: *mut ::BSTR, pBstrDocString: *mut ::BSTR, pdwHelpContext: *mut ::DWORD, pBstrHelpFile: *mut ::BSTR ) -> ::HRESULT, fn GetDllEntry( &mut self, memid: MEMBERID, invKind: ::INVOKEKIND, pBstrDllName: *mut ::BSTR, pBstrName: *mut ::BSTR, pwOrdinal: *mut ::WORD ) -> ::HRESULT, fn GetRefTypeInfo(&mut self, hRefType: HREFTYPE, ppTInfo: *mut *mut ITypeInfo) -> ::HRESULT, fn AddressOfMember( &mut self, memid: MEMBERID, invKind: ::INVOKEKIND, ppv: *mut ::PVOID ) -> ::HRESULT, fn CreateInstance( &mut self, pUnkOuter: *mut ::IUnknown, riid: ::REFIID, ppvObj: *mut ::PVOID ) -> ::HRESULT, fn GetMops(&mut self, memid: MEMBERID, pBstrMops: *mut ::BSTR) -> ::HRESULT, fn GetContainingTypeLib( &mut self, ppTLib: *mut *mut ITypeLib, pIndex: *mut ::UINT ) -> ::HRESULT, fn ReleaseTypeAttr(&mut self, pTypeAttr: *mut TYPEATTR) -> (), fn ReleaseFuncDesc(&mut self, pFuncDesc: *mut FUNCDESC) -> (), fn ReleaseVarDesc(&mut self, pVarDesc: *mut VARDESC) -> () } ); // FIXME: Implement these interfaces #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ITypeInfo2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ITypeLib; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ITypeLib2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ITypeChangeEvents; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IErrorInfo; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ICreateErrorInfo; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ISupportErrorInfo; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ITypeFactory; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ITypeMarshal; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IRecordInfo; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IErrorLog; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IPropertyBag; deps/winapi-0.2.5/src/commdlg.rs0000644000000000000000000005421112613167613015226 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! 32-Bit Common Dialog APIs pub type LPOFNHOOKPROC = Option ::UINT_PTR>; #[repr(C)] #[derive(Copy)] pub struct OPENFILENAME_NT4A { pub lStructSize: ::DWORD, pub hwndOwner: ::HWND, pub hInstance: ::HINSTANCE, pub lpstrFilter: ::LPCSTR, pub lpstrCustomFilter: ::LPSTR, pub nMaxCustFilter: ::DWORD, pub nFilterIndex: ::DWORD, pub lpstrFile: ::LPSTR, pub nMaxFile: ::DWORD, pub lpstrFileTitle: ::LPSTR, pub nMaxFileTitle: ::DWORD, pub lpstrInitialDir: ::LPCSTR, pub lpstrTitle: ::LPCSTR, pub Flags: ::DWORD, pub nFileOffset: ::WORD, pub nFileExtension: ::WORD, pub lpstrDefExt: ::LPCSTR, pub lCustData: ::LPARAM, pub lpfnHook: LPOFNHOOKPROC, pub lpTemplateName: ::LPCSTR, } impl Clone for OPENFILENAME_NT4A { fn clone(&self) -> OPENFILENAME_NT4A { *self } } pub type LPOPENFILENAME_NT4A = *mut OPENFILENAME_NT4A; #[repr(C)] #[derive(Copy)] pub struct OPENFILENAME_NT4W { pub lStructSize: ::DWORD, pub hwndOwner: ::HWND, pub hInstance: ::HINSTANCE, pub lpstrFilter: ::LPCWSTR, pub lpstrCustomFilter: ::LPWSTR, pub nMaxCustFilter: ::DWORD, pub nFilterIndex: ::DWORD, pub lpstrFile: ::LPWSTR, pub nMaxFile: ::DWORD, pub lpstrFileTitle: ::LPWSTR, pub nMaxFileTitle: ::DWORD, pub lpstrInitialDir: ::LPCWSTR, pub lpstrTitle: ::LPCWSTR, pub Flags: ::DWORD, pub nFileOffset: ::WORD, pub nFileExtension: ::WORD, pub lpstrDefExt: ::LPCWSTR, pub lCustData: ::LPARAM, pub lpfnHook: LPOFNHOOKPROC, pub lpTemplateName: ::LPCWSTR, } impl Clone for OPENFILENAME_NT4W { fn clone(&self) -> OPENFILENAME_NT4W { *self } } pub type LPOPENFILENAME_NT4W = *mut OPENFILENAME_NT4W; #[repr(C)] #[derive(Copy)] pub struct OPENFILENAMEA { pub lStructSize: ::DWORD, pub hwndOwner: ::HWND, pub hInstance: ::HINSTANCE, pub lpstrFilter: ::LPCSTR, pub lpstrCustomFilter: ::LPSTR, pub nMaxCustFilter: ::DWORD, pub nFilterIndex: ::DWORD, pub lpstrFile: ::LPSTR, pub nMaxFile: ::DWORD, pub lpstrFileTitle: ::LPSTR, pub nMaxFileTitle: ::DWORD, pub lpstrInitialDir: ::LPCSTR, pub lpstrTitle: ::LPCSTR, pub Flags: ::DWORD, pub nFileOffset: ::WORD, pub nFileExtension: ::WORD, pub lpstrDefExt: ::LPCSTR, pub lCustData: ::LPARAM, pub lpfnHook: LPOFNHOOKPROC, pub lpTemplateName: ::LPCSTR, pub pvReserved: *mut ::c_void, pub dwReserved: ::DWORD, pub FlagsEx: ::DWORD, } impl Clone for OPENFILENAMEA { fn clone(&self) -> OPENFILENAMEA { *self } } pub type LPOPENFILENAMEA = *mut OPENFILENAMEA; #[repr(C)] #[derive(Copy)] pub struct OPENFILENAMEW { pub lStructSize: ::DWORD, pub hwndOwner: ::HWND, pub hInstance: ::HINSTANCE, pub lpstrFilter: ::LPCWSTR, pub lpstrCustomFilter: ::LPWSTR, pub nMaxCustFilter: ::DWORD, pub nFilterIndex: ::DWORD, pub lpstrFile: ::LPWSTR, pub nMaxFile: ::DWORD, pub lpstrFileTitle: ::LPWSTR, pub nMaxFileTitle: ::DWORD, pub lpstrInitialDir: ::LPCWSTR, pub lpstrTitle: ::LPCWSTR, pub Flags: ::DWORD, pub nFileOffset: ::WORD, pub nFileExtension: ::WORD, pub lpstrDefExt: ::LPCWSTR, pub lCustData: ::LPARAM, pub lpfnHook: LPOFNHOOKPROC, pub lpTemplateName: ::LPCWSTR, pub pvReserved: *mut ::c_void, pub dwReserved: ::DWORD, pub FlagsEx: ::DWORD, } impl Clone for OPENFILENAMEW { fn clone(&self) -> OPENFILENAMEW { *self } } pub type LPOPENFILENAMEW = *mut OPENFILENAMEW; pub const OFN_READONLY: ::DWORD = 0x00000001; pub const OFN_OVERWRITEPROMPT: ::DWORD = 0x00000002; pub const OFN_HIDEREADONLY: ::DWORD = 0x00000004; pub const OFN_NOCHANGEDIR: ::DWORD = 0x00000008; pub const OFN_SHOWHELP: ::DWORD = 0x00000010; pub const OFN_ENABLEHOOK: ::DWORD = 0x00000020; pub const OFN_ENABLETEMPLATE: ::DWORD = 0x00000040; pub const OFN_ENABLETEMPLATEHANDLE: ::DWORD = 0x00000080; pub const OFN_NOVALIDATE: ::DWORD = 0x00000100; pub const OFN_ALLOWMULTISELECT: ::DWORD = 0x00000200; pub const OFN_EXTENSIONDIFFERENT: ::DWORD = 0x00000400; pub const OFN_PATHMUSTEXIST: ::DWORD = 0x00000800; pub const OFN_FILEMUSTEXIST: ::DWORD = 0x00001000; pub const OFN_CREATEPROMPT: ::DWORD = 0x00002000; pub const OFN_SHAREAWARE: ::DWORD = 0x00004000; pub const OFN_NOREADONLYRETURN: ::DWORD = 0x00008000; pub const OFN_NOTESTFILECREATE: ::DWORD = 0x00010000; pub const OFN_NONETWORKBUTTON: ::DWORD = 0x00020000; pub const OFN_NOLONGNAMES: ::DWORD = 0x00040000; pub const OFN_EXPLORER: ::DWORD = 0x00080000; pub const OFN_NODEREFERENCELINKS: ::DWORD = 0x00100000; pub const OFN_LONGNAMES: ::DWORD = 0x00200000; pub const OFN_ENABLEINCLUDENOTIFY: ::DWORD = 0x00400000; pub const OFN_ENABLESIZING: ::DWORD = 0x00800000; pub const OFN_DONTADDTORECENT: ::DWORD = 0x02000000; pub const OFN_FORCESHOWHIDDEN: ::DWORD = 0x10000000; pub const OFN_EX_NOPLACESBAR: ::DWORD = 0x00000001; pub const OFN_SHAREFALLTHROUGH: ::UINT_PTR = 2; pub const OFN_SHARENOWARN: ::UINT_PTR = 1; pub const OFN_SHAREWARN: ::UINT_PTR = 0; pub type LPCCHOOKPROC = Option ::UINT_PTR>; STRUCT!{struct OFNOTIFYA { hdr: ::NMHDR, lpOFN: LPOPENFILENAMEA, pszFile: ::LPSTR, }} pub type LPOFNOTIFYA = *mut OFNOTIFYA; STRUCT!{struct OFNOTIFYW { hdr: ::NMHDR, lpOFN: LPOPENFILENAMEW, pszFile: ::LPWSTR, }} pub type LPOFNOTIFYW = *mut OFNOTIFYW; STRUCT!{struct OFNOTIFYEXA { hdr: ::NMHDR, lpOFN: LPOPENFILENAMEA, psf: ::LPVOID, pidl: ::LPVOID, }} pub type LPOFNOTIFYEXA = *mut OFNOTIFYEXA; STRUCT!{struct OFNOTIFYEXW { hdr: ::NMHDR, lpOFN: LPOPENFILENAMEW, psf: ::LPVOID, pidl: ::LPVOID, }} pub type LPOFNOTIFYEXW = *mut OFNOTIFYEXW; pub const CDN_FIRST: ::UINT = 0 - 601; pub const CDN_LAST: ::UINT = 0 - 699; pub const CDN_INITDONE: ::UINT = CDN_FIRST - 0x0000; pub const CDN_SELCHANGE: ::UINT = CDN_FIRST - 0x0001; pub const CDN_FOLDERCHANGE: ::UINT = CDN_FIRST - 0x0002; pub const CDN_SHAREVIOLATION: ::UINT = CDN_FIRST - 0x0003; pub const CDN_HELP: ::UINT = CDN_FIRST - 0x0004; pub const CDN_FILEOK: ::UINT = CDN_FIRST - 0x0005; pub const CDN_TYPECHANGE: ::UINT = CDN_FIRST - 0x0006; pub const CDN_INCLUDEITEM: ::UINT = CDN_FIRST - 0x0007; pub const CDM_FIRST: ::UINT = ::WM_USER + 100; pub const CDM_LAST: ::UINT = ::WM_USER + 200; pub const CDM_GETSPEC: ::UINT = CDM_FIRST + 0x0000; pub const CDM_GETFILEPATH: ::UINT = CDM_FIRST + 0x0001; pub const CDM_GETFOLDERPATH: ::UINT = CDM_FIRST + 0x0002; pub const CDM_GETFOLDERIDLIST: ::UINT = CDM_FIRST + 0x0003; pub const CDM_SETCONTROLTEXT: ::UINT = CDM_FIRST + 0x0004; pub const CDM_HIDECONTROL: ::UINT = CDM_FIRST + 0x0005; pub const CDM_SETDEFEXT: ::UINT = CDM_FIRST + 0x0006; #[repr(C)] #[derive(Copy)] pub struct CHOOSECOLORA { pub lStructSize: ::DWORD, pub hwndOwner: ::HWND, pub hInstance: ::HWND, pub rgbResult: ::COLORREF, pub lpCustColors: *mut ::COLORREF, pub Flags: ::DWORD, pub lCustData: ::LPARAM, pub lpfnHook: LPCCHOOKPROC, pub lpTemplateName: ::LPCSTR, } impl Clone for CHOOSECOLORA { fn clone(&self) -> CHOOSECOLORA { *self } } pub type LPCHOOSECOLORA = *mut CHOOSECOLORA; #[repr(C)] #[derive(Copy)] pub struct CHOOSECOLORW { pub lStructSize: ::DWORD, pub hwndOwner: ::HWND, pub hInstance: ::HWND, pub rgbResult: ::COLORREF, pub lpCustColors: *mut ::COLORREF, pub Flags: ::DWORD, pub lCustData: ::LPARAM, pub lpfnHook: LPCCHOOKPROC, pub lpTemplateName: ::LPCWSTR, } impl Clone for CHOOSECOLORW { fn clone(&self) -> CHOOSECOLORW { *self } } pub type LPCHOOSECOLORW = *mut CHOOSECOLORW; pub const CC_RGBINIT: ::DWORD = 0x00000001; pub const CC_FULLOPEN: ::DWORD = 0x00000002; pub const CC_PREVENTFULLOPEN: ::DWORD = 0x00000004; pub const CC_SHOWHELP: ::DWORD = 0x00000008; pub const CC_ENABLEHOOK: ::DWORD = 0x00000010; pub const CC_ENABLETEMPLATE: ::DWORD = 0x00000020; pub const CC_ENABLETEMPLATEHANDLE: ::DWORD = 0x00000040; pub const CC_SOLIDCOLOR: ::DWORD = 0x00000080; pub const CC_ANYCOLOR: ::DWORD = 0x00000100; pub type LPFRHOOKPROC = Option ::UINT_PTR>; #[repr(C)] #[derive(Copy)] pub struct FINDREPLACEA { pub lStructSize: ::DWORD, pub hwndOwner: ::HWND, pub hInstance: ::HINSTANCE, pub Flags: ::DWORD, pub lpstrFindWhat: ::LPSTR, pub lpstrReplaceWith: ::LPSTR, pub wFindWhatLen: ::WORD, pub wReplaceWithLen: ::WORD, pub lCustData: ::LPARAM, pub lpfnHook: LPFRHOOKPROC, pub lpTemplateName: ::LPCSTR, } impl Clone for FINDREPLACEA { fn clone(&self) -> FINDREPLACEA { *self } } pub type LPFINDREPLACEA = *mut FINDREPLACEA; #[repr(C)] #[derive(Copy)] pub struct FINDREPLACEW { pub lStructSize: ::DWORD, pub hwndOwner: ::HWND, pub hInstance: ::HINSTANCE, pub Flags: ::DWORD, pub lpstrFindWhat: ::LPWSTR, pub lpstrReplaceWith: ::LPWSTR, pub wFindWhatLen: ::WORD, pub wReplaceWithLen: ::WORD, pub lCustData: ::LPARAM, pub lpfnHook: LPFRHOOKPROC, pub lpTemplateName: ::LPCWSTR, } impl Clone for FINDREPLACEW { fn clone(&self) -> FINDREPLACEW { *self } } pub type LPFINDREPLACEW = *mut FINDREPLACEW; pub const FR_DOWN: ::DWORD = 0x00000001; pub const FR_WHOLEWORD: ::DWORD = 0x00000002; pub const FR_MATCHCASE: ::DWORD = 0x00000004; pub const FR_FINDNEXT: ::DWORD = 0x00000008; pub const FR_REPLACE: ::DWORD = 0x00000010; pub const FR_REPLACEALL: ::DWORD = 0x00000020; pub const FR_DIALOGTERM: ::DWORD = 0x00000040; pub const FR_SHOWHELP: ::DWORD = 0x00000080; pub const FR_ENABLEHOOK: ::DWORD = 0x00000100; pub const FR_ENABLETEMPLATE: ::DWORD = 0x00000200; pub const FR_NOUPDOWN: ::DWORD = 0x00000400; pub const FR_NOMATCHCASE: ::DWORD = 0x00000800; pub const FR_NOWHOLEWORD: ::DWORD = 0x00001000; pub const FR_ENABLETEMPLATEHANDLE: ::DWORD = 0x00002000; pub const FR_HIDEUPDOWN: ::DWORD = 0x00004000; pub const FR_HIDEMATCHCASE: ::DWORD = 0x00008000; pub const FR_HIDEWHOLEWORD: ::DWORD = 0x00010000; pub const FR_RAW: ::DWORD = 0x00020000; pub const FR_MATCHDIAC: ::DWORD = 0x20000000; pub const FR_MATCHKASHIDA: ::DWORD = 0x40000000; pub const FR_MATCHALEFHAMZA: ::DWORD = 0x80000000; pub type LPCFHOOKPROC = Option ::UINT_PTR>; #[repr(C)] #[derive(Copy)] pub struct CHOOSEFONTA { pub lStructSize: ::DWORD, pub hwndOwner: ::HWND, pub hDC: ::HDC, pub lpLogFont: ::LPLOGFONTA, pub iPointSize: ::INT, pub Flags: ::DWORD, pub rgbColors: ::COLORREF, pub lCustData: ::LPARAM, pub lpfnHook: LPCFHOOKPROC, pub lpTemplateName: ::LPCSTR, pub hInstance: ::HINSTANCE, pub lpszStyle: ::LPSTR, pub nFontType: ::WORD, pub ___MISSING_ALIGNMENT__: ::WORD, pub nSizeMin: ::INT, pub nSizeMax: ::INT, } impl Clone for CHOOSEFONTA { fn clone(&self) -> CHOOSEFONTA { *self } } pub type LPCHOOSEFONTA = *mut CHOOSEFONTA; #[repr(C)] #[derive(Copy)] pub struct CHOOSEFONTW { pub lStructSize: ::DWORD, pub hwndOwner: ::HWND, pub hDC: ::HDC, pub lpLogFont: ::LPLOGFONTW, pub iPointSize: ::INT, pub Flags: ::DWORD, pub rgbColors: ::COLORREF, pub lCustData: ::LPARAM, pub lpfnHook: LPCFHOOKPROC, pub lpTemplateName: ::LPCWSTR, pub hInstance: ::HINSTANCE, pub lpszStyle: ::LPWSTR, pub nFontType: ::WORD, pub ___MISSING_ALIGNMENT__: ::WORD, pub nSizeMin: ::INT, pub nSizeMax: ::INT, } impl Clone for CHOOSEFONTW { fn clone(&self) -> CHOOSEFONTW { *self } } pub type LPCHOOSEFONTW = *mut CHOOSEFONTW; pub const CF_SCREENFONTS: ::DWORD = 0x00000001; pub const CF_PRINTERFONTS: ::DWORD = 0x00000002; pub const CF_BOTH: ::DWORD = CF_SCREENFONTS | CF_PRINTERFONTS; pub const CF_SHOWHELP: ::DWORD = 0x00000004; pub const CF_ENABLEHOOK: ::DWORD = 0x00000008; pub const CF_ENABLETEMPLATE: ::DWORD = 0x00000010; pub const CF_ENABLETEMPLATEHANDLE: ::DWORD = 0x00000020; pub const CF_INITTOLOGFONTSTRUCT: ::DWORD = 0x00000040; pub const CF_USESTYLE: ::DWORD = 0x00000080; pub const CF_EFFECTS: ::DWORD = 0x00000100; pub const CF_APPLY: ::DWORD = 0x00000200; pub const CF_ANSIONLY: ::DWORD = 0x00000400; pub const CF_SCRIPTSONLY: ::DWORD = CF_ANSIONLY; pub const CF_NOVECTORFONTS: ::DWORD = 0x00000800; pub const CF_NOOEMFONTS: ::DWORD = CF_NOVECTORFONTS; pub const CF_NOSIMULATIONS: ::DWORD = 0x00001000; pub const CF_LIMITSIZE: ::DWORD = 0x00002000; pub const CF_FIXEDPITCHONLY: ::DWORD = 0x00004000; pub const CF_WYSIWYG: ::DWORD = 0x00008000; pub const CF_FORCEFONTEXIST: ::DWORD = 0x00010000; pub const CF_SCALABLEONLY: ::DWORD = 0x00020000; pub const CF_TTONLY: ::DWORD = 0x00040000; pub const CF_NOFACESEL: ::DWORD = 0x00080000; pub const CF_NOSTYLESEL: ::DWORD = 0x00100000; pub const CF_NOSIZESEL: ::DWORD = 0x00200000; pub const CF_SELECTSCRIPT: ::DWORD = 0x00400000; pub const CF_NOSCRIPTSEL: ::DWORD = 0x00800000; pub const CF_NOVERTFONTS: ::DWORD = 0x01000000; pub const CF_INACTIVEFONTS: ::DWORD = 0x02000000; pub const SIMULATED_FONTTYPE: ::WORD = 0x8000; pub const PRINTER_FONTTYPE: ::WORD = 0x4000; pub const SCREEN_FONTTYPE: ::WORD = 0x2000; pub const BOLD_FONTTYPE: ::WORD = 0x0100; pub const ITALIC_FONTTYPE: ::WORD = 0x0200; pub const REGULAR_FONTTYPE: ::WORD = 0x0400; pub const PS_OPENTYPE_FONTTYPE: ::DWORD = 0x10000; pub const TT_OPENTYPE_FONTTYPE: ::DWORD = 0x20000; pub const TYPE1_FONTTYPE: ::DWORD = 0x40000; pub const SYMBOL_FONTTYPE: ::DWORD = 0x80000; pub const WM_CHOOSEFONT_GETLOGFONT: ::UINT = ::WM_USER + 1; pub const WM_CHOOSEFONT_SETLOGFONT: ::UINT = ::WM_USER + 101; pub const WM_CHOOSEFONT_SETFLAGS: ::UINT = ::WM_USER + 102; pub const CD_LBSELNOITEMS: ::WORD = 0 - 1; pub const CD_LBSELCHANGE: ::WORD = 0; pub const CD_LBSELSUB: ::WORD = 1; pub const CD_LBSELADD: ::WORD = 2; pub type LPPRINTHOOKPROC = Option ::UINT_PTR>; pub type LPSETUPHOOKPROC = Option ::UINT_PTR>; #[repr(C)] #[derive(Copy)] pub struct PRINTDLGA { pub lStructSize: ::DWORD, pub hwndOwner: ::HWND, pub hDevMode: ::HGLOBAL, pub hDevNames: ::HGLOBAL, pub hDC: ::HDC, pub Flags: ::DWORD, pub nFromPage: ::WORD, pub nToPage: ::WORD, pub nMinPage: ::WORD, pub nMaxPage: ::WORD, pub nCopies: ::WORD, pub hInstance: ::HINSTANCE, pub lCustData: ::LPARAM, pub lpfnPrintHook: LPPRINTHOOKPROC, pub lpfnSetupHook: LPSETUPHOOKPROC, pub lpPrintTemplateName: ::LPCSTR, pub lpSetupTemplateName: ::LPCSTR, pub hPrintTemplate: ::HGLOBAL, pub hSetupTemplate: ::HGLOBAL, } impl Clone for PRINTDLGA { fn clone(&self) -> PRINTDLGA { *self } } pub type LPPRINTDLGA = *mut PRINTDLGA; #[repr(C)] #[derive(Copy)] pub struct PRINTDLGW { pub lStructSize: ::DWORD, pub hwndOwner: ::HWND, pub hDevMode: ::HGLOBAL, pub hDevNames: ::HGLOBAL, pub hDC: ::HDC, pub Flags: ::DWORD, pub nFromPage: ::WORD, pub nToPage: ::WORD, pub nMinPage: ::WORD, pub nMaxPage: ::WORD, pub nCopies: ::WORD, pub hInstance: ::HINSTANCE, pub lCustData: ::LPARAM, pub lpfnPrintHook: LPPRINTHOOKPROC, pub lpfnSetupHook: LPSETUPHOOKPROC, pub lpPrintTemplateName: ::LPCWSTR, pub lpSetupTemplateName: ::LPCWSTR, pub hPrintTemplate: ::HGLOBAL, pub hSetupTemplate: ::HGLOBAL, } impl Clone for PRINTDLGW { fn clone(&self) -> PRINTDLGW { *self } } pub type LPPRINTDLGW = *mut PRINTDLGW; RIDL!( interface IPrintDialogCallback(IPrintDialogCallbackVtbl) : IUnknown(IUnknownVtbl) { fn InitDone(&mut self) -> ::HRESULT, fn SelectionChange(&mut self) -> ::HRESULT, fn HandleMessage( &mut self, hDlg: ::HWND, uMsg: ::UINT, wParam: ::WPARAM, lParam: ::LPARAM, pResult: *mut ::LRESULT ) -> ::HRESULT } ); RIDL!( interface IPrintDialogServices(IPrintDialogServicesVtbl) : IUnknown(IUnknownVtbl) { fn GetCurrentDevMode(&mut self, pDevMode: ::LPDEVMODEW, pcbSize: *mut ::UINT) -> ::HRESULT, fn GetCurrentPrinterName(&mut self, pPrinterName: ::LPWSTR, pcchSize: *mut ::UINT) -> ::HRESULT, fn GetCurrentPortName(&mut self, pPortName: ::LPWSTR, pcchSize: *mut ::UINT) -> ::HRESULT } ); STRUCT!{struct PRINTPAGERANGE { nFromPage: ::DWORD, nToPage: ::DWORD, }} pub type LPPRINTPAGERANGE = *mut PRINTPAGERANGE; pub type PCPRINTPAGERANGE = *const PRINTPAGERANGE; STRUCT!{struct PRINTDLGEXA { lStructSize: ::DWORD, hwndOwner: ::HWND, hDevMode: ::HGLOBAL, hDevNames: ::HGLOBAL, hDC: ::HDC, Flags: ::DWORD, Flags2: ::DWORD, ExclusionFlags: ::DWORD, nPageRanges: ::DWORD, nMaxPageRanges: ::DWORD, lpPageRanges: LPPRINTPAGERANGE, nMinPage: ::DWORD, nMaxPage: ::DWORD, nCopies: ::DWORD, hInstance: ::HINSTANCE, lpPrintTemplateName: ::LPCSTR, lpCallback: ::LPUNKNOWN, nPropertyPages: ::DWORD, lphPropertyPages: *mut ::HPROPSHEETPAGE, nStartPage: ::DWORD, dwResultAction: ::DWORD, }} pub type LPPRINTDLGEXA = *mut PRINTDLGEXA; STRUCT!{struct PRINTDLGEXW { lStructSize: ::DWORD, hwndOwner: ::HWND, hDevMode: ::HGLOBAL, hDevNames: ::HGLOBAL, hDC: ::HDC, Flags: ::DWORD, Flags2: ::DWORD, ExclusionFlags: ::DWORD, nPageRanges: ::DWORD, nMaxPageRanges: ::DWORD, lpPageRanges: LPPRINTPAGERANGE, nMinPage: ::DWORD, nMaxPage: ::DWORD, nCopies: ::DWORD, hInstance: ::HINSTANCE, lpPrintTemplateName: ::LPCWSTR, lpCallback: ::LPUNKNOWN, nPropertyPages: ::DWORD, lphPropertyPages: *mut ::HPROPSHEETPAGE, nStartPage: ::DWORD, dwResultAction: ::DWORD, }} pub type LPPRINTDLGEXW = *mut PRINTDLGEXW; pub const PD_ALLPAGES: ::DWORD = 0x00000000; pub const PD_SELECTION: ::DWORD = 0x00000001; pub const PD_PAGENUMS: ::DWORD = 0x00000002; pub const PD_NOSELECTION: ::DWORD = 0x00000004; pub const PD_NOPAGENUMS: ::DWORD = 0x00000008; pub const PD_COLLATE: ::DWORD = 0x00000010; pub const PD_PRINTTOFILE: ::DWORD = 0x00000020; pub const PD_PRINTSETUP: ::DWORD = 0x00000040; pub const PD_NOWARNING: ::DWORD = 0x00000080; pub const PD_RETURNDC: ::DWORD = 0x00000100; pub const PD_RETURNIC: ::DWORD = 0x00000200; pub const PD_RETURNDEFAULT: ::DWORD = 0x00000400; pub const PD_SHOWHELP: ::DWORD = 0x00000800; pub const PD_ENABLEPRINTHOOK: ::DWORD = 0x00001000; pub const PD_ENABLESETUPHOOK: ::DWORD = 0x00002000; pub const PD_ENABLEPRINTTEMPLATE: ::DWORD = 0x00004000; pub const PD_ENABLESETUPTEMPLATE: ::DWORD = 0x00008000; pub const PD_ENABLEPRINTTEMPLATEHANDLE: ::DWORD = 0x00010000; pub const PD_ENABLESETUPTEMPLATEHANDLE: ::DWORD = 0x00020000; pub const PD_USEDEVMODECOPIES: ::DWORD = 0x00040000; pub const PD_USEDEVMODECOPIESANDCOLLATE: ::DWORD = 0x00040000; pub const PD_DISABLEPRINTTOFILE: ::DWORD = 0x00080000; pub const PD_HIDEPRINTTOFILE: ::DWORD = 0x00100000; pub const PD_NONETWORKBUTTON: ::DWORD = 0x00200000; pub const PD_CURRENTPAGE: ::DWORD = 0x00400000; pub const PD_NOCURRENTPAGE: ::DWORD = 0x00800000; pub const PD_EXCLUSIONFLAGS: ::DWORD = 0x01000000; pub const PD_USELARGETEMPLATE: ::DWORD = 0x10000000; pub const PD_EXCL_COPIESANDCOLLATE: ::DWORD = ::DM_COPIES | ::DM_COLLATE; pub const START_PAGE_GENERAL: ::DWORD = 0xffffffff; pub const PD_RESULT_CANCEL: ::DWORD = 0; pub const PD_RESULT_PRINT: ::DWORD = 1; pub const PD_RESULT_APPLY: ::DWORD = 2; STRUCT!{struct DEVNAMES { wDriverOffset: ::WORD, wDeviceOffset: ::WORD, wOutputOffset: ::WORD, wDefault: ::WORD, }} pub type LPDEVNAMES = *mut DEVNAMES; pub type PCDEVNAMES = *const DEVNAMES; pub const DN_DEFAULTPRN: ::WORD = 0x0001; pub const WM_PSD_PAGESETUPDLG: ::UINT = ::WM_USER; pub const WM_PSD_FULLPAGERECT: ::UINT = ::WM_USER + 1; pub const WM_PSD_MINMARGINRECT: ::UINT = ::WM_USER + 2; pub const WM_PSD_MARGINRECT: ::UINT = ::WM_USER + 3; pub const WM_PSD_GREEKTEXTRECT: ::UINT = ::WM_USER + 4; pub const WM_PSD_ENVSTAMPRECT: ::UINT = ::WM_USER + 5; pub const WM_PSD_YAFULLPAGERECT: ::UINT = ::WM_USER + 6; pub type LPPAGEPAINTHOOK = Option ::UINT_PTR>; pub type LPPAGESETUPHOOK = Option ::UINT_PTR>; #[repr(C)] #[derive(Copy)] pub struct PAGESETUPDLGA { pub lStructSize: ::DWORD, pub hwndOwner: ::HWND, pub hDevMode: ::HGLOBAL, pub hDevNames: ::HGLOBAL, pub Flags: ::DWORD, pub ptPaperSize: ::POINT, pub rtMinMargin: ::RECT, pub rtMargin: ::RECT, pub hInstance: ::HINSTANCE, pub lCustData: ::LPARAM, pub lpfnPageSetupHook: LPPAGESETUPHOOK, pub lpfnPagePaintHook: LPPAGEPAINTHOOK, pub lpPageSetupTemplateName: ::LPCSTR, pub hPageSetupTemplate: ::HGLOBAL, } impl Clone for PAGESETUPDLGA { fn clone(&self) -> PAGESETUPDLGA { *self } } pub type LPPAGESETUPDLGA = *mut PAGESETUPDLGA; #[repr(C)] #[derive(Copy)] pub struct PAGESETUPDLGW { pub lStructSize: ::DWORD, pub hwndOwner: ::HWND, pub hDevMode: ::HGLOBAL, pub hDevNames: ::HGLOBAL, pub Flags: ::DWORD, pub ptPaperSize: ::POINT, pub rtMinMargin: ::RECT, pub rtMargin: ::RECT, pub hInstance: ::HINSTANCE, pub lCustData: ::LPARAM, pub lpfnPageSetupHook: LPPAGESETUPHOOK, pub lpfnPagePaintHook: LPPAGEPAINTHOOK, pub lpPageSetupTemplateName: ::LPCWSTR, pub hPageSetupTemplate: ::HGLOBAL, } impl Clone for PAGESETUPDLGW { fn clone(&self) -> PAGESETUPDLGW { *self } } pub type LPPAGESETUPDLGW = *mut PAGESETUPDLGW; pub const PSD_DEFAULTMINMARGINS: ::DWORD = 0x00000000; pub const PSD_INWININIINTLMEASURE: ::DWORD = 0x00000000; pub const PSD_MINMARGINS: ::DWORD = 0x00000001; pub const PSD_MARGINS: ::DWORD = 0x00000002; pub const PSD_INTHOUSANDTHSOFINCHES: ::DWORD = 0x00000004; pub const PSD_INHUNDREDTHSOFMILLIMETERS: ::DWORD = 0x00000008; pub const PSD_DISABLEMARGINS: ::DWORD = 0x00000010; pub const PSD_DISABLEPRINTER: ::DWORD = 0x00000020; pub const PSD_NOWARNING: ::DWORD = 0x00000080; pub const PSD_DISABLEORIENTATION: ::DWORD = 0x00000100; pub const PSD_RETURNDEFAULT: ::DWORD = 0x00000400; pub const PSD_DISABLEPAPER: ::DWORD = 0x00000200; pub const PSD_SHOWHELP: ::DWORD = 0x00000800; pub const PSD_ENABLEPAGESETUPHOOK: ::DWORD = 0x00002000; pub const PSD_ENABLEPAGESETUPTEMPLATE: ::DWORD = 0x00008000; pub const PSD_ENABLEPAGESETUPTEMPLATEHANDLE: ::DWORD = 0x00020000; pub const PSD_ENABLEPAGEPAINTHOOK: ::DWORD = 0x00040000; pub const PSD_DISABLEPAGEPAINTING: ::DWORD = 0x00080000; pub const PSD_NONETWORKBUTTON: ::DWORD = 0x00200000; deps/winapi-0.2.5/src/shellapi.rs0000644000000000000000000000017512605021352015373 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License // STUB DECLARE_HANDLE!(HDROP, HDROP__); deps/winapi-0.2.5/src/wtypesbase.rs0000644000000000000000000000146212613167613015772 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //114 pub type OLECHAR = ::WCHAR; pub type LPOLESTR = *mut OLECHAR; pub type LPCOLESTR = *const OLECHAR; //147 pub type DOUBLE = ::c_double; //281 pub type SCODE = ::LONG; pub type PSCODE = *mut SCODE; STRUCT!{struct BLOB { cbSize: ::ULONG, pBlobData: *mut ::BYTE, }} pub type LPBLOB = *mut BLOB; STRUCT!{struct FLAGGED_WORD_BLOB { fFlags: ::ULONG, clSize: ::ULONG, asData: [::c_ushort; 1], }} STRUCT!{struct BYTE_SIZEDARR { clSize: ::ULONG, pData: *mut ::BYTE, }} STRUCT!{struct WORD_SIZEDARR { clSize: ::ULONG, pData: *mut ::c_ushort, }} STRUCT!{struct DWORD_SIZEDARR { clSize: ::ULONG, pData: *mut ::ULONG, }} STRUCT!{struct HYPER_SIZEDARR { clSize: ::ULONG, pData: *mut i64, }} deps/winapi-0.2.5/src/gl.rs0000644000000000000000000000204212605021351014166 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //48 pub type GLenum = ::c_uint; pub type GLboolean = ::c_uchar; pub type GLbitfield = ::c_uint; pub type GLbyte = ::c_schar; pub type GLshort = ::c_short; pub type GLint = ::c_int; pub type GLsizei = ::c_int; pub type GLubyte = ::c_uchar; pub type GLushort = ::c_ushort; pub type GLuint = ::c_uint; pub type GLfloat = ::c_float; pub type GLclampf = ::c_float; pub type GLdouble = ::c_double; pub type GLclampd = ::c_double; pub type GLvoid = ::c_void; //63 //68 //AccumOp pub const GL_ACCUM: GLenum = 0x0100; pub const GL_LOAD: GLenum = 0x0101; pub const GL_RETURN: GLenum = 0x0102; pub const GL_MULT: GLenum = 0x0103; pub const GL_ADD: GLenum = 0x0104; //AlphaFunction pub const GL_NEVER: GLenum = 0x0200; pub const GL_LESS: GLenum = 0x0201; pub const GL_EQUAL: GLenum = 0x0202; pub const GL_LEQUAL: GLenum = 0x0203; pub const GL_GREATER: GLenum = 0x0204; pub const GL_NOTEQUAL: GLenum = 0x0205; pub const GL_GEQUAL: GLenum = 0x0206; pub const GL_ALWAYS: GLenum = 0x0207; deps/winapi-0.2.5/src/winuser.rs0000644000000000000000000023435312615662007015306 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! USER procedure declarations, constant definitions and macros pub const BN_CLICKED: ::WORD = 0; pub const BN_PAINT: ::WORD = 1; pub const BN_HILITE: ::WORD = 2; pub const BN_UNHILITE: ::WORD = 3; pub const BN_DISABLE: ::WORD = 4; pub const BN_DOUBLECLICKED: ::WORD = 5; pub const BN_PUSHED: ::WORD = BN_HILITE; pub const BN_UNPUSHED: ::WORD = BN_UNHILITE; pub const BN_DBLCLK: ::WORD = BN_DOUBLECLICKED; pub const BN_SETFOCUS: ::WORD = 6; pub const BN_KILLFOCUS: ::WORD = 7; pub const BS_PUSHBUTTON: ::DWORD = 0x00000000; pub const BS_DEFPUSHBUTTON: ::DWORD = 0x00000001; pub const BS_CHECKBOX: ::DWORD = 0x00000002; pub const BS_AUTOCHECKBOX: ::DWORD = 0x00000003; pub const BS_RADIOBUTTON: ::DWORD = 0x00000004; pub const BS_3STATE: ::DWORD = 0x00000005; pub const BS_AUTO3STATE: ::DWORD = 0x00000006; pub const BS_GROUPBOX: ::DWORD = 0x00000007; pub const BS_USERBUTTON: ::DWORD = 0x00000008; pub const BS_AUTORADIOBUTTON: ::DWORD = 0x00000009; pub const BS_PUSHBOX: ::DWORD = 0x0000000A; pub const BS_OWNERDRAW: ::DWORD = 0x0000000B; pub const BS_TYPEMASK: ::DWORD = 0x0000000F; pub const BS_LEFTTEXT: ::DWORD = 0x00000020; pub const BS_TEXT: ::DWORD = 0x00000000; pub const BS_ICON: ::DWORD = 0x00000040; pub const BS_BITMAP: ::DWORD = 0x00000080; pub const BS_LEFT: ::DWORD = 0x00000100; pub const BS_RIGHT: ::DWORD = 0x00000200; pub const BS_CENTER: ::DWORD = 0x00000300; pub const BS_TOP: ::DWORD = 0x00000400; pub const BS_BOTTOM: ::DWORD = 0x00000800; pub const BS_VCENTER: ::DWORD = 0x00000C00; pub const BS_PUSHLIKE: ::DWORD = 0x00001000; pub const BS_MULTILINE: ::DWORD = 0x00002000; pub const BS_NOTIFY: ::DWORD = 0x00004000; pub const BS_FLAT: ::DWORD = 0x00008000; pub const BS_RIGHTBUTTON: ::DWORD = BS_LEFTTEXT; pub const CCHILDREN_SCROLLBAR: usize = 5; pub const CDS_UPDATEREGISTRY: ::DWORD = 0x00000001; pub const CDS_TEST: ::DWORD = 0x00000002; pub const CDS_FULLSCREEN: ::DWORD = 0x00000004; pub const CDS_GLOBAL: ::DWORD = 0x00000008; pub const CDS_SET_PRIMARY: ::DWORD = 0x00000010; pub const CDS_VIDEOPARAMETERS: ::DWORD = 0x00000020; pub const CDS_ENABLE_UNSAFE_MODES: ::DWORD = 0x00000100; pub const CDS_DISABLE_UNSAFE_MODES: ::DWORD = 0x00000200; pub const CDS_RESET: ::DWORD = 0x40000000; pub const CDS_RESET_EX: ::DWORD = 0x20000000; pub const CDS_NORESET: ::DWORD = 0x10000000; pub const CS_VREDRAW: ::DWORD = 0x0001; pub const CS_HREDRAW: ::DWORD = 0x0002; pub const CS_DBLCLKS: ::DWORD = 0x0008; pub const CS_OWNDC: ::DWORD = 0x0020; pub const CS_CLASSDC: ::DWORD = 0x0040; pub const CS_PARENTDC: ::DWORD = 0x0080; pub const CS_NOCLOSE: ::DWORD = 0x0200; pub const CS_SAVEBITS: ::DWORD = 0x0800; pub const CS_BYTEALIGNCLIENT: ::DWORD = 0x1000; pub const CS_BYTEALIGNWINDOW: ::DWORD = 0x2000; pub const CS_GLOBALCLASS: ::DWORD = 0x4000; pub const CS_IME: ::DWORD = 0x00010000; pub const CS_DROPSHADOW: ::DWORD = 0x00020000; pub const CW_USEDEFAULT: ::c_int = 0x80000000u32 as ::c_int; pub const DISP_CHANGE_SUCCESSFUL: ::LONG = 0; pub const DISP_CHANGE_RESTART: ::LONG = 1; pub const DISP_CHANGE_FAILED: ::LONG = -1; pub const DISP_CHANGE_BADMODE: ::LONG = -2; pub const DISP_CHANGE_NOTUPDATED: ::LONG = -3; pub const DISP_CHANGE_BADFLAGS: ::LONG = -4; pub const DISP_CHANGE_BADPARAM: ::LONG = -5; pub const DISP_CHANGE_BADDUALVIEW: ::LONG = -6; pub const EDD_GET_DEVICE_INTERFACE_NAME: ::DWORD = 0x00000001; pub const ENUM_CURRENT_SETTINGS: ::DWORD = 0xFFFFFFFF; pub const ENUM_REGISTRY_SETTINGS: ::DWORD = 0xFFFFFFFE; pub const GW_HWNDFIRST: ::UINT = 0; pub const GW_HWNDLAST: ::UINT = 1; pub const GW_HWNDNEXT: ::UINT = 2; pub const GW_HWNDPREV: ::UINT = 3; pub const GW_OWNER: ::UINT = 4; pub const GW_CHILD: ::UINT = 5; pub const GW_ENABLEDPOPUP: ::UINT = 6; pub const GW_MAX: ::UINT = 6; pub const HTERROR: ::c_int = -2; pub const HTTRANSPARENT: ::c_int = -1; pub const HTNOWHERE: ::c_int = 0; pub const HTCLIENT: ::c_int = 1; pub const HTCAPTION: ::c_int = 2; pub const HTSYSMENU: ::c_int = 3; pub const HTGROWBOX: ::c_int = 4; pub const HTSIZE: ::c_int = HTGROWBOX; pub const HTMENU: ::c_int = 5; pub const HTHSCROLL: ::c_int = 6; pub const HTVSCROLL: ::c_int = 7; pub const HTMINBUTTON: ::c_int = 8; pub const HTMAXBUTTON: ::c_int = 9; pub const HTLEFT: ::c_int = 10; pub const HTRIGHT: ::c_int = 11; pub const HTTOP: ::c_int = 12; pub const HTTOPLEFT: ::c_int = 13; pub const HTTOPRIGHT: ::c_int = 14; pub const HTBOTTOM: ::c_int = 15; pub const HTBOTTOMLEFT: ::c_int = 16; pub const HTBOTTOMRIGHT: ::c_int = 17; pub const HTBORDER: ::c_int = 18; pub const HTREDUCE: ::c_int = HTMINBUTTON; pub const HTZOOM: ::c_int = HTMAXBUTTON; pub const HTSIZEFIRST: ::c_int = HTLEFT; pub const HTSIZELAST: ::c_int = HTBOTTOMRIGHT; pub const HTOBJECT: ::c_int = 19; pub const HTCLOSE: ::c_int = 20; pub const HTHELP: ::c_int = 21; pub const LSFW_LOCK: ::UINT = 1; pub const LSFW_UNLOCK: ::UINT = 2; pub const MDITILE_VERTICAL: ::UINT = 0x0000; pub const MDITILE_HORIZONTAL: ::UINT = 0x0001; pub const MDITILE_SKIPDISABLED: ::UINT = 0x0002; pub const MDITILE_ZORDER: ::UINT = 0x0004; pub const MB_OK: ::DWORD = 0x00000000; pub const MB_OKCANCEL: ::DWORD = 0x00000001; pub const MB_ABORTRETRYIGNORE: ::DWORD = 0x00000002; pub const MB_YESNOCANCEL: ::DWORD = 0x00000003; pub const MB_YESNO: ::DWORD = 0x00000004; pub const MB_RETRYCANCEL: ::DWORD = 0x00000005; pub const MB_CANCELTRYCONTINUE: ::DWORD = 0x00000006; pub const MB_ICONHAND: ::DWORD = 0x00000010; pub const MB_ICONQUESTION: ::DWORD = 0x00000020; pub const MB_ICONEXCLAMATION: ::DWORD = 0x00000030; pub const MB_ICONASTERISK: ::DWORD = 0x00000040; pub const MB_USERICON: ::DWORD = 0x00000080; pub const MB_ICONWARNING: ::DWORD = MB_ICONEXCLAMATION; pub const MB_ICONERROR: ::DWORD = MB_ICONHAND; pub const MB_ICONINFORMATION: ::DWORD = MB_ICONASTERISK; pub const MB_ICONSTOP: ::DWORD = MB_ICONHAND; pub const MB_DEFBUTTON1: ::DWORD = 0x00000000; pub const MB_DEFBUTTON2: ::DWORD = 0x00000100; pub const MB_DEFBUTTON3: ::DWORD = 0x00000200; pub const MB_DEFBUTTON4: ::DWORD = 0x00000300; pub const MB_APPLMODAL: ::DWORD = 0x00000000; pub const MB_SYSTEMMODAL: ::DWORD = 0x00001000; pub const MB_TASKMODAL: ::DWORD = 0x00002000; pub const MB_HELP: ::DWORD = 0x00004000; pub const MB_NOFOCUS: ::DWORD = 0x00008000; pub const MB_SETFOREGROUND: ::DWORD = 0x00010000; pub const MB_DEFAULT_DESKTOP_ONLY: ::DWORD = 0x00020000; pub const MB_TOPMOST: ::DWORD = 0x00040000; pub const MB_RIGHT: ::DWORD = 0x00080000; pub const MB_RTLREADING: ::DWORD = 0x00100000; pub const MB_SERVICE_NOTIFICATION: ::DWORD = 0x00200000; pub const MB_SERVICE_NOTIFICATION_NT3X: ::DWORD = 0x00040000; pub const MB_TYPEMASK: ::DWORD = 0x0000000F; pub const MB_ICONMASK: ::DWORD = 0x000000F0; pub const MB_DEFMASK: ::DWORD = 0x00000F00; pub const MB_MODEMASK: ::DWORD = 0x00003000; pub const MB_MISCMASK: ::DWORD = 0x0000C000; pub const SB_HORZ: ::c_int = 0; pub const SB_VERT: ::c_int = 1; pub const SB_CTL: ::c_int = 2; pub const SB_BOTH: ::c_int = 3; pub const SW_HIDE: ::c_int = 0; pub const SW_SHOWNORMAL: ::c_int = 1; pub const SW_NORMAL: ::c_int = 1; pub const SW_SHOWMINIMIZED: ::c_int = 2; pub const SW_SHOWMAXIMIZED: ::c_int = 3; pub const SW_MAXIMIZE: ::c_int = 3; pub const SW_SHOWNOACTIVATE: ::c_int = 4; pub const SW_SHOW: ::c_int = 5; pub const SW_MINIMIZE: ::c_int = 6; pub const SW_SHOWMINNOACTIVE: ::c_int = 7; pub const SW_SHOWNA: ::c_int = 8; pub const SW_RESTORE: ::c_int = 9; pub const SW_SHOWDEFAULT: ::c_int = 10; pub const SW_FORCEMINIMIZE: ::c_int = 11; pub const SW_MAX: ::c_int = 11; pub const SWP_NOSIZE: ::UINT = 0x0001; pub const SWP_NOMOVE: ::UINT = 0x0002; pub const SWP_NOZORDER: ::UINT = 0x0004; pub const SWP_NOREDRAW: ::UINT = 0x0008; pub const SWP_NOACTIVATE: ::UINT = 0x0010; pub const SWP_FRAMECHANGED: ::UINT = 0x0020; pub const SWP_SHOWWINDOW: ::UINT = 0x0040; pub const SWP_HIDEWINDOW: ::UINT = 0x0080; pub const SWP_NOCOPYBITS: ::UINT = 0x0100; pub const SWP_NOOWNERZORDER: ::UINT = 0x0200; pub const SWP_NOSENDCHANGING: ::UINT = 0x0400; pub const SWP_DRAWFRAME: ::UINT = SWP_FRAMECHANGED; pub const SWP_NOREPOSITION: ::UINT = SWP_NOOWNERZORDER; pub const SWP_DEFERERASE: ::UINT = 0x2000; pub const SWP_ASYNCWINDOWPOS: ::UINT = 0x4000; pub const VK_LBUTTON: ::c_int = 0x01; pub const VK_RBUTTON: ::c_int = 0x02; pub const VK_CANCEL: ::c_int = 0x03; pub const VK_MBUTTON: ::c_int = 0x04; pub const VK_XBUTTON1: ::c_int = 0x05; pub const VK_XBUTTON2: ::c_int = 0x06; pub const VK_BACK: ::c_int = 0x08; pub const VK_TAB: ::c_int = 0x09; pub const VK_CLEAR: ::c_int = 0x0C; pub const VK_RETURN: ::c_int = 0x0D; pub const VK_SHIFT: ::c_int = 0x10; pub const VK_CONTROL: ::c_int = 0x11; pub const VK_MENU: ::c_int = 0x12; pub const VK_PAUSE: ::c_int = 0x13; pub const VK_CAPITAL: ::c_int = 0x14; pub const VK_KANA: ::c_int = 0x15; pub const VK_HANGUEL: ::c_int = 0x15; pub const VK_HANGUL: ::c_int = 0x15; pub const VK_JUNJA: ::c_int = 0x17; pub const VK_FINAL: ::c_int = 0x18; pub const VK_HANJA: ::c_int = 0x19; pub const VK_KANJI: ::c_int = 0x19; pub const VK_ESCAPE: ::c_int = 0x1B; pub const VK_CONVERT: ::c_int = 0x1C; pub const VK_NONCONVERT: ::c_int = 0x1D; pub const VK_ACCEPT: ::c_int = 0x1E; pub const VK_MODECHANGE: ::c_int = 0x1F; pub const VK_SPACE: ::c_int = 0x20; pub const VK_PRIOR: ::c_int = 0x21; pub const VK_NEXT: ::c_int = 0x22; pub const VK_END: ::c_int = 0x23; pub const VK_HOME: ::c_int = 0x24; pub const VK_LEFT: ::c_int = 0x25; pub const VK_UP: ::c_int = 0x26; pub const VK_RIGHT: ::c_int = 0x27; pub const VK_DOWN: ::c_int = 0x28; pub const VK_SELECT: ::c_int = 0x29; pub const VK_PRINT: ::c_int = 0x2A; pub const VK_EXECUTE: ::c_int = 0x2B; pub const VK_SNAPSHOT: ::c_int = 0x2C; pub const VK_INSERT: ::c_int = 0x2D; pub const VK_DELETE: ::c_int = 0x2E; pub const VK_HELP: ::c_int = 0x2F; pub const VK_LWIN: ::c_int = 0x5B; pub const VK_RWIN: ::c_int = 0x5C; pub const VK_APPS: ::c_int = 0x5D; pub const VK_SLEEP: ::c_int = 0x5F; pub const VK_NUMPAD0: ::c_int = 0x60; pub const VK_NUMPAD1: ::c_int = 0x61; pub const VK_NUMPAD2: ::c_int = 0x62; pub const VK_NUMPAD3: ::c_int = 0x63; pub const VK_NUMPAD4: ::c_int = 0x64; pub const VK_NUMPAD5: ::c_int = 0x65; pub const VK_NUMPAD6: ::c_int = 0x66; pub const VK_NUMPAD7: ::c_int = 0x67; pub const VK_NUMPAD8: ::c_int = 0x68; pub const VK_NUMPAD9: ::c_int = 0x69; pub const VK_MULTIPLY: ::c_int = 0x6A; pub const VK_ADD: ::c_int = 0x6B; pub const VK_SEPARATOR: ::c_int = 0x6C; pub const VK_SUBTRACT: ::c_int = 0x6D; pub const VK_DECIMAL: ::c_int = 0x6E; pub const VK_DIVIDE: ::c_int = 0x6F; pub const VK_F1: ::c_int = 0x70; pub const VK_F2: ::c_int = 0x71; pub const VK_F3: ::c_int = 0x72; pub const VK_F4: ::c_int = 0x73; pub const VK_F5: ::c_int = 0x74; pub const VK_F6: ::c_int = 0x75; pub const VK_F7: ::c_int = 0x76; pub const VK_F8: ::c_int = 0x77; pub const VK_F9: ::c_int = 0x78; pub const VK_F10: ::c_int = 0x79; pub const VK_F11: ::c_int = 0x7A; pub const VK_F12: ::c_int = 0x7B; pub const VK_F13: ::c_int = 0x7C; pub const VK_F14: ::c_int = 0x7D; pub const VK_F15: ::c_int = 0x7E; pub const VK_F16: ::c_int = 0x7F; pub const VK_F17: ::c_int = 0x80; pub const VK_F18: ::c_int = 0x81; pub const VK_F19: ::c_int = 0x82; pub const VK_F20: ::c_int = 0x83; pub const VK_F21: ::c_int = 0x84; pub const VK_F22: ::c_int = 0x85; pub const VK_F23: ::c_int = 0x86; pub const VK_F24: ::c_int = 0x87; pub const VK_NUMLOCK: ::c_int = 0x90; pub const VK_SCROLL: ::c_int = 0x91; pub const VK_OEM_NEC_EQUAL: ::c_int = 0x92; pub const VK_OEM_FJ_JISHO: ::c_int = 0x92; pub const VK_OEM_FJ_MASSHOU: ::c_int = 0x93; pub const VK_OEM_FJ_TOUROKU: ::c_int = 0x94; pub const VK_OEM_FJ_LOYA: ::c_int = 0x95; pub const VK_OEM_FJ_ROYA: ::c_int = 0x96; pub const VK_LSHIFT: ::c_int = 0xA0; pub const VK_RSHIFT: ::c_int = 0xA1; pub const VK_LCONTROL: ::c_int = 0xA2; pub const VK_RCONTROL: ::c_int = 0xA3; pub const VK_LMENU: ::c_int = 0xA4; pub const VK_RMENU: ::c_int = 0xA5; pub const VK_BROWSER_BACK: ::c_int = 0xA6; pub const VK_BROWSER_FORWARD: ::c_int = 0xA7; pub const VK_BROWSER_REFRESH: ::c_int = 0xA8; pub const VK_BROWSER_STOP: ::c_int = 0xA9; pub const VK_BROWSER_SEARCH: ::c_int = 0xAA; pub const VK_BROWSER_FAVORITES: ::c_int = 0xAB; pub const VK_BROWSER_HOME: ::c_int = 0xAC; pub const VK_VOLUME_MUTE: ::c_int = 0xAD; pub const VK_VOLUME_DOWN: ::c_int = 0xAE; pub const VK_VOLUME_UP: ::c_int = 0xAF; pub const VK_MEDIA_NEXT_TRACK: ::c_int = 0xB0; pub const VK_MEDIA_PREV_TRACK: ::c_int = 0xB1; pub const VK_MEDIA_STOP: ::c_int = 0xB2; pub const VK_MEDIA_PLAY_PAUSE: ::c_int = 0xB3; pub const VK_LAUNCH_MAIL: ::c_int = 0xB4; pub const VK_LAUNCH_MEDIA_SELECT: ::c_int = 0xB5; pub const VK_LAUNCH_APP1: ::c_int = 0xB6; pub const VK_LAUNCH_APP2: ::c_int = 0xB7; pub const VK_OEM_1: ::c_int = 0xBA; pub const VK_OEM_PLUS: ::c_int = 0xBB; pub const VK_OEM_COMMA: ::c_int = 0xBC; pub const VK_OEM_MINUS: ::c_int = 0xBD; pub const VK_OEM_PERIOD: ::c_int = 0xBE; pub const VK_OEM_2: ::c_int = 0xBF; pub const VK_OEM_3: ::c_int = 0xC0; pub const VK_OEM_4: ::c_int = 0xDB; pub const VK_OEM_5: ::c_int = 0xDC; pub const VK_OEM_6: ::c_int = 0xDD; pub const VK_OEM_7: ::c_int = 0xDE; pub const VK_OEM_8: ::c_int = 0xDF; pub const VK_OEM_AX: ::c_int = 0xE1; pub const VK_OEM_102: ::c_int = 0xE2; pub const VK_ICO_HELP: ::c_int = 0xE3; pub const VK_ICO_00: ::c_int = 0xE4; pub const VK_PROCESSKEY: ::c_int = 0xE5; pub const VK_ICO_CLEAR: ::c_int = 0xE6; pub const VK_PACKET: ::c_int = 0xE7; pub const VK_OEM_RESET: ::c_int = 0xE9; pub const VK_OEM_JUMP: ::c_int = 0xEA; pub const VK_OEM_PA1: ::c_int = 0xEB; pub const VK_OEM_PA2: ::c_int = 0xEC; pub const VK_OEM_PA3: ::c_int = 0xED; pub const VK_OEM_WSCTRL: ::c_int = 0xEE; pub const VK_OEM_CUSEL: ::c_int = 0xEF; pub const VK_OEM_ATTN: ::c_int = 0xF0; pub const VK_OEM_FINISH: ::c_int = 0xF1; pub const VK_OEM_COPY: ::c_int = 0xF2; pub const VK_OEM_AUTO: ::c_int = 0xF3; pub const VK_OEM_ENLW: ::c_int = 0xF4; pub const VK_OEM_BACKTAB: ::c_int = 0xF5; pub const VK_ATTN: ::c_int = 0xF6; pub const VK_CRSEL: ::c_int = 0xF7; pub const VK_EXSEL: ::c_int = 0xF8; pub const VK_EREOF: ::c_int = 0xF9; pub const VK_PLAY: ::c_int = 0xFA; pub const VK_ZOOM: ::c_int = 0xFB; pub const VK_NONAME: ::c_int = 0xFC; pub const VK_PA1: ::c_int = 0xFD; pub const VK_OEM_CLEAR: ::c_int = 0xFE; pub const WM_NULL: ::UINT = 0x0000; pub const WM_CREATE: ::UINT = 0x0001; pub const WM_DESTROY: ::UINT = 0x0002; pub const WM_MOVE: ::UINT = 0x0003; pub const WM_SIZE: ::UINT = 0x0005; pub const WM_ACTIVATE: ::UINT = 0x0006; pub const WM_SETFOCUS: ::UINT = 0x0007; pub const WM_KILLFOCUS: ::UINT = 0x0008; pub const WM_ENABLE: ::UINT = 0x000A; pub const WM_SETREDRAW: ::UINT = 0x000B; pub const WM_SETTEXT: ::UINT = 0x000C; pub const WM_GETTEXT: ::UINT = 0x000D; pub const WM_GETTEXTLENGTH: ::UINT = 0x000E; pub const WM_PAINT: ::UINT = 0x000F; pub const WM_CLOSE: ::UINT = 0x0010; pub const WM_QUERYENDSESSION: ::UINT = 0x0011; pub const WM_QUERYOPEN: ::UINT = 0x0013; pub const WM_ENDSESSION: ::UINT = 0x0016; pub const WM_QUIT: ::UINT = 0x0012; pub const WM_ERASEBKGND: ::UINT = 0x0014; pub const WM_SYSCOLORCHANGE: ::UINT = 0x0015; pub const WM_SHOWWINDOW: ::UINT = 0x0018; pub const WM_WININICHANGE: ::UINT = 0x001A; pub const WM_SETTINGCHANGE: ::UINT = WM_WININICHANGE; pub const WM_DEVMODECHANGE: ::UINT = 0x001B; pub const WM_ACTIVATEAPP: ::UINT = 0x001C; pub const WM_FONTCHANGE: ::UINT = 0x001D; pub const WM_TIMECHANGE: ::UINT = 0x001E; pub const WM_CANCELMODE: ::UINT = 0x001F; pub const WM_SETCURSOR: ::UINT = 0x0020; pub const WM_MOUSEACTIVATE: ::UINT = 0x0021; pub const WM_CHILDACTIVATE: ::UINT = 0x0022; pub const WM_QUEUESYNC: ::UINT = 0x0023; pub const WM_GETMINMAXINFO: ::UINT = 0x0024; pub const WM_PAINTICON: ::UINT = 0x0026; pub const WM_ICONERASEBKGND: ::UINT = 0x0027; pub const WM_NEXTDLGCTL: ::UINT = 0x0028; pub const WM_SPOOLERSTATUS: ::UINT = 0x002A; pub const WM_DRAWITEM: ::UINT = 0x002B; pub const WM_MEASUREITEM: ::UINT = 0x002C; pub const WM_DELETEITEM: ::UINT = 0x002D; pub const WM_VKEYTOITEM: ::UINT = 0x002E; pub const WM_CHARTOITEM: ::UINT = 0x002F; pub const WM_SETFONT: ::UINT = 0x0030; pub const WM_GETFONT: ::UINT = 0x0031; pub const WM_SETHOTKEY: ::UINT = 0x0032; pub const WM_GETHOTKEY: ::UINT = 0x0033; pub const WM_QUERYDRAGICON: ::UINT = 0x0037; pub const WM_COMPAREITEM: ::UINT = 0x0039; pub const WM_GETOBJECT: ::UINT = 0x003D; pub const WM_COMPACTING: ::UINT = 0x0041; pub const WM_COMMNOTIFY: ::UINT = 0x0044; pub const WM_WINDOWPOSCHANGING: ::UINT = 0x0046; pub const WM_WINDOWPOSCHANGED: ::UINT = 0x0047; pub const WM_POWER: ::UINT = 0x0048; pub const WM_COPYDATA: ::UINT = 0x004A; pub const WM_CANCELJOURNAL: ::UINT = 0x004B; pub const WM_NOTIFY: ::UINT = 0x004E; pub const WM_INPUTLANGCHANGEREQUEST: ::UINT = 0x0050; pub const WM_INPUTLANGCHANGE: ::UINT = 0x0051; pub const WM_TCARD: ::UINT = 0x0052; pub const WM_HELP: ::UINT = 0x0053; pub const WM_USERCHANGED: ::UINT = 0x0054; pub const WM_NOTIFYFORMAT: ::UINT = 0x0055; pub const WM_CONTEXTMENU: ::UINT = 0x007B; pub const WM_STYLECHANGING: ::UINT = 0x007C; pub const WM_STYLECHANGED: ::UINT = 0x007D; pub const WM_DISPLAYCHANGE: ::UINT = 0x007E; pub const WM_GETICON: ::UINT = 0x007F; pub const WM_SETICON: ::UINT = 0x0080; pub const WM_NCCREATE: ::UINT = 0x0081; pub const WM_NCDESTROY: ::UINT = 0x0082; pub const WM_NCCALCSIZE: ::UINT = 0x0083; pub const WM_NCHITTEST: ::UINT = 0x0084; pub const WM_NCPAINT: ::UINT = 0x0085; pub const WM_NCACTIVATE: ::UINT = 0x0086; pub const WM_GETDLGCODE: ::UINT = 0x0087; pub const WM_SYNCPAINT: ::UINT = 0x0088; pub const WM_NCMOUSEMOVE: ::UINT = 0x00A0; pub const WM_NCLBUTTONDOWN: ::UINT = 0x00A1; pub const WM_NCLBUTTONUP: ::UINT = 0x00A2; pub const WM_NCLBUTTONDBLCLK: ::UINT = 0x00A3; pub const WM_NCRBUTTONDOWN: ::UINT = 0x00A4; pub const WM_NCRBUTTONUP: ::UINT = 0x00A5; pub const WM_NCRBUTTONDBLCLK: ::UINT = 0x00A6; pub const WM_NCMBUTTONDOWN: ::UINT = 0x00A7; pub const WM_NCMBUTTONUP: ::UINT = 0x00A8; pub const WM_NCMBUTTONDBLCLK: ::UINT = 0x00A9; pub const WM_NCXBUTTONDOWN: ::UINT = 0x00AB; pub const WM_NCXBUTTONUP: ::UINT = 0x00AC; pub const WM_NCXBUTTONDBLCLK: ::UINT = 0x00AD; pub const WM_INPUT_DEVICE_CHANGE: ::UINT = 0x00FE; pub const WM_INPUT: ::UINT = 0x00FF; pub const WM_KEYFIRST: ::UINT = 0x0100; pub const WM_KEYDOWN: ::UINT = 0x0100; pub const WM_KEYUP: ::UINT = 0x0101; pub const WM_CHAR: ::UINT = 0x0102; pub const WM_DEADCHAR: ::UINT = 0x0103; pub const WM_SYSKEYDOWN: ::UINT = 0x0104; pub const WM_SYSKEYUP: ::UINT = 0x0105; pub const WM_SYSCHAR: ::UINT = 0x0106; pub const WM_SYSDEADCHAR: ::UINT = 0x0107; pub const WM_UNICHAR: ::UINT = 0x0109; pub const WM_KEYLAST: ::UINT = 0x0109; pub const WM_IME_STARTCOMPOSITION: ::UINT = 0x010D; pub const WM_IME_ENDCOMPOSITION: ::UINT = 0x010E; pub const WM_IME_COMPOSITION: ::UINT = 0x010F; pub const WM_IME_KEYLAST: ::UINT = 0x010F; pub const WM_INITDIALOG: ::UINT = 0x0110; pub const WM_COMMAND: ::UINT = 0x0111; pub const WM_SYSCOMMAND: ::UINT = 0x0112; pub const WM_TIMER: ::UINT = 0x0113; pub const WM_HSCROLL: ::UINT = 0x0114; pub const WM_VSCROLL: ::UINT = 0x0115; pub const WM_INITMENU: ::UINT = 0x0116; pub const WM_INITMENUPOPUP: ::UINT = 0x0117; pub const WM_GESTURE: ::UINT = 0x0119; pub const WM_GESTURENOTIFY: ::UINT = 0x011A; pub const WM_MENUSELECT: ::UINT = 0x011F; pub const WM_MENUCHAR: ::UINT = 0x0120; pub const WM_ENTERIDLE: ::UINT = 0x0121; pub const WM_MENURBUTTONUP: ::UINT = 0x0122; pub const WM_MENUDRAG: ::UINT = 0x0123; pub const WM_MENUGETOBJECT: ::UINT = 0x0124; pub const WM_UNINITMENUPOPUP: ::UINT = 0x0125; pub const WM_MENUCOMMAND: ::UINT = 0x0126; pub const WM_CHANGEUISTATE: ::UINT = 0x0127; pub const WM_UPDATEUISTATE: ::UINT = 0x0128; pub const WM_QUERYUISTATE: ::UINT = 0x0129; pub const WM_CTLCOLORMSGBOX: ::UINT = 0x0132; pub const WM_CTLCOLOREDIT: ::UINT = 0x0133; pub const WM_CTLCOLORLISTBOX: ::UINT = 0x0134; pub const WM_CTLCOLORBTN: ::UINT = 0x0135; pub const WM_CTLCOLORDLG: ::UINT = 0x0136; pub const WM_CTLCOLORSCROLLBAR: ::UINT = 0x0137; pub const WM_CTLCOLORSTATIC: ::UINT = 0x0138; pub const WM_MOUSEFIRST: ::UINT = 0x0200; pub const WM_MOUSEMOVE: ::UINT = 0x0200; pub const WM_LBUTTONDOWN: ::UINT = 0x0201; pub const WM_LBUTTONUP: ::UINT = 0x0202; pub const WM_LBUTTONDBLCLK: ::UINT = 0x0203; pub const WM_RBUTTONDOWN: ::UINT = 0x0204; pub const WM_RBUTTONUP: ::UINT = 0x0205; pub const WM_RBUTTONDBLCLK: ::UINT = 0x0206; pub const WM_MBUTTONDOWN: ::UINT = 0x0207; pub const WM_MBUTTONUP: ::UINT = 0x0208; pub const WM_MBUTTONDBLCLK: ::UINT = 0x0209; pub const WM_MOUSEWHEEL: ::UINT = 0x020A; pub const WM_XBUTTONDOWN: ::UINT = 0x020B; pub const WM_XBUTTONUP: ::UINT = 0x020C; pub const WM_XBUTTONDBLCLK: ::UINT = 0x020D; pub const WM_MOUSEHWHEEL: ::UINT = 0x020E; pub const WM_MOUSELAST: ::UINT = 0x020E; pub const WM_PARENTNOTIFY: ::UINT = 0x0210; pub const WM_ENTERMENULOOP: ::UINT = 0x0211; pub const WM_EXITMENULOOP: ::UINT = 0x0212; pub const WM_NEXTMENU: ::UINT = 0x0213; pub const WM_SIZING: ::UINT = 0x0214; pub const WM_CAPTURECHANGED: ::UINT = 0x0215; pub const WM_MOVING: ::UINT = 0x0216; pub const WM_POWERBROADCAST: ::UINT = 0x0218; pub const WM_DEVICECHANGE: ::UINT = 0x0219; pub const WM_MDICREATE: ::UINT = 0x0220; pub const WM_MDIDESTROY: ::UINT = 0x0221; pub const WM_MDIACTIVATE: ::UINT = 0x0222; pub const WM_MDIRESTORE: ::UINT = 0x0223; pub const WM_MDINEXT: ::UINT = 0x0224; pub const WM_MDIMAXIMIZE: ::UINT = 0x0225; pub const WM_MDITILE: ::UINT = 0x0226; pub const WM_MDICASCADE: ::UINT = 0x0227; pub const WM_MDIICONARRANGE: ::UINT = 0x0228; pub const WM_MDIGETACTIVE: ::UINT = 0x0229; pub const WM_MDISETMENU: ::UINT = 0x0230; pub const WM_ENTERSIZEMOVE: ::UINT = 0x0231; pub const WM_EXITSIZEMOVE: ::UINT = 0x0232; pub const WM_DROPFILES: ::UINT = 0x0233; pub const WM_MDIREFRESHMENU: ::UINT = 0x0234; pub const WM_POINTERDEVICECHANGE: ::UINT = 0x238; pub const WM_POINTERDEVICEINRANGE: ::UINT = 0x239; pub const WM_POINTERDEVICEOUTOFRANGE: ::UINT = 0x23A; pub const WM_TOUCH: ::UINT = 0x0240; pub const WM_NCPOINTERUPDATE: ::UINT = 0x0241; pub const WM_NCPOINTERDOWN: ::UINT = 0x0242; pub const WM_NCPOINTERUP: ::UINT = 0x0243; pub const WM_POINTERUPDATE: ::UINT = 0x0245; pub const WM_POINTERDOWN: ::UINT = 0x0246; pub const WM_POINTERUP: ::UINT = 0x0247; pub const WM_POINTERENTER: ::UINT = 0x0249; pub const WM_POINTERLEAVE: ::UINT = 0x024A; pub const WM_POINTERACTIVATE: ::UINT = 0x024B; pub const WM_POINTERCAPTURECHANGED: ::UINT = 0x024C; pub const WM_TOUCHHITTESTING: ::UINT = 0x024D; pub const WM_POINTERWHEEL: ::UINT = 0x024E; pub const WM_POINTERHWHEEL: ::UINT = 0x024F; pub const WM_IME_SETCONTEXT: ::UINT = 0x0281; pub const WM_IME_NOTIFY: ::UINT = 0x0282; pub const WM_IME_CONTROL: ::UINT = 0x0283; pub const WM_IME_COMPOSITIONFULL: ::UINT = 0x0284; pub const WM_IME_SELECT: ::UINT = 0x0285; pub const WM_IME_CHAR: ::UINT = 0x0286; pub const WM_IME_REQUEST: ::UINT = 0x0288; pub const WM_IME_KEYDOWN: ::UINT = 0x0290; pub const WM_IME_KEYUP: ::UINT = 0x0291; pub const WM_MOUSEHOVER: ::UINT = 0x02A1; pub const WM_MOUSELEAVE: ::UINT = 0x02A3; pub const WM_NCMOUSEHOVER: ::UINT = 0x02A0; pub const WM_NCMOUSELEAVE: ::UINT = 0x02A2; pub const WM_WTSSESSION_CHANGE: ::UINT = 0x02B1; pub const WM_TABLET_FIRST: ::UINT = 0x02c0; pub const WM_TABLET_LAST: ::UINT = 0x02df; pub const WM_DPICHANGED: ::UINT = 0x02E0; pub const WM_CUT: ::UINT = 0x0300; pub const WM_COPY: ::UINT = 0x0301; pub const WM_PASTE: ::UINT = 0x0302; pub const WM_CLEAR: ::UINT = 0x0303; pub const WM_UNDO: ::UINT = 0x0304; pub const WM_RENDERFORMAT: ::UINT = 0x0305; pub const WM_RENDERALLFORMATS: ::UINT = 0x0306; pub const WM_DESTROYCLIPBOARD: ::UINT = 0x0307; pub const WM_DRAWCLIPBOARD: ::UINT = 0x0308; pub const WM_PAINTCLIPBOARD: ::UINT = 0x0309; pub const WM_VSCROLLCLIPBOARD: ::UINT = 0x030A; pub const WM_SIZECLIPBOARD: ::UINT = 0x030B; pub const WM_ASKCBFORMATNAME: ::UINT = 0x030C; pub const WM_CHANGECBCHAIN: ::UINT = 0x030D; pub const WM_HSCROLLCLIPBOARD: ::UINT = 0x030E; pub const WM_QUERYNEWPALETTE: ::UINT = 0x030F; pub const WM_PALETTEISCHANGING: ::UINT = 0x0310; pub const WM_PALETTECHANGED: ::UINT = 0x0311; pub const WM_HOTKEY: ::UINT = 0x0312; pub const WM_PRINT: ::UINT = 0x0317; pub const WM_PRINTCLIENT: ::UINT = 0x0318; pub const WM_APPCOMMAND: ::UINT = 0x0319; pub const WM_THEMECHANGED: ::UINT = 0x031A; pub const WM_CLIPBOARDUPDATE: ::UINT = 0x031D; pub const WM_DWMCOMPOSITIONCHANGED: ::UINT = 0x031E; pub const WM_DWMNCRENDERINGCHANGED: ::UINT = 0x031F; pub const WM_DWMCOLORIZATIONCOLORCHANGED: ::UINT = 0x0320; pub const WM_DWMWINDOWMAXIMIZEDCHANGE: ::UINT = 0x0321; pub const WM_DWMSENDICONICTHUMBNAIL: ::UINT = 0x0323; pub const WM_DWMSENDICONICLIVEPREVIEWBITMAP: ::UINT = 0x0326; pub const WM_GETTITLEBARINFOEX: ::UINT = 0x033F; pub const WM_HANDHELDFIRST: ::UINT = 0x0358; pub const WM_HANDHELDLAST: ::UINT = 0x035F; pub const WM_AFXFIRST: ::UINT = 0x0360; pub const WM_AFXLAST: ::UINT = 0x037F; pub const WM_PENWINFIRST: ::UINT = 0x0380; pub const WM_PENWINLAST: ::UINT = 0x038F; pub const WM_APP: ::UINT = 0x8000; pub const WM_USER: ::UINT = 0x0400; pub const WMSZ_LEFT: ::UINT = 1; pub const WMSZ_RIGHT: ::UINT = 2; pub const WMSZ_TOP: ::UINT = 3; pub const WMSZ_TOPLEFT: ::UINT = 4; pub const WMSZ_TOPRIGHT: ::UINT = 5; pub const WMSZ_BOTTOM: ::UINT = 6; pub const WMSZ_BOTTOMLEFT: ::UINT = 7; pub const WMSZ_BOTTOMRIGHT: ::UINT = 8; pub const SMTO_NORMAL: ::UINT = 0x0000; pub const SMTO_BLOCK: ::UINT = 0x0001; pub const SMTO_ABORTIFHUNG: ::UINT = 0x0002; pub const SMTO_NOTIMEOUTIFNOTHUNG: ::UINT = 0x0008; pub const SMTO_ERRORONEXIT: ::UINT = 0x0020; pub const MA_ACTIVATE: ::UINT = 1; pub const MA_ACTIVATEANDEAT: ::UINT = 2; pub const MA_NOACTIVATE: ::UINT = 3; pub const MA_NOACTIVATEANDEAT: ::UINT = 4; pub const ICON_SMALL: ::UINT = 0; pub const ICON_BIG: ::UINT = 1; pub const ICON_SMALL2: ::UINT = 2; pub const SIZE_RESTORED: ::UINT = 0; pub const SIZE_MINIMIZED: ::UINT = 1; pub const SIZE_MAXIMIZED: ::UINT = 2; pub const SIZE_MAXSHOW: ::UINT = 3; pub const SIZE_MAXHIDE: ::UINT = 4; pub const SIZENORMAL: ::UINT = SIZE_RESTORED; pub const SIZEICONIC: ::UINT = SIZE_MINIMIZED; pub const SIZEFULLSCREEN: ::UINT = SIZE_MAXIMIZED; pub const SIZEZOOMSHOW: ::UINT = SIZE_MAXSHOW; pub const SIZEZOOMHIDE: ::UINT = SIZE_MAXHIDE; #[repr(C)] #[derive(Clone, Copy, Debug)] struct NCCALCSIZE_PARAMS { rgrc: [::RECT; 3], lppos: PWINDOWPOS, } pub type PNCCALCSIZE_PARAMS = *mut NCCALCSIZE_PARAMS; pub type NPNCCALCSIZE_PARAMS = *mut NCCALCSIZE_PARAMS; pub type LPNCCALCSIZE_PARAMS = *mut NCCALCSIZE_PARAMS; pub const WVR_ALIGNTOP: ::UINT = 0x0010; pub const WVR_ALIGNLEFT: ::UINT = 0x0020; pub const WVR_ALIGNBOTTOM: ::UINT = 0x0040; pub const WVR_ALIGNRIGHT: ::UINT = 0x0080; pub const WVR_HREDRAW: ::UINT = 0x0100; pub const WVR_VREDRAW: ::UINT = 0x0200; pub const WVR_REDRAW: ::UINT = WVR_HREDRAW | WVR_VREDRAW; pub const WVR_VALIDRECTS: ::UINT = 0x0400; pub const HOVER_DEFAULT: ::UINT = 0xFFFFFFFF; pub const WS_OVERLAPPED: ::DWORD = 0x00000000; pub const WS_POPUP: ::DWORD = 0x80000000; pub const WS_CHILD: ::DWORD = 0x40000000; pub const WS_MINIMIZE: ::DWORD = 0x20000000; pub const WS_VISIBLE: ::DWORD = 0x10000000; pub const WS_DISABLED: ::DWORD = 0x08000000; pub const WS_CLIPSIBLINGS: ::DWORD = 0x04000000; pub const WS_CLIPCHILDREN: ::DWORD = 0x02000000; pub const WS_MAXIMIZE: ::DWORD = 0x01000000; pub const WS_CAPTION: ::DWORD = 0x00C00000; pub const WS_BORDER: ::DWORD = 0x00800000; pub const WS_DLGFRAME: ::DWORD = 0x00400000; pub const WS_VSCROLL: ::DWORD = 0x00200000; pub const WS_HSCROLL: ::DWORD = 0x00100000; pub const WS_SYSMENU: ::DWORD = 0x00080000; pub const WS_THICKFRAME: ::DWORD = 0x00040000; pub const WS_GROUP: ::DWORD = 0x00020000; pub const WS_TABSTOP: ::DWORD = 0x00010000; pub const WS_MINIMIZEBOX: ::DWORD = 0x00020000; pub const WS_MAXIMIZEBOX: ::DWORD = 0x00010000; pub const WS_TILED: ::DWORD = WS_OVERLAPPED; pub const WS_ICONIC: ::DWORD = WS_MINIMIZE; pub const WS_SIZEBOX: ::DWORD = WS_THICKFRAME; pub const WS_TILEDWINDOW: ::DWORD = WS_OVERLAPPEDWINDOW; pub const WS_OVERLAPPEDWINDOW: ::DWORD = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX; pub const WS_POPUPWINDOW: ::DWORD = WS_POPUP | WS_BORDER | WS_SYSMENU; pub const WS_CHILDWINDOW: ::DWORD = WS_CHILD; pub const WS_EX_DLGMODALFRAME: ::DWORD = 0x00000001; pub const WS_EX_NOPARENTNOTIFY: ::DWORD = 0x00000004; pub const WS_EX_TOPMOST: ::DWORD = 0x00000008; pub const WS_EX_ACCEPTFILES: ::DWORD = 0x00000010; pub const WS_EX_TRANSPARENT: ::DWORD = 0x00000020; pub const WS_EX_MDICHILD: ::DWORD = 0x00000040; pub const WS_EX_TOOLWINDOW: ::DWORD = 0x00000080; pub const WS_EX_WINDOWEDGE: ::DWORD = 0x00000100; pub const WS_EX_CLIENTEDGE: ::DWORD = 0x00000200; pub const WS_EX_CONTEXTHELP: ::DWORD = 0x00000400; pub const WS_EX_RIGHT: ::DWORD = 0x00001000; pub const WS_EX_LEFT: ::DWORD = 0x00000000; pub const WS_EX_RTLREADING: ::DWORD = 0x00002000; pub const WS_EX_LTRREADING: ::DWORD = 0x00000000; pub const WS_EX_LEFTSCROLLBAR: ::DWORD = 0x00004000; pub const WS_EX_RIGHTSCROLLBAR: ::DWORD = 0x00000000; pub const WS_EX_CONTROLPARENT: ::DWORD = 0x00010000; pub const WS_EX_STATICEDGE: ::DWORD = 0x00020000; pub const WS_EX_APPWINDOW: ::DWORD = 0x00040000; pub const WS_EX_OVERLAPPEDWINDOW: ::DWORD = WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE; pub const WS_EX_PALETTEWINDOW: ::DWORD = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST; pub const WS_EX_LAYERED: ::DWORD = 0x00080000; pub const WS_EX_NOINHERITLAYOUT: ::DWORD = 0x00100000; pub const WS_EX_NOREDIRECTIONBITMAP: ::DWORD = 0x00200000; pub const WS_EX_LAYOUTRTL: ::DWORD = 0x00400000; pub const WS_EX_COMPOSITED: ::DWORD = 0x02000000; pub const WS_EX_NOACTIVATE: ::DWORD = 0x08000000; pub type NAMEENUMPROCA = Option ::BOOL>; pub type NAMEENUMPROCW = Option ::BOOL>; pub type DESKTOPENUMPROCA = NAMEENUMPROCA; pub type DESKTOPENUMPROCW = NAMEENUMPROCW; pub type WINSTAENUMPROCA = NAMEENUMPROCA; pub type WINSTAENUMPROCW = NAMEENUMPROCW; pub type WNDENUMPROC = Option ::BOOL>; pub type WNDPROC = Option ::LRESULT>; pub type DLGPROC = Option ::INT_PTR>; pub type HOOKPROC = Option ::LRESULT>; pub type TimerProc = Option; pub type DRAWSTATEPROC = Option ::BOOL>; pub type PROPENUMPROCA = Option ::BOOL>; pub type PROPENUMPROCW = Option ::BOOL>; pub type GRAYSTRINGPROC = Option ::BOOL>; pub type MSGBOXCALLBACK = Option; pub type WINEVENTPROC = Option; pub type HDEVNOTIFY = ::PVOID; pub type MENUTEMPLATEA = ::VOID; pub type MENUTEMPLATEW = ::VOID; STRUCT!{struct MSG { hwnd: ::HWND, message: ::UINT, wParam: ::WPARAM, lParam: ::LPARAM, time: ::DWORD, pt: ::POINT, }} pub type PMSG = *mut MSG; pub type NPMSG = *mut MSG; pub type LPMSG = *mut MSG; STRUCT!{struct PAINTSTRUCT { hdc: ::HDC, fErase: ::BOOL, rcPaint: ::RECT, fRestore: ::BOOL, fIncUpdate: ::BOOL, rgbReserved: [::BYTE; 32], }} pub type PPAINTSTRUCT = *mut PAINTSTRUCT; pub type NPPAINTSTRUCT = *mut PAINTSTRUCT; pub type LPPAINTSTRUCT = *mut PAINTSTRUCT; STRUCT!{struct WINDOWPLACEMENT { length: ::UINT, flags: ::UINT, showCmd: ::UINT, ptMinPosition: ::POINT, ptMaxPosition: ::POINT, rcNormalPosition: ::RECT, }} pub type PWINDOWPLACEMENT = *mut WINDOWPLACEMENT; pub type LPWINDOWPLACEMENT = *mut WINDOWPLACEMENT; #[repr(C)] #[derive(Copy)] pub struct WNDCLASSEXW { pub cbSize: ::UINT, pub style: ::UINT, pub lpfnWndProc: WNDPROC, pub cbClsExtra: ::c_int, pub cbWndExtra: ::c_int, pub hInstance: ::HINSTANCE, pub hIcon: ::HICON, pub hCursor: ::HCURSOR, pub hbrBackground: ::HBRUSH, pub lpszMenuName: ::LPCWSTR, pub lpszClassName: ::LPCWSTR, pub hIconSm: ::HICON, } impl Clone for WNDCLASSEXW { fn clone(&self) -> WNDCLASSEXW { *self } } pub type PWNDCLASSEXW = *mut WNDCLASSEXW; pub type NPWNDCLASSEXW = *mut WNDCLASSEXW; pub type LPWNDCLASSEXW = *mut WNDCLASSEXW; #[repr(C)] #[derive(Copy)] pub struct WNDCLASSW { pub style: ::UINT, pub lpfnWndProc: WNDPROC, pub cbClsExtra: ::c_int, pub cbWndExtra: ::c_int, pub hInstance: ::HINSTANCE, pub hIcon: ::HICON, pub hCursor: ::HCURSOR, pub hbrBackground: ::HBRUSH, pub lpszMenuName: ::LPCWSTR, pub lpszClassName: ::LPCWSTR } impl Clone for WNDCLASSW { fn clone(&self) -> WNDCLASSW { *self } } pub type PWNDCLASSW = *mut WNDCLASSW; pub type NPWNDCLASSW = *mut WNDCLASSW; pub type LPWNDCLASSW = *mut WNDCLASSW; STRUCT!{struct SCROLLBARINFO { cbSize: ::DWORD, rcScrollBar: ::RECT, dxyLineButton: ::c_int, xyThumbTop: ::c_int, xyThumbBottom: ::c_int, reserved: ::c_int, rgstate: [::DWORD; CCHILDREN_SCROLLBAR + 1], }} pub type PSCROLLBARINFO = *mut SCROLLBARINFO; pub type LPSCROLLBARINFO = *mut SCROLLBARINFO; STRUCT!{struct SCROLLINFO { cbSize: ::UINT, fMask: ::UINT, nMin: ::c_int, nMax: ::c_int, nPage: ::UINT, nPos: ::c_int, nTrackPos: ::c_int, }} pub type LPSCROLLINFO = *mut SCROLLINFO; pub type LPCSCROLLINFO = *const SCROLLINFO; STRUCT!{struct SIZE { cx: ::LONG, cy: ::LONG, }} pub type PSIZE = *mut SIZE; pub type LPSIZE = *mut SIZE; pub type SIZEL = SIZE; pub type PSIZEL = *mut SIZEL; pub type LPSIZEL = *mut SIZEL; //1913 pub const UNICODE_NOCHAR: ::WPARAM = 0xffff; pub type HDWP = *mut ::HANDLE; //2193 pub const WHEEL_DELTA: ::DWORD = 120; //2206 pub const XBUTTON1: ::DWORD = 0x0001; pub const XBUTTON2: ::DWORD = 0x0002; //2392 pub const MK_LBUTTON: ::WPARAM = 0x0001; pub const MK_RBUTTON: ::WPARAM = 0x0002; pub const MK_SHIFT: ::WPARAM = 0x0004; pub const MK_CONTROL: ::WPARAM = 0x0008; pub const MK_MBUTTON: ::WPARAM = 0x0010; pub const MK_XBUTTON1: ::WPARAM = 0x0020; pub const MK_XBUTTON2: ::WPARAM = 0x0040; //2408 pub const TME_HOVER: ::DWORD = 0x0000_0001; pub const TME_LEAVE: ::DWORD = 0x0000_0002; pub const TME_NONCLIENT: ::DWORD = 0x0000_0010; pub const TME_QUERY: ::DWORD = 0x4000_0000; pub const TME_CANCEL: ::DWORD = 0x8000_0000; pub const HWND_BROADCAST: ::HWND = 0xFFFF as ::HWND; pub const HWND_MESSAGE: ::HWND = -3isize as ::HWND; STRUCT!{struct TRACKMOUSEEVENT { cbSize: ::DWORD, dwFlags: ::DWORD, hwndTrack: ::HWND, dwHoverTime: ::DWORD, }} pub type LPTRACKMOUSEEVENT = *mut TRACKMOUSEEVENT; //2575 /// lParam of WM_WINDOWPOSCHANGING, WM_WINDOWPOSCHANGED #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct WINDOWPOS { pub hwnd: ::HWND, /// hwnd or HWND_BOTTOM, HWND_NOTOPMOST, HWND_TOP, HWND_TOPMOST pub hwndInsertAfter: ::HWND, pub x: ::c_int, pub y: ::c_int, pub cx: ::c_int, pub cy: ::c_int, /// SWP_\* pub flags: ::UINT, } pub type LPWINDOWPOS = *mut WINDOWPOS; pub type PWINDOWPOS = *mut WINDOWPOS; //3082 STRUCT!{struct CREATESTRUCTA { lpCreateParams: ::LPVOID, hInstance: ::HINSTANCE, hMenu: ::HMENU, hwndParent: ::HWND, cy: ::c_int, cx: ::c_int, y: ::c_int, x: ::c_int, style: ::LONG, lpszName: ::LPCSTR, lpszClass: ::LPCSTR, dwExStyle: ::DWORD, }} pub type LPCREATESTRUCTA = *mut CREATESTRUCTA; STRUCT!{struct CREATESTRUCTW { lpCreateParams: ::LPVOID, hInstance: ::HINSTANCE, hMenu: ::HMENU, hwndParent: ::HWND, cy: ::c_int, cx: ::c_int, y: ::c_int, x: ::c_int, style: ::LONG, lpszName: ::LPCWSTR, lpszClass: ::LPCWSTR, dwExStyle: ::DWORD, }} pub type LPCREATESTRUCTW = *mut CREATESTRUCTW; //3145 #[repr(C)] #[derive(Clone, Copy, Debug)] /// The lParam of the WM_NOTIFY message is a pointer to this structure pub struct NMHDR { pub hwndFrom: ::HWND, pub idFrom: ::UINT_PTR, pub code: ::UINT, // NM_ code } pub type LPNMHDR = *mut NMHDR; //3400 pub const PM_NOREMOVE: ::UINT = 0x0000; pub const PM_REMOVE: ::UINT = 0x0001; pub const PM_NOYIELD: ::UINT = 0x0002; pub const PM_QS_INPUT: ::UINT = QS_INPUT << 16; pub const PM_QS_POSTMESSAGE: ::UINT = (QS_POSTMESSAGE | QS_HOTKEY | QS_TIMER) << 16; pub const PM_QS_PAINT: ::UINT = QS_PAINT << 16; pub const PM_QS_SENDMESSAGE: ::UINT = QS_SENDMESSAGE << 16; // pub const LWA_COLORKEY: ::DWORD = 0x00000001; pub const LWA_ALPHA: ::DWORD = 0x00000002; //3469 pub const EWX_LOGOFF: ::UINT = 0x00000000; pub const EWX_SHUTDOWN: ::UINT = 0x00000001; pub const EWX_REBOOT: ::UINT = 0x00000002; pub const EWX_FORCE: ::UINT = 0x00000004; pub const EWX_POWEROFF: ::UINT = 0x00000008; pub const EWX_FORCEIFHUNG: ::UINT = 0x00000010; pub const EWX_QUICKRESOLVE: ::UINT = 0x00000020; pub const EWX_RESTARTAPPS: ::UINT = 0x00000040; pub const EWX_HYBRID_SHUTDOWN: ::UINT = 0x00400000; pub const EWX_BOOTOPTIONS: ::UINT = 0x01000000; //4054 (Win 7 SDK) STRUCT!{struct FLASHWINFO { cbSize: ::UINT, hwnd: ::HWND, dwFlags: ::DWORD, uCount: ::UINT, dwTimeout: ::DWORD, }} pub type PFLASHWINFO = *mut FLASHWINFO; pub const FLASHW_STOP: ::DWORD = 0; pub const FLASHW_CAPTION: ::DWORD = 0x00000001; pub const FLASHW_TRAY: ::DWORD = 0x00000002; pub const FLASHW_ALL: ::DWORD = FLASHW_CAPTION | FLASHW_TRAY; pub const FLASHW_TIMER: ::DWORD = 0x00000004; pub const FLASHW_TIMERNOFG: ::DWORD = 0x0000000C; //5499 pub const MAPVK_VK_TO_VSC: ::UINT = 0; pub const MAPVK_VSC_TO_VK: ::UINT = 1; pub const MAPVK_VK_TO_CHAR: ::UINT = 2; pub const MAPVK_VSC_TO_VK_EX: ::UINT = 3; pub const MAPVK_VK_TO_VSC_EX: ::UINT = 4; //5741 pub const KEYEVENTF_EXTENDEDKEY: ::DWORD = 0x0001; pub const KEYEVENTF_KEYUP: ::DWORD = 0x0002; pub const KEYEVENTF_UNICODE: ::DWORD = 0x0004; pub const KEYEVENTF_SCANCODE: ::DWORD = 0x0008; pub const MOUSEEVENTF_MOVE: ::DWORD = 0x0001; pub const MOUSEEVENTF_LEFTDOWN: ::DWORD = 0x0002; pub const MOUSEEVENTF_LEFTUP: ::DWORD = 0x0004; pub const MOUSEEVENTF_RIGHTDOWN: ::DWORD = 0x0008; pub const MOUSEEVENTF_RIGHTUP: ::DWORD = 0x0010; pub const MOUSEEVENTF_MIDDLEDOWN: ::DWORD = 0x0020; pub const MOUSEEVENTF_MIDDLEUP: ::DWORD = 0x0040; pub const MOUSEEVENTF_XDOWN: ::DWORD = 0x0080; pub const MOUSEEVENTF_XUP: ::DWORD = 0x0100; pub const MOUSEEVENTF_WHEEL: ::DWORD = 0x0800; pub const MOUSEEVENTF_HWHEEL: ::DWORD = 0x01000; pub const MOUSEEVENTF_MOVE_NOCOALESCE: ::DWORD = 0x2000; pub const MOUSEEVENTF_VIRTUALDESK: ::DWORD = 0x4000; pub const MOUSEEVENTF_ABSOLUTE: ::DWORD = 0x8000; STRUCT!{struct MOUSEINPUT { dx: ::LONG, dy: ::LONG, mouseData: ::DWORD, dwFlags: ::DWORD, time: ::DWORD, dwExtraInfo: ::ULONG_PTR, }} pub type PMOUSEINPUT = *mut MOUSEINPUT; pub type LPMOUSEINPUT = *mut MOUSEINPUT; STRUCT!{struct KEYBDINPUT { wVk: ::WORD, wScan: ::WORD, dwFlags: ::DWORD, time: ::DWORD, dwExtraInfo: ::ULONG_PTR, }} pub type PKEYBDINPUT = *mut KEYBDINPUT; pub type LPKEYBDINPUT = *mut KEYBDINPUT; STRUCT!{struct HARDWAREINPUT { uMsg: ::DWORD, wParamL: ::WORD, wParamH: ::WORD, }} pub type PHARDWAREINPUT = *mut HARDWAREINPUT; pub type LPHARDWAREINPUT= *mut HARDWAREINPUT; pub const INPUT_MOUSE: ::DWORD = 0; pub const INPUT_KEYBOARD: ::DWORD = 1; pub const INPUT_HARDWARE: ::DWORD = 2; #[cfg(target_arch = "x86")] STRUCT!{struct INPUT { type_: ::DWORD, u: [u32; 6], }} #[cfg(target_arch = "x86_64")] STRUCT!{struct INPUT { type_: ::DWORD, u: [u64; 4], }} UNION!{INPUT, u, mi, mi_mut, MOUSEINPUT} UNION!{INPUT, u, ki, ki_mut, KEYBDINPUT} UNION!{INPUT, u, hi, hi_mut, HARDWAREINPUT} pub type PINPUT = *mut INPUT; pub type LPINPUT = *mut INPUT; //Indices for GetWindowLong etc. pub const GWL_EXSTYLE: ::c_int = -20; pub const GWL_STYLE: ::c_int = -16; pub const GWL_WNDPROC: ::c_int = -4; pub const GWLP_WNDPROC: ::c_int = -4; pub const GWL_HINSTANCE: ::c_int = -6; pub const GWLP_HINSTANCE: ::c_int = -6; pub const GWL_HWNDPARENT: ::c_int = -8; pub const GWLP_HWNDPARENT: ::c_int = -8; pub const GWL_ID: ::c_int = -12; pub const GWLP_ID: ::c_int = -12; pub const GWL_USERDATA: ::c_int = -21; pub const GWLP_USERDATA: ::c_int = -21; //5976 ENUM!{enum POINTER_INPUT_TYPE { PT_POINTER = 0x00000001, PT_TOUCH = 0x00000002, PT_PEN = 0x00000003, PT_MOUSE = 0x00000004, PT_TOUCHPAD = 0x00000005, }} //6566 // flags for MsgWaitForMultipleObjectsEx pub const MWMO_WAITALL: ::DWORD = 0x0001; pub const MWMO_ALERTABLE: ::DWORD = 0x0002; pub const MWMO_INPUTAVAILABLE: ::DWORD = 0x0004; //6573 pub const QS_KEY: ::UINT = 0x0001; pub const QS_MOUSEMOVE: ::UINT = 0x0002; pub const QS_MOUSEBUTTON: ::UINT = 0x0004; pub const QS_POSTMESSAGE: ::UINT = 0x0008; pub const QS_TIMER: ::UINT = 0x0010; pub const QS_PAINT: ::UINT = 0x0020; pub const QS_SENDMESSAGE: ::UINT = 0x0040; pub const QS_HOTKEY: ::UINT = 0x0080; pub const QS_ALLPOSTMESSAGE: ::UINT = 0x0100; pub const QS_RAWINPUT: ::UINT = 0x0400; pub const QS_TOUCH: ::UINT = 0x0800; pub const QS_POINTER: ::UINT = 0x1000; pub const QS_MOUSE: ::UINT = QS_MOUSEMOVE | QS_MOUSEBUTTON; pub const QS_INPUT: ::UINT = QS_MOUSE | QS_KEY | QS_RAWINPUT | QS_TOUCH | QS_POINTER; pub const QS_ALLEVENTS: ::UINT = QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY; pub const QS_ALLINPUT: ::UINT = QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY | QS_SENDMESSAGE; //6789 pub const SM_CXSCREEN: ::c_int = 0; pub const SM_CYSCREEN: ::c_int = 1; pub const SM_CXVSCROLL: ::c_int = 2; pub const SM_CYHSCROLL: ::c_int = 3; pub const SM_CYCAPTION: ::c_int = 4; pub const SM_CXBORDER: ::c_int = 5; pub const SM_CYBORDER: ::c_int = 6; pub const SM_CXDLGFRAME: ::c_int = 7; pub const SM_CYDLGFRAME: ::c_int = 8; pub const SM_CYVTHUMB: ::c_int = 9; pub const SM_CXHTHUMB: ::c_int = 10; pub const SM_CXICON: ::c_int = 11; pub const SM_CYICON: ::c_int = 12; pub const SM_CXCURSOR: ::c_int = 13; pub const SM_CYCURSOR: ::c_int = 14; pub const SM_CYMENU: ::c_int = 15; pub const SM_CXFULLSCREEN: ::c_int = 16; pub const SM_CYFULLSCREEN: ::c_int = 17; pub const SM_CYKANJIWINDOW: ::c_int = 18; pub const SM_MOUSEPRESENT: ::c_int = 19; pub const SM_CYVSCROLL: ::c_int = 20; pub const SM_CXHSCROLL: ::c_int = 21; pub const SM_DEBUG: ::c_int = 22; pub const SM_SWAPBUTTON: ::c_int = 23; pub const SM_RESERVED1: ::c_int = 24; pub const SM_RESERVED2: ::c_int = 25; pub const SM_RESERVED3: ::c_int = 26; pub const SM_RESERVED4: ::c_int = 27; pub const SM_CXMIN: ::c_int = 28; pub const SM_CYMIN: ::c_int = 29; pub const SM_CXSIZE: ::c_int = 30; pub const SM_CYSIZE: ::c_int = 31; pub const SM_CXFRAME: ::c_int = 32; pub const SM_CYFRAME: ::c_int = 33; pub const SM_CXMINTRACK: ::c_int = 34; pub const SM_CYMINTRACK: ::c_int = 35; pub const SM_CXDOUBLECLK: ::c_int = 36; pub const SM_CYDOUBLECLK: ::c_int = 37; pub const SM_CXICONSPACING: ::c_int = 38; pub const SM_CYICONSPACING: ::c_int = 39; pub const SM_MENUDROPALIGNMENT: ::c_int = 40; pub const SM_PENWINDOWS: ::c_int = 41; pub const SM_DBCSENABLED: ::c_int = 42; pub const SM_CMOUSEBUTTONS: ::c_int = 43; pub const SM_CXFIXEDFRAME: ::c_int = SM_CXDLGFRAME; pub const SM_CYFIXEDFRAME: ::c_int = SM_CYDLGFRAME; pub const SM_CXSIZEFRAME: ::c_int = SM_CXFRAME; pub const SM_CYSIZEFRAME: ::c_int = SM_CYFRAME; pub const SM_SECURE: ::c_int = 44; pub const SM_CXEDGE: ::c_int = 45; pub const SM_CYEDGE: ::c_int = 46; pub const SM_CXMINSPACING: ::c_int = 47; pub const SM_CYMINSPACING: ::c_int = 48; pub const SM_CXSMICON: ::c_int = 49; pub const SM_CYSMICON: ::c_int = 50; pub const SM_CYSMCAPTION: ::c_int = 51; pub const SM_CXSMSIZE: ::c_int = 52; pub const SM_CYSMSIZE: ::c_int = 53; pub const SM_CXMENUSIZE: ::c_int = 54; pub const SM_CYMENUSIZE: ::c_int = 55; pub const SM_ARRANGE: ::c_int = 56; pub const SM_CXMINIMIZED: ::c_int = 57; pub const SM_CYMINIMIZED: ::c_int = 58; pub const SM_CXMAXTRACK: ::c_int = 59; pub const SM_CYMAXTRACK: ::c_int = 60; pub const SM_CXMAXIMIZED: ::c_int = 61; pub const SM_CYMAXIMIZED: ::c_int = 62; pub const SM_NETWORK: ::c_int = 63; pub const SM_CLEANBOOT: ::c_int = 67; pub const SM_CXDRAG: ::c_int = 68; pub const SM_CYDRAG: ::c_int = 69; pub const SM_SHOWSOUNDS: ::c_int = 70; pub const SM_CXMENUCHECK: ::c_int = 71; pub const SM_CYMENUCHECK: ::c_int = 72; pub const SM_SLOWMACHINE: ::c_int = 73; pub const SM_MIDEASTENABLED: ::c_int = 74; pub const SM_MOUSEWHEELPRESENT: ::c_int = 75; pub const SM_XVIRTUALSCREEN: ::c_int = 76; pub const SM_YVIRTUALSCREEN: ::c_int = 77; pub const SM_CXVIRTUALSCREEN: ::c_int = 78; pub const SM_CYVIRTUALSCREEN: ::c_int = 79; pub const SM_CMONITORS: ::c_int = 80; pub const SM_SAMEDISPLAYFORMAT: ::c_int = 81; pub const SM_IMMENABLED: ::c_int = 82; pub const SM_CXFOCUSBORDER: ::c_int = 83; pub const SM_CYFOCUSBORDER: ::c_int = 84; pub const SM_TABLETPC: ::c_int = 86; pub const SM_MEDIACENTER: ::c_int = 87; pub const SM_STARTER: ::c_int = 88; pub const SM_SERVERR2: ::c_int = 89; pub const SM_MOUSEHORIZONTALWHEELPRESENT: ::c_int = 91; pub const SM_CXPADDEDBORDER: ::c_int = 92; pub const SM_DIGITIZER: ::c_int = 94; pub const SM_MAXIMUMTOUCHES: ::c_int = 95; pub const SM_CMETRICS: ::c_int = 97; pub const SM_REMOTESESSION: ::c_int = 0x1000; pub const SM_SHUTTINGDOWN: ::c_int = 0x2000; pub const SM_REMOTECONTROL: ::c_int = 0x2001; pub const SM_CARETBLINKINGENABLED: ::c_int = 0x2002; pub const SM_CONVERTIBLESLATEMODE: ::c_int = 0x2003; pub const SM_SYSTEMDOCKED: ::c_int = 0x2004; //8855 (Win 7 SDK) STRUCT!{struct ICONINFO { fIcon: ::BOOL, xHotspot: ::DWORD, yHotspot: ::DWORD, hbmMask: ::HBITMAP, hbmColor: ::HBITMAP, }} pub type PICONINFO = *mut ICONINFO; //9066 // Color indexes for use in GetSysColor and SetSysColor // 0-18 (after incrementing) are also valid in RegisterClass's WNDCLASS pub const COLOR_SCROLLBAR: ::c_int = 0; pub const COLOR_BACKGROUND: ::c_int = 1; pub const COLOR_ACTIVECAPTION: ::c_int = 2; pub const COLOR_INACTIVECAPTION: ::c_int = 3; pub const COLOR_MENU: ::c_int = 4; pub const COLOR_WINDOW: ::c_int = 5; pub const COLOR_WINDOWFRAME: ::c_int = 6; pub const COLOR_MENUTEXT: ::c_int = 7; pub const COLOR_WINDOWTEXT: ::c_int = 8; pub const COLOR_CAPTIONTEXT: ::c_int = 9; pub const COLOR_ACTIVEBORDER: ::c_int = 10; pub const COLOR_INACTIVEBORDER: ::c_int = 11; pub const COLOR_APPWORKSPACE: ::c_int = 12; pub const COLOR_HIGHLIGHT: ::c_int = 13; pub const COLOR_HIGHLIGHTTEXT: ::c_int = 14; pub const COLOR_BTNFACE: ::c_int = 15; pub const COLOR_BTNSHADOW: ::c_int = 16; pub const COLOR_GRAYTEXT: ::c_int = 17; pub const COLOR_BTNTEXT: ::c_int = 18; pub const COLOR_INACTIVECAPTIONTEXT: ::c_int = 19; pub const COLOR_BTNHIGHLIGHT: ::c_int = 20; // Introduced in Windows 95 (winver 0x0400): pub const COLOR_3DDKSHADOW: ::c_int = 21; pub const COLOR_3DLIGHT: ::c_int = 22; pub const COLOR_INFOTEXT: ::c_int = 23; pub const COLOR_INFOBK: ::c_int = 24; pub const COLOR_DESKTOP: ::c_int = COLOR_BACKGROUND; pub const COLOR_3DFACE: ::c_int = COLOR_BTNFACE; pub const COLOR_3DSHADOW: ::c_int = COLOR_BTNSHADOW; pub const COLOR_3DHIGHLIGHT: ::c_int = COLOR_BTNHIGHLIGHT; pub const COLOR_3DHILIGHT: ::c_int = COLOR_BTNHIGHLIGHT; pub const COLOR_BTNHILIGHT: ::c_int = COLOR_BTNHIGHLIGHT; // Introduced in Windows 2000 (winver 0x0500) pub const COLOR_HOTLIGHT: ::c_int = 26; pub const COLOR_GRADIENTACTIVECAPTION: ::c_int = 27; pub const COLOR_GRADIENTINACTIVECAPTION: ::c_int = 28; // Introduced in Windows XP (winver 0x0501) pub const COLOR_MENUHILIGHT: ::c_int = 29; pub const COLOR_MENUBAR: ::c_int = 30; //10069 pub const IDC_ARROW: ::LPCWSTR = 32512 as ::LPCWSTR; pub const IDC_IBEAM: ::LPCWSTR = 32513 as ::LPCWSTR; pub const IDC_WAIT: ::LPCWSTR = 32514 as ::LPCWSTR; pub const IDC_CROSS: ::LPCWSTR = 32515 as ::LPCWSTR; pub const IDC_UPARROW: ::LPCWSTR = 32516 as ::LPCWSTR; pub const IDC_SIZE: ::LPCWSTR = 32640 as ::LPCWSTR; pub const IDC_ICON: ::LPCWSTR = 32641 as ::LPCWSTR; pub const IDC_SIZENWSE: ::LPCWSTR = 32642 as ::LPCWSTR; pub const IDC_SIZENESW: ::LPCWSTR = 32643 as ::LPCWSTR; pub const IDC_SIZEWE: ::LPCWSTR = 32644 as ::LPCWSTR; pub const IDC_SIZENS: ::LPCWSTR = 32645 as ::LPCWSTR; pub const IDC_SIZEALL: ::LPCWSTR = 32646 as ::LPCWSTR; pub const IDC_NO: ::LPCWSTR = 32648 as ::LPCWSTR; pub const IDC_HAND: ::LPCWSTR = 32649 as ::LPCWSTR; pub const IDC_APPSTARTING: ::LPCWSTR = 32650 as ::LPCWSTR; pub const IDC_HELP: ::LPCWSTR = 32651 as ::LPCWSTR; //10492 pub const IDI_APPLICATION: ::LPCWSTR = 32512 as ::LPCWSTR; pub const IDI_HAND: ::LPCWSTR = 32513 as ::LPCWSTR; pub const IDI_QUESTION: ::LPCWSTR = 32514 as ::LPCWSTR; pub const IDI_EXCLAMATION: ::LPCWSTR = 32515 as ::LPCWSTR; pub const IDI_ASTERISK: ::LPCWSTR = 32516 as ::LPCWSTR; pub const IDI_WINLOGO: ::LPCWSTR = 32517 as ::LPCWSTR; pub const IDI_SHIELD: ::LPCWSTR = 32518 as ::LPCWSTR; pub const IDI_WARNING: ::LPCWSTR = IDI_EXCLAMATION; pub const IDI_ERROR: ::LPCWSTR = IDI_HAND; pub const IDI_INFORMATION: ::LPCWSTR = IDI_ASTERISK; pub const SPI_GETBEEP: ::UINT = 0x0001; pub const SPI_SETBEEP: ::UINT = 0x0002; pub const SPI_GETMOUSE: ::UINT = 0x0003; pub const SPI_SETMOUSE: ::UINT = 0x0004; pub const SPI_GETBORDER: ::UINT = 0x0005; pub const SPI_SETBORDER: ::UINT = 0x0006; pub const SPI_GETKEYBOARDSPEED: ::UINT = 0x000A; pub const SPI_SETKEYBOARDSPEED: ::UINT = 0x000B; pub const SPI_LANGDRIVER: ::UINT = 0x000C; pub const SPI_ICONHORIZONTALSPACING: ::UINT = 0x000D; pub const SPI_GETSCREENSAVETIMEOUT: ::UINT = 0x000E; pub const SPI_SETSCREENSAVETIMEOUT: ::UINT = 0x000F; pub const SPI_GETSCREENSAVEACTIVE: ::UINT = 0x0010; pub const SPI_SETSCREENSAVEACTIVE: ::UINT = 0x0011; pub const SPI_GETGRIDGRANULARITY: ::UINT = 0x0012; pub const SPI_SETGRIDGRANULARITY: ::UINT = 0x0013; pub const SPI_SETDESKWALLPAPER: ::UINT = 0x0014; pub const SPI_SETDESKPATTERN: ::UINT = 0x0015; pub const SPI_GETKEYBOARDDELAY: ::UINT = 0x0016; pub const SPI_SETKEYBOARDDELAY: ::UINT = 0x0017; pub const SPI_ICONVERTICALSPACING: ::UINT = 0x0018; pub const SPI_GETICONTITLEWRAP: ::UINT = 0x0019; pub const SPI_SETICONTITLEWRAP: ::UINT = 0x001A; pub const SPI_GETMENUDROPALIGNMENT: ::UINT = 0x001B; pub const SPI_SETMENUDROPALIGNMENT: ::UINT = 0x001C; pub const SPI_SETDOUBLECLKWIDTH: ::UINT = 0x001D; pub const SPI_SETDOUBLECLKHEIGHT: ::UINT = 0x001E; pub const SPI_GETICONTITLELOGFONT: ::UINT = 0x001F; pub const SPI_SETDOUBLECLICKTIME: ::UINT = 0x0020; pub const SPI_SETMOUSEBUTTONSWAP: ::UINT = 0x0021; pub const SPI_SETICONTITLELOGFONT: ::UINT = 0x0022; pub const SPI_GETFASTTASKSWITCH: ::UINT = 0x0023; pub const SPI_SETFASTTASKSWITCH: ::UINT = 0x0024; pub const SPI_SETDRAGFULLWINDOWS: ::UINT = 0x0025; pub const SPI_GETDRAGFULLWINDOWS: ::UINT = 0x0026; pub const SPI_GETNONCLIENTMETRICS: ::UINT = 0x0029; pub const SPI_SETNONCLIENTMETRICS: ::UINT = 0x002A; pub const SPI_GETMINIMIZEDMETRICS: ::UINT = 0x002B; pub const SPI_SETMINIMIZEDMETRICS: ::UINT = 0x002C; pub const SPI_GETICONMETRICS: ::UINT = 0x002D; pub const SPI_SETICONMETRICS: ::UINT = 0x002E; pub const SPI_SETWORKAREA: ::UINT = 0x002F; pub const SPI_GETWORKAREA: ::UINT = 0x0030; pub const SPI_SETPENWINDOWS: ::UINT = 0x0031; pub const SPI_GETHIGHCONTRAST: ::UINT = 0x0042; pub const SPI_SETHIGHCONTRAST: ::UINT = 0x0043; pub const SPI_GETKEYBOARDPREF: ::UINT = 0x0044; pub const SPI_SETKEYBOARDPREF: ::UINT = 0x0045; pub const SPI_GETSCREENREADER: ::UINT = 0x0046; pub const SPI_SETSCREENREADER: ::UINT = 0x0047; pub const SPI_GETANIMATION: ::UINT = 0x0048; pub const SPI_SETANIMATION: ::UINT = 0x0049; pub const SPI_GETFONTSMOOTHING: ::UINT = 0x004A; pub const SPI_SETFONTSMOOTHING: ::UINT = 0x004B; pub const SPI_SETDRAGWIDTH: ::UINT = 0x004C; pub const SPI_SETDRAGHEIGHT: ::UINT = 0x004D; pub const SPI_SETHANDHELD: ::UINT = 0x004E; pub const SPI_GETLOWPOWERTIMEOUT: ::UINT = 0x004F; pub const SPI_GETPOWEROFFTIMEOUT: ::UINT = 0x0050; pub const SPI_SETLOWPOWERTIMEOUT: ::UINT = 0x0051; pub const SPI_SETPOWEROFFTIMEOUT: ::UINT = 0x0052; pub const SPI_GETLOWPOWERACTIVE: ::UINT = 0x0053; pub const SPI_GETPOWEROFFACTIVE: ::UINT = 0x0054; pub const SPI_SETLOWPOWERACTIVE: ::UINT = 0x0055; pub const SPI_SETPOWEROFFACTIVE: ::UINT = 0x0056; pub const SPI_SETCURSORS: ::UINT = 0x0057; pub const SPI_SETICONS: ::UINT = 0x0058; pub const SPI_GETDEFAULTINPUTLANG: ::UINT = 0x0059; pub const SPI_SETDEFAULTINPUTLANG: ::UINT = 0x005A; pub const SPI_SETLANGTOGGLE: ::UINT = 0x005B; pub const SPI_GETWINDOWSEXTENSION: ::UINT = 0x005C; pub const SPI_SETMOUSETRAILS: ::UINT = 0x005D; pub const SPI_GETMOUSETRAILS: ::UINT = 0x005E; pub const SPI_SETSCREENSAVERRUNNING: ::UINT = 0x0061; pub const SPI_SCREENSAVERRUNNING: ::UINT = SPI_SETSCREENSAVERRUNNING; pub const SPI_GETFILTERKEYS: ::UINT = 0x0032; pub const SPI_SETFILTERKEYS: ::UINT = 0x0033; pub const SPI_GETTOGGLEKEYS: ::UINT = 0x0034; pub const SPI_SETTOGGLEKEYS: ::UINT = 0x0035; pub const SPI_GETMOUSEKEYS: ::UINT = 0x0036; pub const SPI_SETMOUSEKEYS: ::UINT = 0x0037; pub const SPI_GETSHOWSOUNDS: ::UINT = 0x0038; pub const SPI_SETSHOWSOUNDS: ::UINT = 0x0039; pub const SPI_GETSTICKYKEYS: ::UINT = 0x003A; pub const SPI_SETSTICKYKEYS: ::UINT = 0x003B; pub const SPI_GETACCESSTIMEOUT: ::UINT = 0x003C; pub const SPI_SETACCESSTIMEOUT: ::UINT = 0x003D; pub const SPI_GETSERIALKEYS: ::UINT = 0x003E; pub const SPI_SETSERIALKEYS: ::UINT = 0x003F; pub const SPI_GETSOUNDSENTRY: ::UINT = 0x0040; pub const SPI_SETSOUNDSENTRY: ::UINT = 0x0041; pub const SPI_GETSNAPTODEFBUTTON: ::UINT = 0x005F; pub const SPI_SETSNAPTODEFBUTTON: ::UINT = 0x0060; pub const SPI_GETMOUSEHOVERWIDTH: ::UINT = 0x0062; pub const SPI_SETMOUSEHOVERWIDTH: ::UINT = 0x0063; pub const SPI_GETMOUSEHOVERHEIGHT: ::UINT = 0x0064; pub const SPI_SETMOUSEHOVERHEIGHT: ::UINT = 0x0065; pub const SPI_GETMOUSEHOVERTIME: ::UINT = 0x0066; pub const SPI_SETMOUSEHOVERTIME: ::UINT = 0x0067; pub const SPI_GETWHEELSCROLLLINES: ::UINT = 0x0068; pub const SPI_SETWHEELSCROLLLINES: ::UINT = 0x0069; pub const SPI_GETMENUSHOWDELAY: ::UINT = 0x006A; pub const SPI_SETMENUSHOWDELAY: ::UINT = 0x006B; pub const SPI_GETWHEELSCROLLCHARS: ::UINT = 0x006C; pub const SPI_SETWHEELSCROLLCHARS: ::UINT = 0x006D; pub const SPI_GETSHOWIMEUI: ::UINT = 0x006E; pub const SPI_SETSHOWIMEUI: ::UINT = 0x006F; pub const SPI_GETMOUSESPEED: ::UINT = 0x0070; pub const SPI_SETMOUSESPEED: ::UINT = 0x0071; pub const SPI_GETSCREENSAVERRUNNING: ::UINT = 0x0072; pub const SPI_GETDESKWALLPAPER: ::UINT = 0x0073; pub const SPI_GETAUDIODESCRIPTION: ::UINT = 0x0074; pub const SPI_SETAUDIODESCRIPTION: ::UINT = 0x0075; pub const SPI_GETSCREENSAVESECURE: ::UINT = 0x0076; pub const SPI_SETSCREENSAVESECURE: ::UINT = 0x0077; pub const SPI_GETHUNGAPPTIMEOUT: ::UINT = 0x0078; pub const SPI_SETHUNGAPPTIMEOUT: ::UINT = 0x0079; pub const SPI_GETWAITTOKILLTIMEOUT: ::UINT = 0x007A; pub const SPI_SETWAITTOKILLTIMEOUT: ::UINT = 0x007B; pub const SPI_GETWAITTOKILLSERVICETIMEOUT: ::UINT = 0x007C; pub const SPI_SETWAITTOKILLSERVICETIMEOUT: ::UINT = 0x007D; pub const SPI_GETMOUSEDOCKTHRESHOLD: ::UINT = 0x007E; pub const SPI_SETMOUSEDOCKTHRESHOLD: ::UINT = 0x007F; pub const SPI_GETPENDOCKTHRESHOLD: ::UINT = 0x0080; pub const SPI_SETPENDOCKTHRESHOLD: ::UINT = 0x0081; pub const SPI_GETWINARRANGING: ::UINT = 0x0082; pub const SPI_SETWINARRANGING: ::UINT = 0x0083; pub const SPI_GETMOUSEDRAGOUTTHRESHOLD: ::UINT = 0x0084; pub const SPI_SETMOUSEDRAGOUTTHRESHOLD: ::UINT = 0x0085; pub const SPI_GETPENDRAGOUTTHRESHOLD: ::UINT = 0x0086; pub const SPI_SETPENDRAGOUTTHRESHOLD: ::UINT = 0x0087; pub const SPI_GETMOUSESIDEMOVETHRESHOLD: ::UINT = 0x0088; pub const SPI_SETMOUSESIDEMOVETHRESHOLD: ::UINT = 0x0089; pub const SPI_GETPENSIDEMOVETHRESHOLD: ::UINT = 0x008A; pub const SPI_SETPENSIDEMOVETHRESHOLD: ::UINT = 0x008B; pub const SPI_GETDRAGFROMMAXIMIZE: ::UINT = 0x008C; pub const SPI_SETDRAGFROMMAXIMIZE: ::UINT = 0x008D; pub const SPI_GETSNAPSIZING: ::UINT = 0x008E; pub const SPI_SETSNAPSIZING: ::UINT = 0x008F; pub const SPI_GETDOCKMOVING: ::UINT = 0x0090; pub const SPI_SETDOCKMOVING: ::UINT = 0x0091; pub const SPI_GETACTIVEWINDOWTRACKING: ::UINT = 0x1000; pub const SPI_SETACTIVEWINDOWTRACKING: ::UINT = 0x1001; pub const SPI_GETMENUANIMATION: ::UINT = 0x1002; pub const SPI_SETMENUANIMATION: ::UINT = 0x1003; pub const SPI_GETCOMBOBOXANIMATION: ::UINT = 0x1004; pub const SPI_SETCOMBOBOXANIMATION: ::UINT = 0x1005; pub const SPI_GETLISTBOXSMOOTHSCROLLING: ::UINT = 0x1006; pub const SPI_SETLISTBOXSMOOTHSCROLLING: ::UINT = 0x1007; pub const SPI_GETGRADIENTCAPTIONS: ::UINT = 0x1008; pub const SPI_SETGRADIENTCAPTIONS: ::UINT = 0x1009; pub const SPI_GETKEYBOARDCUES: ::UINT = 0x100A; pub const SPI_SETKEYBOARDCUES: ::UINT = 0x100B; pub const SPI_GETMENUUNDERLINES: ::UINT = SPI_GETKEYBOARDCUES; pub const SPI_SETMENUUNDERLINES: ::UINT = SPI_SETKEYBOARDCUES; pub const SPI_GETACTIVEWNDTRKZORDER: ::UINT = 0x100C; pub const SPI_SETACTIVEWNDTRKZORDER: ::UINT = 0x100D; pub const SPI_GETHOTTRACKING: ::UINT = 0x100E; pub const SPI_SETHOTTRACKING: ::UINT = 0x100F; pub const SPI_GETMENUFADE: ::UINT = 0x1012; pub const SPI_SETMENUFADE: ::UINT = 0x1013; pub const SPI_GETSELECTIONFADE: ::UINT = 0x1014; pub const SPI_SETSELECTIONFADE: ::UINT = 0x1015; pub const SPI_GETTOOLTIPANIMATION: ::UINT = 0x1016; pub const SPI_SETTOOLTIPANIMATION: ::UINT = 0x1017; pub const SPI_GETTOOLTIPFADE: ::UINT = 0x1018; pub const SPI_SETTOOLTIPFADE: ::UINT = 0x1019; pub const SPI_GETCURSORSHADOW: ::UINT = 0x101A; pub const SPI_SETCURSORSHADOW: ::UINT = 0x101B; pub const SPI_GETMOUSESONAR: ::UINT = 0x101C; pub const SPI_SETMOUSESONAR: ::UINT = 0x101D; pub const SPI_GETMOUSECLICKLOCK: ::UINT = 0x101E; pub const SPI_SETMOUSECLICKLOCK: ::UINT = 0x101F; pub const SPI_GETMOUSEVANISH: ::UINT = 0x1020; pub const SPI_SETMOUSEVANISH: ::UINT = 0x1021; pub const SPI_GETFLATMENU: ::UINT = 0x1022; pub const SPI_SETFLATMENU: ::UINT = 0x1023; pub const SPI_GETDROPSHADOW: ::UINT = 0x1024; pub const SPI_SETDROPSHADOW: ::UINT = 0x1025; pub const SPI_GETBLOCKSENDINPUTRESETS: ::UINT = 0x1026; pub const SPI_SETBLOCKSENDINPUTRESETS: ::UINT = 0x1027; pub const SPI_GETUIEFFECTS: ::UINT = 0x103E; pub const SPI_SETUIEFFECTS: ::UINT = 0x103F; pub const SPI_GETDISABLEOVERLAPPEDCONTENT: ::UINT = 0x1040; pub const SPI_SETDISABLEOVERLAPPEDCONTENT: ::UINT = 0x1041; pub const SPI_GETCLIENTAREAANIMATION: ::UINT = 0x1042; pub const SPI_SETCLIENTAREAANIMATION: ::UINT = 0x1043; pub const SPI_GETCLEARTYPE: ::UINT = 0x1048; pub const SPI_SETCLEARTYPE: ::UINT = 0x1049; pub const SPI_GETSPEECHRECOGNITION: ::UINT = 0x104A; pub const SPI_SETSPEECHRECOGNITION: ::UINT = 0x104B; pub const SPI_GETFOREGROUNDLOCKTIMEOUT: ::UINT = 0x2000; pub const SPI_SETFOREGROUNDLOCKTIMEOUT: ::UINT = 0x2001; pub const SPI_GETACTIVEWNDTRKTIMEOUT: ::UINT = 0x2002; pub const SPI_SETACTIVEWNDTRKTIMEOUT: ::UINT = 0x2003; pub const SPI_GETFOREGROUNDFLASHCOUNT: ::UINT = 0x2004; pub const SPI_SETFOREGROUNDFLASHCOUNT: ::UINT = 0x2005; pub const SPI_GETCARETWIDTH: ::UINT = 0x2006; pub const SPI_SETCARETWIDTH: ::UINT = 0x2007; pub const SPI_GETMOUSECLICKLOCKTIME: ::UINT = 0x2008; pub const SPI_SETMOUSECLICKLOCKTIME: ::UINT = 0x2009; pub const SPI_GETFONTSMOOTHINGTYPE: ::UINT = 0x200A; pub const SPI_SETFONTSMOOTHINGTYPE: ::UINT = 0x200B; pub const FE_FONTSMOOTHINGSTANDARD: ::UINT = 0x0001; pub const FE_FONTSMOOTHINGCLEARTYPE: ::UINT = 0x0002; pub const SPI_GETFONTSMOOTHINGCONTRAST: ::UINT = 0x200C; pub const SPI_SETFONTSMOOTHINGCONTRAST: ::UINT = 0x200D; pub const SPI_GETFOCUSBORDERWIDTH: ::UINT = 0x200E; pub const SPI_SETFOCUSBORDERWIDTH: ::UINT = 0x200F; pub const SPI_GETFOCUSBORDERHEIGHT: ::UINT = 0x2010; pub const SPI_SETFOCUSBORDERHEIGHT: ::UINT = 0x2011; pub const SPI_GETFONTSMOOTHINGORIENTATION: ::UINT = 0x2012; pub const SPI_SETFONTSMOOTHINGORIENTATION: ::UINT = 0x2013; pub const FE_FONTSMOOTHINGORIENTATIONBGR: ::UINT = 0x0000; pub const FE_FONTSMOOTHINGORIENTATIONRGB: ::UINT = 0x0001; pub const SPI_GETMINIMUMHITRADIUS: ::UINT = 0x2014; pub const SPI_SETMINIMUMHITRADIUS: ::UINT = 0x2015; pub const SPI_GETMESSAGEDURATION: ::UINT = 0x2016; pub const SPI_SETMESSAGEDURATION: ::UINT = 0x2017; //11264 pub const CB_GETEDITSEL: ::UINT = 0x0140; pub const CB_LIMITTEXT: ::UINT = 0x0141; pub const CB_SETEDITSEL: ::UINT = 0x0142; pub const CB_ADDSTRING: ::UINT = 0x0143; pub const CB_DELETESTRING: ::UINT = 0x0144; pub const CB_DIR: ::UINT = 0x0145; pub const CB_GETCOUNT: ::UINT = 0x0146; pub const CB_GETCURSEL: ::UINT = 0x0147; pub const CB_GETLBTEXT: ::UINT = 0x0148; pub const CB_GETLBTEXTLEN: ::UINT = 0x0149; pub const CB_INSERTSTRING: ::UINT = 0x014A; pub const CB_RESETCONTENT: ::UINT = 0x014B; pub const CB_FINDSTRING: ::UINT = 0x014C; pub const CB_SELECTSTRING: ::UINT = 0x014D; pub const CB_SETCURSEL: ::UINT = 0x014E; pub const CB_SHOWDROPDOWN: ::UINT = 0x014F; pub const CB_GETITEMDATA: ::UINT = 0x0150; pub const CB_SETITEMDATA: ::UINT = 0x0151; pub const CB_GETDROPPEDCONTROLRECT: ::UINT = 0x0152; pub const CB_SETITEMHEIGHT: ::UINT = 0x0153; pub const CB_GETITEMHEIGHT: ::UINT = 0x0154; pub const CB_SETEXTENDEDUI: ::UINT = 0x0155; pub const CB_GETEXTENDEDUI: ::UINT = 0x0156; pub const CB_GETDROPPEDSTATE: ::UINT = 0x0157; pub const CB_FINDSTRINGEXACT: ::UINT = 0x0158; pub const CB_SETLOCALE: ::UINT = 0x0159; pub const CB_GETLOCALE: ::UINT = 0x015A; pub const CB_GETTOPINDEX: ::UINT = 0x015b; pub const CB_SETTOPINDEX: ::UINT = 0x015c; pub const CB_GETHORIZONTALEXTENT: ::UINT = 0x015d; pub const CB_SETHORIZONTALEXTENT: ::UINT = 0x015e; pub const CB_GETDROPPEDWIDTH: ::UINT = 0x015f; pub const CB_SETDROPPEDWIDTH: ::UINT = 0x0160; pub const CB_INITSTORAGE: ::UINT = 0x0161; //12141 #[repr(C)] #[derive(Clone, Copy)] pub struct NONCLIENTMETRICSA { pub cbSize: ::UINT, pub iBorderWidth: ::c_int, pub iScrollWidth: ::c_int, pub iScrollHeight: ::c_int, pub iCaptionWidth: ::c_int, pub iCaptionHeight: ::c_int, pub lfCaptionFont: ::LOGFONTA, pub iSmCaptionWidth: ::c_int, pub iSmCaptionHeight: ::c_int, pub lfSmCaptionFont: ::LOGFONTA, pub iMenuWidth: ::c_int, pub iMenuHeight: ::c_int, pub lfMenuFont: ::LOGFONTA, pub lfStatusFont: ::LOGFONTA, pub lfMessageFont: ::LOGFONTA, pub iPaddedBorderWidth: ::c_int, } pub type LPNONCLIENTMETRICSA = *mut NONCLIENTMETRICSA; #[repr(C)] #[derive(Clone, Copy)] pub struct NONCLIENTMETRICSW { pub cbSize: ::UINT, pub iBorderWidth: ::c_int, pub iScrollWidth: ::c_int, pub iScrollHeight: ::c_int, pub iCaptionWidth: ::c_int, pub iCaptionHeight: ::c_int, pub lfCaptionFont: ::LOGFONTW, pub iSmCaptionWidth: ::c_int, pub iSmCaptionHeight: ::c_int, pub lfSmCaptionFont: ::LOGFONTW, pub iMenuWidth: ::c_int, pub iMenuHeight: ::c_int, pub lfMenuFont: ::LOGFONTW, pub lfStatusFont: ::LOGFONTW, pub lfMessageFont: ::LOGFONTW, pub iPaddedBorderWidth: ::c_int, } pub type LPNONCLIENTMETRICSW = *mut NONCLIENTMETRICSW; //12900 pub const MONITORINFOF_PRIMARY: ::DWORD = 1; pub const CCHDEVICENAME: usize = 32; STRUCT!{struct MONITORINFO { cbSize: ::DWORD, rcMonitor: ::RECT, rcWork: ::RECT, dwFlags: ::DWORD, }} pub type LPMONITORINFO = *mut MONITORINFO; STRUCT!{struct MONITORINFOEXA { cbSize: ::DWORD, rcMonitor: ::RECT, rcWork: ::RECT, dwFlags: ::DWORD, szDevice: [::CHAR; ::CCHDEVICENAME], }} pub type LPMONITORINFOEXA = *mut MONITORINFOEXA; STRUCT!{struct MONITORINFOEXW { cbSize: ::DWORD, rcMonitor: ::RECT, rcWork: ::RECT, dwFlags: ::DWORD, szDevice: [::WCHAR; ::CCHDEVICENAME], }} pub type LPMONITORINFOEXW = *mut MONITORINFOEXW; //12971 pub type MONITORENUMPROC = Option ::BOOL>; //14098 DECLARE_HANDLE!(HRAWINPUT, HRAWINPUT__); pub fn GET_RAWINPUT_CODE_WPARAM(wParam: ::WPARAM) -> ::WPARAM { wParam & 0xff } pub const RIM_INPUT: ::WPARAM = 0; pub const RIM_INPUTSINK: ::WPARAM = 1; STRUCT!{struct RAWINPUTHEADER { dwType: ::DWORD, dwSize: ::DWORD, hDevice: ::HANDLE, wParam: ::WPARAM, }} pub type PRAWINPUTHEADER = *mut RAWINPUTHEADER; pub type LPRAWINPUTHEADER = *mut RAWINPUTHEADER; pub const RIM_TYPEMOUSE: ::DWORD = 0; pub const RIM_TYPEKEYBOARD: ::DWORD = 1; pub const RIM_TYPEHID: ::DWORD = 2; STRUCT!{struct RAWMOUSE { usFlags: ::USHORT, memory_padding: ::USHORT, // 16bit Padding for 32bit align in following union usButtonFlags: ::USHORT, usButtonData: ::USHORT, ulRawButtons: ::ULONG, lLastX: ::LONG, lLastY: ::LONG, ulExtraInformation: ::ULONG, }} pub type PRAWMOUSE = *mut RAWMOUSE; pub type LPRAWMOUSE = *mut RAWMOUSE; pub const RI_MOUSE_LEFT_BUTTON_DOWN: ::USHORT = 0x0001; pub const RI_MOUSE_LEFT_BUTTON_UP: ::USHORT = 0x0002; pub const RI_MOUSE_RIGHT_BUTTON_DOWN: ::USHORT = 0x0004; pub const RI_MOUSE_RIGHT_BUTTON_UP: ::USHORT = 0x0008; pub const RI_MOUSE_MIDDLE_BUTTON_DOWN: ::USHORT = 0x0010; pub const RI_MOUSE_MIDDLE_BUTTON_UP: ::USHORT = 0x0020; pub const RI_MOUSE_BUTTON_1_DOWN: ::USHORT = RI_MOUSE_LEFT_BUTTON_DOWN; pub const RI_MOUSE_BUTTON_1_UP: ::USHORT = RI_MOUSE_LEFT_BUTTON_UP; pub const RI_MOUSE_BUTTON_2_DOWN: ::USHORT = RI_MOUSE_RIGHT_BUTTON_DOWN; pub const RI_MOUSE_BUTTON_2_UP: ::USHORT = RI_MOUSE_RIGHT_BUTTON_UP; pub const RI_MOUSE_BUTTON_3_DOWN: ::USHORT = RI_MOUSE_MIDDLE_BUTTON_DOWN; pub const RI_MOUSE_BUTTON_3_UP: ::USHORT = RI_MOUSE_MIDDLE_BUTTON_UP; pub const RI_MOUSE_BUTTON_4_DOWN: ::USHORT = 0x0040; pub const RI_MOUSE_BUTTON_4_UP: ::USHORT = 0x0080; pub const RI_MOUSE_BUTTON_5_DOWN: ::USHORT = 0x0100; pub const RI_MOUSE_BUTTON_5_UP: ::USHORT = 0x0200; pub const RI_MOUSE_WHEEL: ::USHORT = 0x0400; pub const MOUSE_MOVE_RELATIVE: ::USHORT = 0; pub const MOUSE_MOVE_ABSOLUTE: ::USHORT = 1; pub const MOUSE_VIRTUAL_DESKTOP: ::USHORT = 0x02; pub const MOUSE_ATTRIBUTES_CHANGED: ::USHORT = 0x04; pub const MOUSE_MOVE_NOCOALESCE: ::USHORT = 0x08; STRUCT!{struct RAWKEYBOARD { MakeCode: ::USHORT, Flags: ::USHORT, Reserved: ::USHORT, VKey: ::USHORT, Message: ::UINT, ExtraInformation: ::ULONG, }} pub type PRAWKEYBOARD = *mut RAWKEYBOARD; pub type LPRAWKEYBOARD = *mut RAWKEYBOARD; pub const KEYBOARD_OVERRUN_MAKE_CODE: ::DWORD = 0xFF; pub const RI_KEY_MAKE: ::DWORD = 0; pub const RI_KEY_BREAK: ::DWORD = 1; pub const RI_KEY_E0: ::DWORD = 2; pub const RI_KEY_E1: ::DWORD = 4; pub const RI_KEY_TERMSRV_SET_LED: ::DWORD = 8; pub const RI_KEY_TERMSRV_SHADOW: ::DWORD = 0x10; #[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct RAWHID { pub dwSizeHid: ::DWORD, pub dwCount: ::DWORD, pub bRawData: [::BYTE; 0], } pub type PRAWHID = *mut RAWHID; pub type LPRAWHID = *mut RAWHID; STRUCT!{struct RAWINPUT { header: RAWINPUTHEADER, mouse: RAWMOUSE, }} UNION!(RAWINPUT, mouse, mouse, mouse_mut, RAWMOUSE); UNION!(RAWINPUT, mouse, keyboard, keyboard_mut, RAWKEYBOARD); UNION!(RAWINPUT, mouse, hid, hid_mut, RAWHID); #[test] fn test_RAWINPUT() { use std::mem::{size_of, align_of}; assert!(size_of::() >= size_of::()); assert!(size_of::() >= size_of::()); assert!(size_of::() >= size_of::()); assert!(align_of::() >= align_of::()); assert!(align_of::() >= align_of::()); assert!(align_of::() >= align_of::()); } pub type PRAWINPUT = *mut RAWINPUT; pub type LPRAWINPUT = *mut RAWINPUT; pub const RID_INPUT: ::DWORD = 0x10000003; pub const RID_HEADER: ::DWORD = 0x10000005; pub const RIDI_PREPARSEDDATA: ::DWORD = 0x20000005; pub const RIDI_DEVICENAME: ::DWORD = 0x20000007; pub const RIDI_DEVICEINFO: ::DWORD = 0x2000000b; STRUCT!{struct RID_DEVICE_INFO_MOUSE { dwId: ::DWORD, dwNumberOfButtons: ::DWORD, dwSampleRate: ::DWORD, fHasHorizontalWheel: ::BOOL, }} pub type PRID_DEVICE_INFO_MOUSE = *mut RID_DEVICE_INFO_MOUSE; STRUCT!{struct RID_DEVICE_INFO_KEYBOARD { dwType: ::DWORD, dwSubType: ::DWORD, dwKeyboardMode: ::DWORD, dwNumberOfFunctionKeys: ::DWORD, dwNumberOfIndicators: ::DWORD, dwNumberOfKeysTotal: ::DWORD, }} pub type PRID_DEVICE_INFO_KEYBOARD = *mut RID_DEVICE_INFO_KEYBOARD; STRUCT!{struct RID_DEVICE_INFO_HID { dwVendorId: ::DWORD, dwProductId: ::DWORD, dwVersionNumber: ::DWORD, usUsagePage: ::USHORT, usUsage: ::USHORT, }} pub type PRID_DEVICE_INFO_HID = *mut RID_DEVICE_INFO_HID; STRUCT!{struct RID_DEVICE_INFO { cbSize: ::DWORD, dwType: ::DWORD, keyboard: RID_DEVICE_INFO_KEYBOARD, }} UNION!(RID_DEVICE_INFO, keyboard, mouse, mouse_mut, RID_DEVICE_INFO_MOUSE); UNION!(RID_DEVICE_INFO, keyboard, keyboard, keyboard_mut, RID_DEVICE_INFO_KEYBOARD); UNION!(RID_DEVICE_INFO, keyboard, hid, hid_mut, RID_DEVICE_INFO_HID); #[test] fn test_RID_DEVICE_INFO() { use std::mem::{size_of, align_of}; assert!(size_of::() >= size_of::()); assert!(size_of::() >= size_of::()); assert!(size_of::() >= size_of::()); assert!(align_of::() >= align_of::()); assert!(align_of::() >= align_of::()); assert!(align_of::() >= align_of::()); } pub type PRID_DEVICE_INFO = *mut RID_DEVICE_INFO; pub type LPRID_DEVICE_INFO = *mut RID_DEVICE_INFO; STRUCT!{struct RAWINPUTDEVICE { usUsagePage: ::USHORT, usUsage: ::USHORT, dwFlags: ::DWORD, hwndTarget: ::HWND, }} pub type PRAWINPUTDEVICE = *mut RAWINPUTDEVICE; pub type LPRAWINPUTDEVICE = *mut RAWINPUTDEVICE; pub type PCRAWINPUTDEVICE = *const RAWINPUTDEVICE; pub const RIDEV_REMOVE: ::DWORD = 0x00000001; pub const RIDEV_EXCLUDE: ::DWORD = 0x00000010; pub const RIDEV_PAGEONLY: ::DWORD = 0x00000020; pub const RIDEV_NOLEGACY: ::DWORD = 0x00000030; pub const RIDEV_INPUTSINK: ::DWORD = 0x00000100; pub const RIDEV_CAPTUREMOUSE: ::DWORD = 0x00000200; pub const RIDEV_NOHOTKEYS: ::DWORD = 0x00000200; pub const RIDEV_APPKEYS: ::DWORD = 0x00000400; pub const RIDEV_EXINPUTSINK: ::DWORD = 0x00001000; pub const RIDEV_DEVNOTIFY: ::DWORD = 0x00002000; pub const RIDEV_EXMODEMASK: ::DWORD = 0x000000F0; pub const GIDC_ARRIVAL: ::DWORD = 1; pub const GIDC_REMOVAL: ::DWORD = 2; STRUCT!{struct RAWINPUTDEVICELIST { hDevice: ::HANDLE, dwType: ::DWORD, }} pub type PRAWINPUTDEVICELIST = *mut RAWINPUTDEVICELIST; STRUCT!{struct CHANGEFILTERSTRUCT { cbSize: ::DWORD, ExtStatus: ::DWORD, }} pub type PCHANGEFILTERSTRUCT = *mut CHANGEFILTERSTRUCT; STRUCT!{struct DLGTEMPLATE { style: ::DWORD, dwExtendedStyle: ::DWORD, cdit: ::WORD, x: ::c_short, y: ::c_short, cx: ::c_short, cy: ::c_short, }} pub type LPDLGTEMPLATEA = *mut DLGTEMPLATE; pub type LPDLGTEMPLATEW = *mut DLGTEMPLATE; pub type LPCDLGTEMPLATEA = *const DLGTEMPLATE; pub type LPCDLGTEMPLATEW = *const DLGTEMPLATE; STRUCT!{struct DRAWTEXTPARAMS { cbSize: ::UINT, iTabLength: ::c_int, iLeftMargin: ::c_int, iRightMargin: ::c_int, uiLengthDrawn: ::UINT, }} pub type LPDRAWTEXTPARAMS = *mut DRAWTEXTPARAMS; STRUCT!{struct ACCEL { fVirt: ::BYTE, key: ::WORD, cmd: ::WORD, }} pub type LPACCEL = *mut ACCEL; STRUCT!{struct MENUITEMINFOA { cbSize: ::UINT, fMask: ::UINT, fType: ::UINT, fState: ::UINT, wID: ::UINT, hSubMenu: ::HMENU, hbmpChecked: ::HBITMAP, hbmpUnchecked: ::HBITMAP, dwItemData: ::ULONG_PTR, dwTypeData: ::LPSTR, cch: ::UINT, hbmpItem: ::HBITMAP, }} pub type LPMENUITEMINFOA = *mut MENUITEMINFOA; pub type LPCMENUITEMINFOA = *const MENUITEMINFOA; STRUCT!{struct MENUITEMINFOW { cbSize: ::UINT, fMask: ::UINT, fType: ::UINT, fState: ::UINT, wID: ::UINT, hSubMenu: ::HMENU, hbmpChecked: ::HBITMAP, hbmpUnchecked: ::HBITMAP, dwItemData: ::ULONG_PTR, dwTypeData: ::LPWSTR, cch: ::UINT, hbmpItem: ::HBITMAP, }} pub type LPMENUITEMINFOW = *mut MENUITEMINFOW; pub type LPCMENUITEMINFOW = *const MENUITEMINFOW; #[repr(C)] #[derive(Copy)] pub struct MSGBOXPARAMSA { pub cbSize: ::UINT, pub hwndOwner: ::HWND, pub hInstance: ::HINSTANCE, pub lpszText: ::LPCSTR, pub lpszCaption: ::LPCSTR, pub dwStyle: ::DWORD, pub lpszIcon: ::LPCSTR, pub dwContextHelpId: ::DWORD_PTR, pub lpfnMsgBoxCallback: ::MSGBOXCALLBACK, pub dwLanguageId: ::DWORD, } impl Clone for MSGBOXPARAMSA { fn clone(&self) -> MSGBOXPARAMSA { *self } } pub type PMSGBOXPARAMSA = *mut MSGBOXPARAMSA; pub type LPMSGBOXPARAMSA = *mut MSGBOXPARAMSA; #[repr(C)] #[derive(Copy)] pub struct MSGBOXPARAMSW { pub cbSize: ::UINT, pub hwndOwner: ::HWND, pub hInstance: ::HINSTANCE, pub lpszText: ::LPCWSTR, pub lpszCaption: ::LPCWSTR, pub dwStyle: ::DWORD, pub lpszIcon: ::LPCWSTR, pub dwContextHelpId: ::DWORD_PTR, pub lpfnMsgBoxCallback: ::MSGBOXCALLBACK, pub dwLanguageId: ::DWORD, } impl Clone for MSGBOXPARAMSW { fn clone(&self) -> MSGBOXPARAMSW { *self } } pub type PMSGBOXPARAMSW = *mut MSGBOXPARAMSW; pub type LPMSGBOXPARAMSW = *mut MSGBOXPARAMSW; STRUCT!{struct HELPINFO { cbSize: ::UINT, iContextType: ::c_int, iCtrlId: ::c_int, hItemHandle: ::HANDLE, dwContextId: ::DWORD, MousePos: ::POINT, }} pub type LPHELPINFO = *mut HELPINFO; pub fn GET_WHEEL_DELTA_WPARAM(wParam: ::WPARAM) -> ::c_short { ::HIWORD(wParam as ::DWORD) as ::c_short } pub fn GET_KEYSTATE_WPARAM(wparam: ::WPARAM) -> ::c_int { ::LOWORD(wparam as ::DWORD) as ::c_short as ::c_int } pub const SIF_RANGE: ::UINT = 0x0001; pub const SIF_PAGE: ::UINT = 0x0002; pub const SIF_POS: ::UINT = 0x0004; pub const SIF_DISABLENOSCROLL: ::UINT = 0x0008; pub const SIF_TRACKPOS: ::UINT = 0x0010; pub const SIF_ALL: ::UINT = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS; pub const SW_SCROLLCHILDREN: ::UINT = 0x0001; pub const SW_INVALIDATE: ::UINT = 0x0002; pub const SW_ERASE: ::UINT = 0x0004; pub const SW_SMOOTHSCROLL: ::UINT = 0x0010; pub const SB_LINEUP: ::c_int = 0; pub const SB_LINELEFT: ::c_int = 0; pub const SB_LINEDOWN: ::c_int = 1; pub const SB_LINERIGHT: ::c_int = 1; pub const SB_PAGEUP: ::c_int = 2; pub const SB_PAGELEFT: ::c_int = 2; pub const SB_PAGEDOWN: ::c_int = 3; pub const SB_PAGERIGHT: ::c_int = 3; pub const SB_THUMBPOSITION: ::c_int = 4; pub const SB_THUMBTRACK: ::c_int = 5; pub const SB_TOP: ::c_int = 6; pub const SB_LEFT: ::c_int = 6; pub const SB_BOTTOM: ::c_int = 7; pub const SB_RIGHT: ::c_int = 7; pub const SB_ENDSCROLL: ::c_int = 8; pub const LR_DEFAULTCOLOR: ::UINT = 0x00000000; pub const LR_MONOCHROME: ::UINT = 0x00000001; pub const LR_COLOR: ::UINT = 0x00000002; pub const LR_COPYRETURNORG: ::UINT = 0x00000004; pub const LR_COPYDELETEORG: ::UINT = 0x00000008; pub const LR_LOADFROMFILE: ::UINT = 0x00000010; pub const LR_LOADTRANSPARENT: ::UINT = 0x00000020; pub const LR_DEFAULTSIZE: ::UINT = 0x00000040; pub const LR_VGACOLOR: ::UINT = 0x00000080; pub const LR_LOADMAP3DCOLORS: ::UINT = 0x00001000; pub const LR_CREATEDIBSECTION: ::UINT = 0x00002000; pub const LR_COPYFROMRESOURCE: ::UINT = 0x00004000; pub const LR_SHARED: ::UINT = 0x00008000; pub const IMAGE_BITMAP: ::UINT = 0; pub const IMAGE_ICON: ::UINT = 1; pub const IMAGE_CURSOR: ::UINT = 2; pub const IMAGE_ENHMETAFILE: ::UINT = 3; pub const DT_TOP: ::UINT = 0x00000000; pub const DT_LEFT: ::UINT = 0x00000000; pub const DT_CENTER: ::UINT = 0x00000001; pub const DT_RIGHT: ::UINT = 0x00000002; pub const DT_VCENTER: ::UINT = 0x00000004; pub const DT_BOTTOM: ::UINT = 0x00000008; pub const DT_WORDBREAK: ::UINT = 0x00000010; pub const DT_SINGLELINE: ::UINT = 0x00000020; pub const DT_EXPANDTABS: ::UINT = 0x00000040; pub const DT_TABSTOP: ::UINT = 0x00000080; pub const DT_NOCLIP: ::UINT = 0x00000100; pub const DT_EXTERNALLEADING: ::UINT = 0x00000200; pub const DT_CALCRECT: ::UINT = 0x00000400; pub const DT_NOPREFIX: ::UINT = 0x00000800; pub const DT_INTERNAL: ::UINT = 0x00001000; pub const DT_EDITCONTROL: ::UINT = 0x00002000; pub const DT_PATH_ELLIPSIS: ::UINT = 0x00004000; pub const DT_END_ELLIPSIS: ::UINT = 0x00008000; pub const DT_MODIFYSTRING: ::UINT = 0x00010000; pub const DT_RTLREADING: ::UINT = 0x00020000; pub const DT_WORD_ELLIPSIS: ::UINT = 0x00040000; pub const DT_NOFULLWIDTHCHARBREAK: ::UINT = 0x00080000; pub const DT_HIDEPREFIX: ::UINT = 0x00100000; pub const DT_PREFIXONLY: ::UINT = 0x00200000; STRUCT!{struct KBDLLHOOKSTRUCT { vkCode: ::DWORD, scanCode: ::DWORD, flags: ::DWORD, time: ::DWORD, dwExtraInfo: ::ULONG_PTR, }} pub type PKBDLLHOOKSTRUCT = *mut KBDLLHOOKSTRUCT; pub type LPKBDLLHOOKSTRUCT = *mut KBDLLHOOKSTRUCT; STRUCT!{struct MSLLHOOKSTRUCT { pt: ::POINT, mouseData: ::DWORD, flags: ::DWORD, time: ::DWORD, dwExtraInfo: ::ULONG_PTR, }} pub type PMSLLHOOKSTRUCT = *mut MSLLHOOKSTRUCT; pub type LPMSLLHOOKSTRUCT = *mut MSLLHOOKSTRUCT; pub const WH_MIN: ::c_int = -1; pub const WH_MSGFILTER: ::c_int = -1; pub const WH_JOURNALRECORD: ::c_int = 0; pub const WH_JOURNALPLAYBACK: ::c_int = 1; pub const WH_KEYBOARD: ::c_int = 2; pub const WH_GETMESSAGE: ::c_int = 3; pub const WH_CALLWNDPROC: ::c_int = 4; pub const WH_CBT: ::c_int = 5; pub const WH_SYSMSGFILTER: ::c_int = 6; pub const WH_MOUSE: ::c_int = 7; pub const WH_HARDWARE: ::c_int = 8; pub const WH_DEBUG: ::c_int = 9; pub const WH_SHELL: ::c_int = 10; pub const WH_FOREGROUNDIDLE: ::c_int = 11; pub const WH_CALLWNDPROCRET: ::c_int = 12; pub const WH_KEYBOARD_LL: ::c_int = 13; pub const WH_MOUSE_LL: ::c_int = 14; pub const WH_MAX: ::c_int = 14; pub const WH_MINHOOK: ::c_int = WH_MIN; pub const WH_MAXHOOK: ::c_int = WH_MAX; pub const KLF_ACTIVATE: ::UINT = 1; pub const KLF_SUBSTITUTE_OK: ::UINT = 2; pub const KLF_UNLOADPREVIOUS: ::UINT = 4; pub const KLF_REORDER: ::UINT = 8; pub const KLF_REPLACELANG: ::UINT = 16; pub const KLF_NOTELLSHELL: ::UINT = 128; pub const KLF_SETFORPROCESS: ::UINT = 256; //RedrawWindow() flags pub const RDW_INVALIDATE: ::UINT = 0x0001; pub const RDW_INTERNALPAINT: ::UINT = 0x0002; pub const RDW_ERASE: ::UINT = 0x0004; pub const RDW_VALIDATE: ::UINT = 0x0008; pub const RDW_NOINTERNALPAINT: ::UINT = 0x0010; pub const RDW_NOERASE: ::UINT = 0x0020; pub const RDW_NOCHILDREN: ::UINT = 0x0040; pub const RDW_ALLCHILDREN: ::UINT = 0x0080; pub const RDW_UPDATENOW: ::UINT = 0x0100; pub const RDW_ERASENOW: ::UINT = 0x0200; pub const RDW_FRAME: ::UINT = 0x0400; pub const RDW_NOFRAME: ::UINT = 0x0800; STRUCT!{struct MEASUREITEMSTRUCT { CtlType: ::UINT, CtlID: ::UINT, itemID: ::UINT, itemWidth: ::UINT, itemHeight: ::UINT, itemData: ::ULONG_PTR, }} pub type LPMEASUREITEMSTRUCT = *mut MEASUREITEMSTRUCT; STRUCT!{struct DRAWITEMSTRUCT { CtlType: ::UINT, CtlID: ::UINT, itemID: ::UINT, itemAction: ::UINT, itemState: ::UINT, hwndItem: ::HWND, hDC: ::HDC, rcItem: ::RECT, itemData: ::ULONG_PTR, }} pub type LPDRAWITEMSTRUCT = *mut DRAWITEMSTRUCT; STRUCT!{struct DELETEITEMSTRUCT { CtlType: ::UINT, CtlID: ::UINT, itemID: ::UINT, hwndItem: ::HWND, itemData: ::ULONG_PTR, }} pub type LPDELETEITEMSTRUCT = *mut DELETEITEMSTRUCT; STRUCT!{struct COMPAREITEMSTRUCT { CtlType: ::UINT, CtlID: ::UINT, hwndItem: ::HWND, itemID1: ::UINT, itemData1: ::ULONG_PTR, itemID2: ::UINT, itemData2: ::ULONG_PTR, dwLocaleId: ::DWORD, }} pub type LPCOMPAREITEMSTRUCT = *mut COMPAREITEMSTRUCT; /* Image type */ pub const DST_COMPLEX: ::UINT = 0x0000; pub const DST_TEXT: ::UINT = 0x0001; pub const DST_PREFIXTEXT: ::UINT = 0x0002; pub const DST_ICON: ::UINT = 0x0003; pub const DST_BITMAP: ::UINT = 0x0004; pub const DI_MASK: ::UINT = 0x0001; pub const DI_IMAGE: ::UINT = 0x0002; pub const DI_NORMAL: ::UINT = 0x0003; pub const DI_COMPAT: ::UINT = 0x0004; pub const DI_DEFAULTSIZE: ::UINT = 0x0008; deps/winapi-0.2.5/src/mmsystem.rs0000644000000000000000000002334312613167613015464 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! MM procedure declarations, constant definitions and macros //109 (Win 7 SDK) pub type MMVERSION = ::UINT; pub type MMRESULT = ::UINT; STRUCT!{struct MMTIME { wType: ::UINT, u: MMTIME_u, }} pub type PMMTIME = *mut MMTIME; pub type NPMMTIME = *mut MMTIME; pub type LPMMTIME = *mut MMTIME; STRUCT!{struct MMTIME_u { data: [u8; 8], }} UNION!(MMTIME_u, data, ms, ms_mut, ::DWORD); UNION!(MMTIME_u, data, sample, sample_mut, ::DWORD); UNION!(MMTIME_u, data, cb, cb_mut, ::DWORD); UNION!(MMTIME_u, data, ticks, ticks_mut, ::DWORD); UNION!(MMTIME_u, data, smpte, smpte_mut, MMTIME_smpte); UNION!(MMTIME_u, data, midi, midi_mut, MMTIME_midi); STRUCT!{struct MMTIME_smpte { hour: ::BYTE, min: ::BYTE, sec: ::BYTE, frame: ::BYTE, fps: ::BYTE, dummy: ::BYTE, pad: [::BYTE; 2], }} STRUCT!{struct MMTIME_midi { songptrpos: ::DWORD, }} pub const TIME_MS: ::UINT = 0x0001; pub const TIME_SAMPLES: ::UINT = 0x0002; pub const TIME_BYTES: ::UINT = 0x0004; pub const TIME_SMPTE: ::UINT = 0x0008; pub const TIME_MIDI: ::UINT = 0x0010; pub const TIME_TICKS: ::UINT = 0x0020; pub const MM_JOY1MOVE: ::UINT = 0x3A0; pub const MM_JOY2MOVE: ::UINT = 0x3A1; pub const MM_JOY1ZMOVE: ::UINT = 0x3A2; pub const MM_JOY2ZMOVE: ::UINT = 0x3A3; pub const MM_JOY1BUTTONDOWN: ::UINT = 0x3B5; pub const MM_JOY2BUTTONDOWN: ::UINT = 0x3B6; pub const MM_JOY1BUTTONUP: ::UINT = 0x3B7; pub const MM_JOY2BUTTONUP: ::UINT = 0x3B8; pub const MM_MCINOTIFY: ::UINT = 0x3B9; pub const MM_WOM_OPEN: ::UINT = 0x3BB; pub const MM_WOM_CLOSE: ::UINT = 0x3BC; pub const MM_WOM_DONE: ::UINT = 0x3BD; pub const MM_WIM_OPEN: ::UINT = 0x3BE; pub const MM_WIM_CLOSE: ::UINT = 0x3BF; pub const MM_WIM_DATA: ::UINT = 0x3C0; pub const MM_MIM_OPEN: ::UINT = 0x3C1; pub const MM_MIM_CLOSE: ::UINT = 0x3C2; pub const MM_MIM_DATA: ::UINT = 0x3C3; pub const MM_MIM_LONGDATA: ::UINT = 0x3C4; pub const MM_MIM_ERROR: ::UINT = 0x3C5; pub const MM_MIM_LONGERROR: ::UINT = 0x3C6; pub const MM_MOM_OPEN: ::UINT = 0x3C7; pub const MM_MOM_CLOSE: ::UINT = 0x3C8; pub const MM_MOM_DONE: ::UINT = 0x3C9; pub const MMSYSERR_BASE: MMRESULT = 0; pub const WAVERR_BASE: MMRESULT = 32; pub const MIDIERR_BASE: MMRESULT = 64; pub const TIMERR_BASE: MMRESULT = 96; pub const JOYERR_BASE: MMRESULT = 160; pub const MCIERR_BASE: MMRESULT = 256; pub const MIXERR_BASE: MMRESULT = 1024; pub const MMSYSERR_NOERROR: MMRESULT = 0; pub const MMSYSERR_ERROR: MMRESULT = MMSYSERR_BASE + 1; pub const MMSYSERR_BADDEVICEID: MMRESULT = MMSYSERR_BASE + 2; pub const MMSYSERR_NOTENABLED: MMRESULT = MMSYSERR_BASE + 3; pub const MMSYSERR_ALLOCATED: MMRESULT = MMSYSERR_BASE + 4; pub const MMSYSERR_INVALHANDLE: MMRESULT = MMSYSERR_BASE + 5; pub const MMSYSERR_NODRIVER: MMRESULT = MMSYSERR_BASE + 6; pub const MMSYSERR_NOMEM: MMRESULT = MMSYSERR_BASE + 7; pub const MMSYSERR_NOTSUPPORTED: MMRESULT = MMSYSERR_BASE + 8; pub const MMSYSERR_BADERRNUM: MMRESULT = MMSYSERR_BASE + 9; pub const MMSYSERR_INVALFLAG: MMRESULT = MMSYSERR_BASE + 10; pub const MMSYSERR_INVALPARAM: MMRESULT = MMSYSERR_BASE + 11; pub const MMSYSERR_HANDLEBUSY: MMRESULT = MMSYSERR_BASE + 12; pub const MMSYSERR_INVALIDALIAS: MMRESULT = MMSYSERR_BASE + 13; pub const MMSYSERR_BADDB: MMRESULT = MMSYSERR_BASE + 14; pub const MMSYSERR_KEYNOTFOUND: MMRESULT = MMSYSERR_BASE + 15; pub const MMSYSERR_READERROR: MMRESULT = MMSYSERR_BASE + 16; pub const MMSYSERR_WRITEERROR: MMRESULT = MMSYSERR_BASE + 17; pub const MMSYSERR_DELETEERROR: MMRESULT = MMSYSERR_BASE + 18; pub const MMSYSERR_VALNOTFOUND: MMRESULT = MMSYSERR_BASE + 19; pub const MMSYSERR_NODRIVERCB: MMRESULT = MMSYSERR_BASE + 20; pub const MMSYSERR_MOREDATA: MMRESULT = MMSYSERR_BASE + 21; pub const MMSYSERR_LASTERROR: MMRESULT = MMSYSERR_BASE + 21; pub const MIDIERR_UNPREPARED: MMRESULT = MIDIERR_BASE + 0; pub const MIDIERR_STILLPLAYING: MMRESULT = MIDIERR_BASE + 1; pub const MIDIERR_NOMAP: MMRESULT = MIDIERR_BASE + 2; pub const MIDIERR_NOTREADY: MMRESULT = MIDIERR_BASE + 3; pub const MIDIERR_NODEVICE: MMRESULT = MIDIERR_BASE + 4; pub const MIDIERR_INVALIDSETUP: MMRESULT = MIDIERR_BASE + 5; pub const MIDIERR_BADOPENMODE: MMRESULT = MIDIERR_BASE + 6; pub const MIDIERR_DONT_CONTINUE: MMRESULT = MIDIERR_BASE + 7; pub const MIDIERR_LASTERROR: MMRESULT = MIDIERR_BASE + 7; pub const CALLBACK_TYPEMASK: ::DWORD = 0x00070000; pub const CALLBACK_NULL: ::DWORD = 0x00000000; pub const CALLBACK_WINDOW: ::DWORD = 0x00010000; pub const CALLBACK_TASK: ::DWORD = 0x00020000; pub const CALLBACK_FUNCTION: ::DWORD = 0x00030000; pub const CALLBACK_THREAD: ::DWORD = CALLBACK_TASK; pub const CALLBACK_EVENT: ::DWORD = 0x00050000; //497 (Win 7 SDK) pub const WAVERR_BADFORMAT: MMRESULT = WAVERR_BASE + 0; pub const WAVERR_STILLPLAYING: MMRESULT = WAVERR_BASE + 1; pub const WAVERR_UNPREPARED: MMRESULT = WAVERR_BASE + 2; pub const WAVERR_SYNC: MMRESULT = WAVERR_BASE + 3; pub const WAVERR_LASTERROR: MMRESULT = WAVERR_BASE + 3; DECLARE_HANDLE!(HWAVEIN, HWAVEIN__); DECLARE_HANDLE!(HWAVEOUT, HWAVEOUT__); pub type LPHWAVEIN = *mut HWAVEIN; pub type LPHWAVEOUT = *mut HWAVEOUT; pub const WOM_OPEN: ::UINT = MM_WOM_OPEN; pub const WOM_CLOSE: ::UINT = MM_WOM_CLOSE; pub const WOM_DONE: ::UINT = MM_WOM_DONE; pub const WIM_OPEN: ::UINT = MM_WIM_OPEN; pub const WIM_CLOSE: ::UINT = MM_WIM_CLOSE; pub const WIM_DATA: ::UINT = MM_WIM_DATA; pub const WAVE_MAPPER: ::UINT = 0xFFFFFFFF; pub const WAVE_FORMAT_QUERY: ::DWORD = 0x0001; pub const WAVE_ALLOWSYNC: ::DWORD = 0x0002; pub const WAVE_MAPPED: ::DWORD = 0x0004; pub const WAVE_FORMAT_DIRECT: ::DWORD = 0x0008; pub const WAVE_FORMAT_DIRECT_QUERY: ::DWORD = WAVE_FORMAT_QUERY | WAVE_FORMAT_DIRECT; pub const WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE: ::DWORD = 0x0010; STRUCT!{struct WAVEHDR { lpData: ::LPSTR, dwBufferLength: ::DWORD, dwBytesRecorded: ::DWORD, dwUser: ::DWORD_PTR, dwFlags: ::DWORD, dwLoops: ::DWORD, lpNext: *mut WAVEHDR, reserved: ::DWORD_PTR, }} pub type PWAVEHDR = *mut WAVEHDR; pub type NPWAVEHDR = *mut WAVEHDR; pub type LPWAVEHDR = *mut WAVEHDR; STRUCT!{struct WAVEOUTCAPSW { wMid: ::WORD, wPid: ::WORD, vDriverVersion: MMVERSION, szPname: [::WCHAR; 32], dwFormats: ::DWORD, wChannels: ::WORD, wReserved1: ::WORD, dwSupport: ::DWORD, }} pub type PWAVEOUTCAPSW = *mut WAVEOUTCAPSW; pub type NPWAVEOUTCAPSW = *mut WAVEOUTCAPSW; pub type LPWAVEOUTCAPSW = *mut WAVEOUTCAPSW; STRUCT!{struct WAVEINCAPSW { wMid: ::WORD, wPid: ::WORD, vDriverVersion: MMVERSION, szPname: [::WCHAR; 32], dwFormats: ::DWORD, wChannels: ::WORD, wReserved1: ::WORD, }} pub type PWAVEINCAPSW = *mut WAVEINCAPSW; pub type NPWAVEINCAPSW = *mut WAVEINCAPSW; pub type LPWAVEINCAPSW = *mut WAVEINCAPSW; pub const WAVE_INVALIDFORMAT: ::DWORD = 0x00000000; pub const WAVE_FORMAT_1M08: ::DWORD = 0x00000001; pub const WAVE_FORMAT_1S08: ::DWORD = 0x00000002; pub const WAVE_FORMAT_1M16: ::DWORD = 0x00000004; pub const WAVE_FORMAT_1S16: ::DWORD = 0x00000008; pub const WAVE_FORMAT_2M08: ::DWORD = 0x00000010; pub const WAVE_FORMAT_2S08: ::DWORD = 0x00000020; pub const WAVE_FORMAT_2M16: ::DWORD = 0x00000040; pub const WAVE_FORMAT_2S16: ::DWORD = 0x00000080; pub const WAVE_FORMAT_4M08: ::DWORD = 0x00000100; pub const WAVE_FORMAT_4S08: ::DWORD = 0x00000200; pub const WAVE_FORMAT_4M16: ::DWORD = 0x00000400; pub const WAVE_FORMAT_4S16: ::DWORD = 0x00000800; pub const WAVE_FORMAT_44M08: ::DWORD = 0x00000100; pub const WAVE_FORMAT_44S08: ::DWORD = 0x00000200; pub const WAVE_FORMAT_44M16: ::DWORD = 0x00000400; pub const WAVE_FORMAT_44S16: ::DWORD = 0x00000800; pub const WAVE_FORMAT_48M08: ::DWORD = 0x00001000; pub const WAVE_FORMAT_48S08: ::DWORD = 0x00002000; pub const WAVE_FORMAT_48M16: ::DWORD = 0x00004000; pub const WAVE_FORMAT_48S16: ::DWORD = 0x00008000; pub const WAVE_FORMAT_96M08: ::DWORD = 0x00010000; pub const WAVE_FORMAT_96S08: ::DWORD = 0x00020000; pub const WAVE_FORMAT_96M16: ::DWORD = 0x00040000; pub const WAVE_FORMAT_96S16: ::DWORD = 0x00080000; //782 (Win 7 SDK) pub type PWAVEFORMATEX = *mut ::WAVEFORMATEX; pub type NPWAVEFORMATEX = *mut ::WAVEFORMATEX; pub type LPWAVEFORMATEX = *mut ::WAVEFORMATEX; pub type LPCWAVEFORMATEX = *const ::WAVEFORMATEX; //2170 (Win 7 SDK) pub const TIMERR_NOERROR: ::MMRESULT = 0; pub const TIMERR_NOCANDO: ::MMRESULT = TIMERR_BASE + 1; pub const TIMERR_STRUCT: ::MMRESULT = TIMERR_BASE + 33; //2198 (Win 7 SDK) STRUCT!{struct TIMECAPS { wPeriodMin: ::UINT, wPeriodMax: ::UINT, }} pub type PTIMECAPS = *mut TIMECAPS; pub type NPTIMECAPS = *mut TIMECAPS; pub type LPTIMECAPS = *mut TIMECAPS; STRUCT!{struct MIDIHDR { lpData: ::LPSTR, dwBufferLength: ::DWORD, dwBytesRecorded: ::DWORD, dwUser: ::DWORD_PTR, dwFlags: ::DWORD, lpNext: *mut MIDIHDR, reserved: ::DWORD_PTR, dwOffset: ::DWORD, dwReserved: [::DWORD_PTR; 4], }} pub type PMIDIHDR = *mut MIDIHDR; pub type NPMIDIHDR = *mut MIDIHDR; pub type LPMIDIHDR = *mut MIDIHDR; STRUCT!{struct MIDIINCAPSW { wMid: ::WORD, wPid: ::WORD, vDriverVersion: MMVERSION, szPname: [::WCHAR; 32], dwSupport: ::DWORD, }} pub type PMIDIINCAPSW = *mut MIDIINCAPSW; pub type NPMIDIINCAPSW = *mut MIDIINCAPSW; pub type LPMIDIINCAPSW = *mut MIDIINCAPSW; STRUCT!{struct MIDIOUTCAPSW { wMid: ::WORD, wPid: ::WORD, vDriverVersion: ::MMVERSION, szPname: [::WCHAR; 32], wTechnology: ::WORD, wVoices: ::WORD, wNotes: ::WORD, wChannelMask: ::WORD, dwSupport: ::DWORD, }} pub type PMIDIOUTCAPSW = *mut MIDIOUTCAPSW; pub type NPMIDIOUTCAPSW = *mut MIDIOUTCAPSW; pub type LPMIDIOUTCAPSW = *mut MIDIOUTCAPSW; DECLARE_HANDLE!(HMIDIIN, HMIDIIN__); DECLARE_HANDLE!(HMIDIOUT, HMIDIOUT__); pub type LPHMIDIIN = *mut HMIDIIN; pub type LPHMIDIOUT = *mut HMIDIOUT; DECLARE_HANDLE!(HMIDISTRM, HMIDISTRM__); DECLARE_HANDLE!(HMIDI, HMIDI__); pub type LPHMIDISTRM = *mut HMIDISTRM; pub type LPHMIDI = *mut HMIDI; deps/winapi-0.2.5/src/cfgmgr32.rs0000644000000000000000000010113012615662007015206 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! user APIs for the Configuration Manager pub type PCVOID = *const ::VOID; pub const MAX_DEVICE_ID_LEN: usize = 200; pub const MAX_DEVNODE_ID_LEN: usize = MAX_DEVICE_ID_LEN; pub const MAX_GUID_STRING_LEN: usize = 39; pub const MAX_CLASS_NAME_LEN: usize = 32; pub const MAX_PROFILE_LEN: usize = 80; pub const MAX_CONFIG_VALUE: ::DWORD = 9999; pub const MAX_INSTANCE_VALUE: ::DWORD = 9999; pub const MAX_MEM_REGISTERS: ::DWORD = 9; pub const MAX_IO_PORTS: ::DWORD = 20; pub const MAX_IRQS: ::DWORD = 7; pub const MAX_DMA_CHANNELS: ::DWORD = 7; pub const DWORD_MAX: ::DWORD = 0xffffffff; pub const DWORDLONG_MAX: ::DWORDLONG = 0xffffffffffffffff; pub const CONFIGMG_VERSION: ::DWORD = 0x0400; pub type RETURN_TYPE = ::DWORD; pub type CONFIGRET = RETURN_TYPE; pub type DEVNODE = ::DWORD; pub type DEVINST = ::DWORD; pub type PDEVNODE = *mut DEVNODE; pub type PDEVINST = *mut DEVNODE; pub type DEVNODEID_A = *mut ::CHAR; pub type DEVINSTID_A = *mut ::CHAR; pub type DEVNODEID_W = *mut ::WCHAR; pub type DEVINSTID_W = *mut ::WCHAR; pub type LOG_CONF = ::DWORD_PTR; pub type PLOG_CONF = *mut LOG_CONF; pub type RES_DES = ::DWORD_PTR; pub type PRES_DES = *mut RES_DES; pub type RESOURCEID = ::ULONG; pub type PRESOURCEID = *mut RESOURCEID; pub type PRIORITY = ::ULONG; pub type PPRIORITY = *mut PRIORITY; pub type RANGE_LIST = ::DWORD_PTR; pub type PRANGE_LIST = *mut RANGE_LIST; pub type RANGE_ELEMENT = ::DWORD_PTR; pub type PRANGE_ELEMENT = *mut RANGE_ELEMENT; pub type HMACHINE = ::HANDLE; pub type PHMACHINE = *mut HMACHINE; pub type CONFLICT_LIST = ::ULONG_PTR; pub type PCONFLICT_LIST = *mut CONFLICT_LIST; #[repr(C)] #[derive(Copy)] pub struct CONFLICT_DETAILS_A { pub CD_ulSize: ::ULONG, pub CD_ulMask: ::ULONG, pub CD_dnDevInst: DEVINST, pub CD_rdResDes: RES_DES, pub CD_ulFlags: ::ULONG, pub CD_szDescription: [::CHAR; ::MAX_PATH], } impl Clone for CONFLICT_DETAILS_A { fn clone(&self) -> CONFLICT_DETAILS_A { *self } } pub type PCONFLICT_DETAILS_A = *mut CONFLICT_DETAILS_A; #[repr(C)] #[derive(Copy)] pub struct CONFLICT_DETAILS_W { pub CD_ulSize: ::ULONG, pub CD_ulMask: ::ULONG, pub CD_dnDevInst: DEVINST, pub CD_rdResDes: RES_DES, pub CD_ulFlags: ::ULONG, pub CD_szDescription: [::WCHAR; ::MAX_PATH], } impl Clone for CONFLICT_DETAILS_W { fn clone(&self) -> CONFLICT_DETAILS_W { *self } } pub type PCONFLICT_DETAILS_W = *mut CONFLICT_DETAILS_W; pub const CM_CDMASK_DEVINST: ::ULONG = 0x00000001; pub const CM_CDMASK_RESDES: ::ULONG = 0x00000002; pub const CM_CDMASK_FLAGS: ::ULONG = 0x00000004; pub const CM_CDMASK_DESCRIPTION: ::ULONG = 0x00000008; pub const CM_CDMASK_VALID: ::ULONG = 0x0000000F; pub const CM_CDFLAGS_DRIVER: ::ULONG = 0x00000001; pub const CM_CDFLAGS_ROOT_OWNED: ::ULONG = 0x00000002; pub const CM_CDFLAGS_RESERVED: ::ULONG = 0x00000004; pub type REGDISPOSITION = ::ULONG; pub const mMD_MemoryType: ::DWORD = 0x1; pub const fMD_MemoryType: ::DWORD = mMD_MemoryType; pub const fMD_ROM: ::DWORD = 0x0; pub const fMD_RAM: ::DWORD = 0x1; pub const mMD_32_24: ::DWORD = 0x2; pub const fMD_32_24: ::DWORD = mMD_32_24; pub const fMD_24: ::DWORD = 0x0; pub const fMD_32: ::DWORD = 0x2; pub const mMD_Prefetchable: ::DWORD = 0x4; pub const fMD_Prefetchable: ::DWORD = mMD_Prefetchable; pub const fMD_Pref: ::DWORD = mMD_Prefetchable; pub const fMD_PrefetchDisallowed: ::DWORD = 0x0; pub const fMD_PrefetchAllowed: ::DWORD = 0x4; pub const mMD_Readable: ::DWORD = 0x8; pub const fMD_Readable: ::DWORD = mMD_Readable; pub const fMD_ReadAllowed: ::DWORD = 0x0; pub const fMD_ReadDisallowed: ::DWORD = 0x8; pub const mMD_CombinedWrite: ::DWORD = 0x10; pub const fMD_CombinedWrite: ::DWORD = mMD_CombinedWrite; pub const fMD_CombinedWriteDisallowed: ::DWORD = 0x0; pub const fMD_CombinedWriteAllowed: ::DWORD = 0x10; pub const mMD_Cacheable: ::DWORD = 0x20; pub const fMD_NonCacheable: ::DWORD = 0x0; pub const fMD_Cacheable: ::DWORD = 0x20; pub const fMD_WINDOW_DECODE: ::DWORD = 0x40; pub const fMD_MEMORY_BAR: ::DWORD = 0x80; STRUCT!{struct MEM_RANGE { MR_Align: ::DWORDLONG, MR_nBytes: ::ULONG, MR_Min: ::DWORDLONG, MR_Max: ::DWORDLONG, MR_Flags: ::DWORD, MR_Reserved: ::DWORD, }} pub type PMEM_RANGE = *mut MEM_RANGE; STRUCT!{struct MEM_DES { MD_Count: ::DWORD, MD_Type: ::DWORD, MD_Alloc_Base: ::DWORDLONG, MD_Alloc_End: ::DWORDLONG, MD_Flags: ::DWORD, MD_Reserved: ::DWORD, }} pub type PMEM_DES = *mut MEM_DES; STRUCT!{struct MEM_RESOURCE { MEM_Header: MEM_DES, MEM_Data: [MEM_RANGE; ::ANYSIZE_ARRAY], }} pub type PMEM_RESOURCE = *mut MEM_RESOURCE; STRUCT!{struct MEM_LARGE_RANGE { MLR_Align: ::DWORDLONG, MLR_nBytes: ::ULONGLONG, MLR_Min: ::DWORDLONG, MLR_Max: ::DWORDLONG, MLR_Flags: ::DWORD, MLR_Reserved: ::DWORD, }} pub type PMEM_LARGE_RANGE = *mut MEM_LARGE_RANGE; STRUCT!{struct MEM_LARGE_DES { MLD_Count: ::DWORD, MLD_Type: ::DWORD, MLD_Alloc_Base: ::DWORDLONG, MLD_Alloc_End: ::DWORDLONG, MLD_Flags: ::DWORD, MLD_Reserved: ::DWORD, }} pub type PMEM_LARGE_DES = *mut MEM_LARGE_DES; STRUCT!{struct MEM_LARGE_RESOURCE { MEM_LARGE_Header: MEM_LARGE_DES, MEM_LARGE_Data: [MEM_LARGE_RANGE; ::ANYSIZE_ARRAY], }} pub type PMEM_LARGE_RESOURCE = *mut MEM_LARGE_RESOURCE; pub const fIOD_PortType: ::DWORD = 0x1; pub const fIOD_Memory: ::DWORD = 0x0; pub const fIOD_IO: ::DWORD = 0x1; pub const fIOD_DECODE: ::DWORD = 0x00fc; pub const fIOD_10_BIT_DECODE: ::DWORD = 0x0004; pub const fIOD_12_BIT_DECODE: ::DWORD = 0x0008; pub const fIOD_16_BIT_DECODE: ::DWORD = 0x0010; pub const fIOD_POSITIVE_DECODE: ::DWORD = 0x0020; pub const fIOD_PASSIVE_DECODE: ::DWORD = 0x0040; pub const fIOD_WINDOW_DECODE: ::DWORD = 0x0080; pub const fIOD_PORT_BAR: ::DWORD = 0x0100; pub const IO_ALIAS_10_BIT_DECODE: ::DWORDLONG = 0x00000004; pub const IO_ALIAS_12_BIT_DECODE: ::DWORDLONG = 0x00000010; pub const IO_ALIAS_16_BIT_DECODE: ::DWORDLONG = 0x00000000; pub const IO_ALIAS_POSITIVE_DECODE: ::DWORDLONG = 0x000000FF; STRUCT!{struct IO_RANGE { IOR_Align: ::DWORDLONG, IOR_nPorts: ::DWORD, IOR_Min: ::DWORDLONG, IOR_Max: ::DWORDLONG, IOR_RangeFlags: ::DWORD, IOR_Alias: ::DWORDLONG, }} pub type PIO_RANGE = *mut IO_RANGE; STRUCT!{struct IO_DES { IOD_Count: ::DWORD, IOD_Type: ::DWORD, IOD_Alloc_Base: ::DWORDLONG, IOD_Alloc_End: ::DWORDLONG, IOD_DesFlags: ::DWORD, }} pub type PIO_DES = *mut IO_DES; STRUCT!{struct IO_RESOURCE { IO_Header: IO_DES, IO_Data: [IO_RANGE; ::ANYSIZE_ARRAY], }} pub type PIO_RESOURCE = *mut IO_RESOURCE; pub const mDD_Width: ::ULONG = 0x3; pub const fDD_BYTE: ::ULONG = 0x0; pub const fDD_WORD: ::ULONG = 0x1; pub const fDD_DWORD: ::ULONG = 0x2; pub const fDD_BYTE_AND_WORD: ::ULONG = 0x3; pub const mDD_BusMaster: ::ULONG = 0x4; pub const fDD_NoBusMaster: ::ULONG = 0x0; pub const fDD_BusMaster: ::ULONG = 0x4; pub const mDD_Type: ::ULONG = 0x18; pub const fDD_TypeStandard: ::ULONG = 0x00; pub const fDD_TypeA: ::ULONG = 0x08; pub const fDD_TypeB: ::ULONG = 0x10; pub const fDD_TypeF: ::ULONG = 0x18; STRUCT!{struct DMA_RANGE { DR_Min: ::ULONG, DR_Max: ::ULONG, DR_Flags: ::ULONG, }} pub type PDMA_RANGE = *mut DMA_RANGE; STRUCT!{struct DMA_DES { DD_Count: ::DWORD, DD_Type: ::DWORD, DD_Flags: ::DWORD, DD_Alloc_Chan: ::ULONG, }} pub type PDMA_DES = *mut DMA_DES; STRUCT!{struct DMA_RESOURCE { DMA_Header: DMA_DES, DMA_Data: [DMA_RANGE; ::ANYSIZE_ARRAY], }} pub type PDMA_RESOURCE = *mut DMA_RESOURCE; pub const mIRQD_Share: ::ULONG = 0x1; pub const fIRQD_Exclusive: ::ULONG = 0x0; pub const fIRQD_Share: ::ULONG = 0x1; pub const fIRQD_Share_Bit: ::ULONG = 0; pub const fIRQD_Level_Bit: ::ULONG = 1; pub const mIRQD_Edge_Level: ::ULONG = 0x2; pub const fIRQD_Level: ::ULONG = 0x0; pub const fIRQD_Edge: ::ULONG = 0x2; STRUCT!{struct IRQ_RANGE { IRQR_Min: ::ULONG, IRQR_Max: ::ULONG, IRQR_Flags: ::ULONG, }} pub type PIRQ_RANGE = *mut IRQ_RANGE; STRUCT!{struct IRQ_DES_32 { IRQD_Count: ::DWORD, IRQD_Type: ::DWORD, IRQD_Flags: ::DWORD, IRQD_Alloc_Num: ::ULONG, IRQD_Affinity: ::ULONG32, }} pub type PIRQ_DES_32 = *mut IRQ_DES_32; STRUCT!{struct IRQ_DES_64 { IRQD_Count: ::DWORD, IRQD_Type: ::DWORD, IRQD_Flags: ::DWORD, IRQD_Alloc_Num: ::ULONG, IRQD_Affinity: ::ULONG64, }} pub type PIRQ_DES_64 = *mut IRQ_DES_64; STRUCT!{struct IRQ_RESOURCE_32 { IRQ_Header: IRQ_DES_32, IRQ_Data: [IRQ_RANGE; ::ANYSIZE_ARRAY], }} pub type PIRQ_RESOURCE_32 = *mut IRQ_RESOURCE_32; STRUCT!{struct IRQ_RESOURCE_64 { IRQ_Header: IRQ_DES_64, IRQ_Data: [IRQ_RANGE; ::ANYSIZE_ARRAY], }} pub type PIRQ_RESOURCE_64 = *mut IRQ_RESOURCE_64; STRUCT!{struct DEVPRIVATE_RANGE { PR_Data1: ::DWORD, PR_Data2: ::DWORD, PR_Data3: ::DWORD, }} pub type PDEVPRIVATE_RANGE = *mut DEVPRIVATE_RANGE; STRUCT!{struct DEVPRIVATE_DES { PD_Count: ::DWORD, PD_Type: ::DWORD, PD_Data1: ::DWORD, PD_Data2: ::DWORD, PD_Data3: ::DWORD, PD_Flags: ::DWORD, }} pub type PDEVPRIVATE_DES = *mut DEVPRIVATE_DES; STRUCT!{struct DEVPRIVATE_RESOURCE { PRV_Header: DEVPRIVATE_DES, PRV_Data: [DEVPRIVATE_RANGE; ::ANYSIZE_ARRAY], }} pub type PDEVPRIVATE_RESOURCE = *mut DEVPRIVATE_RESOURCE; STRUCT!{struct CS_DES { CSD_SignatureLength: ::DWORD, CSD_LegacyDataOffset: ::DWORD, CSD_LegacyDataSize: ::DWORD, CSD_Flags: ::DWORD, CSD_ClassGuid: ::GUID, CSD_Signature: [::BYTE; ::ANYSIZE_ARRAY], }} pub type PCS_DES = *mut CS_DES; STRUCT!{struct CS_RESOURCE { CS_Header: CS_DES, }} pub type PCS_RESOURCE = *mut CS_RESOURCE; pub const mPCD_IO_8_16: ::DWORD = 0x1; pub const fPCD_IO_8: ::DWORD = 0x0; pub const fPCD_IO_16: ::DWORD = 0x1; pub const mPCD_MEM_8_16: ::DWORD = 0x2; pub const fPCD_MEM_8: ::DWORD = 0x0; pub const fPCD_MEM_16: ::DWORD = 0x2; pub const mPCD_MEM_A_C: ::DWORD = 0xC; pub const fPCD_MEM1_A: ::DWORD = 0x4; pub const fPCD_MEM2_A: ::DWORD = 0x8; pub const fPCD_IO_ZW_8: ::DWORD = 0x10; pub const fPCD_IO_SRC_16: ::DWORD = 0x20; pub const fPCD_IO_WS_16: ::DWORD = 0x40; pub const mPCD_MEM_WS: ::DWORD = 0x300; pub const fPCD_MEM_WS_ONE: ::DWORD = 0x100; pub const fPCD_MEM_WS_TWO: ::DWORD = 0x200; pub const fPCD_MEM_WS_THREE: ::DWORD = 0x300; pub const fPCD_MEM_A: ::DWORD = 0x4; pub const fPCD_ATTRIBUTES_PER_WINDOW: ::DWORD = 0x8000; pub const fPCD_IO1_16: ::DWORD = 0x00010000; pub const fPCD_IO1_ZW_8: ::DWORD = 0x00020000; pub const fPCD_IO1_SRC_16: ::DWORD = 0x00040000; pub const fPCD_IO1_WS_16: ::DWORD = 0x00080000; pub const fPCD_IO2_16: ::DWORD = 0x00100000; pub const fPCD_IO2_ZW_8: ::DWORD = 0x00200000; pub const fPCD_IO2_SRC_16: ::DWORD = 0x00400000; pub const fPCD_IO2_WS_16: ::DWORD = 0x00800000; pub const mPCD_MEM1_WS: ::DWORD = 0x03000000; pub const fPCD_MEM1_WS_TWO: ::DWORD = 0x02000000; pub const fPCD_MEM1_WS_THREE: ::DWORD = 0x03000000; pub const fPCD_MEM1_16: ::DWORD = 0x04000000; pub const mPCD_MEM2_WS: ::DWORD = 0x30000000; pub const fPCD_MEM2_WS_ONE: ::DWORD = 0x10000000; pub const fPCD_MEM2_WS_TWO: ::DWORD = 0x20000000; pub const fPCD_MEM2_WS_THREE: ::DWORD = 0x30000000; pub const fPCD_MEM2_16: ::DWORD = 0x40000000; pub const PCD_MAX_MEMORY: usize = 2; pub const PCD_MAX_IO: usize = 2; STRUCT!{struct PCCARD_DES { PCD_Count: ::DWORD, PCD_Type: ::DWORD, PCD_Flags: ::DWORD, PCD_ConfigIndex: ::BYTE, PCD_Reserved: [::BYTE; 3], PCD_MemoryCardBase1: ::DWORD, PCD_MemoryCardBase2: ::DWORD, PCD_MemoryCardBase: [::DWORD; PCD_MAX_MEMORY], PCD_MemoryFlags: [::WORD; PCD_MAX_MEMORY], PCD_IoFlags: [::BYTE; PCD_MAX_IO], }} pub type PPCCARD_DES = *mut PCCARD_DES; STRUCT!{struct PCCARD_RESOURCE { PcCard_Header: PCCARD_DES, }} pub type PPCCARD_RESOURCE = *mut PCCARD_RESOURCE; pub const mPMF_AUDIO_ENABLE: ::DWORD = 0x8; pub const fPMF_AUDIO_ENABLE: ::DWORD = 0x8; STRUCT!{struct MFCARD_DES { PMF_Count: ::DWORD, PMF_Type: ::DWORD, PMF_Flags: ::DWORD, PMF_ConfigOptions: ::BYTE, PMF_IoResourceIndex: ::BYTE, PMF_Reserved: [::BYTE; 2], PMF_ConfigRegisterBase: ::DWORD, }} pub type PMFCARD_DES = *mut MFCARD_DES; STRUCT!{struct MFCARD_RESOURCE { MfCard_Header: MFCARD_DES, }} pub type PMFCARD_RESOURCE = *mut MFCARD_RESOURCE; STRUCT!{struct BUSNUMBER_RANGE { BUSR_Min: ::ULONG, BUSR_Max: ::ULONG, BUSR_nBusNumbers: ::ULONG, BUSR_Flags: ::ULONG, }} pub type PBUSNUMBER_RANGE = *mut BUSNUMBER_RANGE; STRUCT!{struct BUSNUMBER_DES { BUSD_Count: ::DWORD, BUSD_Type: ::DWORD, BUSD_Flags: ::DWORD, BUSD_Alloc_Base: ::ULONG, BUSD_Alloc_End: ::ULONG, }} pub type PBUSNUMBER_DES = *mut BUSNUMBER_DES; STRUCT!{struct BUSNUMBER_RESOURCE { BusNumber_Header: BUSNUMBER_DES, BusNumber_Data: [BUSNUMBER_RANGE; ::ANYSIZE_ARRAY], }} pub type PBUSNUMBER_RESOURCE = *mut BUSNUMBER_RESOURCE; STRUCT!{struct CONNECTION_DES { COND_Type: ::DWORD, COND_Flags: ::DWORD, COND_Class: ::BYTE, COND_ClassType: ::BYTE, COND_Reserved1: ::BYTE, COND_Reserved2: ::BYTE, COND_Id: ::LARGE_INTEGER, }} pub type PCONNECTION_DES = *mut CONNECTION_DES; STRUCT!{struct CONNECTION_RESOURCE { Connection_Header: CONNECTION_DES, }} pub type PCONNECTION_RESOURCE = *mut CONNECTION_RESOURCE; pub const CM_HWPI_NOT_DOCKABLE: ::DWORD = 0x00000000; pub const CM_HWPI_UNDOCKED: ::DWORD = 0x00000001; pub const CM_HWPI_DOCKED: ::DWORD = 0x00000002; #[repr(C)] #[derive(Copy)] pub struct HWPROFILEINFO_A { pub HWPI_ulHWProfile: ::ULONG, pub HWPI_szFriendlyName: [::CHAR; MAX_PROFILE_LEN], pub HWPI_dwFlags: ::DWORD, } impl Clone for HWPROFILEINFO_A { fn clone(&self) -> HWPROFILEINFO_A { *self } } pub type PHWPROFILEINFO_A = *mut HWPROFILEINFO_A; #[repr(C)] #[derive(Copy)] pub struct HWPROFILEINFO_W { pub HWPI_ulHWProfile: ::ULONG, pub HWPI_szFriendlyName: [::WCHAR; MAX_PROFILE_LEN], pub HWPI_dwFlags: ::DWORD, } impl Clone for HWPROFILEINFO_W { fn clone(&self) -> HWPROFILEINFO_W { *self } } pub type PHWPROFILEINFO_W = *mut HWPROFILEINFO_W; pub const ResType_All: RESOURCEID = 0x00000000; pub const ResType_None: RESOURCEID = 0x00000000; pub const ResType_Mem: RESOURCEID = 0x00000001; pub const ResType_IO: RESOURCEID = 0x00000002; pub const ResType_DMA: RESOURCEID = 0x00000003; pub const ResType_IRQ: RESOURCEID = 0x00000004; pub const ResType_DoNotUse: RESOURCEID = 0x00000005; pub const ResType_BusNumber: RESOURCEID = 0x00000006; pub const ResType_MemLarge: RESOURCEID = 0x00000007; pub const ResType_MAX: RESOURCEID = 0x00000007; pub const ResType_Ignored_Bit: RESOURCEID = 0x00008000; pub const ResType_ClassSpecific: RESOURCEID = 0x0000FFFF; pub const ResType_Reserved: RESOURCEID = 0x00008000; pub const ResType_DevicePrivate: RESOURCEID = 0x00008001; pub const ResType_PcCardConfig: RESOURCEID = 0x00008002; pub const ResType_MfCardConfig: RESOURCEID = 0x00008003; pub const ResType_Connection: RESOURCEID = 0x00008004; pub const CM_ADD_RANGE_ADDIFCONFLICT: ::ULONG = 0x00000000; pub const CM_ADD_RANGE_DONOTADDIFCONFLICT: ::ULONG = 0x00000001; pub const CM_ADD_RANGE_BITS: ::ULONG = 0x00000001; pub const BASIC_LOG_CONF: ::ULONG = 0x00000000; pub const FILTERED_LOG_CONF: ::ULONG = 0x00000001; pub const ALLOC_LOG_CONF: ::ULONG = 0x00000002; pub const BOOT_LOG_CONF: ::ULONG = 0x00000003; pub const FORCED_LOG_CONF: ::ULONG = 0x00000004; pub const OVERRIDE_LOG_CONF: ::ULONG = 0x00000005; pub const NUM_LOG_CONF: ::ULONG = 0x00000006; pub const LOG_CONF_BITS: ::ULONG = 0x00000007; pub const PRIORITY_EQUAL_FIRST: ::ULONG = 0x00000008; pub const PRIORITY_EQUAL_LAST: ::ULONG = 0x00000000; pub const PRIORITY_BIT: ::ULONG = 0x00000008; pub const RegDisposition_OpenAlways: REGDISPOSITION = 0x00000000; pub const RegDisposition_OpenExisting: REGDISPOSITION = 0x00000001; pub const RegDisposition_Bits: REGDISPOSITION = 0x00000001; pub const CM_ADD_ID_HARDWARE: ::ULONG = 0x00000000; pub const CM_ADD_ID_COMPATIBLE: ::ULONG = 0x00000001; pub const CM_ADD_ID_BITS: ::ULONG = 0x00000001; pub const CM_CREATE_DEVNODE_NORMAL: ::ULONG = 0x00000000; pub const CM_CREATE_DEVNODE_NO_WAIT_INSTALL: ::ULONG = 0x00000001; pub const CM_CREATE_DEVNODE_PHANTOM: ::ULONG = 0x00000002; pub const CM_CREATE_DEVNODE_GENERATE_ID: ::ULONG = 0x00000004; pub const CM_CREATE_DEVNODE_DO_NOT_INSTALL: ::ULONG = 0x00000008; pub const CM_CREATE_DEVNODE_BITS: ::ULONG = 0x0000000F; pub const CM_CREATE_DEVINST_NORMAL: ::ULONG = CM_CREATE_DEVNODE_NORMAL; pub const CM_CREATE_DEVINST_NO_WAIT_INSTALL: ::ULONG = CM_CREATE_DEVNODE_NO_WAIT_INSTALL; pub const CM_CREATE_DEVINST_PHANTOM: ::ULONG = CM_CREATE_DEVNODE_PHANTOM; pub const CM_CREATE_DEVINST_GENERATE_ID: ::ULONG = CM_CREATE_DEVNODE_GENERATE_ID; pub const CM_CREATE_DEVINST_DO_NOT_INSTALL: ::ULONG = CM_CREATE_DEVNODE_DO_NOT_INSTALL; pub const CM_CREATE_DEVINST_BITS: ::ULONG = CM_CREATE_DEVNODE_BITS; pub const CM_DELETE_CLASS_ONLY: ::ULONG = 0x00000000; pub const CM_DELETE_CLASS_SUBKEYS: ::ULONG = 0x00000001; pub const CM_DELETE_CLASS_INTERFACE: ::ULONG = 0x00000002; pub const CM_DELETE_CLASS_BITS: ::ULONG = 0x00000003; pub const CM_ENUMERATE_CLASSES_INSTALLER: ::ULONG = 0x00000000; pub const CM_ENUMERATE_CLASSES_INTERFACE: ::ULONG = 0x00000001; pub const CM_ENUMERATE_CLASSES_BITS: ::ULONG = 0x00000001; pub const CM_DETECT_NEW_PROFILE: ::ULONG = 0x00000001; pub const CM_DETECT_CRASHED: ::ULONG = 0x00000002; pub const CM_DETECT_HWPROF_FIRST_BOOT: ::ULONG = 0x00000004; pub const CM_DETECT_RUN: ::ULONG = 0x80000000; pub const CM_DETECT_BITS: ::ULONG = 0x80000007; pub const CM_DISABLE_POLITE: ::ULONG = 0x00000000; pub const CM_DISABLE_ABSOLUTE: ::ULONG = 0x00000001; pub const CM_DISABLE_HARDWARE: ::ULONG = 0x00000002; pub const CM_DISABLE_UI_NOT_OK: ::ULONG = 0x00000004; pub const CM_DISABLE_BITS: ::ULONG = 0x00000007; pub const CM_GETIDLIST_FILTER_NONE: ::ULONG = 0x00000000; pub const CM_GETIDLIST_FILTER_ENUMERATOR: ::ULONG = 0x00000001; pub const CM_GETIDLIST_FILTER_SERVICE: ::ULONG = 0x00000002; pub const CM_GETIDLIST_FILTER_EJECTRELATIONS: ::ULONG = 0x00000004; pub const CM_GETIDLIST_FILTER_REMOVALRELATIONS: ::ULONG = 0x00000008; pub const CM_GETIDLIST_FILTER_POWERRELATIONS: ::ULONG = 0x00000010; pub const CM_GETIDLIST_FILTER_BUSRELATIONS: ::ULONG = 0x00000020; pub const CM_GETIDLIST_DONOTGENERATE: ::ULONG = 0x10000040; pub const CM_GETIDLIST_FILTER_TRANSPORTRELATIONS: ::ULONG = 0x00000080; pub const CM_GETIDLIST_FILTER_PRESENT: ::ULONG = 0x00000100; pub const CM_GETIDLIST_FILTER_CLASS: ::ULONG = 0x00000200; pub const CM_GETIDLIST_FILTER_BITS: ::ULONG = 0x100003FF; pub const CM_GET_DEVICE_INTERFACE_LIST_PRESENT: ::ULONG = 0x00000000; pub const CM_GET_DEVICE_INTERFACE_LIST_ALL_DEVICES: ::ULONG = 0x00000001; pub const CM_GET_DEVICE_INTERFACE_LIST_BITS: ::ULONG = 0x00000001; pub const CM_DRP_DEVICEDESC: ::ULONG = 0x00000001; pub const CM_DRP_HARDWAREID: ::ULONG = 0x00000002; pub const CM_DRP_COMPATIBLEIDS: ::ULONG = 0x00000003; pub const CM_DRP_UNUSED0: ::ULONG = 0x00000004; pub const CM_DRP_SERVICE: ::ULONG = 0x00000005; pub const CM_DRP_UNUSED1: ::ULONG = 0x00000006; pub const CM_DRP_UNUSED2: ::ULONG = 0x00000007; pub const CM_DRP_CLASS: ::ULONG = 0x00000008; pub const CM_DRP_CLASSGUID: ::ULONG = 0x00000009; pub const CM_DRP_DRIVER: ::ULONG = 0x0000000A; pub const CM_DRP_CONFIGFLAGS: ::ULONG = 0x0000000B; pub const CM_DRP_MFG: ::ULONG = 0x0000000C; pub const CM_DRP_FRIENDLYNAME: ::ULONG = 0x0000000D; pub const CM_DRP_LOCATION_INFORMATION: ::ULONG = 0x0000000E; pub const CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME: ::ULONG = 0x0000000F; pub const CM_DRP_CAPABILITIES: ::ULONG = 0x00000010; pub const CM_DRP_UI_NUMBER: ::ULONG = 0x00000011; pub const CM_DRP_UPPERFILTERS: ::ULONG = 0x00000012; pub const CM_CRP_UPPERFILTERS: ::ULONG = CM_DRP_UPPERFILTERS; pub const CM_DRP_LOWERFILTERS: ::ULONG = 0x00000013; pub const CM_CRP_LOWERFILTERS: ::ULONG = CM_DRP_LOWERFILTERS; pub const CM_DRP_BUSTYPEGUID: ::ULONG = 0x00000014; pub const CM_DRP_LEGACYBUSTYPE: ::ULONG = 0x00000015; pub const CM_DRP_BUSNUMBER: ::ULONG = 0x00000016; pub const CM_DRP_ENUMERATOR_NAME: ::ULONG = 0x00000017; pub const CM_DRP_SECURITY: ::ULONG = 0x00000018; pub const CM_CRP_SECURITY: ::ULONG = CM_DRP_SECURITY; pub const CM_DRP_SECURITY_SDS: ::ULONG = 0x00000019; pub const CM_CRP_SECURITY_SDS: ::ULONG = CM_DRP_SECURITY_SDS; pub const CM_DRP_DEVTYPE: ::ULONG = 0x0000001A; pub const CM_CRP_DEVTYPE: ::ULONG = CM_DRP_DEVTYPE; pub const CM_DRP_EXCLUSIVE: ::ULONG = 0x0000001B; pub const CM_CRP_EXCLUSIVE: ::ULONG = CM_DRP_EXCLUSIVE; pub const CM_DRP_CHARACTERISTICS: ::ULONG = 0x0000001C; pub const CM_CRP_CHARACTERISTICS: ::ULONG = CM_DRP_CHARACTERISTICS; pub const CM_DRP_ADDRESS: ::ULONG = 0x0000001D; pub const CM_DRP_UI_NUMBER_DESC_FORMAT: ::ULONG = 0x0000001E; pub const CM_DRP_DEVICE_POWER_DATA: ::ULONG = 0x0000001F; pub const CM_DRP_REMOVAL_POLICY: ::ULONG = 0x00000020; pub const CM_DRP_REMOVAL_POLICY_HW_DEFAULT: ::ULONG = 0x00000021; pub const CM_DRP_REMOVAL_POLICY_OVERRIDE: ::ULONG = 0x00000022; pub const CM_DRP_INSTALL_STATE: ::ULONG = 0x00000023; pub const CM_DRP_LOCATION_PATHS: ::ULONG = 0x00000024; pub const CM_DRP_BASE_CONTAINERID: ::ULONG = 0x00000025; pub const CM_DRP_MIN: ::ULONG = 0x00000001; pub const CM_CRP_MIN: ::ULONG = CM_DRP_MIN; pub const CM_DRP_MAX: ::ULONG = 0x00000025; pub const CM_CRP_MAX: ::ULONG = CM_DRP_MAX; pub const CM_DEVCAP_LOCKSUPPORTED: ::ULONG = 0x00000001; pub const CM_DEVCAP_EJECTSUPPORTED: ::ULONG = 0x00000002; pub const CM_DEVCAP_REMOVABLE: ::ULONG = 0x00000004; pub const CM_DEVCAP_DOCKDEVICE: ::ULONG = 0x00000008; pub const CM_DEVCAP_UNIQUEID: ::ULONG = 0x00000010; pub const CM_DEVCAP_SILENTINSTALL: ::ULONG = 0x00000020; pub const CM_DEVCAP_RAWDEVICEOK: ::ULONG = 0x00000040; pub const CM_DEVCAP_SURPRISEREMOVALOK: ::ULONG = 0x00000080; pub const CM_DEVCAP_HARDWAREDISABLED: ::ULONG = 0x00000100; pub const CM_DEVCAP_NONDYNAMIC: ::ULONG = 0x00000200; pub const CM_REMOVAL_POLICY_EXPECT_NO_REMOVAL: ::ULONG = 1; pub const CM_REMOVAL_POLICY_EXPECT_ORDERLY_REMOVAL: ::ULONG = 2; pub const CM_REMOVAL_POLICY_EXPECT_SURPRISE_REMOVAL: ::ULONG = 3; pub const CM_INSTALL_STATE_INSTALLED: ::ULONG = 0; pub const CM_INSTALL_STATE_NEEDS_REINSTALL: ::ULONG = 1; pub const CM_INSTALL_STATE_FAILED_INSTALL: ::ULONG = 2; pub const CM_INSTALL_STATE_FINISH_INSTALL: ::ULONG = 3; pub const CM_LOCATE_DEVNODE_NORMAL: ::ULONG = 0x00000000; pub const CM_LOCATE_DEVNODE_PHANTOM: ::ULONG = 0x00000001; pub const CM_LOCATE_DEVNODE_CANCELREMOVE: ::ULONG = 0x00000002; pub const CM_LOCATE_DEVNODE_NOVALIDATION: ::ULONG = 0x00000004; pub const CM_LOCATE_DEVNODE_BITS: ::ULONG = 0x00000007; pub const CM_LOCATE_DEVINST_NORMAL: ::ULONG = CM_LOCATE_DEVNODE_NORMAL; pub const CM_LOCATE_DEVINST_PHANTOM: ::ULONG = CM_LOCATE_DEVNODE_PHANTOM; pub const CM_LOCATE_DEVINST_CANCELREMOVE: ::ULONG = CM_LOCATE_DEVNODE_CANCELREMOVE; pub const CM_LOCATE_DEVINST_NOVALIDATION: ::ULONG = CM_LOCATE_DEVNODE_NOVALIDATION; pub const CM_LOCATE_DEVINST_BITS: ::ULONG = CM_LOCATE_DEVNODE_BITS; pub const CM_OPEN_CLASS_KEY_INSTALLER: ::ULONG = 0x00000000; pub const CM_OPEN_CLASS_KEY_INTERFACE: ::ULONG = 0x00000001; pub const CM_OPEN_CLASS_KEY_BITS: ::ULONG = 0x00000001; pub const CM_REMOVE_UI_OK: ::ULONG = 0x00000000; pub const CM_REMOVE_UI_NOT_OK: ::ULONG = 0x00000001; pub const CM_REMOVE_NO_RESTART: ::ULONG = 0x00000002; pub const CM_REMOVE_BITS: ::ULONG = 0x00000003; pub const CM_QUERY_REMOVE_UI_OK: ::ULONG = CM_REMOVE_UI_OK; pub const CM_QUERY_REMOVE_UI_NOT_OK: ::ULONG = CM_REMOVE_UI_NOT_OK; pub const CM_QUERY_REMOVE_BITS: ::ULONG = CM_QUERY_REMOVE_UI_OK | CM_QUERY_REMOVE_UI_NOT_OK; pub const CM_REENUMERATE_NORMAL: ::ULONG = 0x00000000; pub const CM_REENUMERATE_SYNCHRONOUS: ::ULONG = 0x00000001; pub const CM_REENUMERATE_RETRY_INSTALLATION: ::ULONG = 0x00000002; pub const CM_REENUMERATE_ASYNCHRONOUS: ::ULONG = 0x00000004; pub const CM_REENUMERATE_BITS: ::ULONG = 0x00000007; pub const CM_REGISTER_DEVICE_DRIVER_STATIC: ::ULONG = 0x00000000; pub const CM_REGISTER_DEVICE_DRIVER_DISABLEABLE: ::ULONG = 0x00000001; pub const CM_REGISTER_DEVICE_DRIVER_REMOVABLE: ::ULONG = 0x00000002; pub const CM_REGISTER_DEVICE_DRIVER_BITS: ::ULONG = 0x00000003; pub const CM_REGISTRY_HARDWARE: ::ULONG = 0x00000000; pub const CM_REGISTRY_SOFTWARE: ::ULONG = 0x00000001; pub const CM_REGISTRY_USER: ::ULONG = 0x00000100; pub const CM_REGISTRY_CONFIG: ::ULONG = 0x00000200; pub const CM_REGISTRY_BITS: ::ULONG = 0x00000301; pub const CM_SET_DEVNODE_PROBLEM_NORMAL: ::ULONG = 0x00000000; pub const CM_SET_DEVNODE_PROBLEM_OVERRIDE: ::ULONG = 0x00000001; pub const CM_SET_DEVNODE_PROBLEM_BITS: ::ULONG = 0x00000001; pub const CM_SET_DEVINST_PROBLEM_NORMAL: ::ULONG = CM_SET_DEVNODE_PROBLEM_NORMAL; pub const CM_SET_DEVINST_PROBLEM_OVERRIDE: ::ULONG = CM_SET_DEVNODE_PROBLEM_OVERRIDE; pub const CM_SET_DEVINST_PROBLEM_BITS: ::ULONG = CM_SET_DEVNODE_PROBLEM_BITS; pub const CM_SET_HW_PROF_FLAGS_UI_NOT_OK: ::ULONG = 0x00000001; pub const CM_SET_HW_PROF_FLAGS_BITS: ::ULONG = 0x00000001; pub const CM_SETUP_DEVNODE_READY: ::ULONG = 0x00000000; pub const CM_SETUP_DEVINST_READY: ::ULONG = CM_SETUP_DEVNODE_READY; pub const CM_SETUP_DOWNLOAD: ::ULONG = 0x00000001; pub const CM_SETUP_WRITE_LOG_CONFS: ::ULONG = 0x00000002; pub const CM_SETUP_PROP_CHANGE: ::ULONG = 0x00000003; pub const CM_SETUP_DEVNODE_RESET: ::ULONG = 0x00000004; pub const CM_SETUP_DEVINST_RESET: ::ULONG = CM_SETUP_DEVNODE_RESET; pub const CM_SETUP_DEVNODE_CONFIG: ::ULONG = 0x00000005; pub const CM_SETUP_DEVINST_CONFIG: ::ULONG = CM_SETUP_DEVNODE_CONFIG; pub const CM_SETUP_DEVNODE_CONFIG_CLASS: ::ULONG = 0x00000006; pub const CM_SETUP_DEVINST_CONFIG_CLASS: ::ULONG = CM_SETUP_DEVNODE_CONFIG_CLASS; pub const CM_SETUP_DEVNODE_CONFIG_EXTENSIONS: ::ULONG = 0x00000007; pub const CM_SETUP_DEVINST_CONFIG_EXTENSIONS: ::ULONG = CM_SETUP_DEVNODE_CONFIG_EXTENSIONS; pub const CM_SETUP_BITS: ::ULONG = 0x00000007; pub const CM_QUERY_ARBITRATOR_RAW: ::ULONG = 0x00000000; pub const CM_QUERY_ARBITRATOR_TRANSLATED: ::ULONG = 0x00000001; pub const CM_QUERY_ARBITRATOR_BITS: ::ULONG = 0x00000001; pub const CM_CUSTOMDEVPROP_MERGE_MULTISZ: ::ULONG = 0x00000001; pub const CM_CUSTOMDEVPROP_BITS: ::ULONG = 0x00000001; pub const CM_NAME_ATTRIBUTE_NAME_RETRIEVED_FROM_DEVICE: ::ULONG = 0x1; pub const CM_NAME_ATTRIBUTE_USER_ASSIGNED_NAME: ::ULONG = 0x2; pub const CM_CLASS_PROPERTY_INSTALLER: ::ULONG = 0x00000000; pub const CM_CLASS_PROPERTY_INTERFACE: ::ULONG = 0x00000001; pub const CM_CLASS_PROPERTY_BITS: ::ULONG = 0x00000001; DECLARE_HANDLE!(HCMNOTIFICATION, HCMNOTIFICATION__); pub type PHCMNOTIFICATION = *mut HCMNOTIFICATION; pub const CM_NOTIFY_FILTER_FLAG_ALL_INTERFACE_CLASSES: ::ULONG = 0x00000001; pub const CM_NOTIFY_FILTER_FLAG_ALL_DEVICE_INSTANCES: ::ULONG = 0x00000002; pub const CM_NOTIFY_FILTER_VALID_FLAGS: ::ULONG = CM_NOTIFY_FILTER_FLAG_ALL_INTERFACE_CLASSES | CM_NOTIFY_FILTER_FLAG_ALL_DEVICE_INSTANCES; ENUM!{enum CM_NOTIFY_FILTER_TYPE { CM_NOTIFY_FILTER_TYPE_DEVICEINTERFACE = 0, CM_NOTIFY_FILTER_TYPE_DEVICEHANDLE, CM_NOTIFY_FILTER_TYPE_DEVICEINSTANCE, CM_NOTIFY_FILTER_TYPE_MAX, }} pub type PCM_NOTIFY_FILTER_TYPE = *mut CM_NOTIFY_FILTER_TYPE; STRUCT!{struct CM_NOTIFY_FILTER_DeviceInterface { ClassGuid: ::GUID, }} STRUCT!{struct CM_NOTIFY_FILTER_DeviceHandle { hTarget: ::HANDLE, }} #[repr(C)] #[derive(Copy)] pub struct CM_NOTIFY_FILTER_DeviceInstance { pub InstanceId: [::WCHAR; MAX_DEVICE_ID_LEN], } impl Clone for CM_NOTIFY_FILTER_DeviceInstance { fn clone(&self) -> CM_NOTIFY_FILTER_DeviceInstance { *self } } #[repr(C)] #[derive(Copy)] pub struct CM_NOTIFY_FILTER { pub cbSize: ::DWORD, pub Flags: ::DWORD, pub FilterType: CM_NOTIFY_FILTER_TYPE, pub Reserved: ::DWORD, pub u: [::BYTE; 400], } impl Clone for CM_NOTIFY_FILTER { fn clone(&self) -> CM_NOTIFY_FILTER { *self } } UNION!(CM_NOTIFY_FILTER, u, DeviceInterface, DeviceInterface_mut, CM_NOTIFY_FILTER_DeviceInterface); UNION!(CM_NOTIFY_FILTER, u, DeviceHandle, DeviceHandle_mut, CM_NOTIFY_FILTER_DeviceHandle); UNION!(CM_NOTIFY_FILTER, u, DeviceInstance, DeviceInstance_mut, CM_NOTIFY_FILTER_DeviceInstance); pub type PCM_NOTIFY_FILTER = *mut CM_NOTIFY_FILTER; ENUM!{enum CM_NOTIFY_ACTION { CM_NOTIFY_ACTION_DEVICEINTERFACEARRIVAL = 0, CM_NOTIFY_ACTION_DEVICEINTERFACEREMOVAL, CM_NOTIFY_ACTION_DEVICEQUERYREMOVE, CM_NOTIFY_ACTION_DEVICEQUERYREMOVEFAILED, CM_NOTIFY_ACTION_DEVICEREMOVEPENDING, CM_NOTIFY_ACTION_DEVICEREMOVECOMPLETE, CM_NOTIFY_ACTION_DEVICECUSTOMEVENT, CM_NOTIFY_ACTION_DEVICEINSTANCEENUMERATED, CM_NOTIFY_ACTION_DEVICEINSTANCESTARTED, CM_NOTIFY_ACTION_DEVICEINSTANCEREMOVED, CM_NOTIFY_ACTION_MAX, }} pub type PCM_NOTIFY_ACTION = *mut CM_NOTIFY_ACTION; STRUCT!{struct CM_NOTIFY_EVENT_DATA_DeviceInterface { ClassGuid: ::GUID, SymbolicLink: [::WCHAR; ::ANYSIZE_ARRAY], }} STRUCT!{struct CM_NOTIFY_EVENT_DATA_DeviceHandle { EventGuid: ::GUID, NameOffset: ::LONG, DataSize: ::DWORD, Data: [::BYTE; ::ANYSIZE_ARRAY], }} STRUCT!{struct CM_NOTIFY_EVENT_DATA_DeviceInstance { InstanceId: [::WCHAR; ::ANYSIZE_ARRAY], }} STRUCT!{struct CM_NOTIFY_EVENT_DATA { FilterType: CM_NOTIFY_FILTER_TYPE, Reserved: ::DWORD, u: [::BYTE; 25], }} UNION!( CM_NOTIFY_EVENT_DATA, u, DeviceInterface, DeviceInterface_mut, CM_NOTIFY_EVENT_DATA_DeviceInterface ); UNION!(CM_NOTIFY_EVENT_DATA, u, DeviceHandle, DeviceHandle_mut, CM_NOTIFY_EVENT_DATA_DeviceHandle); UNION!( CM_NOTIFY_EVENT_DATA, u, DeviceInstance, DeviceInstance_mut, CM_NOTIFY_EVENT_DATA_DeviceInstance ); pub type PCM_NOTIFY_EVENT_DATA = *mut CM_NOTIFY_EVENT_DATA; pub type PCM_NOTIFY_CALLBACK = Option ::DWORD>; pub const CR_SUCCESS: CONFIGRET = 0x00000000; pub const CR_DEFAULT: CONFIGRET = 0x00000001; pub const CR_OUT_OF_MEMORY: CONFIGRET = 0x00000002; pub const CR_INVALID_POINTER: CONFIGRET = 0x00000003; pub const CR_INVALID_FLAG: CONFIGRET = 0x00000004; pub const CR_INVALID_DEVNODE: CONFIGRET = 0x00000005; pub const CR_INVALID_DEVINST: CONFIGRET = CR_INVALID_DEVNODE; pub const CR_INVALID_RES_DES: CONFIGRET = 0x00000006; pub const CR_INVALID_LOG_CONF: CONFIGRET = 0x00000007; pub const CR_INVALID_ARBITRATOR: CONFIGRET = 0x00000008; pub const CR_INVALID_NODELIST: CONFIGRET = 0x00000009; pub const CR_DEVNODE_HAS_REQS: CONFIGRET = 0x0000000A; pub const CR_DEVINST_HAS_REQS: CONFIGRET = CR_DEVNODE_HAS_REQS; pub const CR_INVALID_RESOURCEID: CONFIGRET = 0x0000000B; pub const CR_DLVXD_NOT_FOUND: CONFIGRET = 0x0000000C; pub const CR_NO_SUCH_DEVNODE: CONFIGRET = 0x0000000D; pub const CR_NO_SUCH_DEVINST: CONFIGRET = CR_NO_SUCH_DEVNODE; pub const CR_NO_MORE_LOG_CONF: CONFIGRET = 0x0000000E; pub const CR_NO_MORE_RES_DES: CONFIGRET = 0x0000000F; pub const CR_ALREADY_SUCH_DEVNODE: CONFIGRET = 0x00000010; pub const CR_ALREADY_SUCH_DEVINST: CONFIGRET = CR_ALREADY_SUCH_DEVNODE; pub const CR_INVALID_RANGE_LIST: CONFIGRET = 0x00000011; pub const CR_INVALID_RANGE: CONFIGRET = 0x00000012; pub const CR_FAILURE: CONFIGRET = 0x00000013; pub const CR_NO_SUCH_LOGICAL_DEV: CONFIGRET = 0x00000014; pub const CR_CREATE_BLOCKED: CONFIGRET = 0x00000015; pub const CR_NOT_SYSTEM_VM: CONFIGRET = 0x00000016; pub const CR_REMOVE_VETOED: CONFIGRET = 0x00000017; pub const CR_APM_VETOED: CONFIGRET = 0x00000018; pub const CR_INVALID_LOAD_TYPE: CONFIGRET = 0x00000019; pub const CR_BUFFER_SMALL: CONFIGRET = 0x0000001A; pub const CR_NO_ARBITRATOR: CONFIGRET = 0x0000001B; pub const CR_NO_REGISTRY_HANDLE: CONFIGRET = 0x0000001C; pub const CR_REGISTRY_ERROR: CONFIGRET = 0x0000001D; pub const CR_INVALID_DEVICE_ID: CONFIGRET = 0x0000001E; pub const CR_INVALID_DATA: CONFIGRET = 0x0000001F; pub const CR_INVALID_API: CONFIGRET = 0x00000020; pub const CR_DEVLOADER_NOT_READY: CONFIGRET = 0x00000021; pub const CR_NEED_RESTART: CONFIGRET = 0x00000022; pub const CR_NO_MORE_HW_PROFILES: CONFIGRET = 0x00000023; pub const CR_DEVICE_NOT_THERE: CONFIGRET = 0x00000024; pub const CR_NO_SUCH_VALUE: CONFIGRET = 0x00000025; pub const CR_WRONG_TYPE: CONFIGRET = 0x00000026; pub const CR_INVALID_PRIORITY: CONFIGRET = 0x00000027; pub const CR_NOT_DISABLEABLE: CONFIGRET = 0x00000028; pub const CR_FREE_RESOURCES: CONFIGRET = 0x00000029; pub const CR_QUERY_VETOED: CONFIGRET = 0x0000002A; pub const CR_CANT_SHARE_IRQ: CONFIGRET = 0x0000002B; pub const CR_NO_DEPENDENT: CONFIGRET = 0x0000002C; pub const CR_SAME_RESOURCES: CONFIGRET = 0x0000002D; pub const CR_NO_SUCH_REGISTRY_KEY: CONFIGRET = 0x0000002E; pub const CR_INVALID_MACHINENAME: CONFIGRET = 0x0000002F; pub const CR_REMOTE_COMM_FAILURE: CONFIGRET = 0x00000030; pub const CR_MACHINE_UNAVAILABLE: CONFIGRET = 0x00000031; pub const CR_NO_CM_SERVICES: CONFIGRET = 0x00000032; pub const CR_ACCESS_DENIED: CONFIGRET = 0x00000033; pub const CR_CALL_NOT_IMPLEMENTED: CONFIGRET = 0x00000034; pub const CR_INVALID_PROPERTY: CONFIGRET = 0x00000035; pub const CR_DEVICE_INTERFACE_ACTIVE: CONFIGRET = 0x00000036; pub const CR_NO_SUCH_DEVICE_INTERFACE: CONFIGRET = 0x00000037; pub const CR_INVALID_REFERENCE_STRING: CONFIGRET = 0x00000038; pub const CR_INVALID_CONFLICT_LIST: CONFIGRET = 0x00000039; pub const CR_INVALID_INDEX: CONFIGRET = 0x0000003A; pub const CR_INVALID_STRUCTURE_SIZE: CONFIGRET = 0x0000003B; pub const NUM_CR_RESULTS: CONFIGRET = 0x0000003C; deps/winapi-0.2.5/src/werapi.rs0000644000000000000000000000040712615662007015070 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Function prototypes for Windows Error Reporting (WER) ENUM!{enum WER_REGISTER_FILE_TYPE { WerRegFileTypeUserDocument = 1, WerRegFileTypeOther = 2, WerRegFileTypeMax, }} deps/winapi-0.2.5/src/setupapi.rs0000644000000000000000000017462612615662007015452 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Windows NT Setup and Device Installer services pub const LINE_LEN: usize = 256; pub const MAX_INF_STRING_LENGTH: usize = 4096; pub const MAX_INF_SECTION_NAME_LENGTH: usize = 255; pub const MAX_TITLE_LEN: usize = 60; pub const MAX_INSTRUCTION_LEN: usize = 256; pub const MAX_LABEL_LEN: usize = 30; pub const MAX_SERVICE_NAME_LEN: usize = 256; pub const MAX_SUBTITLE_LEN: usize = 256; pub const SP_MAX_MACHINENAME_LENGTH: usize = ::MAX_PATH + 3; pub type HINF = ::PVOID; STRUCT!{struct INFCONTEXT { Inf: ::PVOID, CurrentInf: ::PVOID, Section: ::UINT, Line: ::UINT, }} pub type PINFCONTEXT = *mut INFCONTEXT; STRUCT!{struct SP_INF_INFORMATION { InfStyle: ::DWORD, InfCount: ::DWORD, VersionData: [::BYTE; ::ANYSIZE_ARRAY], }} pub type PSP_INF_INFORMATION = *mut SP_INF_INFORMATION; STRUCT!{struct SP_ALTPLATFORM_INFO_V2 { cbSize: ::DWORD, Platform: ::DWORD, MajorVersion: ::DWORD, MinorVersion: ::DWORD, ProcessorArchitecture: ::WORD, Reserved: ::WORD, FirstValidatedMajorVersion: ::DWORD, FirstValidatedMinorVersion: ::DWORD, }} UNION!(SP_ALTPLATFORM_INFO_V2, Reserved, Flags, Flags_mut, ::WORD); pub type PSP_ALTPLATFORM_INFO_V2 = *mut SP_ALTPLATFORM_INFO_V2; STRUCT!{struct SP_ALTPLATFORM_INFO_V1 { cbSize: ::DWORD, Platform: ::DWORD, MajorVersion: ::DWORD, MinorVersion: ::DWORD, ProcessorArchitecture: ::WORD, Reserved: ::WORD, }} pub type PSP_ALTPLATFORM_INFO_V1 = *mut SP_ALTPLATFORM_INFO_V1; pub type SP_ALTPLATFORM_INFO = SP_ALTPLATFORM_INFO_V2; pub type PSP_ALTPLATFORM_INFO = PSP_ALTPLATFORM_INFO_V2; pub const SP_ALTPLATFORM_FLAGS_VERSION_RANGE: ::WORD = 0x0001; #[repr(C)] #[derive(Copy)] pub struct SP_ORIGINAL_FILE_INFO_A { pub cbSize: ::DWORD, pub OriginalInfName: [::CHAR; ::MAX_PATH], pub OriginalCatalogName: [::CHAR; ::MAX_PATH], } impl Clone for SP_ORIGINAL_FILE_INFO_A { fn clone(&self) -> SP_ORIGINAL_FILE_INFO_A { *self } } pub type PSP_ORIGINAL_FILE_INFO_A = *mut SP_ORIGINAL_FILE_INFO_A; #[repr(C)] #[derive(Copy)] pub struct SP_ORIGINAL_FILE_INFO_W { pub cbSize: ::DWORD, pub OriginalInfName: [::WCHAR; ::MAX_PATH], pub OriginalCatalogName: [::WCHAR; ::MAX_PATH], } impl Clone for SP_ORIGINAL_FILE_INFO_W { fn clone(&self) -> SP_ORIGINAL_FILE_INFO_W { *self } } pub type PSP_ORIGINAL_FILE_INFO_W = *mut SP_ORIGINAL_FILE_INFO_W; pub const INF_STYLE_NONE: ::DWORD = 0x00000000; pub const INF_STYLE_OLDNT: ::DWORD = 0x00000001; pub const INF_STYLE_WIN4: ::DWORD = 0x00000002; pub const INF_STYLE_CACHE_ENABLE: ::DWORD = 0x00000010; pub const INF_STYLE_CACHE_DISABLE: ::DWORD = 0x00000020; pub const INF_STYLE_CACHE_IGNORE: ::DWORD = 0x00000040; pub const DIRID_ABSOLUTE: ::DWORD = 0 - 1; pub const DIRID_ABSOLUTE_16BIT: ::DWORD = 0xffff; pub const DIRID_NULL: ::DWORD = 0; pub const DIRID_SRCPATH: ::DWORD = 1; pub const DIRID_WINDOWS: ::DWORD = 10; pub const DIRID_SYSTEM: ::DWORD = 11; pub const DIRID_DRIVERS: ::DWORD = 12; pub const DIRID_IOSUBSYS: ::DWORD = DIRID_DRIVERS; pub const DIRID_DRIVER_STORE: ::DWORD = 13; pub const DIRID_INF: ::DWORD = 17; pub const DIRID_HELP: ::DWORD = 18; pub const DIRID_FONTS: ::DWORD = 20; pub const DIRID_VIEWERS: ::DWORD = 21; pub const DIRID_COLOR: ::DWORD = 23; pub const DIRID_APPS: ::DWORD = 24; pub const DIRID_SHARED: ::DWORD = 25; pub const DIRID_BOOT: ::DWORD = 30; pub const DIRID_SYSTEM16: ::DWORD = 50; pub const DIRID_SPOOL: ::DWORD = 51; pub const DIRID_SPOOLDRIVERS: ::DWORD = 52; pub const DIRID_USERPROFILE: ::DWORD = 53; pub const DIRID_LOADER: ::DWORD = 54; pub const DIRID_PRINTPROCESSOR: ::DWORD = 55; pub const DIRID_DEFAULT: ::DWORD = DIRID_SYSTEM; pub const DIRID_COMMON_STARTMENU: ::DWORD = 16406; pub const DIRID_COMMON_PROGRAMS: ::DWORD = 16407; pub const DIRID_COMMON_STARTUP: ::DWORD = 16408; pub const DIRID_COMMON_DESKTOPDIRECTORY: ::DWORD = 16409; pub const DIRID_COMMON_FAVORITES: ::DWORD = 16415; pub const DIRID_COMMON_APPDATA: ::DWORD = 16419; pub const DIRID_PROGRAM_FILES: ::DWORD = 16422; pub const DIRID_SYSTEM_X86: ::DWORD = 16425; pub const DIRID_PROGRAM_FILES_X86: ::DWORD = 16426; pub const DIRID_PROGRAM_FILES_COMMON: ::DWORD = 16427; pub const DIRID_PROGRAM_FILES_COMMONX86: ::DWORD = 16428; pub const DIRID_COMMON_TEMPLATES: ::DWORD = 16429; pub const DIRID_COMMON_DOCUMENTS: ::DWORD = 16430; pub const DIRID_USER: ::DWORD = 0x8000; pub type PSP_FILE_CALLBACK_A = Option ::UINT>; pub type PSP_FILE_CALLBACK_W = Option ::UINT>; pub const SPFILENOTIFY_STARTQUEUE: ::UINT = 0x00000001; pub const SPFILENOTIFY_ENDQUEUE: ::UINT = 0x00000002; pub const SPFILENOTIFY_STARTSUBQUEUE: ::UINT = 0x00000003; pub const SPFILENOTIFY_ENDSUBQUEUE: ::UINT = 0x00000004; pub const SPFILENOTIFY_STARTDELETE: ::UINT = 0x00000005; pub const SPFILENOTIFY_ENDDELETE: ::UINT = 0x00000006; pub const SPFILENOTIFY_DELETEERROR: ::UINT = 0x00000007; pub const SPFILENOTIFY_STARTRENAME: ::UINT = 0x00000008; pub const SPFILENOTIFY_ENDRENAME: ::UINT = 0x00000009; pub const SPFILENOTIFY_RENAMEERROR: ::UINT = 0x0000000a; pub const SPFILENOTIFY_STARTCOPY: ::UINT = 0x0000000b; pub const SPFILENOTIFY_ENDCOPY: ::UINT = 0x0000000c; pub const SPFILENOTIFY_COPYERROR: ::UINT = 0x0000000d; pub const SPFILENOTIFY_NEEDMEDIA: ::UINT = 0x0000000e; pub const SPFILENOTIFY_QUEUESCAN: ::UINT = 0x0000000f; pub const SPFILENOTIFY_CABINETINFO: ::UINT = 0x00000010; pub const SPFILENOTIFY_FILEINCABINET: ::UINT = 0x00000011; pub const SPFILENOTIFY_NEEDNEWCABINET: ::UINT = 0x00000012; pub const SPFILENOTIFY_FILEEXTRACTED: ::UINT = 0x00000013; pub const SPFILENOTIFY_FILEOPDELAYED: ::UINT = 0x00000014; pub const SPFILENOTIFY_STARTBACKUP: ::UINT = 0x00000015; pub const SPFILENOTIFY_BACKUPERROR: ::UINT = 0x00000016; pub const SPFILENOTIFY_ENDBACKUP: ::UINT = 0x00000017; pub const SPFILENOTIFY_QUEUESCAN_EX: ::UINT = 0x00000018; pub const SPFILENOTIFY_STARTREGISTRATION: ::UINT = 0x00000019; pub const SPFILENOTIFY_ENDREGISTRATION: ::UINT = 0x00000020; pub const SPFILENOTIFY_QUEUESCAN_SIGNERINFO: ::UINT = 0x00000040; pub const SPFILENOTIFY_LANGMISMATCH: ::UINT = 0x00010000; pub const SPFILENOTIFY_TARGETEXISTS: ::UINT = 0x00020000; pub const SPFILENOTIFY_TARGETNEWER: ::UINT = 0x00040000; pub const FILEOP_COPY: ::UINT = 0; pub const FILEOP_RENAME: ::UINT = 1; pub const FILEOP_DELETE: ::UINT = 2; pub const FILEOP_BACKUP: ::UINT = 3; pub const FILEOP_ABORT: ::UINT = 0; pub const FILEOP_DOIT: ::UINT = 1; pub const FILEOP_SKIP: ::UINT = 2; pub const FILEOP_RETRY: ::UINT = FILEOP_DOIT; pub const FILEOP_NEWPATH: ::UINT = 4; pub const COPYFLG_WARN_IF_SKIP: ::UINT = 0x00000001; pub const COPYFLG_NOSKIP: ::UINT = 0x00000002; pub const COPYFLG_NOVERSIONCHECK: ::UINT = 0x00000004; pub const COPYFLG_FORCE_FILE_IN_USE: ::UINT = 0x00000008; pub const COPYFLG_NO_OVERWRITE: ::UINT = 0x00000010; pub const COPYFLG_NO_VERSION_DIALOG: ::UINT = 0x00000020; pub const COPYFLG_OVERWRITE_OLDER_ONLY: ::UINT = 0x00000040; pub const COPYFLG_PROTECTED_WINDOWS_DRIVER_FILE: ::UINT = 0x00000100; pub const COPYFLG_REPLACEONLY: ::UINT = 0x00000400; pub const COPYFLG_NODECOMP: ::UINT = 0x00000800; pub const COPYFLG_REPLACE_BOOT_FILE: ::UINT = 0x00001000; pub const COPYFLG_NOPRUNE: ::UINT = 0x00002000; pub const COPYFLG_IN_USE_TRY_RENAME: ::UINT = 0x00004000; pub const DELFLG_IN_USE: ::UINT = 0x00000001; pub const DELFLG_IN_USE1: ::UINT = 0x00010000; STRUCT!{struct FILEPATHS_A { Target: ::PCSTR, Source: ::PCSTR, Win32Error: ::UINT, Flags: ::DWORD, }} pub type PFILEPATHS_A = *mut FILEPATHS_A; STRUCT!{struct FILEPATHS_W { Target: ::PCWSTR, Source: ::PCWSTR, Win32Error: ::UINT, Flags: ::DWORD, }} pub type PFILEPATHS_W = *mut FILEPATHS_W; STRUCT!{struct FILEPATHS_SIGNERINFO_A { Target: ::PCSTR, Source: ::PCSTR, Win32Error: ::UINT, Flags: ::DWORD, DigitalSigner: ::PCSTR, Version: ::PCSTR, CatalogFile: ::PCSTR, }} pub type PFILEPATHS_SIGNERINFO_A = *mut FILEPATHS_SIGNERINFO_A; STRUCT!{struct FILEPATHS_SIGNERINFO_W { Target: ::PCWSTR, Source: ::PCWSTR, Win32Error: ::UINT, Flags: ::DWORD, DigitalSigner: ::PCWSTR, Version: ::PCWSTR, CatalogFile: ::PCWSTR, }} pub type PFILEPATHS_SIGNERINFO_W = *mut FILEPATHS_SIGNERINFO_W; STRUCT!{struct SOURCE_MEDIA_A { Reserved: ::PCSTR, Tagfile: ::PCSTR, Description: ::PCSTR, SourcePath: ::PCSTR, SourceFile: ::PCSTR, Flags: ::DWORD, }} pub type PSOURCE_MEDIA_A = *mut SOURCE_MEDIA_A; STRUCT!{struct SOURCE_MEDIA_W { Reserved: ::PCWSTR, Tagfile: ::PCWSTR, Description: ::PCWSTR, SourcePath: ::PCWSTR, SourceFile: ::PCWSTR, Flags: ::DWORD, }} pub type PSOURCE_MEDIA_W = *mut SOURCE_MEDIA_W; STRUCT!{struct CABINET_INFO_A { CabinetPath: ::PCSTR, CabinetFile: ::PCSTR, DiskName: ::PCSTR, SetId: ::USHORT, CabinetNumber: ::USHORT, }} pub type PCABINET_INFO_A = *mut CABINET_INFO_A; STRUCT!{struct CABINET_INFO_W { CabinetPath: ::PCWSTR, CabinetFile: ::PCWSTR, DiskName: ::PCWSTR, SetId: ::USHORT, CabinetNumber: ::USHORT, }} pub type PCABINET_INFO_W = *mut CABINET_INFO_W; #[repr(C)] #[derive(Copy)] pub struct FILE_IN_CABINET_INFO_A { pub NameInCabinet: ::PCSTR, pub FileSize: ::DWORD, pub Win32Error: ::DWORD, pub DosDate: ::WORD, pub DosTime: ::WORD, pub DosAttribs: ::WORD, pub FullTargetName: [::CHAR; ::MAX_PATH], } impl Clone for FILE_IN_CABINET_INFO_A { fn clone(&self) -> FILE_IN_CABINET_INFO_A { *self } } pub type PFILE_IN_CABINET_INFO_A = *mut FILE_IN_CABINET_INFO_A; #[repr(C)] #[derive(Copy)] pub struct FILE_IN_CABINET_INFO_W { pub NameInCabinet: ::PCWSTR, pub FileSize: ::DWORD, pub Win32Error: ::DWORD, pub DosDate: ::WORD, pub DosTime: ::WORD, pub DosAttribs: ::WORD, pub FullTargetName: [::WCHAR; ::MAX_PATH], } impl Clone for FILE_IN_CABINET_INFO_W { fn clone(&self) -> FILE_IN_CABINET_INFO_W { *self } } pub type PFILE_IN_CABINET_INFO_W = *mut FILE_IN_CABINET_INFO_W; STRUCT!{struct SP_REGISTER_CONTROL_STATUSA { cbSize: ::DWORD, FileName: ::PCSTR, Win32Error: ::DWORD, FailureCode: ::DWORD, }} pub type PSP_REGISTER_CONTROL_STATUSA = *mut SP_REGISTER_CONTROL_STATUSA; STRUCT!{struct SP_REGISTER_CONTROL_STATUSW { cbSize: ::DWORD, FileName: ::PCWSTR, Win32Error: ::DWORD, FailureCode: ::DWORD, }} pub type PSP_REGISTER_CONTROL_STATUSW = *mut SP_REGISTER_CONTROL_STATUSW; pub const SPREG_SUCCESS: ::DWORD = 0x00000000; pub const SPREG_LOADLIBRARY: ::DWORD = 0x00000001; pub const SPREG_GETPROCADDR: ::DWORD = 0x00000002; pub const SPREG_REGSVR: ::DWORD = 0x00000003; pub const SPREG_DLLINSTALL: ::DWORD = 0x00000004; pub const SPREG_TIMEOUT: ::DWORD = 0x00000005; pub const SPREG_UNKNOWN: ::DWORD = 0xFFFFFFFF; pub type HSPFILEQ = ::PVOID; STRUCT!{struct SP_FILE_COPY_PARAMS_A { cbSize: ::DWORD, QueueHandle: HSPFILEQ, SourceRootPath: ::PCSTR, SourcePath: ::PCSTR, SourceFilename: ::PCSTR, SourceDescription: ::PCSTR, SourceTagfile: ::PCSTR, TargetDirectory: ::PCSTR, TargetFilename: ::PCSTR, CopyStyle: ::DWORD, LayoutInf: HINF, SecurityDescriptor: ::PCSTR, }} pub type PSP_FILE_COPY_PARAMS_A = *mut SP_FILE_COPY_PARAMS_A; STRUCT!{struct SP_FILE_COPY_PARAMS_W { cbSize: ::DWORD, QueueHandle: HSPFILEQ, SourceRootPath: ::PCWSTR, SourcePath: ::PCWSTR, SourceFilename: ::PCWSTR, SourceDescription: ::PCWSTR, SourceTagfile: ::PCWSTR, TargetDirectory: ::PCWSTR, TargetFilename: ::PCWSTR, CopyStyle: ::DWORD, LayoutInf: HINF, SecurityDescriptor: ::PCWSTR, }} pub type PSP_FILE_COPY_PARAMS_W = *mut SP_FILE_COPY_PARAMS_W; pub type HDSKSPC = ::PVOID; pub type HDEVINFO = ::PVOID; STRUCT!{struct SP_DEVINFO_DATA { cbSize: ::DWORD, ClassGuid: ::GUID, DevInst: ::DWORD, Reserved: ::ULONG_PTR, }} pub type PSP_DEVINFO_DATA = *mut SP_DEVINFO_DATA; STRUCT!{struct SP_DEVICE_INTERFACE_DATA { cbSize: ::DWORD, InterfaceClassGuid: ::GUID, Flags: ::DWORD, Reserved: ::ULONG_PTR, }} pub type PSP_DEVICE_INTERFACE_DATA = *mut SP_DEVICE_INTERFACE_DATA; pub const SPINT_ACTIVE: ::DWORD = 0x00000001; pub const SPINT_DEFAULT: ::DWORD = 0x00000002; pub const SPINT_REMOVED: ::DWORD = 0x00000004; pub type SP_INTERFACE_DEVICE_DATA = SP_DEVICE_INTERFACE_DATA; pub type PSP_INTERFACE_DEVICE_DATA = PSP_DEVICE_INTERFACE_DATA; pub const SPID_ACTIVE: ::DWORD = SPINT_ACTIVE; pub const SPID_DEFAULT: ::DWORD = SPINT_DEFAULT; pub const SPID_REMOVED: ::DWORD = SPINT_REMOVED; STRUCT!{struct SP_DEVICE_INTERFACE_DETAIL_DATA_A { cbSize: ::DWORD, DevicePath: [::CHAR; ::ANYSIZE_ARRAY], }} pub type PSP_DEVICE_INTERFACE_DETAIL_DATA_A = *mut SP_DEVICE_INTERFACE_DETAIL_DATA_A; STRUCT!{struct SP_DEVICE_INTERFACE_DETAIL_DATA_W { cbSize: ::DWORD, DevicePath: [::WCHAR; ::ANYSIZE_ARRAY], }} pub type PSP_DEVICE_INTERFACE_DETAIL_DATA_W = *mut SP_DEVICE_INTERFACE_DETAIL_DATA_W; #[repr(C)] #[derive(Copy)] pub struct SP_DEVINFO_LIST_DETAIL_DATA_A { pub cbSize: ::DWORD, pub ClassGuid: ::GUID, pub RemoteMachineHandle: ::HANDLE, pub RemoteMachineName: [::CHAR; SP_MAX_MACHINENAME_LENGTH], } impl Clone for SP_DEVINFO_LIST_DETAIL_DATA_A { fn clone(&self) -> SP_DEVINFO_LIST_DETAIL_DATA_A { *self } } pub type PSP_DEVINFO_LIST_DETAIL_DATA_A = *mut SP_DEVINFO_LIST_DETAIL_DATA_A; #[repr(C)] #[derive(Copy)] pub struct SP_DEVINFO_LIST_DETAIL_DATA_W { pub cbSize: ::DWORD, pub ClassGuid: ::GUID, pub RemoteMachineHandle: ::HANDLE, pub RemoteMachineName: [::WCHAR; SP_MAX_MACHINENAME_LENGTH], } impl Clone for SP_DEVINFO_LIST_DETAIL_DATA_W { fn clone(&self) -> SP_DEVINFO_LIST_DETAIL_DATA_W { *self } } pub type PSP_DEVINFO_LIST_DETAIL_DATA_W = *mut SP_DEVINFO_LIST_DETAIL_DATA_W; pub const DIF_SELECTDEVICE: DI_FUNCTION = 0x00000001; pub const DIF_INSTALLDEVICE: DI_FUNCTION = 0x00000002; pub const DIF_ASSIGNRESOURCES: DI_FUNCTION = 0x00000003; pub const DIF_PROPERTIES: DI_FUNCTION = 0x00000004; pub const DIF_REMOVE: DI_FUNCTION = 0x00000005; pub const DIF_FIRSTTIMESETUP: DI_FUNCTION = 0x00000006; pub const DIF_FOUNDDEVICE: DI_FUNCTION = 0x00000007; pub const DIF_SELECTCLASSDRIVERS: DI_FUNCTION = 0x00000008; pub const DIF_VALIDATECLASSDRIVERS: DI_FUNCTION = 0x00000009; pub const DIF_INSTALLCLASSDRIVERS: DI_FUNCTION = 0x0000000A; pub const DIF_CALCDISKSPACE: DI_FUNCTION = 0x0000000B; pub const DIF_DESTROYPRIVATEDATA: DI_FUNCTION = 0x0000000C; pub const DIF_VALIDATEDRIVER: DI_FUNCTION = 0x0000000D; pub const DIF_DETECT: DI_FUNCTION = 0x0000000F; pub const DIF_INSTALLWIZARD: DI_FUNCTION = 0x00000010; pub const DIF_DESTROYWIZARDDATA: DI_FUNCTION = 0x00000011; pub const DIF_PROPERTYCHANGE: DI_FUNCTION = 0x00000012; pub const DIF_ENABLECLASS: DI_FUNCTION = 0x00000013; pub const DIF_DETECTVERIFY: DI_FUNCTION = 0x00000014; pub const DIF_INSTALLDEVICEFILES: DI_FUNCTION = 0x00000015; pub const DIF_UNREMOVE: DI_FUNCTION = 0x00000016; pub const DIF_SELECTBESTCOMPATDRV: DI_FUNCTION = 0x00000017; pub const DIF_ALLOW_INSTALL: DI_FUNCTION = 0x00000018; pub const DIF_REGISTERDEVICE: DI_FUNCTION = 0x00000019; pub const DIF_NEWDEVICEWIZARD_PRESELECT: DI_FUNCTION = 0x0000001A; pub const DIF_NEWDEVICEWIZARD_SELECT: DI_FUNCTION = 0x0000001B; pub const DIF_NEWDEVICEWIZARD_PREANALYZE: DI_FUNCTION = 0x0000001C; pub const DIF_NEWDEVICEWIZARD_POSTANALYZE: DI_FUNCTION = 0x0000001D; pub const DIF_NEWDEVICEWIZARD_FINISHINSTALL: DI_FUNCTION = 0x0000001E; pub const DIF_UNUSED1: DI_FUNCTION = 0x0000001F; pub const DIF_INSTALLINTERFACES: DI_FUNCTION = 0x00000020; pub const DIF_DETECTCANCEL: DI_FUNCTION = 0x00000021; pub const DIF_REGISTER_COINSTALLERS: DI_FUNCTION = 0x00000022; pub const DIF_ADDPROPERTYPAGE_ADVANCED: DI_FUNCTION = 0x00000023; pub const DIF_ADDPROPERTYPAGE_BASIC: DI_FUNCTION = 0x00000024; pub const DIF_RESERVED1: DI_FUNCTION = 0x00000025; pub const DIF_TROUBLESHOOTER: DI_FUNCTION = 0x00000026; pub const DIF_POWERMESSAGEWAKE: DI_FUNCTION = 0x00000027; pub const DIF_ADDREMOTEPROPERTYPAGE_ADVANCED: DI_FUNCTION = 0x00000028; pub const DIF_UPDATEDRIVER_UI: DI_FUNCTION = 0x00000029; pub const DIF_FINISHINSTALL_ACTION: DI_FUNCTION = 0x0000002A; pub const DIF_RESERVED2: DI_FUNCTION = 0x00000030; pub const DIF_MOVEDEVICE: DI_FUNCTION = 0x0000000E; pub type DI_FUNCTION = ::UINT; #[repr(C)] #[derive(Copy)] pub struct SP_DEVINSTALL_PARAMS_A { pub cbSize: ::DWORD, pub Flags: ::DWORD, pub FlagsEx: ::DWORD, pub hwndParent: ::HWND, pub InstallMsgHandler: PSP_FILE_CALLBACK_A, pub InstallMsgHandlerContext: ::PVOID, pub FileQueue: HSPFILEQ, pub ClassInstallReserved: ::ULONG_PTR, pub Reserved: ::DWORD, pub DriverPath: [::CHAR; ::MAX_PATH], } impl Clone for SP_DEVINSTALL_PARAMS_A { fn clone(&self) -> SP_DEVINSTALL_PARAMS_A { *self } } pub type PSP_DEVINSTALL_PARAMS_A = *mut SP_DEVINSTALL_PARAMS_A; #[repr(C)] #[derive(Copy)] pub struct SP_DEVINSTALL_PARAMS_W { pub cbSize: ::DWORD, pub Flags: ::DWORD, pub FlagsEx: ::DWORD, pub hwndParent: ::HWND, pub InstallMsgHandler: PSP_FILE_CALLBACK_W, pub InstallMsgHandlerContext: ::PVOID, pub FileQueue: HSPFILEQ, pub ClassInstallReserved: ::ULONG_PTR, pub Reserved: ::DWORD, pub DriverPath: [::WCHAR; ::MAX_PATH], } impl Clone for SP_DEVINSTALL_PARAMS_W { fn clone(&self) -> SP_DEVINSTALL_PARAMS_W { *self } } pub type PSP_DEVINSTALL_PARAMS_W = *mut SP_DEVINSTALL_PARAMS_W; pub const DI_SHOWOEM: ::DWORD = 0x00000001; pub const DI_SHOWCOMPAT: ::DWORD = 0x00000002; pub const DI_SHOWCLASS: ::DWORD = 0x00000004; pub const DI_SHOWALL: ::DWORD = 0x00000007; pub const DI_NOVCP: ::DWORD = 0x00000008; pub const DI_DIDCOMPAT: ::DWORD = 0x00000010; pub const DI_DIDCLASS: ::DWORD = 0x00000020; pub const DI_AUTOASSIGNRES: ::DWORD = 0x00000040; pub const DI_NEEDRESTART: ::DWORD = 0x00000080; pub const DI_NEEDREBOOT: ::DWORD = 0x00000100; pub const DI_NOBROWSE: ::DWORD = 0x00000200; pub const DI_MULTMFGS: ::DWORD = 0x00000400; pub const DI_DISABLED: ::DWORD = 0x00000800; pub const DI_GENERALPAGE_ADDED: ::DWORD = 0x00001000; pub const DI_RESOURCEPAGE_ADDED: ::DWORD = 0x00002000; pub const DI_PROPERTIES_CHANGE: ::DWORD = 0x00004000; pub const DI_INF_IS_SORTED: ::DWORD = 0x00008000; pub const DI_ENUMSINGLEINF: ::DWORD = 0x00010000; pub const DI_DONOTCALLCONFIGMG: ::DWORD = 0x00020000; pub const DI_INSTALLDISABLED: ::DWORD = 0x00040000; pub const DI_COMPAT_FROM_CLASS: ::DWORD = 0x00080000; pub const DI_CLASSINSTALLPARAMS: ::DWORD = 0x00100000; pub const DI_NODI_DEFAULTACTION: ::DWORD = 0x00200000; pub const DI_QUIETINSTALL: ::DWORD = 0x00800000; pub const DI_NOFILECOPY: ::DWORD = 0x01000000; pub const DI_FORCECOPY: ::DWORD = 0x02000000; pub const DI_DRIVERPAGE_ADDED: ::DWORD = 0x04000000; pub const DI_USECI_SELECTSTRINGS: ::DWORD = 0x08000000; pub const DI_OVERRIDE_INFFLAGS: ::DWORD = 0x10000000; pub const DI_PROPS_NOCHANGEUSAGE: ::DWORD = 0x20000000; pub const DI_NOSELECTICONS: ::DWORD = 0x40000000; pub const DI_NOWRITE_IDS: ::DWORD = 0x80000000; pub const DI_FLAGSEX_RESERVED2: ::DWORD = 0x00000001; pub const DI_FLAGSEX_RESERVED3: ::DWORD = 0x00000002; pub const DI_FLAGSEX_CI_FAILED: ::DWORD = 0x00000004; pub const DI_FLAGSEX_FINISHINSTALL_ACTION: ::DWORD = 0x00000008; pub const DI_FLAGSEX_DIDINFOLIST: ::DWORD = 0x00000010; pub const DI_FLAGSEX_DIDCOMPATINFO: ::DWORD = 0x00000020; pub const DI_FLAGSEX_FILTERCLASSES: ::DWORD = 0x00000040; pub const DI_FLAGSEX_SETFAILEDINSTALL: ::DWORD = 0x00000080; pub const DI_FLAGSEX_DEVICECHANGE: ::DWORD = 0x00000100; pub const DI_FLAGSEX_ALWAYSWRITEIDS: ::DWORD = 0x00000200; pub const DI_FLAGSEX_PROPCHANGE_PENDING: ::DWORD = 0x00000400; pub const DI_FLAGSEX_ALLOWEXCLUDEDDRVS: ::DWORD = 0x00000800; pub const DI_FLAGSEX_NOUIONQUERYREMOVE: ::DWORD = 0x00001000; pub const DI_FLAGSEX_USECLASSFORCOMPAT: ::DWORD = 0x00002000; pub const DI_FLAGSEX_RESERVED4: ::DWORD = 0x00004000; pub const DI_FLAGSEX_NO_DRVREG_MODIFY: ::DWORD = 0x00008000; pub const DI_FLAGSEX_IN_SYSTEM_SETUP: ::DWORD = 0x00010000; pub const DI_FLAGSEX_INET_DRIVER: ::DWORD = 0x00020000; pub const DI_FLAGSEX_APPENDDRIVERLIST: ::DWORD = 0x00040000; pub const DI_FLAGSEX_PREINSTALLBACKUP: ::DWORD = 0x00080000; pub const DI_FLAGSEX_BACKUPONREPLACE: ::DWORD = 0x00100000; pub const DI_FLAGSEX_DRIVERLIST_FROM_URL: ::DWORD = 0x00200000; pub const DI_FLAGSEX_RESERVED1: ::DWORD = 0x00400000; pub const DI_FLAGSEX_EXCLUDE_OLD_INET_DRIVERS: ::DWORD = 0x00800000; pub const DI_FLAGSEX_POWERPAGE_ADDED: ::DWORD = 0x01000000; pub const DI_FLAGSEX_FILTERSIMILARDRIVERS: ::DWORD = 0x02000000; pub const DI_FLAGSEX_INSTALLEDDRIVER: ::DWORD = 0x04000000; pub const DI_FLAGSEX_NO_CLASSLIST_NODE_MERGE: ::DWORD = 0x08000000; pub const DI_FLAGSEX_ALTPLATFORM_DRVSEARCH: ::DWORD = 0x10000000; pub const DI_FLAGSEX_RESTART_DEVICE_ONLY: ::DWORD = 0x20000000; pub const DI_FLAGSEX_RECURSIVESEARCH: ::DWORD = 0x40000000; pub const DI_FLAGSEX_SEARCH_PUBLISHED_INFS: ::DWORD = 0x80000000; STRUCT!{struct SP_CLASSINSTALL_HEADER { cbSize: ::DWORD, InstallFunction: DI_FUNCTION, }} pub type PSP_CLASSINSTALL_HEADER = *mut SP_CLASSINSTALL_HEADER; STRUCT!{struct SP_ENABLECLASS_PARAMS { ClassInstallHeader: SP_CLASSINSTALL_HEADER, ClassGuid: ::GUID, EnableMessage: ::DWORD, }} pub type PSP_ENABLECLASS_PARAMS = *mut SP_ENABLECLASS_PARAMS; pub const ENABLECLASS_QUERY: ::DWORD = 0; pub const ENABLECLASS_SUCCESS: ::DWORD = 1; pub const ENABLECLASS_FAILURE: ::DWORD = 2; pub const DICS_ENABLE: ::DWORD = 0x00000001; pub const DICS_DISABLE: ::DWORD = 0x00000002; pub const DICS_PROPCHANGE: ::DWORD = 0x00000003; pub const DICS_START: ::DWORD = 0x00000004; pub const DICS_STOP: ::DWORD = 0x00000005; pub const DICS_FLAG_GLOBAL: ::DWORD = 0x00000001; pub const DICS_FLAG_CONFIGSPECIFIC: ::DWORD = 0x00000002; pub const DICS_FLAG_CONFIGGENERAL: ::DWORD = 0x00000004; STRUCT!{struct SP_PROPCHANGE_PARAMS { ClassInstallHeader: SP_CLASSINSTALL_HEADER, StateChange: ::DWORD, Scope: ::DWORD, HwProfile: ::DWORD, }} pub type PSP_PROPCHANGE_PARAMS = *mut SP_PROPCHANGE_PARAMS; STRUCT!{struct SP_REMOVEDEVICE_PARAMS { ClassInstallHeader: SP_CLASSINSTALL_HEADER, Scope: ::DWORD, HwProfile: ::DWORD, }} pub type PSP_REMOVEDEVICE_PARAMS = *mut SP_REMOVEDEVICE_PARAMS; pub const DI_REMOVEDEVICE_GLOBAL: ::DWORD = 0x00000001; pub const DI_REMOVEDEVICE_CONFIGSPECIFIC: ::DWORD = 0x00000002; STRUCT!{struct SP_UNREMOVEDEVICE_PARAMS { ClassInstallHeader: SP_CLASSINSTALL_HEADER, Scope: ::DWORD, HwProfile: ::DWORD, }} pub type PSP_UNREMOVEDEVICE_PARAMS = *mut SP_UNREMOVEDEVICE_PARAMS; pub const DI_UNREMOVEDEVICE_CONFIGSPECIFIC: ::DWORD = 0x00000002; #[repr(C)] #[derive(Copy)] pub struct SP_SELECTDEVICE_PARAMS_A { pub ClassInstallHeader: SP_CLASSINSTALL_HEADER, pub Title: [::CHAR; MAX_TITLE_LEN], pub Instructions: [::CHAR; MAX_INSTRUCTION_LEN], pub ListLabel: [::CHAR; MAX_LABEL_LEN], pub SubTitle: [::CHAR; MAX_SUBTITLE_LEN], pub Reserved: [::BYTE; 2], } impl Clone for SP_SELECTDEVICE_PARAMS_A { fn clone(&self) -> SP_SELECTDEVICE_PARAMS_A { *self } } pub type PSP_SELECTDEVICE_PARAMS_A = *mut SP_SELECTDEVICE_PARAMS_A; #[repr(C)] #[derive(Copy)] pub struct SP_SELECTDEVICE_PARAMS_W { pub ClassInstallHeader: SP_CLASSINSTALL_HEADER, pub Title: [::WCHAR; MAX_TITLE_LEN], pub Instructions: [::WCHAR; MAX_INSTRUCTION_LEN], pub ListLabel: [::WCHAR; MAX_LABEL_LEN], pub SubTitle: [::WCHAR; MAX_SUBTITLE_LEN], } impl Clone for SP_SELECTDEVICE_PARAMS_W { fn clone(&self) -> SP_SELECTDEVICE_PARAMS_W { *self } } pub type PSP_SELECTDEVICE_PARAMS_W = *mut SP_SELECTDEVICE_PARAMS_W; pub type PDETECT_PROGRESS_NOTIFY = Option ::BOOL>; #[repr(C)] #[derive(Copy)] pub struct SP_DETECTDEVICE_PARAMS { pub ClassInstallHeader: SP_CLASSINSTALL_HEADER, pub DetectProgressNotify: PDETECT_PROGRESS_NOTIFY, pub ProgressNotifyParam: ::PVOID, } impl Clone for SP_DETECTDEVICE_PARAMS { fn clone(&self) -> SP_DETECTDEVICE_PARAMS { *self } } pub type PSP_DETECTDEVICE_PARAMS = *mut SP_DETECTDEVICE_PARAMS; pub const MAX_INSTALLWIZARD_DYNAPAGES: usize = 20; STRUCT!{struct SP_INSTALLWIZARD_DATA { ClassInstallHeader: SP_CLASSINSTALL_HEADER, Flags: ::DWORD, DynamicPages: [::HPROPSHEETPAGE; MAX_INSTALLWIZARD_DYNAPAGES], NumDynamicPages: ::DWORD, DynamicPageFlags: ::DWORD, PrivateFlags: ::DWORD, PrivateData: ::LPARAM, hwndWizardDlg: ::HWND, }} pub type PSP_INSTALLWIZARD_DATA = *mut SP_INSTALLWIZARD_DATA; pub const NDW_INSTALLFLAG_DIDFACTDEFS: ::DWORD = 0x00000001; pub const NDW_INSTALLFLAG_HARDWAREALLREADYIN: ::DWORD = 0x00000002; pub const NDW_INSTALLFLAG_NEEDRESTART: ::DWORD = DI_NEEDRESTART; pub const NDW_INSTALLFLAG_NEEDREBOOT: ::DWORD = DI_NEEDREBOOT; pub const NDW_INSTALLFLAG_NEEDSHUTDOWN: ::DWORD = 0x00000200; pub const NDW_INSTALLFLAG_EXPRESSINTRO: ::DWORD = 0x00000400; pub const NDW_INSTALLFLAG_SKIPISDEVINSTALLED: ::DWORD = 0x00000800; pub const NDW_INSTALLFLAG_NODETECTEDDEVS: ::DWORD = 0x00001000; pub const NDW_INSTALLFLAG_INSTALLSPECIFIC: ::DWORD = 0x00002000; pub const NDW_INSTALLFLAG_SKIPCLASSLIST: ::DWORD = 0x00004000; pub const NDW_INSTALLFLAG_CI_PICKED_OEM: ::DWORD = 0x00008000; pub const NDW_INSTALLFLAG_PCMCIAMODE: ::DWORD = 0x00010000; pub const NDW_INSTALLFLAG_PCMCIADEVICE: ::DWORD = 0x00020000; pub const NDW_INSTALLFLAG_USERCANCEL: ::DWORD = 0x00040000; pub const NDW_INSTALLFLAG_KNOWNCLASS: ::DWORD = 0x00080000; pub const DYNAWIZ_FLAG_PAGESADDED: ::DWORD = 0x00000001; pub const DYNAWIZ_FLAG_ANALYZE_HANDLECONFLICT: ::DWORD = 0x00000008; pub const DYNAWIZ_FLAG_INSTALLDET_NEXT: ::DWORD = 0x00000002; pub const DYNAWIZ_FLAG_INSTALLDET_PREV: ::DWORD = 0x00000004; pub const MIN_IDD_DYNAWIZ_RESOURCE_ID: ::c_int = 10000; pub const MAX_IDD_DYNAWIZ_RESOURCE_ID: ::c_int = 11000; pub const IDD_DYNAWIZ_FIRSTPAGE: ::c_int = 10000; pub const IDD_DYNAWIZ_SELECT_PREVPAGE: ::c_int = 10001; pub const IDD_DYNAWIZ_SELECT_NEXTPAGE: ::c_int = 10002; pub const IDD_DYNAWIZ_ANALYZE_PREVPAGE: ::c_int = 10003; pub const IDD_DYNAWIZ_ANALYZE_NEXTPAGE: ::c_int = 10004; pub const IDD_DYNAWIZ_SELECTDEV_PAGE: ::c_int = 10009; pub const IDD_DYNAWIZ_ANALYZEDEV_PAGE: ::c_int = 10010; pub const IDD_DYNAWIZ_INSTALLDETECTEDDEVS_PAGE: ::c_int = 10011; pub const IDD_DYNAWIZ_SELECTCLASS_PAGE: ::c_int = 10012; pub const IDD_DYNAWIZ_INSTALLDETECTED_PREVPAGE: ::c_int = 10006; pub const IDD_DYNAWIZ_INSTALLDETECTED_NEXTPAGE: ::c_int = 10007; pub const IDD_DYNAWIZ_INSTALLDETECTED_NODEVS: ::c_int = 10008; STRUCT!{struct SP_NEWDEVICEWIZARD_DATA { ClassInstallHeader: SP_CLASSINSTALL_HEADER, Flags: ::DWORD, DynamicPages: [::HPROPSHEETPAGE; MAX_INSTALLWIZARD_DYNAPAGES], NumDynamicPages: ::DWORD, hwndWizardDlg: ::HWND, }} pub type PSP_NEWDEVICEWIZARD_DATA = *mut SP_NEWDEVICEWIZARD_DATA; pub type SP_ADDPROPERTYPAGE_DATA = SP_NEWDEVICEWIZARD_DATA; pub type PSP_ADDPROPERTYPAGE_DATA = PSP_NEWDEVICEWIZARD_DATA; #[repr(C)] #[derive(Copy)] pub struct SP_TROUBLESHOOTER_PARAMS_A { pub ClassInstallHeader: SP_CLASSINSTALL_HEADER, pub ChmFile: [::CHAR; ::MAX_PATH], pub HtmlTroubleShooter: [::CHAR; ::MAX_PATH], } impl Clone for SP_TROUBLESHOOTER_PARAMS_A { fn clone(&self) -> SP_TROUBLESHOOTER_PARAMS_A { *self } } pub type PSP_TROUBLESHOOTER_PARAMS_A = *mut SP_TROUBLESHOOTER_PARAMS_A; #[repr(C)] #[derive(Copy)] pub struct SP_TROUBLESHOOTER_PARAMS_W { pub ClassInstallHeader: SP_CLASSINSTALL_HEADER, pub ChmFile: [::WCHAR; ::MAX_PATH], pub HtmlTroubleShooter: [::WCHAR; ::MAX_PATH], } impl Clone for SP_TROUBLESHOOTER_PARAMS_W { fn clone(&self) -> SP_TROUBLESHOOTER_PARAMS_W { *self } } pub type PSP_TROUBLESHOOTER_PARAMS_W = *mut SP_TROUBLESHOOTER_PARAMS_W; #[repr(C)] #[derive(Copy)] pub struct SP_POWERMESSAGEWAKE_PARAMS_A { pub ClassInstallHeader: SP_CLASSINSTALL_HEADER, pub PowerMessageWake: [::CHAR; LINE_LEN * 2], } impl Clone for SP_POWERMESSAGEWAKE_PARAMS_A { fn clone(&self) -> SP_POWERMESSAGEWAKE_PARAMS_A { *self } } pub type PSP_POWERMESSAGEWAKE_PARAMS_A = *mut SP_POWERMESSAGEWAKE_PARAMS_A; #[repr(C)] #[derive(Copy)] pub struct SP_POWERMESSAGEWAKE_PARAMS_W { pub ClassInstallHeader: SP_CLASSINSTALL_HEADER, pub PowerMessageWake: [::WCHAR; LINE_LEN * 2], } impl Clone for SP_POWERMESSAGEWAKE_PARAMS_W { fn clone(&self) -> SP_POWERMESSAGEWAKE_PARAMS_W { *self } } pub type PSP_POWERMESSAGEWAKE_PARAMS_W = *mut SP_POWERMESSAGEWAKE_PARAMS_W; #[repr(C)] #[derive(Copy)] pub struct SP_DRVINFO_DATA_V2_A { pub cbSize: ::DWORD, pub DriverType: ::DWORD, pub Reserved: ::ULONG_PTR, pub Description: [::CHAR; LINE_LEN], pub MfgName: [::CHAR; LINE_LEN], pub ProviderName: [::CHAR; LINE_LEN], pub DriverDate: ::FILETIME, pub DriverVersion: ::DWORDLONG, } impl Clone for SP_DRVINFO_DATA_V2_A { fn clone(&self) -> SP_DRVINFO_DATA_V2_A { *self } } pub type PSP_DRVINFO_DATA_V2_A = *mut SP_DRVINFO_DATA_V2_A; #[repr(C)] #[derive(Copy)] pub struct SP_DRVINFO_DATA_V2_W { pub cbSize: ::DWORD, pub DriverType: ::DWORD, pub Reserved: ::ULONG_PTR, pub Description: [::WCHAR; LINE_LEN], pub MfgName: [::WCHAR; LINE_LEN], pub ProviderName: [::WCHAR; LINE_LEN], pub DriverDate: ::FILETIME, pub DriverVersion: ::DWORDLONG, } impl Clone for SP_DRVINFO_DATA_V2_W { fn clone(&self) -> SP_DRVINFO_DATA_V2_W { *self } } pub type PSP_DRVINFO_DATA_V2_W = *mut SP_DRVINFO_DATA_V2_W; #[repr(C)] #[derive(Copy)] pub struct SP_DRVINFO_DATA_V1_A { pub cbSize: ::DWORD, pub DriverType: ::DWORD, pub Reserved: ::ULONG_PTR, pub Description: [::CHAR; LINE_LEN], pub MfgName: [::CHAR; LINE_LEN], pub ProviderName: [::CHAR; LINE_LEN], } impl Clone for SP_DRVINFO_DATA_V1_A { fn clone(&self) -> SP_DRVINFO_DATA_V1_A { *self } } pub type PSP_DRVINFO_DATA_V1_A = *mut SP_DRVINFO_DATA_V1_A; #[repr(C)] #[derive(Copy)] pub struct SP_DRVINFO_DATA_V1_W { pub cbSize: ::DWORD, pub DriverType: ::DWORD, pub Reserved: ::ULONG_PTR, pub Description: [::WCHAR; LINE_LEN], pub MfgName: [::WCHAR; LINE_LEN], pub ProviderName: [::WCHAR; LINE_LEN], } impl Clone for SP_DRVINFO_DATA_V1_W { fn clone(&self) -> SP_DRVINFO_DATA_V1_W { *self } } pub type PSP_DRVINFO_DATA_V1_W = *mut SP_DRVINFO_DATA_V1_W; pub type SP_DRVINFO_DATA_A = SP_DRVINFO_DATA_V2_A; pub type PSP_DRVINFO_DATA_A = PSP_DRVINFO_DATA_V2_A; pub type SP_DRVINFO_DATA_W = SP_DRVINFO_DATA_V2_W; pub type PSP_DRVINFO_DATA_W = PSP_DRVINFO_DATA_V2_W; #[repr(C)] #[derive(Copy)] pub struct SP_DRVINFO_DETAIL_DATA_A { pub cbSize: ::DWORD, pub InfDate: ::FILETIME, pub CompatIDsOffset: ::DWORD, pub CompatIDsLength: ::DWORD, pub Reserved: ::ULONG_PTR, pub SectionName: [::CHAR; LINE_LEN], pub InfFileName: [::CHAR; ::MAX_PATH], pub DrvDescription: [::CHAR; LINE_LEN], pub HardwareID: [::CHAR; ::ANYSIZE_ARRAY], } impl Clone for SP_DRVINFO_DETAIL_DATA_A { fn clone(&self) -> SP_DRVINFO_DETAIL_DATA_A { *self } } pub type PSP_DRVINFO_DETAIL_DATA_A = *mut SP_DRVINFO_DETAIL_DATA_A; #[repr(C)] #[derive(Copy)] pub struct SP_DRVINFO_DETAIL_DATA_W { pub cbSize: ::DWORD, pub InfDate: ::FILETIME, pub CompatIDsOffset: ::DWORD, pub CompatIDsLength: ::DWORD, pub Reserved: ::ULONG_PTR, pub SectionName: [::WCHAR; LINE_LEN], pub InfFileName: [::WCHAR; ::MAX_PATH], pub DrvDescription: [::WCHAR; LINE_LEN], pub HardwareID: [::WCHAR; ::ANYSIZE_ARRAY], } impl Clone for SP_DRVINFO_DETAIL_DATA_W { fn clone(&self) -> SP_DRVINFO_DETAIL_DATA_W { *self } } pub type PSP_DRVINFO_DETAIL_DATA_W = *mut SP_DRVINFO_DETAIL_DATA_W; STRUCT!{struct SP_DRVINSTALL_PARAMS { cbSize: ::DWORD, Rank: ::DWORD, Flags: ::DWORD, PrivateData: ::DWORD_PTR, Reserved: ::DWORD, }} pub type PSP_DRVINSTALL_PARAMS = *mut SP_DRVINSTALL_PARAMS; pub const DNF_DUPDESC: ::DWORD = 0x00000001; pub const DNF_OLDDRIVER: ::DWORD = 0x00000002; pub const DNF_EXCLUDEFROMLIST: ::DWORD = 0x00000004; pub const DNF_NODRIVER: ::DWORD = 0x00000008; pub const DNF_LEGACYINF: ::DWORD = 0x00000010; pub const DNF_CLASS_DRIVER: ::DWORD = 0x00000020; pub const DNF_COMPATIBLE_DRIVER: ::DWORD = 0x00000040; pub const DNF_INET_DRIVER: ::DWORD = 0x00000080; pub const DNF_UNUSED1: ::DWORD = 0x00000100; pub const DNF_UNUSED2: ::DWORD = 0x00000200; pub const DNF_OLD_INET_DRIVER: ::DWORD = 0x00000400; pub const DNF_BAD_DRIVER: ::DWORD = 0x00000800; pub const DNF_DUPPROVIDER: ::DWORD = 0x00001000; pub const DNF_INF_IS_SIGNED: ::DWORD = 0x00002000; pub const DNF_OEM_F6_INF: ::DWORD = 0x00004000; pub const DNF_DUPDRIVERVER: ::DWORD = 0x00008000; pub const DNF_BASIC_DRIVER: ::DWORD = 0x00010000; pub const DNF_AUTHENTICODE_SIGNED: ::DWORD = 0x00020000; pub const DNF_INSTALLEDDRIVER: ::DWORD = 0x00040000; pub const DNF_ALWAYSEXCLUDEFROMLIST: ::DWORD = 0x00080000; pub const DNF_INBOX_DRIVER: ::DWORD = 0x00100000; pub const DNF_REQUESTADDITIONALSOFTWARE: ::DWORD = 0x00200000; pub const DNF_UNUSED_22: ::DWORD = 0x00400000; pub const DNF_UNUSED_23: ::DWORD = 0x00800000; pub const DNF_UNUSED_24: ::DWORD = 0x01000000; pub const DNF_UNUSED_25: ::DWORD = 0x02000000; pub const DNF_UNUSED_26: ::DWORD = 0x04000000; pub const DNF_UNUSED_27: ::DWORD = 0x08000000; pub const DNF_UNUSED_28: ::DWORD = 0x10000000; pub const DNF_UNUSED_29: ::DWORD = 0x20000000; pub const DNF_UNUSED_30: ::DWORD = 0x40000000; pub const DNF_UNUSED_31: ::DWORD = 0x80000000; pub type PSP_DETSIG_CMPPROC = Option ::DWORD>; STRUCT!{struct COINSTALLER_CONTEXT_DATA { PostProcessing: ::BOOL, InstallResult: ::DWORD, PrivateData: ::PVOID, }} pub type PCOINSTALLER_CONTEXT_DATA = *mut COINSTALLER_CONTEXT_DATA; STRUCT!{struct SP_CLASSIMAGELIST_DATA { cbSize: ::DWORD, ImageList: ::HIMAGELIST, Reserved: ::ULONG_PTR, }} pub type PSP_CLASSIMAGELIST_DATA = *mut SP_CLASSIMAGELIST_DATA; STRUCT!{struct SP_PROPSHEETPAGE_REQUEST { cbSize: ::DWORD, PageRequested: ::DWORD, DeviceInfoSet: HDEVINFO, DeviceInfoData: PSP_DEVINFO_DATA, }} pub type PSP_PROPSHEETPAGE_REQUEST = *mut SP_PROPSHEETPAGE_REQUEST; pub const SPPSR_SELECT_DEVICE_RESOURCES: ::DWORD = 1; pub const SPPSR_ENUM_BASIC_DEVICE_PROPERTIES: ::DWORD = 2; pub const SPPSR_ENUM_ADV_DEVICE_PROPERTIES: ::DWORD = 3; #[repr(C)] #[derive(Copy)] pub struct SP_BACKUP_QUEUE_PARAMS_V2_A { pub cbSize: ::DWORD, pub FullInfPath: [::CHAR; ::MAX_PATH], pub FilenameOffset: ::INT, pub ReinstallInstance: [::CHAR; ::MAX_PATH], } impl Clone for SP_BACKUP_QUEUE_PARAMS_V2_A { fn clone(&self) -> SP_BACKUP_QUEUE_PARAMS_V2_A { *self } } pub type PSP_BACKUP_QUEUE_PARAMS_V2_A = *mut SP_BACKUP_QUEUE_PARAMS_V2_A; #[repr(C)] #[derive(Copy)] pub struct SP_BACKUP_QUEUE_PARAMS_V2_W { pub cbSize: ::DWORD, pub FullInfPath: [::WCHAR; ::MAX_PATH], pub FilenameOffset: ::INT, pub ReinstallInstance: [::WCHAR; ::MAX_PATH], } impl Clone for SP_BACKUP_QUEUE_PARAMS_V2_W { fn clone(&self) -> SP_BACKUP_QUEUE_PARAMS_V2_W { *self } } pub type PSP_BACKUP_QUEUE_PARAMS_V2_W = *mut SP_BACKUP_QUEUE_PARAMS_V2_W; #[repr(C)] #[derive(Copy)] pub struct SP_BACKUP_QUEUE_PARAMS_V1_A { pub cbSize: ::DWORD, pub FullInfPath: [::CHAR; ::MAX_PATH], pub FilenameOffset: ::INT, } impl Clone for SP_BACKUP_QUEUE_PARAMS_V1_A { fn clone(&self) -> SP_BACKUP_QUEUE_PARAMS_V1_A { *self } } pub type PSP_BACKUP_QUEUE_PARAMS_V1_A = *mut SP_BACKUP_QUEUE_PARAMS_V1_A; #[repr(C)] #[derive(Copy)] pub struct SP_BACKUP_QUEUE_PARAMS_V1_W { pub cbSize: ::DWORD, pub FullInfPath: [::WCHAR; ::MAX_PATH], pub FilenameOffset: ::INT, } impl Clone for SP_BACKUP_QUEUE_PARAMS_V1_W { fn clone(&self) -> SP_BACKUP_QUEUE_PARAMS_V1_W { *self } } pub type PSP_BACKUP_QUEUE_PARAMS_V1_W = *mut SP_BACKUP_QUEUE_PARAMS_V1_W; pub type SP_BACKUP_QUEUE_PARAMS_A = SP_BACKUP_QUEUE_PARAMS_V2_A; pub type PSP_BACKUP_QUEUE_PARAMS_A = PSP_BACKUP_QUEUE_PARAMS_V2_A; pub type SP_BACKUP_QUEUE_PARAMS_W = SP_BACKUP_QUEUE_PARAMS_V2_W; pub type PSP_BACKUP_QUEUE_PARAMS_W = PSP_BACKUP_QUEUE_PARAMS_V2_W; pub const ERROR_EXPECTED_SECTION_NAME: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0; pub const ERROR_BAD_SECTION_NAME_LINE: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 1; pub const ERROR_SECTION_NAME_TOO_LONG: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 2; pub const ERROR_GENERAL_SYNTAX: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 3; pub const ERROR_WRONG_INF_STYLE: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x100; pub const ERROR_SECTION_NOT_FOUND: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x101; pub const ERROR_LINE_NOT_FOUND: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x102; pub const ERROR_NO_BACKUP: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x103; pub const ERROR_NO_ASSOCIATED_CLASS: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x200; pub const ERROR_CLASS_MISMATCH: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x201; pub const ERROR_DUPLICATE_FOUND: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x202; pub const ERROR_NO_DRIVER_SELECTED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x203; pub const ERROR_KEY_DOES_NOT_EXIST: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x204; pub const ERROR_INVALID_DEVINST_NAME: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x205; pub const ERROR_INVALID_CLASS: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x206; pub const ERROR_DEVINST_ALREADY_EXISTS: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x207; pub const ERROR_DEVINFO_NOT_REGISTERED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x208; pub const ERROR_INVALID_REG_PROPERTY: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x209; pub const ERROR_NO_INF: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x20A; pub const ERROR_NO_SUCH_DEVINST: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x20B; pub const ERROR_CANT_LOAD_CLASS_ICON: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x20C; pub const ERROR_INVALID_CLASS_INSTALLER: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x20D; pub const ERROR_DI_DO_DEFAULT: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x20E; pub const ERROR_DI_NOFILECOPY: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x20F; pub const ERROR_INVALID_HWPROFILE: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x210; pub const ERROR_NO_DEVICE_SELECTED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x211; pub const ERROR_DEVINFO_LIST_LOCKED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x212; pub const ERROR_DEVINFO_DATA_LOCKED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x213; pub const ERROR_DI_BAD_PATH: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x214; pub const ERROR_NO_CLASSINSTALL_PARAMS: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x215; pub const ERROR_FILEQUEUE_LOCKED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x216; pub const ERROR_BAD_SERVICE_INSTALLSECT: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x217; pub const ERROR_NO_CLASS_DRIVER_LIST: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x218; pub const ERROR_NO_ASSOCIATED_SERVICE: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x219; pub const ERROR_NO_DEFAULT_DEVICE_INTERFACE: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x21A; pub const ERROR_DEVICE_INTERFACE_ACTIVE: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x21B; pub const ERROR_DEVICE_INTERFACE_REMOVED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x21C; pub const ERROR_BAD_INTERFACE_INSTALLSECT: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x21D; pub const ERROR_NO_SUCH_INTERFACE_CLASS: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x21E; pub const ERROR_INVALID_REFERENCE_STRING: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x21F; pub const ERROR_INVALID_MACHINENAME: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x220; pub const ERROR_REMOTE_COMM_FAILURE: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x221; pub const ERROR_MACHINE_UNAVAILABLE: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x222; pub const ERROR_NO_CONFIGMGR_SERVICES: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x223; pub const ERROR_INVALID_PROPPAGE_PROVIDER: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x224; pub const ERROR_NO_SUCH_DEVICE_INTERFACE: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x225; pub const ERROR_DI_POSTPROCESSING_REQUIRED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x226; pub const ERROR_INVALID_COINSTALLER: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x227; pub const ERROR_NO_COMPAT_DRIVERS: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x228; pub const ERROR_NO_DEVICE_ICON: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x229; pub const ERROR_INVALID_INF_LOGCONFIG: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x22A; pub const ERROR_DI_DONT_INSTALL: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x22B; pub const ERROR_INVALID_FILTER_DRIVER: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x22C; pub const ERROR_NON_WINDOWS_NT_DRIVER: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x22D; pub const ERROR_NON_WINDOWS_DRIVER: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x22E; pub const ERROR_NO_CATALOG_FOR_OEM_INF: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x22F; pub const ERROR_DEVINSTALL_QUEUE_NONNATIVE: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x230; pub const ERROR_NOT_DISABLEABLE: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x231; pub const ERROR_CANT_REMOVE_DEVINST: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x232; pub const ERROR_INVALID_TARGET: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x233; pub const ERROR_DRIVER_NONNATIVE: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x234; pub const ERROR_IN_WOW64: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x235; pub const ERROR_SET_SYSTEM_RESTORE_POINT: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x236; pub const ERROR_SCE_DISABLED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x238; pub const ERROR_UNKNOWN_EXCEPTION: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x239; pub const ERROR_PNP_REGISTRY_ERROR: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x23A; pub const ERROR_REMOTE_REQUEST_UNSUPPORTED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x23B; pub const ERROR_NOT_AN_INSTALLED_OEM_INF: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x23C; pub const ERROR_INF_IN_USE_BY_DEVICES: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x23D; pub const ERROR_DI_FUNCTION_OBSOLETE: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x23E; pub const ERROR_NO_AUTHENTICODE_CATALOG: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x23F; pub const ERROR_AUTHENTICODE_DISALLOWED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x240; pub const ERROR_AUTHENTICODE_TRUSTED_PUBLISHER: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x241; pub const ERROR_AUTHENTICODE_TRUST_NOT_ESTABLISHED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x242; pub const ERROR_AUTHENTICODE_PUBLISHER_NOT_TRUSTED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x243; pub const ERROR_SIGNATURE_OSATTRIBUTE_MISMATCH: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x244; pub const ERROR_ONLY_VALIDATE_VIA_AUTHENTICODE: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x245; pub const ERROR_DEVICE_INSTALLER_NOT_READY: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x246; pub const ERROR_DRIVER_STORE_ADD_FAILED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x247; pub const ERROR_DEVICE_INSTALL_BLOCKED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x248; pub const ERROR_DRIVER_INSTALL_BLOCKED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x249; pub const ERROR_WRONG_INF_TYPE: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x24A; pub const ERROR_FILE_HASH_NOT_IN_CATALOG: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x24B; pub const ERROR_DRIVER_STORE_DELETE_FAILED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x24C; pub const ERROR_UNRECOVERABLE_STACK_OVERFLOW: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x300; pub const EXCEPTION_SPAPI_UNRECOVERABLE_STACK_OVERFLOW: ::DWORD = ERROR_UNRECOVERABLE_STACK_OVERFLOW; pub const ERROR_NO_DEFAULT_INTERFACE_DEVICE: ::DWORD = ERROR_NO_DEFAULT_DEVICE_INTERFACE; pub const ERROR_INTERFACE_DEVICE_ACTIVE: ::DWORD = ERROR_DEVICE_INTERFACE_ACTIVE; pub const ERROR_INTERFACE_DEVICE_REMOVED: ::DWORD = ERROR_DEVICE_INTERFACE_REMOVED; pub const ERROR_NO_SUCH_INTERFACE_DEVICE: ::DWORD = ERROR_NO_SUCH_DEVICE_INTERFACE; pub const ERROR_NOT_INSTALLED: ::DWORD = ::APPLICATION_ERROR_MASK | ::ERROR_SEVERITY_ERROR | 0x1000; pub const INFINFO_INF_SPEC_IS_HINF: ::DWORD = 1; pub const INFINFO_INF_NAME_IS_ABSOLUTE: ::DWORD = 2; pub const INFINFO_DEFAULT_SEARCH: ::DWORD = 3; pub const INFINFO_REVERSE_DEFAULT_SEARCH: ::DWORD = 4; pub const INFINFO_INF_PATH_LIST_SEARCH: ::DWORD = 5; pub const FILE_COMPRESSION_NONE: ::UINT = 0; pub const FILE_COMPRESSION_WINLZA: ::UINT = 1; pub const FILE_COMPRESSION_MSZIP: ::UINT = 2; pub const FILE_COMPRESSION_NTCAB: ::UINT = 3; pub const SRCLIST_TEMPORARY: ::DWORD = 0x00000001; pub const SRCLIST_NOBROWSE: ::DWORD = 0x00000002; pub const SRCLIST_SYSTEM: ::DWORD = 0x00000010; pub const SRCLIST_USER: ::DWORD = 0x00000020; pub const SRCLIST_SYSIFADMIN: ::DWORD = 0x00000040; pub const SRCLIST_SUBDIRS: ::DWORD = 0x00000100; pub const SRCLIST_APPEND: ::DWORD = 0x00000200; pub const SRCLIST_NOSTRIPPLATFORM: ::DWORD = 0x00000400; pub const IDF_NOBROWSE: ::DWORD = 0x00000001; pub const IDF_NOSKIP: ::DWORD = 0x00000002; pub const IDF_NODETAILS: ::DWORD = 0x00000004; pub const IDF_NOCOMPRESSED: ::DWORD = 0x00000008; pub const IDF_CHECKFIRST: ::DWORD = 0x00000100; pub const IDF_NOBEEP: ::DWORD = 0x00000200; pub const IDF_NOFOREGROUND: ::DWORD = 0x00000400; pub const IDF_WARNIFSKIP: ::DWORD = 0x00000800; pub const IDF_NOREMOVABLEMEDIAPROMPT: ::DWORD = 0x00001000; pub const IDF_USEDISKNAMEASPROMPT: ::DWORD = 0x00002000; pub const IDF_OEMDISK: ::DWORD = 0x80000000; pub const DPROMPT_SUCCESS: ::UINT = 0; pub const DPROMPT_CANCEL: ::UINT = 1; pub const DPROMPT_SKIPFILE: ::UINT = 2; pub const DPROMPT_BUFFERTOOSMALL: ::UINT = 3; pub const DPROMPT_OUTOFMEMORY: ::UINT = 4; pub const SETDIRID_NOT_FULL_PATH: ::DWORD = 0x00000001; pub const SRCINFO_PATH: ::UINT = 1; pub const SRCINFO_TAGFILE: ::UINT = 2; pub const SRCINFO_DESCRIPTION: ::UINT = 3; pub const SRCINFO_FLAGS: ::UINT = 4; pub const SRCINFO_TAGFILE2: ::UINT = 4; pub const SRC_FLAGS_CABFILE: ::UINT = 0x0010; pub const SP_COPY_DELETESOURCE: ::DWORD = 0x0000001; pub const SP_COPY_REPLACEONLY: ::DWORD = 0x0000002; pub const SP_COPY_NEWER: ::DWORD = 0x0000004; pub const SP_COPY_NEWER_OR_SAME: ::DWORD = SP_COPY_NEWER; pub const SP_COPY_NOOVERWRITE: ::DWORD = 0x0000008; pub const SP_COPY_NODECOMP: ::DWORD = 0x0000010; pub const SP_COPY_LANGUAGEAWARE: ::DWORD = 0x0000020; pub const SP_COPY_SOURCE_ABSOLUTE: ::DWORD = 0x0000040; pub const SP_COPY_SOURCEPATH_ABSOLUTE: ::DWORD = 0x0000080; pub const SP_COPY_IN_USE_NEEDS_REBOOT: ::DWORD = 0x0000100; pub const SP_COPY_FORCE_IN_USE: ::DWORD = 0x0000200; pub const SP_COPY_NOSKIP: ::DWORD = 0x0000400; pub const SP_FLAG_CABINETCONTINUATION: ::DWORD = 0x0000800; pub const SP_COPY_FORCE_NOOVERWRITE: ::DWORD = 0x0001000; pub const SP_COPY_FORCE_NEWER: ::DWORD = 0x0002000; pub const SP_COPY_WARNIFSKIP: ::DWORD = 0x0004000; pub const SP_COPY_NOBROWSE: ::DWORD = 0x0008000; pub const SP_COPY_NEWER_ONLY: ::DWORD = 0x0010000; pub const SP_COPY_RESERVED: ::DWORD = 0x0020000; pub const SP_COPY_OEMINF_CATALOG_ONLY: ::DWORD = 0x0040000; pub const SP_COPY_REPLACE_BOOT_FILE: ::DWORD = 0x0080000; pub const SP_COPY_NOPRUNE: ::DWORD = 0x0100000; pub const SP_COPY_OEM_F6_INF: ::DWORD = 0x0200000; pub const SP_COPY_ALREADYDECOMP: ::DWORD = 0x0400000; pub const SP_COPY_WINDOWS_SIGNED: ::DWORD = 0x1000000; pub const SP_COPY_PNPLOCKED: ::DWORD = 0x2000000; pub const SP_COPY_IN_USE_TRY_RENAME: ::DWORD = 0x4000000; pub const SP_COPY_INBOX_INF: ::DWORD = 0x8000000; pub const SP_COPY_HARDLINK: ::DWORD = 0x10000000; pub const SP_BACKUP_BACKUPPASS: ::DWORD = 0x00000001; pub const SP_BACKUP_DEMANDPASS: ::DWORD = 0x00000002; pub const SP_BACKUP_SPECIAL: ::DWORD = 0x00000004; pub const SP_BACKUP_BOOTFILE: ::DWORD = 0x00000008; pub const SPQ_SCAN_FILE_PRESENCE: ::DWORD = 0x00000001; pub const SPQ_SCAN_FILE_VALIDITY: ::DWORD = 0x00000002; pub const SPQ_SCAN_USE_CALLBACK: ::DWORD = 0x00000004; pub const SPQ_SCAN_USE_CALLBACKEX: ::DWORD = 0x00000008; pub const SPQ_SCAN_INFORM_USER: ::DWORD = 0x00000010; pub const SPQ_SCAN_PRUNE_COPY_QUEUE: ::DWORD = 0x00000020; pub const SPQ_SCAN_USE_CALLBACK_SIGNERINFO: ::DWORD = 0x00000040; pub const SPQ_SCAN_PRUNE_DELREN: ::DWORD = 0x00000080; pub const SPQ_SCAN_FILE_PRESENCE_WITHOUT_SOURCE: ::DWORD = 0x00000100; pub const SPQ_SCAN_FILE_COMPARISON: ::DWORD = 0x00000200; pub const SPQ_SCAN_ACTIVATE_DRP: ::DWORD = 0x00000400; pub const SPQ_DELAYED_COPY: ::DWORD = 0x00000001; pub const SPQ_FLAG_BACKUP_AWARE: ::DWORD = 0x00000001; pub const SPQ_FLAG_ABORT_IF_UNSIGNED: ::DWORD = 0x00000002; pub const SPQ_FLAG_FILES_MODIFIED: ::DWORD = 0x00000004; pub const SPQ_FLAG_DO_SHUFFLEMOVE: ::DWORD = 0x00000008; pub const SPQ_FLAG_VALID: ::DWORD = 0x0000000F; pub const SPOST_NONE: ::DWORD = 0; pub const SPOST_PATH: ::DWORD = 1; pub const SPOST_URL: ::DWORD = 2; pub const SPOST_MAX: ::DWORD = 3; pub const SUOI_FORCEDELETE: ::DWORD = 0x00000001; pub const SUOI_INTERNAL1: ::DWORD = 0x00000002; pub const SPDSL_IGNORE_DISK: ::UINT = 0x00000001; pub const SPDSL_DISALLOW_NEGATIVE_ADJUST: ::UINT = 0x00000002; pub const SPFILEQ_FILE_IN_USE: ::INT = 0x00000001; pub const SPFILEQ_REBOOT_RECOMMENDED: ::INT = 0x00000002; pub const SPFILEQ_REBOOT_IN_PROGRESS: ::INT = 0x00000004; pub const FLG_ADDREG_DELREG_BIT: ::DWORD = 0x00008000; pub const FLG_ADDREG_BINVALUETYPE: ::DWORD = 0x00000001; pub const FLG_ADDREG_NOCLOBBER: ::DWORD = 0x00000002; pub const FLG_ADDREG_DELVAL: ::DWORD = 0x00000004; pub const FLG_ADDREG_APPEND: ::DWORD = 0x00000008; pub const FLG_ADDREG_KEYONLY: ::DWORD = 0x00000010; pub const FLG_ADDREG_OVERWRITEONLY: ::DWORD = 0x00000020; pub const FLG_ADDREG_64BITKEY: ::DWORD = 0x00001000; pub const FLG_ADDREG_KEYONLY_COMMON: ::DWORD = 0x00002000; pub const FLG_ADDREG_32BITKEY: ::DWORD = 0x00004000; pub const FLG_ADDREG_TYPE_MASK: ::DWORD = 0xFFFF0000 | FLG_ADDREG_BINVALUETYPE; pub const FLG_ADDREG_TYPE_SZ: ::DWORD = 0x00000000; pub const FLG_ADDREG_TYPE_MULTI_SZ: ::DWORD = 0x00010000; pub const FLG_ADDREG_TYPE_EXPAND_SZ: ::DWORD = 0x00020000; pub const FLG_ADDREG_TYPE_BINARY: ::DWORD = 0x00000000 | FLG_ADDREG_BINVALUETYPE; pub const FLG_ADDREG_TYPE_DWORD: ::DWORD = 0x00010000 | FLG_ADDREG_BINVALUETYPE; pub const FLG_ADDREG_TYPE_NONE: ::DWORD = 0x00020000 | FLG_ADDREG_BINVALUETYPE; pub const FLG_DELREG_VALUE: ::DWORD = 0x00000000; pub const FLG_DELREG_TYPE_MASK: ::DWORD = FLG_ADDREG_TYPE_MASK; pub const FLG_DELREG_TYPE_SZ: ::DWORD = FLG_ADDREG_TYPE_SZ; pub const FLG_DELREG_TYPE_MULTI_SZ: ::DWORD = FLG_ADDREG_TYPE_MULTI_SZ; pub const FLG_DELREG_TYPE_EXPAND_SZ: ::DWORD = FLG_ADDREG_TYPE_EXPAND_SZ; pub const FLG_DELREG_TYPE_BINARY: ::DWORD = FLG_ADDREG_TYPE_BINARY; pub const FLG_DELREG_TYPE_DWORD: ::DWORD = FLG_ADDREG_TYPE_DWORD; pub const FLG_DELREG_TYPE_NONE: ::DWORD = FLG_ADDREG_TYPE_NONE; pub const FLG_DELREG_64BITKEY: ::DWORD = FLG_ADDREG_64BITKEY; pub const FLG_DELREG_KEYONLY_COMMON: ::DWORD = FLG_ADDREG_KEYONLY_COMMON; pub const FLG_DELREG_32BITKEY: ::DWORD = FLG_ADDREG_32BITKEY; pub const FLG_DELREG_OPERATION_MASK: ::DWORD = 0x000000FE; pub const FLG_DELREG_MULTI_SZ_DELSTRING: ::DWORD = FLG_DELREG_TYPE_MULTI_SZ | FLG_ADDREG_DELREG_BIT | 0x00000002; pub const FLG_BITREG_CLEARBITS: ::DWORD = 0x00000000; pub const FLG_BITREG_SETBITS: ::DWORD = 0x00000001; pub const FLG_BITREG_64BITKEY: ::DWORD = 0x00001000; pub const FLG_BITREG_32BITKEY: ::DWORD = 0x00004000; pub const FLG_INI2REG_64BITKEY: ::DWORD = 0x00001000; pub const FLG_INI2REG_32BITKEY: ::DWORD = 0x00004000; pub const FLG_REGSVR_DLLREGISTER: ::DWORD = 0x00000001; pub const FLG_REGSVR_DLLINSTALL: ::DWORD = 0x00000002; pub const FLG_PROFITEM_CURRENTUSER: ::DWORD = 0x00000001; pub const FLG_PROFITEM_DELETE: ::DWORD = 0x00000002; pub const FLG_PROFITEM_GROUP: ::DWORD = 0x00000004; pub const FLG_PROFITEM_CSIDL: ::DWORD = 0x00000008; pub const FLG_ADDPROPERTY_NOCLOBBER: ::DWORD = 0x00000001; pub const FLG_ADDPROPERTY_OVERWRITEONLY: ::DWORD = 0x00000002; pub const FLG_ADDPROPERTY_APPEND: ::DWORD = 0x00000004; pub const FLG_ADDPROPERTY_OR: ::DWORD = 0x00000008; pub const FLG_ADDPROPERTY_AND: ::DWORD = 0x00000010; pub const FLG_DELPROPERTY_MULTI_SZ_DELSTRING: ::DWORD = 0x00000001; pub const SPINST_LOGCONFIG: ::UINT = 0x00000001; pub const SPINST_INIFILES: ::UINT = 0x00000002; pub const SPINST_REGISTRY: ::UINT = 0x00000004; pub const SPINST_INI2REG: ::UINT = 0x00000008; pub const SPINST_FILES: ::UINT = 0x00000010; pub const SPINST_BITREG: ::UINT = 0x00000020; pub const SPINST_REGSVR: ::UINT = 0x00000040; pub const SPINST_UNREGSVR: ::UINT = 0x00000080; pub const SPINST_PROFILEITEMS: ::UINT = 0x00000100; pub const SPINST_COPYINF: ::UINT = 0x00000200; pub const SPINST_PROPERTIES: ::UINT = 0x00000400; pub const SPINST_ALL: ::UINT = 0x000007ff; pub const SPINST_SINGLESECTION: ::UINT = 0x00010000; pub const SPINST_LOGCONFIG_IS_FORCED: ::UINT = 0x00020000; pub const SPINST_LOGCONFIGS_ARE_OVERRIDES: ::UINT = 0x00040000; pub const SPINST_REGISTERCALLBACKAWARE: ::UINT = 0x00080000; pub const SPINST_DEVICEINSTALL: ::UINT = 0x00100000; pub const SPSVCINST_TAGTOFRONT: ::DWORD = 0x00000001; pub const SPSVCINST_ASSOCSERVICE: ::DWORD = 0x00000002; pub const SPSVCINST_DELETEEVENTLOGENTRY: ::DWORD = 0x00000004; pub const SPSVCINST_NOCLOBBER_DISPLAYNAME: ::DWORD = 0x00000008; pub const SPSVCINST_NOCLOBBER_STARTTYPE: ::DWORD = 0x00000010; pub const SPSVCINST_NOCLOBBER_ERRORCONTROL: ::DWORD = 0x00000020; pub const SPSVCINST_NOCLOBBER_LOADORDERGROUP: ::DWORD = 0x00000040; pub const SPSVCINST_NOCLOBBER_DEPENDENCIES: ::DWORD = 0x00000080; pub const SPSVCINST_NOCLOBBER_DESCRIPTION: ::DWORD = 0x00000100; pub const SPSVCINST_STOPSERVICE: ::DWORD = 0x00000200; pub const SPSVCINST_CLOBBER_SECURITY: ::DWORD = 0x00000400; pub const SPSVCINST_STARTSERVICE: ::DWORD = 0x00000800; pub const SPSVCINST_NOCLOBBER_REQUIREDPRIVILEGES: ::DWORD = 0x00001000; pub type HSPFILELOG = ::PVOID; pub const SPFILELOG_SYSTEMLOG: ::DWORD = 0x00000001; pub const SPFILELOG_FORCENEW: ::DWORD = 0x00000002; pub const SPFILELOG_QUERYONLY: ::DWORD = 0x00000004; pub const SPFILELOG_OEMFILE: ::DWORD = 0x00000001; ENUM!{enum SetupFileLogInfo { SetupFileLogSourceFilename, SetupFileLogChecksum, SetupFileLogDiskTagfile, SetupFileLogDiskDescription, SetupFileLogOtherInfo, SetupFileLogMax, }} pub type LogSeverity = ::DWORD; pub const LogSevInformation: LogSeverity = 0x00000000; pub const LogSevWarning: LogSeverity = 0x00000001; pub const LogSevError: LogSeverity = 0x00000002; pub const LogSevFatalError: LogSeverity = 0x00000003; pub const LogSevMaximum: LogSeverity = 0x00000004; pub const DICD_GENERATE_ID: ::DWORD = 0x00000001; pub const DICD_INHERIT_CLASSDRVS: ::DWORD = 0x00000002; pub const DIOD_INHERIT_CLASSDRVS: ::DWORD = 0x00000002; pub const DIOD_CANCEL_REMOVE: ::DWORD = 0x00000004; pub const DIODI_NO_ADD: ::DWORD = 0x00000001; pub const SPRDI_FIND_DUPS: ::DWORD = 0x00000001; pub const SPDIT_NODRIVER: ::DWORD = 0x00000000; pub const SPDIT_CLASSDRIVER: ::DWORD = 0x00000001; pub const SPDIT_COMPATDRIVER: ::DWORD = 0x00000002; pub const DIGCF_DEFAULT: ::DWORD = 0x00000001; pub const DIGCF_PRESENT: ::DWORD = 0x00000002; pub const DIGCF_ALLCLASSES: ::DWORD = 0x00000004; pub const DIGCF_PROFILE: ::DWORD = 0x00000008; pub const DIGCF_DEVICEINTERFACE: ::DWORD = 0x00000010; pub const DIBCI_NOINSTALLCLASS: ::DWORD = 0x00000001; pub const DIBCI_NODISPLAYCLASS: ::DWORD = 0x00000002; pub const DIOCR_INSTALLER: ::DWORD = 0x00000001; pub const DIOCR_INTERFACE: ::DWORD = 0x00000002; pub const DIREG_DEV: ::DWORD = 0x00000001; pub const DIREG_DRV: ::DWORD = 0x00000002; pub const DIREG_BOTH: ::DWORD = 0x00000004; pub const DICLASSPROP_INSTALLER: ::DWORD = 0x00000001; pub const DICLASSPROP_INTERFACE: ::DWORD = 0x00000002; pub const SPDRP_DEVICEDESC: ::DWORD = 0x00000000; pub const SPDRP_HARDWAREID: ::DWORD = 0x00000001; pub const SPDRP_COMPATIBLEIDS: ::DWORD = 0x00000002; pub const SPDRP_UNUSED0: ::DWORD = 0x00000003; pub const SPDRP_SERVICE: ::DWORD = 0x00000004; pub const SPDRP_UNUSED1: ::DWORD = 0x00000005; pub const SPDRP_UNUSED2: ::DWORD = 0x00000006; pub const SPDRP_CLASS: ::DWORD = 0x00000007; pub const SPDRP_CLASSGUID: ::DWORD = 0x00000008; pub const SPDRP_DRIVER: ::DWORD = 0x00000009; pub const SPDRP_CONFIGFLAGS: ::DWORD = 0x0000000A; pub const SPDRP_MFG: ::DWORD = 0x0000000B; pub const SPDRP_FRIENDLYNAME: ::DWORD = 0x0000000C; pub const SPDRP_LOCATION_INFORMATION: ::DWORD = 0x0000000D; pub const SPDRP_PHYSICAL_DEVICE_OBJECT_NAME: ::DWORD = 0x0000000E; pub const SPDRP_CAPABILITIES: ::DWORD = 0x0000000F; pub const SPDRP_UI_NUMBER: ::DWORD = 0x00000010; pub const SPDRP_UPPERFILTERS: ::DWORD = 0x00000011; pub const SPDRP_LOWERFILTERS: ::DWORD = 0x00000012; pub const SPDRP_BUSTYPEGUID: ::DWORD = 0x00000013; pub const SPDRP_LEGACYBUSTYPE: ::DWORD = 0x00000014; pub const SPDRP_BUSNUMBER: ::DWORD = 0x00000015; pub const SPDRP_ENUMERATOR_NAME: ::DWORD = 0x00000016; pub const SPDRP_SECURITY: ::DWORD = 0x00000017; pub const SPDRP_SECURITY_SDS: ::DWORD = 0x00000018; pub const SPDRP_DEVTYPE: ::DWORD = 0x00000019; pub const SPDRP_EXCLUSIVE: ::DWORD = 0x0000001A; pub const SPDRP_CHARACTERISTICS: ::DWORD = 0x0000001B; pub const SPDRP_ADDRESS: ::DWORD = 0x0000001C; pub const SPDRP_UI_NUMBER_DESC_FORMAT: ::DWORD = 0x0000001D; pub const SPDRP_DEVICE_POWER_DATA: ::DWORD = 0x0000001E; pub const SPDRP_REMOVAL_POLICY: ::DWORD = 0x0000001F; pub const SPDRP_REMOVAL_POLICY_HW_DEFAULT: ::DWORD = 0x00000020; pub const SPDRP_REMOVAL_POLICY_OVERRIDE: ::DWORD = 0x00000021; pub const SPDRP_INSTALL_STATE: ::DWORD = 0x00000022; pub const SPDRP_LOCATION_PATHS: ::DWORD = 0x00000023; pub const SPDRP_BASE_CONTAINERID: ::DWORD = 0x00000024; pub const SPDRP_MAXIMUM_PROPERTY: ::DWORD = 0x00000025; pub const SPCRP_UPPERFILTERS: ::DWORD = 0x00000011; pub const SPCRP_LOWERFILTERS: ::DWORD = 0x00000012; pub const SPCRP_SECURITY: ::DWORD = 0x00000017; pub const SPCRP_SECURITY_SDS: ::DWORD = 0x00000018; pub const SPCRP_DEVTYPE: ::DWORD = 0x00000019; pub const SPCRP_EXCLUSIVE: ::DWORD = 0x0000001A; pub const SPCRP_CHARACTERISTICS: ::DWORD = 0x0000001B; pub const SPCRP_MAXIMUM_PROPERTY: ::DWORD = 0x0000001C; pub const DMI_MASK: ::DWORD = 0x00000001; pub const DMI_BKCOLOR: ::DWORD = 0x00000002; pub const DMI_USERECT: ::DWORD = 0x00000004; pub const DIGCDP_FLAG_BASIC: ::DWORD = 0x00000001; pub const DIGCDP_FLAG_ADVANCED: ::DWORD = 0x00000002; pub const DIGCDP_FLAG_REMOTE_BASIC: ::DWORD = 0x00000003; pub const DIGCDP_FLAG_REMOTE_ADVANCED: ::DWORD = 0x00000004; pub const IDI_RESOURCEFIRST: ::c_int = 159; pub const IDI_RESOURCE: ::c_int = 159; pub const IDI_RESOURCELAST: ::c_int = 161; pub const IDI_RESOURCEOVERLAYFIRST: ::c_int = 161; pub const IDI_RESOURCEOVERLAYLAST: ::c_int = 161; pub const IDI_CONFLICT: ::c_int = 161; pub const IDI_CLASSICON_OVERLAYFIRST: ::c_int = 500; pub const IDI_CLASSICON_OVERLAYLAST: ::c_int = 502; pub const IDI_PROBLEM_OVL: ::c_int = 500; pub const IDI_DISABLED_OVL: ::c_int = 501; pub const IDI_FORCED_OVL: ::c_int = 502; pub const SPWPT_SELECTDEVICE: ::DWORD = 0x00000001; pub const SPWP_USE_DEVINFO_DATA: ::DWORD = 0x00000001; #[repr(C)] #[derive(Copy)] pub struct SP_INF_SIGNER_INFO_V1_A { pub cbSize: ::DWORD, pub CatalogFile: [::CHAR; ::MAX_PATH], pub DigitalSigner: [::CHAR; ::MAX_PATH], pub DigitalSignerVersion: [::CHAR; ::MAX_PATH], } impl Clone for SP_INF_SIGNER_INFO_V1_A { fn clone(&self) -> SP_INF_SIGNER_INFO_V1_A { *self } } pub type PSP_INF_SIGNER_INFO_V1_A = *mut SP_INF_SIGNER_INFO_V1_A; #[repr(C)] #[derive(Copy)] pub struct SP_INF_SIGNER_INFO_V1_W { pub cbSize: ::DWORD, pub CatalogFile: [::WCHAR; ::MAX_PATH], pub DigitalSigner: [::WCHAR; ::MAX_PATH], pub DigitalSignerVersion: [::WCHAR; ::MAX_PATH], } impl Clone for SP_INF_SIGNER_INFO_V1_W { fn clone(&self) -> SP_INF_SIGNER_INFO_V1_W { *self } } pub type PSP_INF_SIGNER_INFO_V1_W = *mut SP_INF_SIGNER_INFO_V1_W; #[repr(C)] #[derive(Copy)] pub struct SP_INF_SIGNER_INFO_V2_A { pub cbSize: ::DWORD, pub CatalogFile: [::CHAR; ::MAX_PATH], pub DigitalSigner: [::CHAR; ::MAX_PATH], pub DigitalSignerVersion: [::CHAR; ::MAX_PATH], pub SignerScore: ::DWORD, } impl Clone for SP_INF_SIGNER_INFO_V2_A { fn clone(&self) -> SP_INF_SIGNER_INFO_V2_A { *self } } pub type PSP_INF_SIGNER_INFO_V2_A = *mut SP_INF_SIGNER_INFO_V2_A; #[repr(C)] #[derive(Copy)] pub struct SP_INF_SIGNER_INFO_V2_W { pub cbSize: ::DWORD, pub CatalogFile: [::WCHAR; ::MAX_PATH], pub DigitalSigner: [::WCHAR; ::MAX_PATH], pub DigitalSignerVersion: [::WCHAR; ::MAX_PATH], pub SignerScore: ::DWORD, } impl Clone for SP_INF_SIGNER_INFO_V2_W { fn clone(&self) -> SP_INF_SIGNER_INFO_V2_W { *self } } pub type PSP_INF_SIGNER_INFO_V2_W = *mut SP_INF_SIGNER_INFO_V2_W; pub type SP_INF_SIGNER_INFO_A = SP_INF_SIGNER_INFO_V2_A; pub type PSP_INF_SIGNER_INFO_A = PSP_INF_SIGNER_INFO_V2_A; pub type SP_INF_SIGNER_INFO_W = SP_INF_SIGNER_INFO_V2_W; pub type PSP_INF_SIGNER_INFO_W = PSP_INF_SIGNER_INFO_V2_W; pub const SIGNERSCORE_UNKNOWN: ::DWORD = 0xFF000000; pub const SIGNERSCORE_W9X_SUSPECT: ::DWORD = 0xC0000000; pub const SIGNERSCORE_UNSIGNED: ::DWORD = 0x80000000; pub const SIGNERSCORE_AUTHENTICODE: ::DWORD = 0x0F000000; pub const SIGNERSCORE_WHQL: ::DWORD = 0x0D000005; pub const SIGNERSCORE_UNCLASSIFIED: ::DWORD = 0x0D000004; pub const SIGNERSCORE_INBOX: ::DWORD = 0x0D000003; pub const SIGNERSCORE_LOGO_STANDARD: ::DWORD = 0x0D000002; pub const SIGNERSCORE_LOGO_PREMIUM: ::DWORD = 0x0D000001; pub const SIGNERSCORE_MASK: ::DWORD = 0xFF000000; pub const SIGNERSCORE_SIGNED_MASK: ::DWORD = 0xF0000000; pub const DICUSTOMDEVPROP_MERGE_MULTISZ: ::DWORD = 0x00000001; pub const SCWMI_CLOBBER_SECURITY: ::DWORD = 0x00000001; deps/winapi-0.2.5/src/lsalookup.rs0000644000000000000000000000426312613167613015617 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! LSA Policy Lookup API STRUCT!{struct LSA_UNICODE_STRING { Length: ::USHORT, MaximumLength: ::USHORT, Buffer: ::PWSTR, }} pub type PLSA_UNICODE_STRING = *mut LSA_UNICODE_STRING; STRUCT!{struct LSA_STRING { Length: ::USHORT, MaximumLength: ::USHORT, Buffer: ::PCHAR, }} pub type PLSA_STRING = *mut LSA_STRING; STRUCT!{struct LSA_OBJECT_ATTRIBUTES { Length: ::ULONG, RootDirectory: ::HANDLE, ObjectName: PLSA_UNICODE_STRING, Attributes: ::ULONG, SecurityDescriptor: ::PVOID, SecurityQualityOfService: ::PVOID, }} pub type PLSA_OBJECT_ATTRIBUTES = *mut LSA_OBJECT_ATTRIBUTES; STRUCT!{struct LSA_TRUST_INFORMATION { Name: LSA_UNICODE_STRING, Sid: ::PSID, }} pub type PLSA_TRUST_INFORMATION = *mut LSA_TRUST_INFORMATION; STRUCT!{struct LSA_REFERENCED_DOMAIN_LIST { Entries: ::ULONG, Domains: PLSA_TRUST_INFORMATION, }} pub type PLSA_REFERENCED_DOMAIN_LIST = *mut LSA_REFERENCED_DOMAIN_LIST; STRUCT!{struct LSA_TRANSLATED_SID2 { Use: ::SID_NAME_USE, Sid: ::PSID, DomainIndex: ::LONG, Flags: ::ULONG, }} pub type PLSA_TRANSLATED_SID2 = *mut LSA_TRANSLATED_SID2; STRUCT!{struct LSA_TRANSLATED_NAME { Use: ::SID_NAME_USE, Name: LSA_UNICODE_STRING, DomainIndex: ::LONG, }} pub type PLSA_TRANSLATED_NAME = *mut LSA_TRANSLATED_NAME; STRUCT!{struct POLICY_ACCOUNT_DOMAIN_INFO { DomainName: LSA_UNICODE_STRING, DomainSid: ::PSID, }} pub type PPOLICY_ACCOUNT_DOMAIN_INFO = *mut POLICY_ACCOUNT_DOMAIN_INFO; STRUCT!{struct POLICY_DNS_DOMAIN_INFO { Name: LSA_UNICODE_STRING, DnsDomainName: LSA_UNICODE_STRING, DnsForestName: LSA_UNICODE_STRING, DomainGuid: ::GUID, Sid: ::PSID, }} pub type PPOLICY_DNS_DOMAIN_INFO = *mut POLICY_DNS_DOMAIN_INFO; pub const LOOKUP_VIEW_LOCAL_INFORMATION: ::ACCESS_MASK = 0x00000001; pub const LOOKUP_TRANSLATE_NAMES: ::ACCESS_MASK = 0x00000800; ENUM!{enum LSA_LOOKUP_DOMAIN_INFO_CLASS { AccountDomainInformation = 5, DnsDomainInformation = 12, }} pub type PLSA_LOOKUP_DOMAIN_INFO_CLASS = *mut LSA_LOOKUP_DOMAIN_INFO_CLASS; pub type LSA_LOOKUP_HANDLE = ::PVOID; pub type PLSA_LOOKUP_HANDLE = *mut ::PVOID; deps/winapi-0.2.5/src/winioctl.rs0000644000000000000000000012620612613167613015440 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! This module defines the 32-Bit Windows Device I/O control codes. //123 pub const FILE_DEVICE_BEEP: ::DWORD = 0x00000001; pub const FILE_DEVICE_CD_ROM: ::DWORD = 0x00000002; pub const FILE_DEVICE_CD_ROM_FILE_SYSTEM: ::DWORD = 0x00000003; pub const FILE_DEVICE_CONTROLLER: ::DWORD = 0x00000004; pub const FILE_DEVICE_DATALINK: ::DWORD = 0x00000005; pub const FILE_DEVICE_DFS: ::DWORD = 0x00000006; pub const FILE_DEVICE_DISK: ::DWORD = 0x00000007; pub const FILE_DEVICE_DISK_FILE_SYSTEM: ::DWORD = 0x00000008; pub const FILE_DEVICE_FILE_SYSTEM: ::DWORD = 0x00000009; pub const FILE_DEVICE_INPORT_PORT: ::DWORD = 0x0000000a; pub const FILE_DEVICE_KEYBOARD: ::DWORD = 0x0000000b; pub const FILE_DEVICE_MAILSLOT: ::DWORD = 0x0000000c; pub const FILE_DEVICE_MIDI_IN: ::DWORD = 0x0000000d; pub const FILE_DEVICE_MIDI_OUT: ::DWORD = 0x0000000e; pub const FILE_DEVICE_MOUSE: ::DWORD = 0x0000000f; pub const FILE_DEVICE_MULTI_UNC_PROVIDER: ::DWORD = 0x00000010; pub const FILE_DEVICE_NAMED_PIPE: ::DWORD = 0x00000011; pub const FILE_DEVICE_NETWORK: ::DWORD = 0x00000012; pub const FILE_DEVICE_NETWORK_BROWSER: ::DWORD = 0x00000013; pub const FILE_DEVICE_NETWORK_FILE_SYSTEM: ::DWORD = 0x00000014; pub const FILE_DEVICE_NULL: ::DWORD = 0x00000015; pub const FILE_DEVICE_PARALLEL_PORT: ::DWORD = 0x00000016; pub const FILE_DEVICE_PHYSICAL_NETCARD: ::DWORD = 0x00000017; pub const FILE_DEVICE_PRINTER: ::DWORD = 0x00000018; pub const FILE_DEVICE_SCANNER: ::DWORD = 0x00000019; pub const FILE_DEVICE_SERIAL_MOUSE_PORT: ::DWORD = 0x0000001a; pub const FILE_DEVICE_SERIAL_PORT: ::DWORD = 0x0000001b; pub const FILE_DEVICE_SCREEN: ::DWORD = 0x0000001c; pub const FILE_DEVICE_SOUND: ::DWORD = 0x0000001d; pub const FILE_DEVICE_STREAMS: ::DWORD = 0x0000001e; pub const FILE_DEVICE_TAPE: ::DWORD = 0x0000001f; pub const FILE_DEVICE_TAPE_FILE_SYSTEM: ::DWORD = 0x00000020; pub const FILE_DEVICE_TRANSPORT: ::DWORD = 0x00000021; pub const FILE_DEVICE_UNKNOWN: ::DWORD = 0x00000022; pub const FILE_DEVICE_VIDEO: ::DWORD = 0x00000023; pub const FILE_DEVICE_VIRTUAL_DISK: ::DWORD = 0x00000024; pub const FILE_DEVICE_WAVE_IN: ::DWORD = 0x00000025; pub const FILE_DEVICE_WAVE_OUT: ::DWORD = 0x00000026; pub const FILE_DEVICE_8042_PORT: ::DWORD = 0x00000027; pub const FILE_DEVICE_NETWORK_REDIRECTOR: ::DWORD = 0x00000028; pub const FILE_DEVICE_BATTERY: ::DWORD = 0x00000029; pub const FILE_DEVICE_BUS_EXTENDER: ::DWORD = 0x0000002a; pub const FILE_DEVICE_MODEM: ::DWORD = 0x0000002b; pub const FILE_DEVICE_VDM: ::DWORD = 0x0000002c; pub const FILE_DEVICE_MASS_STORAGE: ::DWORD = 0x0000002d; pub const FILE_DEVICE_SMB: ::DWORD = 0x0000002e; pub const FILE_DEVICE_KS: ::DWORD = 0x0000002f; pub const FILE_DEVICE_CHANGER: ::DWORD = 0x00000030; pub const FILE_DEVICE_SMARTCARD: ::DWORD = 0x00000031; pub const FILE_DEVICE_ACPI: ::DWORD = 0x00000032; pub const FILE_DEVICE_DVD: ::DWORD = 0x00000033; pub const FILE_DEVICE_FULLSCREEN_VIDEO: ::DWORD = 0x00000034; pub const FILE_DEVICE_DFS_FILE_SYSTEM: ::DWORD = 0x00000035; pub const FILE_DEVICE_DFS_VOLUME: ::DWORD = 0x00000036; pub const FILE_DEVICE_SERENUM: ::DWORD = 0x00000037; pub const FILE_DEVICE_TERMSRV: ::DWORD = 0x00000038; pub const FILE_DEVICE_KSEC: ::DWORD = 0x00000039; pub const FILE_DEVICE_FIPS: ::DWORD = 0x0000003A; pub const FILE_DEVICE_INFINIBAND: ::DWORD = 0x0000003B; pub const FILE_DEVICE_VMBUS: ::DWORD = 0x0000003E; pub const FILE_DEVICE_CRYPT_PROVIDER: ::DWORD = 0x0000003F; pub const FILE_DEVICE_WPD: ::DWORD = 0x00000040; pub const FILE_DEVICE_BLUETOOTH: ::DWORD = 0x00000041; pub const FILE_DEVICE_MT_COMPOSITE: ::DWORD = 0x00000042; pub const FILE_DEVICE_MT_TRANSPORT: ::DWORD = 0x00000043; pub const FILE_DEVICE_BIOMETRIC: ::DWORD = 0x00000044; pub const FILE_DEVICE_PMI: ::DWORD = 0x00000045; pub const FILE_DEVICE_EHSTOR: ::DWORD = 0x00000046; pub const FILE_DEVICE_DEVAPI: ::DWORD = 0x00000047; pub const FILE_DEVICE_GPIO: ::DWORD = 0x00000048; pub const FILE_DEVICE_USBEX: ::DWORD = 0x00000049; pub const FILE_DEVICE_CONSOLE: ::DWORD = 0x00000050; pub const FILE_DEVICE_NFP: ::DWORD = 0x00000051; pub const FILE_DEVICE_SYSENV: ::DWORD = 0x00000052; pub const FILE_DEVICE_VIRTUAL_BLOCK: ::DWORD = 0x00000053; pub const FILE_DEVICE_POINT_OF_SERVICE: ::DWORD = 0x00000054; //224 pub const METHOD_BUFFERED: ::DWORD = 0; pub const METHOD_IN_DIRECT: ::DWORD = 1; pub const METHOD_OUT_DIRECT: ::DWORD = 2; pub const METHOD_NEITHER: ::DWORD = 3; //253 pub const FILE_ANY_ACCESS: ::DWORD = 0; pub const FILE_SPECIAL_ACCESS: ::DWORD = FILE_ANY_ACCESS; pub const FILE_READ_ACCESS: ::DWORD = 0x0001; pub const FILE_WRITE_ACCESS: ::DWORD = 0x0002; //281 pub const IOCTL_STORAGE_BASE: ::DWORD = FILE_DEVICE_MASS_STORAGE; pub const IOCTL_STORAGE_CHECK_VERIFY: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_STORAGE_CHECK_VERIFY2: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_MEDIA_REMOVAL: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_STORAGE_EJECT_MEDIA: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_STORAGE_LOAD_MEDIA: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_STORAGE_LOAD_MEDIA2: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_RESERVE: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_STORAGE_RELEASE: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_STORAGE_FIND_NEW_DEVICES: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_STORAGE_EJECTION_CONTROL: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0250, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_MCN_CONTROL: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0251, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_GET_MEDIA_TYPES: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_GET_MEDIA_TYPES_EX: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0301, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0304, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_GET_HOTPLUG_INFO: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0305, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_SET_HOTPLUG_INFO: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0306, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_STORAGE_RESET_BUS: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_STORAGE_RESET_DEVICE: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_STORAGE_BREAK_RESERVATION: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_STORAGE_PERSISTENT_RESERVE_IN: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0406, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_STORAGE_PERSISTENT_RESERVE_OUT: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0407, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_STORAGE_GET_DEVICE_NUMBER: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0420, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_PREDICT_FAILURE: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0440, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_FAILURE_PREDICTION_CONFIG: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0441, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_READ_CAPACITY: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0450, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_STORAGE_GET_DEVICE_TELEMETRY: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0470, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_STORAGE_DEVICE_TELEMETRY_NOTIFY: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0471, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_STORAGE_DEVICE_TELEMETRY_QUERY_CAPS: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0472, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_STORAGE_GET_DEVICE_TELEMETRY_RAW: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0473, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_STORAGE_QUERY_PROPERTY: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0500, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0501, METHOD_BUFFERED, FILE_WRITE_ACCESS); pub const IOCTL_STORAGE_GET_LB_PROVISIONING_MAP_RESOURCES: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0502, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_STORAGE_GET_BC_PROPERTIES: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0600, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_STORAGE_ALLOCATE_BC_STREAM: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0601, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_STORAGE_FREE_BC_STREAM: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0602, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_STORAGE_CHECK_PRIORITY_HINT_SUPPORT: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0620, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_START_DATA_INTEGRITY_CHECK: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0621, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_STORAGE_STOP_DATA_INTEGRITY_CHECK: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0622, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const OBSOLETE_IOCTL_STORAGE_RESET_BUS: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const OBSOLETE_IOCTL_STORAGE_RESET_DEVICE: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_STORAGE_ENABLE_IDLE_POWER: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0720, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_GET_IDLE_POWERUP_REASON: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0721, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_POWER_ACTIVE: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0722, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_POWER_IDLE: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0723, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_STORAGE_EVENT_NOTIFICATION: ::DWORD = CTL_CODE!(IOCTL_STORAGE_BASE, 0x0724, METHOD_BUFFERED, FILE_ANY_ACCESS); //2627 pub const IOCTL_DISK_BASE: ::DWORD = FILE_DEVICE_DISK; pub const IOCTL_DISK_GET_DRIVE_GEOMETRY: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_GET_PARTITION_INFO: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_DISK_SET_PARTITION_INFO: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_DISK_GET_DRIVE_LAYOUT: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_DISK_SET_DRIVE_LAYOUT: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_DISK_VERIFY: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_FORMAT_TRACKS: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_DISK_REASSIGN_BLOCKS: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_DISK_PERFORMANCE: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_IS_WRITABLE: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_LOGGING: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_FORMAT_TRACKS_EX: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x000b, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_DISK_HISTOGRAM_STRUCTURE: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x000c, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_HISTOGRAM_DATA: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x000d, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_HISTOGRAM_RESET: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x000e, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_REQUEST_STRUCTURE: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x000f, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_REQUEST_DATA: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_PERFORMANCE_OFF: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0018, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_CONTROLLER_NUMBER: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0011, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const SMART_GET_VERSION: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS); pub const SMART_SEND_DRIVE_COMMAND: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const SMART_RCV_DRIVE_DATA: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_DISK_GET_PARTITION_INFO_EX: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0012, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_SET_PARTITION_INFO_EX: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0013, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_DISK_GET_DRIVE_LAYOUT_EX: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0014, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_SET_DRIVE_LAYOUT_EX: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0015, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_DISK_CREATE_DISK: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0016, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_DISK_GET_LENGTH_INFO: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0017, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_DISK_GET_DRIVE_GEOMETRY_EX: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0028, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_REASSIGN_BLOCKS_EX: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0029, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_DISK_UPDATE_DRIVE_SIZE: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0032, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_DISK_GROW_PARTITION: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0034, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_DISK_GET_CACHE_INFORMATION: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0035, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_DISK_SET_CACHE_INFORMATION: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0036, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_DISK_GET_WRITE_CACHE_STATE: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0037, METHOD_BUFFERED, FILE_READ_ACCESS); pub const OBSOLETE_DISK_GET_WRITE_CACHE_STATE: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0037, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_DISK_DELETE_DRIVE_LAYOUT: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0040, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_DISK_UPDATE_PROPERTIES: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0050, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_FORMAT_DRIVE: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x00f3, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_DISK_SENSE_DEVICE: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x00f8, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_CHECK_VERIFY: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_DISK_MEDIA_REMOVAL: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_DISK_EJECT_MEDIA: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_DISK_LOAD_MEDIA: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_DISK_RESERVE: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_DISK_RELEASE: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_DISK_FIND_NEW_DEVICES: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_DISK_GET_MEDIA_TYPES: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_GET_DISK_ATTRIBUTES: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x003c, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_DISK_SET_DISK_ATTRIBUTES: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x003d, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_DISK_RESET_SNAPSHOT_INFO: ::DWORD = CTL_CODE!(IOCTL_DISK_BASE, 0x0084, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); //3907 pub const IOCTL_CHANGER_BASE: ::DWORD = FILE_DEVICE_CHANGER; pub const IOCTL_CHANGER_GET_PARAMETERS: ::DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0000, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_CHANGER_GET_STATUS: ::DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_CHANGER_GET_PRODUCT_DATA: ::DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_CHANGER_SET_ACCESS: ::DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_CHANGER_GET_ELEMENT_STATUS: ::DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0005, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_CHANGER_INITIALIZE_ELEMENT_STATUS: ::DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_CHANGER_SET_POSITION: ::DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_CHANGER_EXCHANGE_MEDIUM: ::DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0008, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_CHANGER_MOVE_MEDIUM: ::DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x0009, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_CHANGER_REINITIALIZE_TRANSPORT: ::DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x000A, METHOD_BUFFERED, FILE_READ_ACCESS); pub const IOCTL_CHANGER_QUERY_VOLUME_TAGS: ::DWORD = CTL_CODE!(IOCTL_CHANGER_BASE, 0x000B, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_SERIAL_LSRMST_INSERT: ::DWORD = CTL_CODE!(FILE_DEVICE_SERIAL_PORT, 31, METHOD_BUFFERED,FILE_ANY_ACCESS); pub const IOCTL_SERENUM_EXPOSE_HARDWARE: ::DWORD = CTL_CODE!(FILE_DEVICE_SERENUM, 128, METHOD_BUFFERED,FILE_ANY_ACCESS); pub const IOCTL_SERENUM_REMOVE_HARDWARE: ::DWORD = CTL_CODE!(FILE_DEVICE_SERENUM, 129, METHOD_BUFFERED,FILE_ANY_ACCESS); pub const IOCTL_SERENUM_PORT_DESC: ::DWORD = CTL_CODE!(FILE_DEVICE_SERENUM, 130, METHOD_BUFFERED,FILE_ANY_ACCESS); pub const IOCTL_SERENUM_GET_PORT_NAME: ::DWORD = CTL_CODE!(FILE_DEVICE_SERENUM, 131, METHOD_BUFFERED,FILE_ANY_ACCESS); //4690 pub const FSCTL_REQUEST_OPLOCK_LEVEL_1: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 0, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_REQUEST_OPLOCK_LEVEL_2: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 1, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_REQUEST_BATCH_OPLOCK: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 2, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_OPLOCK_BREAK_ACKNOWLEDGE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 3, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_OPBATCH_ACK_CLOSE_PENDING: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 4, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_OPLOCK_BREAK_NOTIFY: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 5, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_LOCK_VOLUME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_UNLOCK_VOLUME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 7, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_DISMOUNT_VOLUME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_IS_VOLUME_MOUNTED: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 10, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_IS_PATHNAME_VALID: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 11, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_MARK_VOLUME_DIRTY: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 12, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_QUERY_RETRIEVAL_POINTERS: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 14, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_GET_COMPRESSION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 15, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_SET_COMPRESSION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, ::FILE_READ_DATA | ::FILE_WRITE_DATA); pub const FSCTL_SET_BOOTLOADER_ACCESSED: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 19, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_MARK_AS_SYSTEM_HIVE: ::DWORD = FSCTL_SET_BOOTLOADER_ACCESSED; pub const FSCTL_OPLOCK_BREAK_ACK_NO_2: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 20, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_INVALIDATE_VOLUMES: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 21, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_QUERY_FAT_BPB: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 22, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_REQUEST_FILTER_OPLOCK: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 23, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_FILESYSTEM_GET_STATISTICS: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 24, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_GET_NTFS_VOLUME_DATA: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 25, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_GET_NTFS_FILE_RECORD: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 26, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_GET_VOLUME_BITMAP: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 27, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_GET_RETRIEVAL_POINTERS: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 28, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_MOVE_FILE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 29, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); pub const FSCTL_IS_VOLUME_DIRTY: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 30, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_ALLOW_EXTENDED_DASD_IO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 32, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_FIND_FILES_BY_SID: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 35, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_SET_OBJECT_ID: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 38, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); pub const FSCTL_GET_OBJECT_ID: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 39, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_DELETE_OBJECT_ID: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 40, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); pub const FSCTL_SET_REPARSE_POINT: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); pub const FSCTL_GET_REPARSE_POINT: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_DELETE_REPARSE_POINT: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); pub const FSCTL_ENUM_USN_DATA: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 44, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_SECURITY_ID_CHECK: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 45, METHOD_NEITHER, ::FILE_READ_DATA); pub const FSCTL_READ_USN_JOURNAL: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 46, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_SET_OBJECT_ID_EXTENDED: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 47, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); pub const FSCTL_CREATE_OR_GET_OBJECT_ID: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 48, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_SET_SPARSE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); pub const FSCTL_SET_ZERO_DATA: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 50, METHOD_BUFFERED, ::FILE_WRITE_DATA); pub const FSCTL_QUERY_ALLOCATED_RANGES: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 51, METHOD_NEITHER, ::FILE_READ_DATA); pub const FSCTL_ENABLE_UPGRADE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 52, METHOD_BUFFERED, ::FILE_WRITE_DATA); pub const FSCTL_SET_ENCRYPTION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 53, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_ENCRYPTION_FSCTL_IO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 54, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_WRITE_RAW_ENCRYPTED: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 55, METHOD_NEITHER, FILE_SPECIAL_ACCESS); pub const FSCTL_READ_RAW_ENCRYPTED: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 56, METHOD_NEITHER, FILE_SPECIAL_ACCESS); pub const FSCTL_CREATE_USN_JOURNAL: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 57, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_READ_FILE_USN_DATA: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 58, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_WRITE_USN_CLOSE_RECORD: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 59, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_EXTEND_VOLUME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 60, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_QUERY_USN_JOURNAL: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 61, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_DELETE_USN_JOURNAL: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 62, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_MARK_HANDLE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 63, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_SIS_COPYFILE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 64, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_SIS_LINK_FILES: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 65, METHOD_BUFFERED, ::FILE_READ_DATA | ::FILE_WRITE_DATA); pub const FSCTL_RECALL_FILE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 69, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_READ_FROM_PLEX: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 71, METHOD_OUT_DIRECT, ::FILE_READ_DATA); pub const FSCTL_FILE_PREFETCH: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 72, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); pub const FSCTL_MAKE_MEDIA_COMPATIBLE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 76, METHOD_BUFFERED, ::FILE_WRITE_DATA); pub const FSCTL_SET_DEFECT_MANAGEMENT: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 77, METHOD_BUFFERED, ::FILE_WRITE_DATA); pub const FSCTL_QUERY_SPARING_INFO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 78, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_QUERY_ON_DISK_VOLUME_INFO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 79, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_SET_VOLUME_COMPRESSION_STATE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 80, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); pub const FSCTL_TXFS_MODIFY_RM: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 81, METHOD_BUFFERED, ::FILE_WRITE_DATA); pub const FSCTL_TXFS_QUERY_RM_INFORMATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 82, METHOD_BUFFERED, ::FILE_READ_DATA); pub const FSCTL_TXFS_ROLLFORWARD_REDO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 84, METHOD_BUFFERED, ::FILE_WRITE_DATA); pub const FSCTL_TXFS_ROLLFORWARD_UNDO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 85, METHOD_BUFFERED, ::FILE_WRITE_DATA); pub const FSCTL_TXFS_START_RM: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 86, METHOD_BUFFERED, ::FILE_WRITE_DATA); pub const FSCTL_TXFS_SHUTDOWN_RM: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 87, METHOD_BUFFERED, ::FILE_WRITE_DATA); pub const FSCTL_TXFS_READ_BACKUP_INFORMATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 88, METHOD_BUFFERED, ::FILE_READ_DATA); pub const FSCTL_TXFS_WRITE_BACKUP_INFORMATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 89, METHOD_BUFFERED, ::FILE_WRITE_DATA); pub const FSCTL_TXFS_CREATE_SECONDARY_RM: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 90, METHOD_BUFFERED, ::FILE_WRITE_DATA); pub const FSCTL_TXFS_GET_METADATA_INFO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 91, METHOD_BUFFERED, ::FILE_READ_DATA); pub const FSCTL_TXFS_GET_TRANSACTED_VERSION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 92, METHOD_BUFFERED, ::FILE_READ_DATA); pub const FSCTL_TXFS_SAVEPOINT_INFORMATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 94, METHOD_BUFFERED, ::FILE_WRITE_DATA); pub const FSCTL_TXFS_CREATE_MINIVERSION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 95, METHOD_BUFFERED, ::FILE_WRITE_DATA); pub const FSCTL_TXFS_TRANSACTION_ACTIVE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 99, METHOD_BUFFERED, ::FILE_READ_DATA); pub const FSCTL_SET_ZERO_ON_DEALLOCATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 101, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); pub const FSCTL_SET_REPAIR: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 102, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_GET_REPAIR: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 103, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_WAIT_FOR_REPAIR: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 104, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_INITIATE_REPAIR: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 106, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_CSC_INTERNAL: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 107, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_SHRINK_VOLUME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 108, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); pub const FSCTL_SET_SHORT_NAME_BEHAVIOR: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 109, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_DFSR_SET_GHOST_HANDLE_STATE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 110, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_TXFS_LIST_TRANSACTION_LOCKED_FILES: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 120, METHOD_BUFFERED, ::FILE_READ_DATA); pub const FSCTL_TXFS_LIST_TRANSACTIONS: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 121, METHOD_BUFFERED, ::FILE_READ_DATA); pub const FSCTL_QUERY_PAGEFILE_ENCRYPTION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 122, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_RESET_VOLUME_ALLOCATION_HINTS: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 123, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_QUERY_DEPENDENT_VOLUME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 124, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_SD_GLOBAL_CHANGE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 125, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_TXFS_READ_BACKUP_INFORMATION2: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 126, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_LOOKUP_STREAM_FROM_CLUSTER: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 127, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_TXFS_WRITE_BACKUP_INFORMATION2: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 128, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_FILE_TYPE_NOTIFICATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 129, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_FILE_LEVEL_TRIM: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 130, METHOD_BUFFERED, ::FILE_WRITE_DATA); pub const FSCTL_GET_BOOT_AREA_INFO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 140, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_GET_RETRIEVAL_POINTER_BASE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 141, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_SET_PERSISTENT_VOLUME_STATE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 142, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_QUERY_PERSISTENT_VOLUME_STATE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 143, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_REQUEST_OPLOCK: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 144, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_CSV_TUNNEL_REQUEST: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 145, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_IS_CSV_FILE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 146, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_QUERY_FILE_SYSTEM_RECOGNITION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 147, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_CSV_GET_VOLUME_PATH_NAME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 148, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_CSV_GET_VOLUME_NAME_FOR_VOLUME_MOUNT_POINT: ::DWORD = CTL_CODE!( FILE_DEVICE_FILE_SYSTEM, 149, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_CSV_GET_VOLUME_PATH_NAMES_FOR_VOLUME_NAME: ::DWORD = CTL_CODE!( FILE_DEVICE_FILE_SYSTEM, 150, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_IS_FILE_ON_CSV_VOLUME: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 151, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_CORRUPTION_HANDLING: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 152, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_OFFLOAD_READ: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 153, METHOD_BUFFERED, FILE_READ_ACCESS); pub const FSCTL_OFFLOAD_WRITE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 154, METHOD_BUFFERED, FILE_WRITE_ACCESS); pub const FSCTL_CSV_INTERNAL: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 155, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_SET_PURGE_FAILURE_MODE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 156, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_QUERY_FILE_LAYOUT: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 157, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_IS_VOLUME_OWNED_BYCSVFS: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 158, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_GET_INTEGRITY_INFORMATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 159, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_SET_INTEGRITY_INFORMATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 160, METHOD_BUFFERED, ::FILE_READ_DATA | ::FILE_WRITE_DATA); pub const FSCTL_QUERY_FILE_REGIONS: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 161, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_DEDUP_FILE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 165, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_DEDUP_QUERY_FILE_HASHES: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 166, METHOD_NEITHER, ::FILE_READ_DATA); pub const FSCTL_DEDUP_QUERY_RANGE_STATE: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 167, METHOD_NEITHER, ::FILE_READ_DATA); pub const FSCTL_DEDUP_QUERY_REPARSE_INFO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 168, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_RKF_INTERNAL: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 171, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_SCRUB_DATA: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 172, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_REPAIR_COPIES: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 173, METHOD_BUFFERED, ::FILE_READ_DATA | ::FILE_WRITE_DATA); pub const FSCTL_DISABLE_LOCAL_BUFFERING: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 174, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_CSV_MGMT_LOCK: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 175, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_CSV_QUERY_DOWN_LEVEL_FILE_SYSTEM_CHARACTERISTICS: ::DWORD = CTL_CODE!( FILE_DEVICE_FILE_SYSTEM, 176, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_ADVANCE_FILE_ID: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 177, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_CSV_SYNC_TUNNEL_REQUEST: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 178, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_CSV_QUERY_VETO_FILE_DIRECT_IO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 179, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_WRITE_USN_REASON: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 180, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_CSV_CONTROL: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 181, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_GET_REFS_VOLUME_DATA: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 182, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_CSV_H_BREAKING_SYNC_TUNNEL_REQUEST: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 185, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_QUERY_STORAGE_CLASSES: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 187, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_QUERY_REGION_INFO: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 188, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_USN_TRACK_MODIFIED_RANGES: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 189, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_QUERY_SHARED_VIRTUAL_DISK_SUPPORT: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 192, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_SVHDX_SYNC_TUNNEL_REQUEST: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 193, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_SVHDX_SET_INITIATOR_INFORMATION: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 194, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_SET_EXTERNAL_BACKING: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 195, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); pub const FSCTL_GET_EXTERNAL_BACKING: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 196, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_DELETE_EXTERNAL_BACKING: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 197, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); pub const FSCTL_ENUM_EXTERNAL_BACKING: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 198, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const FSCTL_ENUM_OVERLAY: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 199, METHOD_NEITHER, FILE_ANY_ACCESS); pub const FSCTL_ADD_OVERLAY: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 204, METHOD_BUFFERED, ::FILE_WRITE_DATA); pub const FSCTL_REMOVE_OVERLAY: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 205, METHOD_BUFFERED, ::FILE_WRITE_DATA); pub const FSCTL_UPDATE_OVERLAY: ::DWORD = CTL_CODE!(FILE_DEVICE_FILE_SYSTEM, 206, METHOD_BUFFERED, ::FILE_WRITE_DATA); // FILE_DEVICE_AVIO is defined nowhere //pub const IOCTL_AVIO_ALLOCATE_STREAM: ::DWORD = CTL_CODE!(FILE_DEVICE_AVIO, 1, METHOD_BUFFERED, // FILE_SPECIAL_ACCESS); //pub const IOCTL_AVIO_FREE_STREAM: ::DWORD = CTL_CODE!(FILE_DEVICE_AVIO, 2, METHOD_BUFFERED, // FILE_SPECIAL_ACCESS); //pub const IOCTL_AVIO_MODIFY_STREAM: ::DWORD = CTL_CODE!(FILE_DEVICE_AVIO, 3, METHOD_BUFFERED, // FILE_SPECIAL_ACCESS); STRUCT!{struct PATHNAME_BUFFER { PathNameLength: ::DWORD, Name: [::WCHAR; 1], }} pub type PPATHNAME_BUFFER = *mut PATHNAME_BUFFER; #[repr(C)] #[derive(Copy)] pub struct FSCTL_QUERY_FAT_BPB_BUFFER { pub First0x24BytesOfBootSector: [::BYTE; 0x24], } impl Clone for FSCTL_QUERY_FAT_BPB_BUFFER {fn clone(&self) -> FSCTL_QUERY_FAT_BPB_BUFFER { *self }} pub type PFSCTL_QUERY_FAT_BPB_BUFFER = *mut FSCTL_QUERY_FAT_BPB_BUFFER; STRUCT!{struct NTFS_VOLUME_DATA_BUFFER { VolumeSerialNumber: ::LARGE_INTEGER, NumberSectors: ::LARGE_INTEGER, TotalClusters: ::LARGE_INTEGER, FreeClusters: ::LARGE_INTEGER, TotalReserved: ::LARGE_INTEGER, BytesPerSector: ::DWORD, BytesPerCluster: ::DWORD, BytesPerFileRecordSegment: ::DWORD, ClustersPerFileRecordSegment: ::DWORD, MftValidDataLength: ::LARGE_INTEGER, MftStartLcn: ::LARGE_INTEGER, Mft2StartLcn: ::LARGE_INTEGER, MftZoneStart: ::LARGE_INTEGER, MftZoneEnd: ::LARGE_INTEGER, }} pub type PNTFS_VOLUME_DATA_BUFFER = *mut NTFS_VOLUME_DATA_BUFFER; STRUCT!{struct NTFS_EXTENDED_VOLUME_DATA { ByteCount: ::DWORD, MajorVersion: ::WORD, MinorVersion: ::WORD, BytesPerPhysicalSector: ::DWORD, LfsMajorVersion: ::WORD, LfsMinorVersion: ::WORD, }} pub type PNTFS_EXTENDED_VOLUME_DATA = *mut NTFS_EXTENDED_VOLUME_DATA; STRUCT!{struct REFS_VOLUME_DATA_BUFFER { ByteCount: ::DWORD, MajorVersion: ::DWORD, MinorVersion: ::DWORD, BytesPerPhysicalSector: ::DWORD, VolumeSerialNumber: ::LARGE_INTEGER, NumberSectors: ::LARGE_INTEGER, TotalClusters: ::LARGE_INTEGER, FreeClusters: ::LARGE_INTEGER, TotalReserved: ::LARGE_INTEGER, BytesPerSector: ::DWORD, BytesPerCluster: ::DWORD, MaximumSizeOfResidentFile: ::LARGE_INTEGER, Reserved: [::LARGE_INTEGER; 10], }} pub type PREFS_VOLUME_DATA_BUFFER = *mut REFS_VOLUME_DATA_BUFFER; STRUCT!{struct STARTING_LCN_INPUT_BUFFER { StartingLcn: ::LARGE_INTEGER, }} pub type PSTARTING_LCN_INPUT_BUFFER = *mut STARTING_LCN_INPUT_BUFFER; STRUCT!{struct VOLUME_BITMAP_BUFFER { StartingLcn: ::LARGE_INTEGER, BitmapSize: ::LARGE_INTEGER, Buffer: [::BYTE; 1], }} pub type PVOLUME_BITMAP_BUFFER = *mut VOLUME_BITMAP_BUFFER; STRUCT!{struct STARTING_VCN_INPUT_BUFFER { StartingVcn: ::LARGE_INTEGER, }} pub type PSTARTING_VCN_INPUT_BUFFER = *mut STARTING_VCN_INPUT_BUFFER; STRUCT!{struct RETRIEVAL_POINTERS_BUFFER_INTERNAL { NextVcn: ::LARGE_INTEGER, Lcn: ::LARGE_INTEGER, }} STRUCT!{struct RETRIEVAL_POINTERS_BUFFER { ExtentCount: ::DWORD, StartingVcn: ::LARGE_INTEGER, Extents: [RETRIEVAL_POINTERS_BUFFER_INTERNAL; 1], }} pub type PRETRIEVAL_POINTERS_BUFFER = *mut RETRIEVAL_POINTERS_BUFFER; STRUCT!{struct NTFS_FILE_RECORD_INPUT_BUFFER { FileReferenceNumber: ::LARGE_INTEGER, }} pub type PNTFS_FILE_RECORD_INPUT_BUFFER = *mut NTFS_FILE_RECORD_INPUT_BUFFER; STRUCT!{struct NTFS_FILE_RECORD_OUTPUT_BUFFER { FileReferenceNumber: ::LARGE_INTEGER, FileRecordLength: ::DWORD, FileRecordBuffer: [::BYTE; 1], }} pub type PNTFS_FILE_RECORD_OUTPUT_BUFFER = *mut NTFS_FILE_RECORD_OUTPUT_BUFFER; STRUCT!{struct MOVE_FILE_DATA { FileHandle: ::HANDLE, StartingVcn: ::LARGE_INTEGER, StartingLcn: ::LARGE_INTEGER, ClusterCount: ::DWORD, }} pub type PMOVE_FILE_DATA = *mut MOVE_FILE_DATA; STRUCT!{struct MOVE_FILE_RECORD_DATA { FileHandle: ::HANDLE, SourceFileRecord: ::LARGE_INTEGER, TargetFileRecord: ::LARGE_INTEGER, }} pub type PMOVE_FILE_RECORD_DATA = *mut MOVE_FILE_RECORD_DATA; //9207 pub const IOCTL_VOLUME_BASE: ::DWORD = 0x00000056; pub const IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS: ::DWORD = CTL_CODE!(IOCTL_VOLUME_BASE, 0, METHOD_BUFFERED, FILE_ANY_ACCESS); STRUCT!{struct DISK_EXTENT { DiskNumber: ::DWORD, StartingOffset: ::LARGE_INTEGER, ExtentLength: ::LARGE_INTEGER, }} pub type PDISK_EXTENT = *mut DISK_EXTENT; STRUCT!{struct VOLUME_DISK_EXTENTS { NumberOfDiskExtents: ::DWORD, Extents: [DISK_EXTENT; ::ANYSIZE_ARRAY], }} pub type PVOLUME_DISK_EXTENTS = *mut VOLUME_DISK_EXTENTS; pub const IOCTL_VOLUME_ONLINE: ::DWORD = CTL_CODE!(IOCTL_VOLUME_BASE, 2, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_VOLUME_OFFLINE: ::DWORD = CTL_CODE!(IOCTL_VOLUME_BASE, 3, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS); pub const IOCTL_VOLUME_IS_CLUSTERED: ::DWORD = CTL_CODE!(IOCTL_VOLUME_BASE, 12, METHOD_BUFFERED, FILE_ANY_ACCESS); pub const IOCTL_VOLUME_GET_GPT_ATTRIBUTES: ::DWORD = CTL_CODE!(IOCTL_VOLUME_BASE, 14, METHOD_BUFFERED, FILE_ANY_ACCESS); deps/winapi-0.2.5/src/d2d1.rs0000644000000000000000000007444012615662007014343 0ustar rootroot// Copyright © 2015, Connor Hilarides // Licensed under the MIT License //! Mappings for the contents of d2d1.h // Types confirmed affected by the ABI issue: // D2D1_SIZE_F, D2D1_SIZE_U, D2D1_COLOR_F, D2D1_PIXEL_FORMAT, // D2D1_POINT_2F pub const D2D1_DEFAULT_FLATTENING_TOLERANCE: ::FLOAT = 0.25; pub const D2D1_INTERPOLATION_MODE_DEFINITION_NEAREST_NEIGHBOR: ::DWORD = 0; pub const D2D1_INTERPOLATION_MODE_DEFINITION_LINEAR: ::DWORD = 1; pub const D2D1_INTERPOLATION_MODE_DEFINITION_CUBIC: ::DWORD = 2; pub const D2D1_INTERPOLATION_MODE_DEFINITION_MULTI_SAMPLE_LINEAR: ::DWORD = 3; pub const D2D1_INTERPOLATION_MODE_DEFINITION_ANISOTROPIC: ::DWORD = 4; pub const D2D1_INTERPOLATION_MODE_DEFINITION_HIGH_QUALITY_CUBIC: ::DWORD = 5; pub const D2D1_INTERPOLATION_MODE_DEFINITION_FANT: ::DWORD = 6; pub const D2D1_INTERPOLATION_MODE_DEFINITION_MIPMAP_LINEAR: ::DWORD = 7; ENUM!{enum D2D1_GAMMA { D2D1_GAMMA_2_2 = 0, D2D1_GAMMA_1_0 = 1, }} ENUM!{enum D2D1_OPACITY_MASK_CONTENT { D2D1_OPACITY_MASK_CONTENT_GRAPHICS = 0, D2D1_OPACITY_MASK_CONTENT_TEXT_NATURAL = 1, D2D1_OPACITY_MASK_CONTENT_TEXT_GDI_COMPATIBLE = 2, }} ENUM!{enum D2D1_EXTEND_MODE { D2D1_EXTEND_MODE_CLAMP = 0, D2D1_EXTEND_MODE_WRAP = 1, D2D1_EXTEND_MODE_MIRROR = 2, }} ENUM!{enum D2D1_ANTIALIAS_MODE { D2D1_ANTIALIAS_MODE_PER_PRIMITIVE = 0, D2D1_ANTIALIAS_MODE_ALIASED = 1, }} ENUM!{enum D2D1_TEXT_ANTIALIAS_MODE { D2D1_TEXT_ANTIALIAS_MODE_DEFAULT = 0, D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE = 1, D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE = 2, D2D1_TEXT_ANTIALIAS_MODE_ALIASED = 3, }} ENUM!{enum D2D1_BITMAP_INTERPOLATION_MODE { D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR = D2D1_INTERPOLATION_MODE_DEFINITION_NEAREST_NEIGHBOR, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR = D2D1_INTERPOLATION_MODE_DEFINITION_LINEAR, }} FLAGS!{enum D2D1_DRAW_TEXT_OPTIONS { D2D1_DRAW_TEXT_OPTIONS_NO_SNAP = 0x00000001, D2D1_DRAW_TEXT_OPTIONS_CLIP = 0x00000002, D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT = 0x00000004, D2D1_DRAW_TEXT_OPTIONS_NONE = 0x00000000, }} pub type D2D1_POINT_2U = ::D2D_POINT_2U; pub type D2D1_POINT_2F = ::D2D_POINT_2F; pub type D2D1_RECT_F = ::D2D_RECT_F; pub type D2D1_RECT_U = ::D2D_RECT_U; pub type D2D1_SIZE_F = ::D2D_SIZE_F; pub type D2D1_SIZE_U = ::D2D_SIZE_U; pub type D2D1_COLOR_F = ::D2D_COLOR_F; pub type D2D1_MATRIX_3X2_F = ::D2D_MATRIX_3X2_F; pub type D2D1_TAG = ::UINT64; STRUCT!{struct D2D1_BITMAP_PROPERTIES { pixelFormat: ::D2D1_PIXEL_FORMAT, dpiX: ::FLOAT, dpiY: ::FLOAT, }} STRUCT!{struct D2D1_GRADIENT_STOP { position: ::FLOAT, color: D2D1_COLOR_F, }} STRUCT!{struct D2D1_BRUSH_PROPERTIES { opacity: ::FLOAT, transform: D2D1_MATRIX_3X2_F, }} STRUCT!{struct D2D1_BITMAP_BRUSH_PROPERTIES { extendModeX: D2D1_EXTEND_MODE, extendModeY: D2D1_EXTEND_MODE, interpolationMode: D2D1_BITMAP_INTERPOLATION_MODE, }} STRUCT!{struct D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES { startPoint: ::D2D1_POINT_2F, endPoint: ::D2D1_POINT_2F, }} STRUCT!{struct D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES { center: ::D2D1_POINT_2F, gradientOriginOffset: ::D2D1_POINT_2F, radiusX: ::FLOAT, radiusY: ::FLOAT, }} ENUM!{enum D2D1_ARC_SIZE { D2D1_ARC_SIZE_SMALL = 0, D2D1_ARC_SIZE_LARGE = 1, }} ENUM!{enum D2D1_CAP_STYLE { D2D1_CAP_STYLE_FLAT = 0, D2D1_CAP_STYLE_SQUARE = 1, D2D1_CAP_STYLE_ROUND = 2, D2D1_CAP_STYLE_TRIANGLE = 3, }} ENUM!{enum D2D1_DASH_STYLE { D2D1_DASH_STYLE_SOLID = 0, D2D1_DASH_STYLE_DASH = 1, D2D1_DASH_STYLE_DOT = 2, D2D1_DASH_STYLE_DASH_DOT = 3, D2D1_DASH_STYLE_DASH_DOT_DOT = 4, D2D1_DASH_STYLE_CUSTOM = 5, }} ENUM!{enum D2D1_LINE_JOIN { D2D1_LINE_JOIN_MITER = 0, D2D1_LINE_JOIN_BEVEL = 1, D2D1_LINE_JOIN_ROUND = 2, D2D1_LINE_JOIN_MITER_OR_BEVEL = 3, }} ENUM!{enum D2D1_COMBINE_MODE { D2D1_COMBINE_MODE_UNION = 0, D2D1_COMBINE_MODE_INTERSECT = 1, D2D1_COMBINE_MODE_XOR = 2, D2D1_COMBINE_MODE_EXCLUDE = 3, }} ENUM!{enum D2D1_GEOMETRY_RELATION { D2D1_GEOMETRY_RELATION_UNKNOWN = 0, D2D1_GEOMETRY_RELATION_DISJOINT = 1, D2D1_GEOMETRY_RELATION_IS_CONTAINED = 2, D2D1_GEOMETRY_RELATION_CONTAINS = 3, D2D1_GEOMETRY_RELATION_OVERLAP = 4, }} ENUM!{enum D2D1_GEOMETRY_SIMPLIFICATION_OPTION { D2D1_GEOMETRY_SIMPLIFICATION_OPTION_CUBICS_AND_LINES = 0, D2D1_GEOMETRY_SIMPLIFICATION_OPTION_LINES = 1, }} ENUM!{enum D2D1_FIGURE_BEGIN { D2D1_FIGURE_BEGIN_FILLED = 0, D2D1_FIGURE_BEGIN_HOLLOW = 1, }} ENUM!{enum D2D1_FIGURE_END { D2D1_FIGURE_END_OPEN = 0, D2D1_FIGURE_END_CLOSED = 1, }} STRUCT!{struct D2D1_BEZIER_SEGMENT { point1: ::D2D1_POINT_2F, point2: ::D2D1_POINT_2F, point3: ::D2D1_POINT_2F, }} STRUCT!{struct D2D1_TRIANGLE { point1: ::D2D1_POINT_2F, point2: ::D2D1_POINT_2F, point3: ::D2D1_POINT_2F, }} FLAGS!{enum D2D1_PATH_SEGMENT { D2D1_PATH_SEGMENT_NONE = 0x00000000, D2D1_PATH_SEGMENT_FORCE_UNSTROKED = 0x00000001, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN = 0x00000002, }} ENUM!{enum D2D1_SWEEP_DIRECTION { D2D1_SWEEP_DIRECTION_COUNTER_CLOCKWISE = 0, D2D1_SWEEP_DIRECTION_CLOCKWISE = 1, }} ENUM!{enum D2D1_FILL_MODE { D2D1_FILL_MODE_ALTERNATE = 0, D2D1_FILL_MODE_WINDING = 1, }} STRUCT!{struct D2D1_ARC_SEGMENT { point: ::D2D1_POINT_2F, size: D2D1_SIZE_F, rotationAngle: ::FLOAT, sweepDirection: D2D1_SWEEP_DIRECTION, arcSize: D2D1_ARC_SIZE, }} STRUCT!{struct D2D1_QUADRATIC_BEZIER_SEGMENT { point1: ::D2D1_POINT_2F, point2: ::D2D1_POINT_2F, }} STRUCT!{struct D2D1_ELLIPSE { point: ::D2D1_POINT_2F, radiusX: ::FLOAT, radiusY: ::FLOAT, }} STRUCT!{struct D2D1_ROUNDED_RECT { rect: ::D2D1_RECT_F, radiusX: ::FLOAT, radiusY: ::FLOAT, }} STRUCT!{struct D2D1_STROKE_STYLE_PROPERTIES { startCap: D2D1_CAP_STYLE, endCap: D2D1_CAP_STYLE, dashCap: D2D1_CAP_STYLE, lineJoin: D2D1_LINE_JOIN, miterLimit: ::FLOAT, dashStyle: D2D1_DASH_STYLE, dashOffset: ::FLOAT, }} FLAGS!{enum D2D1_LAYER_OPTIONS { D2D1_LAYER_OPTIONS_NONE = 0x00000000, D2D1_LAYER_OPTIONS_INITIALIZE_FOR_CLEARTYPE = 0x00000001, }} STRUCT!{struct D2D1_LAYER_PARAMETERS { contentBounds: ::D2D1_RECT_F, geometricMask: *mut ID2D1Geometry, maskAntialiasMode: D2D1_ANTIALIAS_MODE, maskTransform: D2D1_MATRIX_3X2_F, opacity: ::FLOAT, opacityBrush: *mut ID2D1Brush, layerOptions: D2D1_LAYER_OPTIONS, }} ENUM!{enum D2D1_WINDOW_STATE { D2D1_WINDOW_STATE_NONE = 0x0000000, D2D1_WINDOW_STATE_OCCLUDED = 0x0000001, }} ENUM!{enum D2D1_RENDER_TARGET_TYPE { D2D1_RENDER_TARGET_TYPE_DEFAULT = 0, D2D1_RENDER_TARGET_TYPE_SOFTWARE = 1, D2D1_RENDER_TARGET_TYPE_HARDWARE = 2, }} ENUM!{enum D2D1_FEATURE_LEVEL { D2D1_FEATURE_LEVEL_DEFAULT = 0, D2D1_FEATURE_LEVEL_9 = ::D3D_FEATURE_LEVEL_9_1.0, D2D1_FEATURE_LEVEL_10 = ::D3D_FEATURE_LEVEL_10_0.0, }} FLAGS!{enum D2D1_RENDER_TARGET_USAGE { D2D1_RENDER_TARGET_USAGE_NONE = 0x00000000, D2D1_RENDER_TARGET_USAGE_FORCE_BITMAP_REMOTING = 0x00000001, D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE = 0x00000002, }} FLAGS!{enum D2D1_PRESENT_OPTIONS { D2D1_PRESENT_OPTIONS_NONE = 0x00000000, D2D1_PRESENT_OPTIONS_RETAIN_CONTENTS = 0x00000001, D2D1_PRESENT_OPTIONS_IMMEDIATELY = 0x00000002, }} STRUCT!{struct D2D1_RENDER_TARGET_PROPERTIES { _type: D2D1_RENDER_TARGET_TYPE, pixelFormat: ::D2D1_PIXEL_FORMAT, dpiX: ::FLOAT, dpiY: ::FLOAT, usage: D2D1_RENDER_TARGET_USAGE, minLevel: D2D1_FEATURE_LEVEL, }} STRUCT!{struct D2D1_HWND_RENDER_TARGET_PROPERTIES { hwnd: ::HWND, pixelSize: D2D1_SIZE_U, presentOptions: D2D1_PRESENT_OPTIONS, }} FLAGS!{enum D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS { D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_NONE = 0x00000000, D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_GDI_COMPATIBLE = 0x00000001, }} STRUCT!{struct D2D1_DRAWING_STATE_DESCRIPTION { antialiasMode: D2D1_ANTIALIAS_MODE, textAntialiasMode: D2D1_TEXT_ANTIALIAS_MODE, tag1: D2D1_TAG, tag2: D2D1_TAG, transform: D2D1_MATRIX_3X2_F, }} ENUM!{enum D2D1_DC_INITIALIZE_MODE { D2D1_DC_INITIALIZE_MODE_COPY = 0, D2D1_DC_INITIALIZE_MODE_CLEAR = 1, }} ENUM!{enum D2D1_DEBUG_LEVEL { D2D1_DEBUG_LEVEL_NONE = 0, D2D1_DEBUG_LEVEL_ERROR = 1, D2D1_DEBUG_LEVEL_WARNING = 2, D2D1_DEBUG_LEVEL_INFORMATION = 3, }} ENUM!{enum D2D1_FACTORY_TYPE { D2D1_FACTORY_TYPE_SINGLE_THREADED = 0, D2D1_FACTORY_TYPE_MULTI_THREADED = 1, }} STRUCT!{struct D2D1_FACTORY_OPTIONS { debugLevel: D2D1_DEBUG_LEVEL, }} RIDL!( interface ID2D1Resource(ID2D1ResourceVtbl): IUnknown(IUnknownVtbl) { fn GetFactory(&mut self, factory: *mut *mut ID2D1Factory) -> ::HRESULT }); RIDL!( interface ID2D1Image(ID2D1ImageVtbl): ID2D1Resource(ID2D1ResourceVtbl) { }); RIDL!( interface ID2D1Bitmap(ID2D1BitmapVtbl): ID2D1Image(ID2D1ImageVtbl) { fn GetSize(&mut self, ret: *mut D2D1_SIZE_F) -> *mut D2D1_SIZE_F, // FIXME: ABI issue fn GetPixelSize(&mut self, ret: *mut D2D1_SIZE_U) -> *mut D2D1_SIZE_U, // FIXME: ABI issue fn GetPixelFormat( &mut self, ret: *mut ::D2D1_PIXEL_FORMAT ) -> *mut ::D2D1_PIXEL_FORMAT, // FIXME: ABI issue fn GetDpi(&mut self, dpiX: *mut ::FLOAT, dpiY: *mut ::FLOAT) -> (), fn CopyFromBitmap( &mut self, destPoint: *const ::D2D1_POINT_2U, bitmap: *mut ID2D1Bitmap, srcRect: *const ::D2D1_RECT_U ) -> ::HRESULT, fn CopyFromRenderTarget( &mut self, destPoint: *const ::D2D1_POINT_2U, renderTarget: *mut ID2D1RenderTarget, srcRect: *const ::D2D1_RECT_U ) -> ::HRESULT, fn CopyFromMemory( &mut self, dstRect: *const ::D2D1_RECT_U, srcData: *const ::c_void, pitch: ::UINT32 ) -> ::HRESULT }); RIDL!( interface ID2D1GradientStopCollection(ID2D1GradientStopCollectionVtbl) : ID2D1Resource(ID2D1ResourceVtbl) { fn GetGradientStopCount(&mut self) -> ::UINT32, fn GetGradientStops( &mut self, gradientStops: *mut D2D1_GRADIENT_STOP, gradientStopsCount: ::UINT32 ) -> (), fn GetColorInterpolationGamma(&mut self) -> D2D1_GAMMA, fn GetExtendMode(&mut self) -> D2D1_EXTEND_MODE }); RIDL!( interface ID2D1Brush(ID2D1BrushVtbl): ID2D1Resource(ID2D1ResourceVtbl) { fn SetOpacity(&mut self, opacity: ::FLOAT) -> (), fn SetTransform(&mut self, transform: *const D2D1_MATRIX_3X2_F) -> (), fn GetOpacity(&mut self) -> ::FLOAT, fn GetTransform(&mut self, transform: *mut D2D1_MATRIX_3X2_F) -> () }); RIDL!( interface ID2D1BitmapBrush(ID2D1BitmapBrushVtbl): ID2D1Brush(ID2D1BrushVtbl) { fn SetExtendModeX(&mut self, extendModeX: D2D1_EXTEND_MODE) -> (), fn SetExtendModeY(&mut self, extendModeY: D2D1_EXTEND_MODE) -> (), fn SetInterpolationMode(&mut self, interpolationMode: D2D1_BITMAP_INTERPOLATION_MODE) -> (), fn SetBitmap(&mut self, bitmap: *mut ID2D1Bitmap) -> (), fn GetExtendModeX(&mut self) -> D2D1_EXTEND_MODE, fn GetExtendModeY(&mut self) -> D2D1_EXTEND_MODE, fn GetInterpolationMode(&mut self) -> D2D1_BITMAP_INTERPOLATION_MODE, fn GetBitmap(&mut self, bitmap: *mut *mut ID2D1Bitmap) -> () }); RIDL!( interface ID2D1SolidColorBrush(ID2D1SolidColorBrushVtbl): ID2D1Brush(ID2D1BrushVtbl) { fn SetColor(&mut self, color: *const D2D1_COLOR_F) -> (), fn GetColor(&mut self, color: *mut D2D1_COLOR_F) -> *mut D2D1_COLOR_F }); RIDL!( interface ID2D1LinearGradientBrush(ID2D1LinearGradientBrushVtbl): ID2D1Brush(ID2D1BrushVtbl) { fn SetStartPoint(&mut self, startPoint: ::D2D1_POINT_2F) -> (), fn SetEndPoint(&mut self, endPoint: ::D2D1_POINT_2F) -> (), fn GetStartPoint(&mut self, ret: *mut D2D1_POINT_2F) -> *mut D2D1_POINT_2F, // FIXME ABI issue fn GetEndPoint(&mut self, ret: *mut D2D1_POINT_2F) -> *mut D2D1_POINT_2F, // FIXME ABI issue fn GetGradientStopCollection( &mut self, gradientStopCollection: *mut *mut ID2D1GradientStopCollection ) -> () }); RIDL!( interface ID2D1RadialGradientBrush(ID2D1RadialGradientBrushVtbl): ID2D1Brush(ID2D1BrushVtbl) { fn SetCenter(&mut self, center: ::D2D1_POINT_2F) -> (), fn SetGradientOriginOffset(&mut self, gradientOriginOffset: ::D2D1_POINT_2F) -> (), fn SetRadiusX(&mut self, radiusX: ::FLOAT) -> (), fn SetRadiusY(&mut self, radiusY: ::FLOAT) -> (), fn GetCenter(&mut self, ret: *mut D2D1_POINT_2F) -> *mut D2D1_POINT_2F, // FIXME ABI issue fn GetGradientOriginOffset( &mut self, ret: *mut D2D1_POINT_2F ) -> *mut D2D1_POINT_2F, // FIXME ABI issue fn GetRadiusX(&mut self) -> ::FLOAT, fn GetRadiusY(&mut self) -> ::FLOAT, fn GetGradientStopCollection( &mut self, gradientStopCollection: *mut *mut ID2D1GradientStopCollection ) -> () }); RIDL!( interface ID2D1StrokeStyle(ID2D1StrokeStyleVtbl): ID2D1Resource(ID2D1ResourceVtbl) { fn GetStartCap(&mut self) -> D2D1_CAP_STYLE, fn GetEndCap(&mut self) -> D2D1_CAP_STYLE, fn GetDashCap(&mut self) -> D2D1_CAP_STYLE, fn GetMiterLimit(&mut self) -> ::FLOAT, fn GetLineJoin(&mut self) -> D2D1_LINE_JOIN, fn GetDashOffset(&mut self) -> ::FLOAT, fn GetDashStyle(&mut self) -> D2D1_DASH_STYLE, fn GetDashesCount(&mut self) -> ::UINT32, fn GetDashes(&mut self, dashes: *mut ::FLOAT, dashesCount: ::UINT32) -> () }); RIDL!( interface ID2D1Geometry(ID2D1GeometryVtbl): ID2D1Resource(ID2D1ResourceVtbl) { fn GetBounds( &mut self, worldTransform: *const D2D1_MATRIX_3X2_F, bounds: *mut ::D2D1_RECT_F ) -> ::HRESULT, fn GetWidenedBounds( &mut self, strokeWidth: ::FLOAT, strokeStyle: *mut ID2D1StrokeStyle, worldTransform: *const D2D1_MATRIX_3X2_F, flatteningTolerance: ::FLOAT, bounds: *mut ::D2D1_RECT_F ) -> ::HRESULT, fn StrokeContainsPoint( &mut self, point: ::D2D1_POINT_2F, strokeWidth: ::FLOAT, strokeStyle: *mut ID2D1StrokeStyle, worldTransform: *const D2D1_MATRIX_3X2_F, flatteningTolerance: ::FLOAT, contains: *mut ::BOOL ) -> ::HRESULT, fn FillContainsPoint( &mut self, point: ::D2D1_POINT_2F, worldTransform: *const D2D1_MATRIX_3X2_F, flatteningTolerance: ::FLOAT, contains: *mut ::BOOL ) -> ::HRESULT, fn CompareWithGeometry( &mut self, inputGeometry: *mut ID2D1Geometry, inputGeometryTransform: *const D2D1_MATRIX_3X2_F, flatteningTolerance: ::FLOAT, relation: *mut D2D1_GEOMETRY_RELATION ) -> ::HRESULT, fn Simplify( &mut self, simplificationOption: D2D1_GEOMETRY_SIMPLIFICATION_OPTION, worldTransform: *const D2D1_MATRIX_3X2_F, flatteningTolerance: ::FLOAT, geometrySink: *mut ID2D1SimplifiedGeometrySink ) -> ::HRESULT, fn Tessellate( &mut self, worldTransform: *const D2D1_MATRIX_3X2_F, flatteningTolerance: ::FLOAT, tessellationSink: *mut ID2D1TessellationSink ) -> ::HRESULT, fn CombineWithGeometry( &mut self, inputGeometry: *mut ID2D1Geometry, combineMode: D2D1_COMBINE_MODE, inputGeometryTransform: *const D2D1_MATRIX_3X2_F, flatteningTolerance: ::FLOAT, geometrySink: *mut ID2D1SimplifiedGeometrySink ) -> ::HRESULT, fn Outline( &mut self, worldTransform: *const D2D1_MATRIX_3X2_F, flatteningTolerance: ::FLOAT, geometrySink: *mut ID2D1SimplifiedGeometrySink ) -> ::HRESULT, fn ComputeArea( &mut self, worldTransform: *const D2D1_MATRIX_3X2_F, flatteningTolerance: ::FLOAT, area: *mut ::FLOAT ) -> ::HRESULT, fn ComputeLength( &mut self, worldTransform: *const D2D1_MATRIX_3X2_F, flatteningTolerance: ::FLOAT, length: *mut ::FLOAT ) -> ::HRESULT, fn ComputePointAtLength( &mut self, length: ::FLOAT, worldTransform: *const D2D1_MATRIX_3X2_F, flatteningTolerance: ::FLOAT, point: *mut ::D2D1_POINT_2F, unitTangentVector: *mut ::D2D1_POINT_2F ) -> ::HRESULT, fn Widen( &mut self, strokeWidth: ::FLOAT, strokeStyle: *mut ID2D1StrokeStyle, worldTransform: *const D2D1_MATRIX_3X2_F, flatteningTolerance: ::FLOAT, geometrySink: *mut ID2D1SimplifiedGeometrySink ) -> ::HRESULT }); RIDL!( interface ID2D1RectangleGeometry(ID2D1RectangleGeometryVtbl): ID2D1Geometry(ID2D1GeometryVtbl) { fn GetRect(&mut self, rect: *mut ::D2D1_RECT_F) -> () }); RIDL!( interface ID2D1RoundedRectangleGeometry(ID2D1RoundedRectangleGeometryVtbl) : ID2D1Geometry(ID2D1GeometryVtbl) { fn GetRoundedRect(&mut self, roundedRect: *mut D2D1_ROUNDED_RECT) -> () }); RIDL!( interface ID2D1EllipseGeometry(ID2D1EllipseGeometryVtbl): ID2D1Geometry(ID2D1GeometryVtbl) { fn GetEllipse(&mut self, ellipse: *mut D2D1_ELLIPSE) -> () }); RIDL!( interface ID2D1GeometryGroup(ID2D1GeometryGroupVtbl): ID2D1Geometry(ID2D1GeometryVtbl) { fn GetFillMode(&mut self) -> D2D1_FILL_MODE, fn GetSourceGeometryCount(&mut self) -> ::UINT32, fn GetSourceGeometries( &mut self, geometries: *mut *mut ID2D1Geometry, geometriesCount: ::UINT32 ) -> () }); RIDL!( interface ID2D1TransformedGeometry(ID2D1TransformedGeometryVtbl) : ID2D1Geometry(ID2D1GeometryVtbl) { fn GetSourceGeometry(&mut self, sourceGeometry: *mut *mut ID2D1Geometry) -> (), fn GetTransform(&mut self, transform: *mut D2D1_MATRIX_3X2_F) -> () }); RIDL!( interface ID2D1SimplifiedGeometrySink(ID2D1SimplifiedGeometrySinkVtbl): IUnknown(IUnknownVtbl) { fn SetFillMode(&mut self, fillMode: D2D1_FILL_MODE) -> (), fn SetSegmentFlags(&mut self, vertexFlags: D2D1_PATH_SEGMENT) -> (), fn BeginFigure(&mut self, startPoint: ::D2D1_POINT_2F, figureBegin: D2D1_FIGURE_BEGIN) -> (), fn AddLines(&mut self, points: *const ::D2D1_POINT_2F, pointsCount: ::UINT32) -> (), fn AddBeziers(&mut self, beziers: *const D2D1_BEZIER_SEGMENT, beziersCount: ::UINT32) -> (), fn EndFigure(&mut self, figureEnd: D2D1_FIGURE_END) -> (), fn Close(&mut self) -> ::HRESULT }); RIDL!( interface ID2D1GeometrySink(ID2D1GeometrySinkVtbl) : ID2D1SimplifiedGeometrySink(ID2D1SimplifiedGeometrySinkVtbl) { fn AddLine(&mut self, point: ::D2D1_POINT_2F) -> (), fn AddBezier(&mut self, bezier: *const D2D1_BEZIER_SEGMENT) -> (), fn AddQuadraticBezier(&mut self, bezier: *const D2D1_QUADRATIC_BEZIER_SEGMENT) -> (), fn AddQuadraticBeziers( &mut self, beziers: *const D2D1_QUADRATIC_BEZIER_SEGMENT, beziersCount: ::UINT32 ) -> (), fn AddArc(&mut self, arc: *const D2D1_ARC_SEGMENT) -> () }); RIDL!( interface ID2D1TessellationSink(ID2D1TessellationSinkVtbl): IUnknown(IUnknownVtbl) { fn AddTriangles(&mut self, triangles: *const D2D1_TRIANGLE, triangleCount: ::UINT32) -> (), fn Close(&mut self) -> ::HRESULT }); RIDL!( interface ID2D1PathGeometry(ID2D1PathGeometryVtbl): ID2D1Geometry(ID2D1GeometryVtbl) { fn Open(&mut self, geometrySink: *mut *mut ID2D1GeometrySink) -> ::HRESULT, fn Stream(&mut self, geometrySink: *mut ID2D1GeometrySink) -> ::HRESULT, fn GetSegmentCount(&mut self, count: *mut ::UINT32) -> ::HRESULT, fn GetFigureCount(&mut self, count: *mut ::UINT32) -> ::HRESULT }); RIDL!( interface ID2D1Mesh(ID2D1MeshVtbl): ID2D1Resource(ID2D1ResourceVtbl) { fn Open(&mut self, tessellationSink: *mut *mut ID2D1TessellationSink) -> ::HRESULT }); RIDL!( interface ID2D1Layer(ID2D1LayerVtbl): ID2D1Resource(ID2D1ResourceVtbl) { fn GetSize(&mut self, ret: *mut D2D1_SIZE_F) -> *mut D2D1_SIZE_F // FIXME: ABI issue }); RIDL!( interface ID2D1DrawingStateBlock(ID2D1DrawingStateBlockVtbl): ID2D1Resource(ID2D1ResourceVtbl) { fn GetDescription(&mut self, stateDescription: *mut D2D1_DRAWING_STATE_DESCRIPTION) -> (), fn SetDescription(&mut self, stateDescription: *const D2D1_DRAWING_STATE_DESCRIPTION) -> (), fn SetTextRenderingParams( &mut self, textRenderingParams: *mut ::IDWriteRenderingParams ) -> (), fn GetTextRenderingParams( &mut self, textRenderingParams: *mut *mut ::IDWriteRenderingParams ) -> () }); RIDL!( interface ID2D1RenderTarget(ID2D1RenderTargetVtbl): ID2D1Resource(ID2D1ResourceVtbl) { fn CreateBitmap( &mut self, size: D2D1_SIZE_U, srcData: *const ::c_void, pitch: ::UINT32, bitmapProperties: *const D2D1_BITMAP_PROPERTIES, bitmap: *mut *mut ID2D1Bitmap ) -> ::HRESULT, fn CreateBitmapFromWicBitmap( &mut self, wicBitmapSource: *mut ::IWICBitmapSource, bitmapProperties: *const D2D1_BITMAP_PROPERTIES, bitmap: *mut *mut ID2D1Bitmap ) -> ::HRESULT, fn CreateSharedBitmap( &mut self, riid: ::REFIID, data: *const ::c_void, bitmapProperties: *const D2D1_BITMAP_PROPERTIES, bitmap: *mut *mut ID2D1Bitmap ) -> ::HRESULT, fn CreateBitmapBrush( &mut self, bitmap: *mut ID2D1Bitmap, bitmapBrushProperties: *const D2D1_BITMAP_BRUSH_PROPERTIES, brushProperties: *const D2D1_BRUSH_PROPERTIES, bitmapBrush: *mut *mut ID2D1BitmapBrush ) -> ::HRESULT, fn CreateSolidColorBrush( &mut self, color: *const D2D1_COLOR_F, brushProperties: *const D2D1_BRUSH_PROPERTIES, solidColorBrush: *mut *mut ID2D1SolidColorBrush ) -> ::HRESULT, fn CreateGradientStopCollection( &mut self, gradientStops: *const D2D1_GRADIENT_STOP, gradientStopsCount: ::UINT32, colorInterpolationGamma: D2D1_GAMMA, extendMode: D2D1_EXTEND_MODE, gradientStopCollection: *mut *mut ID2D1GradientStopCollection ) -> ::HRESULT, fn CreateLinearGradientBrush( &mut self, linearGradientBrushProperties: *const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES, brushProperties: *const D2D1_BRUSH_PROPERTIES, gradientStopCollection: *mut ID2D1GradientStopCollection, linearGradientBrush: *mut *mut ID2D1LinearGradientBrush ) -> ::HRESULT, fn CreateRadialGradientBrush( &mut self, radialGradientBrushProperties: *const D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES, brushProperties: *const D2D1_BRUSH_PROPERTIES, gradientStopCollection: *mut ID2D1GradientStopCollection, radialGradientBrush: *mut *mut ID2D1RadialGradientBrush ) -> ::HRESULT, fn CreateCompatibleRenderTarget( &mut self, desiredSize: *const D2D1_SIZE_F, desiredPixelSize: *const D2D1_SIZE_U, desiredFormat: *const ::D2D1_PIXEL_FORMAT, options: D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS, bitmapRenderTarget: *mut *mut ID2D1BitmapRenderTarget ) -> ::HRESULT, fn CreateLayer(&mut self, size: *const D2D1_SIZE_F, layer: *mut *mut ID2D1Layer) -> ::HRESULT, fn CreateMesh(&mut self, mesh: *mut *mut ID2D1Mesh) -> ::HRESULT, fn DrawLine( &mut self, point0: ::D2D1_POINT_2F, point1: ::D2D1_POINT_2F, brush: *mut ID2D1Brush, strokeWidth: ::FLOAT, strokeStype: *mut ID2D1StrokeStyle ) -> (), fn DrawRectangle( &mut self, rect: *const ::D2D1_RECT_F, brush: *mut ID2D1Brush, strokeWidth: ::FLOAT, strokeStyle: *mut ID2D1StrokeStyle ) -> (), fn FillRectangle( &mut self, rect: *const ::D2D1_RECT_F, brush: *mut ID2D1Brush ) -> (), fn DrawRoundedRectangle( &mut self, roundedRect: *const D2D1_ROUNDED_RECT, brush: *mut ID2D1Brush, strokeWidth: ::FLOAT, strokeStyle: *mut ID2D1StrokeStyle ) -> (), fn FillRoundedRectangle( &mut self, roundedRect: *const D2D1_ROUNDED_RECT, brush: *mut ID2D1Brush ) -> (), fn DrawEllipse( &mut self, ellipse: *const D2D1_ELLIPSE, brush: *mut ID2D1Brush, strokeWidth: ::FLOAT, strokeStyle: *mut ID2D1StrokeStyle ) -> (), fn FillEllipse( &mut self, ellipse: *const D2D1_ELLIPSE, brush: *mut ID2D1Brush ) -> (), fn DrawGeometry( &mut self, geometry: *mut ID2D1Geometry, brush: *mut ID2D1Brush, strokeWidth: ::FLOAT, strokeStyle: *mut ID2D1StrokeStyle ) -> (), fn FillGeometry( &mut self, geometry: *mut ID2D1Geometry, brush: *mut ID2D1Brush, opacityBrush: *mut ID2D1Brush ) -> (), fn FillMesh( &mut self, mesh: *mut ID2D1Mesh, brush: *const ID2D1Brush ) -> (), fn FillOpacityMask( &mut self, opacityMask: *mut ID2D1Bitmap, brush: *mut ID2D1Brush, content: D2D1_OPACITY_MASK_CONTENT, destinationRectangle: *const ::D2D1_RECT_F, sourceRectangle: *const ::D2D1_RECT_F ) -> (), fn DrawBitmap( &mut self, bitmap: *mut ID2D1Bitmap, destinationRectangle: *const ::D2D1_RECT_F, opacity: ::FLOAT, interpolationMode: D2D1_BITMAP_INTERPOLATION_MODE, sourceRectangle: *const ::D2D1_RECT_F ) -> (), fn DrawText( &mut self, string: *const ::WCHAR, stringLength: ::UINT32, textFormat: *mut ::IDWriteTextFormat, layoutRect: *const ::D2D1_RECT_F, defaultForegroundBrush: *mut ID2D1Brush, options: D2D1_DRAW_TEXT_OPTIONS, measuringMode: ::DWRITE_MEASURING_MODE ) -> (), fn DrawTextLayout( &mut self, origin: ::D2D1_POINT_2F, textLayout: *mut ::IDWriteTextLayout, defaultForegroundBrush: *mut ID2D1Brush ) -> (), fn DrawGlyphRun( &mut self, baselineOrigin: ::D2D1_POINT_2F, glyphRun: *const ::DWRITE_GLYPH_RUN, foregroundBrush: *mut ID2D1Brush, measuringMode: ::DWRITE_MEASURING_MODE ) -> (), fn SetTransform(&mut self, transform: *const D2D1_MATRIX_3X2_F) -> (), fn GetTransform(&mut self, transform: *mut D2D1_MATRIX_3X2_F) -> (), fn SetAntialiasMode(&mut self, antialiasMode: D2D1_ANTIALIAS_MODE) -> (), fn GetAntialiasMode(&mut self) -> D2D1_ANTIALIAS_MODE, fn SetTextAntialiasMode(&mut self, textAntialiasMode: D2D1_TEXT_ANTIALIAS_MODE) -> (), fn GetTextAntialiasMode(&mut self) -> D2D1_TEXT_ANTIALIAS_MODE, fn SetTextRenderingParams( &mut self, textRenderingParams: *mut ::IDWriteRenderingParams ) -> (), fn GetTextRenderingParams( &mut self, textRenderingParams: *mut *mut ::IDWriteRenderingParams ) -> (), fn SetTags(&mut self, tag1: D2D1_TAG, tag2: D2D1_TAG) -> (), fn GetTags(&mut self, tag1: *mut D2D1_TAG, tag2: *mut D2D1_TAG) -> (), fn PushLayer( &mut self, layerParameters: *const D2D1_LAYER_PARAMETERS, layer: *mut ID2D1Layer ) -> (), fn PopLayer(&mut self) -> (), fn Flush(&mut self, tag1: *mut D2D1_TAG, tag2: *mut D2D1_TAG) -> (), fn SaveDrawingState(&mut self, drawingStateBlock: *mut ID2D1DrawingStateBlock) -> (), fn RestoreDrawingState(&mut self, drawingStateBlock: *mut ID2D1DrawingStateBlock) -> (), fn PushAxisAlignedClip( &mut self, clipRect: *const ::D2D1_RECT_F, antialiasMode: D2D1_ANTIALIAS_MODE ) -> (), fn PopAxisAlignedClip(&mut self) -> (), fn Clear(&mut self, clearColor: *const D2D1_COLOR_F) -> (), fn BeginDraw(&mut self) -> (), fn EndDraw(&mut self, tag1: *mut D2D1_TAG, tag2: *mut D2D1_TAG) -> ::HRESULT, fn GetPixelFormat( &mut self, ret: *mut ::D2D1_PIXEL_FORMAT ) -> *mut ::D2D1_PIXEL_FORMAT, // FIXME: ABI issue fn SetDpi(&mut self, dpiX: ::FLOAT, dpiY: ::FLOAT) -> (), fn GetDpi(&mut self, dpiX: *mut ::FLOAT, dpiY: *mut ::FLOAT) -> (), fn GetSize(&mut self, ret: *mut D2D1_SIZE_F) -> *mut D2D1_SIZE_F, // FIXME: ABI issue fn GetPixelSize(&mut self, ret: *mut D2D1_SIZE_U) -> *mut D2D1_SIZE_U, // FIXME: ABI issue fn GetMaximumBitmapSize(&mut self) -> ::UINT32, fn IsSupported( &mut self, renderTargetProperties: *const D2D1_RENDER_TARGET_PROPERTIES ) -> ::BOOL }); RIDL!( interface ID2D1BitmapRenderTarget(ID2D1BitmapRenderTargetVtbl) : ID2D1RenderTarget(ID2D1RenderTargetVtbl) { fn GetBitmap(&mut self, bitmap: *mut *mut ID2D1Bitmap) -> ::HRESULT }); RIDL!( interface ID2D1HwndRenderTarget(ID2D1HwndRenderTargetVtbl) : ID2D1RenderTarget(ID2D1RenderTargetVtbl) { fn CheckWindowState(&mut self) -> D2D1_WINDOW_STATE, fn Resize(&mut self, pixelSize: *const D2D1_SIZE_U) -> ::HRESULT, fn GetHwnd(&mut self) -> ::HWND }); RIDL!( interface ID2D1GdiInteropRenderTarget(ID2D1GdiInteropRenderTargetVtbl): IUnknown(IUnknownVtbl) { fn GetDC(&mut self, mode: D2D1_DC_INITIALIZE_MODE, hdc: *mut ::HDC) -> ::HRESULT, fn ReleaseDC(&mut self, update: *const ::RECT) -> ::HRESULT }); RIDL!( interface ID2D1DCRenderTarget(ID2D1DCRenderTargetVtbl): ID2D1RenderTarget(ID2D1RenderTargetVtbl) { fn BindDC(&mut self, hDC: ::HDC, pSubRect: *const ::RECT) -> ::HRESULT }); RIDL!( interface ID2D1Factory(ID2D1FactoryVtbl): IUnknown(IUnknownVtbl) { fn ReloadSystemMetrics(&mut self) -> ::HRESULT, fn GetDesktopDpi(&mut self, dpiX: *mut ::FLOAT, dpiY: *mut ::FLOAT) -> (), fn CreateRectangleGeometry( &mut self, rectangle: *const ::D2D1_RECT_F, rectangleGeometry: *mut *mut ID2D1RectangleGeometry ) -> ::HRESULT, fn CreateRoundedRectangleGeometry( &mut self, roundedRectangle: *const D2D1_ROUNDED_RECT, roundedRectangleGeometry: *mut *mut ID2D1RoundedRectangleGeometry ) -> ::HRESULT, fn CreateEllipseGeometry( &mut self, ellipse: *const D2D1_ELLIPSE, ellipseGeometry: *mut *mut ID2D1EllipseGeometry ) -> ::HRESULT, fn CreateGeometryGroup( &mut self, fillMode: D2D1_FILL_MODE, geometries: *mut *mut ID2D1Geometry, geometriesCount: ::UINT32, geometryGroup: *mut *mut ID2D1GeometryGroup ) -> ::HRESULT, fn CreateTransformedGeometry( &mut self, sourceGeometry: *mut ID2D1Geometry, transform: *const D2D1_MATRIX_3X2_F, transformedGeometry: *mut *mut ID2D1TransformedGeometry ) -> ::HRESULT, fn CreatePathGeometry( &mut self, pathGeometry: *mut *mut ID2D1PathGeometry ) -> ::HRESULT, fn CreateStrokeStyle( &mut self, strokeStyleProperties: *const D2D1_STROKE_STYLE_PROPERTIES, dashes: *const ::FLOAT, dashesCount: ::UINT32, strokeStyle: *mut *mut ID2D1StrokeStyle ) -> ::HRESULT, fn CreateDrawingStateBlock( &mut self, drawingStateDescription: *const D2D1_DRAWING_STATE_DESCRIPTION, textRenderingParams: *mut ::IDWriteRenderingParams, drawingStateBlock: *mut *mut ID2D1DrawingStateBlock ) -> ::HRESULT, fn CreateWicBitmapRenderTarget( &mut self, target: *mut ::IWICBitmap, renderTargetProperties: *const D2D1_RENDER_TARGET_PROPERTIES, renderTarget: *mut *mut ID2D1RenderTarget ) -> ::HRESULT, fn CreateHwndRenderTarget( &mut self, renderTargetProperties: *const D2D1_RENDER_TARGET_PROPERTIES, hwndRenderTargetProperties: *const D2D1_HWND_RENDER_TARGET_PROPERTIES, hwndRenderTarget: *mut *mut ID2D1HwndRenderTarget ) -> ::HRESULT, fn CreateDxgiSurfaceRenderTarget( &mut self, dxgiSurface: *mut ::IDXGISurface, renderTargetProperties: *const D2D1_RENDER_TARGET_PROPERTIES, renderTarget: *mut *mut ID2D1RenderTarget ) -> ::HRESULT, fn CreateDCRenderTarget( &mut self, renderTargetProperties: *const D2D1_RENDER_TARGET_PROPERTIES, dcRenderTarget: *mut *mut ID2D1DCRenderTarget ) -> ::HRESULT }); DEFINE_GUID!( UuidOfID2D1Factory, 0x06152247, 0x6f50, 0x465a, 0x92, 0x45, 0x11, 0x8b, 0xfd, 0x3b, 0x60, 0x07 ); deps/winapi-0.2.5/src/audiosessiontypes.rs0000644000000000000000000000076712612156461017403 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License ENUM!{enum AUDCLNT_SHAREMODE { AUDCLNT_SHAREMODE_SHARED, AUDCLNT_SHAREMODE_EXCLUSIVE, }} pub const AUDCLNT_STREAMFLAGS_CROSSPROCESS: ::DWORD = 0x00010000; pub const AUDCLNT_STREAMFLAGS_LOOPBACK: ::DWORD = 0x00020000; pub const AUDCLNT_STREAMFLAGS_EVENTCALLBACK: ::DWORD = 0x00040000; pub const AUDCLNT_STREAMFLAGS_NOPERSIST: ::DWORD = 0x00080000; pub const AUDCLNT_STREAMFLAGS_RATEADJUST: ::DWORD = 0x00100000; deps/winapi-0.2.5/src/wtypes.rs0000644000000000000000000000325012615662007015133 0ustar rootroot// Copyright © 2015, Connor Hilarides // Licensed under the MIT License //! Mappings for the contents of wstypes.h ENUM!{enum VARENUM { VT_EMPTY = 0, VT_NULL = 1, VT_I2 = 2, VT_I4 = 3, VT_R4 = 4, VT_R8 = 5, VT_CY = 6, VT_DATE = 7, VT_BSTR = 8, VT_DISPATCH = 9, VT_ERROR = 10, VT_BOOL = 11, VT_VARIANT = 12, VT_UNKNOWN = 13, VT_DECIMAL = 14, VT_I1 = 16, VT_UI1 = 17, VT_UI2 = 18, VT_UI4 = 19, VT_I8 = 20, VT_UI8 = 21, VT_INT = 22, VT_UINT = 23, VT_VOID = 24, VT_HRESULT = 25, VT_PTR = 26, VT_SAFEARRAY = 27, VT_CARRAY = 28, VT_USERDEFINED = 29, VT_LPSTR = 30, VT_LPWSTR = 31, VT_RECORD = 36, VT_INT_PTR = 37, VT_UINT_PTR = 38, VT_FILETIME = 64, VT_BLOB = 65, VT_STREAM = 66, VT_STORAGE = 67, VT_STREAMED_OBJECT = 68, VT_STORED_OBJECT = 69, VT_BLOB_OBJECT = 70, VT_CF = 71, VT_CLSID = 72, VT_VERSIONED_STREAM = 73, VT_BSTR_BLOB = 0xfff, VT_VECTOR = 0x1000, VT_ARRAY = 0x2000, VT_BYREF = 0x4000, VT_RESERVED = 0x8000, VT_ILLEGAL = 0xffff, }} pub const VT_ILLEGALMASKED: VARENUM = VT_BSTR_BLOB; pub const VT_TYPEMASK: VARENUM = VT_BSTR_BLOB; pub type DATE = ::c_double; STRUCT!{struct CY { int64: ::LONGLONG, }} STRUCT!{struct DECIMAL { wReserved: ::USHORT, scale: ::BYTE, sign: ::BYTE, Hi32: ::ULONG, Lo64: ::ULONGLONG, }} pub const DECIMAL_NEG: ::BYTE = 0x80; pub type LPDECIMAL = *mut DECIMAL; pub type VARTYPE = ::c_ushort; pub type wireBSTR = *mut ::FLAGGED_WORD_BLOB; pub type BSTR = *mut ::OLECHAR; pub type LPBSTR = *mut BSTR; pub type VARIANT_BOOL = ::c_short; deps/winapi-0.2.5/src/errhandlingapi.rs0000644000000000000000000000052112605021253016554 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! ApiSet Contract for api-ms-win-core-errorhandling-l1 pub type PTOP_LEVEL_EXCEPTION_FILTER = Option ::LONG>; pub type LPTOP_LEVEL_EXCEPTION_FILTER = PTOP_LEVEL_EXCEPTION_FILTER; deps/winapi-0.2.5/src/ws2spi.rs0000644000000000000000000000511512615662007015031 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Definitions to be used with the WinSock service provider pub const WSPDESCRIPTION_LEN: usize = 255; #[repr(C)] #[derive(Copy)] pub struct WSPDATA { pub wVersion: ::WORD, pub wHighVersion: ::WORD, pub szDescription: [::WCHAR; WSPDESCRIPTION_LEN + 1], } impl Clone for WSPDATA { fn clone(&self) -> WSPDATA { *self } } pub type LPWSPDATA = *mut WSPDATA; STRUCT!{struct WSATHREADID { ThreadHandle: ::HANDLE, Reserved: ::DWORD_PTR, }} pub type LPWSATHREADID = *mut WSATHREADID; pub type LPNSPV2STARTUP = Option ::INT>; pub type LPNSPV2CLEANUP = Option ::INT>; pub type LPNSPV2LOOKUPSERVICEBEGIN = Option ::INT>; pub type LPNSPV2LOOKUPSERVICENEXTEX = Option; pub type LPNSPV2LOOKUPSERVICEEND = Option ::INT>; pub type LPNSPV2SETSERVICEEX = Option; pub type LPNSPV2CLIENTSESSIONRUNDOWN = Option; #[repr(C)] #[derive(Copy)] pub struct NSPV2_ROUTINE { pub cbSize: ::DWORD, pub dwMajorVersion: ::DWORD, pub dwMinorVersion: ::DWORD, pub NSPv2Startup: LPNSPV2STARTUP, pub NSPv2Cleanup: LPNSPV2CLEANUP, pub NSPv2LookupServiceBegin: LPNSPV2LOOKUPSERVICEBEGIN, pub NSPv2LookupServiceNextEx: LPNSPV2LOOKUPSERVICENEXTEX, pub NSPv2LookupServiceEnd: LPNSPV2LOOKUPSERVICEEND, pub NSPv2SetServiceEx: LPNSPV2SETSERVICEEX, pub NSPv2ClientSessionRundown: LPNSPV2CLIENTSESSIONRUNDOWN, } impl Clone for NSPV2_ROUTINE { fn clone(&self) -> NSPV2_ROUTINE { *self } } pub type PNSPV2_ROUTINE = *mut NSPV2_ROUTINE; pub type LPNSPV2_ROUTINE = *mut NSPV2_ROUTINE; pub type PCNSPV2_ROUTINE = *const NSPV2_ROUTINE; pub type LPCNSPV2_ROUTINE = *const NSPV2_ROUTINE; ENUM!{enum WSC_PROVIDER_INFO_TYPE { ProviderInfoLspCategories, ProviderInfoAudit, }} deps/winapi-0.2.5/src/dcommon.rs0000644000000000000000000000105112615662007015231 0ustar rootroot// Copyright © 2015; Connor Hilarides // Licensed under the MIT License //! Mappings for the contents of dcommon.h ENUM!{enum DWRITE_MEASURING_MODE { DWRITE_MEASURING_MODE_NATURAL = 0, DWRITE_MEASURING_MODE_GDI_CLASSIC = 1, DWRITE_MEASURING_MODE_GDI_NATURAL = 2, }} ENUM!{enum D2D1_ALPHA_MODE { D2D1_ALPHA_MODE_UNKNOWN = 0, D2D1_ALPHA_MODE_PREMULTIPLIED = 1, D2D1_ALPHA_MODE_STRAIGHT = 2, D2D1_ALPHA_MODE_IGNORE = 3, }} STRUCT!{struct D2D1_PIXEL_FORMAT { format: ::DWORD, alphaMode: D2D1_ALPHA_MODE, }} deps/winapi-0.2.5/src/reason.rs0000644000000000000000000000717412605021352015067 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License // Flags used by the various UIs pub const SHTDN_REASON_FLAG_COMMENT_REQUIRED: ::DWORD = 0x01000000; pub const SHTDN_REASON_FLAG_DIRTY_PROBLEM_ID_REQUIRED: ::DWORD = 0x02000000; pub const SHTDN_REASON_FLAG_CLEAN_UI: ::DWORD = 0x04000000; pub const SHTDN_REASON_FLAG_DIRTY_UI: ::DWORD = 0x08000000; // Flags that end up in the event log code. pub const SHTDN_REASON_FLAG_USER_DEFINED: ::DWORD = 0x40000000; pub const SHTDN_REASON_FLAG_PLANNED: ::DWORD = 0x80000000; // Microsoft major reasons. pub const SHTDN_REASON_MAJOR_OTHER: ::DWORD = 0x00000000; pub const SHTDN_REASON_MAJOR_NONE: ::DWORD = 0x00000000; pub const SHTDN_REASON_MAJOR_HARDWARE: ::DWORD = 0x00010000; pub const SHTDN_REASON_MAJOR_OPERATINGSYSTEM: ::DWORD = 0x00020000; pub const SHTDN_REASON_MAJOR_SOFTWARE: ::DWORD = 0x00030000; pub const SHTDN_REASON_MAJOR_APPLICATION: ::DWORD = 0x00040000; pub const SHTDN_REASON_MAJOR_SYSTEM: ::DWORD = 0x00050000; pub const SHTDN_REASON_MAJOR_POWER: ::DWORD = 0x00060000; pub const SHTDN_REASON_MAJOR_LEGACY_API: ::DWORD = 0x00070000; // Microsoft minor reasons. pub const SHTDN_REASON_MINOR_OTHER: ::DWORD = 0x00000000; pub const SHTDN_REASON_MINOR_NONE: ::DWORD = 0x000000ff; pub const SHTDN_REASON_MINOR_MAINTENANCE: ::DWORD = 0x00000001; pub const SHTDN_REASON_MINOR_INSTALLATION: ::DWORD = 0x00000002; pub const SHTDN_REASON_MINOR_UPGRADE: ::DWORD = 0x00000003; pub const SHTDN_REASON_MINOR_RECONFIG: ::DWORD = 0x00000004; pub const SHTDN_REASON_MINOR_HUNG: ::DWORD = 0x00000005; pub const SHTDN_REASON_MINOR_UNSTABLE: ::DWORD = 0x00000006; pub const SHTDN_REASON_MINOR_DISK: ::DWORD = 0x00000007; pub const SHTDN_REASON_MINOR_PROCESSOR: ::DWORD = 0x00000008; pub const SHTDN_REASON_MINOR_NETWORKCARD: ::DWORD = 0x00000009; pub const SHTDN_REASON_MINOR_POWER_SUPPLY: ::DWORD = 0x0000000a; pub const SHTDN_REASON_MINOR_CORDUNPLUGGED: ::DWORD = 0x0000000b; pub const SHTDN_REASON_MINOR_ENVIRONMENT: ::DWORD = 0x0000000c; pub const SHTDN_REASON_MINOR_HARDWARE_DRIVER: ::DWORD = 0x0000000d; pub const SHTDN_REASON_MINOR_OTHERDRIVER: ::DWORD = 0x0000000e; pub const SHTDN_REASON_MINOR_BLUESCREEN: ::DWORD = 0x0000000F; pub const SHTDN_REASON_MINOR_SERVICEPACK: ::DWORD = 0x00000010; pub const SHTDN_REASON_MINOR_HOTFIX: ::DWORD = 0x00000011; pub const SHTDN_REASON_MINOR_SECURITYFIX: ::DWORD = 0x00000012; pub const SHTDN_REASON_MINOR_SECURITY: ::DWORD = 0x00000013; pub const SHTDN_REASON_MINOR_NETWORK_CONNECTIVITY: ::DWORD = 0x00000014; pub const SHTDN_REASON_MINOR_WMI: ::DWORD = 0x00000015; pub const SHTDN_REASON_MINOR_SERVICEPACK_UNINSTALL: ::DWORD = 0x00000016; pub const SHTDN_REASON_MINOR_HOTFIX_UNINSTALL: ::DWORD = 0x00000017; pub const SHTDN_REASON_MINOR_SECURITYFIX_UNINSTALL: ::DWORD = 0x00000018; pub const SHTDN_REASON_MINOR_MMC: ::DWORD = 0x00000019; pub const SHTDN_REASON_MINOR_SYSTEMRESTORE: ::DWORD = 0x0000001a; pub const SHTDN_REASON_MINOR_TERMSRV: ::DWORD = 0x00000020; pub const SHTDN_REASON_MINOR_DC_PROMOTION: ::DWORD = 0x00000021; pub const SHTDN_REASON_MINOR_DC_DEMOTION: ::DWORD = 0x00000022; pub const SHTDN_REASON_UNKNOWN: ::DWORD = SHTDN_REASON_MINOR_NONE; pub const SHTDN_REASON_LEGACY_API: ::DWORD = (SHTDN_REASON_MAJOR_LEGACY_API | SHTDN_REASON_FLAG_PLANNED); // This mask cuts out UI flags. pub const SHTDN_REASON_VALID_BIT_MASK: ::DWORD = 0xc0ffffff; // Convenience flags. pub const PCLEANUI: ::DWORD = (SHTDN_REASON_FLAG_PLANNED | SHTDN_REASON_FLAG_CLEAN_UI); pub const UCLEANUI: ::DWORD = (SHTDN_REASON_FLAG_CLEAN_UI); pub const PDIRTYUI: ::DWORD = (SHTDN_REASON_FLAG_PLANNED | SHTDN_REASON_FLAG_DIRTY_UI); pub const UDIRTYUI: ::DWORD = (SHTDN_REASON_FLAG_DIRTY_UI); //89 deps/winapi-0.2.5/src/sysinfoapi.rs0000644000000000000000000000305512615662007015767 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! ApiSet Contract for api-ms-win-core-sysinfo-l1. STRUCT!{struct SYSTEM_INFO { wProcessorArchitecture: ::WORD, wReserved: ::WORD, dwPageSize: ::DWORD, lpMinimumApplicationAddress: ::LPVOID, lpMaximumApplicationAddress: ::LPVOID, dwActiveProcessorMask: ::DWORD_PTR, dwNumberOfProcessors: ::DWORD, dwProcessorType: ::DWORD, dwAllocationGranularity: ::DWORD, wProcessorLevel: ::WORD, wProcessorRevision: ::WORD, }} UNION!(SYSTEM_INFO, wProcessorArchitecture, dwOemId, dwOemId_mut, ::DWORD); pub type LPSYSTEM_INFO = *mut SYSTEM_INFO; STRUCT!{struct MEMORYSTATUSEX { dwLength: ::DWORD, dwMemoryLoad: ::DWORD, ullTotalPhys: ::DWORDLONG, ullAvailPhys: ::DWORDLONG, ullTotalPageFile: ::DWORDLONG, ullAvailPageFile: ::DWORDLONG, ullTotalVirtual: ::DWORDLONG, ullAvailVirtual: ::DWORDLONG, ullAvailExtendedVirtual: ::DWORDLONG, }} pub type LPMEMORYSTATUSEX = *mut MEMORYSTATUSEX; ENUM!{enum COMPUTER_NAME_FORMAT { ComputerNameNetBIOS, ComputerNameDnsHostname, ComputerNameDnsDomain, ComputerNameDnsFullyQualified, ComputerNamePhysicalNetBIOS, ComputerNamePhysicalDnsHostname, ComputerNamePhysicalDnsDomain, ComputerNamePhysicalDnsFullyQualified, ComputerNameMax, }} pub type INIT_ONCE = ::RTL_RUN_ONCE; pub type PINIT_ONCE = ::PRTL_RUN_ONCE; pub type LPINIT_ONCE = ::PRTL_RUN_ONCE; pub type CONDITION_VARIABLE = ::RTL_CONDITION_VARIABLE; pub type PCONDITION_VARIABLE = *mut CONDITION_VARIABLE; deps/winapi-0.2.5/src/minwinbase.rs0000644000000000000000000002205212615662007015735 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! This module defines the 32-Bit Windows Base APIs STRUCT!{struct SECURITY_ATTRIBUTES { nLength: ::DWORD, lpSecurityDescriptor: ::LPVOID, bInheritHandle: ::BOOL, }} pub type PSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; STRUCT!{struct OVERLAPPED { Internal: ::ULONG_PTR, InternalHigh: ::ULONG_PTR, Offset: ::DWORD, OffsetHigh: ::DWORD, hEvent: ::HANDLE, }} UNION!(OVERLAPPED, Offset, Pointer, Pointer_mut, ::PVOID); pub type LPOVERLAPPED = *mut OVERLAPPED; STRUCT!{struct OVERLAPPED_ENTRY { lpCompletionKey: ::ULONG_PTR, lpOverlapped: LPOVERLAPPED, Internal: ::ULONG_PTR, dwNumberOfBytesTransferred: ::DWORD, }} pub type LPOVERLAPPED_ENTRY = *mut OVERLAPPED_ENTRY; STRUCT!{struct SYSTEMTIME { wYear: ::WORD, wMonth: ::WORD, wDayOfWeek: ::WORD, wDay: ::WORD, wHour: ::WORD, wMinute: ::WORD, wSecond: ::WORD, wMilliseconds: ::WORD, }} pub type PSYSTEMTIME = *mut SYSTEMTIME; pub type LPSYSTEMTIME = *mut SYSTEMTIME; #[repr(C)] #[derive(Copy)] pub struct WIN32_FIND_DATAA { pub dwFileAttributes: ::DWORD, pub ftCreationTime: ::FILETIME, pub ftLastAccessTime: ::FILETIME, pub ftLastWriteTime: ::FILETIME, pub nFileSizeHigh: ::DWORD, pub nFileSizeLow: ::DWORD, pub dwReserved0: ::DWORD, pub dwReserved1: ::DWORD, pub cFileName: [::CHAR; ::MAX_PATH], pub cAlternateFileName: [::CHAR; 14], } impl Clone for WIN32_FIND_DATAA { fn clone(&self) -> WIN32_FIND_DATAA { *self } } pub type PWIN32_FIND_DATAA = *mut WIN32_FIND_DATAA; pub type LPWIN32_FIND_DATAA = *mut WIN32_FIND_DATAA; #[repr(C)] #[derive(Copy)] pub struct WIN32_FIND_DATAW { pub dwFileAttributes: ::DWORD, pub ftCreationTime: ::FILETIME, pub ftLastAccessTime: ::FILETIME, pub ftLastWriteTime: ::FILETIME, pub nFileSizeHigh: ::DWORD, pub nFileSizeLow: ::DWORD, pub dwReserved0: ::DWORD, pub dwReserved1: ::DWORD, pub cFileName: [::WCHAR; ::MAX_PATH], pub cAlternateFileName: [::WCHAR; 14], } impl Clone for WIN32_FIND_DATAW { fn clone(&self) -> WIN32_FIND_DATAW { *self } } pub type PWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; ENUM!{enum FINDEX_INFO_LEVELS { FindExInfoStandard, FindExInfoBasic, FindExInfoMaxInfoLevel, }} pub const FIND_FIRST_EX_CASE_SENSITIVE: ::DWORD = 0x00000001; pub const FIND_FIRST_EX_LARGE_FETCH: ::DWORD = 0x00000002; ENUM!{enum FINDEX_SEARCH_OPS { FindExSearchNameMatch, FindExSearchLimitToDirectories, FindExSearchLimitToDevices, FindExSearchMaxSearchOp, }} ENUM!{enum GET_FILEEX_INFO_LEVELS { GetFileExInfoStandard, GetFileExMaxInfoLevel, }} ENUM!{enum FILE_INFO_BY_HANDLE_CLASS { FileBasicInfo, FileStandardInfo, FileNameInfo, FileRenameInfo, FileDispositionInfo, FileAllocationInfo, FileEndOfFileInfo, FileStreamInfo, FileCompressionInfo, FileAttributeTagInfo, FileIdBothDirectoryInfo, FileIdBothDirectoryRestartInfo, FileIoPriorityHintInfo, FileRemoteProtocolInfo, FileFullDirectoryInfo, FileFullDirectoryRestartInfo, FileStorageInfo, FileAlignmentInfo, FileIdInfo, FileIdExtdDirectoryInfo, FileIdExtdDirectoryRestartInfo, MaximumFileInfoByHandleClass, }} pub type PFILE_INFO_BY_HANDLE_CLASS = *mut FILE_INFO_BY_HANDLE_CLASS; pub type CRITICAL_SECTION = ::RTL_CRITICAL_SECTION; pub type PCRITICAL_SECTION = ::PRTL_CRITICAL_SECTION; pub type LPCRITICAL_SECTION = ::PRTL_CRITICAL_SECTION; pub type CRITICAL_SECTION_DEBUG = ::RTL_CRITICAL_SECTION_DEBUG; pub type PCRITICAL_SECTION_DEBUG = ::PRTL_CRITICAL_SECTION_DEBUG; pub type LPCRITICAL_SECTION_DEBUG = ::PRTL_CRITICAL_SECTION_DEBUG; pub type LPOVERLAPPED_COMPLETION_ROUTINE = Option; pub const LOCKFILE_FAIL_IMMEDIATELY: ::DWORD = 0x00000001; pub const LOCKFILE_EXCLUSIVE_LOCK: ::DWORD = 0x00000002; STRUCT!{struct PROCESS_HEAP_ENTRY_Block { hMem: ::HANDLE, dwReserved: [::DWORD; 3], }} STRUCT!{struct PROCESS_HEAP_ENTRY_Region { dwCommittedSize: ::DWORD, dwUnCommittedSize: ::DWORD, lpFirstBlock: ::LPVOID, lpLastBlock: ::LPVOID, }} STRUCT!{struct PROCESS_HEAP_ENTRY { lpData: ::PVOID, cbData: ::DWORD, cbOverhead: ::BYTE, iRegionIndex: ::BYTE, wFlags: ::WORD, Region: PROCESS_HEAP_ENTRY_Region, }} UNION!(PROCESS_HEAP_ENTRY, Region, Block, Block_mut, PROCESS_HEAP_ENTRY_Block); pub type LPPROCESS_HEAP_ENTRY = *mut PROCESS_HEAP_ENTRY; pub type PPROCESS_HEAP_ENTRY = *mut PROCESS_HEAP_ENTRY; pub const PROCESS_HEAP_REGION: ::WORD = 0x0001; pub const PROCESS_HEAP_UNCOMMITTED_RANGE: ::WORD = 0x0002; pub const PROCESS_HEAP_ENTRY_BUSY: ::WORD = 0x0004; pub const PROCESS_HEAP_SEG_ALLOC: ::WORD = 0x0008; pub const PROCESS_HEAP_ENTRY_MOVEABLE: ::WORD = 0x0010; pub const PROCESS_HEAP_ENTRY_DDESHARE: ::WORD = 0x0020; pub type PTHREAD_START_ROUTINE = Option ::DWORD>; pub type LPTHREAD_START_ROUTINE = PTHREAD_START_ROUTINE; pub type LPCONTEXT = ::PCONTEXT; STRUCT!{struct REASON_CONTEXT_Detailed { LocalizedReasonModule: ::HMODULE, LocalizedReasonId: ::ULONG, ReasonStringCount: ::ULONG, ReasonStrings: *mut ::LPWSTR, }} STRUCT!{struct REASON_CONTEXT { Version: ::ULONG, Flags: ::DWORD, Reason: REASON_CONTEXT_Detailed, }} UNION!(REASON_CONTEXT, Reason, SimpleReasonString, SimpleReasonString_mut, ::LPWSTR); pub type PREASON_CONTEXT = *mut REASON_CONTEXT; pub const EXCEPTION_DEBUG_EVENT: ::DWORD = 1; pub const CREATE_THREAD_DEBUG_EVENT: ::DWORD = 2; pub const CREATE_PROCESS_DEBUG_EVENT: ::DWORD = 3; pub const EXIT_THREAD_DEBUG_EVENT: ::DWORD = 4; pub const EXIT_PROCESS_DEBUG_EVENT: ::DWORD = 5; pub const LOAD_DLL_DEBUG_EVENT: ::DWORD = 6; pub const UNLOAD_DLL_DEBUG_EVENT: ::DWORD = 7; pub const OUTPUT_DEBUG_STRING_EVENT: ::DWORD = 8; pub const RIP_EVENT: ::DWORD = 9; STRUCT!{struct EXCEPTION_DEBUG_INFO { ExceptionRecord: ::EXCEPTION_RECORD, dwFirstChance: ::DWORD, }} pub type LPEXCEPTION_DEBUG_INFO = *mut EXCEPTION_DEBUG_INFO; #[repr(C)] #[derive(Copy)] pub struct CREATE_THREAD_DEBUG_INFO { pub hThread: ::HANDLE, pub lpThreadLocalBase: ::LPVOID, pub lpStartAddress: LPTHREAD_START_ROUTINE, } impl Clone for CREATE_THREAD_DEBUG_INFO { fn clone(&self) -> CREATE_THREAD_DEBUG_INFO { *self } } pub type LPCREATE_THREAD_DEBUG_INFO = *mut CREATE_THREAD_DEBUG_INFO; #[repr(C)] #[derive(Copy)] pub struct CREATE_PROCESS_DEBUG_INFO { pub hFile: ::HANDLE, pub hProcess: ::HANDLE, pub hThread: ::HANDLE, pub lpBaseOfImage: ::LPVOID, pub dwDebugInfoFileOffset: ::DWORD, pub nDebugInfoSize: ::DWORD, pub lpThreadLocalBase: ::LPVOID, pub lpStartAddress: LPTHREAD_START_ROUTINE, pub lpImageName: ::LPVOID, pub fUnicode: ::WORD, } impl Clone for CREATE_PROCESS_DEBUG_INFO { fn clone(&self) -> CREATE_PROCESS_DEBUG_INFO { *self } } pub type LPCREATE_PROCESS_DEBUG_INFO = *mut CREATE_PROCESS_DEBUG_INFO; STRUCT!{struct EXIT_THREAD_DEBUG_INFO { dwExitCode: ::DWORD, }} pub type LPEXIT_THREAD_DEBUG_INFO = *mut EXIT_THREAD_DEBUG_INFO; STRUCT!{struct EXIT_PROCESS_DEBUG_INFO { dwExitCode: ::DWORD, }} pub type LPEXIT_PROCESS_DEBUG_INFO = *mut EXIT_PROCESS_DEBUG_INFO; STRUCT!{struct LOAD_DLL_DEBUG_INFO { hFile: ::HANDLE, lpBaseOfDll: ::LPVOID, dwDebugInfoFileOffset: ::DWORD, nDebugInfoSize: ::DWORD, lpImageName: ::LPVOID, fUnicode: ::WORD, }} pub type LPLOAD_DLL_DEBUG_INFO = *mut LOAD_DLL_DEBUG_INFO; STRUCT!{struct UNLOAD_DLL_DEBUG_INFO { lpBaseOfDll: ::LPVOID, }} pub type LPUNLOAD_DLL_DEBUG_INFO = *mut UNLOAD_DLL_DEBUG_INFO; STRUCT!{struct OUTPUT_DEBUG_STRING_INFO { lpDebugStringData: ::LPSTR, fUnicode: ::WORD, nDebugStringLength: ::WORD, }} pub type LPOUTPUT_DEBUG_STRING_INFO = *mut OUTPUT_DEBUG_STRING_INFO; STRUCT!{struct RIP_INFO { dwError: ::DWORD, dwType: ::DWORD, }} pub type LPRIP_INFO = *mut RIP_INFO; #[repr(C)] #[derive(Copy)] pub struct DEBUG_EVENT { pub dwDebugEventCode: ::DWORD, pub dwProcessId: ::DWORD, pub dwThreadId: ::DWORD, #[cfg(target_arch="x86")] pub u: [u8; 84], #[cfg(target_arch="x86_64")] pub u: [u8; 160], } impl Clone for DEBUG_EVENT { fn clone(&self) -> DEBUG_EVENT { *self } } UNION!(DEBUG_EVENT, u, Exception, Exception_mut, EXCEPTION_DEBUG_INFO); UNION!(DEBUG_EVENT, u, CreateThread, CreateThread_mut, CREATE_THREAD_DEBUG_INFO); UNION!(DEBUG_EVENT, u, CreateProcessInfo, CreateProcessInfo_mut, CREATE_PROCESS_DEBUG_INFO); UNION!(DEBUG_EVENT, u, ExitThread, ExitThread_mut, EXIT_THREAD_DEBUG_INFO); UNION!(DEBUG_EVENT, u, ExitProcess, ExitProcess_mut, EXIT_PROCESS_DEBUG_INFO); UNION!(DEBUG_EVENT, u, LoadDll, LoadDll_mut, LOAD_DLL_DEBUG_INFO); UNION!(DEBUG_EVENT, u, UnloadDll, UnloadDll_mut, UNLOAD_DLL_DEBUG_INFO); UNION!(DEBUG_EVENT, u, DebugString, DebugString_mut, OUTPUT_DEBUG_STRING_INFO); UNION!(DEBUG_EVENT, u, RipInfo, RipInfo_mut, RIP_INFO); pub type LPDEBUG_EVENT = *mut DEBUG_EVENT; deps/winapi-0.2.5/src/lmerrlog.rs0000644000000000000000000004034712613167613015434 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License STRUCT!{struct ERROR_LOG { el_len: ::DWORD, el_reserved: ::DWORD, el_time: ::DWORD, el_error: ::DWORD, el_name: ::LPWSTR, el_text: ::LPWSTR, el_data: ::LPBYTE, el_data_size: ::DWORD, el_nstrings: ::DWORD, }} pub type PERROR_LOG = *mut ERROR_LOG; pub type LPERROR_LOG = *mut ERROR_LOG; STRUCT!{struct HLOG { time: ::DWORD, last_flags: ::DWORD, offset: ::DWORD, rec_offset: ::DWORD, }} pub type PHLOG = *mut HLOG; pub type LPHLOG = *mut HLOG; pub const LOGFLAGS_FORWARD: ::DWORD = 0; pub const LOGFLAGS_BACKWARD: ::DWORD = 0x1; pub const LOGFLAGS_SEEK: ::DWORD = 0x2; pub const ERRLOG_BASE: ::DWORD = 3100; pub const NELOG_Internal_Error: ::DWORD = ERRLOG_BASE + 0; pub const NELOG_Resource_Shortage: ::DWORD = ERRLOG_BASE + 1; pub const NELOG_Unable_To_Lock_Segment: ::DWORD = ERRLOG_BASE + 2; pub const NELOG_Unable_To_Unlock_Segment: ::DWORD = ERRLOG_BASE + 3; pub const NELOG_Uninstall_Service: ::DWORD = ERRLOG_BASE + 4; pub const NELOG_Init_Exec_Fail: ::DWORD = ERRLOG_BASE + 5; pub const NELOG_Ncb_Error: ::DWORD = ERRLOG_BASE + 6; pub const NELOG_Net_Not_Started: ::DWORD = ERRLOG_BASE + 7; pub const NELOG_Ioctl_Error: ::DWORD = ERRLOG_BASE + 8; pub const NELOG_System_Semaphore: ::DWORD = ERRLOG_BASE + 9; pub const NELOG_Init_OpenCreate_Err: ::DWORD = ERRLOG_BASE + 10; pub const NELOG_NetBios: ::DWORD = ERRLOG_BASE + 11; pub const NELOG_SMB_Illegal: ::DWORD = ERRLOG_BASE + 12; pub const NELOG_Service_Fail: ::DWORD = ERRLOG_BASE + 13; pub const NELOG_Entries_Lost: ::DWORD = ERRLOG_BASE + 14; pub const NELOG_Init_Seg_Overflow: ::DWORD = ERRLOG_BASE + 20; pub const NELOG_Srv_No_Mem_Grow: ::DWORD = ERRLOG_BASE + 21; pub const NELOG_Access_File_Bad: ::DWORD = ERRLOG_BASE + 22; pub const NELOG_Srvnet_Not_Started: ::DWORD = ERRLOG_BASE + 23; pub const NELOG_Init_Chardev_Err: ::DWORD = ERRLOG_BASE + 24; pub const NELOG_Remote_API: ::DWORD = ERRLOG_BASE + 25; pub const NELOG_Ncb_TooManyErr: ::DWORD = ERRLOG_BASE + 26; pub const NELOG_Mailslot_err: ::DWORD = ERRLOG_BASE + 27; pub const NELOG_ReleaseMem_Alert: ::DWORD = ERRLOG_BASE + 28; pub const NELOG_AT_cannot_write: ::DWORD = ERRLOG_BASE + 29; pub const NELOG_Cant_Make_Msg_File: ::DWORD = ERRLOG_BASE + 30; pub const NELOG_Exec_Netservr_NoMem: ::DWORD = ERRLOG_BASE + 31; pub const NELOG_Server_Lock_Failure: ::DWORD = ERRLOG_BASE + 32; pub const NELOG_Msg_Shutdown: ::DWORD = ERRLOG_BASE + 40; pub const NELOG_Msg_Sem_Shutdown: ::DWORD = ERRLOG_BASE + 41; pub const NELOG_Msg_Log_Err: ::DWORD = ERRLOG_BASE + 50; pub const NELOG_VIO_POPUP_ERR: ::DWORD = ERRLOG_BASE + 51; pub const NELOG_Msg_Unexpected_SMB_Type: ::DWORD = ERRLOG_BASE + 52; pub const NELOG_Wksta_Infoseg: ::DWORD = ERRLOG_BASE + 60; pub const NELOG_Wksta_Compname: ::DWORD = ERRLOG_BASE + 61; pub const NELOG_Wksta_BiosThreadFailure: ::DWORD = ERRLOG_BASE + 62; pub const NELOG_Wksta_IniSeg: ::DWORD = ERRLOG_BASE + 63; pub const NELOG_Wksta_HostTab_Full: ::DWORD = ERRLOG_BASE + 64; pub const NELOG_Wksta_Bad_Mailslot_SMB: ::DWORD = ERRLOG_BASE + 65; pub const NELOG_Wksta_UASInit: ::DWORD = ERRLOG_BASE + 66; pub const NELOG_Wksta_SSIRelogon: ::DWORD = ERRLOG_BASE + 67; pub const NELOG_Build_Name: ::DWORD = ERRLOG_BASE + 70; pub const NELOG_Name_Expansion: ::DWORD = ERRLOG_BASE + 71; pub const NELOG_Message_Send: ::DWORD = ERRLOG_BASE + 72; pub const NELOG_Mail_Slt_Err: ::DWORD = ERRLOG_BASE + 73; pub const NELOG_AT_cannot_read: ::DWORD = ERRLOG_BASE + 74; pub const NELOG_AT_sched_err: ::DWORD = ERRLOG_BASE + 75; pub const NELOG_AT_schedule_file_created: ::DWORD = ERRLOG_BASE + 76; pub const NELOG_Srvnet_NB_Open: ::DWORD = ERRLOG_BASE + 77; pub const NELOG_AT_Exec_Err: ::DWORD = ERRLOG_BASE + 78; pub const NELOG_Lazy_Write_Err: ::DWORD = ERRLOG_BASE + 80; pub const NELOG_HotFix: ::DWORD = ERRLOG_BASE + 81; pub const NELOG_HardErr_From_Server: ::DWORD = ERRLOG_BASE + 82; pub const NELOG_LocalSecFail1: ::DWORD = ERRLOG_BASE + 83; pub const NELOG_LocalSecFail2: ::DWORD = ERRLOG_BASE + 84; pub const NELOG_LocalSecFail3: ::DWORD = ERRLOG_BASE + 85; pub const NELOG_LocalSecGeneralFail: ::DWORD = ERRLOG_BASE + 86; pub const NELOG_NetWkSta_Internal_Error: ::DWORD = ERRLOG_BASE + 90; pub const NELOG_NetWkSta_No_Resource: ::DWORD = ERRLOG_BASE + 91; pub const NELOG_NetWkSta_SMB_Err: ::DWORD = ERRLOG_BASE + 92; pub const NELOG_NetWkSta_VC_Err: ::DWORD = ERRLOG_BASE + 93; pub const NELOG_NetWkSta_Stuck_VC_Err: ::DWORD = ERRLOG_BASE + 94; pub const NELOG_NetWkSta_NCB_Err: ::DWORD = ERRLOG_BASE + 95; pub const NELOG_NetWkSta_Write_Behind_Err: ::DWORD = ERRLOG_BASE + 96; pub const NELOG_NetWkSta_Reset_Err: ::DWORD = ERRLOG_BASE + 97; pub const NELOG_NetWkSta_Too_Many: ::DWORD = ERRLOG_BASE + 98; pub const NELOG_Srv_Thread_Failure: ::DWORD = ERRLOG_BASE + 104; pub const NELOG_Srv_Close_Failure: ::DWORD = ERRLOG_BASE + 105; pub const NELOG_ReplUserCurDir: ::DWORD = ERRLOG_BASE + 106; pub const NELOG_ReplCannotMasterDir: ::DWORD = ERRLOG_BASE + 107; pub const NELOG_ReplUpdateError: ::DWORD = ERRLOG_BASE + 108; pub const NELOG_ReplLostMaster: ::DWORD = ERRLOG_BASE + 109; pub const NELOG_NetlogonAuthDCFail: ::DWORD = ERRLOG_BASE + 110; pub const NELOG_ReplLogonFailed: ::DWORD = ERRLOG_BASE + 111; pub const NELOG_ReplNetErr: ::DWORD = ERRLOG_BASE + 112; pub const NELOG_ReplMaxFiles: ::DWORD = ERRLOG_BASE + 113; pub const NELOG_ReplMaxTreeDepth: ::DWORD = ERRLOG_BASE + 114; pub const NELOG_ReplBadMsg: ::DWORD = ERRLOG_BASE + 115; pub const NELOG_ReplSysErr: ::DWORD = ERRLOG_BASE + 116; pub const NELOG_ReplUserLoged: ::DWORD = ERRLOG_BASE + 117; pub const NELOG_ReplBadImport: ::DWORD = ERRLOG_BASE + 118; pub const NELOG_ReplBadExport: ::DWORD = ERRLOG_BASE + 119; pub const NELOG_ReplSignalFileErr: ::DWORD = ERRLOG_BASE + 120; pub const NELOG_DiskFT: ::DWORD = ERRLOG_BASE + 121; pub const NELOG_ReplAccessDenied: ::DWORD = ERRLOG_BASE + 122; pub const NELOG_NetlogonFailedPrimary: ::DWORD = ERRLOG_BASE + 123; pub const NELOG_NetlogonPasswdSetFailed: ::DWORD = ERRLOG_BASE + 124; pub const NELOG_NetlogonTrackingError: ::DWORD = ERRLOG_BASE + 125; pub const NELOG_NetlogonSyncError: ::DWORD = ERRLOG_BASE + 126; pub const NELOG_NetlogonRequireSignOrSealError: ::DWORD = ERRLOG_BASE + 127; pub const NELOG_UPS_PowerOut: ::DWORD = ERRLOG_BASE + 130; pub const NELOG_UPS_Shutdown: ::DWORD = ERRLOG_BASE + 131; pub const NELOG_UPS_CmdFileError: ::DWORD = ERRLOG_BASE + 132; pub const NELOG_UPS_CannotOpenDriver: ::DWORD = ERRLOG_BASE+133; pub const NELOG_UPS_PowerBack: ::DWORD = ERRLOG_BASE + 134; pub const NELOG_UPS_CmdFileConfig: ::DWORD = ERRLOG_BASE + 135; pub const NELOG_UPS_CmdFileExec: ::DWORD = ERRLOG_BASE + 136; pub const NELOG_Missing_Parameter: ::DWORD = ERRLOG_BASE + 150; pub const NELOG_Invalid_Config_Line: ::DWORD = ERRLOG_BASE + 151; pub const NELOG_Invalid_Config_File: ::DWORD = ERRLOG_BASE + 152; pub const NELOG_File_Changed: ::DWORD = ERRLOG_BASE + 153; pub const NELOG_Files_Dont_Fit: ::DWORD = ERRLOG_BASE + 154; pub const NELOG_Wrong_DLL_Version: ::DWORD = ERRLOG_BASE + 155; pub const NELOG_Error_in_DLL: ::DWORD = ERRLOG_BASE + 156; pub const NELOG_System_Error: ::DWORD = ERRLOG_BASE + 157; pub const NELOG_FT_ErrLog_Too_Large: ::DWORD = ERRLOG_BASE + 158; pub const NELOG_FT_Update_In_Progress: ::DWORD = ERRLOG_BASE + 159; pub const NELOG_Joined_Domain: ::DWORD = ERRLOG_BASE + 160; pub const NELOG_Joined_Workgroup: ::DWORD = ERRLOG_BASE + 161; pub const NELOG_OEM_Code: ::DWORD = ERRLOG_BASE + 199; pub const ERRLOG2_BASE: ::DWORD = 5700; pub const NELOG_NetlogonSSIInitError: ::DWORD = ERRLOG2_BASE + 0; pub const NELOG_NetlogonFailedToUpdateTrustList: ::DWORD = ERRLOG2_BASE + 1; pub const NELOG_NetlogonFailedToAddRpcInterface: ::DWORD = ERRLOG2_BASE + 2; pub const NELOG_NetlogonFailedToReadMailslot: ::DWORD = ERRLOG2_BASE + 3; pub const NELOG_NetlogonFailedToRegisterSC: ::DWORD = ERRLOG2_BASE + 4; pub const NELOG_NetlogonChangeLogCorrupt: ::DWORD = ERRLOG2_BASE + 5; pub const NELOG_NetlogonFailedToCreateShare: ::DWORD = ERRLOG2_BASE + 6; pub const NELOG_NetlogonDownLevelLogonFailed: ::DWORD = ERRLOG2_BASE + 7; pub const NELOG_NetlogonDownLevelLogoffFailed: ::DWORD = ERRLOG2_BASE + 8; pub const NELOG_NetlogonNTLogonFailed: ::DWORD = ERRLOG2_BASE + 9; pub const NELOG_NetlogonNTLogoffFailed: ::DWORD = ERRLOG2_BASE + 10; pub const NELOG_NetlogonPartialSyncCallSuccess: ::DWORD = ERRLOG2_BASE + 11; pub const NELOG_NetlogonPartialSyncCallFailed: ::DWORD = ERRLOG2_BASE + 12; pub const NELOG_NetlogonFullSyncCallSuccess: ::DWORD = ERRLOG2_BASE + 13; pub const NELOG_NetlogonFullSyncCallFailed: ::DWORD = ERRLOG2_BASE + 14; pub const NELOG_NetlogonPartialSyncSuccess: ::DWORD = ERRLOG2_BASE + 15; pub const NELOG_NetlogonPartialSyncFailed: ::DWORD = ERRLOG2_BASE + 16; pub const NELOG_NetlogonFullSyncSuccess: ::DWORD = ERRLOG2_BASE + 17; pub const NELOG_NetlogonFullSyncFailed: ::DWORD = ERRLOG2_BASE + 18; pub const NELOG_NetlogonAuthNoDomainController: ::DWORD = ERRLOG2_BASE + 19; pub const NELOG_NetlogonAuthNoTrustLsaSecret: ::DWORD = ERRLOG2_BASE + 20; pub const NELOG_NetlogonAuthNoTrustSamAccount: ::DWORD = ERRLOG2_BASE + 21; pub const NELOG_NetlogonServerAuthFailed: ::DWORD = ERRLOG2_BASE + 22; pub const NELOG_NetlogonServerAuthNoTrustSamAccount: ::DWORD = ERRLOG2_BASE + 23; pub const NELOG_FailedToRegisterSC: ::DWORD = ERRLOG2_BASE + 24; pub const NELOG_FailedToSetServiceStatus: ::DWORD = ERRLOG2_BASE + 25; pub const NELOG_FailedToGetComputerName: ::DWORD = ERRLOG2_BASE + 26; pub const NELOG_DriverNotLoaded: ::DWORD = ERRLOG2_BASE + 27; pub const NELOG_NoTranportLoaded: ::DWORD = ERRLOG2_BASE + 28; pub const NELOG_NetlogonFailedDomainDelta: ::DWORD = ERRLOG2_BASE + 29; pub const NELOG_NetlogonFailedGlobalGroupDelta: ::DWORD = ERRLOG2_BASE + 30; pub const NELOG_NetlogonFailedLocalGroupDelta: ::DWORD = ERRLOG2_BASE + 31; pub const NELOG_NetlogonFailedUserDelta: ::DWORD = ERRLOG2_BASE + 32; pub const NELOG_NetlogonFailedPolicyDelta: ::DWORD = ERRLOG2_BASE + 33; pub const NELOG_NetlogonFailedTrustedDomainDelta: ::DWORD = ERRLOG2_BASE + 34; pub const NELOG_NetlogonFailedAccountDelta: ::DWORD = ERRLOG2_BASE + 35; pub const NELOG_NetlogonFailedSecretDelta: ::DWORD = ERRLOG2_BASE + 36; pub const NELOG_NetlogonSystemError: ::DWORD = ERRLOG2_BASE + 37; pub const NELOG_NetlogonDuplicateMachineAccounts: ::DWORD = ERRLOG2_BASE + 38; pub const NELOG_NetlogonTooManyGlobalGroups: ::DWORD = ERRLOG2_BASE + 39; pub const NELOG_NetlogonBrowserDriver: ::DWORD = ERRLOG2_BASE + 40; pub const NELOG_NetlogonAddNameFailure: ::DWORD = ERRLOG2_BASE + 41; pub const NELOG_RplMessages: ::DWORD = ERRLOG2_BASE + 42; pub const NELOG_RplXnsBoot: ::DWORD = ERRLOG2_BASE + 43; pub const NELOG_RplSystem: ::DWORD = ERRLOG2_BASE + 44; pub const NELOG_RplWkstaTimeout: ::DWORD = ERRLOG2_BASE + 45; pub const NELOG_RplWkstaFileOpen: ::DWORD = ERRLOG2_BASE + 46; pub const NELOG_RplWkstaFileRead: ::DWORD = ERRLOG2_BASE + 47; pub const NELOG_RplWkstaMemory: ::DWORD = ERRLOG2_BASE + 48; pub const NELOG_RplWkstaFileChecksum: ::DWORD = ERRLOG2_BASE + 49; pub const NELOG_RplWkstaFileLineCount: ::DWORD = ERRLOG2_BASE + 50; pub const NELOG_RplWkstaBbcFile: ::DWORD = ERRLOG2_BASE + 51; pub const NELOG_RplWkstaFileSize: ::DWORD = ERRLOG2_BASE + 52; pub const NELOG_RplWkstaInternal: ::DWORD = ERRLOG2_BASE + 53; pub const NELOG_RplWkstaWrongVersion: ::DWORD = ERRLOG2_BASE + 54; pub const NELOG_RplWkstaNetwork: ::DWORD = ERRLOG2_BASE + 55; pub const NELOG_RplAdapterResource: ::DWORD = ERRLOG2_BASE + 56; pub const NELOG_RplFileCopy: ::DWORD = ERRLOG2_BASE + 57; pub const NELOG_RplFileDelete: ::DWORD = ERRLOG2_BASE + 58; pub const NELOG_RplFilePerms: ::DWORD = ERRLOG2_BASE + 59; pub const NELOG_RplCheckConfigs: ::DWORD = ERRLOG2_BASE + 60; pub const NELOG_RplCreateProfiles: ::DWORD = ERRLOG2_BASE + 61; pub const NELOG_RplRegistry: ::DWORD = ERRLOG2_BASE + 62; pub const NELOG_RplReplaceRPLDISK: ::DWORD = ERRLOG2_BASE + 63; pub const NELOG_RplCheckSecurity: ::DWORD = ERRLOG2_BASE + 64; pub const NELOG_RplBackupDatabase: ::DWORD = ERRLOG2_BASE + 65; pub const NELOG_RplInitDatabase: ::DWORD = ERRLOG2_BASE + 66; pub const NELOG_RplRestoreDatabaseFailure: ::DWORD = ERRLOG2_BASE + 67; pub const NELOG_RplRestoreDatabaseSuccess: ::DWORD = ERRLOG2_BASE + 68; pub const NELOG_RplInitRestoredDatabase: ::DWORD = ERRLOG2_BASE + 69; pub const NELOG_NetlogonSessionTypeWrong: ::DWORD = ERRLOG2_BASE + 70; pub const NELOG_RplUpgradeDBTo40: ::DWORD = ERRLOG2_BASE + 71; pub const NELOG_NetlogonLanmanBdcsNotAllowed: ::DWORD = ERRLOG2_BASE + 72; pub const NELOG_NetlogonNoDynamicDns: ::DWORD = ERRLOG2_BASE + 73; pub const NELOG_NetlogonDynamicDnsRegisterFailure: ::DWORD = ERRLOG2_BASE + 74; pub const NELOG_NetlogonDynamicDnsDeregisterFailure: ::DWORD = ERRLOG2_BASE + 75; pub const NELOG_NetlogonFailedFileCreate: ::DWORD = ERRLOG2_BASE + 76; pub const NELOG_NetlogonGetSubnetToSite: ::DWORD = ERRLOG2_BASE + 77; pub const NELOG_NetlogonNoSiteForClient: ::DWORD = ERRLOG2_BASE + 78; pub const NELOG_NetlogonBadSiteName: ::DWORD = ERRLOG2_BASE + 79; pub const NELOG_NetlogonBadSubnetName: ::DWORD = ERRLOG2_BASE + 80; pub const NELOG_NetlogonDynamicDnsServerFailure: ::DWORD = ERRLOG2_BASE + 81; pub const NELOG_NetlogonDynamicDnsFailure: ::DWORD = ERRLOG2_BASE + 82; pub const NELOG_NetlogonRpcCallCancelled: ::DWORD = ERRLOG2_BASE + 83; pub const NELOG_NetlogonDcSiteCovered: ::DWORD = ERRLOG2_BASE + 84; pub const NELOG_NetlogonDcSiteNotCovered: ::DWORD = ERRLOG2_BASE + 85; pub const NELOG_NetlogonGcSiteCovered: ::DWORD = ERRLOG2_BASE + 86; pub const NELOG_NetlogonGcSiteNotCovered: ::DWORD = ERRLOG2_BASE + 87; pub const NELOG_NetlogonFailedSpnUpdate: ::DWORD = ERRLOG2_BASE + 88; pub const NELOG_NetlogonFailedDnsHostNameUpdate: ::DWORD = ERRLOG2_BASE + 89; pub const NELOG_NetlogonAuthNoUplevelDomainController: ::DWORD = ERRLOG2_BASE + 90; pub const NELOG_NetlogonAuthDomainDowngraded: ::DWORD = ERRLOG2_BASE + 91; pub const NELOG_NetlogonNdncSiteCovered: ::DWORD = ERRLOG2_BASE + 92; pub const NELOG_NetlogonNdncSiteNotCovered: ::DWORD = ERRLOG2_BASE + 93; pub const NELOG_NetlogonDcOldSiteCovered: ::DWORD = ERRLOG2_BASE + 94; pub const NELOG_NetlogonDcSiteNotCoveredAuto: ::DWORD = ERRLOG2_BASE + 95; pub const NELOG_NetlogonGcOldSiteCovered: ::DWORD = ERRLOG2_BASE + 96; pub const NELOG_NetlogonGcSiteNotCoveredAuto: ::DWORD = ERRLOG2_BASE + 97; pub const NELOG_NetlogonNdncOldSiteCovered: ::DWORD = ERRLOG2_BASE + 98; pub const NELOG_NetlogonNdncSiteNotCoveredAuto: ::DWORD = ERRLOG2_BASE + 99; pub const NELOG_NetlogonSpnMultipleSamAccountNames: ::DWORD = ERRLOG2_BASE + 100; pub const NELOG_NetlogonSpnCrackNamesFailure: ::DWORD = ERRLOG2_BASE + 101; pub const NELOG_NetlogonNoAddressToSiteMapping: ::DWORD = ERRLOG2_BASE + 102; pub const NELOG_NetlogonInvalidGenericParameterValue: ::DWORD = ERRLOG2_BASE + 103; pub const NELOG_NetlogonInvalidDwordParameterValue: ::DWORD = ERRLOG2_BASE + 104; pub const NELOG_NetlogonServerAuthFailedNoAccount: ::DWORD = ERRLOG2_BASE + 105; pub const NELOG_NetlogonNoDynamicDnsManual: ::DWORD = ERRLOG2_BASE + 106; pub const NELOG_NetlogonNoSiteForClients: ::DWORD = ERRLOG2_BASE + 107; pub const NELOG_NetlogonDnsDeregAborted: ::DWORD = ERRLOG2_BASE + 108; pub const NELOG_NetlogonRpcPortRequestFailure: ::DWORD = ERRLOG2_BASE + 109; pub const NELOG_NetlogonPartialSiteMappingForClients: ::DWORD = ERRLOG2_BASE + 110; pub const NELOG_NetlogonRemoteDynamicDnsRegisterFailure: ::DWORD = ERRLOG2_BASE + 111; pub const NELOG_NetlogonRemoteDynamicDnsDeregisterFailure: ::DWORD = ERRLOG2_BASE + 112; pub const NELOG_NetlogonRejectedRemoteDynamicDnsRegister: ::DWORD = ERRLOG2_BASE + 113; pub const NELOG_NetlogonRejectedRemoteDynamicDnsDeregister: ::DWORD = ERRLOG2_BASE + 114; pub const NELOG_NetlogonRemoteDynamicDnsUpdateRequestFailure: ::DWORD = ERRLOG2_BASE + 115; pub const NELOG_NetlogonUserValidationReqInitialTimeOut: ::DWORD = ERRLOG2_BASE + 116; pub const NELOG_NetlogonUserValidationReqRecurringTimeOut: ::DWORD = ERRLOG2_BASE + 117; pub const NELOG_NetlogonUserValidationReqWaitInitialWarning: ::DWORD = ERRLOG2_BASE + 118; pub const NELOG_NetlogonUserValidationReqWaitRecurringWarning: ::DWORD = ERRLOG2_BASE + 119; pub const NELOG_NetlogonFailedToAddAuthzRpcInterface: ::DWORD = ERRLOG2_BASE + 120; pub const NELOG_NetLogonFailedToInitializeAuthzRm: ::DWORD = ERRLOG2_BASE + 121; pub const NELOG_NetLogonFailedToInitializeRPCSD: ::DWORD = ERRLOG2_BASE + 122; pub const NELOG_NetlogonMachinePasswdSetSucceeded: ::DWORD = ERRLOG2_BASE + 123; pub const NELOG_NetlogonMsaPasswdSetSucceeded: ::DWORD = ERRLOG2_BASE + 124; deps/winapi-0.2.5/src/vadefs.rs0000644000000000000000000000062212605021254015040 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Definitions of macro helpers used by . This is the topmost header in the CRT header //! lattice, and is always the first CRT header to be included, explicitly or implicitly. //! Therefore, this header also has several definitions that are used throughout the CRT. //39 pub type va_list = *mut ::c_char; deps/winapi-0.2.5/src/shobjidl.rs0000644000000000000000000006124212615662007015403 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! this ALWAYS GENERATED file contains the definitions for the interfaces //Terrible forward declarations that need to be filled in #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IContextMenu; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IContextMenu2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IContextMenu3; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IExecuteCommand; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IPersistFolder; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IRunnableTask; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellTaskScheduler; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IQueryCodePage; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IPersistFolder2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IPersistFolder3; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IPersistIDList; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IEnumIDList; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IEnumFullIDList; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IFileSyncMergeHandler; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IObjectWithFolderEnumMode; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IParseAndCreateItem; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellFolder; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IEnumExtraSearch; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellFolder2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IFolderViewOptions; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellView; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellView2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellView3; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IFolderView; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ISearchBoxInfo; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IFolderView2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IFolderViewSettings; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IPreviewHandlerVisuals; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IVisualProperties; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ICommDlgBrowser; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ICommDlgBrowser2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ICommDlgBrowser3; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IColumnManager; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IFolderFilterSite; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IFolderFilter; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IInputObjectSite; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IInputObject; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IInputObject2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellIcon; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellBrowser; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IProfferService; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellItem2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellItemImageFactory; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IUserAccountChangeCallback; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IEnumShellItems; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ITransferAdviseSink; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ITransferSource; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IEnumResources; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellItemResources; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ITransferDestination; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IStreamAsync; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IStreamUnbufferedInfo; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IInitializeWithItem; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IObjectWithSelection; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IObjectWithBackReferences; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IPropertyUI; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ICategoryProvider; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ICategorizer; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDropTargetHelper; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDragSourceHelper; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDragSourceHelper2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellLinkA; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellLinkW; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellLinkDataList; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IResolveShellLink; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IActionProgressDialog; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IHWEventHandler; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IHWEventHandler2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IQueryCancelAutoPlay; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDynamicHWHandler; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IActionProgress; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellExtInit; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellPropSheetExt; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IRemoteComputer; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IQueryContinue; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IObjectWithCancelEvent; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IUserNotification; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IUserNotificationCallback; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IUserNotification2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IItemNameLimits; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ISearchFolderItemFactory; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IExtractImage; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IExtractImage2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IThumbnailHandlerFactory; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IParentAndItem; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDockingWindow; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDeskBand; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDeskBandInfo; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDeskBand2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ITaskbarList; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ITaskbarList2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ITaskbarList3; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ITaskbarList4; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IStartMenuPinnedList; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ICDBurn; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IWizardSite; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IWizardExtension; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IWebWizardExtension; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IPublishingWizard; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IFolderViewHost; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IExplorerBrowserEvents; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IExplorerBrowser; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IAccessibleObject; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IResultsFolder; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IEnumObjects; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IOperationsProgressDialog; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IIOCancelInformation; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IFileOperation; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IObjectProvider; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct INamespaceWalkCB; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct INamespaceWalkCB2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct INamespaceWalk; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IAutoCompleteDropDown; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IBandSite; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ICDBurnExt; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IContextMenuSite; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IEnumReadyCallback; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IEnumerableView; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IInsertItem; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IMenuBand; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IFolderBandPriv; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IRegTreeItem; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IImageRecompress; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDeskBar; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IMenuPopup; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IFileIsInUse; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IApplicationAssociationRegistration; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IApplicationAssociationRegistrationUI; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDelegateFolder; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IBrowserFrameOptions; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct INewWindowManager; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IAttachmentExecute; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellMenuCallback; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellMenu; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellRunDll; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IKnownFolder; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IKnownFolderManager; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ISharingConfigurationManager; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IPreviousVersionsInfo; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IRelatedItem; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IIdentityName; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDelegateItem; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ICurrentItem; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ITransferMediumItem; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IUseToBrowseItem; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDisplayItem; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IViewStateIdentityItem; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IPreviewItem; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDestinationStreamFactory; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct INewMenuClient; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IInitializeWithBindCtx; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct INameSpaceTreeControl; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct INameSpaceTreeControl2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct INameSpaceTreeControlEvents; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct INameSpaceTreeControlDropHandler; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct INameSpaceTreeAccessible; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct INameSpaceTreeControlCustomDraw; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct INameSpaceTreeControlFolderCapabilities; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IPreviewHandler; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IPreviewHandlerFrame; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ITrayDeskBand; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IBandHost; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IExplorerPaneVisibility; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IContextMenuCB; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDefaultExtractIconInit; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IExplorerCommand; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IExplorerCommandState; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IInitializeCommand; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IEnumExplorerCommand; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IExplorerCommandProvider; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IMarkupCallback; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IControlMarkup; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IInitializeNetworkFolder; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IOpenControlPanel; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IComputerInfoChangeNotify; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IFileSystemBindData; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IFileSystemBindData2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ICustomDestinationList; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IApplicationDestinations; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IApplicationDocumentLists; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IObjectWithAppUserModelID; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IObjectWithProgID; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IUpdateIDList; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDesktopGadget; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDesktopWallpaper; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IHomeGroup; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IInitializeWithPropertyStore; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IOpenSearchSource; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IShellLibrary; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDefaultFolderMenuInitialize; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IApplicationActivationManager; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IAssocHandlerInvoker; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IAssocHandler; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IEnumAssocHandlers; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDataObjectProvider; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IDataTransferManagerInterop; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IFrameworkInputPaneHandler; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IFrameworkInputPane; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IAccessibilityDockingServiceCallback; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IAccessibilityDockingService; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IAppVisibilityEvents; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IAppVisibility; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IPackageExecutionStateChangeNotification; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IPackageDebugSettings; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ISuspensionDependencyManager; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IExecuteCommandApplicationHostEnvironment; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IExecuteCommandHost; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IApplicationDesignModeSettings; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IApplicationDesignModeSettings2; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ILaunchTargetMonitor; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ILaunchSourceViewSizePreference; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ILaunchTargetViewSizePreference; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct ILaunchSourceAppUserModelId; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IInitializeWithWindow; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IHandlerInfo; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IHandlerActivationHost; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct IContactManagerInterop; //4498 pub type SFGAOF = ::ULONG; //9466 ENUM!{enum SIGDN { SIGDN_NORMALDISPLAY = 0, SIGDN_PARENTRELATIVEPARSING = 0x80018001, SIGDN_DESKTOPABSOLUTEPARSING = 0x80028000, SIGDN_PARENTRELATIVEEDITING = 0x80031001, SIGDN_DESKTOPABSOLUTEEDITING = 0x8004c000, SIGDN_FILESYSPATH = 0x80058000, SIGDN_URL = 0x80068000, SIGDN_PARENTRELATIVEFORADDRESSBAR = 0x8007c001, SIGDN_PARENTRELATIVE = 0x80080001, SIGDN_PARENTRELATIVEFORUI = 0x80094001, }} ENUM!{enum SICHINTF { SICHINT_DISPLAY = 0, SICHINT_ALLFIELDS = 0x80000000, SICHINT_CANONICAL = 0x10000000, SICHINT_TEST_FILESYSPATH_IF_NOT_EQUAL = 0x20000000, }} //9498 RIDL!( interface IShellItem(IShellItemVtbl): IUnknown(IUnknownVtbl) { fn BindToHandler( &mut self, pbc: *mut ::IBindCtx, bhid: ::REFGUID, riid: ::REFIID, ppv: *mut *mut ::c_void ) -> ::HRESULT, fn GetParent(&mut self, ppsi: *mut *mut IShellItem) -> ::HRESULT, fn GetDisplayName(&mut self, sigdnName: SIGDN, ppszName: *mut ::LPWSTR) -> ::HRESULT, fn GetAttributes(&mut self, sfgaoMask: SFGAOF, psfgaoAttribs: *mut SFGAOF) -> ::HRESULT, fn Compare(&mut self, psi: *mut IShellItem, hint: SICHINTF, piOrder: *mut ::c_int) -> ::HRESULT } ); //11963 pub type IFileOperationProgressSink = ::IUnknown; // TODO pub type IShellItemArray = ::IUnknown; // TODO //20869 RIDL!( interface IModalWindow(IModalWindowVtbl): IUnknown(IUnknownVtbl) { fn Show(&mut self, hwndOwner: ::HWND) -> ::HRESULT } ); //22307 ENUM!{enum FDE_OVERWRITE_RESPONSE { FDEOR_DEFAULT = 0, FDEOR_ACCEPT = 1, FDEOR_REFUSE = 2, }} ENUM!{enum FDE_SHAREVIOLATION_RESPONSE { FDESVR_DEFAULT = 0, FDESVR_ACCEPT = 1, FDESVR_REFUSE = 2, }} ENUM!{enum FDAP { FDAP_BOTTOM = 0, FDAP_TOP = 1, }} RIDL!( interface IFileDialogEvents(IFileDialogEventsVtbl): IUnknown(IUnknownVtbl) { fn OnFileOk(&mut self, pfd: *mut IFileDialog) -> ::HRESULT, fn OnFolderChanging(&mut self, pfd: *mut IFileDialog, psiFolder: *mut IShellItem) -> ::HRESULT, fn OnFolderChange(&mut self, pfd: *mut IFileDialog) -> ::HRESULT, fn OnSelectionChange(&mut self, pfd: *mut IFileDialog) -> ::HRESULT, fn OnShareViolation( &mut self, pfd: *mut IFileDialog, psi: *mut IShellItem, pResponse: *mut FDE_SHAREVIOLATION_RESPONSE ) -> ::HRESULT, fn OnTypeChange(&mut self, pfd: *mut IFileDialog) -> ::HRESULT, fn OnOverwrite( &mut self, pfd: *mut IFileDialog, psi: *mut IShellItem, pResponse: *mut FDE_OVERWRITE_RESPONSE ) -> ::HRESULT } ); FLAGS!{enum FILEOPENDIALOGOPTIONS { FOS_OVERWRITEPROMPT = 0x2, FOS_STRICTFILETYPES = 0x4, FOS_NOCHANGEDIR = 0x8, FOS_PICKFOLDERS = 0x20, FOS_FORCEFILESYSTEM = 0x40, FOS_ALLNONSTORAGEITEMS = 0x80, FOS_NOVALIDATE = 0x100, FOS_ALLOWMULTISELECT = 0x200, FOS_PATHMUSTEXIST = 0x800, FOS_FILEMUSTEXIST = 0x1000, FOS_CREATEPROMPT = 0x2000, FOS_SHAREAWARE = 0x4000, FOS_NOREADONLYRETURN = 0x8000, FOS_NOTESTFILECREATE = 0x10000, FOS_HIDEMRUPLACES = 0x20000, FOS_HIDEPINNEDPLACES = 0x40000, FOS_NODEREFERENCELINKS = 0x100000, FOS_DONTADDTORECENT = 0x2000000, FOS_FORCESHOWHIDDEN = 0x10000000, FOS_DEFAULTNOMINIMODE = 0x20000000, FOS_FORCEPREVIEWPANEON = 0x40000000, FOS_SUPPORTSTREAMABLEITEMS = 0x80000000, }} RIDL!( interface IFileDialog(IFileDialogVtbl): IModalWindow(IModalWindowVtbl) { fn SetFileTypes( &mut self, cFileTypes: ::UINT, rgFilterSpec: *const ::COMDLG_FILTERSPEC ) -> ::HRESULT, fn SetFileTypeIndex(&mut self, iFileType: ::UINT) -> ::HRESULT, fn GetFileTypeIndex(&mut self, piFileType: *mut ::UINT) -> ::HRESULT, fn Advise(&mut self, pfde: *mut IFileDialogEvents, pdwCookie: *mut ::DWORD) -> ::HRESULT, fn Unadvise(&mut self, dwCookie: ::DWORD) -> ::HRESULT, fn SetOptions(&mut self, fos: FILEOPENDIALOGOPTIONS) -> ::HRESULT, fn GetOptions(&mut self, pfos: *mut FILEOPENDIALOGOPTIONS) -> ::HRESULT, fn SetDefaultFolder(&mut self, psi: *mut IShellItem) -> ::HRESULT, fn SetFolder(&mut self, psi: *mut IShellItem) -> ::HRESULT, fn GetFolder(&mut self, ppsi: *mut *mut IShellItem) -> ::HRESULT, fn GetCurrentSelection(&mut self, ppsi: *mut *mut IShellItem) -> ::HRESULT, fn SetFileName(&mut self, pszName: ::LPCWSTR) -> ::HRESULT, fn GetFileName(&mut self, pszName: *mut ::LPWSTR) -> ::HRESULT, fn SetTitle(&mut self, pszTitle: ::LPCWSTR) -> ::HRESULT, fn SetOkButtonLabel(&mut self, pszText: ::LPCWSTR) -> ::HRESULT, fn SetFileNameLabel(&mut self, pszLabel: ::LPCWSTR) -> ::HRESULT, fn GetResult(&mut self, ppsi: *mut *mut IShellItem) -> ::HRESULT, fn AddPlace(&mut self, psi: *mut IShellItem, fdap: FDAP) -> ::HRESULT, fn SetDefaultExtension(&mut self, pszDefaultExtension: ::LPCWSTR) -> ::HRESULT, fn Close(&mut self, hr: ::HRESULT) -> ::HRESULT, fn SetClientGuid(&mut self, guid: ::REFGUID) -> ::HRESULT, fn ClearClientData(&mut self) -> ::HRESULT, fn SetFilter(&mut self, pFilter: *mut IShellItemFilter) -> ::HRESULT } ); RIDL!( interface IFileSaveDialog(IFileSaveDialogVtbl): IFileDialog(IFileDialogVtbl) { fn SetSaveAsItem(&mut self, psi: *mut IShellItem) -> ::HRESULT, fn SetProperties(&mut self, pStore: *mut ::IPropertyStore) -> ::HRESULT, fn SetCollectedProperties( &mut self, pList: *mut ::IPropertyDescriptionList, fAppendDefault: ::BOOL ) -> ::HRESULT, fn GetProperties(&mut self, ppStore: *mut *mut ::IPropertyStore) -> ::HRESULT, fn ApplyProperties( &mut self, psi: *mut IShellItem, pStore: *mut ::IPropertyStore, hwnd: ::HWND, pSink: *mut IFileOperationProgressSink ) -> ::HRESULT } ); RIDL!( interface IFileOpenDialog(IFileOpenDialogVtbl): IFileDialog(IFileDialogVtbl) { fn GetResults(&mut self, ppenum: *mut *mut IShellItemArray) -> ::HRESULT, fn GetSelectedItems(&mut self, ppsai: *mut *mut IShellItemArray) -> ::HRESULT } ); ENUM!{enum CDCONTROLSTATE { CDCS_INACTIVE = 0x00000000, CDCS_ENABLED = 0x00000001, CDCS_VISIBLE = 0x00000002, CDCS_ENABLEDVISIBLE = 0x00000003, }} RIDL!( interface IFileDialogCustomize(IFileDialogCustomizeVtbl): IUnknown(IUnknownVtbl) { fn EnableOpenDropDown(&mut self, dwIDCtl: ::DWORD) -> ::HRESULT, fn AddMenu(&mut self, dwIDCtl: ::DWORD, pszLabel: ::LPCWSTR) -> ::HRESULT, fn AddPushButton(&mut self, dwIDCtl: ::DWORD, pszLabel: ::LPCWSTR) -> ::HRESULT, fn AddComboBox(&mut self, dwIDCtl: ::DWORD) -> ::HRESULT, fn AddRadioButtonList(&mut self, dwIDCtl: ::DWORD) -> ::HRESULT, fn AddCheckButton( &mut self, dwIDCtl: ::DWORD, pszLabel: ::LPCWSTR, bChecked: ::BOOL ) -> ::HRESULT, fn AddEditBox(&mut self, dwIDCtl: ::DWORD, pszText: ::LPCWSTR) -> ::HRESULT, fn AddSeparator(&mut self, dwIDCtl: ::DWORD) -> ::HRESULT, fn AddText(&mut self, dwIDCtl: ::DWORD, pszText: ::LPCWSTR) -> ::HRESULT, fn SetControlLabel(&mut self, dwIDCtl: ::DWORD, pszLabel: ::LPCWSTR) -> ::HRESULT, fn GetControlState(&mut self, dwIDCtl: ::DWORD, pdwState: *mut CDCONTROLSTATE) -> ::HRESULT, fn SetControlState(&mut self, dwIDCtl: ::DWORD, dwState: CDCONTROLSTATE) -> ::HRESULT, fn GetEditBoxText(&mut self, dwIDCtl: ::DWORD, ppszText: *mut *mut ::WCHAR) -> ::HRESULT, fn SetEditBoxText(&mut self, dwIDCtl: ::DWORD, pszText: ::LPCWSTR) -> ::HRESULT, fn GetCheckButtonState(&mut self, dwIDCtl: ::DWORD, pbChecked: *mut ::BOOL) -> ::HRESULT, fn SetCheckButtonState(&mut self, dwIDCtl: ::DWORD, bChecked: ::BOOL) -> ::HRESULT, fn AddControlItem( &mut self, dwIDCtl: ::DWORD, dwIDItem: ::DWORD, pszLabel: ::LPCWSTR ) -> ::HRESULT, fn RemoveControlItem(&mut self, dwIDCtl: ::DWORD, dwIDItem: ::DWORD) -> ::HRESULT, fn RemoveAllControlItems(&mut self, dwIDCtl: ::DWORD) -> ::HRESULT, fn GetControlItemState( &mut self, dwIDCtl: ::DWORD, dwIDItem: ::DWORD, pdwState: *mut CDCONTROLSTATE ) -> ::HRESULT, fn SetControlItemState( &mut self, dwIDCtl: ::DWORD, dwIDItem: ::DWORD, dwState: CDCONTROLSTATE ) -> ::HRESULT, fn GetSelectedControlItem(&mut self, dwIDCtl: ::DWORD, pdwIDItem: *mut ::DWORD) -> ::HRESULT, fn SetSelectedControlItem(&mut self, dwIDCtl: ::DWORD, dwIDItem: ::DWORD) -> ::HRESULT, fn StartVisualGroup(&mut self, dwIDCtl: ::DWORD, pszLabel: ::LPCWSTR) -> ::HRESULT, fn EndVisualGroup(&mut self) -> ::HRESULT, fn MakeProminent(&mut self, dwIDCtl: ::DWORD) -> ::HRESULT, fn SetControlItemText(&mut self, dwIDCtl: ::DWORD, dwIDItem: ::DWORD, pszLabel: ::LPCWSTR) -> ::HRESULT } ); RIDL!( interface IFileDialogControlEvents(IFileDialogControlEventsVtbl): IUnknown(IUnknownVtbl) { fn OnItemSelected( &mut self, pfdc: *mut IFileDialogCustomize, dwIDCtl: ::DWORD, dwIDItem: ::DWORD ) -> ::HRESULT, fn OnButtonClicked(&mut self, pfdc: *mut IFileDialogCustomize, dwIDCtl: ::DWORD) -> ::HRESULT, fn OnCheckButtonToggled( &mut self, pfdc: *mut IFileDialogCustomize, dwIDCtl: ::DWORD, bChecked: ::BOOL ) -> ::HRESULT, fn OnControlActivating( &mut self, pfdc: *mut IFileDialogCustomize, dwIDCtl: ::DWORD ) -> ::HRESULT } ); RIDL!( interface IFileDialog2(IFileDialog2Vtbl): IFileDialog(IFileDialogVtbl) { fn SetCancelButtonLabel(&mut self, pszLabel: ::LPCWSTR) -> ::HRESULT, fn SetNavigationRoot(&mut self, psi: IShellItem) -> ::HRESULT } ); //27457 pub type IShellItemFilter = ::IUnknown; // TODO deps/winapi-0.2.5/src/objbase.rs0000644000000000000000000000035412605021351015175 0ustar rootroot//! Component object model defintions pub const COINIT_APARTMENTTHREADED: ::DWORD = 0x2; pub const COINIT_MULTITHREADED: ::DWORD = 0x0; pub const COINIT_DISABLE_OLE1DDE: ::DWORD = 0x4; pub const COINIT_SPEED_OVER_MEMORY: ::DWORD = 0x8; deps/winapi-0.2.5/src/dxgi1_3.rs0000644000000000000000000001276612617171043015047 0ustar rootroot// Copyright © 2015; Dmitry Roschin // Licensed under the MIT License //! Mappings for the contents of dxgi1_3.h ENUM!{ enum DXGI_FRAME_PRESENTATION_MODE { DXGI_FRAME_PRESENTATION_MODE_COMPOSED = 0, DXGI_FRAME_PRESENTATION_MODE_OVERLAY = 1, DXGI_FRAME_PRESENTATION_MODE_NONE = 2, DXGI_FRAME_PRESENTATION_MODE_COMPOSITION_FAILURE = 3, }} FLAGS!{ enum DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS { DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAG_NOMINAL_RANGE = 0x1, DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAG_BT709 = 0x2, DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAG_xvYCC = 0x4, }} FLAGS!{ enum DXGI_OVERLAY_SUPPORT_FLAG { DXGI_OVERLAY_SUPPORT_FLAG_DIRECT = 0x1, DXGI_OVERLAY_SUPPORT_FLAG_SCALING = 0x2, }} #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct DXGI_DECODE_SWAP_CHAIN_DESC { pub Flags: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct DXGI_FRAME_STATISTICS_MEDIA { pub PresentCount: ::UINT, pub PresentRefreshCount: ::UINT, pub SyncRefreshCount: ::UINT, pub SyncQPCTime: ::LARGE_INTEGER, pub SyncGPUTime: ::LARGE_INTEGER, pub CompositionMode: ::DXGI_FRAME_PRESENTATION_MODE, pub ApprovedPresentDuration: ::UINT, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct DXGI_MATRIX_3X2_F { pub _11: ::FLOAT, pub _12: ::FLOAT, pub _21: ::FLOAT, pub _22: ::FLOAT, pub _31: ::FLOAT, pub _32: ::FLOAT, } RIDL!( interface IDXGIDecodeSwapChain(IDXGIDecodeSwapChainVtbl): IUnknown(IUnknownVtbl) { fn PresentBuffer( &mut self, BufferToPresent: ::UINT, SyncInterval: ::UINT, Flags: ::UINT ) -> ::HRESULT, fn SetSourceRect(&mut self, pRect: *const ::RECT) -> ::HRESULT, fn SetTargetRect(&mut self, pRect: *const ::RECT) -> ::HRESULT, fn SetDestSize(&mut self, Width: ::UINT, Height: ::UINT) -> ::HRESULT, fn GetSourceRect(&mut self, pRect: *mut ::RECT) -> ::HRESULT, fn GetTargetRect(&mut self, pRect: *mut ::RECT) -> ::HRESULT, fn GetDestSize( &mut self, pWidth: *mut ::UINT, pHeight: *mut ::UINT ) -> ::HRESULT, fn SetColorSpace( &mut self, ColorSpace: ::DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS ) -> ::HRESULT, fn GetColorSpace(&mut self) -> ::DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS }); RIDL!( interface IDXGIDevice3(IDXGIDevice3Vtbl): IDXGIDevice2(IDXGIDevice2Vtbl) { fn Trim(&mut self) -> () }); RIDL!( interface IDXGIFactory3(IDXGIFactory3Vtbl): IDXGIFactory2(IDXGIFactory2Vtbl) { fn GetCreationFlags(&mut self) -> ::UINT }); RIDL!( interface IDXGIFactoryMedia(IDXGIFactoryMediaVtbl): IUnknown(IUnknownVtbl) { fn CreateSwapChainForCompositionSurfaceHandle( &mut self, pDevice: *mut ::IUnknown, hSurface: ::HANDLE, pDesc: *const ::DXGI_SWAP_CHAIN_DESC1, pRestrictToOutput: *mut ::IDXGIOutput, ppSwapChain: *mut *mut ::IDXGISwapChain1 ) -> ::HRESULT, fn CreateDecodeSwapChainForCompositionSurfaceHandle( &mut self, pDevice: *mut ::IUnknown, hSurface: ::HANDLE, pDesc: *mut ::DXGI_DECODE_SWAP_CHAIN_DESC, pYuvDecodeBuffers: *mut ::IDXGIResource, pRestrictToOutput: *mut ::IDXGIOutput, ppSwapChain: *mut *mut ::IDXGIDecodeSwapChain ) -> ::HRESULT }); RIDL!( interface IDXGIOutput2(IDXGIOutput2Vtbl): IDXGIOutput1(IDXGIOutput1Vtbl) { fn SupportsOverlays(&mut self) -> ::BOOL }); RIDL!( interface IDXGIOutput3(IDXGIOutput3Vtbl): IDXGIOutput2(IDXGIOutput2Vtbl) { fn CheckOverlaySupport( &mut self, EnumFormat: ::DXGI_FORMAT, pConcernedDevice: *mut ::IUnknown, pFlags: *mut ::UINT ) -> ::HRESULT }); RIDL!( interface IDXGISwapChain2(IDXGISwapChain2Vtbl): IDXGISwapChain1(IDXGISwapChain1Vtbl) { fn SetSourceSize(&mut self, Width: ::UINT, Height: ::UINT) -> ::HRESULT, fn GetSourceSize( &mut self, pWidth: *mut ::UINT, pHeight: *mut ::UINT ) -> ::HRESULT, fn SetMaximumFrameLatency(&mut self, MaxLatency: ::UINT) -> ::HRESULT, fn GetMaximumFrameLatency(&mut self, pMaxLatency: *mut ::UINT) -> ::HRESULT, fn GetFrameLatencyWaitableObject(&mut self) -> ::HANDLE, fn SetMatrixTransform( &mut self, pMatrix: *const ::DXGI_MATRIX_3X2_F ) -> ::HRESULT, fn GetMatrixTransform( &mut self, pMatrix: *mut ::DXGI_MATRIX_3X2_F ) -> ::HRESULT }); RIDL!( interface IDXGISwapChainMedia(IDXGISwapChainMediaVtbl): IUnknown(IUnknownVtbl) { fn GetFrameStatisticsMedia( &mut self, pStats: *mut ::DXGI_FRAME_STATISTICS_MEDIA ) -> ::HRESULT, fn SetPresentDuration(&mut self, Duration: ::UINT) -> ::HRESULT, fn CheckPresentDurationSupport( &mut self, DesiredPresentDuration: ::UINT, pClosestSmallerPresentDuration: *mut ::UINT, pClosestLargerPresentDuration: *mut ::UINT ) -> ::HRESULT }); pub const DXGI_CREATE_FACTORY_DEBUG: ::UINT = 0x1; DEFINE_GUID!(IID_IDXGIDevice3,0x6007896c,0x3244,0x4afd,0xbf,0x18,0xa6,0xd3,0xbe, 0xda,0x50,0x23); DEFINE_GUID!(IID_IDXGISwapChain2,0xa8be2ac4,0x199f,0x4946,0xb3,0x31,0x79,0x59, 0x9f,0xb9,0x8d,0xe7); DEFINE_GUID!(IID_IDXGIOutput2,0x595e39d1,0x2724,0x4663,0x99,0xb1,0xda,0x96,0x9d, 0xe2,0x83,0x64); DEFINE_GUID!(IID_IDXGIFactory3,0x25483823,0xcd46,0x4c7d,0x86,0xca,0x47,0xaa,0x95, 0xb8,0x37,0xbd); DEFINE_GUID!(IID_IDXGIDecodeSwapChain,0x2633066b,0x4514,0x4c7a,0x8f,0xd8,0x12, 0xea,0x98,0x05,0x9d,0x18); DEFINE_GUID!(IID_IDXGIFactoryMedia,0x41e7d1f2,0xa591,0x4f7b,0xa2,0xe5,0xfa,0x9c, 0x84,0x3e,0x1c,0x12); DEFINE_GUID!(IID_IDXGISwapChainMedia,0xdd95b90b,0xf05f,0x4f6a,0xbd,0x65,0x25, 0xbf,0xb2,0x64,0xbd,0x84); DEFINE_GUID!(IID_IDXGIOutput3,0x8a6bb301,0x7e7e,0x41F4,0xa8,0xe0,0x5b,0x32,0xf7, 0xf9,0x9b,0x18); deps/winapi-0.2.5/src/corsym.rs0000644000000000000000000000662112615662007015121 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Common Language Runtime Debugging Symbol Reader/Writer/Binder Interfaces DEFINE_GUID!(CorSym_LanguageType_C, 0x63a08714, 0xfc37, 0x11d2, 0x90, 0x4c, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1); DEFINE_GUID!(CorSym_LanguageType_CPlusPlus, 0x3a12d0b7, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2); DEFINE_GUID!(CorSym_LanguageType_CSharp, 0x3f5162f8, 0x07c6, 0x11d3, 0x90, 0x53, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1); DEFINE_GUID!(CorSym_LanguageType_Basic, 0x3a12d0b8, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2); DEFINE_GUID!(CorSym_LanguageType_Java, 0x3a12d0b4, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2); DEFINE_GUID!(CorSym_LanguageType_Cobol, 0xaf046cd1, 0xd0e1, 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc); DEFINE_GUID!(CorSym_LanguageType_Pascal, 0xaf046cd2, 0xd0e1, 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc); DEFINE_GUID!(CorSym_LanguageType_ILAssembly, 0xaf046cd3, 0xd0e1, 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc); DEFINE_GUID!(CorSym_LanguageType_JScript, 0x3a12d0b6, 0xc26c, 0x11d0, 0xb4, 0x42, 0x00, 0xa0, 0x24, 0x4a, 0x1d, 0xd2); DEFINE_GUID!(CorSym_LanguageType_SMC, 0xd9b9f7b, 0x6611, 0x11d3, 0xbd, 0x2a, 0x0, 0x0, 0xf8, 0x8, 0x49, 0xbd); DEFINE_GUID!(CorSym_LanguageType_MCPlusPlus, 0x4b35fde8, 0x07c6, 0x11d3, 0x90, 0x53, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1); DEFINE_GUID!(CorSym_LanguageVendor_Microsoft, 0x994b45c4, 0xe6e9, 0x11d2, 0x90, 0x3f, 0x00, 0xc0, 0x4f, 0xa3, 0x02, 0xa1); DEFINE_GUID!(CorSym_DocumentType_Text, 0x5a869d0b, 0x6611, 0x11d3, 0xbd, 0x2a, 0x0, 0x0, 0xf8, 0x8, 0x49, 0xbd); DEFINE_GUID!(CorSym_DocumentType_MC, 0xeb40cb65, 0x3c1f, 0x4352, 0x9d, 0x7b, 0xba, 0xf, 0xc4, 0x7a, 0x9d, 0x77); DEFINE_GUID!(CorSym_SourceHash_MD5, 0x406ea660, 0x64cf, 0x4c82, 0xb6, 0xf0, 0x42, 0xd4, 0x81, 0x72, 0xa7, 0x99); DEFINE_GUID!(CorSym_SourceHash_SHA1, 0xff1816ec, 0xaa5e, 0x4d10, 0x87, 0xf7, 0x6f, 0x49, 0x63, 0x83, 0x34, 0x60); ENUM!{enum CorSymAddrKind { ADDR_IL_OFFSET = 1, ADDR_NATIVE_RVA = 2, ADDR_NATIVE_REGISTER = 3, ADDR_NATIVE_REGREL = 4, ADDR_NATIVE_OFFSET = 5, ADDR_NATIVE_REGREG = 6, ADDR_NATIVE_REGSTK = 7, ADDR_NATIVE_STKREG = 8, ADDR_BITFIELD = 9, ADDR_NATIVE_ISECTOFFSET = 10, }} FLAGS!{enum CorSymVarFlag { VAR_IS_COMP_GEN = 1, }} RIDL!( interface ISymUnmanagedBinder(ISymUnmanagedBinderVtbl): IUnknown(IUnknownVtbl) { fn GetReaderForFile( &mut self, importer: *mut ::IUnknown, fileName: *const ::WCHAR, searchPath: *const ::WCHAR, pRetVal: *mut *mut ISymUnmanagedReader ) -> ::HRESULT, fn GetReaderFromStream( &mut self, importer: *mut ::IUnknown, pstream: *mut ::IStream, pRetVal: *mut *mut ISymUnmanagedReader ) -> ::HRESULT } ); FLAGS!{enum CorSymSearchPolicyAttributes { AllowRegistryAccess = 0x1, AllowSymbolServerAccess = 0x2, AllowOriginalPathAccess = 0x4, AllowReferencePathAccess = 0x8, }} RIDL!( interface ISymUnmanagedBinder2(ISymUnmanagedBinder2Vtbl): ISymUnmanagedBinder(ISymUnmanagedBinderVtbl) { fn GetReaderForFile2( &mut self, importer: *mut ::IUnknown, fileName: *const ::WCHAR, searchPath: *const ::WCHAR, searchPolicy: ::ULONG32, pRetVal: *mut *mut ISymUnmanagedReader ) -> ::HRESULT } ); #[derive(Clone, Copy)] pub struct ISymUnmanagedReader; deps/winapi-0.2.5/src/timezoneapi.rs0000644000000000000000000000216012613167613016124 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! ApiSet Contract for api-ms-win-core-timezone-l1 pub const TIME_ZONE_ID_INVALID: ::DWORD = 0xFFFFFFFF; STRUCT!{struct TIME_ZONE_INFORMATION { Bias: ::LONG, StandardName: [::WCHAR; 32], StandardDate: ::SYSTEMTIME, StandardBias: ::LONG, DaylightName: [::WCHAR; 32], DaylightDate: ::SYSTEMTIME, DaylightBias: ::LONG, }} pub type PTIME_ZONE_INFORMATION = *mut TIME_ZONE_INFORMATION; pub type LPTIME_ZONE_INFORMATION = *mut TIME_ZONE_INFORMATION; #[repr(C)] #[derive(Copy)] pub struct DYNAMIC_TIME_ZONE_INFORMATION { pub Bias: ::LONG, pub StandardName: [::WCHAR; 32], pub StandardDate: ::SYSTEMTIME, pub StandardBias: ::LONG, pub DaylightName: [::WCHAR; 32], pub DaylightDate: ::SYSTEMTIME, pub DaylightBias: ::LONG, pub TimeZoneKeyName: [::WCHAR; 128], pub DynamicDaylightTimeDisabled: ::BOOLEAN, } impl Clone for DYNAMIC_TIME_ZONE_INFORMATION { fn clone(&self) -> DYNAMIC_TIME_ZONE_INFORMATION { *self } } pub type PDYNAMIC_TIME_ZONE_INFORMATION = *mut DYNAMIC_TIME_ZONE_INFORMATION; deps/winapi-0.2.5/src/ncrypt.rs0000644000000000000000000000053012605021253015104 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Cryptographic API Prototypes and Definitions //191 pub type NCRYPT_HANDLE = ::ULONG_PTR; pub type NCRYPT_PROV_HANDLE = ::ULONG_PTR; pub type NCRYPT_KEY_HANDLE = ::ULONG_PTR; pub type NCRYPT_HASH_HANDLE = ::ULONG_PTR; pub type NCRYPT_SECRET_HANDLE = ::ULONG_PTR; deps/winapi-0.2.5/src/winnls.rs0000644000000000000000000001414512615662007015117 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Procedure declarations, constant definitions, and macros for the NLS component. pub const CP_ACP: ::DWORD = 0; pub const CP_OEMCP: ::DWORD = 1; pub const CP_MACCP: ::DWORD = 2; pub const CP_THREAD_ACP: ::DWORD = 3; pub const CP_SYMBOL: ::DWORD = 42; pub const CP_UTF7: ::DWORD = 65000; pub const CP_UTF8: ::DWORD = 65001; pub const MAX_LEADBYTES: usize = 12; pub const MAX_DEFAULTCHAR: usize = 2; pub type LGRPID = ::DWORD; pub type LCTYPE = ::DWORD; pub type CALTYPE = ::DWORD; pub type CALID = ::DWORD; pub type GEOID = ::LONG; pub type GEOTYPE = ::DWORD; pub type GEOCLASS = ::DWORD; STRUCT!{struct NLSVERSIONINFO { dwNLSVersionInfoSize: ::DWORD, dwNLSVersion: ::DWORD, dwDefinedVersion: ::DWORD, dwEffectiveId: ::DWORD, guidCustomVersion: ::GUID, }} pub type LPNLSVERSIONINFO = *mut NLSVERSIONINFO; STRUCT!{struct NLSVERSIONINFOEX { dwNLSVersionInfoSize: ::DWORD, dwNLSVersion: ::DWORD, dwDefinedVersion: ::DWORD, dwEffectiveId: ::DWORD, guidCustomVersion: ::GUID, }} pub type LPNLSVERSIONINFOEX = *mut NLSVERSIONINFOEX; ENUM!{enum NORM_FORM { NormalizationOther = 0, NormalizationC = 0x1, NormalizationD = 0x2, NormalizationKC = 0x5, NormalizationKD = 0x6, }} pub type LANGUAGEGROUP_ENUMPROCA = Option ::BOOL>; pub type LANGGROUPLOCALE_ENUMPROCA = Option ::BOOL>; pub type UILANGUAGE_ENUMPROCA = Option ::BOOL>; pub type CODEPAGE_ENUMPROCA = Option ::BOOL>; pub type DATEFMT_ENUMPROCA = Option ::BOOL>; pub type DATEFMT_ENUMPROCEXA = Option ::BOOL>; pub type TIMEFMT_ENUMPROCA = Option ::BOOL>; pub type CALINFO_ENUMPROCA = Option ::BOOL>; pub type CALINFO_ENUMPROCEXA = Option ::BOOL>; pub type LOCALE_ENUMPROCA = Option ::BOOL>; pub type LOCALE_ENUMPROCW = Option ::BOOL>; pub type LANGUAGEGROUP_ENUMPROCW = Option ::BOOL>; pub type LANGGROUPLOCALE_ENUMPROCW = Option ::BOOL>; pub type UILANGUAGE_ENUMPROCW = Option ::BOOL>; pub type CODEPAGE_ENUMPROCW = Option ::BOOL>; pub type DATEFMT_ENUMPROCW = Option ::BOOL>; pub type DATEFMT_ENUMPROCEXW = Option ::BOOL>; pub type TIMEFMT_ENUMPROCW = Option ::BOOL>; pub type CALINFO_ENUMPROCW = Option ::BOOL>; pub type CALINFO_ENUMPROCEXW = Option ::BOOL>; pub type GEO_ENUMPROC = Option ::BOOL>; STRUCT!{struct CPINFO { MaxCharSize: ::UINT, DefaultChar: [::BYTE; MAX_DEFAULTCHAR], LeadByte: [::BYTE; MAX_LEADBYTES], }} pub type LPCPINFO = *mut CPINFO; #[repr(C)] #[derive(Copy)] pub struct CPINFOEXA { pub MaxCharSize: ::UINT, pub DefaultChar: [::BYTE; MAX_DEFAULTCHAR], pub LeadByte: [::BYTE; MAX_LEADBYTES], pub UnicodeDefaultChar: ::WCHAR, pub CodePage: ::UINT, pub CodePageName: [::CHAR; ::MAX_PATH], } impl Clone for CPINFOEXA { fn clone(&self) -> CPINFOEXA{ *self } } pub type LPCPINFOEXA = *mut CPINFOEXA; #[repr(C)] #[derive(Copy)] pub struct CPINFOEXW { pub MaxCharSize: ::UINT, pub DefaultChar: [::BYTE; MAX_DEFAULTCHAR], pub LeadByte: [::BYTE; MAX_LEADBYTES], pub UnicodeDefaultChar: ::WCHAR, pub CodePage: ::UINT, pub CodePageName: [::WCHAR; ::MAX_PATH], } impl Clone for CPINFOEXW { fn clone(&self) -> CPINFOEXW{ *self } } pub type LPCPINFOEXW = *mut CPINFOEXW; STRUCT!{struct NUMBERFMTA { NumDigits: ::UINT, LeadingZero: ::UINT, Grouping: ::UINT, lpDecimalSep: ::LPSTR, lpThousandSep: ::LPSTR, NegativeOrder: ::UINT, }} pub type LPNUMBERFMTA = *mut NUMBERFMTA; STRUCT!{struct NUMBERFMTW { NumDigits: ::UINT, LeadingZero: ::UINT, Grouping: ::UINT, lpDecimalSep: ::LPWSTR, lpThousandSep: ::LPWSTR, NegativeOrder: ::UINT, }} pub type LPNUMBERFMTW = *mut NUMBERFMTW; STRUCT!{struct CURRENCYFMTA { NumDigits: ::UINT, LeadingZero: ::UINT, Grouping: ::UINT, lpDecimalSep: ::LPSTR, lpThousandSep: ::LPSTR, NegativeOrder: ::UINT, PositiveOrder: ::UINT, lpCurrencySymbol: ::LPSTR, }} pub type LPCURRENCYFMTA = *mut CURRENCYFMTA; STRUCT!{struct CURRENCYFMTW { NumDigits: ::UINT, LeadingZero: ::UINT, Grouping: ::UINT, lpDecimalSep: ::LPWSTR, lpThousandSep: ::LPWSTR, NegativeOrder: ::UINT, PositiveOrder: ::UINT, lpCurrencySymbol: ::LPWSTR, }} pub type LPCURRENCYFMTW = *mut CURRENCYFMTW; pub type NLS_FUNCTION = ::DWORD; STRUCT!{struct FILEMUIINFO { dwSize: ::DWORD, dwVersion: ::DWORD, dwFileType: ::DWORD, pChecksum: [::BYTE; 16], pServiceChecksum: [::BYTE; 16], dwLanguageNameOffset: ::DWORD, dwTypeIDMainSize: ::DWORD, dwTypeIDMainOffset: ::DWORD, dwTypeNameMainOffset: ::DWORD, dwTypeIDMUISize: ::DWORD, dwTypeIDMUIOffset: ::DWORD, dwTypeNameMUIOffset: ::DWORD, abBuffer: [::BYTE; 8], }} pub type PFILEMUIINFO = *mut FILEMUIINFO; pub type CALINFO_ENUMPROCEXEX = Option ::BOOL>; pub type DATEFMT_ENUMPROCEXEX = Option ::BOOL>; pub type TIMEFMT_ENUMPROCEX = Option ::BOOL>; pub type LOCALE_ENUMPROCEX = Option ::BOOL>; deps/winapi-0.2.5/src/memoryapi.rs0000644000000000000000000000152112615662007015601 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! ApiSet Contract for api-ms-win-core-memory-l1-1-0 pub const FILE_MAP_WRITE: ::DWORD = ::SECTION_MAP_WRITE; pub const FILE_MAP_READ: ::DWORD = ::SECTION_MAP_READ; pub const FILE_MAP_ALL_ACCESS: ::DWORD = ::SECTION_ALL_ACCESS; pub const FILE_MAP_EXECUTE: ::DWORD = ::SECTION_MAP_EXECUTE_EXPLICIT; pub const FILE_MAP_COPY: ::DWORD = 0x00000001; pub const FILE_MAP_RESERVE: ::DWORD = 0x80000000; ENUM!{enum MEMORY_RESOURCE_NOTIFICATION_TYPE { LowMemoryResourceNotification, HighMemoryResourceNotification, }} STRUCT!{struct WIN32_MEMORY_RANGE_ENTRY { VirtualAddress: ::PVOID, NumberOfBytes: ::SIZE_T, }} pub type PWIN32_MEMORY_RANGE_ENTRY = *mut WIN32_MEMORY_RANGE_ENTRY; pub type PBAD_MEMORY_CALLBACK_ROUTINE = Option; deps/winapi-0.2.5/src/hidclass.rs0000644000000000000000000000065712613167613015403 0ustar rootroot// Copyright © 2015, Alex Daniel Jones // Licensed under the MIT License // Taken from hidclass.h pub type PHIDP_PREPARSED_DATA = ::PVOID; STRUCT!{struct HID_COLLECTION_INFORMATION { DescriptorSize: ::ULONG, Polled: ::BOOLEAN, Reserved1: [::UCHAR; 1], VendorID: ::USHORT, ProductID: ::USHORT, VersionNumber: ::USHORT, }} pub type PHID_COLLECTION_INFORMATION = *mut HID_COLLECTION_INFORMATION; deps/winapi-0.2.5/src/subauth.rs0000644000000000000000000001730512615662007015261 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Types and macros for Subauthentication Packages. STRUCT!{struct UNICODE_STRING { Length: ::USHORT, MaximumLength: ::USHORT, Buffer: ::PWSTR, }} pub type PUNICODE_STRING = *mut UNICODE_STRING; STRUCT!{struct STRING { Length: ::USHORT, MaximumLength: ::USHORT, Buffer: ::PCHAR, }} pub type PSTRING = *mut STRING; STRUCT!{struct OLD_LARGE_INTEGER { LowPart: ::ULONG, HighPart: ::LONG, }} pub type POLD_LARGE_INTEGER = *mut OLD_LARGE_INTEGER; pub type SAM_HANDLE = ::PVOID; pub type PSAM_HANDLE = *mut ::PVOID; pub const USER_ACCOUNT_DISABLED: ::ULONG = 0x00000001; pub const USER_HOME_DIRECTORY_REQUIRED: ::ULONG = 0x00000002; pub const USER_PASSWORD_NOT_REQUIRED: ::ULONG = 0x00000004; pub const USER_TEMP_DUPLICATE_ACCOUNT: ::ULONG = 0x00000008; pub const USER_NORMAL_ACCOUNT: ::ULONG = 0x00000010; pub const USER_MNS_LOGON_ACCOUNT: ::ULONG = 0x00000020; pub const USER_INTERDOMAIN_TRUST_ACCOUNT: ::ULONG = 0x00000040; pub const USER_WORKSTATION_TRUST_ACCOUNT: ::ULONG = 0x00000080; pub const USER_SERVER_TRUST_ACCOUNT: ::ULONG = 0x00000100; pub const USER_DONT_EXPIRE_PASSWORD: ::ULONG = 0x00000200; pub const USER_ACCOUNT_AUTO_LOCKED: ::ULONG = 0x00000400; pub const USER_ENCRYPTED_TEXT_PASSWORD_ALLOWED: ::ULONG = 0x00000800; pub const USER_SMARTCARD_REQUIRED: ::ULONG = 0x00001000; pub const USER_TRUSTED_FOR_DELEGATION: ::ULONG = 0x00002000; pub const USER_NOT_DELEGATED: ::ULONG = 0x00004000; pub const USER_USE_DES_KEY_ONLY: ::ULONG = 0x00008000; pub const USER_DONT_REQUIRE_PREAUTH: ::ULONG = 0x00010000; pub const USER_PASSWORD_EXPIRED: ::ULONG = 0x00020000; pub const USER_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION: ::ULONG = 0x00040000; pub const USER_NO_AUTH_DATA_REQUIRED: ::ULONG = 0x00080000; pub const USER_PARTIAL_SECRETS_ACCOUNT: ::ULONG = 0x00100000; pub const USER_USE_AES_KEYS: ::ULONG = 0x00200000; pub const NEXT_FREE_ACCOUNT_CONTROL_BIT: ::ULONG = USER_USE_AES_KEYS << 1; pub const USER_MACHINE_ACCOUNT_MASK: ::ULONG = USER_INTERDOMAIN_TRUST_ACCOUNT | USER_WORKSTATION_TRUST_ACCOUNT | USER_SERVER_TRUST_ACCOUNT; pub const USER_ACCOUNT_TYPE_MASK: ::ULONG = USER_TEMP_DUPLICATE_ACCOUNT | USER_NORMAL_ACCOUNT | USER_MACHINE_ACCOUNT_MASK; pub const USER_COMPUTED_ACCOUNT_CONTROL_BITS: ::ULONG = USER_ACCOUNT_AUTO_LOCKED | USER_PASSWORD_EXPIRED; pub const SAM_DAYS_PER_WEEK: ::USHORT = 7; pub const SAM_HOURS_PER_WEEK: ::USHORT = 24 * SAM_DAYS_PER_WEEK; pub const SAM_MINUTES_PER_WEEK: ::USHORT = 60 * SAM_HOURS_PER_WEEK; STRUCT!{struct LOGON_HOURS { UnitsPerWeek: ::USHORT, LogonHours: ::PUCHAR, }} pub type PLOGON_HOURS = *mut LOGON_HOURS; STRUCT!{struct SR_SECURITY_DESCRIPTOR { Length: ::ULONG, SecurityDescriptor: ::PUCHAR, }} pub type PSR_SECURITY_DESCRIPTOR = *mut SR_SECURITY_DESCRIPTOR; STRUCT!{struct USER_ALL_INFORMATION { LastLogon: ::LARGE_INTEGER, LastLogoff: ::LARGE_INTEGER, PasswordLastSet: ::LARGE_INTEGER, AccountExpires: ::LARGE_INTEGER, PasswordCanChange: ::LARGE_INTEGER, PasswordMustChange: ::LARGE_INTEGER, UserName: UNICODE_STRING, FullName: UNICODE_STRING, HomeDirectory: UNICODE_STRING, HomeDirectoryDrive: UNICODE_STRING, ScriptPath: UNICODE_STRING, ProfilePath: UNICODE_STRING, AdminComment: UNICODE_STRING, WorkStations: UNICODE_STRING, UserComment: UNICODE_STRING, Parameters: UNICODE_STRING, LmPassword: UNICODE_STRING, NtPassword: UNICODE_STRING, PrivateData: UNICODE_STRING, SecurityDescriptor: SR_SECURITY_DESCRIPTOR, UserId: ::ULONG, PrimaryGroupId: ::ULONG, UserAccountControl: ::ULONG, WhichFields: ::ULONG, LogonHours: LOGON_HOURS, BadPasswordCount: ::USHORT, LogonCount: ::USHORT, CountryCode: ::USHORT, CodePage: ::USHORT, LmPasswordPresent: ::BOOLEAN, NtPasswordPresent: ::BOOLEAN, PasswordExpired: ::BOOLEAN, PrivateDataSensitive: ::BOOLEAN, }} pub type PUSER_ALL_INFORMATION = *mut USER_ALL_INFORMATION; pub const USER_ALL_PARAMETERS: ::ULONG = 0x00200000; pub const CLEAR_BLOCK_LENGTH: usize = 8; STRUCT!{struct CLEAR_BLOCK { data: [::CHAR; CLEAR_BLOCK_LENGTH], }} pub type PCLEAR_BLOCK = *mut CLEAR_BLOCK; pub const CYPHER_BLOCK_LENGTH: usize = 8; STRUCT!{struct CYPHER_BLOCK { data: [::CHAR; CYPHER_BLOCK_LENGTH], }} pub type PCYPHER_BLOCK = *mut CYPHER_BLOCK; STRUCT!{struct LM_OWF_PASSWORD { data: [CYPHER_BLOCK; 2], }} pub type PLM_OWF_PASSWORD = *mut LM_OWF_PASSWORD; pub type LM_CHALLENGE = CLEAR_BLOCK; pub type PLM_CHALLENGE = *mut LM_CHALLENGE; pub type NT_OWF_PASSWORD = LM_OWF_PASSWORD; pub type PNT_OWF_PASSWORD = *mut NT_OWF_PASSWORD; pub type NT_CHALLENGE = LM_CHALLENGE; pub type PNT_CHALLENGE = *mut NT_CHALLENGE; pub const USER_SESSION_KEY_LENGTH: usize = CYPHER_BLOCK_LENGTH * 2; STRUCT!{struct USER_SESSION_KEY { data: [CYPHER_BLOCK; 2], }} pub type PUSER_SESSION_KEY = *mut USER_SESSION_KEY; ENUM!{enum NETLOGON_LOGON_INFO_CLASS { NetlogonInteractiveInformation = 1, NetlogonNetworkInformation, NetlogonServiceInformation, NetlogonGenericInformation, NetlogonInteractiveTransitiveInformation, NetlogonNetworkTransitiveInformation, NetlogonServiceTransitiveInformation, }} STRUCT!{struct NETLOGON_LOGON_IDENTITY_INFO { LogonDomainName: UNICODE_STRING, ParameterControl: ::ULONG, LogonId: OLD_LARGE_INTEGER, UserName: UNICODE_STRING, Workstation: UNICODE_STRING, }} pub type PNETLOGON_LOGON_IDENTITY_INFO = *mut NETLOGON_LOGON_IDENTITY_INFO; STRUCT!{struct NETLOGON_INTERACTIVE_INFO { Identity: NETLOGON_LOGON_IDENTITY_INFO, LmOwfPassword: LM_OWF_PASSWORD, NtOwfPassword: NT_OWF_PASSWORD, }} pub type PNETLOGON_INTERACTIVE_INFO = *mut NETLOGON_INTERACTIVE_INFO; STRUCT!{struct NETLOGON_SERVICE_INFO { Identity: NETLOGON_LOGON_IDENTITY_INFO, LmOwfPassword: LM_OWF_PASSWORD, NtOwfPassword: NT_OWF_PASSWORD, }} pub type PNETLOGON_SERVICE_INFO = *mut NETLOGON_SERVICE_INFO; STRUCT!{struct NETLOGON_NETWORK_INFO { Identity: NETLOGON_LOGON_IDENTITY_INFO, LmChallenge: LM_CHALLENGE, NtChallengeResponse: STRING, LmChallengeResponse: STRING, }} pub type PNETLOGON_NETWORK_INFO = *mut NETLOGON_NETWORK_INFO; STRUCT!{struct NETLOGON_GENERIC_INFO { Identity: NETLOGON_LOGON_IDENTITY_INFO, PackageName: UNICODE_STRING, DataLength: ::ULONG, LogonData: ::PUCHAR, }} pub type PNETLOGON_GENERIC_INFO = *mut NETLOGON_GENERIC_INFO; pub const MSV1_0_PASSTHRU: ::ULONG = 0x01; pub const MSV1_0_GUEST_LOGON: ::ULONG = 0x02; STRUCT!{struct MSV1_0_VALIDATION_INFO { LogoffTime: ::LARGE_INTEGER, KickoffTime: ::LARGE_INTEGER, LogonServer: UNICODE_STRING, LogonDomainName: UNICODE_STRING, SessionKey: USER_SESSION_KEY, Authoritative: ::BOOLEAN, UserFlags: ::ULONG, WhichFields: ::ULONG, UserId: ::ULONG, }} pub type PMSV1_0_VALIDATION_INFO = *mut MSV1_0_VALIDATION_INFO; pub const MSV1_0_VALIDATION_LOGOFF_TIME: ::ULONG = 0x00000001; pub const MSV1_0_VALIDATION_KICKOFF_TIME: ::ULONG = 0x00000002; pub const MSV1_0_VALIDATION_LOGON_SERVER: ::ULONG = 0x00000004; pub const MSV1_0_VALIDATION_LOGON_DOMAIN: ::ULONG = 0x00000008; pub const MSV1_0_VALIDATION_SESSION_KEY: ::ULONG = 0x00000010; pub const MSV1_0_VALIDATION_USER_FLAGS: ::ULONG = 0x00000020; pub const MSV1_0_VALIDATION_USER_ID: ::ULONG = 0x00000040; pub const MSV1_0_SUBAUTH_ACCOUNT_DISABLED: ::ULONG = 0x00000001; pub const MSV1_0_SUBAUTH_PASSWORD: ::ULONG = 0x00000002; pub const MSV1_0_SUBAUTH_WORKSTATIONS: ::ULONG = 0x00000004; pub const MSV1_0_SUBAUTH_LOGON_HOURS: ::ULONG = 0x00000008; pub const MSV1_0_SUBAUTH_ACCOUNT_EXPIRY: ::ULONG = 0x00000010; pub const MSV1_0_SUBAUTH_PASSWORD_EXPIRY: ::ULONG = 0x00000020; pub const MSV1_0_SUBAUTH_ACCOUNT_TYPE: ::ULONG = 0x00000040; pub const MSV1_0_SUBAUTH_LOCKOUT: ::ULONG = 0x00000080; deps/winapi-0.2.5/src/winhttp.rs0000644000000000000000000006030112615662007015275 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Windows HTTP Services API constant definitions and macros //54 pub type HINTERNET = ::LPVOID; pub type LPHINTERNET = *mut HINTERNET; pub type INTERNET_PORT = ::WORD; pub type LPINTERNET_PORT = *mut INTERNET_PORT; pub const INTERNET_DEFAULT_PORT: INTERNET_PORT = 0; pub const INTERNET_DEFAULT_HTTP_PORT: INTERNET_PORT = 80; pub const INTERNET_DEFAULT_HTTPS_PORT: INTERNET_PORT = 443; pub const WINHTTP_FLAG_ASYNC: ::DWORD = 0x10000000; pub const WINHTTP_FLAG_SECURE: ::DWORD = 0x00800000; pub const WINHTTP_FLAG_ESCAPE_PERCENT: ::DWORD = 0x00000004; pub const WINHTTP_FLAG_NULL_CODEPAGE: ::DWORD = 0x00000008; pub const WINHTTP_FLAG_BYPASS_PROXY_CACHE: ::DWORD = 0x00000100; pub const WINHTTP_FLAG_REFRESH: ::DWORD = WINHTTP_FLAG_BYPASS_PROXY_CACHE; pub const WINHTTP_FLAG_ESCAPE_DISABLE: ::DWORD = 0x00000040; pub const WINHTTP_FLAG_ESCAPE_DISABLE_QUERY: ::DWORD = 0x00000080; STRUCT!{struct WINHTTP_ASYNC_RESULT { dwResult: ::DWORD_PTR, dwError: ::DWORD, }} pub type LPWINHTTP_ASYNC_RESULT = *mut WINHTTP_ASYNC_RESULT; pub type INTERNET_SCHEME = ::c_int; pub type LPINTERNET_SCHEME = *mut ::c_int; pub const INTERNET_SCHEME_HTTP: INTERNET_SCHEME = 1; pub const INTERNET_SCHEME_HTTPS: INTERNET_SCHEME = 2; pub const INTERNET_SCHEME_FTP: INTERNET_SCHEME = 3; pub const INTERNET_SCHEME_SOCKS: INTERNET_SCHEME = 4; STRUCT!{struct URL_COMPONENTS { dwStructSize: ::DWORD, lpszScheme: ::LPWSTR, dwSchemeLength: ::DWORD, nScheme: INTERNET_SCHEME, lpszHostName: ::LPWSTR, dwHostNameLength: ::DWORD, nPort: INTERNET_PORT, lpszUserName: ::LPWSTR, dwUserNameLength: ::DWORD, lpszPassword: ::LPWSTR, dwPasswordLength: ::DWORD, lpszUrlPath: ::LPWSTR, dwUrlPathLength: ::DWORD, lpszExtraInfo: ::LPWSTR, dwExtraInfoLength: ::DWORD, }} pub type LPURL_COMPONENTS = *mut URL_COMPONENTS; pub type URL_COMPONENTSW = URL_COMPONENTS; pub type LPURL_COMPONENTSW = LPURL_COMPONENTS; STRUCT!{struct WINHTTP_PROXY_INFO { dwAccessType: ::DWORD, lpszProxy: ::LPWSTR, lpszProxyBypass: ::LPWSTR, }} pub type LPWINHTTP_PROXY_INFO = *mut WINHTTP_PROXY_INFO; pub type WINHTTP_PROXY_INFOW = WINHTTP_PROXY_INFO; pub type LPWINHTTP_PROXY_INFOW = LPWINHTTP_PROXY_INFO; STRUCT!{struct WINHTTP_AUTOPROXY_OPTIONS { dwFlags: ::DWORD, dwAutoDetectFlags: ::DWORD, lpszAutoConfigUrl: ::LPCWSTR, lpvReserved: ::LPVOID, dwReserved: ::DWORD, fAutoLogonIfChallenged: ::BOOL, }} pub const WINHTTP_AUTOPROXY_AUTO_DETECT: ::DWORD = 0x00000001; pub const WINHTTP_AUTOPROXY_CONFIG_URL: ::DWORD = 0x00000002; pub const WINHTTP_AUTOPROXY_HOST_KEEPCASE: ::DWORD = 0x00000004; pub const WINHTTP_AUTOPROXY_HOST_LOWERCASE: ::DWORD = 0x00000008; pub const WINHTTP_AUTOPROXY_RUN_INPROCESS: ::DWORD = 0x00010000; pub const WINHTTP_AUTOPROXY_RUN_OUTPROCESS_ONLY: ::DWORD = 0x00020000; pub const WINHTTP_AUTOPROXY_NO_DIRECTACCESS: ::DWORD = 0x00040000; pub const WINHTTP_AUTOPROXY_NO_CACHE_CLIENT: ::DWORD = 0x00080000; pub const WINHTTP_AUTOPROXY_NO_CACHE_SVC: ::DWORD = 0x00100000; pub const WINHTTP_AUTOPROXY_SORT_RESULTS: ::DWORD = 0x00400000; pub const WINHTTP_AUTO_DETECT_TYPE_DHCP: ::DWORD = 0x00000001; pub const WINHTTP_AUTO_DETECT_TYPE_DNS_A: ::DWORD = 0x00000002; STRUCT!{struct WINHTTP_PROXY_RESULT_ENTRY { fProxy: ::BOOL, fBypass: ::BOOL, ProxyScheme: INTERNET_SCHEME, pwszProxy: ::PWSTR, ProxyPort: INTERNET_PORT, }} STRUCT!{struct WINHTTP_PROXY_RESULT { cEntries: ::DWORD, pEntries: *mut WINHTTP_PROXY_RESULT_ENTRY, }} pub const WINHTTP_FIRST_OPTION: ::DWORD = WINHTTP_OPTION_CALLBACK; pub const WINHTTP_OPTION_CALLBACK: ::DWORD = 1; pub const WINHTTP_OPTION_RESOLVE_TIMEOUT: ::DWORD = 2; pub const WINHTTP_OPTION_CONNECT_TIMEOUT: ::DWORD = 3; pub const WINHTTP_OPTION_CONNECT_RETRIES: ::DWORD = 4; pub const WINHTTP_OPTION_SEND_TIMEOUT: ::DWORD = 5; pub const WINHTTP_OPTION_RECEIVE_TIMEOUT: ::DWORD = 6; pub const WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT: ::DWORD = 7; pub const WINHTTP_OPTION_HANDLE_TYPE: ::DWORD = 9; pub const WINHTTP_OPTION_READ_BUFFER_SIZE: ::DWORD = 12; pub const WINHTTP_OPTION_WRITE_BUFFER_SIZE: ::DWORD = 13; pub const WINHTTP_OPTION_PARENT_HANDLE: ::DWORD = 21; pub const WINHTTP_OPTION_EXTENDED_ERROR: ::DWORD = 24; pub const WINHTTP_OPTION_SECURITY_FLAGS: ::DWORD = 31; pub const WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT: ::DWORD = 32; pub const WINHTTP_OPTION_URL: ::DWORD = 34; pub const WINHTTP_OPTION_SECURITY_KEY_BITNESS: ::DWORD = 36; pub const WINHTTP_OPTION_PROXY: ::DWORD = 38; pub const WINHTTP_OPTION_PROXY_RESULT_ENTRY: ::DWORD = 39; pub const WINHTTP_OPTION_USER_AGENT: ::DWORD = 41; pub const WINHTTP_OPTION_CONTEXT_VALUE: ::DWORD = 45; pub const WINHTTP_OPTION_CLIENT_CERT_CONTEXT: ::DWORD = 47; pub const WINHTTP_OPTION_REQUEST_PRIORITY: ::DWORD = 58; pub const WINHTTP_OPTION_HTTP_VERSION: ::DWORD = 59; pub const WINHTTP_OPTION_DISABLE_FEATURE: ::DWORD = 63; pub const WINHTTP_OPTION_CODEPAGE: ::DWORD = 68; pub const WINHTTP_OPTION_MAX_CONNS_PER_SERVER: ::DWORD = 73; pub const WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER: ::DWORD = 74; pub const WINHTTP_OPTION_AUTOLOGON_POLICY: ::DWORD = 77; pub const WINHTTP_OPTION_SERVER_CERT_CONTEXT: ::DWORD = 78; pub const WINHTTP_OPTION_ENABLE_FEATURE: ::DWORD = 79; pub const WINHTTP_OPTION_WORKER_THREAD_COUNT: ::DWORD = 80; pub const WINHTTP_OPTION_PASSPORT_COBRANDING_TEXT: ::DWORD = 81; pub const WINHTTP_OPTION_PASSPORT_COBRANDING_URL: ::DWORD = 82; pub const WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH: ::DWORD = 83; pub const WINHTTP_OPTION_SECURE_PROTOCOLS: ::DWORD = 84; pub const WINHTTP_OPTION_ENABLETRACING: ::DWORD = 85; pub const WINHTTP_OPTION_PASSPORT_SIGN_OUT: ::DWORD = 86; pub const WINHTTP_OPTION_PASSPORT_RETURN_URL: ::DWORD = 87; pub const WINHTTP_OPTION_REDIRECT_POLICY: ::DWORD = 88; pub const WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS: ::DWORD = 89; pub const WINHTTP_OPTION_MAX_HTTP_STATUS_CONTINUE: ::DWORD = 90; pub const WINHTTP_OPTION_MAX_RESPONSE_HEADER_SIZE: ::DWORD = 91; pub const WINHTTP_OPTION_MAX_RESPONSE_DRAIN_SIZE: ::DWORD = 92; pub const WINHTTP_OPTION_CONNECTION_INFO: ::DWORD = 93; pub const WINHTTP_OPTION_CLIENT_CERT_ISSUER_LIST: ::DWORD = 94; pub const WINHTTP_OPTION_SPN: ::DWORD = 96; pub const WINHTTP_OPTION_GLOBAL_PROXY_CREDS: ::DWORD = 97; pub const WINHTTP_OPTION_GLOBAL_SERVER_CREDS: ::DWORD = 98; pub const WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT: ::DWORD = 99; pub const WINHTTP_OPTION_REJECT_USERPWD_IN_URL: ::DWORD = 100; pub const WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS: ::DWORD = 101; pub const WINHTTP_OPTION_RECEIVE_PROXY_CONNECT_RESPONSE: ::DWORD = 103; pub const WINHTTP_OPTION_IS_PROXY_CONNECT_RESPONSE: ::DWORD = 104; pub const WINHTTP_OPTION_SERVER_SPN_USED: ::DWORD = 106; pub const WINHTTP_OPTION_PROXY_SPN_USED: ::DWORD = 107; pub const WINHTTP_OPTION_SERVER_CBT: ::DWORD = 108; pub const WINHTTP_OPTION_UNSAFE_HEADER_PARSING: ::DWORD = 110; pub const WINHTTP_OPTION_ASSURED_NON_BLOCKING_CALLBACKS: ::DWORD = 111; pub const WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET: ::DWORD = 114; pub const WINHTTP_OPTION_WEB_SOCKET_CLOSE_TIMEOUT: ::DWORD = 115; pub const WINHTTP_OPTION_WEB_SOCKET_KEEPALIVE_INTERVAL: ::DWORD = 116; pub const WINHTTP_OPTION_DECOMPRESSION: ::DWORD = 118; pub const WINHTTP_OPTION_WEB_SOCKET_RECEIVE_BUFFER_SIZE: ::DWORD = 122; pub const WINHTTP_OPTION_WEB_SOCKET_SEND_BUFFER_SIZE: ::DWORD = 123; pub const WINHTTP_LAST_OPTION: ::DWORD = WINHTTP_OPTION_WEB_SOCKET_SEND_BUFFER_SIZE; pub const WINHTTP_OPTION_USERNAME: ::DWORD = 0x1000; pub const WINHTTP_OPTION_PASSWORD: ::DWORD = 0x1001; pub const WINHTTP_OPTION_PROXY_USERNAME: ::DWORD = 0x1002; pub const WINHTTP_OPTION_PROXY_PASSWORD: ::DWORD = 0x1003; //552 pub type WINHTTP_STATUS_CALLBACK = Option; pub type LPWINHTTP_STATUS_CALLBACK = *mut WINHTTP_STATUS_CALLBACK; pub const WINHTTP_CALLBACK_STATUS_RESOLVING_NAME: ::DWORD = 0x00000001; pub const WINHTTP_CALLBACK_STATUS_NAME_RESOLVED: ::DWORD = 0x00000002; pub const WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER: ::DWORD = 0x00000004; pub const WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER: ::DWORD = 0x00000008; pub const WINHTTP_CALLBACK_STATUS_SENDING_REQUEST: ::DWORD = 0x00000010; pub const WINHTTP_CALLBACK_STATUS_REQUEST_SENT: ::DWORD = 0x00000020; pub const WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE: ::DWORD = 0x00000040; pub const WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED: ::DWORD = 0x00000080; pub const WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION: ::DWORD = 0x00000100; pub const WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED: ::DWORD = 0x00000200; pub const WINHTTP_CALLBACK_STATUS_HANDLE_CREATED: ::DWORD = 0x00000400; pub const WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING: ::DWORD = 0x00000800; pub const WINHTTP_CALLBACK_STATUS_DETECTING_PROXY: ::DWORD = 0x00001000; pub const WINHTTP_CALLBACK_STATUS_REDIRECT: ::DWORD = 0x00004000; pub const WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE: ::DWORD = 0x00008000; pub const WINHTTP_CALLBACK_STATUS_SECURE_FAILURE: ::DWORD = 0x00010000; pub const WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE: ::DWORD = 0x00020000; pub const WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE: ::DWORD = 0x00040000; pub const WINHTTP_CALLBACK_STATUS_READ_COMPLETE: ::DWORD = 0x00080000; pub const WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE: ::DWORD = 0x00100000; pub const WINHTTP_CALLBACK_STATUS_REQUEST_ERROR: ::DWORD = 0x00200000; pub const WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE: ::DWORD = 0x00400000; pub const WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE: ::DWORD = 0x01000000; pub const WINHTTP_CALLBACK_STATUS_CLOSE_COMPLETE: ::DWORD = 0x02000000; pub const WINHTTP_CALLBACK_STATUS_SHUTDOWN_COMPLETE: ::DWORD = 0x04000000; pub const WINHTTP_CALLBACK_FLAG_RESOLVE_NAME: ::DWORD = WINHTTP_CALLBACK_STATUS_RESOLVING_NAME | WINHTTP_CALLBACK_STATUS_NAME_RESOLVED; pub const WINHTTP_CALLBACK_FLAG_CONNECT_TO_SERVER: ::DWORD = WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER | WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER; pub const WINHTTP_CALLBACK_FLAG_SEND_REQUEST: ::DWORD = WINHTTP_CALLBACK_STATUS_SENDING_REQUEST | WINHTTP_CALLBACK_STATUS_REQUEST_SENT; pub const WINHTTP_CALLBACK_FLAG_RECEIVE_RESPONSE: ::DWORD = WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE | WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED; pub const WINHTTP_CALLBACK_FLAG_CLOSE_CONNECTION: ::DWORD = WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION | WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED; pub const WINHTTP_CALLBACK_FLAG_HANDLES: ::DWORD = WINHTTP_CALLBACK_STATUS_HANDLE_CREATED | WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING; pub const WINHTTP_CALLBACK_FLAG_DETECTING_PROXY: ::DWORD = WINHTTP_CALLBACK_STATUS_DETECTING_PROXY; pub const WINHTTP_CALLBACK_FLAG_REDIRECT: ::DWORD = WINHTTP_CALLBACK_STATUS_REDIRECT; pub const WINHTTP_CALLBACK_FLAG_INTERMEDIATE_RESPONSE: ::DWORD = WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE; pub const WINHTTP_CALLBACK_FLAG_SECURE_FAILURE: ::DWORD = WINHTTP_CALLBACK_STATUS_SECURE_FAILURE; pub const WINHTTP_CALLBACK_FLAG_SENDREQUEST_COMPLETE: ::DWORD = WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE; pub const WINHTTP_CALLBACK_FLAG_HEADERS_AVAILABLE: ::DWORD = WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE; pub const WINHTTP_CALLBACK_FLAG_DATA_AVAILABLE: ::DWORD = WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE; pub const WINHTTP_CALLBACK_FLAG_READ_COMPLETE: ::DWORD = WINHTTP_CALLBACK_STATUS_READ_COMPLETE; pub const WINHTTP_CALLBACK_FLAG_WRITE_COMPLETE: ::DWORD = WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE; pub const WINHTTP_CALLBACK_FLAG_REQUEST_ERROR: ::DWORD = WINHTTP_CALLBACK_STATUS_REQUEST_ERROR; pub const WINHTTP_CALLBACK_FLAG_GETPROXYFORURL_COMPLETE: ::DWORD = WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE; pub const WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS: ::DWORD = WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE | WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE | WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE | WINHTTP_CALLBACK_STATUS_READ_COMPLETE | WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE | WINHTTP_CALLBACK_STATUS_REQUEST_ERROR | WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE; pub const WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS: ::DWORD = 0xffffffff; pub const WINHTTP_QUERY_MIME_VERSION: ::DWORD = 0; pub const WINHTTP_QUERY_CONTENT_TYPE: ::DWORD = 1; pub const WINHTTP_QUERY_CONTENT_TRANSFER_ENCODING: ::DWORD = 2; pub const WINHTTP_QUERY_CONTENT_ID: ::DWORD = 3; pub const WINHTTP_QUERY_CONTENT_DESCRIPTION: ::DWORD = 4; pub const WINHTTP_QUERY_CONTENT_LENGTH: ::DWORD = 5; pub const WINHTTP_QUERY_CONTENT_LANGUAGE: ::DWORD = 6; pub const WINHTTP_QUERY_ALLOW: ::DWORD = 7; pub const WINHTTP_QUERY_PUBLIC: ::DWORD = 8; pub const WINHTTP_QUERY_DATE: ::DWORD = 9; pub const WINHTTP_QUERY_EXPIRES: ::DWORD = 10; pub const WINHTTP_QUERY_LAST_MODIFIED: ::DWORD = 11; pub const WINHTTP_QUERY_MESSAGE_ID: ::DWORD = 12; pub const WINHTTP_QUERY_URI: ::DWORD = 13; pub const WINHTTP_QUERY_DERIVED_FROM: ::DWORD = 14; pub const WINHTTP_QUERY_COST: ::DWORD = 15; pub const WINHTTP_QUERY_LINK: ::DWORD = 16; pub const WINHTTP_QUERY_PRAGMA: ::DWORD = 17; pub const WINHTTP_QUERY_VERSION: ::DWORD = 18; pub const WINHTTP_QUERY_STATUS_CODE: ::DWORD = 19; pub const WINHTTP_QUERY_STATUS_TEXT: ::DWORD = 20; pub const WINHTTP_QUERY_RAW_HEADERS: ::DWORD = 21; pub const WINHTTP_QUERY_RAW_HEADERS_CRLF: ::DWORD = 22; pub const WINHTTP_QUERY_CONNECTION: ::DWORD = 23; pub const WINHTTP_QUERY_ACCEPT: ::DWORD = 24; pub const WINHTTP_QUERY_ACCEPT_CHARSET: ::DWORD = 25; pub const WINHTTP_QUERY_ACCEPT_ENCODING: ::DWORD = 26; pub const WINHTTP_QUERY_ACCEPT_LANGUAGE: ::DWORD = 27; pub const WINHTTP_QUERY_AUTHORIZATION: ::DWORD = 28; pub const WINHTTP_QUERY_CONTENT_ENCODING: ::DWORD = 29; pub const WINHTTP_QUERY_FORWARDED: ::DWORD = 30; pub const WINHTTP_QUERY_FROM: ::DWORD = 31; pub const WINHTTP_QUERY_IF_MODIFIED_SINCE: ::DWORD = 32; pub const WINHTTP_QUERY_LOCATION: ::DWORD = 33; pub const WINHTTP_QUERY_ORIG_URI: ::DWORD = 34; pub const WINHTTP_QUERY_REFERER: ::DWORD = 35; pub const WINHTTP_QUERY_RETRY_AFTER: ::DWORD = 36; pub const WINHTTP_QUERY_SERVER: ::DWORD = 37; pub const WINHTTP_QUERY_TITLE: ::DWORD = 38; pub const WINHTTP_QUERY_USER_AGENT: ::DWORD = 39; pub const WINHTTP_QUERY_WWW_AUTHENTICATE: ::DWORD = 40; pub const WINHTTP_QUERY_PROXY_AUTHENTICATE: ::DWORD = 41; pub const WINHTTP_QUERY_ACCEPT_RANGES: ::DWORD = 42; pub const WINHTTP_QUERY_SET_COOKIE: ::DWORD = 43; pub const WINHTTP_QUERY_COOKIE: ::DWORD = 44; pub const WINHTTP_QUERY_REQUEST_METHOD: ::DWORD = 45; pub const WINHTTP_QUERY_REFRESH: ::DWORD = 46; pub const WINHTTP_QUERY_CONTENT_DISPOSITION: ::DWORD = 47; pub const WINHTTP_QUERY_AGE: ::DWORD = 48; pub const WINHTTP_QUERY_CACHE_CONTROL: ::DWORD = 49; pub const WINHTTP_QUERY_CONTENT_BASE: ::DWORD = 50; pub const WINHTTP_QUERY_CONTENT_LOCATION: ::DWORD = 51; pub const WINHTTP_QUERY_CONTENT_MD5: ::DWORD = 52; pub const WINHTTP_QUERY_CONTENT_RANGE: ::DWORD = 53; pub const WINHTTP_QUERY_ETAG: ::DWORD = 54; pub const WINHTTP_QUERY_HOST: ::DWORD = 55; pub const WINHTTP_QUERY_IF_MATCH: ::DWORD = 56; pub const WINHTTP_QUERY_IF_NONE_MATCH: ::DWORD = 57; pub const WINHTTP_QUERY_IF_RANGE: ::DWORD = 58; pub const WINHTTP_QUERY_IF_UNMODIFIED_SINCE: ::DWORD = 59; pub const WINHTTP_QUERY_MAX_FORWARDS: ::DWORD = 60; pub const WINHTTP_QUERY_PROXY_AUTHORIZATION: ::DWORD = 61; pub const WINHTTP_QUERY_RANGE: ::DWORD = 62; pub const WINHTTP_QUERY_TRANSFER_ENCODING: ::DWORD = 63; pub const WINHTTP_QUERY_UPGRADE: ::DWORD = 64; pub const WINHTTP_QUERY_VARY: ::DWORD = 65; pub const WINHTTP_QUERY_VIA: ::DWORD = 66; pub const WINHTTP_QUERY_WARNING: ::DWORD = 67; pub const WINHTTP_QUERY_EXPECT: ::DWORD = 68; pub const WINHTTP_QUERY_PROXY_CONNECTION: ::DWORD = 69; pub const WINHTTP_QUERY_UNLESS_MODIFIED_SINCE: ::DWORD = 70; pub const WINHTTP_QUERY_PROXY_SUPPORT: ::DWORD = 75; pub const WINHTTP_QUERY_AUTHENTICATION_INFO: ::DWORD = 76; pub const WINHTTP_QUERY_PASSPORT_URLS: ::DWORD = 77; pub const WINHTTP_QUERY_PASSPORT_CONFIG: ::DWORD = 78; pub const WINHTTP_QUERY_MAX: ::DWORD = 78; pub const WINHTTP_QUERY_CUSTOM: ::DWORD = 65535; pub const WINHTTP_QUERY_FLAG_REQUEST_HEADERS: ::DWORD = 0x80000000; pub const WINHTTP_QUERY_FLAG_SYSTEMTIME: ::DWORD = 0x40000000; pub const WINHTTP_QUERY_FLAG_NUMBER: ::DWORD = 0x20000000; pub const HTTP_STATUS_CONTINUE: ::DWORD = 100; pub const HTTP_STATUS_SWITCH_PROTOCOLS: ::DWORD = 101; pub const HTTP_STATUS_OK: ::DWORD = 200; pub const HTTP_STATUS_CREATED: ::DWORD = 201; pub const HTTP_STATUS_ACCEPTED: ::DWORD = 202; pub const HTTP_STATUS_PARTIAL: ::DWORD = 203; pub const HTTP_STATUS_NO_CONTENT: ::DWORD = 204; pub const HTTP_STATUS_RESET_CONTENT: ::DWORD = 205; pub const HTTP_STATUS_PARTIAL_CONTENT: ::DWORD = 206; pub const HTTP_STATUS_WEBDAV_MULTI_STATUS: ::DWORD = 207; pub const HTTP_STATUS_AMBIGUOUS: ::DWORD = 300; pub const HTTP_STATUS_MOVED: ::DWORD = 301; pub const HTTP_STATUS_REDIRECT: ::DWORD = 302; pub const HTTP_STATUS_REDIRECT_METHOD: ::DWORD = 303; pub const HTTP_STATUS_NOT_MODIFIED: ::DWORD = 304; pub const HTTP_STATUS_USE_PROXY: ::DWORD = 305; pub const HTTP_STATUS_REDIRECT_KEEP_VERB: ::DWORD = 307; pub const HTTP_STATUS_BAD_REQUEST: ::DWORD = 400; pub const HTTP_STATUS_DENIED: ::DWORD = 401; pub const HTTP_STATUS_PAYMENT_REQ: ::DWORD = 402; pub const HTTP_STATUS_FORBIDDEN: ::DWORD = 403; pub const HTTP_STATUS_NOT_FOUND: ::DWORD = 404; pub const HTTP_STATUS_BAD_METHOD: ::DWORD = 405; pub const HTTP_STATUS_NONE_ACCEPTABLE: ::DWORD = 406; pub const HTTP_STATUS_PROXY_AUTH_REQ: ::DWORD = 407; pub const HTTP_STATUS_REQUEST_TIMEOUT: ::DWORD = 408; pub const HTTP_STATUS_CONFLICT: ::DWORD = 409; pub const HTTP_STATUS_GONE: ::DWORD = 410; pub const HTTP_STATUS_LENGTH_REQUIRED: ::DWORD = 411; pub const HTTP_STATUS_PRECOND_FAILED: ::DWORD = 412; pub const HTTP_STATUS_REQUEST_TOO_LARGE: ::DWORD = 413; pub const HTTP_STATUS_URI_TOO_LONG: ::DWORD = 414; pub const HTTP_STATUS_UNSUPPORTED_MEDIA: ::DWORD = 415; pub const HTTP_STATUS_RETRY_WITH: ::DWORD = 449; pub const HTTP_STATUS_SERVER_ERROR: ::DWORD = 500; pub const HTTP_STATUS_NOT_SUPPORTED: ::DWORD = 501; pub const HTTP_STATUS_BAD_GATEWAY: ::DWORD = 502; pub const HTTP_STATUS_SERVICE_UNAVAIL: ::DWORD = 503; pub const HTTP_STATUS_GATEWAY_TIMEOUT: ::DWORD = 504; pub const HTTP_STATUS_VERSION_NOT_SUP: ::DWORD = 505; pub const HTTP_STATUS_FIRST: ::DWORD = HTTP_STATUS_CONTINUE; pub const HTTP_STATUS_LAST: ::DWORD = HTTP_STATUS_VERSION_NOT_SUP; pub const WINHTTP_ACCESS_TYPE_DEFAULT_PROXY: ::DWORD = 0; pub const WINHTTP_ACCESS_TYPE_NO_PROXY: ::DWORD = 1; pub const WINHTTP_ACCESS_TYPE_NAMED_PROXY: ::DWORD = 3; pub const WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY: ::DWORD = 4; pub const WINHTTP_ERROR_BASE: ::DWORD = 12000; pub const ERROR_WINHTTP_OUT_OF_HANDLES: ::DWORD = WINHTTP_ERROR_BASE + 1; pub const ERROR_WINHTTP_TIMEOUT: ::DWORD = WINHTTP_ERROR_BASE + 2; pub const ERROR_WINHTTP_INTERNAL_ERROR: ::DWORD = WINHTTP_ERROR_BASE + 4; pub const ERROR_WINHTTP_INVALID_URL: ::DWORD = WINHTTP_ERROR_BASE + 5; pub const ERROR_WINHTTP_UNRECOGNIZED_SCHEME: ::DWORD = WINHTTP_ERROR_BASE + 6; pub const ERROR_WINHTTP_NAME_NOT_RESOLVED: ::DWORD = WINHTTP_ERROR_BASE + 7; pub const ERROR_WINHTTP_INVALID_OPTION: ::DWORD = WINHTTP_ERROR_BASE + 9; pub const ERROR_WINHTTP_OPTION_NOT_SETTABLE: ::DWORD = WINHTTP_ERROR_BASE + 11; pub const ERROR_WINHTTP_SHUTDOWN: ::DWORD = WINHTTP_ERROR_BASE + 12; pub const ERROR_WINHTTP_LOGIN_FAILURE: ::DWORD = WINHTTP_ERROR_BASE + 15; pub const ERROR_WINHTTP_OPERATION_CANCELLED: ::DWORD = WINHTTP_ERROR_BASE + 17; pub const ERROR_WINHTTP_INCORRECT_HANDLE_TYPE: ::DWORD = WINHTTP_ERROR_BASE + 18; pub const ERROR_WINHTTP_INCORRECT_HANDLE_STATE: ::DWORD = WINHTTP_ERROR_BASE + 19; pub const ERROR_WINHTTP_CANNOT_CONNECT: ::DWORD = WINHTTP_ERROR_BASE + 29; pub const ERROR_WINHTTP_CONNECTION_ERROR: ::DWORD = WINHTTP_ERROR_BASE + 30; pub const ERROR_WINHTTP_RESEND_REQUEST: ::DWORD = WINHTTP_ERROR_BASE + 32; pub const ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED: ::DWORD = WINHTTP_ERROR_BASE + 44; pub const ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN: ::DWORD = WINHTTP_ERROR_BASE + 100; pub const ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND: ::DWORD = WINHTTP_ERROR_BASE + 101; pub const ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND: ::DWORD = WINHTTP_ERROR_BASE + 102; pub const ERROR_WINHTTP_CANNOT_CALL_AFTER_OPEN: ::DWORD = WINHTTP_ERROR_BASE + 103; pub const ERROR_WINHTTP_HEADER_NOT_FOUND: ::DWORD = WINHTTP_ERROR_BASE + 150; pub const ERROR_WINHTTP_INVALID_SERVER_RESPONSE: ::DWORD = WINHTTP_ERROR_BASE + 152; pub const ERROR_WINHTTP_INVALID_HEADER: ::DWORD = WINHTTP_ERROR_BASE + 153; pub const ERROR_WINHTTP_INVALID_QUERY_REQUEST: ::DWORD = WINHTTP_ERROR_BASE + 154; pub const ERROR_WINHTTP_HEADER_ALREADY_EXISTS: ::DWORD = WINHTTP_ERROR_BASE + 155; pub const ERROR_WINHTTP_REDIRECT_FAILED: ::DWORD = WINHTTP_ERROR_BASE + 156; pub const ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR: ::DWORD = WINHTTP_ERROR_BASE + 178; pub const ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT: ::DWORD = WINHTTP_ERROR_BASE + 166; pub const ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT: ::DWORD = WINHTTP_ERROR_BASE + 167; pub const ERROR_WINHTTP_UNHANDLED_SCRIPT_TYPE: ::DWORD = WINHTTP_ERROR_BASE + 176; pub const ERROR_WINHTTP_SCRIPT_EXECUTION_ERROR: ::DWORD = WINHTTP_ERROR_BASE + 177; pub const ERROR_WINHTTP_NOT_INITIALIZED: ::DWORD = WINHTTP_ERROR_BASE + 172; pub const ERROR_WINHTTP_SECURE_FAILURE: ::DWORD = WINHTTP_ERROR_BASE + 175; pub const ERROR_WINHTTP_SECURE_CERT_DATE_INVALID: ::DWORD = WINHTTP_ERROR_BASE + 37; pub const ERROR_WINHTTP_SECURE_CERT_CN_INVALID: ::DWORD = WINHTTP_ERROR_BASE + 38; pub const ERROR_WINHTTP_SECURE_INVALID_CA: ::DWORD = WINHTTP_ERROR_BASE + 45; pub const ERROR_WINHTTP_SECURE_CERT_REV_FAILED: ::DWORD = WINHTTP_ERROR_BASE + 57; pub const ERROR_WINHTTP_SECURE_CHANNEL_ERROR: ::DWORD = WINHTTP_ERROR_BASE + 157; pub const ERROR_WINHTTP_SECURE_INVALID_CERT: ::DWORD = WINHTTP_ERROR_BASE + 169; pub const ERROR_WINHTTP_SECURE_CERT_REVOKED: ::DWORD = WINHTTP_ERROR_BASE + 170; pub const ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE: ::DWORD = WINHTTP_ERROR_BASE + 179; pub const ERROR_WINHTTP_AUTODETECTION_FAILED: ::DWORD = WINHTTP_ERROR_BASE + 180; pub const ERROR_WINHTTP_HEADER_COUNT_EXCEEDED: ::DWORD = WINHTTP_ERROR_BASE + 181; pub const ERROR_WINHTTP_HEADER_SIZE_OVERFLOW: ::DWORD = WINHTTP_ERROR_BASE + 182; pub const ERROR_WINHTTP_CHUNKED_ENCODING_HEADER_SIZE_OVERFLOW: ::DWORD = WINHTTP_ERROR_BASE + 183; pub const ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW: ::DWORD = WINHTTP_ERROR_BASE + 184; pub const ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY: ::DWORD = WINHTTP_ERROR_BASE + 185; pub const ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY: ::DWORD = WINHTTP_ERROR_BASE + 186; pub const WINHTTP_ERROR_LAST: ::DWORD = WINHTTP_ERROR_BASE + 186; pub const WINHTTP_RESET_STATE: ::DWORD = 0x00000001; pub const WINHTTP_RESET_SWPAD_CURRENT_NETWORK: ::DWORD = 0x00000002; pub const WINHTTP_RESET_SWPAD_ALL: ::DWORD = 0x00000004; pub const WINHTTP_RESET_SCRIPT_CACHE: ::DWORD = 0x00000008; pub const WINHTTP_RESET_ALL: ::DWORD = 0x0000FFFF; pub const WINHTTP_RESET_NOTIFY_NETWORK_CHANGED: ::DWORD = 0x00010000; pub const WINHTTP_RESET_OUT_OF_PROC: ::DWORD = 0x00020000; STRUCT!{struct WINHTTP_CURRENT_USER_IE_PROXY_CONFIG { fAutoDetect: ::BOOL, lpszAutoConfigUrl: ::LPWSTR, lpszProxy: ::LPWSTR, lpszProxyBypass: ::LPWSTR, }} //1370 ENUM!{enum WINHTTP_WEB_SOCKET_OPERATION { WINHTTP_WEB_SOCKET_SEND_OPERATION = 0, WINHTTP_WEB_SOCKET_RECEIVE_OPERATION = 1, WINHTTP_WEB_SOCKET_CLOSE_OPERATION = 2, WINHTTP_WEB_SOCKET_SHUTDOWN_OPERATION = 3, }} ENUM!{enum WINHTTP_WEB_SOCKET_BUFFER_TYPE { WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE = 0, WINHTTP_WEB_SOCKET_BINARY_FRAGMENT_BUFFER_TYPE = 1, WINHTTP_WEB_SOCKET_UTF8_MESSAGE_BUFFER_TYPE = 2, WINHTTP_WEB_SOCKET_UTF8_FRAGMENT_BUFFER_TYPE = 3, WINHTTP_WEB_SOCKET_CLOSE_BUFFER_TYPE = 4, }} ENUM!{enum WINHTTP_WEB_SOCKET_CLOSE_STATUS { WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS = 1000, WINHTTP_WEB_SOCKET_ENDPOINT_TERMINATED_CLOSE_STATUS = 1001, WINHTTP_WEB_SOCKET_PROTOCOL_ERROR_CLOSE_STATUS = 1002, WINHTTP_WEB_SOCKET_INVALID_DATA_TYPE_CLOSE_STATUS = 1003, WINHTTP_WEB_SOCKET_EMPTY_CLOSE_STATUS = 1005, WINHTTP_WEB_SOCKET_ABORTED_CLOSE_STATUS = 1006, WINHTTP_WEB_SOCKET_INVALID_PAYLOAD_CLOSE_STATUS = 1007, WINHTTP_WEB_SOCKET_POLICY_VIOLATION_CLOSE_STATUS = 1008, WINHTTP_WEB_SOCKET_MESSAGE_TOO_BIG_CLOSE_STATUS = 1009, WINHTTP_WEB_SOCKET_UNSUPPORTED_EXTENSIONS_CLOSE_STATUS = 1010, WINHTTP_WEB_SOCKET_SERVER_ERROR_CLOSE_STATUS = 1011, WINHTTP_WEB_SOCKET_SECURE_HANDSHAKE_ERROR_CLOSE_STATUS = 1015, }} deps/winapi-0.2.5/src/spapidef.rs0000644000000000000000000000421212605021352015361 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Windows NT Setup and Device Installer services pub type SP_LOG_TOKEN = ::DWORDLONG; pub type PSP_LOG_TOKEN = *mut ::DWORDLONG; pub const LOGTOKEN_TYPE_MASK: SP_LOG_TOKEN = 3; pub const LOGTOKEN_UNSPECIFIED: SP_LOG_TOKEN = 0; pub const LOGTOKEN_NO_LOG: SP_LOG_TOKEN = 1; pub const LOGTOKEN_SETUPAPI_APPLOG: SP_LOG_TOKEN = 2; pub const LOGTOKEN_SETUPAPI_DEVLOG: SP_LOG_TOKEN = 3; pub const TXTLOG_SETUPAPI_DEVLOG: ::DWORD = 0x00000001; pub const TXTLOG_SETUPAPI_CMDLINE: ::DWORD = 0x00000002; pub const TXTLOG_SETUPAPI_BITS: ::DWORD = 0x00000003; pub const TXTLOG_ERROR: ::DWORD = 0x1; pub const TXTLOG_WARNING: ::DWORD = 0x2; pub const TXTLOG_SYSTEM_STATE_CHANGE: ::DWORD = 0x3; pub const TXTLOG_SUMMARY: ::DWORD = 0x4; pub const TXTLOG_DETAILS: ::DWORD = 0x5; pub const TXTLOG_VERBOSE: ::DWORD = 0x6; pub const TXTLOG_VERY_VERBOSE: ::DWORD = 0x7; pub const TXTLOG_RESERVED_FLAGS: ::DWORD = 0x0000FFF0; pub const TXTLOG_TIMESTAMP: ::DWORD = 0x00010000; pub const TXTLOG_DEPTH_INCR: ::DWORD = 0x00020000; pub const TXTLOG_DEPTH_DECR: ::DWORD = 0x00040000; pub const TXTLOG_TAB_1: ::DWORD = 0x00080000; pub const TXTLOG_FLUSH_FILE: ::DWORD = 0x00100000; #[inline] #[allow(dead_code)] pub fn TXTLOG_LEVEL(flags: ::DWORD) -> ::DWORD { return flags & 0xf; } pub const TXTLOG_DEVINST: ::DWORD = 0x00000001; pub const TXTLOG_INF: ::DWORD = 0x00000002; pub const TXTLOG_FILEQ: ::DWORD = 0x00000004; pub const TXTLOG_COPYFILES: ::DWORD = 0x00000008; pub const TXTLOG_SIGVERIF: ::DWORD = 0x00000020; pub const TXTLOG_BACKUP: ::DWORD = 0x00000080; pub const TXTLOG_UI: ::DWORD = 0x00000100; pub const TXTLOG_UTIL: ::DWORD = 0x00000200; pub const TXTLOG_INFDB: ::DWORD = 0x00000400; pub const TXTLOG_POLICY: ::DWORD = 0x00800000; pub const TXTLOG_NEWDEV: ::DWORD = 0x01000000; pub const TXTLOG_UMPNPMGR: ::DWORD = 0x02000000; pub const TXTLOG_DRIVER_STORE: ::DWORD = 0x04000000; pub const TXTLOG_SETUP: ::DWORD = 0x08000000; pub const TXTLOG_CMI: ::DWORD = 0x10000000; pub const TXTLOG_DEVMGR: ::DWORD = 0x20000000; pub const TXTLOG_INSTALLER: ::DWORD = 0x40000000; pub const TXTLOG_VENDOR: ::DWORD = 0x80000000; deps/winapi-0.2.5/src/basetsd.rs0000644000000000000000000000617012605021252015217 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Type definitions for the basic sized types. #[cfg(target_arch = "x86")] pub type POINTER_64_INT = ::c_ulong; #[cfg(target_arch = "x86_64")] pub type POINTER_64_INT = ::__uint64; pub type INT8 = ::c_schar; pub type PINT8 = *mut ::c_schar; pub type INT16 = ::c_short; pub type PINT16 = *mut ::c_short; pub type INT32 = ::c_int; pub type PINT32 = *mut ::c_int; pub type INT64 = ::__int64; pub type PINT64 = *mut ::__int64; pub type UINT8 = ::c_uchar; pub type PUINT8 = *mut ::c_uchar; pub type UINT16 = ::c_ushort; pub type PUINT16 = *mut ::c_ushort; pub type UINT32 = ::c_uint; pub type PUINT32 = *mut ::c_uint; pub type UINT64 = ::__uint64; pub type PUINT64 = *mut ::__uint64; pub type LONG32 = ::c_int; pub type PLONG32 = *mut ::c_int; pub type ULONG32 = ::c_uint; pub type PULONG32 = *mut ::c_uint; pub type DWORD32 = ::c_uint; pub type PDWORD32 = *mut ::c_uint; #[cfg(target_arch = "x86")] pub type INT_PTR = ::c_int; #[cfg(target_arch = "x86_64")] pub type INT_PTR = ::__int64; #[cfg(target_arch = "x86")] pub type PINT_PTR = *mut ::c_int; #[cfg(target_arch = "x86_64")] pub type PINT_PTR = *mut ::__int64; #[cfg(target_arch = "x86")] pub type UINT_PTR = ::c_uint; #[cfg(target_arch = "x86_64")] pub type UINT_PTR = ::__uint64; #[cfg(target_arch = "x86")] pub type PUINT_PTR = *mut ::c_uint; #[cfg(target_arch = "x86_64")] pub type PUINT_PTR = *mut ::__uint64; #[cfg(target_arch = "x86")] pub type LONG_PTR = ::c_long; #[cfg(target_arch = "x86_64")] pub type LONG_PTR = ::__int64; #[cfg(target_arch = "x86")] pub type PLONG_PTR = *mut ::c_long; #[cfg(target_arch = "x86_64")] pub type PLONG_PTR = *mut ::__int64; #[cfg(target_arch = "x86")] pub type ULONG_PTR = ::c_ulong; #[cfg(target_arch = "x86_64")] pub type ULONG_PTR = ::__uint64; #[cfg(target_arch = "x86")] pub type PULONG_PTR = *mut ::c_ulong; #[cfg(target_arch = "x86_64")] pub type PULONG_PTR = *mut ::__uint64; #[cfg(target_arch = "x86_64")] pub type SHANDLE_PTR = ::__int64; #[cfg(target_arch = "x86_64")] pub type HANDLE_PTR = ::__uint64; #[cfg(target_arch = "x86_64")] pub type UHALF_PTR = ::c_uint; #[cfg(target_arch = "x86_64")] pub type PUHALF_PTR = *mut ::c_uint; #[cfg(target_arch = "x86_64")] pub type HALF_PTR = ::c_int; #[cfg(target_arch = "x86_64")] pub type PHALF_PTR = *mut ::c_int; #[cfg(target_arch = "x86")] pub type SHANDLE_PTR = ::c_long; #[cfg(target_arch = "x86")] pub type HANDLE_PTR = ::c_ulong; #[cfg(target_arch = "x86")] pub type UHALF_PTR = ::c_ushort; #[cfg(target_arch = "x86")] pub type PUHALF_PTR = *mut ::c_ushort; #[cfg(target_arch = "x86")] pub type HALF_PTR = ::c_short; #[cfg(target_arch = "x86")] pub type PHALF_PTR = *mut ::c_short; pub type SIZE_T = ULONG_PTR; pub type PSIZE_T = *mut ULONG_PTR; pub type SSIZE_T = LONG_PTR; pub type PSSIZE_T = *mut LONG_PTR; pub type DWORD_PTR = ULONG_PTR; pub type PDWORD_PTR = *mut ULONG_PTR; pub type LONG64 = ::__int64; pub type PLONG64 = *mut ::__int64; pub type ULONG64 = ::__uint64; pub type PULONG64 = *mut ::__uint64; pub type DWORD64 = ::__uint64; pub type PDWORD64 = *mut ::__uint64; pub type KAFFINITY = ULONG_PTR; pub type PKAFFINITY = *mut KAFFINITY; deps/winapi-0.2.5/src/mmreg.rs0000644000000000000000000003646312612764151014723 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License pub const WAVE_FORMAT_UNKNOWN: ::WORD = 0x0000; pub const WAVE_FORMAT_PCM: ::WORD = 0x0001; pub const WAVE_FORMAT_ADPCM: ::WORD = 0x0002; pub const WAVE_FORMAT_IEEE_FLOAT: ::WORD = 0x0003; pub const WAVE_FORMAT_VSELP: ::WORD = 0x0004; pub const WAVE_FORMAT_IBM_CVSD: ::WORD = 0x0005; pub const WAVE_FORMAT_ALAW: ::WORD = 0x0006; pub const WAVE_FORMAT_MULAW: ::WORD = 0x0007; pub const WAVE_FORMAT_DTS: ::WORD = 0x0008; pub const WAVE_FORMAT_DRM: ::WORD = 0x0009; pub const WAVE_FORMAT_WMAVOICE9: ::WORD = 0x000A; pub const WAVE_FORMAT_WMAVOICE10: ::WORD = 0x000B; pub const WAVE_FORMAT_OKI_ADPCM: ::WORD = 0x0010; pub const WAVE_FORMAT_DVI_ADPCM: ::WORD = 0x0011; pub const WAVE_FORMAT_IMA_ADPCM: ::WORD = WAVE_FORMAT_DVI_ADPCM; pub const WAVE_FORMAT_MEDIASPACE_ADPCM: ::WORD = 0x0012; pub const WAVE_FORMAT_SIERRA_ADPCM: ::WORD = 0x0013; pub const WAVE_FORMAT_G723_ADPCM: ::WORD = 0x0014; pub const WAVE_FORMAT_DIGISTD: ::WORD = 0x0015; pub const WAVE_FORMAT_DIGIFIX: ::WORD = 0x0016; pub const WAVE_FORMAT_DIALOGIC_OKI_ADPCM: ::WORD = 0x0017; pub const WAVE_FORMAT_MEDIAVISION_ADPCM: ::WORD = 0x0018; pub const WAVE_FORMAT_CU_CODEC: ::WORD = 0x0019; pub const WAVE_FORMAT_HP_DYN_VOICE: ::WORD = 0x001A; pub const WAVE_FORMAT_YAMAHA_ADPCM: ::WORD = 0x0020; pub const WAVE_FORMAT_SONARC: ::WORD = 0x0021; pub const WAVE_FORMAT_DSPGROUP_TRUESPEECH: ::WORD = 0x0022; pub const WAVE_FORMAT_ECHOSC1: ::WORD = 0x0023; pub const WAVE_FORMAT_AUDIOFILE_AF36: ::WORD = 0x0024; pub const WAVE_FORMAT_APTX: ::WORD = 0x0025; pub const WAVE_FORMAT_AUDIOFILE_AF10: ::WORD = 0x0026; pub const WAVE_FORMAT_PROSODY_1612: ::WORD = 0x0027; pub const WAVE_FORMAT_LRC: ::WORD = 0x0028; pub const WAVE_FORMAT_DOLBY_AC2: ::WORD = 0x0030; pub const WAVE_FORMAT_GSM610: ::WORD = 0x0031; pub const WAVE_FORMAT_MSNAUDIO: ::WORD = 0x0032; pub const WAVE_FORMAT_ANTEX_ADPCME: ::WORD = 0x0033; pub const WAVE_FORMAT_CONTROL_RES_VQLPC: ::WORD = 0x0034; pub const WAVE_FORMAT_DIGIREAL: ::WORD = 0x0035; pub const WAVE_FORMAT_DIGIADPCM: ::WORD = 0x0036; pub const WAVE_FORMAT_CONTROL_RES_CR10: ::WORD = 0x0037; pub const WAVE_FORMAT_NMS_VBXADPCM: ::WORD = 0x0038; pub const WAVE_FORMAT_CS_IMAADPCM: ::WORD = 0x0039; pub const WAVE_FORMAT_ECHOSC3: ::WORD = 0x003A; pub const WAVE_FORMAT_ROCKWELL_ADPCM: ::WORD = 0x003B; pub const WAVE_FORMAT_ROCKWELL_DIGITALK: ::WORD = 0x003C; pub const WAVE_FORMAT_XEBEC: ::WORD = 0x003D; pub const WAVE_FORMAT_G721_ADPCM: ::WORD = 0x0040; pub const WAVE_FORMAT_G728_CELP: ::WORD = 0x0041; pub const WAVE_FORMAT_MSG723: ::WORD = 0x0042; pub const WAVE_FORMAT_INTEL_G723_1: ::WORD = 0x0043; pub const WAVE_FORMAT_INTEL_G729: ::WORD = 0x0044; pub const WAVE_FORMAT_SHARP_G726: ::WORD = 0x0045; pub const WAVE_FORMAT_MPEG: ::WORD = 0x0050; pub const WAVE_FORMAT_RT24: ::WORD = 0x0052; pub const WAVE_FORMAT_PAC: ::WORD = 0x0053; pub const WAVE_FORMAT_MPEGLAYER3: ::WORD = 0x0055; pub const WAVE_FORMAT_LUCENT_G723: ::WORD = 0x0059; pub const WAVE_FORMAT_CIRRUS: ::WORD = 0x0060; pub const WAVE_FORMAT_ESPCM: ::WORD = 0x0061; pub const WAVE_FORMAT_VOXWARE: ::WORD = 0x0062; pub const WAVE_FORMAT_CANOPUS_ATRAC: ::WORD = 0x0063; pub const WAVE_FORMAT_G726_ADPCM: ::WORD = 0x0064; pub const WAVE_FORMAT_G722_ADPCM: ::WORD = 0x0065; pub const WAVE_FORMAT_DSAT: ::WORD = 0x0066; pub const WAVE_FORMAT_DSAT_DISPLAY: ::WORD = 0x0067; pub const WAVE_FORMAT_VOXWARE_BYTE_ALIGNED: ::WORD = 0x0069; pub const WAVE_FORMAT_VOXWARE_AC8: ::WORD = 0x0070; pub const WAVE_FORMAT_VOXWARE_AC10: ::WORD = 0x0071; pub const WAVE_FORMAT_VOXWARE_AC16: ::WORD = 0x0072; pub const WAVE_FORMAT_VOXWARE_AC20: ::WORD = 0x0073; pub const WAVE_FORMAT_VOXWARE_RT24: ::WORD = 0x0074; pub const WAVE_FORMAT_VOXWARE_RT29: ::WORD = 0x0075; pub const WAVE_FORMAT_VOXWARE_RT29HW: ::WORD = 0x0076; pub const WAVE_FORMAT_VOXWARE_VR12: ::WORD = 0x0077; pub const WAVE_FORMAT_VOXWARE_VR18: ::WORD = 0x0078; pub const WAVE_FORMAT_VOXWARE_TQ40: ::WORD = 0x0079; pub const WAVE_FORMAT_VOXWARE_SC3: ::WORD = 0x007A; pub const WAVE_FORMAT_VOXWARE_SC3_1: ::WORD = 0x007B; pub const WAVE_FORMAT_SOFTSOUND: ::WORD = 0x0080; pub const WAVE_FORMAT_VOXWARE_TQ60: ::WORD = 0x0081; pub const WAVE_FORMAT_MSRT24: ::WORD = 0x0082; pub const WAVE_FORMAT_G729A: ::WORD = 0x0083; pub const WAVE_FORMAT_MVI_MVI2: ::WORD = 0x0084; pub const WAVE_FORMAT_DF_G726: ::WORD = 0x0085; pub const WAVE_FORMAT_DF_GSM610: ::WORD = 0x0086; pub const WAVE_FORMAT_ISIAUDIO: ::WORD = 0x0088; pub const WAVE_FORMAT_ONLIVE: ::WORD = 0x0089; pub const WAVE_FORMAT_MULTITUDE_FT_SX20: ::WORD = 0x008A; pub const WAVE_FORMAT_INFOCOM_ITS_G721_ADPCM: ::WORD = 0x008B; pub const WAVE_FORMAT_CONVEDIA_G729: ::WORD = 0x008C; pub const WAVE_FORMAT_CONGRUENCY: ::WORD = 0x008D; pub const WAVE_FORMAT_SBC24: ::WORD = 0x0091; pub const WAVE_FORMAT_DOLBY_AC3_SPDIF: ::WORD = 0x0092; pub const WAVE_FORMAT_MEDIASONIC_G723: ::WORD = 0x0093; pub const WAVE_FORMAT_PROSODY_8KBPS: ::WORD = 0x0094; pub const WAVE_FORMAT_ZYXEL_ADPCM: ::WORD = 0x0097; pub const WAVE_FORMAT_PHILIPS_LPCBB: ::WORD = 0x0098; pub const WAVE_FORMAT_PACKED: ::WORD = 0x0099; pub const WAVE_FORMAT_MALDEN_PHONYTALK: ::WORD = 0x00A0; pub const WAVE_FORMAT_RACAL_RECORDER_GSM: ::WORD = 0x00A1; pub const WAVE_FORMAT_RACAL_RECORDER_G720_A: ::WORD = 0x00A2; pub const WAVE_FORMAT_RACAL_RECORDER_G723_1: ::WORD = 0x00A3; pub const WAVE_FORMAT_RACAL_RECORDER_TETRA_ACELP: ::WORD = 0x00A4; pub const WAVE_FORMAT_NEC_AAC: ::WORD = 0x00B0; pub const WAVE_FORMAT_RAW_AAC1: ::WORD = 0x00FF; pub const WAVE_FORMAT_RHETOREX_ADPCM: ::WORD = 0x0100; pub const WAVE_FORMAT_IRAT: ::WORD = 0x0101; pub const WAVE_FORMAT_VIVO_G723: ::WORD = 0x0111; pub const WAVE_FORMAT_VIVO_SIREN: ::WORD = 0x0112; pub const WAVE_FORMAT_PHILIPS_CELP: ::WORD = 0x0120; pub const WAVE_FORMAT_PHILIPS_GRUNDIG: ::WORD = 0x0121; pub const WAVE_FORMAT_DIGITAL_G723: ::WORD = 0x0123; pub const WAVE_FORMAT_SANYO_LD_ADPCM: ::WORD = 0x0125; pub const WAVE_FORMAT_SIPROLAB_ACEPLNET: ::WORD = 0x0130; pub const WAVE_FORMAT_SIPROLAB_ACELP4800: ::WORD = 0x0131; pub const WAVE_FORMAT_SIPROLAB_ACELP8V3: ::WORD = 0x0132; pub const WAVE_FORMAT_SIPROLAB_G729: ::WORD = 0x0133; pub const WAVE_FORMAT_SIPROLAB_G729A: ::WORD = 0x0134; pub const WAVE_FORMAT_SIPROLAB_KELVIN: ::WORD = 0x0135; pub const WAVE_FORMAT_VOICEAGE_AMR: ::WORD = 0x0136; pub const WAVE_FORMAT_G726ADPCM: ::WORD = 0x0140; pub const WAVE_FORMAT_DICTAPHONE_CELP68: ::WORD = 0x0141; pub const WAVE_FORMAT_DICTAPHONE_CELP54: ::WORD = 0x0142; pub const WAVE_FORMAT_QUALCOMM_PUREVOICE: ::WORD = 0x0150; pub const WAVE_FORMAT_QUALCOMM_HALFRATE: ::WORD = 0x0151; pub const WAVE_FORMAT_TUBGSM: ::WORD = 0x0155; pub const WAVE_FORMAT_MSAUDIO1: ::WORD = 0x0160; pub const WAVE_FORMAT_WMAUDIO2: ::WORD = 0x0161; pub const WAVE_FORMAT_WMAUDIO3: ::WORD = 0x0162; pub const WAVE_FORMAT_WMAUDIO_LOSSLESS: ::WORD = 0x0163; pub const WAVE_FORMAT_WMASPDIF: ::WORD = 0x0164; pub const WAVE_FORMAT_UNISYS_NAP_ADPCM: ::WORD = 0x0170; pub const WAVE_FORMAT_UNISYS_NAP_ULAW: ::WORD = 0x0171; pub const WAVE_FORMAT_UNISYS_NAP_ALAW: ::WORD = 0x0172; pub const WAVE_FORMAT_UNISYS_NAP_16K: ::WORD = 0x0173; pub const WAVE_FORMAT_SYCOM_ACM_SYC008: ::WORD = 0x0174; pub const WAVE_FORMAT_SYCOM_ACM_SYC701_G726L: ::WORD = 0x0175; pub const WAVE_FORMAT_SYCOM_ACM_SYC701_CELP54: ::WORD = 0x0176; pub const WAVE_FORMAT_SYCOM_ACM_SYC701_CELP68: ::WORD = 0x0177; pub const WAVE_FORMAT_KNOWLEDGE_ADVENTURE_ADPCM: ::WORD = 0x0178; pub const WAVE_FORMAT_FRAUNHOFER_IIS_MPEG2_AAC: ::WORD = 0x0180; pub const WAVE_FORMAT_DTS_DS: ::WORD = 0x0190; pub const WAVE_FORMAT_CREATIVE_ADPCM: ::WORD = 0x0200; pub const WAVE_FORMAT_CREATIVE_FASTSPEECH8: ::WORD = 0x0202; pub const WAVE_FORMAT_CREATIVE_FASTSPEECH10: ::WORD = 0x0203; pub const WAVE_FORMAT_UHER_ADPCM: ::WORD = 0x0210; pub const WAVE_FORMAT_ULEAD_DV_AUDIO: ::WORD = 0x0215; pub const WAVE_FORMAT_ULEAD_DV_AUDIO_1: ::WORD = 0x0216; pub const WAVE_FORMAT_QUARTERDECK: ::WORD = 0x0220; pub const WAVE_FORMAT_ILINK_VC: ::WORD = 0x0230; pub const WAVE_FORMAT_RAW_SPORT: ::WORD = 0x0240; pub const WAVE_FORMAT_ESST_AC3: ::WORD = 0x0241; pub const WAVE_FORMAT_GENERIC_PASSTHRU: ::WORD = 0x0249; pub const WAVE_FORMAT_IPI_HSX: ::WORD = 0x0250; pub const WAVE_FORMAT_IPI_RPELP: ::WORD = 0x0251; pub const WAVE_FORMAT_CS2: ::WORD = 0x0260; pub const WAVE_FORMAT_SONY_SCX: ::WORD = 0x0270; pub const WAVE_FORMAT_SONY_SCY: ::WORD = 0x0271; pub const WAVE_FORMAT_SONY_ATRAC3: ::WORD = 0x0272; pub const WAVE_FORMAT_SONY_SPC: ::WORD = 0x0273; pub const WAVE_FORMAT_TELUM_AUDIO: ::WORD = 0x0280; pub const WAVE_FORMAT_TELUM_IA_AUDIO: ::WORD = 0x0281; pub const WAVE_FORMAT_NORCOM_VOICE_SYSTEMS_ADPCM: ::WORD = 0x0285; pub const WAVE_FORMAT_FM_TOWNS_SND: ::WORD = 0x0300; pub const WAVE_FORMAT_MICRONAS: ::WORD = 0x0350; pub const WAVE_FORMAT_MICRONAS_CELP833: ::WORD = 0x0351; pub const WAVE_FORMAT_BTV_DIGITAL: ::WORD = 0x0400; pub const WAVE_FORMAT_INTEL_MUSIC_CODER: ::WORD = 0x0401; pub const WAVE_FORMAT_INDEO_AUDIO: ::WORD = 0x0402; pub const WAVE_FORMAT_QDESIGN_MUSIC: ::WORD = 0x0450; pub const WAVE_FORMAT_ON2_VP7_AUDIO: ::WORD = 0x0500; pub const WAVE_FORMAT_ON2_VP6_AUDIO: ::WORD = 0x0501; pub const WAVE_FORMAT_VME_VMPCM: ::WORD = 0x0680; pub const WAVE_FORMAT_TPC: ::WORD = 0x0681; pub const WAVE_FORMAT_LIGHTWAVE_LOSSLESS: ::WORD = 0x08AE; pub const WAVE_FORMAT_OLIGSM: ::WORD = 0x1000; pub const WAVE_FORMAT_OLIADPCM: ::WORD = 0x1001; pub const WAVE_FORMAT_OLICELP: ::WORD = 0x1002; pub const WAVE_FORMAT_OLISBC: ::WORD = 0x1003; pub const WAVE_FORMAT_OLIOPR: ::WORD = 0x1004; pub const WAVE_FORMAT_LH_CODEC: ::WORD = 0x1100; pub const WAVE_FORMAT_LH_CODEC_CELP: ::WORD = 0x1101; pub const WAVE_FORMAT_LH_CODEC_SBC8: ::WORD = 0x1102; pub const WAVE_FORMAT_LH_CODEC_SBC12: ::WORD = 0x1103; pub const WAVE_FORMAT_LH_CODEC_SBC16: ::WORD = 0x1104; pub const WAVE_FORMAT_NORRIS: ::WORD = 0x1400; pub const WAVE_FORMAT_ISIAUDIO_2: ::WORD = 0x1401; pub const WAVE_FORMAT_SOUNDSPACE_MUSICOMPRESS: ::WORD = 0x1500; pub const WAVE_FORMAT_MPEG_ADTS_AAC: ::WORD = 0x1600; pub const WAVE_FORMAT_MPEG_RAW_AAC: ::WORD = 0x1601; pub const WAVE_FORMAT_MPEG_LOAS: ::WORD = 0x1602; pub const WAVE_FORMAT_NOKIA_MPEG_ADTS_AAC: ::WORD = 0x1608; pub const WAVE_FORMAT_NOKIA_MPEG_RAW_AAC: ::WORD = 0x1609; pub const WAVE_FORMAT_VODAFONE_MPEG_ADTS_AAC: ::WORD = 0x160A; pub const WAVE_FORMAT_VODAFONE_MPEG_RAW_AAC: ::WORD = 0x160B; pub const WAVE_FORMAT_MPEG_HEAAC: ::WORD = 0x1610; pub const WAVE_FORMAT_VOXWARE_RT24_SPEECH: ::WORD = 0x181C; pub const WAVE_FORMAT_SONICFOUNDRY_LOSSLESS: ::WORD = 0x1971; pub const WAVE_FORMAT_INNINGS_TELECOM_ADPCM: ::WORD = 0x1979; pub const WAVE_FORMAT_LUCENT_SX8300P: ::WORD = 0x1C07; pub const WAVE_FORMAT_LUCENT_SX5363S: ::WORD = 0x1C0C; pub const WAVE_FORMAT_CUSEEME: ::WORD = 0x1F03; pub const WAVE_FORMAT_NTCSOFT_ALF2CM_ACM: ::WORD = 0x1FC4; pub const WAVE_FORMAT_DVM: ::WORD = 0x2000; pub const WAVE_FORMAT_DTS2: ::WORD = 0x2001; pub const WAVE_FORMAT_MAKEAVIS: ::WORD = 0x3313; pub const WAVE_FORMAT_DIVIO_MPEG4_AAC: ::WORD = 0x4143; pub const WAVE_FORMAT_NOKIA_ADAPTIVE_MULTIRATE: ::WORD = 0x4201; pub const WAVE_FORMAT_DIVIO_G726: ::WORD = 0x4243; pub const WAVE_FORMAT_LEAD_SPEECH: ::WORD = 0x434C; pub const WAVE_FORMAT_LEAD_VORBIS: ::WORD = 0x564C; pub const WAVE_FORMAT_WAVPACK_AUDIO: ::WORD = 0x5756; pub const WAVE_FORMAT_OGG_VORBIS_MODE_1: ::WORD = 0x674F; pub const WAVE_FORMAT_OGG_VORBIS_MODE_2: ::WORD = 0x6750; pub const WAVE_FORMAT_OGG_VORBIS_MODE_3: ::WORD = 0x6751; pub const WAVE_FORMAT_OGG_VORBIS_MODE_1_PLUS: ::WORD = 0x676F; pub const WAVE_FORMAT_OGG_VORBIS_MODE_2_PLUS: ::WORD = 0x6770; pub const WAVE_FORMAT_OGG_VORBIS_MODE_3_PLUS: ::WORD = 0x6771; pub const WAVE_FORMAT_3COM_NBX: ::WORD = 0x7000; pub const WAVE_FORMAT_FAAD_AAC: ::WORD = 0x706D; pub const WAVE_FORMAT_AMR_NB: ::WORD = 0x7361; pub const WAVE_FORMAT_AMR_WB: ::WORD = 0x7362; pub const WAVE_FORMAT_AMR_WP: ::WORD = 0x7363; pub const WAVE_FORMAT_GSM_AMR_CBR: ::WORD = 0x7A21; pub const WAVE_FORMAT_GSM_AMR_VBR_SID: ::WORD = 0x7A22; pub const WAVE_FORMAT_COMVERSE_INFOSYS_G723_1: ::WORD = 0xA100; pub const WAVE_FORMAT_COMVERSE_INFOSYS_AVQSBC: ::WORD = 0xA101; pub const WAVE_FORMAT_COMVERSE_INFOSYS_SBC: ::WORD = 0xA102; pub const WAVE_FORMAT_SYMBOL_G729_A: ::WORD = 0xA103; pub const WAVE_FORMAT_VOICEAGE_AMR_WB: ::WORD = 0xA104; pub const WAVE_FORMAT_INGENIENT_G726: ::WORD = 0xA105; pub const WAVE_FORMAT_MPEG4_AAC: ::WORD = 0xA106; pub const WAVE_FORMAT_ENCORE_G726: ::WORD = 0xA107; pub const WAVE_FORMAT_ZOLL_ASAO: ::WORD = 0xA108; pub const WAVE_FORMAT_SPEEX_VOICE: ::WORD = 0xA109; pub const WAVE_FORMAT_VIANIX_MASC: ::WORD = 0xA10A; pub const WAVE_FORMAT_WM9_SPECTRUM_ANALYZER: ::WORD = 0xA10B; pub const WAVE_FORMAT_WMF_SPECTRUM_ANAYZER: ::WORD = 0xA10C; pub const WAVE_FORMAT_GSM_610: ::WORD = 0xA10D; pub const WAVE_FORMAT_GSM_620: ::WORD = 0xA10E; pub const WAVE_FORMAT_GSM_660: ::WORD = 0xA10F; pub const WAVE_FORMAT_GSM_690: ::WORD = 0xA110; pub const WAVE_FORMAT_GSM_ADAPTIVE_MULTIRATE_WB: ::WORD = 0xA111; pub const WAVE_FORMAT_POLYCOM_G722: ::WORD = 0xA112; pub const WAVE_FORMAT_POLYCOM_G728: ::WORD = 0xA113; pub const WAVE_FORMAT_POLYCOM_G729_A: ::WORD = 0xA114; pub const WAVE_FORMAT_POLYCOM_SIREN: ::WORD = 0xA115; pub const WAVE_FORMAT_GLOBAL_IP_ILBC: ::WORD = 0xA116; pub const WAVE_FORMAT_RADIOTIME_TIME_SHIFT_RADIO: ::WORD = 0xA117; pub const WAVE_FORMAT_NICE_ACA: ::WORD = 0xA118; pub const WAVE_FORMAT_NICE_ADPCM: ::WORD = 0xA119; pub const WAVE_FORMAT_VOCORD_G721: ::WORD = 0xA11A; pub const WAVE_FORMAT_VOCORD_G726: ::WORD = 0xA11B; pub const WAVE_FORMAT_VOCORD_G722_1: ::WORD = 0xA11C; pub const WAVE_FORMAT_VOCORD_G728: ::WORD = 0xA11D; pub const WAVE_FORMAT_VOCORD_G729: ::WORD = 0xA11E; pub const WAVE_FORMAT_VOCORD_G729_A: ::WORD = 0xA11F; pub const WAVE_FORMAT_VOCORD_G723_1: ::WORD = 0xA120; pub const WAVE_FORMAT_VOCORD_LBC: ::WORD = 0xA121; pub const WAVE_FORMAT_NICE_G728: ::WORD = 0xA122; pub const WAVE_FORMAT_FRACE_TELECOM_G729: ::WORD = 0xA123; pub const WAVE_FORMAT_CODIAN: ::WORD = 0xA124; pub const WAVE_FORMAT_FLAC: ::WORD = 0xF1AC; pub const WAVE_FORMAT_EXTENSIBLE: ::WORD = 0xFFFE; pub const WAVE_FORMAT_DEVELOPMENT: ::WORD = 0xFFFF; //2557 pub const SPEAKER_FRONT_LEFT: ::DWORD = 0x1; pub const SPEAKER_FRONT_RIGHT: ::DWORD = 0x2; pub const SPEAKER_FRONT_CENTER: ::DWORD = 0x4; pub const SPEAKER_LOW_FREQUENCY: ::DWORD = 0x8; pub const SPEAKER_BACK_LEFT: ::DWORD = 0x10; pub const SPEAKER_BACK_RIGHT: ::DWORD = 0x20; pub const SPEAKER_FRONT_LEFT_OF_CENTER: ::DWORD = 0x40; pub const SPEAKER_FRONT_RIGHT_OF_CENTER: ::DWORD = 0x80; pub const SPEAKER_BACK_CENTER: ::DWORD = 0x100; pub const SPEAKER_SIDE_LEFT: ::DWORD = 0x200; pub const SPEAKER_SIDE_RIGHT: ::DWORD = 0x400; pub const SPEAKER_TOP_CENTER: ::DWORD = 0x800; pub const SPEAKER_TOP_FRONT_LEFT: ::DWORD = 0x1000; pub const SPEAKER_TOP_FRONT_CENTER: ::DWORD = 0x2000; pub const SPEAKER_TOP_FRONT_RIGHT: ::DWORD = 0x4000; pub const SPEAKER_TOP_BACK_LEFT: ::DWORD = 0x8000; pub const SPEAKER_TOP_BACK_CENTER: ::DWORD = 0x10000; pub const SPEAKER_TOP_BACK_RIGHT: ::DWORD = 0x20000; pub const SPEAKER_RESERVED: ::DWORD = 0x7FFC0000; pub const SPEAKER_ALL: ::DWORD = 0x80000000; #[repr(C, packed)] #[derive(Clone, Copy, Debug)] pub struct WAVEFORMATEX { pub wFormatTag: ::WORD, pub nChannels: ::WORD, pub nSamplesPerSec: ::DWORD, pub nAvgBytesPerSec: ::DWORD, pub nBlockAlign: ::WORD, pub wBitsPerSample: ::WORD, pub cbSize: ::WORD, } #[repr(C, packed)] #[derive(Clone, Copy, Debug)] pub struct WAVEFORMATEXTENSIBLE { pub Format: ::WAVEFORMATEX, pub Samples: ::WORD, pub dwChannelMask: ::DWORD, pub SubFormat: ::GUID, } deps/winapi-0.2.5/src/d3d9caps.rs0000644000000000000000000004342612613167613015224 0ustar rootroot// Copyright © 2015, Corey Richardson // Licensed under the MIT License //! Direct3D capabilities include file STRUCT!{struct D3DVSHADERCAPS2_0 { Caps: ::DWORD, DynamicFlowControlDepth: ::INT, NumTemps: ::INT, StaticFlowControlDepth: ::INT, }} pub const D3DVS20CAPS_PREDICATION: ::DWORD = 1 << 0; pub const D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH: ::DWORD = 24; pub const D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH: ::DWORD = 0; pub const D3DVS20_MAX_NUMTEMPS: ::DWORD = 32; pub const D3DVS20_MIN_NUMTEMPS: ::DWORD = 12; pub const D3DVS20_MAX_STATICFLOWCONTROLDEPTH: ::DWORD = 4; pub const D3DVS20_MIN_STATICFLOWCONTROLDEPTH: ::DWORD = 1; STRUCT!{struct D3DPSHADERCAPS2_0 { Caps: ::DWORD, DynamicFlowControlDepth: ::INT, NumTemps: ::INT, StaticFlowControlDepth: ::INT, NumInstructionSlots: ::INT, }} pub const D3DPS20CAPS_ARBITRARYSWIZZLE: ::DWORD = 1 << 0; pub const D3DPS20CAPS_GRADIENTINSTRUCTIONS: ::DWORD = 1 << 1; pub const D3DPS20CAPS_PREDICATION: ::DWORD = 1 << 2; pub const D3DPS20CAPS_NODEPENDENTREADLIMIT: ::DWORD = 1 << 3; pub const D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT: ::DWORD = 1 << 4; pub const D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH: ::DWORD = 24; pub const D3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH: ::DWORD = 0; pub const D3DPS20_MAX_NUMTEMPS: ::DWORD = 32; pub const D3DPS20_MIN_NUMTEMPS: ::DWORD = 12; pub const D3DPS20_MAX_STATICFLOWCONTROLDEPTH: ::DWORD = 4; pub const D3DPS20_MIN_STATICFLOWCONTROLDEPTH: ::DWORD = 0; pub const D3DPS20_MAX_NUMINSTRUCTIONSLOTS: ::DWORD = 512; pub const D3DPS20_MIN_NUMINSTRUCTIONSLOTS: ::DWORD = 96; pub const D3DMIN30SHADERINSTRUCTIONS: ::DWORD = 512; pub const D3DMAX30SHADERINSTRUCTIONS: ::DWORD = 32768; STRUCT!{struct D3DOVERLAYCAPS { Caps: ::UINT, MaxOverlayDisplayWidth: ::UINT, MaxOverlayDisplayHeight: ::UINT, }} pub const D3DOVERLAYCAPS_FULLRANGERGB: ::DWORD = 0x00000001; pub const D3DOVERLAYCAPS_LIMITEDRANGERGB: ::DWORD = 0x00000002; pub const D3DOVERLAYCAPS_YCbCr_BT601: ::DWORD = 0x00000004; pub const D3DOVERLAYCAPS_YCbCr_BT709: ::DWORD = 0x00000008; pub const D3DOVERLAYCAPS_YCbCr_BT601_xvYCC: ::DWORD = 0x00000010; pub const D3DOVERLAYCAPS_YCbCr_BT709_xvYCC: ::DWORD = 0x00000020; pub const D3DOVERLAYCAPS_STRETCHX: ::DWORD = 0x00000040; pub const D3DOVERLAYCAPS_STRETCHY: ::DWORD = 0x00000080; STRUCT!{struct D3DCONTENTPROTECTIONCAPS { Caps: ::DWORD, KeyExchangeType: ::GUID, BufferAlignmentStart: ::UINT, BlockAlignmentSize: ::UINT, ProtectedMemorySize: ::ULONGLONG, }} pub const D3DCPCAPS_SOFTWARE: ::DWORD = 0x00000001; pub const D3DCPCAPS_HARDWARE: ::DWORD = 0x00000002; pub const D3DCPCAPS_PROTECTIONALWAYSON: ::DWORD = 0x00000004; pub const D3DCPCAPS_PARTIALDECRYPTION: ::DWORD = 0x00000008; pub const D3DCPCAPS_CONTENTKEY: ::DWORD = 0x00000010; pub const D3DCPCAPS_FRESHENSESSIONKEY: ::DWORD = 0x00000020; pub const D3DCPCAPS_ENCRYPTEDREADBACK: ::DWORD = 0x00000040; pub const D3DCPCAPS_ENCRYPTEDREADBACKKEY: ::DWORD = 0x00000080; pub const D3DCPCAPS_SEQUENTIAL_CTR_IV: ::DWORD = 0x00000100; pub const D3DCPCAPS_ENCRYPTSLICEDATAONLY: ::DWORD = 0x00000200; DEFINE_GUID!(D3DCRYPTOTYPE_AES128_CTR, 0x9b6bd711, 0x4f74, 0x41c9, 0x9e, 0x7b, 0xb, 0xe2, 0xd7, 0xd9, 0x3b, 0x4f); DEFINE_GUID!(D3DCRYPTOTYPE_PROPRIETARY, 0xab4e9afd, 0x1d1c, 0x46e6, 0xa7, 0x2f, 0x8, 0x69, 0x91, 0x7b, 0xd, 0xe8); DEFINE_GUID!(D3DKEYEXCHANGE_RSAES_OAEP, 0xc1949895, 0xd72a, 0x4a1d, 0x8e, 0x5d, 0xed, 0x85, 0x7d, 0x17, 0x15, 0x20); DEFINE_GUID!(D3DKEYEXCHANGE_DXVA, 0x43d3775c, 0x38e5, 0x4924, 0x8d, 0x86, 0xd3, 0xfc, 0xcf, 0x15, 0x3e, 0x9b); STRUCT!{struct D3DCAPS9 { DeviceType: ::D3DDEVTYPE, AdapterOrdinal: ::UINT, Caps: ::DWORD, Caps2: ::DWORD, Caps3: ::DWORD, PresentationIntervals: ::DWORD, CursorCaps: ::DWORD, DevCaps: ::DWORD, PrimitiveMiscCaps: ::DWORD, RasterCaps: ::DWORD, ZCmpCaps: ::DWORD, SrcBlendCaps: ::DWORD, DestBlendCaps: ::DWORD, AlphaCmpCaps: ::DWORD, ShadeCaps: ::DWORD, TextureCaps: ::DWORD, TextureFilterCaps: ::DWORD, CubeTextureFilterCaps: ::DWORD, VolumeTextureFilterCaps: ::DWORD, TextureAddressCaps: ::DWORD, VolumeTextureAddressCaps: ::DWORD, LineCaps: ::DWORD, MaxTextureWidth: ::DWORD, MaxTextureHeight: ::DWORD, MaxVolumeExtent: ::DWORD, MaxTextureRepeat: ::DWORD, MaxTextureAspectRatio: ::DWORD, MaxAnisotropy: ::DWORD, MaxVertexW: ::c_float, GuardBandLeft: ::c_float, GuardBandTop: ::c_float, GuardBandRight: ::c_float, GuardBandBottom: ::c_float, ExtentsAdjust: ::c_float, StencilCaps: ::DWORD, FVFCaps: ::DWORD, TextureOpCaps: ::DWORD, MaxTextureBlendStages: ::DWORD, MaxSimultaneousTextures: ::DWORD, VertexProcessingCaps: ::DWORD, MaxActiveLights: ::DWORD, MaxUserClipPlanes: ::DWORD, MaxVertexBlendMatrices: ::DWORD, MaxVertexBlendMatrixIndex: ::DWORD, MaxPointSize: ::c_float, MaxPrimitiveCount: ::DWORD, MaxVertexIndex: ::DWORD, MaxStreams: ::DWORD, MaxStreamStride: ::DWORD, VertexShaderVersion: ::DWORD, MaxVertexShaderConst: ::DWORD, PixelShaderVersion: ::DWORD, PixelShader1xMaxValue: ::c_float, DevCaps2: ::DWORD, MaxNpatchTessellationLevel: ::c_float, Reserved5: ::DWORD, MasterAdapterOrdinal: ::UINT, AdapterOrdinalInGroup: ::UINT, NumberOfAdaptersInGroup: ::UINT, DeclTypes: ::DWORD, NumSimultaneousRTs: ::DWORD, StretchRectFilterCaps: ::DWORD, VS20Caps: ::D3DVSHADERCAPS2_0, PS20Caps: ::D3DPSHADERCAPS2_0, VertexTextureFilterCaps: ::DWORD, MaxVShaderInstructionsExecuted: ::DWORD, MaxPShaderInstructionsExecuted: ::DWORD, MaxVertexShader30InstructionSlots: ::DWORD, MaxPixelShader30InstructionSlots: ::DWORD, }} pub const D3DCAPS_OVERLAY: ::DWORD = 0x00000800; pub const D3DCAPS_READ_SCANLINE: ::DWORD = 0x00020000; pub const D3DCAPS2_FULLSCREENGAMMA: ::DWORD = 0x00020000; pub const D3DCAPS2_CANCALIBRATEGAMMA: ::DWORD = 0x00100000; pub const D3DCAPS2_RESERVED: ::DWORD = 0x02000000; pub const D3DCAPS2_CANMANAGERESOURCE: ::DWORD = 0x10000000; pub const D3DCAPS2_DYNAMICTEXTURES: ::DWORD = 0x20000000; pub const D3DCAPS2_CANAUTOGENMIPMAP: ::DWORD = 0x40000000; pub const D3DCAPS2_CANSHARERESOURCE: ::DWORD = 0x80000000; pub const D3DCAPS3_RESERVED: ::DWORD = 0x8000001f; pub const D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD: ::DWORD = 0x00000020; pub const D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION: ::DWORD = 0x00000080; pub const D3DCAPS3_COPY_TO_VIDMEM: ::DWORD = 0x00000100; pub const D3DCAPS3_COPY_TO_SYSTEMMEM: ::DWORD = 0x00000200; pub const D3DCAPS3_DXVAHD: ::DWORD = 0x00000400; pub const D3DCAPS3_DXVAHD_LIMITED: ::DWORD = 0x00000800; pub const D3DPRESENT_INTERVAL_DEFAULT: ::DWORD = 0x00000000; pub const D3DPRESENT_INTERVAL_ONE: ::DWORD = 0x00000001; pub const D3DPRESENT_INTERVAL_TWO: ::DWORD = 0x00000002; pub const D3DPRESENT_INTERVAL_THREE: ::DWORD = 0x00000004; pub const D3DPRESENT_INTERVAL_FOUR: ::DWORD = 0x00000008; pub const D3DPRESENT_INTERVAL_IMMEDIATE: ::DWORD = 0x80000000; pub const D3DCURSORCAPS_COLOR: ::DWORD = 0x00000001; pub const D3DCURSORCAPS_LOWRES: ::DWORD = 0x00000002; pub const D3DDEVCAPS_EXECUTESYSTEMMEMORY: ::DWORD = 0x00000010; pub const D3DDEVCAPS_EXECUTEVIDEOMEMORY: ::DWORD = 0x00000020; pub const D3DDEVCAPS_TLVERTEXSYSTEMMEMORY: ::DWORD = 0x00000040; pub const D3DDEVCAPS_TLVERTEXVIDEOMEMORY: ::DWORD = 0x00000080; pub const D3DDEVCAPS_TEXTURESYSTEMMEMORY: ::DWORD = 0x00000100; pub const D3DDEVCAPS_TEXTUREVIDEOMEMORY: ::DWORD = 0x00000200; pub const D3DDEVCAPS_DRAWPRIMTLVERTEX: ::DWORD = 0x00000400; pub const D3DDEVCAPS_CANRENDERAFTERFLIP: ::DWORD = 0x00000800; pub const D3DDEVCAPS_TEXTURENONLOCALVIDMEM: ::DWORD = 0x00001000; pub const D3DDEVCAPS_DRAWPRIMITIVES2: ::DWORD = 0x00002000; pub const D3DDEVCAPS_SEPARATETEXTUREMEMORIES: ::DWORD = 0x00004000; pub const D3DDEVCAPS_DRAWPRIMITIVES2EX: ::DWORD = 0x00008000; pub const D3DDEVCAPS_HWTRANSFORMANDLIGHT: ::DWORD = 0x00010000; pub const D3DDEVCAPS_CANBLTSYSTONONLOCAL: ::DWORD = 0x00020000; pub const D3DDEVCAPS_HWRASTERIZATION: ::DWORD = 0x00080000; pub const D3DDEVCAPS_PUREDEVICE: ::DWORD = 0x00100000; pub const D3DDEVCAPS_QUINTICRTPATCHES: ::DWORD = 0x00200000; pub const D3DDEVCAPS_RTPATCHES: ::DWORD = 0x00400000; pub const D3DDEVCAPS_RTPATCHHANDLEZERO: ::DWORD = 0x00800000; pub const D3DDEVCAPS_NPATCHES: ::DWORD = 0x01000000; pub const D3DPMISCCAPS_MASKZ: ::DWORD = 0x00000002; pub const D3DPMISCCAPS_CULLNONE: ::DWORD = 0x00000010; pub const D3DPMISCCAPS_CULLCW: ::DWORD = 0x00000020; pub const D3DPMISCCAPS_CULLCCW: ::DWORD = 0x00000040; pub const D3DPMISCCAPS_COLORWRITEENABLE: ::DWORD = 0x00000080; pub const D3DPMISCCAPS_CLIPPLANESCALEDPOINTS: ::DWORD = 0x00000100; pub const D3DPMISCCAPS_CLIPTLVERTS: ::DWORD = 0x00000200; pub const D3DPMISCCAPS_TSSARGTEMP: ::DWORD = 0x00000400; pub const D3DPMISCCAPS_BLENDOP: ::DWORD = 0x00000800; pub const D3DPMISCCAPS_NULLREFERENCE: ::DWORD = 0x00001000; pub const D3DPMISCCAPS_INDEPENDENTWRITEMASKS: ::DWORD = 0x00004000; pub const D3DPMISCCAPS_PERSTAGECONSTANT: ::DWORD = 0x00008000; pub const D3DPMISCCAPS_FOGANDSPECULARALPHA: ::DWORD = 0x00010000; pub const D3DPMISCCAPS_SEPARATEALPHABLEND: ::DWORD = 0x00020000; pub const D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS: ::DWORD = 0x00040000; pub const D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING: ::DWORD = 0x00080000; pub const D3DPMISCCAPS_FOGVERTEXCLAMPED: ::DWORD = 0x00100000; pub const D3DPMISCCAPS_POSTBLENDSRGBCONVERT: ::DWORD = 0x00200000; pub const D3DLINECAPS_TEXTURE: ::DWORD = 0x00000001; pub const D3DLINECAPS_ZTEST: ::DWORD = 0x00000002; pub const D3DLINECAPS_BLEND: ::DWORD = 0x00000004; pub const D3DLINECAPS_ALPHACMP: ::DWORD = 0x00000008; pub const D3DLINECAPS_FOG: ::DWORD = 0x00000010; pub const D3DLINECAPS_ANTIALIAS: ::DWORD = 0x00000020; pub const D3DPRASTERCAPS_DITHER: ::DWORD = 0x00000001; pub const D3DPRASTERCAPS_ZTEST: ::DWORD = 0x00000010; pub const D3DPRASTERCAPS_FOGVERTEX: ::DWORD = 0x00000080; pub const D3DPRASTERCAPS_FOGTABLE: ::DWORD = 0x00000100; pub const D3DPRASTERCAPS_MIPMAPLODBIAS: ::DWORD = 0x00002000; pub const D3DPRASTERCAPS_ZBUFFERLESSHSR: ::DWORD = 0x00008000; pub const D3DPRASTERCAPS_FOGRANGE: ::DWORD = 0x00010000; pub const D3DPRASTERCAPS_ANISOTROPY: ::DWORD = 0x00020000; pub const D3DPRASTERCAPS_WBUFFER: ::DWORD = 0x00040000; pub const D3DPRASTERCAPS_WFOG: ::DWORD = 0x00100000; pub const D3DPRASTERCAPS_ZFOG: ::DWORD = 0x00200000; pub const D3DPRASTERCAPS_COLORPERSPECTIVE: ::DWORD = 0x00400000; pub const D3DPRASTERCAPS_SCISSORTEST: ::DWORD = 0x01000000; pub const D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS: ::DWORD = 0x02000000; pub const D3DPRASTERCAPS_DEPTHBIAS: ::DWORD = 0x04000000; pub const D3DPRASTERCAPS_MULTISAMPLE_TOGGLE: ::DWORD = 0x08000000; pub const D3DPCMPCAPS_NEVER: ::DWORD = 0x00000001; pub const D3DPCMPCAPS_LESS: ::DWORD = 0x00000002; pub const D3DPCMPCAPS_EQUAL: ::DWORD = 0x00000004; pub const D3DPCMPCAPS_LESSEQUAL: ::DWORD = 0x00000008; pub const D3DPCMPCAPS_GREATER: ::DWORD = 0x00000010; pub const D3DPCMPCAPS_NOTEQUAL: ::DWORD = 0x00000020; pub const D3DPCMPCAPS_GREATEREQUAL: ::DWORD = 0x00000040; pub const D3DPCMPCAPS_ALWAYS: ::DWORD = 0x00000080; pub const D3DPBLENDCAPS_ZERO: ::DWORD = 0x00000001; pub const D3DPBLENDCAPS_ONE: ::DWORD = 0x00000002; pub const D3DPBLENDCAPS_SRCCOLOR: ::DWORD = 0x00000004; pub const D3DPBLENDCAPS_INVSRCCOLOR: ::DWORD = 0x00000008; pub const D3DPBLENDCAPS_SRCALPHA: ::DWORD = 0x00000010; pub const D3DPBLENDCAPS_INVSRCALPHA: ::DWORD = 0x00000020; pub const D3DPBLENDCAPS_DESTALPHA: ::DWORD = 0x00000040; pub const D3DPBLENDCAPS_INVDESTALPHA: ::DWORD = 0x00000080; pub const D3DPBLENDCAPS_DESTCOLOR: ::DWORD = 0x00000100; pub const D3DPBLENDCAPS_INVDESTCOLOR: ::DWORD = 0x00000200; pub const D3DPBLENDCAPS_SRCALPHASAT: ::DWORD = 0x00000400; pub const D3DPBLENDCAPS_BOTHSRCALPHA: ::DWORD = 0x00000800; pub const D3DPBLENDCAPS_BOTHINVSRCALPHA: ::DWORD = 0x00001000; pub const D3DPBLENDCAPS_BLENDFACTOR: ::DWORD = 0x00002000; pub const D3DPBLENDCAPS_SRCCOLOR2: ::DWORD = 0x00004000; pub const D3DPBLENDCAPS_INVSRCCOLOR2: ::DWORD = 0x00008000; pub const D3DPSHADECAPS_COLORGOURAUDRGB: ::DWORD = 0x00000008; pub const D3DPSHADECAPS_SPECULARGOURAUDRGB: ::DWORD = 0x00000200; pub const D3DPSHADECAPS_ALPHAGOURAUDBLEND: ::DWORD = 0x00004000; pub const D3DPSHADECAPS_FOGGOURAUD: ::DWORD = 0x00080000; pub const D3DPTEXTURECAPS_PERSPECTIVE: ::DWORD = 0x00000001; pub const D3DPTEXTURECAPS_POW2: ::DWORD = 0x00000002; pub const D3DPTEXTURECAPS_ALPHA: ::DWORD = 0x00000004; pub const D3DPTEXTURECAPS_SQUAREONLY: ::DWORD = 0x00000020; pub const D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE: ::DWORD = 0x00000040; pub const D3DPTEXTURECAPS_ALPHAPALETTE: ::DWORD = 0x00000080; pub const D3DPTEXTURECAPS_NONPOW2CONDITIONAL: ::DWORD = 0x00000100; pub const D3DPTEXTURECAPS_PROJECTED: ::DWORD = 0x00000400; pub const D3DPTEXTURECAPS_CUBEMAP: ::DWORD = 0x00000800; pub const D3DPTEXTURECAPS_VOLUMEMAP: ::DWORD = 0x00002000; pub const D3DPTEXTURECAPS_MIPMAP: ::DWORD = 0x00004000; pub const D3DPTEXTURECAPS_MIPVOLUMEMAP: ::DWORD = 0x00008000; pub const D3DPTEXTURECAPS_MIPCUBEMAP: ::DWORD = 0x00010000; pub const D3DPTEXTURECAPS_CUBEMAP_POW2: ::DWORD = 0x00020000; pub const D3DPTEXTURECAPS_VOLUMEMAP_POW2: ::DWORD = 0x00040000; pub const D3DPTEXTURECAPS_NOPROJECTEDBUMPENV: ::DWORD = 0x00200000; pub const D3DPTFILTERCAPS_MINFPOINT: ::DWORD = 0x00000100; pub const D3DPTFILTERCAPS_MINFLINEAR: ::DWORD = 0x00000200; pub const D3DPTFILTERCAPS_MINFANISOTROPIC: ::DWORD = 0x00000400; pub const D3DPTFILTERCAPS_MINFPYRAMIDALQUAD: ::DWORD = 0x00000800; pub const D3DPTFILTERCAPS_MINFGAUSSIANQUAD: ::DWORD = 0x00001000; pub const D3DPTFILTERCAPS_MIPFPOINT: ::DWORD = 0x00010000; pub const D3DPTFILTERCAPS_MIPFLINEAR: ::DWORD = 0x00020000; pub const D3DPTFILTERCAPS_CONVOLUTIONMONO: ::DWORD = 0x00040000; pub const D3DPTFILTERCAPS_MAGFPOINT: ::DWORD = 0x01000000; pub const D3DPTFILTERCAPS_MAGFLINEAR: ::DWORD = 0x02000000; pub const D3DPTFILTERCAPS_MAGFANISOTROPIC: ::DWORD = 0x04000000; pub const D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD: ::DWORD = 0x08000000; pub const D3DPTFILTERCAPS_MAGFGAUSSIANQUAD: ::DWORD = 0x10000000; pub const D3DPTADDRESSCAPS_WRAP: ::DWORD = 0x00000001; pub const D3DPTADDRESSCAPS_MIRROR: ::DWORD = 0x00000002; pub const D3DPTADDRESSCAPS_CLAMP: ::DWORD = 0x00000004; pub const D3DPTADDRESSCAPS_BORDER: ::DWORD = 0x00000008; pub const D3DPTADDRESSCAPS_INDEPENDENTUV: ::DWORD = 0x00000010; pub const D3DPTADDRESSCAPS_MIRRORONCE: ::DWORD = 0x00000020; pub const D3DSTENCILCAPS_KEEP: ::DWORD = 0x00000001; pub const D3DSTENCILCAPS_ZERO: ::DWORD = 0x00000002; pub const D3DSTENCILCAPS_REPLACE: ::DWORD = 0x00000004; pub const D3DSTENCILCAPS_INCRSAT: ::DWORD = 0x00000008; pub const D3DSTENCILCAPS_DECRSAT: ::DWORD = 0x00000010; pub const D3DSTENCILCAPS_INVERT: ::DWORD = 0x00000020; pub const D3DSTENCILCAPS_INCR: ::DWORD = 0x00000040; pub const D3DSTENCILCAPS_DECR: ::DWORD = 0x00000080; pub const D3DSTENCILCAPS_TWOSIDED: ::DWORD = 0x00000100; pub const D3DTEXOPCAPS_DISABLE: ::DWORD = 0x00000001; pub const D3DTEXOPCAPS_SELECTARG1: ::DWORD = 0x00000002; pub const D3DTEXOPCAPS_SELECTARG2: ::DWORD = 0x00000004; pub const D3DTEXOPCAPS_MODULATE: ::DWORD = 0x00000008; pub const D3DTEXOPCAPS_MODULATE2X: ::DWORD = 0x00000010; pub const D3DTEXOPCAPS_MODULATE4X: ::DWORD = 0x00000020; pub const D3DTEXOPCAPS_ADD: ::DWORD = 0x00000040; pub const D3DTEXOPCAPS_ADDSIGNED: ::DWORD = 0x00000080; pub const D3DTEXOPCAPS_ADDSIGNED2X: ::DWORD = 0x00000100; pub const D3DTEXOPCAPS_SUBTRACT: ::DWORD = 0x00000200; pub const D3DTEXOPCAPS_ADDSMOOTH: ::DWORD = 0x00000400; pub const D3DTEXOPCAPS_BLENDDIFFUSEALPHA: ::DWORD = 0x00000800; pub const D3DTEXOPCAPS_BLENDTEXTUREALPHA: ::DWORD = 0x00001000; pub const D3DTEXOPCAPS_BLENDFACTORALPHA: ::DWORD = 0x00002000; pub const D3DTEXOPCAPS_BLENDTEXTUREALPHAPM: ::DWORD = 0x00004000; pub const D3DTEXOPCAPS_BLENDCURRENTALPHA: ::DWORD = 0x00008000; pub const D3DTEXOPCAPS_PREMODULATE: ::DWORD = 0x00010000; pub const D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR: ::DWORD = 0x00020000; pub const D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA: ::DWORD = 0x00040000; pub const D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR: ::DWORD = 0x00080000; pub const D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA: ::DWORD = 0x00100000; pub const D3DTEXOPCAPS_BUMPENVMAP: ::DWORD = 0x00200000; pub const D3DTEXOPCAPS_BUMPENVMAPLUMINANCE: ::DWORD = 0x00400000; pub const D3DTEXOPCAPS_DOTPRODUCT3: ::DWORD = 0x00800000; pub const D3DTEXOPCAPS_MULTIPLYADD: ::DWORD = 0x01000000; pub const D3DTEXOPCAPS_LERP: ::DWORD = 0x02000000; pub const D3DFVFCAPS_TEXCOORDCOUNTMASK: ::DWORD = 0x0000ffff; pub const D3DFVFCAPS_DONOTSTRIPELEMENTS: ::DWORD = 0x00080000; pub const D3DFVFCAPS_PSIZE: ::DWORD = 0x00100000; pub const D3DVTXPCAPS_TEXGEN: ::DWORD = 0x00000001; pub const D3DVTXPCAPS_MATERIALSOURCE7: ::DWORD = 0x00000002; pub const D3DVTXPCAPS_DIRECTIONALLIGHTS: ::DWORD = 0x00000008; pub const D3DVTXPCAPS_POSITIONALLIGHTS: ::DWORD = 0x00000010; pub const D3DVTXPCAPS_LOCALVIEWER: ::DWORD = 0x00000020; pub const D3DVTXPCAPS_TWEENING: ::DWORD = 0x00000040; pub const D3DVTXPCAPS_TEXGEN_SPHEREMAP: ::DWORD = 0x00000100; pub const D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER: ::DWORD = 0x00000200; pub const D3DDEVCAPS2_STREAMOFFSET: ::DWORD = 0x00000001; pub const D3DDEVCAPS2_DMAPNPATCH: ::DWORD = 0x00000002; pub const D3DDEVCAPS2_ADAPTIVETESSRTPATCH: ::DWORD = 0x00000004; pub const D3DDEVCAPS2_ADAPTIVETESSNPATCH: ::DWORD = 0x00000008; pub const D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES: ::DWORD = 0x00000010; pub const D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH: ::DWORD = 0x00000020; pub const D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET: ::DWORD = 0x00000040; pub const D3DDTCAPS_UBYTE4: ::DWORD = 0x00000001; pub const D3DDTCAPS_UBYTE4N: ::DWORD = 0x00000002; pub const D3DDTCAPS_SHORT2N: ::DWORD = 0x00000004; pub const D3DDTCAPS_SHORT4N: ::DWORD = 0x00000008; pub const D3DDTCAPS_USHORT2N: ::DWORD = 0x00000010; pub const D3DDTCAPS_USHORT4N: ::DWORD = 0x00000020; pub const D3DDTCAPS_UDEC3: ::DWORD = 0x00000040; pub const D3DDTCAPS_DEC3N: ::DWORD = 0x00000080; pub const D3DDTCAPS_FLOAT16_2: ::DWORD = 0x00000100; pub const D3DDTCAPS_FLOAT16_4: ::DWORD = 0x00000200; deps/winapi-0.2.5/src/windef.rs0000644000000000000000000000305012613167613015053 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Basic Windows Type Definitions DECLARE_HANDLE!(HWND, HWND__); DECLARE_HANDLE!(HHOOK, HHOOK__); DECLARE_HANDLE!(HEVENT, HEVENT__); pub type HGDIOBJ = *mut ::c_void; DECLARE_HANDLE!(HACCEL, HACCEL__); DECLARE_HANDLE!(HBITMAP, HBITMAP__); DECLARE_HANDLE!(HBRUSH, HBRUSH__); DECLARE_HANDLE!(HCOLORSPACE, HCOLORSPACE__); DECLARE_HANDLE!(HDC, HDC__); DECLARE_HANDLE!(HGLRC, HGLRC__); DECLARE_HANDLE!(HDESK, HDESK__); DECLARE_HANDLE!(HENHMETAFILE, HENHMETAFILE__); DECLARE_HANDLE!(HFONT, HFONT__); DECLARE_HANDLE!(HICON, HICON__); DECLARE_HANDLE!(HMENU, HMENU__); DECLARE_HANDLE!(HPALETTE, HPALETTE__); DECLARE_HANDLE!(HPEN, HPEN__); DECLARE_HANDLE!(HWINEVENTHOOK, HWINEVENTHOOK__); DECLARE_HANDLE!(HMONITOR, HMONITOR__); DECLARE_HANDLE!(HUMPD, HUMPD__); pub type HCURSOR = HICON; pub type COLORREF = ::DWORD; pub type LPCOLORREF = *mut ::DWORD; STRUCT!{struct RECT { left: ::LONG, top: ::LONG, right: ::LONG, bottom: ::LONG, }} pub type PRECT = *mut RECT; pub type NPRECT = *mut RECT; pub type LPRECT = *mut RECT; pub type LPCRECT = *const RECT; STRUCT!{struct RECTL { left: ::LONG, top: ::LONG, right: ::LONG, bottom: ::LONG, }} pub type PRECTL = *mut RECTL; pub type LPRECTL = *mut RECTL; pub type LPCRECTL = *const RECTL; STRUCT!{struct POINT { x: ::LONG, y: ::LONG, }} pub type PPOINT = *mut POINT; pub type NPPOINT = *mut POINT; pub type LPPOINT = *mut POINT; STRUCT!{struct POINTL { x: ::LONG, y: ::LONG, }} pub type PPOINTL = *mut POINTL; deps/winapi-0.2.5/src/winevt.rs0000644000000000000000000000212212615656124015114 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! Windows Events API pub type EVT_HANDLE = ::HANDLE; pub type PEVT_HANDLE = *mut ::HANDLE; ENUM!{enum EVT_VARIANT_TYPE { EvtVarTypeNull = 0, EvtVarTypeString = 1, EvtVarTypeAnsiString = 2, EvtVarTypeSByte = 3, EvtVarTypeByte = 4, EvtVarTypeInt16 = 5, EvtVarTypeUInt16 = 6, EvtVarTypeInt32 = 7, EvtVarTypeUInt32 = 8, EvtVarTypeInt64 = 9, EvtVarTypeUInt64 = 10, EvtVarTypeSingle = 11, EvtVarTypeDouble = 12, EvtVarTypeBoolean = 13, EvtVarTypeBinary = 14, EvtVarTypeGuid = 15, EvtVarTypeSizeT = 16, EvtVarTypeFileTime = 17, EvtVarTypeSysTime = 18, EvtVarTypeSid = 19, EvtVarTypeHexInt32 = 20, EvtVarTypeHexInt64 = 21, EvtVarTypeEvtHandle = 32, EvtVarTypeEvtXml = 35, }} pub const EVT_VARIANT_TYPE_MASK: ::DWORD = 0x7f; pub const EVT_VARIANT_TYPE_ARRAY: ::DWORD = 128; STRUCT!{struct EVT_VARIANT { u: u64, Count: ::DWORD, Type: ::DWORD, }} // TODO - All the UNION! for each variant // TODO - The rest of this header deps/winapi-0.2.5/src/dxgiformat.rs0000644000000000000000000001035312617171733015751 0ustar rootroot// Copyright © 2015, Connor Hilarides // Licensed under the MIT License //! Mappings for the contents of dxgiformat.h ENUM!{enum DXGI_FORMAT { DXGI_FORMAT_UNKNOWN = 0, DXGI_FORMAT_R32G32B32A32_TYPELESS = 1, DXGI_FORMAT_R32G32B32A32_FLOAT = 2, DXGI_FORMAT_R32G32B32A32_UINT = 3, DXGI_FORMAT_R32G32B32A32_SINT = 4, DXGI_FORMAT_R32G32B32_TYPELESS = 5, DXGI_FORMAT_R32G32B32_FLOAT = 6, DXGI_FORMAT_R32G32B32_UINT = 7, DXGI_FORMAT_R32G32B32_SINT = 8, DXGI_FORMAT_R16G16B16A16_TYPELESS = 9, DXGI_FORMAT_R16G16B16A16_FLOAT = 10, DXGI_FORMAT_R16G16B16A16_UNORM = 11, DXGI_FORMAT_R16G16B16A16_UINT = 12, DXGI_FORMAT_R16G16B16A16_SNORM = 13, DXGI_FORMAT_R16G16B16A16_SINT = 14, DXGI_FORMAT_R32G32_TYPELESS = 15, DXGI_FORMAT_R32G32_FLOAT = 16, DXGI_FORMAT_R32G32_UINT = 17, DXGI_FORMAT_R32G32_SINT = 18, DXGI_FORMAT_R32G8X24_TYPELESS = 19, DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20, DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21, DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22, DXGI_FORMAT_R10G10B10A2_TYPELESS = 23, DXGI_FORMAT_R10G10B10A2_UNORM = 24, DXGI_FORMAT_R10G10B10A2_UINT = 25, DXGI_FORMAT_R11G11B10_FLOAT = 26, DXGI_FORMAT_R8G8B8A8_TYPELESS = 27, DXGI_FORMAT_R8G8B8A8_UNORM = 28, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29, DXGI_FORMAT_R8G8B8A8_UINT = 30, DXGI_FORMAT_R8G8B8A8_SNORM = 31, DXGI_FORMAT_R8G8B8A8_SINT = 32, DXGI_FORMAT_R16G16_TYPELESS = 33, DXGI_FORMAT_R16G16_FLOAT = 34, DXGI_FORMAT_R16G16_UNORM = 35, DXGI_FORMAT_R16G16_UINT = 36, DXGI_FORMAT_R16G16_SNORM = 37, DXGI_FORMAT_R16G16_SINT = 38, DXGI_FORMAT_R32_TYPELESS = 39, DXGI_FORMAT_D32_FLOAT = 40, DXGI_FORMAT_R32_FLOAT = 41, DXGI_FORMAT_R32_UINT = 42, DXGI_FORMAT_R32_SINT = 43, DXGI_FORMAT_R24G8_TYPELESS = 44, DXGI_FORMAT_D24_UNORM_S8_UINT = 45, DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46, DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47, DXGI_FORMAT_R8G8_TYPELESS = 48, DXGI_FORMAT_R8G8_UNORM = 49, DXGI_FORMAT_R8G8_UINT = 50, DXGI_FORMAT_R8G8_SNORM = 51, DXGI_FORMAT_R8G8_SINT = 52, DXGI_FORMAT_R16_TYPELESS = 53, DXGI_FORMAT_R16_FLOAT = 54, DXGI_FORMAT_D16_UNORM = 55, DXGI_FORMAT_R16_UNORM = 56, DXGI_FORMAT_R16_UINT = 57, DXGI_FORMAT_R16_SNORM = 58, DXGI_FORMAT_R16_SINT = 59, DXGI_FORMAT_R8_TYPELESS = 60, DXGI_FORMAT_R8_UNORM = 61, DXGI_FORMAT_R8_UINT = 62, DXGI_FORMAT_R8_SNORM = 63, DXGI_FORMAT_R8_SINT = 64, DXGI_FORMAT_A8_UNORM = 65, DXGI_FORMAT_R1_UNORM = 66, DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67, DXGI_FORMAT_R8G8_B8G8_UNORM = 68, DXGI_FORMAT_G8R8_G8B8_UNORM = 69, DXGI_FORMAT_BC1_TYPELESS = 70, DXGI_FORMAT_BC1_UNORM = 71, DXGI_FORMAT_BC1_UNORM_SRGB = 72, DXGI_FORMAT_BC2_TYPELESS = 73, DXGI_FORMAT_BC2_UNORM = 74, DXGI_FORMAT_BC2_UNORM_SRGB = 75, DXGI_FORMAT_BC3_TYPELESS = 76, DXGI_FORMAT_BC3_UNORM = 77, DXGI_FORMAT_BC3_UNORM_SRGB = 78, DXGI_FORMAT_BC4_TYPELESS = 79, DXGI_FORMAT_BC4_UNORM = 80, DXGI_FORMAT_BC4_SNORM = 81, DXGI_FORMAT_BC5_TYPELESS = 82, DXGI_FORMAT_BC5_UNORM = 83, DXGI_FORMAT_BC5_SNORM = 84, DXGI_FORMAT_B5G6R5_UNORM = 85, DXGI_FORMAT_B5G5R5A1_UNORM = 86, DXGI_FORMAT_B8G8R8A8_UNORM = 87, DXGI_FORMAT_B8G8R8X8_UNORM = 88, DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89, DXGI_FORMAT_B8G8R8A8_TYPELESS = 90, DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91, DXGI_FORMAT_B8G8R8X8_TYPELESS = 92, DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93, DXGI_FORMAT_BC6H_TYPELESS = 94, DXGI_FORMAT_BC6H_UF16 = 95, DXGI_FORMAT_BC6H_SF16 = 96, DXGI_FORMAT_BC7_TYPELESS = 97, DXGI_FORMAT_BC7_UNORM = 98, DXGI_FORMAT_BC7_UNORM_SRGB = 99, DXGI_FORMAT_AYUV = 100, DXGI_FORMAT_Y410 = 101, DXGI_FORMAT_Y416 = 102, DXGI_FORMAT_NV12 = 103, DXGI_FORMAT_P010 = 104, DXGI_FORMAT_P016 = 105, DXGI_FORMAT_420_OPAQUE = 106, DXGI_FORMAT_YUY2 = 107, DXGI_FORMAT_Y210 = 108, DXGI_FORMAT_Y216 = 109, DXGI_FORMAT_NV11 = 110, DXGI_FORMAT_AI44 = 111, DXGI_FORMAT_IA44 = 112, DXGI_FORMAT_P8 = 113, DXGI_FORMAT_A8P8 = 114, DXGI_FORMAT_B4G4R4A4_UNORM = 115, DXGI_FORMAT_P208 = 130, DXGI_FORMAT_V208 = 131, DXGI_FORMAT_V408 = 132, }} deps/winapi-0.2.5/src/libloaderapi.rs0000644000000000000000000000222012605021351016211 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! ApiSet Contract for api-ms-win-core-libraryloader-l1 pub type DLL_DIRECTORY_COOKIE = ::PVOID; pub type PDLL_DIRECTORY_COOKIE = *mut ::PVOID; pub type ENUMRESLANGPROCA = Option ::BOOL>; pub type ENUMRESLANGPROCW = Option ::BOOL>; pub type ENUMRESNAMEPROCA = Option ::BOOL>; pub type ENUMRESNAMEPROCW = Option ::BOOL>; pub type ENUMRESTYPEPROCA = Option ::BOOL>; pub type ENUMRESTYPEPROCW = Option ::BOOL>; deps/winapi-0.2.5/src/winsock2.rs0000644000000000000000000003377212616503465015356 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! definitions to be used with the WinSock 2 DLL and WinSock 2 applications. //! //! This header file corresponds to version 2.2.x of the WinSock API specification. pub const WINSOCK_VERSION: ::WORD = 2 | (2 << 8); pub type u_char = ::c_uchar; pub type u_short = ::c_ushort; pub type u_int = ::c_uint; pub type u_long = ::c_ulong; pub type u_int64 = ::__uint64; pub type SOCKET = ::UINT_PTR; pub type GROUP = ::c_uint; pub const FD_SETSIZE: usize = 64; pub const FD_MAX_EVENTS: usize = 10; #[repr(C)] #[derive(Copy)] pub struct fd_set { pub fd_count: u_int, pub fd_array: [SOCKET; FD_SETSIZE], } impl Clone for fd_set { fn clone(&self) -> fd_set { *self } } STRUCT!{struct timeval { tv_sec: ::c_long, tv_usec: ::c_long, }} STRUCT!{struct hostent { h_name: *mut ::c_char, h_aliases: *mut *mut ::c_char, h_addrtype: ::c_short, h_length: ::c_short, h_addr_list: *mut *mut ::c_char, }} STRUCT!{struct netent { n_name: *mut ::c_char, n_aliases: *mut *mut ::c_char, n_addrtype: ::c_short, n_net: u_long, }} #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct servent { pub s_name: *mut ::c_char, pub s_aliases: *mut *mut ::c_char, #[cfg(target_arch="x86")] pub s_port: ::c_short, #[cfg(target_arch="x86")] pub s_proto: *mut ::c_char, #[cfg(target_arch="x86_64")] pub s_proto: *mut ::c_char, #[cfg(target_arch="x86_64")] pub s_port: ::c_short, } STRUCT!{struct protoent { p_name: *mut ::c_char, p_aliases: *mut *mut ::c_char, p_proto: ::c_short, }} pub const WSADESCRIPTION_LEN: usize = 256; pub const WSASYS_STATUS_LEN: usize = 128; #[repr(C)] #[derive(Copy)] pub struct WSADATA { pub wVersion: ::WORD, pub wHighVersion: ::WORD, #[cfg(target_arch="x86")] pub szDescription: [::c_char; WSADESCRIPTION_LEN + 1], #[cfg(target_arch="x86")] pub szSystemStatus: [::c_char; WSASYS_STATUS_LEN + 1], pub iMaxSockets: ::c_ushort, pub iMaxUdpDg: ::c_ushort, pub lpVendorInfo: *mut ::c_char, #[cfg(target_arch="x86_64")] pub szDescription: [::c_char; WSADESCRIPTION_LEN + 1], #[cfg(target_arch="x86_64")] pub szSystemStatus: [::c_char; WSASYS_STATUS_LEN + 1], } impl Clone for WSADATA { fn clone(&self) -> WSADATA { *self } } pub type LPWSADATA = *mut WSADATA; //391 pub const INVALID_SOCKET: SOCKET = !0; pub const SOCKET_ERROR: ::c_int = -1; STRUCT!{struct sockproto { sp_family: u_short, sp_protocol: u_short, }} pub const PF_UNSPEC: ::c_int = ::AF_UNSPEC; pub const PF_UNIX: ::c_int = ::AF_UNIX; pub const PF_INET: ::c_int = ::AF_INET; pub const PF_IMPLINK: ::c_int = ::AF_IMPLINK; pub const PF_PUP: ::c_int = ::AF_PUP; pub const PF_CHAOS: ::c_int = ::AF_CHAOS; pub const PF_NS: ::c_int = ::AF_NS; pub const PF_IPX: ::c_int = ::AF_IPX; pub const PF_ISO: ::c_int = ::AF_ISO; pub const PF_OSI: ::c_int = ::AF_OSI; pub const PF_ECMA: ::c_int = ::AF_ECMA; pub const PF_DATAKIT: ::c_int = ::AF_DATAKIT; pub const PF_CCITT: ::c_int = ::AF_CCITT; pub const PF_SNA: ::c_int = ::AF_SNA; pub const PF_DECnet: ::c_int = ::AF_DECnet; pub const PF_DLI: ::c_int = ::AF_DLI; pub const PF_LAT: ::c_int = ::AF_LAT; pub const PF_HYLINK: ::c_int = ::AF_HYLINK; pub const PF_APPLETALK: ::c_int = ::AF_APPLETALK; pub const PF_VOICEVIEW: ::c_int = ::AF_VOICEVIEW; pub const PF_FIREFOX: ::c_int = ::AF_FIREFOX; pub const PF_UNKNOWN1: ::c_int = ::AF_UNKNOWN1; pub const PF_BAN: ::c_int = ::AF_BAN; pub const PF_ATM: ::c_int = ::AF_ATM; pub const PF_INET6: ::c_int = ::AF_INET6; pub const PF_BTH: ::c_int = ::AF_BTH; pub const PF_MAX: ::c_int = ::AF_MAX; STRUCT!{struct linger { l_onoff: u_short, l_linger: u_short, }} pub const SOMAXCONN: ::c_int = 0x7fffffff; pub type WSAEVENT = ::HANDLE; pub type LPWSAEVENT = ::LPHANDLE; pub type WSAOVERLAPPED = ::OVERLAPPED; pub type LPWSAOVERLAPPED = *mut ::OVERLAPPED; pub const WSA_IO_PENDING: ::DWORD = ::ERROR_IO_PENDING; pub const WSA_IO_INCOMPLETE: ::DWORD = ::ERROR_IO_INCOMPLETE; pub const WSA_INVALID_HANDLE: ::DWORD = ::ERROR_INVALID_HANDLE; pub const WSA_INVALID_PARAMETER: ::DWORD = ::ERROR_INVALID_PARAMETER; pub const WSA_NOT_ENOUGH_MEMORY: ::DWORD = ::ERROR_NOT_ENOUGH_MEMORY; pub const WSA_OPERATION_ABORTED: ::DWORD = ::ERROR_OPERATION_ABORTED; STRUCT!{struct QOS { SendingFlowspec: ::FLOWSPEC, FLOWSPEC: ::FLOWSPEC, ProviderSpecific: ::WSABUF, }} pub type LPQOS = *mut QOS; STRUCT!{struct WSANETWORKEVENTS { lNetworkEvents: ::c_long, iErrorCode: [::c_int; FD_MAX_EVENTS], }} pub type LPWSANETWORKEVENTS = *mut WSANETWORKEVENTS; pub const MAX_PROTOCOL_CHAIN: usize = 7; STRUCT!{struct WSAPROTOCOLCHAIN { ChainLen: ::c_int, ChainEntries: [::DWORD; MAX_PROTOCOL_CHAIN], }} pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN; pub const WSAPROTOCOL_LEN: usize = 255; #[repr(C)] #[derive(Copy)] pub struct WSAPROTOCOL_INFOA { pub dwServiceFlags1: ::DWORD, pub dwServiceFlags2: ::DWORD, pub dwServiceFlags3: ::DWORD, pub dwServiceFlags4: ::DWORD, pub dwServiceFlags5: ::DWORD, pub ProviderId: ::GUID, pub dwCatalogEntryId: ::DWORD, pub ProtocolChain: WSAPROTOCOLCHAIN, pub iVersion: ::c_int, pub iAddressFamily: ::c_int, pub iMaxSockAddr: ::c_int, pub iMinSockAddr: ::c_int, pub iSocketType: ::c_int, pub iProtocol: ::c_int, pub iProtocolMaxOffset: ::c_int, pub iNetworkByteOrder: ::c_int, pub iSecurityScheme: ::c_int, pub dwMessageSize: ::DWORD, pub dwProviderReserved: ::DWORD, pub szProtocol: [::CHAR; WSAPROTOCOL_LEN + 1], } impl Clone for WSAPROTOCOL_INFOA { fn clone(&self) -> WSAPROTOCOL_INFOA { *self } } pub type LPWSAPROTOCOL_INFOA = *mut WSAPROTOCOL_INFOA; #[repr(C)] #[derive(Copy)] pub struct WSAPROTOCOL_INFOW { pub dwServiceFlags1: ::DWORD, pub dwServiceFlags2: ::DWORD, pub dwServiceFlags3: ::DWORD, pub dwServiceFlags4: ::DWORD, pub dwServiceFlags5: ::DWORD, pub ProviderId: ::GUID, pub dwCatalogEntryId: ::DWORD, pub ProtocolChain: WSAPROTOCOLCHAIN, pub iVersion: ::c_int, pub iAddressFamily: ::c_int, pub iMaxSockAddr: ::c_int, pub iMinSockAddr: ::c_int, pub iSocketType: ::c_int, pub iProtocol: ::c_int, pub iProtocolMaxOffset: ::c_int, pub iNetworkByteOrder: ::c_int, pub iSecurityScheme: ::c_int, pub dwMessageSize: ::DWORD, pub dwProviderReserved: ::DWORD, pub szProtocol: [::WCHAR; WSAPROTOCOL_LEN + 1], } impl Clone for WSAPROTOCOL_INFOW { fn clone(&self) -> WSAPROTOCOL_INFOW { *self } } pub type LPWSAPROTOCOL_INFOW = *mut WSAPROTOCOL_INFOW; pub type LPCONDITIONPROC = Option ::c_int>; pub type LPWSAOVERLAPPED_COMPLETION_ROUTINE = Option; ENUM!{enum WSACOMPLETIONTYPE { NSP_NOTIFY_IMMEDIATELY = 0, NSP_NOTIFY_HWND, NSP_NOTIFY_EVENT, NSP_NOTIFY_PORT, NSP_NOTIFY_APC, }} pub type PWSACOMPLETIONTYPE = *mut WSACOMPLETIONTYPE; pub type LPWSACOMPLETIONTYPE = *mut WSACOMPLETIONTYPE; STRUCT!{struct WSACOMPLETION_WindowMessage { hWnd: ::HWND, uMsg: ::UINT, context: ::WPARAM, }} STRUCT!{struct WSACOMPLETION_Event { lpOverlapped: LPWSAOVERLAPPED, }} #[repr(C)] #[derive(Copy)] pub struct WSACOMPLETION_Apc { pub lpOverlapped: LPWSAOVERLAPPED, pub lpfnCompletionProc: LPWSAOVERLAPPED_COMPLETION_ROUTINE } impl Clone for WSACOMPLETION_Apc { fn clone(&self) -> WSACOMPLETION_Apc { *self } } STRUCT!{struct WSACOMPLETION_Port { lpOverlapped: LPWSAOVERLAPPED, hPort: ::HANDLE, Key: ::ULONG_PTR, }} #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct WSACOMPLETION { pub Type: WSACOMPLETIONTYPE, #[cfg(target_arch="x86")] pub Parameters: [u8; 12], #[cfg(target_arch="x86_64")] pub Parameters: [u8; 24], } UNION!(WSACOMPLETION, Parameters, WindowMessage, WindowMessage_mut, WSACOMPLETION_WindowMessage); UNION!(WSACOMPLETION, Parameters, Event, Event_mut, WSACOMPLETION_Event); UNION!(WSACOMPLETION, Parameters, Apc, Apc_mut, WSACOMPLETION_Apc); UNION!(WSACOMPLETION, Parameters, Port, Port_mut, WSACOMPLETION_Port); pub type PWSACOMPLETION = *mut WSACOMPLETION; pub type LPWSACOMPLETION = *mut WSACOMPLETION; STRUCT!{struct AFPROTOCOLS { iAddressFamily: ::INT, iProtocol: ::INT, }} pub type PAFPROTOCOLS = *mut AFPROTOCOLS; pub type LPAFPROTOCOLS = *mut AFPROTOCOLS; ENUM!{enum WSAECOMPARATOR { COMP_EQUAL = 0, COMP_NOTLESS, }} pub type PWSAECOMPARATOR = *mut WSAECOMPARATOR; pub type LPWSAECOMPARATOR = *mut WSAECOMPARATOR; STRUCT!{struct WSAVERSION { dwVersion: ::DWORD, ecHow: WSAECOMPARATOR, }} pub type PWSAVERSION = *mut WSAVERSION; pub type LPWSAVERSION = *mut WSAVERSION; STRUCT!{struct WSAQUERYSETA { dwSize: ::DWORD, lpszServiceInstanceName: ::LPSTR, lpServiceClassId: ::LPGUID, lpVersion: LPWSAVERSION, lpszComment: ::LPSTR, dwNameSpace: ::DWORD, lpNSProviderId: ::LPGUID, lpszContext: ::LPSTR, dwNumberOfProtocols: ::DWORD, lpafpProtocols: LPAFPROTOCOLS, lpszQueryString: ::LPSTR, dwNumberOfCsAddrs: ::DWORD, lpcsaBuffer: ::LPCSADDR_INFO, dwOutputFlags: ::DWORD, lpBlob: ::LPBLOB, }} pub type PWSAQUERYSETA = *mut WSAQUERYSETA; pub type LPWSAQUERYSETA = *mut WSAQUERYSETA; STRUCT!{struct WSAQUERYSETW { dwSize: ::DWORD, lpszServiceInstanceName: ::LPWSTR, lpServiceClassId: ::LPGUID, lpVersion: LPWSAVERSION, lpszComment: ::LPWSTR, dwNameSpace: ::DWORD, lpNSProviderId: ::LPGUID, lpszContext: ::LPWSTR, dwNumberOfProtocols: ::DWORD, lpafpProtocols: LPAFPROTOCOLS, lpszQueryString: ::LPWSTR, dwNumberOfCsAddrs: ::DWORD, lpcsaBuffer: ::LPCSADDR_INFO, dwOutputFlags: ::DWORD, lpBlob: ::LPBLOB, }} pub type PWSAQUERYSETW = *mut WSAQUERYSETW; pub type LPWSAQUERYSETW = *mut WSAQUERYSETW; STRUCT!{struct WSAQUERYSET2A { dwSize: ::DWORD, lpszServiceInstanceName: ::LPSTR, lpVersion: LPWSAVERSION, lpszComment: ::LPSTR, dwNameSpace: ::DWORD, lpNSProviderId: ::LPGUID, lpszContext: ::LPSTR, dwNumberOfProtocols: ::DWORD, lpafpProtocols: LPAFPROTOCOLS, lpszQueryString: ::LPSTR, dwNumberOfCsAddrs: ::DWORD, lpcsaBuffer: ::LPCSADDR_INFO, dwOutputFlags: ::DWORD, lpBlob: ::LPBLOB, }} pub type PWSAQUERYSET2A = *mut WSAQUERYSET2A; pub type LPWSAQUERYSET2A = *mut WSAQUERYSET2A; STRUCT!{struct WSAQUERYSET2W { dwSize: ::DWORD, lpszServiceInstanceName: ::LPWSTR, lpVersion: LPWSAVERSION, lpszComment: ::LPWSTR, dwNameSpace: ::DWORD, lpNSProviderId: ::LPGUID, lpszContext: ::LPWSTR, dwNumberOfProtocols: ::DWORD, lpafpProtocols: LPAFPROTOCOLS, lpszQueryString: ::LPWSTR, dwNumberOfCsAddrs: ::DWORD, lpcsaBuffer: ::LPCSADDR_INFO, dwOutputFlags: ::DWORD, lpBlob: ::LPBLOB, }} pub type PWSAQUERYSET2W = *mut WSAQUERYSET2W; pub type LPWSAQUERYSET2W = *mut WSAQUERYSET2W; ENUM!{enum WSAESETSERVICEOP { RNRSERVICE_REGISTER = 0, RNRSERVICE_DEREGISTER, RNRSERVICE_DELETE, }} pub type PWSAESETSERVICEOP = *mut WSAESETSERVICEOP; pub type LPWSAESETSERVICEOP = *mut WSAESETSERVICEOP; STRUCT!{struct WSANSCLASSINFOA { lpszName: ::LPSTR, dwNameSpace: ::DWORD, dwValueType: ::DWORD, dwValueSize: ::DWORD, lpValue: ::LPVOID, }} pub type PWSANSCLASSINFOA = *mut WSANSCLASSINFOA; pub type LPWSANSCLASSINFOA = *mut WSANSCLASSINFOA; STRUCT!{struct WSANSCLASSINFOW { lpszName: ::LPWSTR, dwNameSpace: ::DWORD, dwValueType: ::DWORD, dwValueSize: ::DWORD, lpValue: ::LPVOID, }} pub type PWSANSCLASSINFOW = *mut WSANSCLASSINFOW; pub type LPWSANSCLASSINFOW = *mut WSANSCLASSINFOW; STRUCT!{struct WSASERVICECLASSINFOA { lpServiceClassId: ::LPGUID, lpszServiceClassName: ::LPSTR, dwCount: ::DWORD, lpClassInfos: LPWSANSCLASSINFOA, }} pub type PWSASERVICECLASSINFOA = *mut WSASERVICECLASSINFOA; pub type LPWSASERVICECLASSINFOA = *mut WSASERVICECLASSINFOA; STRUCT!{struct WSASERVICECLASSINFOW { lpServiceClassId: ::LPGUID, lpszServiceClassName: ::LPWSTR, dwCount: ::DWORD, lpClassInfos: LPWSANSCLASSINFOW, }} pub type PWSASERVICECLASSINFOW = *mut WSASERVICECLASSINFOW; pub type LPWSASERVICECLASSINFOW = *mut WSASERVICECLASSINFOW; STRUCT!{struct WSANAMESPACE_INFOA { NSProviderId: ::GUID, dwNameSpace: ::DWORD, fActive: ::BOOL, dwVersion: ::DWORD, lpszIdentifier: ::LPSTR, }} pub type PWSANAMESPACE_INFOA = *mut WSANAMESPACE_INFOA; pub type LPWSANAMESPACE_INFOA = *mut WSANAMESPACE_INFOA; STRUCT!{struct WSANAMESPACE_INFOW { NSProviderId: ::GUID, dwNameSpace: ::DWORD, fActive: ::BOOL, dwVersion: ::DWORD, lpszIdentifier: ::LPWSTR, }} pub type PWSANAMESPACE_INFOW = *mut WSANAMESPACE_INFOW; pub type LPWSANAMESPACE_INFOW = *mut WSANAMESPACE_INFOW; STRUCT!{struct WSANAMESPACE_INFOEXA { NSProviderId: ::GUID, dwNameSpace: ::DWORD, fActive: ::BOOL, dwVersion: ::DWORD, lpszIdentifier: ::LPSTR, ProviderSpecific: ::BLOB, }} pub type PWSANAMESPACE_INFOEXA = *mut WSANAMESPACE_INFOEXA; pub type LPWSANAMESPACE_INFOEXA = *mut WSANAMESPACE_INFOEXA; STRUCT!{struct WSANAMESPACE_INFOEXW { NSProviderId: ::GUID, dwNameSpace: ::DWORD, fActive: ::BOOL, dwVersion: ::DWORD, lpszIdentifier: ::LPWSTR, ProviderSpecific: ::BLOB, }} pub type PWSANAMESPACE_INFOEXW = *mut WSANAMESPACE_INFOEXW; pub type LPWSANAMESPACE_INFOEXW = *mut WSANAMESPACE_INFOEXW; pub const POLLRDNORM: ::SHORT = 0x0100; pub const POLLRDBAND: ::SHORT = 0x0200; pub const POLLIN: ::SHORT = POLLRDNORM | POLLRDBAND; pub const POLLPRI: ::SHORT = 0x0400; pub const POLLWRNORM: ::SHORT = 0x0010; pub const POLLOUT: ::SHORT = POLLWRNORM; pub const POLLWRBAND: ::SHORT = 0x0020; pub const POLLERR: ::SHORT = 0x0001; pub const POLLHUP: ::SHORT = 0x0002; pub const POLLNVAL: ::SHORT = 0x0004; STRUCT!{struct WSAPOLLFD { fd: ::SOCKET, events: ::SHORT, revents: ::SHORT, }} pub type PWSAPOLLFD = *mut WSAPOLLFD; pub type LPWSAPOLLFD = *mut WSAPOLLFD; pub const FIONBIO: ::c_ulong = 0x8004667e; deps/winapi-0.2.5/src/wingdi.rs0000644000000000000000000012110112613167613015056 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! GDI procedure declarations, constant definitions and macros pub const DISPLAY_DEVICE_ATTACHED_TO_DESKTOP: ::DWORD = 0x00000001; pub const DISPLAY_DEVICE_MULTI_DRIVER: ::DWORD = 0x00000002; pub const DISPLAY_DEVICE_PRIMARY_DEVICE: ::DWORD = 0x00000004; pub const DISPLAY_DEVICE_MIRRORING_DRIVER: ::DWORD = 0x00000008; pub const DISPLAY_DEVICE_VGA_COMPATIBLE: ::DWORD = 0x00000010; pub const DISPLAY_DEVICE_REMOVABLE: ::DWORD = 0x00000020; pub const DISPLAY_DEVICE_ACC_DRIVER: ::DWORD = 0x00000040; pub const DISPLAY_DEVICE_MODESPRUNED: ::DWORD = 0x08000000; pub const DISPLAY_DEVICE_REMOTE: ::DWORD = 0x04000000; pub const DISPLAY_DEVICE_DISCONNECT: ::DWORD = 0x02000000; pub const DISPLAY_DEVICE_TS_COMPATIBLE: ::DWORD = 0x00200000; pub const DISPLAY_DEVICE_UNSAFE_MODES_ON: ::DWORD = 0x00080000; pub const DISPLAY_DEVICE_ACTIVE: ::DWORD = 0x00000001; pub const DISPLAY_DEVICE_ATTACHED: ::DWORD = 0x00000002; pub const DM_ORIENTATION: ::DWORD = 0x00000001; pub const DM_PAPERSIZE: ::DWORD = 0x00000002; pub const DM_PAPERLENGTH: ::DWORD = 0x00000004; pub const DM_PAPERWIDTH: ::DWORD = 0x00000008; pub const DM_SCALE: ::DWORD = 0x00000010; pub const DM_POSITION: ::DWORD = 0x00000020; pub const DM_NUP: ::DWORD = 0x00000040; pub const DM_DISPLAYORIENTATION: ::DWORD = 0x00000080; pub const DM_COPIES: ::DWORD = 0x00000100; pub const DM_DEFAULTSOURCE: ::DWORD = 0x00000200; pub const DM_PRINTQUALITY: ::DWORD = 0x00000400; pub const DM_COLOR: ::DWORD = 0x00000800; pub const DM_DUPLEX: ::DWORD = 0x00001000; pub const DM_YRESOLUTION: ::DWORD = 0x00002000; pub const DM_TTOPTION: ::DWORD = 0x00004000; pub const DM_COLLATE: ::DWORD = 0x00008000; pub const DM_FORMNAME: ::DWORD = 0x00010000; pub const DM_LOGPIXELS: ::DWORD = 0x00020000; pub const DM_BITSPERPEL: ::DWORD = 0x00040000; pub const DM_PELSWIDTH: ::DWORD = 0x00080000; pub const DM_PELSHEIGHT: ::DWORD = 0x00100000; pub const DM_DISPLAYFLAGS: ::DWORD = 0x00200000; pub const DM_DISPLAYFREQUENCY: ::DWORD = 0x00400000; pub const DM_ICMMETHOD: ::DWORD = 0x00800000; pub const DM_ICMINTENT: ::DWORD = 0x01000000; pub const DM_MEDIATYPE: ::DWORD = 0x02000000; pub const DM_DITHERTYPE: ::DWORD = 0x04000000; pub const DM_PANNINGWIDTH: ::DWORD = 0x08000000; pub const DM_PANNINGHEIGHT: ::DWORD = 0x10000000; pub const DM_DISPLAYFIXEDOUTPUT: ::DWORD = 0x20000000; pub const PFD_TYPE_RGBA: ::BYTE = 0; pub const PFD_TYPE_COLORINDEX: ::BYTE = 1; pub const PFD_MAIN_PLANE: ::BYTE = 0; pub const PFD_OVERLAY_PLANE: ::BYTE = 1; pub const PFD_UNDERLAY_PLANE: ::BYTE = 0xFF; pub const PFD_DOUBLEBUFFER: ::DWORD = 0x00000001; pub const PFD_STEREO: ::DWORD = 0x00000002; pub const PFD_DRAW_TO_WINDOW: ::DWORD = 0x00000004; pub const PFD_DRAW_TO_BITMAP: ::DWORD = 0x00000008; pub const PFD_SUPPORT_GDI: ::DWORD = 0x00000010; pub const PFD_SUPPORT_OPENGL: ::DWORD = 0x00000020; pub const PFD_GENERIC_FORMAT: ::DWORD = 0x00000040; pub const PFD_NEED_PALETTE: ::DWORD = 0x00000080; pub const PFD_NEED_SYSTEM_PALETTE: ::DWORD = 0x00000100; pub const PFD_SWAP_EXCHANGE: ::DWORD = 0x00000200; pub const PFD_SWAP_COPY: ::DWORD = 0x00000400; pub const PFD_SWAP_LAYER_BUFFERS: ::DWORD = 0x00000800; pub const PFD_GENERIC_ACCELERATED: ::DWORD = 0x00001000; pub const PFD_SUPPORT_DIRECTDRAW: ::DWORD = 0x00002000; pub const PFD_DIRECT3D_ACCELERATED: ::DWORD = 0x00004000; pub const PFD_SUPPORT_COMPOSITION: ::DWORD = 0x00008000; pub const PFD_DEPTH_DONTCARE: ::DWORD = 0x20000000; pub const PFD_DOUBLEBUFFER_DONTCARE: ::DWORD = 0x40000000; pub const PFD_STEREO_DONTCARE: ::DWORD = 0x80000000; pub const CCHFORMNAME: usize = 32; STRUCT!{struct DEVMODEA { dmDeviceName: [::CHAR; ::CCHDEVICENAME], dmSpecVersion: ::WORD, dmDriverVersion: ::WORD, dmSize: ::WORD, dmDriverExtra: ::WORD, dmFields: ::DWORD, union1: [u8; 16], dmColor: ::c_short, dmDuplex: ::c_short, dmYResolution: ::c_short, dmTTOption: ::c_short, dmCollate: ::c_short, dmFormName: [::CHAR; CCHFORMNAME], dmLogPixels: ::WORD, dmBitsPerPel: ::DWORD, dmPelsWidth: ::DWORD, dmPelsHeight: ::DWORD, dmDisplayFlags: ::DWORD, dmDisplayFrequency: ::DWORD, dmICMMethod: ::DWORD, dmICMIntent: ::DWORD, dmMediaType: ::DWORD, dmDitherType: ::DWORD, dmReserved1: ::DWORD, dmReserved2: ::DWORD, dmPanningWidth: ::DWORD, dmPanningHeight: ::DWORD, }} pub type PDEVMODEA = *mut DEVMODEA; pub type NPDEVMODEA = *mut DEVMODEA; pub type LPDEVMODEA = *mut DEVMODEA; STRUCT!{struct DEVMODEW { dmDeviceName: [::WCHAR; ::CCHDEVICENAME], dmSpecVersion: ::WORD, dmDriverVersion: ::WORD, dmSize: ::WORD, dmDriverExtra: ::WORD, dmFields: ::DWORD, union1: [u8; 16], dmColor: ::c_short, dmDuplex: ::c_short, dmYResolution: ::c_short, dmTTOption: ::c_short, dmCollate: ::c_short, dmFormName: [::WCHAR; CCHFORMNAME], dmLogPixels: ::WORD, dmBitsPerPel: ::DWORD, dmPelsWidth: ::DWORD, dmPelsHeight: ::DWORD, dmDisplayFlags: ::DWORD, dmDisplayFrequency: ::DWORD, dmICMMethod: ::DWORD, dmICMIntent: ::DWORD, dmMediaType: ::DWORD, dmDitherType: ::DWORD, dmReserved1: ::DWORD, dmReserved2: ::DWORD, dmPanningWidth: ::DWORD, dmPanningHeight: ::DWORD, }} pub type PDEVMODEW = *mut DEVMODEW; pub type NPDEVMODEW = *mut DEVMODEW; pub type LPDEVMODEW = *mut DEVMODEW; #[repr(C)] #[derive(Copy)] pub struct DISPLAY_DEVICEW { pub cb: ::DWORD, pub DeviceName: [::WCHAR; 32], pub DeviceString: [::WCHAR; 128], pub StateFlags: ::DWORD, pub DeviceID: [::WCHAR; 128], pub DeviceKey: [::WCHAR; 128], } impl Clone for DISPLAY_DEVICEW { fn clone(&self) -> DISPLAY_DEVICEW { *self } } pub type PDISPLAY_DEVICEW = *mut DISPLAY_DEVICEW; pub type LPDISPLAY_DEVICEW = *mut DISPLAY_DEVICEW; #[repr(C)] #[derive(Copy)] pub struct DISPLAY_DEVICEA { pub cb: ::DWORD, pub DeviceName: [::CHAR; 32], pub DeviceString: [::CHAR; 128], pub StateFlags: ::DWORD, pub DeviceID: [::CHAR; 128], pub DeviceKey: [::CHAR; 128], } impl Clone for DISPLAY_DEVICEA { fn clone(&self) -> DISPLAY_DEVICEA { *self } } pub type PDISPLAY_DEVICEA = *mut DISPLAY_DEVICEA; pub type LPDISPLAY_DEVICEA = *mut DISPLAY_DEVICEA; STRUCT!{struct PIXELFORMATDESCRIPTOR { nSize: ::WORD, nVersion: ::WORD, dwFlags: ::DWORD, iPixelType: ::BYTE, cColorBits: ::BYTE, cRedBits: ::BYTE, cRedShift: ::BYTE, cGreenBits: ::BYTE, cGreenShift: ::BYTE, cBlueBits: ::BYTE, cBlueShift: ::BYTE, cAlphaBits: ::BYTE, cAlphaShift: ::BYTE, cAccumBits: ::BYTE, cAccumRedBits: ::BYTE, cAccumGreenBits: ::BYTE, cAccumBlueBits: ::BYTE, cAccumAlphaBits: ::BYTE, cDepthBits: ::BYTE, cStencilBits: ::BYTE, cAuxBuffers: ::BYTE, iLayerType: ::BYTE, bReserved: ::BYTE, dwLayerMask: ::DWORD, dwVisibleMask: ::DWORD, dwDamageMask: ::DWORD, }} pub type PPIXELFORMATDESCRIPTOR = *mut PIXELFORMATDESCRIPTOR; pub type LPPIXELFORMATDESCRIPTOR = *mut PIXELFORMATDESCRIPTOR; pub const R2_BLACK: ::c_int = 1; pub const R2_NOTMERGEPEN: ::c_int = 2; pub const R2_MASKNOTPEN: ::c_int = 3; pub const R2_NOTCOPYPEN: ::c_int = 4; pub const R2_MASKPENNOT: ::c_int = 5; pub const R2_NOT: ::c_int = 6; pub const R2_XORPEN: ::c_int = 7; pub const R2_NOTMASKPEN: ::c_int = 8; pub const R2_MASKPEN: ::c_int = 9; pub const R2_NOTXORPEN: ::c_int = 10; pub const R2_NOP: ::c_int = 11; pub const R2_MERGENOTPEN: ::c_int = 12; pub const R2_COPYPEN: ::c_int = 13; pub const R2_MERGEPENNOT: ::c_int = 14; pub const R2_MERGEPEN: ::c_int = 15; pub const R2_WHITE: ::c_int = 16; pub const R2_LAST: ::c_int = 16; //83 pub const SRCCOPY: ::DWORD = 0x00CC0020; pub const SRCPAINT: ::DWORD = 0x00EE0086; pub const SRCAND: ::DWORD = 0x008800C6; pub const SRCINVERT: ::DWORD = 0x00660046; pub const SRCERASE: ::DWORD = 0x00440328; pub const NOTSRCCOPY: ::DWORD = 0x00330008; pub const NOTSRCERASE: ::DWORD = 0x001100A6; pub const MERGECOPY: ::DWORD = 0x00C000CA; pub const MERGEPAINT: ::DWORD = 0x00BB0226; pub const PATCOPY: ::DWORD = 0x00F00021; pub const PATPAINT: ::DWORD = 0x00FB0A09; pub const PATINVERT: ::DWORD = 0x005A0049; pub const DSTINVERT: ::DWORD = 0x00550009; pub const BLACKNESS: ::DWORD = 0x00000042; pub const WHITENESS: ::DWORD = 0x00FF0062; //121 // fnCombineMode values for CombineRgn pub const RGN_AND: ::c_int = 1; pub const RGN_OR: ::c_int = 2; pub const RGN_XOR: ::c_int = 3; pub const RGN_DIFF: ::c_int = 4; pub const RGN_COPY: ::c_int = 5; pub const RGN_MIN: ::c_int = RGN_AND; pub const RGN_MAX: ::c_int = RGN_COPY; //572 (Win 7 SDK) STRUCT!{struct BITMAP { bmType: ::LONG, bmWidth: ::LONG, bmHeight: ::LONG, bmWidthBytes: ::LONG, bmPlanes: ::WORD, bmBitsPixel: ::WORD, bmBits: ::LPVOID, }} pub type PBITMAP = *mut BITMAP; pub type NPBITMAP = *mut BITMAP; pub type LPBITMAP = *mut BITMAP; STRUCT!{struct RGBQUAD { rgbBlue: ::BYTE, rgbGreen: ::BYTE, rgbRed: ::BYTE, rgbReserved: ::BYTE, }} pub type LPRGBQUAD = *mut RGBQUAD; pub const CS_ENABLE: ::DWORD = 0x00000001; pub const CS_DISABLE: ::DWORD = 0x00000002; pub const CS_DELETE_TRANSFORM: ::DWORD = 0x00000003; pub const LCS_SIGNATURE: ::DWORD = 0x5053_4F43; // 'PSOC' pub const LCS_sRGB: LCSCSTYPE = 0x7352_4742; // 'sRGB' pub const LCS_WINDOWS_COLOR_SPACE: LCSCSTYPE = 0x5769_6E20; // 'Win ' pub type LCSCSTYPE = ::LONG; pub const LCS_CALIBRATED_RGB: LCSCSTYPE = 0x00000000; pub type LCSGAMUTMATCH = ::LONG; pub const LCS_GM_BUSINESS: LCSGAMUTMATCH = 0x00000001; pub const LCS_GM_GRAPHICS: LCSGAMUTMATCH = 0x00000002; pub const LCS_GM_IMAGES: LCSGAMUTMATCH = 0x00000004; pub const LCS_GM_ABS_COLORIMETRIC: LCSGAMUTMATCH = 0x00000008; pub const CM_OUT_OF_GAMUT: ::BYTE = 255; pub const CM_IN_GAMUT: ::BYTE = 0; pub const ICM_ADDPROFILE: ::UINT = 1; pub const ICM_DELETEPROFILE: ::UINT = 2; pub const ICM_QUERYPROFILE: ::UINT = 3; pub const ICM_SETDEFAULTPROFILE: ::UINT = 4; pub const ICM_REGISTERICMATCHER: ::UINT = 5; pub const ICM_UNREGISTERICMATCHER: ::UINT = 6; pub const ICM_QUERYMATCH: ::UINT = 7; pub type FXPT16DOT16 = ::c_long; pub type LPFXPT16DOT16 = *mut ::c_long; pub type FXPT2DOT30 = ::c_long; pub type LPFXPT2DOT30 = *mut ::c_long; STRUCT!{struct CIEXYZ { ciexyzX: FXPT2DOT30, ciexyzY: FXPT2DOT30, ciexyzZ: FXPT2DOT30, }} pub type LPCIEXYZ = *mut CIEXYZ; STRUCT!{struct CIEXYZTRIPLE { ciexyzRed: CIEXYZ, ciexyzGreen: CIEXYZ, ciexyzBlue: CIEXYZ, }} pub type LPCIEXYZTRIPLE = *mut CIEXYZTRIPLE; //716 (Win 7 SDK) STRUCT!{struct BITMAPINFOHEADER { biSize: ::DWORD, biWidth: ::LONG, biHeight: ::LONG, biPlanes: ::WORD, biBitCount: ::WORD, biCompression: ::DWORD, biSizeImage: ::DWORD, biXPelsPerMeter: ::LONG, biYPelsPerMeter: ::LONG, biClrUsed: ::DWORD, biClrImportant: ::DWORD, }} pub type LPBITMAPINFOHEADER = *mut BITMAPINFOHEADER; pub type PBITMAPINFOHEADER = *mut BITMAPINFOHEADER; STRUCT!{struct BITMAPV5HEADER { bV5Size: ::DWORD, bV5Width: ::LONG, bV5Height: ::LONG, bV5Planes: ::WORD, bV5BitCount: ::WORD, bV5Compression: ::DWORD, bV5SizeImage: ::DWORD, bV5XPelsPerMeter: ::LONG, bV5YPelsPerMeter: ::LONG, bV5ClrUsed: ::DWORD, bV5ClrImportant: ::DWORD, bV5RedMask: ::DWORD, bV5GreenMask: ::DWORD, bV5BlueMask: ::DWORD, bV5AlphaMask: ::DWORD, bV5CSType: ::LONG, // LONG to match LOGCOLORSPACE bV5Endpoints: CIEXYZTRIPLE, bV5GammaRed: ::DWORD, bV5GammaGreen: ::DWORD, bV5GammaBlue: ::DWORD, bV5Intent: ::LONG, // LONG to match LOGCOLORSPACE bV5ProfileData: ::DWORD, bV5ProfileSize: ::DWORD, bV5Reserved: ::DWORD, }} pub type LPBITMAPV5HEADER = *mut BITMAPV5HEADER; pub type PBITMAPV5HEADER = *mut BITMAPV5HEADER; pub const PROFILE_LINKED: ::LONG = 0x4C49_4E4B; // 'LINK' pub const PROFILE_EMBEDDED: ::LONG = 0x4D42_4544; // 'MBED' pub const BI_RGB: ::DWORD = 0; pub const BI_RLE8: ::DWORD = 1; pub const BI_RLE4: ::DWORD = 2; pub const BI_BITFIELDS: ::DWORD = 3; pub const BI_JPEG: ::DWORD = 4; pub const BI_PNG: ::DWORD = 5; #[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct BITMAPINFO { pub bmiHeader: BITMAPINFOHEADER, pub bmiColors: [RGBQUAD; 0], } pub type LPBITMAPINFO = *mut BITMAPINFO; pub type PBITMAPINFO = *mut BITMAPINFO; //1438 pub const LF_FACESIZE: usize = 32; #[repr(C)] #[derive(Copy, Clone)] pub struct LOGFONTA { pub lfHeight: ::LONG, pub lfWidth: ::LONG, pub lfEscapement: ::LONG, pub lfOrientation: ::LONG, pub lfWeight: ::LONG, pub lfItalic: ::BYTE, pub lfUnderline: ::BYTE, pub lfStrikeOut: ::BYTE, pub lfCharSet: ::BYTE, pub lfOutPrecision: ::BYTE, pub lfClipPrecision: ::BYTE, pub lfQuality: ::BYTE, pub lfPitchAndFamily: ::BYTE, pub lfFaceName: [::CHAR; LF_FACESIZE], } pub type LPLOGFONTA = *mut LOGFONTA; #[repr(C)] #[derive(Copy, Clone)] pub struct LOGFONTW { pub lfHeight: ::LONG, pub lfWidth: ::LONG, pub lfEscapement: ::LONG, pub lfOrientation: ::LONG, pub lfWeight: ::LONG, pub lfItalic: ::BYTE, pub lfUnderline: ::BYTE, pub lfStrikeOut: ::BYTE, pub lfCharSet: ::BYTE, pub lfOutPrecision: ::BYTE, pub lfClipPrecision: ::BYTE, pub lfQuality: ::BYTE, pub lfPitchAndFamily: ::BYTE, pub lfFaceName: [::WCHAR; LF_FACESIZE], } pub type LPLOGFONTW = *mut LOGFONTW; //1595 #[inline] pub fn RGB (r: ::BYTE, g: ::BYTE, b: ::BYTE) -> ::COLORREF { r as ::COLORREF | ((g as ::COLORREF) << 8) | ((b as ::COLORREF) << 16) } // pub const DRIVERVERSION: ::c_int = 0; pub const TECHNOLOGY: ::c_int = 2; pub const HORZSIZE: ::c_int = 4; pub const VERTSIZE: ::c_int = 6; pub const HORZRES: ::c_int = 8; pub const VERTRES: ::c_int = 10; pub const BITSPIXEL: ::c_int = 12; pub const PLANES: ::c_int = 14; pub const NUMBRUSHES: ::c_int = 16; pub const NUMPENS: ::c_int = 18; pub const NUMMARKERS: ::c_int = 20; pub const NUMFONTS: ::c_int = 22; pub const NUMCOLORS: ::c_int = 24; pub const PDEVICESIZE: ::c_int = 26; pub const CURVECAPS: ::c_int = 28; pub const LINECAPS: ::c_int = 30; pub const POLYGONALCAPS: ::c_int = 32; pub const TEXTCAPS: ::c_int = 34; pub const CLIPCAPS: ::c_int = 36; pub const RASTERCAPS: ::c_int = 38; pub const ASPECTX: ::c_int = 40; pub const ASPECTY: ::c_int = 42; pub const ASPECTXY: ::c_int = 44; pub const LOGPIXELSX: ::c_int = 88; pub const LOGPIXELSY: ::c_int = 90; pub const SIZEPALETTE: ::c_int = 104; pub const NUMRESERVED: ::c_int = 106; pub const COLORRES: ::c_int = 108; pub const PHYSICALWIDTH: ::c_int = 110; pub const PHYSICALHEIGHT: ::c_int = 111; pub const PHYSICALOFFSETX: ::c_int = 112; pub const PHYSICALOFFSETY: ::c_int = 113; pub const SCALINGFACTORX: ::c_int = 114; pub const SCALINGFACTORY: ::c_int = 115; pub const VREFRESH: ::c_int = 116; pub const DESKTOPVERTRES: ::c_int = 117; pub const DESKTOPHORZRES: ::c_int = 118; pub const BLTALIGNMENT: ::c_int = 119; pub const SHADEBLENDCAPS: ::c_int = 120; pub const COLORMGMTCAPS: ::c_int = 121; //1906 pub const DIB_RGB_COLORS: ::UINT = 0; pub const DIB_PAL_COLORS: ::UINT = 1; pub const CBM_INIT: ::DWORD = 4; STRUCT!{struct RGNDATAHEADER { dwSize: ::DWORD, iType: ::DWORD, nCount: ::DWORD, nRgnSize: ::DWORD, rcBound: ::RECT, }} pub type PRGNDATAHEADER = *mut RGNDATAHEADER; #[repr(C)] #[derive(Debug)] #[allow(missing_copy_implementations)] pub struct RGNDATA { pub rdh: RGNDATAHEADER, pub Buffer: [::c_char; 0], } pub type PRGNDATA = *mut RGNDATA; pub type NPRGNDATA = *mut RGNDATA; pub type LPRGNDATA = *mut RGNDATA; STRUCT!{struct PALETTEENTRY { peRed: ::BYTE, peGreen: ::BYTE, peBlue: ::BYTE, peFlags: ::BYTE, }} pub type PPALETTEENTRY = *mut PALETTEENTRY; pub type LPPALETTEENTRY = *mut PALETTEENTRY; //2824 (Win 7 SDK) STRUCT!{struct ABC { abcA: ::c_int, abcB: ::UINT, abcC: ::c_int, }} pub type PABC = *mut ABC; pub type NPABC = *mut ABC; pub type LPABC = *mut ABC; STRUCT!{struct ABCFLOAT { abcfA: ::FLOAT, abcfB: ::FLOAT, abcfC: ::FLOAT, }} pub type PABCFLOAT = *mut ABCFLOAT; pub type NPABCFLOAT = *mut ABCFLOAT; pub type LPABCFLOAT = *mut ABCFLOAT; //3581 pub type LINEDDAPROC = Option; STRUCT!{struct XFORM { eM11: ::FLOAT, eM12: ::FLOAT, eM21: ::FLOAT, eM22: ::FLOAT, eDx: ::FLOAT, eDy: ::FLOAT, }} pub type PXFORM = *mut XFORM; pub type LPXFORM = *mut XFORM; STRUCT!{struct LOGBRUSH { lbStyle: ::UINT, lbColor: ::COLORREF, lbHatch: ::ULONG_PTR, }} pub type PLOGBRUSH = *mut LOGBRUSH; #[repr(C)] #[derive(Copy)] pub struct LOGCOLORSPACEA { pub lcsSignature: ::DWORD, pub lcsVersion: ::DWORD, pub lcsSize: ::DWORD, pub lcsCSType: LCSCSTYPE, pub lcsIntent: LCSGAMUTMATCH, pub lcsEndpoints: CIEXYZTRIPLE, pub lcsGammaRed: ::DWORD, pub lcsGammaGreen: ::DWORD, pub lcsGammaBlue: ::DWORD, pub lcsFilename: [::CHAR; ::MAX_PATH], } impl Clone for LOGCOLORSPACEA { fn clone(&self) -> LOGCOLORSPACEA { *self } } pub type LPLOGCOLORSPACEA = *mut LOGCOLORSPACEA; #[repr(C)] #[derive(Copy)] pub struct LOGCOLORSPACEW { pub lcsSignature: ::DWORD, pub lcsVersion: ::DWORD, pub lcsSize: ::DWORD, pub lcsCSType: LCSCSTYPE, pub lcsIntent: LCSGAMUTMATCH, pub lcsEndpoints: CIEXYZTRIPLE, pub lcsGammaRed: ::DWORD, pub lcsGammaGreen: ::DWORD, pub lcsGammaBlue: ::DWORD, pub lcsFilename: [::WCHAR; ::MAX_PATH], } impl Clone for LOGCOLORSPACEW { fn clone(&self) -> LOGCOLORSPACEW { *self } } pub type LPLOGCOLORSPACEW = *mut LOGCOLORSPACEW; pub const LF_FULLFACESIZE: usize = 64; #[repr(C)] #[derive(Copy)] pub struct ENUMLOGFONTEXA { pub elfLogFont: LOGFONTA, pub elfFullName: [::BYTE; LF_FULLFACESIZE], pub elfStyle: [::BYTE; LF_FACESIZE], pub elfScript: [::BYTE; LF_FACESIZE], } impl Clone for ENUMLOGFONTEXA { fn clone(&self) -> ENUMLOGFONTEXA { *self } } pub type LPENUMLOGFONTEXA = *mut ENUMLOGFONTEXA; #[repr(C)] #[derive(Copy)] pub struct ENUMLOGFONTEXW { pub elfLogFont: LOGFONTW, pub elfFullName: [::WCHAR; LF_FULLFACESIZE], pub elfStyle: [::WCHAR; LF_FACESIZE], pub elfScript: [::WCHAR; LF_FACESIZE], } impl Clone for ENUMLOGFONTEXW { fn clone(&self) -> ENUMLOGFONTEXW { *self } } pub type LPENUMLOGFONTEXW = *mut ENUMLOGFONTEXW; pub const MM_MAX_NUMAXES: usize = 16; STRUCT!{struct DESIGNVECTOR { dvReserved: ::DWORD, dvNumAxes: ::DWORD, dvValues: [::LONG; MM_MAX_NUMAXES], }} pub type PDESIGNVECTOR = *mut DESIGNVECTOR; pub type LPDESIGNVECTOR = *mut DESIGNVECTOR; #[repr(C)] #[derive(Clone, Copy)] pub struct ENUMLOGFONTEXDVA { pub elfEnumLogfontEx: ENUMLOGFONTEXA, pub elfDesignVector: DESIGNVECTOR, } pub type PENUMLOGFONTEXDVA = *mut ENUMLOGFONTEXDVA; pub type LPENUMLOGFONTEXDVA = *mut ENUMLOGFONTEXDVA; #[repr(C)] #[derive(Clone, Copy)] pub struct ENUMLOGFONTEXDVW { pub elfEnumLogfontEx: ENUMLOGFONTEXW, pub elfDesignVector: DESIGNVECTOR, } pub type PENUMLOGFONTEXDVW = *mut ENUMLOGFONTEXDVW; pub type LPENUMLOGFONTEXDVW = *mut ENUMLOGFONTEXDVW; STRUCT!{struct LOGPALETTE { palVersion: ::WORD, palNumEntries: ::WORD, palPalEntry: [PALETTEENTRY; 1], }} pub type PLOGPALETTE = *mut LOGPALETTE; pub type NPLOGPALETTE = *mut LOGPALETTE; pub type LPLOGPALETTE = *mut LOGPALETTE; STRUCT!{struct LOGPEN { lopnStyle: ::UINT, lopnWidth: ::POINT, lopnColor: ::COLORREF, }} pub type PLOGPEN = *mut LOGPEN; pub type NPLOGPEN = *mut LOGPEN; pub type LPLOGPEN = *mut LOGPEN; STRUCT!{struct BLENDFUNCTION { BlendOp: ::BYTE, BlendFlags: ::BYTE, SourceConstantAlpha: ::BYTE, AlphaFormat: ::BYTE, }} pub type PBLENDFUNCTION = *mut BLENDFUNCTION; pub const TMPF_FIXED_PITCH: ::BYTE = 0x01; pub const TMPF_VECTOR: ::BYTE = 0x02; pub const TMPF_DEVICE: ::BYTE = 0x08; pub const TMPF_TRUETYPE: ::BYTE = 0x04; STRUCT!{struct TEXTMETRICA { tmHeight: ::LONG, tmAscent: ::LONG, tmDescent: ::LONG, tmInternalLeading: ::LONG, tmExternalLeading: ::LONG, tmAveCharWidth: ::LONG, tmMaxCharWidth: ::LONG, tmWeight: ::LONG, tmOverhang: ::LONG, tmDigitizedAspectX: ::LONG, tmDigitizedAspectY: ::LONG, tmFirstChar: ::BYTE, tmLastChar: ::BYTE, tmDefaultChar: ::BYTE, tmBreakChar: ::BYTE, tmItalic: ::BYTE, tmUnderlined: ::BYTE, tmStruckOut: ::BYTE, tmPitchAndFamily: ::BYTE, tmCharSet: ::BYTE, }} pub type PTEXTMETRICA = *mut TEXTMETRICA; pub type NPTEXTMETRICA = *mut TEXTMETRICA; pub type LPTEXTMETRICA = *mut TEXTMETRICA; STRUCT!{struct TEXTMETRICW { tmHeight: ::LONG, tmAscent: ::LONG, tmDescent: ::LONG, tmInternalLeading: ::LONG, tmExternalLeading: ::LONG, tmAveCharWidth: ::LONG, tmMaxCharWidth: ::LONG, tmWeight: ::LONG, tmOverhang: ::LONG, tmDigitizedAspectX: ::LONG, tmDigitizedAspectY: ::LONG, tmFirstChar: ::WCHAR, tmLastChar: ::WCHAR, tmDefaultChar: ::WCHAR, tmBreakChar: ::WCHAR, tmItalic: ::BYTE, tmUnderlined: ::BYTE, tmStruckOut: ::BYTE, tmPitchAndFamily: ::BYTE, tmCharSet: ::BYTE, }} pub type PTEXTMETRICW = *mut TEXTMETRICW; pub type NPTEXTMETRICW = *mut TEXTMETRICW; pub type LPTEXTMETRICW = *mut TEXTMETRICW; pub const TA_NOUPDATECP: ::UINT = 0; pub const TA_UPDATECP: ::UINT = 1; pub const TA_LEFT: ::UINT = 0; pub const TA_RIGHT: ::UINT = 2; pub const TA_CENTER: ::UINT = 6; pub const TA_TOP: ::UINT = 0; pub const TA_BOTTOM: ::UINT = 8; pub const TA_BASELINE: ::UINT = 24; pub const TA_RTLREADING: ::UINT = 256; pub const TA_MASK: ::UINT = TA_BASELINE + TA_CENTER + TA_UPDATECP + TA_RTLREADING; pub const WHITE_BRUSH: ::c_int = 0; pub const LTGRAY_BRUSH: ::c_int = 1; pub const GRAY_BRUSH: ::c_int = 2; pub const DKGRAY_BRUSH: ::c_int = 3; pub const BLACK_BRUSH: ::c_int = 4; pub const NULL_BRUSH: ::c_int = 5; pub const HOLLOW_BRUSH: ::c_int = 5; pub const WHITE_PEN: ::c_int = 6; pub const BLACK_PEN: ::c_int = 7; pub const NULL_PEN: ::c_int = 8; pub const OEM_FIXED_FONT: ::c_int = 10; pub const ANSI_FIXED_FONT: ::c_int = 11; pub const ANSI_VAR_FONT: ::c_int = 12; pub const SYSTEM_FONT: ::c_int = 13; pub const DEVICE_DEFAULT_FONT: ::c_int = 14; pub const DEFAULT_PALETTE: ::c_int = 15; pub const SYSTEM_FIXED_FONT: ::c_int = 16; pub const DEFAULT_GUI_FONT: ::c_int = 17; pub const DC_BRUSH: ::c_int = 18; pub const DC_PEN: ::c_int = 19; pub const STOCK_LAST: ::c_int = 19;pub const PS_SOLID: ::c_int = 0; pub const PS_DASH: ::c_int = 1; pub const PS_DOT: ::c_int = 2; pub const PS_DASHDOT: ::c_int = 3; pub const PS_DASHDOTDOT: ::c_int = 4; pub const PS_NULL: ::c_int = 5; pub const PS_INSIDEFRAME: ::c_int = 6; pub const PS_USERSTYLE: ::c_int = 7; pub const PS_ALTERNATE: ::c_int = 8; pub const TRANSPARENT: ::c_int = 1; pub const OPAQUE: ::c_int = 2; pub const BKMODE_LAST: ::c_int = 2; pub const MM_TEXT: ::c_int = 1; pub const MM_LOMETRIC: ::c_int = 2; pub const MM_HIMETRIC: ::c_int = 3; pub const MM_LOENGLISH: ::c_int = 4; pub const MM_HIENGLISH: ::c_int = 5; pub const MM_TWIPS: ::c_int = 6; pub const MM_ISOTROPIC: ::c_int = 7; pub const MM_ANISOTROPIC: ::c_int = 8; pub const ALTERNATE: ::c_int = 1; pub const WINDING: ::c_int = 2; pub const POLYFILL_LAST: ::c_int = 2; pub const OUT_DEFAULT_PRECIS: ::DWORD = 0; pub const OUT_STRING_PRECIS: ::DWORD = 1; pub const OUT_CHARACTER_PRECIS: ::DWORD = 2; pub const OUT_STROKE_PRECIS: ::DWORD = 3; pub const OUT_TT_PRECIS: ::DWORD = 4; pub const OUT_DEVICE_PRECIS: ::DWORD = 5; pub const OUT_RASTER_PRECIS: ::DWORD = 6; pub const OUT_TT_ONLY_PRECIS: ::DWORD = 7; pub const OUT_OUTLINE_PRECIS: ::DWORD = 8; pub const OUT_SCREEN_OUTLINE_PRECIS: ::DWORD = 9; pub const OUT_PS_ONLY_PRECIS: ::DWORD = 10; pub const CLIP_DEFAULT_PRECIS: ::DWORD = 0; pub const CLIP_CHARACTER_PRECIS: ::DWORD = 1; pub const CLIP_STROKE_PRECIS: ::DWORD = 2; pub const CLIP_MASK: ::DWORD = 0xf; pub const CLIP_LH_ANGLES: ::DWORD = 1 << 4; pub const CLIP_TT_ALWAYS: ::DWORD = 2 << 4; pub const CLIP_DFA_DISABLE: ::DWORD = 4 << 4; pub const CLIP_EMBEDDED: ::DWORD = 8 << 4; pub const DEFAULT_QUALITY: ::DWORD = 0; pub const DRAFT_QUALITY: ::DWORD = 1; pub const PROOF_QUALITY: ::DWORD = 2; pub const NONANTIALIASED_QUALITY: ::DWORD = 3; pub const ANTIALIASED_QUALITY: ::DWORD = 4; pub const CLEARTYPE_QUALITY: ::DWORD = 5; pub const CLEARTYPE_NATURAL_QUALITY: ::DWORD = 6; pub const DEFAULT_PITCH: ::DWORD = 0; pub const FIXED_PITCH: ::DWORD = 1; pub const VARIABLE_PITCH: ::DWORD = 2; pub const MONO_FONT: ::DWORD = 8; pub const ANSI_CHARSET: ::DWORD = 0; pub const DEFAULT_CHARSET: ::DWORD = 1; pub const SYMBOL_CHARSET: ::DWORD = 2; pub const SHIFTJIS_CHARSET: ::DWORD = 128; pub const HANGEUL_CHARSET: ::DWORD = 129; pub const HANGUL_CHARSET: ::DWORD = 129; pub const GB2312_CHARSET: ::DWORD = 134; pub const CHINESEBIG5_CHARSET: ::DWORD = 136; pub const OEM_CHARSET: ::DWORD = 255; pub const JOHAB_CHARSET: ::DWORD = 130; pub const HEBREW_CHARSET: ::DWORD = 177; pub const ARABIC_CHARSET: ::DWORD = 178; pub const GREEK_CHARSET: ::DWORD = 161; pub const TURKISH_CHARSET: ::DWORD = 162; pub const VIETNAMESE_CHARSET: ::DWORD = 163; pub const THAI_CHARSET: ::DWORD = 222; pub const EASTEUROPE_CHARSET: ::DWORD = 238; pub const RUSSIAN_CHARSET: ::DWORD = 204; pub const MAC_CHARSET: ::DWORD = 77; pub const BALTIC_CHARSET: ::DWORD = 186; pub const FS_LATIN1: ::DWORD = 0x00000001; pub const FS_LATIN2: ::DWORD = 0x00000002; pub const FS_CYRILLIC: ::DWORD = 0x00000004; pub const FS_GREEK: ::DWORD = 0x00000008; pub const FS_TURKISH: ::DWORD = 0x00000010; pub const FS_HEBREW: ::DWORD = 0x00000020; pub const FS_ARABIC: ::DWORD = 0x00000040; pub const FS_BALTIC: ::DWORD = 0x00000080; pub const FS_VIETNAMESE: ::DWORD = 0x00000100; pub const FS_THAI: ::DWORD = 0x00010000; pub const FS_JISJAPAN: ::DWORD = 0x00020000; pub const FS_CHINESESIMP: ::DWORD = 0x00040000; pub const FS_WANSUNG: ::DWORD = 0x00080000; pub const FS_CHINESETRAD: ::DWORD = 0x00100000; pub const FS_JOHAB: ::DWORD = 0x00200000; pub const FS_SYMBOL: ::DWORD = 0x80000000; pub const FW_DONTCARE: ::c_int = 0; pub const FW_THIN: ::c_int = 100; pub const FW_EXTRALIGHT: ::c_int = 200; pub const FW_LIGHT: ::c_int = 300; pub const FW_NORMAL: ::c_int = 400; pub const FW_MEDIUM: ::c_int = 500; pub const FW_SEMIBOLD: ::c_int = 600; pub const FW_BOLD: ::c_int = 700; pub const FW_EXTRABOLD: ::c_int = 800; pub const FW_HEAVY: ::c_int = 900; pub const FW_ULTRALIGHT: ::c_int = FW_EXTRALIGHT; pub const FW_REGULAR: ::c_int = FW_NORMAL; pub const FW_DEMIBOLD: ::c_int = FW_SEMIBOLD; pub const FW_ULTRABOLD: ::c_int = FW_EXTRABOLD; pub const FW_BLACK: ::c_int = FW_HEAVY; pub type COLOR16 = ::c_ushort; STRUCT!{struct TRIVERTEX { x: ::LONG, y: ::LONG, Red: COLOR16, Green: COLOR16, Blue: COLOR16, Alpha: COLOR16, }} pub type PTRIVERTEX = *mut TRIVERTEX; pub type LPTRIVERTEX = *mut TRIVERTEX; STRUCT!{struct GRADIENT_RECT { UpperLeft: ::ULONG, LowerRight: ::ULONG, }} pub type PGRADIENT_RECT = *mut GRADIENT_RECT; pub type LPGRADIENT_RECT = *mut GRADIENT_RECT; /* Object Definitions for EnumObjects() */ pub const OBJ_PEN: ::UINT = 1; pub const OBJ_BRUSH: ::UINT = 2; pub const OBJ_DC: ::UINT = 3; pub const OBJ_METADC: ::UINT = 4; pub const OBJ_PAL: ::UINT = 5; pub const OBJ_FONT: ::UINT = 6; pub const OBJ_BITMAP: ::UINT = 7; pub const OBJ_REGION: ::UINT = 8; pub const OBJ_METAFILE: ::UINT = 9; pub const OBJ_MEMDC: ::UINT = 10; pub const OBJ_EXTPEN: ::UINT = 11; pub const OBJ_ENHMETADC: ::UINT = 12; pub const OBJ_ENHMETAFILE: ::UINT = 13; pub const OBJ_COLORSPACE: ::UINT = 14; pub const GDI_OBJ_LAST: ::UINT = OBJ_COLORSPACE; STRUCT!{struct COLORADJUSTMENT { caSize: ::WORD, caFlags: ::WORD, caIlluminantIndex: ::WORD, caRedGamma: ::WORD, caGreenGamma: ::WORD, caBlueGamma: ::WORD, caReferenceBlack: ::WORD, caReferenceWhite: ::WORD, caContrast: ::SHORT, caBrightness: ::SHORT, caColorfulness: ::SHORT, caRedGreenTint: ::SHORT, }} pub type PCOLORADJUSTMENT = *mut COLORADJUSTMENT; pub type LPCOLORADJUSTMENT = *mut COLORADJUSTMENT; pub type OLDFONTENUMPROCA = Option ::c_int>; pub type OLDFONTENUMPROCW = Option ::c_int>; pub type FONTENUMPROCA = OLDFONTENUMPROCA; pub type FONTENUMPROCW = OLDFONTENUMPROCW; STRUCT!{struct WCRANGE { wcLow: ::WCHAR, cGlyphs: ::USHORT, }} pub type PWCRANGE = *mut WCRANGE; pub type LPWCRANGE = *mut WCRANGE; STRUCT!{struct GLYPHSET { cbThis: ::DWORD, flAccel: ::DWORD, cGlyphsSupported: ::DWORD, cRanges: ::DWORD, ranges: [WCRANGE;1], }} pub type PGLYPHSET = *mut GLYPHSET; pub type LPGLYPHSET = *mut GLYPHSET; pub type ABORTPROC = Option ::BOOL>; STRUCT!{struct DOCINFOA { cbSize: ::c_int, lpszDocName: ::LPCSTR, lpszOutput: ::LPCSTR, lpszDatatype: ::LPCSTR, fwType: ::DWORD, }} pub type LPDOCINFOA = *mut DOCINFOA; STRUCT!{struct DOCINFOW { cbSize: ::c_int, lpszDocName: ::LPCWSTR, lpszOutput: ::LPCWSTR, lpszDatatype: ::LPCWSTR, fwType: ::DWORD, }} pub type LPDOCINFOW = *mut DOCINFOW; pub type ICMENUMPROCA = Option ::c_int>; pub type ICMENUMPROCW = Option ::c_int>; STRUCT!{struct HANDLETABLE { objectHandle: [::HGDIOBJ; 1], }} pub type LPHANDLETABLE = *mut HANDLETABLE; pub type PHANDLETABLE = *mut HANDLETABLE; STRUCT!{struct METARECORD { rdSize: ::DWORD, rdFunction: ::WORD, rdParm: [::WORD; 1], }} pub type PMETARECORD = *mut METARECORD; pub type LPMETARECORD = *mut METARECORD; pub type MFENUMPROC = Option ::c_int>; pub type GOBJENUMPROC = Option ::c_int>; STRUCT!{struct GCP_RESULTSA { lStructSize: ::DWORD, lpOutString: ::LPSTR, lpOrder: *const ::UINT, lpDx: *const ::c_int, lpCaretPos: *const ::c_int, lpClass: ::LPSTR, lpGlyphs: ::LPWSTR, nGlyphs: ::UINT, nMaxFit: ::c_int, }} pub type LPGCP_RESULTSA = *mut GCP_RESULTSA; STRUCT!{struct GCP_RESULTSW { lStructSize: ::DWORD, lpOutString: ::LPWSTR, lpOrder: *const ::UINT, lpDx: *const ::c_int, lpCaretPos: *const ::c_int, lpClass: ::LPSTR, lpGlyphs: ::LPWSTR, nGlyphs: ::UINT, nMaxFit: ::c_int, }} pub type LPGCP_RESULTSW = *mut GCP_RESULTSW; STRUCT!{struct FONTSIGNATURE { fsUsb: [::DWORD; 4], fsCsb: [::DWORD; 2], }} pub type LPFONTSIGNATURE = *mut FONTSIGNATURE; pub type PFONTSIGNATURE = *mut FONTSIGNATURE; STRUCT!{struct POLYTEXTA { x: ::c_int, y: ::c_int, n: ::UINT, lpstr: ::LPCSTR, uiFlags: ::UINT, rcl: ::RECT, pdx: *const ::c_int, }} pub type PPOLYTEXTA = *mut POLYTEXTA; pub type NPPOLYTEXTA = *mut POLYTEXTA; pub type LPPOLYTEXTA = *mut POLYTEXTA; STRUCT!{struct POLYTEXTW { x: ::c_int, y: ::c_int, n: ::UINT, lpstr: ::LPCWSTR, uiFlags: ::UINT, rcl: ::RECT, pdx: *const ::c_int, }} pub type PPOLYTEXTW = *mut POLYTEXTW; pub type NPPOLYTEXTW = *mut POLYTEXTW; pub type LPPOLYTEXTW = *mut POLYTEXTW; STRUCT!{struct CHARSETINFO { ciCharset: ::UINT, ciACP: ::UINT, fs: ::FONTSIGNATURE, }} pub type PCHARSETINFO = *mut CHARSETINFO; pub type NPCHARSETINFO = *mut CHARSETINFO; pub type LPCHARSETINFO = *mut CHARSETINFO; pub const GRADIENT_FILL_RECT_H: ::ULONG = 0x00000000; pub const GRADIENT_FILL_RECT_V: ::ULONG = 0x00000001; pub const GRADIENT_FILL_TRIANGLE: ::ULONG = 0x00000002; pub const GRADIENT_FILL_OP_FLAG: ::ULONG = 0x000000ff; STRUCT!{struct LAYERPLANEDESCRIPTOR { nSize: ::WORD, nVersion: ::WORD, dwFlags: ::DWORD, iPixelType: ::BYTE, cColorBits: ::BYTE, cRedBits: ::BYTE, cRedShift: ::BYTE, cGreenBits: ::BYTE, cGreenShift: ::BYTE, cBlueBits: ::BYTE, cBlueShift: ::BYTE, cAlphaBits: ::BYTE, cAlphaShift: ::BYTE, cAccumBits: ::BYTE, cAccumRedBits: ::BYTE, cAccumGreenBits: ::BYTE, cAccumBlueBits: ::BYTE, cAccumAlphaBits: ::BYTE, cDepthBits: ::BYTE, cStencilBits: ::BYTE, cAuxBuffers: ::BYTE, iLayerPlane: ::BYTE, bReserved: ::BYTE, crTransparent: ::COLORREF, }} pub type PLAYERPLANEDESCRIPTOR = *mut LAYERPLANEDESCRIPTOR; pub type LPLAYERPLANEDESCRIPTOR = *mut LAYERPLANEDESCRIPTOR; STRUCT!{struct ENHMETAHEADER { iType: ::DWORD, nSize: ::DWORD, rclBounds: ::RECTL, rclFrame: ::RECTL, dSignature: ::DWORD, nVersion: ::DWORD, nBytes: ::DWORD, nRecords: ::DWORD, nHandles: ::WORD, sReserved: ::WORD, nDescription: ::DWORD, offDescription: ::DWORD, nPalEntries: ::DWORD, szlDevice: ::SIZEL, szlMillimeters: ::SIZEL, cbPixelFormat: ::DWORD, offPixelFormat: ::DWORD, bOpenGL: ::DWORD, szlMicrometers: ::SIZEL, }} pub type PENHMETAHEADER = *mut ENHMETAHEADER; pub type LPENHMETAHEADER = *mut ENHMETAHEADER; STRUCT!{struct FIXED { fract: ::WORD, value: ::c_short, }} STRUCT!{struct MAT2 { eM11: FIXED, eM12: FIXED, eM21: FIXED, eM22: FIXED, }} pub type LPMAT2 = *mut MAT2; STRUCT!{struct GLYPHMETRICS { gmBlackBoxX: ::UINT, gmBlackBoxY: ::UINT, gmptGlyphOrigin: ::POINT, gmCellIncX: ::c_short, gmCellIncY: ::c_short, }} pub type LPGLYPHMETRICS = *mut GLYPHMETRICS; STRUCT!{struct KERNINGPAIR { wFirst: ::WORD, wSecond: ::WORD, iKernAmount: ::c_int, }} pub type LPKERNINGPAIR = *mut KERNINGPAIR; STRUCT!{struct PANOSE { bFamilyType: ::BYTE, bSerifStyle: ::BYTE, bWeight: ::BYTE, bProportion: ::BYTE, bContrast: ::BYTE, bStrokeVariation: ::BYTE, bArmStyle: ::BYTE, bLetterform: ::BYTE, bMidline: ::BYTE, bXHeight: ::BYTE, }} pub type LPPANOSE = *mut PANOSE; STRUCT!{struct OUTLINETEXTMETRICA { otmSize: ::UINT, otmTextMetrics: TEXTMETRICA, otmFiller: ::BYTE, otmPanoseNumber: ::PANOSE, otmfsSelection: ::UINT, otmfsType: ::UINT, otmsCharSlopeRise: ::c_int, otmsCharSlopeRun: ::c_int, otmItalicAngle: ::c_int, otmEMSquare: ::UINT, otmAscent: ::c_int, otmDescent: ::c_int, otmLineGap: ::UINT, otmsCapEmHeight: ::UINT, otmsXHeight: ::UINT, otmrcFontBox: ::RECT, otmMacAscent: ::c_int, otmMacDescent: ::c_int, otmMacLineGap: ::UINT, otmusMinimumPPEM: ::UINT, otmptSubscriptSize: ::POINT, otmptSubscriptOffset: ::POINT, otmptSuperscriptSize: ::POINT, otmptSuperscriptOffset: ::POINT, otmsStrikeoutSize: ::UINT, otmsStrikeoutPosition: ::c_int, otmsUnderscoreSize: ::c_int, otmsUnderscorePosition: ::c_int, otmpFamilyName: ::PSTR, otmpFaceName: ::PSTR, otmpStyleName: ::PSTR, otmpFullName: ::PSTR, }} pub type POUTLINETEXTMETRICA = *mut OUTLINETEXTMETRICA; pub type NPOUTLINETEXTMETRICA = *mut OUTLINETEXTMETRICA; pub type LPOUTLINETEXTMETRICA = *mut OUTLINETEXTMETRICA; STRUCT!{struct OUTLINETEXTMETRICW { otmSize: ::UINT, otmTextMetrics: TEXTMETRICW, otmFiller: ::BYTE, otmPanoseNumber: ::PANOSE, otmfsSelection: ::UINT, otmfsType: ::UINT, otmsCharSlopeRise: ::c_int, otmsCharSlopeRun: ::c_int, otmItalicAngle: ::c_int, otmEMSquare: ::UINT, otmAscent: ::c_int, otmDescent: ::c_int, otmLineGap: ::UINT, otmsCapEmHeight: ::UINT, otmsXHeight: ::UINT, otmrcFontBox: ::RECT, otmMacAscent: ::c_int, otmMacDescent: ::c_int, otmMacLineGap: ::UINT, otmusMinimumPPEM: ::UINT, otmptSubscriptSize: ::POINT, otmptSubscriptOffset: ::POINT, otmptSuperscriptSize: ::POINT, otmptSuperscriptOffset: ::POINT, otmsStrikeoutSize: ::UINT, otmsStrikeoutPosition: ::c_int, otmsUnderscoreSize: ::c_int, otmsUnderscorePosition: ::c_int, otmpFamilyName: ::PSTR, otmpFaceName: ::PSTR, otmpStyleName: ::PSTR, otmpFullName: ::PSTR, }} pub type POUTLINETEXTMETRICW = *mut OUTLINETEXTMETRICW; pub type NPOUTLINETEXTMETRICW = *mut OUTLINETEXTMETRICW; pub type LPOUTLINETEXTMETRICW = *mut OUTLINETEXTMETRICW; STRUCT!{struct RASTERIZER_STATUS { nSize: ::c_short, wFlags: ::c_short, nLanguageID: ::c_short, }} pub type LPRASTERIZER_STATUS = *mut RASTERIZER_STATUS; STRUCT!{struct ENHMETARECORD { iType: ::DWORD, nSize: ::DWORD, dParm: [::DWORD; 1], }} pub type PENHMETARECORD = *mut ENHMETARECORD; pub type LPENHMETARECORD = *mut ENHMETARECORD; STRUCT!{struct METAFILEPICT { mm: ::LONG, xExt: ::LONG, yExt: ::LONG, hMF: ::HMETAFILE, }} pub type LPMETAFILEPICT = *mut METAFILEPICT; STRUCT!{struct POINTFLOAT { x: ::FLOAT, y: ::FLOAT, }} pub type PPOINTFLOAT = *mut POINTFLOAT; STRUCT!{struct GLYPHMETRICSFLOAT { gmfBlackBoxX: ::FLOAT, gmfBlackBoxY: ::FLOAT, gmfptGlyphOrigin: POINTFLOAT, gmfCellIncX: ::FLOAT, gmfCellIncY: ::FLOAT, }} pub type PGLYPHMETRICSFLOAT = *mut GLYPHMETRICSFLOAT; pub type LPGLYPHMETRICSFLOAT = *mut GLYPHMETRICSFLOAT; pub const DT_PLOTTER: ::c_int = 0; pub const DT_RASDISPLAY: ::c_int = 1; pub const DT_RASPRINTER: ::c_int = 2; pub const DT_RASCAMERA: ::c_int = 3; pub const DT_CHARSTREAM: ::c_int = 4; pub const DT_METAFILE: ::c_int = 5; pub const DT_DISPFILE: ::c_int = 6; pub const CLR_INVALID: ::COLORREF = 0xFFFFFFFF; pub const ETO_OPAQUE: ::UINT = 0x0002; pub const ETO_CLIPPED: ::UINT = 0x0004; pub const ETO_GLYPH_INDEX: ::UINT = 0x0010; pub const ETO_RTLREADING: ::UINT = 0x0080; pub const ETO_NUMERICSLOCAL: ::UINT = 0x0400; pub const ETO_NUMERICSLATIN: ::UINT = 0x0800; pub const ETO_IGNORELANGUAGE: ::UINT = 0x1000; pub const ETO_PDY: ::UINT = 0x2000; pub const ETO_REVERSE_INDEX_MAP: ::UINT = 0x10000; STRUCT!{struct EXTLOGPEN { elpPenStyle: ::DWORD, elpWidth: ::DWORD, elpBrushStyle: ::UINT, elpColor: ::COLORREF, elpHatch: ::ULONG_PTR, elpNumEntries: ::DWORD, elpStyleEntry: [::DWORD; 1], }} pub type PEXTLOGPEN = *mut EXTLOGPEN; pub type NPEXTLOGPEN = *mut EXTLOGPEN; pub type LPEXTLOGPEN = *mut EXTLOGPEN; pub type ENHMFENUMPROC = Option ::c_int>; /* Metafile Functions */ pub const META_SETBKCOLOR: ::WORD = 0x0201; pub const META_SETBKMODE: ::WORD = 0x0102; pub const META_SETMAPMODE: ::WORD = 0x0103; pub const META_SETROP2: ::WORD = 0x0104; pub const META_SETRELABS: ::WORD = 0x0105; pub const META_SETPOLYFILLMODE: ::WORD = 0x0106; pub const META_SETSTRETCHBLTMODE: ::WORD = 0x0107; pub const META_SETTEXTCHAREXTRA: ::WORD = 0x0108; pub const META_SETTEXTCOLOR: ::WORD = 0x0209; pub const META_SETTEXTJUSTIFICATION: ::WORD = 0x020A; pub const META_SETWINDOWORG: ::WORD = 0x020B; pub const META_SETWINDOWEXT: ::WORD = 0x020C; pub const META_SETVIEWPORTORG: ::WORD = 0x020D; pub const META_SETVIEWPORTEXT: ::WORD = 0x020E; pub const META_OFFSETWINDOWORG: ::WORD = 0x020F; pub const META_SCALEWINDOWEXT: ::WORD = 0x0410; pub const META_OFFSETVIEWPORTORG: ::WORD = 0x0211; pub const META_SCALEVIEWPORTEXT: ::WORD = 0x0412; pub const META_LINETO: ::WORD = 0x0213; pub const META_MOVETO: ::WORD = 0x0214; pub const META_EXCLUDECLIPRECT: ::WORD = 0x0415; pub const META_INTERSECTCLIPRECT: ::WORD = 0x0416; pub const META_ARC: ::WORD = 0x0817; pub const META_ELLIPSE: ::WORD = 0x0418; pub const META_FLOODFILL: ::WORD = 0x0419; pub const META_PIE: ::WORD = 0x081A; pub const META_RECTANGLE: ::WORD = 0x041B; pub const META_ROUNDRECT: ::WORD = 0x061C; pub const META_PATBLT: ::WORD = 0x061D; pub const META_SAVEDC: ::WORD = 0x001E; pub const META_SETPIXEL: ::WORD = 0x041F; pub const META_OFFSETCLIPRGN: ::WORD = 0x0220; pub const META_TEXTOUT: ::WORD = 0x0521; pub const META_BITBLT: ::WORD = 0x0922; pub const META_STRETCHBLT: ::WORD = 0x0B23; pub const META_POLYGON: ::WORD = 0x0324; pub const META_POLYLINE: ::WORD = 0x0325; pub const META_ESCAPE: ::WORD = 0x0626; pub const META_RESTOREDC: ::WORD = 0x0127; pub const META_FILLREGION: ::WORD = 0x0228; pub const META_FRAMEREGION: ::WORD = 0x0429; pub const META_INVERTREGION: ::WORD = 0x012A; pub const META_PAINTREGION: ::WORD = 0x012B; pub const META_SELECTCLIPREGION: ::WORD = 0x012C; pub const META_SELECTOBJECT: ::WORD = 0x012D; pub const META_SETTEXTALIGN: ::WORD = 0x012E; pub const META_CHORD: ::WORD = 0x0830; pub const META_SETMAPPERFLAGS: ::WORD = 0x0231; pub const META_EXTTEXTOUT: ::WORD = 0x0a32; pub const META_SETDIBTODEV: ::WORD = 0x0d33; pub const META_SELECTPALETTE: ::WORD = 0x0234; pub const META_REALIZEPALETTE: ::WORD = 0x0035; pub const META_ANIMATEPALETTE: ::WORD = 0x0436; pub const META_SETPALENTRIES: ::WORD = 0x0037; pub const META_POLYPOLYGON: ::WORD = 0x0538; pub const META_RESIZEPALETTE: ::WORD = 0x0139; pub const META_DIBBITBLT: ::WORD = 0x0940; pub const META_DIBSTRETCHBLT: ::WORD = 0x0b41; pub const META_DIBCREATEPATTERNBRUSH: ::WORD = 0x0142; pub const META_STRETCHDIB: ::WORD = 0x0f43; pub const META_EXTFLOODFILL: ::WORD = 0x0548; pub const META_SETLAYOUT: ::WORD = 0x0149; pub const META_DELETEOBJECT: ::WORD = 0x01f0; pub const META_CREATEPALETTE: ::WORD = 0x00f7; pub const META_CREATEPATTERNBRUSH: ::WORD = 0x01F9; pub const META_CREATEPENINDIRECT: ::WORD = 0x02FA; pub const META_CREATEFONTINDIRECT: ::WORD = 0x02FB; pub const META_CREATEBRUSHINDIRECT: ::WORD = 0x02FC; pub const META_CREATEREGION: ::WORD = 0x06FF; deps/winapi-0.2.5/src/dxgi1_4.rs0000644000000000000000000000652012617171043015037 0ustar rootroot// Copyright © 2015; Dmitry Roschin // Licensed under the MIT License //! Mappings for the contents of dxgi1_4.h ENUM!{ enum DXGI_MEMORY_SEGMENT_GROUP { DXGI_MEMORY_SEGMENT_GROUP_LOCAL = 0, DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL = 1, }} FLAGS!{ enum DXGI_OVERLAY_COLOR_SPACE_SUPPORT_FLAG { DXGI_OVERLAY_COLOR_SPACE_SUPPORT_FLAG_PRESENT = 0x1, }} FLAGS!{ enum DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG { DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_PRESENT = 0x1, DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_OVERLAY_PRESENT = 0x2, }} #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct DXGI_QUERY_VIDEO_MEMORY_INFO { pub Budget: ::UINT64, pub CurrentUsage: ::UINT64, pub AvailableForReservation: ::UINT64, pub CurrentReservation: ::UINT64, } RIDL!( interface IDXGIAdapter3(IDXGIAdapter3Vtbl): IDXGIAdapter2(IDXGIAdapter2Vtbl) { fn RegisterHardwareContentProtectionTeardownStatusEvent( &mut self, hEvent: ::HANDLE, pdwCookie: *mut ::DWORD ) -> ::HRESULT, fn UnregisterHardwareContentProtectionTeardownStatus( &mut self, dwCookie: ::DWORD ) -> (), fn QueryVideoMemoryInfo( &mut self, NodeIndex: ::UINT, MemorySegmentGroup: ::DXGI_MEMORY_SEGMENT_GROUP, pVideoMemoryInfo: *mut ::DXGI_QUERY_VIDEO_MEMORY_INFO ) -> ::HRESULT, fn SetVideoMemoryReservation( &mut self, NodeIndex: ::UINT, MemorySegmentGroup: ::DXGI_MEMORY_SEGMENT_GROUP, Reservation: ::UINT64 ) -> ::HRESULT, fn RegisterVideoMemoryBudgetChangeNotificationEvent( &mut self, hEvent: ::HANDLE, pdwCookie: *mut ::DWORD ) -> ::HRESULT, fn UnregisterVideoMemoryBudgetChangeNotification( &mut self, dwCookie: ::DWORD ) -> () }); RIDL!( interface IDXGIFactory4(IDXGIFactory4Vtbl): IDXGIFactory3(IDXGIFactory3Vtbl) { fn EnumAdapterByLuid( &mut self, AdapterLuid: ::LUID, riid: ::REFGUID, ppvAdapter: *mut *mut ::c_void ) -> ::HRESULT, fn EnumWarpAdapter( &mut self, riid: ::REFGUID, ppvAdapter: *mut *mut ::c_void ) -> ::HRESULT }); RIDL!( interface IDXGIOutput4(IDXGIOutput4Vtbl): IDXGIOutput3(IDXGIOutput3Vtbl) { fn CheckOverlayColorSpaceSupport( &mut self, Format: ::DXGI_FORMAT, ColorSpace: ::DXGI_COLOR_SPACE_TYPE, pConcernedDevice: *mut ::IUnknown, pFlags: *mut ::UINT ) -> ::HRESULT }); RIDL!( interface IDXGISwapChain3(IDXGISwapChain3Vtbl): IDXGISwapChain2(IDXGISwapChain2Vtbl) { fn GetCurrentBackBufferIndex(&mut self) -> ::UINT, fn CheckColorSpaceSupport( &mut self, ColorSpace: ::DXGI_COLOR_SPACE_TYPE, pColorSpaceSupport: *mut ::UINT ) -> ::HRESULT, fn SetColorSpace1( &mut self, ColorSpace: ::DXGI_COLOR_SPACE_TYPE ) -> ::HRESULT, fn ResizeBuffers1( &mut self, BufferCount: ::UINT, Width: ::UINT, Height: ::UINT, Format: ::DXGI_FORMAT, SwapChainFlags: ::UINT, pCreationNodeMask: *const ::UINT, ppPresentQueue: *mut *mut ::IUnknown ) -> ::HRESULT }); DEFINE_GUID!(IID_IDXGISwapChain3,0x94d99bdb,0xf1f8,0x4ab0,0xb2,0x36,0x7d,0xa0, 0x17,0x0e,0xda,0xb1); DEFINE_GUID!(IID_IDXGIOutput4,0xdc7dca35,0x2196,0x414d,0x9F,0x53,0x61,0x78, 0x84,0x03,0x2a,0x60); DEFINE_GUID!(IID_IDXGIFactory4,0x1bc6ea02,0xef36,0x464f,0xbf,0x0c,0x21,0xca, 0x39,0xe5,0x16,0x8a); DEFINE_GUID!(IID_IDXGIAdapter3,0x645967A4,0x1392,0x4310,0xA7,0x98,0x80,0x53, 0xCE,0x3E,0x93,0xFD); deps/winapi-0.2.5/src/dxgitype.rs0000644000000000000000000000626712617171733015453 0ustar rootroot// Copyright © 2015; Connor Hilarides // Licensed under the MIT License //! Mappings for the contents of dxgitype.h pub const DXGI_CPU_ACCESS_NONE: ::DWORD = 0; pub const DXGI_CPU_ACCESS_DYNAMIC: ::DWORD = 1; pub const DXGI_CPU_ACCESS_READ_WRITE: ::DWORD = 2; pub const DXGI_CPU_ACCESS_SCRATCH: ::DWORD = 3; pub const DXGI_CPU_ACCESS_FIELD: ::DWORD = 15; FLAGS!{enum DXGI_USAGE { DXGI_USAGE_SHADER_INPUT = 1 << (0 + 4), DXGI_USAGE_RENDER_TARGET_OUTPUT = 1 << (1 + 4), DXGI_USAGE_BACK_BUFFER = 1 << (2 + 4), DXGI_USAGE_SHARED = 1 << (3 + 4), DXGI_USAGE_READ_ONLY = 1 << (4 + 4), DXGI_USAGE_DISCARD_ON_PRESENT = 1 << (5 + 4), DXGI_USAGE_UNORDERED_ACCESS = 1 << (6 + 4), }} STRUCT!{struct DXGI_RGB { Red: f32, Green: f32, Blue: f32, }} pub type DXGI_RGBA = ::D3DCOLORVALUE; #[repr(C)] #[derive(Copy)] pub struct DXGI_GAMMA_CONTROL { pub Scale: DXGI_RGB, pub Offset: DXGI_RGB, pub GammaCurve: [DXGI_RGB; 1025], } impl Clone for DXGI_GAMMA_CONTROL { fn clone(&self) -> DXGI_GAMMA_CONTROL { *self } } #[repr(C)] #[derive(Copy)] pub struct DXGI_GAMMA_CONTROL_CAPABILITIES { pub ScaleAndOffsetSupported: ::BOOL, pub MaxConvertedValue: f32, pub MinConvertedValue: f32, pub NumGammaControlPoints: ::UINT, pub ControlPointPositions: [f32; 1025], } impl Clone for DXGI_GAMMA_CONTROL_CAPABILITIES { fn clone(&self) -> DXGI_GAMMA_CONTROL_CAPABILITIES { *self } } STRUCT!{struct DXGI_RATIONAL { Numerator: ::UINT, Denominator: ::UINT, }} ENUM!{enum DXGI_MODE_SCANLINE_ORDER { DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED, DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE, DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST, DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST, }} ENUM!{enum DXGI_MODE_SCALING { DXGI_MODE_SCALING_UNSPECIFIED, DXGI_MODE_SCALING_CENTERED, DXGI_MODE_SCALING_STRETCHED, }} ENUM!{enum DXGI_MODE_ROTATION { DXGI_MODE_ROTATION_UNSPECIFIED, DXGI_MODE_ROTATION_IDENTITY, DXGI_MODE_ROTATION_ROTATE90, DXGI_MODE_ROTATION_ROTATE180, DXGI_MODE_ROTATION_ROTATE270, }} STRUCT!{struct DXGI_MODE_DESC { Width: ::UINT, Height: ::UINT, RefreshRate: DXGI_RATIONAL, Format: ::DXGI_FORMAT, ScanlineOrdering: DXGI_MODE_SCANLINE_ORDER, Scaling: DXGI_MODE_SCALING, }} STRUCT!{struct DXGI_SAMPLE_DESC { Count: ::UINT, Quality: ::UINT, }} ENUM!{enum DXGI_COLOR_SPACE_TYPE { DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709 = 0x0, DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709 = 0x1, DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P709 = 0x2, DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P2020 = 0x3, DXGI_COLOR_SPACE_RESERVED = 0x4, DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601 = 0x5, DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 = 0x6, DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P601 = 0x7, DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 = 0x8, DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P709 = 0x9, DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020 = 0xA, DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020 = 0xB, DXGI_COLOR_SPACE_CUSTOM = 0xFFFFFFFF, }} pub const DXGI_CENTER_MULTISAMPLE_QUALITY_PATTERN: ::UINT = 0xfffffffe; pub const DXGI_STANDARD_MULTISAMPLE_QUALITY_PATTERN: ::UINT = 0xffffffff; deps/winapi-0.2.5/src/winspool.rs0000644000000000000000000000165212613167613015457 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License //! Winspool header file STRUCT!{struct PRINTER_DEFAULTSA { pDataType: ::LPSTR, pDevMode: ::LPDEVMODEA, DesiredAccess: ::ACCESS_MASK, }} pub type PPRINTER_DEFAULTSA = *mut PRINTER_DEFAULTSA; pub type LPPRINTER_DEFAULTSA = *mut PRINTER_DEFAULTSA; STRUCT!{struct PRINTER_DEFAULTSW { pDataType: ::LPWSTR, pDevMode: ::LPDEVMODEW, DesiredAccess: ::ACCESS_MASK, }} pub type PPRINTER_DEFAULTSW = *mut PRINTER_DEFAULTSW; pub type LPPRINTER_DEFAULTSW = *mut PRINTER_DEFAULTSW; STRUCT!{struct PRINTER_OPTIONSA { cbSize: ::UINT, dwFlags: ::DWORD, }} pub type PPRINTER_OPTIONSA = *mut PRINTER_OPTIONSA; pub type LPPRINTER_OPTIONSA = *mut PRINTER_OPTIONSA; STRUCT!{struct PRINTER_OPTIONSW { cbSize: ::UINT, dwFlags: ::DWORD, }} pub type PPRINTER_OPTIONSW = *mut PRINTER_OPTIONSW; pub type LPPRINTER_OPTIONSW = *mut PRINTER_OPTIONSW; deps/winapi-0.2.5/tests/0000755000000000000000000000000012666635521013614 5ustar rootrootdeps/winapi-0.2.5/tests/dwrite.rs0000644000000000000000000000035612566177605015467 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License #![cfg(windows)] extern crate dwrite; use dwrite::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(DWriteCreateFactory); } deps/winapi-0.2.5/tests/mpr.rs0000644000000000000000000000253612565203572014761 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License #![cfg(windows)] extern crate mpr; use mpr::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(MultinetGetConnectionPerformanceA); bb(MultinetGetConnectionPerformanceW); bb(WNetAddConnection2A); bb(WNetAddConnection2W); bb(WNetAddConnection3A); bb(WNetAddConnection3W); bb(WNetCancelConnectionA); bb(WNetCancelConnectionW); bb(WNetCancelConnection2A); bb(WNetCancelConnection2W); bb(WNetCloseEnum); bb(WNetConnectionDialog); bb(WNetConnectionDialog1A); bb(WNetConnectionDialog1W); bb(WNetDisconnectDialog); bb(WNetDisconnectDialog1A); bb(WNetDisconnectDialog1W); bb(WNetEnumResourceA); bb(WNetEnumResourceW); bb(WNetGetConnectionA); bb(WNetGetConnectionW); bb(WNetGetLastErrorA); bb(WNetGetLastErrorW); bb(WNetGetNetworkInformationA); bb(WNetGetNetworkInformationW); bb(WNetGetProviderNameA); bb(WNetGetProviderNameW); bb(WNetGetResourceInformationA); bb(WNetGetResourceInformationW); bb(WNetGetResourceParentA); bb(WNetGetResourceParentW); bb(WNetGetUniversalNameA); bb(WNetGetUniversalNameW); bb(WNetGetUserA); bb(WNetGetUserW); bb(WNetOpenEnumA); bb(WNetOpenEnumW); bb(WNetUseConnectionA); bb(WNetUseConnectionW); } deps/winapi-0.2.5/tests/kernel32.rs0000644000000000000000000010627012565273546015620 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License #![cfg(windows)] extern crate kernel32; use kernel32::*; #[inline(never)] fn bb(_: T) {} #[test] #[cfg(target_arch="x86")] fn functions_x86() { bb(InterlockedCompareExchange); bb(InterlockedCompareExchange64); bb(InterlockedDecrement); bb(InterlockedExchange); bb(InterlockedExchangeAdd); bb(InterlockedIncrement); } #[test] #[cfg(target_arch="x86_64")] fn functions_x64() { bb(CreateUmsCompletionList); bb(CreateUmsThreadContext); bb(DeleteUmsCompletionList); bb(DeleteUmsThreadContext); bb(DequeueUmsCompletionListItems); bb(EnterUmsSchedulingMode); bb(ExecuteUmsThread); bb(GetCurrentUmsThread); bb(GetNextUmsListItem); bb(GetUmsCompletionListEvent); bb(QueryUmsThreadInformation); bb(RtlAddFunctionTable); bb(RtlDeleteFunctionTable); bb(RtlInstallFunctionTableCallback); bb(RtlLookupFunctionEntry); bb(RtlRestoreContext); bb(RtlUnwindEx); bb(RtlVirtualUnwind); bb(SetUmsThreadInformation); bb(UmsThreadYield); bb(uaw_lstrcmpW); bb(uaw_lstrcmpiW); bb(uaw_lstrlenW); bb(uaw_wcschr); bb(uaw_wcscpy); bb(uaw_wcsicmp); bb(uaw_wcslen); bb(uaw_wcsrchr); } #[test] #[cfg(target_arch="x86_64")] #[cfg(target_env = "msvc")] fn functions_x64_msvc() { bb(GetEnabledXStateFeatures); bb(GetUmsSystemThreadInformation); bb(GetXStateFeaturesMask); bb(LocateXStateFeature); bb(SetXStateFeaturesMask); } #[test] #[cfg(any(target_arch="x86_64", target_arch="arm"))] #[cfg(target_env = "msvc")] fn functions_x64_arm_msvc() { bb(RtlCompareMemory); bb(RtlCopyMemory); } #[test] #[cfg(target_arch="arm")] fn functions_arm() { bb(RtlAddFunctionTable); bb(RtlDeleteFunctionTable); bb(RtlInstallFunctionTableCallback); bb(RtlLookupFunctionEntry); bb(RtlRestoreContext); bb(RtlUnwindEx); bb(RtlVirtualUnwind); bb(uaw_lstrcmpW); bb(uaw_lstrcmpiW); bb(uaw_lstrlenW); bb(uaw_wcschr); bb(uaw_wcscpy); bb(uaw_wcsicmp); bb(uaw_wcslen); bb(uaw_wcsrchr); } #[test] #[cfg(target_env = "msvc")] fn functions_msvc() { bb(AddDllDirectory); bb(AddResourceAttributeAce); bb(AddScopedPolicyIDAce); bb(CalloutOnFiberStack); bb(CeipIsOptedIn); bb(CheckTokenCapability); bb(CheckTokenMembershipEx); bb(CopyContext); bb(CopyFile2); bb(CreateFile2); bb(CreateFileMappingFromApp); bb(CreateRemoteThreadEx); bb(DeleteSynchronizationBarrier); bb(DisableThreadProfiling); bb(DnsHostnameToComputerNameExW); bb(EnableThreadProfiling); bb(EnterSynchronizationBarrier); bb(ExitThread); bb(GetAppContainerAce); bb(GetAppContainerNamedObjectPath); bb(GetCachedSigningLevel); bb(GetCurrentThreadStackLimits); bb(GetEnabledXStateFeatures); bb(GetFileMUIPath); bb(GetFirmwareEnvironmentVariableExA); bb(GetFirmwareEnvironmentVariableExW); bb(GetFirmwareType); bb(GetLogicalProcessorInformationEx); bb(GetMemoryErrorHandlingCapabilities); bb(GetOverlappedResultEx); bb(GetProcessInformation); bb(GetProcessMitigationPolicy); bb(GetSystemTimePreciseAsFileTime); bb(GetThreadInformation); bb(GetXStateFeaturesMask); bb(GlobalAddAtomExA); bb(GlobalAddAtomExW); bb(InitializeContext); bb(InitializeSynchronizationBarrier); bb(InstallELAMCertificateInfo); bb(InterlockedPushListSListEx); bb(IsNativeVhdBoot); bb(IsProcessCritical); bb(IsValidNLSVersion); bb(K32EmptyWorkingSet); bb(K32EnumDeviceDrivers); bb(K32EnumPageFilesA); bb(K32EnumPageFilesW); bb(K32EnumProcessModules); bb(K32EnumProcessModulesEx); bb(K32EnumProcesses); bb(K32GetDeviceDriverBaseNameA); bb(K32GetDeviceDriverBaseNameW); bb(K32GetDeviceDriverFileNameA); bb(K32GetDeviceDriverFileNameW); bb(K32GetMappedFileNameA); bb(K32GetMappedFileNameW); bb(K32GetModuleBaseNameA); bb(K32GetModuleBaseNameW); bb(K32GetModuleFileNameExA); bb(K32GetModuleFileNameExW); bb(K32GetModuleInformation); bb(K32GetPerformanceInfo); bb(K32GetProcessImageFileNameA); bb(K32GetProcessImageFileNameW); bb(K32GetProcessMemoryInfo); bb(K32GetWsChanges); bb(K32GetWsChangesEx); bb(K32InitializeProcessForWsWatch); bb(K32QueryWorkingSet); bb(K32QueryWorkingSetEx); bb(LoadPackagedLibrary); bb(LocateXStateFeature); bb(MapViewOfFileFromApp); bb(PowerSetRequest); bb(PrefetchVirtualMemory); bb(PssCaptureSnapshot); bb(PssDuplicateSnapshot); bb(PssFreeSnapshot); bb(PssQuerySnapshot); bb(PssWalkMarkerCreate); bb(PssWalkMarkerFree); bb(PssWalkMarkerGetPosition); bb(PssWalkMarkerSeekToBeginning); bb(PssWalkMarkerSetPosition); bb(PssWalkSnapshot); bb(QueryProtectedPolicy); bb(RegisterBadMemoryNotification); bb(RemoveDllDirectory); bb(SetCachedSigningLevel); bb(SetComputerNameEx2W); bb(SetDefaultDllDirectories); bb(SetFirmwareEnvironmentVariableExA); bb(SetFirmwareEnvironmentVariableExW); bb(SetProcessInformation); bb(SetProcessMitigationPolicy); bb(SetProtectedPolicy); bb(SetThreadInformation); bb(SetThreadpoolStackInformation); bb(SetThreadpoolTimerEx); bb(SetThreadpoolWaitEx); bb(SetWaitableTimerEx); bb(SetXStateFeaturesMask); bb(SystemTimeToTzSpecificLocalTimeEx); bb(TzSpecificLocalTimeToSystemTimeEx); bb(UnregisterBadMemoryNotification); } #[test] fn functions() { bb(AcquireSRWLockExclusive); bb(AcquireSRWLockShared); bb(ActivateActCtx); bb(AddAtomA); bb(AddAtomW); bb(AddConsoleAliasA); bb(AddConsoleAliasW); bb(AddIntegrityLabelToBoundaryDescriptor); bb(AddRefActCtx); bb(AddSIDToBoundaryDescriptor); bb(AddSecureMemoryCacheCallback); bb(AddVectoredContinueHandler); bb(AddVectoredExceptionHandler); bb(AllocConsole); bb(AllocateUserPhysicalPages); bb(AllocateUserPhysicalPagesNuma); bb(ApplicationRecoveryFinished); bb(ApplicationRecoveryInProgress); bb(BackupRead); bb(BackupSeek); bb(BackupWrite); bb(BeginUpdateResourceA); bb(BeginUpdateResourceW); bb(BindIoCompletionCallback); bb(BuildCommDCBA); bb(BuildCommDCBAndTimeoutsA); bb(BuildCommDCBAndTimeoutsW); bb(BuildCommDCBW); bb(CallNamedPipeA); bb(CallNamedPipeW); bb(CallbackMayRunLong); bb(CancelDeviceWakeupRequest); bb(CancelIo); bb(CancelIoEx); bb(CancelSynchronousIo); bb(CancelThreadpoolIo); bb(CancelTimerQueueTimer); bb(CancelWaitableTimer); bb(ChangeTimerQueueTimer); bb(CheckNameLegalDOS8Dot3A); bb(CheckNameLegalDOS8Dot3W); bb(CheckRemoteDebuggerPresent); bb(ClearCommBreak); bb(ClearCommError); bb(CloseHandle); bb(ClosePrivateNamespace); bb(CloseThreadpool); bb(CloseThreadpoolCleanupGroup); bb(CloseThreadpoolCleanupGroupMembers); bb(CloseThreadpoolIo); bb(CloseThreadpoolTimer); bb(CloseThreadpoolWait); bb(CloseThreadpoolWork); bb(CommConfigDialogA); bb(CommConfigDialogW); bb(CompareFileTime); bb(CompareStringA); bb(CompareStringEx); bb(CompareStringOrdinal); bb(CompareStringW); bb(ConnectNamedPipe); bb(ContinueDebugEvent); bb(ConvertDefaultLocale); bb(ConvertFiberToThread); bb(ConvertThreadToFiber); bb(ConvertThreadToFiberEx); bb(CopyFileA); bb(CopyFileExA); bb(CopyFileExW); bb(CopyFileTransactedA); bb(CopyFileTransactedW); bb(CopyFileW); bb(CreateActCtxA); bb(CreateActCtxW); bb(CreateBoundaryDescriptorA); bb(CreateBoundaryDescriptorW); bb(CreateConsoleScreenBuffer); bb(CreateDirectoryA); bb(CreateDirectoryExA); bb(CreateDirectoryExW); bb(CreateDirectoryTransactedA); bb(CreateDirectoryTransactedW); bb(CreateDirectoryW); bb(CreateEventA); bb(CreateEventW); bb(CreateEventExA); bb(CreateEventExW); bb(CreateFiber); bb(CreateFiberEx); bb(CreateFileA); bb(CreateFileMappingA); bb(CreateFileMappingNumaA); bb(CreateFileMappingNumaW); bb(CreateFileMappingW); bb(CreateFileTransactedA); bb(CreateFileTransactedW); bb(CreateFileW); bb(CreateHardLinkA); bb(CreateHardLinkTransactedA); bb(CreateHardLinkTransactedW); bb(CreateHardLinkW); bb(CreateIoCompletionPort); bb(CreateJobObjectA); bb(CreateJobObjectW); bb(CreateJobSet); bb(CreateMailslotA); bb(CreateMailslotW); bb(CreateMemoryResourceNotification); bb(CreateMutexA); bb(CreateMutexExA); bb(CreateMutexExW); bb(CreateMutexW); bb(CreateNamedPipeA); bb(CreateNamedPipeW); bb(CreatePipe); bb(CreatePrivateNamespaceA); bb(CreatePrivateNamespaceW); bb(CreateProcessA); bb(CreateProcessW); bb(CreateRemoteThread); bb(CreateSemaphoreA); bb(CreateSemaphoreExA); bb(CreateSemaphoreExW); bb(CreateSemaphoreW); bb(CreateSymbolicLinkA); bb(CreateSymbolicLinkTransactedA); bb(CreateSymbolicLinkTransactedW); bb(CreateSymbolicLinkW); bb(CreateTapePartition); bb(CreateThread); bb(CreateThreadpool); bb(CreateThreadpoolCleanupGroup); bb(CreateThreadpoolIo); bb(CreateThreadpoolTimer); bb(CreateThreadpoolWait); bb(CreateThreadpoolWork); bb(CreateTimerQueue); bb(CreateTimerQueueTimer); bb(CreateToolhelp32Snapshot); bb(CreateWaitableTimerA); bb(CreateWaitableTimerExA); bb(CreateWaitableTimerExW); bb(CreateWaitableTimerW); bb(DeactivateActCtx); bb(DebugActiveProcess); bb(DebugActiveProcessStop); bb(DebugBreak); bb(DebugBreakProcess); bb(DebugSetProcessKillOnExit); bb(DecodePointer); bb(DecodeSystemPointer); bb(DefineDosDeviceA); bb(DefineDosDeviceW); bb(DelayLoadFailureHook); bb(DeleteAtom); bb(DeleteBoundaryDescriptor); bb(DeleteCriticalSection); bb(DeleteFiber); bb(DeleteFileA); bb(DeleteFileTransactedA); bb(DeleteFileTransactedW); bb(DeleteFileW); bb(DeleteProcThreadAttributeList); bb(DeleteTimerQueue); bb(DeleteTimerQueueEx); bb(DeleteTimerQueueTimer); bb(DeleteVolumeMountPointA); bb(DeleteVolumeMountPointW); bb(DeviceIoControl); bb(DisableThreadLibraryCalls); bb(DisassociateCurrentThreadFromCallback); bb(DisconnectNamedPipe); bb(DnsHostnameToComputerNameA); bb(DnsHostnameToComputerNameW); bb(DosDateTimeToFileTime); bb(DuplicateHandle); bb(EncodePointer); bb(EncodeSystemPointer); bb(EndUpdateResourceA); bb(EndUpdateResourceW); bb(EnumCalendarInfoA); bb(EnumCalendarInfoExA); bb(EnumCalendarInfoExEx); bb(EnumCalendarInfoExW); bb(EnumCalendarInfoW); bb(EnumDateFormatsA); bb(EnumDateFormatsExA); bb(EnumDateFormatsExEx); bb(EnumDateFormatsExW); bb(EnumDateFormatsW); bb(EnumLanguageGroupLocalesA); bb(EnumLanguageGroupLocalesW); bb(EnumResourceLanguagesA); bb(EnumResourceLanguagesExA); bb(EnumResourceLanguagesExW); bb(EnumResourceLanguagesW); bb(EnumResourceNamesA); bb(EnumResourceNamesExA); bb(EnumResourceNamesExW); bb(EnumResourceNamesW); bb(EnumResourceTypesA); bb(EnumResourceTypesExA); bb(EnumResourceTypesExW); bb(EnumResourceTypesW); bb(EnumSystemCodePagesA); bb(EnumSystemCodePagesW); bb(EnumSystemFirmwareTables); bb(EnumSystemGeoID); bb(EnumSystemLanguageGroupsA); bb(EnumSystemLanguageGroupsW); bb(EnumSystemLocalesA); bb(EnumSystemLocalesEx); bb(EnumSystemLocalesW); bb(EnumTimeFormatsA); bb(EnumTimeFormatsEx); bb(EnumTimeFormatsW); bb(EnumUILanguagesA); bb(EnumUILanguagesW); bb(EraseTape); bb(EscapeCommFunction); bb(ExitProcess); bb(ExpandEnvironmentStringsA); bb(ExpandEnvironmentStringsW); bb(FatalAppExitA); bb(FatalAppExitW); bb(FatalExit); bb(FileTimeToDosDateTime); bb(FileTimeToLocalFileTime); bb(FileTimeToSystemTime); bb(FillConsoleOutputAttribute); bb(FillConsoleOutputCharacterA); bb(FillConsoleOutputCharacterW); bb(FindActCtxSectionGuid); bb(FindActCtxSectionStringA); bb(FindActCtxSectionStringW); bb(FindAtomA); bb(FindAtomW); bb(FindClose); bb(FindCloseChangeNotification); bb(FindFirstChangeNotificationA); bb(FindFirstChangeNotificationW); bb(FindFirstFileA); bb(FindFirstFileExA); bb(FindFirstFileExW); bb(FindFirstFileNameTransactedW); bb(FindFirstFileNameW); bb(FindFirstFileTransactedA); bb(FindFirstFileTransactedW); bb(FindFirstFileW); bb(FindFirstStreamTransactedW); bb(FindFirstStreamW); bb(FindFirstVolumeA); bb(FindFirstVolumeMountPointA); bb(FindFirstVolumeMountPointW); bb(FindFirstVolumeW); bb(FindNLSString); bb(FindNLSStringEx); bb(FindNextChangeNotification); bb(FindNextFileA); bb(FindNextFileNameW); bb(FindNextFileW); bb(FindNextStreamW); bb(FindNextVolumeA); bb(FindNextVolumeMountPointA); bb(FindNextVolumeMountPointW); bb(FindNextVolumeW); bb(FindResourceA); bb(FindResourceExA); bb(FindResourceExW); bb(FindResourceW); bb(FindStringOrdinal); bb(FindVolumeClose); bb(FindVolumeMountPointClose); bb(FlsAlloc); bb(FlsFree); bb(FlsGetValue); bb(FlsSetValue); bb(FlushConsoleInputBuffer); bb(FlushFileBuffers); bb(FlushInstructionCache); bb(FlushProcessWriteBuffers); bb(FlushViewOfFile); bb(FoldStringA); bb(FoldStringW); bb(FormatMessageA); bb(FormatMessageW); bb(FreeConsole); bb(FreeEnvironmentStringsA); bb(FreeEnvironmentStringsW); bb(FreeLibrary); bb(FreeLibraryAndExitThread); bb(FreeLibraryWhenCallbackReturns); bb(FreeResource); bb(FreeUserPhysicalPages); bb(GenerateConsoleCtrlEvent); bb(GetACP); bb(GetActiveProcessorCount); bb(GetActiveProcessorGroupCount); bb(GetApplicationRecoveryCallback); bb(GetApplicationRestartSettings); bb(GetAtomNameA); bb(GetAtomNameW); bb(GetBinaryTypeA); bb(GetBinaryTypeW); bb(GetCPInfo); bb(GetCPInfoExA); bb(GetCPInfoExW); bb(GetCalendarInfoA); bb(GetCalendarInfoEx); bb(GetCalendarInfoW); bb(GetCommConfig); bb(GetCommMask); bb(GetCommModemStatus); bb(GetCommProperties); bb(GetCommState); bb(GetCommTimeouts); bb(GetCommandLineA); bb(GetCommandLineW); bb(GetCompressedFileSizeA); bb(GetCompressedFileSizeTransactedA); bb(GetCompressedFileSizeTransactedW); bb(GetCompressedFileSizeW); bb(GetComputerNameA); bb(GetComputerNameExA); bb(GetComputerNameExW); bb(GetComputerNameW); bb(GetConsoleAliasA); bb(GetConsoleAliasExesA); bb(GetConsoleAliasExesLengthA); bb(GetConsoleAliasExesLengthW); bb(GetConsoleAliasExesW); bb(GetConsoleAliasW); bb(GetConsoleAliasesA); bb(GetConsoleAliasesLengthA); bb(GetConsoleAliasesLengthW); bb(GetConsoleAliasesW); bb(GetConsoleCP); bb(GetConsoleCursorInfo); bb(GetConsoleDisplayMode); bb(GetConsoleFontSize); bb(GetConsoleHistoryInfo); bb(GetConsoleMode); bb(GetConsoleOriginalTitleA); bb(GetConsoleOriginalTitleW); bb(GetConsoleOutputCP); bb(GetConsoleProcessList); bb(GetConsoleScreenBufferInfo); bb(GetConsoleScreenBufferInfoEx); bb(GetConsoleSelectionInfo); bb(GetConsoleTitleA); bb(GetConsoleTitleW); bb(GetConsoleWindow); bb(GetCurrencyFormatA); bb(GetCurrencyFormatEx); bb(GetCurrencyFormatW); bb(GetCurrentActCtx); bb(GetCurrentConsoleFont); bb(GetCurrentConsoleFontEx); bb(GetCurrentDirectoryA); bb(GetCurrentDirectoryW); bb(GetCurrentProcess); bb(GetCurrentProcessId); bb(GetCurrentProcessorNumber); bb(GetCurrentProcessorNumberEx); bb(GetCurrentThread); bb(GetCurrentThreadId); bb(GetDateFormatA); bb(GetDateFormatEx); bb(GetDateFormatW); bb(GetDefaultCommConfigA); bb(GetDefaultCommConfigW); bb(GetDevicePowerState); bb(GetDiskFreeSpaceA); bb(GetDiskFreeSpaceExA); bb(GetDiskFreeSpaceExW); bb(GetDiskFreeSpaceW); bb(GetDllDirectoryA); bb(GetDllDirectoryW); bb(GetDurationFormat); bb(GetDurationFormatEx); bb(GetDynamicTimeZoneInformation); bb(GetEnvironmentStrings); bb(GetEnvironmentStringsW); bb(GetEnvironmentVariableA); bb(GetEnvironmentVariableW); bb(GetErrorMode); bb(GetExitCodeProcess); bb(GetExitCodeThread); bb(GetFileAttributesA); bb(GetFileAttributesExA); bb(GetFileAttributesExW); bb(GetFileAttributesTransactedA); bb(GetFileAttributesTransactedW); bb(GetFileAttributesW); bb(GetFileBandwidthReservation); bb(GetFileInformationByHandle); bb(GetFileInformationByHandleEx); bb(GetFileMUIInfo); bb(GetFileSize); bb(GetFileSizeEx); bb(GetFileTime); bb(GetFileType); bb(GetFinalPathNameByHandleA); bb(GetFinalPathNameByHandleW); bb(GetFirmwareEnvironmentVariableA); bb(GetFirmwareEnvironmentVariableW); bb(GetFullPathNameA); bb(GetFullPathNameTransactedA); bb(GetFullPathNameTransactedW); bb(GetFullPathNameW); bb(GetGeoInfoA); bb(GetGeoInfoW); bb(GetHandleInformation); bb(GetLargePageMinimum); bb(GetLargestConsoleWindowSize); bb(GetLastError); bb(GetLocalTime); bb(GetLocaleInfoA); bb(GetLocaleInfoEx); bb(GetLocaleInfoW); bb(GetLogicalDriveStringsA); bb(GetLogicalDriveStringsW); bb(GetLogicalDrives); bb(GetLogicalProcessorInformation); bb(GetLongPathNameA); bb(GetLongPathNameTransactedA); bb(GetLongPathNameTransactedW); bb(GetLongPathNameW); bb(GetMailslotInfo); bb(GetMaximumProcessorCount); bb(GetMaximumProcessorGroupCount); bb(GetModuleFileNameA); bb(GetModuleFileNameW); bb(GetModuleHandleA); bb(GetModuleHandleExA); bb(GetModuleHandleExW); bb(GetModuleHandleW); bb(GetNLSVersion); bb(GetNLSVersionEx); bb(GetNamedPipeClientComputerNameA); bb(GetNamedPipeClientComputerNameW); bb(GetNamedPipeClientProcessId); bb(GetNamedPipeClientSessionId); bb(GetNamedPipeHandleStateA); bb(GetNamedPipeHandleStateW); bb(GetNamedPipeInfo); bb(GetNamedPipeServerProcessId); bb(GetNamedPipeServerSessionId); bb(GetNativeSystemInfo); bb(GetNumaAvailableMemoryNode); bb(GetNumaAvailableMemoryNodeEx); bb(GetNumaHighestNodeNumber); bb(GetNumaNodeNumberFromHandle); bb(GetNumaNodeProcessorMask); bb(GetNumaNodeProcessorMaskEx); bb(GetNumaProcessorNode); bb(GetNumaProcessorNodeEx); bb(GetNumaProximityNode); bb(GetNumaProximityNodeEx); bb(GetNumberFormatA); bb(GetNumberFormatEx); bb(GetNumberFormatW); bb(GetNumberOfConsoleInputEvents); bb(GetNumberOfConsoleMouseButtons); bb(GetOEMCP); bb(GetOverlappedResult); bb(GetPhysicallyInstalledSystemMemory); bb(GetPriorityClass); bb(GetPrivateProfileIntA); bb(GetPrivateProfileIntW); bb(GetPrivateProfileSectionA); bb(GetPrivateProfileSectionNamesA); bb(GetPrivateProfileSectionNamesW); bb(GetPrivateProfileSectionW); bb(GetPrivateProfileStringA); bb(GetPrivateProfileStringW); bb(GetPrivateProfileStructA); bb(GetPrivateProfileStructW); bb(GetProcAddress); bb(GetProcessAffinityMask); bb(GetProcessDEPPolicy); bb(GetProcessGroupAffinity); bb(GetProcessHandleCount); bb(GetProcessHeap); bb(GetProcessHeaps); bb(GetProcessId); bb(GetProcessIdOfThread); bb(GetProcessIoCounters); bb(GetProcessPreferredUILanguages); bb(GetProcessPriorityBoost); bb(GetProcessShutdownParameters); bb(GetProcessTimes); bb(GetProcessVersion); bb(GetProcessWorkingSetSize); bb(GetProcessWorkingSetSizeEx); bb(GetProcessorSystemCycleTime); bb(GetProductInfo); bb(GetProfileIntA); bb(GetProfileIntW); bb(GetProfileSectionA); bb(GetProfileSectionW); bb(GetProfileStringA); bb(GetProfileStringW); bb(GetQueuedCompletionStatus); bb(GetQueuedCompletionStatusEx); bb(GetShortPathNameA); bb(GetShortPathNameW); bb(GetStartupInfoA); bb(GetStartupInfoW); bb(GetStdHandle); bb(GetStringScripts); bb(GetStringTypeA); bb(GetStringTypeExA); bb(GetStringTypeExW); bb(GetStringTypeW); bb(GetSystemDEPPolicy); bb(GetSystemDefaultLCID); bb(GetSystemDefaultLangID); bb(GetSystemDefaultLocaleName); bb(GetSystemDefaultUILanguage); bb(GetSystemDirectoryA); bb(GetSystemDirectoryW); bb(GetSystemFileCacheSize); bb(GetSystemFirmwareTable); bb(GetSystemInfo); bb(GetSystemPowerStatus); bb(GetSystemPreferredUILanguages); bb(GetSystemRegistryQuota); bb(GetSystemTime); bb(GetSystemTimeAdjustment); bb(GetSystemTimeAsFileTime); bb(GetSystemTimes); bb(GetSystemWindowsDirectoryA); bb(GetSystemWindowsDirectoryW); bb(GetSystemWow64DirectoryA); bb(GetSystemWow64DirectoryW); bb(GetTapeParameters); bb(GetTapePosition); bb(GetTapeStatus); bb(GetTempFileNameA); bb(GetTempFileNameW); bb(GetTempPathA); bb(GetTempPathW); bb(GetThreadContext); bb(GetThreadErrorMode); bb(GetThreadGroupAffinity); bb(GetThreadIOPendingFlag); bb(GetThreadId); bb(GetThreadIdealProcessorEx); bb(GetThreadLocale); bb(GetThreadPreferredUILanguages); bb(GetThreadPriority); bb(GetThreadPriorityBoost); bb(GetThreadSelectorEntry); bb(GetThreadTimes); bb(GetThreadUILanguage); bb(GetTickCount); bb(GetTickCount64); bb(GetTimeFormatA); bb(GetTimeFormatEx); bb(GetTimeFormatW); bb(GetTimeZoneInformation); bb(GetTimeZoneInformationForYear); bb(GetUILanguageInfo); bb(GetUserDefaultLCID); bb(GetUserDefaultLangID); bb(GetUserDefaultLocaleName); bb(GetUserDefaultUILanguage); bb(GetUserGeoID); bb(GetUserPreferredUILanguages); bb(GetVersion); bb(GetVersionExA); bb(GetVersionExW); bb(GetVolumeInformationA); bb(GetVolumeInformationByHandleW); bb(GetVolumeInformationW); bb(GetVolumeNameForVolumeMountPointA); bb(GetVolumeNameForVolumeMountPointW); bb(GetVolumePathNameA); bb(GetVolumePathNameW); bb(GetVolumePathNamesForVolumeNameA); bb(GetVolumePathNamesForVolumeNameW); bb(GetWindowsDirectoryA); bb(GetWindowsDirectoryW); bb(GetWriteWatch); bb(GlobalAddAtomA); bb(GlobalAddAtomW); bb(GlobalAlloc); bb(GlobalCompact); bb(GlobalDeleteAtom); bb(GlobalFindAtomA); bb(GlobalFindAtomW); bb(GlobalFix); bb(GlobalFlags); bb(GlobalGetAtomNameA); bb(GlobalGetAtomNameW); bb(GlobalHandle); bb(GlobalLock); bb(GlobalMemoryStatus); bb(GlobalMemoryStatusEx); bb(GlobalReAlloc); bb(GlobalSize); bb(GlobalUnWire); bb(GlobalUnfix); bb(GlobalUnlock); bb(GlobalWire); bb(Heap32First); bb(Heap32ListFirst); bb(Heap32ListNext); bb(Heap32Next); bb(HeapAlloc); bb(HeapCompact); bb(HeapCreate); bb(HeapDestroy); bb(HeapFree); bb(HeapLock); bb(HeapQueryInformation); bb(HeapReAlloc); bb(HeapSetInformation); bb(HeapSize); bb(HeapSummary); bb(HeapUnlock); bb(HeapValidate); bb(HeapWalk); bb(InitAtomTable); bb(InitOnceBeginInitialize); bb(InitOnceComplete); bb(InitOnceExecuteOnce); bb(InitOnceInitialize); bb(InitializeConditionVariable); bb(InitializeCriticalSection); bb(InitializeCriticalSectionAndSpinCount); bb(InitializeCriticalSectionEx); bb(InitializeProcThreadAttributeList); bb(InitializeSListHead); bb(InitializeSRWLock); bb(InterlockedFlushSList); bb(InterlockedPopEntrySList); bb(IsBadCodePtr); bb(IsBadHugeReadPtr); bb(IsBadHugeWritePtr); bb(IsBadReadPtr); bb(IsBadStringPtrA); bb(IsBadStringPtrW); bb(IsBadWritePtr); bb(IsDBCSLeadByte); bb(IsDBCSLeadByteEx); bb(IsDebuggerPresent); bb(IsNLSDefinedString); bb(IsNormalizedString); bb(IsProcessInJob); bb(IsProcessorFeaturePresent); bb(IsSystemResumeAutomatic); bb(IsThreadAFiber); bb(IsThreadpoolTimerSet); bb(IsValidCodePage); bb(IsValidLanguageGroup); bb(IsValidLocale); bb(IsValidLocaleName); bb(IsWow64Process); bb(LCIDToLocaleName); bb(LCMapStringA); bb(LCMapStringEx); bb(LCMapStringW); bb(LeaveCriticalSection); bb(LeaveCriticalSectionWhenCallbackReturns); bb(LoadLibraryA); bb(LoadLibraryExA); bb(LoadLibraryExW); bb(LoadLibraryW); bb(LoadModule); bb(LoadResource); bb(LocalAlloc); bb(LocalCompact); bb(LocalFileTimeToFileTime); bb(LocalFlags); bb(LocalFree); bb(LocalHandle); bb(LocalLock); bb(LocalReAlloc); bb(LocalShrink); bb(LocalSize); bb(LocalUnlock); bb(LocaleNameToLCID); bb(LockFile); bb(LockFileEx); bb(LockResource); bb(MapUserPhysicalPages); bb(MapUserPhysicalPagesScatter); bb(MapViewOfFile); bb(MapViewOfFileEx); bb(MapViewOfFileExNuma); bb(Module32First); bb(Module32FirstW); bb(Module32Next); bb(Module32NextW); bb(MoveFileA); bb(MoveFileExA); bb(MoveFileExW); bb(MoveFileTransactedA); bb(MoveFileTransactedW); bb(MoveFileW); bb(MoveFileWithProgressA); bb(MoveFileWithProgressW); bb(MulDiv); bb(MultiByteToWideChar); bb(NeedCurrentDirectoryForExePathA); bb(NeedCurrentDirectoryForExePathW); bb(NormalizeString); bb(NotifyUILanguageChange); bb(OpenEventA); bb(OpenEventW); bb(OpenFile); bb(OpenFileById); bb(OpenFileMappingA); bb(OpenFileMappingW); bb(OpenJobObjectA); bb(OpenJobObjectW); bb(OpenMutexA); bb(OpenMutexW); bb(OpenPrivateNamespaceA); bb(OpenPrivateNamespaceW); bb(OpenProcess); bb(OpenSemaphoreA); bb(OpenSemaphoreW); bb(OpenThread); bb(OpenWaitableTimerA); bb(OpenWaitableTimerW); bb(OutputDebugStringA); bb(OutputDebugStringW); bb(PeekConsoleInputA); bb(PeekConsoleInputW); bb(PeekNamedPipe); bb(PostQueuedCompletionStatus); bb(PowerClearRequest); bb(PowerCreateRequest); bb(PrepareTape); bb(Process32First); bb(Process32FirstW); bb(Process32Next); bb(Process32NextW); bb(ProcessIdToSessionId); bb(PulseEvent); bb(PurgeComm); bb(QueryActCtxSettingsW); bb(QueryActCtxW); bb(QueryDepthSList); bb(QueryDosDeviceA); bb(QueryDosDeviceW); bb(QueryFullProcessImageNameA); bb(QueryFullProcessImageNameW); bb(QueryIdleProcessorCycleTime); bb(QueryIdleProcessorCycleTimeEx); bb(QueryInformationJobObject); bb(QueryPerformanceCounter); bb(QueryPerformanceFrequency); bb(QueryProcessAffinityUpdateMode); bb(QueryProcessCycleTime); bb(QueryThreadCycleTime); bb(QueryThreadProfiling); bb(QueryThreadpoolStackInformation); bb(QueryUnbiasedInterruptTime); bb(QueueUserAPC); bb(QueueUserWorkItem); bb(RaiseException); bb(RaiseFailFastException); bb(ReOpenFile); bb(ReadConsoleA); bb(ReadConsoleInputA); bb(ReadConsoleInputW); bb(ReadConsoleOutputA); bb(ReadConsoleOutputAttribute); bb(ReadConsoleOutputCharacterA); bb(ReadConsoleOutputCharacterW); bb(ReadConsoleOutputW); bb(ReadConsoleW); bb(ReadDirectoryChangesW); bb(ReadFile); bb(ReadFileEx); bb(ReadFileScatter); bb(ReadProcessMemory); bb(ReadThreadProfilingData); bb(RegisterApplicationRecoveryCallback); bb(RegisterApplicationRestart); bb(RegisterWaitForSingleObject); bb(RegisterWaitForSingleObjectEx); bb(ReleaseActCtx); bb(ReleaseMutex); bb(ReleaseMutexWhenCallbackReturns); bb(ReleaseSRWLockExclusive); bb(ReleaseSRWLockShared); bb(ReleaseSemaphore); bb(ReleaseSemaphoreWhenCallbackReturns); bb(RemoveDirectoryA); bb(RemoveDirectoryTransactedA); bb(RemoveDirectoryTransactedW); bb(RemoveDirectoryW); bb(RemoveSecureMemoryCacheCallback); bb(RemoveVectoredContinueHandler); bb(RemoveVectoredExceptionHandler); bb(ReplaceFileA); bb(ReplaceFileW); bb(ReplacePartitionUnit); bb(RequestDeviceWakeup); bb(RequestWakeupLatency); bb(ResetEvent); bb(ResetWriteWatch); bb(RestoreLastError); bb(ResumeThread); bb(RtlCaptureContext); bb(RtlCaptureStackBackTrace); bb(RtlUnwind); bb(ScrollConsoleScreenBufferA); bb(ScrollConsoleScreenBufferW); bb(SearchPathA); bb(SearchPathW); bb(SetCalendarInfoA); bb(SetCalendarInfoW); bb(SetCommBreak); bb(SetCommConfig); bb(SetCommMask); bb(SetCommState); bb(SetCommTimeouts); bb(SetComputerNameA); bb(SetComputerNameExA); bb(SetComputerNameExW); bb(SetComputerNameW); bb(SetConsoleActiveScreenBuffer); bb(SetConsoleCP); bb(SetConsoleCtrlHandler); bb(SetConsoleCursorInfo); bb(SetConsoleCursorPosition); bb(SetConsoleDisplayMode); bb(SetConsoleHistoryInfo); bb(SetConsoleMode); bb(SetConsoleOutputCP); bb(SetConsoleScreenBufferInfoEx); bb(SetConsoleScreenBufferSize); bb(SetConsoleTextAttribute); bb(SetConsoleTitleA); bb(SetConsoleTitleW); bb(SetConsoleWindowInfo); bb(SetCriticalSectionSpinCount); bb(SetCurrentConsoleFontEx); bb(SetCurrentDirectoryA); bb(SetCurrentDirectoryW); bb(SetDefaultCommConfigA); bb(SetDefaultCommConfigW); bb(SetDllDirectoryA); bb(SetDllDirectoryW); bb(SetDynamicTimeZoneInformation); bb(SetEndOfFile); bb(SetEnvironmentStringsA); bb(SetEnvironmentStringsW); bb(SetEnvironmentVariableA); bb(SetEnvironmentVariableW); bb(SetErrorMode); bb(SetEvent); bb(SetEventWhenCallbackReturns); bb(SetFileApisToANSI); bb(SetFileApisToOEM); bb(SetFileAttributesA); bb(SetFileAttributesTransactedA); bb(SetFileAttributesTransactedW); bb(SetFileAttributesW); bb(SetFileBandwidthReservation); bb(SetFileCompletionNotificationModes); bb(SetFileInformationByHandle); bb(SetFileIoOverlappedRange); bb(SetFilePointer); bb(SetFilePointerEx); bb(SetFileShortNameA); bb(SetFileShortNameW); bb(SetFileTime); bb(SetFileValidData); bb(SetFirmwareEnvironmentVariableA); bb(SetFirmwareEnvironmentVariableW); bb(SetHandleCount); bb(SetHandleInformation); bb(SetInformationJobObject); bb(SetLastError); bb(SetLocalTime); bb(SetLocaleInfoA); bb(SetLocaleInfoW); bb(SetMailslotInfo); bb(SetMessageWaitingIndicator); bb(SetNamedPipeAttribute); bb(SetNamedPipeHandleState); bb(SetPriorityClass); bb(SetProcessAffinityMask); bb(SetProcessAffinityUpdateMode); bb(SetProcessDEPPolicy); bb(SetProcessPreferredUILanguages); bb(SetProcessPriorityBoost); bb(SetProcessShutdownParameters); bb(SetProcessWorkingSetSize); bb(SetProcessWorkingSetSizeEx); bb(SetSearchPathMode); bb(SetStdHandle); bb(SetStdHandleEx); bb(SetSystemFileCacheSize); bb(SetSystemPowerState); bb(SetSystemTime); bb(SetSystemTimeAdjustment); bb(SetTapeParameters); bb(SetTapePosition); bb(SetThreadAffinityMask); bb(SetThreadContext); bb(SetThreadErrorMode); bb(SetThreadExecutionState); bb(SetThreadGroupAffinity); bb(SetThreadIdealProcessor); bb(SetThreadIdealProcessorEx); bb(SetThreadLocale); bb(SetThreadPreferredUILanguages); bb(SetThreadPriority); bb(SetThreadPriorityBoost); bb(SetThreadUILanguage); bb(SetThreadpoolThreadMaximum); bb(SetThreadpoolThreadMinimum); bb(SetThreadpoolTimer); bb(SetThreadpoolWait); bb(SetTimeZoneInformation); bb(SetTimerQueueTimer); bb(SetUnhandledExceptionFilter); bb(SetUserGeoID); bb(SetVolumeLabelA); bb(SetVolumeLabelW); bb(SetVolumeMountPointA); bb(SetVolumeMountPointW); bb(SetWaitableTimer); bb(SetupComm); bb(SignalObjectAndWait); bb(SizeofResource); bb(Sleep); bb(SleepConditionVariableCS); bb(SleepConditionVariableSRW); bb(SleepEx); bb(StartThreadpoolIo); bb(SubmitThreadpoolWork); bb(SuspendThread); bb(SwitchToFiber); bb(SwitchToThread); bb(SystemTimeToFileTime); bb(SystemTimeToTzSpecificLocalTime); bb(TerminateJobObject); bb(TerminateProcess); bb(TerminateThread); bb(Thread32First); bb(Thread32Next); bb(TlsAlloc); bb(TlsFree); bb(TlsGetValue); bb(TlsSetValue); bb(Toolhelp32ReadProcessMemory); bb(TransactNamedPipe); bb(TransmitCommChar); bb(TryAcquireSRWLockExclusive); bb(TryAcquireSRWLockShared); bb(TryEnterCriticalSection); bb(TrySubmitThreadpoolCallback); bb(TzSpecificLocalTimeToSystemTime); bb(UnhandledExceptionFilter); bb(UnlockFile); bb(UnlockFileEx); bb(UnmapViewOfFile); bb(UnregisterApplicationRecoveryCallback); bb(UnregisterApplicationRestart); bb(UnregisterWait); bb(UnregisterWaitEx); bb(UpdateProcThreadAttribute); bb(UpdateResourceA); bb(UpdateResourceW); bb(VerLanguageNameA); bb(VerLanguageNameW); bb(VerSetConditionMask); bb(VerifyScripts); bb(VerifyVersionInfoA); bb(VerifyVersionInfoW); bb(VirtualAlloc); bb(VirtualAllocEx); bb(VirtualAllocExNuma); bb(VirtualFree); bb(VirtualFreeEx); bb(VirtualLock); bb(VirtualProtect); bb(VirtualProtectEx); bb(VirtualQuery); bb(VirtualQueryEx); bb(VirtualUnlock); bb(WTSGetActiveConsoleSessionId); bb(WaitCommEvent); bb(WaitForDebugEvent); bb(WaitForMultipleObjects); bb(WaitForMultipleObjectsEx); bb(WaitForSingleObject); bb(WaitForSingleObjectEx); bb(WaitForThreadpoolIoCallbacks); bb(WaitForThreadpoolTimerCallbacks); bb(WaitForThreadpoolWaitCallbacks); bb(WaitNamedPipeA); bb(WaitNamedPipeW); bb(WakeAllConditionVariable); bb(WakeConditionVariable); bb(WerGetFlags); bb(WerRegisterFile); bb(WerRegisterMemoryBlock); bb(WerRegisterRuntimeExceptionModule); bb(WerSetFlags); bb(WerUnregisterFile); bb(WerUnregisterMemoryBlock); bb(WerUnregisterRuntimeExceptionModule); bb(WideCharToMultiByte); bb(WinExec); bb(Wow64DisableWow64FsRedirection); bb(Wow64EnableWow64FsRedirection); bb(Wow64GetThreadContext); bb(Wow64GetThreadSelectorEntry); bb(Wow64RevertWow64FsRedirection); bb(Wow64SetThreadContext); bb(Wow64SuspendThread); bb(WriteConsoleA); bb(WriteConsoleInputA); bb(WriteConsoleInputW); bb(WriteConsoleOutputA); bb(WriteConsoleOutputAttribute); bb(WriteConsoleOutputCharacterA); bb(WriteConsoleOutputCharacterW); bb(WriteConsoleOutputW); bb(WriteConsoleW); bb(WriteFile); bb(WriteFileEx); bb(WriteFileGather); bb(WritePrivateProfileSectionA); bb(WritePrivateProfileSectionW); bb(WritePrivateProfileStringA); bb(WritePrivateProfileStringW); bb(WritePrivateProfileStructA); bb(WritePrivateProfileStructW); bb(WriteProcessMemory); bb(WriteProfileSectionA); bb(WriteProfileSectionW); bb(WriteProfileStringA); bb(WriteProfileStringW); bb(WriteTapemark); bb(ZombifyActCtx); bb(_hread); bb(_hwrite); bb(_lclose); bb(_lcreat); bb(_llseek); bb(_lopen); bb(_lread); bb(_lwrite); bb(lstrcat); bb(lstrcatA); bb(lstrcatW); bb(lstrcmp); bb(lstrcmpA); bb(lstrcmpW); bb(lstrcmpi); bb(lstrcmpiA); bb(lstrcmpiW); bb(lstrcpy); bb(lstrcpyA); bb(lstrcpyW); bb(lstrcpyn); bb(lstrcpynA); bb(lstrcpynW); bb(lstrlen); bb(lstrlenA); bb(lstrlenW); } deps/winapi-0.2.5/tests/ktmw32.rs0000644000000000000000000000043212565203572015303 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License #![cfg(windows)] extern crate ktmw32; use ktmw32::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(CommitTransaction); bb(CreateTransaction); bb(RollbackTransaction); } deps/winapi-0.2.5/tests/gdi32.rs0000644000000000000000000000526712572036632015076 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License #![cfg(windows)] extern crate gdi32; use gdi32::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(Chord); bb(CreateBitmap); bb(CreateBitmapIndirect); bb(CreateDIBitmap); bb(CreateDIBSection); bb(Ellipse); bb(GetDIBits); // Not in MingGW yet // bb(Pie); bb(Polygon); bb(PolyPolygon); bb(RoundRect); bb(AngleArc); bb(Arc); bb(ArcTo); bb(GetArcDirection); bb(LineDDA); bb(LineTo); bb(MoveToEx); bb(PolyBezier); bb(PolyBezierTo); bb(PolyDraw); bb(PolyPolygon); bb(PolyPolyline); bb(Polyline); bb(PolylineTo); bb(SetArcDirection); bb(AbortDoc); bb(AbortPath); bb(AddFontMemResourceEx); bb(AddFontResourceA); bb(AddFontResourceExA); bb(AddFontResourceExW); bb(AddFontResourceW); bb(AnimatePalette); bb(BeginPath); bb(CancelDC); bb(CheckColorsInGamut); bb(CloseEnhMetaFile); bb(CloseFigure); bb(CloseMetaFile); bb(ColorCorrectPalette); bb(ColorMatchToTarget); bb(CombineTransform); bb(CopyEnhMetaFileA); bb(CopyEnhMetaFileW); bb(CopyMetaFileA); bb(CopyMetaFileW); bb(CreateBrushIndirect); bb(CreateColorSpaceA); bb(CreateColorSpaceW); bb(CreateDIBPatternBrush); bb(CreateDIBPatternBrushPt); bb(CreateDiscardableBitmap); bb(CreateEllipticRgn); bb(CreateEllipticRgnIndirect); bb(CreateEnhMetaFileA); bb(CreateEnhMetaFileW); bb(CreateFontA); bb(CreateFontIndirectA); bb(CreateFontIndirectExA); bb(CreateFontIndirectExW); bb(CreateFontIndirectW); bb(CreateFontW); bb(CreateHalftonePalette); bb(CreateHatchBrush); bb(CreateICA); bb(CreateICW); bb(CreateMetaFileA); bb(CreateMetaFileW); bb(CreatePalette); bb(CreatePatternBrush); bb(CreatePen); bb(CreatePenIndirect); bb(CreatePolyPolygonRgn); bb(CreatePolygonRgn); bb(CreateRectRgn); bb(CreateSolidBrush); bb(DeleteDC); bb(DeleteObject); bb(DescribePixelFormat); bb(ExtSelectClipRgn); bb(GetStockObject); bb(PatBlt); bb(Rectangle); bb(SelectClipRgn); bb(SelectObject); bb(SetBkColor); bb(SetDCBrushColor); bb(SetPixelFormat); bb(SetRectRgn); bb(SetTextColor); bb(StretchDIBits); bb(SwapBuffers); bb(TextOutA); bb(TextOutW); bb(DPtoLP); bb(SetPixel); bb(GetTextFaceW); bb(GetTextMetricsW); bb(RestoreDC); bb(SaveDC); bb(SetBkMode); bb(SetMapMode); bb(SetTextAlign); bb(SetViewportExtEx); bb(SetViewportOrgEx); bb(SetWindowExtEx); bb(SetROP2); bb(SetPolyFillMode); } deps/winapi-0.2.5/tests/credui.rs0000644000000000000000000000164212567222146015433 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License #![cfg(windows)] extern crate credui; use credui::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(CredPackAuthenticationBufferA); bb(CredPackAuthenticationBufferW); bb(CredUICmdLinePromptForCredentialsA); bb(CredUICmdLinePromptForCredentialsW); bb(CredUIConfirmCredentialsA); bb(CredUIConfirmCredentialsW); bb(CredUIParseUserNameA); bb(CredUIParseUserNameW); bb(CredUIPromptForCredentialsA); bb(CredUIPromptForCredentialsW); bb(CredUIPromptForWindowsCredentialsA); bb(CredUIPromptForWindowsCredentialsW); bb(CredUIReadSSOCredW); bb(CredUIStoreSSOCredW); bb(CredUnPackAuthenticationBufferA); bb(CredUnPackAuthenticationBufferW); // bb(SspiGetCredUIContext); // bb(SspiIsPromptingNeeded); // bb(SspiUnmarshalCredUIContext); // bb(SspiUpdateCredentials); } deps/winapi-0.2.5/tests/comdlg32.rs0000644000000000000000000000123712566743030015571 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License #![cfg(windows)] extern crate comdlg32; use comdlg32::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(ChooseColorA); bb(ChooseColorW); bb(ChooseFontA); bb(ChooseFontW); bb(CommDlgExtendedError); bb(FindTextA); bb(FindTextW); bb(GetFileTitleA); bb(GetFileTitleW); bb(GetOpenFileNameA); bb(GetOpenFileNameW); bb(GetSaveFileNameA); bb(GetSaveFileNameW); bb(PageSetupDlgA); bb(PageSetupDlgW); bb(PrintDlgA); bb(PrintDlgExA); bb(PrintDlgExW); bb(PrintDlgW); bb(ReplaceTextA); bb(ReplaceTextW); } deps/winapi-0.2.5/tests/advapi32.rs0000644000000000000000000000472712565203572015600 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License #![cfg(windows)] extern crate advapi32; use advapi32::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(AdjustTokenPrivileges); bb(CloseServiceHandle); bb(ControlService); bb(CreateServiceA); bb(CreateServiceW); bb(CredDeleteA); bb(CredDeleteW); bb(CredFree); bb(CredReadA); bb(CredReadW); bb(CredWriteA); bb(CredWriteW); bb(CryptAcquireContextA); bb(CryptAcquireContextW); bb(CryptCreateHash); bb(CryptDestroyHash); bb(CryptGetHashParam); bb(CryptHashData); bb(CryptReleaseContext); bb(DeleteService); bb(OpenProcessToken); bb(OpenSCManagerA); bb(OpenSCManagerW); bb(OpenServiceA); bb(OpenServiceW); bb(QueryServiceStatus); bb(QueryServiceStatusEx); bb(RegCloseKey); bb(RegConnectRegistryA); bb(RegConnectRegistryW); bb(RegCopyTreeA); bb(RegCopyTreeW); bb(RegCreateKeyExA); bb(RegCreateKeyExW); bb(RegCreateKeyTransactedA); bb(RegCreateKeyTransactedW); bb(RegDeleteKeyA); bb(RegDeleteKeyExA); bb(RegDeleteKeyExW); bb(RegDeleteKeyTransactedA); bb(RegDeleteKeyTransactedW); bb(RegDeleteKeyValueA); bb(RegDeleteKeyValueW); bb(RegDeleteKeyW); bb(RegDeleteTreeA); bb(RegDeleteTreeW); bb(RegDeleteValueA); bb(RegDeleteValueW); bb(RegDisablePredefinedCache); bb(RegDisablePredefinedCacheEx); bb(RegDisableReflectionKey); bb(RegEnableReflectionKey); bb(RegEnumKeyExA); bb(RegEnumKeyExW); bb(RegEnumValueA); bb(RegEnumValueW); bb(RegFlushKey); bb(RegGetValueA); bb(RegGetValueW); bb(RegLoadMUIStringW); bb(RegNotifyChangeKeyValue); bb(RegOpenCurrentUser); bb(RegOpenKeyExA); bb(RegOpenKeyExW); bb(RegOpenKeyTransactedA); bb(RegOpenKeyTransactedW); bb(RegOpenUserClassesRoot); bb(RegOverridePredefKey); bb(RegQueryInfoKeyA); bb(RegQueryInfoKeyW); bb(RegQueryMultipleValuesA); bb(RegQueryMultipleValuesW); bb(RegQueryReflectionKey); bb(RegQueryValueExA); bb(RegQueryValueExW); bb(RegSetKeyValueA); bb(RegSetValueExA); bb(RegSetValueExW); bb(RegSetKeyValueW); bb(RegisterServiceCtrlHandlerA); bb(RegisterServiceCtrlHandlerExA); bb(RegisterServiceCtrlHandlerExW); bb(RegisterServiceCtrlHandlerW); bb(SetServiceStatus); bb(StartServiceCtrlDispatcherA); bb(StartServiceCtrlDispatcherW); } deps/winapi-0.2.5/tests/psapi.rs0000644000000000000000000000171312566764126015303 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License #![cfg(windows)] extern crate psapi; use psapi::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(EmptyWorkingSet); bb(EnumDeviceDrivers); bb(EnumPageFilesA); bb(EnumPageFilesW); bb(EnumProcessModules); bb(EnumProcessModulesEx); bb(EnumProcesses); bb(GetDeviceDriverBaseNameA); bb(GetDeviceDriverBaseNameW); bb(GetDeviceDriverFileNameA); bb(GetDeviceDriverFileNameW); bb(GetMappedFileNameA); bb(GetMappedFileNameW); bb(GetModuleBaseNameA); bb(GetModuleBaseNameW); bb(GetModuleFileNameExA); bb(GetModuleFileNameExW); bb(GetModuleInformation); bb(GetPerformanceInfo); bb(GetProcessImageFileNameA); bb(GetProcessImageFileNameW); bb(GetProcessMemoryInfo); bb(GetWsChanges); bb(GetWsChangesEx); bb(InitializeProcessForWsWatch); bb(QueryWorkingSet); bb(QueryWorkingSetEx); } deps/winapi-0.2.5/tests/crypt32.rs0000644000000000000000000001775512565203572015502 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License #![cfg(windows)] extern crate crypt32; use crypt32::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(CertAddCRLContextToStore); bb(CertAddCRLLinkToStore); bb(CertAddCTLContextToStore); bb(CertAddCTLLinkToStore); bb(CertAddCertificateContextToStore); bb(CertAddCertificateLinkToStore); bb(CertAddEncodedCRLToStore); bb(CertAddEncodedCTLToStore); bb(CertAddEncodedCertificateToStore); bb(CertAddEncodedCertificateToSystemStoreA); bb(CertAddEncodedCertificateToSystemStoreW); bb(CertAddEnhancedKeyUsageIdentifier); bb(CertAddSerializedElementToStore); bb(CertAddStoreToCollection); bb(CertAlgIdToOID); bb(CertCloseStore); bb(CertCompareCertificate); bb(CertCompareCertificateName); bb(CertCompareIntegerBlob); bb(CertComparePublicKeyInfo); bb(CertControlStore); bb(CertCreateCRLContext); bb(CertCreateCTLContext); bb(CertCreateCTLEntryFromCertificateContextProperties); bb(CertCreateCertificateChainEngine); bb(CertCreateCertificateContext); bb(CertCreateContext); bb(CertCreateSelfSignCertificate); bb(CertDeleteCRLFromStore); bb(CertDeleteCTLFromStore); bb(CertDeleteCertificateFromStore); bb(CertDuplicateCRLContext); bb(CertDuplicateCTLContext); bb(CertDuplicateCertificateChain); bb(CertDuplicateCertificateContext); bb(CertDuplicateStore); bb(CertEnumCRLContextProperties); bb(CertEnumCRLsInStore); bb(CertEnumCTLContextProperties); bb(CertEnumCTLsInStore); bb(CertEnumCertificateContextProperties); bb(CertEnumCertificatesInStore); bb(CertEnumPhysicalStore); bb(CertEnumSubjectInSortedCTL); bb(CertEnumSystemStore); bb(CertEnumSystemStoreLocation); bb(CertFindAttribute); bb(CertFindCRLInStore); bb(CertFindCTLInStore); bb(CertFindCertificateInCRL); bb(CertFindCertificateInStore); bb(CertFindChainInStore); bb(CertFindExtension); bb(CertFindRDNAttr); bb(CertFindSubjectInCTL); bb(CertFindSubjectInSortedCTL); bb(CertFreeCRLContext); bb(CertFreeCTLContext); bb(CertFreeCertificateChain); bb(CertFreeCertificateChainEngine); bb(CertFreeCertificateContext); bb(CertGetCRLContextProperty); bb(CertGetCRLFromStore); bb(CertGetCTLContextProperty); bb(CertGetCertificateChain); bb(CertGetCertificateContextProperty); bb(CertGetEnhancedKeyUsage); bb(CertGetIntendedKeyUsage); bb(CertGetIssuerCertificateFromStore); bb(CertGetNameStringA); bb(CertGetNameStringW); bb(CertGetPublicKeyLength); bb(CertGetStoreProperty); bb(CertGetSubjectCertificateFromStore); bb(CertGetValidUsages); bb(CertIsRDNAttrsInCertificateName); bb(CertIsValidCRLForCertificate); bb(CertNameToStrA); bb(CertNameToStrW); bb(CertOIDToAlgId); bb(CertOpenStore); bb(CertOpenSystemStoreA); bb(CertOpenSystemStoreW); bb(CertRDNValueToStrA); bb(CertRDNValueToStrW); bb(CertRegisterPhysicalStore); bb(CertRegisterSystemStore); bb(CertRemoveEnhancedKeyUsageIdentifier); bb(CertRemoveStoreFromCollection); bb(CertResyncCertificateChainEngine); bb(CertSaveStore); bb(CertSerializeCRLStoreElement); bb(CertSerializeCTLStoreElement); bb(CertSerializeCertificateStoreElement); bb(CertSetCRLContextProperty); bb(CertSetCTLContextProperty); bb(CertSetCertificateContextPropertiesFromCTLEntry); bb(CertSetCertificateContextProperty); bb(CertSetEnhancedKeyUsage); bb(CertSetStoreProperty); bb(CertStrToNameA); bb(CertStrToNameW); bb(CertUnregisterPhysicalStore); bb(CertUnregisterSystemStore); bb(CertVerifyCRLRevocation); bb(CertVerifyCRLTimeValidity); bb(CertVerifyCTLUsage); bb(CertVerifyCertificateChainPolicy); bb(CertVerifyRevocation); bb(CertVerifySubjectCertificateContext); bb(CertVerifyTimeValidity); bb(CertVerifyValidityNesting); bb(CryptAcquireCertificatePrivateKey); bb(CryptBinaryToStringA); bb(CryptBinaryToStringW); bb(CryptCloseAsyncHandle); bb(CryptCreateAsyncHandle); bb(CryptCreateKeyIdentifierFromCSP); bb(CryptDecodeMessage); bb(CryptDecodeObject); bb(CryptDecodeObjectEx); bb(CryptDecryptAndVerifyMessageSignature); bb(CryptDecryptMessage); bb(CryptEncodeObject); bb(CryptEncodeObjectEx); bb(CryptEncryptMessage); bb(CryptEnumKeyIdentifierProperties); bb(CryptEnumOIDFunction); bb(CryptEnumOIDInfo); bb(CryptExportPKCS8); bb(CryptExportPublicKeyInfo); bb(CryptExportPublicKeyInfoEx); bb(CryptFindCertificateKeyProvInfo); bb(CryptFindLocalizedName); bb(CryptFindOIDInfo); bb(CryptFormatObject); bb(CryptFreeOIDFunctionAddress); bb(CryptGetAsyncParam); bb(CryptGetDefaultOIDDllList); bb(CryptGetDefaultOIDFunctionAddress); bb(CryptGetKeyIdentifierProperty); bb(CryptGetMessageCertificates); bb(CryptGetMessageSignerCount); bb(CryptGetOIDFunctionAddress); bb(CryptGetOIDFunctionValue); bb(CryptHashCertificate); bb(CryptHashMessage); bb(CryptHashPublicKeyInfo); bb(CryptHashToBeSigned); bb(CryptImportPKCS8); bb(CryptImportPublicKeyInfo); bb(CryptImportPublicKeyInfoEx); bb(CryptInitOIDFunctionSet); bb(CryptInstallDefaultContext); bb(CryptInstallOIDFunctionAddress); bb(CryptMemAlloc); bb(CryptMemFree); bb(CryptMemRealloc); bb(CryptMsgCalculateEncodedLength); bb(CryptMsgClose); bb(CryptMsgControl); bb(CryptMsgCountersign); bb(CryptMsgCountersignEncoded); bb(CryptMsgDuplicate); bb(CryptMsgEncodeAndSignCTL); bb(CryptMsgGetAndVerifySigner); bb(CryptMsgGetParam); bb(CryptMsgOpenToDecode); bb(CryptMsgOpenToEncode); bb(CryptMsgSignCTL); bb(CryptMsgUpdate); bb(CryptMsgVerifyCountersignatureEncoded); bb(CryptMsgVerifyCountersignatureEncodedEx); bb(CryptProtectData); bb(CryptQueryObject); bb(CryptRegisterDefaultOIDFunction); bb(CryptRegisterOIDFunction); bb(CryptRegisterOIDInfo); bb(CryptSIPAddProvider); bb(CryptSIPCreateIndirectData); bb(CryptSIPGetSignedDataMsg); bb(CryptSIPLoad); bb(CryptSIPPutSignedDataMsg); bb(CryptSIPRemoveProvider); bb(CryptSIPRemoveSignedDataMsg); bb(CryptSIPRetrieveSubjectGuid); bb(CryptSIPVerifyIndirectData); bb(CryptSetAsyncParam); bb(CryptSetKeyIdentifierProperty); bb(CryptSetOIDFunctionValue); bb(CryptSignAndEncodeCertificate); bb(CryptSignAndEncryptMessage); bb(CryptSignCertificate); bb(CryptSignMessage); bb(CryptSignMessageWithKey); bb(CryptStringToBinaryA); bb(CryptStringToBinaryW); bb(CryptUninstallDefaultContext); bb(CryptUnprotectData); bb(CryptUnregisterDefaultOIDFunction); bb(CryptUnregisterOIDFunction); bb(CryptUnregisterOIDInfo); bb(CryptVerifyCertificateSignature); bb(CryptVerifyCertificateSignatureEx); bb(CryptVerifyDetachedMessageHash); bb(CryptVerifyDetachedMessageSignature); bb(CryptVerifyMessageHash); bb(CryptVerifyMessageSignature); bb(CryptVerifyMessageSignatureWithKey); bb(PFXExportCertStore); bb(PFXExportCertStoreEx); bb(PFXImportCertStore); bb(PFXIsPFXBlob); bb(PFXVerifyPassword); } #[cfg(target_env = "msvc")] #[test] fn functions_msvc() { bb(CertAddRefServerOcspResponse); bb(CertAddRefServerOcspResponseContext); bb(CertCloseServerOcspResponse); bb(CertFreeServerOcspResponseContext); bb(CertGetServerOcspResponseContext); bb(CertFreeCertificateChainList); bb(CertOpenServerOcspResponse); bb(CertIsStrongHashToSign); bb(CertRetrieveLogoOrBiometricInfo); bb(CertSelectCertificateChains); bb(CryptExportPublicKeyInfoFromBCryptKeyHandle); bb(CryptHashCertificate2); bb(CryptImportPublicKeyInfoEx2); bb(CryptRetrieveTimeStamp); bb(CryptSIPGetCaps); bb(CryptSIPGetSealedDigest); bb(CryptUpdateProtectedState); bb(CryptVerifyTimeStampSignature); bb(CryptProtectMemory); bb(CryptUnprotectMemory); } deps/winapi-0.2.5/tests/d3d11.rs0000644000000000000000000000040712577275501014776 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License #![cfg(windows)] extern crate d3d11; use d3d11::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(D3D11CreateDevice); bb(D3D11CreateDeviceAndSwapChain); } deps/winapi-0.2.5/tests/ws2_32.rs0000644000000000000000000001043012565203572015172 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License #![cfg(windows)] extern crate ws2_32; use ws2_32::*; #[inline(never)] fn bb(_: T) {} #[test] #[cfg(target_arch="x86")] fn functions_x86() { bb(WSCInstallProviderAndChains); } #[test] #[cfg(target_arch="x86_64")] fn functions_x86_64() { bb(WSCDeinstallProvider32); bb(WSCEnableNSProvider32); bb(WSCEnumNameSpaceProviders32); bb(WSCEnumNameSpaceProvidersEx32); bb(WSCEnumProtocols32); bb(WSCGetProviderInfo32); bb(WSCGetProviderPath32); bb(WSCInstallNameSpace32); bb(WSCInstallProvider64_32); bb(WSCInstallProviderAndChains64_32); bb(WSCSetProviderInfo32); bb(WSCUnInstallNameSpace32); bb(WSCUpdateProvider32); bb(WSCWriteNameSpaceOrder32); bb(WSCWriteProviderOrder32); } #[test] #[cfg(target_env="msvc")] fn functions_msvc() { bb(GetAddrInfoExCancel); bb(GetAddrInfoExOverlappedResult); bb(GetHostNameW); } #[test] fn functions() { bb(FreeAddrInfoEx); bb(FreeAddrInfoExW); bb(FreeAddrInfoW); bb(GetAddrInfoExA); bb(GetAddrInfoExW); bb(GetAddrInfoW); bb(GetNameInfoW); bb(InetNtopW); bb(InetPtonW); bb(SetAddrInfoExA); bb(SetAddrInfoExW); bb(WPUCompleteOverlappedRequest); bb(WSAAccept); bb(WSAAddressToStringA); bb(WSAAddressToStringW); bb(WSAAdvertiseProvider); bb(WSAAsyncGetHostByAddr); bb(WSAAsyncGetHostByName); bb(WSAAsyncGetProtoByName); bb(WSAAsyncGetProtoByNumber); bb(WSAAsyncGetServByName); bb(WSAAsyncGetServByPort); bb(WSAAsyncSelect); bb(WSACancelAsyncRequest); bb(WSACancelBlockingCall); bb(WSACleanup); bb(WSACloseEvent); bb(WSAConnect); bb(WSAConnectByList); bb(WSAConnectByNameA); bb(WSAConnectByNameW); bb(WSACreateEvent); bb(WSADuplicateSocketA); bb(WSADuplicateSocketW); bb(WSAEnumNameSpaceProvidersA); bb(WSAEnumNameSpaceProvidersExA); bb(WSAEnumNameSpaceProvidersExW); bb(WSAEnumNameSpaceProvidersW); bb(WSAEnumNetworkEvents); bb(WSAEnumProtocolsA); bb(WSAEnumProtocolsW); bb(WSAEventSelect); bb(WSAGetLastError); bb(WSAGetOverlappedResult); bb(WSAGetQOSByName); bb(WSAGetServiceClassInfoA); bb(WSAGetServiceClassInfoW); bb(WSAGetServiceClassNameByClassIdA); bb(WSAGetServiceClassNameByClassIdW); bb(WSAHtonl); bb(WSAHtons); bb(WSAIoctl); bb(WSAIsBlocking); bb(WSAJoinLeaf); bb(WSALookupServiceBeginA); bb(WSALookupServiceBeginW); bb(WSALookupServiceEnd); bb(WSALookupServiceNextA); bb(WSALookupServiceNextW); bb(WSANSPIoctl); bb(WSANtohl); bb(WSANtohs); bb(WSAPoll); bb(WSAProviderCompleteAsyncCall); bb(WSAProviderConfigChange); bb(WSARecv); bb(WSARecvDisconnect); bb(WSARecvFrom); bb(WSARemoveServiceClass); bb(WSAResetEvent); bb(WSASend); bb(WSASendDisconnect); bb(WSASendMsg); bb(WSASendTo); bb(WSASetBlockingHook); bb(WSASetEvent); bb(WSASetLastError); bb(WSASetServiceA); bb(WSASetServiceW); bb(WSASocketA); bb(WSASocketW); bb(WSAStartup); bb(WSAStringToAddressA); bb(WSAStringToAddressW); bb(WSAUnadvertiseProvider); bb(WSAUnhookBlockingHook); bb(WSAWaitForMultipleEvents); bb(WSCDeinstallProvider); bb(WSCEnableNSProvider); bb(WSCEnumProtocols); bb(WSCGetApplicationCategory); bb(WSCGetProviderInfo); bb(WSCGetProviderPath); bb(WSCInstallNameSpace); bb(WSCInstallNameSpaceEx); bb(WSCInstallProvider); bb(WSCSetApplicationCategory); bb(WSCSetProviderInfo); bb(WSCUpdateProvider); bb(WSCWriteNameSpaceOrder); bb(WSCWriteProviderOrder); bb(accept); bb(closesocket); bb(connect); bb(freeaddrinfo); bb(getaddrinfo); bb(gethostbyaddr); bb(gethostbyname); bb(gethostname); bb(getnameinfo); bb(getpeername); bb(getprotobyname); bb(getprotobynumber); bb(getservbyname); bb(getservbyport); bb(getsockname); bb(getsockopt); bb(htonl); bb(htons); bb(inet_addr); bb(inet_ntoa); bb(inet_ntop); bb(inet_pton); bb(ioctlsocket); bb(listen); bb(ntohl); bb(ntohs); bb(recv); bb(recvfrom); bb(select); bb(send); bb(sendto); bb(setsockopt); bb(shutdown); bb(socket); } deps/winapi-0.2.5/tests/uuid.rs0000644000000000000000000000766712600361211015124 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License #![cfg(windows)] #![cfg(not(target_env = "msvc"))] // FIXME - https://github.com/rust-lang/rust/issues/27438 extern crate uuid; use uuid::*; #[inline(never)] fn bb(_: T) {} #[test] fn statics() { bb(FOLDERID_AccountPictures); bb(FOLDERID_AddNewPrograms); bb(FOLDERID_AdminTools); bb(FOLDERID_AppUpdates); bb(FOLDERID_ApplicationShortcuts); bb(FOLDERID_AppsFolder); bb(FOLDERID_CDBurning); // bb(FOLDERID_CameraRoll); bb(FOLDERID_ChangeRemovePrograms); bb(FOLDERID_CommonAdminTools); bb(FOLDERID_CommonOEMLinks); bb(FOLDERID_CommonPrograms); bb(FOLDERID_CommonStartMenu); bb(FOLDERID_CommonStartup); bb(FOLDERID_CommonTemplates); bb(FOLDERID_ComputerFolder); bb(FOLDERID_ConflictFolder); bb(FOLDERID_ConnectionsFolder); bb(FOLDERID_Contacts); bb(FOLDERID_ControlPanelFolder); bb(FOLDERID_Cookies); bb(FOLDERID_Desktop); bb(FOLDERID_DeviceMetadataStore); bb(FOLDERID_Documents); bb(FOLDERID_DocumentsLibrary); bb(FOLDERID_Downloads); bb(FOLDERID_Favorites); bb(FOLDERID_Fonts); bb(FOLDERID_GameTasks); bb(FOLDERID_Games); bb(FOLDERID_History); bb(FOLDERID_HomeGroup); bb(FOLDERID_HomeGroupCurrentUser); bb(FOLDERID_ImplicitAppShortcuts); bb(FOLDERID_InternetCache); bb(FOLDERID_InternetFolder); bb(FOLDERID_Libraries); bb(FOLDERID_Links); bb(FOLDERID_LocalAppData); bb(FOLDERID_LocalAppDataLow); bb(FOLDERID_LocalizedResourcesDir); bb(FOLDERID_Music); bb(FOLDERID_MusicLibrary); bb(FOLDERID_NetHood); bb(FOLDERID_NetworkFolder); bb(FOLDERID_OriginalImages); bb(FOLDERID_PhotoAlbums); bb(FOLDERID_Pictures); bb(FOLDERID_PicturesLibrary); bb(FOLDERID_Playlists); bb(FOLDERID_PrintHood); bb(FOLDERID_PrintersFolder); bb(FOLDERID_Profile); bb(FOLDERID_ProgramData); bb(FOLDERID_ProgramFiles); bb(FOLDERID_ProgramFilesCommon); bb(FOLDERID_ProgramFilesCommonX64); bb(FOLDERID_ProgramFilesCommonX86); bb(FOLDERID_ProgramFilesX64); bb(FOLDERID_ProgramFilesX86); bb(FOLDERID_Programs); bb(FOLDERID_Public); bb(FOLDERID_PublicDesktop); bb(FOLDERID_PublicDocuments); bb(FOLDERID_PublicDownloads); bb(FOLDERID_PublicGameTasks); bb(FOLDERID_PublicLibraries); bb(FOLDERID_PublicMusic); bb(FOLDERID_PublicPictures); bb(FOLDERID_PublicRingtones); bb(FOLDERID_PublicUserTiles); bb(FOLDERID_PublicVideos); bb(FOLDERID_QuickLaunch); bb(FOLDERID_Recent); bb(FOLDERID_RecordedTVLibrary); bb(FOLDERID_RecycleBinFolder); bb(FOLDERID_ResourceDir); bb(FOLDERID_Ringtones); bb(FOLDERID_RoamedTileImages); bb(FOLDERID_RoamingAppData); bb(FOLDERID_RoamingTiles); bb(FOLDERID_SEARCH_CSC); bb(FOLDERID_SEARCH_MAPI); bb(FOLDERID_SampleMusic); bb(FOLDERID_SamplePictures); bb(FOLDERID_SamplePlaylists); bb(FOLDERID_SampleVideos); bb(FOLDERID_SavedGames); bb(FOLDERID_SavedSearches); bb(FOLDERID_Screenshots); // bb(FOLDERID_SearchHistory); bb(FOLDERID_SearchHome); // bb(FOLDERID_SearchTemplates); bb(FOLDERID_SendTo); bb(FOLDERID_SidebarDefaultParts); bb(FOLDERID_SidebarParts); // bb(FOLDERID_SkyDrive); // bb(FOLDERID_SkyDriveCameraRoll); // bb(FOLDERID_SkyDriveDocuments); // bb(FOLDERID_SkyDriveMusic); // bb(FOLDERID_SkyDrivePictures); bb(FOLDERID_StartMenu); bb(FOLDERID_Startup); bb(FOLDERID_SyncManagerFolder); bb(FOLDERID_SyncResultsFolder); bb(FOLDERID_SyncSetupFolder); bb(FOLDERID_System); bb(FOLDERID_SystemX86); bb(FOLDERID_Templates); bb(FOLDERID_UserPinned); bb(FOLDERID_UserProfiles); bb(FOLDERID_UserProgramFiles); bb(FOLDERID_UserProgramFilesCommon); bb(FOLDERID_UsersFiles); bb(FOLDERID_UsersLibraries); bb(FOLDERID_Videos); bb(FOLDERID_VideosLibrary); bb(FOLDERID_Windows); } deps/winapi-0.2.5/tests/netapi32.rs0000644000000000000000000001350712577105677015622 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License #![cfg(windows)] extern crate netapi32; use netapi32::*; #[inline(never)] fn bb(_: T) {} #[test] #[cfg(target_env = "msvc")] fn functions_msvc() { bb(NetCreateProvisioningPackage); bb(NetRequestProvisioningPackageInstall); } #[test] fn functions() { bb(DavAddConnection); bb(DavDeleteConnection); bb(DavFlushFile); bb(DavGetExtendedError); bb(DavGetHTTPFromUNCPath); bb(DavGetUNCFromHTTPPath); bb(DsAddressToSiteNamesA); bb(DsAddressToSiteNamesExA); bb(DsAddressToSiteNamesExW); bb(DsAddressToSiteNamesW); bb(DsDeregisterDnsHostRecordsA); bb(DsDeregisterDnsHostRecordsW); bb(DsEnumerateDomainTrustsA); bb(DsEnumerateDomainTrustsW); bb(DsGetDcCloseW); bb(DsGetDcNameA); bb(DsGetDcNameW); bb(DsGetDcNextA); bb(DsGetDcNextW); bb(DsGetDcOpenA); bb(DsGetDcOpenW); bb(DsGetDcSiteCoverageA); bb(DsGetDcSiteCoverageW); bb(DsGetForestTrustInformationW); bb(DsGetSiteNameA); bb(DsGetSiteNameW); bb(DsMergeForestTrustInformationW); bb(DsRoleFreeMemory); bb(DsRoleGetPrimaryDomainInformation); bb(DsValidateSubnetNameA); bb(DsValidateSubnetNameW); bb(I_NetLogonControl2); bb(NetAccessAdd); bb(NetAccessDel); bb(NetAccessEnum); bb(NetAccessGetInfo); bb(NetAccessGetUserPerms); bb(NetAccessSetInfo); bb(NetAddAlternateComputerName); bb(NetAddServiceAccount); bb(NetAlertRaise); bb(NetAlertRaiseEx); bb(NetApiBufferAllocate); bb(NetApiBufferFree); bb(NetApiBufferReallocate); bb(NetApiBufferSize); bb(NetAuditClear); bb(NetAuditRead); bb(NetAuditWrite); bb(NetConfigGet); bb(NetConfigGetAll); bb(NetConfigSet); bb(NetConnectionEnum); bb(NetDfsAdd); bb(NetDfsAddFtRoot); bb(NetDfsAddRootTarget); bb(NetDfsAddStdRoot); bb(NetDfsEnum); bb(NetDfsGetClientInfo); bb(NetDfsGetFtContainerSecurity); bb(NetDfsGetInfo); bb(NetDfsGetSecurity); bb(NetDfsGetStdContainerSecurity); bb(NetDfsGetSupportedNamespaceVersion); bb(NetDfsMove); bb(NetDfsRemove); bb(NetDfsRemoveFtRoot); bb(NetDfsRemoveFtRootForced); bb(NetDfsRemoveRootTarget); bb(NetDfsRemoveStdRoot); bb(NetDfsSetClientInfo); bb(NetDfsSetFtContainerSecurity); bb(NetDfsSetInfo); bb(NetDfsSetSecurity); bb(NetDfsSetStdContainerSecurity); bb(NetEnumerateComputerNames); bb(NetEnumerateServiceAccounts); bb(NetErrorLogClear); bb(NetErrorLogRead); bb(NetErrorLogWrite); bb(NetFileClose); bb(NetFileEnum); bb(NetFileGetInfo); bb(NetGetAnyDCName); bb(NetGetDCName); bb(NetGetDisplayInformationIndex); bb(NetGetJoinInformation); bb(NetGetJoinableOUs); bb(NetGroupAdd); bb(NetGroupAddUser); bb(NetGroupDel); bb(NetGroupDelUser); bb(NetGroupEnum); bb(NetGroupGetInfo); bb(NetGroupGetUsers); bb(NetGroupSetInfo); bb(NetGroupSetUsers); bb(NetIsServiceAccount); bb(NetJoinDomain); bb(NetLocalGroupAdd); bb(NetLocalGroupAddMember); bb(NetLocalGroupAddMembers); bb(NetLocalGroupDel); bb(NetLocalGroupDelMember); bb(NetLocalGroupDelMembers); bb(NetLocalGroupEnum); bb(NetLocalGroupGetInfo); bb(NetLocalGroupGetMembers); bb(NetLocalGroupSetInfo); bb(NetLocalGroupSetMembers); bb(NetMessageBufferSend); bb(NetMessageNameAdd); bb(NetMessageNameDel); bb(NetMessageNameEnum); bb(NetMessageNameGetInfo); bb(NetProvisionComputerAccount); bb(NetQueryDisplayInformation); bb(NetQueryServiceAccount); bb(NetRemoteComputerSupports); bb(NetRemoteTOD); bb(NetRemoveAlternateComputerName); bb(NetRemoveServiceAccount); bb(NetRenameMachineInDomain); bb(NetReplExportDirAdd); bb(NetReplExportDirDel); bb(NetReplExportDirEnum); bb(NetReplExportDirGetInfo); bb(NetReplExportDirLock); bb(NetReplExportDirSetInfo); bb(NetReplExportDirUnlock); bb(NetReplGetInfo); bb(NetReplImportDirAdd); bb(NetReplImportDirDel); bb(NetReplImportDirEnum); bb(NetReplImportDirGetInfo); bb(NetReplImportDirLock); bb(NetReplImportDirUnlock); bb(NetReplSetInfo); bb(NetRequestOfflineDomainJoin); bb(NetScheduleJobAdd); bb(NetScheduleJobDel); bb(NetScheduleJobEnum); bb(NetScheduleJobGetInfo); bb(NetServerAliasAdd); bb(NetServerAliasDel); bb(NetServerAliasEnum); bb(NetServerComputerNameAdd); bb(NetServerComputerNameDel); bb(NetServerDiskEnum); bb(NetServerEnum); bb(NetServerGetInfo); bb(NetServerSetInfo); bb(NetServerTransportAdd); bb(NetServerTransportAddEx); bb(NetServerTransportDel); bb(NetServerTransportEnum); bb(NetServiceControl); bb(NetServiceEnum); bb(NetServiceGetInfo); bb(NetServiceInstall); bb(NetSessionDel); bb(NetSessionEnum); bb(NetSessionGetInfo); bb(NetSetPrimaryComputerName); bb(NetShareAdd); bb(NetShareCheck); bb(NetShareDel); bb(NetShareDelEx); bb(NetShareDelSticky); bb(NetShareEnum); bb(NetShareEnumSticky); bb(NetShareGetInfo); bb(NetShareSetInfo); bb(NetStatisticsGet); bb(NetUnjoinDomain); bb(NetUseAdd); bb(NetUseDel); bb(NetUseEnum); bb(NetUseGetInfo); bb(NetUserAdd); bb(NetUserChangePassword); bb(NetUserDel); bb(NetUserEnum); bb(NetUserGetGroups); bb(NetUserGetInfo); bb(NetUserModalsGet); bb(NetUserModalsSet); bb(NetUserSetGroups); bb(NetUserSetInfo); bb(NetValidateName); bb(NetValidatePasswordPolicy); bb(NetValidatePasswordPolicyFree); bb(NetWkstaGetInfo); bb(NetWkstaSetInfo); bb(NetWkstaTransportAdd); bb(NetWkstaTransportDel); bb(NetWkstaTransportEnum); bb(NetWkstaUserEnum); bb(NetWkstaUserGetInfo); bb(NetWkstaUserSetInfo); bb(Netbios); } deps/winapi-0.2.5/tests/bcrypt.rs0000644000000000000000000000357612565203572015473 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License #![cfg(windows)] extern crate bcrypt; use bcrypt::*; #[inline(never)] fn bb(_: T) {} #[test] #[cfg(target_env = "msvc")] fn functions_msvc() { bb(BCryptCreateMultiHash); bb(BCryptDeriveKeyCapi); bb(BCryptDeriveKeyPBKDF2); bb(BCryptKeyDerivation); bb(BCryptProcessMultiOperations); } #[test] fn functions() { bb(BCryptAddContextFunction); bb(BCryptCloseAlgorithmProvider); bb(BCryptConfigureContext); bb(BCryptConfigureContextFunction); bb(BCryptCreateContext); bb(BCryptCreateHash); bb(BCryptDecrypt); bb(BCryptDeleteContext); bb(BCryptDeriveKey); bb(BCryptDestroyHash); bb(BCryptDestroyKey); bb(BCryptDestroySecret); bb(BCryptDuplicateHash); bb(BCryptDuplicateKey); bb(BCryptEncrypt); bb(BCryptEnumAlgorithms); bb(BCryptEnumContextFunctionProviders); bb(BCryptEnumContextFunctions); bb(BCryptEnumContexts); bb(BCryptEnumProviders); bb(BCryptEnumRegisteredProviders); bb(BCryptExportKey); bb(BCryptFinalizeKeyPair); bb(BCryptFinishHash); bb(BCryptFreeBuffer); bb(BCryptGenRandom); bb(BCryptGenerateKeyPair); bb(BCryptGenerateSymmetricKey); bb(BCryptGetFipsAlgorithmMode); bb(BCryptGetProperty); bb(BCryptHashData); bb(BCryptImportKey); bb(BCryptImportKeyPair); bb(BCryptOpenAlgorithmProvider); bb(BCryptQueryContextConfiguration); bb(BCryptQueryContextFunctionConfiguration); bb(BCryptQueryContextFunctionProperty); bb(BCryptQueryProviderRegistration); bb(BCryptRegisterConfigChangeNotify); bb(BCryptRemoveContextFunction); bb(BCryptResolveProviders); bb(BCryptSecretAgreement); bb(BCryptSetContextFunctionProperty); bb(BCryptSetProperty); bb(BCryptSignHash); bb(BCryptUnregisterConfigChangeNotify); bb(BCryptVerifySignature); } deps/winapi-0.2.5/tests/httpapi.rs0000644000000000000000000000255012565203572015630 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License #![cfg(windows)] extern crate httpapi; use httpapi::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(HttpAddFragmentToCache); bb(HttpAddUrl); bb(HttpAddUrlToUrlGroup); bb(HttpCancelHttpRequest); bb(HttpCloseRequestQueue); bb(HttpCloseServerSession); bb(HttpCloseUrlGroup); bb(HttpCreateHttpHandle); bb(HttpCreateRequestQueue); bb(HttpCreateServerSession); bb(HttpCreateUrlGroup); bb(HttpDeleteServiceConfiguration); bb(HttpFlushResponseCache); bb(HttpInitialize); // bb(HttpPrepareUrl); ------> Windows 8 API bb(HttpQueryRequestQueueProperty); bb(HttpQueryServerSessionProperty); bb(HttpQueryServiceConfiguration); bb(HttpQueryUrlGroupProperty); bb(HttpReadFragmentFromCache); bb(HttpReceiveClientCertificate); bb(HttpReceiveHttpRequest); bb(HttpReceiveRequestEntityBody); bb(HttpRemoveUrl); bb(HttpRemoveUrlFromUrlGroup); bb(HttpSendHttpResponse); bb(HttpSendResponseEntityBody); bb(HttpSetRequestQueueProperty); bb(HttpSetServerSessionProperty); bb(HttpSetServiceConfiguration); bb(HttpSetUrlGroupProperty); bb(HttpShutdownRequestQueue); bb(HttpTerminate); bb(HttpWaitForDemandStart); bb(HttpWaitForDisconnect); bb(HttpWaitForDisconnectEx); } deps/winapi-0.2.5/tests/dxgi.rs0000644000000000000000000000104112617171733015105 0ustar rootroot// Copyright © 2015, Dmitry Roschin // Licensed under the MIT License #![cfg(windows)] extern crate dxgi; use dxgi::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(CreateDXGIFactory); bb(CreateDXGIFactory1); // bb(CreateDXGIFactory2); // bb(DXGIGetDebugInterface1); } #[cfg(target_env = "msvc")] #[test] fn msvc_functions() { bb(CreateDXGIFactory); bb(CreateDXGIFactory1); // Build server lacks latest version of Windows SDK // bb(CreateDXGIFactory2); // bb(DXGIGetDebugInterface1); } deps/winapi-0.2.5/tests/usp10.rs0000644000000000000000000000251312565203572015126 0ustar rootroot// Copyright © 2015, Jordan Miner // Licensed under the MIT License #![cfg(windows)] extern crate usp10; use usp10::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(ScriptApplyDigitSubstitution); bb(ScriptApplyLogicalWidth); bb(ScriptBreak); bb(ScriptCPtoX); bb(ScriptCacheGetHeight); bb(ScriptFreeCache); bb(ScriptGetCMap); bb(ScriptGetFontAlternateGlyphs); bb(ScriptGetFontFeatureTags); bb(ScriptGetFontLanguageTags); bb(ScriptGetFontProperties); bb(ScriptGetFontScriptTags); bb(ScriptGetGlyphABCWidth); bb(ScriptGetLogicalWidths); bb(ScriptGetProperties); bb(ScriptIsComplex); bb(ScriptItemize); bb(ScriptItemizeOpenType); bb(ScriptJustify); bb(ScriptLayout); bb(ScriptPlace); bb(ScriptPlaceOpenType); bb(ScriptPositionSingleGlyph); bb(ScriptRecordDigitSubstitution); bb(ScriptShape); bb(ScriptShapeOpenType); bb(ScriptStringAnalyse); bb(ScriptStringCPtoX); bb(ScriptStringFree); bb(ScriptStringGetLogicalWidths); bb(ScriptStringGetOrder); bb(ScriptStringOut); bb(ScriptStringValidate); bb(ScriptStringXtoCP); bb(ScriptString_pLogAttr); bb(ScriptString_pSize); bb(ScriptString_pcOutChars); bb(ScriptSubstituteSingleGlyph); bb(ScriptTextOut); bb(ScriptXtoCP); } deps/winapi-0.2.5/tests/winscard.rs0000644000000000000000000000447212601124124015760 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License #![cfg(windows)] extern crate winscard; use winscard::*; #[inline(never)] fn bb(_: T) {} #[test] #[cfg(target_env = "msvc")] fn functions_msvc() { bb(SCardAudit); bb(SCardGetDeviceTypeIdA); bb(SCardGetDeviceTypeIdW); bb(SCardGetReaderDeviceInstanceIdA); bb(SCardGetReaderDeviceInstanceIdW); bb(SCardGetReaderIconA); bb(SCardGetReaderIconW); bb(SCardListReadersWithDeviceInstanceIdA); bb(SCardListReadersWithDeviceInstanceIdW); } #[test] fn functions() { bb(SCardAccessStartedEvent); bb(SCardAddReaderToGroupA); bb(SCardAddReaderToGroupW); bb(SCardBeginTransaction); bb(SCardCancel); bb(SCardConnectA); bb(SCardConnectW); bb(SCardControl); bb(SCardDisconnect); bb(SCardEndTransaction); bb(SCardEstablishContext); bb(SCardForgetCardTypeA); bb(SCardForgetCardTypeW); bb(SCardForgetReaderA); bb(SCardForgetReaderGroupA); bb(SCardForgetReaderGroupW); bb(SCardForgetReaderW); bb(SCardFreeMemory); bb(SCardGetAttrib); bb(SCardGetCardTypeProviderNameA); bb(SCardGetCardTypeProviderNameW); bb(SCardGetProviderIdA); bb(SCardGetProviderIdW); bb(SCardGetStatusChangeA); bb(SCardGetStatusChangeW); bb(SCardGetTransmitCount); bb(SCardIntroduceCardTypeA); bb(SCardIntroduceCardTypeW); bb(SCardIntroduceReaderA); bb(SCardIntroduceReaderGroupA); bb(SCardIntroduceReaderGroupW); bb(SCardIntroduceReaderW); bb(SCardIsValidContext); bb(SCardListCardsA); bb(SCardListCardsW); bb(SCardListInterfacesA); bb(SCardListInterfacesW); bb(SCardListReaderGroupsA); bb(SCardListReaderGroupsW); bb(SCardListReadersA); bb(SCardListReadersW); bb(SCardLocateCardsA); bb(SCardLocateCardsByATRA); bb(SCardLocateCardsByATRW); bb(SCardLocateCardsW); bb(SCardReadCacheA); bb(SCardReadCacheW); bb(SCardReconnect); bb(SCardReleaseContext); bb(SCardReleaseStartedEvent); bb(SCardRemoveReaderFromGroupA); bb(SCardRemoveReaderFromGroupW); bb(SCardSetAttrib); bb(SCardSetCardTypeProviderNameA); bb(SCardSetCardTypeProviderNameW); bb(SCardState); bb(SCardStatusA); bb(SCardStatusW); bb(SCardTransmit); bb(SCardWriteCacheA); bb(SCardWriteCacheW); } deps/winapi-0.2.5/tests/user32.rs0000644000000000000000000002516612572036632015311 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License #![cfg(windows)] extern crate user32; use user32::*; #[inline(never)] fn bb(_: T) {} #[cfg(target_arch = "x86_64")] #[test] fn functions_x64() { bb(GetClassLongPtrA); bb(GetClassLongPtrW); bb(GetWindowLongPtrA); bb(GetWindowLongPtrW); bb(SetClassLongPtrA); bb(SetClassLongPtrW); bb(SetWindowLongPtrA); bb(SetWindowLongPtrW); } #[test] fn functions() { bb(ActivateKeyboardLayout); // bb(AddClipboardFormatListener); bb(AdjustWindowRect); bb(AdjustWindowRectEx); bb(AllowSetForegroundWindow); bb(AnimateWindow); bb(AnyPopup); bb(ArrangeIconicWindows); bb(AttachThreadInput); bb(BeginPaint); bb(BlockInput); bb(BringWindowToTop); // bb(CalculatePopupWindowPosition); bb(CallMsgFilterA); bb(CallMsgFilterW); bb(CallNextHookEx); bb(CallWindowProcA); bb(CallWindowProcW); bb(CascadeWindows); bb(ChangeClipboardChain); bb(ChangeDisplaySettingsA); bb(ChangeDisplaySettingsExA); bb(ChangeDisplaySettingsExW); bb(ChangeDisplaySettingsW); bb(ChangeMenuA); bb(ChangeMenuW); // bb(ChangeWindowMessageFilter); // bb(ChangeWindowMessageFilterEx); bb(CharLowerA); bb(CharLowerBuffA); bb(CharLowerBuffW); bb(CharLowerW); bb(CharNextA); bb(CharNextExA); bb(CharNextW); bb(CharPrevA); bb(CharPrevExA); bb(CharPrevW); bb(CharUpperA); bb(CharUpperBuffA); bb(CharUpperBuffW); bb(CharUpperW); bb(ChildWindowFromPoint); bb(ChildWindowFromPointEx); bb(ClipCursor); bb(CloseClipboard); bb(CloseDesktop); bb(CloseWindow); bb(CloseWindowStation); bb(CopyAcceleratorTableA); bb(CopyAcceleratorTableW); bb(CopyIcon); bb(CopyImage); bb(CopyRect); bb(CountClipboardFormats); bb(CreateAcceleratorTableA); bb(CreateAcceleratorTableW); bb(CreateCaret); bb(CreateCursor); bb(CreateDesktopA); bb(CreateDesktopW); bb(CreateDialogIndirectParamA); bb(CreateDialogIndirectParamW); bb(CreateDialogParamA); bb(CreateDialogParamW); bb(CreateIcon); bb(CreateIconFromResource); bb(CreateIconFromResourceEx); bb(CreateIconIndirect); bb(CreateMDIWindowA); bb(CreateMDIWindowW); bb(CreateMenu); bb(CreatePopupMenu); bb(CreateWindowExA); bb(CreateWindowExW); bb(CreateWindowStationA); bb(CreateWindowStationW); bb(DefDlgProcA); bb(DefDlgProcW); bb(DefFrameProcA); bb(DefFrameProcW); bb(DefMDIChildProcA); bb(DefMDIChildProcW); bb(DefRawInputProc); bb(DefWindowProcA); bb(DefWindowProcW); bb(DeferWindowPos); bb(DeleteMenu); bb(DeregisterShellHookWindow); bb(DestroyAcceleratorTable); bb(DestroyCaret); bb(DestroyCursor); bb(DestroyIcon); bb(DestroyMenu); bb(DestroyWindow); bb(DialogBoxIndirectParamA); bb(DialogBoxIndirectParamW); bb(DialogBoxParamA); bb(DialogBoxParamW); bb(DispatchMessageA); bb(DispatchMessageW); bb(DragDetect); bb(DragObject); bb(DrawAnimatedRects); bb(DrawCaption); bb(DrawEdge); bb(DrawFocusRect); bb(DrawFrameControl); bb(DrawIcon); bb(DrawIconEx); bb(DrawMenuBar); bb(DrawStateA); bb(DrawStateW); bb(DrawTextA); bb(DrawTextExA); bb(DrawTextExW); bb(DrawTextW); bb(EmptyClipboard); bb(EnableMenuItem); //bb(EnableMouseInPointer); bb(EnableScrollBar); bb(EnableWindow); bb(EndDeferWindowPos); bb(EndDialog); //bb(EndMenu); bb(EndPaint); bb(EndTask); bb(EnumClipboardFormats); bb(EnumDesktopWindows); bb(EnumDesktopsA); bb(EnumDesktopsW); bb(EnumDisplayDevicesA); bb(EnumDisplayDevicesW); bb(EnumDisplayMonitors); bb(EnumDisplaySettingsA); bb(EnumDisplaySettingsExA); bb(EnumDisplaySettingsExW); bb(EnumDisplaySettingsW); bb(EnumPropsA); bb(EnumPropsExA); bb(EnumPropsExW); bb(EnumPropsW); bb(EnumThreadWindows); bb(EnumWindowStationsA); bb(EnumWindowStationsW); bb(EnumWindows); bb(FillRect); bb(FindWindowA ); bb(FindWindowExA); bb(FindWindowExW); bb(FindWindowW); bb(FlashWindowEx); bb(GetActiveWindow); bb(GetAncestor); bb(GetAsyncKeyState); bb(GetCaretBlinkTime); bb(GetCaretPos); bb(GetClassInfoExW); bb(GetClassInfoW); bb(GetClassLongA); bb(GetClassLongW); bb(GetClassWord); bb(GetClientRect); bb(GetClipCursor); bb(GetClipboardData); bb(GetClipboardFormatNameA); bb(GetClipboardFormatNameW); bb(GetClipboardOwner); bb(GetClipboardSequenceNumber); bb(GetClipboardViewer); bb(GetCursor); bb(GetCursorPos); bb(GetDC); bb(GetDesktopWindow); bb(GetDoubleClickTime); bb(GetFocus); bb(GetForegroundWindow); bb(GetIconInfo); bb(GetKBCodePage); bb(GetKeyNameTextA); bb(GetKeyNameTextW); bb(GetKeyState); bb(GetKeyboardLayout); bb(GetKeyboardLayoutList); bb(GetKeyboardLayoutNameA); bb(GetKeyboardLayoutNameW); bb(GetKeyboardState); bb(GetKeyboardType); bb(GetMessageW); bb(GetOpenClipboardWindow); bb(GetParent); bb(GetQueueStatus); // bb(GetPhysicalCursorPos); bb(GetScrollPos); bb(GetScrollRange); bb(GetShellWindow); bb(GetSysColor); bb(GetSysColorBrush); bb(GetSystemMetrics); bb(GetThreadDesktop); // bb(GetUpdatedClipboardFormats); bb(GetWindow); bb(GetWindowLongA); bb(GetWindowLongW); bb(GetWindowModuleFileNameA); bb(GetWindowModuleFileNameW); bb(GetWindowPlacement); bb(GetWindowRect); bb(GetWindowRgn); //bb(GetWindowRgnBox); bb(GetWindowTextA); bb(GetWindowTextLengthA); bb(GetWindowTextLengthW); bb(GetWindowTextW); bb(GetWindowThreadProcessId); bb(GrayStringA); bb(GrayStringW); bb(HideCaret); bb(InflateRect); bb(InsertMenuA); bb(InsertMenuW); bb(InsertMenuItemA); bb(InsertMenuItemW); bb(InternalGetWindowText); bb(IntersectRect); bb(InvalidateRect); bb(InvalidateRgn); bb(IsCharAlphaA); bb(IsCharAlphaNumericA); bb(IsCharAlphaNumericW); bb(IsCharAlphaW); bb(IsCharLowerA); bb(IsCharLowerW); bb(IsCharUpperA); bb(IsCharUpperW); bb(IsChild); bb(IsClipboardFormatAvailable); bb(IsDialogMessageA); bb(IsDialogMessageW); bb(IsDlgButtonChecked); bb(IsGUIThread); bb(IsHungAppWindow); bb(IsIconic); bb(IsMenu); bb(IsWindow); bb(IsWindowEnabled); bb(IsWindowUnicode); bb(IsWindowVisible); //bb(IsWow64Message); bb(IsZoomed); bb(KillTimer); bb(LoadAcceleratorsA); bb(LoadAcceleratorsW); bb(LoadBitmapA); bb(LoadBitmapW); bb(LoadCursorA); bb(LoadCursorFromFileA); bb(LoadCursorFromFileW); bb(LoadCursorW); bb(LoadIconA); bb(LoadIconW); bb(LoadImageA); bb(LoadImageW); bb(LoadKeyboardLayoutA); bb(LoadKeyboardLayoutW); bb(LoadMenuA); bb(LoadMenuIndirectA); bb(LoadMenuIndirectW); bb(LoadMenuW); bb(LoadStringA); bb(LoadStringW); bb(LockSetForegroundWindow); bb(LockWindowUpdate); bb(LockWorkStation); bb(LookupIconIdFromDirectory); bb(LookupIconIdFromDirectoryEx); bb(MapDialogRect); bb(MapVirtualKeyA); bb(MapVirtualKeyExA); bb(MapVirtualKeyExW); bb(MapVirtualKeyW); bb(MapWindowPoints); bb(MenuItemFromPoint); bb(MessageBeep); bb(MessageBoxA); bb(MessageBoxExA); bb(MessageBoxExW); bb(MessageBoxIndirectA); bb(MessageBoxIndirectW); bb(MessageBoxW); bb(ModifyMenuA); bb(ModifyMenuW); bb(MsgWaitForMultipleObjects); bb(MsgWaitForMultipleObjectsEx); bb(NotifyWinEvent); bb(OemKeyScan); bb(OemToCharA); bb(OemToCharBuffA); bb(OemToCharBuffW); bb(OemToCharW); bb(OffsetRect); bb(OpenClipboard); bb(OpenDesktopA); bb(OpenDesktopW); bb(OpenIcon); bb(OpenInputDesktop); bb(OpenWindowStationA); bb(OpenWindowStationW); bb(PackDDElParam); bb(PaintDesktop); bb(PeekMessageA); bb(PeekMessageW); bb(PostMessageA); bb(PostMessageW); bb(PostQuitMessage); bb(RegisterClassExW); bb(RegisterClipboardFormatA); bb(RegisterClipboardFormatW); bb(RegisterDeviceNotificationA); bb(RegisterDeviceNotificationW); bb(RegisterHotKey); bb(RegisterRawInputDevices); bb(RegisterWindowMessageA); bb(RegisterWindowMessageW); bb(ReleaseCapture); bb(ReleaseDC); bb(RemovePropA); bb(RemovePropW); bb(ScreenToClient); bb(ScrollDC); bb(ScrollWindow); bb(ScrollWindowEx); bb(SendDlgItemMessageA); bb(SendDlgItemMessageW); bb(SendInput); bb(SendMessageA); bb(SendMessageTimeoutA); bb(SendMessageTimeoutW); bb(SendMessageW); bb(SendNotifyMessageA); bb(SendNotifyMessageW); bb(SetActiveWindow); bb(SetCaretBlinkTime); bb(SetCaretPos); bb(SetClassLongA); bb(SetClassLongW); bb(SetClassWord); bb(SetClipboardViewer); bb(SetCursor); bb(SetCursorPos); bb(SetDlgItemInt); bb(SetDlgItemTextA); bb(SetDlgItemTextW); bb(SetDoubleClickTime); bb(SetFocus); bb(SetForegroundWindow); bb(SetKeyboardState); bb(SetLastErrorEx); bb(SetMenu); bb(SetParent); // bb(SetPhysicalCursorPos); bb(SetPropA); bb(SetPropW); bb(SetRect); bb(SetRectEmpty); bb(SetScrollPos); bb(SetScrollRange); bb(SetSysColors); bb(SetSystemCursor); bb(SetThreadDesktop); bb(SetTimer); bb(SetWinEventHook); bb(SetWindowLongA); bb(SetWindowLongW); bb(SetWindowPos); bb(SetWindowRgn); bb(SetWindowTextA); bb(SetWindowTextW); bb(SetWindowsHookExA); bb(SetWindowsHookExW); bb(ShowCaret); bb(ShowCursor); bb(ShowWindow); bb(ShowWindowAsync); bb(SwapMouseButton); bb(SwitchDesktop); bb(SystemParametersInfoA); bb(SystemParametersInfoW); bb(TabbedTextOutA); bb(TabbedTextOutW); bb(TrackMouseEvent); bb(TranslateMessage); bb(UnhookWinEvent); bb(UnhookWindowsHookEx); bb(UnionRect); bb(UnloadKeyboardLayout); bb(UnpackDDElParam); bb(UnregisterClassA); bb(UnregisterClassW); bb(UnregisterDeviceNotification); bb(UnregisterHotKey); bb(UpdateLayeredWindow); bb(UpdateWindow); bb(UserHandleGrantAccess); bb(ValidateRect); bb(ValidateRgn); bb(VkKeyScanA); bb(VkKeyScanExA); bb(VkKeyScanExW); bb(VkKeyScanW); bb(WaitForInputIdle); bb(WaitMessage); bb(WinHelpA); bb(WinHelpW); bb(WindowFromDC); bb(WindowFromPoint); bb(keybd_event); bb(mouse_event); bb(GetScrollInfo); bb(SetScrollInfo); } deps/winapi-0.2.5/tests/winmm.rs0000644000000000000000000000230212565203572015301 0ustar rootroot// Copyright © 2015, Jordan Miner // Licensed under the MIT License #![cfg(windows)] extern crate winmm; use winmm::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(PlaySoundA); bb(PlaySoundW); bb(sndPlaySoundA); bb(sndPlaySoundW); bb(timeBeginPeriod); bb(timeEndPeriod); bb(timeGetDevCaps); bb(timeGetTime); bb(waveInAddBuffer); bb(waveInClose); bb(waveInGetDevCapsW); bb(waveInGetErrorTextW); bb(waveInGetNumDevs); bb(waveInGetPosition); bb(waveInMessage); bb(waveInOpen); bb(waveInPrepareHeader); bb(waveInReset); bb(waveInStart); bb(waveInStop); bb(waveInUnprepareHeader); bb(waveOutBreakLoop); bb(waveOutClose); bb(waveOutGetDevCapsW); bb(waveOutGetErrorTextW); bb(waveOutGetNumDevs); bb(waveOutGetPitch); bb(waveOutGetPlaybackRate); bb(waveOutGetPosition); bb(waveOutGetVolume); bb(waveOutMessage); bb(waveOutOpen); bb(waveOutPause); bb(waveOutPrepareHeader); bb(waveOutReset); bb(waveOutRestart); bb(waveOutSetPitch); bb(waveOutSetPlaybackRate); bb(waveOutSetVolume); bb(waveOutUnprepareHeader); bb(waveOutWrite); } deps/winapi-0.2.5/tests/d3d12.rs0000644000000000000000000000057012620146521014764 0ustar rootroot// Copyright © 2015, Dmitry Roschin // Licensed under the MIT License #![cfg(windows)] #![cfg(target_env = "msvc")] extern crate d3d12; use d3d12::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { // bb(D3D12CreateDevice); // bb(D3D12CreateRootSignatureDeserializer); // bb(D3D12GetDebugInterface); // bb(D3D12SerializeRootSignature); } deps/winapi-0.2.5/tests/dwmapi.rs0000644000000000000000000000035212565203572015436 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License #![cfg(windows)] extern crate dwmapi; use dwmapi::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(DwmEnableBlurBehindWindow); } deps/winapi-0.2.5/tests/comctl32.rs0000644000000000000000000000612412566201141015575 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License #![cfg(windows)] extern crate comctl32; use comctl32::*; #[inline(never)] fn bb(_: T) {} #[test] #[cfg(target_env = "msvc")] fn functions_msvc() { bb(DPA_Clone); bb(DPA_CreateEx); bb(DPA_DestroyCallback); bb(DPA_EnumCallback); bb(DPA_GetPtrIndex); bb(DPA_Grow); bb(DPA_LoadStream); bb(DPA_Merge); bb(DPA_SaveStream); bb(DSA_DeleteItem); bb(DSA_DestroyCallback); bb(DSA_GetItem); bb(DSA_SetItem); bb(FlatSB_EnableScrollBar); bb(FlatSB_GetScrollInfo); bb(FlatSB_GetScrollPos); bb(FlatSB_GetScrollProp); bb(FlatSB_GetScrollRange); bb(FlatSB_SetScrollInfo); bb(FlatSB_SetScrollPos); bb(FlatSB_SetScrollProp); bb(FlatSB_SetScrollRange); bb(FlatSB_ShowScrollBar); bb(InitializeFlatSB); bb(UninitializeFlatSB); } #[test] fn functions() { bb(AddMRUStringW); // bb(CreateMRUListW); bb(CreateMappedBitmap); bb(CreatePropertySheetPage); bb(CreatePropertySheetPageA); bb(CreatePropertySheetPageW); bb(CreateStatusWindow); bb(CreateStatusWindowA); bb(CreateStatusWindowW); bb(CreateToolbarEx); bb(CreateUpDownControl); bb(DPA_Create); bb(DPA_DeleteAllPtrs); bb(DPA_DeletePtr); bb(DPA_Destroy); bb(DPA_GetPtr); bb(DPA_InsertPtr); bb(DPA_Search); bb(DPA_SetPtr); bb(DPA_Sort); bb(DSA_Create); bb(DSA_DeleteAllItems); bb(DSA_Destroy); bb(DSA_GetItemPtr); bb(DSA_InsertItem); bb(DefSubclassProc); bb(DestroyPropertySheetPage); bb(DrawInsert); bb(DrawStatusText); bb(DrawStatusTextA); bb(DrawStatusTextW); bb(EnumMRUListW); bb(FreeMRUList); bb(GetEffectiveClientRect); bb(GetMUILanguage); bb(ImageList_Add); bb(ImageList_AddIcon); bb(ImageList_AddMasked); bb(ImageList_BeginDrag); bb(ImageList_Copy); bb(ImageList_Create); bb(ImageList_Destroy); bb(ImageList_DragEnter); bb(ImageList_DragLeave); bb(ImageList_DragMove); bb(ImageList_DragShowNolock); bb(ImageList_Draw); bb(ImageList_DrawEx); bb(ImageList_DrawIndirect); bb(ImageList_Duplicate); bb(ImageList_EndDrag); bb(ImageList_GetBkColor); bb(ImageList_GetDragImage); bb(ImageList_GetIcon); bb(ImageList_GetIconSize); bb(ImageList_GetImageCount); bb(ImageList_GetImageInfo); bb(ImageList_LoadImage); bb(ImageList_LoadImageA); bb(ImageList_LoadImageW); bb(ImageList_Merge); bb(ImageList_Read); bb(ImageList_Remove); bb(ImageList_Replace); bb(ImageList_ReplaceIcon); bb(ImageList_SetBkColor); bb(ImageList_SetDragCursorImage); bb(ImageList_SetIconSize); bb(ImageList_SetImageCount); bb(ImageList_SetOverlayImage); bb(InitCommonControls); bb(InitCommonControlsEx); bb(InitMUILanguage); bb(LBItemFromPt); bb(MakeDragList); bb(MenuHelp); bb(PropertySheet); bb(PropertySheetA); bb(PropertySheetW); bb(RemoveWindowSubclass); bb(SetWindowSubclass); bb(ShowHideMenuCtl); bb(Str_SetPtrW); bb(_TrackMouseEvent); } deps/winapi-0.2.5/tests/setupapi.rs0000644000000000000000000004534212571301522016006 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License #![cfg(windows)] extern crate setupapi; use setupapi::*; #[inline(never)] fn bb(_: T) {} #[test] #[cfg(target_env = "msvc")] fn functions_msvc() { //bb(SetupGetFileCompressionInfoExW); //bb(SetupWriteTextLog); //bb(SetupWriteTextLogError); } #[test] fn functions() { bb(CMP_WaitNoPendingInstallEvents); bb(CM_Add_Empty_Log_Conf); bb(CM_Add_Empty_Log_Conf_Ex); bb(CM_Add_IDA); bb(CM_Add_IDW); bb(CM_Add_ID_ExA); bb(CM_Add_ID_ExW); bb(CM_Add_Range); bb(CM_Add_Res_Des); bb(CM_Add_Res_Des_Ex); bb(CM_Connect_MachineA); bb(CM_Connect_MachineW); bb(CM_Create_DevNodeA); bb(CM_Create_DevNodeW); bb(CM_Create_DevNode_ExA); bb(CM_Create_DevNode_ExW); bb(CM_Create_Range_List); bb(CM_Delete_Class_Key); bb(CM_Delete_Class_Key_Ex); bb(CM_Delete_DevNode_Key); bb(CM_Delete_DevNode_Key_Ex); bb(CM_Delete_Device_Interface_KeyA); bb(CM_Delete_Device_Interface_KeyW); bb(CM_Delete_Device_Interface_Key_ExA); bb(CM_Delete_Device_Interface_Key_ExW); bb(CM_Delete_Range); bb(CM_Detect_Resource_Conflict); bb(CM_Detect_Resource_Conflict_Ex); bb(CM_Disable_DevNode); bb(CM_Disable_DevNode_Ex); bb(CM_Disconnect_Machine); bb(CM_Dup_Range_List); bb(CM_Enable_DevNode); bb(CM_Enable_DevNode_Ex); bb(CM_Enumerate_Classes); bb(CM_Enumerate_Classes_Ex); bb(CM_Enumerate_EnumeratorsA); bb(CM_Enumerate_EnumeratorsW); bb(CM_Enumerate_Enumerators_ExA); bb(CM_Enumerate_Enumerators_ExW); bb(CM_Find_Range); bb(CM_First_Range); bb(CM_Free_Log_Conf); bb(CM_Free_Log_Conf_Ex); bb(CM_Free_Log_Conf_Handle); bb(CM_Free_Range_List); bb(CM_Free_Res_Des); bb(CM_Free_Res_Des_Ex); bb(CM_Free_Res_Des_Handle); bb(CM_Free_Resource_Conflict_Handle); bb(CM_Get_Child); bb(CM_Get_Child_Ex); bb(CM_Get_Class_Key_NameA); bb(CM_Get_Class_Key_NameW); bb(CM_Get_Class_Key_Name_ExA); bb(CM_Get_Class_Key_Name_ExW); bb(CM_Get_Class_NameA); bb(CM_Get_Class_NameW); bb(CM_Get_Class_Name_ExA); bb(CM_Get_Class_Name_ExW); bb(CM_Get_Class_Registry_PropertyA); bb(CM_Get_Class_Registry_PropertyW); bb(CM_Get_Depth); bb(CM_Get_Depth_Ex); bb(CM_Get_DevNode_Custom_PropertyA); bb(CM_Get_DevNode_Custom_PropertyW); bb(CM_Get_DevNode_Custom_Property_ExA); bb(CM_Get_DevNode_Custom_Property_ExW); bb(CM_Get_DevNode_Registry_PropertyA); bb(CM_Get_DevNode_Registry_PropertyW); bb(CM_Get_DevNode_Registry_Property_ExA); bb(CM_Get_DevNode_Registry_Property_ExW); bb(CM_Get_DevNode_Status); bb(CM_Get_DevNode_Status_Ex); bb(CM_Get_Device_IDA); bb(CM_Get_Device_IDW); bb(CM_Get_Device_ID_ExA); bb(CM_Get_Device_ID_ExW); bb(CM_Get_Device_ID_ListA); bb(CM_Get_Device_ID_ListW); bb(CM_Get_Device_ID_List_ExA); bb(CM_Get_Device_ID_List_ExW); bb(CM_Get_Device_ID_List_SizeA); bb(CM_Get_Device_ID_List_SizeW); bb(CM_Get_Device_ID_List_Size_ExA); bb(CM_Get_Device_ID_List_Size_ExW); bb(CM_Get_Device_ID_Size); bb(CM_Get_Device_ID_Size_Ex); bb(CM_Get_Device_Interface_AliasA); bb(CM_Get_Device_Interface_AliasW); bb(CM_Get_Device_Interface_Alias_ExA); bb(CM_Get_Device_Interface_Alias_ExW); bb(CM_Get_Device_Interface_ListA); bb(CM_Get_Device_Interface_ListW); bb(CM_Get_Device_Interface_List_ExA); bb(CM_Get_Device_Interface_List_ExW); bb(CM_Get_Device_Interface_List_SizeA); bb(CM_Get_Device_Interface_List_SizeW); bb(CM_Get_Device_Interface_List_Size_ExA); bb(CM_Get_Device_Interface_List_Size_ExW); bb(CM_Get_First_Log_Conf); bb(CM_Get_First_Log_Conf_Ex); bb(CM_Get_Global_State); bb(CM_Get_Global_State_Ex); bb(CM_Get_HW_Prof_FlagsA); bb(CM_Get_HW_Prof_FlagsW); bb(CM_Get_HW_Prof_Flags_ExA); bb(CM_Get_HW_Prof_Flags_ExW); bb(CM_Get_Hardware_Profile_InfoA); bb(CM_Get_Hardware_Profile_InfoW); bb(CM_Get_Hardware_Profile_Info_ExA); bb(CM_Get_Hardware_Profile_Info_ExW); bb(CM_Get_Log_Conf_Priority); bb(CM_Get_Log_Conf_Priority_Ex); bb(CM_Get_Next_Log_Conf); bb(CM_Get_Next_Log_Conf_Ex); bb(CM_Get_Next_Res_Des); bb(CM_Get_Next_Res_Des_Ex); bb(CM_Get_Parent); bb(CM_Get_Parent_Ex); bb(CM_Get_Res_Des_Data); bb(CM_Get_Res_Des_Data_Ex); bb(CM_Get_Res_Des_Data_Size); bb(CM_Get_Res_Des_Data_Size_Ex); bb(CM_Get_Resource_Conflict_Count); bb(CM_Get_Resource_Conflict_DetailsA); bb(CM_Get_Resource_Conflict_DetailsW); bb(CM_Get_Sibling); bb(CM_Get_Sibling_Ex); bb(CM_Get_Version); bb(CM_Get_Version_Ex); bb(CM_Intersect_Range_List); bb(CM_Invert_Range_List); bb(CM_Is_Dock_Station_Present); bb(CM_Is_Dock_Station_Present_Ex); bb(CM_Is_Version_Available); bb(CM_Is_Version_Available_Ex); bb(CM_Locate_DevNodeA); bb(CM_Locate_DevNodeW); bb(CM_Locate_DevNode_ExA); bb(CM_Locate_DevNode_ExW); bb(CM_Merge_Range_List); bb(CM_Modify_Res_Des); bb(CM_Modify_Res_Des_Ex); bb(CM_Move_DevNode); bb(CM_Move_DevNode_Ex); bb(CM_Next_Range); bb(CM_Open_Class_KeyA); bb(CM_Open_Class_KeyW); bb(CM_Open_Class_Key_ExA); bb(CM_Open_Class_Key_ExW); bb(CM_Open_DevNode_Key); bb(CM_Open_DevNode_Key_Ex); bb(CM_Open_Device_Interface_KeyA); bb(CM_Open_Device_Interface_KeyW); bb(CM_Open_Device_Interface_Key_ExA); bb(CM_Open_Device_Interface_Key_ExW); bb(CM_Query_And_Remove_SubTreeA); bb(CM_Query_And_Remove_SubTreeW); bb(CM_Query_And_Remove_SubTree_ExA); bb(CM_Query_And_Remove_SubTree_ExW); bb(CM_Query_Arbitrator_Free_Data); bb(CM_Query_Arbitrator_Free_Data_Ex); bb(CM_Query_Arbitrator_Free_Size); bb(CM_Query_Arbitrator_Free_Size_Ex); bb(CM_Query_Remove_SubTree); bb(CM_Query_Remove_SubTree_Ex); bb(CM_Query_Resource_Conflict_List); bb(CM_Reenumerate_DevNode); bb(CM_Reenumerate_DevNode_Ex); bb(CM_Register_Device_Driver); bb(CM_Register_Device_Driver_Ex); bb(CM_Register_Device_InterfaceA); bb(CM_Register_Device_InterfaceW); bb(CM_Register_Device_Interface_ExA); bb(CM_Register_Device_Interface_ExW); bb(CM_Remove_SubTree); bb(CM_Remove_SubTree_Ex); bb(CM_Request_Device_EjectA); bb(CM_Request_Device_EjectW); bb(CM_Request_Device_Eject_ExA); bb(CM_Request_Device_Eject_ExW); bb(CM_Request_Eject_PC); bb(CM_Request_Eject_PC_Ex); bb(CM_Run_Detection); bb(CM_Run_Detection_Ex); bb(CM_Set_Class_Registry_PropertyA); bb(CM_Set_Class_Registry_PropertyW); bb(CM_Set_DevNode_Problem); bb(CM_Set_DevNode_Problem_Ex); bb(CM_Set_DevNode_Registry_PropertyA); bb(CM_Set_DevNode_Registry_PropertyW); bb(CM_Set_DevNode_Registry_Property_ExA); bb(CM_Set_DevNode_Registry_Property_ExW); bb(CM_Set_HW_Prof); bb(CM_Set_HW_Prof_Ex); bb(CM_Set_HW_Prof_FlagsA); bb(CM_Set_HW_Prof_FlagsW); bb(CM_Set_HW_Prof_Flags_ExA); bb(CM_Set_HW_Prof_Flags_ExW); bb(CM_Setup_DevNode); bb(CM_Setup_DevNode_Ex); bb(CM_Test_Range_Available); bb(CM_Uninstall_DevNode); bb(CM_Uninstall_DevNode_Ex); bb(CM_Unregister_Device_InterfaceA); bb(CM_Unregister_Device_InterfaceW); bb(CM_Unregister_Device_Interface_ExA); bb(CM_Unregister_Device_Interface_ExW); bb(InstallHinfSection); bb(InstallHinfSectionA); bb(InstallHinfSectionW); bb(SetupAddInstallSectionToDiskSpaceListA); bb(SetupAddInstallSectionToDiskSpaceListW); bb(SetupAddSectionToDiskSpaceListA); bb(SetupAddSectionToDiskSpaceListW); bb(SetupAddToDiskSpaceListA); bb(SetupAddToDiskSpaceListW); bb(SetupAddToSourceListA); bb(SetupAddToSourceListW); bb(SetupAdjustDiskSpaceListA); bb(SetupAdjustDiskSpaceListW); bb(SetupBackupErrorA); bb(SetupBackupErrorW); bb(SetupCancelTemporarySourceList); bb(SetupCloseFileQueue); bb(SetupCloseInfFile); bb(SetupCloseLog); bb(SetupCommitFileQueue); bb(SetupCommitFileQueueA); bb(SetupCommitFileQueueW); bb(SetupConfigureWmiFromInfSectionA); bb(SetupConfigureWmiFromInfSectionW); bb(SetupCopyErrorA); bb(SetupCopyErrorW); bb(SetupCopyOEMInfA); bb(SetupCopyOEMInfW); bb(SetupCreateDiskSpaceListA); bb(SetupCreateDiskSpaceListW); bb(SetupDecompressOrCopyFileA); bb(SetupDecompressOrCopyFileW); bb(SetupDefaultQueueCallback); bb(SetupDefaultQueueCallbackA); bb(SetupDefaultQueueCallbackW); bb(SetupDeleteErrorA); bb(SetupDeleteErrorW); bb(SetupDestroyDiskSpaceList); bb(SetupDiAskForOEMDisk); bb(SetupDiBuildClassInfoList); bb(SetupDiBuildClassInfoListExA); bb(SetupDiBuildClassInfoListExW); bb(SetupDiBuildDriverInfoList); bb(SetupDiCallClassInstaller); bb(SetupDiCancelDriverInfoSearch); bb(SetupDiChangeState); bb(SetupDiClassGuidsFromNameA); bb(SetupDiClassGuidsFromNameExA); bb(SetupDiClassGuidsFromNameExW); bb(SetupDiClassGuidsFromNameW); bb(SetupDiClassNameFromGuidA); bb(SetupDiClassNameFromGuidExA); bb(SetupDiClassNameFromGuidExW); bb(SetupDiClassNameFromGuidW); bb(SetupDiCreateDevRegKeyA); bb(SetupDiCreateDevRegKeyW); bb(SetupDiCreateDeviceInfoA); bb(SetupDiCreateDeviceInfoList); bb(SetupDiCreateDeviceInfoListExA); bb(SetupDiCreateDeviceInfoListExW); bb(SetupDiCreateDeviceInfoW); bb(SetupDiCreateDeviceInterfaceA); bb(SetupDiCreateDeviceInterfaceRegKeyA); bb(SetupDiCreateDeviceInterfaceRegKeyW); bb(SetupDiCreateDeviceInterfaceW); bb(SetupDiDeleteDevRegKey); bb(SetupDiDeleteDeviceInfo); bb(SetupDiDeleteDeviceInterfaceData); bb(SetupDiDeleteDeviceInterfaceRegKey); bb(SetupDiDestroyClassImageList); bb(SetupDiDestroyDeviceInfoList); bb(SetupDiDestroyDriverInfoList); bb(SetupDiDrawMiniIcon); bb(SetupDiEnumDeviceInfo); bb(SetupDiEnumDeviceInterfaces); bb(SetupDiEnumDriverInfoA); bb(SetupDiEnumDriverInfoW); bb(SetupDiGetActualModelsSectionA); bb(SetupDiGetActualModelsSectionW); bb(SetupDiGetActualSectionToInstallA); bb(SetupDiGetActualSectionToInstallExA); bb(SetupDiGetActualSectionToInstallExW); bb(SetupDiGetActualSectionToInstallW); bb(SetupDiGetClassBitmapIndex); bb(SetupDiGetClassDescriptionA); bb(SetupDiGetClassDescriptionExA); bb(SetupDiGetClassDescriptionExW); bb(SetupDiGetClassDescriptionW); bb(SetupDiGetClassDevPropertySheetsA); bb(SetupDiGetClassDevPropertySheetsW); bb(SetupDiGetClassDevsA); bb(SetupDiGetClassDevsExA); bb(SetupDiGetClassDevsExW); bb(SetupDiGetClassDevsW); bb(SetupDiGetClassImageIndex); bb(SetupDiGetClassImageList); bb(SetupDiGetClassImageListExA); bb(SetupDiGetClassImageListExW); bb(SetupDiGetClassInstallParamsA); bb(SetupDiGetClassInstallParamsW); bb(SetupDiGetClassPropertyExW); bb(SetupDiGetClassPropertyKeys); bb(SetupDiGetClassPropertyKeysExW); bb(SetupDiGetClassPropertyW); bb(SetupDiGetClassRegistryPropertyA); bb(SetupDiGetClassRegistryPropertyW); bb(SetupDiGetCustomDevicePropertyA); bb(SetupDiGetCustomDevicePropertyW); bb(SetupDiGetDeviceInfoListClass); bb(SetupDiGetDeviceInfoListDetailA); bb(SetupDiGetDeviceInfoListDetailW); bb(SetupDiGetDeviceInstallParamsA); bb(SetupDiGetDeviceInstallParamsW); bb(SetupDiGetDeviceInstanceIdA); bb(SetupDiGetDeviceInstanceIdW); bb(SetupDiGetDeviceInterfaceAlias); bb(SetupDiGetDeviceInterfaceDetailA); bb(SetupDiGetDeviceInterfaceDetailW); bb(SetupDiGetDeviceInterfacePropertyKeys); bb(SetupDiGetDeviceInterfacePropertyW); bb(SetupDiGetDevicePropertyKeys); bb(SetupDiGetDevicePropertyW); bb(SetupDiGetDeviceRegistryPropertyA); bb(SetupDiGetDeviceRegistryPropertyW); bb(SetupDiGetDriverInfoDetailA); bb(SetupDiGetDriverInfoDetailW); bb(SetupDiGetDriverInstallParamsA); bb(SetupDiGetDriverInstallParamsW); bb(SetupDiGetHwProfileFriendlyNameA); bb(SetupDiGetHwProfileFriendlyNameExA); bb(SetupDiGetHwProfileFriendlyNameExW); bb(SetupDiGetHwProfileFriendlyNameW); bb(SetupDiGetHwProfileList); bb(SetupDiGetHwProfileListExA); bb(SetupDiGetHwProfileListExW); bb(SetupDiGetINFClassA); bb(SetupDiGetINFClassW); bb(SetupDiGetSelectedDevice); bb(SetupDiGetSelectedDriverA); bb(SetupDiGetSelectedDriverW); bb(SetupDiGetWizardPage); bb(SetupDiInstallClassA); bb(SetupDiInstallClassExA); bb(SetupDiInstallClassExW); bb(SetupDiInstallClassW); bb(SetupDiInstallDevice); bb(SetupDiInstallDeviceInterfaces); bb(SetupDiInstallDriverFiles); bb(SetupDiLoadClassIcon); bb(SetupDiLoadDeviceIcon); bb(SetupDiOpenClassRegKey); bb(SetupDiOpenClassRegKeyExA); bb(SetupDiOpenClassRegKeyExW); bb(SetupDiOpenDevRegKey); bb(SetupDiOpenDeviceInfoA); bb(SetupDiOpenDeviceInfoW); bb(SetupDiOpenDeviceInterfaceA); bb(SetupDiOpenDeviceInterfaceRegKey); bb(SetupDiOpenDeviceInterfaceW); bb(SetupDiRegisterCoDeviceInstallers); bb(SetupDiRegisterDeviceInfo); bb(SetupDiRemoveDevice); bb(SetupDiRemoveDeviceInterface); bb(SetupDiRestartDevices); bb(SetupDiSelectBestCompatDrv); bb(SetupDiSelectDevice); bb(SetupDiSelectOEMDrv); bb(SetupDiSetClassInstallParamsA); bb(SetupDiSetClassInstallParamsW); bb(SetupDiSetClassPropertyExW); bb(SetupDiSetClassPropertyW); bb(SetupDiSetClassRegistryPropertyA); bb(SetupDiSetClassRegistryPropertyW); bb(SetupDiSetDeviceInstallParamsA); bb(SetupDiSetDeviceInstallParamsW); bb(SetupDiSetDeviceInterfaceDefault); bb(SetupDiSetDeviceInterfacePropertyW); bb(SetupDiSetDevicePropertyW); bb(SetupDiSetDeviceRegistryPropertyA); bb(SetupDiSetDeviceRegistryPropertyW); bb(SetupDiSetDriverInstallParamsA); bb(SetupDiSetDriverInstallParamsW); bb(SetupDiSetSelectedDevice); bb(SetupDiSetSelectedDriverA); bb(SetupDiSetSelectedDriverW); bb(SetupDiUnremoveDevice); bb(SetupDuplicateDiskSpaceListA); bb(SetupDuplicateDiskSpaceListW); bb(SetupEnumInfSectionsA); bb(SetupEnumInfSectionsW); bb(SetupFindFirstLineA); bb(SetupFindFirstLineW); bb(SetupFindNextLine); bb(SetupFindNextMatchLineA); bb(SetupFindNextMatchLineW); bb(SetupFreeSourceListA); bb(SetupFreeSourceListW); bb(SetupGetBackupInformationA); bb(SetupGetBackupInformationW); bb(SetupGetBinaryField); bb(SetupGetFieldCount); bb(SetupGetFileCompressionInfoA); bb(SetupGetFileCompressionInfoExA); bb(SetupGetFileCompressionInfoW); bb(SetupGetFileQueueCount); bb(SetupGetFileQueueFlags); bb(SetupGetInfDriverStoreLocationA); bb(SetupGetInfDriverStoreLocationW); bb(SetupGetInfFileListA); bb(SetupGetInfFileListW); bb(SetupGetInfInformationA); bb(SetupGetInfInformationW); bb(SetupGetInfPublishedNameA); bb(SetupGetInfPublishedNameW); bb(SetupGetIntField); bb(SetupGetLineByIndexA); bb(SetupGetLineByIndexW); bb(SetupGetLineCountA); bb(SetupGetLineCountW); bb(SetupGetLineTextA); bb(SetupGetLineTextW); bb(SetupGetMultiSzFieldA); bb(SetupGetMultiSzFieldW); bb(SetupGetNonInteractiveMode); bb(SetupGetSourceFileLocationA); bb(SetupGetSourceFileLocationW); bb(SetupGetSourceFileSizeA); bb(SetupGetSourceFileSizeW); bb(SetupGetSourceInfoA); bb(SetupGetSourceInfoW); bb(SetupGetStringFieldA); bb(SetupGetStringFieldW); bb(SetupGetTargetPathA); bb(SetupGetTargetPathW); bb(SetupGetThreadLogToken); bb(SetupInitDefaultQueueCallback); bb(SetupInitDefaultQueueCallbackEx); bb(SetupInitializeFileLogA); bb(SetupInitializeFileLogW); bb(SetupInstallFileA); bb(SetupInstallFileExA); bb(SetupInstallFileExW); bb(SetupInstallFileW); bb(SetupInstallFilesFromInfSectionA); bb(SetupInstallFilesFromInfSectionW); bb(SetupInstallFromInfSectionA); bb(SetupInstallFromInfSectionW); bb(SetupInstallServicesFromInfSectionA); bb(SetupInstallServicesFromInfSectionExA); bb(SetupInstallServicesFromInfSectionExW); bb(SetupInstallServicesFromInfSectionW); bb(SetupIterateCabinetA); bb(SetupIterateCabinetW); bb(SetupLogErrorA); bb(SetupLogErrorW); bb(SetupLogFileA); bb(SetupLogFileW); bb(SetupOpenAppendInfFileA); bb(SetupOpenAppendInfFileW); bb(SetupOpenFileQueue); bb(SetupOpenInfFileA); bb(SetupOpenInfFileW); bb(SetupOpenLog); bb(SetupOpenMasterInf); bb(SetupPrepareQueueForRestoreA); bb(SetupPrepareQueueForRestoreW); bb(SetupPromptForDiskA); bb(SetupPromptForDiskW); bb(SetupPromptReboot); bb(SetupQueryDrivesInDiskSpaceListA); bb(SetupQueryDrivesInDiskSpaceListW); bb(SetupQueryFileLogA); bb(SetupQueryFileLogW); bb(SetupQueryInfFileInformationA); bb(SetupQueryInfFileInformationW); bb(SetupQueryInfOriginalFileInformationA); bb(SetupQueryInfOriginalFileInformationW); bb(SetupQueryInfVersionInformationA); bb(SetupQueryInfVersionInformationW); bb(SetupQuerySourceListA); bb(SetupQuerySourceListW); bb(SetupQuerySpaceRequiredOnDriveA); bb(SetupQuerySpaceRequiredOnDriveW); bb(SetupQueueCopyA); bb(SetupQueueCopyIndirectA); bb(SetupQueueCopyIndirectW); bb(SetupQueueCopySectionA); bb(SetupQueueCopySectionW); bb(SetupQueueCopyW); bb(SetupQueueDefaultCopyA); bb(SetupQueueDefaultCopyW); bb(SetupQueueDeleteA); bb(SetupQueueDeleteSectionA); bb(SetupQueueDeleteSectionW); bb(SetupQueueDeleteW); bb(SetupQueueRenameA); bb(SetupQueueRenameSectionA); bb(SetupQueueRenameSectionW); bb(SetupQueueRenameW); bb(SetupRemoveFileLogEntryA); bb(SetupRemoveFileLogEntryW); bb(SetupRemoveFromDiskSpaceListA); bb(SetupRemoveFromDiskSpaceListW); bb(SetupRemoveFromSourceListA); bb(SetupRemoveFromSourceListW); bb(SetupRemoveInstallSectionFromDiskSpaceListA); bb(SetupRemoveInstallSectionFromDiskSpaceListW); bb(SetupRemoveSectionFromDiskSpaceListA); bb(SetupRemoveSectionFromDiskSpaceListW); bb(SetupRenameErrorA); bb(SetupRenameErrorW); bb(SetupScanFileQueue); bb(SetupScanFileQueueA); bb(SetupScanFileQueueW); bb(SetupSetDirectoryIdA); bb(SetupSetDirectoryIdExA); bb(SetupSetDirectoryIdExW); bb(SetupSetDirectoryIdW); bb(SetupSetFileQueueAlternatePlatformA); bb(SetupSetFileQueueAlternatePlatformW); bb(SetupSetFileQueueFlags); bb(SetupSetNonInteractiveMode); bb(SetupSetPlatformPathOverrideA); bb(SetupSetPlatformPathOverrideW); bb(SetupSetSourceListA); bb(SetupSetSourceListW); bb(SetupSetThreadLogToken); bb(SetupTermDefaultQueueCallback); bb(SetupTerminateFileLog); bb(SetupUninstallNewlyCopiedInfs); bb(SetupUninstallOEMInfA); bb(SetupUninstallOEMInfW); bb(SetupVerifyInfFileA); bb(SetupVerifyInfFileW); bb(SetupWriteTextLogInfLine); } deps/winapi-0.2.5/tests/d2d1.rs0000644000000000000000000000115312566177605014717 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License #![cfg(windows)] extern crate d2d1; use d2d1::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { //bb(D2D1ConvertColorSpace); //bb(D2D1CreateDevice); //bb(D2D1CreateDeviceContext); bb(D2D1CreateFactory); bb(D2D1InvertMatrix); bb(D2D1IsMatrixInvertible); bb(D2D1MakeRotateMatrix); bb(D2D1MakeSkewMatrix); } #[cfg(target_env = "msvc")] #[test] fn msvc_functions() { bb(D2D1ComputeMaximumScaleFactor); bb(D2D1SinCos); bb(D2D1Tan); bb(D2D1Vec3Length); } deps/winapi-0.2.5/tests/winhttp.rs0000644000000000000000000000270512565203572015656 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License #![cfg(windows)] extern crate winhttp; use winhttp::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(WinHttpAddRequestHeaders); bb(WinHttpCheckPlatform); bb(WinHttpCloseHandle); bb(WinHttpConnect); bb(WinHttpCrackUrl); bb(WinHttpCreateUrl); bb(WinHttpDetectAutoProxyConfigUrl); bb(WinHttpGetDefaultProxyConfiguration); bb(WinHttpGetIEProxyConfigForCurrentUser); bb(WinHttpGetProxyForUrl); bb(WinHttpOpen); bb(WinHttpOpenRequest); bb(WinHttpQueryAuthSchemes); bb(WinHttpQueryDataAvailable); bb(WinHttpQueryHeaders); bb(WinHttpQueryOption); bb(WinHttpReadData); bb(WinHttpReceiveResponse); bb(WinHttpSendRequest); bb(WinHttpSetCredentials); bb(WinHttpSetDefaultProxyConfiguration); bb(WinHttpSetOption); bb(WinHttpSetStatusCallback); bb(WinHttpSetTimeouts); bb(WinHttpTimeFromSystemTime); bb(WinHttpTimeToSystemTime); bb(WinHttpWriteData); } #[cfg(target_env = "msvc")] #[test] fn functions_msvc() { bb(WinHttpCreateProxyResolver); bb(WinHttpFreeProxyResult); bb(WinHttpGetProxyForUrlEx); bb(WinHttpGetProxyResult); bb(WinHttpResetAutoProxy); bb(WinHttpWebSocketClose); bb(WinHttpWebSocketCompleteUpgrade); bb(WinHttpWebSocketQueryCloseStatus); bb(WinHttpWebSocketReceive); bb(WinHttpWebSocketSend); bb(WinHttpWebSocketShutdown); } deps/winapi-0.2.5/tests/winspool.rs0000644000000000000000000000715612565203572016040 0ustar rootroot// Copyright © 2015, skdltmxn // Licensed under the MIT License #![cfg(windows)] extern crate winspool; use winspool::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(AbortPrinter); bb(AddFormA); bb(AddFormW); bb(AddJobA); bb(AddJobW); bb(AddMonitorA); bb(AddMonitorW); bb(AddPortA); bb(AddPortW); bb(AddPrintProcessorA); bb(AddPrintProcessorW); bb(AddPrintProvidorA); bb(AddPrintProvidorW); bb(AddPrinterA); bb(AddPrinterW); bb(AddPrinterConnectionA); bb(AddPrinterConnectionW); bb(AddPrinterConnection2A); bb(AddPrinterConnection2W); bb(AddPrinterDriverA); bb(AddPrinterDriverW); bb(AdvancedDocumentPropertiesA); bb(AdvancedDocumentPropertiesW); bb(ClosePrinter); bb(ConfigurePortA); bb(ConfigurePortW); bb(ConnectToPrinterDlg); bb(DeleteFormA); bb(DeleteFormW); bb(DeleteMonitorA); bb(DeleteMonitorW); bb(DeletePortA); bb(DeletePortW); bb(DeletePrintProcessorA); bb(DeletePrintProcessorW); bb(DeletePrintProvidorA); bb(DeletePrintProvidorW); bb(DeletePrinter); bb(DeletePrinterConnectionA); bb(DeletePrinterConnectionW); bb(DeletePrinterDataA); bb(DeletePrinterDataW); bb(DeletePrinterDriverA); bb(DeletePrinterDriverW); bb(DeviceCapabilitiesA); bb(DeviceCapabilitiesW); bb(DocumentPropertiesA); bb(DocumentPropertiesW); bb(EndDocPrinter); bb(EndPagePrinter); bb(EnumFormsA); bb(EnumFormsW); bb(EnumJobsA); bb(EnumJobsW); bb(EnumMonitorsA); bb(EnumMonitorsW); bb(EnumPortsA); bb(EnumPortsW); bb(EnumPrintProcessorDatatypesA); bb(EnumPrintProcessorDatatypesW); bb(EnumPrintProcessorsA); bb(EnumPrintProcessorsW); bb(EnumPrinterDataA); bb(EnumPrinterDataW); bb(EnumPrinterDriversA); bb(EnumPrinterDriversW); bb(EnumPrintersA); bb(EnumPrintersW); bb(ExtDeviceMode); bb(FindClosePrinterChangeNotification); bb(FindFirstPrinterChangeNotification); bb(FindNextPrinterChangeNotification); bb(GetDefaultPrinterA); bb(GetDefaultPrinterW); bb(GetFormA); bb(GetFormW); bb(GetJobA); bb(GetJobW); bb(GetPrintProcessorDirectoryA); bb(GetPrintProcessorDirectoryW); bb(GetPrinterA); bb(GetPrinterW); bb(GetPrinterDataA); bb(GetPrinterDataW); bb(GetPrinterDriverA); bb(GetPrinterDriverW); bb(GetPrinterDriverDirectoryA); bb(GetPrinterDriverDirectoryW); bb(OpenPrinterA); bb(OpenPrinterW); bb(PrinterMessageBoxA); bb(PrinterMessageBoxW); bb(PrinterProperties); bb(ReadPrinter); bb(ResetPrinterA); bb(ResetPrinterW); bb(ScheduleJob); bb(SetFormA); bb(SetFormW); bb(SetJobA); bb(SetJobW); bb(SetPrinterA); bb(SetPrinterW); bb(SetPrinterDataA); bb(SetPrinterDataW); bb(StartDocPrinterA); bb(StartDocPrinterW); bb(StartPagePrinter); bb(WaitForPrinterChange); bb(WritePrinter); } #[cfg(target_env = "msvc")] #[test] fn functions_msvc() { bb(CloseSpoolFileHandle); bb(CommitSpoolData); bb(DeletePrinterDataExA); bb(DeletePrinterDataExW); bb(DeletePrinterDriverExA); bb(DeletePrinterDriverExW); bb(DeletePrinterKeyA); bb(DeletePrinterKeyW); bb(EnumPrinterDataExA); bb(EnumPrinterDataExW); bb(EnumPrinterKeyA); bb(EnumPrinterKeyW); bb(FlushPrinter); bb(GetPrinterDataExA); bb(GetPrinterDataExW); bb(GetSpoolFileHandle); bb(IsValidDevmodeA); bb(IsValidDevmodeW); bb(SetDefaultPrinterA); bb(SetDefaultPrinterW); bb(SetPortA); bb(SetPortW); bb(XcvDataW); } deps/winapi-0.2.5/tests/shell32.rs0000644000000000000000000000173312565203572015435 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License #![cfg(windows)] extern crate shell32; use shell32::*; #[inline(never)] fn bb(_: T) {} #[test] fn functions() { bb(SHCloneSpecialIDList); bb(SHCreateDirectory); bb(SHCreateDirectoryExA); bb(SHCreateDirectoryExW); bb(SHCreateShellItem); bb(SHFlushSFCache); bb(SHGetFolderLocation); bb(SHGetFolderPathA); bb(SHGetFolderPathAndSubDirA); bb(SHGetFolderPathAndSubDirW); bb(SHGetFolderPathW); bb(SHGetIconOverlayIndexA); bb(SHGetIconOverlayIndexW); bb(SHGetKnownFolderIDList); bb(SHGetKnownFolderItem); bb(SHGetKnownFolderPath); bb(SHGetPathFromIDListA); bb(SHGetPathFromIDListEx); bb(SHGetPathFromIDListW); bb(SHGetSpecialFolderLocation); bb(SHGetSpecialFolderPathA); bb(SHGetSpecialFolderPathW); bb(SHOpenFolderAndSelectItems); bb(SHSetFolderPathA); bb(SHSetFolderPathW); bb(SHSetKnownFolderPath); } deps/winapi-0.2.5/CONTRIBUTING.md0000644000000000000000000000176012611475231014675 0ustar rootroot#Guidelines ##Style ###Line length * The maximum line length for `winapi-rs` is 99. Any lines longer than this **must** be modified before they will be accepted. * Avoid line breaks when possible, but if you cannot make it fit, add line breaks as late as possible (for example, between 80 and 95). ###Multiline functions * Multiline functions and structs **should** have commas after every field and parameter. * When implementing multiline functions, please use this style: ```rust pub fn QueryInformationJobObject( hJob: HANDLE, JobObjectInformationClass: JOBOBJECTINFOCLASS, lpJobObjectInformation: LPVOID, cbJobObjectInformationLength: DWORD, lpReturnLength: LPDWORD, ) -> BOOL; ``` ##Organization of code * Functions go into the respective `-sys` crate inside `lib`. All types and constants go into the main crate. * If you have types, enums, or constants defined in a .h file not represented in `winapi-rs`, please create a new file and reference it in lib.rs. deps/winapi-0.2.5/appveyor.yml0000644000000000000000000000113712573445135015041 0ustar rootrootenvironment: matrix: - TARGET: x86_64-pc-windows-msvc - TARGET: i686-pc-windows-msvc - TARGET: x86_64-pc-windows-gnu - TARGET: i686-pc-windows-gnu install: - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" -FileName "rust-nightly.exe" - ps: .\rust-nightly.exe /VERYSILENT /NORESTART /DIR="C:\rust" | Out-Null - ps: $env:PATH="$env:PATH;C:\rust\bin" - rustc -vV - cargo -vV build_script: - cargo build - cargo package test_script: - cargo test notifications: - provider: Webhook url: https://webhooks.gitter.im/e/9907ad94eb7a5ff291c3 deps/winapi-0.2.5/Cargo.toml0000644000000000000000000000474412620206551014376 0ustar rootroot[package] name = "winapi" version = "0.2.5" authors = ["Peter Atashian "] description = "Types and constants for WinAPI bindings. See README for list of crates providing function bindings." documentation = "https://retep998.github.io/doc/winapi/" repository = "https://github.com/retep998/winapi-rs" readme = "README.md" keywords = ["windows", "ffi", "win32", "com", "directx"] license = "MIT" [dev-dependencies] advapi32-sys = { version = "*", path = "lib/advapi32" } bcrypt-sys = { version = "*", path = "lib/bcrypt" } comctl32-sys = { version = "*", path = "lib/comctl32" } comdlg32-sys = { version = "*", path = "lib/comdlg32" } credui-sys = { version = "*", path = "lib/credui" } crypt32-sys = { version = "*", path = "lib/crypt32" } d2d1-sys = { version = "*", path = "lib/d2d1" } d3d11-sys = { version = "*", path = "lib/d3d11" } d3d12-sys = { version = "*", path = "lib/d3d12" } d3d9-sys = { version = "*", path = "lib/d3d9" } dbghelp-sys = { version = "*", path = "lib/dbghelp" } dsound-sys = { version = "*", path = "lib/dsound" } dwmapi-sys = { version = "*", path = "lib/dwmapi" } dwrite-sys = { version = "*", path = "lib/dwrite" } dxgi-sys = { version = "*", path = "lib/dxgi" } dxguid-sys = { version = "*", path = "lib/dxguid" } gdi32-sys = { version = "*", path = "lib/gdi32" } httpapi-sys = { version = "*", path = "lib/httpapi" } kernel32-sys = { version = "*", path = "lib/kernel32" } ktmw32-sys = { version = "*", path = "lib/ktmw32" } mpr-sys = { version = "*", path = "lib/mpr" } netapi32-sys = { version = "*", path = "lib/netapi32" } ole32-sys = { version = "*", path = "lib/ole32" } oleaut32-sys = { version = "*", path = "lib/oleaut32" } opengl32-sys = { version = "*", path = "lib/opengl32" } psapi-sys = { version = "*", path = "lib/psapi" } secur32-sys = { version = "*", path = "lib/secur32" } setupapi-sys = { version = "*", path = "lib/setupapi" } shell32-sys = { version = "*", path = "lib/shell32" } user32-sys = { version = "*", path = "lib/user32" } usp10-sys = { version = "*", path = "lib/usp10" } uuid-sys = { version = "*", path = "lib/uuid" } vssapi-sys = { version = "*", path = "lib/vssapi" } wevtapi-sys = { version = "*", path = "lib/wevtapi" } winhttp-sys = { version = "*", path = "lib/winhttp" } winmm-sys = { version = "*", path = "lib/winmm" } winscard-sys = { version = "*", path = "lib/winscard" } winspool-sys = { version = "*", path = "lib/winspool" } ws2_32-sys = { version = "*", path = "lib/ws2_32" } xinput-sys = { version = "*", path = "lib/xinput" } deps/winapi-0.2.5/LICENSE.md0000644000000000000000000000207112542643300014041 0ustar rootrootThe MIT License (MIT) Copyright (c) 2015 Peter Atashian Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/libz-sys-1.0.0/0000755000000000000000000000000012666635521012731 5ustar rootrootdeps/libz-sys-1.0.0/LICENSE-APACHE0000664000175000017500000002513712425232420013071 0ustar Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/libz-sys-1.0.0/LICENSE-MIT0000664000175000017500000000204112425232420012566 0ustar Copyright (c) 2014 Alex Crichton Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/libz-sys-1.0.0/.travis.yml0000664000175000017500000000110612617163142013253 0ustar language: rust rust: - stable - beta - nightly sudo: false before_script: - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH script: - cargo test - cargo run --manifest-path systest/Cargo.toml - cargo doc --no-deps after_success: - travis-cargo --only nightly doc-upload notifications: email: on_success: never env: global: secure: AEw7peNq5yyhDlGod702HScsujYFaFWvdOaZKiyVwUMNHkou1U4BiziBGekBqTmrPOW8+iNSS5J7MDPu8I7RAtkrlOvsBKIjmGbBYkzodkMFjR6TNNAnfAXhjqUzHh77wL5qWtNh+bz/PL4RVyjdo1Swnc6mqz5Unu9rP9S2LeE= os: - linux - osx deps/libz-sys-1.0.0/README.md0000664000175000017500000000047312425232546012431 0ustar # libz-sys A common library for linking `libz` to rust programs (also known as zlib). # License `libz-sys` is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses. See LICENSE-APACHE, and LICENSE-MIT for details. deps/libz-sys-1.0.0/.gitignore0000600000175000017500000000002212617163202013111 0ustar target Cargo.lock deps/libz-sys-1.0.0/src/0000755000000000000000000000000012666635521013520 5ustar rootrootdeps/libz-sys-1.0.0/src/lib.rs0000664000175000017500000002134512617177424013064 0ustar #![doc(html_root_url = "http://alexcrichton.com/libz-sys")] #![allow(non_camel_case_types)] extern crate libc; use libc::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_void}; pub type alloc_func = unsafe extern fn (voidpf, uInt, uInt) -> voidpf; pub type Bytef = u8; pub type free_func = unsafe extern fn (voidpf, voidpf); pub type gzFile = *mut gzFile_s; pub type in_func = unsafe extern fn (*mut c_void, *mut *const c_uchar) -> c_uint; pub type out_func = unsafe extern fn (*mut c_void, *mut c_uchar, c_uint) -> c_int; pub type uInt = c_uint; pub type uLong = c_ulong; pub type uLongf = c_ulong; pub type voidp = *mut c_void; pub type voidpc = *const c_void; pub type voidpf = *mut c_void; pub enum gzFile_s {} pub enum internal_state {} #[cfg(unix)] pub type z_off_t = libc::off_t; #[cfg(not(unix))] pub type z_off_t = c_long; #[repr(C)] pub struct gz_header { pub text: c_int, pub time: uLong, pub xflags: c_int, pub os: c_int, pub extra: *mut Bytef, pub extra_len: uInt, pub extra_max: uInt, pub name: *mut Bytef, pub name_max: uInt, pub comment: *mut Bytef, pub comm_max: uInt, pub hcrc: c_int, pub done: c_int, } pub type gz_headerp = *mut gz_header; #[repr(C)] pub struct z_stream { pub next_in: *mut Bytef, pub avail_in: uInt, pub total_in: uLong, pub next_out: *mut Bytef, pub avail_out: uInt, pub total_out: uLong, pub msg: *mut c_char, pub state: *mut internal_state, pub zalloc: alloc_func, pub zfree: free_func, pub opaque: voidpf, pub data_type: c_int, pub adler: uLong, pub reserved: uLong, } pub type z_streamp = *mut z_stream; macro_rules! fns { ($($arg:tt)*) => { item! { #[cfg(all(target_env = "msvc", target_pointer_width = "32"))] extern { $($arg)* } } item! { #[cfg(not(all(target_env = "msvc", target_pointer_width = "32")))] extern "system" { $($arg)* } } } } macro_rules! item { ($i:item) => ($i) } fns! { pub fn adler32(adler: uLong, buf: *const Bytef, len: uInt) -> uLong; pub fn adler32_combine(adler1: uLong, adler2: uLong, len2: z_off_t) -> uLong; pub fn compress(dest: *mut Bytef, destLen: *mut uLongf, source: *const Bytef, sourceLen: uLong) -> c_int; pub fn compress2(dest: *mut Bytef, destLen: *mut uLongf, source: *const Bytef, sourceLen: uLong, level: c_int) -> c_int; pub fn compressBound(sourceLen: uLong) -> uLong; pub fn crc32(crc: uLong, buf: *const Bytef, len: uInt) -> uLong; pub fn crc32_combine(crc1: uLong, crc2: uLong, len2: z_off_t) -> uLong; pub fn deflate(strm: z_streamp, flush: c_int) -> c_int; pub fn deflateBound(strm: z_streamp, sourceLen: uLong) -> uLong; pub fn deflateCopy(dest: z_streamp, source: z_streamp) -> c_int; pub fn deflateEnd(strm: z_streamp) -> c_int; pub fn deflateInit_(strm: z_streamp, level: c_int, version: *const c_char, stream_size: c_int) -> c_int; pub fn deflateInit2_(strm: z_streamp, level: c_int, method: c_int, windowBits: c_int, memLevel: c_int, strategy: c_int, version: *const c_char, stream_size: c_int) -> c_int; pub fn deflateParams(strm: z_streamp, level: c_int, strategy: c_int) -> c_int; pub fn deflatePrime(strm: z_streamp, bits: c_int, value: c_int) -> c_int; pub fn deflateReset(strm: z_streamp) -> c_int; pub fn deflateSetDictionary(strm: z_streamp, dictionary: *const Bytef, dictLength: uInt) -> c_int; pub fn deflateSetHeader(strm: z_streamp, head: gz_headerp) -> c_int; pub fn deflateTune(strm: z_streamp, good_length: c_int, max_lazy: c_int, nice_length: c_int, max_chain: c_int) -> c_int; pub fn gzdirect(file: gzFile) -> c_int; pub fn gzdopen(fd: c_int, mode: *const c_char) -> gzFile; pub fn gzclearerr(file: gzFile); pub fn gzclose(file: gzFile) -> c_int; pub fn gzeof(file: gzFile) -> c_int; pub fn gzerror(file: gzFile, errnum: *mut c_int) -> *const c_char; pub fn gzflush(file: gzFile, flush: c_int) -> c_int; pub fn gzgetc(file: gzFile) -> c_int; pub fn gzgets(file: gzFile, buf: *mut c_char, len: c_int) -> *mut c_char; pub fn gzopen(path: *const c_char, mode: *const c_char) -> gzFile; pub fn gzputc(file: gzFile, c: c_int) -> c_int; pub fn gzputs(file: gzFile, s: *const c_char) -> c_int; pub fn gzread(file: gzFile, buf: voidp, len: c_uint) -> c_int; pub fn gzrewind(file: gzFile) -> c_int; pub fn gzseek(file: gzFile, offset: z_off_t, whence: c_int) -> z_off_t; pub fn gzsetparams(file: gzFile, level: c_int, strategy: c_int) -> c_int; pub fn gztell(file: gzFile) -> z_off_t; pub fn gzungetc(c: c_int, file: gzFile) -> c_int; pub fn gzwrite(file: gzFile, buf: voidpc, len: c_uint) -> c_int; pub fn inflate(strm: z_streamp, flush: c_int) -> c_int; pub fn inflateBack(strm: z_streamp, _in: in_func, in_desc: *mut c_void, out: out_func, out_desc: *mut c_void) -> c_int; pub fn inflateBackEnd(strm: z_streamp) -> c_int; pub fn inflateBackInit_(strm: z_streamp, windowBits: c_int, window: *mut c_uchar, version: *const c_char, stream_size: c_int) -> c_int; pub fn inflateCopy(dest: z_streamp, source: z_streamp) -> c_int; pub fn inflateEnd(strm: z_streamp) -> c_int; pub fn inflateGetHeader(strm: z_streamp, head: gz_headerp) -> c_int; pub fn inflateInit_(strm: z_streamp, version: *const c_char, stream_size: c_int) -> c_int; pub fn inflateInit2_(strm: z_streamp, windowBits: c_int, version: *const c_char, stream_size: c_int) -> c_int; pub fn inflateMark(strm: z_streamp) -> c_long; pub fn inflatePrime(strm: z_streamp, bits: c_int, value: c_int) -> c_int; pub fn inflateReset(strm: z_streamp) -> c_int; pub fn inflateReset2(strm: z_streamp, windowBits: c_int) -> c_int; pub fn inflateSetDictionary(strm: z_streamp, dictionary: *const Bytef, dictLength: uInt) -> c_int; pub fn inflateSync(strm: z_streamp) -> c_int; pub fn uncompress(dest: *mut Bytef, destLen: *mut uLongf, source: *const Bytef, sourceLen: uLong) -> c_int; pub fn zlibCompileFlags() -> uLong; pub fn zlibVersion() -> *const c_char; // The above set of functions currently target 1.2.3.4 (what's present on Ubuntu // 12.04, but there's some other APIs that were added later. Should figure out // how to expose them... // // Added in 1.2.5.1 // // pub fn deflatePending(strm: z_streamp, // pending: *mut c_uint, // bits: *mut c_int) -> c_int; // // Addedin 1.2.7.1 // pub fn inflateGetDictionary(strm: z_streamp, // dictionary: *mut Bytef, // dictLength: *mut uInt) -> c_int; // // Added in 1.2.3.5 // pub fn gzbuffer(file: gzFile, size: c_uint) -> c_int; // pub fn gzclose_r(file: gzFile) -> c_int; // pub fn gzclose_w(file: gzFile) -> c_int; // pub fn gzoffset(file: gzFile) -> z_off_t; } pub const Z_NO_FLUSH: c_int = 0; pub const Z_PARTIAL_FLUSH: c_int = 1; pub const Z_SYNC_FLUSH: c_int = 2; pub const Z_FULL_FLUSH: c_int = 3; pub const Z_FINISH: c_int = 4; pub const Z_BLOCK: c_int = 5; pub const Z_TREES: c_int = 6; pub const Z_OK: c_int = 0; pub const Z_STREAM_END: c_int = 1; pub const Z_NEED_DICT: c_int = 2; pub const Z_ERRNO: c_int = -1; pub const Z_STREAM_ERROR: c_int = -2; pub const Z_DATA_ERROR: c_int = -3; pub const Z_MEM_ERROR: c_int = -4; pub const Z_BUF_ERROR: c_int = -5; pub const Z_VERSION_ERROR: c_int = -6; pub const Z_NO_COMPRESSION: c_int = 0; pub const Z_BEST_SPEED: c_int = 1; pub const Z_BEST_COMPRESSION: c_int = 9; pub const Z_DEFAULT_COMPRESSION: c_int = -1; pub const Z_FILTERED: c_int = 1; pub const Z_HUFFMAN_ONLY: c_int = 2; pub const Z_RLE: c_int = 3; pub const Z_FIXED: c_int = 4; pub const Z_DEFAULT_STRATEGY: c_int = 0; pub const Z_BINARY: c_int = 0; pub const Z_TEXT: c_int = 1; pub const Z_ASCII: c_int = Z_TEXT; pub const Z_UNKNOWN: c_int = 2; pub const Z_DEFLATED: c_int = 8; deps/libz-sys-1.0.0/appveyor.yml0000664000175000017500000000120412617163167013540 0ustar environment: matrix: - TARGET: x86_64-pc-windows-gnu MSYS_BITS: 64 - TARGET: i686-pc-windows-gnu MSYS_BITS: 32 - TARGET: x86_64-pc-windows-msvc - TARGET: i686-pc-windows-msvc install: - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - set PATH=%PATH%;C:\Program Files (x86)\Rust\bin - if defined MSYS_BITS set PATH=%PATH%;C:\msys64\mingw%MSYS_BITS%\bin;C:\msys64\usr\bin - rustc -V - cargo -V build: false test_script: - cargo test - cargo run --manifest-path systest/Cargo.toml deps/libz-sys-1.0.0/Cargo.toml0000664000175000017500000000065512617226275013111 0ustar [package] name = "libz-sys" version = "1.0.0" authors = ["Alex Crichton "] links = "z" build = "build.rs" license = "MIT/Apache-2.0" repository = "https://github.com/alexcrichton/libz-sys" documentation = "http://alexcrichton.com/libz-sys" description = """ Bindings to the system libz library (also known as zlib). """ [dependencies] libc = "0.2" [build-dependencies] pkg-config = "0.3" gcc = "0.3.10" deps/libz-sys-1.0.0/build.rs0000664000175000017500000000675512610310363012616 0ustar extern crate pkg_config; extern crate gcc; use std::env; use std::ffi::OsString; use std::fs; use std::path::{Path, PathBuf}; use std::process::Command; macro_rules! t { ($e:expr) => (match $e { Ok(n) => n, Err(e) => panic!("\n{} failed with {}\n", stringify!($e), e), }) } fn main() { if pkg_config::find_library("zlib").is_ok() { return } // Practically all platforms come with libz installed already, but MSVC is // one of those sole platforms that doesn't! let target = env::var("TARGET").unwrap(); if target.contains("msvc") { build_msvc_zlib(&target); } else if target.contains("musl") { build_zlib(); } else { println!("cargo:rustc-link-lib=z"); } } fn build_zlib() { let src = env::current_dir().unwrap().join("src/zlib-1.2.8"); let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); let build = dst.join("build"); t!(fs::create_dir_all(&build)); cp_r(&src, &build); let compiler = gcc::Config::new().get_compiler(); let mut cflags = OsString::new(); for arg in compiler.args() { cflags.push(arg); cflags.push(" "); } run(Command::new("./configure") .current_dir(&build) .arg(format!("--prefix={}", dst.display())) .env("CC", compiler.path()) .env("CFLAGS", cflags)); run(Command::new("make") .current_dir(&build) .arg("install")); println!("cargo:rustc-link-lib=static=z"); println!("cargo:rustc-link-search={}/lib", dst.to_string_lossy()); println!("cargo:root={}", dst.to_string_lossy()); println!("cargo:include={}/include", dst.to_string_lossy()); } fn cp_r(dir: &Path, dst: &Path) { for entry in t!(fs::read_dir(dir)) { let entry = t!(entry); let path = entry.path(); let dst = dst.join(path.file_name().unwrap()); if t!(fs::metadata(&path)).is_file() { t!(fs::copy(path, dst)); } else { t!(fs::create_dir_all(&dst)); cp_r(&path, &dst); } } } fn build_msvc_zlib(target: &str) { let src = t!(env::current_dir()).join("src/zlib-1.2.8"); let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); t!(fs::create_dir_all(dst.join("lib"))); t!(fs::create_dir_all(dst.join("include"))); let mut top = OsString::from("TOP="); top.push(&src); let nmake = gcc::windows_registry::find(target, "nmake.exe"); let mut nmake = nmake.unwrap_or(Command::new("nmake.exe")); run(nmake.current_dir(dst.join("lib")) .arg("/nologo") .arg("/f") .arg(src.join("win32/Makefile.msc")) .arg(top) .arg("zlib.lib")); for file in t!(fs::read_dir(&src)) { let file = t!(file).path(); if let Some(s) = file.file_name().and_then(|s| s.to_str()) { if s.ends_with(".h") { t!(fs::copy(&file, dst.join("include").join(s))); } } } println!("cargo:rustc-link-lib=static=zlib"); println!("cargo:rustc-link-search={}/lib", dst.to_string_lossy()); println!("cargo:root={}", dst.to_string_lossy()); println!("cargo:include={}/include", dst.to_string_lossy()); } fn run(cmd: &mut Command) { println!("running: {:?}", cmd); let status = match cmd.status() { Ok(s) => s, Err(e) => panic!("failed to run: {}", e), }; if !status.success() { panic!("failed to run successfully: {}", status); } } deps/term-0.2.14/0000755000000000000000000000000012666635520012211 5ustar rootrootdeps/term-0.2.14/LICENSE-APACHE0000600000175000001440000002513712604320630013416 0ustar users Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/term-0.2.14/LICENSE-MIT0000600000175000001440000000205712604320630013122 0ustar usersCopyright (c) 2014 The Rust Project Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/term-0.2.14/.travis.yml0000600000175000001440000000034712616414511013604 0ustar userslanguage: rust rust: - stable - beta - nightly sudo: false script: - cargo build --verbose - cargo test --verbose - cargo doc after_success: curl https://raw.githubusercontent.com/Stebalien/doc/master/push_docs.sh | sh deps/term-0.2.14/README.md0000600000175000001440000000101312616414511012741 0ustar usersterm ==== A Rust library for terminfo parsing and terminal colors. [![Build Status](https://travis-ci.org/Stebalien/term.svg?branch=master)](https://travis-ci.org/Stebalien/term) [![Build status](https://ci.appveyor.com/api/projects/status/2duvop23k4n3owyt?svg=true)](https://ci.appveyor.com/project/Stebalien/term) [Documentation](https://stebalien.github.io/doc/term/term/) ## Usage Add this to your `Cargo.toml`: ```toml [dependencies] term = "*" ``` and this to your crate root: ```rust extern crate term; ``` deps/term-0.2.14/.gitignore0000600000175000001440000000002412604320630013446 0ustar users/target /Cargo.lock deps/term-0.2.14/src/0000755000000000000000000000000012666635520013000 5ustar rootrootdeps/term-0.2.14/src/win.rs0000600000175000001440000001770112621236416013431 0ustar users// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Windows console handling // FIXME (#13400): this is only a tiny fraction of the Windows console api extern crate kernel32; extern crate winapi; use std::io::prelude::*; use std::io; use std::ptr; use Attr; use color; use Terminal; /// A Terminal implementation which uses the Win32 Console API. pub struct WinConsole { buf: T, def_foreground: color::Color, def_background: color::Color, foreground: color::Color, background: color::Color, } fn color_to_bits(color: color::Color) -> u16 { // magic numbers from mingw-w64's wincon.h let bits = match color % 8 { color::BLACK => 0, color::BLUE => 0x1, color::GREEN => 0x2, color::RED => 0x4, color::YELLOW => 0x2 | 0x4, color::MAGENTA => 0x1 | 0x4, color::CYAN => 0x1 | 0x2, color::WHITE => 0x1 | 0x2 | 0x4, _ => unreachable!() }; if color >= 8 { bits | 0x8 } else { bits } } fn bits_to_color(bits: u16) -> color::Color { let color = match bits & 0x7 { 0 => color::BLACK, 0x1 => color::BLUE, 0x2 => color::GREEN, 0x4 => color::RED, 0x6 => color::YELLOW, 0x5 => color::MAGENTA, 0x3 => color::CYAN, 0x7 => color::WHITE, _ => unreachable!() }; color | (bits & 0x8) // copy the hi-intensity bit } // Just get a handle to the current console buffer whatever it is fn conout() -> io::Result { let name = b"CONOUT$\0"; let handle = unsafe { kernel32::CreateFileA( name.as_ptr() as *const i8, winapi::GENERIC_READ | winapi::GENERIC_WRITE, winapi::FILE_SHARE_WRITE, ptr::null_mut(), winapi::OPEN_EXISTING, 0, ptr::null_mut(), ) }; if handle == winapi::INVALID_HANDLE_VALUE { Err(io::Error::last_os_error()) } else { Ok(handle) } } // This test will only pass if it is running in an actual console, probably #[test] fn test_conout() { assert!(conout().is_ok()) } impl WinConsole { fn apply(&mut self) -> io::Result<()> { let out = try!(conout()); let _unused = self.buf.flush(); let mut accum: winapi::WORD = 0; accum |= color_to_bits(self.foreground); accum |= color_to_bits(self.background) << 4; unsafe { kernel32::SetConsoleTextAttribute(out, accum); } Ok(()) } /// Returns `None` whenever the terminal cannot be created for some /// reason. pub fn new(out: T) -> io::Result> { let fg; let bg; let handle = try!(conout()); unsafe { let mut buffer_info = ::std::mem::uninitialized(); if kernel32::GetConsoleScreenBufferInfo(handle, &mut buffer_info) != 0 { fg = bits_to_color(buffer_info.wAttributes); bg = bits_to_color(buffer_info.wAttributes >> 4); } else { return Err(io::Error::last_os_error()) } } Ok(WinConsole { buf: out, def_foreground: fg, def_background: bg, foreground: fg, background: bg, }) } } impl Write for WinConsole { fn write(&mut self, buf: &[u8]) -> io::Result { self.buf.write(buf) } fn flush(&mut self) -> io::Result<()> { self.buf.flush() } } impl Terminal for WinConsole { type Output = T; fn fg(&mut self, color: color::Color) -> io::Result { self.foreground = color; try!(self.apply()); Ok(true) } fn bg(&mut self, color: color::Color) -> io::Result { self.background = color; try!(self.apply()); Ok(true) } fn attr(&mut self, attr: Attr) -> io::Result { match attr { Attr::ForegroundColor(f) => { self.foreground = f; try!(self.apply()); Ok(true) }, Attr::BackgroundColor(b) => { self.background = b; try!(self.apply()); Ok(true) }, _ => Ok(false) } } fn supports_attr(&self, attr: Attr) -> bool { // it claims support for underscore and reverse video, but I can't get // it to do anything -cmr match attr { Attr::ForegroundColor(_) | Attr::BackgroundColor(_) => true, _ => false } } fn reset(&mut self) -> io::Result { self.foreground = self.def_foreground; self.background = self.def_background; try!(self.apply()); Ok(true) } fn cursor_up(&mut self) -> io::Result { let _unused = self.buf.flush(); let handle = try!(conout()); unsafe { let mut buffer_info = ::std::mem::uninitialized(); if kernel32::GetConsoleScreenBufferInfo(handle, &mut buffer_info) != 0 { let (x, y) = (buffer_info.dwCursorPosition.X, buffer_info.dwCursorPosition.Y); if y == 0 { Ok(false) } else { let pos = winapi::COORD { X: x, Y: y - 1 }; if kernel32::SetConsoleCursorPosition(handle, pos) != 0 { Ok(true) } else { Err(io::Error::last_os_error()) } } } else { Err(io::Error::last_os_error()) } } } fn delete_line(&mut self) -> io::Result { let _unused = self.buf.flush(); let handle = try!(conout()); unsafe { let mut buffer_info = ::std::mem::uninitialized(); if kernel32::GetConsoleScreenBufferInfo(handle, &mut buffer_info) == 0 { return Err(io::Error::last_os_error()) } let pos = buffer_info.dwCursorPosition; let size = buffer_info.dwSize; let num = (size.X - pos.X) as winapi::DWORD; let mut written = 0; if kernel32::FillConsoleOutputCharacterW(handle, 0, num, pos, &mut written) == 0 { return Err(io::Error::last_os_error()) } if kernel32::FillConsoleOutputAttribute(handle, 0, num, pos, &mut written) == 0 { return Err(io::Error::last_os_error()) } Ok(written != 0) } } fn carriage_return(&mut self) -> io::Result { let _unused = self.buf.flush(); let handle = try!(conout()); unsafe { let mut buffer_info = ::std::mem::uninitialized(); if kernel32::GetConsoleScreenBufferInfo(handle, &mut buffer_info) != 0 { let (x, y) = (buffer_info.dwCursorPosition.X, buffer_info.dwCursorPosition.Y); if x == 0 { Ok(false) } else { let pos = winapi::COORD { X: 0, Y: y }; if kernel32::SetConsoleCursorPosition(handle, pos) != 0 { Ok(true) } else { Err(io::Error::last_os_error()) } } } else { Err(io::Error::last_os_error()) } } } fn get_ref<'a>(&'a self) -> &'a T { &self.buf } fn get_mut<'a>(&'a mut self) -> &'a mut T { &mut self.buf } fn into_inner(self) -> T where Self: Sized { self.buf } } deps/term-0.2.14/src/lib.rs0000600000175000001440000002071312610334574013401 0ustar users// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Terminal formatting library. //! //! This crate provides the `Terminal` trait, which abstracts over an [ANSI //! Terminal][ansi] to provide color printing, among other things. There are two //! implementations, the `TerminfoTerminal`, which uses control characters from //! a [terminfo][ti] database, and `WinConsole`, which uses the [Win32 Console //! API][win]. //! //! # Usage //! //! This crate is [on crates.io](https://crates.io/crates/term) and can be //! used by adding `term` to the dependencies in your project's `Cargo.toml`. //! //! ```toml //! [dependencies] //! //! term = "0.2" //! ``` //! //! and this to your crate root: //! //! ```rust //! extern crate term; //! ``` //! //! # Examples //! //! ```no_run //! extern crate term; //! use std::io::prelude::*; //! //! fn main() { //! let mut t = term::stdout().unwrap(); //! //! t.fg(term::color::GREEN).unwrap(); //! write!(t, "hello, ").unwrap(); //! //! t.fg(term::color::RED).unwrap(); //! writeln!(t, "world!").unwrap(); //! //! assert!(t.reset().unwrap()); //! } //! ``` //! //! [ansi]: https://en.wikipedia.org/wiki/ANSI_escape_code //! [win]: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682010%28v=vs.85%29.aspx //! [ti]: https://en.wikipedia.org/wiki/Terminfo #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://www.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "http://play.rust-lang.org/")] #![deny(missing_docs)] #![cfg_attr(test, deny(warnings))] #![cfg_attr(rust_build, feature(staged_api))] #![cfg_attr(rust_build, staged_api)] #![cfg_attr(rust_build, unstable(feature = "rustc_private", reason = "use the crates.io `term` library instead"))] use std::io::prelude::*; pub use terminfo::TerminfoTerminal; #[cfg(windows)] pub use win::WinConsole; use std::io::{self, Stdout, Stderr}; pub mod terminfo; #[cfg(windows)] mod win; /// Alias for stdout terminals. pub type StdoutTerminal = Terminal + Send; /// Alias for stderr terminals. pub type StderrTerminal = Terminal + Send; #[cfg(not(windows))] /// Return a Terminal wrapping stdout, or None if a terminal couldn't be /// opened. pub fn stdout() -> Option> { TerminfoTerminal::new(io::stdout()).map(|t| { Box::new(t) as Box }) } #[cfg(windows)] /// Return a Terminal wrapping stdout, or None if a terminal couldn't be /// opened. pub fn stdout() -> Option> { TerminfoTerminal::new(io::stdout()).map(|t| { Box::new(t) as Box }).or_else(|| WinConsole::new(io::stdout()).ok().map(|t| { Box::new(t) as Box })) } #[cfg(not(windows))] /// Return a Terminal wrapping stderr, or None if a terminal couldn't be /// opened. pub fn stderr() -> Option> { TerminfoTerminal::new(io::stderr()).map(|t| { Box::new(t) as Box }) } #[cfg(windows)] /// Return a Terminal wrapping stderr, or None if a terminal couldn't be /// opened. pub fn stderr() -> Option> { TerminfoTerminal::new(io::stderr()).map(|t| { Box::new(t) as Box }).or_else(|| WinConsole::new(io::stderr()).ok().map(|t| { Box::new(t) as Box })) } /// Terminal color definitions #[allow(missing_docs)] pub mod color { /// Number for a terminal color pub type Color = u16; pub const BLACK: Color = 0; pub const RED: Color = 1; pub const GREEN: Color = 2; pub const YELLOW: Color = 3; pub const BLUE: Color = 4; pub const MAGENTA: Color = 5; pub const CYAN: Color = 6; pub const WHITE: Color = 7; pub const BRIGHT_BLACK: Color = 8; pub const BRIGHT_RED: Color = 9; pub const BRIGHT_GREEN: Color = 10; pub const BRIGHT_YELLOW: Color = 11; pub const BRIGHT_BLUE: Color = 12; pub const BRIGHT_MAGENTA: Color = 13; pub const BRIGHT_CYAN: Color = 14; pub const BRIGHT_WHITE: Color = 15; } /// Terminal attributes for use with term.attr(). /// /// Most attributes can only be turned on and must be turned off with term.reset(). /// The ones that can be turned off explicitly take a boolean value. /// Color is also represented as an attribute for convenience. #[derive(Debug, PartialEq, Eq, Copy, Clone)] pub enum Attr { /// Bold (or possibly bright) mode Bold, /// Dim mode, also called faint or half-bright. Often not supported Dim, /// Italics mode. Often not supported Italic(bool), /// Underline mode Underline(bool), /// Blink mode Blink, /// Standout mode. Often implemented as Reverse, sometimes coupled with Bold Standout(bool), /// Reverse mode, inverts the foreground and background colors Reverse, /// Secure mode, also called invis mode. Hides the printed text Secure, /// Convenience attribute to set the foreground color ForegroundColor(color::Color), /// Convenience attribute to set the background color BackgroundColor(color::Color) } /// A terminal with similar capabilities to an ANSI Terminal /// (foreground/background colors etc). pub trait Terminal: Write { /// The terminal's output writer type. type Output: Write; /// Sets the foreground color to the given color. /// /// If the color is a bright color, but the terminal only supports 8 colors, /// the corresponding normal color will be used instead. /// /// Returns `Ok(true)` if the color was set, `Ok(false)` otherwise, and `Err(e)` /// if there was an I/O error. fn fg(&mut self, color: color::Color) -> io::Result; /// Sets the background color to the given color. /// /// If the color is a bright color, but the terminal only supports 8 colors, /// the corresponding normal color will be used instead. /// /// Returns `Ok(true)` if the color was set, `Ok(false)` otherwise, and `Err(e)` /// if there was an I/O error. fn bg(&mut self, color: color::Color) -> io::Result; /// Sets the given terminal attribute, if supported. Returns `Ok(true)` /// if the attribute was supported, `Ok(false)` otherwise, and `Err(e)` if /// there was an I/O error. fn attr(&mut self, attr: Attr) -> io::Result; /// Returns whether the given terminal attribute is supported. fn supports_attr(&self, attr: Attr) -> bool; /// Resets all terminal attributes and colors to their defaults. /// /// Returns `Ok(true)` if the terminal was reset, `Ok(false)` otherwise, and `Err(e)` if there /// was an I/O error. /// /// *Note: This does not flush.* /// /// That means the reset command may get buffered so, if you aren't planning on doing anything /// else that might flush stdout's buffer (e.g. writing a line of text), you should flush after /// calling reset. fn reset(&mut self) -> io::Result; /// Moves the cursor up one line. /// /// Returns `Ok(true)` if the cursor was moved, `Ok(false)` otherwise, and `Err(e)` /// if there was an I/O error. fn cursor_up(&mut self) -> io::Result; /// Deletes the text from the cursor location to the end of the line. /// /// Returns `Ok(true)` if the text was deleted, `Ok(false)` otherwise, and `Err(e)` /// if there was an I/O error. fn delete_line(&mut self) -> io::Result; /// Moves the cursor to the left edge of the current line. /// /// Returns `Ok(true)` if the text was deleted, `Ok(false)` otherwise, and `Err(e)` /// if there was an I/O error. fn carriage_return(&mut self) -> io::Result; /// Gets an immutable reference to the stream inside fn get_ref<'a>(&'a self) -> &'a Self::Output; /// Gets a mutable reference to the stream inside fn get_mut<'a>(&'a mut self) -> &'a mut Self::Output; /// Returns the contained stream, destroying the `Terminal` fn into_inner(self) -> Self::Output where Self: Sized; } deps/term-0.2.14/src/terminfo/0000755000000000000000000000000012666635520014623 5ustar rootrootdeps/term-0.2.14/src/terminfo/parser/0000755000000000000000000000000012666635520016117 5ustar rootrootdeps/term-0.2.14/src/terminfo/parser/compiled.rs0000600000175000001440000004651112621141236017543 0ustar users// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![allow(non_upper_case_globals, missing_docs)] //! ncurses-compatible compiled terminfo format parsing (term(5)) use std::collections::HashMap; use std::io::prelude::*; use std::io; use super::super::TermInfo; // These are the orders ncurses uses in its compiled format (as of 5.9). Not sure if portable. pub static boolfnames: &'static[&'static str] = &["auto_left_margin", "auto_right_margin", "no_esc_ctlc", "ceol_standout_glitch", "eat_newline_glitch", "erase_overstrike", "generic_type", "hard_copy", "has_meta_key", "has_status_line", "insert_null_glitch", "memory_above", "memory_below", "move_insert_mode", "move_standout_mode", "over_strike", "status_line_esc_ok", "dest_tabs_magic_smso", "tilde_glitch", "transparent_underline", "xon_xoff", "needs_xon_xoff", "prtr_silent", "hard_cursor", "non_rev_rmcup", "no_pad_char", "non_dest_scroll_region", "can_change", "back_color_erase", "hue_lightness_saturation", "col_addr_glitch", "cr_cancels_micro_mode", "has_print_wheel", "row_addr_glitch", "semi_auto_right_margin", "cpi_changes_res", "lpi_changes_res", "backspaces_with_bs", "crt_no_scrolling", "no_correctly_working_cr", "gnu_has_meta_key", "linefeed_is_newline", "has_hardware_tabs", "return_does_clr_eol"]; pub static boolnames: &'static[&'static str] = &["bw", "am", "xsb", "xhp", "xenl", "eo", "gn", "hc", "km", "hs", "in", "db", "da", "mir", "msgr", "os", "eslok", "xt", "hz", "ul", "xon", "nxon", "mc5i", "chts", "nrrmc", "npc", "ndscr", "ccc", "bce", "hls", "xhpa", "crxm", "daisy", "xvpa", "sam", "cpix", "lpix", "OTbs", "OTns", "OTnc", "OTMT", "OTNL", "OTpt", "OTxr"]; pub static numfnames: &'static[&'static str] = &[ "columns", "init_tabs", "lines", "lines_of_memory", "magic_cookie_glitch", "padding_baud_rate", "virtual_terminal", "width_status_line", "num_labels", "label_height", "label_width", "max_attributes", "maximum_windows", "max_colors", "max_pairs", "no_color_video", "buffer_capacity", "dot_vert_spacing", "dot_horz_spacing", "max_micro_address", "max_micro_jump", "micro_col_size", "micro_line_size", "number_of_pins", "output_res_char", "output_res_line", "output_res_horz_inch", "output_res_vert_inch", "print_rate", "wide_char_size", "buttons", "bit_image_entwining", "bit_image_type", "magic_cookie_glitch_ul", "carriage_return_delay", "new_line_delay", "backspace_delay", "horizontal_tab_delay", "number_of_function_keys"]; pub static numnames: &'static[&'static str] = &[ "cols", "it", "lines", "lm", "xmc", "pb", "vt", "wsl", "nlab", "lh", "lw", "ma", "wnum", "colors", "pairs", "ncv", "bufsz", "spinv", "spinh", "maddr", "mjump", "mcs", "mls", "npins", "orc", "orl", "orhi", "orvi", "cps", "widcs", "btns", "bitwin", "bitype", "UTug", "OTdC", "OTdN", "OTdB", "OTdT", "OTkn"]; pub static stringfnames: &'static[&'static str] = &[ "back_tab", "bell", "carriage_return", "change_scroll_region", "clear_all_tabs", "clear_screen", "clr_eol", "clr_eos", "column_address", "command_character", "cursor_address", "cursor_down", "cursor_home", "cursor_invisible", "cursor_left", "cursor_mem_address", "cursor_normal", "cursor_right", "cursor_to_ll", "cursor_up", "cursor_visible", "delete_character", "delete_line", "dis_status_line", "down_half_line", "enter_alt_charset_mode", "enter_blink_mode", "enter_bold_mode", "enter_ca_mode", "enter_delete_mode", "enter_dim_mode", "enter_insert_mode", "enter_secure_mode", "enter_protected_mode", "enter_reverse_mode", "enter_standout_mode", "enter_underline_mode", "erase_chars", "exit_alt_charset_mode", "exit_attribute_mode", "exit_ca_mode", "exit_delete_mode", "exit_insert_mode", "exit_standout_mode", "exit_underline_mode", "flash_screen", "form_feed", "from_status_line", "init_1string", "init_2string", "init_3string", "init_file", "insert_character", "insert_line", "insert_padding", "key_backspace", "key_catab", "key_clear", "key_ctab", "key_dc", "key_dl", "key_down", "key_eic", "key_eol", "key_eos", "key_f0", "key_f1", "key_f10", "key_f2", "key_f3", "key_f4", "key_f5", "key_f6", "key_f7", "key_f8", "key_f9", "key_home", "key_ic", "key_il", "key_left", "key_ll", "key_npage", "key_ppage", "key_right", "key_sf", "key_sr", "key_stab", "key_up", "keypad_local", "keypad_xmit", "lab_f0", "lab_f1", "lab_f10", "lab_f2", "lab_f3", "lab_f4", "lab_f5", "lab_f6", "lab_f7", "lab_f8", "lab_f9", "meta_off", "meta_on", "newline", "pad_char", "parm_dch", "parm_delete_line", "parm_down_cursor", "parm_ich", "parm_index", "parm_insert_line", "parm_left_cursor", "parm_right_cursor", "parm_rindex", "parm_up_cursor", "pkey_key", "pkey_local", "pkey_xmit", "print_screen", "prtr_off", "prtr_on", "repeat_char", "reset_1string", "reset_2string", "reset_3string", "reset_file", "restore_cursor", "row_address", "save_cursor", "scroll_forward", "scroll_reverse", "set_attributes", "set_tab", "set_window", "tab", "to_status_line", "underline_char", "up_half_line", "init_prog", "key_a1", "key_a3", "key_b2", "key_c1", "key_c3", "prtr_non", "char_padding", "acs_chars", "plab_norm", "key_btab", "enter_xon_mode", "exit_xon_mode", "enter_am_mode", "exit_am_mode", "xon_character", "xoff_character", "ena_acs", "label_on", "label_off", "key_beg", "key_cancel", "key_close", "key_command", "key_copy", "key_create", "key_end", "key_enter", "key_exit", "key_find", "key_help", "key_mark", "key_message", "key_move", "key_next", "key_open", "key_options", "key_previous", "key_print", "key_redo", "key_reference", "key_refresh", "key_replace", "key_restart", "key_resume", "key_save", "key_suspend", "key_undo", "key_sbeg", "key_scancel", "key_scommand", "key_scopy", "key_screate", "key_sdc", "key_sdl", "key_select", "key_send", "key_seol", "key_sexit", "key_sfind", "key_shelp", "key_shome", "key_sic", "key_sleft", "key_smessage", "key_smove", "key_snext", "key_soptions", "key_sprevious", "key_sprint", "key_sredo", "key_sreplace", "key_sright", "key_srsume", "key_ssave", "key_ssuspend", "key_sundo", "req_for_input", "key_f11", "key_f12", "key_f13", "key_f14", "key_f15", "key_f16", "key_f17", "key_f18", "key_f19", "key_f20", "key_f21", "key_f22", "key_f23", "key_f24", "key_f25", "key_f26", "key_f27", "key_f28", "key_f29", "key_f30", "key_f31", "key_f32", "key_f33", "key_f34", "key_f35", "key_f36", "key_f37", "key_f38", "key_f39", "key_f40", "key_f41", "key_f42", "key_f43", "key_f44", "key_f45", "key_f46", "key_f47", "key_f48", "key_f49", "key_f50", "key_f51", "key_f52", "key_f53", "key_f54", "key_f55", "key_f56", "key_f57", "key_f58", "key_f59", "key_f60", "key_f61", "key_f62", "key_f63", "clr_bol", "clear_margins", "set_left_margin", "set_right_margin", "label_format", "set_clock", "display_clock", "remove_clock", "create_window", "goto_window", "hangup", "dial_phone", "quick_dial", "tone", "pulse", "flash_hook", "fixed_pause", "wait_tone", "user0", "user1", "user2", "user3", "user4", "user5", "user6", "user7", "user8", "user9", "orig_pair", "orig_colors", "initialize_color", "initialize_pair", "set_color_pair", "set_foreground", "set_background", "change_char_pitch", "change_line_pitch", "change_res_horz", "change_res_vert", "define_char", "enter_doublewide_mode", "enter_draft_quality", "enter_italics_mode", "enter_leftward_mode", "enter_micro_mode", "enter_near_letter_quality", "enter_normal_quality", "enter_shadow_mode", "enter_subscript_mode", "enter_superscript_mode", "enter_upward_mode", "exit_doublewide_mode", "exit_italics_mode", "exit_leftward_mode", "exit_micro_mode", "exit_shadow_mode", "exit_subscript_mode", "exit_superscript_mode", "exit_upward_mode", "micro_column_address", "micro_down", "micro_left", "micro_right", "micro_row_address", "micro_up", "order_of_pins", "parm_down_micro", "parm_left_micro", "parm_right_micro", "parm_up_micro", "select_char_set", "set_bottom_margin", "set_bottom_margin_parm", "set_left_margin_parm", "set_right_margin_parm", "set_top_margin", "set_top_margin_parm", "start_bit_image", "start_char_set_def", "stop_bit_image", "stop_char_set_def", "subscript_characters", "superscript_characters", "these_cause_cr", "zero_motion", "char_set_names", "key_mouse", "mouse_info", "req_mouse_pos", "get_mouse", "set_a_foreground", "set_a_background", "pkey_plab", "device_type", "code_set_init", "set0_des_seq", "set1_des_seq", "set2_des_seq", "set3_des_seq", "set_lr_margin", "set_tb_margin", "bit_image_repeat", "bit_image_newline", "bit_image_carriage_return", "color_names", "define_bit_image_region", "end_bit_image_region", "set_color_band", "set_page_length", "display_pc_char", "enter_pc_charset_mode", "exit_pc_charset_mode", "enter_scancode_mode", "exit_scancode_mode", "pc_term_options", "scancode_escape", "alt_scancode_esc", "enter_horizontal_hl_mode", "enter_left_hl_mode", "enter_low_hl_mode", "enter_right_hl_mode", "enter_top_hl_mode", "enter_vertical_hl_mode", "set_a_attributes", "set_pglen_inch", "termcap_init2", "termcap_reset", "linefeed_if_not_lf", "backspace_if_not_bs", "other_non_function_keys", "arrow_key_map", "acs_ulcorner", "acs_llcorner", "acs_urcorner", "acs_lrcorner", "acs_ltee", "acs_rtee", "acs_btee", "acs_ttee", "acs_hline", "acs_vline", "acs_plus", "memory_lock", "memory_unlock", "box_chars_1"]; pub static stringnames: &'static[&'static str] = &[ "cbt", "_", "cr", "csr", "tbc", "clear", "_", "_", "hpa", "cmdch", "cup", "cud1", "home", "civis", "cub1", "mrcup", "cnorm", "cuf1", "ll", "cuu1", "cvvis", "dch1", "dl1", "dsl", "hd", "smacs", "blink", "bold", "smcup", "smdc", "dim", "smir", "invis", "prot", "rev", "smso", "smul", "ech", "rmacs", "sgr0", "rmcup", "rmdc", "rmir", "rmso", "rmul", "flash", "ff", "fsl", "is1", "is2", "is3", "if", "ich1", "il1", "ip", "kbs", "ktbc", "kclr", "kctab", "_", "_", "kcud1", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "khome", "_", "_", "kcub1", "_", "knp", "kpp", "kcuf1", "_", "_", "khts", "_", "rmkx", "smkx", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "rmm", "_", "_", "pad", "dch", "dl", "cud", "ich", "indn", "il", "cub", "cuf", "rin", "cuu", "pfkey", "pfloc", "pfx", "mc0", "mc4", "_", "rep", "rs1", "rs2", "rs3", "rf", "rc", "vpa", "sc", "ind", "ri", "sgr", "_", "wind", "_", "tsl", "uc", "hu", "iprog", "_", "_", "_", "_", "_", "mc5p", "rmp", "acsc", "pln", "kcbt", "smxon", "rmxon", "smam", "rmam", "xonc", "xoffc", "_", "smln", "rmln", "_", "kcan", "kclo", "kcmd", "kcpy", "kcrt", "_", "kent", "kext", "kfnd", "khlp", "kmrk", "kmsg", "kmov", "knxt", "kopn", "kopt", "kprv", "kprt", "krdo", "kref", "krfr", "krpl", "krst", "kres", "ksav", "kspd", "kund", "kBEG", "kCAN", "kCMD", "kCPY", "kCRT", "_", "_", "kslt", "kEND", "kEOL", "kEXT", "kFND", "kHLP", "kHOM", "_", "kLFT", "kMSG", "kMOV", "kNXT", "kOPT", "kPRV", "kPRT", "kRDO", "kRPL", "kRIT", "kRES", "kSAV", "kSPD", "kUND", "rfi", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "dclk", "rmclk", "cwin", "wingo", "_", "dial", "qdial", "_", "_", "hook", "pause", "wait", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "op", "oc", "initc", "initp", "scp", "setf", "setb", "cpi", "lpi", "chr", "cvr", "defc", "swidm", "sdrfq", "sitm", "slm", "smicm", "snlq", "snrmq", "sshm", "ssubm", "ssupm", "sum", "rwidm", "ritm", "rlm", "rmicm", "rshm", "rsubm", "rsupm", "rum", "mhpa", "mcud1", "mcub1", "mcuf1", "mvpa", "mcuu1", "porder", "mcud", "mcub", "mcuf", "mcuu", "scs", "smgb", "smgbp", "smglp", "smgrp", "smgt", "smgtp", "sbim", "scsd", "rbim", "rcsd", "subcs", "supcs", "docr", "zerom", "csnm", "kmous", "minfo", "reqmp", "getm", "setaf", "setab", "pfxl", "devt", "csin", "s0ds", "s1ds", "s2ds", "s3ds", "smglr", "smgtb", "birep", "binel", "bicr", "colornm", "defbi", "endbi", "setcolor", "slines", "dispc", "smpch", "rmpch", "smsc", "rmsc", "pctrm", "scesc", "scesa", "ehhlm", "elhlm", "elohlm", "erhlm", "ethlm", "evhlm", "sgr1", "slength", "OTi2", "OTrs", "OTnl", "OTbs", "OTko", "OTma", "OTG2", "OTG3", "OTG1", "OTG4", "OTGR", "OTGL", "OTGU", "OTGD", "OTGH", "OTGV", "OTGC", "meml", "memu", "box1"]; fn read_le_u16(r: &mut io::Read) -> io::Result { let mut b = [0; 2]; let mut amt = 0; while amt < b.len() { match try!(r.read(&mut b[amt..])) { 0 => return Err(io::Error::new(io::ErrorKind::Other, "end of file")), n => amt += n, } } Ok((b[0] as u16) | ((b[1] as u16) << 8)) } fn read_byte(r: &mut io::Read) -> io::Result { match r.bytes().next() { Some(s) => s, None => Err(io::Error::new(io::ErrorKind::Other, "end of file")) } } /// Parse a compiled terminfo entry, using long capability names if `longnames` /// is true pub fn parse(file: &mut io::Read, longnames: bool) -> Result { macro_rules! try( ($e:expr) => ( match $e { Ok(e) => e, Err(e) => return Err(format!("{}", e)) } ) ); let (bnames, snames, nnames) = if longnames { (boolfnames, stringfnames, numfnames) } else { (boolnames, stringnames, numnames) }; // Check magic number let magic = try!(read_le_u16(file)); if magic != 0x011A { return Err(format!("invalid magic number: expected {:x}, found {:x}", 0x011A, magic)); } // According to the spec, these fields must be >= -1 where -1 means that the feature is not // supported. Using 0 instead of -1 works because we skip sections with length 0. macro_rules! read_nonneg { () => {{ match try!(read_le_u16(file)) as i16 { n if n >= 0 => n as usize, -1 => 0, _ => return Err("incompatible file: length fields must be >= -1".to_string()), } }} } let names_bytes = read_nonneg!(); let bools_bytes = read_nonneg!(); let numbers_count = read_nonneg!(); let string_offsets_count = read_nonneg!(); let string_table_bytes = read_nonneg!(); if names_bytes == 0 { return Err("incompatible file: names field must be \ at least 1 byte wide".to_string()); } if bools_bytes > boolnames.len() { return Err("incompatible file: more booleans than \ expected".to_string()); } if numbers_count > numnames.len() { return Err("incompatible file: more numbers than \ expected".to_string()); } if string_offsets_count > stringnames.len() { return Err("incompatible file: more string offsets than \ expected".to_string()); } // don't read NUL let mut bytes = Vec::new(); try!(file.take((names_bytes - 1) as u64).read_to_end(&mut bytes)); let names_str = match String::from_utf8(bytes) { Ok(s) => s, Err(_) => return Err("input not utf-8".to_string()), }; let term_names: Vec = names_str.split('|') .map(|s| s.to_string()) .collect(); // consume NUL if try!(read_byte(file)) != b'\0' { return Err("incompatible file: missing null terminator \ for names section".to_string()); } let bools_map: HashMap = try! { (0..bools_bytes).filter_map(|i| match read_byte(file) { Err(e) => Some(Err(e)), Ok(1) => Some(Ok((bnames[i].to_string(), true))), Ok(_) => None }).collect() }; if (bools_bytes + names_bytes) % 2 == 1 { try!(read_byte(file)); // compensate for padding } let numbers_map: HashMap = try! { (0..numbers_count).filter_map(|i| match read_le_u16(file) { Ok(0xFFFF) => None, Ok(n) => Some(Ok((nnames[i].to_string(), n))), Err(e) => Some(Err(e)) }).collect() }; let string_map: HashMap> = if string_offsets_count > 0 { let string_offsets: Vec = try!((0..string_offsets_count).map(|_| { read_le_u16(file) }).collect()); let mut string_table = Vec::new(); try!(file.take(string_table_bytes as u64).read_to_end(&mut string_table)); try!(string_offsets.into_iter().enumerate().filter(|&(_, offset)| { // non-entry offset != 0xFFFF }).map(|(i, offset)| { let offset = offset as usize; let name = if snames[i] == "_" { stringfnames[i] } else { snames[i] }; if offset == 0xFFFE { // undocumented: FFFE indicates cap@, which means the capability is not present // unsure if the handling for this is correct return Ok((name.to_string(), Vec::new())); } // Find the offset of the NUL we want to go to let nulpos = string_table[offset..string_table_bytes].iter().position(|&b| b == 0); match nulpos { Some(len) => Ok((name.to_string(), string_table[offset..offset + len].to_vec())), None => Err("invalid file: missing NUL in string_table".to_string()), } }).collect()) } else { HashMap::new() }; // And that's all there is to it Ok(TermInfo { names: term_names, bools: bools_map, numbers: numbers_map, strings: string_map }) } /// Create a dummy TermInfo struct for msys terminals pub fn msys_terminfo() -> TermInfo { let mut strings = HashMap::new(); strings.insert("sgr0".to_string(), b"\x1B[0m".to_vec()); strings.insert("bold".to_string(), b"\x1B[1m".to_vec()); strings.insert("setaf".to_string(), b"\x1B[3%p1%dm".to_vec()); strings.insert("setab".to_string(), b"\x1B[4%p1%dm".to_vec()); let mut numbers = HashMap::new(); numbers.insert("colors".to_string(), 8u16); TermInfo { names: vec!("cygwin".to_string()), // msys is a fork of an older cygwin version bools: HashMap::new(), numbers: numbers, strings: strings } } #[cfg(test)] mod test { use super::{boolnames, boolfnames, numnames, numfnames, stringnames, stringfnames}; #[test] fn test_veclens() { assert_eq!(boolfnames.len(), boolnames.len()); assert_eq!(numfnames.len(), numnames.len()); assert_eq!(stringfnames.len(), stringnames.len()); } #[test] #[ignore(reason = "no ncurses on buildbots, needs a bundled terminfo file to test against")] fn test_parse() { // FIXME #6870: Distribute a compiled file in src/tests and test there // parse(io::fs_reader(&p("/usr/share/terminfo/r/rxvt-256color")).unwrap(), false); } } deps/term-0.2.14/src/terminfo/searcher.rs0000600000175000001440000000536612621660316016257 0ustar users// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! ncurses-compatible database discovery //! //! Does not support hashed database, only filesystem! use std::env; use std::fs; use std::path::PathBuf; /// Return path to database entry for `term` pub fn get_dbpath_for_term(term: &str) -> Option { let mut dirs_to_search = Vec::new(); let first_char = match term.chars().next() { Some(c) => c, None => return None }; // Find search directory match env::var_os("TERMINFO") { Some(dir) => dirs_to_search.push(PathBuf::from(dir)), None => { if let Some(mut homedir) = env::home_dir() { // ncurses compatibility; homedir.push(".terminfo"); dirs_to_search.push(homedir) } match env::var("TERMINFO_DIRS") { Ok(dirs) => for i in dirs.split(':') { if i == "" { dirs_to_search.push(PathBuf::from("/usr/share/terminfo")); } else { dirs_to_search.push(PathBuf::from(i)); } }, // Found nothing in TERMINFO_DIRS, use the default paths: // According to /etc/terminfo/README, after looking at // ~/.terminfo, ncurses will search /etc/terminfo, then // /lib/terminfo, and eventually /usr/share/terminfo. Err(..) => { dirs_to_search.push(PathBuf::from("/etc/terminfo")); dirs_to_search.push(PathBuf::from("/lib/terminfo")); dirs_to_search.push(PathBuf::from("/usr/share/terminfo")); } } } }; // Look for the terminal in all of the search directories for mut p in dirs_to_search { if fs::metadata(&p).is_ok() { p.push(&first_char.to_string()); p.push(&term); if fs::metadata(&p).is_ok() { return Some(p); } p.pop(); p.pop(); // on some installations the dir is named after the hex of the char // (e.g. OS X) p.push(&format!("{:x}", first_char as usize)); p.push(term); if fs::metadata(&p).is_ok() { return Some(p); } } } None } deps/term-0.2.14/src/terminfo/mod.rs0000600000175000001440000002020012624756471015235 0ustar users// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Terminfo database interface. use std::collections::HashMap; use std::env; use std::error; use std::fmt; use std::fs::File; use std::io::prelude::*; use std::io; use std::io::BufReader; use std::path::Path; use Attr; use color; use Terminal; use self::searcher::get_dbpath_for_term; use self::parser::compiled::{parse, msys_terminfo}; use self::parm::{expand, Variables, Param}; /// A parsed terminfo database entry. #[derive(Debug)] pub struct TermInfo { /// Names for the terminal pub names: Vec , /// Map of capability name to boolean value pub bools: HashMap, /// Map of capability name to numeric value pub numbers: HashMap, /// Map of capability name to raw (unexpanded) string pub strings: HashMap > } /// A terminfo creation error. #[derive(Debug)] pub enum Error { /// TermUnset Indicates that the environment doesn't include enough information to find /// the terminfo entry. TermUnset, /// MalformedTerminfo indicates that parsing the terminfo entry failed. MalformedTerminfo(String), /// io::Error forwards any io::Errors encountered when finding or reading the terminfo entry. IoError(io::Error), } impl error::Error for Error { fn description(&self) -> &str { "failed to create TermInfo" } fn cause(&self) -> Option<&error::Error> { use self::Error::*; match self { &IoError(ref e) => Some(e), _ => None, } } } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use self::Error::*; match self { &TermUnset => Ok(()), &MalformedTerminfo(ref e) => e.fmt(f), &IoError(ref e) => e.fmt(f), } } } impl TermInfo { /// Create a TermInfo based on current environment. pub fn from_env() -> Result { let term = match env::var("TERM") { Ok(name) => TermInfo::from_name(&name), Err(..) => return Err(Error::TermUnset), }; if term.is_err() && env::var("MSYSCON").ok().map_or(false, |s| "mintty.exe" == s) { // msys terminal Ok(msys_terminfo()) } else { term } } /// Create a TermInfo for the named terminal. pub fn from_name(name: &str) -> Result { get_dbpath_for_term(name).ok_or_else(|| { Error::IoError(io::Error::new(io::ErrorKind::NotFound, "terminfo file not found")) }).and_then(|p| { TermInfo::from_path(&p) }) } /// Parse the given TermInfo. pub fn from_path(path: &Path) -> Result { let file = try!(File::open(path).map_err(|e| { Error::IoError(e) })); let mut reader = BufReader::new(file); parse(&mut reader, false).map_err(|e| { Error::MalformedTerminfo(e) }) } } pub mod searcher; /// TermInfo format parsing. pub mod parser { //! ncurses-compatible compiled terminfo format parsing (term(5)) pub mod compiled; } pub mod parm; fn cap_for_attr(attr: Attr) -> &'static str { match attr { Attr::Bold => "bold", Attr::Dim => "dim", Attr::Italic(true) => "sitm", Attr::Italic(false) => "ritm", Attr::Underline(true) => "smul", Attr::Underline(false) => "rmul", Attr::Blink => "blink", Attr::Standout(true) => "smso", Attr::Standout(false) => "rmso", Attr::Reverse => "rev", Attr::Secure => "invis", Attr::ForegroundColor(_) => "setaf", Attr::BackgroundColor(_) => "setab" } } /// A Terminal that knows how many colors it supports, with a reference to its /// parsed Terminfo database record. pub struct TerminfoTerminal { num_colors: u16, out: T, ti: TermInfo, } impl Terminal for TerminfoTerminal { type Output = T; fn fg(&mut self, color: color::Color) -> io::Result { let color = self.dim_if_necessary(color); if self.num_colors > color { return self.apply_cap("setaf", &[Param::Number(color as i32)]); } Ok(false) } fn bg(&mut self, color: color::Color) -> io::Result { let color = self.dim_if_necessary(color); if self.num_colors > color { return self.apply_cap("setab", &[Param::Number(color as i32)]); } Ok(false) } fn attr(&mut self, attr: Attr) -> io::Result { match attr { Attr::ForegroundColor(c) => self.fg(c), Attr::BackgroundColor(c) => self.bg(c), _ => self.apply_cap(cap_for_attr(attr), &[]), } } fn supports_attr(&self, attr: Attr) -> bool { match attr { Attr::ForegroundColor(_) | Attr::BackgroundColor(_) => { self.num_colors > 0 } _ => { let cap = cap_for_attr(attr); self.ti.strings.get(cap).is_some() } } } fn reset(&mut self) -> io::Result { // are there any terminals that have color/attrs and not sgr0? // Try falling back to sgr, then op let cmd = match [ "sg0", "sgr", "op" ].iter().filter_map(|cap| { self.ti.strings.get(*cap) }).next() { Some(op) => match expand(&op, &[], &mut Variables::new()) { Ok(cmd) => cmd, Err(_) => return Ok(false), }, None => return Ok(false), }; self.out.write_all(&cmd).map(|_|true) } fn cursor_up(&mut self) -> io::Result { self.apply_cap("cuu1", &[]) } fn delete_line(&mut self) -> io::Result { self.apply_cap("dl", &[]) } fn carriage_return(&mut self) -> io::Result { self.apply_cap("cr", &[]) } fn get_ref<'a>(&'a self) -> &'a T { &self.out } fn get_mut<'a>(&'a mut self) -> &'a mut T { &mut self.out } fn into_inner(self) -> T where Self: Sized { self.out } } impl TerminfoTerminal { /// Create a new TerminfoTerminal with the given TermInfo and Write. pub fn new_with_terminfo(out: T, terminfo: TermInfo) -> TerminfoTerminal { let nc = if terminfo.strings.contains_key("setaf") && terminfo.strings.contains_key("setab") { terminfo.numbers.get("colors").map_or(0, |&n| n) } else { 0 }; TerminfoTerminal { out: out, ti: terminfo, num_colors: nc, } } /// Create a new TerminfoTerminal for the current environment with the given Write. /// /// Returns `None` when the terminfo cannot be found or parsed. pub fn new(out: T) -> Option> { TermInfo::from_env().map(move |ti| TerminfoTerminal::new_with_terminfo(out, ti)).ok() } fn dim_if_necessary(&self, color: color::Color) -> color::Color { if color >= self.num_colors && color >= 8 && color < 16 { color-8 } else { color } } fn apply_cap(&mut self, cmd: &str, params: &[Param]) -> io::Result { if let Some(cmd) = self.ti.strings.get(cmd) { if let Ok(s) = expand(&cmd, params, &mut Variables::new()) { try!(self.out.write_all(&s)); return Ok(true) } } Ok(false) } } impl Write for TerminfoTerminal { fn write(&mut self, buf: &[u8]) -> io::Result { self.out.write(buf) } fn flush(&mut self) -> io::Result<()> { self.out.flush() } } deps/term-0.2.14/src/terminfo/parm.rs0000600000175000001440000005633112624756425015432 0ustar users// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Parameterized string expansion use self::Param::*; use self::States::*; use self::FormatState::*; use self::FormatOp::*; use std::iter::repeat; #[derive(Clone, Copy, PartialEq)] enum States { Nothing, Percent, SetVar, GetVar, PushParam, CharConstant, CharClose, IntConstant(i32), FormatPattern(Flags, FormatState), SeekIfElse(usize), SeekIfElsePercent(usize), SeekIfEnd(usize), SeekIfEndPercent(usize) } #[derive(Copy, PartialEq, Clone)] enum FormatState { FormatStateFlags, FormatStateWidth, FormatStatePrecision } /// Types of parameters a capability can use #[allow(missing_docs)] #[derive(Clone)] pub enum Param { Words(String), Number(i32) } /// Container for static and dynamic variable arrays pub struct Variables { /// Static variables A-Z sta: [Param; 26], /// Dynamic variables a-z dyn: [Param; 26] } impl Variables { /// Return a new zero-initialized Variables pub fn new() -> Variables { Variables { sta: [ Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), ], dyn: [ Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), ], } } } /// Expand a parameterized capability /// /// # Arguments /// * `cap` - string to expand /// * `params` - vector of params for %p1 etc /// * `vars` - Variables struct for %Pa etc /// /// To be compatible with ncurses, `vars` should be the same between calls to `expand` for /// multiple capabilities for the same terminal. pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) -> Result , String> { let mut state = Nothing; // expanded cap will only rarely be larger than the cap itself let mut output = Vec::with_capacity(cap.len()); let mut stack: Vec = Vec::new(); // Copy parameters into a local vector for mutability let mut mparams = [ Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), ]; for (dst, src) in mparams.iter_mut().zip(params.iter()) { *dst = (*src).clone(); } for &c in cap.iter() { let cur = c as char; let mut old_state = state; match state { Nothing => { if cur == '%' { state = Percent; } else { output.push(c); } }, Percent => { match cur { '%' => { output.push(c); state = Nothing }, 'c' => match stack.pop() { // if c is 0, use 0200 (128) for ncurses compatibility Some(Number(0)) => output.push(128u8), // Don't check bounds. ncurses just casts and truncates. Some(Number(c)) => output.push(c as u8), Some(_) => return Err("a non-char was used with %c".to_string()), None => return Err("stack is empty".to_string()), }, 'p' => state = PushParam, 'P' => state = SetVar, 'g' => state = GetVar, '\'' => state = CharConstant, '{' => state = IntConstant(0), 'l' => match stack.pop() { Some(Words(s)) => stack.push(Number(s.len() as i32)), Some(_) => return Err("a non-str was used with %l".to_string()), None => return Err("stack is empty".to_string()) }, '+'|'-'|'/'|'*'|'^'|'&'|'|'|'m' => match (stack.pop(), stack.pop()) { (Some(Number(y)), Some(Number(x))) => stack.push(Number(match cur { '+' => x + y, '-' => x - y, '*' => x * y, '/' => x / y, '|' => x | y, '&' => x & y, '^' => x ^ y, 'm' => x % y, _ => unreachable!("All cases handled"), })), (Some(_), Some(_)) => return Err(format!("non-numbers on stack with {}", cur)), _ => return Err("stack is empty".to_string()), }, '='|'>'|'<'|'A'|'O' => match (stack.pop(), stack.pop()) { (Some(Number(y)), Some(Number(x))) => stack.push(Number(if match cur { '=' => x == y, '<' => x < y, '>' => x > y, 'A' => x > 0 && y > 0, 'O' => x > 0 || y > 0, _ => unreachable!(), } { 1 } else { 0 })), (Some(_), Some(_)) => return Err(format!("non-numbers on stack with {}", cur)), _ => return Err("stack is empty".to_string()), }, '!'|'~' => match stack.pop() { Some(Number(x)) => stack.push(Number(match cur { '!' if x > 0 => 0, '!' => 1, '~' => !x, _ => unreachable!(), })), Some(_) => return Err(format!("non-numbers on stack with {}", cur)), None => return Err("stack is empty".to_string()), }, 'i' => match (&mparams[0], &mparams[1]) { (&Number(x), &Number(y)) => { mparams[0] = Number(x+1); mparams[1] = Number(y+1); }, (_, _) => return Err("first two params not numbers with %i".to_string()) }, // printf-style support for %doxXs 'd'|'o'|'x'|'X'|'s' => if let Some(arg) = stack.pop() { let flags = Flags::new(); let res = try!(format(arg, FormatOp::from_char(cur), flags)); output.extend(res.iter().map(|x| *x)); } else { return Err("stack is empty".to_string()) }, ':'|'#'|' '|'.'|'0'...'9' => { let mut flags = Flags::new(); let mut fstate = FormatStateFlags; match cur { ':' => (), '#' => flags.alternate = true, ' ' => flags.space = true, '.' => fstate = FormatStatePrecision, '0'...'9' => { flags.width = cur as usize - '0' as usize; fstate = FormatStateWidth; } _ => unreachable!() } state = FormatPattern(flags, fstate); } // conditionals '?' => (), 't' => match stack.pop() { Some(Number(0)) => state = SeekIfElse(0), Some(Number(_)) => (), Some(_) => return Err("non-number on stack with conditional".to_string()), None => return Err("stack is empty".to_string()), }, 'e' => state = SeekIfEnd(0), ';' => (), _ => return Err(format!("unrecognized format option {}", cur)), } }, PushParam => { // params are 1-indexed stack.push(mparams[match cur.to_digit(10) { Some(d) => d as usize - 1, None => return Err("bad param number".to_string()) }].clone()); }, SetVar => { if cur >= 'A' && cur <= 'Z' { if let Some(arg) = stack.pop() { let idx = (cur as u8) - b'A'; vars.sta[idx as usize] = arg; } else { return Err("stack is empty".to_string()) } } else if cur >= 'a' && cur <= 'z' { if let Some(arg) = stack.pop() { let idx = (cur as u8) - b'a'; vars.dyn[idx as usize] = arg; } else { return Err("stack is empty".to_string()) } } else { return Err("bad variable name in %P".to_string()); } }, GetVar => { if cur >= 'A' && cur <= 'Z' { let idx = (cur as u8) - b'A'; stack.push(vars.sta[idx as usize].clone()); } else if cur >= 'a' && cur <= 'z' { let idx = (cur as u8) - b'a'; stack.push(vars.dyn[idx as usize].clone()); } else { return Err("bad variable name in %g".to_string()); } }, CharConstant => { stack.push(Number(c as i32)); state = CharClose; }, CharClose => if cur != '\'' { return Err("malformed character constant".to_string()); }, IntConstant(i) => { if cur == '}' { stack.push(Number(i)); state = Nothing; } else if let Some(digit) = cur.to_digit(10) { match i.checked_mul(10).and_then(|i_ten|i_ten.checked_add(digit as i32)) { Some(i) => { state = IntConstant(i); old_state = Nothing; } None => return Err("int constant too large".to_string()) } } else { return Err("bad int constant".to_string()); } } FormatPattern(ref mut flags, ref mut fstate) => { old_state = Nothing; match (*fstate, cur) { (_,'d')|(_,'o')|(_,'x')|(_,'X')|(_,'s') => if let Some(arg) = stack.pop() { let res = try!(format(arg, FormatOp::from_char(cur), *flags)); output.extend(res.iter().map(|x| *x)); // will cause state to go to Nothing old_state = FormatPattern(*flags, *fstate); } else { return Err("stack is empty".to_string()) }, (FormatStateFlags,'#') => { flags.alternate = true; } (FormatStateFlags,'-') => { flags.left = true; } (FormatStateFlags,'+') => { flags.sign = true; } (FormatStateFlags,' ') => { flags.space = true; } (FormatStateFlags,'0'...'9') => { flags.width = cur as usize - '0' as usize; *fstate = FormatStateWidth; } (FormatStateFlags,'.') => { *fstate = FormatStatePrecision; } (FormatStateWidth,'0'...'9') => { let old = flags.width; flags.width = flags.width * 10 + (cur as usize - '0' as usize); if flags.width < old { return Err("format width overflow".to_string()) } } (FormatStateWidth,'.') => { *fstate = FormatStatePrecision; } (FormatStatePrecision,'0'...'9') => { let old = flags.precision; flags.precision = flags.precision * 10 + (cur as usize - '0' as usize); if flags.precision < old { return Err("format precision overflow".to_string()) } } _ => return Err("invalid format specifier".to_string()) } } SeekIfElse(level) => { if cur == '%' { state = SeekIfElsePercent(level); } old_state = Nothing; } SeekIfElsePercent(level) => { if cur == ';' { if level == 0 { state = Nothing; } else { state = SeekIfElse(level-1); } } else if cur == 'e' && level == 0 { state = Nothing; } else if cur == '?' { state = SeekIfElse(level+1); } else { state = SeekIfElse(level); } } SeekIfEnd(level) => { if cur == '%' { state = SeekIfEndPercent(level); } old_state = Nothing; } SeekIfEndPercent(level) => { if cur == ';' { if level == 0 { state = Nothing; } else { state = SeekIfEnd(level-1); } } else if cur == '?' { state = SeekIfEnd(level+1); } else { state = SeekIfEnd(level); } } } if state == old_state { state = Nothing; } } Ok(output) } #[derive(Copy, PartialEq, Clone)] struct Flags { width: usize, precision: usize, alternate: bool, left: bool, sign: bool, space: bool } impl Flags { fn new() -> Flags { Flags{ width: 0, precision: 0, alternate: false, left: false, sign: false, space: false } } } #[derive(Copy, Clone)] enum FormatOp { FormatDigit, FormatOctal, FormatHex, FormatHEX, FormatString } impl FormatOp { fn from_char(c: char) -> FormatOp { match c { 'd' => FormatDigit, 'o' => FormatOctal, 'x' => FormatHex, 'X' => FormatHEX, 's' => FormatString, _ => panic!("bad FormatOp char") } } fn to_char(self) -> char { match self { FormatDigit => 'd', FormatOctal => 'o', FormatHex => 'x', FormatHEX => 'X', FormatString => 's' } } } fn format(val: Param, op: FormatOp, flags: Flags) -> Result ,String> { let mut s = match val { Number(d) => match op { FormatDigit => { if flags.sign { format!("{:+01$}", d, flags.precision) } else if d < 0 { // C doesn't take sign into account in precision calculation. format!("{:01$}", d, flags.precision + 1) } else if flags.space { format!(" {:01$}", d, flags.precision) } else { format!("{:01$}", d, flags.precision) } }, FormatOctal => { if flags.alternate { // Leading octal zero counts against precision. format!("0{:01$o}", d, flags.precision.saturating_sub(1)) } else { format!("{:01$o}", d, flags.precision) } }, FormatHex => { if flags.alternate && d != 0 { format!("0x{:01$x}", d, flags.precision) } else { format!("{:01$x}", d, flags.precision) } }, FormatHEX => { if flags.alternate && d != 0 { format!("0X{:01$X}", d, flags.precision) } else { format!("{:01$X}", d, flags.precision) } }, FormatString => return Err("non-number on stack with %s".to_string()) }.into_bytes(), Words(s) => match op { FormatString => { let mut s = s.into_bytes(); if flags.precision > 0 && flags.precision < s.len() { s.truncate(flags.precision); } s }, _ => return Err(format!("non-string on stack with %{}", op.to_char())) } }; if flags.width > s.len() { let n = flags.width - s.len(); if flags.left { s.extend(repeat(b' ').take(n)); } else { let mut s_ = Vec::with_capacity(flags.width); s_.extend(repeat(b' ').take(n)); s_.extend(s.into_iter()); s = s_; } } Ok(s) } #[cfg(test)] mod test { use super::{expand, Variables}; use super::Param::{self, Words, Number}; use std::result::Result::Ok; #[test] fn test_basic_setabf() { let s = b"\\E[48;5;%p1%dm"; assert_eq!(expand(s, &[Number(1)], &mut Variables::new()).unwrap(), "\\E[48;5;1m".bytes().collect::>()); } #[test] fn test_multiple_int_constants() { assert_eq!(expand(b"%{1}%{2}%d%d", &[], &mut Variables::new()).unwrap(), "21".bytes().collect::>()); } #[test] fn test_op_i() { let mut vars = Variables::new(); assert_eq!(expand(b"%p1%d%p2%d%p3%d%i%p1%d%p2%d%p3%d", &[Number(1),Number(2),Number(3)], &mut vars), Ok("123233".bytes().collect::>())); assert_eq!(expand(b"%p1%d%p2%d%i%p1%d%p2%d", &[], &mut vars), Ok("0011".bytes().collect::>())); } #[test] fn test_param_stack_failure_conditions() { let mut varstruct = Variables::new(); let vars = &mut varstruct; fn get_res(fmt: &str, cap: &str, params: &[Param], vars: &mut Variables) -> Result, String> { let mut u8v: Vec<_> = fmt.bytes().collect(); u8v.extend(cap.as_bytes().iter().map(|&b| b)); expand(&u8v, params, vars) } let caps = ["%d", "%c", "%s", "%Pa", "%l", "%!", "%~"]; for &cap in caps.iter() { let res = get_res("", cap, &[], vars); assert!(res.is_err(), "Op {} succeeded incorrectly with 0 stack entries", cap); let p = if cap == "%s" || cap == "%l" { Words("foo".to_string()) } else { Number(97) }; let res = get_res("%p1", cap, &[p], vars); assert!(res.is_ok(), "Op {} failed with 1 stack entry: {}", cap, res.err().unwrap()); } let caps = ["%+", "%-", "%*", "%/", "%m", "%&", "%|", "%A", "%O"]; for &cap in caps.iter() { let res = expand(cap.as_bytes(), &[], vars); assert!(res.is_err(), "Binop {} succeeded incorrectly with 0 stack entries", cap); let res = get_res("%{1}", cap, &[], vars); assert!(res.is_err(), "Binop {} succeeded incorrectly with 1 stack entry", cap); let res = get_res("%{1}%{2}", cap, &[], vars); assert!(res.is_ok(), "Binop {} failed with 2 stack entries: {}", cap, res.err().unwrap()); } } #[test] fn test_push_bad_param() { assert!(expand(b"%pa", &[], &mut Variables::new()).is_err()); } #[test] fn test_comparison_ops() { let v = [('<', [1u8, 0u8, 0u8]), ('=', [0u8, 1u8, 0u8]), ('>', [0u8, 0u8, 1u8])]; for &(op, bs) in v.iter() { let s = format!("%{{1}}%{{2}}%{}%d", op); let res = expand(s.as_bytes(), &[], &mut Variables::new()); assert!(res.is_ok(), res.err().unwrap()); assert_eq!(res.unwrap(), vec!(b'0' + bs[0])); let s = format!("%{{1}}%{{1}}%{}%d", op); let res = expand(s.as_bytes(), &[], &mut Variables::new()); assert!(res.is_ok(), res.err().unwrap()); assert_eq!(res.unwrap(), vec!(b'0' + bs[1])); let s = format!("%{{2}}%{{1}}%{}%d", op); let res = expand(s.as_bytes(), &[], &mut Variables::new()); assert!(res.is_ok(), res.err().unwrap()); assert_eq!(res.unwrap(), vec!(b'0' + bs[2])); } } #[test] fn test_conditionals() { let mut vars = Variables::new(); let s = b"\\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m"; let res = expand(s, &[Number(1)], &mut vars); assert!(res.is_ok(), res.err().unwrap()); assert_eq!(res.unwrap(), "\\E[31m".bytes().collect::>()); let res = expand(s, &[Number(8)], &mut vars); assert!(res.is_ok(), res.err().unwrap()); assert_eq!(res.unwrap(), "\\E[90m".bytes().collect::>()); let res = expand(s, &[Number(42)], &mut vars); assert!(res.is_ok(), res.err().unwrap()); assert_eq!(res.unwrap(), "\\E[38;5;42m".bytes().collect::>()); } #[test] fn test_format() { let mut varstruct = Variables::new(); let vars = &mut varstruct; assert_eq!(expand(b"%p1%s%p2%2s%p3%2s%p4%.2s", &[Words("foo".to_string()), Words("foo".to_string()), Words("f".to_string()), Words("foo".to_string())], vars), Ok("foofoo ffo".bytes().collect::>())); assert_eq!(expand(b"%p1%:-4.2s", &[Words("foo".to_string())], vars), Ok("fo ".bytes().collect::>())); assert_eq!(expand(b"%p1%d%p1%.3d%p1%5d%p1%:+d", &[Number(1)], vars), Ok("1001 1+1".bytes().collect::>())); assert_eq!(expand(b"%p1%o%p1%#o%p2%6.4x%p2%#6.4X", &[Number(15), Number(27)], vars), Ok("17017 001b0X001B".bytes().collect::>())); } } deps/term-0.2.14/scripts/0000755000000000000000000000000012666635520013700 5ustar rootrootdeps/term-0.2.14/scripts/id_rsa.enc0000600000175000001440000000322012616414511015103 0ustar users'(sTHDB9xX=ZCkK<8?73x*~aI7 ~? 0#k`*zv(̓~aؿ$TJQ-RUrރl1Aٮ#uv4&Qԉ%) v:rƁ<7k b:JUH=!(}\O;w(FB/"^#S-N#֡gӈl5 9AsȤAQ$_g>~6HS}h}q lD2I7T fz# ԈИl~&-%Wdi~]lxO2eVeG] qƕ}9̔*jl0Y 6 Z_~\9MShibF 4R@&ufq6Rv0i& Vٿ.`S*aVqAs'Yua7\fȦ lx9F3GϦmwY0ek=" {1 Y xo¹X>_qߘVp(f` cCmpưI|qv}=dΆx[dϨݟX& u!YB_^Ye"Zm}\Ijk{k0sژuòyOw J?OKd1u-ʴePlY2^@5u> )31m&Yڂ*ݗ ČQ% ̉^5ơ45J$VUk̓:*'a*4':Mq3_PQ$/i:'w>C?3Cg=]gQ0R<Zvz^z꿾qi >@H{hOU'`h|E9k (1qg EJC'2IoP݊ #k?L$:{Q18k6Kmd8A!(ԁK54- b{PLes5/75Ez6c2!GUᖰpx3uy&wd/G.ȂJL&o)m-4is-w%Ԟwլ/BGg\ArFwqA)yo w !$גtf5W()1r vOO+^6Z{A3W|\deps/term-0.2.14/scripts/travis-doc-upload.cfg0000600000175000001440000000011512616414511017171 0ustar usersPROJECT_NAME=term DOCS_REPO=Stebalien/doc.git SSH_KEY_TRAVIS_ID=b92a405b42db deps/term-0.2.14/appveyor.yml0000600000175000001440000000073612616414511014065 0ustar usersenvironment: matrix: - TARGET: x86_64-pc-windows-msvc - TARGET: i686-pc-windows-msvc - TARGET: i686-pc-windows-gnu install: - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin - SET PATH=%PATH%;C:\MinGW\bin - rustc -V - cargo -V build: false test_script: - cargo test --verbose deps/term-0.2.14/Cargo.toml0000600000175000001440000000063312624757010013424 0ustar users[package] name = "term" version = "0.2.14" authors = ["The Rust Project Developers", "Steven Allen"] license = "MIT/Apache-2.0" readme = "README.md" repository = "https://github.com/Stebalien/term" homepage = "https://github.com/Stebalien/term" documentation = "https://stebalien.github.io/doc/term/term/" description = """ A terminal formatting library """ [dependencies] winapi = "0.2" kernel32-sys = "0.2" deps/cmake-0.1.12/0000755000000000000000000000000012666635520012317 5ustar rootrootdeps/cmake-0.1.12/LICENSE-APACHE0000664000175000017500000002513712556776060012502 0ustar Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/cmake-0.1.12/LICENSE-MIT0000664000175000017500000000204112556776060012177 0ustar Copyright (c) 2014 Alex Crichton Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/cmake-0.1.12/.travis.yml0000664000175000017500000000101012556776221012646 0ustar language: rust rust: - 1.0.0 - beta - nightly sudo: false before_script: - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH script: - cargo test --verbose - cargo doc --no-deps after_success: - travis-cargo --only nightly doc-upload env: global: secure: WSQJRyheeMf7eRdivHextSEQzyFnTIw2yeemO2+ZkHVftp0XYsTXQVca3RGlQNsVmjI0RP8lbDVe7HG23uwbTMeRgm+9hzSwNMa0ndJZ06TNMpPM6nqcXFUaNGeuf7EqU370xcgVBO+ZA0cSh55pJkOBg5ALd9bfRWbjEAjHkx8= notifications: email: on_success: never deps/cmake-0.1.12/README.md0000664000175000017500000000105712556776136012034 0ustar # cmake [![Build Status](https://travis-ci.org/alexcrichton/cmake-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/cmake-rs) [Documentation](http://alexcrichton.com/cmake-rs) A build dependency for running the `cmake` build tool to compile a native library. ```toml # Cargo.toml [build-dependencies] cmake = "0.2" ``` # License `cmake-rs` is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses. See LICENSE-APACHE, and LICENSE-MIT for details. deps/cmake-0.1.12/.gitignore0000600000175000017500000000002412425261063012503 0ustar /target /Cargo.lock deps/cmake-0.1.12/src/0000755000000000000000000000000012666635520013106 5ustar rootrootdeps/cmake-0.1.12/src/lib.rs0000664000175000017500000003600712635042243012442 0ustar //! A build dependency for running `cmake` to build a native library //! //! This crate provides some necessary boilerplate and shim support for running //! the system `cmake` command to build a native library. It will add //! appropriate cflags for building code to link into Rust, handle cross //! compilation, and use the necessary generator for the platform being //! targeted. //! //! The builder-style configuration allows for various variables and such to be //! passed down into the build as well. //! //! ## Installation //! //! Add this to your `Cargo.toml`: //! //! ```toml //! [build-dependencies] //! cmake = "0.1" //! ``` //! //! ## Examples //! //! ```no_run //! use cmake; //! //! // Builds the project in the directory located in `libfoo`, installing it //! // into $OUT_DIR //! let dst = cmake::build("libfoo"); //! //! println!("cargo:rustc-link-search=native={}", dst.display()); //! println!("cargo:rustc-link-lib=static=foo"); //! ``` //! //! ```no_run //! use cmake::Config; //! //! let dst = Config::new("libfoo") //! .define("FOO", "BAR") //! .cflag("-foo") //! .build(); //! println!("cargo:rustc-link-search=native={}", dst.display()); //! println!("cargo:rustc-link-lib=static=foo"); //! ``` #![deny(missing_docs)] extern crate gcc; use std::env; use std::ffi::{OsString, OsStr}; use std::fs::{self, File}; use std::io::ErrorKind; use std::io::prelude::*; use std::path::{Path, PathBuf}; use std::process::Command; /// Builder style configuration for a pending CMake build. pub struct Config { path: PathBuf, cflags: OsString, defines: Vec<(OsString, OsString)>, deps: Vec, target: Option, host: Option, out_dir: Option, profile: Option, build_args: Vec, cmake_target: Option, } /// Builds the native library rooted at `path` with the default cmake options. /// This will return the directory in which the library was installed. /// /// # Examples /// /// ```no_run /// use cmake; /// /// // Builds the project in the directory located in `libfoo`, installing it /// // into $OUT_DIR /// let dst = cmake::build("libfoo"); /// /// println!("cargo:rustc-link-search=native={}", dst.display()); /// println!("cargo:rustc-link-lib=static=foo"); /// ``` /// pub fn build>(path: P) -> PathBuf { Config::new(path.as_ref()).build() } impl Config { /// Creates a new blank set of configuration to build the project specified /// at the path `path`. pub fn new>(path: P) -> Config { Config { path: env::current_dir().unwrap().join(path), cflags: OsString::new(), defines: Vec::new(), deps: Vec::new(), profile: None, out_dir: None, target: None, host: None, build_args: Vec::new(), cmake_target: None, } } /// Adds a custom flag to pass down to the compiler, supplementing those /// that this library already passes. pub fn cflag>(&mut self, flag: P) -> &mut Config { self.cflags.push(" "); self.cflags.push(flag.as_ref()); self } /// Adds a new `-D` flag to pass to cmake during the generation step. pub fn define(&mut self, k: K, v: V) -> &mut Config where K: AsRef, V: AsRef { self.defines.push((k.as_ref().to_owned(), v.as_ref().to_owned())); self } /// Registers a dependency for this compilation on the native library built /// by Cargo previously. /// /// This registration will modify the `CMAKE_PREFIX_PATH` environment /// variable for the build system generation step. pub fn register_dep(&mut self, dep: &str) -> &mut Config { self.deps.push(dep.to_string()); self } /// Sets the target triple for this compilation. /// /// This is automatically scraped from `$TARGET` which is set for Cargo /// build scripts so it's not necessary to call this from a build script. pub fn target(&mut self, target: &str) -> &mut Config { self.target = Some(target.to_string()); self } /// Sets the host triple for this compilation. /// /// This is automatically scraped from `$HOST` which is set for Cargo /// build scripts so it's not necessary to call this from a build script. pub fn host(&mut self, host: &str) -> &mut Config { self.host = Some(host.to_string()); self } /// Sets the output directory for this compilation. /// /// This is automatically scraped from `$OUT_DIR` which is set for Cargo /// build scripts so it's not necessary to call this from a build script. pub fn out_dir>(&mut self, out: P) -> &mut Config { self.out_dir = Some(out.as_ref().to_path_buf()); self } /// Sets the profile for this compilation. /// /// This is automatically scraped from `$PROFILE` which is set for Cargo /// build scripts so it's not necessary to call this from a build script. pub fn profile(&mut self, profile: &str) -> &mut Config { self.profile = Some(profile.to_string()); self } /// Add an argument to the final `cmake` build step pub fn build_arg>(&mut self, arg: A) -> &mut Config { self.build_args.push(arg.as_ref().to_owned()); self } /// Sets the build target for the final `cmake` build step, this will /// default to "install" if not specified. pub fn build_target(&mut self, target: &str) -> &mut Config { self.cmake_target = Some(target.to_string()); self } /// Run this configuration, compiling the library with all the configured /// options. /// /// This will run both the build system generator command as well as the /// command to build the library. pub fn build(&mut self) -> PathBuf { let target = self.target.clone().unwrap_or_else(|| { getenv_unwrap("TARGET") }); let host = self.host.clone().unwrap_or_else(|| { getenv_unwrap("HOST") }); let msvc = target.contains("msvc"); let c_compiler = gcc::Config::new().cargo_metadata(false) .opt_level(0) .debug(false) .target(&target) .host(&host) .get_compiler(); let cxx_compiler = gcc::Config::new().cargo_metadata(false) .cpp(true) .opt_level(0) .debug(false) .target(&target) .host(&host) .get_compiler(); let dst = self.out_dir.clone().unwrap_or_else(|| { PathBuf::from(getenv_unwrap("OUT_DIR")) }); let build = dst.join("build"); self.maybe_clear(&build); let _ = fs::create_dir(&build); // Add all our dependencies to our cmake paths let mut cmake_prefix_path = Vec::new(); for dep in &self.deps { if let Some(root) = env::var_os(&format!("DEP_{}_ROOT", dep)) { cmake_prefix_path.push(PathBuf::from(root)); } } let system_prefix = env::var_os("CMAKE_PREFIX_PATH") .unwrap_or(OsString::new()); cmake_prefix_path.extend(env::split_paths(&system_prefix) .map(|s| s.to_owned())); let cmake_prefix_path = env::join_paths(&cmake_prefix_path).unwrap(); // Build up the first cmake command to build the build system. let mut cmd = Command::new("cmake"); cmd.arg(&self.path) .current_dir(&build); if target.contains("windows-gnu") { // On MinGW we need to coerce cmake to not generate a visual studio // build system but instead use makefiles that MinGW can use to // build. cmd.arg("-G").arg("MSYS Makefiles"); } else if msvc { // If we're on MSVC we need to be sure to use the right generator or // otherwise we won't get 32/64 bit correct automatically. cmd.arg("-G").arg(self.visual_studio_generator(&target)); } let profile = self.profile.clone().unwrap_or_else(|| { match &getenv_unwrap("PROFILE")[..] { "bench" | "release" => "Release", // currently we need to always use the same CRT for MSVC _ if msvc => "Release", _ => "Debug", }.to_string() }); for &(ref k, ref v) in &self.defines { let mut os = OsString::from("-D"); os.push(k); os.push("="); os.push(v); cmd.arg(os); } if !self.defined("CMAKE_INSTALL_PREFIX") { let mut dstflag = OsString::from("-DCMAKE_INSTALL_PREFIX="); dstflag.push(&dst); cmd.arg(dstflag); } { let mut set_compiler = |kind: &str, compiler: &gcc::Tool, extra: &OsString| { let flag_var = format!("CMAKE_{}_FLAGS", kind); let tool_var = format!("CMAKE_{}_COMPILER", kind); if !self.defined(&flag_var) { let mut flagsflag = OsString::from("-D"); flagsflag.push(&flag_var); flagsflag.push("="); flagsflag.push(extra); for arg in compiler.args() { flagsflag.push(" "); flagsflag.push(arg); } cmd.arg(flagsflag); } // Apparently cmake likes to have an absolute path to the // compiler as otherwise it sometimes thinks that this variable // changed as it thinks the found compiler, /usr/bin/cc, // differs from the specified compiler, cc. Not entirely sure // what's up, but at least this means cmake doesn't get // confused? // // Also don't specify this on Windows as it's not needed for // MSVC and for MinGW it doesn't really vary. if !self.defined(&tool_var) && env::consts::FAMILY != "windows" { let mut ccompiler = OsString::from("-D"); ccompiler.push(&tool_var); ccompiler.push("="); ccompiler.push(find_exe(compiler.path())); cmd.arg(ccompiler); } }; set_compiler("C", &c_compiler, &self.cflags); set_compiler("CXX", &cxx_compiler, &OsString::new()); } if !self.defined("CMAKE_BUILD_TYPE") { cmd.arg(&format!("-DCMAKE_BUILD_TYPE={}", profile)); } run(cmd.env("CMAKE_PREFIX_PATH", cmake_prefix_path), "cmake"); let mut parallel_args = Vec::new(); if fs::metadata(&dst.join("build/Makefile")).is_ok() { if let Ok(s) = env::var("NUM_JOBS") { parallel_args.push(format!("-j{}", s)); } } // And build! let target = self.cmake_target.clone().unwrap_or("install".to_string()); run(Command::new("cmake") .arg("--build").arg(".") .arg("--target").arg(target) .arg("--config").arg(profile) .arg("--").args(&self.build_args) .args(¶llel_args) .current_dir(&build), "cmake"); println!("cargo:root={}", dst.display()); return dst } fn visual_studio_generator(&self, target: &str) -> String { // TODO: need a better way of scraping the VS install... let candidate = format!("{:?}", gcc::windows_registry::find(target, "cl.exe")); let base = if candidate.contains("12.0") { "Visual Studio 12 2013" } else if candidate.contains("14.0") { "Visual Studio 14 2015" } else { panic!("couldn't determine visual studio generator") }; if target.contains("i686") { base.to_string() } else if target.contains("x86_64") { format!("{} Win64", base) } else { panic!("unsupported msvc target: {}", target); } } fn defined(&self, var: &str) -> bool { self.defines.iter().any(|&(ref a, _)| a == var) } // If a cmake project has previously been built (e.g. CMakeCache.txt already // exists), then cmake will choke if the source directory for the original // project being built has changed. Detect this situation through the // `CMAKE_HOME_DIRECTORY` variable that cmake emits and if it doesn't match // we blow away the build directory and start from scratch (the recommended // solution apparently [1]). // // [1]: https://cmake.org/pipermail/cmake/2012-August/051545.html fn maybe_clear(&self, dir: &Path) { let src = match self.path.to_str() { Some(src) => src, None => return, }; let mut f = match File::open(dir.join("CMakeCache.txt")) { Ok(f) => f, Err(..) => return, }; let mut u8contents = Vec::new(); match f.read_to_end(&mut u8contents) { Ok(f) => f, Err(..) => return, }; let contents = String::from_utf8_lossy(&u8contents); drop(f); for line in contents.lines() { if line.contains("CMAKE_HOME_DIRECTORY") && !line.contains(src) { println!("detected home dir change, cleaning out entire build \ directory"); fs::remove_dir_all(dir).unwrap(); break } } } } fn run(cmd: &mut Command, program: &str) { println!("running: {:?}", cmd); let status = match cmd.status() { Ok(status) => status, Err(ref e) if e.kind() == ErrorKind::NotFound => { fail(&format!("failed to execute command: {}\nis `{}` not installed?", e, program)); } Err(e) => fail(&format!("failed to execute command: {}", e)), }; if !status.success() { fail(&format!("command did not execute successfully, got: {}", status)); } } fn find_exe(path: &Path) -> PathBuf { env::split_paths(&env::var_os("PATH").unwrap_or(OsString::new())) .map(|p| p.join(path)) .find(|p| fs::metadata(p).is_ok()) .unwrap_or(path.to_owned()) } fn getenv_unwrap(v: &str) -> String { match env::var(v) { Ok(s) => s, Err(..) => fail(&format!("environment variable `{}` not defined", v)), } } fn fail(s: &str) -> ! { panic!("\n{}\n\nbuild script failed, must exit now", s) } deps/cmake-0.1.12/Cargo.toml0000600000175000017500000000071212635042677012462 0ustar [package] name = "cmake" version = "0.1.12" authors = ["Alex Crichton "] license = "MIT/Apache-2.0" readme = "README.md" keywords = ["build-dependencies"] repository = "https://github.com/alexcrichton/cmake-rs" homepage = "https://github.com/alexcrichton/cmake-rs" documentation = "http://alexcrichton.com/cmake-rs" description = """ A build dependency for running `cmake` to build a native library """ [dependencies] gcc = "0.3.17" deps/regex-syntax-0.2.2/0000755000000000000000000000000012666635520013615 5ustar rootrootdeps/regex-syntax-0.2.2/src/0000755000000000000000000000000012666635520014404 5ustar rootrootdeps/regex-syntax-0.2.2/src/parser.rs0000644000175000001440000021255412574165524015557 0ustar users// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::cmp::{max, min}; use unicode::regex::UNICODE_CLASSES; use { Expr, Repeater, CharClass, ClassRange, CaptureIndex, CaptureName, Error, ErrorKind, Result, }; /// Parser state. /// /// Keeps the entire input in memory and maintains a cursor (char offset). /// /// It also keeps an expression stack, which is responsible for managing /// grouped expressions and flag state. #[derive(Debug)] pub struct Parser { chars: Vec, chari: usize, stack: Vec, caps: usize, names: Vec, // to check for duplicates flags: Flags, } /// An empheral type for representing the expression stack. /// /// Everything on the stack is either a regular expression or a marker /// indicating the opening of a group (possibly non-capturing). The opening /// of a group copies the current flag state, which is reset on the parser /// state once the group closes. #[derive(Debug)] enum Build { Expr(Expr), LeftParen { i: CaptureIndex, name: CaptureName, chari: usize, old_flags: Flags, }, } /// Flag state. #[derive(Clone, Copy, Debug)] struct Flags { casei: bool, multi: bool, dotnl: bool, swap_greed: bool, ignore_space: bool, } // Primary expression parsing routines. impl Parser { pub fn parse(s: &str) -> Result { Parser { chars: s.chars().collect(), chari: 0, stack: vec![], caps: 0, names: vec![], flags: Flags { casei: false, multi: false, dotnl: false, swap_greed: false, ignore_space: false, }, }.parse_expr() } // Top-level expression parser. // // Starts at the beginning of the input and consumes until either the end // of input or an error. fn parse_expr(mut self) -> Result { while !self.eof() { let build_expr = match self.cur() { '\\' => try!(self.parse_escape()), '|' => { let e = try!(self.alternate()); self.bump(); e } '?' => try!(self.parse_simple_repeat(Repeater::ZeroOrOne)), '*' => try!(self.parse_simple_repeat(Repeater::ZeroOrMore)), '+' => try!(self.parse_simple_repeat(Repeater::OneOrMore)), '{' => try!(self.parse_counted_repeat()), '[' => match self.maybe_parse_ascii() { None => try!(self.parse_class()), Some(cls) => Build::Expr(Expr::Class(cls)), }, '^' => { if self.flags.multi { self.parse_one(Expr::StartLine) } else { self.parse_one(Expr::StartText) } } '$' => { if self.flags.multi { self.parse_one(Expr::EndLine) } else { self.parse_one(Expr::EndText) } } '.' => { if self.flags.dotnl { self.parse_one(Expr::AnyChar) } else { self.parse_one(Expr::AnyCharNoNL) } } '(' => try!(self.parse_group()), ')' => { let (old_flags, e) = try!(self.close_paren()); self.bump(); self.flags = old_flags; e } _ => Build::Expr(Expr::Literal { chars: vec![self.bump()], casei: self.flags.casei, }), }; if !build_expr.is_empty() { self.stack.push(build_expr); } } self.finish_concat() } // Parses an escape sequence, e.g., \Ax // // Start: `\` // End: `x` fn parse_escape(&mut self) -> Result { self.bump(); if self.eof() { return Err(self.err(ErrorKind::UnexpectedEscapeEof)); } let c = self.cur(); if is_punct(c) { return Ok(Build::Expr(Expr::Literal { chars: vec![self.bump()], casei: self.flags.casei, })); } fn lit(c: char) -> Build { Build::Expr(Expr::Literal { chars: vec![c], casei: false }) } match c { 'a' => { self.bump(); Ok(lit('\x07')) } 'f' => { self.bump(); Ok(lit('\x0C')) } 't' => { self.bump(); Ok(lit('\t')) } 'n' => { self.bump(); Ok(lit('\n')) } 'r' => { self.bump(); Ok(lit('\r')) } 'v' => { self.bump(); Ok(lit('\x0B')) } 'A' => { self.bump(); Ok(Build::Expr(Expr::StartText)) } 'z' => { self.bump(); Ok(Build::Expr(Expr::EndText)) } 'b' => { self.bump(); Ok(Build::Expr(Expr::WordBoundary)) } 'B' => { self.bump(); Ok(Build::Expr(Expr::NotWordBoundary)) } '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7' => self.parse_octal(), 'x' => { self.bump(); self.parse_hex() } 'p'|'P' => { self.bump(); self.parse_unicode_class(c == 'P') .map(|cls| Build::Expr(Expr::Class(cls))) } 'd'|'s'|'w'|'D'|'S'|'W' => { self.bump(); Ok(Build::Expr(Expr::Class(self.parse_perl_class(c)))) } c => Err(self.err(ErrorKind::UnrecognizedEscape(c))), } } // Parses a group, e.g., `(abc)`. // // Start: `(` // End: `a` // // A more interesting example, `(?Pabc)`. // // Start: `(` // End: `a` fn parse_group(&mut self) -> Result { let chari = self.chari; let mut name: CaptureName = None; self.bump(); if self.bump_if("?P<") { let n = try!(self.parse_group_name()); if self.names.iter().any(|n2| n2 == &n) { return Err(self.err(ErrorKind::DuplicateCaptureName(n))); } self.names.push(n.clone()); name = Some(n); } else if self.bump_if("?") { // This can never be capturing. It's either setting flags for // the current group, or it's opening a non-capturing group or // it's opening a group with a specific set of flags (which is // also non-capturing). // Anything else is an error. return self.parse_group_flags(chari); } self.caps = checkadd(self.caps, 1); Ok(Build::LeftParen { i: Some(self.caps), name: name, chari: chari, old_flags: self.flags, // no flags changed if we're here }) } // Parses flags (inline or grouped), e.g., `(?s-i:abc)`. // // Start: `s` // End: `a` // // Another example, `(?s-i)a`. // // Start: `s` // End: `a` fn parse_group_flags(&mut self, opening_chari: usize) -> Result { let old_flags = self.flags; let mut sign = true; let mut saw_flag = false; loop { if self.eof() { // e.g., (?i return Err(self.err(ErrorKind::UnexpectedFlagEof)); } match self.cur() { 'i' => { self.flags.casei = sign; saw_flag = true } 'm' => { self.flags.multi = sign; saw_flag = true } 's' => { self.flags.dotnl = sign; saw_flag = true } 'U' => { self.flags.swap_greed = sign; saw_flag = true } 'x' => { self.flags.ignore_space = sign; saw_flag = true } '-' => { if !sign { // e.g., (?-i-s) return Err(self.err(ErrorKind::DoubleFlagNegation)); } sign = false; saw_flag = false; } ')' => { if !saw_flag { // e.g., (?) return Err(self.err(ErrorKind::EmptyFlagNegation)); } // At this point, we're just changing the flags inside // the current group, which means the old flags have // been saved elsewhere. Our modifications in place are // okey dokey! // // This particular flag expression only has a stateful // impact on a regex's AST, so nothing gets explicitly // added. self.bump(); return Ok(Build::Expr(Expr::Empty)); } ':' => { if !sign && !saw_flag { // e.g., (?i-:a) // Note that if there's no negation, it's OK not // to see flag, because you end up with a regular // non-capturing group: `(?:a)`. return Err(self.err(ErrorKind::EmptyFlagNegation)); } self.bump(); return Ok(Build::LeftParen { i: None, name: None, chari: opening_chari, old_flags: old_flags, }); } // e.g., (?z:a) c => return Err(self.err(ErrorKind::UnrecognizedFlag(c))), } self.bump(); } } // Parses a group name, e.g., `foo` in `(?Pabc)`. // // Start: `f` // End: `a` fn parse_group_name(&mut self) -> Result { let mut name = String::new(); while !self.eof() && !self.peek_is('>') { name.push(self.bump()); } if self.eof() { // e.g., (?Pa) None => Err(self.err(ErrorKind::EmptyCaptureName)), Some(c) if (c >= '0' && c <= '9') || !all_valid => { // e.g., (?Px) // e.g., (?P<1a>x) Err(self.err(ErrorKind::InvalidCaptureName(name))) } _ => { self.bump(); // for `>` Ok(name) } } } // Parses a counted repeition operator, e.g., `a{2,4}?z`. // // Start: `{` // End: `z` fn parse_counted_repeat(&mut self) -> Result { let e = try!(self.pop(ErrorKind::RepeaterExpectsExpr)); // e.g., ({5} if !e.can_repeat() { // e.g., a*{5} return Err(self.err(ErrorKind::RepeaterUnexpectedExpr(e))); } self.bump(); let min = try!(self.parse_decimal(|c| c != ',' && c != '}')); let mut max_opt = Some(min); if self.bump_if(',') { if self.peek_is('}') { max_opt = None; } else { let max = try!(self.parse_decimal(|c| c != '}')); if min > max { // e.g., a{2,1} return Err(self.err(ErrorKind::InvalidRepeatRange { min: min, max: max, })); } max_opt = Some(max); } } if !self.bump_if('}') { Err(self.err(ErrorKind::UnclosedRepeat)) } else { Ok(Build::Expr(Expr::Repeat { e: Box::new(e), r: Repeater::Range { min: min, max: max_opt }, greedy: !self.bump_if('?') ^ self.flags.swap_greed, })) } } // Parses a simple repetition operator, e.g., `a+?z`. // // Start: `+` // End: `z` // // N.B. "simple" in this context means "not min/max repetition", // e.g., `a{1,2}`. fn parse_simple_repeat(&mut self, rep: Repeater) -> Result { let e = try!(self.pop(ErrorKind::RepeaterExpectsExpr)); // e.g., (* if !e.can_repeat() { // e.g., a** return Err(self.err(ErrorKind::RepeaterUnexpectedExpr(e))); } self.bump(); Ok(Build::Expr(Expr::Repeat { e: Box::new(e), r: rep, greedy: !self.bump_if('?') ^ self.flags.swap_greed, })) } // Parses a decimal number until the given character, e.g., `a{123,456}`. // // Start: `1` // End: `,` (where `until == ','`) fn parse_decimal(&mut self, until: B) -> Result { match self.bump_get(until) { // e.g., a{} None => Err(self.err(ErrorKind::MissingBase10)), Some(n) => { // e.g., a{xyz // e.g., a{9999999999} let n = n.trim(); u32::from_str_radix(n, 10) .map_err(|_| self.err(ErrorKind::InvalidBase10(n.into()))) } } } // Parses an octal number, up to 3 digits, e.g., `a\123b` // // Start: `1` // End: `b` fn parse_octal(&mut self) -> Result { use std::char; let mut i = 0; // counter for limiting octal to 3 digits. let n = self.bump_get(|c| { i += 1; i <= 3 && c >= '0' && c <= '7' }) .expect("octal string"); // guaranteed at least 1 digit // I think both of the following unwraps are impossible to fail. // We limit it to a three digit octal number, which maxes out at // `0777` or `511` in decimal. Since all digits are in `0...7`, we'll // always have a valid `u32` number. Moreover, since all numbers in // the range `0...511` are valid Unicode scalar values, it will always // be a valid `char`. // // Hence, we `unwrap` with reckless abandon. let n = u32::from_str_radix(&n, 8).ok().expect("valid octal number"); Ok(Build::Expr(Expr::Literal { chars: vec![char::from_u32(n).expect("Unicode scalar value")], casei: self.flags.casei, })) } // Parses a hex number, e.g., `a\x5ab`. // // Start: `5` // End: `b` // // And also, `a\x{2603}b`. // // Start: `{` // End: `b` fn parse_hex(&mut self) -> Result { if self.bump_if('{') { self.parse_hex_many_digits() } else { self.parse_hex_two_digits() } } // Parses a many-digit hex number, e.g., `a\x{2603}b`. // // Start: `2` // End: `b` fn parse_hex_many_digits(&mut self) -> Result { use std::char; let s = self.bump_get(|c| c != '}').unwrap_or("".into()); let n = try!(u32::from_str_radix(&s, 16) .map_err(|_| self.err(ErrorKind::InvalidBase16(s)))); let c = try!(char::from_u32(n) .ok_or(self.err(ErrorKind::InvalidScalarValue(n)))); if !self.bump_if('}') { // e.g., a\x{d return Err(self.err(ErrorKind::UnclosedHex)); } Ok(Build::Expr(Expr::Literal { chars: vec![c], casei: self.flags.casei, })) } // Parses a two-digit hex number, e.g., `a\x5ab`. // // Start: `5` // End: `b` fn parse_hex_two_digits(&mut self) -> Result { use std::char; let mut i = 0; let s = self.bump_get(|_| { i += 1; i <= 2 }).unwrap_or("".into()); if s.len() < 2 { // e.g., a\x // e.g., a\xf return Err(self.err(ErrorKind::UnexpectedTwoDigitHexEof)); } let n = try!(u32::from_str_radix(&s, 16) .map_err(|_| self.err(ErrorKind::InvalidBase16(s)))); Ok(Build::Expr(Expr::Literal { // Because 0...255 are all valid Unicode scalar values. chars: vec![char::from_u32(n).expect("Unicode scalar value")], casei: self.flags.casei, })) } // Parses a character class, e.g., `[^a-zA-Z0-9]+`. // // Start: `[` // End: `+` fn parse_class(&mut self) -> Result { self.bump(); let negated = self.bump_if('^'); let mut class = CharClass::empty(); while self.bump_if('-') { class.ranges.push(ClassRange::one('-')); } loop { if self.eof() { // e.g., [a return Err(self.err(ErrorKind::UnexpectedClassEof)); } match self.cur() { // If no ranges have been added, then `]` is the first // character (sans, perhaps, the `^` symbol), so it should // be interpreted as a `]` instead of a closing class bracket. ']' if class.len() > 0 => { self.bump(); break } '[' => match self.maybe_parse_ascii() { Some(class2) => class.ranges.extend(class2), None => { self.bump(); try!(self.parse_class_range(&mut class, '[')) } }, '\\' => match try!(self.parse_escape()) { Build::Expr(Expr::Class(class2)) => { class.ranges.extend(class2); } Build::Expr(Expr::Literal { chars, .. }) => { try!(self.parse_class_range(&mut class, chars[0])); } Build::Expr(e) => { let err = ErrorKind::InvalidClassEscape(e); return Err(self.err(err)); } // Because `parse_escape` can never return `LeftParen`. _ => unreachable!(), }, start => { self.bump(); try!(self.parse_class_range(&mut class, start)); } } } class = self.class_transform(negated, class).canonicalize(); Ok(Build::Expr(Expr::Class(class))) } // Parses a single range in a character class. // // Since this is a helper for `parse_class`, its signature sticks out. // Namely, it requires the start character of the range and the char // class to mutate. // // e.g., `[a-z]` // // Start: `-` (with start == `a`) // End: `]` fn parse_class_range(&mut self, class: &mut CharClass, start: char) -> Result<()> { if !self.bump_if('-') { // Not a range, so just push a singleton range. class.ranges.push(ClassRange::one(start)); return Ok(()); } if self.eof() { // e.g., [a- return Err(self.err(ErrorKind::UnexpectedClassEof)); } if self.peek_is(']') { // This is the end of the class, so we permit use of `-` as a // regular char (just like we do in the beginning). class.ranges.push(ClassRange::one(start)); class.ranges.push(ClassRange::one('-')); return Ok(()); } // We have a real range. Just need to check to parse literal and // make sure it's a valid range. let end = match self.cur() { '\\' => match try!(self.parse_escape()) { Build::Expr(Expr::Literal { chars, .. }) => chars[0], Build::Expr(e) => { return Err(self.err(ErrorKind::InvalidClassEscape(e))); } // Because `parse_escape` can never return `LeftParen`. _ => unreachable!(), }, _ => self.bump(), }; if end < start { // e.g., [z-a] return Err(self.err(ErrorKind::InvalidClassRange { start: start, end: end, })); } class.ranges.push(ClassRange::new(start, end)); Ok(()) } // Parses an ASCII class, e.g., `[:alnum:]+`. // // Start: `[` // End: `+` // // Also supports negation, e.g., `[:^alnum:]`. // // This parsing routine is distinct from the others in that it doesn't // actually report any errors. Namely, if it fails, then the parser should // fall back to parsing a regular class. // // This method will only make progress in the parser if it succeeds. // Otherwise, the input remains where it started. fn maybe_parse_ascii(&mut self) -> Option { fn parse(p: &mut Parser) -> Option { p.bump(); // the `[` if !p.bump_if(':') { return None; } let negate = p.bump_if('^'); let name = match p.bump_get(|c| c != ':') { None => return None, Some(name) => name, }; if !p.bump_if(":]") { return None; } ascii_class(&name).map(|cls| p.class_transform(negate, cls)) } let start = self.chari; match parse(self) { None => { self.chari = start; None } result => result, } } // Parses a Uncode class name, e.g., `a\pLb`. // // Start: `L` // End: `b` // // And also, `a\p{Greek}b`. // // Start: `{` // End: `b` // // `negate` is true when the class name is used with `\P`. fn parse_unicode_class(&mut self, neg: bool) -> Result { let name = if self.bump_if('{') { let n = self.bump_get(|c| c != '}').unwrap_or("".into()); if n.is_empty() || !self.bump_if('}') { // e.g., \p{Greek return Err(self.err(ErrorKind::UnclosedUnicodeName)); } n } else { if self.eof() { // e.g., \p return Err(self.err(ErrorKind::UnexpectedEscapeEof)); } self.bump().to_string() }; match unicode_class(&name) { None => Err(self.err(ErrorKind::UnrecognizedUnicodeClass(name))), Some(cls) => Ok(self.class_transform(neg, cls)), } } // Parses a perl character class with Unicode support. // // `name` must be one of d, s, w, D, S, W. If not, this function panics. // // No parser state is changed. fn parse_perl_class(&mut self, name: char) -> CharClass { use unicode::regex::{PERLD, PERLS, PERLW}; let (cls, negate) = match name { 'd' | 'D' => (raw_class_to_expr(PERLD), name == 'D'), 's' | 'S' => (raw_class_to_expr(PERLS), name == 'S'), 'w' | 'W' => (raw_class_to_expr(PERLW), name == 'W'), _ => unreachable!(), }; self.class_transform(negate, cls) } // Always bump to the next input and return the given expression as a // `Build`. // // This is mostly for convenience when the surrounding context implies // that the next character corresponds to the given expression. fn parse_one(&mut self, e: Expr) -> Build { self.bump(); Build::Expr(e) } } // Auxiliary helper methods. impl Parser { fn chars(&self) -> Chars { Chars::new(&self.chars[self.chari..], self.flags.ignore_space) } fn bump(&mut self) -> char { let c = self.cur(); self.chari = checkadd(self.chari, self.chars().next_count()); c } fn cur(&self) -> char { self.chars().next().unwrap() } fn eof(&self) -> bool { self.chars().next().is_none() } fn bump_get(&mut self, s: B) -> Option { let n = s.match_end(self); if n == 0 { None } else { let end = checkadd(self.chari, n); let s = self.chars[self.chari..end] .iter().cloned().collect::(); self.chari = end; Some(s) } } fn bump_if(&mut self, s: B) -> bool { let n = s.match_end(self); if n == 0 { false } else { self.chari = checkadd(self.chari, n); true } } fn peek_is(&self, s: B) -> bool { s.match_end(self) > 0 } fn err(&self, kind: ErrorKind) -> Error { self.errat(self.chari, kind) } fn errat(&self, pos: usize, kind: ErrorKind) -> Error { Error { pos: pos, surround: self.windowat(pos), kind: kind } } fn windowat(&self, pos: usize) -> String { let s = max(5, pos) - 5; let e = min(self.chars.len(), checkadd(pos, 5)); self.chars[s..e].iter().cloned().collect() } fn pop(&mut self, expected: ErrorKind) -> Result { match self.stack.pop() { None | Some(Build::LeftParen{..}) => Err(self.err(expected)), Some(Build::Expr(e)) => Ok(e), } } // If the current context calls for case insensitivity, then apply // case folding. Similarly, if `negate` is `true`, then negate the // class. (Negation always proceeds case folding.) fn class_transform(&self, negate: bool, mut cls: CharClass) -> CharClass { if self.flags.casei { cls = cls.case_fold(); } if negate { cls = cls.negate(); } cls } } struct Chars<'a> { chars: &'a [char], cur: usize, ignore_space: bool, } impl<'a> Iterator for Chars<'a> { type Item = char; fn next(&mut self) -> Option { if !self.ignore_space { let x = self.c(); self.advance(); return x; } while let Some(c) = self.c() { self.advance(); match c { '\\' => return match self.c() { Some('#') => {self.advance(); Some('#')} _ => Some('\\') }, '#' => loop { match self.c() { Some(c) => { self.advance(); if c == '\n' { break; } }, None => return None } }, _ => if !c.is_whitespace() {return Some(c);} } } None } } impl<'a> Chars<'a> { fn new(chars: &[char], ignore_space: bool) -> Chars { Chars { chars: chars, cur: 0, ignore_space: ignore_space, } } fn c(&self) -> Option { self.chars.get(self.cur).map(|&c| c) } fn advance(&mut self) { self.cur = checkadd(self.cur, 1); } fn next_count(&mut self) -> usize { self.next(); self.cur } } // Auxiliary methods for manipulating the expression stack. impl Parser { // Called whenever an alternate (`|`) is found. // // This pops the expression stack until: // // 1. The stack is empty. Pushes an alternation with one arm. // 2. An opening parenthesis is found. Leave the parenthesis // on the stack and push an alternation with one arm. // 3. An alternate (`|`) is found. Pop the existing alternation, // add an arm and push the modified alternation. // // Each "arm" in the above corresponds to the concatenation of all // popped expressions. // // In the first two cases, the stack is left in an invalid state // because an alternation with one arm is not allowed. This // particular state will be detected by `finish_concat` and an // error will be reported. // // In none of the cases is an empty arm allowed. If an empty arm // is found, an error is reported. fn alternate(&mut self) -> Result { let mut concat = vec![]; let alts = |es| Ok(Build::Expr(Expr::Alternate(es))); loop { match self.stack.pop() { None => { if concat.is_empty() { // e.g., |a return Err(self.err(ErrorKind::EmptyAlternate)); } return alts(vec![rev_concat(concat)]); } Some(e @ Build::LeftParen{..}) => { if concat.is_empty() { // e.g., (|a) return Err(self.err(ErrorKind::EmptyAlternate)); } self.stack.push(e); return alts(vec![rev_concat(concat)]); } Some(Build::Expr(Expr::Alternate(mut es))) => { if concat.is_empty() { // e.g., a|| return Err(self.err(ErrorKind::EmptyAlternate)); } es.push(rev_concat(concat)); return alts(es); } Some(Build::Expr(e)) => { concat.push(e); } } } } // Called whenever a closing parenthesis (`)`) is found. // // This pops the expression stack until: // // 1. The stack is empty. An error is reported because this // indicates an unopened parenthesis. // 2. An opening parenthesis is found. Pop the opening parenthesis // and push a `Group` expression. // 3. An alternate (`|`) is found. Pop the existing alternation // and an arm to it in place. Pop one more item from the stack. // If the stack was empty, then report an unopened parenthesis // error, otherwise assume it is an opening parenthesis and // push a `Group` expression with the popped alternation. // (We can assume this is an opening parenthesis because an // alternation either corresponds to the entire Regex or it // corresponds to an entire group. This is guaranteed by the // `alternate` method.) // // Each "arm" in the above corresponds to the concatenation of all // popped expressions. // // Empty arms nor empty groups are allowed. fn close_paren(&mut self) -> Result<(Flags, Build)> { let mut concat = vec![]; loop { match self.stack.pop() { // e.g., ) None => return Err(self.err(ErrorKind::UnopenedParen)), Some(Build::LeftParen { i, name, old_flags, .. }) => { if concat.is_empty() { // e.g., () return Err(self.err(ErrorKind::EmptyGroup)); } return Ok((old_flags, Build::Expr(Expr::Group { e: Box::new(rev_concat(concat)), i: i, name: name, }))); } Some(Build::Expr(Expr::Alternate(mut es))) => { if concat.is_empty() { // e.g., (a|) return Err(self.err(ErrorKind::EmptyAlternate)); } es.push(rev_concat(concat)); match self.stack.pop() { // e.g., a|b) None => return Err(self.err(ErrorKind::UnopenedParen)), Some(Build::Expr(_)) => unreachable!(), Some(Build::LeftParen { i, name, old_flags, .. }) => { return Ok((old_flags, Build::Expr(Expr::Group { e: Box::new(Expr::Alternate(es)), i: i, name: name, }))); } } } Some(Build::Expr(e)) => { concat.push(e); } } } } // Called only when the parser reaches the end of input. // // This pops the expression stack until: // // 1. The stack is empty. Return concatenation of popped // expressions. This concatenation may be empty! // 2. An alternation is found. Pop the alternation and push // a new arm. Return the alternation as the entire Regex. // // If an opening parenthesis is popped, then an error is // returned since it indicates an unclosed parenthesis. fn finish_concat(&mut self) -> Result { let mut concat = vec![]; loop { match self.stack.pop() { None => { return Ok(rev_concat(concat)); } Some(Build::LeftParen{ chari, ..}) => { // e.g., a(b return Err(self.errat(chari, ErrorKind::UnclosedParen)); } Some(Build::Expr(Expr::Alternate(mut es))) => { if concat.is_empty() { // e.g., a| return Err(self.err(ErrorKind::EmptyAlternate)); } es.push(rev_concat(concat)); return Ok(Expr::Alternate(es)); } Some(Build::Expr(e)) => { concat.push(e); } } } } } impl Build { fn is_empty(&self) -> bool { match *self { Build::Expr(Expr::Empty) => true, _ => false, } } } // Make it ergonomic to conditionally bump the parser. // i.e., `bump_if('a')` or `bump_if("abc")`. trait Bumpable { fn match_end(self, p: &Parser) -> usize; } impl Bumpable for char { fn match_end(self, p: &Parser) -> usize { let mut chars = p.chars(); if chars.next().map(|c| c == self).unwrap_or(false) { chars.cur } else { 0 } } } impl<'a> Bumpable for &'a str { fn match_end(self, p: &Parser) -> usize { let mut search = self.chars(); let mut rest = p.chars(); let mut count = 0; loop { match (rest.next(), search.next()) { (Some(c1), Some(c2)) if c1 == c2 => count = rest.cur, (_, None) => return count, _ => return 0, } } } } impl bool> Bumpable for F { fn match_end(mut self, p: &Parser) -> usize { let mut chars = p.chars(); let mut count = 0; while let Some(c) = chars.next() { if !self(c) { break } count = chars.cur; } count } } // Turn a sequence of expressions into a concatenation. // This only uses `Concat` if there are 2 or more expressions. fn rev_concat(mut exprs: Vec) -> Expr { if exprs.len() == 0 { Expr::Empty } else if exprs.len() == 1 { exprs.pop().unwrap() } else { exprs.reverse(); Expr::Concat(exprs) } } // Returns true if and only if the given character is allowed in a capture // name. Note that the first char of a capture name must not be numeric. fn is_valid_capture_char(c: char) -> bool { c == '_' || (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') } /// Returns true if the give character has significance in a regex. #[doc(hidden)] pub fn is_punct(c: char) -> bool { match c { '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | '{' | '}' | '^' | '$' | '#' => true, _ => false, } } fn checkadd(x: usize, y: usize) -> usize { x.checked_add(y).expect("regex length overflow") } fn unicode_class(name: &str) -> Option { UNICODE_CLASSES.binary_search_by(|&(s, _)| s.cmp(name)).ok().map(|i| { raw_class_to_expr(UNICODE_CLASSES[i].1) }) } fn ascii_class(name: &str) -> Option { ASCII_CLASSES.binary_search_by(|&(s, _)| s.cmp(name)).ok().map(|i| { raw_class_to_expr(ASCII_CLASSES[i].1) }) } fn raw_class_to_expr(raw: &[(char, char)]) -> CharClass { let range = |&(s, e)| ClassRange { start: s, end: e }; CharClass::new(raw.iter().map(range).collect()) } type Class = &'static [(char, char)]; type NamedClasses = &'static [(&'static str, Class)]; const ASCII_CLASSES: NamedClasses = &[ // Classes must be in alphabetical order so that bsearch works. // [:alnum:] alphanumeric (== [0-9A-Za-z]) // [:alpha:] alphabetic (== [A-Za-z]) // [:ascii:] ASCII (== [\x00-\x7F]) // [:blank:] blank (== [\t ]) // [:cntrl:] control (== [\x00-\x1F\x7F]) // [:digit:] digits (== [0-9]) // [:graph:] graphical (== [!-~]) // [:lower:] lower case (== [a-z]) // [:print:] printable (== [ -~] == [ [:graph:]]) // [:punct:] punctuation (== [!-/:-@[-`{-~]) // [:space:] whitespace (== [\t\n\v\f\r ]) // [:upper:] upper case (== [A-Z]) // [:word:] word characters (== [0-9A-Za-z_]) // [:xdigit:] hex digit (== [0-9A-Fa-f]) // Taken from: http://golang.org/pkg/regex/syntax/ ("alnum", &ALNUM), ("alpha", &ALPHA), ("ascii", &ASCII), ("blank", &BLANK), ("cntrl", &CNTRL), ("digit", &DIGIT), ("graph", &GRAPH), ("lower", &LOWER), ("print", &PRINT), ("punct", &PUNCT), ("space", &SPACE), ("upper", &UPPER), ("word", &WORD), ("xdigit", &XDIGIT), ]; const ALNUM: Class = &[('0', '9'), ('A', 'Z'), ('a', 'z')]; const ALPHA: Class = &[('A', 'Z'), ('a', 'z')]; const ASCII: Class = &[('\x00', '\x7F')]; const BLANK: Class = &[(' ', ' '), ('\t', '\t')]; const CNTRL: Class = &[('\x00', '\x1F'), ('\x7F', '\x7F')]; const DIGIT: Class = &[('0', '9')]; const GRAPH: Class = &[('!', '~')]; const LOWER: Class = &[('a', 'z')]; const PRINT: Class = &[(' ', '~')]; const PUNCT: Class = &[('!', '/'), (':', '@'), ('[', '`'), ('{', '~')]; const SPACE: Class = &[('\t', '\t'), ('\n', '\n'), ('\x0B', '\x0B'), ('\x0C', '\x0C'), ('\r', '\r'), (' ', ' ')]; const UPPER: Class = &[('A', 'Z')]; const WORD: Class = &[('0', '9'), ('A', 'Z'), ('_', '_'), ('a', 'z')]; const XDIGIT: Class = &[('0', '9'), ('A', 'F'), ('a', 'f')]; #[cfg(test)] mod tests { use { CharClass, ClassRange, Expr, Repeater, ErrorKind }; use unicode::regex::{PERLD, PERLS, PERLW}; use super::Parser; use super::{LOWER, UPPER}; static YI: &'static [(char, char)] = &[ ('\u{a000}', '\u{a48c}'), ('\u{a490}', '\u{a4c6}'), ]; fn p(s: &str) -> Expr { Parser::parse(s).unwrap() } fn lit(c: char) -> Expr { Expr::Literal { chars: vec![c], casei: false } } fn liti(c: char) -> Expr { Expr::Literal { chars: vec![c], casei: true } } fn b(v: T) -> Box { Box::new(v) } fn c(es: &[Expr]) -> Expr { Expr::Concat(es.to_vec()) } fn class(ranges: &[(char, char)]) -> CharClass { let ranges = ranges.iter().cloned() .map(|(c1, c2)| ClassRange::new(c1, c2)).collect(); CharClass::new(ranges) } fn classes(classes: &[&[(char, char)]]) -> CharClass { let mut cls = CharClass::empty(); for &ranges in classes { cls.ranges.extend(class(ranges)); } cls.canonicalize() } #[test] fn empty() { assert_eq!(p(""), Expr::Empty); } #[test] fn literal() { assert_eq!(p("a"), lit('a')); } #[test] fn literal_string() { assert_eq!(p("ab"), Expr::Concat(vec![lit('a'), lit('b')])); } #[test] fn start_literal() { assert_eq!(p("^a"), Expr::Concat(vec![ Expr::StartText, Expr::Literal { chars: vec!['a'], casei: false }, ])); } #[test] fn repeat_zero_or_one_greedy() { assert_eq!(p("a?"), Expr::Repeat { e: b(lit('a')), r: Repeater::ZeroOrOne, greedy: true, }); } #[test] fn repeat_zero_or_one_greedy_concat() { assert_eq!(p("ab?"), Expr::Concat(vec![ lit('a'), Expr::Repeat { e: b(lit('b')), r: Repeater::ZeroOrOne, greedy: true, }, ])); } #[test] fn repeat_zero_or_one_nongreedy() { assert_eq!(p("a??"), Expr::Repeat { e: b(lit('a')), r: Repeater::ZeroOrOne, greedy: false, }); } #[test] fn repeat_one_or_more_greedy() { assert_eq!(p("a+"), Expr::Repeat { e: b(lit('a')), r: Repeater::OneOrMore, greedy: true, }); } #[test] fn repeat_one_or_more_nongreedy() { assert_eq!(p("a+?"), Expr::Repeat { e: b(lit('a')), r: Repeater::OneOrMore, greedy: false, }); } #[test] fn repeat_zero_or_more_greedy() { assert_eq!(p("a*"), Expr::Repeat { e: b(lit('a')), r: Repeater::ZeroOrMore, greedy: true, }); } #[test] fn repeat_zero_or_more_nongreedy() { assert_eq!(p("a*?"), Expr::Repeat { e: b(lit('a')), r: Repeater::ZeroOrMore, greedy: false, }); } #[test] fn repeat_counted_exact() { assert_eq!(p("a{5}"), Expr::Repeat { e: b(lit('a')), r: Repeater::Range { min: 5, max: Some(5) }, greedy: true, }); } #[test] fn repeat_counted_min() { assert_eq!(p("a{5,}"), Expr::Repeat { e: b(lit('a')), r: Repeater::Range { min: 5, max: None }, greedy: true, }); } #[test] fn repeat_counted_min_max() { assert_eq!(p("a{5,10}"), Expr::Repeat { e: b(lit('a')), r: Repeater::Range { min: 5, max: Some(10) }, greedy: true, }); } #[test] fn repeat_counted_exact_nongreedy() { assert_eq!(p("a{5}?"), Expr::Repeat { e: b(lit('a')), r: Repeater::Range { min: 5, max: Some(5) }, greedy: false, }); } #[test] fn repeat_counted_min_nongreedy() { assert_eq!(p("a{5,}?"), Expr::Repeat { e: b(lit('a')), r: Repeater::Range { min: 5, max: None }, greedy: false, }); } #[test] fn repeat_counted_min_max_nongreedy() { assert_eq!(p("a{5,10}?"), Expr::Repeat { e: b(lit('a')), r: Repeater::Range { min: 5, max: Some(10) }, greedy: false, }); } #[test] fn repeat_counted_whitespace() { assert_eq!(p("a{ 5 }"), Expr::Repeat { e: b(lit('a')), r: Repeater::Range { min: 5, max: Some(5) }, greedy: true, }); assert_eq!(p("a{ 5 , 10 }"), Expr::Repeat { e: b(lit('a')), r: Repeater::Range { min: 5, max: Some(10) }, greedy: true, }); } #[test] fn group_literal() { assert_eq!(p("(a)"), Expr::Group { e: b(lit('a')), i: Some(1), name: None, }); } #[test] fn group_literal_concat() { assert_eq!(p("(ab)"), Expr::Group { e: b(c(&[lit('a'), lit('b')])), i: Some(1), name: None, }); } #[test] fn alt_two() { assert_eq!(p("a|b"), Expr::Alternate(vec![lit('a'), lit('b')])); } #[test] fn alt_many() { assert_eq!(p("a|b|c"), Expr::Alternate(vec![ lit('a'), lit('b'), lit('c'), ])); } #[test] fn alt_many_concat() { assert_eq!(p("ab|bc|cd"), Expr::Alternate(vec![ c(&[lit('a'), lit('b')]), c(&[lit('b'), lit('c')]), c(&[lit('c'), lit('d')]), ])); } #[test] fn alt_group_two() { assert_eq!(p("(a|b)"), Expr::Group { e: b(Expr::Alternate(vec![lit('a'), lit('b')])), i: Some(1), name: None, }); } #[test] fn alt_group_many() { assert_eq!(p("(a|b|c)"), Expr::Group { e: b(Expr::Alternate(vec![lit('a'), lit('b'), lit('c')])), i: Some(1), name: None, }); } #[test] fn alt_group_many_concat() { assert_eq!(p("(ab|bc|cd)"), Expr::Group { e: b(Expr::Alternate(vec![ c(&[lit('a'), lit('b')]), c(&[lit('b'), lit('c')]), c(&[lit('c'), lit('d')]), ])), i: Some(1), name: None, }); } #[test] fn alt_group_nested() { assert_eq!(p("(ab|(bc|(cd)))"), Expr::Group { e: b(Expr::Alternate(vec![ c(&[lit('a'), lit('b')]), Expr::Group { e: b(Expr::Alternate(vec![ c(&[lit('b'), lit('c')]), Expr::Group { e: b(c(&[lit('c'), lit('d')])), i: Some(3), name: None, } ])), i: Some(2), name: None, }, ])), i: Some(1), name: None, }); } #[test] fn group_name() { assert_eq!(p("(?Pa)"), Expr::Group { e: b(lit('a')), i: Some(1), name: Some("foo".into()), }); } #[test] fn group_no_capture() { assert_eq!(p("(?:a)"), Expr::Group { e: b(lit('a')), i: None, name: None, }); } #[test] fn group_flags() { assert_eq!(p("(?i:a)"), Expr::Group { e: b(liti('a')), i: None, name: None, }); } #[test] fn group_flags_returned() { assert_eq!(p("(?i:a)a"), c(&[ Expr::Group { e: b(liti('a')), i: None, name: None, }, lit('a'), ])); } #[test] fn group_flags_retained() { assert_eq!(p("(?i)(?-i:a)a"), c(&[ Expr::Group { e: b(lit('a')), i: None, name: None, }, liti('a'), ])); } #[test] fn flags_inline() { assert_eq!(p("(?i)a"), liti('a')); } #[test] fn flags_inline_multiple() { assert_eq!(p("(?is)a."), c(&[liti('a'), Expr::AnyChar])); } #[test] fn flags_inline_multiline() { assert_eq!(p("(?m)^(?-m)$"), c(&[Expr::StartLine, Expr::EndText])); } #[test] fn flags_inline_swap_greed() { assert_eq!(p("(?U)a*a*?(?i-U)a*a*?"), c(&[ Expr::Repeat { e: b(lit('a')), r: Repeater::ZeroOrMore, greedy: false, }, Expr::Repeat { e: b(lit('a')), r: Repeater::ZeroOrMore, greedy: true, }, Expr::Repeat { e: b(liti('a')), r: Repeater::ZeroOrMore, greedy: true, }, Expr::Repeat { e: b(liti('a')), r: Repeater::ZeroOrMore, greedy: false, }, ])); } #[test] fn flags_inline_multiple_negate_one() { assert_eq!(p("(?is)a.(?i-s)a."), c(&[ liti('a'), Expr::AnyChar, liti('a'), Expr::AnyCharNoNL, ])); } #[test] fn flags_inline_negate() { assert_eq!(p("(?i)a(?-i)a"), c(&[liti('a'), lit('a')])); } #[test] fn flags_group_inline() { assert_eq!(p("(a(?i)a)a"), c(&[ Expr::Group { e: b(c(&[lit('a'), liti('a')])), i: Some(1), name: None, }, lit('a'), ])); } #[test] fn flags_group_inline_retain() { assert_eq!(p("(?i)((?-i)a)a"), c(&[ Expr::Group { e: b(lit('a')), i: Some(1), name: None, }, liti('a'), ])); } #[test] fn escape_simple() { assert_eq!(p(r"\a\f\t\n\r\v"), c(&[ lit('\x07'), lit('\x0C'), lit('\t'), lit('\n'), lit('\r'), lit('\x0B'), ])); } #[test] fn escape_boundaries() { assert_eq!(p(r"\A\z\b\B"), c(&[ Expr::StartText, Expr::EndText, Expr::WordBoundary, Expr::NotWordBoundary, ])); } #[test] fn escape_punctuation() { assert_eq!(p(r"\\\.\+\*\?\(\)\|\[\]\{\}\^\$\#"), c(&[ lit('\\'), lit('.'), lit('+'), lit('*'), lit('?'), lit('('), lit(')'), lit('|'), lit('['), lit(']'), lit('{'), lit('}'), lit('^'), lit('$'), lit('#'), ])); } #[test] fn escape_octal() { assert_eq!(p(r"\123"), lit('S')); assert_eq!(p(r"\1234"), c(&[lit('S'), lit('4')])); } #[test] fn escape_hex2() { assert_eq!(p(r"\x53"), lit('S')); assert_eq!(p(r"\x534"), c(&[lit('S'), lit('4')])); } #[test] fn escape_hex() { assert_eq!(p(r"\x{53}"), lit('S')); assert_eq!(p(r"\x{53}4"), c(&[lit('S'), lit('4')])); assert_eq!(p(r"\x{2603}"), lit('\u{2603}')); } #[test] fn escape_unicode_name() { assert_eq!(p(r"\p{Yi}"), Expr::Class(class(YI))); } #[test] fn escape_unicode_letter() { assert_eq!(p(r"\pZ"), Expr::Class(class(&[ ('\u{20}', '\u{20}'), ('\u{a0}', '\u{a0}'), ('\u{1680}', '\u{1680}'), ('\u{2000}', '\u{200a}'), ('\u{2028}', '\u{2029}'), ('\u{202f}', '\u{202f}'), ('\u{205f}', '\u{205f}'), ('\u{3000}', '\u{3000}'), ]))); } #[test] fn escape_unicode_name_case_fold() { assert_eq!(p(r"(?i)\p{Yi}"), Expr::Class(class(YI).case_fold())); } #[test] fn escape_unicode_letter_case_fold() { assert_eq!(p(r"(?i)\pZ"), Expr::Class(class(&[ ('\u{20}', '\u{20}'), ('\u{a0}', '\u{a0}'), ('\u{1680}', '\u{1680}'), ('\u{2000}', '\u{200a}'), ('\u{2028}', '\u{2029}'), ('\u{202f}', '\u{202f}'), ('\u{205f}', '\u{205f}'), ('\u{3000}', '\u{3000}'), ]).case_fold())); } #[test] fn escape_unicode_name_negate() { assert_eq!(p(r"\P{Yi}"), Expr::Class(class(YI).negate())); } #[test] fn escape_unicode_letter_negate() { assert_eq!(p(r"\PZ"), Expr::Class(class(&[ ('\u{20}', '\u{20}'), ('\u{a0}', '\u{a0}'), ('\u{1680}', '\u{1680}'), ('\u{2000}', '\u{200a}'), ('\u{2028}', '\u{2029}'), ('\u{202f}', '\u{202f}'), ('\u{205f}', '\u{205f}'), ('\u{3000}', '\u{3000}'), ]).negate())); } #[test] fn escape_unicode_name_negate_case_fold() { assert_eq!(p(r"(?i)\P{Yi}"), Expr::Class(class(YI).negate().case_fold())); } #[test] fn escape_unicode_letter_negate_case_fold() { assert_eq!(p(r"(?i)\PZ"), Expr::Class(class(&[ ('\u{20}', '\u{20}'), ('\u{a0}', '\u{a0}'), ('\u{1680}', '\u{1680}'), ('\u{2000}', '\u{200a}'), ('\u{2028}', '\u{2029}'), ('\u{202f}', '\u{202f}'), ('\u{205f}', '\u{205f}'), ('\u{3000}', '\u{3000}'), ]).negate().case_fold())); } #[test] fn escape_perl_d() { assert_eq!(p(r"\d"), Expr::Class(class(PERLD))); } #[test] fn escape_perl_s() { assert_eq!(p(r"\s"), Expr::Class(class(PERLS))); } #[test] fn escape_perl_w() { assert_eq!(p(r"\w"), Expr::Class(class(PERLW))); } #[test] fn escape_perl_d_negate() { assert_eq!(p(r"\D"), Expr::Class(class(PERLD).negate())); } #[test] fn escape_perl_s_negate() { assert_eq!(p(r"\S"), Expr::Class(class(PERLS).negate())); } #[test] fn escape_perl_w_negate() { assert_eq!(p(r"\W"), Expr::Class(class(PERLW).negate())); } #[test] fn escape_perl_d_case_fold() { assert_eq!(p(r"(?i)\d"), Expr::Class(class(PERLD).case_fold())); } #[test] fn escape_perl_s_case_fold() { assert_eq!(p(r"(?i)\s"), Expr::Class(class(PERLS).case_fold())); } #[test] fn escape_perl_w_case_fold() { assert_eq!(p(r"(?i)\w"), Expr::Class(class(PERLW).case_fold())); } #[test] fn escape_perl_d_case_fold_negate() { assert_eq!(p(r"(?i)\D"), Expr::Class(class(PERLD).negate().case_fold())); } #[test] fn escape_perl_s_case_fold_negate() { assert_eq!(p(r"(?i)\S"), Expr::Class(class(PERLS).negate().case_fold())); } #[test] fn escape_perl_w_case_fold_negate() { assert_eq!(p(r"(?i)\W"), Expr::Class(class(PERLW).negate().case_fold())); } #[test] fn class_singleton() { assert_eq!(p(r"[a]"), Expr::Class(class(&[('a', 'a')]))); assert_eq!(p(r"[\x00]"), Expr::Class(class(&[('\x00', '\x00')]))); assert_eq!(p(r"[\n]"), Expr::Class(class(&[('\n', '\n')]))); assert_eq!(p("[\n]"), Expr::Class(class(&[('\n', '\n')]))); } #[test] fn class_singleton_negate() { assert_eq!(p(r"[^a]"), Expr::Class(class(&[ ('\x00', '\x60'), ('\x62', '\u{10FFFF}'), ]))); assert_eq!(p(r"[^\x00]"), Expr::Class(class(&[ ('\x01', '\u{10FFFF}'), ]))); assert_eq!(p(r"[^\n]"), Expr::Class(class(&[ ('\x00', '\x09'), ('\x0b', '\u{10FFFF}'), ]))); assert_eq!(p("[^\n]"), Expr::Class(class(&[ ('\x00', '\x09'), ('\x0b', '\u{10FFFF}'), ]))); } #[test] fn class_singleton_class() { assert_eq!(p(r"[\d]"), Expr::Class(class(PERLD))); assert_eq!(p(r"[\p{Yi}]"), Expr::Class(class(YI))); } #[test] fn class_singleton_class_negate() { assert_eq!(p(r"[^\d]"), Expr::Class(class(PERLD).negate())); assert_eq!(p(r"[^\w]"), Expr::Class(class(PERLW).negate())); assert_eq!(p(r"[^\s]"), Expr::Class(class(PERLS).negate())); } #[test] fn class_singleton_class_negate_negate() { assert_eq!(p(r"[^\D]"), Expr::Class(class(PERLD))); assert_eq!(p(r"[^\W]"), Expr::Class(class(PERLW))); assert_eq!(p(r"[^\S]"), Expr::Class(class(PERLS))); } #[test] fn class_singleton_class_casei() { assert_eq!(p(r"(?i)[\d]"), Expr::Class(class(PERLD).case_fold())); assert_eq!(p(r"(?i)[\p{Yi}]"), Expr::Class(class(YI).case_fold())); } #[test] fn class_singleton_class_negate_casei() { assert_eq!(p(r"(?i)[^\d]"), Expr::Class(class(PERLD).negate().case_fold())); assert_eq!(p(r"(?i)[^\w]"), Expr::Class(class(PERLW).negate().case_fold())); assert_eq!(p(r"(?i)[^\s]"), Expr::Class(class(PERLS).negate().case_fold())); } #[test] fn class_singleton_class_negate_negate_casei() { assert_eq!(p(r"(?i)[^\D]"), Expr::Class(class(PERLD).case_fold())); assert_eq!(p(r"(?i)[^\W]"), Expr::Class(class(PERLW).case_fold())); assert_eq!(p(r"(?i)[^\S]"), Expr::Class(class(PERLS).case_fold())); } #[test] fn class_multiple_class() { assert_eq!(p(r"[\d\p{Yi}]"), Expr::Class(classes(&[ PERLD, YI, ]))); } #[test] fn class_multiple_class_negate() { assert_eq!(p(r"[^\d\p{Yi}]"), Expr::Class(classes(&[ PERLD, YI, ]).negate())); } #[test] fn class_multiple_class_negate_negate() { let nperld = class(PERLD).negate(); let nyi = class(YI).negate(); let cls = CharClass::empty().merge(nperld).merge(nyi); assert_eq!(p(r"[^\D\P{Yi}]"), Expr::Class(cls.negate())); } #[test] fn class_multiple_class_casei() { assert_eq!(p(r"(?i)[\d\p{Yi}]"), Expr::Class(classes(&[ PERLD, YI, ]).case_fold())); } #[test] fn class_multiple_class_negate_casei() { assert_eq!(p(r"(?i)[^\d\p{Yi}]"), Expr::Class(classes(&[ PERLD, YI, ]).negate().case_fold())); } #[test] fn class_multiple_class_negate_negate_casei() { let nperld = class(PERLD).negate(); let nyi = class(YI).negate(); let class = CharClass::empty().merge(nperld).merge(nyi); assert_eq!(p(r"(?i)[^\D\P{Yi}]"), Expr::Class(class.negate().case_fold())); } #[test] fn class_class_hypen() { assert_eq!(p(r"[\p{Yi}-]"), Expr::Class(classes(&[ &[('-', '-')], YI, ]))); assert_eq!(p(r"[\p{Yi}-a]"), Expr::Class(classes(&[ &[('-', '-')], &[('a', 'a')], YI, ]))); } #[test] fn class_brackets() { assert_eq!(p("[]]"), Expr::Class(class(&[(']', ']')]))); assert_eq!(p("[][]"), Expr::Class(class(&[('[', '['), (']', ']')]))); assert_eq!(p("[[]]"), Expr::Concat(vec![ Expr::Class(class(&[('[', '[')])), lit(']'), ])); } #[test] fn class_brackets_hypen() { assert_eq!(p("[]-]"), Expr::Class(class(&[('-', '-'), (']', ']')]))); assert_eq!(p("[-]]"), Expr::Concat(vec![ Expr::Class(class(&[('-', '-')])), lit(']'), ])); } #[test] fn class_overlapping() { assert_eq!(p("[a-fd-h]"), Expr::Class(class(&[('a', 'h')]))); assert_eq!(p("[a-fg-m]"), Expr::Class(class(&[('a', 'm')]))); } #[test] fn ascii_class() { assert_eq!(p("[:upper:]"), Expr::Class(class(UPPER))); assert_eq!(p("[[:upper:]]"), Expr::Class(class(UPPER))); } #[test] fn ascii_class_not() { assert_eq!(p("[:abc:]"), Expr::Class(class(&[(':', ':'), ('a', 'c')]))); } #[test] fn ascii_class_multiple() { assert_eq!(p("[[:lower:][:upper:]]"), Expr::Class(classes(&[UPPER, LOWER]))); } #[test] fn ascii_class_negate() { assert_eq!(p("[[:^upper:]]"), Expr::Class(class(UPPER).negate())); assert_eq!(p("[^[:^upper:]]"), Expr::Class(class(UPPER))); } #[test] fn ascii_class_negate_multiple() { let (nlower, nupper) = (class(LOWER).negate(), class(UPPER).negate()); let cls = CharClass::empty().merge(nlower).merge(nupper); assert_eq!(p("[[:^lower:][:^upper:]]"), Expr::Class(cls.clone())); assert_eq!(p("[^[:^lower:][:^upper:]]"), Expr::Class(cls.negate())); } #[test] fn ascii_class_case_fold() { assert_eq!(p("(?i)[:upper:]"), Expr::Class(class(UPPER).case_fold())); assert_eq!(p("(?i)[[:upper:]]"), Expr::Class(class(UPPER).case_fold())); } #[test] fn ascii_class_negate_case_fold() { assert_eq!(p("(?i)[[:^upper:]]"), Expr::Class(class(UPPER).case_fold().negate())); assert_eq!(p("(?i)[^[:^upper:]]"), Expr::Class(class(UPPER).case_fold())); } #[test] fn single_class_negate_case_fold() { assert_eq!(p("(?i)[^x]"), Expr::Class(class(&[('x', 'x')]).case_fold().negate())); } #[test] fn ignore_space_literal() { assert_eq!(p("(?x) a b c"), Expr::Concat(vec![ lit('a'), lit('b'), lit('c'), ])); } #[test] fn ignore_space_literal_off() { assert_eq!(p("(?x) a b c(?-x) a"), Expr::Concat(vec![ lit('a'), lit('b'), lit('c'), lit(' '), lit('a'), ])); } #[test] fn ignore_space_class() { assert_eq!(p("(?x)[a - z ]"), Expr::Class(class(&[('a', 'z')]))); assert_eq!(p("(?x)[ ^ a - z ]"), Expr::Class(class(&[('a', 'z')]).negate())); } #[test] fn ignore_space_escape() { assert_eq!(p(r"(?x)\ d"), Expr::Class(class(PERLD))); assert_eq!(p(r"(?x)\ D"), Expr::Class(class(PERLD).negate())); } #[test] fn ignore_space_comments() { assert_eq!(p(r"(?x)(?P a # comment 1 )(?P z # comment 2 )"), Expr::Concat(vec![ Expr::Group { e: Box::new(lit('a')), i: Some(1), name: Some("foo".into()), }, Expr::Group { e: Box::new(lit('z')), i: Some(2), name: Some("bar".into()), }, ])); } #[test] fn ignore_space_comments_re_enable() { assert_eq!(p(r"(?x)a # hi (?-x:#) # sweet"), Expr::Concat(vec![ lit('a'), Expr::Group { e: Box::new(lit('#')), i: None, name: None, }, ])); } #[test] fn ignore_space_escape_punctuation() { assert_eq!(p(r"(?x)\\\.\+\*\?\(\)\|\[\]\{\}\^\$\#"), c(&[ lit('\\'), lit('.'), lit('+'), lit('*'), lit('?'), lit('('), lit(')'), lit('|'), lit('['), lit(']'), lit('{'), lit('}'), lit('^'), lit('$'), lit('#'), ])); } #[test] fn ignore_space_escape_hash() { assert_eq!(p(r"(?x)a\# # hi there"), Expr::Concat(vec![ lit('a'), lit('#'), ])); } // Test every single possible error case. macro_rules! test_err { ($re:expr, $pos:expr, $kind:expr) => {{ let err = Parser::parse($re).unwrap_err(); assert_eq!($pos, err.pos); assert_eq!($kind, err.kind); assert!($re.contains(&err.surround)); }} } #[test] fn error_repeat_no_expr_simple() { test_err!("(*", 1, ErrorKind::RepeaterExpectsExpr); } #[test] fn error_repeat_no_expr_counted() { test_err!("({5}", 1, ErrorKind::RepeaterExpectsExpr); } #[test] fn error_repeat_beginning_counted() { test_err!("{5}", 0, ErrorKind::RepeaterExpectsExpr); } #[test] fn error_repeat_illegal_exprs_simple() { test_err!("a**", 2, ErrorKind::RepeaterUnexpectedExpr(Expr::Repeat { e: b(lit('a')), r: Repeater::ZeroOrMore, greedy: true, })); test_err!("a|*", 2, ErrorKind::RepeaterUnexpectedExpr(Expr::Alternate(vec![lit('a')])) ); } #[test] fn error_repeat_illegal_exprs_counted() { test_err!("a*{5}", 2, ErrorKind::RepeaterUnexpectedExpr(Expr::Repeat { e: b(lit('a')), r: Repeater::ZeroOrMore, greedy: true, })); test_err!("a|{5}", 2, ErrorKind::RepeaterUnexpectedExpr(Expr::Alternate(vec![lit('a')])) ); } #[test] fn error_repeat_empty_number() { test_err!("a{}", 2, ErrorKind::MissingBase10); } #[test] fn error_repeat_eof() { test_err!("a{5", 3, ErrorKind::UnclosedRepeat); } #[test] fn error_repeat_empty_number_eof() { test_err!("a{xyz", 5, ErrorKind::InvalidBase10("xyz".into())); test_err!("a{12,xyz", 8, ErrorKind::InvalidBase10("xyz".into())); } #[test] fn error_repeat_invalid_number() { test_err!("a{9999999999}", 12, ErrorKind::InvalidBase10("9999999999".into())); test_err!("a{1,9999999999}", 14, ErrorKind::InvalidBase10("9999999999".into())); } #[test] fn error_repeat_invalid_number_extra() { test_err!("a{12x}", 5, ErrorKind::InvalidBase10("12x".into())); test_err!("a{1,12x}", 7, ErrorKind::InvalidBase10("12x".into())); } #[test] fn error_repeat_invalid_range() { test_err!("a{2,1}", 5, ErrorKind::InvalidRepeatRange { min: 2, max: 1 }); } #[test] fn error_alternate_empty() { test_err!("|a", 0, ErrorKind::EmptyAlternate); } #[test] fn error_alternate_empty_with_group() { test_err!("(|a)", 1, ErrorKind::EmptyAlternate); } #[test] fn error_alternate_empty_with_alternate() { test_err!("a||", 2, ErrorKind::EmptyAlternate); } #[test] fn error_close_paren_unopened_empty() { test_err!(")", 0, ErrorKind::UnopenedParen); } #[test] fn error_close_paren_unopened() { test_err!("ab)", 2, ErrorKind::UnopenedParen); } #[test] fn error_close_paren_unopened_with_alt() { test_err!("a|b)", 3, ErrorKind::UnopenedParen); } #[test] fn error_close_paren_empty_alt() { test_err!("(a|)", 3, ErrorKind::EmptyAlternate); } #[test] fn error_close_paren_empty_group() { test_err!("()", 1, ErrorKind::EmptyGroup); } #[test] fn error_close_paren_empty_group_with_name() { test_err!("(?P)", 8, ErrorKind::EmptyGroup); } #[test] fn error_finish_concat_unclosed() { test_err!("ab(xy", 2, ErrorKind::UnclosedParen); } #[test] fn error_finish_concat_empty_alt() { test_err!("a|", 2, ErrorKind::EmptyAlternate); } #[test] fn error_group_name_invalid() { test_err!("(?Px)", 6, ErrorKind::InvalidCaptureName("a#".into())); } #[test] fn error_group_name_invalid_leading() { test_err!("(?P<1a>a)", 6, ErrorKind::InvalidCaptureName("1a".into())); } #[test] fn error_group_name_unexpected_eof() { test_err!("(?Pa)", 4, ErrorKind::EmptyCaptureName); } #[test] fn error_group_opts_unrecognized_flag() { test_err!("(?z:a)", 2, ErrorKind::UnrecognizedFlag('z')); } #[test] fn error_group_opts_unexpected_eof() { test_err!("(?i", 3, ErrorKind::UnexpectedFlagEof); } #[test] fn error_group_opts_double_negation() { test_err!("(?-i-s:a)", 4, ErrorKind::DoubleFlagNegation); } #[test] fn error_group_opts_empty_negation() { test_err!("(?i-:a)", 4, ErrorKind::EmptyFlagNegation); } #[test] fn error_group_opts_empty() { test_err!("(?)", 2, ErrorKind::EmptyFlagNegation); } #[test] fn error_escape_unexpected_eof() { test_err!(r"\", 1, ErrorKind::UnexpectedEscapeEof); } #[test] fn error_escape_unrecognized() { test_err!(r"\m", 1, ErrorKind::UnrecognizedEscape('m')); } #[test] fn error_escape_hex2_eof0() { test_err!(r"\x", 2, ErrorKind::UnexpectedTwoDigitHexEof); } #[test] fn error_escape_hex2_eof1() { test_err!(r"\xA", 3, ErrorKind::UnexpectedTwoDigitHexEof); } #[test] fn error_escape_hex2_invalid() { test_err!(r"\xAG", 4, ErrorKind::InvalidBase16("AG".into())); } #[test] fn error_escape_hex_eof0() { test_err!(r"\x{", 3, ErrorKind::InvalidBase16("".into())); } #[test] fn error_escape_hex_eof1() { test_err!(r"\x{A", 4, ErrorKind::UnclosedHex); } #[test] fn error_escape_hex_invalid() { test_err!(r"\x{AG}", 5, ErrorKind::InvalidBase16("AG".into())); } #[test] fn error_escape_hex_invalid_scalar_value_surrogate() { test_err!(r"\x{D800}", 7, ErrorKind::InvalidScalarValue(0xD800)); } #[test] fn error_escape_hex_invalid_scalar_value_high() { test_err!(r"\x{110000}", 9, ErrorKind::InvalidScalarValue(0x110000)); } #[test] fn error_escape_hex_invalid_u32() { test_err!(r"\x{9999999999}", 13, ErrorKind::InvalidBase16("9999999999".into())); } #[test] fn error_unicode_unclosed() { test_err!(r"\p{", 3, ErrorKind::UnclosedUnicodeName); test_err!(r"\p{Greek", 8, ErrorKind::UnclosedUnicodeName); } #[test] fn error_unicode_no_letter() { test_err!(r"\p", 2, ErrorKind::UnexpectedEscapeEof); } #[test] fn error_unicode_unknown_letter() { test_err!(r"\pA", 3, ErrorKind::UnrecognizedUnicodeClass("A".into())); } #[test] fn error_unicode_unknown_name() { test_err!(r"\p{Yii}", 7, ErrorKind::UnrecognizedUnicodeClass("Yii".into())); } #[test] fn error_class_eof_empty() { test_err!("[", 1, ErrorKind::UnexpectedClassEof); test_err!("[^", 2, ErrorKind::UnexpectedClassEof); } #[test] fn error_class_eof_non_empty() { test_err!("[a", 2, ErrorKind::UnexpectedClassEof); test_err!("[^a", 3, ErrorKind::UnexpectedClassEof); } #[test] fn error_class_eof_range() { test_err!("[a-", 3, ErrorKind::UnexpectedClassEof); test_err!("[^a-", 4, ErrorKind::UnexpectedClassEof); test_err!("[---", 4, ErrorKind::UnexpectedClassEof); } #[test] fn error_class_invalid_escape() { test_err!(r"[\pA]", 4, ErrorKind::UnrecognizedUnicodeClass("A".into())); } #[test] fn error_class_valid_escape_not_allowed() { test_err!(r"[\A]", 3, ErrorKind::InvalidClassEscape(Expr::StartText)); } #[test] fn error_class_range_valid_escape_not_allowed() { test_err!(r"[a-\d]", 5, ErrorKind::InvalidClassEscape(Expr::Class(class(PERLD)))); test_err!(r"[a-\A]", 5, ErrorKind::InvalidClassEscape(Expr::StartText)); test_err!(r"[\A-a]", 3, ErrorKind::InvalidClassEscape(Expr::StartText)); } #[test] fn error_class_invalid_range() { test_err!("[z-a]", 4, ErrorKind::InvalidClassRange { start: 'z', end: 'a', }); } #[test] fn error_class_empty_range() { test_err!("[]", 2, ErrorKind::UnexpectedClassEof); test_err!("[^]", 3, ErrorKind::UnexpectedClassEof); } #[test] fn error_duplicate_capture_name() { test_err!("(?P.)(?P.)", 14, ErrorKind::DuplicateCaptureName("a".into())); } } deps/regex-syntax-0.2.2/src/properties.rs0000644000175000001440000003163512553257506016455 0ustar users// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. use quickcheck::{Arbitrary, Gen, Testable, QuickCheck, StdGen}; use rand::Rng; use {Expr, CharClass, ClassRange, Repeater, dec_char}; fn qc(t: T) { QuickCheck::new() .tests(10_000) .max_tests(20_000) .quickcheck(t); } fn class(ranges: &[(char, char)]) -> CharClass { let ranges = ranges.iter().cloned() .map(|(c1, c2)| ClassRange::new(c1, c2)).collect(); CharClass::new(ranges) } // Test invariants for canonicalizing character classes. #[test] fn negate() { fn prop(ranges: Vec<(char, char)>) -> bool { class(&ranges).canonicalize() == class(&ranges).negate().negate() } qc(prop as fn(Vec<(char, char)>) -> bool); } #[test] fn classes_are_sorted_and_nonoverlapping() { fn prop(ranges: Vec<(char, char)>) -> bool { class(&ranges) .canonicalize() .windows(2) .all(|w| w[0].end < dec_char(w[1].start)) } qc(prop as fn(Vec<(char, char)>) -> bool); } #[test] fn valid_class_ranges() { fn prop(ranges: Vec<(char, char)>) -> bool { class(&ranges).canonicalize().into_iter().all(|r| r.start <= r.end) } qc(prop as fn(Vec<(char, char)>) -> bool); } /// A wrapper type for generating "regex-like" Unicode strings. /// /// In particular, this type's `Arbitrary` impl specifically biases toward /// special regex characters to make test cases more interesting. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] struct RegexLikeString(String); impl Arbitrary for RegexLikeString { fn arbitrary(g: &mut G) -> RegexLikeString { const SPECIAL: &'static [char] = &[ '\\', '.', '+', '*', '?', '(', ')', '|', '[', ']', '{', '}', '^', '$', ]; // Generating random Unicode strings results in mostly uninteresting // regexes. Namely, they'll mostly just be literals. // To make properties using regex strings more interesting, we bias // toward selecting characters of significance to a regex. let size = { let s = g.size(); g.gen_range(0, s) }; RegexLikeString((0..size).map(|_| { if g.gen_weighted_bool(3) { *g.choose(SPECIAL).unwrap() } else { g.gen() } }).collect()) } fn shrink(&self) -> Box> { // The regular `String` shrinker is good enough. Box::new(self.0.shrink().map(RegexLikeString)) } } /// A special type for generating small non-zero sized ASCII strings. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] struct SmallAscii(String); impl Arbitrary for SmallAscii { fn arbitrary(g: &mut G) -> SmallAscii { use std::char::from_u32; let size = g.gen_range(1, 5); SmallAscii((0..size) .map(|_| from_u32(g.gen_range(97, 123)).unwrap()) .collect()) } fn shrink(&self) -> Box> { Box::new(self.0.shrink().map(SmallAscii)) } } #[test] fn parser_never_panics() { fn prop(s: RegexLikeString) -> bool { let _ = Expr::parse(&s.0); true } qc(prop as fn(RegexLikeString) -> bool); } // Testing entire expressions. // // We only have one test at the moment, but the machinery could be useful // for other things. // // In particular, Russ Cox writes about testing regexes by comparing the // strings they match with other regex implementations. A fuzzer/shrinker // (which is what's implemented below) would be a great way to drive that // process. ---AG impl Arbitrary for Expr { fn arbitrary(g: &mut G) -> Expr { fix_capture_indices(gen_expr(g, 0, ExprType::Anything)).simplify() } fn shrink(&self) -> Box> { use Expr::*; let nada = || Box::new(None.into_iter()); let es: Box> = match *self { Empty | AnyChar | AnyCharNoNL | StartLine | EndLine | StartText | EndText | WordBoundary | NotWordBoundary => nada(), Literal { ref chars, .. } if chars.len() == 1 => nada(), Literal { ref chars, casei } => { Box::new((chars.clone(), casei) .shrink() .filter(|&(ref chars, _)| chars.len() > 0) .map(|(chars, casei)| { Literal { chars: chars, casei: casei } })) } Class(ref cls) => Box::new(cls.shrink().map(Class)), Group { ref e, ref i, ref name } => { let (i, name) = (i.clone(), name.clone()); Box::new(e.clone().shrink() .chain(e.clone().shrink() .map(move |e| Group { e: Box::new(e), i: i.clone(), name: name.clone(), }))) } Repeat { ref e, ref r, greedy } => { Box::new((*e.clone(), r.clone()) .shrink() .filter(|&(ref e, _)| e.can_repeat()) .map(move |(e, r)| Repeat { e: Box::new(e), r: r, greedy: greedy, })) } // Concat(ref es) if es.len() <= 2 => nada(), Concat(ref es) => { Box::new(es.clone() .shrink() .filter(|es| es.len() > 0) .map(|mut es| if es.len() == 1 { es.pop().unwrap() } else { Concat(es) })) } // Alternate(ref es) if es.len() <= 2 => nada(), Alternate(ref es) => { Box::new(es.clone() .shrink() .filter(|es| es.len() > 0) .map(|mut es| if es.len() == 1 { es.pop().unwrap() } else { Alternate(es) })) } }; Box::new(es.map(|e| fix_capture_indices(e).simplify())) } } enum ExprType { NoSequences, // disallow concat/alternate Anything, } fn gen_expr(g: &mut G, depth: u32, ty: ExprType) -> Expr { use Expr::*; let ub = match (depth as usize >= g.size(), ty) { (true, _) => 11, (false, ExprType::NoSequences) => 13, (false, ExprType::Anything) => 15, }; match g.gen_range(1, ub) { 0 => Empty, 1 => Literal { chars: SmallAscii::arbitrary(g).0.chars().collect(), casei: g.gen(), }, 2 => AnyChar, 3 => AnyCharNoNL, 4 => Class(CharClass::arbitrary(g)), 5 => StartLine, 6 => EndLine, 7 => StartText, 8 => EndText, 9 => WordBoundary, 10 => NotWordBoundary, 11 => gen_group_expr(g, depth + 1), 12 => Repeat { e: Box::new(gen_repeatable_expr(g, depth + 1)), r: Repeater::arbitrary(g), greedy: bool::arbitrary(g), }, 13 => { let size = { let s = g.size(); g.gen_range(2, s) }; Concat((0..size) .map(|_| { gen_expr(g, depth + 1, ExprType::NoSequences) }) .collect()) } 14 => { let size = { let s = g.size(); g.gen_range(2, s) }; Alternate((0..size) .map(|_| { gen_expr(g, depth + 1, ExprType::NoSequences) }) .collect()) } _ => unreachable!() } } fn gen_repeatable_expr(g: &mut G, depth: u32) -> Expr { use Expr::*; match g.gen_range(1, 6) { 0 => Empty, 1 => Literal { chars: vec![Arbitrary::arbitrary(g)], casei: g.gen(), }, 2 => AnyChar, 3 => AnyCharNoNL, 4 => Class(CharClass::arbitrary(g)), 5 => gen_group_expr(g, depth + 1), _ => unreachable!(), } } fn gen_group_expr(g: &mut G, depth: u32) -> Expr { let (i, name) = if g.gen() { (None, None) } else { (Some(0), if g.gen() { Some(SmallAscii::arbitrary(g).0) } else { None }) }; Expr::Group { e: Box::new(gen_expr(g, depth + 1, ExprType::Anything)), i: i, name: name, } } fn fix_capture_indices(e: Expr) -> Expr { fn bx(e: Expr) -> Box { Box::new(e) } fn fix(e: Expr, capi: &mut usize, names: &mut Vec) -> Expr { use Expr::*; match e { Group { e, i: Some(_), mut name } => { *capi += 1; let i = *capi; let mut dupe_name = false; if let Some(ref n1) = name { if names.iter().any(|n2| n1 == n2) { dupe_name = true; } else { names.push(n1.clone()); } } if dupe_name { name = None; } Group { e: bx(fix(*e, capi, names)), i: Some(i), name: name } } Group { e, i, name } => { Group { e: bx(fix(*e, capi, names)), i: i, name: name } } Repeat { e, r, greedy } => { Repeat { e: bx(fix(*e, capi, names)), r: r, greedy: greedy } } Concat(es) => Concat(es.into_iter().map(|e| fix(e, capi, names)).collect()), Alternate(es) => Alternate(es.into_iter().map(|e| fix(e, capi, names)).collect()), e => e, } } fix(e, &mut 0, &mut vec![]) } impl Arbitrary for Repeater { fn arbitrary(g: &mut G) -> Repeater { use Repeater::*; match g.gen_range(0, 4) { 0 => ZeroOrOne, 1 => ZeroOrMore, 2 => OneOrMore, 3 => { use std::cmp::{max, min}; let n1 = Arbitrary::arbitrary(g); let n2 = Arbitrary::arbitrary(g); Range { min: min(n1, n2), max: if g.gen() { None } else { Some(max(n1, n2)) }, } }, _ => unreachable!(), } } fn shrink(&self) -> Box> { use Repeater::*; match *self { ZeroOrOne | ZeroOrMore | OneOrMore => Box::new(None.into_iter()), Range { min, max } => { Box::new((min, max) .shrink() .map(|(min, max)| Range { min: min, max: max })) } } } } impl Arbitrary for CharClass { fn arbitrary(g: &mut G) -> CharClass { let mut ranges: Vec = Arbitrary::arbitrary(g); if ranges.is_empty() { ranges.push(Arbitrary::arbitrary(g)); } let cls = CharClass { ranges: ranges }.canonicalize(); if g.gen() { cls.case_fold() } else { cls } } fn shrink(&self) -> Box> { Box::new(self.ranges.clone() .shrink() .filter(|ranges| ranges.len() > 0) .map(|ranges| CharClass { ranges: ranges }.canonicalize())) } } impl Arbitrary for ClassRange { fn arbitrary(g: &mut G) -> ClassRange { use std::char::from_u32; ClassRange::new( from_u32(g.gen_range(97, 123)).unwrap(), from_u32(g.gen_range(97, 123)).unwrap(), ) } fn shrink(&self) -> Box> { Box::new((self.start, self.end) .shrink().map(|(s, e)| ClassRange::new(s, e))) } } #[test] fn display_regex_roundtrips() { // Given an AST, if we print it as a regex and then re-parse it, do we // get back the same AST? // A lot of this relies crucially on regex simplification. So this is // testing `Expr::simplify` as much as it is testing the `Display` impl. fn prop(e: Expr) -> bool { e == Expr::parse(&e.to_string()).unwrap() } QuickCheck::new() .tests(10_000) .max_tests(20_000) .gen(StdGen::new(::rand::thread_rng(), 50)) .quickcheck(prop as fn(Expr) -> bool); } deps/regex-syntax-0.2.2/src/lib.rs0000644000175000001440000011673112553257506015030 0ustar users// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. /*! This crate provides a regular expression parser and an abstract syntax for regular expressions. The abstract syntax is defined by the `Expr` type. The concrete syntax is enumerated in the [`regex`](../regex/index.html#syntax) crate documentation. Note that since this crate is first and foremost an implementation detail for the `regex` crate, it may experience more frequent breaking changes. It is exposed as a separate crate so that others may use it to do analysis on regular expressions or even build their own matching engine. # Example: parsing an expression Parsing a regular expression can be done with the `Expr::parse` function. ```rust use regex_syntax::Expr; assert_eq!(Expr::parse(r"ab|yz").unwrap(), Expr::Alternate(vec![ Expr::Literal { chars: vec!['a', 'b'], casei: false }, Expr::Literal { chars: vec!['y', 'z'], casei: false }, ])); ``` # Example: inspecting an error The parser in this crate provides very detailed error values. For example, if an invalid character class range is given: ```rust use regex_syntax::{Expr, ErrorKind}; let err = Expr::parse(r"[z-a]").unwrap_err(); assert_eq!(err.position(), 4); assert_eq!(err.kind(), &ErrorKind::InvalidClassRange { start: 'z', end: 'a', }); ``` Or unbalanced parentheses: ```rust use regex_syntax::{Expr, ErrorKind}; let err = Expr::parse(r"ab(cd").unwrap_err(); assert_eq!(err.position(), 2); assert_eq!(err.kind(), &ErrorKind::UnclosedParen); ``` */ #![deny(missing_docs)] #[cfg(test)] extern crate quickcheck; #[cfg(test)] extern crate rand; mod parser; mod unicode; use std::char; use std::cmp::{Ordering, max, min}; use std::fmt; use std::iter::IntoIterator; use std::ops::Deref; use std::result; use std::slice; use std::vec; use unicode::case_folding; use self::Expr::*; use self::Repeater::*; pub use parser::is_punct; /// A regular expression abstract syntax tree. /// /// An `Expr` represents the abstract syntax of a regular expression. #[derive(Clone, Debug, PartialEq, Eq)] pub enum Expr { /// An empty regex (which never matches any text). Empty, /// A sequence of one or more literal characters to be matched. Literal { /// The characters. chars: Vec, /// Whether to match case insensitively. casei: bool, }, /// Match any character, excluding new line. AnyChar, /// Match any character. AnyCharNoNL, /// A character class. Class(CharClass), /// Match the start of a line or beginning of input. StartLine, /// Match the end of a line or end of input. EndLine, /// Match the beginning of input. StartText, /// Match the end of input. EndText, /// Match a word boundary (word character on one side and a non-word /// character on the other). WordBoundary, /// Match a position that is not a word boundary (word or non-word /// characters on both sides). NotWordBoundary, /// A group, possibly non-capturing. Group { /// The expression inside the group. e: Box, /// The capture index (starting at `1`) only for capturing groups. i: Option, /// The capture name, only for capturing named groups. name: Option, }, /// A repeat operator (`?`, `*`, `+` or `{m,n}`). Repeat { /// The expression to be repeated. Limited to literals, `.`, classes /// or grouped expressions. e: Box, /// The type of repeat operator used. r: Repeater, /// Whether the repeat is greedy (match the most) or not (match the /// least). greedy: bool, }, /// A concatenation of expressions. Must be matched one after the other. /// /// N.B. A concat expression can only appear at the top-level or /// immediately inside a group expression. Concat(Vec), /// An alternation of expressions. Only one must match. /// /// N.B. An alternate expression can only appear at the top-level or /// immediately inside a group expression. Alternate(Vec), } type CaptureIndex = Option; type CaptureName = Option; /// The type of a repeat operator expression. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Repeater { /// Match zero or one (`?`). ZeroOrOne, /// Match zero or more (`*`). ZeroOrMore, /// Match one or more (`+`). OneOrMore, /// Match for at least `min` and at most `max` (`{m,n}`). /// /// When `max` is `None`, there is no upper bound on the number of matches. Range { /// Lower bound on the number of matches. min: u32, /// Optional upper bound on the number of matches. max: Option, }, } /// A character class. /// /// A character class has a canonical format that the parser guarantees. Its /// canonical format is defined by the following invariants: /// /// 1. Given any Unicode scalar value, it is matched by *at most* one character /// range in a canonical character class. /// 2. Every adjacent character range is separated by at least one Unicode /// scalar value. /// 3. Given any pair of character ranges `r1` and `r2`, if /// `r1.end < r2.start`, then `r1` comes before `r2` in a canonical /// character class. /// /// In sum, any `CharClass` produced by this crate's parser is a sorted /// sequence of non-overlapping ranges. This makes it possible to test whether /// a character is matched by a class with a binary search. /// /// Additionally, a character class may be marked *case insensitive*. If it's /// case insensitive, then: /// /// 1. Simple case folding has been applied to all ranges. /// 2. Simple case folding must be applied to a character before testing /// whether it matches the character class. #[derive(Clone, Debug, PartialEq, Eq)] pub struct CharClass { ranges: Vec, } /// A single inclusive range in a character class. /// /// Since range boundaries are defined by Unicode scalar values, the boundaries /// can never be in the open interval `(0xD7FF, 0xE000)`. However, a range may /// *cover* codepoints that are not scalar values. /// /// Note that this has a few convenient impls on `PartialEq` and `PartialOrd` /// for testing whether a character is contained inside a given range. #[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Eq, Ord)] pub struct ClassRange { /// The start character of the range. /// /// This must be less than or equal to `end`. pub start: char, /// The end character of the range. /// /// This must be greater than or equal to `end`. pub end: char, } impl Expr { /// Parses a string in a regular expression syntax tree. pub fn parse(s: &str) -> Result { parser::Parser::parse(s).map(|e| e.simplify()) } /// Returns true iff the expression can be repeated by a quantifier. fn can_repeat(&self) -> bool { match *self { Literal{..} | AnyChar | AnyCharNoNL | Class(_) | StartLine | EndLine | StartText | EndText | WordBoundary | NotWordBoundary | Group{..} => true, _ => false, } } fn simplify(self) -> Expr { fn combine_literals(es: &mut Vec, e: Expr) { match (es.pop(), e) { (None, e) => es.push(e), (Some(Literal { chars: mut chars1, casei: casei1 }), Literal { chars: chars2, casei: casei2 }) => { if casei1 == casei2 { chars1.extend(chars2); es.push(Literal { chars: chars1, casei: casei1 }); } else { es.push(Literal { chars: chars1, casei: casei1 }); es.push(Literal { chars: chars2, casei: casei2 }); } } (Some(e1), e2) => { es.push(e1); es.push(e2); } } } match self { Repeat { e, r, greedy } => Repeat { e: Box::new(e.simplify()), r: r, greedy: greedy, }, Group { e, i, name } => { let e = e.simplify(); if i.is_none() && name.is_none() && e.can_repeat() { e } else { Group { e: Box::new(e), i: i, name: name } } } Concat(es) => { let mut new_es = Vec::with_capacity(es.len()); for e in es { combine_literals(&mut new_es, e.simplify()); } if new_es.len() == 1 { new_es.pop().unwrap() } else { Concat(new_es) } } Alternate(es) => Alternate(es.into_iter() .map(|e| e.simplify()) .collect()), e => e, } } } impl Deref for CharClass { type Target = Vec; fn deref(&self) -> &Vec { &self.ranges } } impl IntoIterator for CharClass { type Item = ClassRange; type IntoIter = vec::IntoIter; fn into_iter(self) -> vec::IntoIter { self.ranges.into_iter() } } impl<'a> IntoIterator for &'a CharClass { type Item = &'a ClassRange; type IntoIter = slice::Iter<'a, ClassRange>; fn into_iter(self) -> slice::Iter<'a, ClassRange> { self.iter() } } impl CharClass { /// Create a new class from an existing set of ranges. pub fn new(ranges: Vec) -> CharClass { CharClass { ranges: ranges } } /// Create an empty class. fn empty() -> CharClass { CharClass::new(Vec::new()) } /// Returns true if `c` is matched by this character class. pub fn matches(&self, c: char) -> bool { self.binary_search_by(|range| c.partial_cmp(range).unwrap()).is_ok() } /// Create a new empty class from this one. /// /// Namely, its capacity and case insensitive setting will be the same. fn to_empty(&self) -> CharClass { CharClass { ranges: Vec::with_capacity(self.len()) } } /// Merge two classes and canonicalize them. #[cfg(test)] fn merge(mut self, other: CharClass) -> CharClass { self.ranges.extend(other); self.canonicalize() } /// Canonicalze any sequence of ranges. /// /// This is responsible for enforcing the canonical format invariants /// as described on the docs for the `CharClass` type. fn canonicalize(mut self) -> CharClass { // TODO: Save some cycles here by checking if already canonicalized. self.ranges.sort(); let mut ordered = self.to_empty(); // TODO: Do this in place? for candidate in self { // If the candidate overlaps with an existing range, then it must // be the most recent range added because we process the candidates // in order. if let Some(or) = ordered.ranges.last_mut() { if or.overlapping(candidate) { *or = or.merge(candidate); continue; } } ordered.ranges.push(candidate); } ordered } /// Negates the character class. /// /// For all `c` where `c` is a Unicode scalar value, `c` matches `self` /// if and only if `c` does not match `self.negate()`. pub fn negate(mut self) -> CharClass { fn range(s: char, e: char) -> ClassRange { ClassRange::new(s, e) } if self.is_empty() { return self; } self = self.canonicalize(); let mut inv = self.to_empty(); if self[0].start > '\x00' { inv.ranges.push(range('\x00', dec_char(self[0].start))); } for win in self.windows(2) { inv.ranges.push(range(inc_char(win[0].end), dec_char(win[1].start))); } if self[self.len() - 1].end < char::MAX { inv.ranges.push(range(inc_char(self[self.len() - 1].end), char::MAX)); } inv } /// Apply case folding to this character class. /// /// N.B. Applying case folding to a negated character class probably /// won't produce the expected result. e.g., `(?i)[^x]` really should /// match any character sans `x` and `X`, but if `[^x]` is negated /// before being case folded, you'll end up matching any character. pub fn case_fold(self) -> CharClass { let mut folded = self.to_empty(); for r in self { // Applying case folding to a range is expensive because *every* // character needs to be examined. Thus, we avoid that drudgery // if no character in the current range is in our case folding // table. if r.needs_case_folding() { folded.ranges.extend(r.case_fold()); } folded.ranges.push(r); } folded.canonicalize() } } impl ClassRange { /// Create a new class range. /// /// If `end < start`, then the two values are swapped so that /// the invariant `start <= end` is preserved. fn new(start: char, end: char) -> ClassRange { if start <= end { ClassRange { start: start, end: end } } else { ClassRange { start: end, end: start } } } /// Create a range of one character. fn one(c: char) -> ClassRange { ClassRange { start: c, end: c } } /// Returns true if and only if the two ranges are overlapping. Note that /// since ranges are inclusive, `a-c` and `d-f` are overlapping! fn overlapping(self, other: ClassRange) -> bool { max(self.start, other.start) <= inc_char(min(self.end, other.end)) } /// Creates a new range representing the union of `self` and `other. fn merge(self, other: ClassRange) -> ClassRange { ClassRange { start: min(self.start, other.start), end: max(self.end, other.end), } } /// Returns true if and only if this range contains a character that is /// in the case folding table. fn needs_case_folding(self) -> bool { case_folding::C_plus_S_both_table .binary_search_by(|&(c, _)| self.partial_cmp(&c).unwrap()).is_ok() } /// Apply case folding to this range. /// /// Since case folding might add characters such that the range is no /// longer contiguous, this returns multiple class ranges. They are in /// canonical order. fn case_fold(self) -> Vec { let table = &case_folding::C_plus_S_both_table; let (s, e) = (self.start as u32, self.end as u32 + 1); let mut start = self.start; let mut end = start; let mut next_case_fold = '\x00'; let mut ranges = Vec::with_capacity(10); for mut c in (s..e).filter_map(char::from_u32) { if c >= next_case_fold { c = match simple_case_fold_both_result(c) { Ok(i) => { for &(c1, c2) in &table[i..] { if c1 != c { break; } if c2 != inc_char(end) { ranges.push(ClassRange::new(start, end)); start = c2; } end = c2; } continue; } Err(i) => { if i < table.len() { next_case_fold = table[i].0; } else { next_case_fold = '\u{10FFFF}'; } c } }; } // The fast path. We know this character doesn't have an entry // in the case folding table. if c != inc_char(end) { ranges.push(ClassRange::new(start, end)); start = c; } end = c; } ranges.push(ClassRange::new(start, end)); ranges } } impl PartialEq for ClassRange { #[inline] fn eq(&self, other: &char) -> bool { self.start <= *other && *other <= self.end } } impl PartialEq for char { #[inline] fn eq(&self, other: &ClassRange) -> bool { other.eq(self) } } impl PartialOrd for ClassRange { #[inline] fn partial_cmp(&self, other: &char) -> Option { Some(if self == other { Ordering::Equal } else if *other > self.end { Ordering::Greater } else { Ordering::Less }) } } impl PartialOrd for char { #[inline] fn partial_cmp(&self, other: &ClassRange) -> Option { other.partial_cmp(self).map(|o| o.reverse()) } } /// This implementation of `Display` will write a regular expression from the /// syntax tree. It does not write the original string parsed. impl fmt::Display for Expr { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Empty => write!(f, ""), Literal { ref chars, casei } => { if casei { try!(write!(f, "(?i:")); } for &c in chars { try!(write!(f, "{}", quote_char(c))); } if casei { try!(write!(f, ")")); } Ok(()) } AnyChar => write!(f, "(?s:.)"), AnyCharNoNL => write!(f, "."), Class(ref cls) => write!(f, "{}", cls), StartLine => write!(f, "(?m:^)"), EndLine => write!(f, "(?m:$)"), StartText => write!(f, r"^"), EndText => write!(f, r"$"), WordBoundary => write!(f, r"\b"), NotWordBoundary => write!(f, r"\B"), Group { ref e, i: None, name: None } => write!(f, "(?:{})", e), Group { ref e, name: None, .. } => write!(f, "({})", e), Group { ref e, name: Some(ref n), .. } => { write!(f, "(?P<{}>{})", n, e) } Repeat { ref e, r, greedy } => { match &**e { &Literal { ref chars, .. } if chars.len() > 1 => { try!(write!(f, "(?:{}){}", e, r)) } _ => try!(write!(f, "{}{}", e, r)), } if !greedy { try!(write!(f, "?")); } Ok(()) } Concat(ref es) => { for e in es { try!(write!(f, "{}", e)); } Ok(()) } Alternate(ref es) => { for (i, e) in es.iter().enumerate() { if i > 0 { try!(write!(f, "|")); } try!(write!(f, "{}", e)); } Ok(()) } } } } impl fmt::Display for Repeater { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { ZeroOrOne => write!(f, "?"), ZeroOrMore => write!(f, "*"), OneOrMore => write!(f, "+"), Range { min: s, max: None } => write!(f, "{{{},}}", s), Range { min: s, max: Some(e) } if s == e => write!(f, "{{{}}}", s), Range { min: s, max: Some(e) } => write!(f, "{{{}, {}}}", s, e), } } } impl fmt::Display for CharClass { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { try!(write!(f, "[")); for range in self.iter() { try!(write!(f, "{}", range)); } try!(write!(f, "]")); Ok(()) } } impl fmt::Display for ClassRange { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}-{}", quote_char(self.start), quote_char(self.end)) } } /// An alias for computations that can return a `Error`. pub type Result = ::std::result::Result; /// A parse error. /// /// This includes details about the specific type of error and a rough /// approximation of where it occurred. #[derive(Clone, Debug, PartialEq)] pub struct Error { pos: usize, surround: String, kind: ErrorKind, } /// The specific type of parse error that can occur. #[derive(Clone, Debug, PartialEq)] pub enum ErrorKind { /// A negation symbol is used twice in flag settings. /// e.g., `(?-i-s)`. DoubleFlagNegation, /// The same capture name was used more than once. /// e.g., `(?P.)(?P.)`. DuplicateCaptureName(String), /// An alternate is empty. e.g., `(|a)`. EmptyAlternate, /// A capture group name is empty. e.g., `(?P<>a)`. EmptyCaptureName, /// A negation symbol was not proceded by any flags. e.g., `(?i-)`. EmptyFlagNegation, /// A group is empty. e.g., `()`. EmptyGroup, /// An invalid number was used in a counted repetition. e.g., `a{b}`. InvalidBase10(String), /// An invalid hexadecimal number was used in an escape sequence. /// e.g., `\xAG`. InvalidBase16(String), /// An invalid capture name was used. e.g., `(?P<0a>b)`. InvalidCaptureName(String), /// An invalid class range was givien. Specifically, when the start of the /// range is greater than the end. e.g., `[z-a]`. InvalidClassRange { /// The first character specified in the range. start: char, /// The second character specified in the range. end: char, }, /// An escape sequence was used in a character class where it is not /// allowed. e.g., `[a-\pN]` or `[\A]`. InvalidClassEscape(Expr), /// An invalid counted repetition min/max was given. e.g., `a{2,1}`. InvalidRepeatRange { /// The first number specified in the repetition. min: u32, /// The second number specified in the repetition. max: u32, }, /// An invalid Unicode scalar value was used in a long hexadecimal /// sequence. e.g., `\x{D800}`. InvalidScalarValue(u32), /// An empty counted repetition operator. e.g., `a{}`. MissingBase10, /// A repetition operator was not applied to an expression. e.g., `*`. RepeaterExpectsExpr, /// A repetition operator was applied to an expression that cannot be /// repeated. e.g., `a+*` or `a|*`. RepeaterUnexpectedExpr(Expr), /// A capture group name that is never closed. e.g., `(?P usize { self.pos } /// Returns the type of the regex parse error. pub fn kind(&self) -> &ErrorKind { &self.kind } } impl ErrorKind { fn description(&self) -> &str { use ErrorKind::*; match *self { DoubleFlagNegation => "double flag negation", DuplicateCaptureName(_) => "duplicate capture name", EmptyAlternate => "empty alternate", EmptyCaptureName => "empty capture name", EmptyFlagNegation => "flag negation without any flags", EmptyGroup => "empty group (e.g., '()')", InvalidBase10(_) => "invalid base 10 number", InvalidBase16(_) => "invalid base 16 number", InvalidCaptureName(_) => "invalid capture name", InvalidClassRange{..} => "invalid character class range", InvalidClassEscape(_) => "invalid escape sequence in class", InvalidRepeatRange{..} => "invalid counted repetition range", InvalidScalarValue(_) => "invalid Unicode scalar value", MissingBase10 => "missing count in repetition operator", RepeaterExpectsExpr => "repetition operator missing expression", RepeaterUnexpectedExpr(_) => "expression cannot be repeated", UnclosedCaptureName(_) => "unclosed capture group name", UnclosedHex => "unclosed hexadecimal literal", UnclosedParen => "unclosed parenthesis", UnclosedRepeat => "unclosed counted repetition operator", UnclosedUnicodeName => "unclosed Unicode class literal", UnexpectedClassEof => "unexpected EOF in character class", UnexpectedEscapeEof => "unexpected EOF in escape sequence", UnexpectedFlagEof => "unexpected EOF in flags", UnexpectedTwoDigitHexEof => "unexpected EOF in hex literal", UnopenedParen => "unopened parenthesis", UnrecognizedEscape(_) => "unrecognized escape sequence", UnrecognizedFlag(_) => "unrecognized flag", UnrecognizedUnicodeClass(_) => "unrecognized Unicode class name", __Nonexhaustive => unreachable!(), } } } impl ::std::error::Error for Error { fn description(&self) -> &str { self.kind.description() } } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Error parsing regex near '{}' at character offset {}: {}", self.surround, self.pos, self.kind) } } impl fmt::Display for ErrorKind { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use ErrorKind::*; match *self { DoubleFlagNegation => write!(f, "Only one negation symbol is allowed in flags."), DuplicateCaptureName(ref s) => write!(f, "Capture name '{}' is used more than once.", s), EmptyAlternate => write!(f, "Alternations cannot be empty."), EmptyCaptureName => write!(f, "Capture names cannot be empty."), EmptyFlagNegation => write!(f, "Flag negation requires setting at least one flag."), EmptyGroup => write!(f, "Empty regex groups (e.g., '()') are not allowed."), InvalidBase10(ref s) => write!(f, "Not a valid base 10 number: '{}'", s), InvalidBase16(ref s) => write!(f, "Not a valid base 16 number: '{}'", s), InvalidCaptureName(ref s) => write!(f, "Invalid capture name: '{}'. Capture names must \ consist of [_a-zA-Z0-9] and are not allowed to \ start with with a number.", s), InvalidClassRange { start, end } => write!(f, "Invalid character class range '{}-{}'. \ Character class ranges must start with the smaller \ character, but {} > {}", start, end, start, end), InvalidClassEscape(ref e) => write!(f, "Invalid escape sequence in character \ class: '{}'.", e), InvalidRepeatRange { min, max } => write!(f, "Invalid counted repetition range: {{{}, {}}}. \ Counted repetition ranges must start with the \ minimum, but {} > {}", min, max, min, max), InvalidScalarValue(c) => write!(f, "Number does not correspond to a Unicode scalar \ value: '{}'.", c), MissingBase10 => write!(f, "Missing maximum in counted reptition operator."), RepeaterExpectsExpr => write!(f, "Missing expression for reptition operator."), RepeaterUnexpectedExpr(ref e) => write!(f, "Invalid application of reptition operator to: \ '{}'.", e), UnclosedCaptureName(ref s) => write!(f, "Capture name group for '{}' is not closed. \ (Missing a '>'.)", s), UnclosedHex => write!(f, "Unclosed hexadecimal literal (missing a '}}')."), UnclosedParen => write!(f, "Unclosed parenthesis."), UnclosedRepeat => write!(f, "Unclosed counted repetition (missing a '}}')."), UnclosedUnicodeName => write!(f, "Unclosed Unicode literal (missing a '}}')."), UnexpectedClassEof => write!(f, "Character class was not closed before the end of \ the regex (missing a ']')."), UnexpectedEscapeEof => write!(f, "Started an escape sequence that didn't finish \ before the end of the regex."), UnexpectedFlagEof => write!(f, "Inline flag settings was not closed before the end \ of the regex (missing a ')' or ':')."), UnexpectedTwoDigitHexEof => write!(f, "Unexpected end of two digit hexadecimal literal."), UnopenedParen => write!(f, "Unopened parenthesis."), UnrecognizedEscape(c) => write!(f, "Unrecognized escape sequence: '\\{}'.", c), UnrecognizedFlag(c) => write!(f, "Unrecognized flag: '{}'. \ (Allowed flags: i, s, m, U, x.)", c), UnrecognizedUnicodeClass(ref s) => write!(f, "Unrecognized Unicode class name: '{}'.", s), __Nonexhaustive => unreachable!(), } } } /// The result of binary search on the simple case folding table. /// /// Note that this binary search is done on the "both" table, such that /// the index returned corresponds to the *first* location of `c1` in the /// table. The table can then be scanned linearly starting from the position /// returned to find other case mappings for `c1`. fn simple_case_fold_both_result(c1: char) -> result::Result { let table = &case_folding::C_plus_S_both_table; let i = binary_search(table, |&(c2, _)| c1 <= c2); if i >= table.len() || table[i].0 != c1 { Err(i) } else { Ok(i) } } /// Binary search to find first element such that `pred(T) == true`. /// /// Assumes that if `pred(xs[i]) == true` then `pred(xs[i+1]) == true`. /// /// If all elements yield `pred(T) == false`, then `xs.len()` is returned. fn binary_search(xs: &[T], mut pred: F) -> usize where F: FnMut(&T) -> bool { let (mut left, mut right) = (0, xs.len()); while left < right { let mid = (left + right) / 2; if pred(&xs[mid]) { right = mid; } else { left = mid + 1; } } left } /// Escapes all regular expression meta characters in `text`. /// /// The string returned may be safely used as a literal in a regular /// expression. pub fn quote(text: &str) -> String { let mut quoted = String::with_capacity(text.len()); for c in text.chars() { if parser::is_punct(c) { quoted.push('\\'); } quoted.push(c); } quoted } fn quote_char(c: char) -> String { let mut s = String::new(); if parser::is_punct(c) { s.push('\\'); } s.push(c); s } fn inc_char(c: char) -> char { match c { char::MAX => char::MAX, '\u{D7FF}' => '\u{E000}', c => char::from_u32(c as u32 + 1).unwrap(), } } fn dec_char(c: char) -> char { match c { '\x00' => '\x00', '\u{E000}' => '\u{D7FF}', c => char::from_u32(c as u32 - 1).unwrap(), } } /// Returns true if and only if `c` is a word character. #[doc(hidden)] pub fn is_word_char(c: char) -> bool { match c { '_' | '0' ... '9' | 'a' ... 'z' | 'A' ... 'Z' => true, _ => ::unicode::regex::PERLW.binary_search_by(|&(start, end)| { if c >= start && c <= end { Ordering::Equal } else if start > c { Ordering::Greater } else { Ordering::Less } }).is_ok(), } } #[cfg(test)] mod properties; #[cfg(test)] mod tests { use {CharClass, ClassRange}; fn class(ranges: &[(char, char)]) -> CharClass { let ranges = ranges.iter().cloned() .map(|(c1, c2)| ClassRange::new(c1, c2)).collect(); CharClass::new(ranges) } fn classi(ranges: &[(char, char)]) -> CharClass { class(ranges) } #[test] fn class_canon_no_change() { let cls = class(&[('a', 'c'), ('x', 'z')]); assert_eq!(cls.clone().canonicalize(), cls); } #[test] fn class_canon_unordered() { let cls = class(&[('x', 'z'), ('a', 'c')]); assert_eq!(cls.canonicalize(), class(&[ ('a', 'c'), ('x', 'z'), ])); } #[test] fn class_canon_overlap() { let cls = class(&[('x', 'z'), ('w', 'y')]); assert_eq!(cls.canonicalize(), class(&[ ('w', 'z'), ])); } #[test] fn class_canon_overlap_many() { let cls = class(&[ ('c', 'f'), ('a', 'g'), ('d', 'j'), ('a', 'c'), ('m', 'p'), ('l', 's'), ]); assert_eq!(cls.clone().canonicalize(), class(&[ ('a', 'j'), ('l', 's'), ])); } #[test] fn class_canon_overlap_many_case_fold() { let cls = class(&[ ('C', 'F'), ('A', 'G'), ('D', 'J'), ('A', 'C'), ('M', 'P'), ('L', 'S'), ('c', 'f'), ]); assert_eq!(cls.case_fold(), classi(&[ ('A', 'J'), ('L', 'S'), ('a', 'j'), ('l', 's'), ('\u{17F}', '\u{17F}'), ])); } #[test] fn class_canon_overlap_boundary() { let cls = class(&[('x', 'z'), ('u', 'w')]); assert_eq!(cls.canonicalize(), class(&[ ('u', 'z'), ])); } #[test] fn class_canon_extreme_edge_case() { let cls = class(&[('\x00', '\u{10FFFF}'), ('\x00', '\u{10FFFF}')]); assert_eq!(cls.canonicalize(), class(&[ ('\x00', '\u{10FFFF}'), ])); } #[test] fn class_canon_singles() { let cls = class(&[('a', 'a'), ('b', 'b')]); assert_eq!(cls.canonicalize(), class(&[('a', 'b')])); } #[test] fn class_negate_single() { let cls = class(&[('a', 'a')]); assert_eq!(cls.negate(), class(&[ ('\x00', '\x60'), ('\x62', '\u{10FFFF}'), ])); } #[test] fn class_negate_singles() { let cls = class(&[('a', 'a'), ('b', 'b')]); assert_eq!(cls.negate(), class(&[ ('\x00', '\x60'), ('\x63', '\u{10FFFF}'), ])); } #[test] fn class_negate_multiples() { let cls = class(&[('a', 'c'), ('x', 'z')]); assert_eq!(cls.negate(), class(&[ ('\x00', '\x60'), ('\x64', '\x77'), ('\x7b', '\u{10FFFF}'), ])); } #[test] fn class_negate_min_scalar() { let cls = class(&[('\x00', 'a')]); assert_eq!(cls.negate(), class(&[ ('\x62', '\u{10FFFF}'), ])); } #[test] fn class_negate_max_scalar() { let cls = class(&[('a', '\u{10FFFF}')]); assert_eq!(cls.negate(), class(&[ ('\x00', '\x60'), ])); } #[test] fn class_negate_everything() { let cls = class(&[('\x00', '\u{10FFFF}')]); assert_eq!(cls.negate(), class(&[])); } #[test] fn class_negate_everything_sans_one() { let cls = class(&[ ('\x00', '\u{10FFFD}'), ('\u{10FFFF}', '\u{10FFFF}') ]); assert_eq!(cls.negate(), class(&[ ('\u{10FFFE}', '\u{10FFFE}'), ])); } #[test] fn class_negate_surrogates_min() { let cls = class(&[('\x00', '\u{D7FF}')]); assert_eq!(cls.negate(), class(&[ ('\u{E000}', '\u{10FFFF}'), ])); } #[test] fn class_negate_surrogates_min_edge() { let cls = class(&[('\x00', '\u{D7FE}')]); assert_eq!(cls.negate(), class(&[ ('\u{D7FF}', '\u{10FFFF}'), ])); } #[test] fn class_negate_surrogates_max() { let cls = class(&[('\u{E000}', '\u{10FFFF}')]); assert_eq!(cls.negate(), class(&[ ('\x00', '\u{D7FF}'), ])); } #[test] fn class_negate_surrogates_max_edge() { let cls = class(&[('\u{E001}', '\u{10FFFF}')]); assert_eq!(cls.negate(), class(&[ ('\x00', '\u{E000}'), ])); } #[test] fn class_fold_az() { let cls = class(&[('A', 'Z')]); assert_eq!(cls.case_fold(), classi(&[ ('A', 'Z'), ('a', 'z'), ('\u{17F}', '\u{17F}'), ('\u{212A}', '\u{212A}'), ])); let cls = class(&[('a', 'z')]); assert_eq!(cls.case_fold(), classi(&[ ('A', 'Z'), ('a', 'z'), ('\u{17F}', '\u{17F}'), ('\u{212A}', '\u{212A}'), ])); } #[test] fn class_fold_a_underscore() { let cls = class(&[('A', 'A'), ('_', '_')]); assert_eq!(cls.clone().canonicalize(), class(&[ ('A', 'A'), ('_', '_'), ])); assert_eq!(cls.case_fold(), classi(&[ ('A', 'A'), ('_', '_'), ('a', 'a'), ])); } #[test] fn class_fold_a_equals() { let cls = class(&[('A', 'A'), ('=', '=')]); assert_eq!(cls.clone().canonicalize(), class(&[ ('=', '='), ('A', 'A'), ])); assert_eq!(cls.case_fold(), classi(&[ ('=', '='), ('A', 'A'), ('a', 'a'), ])); } #[test] fn class_fold_no_folding_needed() { let cls = class(&[('\x00', '\x10')]); assert_eq!(cls.case_fold(), classi(&[ ('\x00', '\x10'), ])); } #[test] fn class_fold_negated() { let cls = class(&[('x', 'x')]); assert_eq!(cls.clone().case_fold(), classi(&[ ('X', 'X'), ('x', 'x'), ])); assert_eq!(cls.case_fold().negate(), classi(&[ ('\x00', 'W'), ('Y', 'w'), ('y', '\u{10FFFF}'), ])); } #[test] fn class_fold_single_to_multiple() { let cls = class(&[('k', 'k')]); assert_eq!(cls.case_fold(), classi(&[ ('K', 'K'), ('k', 'k'), ('\u{212A}', '\u{212A}'), ])); } } deps/regex-syntax-0.2.2/src/unicode.rs0000644000175000001440000140525612553257506015714 0ustar users// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // NOTE: The following code was generated by "scripts/unicode.py", do not edit // directly #![allow(warnings)] pub mod general_category { pub const C_table: &'static [(char, char)] = &[ ('\u{0}', '\u{1f}'), ('\u{7f}', '\u{9f}'), ('\u{ad}', '\u{ad}'), ('\u{378}', '\u{379}'), ('\u{380}', '\u{383}'), ('\u{38b}', '\u{38b}'), ('\u{38d}', '\u{38d}'), ('\u{3a2}', '\u{3a2}'), ('\u{530}', '\u{530}'), ('\u{557}', '\u{558}'), ('\u{560}', '\u{560}'), ('\u{588}', '\u{588}'), ('\u{58b}', '\u{58c}'), ('\u{590}', '\u{590}'), ('\u{5c8}', '\u{5cf}'), ('\u{5eb}', '\u{5ef}'), ('\u{5f5}', '\u{605}'), ('\u{61c}', '\u{61d}'), ('\u{6dd}', '\u{6dd}'), ('\u{70e}', '\u{70f}'), ('\u{74b}', '\u{74c}'), ('\u{7b2}', '\u{7bf}'), ('\u{7fb}', '\u{7ff}'), ('\u{82e}', '\u{82f}'), ('\u{83f}', '\u{83f}'), ('\u{85c}', '\u{85d}'), ('\u{85f}', '\u{89f}'), ('\u{8b5}', '\u{8e2}'), ('\u{984}', '\u{984}'), ('\u{98d}', '\u{98e}'), ('\u{991}', '\u{992}'), ('\u{9a9}', '\u{9a9}'), ('\u{9b1}', '\u{9b1}'), ('\u{9b3}', '\u{9b5}'), ('\u{9ba}', '\u{9bb}'), ('\u{9c5}', '\u{9c6}'), ('\u{9c9}', '\u{9ca}'), ('\u{9cf}', '\u{9d6}'), ('\u{9d8}', '\u{9db}'), ('\u{9de}', '\u{9de}'), ('\u{9e4}', '\u{9e5}'), ('\u{9fc}', '\u{a00}'), ('\u{a04}', '\u{a04}'), ('\u{a0b}', '\u{a0e}'), ('\u{a11}', '\u{a12}'), ('\u{a29}', '\u{a29}'), ('\u{a31}', '\u{a31}'), ('\u{a34}', '\u{a34}'), ('\u{a37}', '\u{a37}'), ('\u{a3a}', '\u{a3b}'), ('\u{a3d}', '\u{a3d}'), ('\u{a43}', '\u{a46}'), ('\u{a49}', '\u{a4a}'), ('\u{a4e}', '\u{a50}'), ('\u{a52}', '\u{a58}'), ('\u{a5d}', '\u{a5d}'), ('\u{a5f}', '\u{a65}'), ('\u{a76}', '\u{a80}'), ('\u{a84}', '\u{a84}'), ('\u{a8e}', '\u{a8e}'), ('\u{a92}', '\u{a92}'), ('\u{aa9}', '\u{aa9}'), ('\u{ab1}', '\u{ab1}'), ('\u{ab4}', '\u{ab4}'), ('\u{aba}', '\u{abb}'), ('\u{ac6}', '\u{ac6}'), ('\u{aca}', '\u{aca}'), ('\u{ace}', '\u{acf}'), ('\u{ad1}', '\u{adf}'), ('\u{ae4}', '\u{ae5}'), ('\u{af2}', '\u{af8}'), ('\u{afa}', '\u{b00}'), ('\u{b04}', '\u{b04}'), ('\u{b0d}', '\u{b0e}'), ('\u{b11}', '\u{b12}'), ('\u{b29}', '\u{b29}'), ('\u{b31}', '\u{b31}'), ('\u{b34}', '\u{b34}'), ('\u{b3a}', '\u{b3b}'), ('\u{b45}', '\u{b46}'), ('\u{b49}', '\u{b4a}'), ('\u{b4e}', '\u{b55}'), ('\u{b58}', '\u{b5b}'), ('\u{b5e}', '\u{b5e}'), ('\u{b64}', '\u{b65}'), ('\u{b78}', '\u{b81}'), ('\u{b84}', '\u{b84}'), ('\u{b8b}', '\u{b8d}'), ('\u{b91}', '\u{b91}'), ('\u{b96}', '\u{b98}'), ('\u{b9b}', '\u{b9b}'), ('\u{b9d}', '\u{b9d}'), ('\u{ba0}', '\u{ba2}'), ('\u{ba5}', '\u{ba7}'), ('\u{bab}', '\u{bad}'), ('\u{bba}', '\u{bbd}'), ('\u{bc3}', '\u{bc5}'), ('\u{bc9}', '\u{bc9}'), ('\u{bce}', '\u{bcf}'), ('\u{bd1}', '\u{bd6}'), ('\u{bd8}', '\u{be5}'), ('\u{bfb}', '\u{bff}'), ('\u{c04}', '\u{c04}'), ('\u{c0d}', '\u{c0d}'), ('\u{c11}', '\u{c11}'), ('\u{c29}', '\u{c29}'), ('\u{c3a}', '\u{c3c}'), ('\u{c45}', '\u{c45}'), ('\u{c49}', '\u{c49}'), ('\u{c4e}', '\u{c54}'), ('\u{c57}', '\u{c57}'), ('\u{c5b}', '\u{c5f}'), ('\u{c64}', '\u{c65}'), ('\u{c70}', '\u{c77}'), ('\u{c80}', '\u{c80}'), ('\u{c84}', '\u{c84}'), ('\u{c8d}', '\u{c8d}'), ('\u{c91}', '\u{c91}'), ('\u{ca9}', '\u{ca9}'), ('\u{cb4}', '\u{cb4}'), ('\u{cba}', '\u{cbb}'), ('\u{cc5}', '\u{cc5}'), ('\u{cc9}', '\u{cc9}'), ('\u{cce}', '\u{cd4}'), ('\u{cd7}', '\u{cdd}'), ('\u{cdf}', '\u{cdf}'), ('\u{ce4}', '\u{ce5}'), ('\u{cf0}', '\u{cf0}'), ('\u{cf3}', '\u{d00}'), ('\u{d04}', '\u{d04}'), ('\u{d0d}', '\u{d0d}'), ('\u{d11}', '\u{d11}'), ('\u{d3b}', '\u{d3c}'), ('\u{d45}', '\u{d45}'), ('\u{d49}', '\u{d49}'), ('\u{d4f}', '\u{d56}'), ('\u{d58}', '\u{d5e}'), ('\u{d64}', '\u{d65}'), ('\u{d76}', '\u{d78}'), ('\u{d80}', '\u{d81}'), ('\u{d84}', '\u{d84}'), ('\u{d97}', '\u{d99}'), ('\u{db2}', '\u{db2}'), ('\u{dbc}', '\u{dbc}'), ('\u{dbe}', '\u{dbf}'), ('\u{dc7}', '\u{dc9}'), ('\u{dcb}', '\u{dce}'), ('\u{dd5}', '\u{dd5}'), ('\u{dd7}', '\u{dd7}'), ('\u{de0}', '\u{de5}'), ('\u{df0}', '\u{df1}'), ('\u{df5}', '\u{e00}'), ('\u{e3b}', '\u{e3e}'), ('\u{e5c}', '\u{e80}'), ('\u{e83}', '\u{e83}'), ('\u{e85}', '\u{e86}'), ('\u{e89}', '\u{e89}'), ('\u{e8b}', '\u{e8c}'), ('\u{e8e}', '\u{e93}'), ('\u{e98}', '\u{e98}'), ('\u{ea0}', '\u{ea0}'), ('\u{ea4}', '\u{ea4}'), ('\u{ea6}', '\u{ea6}'), ('\u{ea8}', '\u{ea9}'), ('\u{eac}', '\u{eac}'), ('\u{eba}', '\u{eba}'), ('\u{ebe}', '\u{ebf}'), ('\u{ec5}', '\u{ec5}'), ('\u{ec7}', '\u{ec7}'), ('\u{ece}', '\u{ecf}'), ('\u{eda}', '\u{edb}'), ('\u{ee0}', '\u{eff}'), ('\u{f48}', '\u{f48}'), ('\u{f6d}', '\u{f70}'), ('\u{f98}', '\u{f98}'), ('\u{fbd}', '\u{fbd}'), ('\u{fcd}', '\u{fcd}'), ('\u{fdb}', '\u{fff}'), ('\u{10c6}', '\u{10c6}'), ('\u{10c8}', '\u{10cc}'), ('\u{10ce}', '\u{10cf}'), ('\u{1249}', '\u{1249}'), ('\u{124e}', '\u{124f}'), ('\u{1257}', '\u{1257}'), ('\u{1259}', '\u{1259}'), ('\u{125e}', '\u{125f}'), ('\u{1289}', '\u{1289}'), ('\u{128e}', '\u{128f}'), ('\u{12b1}', '\u{12b1}'), ('\u{12b6}', '\u{12b7}'), ('\u{12bf}', '\u{12bf}'), ('\u{12c1}', '\u{12c1}'), ('\u{12c6}', '\u{12c7}'), ('\u{12d7}', '\u{12d7}'), ('\u{1311}', '\u{1311}'), ('\u{1316}', '\u{1317}'), ('\u{135b}', '\u{135c}'), ('\u{137d}', '\u{137f}'), ('\u{139a}', '\u{139f}'), ('\u{13f6}', '\u{13f7}'), ('\u{13fe}', '\u{13ff}'), ('\u{169d}', '\u{169f}'), ('\u{16f9}', '\u{16ff}'), ('\u{170d}', '\u{170d}'), ('\u{1715}', '\u{171f}'), ('\u{1737}', '\u{173f}'), ('\u{1754}', '\u{175f}'), ('\u{176d}', '\u{176d}'), ('\u{1771}', '\u{1771}'), ('\u{1774}', '\u{177f}'), ('\u{17de}', '\u{17df}'), ('\u{17ea}', '\u{17ef}'), ('\u{17fa}', '\u{17ff}'), ('\u{180e}', '\u{180f}'), ('\u{181a}', '\u{181f}'), ('\u{1878}', '\u{187f}'), ('\u{18ab}', '\u{18af}'), ('\u{18f6}', '\u{18ff}'), ('\u{191f}', '\u{191f}'), ('\u{192c}', '\u{192f}'), ('\u{193c}', '\u{193f}'), ('\u{1941}', '\u{1943}'), ('\u{196e}', '\u{196f}'), ('\u{1975}', '\u{197f}'), ('\u{19ac}', '\u{19af}'), ('\u{19ca}', '\u{19cf}'), ('\u{19db}', '\u{19dd}'), ('\u{1a1c}', '\u{1a1d}'), ('\u{1a5f}', '\u{1a5f}'), ('\u{1a7d}', '\u{1a7e}'), ('\u{1a8a}', '\u{1a8f}'), ('\u{1a9a}', '\u{1a9f}'), ('\u{1aae}', '\u{1aaf}'), ('\u{1abf}', '\u{1aff}'), ('\u{1b4c}', '\u{1b4f}'), ('\u{1b7d}', '\u{1b7f}'), ('\u{1bf4}', '\u{1bfb}'), ('\u{1c38}', '\u{1c3a}'), ('\u{1c4a}', '\u{1c4c}'), ('\u{1c80}', '\u{1cbf}'), ('\u{1cc8}', '\u{1ccf}'), ('\u{1cf7}', '\u{1cf7}'), ('\u{1cfa}', '\u{1cff}'), ('\u{1df6}', '\u{1dfb}'), ('\u{1f16}', '\u{1f17}'), ('\u{1f1e}', '\u{1f1f}'), ('\u{1f46}', '\u{1f47}'), ('\u{1f4e}', '\u{1f4f}'), ('\u{1f58}', '\u{1f58}'), ('\u{1f5a}', '\u{1f5a}'), ('\u{1f5c}', '\u{1f5c}'), ('\u{1f5e}', '\u{1f5e}'), ('\u{1f7e}', '\u{1f7f}'), ('\u{1fb5}', '\u{1fb5}'), ('\u{1fc5}', '\u{1fc5}'), ('\u{1fd4}', '\u{1fd5}'), ('\u{1fdc}', '\u{1fdc}'), ('\u{1ff0}', '\u{1ff1}'), ('\u{1ff5}', '\u{1ff5}'), ('\u{1fff}', '\u{1fff}'), ('\u{200b}', '\u{200f}'), ('\u{202a}', '\u{202e}'), ('\u{2060}', '\u{206f}'), ('\u{2072}', '\u{2073}'), ('\u{208f}', '\u{208f}'), ('\u{209d}', '\u{209f}'), ('\u{20bf}', '\u{20cf}'), ('\u{20f1}', '\u{20ff}'), ('\u{218c}', '\u{218f}'), ('\u{23fb}', '\u{23ff}'), ('\u{2427}', '\u{243f}'), ('\u{244b}', '\u{245f}'), ('\u{2b74}', '\u{2b75}'), ('\u{2b96}', '\u{2b97}'), ('\u{2bba}', '\u{2bbc}'), ('\u{2bc9}', '\u{2bc9}'), ('\u{2bd2}', '\u{2beb}'), ('\u{2bf0}', '\u{2bff}'), ('\u{2c2f}', '\u{2c2f}'), ('\u{2c5f}', '\u{2c5f}'), ('\u{2cf4}', '\u{2cf8}'), ('\u{2d26}', '\u{2d26}'), ('\u{2d28}', '\u{2d2c}'), ('\u{2d2e}', '\u{2d2f}'), ('\u{2d68}', '\u{2d6e}'), ('\u{2d71}', '\u{2d7e}'), ('\u{2d97}', '\u{2d9f}'), ('\u{2da7}', '\u{2da7}'), ('\u{2daf}', '\u{2daf}'), ('\u{2db7}', '\u{2db7}'), ('\u{2dbf}', '\u{2dbf}'), ('\u{2dc7}', '\u{2dc7}'), ('\u{2dcf}', '\u{2dcf}'), ('\u{2dd7}', '\u{2dd7}'), ('\u{2ddf}', '\u{2ddf}'), ('\u{2e43}', '\u{2e7f}'), ('\u{2e9a}', '\u{2e9a}'), ('\u{2ef4}', '\u{2eff}'), ('\u{2fd6}', '\u{2fef}'), ('\u{2ffc}', '\u{2fff}'), ('\u{3040}', '\u{3040}'), ('\u{3097}', '\u{3098}'), ('\u{3100}', '\u{3104}'), ('\u{312e}', '\u{3130}'), ('\u{318f}', '\u{318f}'), ('\u{31bb}', '\u{31bf}'), ('\u{31e4}', '\u{31ef}'), ('\u{321f}', '\u{321f}'), ('\u{32ff}', '\u{32ff}'), ('\u{4db6}', '\u{4dbf}'), ('\u{9fd6}', '\u{9fff}'), ('\u{a48d}', '\u{a48f}'), ('\u{a4c7}', '\u{a4cf}'), ('\u{a62c}', '\u{a63f}'), ('\u{a6f8}', '\u{a6ff}'), ('\u{a7ae}', '\u{a7af}'), ('\u{a7b8}', '\u{a7f6}'), ('\u{a82c}', '\u{a82f}'), ('\u{a83a}', '\u{a83f}'), ('\u{a878}', '\u{a87f}'), ('\u{a8c5}', '\u{a8cd}'), ('\u{a8da}', '\u{a8df}'), ('\u{a8fe}', '\u{a8ff}'), ('\u{a954}', '\u{a95e}'), ('\u{a97d}', '\u{a97f}'), ('\u{a9ce}', '\u{a9ce}'), ('\u{a9da}', '\u{a9dd}'), ('\u{a9ff}', '\u{a9ff}'), ('\u{aa37}', '\u{aa3f}'), ('\u{aa4e}', '\u{aa4f}'), ('\u{aa5a}', '\u{aa5b}'), ('\u{aac3}', '\u{aada}'), ('\u{aaf7}', '\u{ab00}'), ('\u{ab07}', '\u{ab08}'), ('\u{ab0f}', '\u{ab10}'), ('\u{ab17}', '\u{ab1f}'), ('\u{ab27}', '\u{ab27}'), ('\u{ab2f}', '\u{ab2f}'), ('\u{ab66}', '\u{ab6f}'), ('\u{abee}', '\u{abef}'), ('\u{abfa}', '\u{abff}'), ('\u{d7a4}', '\u{d7af}'), ('\u{d7c7}', '\u{d7ca}'), ('\u{d7fc}', '\u{d7ff}'), ('\u{e000}', '\u{f8ff}'), ('\u{fa6e}', '\u{fa6f}'), ('\u{fada}', '\u{faff}'), ('\u{fb07}', '\u{fb12}'), ('\u{fb18}', '\u{fb1c}'), ('\u{fb37}', '\u{fb37}'), ('\u{fb3d}', '\u{fb3d}'), ('\u{fb3f}', '\u{fb3f}'), ('\u{fb42}', '\u{fb42}'), ('\u{fb45}', '\u{fb45}'), ('\u{fbc2}', '\u{fbd2}'), ('\u{fd40}', '\u{fd4f}'), ('\u{fd90}', '\u{fd91}'), ('\u{fdc8}', '\u{fdef}'), ('\u{fdfe}', '\u{fdff}'), ('\u{fe1a}', '\u{fe1f}'), ('\u{fe53}', '\u{fe53}'), ('\u{fe67}', '\u{fe67}'), ('\u{fe6c}', '\u{fe6f}'), ('\u{fe75}', '\u{fe75}'), ('\u{fefd}', '\u{ff00}'), ('\u{ffbf}', '\u{ffc1}'), ('\u{ffc8}', '\u{ffc9}'), ('\u{ffd0}', '\u{ffd1}'), ('\u{ffd8}', '\u{ffd9}'), ('\u{ffdd}', '\u{ffdf}'), ('\u{ffe7}', '\u{ffe7}'), ('\u{ffef}', '\u{fffb}'), ('\u{fffe}', '\u{ffff}'), ('\u{1000c}', '\u{1000c}'), ('\u{10027}', '\u{10027}'), ('\u{1003b}', '\u{1003b}'), ('\u{1003e}', '\u{1003e}'), ('\u{1004e}', '\u{1004f}'), ('\u{1005e}', '\u{1007f}'), ('\u{100fb}', '\u{100ff}'), ('\u{10103}', '\u{10106}'), ('\u{10134}', '\u{10136}'), ('\u{1018d}', '\u{1018f}'), ('\u{1019c}', '\u{1019f}'), ('\u{101a1}', '\u{101cf}'), ('\u{101fe}', '\u{1027f}'), ('\u{1029d}', '\u{1029f}'), ('\u{102d1}', '\u{102df}'), ('\u{102fc}', '\u{102ff}'), ('\u{10324}', '\u{1032f}'), ('\u{1034b}', '\u{1034f}'), ('\u{1037b}', '\u{1037f}'), ('\u{1039e}', '\u{1039e}'), ('\u{103c4}', '\u{103c7}'), ('\u{103d6}', '\u{103ff}'), ('\u{1049e}', '\u{1049f}'), ('\u{104aa}', '\u{104ff}'), ('\u{10528}', '\u{1052f}'), ('\u{10564}', '\u{1056e}'), ('\u{10570}', '\u{105ff}'), ('\u{10737}', '\u{1073f}'), ('\u{10756}', '\u{1075f}'), ('\u{10768}', '\u{107ff}'), ('\u{10806}', '\u{10807}'), ('\u{10809}', '\u{10809}'), ('\u{10836}', '\u{10836}'), ('\u{10839}', '\u{1083b}'), ('\u{1083d}', '\u{1083e}'), ('\u{10856}', '\u{10856}'), ('\u{1089f}', '\u{108a6}'), ('\u{108b0}', '\u{108df}'), ('\u{108f3}', '\u{108f3}'), ('\u{108f6}', '\u{108fa}'), ('\u{1091c}', '\u{1091e}'), ('\u{1093a}', '\u{1093e}'), ('\u{10940}', '\u{1097f}'), ('\u{109b8}', '\u{109bb}'), ('\u{109d0}', '\u{109d1}'), ('\u{10a04}', '\u{10a04}'), ('\u{10a07}', '\u{10a0b}'), ('\u{10a14}', '\u{10a14}'), ('\u{10a18}', '\u{10a18}'), ('\u{10a34}', '\u{10a37}'), ('\u{10a3b}', '\u{10a3e}'), ('\u{10a48}', '\u{10a4f}'), ('\u{10a59}', '\u{10a5f}'), ('\u{10aa0}', '\u{10abf}'), ('\u{10ae7}', '\u{10aea}'), ('\u{10af7}', '\u{10aff}'), ('\u{10b36}', '\u{10b38}'), ('\u{10b56}', '\u{10b57}'), ('\u{10b73}', '\u{10b77}'), ('\u{10b92}', '\u{10b98}'), ('\u{10b9d}', '\u{10ba8}'), ('\u{10bb0}', '\u{10bff}'), ('\u{10c49}', '\u{10c7f}'), ('\u{10cb3}', '\u{10cbf}'), ('\u{10cf3}', '\u{10cf9}'), ('\u{10d00}', '\u{10e5f}'), ('\u{10e7f}', '\u{10fff}'), ('\u{1104e}', '\u{11051}'), ('\u{11070}', '\u{1107e}'), ('\u{110bd}', '\u{110bd}'), ('\u{110c2}', '\u{110cf}'), ('\u{110e9}', '\u{110ef}'), ('\u{110fa}', '\u{110ff}'), ('\u{11135}', '\u{11135}'), ('\u{11144}', '\u{1114f}'), ('\u{11177}', '\u{1117f}'), ('\u{111ce}', '\u{111cf}'), ('\u{111e0}', '\u{111e0}'), ('\u{111f5}', '\u{111ff}'), ('\u{11212}', '\u{11212}'), ('\u{1123e}', '\u{1127f}'), ('\u{11287}', '\u{11287}'), ('\u{11289}', '\u{11289}'), ('\u{1128e}', '\u{1128e}'), ('\u{1129e}', '\u{1129e}'), ('\u{112aa}', '\u{112af}'), ('\u{112eb}', '\u{112ef}'), ('\u{112fa}', '\u{112ff}'), ('\u{11304}', '\u{11304}'), ('\u{1130d}', '\u{1130e}'), ('\u{11311}', '\u{11312}'), ('\u{11329}', '\u{11329}'), ('\u{11331}', '\u{11331}'), ('\u{11334}', '\u{11334}'), ('\u{1133a}', '\u{1133b}'), ('\u{11345}', '\u{11346}'), ('\u{11349}', '\u{1134a}'), ('\u{1134e}', '\u{1134f}'), ('\u{11351}', '\u{11356}'), ('\u{11358}', '\u{1135c}'), ('\u{11364}', '\u{11365}'), ('\u{1136d}', '\u{1136f}'), ('\u{11375}', '\u{1147f}'), ('\u{114c8}', '\u{114cf}'), ('\u{114da}', '\u{1157f}'), ('\u{115b6}', '\u{115b7}'), ('\u{115de}', '\u{115ff}'), ('\u{11645}', '\u{1164f}'), ('\u{1165a}', '\u{1167f}'), ('\u{116b8}', '\u{116bf}'), ('\u{116ca}', '\u{116ff}'), ('\u{1171a}', '\u{1171c}'), ('\u{1172c}', '\u{1172f}'), ('\u{11740}', '\u{1189f}'), ('\u{118f3}', '\u{118fe}'), ('\u{11900}', '\u{11abf}'), ('\u{11af9}', '\u{11fff}'), ('\u{1239a}', '\u{123ff}'), ('\u{1246f}', '\u{1246f}'), ('\u{12475}', '\u{1247f}'), ('\u{12544}', '\u{12fff}'), ('\u{1342f}', '\u{143ff}'), ('\u{14647}', '\u{167ff}'), ('\u{16a39}', '\u{16a3f}'), ('\u{16a5f}', '\u{16a5f}'), ('\u{16a6a}', '\u{16a6d}'), ('\u{16a70}', '\u{16acf}'), ('\u{16aee}', '\u{16aef}'), ('\u{16af6}', '\u{16aff}'), ('\u{16b46}', '\u{16b4f}'), ('\u{16b5a}', '\u{16b5a}'), ('\u{16b62}', '\u{16b62}'), ('\u{16b78}', '\u{16b7c}'), ('\u{16b90}', '\u{16eff}'), ('\u{16f45}', '\u{16f4f}'), ('\u{16f7f}', '\u{16f8e}'), ('\u{16fa0}', '\u{1afff}'), ('\u{1b002}', '\u{1bbff}'), ('\u{1bc6b}', '\u{1bc6f}'), ('\u{1bc7d}', '\u{1bc7f}'), ('\u{1bc89}', '\u{1bc8f}'), ('\u{1bc9a}', '\u{1bc9b}'), ('\u{1bca0}', '\u{1cfff}'), ('\u{1d0f6}', '\u{1d0ff}'), ('\u{1d127}', '\u{1d128}'), ('\u{1d173}', '\u{1d17a}'), ('\u{1d1e9}', '\u{1d1ff}'), ('\u{1d246}', '\u{1d2ff}'), ('\u{1d357}', '\u{1d35f}'), ('\u{1d372}', '\u{1d3ff}'), ('\u{1d455}', '\u{1d455}'), ('\u{1d49d}', '\u{1d49d}'), ('\u{1d4a0}', '\u{1d4a1}'), ('\u{1d4a3}', '\u{1d4a4}'), ('\u{1d4a7}', '\u{1d4a8}'), ('\u{1d4ad}', '\u{1d4ad}'), ('\u{1d4ba}', '\u{1d4ba}'), ('\u{1d4bc}', '\u{1d4bc}'), ('\u{1d4c4}', '\u{1d4c4}'), ('\u{1d506}', '\u{1d506}'), ('\u{1d50b}', '\u{1d50c}'), ('\u{1d515}', '\u{1d515}'), ('\u{1d51d}', '\u{1d51d}'), ('\u{1d53a}', '\u{1d53a}'), ('\u{1d53f}', '\u{1d53f}'), ('\u{1d545}', '\u{1d545}'), ('\u{1d547}', '\u{1d549}'), ('\u{1d551}', '\u{1d551}'), ('\u{1d6a6}', '\u{1d6a7}'), ('\u{1d7cc}', '\u{1d7cd}'), ('\u{1da8c}', '\u{1da9a}'), ('\u{1daa0}', '\u{1daa0}'), ('\u{1dab0}', '\u{1e7ff}'), ('\u{1e8c5}', '\u{1e8c6}'), ('\u{1e8d7}', '\u{1edff}'), ('\u{1ee04}', '\u{1ee04}'), ('\u{1ee20}', '\u{1ee20}'), ('\u{1ee23}', '\u{1ee23}'), ('\u{1ee25}', '\u{1ee26}'), ('\u{1ee28}', '\u{1ee28}'), ('\u{1ee33}', '\u{1ee33}'), ('\u{1ee38}', '\u{1ee38}'), ('\u{1ee3a}', '\u{1ee3a}'), ('\u{1ee3c}', '\u{1ee41}'), ('\u{1ee43}', '\u{1ee46}'), ('\u{1ee48}', '\u{1ee48}'), ('\u{1ee4a}', '\u{1ee4a}'), ('\u{1ee4c}', '\u{1ee4c}'), ('\u{1ee50}', '\u{1ee50}'), ('\u{1ee53}', '\u{1ee53}'), ('\u{1ee55}', '\u{1ee56}'), ('\u{1ee58}', '\u{1ee58}'), ('\u{1ee5a}', '\u{1ee5a}'), ('\u{1ee5c}', '\u{1ee5c}'), ('\u{1ee5e}', '\u{1ee5e}'), ('\u{1ee60}', '\u{1ee60}'), ('\u{1ee63}', '\u{1ee63}'), ('\u{1ee65}', '\u{1ee66}'), ('\u{1ee6b}', '\u{1ee6b}'), ('\u{1ee73}', '\u{1ee73}'), ('\u{1ee78}', '\u{1ee78}'), ('\u{1ee7d}', '\u{1ee7d}'), ('\u{1ee7f}', '\u{1ee7f}'), ('\u{1ee8a}', '\u{1ee8a}'), ('\u{1ee9c}', '\u{1eea0}'), ('\u{1eea4}', '\u{1eea4}'), ('\u{1eeaa}', '\u{1eeaa}'), ('\u{1eebc}', '\u{1eeef}'), ('\u{1eef2}', '\u{1efff}'), ('\u{1f02c}', '\u{1f02f}'), ('\u{1f094}', '\u{1f09f}'), ('\u{1f0af}', '\u{1f0b0}'), ('\u{1f0c0}', '\u{1f0c0}'), ('\u{1f0d0}', '\u{1f0d0}'), ('\u{1f0f6}', '\u{1f0ff}'), ('\u{1f10d}', '\u{1f10f}'), ('\u{1f12f}', '\u{1f12f}'), ('\u{1f16c}', '\u{1f16f}'), ('\u{1f19b}', '\u{1f1e5}'), ('\u{1f203}', '\u{1f20f}'), ('\u{1f23b}', '\u{1f23f}'), ('\u{1f249}', '\u{1f24f}'), ('\u{1f252}', '\u{1f2ff}'), ('\u{1f57a}', '\u{1f57a}'), ('\u{1f5a4}', '\u{1f5a4}'), ('\u{1f6d1}', '\u{1f6df}'), ('\u{1f6ed}', '\u{1f6ef}'), ('\u{1f6f4}', '\u{1f6ff}'), ('\u{1f774}', '\u{1f77f}'), ('\u{1f7d5}', '\u{1f7ff}'), ('\u{1f80c}', '\u{1f80f}'), ('\u{1f848}', '\u{1f84f}'), ('\u{1f85a}', '\u{1f85f}'), ('\u{1f888}', '\u{1f88f}'), ('\u{1f8ae}', '\u{1f90f}'), ('\u{1f919}', '\u{1f97f}'), ('\u{1f985}', '\u{1f9bf}'), ('\u{1f9c1}', '\u{1ffff}'), ('\u{2a6d7}', '\u{2a6ff}'), ('\u{2b735}', '\u{2b73f}'), ('\u{2b81e}', '\u{2b81f}'), ('\u{2cea2}', '\u{2f7ff}'), ('\u{2fa1e}', '\u{e00ff}'), ('\u{e01f0}', '\u{10ffff}') ]; pub const Cc_table: &'static [(char, char)] = &[ ('\u{0}', '\u{1f}'), ('\u{7f}', '\u{9f}') ]; pub const Cf_table: &'static [(char, char)] = &[ ('\u{ad}', '\u{ad}'), ('\u{600}', '\u{605}'), ('\u{61c}', '\u{61c}'), ('\u{6dd}', '\u{6dd}'), ('\u{70f}', '\u{70f}'), ('\u{180e}', '\u{180e}'), ('\u{200b}', '\u{200f}'), ('\u{202a}', '\u{202e}'), ('\u{2060}', '\u{2064}'), ('\u{2066}', '\u{206f}'), ('\u{feff}', '\u{feff}'), ('\u{fff9}', '\u{fffb}'), ('\u{110bd}', '\u{110bd}'), ('\u{1bca0}', '\u{1bca3}'), ('\u{1d173}', '\u{1d17a}'), ('\u{e0001}', '\u{e0001}'), ('\u{e0020}', '\u{e007f}') ]; pub const Cn_table: &'static [(char, char)] = &[ ('\u{378}', '\u{379}'), ('\u{380}', '\u{383}'), ('\u{38b}', '\u{38b}'), ('\u{38d}', '\u{38d}'), ('\u{3a2}', '\u{3a2}'), ('\u{530}', '\u{530}'), ('\u{557}', '\u{558}'), ('\u{560}', '\u{560}'), ('\u{588}', '\u{588}'), ('\u{58b}', '\u{58c}'), ('\u{590}', '\u{590}'), ('\u{5c8}', '\u{5cf}'), ('\u{5eb}', '\u{5ef}'), ('\u{5f5}', '\u{5ff}'), ('\u{61d}', '\u{61d}'), ('\u{70e}', '\u{70e}'), ('\u{74b}', '\u{74c}'), ('\u{7b2}', '\u{7bf}'), ('\u{7fb}', '\u{7ff}'), ('\u{82e}', '\u{82f}'), ('\u{83f}', '\u{83f}'), ('\u{85c}', '\u{85d}'), ('\u{85f}', '\u{89f}'), ('\u{8b5}', '\u{8e2}'), ('\u{984}', '\u{984}'), ('\u{98d}', '\u{98e}'), ('\u{991}', '\u{992}'), ('\u{9a9}', '\u{9a9}'), ('\u{9b1}', '\u{9b1}'), ('\u{9b3}', '\u{9b5}'), ('\u{9ba}', '\u{9bb}'), ('\u{9c5}', '\u{9c6}'), ('\u{9c9}', '\u{9ca}'), ('\u{9cf}', '\u{9d6}'), ('\u{9d8}', '\u{9db}'), ('\u{9de}', '\u{9de}'), ('\u{9e4}', '\u{9e5}'), ('\u{9fc}', '\u{a00}'), ('\u{a04}', '\u{a04}'), ('\u{a0b}', '\u{a0e}'), ('\u{a11}', '\u{a12}'), ('\u{a29}', '\u{a29}'), ('\u{a31}', '\u{a31}'), ('\u{a34}', '\u{a34}'), ('\u{a37}', '\u{a37}'), ('\u{a3a}', '\u{a3b}'), ('\u{a3d}', '\u{a3d}'), ('\u{a43}', '\u{a46}'), ('\u{a49}', '\u{a4a}'), ('\u{a4e}', '\u{a50}'), ('\u{a52}', '\u{a58}'), ('\u{a5d}', '\u{a5d}'), ('\u{a5f}', '\u{a65}'), ('\u{a76}', '\u{a80}'), ('\u{a84}', '\u{a84}'), ('\u{a8e}', '\u{a8e}'), ('\u{a92}', '\u{a92}'), ('\u{aa9}', '\u{aa9}'), ('\u{ab1}', '\u{ab1}'), ('\u{ab4}', '\u{ab4}'), ('\u{aba}', '\u{abb}'), ('\u{ac6}', '\u{ac6}'), ('\u{aca}', '\u{aca}'), ('\u{ace}', '\u{acf}'), ('\u{ad1}', '\u{adf}'), ('\u{ae4}', '\u{ae5}'), ('\u{af2}', '\u{af8}'), ('\u{afa}', '\u{b00}'), ('\u{b04}', '\u{b04}'), ('\u{b0d}', '\u{b0e}'), ('\u{b11}', '\u{b12}'), ('\u{b29}', '\u{b29}'), ('\u{b31}', '\u{b31}'), ('\u{b34}', '\u{b34}'), ('\u{b3a}', '\u{b3b}'), ('\u{b45}', '\u{b46}'), ('\u{b49}', '\u{b4a}'), ('\u{b4e}', '\u{b55}'), ('\u{b58}', '\u{b5b}'), ('\u{b5e}', '\u{b5e}'), ('\u{b64}', '\u{b65}'), ('\u{b78}', '\u{b81}'), ('\u{b84}', '\u{b84}'), ('\u{b8b}', '\u{b8d}'), ('\u{b91}', '\u{b91}'), ('\u{b96}', '\u{b98}'), ('\u{b9b}', '\u{b9b}'), ('\u{b9d}', '\u{b9d}'), ('\u{ba0}', '\u{ba2}'), ('\u{ba5}', '\u{ba7}'), ('\u{bab}', '\u{bad}'), ('\u{bba}', '\u{bbd}'), ('\u{bc3}', '\u{bc5}'), ('\u{bc9}', '\u{bc9}'), ('\u{bce}', '\u{bcf}'), ('\u{bd1}', '\u{bd6}'), ('\u{bd8}', '\u{be5}'), ('\u{bfb}', '\u{bff}'), ('\u{c04}', '\u{c04}'), ('\u{c0d}', '\u{c0d}'), ('\u{c11}', '\u{c11}'), ('\u{c29}', '\u{c29}'), ('\u{c3a}', '\u{c3c}'), ('\u{c45}', '\u{c45}'), ('\u{c49}', '\u{c49}'), ('\u{c4e}', '\u{c54}'), ('\u{c57}', '\u{c57}'), ('\u{c5b}', '\u{c5f}'), ('\u{c64}', '\u{c65}'), ('\u{c70}', '\u{c77}'), ('\u{c80}', '\u{c80}'), ('\u{c84}', '\u{c84}'), ('\u{c8d}', '\u{c8d}'), ('\u{c91}', '\u{c91}'), ('\u{ca9}', '\u{ca9}'), ('\u{cb4}', '\u{cb4}'), ('\u{cba}', '\u{cbb}'), ('\u{cc5}', '\u{cc5}'), ('\u{cc9}', '\u{cc9}'), ('\u{cce}', '\u{cd4}'), ('\u{cd7}', '\u{cdd}'), ('\u{cdf}', '\u{cdf}'), ('\u{ce4}', '\u{ce5}'), ('\u{cf0}', '\u{cf0}'), ('\u{cf3}', '\u{d00}'), ('\u{d04}', '\u{d04}'), ('\u{d0d}', '\u{d0d}'), ('\u{d11}', '\u{d11}'), ('\u{d3b}', '\u{d3c}'), ('\u{d45}', '\u{d45}'), ('\u{d49}', '\u{d49}'), ('\u{d4f}', '\u{d56}'), ('\u{d58}', '\u{d5e}'), ('\u{d64}', '\u{d65}'), ('\u{d76}', '\u{d78}'), ('\u{d80}', '\u{d81}'), ('\u{d84}', '\u{d84}'), ('\u{d97}', '\u{d99}'), ('\u{db2}', '\u{db2}'), ('\u{dbc}', '\u{dbc}'), ('\u{dbe}', '\u{dbf}'), ('\u{dc7}', '\u{dc9}'), ('\u{dcb}', '\u{dce}'), ('\u{dd5}', '\u{dd5}'), ('\u{dd7}', '\u{dd7}'), ('\u{de0}', '\u{de5}'), ('\u{df0}', '\u{df1}'), ('\u{df5}', '\u{e00}'), ('\u{e3b}', '\u{e3e}'), ('\u{e5c}', '\u{e80}'), ('\u{e83}', '\u{e83}'), ('\u{e85}', '\u{e86}'), ('\u{e89}', '\u{e89}'), ('\u{e8b}', '\u{e8c}'), ('\u{e8e}', '\u{e93}'), ('\u{e98}', '\u{e98}'), ('\u{ea0}', '\u{ea0}'), ('\u{ea4}', '\u{ea4}'), ('\u{ea6}', '\u{ea6}'), ('\u{ea8}', '\u{ea9}'), ('\u{eac}', '\u{eac}'), ('\u{eba}', '\u{eba}'), ('\u{ebe}', '\u{ebf}'), ('\u{ec5}', '\u{ec5}'), ('\u{ec7}', '\u{ec7}'), ('\u{ece}', '\u{ecf}'), ('\u{eda}', '\u{edb}'), ('\u{ee0}', '\u{eff}'), ('\u{f48}', '\u{f48}'), ('\u{f6d}', '\u{f70}'), ('\u{f98}', '\u{f98}'), ('\u{fbd}', '\u{fbd}'), ('\u{fcd}', '\u{fcd}'), ('\u{fdb}', '\u{fff}'), ('\u{10c6}', '\u{10c6}'), ('\u{10c8}', '\u{10cc}'), ('\u{10ce}', '\u{10cf}'), ('\u{1249}', '\u{1249}'), ('\u{124e}', '\u{124f}'), ('\u{1257}', '\u{1257}'), ('\u{1259}', '\u{1259}'), ('\u{125e}', '\u{125f}'), ('\u{1289}', '\u{1289}'), ('\u{128e}', '\u{128f}'), ('\u{12b1}', '\u{12b1}'), ('\u{12b6}', '\u{12b7}'), ('\u{12bf}', '\u{12bf}'), ('\u{12c1}', '\u{12c1}'), ('\u{12c6}', '\u{12c7}'), ('\u{12d7}', '\u{12d7}'), ('\u{1311}', '\u{1311}'), ('\u{1316}', '\u{1317}'), ('\u{135b}', '\u{135c}'), ('\u{137d}', '\u{137f}'), ('\u{139a}', '\u{139f}'), ('\u{13f6}', '\u{13f7}'), ('\u{13fe}', '\u{13ff}'), ('\u{169d}', '\u{169f}'), ('\u{16f9}', '\u{16ff}'), ('\u{170d}', '\u{170d}'), ('\u{1715}', '\u{171f}'), ('\u{1737}', '\u{173f}'), ('\u{1754}', '\u{175f}'), ('\u{176d}', '\u{176d}'), ('\u{1771}', '\u{1771}'), ('\u{1774}', '\u{177f}'), ('\u{17de}', '\u{17df}'), ('\u{17ea}', '\u{17ef}'), ('\u{17fa}', '\u{17ff}'), ('\u{180f}', '\u{180f}'), ('\u{181a}', '\u{181f}'), ('\u{1878}', '\u{187f}'), ('\u{18ab}', '\u{18af}'), ('\u{18f6}', '\u{18ff}'), ('\u{191f}', '\u{191f}'), ('\u{192c}', '\u{192f}'), ('\u{193c}', '\u{193f}'), ('\u{1941}', '\u{1943}'), ('\u{196e}', '\u{196f}'), ('\u{1975}', '\u{197f}'), ('\u{19ac}', '\u{19af}'), ('\u{19ca}', '\u{19cf}'), ('\u{19db}', '\u{19dd}'), ('\u{1a1c}', '\u{1a1d}'), ('\u{1a5f}', '\u{1a5f}'), ('\u{1a7d}', '\u{1a7e}'), ('\u{1a8a}', '\u{1a8f}'), ('\u{1a9a}', '\u{1a9f}'), ('\u{1aae}', '\u{1aaf}'), ('\u{1abf}', '\u{1aff}'), ('\u{1b4c}', '\u{1b4f}'), ('\u{1b7d}', '\u{1b7f}'), ('\u{1bf4}', '\u{1bfb}'), ('\u{1c38}', '\u{1c3a}'), ('\u{1c4a}', '\u{1c4c}'), ('\u{1c80}', '\u{1cbf}'), ('\u{1cc8}', '\u{1ccf}'), ('\u{1cf7}', '\u{1cf7}'), ('\u{1cfa}', '\u{1cff}'), ('\u{1df6}', '\u{1dfb}'), ('\u{1f16}', '\u{1f17}'), ('\u{1f1e}', '\u{1f1f}'), ('\u{1f46}', '\u{1f47}'), ('\u{1f4e}', '\u{1f4f}'), ('\u{1f58}', '\u{1f58}'), ('\u{1f5a}', '\u{1f5a}'), ('\u{1f5c}', '\u{1f5c}'), ('\u{1f5e}', '\u{1f5e}'), ('\u{1f7e}', '\u{1f7f}'), ('\u{1fb5}', '\u{1fb5}'), ('\u{1fc5}', '\u{1fc5}'), ('\u{1fd4}', '\u{1fd5}'), ('\u{1fdc}', '\u{1fdc}'), ('\u{1ff0}', '\u{1ff1}'), ('\u{1ff5}', '\u{1ff5}'), ('\u{1fff}', '\u{1fff}'), ('\u{2065}', '\u{2065}'), ('\u{2072}', '\u{2073}'), ('\u{208f}', '\u{208f}'), ('\u{209d}', '\u{209f}'), ('\u{20bf}', '\u{20cf}'), ('\u{20f1}', '\u{20ff}'), ('\u{218c}', '\u{218f}'), ('\u{23fb}', '\u{23ff}'), ('\u{2427}', '\u{243f}'), ('\u{244b}', '\u{245f}'), ('\u{2b74}', '\u{2b75}'), ('\u{2b96}', '\u{2b97}'), ('\u{2bba}', '\u{2bbc}'), ('\u{2bc9}', '\u{2bc9}'), ('\u{2bd2}', '\u{2beb}'), ('\u{2bf0}', '\u{2bff}'), ('\u{2c2f}', '\u{2c2f}'), ('\u{2c5f}', '\u{2c5f}'), ('\u{2cf4}', '\u{2cf8}'), ('\u{2d26}', '\u{2d26}'), ('\u{2d28}', '\u{2d2c}'), ('\u{2d2e}', '\u{2d2f}'), ('\u{2d68}', '\u{2d6e}'), ('\u{2d71}', '\u{2d7e}'), ('\u{2d97}', '\u{2d9f}'), ('\u{2da7}', '\u{2da7}'), ('\u{2daf}', '\u{2daf}'), ('\u{2db7}', '\u{2db7}'), ('\u{2dbf}', '\u{2dbf}'), ('\u{2dc7}', '\u{2dc7}'), ('\u{2dcf}', '\u{2dcf}'), ('\u{2dd7}', '\u{2dd7}'), ('\u{2ddf}', '\u{2ddf}'), ('\u{2e43}', '\u{2e7f}'), ('\u{2e9a}', '\u{2e9a}'), ('\u{2ef4}', '\u{2eff}'), ('\u{2fd6}', '\u{2fef}'), ('\u{2ffc}', '\u{2fff}'), ('\u{3040}', '\u{3040}'), ('\u{3097}', '\u{3098}'), ('\u{3100}', '\u{3104}'), ('\u{312e}', '\u{3130}'), ('\u{318f}', '\u{318f}'), ('\u{31bb}', '\u{31bf}'), ('\u{31e4}', '\u{31ef}'), ('\u{321f}', '\u{321f}'), ('\u{32ff}', '\u{32ff}'), ('\u{4db6}', '\u{4dbf}'), ('\u{9fd6}', '\u{9fff}'), ('\u{a48d}', '\u{a48f}'), ('\u{a4c7}', '\u{a4cf}'), ('\u{a62c}', '\u{a63f}'), ('\u{a6f8}', '\u{a6ff}'), ('\u{a7ae}', '\u{a7af}'), ('\u{a7b8}', '\u{a7f6}'), ('\u{a82c}', '\u{a82f}'), ('\u{a83a}', '\u{a83f}'), ('\u{a878}', '\u{a87f}'), ('\u{a8c5}', '\u{a8cd}'), ('\u{a8da}', '\u{a8df}'), ('\u{a8fe}', '\u{a8ff}'), ('\u{a954}', '\u{a95e}'), ('\u{a97d}', '\u{a97f}'), ('\u{a9ce}', '\u{a9ce}'), ('\u{a9da}', '\u{a9dd}'), ('\u{a9ff}', '\u{a9ff}'), ('\u{aa37}', '\u{aa3f}'), ('\u{aa4e}', '\u{aa4f}'), ('\u{aa5a}', '\u{aa5b}'), ('\u{aac3}', '\u{aada}'), ('\u{aaf7}', '\u{ab00}'), ('\u{ab07}', '\u{ab08}'), ('\u{ab0f}', '\u{ab10}'), ('\u{ab17}', '\u{ab1f}'), ('\u{ab27}', '\u{ab27}'), ('\u{ab2f}', '\u{ab2f}'), ('\u{ab66}', '\u{ab6f}'), ('\u{abee}', '\u{abef}'), ('\u{abfa}', '\u{abff}'), ('\u{d7a4}', '\u{d7af}'), ('\u{d7c7}', '\u{d7ca}'), ('\u{d7fc}', '\u{d7ff}'), ('\u{fa6e}', '\u{fa6f}'), ('\u{fada}', '\u{faff}'), ('\u{fb07}', '\u{fb12}'), ('\u{fb18}', '\u{fb1c}'), ('\u{fb37}', '\u{fb37}'), ('\u{fb3d}', '\u{fb3d}'), ('\u{fb3f}', '\u{fb3f}'), ('\u{fb42}', '\u{fb42}'), ('\u{fb45}', '\u{fb45}'), ('\u{fbc2}', '\u{fbd2}'), ('\u{fd40}', '\u{fd4f}'), ('\u{fd90}', '\u{fd91}'), ('\u{fdc8}', '\u{fdef}'), ('\u{fdfe}', '\u{fdff}'), ('\u{fe1a}', '\u{fe1f}'), ('\u{fe53}', '\u{fe53}'), ('\u{fe67}', '\u{fe67}'), ('\u{fe6c}', '\u{fe6f}'), ('\u{fe75}', '\u{fe75}'), ('\u{fefd}', '\u{fefe}'), ('\u{ff00}', '\u{ff00}'), ('\u{ffbf}', '\u{ffc1}'), ('\u{ffc8}', '\u{ffc9}'), ('\u{ffd0}', '\u{ffd1}'), ('\u{ffd8}', '\u{ffd9}'), ('\u{ffdd}', '\u{ffdf}'), ('\u{ffe7}', '\u{ffe7}'), ('\u{ffef}', '\u{fff8}'), ('\u{fffe}', '\u{ffff}'), ('\u{1000c}', '\u{1000c}'), ('\u{10027}', '\u{10027}'), ('\u{1003b}', '\u{1003b}'), ('\u{1003e}', '\u{1003e}'), ('\u{1004e}', '\u{1004f}'), ('\u{1005e}', '\u{1007f}'), ('\u{100fb}', '\u{100ff}'), ('\u{10103}', '\u{10106}'), ('\u{10134}', '\u{10136}'), ('\u{1018d}', '\u{1018f}'), ('\u{1019c}', '\u{1019f}'), ('\u{101a1}', '\u{101cf}'), ('\u{101fe}', '\u{1027f}'), ('\u{1029d}', '\u{1029f}'), ('\u{102d1}', '\u{102df}'), ('\u{102fc}', '\u{102ff}'), ('\u{10324}', '\u{1032f}'), ('\u{1034b}', '\u{1034f}'), ('\u{1037b}', '\u{1037f}'), ('\u{1039e}', '\u{1039e}'), ('\u{103c4}', '\u{103c7}'), ('\u{103d6}', '\u{103ff}'), ('\u{1049e}', '\u{1049f}'), ('\u{104aa}', '\u{104ff}'), ('\u{10528}', '\u{1052f}'), ('\u{10564}', '\u{1056e}'), ('\u{10570}', '\u{105ff}'), ('\u{10737}', '\u{1073f}'), ('\u{10756}', '\u{1075f}'), ('\u{10768}', '\u{107ff}'), ('\u{10806}', '\u{10807}'), ('\u{10809}', '\u{10809}'), ('\u{10836}', '\u{10836}'), ('\u{10839}', '\u{1083b}'), ('\u{1083d}', '\u{1083e}'), ('\u{10856}', '\u{10856}'), ('\u{1089f}', '\u{108a6}'), ('\u{108b0}', '\u{108df}'), ('\u{108f3}', '\u{108f3}'), ('\u{108f6}', '\u{108fa}'), ('\u{1091c}', '\u{1091e}'), ('\u{1093a}', '\u{1093e}'), ('\u{10940}', '\u{1097f}'), ('\u{109b8}', '\u{109bb}'), ('\u{109d0}', '\u{109d1}'), ('\u{10a04}', '\u{10a04}'), ('\u{10a07}', '\u{10a0b}'), ('\u{10a14}', '\u{10a14}'), ('\u{10a18}', '\u{10a18}'), ('\u{10a34}', '\u{10a37}'), ('\u{10a3b}', '\u{10a3e}'), ('\u{10a48}', '\u{10a4f}'), ('\u{10a59}', '\u{10a5f}'), ('\u{10aa0}', '\u{10abf}'), ('\u{10ae7}', '\u{10aea}'), ('\u{10af7}', '\u{10aff}'), ('\u{10b36}', '\u{10b38}'), ('\u{10b56}', '\u{10b57}'), ('\u{10b73}', '\u{10b77}'), ('\u{10b92}', '\u{10b98}'), ('\u{10b9d}', '\u{10ba8}'), ('\u{10bb0}', '\u{10bff}'), ('\u{10c49}', '\u{10c7f}'), ('\u{10cb3}', '\u{10cbf}'), ('\u{10cf3}', '\u{10cf9}'), ('\u{10d00}', '\u{10e5f}'), ('\u{10e7f}', '\u{10fff}'), ('\u{1104e}', '\u{11051}'), ('\u{11070}', '\u{1107e}'), ('\u{110c2}', '\u{110cf}'), ('\u{110e9}', '\u{110ef}'), ('\u{110fa}', '\u{110ff}'), ('\u{11135}', '\u{11135}'), ('\u{11144}', '\u{1114f}'), ('\u{11177}', '\u{1117f}'), ('\u{111ce}', '\u{111cf}'), ('\u{111e0}', '\u{111e0}'), ('\u{111f5}', '\u{111ff}'), ('\u{11212}', '\u{11212}'), ('\u{1123e}', '\u{1127f}'), ('\u{11287}', '\u{11287}'), ('\u{11289}', '\u{11289}'), ('\u{1128e}', '\u{1128e}'), ('\u{1129e}', '\u{1129e}'), ('\u{112aa}', '\u{112af}'), ('\u{112eb}', '\u{112ef}'), ('\u{112fa}', '\u{112ff}'), ('\u{11304}', '\u{11304}'), ('\u{1130d}', '\u{1130e}'), ('\u{11311}', '\u{11312}'), ('\u{11329}', '\u{11329}'), ('\u{11331}', '\u{11331}'), ('\u{11334}', '\u{11334}'), ('\u{1133a}', '\u{1133b}'), ('\u{11345}', '\u{11346}'), ('\u{11349}', '\u{1134a}'), ('\u{1134e}', '\u{1134f}'), ('\u{11351}', '\u{11356}'), ('\u{11358}', '\u{1135c}'), ('\u{11364}', '\u{11365}'), ('\u{1136d}', '\u{1136f}'), ('\u{11375}', '\u{1147f}'), ('\u{114c8}', '\u{114cf}'), ('\u{114da}', '\u{1157f}'), ('\u{115b6}', '\u{115b7}'), ('\u{115de}', '\u{115ff}'), ('\u{11645}', '\u{1164f}'), ('\u{1165a}', '\u{1167f}'), ('\u{116b8}', '\u{116bf}'), ('\u{116ca}', '\u{116ff}'), ('\u{1171a}', '\u{1171c}'), ('\u{1172c}', '\u{1172f}'), ('\u{11740}', '\u{1189f}'), ('\u{118f3}', '\u{118fe}'), ('\u{11900}', '\u{11abf}'), ('\u{11af9}', '\u{11fff}'), ('\u{1239a}', '\u{123ff}'), ('\u{1246f}', '\u{1246f}'), ('\u{12475}', '\u{1247f}'), ('\u{12544}', '\u{12fff}'), ('\u{1342f}', '\u{143ff}'), ('\u{14647}', '\u{167ff}'), ('\u{16a39}', '\u{16a3f}'), ('\u{16a5f}', '\u{16a5f}'), ('\u{16a6a}', '\u{16a6d}'), ('\u{16a70}', '\u{16acf}'), ('\u{16aee}', '\u{16aef}'), ('\u{16af6}', '\u{16aff}'), ('\u{16b46}', '\u{16b4f}'), ('\u{16b5a}', '\u{16b5a}'), ('\u{16b62}', '\u{16b62}'), ('\u{16b78}', '\u{16b7c}'), ('\u{16b90}', '\u{16eff}'), ('\u{16f45}', '\u{16f4f}'), ('\u{16f7f}', '\u{16f8e}'), ('\u{16fa0}', '\u{1afff}'), ('\u{1b002}', '\u{1bbff}'), ('\u{1bc6b}', '\u{1bc6f}'), ('\u{1bc7d}', '\u{1bc7f}'), ('\u{1bc89}', '\u{1bc8f}'), ('\u{1bc9a}', '\u{1bc9b}'), ('\u{1bca4}', '\u{1cfff}'), ('\u{1d0f6}', '\u{1d0ff}'), ('\u{1d127}', '\u{1d128}'), ('\u{1d1e9}', '\u{1d1ff}'), ('\u{1d246}', '\u{1d2ff}'), ('\u{1d357}', '\u{1d35f}'), ('\u{1d372}', '\u{1d3ff}'), ('\u{1d455}', '\u{1d455}'), ('\u{1d49d}', '\u{1d49d}'), ('\u{1d4a0}', '\u{1d4a1}'), ('\u{1d4a3}', '\u{1d4a4}'), ('\u{1d4a7}', '\u{1d4a8}'), ('\u{1d4ad}', '\u{1d4ad}'), ('\u{1d4ba}', '\u{1d4ba}'), ('\u{1d4bc}', '\u{1d4bc}'), ('\u{1d4c4}', '\u{1d4c4}'), ('\u{1d506}', '\u{1d506}'), ('\u{1d50b}', '\u{1d50c}'), ('\u{1d515}', '\u{1d515}'), ('\u{1d51d}', '\u{1d51d}'), ('\u{1d53a}', '\u{1d53a}'), ('\u{1d53f}', '\u{1d53f}'), ('\u{1d545}', '\u{1d545}'), ('\u{1d547}', '\u{1d549}'), ('\u{1d551}', '\u{1d551}'), ('\u{1d6a6}', '\u{1d6a7}'), ('\u{1d7cc}', '\u{1d7cd}'), ('\u{1da8c}', '\u{1da9a}'), ('\u{1daa0}', '\u{1daa0}'), ('\u{1dab0}', '\u{1e7ff}'), ('\u{1e8c5}', '\u{1e8c6}'), ('\u{1e8d7}', '\u{1edff}'), ('\u{1ee04}', '\u{1ee04}'), ('\u{1ee20}', '\u{1ee20}'), ('\u{1ee23}', '\u{1ee23}'), ('\u{1ee25}', '\u{1ee26}'), ('\u{1ee28}', '\u{1ee28}'), ('\u{1ee33}', '\u{1ee33}'), ('\u{1ee38}', '\u{1ee38}'), ('\u{1ee3a}', '\u{1ee3a}'), ('\u{1ee3c}', '\u{1ee41}'), ('\u{1ee43}', '\u{1ee46}'), ('\u{1ee48}', '\u{1ee48}'), ('\u{1ee4a}', '\u{1ee4a}'), ('\u{1ee4c}', '\u{1ee4c}'), ('\u{1ee50}', '\u{1ee50}'), ('\u{1ee53}', '\u{1ee53}'), ('\u{1ee55}', '\u{1ee56}'), ('\u{1ee58}', '\u{1ee58}'), ('\u{1ee5a}', '\u{1ee5a}'), ('\u{1ee5c}', '\u{1ee5c}'), ('\u{1ee5e}', '\u{1ee5e}'), ('\u{1ee60}', '\u{1ee60}'), ('\u{1ee63}', '\u{1ee63}'), ('\u{1ee65}', '\u{1ee66}'), ('\u{1ee6b}', '\u{1ee6b}'), ('\u{1ee73}', '\u{1ee73}'), ('\u{1ee78}', '\u{1ee78}'), ('\u{1ee7d}', '\u{1ee7d}'), ('\u{1ee7f}', '\u{1ee7f}'), ('\u{1ee8a}', '\u{1ee8a}'), ('\u{1ee9c}', '\u{1eea0}'), ('\u{1eea4}', '\u{1eea4}'), ('\u{1eeaa}', '\u{1eeaa}'), ('\u{1eebc}', '\u{1eeef}'), ('\u{1eef2}', '\u{1efff}'), ('\u{1f02c}', '\u{1f02f}'), ('\u{1f094}', '\u{1f09f}'), ('\u{1f0af}', '\u{1f0b0}'), ('\u{1f0c0}', '\u{1f0c0}'), ('\u{1f0d0}', '\u{1f0d0}'), ('\u{1f0f6}', '\u{1f0ff}'), ('\u{1f10d}', '\u{1f10f}'), ('\u{1f12f}', '\u{1f12f}'), ('\u{1f16c}', '\u{1f16f}'), ('\u{1f19b}', '\u{1f1e5}'), ('\u{1f203}', '\u{1f20f}'), ('\u{1f23b}', '\u{1f23f}'), ('\u{1f249}', '\u{1f24f}'), ('\u{1f252}', '\u{1f2ff}'), ('\u{1f57a}', '\u{1f57a}'), ('\u{1f5a4}', '\u{1f5a4}'), ('\u{1f6d1}', '\u{1f6df}'), ('\u{1f6ed}', '\u{1f6ef}'), ('\u{1f6f4}', '\u{1f6ff}'), ('\u{1f774}', '\u{1f77f}'), ('\u{1f7d5}', '\u{1f7ff}'), ('\u{1f80c}', '\u{1f80f}'), ('\u{1f848}', '\u{1f84f}'), ('\u{1f85a}', '\u{1f85f}'), ('\u{1f888}', '\u{1f88f}'), ('\u{1f8ae}', '\u{1f90f}'), ('\u{1f919}', '\u{1f97f}'), ('\u{1f985}', '\u{1f9bf}'), ('\u{1f9c1}', '\u{1ffff}'), ('\u{2a6d7}', '\u{2a6ff}'), ('\u{2b735}', '\u{2b73f}'), ('\u{2b81e}', '\u{2b81f}'), ('\u{2cea2}', '\u{2f7ff}'), ('\u{2fa1e}', '\u{e0000}'), ('\u{e0002}', '\u{e001f}'), ('\u{e0080}', '\u{e00ff}'), ('\u{e01f0}', '\u{effff}'), ('\u{ffffe}', '\u{fffff}'), ('\u{10fffe}', '\u{10ffff}') ]; pub const Co_table: &'static [(char, char)] = &[ ('\u{e000}', '\u{f8ff}'), ('\u{f0000}', '\u{ffffd}'), ('\u{100000}', '\u{10fffd}') ]; pub const L_table: &'static [(char, char)] = &[ ('\u{41}', '\u{5a}'), ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), ('\u{b5}', '\u{b5}'), ('\u{ba}', '\u{ba}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2c1}'), ('\u{2c6}', '\u{2d1}'), ('\u{2e0}', '\u{2e4}'), ('\u{2ec}', '\u{2ec}'), ('\u{2ee}', '\u{2ee}'), ('\u{370}', '\u{374}'), ('\u{376}', '\u{377}'), ('\u{37a}', '\u{37d}'), ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{386}'), ('\u{388}', '\u{38a}'), ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{3a1}'), ('\u{3a3}', '\u{3f5}'), ('\u{3f7}', '\u{481}'), ('\u{48a}', '\u{52f}'), ('\u{531}', '\u{556}'), ('\u{559}', '\u{559}'), ('\u{561}', '\u{587}'), ('\u{5d0}', '\u{5ea}'), ('\u{5f0}', '\u{5f2}'), ('\u{620}', '\u{64a}'), ('\u{66e}', '\u{66f}'), ('\u{671}', '\u{6d3}'), ('\u{6d5}', '\u{6d5}'), ('\u{6e5}', '\u{6e6}'), ('\u{6ee}', '\u{6ef}'), ('\u{6fa}', '\u{6fc}'), ('\u{6ff}', '\u{6ff}'), ('\u{710}', '\u{710}'), ('\u{712}', '\u{72f}'), ('\u{74d}', '\u{7a5}'), ('\u{7b1}', '\u{7b1}'), ('\u{7ca}', '\u{7ea}'), ('\u{7f4}', '\u{7f5}'), ('\u{7fa}', '\u{7fa}'), ('\u{800}', '\u{815}'), ('\u{81a}', '\u{81a}'), ('\u{824}', '\u{824}'), ('\u{828}', '\u{828}'), ('\u{840}', '\u{858}'), ('\u{8a0}', '\u{8b4}'), ('\u{904}', '\u{939}'), ('\u{93d}', '\u{93d}'), ('\u{950}', '\u{950}'), ('\u{958}', '\u{961}'), ('\u{971}', '\u{980}'), ('\u{985}', '\u{98c}'), ('\u{98f}', '\u{990}'), ('\u{993}', '\u{9a8}'), ('\u{9aa}', '\u{9b0}'), ('\u{9b2}', '\u{9b2}'), ('\u{9b6}', '\u{9b9}'), ('\u{9bd}', '\u{9bd}'), ('\u{9ce}', '\u{9ce}'), ('\u{9dc}', '\u{9dd}'), ('\u{9df}', '\u{9e1}'), ('\u{9f0}', '\u{9f1}'), ('\u{a05}', '\u{a0a}'), ('\u{a0f}', '\u{a10}'), ('\u{a13}', '\u{a28}'), ('\u{a2a}', '\u{a30}'), ('\u{a32}', '\u{a33}'), ('\u{a35}', '\u{a36}'), ('\u{a38}', '\u{a39}'), ('\u{a59}', '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), ('\u{a72}', '\u{a74}'), ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), ('\u{a93}', '\u{aa8}'), ('\u{aaa}', '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), ('\u{ab5}', '\u{ab9}'), ('\u{abd}', '\u{abd}'), ('\u{ad0}', '\u{ad0}'), ('\u{ae0}', '\u{ae1}'), ('\u{af9}', '\u{af9}'), ('\u{b05}', '\u{b0c}'), ('\u{b0f}', '\u{b10}'), ('\u{b13}', '\u{b28}'), ('\u{b2a}', '\u{b30}'), ('\u{b32}', '\u{b33}'), ('\u{b35}', '\u{b39}'), ('\u{b3d}', '\u{b3d}'), ('\u{b5c}', '\u{b5d}'), ('\u{b5f}', '\u{b61}'), ('\u{b71}', '\u{b71}'), ('\u{b83}', '\u{b83}'), ('\u{b85}', '\u{b8a}'), ('\u{b8e}', '\u{b90}'), ('\u{b92}', '\u{b95}'), ('\u{b99}', '\u{b9a}'), ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', '\u{b9f}'), ('\u{ba3}', '\u{ba4}'), ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), ('\u{bd0}', '\u{bd0}'), ('\u{c05}', '\u{c0c}'), ('\u{c0e}', '\u{c10}'), ('\u{c12}', '\u{c28}'), ('\u{c2a}', '\u{c39}'), ('\u{c3d}', '\u{c3d}'), ('\u{c58}', '\u{c5a}'), ('\u{c60}', '\u{c61}'), ('\u{c85}', '\u{c8c}'), ('\u{c8e}', '\u{c90}'), ('\u{c92}', '\u{ca8}'), ('\u{caa}', '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), ('\u{cbd}', '\u{cbd}'), ('\u{cde}', '\u{cde}'), ('\u{ce0}', '\u{ce1}'), ('\u{cf1}', '\u{cf2}'), ('\u{d05}', '\u{d0c}'), ('\u{d0e}', '\u{d10}'), ('\u{d12}', '\u{d3a}'), ('\u{d3d}', '\u{d3d}'), ('\u{d4e}', '\u{d4e}'), ('\u{d5f}', '\u{d61}'), ('\u{d7a}', '\u{d7f}'), ('\u{d85}', '\u{d96}'), ('\u{d9a}', '\u{db1}'), ('\u{db3}', '\u{dbb}'), ('\u{dbd}', '\u{dbd}'), ('\u{dc0}', '\u{dc6}'), ('\u{e01}', '\u{e30}'), ('\u{e32}', '\u{e33}'), ('\u{e40}', '\u{e46}'), ('\u{e81}', '\u{e82}'), ('\u{e84}', '\u{e84}'), ('\u{e87}', '\u{e88}'), ('\u{e8a}', '\u{e8a}'), ('\u{e8d}', '\u{e8d}'), ('\u{e94}', '\u{e97}'), ('\u{e99}', '\u{e9f}'), ('\u{ea1}', '\u{ea3}'), ('\u{ea5}', '\u{ea5}'), ('\u{ea7}', '\u{ea7}'), ('\u{eaa}', '\u{eab}'), ('\u{ead}', '\u{eb0}'), ('\u{eb2}', '\u{eb3}'), ('\u{ebd}', '\u{ebd}'), ('\u{ec0}', '\u{ec4}'), ('\u{ec6}', '\u{ec6}'), ('\u{edc}', '\u{edf}'), ('\u{f00}', '\u{f00}'), ('\u{f40}', '\u{f47}'), ('\u{f49}', '\u{f6c}'), ('\u{f88}', '\u{f8c}'), ('\u{1000}', '\u{102a}'), ('\u{103f}', '\u{103f}'), ('\u{1050}', '\u{1055}'), ('\u{105a}', '\u{105d}'), ('\u{1061}', '\u{1061}'), ('\u{1065}', '\u{1066}'), ('\u{106e}', '\u{1070}'), ('\u{1075}', '\u{1081}'), ('\u{108e}', '\u{108e}'), ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', '\u{10cd}'), ('\u{10d0}', '\u{10fa}'), ('\u{10fc}', '\u{1248}'), ('\u{124a}', '\u{124d}'), ('\u{1250}', '\u{1256}'), ('\u{1258}', '\u{1258}'), ('\u{125a}', '\u{125d}'), ('\u{1260}', '\u{1288}'), ('\u{128a}', '\u{128d}'), ('\u{1290}', '\u{12b0}'), ('\u{12b2}', '\u{12b5}'), ('\u{12b8}', '\u{12be}'), ('\u{12c0}', '\u{12c0}'), ('\u{12c2}', '\u{12c5}'), ('\u{12c8}', '\u{12d6}'), ('\u{12d8}', '\u{1310}'), ('\u{1312}', '\u{1315}'), ('\u{1318}', '\u{135a}'), ('\u{1380}', '\u{138f}'), ('\u{13a0}', '\u{13f5}'), ('\u{13f8}', '\u{13fd}'), ('\u{1401}', '\u{166c}'), ('\u{166f}', '\u{167f}'), ('\u{1681}', '\u{169a}'), ('\u{16a0}', '\u{16ea}'), ('\u{16f1}', '\u{16f8}'), ('\u{1700}', '\u{170c}'), ('\u{170e}', '\u{1711}'), ('\u{1720}', '\u{1731}'), ('\u{1740}', '\u{1751}'), ('\u{1760}', '\u{176c}'), ('\u{176e}', '\u{1770}'), ('\u{1780}', '\u{17b3}'), ('\u{17d7}', '\u{17d7}'), ('\u{17dc}', '\u{17dc}'), ('\u{1820}', '\u{1877}'), ('\u{1880}', '\u{18a8}'), ('\u{18aa}', '\u{18aa}'), ('\u{18b0}', '\u{18f5}'), ('\u{1900}', '\u{191e}'), ('\u{1950}', '\u{196d}'), ('\u{1970}', '\u{1974}'), ('\u{1980}', '\u{19ab}'), ('\u{19b0}', '\u{19c9}'), ('\u{1a00}', '\u{1a16}'), ('\u{1a20}', '\u{1a54}'), ('\u{1aa7}', '\u{1aa7}'), ('\u{1b05}', '\u{1b33}'), ('\u{1b45}', '\u{1b4b}'), ('\u{1b83}', '\u{1ba0}'), ('\u{1bae}', '\u{1baf}'), ('\u{1bba}', '\u{1be5}'), ('\u{1c00}', '\u{1c23}'), ('\u{1c4d}', '\u{1c4f}'), ('\u{1c5a}', '\u{1c7d}'), ('\u{1ce9}', '\u{1cec}'), ('\u{1cee}', '\u{1cf1}'), ('\u{1cf5}', '\u{1cf6}'), ('\u{1d00}', '\u{1dbf}'), ('\u{1e00}', '\u{1f15}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', '\u{1f45}'), ('\u{1f48}', '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f59}', '\u{1f59}'), ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}', '\u{1fb4}'), ('\u{1fb6}', '\u{1fbc}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'), ('\u{1fc6}', '\u{1fcc}'), ('\u{1fd0}', '\u{1fd3}'), ('\u{1fd6}', '\u{1fdb}'), ('\u{1fe0}', '\u{1fec}'), ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}', '\u{1ffc}'), ('\u{2071}', '\u{2071}'), ('\u{207f}', '\u{207f}'), ('\u{2090}', '\u{209c}'), ('\u{2102}', '\u{2102}'), ('\u{2107}', '\u{2107}'), ('\u{210a}', '\u{2113}'), ('\u{2115}', '\u{2115}'), ('\u{2119}', '\u{211d}'), ('\u{2124}', '\u{2124}'), ('\u{2126}', '\u{2126}'), ('\u{2128}', '\u{2128}'), ('\u{212a}', '\u{212d}'), ('\u{212f}', '\u{2139}'), ('\u{213c}', '\u{213f}'), ('\u{2145}', '\u{2149}'), ('\u{214e}', '\u{214e}'), ('\u{2183}', '\u{2184}'), ('\u{2c00}', '\u{2c2e}'), ('\u{2c30}', '\u{2c5e}'), ('\u{2c60}', '\u{2ce4}'), ('\u{2ceb}', '\u{2cee}'), ('\u{2cf2}', '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'), ('\u{2d30}', '\u{2d67}'), ('\u{2d6f}', '\u{2d6f}'), ('\u{2d80}', '\u{2d96}'), ('\u{2da0}', '\u{2da6}'), ('\u{2da8}', '\u{2dae}'), ('\u{2db0}', '\u{2db6}'), ('\u{2db8}', '\u{2dbe}'), ('\u{2dc0}', '\u{2dc6}'), ('\u{2dc8}', '\u{2dce}'), ('\u{2dd0}', '\u{2dd6}'), ('\u{2dd8}', '\u{2dde}'), ('\u{2e2f}', '\u{2e2f}'), ('\u{3005}', '\u{3006}'), ('\u{3031}', '\u{3035}'), ('\u{303b}', '\u{303c}'), ('\u{3041}', '\u{3096}'), ('\u{309d}', '\u{309f}'), ('\u{30a1}', '\u{30fa}'), ('\u{30fc}', '\u{30ff}'), ('\u{3105}', '\u{312d}'), ('\u{3131}', '\u{318e}'), ('\u{31a0}', '\u{31ba}'), ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{4db5}'), ('\u{4e00}', '\u{9fd5}'), ('\u{a000}', '\u{a48c}'), ('\u{a4d0}', '\u{a4fd}'), ('\u{a500}', '\u{a60c}'), ('\u{a610}', '\u{a61f}'), ('\u{a62a}', '\u{a62b}'), ('\u{a640}', '\u{a66e}'), ('\u{a67f}', '\u{a69d}'), ('\u{a6a0}', '\u{a6e5}'), ('\u{a717}', '\u{a71f}'), ('\u{a722}', '\u{a788}'), ('\u{a78b}', '\u{a7ad}'), ('\u{a7b0}', '\u{a7b7}'), ('\u{a7f7}', '\u{a801}'), ('\u{a803}', '\u{a805}'), ('\u{a807}', '\u{a80a}'), ('\u{a80c}', '\u{a822}'), ('\u{a840}', '\u{a873}'), ('\u{a882}', '\u{a8b3}'), ('\u{a8f2}', '\u{a8f7}'), ('\u{a8fb}', '\u{a8fb}'), ('\u{a8fd}', '\u{a8fd}'), ('\u{a90a}', '\u{a925}'), ('\u{a930}', '\u{a946}'), ('\u{a960}', '\u{a97c}'), ('\u{a984}', '\u{a9b2}'), ('\u{a9cf}', '\u{a9cf}'), ('\u{a9e0}', '\u{a9e4}'), ('\u{a9e6}', '\u{a9ef}'), ('\u{a9fa}', '\u{a9fe}'), ('\u{aa00}', '\u{aa28}'), ('\u{aa40}', '\u{aa42}'), ('\u{aa44}', '\u{aa4b}'), ('\u{aa60}', '\u{aa76}'), ('\u{aa7a}', '\u{aa7a}'), ('\u{aa7e}', '\u{aaaf}'), ('\u{aab1}', '\u{aab1}'), ('\u{aab5}', '\u{aab6}'), ('\u{aab9}', '\u{aabd}'), ('\u{aac0}', '\u{aac0}'), ('\u{aac2}', '\u{aac2}'), ('\u{aadb}', '\u{aadd}'), ('\u{aae0}', '\u{aaea}'), ('\u{aaf2}', '\u{aaf4}'), ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab5c}', '\u{ab65}'), ('\u{ab70}', '\u{abe2}'), ('\u{ac00}', '\u{d7a3}'), ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', '\u{fa6d}'), ('\u{fa70}', '\u{fad9}'), ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{fb1d}', '\u{fb1d}'), ('\u{fb1f}', '\u{fb28}'), ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), ('\u{fb46}', '\u{fbb1}'), ('\u{fbd3}', '\u{fd3d}'), ('\u{fd50}', '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}', '\u{fdfb}'), ('\u{fe70}', '\u{fe74}'), ('\u{fe76}', '\u{fefc}'), ('\u{ff21}', '\u{ff3a}'), ('\u{ff41}', '\u{ff5a}'), ('\u{ff66}', '\u{ffbe}'), ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'), ('\u{10000}', '\u{1000b}'), ('\u{1000d}', '\u{10026}'), ('\u{10028}', '\u{1003a}'), ('\u{1003c}', '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'), ('\u{10080}', '\u{100fa}'), ('\u{10280}', '\u{1029c}'), ('\u{102a0}', '\u{102d0}'), ('\u{10300}', '\u{1031f}'), ('\u{10330}', '\u{10340}'), ('\u{10342}', '\u{10349}'), ('\u{10350}', '\u{10375}'), ('\u{10380}', '\u{1039d}'), ('\u{103a0}', '\u{103c3}'), ('\u{103c8}', '\u{103cf}'), ('\u{10400}', '\u{1049d}'), ('\u{10500}', '\u{10527}'), ('\u{10530}', '\u{10563}'), ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), ('\u{10760}', '\u{10767}'), ('\u{10800}', '\u{10805}'), ('\u{10808}', '\u{10808}'), ('\u{1080a}', '\u{10835}'), ('\u{10837}', '\u{10838}'), ('\u{1083c}', '\u{1083c}'), ('\u{1083f}', '\u{10855}'), ('\u{10860}', '\u{10876}'), ('\u{10880}', '\u{1089e}'), ('\u{108e0}', '\u{108f2}'), ('\u{108f4}', '\u{108f5}'), ('\u{10900}', '\u{10915}'), ('\u{10920}', '\u{10939}'), ('\u{10980}', '\u{109b7}'), ('\u{109be}', '\u{109bf}'), ('\u{10a00}', '\u{10a00}'), ('\u{10a10}', '\u{10a13}'), ('\u{10a15}', '\u{10a17}'), ('\u{10a19}', '\u{10a33}'), ('\u{10a60}', '\u{10a7c}'), ('\u{10a80}', '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'), ('\u{10ac9}', '\u{10ae4}'), ('\u{10b00}', '\u{10b35}'), ('\u{10b40}', '\u{10b55}'), ('\u{10b60}', '\u{10b72}'), ('\u{10b80}', '\u{10b91}'), ('\u{10c00}', '\u{10c48}'), ('\u{10c80}', '\u{10cb2}'), ('\u{10cc0}', '\u{10cf2}'), ('\u{11003}', '\u{11037}'), ('\u{11083}', '\u{110af}'), ('\u{110d0}', '\u{110e8}'), ('\u{11103}', '\u{11126}'), ('\u{11150}', '\u{11172}'), ('\u{11176}', '\u{11176}'), ('\u{11183}', '\u{111b2}'), ('\u{111c1}', '\u{111c4}'), ('\u{111da}', '\u{111da}'), ('\u{111dc}', '\u{111dc}'), ('\u{11200}', '\u{11211}'), ('\u{11213}', '\u{1122b}'), ('\u{11280}', '\u{11286}'), ('\u{11288}', '\u{11288}'), ('\u{1128a}', '\u{1128d}'), ('\u{1128f}', '\u{1129d}'), ('\u{1129f}', '\u{112a8}'), ('\u{112b0}', '\u{112de}'), ('\u{11305}', '\u{1130c}'), ('\u{1130f}', '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'), ('\u{11332}', '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133d}', '\u{1133d}'), ('\u{11350}', '\u{11350}'), ('\u{1135d}', '\u{11361}'), ('\u{11480}', '\u{114af}'), ('\u{114c4}', '\u{114c5}'), ('\u{114c7}', '\u{114c7}'), ('\u{11580}', '\u{115ae}'), ('\u{115d8}', '\u{115db}'), ('\u{11600}', '\u{1162f}'), ('\u{11644}', '\u{11644}'), ('\u{11680}', '\u{116aa}'), ('\u{11700}', '\u{11719}'), ('\u{118a0}', '\u{118df}'), ('\u{118ff}', '\u{118ff}'), ('\u{11ac0}', '\u{11af8}'), ('\u{12000}', '\u{12399}'), ('\u{12480}', '\u{12543}'), ('\u{13000}', '\u{1342e}'), ('\u{14400}', '\u{14646}'), ('\u{16800}', '\u{16a38}'), ('\u{16a40}', '\u{16a5e}'), ('\u{16ad0}', '\u{16aed}'), ('\u{16b00}', '\u{16b2f}'), ('\u{16b40}', '\u{16b43}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}'), ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f50}'), ('\u{16f93}', '\u{16f9f}'), ('\u{1b000}', '\u{1b001}'), ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}', '\u{1bc99}'), ('\u{1d400}', '\u{1d454}'), ('\u{1d456}', '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}', '\u{1d6a5}'), ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}', '\u{1d6fa}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', '\u{1d734}'), ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d76e}'), ('\u{1d770}', '\u{1d788}'), ('\u{1d78a}', '\u{1d7a8}'), ('\u{1d7aa}', '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7cb}'), ('\u{1e800}', '\u{1e8c4}'), ('\u{1ee00}', '\u{1ee03}'), ('\u{1ee05}', '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', '\u{1ee47}'), ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}', '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), ('\u{1ee57}', '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', '\u{1ee77}'), ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}', '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), ('\u{1eea5}', '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}', '\u{2b734}'), ('\u{2b740}', '\u{2b81d}'), ('\u{2b820}', '\u{2cea1}'), ('\u{2f800}', '\u{2fa1d}') ]; pub const LC_table: &'static [(char, char)] = &[ ('\u{41}', '\u{5a}'), ('\u{61}', '\u{7a}'), ('\u{b5}', '\u{b5}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{1ba}'), ('\u{1bc}', '\u{1bf}'), ('\u{1c4}', '\u{293}'), ('\u{295}', '\u{2af}'), ('\u{370}', '\u{373}'), ('\u{376}', '\u{377}'), ('\u{37b}', '\u{37d}'), ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{386}'), ('\u{388}', '\u{38a}'), ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{3a1}'), ('\u{3a3}', '\u{3f5}'), ('\u{3f7}', '\u{481}'), ('\u{48a}', '\u{52f}'), ('\u{531}', '\u{556}'), ('\u{561}', '\u{587}'), ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', '\u{10cd}'), ('\u{13a0}', '\u{13f5}'), ('\u{13f8}', '\u{13fd}'), ('\u{1d00}', '\u{1d2b}'), ('\u{1d6b}', '\u{1d77}'), ('\u{1d79}', '\u{1d9a}'), ('\u{1e00}', '\u{1f15}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', '\u{1f45}'), ('\u{1f48}', '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f59}', '\u{1f59}'), ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}', '\u{1fb4}'), ('\u{1fb6}', '\u{1fbc}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'), ('\u{1fc6}', '\u{1fcc}'), ('\u{1fd0}', '\u{1fd3}'), ('\u{1fd6}', '\u{1fdb}'), ('\u{1fe0}', '\u{1fec}'), ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}', '\u{1ffc}'), ('\u{2102}', '\u{2102}'), ('\u{2107}', '\u{2107}'), ('\u{210a}', '\u{2113}'), ('\u{2115}', '\u{2115}'), ('\u{2119}', '\u{211d}'), ('\u{2124}', '\u{2124}'), ('\u{2126}', '\u{2126}'), ('\u{2128}', '\u{2128}'), ('\u{212a}', '\u{212d}'), ('\u{212f}', '\u{2134}'), ('\u{2139}', '\u{2139}'), ('\u{213c}', '\u{213f}'), ('\u{2145}', '\u{2149}'), ('\u{214e}', '\u{214e}'), ('\u{2183}', '\u{2184}'), ('\u{2c00}', '\u{2c2e}'), ('\u{2c30}', '\u{2c5e}'), ('\u{2c60}', '\u{2c7b}'), ('\u{2c7e}', '\u{2ce4}'), ('\u{2ceb}', '\u{2cee}'), ('\u{2cf2}', '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'), ('\u{a640}', '\u{a66d}'), ('\u{a680}', '\u{a69b}'), ('\u{a722}', '\u{a76f}'), ('\u{a771}', '\u{a787}'), ('\u{a78b}', '\u{a78e}'), ('\u{a790}', '\u{a7ad}'), ('\u{a7b0}', '\u{a7b7}'), ('\u{a7fa}', '\u{a7fa}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab60}', '\u{ab65}'), ('\u{ab70}', '\u{abbf}'), ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{ff21}', '\u{ff3a}'), ('\u{ff41}', '\u{ff5a}'), ('\u{10400}', '\u{1044f}'), ('\u{10c80}', '\u{10cb2}'), ('\u{10cc0}', '\u{10cf2}'), ('\u{118a0}', '\u{118df}'), ('\u{1d400}', '\u{1d454}'), ('\u{1d456}', '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}', '\u{1d6a5}'), ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}', '\u{1d6fa}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', '\u{1d734}'), ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d76e}'), ('\u{1d770}', '\u{1d788}'), ('\u{1d78a}', '\u{1d7a8}'), ('\u{1d7aa}', '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7cb}') ]; pub const Ll_table: &'static [(char, char)] = &[ ('\u{61}', '\u{7a}'), ('\u{b5}', '\u{b5}'), ('\u{df}', '\u{f6}'), ('\u{f8}', '\u{ff}'), ('\u{101}', '\u{101}'), ('\u{103}', '\u{103}'), ('\u{105}', '\u{105}'), ('\u{107}', '\u{107}'), ('\u{109}', '\u{109}'), ('\u{10b}', '\u{10b}'), ('\u{10d}', '\u{10d}'), ('\u{10f}', '\u{10f}'), ('\u{111}', '\u{111}'), ('\u{113}', '\u{113}'), ('\u{115}', '\u{115}'), ('\u{117}', '\u{117}'), ('\u{119}', '\u{119}'), ('\u{11b}', '\u{11b}'), ('\u{11d}', '\u{11d}'), ('\u{11f}', '\u{11f}'), ('\u{121}', '\u{121}'), ('\u{123}', '\u{123}'), ('\u{125}', '\u{125}'), ('\u{127}', '\u{127}'), ('\u{129}', '\u{129}'), ('\u{12b}', '\u{12b}'), ('\u{12d}', '\u{12d}'), ('\u{12f}', '\u{12f}'), ('\u{131}', '\u{131}'), ('\u{133}', '\u{133}'), ('\u{135}', '\u{135}'), ('\u{137}', '\u{138}'), ('\u{13a}', '\u{13a}'), ('\u{13c}', '\u{13c}'), ('\u{13e}', '\u{13e}'), ('\u{140}', '\u{140}'), ('\u{142}', '\u{142}'), ('\u{144}', '\u{144}'), ('\u{146}', '\u{146}'), ('\u{148}', '\u{149}'), ('\u{14b}', '\u{14b}'), ('\u{14d}', '\u{14d}'), ('\u{14f}', '\u{14f}'), ('\u{151}', '\u{151}'), ('\u{153}', '\u{153}'), ('\u{155}', '\u{155}'), ('\u{157}', '\u{157}'), ('\u{159}', '\u{159}'), ('\u{15b}', '\u{15b}'), ('\u{15d}', '\u{15d}'), ('\u{15f}', '\u{15f}'), ('\u{161}', '\u{161}'), ('\u{163}', '\u{163}'), ('\u{165}', '\u{165}'), ('\u{167}', '\u{167}'), ('\u{169}', '\u{169}'), ('\u{16b}', '\u{16b}'), ('\u{16d}', '\u{16d}'), ('\u{16f}', '\u{16f}'), ('\u{171}', '\u{171}'), ('\u{173}', '\u{173}'), ('\u{175}', '\u{175}'), ('\u{177}', '\u{177}'), ('\u{17a}', '\u{17a}'), ('\u{17c}', '\u{17c}'), ('\u{17e}', '\u{180}'), ('\u{183}', '\u{183}'), ('\u{185}', '\u{185}'), ('\u{188}', '\u{188}'), ('\u{18c}', '\u{18d}'), ('\u{192}', '\u{192}'), ('\u{195}', '\u{195}'), ('\u{199}', '\u{19b}'), ('\u{19e}', '\u{19e}'), ('\u{1a1}', '\u{1a1}'), ('\u{1a3}', '\u{1a3}'), ('\u{1a5}', '\u{1a5}'), ('\u{1a8}', '\u{1a8}'), ('\u{1aa}', '\u{1ab}'), ('\u{1ad}', '\u{1ad}'), ('\u{1b0}', '\u{1b0}'), ('\u{1b4}', '\u{1b4}'), ('\u{1b6}', '\u{1b6}'), ('\u{1b9}', '\u{1ba}'), ('\u{1bd}', '\u{1bf}'), ('\u{1c6}', '\u{1c6}'), ('\u{1c9}', '\u{1c9}'), ('\u{1cc}', '\u{1cc}'), ('\u{1ce}', '\u{1ce}'), ('\u{1d0}', '\u{1d0}'), ('\u{1d2}', '\u{1d2}'), ('\u{1d4}', '\u{1d4}'), ('\u{1d6}', '\u{1d6}'), ('\u{1d8}', '\u{1d8}'), ('\u{1da}', '\u{1da}'), ('\u{1dc}', '\u{1dd}'), ('\u{1df}', '\u{1df}'), ('\u{1e1}', '\u{1e1}'), ('\u{1e3}', '\u{1e3}'), ('\u{1e5}', '\u{1e5}'), ('\u{1e7}', '\u{1e7}'), ('\u{1e9}', '\u{1e9}'), ('\u{1eb}', '\u{1eb}'), ('\u{1ed}', '\u{1ed}'), ('\u{1ef}', '\u{1f0}'), ('\u{1f3}', '\u{1f3}'), ('\u{1f5}', '\u{1f5}'), ('\u{1f9}', '\u{1f9}'), ('\u{1fb}', '\u{1fb}'), ('\u{1fd}', '\u{1fd}'), ('\u{1ff}', '\u{1ff}'), ('\u{201}', '\u{201}'), ('\u{203}', '\u{203}'), ('\u{205}', '\u{205}'), ('\u{207}', '\u{207}'), ('\u{209}', '\u{209}'), ('\u{20b}', '\u{20b}'), ('\u{20d}', '\u{20d}'), ('\u{20f}', '\u{20f}'), ('\u{211}', '\u{211}'), ('\u{213}', '\u{213}'), ('\u{215}', '\u{215}'), ('\u{217}', '\u{217}'), ('\u{219}', '\u{219}'), ('\u{21b}', '\u{21b}'), ('\u{21d}', '\u{21d}'), ('\u{21f}', '\u{21f}'), ('\u{221}', '\u{221}'), ('\u{223}', '\u{223}'), ('\u{225}', '\u{225}'), ('\u{227}', '\u{227}'), ('\u{229}', '\u{229}'), ('\u{22b}', '\u{22b}'), ('\u{22d}', '\u{22d}'), ('\u{22f}', '\u{22f}'), ('\u{231}', '\u{231}'), ('\u{233}', '\u{239}'), ('\u{23c}', '\u{23c}'), ('\u{23f}', '\u{240}'), ('\u{242}', '\u{242}'), ('\u{247}', '\u{247}'), ('\u{249}', '\u{249}'), ('\u{24b}', '\u{24b}'), ('\u{24d}', '\u{24d}'), ('\u{24f}', '\u{293}'), ('\u{295}', '\u{2af}'), ('\u{371}', '\u{371}'), ('\u{373}', '\u{373}'), ('\u{377}', '\u{377}'), ('\u{37b}', '\u{37d}'), ('\u{390}', '\u{390}'), ('\u{3ac}', '\u{3ce}'), ('\u{3d0}', '\u{3d1}'), ('\u{3d5}', '\u{3d7}'), ('\u{3d9}', '\u{3d9}'), ('\u{3db}', '\u{3db}'), ('\u{3dd}', '\u{3dd}'), ('\u{3df}', '\u{3df}'), ('\u{3e1}', '\u{3e1}'), ('\u{3e3}', '\u{3e3}'), ('\u{3e5}', '\u{3e5}'), ('\u{3e7}', '\u{3e7}'), ('\u{3e9}', '\u{3e9}'), ('\u{3eb}', '\u{3eb}'), ('\u{3ed}', '\u{3ed}'), ('\u{3ef}', '\u{3f3}'), ('\u{3f5}', '\u{3f5}'), ('\u{3f8}', '\u{3f8}'), ('\u{3fb}', '\u{3fc}'), ('\u{430}', '\u{45f}'), ('\u{461}', '\u{461}'), ('\u{463}', '\u{463}'), ('\u{465}', '\u{465}'), ('\u{467}', '\u{467}'), ('\u{469}', '\u{469}'), ('\u{46b}', '\u{46b}'), ('\u{46d}', '\u{46d}'), ('\u{46f}', '\u{46f}'), ('\u{471}', '\u{471}'), ('\u{473}', '\u{473}'), ('\u{475}', '\u{475}'), ('\u{477}', '\u{477}'), ('\u{479}', '\u{479}'), ('\u{47b}', '\u{47b}'), ('\u{47d}', '\u{47d}'), ('\u{47f}', '\u{47f}'), ('\u{481}', '\u{481}'), ('\u{48b}', '\u{48b}'), ('\u{48d}', '\u{48d}'), ('\u{48f}', '\u{48f}'), ('\u{491}', '\u{491}'), ('\u{493}', '\u{493}'), ('\u{495}', '\u{495}'), ('\u{497}', '\u{497}'), ('\u{499}', '\u{499}'), ('\u{49b}', '\u{49b}'), ('\u{49d}', '\u{49d}'), ('\u{49f}', '\u{49f}'), ('\u{4a1}', '\u{4a1}'), ('\u{4a3}', '\u{4a3}'), ('\u{4a5}', '\u{4a5}'), ('\u{4a7}', '\u{4a7}'), ('\u{4a9}', '\u{4a9}'), ('\u{4ab}', '\u{4ab}'), ('\u{4ad}', '\u{4ad}'), ('\u{4af}', '\u{4af}'), ('\u{4b1}', '\u{4b1}'), ('\u{4b3}', '\u{4b3}'), ('\u{4b5}', '\u{4b5}'), ('\u{4b7}', '\u{4b7}'), ('\u{4b9}', '\u{4b9}'), ('\u{4bb}', '\u{4bb}'), ('\u{4bd}', '\u{4bd}'), ('\u{4bf}', '\u{4bf}'), ('\u{4c2}', '\u{4c2}'), ('\u{4c4}', '\u{4c4}'), ('\u{4c6}', '\u{4c6}'), ('\u{4c8}', '\u{4c8}'), ('\u{4ca}', '\u{4ca}'), ('\u{4cc}', '\u{4cc}'), ('\u{4ce}', '\u{4cf}'), ('\u{4d1}', '\u{4d1}'), ('\u{4d3}', '\u{4d3}'), ('\u{4d5}', '\u{4d5}'), ('\u{4d7}', '\u{4d7}'), ('\u{4d9}', '\u{4d9}'), ('\u{4db}', '\u{4db}'), ('\u{4dd}', '\u{4dd}'), ('\u{4df}', '\u{4df}'), ('\u{4e1}', '\u{4e1}'), ('\u{4e3}', '\u{4e3}'), ('\u{4e5}', '\u{4e5}'), ('\u{4e7}', '\u{4e7}'), ('\u{4e9}', '\u{4e9}'), ('\u{4eb}', '\u{4eb}'), ('\u{4ed}', '\u{4ed}'), ('\u{4ef}', '\u{4ef}'), ('\u{4f1}', '\u{4f1}'), ('\u{4f3}', '\u{4f3}'), ('\u{4f5}', '\u{4f5}'), ('\u{4f7}', '\u{4f7}'), ('\u{4f9}', '\u{4f9}'), ('\u{4fb}', '\u{4fb}'), ('\u{4fd}', '\u{4fd}'), ('\u{4ff}', '\u{4ff}'), ('\u{501}', '\u{501}'), ('\u{503}', '\u{503}'), ('\u{505}', '\u{505}'), ('\u{507}', '\u{507}'), ('\u{509}', '\u{509}'), ('\u{50b}', '\u{50b}'), ('\u{50d}', '\u{50d}'), ('\u{50f}', '\u{50f}'), ('\u{511}', '\u{511}'), ('\u{513}', '\u{513}'), ('\u{515}', '\u{515}'), ('\u{517}', '\u{517}'), ('\u{519}', '\u{519}'), ('\u{51b}', '\u{51b}'), ('\u{51d}', '\u{51d}'), ('\u{51f}', '\u{51f}'), ('\u{521}', '\u{521}'), ('\u{523}', '\u{523}'), ('\u{525}', '\u{525}'), ('\u{527}', '\u{527}'), ('\u{529}', '\u{529}'), ('\u{52b}', '\u{52b}'), ('\u{52d}', '\u{52d}'), ('\u{52f}', '\u{52f}'), ('\u{561}', '\u{587}'), ('\u{13f8}', '\u{13fd}'), ('\u{1d00}', '\u{1d2b}'), ('\u{1d6b}', '\u{1d77}'), ('\u{1d79}', '\u{1d9a}'), ('\u{1e01}', '\u{1e01}'), ('\u{1e03}', '\u{1e03}'), ('\u{1e05}', '\u{1e05}'), ('\u{1e07}', '\u{1e07}'), ('\u{1e09}', '\u{1e09}'), ('\u{1e0b}', '\u{1e0b}'), ('\u{1e0d}', '\u{1e0d}'), ('\u{1e0f}', '\u{1e0f}'), ('\u{1e11}', '\u{1e11}'), ('\u{1e13}', '\u{1e13}'), ('\u{1e15}', '\u{1e15}'), ('\u{1e17}', '\u{1e17}'), ('\u{1e19}', '\u{1e19}'), ('\u{1e1b}', '\u{1e1b}'), ('\u{1e1d}', '\u{1e1d}'), ('\u{1e1f}', '\u{1e1f}'), ('\u{1e21}', '\u{1e21}'), ('\u{1e23}', '\u{1e23}'), ('\u{1e25}', '\u{1e25}'), ('\u{1e27}', '\u{1e27}'), ('\u{1e29}', '\u{1e29}'), ('\u{1e2b}', '\u{1e2b}'), ('\u{1e2d}', '\u{1e2d}'), ('\u{1e2f}', '\u{1e2f}'), ('\u{1e31}', '\u{1e31}'), ('\u{1e33}', '\u{1e33}'), ('\u{1e35}', '\u{1e35}'), ('\u{1e37}', '\u{1e37}'), ('\u{1e39}', '\u{1e39}'), ('\u{1e3b}', '\u{1e3b}'), ('\u{1e3d}', '\u{1e3d}'), ('\u{1e3f}', '\u{1e3f}'), ('\u{1e41}', '\u{1e41}'), ('\u{1e43}', '\u{1e43}'), ('\u{1e45}', '\u{1e45}'), ('\u{1e47}', '\u{1e47}'), ('\u{1e49}', '\u{1e49}'), ('\u{1e4b}', '\u{1e4b}'), ('\u{1e4d}', '\u{1e4d}'), ('\u{1e4f}', '\u{1e4f}'), ('\u{1e51}', '\u{1e51}'), ('\u{1e53}', '\u{1e53}'), ('\u{1e55}', '\u{1e55}'), ('\u{1e57}', '\u{1e57}'), ('\u{1e59}', '\u{1e59}'), ('\u{1e5b}', '\u{1e5b}'), ('\u{1e5d}', '\u{1e5d}'), ('\u{1e5f}', '\u{1e5f}'), ('\u{1e61}', '\u{1e61}'), ('\u{1e63}', '\u{1e63}'), ('\u{1e65}', '\u{1e65}'), ('\u{1e67}', '\u{1e67}'), ('\u{1e69}', '\u{1e69}'), ('\u{1e6b}', '\u{1e6b}'), ('\u{1e6d}', '\u{1e6d}'), ('\u{1e6f}', '\u{1e6f}'), ('\u{1e71}', '\u{1e71}'), ('\u{1e73}', '\u{1e73}'), ('\u{1e75}', '\u{1e75}'), ('\u{1e77}', '\u{1e77}'), ('\u{1e79}', '\u{1e79}'), ('\u{1e7b}', '\u{1e7b}'), ('\u{1e7d}', '\u{1e7d}'), ('\u{1e7f}', '\u{1e7f}'), ('\u{1e81}', '\u{1e81}'), ('\u{1e83}', '\u{1e83}'), ('\u{1e85}', '\u{1e85}'), ('\u{1e87}', '\u{1e87}'), ('\u{1e89}', '\u{1e89}'), ('\u{1e8b}', '\u{1e8b}'), ('\u{1e8d}', '\u{1e8d}'), ('\u{1e8f}', '\u{1e8f}'), ('\u{1e91}', '\u{1e91}'), ('\u{1e93}', '\u{1e93}'), ('\u{1e95}', '\u{1e9d}'), ('\u{1e9f}', '\u{1e9f}'), ('\u{1ea1}', '\u{1ea1}'), ('\u{1ea3}', '\u{1ea3}'), ('\u{1ea5}', '\u{1ea5}'), ('\u{1ea7}', '\u{1ea7}'), ('\u{1ea9}', '\u{1ea9}'), ('\u{1eab}', '\u{1eab}'), ('\u{1ead}', '\u{1ead}'), ('\u{1eaf}', '\u{1eaf}'), ('\u{1eb1}', '\u{1eb1}'), ('\u{1eb3}', '\u{1eb3}'), ('\u{1eb5}', '\u{1eb5}'), ('\u{1eb7}', '\u{1eb7}'), ('\u{1eb9}', '\u{1eb9}'), ('\u{1ebb}', '\u{1ebb}'), ('\u{1ebd}', '\u{1ebd}'), ('\u{1ebf}', '\u{1ebf}'), ('\u{1ec1}', '\u{1ec1}'), ('\u{1ec3}', '\u{1ec3}'), ('\u{1ec5}', '\u{1ec5}'), ('\u{1ec7}', '\u{1ec7}'), ('\u{1ec9}', '\u{1ec9}'), ('\u{1ecb}', '\u{1ecb}'), ('\u{1ecd}', '\u{1ecd}'), ('\u{1ecf}', '\u{1ecf}'), ('\u{1ed1}', '\u{1ed1}'), ('\u{1ed3}', '\u{1ed3}'), ('\u{1ed5}', '\u{1ed5}'), ('\u{1ed7}', '\u{1ed7}'), ('\u{1ed9}', '\u{1ed9}'), ('\u{1edb}', '\u{1edb}'), ('\u{1edd}', '\u{1edd}'), ('\u{1edf}', '\u{1edf}'), ('\u{1ee1}', '\u{1ee1}'), ('\u{1ee3}', '\u{1ee3}'), ('\u{1ee5}', '\u{1ee5}'), ('\u{1ee7}', '\u{1ee7}'), ('\u{1ee9}', '\u{1ee9}'), ('\u{1eeb}', '\u{1eeb}'), ('\u{1eed}', '\u{1eed}'), ('\u{1eef}', '\u{1eef}'), ('\u{1ef1}', '\u{1ef1}'), ('\u{1ef3}', '\u{1ef3}'), ('\u{1ef5}', '\u{1ef5}'), ('\u{1ef7}', '\u{1ef7}'), ('\u{1ef9}', '\u{1ef9}'), ('\u{1efb}', '\u{1efb}'), ('\u{1efd}', '\u{1efd}'), ('\u{1eff}', '\u{1f07}'), ('\u{1f10}', '\u{1f15}'), ('\u{1f20}', '\u{1f27}'), ('\u{1f30}', '\u{1f37}'), ('\u{1f40}', '\u{1f45}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f60}', '\u{1f67}'), ('\u{1f70}', '\u{1f7d}'), ('\u{1f80}', '\u{1f87}'), ('\u{1f90}', '\u{1f97}'), ('\u{1fa0}', '\u{1fa7}'), ('\u{1fb0}', '\u{1fb4}'), ('\u{1fb6}', '\u{1fb7}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'), ('\u{1fc6}', '\u{1fc7}'), ('\u{1fd0}', '\u{1fd3}'), ('\u{1fd6}', '\u{1fd7}'), ('\u{1fe0}', '\u{1fe7}'), ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}', '\u{1ff7}'), ('\u{210a}', '\u{210a}'), ('\u{210e}', '\u{210f}'), ('\u{2113}', '\u{2113}'), ('\u{212f}', '\u{212f}'), ('\u{2134}', '\u{2134}'), ('\u{2139}', '\u{2139}'), ('\u{213c}', '\u{213d}'), ('\u{2146}', '\u{2149}'), ('\u{214e}', '\u{214e}'), ('\u{2184}', '\u{2184}'), ('\u{2c30}', '\u{2c5e}'), ('\u{2c61}', '\u{2c61}'), ('\u{2c65}', '\u{2c66}'), ('\u{2c68}', '\u{2c68}'), ('\u{2c6a}', '\u{2c6a}'), ('\u{2c6c}', '\u{2c6c}'), ('\u{2c71}', '\u{2c71}'), ('\u{2c73}', '\u{2c74}'), ('\u{2c76}', '\u{2c7b}'), ('\u{2c81}', '\u{2c81}'), ('\u{2c83}', '\u{2c83}'), ('\u{2c85}', '\u{2c85}'), ('\u{2c87}', '\u{2c87}'), ('\u{2c89}', '\u{2c89}'), ('\u{2c8b}', '\u{2c8b}'), ('\u{2c8d}', '\u{2c8d}'), ('\u{2c8f}', '\u{2c8f}'), ('\u{2c91}', '\u{2c91}'), ('\u{2c93}', '\u{2c93}'), ('\u{2c95}', '\u{2c95}'), ('\u{2c97}', '\u{2c97}'), ('\u{2c99}', '\u{2c99}'), ('\u{2c9b}', '\u{2c9b}'), ('\u{2c9d}', '\u{2c9d}'), ('\u{2c9f}', '\u{2c9f}'), ('\u{2ca1}', '\u{2ca1}'), ('\u{2ca3}', '\u{2ca3}'), ('\u{2ca5}', '\u{2ca5}'), ('\u{2ca7}', '\u{2ca7}'), ('\u{2ca9}', '\u{2ca9}'), ('\u{2cab}', '\u{2cab}'), ('\u{2cad}', '\u{2cad}'), ('\u{2caf}', '\u{2caf}'), ('\u{2cb1}', '\u{2cb1}'), ('\u{2cb3}', '\u{2cb3}'), ('\u{2cb5}', '\u{2cb5}'), ('\u{2cb7}', '\u{2cb7}'), ('\u{2cb9}', '\u{2cb9}'), ('\u{2cbb}', '\u{2cbb}'), ('\u{2cbd}', '\u{2cbd}'), ('\u{2cbf}', '\u{2cbf}'), ('\u{2cc1}', '\u{2cc1}'), ('\u{2cc3}', '\u{2cc3}'), ('\u{2cc5}', '\u{2cc5}'), ('\u{2cc7}', '\u{2cc7}'), ('\u{2cc9}', '\u{2cc9}'), ('\u{2ccb}', '\u{2ccb}'), ('\u{2ccd}', '\u{2ccd}'), ('\u{2ccf}', '\u{2ccf}'), ('\u{2cd1}', '\u{2cd1}'), ('\u{2cd3}', '\u{2cd3}'), ('\u{2cd5}', '\u{2cd5}'), ('\u{2cd7}', '\u{2cd7}'), ('\u{2cd9}', '\u{2cd9}'), ('\u{2cdb}', '\u{2cdb}'), ('\u{2cdd}', '\u{2cdd}'), ('\u{2cdf}', '\u{2cdf}'), ('\u{2ce1}', '\u{2ce1}'), ('\u{2ce3}', '\u{2ce4}'), ('\u{2cec}', '\u{2cec}'), ('\u{2cee}', '\u{2cee}'), ('\u{2cf3}', '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'), ('\u{a641}', '\u{a641}'), ('\u{a643}', '\u{a643}'), ('\u{a645}', '\u{a645}'), ('\u{a647}', '\u{a647}'), ('\u{a649}', '\u{a649}'), ('\u{a64b}', '\u{a64b}'), ('\u{a64d}', '\u{a64d}'), ('\u{a64f}', '\u{a64f}'), ('\u{a651}', '\u{a651}'), ('\u{a653}', '\u{a653}'), ('\u{a655}', '\u{a655}'), ('\u{a657}', '\u{a657}'), ('\u{a659}', '\u{a659}'), ('\u{a65b}', '\u{a65b}'), ('\u{a65d}', '\u{a65d}'), ('\u{a65f}', '\u{a65f}'), ('\u{a661}', '\u{a661}'), ('\u{a663}', '\u{a663}'), ('\u{a665}', '\u{a665}'), ('\u{a667}', '\u{a667}'), ('\u{a669}', '\u{a669}'), ('\u{a66b}', '\u{a66b}'), ('\u{a66d}', '\u{a66d}'), ('\u{a681}', '\u{a681}'), ('\u{a683}', '\u{a683}'), ('\u{a685}', '\u{a685}'), ('\u{a687}', '\u{a687}'), ('\u{a689}', '\u{a689}'), ('\u{a68b}', '\u{a68b}'), ('\u{a68d}', '\u{a68d}'), ('\u{a68f}', '\u{a68f}'), ('\u{a691}', '\u{a691}'), ('\u{a693}', '\u{a693}'), ('\u{a695}', '\u{a695}'), ('\u{a697}', '\u{a697}'), ('\u{a699}', '\u{a699}'), ('\u{a69b}', '\u{a69b}'), ('\u{a723}', '\u{a723}'), ('\u{a725}', '\u{a725}'), ('\u{a727}', '\u{a727}'), ('\u{a729}', '\u{a729}'), ('\u{a72b}', '\u{a72b}'), ('\u{a72d}', '\u{a72d}'), ('\u{a72f}', '\u{a731}'), ('\u{a733}', '\u{a733}'), ('\u{a735}', '\u{a735}'), ('\u{a737}', '\u{a737}'), ('\u{a739}', '\u{a739}'), ('\u{a73b}', '\u{a73b}'), ('\u{a73d}', '\u{a73d}'), ('\u{a73f}', '\u{a73f}'), ('\u{a741}', '\u{a741}'), ('\u{a743}', '\u{a743}'), ('\u{a745}', '\u{a745}'), ('\u{a747}', '\u{a747}'), ('\u{a749}', '\u{a749}'), ('\u{a74b}', '\u{a74b}'), ('\u{a74d}', '\u{a74d}'), ('\u{a74f}', '\u{a74f}'), ('\u{a751}', '\u{a751}'), ('\u{a753}', '\u{a753}'), ('\u{a755}', '\u{a755}'), ('\u{a757}', '\u{a757}'), ('\u{a759}', '\u{a759}'), ('\u{a75b}', '\u{a75b}'), ('\u{a75d}', '\u{a75d}'), ('\u{a75f}', '\u{a75f}'), ('\u{a761}', '\u{a761}'), ('\u{a763}', '\u{a763}'), ('\u{a765}', '\u{a765}'), ('\u{a767}', '\u{a767}'), ('\u{a769}', '\u{a769}'), ('\u{a76b}', '\u{a76b}'), ('\u{a76d}', '\u{a76d}'), ('\u{a76f}', '\u{a76f}'), ('\u{a771}', '\u{a778}'), ('\u{a77a}', '\u{a77a}'), ('\u{a77c}', '\u{a77c}'), ('\u{a77f}', '\u{a77f}'), ('\u{a781}', '\u{a781}'), ('\u{a783}', '\u{a783}'), ('\u{a785}', '\u{a785}'), ('\u{a787}', '\u{a787}'), ('\u{a78c}', '\u{a78c}'), ('\u{a78e}', '\u{a78e}'), ('\u{a791}', '\u{a791}'), ('\u{a793}', '\u{a795}'), ('\u{a797}', '\u{a797}'), ('\u{a799}', '\u{a799}'), ('\u{a79b}', '\u{a79b}'), ('\u{a79d}', '\u{a79d}'), ('\u{a79f}', '\u{a79f}'), ('\u{a7a1}', '\u{a7a1}'), ('\u{a7a3}', '\u{a7a3}'), ('\u{a7a5}', '\u{a7a5}'), ('\u{a7a7}', '\u{a7a7}'), ('\u{a7a9}', '\u{a7a9}'), ('\u{a7b5}', '\u{a7b5}'), ('\u{a7b7}', '\u{a7b7}'), ('\u{a7fa}', '\u{a7fa}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab60}', '\u{ab65}'), ('\u{ab70}', '\u{abbf}'), ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{ff41}', '\u{ff5a}'), ('\u{10428}', '\u{1044f}'), ('\u{10cc0}', '\u{10cf2}'), ('\u{118c0}', '\u{118df}'), ('\u{1d41a}', '\u{1d433}'), ('\u{1d44e}', '\u{1d454}'), ('\u{1d456}', '\u{1d467}'), ('\u{1d482}', '\u{1d49b}'), ('\u{1d4b6}', '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d4cf}'), ('\u{1d4ea}', '\u{1d503}'), ('\u{1d51e}', '\u{1d537}'), ('\u{1d552}', '\u{1d56b}'), ('\u{1d586}', '\u{1d59f}'), ('\u{1d5ba}', '\u{1d5d3}'), ('\u{1d5ee}', '\u{1d607}'), ('\u{1d622}', '\u{1d63b}'), ('\u{1d656}', '\u{1d66f}'), ('\u{1d68a}', '\u{1d6a5}'), ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}', '\u{1d6e1}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', '\u{1d71b}'), ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d755}'), ('\u{1d770}', '\u{1d788}'), ('\u{1d78a}', '\u{1d78f}'), ('\u{1d7aa}', '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7c9}'), ('\u{1d7cb}', '\u{1d7cb}') ]; pub const Lm_table: &'static [(char, char)] = &[ ('\u{2b0}', '\u{2c1}'), ('\u{2c6}', '\u{2d1}'), ('\u{2e0}', '\u{2e4}'), ('\u{2ec}', '\u{2ec}'), ('\u{2ee}', '\u{2ee}'), ('\u{374}', '\u{374}'), ('\u{37a}', '\u{37a}'), ('\u{559}', '\u{559}'), ('\u{640}', '\u{640}'), ('\u{6e5}', '\u{6e6}'), ('\u{7f4}', '\u{7f5}'), ('\u{7fa}', '\u{7fa}'), ('\u{81a}', '\u{81a}'), ('\u{824}', '\u{824}'), ('\u{828}', '\u{828}'), ('\u{971}', '\u{971}'), ('\u{e46}', '\u{e46}'), ('\u{ec6}', '\u{ec6}'), ('\u{10fc}', '\u{10fc}'), ('\u{17d7}', '\u{17d7}'), ('\u{1843}', '\u{1843}'), ('\u{1aa7}', '\u{1aa7}'), ('\u{1c78}', '\u{1c7d}'), ('\u{1d2c}', '\u{1d6a}'), ('\u{1d78}', '\u{1d78}'), ('\u{1d9b}', '\u{1dbf}'), ('\u{2071}', '\u{2071}'), ('\u{207f}', '\u{207f}'), ('\u{2090}', '\u{209c}'), ('\u{2c7c}', '\u{2c7d}'), ('\u{2d6f}', '\u{2d6f}'), ('\u{2e2f}', '\u{2e2f}'), ('\u{3005}', '\u{3005}'), ('\u{3031}', '\u{3035}'), ('\u{303b}', '\u{303b}'), ('\u{309d}', '\u{309e}'), ('\u{30fc}', '\u{30fe}'), ('\u{a015}', '\u{a015}'), ('\u{a4f8}', '\u{a4fd}'), ('\u{a60c}', '\u{a60c}'), ('\u{a67f}', '\u{a67f}'), ('\u{a69c}', '\u{a69d}'), ('\u{a717}', '\u{a71f}'), ('\u{a770}', '\u{a770}'), ('\u{a788}', '\u{a788}'), ('\u{a7f8}', '\u{a7f9}'), ('\u{a9cf}', '\u{a9cf}'), ('\u{a9e6}', '\u{a9e6}'), ('\u{aa70}', '\u{aa70}'), ('\u{aadd}', '\u{aadd}'), ('\u{aaf3}', '\u{aaf4}'), ('\u{ab5c}', '\u{ab5f}'), ('\u{ff70}', '\u{ff70}'), ('\u{ff9e}', '\u{ff9f}'), ('\u{16b40}', '\u{16b43}'), ('\u{16f93}', '\u{16f9f}') ]; pub const Lo_table: &'static [(char, char)] = &[ ('\u{aa}', '\u{aa}'), ('\u{ba}', '\u{ba}'), ('\u{1bb}', '\u{1bb}'), ('\u{1c0}', '\u{1c3}'), ('\u{294}', '\u{294}'), ('\u{5d0}', '\u{5ea}'), ('\u{5f0}', '\u{5f2}'), ('\u{620}', '\u{63f}'), ('\u{641}', '\u{64a}'), ('\u{66e}', '\u{66f}'), ('\u{671}', '\u{6d3}'), ('\u{6d5}', '\u{6d5}'), ('\u{6ee}', '\u{6ef}'), ('\u{6fa}', '\u{6fc}'), ('\u{6ff}', '\u{6ff}'), ('\u{710}', '\u{710}'), ('\u{712}', '\u{72f}'), ('\u{74d}', '\u{7a5}'), ('\u{7b1}', '\u{7b1}'), ('\u{7ca}', '\u{7ea}'), ('\u{800}', '\u{815}'), ('\u{840}', '\u{858}'), ('\u{8a0}', '\u{8b4}'), ('\u{904}', '\u{939}'), ('\u{93d}', '\u{93d}'), ('\u{950}', '\u{950}'), ('\u{958}', '\u{961}'), ('\u{972}', '\u{980}'), ('\u{985}', '\u{98c}'), ('\u{98f}', '\u{990}'), ('\u{993}', '\u{9a8}'), ('\u{9aa}', '\u{9b0}'), ('\u{9b2}', '\u{9b2}'), ('\u{9b6}', '\u{9b9}'), ('\u{9bd}', '\u{9bd}'), ('\u{9ce}', '\u{9ce}'), ('\u{9dc}', '\u{9dd}'), ('\u{9df}', '\u{9e1}'), ('\u{9f0}', '\u{9f1}'), ('\u{a05}', '\u{a0a}'), ('\u{a0f}', '\u{a10}'), ('\u{a13}', '\u{a28}'), ('\u{a2a}', '\u{a30}'), ('\u{a32}', '\u{a33}'), ('\u{a35}', '\u{a36}'), ('\u{a38}', '\u{a39}'), ('\u{a59}', '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), ('\u{a72}', '\u{a74}'), ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), ('\u{a93}', '\u{aa8}'), ('\u{aaa}', '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), ('\u{ab5}', '\u{ab9}'), ('\u{abd}', '\u{abd}'), ('\u{ad0}', '\u{ad0}'), ('\u{ae0}', '\u{ae1}'), ('\u{af9}', '\u{af9}'), ('\u{b05}', '\u{b0c}'), ('\u{b0f}', '\u{b10}'), ('\u{b13}', '\u{b28}'), ('\u{b2a}', '\u{b30}'), ('\u{b32}', '\u{b33}'), ('\u{b35}', '\u{b39}'), ('\u{b3d}', '\u{b3d}'), ('\u{b5c}', '\u{b5d}'), ('\u{b5f}', '\u{b61}'), ('\u{b71}', '\u{b71}'), ('\u{b83}', '\u{b83}'), ('\u{b85}', '\u{b8a}'), ('\u{b8e}', '\u{b90}'), ('\u{b92}', '\u{b95}'), ('\u{b99}', '\u{b9a}'), ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', '\u{b9f}'), ('\u{ba3}', '\u{ba4}'), ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), ('\u{bd0}', '\u{bd0}'), ('\u{c05}', '\u{c0c}'), ('\u{c0e}', '\u{c10}'), ('\u{c12}', '\u{c28}'), ('\u{c2a}', '\u{c39}'), ('\u{c3d}', '\u{c3d}'), ('\u{c58}', '\u{c5a}'), ('\u{c60}', '\u{c61}'), ('\u{c85}', '\u{c8c}'), ('\u{c8e}', '\u{c90}'), ('\u{c92}', '\u{ca8}'), ('\u{caa}', '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), ('\u{cbd}', '\u{cbd}'), ('\u{cde}', '\u{cde}'), ('\u{ce0}', '\u{ce1}'), ('\u{cf1}', '\u{cf2}'), ('\u{d05}', '\u{d0c}'), ('\u{d0e}', '\u{d10}'), ('\u{d12}', '\u{d3a}'), ('\u{d3d}', '\u{d3d}'), ('\u{d4e}', '\u{d4e}'), ('\u{d5f}', '\u{d61}'), ('\u{d7a}', '\u{d7f}'), ('\u{d85}', '\u{d96}'), ('\u{d9a}', '\u{db1}'), ('\u{db3}', '\u{dbb}'), ('\u{dbd}', '\u{dbd}'), ('\u{dc0}', '\u{dc6}'), ('\u{e01}', '\u{e30}'), ('\u{e32}', '\u{e33}'), ('\u{e40}', '\u{e45}'), ('\u{e81}', '\u{e82}'), ('\u{e84}', '\u{e84}'), ('\u{e87}', '\u{e88}'), ('\u{e8a}', '\u{e8a}'), ('\u{e8d}', '\u{e8d}'), ('\u{e94}', '\u{e97}'), ('\u{e99}', '\u{e9f}'), ('\u{ea1}', '\u{ea3}'), ('\u{ea5}', '\u{ea5}'), ('\u{ea7}', '\u{ea7}'), ('\u{eaa}', '\u{eab}'), ('\u{ead}', '\u{eb0}'), ('\u{eb2}', '\u{eb3}'), ('\u{ebd}', '\u{ebd}'), ('\u{ec0}', '\u{ec4}'), ('\u{edc}', '\u{edf}'), ('\u{f00}', '\u{f00}'), ('\u{f40}', '\u{f47}'), ('\u{f49}', '\u{f6c}'), ('\u{f88}', '\u{f8c}'), ('\u{1000}', '\u{102a}'), ('\u{103f}', '\u{103f}'), ('\u{1050}', '\u{1055}'), ('\u{105a}', '\u{105d}'), ('\u{1061}', '\u{1061}'), ('\u{1065}', '\u{1066}'), ('\u{106e}', '\u{1070}'), ('\u{1075}', '\u{1081}'), ('\u{108e}', '\u{108e}'), ('\u{10d0}', '\u{10fa}'), ('\u{10fd}', '\u{1248}'), ('\u{124a}', '\u{124d}'), ('\u{1250}', '\u{1256}'), ('\u{1258}', '\u{1258}'), ('\u{125a}', '\u{125d}'), ('\u{1260}', '\u{1288}'), ('\u{128a}', '\u{128d}'), ('\u{1290}', '\u{12b0}'), ('\u{12b2}', '\u{12b5}'), ('\u{12b8}', '\u{12be}'), ('\u{12c0}', '\u{12c0}'), ('\u{12c2}', '\u{12c5}'), ('\u{12c8}', '\u{12d6}'), ('\u{12d8}', '\u{1310}'), ('\u{1312}', '\u{1315}'), ('\u{1318}', '\u{135a}'), ('\u{1380}', '\u{138f}'), ('\u{1401}', '\u{166c}'), ('\u{166f}', '\u{167f}'), ('\u{1681}', '\u{169a}'), ('\u{16a0}', '\u{16ea}'), ('\u{16f1}', '\u{16f8}'), ('\u{1700}', '\u{170c}'), ('\u{170e}', '\u{1711}'), ('\u{1720}', '\u{1731}'), ('\u{1740}', '\u{1751}'), ('\u{1760}', '\u{176c}'), ('\u{176e}', '\u{1770}'), ('\u{1780}', '\u{17b3}'), ('\u{17dc}', '\u{17dc}'), ('\u{1820}', '\u{1842}'), ('\u{1844}', '\u{1877}'), ('\u{1880}', '\u{18a8}'), ('\u{18aa}', '\u{18aa}'), ('\u{18b0}', '\u{18f5}'), ('\u{1900}', '\u{191e}'), ('\u{1950}', '\u{196d}'), ('\u{1970}', '\u{1974}'), ('\u{1980}', '\u{19ab}'), ('\u{19b0}', '\u{19c9}'), ('\u{1a00}', '\u{1a16}'), ('\u{1a20}', '\u{1a54}'), ('\u{1b05}', '\u{1b33}'), ('\u{1b45}', '\u{1b4b}'), ('\u{1b83}', '\u{1ba0}'), ('\u{1bae}', '\u{1baf}'), ('\u{1bba}', '\u{1be5}'), ('\u{1c00}', '\u{1c23}'), ('\u{1c4d}', '\u{1c4f}'), ('\u{1c5a}', '\u{1c77}'), ('\u{1ce9}', '\u{1cec}'), ('\u{1cee}', '\u{1cf1}'), ('\u{1cf5}', '\u{1cf6}'), ('\u{2135}', '\u{2138}'), ('\u{2d30}', '\u{2d67}'), ('\u{2d80}', '\u{2d96}'), ('\u{2da0}', '\u{2da6}'), ('\u{2da8}', '\u{2dae}'), ('\u{2db0}', '\u{2db6}'), ('\u{2db8}', '\u{2dbe}'), ('\u{2dc0}', '\u{2dc6}'), ('\u{2dc8}', '\u{2dce}'), ('\u{2dd0}', '\u{2dd6}'), ('\u{2dd8}', '\u{2dde}'), ('\u{3006}', '\u{3006}'), ('\u{303c}', '\u{303c}'), ('\u{3041}', '\u{3096}'), ('\u{309f}', '\u{309f}'), ('\u{30a1}', '\u{30fa}'), ('\u{30ff}', '\u{30ff}'), ('\u{3105}', '\u{312d}'), ('\u{3131}', '\u{318e}'), ('\u{31a0}', '\u{31ba}'), ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{4db5}'), ('\u{4e00}', '\u{9fd5}'), ('\u{a000}', '\u{a014}'), ('\u{a016}', '\u{a48c}'), ('\u{a4d0}', '\u{a4f7}'), ('\u{a500}', '\u{a60b}'), ('\u{a610}', '\u{a61f}'), ('\u{a62a}', '\u{a62b}'), ('\u{a66e}', '\u{a66e}'), ('\u{a6a0}', '\u{a6e5}'), ('\u{a78f}', '\u{a78f}'), ('\u{a7f7}', '\u{a7f7}'), ('\u{a7fb}', '\u{a801}'), ('\u{a803}', '\u{a805}'), ('\u{a807}', '\u{a80a}'), ('\u{a80c}', '\u{a822}'), ('\u{a840}', '\u{a873}'), ('\u{a882}', '\u{a8b3}'), ('\u{a8f2}', '\u{a8f7}'), ('\u{a8fb}', '\u{a8fb}'), ('\u{a8fd}', '\u{a8fd}'), ('\u{a90a}', '\u{a925}'), ('\u{a930}', '\u{a946}'), ('\u{a960}', '\u{a97c}'), ('\u{a984}', '\u{a9b2}'), ('\u{a9e0}', '\u{a9e4}'), ('\u{a9e7}', '\u{a9ef}'), ('\u{a9fa}', '\u{a9fe}'), ('\u{aa00}', '\u{aa28}'), ('\u{aa40}', '\u{aa42}'), ('\u{aa44}', '\u{aa4b}'), ('\u{aa60}', '\u{aa6f}'), ('\u{aa71}', '\u{aa76}'), ('\u{aa7a}', '\u{aa7a}'), ('\u{aa7e}', '\u{aaaf}'), ('\u{aab1}', '\u{aab1}'), ('\u{aab5}', '\u{aab6}'), ('\u{aab9}', '\u{aabd}'), ('\u{aac0}', '\u{aac0}'), ('\u{aac2}', '\u{aac2}'), ('\u{aadb}', '\u{aadc}'), ('\u{aae0}', '\u{aaea}'), ('\u{aaf2}', '\u{aaf2}'), ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}'), ('\u{abc0}', '\u{abe2}'), ('\u{ac00}', '\u{d7a3}'), ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', '\u{fa6d}'), ('\u{fa70}', '\u{fad9}'), ('\u{fb1d}', '\u{fb1d}'), ('\u{fb1f}', '\u{fb28}'), ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), ('\u{fb46}', '\u{fbb1}'), ('\u{fbd3}', '\u{fd3d}'), ('\u{fd50}', '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}', '\u{fdfb}'), ('\u{fe70}', '\u{fe74}'), ('\u{fe76}', '\u{fefc}'), ('\u{ff66}', '\u{ff6f}'), ('\u{ff71}', '\u{ff9d}'), ('\u{ffa0}', '\u{ffbe}'), ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'), ('\u{10000}', '\u{1000b}'), ('\u{1000d}', '\u{10026}'), ('\u{10028}', '\u{1003a}'), ('\u{1003c}', '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'), ('\u{10080}', '\u{100fa}'), ('\u{10280}', '\u{1029c}'), ('\u{102a0}', '\u{102d0}'), ('\u{10300}', '\u{1031f}'), ('\u{10330}', '\u{10340}'), ('\u{10342}', '\u{10349}'), ('\u{10350}', '\u{10375}'), ('\u{10380}', '\u{1039d}'), ('\u{103a0}', '\u{103c3}'), ('\u{103c8}', '\u{103cf}'), ('\u{10450}', '\u{1049d}'), ('\u{10500}', '\u{10527}'), ('\u{10530}', '\u{10563}'), ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), ('\u{10760}', '\u{10767}'), ('\u{10800}', '\u{10805}'), ('\u{10808}', '\u{10808}'), ('\u{1080a}', '\u{10835}'), ('\u{10837}', '\u{10838}'), ('\u{1083c}', '\u{1083c}'), ('\u{1083f}', '\u{10855}'), ('\u{10860}', '\u{10876}'), ('\u{10880}', '\u{1089e}'), ('\u{108e0}', '\u{108f2}'), ('\u{108f4}', '\u{108f5}'), ('\u{10900}', '\u{10915}'), ('\u{10920}', '\u{10939}'), ('\u{10980}', '\u{109b7}'), ('\u{109be}', '\u{109bf}'), ('\u{10a00}', '\u{10a00}'), ('\u{10a10}', '\u{10a13}'), ('\u{10a15}', '\u{10a17}'), ('\u{10a19}', '\u{10a33}'), ('\u{10a60}', '\u{10a7c}'), ('\u{10a80}', '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'), ('\u{10ac9}', '\u{10ae4}'), ('\u{10b00}', '\u{10b35}'), ('\u{10b40}', '\u{10b55}'), ('\u{10b60}', '\u{10b72}'), ('\u{10b80}', '\u{10b91}'), ('\u{10c00}', '\u{10c48}'), ('\u{11003}', '\u{11037}'), ('\u{11083}', '\u{110af}'), ('\u{110d0}', '\u{110e8}'), ('\u{11103}', '\u{11126}'), ('\u{11150}', '\u{11172}'), ('\u{11176}', '\u{11176}'), ('\u{11183}', '\u{111b2}'), ('\u{111c1}', '\u{111c4}'), ('\u{111da}', '\u{111da}'), ('\u{111dc}', '\u{111dc}'), ('\u{11200}', '\u{11211}'), ('\u{11213}', '\u{1122b}'), ('\u{11280}', '\u{11286}'), ('\u{11288}', '\u{11288}'), ('\u{1128a}', '\u{1128d}'), ('\u{1128f}', '\u{1129d}'), ('\u{1129f}', '\u{112a8}'), ('\u{112b0}', '\u{112de}'), ('\u{11305}', '\u{1130c}'), ('\u{1130f}', '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'), ('\u{11332}', '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133d}', '\u{1133d}'), ('\u{11350}', '\u{11350}'), ('\u{1135d}', '\u{11361}'), ('\u{11480}', '\u{114af}'), ('\u{114c4}', '\u{114c5}'), ('\u{114c7}', '\u{114c7}'), ('\u{11580}', '\u{115ae}'), ('\u{115d8}', '\u{115db}'), ('\u{11600}', '\u{1162f}'), ('\u{11644}', '\u{11644}'), ('\u{11680}', '\u{116aa}'), ('\u{11700}', '\u{11719}'), ('\u{118ff}', '\u{118ff}'), ('\u{11ac0}', '\u{11af8}'), ('\u{12000}', '\u{12399}'), ('\u{12480}', '\u{12543}'), ('\u{13000}', '\u{1342e}'), ('\u{14400}', '\u{14646}'), ('\u{16800}', '\u{16a38}'), ('\u{16a40}', '\u{16a5e}'), ('\u{16ad0}', '\u{16aed}'), ('\u{16b00}', '\u{16b2f}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}'), ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f50}'), ('\u{1b000}', '\u{1b001}'), ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}', '\u{1bc99}'), ('\u{1e800}', '\u{1e8c4}'), ('\u{1ee00}', '\u{1ee03}'), ('\u{1ee05}', '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', '\u{1ee47}'), ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}', '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), ('\u{1ee57}', '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', '\u{1ee77}'), ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}', '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), ('\u{1eea5}', '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}', '\u{2b734}'), ('\u{2b740}', '\u{2b81d}'), ('\u{2b820}', '\u{2cea1}'), ('\u{2f800}', '\u{2fa1d}') ]; pub const Lt_table: &'static [(char, char)] = &[ ('\u{1c5}', '\u{1c5}'), ('\u{1c8}', '\u{1c8}'), ('\u{1cb}', '\u{1cb}'), ('\u{1f2}', '\u{1f2}'), ('\u{1f88}', '\u{1f8f}'), ('\u{1f98}', '\u{1f9f}'), ('\u{1fa8}', '\u{1faf}'), ('\u{1fbc}', '\u{1fbc}'), ('\u{1fcc}', '\u{1fcc}'), ('\u{1ffc}', '\u{1ffc}') ]; pub const Lu_table: &'static [(char, char)] = &[ ('\u{41}', '\u{5a}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{de}'), ('\u{100}', '\u{100}'), ('\u{102}', '\u{102}'), ('\u{104}', '\u{104}'), ('\u{106}', '\u{106}'), ('\u{108}', '\u{108}'), ('\u{10a}', '\u{10a}'), ('\u{10c}', '\u{10c}'), ('\u{10e}', '\u{10e}'), ('\u{110}', '\u{110}'), ('\u{112}', '\u{112}'), ('\u{114}', '\u{114}'), ('\u{116}', '\u{116}'), ('\u{118}', '\u{118}'), ('\u{11a}', '\u{11a}'), ('\u{11c}', '\u{11c}'), ('\u{11e}', '\u{11e}'), ('\u{120}', '\u{120}'), ('\u{122}', '\u{122}'), ('\u{124}', '\u{124}'), ('\u{126}', '\u{126}'), ('\u{128}', '\u{128}'), ('\u{12a}', '\u{12a}'), ('\u{12c}', '\u{12c}'), ('\u{12e}', '\u{12e}'), ('\u{130}', '\u{130}'), ('\u{132}', '\u{132}'), ('\u{134}', '\u{134}'), ('\u{136}', '\u{136}'), ('\u{139}', '\u{139}'), ('\u{13b}', '\u{13b}'), ('\u{13d}', '\u{13d}'), ('\u{13f}', '\u{13f}'), ('\u{141}', '\u{141}'), ('\u{143}', '\u{143}'), ('\u{145}', '\u{145}'), ('\u{147}', '\u{147}'), ('\u{14a}', '\u{14a}'), ('\u{14c}', '\u{14c}'), ('\u{14e}', '\u{14e}'), ('\u{150}', '\u{150}'), ('\u{152}', '\u{152}'), ('\u{154}', '\u{154}'), ('\u{156}', '\u{156}'), ('\u{158}', '\u{158}'), ('\u{15a}', '\u{15a}'), ('\u{15c}', '\u{15c}'), ('\u{15e}', '\u{15e}'), ('\u{160}', '\u{160}'), ('\u{162}', '\u{162}'), ('\u{164}', '\u{164}'), ('\u{166}', '\u{166}'), ('\u{168}', '\u{168}'), ('\u{16a}', '\u{16a}'), ('\u{16c}', '\u{16c}'), ('\u{16e}', '\u{16e}'), ('\u{170}', '\u{170}'), ('\u{172}', '\u{172}'), ('\u{174}', '\u{174}'), ('\u{176}', '\u{176}'), ('\u{178}', '\u{179}'), ('\u{17b}', '\u{17b}'), ('\u{17d}', '\u{17d}'), ('\u{181}', '\u{182}'), ('\u{184}', '\u{184}'), ('\u{186}', '\u{187}'), ('\u{189}', '\u{18b}'), ('\u{18e}', '\u{191}'), ('\u{193}', '\u{194}'), ('\u{196}', '\u{198}'), ('\u{19c}', '\u{19d}'), ('\u{19f}', '\u{1a0}'), ('\u{1a2}', '\u{1a2}'), ('\u{1a4}', '\u{1a4}'), ('\u{1a6}', '\u{1a7}'), ('\u{1a9}', '\u{1a9}'), ('\u{1ac}', '\u{1ac}'), ('\u{1ae}', '\u{1af}'), ('\u{1b1}', '\u{1b3}'), ('\u{1b5}', '\u{1b5}'), ('\u{1b7}', '\u{1b8}'), ('\u{1bc}', '\u{1bc}'), ('\u{1c4}', '\u{1c4}'), ('\u{1c7}', '\u{1c7}'), ('\u{1ca}', '\u{1ca}'), ('\u{1cd}', '\u{1cd}'), ('\u{1cf}', '\u{1cf}'), ('\u{1d1}', '\u{1d1}'), ('\u{1d3}', '\u{1d3}'), ('\u{1d5}', '\u{1d5}'), ('\u{1d7}', '\u{1d7}'), ('\u{1d9}', '\u{1d9}'), ('\u{1db}', '\u{1db}'), ('\u{1de}', '\u{1de}'), ('\u{1e0}', '\u{1e0}'), ('\u{1e2}', '\u{1e2}'), ('\u{1e4}', '\u{1e4}'), ('\u{1e6}', '\u{1e6}'), ('\u{1e8}', '\u{1e8}'), ('\u{1ea}', '\u{1ea}'), ('\u{1ec}', '\u{1ec}'), ('\u{1ee}', '\u{1ee}'), ('\u{1f1}', '\u{1f1}'), ('\u{1f4}', '\u{1f4}'), ('\u{1f6}', '\u{1f8}'), ('\u{1fa}', '\u{1fa}'), ('\u{1fc}', '\u{1fc}'), ('\u{1fe}', '\u{1fe}'), ('\u{200}', '\u{200}'), ('\u{202}', '\u{202}'), ('\u{204}', '\u{204}'), ('\u{206}', '\u{206}'), ('\u{208}', '\u{208}'), ('\u{20a}', '\u{20a}'), ('\u{20c}', '\u{20c}'), ('\u{20e}', '\u{20e}'), ('\u{210}', '\u{210}'), ('\u{212}', '\u{212}'), ('\u{214}', '\u{214}'), ('\u{216}', '\u{216}'), ('\u{218}', '\u{218}'), ('\u{21a}', '\u{21a}'), ('\u{21c}', '\u{21c}'), ('\u{21e}', '\u{21e}'), ('\u{220}', '\u{220}'), ('\u{222}', '\u{222}'), ('\u{224}', '\u{224}'), ('\u{226}', '\u{226}'), ('\u{228}', '\u{228}'), ('\u{22a}', '\u{22a}'), ('\u{22c}', '\u{22c}'), ('\u{22e}', '\u{22e}'), ('\u{230}', '\u{230}'), ('\u{232}', '\u{232}'), ('\u{23a}', '\u{23b}'), ('\u{23d}', '\u{23e}'), ('\u{241}', '\u{241}'), ('\u{243}', '\u{246}'), ('\u{248}', '\u{248}'), ('\u{24a}', '\u{24a}'), ('\u{24c}', '\u{24c}'), ('\u{24e}', '\u{24e}'), ('\u{370}', '\u{370}'), ('\u{372}', '\u{372}'), ('\u{376}', '\u{376}'), ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{386}'), ('\u{388}', '\u{38a}'), ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{38f}'), ('\u{391}', '\u{3a1}'), ('\u{3a3}', '\u{3ab}'), ('\u{3cf}', '\u{3cf}'), ('\u{3d2}', '\u{3d4}'), ('\u{3d8}', '\u{3d8}'), ('\u{3da}', '\u{3da}'), ('\u{3dc}', '\u{3dc}'), ('\u{3de}', '\u{3de}'), ('\u{3e0}', '\u{3e0}'), ('\u{3e2}', '\u{3e2}'), ('\u{3e4}', '\u{3e4}'), ('\u{3e6}', '\u{3e6}'), ('\u{3e8}', '\u{3e8}'), ('\u{3ea}', '\u{3ea}'), ('\u{3ec}', '\u{3ec}'), ('\u{3ee}', '\u{3ee}'), ('\u{3f4}', '\u{3f4}'), ('\u{3f7}', '\u{3f7}'), ('\u{3f9}', '\u{3fa}'), ('\u{3fd}', '\u{42f}'), ('\u{460}', '\u{460}'), ('\u{462}', '\u{462}'), ('\u{464}', '\u{464}'), ('\u{466}', '\u{466}'), ('\u{468}', '\u{468}'), ('\u{46a}', '\u{46a}'), ('\u{46c}', '\u{46c}'), ('\u{46e}', '\u{46e}'), ('\u{470}', '\u{470}'), ('\u{472}', '\u{472}'), ('\u{474}', '\u{474}'), ('\u{476}', '\u{476}'), ('\u{478}', '\u{478}'), ('\u{47a}', '\u{47a}'), ('\u{47c}', '\u{47c}'), ('\u{47e}', '\u{47e}'), ('\u{480}', '\u{480}'), ('\u{48a}', '\u{48a}'), ('\u{48c}', '\u{48c}'), ('\u{48e}', '\u{48e}'), ('\u{490}', '\u{490}'), ('\u{492}', '\u{492}'), ('\u{494}', '\u{494}'), ('\u{496}', '\u{496}'), ('\u{498}', '\u{498}'), ('\u{49a}', '\u{49a}'), ('\u{49c}', '\u{49c}'), ('\u{49e}', '\u{49e}'), ('\u{4a0}', '\u{4a0}'), ('\u{4a2}', '\u{4a2}'), ('\u{4a4}', '\u{4a4}'), ('\u{4a6}', '\u{4a6}'), ('\u{4a8}', '\u{4a8}'), ('\u{4aa}', '\u{4aa}'), ('\u{4ac}', '\u{4ac}'), ('\u{4ae}', '\u{4ae}'), ('\u{4b0}', '\u{4b0}'), ('\u{4b2}', '\u{4b2}'), ('\u{4b4}', '\u{4b4}'), ('\u{4b6}', '\u{4b6}'), ('\u{4b8}', '\u{4b8}'), ('\u{4ba}', '\u{4ba}'), ('\u{4bc}', '\u{4bc}'), ('\u{4be}', '\u{4be}'), ('\u{4c0}', '\u{4c1}'), ('\u{4c3}', '\u{4c3}'), ('\u{4c5}', '\u{4c5}'), ('\u{4c7}', '\u{4c7}'), ('\u{4c9}', '\u{4c9}'), ('\u{4cb}', '\u{4cb}'), ('\u{4cd}', '\u{4cd}'), ('\u{4d0}', '\u{4d0}'), ('\u{4d2}', '\u{4d2}'), ('\u{4d4}', '\u{4d4}'), ('\u{4d6}', '\u{4d6}'), ('\u{4d8}', '\u{4d8}'), ('\u{4da}', '\u{4da}'), ('\u{4dc}', '\u{4dc}'), ('\u{4de}', '\u{4de}'), ('\u{4e0}', '\u{4e0}'), ('\u{4e2}', '\u{4e2}'), ('\u{4e4}', '\u{4e4}'), ('\u{4e6}', '\u{4e6}'), ('\u{4e8}', '\u{4e8}'), ('\u{4ea}', '\u{4ea}'), ('\u{4ec}', '\u{4ec}'), ('\u{4ee}', '\u{4ee}'), ('\u{4f0}', '\u{4f0}'), ('\u{4f2}', '\u{4f2}'), ('\u{4f4}', '\u{4f4}'), ('\u{4f6}', '\u{4f6}'), ('\u{4f8}', '\u{4f8}'), ('\u{4fa}', '\u{4fa}'), ('\u{4fc}', '\u{4fc}'), ('\u{4fe}', '\u{4fe}'), ('\u{500}', '\u{500}'), ('\u{502}', '\u{502}'), ('\u{504}', '\u{504}'), ('\u{506}', '\u{506}'), ('\u{508}', '\u{508}'), ('\u{50a}', '\u{50a}'), ('\u{50c}', '\u{50c}'), ('\u{50e}', '\u{50e}'), ('\u{510}', '\u{510}'), ('\u{512}', '\u{512}'), ('\u{514}', '\u{514}'), ('\u{516}', '\u{516}'), ('\u{518}', '\u{518}'), ('\u{51a}', '\u{51a}'), ('\u{51c}', '\u{51c}'), ('\u{51e}', '\u{51e}'), ('\u{520}', '\u{520}'), ('\u{522}', '\u{522}'), ('\u{524}', '\u{524}'), ('\u{526}', '\u{526}'), ('\u{528}', '\u{528}'), ('\u{52a}', '\u{52a}'), ('\u{52c}', '\u{52c}'), ('\u{52e}', '\u{52e}'), ('\u{531}', '\u{556}'), ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', '\u{10cd}'), ('\u{13a0}', '\u{13f5}'), ('\u{1e00}', '\u{1e00}'), ('\u{1e02}', '\u{1e02}'), ('\u{1e04}', '\u{1e04}'), ('\u{1e06}', '\u{1e06}'), ('\u{1e08}', '\u{1e08}'), ('\u{1e0a}', '\u{1e0a}'), ('\u{1e0c}', '\u{1e0c}'), ('\u{1e0e}', '\u{1e0e}'), ('\u{1e10}', '\u{1e10}'), ('\u{1e12}', '\u{1e12}'), ('\u{1e14}', '\u{1e14}'), ('\u{1e16}', '\u{1e16}'), ('\u{1e18}', '\u{1e18}'), ('\u{1e1a}', '\u{1e1a}'), ('\u{1e1c}', '\u{1e1c}'), ('\u{1e1e}', '\u{1e1e}'), ('\u{1e20}', '\u{1e20}'), ('\u{1e22}', '\u{1e22}'), ('\u{1e24}', '\u{1e24}'), ('\u{1e26}', '\u{1e26}'), ('\u{1e28}', '\u{1e28}'), ('\u{1e2a}', '\u{1e2a}'), ('\u{1e2c}', '\u{1e2c}'), ('\u{1e2e}', '\u{1e2e}'), ('\u{1e30}', '\u{1e30}'), ('\u{1e32}', '\u{1e32}'), ('\u{1e34}', '\u{1e34}'), ('\u{1e36}', '\u{1e36}'), ('\u{1e38}', '\u{1e38}'), ('\u{1e3a}', '\u{1e3a}'), ('\u{1e3c}', '\u{1e3c}'), ('\u{1e3e}', '\u{1e3e}'), ('\u{1e40}', '\u{1e40}'), ('\u{1e42}', '\u{1e42}'), ('\u{1e44}', '\u{1e44}'), ('\u{1e46}', '\u{1e46}'), ('\u{1e48}', '\u{1e48}'), ('\u{1e4a}', '\u{1e4a}'), ('\u{1e4c}', '\u{1e4c}'), ('\u{1e4e}', '\u{1e4e}'), ('\u{1e50}', '\u{1e50}'), ('\u{1e52}', '\u{1e52}'), ('\u{1e54}', '\u{1e54}'), ('\u{1e56}', '\u{1e56}'), ('\u{1e58}', '\u{1e58}'), ('\u{1e5a}', '\u{1e5a}'), ('\u{1e5c}', '\u{1e5c}'), ('\u{1e5e}', '\u{1e5e}'), ('\u{1e60}', '\u{1e60}'), ('\u{1e62}', '\u{1e62}'), ('\u{1e64}', '\u{1e64}'), ('\u{1e66}', '\u{1e66}'), ('\u{1e68}', '\u{1e68}'), ('\u{1e6a}', '\u{1e6a}'), ('\u{1e6c}', '\u{1e6c}'), ('\u{1e6e}', '\u{1e6e}'), ('\u{1e70}', '\u{1e70}'), ('\u{1e72}', '\u{1e72}'), ('\u{1e74}', '\u{1e74}'), ('\u{1e76}', '\u{1e76}'), ('\u{1e78}', '\u{1e78}'), ('\u{1e7a}', '\u{1e7a}'), ('\u{1e7c}', '\u{1e7c}'), ('\u{1e7e}', '\u{1e7e}'), ('\u{1e80}', '\u{1e80}'), ('\u{1e82}', '\u{1e82}'), ('\u{1e84}', '\u{1e84}'), ('\u{1e86}', '\u{1e86}'), ('\u{1e88}', '\u{1e88}'), ('\u{1e8a}', '\u{1e8a}'), ('\u{1e8c}', '\u{1e8c}'), ('\u{1e8e}', '\u{1e8e}'), ('\u{1e90}', '\u{1e90}'), ('\u{1e92}', '\u{1e92}'), ('\u{1e94}', '\u{1e94}'), ('\u{1e9e}', '\u{1e9e}'), ('\u{1ea0}', '\u{1ea0}'), ('\u{1ea2}', '\u{1ea2}'), ('\u{1ea4}', '\u{1ea4}'), ('\u{1ea6}', '\u{1ea6}'), ('\u{1ea8}', '\u{1ea8}'), ('\u{1eaa}', '\u{1eaa}'), ('\u{1eac}', '\u{1eac}'), ('\u{1eae}', '\u{1eae}'), ('\u{1eb0}', '\u{1eb0}'), ('\u{1eb2}', '\u{1eb2}'), ('\u{1eb4}', '\u{1eb4}'), ('\u{1eb6}', '\u{1eb6}'), ('\u{1eb8}', '\u{1eb8}'), ('\u{1eba}', '\u{1eba}'), ('\u{1ebc}', '\u{1ebc}'), ('\u{1ebe}', '\u{1ebe}'), ('\u{1ec0}', '\u{1ec0}'), ('\u{1ec2}', '\u{1ec2}'), ('\u{1ec4}', '\u{1ec4}'), ('\u{1ec6}', '\u{1ec6}'), ('\u{1ec8}', '\u{1ec8}'), ('\u{1eca}', '\u{1eca}'), ('\u{1ecc}', '\u{1ecc}'), ('\u{1ece}', '\u{1ece}'), ('\u{1ed0}', '\u{1ed0}'), ('\u{1ed2}', '\u{1ed2}'), ('\u{1ed4}', '\u{1ed4}'), ('\u{1ed6}', '\u{1ed6}'), ('\u{1ed8}', '\u{1ed8}'), ('\u{1eda}', '\u{1eda}'), ('\u{1edc}', '\u{1edc}'), ('\u{1ede}', '\u{1ede}'), ('\u{1ee0}', '\u{1ee0}'), ('\u{1ee2}', '\u{1ee2}'), ('\u{1ee4}', '\u{1ee4}'), ('\u{1ee6}', '\u{1ee6}'), ('\u{1ee8}', '\u{1ee8}'), ('\u{1eea}', '\u{1eea}'), ('\u{1eec}', '\u{1eec}'), ('\u{1eee}', '\u{1eee}'), ('\u{1ef0}', '\u{1ef0}'), ('\u{1ef2}', '\u{1ef2}'), ('\u{1ef4}', '\u{1ef4}'), ('\u{1ef6}', '\u{1ef6}'), ('\u{1ef8}', '\u{1ef8}'), ('\u{1efa}', '\u{1efa}'), ('\u{1efc}', '\u{1efc}'), ('\u{1efe}', '\u{1efe}'), ('\u{1f08}', '\u{1f0f}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f28}', '\u{1f2f}'), ('\u{1f38}', '\u{1f3f}'), ('\u{1f48}', '\u{1f4d}'), ('\u{1f59}', '\u{1f59}'), ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', '\u{1f5f}'), ('\u{1f68}', '\u{1f6f}'), ('\u{1fb8}', '\u{1fbb}'), ('\u{1fc8}', '\u{1fcb}'), ('\u{1fd8}', '\u{1fdb}'), ('\u{1fe8}', '\u{1fec}'), ('\u{1ff8}', '\u{1ffb}'), ('\u{2102}', '\u{2102}'), ('\u{2107}', '\u{2107}'), ('\u{210b}', '\u{210d}'), ('\u{2110}', '\u{2112}'), ('\u{2115}', '\u{2115}'), ('\u{2119}', '\u{211d}'), ('\u{2124}', '\u{2124}'), ('\u{2126}', '\u{2126}'), ('\u{2128}', '\u{2128}'), ('\u{212a}', '\u{212d}'), ('\u{2130}', '\u{2133}'), ('\u{213e}', '\u{213f}'), ('\u{2145}', '\u{2145}'), ('\u{2183}', '\u{2183}'), ('\u{2c00}', '\u{2c2e}'), ('\u{2c60}', '\u{2c60}'), ('\u{2c62}', '\u{2c64}'), ('\u{2c67}', '\u{2c67}'), ('\u{2c69}', '\u{2c69}'), ('\u{2c6b}', '\u{2c6b}'), ('\u{2c6d}', '\u{2c70}'), ('\u{2c72}', '\u{2c72}'), ('\u{2c75}', '\u{2c75}'), ('\u{2c7e}', '\u{2c80}'), ('\u{2c82}', '\u{2c82}'), ('\u{2c84}', '\u{2c84}'), ('\u{2c86}', '\u{2c86}'), ('\u{2c88}', '\u{2c88}'), ('\u{2c8a}', '\u{2c8a}'), ('\u{2c8c}', '\u{2c8c}'), ('\u{2c8e}', '\u{2c8e}'), ('\u{2c90}', '\u{2c90}'), ('\u{2c92}', '\u{2c92}'), ('\u{2c94}', '\u{2c94}'), ('\u{2c96}', '\u{2c96}'), ('\u{2c98}', '\u{2c98}'), ('\u{2c9a}', '\u{2c9a}'), ('\u{2c9c}', '\u{2c9c}'), ('\u{2c9e}', '\u{2c9e}'), ('\u{2ca0}', '\u{2ca0}'), ('\u{2ca2}', '\u{2ca2}'), ('\u{2ca4}', '\u{2ca4}'), ('\u{2ca6}', '\u{2ca6}'), ('\u{2ca8}', '\u{2ca8}'), ('\u{2caa}', '\u{2caa}'), ('\u{2cac}', '\u{2cac}'), ('\u{2cae}', '\u{2cae}'), ('\u{2cb0}', '\u{2cb0}'), ('\u{2cb2}', '\u{2cb2}'), ('\u{2cb4}', '\u{2cb4}'), ('\u{2cb6}', '\u{2cb6}'), ('\u{2cb8}', '\u{2cb8}'), ('\u{2cba}', '\u{2cba}'), ('\u{2cbc}', '\u{2cbc}'), ('\u{2cbe}', '\u{2cbe}'), ('\u{2cc0}', '\u{2cc0}'), ('\u{2cc2}', '\u{2cc2}'), ('\u{2cc4}', '\u{2cc4}'), ('\u{2cc6}', '\u{2cc6}'), ('\u{2cc8}', '\u{2cc8}'), ('\u{2cca}', '\u{2cca}'), ('\u{2ccc}', '\u{2ccc}'), ('\u{2cce}', '\u{2cce}'), ('\u{2cd0}', '\u{2cd0}'), ('\u{2cd2}', '\u{2cd2}'), ('\u{2cd4}', '\u{2cd4}'), ('\u{2cd6}', '\u{2cd6}'), ('\u{2cd8}', '\u{2cd8}'), ('\u{2cda}', '\u{2cda}'), ('\u{2cdc}', '\u{2cdc}'), ('\u{2cde}', '\u{2cde}'), ('\u{2ce0}', '\u{2ce0}'), ('\u{2ce2}', '\u{2ce2}'), ('\u{2ceb}', '\u{2ceb}'), ('\u{2ced}', '\u{2ced}'), ('\u{2cf2}', '\u{2cf2}'), ('\u{a640}', '\u{a640}'), ('\u{a642}', '\u{a642}'), ('\u{a644}', '\u{a644}'), ('\u{a646}', '\u{a646}'), ('\u{a648}', '\u{a648}'), ('\u{a64a}', '\u{a64a}'), ('\u{a64c}', '\u{a64c}'), ('\u{a64e}', '\u{a64e}'), ('\u{a650}', '\u{a650}'), ('\u{a652}', '\u{a652}'), ('\u{a654}', '\u{a654}'), ('\u{a656}', '\u{a656}'), ('\u{a658}', '\u{a658}'), ('\u{a65a}', '\u{a65a}'), ('\u{a65c}', '\u{a65c}'), ('\u{a65e}', '\u{a65e}'), ('\u{a660}', '\u{a660}'), ('\u{a662}', '\u{a662}'), ('\u{a664}', '\u{a664}'), ('\u{a666}', '\u{a666}'), ('\u{a668}', '\u{a668}'), ('\u{a66a}', '\u{a66a}'), ('\u{a66c}', '\u{a66c}'), ('\u{a680}', '\u{a680}'), ('\u{a682}', '\u{a682}'), ('\u{a684}', '\u{a684}'), ('\u{a686}', '\u{a686}'), ('\u{a688}', '\u{a688}'), ('\u{a68a}', '\u{a68a}'), ('\u{a68c}', '\u{a68c}'), ('\u{a68e}', '\u{a68e}'), ('\u{a690}', '\u{a690}'), ('\u{a692}', '\u{a692}'), ('\u{a694}', '\u{a694}'), ('\u{a696}', '\u{a696}'), ('\u{a698}', '\u{a698}'), ('\u{a69a}', '\u{a69a}'), ('\u{a722}', '\u{a722}'), ('\u{a724}', '\u{a724}'), ('\u{a726}', '\u{a726}'), ('\u{a728}', '\u{a728}'), ('\u{a72a}', '\u{a72a}'), ('\u{a72c}', '\u{a72c}'), ('\u{a72e}', '\u{a72e}'), ('\u{a732}', '\u{a732}'), ('\u{a734}', '\u{a734}'), ('\u{a736}', '\u{a736}'), ('\u{a738}', '\u{a738}'), ('\u{a73a}', '\u{a73a}'), ('\u{a73c}', '\u{a73c}'), ('\u{a73e}', '\u{a73e}'), ('\u{a740}', '\u{a740}'), ('\u{a742}', '\u{a742}'), ('\u{a744}', '\u{a744}'), ('\u{a746}', '\u{a746}'), ('\u{a748}', '\u{a748}'), ('\u{a74a}', '\u{a74a}'), ('\u{a74c}', '\u{a74c}'), ('\u{a74e}', '\u{a74e}'), ('\u{a750}', '\u{a750}'), ('\u{a752}', '\u{a752}'), ('\u{a754}', '\u{a754}'), ('\u{a756}', '\u{a756}'), ('\u{a758}', '\u{a758}'), ('\u{a75a}', '\u{a75a}'), ('\u{a75c}', '\u{a75c}'), ('\u{a75e}', '\u{a75e}'), ('\u{a760}', '\u{a760}'), ('\u{a762}', '\u{a762}'), ('\u{a764}', '\u{a764}'), ('\u{a766}', '\u{a766}'), ('\u{a768}', '\u{a768}'), ('\u{a76a}', '\u{a76a}'), ('\u{a76c}', '\u{a76c}'), ('\u{a76e}', '\u{a76e}'), ('\u{a779}', '\u{a779}'), ('\u{a77b}', '\u{a77b}'), ('\u{a77d}', '\u{a77e}'), ('\u{a780}', '\u{a780}'), ('\u{a782}', '\u{a782}'), ('\u{a784}', '\u{a784}'), ('\u{a786}', '\u{a786}'), ('\u{a78b}', '\u{a78b}'), ('\u{a78d}', '\u{a78d}'), ('\u{a790}', '\u{a790}'), ('\u{a792}', '\u{a792}'), ('\u{a796}', '\u{a796}'), ('\u{a798}', '\u{a798}'), ('\u{a79a}', '\u{a79a}'), ('\u{a79c}', '\u{a79c}'), ('\u{a79e}', '\u{a79e}'), ('\u{a7a0}', '\u{a7a0}'), ('\u{a7a2}', '\u{a7a2}'), ('\u{a7a4}', '\u{a7a4}'), ('\u{a7a6}', '\u{a7a6}'), ('\u{a7a8}', '\u{a7a8}'), ('\u{a7aa}', '\u{a7ad}'), ('\u{a7b0}', '\u{a7b4}'), ('\u{a7b6}', '\u{a7b6}'), ('\u{ff21}', '\u{ff3a}'), ('\u{10400}', '\u{10427}'), ('\u{10c80}', '\u{10cb2}'), ('\u{118a0}', '\u{118bf}'), ('\u{1d400}', '\u{1d419}'), ('\u{1d434}', '\u{1d44d}'), ('\u{1d468}', '\u{1d481}'), ('\u{1d49c}', '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b5}'), ('\u{1d4d0}', '\u{1d4e9}'), ('\u{1d504}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d538}', '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d56c}', '\u{1d585}'), ('\u{1d5a0}', '\u{1d5b9}'), ('\u{1d5d4}', '\u{1d5ed}'), ('\u{1d608}', '\u{1d621}'), ('\u{1d63c}', '\u{1d655}'), ('\u{1d670}', '\u{1d689}'), ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6e2}', '\u{1d6fa}'), ('\u{1d71c}', '\u{1d734}'), ('\u{1d756}', '\u{1d76e}'), ('\u{1d790}', '\u{1d7a8}'), ('\u{1d7ca}', '\u{1d7ca}') ]; pub const M_table: &'static [(char, char)] = &[ ('\u{300}', '\u{36f}'), ('\u{483}', '\u{489}'), ('\u{591}', '\u{5bd}'), ('\u{5bf}', '\u{5bf}'), ('\u{5c1}', '\u{5c2}'), ('\u{5c4}', '\u{5c5}'), ('\u{5c7}', '\u{5c7}'), ('\u{610}', '\u{61a}'), ('\u{64b}', '\u{65f}'), ('\u{670}', '\u{670}'), ('\u{6d6}', '\u{6dc}'), ('\u{6df}', '\u{6e4}'), ('\u{6e7}', '\u{6e8}'), ('\u{6ea}', '\u{6ed}'), ('\u{711}', '\u{711}'), ('\u{730}', '\u{74a}'), ('\u{7a6}', '\u{7b0}'), ('\u{7eb}', '\u{7f3}'), ('\u{816}', '\u{819}'), ('\u{81b}', '\u{823}'), ('\u{825}', '\u{827}'), ('\u{829}', '\u{82d}'), ('\u{859}', '\u{85b}'), ('\u{8e3}', '\u{903}'), ('\u{93a}', '\u{93c}'), ('\u{93e}', '\u{94f}'), ('\u{951}', '\u{957}'), ('\u{962}', '\u{963}'), ('\u{981}', '\u{983}'), ('\u{9bc}', '\u{9bc}'), ('\u{9be}', '\u{9c4}'), ('\u{9c7}', '\u{9c8}'), ('\u{9cb}', '\u{9cd}'), ('\u{9d7}', '\u{9d7}'), ('\u{9e2}', '\u{9e3}'), ('\u{a01}', '\u{a03}'), ('\u{a3c}', '\u{a3c}'), ('\u{a3e}', '\u{a42}'), ('\u{a47}', '\u{a48}'), ('\u{a4b}', '\u{a4d}'), ('\u{a51}', '\u{a51}'), ('\u{a70}', '\u{a71}'), ('\u{a75}', '\u{a75}'), ('\u{a81}', '\u{a83}'), ('\u{abc}', '\u{abc}'), ('\u{abe}', '\u{ac5}'), ('\u{ac7}', '\u{ac9}'), ('\u{acb}', '\u{acd}'), ('\u{ae2}', '\u{ae3}'), ('\u{b01}', '\u{b03}'), ('\u{b3c}', '\u{b3c}'), ('\u{b3e}', '\u{b44}'), ('\u{b47}', '\u{b48}'), ('\u{b4b}', '\u{b4d}'), ('\u{b56}', '\u{b57}'), ('\u{b62}', '\u{b63}'), ('\u{b82}', '\u{b82}'), ('\u{bbe}', '\u{bc2}'), ('\u{bc6}', '\u{bc8}'), ('\u{bca}', '\u{bcd}'), ('\u{bd7}', '\u{bd7}'), ('\u{c00}', '\u{c03}'), ('\u{c3e}', '\u{c44}'), ('\u{c46}', '\u{c48}'), ('\u{c4a}', '\u{c4d}'), ('\u{c55}', '\u{c56}'), ('\u{c62}', '\u{c63}'), ('\u{c81}', '\u{c83}'), ('\u{cbc}', '\u{cbc}'), ('\u{cbe}', '\u{cc4}'), ('\u{cc6}', '\u{cc8}'), ('\u{cca}', '\u{ccd}'), ('\u{cd5}', '\u{cd6}'), ('\u{ce2}', '\u{ce3}'), ('\u{d01}', '\u{d03}'), ('\u{d3e}', '\u{d44}'), ('\u{d46}', '\u{d48}'), ('\u{d4a}', '\u{d4d}'), ('\u{d57}', '\u{d57}'), ('\u{d62}', '\u{d63}'), ('\u{d82}', '\u{d83}'), ('\u{dca}', '\u{dca}'), ('\u{dcf}', '\u{dd4}'), ('\u{dd6}', '\u{dd6}'), ('\u{dd8}', '\u{ddf}'), ('\u{df2}', '\u{df3}'), ('\u{e31}', '\u{e31}'), ('\u{e34}', '\u{e3a}'), ('\u{e47}', '\u{e4e}'), ('\u{eb1}', '\u{eb1}'), ('\u{eb4}', '\u{eb9}'), ('\u{ebb}', '\u{ebc}'), ('\u{ec8}', '\u{ecd}'), ('\u{f18}', '\u{f19}'), ('\u{f35}', '\u{f35}'), ('\u{f37}', '\u{f37}'), ('\u{f39}', '\u{f39}'), ('\u{f3e}', '\u{f3f}'), ('\u{f71}', '\u{f84}'), ('\u{f86}', '\u{f87}'), ('\u{f8d}', '\u{f97}'), ('\u{f99}', '\u{fbc}'), ('\u{fc6}', '\u{fc6}'), ('\u{102b}', '\u{103e}'), ('\u{1056}', '\u{1059}'), ('\u{105e}', '\u{1060}'), ('\u{1062}', '\u{1064}'), ('\u{1067}', '\u{106d}'), ('\u{1071}', '\u{1074}'), ('\u{1082}', '\u{108d}'), ('\u{108f}', '\u{108f}'), ('\u{109a}', '\u{109d}'), ('\u{135d}', '\u{135f}'), ('\u{1712}', '\u{1714}'), ('\u{1732}', '\u{1734}'), ('\u{1752}', '\u{1753}'), ('\u{1772}', '\u{1773}'), ('\u{17b4}', '\u{17d3}'), ('\u{17dd}', '\u{17dd}'), ('\u{180b}', '\u{180d}'), ('\u{18a9}', '\u{18a9}'), ('\u{1920}', '\u{192b}'), ('\u{1930}', '\u{193b}'), ('\u{1a17}', '\u{1a1b}'), ('\u{1a55}', '\u{1a5e}'), ('\u{1a60}', '\u{1a7c}'), ('\u{1a7f}', '\u{1a7f}'), ('\u{1ab0}', '\u{1abe}'), ('\u{1b00}', '\u{1b04}'), ('\u{1b34}', '\u{1b44}'), ('\u{1b6b}', '\u{1b73}'), ('\u{1b80}', '\u{1b82}'), ('\u{1ba1}', '\u{1bad}'), ('\u{1be6}', '\u{1bf3}'), ('\u{1c24}', '\u{1c37}'), ('\u{1cd0}', '\u{1cd2}'), ('\u{1cd4}', '\u{1ce8}'), ('\u{1ced}', '\u{1ced}'), ('\u{1cf2}', '\u{1cf4}'), ('\u{1cf8}', '\u{1cf9}'), ('\u{1dc0}', '\u{1df5}'), ('\u{1dfc}', '\u{1dff}'), ('\u{20d0}', '\u{20f0}'), ('\u{2cef}', '\u{2cf1}'), ('\u{2d7f}', '\u{2d7f}'), ('\u{2de0}', '\u{2dff}'), ('\u{302a}', '\u{302f}'), ('\u{3099}', '\u{309a}'), ('\u{a66f}', '\u{a672}'), ('\u{a674}', '\u{a67d}'), ('\u{a69e}', '\u{a69f}'), ('\u{a6f0}', '\u{a6f1}'), ('\u{a802}', '\u{a802}'), ('\u{a806}', '\u{a806}'), ('\u{a80b}', '\u{a80b}'), ('\u{a823}', '\u{a827}'), ('\u{a880}', '\u{a881}'), ('\u{a8b4}', '\u{a8c4}'), ('\u{a8e0}', '\u{a8f1}'), ('\u{a926}', '\u{a92d}'), ('\u{a947}', '\u{a953}'), ('\u{a980}', '\u{a983}'), ('\u{a9b3}', '\u{a9c0}'), ('\u{a9e5}', '\u{a9e5}'), ('\u{aa29}', '\u{aa36}'), ('\u{aa43}', '\u{aa43}'), ('\u{aa4c}', '\u{aa4d}'), ('\u{aa7b}', '\u{aa7d}'), ('\u{aab0}', '\u{aab0}'), ('\u{aab2}', '\u{aab4}'), ('\u{aab7}', '\u{aab8}'), ('\u{aabe}', '\u{aabf}'), ('\u{aac1}', '\u{aac1}'), ('\u{aaeb}', '\u{aaef}'), ('\u{aaf5}', '\u{aaf6}'), ('\u{abe3}', '\u{abea}'), ('\u{abec}', '\u{abed}'), ('\u{fb1e}', '\u{fb1e}'), ('\u{fe00}', '\u{fe0f}'), ('\u{fe20}', '\u{fe2f}'), ('\u{101fd}', '\u{101fd}'), ('\u{102e0}', '\u{102e0}'), ('\u{10376}', '\u{1037a}'), ('\u{10a01}', '\u{10a03}'), ('\u{10a05}', '\u{10a06}'), ('\u{10a0c}', '\u{10a0f}'), ('\u{10a38}', '\u{10a3a}'), ('\u{10a3f}', '\u{10a3f}'), ('\u{10ae5}', '\u{10ae6}'), ('\u{11000}', '\u{11002}'), ('\u{11038}', '\u{11046}'), ('\u{1107f}', '\u{11082}'), ('\u{110b0}', '\u{110ba}'), ('\u{11100}', '\u{11102}'), ('\u{11127}', '\u{11134}'), ('\u{11173}', '\u{11173}'), ('\u{11180}', '\u{11182}'), ('\u{111b3}', '\u{111c0}'), ('\u{111ca}', '\u{111cc}'), ('\u{1122c}', '\u{11237}'), ('\u{112df}', '\u{112ea}'), ('\u{11300}', '\u{11303}'), ('\u{1133c}', '\u{1133c}'), ('\u{1133e}', '\u{11344}'), ('\u{11347}', '\u{11348}'), ('\u{1134b}', '\u{1134d}'), ('\u{11357}', '\u{11357}'), ('\u{11362}', '\u{11363}'), ('\u{11366}', '\u{1136c}'), ('\u{11370}', '\u{11374}'), ('\u{114b0}', '\u{114c3}'), ('\u{115af}', '\u{115b5}'), ('\u{115b8}', '\u{115c0}'), ('\u{115dc}', '\u{115dd}'), ('\u{11630}', '\u{11640}'), ('\u{116ab}', '\u{116b7}'), ('\u{1171d}', '\u{1172b}'), ('\u{16af0}', '\u{16af4}'), ('\u{16b30}', '\u{16b36}'), ('\u{16f51}', '\u{16f7e}'), ('\u{16f8f}', '\u{16f92}'), ('\u{1bc9d}', '\u{1bc9e}'), ('\u{1d165}', '\u{1d169}'), ('\u{1d16d}', '\u{1d172}'), ('\u{1d17b}', '\u{1d182}'), ('\u{1d185}', '\u{1d18b}'), ('\u{1d1aa}', '\u{1d1ad}'), ('\u{1d242}', '\u{1d244}'), ('\u{1da00}', '\u{1da36}'), ('\u{1da3b}', '\u{1da6c}'), ('\u{1da75}', '\u{1da75}'), ('\u{1da84}', '\u{1da84}'), ('\u{1da9b}', '\u{1da9f}'), ('\u{1daa1}', '\u{1daaf}'), ('\u{1e8d0}', '\u{1e8d6}'), ('\u{e0100}', '\u{e01ef}') ]; pub const Mc_table: &'static [(char, char)] = &[ ('\u{903}', '\u{903}'), ('\u{93b}', '\u{93b}'), ('\u{93e}', '\u{940}'), ('\u{949}', '\u{94c}'), ('\u{94e}', '\u{94f}'), ('\u{982}', '\u{983}'), ('\u{9be}', '\u{9c0}'), ('\u{9c7}', '\u{9c8}'), ('\u{9cb}', '\u{9cc}'), ('\u{9d7}', '\u{9d7}'), ('\u{a03}', '\u{a03}'), ('\u{a3e}', '\u{a40}'), ('\u{a83}', '\u{a83}'), ('\u{abe}', '\u{ac0}'), ('\u{ac9}', '\u{ac9}'), ('\u{acb}', '\u{acc}'), ('\u{b02}', '\u{b03}'), ('\u{b3e}', '\u{b3e}'), ('\u{b40}', '\u{b40}'), ('\u{b47}', '\u{b48}'), ('\u{b4b}', '\u{b4c}'), ('\u{b57}', '\u{b57}'), ('\u{bbe}', '\u{bbf}'), ('\u{bc1}', '\u{bc2}'), ('\u{bc6}', '\u{bc8}'), ('\u{bca}', '\u{bcc}'), ('\u{bd7}', '\u{bd7}'), ('\u{c01}', '\u{c03}'), ('\u{c41}', '\u{c44}'), ('\u{c82}', '\u{c83}'), ('\u{cbe}', '\u{cbe}'), ('\u{cc0}', '\u{cc4}'), ('\u{cc7}', '\u{cc8}'), ('\u{cca}', '\u{ccb}'), ('\u{cd5}', '\u{cd6}'), ('\u{d02}', '\u{d03}'), ('\u{d3e}', '\u{d40}'), ('\u{d46}', '\u{d48}'), ('\u{d4a}', '\u{d4c}'), ('\u{d57}', '\u{d57}'), ('\u{d82}', '\u{d83}'), ('\u{dcf}', '\u{dd1}'), ('\u{dd8}', '\u{ddf}'), ('\u{df2}', '\u{df3}'), ('\u{f3e}', '\u{f3f}'), ('\u{f7f}', '\u{f7f}'), ('\u{102b}', '\u{102c}'), ('\u{1031}', '\u{1031}'), ('\u{1038}', '\u{1038}'), ('\u{103b}', '\u{103c}'), ('\u{1056}', '\u{1057}'), ('\u{1062}', '\u{1064}'), ('\u{1067}', '\u{106d}'), ('\u{1083}', '\u{1084}'), ('\u{1087}', '\u{108c}'), ('\u{108f}', '\u{108f}'), ('\u{109a}', '\u{109c}'), ('\u{17b6}', '\u{17b6}'), ('\u{17be}', '\u{17c5}'), ('\u{17c7}', '\u{17c8}'), ('\u{1923}', '\u{1926}'), ('\u{1929}', '\u{192b}'), ('\u{1930}', '\u{1931}'), ('\u{1933}', '\u{1938}'), ('\u{1a19}', '\u{1a1a}'), ('\u{1a55}', '\u{1a55}'), ('\u{1a57}', '\u{1a57}'), ('\u{1a61}', '\u{1a61}'), ('\u{1a63}', '\u{1a64}'), ('\u{1a6d}', '\u{1a72}'), ('\u{1b04}', '\u{1b04}'), ('\u{1b35}', '\u{1b35}'), ('\u{1b3b}', '\u{1b3b}'), ('\u{1b3d}', '\u{1b41}'), ('\u{1b43}', '\u{1b44}'), ('\u{1b82}', '\u{1b82}'), ('\u{1ba1}', '\u{1ba1}'), ('\u{1ba6}', '\u{1ba7}'), ('\u{1baa}', '\u{1baa}'), ('\u{1be7}', '\u{1be7}'), ('\u{1bea}', '\u{1bec}'), ('\u{1bee}', '\u{1bee}'), ('\u{1bf2}', '\u{1bf3}'), ('\u{1c24}', '\u{1c2b}'), ('\u{1c34}', '\u{1c35}'), ('\u{1ce1}', '\u{1ce1}'), ('\u{1cf2}', '\u{1cf3}'), ('\u{302e}', '\u{302f}'), ('\u{a823}', '\u{a824}'), ('\u{a827}', '\u{a827}'), ('\u{a880}', '\u{a881}'), ('\u{a8b4}', '\u{a8c3}'), ('\u{a952}', '\u{a953}'), ('\u{a983}', '\u{a983}'), ('\u{a9b4}', '\u{a9b5}'), ('\u{a9ba}', '\u{a9bb}'), ('\u{a9bd}', '\u{a9c0}'), ('\u{aa2f}', '\u{aa30}'), ('\u{aa33}', '\u{aa34}'), ('\u{aa4d}', '\u{aa4d}'), ('\u{aa7b}', '\u{aa7b}'), ('\u{aa7d}', '\u{aa7d}'), ('\u{aaeb}', '\u{aaeb}'), ('\u{aaee}', '\u{aaef}'), ('\u{aaf5}', '\u{aaf5}'), ('\u{abe3}', '\u{abe4}'), ('\u{abe6}', '\u{abe7}'), ('\u{abe9}', '\u{abea}'), ('\u{abec}', '\u{abec}'), ('\u{11000}', '\u{11000}'), ('\u{11002}', '\u{11002}'), ('\u{11082}', '\u{11082}'), ('\u{110b0}', '\u{110b2}'), ('\u{110b7}', '\u{110b8}'), ('\u{1112c}', '\u{1112c}'), ('\u{11182}', '\u{11182}'), ('\u{111b3}', '\u{111b5}'), ('\u{111bf}', '\u{111c0}'), ('\u{1122c}', '\u{1122e}'), ('\u{11232}', '\u{11233}'), ('\u{11235}', '\u{11235}'), ('\u{112e0}', '\u{112e2}'), ('\u{11302}', '\u{11303}'), ('\u{1133e}', '\u{1133f}'), ('\u{11341}', '\u{11344}'), ('\u{11347}', '\u{11348}'), ('\u{1134b}', '\u{1134d}'), ('\u{11357}', '\u{11357}'), ('\u{11362}', '\u{11363}'), ('\u{114b0}', '\u{114b2}'), ('\u{114b9}', '\u{114b9}'), ('\u{114bb}', '\u{114be}'), ('\u{114c1}', '\u{114c1}'), ('\u{115af}', '\u{115b1}'), ('\u{115b8}', '\u{115bb}'), ('\u{115be}', '\u{115be}'), ('\u{11630}', '\u{11632}'), ('\u{1163b}', '\u{1163c}'), ('\u{1163e}', '\u{1163e}'), ('\u{116ac}', '\u{116ac}'), ('\u{116ae}', '\u{116af}'), ('\u{116b6}', '\u{116b6}'), ('\u{11720}', '\u{11721}'), ('\u{11726}', '\u{11726}'), ('\u{16f51}', '\u{16f7e}'), ('\u{1d165}', '\u{1d166}'), ('\u{1d16d}', '\u{1d172}') ]; pub const Me_table: &'static [(char, char)] = &[ ('\u{488}', '\u{489}'), ('\u{1abe}', '\u{1abe}'), ('\u{20dd}', '\u{20e0}'), ('\u{20e2}', '\u{20e4}'), ('\u{a670}', '\u{a672}') ]; pub const Mn_table: &'static [(char, char)] = &[ ('\u{300}', '\u{36f}'), ('\u{483}', '\u{487}'), ('\u{591}', '\u{5bd}'), ('\u{5bf}', '\u{5bf}'), ('\u{5c1}', '\u{5c2}'), ('\u{5c4}', '\u{5c5}'), ('\u{5c7}', '\u{5c7}'), ('\u{610}', '\u{61a}'), ('\u{64b}', '\u{65f}'), ('\u{670}', '\u{670}'), ('\u{6d6}', '\u{6dc}'), ('\u{6df}', '\u{6e4}'), ('\u{6e7}', '\u{6e8}'), ('\u{6ea}', '\u{6ed}'), ('\u{711}', '\u{711}'), ('\u{730}', '\u{74a}'), ('\u{7a6}', '\u{7b0}'), ('\u{7eb}', '\u{7f3}'), ('\u{816}', '\u{819}'), ('\u{81b}', '\u{823}'), ('\u{825}', '\u{827}'), ('\u{829}', '\u{82d}'), ('\u{859}', '\u{85b}'), ('\u{8e3}', '\u{902}'), ('\u{93a}', '\u{93a}'), ('\u{93c}', '\u{93c}'), ('\u{941}', '\u{948}'), ('\u{94d}', '\u{94d}'), ('\u{951}', '\u{957}'), ('\u{962}', '\u{963}'), ('\u{981}', '\u{981}'), ('\u{9bc}', '\u{9bc}'), ('\u{9c1}', '\u{9c4}'), ('\u{9cd}', '\u{9cd}'), ('\u{9e2}', '\u{9e3}'), ('\u{a01}', '\u{a02}'), ('\u{a3c}', '\u{a3c}'), ('\u{a41}', '\u{a42}'), ('\u{a47}', '\u{a48}'), ('\u{a4b}', '\u{a4d}'), ('\u{a51}', '\u{a51}'), ('\u{a70}', '\u{a71}'), ('\u{a75}', '\u{a75}'), ('\u{a81}', '\u{a82}'), ('\u{abc}', '\u{abc}'), ('\u{ac1}', '\u{ac5}'), ('\u{ac7}', '\u{ac8}'), ('\u{acd}', '\u{acd}'), ('\u{ae2}', '\u{ae3}'), ('\u{b01}', '\u{b01}'), ('\u{b3c}', '\u{b3c}'), ('\u{b3f}', '\u{b3f}'), ('\u{b41}', '\u{b44}'), ('\u{b4d}', '\u{b4d}'), ('\u{b56}', '\u{b56}'), ('\u{b62}', '\u{b63}'), ('\u{b82}', '\u{b82}'), ('\u{bc0}', '\u{bc0}'), ('\u{bcd}', '\u{bcd}'), ('\u{c00}', '\u{c00}'), ('\u{c3e}', '\u{c40}'), ('\u{c46}', '\u{c48}'), ('\u{c4a}', '\u{c4d}'), ('\u{c55}', '\u{c56}'), ('\u{c62}', '\u{c63}'), ('\u{c81}', '\u{c81}'), ('\u{cbc}', '\u{cbc}'), ('\u{cbf}', '\u{cbf}'), ('\u{cc6}', '\u{cc6}'), ('\u{ccc}', '\u{ccd}'), ('\u{ce2}', '\u{ce3}'), ('\u{d01}', '\u{d01}'), ('\u{d41}', '\u{d44}'), ('\u{d4d}', '\u{d4d}'), ('\u{d62}', '\u{d63}'), ('\u{dca}', '\u{dca}'), ('\u{dd2}', '\u{dd4}'), ('\u{dd6}', '\u{dd6}'), ('\u{e31}', '\u{e31}'), ('\u{e34}', '\u{e3a}'), ('\u{e47}', '\u{e4e}'), ('\u{eb1}', '\u{eb1}'), ('\u{eb4}', '\u{eb9}'), ('\u{ebb}', '\u{ebc}'), ('\u{ec8}', '\u{ecd}'), ('\u{f18}', '\u{f19}'), ('\u{f35}', '\u{f35}'), ('\u{f37}', '\u{f37}'), ('\u{f39}', '\u{f39}'), ('\u{f71}', '\u{f7e}'), ('\u{f80}', '\u{f84}'), ('\u{f86}', '\u{f87}'), ('\u{f8d}', '\u{f97}'), ('\u{f99}', '\u{fbc}'), ('\u{fc6}', '\u{fc6}'), ('\u{102d}', '\u{1030}'), ('\u{1032}', '\u{1037}'), ('\u{1039}', '\u{103a}'), ('\u{103d}', '\u{103e}'), ('\u{1058}', '\u{1059}'), ('\u{105e}', '\u{1060}'), ('\u{1071}', '\u{1074}'), ('\u{1082}', '\u{1082}'), ('\u{1085}', '\u{1086}'), ('\u{108d}', '\u{108d}'), ('\u{109d}', '\u{109d}'), ('\u{135d}', '\u{135f}'), ('\u{1712}', '\u{1714}'), ('\u{1732}', '\u{1734}'), ('\u{1752}', '\u{1753}'), ('\u{1772}', '\u{1773}'), ('\u{17b4}', '\u{17b5}'), ('\u{17b7}', '\u{17bd}'), ('\u{17c6}', '\u{17c6}'), ('\u{17c9}', '\u{17d3}'), ('\u{17dd}', '\u{17dd}'), ('\u{180b}', '\u{180d}'), ('\u{18a9}', '\u{18a9}'), ('\u{1920}', '\u{1922}'), ('\u{1927}', '\u{1928}'), ('\u{1932}', '\u{1932}'), ('\u{1939}', '\u{193b}'), ('\u{1a17}', '\u{1a18}'), ('\u{1a1b}', '\u{1a1b}'), ('\u{1a56}', '\u{1a56}'), ('\u{1a58}', '\u{1a5e}'), ('\u{1a60}', '\u{1a60}'), ('\u{1a62}', '\u{1a62}'), ('\u{1a65}', '\u{1a6c}'), ('\u{1a73}', '\u{1a7c}'), ('\u{1a7f}', '\u{1a7f}'), ('\u{1ab0}', '\u{1abd}'), ('\u{1b00}', '\u{1b03}'), ('\u{1b34}', '\u{1b34}'), ('\u{1b36}', '\u{1b3a}'), ('\u{1b3c}', '\u{1b3c}'), ('\u{1b42}', '\u{1b42}'), ('\u{1b6b}', '\u{1b73}'), ('\u{1b80}', '\u{1b81}'), ('\u{1ba2}', '\u{1ba5}'), ('\u{1ba8}', '\u{1ba9}'), ('\u{1bab}', '\u{1bad}'), ('\u{1be6}', '\u{1be6}'), ('\u{1be8}', '\u{1be9}'), ('\u{1bed}', '\u{1bed}'), ('\u{1bef}', '\u{1bf1}'), ('\u{1c2c}', '\u{1c33}'), ('\u{1c36}', '\u{1c37}'), ('\u{1cd0}', '\u{1cd2}'), ('\u{1cd4}', '\u{1ce0}'), ('\u{1ce2}', '\u{1ce8}'), ('\u{1ced}', '\u{1ced}'), ('\u{1cf4}', '\u{1cf4}'), ('\u{1cf8}', '\u{1cf9}'), ('\u{1dc0}', '\u{1df5}'), ('\u{1dfc}', '\u{1dff}'), ('\u{20d0}', '\u{20dc}'), ('\u{20e1}', '\u{20e1}'), ('\u{20e5}', '\u{20f0}'), ('\u{2cef}', '\u{2cf1}'), ('\u{2d7f}', '\u{2d7f}'), ('\u{2de0}', '\u{2dff}'), ('\u{302a}', '\u{302d}'), ('\u{3099}', '\u{309a}'), ('\u{a66f}', '\u{a66f}'), ('\u{a674}', '\u{a67d}'), ('\u{a69e}', '\u{a69f}'), ('\u{a6f0}', '\u{a6f1}'), ('\u{a802}', '\u{a802}'), ('\u{a806}', '\u{a806}'), ('\u{a80b}', '\u{a80b}'), ('\u{a825}', '\u{a826}'), ('\u{a8c4}', '\u{a8c4}'), ('\u{a8e0}', '\u{a8f1}'), ('\u{a926}', '\u{a92d}'), ('\u{a947}', '\u{a951}'), ('\u{a980}', '\u{a982}'), ('\u{a9b3}', '\u{a9b3}'), ('\u{a9b6}', '\u{a9b9}'), ('\u{a9bc}', '\u{a9bc}'), ('\u{a9e5}', '\u{a9e5}'), ('\u{aa29}', '\u{aa2e}'), ('\u{aa31}', '\u{aa32}'), ('\u{aa35}', '\u{aa36}'), ('\u{aa43}', '\u{aa43}'), ('\u{aa4c}', '\u{aa4c}'), ('\u{aa7c}', '\u{aa7c}'), ('\u{aab0}', '\u{aab0}'), ('\u{aab2}', '\u{aab4}'), ('\u{aab7}', '\u{aab8}'), ('\u{aabe}', '\u{aabf}'), ('\u{aac1}', '\u{aac1}'), ('\u{aaec}', '\u{aaed}'), ('\u{aaf6}', '\u{aaf6}'), ('\u{abe5}', '\u{abe5}'), ('\u{abe8}', '\u{abe8}'), ('\u{abed}', '\u{abed}'), ('\u{fb1e}', '\u{fb1e}'), ('\u{fe00}', '\u{fe0f}'), ('\u{fe20}', '\u{fe2f}'), ('\u{101fd}', '\u{101fd}'), ('\u{102e0}', '\u{102e0}'), ('\u{10376}', '\u{1037a}'), ('\u{10a01}', '\u{10a03}'), ('\u{10a05}', '\u{10a06}'), ('\u{10a0c}', '\u{10a0f}'), ('\u{10a38}', '\u{10a3a}'), ('\u{10a3f}', '\u{10a3f}'), ('\u{10ae5}', '\u{10ae6}'), ('\u{11001}', '\u{11001}'), ('\u{11038}', '\u{11046}'), ('\u{1107f}', '\u{11081}'), ('\u{110b3}', '\u{110b6}'), ('\u{110b9}', '\u{110ba}'), ('\u{11100}', '\u{11102}'), ('\u{11127}', '\u{1112b}'), ('\u{1112d}', '\u{11134}'), ('\u{11173}', '\u{11173}'), ('\u{11180}', '\u{11181}'), ('\u{111b6}', '\u{111be}'), ('\u{111ca}', '\u{111cc}'), ('\u{1122f}', '\u{11231}'), ('\u{11234}', '\u{11234}'), ('\u{11236}', '\u{11237}'), ('\u{112df}', '\u{112df}'), ('\u{112e3}', '\u{112ea}'), ('\u{11300}', '\u{11301}'), ('\u{1133c}', '\u{1133c}'), ('\u{11340}', '\u{11340}'), ('\u{11366}', '\u{1136c}'), ('\u{11370}', '\u{11374}'), ('\u{114b3}', '\u{114b8}'), ('\u{114ba}', '\u{114ba}'), ('\u{114bf}', '\u{114c0}'), ('\u{114c2}', '\u{114c3}'), ('\u{115b2}', '\u{115b5}'), ('\u{115bc}', '\u{115bd}'), ('\u{115bf}', '\u{115c0}'), ('\u{115dc}', '\u{115dd}'), ('\u{11633}', '\u{1163a}'), ('\u{1163d}', '\u{1163d}'), ('\u{1163f}', '\u{11640}'), ('\u{116ab}', '\u{116ab}'), ('\u{116ad}', '\u{116ad}'), ('\u{116b0}', '\u{116b5}'), ('\u{116b7}', '\u{116b7}'), ('\u{1171d}', '\u{1171f}'), ('\u{11722}', '\u{11725}'), ('\u{11727}', '\u{1172b}'), ('\u{16af0}', '\u{16af4}'), ('\u{16b30}', '\u{16b36}'), ('\u{16f8f}', '\u{16f92}'), ('\u{1bc9d}', '\u{1bc9e}'), ('\u{1d167}', '\u{1d169}'), ('\u{1d17b}', '\u{1d182}'), ('\u{1d185}', '\u{1d18b}'), ('\u{1d1aa}', '\u{1d1ad}'), ('\u{1d242}', '\u{1d244}'), ('\u{1da00}', '\u{1da36}'), ('\u{1da3b}', '\u{1da6c}'), ('\u{1da75}', '\u{1da75}'), ('\u{1da84}', '\u{1da84}'), ('\u{1da9b}', '\u{1da9f}'), ('\u{1daa1}', '\u{1daaf}'), ('\u{1e8d0}', '\u{1e8d6}'), ('\u{e0100}', '\u{e01ef}') ]; pub const N_table: &'static [(char, char)] = &[ ('\u{30}', '\u{39}'), ('\u{660}', '\u{669}'), ('\u{6f0}', '\u{6f9}'), ('\u{7c0}', '\u{7c9}'), ('\u{966}', '\u{96f}'), ('\u{9e6}', '\u{9ef}'), ('\u{a66}', '\u{a6f}'), ('\u{ae6}', '\u{aef}'), ('\u{b66}', '\u{b6f}'), ('\u{be6}', '\u{bef}'), ('\u{c66}', '\u{c6f}'), ('\u{ce6}', '\u{cef}'), ('\u{d66}', '\u{d6f}'), ('\u{de6}', '\u{def}'), ('\u{e50}', '\u{e59}'), ('\u{ed0}', '\u{ed9}'), ('\u{f20}', '\u{f29}'), ('\u{1040}', '\u{1049}'), ('\u{1090}', '\u{1099}'), ('\u{16ee}', '\u{16f0}'), ('\u{17e0}', '\u{17e9}'), ('\u{1810}', '\u{1819}'), ('\u{1946}', '\u{194f}'), ('\u{19d0}', '\u{19d9}'), ('\u{1a80}', '\u{1a89}'), ('\u{1a90}', '\u{1a99}'), ('\u{1b50}', '\u{1b59}'), ('\u{1bb0}', '\u{1bb9}'), ('\u{1c40}', '\u{1c49}'), ('\u{1c50}', '\u{1c59}'), ('\u{2160}', '\u{2182}'), ('\u{2185}', '\u{2188}'), ('\u{3007}', '\u{3007}'), ('\u{3021}', '\u{3029}'), ('\u{3038}', '\u{303a}'), ('\u{a620}', '\u{a629}'), ('\u{a6e6}', '\u{a6ef}'), ('\u{a8d0}', '\u{a8d9}'), ('\u{a900}', '\u{a909}'), ('\u{a9d0}', '\u{a9d9}'), ('\u{a9f0}', '\u{a9f9}'), ('\u{aa50}', '\u{aa59}'), ('\u{abf0}', '\u{abf9}'), ('\u{ff10}', '\u{ff19}'), ('\u{10140}', '\u{10174}'), ('\u{10341}', '\u{10341}'), ('\u{1034a}', '\u{1034a}'), ('\u{103d1}', '\u{103d5}'), ('\u{104a0}', '\u{104a9}'), ('\u{11066}', '\u{1106f}'), ('\u{110f0}', '\u{110f9}'), ('\u{11136}', '\u{1113f}'), ('\u{111d0}', '\u{111d9}'), ('\u{112f0}', '\u{112f9}'), ('\u{114d0}', '\u{114d9}'), ('\u{11650}', '\u{11659}'), ('\u{116c0}', '\u{116c9}'), ('\u{11730}', '\u{11739}'), ('\u{118e0}', '\u{118e9}'), ('\u{12400}', '\u{1246e}'), ('\u{16a60}', '\u{16a69}'), ('\u{16b50}', '\u{16b59}'), ('\u{1d7ce}', '\u{1d7ff}') ]; pub const Nd_table: &'static [(char, char)] = &[ ('\u{30}', '\u{39}'), ('\u{660}', '\u{669}'), ('\u{6f0}', '\u{6f9}'), ('\u{7c0}', '\u{7c9}'), ('\u{966}', '\u{96f}'), ('\u{9e6}', '\u{9ef}'), ('\u{a66}', '\u{a6f}'), ('\u{ae6}', '\u{aef}'), ('\u{b66}', '\u{b6f}'), ('\u{be6}', '\u{bef}'), ('\u{c66}', '\u{c6f}'), ('\u{ce6}', '\u{cef}'), ('\u{d66}', '\u{d6f}'), ('\u{de6}', '\u{def}'), ('\u{e50}', '\u{e59}'), ('\u{ed0}', '\u{ed9}'), ('\u{f20}', '\u{f29}'), ('\u{1040}', '\u{1049}'), ('\u{1090}', '\u{1099}'), ('\u{17e0}', '\u{17e9}'), ('\u{1810}', '\u{1819}'), ('\u{1946}', '\u{194f}'), ('\u{19d0}', '\u{19d9}'), ('\u{1a80}', '\u{1a89}'), ('\u{1a90}', '\u{1a99}'), ('\u{1b50}', '\u{1b59}'), ('\u{1bb0}', '\u{1bb9}'), ('\u{1c40}', '\u{1c49}'), ('\u{1c50}', '\u{1c59}'), ('\u{a620}', '\u{a629}'), ('\u{a8d0}', '\u{a8d9}'), ('\u{a900}', '\u{a909}'), ('\u{a9d0}', '\u{a9d9}'), ('\u{a9f0}', '\u{a9f9}'), ('\u{aa50}', '\u{aa59}'), ('\u{abf0}', '\u{abf9}'), ('\u{ff10}', '\u{ff19}'), ('\u{104a0}', '\u{104a9}'), ('\u{11066}', '\u{1106f}'), ('\u{110f0}', '\u{110f9}'), ('\u{11136}', '\u{1113f}'), ('\u{111d0}', '\u{111d9}'), ('\u{112f0}', '\u{112f9}'), ('\u{114d0}', '\u{114d9}'), ('\u{11650}', '\u{11659}'), ('\u{116c0}', '\u{116c9}'), ('\u{11730}', '\u{11739}'), ('\u{118e0}', '\u{118e9}'), ('\u{16a60}', '\u{16a69}'), ('\u{16b50}', '\u{16b59}'), ('\u{1d7ce}', '\u{1d7ff}') ]; pub const Nl_table: &'static [(char, char)] = &[ ('\u{16ee}', '\u{16f0}'), ('\u{2160}', '\u{2182}'), ('\u{2185}', '\u{2188}'), ('\u{3007}', '\u{3007}'), ('\u{3021}', '\u{3029}'), ('\u{3038}', '\u{303a}'), ('\u{a6e6}', '\u{a6ef}'), ('\u{10140}', '\u{10174}'), ('\u{10341}', '\u{10341}'), ('\u{1034a}', '\u{1034a}'), ('\u{103d1}', '\u{103d5}'), ('\u{12400}', '\u{1246e}') ]; pub const No_table: &'static [(char, char)] = &[ ('\u{b2}', '\u{b3}'), ('\u{b9}', '\u{b9}'), ('\u{bc}', '\u{be}'), ('\u{9f4}', '\u{9f9}'), ('\u{b72}', '\u{b77}'), ('\u{bf0}', '\u{bf2}'), ('\u{c78}', '\u{c7e}'), ('\u{d70}', '\u{d75}'), ('\u{f2a}', '\u{f33}'), ('\u{1369}', '\u{137c}'), ('\u{17f0}', '\u{17f9}'), ('\u{19da}', '\u{19da}'), ('\u{2070}', '\u{2070}'), ('\u{2074}', '\u{2079}'), ('\u{2080}', '\u{2089}'), ('\u{2150}', '\u{215f}'), ('\u{2189}', '\u{2189}'), ('\u{2460}', '\u{249b}'), ('\u{24ea}', '\u{24ff}'), ('\u{2776}', '\u{2793}'), ('\u{2cfd}', '\u{2cfd}'), ('\u{3192}', '\u{3195}'), ('\u{3220}', '\u{3229}'), ('\u{3248}', '\u{324f}'), ('\u{3251}', '\u{325f}'), ('\u{3280}', '\u{3289}'), ('\u{32b1}', '\u{32bf}'), ('\u{a830}', '\u{a835}'), ('\u{10107}', '\u{10133}'), ('\u{10175}', '\u{10178}'), ('\u{1018a}', '\u{1018b}'), ('\u{102e1}', '\u{102fb}'), ('\u{10320}', '\u{10323}'), ('\u{10858}', '\u{1085f}'), ('\u{10879}', '\u{1087f}'), ('\u{108a7}', '\u{108af}'), ('\u{108fb}', '\u{108ff}'), ('\u{10916}', '\u{1091b}'), ('\u{109bc}', '\u{109bd}'), ('\u{109c0}', '\u{109cf}'), ('\u{109d2}', '\u{109ff}'), ('\u{10a40}', '\u{10a47}'), ('\u{10a7d}', '\u{10a7e}'), ('\u{10a9d}', '\u{10a9f}'), ('\u{10aeb}', '\u{10aef}'), ('\u{10b58}', '\u{10b5f}'), ('\u{10b78}', '\u{10b7f}'), ('\u{10ba9}', '\u{10baf}'), ('\u{10cfa}', '\u{10cff}'), ('\u{10e60}', '\u{10e7e}'), ('\u{11052}', '\u{11065}'), ('\u{111e1}', '\u{111f4}'), ('\u{1173a}', '\u{1173b}'), ('\u{118ea}', '\u{118f2}'), ('\u{16b5b}', '\u{16b61}'), ('\u{1d360}', '\u{1d371}'), ('\u{1e8c7}', '\u{1e8cf}'), ('\u{1f100}', '\u{1f10c}') ]; pub const P_table: &'static [(char, char)] = &[ ('\u{21}', '\u{23}'), ('\u{25}', '\u{2a}'), ('\u{2c}', '\u{2f}'), ('\u{3a}', '\u{3b}'), ('\u{3f}', '\u{40}'), ('\u{5b}', '\u{5d}'), ('\u{5f}', '\u{5f}'), ('\u{7b}', '\u{7b}'), ('\u{7d}', '\u{7d}'), ('\u{a1}', '\u{a1}'), ('\u{a7}', '\u{a7}'), ('\u{ab}', '\u{ab}'), ('\u{b6}', '\u{b7}'), ('\u{bb}', '\u{bb}'), ('\u{bf}', '\u{bf}'), ('\u{37e}', '\u{37e}'), ('\u{387}', '\u{387}'), ('\u{55a}', '\u{55f}'), ('\u{589}', '\u{58a}'), ('\u{5be}', '\u{5be}'), ('\u{5c0}', '\u{5c0}'), ('\u{5c3}', '\u{5c3}'), ('\u{5c6}', '\u{5c6}'), ('\u{5f3}', '\u{5f4}'), ('\u{609}', '\u{60a}'), ('\u{60c}', '\u{60d}'), ('\u{61b}', '\u{61b}'), ('\u{61e}', '\u{61f}'), ('\u{66a}', '\u{66d}'), ('\u{6d4}', '\u{6d4}'), ('\u{700}', '\u{70d}'), ('\u{7f7}', '\u{7f9}'), ('\u{830}', '\u{83e}'), ('\u{85e}', '\u{85e}'), ('\u{964}', '\u{965}'), ('\u{970}', '\u{970}'), ('\u{af0}', '\u{af0}'), ('\u{df4}', '\u{df4}'), ('\u{e4f}', '\u{e4f}'), ('\u{e5a}', '\u{e5b}'), ('\u{f04}', '\u{f12}'), ('\u{f14}', '\u{f14}'), ('\u{f3a}', '\u{f3d}'), ('\u{f85}', '\u{f85}'), ('\u{fd0}', '\u{fd4}'), ('\u{fd9}', '\u{fda}'), ('\u{104a}', '\u{104f}'), ('\u{10fb}', '\u{10fb}'), ('\u{1360}', '\u{1368}'), ('\u{1400}', '\u{1400}'), ('\u{166d}', '\u{166e}'), ('\u{169b}', '\u{169c}'), ('\u{16eb}', '\u{16ed}'), ('\u{1735}', '\u{1736}'), ('\u{17d4}', '\u{17d6}'), ('\u{17d8}', '\u{17da}'), ('\u{1800}', '\u{180a}'), ('\u{1944}', '\u{1945}'), ('\u{1a1e}', '\u{1a1f}'), ('\u{1aa0}', '\u{1aa6}'), ('\u{1aa8}', '\u{1aad}'), ('\u{1b5a}', '\u{1b60}'), ('\u{1bfc}', '\u{1bff}'), ('\u{1c3b}', '\u{1c3f}'), ('\u{1c7e}', '\u{1c7f}'), ('\u{1cc0}', '\u{1cc7}'), ('\u{1cd3}', '\u{1cd3}'), ('\u{2010}', '\u{2027}'), ('\u{2030}', '\u{2043}'), ('\u{2045}', '\u{2051}'), ('\u{2053}', '\u{205e}'), ('\u{207d}', '\u{207e}'), ('\u{208d}', '\u{208e}'), ('\u{2308}', '\u{230b}'), ('\u{2329}', '\u{232a}'), ('\u{2768}', '\u{2775}'), ('\u{27c5}', '\u{27c6}'), ('\u{27e6}', '\u{27ef}'), ('\u{2983}', '\u{2998}'), ('\u{29d8}', '\u{29db}'), ('\u{29fc}', '\u{29fd}'), ('\u{2cf9}', '\u{2cfc}'), ('\u{2cfe}', '\u{2cff}'), ('\u{2d70}', '\u{2d70}'), ('\u{2e00}', '\u{2e2e}'), ('\u{2e30}', '\u{2e42}'), ('\u{3001}', '\u{3003}'), ('\u{3008}', '\u{3011}'), ('\u{3014}', '\u{301f}'), ('\u{3030}', '\u{3030}'), ('\u{303d}', '\u{303d}'), ('\u{30a0}', '\u{30a0}'), ('\u{30fb}', '\u{30fb}'), ('\u{a4fe}', '\u{a4ff}'), ('\u{a60d}', '\u{a60f}'), ('\u{a673}', '\u{a673}'), ('\u{a67e}', '\u{a67e}'), ('\u{a6f2}', '\u{a6f7}'), ('\u{a874}', '\u{a877}'), ('\u{a8ce}', '\u{a8cf}'), ('\u{a8f8}', '\u{a8fa}'), ('\u{a8fc}', '\u{a8fc}'), ('\u{a92e}', '\u{a92f}'), ('\u{a95f}', '\u{a95f}'), ('\u{a9c1}', '\u{a9cd}'), ('\u{a9de}', '\u{a9df}'), ('\u{aa5c}', '\u{aa5f}'), ('\u{aade}', '\u{aadf}'), ('\u{aaf0}', '\u{aaf1}'), ('\u{abeb}', '\u{abeb}'), ('\u{fd3e}', '\u{fd3f}'), ('\u{fe10}', '\u{fe19}'), ('\u{fe30}', '\u{fe52}'), ('\u{fe54}', '\u{fe61}'), ('\u{fe63}', '\u{fe63}'), ('\u{fe68}', '\u{fe68}'), ('\u{fe6a}', '\u{fe6b}'), ('\u{ff01}', '\u{ff03}'), ('\u{ff05}', '\u{ff0a}'), ('\u{ff0c}', '\u{ff0f}'), ('\u{ff1a}', '\u{ff1b}'), ('\u{ff1f}', '\u{ff20}'), ('\u{ff3b}', '\u{ff3d}'), ('\u{ff3f}', '\u{ff3f}'), ('\u{ff5b}', '\u{ff5b}'), ('\u{ff5d}', '\u{ff5d}'), ('\u{ff5f}', '\u{ff65}'), ('\u{10100}', '\u{10102}'), ('\u{1039f}', '\u{1039f}'), ('\u{103d0}', '\u{103d0}'), ('\u{1056f}', '\u{1056f}'), ('\u{10857}', '\u{10857}'), ('\u{1091f}', '\u{1091f}'), ('\u{1093f}', '\u{1093f}'), ('\u{10a50}', '\u{10a58}'), ('\u{10a7f}', '\u{10a7f}'), ('\u{10af0}', '\u{10af6}'), ('\u{10b39}', '\u{10b3f}'), ('\u{10b99}', '\u{10b9c}'), ('\u{11047}', '\u{1104d}'), ('\u{110bb}', '\u{110bc}'), ('\u{110be}', '\u{110c1}'), ('\u{11140}', '\u{11143}'), ('\u{11174}', '\u{11175}'), ('\u{111c5}', '\u{111c9}'), ('\u{111cd}', '\u{111cd}'), ('\u{111db}', '\u{111db}'), ('\u{111dd}', '\u{111df}'), ('\u{11238}', '\u{1123d}'), ('\u{112a9}', '\u{112a9}'), ('\u{114c6}', '\u{114c6}'), ('\u{115c1}', '\u{115d7}'), ('\u{11641}', '\u{11643}'), ('\u{1173c}', '\u{1173e}'), ('\u{12470}', '\u{12474}'), ('\u{16a6e}', '\u{16a6f}'), ('\u{16af5}', '\u{16af5}'), ('\u{16b37}', '\u{16b3b}'), ('\u{16b44}', '\u{16b44}'), ('\u{1bc9f}', '\u{1bc9f}'), ('\u{1da87}', '\u{1da8b}') ]; pub const Pc_table: &'static [(char, char)] = &[ ('\u{5f}', '\u{5f}'), ('\u{203f}', '\u{2040}'), ('\u{2054}', '\u{2054}'), ('\u{fe33}', '\u{fe34}'), ('\u{fe4d}', '\u{fe4f}'), ('\u{ff3f}', '\u{ff3f}') ]; pub const Pd_table: &'static [(char, char)] = &[ ('\u{2d}', '\u{2d}'), ('\u{58a}', '\u{58a}'), ('\u{5be}', '\u{5be}'), ('\u{1400}', '\u{1400}'), ('\u{1806}', '\u{1806}'), ('\u{2010}', '\u{2015}'), ('\u{2e17}', '\u{2e17}'), ('\u{2e1a}', '\u{2e1a}'), ('\u{2e3a}', '\u{2e3b}'), ('\u{2e40}', '\u{2e40}'), ('\u{301c}', '\u{301c}'), ('\u{3030}', '\u{3030}'), ('\u{30a0}', '\u{30a0}'), ('\u{fe31}', '\u{fe32}'), ('\u{fe58}', '\u{fe58}'), ('\u{fe63}', '\u{fe63}'), ('\u{ff0d}', '\u{ff0d}') ]; pub const Pe_table: &'static [(char, char)] = &[ ('\u{29}', '\u{29}'), ('\u{5d}', '\u{5d}'), ('\u{7d}', '\u{7d}'), ('\u{f3b}', '\u{f3b}'), ('\u{f3d}', '\u{f3d}'), ('\u{169c}', '\u{169c}'), ('\u{2046}', '\u{2046}'), ('\u{207e}', '\u{207e}'), ('\u{208e}', '\u{208e}'), ('\u{2309}', '\u{2309}'), ('\u{230b}', '\u{230b}'), ('\u{232a}', '\u{232a}'), ('\u{2769}', '\u{2769}'), ('\u{276b}', '\u{276b}'), ('\u{276d}', '\u{276d}'), ('\u{276f}', '\u{276f}'), ('\u{2771}', '\u{2771}'), ('\u{2773}', '\u{2773}'), ('\u{2775}', '\u{2775}'), ('\u{27c6}', '\u{27c6}'), ('\u{27e7}', '\u{27e7}'), ('\u{27e9}', '\u{27e9}'), ('\u{27eb}', '\u{27eb}'), ('\u{27ed}', '\u{27ed}'), ('\u{27ef}', '\u{27ef}'), ('\u{2984}', '\u{2984}'), ('\u{2986}', '\u{2986}'), ('\u{2988}', '\u{2988}'), ('\u{298a}', '\u{298a}'), ('\u{298c}', '\u{298c}'), ('\u{298e}', '\u{298e}'), ('\u{2990}', '\u{2990}'), ('\u{2992}', '\u{2992}'), ('\u{2994}', '\u{2994}'), ('\u{2996}', '\u{2996}'), ('\u{2998}', '\u{2998}'), ('\u{29d9}', '\u{29d9}'), ('\u{29db}', '\u{29db}'), ('\u{29fd}', '\u{29fd}'), ('\u{2e23}', '\u{2e23}'), ('\u{2e25}', '\u{2e25}'), ('\u{2e27}', '\u{2e27}'), ('\u{2e29}', '\u{2e29}'), ('\u{3009}', '\u{3009}'), ('\u{300b}', '\u{300b}'), ('\u{300d}', '\u{300d}'), ('\u{300f}', '\u{300f}'), ('\u{3011}', '\u{3011}'), ('\u{3015}', '\u{3015}'), ('\u{3017}', '\u{3017}'), ('\u{3019}', '\u{3019}'), ('\u{301b}', '\u{301b}'), ('\u{301e}', '\u{301f}'), ('\u{fd3e}', '\u{fd3e}'), ('\u{fe18}', '\u{fe18}'), ('\u{fe36}', '\u{fe36}'), ('\u{fe38}', '\u{fe38}'), ('\u{fe3a}', '\u{fe3a}'), ('\u{fe3c}', '\u{fe3c}'), ('\u{fe3e}', '\u{fe3e}'), ('\u{fe40}', '\u{fe40}'), ('\u{fe42}', '\u{fe42}'), ('\u{fe44}', '\u{fe44}'), ('\u{fe48}', '\u{fe48}'), ('\u{fe5a}', '\u{fe5a}'), ('\u{fe5c}', '\u{fe5c}'), ('\u{fe5e}', '\u{fe5e}'), ('\u{ff09}', '\u{ff09}'), ('\u{ff3d}', '\u{ff3d}'), ('\u{ff5d}', '\u{ff5d}'), ('\u{ff60}', '\u{ff60}'), ('\u{ff63}', '\u{ff63}') ]; pub const Pf_table: &'static [(char, char)] = &[ ('\u{bb}', '\u{bb}'), ('\u{2019}', '\u{2019}'), ('\u{201d}', '\u{201d}'), ('\u{203a}', '\u{203a}'), ('\u{2e03}', '\u{2e03}'), ('\u{2e05}', '\u{2e05}'), ('\u{2e0a}', '\u{2e0a}'), ('\u{2e0d}', '\u{2e0d}'), ('\u{2e1d}', '\u{2e1d}'), ('\u{2e21}', '\u{2e21}') ]; pub const Pi_table: &'static [(char, char)] = &[ ('\u{ab}', '\u{ab}'), ('\u{2018}', '\u{2018}'), ('\u{201b}', '\u{201c}'), ('\u{201f}', '\u{201f}'), ('\u{2039}', '\u{2039}'), ('\u{2e02}', '\u{2e02}'), ('\u{2e04}', '\u{2e04}'), ('\u{2e09}', '\u{2e09}'), ('\u{2e0c}', '\u{2e0c}'), ('\u{2e1c}', '\u{2e1c}'), ('\u{2e20}', '\u{2e20}') ]; pub const Po_table: &'static [(char, char)] = &[ ('\u{21}', '\u{23}'), ('\u{25}', '\u{27}'), ('\u{2a}', '\u{2a}'), ('\u{2c}', '\u{2c}'), ('\u{2e}', '\u{2f}'), ('\u{3a}', '\u{3b}'), ('\u{3f}', '\u{40}'), ('\u{5c}', '\u{5c}'), ('\u{a1}', '\u{a1}'), ('\u{a7}', '\u{a7}'), ('\u{b6}', '\u{b7}'), ('\u{bf}', '\u{bf}'), ('\u{37e}', '\u{37e}'), ('\u{387}', '\u{387}'), ('\u{55a}', '\u{55f}'), ('\u{589}', '\u{589}'), ('\u{5c0}', '\u{5c0}'), ('\u{5c3}', '\u{5c3}'), ('\u{5c6}', '\u{5c6}'), ('\u{5f3}', '\u{5f4}'), ('\u{609}', '\u{60a}'), ('\u{60c}', '\u{60d}'), ('\u{61b}', '\u{61b}'), ('\u{61e}', '\u{61f}'), ('\u{66a}', '\u{66d}'), ('\u{6d4}', '\u{6d4}'), ('\u{700}', '\u{70d}'), ('\u{7f7}', '\u{7f9}'), ('\u{830}', '\u{83e}'), ('\u{85e}', '\u{85e}'), ('\u{964}', '\u{965}'), ('\u{970}', '\u{970}'), ('\u{af0}', '\u{af0}'), ('\u{df4}', '\u{df4}'), ('\u{e4f}', '\u{e4f}'), ('\u{e5a}', '\u{e5b}'), ('\u{f04}', '\u{f12}'), ('\u{f14}', '\u{f14}'), ('\u{f85}', '\u{f85}'), ('\u{fd0}', '\u{fd4}'), ('\u{fd9}', '\u{fda}'), ('\u{104a}', '\u{104f}'), ('\u{10fb}', '\u{10fb}'), ('\u{1360}', '\u{1368}'), ('\u{166d}', '\u{166e}'), ('\u{16eb}', '\u{16ed}'), ('\u{1735}', '\u{1736}'), ('\u{17d4}', '\u{17d6}'), ('\u{17d8}', '\u{17da}'), ('\u{1800}', '\u{1805}'), ('\u{1807}', '\u{180a}'), ('\u{1944}', '\u{1945}'), ('\u{1a1e}', '\u{1a1f}'), ('\u{1aa0}', '\u{1aa6}'), ('\u{1aa8}', '\u{1aad}'), ('\u{1b5a}', '\u{1b60}'), ('\u{1bfc}', '\u{1bff}'), ('\u{1c3b}', '\u{1c3f}'), ('\u{1c7e}', '\u{1c7f}'), ('\u{1cc0}', '\u{1cc7}'), ('\u{1cd3}', '\u{1cd3}'), ('\u{2016}', '\u{2017}'), ('\u{2020}', '\u{2027}'), ('\u{2030}', '\u{2038}'), ('\u{203b}', '\u{203e}'), ('\u{2041}', '\u{2043}'), ('\u{2047}', '\u{2051}'), ('\u{2053}', '\u{2053}'), ('\u{2055}', '\u{205e}'), ('\u{2cf9}', '\u{2cfc}'), ('\u{2cfe}', '\u{2cff}'), ('\u{2d70}', '\u{2d70}'), ('\u{2e00}', '\u{2e01}'), ('\u{2e06}', '\u{2e08}'), ('\u{2e0b}', '\u{2e0b}'), ('\u{2e0e}', '\u{2e16}'), ('\u{2e18}', '\u{2e19}'), ('\u{2e1b}', '\u{2e1b}'), ('\u{2e1e}', '\u{2e1f}'), ('\u{2e2a}', '\u{2e2e}'), ('\u{2e30}', '\u{2e39}'), ('\u{2e3c}', '\u{2e3f}'), ('\u{2e41}', '\u{2e41}'), ('\u{3001}', '\u{3003}'), ('\u{303d}', '\u{303d}'), ('\u{30fb}', '\u{30fb}'), ('\u{a4fe}', '\u{a4ff}'), ('\u{a60d}', '\u{a60f}'), ('\u{a673}', '\u{a673}'), ('\u{a67e}', '\u{a67e}'), ('\u{a6f2}', '\u{a6f7}'), ('\u{a874}', '\u{a877}'), ('\u{a8ce}', '\u{a8cf}'), ('\u{a8f8}', '\u{a8fa}'), ('\u{a8fc}', '\u{a8fc}'), ('\u{a92e}', '\u{a92f}'), ('\u{a95f}', '\u{a95f}'), ('\u{a9c1}', '\u{a9cd}'), ('\u{a9de}', '\u{a9df}'), ('\u{aa5c}', '\u{aa5f}'), ('\u{aade}', '\u{aadf}'), ('\u{aaf0}', '\u{aaf1}'), ('\u{abeb}', '\u{abeb}'), ('\u{fe10}', '\u{fe16}'), ('\u{fe19}', '\u{fe19}'), ('\u{fe30}', '\u{fe30}'), ('\u{fe45}', '\u{fe46}'), ('\u{fe49}', '\u{fe4c}'), ('\u{fe50}', '\u{fe52}'), ('\u{fe54}', '\u{fe57}'), ('\u{fe5f}', '\u{fe61}'), ('\u{fe68}', '\u{fe68}'), ('\u{fe6a}', '\u{fe6b}'), ('\u{ff01}', '\u{ff03}'), ('\u{ff05}', '\u{ff07}'), ('\u{ff0a}', '\u{ff0a}'), ('\u{ff0c}', '\u{ff0c}'), ('\u{ff0e}', '\u{ff0f}'), ('\u{ff1a}', '\u{ff1b}'), ('\u{ff1f}', '\u{ff20}'), ('\u{ff3c}', '\u{ff3c}'), ('\u{ff61}', '\u{ff61}'), ('\u{ff64}', '\u{ff65}'), ('\u{10100}', '\u{10102}'), ('\u{1039f}', '\u{1039f}'), ('\u{103d0}', '\u{103d0}'), ('\u{1056f}', '\u{1056f}'), ('\u{10857}', '\u{10857}'), ('\u{1091f}', '\u{1091f}'), ('\u{1093f}', '\u{1093f}'), ('\u{10a50}', '\u{10a58}'), ('\u{10a7f}', '\u{10a7f}'), ('\u{10af0}', '\u{10af6}'), ('\u{10b39}', '\u{10b3f}'), ('\u{10b99}', '\u{10b9c}'), ('\u{11047}', '\u{1104d}'), ('\u{110bb}', '\u{110bc}'), ('\u{110be}', '\u{110c1}'), ('\u{11140}', '\u{11143}'), ('\u{11174}', '\u{11175}'), ('\u{111c5}', '\u{111c9}'), ('\u{111cd}', '\u{111cd}'), ('\u{111db}', '\u{111db}'), ('\u{111dd}', '\u{111df}'), ('\u{11238}', '\u{1123d}'), ('\u{112a9}', '\u{112a9}'), ('\u{114c6}', '\u{114c6}'), ('\u{115c1}', '\u{115d7}'), ('\u{11641}', '\u{11643}'), ('\u{1173c}', '\u{1173e}'), ('\u{12470}', '\u{12474}'), ('\u{16a6e}', '\u{16a6f}'), ('\u{16af5}', '\u{16af5}'), ('\u{16b37}', '\u{16b3b}'), ('\u{16b44}', '\u{16b44}'), ('\u{1bc9f}', '\u{1bc9f}'), ('\u{1da87}', '\u{1da8b}') ]; pub const Ps_table: &'static [(char, char)] = &[ ('\u{28}', '\u{28}'), ('\u{5b}', '\u{5b}'), ('\u{7b}', '\u{7b}'), ('\u{f3a}', '\u{f3a}'), ('\u{f3c}', '\u{f3c}'), ('\u{169b}', '\u{169b}'), ('\u{201a}', '\u{201a}'), ('\u{201e}', '\u{201e}'), ('\u{2045}', '\u{2045}'), ('\u{207d}', '\u{207d}'), ('\u{208d}', '\u{208d}'), ('\u{2308}', '\u{2308}'), ('\u{230a}', '\u{230a}'), ('\u{2329}', '\u{2329}'), ('\u{2768}', '\u{2768}'), ('\u{276a}', '\u{276a}'), ('\u{276c}', '\u{276c}'), ('\u{276e}', '\u{276e}'), ('\u{2770}', '\u{2770}'), ('\u{2772}', '\u{2772}'), ('\u{2774}', '\u{2774}'), ('\u{27c5}', '\u{27c5}'), ('\u{27e6}', '\u{27e6}'), ('\u{27e8}', '\u{27e8}'), ('\u{27ea}', '\u{27ea}'), ('\u{27ec}', '\u{27ec}'), ('\u{27ee}', '\u{27ee}'), ('\u{2983}', '\u{2983}'), ('\u{2985}', '\u{2985}'), ('\u{2987}', '\u{2987}'), ('\u{2989}', '\u{2989}'), ('\u{298b}', '\u{298b}'), ('\u{298d}', '\u{298d}'), ('\u{298f}', '\u{298f}'), ('\u{2991}', '\u{2991}'), ('\u{2993}', '\u{2993}'), ('\u{2995}', '\u{2995}'), ('\u{2997}', '\u{2997}'), ('\u{29d8}', '\u{29d8}'), ('\u{29da}', '\u{29da}'), ('\u{29fc}', '\u{29fc}'), ('\u{2e22}', '\u{2e22}'), ('\u{2e24}', '\u{2e24}'), ('\u{2e26}', '\u{2e26}'), ('\u{2e28}', '\u{2e28}'), ('\u{2e42}', '\u{2e42}'), ('\u{3008}', '\u{3008}'), ('\u{300a}', '\u{300a}'), ('\u{300c}', '\u{300c}'), ('\u{300e}', '\u{300e}'), ('\u{3010}', '\u{3010}'), ('\u{3014}', '\u{3014}'), ('\u{3016}', '\u{3016}'), ('\u{3018}', '\u{3018}'), ('\u{301a}', '\u{301a}'), ('\u{301d}', '\u{301d}'), ('\u{fd3f}', '\u{fd3f}'), ('\u{fe17}', '\u{fe17}'), ('\u{fe35}', '\u{fe35}'), ('\u{fe37}', '\u{fe37}'), ('\u{fe39}', '\u{fe39}'), ('\u{fe3b}', '\u{fe3b}'), ('\u{fe3d}', '\u{fe3d}'), ('\u{fe3f}', '\u{fe3f}'), ('\u{fe41}', '\u{fe41}'), ('\u{fe43}', '\u{fe43}'), ('\u{fe47}', '\u{fe47}'), ('\u{fe59}', '\u{fe59}'), ('\u{fe5b}', '\u{fe5b}'), ('\u{fe5d}', '\u{fe5d}'), ('\u{ff08}', '\u{ff08}'), ('\u{ff3b}', '\u{ff3b}'), ('\u{ff5b}', '\u{ff5b}'), ('\u{ff5f}', '\u{ff5f}'), ('\u{ff62}', '\u{ff62}') ]; pub const S_table: &'static [(char, char)] = &[ ('\u{24}', '\u{24}'), ('\u{2b}', '\u{2b}'), ('\u{3c}', '\u{3e}'), ('\u{5e}', '\u{5e}'), ('\u{60}', '\u{60}'), ('\u{7c}', '\u{7c}'), ('\u{7e}', '\u{7e}'), ('\u{a2}', '\u{a6}'), ('\u{a8}', '\u{a9}'), ('\u{ac}', '\u{ac}'), ('\u{ae}', '\u{b1}'), ('\u{b4}', '\u{b4}'), ('\u{b8}', '\u{b8}'), ('\u{d7}', '\u{d7}'), ('\u{f7}', '\u{f7}'), ('\u{2c2}', '\u{2c5}'), ('\u{2d2}', '\u{2df}'), ('\u{2e5}', '\u{2eb}'), ('\u{2ed}', '\u{2ed}'), ('\u{2ef}', '\u{2ff}'), ('\u{375}', '\u{375}'), ('\u{384}', '\u{385}'), ('\u{3f6}', '\u{3f6}'), ('\u{482}', '\u{482}'), ('\u{58d}', '\u{58f}'), ('\u{606}', '\u{608}'), ('\u{60b}', '\u{60b}'), ('\u{60e}', '\u{60f}'), ('\u{6de}', '\u{6de}'), ('\u{6e9}', '\u{6e9}'), ('\u{6fd}', '\u{6fe}'), ('\u{7f6}', '\u{7f6}'), ('\u{9f2}', '\u{9f3}'), ('\u{9fa}', '\u{9fb}'), ('\u{af1}', '\u{af1}'), ('\u{b70}', '\u{b70}'), ('\u{bf3}', '\u{bfa}'), ('\u{c7f}', '\u{c7f}'), ('\u{d79}', '\u{d79}'), ('\u{e3f}', '\u{e3f}'), ('\u{f01}', '\u{f03}'), ('\u{f13}', '\u{f13}'), ('\u{f15}', '\u{f17}'), ('\u{f1a}', '\u{f1f}'), ('\u{f34}', '\u{f34}'), ('\u{f36}', '\u{f36}'), ('\u{f38}', '\u{f38}'), ('\u{fbe}', '\u{fc5}'), ('\u{fc7}', '\u{fcc}'), ('\u{fce}', '\u{fcf}'), ('\u{fd5}', '\u{fd8}'), ('\u{109e}', '\u{109f}'), ('\u{1390}', '\u{1399}'), ('\u{17db}', '\u{17db}'), ('\u{1940}', '\u{1940}'), ('\u{19de}', '\u{19ff}'), ('\u{1b61}', '\u{1b6a}'), ('\u{1b74}', '\u{1b7c}'), ('\u{1fbd}', '\u{1fbd}'), ('\u{1fbf}', '\u{1fc1}'), ('\u{1fcd}', '\u{1fcf}'), ('\u{1fdd}', '\u{1fdf}'), ('\u{1fed}', '\u{1fef}'), ('\u{1ffd}', '\u{1ffe}'), ('\u{2044}', '\u{2044}'), ('\u{2052}', '\u{2052}'), ('\u{207a}', '\u{207c}'), ('\u{208a}', '\u{208c}'), ('\u{20a0}', '\u{20be}'), ('\u{2100}', '\u{2101}'), ('\u{2103}', '\u{2106}'), ('\u{2108}', '\u{2109}'), ('\u{2114}', '\u{2114}'), ('\u{2116}', '\u{2118}'), ('\u{211e}', '\u{2123}'), ('\u{2125}', '\u{2125}'), ('\u{2127}', '\u{2127}'), ('\u{2129}', '\u{2129}'), ('\u{212e}', '\u{212e}'), ('\u{213a}', '\u{213b}'), ('\u{2140}', '\u{2144}'), ('\u{214a}', '\u{214d}'), ('\u{214f}', '\u{214f}'), ('\u{218a}', '\u{218b}'), ('\u{2190}', '\u{2307}'), ('\u{230c}', '\u{2328}'), ('\u{232b}', '\u{23fa}'), ('\u{2400}', '\u{2426}'), ('\u{2440}', '\u{244a}'), ('\u{249c}', '\u{24e9}'), ('\u{2500}', '\u{2767}'), ('\u{2794}', '\u{27c4}'), ('\u{27c7}', '\u{27e5}'), ('\u{27f0}', '\u{2982}'), ('\u{2999}', '\u{29d7}'), ('\u{29dc}', '\u{29fb}'), ('\u{29fe}', '\u{2b73}'), ('\u{2b76}', '\u{2b95}'), ('\u{2b98}', '\u{2bb9}'), ('\u{2bbd}', '\u{2bc8}'), ('\u{2bca}', '\u{2bd1}'), ('\u{2bec}', '\u{2bef}'), ('\u{2ce5}', '\u{2cea}'), ('\u{2e80}', '\u{2e99}'), ('\u{2e9b}', '\u{2ef3}'), ('\u{2f00}', '\u{2fd5}'), ('\u{2ff0}', '\u{2ffb}'), ('\u{3004}', '\u{3004}'), ('\u{3012}', '\u{3013}'), ('\u{3020}', '\u{3020}'), ('\u{3036}', '\u{3037}'), ('\u{303e}', '\u{303f}'), ('\u{309b}', '\u{309c}'), ('\u{3190}', '\u{3191}'), ('\u{3196}', '\u{319f}'), ('\u{31c0}', '\u{31e3}'), ('\u{3200}', '\u{321e}'), ('\u{322a}', '\u{3247}'), ('\u{3250}', '\u{3250}'), ('\u{3260}', '\u{327f}'), ('\u{328a}', '\u{32b0}'), ('\u{32c0}', '\u{32fe}'), ('\u{3300}', '\u{33ff}'), ('\u{4dc0}', '\u{4dff}'), ('\u{a490}', '\u{a4c6}'), ('\u{a700}', '\u{a716}'), ('\u{a720}', '\u{a721}'), ('\u{a789}', '\u{a78a}'), ('\u{a828}', '\u{a82b}'), ('\u{a836}', '\u{a839}'), ('\u{aa77}', '\u{aa79}'), ('\u{ab5b}', '\u{ab5b}'), ('\u{fb29}', '\u{fb29}'), ('\u{fbb2}', '\u{fbc1}'), ('\u{fdfc}', '\u{fdfd}'), ('\u{fe62}', '\u{fe62}'), ('\u{fe64}', '\u{fe66}'), ('\u{fe69}', '\u{fe69}'), ('\u{ff04}', '\u{ff04}'), ('\u{ff0b}', '\u{ff0b}'), ('\u{ff1c}', '\u{ff1e}'), ('\u{ff3e}', '\u{ff3e}'), ('\u{ff40}', '\u{ff40}'), ('\u{ff5c}', '\u{ff5c}'), ('\u{ff5e}', '\u{ff5e}'), ('\u{ffe0}', '\u{ffe6}'), ('\u{ffe8}', '\u{ffee}'), ('\u{fffc}', '\u{fffd}'), ('\u{10137}', '\u{1013f}'), ('\u{10179}', '\u{10189}'), ('\u{1018c}', '\u{1018c}'), ('\u{10190}', '\u{1019b}'), ('\u{101a0}', '\u{101a0}'), ('\u{101d0}', '\u{101fc}'), ('\u{10877}', '\u{10878}'), ('\u{10ac8}', '\u{10ac8}'), ('\u{1173f}', '\u{1173f}'), ('\u{16b3c}', '\u{16b3f}'), ('\u{16b45}', '\u{16b45}'), ('\u{1bc9c}', '\u{1bc9c}'), ('\u{1d000}', '\u{1d0f5}'), ('\u{1d100}', '\u{1d126}'), ('\u{1d129}', '\u{1d164}'), ('\u{1d16a}', '\u{1d16c}'), ('\u{1d183}', '\u{1d184}'), ('\u{1d18c}', '\u{1d1a9}'), ('\u{1d1ae}', '\u{1d1e8}'), ('\u{1d200}', '\u{1d241}'), ('\u{1d245}', '\u{1d245}'), ('\u{1d300}', '\u{1d356}'), ('\u{1d6c1}', '\u{1d6c1}'), ('\u{1d6db}', '\u{1d6db}'), ('\u{1d6fb}', '\u{1d6fb}'), ('\u{1d715}', '\u{1d715}'), ('\u{1d735}', '\u{1d735}'), ('\u{1d74f}', '\u{1d74f}'), ('\u{1d76f}', '\u{1d76f}'), ('\u{1d789}', '\u{1d789}'), ('\u{1d7a9}', '\u{1d7a9}'), ('\u{1d7c3}', '\u{1d7c3}'), ('\u{1d800}', '\u{1d9ff}'), ('\u{1da37}', '\u{1da3a}'), ('\u{1da6d}', '\u{1da74}'), ('\u{1da76}', '\u{1da83}'), ('\u{1da85}', '\u{1da86}'), ('\u{1eef0}', '\u{1eef1}'), ('\u{1f000}', '\u{1f02b}'), ('\u{1f030}', '\u{1f093}'), ('\u{1f0a0}', '\u{1f0ae}'), ('\u{1f0b1}', '\u{1f0bf}'), ('\u{1f0c1}', '\u{1f0cf}'), ('\u{1f0d1}', '\u{1f0f5}'), ('\u{1f110}', '\u{1f12e}'), ('\u{1f130}', '\u{1f16b}'), ('\u{1f170}', '\u{1f19a}'), ('\u{1f1e6}', '\u{1f202}'), ('\u{1f210}', '\u{1f23a}'), ('\u{1f240}', '\u{1f248}'), ('\u{1f250}', '\u{1f251}'), ('\u{1f300}', '\u{1f579}'), ('\u{1f57b}', '\u{1f5a3}'), ('\u{1f5a5}', '\u{1f6d0}'), ('\u{1f6e0}', '\u{1f6ec}'), ('\u{1f6f0}', '\u{1f6f3}'), ('\u{1f700}', '\u{1f773}'), ('\u{1f780}', '\u{1f7d4}'), ('\u{1f800}', '\u{1f80b}'), ('\u{1f810}', '\u{1f847}'), ('\u{1f850}', '\u{1f859}'), ('\u{1f860}', '\u{1f887}'), ('\u{1f890}', '\u{1f8ad}'), ('\u{1f910}', '\u{1f918}'), ('\u{1f980}', '\u{1f984}'), ('\u{1f9c0}', '\u{1f9c0}') ]; pub const Sc_table: &'static [(char, char)] = &[ ('\u{24}', '\u{24}'), ('\u{a2}', '\u{a5}'), ('\u{58f}', '\u{58f}'), ('\u{60b}', '\u{60b}'), ('\u{9f2}', '\u{9f3}'), ('\u{9fb}', '\u{9fb}'), ('\u{af1}', '\u{af1}'), ('\u{bf9}', '\u{bf9}'), ('\u{e3f}', '\u{e3f}'), ('\u{17db}', '\u{17db}'), ('\u{20a0}', '\u{20be}'), ('\u{a838}', '\u{a838}'), ('\u{fdfc}', '\u{fdfc}'), ('\u{fe69}', '\u{fe69}'), ('\u{ff04}', '\u{ff04}'), ('\u{ffe0}', '\u{ffe1}'), ('\u{ffe5}', '\u{ffe6}') ]; pub const Sk_table: &'static [(char, char)] = &[ ('\u{5e}', '\u{5e}'), ('\u{60}', '\u{60}'), ('\u{a8}', '\u{a8}'), ('\u{af}', '\u{af}'), ('\u{b4}', '\u{b4}'), ('\u{b8}', '\u{b8}'), ('\u{2c2}', '\u{2c5}'), ('\u{2d2}', '\u{2df}'), ('\u{2e5}', '\u{2eb}'), ('\u{2ed}', '\u{2ed}'), ('\u{2ef}', '\u{2ff}'), ('\u{375}', '\u{375}'), ('\u{384}', '\u{385}'), ('\u{1fbd}', '\u{1fbd}'), ('\u{1fbf}', '\u{1fc1}'), ('\u{1fcd}', '\u{1fcf}'), ('\u{1fdd}', '\u{1fdf}'), ('\u{1fed}', '\u{1fef}'), ('\u{1ffd}', '\u{1ffe}'), ('\u{309b}', '\u{309c}'), ('\u{a700}', '\u{a716}'), ('\u{a720}', '\u{a721}'), ('\u{a789}', '\u{a78a}'), ('\u{ab5b}', '\u{ab5b}'), ('\u{fbb2}', '\u{fbc1}'), ('\u{ff3e}', '\u{ff3e}'), ('\u{ff40}', '\u{ff40}'), ('\u{ffe3}', '\u{ffe3}'), ('\u{1f3fb}', '\u{1f3ff}') ]; pub const Sm_table: &'static [(char, char)] = &[ ('\u{2b}', '\u{2b}'), ('\u{3c}', '\u{3e}'), ('\u{7c}', '\u{7c}'), ('\u{7e}', '\u{7e}'), ('\u{ac}', '\u{ac}'), ('\u{b1}', '\u{b1}'), ('\u{d7}', '\u{d7}'), ('\u{f7}', '\u{f7}'), ('\u{3f6}', '\u{3f6}'), ('\u{606}', '\u{608}'), ('\u{2044}', '\u{2044}'), ('\u{2052}', '\u{2052}'), ('\u{207a}', '\u{207c}'), ('\u{208a}', '\u{208c}'), ('\u{2118}', '\u{2118}'), ('\u{2140}', '\u{2144}'), ('\u{214b}', '\u{214b}'), ('\u{2190}', '\u{2194}'), ('\u{219a}', '\u{219b}'), ('\u{21a0}', '\u{21a0}'), ('\u{21a3}', '\u{21a3}'), ('\u{21a6}', '\u{21a6}'), ('\u{21ae}', '\u{21ae}'), ('\u{21ce}', '\u{21cf}'), ('\u{21d2}', '\u{21d2}'), ('\u{21d4}', '\u{21d4}'), ('\u{21f4}', '\u{22ff}'), ('\u{2320}', '\u{2321}'), ('\u{237c}', '\u{237c}'), ('\u{239b}', '\u{23b3}'), ('\u{23dc}', '\u{23e1}'), ('\u{25b7}', '\u{25b7}'), ('\u{25c1}', '\u{25c1}'), ('\u{25f8}', '\u{25ff}'), ('\u{266f}', '\u{266f}'), ('\u{27c0}', '\u{27c4}'), ('\u{27c7}', '\u{27e5}'), ('\u{27f0}', '\u{27ff}'), ('\u{2900}', '\u{2982}'), ('\u{2999}', '\u{29d7}'), ('\u{29dc}', '\u{29fb}'), ('\u{29fe}', '\u{2aff}'), ('\u{2b30}', '\u{2b44}'), ('\u{2b47}', '\u{2b4c}'), ('\u{fb29}', '\u{fb29}'), ('\u{fe62}', '\u{fe62}'), ('\u{fe64}', '\u{fe66}'), ('\u{ff0b}', '\u{ff0b}'), ('\u{ff1c}', '\u{ff1e}'), ('\u{ff5c}', '\u{ff5c}'), ('\u{ff5e}', '\u{ff5e}'), ('\u{ffe2}', '\u{ffe2}'), ('\u{ffe9}', '\u{ffec}'), ('\u{1d6c1}', '\u{1d6c1}'), ('\u{1d6db}', '\u{1d6db}'), ('\u{1d6fb}', '\u{1d6fb}'), ('\u{1d715}', '\u{1d715}'), ('\u{1d735}', '\u{1d735}'), ('\u{1d74f}', '\u{1d74f}'), ('\u{1d76f}', '\u{1d76f}'), ('\u{1d789}', '\u{1d789}'), ('\u{1d7a9}', '\u{1d7a9}'), ('\u{1d7c3}', '\u{1d7c3}'), ('\u{1eef0}', '\u{1eef1}') ]; pub const So_table: &'static [(char, char)] = &[ ('\u{a6}', '\u{a6}'), ('\u{a9}', '\u{a9}'), ('\u{ae}', '\u{ae}'), ('\u{b0}', '\u{b0}'), ('\u{482}', '\u{482}'), ('\u{58d}', '\u{58e}'), ('\u{60e}', '\u{60f}'), ('\u{6de}', '\u{6de}'), ('\u{6e9}', '\u{6e9}'), ('\u{6fd}', '\u{6fe}'), ('\u{7f6}', '\u{7f6}'), ('\u{9fa}', '\u{9fa}'), ('\u{b70}', '\u{b70}'), ('\u{bf3}', '\u{bf8}'), ('\u{bfa}', '\u{bfa}'), ('\u{c7f}', '\u{c7f}'), ('\u{d79}', '\u{d79}'), ('\u{f01}', '\u{f03}'), ('\u{f13}', '\u{f13}'), ('\u{f15}', '\u{f17}'), ('\u{f1a}', '\u{f1f}'), ('\u{f34}', '\u{f34}'), ('\u{f36}', '\u{f36}'), ('\u{f38}', '\u{f38}'), ('\u{fbe}', '\u{fc5}'), ('\u{fc7}', '\u{fcc}'), ('\u{fce}', '\u{fcf}'), ('\u{fd5}', '\u{fd8}'), ('\u{109e}', '\u{109f}'), ('\u{1390}', '\u{1399}'), ('\u{1940}', '\u{1940}'), ('\u{19de}', '\u{19ff}'), ('\u{1b61}', '\u{1b6a}'), ('\u{1b74}', '\u{1b7c}'), ('\u{2100}', '\u{2101}'), ('\u{2103}', '\u{2106}'), ('\u{2108}', '\u{2109}'), ('\u{2114}', '\u{2114}'), ('\u{2116}', '\u{2117}'), ('\u{211e}', '\u{2123}'), ('\u{2125}', '\u{2125}'), ('\u{2127}', '\u{2127}'), ('\u{2129}', '\u{2129}'), ('\u{212e}', '\u{212e}'), ('\u{213a}', '\u{213b}'), ('\u{214a}', '\u{214a}'), ('\u{214c}', '\u{214d}'), ('\u{214f}', '\u{214f}'), ('\u{218a}', '\u{218b}'), ('\u{2195}', '\u{2199}'), ('\u{219c}', '\u{219f}'), ('\u{21a1}', '\u{21a2}'), ('\u{21a4}', '\u{21a5}'), ('\u{21a7}', '\u{21ad}'), ('\u{21af}', '\u{21cd}'), ('\u{21d0}', '\u{21d1}'), ('\u{21d3}', '\u{21d3}'), ('\u{21d5}', '\u{21f3}'), ('\u{2300}', '\u{2307}'), ('\u{230c}', '\u{231f}'), ('\u{2322}', '\u{2328}'), ('\u{232b}', '\u{237b}'), ('\u{237d}', '\u{239a}'), ('\u{23b4}', '\u{23db}'), ('\u{23e2}', '\u{23fa}'), ('\u{2400}', '\u{2426}'), ('\u{2440}', '\u{244a}'), ('\u{249c}', '\u{24e9}'), ('\u{2500}', '\u{25b6}'), ('\u{25b8}', '\u{25c0}'), ('\u{25c2}', '\u{25f7}'), ('\u{2600}', '\u{266e}'), ('\u{2670}', '\u{2767}'), ('\u{2794}', '\u{27bf}'), ('\u{2800}', '\u{28ff}'), ('\u{2b00}', '\u{2b2f}'), ('\u{2b45}', '\u{2b46}'), ('\u{2b4d}', '\u{2b73}'), ('\u{2b76}', '\u{2b95}'), ('\u{2b98}', '\u{2bb9}'), ('\u{2bbd}', '\u{2bc8}'), ('\u{2bca}', '\u{2bd1}'), ('\u{2bec}', '\u{2bef}'), ('\u{2ce5}', '\u{2cea}'), ('\u{2e80}', '\u{2e99}'), ('\u{2e9b}', '\u{2ef3}'), ('\u{2f00}', '\u{2fd5}'), ('\u{2ff0}', '\u{2ffb}'), ('\u{3004}', '\u{3004}'), ('\u{3012}', '\u{3013}'), ('\u{3020}', '\u{3020}'), ('\u{3036}', '\u{3037}'), ('\u{303e}', '\u{303f}'), ('\u{3190}', '\u{3191}'), ('\u{3196}', '\u{319f}'), ('\u{31c0}', '\u{31e3}'), ('\u{3200}', '\u{321e}'), ('\u{322a}', '\u{3247}'), ('\u{3250}', '\u{3250}'), ('\u{3260}', '\u{327f}'), ('\u{328a}', '\u{32b0}'), ('\u{32c0}', '\u{32fe}'), ('\u{3300}', '\u{33ff}'), ('\u{4dc0}', '\u{4dff}'), ('\u{a490}', '\u{a4c6}'), ('\u{a828}', '\u{a82b}'), ('\u{a836}', '\u{a837}'), ('\u{a839}', '\u{a839}'), ('\u{aa77}', '\u{aa79}'), ('\u{fdfd}', '\u{fdfd}'), ('\u{ffe4}', '\u{ffe4}'), ('\u{ffe8}', '\u{ffe8}'), ('\u{ffed}', '\u{ffee}'), ('\u{fffc}', '\u{fffd}'), ('\u{10137}', '\u{1013f}'), ('\u{10179}', '\u{10189}'), ('\u{1018c}', '\u{1018c}'), ('\u{10190}', '\u{1019b}'), ('\u{101a0}', '\u{101a0}'), ('\u{101d0}', '\u{101fc}'), ('\u{10877}', '\u{10878}'), ('\u{10ac8}', '\u{10ac8}'), ('\u{1173f}', '\u{1173f}'), ('\u{16b3c}', '\u{16b3f}'), ('\u{16b45}', '\u{16b45}'), ('\u{1bc9c}', '\u{1bc9c}'), ('\u{1d000}', '\u{1d0f5}'), ('\u{1d100}', '\u{1d126}'), ('\u{1d129}', '\u{1d164}'), ('\u{1d16a}', '\u{1d16c}'), ('\u{1d183}', '\u{1d184}'), ('\u{1d18c}', '\u{1d1a9}'), ('\u{1d1ae}', '\u{1d1e8}'), ('\u{1d200}', '\u{1d241}'), ('\u{1d245}', '\u{1d245}'), ('\u{1d300}', '\u{1d356}'), ('\u{1d800}', '\u{1d9ff}'), ('\u{1da37}', '\u{1da3a}'), ('\u{1da6d}', '\u{1da74}'), ('\u{1da76}', '\u{1da83}'), ('\u{1da85}', '\u{1da86}'), ('\u{1f000}', '\u{1f02b}'), ('\u{1f030}', '\u{1f093}'), ('\u{1f0a0}', '\u{1f0ae}'), ('\u{1f0b1}', '\u{1f0bf}'), ('\u{1f0c1}', '\u{1f0cf}'), ('\u{1f0d1}', '\u{1f0f5}'), ('\u{1f110}', '\u{1f12e}'), ('\u{1f130}', '\u{1f16b}'), ('\u{1f170}', '\u{1f19a}'), ('\u{1f1e6}', '\u{1f202}'), ('\u{1f210}', '\u{1f23a}'), ('\u{1f240}', '\u{1f248}'), ('\u{1f250}', '\u{1f251}'), ('\u{1f300}', '\u{1f3fa}'), ('\u{1f400}', '\u{1f579}'), ('\u{1f57b}', '\u{1f5a3}'), ('\u{1f5a5}', '\u{1f6d0}'), ('\u{1f6e0}', '\u{1f6ec}'), ('\u{1f6f0}', '\u{1f6f3}'), ('\u{1f700}', '\u{1f773}'), ('\u{1f780}', '\u{1f7d4}'), ('\u{1f800}', '\u{1f80b}'), ('\u{1f810}', '\u{1f847}'), ('\u{1f850}', '\u{1f859}'), ('\u{1f860}', '\u{1f887}'), ('\u{1f890}', '\u{1f8ad}'), ('\u{1f910}', '\u{1f918}'), ('\u{1f980}', '\u{1f984}'), ('\u{1f9c0}', '\u{1f9c0}') ]; pub const Z_table: &'static [(char, char)] = &[ ('\u{20}', '\u{20}'), ('\u{a0}', '\u{a0}'), ('\u{1680}', '\u{1680}'), ('\u{2000}', '\u{200a}'), ('\u{2028}', '\u{2029}'), ('\u{202f}', '\u{202f}'), ('\u{205f}', '\u{205f}'), ('\u{3000}', '\u{3000}') ]; pub const Zl_table: &'static [(char, char)] = &[ ('\u{2028}', '\u{2028}') ]; pub const Zp_table: &'static [(char, char)] = &[ ('\u{2029}', '\u{2029}') ]; pub const Zs_table: &'static [(char, char)] = &[ ('\u{20}', '\u{20}'), ('\u{a0}', '\u{a0}'), ('\u{1680}', '\u{1680}'), ('\u{2000}', '\u{200a}'), ('\u{202f}', '\u{202f}'), ('\u{205f}', '\u{205f}'), ('\u{3000}', '\u{3000}') ]; } pub mod derived_property { pub const Alphabetic_table: &'static [(char, char)] = &[ ('\u{41}', '\u{5a}'), ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), ('\u{b5}', '\u{b5}'), ('\u{ba}', '\u{ba}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2c1}'), ('\u{2c6}', '\u{2d1}'), ('\u{2e0}', '\u{2e4}'), ('\u{2ec}', '\u{2ec}'), ('\u{2ee}', '\u{2ee}'), ('\u{345}', '\u{345}'), ('\u{370}', '\u{374}'), ('\u{376}', '\u{377}'), ('\u{37a}', '\u{37d}'), ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{386}'), ('\u{388}', '\u{38a}'), ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{3a1}'), ('\u{3a3}', '\u{3f5}'), ('\u{3f7}', '\u{481}'), ('\u{48a}', '\u{52f}'), ('\u{531}', '\u{556}'), ('\u{559}', '\u{559}'), ('\u{561}', '\u{587}'), ('\u{5b0}', '\u{5bd}'), ('\u{5bf}', '\u{5bf}'), ('\u{5c1}', '\u{5c2}'), ('\u{5c4}', '\u{5c5}'), ('\u{5c7}', '\u{5c7}'), ('\u{5d0}', '\u{5ea}'), ('\u{5f0}', '\u{5f2}'), ('\u{610}', '\u{61a}'), ('\u{620}', '\u{657}'), ('\u{659}', '\u{65f}'), ('\u{66e}', '\u{6d3}'), ('\u{6d5}', '\u{6dc}'), ('\u{6e1}', '\u{6e8}'), ('\u{6ed}', '\u{6ef}'), ('\u{6fa}', '\u{6fc}'), ('\u{6ff}', '\u{6ff}'), ('\u{710}', '\u{73f}'), ('\u{74d}', '\u{7b1}'), ('\u{7ca}', '\u{7ea}'), ('\u{7f4}', '\u{7f5}'), ('\u{7fa}', '\u{7fa}'), ('\u{800}', '\u{817}'), ('\u{81a}', '\u{82c}'), ('\u{840}', '\u{858}'), ('\u{8a0}', '\u{8b4}'), ('\u{8e3}', '\u{8e9}'), ('\u{8f0}', '\u{93b}'), ('\u{93d}', '\u{94c}'), ('\u{94e}', '\u{950}'), ('\u{955}', '\u{963}'), ('\u{971}', '\u{983}'), ('\u{985}', '\u{98c}'), ('\u{98f}', '\u{990}'), ('\u{993}', '\u{9a8}'), ('\u{9aa}', '\u{9b0}'), ('\u{9b2}', '\u{9b2}'), ('\u{9b6}', '\u{9b9}'), ('\u{9bd}', '\u{9c4}'), ('\u{9c7}', '\u{9c8}'), ('\u{9cb}', '\u{9cc}'), ('\u{9ce}', '\u{9ce}'), ('\u{9d7}', '\u{9d7}'), ('\u{9dc}', '\u{9dd}'), ('\u{9df}', '\u{9e3}'), ('\u{9f0}', '\u{9f1}'), ('\u{a01}', '\u{a03}'), ('\u{a05}', '\u{a0a}'), ('\u{a0f}', '\u{a10}'), ('\u{a13}', '\u{a28}'), ('\u{a2a}', '\u{a30}'), ('\u{a32}', '\u{a33}'), ('\u{a35}', '\u{a36}'), ('\u{a38}', '\u{a39}'), ('\u{a3e}', '\u{a42}'), ('\u{a47}', '\u{a48}'), ('\u{a4b}', '\u{a4c}'), ('\u{a51}', '\u{a51}'), ('\u{a59}', '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), ('\u{a70}', '\u{a75}'), ('\u{a81}', '\u{a83}'), ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), ('\u{a93}', '\u{aa8}'), ('\u{aaa}', '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), ('\u{ab5}', '\u{ab9}'), ('\u{abd}', '\u{ac5}'), ('\u{ac7}', '\u{ac9}'), ('\u{acb}', '\u{acc}'), ('\u{ad0}', '\u{ad0}'), ('\u{ae0}', '\u{ae3}'), ('\u{af9}', '\u{af9}'), ('\u{b01}', '\u{b03}'), ('\u{b05}', '\u{b0c}'), ('\u{b0f}', '\u{b10}'), ('\u{b13}', '\u{b28}'), ('\u{b2a}', '\u{b30}'), ('\u{b32}', '\u{b33}'), ('\u{b35}', '\u{b39}'), ('\u{b3d}', '\u{b44}'), ('\u{b47}', '\u{b48}'), ('\u{b4b}', '\u{b4c}'), ('\u{b56}', '\u{b57}'), ('\u{b5c}', '\u{b5d}'), ('\u{b5f}', '\u{b63}'), ('\u{b71}', '\u{b71}'), ('\u{b82}', '\u{b83}'), ('\u{b85}', '\u{b8a}'), ('\u{b8e}', '\u{b90}'), ('\u{b92}', '\u{b95}'), ('\u{b99}', '\u{b9a}'), ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', '\u{b9f}'), ('\u{ba3}', '\u{ba4}'), ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), ('\u{bbe}', '\u{bc2}'), ('\u{bc6}', '\u{bc8}'), ('\u{bca}', '\u{bcc}'), ('\u{bd0}', '\u{bd0}'), ('\u{bd7}', '\u{bd7}'), ('\u{c00}', '\u{c03}'), ('\u{c05}', '\u{c0c}'), ('\u{c0e}', '\u{c10}'), ('\u{c12}', '\u{c28}'), ('\u{c2a}', '\u{c39}'), ('\u{c3d}', '\u{c44}'), ('\u{c46}', '\u{c48}'), ('\u{c4a}', '\u{c4c}'), ('\u{c55}', '\u{c56}'), ('\u{c58}', '\u{c5a}'), ('\u{c60}', '\u{c63}'), ('\u{c81}', '\u{c83}'), ('\u{c85}', '\u{c8c}'), ('\u{c8e}', '\u{c90}'), ('\u{c92}', '\u{ca8}'), ('\u{caa}', '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), ('\u{cbd}', '\u{cc4}'), ('\u{cc6}', '\u{cc8}'), ('\u{cca}', '\u{ccc}'), ('\u{cd5}', '\u{cd6}'), ('\u{cde}', '\u{cde}'), ('\u{ce0}', '\u{ce3}'), ('\u{cf1}', '\u{cf2}'), ('\u{d01}', '\u{d03}'), ('\u{d05}', '\u{d0c}'), ('\u{d0e}', '\u{d10}'), ('\u{d12}', '\u{d3a}'), ('\u{d3d}', '\u{d44}'), ('\u{d46}', '\u{d48}'), ('\u{d4a}', '\u{d4c}'), ('\u{d4e}', '\u{d4e}'), ('\u{d57}', '\u{d57}'), ('\u{d5f}', '\u{d63}'), ('\u{d7a}', '\u{d7f}'), ('\u{d82}', '\u{d83}'), ('\u{d85}', '\u{d96}'), ('\u{d9a}', '\u{db1}'), ('\u{db3}', '\u{dbb}'), ('\u{dbd}', '\u{dbd}'), ('\u{dc0}', '\u{dc6}'), ('\u{dcf}', '\u{dd4}'), ('\u{dd6}', '\u{dd6}'), ('\u{dd8}', '\u{ddf}'), ('\u{df2}', '\u{df3}'), ('\u{e01}', '\u{e3a}'), ('\u{e40}', '\u{e46}'), ('\u{e4d}', '\u{e4d}'), ('\u{e81}', '\u{e82}'), ('\u{e84}', '\u{e84}'), ('\u{e87}', '\u{e88}'), ('\u{e8a}', '\u{e8a}'), ('\u{e8d}', '\u{e8d}'), ('\u{e94}', '\u{e97}'), ('\u{e99}', '\u{e9f}'), ('\u{ea1}', '\u{ea3}'), ('\u{ea5}', '\u{ea5}'), ('\u{ea7}', '\u{ea7}'), ('\u{eaa}', '\u{eab}'), ('\u{ead}', '\u{eb9}'), ('\u{ebb}', '\u{ebd}'), ('\u{ec0}', '\u{ec4}'), ('\u{ec6}', '\u{ec6}'), ('\u{ecd}', '\u{ecd}'), ('\u{edc}', '\u{edf}'), ('\u{f00}', '\u{f00}'), ('\u{f40}', '\u{f47}'), ('\u{f49}', '\u{f6c}'), ('\u{f71}', '\u{f81}'), ('\u{f88}', '\u{f97}'), ('\u{f99}', '\u{fbc}'), ('\u{1000}', '\u{1036}'), ('\u{1038}', '\u{1038}'), ('\u{103b}', '\u{103f}'), ('\u{1050}', '\u{1062}'), ('\u{1065}', '\u{1068}'), ('\u{106e}', '\u{1086}'), ('\u{108e}', '\u{108e}'), ('\u{109c}', '\u{109d}'), ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', '\u{10cd}'), ('\u{10d0}', '\u{10fa}'), ('\u{10fc}', '\u{1248}'), ('\u{124a}', '\u{124d}'), ('\u{1250}', '\u{1256}'), ('\u{1258}', '\u{1258}'), ('\u{125a}', '\u{125d}'), ('\u{1260}', '\u{1288}'), ('\u{128a}', '\u{128d}'), ('\u{1290}', '\u{12b0}'), ('\u{12b2}', '\u{12b5}'), ('\u{12b8}', '\u{12be}'), ('\u{12c0}', '\u{12c0}'), ('\u{12c2}', '\u{12c5}'), ('\u{12c8}', '\u{12d6}'), ('\u{12d8}', '\u{1310}'), ('\u{1312}', '\u{1315}'), ('\u{1318}', '\u{135a}'), ('\u{135f}', '\u{135f}'), ('\u{1380}', '\u{138f}'), ('\u{13a0}', '\u{13f5}'), ('\u{13f8}', '\u{13fd}'), ('\u{1401}', '\u{166c}'), ('\u{166f}', '\u{167f}'), ('\u{1681}', '\u{169a}'), ('\u{16a0}', '\u{16ea}'), ('\u{16ee}', '\u{16f8}'), ('\u{1700}', '\u{170c}'), ('\u{170e}', '\u{1713}'), ('\u{1720}', '\u{1733}'), ('\u{1740}', '\u{1753}'), ('\u{1760}', '\u{176c}'), ('\u{176e}', '\u{1770}'), ('\u{1772}', '\u{1773}'), ('\u{1780}', '\u{17b3}'), ('\u{17b6}', '\u{17c8}'), ('\u{17d7}', '\u{17d7}'), ('\u{17dc}', '\u{17dc}'), ('\u{1820}', '\u{1877}'), ('\u{1880}', '\u{18aa}'), ('\u{18b0}', '\u{18f5}'), ('\u{1900}', '\u{191e}'), ('\u{1920}', '\u{192b}'), ('\u{1930}', '\u{1938}'), ('\u{1950}', '\u{196d}'), ('\u{1970}', '\u{1974}'), ('\u{1980}', '\u{19ab}'), ('\u{19b0}', '\u{19c9}'), ('\u{1a00}', '\u{1a1b}'), ('\u{1a20}', '\u{1a5e}'), ('\u{1a61}', '\u{1a74}'), ('\u{1aa7}', '\u{1aa7}'), ('\u{1b00}', '\u{1b33}'), ('\u{1b35}', '\u{1b43}'), ('\u{1b45}', '\u{1b4b}'), ('\u{1b80}', '\u{1ba9}'), ('\u{1bac}', '\u{1baf}'), ('\u{1bba}', '\u{1be5}'), ('\u{1be7}', '\u{1bf1}'), ('\u{1c00}', '\u{1c35}'), ('\u{1c4d}', '\u{1c4f}'), ('\u{1c5a}', '\u{1c7d}'), ('\u{1ce9}', '\u{1cec}'), ('\u{1cee}', '\u{1cf3}'), ('\u{1cf5}', '\u{1cf6}'), ('\u{1d00}', '\u{1dbf}'), ('\u{1de7}', '\u{1df4}'), ('\u{1e00}', '\u{1f15}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', '\u{1f45}'), ('\u{1f48}', '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f59}', '\u{1f59}'), ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}', '\u{1fb4}'), ('\u{1fb6}', '\u{1fbc}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'), ('\u{1fc6}', '\u{1fcc}'), ('\u{1fd0}', '\u{1fd3}'), ('\u{1fd6}', '\u{1fdb}'), ('\u{1fe0}', '\u{1fec}'), ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}', '\u{1ffc}'), ('\u{2071}', '\u{2071}'), ('\u{207f}', '\u{207f}'), ('\u{2090}', '\u{209c}'), ('\u{2102}', '\u{2102}'), ('\u{2107}', '\u{2107}'), ('\u{210a}', '\u{2113}'), ('\u{2115}', '\u{2115}'), ('\u{2119}', '\u{211d}'), ('\u{2124}', '\u{2124}'), ('\u{2126}', '\u{2126}'), ('\u{2128}', '\u{2128}'), ('\u{212a}', '\u{212d}'), ('\u{212f}', '\u{2139}'), ('\u{213c}', '\u{213f}'), ('\u{2145}', '\u{2149}'), ('\u{214e}', '\u{214e}'), ('\u{2160}', '\u{2188}'), ('\u{24b6}', '\u{24e9}'), ('\u{2c00}', '\u{2c2e}'), ('\u{2c30}', '\u{2c5e}'), ('\u{2c60}', '\u{2ce4}'), ('\u{2ceb}', '\u{2cee}'), ('\u{2cf2}', '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'), ('\u{2d30}', '\u{2d67}'), ('\u{2d6f}', '\u{2d6f}'), ('\u{2d80}', '\u{2d96}'), ('\u{2da0}', '\u{2da6}'), ('\u{2da8}', '\u{2dae}'), ('\u{2db0}', '\u{2db6}'), ('\u{2db8}', '\u{2dbe}'), ('\u{2dc0}', '\u{2dc6}'), ('\u{2dc8}', '\u{2dce}'), ('\u{2dd0}', '\u{2dd6}'), ('\u{2dd8}', '\u{2dde}'), ('\u{2de0}', '\u{2dff}'), ('\u{2e2f}', '\u{2e2f}'), ('\u{3005}', '\u{3007}'), ('\u{3021}', '\u{3029}'), ('\u{3031}', '\u{3035}'), ('\u{3038}', '\u{303c}'), ('\u{3041}', '\u{3096}'), ('\u{309d}', '\u{309f}'), ('\u{30a1}', '\u{30fa}'), ('\u{30fc}', '\u{30ff}'), ('\u{3105}', '\u{312d}'), ('\u{3131}', '\u{318e}'), ('\u{31a0}', '\u{31ba}'), ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{4db5}'), ('\u{4e00}', '\u{9fd5}'), ('\u{a000}', '\u{a48c}'), ('\u{a4d0}', '\u{a4fd}'), ('\u{a500}', '\u{a60c}'), ('\u{a610}', '\u{a61f}'), ('\u{a62a}', '\u{a62b}'), ('\u{a640}', '\u{a66e}'), ('\u{a674}', '\u{a67b}'), ('\u{a67f}', '\u{a6ef}'), ('\u{a717}', '\u{a71f}'), ('\u{a722}', '\u{a788}'), ('\u{a78b}', '\u{a7ad}'), ('\u{a7b0}', '\u{a7b7}'), ('\u{a7f7}', '\u{a801}'), ('\u{a803}', '\u{a805}'), ('\u{a807}', '\u{a80a}'), ('\u{a80c}', '\u{a827}'), ('\u{a840}', '\u{a873}'), ('\u{a880}', '\u{a8c3}'), ('\u{a8f2}', '\u{a8f7}'), ('\u{a8fb}', '\u{a8fb}'), ('\u{a8fd}', '\u{a8fd}'), ('\u{a90a}', '\u{a92a}'), ('\u{a930}', '\u{a952}'), ('\u{a960}', '\u{a97c}'), ('\u{a980}', '\u{a9b2}'), ('\u{a9b4}', '\u{a9bf}'), ('\u{a9cf}', '\u{a9cf}'), ('\u{a9e0}', '\u{a9e4}'), ('\u{a9e6}', '\u{a9ef}'), ('\u{a9fa}', '\u{a9fe}'), ('\u{aa00}', '\u{aa36}'), ('\u{aa40}', '\u{aa4d}'), ('\u{aa60}', '\u{aa76}'), ('\u{aa7a}', '\u{aa7a}'), ('\u{aa7e}', '\u{aabe}'), ('\u{aac0}', '\u{aac0}'), ('\u{aac2}', '\u{aac2}'), ('\u{aadb}', '\u{aadd}'), ('\u{aae0}', '\u{aaef}'), ('\u{aaf2}', '\u{aaf5}'), ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab5c}', '\u{ab65}'), ('\u{ab70}', '\u{abea}'), ('\u{ac00}', '\u{d7a3}'), ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', '\u{fa6d}'), ('\u{fa70}', '\u{fad9}'), ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{fb1d}', '\u{fb28}'), ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), ('\u{fb46}', '\u{fbb1}'), ('\u{fbd3}', '\u{fd3d}'), ('\u{fd50}', '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}', '\u{fdfb}'), ('\u{fe70}', '\u{fe74}'), ('\u{fe76}', '\u{fefc}'), ('\u{ff21}', '\u{ff3a}'), ('\u{ff41}', '\u{ff5a}'), ('\u{ff66}', '\u{ffbe}'), ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'), ('\u{10000}', '\u{1000b}'), ('\u{1000d}', '\u{10026}'), ('\u{10028}', '\u{1003a}'), ('\u{1003c}', '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'), ('\u{10080}', '\u{100fa}'), ('\u{10140}', '\u{10174}'), ('\u{10280}', '\u{1029c}'), ('\u{102a0}', '\u{102d0}'), ('\u{10300}', '\u{1031f}'), ('\u{10330}', '\u{1034a}'), ('\u{10350}', '\u{1037a}'), ('\u{10380}', '\u{1039d}'), ('\u{103a0}', '\u{103c3}'), ('\u{103c8}', '\u{103cf}'), ('\u{103d1}', '\u{103d5}'), ('\u{10400}', '\u{1049d}'), ('\u{10500}', '\u{10527}'), ('\u{10530}', '\u{10563}'), ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), ('\u{10760}', '\u{10767}'), ('\u{10800}', '\u{10805}'), ('\u{10808}', '\u{10808}'), ('\u{1080a}', '\u{10835}'), ('\u{10837}', '\u{10838}'), ('\u{1083c}', '\u{1083c}'), ('\u{1083f}', '\u{10855}'), ('\u{10860}', '\u{10876}'), ('\u{10880}', '\u{1089e}'), ('\u{108e0}', '\u{108f2}'), ('\u{108f4}', '\u{108f5}'), ('\u{10900}', '\u{10915}'), ('\u{10920}', '\u{10939}'), ('\u{10980}', '\u{109b7}'), ('\u{109be}', '\u{109bf}'), ('\u{10a00}', '\u{10a03}'), ('\u{10a05}', '\u{10a06}'), ('\u{10a0c}', '\u{10a13}'), ('\u{10a15}', '\u{10a17}'), ('\u{10a19}', '\u{10a33}'), ('\u{10a60}', '\u{10a7c}'), ('\u{10a80}', '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'), ('\u{10ac9}', '\u{10ae4}'), ('\u{10b00}', '\u{10b35}'), ('\u{10b40}', '\u{10b55}'), ('\u{10b60}', '\u{10b72}'), ('\u{10b80}', '\u{10b91}'), ('\u{10c00}', '\u{10c48}'), ('\u{10c80}', '\u{10cb2}'), ('\u{10cc0}', '\u{10cf2}'), ('\u{11000}', '\u{11045}'), ('\u{11082}', '\u{110b8}'), ('\u{110d0}', '\u{110e8}'), ('\u{11100}', '\u{11132}'), ('\u{11150}', '\u{11172}'), ('\u{11176}', '\u{11176}'), ('\u{11180}', '\u{111bf}'), ('\u{111c1}', '\u{111c4}'), ('\u{111da}', '\u{111da}'), ('\u{111dc}', '\u{111dc}'), ('\u{11200}', '\u{11211}'), ('\u{11213}', '\u{11234}'), ('\u{11237}', '\u{11237}'), ('\u{11280}', '\u{11286}'), ('\u{11288}', '\u{11288}'), ('\u{1128a}', '\u{1128d}'), ('\u{1128f}', '\u{1129d}'), ('\u{1129f}', '\u{112a8}'), ('\u{112b0}', '\u{112e8}'), ('\u{11300}', '\u{11303}'), ('\u{11305}', '\u{1130c}'), ('\u{1130f}', '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'), ('\u{11332}', '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133d}', '\u{11344}'), ('\u{11347}', '\u{11348}'), ('\u{1134b}', '\u{1134c}'), ('\u{11350}', '\u{11350}'), ('\u{11357}', '\u{11357}'), ('\u{1135d}', '\u{11363}'), ('\u{11480}', '\u{114c1}'), ('\u{114c4}', '\u{114c5}'), ('\u{114c7}', '\u{114c7}'), ('\u{11580}', '\u{115b5}'), ('\u{115b8}', '\u{115be}'), ('\u{115d8}', '\u{115dd}'), ('\u{11600}', '\u{1163e}'), ('\u{11640}', '\u{11640}'), ('\u{11644}', '\u{11644}'), ('\u{11680}', '\u{116b5}'), ('\u{11700}', '\u{11719}'), ('\u{1171d}', '\u{1172a}'), ('\u{118a0}', '\u{118df}'), ('\u{118ff}', '\u{118ff}'), ('\u{11ac0}', '\u{11af8}'), ('\u{12000}', '\u{12399}'), ('\u{12400}', '\u{1246e}'), ('\u{12480}', '\u{12543}'), ('\u{13000}', '\u{1342e}'), ('\u{14400}', '\u{14646}'), ('\u{16800}', '\u{16a38}'), ('\u{16a40}', '\u{16a5e}'), ('\u{16ad0}', '\u{16aed}'), ('\u{16b00}', '\u{16b36}'), ('\u{16b40}', '\u{16b43}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}'), ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f7e}'), ('\u{16f93}', '\u{16f9f}'), ('\u{1b000}', '\u{1b001}'), ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}', '\u{1bc99}'), ('\u{1bc9e}', '\u{1bc9e}'), ('\u{1d400}', '\u{1d454}'), ('\u{1d456}', '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}', '\u{1d6a5}'), ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}', '\u{1d6fa}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', '\u{1d734}'), ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d76e}'), ('\u{1d770}', '\u{1d788}'), ('\u{1d78a}', '\u{1d7a8}'), ('\u{1d7aa}', '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7cb}'), ('\u{1e800}', '\u{1e8c4}'), ('\u{1ee00}', '\u{1ee03}'), ('\u{1ee05}', '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', '\u{1ee47}'), ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}', '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), ('\u{1ee57}', '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', '\u{1ee77}'), ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}', '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), ('\u{1eea5}', '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), ('\u{1f130}', '\u{1f149}'), ('\u{1f150}', '\u{1f169}'), ('\u{1f170}', '\u{1f189}'), ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}', '\u{2b734}'), ('\u{2b740}', '\u{2b81d}'), ('\u{2b820}', '\u{2cea1}'), ('\u{2f800}', '\u{2fa1d}') ]; pub const Default_Ignorable_Code_Point_table: &'static [(char, char)] = &[ ('\u{ad}', '\u{ad}'), ('\u{34f}', '\u{34f}'), ('\u{61c}', '\u{61c}'), ('\u{115f}', '\u{1160}'), ('\u{17b4}', '\u{17b5}'), ('\u{180b}', '\u{180e}'), ('\u{200b}', '\u{200f}'), ('\u{202a}', '\u{202e}'), ('\u{2060}', '\u{206f}'), ('\u{3164}', '\u{3164}'), ('\u{fe00}', '\u{fe0f}'), ('\u{feff}', '\u{feff}'), ('\u{ffa0}', '\u{ffa0}'), ('\u{fff0}', '\u{fff8}'), ('\u{1bca0}', '\u{1bca3}'), ('\u{1d173}', '\u{1d17a}'), ('\u{e0000}', '\u{e0fff}') ]; pub const Grapheme_Extend_table: &'static [(char, char)] = &[ ('\u{300}', '\u{36f}'), ('\u{483}', '\u{489}'), ('\u{591}', '\u{5bd}'), ('\u{5bf}', '\u{5bf}'), ('\u{5c1}', '\u{5c2}'), ('\u{5c4}', '\u{5c5}'), ('\u{5c7}', '\u{5c7}'), ('\u{610}', '\u{61a}'), ('\u{64b}', '\u{65f}'), ('\u{670}', '\u{670}'), ('\u{6d6}', '\u{6dc}'), ('\u{6df}', '\u{6e4}'), ('\u{6e7}', '\u{6e8}'), ('\u{6ea}', '\u{6ed}'), ('\u{711}', '\u{711}'), ('\u{730}', '\u{74a}'), ('\u{7a6}', '\u{7b0}'), ('\u{7eb}', '\u{7f3}'), ('\u{816}', '\u{819}'), ('\u{81b}', '\u{823}'), ('\u{825}', '\u{827}'), ('\u{829}', '\u{82d}'), ('\u{859}', '\u{85b}'), ('\u{8e3}', '\u{902}'), ('\u{93a}', '\u{93a}'), ('\u{93c}', '\u{93c}'), ('\u{941}', '\u{948}'), ('\u{94d}', '\u{94d}'), ('\u{951}', '\u{957}'), ('\u{962}', '\u{963}'), ('\u{981}', '\u{981}'), ('\u{9bc}', '\u{9bc}'), ('\u{9be}', '\u{9be}'), ('\u{9c1}', '\u{9c4}'), ('\u{9cd}', '\u{9cd}'), ('\u{9d7}', '\u{9d7}'), ('\u{9e2}', '\u{9e3}'), ('\u{a01}', '\u{a02}'), ('\u{a3c}', '\u{a3c}'), ('\u{a41}', '\u{a42}'), ('\u{a47}', '\u{a48}'), ('\u{a4b}', '\u{a4d}'), ('\u{a51}', '\u{a51}'), ('\u{a70}', '\u{a71}'), ('\u{a75}', '\u{a75}'), ('\u{a81}', '\u{a82}'), ('\u{abc}', '\u{abc}'), ('\u{ac1}', '\u{ac5}'), ('\u{ac7}', '\u{ac8}'), ('\u{acd}', '\u{acd}'), ('\u{ae2}', '\u{ae3}'), ('\u{b01}', '\u{b01}'), ('\u{b3c}', '\u{b3c}'), ('\u{b3e}', '\u{b3f}'), ('\u{b41}', '\u{b44}'), ('\u{b4d}', '\u{b4d}'), ('\u{b56}', '\u{b57}'), ('\u{b62}', '\u{b63}'), ('\u{b82}', '\u{b82}'), ('\u{bbe}', '\u{bbe}'), ('\u{bc0}', '\u{bc0}'), ('\u{bcd}', '\u{bcd}'), ('\u{bd7}', '\u{bd7}'), ('\u{c00}', '\u{c00}'), ('\u{c3e}', '\u{c40}'), ('\u{c46}', '\u{c48}'), ('\u{c4a}', '\u{c4d}'), ('\u{c55}', '\u{c56}'), ('\u{c62}', '\u{c63}'), ('\u{c81}', '\u{c81}'), ('\u{cbc}', '\u{cbc}'), ('\u{cbf}', '\u{cbf}'), ('\u{cc2}', '\u{cc2}'), ('\u{cc6}', '\u{cc6}'), ('\u{ccc}', '\u{ccd}'), ('\u{cd5}', '\u{cd6}'), ('\u{ce2}', '\u{ce3}'), ('\u{d01}', '\u{d01}'), ('\u{d3e}', '\u{d3e}'), ('\u{d41}', '\u{d44}'), ('\u{d4d}', '\u{d4d}'), ('\u{d57}', '\u{d57}'), ('\u{d62}', '\u{d63}'), ('\u{dca}', '\u{dca}'), ('\u{dcf}', '\u{dcf}'), ('\u{dd2}', '\u{dd4}'), ('\u{dd6}', '\u{dd6}'), ('\u{ddf}', '\u{ddf}'), ('\u{e31}', '\u{e31}'), ('\u{e34}', '\u{e3a}'), ('\u{e47}', '\u{e4e}'), ('\u{eb1}', '\u{eb1}'), ('\u{eb4}', '\u{eb9}'), ('\u{ebb}', '\u{ebc}'), ('\u{ec8}', '\u{ecd}'), ('\u{f18}', '\u{f19}'), ('\u{f35}', '\u{f35}'), ('\u{f37}', '\u{f37}'), ('\u{f39}', '\u{f39}'), ('\u{f71}', '\u{f7e}'), ('\u{f80}', '\u{f84}'), ('\u{f86}', '\u{f87}'), ('\u{f8d}', '\u{f97}'), ('\u{f99}', '\u{fbc}'), ('\u{fc6}', '\u{fc6}'), ('\u{102d}', '\u{1030}'), ('\u{1032}', '\u{1037}'), ('\u{1039}', '\u{103a}'), ('\u{103d}', '\u{103e}'), ('\u{1058}', '\u{1059}'), ('\u{105e}', '\u{1060}'), ('\u{1071}', '\u{1074}'), ('\u{1082}', '\u{1082}'), ('\u{1085}', '\u{1086}'), ('\u{108d}', '\u{108d}'), ('\u{109d}', '\u{109d}'), ('\u{135d}', '\u{135f}'), ('\u{1712}', '\u{1714}'), ('\u{1732}', '\u{1734}'), ('\u{1752}', '\u{1753}'), ('\u{1772}', '\u{1773}'), ('\u{17b4}', '\u{17b5}'), ('\u{17b7}', '\u{17bd}'), ('\u{17c6}', '\u{17c6}'), ('\u{17c9}', '\u{17d3}'), ('\u{17dd}', '\u{17dd}'), ('\u{180b}', '\u{180d}'), ('\u{18a9}', '\u{18a9}'), ('\u{1920}', '\u{1922}'), ('\u{1927}', '\u{1928}'), ('\u{1932}', '\u{1932}'), ('\u{1939}', '\u{193b}'), ('\u{1a17}', '\u{1a18}'), ('\u{1a1b}', '\u{1a1b}'), ('\u{1a56}', '\u{1a56}'), ('\u{1a58}', '\u{1a5e}'), ('\u{1a60}', '\u{1a60}'), ('\u{1a62}', '\u{1a62}'), ('\u{1a65}', '\u{1a6c}'), ('\u{1a73}', '\u{1a7c}'), ('\u{1a7f}', '\u{1a7f}'), ('\u{1ab0}', '\u{1abe}'), ('\u{1b00}', '\u{1b03}'), ('\u{1b34}', '\u{1b34}'), ('\u{1b36}', '\u{1b3a}'), ('\u{1b3c}', '\u{1b3c}'), ('\u{1b42}', '\u{1b42}'), ('\u{1b6b}', '\u{1b73}'), ('\u{1b80}', '\u{1b81}'), ('\u{1ba2}', '\u{1ba5}'), ('\u{1ba8}', '\u{1ba9}'), ('\u{1bab}', '\u{1bad}'), ('\u{1be6}', '\u{1be6}'), ('\u{1be8}', '\u{1be9}'), ('\u{1bed}', '\u{1bed}'), ('\u{1bef}', '\u{1bf1}'), ('\u{1c2c}', '\u{1c33}'), ('\u{1c36}', '\u{1c37}'), ('\u{1cd0}', '\u{1cd2}'), ('\u{1cd4}', '\u{1ce0}'), ('\u{1ce2}', '\u{1ce8}'), ('\u{1ced}', '\u{1ced}'), ('\u{1cf4}', '\u{1cf4}'), ('\u{1cf8}', '\u{1cf9}'), ('\u{1dc0}', '\u{1df5}'), ('\u{1dfc}', '\u{1dff}'), ('\u{200c}', '\u{200d}'), ('\u{20d0}', '\u{20f0}'), ('\u{2cef}', '\u{2cf1}'), ('\u{2d7f}', '\u{2d7f}'), ('\u{2de0}', '\u{2dff}'), ('\u{302a}', '\u{302f}'), ('\u{3099}', '\u{309a}'), ('\u{a66f}', '\u{a672}'), ('\u{a674}', '\u{a67d}'), ('\u{a69e}', '\u{a69f}'), ('\u{a6f0}', '\u{a6f1}'), ('\u{a802}', '\u{a802}'), ('\u{a806}', '\u{a806}'), ('\u{a80b}', '\u{a80b}'), ('\u{a825}', '\u{a826}'), ('\u{a8c4}', '\u{a8c4}'), ('\u{a8e0}', '\u{a8f1}'), ('\u{a926}', '\u{a92d}'), ('\u{a947}', '\u{a951}'), ('\u{a980}', '\u{a982}'), ('\u{a9b3}', '\u{a9b3}'), ('\u{a9b6}', '\u{a9b9}'), ('\u{a9bc}', '\u{a9bc}'), ('\u{a9e5}', '\u{a9e5}'), ('\u{aa29}', '\u{aa2e}'), ('\u{aa31}', '\u{aa32}'), ('\u{aa35}', '\u{aa36}'), ('\u{aa43}', '\u{aa43}'), ('\u{aa4c}', '\u{aa4c}'), ('\u{aa7c}', '\u{aa7c}'), ('\u{aab0}', '\u{aab0}'), ('\u{aab2}', '\u{aab4}'), ('\u{aab7}', '\u{aab8}'), ('\u{aabe}', '\u{aabf}'), ('\u{aac1}', '\u{aac1}'), ('\u{aaec}', '\u{aaed}'), ('\u{aaf6}', '\u{aaf6}'), ('\u{abe5}', '\u{abe5}'), ('\u{abe8}', '\u{abe8}'), ('\u{abed}', '\u{abed}'), ('\u{fb1e}', '\u{fb1e}'), ('\u{fe00}', '\u{fe0f}'), ('\u{fe20}', '\u{fe2f}'), ('\u{ff9e}', '\u{ff9f}'), ('\u{101fd}', '\u{101fd}'), ('\u{102e0}', '\u{102e0}'), ('\u{10376}', '\u{1037a}'), ('\u{10a01}', '\u{10a03}'), ('\u{10a05}', '\u{10a06}'), ('\u{10a0c}', '\u{10a0f}'), ('\u{10a38}', '\u{10a3a}'), ('\u{10a3f}', '\u{10a3f}'), ('\u{10ae5}', '\u{10ae6}'), ('\u{11001}', '\u{11001}'), ('\u{11038}', '\u{11046}'), ('\u{1107f}', '\u{11081}'), ('\u{110b3}', '\u{110b6}'), ('\u{110b9}', '\u{110ba}'), ('\u{11100}', '\u{11102}'), ('\u{11127}', '\u{1112b}'), ('\u{1112d}', '\u{11134}'), ('\u{11173}', '\u{11173}'), ('\u{11180}', '\u{11181}'), ('\u{111b6}', '\u{111be}'), ('\u{111ca}', '\u{111cc}'), ('\u{1122f}', '\u{11231}'), ('\u{11234}', '\u{11234}'), ('\u{11236}', '\u{11237}'), ('\u{112df}', '\u{112df}'), ('\u{112e3}', '\u{112ea}'), ('\u{11300}', '\u{11301}'), ('\u{1133c}', '\u{1133c}'), ('\u{1133e}', '\u{1133e}'), ('\u{11340}', '\u{11340}'), ('\u{11357}', '\u{11357}'), ('\u{11366}', '\u{1136c}'), ('\u{11370}', '\u{11374}'), ('\u{114b0}', '\u{114b0}'), ('\u{114b3}', '\u{114b8}'), ('\u{114ba}', '\u{114ba}'), ('\u{114bd}', '\u{114bd}'), ('\u{114bf}', '\u{114c0}'), ('\u{114c2}', '\u{114c3}'), ('\u{115af}', '\u{115af}'), ('\u{115b2}', '\u{115b5}'), ('\u{115bc}', '\u{115bd}'), ('\u{115bf}', '\u{115c0}'), ('\u{115dc}', '\u{115dd}'), ('\u{11633}', '\u{1163a}'), ('\u{1163d}', '\u{1163d}'), ('\u{1163f}', '\u{11640}'), ('\u{116ab}', '\u{116ab}'), ('\u{116ad}', '\u{116ad}'), ('\u{116b0}', '\u{116b5}'), ('\u{116b7}', '\u{116b7}'), ('\u{1171d}', '\u{1171f}'), ('\u{11722}', '\u{11725}'), ('\u{11727}', '\u{1172b}'), ('\u{16af0}', '\u{16af4}'), ('\u{16b30}', '\u{16b36}'), ('\u{16f8f}', '\u{16f92}'), ('\u{1bc9d}', '\u{1bc9e}'), ('\u{1d165}', '\u{1d165}'), ('\u{1d167}', '\u{1d169}'), ('\u{1d16e}', '\u{1d172}'), ('\u{1d17b}', '\u{1d182}'), ('\u{1d185}', '\u{1d18b}'), ('\u{1d1aa}', '\u{1d1ad}'), ('\u{1d242}', '\u{1d244}'), ('\u{1da00}', '\u{1da36}'), ('\u{1da3b}', '\u{1da6c}'), ('\u{1da75}', '\u{1da75}'), ('\u{1da84}', '\u{1da84}'), ('\u{1da9b}', '\u{1da9f}'), ('\u{1daa1}', '\u{1daaf}'), ('\u{1e8d0}', '\u{1e8d6}'), ('\u{e0100}', '\u{e01ef}') ]; pub const Lowercase_table: &'static [(char, char)] = &[ ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), ('\u{b5}', '\u{b5}'), ('\u{ba}', '\u{ba}'), ('\u{df}', '\u{f6}'), ('\u{f8}', '\u{ff}'), ('\u{101}', '\u{101}'), ('\u{103}', '\u{103}'), ('\u{105}', '\u{105}'), ('\u{107}', '\u{107}'), ('\u{109}', '\u{109}'), ('\u{10b}', '\u{10b}'), ('\u{10d}', '\u{10d}'), ('\u{10f}', '\u{10f}'), ('\u{111}', '\u{111}'), ('\u{113}', '\u{113}'), ('\u{115}', '\u{115}'), ('\u{117}', '\u{117}'), ('\u{119}', '\u{119}'), ('\u{11b}', '\u{11b}'), ('\u{11d}', '\u{11d}'), ('\u{11f}', '\u{11f}'), ('\u{121}', '\u{121}'), ('\u{123}', '\u{123}'), ('\u{125}', '\u{125}'), ('\u{127}', '\u{127}'), ('\u{129}', '\u{129}'), ('\u{12b}', '\u{12b}'), ('\u{12d}', '\u{12d}'), ('\u{12f}', '\u{12f}'), ('\u{131}', '\u{131}'), ('\u{133}', '\u{133}'), ('\u{135}', '\u{135}'), ('\u{137}', '\u{138}'), ('\u{13a}', '\u{13a}'), ('\u{13c}', '\u{13c}'), ('\u{13e}', '\u{13e}'), ('\u{140}', '\u{140}'), ('\u{142}', '\u{142}'), ('\u{144}', '\u{144}'), ('\u{146}', '\u{146}'), ('\u{148}', '\u{149}'), ('\u{14b}', '\u{14b}'), ('\u{14d}', '\u{14d}'), ('\u{14f}', '\u{14f}'), ('\u{151}', '\u{151}'), ('\u{153}', '\u{153}'), ('\u{155}', '\u{155}'), ('\u{157}', '\u{157}'), ('\u{159}', '\u{159}'), ('\u{15b}', '\u{15b}'), ('\u{15d}', '\u{15d}'), ('\u{15f}', '\u{15f}'), ('\u{161}', '\u{161}'), ('\u{163}', '\u{163}'), ('\u{165}', '\u{165}'), ('\u{167}', '\u{167}'), ('\u{169}', '\u{169}'), ('\u{16b}', '\u{16b}'), ('\u{16d}', '\u{16d}'), ('\u{16f}', '\u{16f}'), ('\u{171}', '\u{171}'), ('\u{173}', '\u{173}'), ('\u{175}', '\u{175}'), ('\u{177}', '\u{177}'), ('\u{17a}', '\u{17a}'), ('\u{17c}', '\u{17c}'), ('\u{17e}', '\u{180}'), ('\u{183}', '\u{183}'), ('\u{185}', '\u{185}'), ('\u{188}', '\u{188}'), ('\u{18c}', '\u{18d}'), ('\u{192}', '\u{192}'), ('\u{195}', '\u{195}'), ('\u{199}', '\u{19b}'), ('\u{19e}', '\u{19e}'), ('\u{1a1}', '\u{1a1}'), ('\u{1a3}', '\u{1a3}'), ('\u{1a5}', '\u{1a5}'), ('\u{1a8}', '\u{1a8}'), ('\u{1aa}', '\u{1ab}'), ('\u{1ad}', '\u{1ad}'), ('\u{1b0}', '\u{1b0}'), ('\u{1b4}', '\u{1b4}'), ('\u{1b6}', '\u{1b6}'), ('\u{1b9}', '\u{1ba}'), ('\u{1bd}', '\u{1bf}'), ('\u{1c6}', '\u{1c6}'), ('\u{1c9}', '\u{1c9}'), ('\u{1cc}', '\u{1cc}'), ('\u{1ce}', '\u{1ce}'), ('\u{1d0}', '\u{1d0}'), ('\u{1d2}', '\u{1d2}'), ('\u{1d4}', '\u{1d4}'), ('\u{1d6}', '\u{1d6}'), ('\u{1d8}', '\u{1d8}'), ('\u{1da}', '\u{1da}'), ('\u{1dc}', '\u{1dd}'), ('\u{1df}', '\u{1df}'), ('\u{1e1}', '\u{1e1}'), ('\u{1e3}', '\u{1e3}'), ('\u{1e5}', '\u{1e5}'), ('\u{1e7}', '\u{1e7}'), ('\u{1e9}', '\u{1e9}'), ('\u{1eb}', '\u{1eb}'), ('\u{1ed}', '\u{1ed}'), ('\u{1ef}', '\u{1f0}'), ('\u{1f3}', '\u{1f3}'), ('\u{1f5}', '\u{1f5}'), ('\u{1f9}', '\u{1f9}'), ('\u{1fb}', '\u{1fb}'), ('\u{1fd}', '\u{1fd}'), ('\u{1ff}', '\u{1ff}'), ('\u{201}', '\u{201}'), ('\u{203}', '\u{203}'), ('\u{205}', '\u{205}'), ('\u{207}', '\u{207}'), ('\u{209}', '\u{209}'), ('\u{20b}', '\u{20b}'), ('\u{20d}', '\u{20d}'), ('\u{20f}', '\u{20f}'), ('\u{211}', '\u{211}'), ('\u{213}', '\u{213}'), ('\u{215}', '\u{215}'), ('\u{217}', '\u{217}'), ('\u{219}', '\u{219}'), ('\u{21b}', '\u{21b}'), ('\u{21d}', '\u{21d}'), ('\u{21f}', '\u{21f}'), ('\u{221}', '\u{221}'), ('\u{223}', '\u{223}'), ('\u{225}', '\u{225}'), ('\u{227}', '\u{227}'), ('\u{229}', '\u{229}'), ('\u{22b}', '\u{22b}'), ('\u{22d}', '\u{22d}'), ('\u{22f}', '\u{22f}'), ('\u{231}', '\u{231}'), ('\u{233}', '\u{239}'), ('\u{23c}', '\u{23c}'), ('\u{23f}', '\u{240}'), ('\u{242}', '\u{242}'), ('\u{247}', '\u{247}'), ('\u{249}', '\u{249}'), ('\u{24b}', '\u{24b}'), ('\u{24d}', '\u{24d}'), ('\u{24f}', '\u{293}'), ('\u{295}', '\u{2b8}'), ('\u{2c0}', '\u{2c1}'), ('\u{2e0}', '\u{2e4}'), ('\u{345}', '\u{345}'), ('\u{371}', '\u{371}'), ('\u{373}', '\u{373}'), ('\u{377}', '\u{377}'), ('\u{37a}', '\u{37d}'), ('\u{390}', '\u{390}'), ('\u{3ac}', '\u{3ce}'), ('\u{3d0}', '\u{3d1}'), ('\u{3d5}', '\u{3d7}'), ('\u{3d9}', '\u{3d9}'), ('\u{3db}', '\u{3db}'), ('\u{3dd}', '\u{3dd}'), ('\u{3df}', '\u{3df}'), ('\u{3e1}', '\u{3e1}'), ('\u{3e3}', '\u{3e3}'), ('\u{3e5}', '\u{3e5}'), ('\u{3e7}', '\u{3e7}'), ('\u{3e9}', '\u{3e9}'), ('\u{3eb}', '\u{3eb}'), ('\u{3ed}', '\u{3ed}'), ('\u{3ef}', '\u{3f3}'), ('\u{3f5}', '\u{3f5}'), ('\u{3f8}', '\u{3f8}'), ('\u{3fb}', '\u{3fc}'), ('\u{430}', '\u{45f}'), ('\u{461}', '\u{461}'), ('\u{463}', '\u{463}'), ('\u{465}', '\u{465}'), ('\u{467}', '\u{467}'), ('\u{469}', '\u{469}'), ('\u{46b}', '\u{46b}'), ('\u{46d}', '\u{46d}'), ('\u{46f}', '\u{46f}'), ('\u{471}', '\u{471}'), ('\u{473}', '\u{473}'), ('\u{475}', '\u{475}'), ('\u{477}', '\u{477}'), ('\u{479}', '\u{479}'), ('\u{47b}', '\u{47b}'), ('\u{47d}', '\u{47d}'), ('\u{47f}', '\u{47f}'), ('\u{481}', '\u{481}'), ('\u{48b}', '\u{48b}'), ('\u{48d}', '\u{48d}'), ('\u{48f}', '\u{48f}'), ('\u{491}', '\u{491}'), ('\u{493}', '\u{493}'), ('\u{495}', '\u{495}'), ('\u{497}', '\u{497}'), ('\u{499}', '\u{499}'), ('\u{49b}', '\u{49b}'), ('\u{49d}', '\u{49d}'), ('\u{49f}', '\u{49f}'), ('\u{4a1}', '\u{4a1}'), ('\u{4a3}', '\u{4a3}'), ('\u{4a5}', '\u{4a5}'), ('\u{4a7}', '\u{4a7}'), ('\u{4a9}', '\u{4a9}'), ('\u{4ab}', '\u{4ab}'), ('\u{4ad}', '\u{4ad}'), ('\u{4af}', '\u{4af}'), ('\u{4b1}', '\u{4b1}'), ('\u{4b3}', '\u{4b3}'), ('\u{4b5}', '\u{4b5}'), ('\u{4b7}', '\u{4b7}'), ('\u{4b9}', '\u{4b9}'), ('\u{4bb}', '\u{4bb}'), ('\u{4bd}', '\u{4bd}'), ('\u{4bf}', '\u{4bf}'), ('\u{4c2}', '\u{4c2}'), ('\u{4c4}', '\u{4c4}'), ('\u{4c6}', '\u{4c6}'), ('\u{4c8}', '\u{4c8}'), ('\u{4ca}', '\u{4ca}'), ('\u{4cc}', '\u{4cc}'), ('\u{4ce}', '\u{4cf}'), ('\u{4d1}', '\u{4d1}'), ('\u{4d3}', '\u{4d3}'), ('\u{4d5}', '\u{4d5}'), ('\u{4d7}', '\u{4d7}'), ('\u{4d9}', '\u{4d9}'), ('\u{4db}', '\u{4db}'), ('\u{4dd}', '\u{4dd}'), ('\u{4df}', '\u{4df}'), ('\u{4e1}', '\u{4e1}'), ('\u{4e3}', '\u{4e3}'), ('\u{4e5}', '\u{4e5}'), ('\u{4e7}', '\u{4e7}'), ('\u{4e9}', '\u{4e9}'), ('\u{4eb}', '\u{4eb}'), ('\u{4ed}', '\u{4ed}'), ('\u{4ef}', '\u{4ef}'), ('\u{4f1}', '\u{4f1}'), ('\u{4f3}', '\u{4f3}'), ('\u{4f5}', '\u{4f5}'), ('\u{4f7}', '\u{4f7}'), ('\u{4f9}', '\u{4f9}'), ('\u{4fb}', '\u{4fb}'), ('\u{4fd}', '\u{4fd}'), ('\u{4ff}', '\u{4ff}'), ('\u{501}', '\u{501}'), ('\u{503}', '\u{503}'), ('\u{505}', '\u{505}'), ('\u{507}', '\u{507}'), ('\u{509}', '\u{509}'), ('\u{50b}', '\u{50b}'), ('\u{50d}', '\u{50d}'), ('\u{50f}', '\u{50f}'), ('\u{511}', '\u{511}'), ('\u{513}', '\u{513}'), ('\u{515}', '\u{515}'), ('\u{517}', '\u{517}'), ('\u{519}', '\u{519}'), ('\u{51b}', '\u{51b}'), ('\u{51d}', '\u{51d}'), ('\u{51f}', '\u{51f}'), ('\u{521}', '\u{521}'), ('\u{523}', '\u{523}'), ('\u{525}', '\u{525}'), ('\u{527}', '\u{527}'), ('\u{529}', '\u{529}'), ('\u{52b}', '\u{52b}'), ('\u{52d}', '\u{52d}'), ('\u{52f}', '\u{52f}'), ('\u{561}', '\u{587}'), ('\u{13f8}', '\u{13fd}'), ('\u{1d00}', '\u{1dbf}'), ('\u{1e01}', '\u{1e01}'), ('\u{1e03}', '\u{1e03}'), ('\u{1e05}', '\u{1e05}'), ('\u{1e07}', '\u{1e07}'), ('\u{1e09}', '\u{1e09}'), ('\u{1e0b}', '\u{1e0b}'), ('\u{1e0d}', '\u{1e0d}'), ('\u{1e0f}', '\u{1e0f}'), ('\u{1e11}', '\u{1e11}'), ('\u{1e13}', '\u{1e13}'), ('\u{1e15}', '\u{1e15}'), ('\u{1e17}', '\u{1e17}'), ('\u{1e19}', '\u{1e19}'), ('\u{1e1b}', '\u{1e1b}'), ('\u{1e1d}', '\u{1e1d}'), ('\u{1e1f}', '\u{1e1f}'), ('\u{1e21}', '\u{1e21}'), ('\u{1e23}', '\u{1e23}'), ('\u{1e25}', '\u{1e25}'), ('\u{1e27}', '\u{1e27}'), ('\u{1e29}', '\u{1e29}'), ('\u{1e2b}', '\u{1e2b}'), ('\u{1e2d}', '\u{1e2d}'), ('\u{1e2f}', '\u{1e2f}'), ('\u{1e31}', '\u{1e31}'), ('\u{1e33}', '\u{1e33}'), ('\u{1e35}', '\u{1e35}'), ('\u{1e37}', '\u{1e37}'), ('\u{1e39}', '\u{1e39}'), ('\u{1e3b}', '\u{1e3b}'), ('\u{1e3d}', '\u{1e3d}'), ('\u{1e3f}', '\u{1e3f}'), ('\u{1e41}', '\u{1e41}'), ('\u{1e43}', '\u{1e43}'), ('\u{1e45}', '\u{1e45}'), ('\u{1e47}', '\u{1e47}'), ('\u{1e49}', '\u{1e49}'), ('\u{1e4b}', '\u{1e4b}'), ('\u{1e4d}', '\u{1e4d}'), ('\u{1e4f}', '\u{1e4f}'), ('\u{1e51}', '\u{1e51}'), ('\u{1e53}', '\u{1e53}'), ('\u{1e55}', '\u{1e55}'), ('\u{1e57}', '\u{1e57}'), ('\u{1e59}', '\u{1e59}'), ('\u{1e5b}', '\u{1e5b}'), ('\u{1e5d}', '\u{1e5d}'), ('\u{1e5f}', '\u{1e5f}'), ('\u{1e61}', '\u{1e61}'), ('\u{1e63}', '\u{1e63}'), ('\u{1e65}', '\u{1e65}'), ('\u{1e67}', '\u{1e67}'), ('\u{1e69}', '\u{1e69}'), ('\u{1e6b}', '\u{1e6b}'), ('\u{1e6d}', '\u{1e6d}'), ('\u{1e6f}', '\u{1e6f}'), ('\u{1e71}', '\u{1e71}'), ('\u{1e73}', '\u{1e73}'), ('\u{1e75}', '\u{1e75}'), ('\u{1e77}', '\u{1e77}'), ('\u{1e79}', '\u{1e79}'), ('\u{1e7b}', '\u{1e7b}'), ('\u{1e7d}', '\u{1e7d}'), ('\u{1e7f}', '\u{1e7f}'), ('\u{1e81}', '\u{1e81}'), ('\u{1e83}', '\u{1e83}'), ('\u{1e85}', '\u{1e85}'), ('\u{1e87}', '\u{1e87}'), ('\u{1e89}', '\u{1e89}'), ('\u{1e8b}', '\u{1e8b}'), ('\u{1e8d}', '\u{1e8d}'), ('\u{1e8f}', '\u{1e8f}'), ('\u{1e91}', '\u{1e91}'), ('\u{1e93}', '\u{1e93}'), ('\u{1e95}', '\u{1e9d}'), ('\u{1e9f}', '\u{1e9f}'), ('\u{1ea1}', '\u{1ea1}'), ('\u{1ea3}', '\u{1ea3}'), ('\u{1ea5}', '\u{1ea5}'), ('\u{1ea7}', '\u{1ea7}'), ('\u{1ea9}', '\u{1ea9}'), ('\u{1eab}', '\u{1eab}'), ('\u{1ead}', '\u{1ead}'), ('\u{1eaf}', '\u{1eaf}'), ('\u{1eb1}', '\u{1eb1}'), ('\u{1eb3}', '\u{1eb3}'), ('\u{1eb5}', '\u{1eb5}'), ('\u{1eb7}', '\u{1eb7}'), ('\u{1eb9}', '\u{1eb9}'), ('\u{1ebb}', '\u{1ebb}'), ('\u{1ebd}', '\u{1ebd}'), ('\u{1ebf}', '\u{1ebf}'), ('\u{1ec1}', '\u{1ec1}'), ('\u{1ec3}', '\u{1ec3}'), ('\u{1ec5}', '\u{1ec5}'), ('\u{1ec7}', '\u{1ec7}'), ('\u{1ec9}', '\u{1ec9}'), ('\u{1ecb}', '\u{1ecb}'), ('\u{1ecd}', '\u{1ecd}'), ('\u{1ecf}', '\u{1ecf}'), ('\u{1ed1}', '\u{1ed1}'), ('\u{1ed3}', '\u{1ed3}'), ('\u{1ed5}', '\u{1ed5}'), ('\u{1ed7}', '\u{1ed7}'), ('\u{1ed9}', '\u{1ed9}'), ('\u{1edb}', '\u{1edb}'), ('\u{1edd}', '\u{1edd}'), ('\u{1edf}', '\u{1edf}'), ('\u{1ee1}', '\u{1ee1}'), ('\u{1ee3}', '\u{1ee3}'), ('\u{1ee5}', '\u{1ee5}'), ('\u{1ee7}', '\u{1ee7}'), ('\u{1ee9}', '\u{1ee9}'), ('\u{1eeb}', '\u{1eeb}'), ('\u{1eed}', '\u{1eed}'), ('\u{1eef}', '\u{1eef}'), ('\u{1ef1}', '\u{1ef1}'), ('\u{1ef3}', '\u{1ef3}'), ('\u{1ef5}', '\u{1ef5}'), ('\u{1ef7}', '\u{1ef7}'), ('\u{1ef9}', '\u{1ef9}'), ('\u{1efb}', '\u{1efb}'), ('\u{1efd}', '\u{1efd}'), ('\u{1eff}', '\u{1f07}'), ('\u{1f10}', '\u{1f15}'), ('\u{1f20}', '\u{1f27}'), ('\u{1f30}', '\u{1f37}'), ('\u{1f40}', '\u{1f45}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f60}', '\u{1f67}'), ('\u{1f70}', '\u{1f7d}'), ('\u{1f80}', '\u{1f87}'), ('\u{1f90}', '\u{1f97}'), ('\u{1fa0}', '\u{1fa7}'), ('\u{1fb0}', '\u{1fb4}'), ('\u{1fb6}', '\u{1fb7}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'), ('\u{1fc6}', '\u{1fc7}'), ('\u{1fd0}', '\u{1fd3}'), ('\u{1fd6}', '\u{1fd7}'), ('\u{1fe0}', '\u{1fe7}'), ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}', '\u{1ff7}'), ('\u{2071}', '\u{2071}'), ('\u{207f}', '\u{207f}'), ('\u{2090}', '\u{209c}'), ('\u{210a}', '\u{210a}'), ('\u{210e}', '\u{210f}'), ('\u{2113}', '\u{2113}'), ('\u{212f}', '\u{212f}'), ('\u{2134}', '\u{2134}'), ('\u{2139}', '\u{2139}'), ('\u{213c}', '\u{213d}'), ('\u{2146}', '\u{2149}'), ('\u{214e}', '\u{214e}'), ('\u{2170}', '\u{217f}'), ('\u{2184}', '\u{2184}'), ('\u{24d0}', '\u{24e9}'), ('\u{2c30}', '\u{2c5e}'), ('\u{2c61}', '\u{2c61}'), ('\u{2c65}', '\u{2c66}'), ('\u{2c68}', '\u{2c68}'), ('\u{2c6a}', '\u{2c6a}'), ('\u{2c6c}', '\u{2c6c}'), ('\u{2c71}', '\u{2c71}'), ('\u{2c73}', '\u{2c74}'), ('\u{2c76}', '\u{2c7d}'), ('\u{2c81}', '\u{2c81}'), ('\u{2c83}', '\u{2c83}'), ('\u{2c85}', '\u{2c85}'), ('\u{2c87}', '\u{2c87}'), ('\u{2c89}', '\u{2c89}'), ('\u{2c8b}', '\u{2c8b}'), ('\u{2c8d}', '\u{2c8d}'), ('\u{2c8f}', '\u{2c8f}'), ('\u{2c91}', '\u{2c91}'), ('\u{2c93}', '\u{2c93}'), ('\u{2c95}', '\u{2c95}'), ('\u{2c97}', '\u{2c97}'), ('\u{2c99}', '\u{2c99}'), ('\u{2c9b}', '\u{2c9b}'), ('\u{2c9d}', '\u{2c9d}'), ('\u{2c9f}', '\u{2c9f}'), ('\u{2ca1}', '\u{2ca1}'), ('\u{2ca3}', '\u{2ca3}'), ('\u{2ca5}', '\u{2ca5}'), ('\u{2ca7}', '\u{2ca7}'), ('\u{2ca9}', '\u{2ca9}'), ('\u{2cab}', '\u{2cab}'), ('\u{2cad}', '\u{2cad}'), ('\u{2caf}', '\u{2caf}'), ('\u{2cb1}', '\u{2cb1}'), ('\u{2cb3}', '\u{2cb3}'), ('\u{2cb5}', '\u{2cb5}'), ('\u{2cb7}', '\u{2cb7}'), ('\u{2cb9}', '\u{2cb9}'), ('\u{2cbb}', '\u{2cbb}'), ('\u{2cbd}', '\u{2cbd}'), ('\u{2cbf}', '\u{2cbf}'), ('\u{2cc1}', '\u{2cc1}'), ('\u{2cc3}', '\u{2cc3}'), ('\u{2cc5}', '\u{2cc5}'), ('\u{2cc7}', '\u{2cc7}'), ('\u{2cc9}', '\u{2cc9}'), ('\u{2ccb}', '\u{2ccb}'), ('\u{2ccd}', '\u{2ccd}'), ('\u{2ccf}', '\u{2ccf}'), ('\u{2cd1}', '\u{2cd1}'), ('\u{2cd3}', '\u{2cd3}'), ('\u{2cd5}', '\u{2cd5}'), ('\u{2cd7}', '\u{2cd7}'), ('\u{2cd9}', '\u{2cd9}'), ('\u{2cdb}', '\u{2cdb}'), ('\u{2cdd}', '\u{2cdd}'), ('\u{2cdf}', '\u{2cdf}'), ('\u{2ce1}', '\u{2ce1}'), ('\u{2ce3}', '\u{2ce4}'), ('\u{2cec}', '\u{2cec}'), ('\u{2cee}', '\u{2cee}'), ('\u{2cf3}', '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'), ('\u{a641}', '\u{a641}'), ('\u{a643}', '\u{a643}'), ('\u{a645}', '\u{a645}'), ('\u{a647}', '\u{a647}'), ('\u{a649}', '\u{a649}'), ('\u{a64b}', '\u{a64b}'), ('\u{a64d}', '\u{a64d}'), ('\u{a64f}', '\u{a64f}'), ('\u{a651}', '\u{a651}'), ('\u{a653}', '\u{a653}'), ('\u{a655}', '\u{a655}'), ('\u{a657}', '\u{a657}'), ('\u{a659}', '\u{a659}'), ('\u{a65b}', '\u{a65b}'), ('\u{a65d}', '\u{a65d}'), ('\u{a65f}', '\u{a65f}'), ('\u{a661}', '\u{a661}'), ('\u{a663}', '\u{a663}'), ('\u{a665}', '\u{a665}'), ('\u{a667}', '\u{a667}'), ('\u{a669}', '\u{a669}'), ('\u{a66b}', '\u{a66b}'), ('\u{a66d}', '\u{a66d}'), ('\u{a681}', '\u{a681}'), ('\u{a683}', '\u{a683}'), ('\u{a685}', '\u{a685}'), ('\u{a687}', '\u{a687}'), ('\u{a689}', '\u{a689}'), ('\u{a68b}', '\u{a68b}'), ('\u{a68d}', '\u{a68d}'), ('\u{a68f}', '\u{a68f}'), ('\u{a691}', '\u{a691}'), ('\u{a693}', '\u{a693}'), ('\u{a695}', '\u{a695}'), ('\u{a697}', '\u{a697}'), ('\u{a699}', '\u{a699}'), ('\u{a69b}', '\u{a69d}'), ('\u{a723}', '\u{a723}'), ('\u{a725}', '\u{a725}'), ('\u{a727}', '\u{a727}'), ('\u{a729}', '\u{a729}'), ('\u{a72b}', '\u{a72b}'), ('\u{a72d}', '\u{a72d}'), ('\u{a72f}', '\u{a731}'), ('\u{a733}', '\u{a733}'), ('\u{a735}', '\u{a735}'), ('\u{a737}', '\u{a737}'), ('\u{a739}', '\u{a739}'), ('\u{a73b}', '\u{a73b}'), ('\u{a73d}', '\u{a73d}'), ('\u{a73f}', '\u{a73f}'), ('\u{a741}', '\u{a741}'), ('\u{a743}', '\u{a743}'), ('\u{a745}', '\u{a745}'), ('\u{a747}', '\u{a747}'), ('\u{a749}', '\u{a749}'), ('\u{a74b}', '\u{a74b}'), ('\u{a74d}', '\u{a74d}'), ('\u{a74f}', '\u{a74f}'), ('\u{a751}', '\u{a751}'), ('\u{a753}', '\u{a753}'), ('\u{a755}', '\u{a755}'), ('\u{a757}', '\u{a757}'), ('\u{a759}', '\u{a759}'), ('\u{a75b}', '\u{a75b}'), ('\u{a75d}', '\u{a75d}'), ('\u{a75f}', '\u{a75f}'), ('\u{a761}', '\u{a761}'), ('\u{a763}', '\u{a763}'), ('\u{a765}', '\u{a765}'), ('\u{a767}', '\u{a767}'), ('\u{a769}', '\u{a769}'), ('\u{a76b}', '\u{a76b}'), ('\u{a76d}', '\u{a76d}'), ('\u{a76f}', '\u{a778}'), ('\u{a77a}', '\u{a77a}'), ('\u{a77c}', '\u{a77c}'), ('\u{a77f}', '\u{a77f}'), ('\u{a781}', '\u{a781}'), ('\u{a783}', '\u{a783}'), ('\u{a785}', '\u{a785}'), ('\u{a787}', '\u{a787}'), ('\u{a78c}', '\u{a78c}'), ('\u{a78e}', '\u{a78e}'), ('\u{a791}', '\u{a791}'), ('\u{a793}', '\u{a795}'), ('\u{a797}', '\u{a797}'), ('\u{a799}', '\u{a799}'), ('\u{a79b}', '\u{a79b}'), ('\u{a79d}', '\u{a79d}'), ('\u{a79f}', '\u{a79f}'), ('\u{a7a1}', '\u{a7a1}'), ('\u{a7a3}', '\u{a7a3}'), ('\u{a7a5}', '\u{a7a5}'), ('\u{a7a7}', '\u{a7a7}'), ('\u{a7a9}', '\u{a7a9}'), ('\u{a7b5}', '\u{a7b5}'), ('\u{a7b7}', '\u{a7b7}'), ('\u{a7f8}', '\u{a7fa}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab5c}', '\u{ab65}'), ('\u{ab70}', '\u{abbf}'), ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{ff41}', '\u{ff5a}'), ('\u{10428}', '\u{1044f}'), ('\u{10cc0}', '\u{10cf2}'), ('\u{118c0}', '\u{118df}'), ('\u{1d41a}', '\u{1d433}'), ('\u{1d44e}', '\u{1d454}'), ('\u{1d456}', '\u{1d467}'), ('\u{1d482}', '\u{1d49b}'), ('\u{1d4b6}', '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d4cf}'), ('\u{1d4ea}', '\u{1d503}'), ('\u{1d51e}', '\u{1d537}'), ('\u{1d552}', '\u{1d56b}'), ('\u{1d586}', '\u{1d59f}'), ('\u{1d5ba}', '\u{1d5d3}'), ('\u{1d5ee}', '\u{1d607}'), ('\u{1d622}', '\u{1d63b}'), ('\u{1d656}', '\u{1d66f}'), ('\u{1d68a}', '\u{1d6a5}'), ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}', '\u{1d6e1}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', '\u{1d71b}'), ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d755}'), ('\u{1d770}', '\u{1d788}'), ('\u{1d78a}', '\u{1d78f}'), ('\u{1d7aa}', '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7c9}'), ('\u{1d7cb}', '\u{1d7cb}') ]; pub const Uppercase_table: &'static [(char, char)] = &[ ('\u{41}', '\u{5a}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{de}'), ('\u{100}', '\u{100}'), ('\u{102}', '\u{102}'), ('\u{104}', '\u{104}'), ('\u{106}', '\u{106}'), ('\u{108}', '\u{108}'), ('\u{10a}', '\u{10a}'), ('\u{10c}', '\u{10c}'), ('\u{10e}', '\u{10e}'), ('\u{110}', '\u{110}'), ('\u{112}', '\u{112}'), ('\u{114}', '\u{114}'), ('\u{116}', '\u{116}'), ('\u{118}', '\u{118}'), ('\u{11a}', '\u{11a}'), ('\u{11c}', '\u{11c}'), ('\u{11e}', '\u{11e}'), ('\u{120}', '\u{120}'), ('\u{122}', '\u{122}'), ('\u{124}', '\u{124}'), ('\u{126}', '\u{126}'), ('\u{128}', '\u{128}'), ('\u{12a}', '\u{12a}'), ('\u{12c}', '\u{12c}'), ('\u{12e}', '\u{12e}'), ('\u{130}', '\u{130}'), ('\u{132}', '\u{132}'), ('\u{134}', '\u{134}'), ('\u{136}', '\u{136}'), ('\u{139}', '\u{139}'), ('\u{13b}', '\u{13b}'), ('\u{13d}', '\u{13d}'), ('\u{13f}', '\u{13f}'), ('\u{141}', '\u{141}'), ('\u{143}', '\u{143}'), ('\u{145}', '\u{145}'), ('\u{147}', '\u{147}'), ('\u{14a}', '\u{14a}'), ('\u{14c}', '\u{14c}'), ('\u{14e}', '\u{14e}'), ('\u{150}', '\u{150}'), ('\u{152}', '\u{152}'), ('\u{154}', '\u{154}'), ('\u{156}', '\u{156}'), ('\u{158}', '\u{158}'), ('\u{15a}', '\u{15a}'), ('\u{15c}', '\u{15c}'), ('\u{15e}', '\u{15e}'), ('\u{160}', '\u{160}'), ('\u{162}', '\u{162}'), ('\u{164}', '\u{164}'), ('\u{166}', '\u{166}'), ('\u{168}', '\u{168}'), ('\u{16a}', '\u{16a}'), ('\u{16c}', '\u{16c}'), ('\u{16e}', '\u{16e}'), ('\u{170}', '\u{170}'), ('\u{172}', '\u{172}'), ('\u{174}', '\u{174}'), ('\u{176}', '\u{176}'), ('\u{178}', '\u{179}'), ('\u{17b}', '\u{17b}'), ('\u{17d}', '\u{17d}'), ('\u{181}', '\u{182}'), ('\u{184}', '\u{184}'), ('\u{186}', '\u{187}'), ('\u{189}', '\u{18b}'), ('\u{18e}', '\u{191}'), ('\u{193}', '\u{194}'), ('\u{196}', '\u{198}'), ('\u{19c}', '\u{19d}'), ('\u{19f}', '\u{1a0}'), ('\u{1a2}', '\u{1a2}'), ('\u{1a4}', '\u{1a4}'), ('\u{1a6}', '\u{1a7}'), ('\u{1a9}', '\u{1a9}'), ('\u{1ac}', '\u{1ac}'), ('\u{1ae}', '\u{1af}'), ('\u{1b1}', '\u{1b3}'), ('\u{1b5}', '\u{1b5}'), ('\u{1b7}', '\u{1b8}'), ('\u{1bc}', '\u{1bc}'), ('\u{1c4}', '\u{1c4}'), ('\u{1c7}', '\u{1c7}'), ('\u{1ca}', '\u{1ca}'), ('\u{1cd}', '\u{1cd}'), ('\u{1cf}', '\u{1cf}'), ('\u{1d1}', '\u{1d1}'), ('\u{1d3}', '\u{1d3}'), ('\u{1d5}', '\u{1d5}'), ('\u{1d7}', '\u{1d7}'), ('\u{1d9}', '\u{1d9}'), ('\u{1db}', '\u{1db}'), ('\u{1de}', '\u{1de}'), ('\u{1e0}', '\u{1e0}'), ('\u{1e2}', '\u{1e2}'), ('\u{1e4}', '\u{1e4}'), ('\u{1e6}', '\u{1e6}'), ('\u{1e8}', '\u{1e8}'), ('\u{1ea}', '\u{1ea}'), ('\u{1ec}', '\u{1ec}'), ('\u{1ee}', '\u{1ee}'), ('\u{1f1}', '\u{1f1}'), ('\u{1f4}', '\u{1f4}'), ('\u{1f6}', '\u{1f8}'), ('\u{1fa}', '\u{1fa}'), ('\u{1fc}', '\u{1fc}'), ('\u{1fe}', '\u{1fe}'), ('\u{200}', '\u{200}'), ('\u{202}', '\u{202}'), ('\u{204}', '\u{204}'), ('\u{206}', '\u{206}'), ('\u{208}', '\u{208}'), ('\u{20a}', '\u{20a}'), ('\u{20c}', '\u{20c}'), ('\u{20e}', '\u{20e}'), ('\u{210}', '\u{210}'), ('\u{212}', '\u{212}'), ('\u{214}', '\u{214}'), ('\u{216}', '\u{216}'), ('\u{218}', '\u{218}'), ('\u{21a}', '\u{21a}'), ('\u{21c}', '\u{21c}'), ('\u{21e}', '\u{21e}'), ('\u{220}', '\u{220}'), ('\u{222}', '\u{222}'), ('\u{224}', '\u{224}'), ('\u{226}', '\u{226}'), ('\u{228}', '\u{228}'), ('\u{22a}', '\u{22a}'), ('\u{22c}', '\u{22c}'), ('\u{22e}', '\u{22e}'), ('\u{230}', '\u{230}'), ('\u{232}', '\u{232}'), ('\u{23a}', '\u{23b}'), ('\u{23d}', '\u{23e}'), ('\u{241}', '\u{241}'), ('\u{243}', '\u{246}'), ('\u{248}', '\u{248}'), ('\u{24a}', '\u{24a}'), ('\u{24c}', '\u{24c}'), ('\u{24e}', '\u{24e}'), ('\u{370}', '\u{370}'), ('\u{372}', '\u{372}'), ('\u{376}', '\u{376}'), ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{386}'), ('\u{388}', '\u{38a}'), ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{38f}'), ('\u{391}', '\u{3a1}'), ('\u{3a3}', '\u{3ab}'), ('\u{3cf}', '\u{3cf}'), ('\u{3d2}', '\u{3d4}'), ('\u{3d8}', '\u{3d8}'), ('\u{3da}', '\u{3da}'), ('\u{3dc}', '\u{3dc}'), ('\u{3de}', '\u{3de}'), ('\u{3e0}', '\u{3e0}'), ('\u{3e2}', '\u{3e2}'), ('\u{3e4}', '\u{3e4}'), ('\u{3e6}', '\u{3e6}'), ('\u{3e8}', '\u{3e8}'), ('\u{3ea}', '\u{3ea}'), ('\u{3ec}', '\u{3ec}'), ('\u{3ee}', '\u{3ee}'), ('\u{3f4}', '\u{3f4}'), ('\u{3f7}', '\u{3f7}'), ('\u{3f9}', '\u{3fa}'), ('\u{3fd}', '\u{42f}'), ('\u{460}', '\u{460}'), ('\u{462}', '\u{462}'), ('\u{464}', '\u{464}'), ('\u{466}', '\u{466}'), ('\u{468}', '\u{468}'), ('\u{46a}', '\u{46a}'), ('\u{46c}', '\u{46c}'), ('\u{46e}', '\u{46e}'), ('\u{470}', '\u{470}'), ('\u{472}', '\u{472}'), ('\u{474}', '\u{474}'), ('\u{476}', '\u{476}'), ('\u{478}', '\u{478}'), ('\u{47a}', '\u{47a}'), ('\u{47c}', '\u{47c}'), ('\u{47e}', '\u{47e}'), ('\u{480}', '\u{480}'), ('\u{48a}', '\u{48a}'), ('\u{48c}', '\u{48c}'), ('\u{48e}', '\u{48e}'), ('\u{490}', '\u{490}'), ('\u{492}', '\u{492}'), ('\u{494}', '\u{494}'), ('\u{496}', '\u{496}'), ('\u{498}', '\u{498}'), ('\u{49a}', '\u{49a}'), ('\u{49c}', '\u{49c}'), ('\u{49e}', '\u{49e}'), ('\u{4a0}', '\u{4a0}'), ('\u{4a2}', '\u{4a2}'), ('\u{4a4}', '\u{4a4}'), ('\u{4a6}', '\u{4a6}'), ('\u{4a8}', '\u{4a8}'), ('\u{4aa}', '\u{4aa}'), ('\u{4ac}', '\u{4ac}'), ('\u{4ae}', '\u{4ae}'), ('\u{4b0}', '\u{4b0}'), ('\u{4b2}', '\u{4b2}'), ('\u{4b4}', '\u{4b4}'), ('\u{4b6}', '\u{4b6}'), ('\u{4b8}', '\u{4b8}'), ('\u{4ba}', '\u{4ba}'), ('\u{4bc}', '\u{4bc}'), ('\u{4be}', '\u{4be}'), ('\u{4c0}', '\u{4c1}'), ('\u{4c3}', '\u{4c3}'), ('\u{4c5}', '\u{4c5}'), ('\u{4c7}', '\u{4c7}'), ('\u{4c9}', '\u{4c9}'), ('\u{4cb}', '\u{4cb}'), ('\u{4cd}', '\u{4cd}'), ('\u{4d0}', '\u{4d0}'), ('\u{4d2}', '\u{4d2}'), ('\u{4d4}', '\u{4d4}'), ('\u{4d6}', '\u{4d6}'), ('\u{4d8}', '\u{4d8}'), ('\u{4da}', '\u{4da}'), ('\u{4dc}', '\u{4dc}'), ('\u{4de}', '\u{4de}'), ('\u{4e0}', '\u{4e0}'), ('\u{4e2}', '\u{4e2}'), ('\u{4e4}', '\u{4e4}'), ('\u{4e6}', '\u{4e6}'), ('\u{4e8}', '\u{4e8}'), ('\u{4ea}', '\u{4ea}'), ('\u{4ec}', '\u{4ec}'), ('\u{4ee}', '\u{4ee}'), ('\u{4f0}', '\u{4f0}'), ('\u{4f2}', '\u{4f2}'), ('\u{4f4}', '\u{4f4}'), ('\u{4f6}', '\u{4f6}'), ('\u{4f8}', '\u{4f8}'), ('\u{4fa}', '\u{4fa}'), ('\u{4fc}', '\u{4fc}'), ('\u{4fe}', '\u{4fe}'), ('\u{500}', '\u{500}'), ('\u{502}', '\u{502}'), ('\u{504}', '\u{504}'), ('\u{506}', '\u{506}'), ('\u{508}', '\u{508}'), ('\u{50a}', '\u{50a}'), ('\u{50c}', '\u{50c}'), ('\u{50e}', '\u{50e}'), ('\u{510}', '\u{510}'), ('\u{512}', '\u{512}'), ('\u{514}', '\u{514}'), ('\u{516}', '\u{516}'), ('\u{518}', '\u{518}'), ('\u{51a}', '\u{51a}'), ('\u{51c}', '\u{51c}'), ('\u{51e}', '\u{51e}'), ('\u{520}', '\u{520}'), ('\u{522}', '\u{522}'), ('\u{524}', '\u{524}'), ('\u{526}', '\u{526}'), ('\u{528}', '\u{528}'), ('\u{52a}', '\u{52a}'), ('\u{52c}', '\u{52c}'), ('\u{52e}', '\u{52e}'), ('\u{531}', '\u{556}'), ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', '\u{10cd}'), ('\u{13a0}', '\u{13f5}'), ('\u{1e00}', '\u{1e00}'), ('\u{1e02}', '\u{1e02}'), ('\u{1e04}', '\u{1e04}'), ('\u{1e06}', '\u{1e06}'), ('\u{1e08}', '\u{1e08}'), ('\u{1e0a}', '\u{1e0a}'), ('\u{1e0c}', '\u{1e0c}'), ('\u{1e0e}', '\u{1e0e}'), ('\u{1e10}', '\u{1e10}'), ('\u{1e12}', '\u{1e12}'), ('\u{1e14}', '\u{1e14}'), ('\u{1e16}', '\u{1e16}'), ('\u{1e18}', '\u{1e18}'), ('\u{1e1a}', '\u{1e1a}'), ('\u{1e1c}', '\u{1e1c}'), ('\u{1e1e}', '\u{1e1e}'), ('\u{1e20}', '\u{1e20}'), ('\u{1e22}', '\u{1e22}'), ('\u{1e24}', '\u{1e24}'), ('\u{1e26}', '\u{1e26}'), ('\u{1e28}', '\u{1e28}'), ('\u{1e2a}', '\u{1e2a}'), ('\u{1e2c}', '\u{1e2c}'), ('\u{1e2e}', '\u{1e2e}'), ('\u{1e30}', '\u{1e30}'), ('\u{1e32}', '\u{1e32}'), ('\u{1e34}', '\u{1e34}'), ('\u{1e36}', '\u{1e36}'), ('\u{1e38}', '\u{1e38}'), ('\u{1e3a}', '\u{1e3a}'), ('\u{1e3c}', '\u{1e3c}'), ('\u{1e3e}', '\u{1e3e}'), ('\u{1e40}', '\u{1e40}'), ('\u{1e42}', '\u{1e42}'), ('\u{1e44}', '\u{1e44}'), ('\u{1e46}', '\u{1e46}'), ('\u{1e48}', '\u{1e48}'), ('\u{1e4a}', '\u{1e4a}'), ('\u{1e4c}', '\u{1e4c}'), ('\u{1e4e}', '\u{1e4e}'), ('\u{1e50}', '\u{1e50}'), ('\u{1e52}', '\u{1e52}'), ('\u{1e54}', '\u{1e54}'), ('\u{1e56}', '\u{1e56}'), ('\u{1e58}', '\u{1e58}'), ('\u{1e5a}', '\u{1e5a}'), ('\u{1e5c}', '\u{1e5c}'), ('\u{1e5e}', '\u{1e5e}'), ('\u{1e60}', '\u{1e60}'), ('\u{1e62}', '\u{1e62}'), ('\u{1e64}', '\u{1e64}'), ('\u{1e66}', '\u{1e66}'), ('\u{1e68}', '\u{1e68}'), ('\u{1e6a}', '\u{1e6a}'), ('\u{1e6c}', '\u{1e6c}'), ('\u{1e6e}', '\u{1e6e}'), ('\u{1e70}', '\u{1e70}'), ('\u{1e72}', '\u{1e72}'), ('\u{1e74}', '\u{1e74}'), ('\u{1e76}', '\u{1e76}'), ('\u{1e78}', '\u{1e78}'), ('\u{1e7a}', '\u{1e7a}'), ('\u{1e7c}', '\u{1e7c}'), ('\u{1e7e}', '\u{1e7e}'), ('\u{1e80}', '\u{1e80}'), ('\u{1e82}', '\u{1e82}'), ('\u{1e84}', '\u{1e84}'), ('\u{1e86}', '\u{1e86}'), ('\u{1e88}', '\u{1e88}'), ('\u{1e8a}', '\u{1e8a}'), ('\u{1e8c}', '\u{1e8c}'), ('\u{1e8e}', '\u{1e8e}'), ('\u{1e90}', '\u{1e90}'), ('\u{1e92}', '\u{1e92}'), ('\u{1e94}', '\u{1e94}'), ('\u{1e9e}', '\u{1e9e}'), ('\u{1ea0}', '\u{1ea0}'), ('\u{1ea2}', '\u{1ea2}'), ('\u{1ea4}', '\u{1ea4}'), ('\u{1ea6}', '\u{1ea6}'), ('\u{1ea8}', '\u{1ea8}'), ('\u{1eaa}', '\u{1eaa}'), ('\u{1eac}', '\u{1eac}'), ('\u{1eae}', '\u{1eae}'), ('\u{1eb0}', '\u{1eb0}'), ('\u{1eb2}', '\u{1eb2}'), ('\u{1eb4}', '\u{1eb4}'), ('\u{1eb6}', '\u{1eb6}'), ('\u{1eb8}', '\u{1eb8}'), ('\u{1eba}', '\u{1eba}'), ('\u{1ebc}', '\u{1ebc}'), ('\u{1ebe}', '\u{1ebe}'), ('\u{1ec0}', '\u{1ec0}'), ('\u{1ec2}', '\u{1ec2}'), ('\u{1ec4}', '\u{1ec4}'), ('\u{1ec6}', '\u{1ec6}'), ('\u{1ec8}', '\u{1ec8}'), ('\u{1eca}', '\u{1eca}'), ('\u{1ecc}', '\u{1ecc}'), ('\u{1ece}', '\u{1ece}'), ('\u{1ed0}', '\u{1ed0}'), ('\u{1ed2}', '\u{1ed2}'), ('\u{1ed4}', '\u{1ed4}'), ('\u{1ed6}', '\u{1ed6}'), ('\u{1ed8}', '\u{1ed8}'), ('\u{1eda}', '\u{1eda}'), ('\u{1edc}', '\u{1edc}'), ('\u{1ede}', '\u{1ede}'), ('\u{1ee0}', '\u{1ee0}'), ('\u{1ee2}', '\u{1ee2}'), ('\u{1ee4}', '\u{1ee4}'), ('\u{1ee6}', '\u{1ee6}'), ('\u{1ee8}', '\u{1ee8}'), ('\u{1eea}', '\u{1eea}'), ('\u{1eec}', '\u{1eec}'), ('\u{1eee}', '\u{1eee}'), ('\u{1ef0}', '\u{1ef0}'), ('\u{1ef2}', '\u{1ef2}'), ('\u{1ef4}', '\u{1ef4}'), ('\u{1ef6}', '\u{1ef6}'), ('\u{1ef8}', '\u{1ef8}'), ('\u{1efa}', '\u{1efa}'), ('\u{1efc}', '\u{1efc}'), ('\u{1efe}', '\u{1efe}'), ('\u{1f08}', '\u{1f0f}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f28}', '\u{1f2f}'), ('\u{1f38}', '\u{1f3f}'), ('\u{1f48}', '\u{1f4d}'), ('\u{1f59}', '\u{1f59}'), ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', '\u{1f5f}'), ('\u{1f68}', '\u{1f6f}'), ('\u{1fb8}', '\u{1fbb}'), ('\u{1fc8}', '\u{1fcb}'), ('\u{1fd8}', '\u{1fdb}'), ('\u{1fe8}', '\u{1fec}'), ('\u{1ff8}', '\u{1ffb}'), ('\u{2102}', '\u{2102}'), ('\u{2107}', '\u{2107}'), ('\u{210b}', '\u{210d}'), ('\u{2110}', '\u{2112}'), ('\u{2115}', '\u{2115}'), ('\u{2119}', '\u{211d}'), ('\u{2124}', '\u{2124}'), ('\u{2126}', '\u{2126}'), ('\u{2128}', '\u{2128}'), ('\u{212a}', '\u{212d}'), ('\u{2130}', '\u{2133}'), ('\u{213e}', '\u{213f}'), ('\u{2145}', '\u{2145}'), ('\u{2160}', '\u{216f}'), ('\u{2183}', '\u{2183}'), ('\u{24b6}', '\u{24cf}'), ('\u{2c00}', '\u{2c2e}'), ('\u{2c60}', '\u{2c60}'), ('\u{2c62}', '\u{2c64}'), ('\u{2c67}', '\u{2c67}'), ('\u{2c69}', '\u{2c69}'), ('\u{2c6b}', '\u{2c6b}'), ('\u{2c6d}', '\u{2c70}'), ('\u{2c72}', '\u{2c72}'), ('\u{2c75}', '\u{2c75}'), ('\u{2c7e}', '\u{2c80}'), ('\u{2c82}', '\u{2c82}'), ('\u{2c84}', '\u{2c84}'), ('\u{2c86}', '\u{2c86}'), ('\u{2c88}', '\u{2c88}'), ('\u{2c8a}', '\u{2c8a}'), ('\u{2c8c}', '\u{2c8c}'), ('\u{2c8e}', '\u{2c8e}'), ('\u{2c90}', '\u{2c90}'), ('\u{2c92}', '\u{2c92}'), ('\u{2c94}', '\u{2c94}'), ('\u{2c96}', '\u{2c96}'), ('\u{2c98}', '\u{2c98}'), ('\u{2c9a}', '\u{2c9a}'), ('\u{2c9c}', '\u{2c9c}'), ('\u{2c9e}', '\u{2c9e}'), ('\u{2ca0}', '\u{2ca0}'), ('\u{2ca2}', '\u{2ca2}'), ('\u{2ca4}', '\u{2ca4}'), ('\u{2ca6}', '\u{2ca6}'), ('\u{2ca8}', '\u{2ca8}'), ('\u{2caa}', '\u{2caa}'), ('\u{2cac}', '\u{2cac}'), ('\u{2cae}', '\u{2cae}'), ('\u{2cb0}', '\u{2cb0}'), ('\u{2cb2}', '\u{2cb2}'), ('\u{2cb4}', '\u{2cb4}'), ('\u{2cb6}', '\u{2cb6}'), ('\u{2cb8}', '\u{2cb8}'), ('\u{2cba}', '\u{2cba}'), ('\u{2cbc}', '\u{2cbc}'), ('\u{2cbe}', '\u{2cbe}'), ('\u{2cc0}', '\u{2cc0}'), ('\u{2cc2}', '\u{2cc2}'), ('\u{2cc4}', '\u{2cc4}'), ('\u{2cc6}', '\u{2cc6}'), ('\u{2cc8}', '\u{2cc8}'), ('\u{2cca}', '\u{2cca}'), ('\u{2ccc}', '\u{2ccc}'), ('\u{2cce}', '\u{2cce}'), ('\u{2cd0}', '\u{2cd0}'), ('\u{2cd2}', '\u{2cd2}'), ('\u{2cd4}', '\u{2cd4}'), ('\u{2cd6}', '\u{2cd6}'), ('\u{2cd8}', '\u{2cd8}'), ('\u{2cda}', '\u{2cda}'), ('\u{2cdc}', '\u{2cdc}'), ('\u{2cde}', '\u{2cde}'), ('\u{2ce0}', '\u{2ce0}'), ('\u{2ce2}', '\u{2ce2}'), ('\u{2ceb}', '\u{2ceb}'), ('\u{2ced}', '\u{2ced}'), ('\u{2cf2}', '\u{2cf2}'), ('\u{a640}', '\u{a640}'), ('\u{a642}', '\u{a642}'), ('\u{a644}', '\u{a644}'), ('\u{a646}', '\u{a646}'), ('\u{a648}', '\u{a648}'), ('\u{a64a}', '\u{a64a}'), ('\u{a64c}', '\u{a64c}'), ('\u{a64e}', '\u{a64e}'), ('\u{a650}', '\u{a650}'), ('\u{a652}', '\u{a652}'), ('\u{a654}', '\u{a654}'), ('\u{a656}', '\u{a656}'), ('\u{a658}', '\u{a658}'), ('\u{a65a}', '\u{a65a}'), ('\u{a65c}', '\u{a65c}'), ('\u{a65e}', '\u{a65e}'), ('\u{a660}', '\u{a660}'), ('\u{a662}', '\u{a662}'), ('\u{a664}', '\u{a664}'), ('\u{a666}', '\u{a666}'), ('\u{a668}', '\u{a668}'), ('\u{a66a}', '\u{a66a}'), ('\u{a66c}', '\u{a66c}'), ('\u{a680}', '\u{a680}'), ('\u{a682}', '\u{a682}'), ('\u{a684}', '\u{a684}'), ('\u{a686}', '\u{a686}'), ('\u{a688}', '\u{a688}'), ('\u{a68a}', '\u{a68a}'), ('\u{a68c}', '\u{a68c}'), ('\u{a68e}', '\u{a68e}'), ('\u{a690}', '\u{a690}'), ('\u{a692}', '\u{a692}'), ('\u{a694}', '\u{a694}'), ('\u{a696}', '\u{a696}'), ('\u{a698}', '\u{a698}'), ('\u{a69a}', '\u{a69a}'), ('\u{a722}', '\u{a722}'), ('\u{a724}', '\u{a724}'), ('\u{a726}', '\u{a726}'), ('\u{a728}', '\u{a728}'), ('\u{a72a}', '\u{a72a}'), ('\u{a72c}', '\u{a72c}'), ('\u{a72e}', '\u{a72e}'), ('\u{a732}', '\u{a732}'), ('\u{a734}', '\u{a734}'), ('\u{a736}', '\u{a736}'), ('\u{a738}', '\u{a738}'), ('\u{a73a}', '\u{a73a}'), ('\u{a73c}', '\u{a73c}'), ('\u{a73e}', '\u{a73e}'), ('\u{a740}', '\u{a740}'), ('\u{a742}', '\u{a742}'), ('\u{a744}', '\u{a744}'), ('\u{a746}', '\u{a746}'), ('\u{a748}', '\u{a748}'), ('\u{a74a}', '\u{a74a}'), ('\u{a74c}', '\u{a74c}'), ('\u{a74e}', '\u{a74e}'), ('\u{a750}', '\u{a750}'), ('\u{a752}', '\u{a752}'), ('\u{a754}', '\u{a754}'), ('\u{a756}', '\u{a756}'), ('\u{a758}', '\u{a758}'), ('\u{a75a}', '\u{a75a}'), ('\u{a75c}', '\u{a75c}'), ('\u{a75e}', '\u{a75e}'), ('\u{a760}', '\u{a760}'), ('\u{a762}', '\u{a762}'), ('\u{a764}', '\u{a764}'), ('\u{a766}', '\u{a766}'), ('\u{a768}', '\u{a768}'), ('\u{a76a}', '\u{a76a}'), ('\u{a76c}', '\u{a76c}'), ('\u{a76e}', '\u{a76e}'), ('\u{a779}', '\u{a779}'), ('\u{a77b}', '\u{a77b}'), ('\u{a77d}', '\u{a77e}'), ('\u{a780}', '\u{a780}'), ('\u{a782}', '\u{a782}'), ('\u{a784}', '\u{a784}'), ('\u{a786}', '\u{a786}'), ('\u{a78b}', '\u{a78b}'), ('\u{a78d}', '\u{a78d}'), ('\u{a790}', '\u{a790}'), ('\u{a792}', '\u{a792}'), ('\u{a796}', '\u{a796}'), ('\u{a798}', '\u{a798}'), ('\u{a79a}', '\u{a79a}'), ('\u{a79c}', '\u{a79c}'), ('\u{a79e}', '\u{a79e}'), ('\u{a7a0}', '\u{a7a0}'), ('\u{a7a2}', '\u{a7a2}'), ('\u{a7a4}', '\u{a7a4}'), ('\u{a7a6}', '\u{a7a6}'), ('\u{a7a8}', '\u{a7a8}'), ('\u{a7aa}', '\u{a7ad}'), ('\u{a7b0}', '\u{a7b4}'), ('\u{a7b6}', '\u{a7b6}'), ('\u{ff21}', '\u{ff3a}'), ('\u{10400}', '\u{10427}'), ('\u{10c80}', '\u{10cb2}'), ('\u{118a0}', '\u{118bf}'), ('\u{1d400}', '\u{1d419}'), ('\u{1d434}', '\u{1d44d}'), ('\u{1d468}', '\u{1d481}'), ('\u{1d49c}', '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b5}'), ('\u{1d4d0}', '\u{1d4e9}'), ('\u{1d504}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d538}', '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d56c}', '\u{1d585}'), ('\u{1d5a0}', '\u{1d5b9}'), ('\u{1d5d4}', '\u{1d5ed}'), ('\u{1d608}', '\u{1d621}'), ('\u{1d63c}', '\u{1d655}'), ('\u{1d670}', '\u{1d689}'), ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6e2}', '\u{1d6fa}'), ('\u{1d71c}', '\u{1d734}'), ('\u{1d756}', '\u{1d76e}'), ('\u{1d790}', '\u{1d7a8}'), ('\u{1d7ca}', '\u{1d7ca}'), ('\u{1f130}', '\u{1f149}'), ('\u{1f150}', '\u{1f169}'), ('\u{1f170}', '\u{1f189}') ]; pub const XID_Continue_table: &'static [(char, char)] = &[ ('\u{30}', '\u{39}'), ('\u{41}', '\u{5a}'), ('\u{5f}', '\u{5f}'), ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), ('\u{b5}', '\u{b5}'), ('\u{b7}', '\u{b7}'), ('\u{ba}', '\u{ba}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2c1}'), ('\u{2c6}', '\u{2d1}'), ('\u{2e0}', '\u{2e4}'), ('\u{2ec}', '\u{2ec}'), ('\u{2ee}', '\u{2ee}'), ('\u{300}', '\u{374}'), ('\u{376}', '\u{377}'), ('\u{37b}', '\u{37d}'), ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{38a}'), ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{3a1}'), ('\u{3a3}', '\u{3f5}'), ('\u{3f7}', '\u{481}'), ('\u{483}', '\u{487}'), ('\u{48a}', '\u{52f}'), ('\u{531}', '\u{556}'), ('\u{559}', '\u{559}'), ('\u{561}', '\u{587}'), ('\u{591}', '\u{5bd}'), ('\u{5bf}', '\u{5bf}'), ('\u{5c1}', '\u{5c2}'), ('\u{5c4}', '\u{5c5}'), ('\u{5c7}', '\u{5c7}'), ('\u{5d0}', '\u{5ea}'), ('\u{5f0}', '\u{5f2}'), ('\u{610}', '\u{61a}'), ('\u{620}', '\u{669}'), ('\u{66e}', '\u{6d3}'), ('\u{6d5}', '\u{6dc}'), ('\u{6df}', '\u{6e8}'), ('\u{6ea}', '\u{6fc}'), ('\u{6ff}', '\u{6ff}'), ('\u{710}', '\u{74a}'), ('\u{74d}', '\u{7b1}'), ('\u{7c0}', '\u{7f5}'), ('\u{7fa}', '\u{7fa}'), ('\u{800}', '\u{82d}'), ('\u{840}', '\u{85b}'), ('\u{8a0}', '\u{8b4}'), ('\u{8e3}', '\u{963}'), ('\u{966}', '\u{96f}'), ('\u{971}', '\u{983}'), ('\u{985}', '\u{98c}'), ('\u{98f}', '\u{990}'), ('\u{993}', '\u{9a8}'), ('\u{9aa}', '\u{9b0}'), ('\u{9b2}', '\u{9b2}'), ('\u{9b6}', '\u{9b9}'), ('\u{9bc}', '\u{9c4}'), ('\u{9c7}', '\u{9c8}'), ('\u{9cb}', '\u{9ce}'), ('\u{9d7}', '\u{9d7}'), ('\u{9dc}', '\u{9dd}'), ('\u{9df}', '\u{9e3}'), ('\u{9e6}', '\u{9f1}'), ('\u{a01}', '\u{a03}'), ('\u{a05}', '\u{a0a}'), ('\u{a0f}', '\u{a10}'), ('\u{a13}', '\u{a28}'), ('\u{a2a}', '\u{a30}'), ('\u{a32}', '\u{a33}'), ('\u{a35}', '\u{a36}'), ('\u{a38}', '\u{a39}'), ('\u{a3c}', '\u{a3c}'), ('\u{a3e}', '\u{a42}'), ('\u{a47}', '\u{a48}'), ('\u{a4b}', '\u{a4d}'), ('\u{a51}', '\u{a51}'), ('\u{a59}', '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), ('\u{a66}', '\u{a75}'), ('\u{a81}', '\u{a83}'), ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), ('\u{a93}', '\u{aa8}'), ('\u{aaa}', '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), ('\u{ab5}', '\u{ab9}'), ('\u{abc}', '\u{ac5}'), ('\u{ac7}', '\u{ac9}'), ('\u{acb}', '\u{acd}'), ('\u{ad0}', '\u{ad0}'), ('\u{ae0}', '\u{ae3}'), ('\u{ae6}', '\u{aef}'), ('\u{af9}', '\u{af9}'), ('\u{b01}', '\u{b03}'), ('\u{b05}', '\u{b0c}'), ('\u{b0f}', '\u{b10}'), ('\u{b13}', '\u{b28}'), ('\u{b2a}', '\u{b30}'), ('\u{b32}', '\u{b33}'), ('\u{b35}', '\u{b39}'), ('\u{b3c}', '\u{b44}'), ('\u{b47}', '\u{b48}'), ('\u{b4b}', '\u{b4d}'), ('\u{b56}', '\u{b57}'), ('\u{b5c}', '\u{b5d}'), ('\u{b5f}', '\u{b63}'), ('\u{b66}', '\u{b6f}'), ('\u{b71}', '\u{b71}'), ('\u{b82}', '\u{b83}'), ('\u{b85}', '\u{b8a}'), ('\u{b8e}', '\u{b90}'), ('\u{b92}', '\u{b95}'), ('\u{b99}', '\u{b9a}'), ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', '\u{b9f}'), ('\u{ba3}', '\u{ba4}'), ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), ('\u{bbe}', '\u{bc2}'), ('\u{bc6}', '\u{bc8}'), ('\u{bca}', '\u{bcd}'), ('\u{bd0}', '\u{bd0}'), ('\u{bd7}', '\u{bd7}'), ('\u{be6}', '\u{bef}'), ('\u{c00}', '\u{c03}'), ('\u{c05}', '\u{c0c}'), ('\u{c0e}', '\u{c10}'), ('\u{c12}', '\u{c28}'), ('\u{c2a}', '\u{c39}'), ('\u{c3d}', '\u{c44}'), ('\u{c46}', '\u{c48}'), ('\u{c4a}', '\u{c4d}'), ('\u{c55}', '\u{c56}'), ('\u{c58}', '\u{c5a}'), ('\u{c60}', '\u{c63}'), ('\u{c66}', '\u{c6f}'), ('\u{c81}', '\u{c83}'), ('\u{c85}', '\u{c8c}'), ('\u{c8e}', '\u{c90}'), ('\u{c92}', '\u{ca8}'), ('\u{caa}', '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), ('\u{cbc}', '\u{cc4}'), ('\u{cc6}', '\u{cc8}'), ('\u{cca}', '\u{ccd}'), ('\u{cd5}', '\u{cd6}'), ('\u{cde}', '\u{cde}'), ('\u{ce0}', '\u{ce3}'), ('\u{ce6}', '\u{cef}'), ('\u{cf1}', '\u{cf2}'), ('\u{d01}', '\u{d03}'), ('\u{d05}', '\u{d0c}'), ('\u{d0e}', '\u{d10}'), ('\u{d12}', '\u{d3a}'), ('\u{d3d}', '\u{d44}'), ('\u{d46}', '\u{d48}'), ('\u{d4a}', '\u{d4e}'), ('\u{d57}', '\u{d57}'), ('\u{d5f}', '\u{d63}'), ('\u{d66}', '\u{d6f}'), ('\u{d7a}', '\u{d7f}'), ('\u{d82}', '\u{d83}'), ('\u{d85}', '\u{d96}'), ('\u{d9a}', '\u{db1}'), ('\u{db3}', '\u{dbb}'), ('\u{dbd}', '\u{dbd}'), ('\u{dc0}', '\u{dc6}'), ('\u{dca}', '\u{dca}'), ('\u{dcf}', '\u{dd4}'), ('\u{dd6}', '\u{dd6}'), ('\u{dd8}', '\u{ddf}'), ('\u{de6}', '\u{def}'), ('\u{df2}', '\u{df3}'), ('\u{e01}', '\u{e3a}'), ('\u{e40}', '\u{e4e}'), ('\u{e50}', '\u{e59}'), ('\u{e81}', '\u{e82}'), ('\u{e84}', '\u{e84}'), ('\u{e87}', '\u{e88}'), ('\u{e8a}', '\u{e8a}'), ('\u{e8d}', '\u{e8d}'), ('\u{e94}', '\u{e97}'), ('\u{e99}', '\u{e9f}'), ('\u{ea1}', '\u{ea3}'), ('\u{ea5}', '\u{ea5}'), ('\u{ea7}', '\u{ea7}'), ('\u{eaa}', '\u{eab}'), ('\u{ead}', '\u{eb9}'), ('\u{ebb}', '\u{ebd}'), ('\u{ec0}', '\u{ec4}'), ('\u{ec6}', '\u{ec6}'), ('\u{ec8}', '\u{ecd}'), ('\u{ed0}', '\u{ed9}'), ('\u{edc}', '\u{edf}'), ('\u{f00}', '\u{f00}'), ('\u{f18}', '\u{f19}'), ('\u{f20}', '\u{f29}'), ('\u{f35}', '\u{f35}'), ('\u{f37}', '\u{f37}'), ('\u{f39}', '\u{f39}'), ('\u{f3e}', '\u{f47}'), ('\u{f49}', '\u{f6c}'), ('\u{f71}', '\u{f84}'), ('\u{f86}', '\u{f97}'), ('\u{f99}', '\u{fbc}'), ('\u{fc6}', '\u{fc6}'), ('\u{1000}', '\u{1049}'), ('\u{1050}', '\u{109d}'), ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', '\u{10cd}'), ('\u{10d0}', '\u{10fa}'), ('\u{10fc}', '\u{1248}'), ('\u{124a}', '\u{124d}'), ('\u{1250}', '\u{1256}'), ('\u{1258}', '\u{1258}'), ('\u{125a}', '\u{125d}'), ('\u{1260}', '\u{1288}'), ('\u{128a}', '\u{128d}'), ('\u{1290}', '\u{12b0}'), ('\u{12b2}', '\u{12b5}'), ('\u{12b8}', '\u{12be}'), ('\u{12c0}', '\u{12c0}'), ('\u{12c2}', '\u{12c5}'), ('\u{12c8}', '\u{12d6}'), ('\u{12d8}', '\u{1310}'), ('\u{1312}', '\u{1315}'), ('\u{1318}', '\u{135a}'), ('\u{135d}', '\u{135f}'), ('\u{1369}', '\u{1371}'), ('\u{1380}', '\u{138f}'), ('\u{13a0}', '\u{13f5}'), ('\u{13f8}', '\u{13fd}'), ('\u{1401}', '\u{166c}'), ('\u{166f}', '\u{167f}'), ('\u{1681}', '\u{169a}'), ('\u{16a0}', '\u{16ea}'), ('\u{16ee}', '\u{16f8}'), ('\u{1700}', '\u{170c}'), ('\u{170e}', '\u{1714}'), ('\u{1720}', '\u{1734}'), ('\u{1740}', '\u{1753}'), ('\u{1760}', '\u{176c}'), ('\u{176e}', '\u{1770}'), ('\u{1772}', '\u{1773}'), ('\u{1780}', '\u{17d3}'), ('\u{17d7}', '\u{17d7}'), ('\u{17dc}', '\u{17dd}'), ('\u{17e0}', '\u{17e9}'), ('\u{180b}', '\u{180d}'), ('\u{1810}', '\u{1819}'), ('\u{1820}', '\u{1877}'), ('\u{1880}', '\u{18aa}'), ('\u{18b0}', '\u{18f5}'), ('\u{1900}', '\u{191e}'), ('\u{1920}', '\u{192b}'), ('\u{1930}', '\u{193b}'), ('\u{1946}', '\u{196d}'), ('\u{1970}', '\u{1974}'), ('\u{1980}', '\u{19ab}'), ('\u{19b0}', '\u{19c9}'), ('\u{19d0}', '\u{19da}'), ('\u{1a00}', '\u{1a1b}'), ('\u{1a20}', '\u{1a5e}'), ('\u{1a60}', '\u{1a7c}'), ('\u{1a7f}', '\u{1a89}'), ('\u{1a90}', '\u{1a99}'), ('\u{1aa7}', '\u{1aa7}'), ('\u{1ab0}', '\u{1abd}'), ('\u{1b00}', '\u{1b4b}'), ('\u{1b50}', '\u{1b59}'), ('\u{1b6b}', '\u{1b73}'), ('\u{1b80}', '\u{1bf3}'), ('\u{1c00}', '\u{1c37}'), ('\u{1c40}', '\u{1c49}'), ('\u{1c4d}', '\u{1c7d}'), ('\u{1cd0}', '\u{1cd2}'), ('\u{1cd4}', '\u{1cf6}'), ('\u{1cf8}', '\u{1cf9}'), ('\u{1d00}', '\u{1df5}'), ('\u{1dfc}', '\u{1f15}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', '\u{1f45}'), ('\u{1f48}', '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f59}', '\u{1f59}'), ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}', '\u{1fb4}'), ('\u{1fb6}', '\u{1fbc}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'), ('\u{1fc6}', '\u{1fcc}'), ('\u{1fd0}', '\u{1fd3}'), ('\u{1fd6}', '\u{1fdb}'), ('\u{1fe0}', '\u{1fec}'), ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}', '\u{1ffc}'), ('\u{203f}', '\u{2040}'), ('\u{2054}', '\u{2054}'), ('\u{2071}', '\u{2071}'), ('\u{207f}', '\u{207f}'), ('\u{2090}', '\u{209c}'), ('\u{20d0}', '\u{20dc}'), ('\u{20e1}', '\u{20e1}'), ('\u{20e5}', '\u{20f0}'), ('\u{2102}', '\u{2102}'), ('\u{2107}', '\u{2107}'), ('\u{210a}', '\u{2113}'), ('\u{2115}', '\u{2115}'), ('\u{2118}', '\u{211d}'), ('\u{2124}', '\u{2124}'), ('\u{2126}', '\u{2126}'), ('\u{2128}', '\u{2128}'), ('\u{212a}', '\u{2139}'), ('\u{213c}', '\u{213f}'), ('\u{2145}', '\u{2149}'), ('\u{214e}', '\u{214e}'), ('\u{2160}', '\u{2188}'), ('\u{2c00}', '\u{2c2e}'), ('\u{2c30}', '\u{2c5e}'), ('\u{2c60}', '\u{2ce4}'), ('\u{2ceb}', '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'), ('\u{2d30}', '\u{2d67}'), ('\u{2d6f}', '\u{2d6f}'), ('\u{2d7f}', '\u{2d96}'), ('\u{2da0}', '\u{2da6}'), ('\u{2da8}', '\u{2dae}'), ('\u{2db0}', '\u{2db6}'), ('\u{2db8}', '\u{2dbe}'), ('\u{2dc0}', '\u{2dc6}'), ('\u{2dc8}', '\u{2dce}'), ('\u{2dd0}', '\u{2dd6}'), ('\u{2dd8}', '\u{2dde}'), ('\u{2de0}', '\u{2dff}'), ('\u{3005}', '\u{3007}'), ('\u{3021}', '\u{302f}'), ('\u{3031}', '\u{3035}'), ('\u{3038}', '\u{303c}'), ('\u{3041}', '\u{3096}'), ('\u{3099}', '\u{309a}'), ('\u{309d}', '\u{309f}'), ('\u{30a1}', '\u{30fa}'), ('\u{30fc}', '\u{30ff}'), ('\u{3105}', '\u{312d}'), ('\u{3131}', '\u{318e}'), ('\u{31a0}', '\u{31ba}'), ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{4db5}'), ('\u{4e00}', '\u{9fd5}'), ('\u{a000}', '\u{a48c}'), ('\u{a4d0}', '\u{a4fd}'), ('\u{a500}', '\u{a60c}'), ('\u{a610}', '\u{a62b}'), ('\u{a640}', '\u{a66f}'), ('\u{a674}', '\u{a67d}'), ('\u{a67f}', '\u{a6f1}'), ('\u{a717}', '\u{a71f}'), ('\u{a722}', '\u{a788}'), ('\u{a78b}', '\u{a7ad}'), ('\u{a7b0}', '\u{a7b7}'), ('\u{a7f7}', '\u{a827}'), ('\u{a840}', '\u{a873}'), ('\u{a880}', '\u{a8c4}'), ('\u{a8d0}', '\u{a8d9}'), ('\u{a8e0}', '\u{a8f7}'), ('\u{a8fb}', '\u{a8fb}'), ('\u{a8fd}', '\u{a8fd}'), ('\u{a900}', '\u{a92d}'), ('\u{a930}', '\u{a953}'), ('\u{a960}', '\u{a97c}'), ('\u{a980}', '\u{a9c0}'), ('\u{a9cf}', '\u{a9d9}'), ('\u{a9e0}', '\u{a9fe}'), ('\u{aa00}', '\u{aa36}'), ('\u{aa40}', '\u{aa4d}'), ('\u{aa50}', '\u{aa59}'), ('\u{aa60}', '\u{aa76}'), ('\u{aa7a}', '\u{aac2}'), ('\u{aadb}', '\u{aadd}'), ('\u{aae0}', '\u{aaef}'), ('\u{aaf2}', '\u{aaf6}'), ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab5c}', '\u{ab65}'), ('\u{ab70}', '\u{abea}'), ('\u{abec}', '\u{abed}'), ('\u{abf0}', '\u{abf9}'), ('\u{ac00}', '\u{d7a3}'), ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', '\u{fa6d}'), ('\u{fa70}', '\u{fad9}'), ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{fb1d}', '\u{fb28}'), ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), ('\u{fb46}', '\u{fbb1}'), ('\u{fbd3}', '\u{fc5d}'), ('\u{fc64}', '\u{fd3d}'), ('\u{fd50}', '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}', '\u{fdf9}'), ('\u{fe00}', '\u{fe0f}'), ('\u{fe20}', '\u{fe2f}'), ('\u{fe33}', '\u{fe34}'), ('\u{fe4d}', '\u{fe4f}'), ('\u{fe71}', '\u{fe71}'), ('\u{fe73}', '\u{fe73}'), ('\u{fe77}', '\u{fe77}'), ('\u{fe79}', '\u{fe79}'), ('\u{fe7b}', '\u{fe7b}'), ('\u{fe7d}', '\u{fe7d}'), ('\u{fe7f}', '\u{fefc}'), ('\u{ff10}', '\u{ff19}'), ('\u{ff21}', '\u{ff3a}'), ('\u{ff3f}', '\u{ff3f}'), ('\u{ff41}', '\u{ff5a}'), ('\u{ff66}', '\u{ffbe}'), ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'), ('\u{10000}', '\u{1000b}'), ('\u{1000d}', '\u{10026}'), ('\u{10028}', '\u{1003a}'), ('\u{1003c}', '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'), ('\u{10080}', '\u{100fa}'), ('\u{10140}', '\u{10174}'), ('\u{101fd}', '\u{101fd}'), ('\u{10280}', '\u{1029c}'), ('\u{102a0}', '\u{102d0}'), ('\u{102e0}', '\u{102e0}'), ('\u{10300}', '\u{1031f}'), ('\u{10330}', '\u{1034a}'), ('\u{10350}', '\u{1037a}'), ('\u{10380}', '\u{1039d}'), ('\u{103a0}', '\u{103c3}'), ('\u{103c8}', '\u{103cf}'), ('\u{103d1}', '\u{103d5}'), ('\u{10400}', '\u{1049d}'), ('\u{104a0}', '\u{104a9}'), ('\u{10500}', '\u{10527}'), ('\u{10530}', '\u{10563}'), ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), ('\u{10760}', '\u{10767}'), ('\u{10800}', '\u{10805}'), ('\u{10808}', '\u{10808}'), ('\u{1080a}', '\u{10835}'), ('\u{10837}', '\u{10838}'), ('\u{1083c}', '\u{1083c}'), ('\u{1083f}', '\u{10855}'), ('\u{10860}', '\u{10876}'), ('\u{10880}', '\u{1089e}'), ('\u{108e0}', '\u{108f2}'), ('\u{108f4}', '\u{108f5}'), ('\u{10900}', '\u{10915}'), ('\u{10920}', '\u{10939}'), ('\u{10980}', '\u{109b7}'), ('\u{109be}', '\u{109bf}'), ('\u{10a00}', '\u{10a03}'), ('\u{10a05}', '\u{10a06}'), ('\u{10a0c}', '\u{10a13}'), ('\u{10a15}', '\u{10a17}'), ('\u{10a19}', '\u{10a33}'), ('\u{10a38}', '\u{10a3a}'), ('\u{10a3f}', '\u{10a3f}'), ('\u{10a60}', '\u{10a7c}'), ('\u{10a80}', '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'), ('\u{10ac9}', '\u{10ae6}'), ('\u{10b00}', '\u{10b35}'), ('\u{10b40}', '\u{10b55}'), ('\u{10b60}', '\u{10b72}'), ('\u{10b80}', '\u{10b91}'), ('\u{10c00}', '\u{10c48}'), ('\u{10c80}', '\u{10cb2}'), ('\u{10cc0}', '\u{10cf2}'), ('\u{11000}', '\u{11046}'), ('\u{11066}', '\u{1106f}'), ('\u{1107f}', '\u{110ba}'), ('\u{110d0}', '\u{110e8}'), ('\u{110f0}', '\u{110f9}'), ('\u{11100}', '\u{11134}'), ('\u{11136}', '\u{1113f}'), ('\u{11150}', '\u{11173}'), ('\u{11176}', '\u{11176}'), ('\u{11180}', '\u{111c4}'), ('\u{111ca}', '\u{111cc}'), ('\u{111d0}', '\u{111da}'), ('\u{111dc}', '\u{111dc}'), ('\u{11200}', '\u{11211}'), ('\u{11213}', '\u{11237}'), ('\u{11280}', '\u{11286}'), ('\u{11288}', '\u{11288}'), ('\u{1128a}', '\u{1128d}'), ('\u{1128f}', '\u{1129d}'), ('\u{1129f}', '\u{112a8}'), ('\u{112b0}', '\u{112ea}'), ('\u{112f0}', '\u{112f9}'), ('\u{11300}', '\u{11303}'), ('\u{11305}', '\u{1130c}'), ('\u{1130f}', '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'), ('\u{11332}', '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133c}', '\u{11344}'), ('\u{11347}', '\u{11348}'), ('\u{1134b}', '\u{1134d}'), ('\u{11350}', '\u{11350}'), ('\u{11357}', '\u{11357}'), ('\u{1135d}', '\u{11363}'), ('\u{11366}', '\u{1136c}'), ('\u{11370}', '\u{11374}'), ('\u{11480}', '\u{114c5}'), ('\u{114c7}', '\u{114c7}'), ('\u{114d0}', '\u{114d9}'), ('\u{11580}', '\u{115b5}'), ('\u{115b8}', '\u{115c0}'), ('\u{115d8}', '\u{115dd}'), ('\u{11600}', '\u{11640}'), ('\u{11644}', '\u{11644}'), ('\u{11650}', '\u{11659}'), ('\u{11680}', '\u{116b7}'), ('\u{116c0}', '\u{116c9}'), ('\u{11700}', '\u{11719}'), ('\u{1171d}', '\u{1172b}'), ('\u{11730}', '\u{11739}'), ('\u{118a0}', '\u{118e9}'), ('\u{118ff}', '\u{118ff}'), ('\u{11ac0}', '\u{11af8}'), ('\u{12000}', '\u{12399}'), ('\u{12400}', '\u{1246e}'), ('\u{12480}', '\u{12543}'), ('\u{13000}', '\u{1342e}'), ('\u{14400}', '\u{14646}'), ('\u{16800}', '\u{16a38}'), ('\u{16a40}', '\u{16a5e}'), ('\u{16a60}', '\u{16a69}'), ('\u{16ad0}', '\u{16aed}'), ('\u{16af0}', '\u{16af4}'), ('\u{16b00}', '\u{16b36}'), ('\u{16b40}', '\u{16b43}'), ('\u{16b50}', '\u{16b59}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}'), ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f7e}'), ('\u{16f8f}', '\u{16f9f}'), ('\u{1b000}', '\u{1b001}'), ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}', '\u{1bc99}'), ('\u{1bc9d}', '\u{1bc9e}'), ('\u{1d165}', '\u{1d169}'), ('\u{1d16d}', '\u{1d172}'), ('\u{1d17b}', '\u{1d182}'), ('\u{1d185}', '\u{1d18b}'), ('\u{1d1aa}', '\u{1d1ad}'), ('\u{1d242}', '\u{1d244}'), ('\u{1d400}', '\u{1d454}'), ('\u{1d456}', '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}', '\u{1d6a5}'), ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}', '\u{1d6fa}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', '\u{1d734}'), ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d76e}'), ('\u{1d770}', '\u{1d788}'), ('\u{1d78a}', '\u{1d7a8}'), ('\u{1d7aa}', '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7cb}'), ('\u{1d7ce}', '\u{1d7ff}'), ('\u{1da00}', '\u{1da36}'), ('\u{1da3b}', '\u{1da6c}'), ('\u{1da75}', '\u{1da75}'), ('\u{1da84}', '\u{1da84}'), ('\u{1da9b}', '\u{1da9f}'), ('\u{1daa1}', '\u{1daaf}'), ('\u{1e800}', '\u{1e8c4}'), ('\u{1e8d0}', '\u{1e8d6}'), ('\u{1ee00}', '\u{1ee03}'), ('\u{1ee05}', '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', '\u{1ee47}'), ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}', '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), ('\u{1ee57}', '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', '\u{1ee77}'), ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}', '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), ('\u{1eea5}', '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}', '\u{2b734}'), ('\u{2b740}', '\u{2b81d}'), ('\u{2b820}', '\u{2cea1}'), ('\u{2f800}', '\u{2fa1d}'), ('\u{e0100}', '\u{e01ef}') ]; pub const XID_Start_table: &'static [(char, char)] = &[ ('\u{41}', '\u{5a}'), ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), ('\u{b5}', '\u{b5}'), ('\u{ba}', '\u{ba}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2c1}'), ('\u{2c6}', '\u{2d1}'), ('\u{2e0}', '\u{2e4}'), ('\u{2ec}', '\u{2ec}'), ('\u{2ee}', '\u{2ee}'), ('\u{370}', '\u{374}'), ('\u{376}', '\u{377}'), ('\u{37b}', '\u{37d}'), ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{386}'), ('\u{388}', '\u{38a}'), ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{3a1}'), ('\u{3a3}', '\u{3f5}'), ('\u{3f7}', '\u{481}'), ('\u{48a}', '\u{52f}'), ('\u{531}', '\u{556}'), ('\u{559}', '\u{559}'), ('\u{561}', '\u{587}'), ('\u{5d0}', '\u{5ea}'), ('\u{5f0}', '\u{5f2}'), ('\u{620}', '\u{64a}'), ('\u{66e}', '\u{66f}'), ('\u{671}', '\u{6d3}'), ('\u{6d5}', '\u{6d5}'), ('\u{6e5}', '\u{6e6}'), ('\u{6ee}', '\u{6ef}'), ('\u{6fa}', '\u{6fc}'), ('\u{6ff}', '\u{6ff}'), ('\u{710}', '\u{710}'), ('\u{712}', '\u{72f}'), ('\u{74d}', '\u{7a5}'), ('\u{7b1}', '\u{7b1}'), ('\u{7ca}', '\u{7ea}'), ('\u{7f4}', '\u{7f5}'), ('\u{7fa}', '\u{7fa}'), ('\u{800}', '\u{815}'), ('\u{81a}', '\u{81a}'), ('\u{824}', '\u{824}'), ('\u{828}', '\u{828}'), ('\u{840}', '\u{858}'), ('\u{8a0}', '\u{8b4}'), ('\u{904}', '\u{939}'), ('\u{93d}', '\u{93d}'), ('\u{950}', '\u{950}'), ('\u{958}', '\u{961}'), ('\u{971}', '\u{980}'), ('\u{985}', '\u{98c}'), ('\u{98f}', '\u{990}'), ('\u{993}', '\u{9a8}'), ('\u{9aa}', '\u{9b0}'), ('\u{9b2}', '\u{9b2}'), ('\u{9b6}', '\u{9b9}'), ('\u{9bd}', '\u{9bd}'), ('\u{9ce}', '\u{9ce}'), ('\u{9dc}', '\u{9dd}'), ('\u{9df}', '\u{9e1}'), ('\u{9f0}', '\u{9f1}'), ('\u{a05}', '\u{a0a}'), ('\u{a0f}', '\u{a10}'), ('\u{a13}', '\u{a28}'), ('\u{a2a}', '\u{a30}'), ('\u{a32}', '\u{a33}'), ('\u{a35}', '\u{a36}'), ('\u{a38}', '\u{a39}'), ('\u{a59}', '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), ('\u{a72}', '\u{a74}'), ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), ('\u{a93}', '\u{aa8}'), ('\u{aaa}', '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), ('\u{ab5}', '\u{ab9}'), ('\u{abd}', '\u{abd}'), ('\u{ad0}', '\u{ad0}'), ('\u{ae0}', '\u{ae1}'), ('\u{af9}', '\u{af9}'), ('\u{b05}', '\u{b0c}'), ('\u{b0f}', '\u{b10}'), ('\u{b13}', '\u{b28}'), ('\u{b2a}', '\u{b30}'), ('\u{b32}', '\u{b33}'), ('\u{b35}', '\u{b39}'), ('\u{b3d}', '\u{b3d}'), ('\u{b5c}', '\u{b5d}'), ('\u{b5f}', '\u{b61}'), ('\u{b71}', '\u{b71}'), ('\u{b83}', '\u{b83}'), ('\u{b85}', '\u{b8a}'), ('\u{b8e}', '\u{b90}'), ('\u{b92}', '\u{b95}'), ('\u{b99}', '\u{b9a}'), ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', '\u{b9f}'), ('\u{ba3}', '\u{ba4}'), ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), ('\u{bd0}', '\u{bd0}'), ('\u{c05}', '\u{c0c}'), ('\u{c0e}', '\u{c10}'), ('\u{c12}', '\u{c28}'), ('\u{c2a}', '\u{c39}'), ('\u{c3d}', '\u{c3d}'), ('\u{c58}', '\u{c5a}'), ('\u{c60}', '\u{c61}'), ('\u{c85}', '\u{c8c}'), ('\u{c8e}', '\u{c90}'), ('\u{c92}', '\u{ca8}'), ('\u{caa}', '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), ('\u{cbd}', '\u{cbd}'), ('\u{cde}', '\u{cde}'), ('\u{ce0}', '\u{ce1}'), ('\u{cf1}', '\u{cf2}'), ('\u{d05}', '\u{d0c}'), ('\u{d0e}', '\u{d10}'), ('\u{d12}', '\u{d3a}'), ('\u{d3d}', '\u{d3d}'), ('\u{d4e}', '\u{d4e}'), ('\u{d5f}', '\u{d61}'), ('\u{d7a}', '\u{d7f}'), ('\u{d85}', '\u{d96}'), ('\u{d9a}', '\u{db1}'), ('\u{db3}', '\u{dbb}'), ('\u{dbd}', '\u{dbd}'), ('\u{dc0}', '\u{dc6}'), ('\u{e01}', '\u{e30}'), ('\u{e32}', '\u{e32}'), ('\u{e40}', '\u{e46}'), ('\u{e81}', '\u{e82}'), ('\u{e84}', '\u{e84}'), ('\u{e87}', '\u{e88}'), ('\u{e8a}', '\u{e8a}'), ('\u{e8d}', '\u{e8d}'), ('\u{e94}', '\u{e97}'), ('\u{e99}', '\u{e9f}'), ('\u{ea1}', '\u{ea3}'), ('\u{ea5}', '\u{ea5}'), ('\u{ea7}', '\u{ea7}'), ('\u{eaa}', '\u{eab}'), ('\u{ead}', '\u{eb0}'), ('\u{eb2}', '\u{eb2}'), ('\u{ebd}', '\u{ebd}'), ('\u{ec0}', '\u{ec4}'), ('\u{ec6}', '\u{ec6}'), ('\u{edc}', '\u{edf}'), ('\u{f00}', '\u{f00}'), ('\u{f40}', '\u{f47}'), ('\u{f49}', '\u{f6c}'), ('\u{f88}', '\u{f8c}'), ('\u{1000}', '\u{102a}'), ('\u{103f}', '\u{103f}'), ('\u{1050}', '\u{1055}'), ('\u{105a}', '\u{105d}'), ('\u{1061}', '\u{1061}'), ('\u{1065}', '\u{1066}'), ('\u{106e}', '\u{1070}'), ('\u{1075}', '\u{1081}'), ('\u{108e}', '\u{108e}'), ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', '\u{10cd}'), ('\u{10d0}', '\u{10fa}'), ('\u{10fc}', '\u{1248}'), ('\u{124a}', '\u{124d}'), ('\u{1250}', '\u{1256}'), ('\u{1258}', '\u{1258}'), ('\u{125a}', '\u{125d}'), ('\u{1260}', '\u{1288}'), ('\u{128a}', '\u{128d}'), ('\u{1290}', '\u{12b0}'), ('\u{12b2}', '\u{12b5}'), ('\u{12b8}', '\u{12be}'), ('\u{12c0}', '\u{12c0}'), ('\u{12c2}', '\u{12c5}'), ('\u{12c8}', '\u{12d6}'), ('\u{12d8}', '\u{1310}'), ('\u{1312}', '\u{1315}'), ('\u{1318}', '\u{135a}'), ('\u{1380}', '\u{138f}'), ('\u{13a0}', '\u{13f5}'), ('\u{13f8}', '\u{13fd}'), ('\u{1401}', '\u{166c}'), ('\u{166f}', '\u{167f}'), ('\u{1681}', '\u{169a}'), ('\u{16a0}', '\u{16ea}'), ('\u{16ee}', '\u{16f8}'), ('\u{1700}', '\u{170c}'), ('\u{170e}', '\u{1711}'), ('\u{1720}', '\u{1731}'), ('\u{1740}', '\u{1751}'), ('\u{1760}', '\u{176c}'), ('\u{176e}', '\u{1770}'), ('\u{1780}', '\u{17b3}'), ('\u{17d7}', '\u{17d7}'), ('\u{17dc}', '\u{17dc}'), ('\u{1820}', '\u{1877}'), ('\u{1880}', '\u{18a8}'), ('\u{18aa}', '\u{18aa}'), ('\u{18b0}', '\u{18f5}'), ('\u{1900}', '\u{191e}'), ('\u{1950}', '\u{196d}'), ('\u{1970}', '\u{1974}'), ('\u{1980}', '\u{19ab}'), ('\u{19b0}', '\u{19c9}'), ('\u{1a00}', '\u{1a16}'), ('\u{1a20}', '\u{1a54}'), ('\u{1aa7}', '\u{1aa7}'), ('\u{1b05}', '\u{1b33}'), ('\u{1b45}', '\u{1b4b}'), ('\u{1b83}', '\u{1ba0}'), ('\u{1bae}', '\u{1baf}'), ('\u{1bba}', '\u{1be5}'), ('\u{1c00}', '\u{1c23}'), ('\u{1c4d}', '\u{1c4f}'), ('\u{1c5a}', '\u{1c7d}'), ('\u{1ce9}', '\u{1cec}'), ('\u{1cee}', '\u{1cf1}'), ('\u{1cf5}', '\u{1cf6}'), ('\u{1d00}', '\u{1dbf}'), ('\u{1e00}', '\u{1f15}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', '\u{1f45}'), ('\u{1f48}', '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f59}', '\u{1f59}'), ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}', '\u{1fb4}'), ('\u{1fb6}', '\u{1fbc}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'), ('\u{1fc6}', '\u{1fcc}'), ('\u{1fd0}', '\u{1fd3}'), ('\u{1fd6}', '\u{1fdb}'), ('\u{1fe0}', '\u{1fec}'), ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}', '\u{1ffc}'), ('\u{2071}', '\u{2071}'), ('\u{207f}', '\u{207f}'), ('\u{2090}', '\u{209c}'), ('\u{2102}', '\u{2102}'), ('\u{2107}', '\u{2107}'), ('\u{210a}', '\u{2113}'), ('\u{2115}', '\u{2115}'), ('\u{2118}', '\u{211d}'), ('\u{2124}', '\u{2124}'), ('\u{2126}', '\u{2126}'), ('\u{2128}', '\u{2128}'), ('\u{212a}', '\u{2139}'), ('\u{213c}', '\u{213f}'), ('\u{2145}', '\u{2149}'), ('\u{214e}', '\u{214e}'), ('\u{2160}', '\u{2188}'), ('\u{2c00}', '\u{2c2e}'), ('\u{2c30}', '\u{2c5e}'), ('\u{2c60}', '\u{2ce4}'), ('\u{2ceb}', '\u{2cee}'), ('\u{2cf2}', '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'), ('\u{2d30}', '\u{2d67}'), ('\u{2d6f}', '\u{2d6f}'), ('\u{2d80}', '\u{2d96}'), ('\u{2da0}', '\u{2da6}'), ('\u{2da8}', '\u{2dae}'), ('\u{2db0}', '\u{2db6}'), ('\u{2db8}', '\u{2dbe}'), ('\u{2dc0}', '\u{2dc6}'), ('\u{2dc8}', '\u{2dce}'), ('\u{2dd0}', '\u{2dd6}'), ('\u{2dd8}', '\u{2dde}'), ('\u{3005}', '\u{3007}'), ('\u{3021}', '\u{3029}'), ('\u{3031}', '\u{3035}'), ('\u{3038}', '\u{303c}'), ('\u{3041}', '\u{3096}'), ('\u{309d}', '\u{309f}'), ('\u{30a1}', '\u{30fa}'), ('\u{30fc}', '\u{30ff}'), ('\u{3105}', '\u{312d}'), ('\u{3131}', '\u{318e}'), ('\u{31a0}', '\u{31ba}'), ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{4db5}'), ('\u{4e00}', '\u{9fd5}'), ('\u{a000}', '\u{a48c}'), ('\u{a4d0}', '\u{a4fd}'), ('\u{a500}', '\u{a60c}'), ('\u{a610}', '\u{a61f}'), ('\u{a62a}', '\u{a62b}'), ('\u{a640}', '\u{a66e}'), ('\u{a67f}', '\u{a69d}'), ('\u{a6a0}', '\u{a6ef}'), ('\u{a717}', '\u{a71f}'), ('\u{a722}', '\u{a788}'), ('\u{a78b}', '\u{a7ad}'), ('\u{a7b0}', '\u{a7b7}'), ('\u{a7f7}', '\u{a801}'), ('\u{a803}', '\u{a805}'), ('\u{a807}', '\u{a80a}'), ('\u{a80c}', '\u{a822}'), ('\u{a840}', '\u{a873}'), ('\u{a882}', '\u{a8b3}'), ('\u{a8f2}', '\u{a8f7}'), ('\u{a8fb}', '\u{a8fb}'), ('\u{a8fd}', '\u{a8fd}'), ('\u{a90a}', '\u{a925}'), ('\u{a930}', '\u{a946}'), ('\u{a960}', '\u{a97c}'), ('\u{a984}', '\u{a9b2}'), ('\u{a9cf}', '\u{a9cf}'), ('\u{a9e0}', '\u{a9e4}'), ('\u{a9e6}', '\u{a9ef}'), ('\u{a9fa}', '\u{a9fe}'), ('\u{aa00}', '\u{aa28}'), ('\u{aa40}', '\u{aa42}'), ('\u{aa44}', '\u{aa4b}'), ('\u{aa60}', '\u{aa76}'), ('\u{aa7a}', '\u{aa7a}'), ('\u{aa7e}', '\u{aaaf}'), ('\u{aab1}', '\u{aab1}'), ('\u{aab5}', '\u{aab6}'), ('\u{aab9}', '\u{aabd}'), ('\u{aac0}', '\u{aac0}'), ('\u{aac2}', '\u{aac2}'), ('\u{aadb}', '\u{aadd}'), ('\u{aae0}', '\u{aaea}'), ('\u{aaf2}', '\u{aaf4}'), ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab5c}', '\u{ab65}'), ('\u{ab70}', '\u{abe2}'), ('\u{ac00}', '\u{d7a3}'), ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', '\u{fa6d}'), ('\u{fa70}', '\u{fad9}'), ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{fb1d}', '\u{fb1d}'), ('\u{fb1f}', '\u{fb28}'), ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), ('\u{fb46}', '\u{fbb1}'), ('\u{fbd3}', '\u{fc5d}'), ('\u{fc64}', '\u{fd3d}'), ('\u{fd50}', '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}', '\u{fdf9}'), ('\u{fe71}', '\u{fe71}'), ('\u{fe73}', '\u{fe73}'), ('\u{fe77}', '\u{fe77}'), ('\u{fe79}', '\u{fe79}'), ('\u{fe7b}', '\u{fe7b}'), ('\u{fe7d}', '\u{fe7d}'), ('\u{fe7f}', '\u{fefc}'), ('\u{ff21}', '\u{ff3a}'), ('\u{ff41}', '\u{ff5a}'), ('\u{ff66}', '\u{ff9d}'), ('\u{ffa0}', '\u{ffbe}'), ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'), ('\u{10000}', '\u{1000b}'), ('\u{1000d}', '\u{10026}'), ('\u{10028}', '\u{1003a}'), ('\u{1003c}', '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'), ('\u{10080}', '\u{100fa}'), ('\u{10140}', '\u{10174}'), ('\u{10280}', '\u{1029c}'), ('\u{102a0}', '\u{102d0}'), ('\u{10300}', '\u{1031f}'), ('\u{10330}', '\u{1034a}'), ('\u{10350}', '\u{10375}'), ('\u{10380}', '\u{1039d}'), ('\u{103a0}', '\u{103c3}'), ('\u{103c8}', '\u{103cf}'), ('\u{103d1}', '\u{103d5}'), ('\u{10400}', '\u{1049d}'), ('\u{10500}', '\u{10527}'), ('\u{10530}', '\u{10563}'), ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), ('\u{10760}', '\u{10767}'), ('\u{10800}', '\u{10805}'), ('\u{10808}', '\u{10808}'), ('\u{1080a}', '\u{10835}'), ('\u{10837}', '\u{10838}'), ('\u{1083c}', '\u{1083c}'), ('\u{1083f}', '\u{10855}'), ('\u{10860}', '\u{10876}'), ('\u{10880}', '\u{1089e}'), ('\u{108e0}', '\u{108f2}'), ('\u{108f4}', '\u{108f5}'), ('\u{10900}', '\u{10915}'), ('\u{10920}', '\u{10939}'), ('\u{10980}', '\u{109b7}'), ('\u{109be}', '\u{109bf}'), ('\u{10a00}', '\u{10a00}'), ('\u{10a10}', '\u{10a13}'), ('\u{10a15}', '\u{10a17}'), ('\u{10a19}', '\u{10a33}'), ('\u{10a60}', '\u{10a7c}'), ('\u{10a80}', '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'), ('\u{10ac9}', '\u{10ae4}'), ('\u{10b00}', '\u{10b35}'), ('\u{10b40}', '\u{10b55}'), ('\u{10b60}', '\u{10b72}'), ('\u{10b80}', '\u{10b91}'), ('\u{10c00}', '\u{10c48}'), ('\u{10c80}', '\u{10cb2}'), ('\u{10cc0}', '\u{10cf2}'), ('\u{11003}', '\u{11037}'), ('\u{11083}', '\u{110af}'), ('\u{110d0}', '\u{110e8}'), ('\u{11103}', '\u{11126}'), ('\u{11150}', '\u{11172}'), ('\u{11176}', '\u{11176}'), ('\u{11183}', '\u{111b2}'), ('\u{111c1}', '\u{111c4}'), ('\u{111da}', '\u{111da}'), ('\u{111dc}', '\u{111dc}'), ('\u{11200}', '\u{11211}'), ('\u{11213}', '\u{1122b}'), ('\u{11280}', '\u{11286}'), ('\u{11288}', '\u{11288}'), ('\u{1128a}', '\u{1128d}'), ('\u{1128f}', '\u{1129d}'), ('\u{1129f}', '\u{112a8}'), ('\u{112b0}', '\u{112de}'), ('\u{11305}', '\u{1130c}'), ('\u{1130f}', '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'), ('\u{11332}', '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133d}', '\u{1133d}'), ('\u{11350}', '\u{11350}'), ('\u{1135d}', '\u{11361}'), ('\u{11480}', '\u{114af}'), ('\u{114c4}', '\u{114c5}'), ('\u{114c7}', '\u{114c7}'), ('\u{11580}', '\u{115ae}'), ('\u{115d8}', '\u{115db}'), ('\u{11600}', '\u{1162f}'), ('\u{11644}', '\u{11644}'), ('\u{11680}', '\u{116aa}'), ('\u{11700}', '\u{11719}'), ('\u{118a0}', '\u{118df}'), ('\u{118ff}', '\u{118ff}'), ('\u{11ac0}', '\u{11af8}'), ('\u{12000}', '\u{12399}'), ('\u{12400}', '\u{1246e}'), ('\u{12480}', '\u{12543}'), ('\u{13000}', '\u{1342e}'), ('\u{14400}', '\u{14646}'), ('\u{16800}', '\u{16a38}'), ('\u{16a40}', '\u{16a5e}'), ('\u{16ad0}', '\u{16aed}'), ('\u{16b00}', '\u{16b2f}'), ('\u{16b40}', '\u{16b43}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}'), ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f50}'), ('\u{16f93}', '\u{16f9f}'), ('\u{1b000}', '\u{1b001}'), ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}', '\u{1bc99}'), ('\u{1d400}', '\u{1d454}'), ('\u{1d456}', '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}', '\u{1d6a5}'), ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}', '\u{1d6fa}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', '\u{1d734}'), ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d76e}'), ('\u{1d770}', '\u{1d788}'), ('\u{1d78a}', '\u{1d7a8}'), ('\u{1d7aa}', '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7cb}'), ('\u{1e800}', '\u{1e8c4}'), ('\u{1ee00}', '\u{1ee03}'), ('\u{1ee05}', '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', '\u{1ee47}'), ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}', '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), ('\u{1ee57}', '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', '\u{1ee77}'), ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}', '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), ('\u{1eea5}', '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}', '\u{2b734}'), ('\u{2b740}', '\u{2b81d}'), ('\u{2b820}', '\u{2cea1}'), ('\u{2f800}', '\u{2fa1d}') ]; } pub mod script { pub const Ahom_table: &'static [(char, char)] = &[ ('\u{11700}', '\u{11719}'), ('\u{1171d}', '\u{1172b}'), ('\u{11730}', '\u{1173f}') ]; pub const Anatolian_Hieroglyphs_table: &'static [(char, char)] = &[ ('\u{14400}', '\u{14646}') ]; pub const Arabic_table: &'static [(char, char)] = &[ ('\u{600}', '\u{604}'), ('\u{606}', '\u{60b}'), ('\u{60d}', '\u{61a}'), ('\u{61e}', '\u{61e}'), ('\u{620}', '\u{63f}'), ('\u{641}', '\u{64a}'), ('\u{656}', '\u{66f}'), ('\u{671}', '\u{6dc}'), ('\u{6de}', '\u{6ff}'), ('\u{750}', '\u{77f}'), ('\u{8a0}', '\u{8b4}'), ('\u{8e3}', '\u{8ff}'), ('\u{fb50}', '\u{fbc1}'), ('\u{fbd3}', '\u{fd3d}'), ('\u{fd50}', '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}', '\u{fdfd}'), ('\u{fe70}', '\u{fe74}'), ('\u{fe76}', '\u{fefc}'), ('\u{10e60}', '\u{10e7e}'), ('\u{1ee00}', '\u{1ee03}'), ('\u{1ee05}', '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', '\u{1ee47}'), ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}', '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), ('\u{1ee57}', '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', '\u{1ee77}'), ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}', '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), ('\u{1eea5}', '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), ('\u{1eef0}', '\u{1eef1}') ]; pub const Armenian_table: &'static [(char, char)] = &[ ('\u{531}', '\u{556}'), ('\u{559}', '\u{55f}'), ('\u{561}', '\u{587}'), ('\u{58a}', '\u{58a}'), ('\u{58d}', '\u{58f}'), ('\u{fb13}', '\u{fb17}') ]; pub const Avestan_table: &'static [(char, char)] = &[ ('\u{10b00}', '\u{10b35}'), ('\u{10b39}', '\u{10b3f}') ]; pub const Balinese_table: &'static [(char, char)] = &[ ('\u{1b00}', '\u{1b4b}'), ('\u{1b50}', '\u{1b7c}') ]; pub const Bamum_table: &'static [(char, char)] = &[ ('\u{a6a0}', '\u{a6f7}'), ('\u{16800}', '\u{16a38}') ]; pub const Bassa_Vah_table: &'static [(char, char)] = &[ ('\u{16ad0}', '\u{16aed}'), ('\u{16af0}', '\u{16af5}') ]; pub const Batak_table: &'static [(char, char)] = &[ ('\u{1bc0}', '\u{1bf3}'), ('\u{1bfc}', '\u{1bff}') ]; pub const Bengali_table: &'static [(char, char)] = &[ ('\u{980}', '\u{983}'), ('\u{985}', '\u{98c}'), ('\u{98f}', '\u{990}'), ('\u{993}', '\u{9a8}'), ('\u{9aa}', '\u{9b0}'), ('\u{9b2}', '\u{9b2}'), ('\u{9b6}', '\u{9b9}'), ('\u{9bc}', '\u{9c4}'), ('\u{9c7}', '\u{9c8}'), ('\u{9cb}', '\u{9ce}'), ('\u{9d7}', '\u{9d7}'), ('\u{9dc}', '\u{9dd}'), ('\u{9df}', '\u{9e3}'), ('\u{9e6}', '\u{9fb}') ]; pub const Bopomofo_table: &'static [(char, char)] = &[ ('\u{2ea}', '\u{2eb}'), ('\u{3105}', '\u{312d}'), ('\u{31a0}', '\u{31ba}') ]; pub const Brahmi_table: &'static [(char, char)] = &[ ('\u{11000}', '\u{1104d}'), ('\u{11052}', '\u{1106f}'), ('\u{1107f}', '\u{1107f}') ]; pub const Braille_table: &'static [(char, char)] = &[ ('\u{2800}', '\u{28ff}') ]; pub const Buginese_table: &'static [(char, char)] = &[ ('\u{1a00}', '\u{1a1b}'), ('\u{1a1e}', '\u{1a1f}') ]; pub const Buhid_table: &'static [(char, char)] = &[ ('\u{1740}', '\u{1753}') ]; pub const Canadian_Aboriginal_table: &'static [(char, char)] = &[ ('\u{1400}', '\u{167f}'), ('\u{18b0}', '\u{18f5}') ]; pub const Carian_table: &'static [(char, char)] = &[ ('\u{102a0}', '\u{102d0}') ]; pub const Caucasian_Albanian_table: &'static [(char, char)] = &[ ('\u{10530}', '\u{10563}'), ('\u{1056f}', '\u{1056f}') ]; pub const Chakma_table: &'static [(char, char)] = &[ ('\u{11100}', '\u{11134}'), ('\u{11136}', '\u{11143}') ]; pub const Cham_table: &'static [(char, char)] = &[ ('\u{aa00}', '\u{aa36}'), ('\u{aa40}', '\u{aa4d}'), ('\u{aa50}', '\u{aa59}'), ('\u{aa5c}', '\u{aa5f}') ]; pub const Cherokee_table: &'static [(char, char)] = &[ ('\u{13a0}', '\u{13f5}'), ('\u{13f8}', '\u{13fd}'), ('\u{ab70}', '\u{abbf}') ]; pub const Common_table: &'static [(char, char)] = &[ ('\u{0}', '\u{40}'), ('\u{5b}', '\u{60}'), ('\u{7b}', '\u{a9}'), ('\u{ab}', '\u{b9}'), ('\u{bb}', '\u{bf}'), ('\u{d7}', '\u{d7}'), ('\u{f7}', '\u{f7}'), ('\u{2b9}', '\u{2df}'), ('\u{2e5}', '\u{2e9}'), ('\u{2ec}', '\u{2ff}'), ('\u{374}', '\u{374}'), ('\u{37e}', '\u{37e}'), ('\u{385}', '\u{385}'), ('\u{387}', '\u{387}'), ('\u{589}', '\u{589}'), ('\u{605}', '\u{605}'), ('\u{60c}', '\u{60c}'), ('\u{61b}', '\u{61c}'), ('\u{61f}', '\u{61f}'), ('\u{640}', '\u{640}'), ('\u{6dd}', '\u{6dd}'), ('\u{964}', '\u{965}'), ('\u{e3f}', '\u{e3f}'), ('\u{fd5}', '\u{fd8}'), ('\u{10fb}', '\u{10fb}'), ('\u{16eb}', '\u{16ed}'), ('\u{1735}', '\u{1736}'), ('\u{1802}', '\u{1803}'), ('\u{1805}', '\u{1805}'), ('\u{1cd3}', '\u{1cd3}'), ('\u{1ce1}', '\u{1ce1}'), ('\u{1ce9}', '\u{1cec}'), ('\u{1cee}', '\u{1cf3}'), ('\u{1cf5}', '\u{1cf6}'), ('\u{2000}', '\u{200b}'), ('\u{200e}', '\u{2064}'), ('\u{2066}', '\u{2070}'), ('\u{2074}', '\u{207e}'), ('\u{2080}', '\u{208e}'), ('\u{20a0}', '\u{20be}'), ('\u{2100}', '\u{2125}'), ('\u{2127}', '\u{2129}'), ('\u{212c}', '\u{2131}'), ('\u{2133}', '\u{214d}'), ('\u{214f}', '\u{215f}'), ('\u{2189}', '\u{218b}'), ('\u{2190}', '\u{23fa}'), ('\u{2400}', '\u{2426}'), ('\u{2440}', '\u{244a}'), ('\u{2460}', '\u{27ff}'), ('\u{2900}', '\u{2b73}'), ('\u{2b76}', '\u{2b95}'), ('\u{2b98}', '\u{2bb9}'), ('\u{2bbd}', '\u{2bc8}'), ('\u{2bca}', '\u{2bd1}'), ('\u{2bec}', '\u{2bef}'), ('\u{2e00}', '\u{2e42}'), ('\u{2ff0}', '\u{2ffb}'), ('\u{3000}', '\u{3004}'), ('\u{3006}', '\u{3006}'), ('\u{3008}', '\u{3020}'), ('\u{3030}', '\u{3037}'), ('\u{303c}', '\u{303f}'), ('\u{309b}', '\u{309c}'), ('\u{30a0}', '\u{30a0}'), ('\u{30fb}', '\u{30fc}'), ('\u{3190}', '\u{319f}'), ('\u{31c0}', '\u{31e3}'), ('\u{3220}', '\u{325f}'), ('\u{327f}', '\u{32cf}'), ('\u{3358}', '\u{33ff}'), ('\u{4dc0}', '\u{4dff}'), ('\u{a700}', '\u{a721}'), ('\u{a788}', '\u{a78a}'), ('\u{a830}', '\u{a839}'), ('\u{a92e}', '\u{a92e}'), ('\u{a9cf}', '\u{a9cf}'), ('\u{ab5b}', '\u{ab5b}'), ('\u{fd3e}', '\u{fd3f}'), ('\u{fe10}', '\u{fe19}'), ('\u{fe30}', '\u{fe52}'), ('\u{fe54}', '\u{fe66}'), ('\u{fe68}', '\u{fe6b}'), ('\u{feff}', '\u{feff}'), ('\u{ff01}', '\u{ff20}'), ('\u{ff3b}', '\u{ff40}'), ('\u{ff5b}', '\u{ff65}'), ('\u{ff70}', '\u{ff70}'), ('\u{ff9e}', '\u{ff9f}'), ('\u{ffe0}', '\u{ffe6}'), ('\u{ffe8}', '\u{ffee}'), ('\u{fff9}', '\u{fffd}'), ('\u{10100}', '\u{10102}'), ('\u{10107}', '\u{10133}'), ('\u{10137}', '\u{1013f}'), ('\u{10190}', '\u{1019b}'), ('\u{101d0}', '\u{101fc}'), ('\u{102e1}', '\u{102fb}'), ('\u{1bca0}', '\u{1bca3}'), ('\u{1d000}', '\u{1d0f5}'), ('\u{1d100}', '\u{1d126}'), ('\u{1d129}', '\u{1d166}'), ('\u{1d16a}', '\u{1d17a}'), ('\u{1d183}', '\u{1d184}'), ('\u{1d18c}', '\u{1d1a9}'), ('\u{1d1ae}', '\u{1d1e8}'), ('\u{1d300}', '\u{1d356}'), ('\u{1d360}', '\u{1d371}'), ('\u{1d400}', '\u{1d454}'), ('\u{1d456}', '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}', '\u{1d6a5}'), ('\u{1d6a8}', '\u{1d7cb}'), ('\u{1d7ce}', '\u{1d7ff}'), ('\u{1f000}', '\u{1f02b}'), ('\u{1f030}', '\u{1f093}'), ('\u{1f0a0}', '\u{1f0ae}'), ('\u{1f0b1}', '\u{1f0bf}'), ('\u{1f0c1}', '\u{1f0cf}'), ('\u{1f0d1}', '\u{1f0f5}'), ('\u{1f100}', '\u{1f10c}'), ('\u{1f110}', '\u{1f12e}'), ('\u{1f130}', '\u{1f16b}'), ('\u{1f170}', '\u{1f19a}'), ('\u{1f1e6}', '\u{1f1ff}'), ('\u{1f201}', '\u{1f202}'), ('\u{1f210}', '\u{1f23a}'), ('\u{1f240}', '\u{1f248}'), ('\u{1f250}', '\u{1f251}'), ('\u{1f300}', '\u{1f579}'), ('\u{1f57b}', '\u{1f5a3}'), ('\u{1f5a5}', '\u{1f6d0}'), ('\u{1f6e0}', '\u{1f6ec}'), ('\u{1f6f0}', '\u{1f6f3}'), ('\u{1f700}', '\u{1f773}'), ('\u{1f780}', '\u{1f7d4}'), ('\u{1f800}', '\u{1f80b}'), ('\u{1f810}', '\u{1f847}'), ('\u{1f850}', '\u{1f859}'), ('\u{1f860}', '\u{1f887}'), ('\u{1f890}', '\u{1f8ad}'), ('\u{1f910}', '\u{1f918}'), ('\u{1f980}', '\u{1f984}'), ('\u{1f9c0}', '\u{1f9c0}'), ('\u{e0001}', '\u{e0001}'), ('\u{e0020}', '\u{e007f}') ]; pub const Coptic_table: &'static [(char, char)] = &[ ('\u{3e2}', '\u{3ef}'), ('\u{2c80}', '\u{2cf3}'), ('\u{2cf9}', '\u{2cff}') ]; pub const Cuneiform_table: &'static [(char, char)] = &[ ('\u{12000}', '\u{12399}'), ('\u{12400}', '\u{1246e}'), ('\u{12470}', '\u{12474}'), ('\u{12480}', '\u{12543}') ]; pub const Cypriot_table: &'static [(char, char)] = &[ ('\u{10800}', '\u{10805}'), ('\u{10808}', '\u{10808}'), ('\u{1080a}', '\u{10835}'), ('\u{10837}', '\u{10838}'), ('\u{1083c}', '\u{1083c}'), ('\u{1083f}', '\u{1083f}') ]; pub const Cyrillic_table: &'static [(char, char)] = &[ ('\u{400}', '\u{484}'), ('\u{487}', '\u{52f}'), ('\u{1d2b}', '\u{1d2b}'), ('\u{1d78}', '\u{1d78}'), ('\u{2de0}', '\u{2dff}'), ('\u{a640}', '\u{a69f}'), ('\u{fe2e}', '\u{fe2f}') ]; pub const Deseret_table: &'static [(char, char)] = &[ ('\u{10400}', '\u{1044f}') ]; pub const Devanagari_table: &'static [(char, char)] = &[ ('\u{900}', '\u{950}'), ('\u{953}', '\u{963}'), ('\u{966}', '\u{97f}'), ('\u{a8e0}', '\u{a8fd}') ]; pub const Duployan_table: &'static [(char, char)] = &[ ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}', '\u{1bc99}'), ('\u{1bc9c}', '\u{1bc9f}') ]; pub const Egyptian_Hieroglyphs_table: &'static [(char, char)] = &[ ('\u{13000}', '\u{1342e}') ]; pub const Elbasan_table: &'static [(char, char)] = &[ ('\u{10500}', '\u{10527}') ]; pub const Ethiopic_table: &'static [(char, char)] = &[ ('\u{1200}', '\u{1248}'), ('\u{124a}', '\u{124d}'), ('\u{1250}', '\u{1256}'), ('\u{1258}', '\u{1258}'), ('\u{125a}', '\u{125d}'), ('\u{1260}', '\u{1288}'), ('\u{128a}', '\u{128d}'), ('\u{1290}', '\u{12b0}'), ('\u{12b2}', '\u{12b5}'), ('\u{12b8}', '\u{12be}'), ('\u{12c0}', '\u{12c0}'), ('\u{12c2}', '\u{12c5}'), ('\u{12c8}', '\u{12d6}'), ('\u{12d8}', '\u{1310}'), ('\u{1312}', '\u{1315}'), ('\u{1318}', '\u{135a}'), ('\u{135d}', '\u{137c}'), ('\u{1380}', '\u{1399}'), ('\u{2d80}', '\u{2d96}'), ('\u{2da0}', '\u{2da6}'), ('\u{2da8}', '\u{2dae}'), ('\u{2db0}', '\u{2db6}'), ('\u{2db8}', '\u{2dbe}'), ('\u{2dc0}', '\u{2dc6}'), ('\u{2dc8}', '\u{2dce}'), ('\u{2dd0}', '\u{2dd6}'), ('\u{2dd8}', '\u{2dde}'), ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}') ]; pub const Georgian_table: &'static [(char, char)] = &[ ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', '\u{10cd}'), ('\u{10d0}', '\u{10fa}'), ('\u{10fc}', '\u{10ff}'), ('\u{2d00}', '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}') ]; pub const Glagolitic_table: &'static [(char, char)] = &[ ('\u{2c00}', '\u{2c2e}'), ('\u{2c30}', '\u{2c5e}') ]; pub const Gothic_table: &'static [(char, char)] = &[ ('\u{10330}', '\u{1034a}') ]; pub const Grantha_table: &'static [(char, char)] = &[ ('\u{11300}', '\u{11303}'), ('\u{11305}', '\u{1130c}'), ('\u{1130f}', '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'), ('\u{11332}', '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133c}', '\u{11344}'), ('\u{11347}', '\u{11348}'), ('\u{1134b}', '\u{1134d}'), ('\u{11350}', '\u{11350}'), ('\u{11357}', '\u{11357}'), ('\u{1135d}', '\u{11363}'), ('\u{11366}', '\u{1136c}'), ('\u{11370}', '\u{11374}') ]; pub const Greek_table: &'static [(char, char)] = &[ ('\u{370}', '\u{373}'), ('\u{375}', '\u{377}'), ('\u{37a}', '\u{37d}'), ('\u{37f}', '\u{37f}'), ('\u{384}', '\u{384}'), ('\u{386}', '\u{386}'), ('\u{388}', '\u{38a}'), ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{3a1}'), ('\u{3a3}', '\u{3e1}'), ('\u{3f0}', '\u{3ff}'), ('\u{1d26}', '\u{1d2a}'), ('\u{1d5d}', '\u{1d61}'), ('\u{1d66}', '\u{1d6a}'), ('\u{1dbf}', '\u{1dbf}'), ('\u{1f00}', '\u{1f15}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', '\u{1f45}'), ('\u{1f48}', '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f59}', '\u{1f59}'), ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}', '\u{1fb4}'), ('\u{1fb6}', '\u{1fc4}'), ('\u{1fc6}', '\u{1fd3}'), ('\u{1fd6}', '\u{1fdb}'), ('\u{1fdd}', '\u{1fef}'), ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}', '\u{1ffe}'), ('\u{2126}', '\u{2126}'), ('\u{ab65}', '\u{ab65}'), ('\u{10140}', '\u{1018c}'), ('\u{101a0}', '\u{101a0}'), ('\u{1d200}', '\u{1d245}') ]; pub const Gujarati_table: &'static [(char, char)] = &[ ('\u{a81}', '\u{a83}'), ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), ('\u{a93}', '\u{aa8}'), ('\u{aaa}', '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), ('\u{ab5}', '\u{ab9}'), ('\u{abc}', '\u{ac5}'), ('\u{ac7}', '\u{ac9}'), ('\u{acb}', '\u{acd}'), ('\u{ad0}', '\u{ad0}'), ('\u{ae0}', '\u{ae3}'), ('\u{ae6}', '\u{af1}'), ('\u{af9}', '\u{af9}') ]; pub const Gurmukhi_table: &'static [(char, char)] = &[ ('\u{a01}', '\u{a03}'), ('\u{a05}', '\u{a0a}'), ('\u{a0f}', '\u{a10}'), ('\u{a13}', '\u{a28}'), ('\u{a2a}', '\u{a30}'), ('\u{a32}', '\u{a33}'), ('\u{a35}', '\u{a36}'), ('\u{a38}', '\u{a39}'), ('\u{a3c}', '\u{a3c}'), ('\u{a3e}', '\u{a42}'), ('\u{a47}', '\u{a48}'), ('\u{a4b}', '\u{a4d}'), ('\u{a51}', '\u{a51}'), ('\u{a59}', '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), ('\u{a66}', '\u{a75}') ]; pub const Han_table: &'static [(char, char)] = &[ ('\u{2e80}', '\u{2e99}'), ('\u{2e9b}', '\u{2ef3}'), ('\u{2f00}', '\u{2fd5}'), ('\u{3005}', '\u{3005}'), ('\u{3007}', '\u{3007}'), ('\u{3021}', '\u{3029}'), ('\u{3038}', '\u{303b}'), ('\u{3400}', '\u{4db5}'), ('\u{4e00}', '\u{9fd5}'), ('\u{f900}', '\u{fa6d}'), ('\u{fa70}', '\u{fad9}'), ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}', '\u{2b734}'), ('\u{2b740}', '\u{2b81d}'), ('\u{2b820}', '\u{2cea1}'), ('\u{2f800}', '\u{2fa1d}') ]; pub const Hangul_table: &'static [(char, char)] = &[ ('\u{1100}', '\u{11ff}'), ('\u{302e}', '\u{302f}'), ('\u{3131}', '\u{318e}'), ('\u{3200}', '\u{321e}'), ('\u{3260}', '\u{327e}'), ('\u{a960}', '\u{a97c}'), ('\u{ac00}', '\u{d7a3}'), ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{ffa0}', '\u{ffbe}'), ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}') ]; pub const Hanunoo_table: &'static [(char, char)] = &[ ('\u{1720}', '\u{1734}') ]; pub const Hatran_table: &'static [(char, char)] = &[ ('\u{108e0}', '\u{108f2}'), ('\u{108f4}', '\u{108f5}'), ('\u{108fb}', '\u{108ff}') ]; pub const Hebrew_table: &'static [(char, char)] = &[ ('\u{591}', '\u{5c7}'), ('\u{5d0}', '\u{5ea}'), ('\u{5f0}', '\u{5f4}'), ('\u{fb1d}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), ('\u{fb46}', '\u{fb4f}') ]; pub const Hiragana_table: &'static [(char, char)] = &[ ('\u{3041}', '\u{3096}'), ('\u{309d}', '\u{309f}'), ('\u{1b001}', '\u{1b001}'), ('\u{1f200}', '\u{1f200}') ]; pub const Imperial_Aramaic_table: &'static [(char, char)] = &[ ('\u{10840}', '\u{10855}'), ('\u{10857}', '\u{1085f}') ]; pub const Inherited_table: &'static [(char, char)] = &[ ('\u{300}', '\u{36f}'), ('\u{485}', '\u{486}'), ('\u{64b}', '\u{655}'), ('\u{670}', '\u{670}'), ('\u{951}', '\u{952}'), ('\u{1ab0}', '\u{1abe}'), ('\u{1cd0}', '\u{1cd2}'), ('\u{1cd4}', '\u{1ce0}'), ('\u{1ce2}', '\u{1ce8}'), ('\u{1ced}', '\u{1ced}'), ('\u{1cf4}', '\u{1cf4}'), ('\u{1cf8}', '\u{1cf9}'), ('\u{1dc0}', '\u{1df5}'), ('\u{1dfc}', '\u{1dff}'), ('\u{200c}', '\u{200d}'), ('\u{20d0}', '\u{20f0}'), ('\u{302a}', '\u{302d}'), ('\u{3099}', '\u{309a}'), ('\u{fe00}', '\u{fe0f}'), ('\u{fe20}', '\u{fe2d}'), ('\u{101fd}', '\u{101fd}'), ('\u{102e0}', '\u{102e0}'), ('\u{1d167}', '\u{1d169}'), ('\u{1d17b}', '\u{1d182}'), ('\u{1d185}', '\u{1d18b}'), ('\u{1d1aa}', '\u{1d1ad}'), ('\u{e0100}', '\u{e01ef}') ]; pub const Inscriptional_Pahlavi_table: &'static [(char, char)] = &[ ('\u{10b60}', '\u{10b72}'), ('\u{10b78}', '\u{10b7f}') ]; pub const Inscriptional_Parthian_table: &'static [(char, char)] = &[ ('\u{10b40}', '\u{10b55}'), ('\u{10b58}', '\u{10b5f}') ]; pub const Javanese_table: &'static [(char, char)] = &[ ('\u{a980}', '\u{a9cd}'), ('\u{a9d0}', '\u{a9d9}'), ('\u{a9de}', '\u{a9df}') ]; pub const Kaithi_table: &'static [(char, char)] = &[ ('\u{11080}', '\u{110c1}') ]; pub const Kannada_table: &'static [(char, char)] = &[ ('\u{c81}', '\u{c83}'), ('\u{c85}', '\u{c8c}'), ('\u{c8e}', '\u{c90}'), ('\u{c92}', '\u{ca8}'), ('\u{caa}', '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), ('\u{cbc}', '\u{cc4}'), ('\u{cc6}', '\u{cc8}'), ('\u{cca}', '\u{ccd}'), ('\u{cd5}', '\u{cd6}'), ('\u{cde}', '\u{cde}'), ('\u{ce0}', '\u{ce3}'), ('\u{ce6}', '\u{cef}'), ('\u{cf1}', '\u{cf2}') ]; pub const Katakana_table: &'static [(char, char)] = &[ ('\u{30a1}', '\u{30fa}'), ('\u{30fd}', '\u{30ff}'), ('\u{31f0}', '\u{31ff}'), ('\u{32d0}', '\u{32fe}'), ('\u{3300}', '\u{3357}'), ('\u{ff66}', '\u{ff6f}'), ('\u{ff71}', '\u{ff9d}'), ('\u{1b000}', '\u{1b000}') ]; pub const Kayah_Li_table: &'static [(char, char)] = &[ ('\u{a900}', '\u{a92d}'), ('\u{a92f}', '\u{a92f}') ]; pub const Kharoshthi_table: &'static [(char, char)] = &[ ('\u{10a00}', '\u{10a03}'), ('\u{10a05}', '\u{10a06}'), ('\u{10a0c}', '\u{10a13}'), ('\u{10a15}', '\u{10a17}'), ('\u{10a19}', '\u{10a33}'), ('\u{10a38}', '\u{10a3a}'), ('\u{10a3f}', '\u{10a47}'), ('\u{10a50}', '\u{10a58}') ]; pub const Khmer_table: &'static [(char, char)] = &[ ('\u{1780}', '\u{17dd}'), ('\u{17e0}', '\u{17e9}'), ('\u{17f0}', '\u{17f9}'), ('\u{19e0}', '\u{19ff}') ]; pub const Khojki_table: &'static [(char, char)] = &[ ('\u{11200}', '\u{11211}'), ('\u{11213}', '\u{1123d}') ]; pub const Khudawadi_table: &'static [(char, char)] = &[ ('\u{112b0}', '\u{112ea}'), ('\u{112f0}', '\u{112f9}') ]; pub const Lao_table: &'static [(char, char)] = &[ ('\u{e81}', '\u{e82}'), ('\u{e84}', '\u{e84}'), ('\u{e87}', '\u{e88}'), ('\u{e8a}', '\u{e8a}'), ('\u{e8d}', '\u{e8d}'), ('\u{e94}', '\u{e97}'), ('\u{e99}', '\u{e9f}'), ('\u{ea1}', '\u{ea3}'), ('\u{ea5}', '\u{ea5}'), ('\u{ea7}', '\u{ea7}'), ('\u{eaa}', '\u{eab}'), ('\u{ead}', '\u{eb9}'), ('\u{ebb}', '\u{ebd}'), ('\u{ec0}', '\u{ec4}'), ('\u{ec6}', '\u{ec6}'), ('\u{ec8}', '\u{ecd}'), ('\u{ed0}', '\u{ed9}'), ('\u{edc}', '\u{edf}') ]; pub const Latin_table: &'static [(char, char)] = &[ ('\u{41}', '\u{5a}'), ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), ('\u{ba}', '\u{ba}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2b8}'), ('\u{2e0}', '\u{2e4}'), ('\u{1d00}', '\u{1d25}'), ('\u{1d2c}', '\u{1d5c}'), ('\u{1d62}', '\u{1d65}'), ('\u{1d6b}', '\u{1d77}'), ('\u{1d79}', '\u{1dbe}'), ('\u{1e00}', '\u{1eff}'), ('\u{2071}', '\u{2071}'), ('\u{207f}', '\u{207f}'), ('\u{2090}', '\u{209c}'), ('\u{212a}', '\u{212b}'), ('\u{2132}', '\u{2132}'), ('\u{214e}', '\u{214e}'), ('\u{2160}', '\u{2188}'), ('\u{2c60}', '\u{2c7f}'), ('\u{a722}', '\u{a787}'), ('\u{a78b}', '\u{a7ad}'), ('\u{a7b0}', '\u{a7b7}'), ('\u{a7f7}', '\u{a7ff}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab5c}', '\u{ab64}'), ('\u{fb00}', '\u{fb06}'), ('\u{ff21}', '\u{ff3a}'), ('\u{ff41}', '\u{ff5a}') ]; pub const Lepcha_table: &'static [(char, char)] = &[ ('\u{1c00}', '\u{1c37}'), ('\u{1c3b}', '\u{1c49}'), ('\u{1c4d}', '\u{1c4f}') ]; pub const Limbu_table: &'static [(char, char)] = &[ ('\u{1900}', '\u{191e}'), ('\u{1920}', '\u{192b}'), ('\u{1930}', '\u{193b}'), ('\u{1940}', '\u{1940}'), ('\u{1944}', '\u{194f}') ]; pub const Linear_A_table: &'static [(char, char)] = &[ ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), ('\u{10760}', '\u{10767}') ]; pub const Linear_B_table: &'static [(char, char)] = &[ ('\u{10000}', '\u{1000b}'), ('\u{1000d}', '\u{10026}'), ('\u{10028}', '\u{1003a}'), ('\u{1003c}', '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'), ('\u{10080}', '\u{100fa}') ]; pub const Lisu_table: &'static [(char, char)] = &[ ('\u{a4d0}', '\u{a4ff}') ]; pub const Lycian_table: &'static [(char, char)] = &[ ('\u{10280}', '\u{1029c}') ]; pub const Lydian_table: &'static [(char, char)] = &[ ('\u{10920}', '\u{10939}'), ('\u{1093f}', '\u{1093f}') ]; pub const Mahajani_table: &'static [(char, char)] = &[ ('\u{11150}', '\u{11176}') ]; pub const Malayalam_table: &'static [(char, char)] = &[ ('\u{d01}', '\u{d03}'), ('\u{d05}', '\u{d0c}'), ('\u{d0e}', '\u{d10}'), ('\u{d12}', '\u{d3a}'), ('\u{d3d}', '\u{d44}'), ('\u{d46}', '\u{d48}'), ('\u{d4a}', '\u{d4e}'), ('\u{d57}', '\u{d57}'), ('\u{d5f}', '\u{d63}'), ('\u{d66}', '\u{d75}'), ('\u{d79}', '\u{d7f}') ]; pub const Mandaic_table: &'static [(char, char)] = &[ ('\u{840}', '\u{85b}'), ('\u{85e}', '\u{85e}') ]; pub const Manichaean_table: &'static [(char, char)] = &[ ('\u{10ac0}', '\u{10ae6}'), ('\u{10aeb}', '\u{10af6}') ]; pub const Meetei_Mayek_table: &'static [(char, char)] = &[ ('\u{aae0}', '\u{aaf6}'), ('\u{abc0}', '\u{abed}'), ('\u{abf0}', '\u{abf9}') ]; pub const Mende_Kikakui_table: &'static [(char, char)] = &[ ('\u{1e800}', '\u{1e8c4}'), ('\u{1e8c7}', '\u{1e8d6}') ]; pub const Meroitic_Cursive_table: &'static [(char, char)] = &[ ('\u{109a0}', '\u{109b7}'), ('\u{109bc}', '\u{109cf}'), ('\u{109d2}', '\u{109ff}') ]; pub const Meroitic_Hieroglyphs_table: &'static [(char, char)] = &[ ('\u{10980}', '\u{1099f}') ]; pub const Miao_table: &'static [(char, char)] = &[ ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f7e}'), ('\u{16f8f}', '\u{16f9f}') ]; pub const Modi_table: &'static [(char, char)] = &[ ('\u{11600}', '\u{11644}'), ('\u{11650}', '\u{11659}') ]; pub const Mongolian_table: &'static [(char, char)] = &[ ('\u{1800}', '\u{1801}'), ('\u{1804}', '\u{1804}'), ('\u{1806}', '\u{180e}'), ('\u{1810}', '\u{1819}'), ('\u{1820}', '\u{1877}'), ('\u{1880}', '\u{18aa}') ]; pub const Mro_table: &'static [(char, char)] = &[ ('\u{16a40}', '\u{16a5e}'), ('\u{16a60}', '\u{16a69}'), ('\u{16a6e}', '\u{16a6f}') ]; pub const Multani_table: &'static [(char, char)] = &[ ('\u{11280}', '\u{11286}'), ('\u{11288}', '\u{11288}'), ('\u{1128a}', '\u{1128d}'), ('\u{1128f}', '\u{1129d}'), ('\u{1129f}', '\u{112a9}') ]; pub const Myanmar_table: &'static [(char, char)] = &[ ('\u{1000}', '\u{109f}'), ('\u{a9e0}', '\u{a9fe}'), ('\u{aa60}', '\u{aa7f}') ]; pub const Nabataean_table: &'static [(char, char)] = &[ ('\u{10880}', '\u{1089e}'), ('\u{108a7}', '\u{108af}') ]; pub const New_Tai_Lue_table: &'static [(char, char)] = &[ ('\u{1980}', '\u{19ab}'), ('\u{19b0}', '\u{19c9}'), ('\u{19d0}', '\u{19da}'), ('\u{19de}', '\u{19df}') ]; pub const Nko_table: &'static [(char, char)] = &[ ('\u{7c0}', '\u{7fa}') ]; pub const Ogham_table: &'static [(char, char)] = &[ ('\u{1680}', '\u{169c}') ]; pub const Ol_Chiki_table: &'static [(char, char)] = &[ ('\u{1c50}', '\u{1c7f}') ]; pub const Old_Hungarian_table: &'static [(char, char)] = &[ ('\u{10c80}', '\u{10cb2}'), ('\u{10cc0}', '\u{10cf2}'), ('\u{10cfa}', '\u{10cff}') ]; pub const Old_Italic_table: &'static [(char, char)] = &[ ('\u{10300}', '\u{10323}') ]; pub const Old_North_Arabian_table: &'static [(char, char)] = &[ ('\u{10a80}', '\u{10a9f}') ]; pub const Old_Permic_table: &'static [(char, char)] = &[ ('\u{10350}', '\u{1037a}') ]; pub const Old_Persian_table: &'static [(char, char)] = &[ ('\u{103a0}', '\u{103c3}'), ('\u{103c8}', '\u{103d5}') ]; pub const Old_South_Arabian_table: &'static [(char, char)] = &[ ('\u{10a60}', '\u{10a7f}') ]; pub const Old_Turkic_table: &'static [(char, char)] = &[ ('\u{10c00}', '\u{10c48}') ]; pub const Oriya_table: &'static [(char, char)] = &[ ('\u{b01}', '\u{b03}'), ('\u{b05}', '\u{b0c}'), ('\u{b0f}', '\u{b10}'), ('\u{b13}', '\u{b28}'), ('\u{b2a}', '\u{b30}'), ('\u{b32}', '\u{b33}'), ('\u{b35}', '\u{b39}'), ('\u{b3c}', '\u{b44}'), ('\u{b47}', '\u{b48}'), ('\u{b4b}', '\u{b4d}'), ('\u{b56}', '\u{b57}'), ('\u{b5c}', '\u{b5d}'), ('\u{b5f}', '\u{b63}'), ('\u{b66}', '\u{b77}') ]; pub const Osmanya_table: &'static [(char, char)] = &[ ('\u{10480}', '\u{1049d}'), ('\u{104a0}', '\u{104a9}') ]; pub const Pahawh_Hmong_table: &'static [(char, char)] = &[ ('\u{16b00}', '\u{16b45}'), ('\u{16b50}', '\u{16b59}'), ('\u{16b5b}', '\u{16b61}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}') ]; pub const Palmyrene_table: &'static [(char, char)] = &[ ('\u{10860}', '\u{1087f}') ]; pub const Pau_Cin_Hau_table: &'static [(char, char)] = &[ ('\u{11ac0}', '\u{11af8}') ]; pub const Phags_Pa_table: &'static [(char, char)] = &[ ('\u{a840}', '\u{a877}') ]; pub const Phoenician_table: &'static [(char, char)] = &[ ('\u{10900}', '\u{1091b}'), ('\u{1091f}', '\u{1091f}') ]; pub const Psalter_Pahlavi_table: &'static [(char, char)] = &[ ('\u{10b80}', '\u{10b91}'), ('\u{10b99}', '\u{10b9c}'), ('\u{10ba9}', '\u{10baf}') ]; pub const Rejang_table: &'static [(char, char)] = &[ ('\u{a930}', '\u{a953}'), ('\u{a95f}', '\u{a95f}') ]; pub const Runic_table: &'static [(char, char)] = &[ ('\u{16a0}', '\u{16ea}'), ('\u{16ee}', '\u{16f8}') ]; pub const Samaritan_table: &'static [(char, char)] = &[ ('\u{800}', '\u{82d}'), ('\u{830}', '\u{83e}') ]; pub const Saurashtra_table: &'static [(char, char)] = &[ ('\u{a880}', '\u{a8c4}'), ('\u{a8ce}', '\u{a8d9}') ]; pub const Sharada_table: &'static [(char, char)] = &[ ('\u{11180}', '\u{111cd}'), ('\u{111d0}', '\u{111df}') ]; pub const Shavian_table: &'static [(char, char)] = &[ ('\u{10450}', '\u{1047f}') ]; pub const Siddham_table: &'static [(char, char)] = &[ ('\u{11580}', '\u{115b5}'), ('\u{115b8}', '\u{115dd}') ]; pub const SignWriting_table: &'static [(char, char)] = &[ ('\u{1d800}', '\u{1da8b}'), ('\u{1da9b}', '\u{1da9f}'), ('\u{1daa1}', '\u{1daaf}') ]; pub const Sinhala_table: &'static [(char, char)] = &[ ('\u{d82}', '\u{d83}'), ('\u{d85}', '\u{d96}'), ('\u{d9a}', '\u{db1}'), ('\u{db3}', '\u{dbb}'), ('\u{dbd}', '\u{dbd}'), ('\u{dc0}', '\u{dc6}'), ('\u{dca}', '\u{dca}'), ('\u{dcf}', '\u{dd4}'), ('\u{dd6}', '\u{dd6}'), ('\u{dd8}', '\u{ddf}'), ('\u{de6}', '\u{def}'), ('\u{df2}', '\u{df4}'), ('\u{111e1}', '\u{111f4}') ]; pub const Sora_Sompeng_table: &'static [(char, char)] = &[ ('\u{110d0}', '\u{110e8}'), ('\u{110f0}', '\u{110f9}') ]; pub const Sundanese_table: &'static [(char, char)] = &[ ('\u{1b80}', '\u{1bbf}'), ('\u{1cc0}', '\u{1cc7}') ]; pub const Syloti_Nagri_table: &'static [(char, char)] = &[ ('\u{a800}', '\u{a82b}') ]; pub const Syriac_table: &'static [(char, char)] = &[ ('\u{700}', '\u{70d}'), ('\u{70f}', '\u{74a}'), ('\u{74d}', '\u{74f}') ]; pub const Tagalog_table: &'static [(char, char)] = &[ ('\u{1700}', '\u{170c}'), ('\u{170e}', '\u{1714}') ]; pub const Tagbanwa_table: &'static [(char, char)] = &[ ('\u{1760}', '\u{176c}'), ('\u{176e}', '\u{1770}'), ('\u{1772}', '\u{1773}') ]; pub const Tai_Le_table: &'static [(char, char)] = &[ ('\u{1950}', '\u{196d}'), ('\u{1970}', '\u{1974}') ]; pub const Tai_Tham_table: &'static [(char, char)] = &[ ('\u{1a20}', '\u{1a5e}'), ('\u{1a60}', '\u{1a7c}'), ('\u{1a7f}', '\u{1a89}'), ('\u{1a90}', '\u{1a99}'), ('\u{1aa0}', '\u{1aad}') ]; pub const Tai_Viet_table: &'static [(char, char)] = &[ ('\u{aa80}', '\u{aac2}'), ('\u{aadb}', '\u{aadf}') ]; pub const Takri_table: &'static [(char, char)] = &[ ('\u{11680}', '\u{116b7}'), ('\u{116c0}', '\u{116c9}') ]; pub const Tamil_table: &'static [(char, char)] = &[ ('\u{b82}', '\u{b83}'), ('\u{b85}', '\u{b8a}'), ('\u{b8e}', '\u{b90}'), ('\u{b92}', '\u{b95}'), ('\u{b99}', '\u{b9a}'), ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', '\u{b9f}'), ('\u{ba3}', '\u{ba4}'), ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), ('\u{bbe}', '\u{bc2}'), ('\u{bc6}', '\u{bc8}'), ('\u{bca}', '\u{bcd}'), ('\u{bd0}', '\u{bd0}'), ('\u{bd7}', '\u{bd7}'), ('\u{be6}', '\u{bfa}') ]; pub const Telugu_table: &'static [(char, char)] = &[ ('\u{c00}', '\u{c03}'), ('\u{c05}', '\u{c0c}'), ('\u{c0e}', '\u{c10}'), ('\u{c12}', '\u{c28}'), ('\u{c2a}', '\u{c39}'), ('\u{c3d}', '\u{c44}'), ('\u{c46}', '\u{c48}'), ('\u{c4a}', '\u{c4d}'), ('\u{c55}', '\u{c56}'), ('\u{c58}', '\u{c5a}'), ('\u{c60}', '\u{c63}'), ('\u{c66}', '\u{c6f}'), ('\u{c78}', '\u{c7f}') ]; pub const Thaana_table: &'static [(char, char)] = &[ ('\u{780}', '\u{7b1}') ]; pub const Thai_table: &'static [(char, char)] = &[ ('\u{e01}', '\u{e3a}'), ('\u{e40}', '\u{e5b}') ]; pub const Tibetan_table: &'static [(char, char)] = &[ ('\u{f00}', '\u{f47}'), ('\u{f49}', '\u{f6c}'), ('\u{f71}', '\u{f97}'), ('\u{f99}', '\u{fbc}'), ('\u{fbe}', '\u{fcc}'), ('\u{fce}', '\u{fd4}'), ('\u{fd9}', '\u{fda}') ]; pub const Tifinagh_table: &'static [(char, char)] = &[ ('\u{2d30}', '\u{2d67}'), ('\u{2d6f}', '\u{2d70}'), ('\u{2d7f}', '\u{2d7f}') ]; pub const Tirhuta_table: &'static [(char, char)] = &[ ('\u{11480}', '\u{114c7}'), ('\u{114d0}', '\u{114d9}') ]; pub const Ugaritic_table: &'static [(char, char)] = &[ ('\u{10380}', '\u{1039d}'), ('\u{1039f}', '\u{1039f}') ]; pub const Vai_table: &'static [(char, char)] = &[ ('\u{a500}', '\u{a62b}') ]; pub const Warang_Citi_table: &'static [(char, char)] = &[ ('\u{118a0}', '\u{118f2}'), ('\u{118ff}', '\u{118ff}') ]; pub const Yi_table: &'static [(char, char)] = &[ ('\u{a000}', '\u{a48c}'), ('\u{a490}', '\u{a4c6}') ]; } pub mod property { pub const Join_Control_table: &'static [(char, char)] = &[ ('\u{200c}', '\u{200d}') ]; pub const Noncharacter_Code_Point_table: &'static [(char, char)] = &[ ('\u{fdd0}', '\u{fdef}'), ('\u{fffe}', '\u{ffff}'), ('\u{1fffe}', '\u{1ffff}'), ('\u{2fffe}', '\u{2ffff}'), ('\u{3fffe}', '\u{3ffff}'), ('\u{4fffe}', '\u{4ffff}'), ('\u{5fffe}', '\u{5ffff}'), ('\u{6fffe}', '\u{6ffff}'), ('\u{7fffe}', '\u{7ffff}'), ('\u{8fffe}', '\u{8ffff}'), ('\u{9fffe}', '\u{9ffff}'), ('\u{afffe}', '\u{affff}'), ('\u{bfffe}', '\u{bffff}'), ('\u{cfffe}', '\u{cffff}'), ('\u{dfffe}', '\u{dffff}'), ('\u{efffe}', '\u{effff}'), ('\u{ffffe}', '\u{fffff}'), ('\u{10fffe}', '\u{10ffff}') ]; pub const White_Space_table: &'static [(char, char)] = &[ ('\u{9}', '\u{d}'), ('\u{20}', '\u{20}'), ('\u{85}', '\u{85}'), ('\u{a0}', '\u{a0}'), ('\u{1680}', '\u{1680}'), ('\u{2000}', '\u{200a}'), ('\u{2028}', '\u{2029}'), ('\u{202f}', '\u{202f}'), ('\u{205f}', '\u{205f}'), ('\u{3000}', '\u{3000}') ]; } pub mod regex { pub const UNICODE_CLASSES: &'static [(&'static str, &'static [(char, char)])] = &[ ("Ahom", super::script::Ahom_table), ("Alphabetic", super::derived_property::Alphabetic_table), ("Anatolian_Hieroglyphs", super::script::Anatolian_Hieroglyphs_table), ("Arabic", super::script::Arabic_table), ("Armenian", super::script::Armenian_table), ("Avestan", super::script::Avestan_table), ("Balinese", super::script::Balinese_table), ("Bamum", super::script::Bamum_table), ("Bassa_Vah", super::script::Bassa_Vah_table), ("Batak", super::script::Batak_table), ("Bengali", super::script::Bengali_table), ("Bopomofo", super::script::Bopomofo_table), ("Brahmi", super::script::Brahmi_table), ("Braille", super::script::Braille_table), ("Buginese", super::script::Buginese_table), ("Buhid", super::script::Buhid_table), ("C", super::general_category::C_table), ("Canadian_Aboriginal", super::script::Canadian_Aboriginal_table), ("Carian", super::script::Carian_table), ("Caucasian_Albanian", super::script::Caucasian_Albanian_table), ("Cc", super::general_category::Cc_table), ("Cf", super::general_category::Cf_table), ("Chakma", super::script::Chakma_table), ("Cham", super::script::Cham_table), ("Cherokee", super::script::Cherokee_table), ("Cn", super::general_category::Cn_table), ("Co", super::general_category::Co_table), ("Common", super::script::Common_table), ("Coptic", super::script::Coptic_table), ("Cuneiform", super::script::Cuneiform_table), ("Cypriot", super::script::Cypriot_table), ("Cyrillic", super::script::Cyrillic_table), ("Default_Ignorable_Code_Point", super::derived_property::Default_Ignorable_Code_Point_table), ("Deseret", super::script::Deseret_table), ("Devanagari", super::script::Devanagari_table), ("Duployan", super::script::Duployan_table), ("Egyptian_Hieroglyphs", super::script::Egyptian_Hieroglyphs_table), ("Elbasan", super::script::Elbasan_table), ("Ethiopic", super::script::Ethiopic_table), ("Georgian", super::script::Georgian_table), ("Glagolitic", super::script::Glagolitic_table), ("Gothic", super::script::Gothic_table), ("Grantha", super::script::Grantha_table), ("Grapheme_Extend", super::derived_property::Grapheme_Extend_table), ("Greek", super::script::Greek_table), ("Gujarati", super::script::Gujarati_table), ("Gurmukhi", super::script::Gurmukhi_table), ("Han", super::script::Han_table), ("Hangul", super::script::Hangul_table), ("Hanunoo", super::script::Hanunoo_table), ("Hatran", super::script::Hatran_table), ("Hebrew", super::script::Hebrew_table), ("Hiragana", super::script::Hiragana_table), ("Imperial_Aramaic", super::script::Imperial_Aramaic_table), ("Inherited", super::script::Inherited_table), ("Inscriptional_Pahlavi", super::script::Inscriptional_Pahlavi_table), ("Inscriptional_Parthian", super::script::Inscriptional_Parthian_table), ("Javanese", super::script::Javanese_table), ("Join_Control", super::property::Join_Control_table), ("Kaithi", super::script::Kaithi_table), ("Kannada", super::script::Kannada_table), ("Katakana", super::script::Katakana_table), ("Kayah_Li", super::script::Kayah_Li_table), ("Kharoshthi", super::script::Kharoshthi_table), ("Khmer", super::script::Khmer_table), ("Khojki", super::script::Khojki_table), ("Khudawadi", super::script::Khudawadi_table), ("L", super::general_category::L_table), ("LC", super::general_category::LC_table), ("Lao", super::script::Lao_table), ("Latin", super::script::Latin_table), ("Lepcha", super::script::Lepcha_table), ("Limbu", super::script::Limbu_table), ("Linear_A", super::script::Linear_A_table), ("Linear_B", super::script::Linear_B_table), ("Lisu", super::script::Lisu_table), ("Ll", super::general_category::Ll_table), ("Lm", super::general_category::Lm_table), ("Lo", super::general_category::Lo_table), ("Lowercase", super::derived_property::Lowercase_table), ("Lt", super::general_category::Lt_table), ("Lu", super::general_category::Lu_table), ("Lycian", super::script::Lycian_table), ("Lydian", super::script::Lydian_table), ("M", super::general_category::M_table), ("Mahajani", super::script::Mahajani_table), ("Malayalam", super::script::Malayalam_table), ("Mandaic", super::script::Mandaic_table), ("Manichaean", super::script::Manichaean_table), ("Mc", super::general_category::Mc_table), ("Me", super::general_category::Me_table), ("Meetei_Mayek", super::script::Meetei_Mayek_table), ("Mende_Kikakui", super::script::Mende_Kikakui_table), ("Meroitic_Cursive", super::script::Meroitic_Cursive_table), ("Meroitic_Hieroglyphs", super::script::Meroitic_Hieroglyphs_table), ("Miao", super::script::Miao_table), ("Mn", super::general_category::Mn_table), ("Modi", super::script::Modi_table), ("Mongolian", super::script::Mongolian_table), ("Mro", super::script::Mro_table), ("Multani", super::script::Multani_table), ("Myanmar", super::script::Myanmar_table), ("N", super::general_category::N_table), ("Nabataean", super::script::Nabataean_table), ("Nd", super::general_category::Nd_table), ("New_Tai_Lue", super::script::New_Tai_Lue_table), ("Nko", super::script::Nko_table), ("Nl", super::general_category::Nl_table), ("No", super::general_category::No_table), ("Noncharacter_Code_Point", super::property::Noncharacter_Code_Point_table), ("Ogham", super::script::Ogham_table), ("Ol_Chiki", super::script::Ol_Chiki_table), ("Old_Hungarian", super::script::Old_Hungarian_table), ("Old_Italic", super::script::Old_Italic_table), ("Old_North_Arabian", super::script::Old_North_Arabian_table), ("Old_Permic", super::script::Old_Permic_table), ("Old_Persian", super::script::Old_Persian_table), ("Old_South_Arabian", super::script::Old_South_Arabian_table), ("Old_Turkic", super::script::Old_Turkic_table), ("Oriya", super::script::Oriya_table), ("Osmanya", super::script::Osmanya_table), ("P", super::general_category::P_table), ("Pahawh_Hmong", super::script::Pahawh_Hmong_table), ("Palmyrene", super::script::Palmyrene_table), ("Pau_Cin_Hau", super::script::Pau_Cin_Hau_table), ("Pc", super::general_category::Pc_table), ("Pd", super::general_category::Pd_table), ("Pe", super::general_category::Pe_table), ("Pf", super::general_category::Pf_table), ("Phags_Pa", super::script::Phags_Pa_table), ("Phoenician", super::script::Phoenician_table), ("Pi", super::general_category::Pi_table), ("Po", super::general_category::Po_table), ("Ps", super::general_category::Ps_table), ("Psalter_Pahlavi", super::script::Psalter_Pahlavi_table), ("Rejang", super::script::Rejang_table), ("Runic", super::script::Runic_table), ("S", super::general_category::S_table), ("Samaritan", super::script::Samaritan_table), ("Saurashtra", super::script::Saurashtra_table), ("Sc", super::general_category::Sc_table), ("Sharada", super::script::Sharada_table), ("Shavian", super::script::Shavian_table), ("Siddham", super::script::Siddham_table), ("SignWriting", super::script::SignWriting_table), ("Sinhala", super::script::Sinhala_table), ("Sk", super::general_category::Sk_table), ("Sm", super::general_category::Sm_table), ("So", super::general_category::So_table), ("Sora_Sompeng", super::script::Sora_Sompeng_table), ("Sundanese", super::script::Sundanese_table), ("Syloti_Nagri", super::script::Syloti_Nagri_table), ("Syriac", super::script::Syriac_table), ("Tagalog", super::script::Tagalog_table), ("Tagbanwa", super::script::Tagbanwa_table), ("Tai_Le", super::script::Tai_Le_table), ("Tai_Tham", super::script::Tai_Tham_table), ("Tai_Viet", super::script::Tai_Viet_table), ("Takri", super::script::Takri_table), ("Tamil", super::script::Tamil_table), ("Telugu", super::script::Telugu_table), ("Thaana", super::script::Thaana_table), ("Thai", super::script::Thai_table), ("Tibetan", super::script::Tibetan_table), ("Tifinagh", super::script::Tifinagh_table), ("Tirhuta", super::script::Tirhuta_table), ("Ugaritic", super::script::Ugaritic_table), ("Uppercase", super::derived_property::Uppercase_table), ("Vai", super::script::Vai_table), ("Warang_Citi", super::script::Warang_Citi_table), ("White_Space", super::property::White_Space_table), ("XID_Continue", super::derived_property::XID_Continue_table), ("XID_Start", super::derived_property::XID_Start_table), ("Yi", super::script::Yi_table), ("Z", super::general_category::Z_table), ("Zl", super::general_category::Zl_table), ("Zp", super::general_category::Zp_table), ("Zs", super::general_category::Zs_table) ]; pub const PERLD: &'static [(char, char)] = super::general_category::Nd_table; pub const PERLS: &'static [(char, char)] = super::property::White_Space_table; pub const PERLW: &'static [(char, char)] = &[ ('\u{30}', '\u{39}'), ('\u{41}', '\u{5a}'), ('\u{5f}', '\u{5f}'), ('\u{61}', '\u{7a}'), ('\u{aa}', '\u{aa}'), ('\u{b5}', '\u{b5}'), ('\u{ba}', '\u{ba}'), ('\u{c0}', '\u{d6}'), ('\u{d8}', '\u{f6}'), ('\u{f8}', '\u{2c1}'), ('\u{2c6}', '\u{2d1}'), ('\u{2e0}', '\u{2e4}'), ('\u{2ec}', '\u{2ec}'), ('\u{2ee}', '\u{2ee}'), ('\u{300}', '\u{374}'), ('\u{376}', '\u{377}'), ('\u{37a}', '\u{37d}'), ('\u{37f}', '\u{37f}'), ('\u{386}', '\u{386}'), ('\u{388}', '\u{38a}'), ('\u{38c}', '\u{38c}'), ('\u{38e}', '\u{3a1}'), ('\u{3a3}', '\u{3f5}'), ('\u{3f7}', '\u{481}'), ('\u{483}', '\u{52f}'), ('\u{531}', '\u{556}'), ('\u{559}', '\u{559}'), ('\u{561}', '\u{587}'), ('\u{591}', '\u{5bd}'), ('\u{5bf}', '\u{5bf}'), ('\u{5c1}', '\u{5c2}'), ('\u{5c4}', '\u{5c5}'), ('\u{5c7}', '\u{5c7}'), ('\u{5d0}', '\u{5ea}'), ('\u{5f0}', '\u{5f2}'), ('\u{610}', '\u{61a}'), ('\u{620}', '\u{669}'), ('\u{66e}', '\u{6d3}'), ('\u{6d5}', '\u{6dc}'), ('\u{6df}', '\u{6e8}'), ('\u{6ea}', '\u{6fc}'), ('\u{6ff}', '\u{6ff}'), ('\u{710}', '\u{74a}'), ('\u{74d}', '\u{7b1}'), ('\u{7c0}', '\u{7f5}'), ('\u{7fa}', '\u{7fa}'), ('\u{800}', '\u{82d}'), ('\u{840}', '\u{85b}'), ('\u{8a0}', '\u{8b4}'), ('\u{8e3}', '\u{963}'), ('\u{966}', '\u{96f}'), ('\u{971}', '\u{983}'), ('\u{985}', '\u{98c}'), ('\u{98f}', '\u{990}'), ('\u{993}', '\u{9a8}'), ('\u{9aa}', '\u{9b0}'), ('\u{9b2}', '\u{9b2}'), ('\u{9b6}', '\u{9b9}'), ('\u{9bc}', '\u{9c4}'), ('\u{9c7}', '\u{9c8}'), ('\u{9cb}', '\u{9ce}'), ('\u{9d7}', '\u{9d7}'), ('\u{9dc}', '\u{9dd}'), ('\u{9df}', '\u{9e3}'), ('\u{9e6}', '\u{9f1}'), ('\u{a01}', '\u{a03}'), ('\u{a05}', '\u{a0a}'), ('\u{a0f}', '\u{a10}'), ('\u{a13}', '\u{a28}'), ('\u{a2a}', '\u{a30}'), ('\u{a32}', '\u{a33}'), ('\u{a35}', '\u{a36}'), ('\u{a38}', '\u{a39}'), ('\u{a3c}', '\u{a3c}'), ('\u{a3e}', '\u{a42}'), ('\u{a47}', '\u{a48}'), ('\u{a4b}', '\u{a4d}'), ('\u{a51}', '\u{a51}'), ('\u{a59}', '\u{a5c}'), ('\u{a5e}', '\u{a5e}'), ('\u{a66}', '\u{a75}'), ('\u{a81}', '\u{a83}'), ('\u{a85}', '\u{a8d}'), ('\u{a8f}', '\u{a91}'), ('\u{a93}', '\u{aa8}'), ('\u{aaa}', '\u{ab0}'), ('\u{ab2}', '\u{ab3}'), ('\u{ab5}', '\u{ab9}'), ('\u{abc}', '\u{ac5}'), ('\u{ac7}', '\u{ac9}'), ('\u{acb}', '\u{acd}'), ('\u{ad0}', '\u{ad0}'), ('\u{ae0}', '\u{ae3}'), ('\u{ae6}', '\u{aef}'), ('\u{af9}', '\u{af9}'), ('\u{b01}', '\u{b03}'), ('\u{b05}', '\u{b0c}'), ('\u{b0f}', '\u{b10}'), ('\u{b13}', '\u{b28}'), ('\u{b2a}', '\u{b30}'), ('\u{b32}', '\u{b33}'), ('\u{b35}', '\u{b39}'), ('\u{b3c}', '\u{b44}'), ('\u{b47}', '\u{b48}'), ('\u{b4b}', '\u{b4d}'), ('\u{b56}', '\u{b57}'), ('\u{b5c}', '\u{b5d}'), ('\u{b5f}', '\u{b63}'), ('\u{b66}', '\u{b6f}'), ('\u{b71}', '\u{b71}'), ('\u{b82}', '\u{b83}'), ('\u{b85}', '\u{b8a}'), ('\u{b8e}', '\u{b90}'), ('\u{b92}', '\u{b95}'), ('\u{b99}', '\u{b9a}'), ('\u{b9c}', '\u{b9c}'), ('\u{b9e}', '\u{b9f}'), ('\u{ba3}', '\u{ba4}'), ('\u{ba8}', '\u{baa}'), ('\u{bae}', '\u{bb9}'), ('\u{bbe}', '\u{bc2}'), ('\u{bc6}', '\u{bc8}'), ('\u{bca}', '\u{bcd}'), ('\u{bd0}', '\u{bd0}'), ('\u{bd7}', '\u{bd7}'), ('\u{be6}', '\u{bef}'), ('\u{c00}', '\u{c03}'), ('\u{c05}', '\u{c0c}'), ('\u{c0e}', '\u{c10}'), ('\u{c12}', '\u{c28}'), ('\u{c2a}', '\u{c39}'), ('\u{c3d}', '\u{c44}'), ('\u{c46}', '\u{c48}'), ('\u{c4a}', '\u{c4d}'), ('\u{c55}', '\u{c56}'), ('\u{c58}', '\u{c5a}'), ('\u{c60}', '\u{c63}'), ('\u{c66}', '\u{c6f}'), ('\u{c81}', '\u{c83}'), ('\u{c85}', '\u{c8c}'), ('\u{c8e}', '\u{c90}'), ('\u{c92}', '\u{ca8}'), ('\u{caa}', '\u{cb3}'), ('\u{cb5}', '\u{cb9}'), ('\u{cbc}', '\u{cc4}'), ('\u{cc6}', '\u{cc8}'), ('\u{cca}', '\u{ccd}'), ('\u{cd5}', '\u{cd6}'), ('\u{cde}', '\u{cde}'), ('\u{ce0}', '\u{ce3}'), ('\u{ce6}', '\u{cef}'), ('\u{cf1}', '\u{cf2}'), ('\u{d01}', '\u{d03}'), ('\u{d05}', '\u{d0c}'), ('\u{d0e}', '\u{d10}'), ('\u{d12}', '\u{d3a}'), ('\u{d3d}', '\u{d44}'), ('\u{d46}', '\u{d48}'), ('\u{d4a}', '\u{d4e}'), ('\u{d57}', '\u{d57}'), ('\u{d5f}', '\u{d63}'), ('\u{d66}', '\u{d6f}'), ('\u{d7a}', '\u{d7f}'), ('\u{d82}', '\u{d83}'), ('\u{d85}', '\u{d96}'), ('\u{d9a}', '\u{db1}'), ('\u{db3}', '\u{dbb}'), ('\u{dbd}', '\u{dbd}'), ('\u{dc0}', '\u{dc6}'), ('\u{dca}', '\u{dca}'), ('\u{dcf}', '\u{dd4}'), ('\u{dd6}', '\u{dd6}'), ('\u{dd8}', '\u{ddf}'), ('\u{de6}', '\u{def}'), ('\u{df2}', '\u{df3}'), ('\u{e01}', '\u{e3a}'), ('\u{e40}', '\u{e4e}'), ('\u{e50}', '\u{e59}'), ('\u{e81}', '\u{e82}'), ('\u{e84}', '\u{e84}'), ('\u{e87}', '\u{e88}'), ('\u{e8a}', '\u{e8a}'), ('\u{e8d}', '\u{e8d}'), ('\u{e94}', '\u{e97}'), ('\u{e99}', '\u{e9f}'), ('\u{ea1}', '\u{ea3}'), ('\u{ea5}', '\u{ea5}'), ('\u{ea7}', '\u{ea7}'), ('\u{eaa}', '\u{eab}'), ('\u{ead}', '\u{eb9}'), ('\u{ebb}', '\u{ebd}'), ('\u{ec0}', '\u{ec4}'), ('\u{ec6}', '\u{ec6}'), ('\u{ec8}', '\u{ecd}'), ('\u{ed0}', '\u{ed9}'), ('\u{edc}', '\u{edf}'), ('\u{f00}', '\u{f00}'), ('\u{f18}', '\u{f19}'), ('\u{f20}', '\u{f29}'), ('\u{f35}', '\u{f35}'), ('\u{f37}', '\u{f37}'), ('\u{f39}', '\u{f39}'), ('\u{f3e}', '\u{f47}'), ('\u{f49}', '\u{f6c}'), ('\u{f71}', '\u{f84}'), ('\u{f86}', '\u{f97}'), ('\u{f99}', '\u{fbc}'), ('\u{fc6}', '\u{fc6}'), ('\u{1000}', '\u{1049}'), ('\u{1050}', '\u{109d}'), ('\u{10a0}', '\u{10c5}'), ('\u{10c7}', '\u{10c7}'), ('\u{10cd}', '\u{10cd}'), ('\u{10d0}', '\u{10fa}'), ('\u{10fc}', '\u{1248}'), ('\u{124a}', '\u{124d}'), ('\u{1250}', '\u{1256}'), ('\u{1258}', '\u{1258}'), ('\u{125a}', '\u{125d}'), ('\u{1260}', '\u{1288}'), ('\u{128a}', '\u{128d}'), ('\u{1290}', '\u{12b0}'), ('\u{12b2}', '\u{12b5}'), ('\u{12b8}', '\u{12be}'), ('\u{12c0}', '\u{12c0}'), ('\u{12c2}', '\u{12c5}'), ('\u{12c8}', '\u{12d6}'), ('\u{12d8}', '\u{1310}'), ('\u{1312}', '\u{1315}'), ('\u{1318}', '\u{135a}'), ('\u{135d}', '\u{135f}'), ('\u{1380}', '\u{138f}'), ('\u{13a0}', '\u{13f5}'), ('\u{13f8}', '\u{13fd}'), ('\u{1401}', '\u{166c}'), ('\u{166f}', '\u{167f}'), ('\u{1681}', '\u{169a}'), ('\u{16a0}', '\u{16ea}'), ('\u{16ee}', '\u{16f8}'), ('\u{1700}', '\u{170c}'), ('\u{170e}', '\u{1714}'), ('\u{1720}', '\u{1734}'), ('\u{1740}', '\u{1753}'), ('\u{1760}', '\u{176c}'), ('\u{176e}', '\u{1770}'), ('\u{1772}', '\u{1773}'), ('\u{1780}', '\u{17d3}'), ('\u{17d7}', '\u{17d7}'), ('\u{17dc}', '\u{17dd}'), ('\u{17e0}', '\u{17e9}'), ('\u{180b}', '\u{180d}'), ('\u{1810}', '\u{1819}'), ('\u{1820}', '\u{1877}'), ('\u{1880}', '\u{18aa}'), ('\u{18b0}', '\u{18f5}'), ('\u{1900}', '\u{191e}'), ('\u{1920}', '\u{192b}'), ('\u{1930}', '\u{193b}'), ('\u{1946}', '\u{196d}'), ('\u{1970}', '\u{1974}'), ('\u{1980}', '\u{19ab}'), ('\u{19b0}', '\u{19c9}'), ('\u{19d0}', '\u{19d9}'), ('\u{1a00}', '\u{1a1b}'), ('\u{1a20}', '\u{1a5e}'), ('\u{1a60}', '\u{1a7c}'), ('\u{1a7f}', '\u{1a89}'), ('\u{1a90}', '\u{1a99}'), ('\u{1aa7}', '\u{1aa7}'), ('\u{1ab0}', '\u{1abe}'), ('\u{1b00}', '\u{1b4b}'), ('\u{1b50}', '\u{1b59}'), ('\u{1b6b}', '\u{1b73}'), ('\u{1b80}', '\u{1bf3}'), ('\u{1c00}', '\u{1c37}'), ('\u{1c40}', '\u{1c49}'), ('\u{1c4d}', '\u{1c7d}'), ('\u{1cd0}', '\u{1cd2}'), ('\u{1cd4}', '\u{1cf6}'), ('\u{1cf8}', '\u{1cf9}'), ('\u{1d00}', '\u{1df5}'), ('\u{1dfc}', '\u{1f15}'), ('\u{1f18}', '\u{1f1d}'), ('\u{1f20}', '\u{1f45}'), ('\u{1f48}', '\u{1f4d}'), ('\u{1f50}', '\u{1f57}'), ('\u{1f59}', '\u{1f59}'), ('\u{1f5b}', '\u{1f5b}'), ('\u{1f5d}', '\u{1f5d}'), ('\u{1f5f}', '\u{1f7d}'), ('\u{1f80}', '\u{1fb4}'), ('\u{1fb6}', '\u{1fbc}'), ('\u{1fbe}', '\u{1fbe}'), ('\u{1fc2}', '\u{1fc4}'), ('\u{1fc6}', '\u{1fcc}'), ('\u{1fd0}', '\u{1fd3}'), ('\u{1fd6}', '\u{1fdb}'), ('\u{1fe0}', '\u{1fec}'), ('\u{1ff2}', '\u{1ff4}'), ('\u{1ff6}', '\u{1ffc}'), ('\u{200c}', '\u{200d}'), ('\u{203f}', '\u{2040}'), ('\u{2054}', '\u{2054}'), ('\u{2071}', '\u{2071}'), ('\u{207f}', '\u{207f}'), ('\u{2090}', '\u{209c}'), ('\u{20d0}', '\u{20f0}'), ('\u{2102}', '\u{2102}'), ('\u{2107}', '\u{2107}'), ('\u{210a}', '\u{2113}'), ('\u{2115}', '\u{2115}'), ('\u{2119}', '\u{211d}'), ('\u{2124}', '\u{2124}'), ('\u{2126}', '\u{2126}'), ('\u{2128}', '\u{2128}'), ('\u{212a}', '\u{212d}'), ('\u{212f}', '\u{2139}'), ('\u{213c}', '\u{213f}'), ('\u{2145}', '\u{2149}'), ('\u{214e}', '\u{214e}'), ('\u{2160}', '\u{2188}'), ('\u{24b6}', '\u{24e9}'), ('\u{2c00}', '\u{2c2e}'), ('\u{2c30}', '\u{2c5e}'), ('\u{2c60}', '\u{2ce4}'), ('\u{2ceb}', '\u{2cf3}'), ('\u{2d00}', '\u{2d25}'), ('\u{2d27}', '\u{2d27}'), ('\u{2d2d}', '\u{2d2d}'), ('\u{2d30}', '\u{2d67}'), ('\u{2d6f}', '\u{2d6f}'), ('\u{2d7f}', '\u{2d96}'), ('\u{2da0}', '\u{2da6}'), ('\u{2da8}', '\u{2dae}'), ('\u{2db0}', '\u{2db6}'), ('\u{2db8}', '\u{2dbe}'), ('\u{2dc0}', '\u{2dc6}'), ('\u{2dc8}', '\u{2dce}'), ('\u{2dd0}', '\u{2dd6}'), ('\u{2dd8}', '\u{2dde}'), ('\u{2de0}', '\u{2dff}'), ('\u{2e2f}', '\u{2e2f}'), ('\u{3005}', '\u{3007}'), ('\u{3021}', '\u{302f}'), ('\u{3031}', '\u{3035}'), ('\u{3038}', '\u{303c}'), ('\u{3041}', '\u{3096}'), ('\u{3099}', '\u{309a}'), ('\u{309d}', '\u{309f}'), ('\u{30a1}', '\u{30fa}'), ('\u{30fc}', '\u{30ff}'), ('\u{3105}', '\u{312d}'), ('\u{3131}', '\u{318e}'), ('\u{31a0}', '\u{31ba}'), ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{4db5}'), ('\u{4e00}', '\u{9fd5}'), ('\u{a000}', '\u{a48c}'), ('\u{a4d0}', '\u{a4fd}'), ('\u{a500}', '\u{a60c}'), ('\u{a610}', '\u{a62b}'), ('\u{a640}', '\u{a672}'), ('\u{a674}', '\u{a67d}'), ('\u{a67f}', '\u{a6f1}'), ('\u{a717}', '\u{a71f}'), ('\u{a722}', '\u{a788}'), ('\u{a78b}', '\u{a7ad}'), ('\u{a7b0}', '\u{a7b7}'), ('\u{a7f7}', '\u{a827}'), ('\u{a840}', '\u{a873}'), ('\u{a880}', '\u{a8c4}'), ('\u{a8d0}', '\u{a8d9}'), ('\u{a8e0}', '\u{a8f7}'), ('\u{a8fb}', '\u{a8fb}'), ('\u{a8fd}', '\u{a8fd}'), ('\u{a900}', '\u{a92d}'), ('\u{a930}', '\u{a953}'), ('\u{a960}', '\u{a97c}'), ('\u{a980}', '\u{a9c0}'), ('\u{a9cf}', '\u{a9d9}'), ('\u{a9e0}', '\u{a9fe}'), ('\u{aa00}', '\u{aa36}'), ('\u{aa40}', '\u{aa4d}'), ('\u{aa50}', '\u{aa59}'), ('\u{aa60}', '\u{aa76}'), ('\u{aa7a}', '\u{aac2}'), ('\u{aadb}', '\u{aadd}'), ('\u{aae0}', '\u{aaef}'), ('\u{aaf2}', '\u{aaf6}'), ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab5c}', '\u{ab65}'), ('\u{ab70}', '\u{abea}'), ('\u{abec}', '\u{abed}'), ('\u{abf0}', '\u{abf9}'), ('\u{ac00}', '\u{d7a3}'), ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', '\u{fa6d}'), ('\u{fa70}', '\u{fad9}'), ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{fb1d}', '\u{fb28}'), ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), ('\u{fb46}', '\u{fbb1}'), ('\u{fbd3}', '\u{fd3d}'), ('\u{fd50}', '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}', '\u{fdfb}'), ('\u{fe00}', '\u{fe0f}'), ('\u{fe20}', '\u{fe2f}'), ('\u{fe33}', '\u{fe34}'), ('\u{fe4d}', '\u{fe4f}'), ('\u{fe70}', '\u{fe74}'), ('\u{fe76}', '\u{fefc}'), ('\u{ff10}', '\u{ff19}'), ('\u{ff21}', '\u{ff3a}'), ('\u{ff3f}', '\u{ff3f}'), ('\u{ff41}', '\u{ff5a}'), ('\u{ff66}', '\u{ffbe}'), ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'), ('\u{10000}', '\u{1000b}'), ('\u{1000d}', '\u{10026}'), ('\u{10028}', '\u{1003a}'), ('\u{1003c}', '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'), ('\u{10080}', '\u{100fa}'), ('\u{10140}', '\u{10174}'), ('\u{101fd}', '\u{101fd}'), ('\u{10280}', '\u{1029c}'), ('\u{102a0}', '\u{102d0}'), ('\u{102e0}', '\u{102e0}'), ('\u{10300}', '\u{1031f}'), ('\u{10330}', '\u{1034a}'), ('\u{10350}', '\u{1037a}'), ('\u{10380}', '\u{1039d}'), ('\u{103a0}', '\u{103c3}'), ('\u{103c8}', '\u{103cf}'), ('\u{103d1}', '\u{103d5}'), ('\u{10400}', '\u{1049d}'), ('\u{104a0}', '\u{104a9}'), ('\u{10500}', '\u{10527}'), ('\u{10530}', '\u{10563}'), ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), ('\u{10760}', '\u{10767}'), ('\u{10800}', '\u{10805}'), ('\u{10808}', '\u{10808}'), ('\u{1080a}', '\u{10835}'), ('\u{10837}', '\u{10838}'), ('\u{1083c}', '\u{1083c}'), ('\u{1083f}', '\u{10855}'), ('\u{10860}', '\u{10876}'), ('\u{10880}', '\u{1089e}'), ('\u{108e0}', '\u{108f2}'), ('\u{108f4}', '\u{108f5}'), ('\u{10900}', '\u{10915}'), ('\u{10920}', '\u{10939}'), ('\u{10980}', '\u{109b7}'), ('\u{109be}', '\u{109bf}'), ('\u{10a00}', '\u{10a03}'), ('\u{10a05}', '\u{10a06}'), ('\u{10a0c}', '\u{10a13}'), ('\u{10a15}', '\u{10a17}'), ('\u{10a19}', '\u{10a33}'), ('\u{10a38}', '\u{10a3a}'), ('\u{10a3f}', '\u{10a3f}'), ('\u{10a60}', '\u{10a7c}'), ('\u{10a80}', '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'), ('\u{10ac9}', '\u{10ae6}'), ('\u{10b00}', '\u{10b35}'), ('\u{10b40}', '\u{10b55}'), ('\u{10b60}', '\u{10b72}'), ('\u{10b80}', '\u{10b91}'), ('\u{10c00}', '\u{10c48}'), ('\u{10c80}', '\u{10cb2}'), ('\u{10cc0}', '\u{10cf2}'), ('\u{11000}', '\u{11046}'), ('\u{11066}', '\u{1106f}'), ('\u{1107f}', '\u{110ba}'), ('\u{110d0}', '\u{110e8}'), ('\u{110f0}', '\u{110f9}'), ('\u{11100}', '\u{11134}'), ('\u{11136}', '\u{1113f}'), ('\u{11150}', '\u{11173}'), ('\u{11176}', '\u{11176}'), ('\u{11180}', '\u{111c4}'), ('\u{111ca}', '\u{111cc}'), ('\u{111d0}', '\u{111da}'), ('\u{111dc}', '\u{111dc}'), ('\u{11200}', '\u{11211}'), ('\u{11213}', '\u{11237}'), ('\u{11280}', '\u{11286}'), ('\u{11288}', '\u{11288}'), ('\u{1128a}', '\u{1128d}'), ('\u{1128f}', '\u{1129d}'), ('\u{1129f}', '\u{112a8}'), ('\u{112b0}', '\u{112ea}'), ('\u{112f0}', '\u{112f9}'), ('\u{11300}', '\u{11303}'), ('\u{11305}', '\u{1130c}'), ('\u{1130f}', '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'), ('\u{11332}', '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133c}', '\u{11344}'), ('\u{11347}', '\u{11348}'), ('\u{1134b}', '\u{1134d}'), ('\u{11350}', '\u{11350}'), ('\u{11357}', '\u{11357}'), ('\u{1135d}', '\u{11363}'), ('\u{11366}', '\u{1136c}'), ('\u{11370}', '\u{11374}'), ('\u{11480}', '\u{114c5}'), ('\u{114c7}', '\u{114c7}'), ('\u{114d0}', '\u{114d9}'), ('\u{11580}', '\u{115b5}'), ('\u{115b8}', '\u{115c0}'), ('\u{115d8}', '\u{115dd}'), ('\u{11600}', '\u{11640}'), ('\u{11644}', '\u{11644}'), ('\u{11650}', '\u{11659}'), ('\u{11680}', '\u{116b7}'), ('\u{116c0}', '\u{116c9}'), ('\u{11700}', '\u{11719}'), ('\u{1171d}', '\u{1172b}'), ('\u{11730}', '\u{11739}'), ('\u{118a0}', '\u{118e9}'), ('\u{118ff}', '\u{118ff}'), ('\u{11ac0}', '\u{11af8}'), ('\u{12000}', '\u{12399}'), ('\u{12400}', '\u{1246e}'), ('\u{12480}', '\u{12543}'), ('\u{13000}', '\u{1342e}'), ('\u{14400}', '\u{14646}'), ('\u{16800}', '\u{16a38}'), ('\u{16a40}', '\u{16a5e}'), ('\u{16a60}', '\u{16a69}'), ('\u{16ad0}', '\u{16aed}'), ('\u{16af0}', '\u{16af4}'), ('\u{16b00}', '\u{16b36}'), ('\u{16b40}', '\u{16b43}'), ('\u{16b50}', '\u{16b59}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}'), ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f7e}'), ('\u{16f8f}', '\u{16f9f}'), ('\u{1b000}', '\u{1b001}'), ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}', '\u{1bc99}'), ('\u{1bc9d}', '\u{1bc9e}'), ('\u{1d165}', '\u{1d169}'), ('\u{1d16d}', '\u{1d172}'), ('\u{1d17b}', '\u{1d182}'), ('\u{1d185}', '\u{1d18b}'), ('\u{1d1aa}', '\u{1d1ad}'), ('\u{1d242}', '\u{1d244}'), ('\u{1d400}', '\u{1d454}'), ('\u{1d456}', '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'), ('\u{1d552}', '\u{1d6a5}'), ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6c2}', '\u{1d6da}'), ('\u{1d6dc}', '\u{1d6fa}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', '\u{1d734}'), ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d76e}'), ('\u{1d770}', '\u{1d788}'), ('\u{1d78a}', '\u{1d7a8}'), ('\u{1d7aa}', '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7cb}'), ('\u{1d7ce}', '\u{1d7ff}'), ('\u{1da00}', '\u{1da36}'), ('\u{1da3b}', '\u{1da6c}'), ('\u{1da75}', '\u{1da75}'), ('\u{1da84}', '\u{1da84}'), ('\u{1da9b}', '\u{1da9f}'), ('\u{1daa1}', '\u{1daaf}'), ('\u{1e800}', '\u{1e8c4}'), ('\u{1e8d0}', '\u{1e8d6}'), ('\u{1ee00}', '\u{1ee03}'), ('\u{1ee05}', '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', '\u{1ee47}'), ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}', '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), ('\u{1ee57}', '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', '\u{1ee77}'), ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}', '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), ('\u{1eea5}', '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), ('\u{1f130}', '\u{1f149}'), ('\u{1f150}', '\u{1f169}'), ('\u{1f170}', '\u{1f189}'), ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}', '\u{2b734}'), ('\u{2b740}', '\u{2b81d}'), ('\u{2b820}', '\u{2cea1}'), ('\u{2f800}', '\u{2fa1d}'), ('\u{e0100}', '\u{e01ef}') ]; } pub mod case_folding { pub const C_plus_S_both_table: &'static [(char, char)] = &[ ('\u{41}', '\u{61}'), ('\u{42}', '\u{62}'), ('\u{43}', '\u{63}'), ('\u{44}', '\u{64}'), ('\u{45}', '\u{65}'), ('\u{46}', '\u{66}'), ('\u{47}', '\u{67}'), ('\u{48}', '\u{68}'), ('\u{49}', '\u{69}'), ('\u{4a}', '\u{6a}'), ('\u{4b}', '\u{6b}'), ('\u{4b}', '\u{212a}'), ('\u{4c}', '\u{6c}'), ('\u{4d}', '\u{6d}'), ('\u{4e}', '\u{6e}'), ('\u{4f}', '\u{6f}'), ('\u{50}', '\u{70}'), ('\u{51}', '\u{71}'), ('\u{52}', '\u{72}'), ('\u{53}', '\u{73}'), ('\u{53}', '\u{17f}'), ('\u{54}', '\u{74}'), ('\u{55}', '\u{75}'), ('\u{56}', '\u{76}'), ('\u{57}', '\u{77}'), ('\u{58}', '\u{78}'), ('\u{59}', '\u{79}'), ('\u{5a}', '\u{7a}'), ('\u{61}', '\u{41}'), ('\u{62}', '\u{42}'), ('\u{63}', '\u{43}'), ('\u{64}', '\u{44}'), ('\u{65}', '\u{45}'), ('\u{66}', '\u{46}'), ('\u{67}', '\u{47}'), ('\u{68}', '\u{48}'), ('\u{69}', '\u{49}'), ('\u{6a}', '\u{4a}'), ('\u{6b}', '\u{4b}'), ('\u{6b}', '\u{212a}'), ('\u{6c}', '\u{4c}'), ('\u{6d}', '\u{4d}'), ('\u{6e}', '\u{4e}'), ('\u{6f}', '\u{4f}'), ('\u{70}', '\u{50}'), ('\u{71}', '\u{51}'), ('\u{72}', '\u{52}'), ('\u{73}', '\u{53}'), ('\u{73}', '\u{17f}'), ('\u{74}', '\u{54}'), ('\u{75}', '\u{55}'), ('\u{76}', '\u{56}'), ('\u{77}', '\u{57}'), ('\u{78}', '\u{58}'), ('\u{79}', '\u{59}'), ('\u{7a}', '\u{5a}'), ('\u{b5}', '\u{39c}'), ('\u{b5}', '\u{3bc}'), ('\u{c0}', '\u{e0}'), ('\u{c1}', '\u{e1}'), ('\u{c2}', '\u{e2}'), ('\u{c3}', '\u{e3}'), ('\u{c4}', '\u{e4}'), ('\u{c5}', '\u{e5}'), ('\u{c5}', '\u{212b}'), ('\u{c6}', '\u{e6}'), ('\u{c7}', '\u{e7}'), ('\u{c8}', '\u{e8}'), ('\u{c9}', '\u{e9}'), ('\u{ca}', '\u{ea}'), ('\u{cb}', '\u{eb}'), ('\u{cc}', '\u{ec}'), ('\u{cd}', '\u{ed}'), ('\u{ce}', '\u{ee}'), ('\u{cf}', '\u{ef}'), ('\u{d0}', '\u{f0}'), ('\u{d1}', '\u{f1}'), ('\u{d2}', '\u{f2}'), ('\u{d3}', '\u{f3}'), ('\u{d4}', '\u{f4}'), ('\u{d5}', '\u{f5}'), ('\u{d6}', '\u{f6}'), ('\u{d8}', '\u{f8}'), ('\u{d9}', '\u{f9}'), ('\u{da}', '\u{fa}'), ('\u{db}', '\u{fb}'), ('\u{dc}', '\u{fc}'), ('\u{dd}', '\u{fd}'), ('\u{de}', '\u{fe}'), ('\u{df}', '\u{1e9e}'), ('\u{e0}', '\u{c0}'), ('\u{e1}', '\u{c1}'), ('\u{e2}', '\u{c2}'), ('\u{e3}', '\u{c3}'), ('\u{e4}', '\u{c4}'), ('\u{e5}', '\u{c5}'), ('\u{e5}', '\u{212b}'), ('\u{e6}', '\u{c6}'), ('\u{e7}', '\u{c7}'), ('\u{e8}', '\u{c8}'), ('\u{e9}', '\u{c9}'), ('\u{ea}', '\u{ca}'), ('\u{eb}', '\u{cb}'), ('\u{ec}', '\u{cc}'), ('\u{ed}', '\u{cd}'), ('\u{ee}', '\u{ce}'), ('\u{ef}', '\u{cf}'), ('\u{f0}', '\u{d0}'), ('\u{f1}', '\u{d1}'), ('\u{f2}', '\u{d2}'), ('\u{f3}', '\u{d3}'), ('\u{f4}', '\u{d4}'), ('\u{f5}', '\u{d5}'), ('\u{f6}', '\u{d6}'), ('\u{f8}', '\u{d8}'), ('\u{f9}', '\u{d9}'), ('\u{fa}', '\u{da}'), ('\u{fb}', '\u{db}'), ('\u{fc}', '\u{dc}'), ('\u{fd}', '\u{dd}'), ('\u{fe}', '\u{de}'), ('\u{ff}', '\u{178}'), ('\u{100}', '\u{101}'), ('\u{101}', '\u{100}'), ('\u{102}', '\u{103}'), ('\u{103}', '\u{102}'), ('\u{104}', '\u{105}'), ('\u{105}', '\u{104}'), ('\u{106}', '\u{107}'), ('\u{107}', '\u{106}'), ('\u{108}', '\u{109}'), ('\u{109}', '\u{108}'), ('\u{10a}', '\u{10b}'), ('\u{10b}', '\u{10a}'), ('\u{10c}', '\u{10d}'), ('\u{10d}', '\u{10c}'), ('\u{10e}', '\u{10f}'), ('\u{10f}', '\u{10e}'), ('\u{110}', '\u{111}'), ('\u{111}', '\u{110}'), ('\u{112}', '\u{113}'), ('\u{113}', '\u{112}'), ('\u{114}', '\u{115}'), ('\u{115}', '\u{114}'), ('\u{116}', '\u{117}'), ('\u{117}', '\u{116}'), ('\u{118}', '\u{119}'), ('\u{119}', '\u{118}'), ('\u{11a}', '\u{11b}'), ('\u{11b}', '\u{11a}'), ('\u{11c}', '\u{11d}'), ('\u{11d}', '\u{11c}'), ('\u{11e}', '\u{11f}'), ('\u{11f}', '\u{11e}'), ('\u{120}', '\u{121}'), ('\u{121}', '\u{120}'), ('\u{122}', '\u{123}'), ('\u{123}', '\u{122}'), ('\u{124}', '\u{125}'), ('\u{125}', '\u{124}'), ('\u{126}', '\u{127}'), ('\u{127}', '\u{126}'), ('\u{128}', '\u{129}'), ('\u{129}', '\u{128}'), ('\u{12a}', '\u{12b}'), ('\u{12b}', '\u{12a}'), ('\u{12c}', '\u{12d}'), ('\u{12d}', '\u{12c}'), ('\u{12e}', '\u{12f}'), ('\u{12f}', '\u{12e}'), ('\u{132}', '\u{133}'), ('\u{133}', '\u{132}'), ('\u{134}', '\u{135}'), ('\u{135}', '\u{134}'), ('\u{136}', '\u{137}'), ('\u{137}', '\u{136}'), ('\u{139}', '\u{13a}'), ('\u{13a}', '\u{139}'), ('\u{13b}', '\u{13c}'), ('\u{13c}', '\u{13b}'), ('\u{13d}', '\u{13e}'), ('\u{13e}', '\u{13d}'), ('\u{13f}', '\u{140}'), ('\u{140}', '\u{13f}'), ('\u{141}', '\u{142}'), ('\u{142}', '\u{141}'), ('\u{143}', '\u{144}'), ('\u{144}', '\u{143}'), ('\u{145}', '\u{146}'), ('\u{146}', '\u{145}'), ('\u{147}', '\u{148}'), ('\u{148}', '\u{147}'), ('\u{14a}', '\u{14b}'), ('\u{14b}', '\u{14a}'), ('\u{14c}', '\u{14d}'), ('\u{14d}', '\u{14c}'), ('\u{14e}', '\u{14f}'), ('\u{14f}', '\u{14e}'), ('\u{150}', '\u{151}'), ('\u{151}', '\u{150}'), ('\u{152}', '\u{153}'), ('\u{153}', '\u{152}'), ('\u{154}', '\u{155}'), ('\u{155}', '\u{154}'), ('\u{156}', '\u{157}'), ('\u{157}', '\u{156}'), ('\u{158}', '\u{159}'), ('\u{159}', '\u{158}'), ('\u{15a}', '\u{15b}'), ('\u{15b}', '\u{15a}'), ('\u{15c}', '\u{15d}'), ('\u{15d}', '\u{15c}'), ('\u{15e}', '\u{15f}'), ('\u{15f}', '\u{15e}'), ('\u{160}', '\u{161}'), ('\u{161}', '\u{160}'), ('\u{162}', '\u{163}'), ('\u{163}', '\u{162}'), ('\u{164}', '\u{165}'), ('\u{165}', '\u{164}'), ('\u{166}', '\u{167}'), ('\u{167}', '\u{166}'), ('\u{168}', '\u{169}'), ('\u{169}', '\u{168}'), ('\u{16a}', '\u{16b}'), ('\u{16b}', '\u{16a}'), ('\u{16c}', '\u{16d}'), ('\u{16d}', '\u{16c}'), ('\u{16e}', '\u{16f}'), ('\u{16f}', '\u{16e}'), ('\u{170}', '\u{171}'), ('\u{171}', '\u{170}'), ('\u{172}', '\u{173}'), ('\u{173}', '\u{172}'), ('\u{174}', '\u{175}'), ('\u{175}', '\u{174}'), ('\u{176}', '\u{177}'), ('\u{177}', '\u{176}'), ('\u{178}', '\u{ff}'), ('\u{179}', '\u{17a}'), ('\u{17a}', '\u{179}'), ('\u{17b}', '\u{17c}'), ('\u{17c}', '\u{17b}'), ('\u{17d}', '\u{17e}'), ('\u{17e}', '\u{17d}'), ('\u{17f}', '\u{53}'), ('\u{17f}', '\u{73}'), ('\u{180}', '\u{243}'), ('\u{181}', '\u{253}'), ('\u{182}', '\u{183}'), ('\u{183}', '\u{182}'), ('\u{184}', '\u{185}'), ('\u{185}', '\u{184}'), ('\u{186}', '\u{254}'), ('\u{187}', '\u{188}'), ('\u{188}', '\u{187}'), ('\u{189}', '\u{256}'), ('\u{18a}', '\u{257}'), ('\u{18b}', '\u{18c}'), ('\u{18c}', '\u{18b}'), ('\u{18e}', '\u{1dd}'), ('\u{18f}', '\u{259}'), ('\u{190}', '\u{25b}'), ('\u{191}', '\u{192}'), ('\u{192}', '\u{191}'), ('\u{193}', '\u{260}'), ('\u{194}', '\u{263}'), ('\u{195}', '\u{1f6}'), ('\u{196}', '\u{269}'), ('\u{197}', '\u{268}'), ('\u{198}', '\u{199}'), ('\u{199}', '\u{198}'), ('\u{19a}', '\u{23d}'), ('\u{19c}', '\u{26f}'), ('\u{19d}', '\u{272}'), ('\u{19e}', '\u{220}'), ('\u{19f}', '\u{275}'), ('\u{1a0}', '\u{1a1}'), ('\u{1a1}', '\u{1a0}'), ('\u{1a2}', '\u{1a3}'), ('\u{1a3}', '\u{1a2}'), ('\u{1a4}', '\u{1a5}'), ('\u{1a5}', '\u{1a4}'), ('\u{1a6}', '\u{280}'), ('\u{1a7}', '\u{1a8}'), ('\u{1a8}', '\u{1a7}'), ('\u{1a9}', '\u{283}'), ('\u{1ac}', '\u{1ad}'), ('\u{1ad}', '\u{1ac}'), ('\u{1ae}', '\u{288}'), ('\u{1af}', '\u{1b0}'), ('\u{1b0}', '\u{1af}'), ('\u{1b1}', '\u{28a}'), ('\u{1b2}', '\u{28b}'), ('\u{1b3}', '\u{1b4}'), ('\u{1b4}', '\u{1b3}'), ('\u{1b5}', '\u{1b6}'), ('\u{1b6}', '\u{1b5}'), ('\u{1b7}', '\u{292}'), ('\u{1b8}', '\u{1b9}'), ('\u{1b9}', '\u{1b8}'), ('\u{1bc}', '\u{1bd}'), ('\u{1bd}', '\u{1bc}'), ('\u{1bf}', '\u{1f7}'), ('\u{1c4}', '\u{1c5}'), ('\u{1c4}', '\u{1c6}'), ('\u{1c5}', '\u{1c4}'), ('\u{1c5}', '\u{1c6}'), ('\u{1c6}', '\u{1c4}'), ('\u{1c6}', '\u{1c5}'), ('\u{1c7}', '\u{1c8}'), ('\u{1c7}', '\u{1c9}'), ('\u{1c8}', '\u{1c7}'), ('\u{1c8}', '\u{1c9}'), ('\u{1c9}', '\u{1c7}'), ('\u{1c9}', '\u{1c8}'), ('\u{1ca}', '\u{1cb}'), ('\u{1ca}', '\u{1cc}'), ('\u{1cb}', '\u{1ca}'), ('\u{1cb}', '\u{1cc}'), ('\u{1cc}', '\u{1ca}'), ('\u{1cc}', '\u{1cb}'), ('\u{1cd}', '\u{1ce}'), ('\u{1ce}', '\u{1cd}'), ('\u{1cf}', '\u{1d0}'), ('\u{1d0}', '\u{1cf}'), ('\u{1d1}', '\u{1d2}'), ('\u{1d2}', '\u{1d1}'), ('\u{1d3}', '\u{1d4}'), ('\u{1d4}', '\u{1d3}'), ('\u{1d5}', '\u{1d6}'), ('\u{1d6}', '\u{1d5}'), ('\u{1d7}', '\u{1d8}'), ('\u{1d8}', '\u{1d7}'), ('\u{1d9}', '\u{1da}'), ('\u{1da}', '\u{1d9}'), ('\u{1db}', '\u{1dc}'), ('\u{1dc}', '\u{1db}'), ('\u{1dd}', '\u{18e}'), ('\u{1de}', '\u{1df}'), ('\u{1df}', '\u{1de}'), ('\u{1e0}', '\u{1e1}'), ('\u{1e1}', '\u{1e0}'), ('\u{1e2}', '\u{1e3}'), ('\u{1e3}', '\u{1e2}'), ('\u{1e4}', '\u{1e5}'), ('\u{1e5}', '\u{1e4}'), ('\u{1e6}', '\u{1e7}'), ('\u{1e7}', '\u{1e6}'), ('\u{1e8}', '\u{1e9}'), ('\u{1e9}', '\u{1e8}'), ('\u{1ea}', '\u{1eb}'), ('\u{1eb}', '\u{1ea}'), ('\u{1ec}', '\u{1ed}'), ('\u{1ed}', '\u{1ec}'), ('\u{1ee}', '\u{1ef}'), ('\u{1ef}', '\u{1ee}'), ('\u{1f1}', '\u{1f2}'), ('\u{1f1}', '\u{1f3}'), ('\u{1f2}', '\u{1f1}'), ('\u{1f2}', '\u{1f3}'), ('\u{1f3}', '\u{1f1}'), ('\u{1f3}', '\u{1f2}'), ('\u{1f4}', '\u{1f5}'), ('\u{1f5}', '\u{1f4}'), ('\u{1f6}', '\u{195}'), ('\u{1f7}', '\u{1bf}'), ('\u{1f8}', '\u{1f9}'), ('\u{1f9}', '\u{1f8}'), ('\u{1fa}', '\u{1fb}'), ('\u{1fb}', '\u{1fa}'), ('\u{1fc}', '\u{1fd}'), ('\u{1fd}', '\u{1fc}'), ('\u{1fe}', '\u{1ff}'), ('\u{1ff}', '\u{1fe}'), ('\u{200}', '\u{201}'), ('\u{201}', '\u{200}'), ('\u{202}', '\u{203}'), ('\u{203}', '\u{202}'), ('\u{204}', '\u{205}'), ('\u{205}', '\u{204}'), ('\u{206}', '\u{207}'), ('\u{207}', '\u{206}'), ('\u{208}', '\u{209}'), ('\u{209}', '\u{208}'), ('\u{20a}', '\u{20b}'), ('\u{20b}', '\u{20a}'), ('\u{20c}', '\u{20d}'), ('\u{20d}', '\u{20c}'), ('\u{20e}', '\u{20f}'), ('\u{20f}', '\u{20e}'), ('\u{210}', '\u{211}'), ('\u{211}', '\u{210}'), ('\u{212}', '\u{213}'), ('\u{213}', '\u{212}'), ('\u{214}', '\u{215}'), ('\u{215}', '\u{214}'), ('\u{216}', '\u{217}'), ('\u{217}', '\u{216}'), ('\u{218}', '\u{219}'), ('\u{219}', '\u{218}'), ('\u{21a}', '\u{21b}'), ('\u{21b}', '\u{21a}'), ('\u{21c}', '\u{21d}'), ('\u{21d}', '\u{21c}'), ('\u{21e}', '\u{21f}'), ('\u{21f}', '\u{21e}'), ('\u{220}', '\u{19e}'), ('\u{222}', '\u{223}'), ('\u{223}', '\u{222}'), ('\u{224}', '\u{225}'), ('\u{225}', '\u{224}'), ('\u{226}', '\u{227}'), ('\u{227}', '\u{226}'), ('\u{228}', '\u{229}'), ('\u{229}', '\u{228}'), ('\u{22a}', '\u{22b}'), ('\u{22b}', '\u{22a}'), ('\u{22c}', '\u{22d}'), ('\u{22d}', '\u{22c}'), ('\u{22e}', '\u{22f}'), ('\u{22f}', '\u{22e}'), ('\u{230}', '\u{231}'), ('\u{231}', '\u{230}'), ('\u{232}', '\u{233}'), ('\u{233}', '\u{232}'), ('\u{23a}', '\u{2c65}'), ('\u{23b}', '\u{23c}'), ('\u{23c}', '\u{23b}'), ('\u{23d}', '\u{19a}'), ('\u{23e}', '\u{2c66}'), ('\u{23f}', '\u{2c7e}'), ('\u{240}', '\u{2c7f}'), ('\u{241}', '\u{242}'), ('\u{242}', '\u{241}'), ('\u{243}', '\u{180}'), ('\u{244}', '\u{289}'), ('\u{245}', '\u{28c}'), ('\u{246}', '\u{247}'), ('\u{247}', '\u{246}'), ('\u{248}', '\u{249}'), ('\u{249}', '\u{248}'), ('\u{24a}', '\u{24b}'), ('\u{24b}', '\u{24a}'), ('\u{24c}', '\u{24d}'), ('\u{24d}', '\u{24c}'), ('\u{24e}', '\u{24f}'), ('\u{24f}', '\u{24e}'), ('\u{250}', '\u{2c6f}'), ('\u{251}', '\u{2c6d}'), ('\u{252}', '\u{2c70}'), ('\u{253}', '\u{181}'), ('\u{254}', '\u{186}'), ('\u{256}', '\u{189}'), ('\u{257}', '\u{18a}'), ('\u{259}', '\u{18f}'), ('\u{25b}', '\u{190}'), ('\u{25c}', '\u{a7ab}'), ('\u{260}', '\u{193}'), ('\u{261}', '\u{a7ac}'), ('\u{263}', '\u{194}'), ('\u{265}', '\u{a78d}'), ('\u{266}', '\u{a7aa}'), ('\u{268}', '\u{197}'), ('\u{269}', '\u{196}'), ('\u{26b}', '\u{2c62}'), ('\u{26c}', '\u{a7ad}'), ('\u{26f}', '\u{19c}'), ('\u{271}', '\u{2c6e}'), ('\u{272}', '\u{19d}'), ('\u{275}', '\u{19f}'), ('\u{27d}', '\u{2c64}'), ('\u{280}', '\u{1a6}'), ('\u{283}', '\u{1a9}'), ('\u{287}', '\u{a7b1}'), ('\u{288}', '\u{1ae}'), ('\u{289}', '\u{244}'), ('\u{28a}', '\u{1b1}'), ('\u{28b}', '\u{1b2}'), ('\u{28c}', '\u{245}'), ('\u{292}', '\u{1b7}'), ('\u{29d}', '\u{a7b2}'), ('\u{29e}', '\u{a7b0}'), ('\u{345}', '\u{399}'), ('\u{345}', '\u{3b9}'), ('\u{345}', '\u{1fbe}'), ('\u{370}', '\u{371}'), ('\u{371}', '\u{370}'), ('\u{372}', '\u{373}'), ('\u{373}', '\u{372}'), ('\u{376}', '\u{377}'), ('\u{377}', '\u{376}'), ('\u{37b}', '\u{3fd}'), ('\u{37c}', '\u{3fe}'), ('\u{37d}', '\u{3ff}'), ('\u{37f}', '\u{3f3}'), ('\u{386}', '\u{3ac}'), ('\u{388}', '\u{3ad}'), ('\u{389}', '\u{3ae}'), ('\u{38a}', '\u{3af}'), ('\u{38c}', '\u{3cc}'), ('\u{38e}', '\u{3cd}'), ('\u{38f}', '\u{3ce}'), ('\u{391}', '\u{3b1}'), ('\u{392}', '\u{3b2}'), ('\u{392}', '\u{3d0}'), ('\u{393}', '\u{3b3}'), ('\u{394}', '\u{3b4}'), ('\u{395}', '\u{3b5}'), ('\u{395}', '\u{3f5}'), ('\u{396}', '\u{3b6}'), ('\u{397}', '\u{3b7}'), ('\u{398}', '\u{3b8}'), ('\u{398}', '\u{3d1}'), ('\u{398}', '\u{3f4}'), ('\u{399}', '\u{345}'), ('\u{399}', '\u{3b9}'), ('\u{399}', '\u{1fbe}'), ('\u{39a}', '\u{3ba}'), ('\u{39a}', '\u{3f0}'), ('\u{39b}', '\u{3bb}'), ('\u{39c}', '\u{b5}'), ('\u{39c}', '\u{3bc}'), ('\u{39d}', '\u{3bd}'), ('\u{39e}', '\u{3be}'), ('\u{39f}', '\u{3bf}'), ('\u{3a0}', '\u{3c0}'), ('\u{3a0}', '\u{3d6}'), ('\u{3a1}', '\u{3c1}'), ('\u{3a1}', '\u{3f1}'), ('\u{3a3}', '\u{3c2}'), ('\u{3a3}', '\u{3c3}'), ('\u{3a4}', '\u{3c4}'), ('\u{3a5}', '\u{3c5}'), ('\u{3a6}', '\u{3c6}'), ('\u{3a6}', '\u{3d5}'), ('\u{3a7}', '\u{3c7}'), ('\u{3a8}', '\u{3c8}'), ('\u{3a9}', '\u{3c9}'), ('\u{3a9}', '\u{2126}'), ('\u{3aa}', '\u{3ca}'), ('\u{3ab}', '\u{3cb}'), ('\u{3ac}', '\u{386}'), ('\u{3ad}', '\u{388}'), ('\u{3ae}', '\u{389}'), ('\u{3af}', '\u{38a}'), ('\u{3b1}', '\u{391}'), ('\u{3b2}', '\u{392}'), ('\u{3b2}', '\u{3d0}'), ('\u{3b3}', '\u{393}'), ('\u{3b4}', '\u{394}'), ('\u{3b5}', '\u{395}'), ('\u{3b5}', '\u{3f5}'), ('\u{3b6}', '\u{396}'), ('\u{3b7}', '\u{397}'), ('\u{3b8}', '\u{398}'), ('\u{3b8}', '\u{3d1}'), ('\u{3b8}', '\u{3f4}'), ('\u{3b9}', '\u{345}'), ('\u{3b9}', '\u{399}'), ('\u{3b9}', '\u{1fbe}'), ('\u{3ba}', '\u{39a}'), ('\u{3ba}', '\u{3f0}'), ('\u{3bb}', '\u{39b}'), ('\u{3bc}', '\u{b5}'), ('\u{3bc}', '\u{39c}'), ('\u{3bd}', '\u{39d}'), ('\u{3be}', '\u{39e}'), ('\u{3bf}', '\u{39f}'), ('\u{3c0}', '\u{3a0}'), ('\u{3c0}', '\u{3d6}'), ('\u{3c1}', '\u{3a1}'), ('\u{3c1}', '\u{3f1}'), ('\u{3c2}', '\u{3a3}'), ('\u{3c2}', '\u{3c3}'), ('\u{3c3}', '\u{3a3}'), ('\u{3c3}', '\u{3c2}'), ('\u{3c4}', '\u{3a4}'), ('\u{3c5}', '\u{3a5}'), ('\u{3c6}', '\u{3a6}'), ('\u{3c6}', '\u{3d5}'), ('\u{3c7}', '\u{3a7}'), ('\u{3c8}', '\u{3a8}'), ('\u{3c9}', '\u{3a9}'), ('\u{3c9}', '\u{2126}'), ('\u{3ca}', '\u{3aa}'), ('\u{3cb}', '\u{3ab}'), ('\u{3cc}', '\u{38c}'), ('\u{3cd}', '\u{38e}'), ('\u{3ce}', '\u{38f}'), ('\u{3cf}', '\u{3d7}'), ('\u{3d0}', '\u{392}'), ('\u{3d0}', '\u{3b2}'), ('\u{3d1}', '\u{398}'), ('\u{3d1}', '\u{3b8}'), ('\u{3d1}', '\u{3f4}'), ('\u{3d5}', '\u{3a6}'), ('\u{3d5}', '\u{3c6}'), ('\u{3d6}', '\u{3a0}'), ('\u{3d6}', '\u{3c0}'), ('\u{3d7}', '\u{3cf}'), ('\u{3d8}', '\u{3d9}'), ('\u{3d9}', '\u{3d8}'), ('\u{3da}', '\u{3db}'), ('\u{3db}', '\u{3da}'), ('\u{3dc}', '\u{3dd}'), ('\u{3dd}', '\u{3dc}'), ('\u{3de}', '\u{3df}'), ('\u{3df}', '\u{3de}'), ('\u{3e0}', '\u{3e1}'), ('\u{3e1}', '\u{3e0}'), ('\u{3e2}', '\u{3e3}'), ('\u{3e3}', '\u{3e2}'), ('\u{3e4}', '\u{3e5}'), ('\u{3e5}', '\u{3e4}'), ('\u{3e6}', '\u{3e7}'), ('\u{3e7}', '\u{3e6}'), ('\u{3e8}', '\u{3e9}'), ('\u{3e9}', '\u{3e8}'), ('\u{3ea}', '\u{3eb}'), ('\u{3eb}', '\u{3ea}'), ('\u{3ec}', '\u{3ed}'), ('\u{3ed}', '\u{3ec}'), ('\u{3ee}', '\u{3ef}'), ('\u{3ef}', '\u{3ee}'), ('\u{3f0}', '\u{39a}'), ('\u{3f0}', '\u{3ba}'), ('\u{3f1}', '\u{3a1}'), ('\u{3f1}', '\u{3c1}'), ('\u{3f2}', '\u{3f9}'), ('\u{3f3}', '\u{37f}'), ('\u{3f4}', '\u{398}'), ('\u{3f4}', '\u{3b8}'), ('\u{3f4}', '\u{3d1}'), ('\u{3f5}', '\u{395}'), ('\u{3f5}', '\u{3b5}'), ('\u{3f7}', '\u{3f8}'), ('\u{3f8}', '\u{3f7}'), ('\u{3f9}', '\u{3f2}'), ('\u{3fa}', '\u{3fb}'), ('\u{3fb}', '\u{3fa}'), ('\u{3fd}', '\u{37b}'), ('\u{3fe}', '\u{37c}'), ('\u{3ff}', '\u{37d}'), ('\u{400}', '\u{450}'), ('\u{401}', '\u{451}'), ('\u{402}', '\u{452}'), ('\u{403}', '\u{453}'), ('\u{404}', '\u{454}'), ('\u{405}', '\u{455}'), ('\u{406}', '\u{456}'), ('\u{407}', '\u{457}'), ('\u{408}', '\u{458}'), ('\u{409}', '\u{459}'), ('\u{40a}', '\u{45a}'), ('\u{40b}', '\u{45b}'), ('\u{40c}', '\u{45c}'), ('\u{40d}', '\u{45d}'), ('\u{40e}', '\u{45e}'), ('\u{40f}', '\u{45f}'), ('\u{410}', '\u{430}'), ('\u{411}', '\u{431}'), ('\u{412}', '\u{432}'), ('\u{413}', '\u{433}'), ('\u{414}', '\u{434}'), ('\u{415}', '\u{435}'), ('\u{416}', '\u{436}'), ('\u{417}', '\u{437}'), ('\u{418}', '\u{438}'), ('\u{419}', '\u{439}'), ('\u{41a}', '\u{43a}'), ('\u{41b}', '\u{43b}'), ('\u{41c}', '\u{43c}'), ('\u{41d}', '\u{43d}'), ('\u{41e}', '\u{43e}'), ('\u{41f}', '\u{43f}'), ('\u{420}', '\u{440}'), ('\u{421}', '\u{441}'), ('\u{422}', '\u{442}'), ('\u{423}', '\u{443}'), ('\u{424}', '\u{444}'), ('\u{425}', '\u{445}'), ('\u{426}', '\u{446}'), ('\u{427}', '\u{447}'), ('\u{428}', '\u{448}'), ('\u{429}', '\u{449}'), ('\u{42a}', '\u{44a}'), ('\u{42b}', '\u{44b}'), ('\u{42c}', '\u{44c}'), ('\u{42d}', '\u{44d}'), ('\u{42e}', '\u{44e}'), ('\u{42f}', '\u{44f}'), ('\u{430}', '\u{410}'), ('\u{431}', '\u{411}'), ('\u{432}', '\u{412}'), ('\u{433}', '\u{413}'), ('\u{434}', '\u{414}'), ('\u{435}', '\u{415}'), ('\u{436}', '\u{416}'), ('\u{437}', '\u{417}'), ('\u{438}', '\u{418}'), ('\u{439}', '\u{419}'), ('\u{43a}', '\u{41a}'), ('\u{43b}', '\u{41b}'), ('\u{43c}', '\u{41c}'), ('\u{43d}', '\u{41d}'), ('\u{43e}', '\u{41e}'), ('\u{43f}', '\u{41f}'), ('\u{440}', '\u{420}'), ('\u{441}', '\u{421}'), ('\u{442}', '\u{422}'), ('\u{443}', '\u{423}'), ('\u{444}', '\u{424}'), ('\u{445}', '\u{425}'), ('\u{446}', '\u{426}'), ('\u{447}', '\u{427}'), ('\u{448}', '\u{428}'), ('\u{449}', '\u{429}'), ('\u{44a}', '\u{42a}'), ('\u{44b}', '\u{42b}'), ('\u{44c}', '\u{42c}'), ('\u{44d}', '\u{42d}'), ('\u{44e}', '\u{42e}'), ('\u{44f}', '\u{42f}'), ('\u{450}', '\u{400}'), ('\u{451}', '\u{401}'), ('\u{452}', '\u{402}'), ('\u{453}', '\u{403}'), ('\u{454}', '\u{404}'), ('\u{455}', '\u{405}'), ('\u{456}', '\u{406}'), ('\u{457}', '\u{407}'), ('\u{458}', '\u{408}'), ('\u{459}', '\u{409}'), ('\u{45a}', '\u{40a}'), ('\u{45b}', '\u{40b}'), ('\u{45c}', '\u{40c}'), ('\u{45d}', '\u{40d}'), ('\u{45e}', '\u{40e}'), ('\u{45f}', '\u{40f}'), ('\u{460}', '\u{461}'), ('\u{461}', '\u{460}'), ('\u{462}', '\u{463}'), ('\u{463}', '\u{462}'), ('\u{464}', '\u{465}'), ('\u{465}', '\u{464}'), ('\u{466}', '\u{467}'), ('\u{467}', '\u{466}'), ('\u{468}', '\u{469}'), ('\u{469}', '\u{468}'), ('\u{46a}', '\u{46b}'), ('\u{46b}', '\u{46a}'), ('\u{46c}', '\u{46d}'), ('\u{46d}', '\u{46c}'), ('\u{46e}', '\u{46f}'), ('\u{46f}', '\u{46e}'), ('\u{470}', '\u{471}'), ('\u{471}', '\u{470}'), ('\u{472}', '\u{473}'), ('\u{473}', '\u{472}'), ('\u{474}', '\u{475}'), ('\u{475}', '\u{474}'), ('\u{476}', '\u{477}'), ('\u{477}', '\u{476}'), ('\u{478}', '\u{479}'), ('\u{479}', '\u{478}'), ('\u{47a}', '\u{47b}'), ('\u{47b}', '\u{47a}'), ('\u{47c}', '\u{47d}'), ('\u{47d}', '\u{47c}'), ('\u{47e}', '\u{47f}'), ('\u{47f}', '\u{47e}'), ('\u{480}', '\u{481}'), ('\u{481}', '\u{480}'), ('\u{48a}', '\u{48b}'), ('\u{48b}', '\u{48a}'), ('\u{48c}', '\u{48d}'), ('\u{48d}', '\u{48c}'), ('\u{48e}', '\u{48f}'), ('\u{48f}', '\u{48e}'), ('\u{490}', '\u{491}'), ('\u{491}', '\u{490}'), ('\u{492}', '\u{493}'), ('\u{493}', '\u{492}'), ('\u{494}', '\u{495}'), ('\u{495}', '\u{494}'), ('\u{496}', '\u{497}'), ('\u{497}', '\u{496}'), ('\u{498}', '\u{499}'), ('\u{499}', '\u{498}'), ('\u{49a}', '\u{49b}'), ('\u{49b}', '\u{49a}'), ('\u{49c}', '\u{49d}'), ('\u{49d}', '\u{49c}'), ('\u{49e}', '\u{49f}'), ('\u{49f}', '\u{49e}'), ('\u{4a0}', '\u{4a1}'), ('\u{4a1}', '\u{4a0}'), ('\u{4a2}', '\u{4a3}'), ('\u{4a3}', '\u{4a2}'), ('\u{4a4}', '\u{4a5}'), ('\u{4a5}', '\u{4a4}'), ('\u{4a6}', '\u{4a7}'), ('\u{4a7}', '\u{4a6}'), ('\u{4a8}', '\u{4a9}'), ('\u{4a9}', '\u{4a8}'), ('\u{4aa}', '\u{4ab}'), ('\u{4ab}', '\u{4aa}'), ('\u{4ac}', '\u{4ad}'), ('\u{4ad}', '\u{4ac}'), ('\u{4ae}', '\u{4af}'), ('\u{4af}', '\u{4ae}'), ('\u{4b0}', '\u{4b1}'), ('\u{4b1}', '\u{4b0}'), ('\u{4b2}', '\u{4b3}'), ('\u{4b3}', '\u{4b2}'), ('\u{4b4}', '\u{4b5}'), ('\u{4b5}', '\u{4b4}'), ('\u{4b6}', '\u{4b7}'), ('\u{4b7}', '\u{4b6}'), ('\u{4b8}', '\u{4b9}'), ('\u{4b9}', '\u{4b8}'), ('\u{4ba}', '\u{4bb}'), ('\u{4bb}', '\u{4ba}'), ('\u{4bc}', '\u{4bd}'), ('\u{4bd}', '\u{4bc}'), ('\u{4be}', '\u{4bf}'), ('\u{4bf}', '\u{4be}'), ('\u{4c0}', '\u{4cf}'), ('\u{4c1}', '\u{4c2}'), ('\u{4c2}', '\u{4c1}'), ('\u{4c3}', '\u{4c4}'), ('\u{4c4}', '\u{4c3}'), ('\u{4c5}', '\u{4c6}'), ('\u{4c6}', '\u{4c5}'), ('\u{4c7}', '\u{4c8}'), ('\u{4c8}', '\u{4c7}'), ('\u{4c9}', '\u{4ca}'), ('\u{4ca}', '\u{4c9}'), ('\u{4cb}', '\u{4cc}'), ('\u{4cc}', '\u{4cb}'), ('\u{4cd}', '\u{4ce}'), ('\u{4ce}', '\u{4cd}'), ('\u{4cf}', '\u{4c0}'), ('\u{4d0}', '\u{4d1}'), ('\u{4d1}', '\u{4d0}'), ('\u{4d2}', '\u{4d3}'), ('\u{4d3}', '\u{4d2}'), ('\u{4d4}', '\u{4d5}'), ('\u{4d5}', '\u{4d4}'), ('\u{4d6}', '\u{4d7}'), ('\u{4d7}', '\u{4d6}'), ('\u{4d8}', '\u{4d9}'), ('\u{4d9}', '\u{4d8}'), ('\u{4da}', '\u{4db}'), ('\u{4db}', '\u{4da}'), ('\u{4dc}', '\u{4dd}'), ('\u{4dd}', '\u{4dc}'), ('\u{4de}', '\u{4df}'), ('\u{4df}', '\u{4de}'), ('\u{4e0}', '\u{4e1}'), ('\u{4e1}', '\u{4e0}'), ('\u{4e2}', '\u{4e3}'), ('\u{4e3}', '\u{4e2}'), ('\u{4e4}', '\u{4e5}'), ('\u{4e5}', '\u{4e4}'), ('\u{4e6}', '\u{4e7}'), ('\u{4e7}', '\u{4e6}'), ('\u{4e8}', '\u{4e9}'), ('\u{4e9}', '\u{4e8}'), ('\u{4ea}', '\u{4eb}'), ('\u{4eb}', '\u{4ea}'), ('\u{4ec}', '\u{4ed}'), ('\u{4ed}', '\u{4ec}'), ('\u{4ee}', '\u{4ef}'), ('\u{4ef}', '\u{4ee}'), ('\u{4f0}', '\u{4f1}'), ('\u{4f1}', '\u{4f0}'), ('\u{4f2}', '\u{4f3}'), ('\u{4f3}', '\u{4f2}'), ('\u{4f4}', '\u{4f5}'), ('\u{4f5}', '\u{4f4}'), ('\u{4f6}', '\u{4f7}'), ('\u{4f7}', '\u{4f6}'), ('\u{4f8}', '\u{4f9}'), ('\u{4f9}', '\u{4f8}'), ('\u{4fa}', '\u{4fb}'), ('\u{4fb}', '\u{4fa}'), ('\u{4fc}', '\u{4fd}'), ('\u{4fd}', '\u{4fc}'), ('\u{4fe}', '\u{4ff}'), ('\u{4ff}', '\u{4fe}'), ('\u{500}', '\u{501}'), ('\u{501}', '\u{500}'), ('\u{502}', '\u{503}'), ('\u{503}', '\u{502}'), ('\u{504}', '\u{505}'), ('\u{505}', '\u{504}'), ('\u{506}', '\u{507}'), ('\u{507}', '\u{506}'), ('\u{508}', '\u{509}'), ('\u{509}', '\u{508}'), ('\u{50a}', '\u{50b}'), ('\u{50b}', '\u{50a}'), ('\u{50c}', '\u{50d}'), ('\u{50d}', '\u{50c}'), ('\u{50e}', '\u{50f}'), ('\u{50f}', '\u{50e}'), ('\u{510}', '\u{511}'), ('\u{511}', '\u{510}'), ('\u{512}', '\u{513}'), ('\u{513}', '\u{512}'), ('\u{514}', '\u{515}'), ('\u{515}', '\u{514}'), ('\u{516}', '\u{517}'), ('\u{517}', '\u{516}'), ('\u{518}', '\u{519}'), ('\u{519}', '\u{518}'), ('\u{51a}', '\u{51b}'), ('\u{51b}', '\u{51a}'), ('\u{51c}', '\u{51d}'), ('\u{51d}', '\u{51c}'), ('\u{51e}', '\u{51f}'), ('\u{51f}', '\u{51e}'), ('\u{520}', '\u{521}'), ('\u{521}', '\u{520}'), ('\u{522}', '\u{523}'), ('\u{523}', '\u{522}'), ('\u{524}', '\u{525}'), ('\u{525}', '\u{524}'), ('\u{526}', '\u{527}'), ('\u{527}', '\u{526}'), ('\u{528}', '\u{529}'), ('\u{529}', '\u{528}'), ('\u{52a}', '\u{52b}'), ('\u{52b}', '\u{52a}'), ('\u{52c}', '\u{52d}'), ('\u{52d}', '\u{52c}'), ('\u{52e}', '\u{52f}'), ('\u{52f}', '\u{52e}'), ('\u{531}', '\u{561}'), ('\u{532}', '\u{562}'), ('\u{533}', '\u{563}'), ('\u{534}', '\u{564}'), ('\u{535}', '\u{565}'), ('\u{536}', '\u{566}'), ('\u{537}', '\u{567}'), ('\u{538}', '\u{568}'), ('\u{539}', '\u{569}'), ('\u{53a}', '\u{56a}'), ('\u{53b}', '\u{56b}'), ('\u{53c}', '\u{56c}'), ('\u{53d}', '\u{56d}'), ('\u{53e}', '\u{56e}'), ('\u{53f}', '\u{56f}'), ('\u{540}', '\u{570}'), ('\u{541}', '\u{571}'), ('\u{542}', '\u{572}'), ('\u{543}', '\u{573}'), ('\u{544}', '\u{574}'), ('\u{545}', '\u{575}'), ('\u{546}', '\u{576}'), ('\u{547}', '\u{577}'), ('\u{548}', '\u{578}'), ('\u{549}', '\u{579}'), ('\u{54a}', '\u{57a}'), ('\u{54b}', '\u{57b}'), ('\u{54c}', '\u{57c}'), ('\u{54d}', '\u{57d}'), ('\u{54e}', '\u{57e}'), ('\u{54f}', '\u{57f}'), ('\u{550}', '\u{580}'), ('\u{551}', '\u{581}'), ('\u{552}', '\u{582}'), ('\u{553}', '\u{583}'), ('\u{554}', '\u{584}'), ('\u{555}', '\u{585}'), ('\u{556}', '\u{586}'), ('\u{561}', '\u{531}'), ('\u{562}', '\u{532}'), ('\u{563}', '\u{533}'), ('\u{564}', '\u{534}'), ('\u{565}', '\u{535}'), ('\u{566}', '\u{536}'), ('\u{567}', '\u{537}'), ('\u{568}', '\u{538}'), ('\u{569}', '\u{539}'), ('\u{56a}', '\u{53a}'), ('\u{56b}', '\u{53b}'), ('\u{56c}', '\u{53c}'), ('\u{56d}', '\u{53d}'), ('\u{56e}', '\u{53e}'), ('\u{56f}', '\u{53f}'), ('\u{570}', '\u{540}'), ('\u{571}', '\u{541}'), ('\u{572}', '\u{542}'), ('\u{573}', '\u{543}'), ('\u{574}', '\u{544}'), ('\u{575}', '\u{545}'), ('\u{576}', '\u{546}'), ('\u{577}', '\u{547}'), ('\u{578}', '\u{548}'), ('\u{579}', '\u{549}'), ('\u{57a}', '\u{54a}'), ('\u{57b}', '\u{54b}'), ('\u{57c}', '\u{54c}'), ('\u{57d}', '\u{54d}'), ('\u{57e}', '\u{54e}'), ('\u{57f}', '\u{54f}'), ('\u{580}', '\u{550}'), ('\u{581}', '\u{551}'), ('\u{582}', '\u{552}'), ('\u{583}', '\u{553}'), ('\u{584}', '\u{554}'), ('\u{585}', '\u{555}'), ('\u{586}', '\u{556}'), ('\u{10a0}', '\u{2d00}'), ('\u{10a1}', '\u{2d01}'), ('\u{10a2}', '\u{2d02}'), ('\u{10a3}', '\u{2d03}'), ('\u{10a4}', '\u{2d04}'), ('\u{10a5}', '\u{2d05}'), ('\u{10a6}', '\u{2d06}'), ('\u{10a7}', '\u{2d07}'), ('\u{10a8}', '\u{2d08}'), ('\u{10a9}', '\u{2d09}'), ('\u{10aa}', '\u{2d0a}'), ('\u{10ab}', '\u{2d0b}'), ('\u{10ac}', '\u{2d0c}'), ('\u{10ad}', '\u{2d0d}'), ('\u{10ae}', '\u{2d0e}'), ('\u{10af}', '\u{2d0f}'), ('\u{10b0}', '\u{2d10}'), ('\u{10b1}', '\u{2d11}'), ('\u{10b2}', '\u{2d12}'), ('\u{10b3}', '\u{2d13}'), ('\u{10b4}', '\u{2d14}'), ('\u{10b5}', '\u{2d15}'), ('\u{10b6}', '\u{2d16}'), ('\u{10b7}', '\u{2d17}'), ('\u{10b8}', '\u{2d18}'), ('\u{10b9}', '\u{2d19}'), ('\u{10ba}', '\u{2d1a}'), ('\u{10bb}', '\u{2d1b}'), ('\u{10bc}', '\u{2d1c}'), ('\u{10bd}', '\u{2d1d}'), ('\u{10be}', '\u{2d1e}'), ('\u{10bf}', '\u{2d1f}'), ('\u{10c0}', '\u{2d20}'), ('\u{10c1}', '\u{2d21}'), ('\u{10c2}', '\u{2d22}'), ('\u{10c3}', '\u{2d23}'), ('\u{10c4}', '\u{2d24}'), ('\u{10c5}', '\u{2d25}'), ('\u{10c7}', '\u{2d27}'), ('\u{10cd}', '\u{2d2d}'), ('\u{13a0}', '\u{ab70}'), ('\u{13a1}', '\u{ab71}'), ('\u{13a2}', '\u{ab72}'), ('\u{13a3}', '\u{ab73}'), ('\u{13a4}', '\u{ab74}'), ('\u{13a5}', '\u{ab75}'), ('\u{13a6}', '\u{ab76}'), ('\u{13a7}', '\u{ab77}'), ('\u{13a8}', '\u{ab78}'), ('\u{13a9}', '\u{ab79}'), ('\u{13aa}', '\u{ab7a}'), ('\u{13ab}', '\u{ab7b}'), ('\u{13ac}', '\u{ab7c}'), ('\u{13ad}', '\u{ab7d}'), ('\u{13ae}', '\u{ab7e}'), ('\u{13af}', '\u{ab7f}'), ('\u{13b0}', '\u{ab80}'), ('\u{13b1}', '\u{ab81}'), ('\u{13b2}', '\u{ab82}'), ('\u{13b3}', '\u{ab83}'), ('\u{13b4}', '\u{ab84}'), ('\u{13b5}', '\u{ab85}'), ('\u{13b6}', '\u{ab86}'), ('\u{13b7}', '\u{ab87}'), ('\u{13b8}', '\u{ab88}'), ('\u{13b9}', '\u{ab89}'), ('\u{13ba}', '\u{ab8a}'), ('\u{13bb}', '\u{ab8b}'), ('\u{13bc}', '\u{ab8c}'), ('\u{13bd}', '\u{ab8d}'), ('\u{13be}', '\u{ab8e}'), ('\u{13bf}', '\u{ab8f}'), ('\u{13c0}', '\u{ab90}'), ('\u{13c1}', '\u{ab91}'), ('\u{13c2}', '\u{ab92}'), ('\u{13c3}', '\u{ab93}'), ('\u{13c4}', '\u{ab94}'), ('\u{13c5}', '\u{ab95}'), ('\u{13c6}', '\u{ab96}'), ('\u{13c7}', '\u{ab97}'), ('\u{13c8}', '\u{ab98}'), ('\u{13c9}', '\u{ab99}'), ('\u{13ca}', '\u{ab9a}'), ('\u{13cb}', '\u{ab9b}'), ('\u{13cc}', '\u{ab9c}'), ('\u{13cd}', '\u{ab9d}'), ('\u{13ce}', '\u{ab9e}'), ('\u{13cf}', '\u{ab9f}'), ('\u{13d0}', '\u{aba0}'), ('\u{13d1}', '\u{aba1}'), ('\u{13d2}', '\u{aba2}'), ('\u{13d3}', '\u{aba3}'), ('\u{13d4}', '\u{aba4}'), ('\u{13d5}', '\u{aba5}'), ('\u{13d6}', '\u{aba6}'), ('\u{13d7}', '\u{aba7}'), ('\u{13d8}', '\u{aba8}'), ('\u{13d9}', '\u{aba9}'), ('\u{13da}', '\u{abaa}'), ('\u{13db}', '\u{abab}'), ('\u{13dc}', '\u{abac}'), ('\u{13dd}', '\u{abad}'), ('\u{13de}', '\u{abae}'), ('\u{13df}', '\u{abaf}'), ('\u{13e0}', '\u{abb0}'), ('\u{13e1}', '\u{abb1}'), ('\u{13e2}', '\u{abb2}'), ('\u{13e3}', '\u{abb3}'), ('\u{13e4}', '\u{abb4}'), ('\u{13e5}', '\u{abb5}'), ('\u{13e6}', '\u{abb6}'), ('\u{13e7}', '\u{abb7}'), ('\u{13e8}', '\u{abb8}'), ('\u{13e9}', '\u{abb9}'), ('\u{13ea}', '\u{abba}'), ('\u{13eb}', '\u{abbb}'), ('\u{13ec}', '\u{abbc}'), ('\u{13ed}', '\u{abbd}'), ('\u{13ee}', '\u{abbe}'), ('\u{13ef}', '\u{abbf}'), ('\u{13f0}', '\u{13f8}'), ('\u{13f1}', '\u{13f9}'), ('\u{13f2}', '\u{13fa}'), ('\u{13f3}', '\u{13fb}'), ('\u{13f4}', '\u{13fc}'), ('\u{13f5}', '\u{13fd}'), ('\u{13f8}', '\u{13f0}'), ('\u{13f9}', '\u{13f1}'), ('\u{13fa}', '\u{13f2}'), ('\u{13fb}', '\u{13f3}'), ('\u{13fc}', '\u{13f4}'), ('\u{13fd}', '\u{13f5}'), ('\u{1d79}', '\u{a77d}'), ('\u{1d7d}', '\u{2c63}'), ('\u{1e00}', '\u{1e01}'), ('\u{1e01}', '\u{1e00}'), ('\u{1e02}', '\u{1e03}'), ('\u{1e03}', '\u{1e02}'), ('\u{1e04}', '\u{1e05}'), ('\u{1e05}', '\u{1e04}'), ('\u{1e06}', '\u{1e07}'), ('\u{1e07}', '\u{1e06}'), ('\u{1e08}', '\u{1e09}'), ('\u{1e09}', '\u{1e08}'), ('\u{1e0a}', '\u{1e0b}'), ('\u{1e0b}', '\u{1e0a}'), ('\u{1e0c}', '\u{1e0d}'), ('\u{1e0d}', '\u{1e0c}'), ('\u{1e0e}', '\u{1e0f}'), ('\u{1e0f}', '\u{1e0e}'), ('\u{1e10}', '\u{1e11}'), ('\u{1e11}', '\u{1e10}'), ('\u{1e12}', '\u{1e13}'), ('\u{1e13}', '\u{1e12}'), ('\u{1e14}', '\u{1e15}'), ('\u{1e15}', '\u{1e14}'), ('\u{1e16}', '\u{1e17}'), ('\u{1e17}', '\u{1e16}'), ('\u{1e18}', '\u{1e19}'), ('\u{1e19}', '\u{1e18}'), ('\u{1e1a}', '\u{1e1b}'), ('\u{1e1b}', '\u{1e1a}'), ('\u{1e1c}', '\u{1e1d}'), ('\u{1e1d}', '\u{1e1c}'), ('\u{1e1e}', '\u{1e1f}'), ('\u{1e1f}', '\u{1e1e}'), ('\u{1e20}', '\u{1e21}'), ('\u{1e21}', '\u{1e20}'), ('\u{1e22}', '\u{1e23}'), ('\u{1e23}', '\u{1e22}'), ('\u{1e24}', '\u{1e25}'), ('\u{1e25}', '\u{1e24}'), ('\u{1e26}', '\u{1e27}'), ('\u{1e27}', '\u{1e26}'), ('\u{1e28}', '\u{1e29}'), ('\u{1e29}', '\u{1e28}'), ('\u{1e2a}', '\u{1e2b}'), ('\u{1e2b}', '\u{1e2a}'), ('\u{1e2c}', '\u{1e2d}'), ('\u{1e2d}', '\u{1e2c}'), ('\u{1e2e}', '\u{1e2f}'), ('\u{1e2f}', '\u{1e2e}'), ('\u{1e30}', '\u{1e31}'), ('\u{1e31}', '\u{1e30}'), ('\u{1e32}', '\u{1e33}'), ('\u{1e33}', '\u{1e32}'), ('\u{1e34}', '\u{1e35}'), ('\u{1e35}', '\u{1e34}'), ('\u{1e36}', '\u{1e37}'), ('\u{1e37}', '\u{1e36}'), ('\u{1e38}', '\u{1e39}'), ('\u{1e39}', '\u{1e38}'), ('\u{1e3a}', '\u{1e3b}'), ('\u{1e3b}', '\u{1e3a}'), ('\u{1e3c}', '\u{1e3d}'), ('\u{1e3d}', '\u{1e3c}'), ('\u{1e3e}', '\u{1e3f}'), ('\u{1e3f}', '\u{1e3e}'), ('\u{1e40}', '\u{1e41}'), ('\u{1e41}', '\u{1e40}'), ('\u{1e42}', '\u{1e43}'), ('\u{1e43}', '\u{1e42}'), ('\u{1e44}', '\u{1e45}'), ('\u{1e45}', '\u{1e44}'), ('\u{1e46}', '\u{1e47}'), ('\u{1e47}', '\u{1e46}'), ('\u{1e48}', '\u{1e49}'), ('\u{1e49}', '\u{1e48}'), ('\u{1e4a}', '\u{1e4b}'), ('\u{1e4b}', '\u{1e4a}'), ('\u{1e4c}', '\u{1e4d}'), ('\u{1e4d}', '\u{1e4c}'), ('\u{1e4e}', '\u{1e4f}'), ('\u{1e4f}', '\u{1e4e}'), ('\u{1e50}', '\u{1e51}'), ('\u{1e51}', '\u{1e50}'), ('\u{1e52}', '\u{1e53}'), ('\u{1e53}', '\u{1e52}'), ('\u{1e54}', '\u{1e55}'), ('\u{1e55}', '\u{1e54}'), ('\u{1e56}', '\u{1e57}'), ('\u{1e57}', '\u{1e56}'), ('\u{1e58}', '\u{1e59}'), ('\u{1e59}', '\u{1e58}'), ('\u{1e5a}', '\u{1e5b}'), ('\u{1e5b}', '\u{1e5a}'), ('\u{1e5c}', '\u{1e5d}'), ('\u{1e5d}', '\u{1e5c}'), ('\u{1e5e}', '\u{1e5f}'), ('\u{1e5f}', '\u{1e5e}'), ('\u{1e60}', '\u{1e61}'), ('\u{1e60}', '\u{1e9b}'), ('\u{1e61}', '\u{1e60}'), ('\u{1e61}', '\u{1e9b}'), ('\u{1e62}', '\u{1e63}'), ('\u{1e63}', '\u{1e62}'), ('\u{1e64}', '\u{1e65}'), ('\u{1e65}', '\u{1e64}'), ('\u{1e66}', '\u{1e67}'), ('\u{1e67}', '\u{1e66}'), ('\u{1e68}', '\u{1e69}'), ('\u{1e69}', '\u{1e68}'), ('\u{1e6a}', '\u{1e6b}'), ('\u{1e6b}', '\u{1e6a}'), ('\u{1e6c}', '\u{1e6d}'), ('\u{1e6d}', '\u{1e6c}'), ('\u{1e6e}', '\u{1e6f}'), ('\u{1e6f}', '\u{1e6e}'), ('\u{1e70}', '\u{1e71}'), ('\u{1e71}', '\u{1e70}'), ('\u{1e72}', '\u{1e73}'), ('\u{1e73}', '\u{1e72}'), ('\u{1e74}', '\u{1e75}'), ('\u{1e75}', '\u{1e74}'), ('\u{1e76}', '\u{1e77}'), ('\u{1e77}', '\u{1e76}'), ('\u{1e78}', '\u{1e79}'), ('\u{1e79}', '\u{1e78}'), ('\u{1e7a}', '\u{1e7b}'), ('\u{1e7b}', '\u{1e7a}'), ('\u{1e7c}', '\u{1e7d}'), ('\u{1e7d}', '\u{1e7c}'), ('\u{1e7e}', '\u{1e7f}'), ('\u{1e7f}', '\u{1e7e}'), ('\u{1e80}', '\u{1e81}'), ('\u{1e81}', '\u{1e80}'), ('\u{1e82}', '\u{1e83}'), ('\u{1e83}', '\u{1e82}'), ('\u{1e84}', '\u{1e85}'), ('\u{1e85}', '\u{1e84}'), ('\u{1e86}', '\u{1e87}'), ('\u{1e87}', '\u{1e86}'), ('\u{1e88}', '\u{1e89}'), ('\u{1e89}', '\u{1e88}'), ('\u{1e8a}', '\u{1e8b}'), ('\u{1e8b}', '\u{1e8a}'), ('\u{1e8c}', '\u{1e8d}'), ('\u{1e8d}', '\u{1e8c}'), ('\u{1e8e}', '\u{1e8f}'), ('\u{1e8f}', '\u{1e8e}'), ('\u{1e90}', '\u{1e91}'), ('\u{1e91}', '\u{1e90}'), ('\u{1e92}', '\u{1e93}'), ('\u{1e93}', '\u{1e92}'), ('\u{1e94}', '\u{1e95}'), ('\u{1e95}', '\u{1e94}'), ('\u{1e9b}', '\u{1e60}'), ('\u{1e9b}', '\u{1e61}'), ('\u{1e9e}', '\u{df}'), ('\u{1ea0}', '\u{1ea1}'), ('\u{1ea1}', '\u{1ea0}'), ('\u{1ea2}', '\u{1ea3}'), ('\u{1ea3}', '\u{1ea2}'), ('\u{1ea4}', '\u{1ea5}'), ('\u{1ea5}', '\u{1ea4}'), ('\u{1ea6}', '\u{1ea7}'), ('\u{1ea7}', '\u{1ea6}'), ('\u{1ea8}', '\u{1ea9}'), ('\u{1ea9}', '\u{1ea8}'), ('\u{1eaa}', '\u{1eab}'), ('\u{1eab}', '\u{1eaa}'), ('\u{1eac}', '\u{1ead}'), ('\u{1ead}', '\u{1eac}'), ('\u{1eae}', '\u{1eaf}'), ('\u{1eaf}', '\u{1eae}'), ('\u{1eb0}', '\u{1eb1}'), ('\u{1eb1}', '\u{1eb0}'), ('\u{1eb2}', '\u{1eb3}'), ('\u{1eb3}', '\u{1eb2}'), ('\u{1eb4}', '\u{1eb5}'), ('\u{1eb5}', '\u{1eb4}'), ('\u{1eb6}', '\u{1eb7}'), ('\u{1eb7}', '\u{1eb6}'), ('\u{1eb8}', '\u{1eb9}'), ('\u{1eb9}', '\u{1eb8}'), ('\u{1eba}', '\u{1ebb}'), ('\u{1ebb}', '\u{1eba}'), ('\u{1ebc}', '\u{1ebd}'), ('\u{1ebd}', '\u{1ebc}'), ('\u{1ebe}', '\u{1ebf}'), ('\u{1ebf}', '\u{1ebe}'), ('\u{1ec0}', '\u{1ec1}'), ('\u{1ec1}', '\u{1ec0}'), ('\u{1ec2}', '\u{1ec3}'), ('\u{1ec3}', '\u{1ec2}'), ('\u{1ec4}', '\u{1ec5}'), ('\u{1ec5}', '\u{1ec4}'), ('\u{1ec6}', '\u{1ec7}'), ('\u{1ec7}', '\u{1ec6}'), ('\u{1ec8}', '\u{1ec9}'), ('\u{1ec9}', '\u{1ec8}'), ('\u{1eca}', '\u{1ecb}'), ('\u{1ecb}', '\u{1eca}'), ('\u{1ecc}', '\u{1ecd}'), ('\u{1ecd}', '\u{1ecc}'), ('\u{1ece}', '\u{1ecf}'), ('\u{1ecf}', '\u{1ece}'), ('\u{1ed0}', '\u{1ed1}'), ('\u{1ed1}', '\u{1ed0}'), ('\u{1ed2}', '\u{1ed3}'), ('\u{1ed3}', '\u{1ed2}'), ('\u{1ed4}', '\u{1ed5}'), ('\u{1ed5}', '\u{1ed4}'), ('\u{1ed6}', '\u{1ed7}'), ('\u{1ed7}', '\u{1ed6}'), ('\u{1ed8}', '\u{1ed9}'), ('\u{1ed9}', '\u{1ed8}'), ('\u{1eda}', '\u{1edb}'), ('\u{1edb}', '\u{1eda}'), ('\u{1edc}', '\u{1edd}'), ('\u{1edd}', '\u{1edc}'), ('\u{1ede}', '\u{1edf}'), ('\u{1edf}', '\u{1ede}'), ('\u{1ee0}', '\u{1ee1}'), ('\u{1ee1}', '\u{1ee0}'), ('\u{1ee2}', '\u{1ee3}'), ('\u{1ee3}', '\u{1ee2}'), ('\u{1ee4}', '\u{1ee5}'), ('\u{1ee5}', '\u{1ee4}'), ('\u{1ee6}', '\u{1ee7}'), ('\u{1ee7}', '\u{1ee6}'), ('\u{1ee8}', '\u{1ee9}'), ('\u{1ee9}', '\u{1ee8}'), ('\u{1eea}', '\u{1eeb}'), ('\u{1eeb}', '\u{1eea}'), ('\u{1eec}', '\u{1eed}'), ('\u{1eed}', '\u{1eec}'), ('\u{1eee}', '\u{1eef}'), ('\u{1eef}', '\u{1eee}'), ('\u{1ef0}', '\u{1ef1}'), ('\u{1ef1}', '\u{1ef0}'), ('\u{1ef2}', '\u{1ef3}'), ('\u{1ef3}', '\u{1ef2}'), ('\u{1ef4}', '\u{1ef5}'), ('\u{1ef5}', '\u{1ef4}'), ('\u{1ef6}', '\u{1ef7}'), ('\u{1ef7}', '\u{1ef6}'), ('\u{1ef8}', '\u{1ef9}'), ('\u{1ef9}', '\u{1ef8}'), ('\u{1efa}', '\u{1efb}'), ('\u{1efb}', '\u{1efa}'), ('\u{1efc}', '\u{1efd}'), ('\u{1efd}', '\u{1efc}'), ('\u{1efe}', '\u{1eff}'), ('\u{1eff}', '\u{1efe}'), ('\u{1f00}', '\u{1f08}'), ('\u{1f01}', '\u{1f09}'), ('\u{1f02}', '\u{1f0a}'), ('\u{1f03}', '\u{1f0b}'), ('\u{1f04}', '\u{1f0c}'), ('\u{1f05}', '\u{1f0d}'), ('\u{1f06}', '\u{1f0e}'), ('\u{1f07}', '\u{1f0f}'), ('\u{1f08}', '\u{1f00}'), ('\u{1f09}', '\u{1f01}'), ('\u{1f0a}', '\u{1f02}'), ('\u{1f0b}', '\u{1f03}'), ('\u{1f0c}', '\u{1f04}'), ('\u{1f0d}', '\u{1f05}'), ('\u{1f0e}', '\u{1f06}'), ('\u{1f0f}', '\u{1f07}'), ('\u{1f10}', '\u{1f18}'), ('\u{1f11}', '\u{1f19}'), ('\u{1f12}', '\u{1f1a}'), ('\u{1f13}', '\u{1f1b}'), ('\u{1f14}', '\u{1f1c}'), ('\u{1f15}', '\u{1f1d}'), ('\u{1f18}', '\u{1f10}'), ('\u{1f19}', '\u{1f11}'), ('\u{1f1a}', '\u{1f12}'), ('\u{1f1b}', '\u{1f13}'), ('\u{1f1c}', '\u{1f14}'), ('\u{1f1d}', '\u{1f15}'), ('\u{1f20}', '\u{1f28}'), ('\u{1f21}', '\u{1f29}'), ('\u{1f22}', '\u{1f2a}'), ('\u{1f23}', '\u{1f2b}'), ('\u{1f24}', '\u{1f2c}'), ('\u{1f25}', '\u{1f2d}'), ('\u{1f26}', '\u{1f2e}'), ('\u{1f27}', '\u{1f2f}'), ('\u{1f28}', '\u{1f20}'), ('\u{1f29}', '\u{1f21}'), ('\u{1f2a}', '\u{1f22}'), ('\u{1f2b}', '\u{1f23}'), ('\u{1f2c}', '\u{1f24}'), ('\u{1f2d}', '\u{1f25}'), ('\u{1f2e}', '\u{1f26}'), ('\u{1f2f}', '\u{1f27}'), ('\u{1f30}', '\u{1f38}'), ('\u{1f31}', '\u{1f39}'), ('\u{1f32}', '\u{1f3a}'), ('\u{1f33}', '\u{1f3b}'), ('\u{1f34}', '\u{1f3c}'), ('\u{1f35}', '\u{1f3d}'), ('\u{1f36}', '\u{1f3e}'), ('\u{1f37}', '\u{1f3f}'), ('\u{1f38}', '\u{1f30}'), ('\u{1f39}', '\u{1f31}'), ('\u{1f3a}', '\u{1f32}'), ('\u{1f3b}', '\u{1f33}'), ('\u{1f3c}', '\u{1f34}'), ('\u{1f3d}', '\u{1f35}'), ('\u{1f3e}', '\u{1f36}'), ('\u{1f3f}', '\u{1f37}'), ('\u{1f40}', '\u{1f48}'), ('\u{1f41}', '\u{1f49}'), ('\u{1f42}', '\u{1f4a}'), ('\u{1f43}', '\u{1f4b}'), ('\u{1f44}', '\u{1f4c}'), ('\u{1f45}', '\u{1f4d}'), ('\u{1f48}', '\u{1f40}'), ('\u{1f49}', '\u{1f41}'), ('\u{1f4a}', '\u{1f42}'), ('\u{1f4b}', '\u{1f43}'), ('\u{1f4c}', '\u{1f44}'), ('\u{1f4d}', '\u{1f45}'), ('\u{1f51}', '\u{1f59}'), ('\u{1f53}', '\u{1f5b}'), ('\u{1f55}', '\u{1f5d}'), ('\u{1f57}', '\u{1f5f}'), ('\u{1f59}', '\u{1f51}'), ('\u{1f5b}', '\u{1f53}'), ('\u{1f5d}', '\u{1f55}'), ('\u{1f5f}', '\u{1f57}'), ('\u{1f60}', '\u{1f68}'), ('\u{1f61}', '\u{1f69}'), ('\u{1f62}', '\u{1f6a}'), ('\u{1f63}', '\u{1f6b}'), ('\u{1f64}', '\u{1f6c}'), ('\u{1f65}', '\u{1f6d}'), ('\u{1f66}', '\u{1f6e}'), ('\u{1f67}', '\u{1f6f}'), ('\u{1f68}', '\u{1f60}'), ('\u{1f69}', '\u{1f61}'), ('\u{1f6a}', '\u{1f62}'), ('\u{1f6b}', '\u{1f63}'), ('\u{1f6c}', '\u{1f64}'), ('\u{1f6d}', '\u{1f65}'), ('\u{1f6e}', '\u{1f66}'), ('\u{1f6f}', '\u{1f67}'), ('\u{1f70}', '\u{1fba}'), ('\u{1f71}', '\u{1fbb}'), ('\u{1f72}', '\u{1fc8}'), ('\u{1f73}', '\u{1fc9}'), ('\u{1f74}', '\u{1fca}'), ('\u{1f75}', '\u{1fcb}'), ('\u{1f76}', '\u{1fda}'), ('\u{1f77}', '\u{1fdb}'), ('\u{1f78}', '\u{1ff8}'), ('\u{1f79}', '\u{1ff9}'), ('\u{1f7a}', '\u{1fea}'), ('\u{1f7b}', '\u{1feb}'), ('\u{1f7c}', '\u{1ffa}'), ('\u{1f7d}', '\u{1ffb}'), ('\u{1f80}', '\u{1f88}'), ('\u{1f81}', '\u{1f89}'), ('\u{1f82}', '\u{1f8a}'), ('\u{1f83}', '\u{1f8b}'), ('\u{1f84}', '\u{1f8c}'), ('\u{1f85}', '\u{1f8d}'), ('\u{1f86}', '\u{1f8e}'), ('\u{1f87}', '\u{1f8f}'), ('\u{1f88}', '\u{1f80}'), ('\u{1f89}', '\u{1f81}'), ('\u{1f8a}', '\u{1f82}'), ('\u{1f8b}', '\u{1f83}'), ('\u{1f8c}', '\u{1f84}'), ('\u{1f8d}', '\u{1f85}'), ('\u{1f8e}', '\u{1f86}'), ('\u{1f8f}', '\u{1f87}'), ('\u{1f90}', '\u{1f98}'), ('\u{1f91}', '\u{1f99}'), ('\u{1f92}', '\u{1f9a}'), ('\u{1f93}', '\u{1f9b}'), ('\u{1f94}', '\u{1f9c}'), ('\u{1f95}', '\u{1f9d}'), ('\u{1f96}', '\u{1f9e}'), ('\u{1f97}', '\u{1f9f}'), ('\u{1f98}', '\u{1f90}'), ('\u{1f99}', '\u{1f91}'), ('\u{1f9a}', '\u{1f92}'), ('\u{1f9b}', '\u{1f93}'), ('\u{1f9c}', '\u{1f94}'), ('\u{1f9d}', '\u{1f95}'), ('\u{1f9e}', '\u{1f96}'), ('\u{1f9f}', '\u{1f97}'), ('\u{1fa0}', '\u{1fa8}'), ('\u{1fa1}', '\u{1fa9}'), ('\u{1fa2}', '\u{1faa}'), ('\u{1fa3}', '\u{1fab}'), ('\u{1fa4}', '\u{1fac}'), ('\u{1fa5}', '\u{1fad}'), ('\u{1fa6}', '\u{1fae}'), ('\u{1fa7}', '\u{1faf}'), ('\u{1fa8}', '\u{1fa0}'), ('\u{1fa9}', '\u{1fa1}'), ('\u{1faa}', '\u{1fa2}'), ('\u{1fab}', '\u{1fa3}'), ('\u{1fac}', '\u{1fa4}'), ('\u{1fad}', '\u{1fa5}'), ('\u{1fae}', '\u{1fa6}'), ('\u{1faf}', '\u{1fa7}'), ('\u{1fb0}', '\u{1fb8}'), ('\u{1fb1}', '\u{1fb9}'), ('\u{1fb3}', '\u{1fbc}'), ('\u{1fb8}', '\u{1fb0}'), ('\u{1fb9}', '\u{1fb1}'), ('\u{1fba}', '\u{1f70}'), ('\u{1fbb}', '\u{1f71}'), ('\u{1fbc}', '\u{1fb3}'), ('\u{1fbe}', '\u{345}'), ('\u{1fbe}', '\u{399}'), ('\u{1fbe}', '\u{3b9}'), ('\u{1fc3}', '\u{1fcc}'), ('\u{1fc8}', '\u{1f72}'), ('\u{1fc9}', '\u{1f73}'), ('\u{1fca}', '\u{1f74}'), ('\u{1fcb}', '\u{1f75}'), ('\u{1fcc}', '\u{1fc3}'), ('\u{1fd0}', '\u{1fd8}'), ('\u{1fd1}', '\u{1fd9}'), ('\u{1fd8}', '\u{1fd0}'), ('\u{1fd9}', '\u{1fd1}'), ('\u{1fda}', '\u{1f76}'), ('\u{1fdb}', '\u{1f77}'), ('\u{1fe0}', '\u{1fe8}'), ('\u{1fe1}', '\u{1fe9}'), ('\u{1fe5}', '\u{1fec}'), ('\u{1fe8}', '\u{1fe0}'), ('\u{1fe9}', '\u{1fe1}'), ('\u{1fea}', '\u{1f7a}'), ('\u{1feb}', '\u{1f7b}'), ('\u{1fec}', '\u{1fe5}'), ('\u{1ff3}', '\u{1ffc}'), ('\u{1ff8}', '\u{1f78}'), ('\u{1ff9}', '\u{1f79}'), ('\u{1ffa}', '\u{1f7c}'), ('\u{1ffb}', '\u{1f7d}'), ('\u{1ffc}', '\u{1ff3}'), ('\u{2126}', '\u{3a9}'), ('\u{2126}', '\u{3c9}'), ('\u{212a}', '\u{4b}'), ('\u{212a}', '\u{6b}'), ('\u{212b}', '\u{c5}'), ('\u{212b}', '\u{e5}'), ('\u{2132}', '\u{214e}'), ('\u{214e}', '\u{2132}'), ('\u{2160}', '\u{2170}'), ('\u{2161}', '\u{2171}'), ('\u{2162}', '\u{2172}'), ('\u{2163}', '\u{2173}'), ('\u{2164}', '\u{2174}'), ('\u{2165}', '\u{2175}'), ('\u{2166}', '\u{2176}'), ('\u{2167}', '\u{2177}'), ('\u{2168}', '\u{2178}'), ('\u{2169}', '\u{2179}'), ('\u{216a}', '\u{217a}'), ('\u{216b}', '\u{217b}'), ('\u{216c}', '\u{217c}'), ('\u{216d}', '\u{217d}'), ('\u{216e}', '\u{217e}'), ('\u{216f}', '\u{217f}'), ('\u{2170}', '\u{2160}'), ('\u{2171}', '\u{2161}'), ('\u{2172}', '\u{2162}'), ('\u{2173}', '\u{2163}'), ('\u{2174}', '\u{2164}'), ('\u{2175}', '\u{2165}'), ('\u{2176}', '\u{2166}'), ('\u{2177}', '\u{2167}'), ('\u{2178}', '\u{2168}'), ('\u{2179}', '\u{2169}'), ('\u{217a}', '\u{216a}'), ('\u{217b}', '\u{216b}'), ('\u{217c}', '\u{216c}'), ('\u{217d}', '\u{216d}'), ('\u{217e}', '\u{216e}'), ('\u{217f}', '\u{216f}'), ('\u{2183}', '\u{2184}'), ('\u{2184}', '\u{2183}'), ('\u{24b6}', '\u{24d0}'), ('\u{24b7}', '\u{24d1}'), ('\u{24b8}', '\u{24d2}'), ('\u{24b9}', '\u{24d3}'), ('\u{24ba}', '\u{24d4}'), ('\u{24bb}', '\u{24d5}'), ('\u{24bc}', '\u{24d6}'), ('\u{24bd}', '\u{24d7}'), ('\u{24be}', '\u{24d8}'), ('\u{24bf}', '\u{24d9}'), ('\u{24c0}', '\u{24da}'), ('\u{24c1}', '\u{24db}'), ('\u{24c2}', '\u{24dc}'), ('\u{24c3}', '\u{24dd}'), ('\u{24c4}', '\u{24de}'), ('\u{24c5}', '\u{24df}'), ('\u{24c6}', '\u{24e0}'), ('\u{24c7}', '\u{24e1}'), ('\u{24c8}', '\u{24e2}'), ('\u{24c9}', '\u{24e3}'), ('\u{24ca}', '\u{24e4}'), ('\u{24cb}', '\u{24e5}'), ('\u{24cc}', '\u{24e6}'), ('\u{24cd}', '\u{24e7}'), ('\u{24ce}', '\u{24e8}'), ('\u{24cf}', '\u{24e9}'), ('\u{24d0}', '\u{24b6}'), ('\u{24d1}', '\u{24b7}'), ('\u{24d2}', '\u{24b8}'), ('\u{24d3}', '\u{24b9}'), ('\u{24d4}', '\u{24ba}'), ('\u{24d5}', '\u{24bb}'), ('\u{24d6}', '\u{24bc}'), ('\u{24d7}', '\u{24bd}'), ('\u{24d8}', '\u{24be}'), ('\u{24d9}', '\u{24bf}'), ('\u{24da}', '\u{24c0}'), ('\u{24db}', '\u{24c1}'), ('\u{24dc}', '\u{24c2}'), ('\u{24dd}', '\u{24c3}'), ('\u{24de}', '\u{24c4}'), ('\u{24df}', '\u{24c5}'), ('\u{24e0}', '\u{24c6}'), ('\u{24e1}', '\u{24c7}'), ('\u{24e2}', '\u{24c8}'), ('\u{24e3}', '\u{24c9}'), ('\u{24e4}', '\u{24ca}'), ('\u{24e5}', '\u{24cb}'), ('\u{24e6}', '\u{24cc}'), ('\u{24e7}', '\u{24cd}'), ('\u{24e8}', '\u{24ce}'), ('\u{24e9}', '\u{24cf}'), ('\u{2c00}', '\u{2c30}'), ('\u{2c01}', '\u{2c31}'), ('\u{2c02}', '\u{2c32}'), ('\u{2c03}', '\u{2c33}'), ('\u{2c04}', '\u{2c34}'), ('\u{2c05}', '\u{2c35}'), ('\u{2c06}', '\u{2c36}'), ('\u{2c07}', '\u{2c37}'), ('\u{2c08}', '\u{2c38}'), ('\u{2c09}', '\u{2c39}'), ('\u{2c0a}', '\u{2c3a}'), ('\u{2c0b}', '\u{2c3b}'), ('\u{2c0c}', '\u{2c3c}'), ('\u{2c0d}', '\u{2c3d}'), ('\u{2c0e}', '\u{2c3e}'), ('\u{2c0f}', '\u{2c3f}'), ('\u{2c10}', '\u{2c40}'), ('\u{2c11}', '\u{2c41}'), ('\u{2c12}', '\u{2c42}'), ('\u{2c13}', '\u{2c43}'), ('\u{2c14}', '\u{2c44}'), ('\u{2c15}', '\u{2c45}'), ('\u{2c16}', '\u{2c46}'), ('\u{2c17}', '\u{2c47}'), ('\u{2c18}', '\u{2c48}'), ('\u{2c19}', '\u{2c49}'), ('\u{2c1a}', '\u{2c4a}'), ('\u{2c1b}', '\u{2c4b}'), ('\u{2c1c}', '\u{2c4c}'), ('\u{2c1d}', '\u{2c4d}'), ('\u{2c1e}', '\u{2c4e}'), ('\u{2c1f}', '\u{2c4f}'), ('\u{2c20}', '\u{2c50}'), ('\u{2c21}', '\u{2c51}'), ('\u{2c22}', '\u{2c52}'), ('\u{2c23}', '\u{2c53}'), ('\u{2c24}', '\u{2c54}'), ('\u{2c25}', '\u{2c55}'), ('\u{2c26}', '\u{2c56}'), ('\u{2c27}', '\u{2c57}'), ('\u{2c28}', '\u{2c58}'), ('\u{2c29}', '\u{2c59}'), ('\u{2c2a}', '\u{2c5a}'), ('\u{2c2b}', '\u{2c5b}'), ('\u{2c2c}', '\u{2c5c}'), ('\u{2c2d}', '\u{2c5d}'), ('\u{2c2e}', '\u{2c5e}'), ('\u{2c30}', '\u{2c00}'), ('\u{2c31}', '\u{2c01}'), ('\u{2c32}', '\u{2c02}'), ('\u{2c33}', '\u{2c03}'), ('\u{2c34}', '\u{2c04}'), ('\u{2c35}', '\u{2c05}'), ('\u{2c36}', '\u{2c06}'), ('\u{2c37}', '\u{2c07}'), ('\u{2c38}', '\u{2c08}'), ('\u{2c39}', '\u{2c09}'), ('\u{2c3a}', '\u{2c0a}'), ('\u{2c3b}', '\u{2c0b}'), ('\u{2c3c}', '\u{2c0c}'), ('\u{2c3d}', '\u{2c0d}'), ('\u{2c3e}', '\u{2c0e}'), ('\u{2c3f}', '\u{2c0f}'), ('\u{2c40}', '\u{2c10}'), ('\u{2c41}', '\u{2c11}'), ('\u{2c42}', '\u{2c12}'), ('\u{2c43}', '\u{2c13}'), ('\u{2c44}', '\u{2c14}'), ('\u{2c45}', '\u{2c15}'), ('\u{2c46}', '\u{2c16}'), ('\u{2c47}', '\u{2c17}'), ('\u{2c48}', '\u{2c18}'), ('\u{2c49}', '\u{2c19}'), ('\u{2c4a}', '\u{2c1a}'), ('\u{2c4b}', '\u{2c1b}'), ('\u{2c4c}', '\u{2c1c}'), ('\u{2c4d}', '\u{2c1d}'), ('\u{2c4e}', '\u{2c1e}'), ('\u{2c4f}', '\u{2c1f}'), ('\u{2c50}', '\u{2c20}'), ('\u{2c51}', '\u{2c21}'), ('\u{2c52}', '\u{2c22}'), ('\u{2c53}', '\u{2c23}'), ('\u{2c54}', '\u{2c24}'), ('\u{2c55}', '\u{2c25}'), ('\u{2c56}', '\u{2c26}'), ('\u{2c57}', '\u{2c27}'), ('\u{2c58}', '\u{2c28}'), ('\u{2c59}', '\u{2c29}'), ('\u{2c5a}', '\u{2c2a}'), ('\u{2c5b}', '\u{2c2b}'), ('\u{2c5c}', '\u{2c2c}'), ('\u{2c5d}', '\u{2c2d}'), ('\u{2c5e}', '\u{2c2e}'), ('\u{2c60}', '\u{2c61}'), ('\u{2c61}', '\u{2c60}'), ('\u{2c62}', '\u{26b}'), ('\u{2c63}', '\u{1d7d}'), ('\u{2c64}', '\u{27d}'), ('\u{2c65}', '\u{23a}'), ('\u{2c66}', '\u{23e}'), ('\u{2c67}', '\u{2c68}'), ('\u{2c68}', '\u{2c67}'), ('\u{2c69}', '\u{2c6a}'), ('\u{2c6a}', '\u{2c69}'), ('\u{2c6b}', '\u{2c6c}'), ('\u{2c6c}', '\u{2c6b}'), ('\u{2c6d}', '\u{251}'), ('\u{2c6e}', '\u{271}'), ('\u{2c6f}', '\u{250}'), ('\u{2c70}', '\u{252}'), ('\u{2c72}', '\u{2c73}'), ('\u{2c73}', '\u{2c72}'), ('\u{2c75}', '\u{2c76}'), ('\u{2c76}', '\u{2c75}'), ('\u{2c7e}', '\u{23f}'), ('\u{2c7f}', '\u{240}'), ('\u{2c80}', '\u{2c81}'), ('\u{2c81}', '\u{2c80}'), ('\u{2c82}', '\u{2c83}'), ('\u{2c83}', '\u{2c82}'), ('\u{2c84}', '\u{2c85}'), ('\u{2c85}', '\u{2c84}'), ('\u{2c86}', '\u{2c87}'), ('\u{2c87}', '\u{2c86}'), ('\u{2c88}', '\u{2c89}'), ('\u{2c89}', '\u{2c88}'), ('\u{2c8a}', '\u{2c8b}'), ('\u{2c8b}', '\u{2c8a}'), ('\u{2c8c}', '\u{2c8d}'), ('\u{2c8d}', '\u{2c8c}'), ('\u{2c8e}', '\u{2c8f}'), ('\u{2c8f}', '\u{2c8e}'), ('\u{2c90}', '\u{2c91}'), ('\u{2c91}', '\u{2c90}'), ('\u{2c92}', '\u{2c93}'), ('\u{2c93}', '\u{2c92}'), ('\u{2c94}', '\u{2c95}'), ('\u{2c95}', '\u{2c94}'), ('\u{2c96}', '\u{2c97}'), ('\u{2c97}', '\u{2c96}'), ('\u{2c98}', '\u{2c99}'), ('\u{2c99}', '\u{2c98}'), ('\u{2c9a}', '\u{2c9b}'), ('\u{2c9b}', '\u{2c9a}'), ('\u{2c9c}', '\u{2c9d}'), ('\u{2c9d}', '\u{2c9c}'), ('\u{2c9e}', '\u{2c9f}'), ('\u{2c9f}', '\u{2c9e}'), ('\u{2ca0}', '\u{2ca1}'), ('\u{2ca1}', '\u{2ca0}'), ('\u{2ca2}', '\u{2ca3}'), ('\u{2ca3}', '\u{2ca2}'), ('\u{2ca4}', '\u{2ca5}'), ('\u{2ca5}', '\u{2ca4}'), ('\u{2ca6}', '\u{2ca7}'), ('\u{2ca7}', '\u{2ca6}'), ('\u{2ca8}', '\u{2ca9}'), ('\u{2ca9}', '\u{2ca8}'), ('\u{2caa}', '\u{2cab}'), ('\u{2cab}', '\u{2caa}'), ('\u{2cac}', '\u{2cad}'), ('\u{2cad}', '\u{2cac}'), ('\u{2cae}', '\u{2caf}'), ('\u{2caf}', '\u{2cae}'), ('\u{2cb0}', '\u{2cb1}'), ('\u{2cb1}', '\u{2cb0}'), ('\u{2cb2}', '\u{2cb3}'), ('\u{2cb3}', '\u{2cb2}'), ('\u{2cb4}', '\u{2cb5}'), ('\u{2cb5}', '\u{2cb4}'), ('\u{2cb6}', '\u{2cb7}'), ('\u{2cb7}', '\u{2cb6}'), ('\u{2cb8}', '\u{2cb9}'), ('\u{2cb9}', '\u{2cb8}'), ('\u{2cba}', '\u{2cbb}'), ('\u{2cbb}', '\u{2cba}'), ('\u{2cbc}', '\u{2cbd}'), ('\u{2cbd}', '\u{2cbc}'), ('\u{2cbe}', '\u{2cbf}'), ('\u{2cbf}', '\u{2cbe}'), ('\u{2cc0}', '\u{2cc1}'), ('\u{2cc1}', '\u{2cc0}'), ('\u{2cc2}', '\u{2cc3}'), ('\u{2cc3}', '\u{2cc2}'), ('\u{2cc4}', '\u{2cc5}'), ('\u{2cc5}', '\u{2cc4}'), ('\u{2cc6}', '\u{2cc7}'), ('\u{2cc7}', '\u{2cc6}'), ('\u{2cc8}', '\u{2cc9}'), ('\u{2cc9}', '\u{2cc8}'), ('\u{2cca}', '\u{2ccb}'), ('\u{2ccb}', '\u{2cca}'), ('\u{2ccc}', '\u{2ccd}'), ('\u{2ccd}', '\u{2ccc}'), ('\u{2cce}', '\u{2ccf}'), ('\u{2ccf}', '\u{2cce}'), ('\u{2cd0}', '\u{2cd1}'), ('\u{2cd1}', '\u{2cd0}'), ('\u{2cd2}', '\u{2cd3}'), ('\u{2cd3}', '\u{2cd2}'), ('\u{2cd4}', '\u{2cd5}'), ('\u{2cd5}', '\u{2cd4}'), ('\u{2cd6}', '\u{2cd7}'), ('\u{2cd7}', '\u{2cd6}'), ('\u{2cd8}', '\u{2cd9}'), ('\u{2cd9}', '\u{2cd8}'), ('\u{2cda}', '\u{2cdb}'), ('\u{2cdb}', '\u{2cda}'), ('\u{2cdc}', '\u{2cdd}'), ('\u{2cdd}', '\u{2cdc}'), ('\u{2cde}', '\u{2cdf}'), ('\u{2cdf}', '\u{2cde}'), ('\u{2ce0}', '\u{2ce1}'), ('\u{2ce1}', '\u{2ce0}'), ('\u{2ce2}', '\u{2ce3}'), ('\u{2ce3}', '\u{2ce2}'), ('\u{2ceb}', '\u{2cec}'), ('\u{2cec}', '\u{2ceb}'), ('\u{2ced}', '\u{2cee}'), ('\u{2cee}', '\u{2ced}'), ('\u{2cf2}', '\u{2cf3}'), ('\u{2cf3}', '\u{2cf2}'), ('\u{2d00}', '\u{10a0}'), ('\u{2d01}', '\u{10a1}'), ('\u{2d02}', '\u{10a2}'), ('\u{2d03}', '\u{10a3}'), ('\u{2d04}', '\u{10a4}'), ('\u{2d05}', '\u{10a5}'), ('\u{2d06}', '\u{10a6}'), ('\u{2d07}', '\u{10a7}'), ('\u{2d08}', '\u{10a8}'), ('\u{2d09}', '\u{10a9}'), ('\u{2d0a}', '\u{10aa}'), ('\u{2d0b}', '\u{10ab}'), ('\u{2d0c}', '\u{10ac}'), ('\u{2d0d}', '\u{10ad}'), ('\u{2d0e}', '\u{10ae}'), ('\u{2d0f}', '\u{10af}'), ('\u{2d10}', '\u{10b0}'), ('\u{2d11}', '\u{10b1}'), ('\u{2d12}', '\u{10b2}'), ('\u{2d13}', '\u{10b3}'), ('\u{2d14}', '\u{10b4}'), ('\u{2d15}', '\u{10b5}'), ('\u{2d16}', '\u{10b6}'), ('\u{2d17}', '\u{10b7}'), ('\u{2d18}', '\u{10b8}'), ('\u{2d19}', '\u{10b9}'), ('\u{2d1a}', '\u{10ba}'), ('\u{2d1b}', '\u{10bb}'), ('\u{2d1c}', '\u{10bc}'), ('\u{2d1d}', '\u{10bd}'), ('\u{2d1e}', '\u{10be}'), ('\u{2d1f}', '\u{10bf}'), ('\u{2d20}', '\u{10c0}'), ('\u{2d21}', '\u{10c1}'), ('\u{2d22}', '\u{10c2}'), ('\u{2d23}', '\u{10c3}'), ('\u{2d24}', '\u{10c4}'), ('\u{2d25}', '\u{10c5}'), ('\u{2d27}', '\u{10c7}'), ('\u{2d2d}', '\u{10cd}'), ('\u{a640}', '\u{a641}'), ('\u{a641}', '\u{a640}'), ('\u{a642}', '\u{a643}'), ('\u{a643}', '\u{a642}'), ('\u{a644}', '\u{a645}'), ('\u{a645}', '\u{a644}'), ('\u{a646}', '\u{a647}'), ('\u{a647}', '\u{a646}'), ('\u{a648}', '\u{a649}'), ('\u{a649}', '\u{a648}'), ('\u{a64a}', '\u{a64b}'), ('\u{a64b}', '\u{a64a}'), ('\u{a64c}', '\u{a64d}'), ('\u{a64d}', '\u{a64c}'), ('\u{a64e}', '\u{a64f}'), ('\u{a64f}', '\u{a64e}'), ('\u{a650}', '\u{a651}'), ('\u{a651}', '\u{a650}'), ('\u{a652}', '\u{a653}'), ('\u{a653}', '\u{a652}'), ('\u{a654}', '\u{a655}'), ('\u{a655}', '\u{a654}'), ('\u{a656}', '\u{a657}'), ('\u{a657}', '\u{a656}'), ('\u{a658}', '\u{a659}'), ('\u{a659}', '\u{a658}'), ('\u{a65a}', '\u{a65b}'), ('\u{a65b}', '\u{a65a}'), ('\u{a65c}', '\u{a65d}'), ('\u{a65d}', '\u{a65c}'), ('\u{a65e}', '\u{a65f}'), ('\u{a65f}', '\u{a65e}'), ('\u{a660}', '\u{a661}'), ('\u{a661}', '\u{a660}'), ('\u{a662}', '\u{a663}'), ('\u{a663}', '\u{a662}'), ('\u{a664}', '\u{a665}'), ('\u{a665}', '\u{a664}'), ('\u{a666}', '\u{a667}'), ('\u{a667}', '\u{a666}'), ('\u{a668}', '\u{a669}'), ('\u{a669}', '\u{a668}'), ('\u{a66a}', '\u{a66b}'), ('\u{a66b}', '\u{a66a}'), ('\u{a66c}', '\u{a66d}'), ('\u{a66d}', '\u{a66c}'), ('\u{a680}', '\u{a681}'), ('\u{a681}', '\u{a680}'), ('\u{a682}', '\u{a683}'), ('\u{a683}', '\u{a682}'), ('\u{a684}', '\u{a685}'), ('\u{a685}', '\u{a684}'), ('\u{a686}', '\u{a687}'), ('\u{a687}', '\u{a686}'), ('\u{a688}', '\u{a689}'), ('\u{a689}', '\u{a688}'), ('\u{a68a}', '\u{a68b}'), ('\u{a68b}', '\u{a68a}'), ('\u{a68c}', '\u{a68d}'), ('\u{a68d}', '\u{a68c}'), ('\u{a68e}', '\u{a68f}'), ('\u{a68f}', '\u{a68e}'), ('\u{a690}', '\u{a691}'), ('\u{a691}', '\u{a690}'), ('\u{a692}', '\u{a693}'), ('\u{a693}', '\u{a692}'), ('\u{a694}', '\u{a695}'), ('\u{a695}', '\u{a694}'), ('\u{a696}', '\u{a697}'), ('\u{a697}', '\u{a696}'), ('\u{a698}', '\u{a699}'), ('\u{a699}', '\u{a698}'), ('\u{a69a}', '\u{a69b}'), ('\u{a69b}', '\u{a69a}'), ('\u{a722}', '\u{a723}'), ('\u{a723}', '\u{a722}'), ('\u{a724}', '\u{a725}'), ('\u{a725}', '\u{a724}'), ('\u{a726}', '\u{a727}'), ('\u{a727}', '\u{a726}'), ('\u{a728}', '\u{a729}'), ('\u{a729}', '\u{a728}'), ('\u{a72a}', '\u{a72b}'), ('\u{a72b}', '\u{a72a}'), ('\u{a72c}', '\u{a72d}'), ('\u{a72d}', '\u{a72c}'), ('\u{a72e}', '\u{a72f}'), ('\u{a72f}', '\u{a72e}'), ('\u{a732}', '\u{a733}'), ('\u{a733}', '\u{a732}'), ('\u{a734}', '\u{a735}'), ('\u{a735}', '\u{a734}'), ('\u{a736}', '\u{a737}'), ('\u{a737}', '\u{a736}'), ('\u{a738}', '\u{a739}'), ('\u{a739}', '\u{a738}'), ('\u{a73a}', '\u{a73b}'), ('\u{a73b}', '\u{a73a}'), ('\u{a73c}', '\u{a73d}'), ('\u{a73d}', '\u{a73c}'), ('\u{a73e}', '\u{a73f}'), ('\u{a73f}', '\u{a73e}'), ('\u{a740}', '\u{a741}'), ('\u{a741}', '\u{a740}'), ('\u{a742}', '\u{a743}'), ('\u{a743}', '\u{a742}'), ('\u{a744}', '\u{a745}'), ('\u{a745}', '\u{a744}'), ('\u{a746}', '\u{a747}'), ('\u{a747}', '\u{a746}'), ('\u{a748}', '\u{a749}'), ('\u{a749}', '\u{a748}'), ('\u{a74a}', '\u{a74b}'), ('\u{a74b}', '\u{a74a}'), ('\u{a74c}', '\u{a74d}'), ('\u{a74d}', '\u{a74c}'), ('\u{a74e}', '\u{a74f}'), ('\u{a74f}', '\u{a74e}'), ('\u{a750}', '\u{a751}'), ('\u{a751}', '\u{a750}'), ('\u{a752}', '\u{a753}'), ('\u{a753}', '\u{a752}'), ('\u{a754}', '\u{a755}'), ('\u{a755}', '\u{a754}'), ('\u{a756}', '\u{a757}'), ('\u{a757}', '\u{a756}'), ('\u{a758}', '\u{a759}'), ('\u{a759}', '\u{a758}'), ('\u{a75a}', '\u{a75b}'), ('\u{a75b}', '\u{a75a}'), ('\u{a75c}', '\u{a75d}'), ('\u{a75d}', '\u{a75c}'), ('\u{a75e}', '\u{a75f}'), ('\u{a75f}', '\u{a75e}'), ('\u{a760}', '\u{a761}'), ('\u{a761}', '\u{a760}'), ('\u{a762}', '\u{a763}'), ('\u{a763}', '\u{a762}'), ('\u{a764}', '\u{a765}'), ('\u{a765}', '\u{a764}'), ('\u{a766}', '\u{a767}'), ('\u{a767}', '\u{a766}'), ('\u{a768}', '\u{a769}'), ('\u{a769}', '\u{a768}'), ('\u{a76a}', '\u{a76b}'), ('\u{a76b}', '\u{a76a}'), ('\u{a76c}', '\u{a76d}'), ('\u{a76d}', '\u{a76c}'), ('\u{a76e}', '\u{a76f}'), ('\u{a76f}', '\u{a76e}'), ('\u{a779}', '\u{a77a}'), ('\u{a77a}', '\u{a779}'), ('\u{a77b}', '\u{a77c}'), ('\u{a77c}', '\u{a77b}'), ('\u{a77d}', '\u{1d79}'), ('\u{a77e}', '\u{a77f}'), ('\u{a77f}', '\u{a77e}'), ('\u{a780}', '\u{a781}'), ('\u{a781}', '\u{a780}'), ('\u{a782}', '\u{a783}'), ('\u{a783}', '\u{a782}'), ('\u{a784}', '\u{a785}'), ('\u{a785}', '\u{a784}'), ('\u{a786}', '\u{a787}'), ('\u{a787}', '\u{a786}'), ('\u{a78b}', '\u{a78c}'), ('\u{a78c}', '\u{a78b}'), ('\u{a78d}', '\u{265}'), ('\u{a790}', '\u{a791}'), ('\u{a791}', '\u{a790}'), ('\u{a792}', '\u{a793}'), ('\u{a793}', '\u{a792}'), ('\u{a796}', '\u{a797}'), ('\u{a797}', '\u{a796}'), ('\u{a798}', '\u{a799}'), ('\u{a799}', '\u{a798}'), ('\u{a79a}', '\u{a79b}'), ('\u{a79b}', '\u{a79a}'), ('\u{a79c}', '\u{a79d}'), ('\u{a79d}', '\u{a79c}'), ('\u{a79e}', '\u{a79f}'), ('\u{a79f}', '\u{a79e}'), ('\u{a7a0}', '\u{a7a1}'), ('\u{a7a1}', '\u{a7a0}'), ('\u{a7a2}', '\u{a7a3}'), ('\u{a7a3}', '\u{a7a2}'), ('\u{a7a4}', '\u{a7a5}'), ('\u{a7a5}', '\u{a7a4}'), ('\u{a7a6}', '\u{a7a7}'), ('\u{a7a7}', '\u{a7a6}'), ('\u{a7a8}', '\u{a7a9}'), ('\u{a7a9}', '\u{a7a8}'), ('\u{a7aa}', '\u{266}'), ('\u{a7ab}', '\u{25c}'), ('\u{a7ac}', '\u{261}'), ('\u{a7ad}', '\u{26c}'), ('\u{a7b0}', '\u{29e}'), ('\u{a7b1}', '\u{287}'), ('\u{a7b2}', '\u{29d}'), ('\u{a7b3}', '\u{ab53}'), ('\u{a7b4}', '\u{a7b5}'), ('\u{a7b5}', '\u{a7b4}'), ('\u{a7b6}', '\u{a7b7}'), ('\u{a7b7}', '\u{a7b6}'), ('\u{ab53}', '\u{a7b3}'), ('\u{ab70}', '\u{13a0}'), ('\u{ab71}', '\u{13a1}'), ('\u{ab72}', '\u{13a2}'), ('\u{ab73}', '\u{13a3}'), ('\u{ab74}', '\u{13a4}'), ('\u{ab75}', '\u{13a5}'), ('\u{ab76}', '\u{13a6}'), ('\u{ab77}', '\u{13a7}'), ('\u{ab78}', '\u{13a8}'), ('\u{ab79}', '\u{13a9}'), ('\u{ab7a}', '\u{13aa}'), ('\u{ab7b}', '\u{13ab}'), ('\u{ab7c}', '\u{13ac}'), ('\u{ab7d}', '\u{13ad}'), ('\u{ab7e}', '\u{13ae}'), ('\u{ab7f}', '\u{13af}'), ('\u{ab80}', '\u{13b0}'), ('\u{ab81}', '\u{13b1}'), ('\u{ab82}', '\u{13b2}'), ('\u{ab83}', '\u{13b3}'), ('\u{ab84}', '\u{13b4}'), ('\u{ab85}', '\u{13b5}'), ('\u{ab86}', '\u{13b6}'), ('\u{ab87}', '\u{13b7}'), ('\u{ab88}', '\u{13b8}'), ('\u{ab89}', '\u{13b9}'), ('\u{ab8a}', '\u{13ba}'), ('\u{ab8b}', '\u{13bb}'), ('\u{ab8c}', '\u{13bc}'), ('\u{ab8d}', '\u{13bd}'), ('\u{ab8e}', '\u{13be}'), ('\u{ab8f}', '\u{13bf}'), ('\u{ab90}', '\u{13c0}'), ('\u{ab91}', '\u{13c1}'), ('\u{ab92}', '\u{13c2}'), ('\u{ab93}', '\u{13c3}'), ('\u{ab94}', '\u{13c4}'), ('\u{ab95}', '\u{13c5}'), ('\u{ab96}', '\u{13c6}'), ('\u{ab97}', '\u{13c7}'), ('\u{ab98}', '\u{13c8}'), ('\u{ab99}', '\u{13c9}'), ('\u{ab9a}', '\u{13ca}'), ('\u{ab9b}', '\u{13cb}'), ('\u{ab9c}', '\u{13cc}'), ('\u{ab9d}', '\u{13cd}'), ('\u{ab9e}', '\u{13ce}'), ('\u{ab9f}', '\u{13cf}'), ('\u{aba0}', '\u{13d0}'), ('\u{aba1}', '\u{13d1}'), ('\u{aba2}', '\u{13d2}'), ('\u{aba3}', '\u{13d3}'), ('\u{aba4}', '\u{13d4}'), ('\u{aba5}', '\u{13d5}'), ('\u{aba6}', '\u{13d6}'), ('\u{aba7}', '\u{13d7}'), ('\u{aba8}', '\u{13d8}'), ('\u{aba9}', '\u{13d9}'), ('\u{abaa}', '\u{13da}'), ('\u{abab}', '\u{13db}'), ('\u{abac}', '\u{13dc}'), ('\u{abad}', '\u{13dd}'), ('\u{abae}', '\u{13de}'), ('\u{abaf}', '\u{13df}'), ('\u{abb0}', '\u{13e0}'), ('\u{abb1}', '\u{13e1}'), ('\u{abb2}', '\u{13e2}'), ('\u{abb3}', '\u{13e3}'), ('\u{abb4}', '\u{13e4}'), ('\u{abb5}', '\u{13e5}'), ('\u{abb6}', '\u{13e6}'), ('\u{abb7}', '\u{13e7}'), ('\u{abb8}', '\u{13e8}'), ('\u{abb9}', '\u{13e9}'), ('\u{abba}', '\u{13ea}'), ('\u{abbb}', '\u{13eb}'), ('\u{abbc}', '\u{13ec}'), ('\u{abbd}', '\u{13ed}'), ('\u{abbe}', '\u{13ee}'), ('\u{abbf}', '\u{13ef}'), ('\u{ff21}', '\u{ff41}'), ('\u{ff22}', '\u{ff42}'), ('\u{ff23}', '\u{ff43}'), ('\u{ff24}', '\u{ff44}'), ('\u{ff25}', '\u{ff45}'), ('\u{ff26}', '\u{ff46}'), ('\u{ff27}', '\u{ff47}'), ('\u{ff28}', '\u{ff48}'), ('\u{ff29}', '\u{ff49}'), ('\u{ff2a}', '\u{ff4a}'), ('\u{ff2b}', '\u{ff4b}'), ('\u{ff2c}', '\u{ff4c}'), ('\u{ff2d}', '\u{ff4d}'), ('\u{ff2e}', '\u{ff4e}'), ('\u{ff2f}', '\u{ff4f}'), ('\u{ff30}', '\u{ff50}'), ('\u{ff31}', '\u{ff51}'), ('\u{ff32}', '\u{ff52}'), ('\u{ff33}', '\u{ff53}'), ('\u{ff34}', '\u{ff54}'), ('\u{ff35}', '\u{ff55}'), ('\u{ff36}', '\u{ff56}'), ('\u{ff37}', '\u{ff57}'), ('\u{ff38}', '\u{ff58}'), ('\u{ff39}', '\u{ff59}'), ('\u{ff3a}', '\u{ff5a}'), ('\u{ff41}', '\u{ff21}'), ('\u{ff42}', '\u{ff22}'), ('\u{ff43}', '\u{ff23}'), ('\u{ff44}', '\u{ff24}'), ('\u{ff45}', '\u{ff25}'), ('\u{ff46}', '\u{ff26}'), ('\u{ff47}', '\u{ff27}'), ('\u{ff48}', '\u{ff28}'), ('\u{ff49}', '\u{ff29}'), ('\u{ff4a}', '\u{ff2a}'), ('\u{ff4b}', '\u{ff2b}'), ('\u{ff4c}', '\u{ff2c}'), ('\u{ff4d}', '\u{ff2d}'), ('\u{ff4e}', '\u{ff2e}'), ('\u{ff4f}', '\u{ff2f}'), ('\u{ff50}', '\u{ff30}'), ('\u{ff51}', '\u{ff31}'), ('\u{ff52}', '\u{ff32}'), ('\u{ff53}', '\u{ff33}'), ('\u{ff54}', '\u{ff34}'), ('\u{ff55}', '\u{ff35}'), ('\u{ff56}', '\u{ff36}'), ('\u{ff57}', '\u{ff37}'), ('\u{ff58}', '\u{ff38}'), ('\u{ff59}', '\u{ff39}'), ('\u{ff5a}', '\u{ff3a}'), ('\u{10400}', '\u{10428}'), ('\u{10401}', '\u{10429}'), ('\u{10402}', '\u{1042a}'), ('\u{10403}', '\u{1042b}'), ('\u{10404}', '\u{1042c}'), ('\u{10405}', '\u{1042d}'), ('\u{10406}', '\u{1042e}'), ('\u{10407}', '\u{1042f}'), ('\u{10408}', '\u{10430}'), ('\u{10409}', '\u{10431}'), ('\u{1040a}', '\u{10432}'), ('\u{1040b}', '\u{10433}'), ('\u{1040c}', '\u{10434}'), ('\u{1040d}', '\u{10435}'), ('\u{1040e}', '\u{10436}'), ('\u{1040f}', '\u{10437}'), ('\u{10410}', '\u{10438}'), ('\u{10411}', '\u{10439}'), ('\u{10412}', '\u{1043a}'), ('\u{10413}', '\u{1043b}'), ('\u{10414}', '\u{1043c}'), ('\u{10415}', '\u{1043d}'), ('\u{10416}', '\u{1043e}'), ('\u{10417}', '\u{1043f}'), ('\u{10418}', '\u{10440}'), ('\u{10419}', '\u{10441}'), ('\u{1041a}', '\u{10442}'), ('\u{1041b}', '\u{10443}'), ('\u{1041c}', '\u{10444}'), ('\u{1041d}', '\u{10445}'), ('\u{1041e}', '\u{10446}'), ('\u{1041f}', '\u{10447}'), ('\u{10420}', '\u{10448}'), ('\u{10421}', '\u{10449}'), ('\u{10422}', '\u{1044a}'), ('\u{10423}', '\u{1044b}'), ('\u{10424}', '\u{1044c}'), ('\u{10425}', '\u{1044d}'), ('\u{10426}', '\u{1044e}'), ('\u{10427}', '\u{1044f}'), ('\u{10428}', '\u{10400}'), ('\u{10429}', '\u{10401}'), ('\u{1042a}', '\u{10402}'), ('\u{1042b}', '\u{10403}'), ('\u{1042c}', '\u{10404}'), ('\u{1042d}', '\u{10405}'), ('\u{1042e}', '\u{10406}'), ('\u{1042f}', '\u{10407}'), ('\u{10430}', '\u{10408}'), ('\u{10431}', '\u{10409}'), ('\u{10432}', '\u{1040a}'), ('\u{10433}', '\u{1040b}'), ('\u{10434}', '\u{1040c}'), ('\u{10435}', '\u{1040d}'), ('\u{10436}', '\u{1040e}'), ('\u{10437}', '\u{1040f}'), ('\u{10438}', '\u{10410}'), ('\u{10439}', '\u{10411}'), ('\u{1043a}', '\u{10412}'), ('\u{1043b}', '\u{10413}'), ('\u{1043c}', '\u{10414}'), ('\u{1043d}', '\u{10415}'), ('\u{1043e}', '\u{10416}'), ('\u{1043f}', '\u{10417}'), ('\u{10440}', '\u{10418}'), ('\u{10441}', '\u{10419}'), ('\u{10442}', '\u{1041a}'), ('\u{10443}', '\u{1041b}'), ('\u{10444}', '\u{1041c}'), ('\u{10445}', '\u{1041d}'), ('\u{10446}', '\u{1041e}'), ('\u{10447}', '\u{1041f}'), ('\u{10448}', '\u{10420}'), ('\u{10449}', '\u{10421}'), ('\u{1044a}', '\u{10422}'), ('\u{1044b}', '\u{10423}'), ('\u{1044c}', '\u{10424}'), ('\u{1044d}', '\u{10425}'), ('\u{1044e}', '\u{10426}'), ('\u{1044f}', '\u{10427}'), ('\u{10c80}', '\u{10cc0}'), ('\u{10c81}', '\u{10cc1}'), ('\u{10c82}', '\u{10cc2}'), ('\u{10c83}', '\u{10cc3}'), ('\u{10c84}', '\u{10cc4}'), ('\u{10c85}', '\u{10cc5}'), ('\u{10c86}', '\u{10cc6}'), ('\u{10c87}', '\u{10cc7}'), ('\u{10c88}', '\u{10cc8}'), ('\u{10c89}', '\u{10cc9}'), ('\u{10c8a}', '\u{10cca}'), ('\u{10c8b}', '\u{10ccb}'), ('\u{10c8c}', '\u{10ccc}'), ('\u{10c8d}', '\u{10ccd}'), ('\u{10c8e}', '\u{10cce}'), ('\u{10c8f}', '\u{10ccf}'), ('\u{10c90}', '\u{10cd0}'), ('\u{10c91}', '\u{10cd1}'), ('\u{10c92}', '\u{10cd2}'), ('\u{10c93}', '\u{10cd3}'), ('\u{10c94}', '\u{10cd4}'), ('\u{10c95}', '\u{10cd5}'), ('\u{10c96}', '\u{10cd6}'), ('\u{10c97}', '\u{10cd7}'), ('\u{10c98}', '\u{10cd8}'), ('\u{10c99}', '\u{10cd9}'), ('\u{10c9a}', '\u{10cda}'), ('\u{10c9b}', '\u{10cdb}'), ('\u{10c9c}', '\u{10cdc}'), ('\u{10c9d}', '\u{10cdd}'), ('\u{10c9e}', '\u{10cde}'), ('\u{10c9f}', '\u{10cdf}'), ('\u{10ca0}', '\u{10ce0}'), ('\u{10ca1}', '\u{10ce1}'), ('\u{10ca2}', '\u{10ce2}'), ('\u{10ca3}', '\u{10ce3}'), ('\u{10ca4}', '\u{10ce4}'), ('\u{10ca5}', '\u{10ce5}'), ('\u{10ca6}', '\u{10ce6}'), ('\u{10ca7}', '\u{10ce7}'), ('\u{10ca8}', '\u{10ce8}'), ('\u{10ca9}', '\u{10ce9}'), ('\u{10caa}', '\u{10cea}'), ('\u{10cab}', '\u{10ceb}'), ('\u{10cac}', '\u{10cec}'), ('\u{10cad}', '\u{10ced}'), ('\u{10cae}', '\u{10cee}'), ('\u{10caf}', '\u{10cef}'), ('\u{10cb0}', '\u{10cf0}'), ('\u{10cb1}', '\u{10cf1}'), ('\u{10cb2}', '\u{10cf2}'), ('\u{10cc0}', '\u{10c80}'), ('\u{10cc1}', '\u{10c81}'), ('\u{10cc2}', '\u{10c82}'), ('\u{10cc3}', '\u{10c83}'), ('\u{10cc4}', '\u{10c84}'), ('\u{10cc5}', '\u{10c85}'), ('\u{10cc6}', '\u{10c86}'), ('\u{10cc7}', '\u{10c87}'), ('\u{10cc8}', '\u{10c88}'), ('\u{10cc9}', '\u{10c89}'), ('\u{10cca}', '\u{10c8a}'), ('\u{10ccb}', '\u{10c8b}'), ('\u{10ccc}', '\u{10c8c}'), ('\u{10ccd}', '\u{10c8d}'), ('\u{10cce}', '\u{10c8e}'), ('\u{10ccf}', '\u{10c8f}'), ('\u{10cd0}', '\u{10c90}'), ('\u{10cd1}', '\u{10c91}'), ('\u{10cd2}', '\u{10c92}'), ('\u{10cd3}', '\u{10c93}'), ('\u{10cd4}', '\u{10c94}'), ('\u{10cd5}', '\u{10c95}'), ('\u{10cd6}', '\u{10c96}'), ('\u{10cd7}', '\u{10c97}'), ('\u{10cd8}', '\u{10c98}'), ('\u{10cd9}', '\u{10c99}'), ('\u{10cda}', '\u{10c9a}'), ('\u{10cdb}', '\u{10c9b}'), ('\u{10cdc}', '\u{10c9c}'), ('\u{10cdd}', '\u{10c9d}'), ('\u{10cde}', '\u{10c9e}'), ('\u{10cdf}', '\u{10c9f}'), ('\u{10ce0}', '\u{10ca0}'), ('\u{10ce1}', '\u{10ca1}'), ('\u{10ce2}', '\u{10ca2}'), ('\u{10ce3}', '\u{10ca3}'), ('\u{10ce4}', '\u{10ca4}'), ('\u{10ce5}', '\u{10ca5}'), ('\u{10ce6}', '\u{10ca6}'), ('\u{10ce7}', '\u{10ca7}'), ('\u{10ce8}', '\u{10ca8}'), ('\u{10ce9}', '\u{10ca9}'), ('\u{10cea}', '\u{10caa}'), ('\u{10ceb}', '\u{10cab}'), ('\u{10cec}', '\u{10cac}'), ('\u{10ced}', '\u{10cad}'), ('\u{10cee}', '\u{10cae}'), ('\u{10cef}', '\u{10caf}'), ('\u{10cf0}', '\u{10cb0}'), ('\u{10cf1}', '\u{10cb1}'), ('\u{10cf2}', '\u{10cb2}'), ('\u{118a0}', '\u{118c0}'), ('\u{118a1}', '\u{118c1}'), ('\u{118a2}', '\u{118c2}'), ('\u{118a3}', '\u{118c3}'), ('\u{118a4}', '\u{118c4}'), ('\u{118a5}', '\u{118c5}'), ('\u{118a6}', '\u{118c6}'), ('\u{118a7}', '\u{118c7}'), ('\u{118a8}', '\u{118c8}'), ('\u{118a9}', '\u{118c9}'), ('\u{118aa}', '\u{118ca}'), ('\u{118ab}', '\u{118cb}'), ('\u{118ac}', '\u{118cc}'), ('\u{118ad}', '\u{118cd}'), ('\u{118ae}', '\u{118ce}'), ('\u{118af}', '\u{118cf}'), ('\u{118b0}', '\u{118d0}'), ('\u{118b1}', '\u{118d1}'), ('\u{118b2}', '\u{118d2}'), ('\u{118b3}', '\u{118d3}'), ('\u{118b4}', '\u{118d4}'), ('\u{118b5}', '\u{118d5}'), ('\u{118b6}', '\u{118d6}'), ('\u{118b7}', '\u{118d7}'), ('\u{118b8}', '\u{118d8}'), ('\u{118b9}', '\u{118d9}'), ('\u{118ba}', '\u{118da}'), ('\u{118bb}', '\u{118db}'), ('\u{118bc}', '\u{118dc}'), ('\u{118bd}', '\u{118dd}'), ('\u{118be}', '\u{118de}'), ('\u{118bf}', '\u{118df}'), ('\u{118c0}', '\u{118a0}'), ('\u{118c1}', '\u{118a1}'), ('\u{118c2}', '\u{118a2}'), ('\u{118c3}', '\u{118a3}'), ('\u{118c4}', '\u{118a4}'), ('\u{118c5}', '\u{118a5}'), ('\u{118c6}', '\u{118a6}'), ('\u{118c7}', '\u{118a7}'), ('\u{118c8}', '\u{118a8}'), ('\u{118c9}', '\u{118a9}'), ('\u{118ca}', '\u{118aa}'), ('\u{118cb}', '\u{118ab}'), ('\u{118cc}', '\u{118ac}'), ('\u{118cd}', '\u{118ad}'), ('\u{118ce}', '\u{118ae}'), ('\u{118cf}', '\u{118af}'), ('\u{118d0}', '\u{118b0}'), ('\u{118d1}', '\u{118b1}'), ('\u{118d2}', '\u{118b2}'), ('\u{118d3}', '\u{118b3}'), ('\u{118d4}', '\u{118b4}'), ('\u{118d5}', '\u{118b5}'), ('\u{118d6}', '\u{118b6}'), ('\u{118d7}', '\u{118b7}'), ('\u{118d8}', '\u{118b8}'), ('\u{118d9}', '\u{118b9}'), ('\u{118da}', '\u{118ba}'), ('\u{118db}', '\u{118bb}'), ('\u{118dc}', '\u{118bc}'), ('\u{118dd}', '\u{118bd}'), ('\u{118de}', '\u{118be}'), ('\u{118df}', '\u{118bf}') ]; } deps/regex-syntax-0.2.2/Cargo.toml0000644000175000001440000000060312574166611015042 0ustar users[package] name = "regex-syntax" version = "0.2.2" authors = ["The Rust Project Developers"] license = "MIT/Apache-2.0" repository = "https://github.com/rust-lang/regex" documentation = "http://doc.rust-lang.org/regex/regex_syntax/index.html" homepage = "https://github.com/rust-lang/regex" description = "A regular expression parser." [dev-dependencies] quickcheck = "0.2" rand = "0.3" deps/libgit2-sys-0.3.8/0000755000000000000000000000000012666635521013337 5ustar rootrootdeps/libgit2-sys-0.3.8/lib.rs0000664000175000017500000031557112623401410012670 0ustar #![doc(html_root_url = "http://alexcrichton.com/git2-rs")] #![allow(non_camel_case_types)] #![allow(raw_pointer_derive)] extern crate libc; #[cfg(feature = "ssh")] extern crate libssh2_sys as libssh2; #[cfg(all(unix, not(target_os = "macos"), feature = "https"))] extern crate openssl_sys as openssl; extern crate libz_sys as libz; use libc::{c_int, c_char, c_uint, size_t, c_uchar, c_void}; pub const GIT_OID_RAWSZ: usize = 20; pub const GIT_OID_HEXSZ: usize = GIT_OID_RAWSZ * 2; pub const GIT_CLONE_OPTIONS_VERSION: c_uint = 1; pub const GIT_CHECKOUT_OPTIONS_VERSION: c_uint = 1; pub const GIT_MERGE_OPTIONS_VERSION: c_uint = 1; pub const GIT_REMOTE_CALLBACKS_VERSION: c_uint = 1; pub const GIT_STATUS_OPTIONS_VERSION: c_uint = 1; pub const GIT_BLAME_OPTIONS_VERSION: c_uint = 1; #[cfg(target_env = "msvc")] type __enum_ty = i32; #[cfg(not(target_env = "msvc"))] type __enum_ty = u32; macro_rules! git_enum { (pub enum $name:ident { $($variants:tt)* }) => { pub type $name = __enum_ty; git_enum!(gen, $name, 0, $($variants)*); }; (pub enum $name:ident: $t:ty { $($variants:tt)* }) => { pub type $name = $t; git_enum!(gen, $name, 0, $($variants)*); }; (gen, $name:ident, $val:expr, $variant:ident, $($rest:tt)*) => { pub const $variant: $name = $val; git_enum!(gen, $name, $val+1, $($rest)*); }; (gen, $name:ident, $val:expr, $variant:ident = $e:expr, $($rest:tt)*) => { pub const $variant: $name = $e; git_enum!(gen, $name, $e+1, $($rest)*); }; (gen, $name:ident, $val:expr, ) => {} } pub enum git_blob {} pub enum git_branch_iterator {} pub enum git_blame {} pub enum git_commit {} pub enum git_config {} pub enum git_config_iterator {} pub enum git_index {} pub enum git_object {} pub enum git_reference {} pub enum git_reference_iterator {} pub enum git_annotated_commit {} pub enum git_refspec {} pub enum git_remote {} pub enum git_repository {} pub enum git_revwalk {} pub enum git_submodule {} pub enum git_tag {} pub enum git_tree {} pub enum git_tree_entry {} pub enum git_treebuilder {} pub enum git_push {} pub enum git_note {} pub enum git_note_iterator {} pub enum git_status_list {} pub enum git_pathspec {} pub enum git_pathspec_match_list {} pub enum git_diff {} pub enum git_diff_stats {} pub enum git_reflog {} pub enum git_reflog_entry {} pub enum git_describe_result {} #[repr(C)] pub struct git_revspec { pub from: *mut git_object, pub to: *mut git_object, pub flags: c_uint, } #[repr(C)] pub struct git_error { pub message: *mut c_char, pub klass: c_int, } #[repr(C)] #[derive(Copy, Clone)] pub struct git_oid { pub id: [u8; GIT_OID_RAWSZ], } #[repr(C)] #[derive(Copy)] pub struct git_strarray { pub strings: *mut *mut c_char, pub count: size_t, } impl Clone for git_strarray { fn clone(&self) -> git_strarray { *self } } #[repr(C)] #[derive(Copy)] pub struct git_oidarray { pub ids: *mut git_oid, pub count: size_t, } impl Clone for git_oidarray { fn clone(&self) -> git_oidarray { *self } } #[repr(C)] pub struct git_signature { pub name: *mut c_char, pub email: *mut c_char, pub when: git_time, } #[repr(C)] #[derive(Copy, Clone, Eq, PartialEq)] pub struct git_time { pub time: git_time_t, pub offset: c_int, } pub type git_off_t = i64; pub type git_time_t = i64; git_enum! { pub enum git_revparse_mode_t { GIT_REVPARSE_SINGLE = 1 << 0, GIT_REVPARSE_RANGE = 1 << 1, GIT_REVPARSE_MERGE_BASE = 1 << 2, } } git_enum! { pub enum git_error_code: c_int { GIT_OK = 0, GIT_ERROR = -1, GIT_ENOTFOUND = -3, GIT_EEXISTS = -4, GIT_EAMBIGUOUS = -5, GIT_EBUFS = -6, GIT_EUSER = -7, GIT_EBAREREPO = -8, GIT_EUNBORNBRANCH = -9, GIT_EUNMERGED = -10, GIT_ENONFASTFORWARD = -11, GIT_EINVALIDSPEC = -12, GIT_ECONFLICT = -13, GIT_ELOCKED = -14, GIT_EMODIFIED = -15, GIT_EAUTH = -16, GIT_ECERTIFICATE = -17, GIT_EAPPLIED = -18, GIT_EPEEL = -19, GIT_EEOF = -20, GIT_EINVALID = -21, GIT_EUNCOMMITTED = -22, GIT_EDIRECTORY = -23, GIT_PASSTHROUGH = -30, GIT_ITEROVER = -31, } } git_enum! { pub enum git_error_t { GITERR_NONE = 0, GITERR_NOMEMORY, GITERR_OS, GITERR_INVALID, GITERR_REFERENCE, GITERR_ZLIB, GITERR_REPOSITORY, GITERR_CONFIG, GITERR_REGEX, GITERR_ODB, GITERR_INDEX, GITERR_OBJECT, GITERR_NET, GITERR_TAG, GITERR_TREE, GITERR_INDEXER, GITERR_SSL, GITERR_SUBMODULE, GITERR_THREAD, GITERR_STASH, GITERR_CHECKOUT, GITERR_FETCHHEAD, GITERR_MERGE, GITERR_SSH, GITERR_FILTER, GITERR_REVERT, GITERR_CALLBACK, GITERR_CHERRYPICK, GITERR_DESCRIBE, GITERR_REBASE, GITERR_FILESYSTEM, } } git_enum! { pub enum git_repository_state_t { GIT_REPOSITORY_STATE_NONE, GIT_REPOSITORY_STATE_MERGE, GIT_REPOSITORY_STATE_REVERT, GIT_REPOSITORY_STATE_CHERRYPICK, GIT_REPOSITORY_STATE_BISECT, GIT_REPOSITORY_STATE_REBASE, GIT_REPOSITORY_STATE_REBASE_INTERACTIVE, GIT_REPOSITORY_STATE_REBASE_MERGE, GIT_REPOSITORY_STATE_APPLY_MAILBOX, GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE, } } git_enum! { pub enum git_direction { GIT_DIRECTION_FETCH, GIT_DIRECTION_PUSH, } } #[repr(C)] pub struct git_clone_options { pub version: c_uint, pub checkout_opts: git_checkout_options, pub fetch_opts: git_fetch_options, pub bare: c_int, pub local: git_clone_local_t, pub checkout_branch: *const c_char, pub repository_cb: Option, pub repository_cb_payload: *mut c_void, pub remote_cb: Option, pub remote_cb_payload: *mut c_void, } git_enum! { pub enum git_clone_local_t { GIT_CLONE_LOCAL_AUTO, GIT_CLONE_LOCAL, GIT_CLONE_NO_LOCAL, GIT_CLONE_LOCAL_NO_LINKS, } } #[repr(C)] pub struct git_checkout_options { pub version: c_uint, pub checkout_strategy: c_uint, pub disable_filters: c_int, pub dir_mode: c_uint, pub file_mode: c_uint, pub file_open_flags: c_int, pub notify_flags: c_uint, pub notify_cb: Option, pub notify_payload: *mut c_void, pub progress_cb: Option, pub progress_payload: *mut c_void, pub paths: git_strarray, pub baseline: *mut git_tree, pub baseline_index: *mut git_index, pub target_directory: *const c_char, pub ancestor_label: *const c_char, pub our_label: *const c_char, pub their_label: *const c_char, pub perfdata_cb: Option, pub perfdata_payload: *mut c_void, } pub type git_checkout_notify_cb = extern fn(git_checkout_notify_t, *const c_char, *const git_diff_file, *const git_diff_file, *const git_diff_file, *mut c_void) -> c_int; pub type git_checkout_progress_cb = extern fn(*const c_char, size_t, size_t, *mut c_void); pub type git_checkout_perfdata_cb = extern fn(*const git_checkout_perfdata, *mut c_void); #[repr(C)] pub struct git_checkout_perfdata { pub mkdir_calls: size_t, pub stat_calls: size_t, pub chmod_calls: size_t, } #[repr(C)] pub struct git_remote_callbacks { pub version: c_uint, pub sideband_progress: Option, pub completion: Option c_int>, pub credentials: Option, pub certificate_check: Option, pub transfer_progress: Option, pub update_tips: Option c_int>, pub pack_progress: Option, pub push_transfer_progress: Option, pub push_update_reference: Option c_int>, pub push_negotiation: Option, pub transport: Option, pub payload: *mut c_void, } #[repr(C)] pub struct git_fetch_options { pub version: c_int, pub callbacks: git_remote_callbacks, pub prune: git_fetch_prune_t, pub update_fetchhead: c_int, pub download_tags: git_remote_autotag_option_t, pub custom_headers: git_strarray, } git_enum! { pub enum git_remote_autotag_option_t { GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED, GIT_REMOTE_DOWNLOAD_TAGS_AUTO, GIT_REMOTE_DOWNLOAD_TAGS_NONE, GIT_REMOTE_DOWNLOAD_TAGS_ALL, } } git_enum! { pub enum git_fetch_prune_t { GIT_FETCH_PRUNE_UNSPECIFIED, GIT_FETCH_PRUNE, GIT_FETCH_NO_PRUNE, } } git_enum! { pub enum git_remote_completion_type { GIT_REMOTE_COMPLETION_DOWNLOAD, GIT_REMOTE_COMPLETION_INDEXING, GIT_REMOTE_COMPLETION_ERROR, } } pub type git_transport_message_cb = extern fn(*const c_char, c_int, *mut c_void) -> c_int; pub type git_cred_acquire_cb = extern fn(*mut *mut git_cred, *const c_char, *const c_char, c_uint, *mut c_void) -> c_int; pub type git_transfer_progress_cb = extern fn(*const git_transfer_progress, *mut c_void) -> c_int; pub type git_packbuilder_progress = extern fn(c_int, c_uint, c_uint, *mut c_void) -> c_int; pub type git_push_transfer_progress = extern fn(c_uint, c_uint, size_t, *mut c_void) -> c_int; pub type git_transport_certificate_check_cb = extern fn(*mut git_cert, c_int, *const c_char, *mut c_void) -> c_int; pub type git_push_negotiation = extern fn(*mut *const git_push_update, size_t, *mut c_void) -> c_int; #[repr(C)] pub struct git_push_update { pub src_refname: *mut c_char, pub dst_refname: *mut c_char, pub src: git_oid, pub dst: git_oid, } git_enum! { pub enum git_cert_t { GIT_CERT_NONE, GIT_CERT_X509, GIT_CERT_HOSTKEY_LIBSSH2, } } #[repr(C)] pub struct git_cert { pub cert_type: git_cert_t, } #[repr(C)] pub struct git_cert_hostkey { pub parent: git_cert, pub kind: git_cert_ssh_t, pub hash_md5: [u8; 16], pub hash_sha1: [u8; 20], } #[repr(C)] pub struct git_cert_x509 { pub parent: git_cert, pub data: *mut c_void, pub len: size_t, } git_enum! { pub enum git_cert_ssh_t { GIT_CERT_SSH_MD5 = 1 << 0, GIT_CERT_SSH_SHA1 = 1 << 1, } } #[repr(C)] #[derive(Copy, Clone)] pub struct git_transfer_progress { pub total_objects: c_uint, pub indexed_objects: c_uint, pub received_objects: c_uint, pub local_objects: c_uint, pub total_deltas: c_uint, pub indexed_deltas: c_uint, pub received_bytes: size_t, } #[repr(C)] pub struct git_diff_file { pub id: git_oid, pub path: *const c_char, pub size: git_off_t, pub flags: u32, pub mode: u16, } pub type git_repository_create_cb = extern fn(*mut *mut git_repository, *const c_char, c_int, *mut c_void) -> c_int; pub type git_remote_create_cb = extern fn(*mut *mut git_remote, *mut git_repository, *const c_char, *const c_char, *mut c_void) -> c_int; git_enum! { pub enum git_checkout_notify_t { GIT_CHECKOUT_NOTIFY_NONE = 0, GIT_CHECKOUT_NOTIFY_CONFLICT = (1 << 0), GIT_CHECKOUT_NOTIFY_DIRTY = (1 << 1), GIT_CHECKOUT_NOTIFY_UPDATED = (1 << 2), GIT_CHECKOUT_NOTIFY_UNTRACKED = (1 << 3), GIT_CHECKOUT_NOTIFY_IGNORED = (1 << 4), GIT_CHECKOUT_NOTIFY_ALL = 0x0FFFF, } } git_enum! { pub enum git_status_t { GIT_STATUS_CURRENT = 0, GIT_STATUS_INDEX_NEW = (1 << 0), GIT_STATUS_INDEX_MODIFIED = (1 << 1), GIT_STATUS_INDEX_DELETED = (1 << 2), GIT_STATUS_INDEX_RENAMED = (1 << 3), GIT_STATUS_INDEX_TYPECHANGE = (1 << 4), GIT_STATUS_WT_NEW = (1 << 7), GIT_STATUS_WT_MODIFIED = (1 << 8), GIT_STATUS_WT_DELETED = (1 << 9), GIT_STATUS_WT_TYPECHANGE = (1 << 10), GIT_STATUS_WT_RENAMED = (1 << 11), GIT_STATUS_WT_UNREADABLE = (1 << 12), GIT_STATUS_IGNORED = (1 << 14), GIT_STATUS_CONFLICTED = (1 << 15), } } git_enum! { pub enum git_status_opt_t { GIT_STATUS_OPT_INCLUDE_UNTRACKED = (1 << 0), GIT_STATUS_OPT_INCLUDE_IGNORED = (1 << 1), GIT_STATUS_OPT_INCLUDE_UNMODIFIED = (1 << 2), GIT_STATUS_OPT_EXCLUDE_SUBMODULES = (1 << 3), GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS = (1 << 4), GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH = (1 << 5), GIT_STATUS_OPT_RECURSE_IGNORED_DIRS = (1 << 6), GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX = (1 << 7), GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR = (1 << 8), GIT_STATUS_OPT_SORT_CASE_SENSITIVELY = (1 << 9), GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY = (1 << 10), GIT_STATUS_OPT_RENAMES_FROM_REWRITES = (1 << 11), GIT_STATUS_OPT_NO_REFRESH = (1 << 12), GIT_STATUS_OPT_UPDATE_INDEX = (1 << 13), GIT_STATUS_OPT_INCLUDE_UNREADABLE = (1 << 14), GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED = (1 << 15), } } git_enum! { pub enum git_status_show_t { GIT_STATUS_SHOW_INDEX_AND_WORKDIR = 0, GIT_STATUS_SHOW_INDEX_ONLY = 1, GIT_STATUS_SHOW_WORKDIR_ONLY = 2, } } git_enum! { pub enum git_delta_t { GIT_DELTA_UNMODIFIED, GIT_DELTA_ADDED, GIT_DELTA_DELETED, GIT_DELTA_MODIFIED, GIT_DELTA_RENAMED, GIT_DELTA_COPIED, GIT_DELTA_IGNORED, GIT_DELTA_UNTRACKED, GIT_DELTA_TYPECHANGE, GIT_DELTA_UNREADABLE, GIT_DELTA_CONFLICTED, } } #[repr(C)] pub struct git_status_options { pub version: c_uint, pub show: git_status_show_t, pub flags: c_uint, pub pathspec: git_strarray, } pub use git_status_show_t::*; #[repr(C)] pub struct git_diff_delta { pub status: git_delta_t, pub flags: u32, pub similarity: u16, pub nfiles: u16, pub old_file: git_diff_file, pub new_file: git_diff_file, } #[repr(C)] pub struct git_status_entry { pub status: git_status_t, pub head_to_index: *mut git_diff_delta, pub index_to_workdir: *mut git_diff_delta } git_enum! { pub enum git_checkout_strategy_t { GIT_CHECKOUT_NONE = 0, GIT_CHECKOUT_SAFE = (1 << 0), GIT_CHECKOUT_FORCE = (1 << 1), GIT_CHECKOUT_ALLOW_CONFLICTS = (1 << 4), GIT_CHECKOUT_REMOVE_UNTRACKED = (1 << 5), GIT_CHECKOUT_REMOVE_IGNORED = (1 << 6), GIT_CHECKOUT_UPDATE_ONLY = (1 << 7), GIT_CHECKOUT_DONT_UPDATE_INDEX = (1 << 8), GIT_CHECKOUT_NO_REFRESH = (1 << 9), GIT_CHECKOUT_SKIP_UNMERGED = (1 << 10), GIT_CHECKOUT_USE_OURS = (1 << 11), GIT_CHECKOUT_USE_THEIRS = (1 << 12), GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH = (1 << 13), GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES = (1 << 18), GIT_CHECKOUT_DONT_OVERWRITE_IGNORED = (1 << 19), GIT_CHECKOUT_CONFLICT_STYLE_MERGE = (1 << 20), GIT_CHECKOUT_CONFLICT_STYLE_DIFF3 = (1 << 21), GIT_CHECKOUT_UPDATE_SUBMODULES = (1 << 16), GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = (1 << 17), } } git_enum! { pub enum git_reset_t { GIT_RESET_SOFT = 1, GIT_RESET_MIXED = 2, GIT_RESET_HARD = 3, } } git_enum! { pub enum git_otype: c_int { GIT_OBJ_ANY = -2, GIT_OBJ_BAD = -1, GIT_OBJ__EXT1 = 0, GIT_OBJ_COMMIT = 1, GIT_OBJ_TREE = 2, GIT_OBJ_BLOB = 3, GIT_OBJ_TAG = 4, GIT_OBJ__EXT2 = 5, GIT_OBJ_OFS_DELTA = 6, GIT_OBJ_REF_DELTA = 7, } } git_enum! { pub enum git_ref_t { GIT_REF_INVALID = 0, GIT_REF_OID = 1, GIT_REF_SYMBOLIC = 2, GIT_REF_LISTALL = GIT_REF_OID | GIT_REF_SYMBOLIC, } } git_enum! { pub enum git_filemode_t { GIT_FILEMODE_UNREADABLE = 0o000000, GIT_FILEMODE_TREE = 0o040000, GIT_FILEMODE_BLOB = 0o100644, GIT_FILEMODE_BLOB_EXECUTABLE = 0o100755, GIT_FILEMODE_LINK = 0o120000, GIT_FILEMODE_COMMIT = 0o160000, } } git_enum! { pub enum git_treewalk_mode { GIT_TREEWALK_PRE = 0, GIT_TREEWALK_POST = 1, } } pub type git_treewalk_cb = extern fn(*const c_char, *const git_tree_entry, *mut c_void) -> c_int; pub type git_treebuilder_filter_cb = extern fn(*const git_tree_entry, *mut c_void) -> c_int; #[repr(C)] #[derive(Copy, Clone)] pub struct git_buf { pub ptr: *mut c_char, pub asize: size_t, pub size: size_t, } git_enum! { pub enum git_branch_t { GIT_BRANCH_LOCAL = 1, GIT_BRANCH_REMOTE = 2, GIT_BRANCH_ALL = GIT_BRANCH_LOCAL | GIT_BRANCH_REMOTE, } } pub const GIT_BLAME_NORMAL: u32 = 0; pub const GIT_BLAME_TRACK_COPIES_SAME_FILE: u32 = 1<<0; pub const GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES: u32 = 1<<1; pub const GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES: u32 = 1<<2; pub const GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES: u32 = 1<<3; pub const GIT_BLAME_FIRST_PARENT: u32 = 1<<4; #[repr(C)] #[derive(Copy, Clone)] pub struct git_blame_options { pub version: c_uint, pub flags: u32, pub min_match_characters: u16, pub newest_commit: git_oid, pub oldest_commit: git_oid, pub min_line: u32, pub max_line: u32, } #[repr(C)] #[derive(Copy, Clone)] pub struct git_blame_hunk { pub lines_in_hunk: u16, pub final_commit_id: git_oid, pub final_start_line_number: u16, pub final_signature: *mut git_signature, pub orig_commit_id: git_oid, pub orig_path: *const c_char, pub orig_start_line_number: u16, pub orig_signature: *mut git_signature, pub boundary: c_char, } pub type git_index_matched_path_cb = extern fn(*const c_char, *const c_char, *mut c_void) -> c_int; #[repr(C)] #[derive(Copy, Clone)] pub struct git_index_entry { pub ctime: git_index_time, pub mtime: git_index_time, pub dev: u32, pub ino: u32, pub mode: u32, pub uid: u32, pub gid: u32, pub file_size: u32, pub id: git_oid, pub flags: u16, pub flags_extended: u16, pub path: *const c_char, } #[repr(C)] #[derive(Copy, Clone, Eq, PartialEq)] pub struct git_index_time { pub seconds: i32, pub nanoseconds: u32, } #[repr(C)] pub struct git_config_entry { pub name: *const c_char, pub value: *const c_char, pub level: git_config_level_t, pub free: extern fn(*mut git_config_entry), pub payload: *mut c_void, } git_enum! { pub enum git_config_level_t: c_int { GIT_CONFIG_LEVEL_SYSTEM = 1, GIT_CONFIG_LEVEL_XDG = 2, GIT_CONFIG_LEVEL_GLOBAL = 3, GIT_CONFIG_LEVEL_LOCAL = 4, GIT_CONFIG_LEVEL_APP = 5, GIT_CONFIG_HIGHEST_LEVEL = -1, } } git_enum! { pub enum git_submodule_update_t { GIT_SUBMODULE_UPDATE_CHECKOUT = 1, GIT_SUBMODULE_UPDATE_REBASE = 2, GIT_SUBMODULE_UPDATE_MERGE = 3, GIT_SUBMODULE_UPDATE_NONE = 4, GIT_SUBMODULE_UPDATE_DEFAULT = 0, } } git_enum! { pub enum git_submodule_ignore_t: c_int { GIT_SUBMODULE_IGNORE_UNSPECIFIED = -1, GIT_SUBMODULE_IGNORE_NONE = 1, GIT_SUBMODULE_IGNORE_UNTRACKED = 2, GIT_SUBMODULE_IGNORE_DIRTY = 3, GIT_SUBMODULE_IGNORE_ALL = 4, } } #[repr(C)] pub struct git_cred { pub credtype: git_credtype_t, pub free: extern fn(*mut git_cred), } git_enum! { pub enum git_credtype_t { GIT_CREDTYPE_USERPASS_PLAINTEXT = 1 << 0, GIT_CREDTYPE_SSH_KEY = 1 << 1, GIT_CREDTYPE_SSH_CUSTOM = 1 << 2, GIT_CREDTYPE_DEFAULT = 1 << 3, GIT_CREDTYPE_SSH_INTERACTIVE = 1 << 4, GIT_CREDTYPE_USERNAME = 1 << 5, GIT_CREDTYPE_SSH_MEMORY = 1 << 6, } } pub type git_cred_ssh_interactive_callback = extern fn( name: *const c_char, name_len: c_int, instruction: *const c_char, instruction_len: c_int, num_prompts: c_int, prompts: *const LIBSSH2_USERAUTH_KBDINT_PROMPT, responses: *mut LIBSSH2_USERAUTH_KBDINT_RESPONSE, abstrakt: *mut *mut c_void ); pub type git_cred_sign_callback = extern fn( session: *mut LIBSSH2_SESSION, sig: *mut *mut c_uchar, sig_len: *mut size_t, data: *const c_uchar, data_len: size_t, abstrakt: *mut *mut c_void, ); pub enum LIBSSH2_SESSION {} pub enum LIBSSH2_USERAUTH_KBDINT_PROMPT {} pub enum LIBSSH2_USERAUTH_KBDINT_RESPONSE {} #[repr(C)] pub struct git_push_options { pub version: c_uint, pub pb_parallelism: c_uint, pub callbacks: git_remote_callbacks, pub custom_headers: git_strarray, } pub type git_tag_foreach_cb = extern fn(name: *const c_char, oid: *mut git_oid, payload: *mut c_void) -> c_int; git_enum! { pub enum git_index_add_option_t { GIT_INDEX_ADD_DEFAULT = 0, GIT_INDEX_ADD_FORCE = 1 << 0, GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH = 1 << 1, GIT_INDEX_ADD_CHECK_PATHSPEC = 1 << 2, } } #[repr(C)] pub struct git_repository_init_options { pub version: c_uint, pub flags: u32, pub mode: u32, pub workdir_path: *const c_char, pub description: *const c_char, pub template_path: *const c_char, pub initial_head: *const c_char, pub origin_url: *const c_char, } pub const GIT_REPOSITORY_INIT_OPTIONS_VERSION: c_uint = 1; git_enum! { pub enum git_repository_init_flag_t { GIT_REPOSITORY_INIT_BARE = (1 << 0), GIT_REPOSITORY_INIT_NO_REINIT = (1 << 1), GIT_REPOSITORY_INIT_NO_DOTGIT_DIR = (1 << 2), GIT_REPOSITORY_INIT_MKDIR = (1 << 3), GIT_REPOSITORY_INIT_MKPATH = (1 << 4), GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = (1 << 5), } } git_enum! { pub enum git_repository_init_mode_t { GIT_REPOSITORY_INIT_SHARED_UMASK = 0, GIT_REPOSITORY_INIT_SHARED_GROUP = 0o002775, GIT_REPOSITORY_INIT_SHARED_ALL = 0o002777, } } git_enum! { pub enum git_sort_t { GIT_SORT_NONE = 0, GIT_SORT_TOPOLOGICAL = (1 << 0), GIT_SORT_TIME = (1 << 1), GIT_SORT_REVERSE = (1 << 2), } } git_enum! { pub enum git_submodule_status_t { GIT_SUBMODULE_STATUS_IN_HEAD = 1 << 0, GIT_SUBMODULE_STATUS_IN_INDEX = 1 << 1, GIT_SUBMODULE_STATUS_IN_CONFIG = 1 << 2, GIT_SUBMODULE_STATUS_IN_WD = 1 << 3, GIT_SUBMODULE_STATUS_INDEX_ADDED = 1 << 4, GIT_SUBMODULE_STATUS_INDEX_DELETED = 1 << 5, GIT_SUBMODULE_STATUS_INDEX_MODIFIED = 1 << 6, GIT_SUBMODULE_STATUS_WD_UNINITIALIZED = 1 << 7, GIT_SUBMODULE_STATUS_WD_ADDED = 1 << 8, GIT_SUBMODULE_STATUS_WD_DELETED = 1 << 9, GIT_SUBMODULE_STATUS_WD_MODIFIED = 1 << 10, GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED = 1 << 11, GIT_SUBMODULE_STATUS_WD_WD_MODIFIED = 1 << 12, GIT_SUBMODULE_STATUS_WD_UNTRACKED = 1 << 13, } } #[repr(C)] pub struct git_remote_head { pub local: c_int, pub oid: git_oid, pub loid: git_oid, pub name: *mut c_char, pub symref_target: *mut c_char, } git_enum! { pub enum git_pathspec_flag_t { GIT_PATHSPEC_DEFAULT = 0, GIT_PATHSPEC_IGNORE_CASE = 1 << 0, GIT_PATHSPEC_USE_CASE = 1 << 1, GIT_PATHSPEC_NO_GLOB = 1 << 2, GIT_PATHSPEC_NO_MATCH_ERROR = 1 << 3, GIT_PATHSPEC_FIND_FAILURES = 1 << 4, GIT_PATHSPEC_FAILURES_ONLY = 1 << 5, } } pub type git_diff_file_cb = extern fn(*const git_diff_delta, f32, *mut c_void) -> c_int; pub type git_diff_hunk_cb = extern fn(*const git_diff_delta, *const git_diff_hunk, *mut c_void) -> c_int; pub type git_diff_line_cb = extern fn(*const git_diff_delta, *const git_diff_hunk, *const git_diff_line, *mut c_void) -> c_int; pub type git_diff_binary_cb = extern fn(*const git_diff_delta, *const git_diff_binary, *mut c_void) -> c_int; #[repr(C)] pub struct git_diff_hunk { pub old_start: c_int, pub old_lines: c_int, pub new_start: c_int, pub new_lines: c_int, pub header_len: size_t, pub header: [c_char; 128], } pub type git_diff_line_t = __enum_ty; pub const GIT_DIFF_LINE_CONTEXT: c_char = ' ' as c_char; pub const GIT_DIFF_LINE_ADDITION: c_char = '+' as c_char; pub const GIT_DIFF_LINE_DELETION: c_char = '-' as c_char; pub const GIT_DIFF_LINE_CONTEXT_EOFNL: c_char = '=' as c_char; pub const GIT_DIFF_LINE_ADD_EOFNL: c_char = '>' as c_char; pub const GIT_DIFF_LINE_DEL_EOFNL: c_char = '<' as c_char; pub const GIT_DIFF_LINE_FILE_HDR: c_char = 'F' as c_char; pub const GIT_DIFF_LINE_HUNK_HDR: c_char = 'H' as c_char; pub const GIT_DIFF_LINE_BINARY: c_char = 'B' as c_char; #[repr(C)] pub struct git_diff_line { pub origin: c_char, pub old_lineno: c_int, pub new_lineno: c_int, pub num_lines: c_int, pub content_len: size_t, pub content_offset: git_off_t, pub content: *const c_char, } #[repr(C)] pub struct git_diff_options { pub version: c_uint, pub flags: u32, pub ignore_submodules: git_submodule_ignore_t, pub pathspec: git_strarray, pub notify_cb: git_diff_notify_cb, pub notify_payload: *mut c_void, pub context_lines: u32, pub interhunk_lines: u32, pub id_abbrev: u16, pub max_size: git_off_t, pub old_prefix: *const c_char, pub new_prefix: *const c_char, } git_enum! { pub enum git_diff_format_t { GIT_DIFF_FORMAT_PATCH = 1, GIT_DIFF_FORMAT_PATCH_HEADER = 2, GIT_DIFF_FORMAT_RAW = 3, GIT_DIFF_FORMAT_NAME_ONLY = 4, GIT_DIFF_FORMAT_NAME_STATUS = 5, } } git_enum! { pub enum git_diff_stats_format_t { GIT_DIFF_STATS_NONE = 0, GIT_DIFF_STATS_FULL = 1 << 0, GIT_DIFF_STATS_SHORT = 1 << 1, GIT_DIFF_STATS_NUMBER = 1 << 2, GIT_DIFF_STATS_INCLUDE_SUMMARY = 1 << 3, } } pub type git_diff_notify_cb = extern fn(*const git_diff, *const git_diff_delta, *const c_char, *mut c_void) -> c_int; pub const GIT_DIFF_NORMAL: u32 = 0; pub const GIT_DIFF_REVERSE: u32 = 1 << 0; pub const GIT_DIFF_INCLUDE_IGNORED: u32 = 1 << 1; pub const GIT_DIFF_RECURSE_IGNORED_DIRS: u32 = 1 << 2; pub const GIT_DIFF_INCLUDE_UNTRACKED: u32 = 1 << 3; pub const GIT_DIFF_RECURSE_UNTRACKED_DIRS: u32 = 1 << 4; pub const GIT_DIFF_INCLUDE_UNMODIFIED: u32 = 1 << 5; pub const GIT_DIFF_INCLUDE_TYPECHANGE: u32 = 1 << 6; pub const GIT_DIFF_INCLUDE_TYPECHANGE_TREES: u32 = 1 << 7; pub const GIT_DIFF_IGNORE_FILEMODE: u32 = 1 << 8; pub const GIT_DIFF_IGNORE_SUBMODULES: u32 = 1 << 9; pub const GIT_DIFF_IGNORE_CASE: u32 = 1 << 10; pub const GIT_DIFF_DISABLE_PATHSPEC_MATCH: u32 = 1 << 12; pub const GIT_DIFF_SKIP_BINARY_CHECK: u32 = 1 << 13; pub const GIT_DIFF_ENABLE_FAST_UNTRACKED_DIRS: u32 = 1 << 14; pub const GIT_DIFF_UPDATE_INDEX: u32 = 1 << 15; pub const GIT_DIFF_INCLUDE_UNREADABLE: u32 = 1 << 16; pub const GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED: u32 = 1 << 17; pub const GIT_DIFF_FORCE_TEXT: u32 = 1 << 20; pub const GIT_DIFF_FORCE_BINARY: u32 = 1 << 21; pub const GIT_DIFF_IGNORE_WHITESPACE: u32 = 1 << 22; pub const GIT_DIFF_IGNORE_WHITESPACE_CHANGE: u32 = 1 << 23; pub const GIT_DIFF_IGNORE_WHITESPACE_EOL: u32 = 1 << 24; pub const GIT_DIFF_SHOW_UNTRACKED_CONTENT: u32 = 1 << 25; pub const GIT_DIFF_SHOW_UNMODIFIED: u32 = 1 << 26; pub const GIT_DIFF_PATIENCE: u32 = 1 << 28; pub const GIT_DIFF_MINIMAL: u32 = 1 << 29; pub const GIT_DIFF_SHOW_BINARY: u32 = 1 << 30; #[repr(C)] pub struct git_diff_find_options { pub version: c_uint, pub flags: u32, pub rename_threshold: u16, pub rename_from_rewrite_threshold: u16, pub copy_threshold: u16, pub break_rewrite_threshold: u16, pub rename_limit: size_t, pub metric: *mut git_diff_similarity_metric, } #[repr(C)] pub struct git_diff_similarity_metric { pub file_signature: extern fn(*mut *mut c_void, *const git_diff_file, *const c_char, *mut c_void) -> c_int, pub buffer_signature: extern fn(*mut *mut c_void, *const git_diff_file, *const c_char, size_t, *mut c_void) -> c_int, pub free_signature: extern fn(*mut c_void, *mut c_void), pub similarity: extern fn(*mut c_int, *mut c_void, *mut c_void, *mut c_void) -> c_int, pub payload: *mut c_void, } pub const GIT_DIFF_FIND_OPTIONS_VERSION: c_uint = 1; pub const GIT_DIFF_FIND_BY_CONFIG: u32 = 0; pub const GIT_DIFF_FIND_RENAMES: u32 = 1 << 0; pub const GIT_DIFF_FIND_RENAMES_FROM_REWRITES: u32 = 1 << 1; pub const GIT_DIFF_FIND_COPIES: u32 = 1 << 2; pub const GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED: u32 = 1 << 3; pub const GIT_DIFF_FIND_REWRITES: u32 = 1 << 4; pub const GIT_DIFF_BREAK_REWRITES: u32 = 1 << 5; pub const GIT_DIFF_FIND_AND_BREAK_REWRITES: u32 = GIT_DIFF_FIND_REWRITES | GIT_DIFF_BREAK_REWRITES; pub const GIT_DIFF_FIND_FOR_UNTRACKED: u32 = 1 << 6; pub const GIT_DIFF_FIND_ALL: u32 = 0x0ff; pub const GIT_DIFF_FIND_IGNORE_LEADING_WHITESPACE: u32 = 0; pub const GIT_DIFF_FIND_IGNORE_WHITESPACE: u32 = 1 << 12; pub const GIT_DIFF_FIND_DONT_IGNORE_WHITESPACE: u32 = 1 << 13; pub const GIT_DIFF_FIND_EXACT_MATCH_ONLY: u32 = 1 << 14; pub const GIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY : u32 = 1 << 15; pub const GIT_DIFF_FIND_REMOVE_UNMODIFIED: u32 = 1 << 16; #[repr(C)] pub struct git_diff_binary { pub old_file: git_diff_binary_file, pub new_file: git_diff_binary_file, } #[repr(C)] pub struct git_diff_binary_file { pub kind: git_diff_binary_t, pub data: *const c_char, pub datalen: size_t, pub inflatedlen: size_t, } git_enum! { pub enum git_diff_binary_t { GIT_DIFF_BINARY_NONE, GIT_DIFF_BINARY_LITERAL, GIT_DIFF_BINARY_DELTA, } } #[repr(C)] pub struct git_merge_options { pub version: c_uint, pub tree_flags: git_merge_tree_flag_t, pub rename_threshold: c_uint, pub target_limit: c_uint, pub metric: *mut git_diff_similarity_metric, pub file_favor: git_merge_file_favor_t, pub file_flags: c_uint, } git_enum! { pub enum git_merge_tree_flag_t { GIT_MERGE_TREE_FIND_RENAMES = 1 << 0, } } git_enum! { pub enum git_merge_file_favor_t { GIT_MERGE_FILE_FAVOR_NORMAL = 0, GIT_MERGE_FILE_FAVOR_OURS = 1, GIT_MERGE_FILE_FAVOR_THEIRS = 2, GIT_MERGE_FILE_FAVOR_UNION = 3, } } // used in git_merge_options.file_flags pub const GIT_MERGE_FILE_DEFAULT: u32 = 0; pub const GIT_MERGE_FILE_STYLE_MERGE: u32 = (1 << 0); pub const GIT_MERGE_FILE_STYLE_DIFF3: u32 = (1 << 1); pub const GIT_MERGE_FILE_SIMPLIFY_ALNUM: u32 = (1 << 2); pub const GIT_MERGE_FILE_IGNORE_WHITESPACE: u32 = (1 << 3); pub const GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE: u32 = (1 << 4); pub const GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL: u32 = (1 << 5); pub const GIT_MERGE_FILE_DIFF_PATIENCE: u32 = (1 << 6); pub const GIT_MERGE_FILE_DIFF_MINIMAL: u32 = (1 << 7); pub type git_transport_cb = extern fn(out: *mut *mut git_transport, owner: *mut git_remote, param: *mut c_void) -> c_int; #[repr(C)] pub struct git_transport { pub version: c_uint, pub set_callbacks: extern fn(*mut git_transport, git_transport_message_cb, git_transport_message_cb, git_transport_certificate_check_cb, *mut c_void) -> c_int, pub set_custom_headers: extern fn(*mut git_transport, *const git_strarray) -> c_int, pub connect: extern fn(*mut git_transport, *const c_char, git_cred_acquire_cb, *mut c_void, c_int, c_int) -> c_int, pub ls: extern fn(*mut *mut *const git_remote_head, *mut size_t, *mut git_transport) -> c_int, pub push: extern fn(*mut git_transport, *mut git_push, *const git_remote_callbacks) -> c_int, pub negotiate_fetch: extern fn(*mut git_transport, *mut git_repository, *const *const git_remote_head, size_t) -> c_int, pub download_pack: extern fn(*mut git_transport, *mut git_repository, *mut git_transfer_progress, git_transfer_progress_cb, *mut c_void) -> c_int, pub is_connected: extern fn(*mut git_transport) -> c_int, pub read_flags: extern fn(*mut git_transport, *mut c_int) -> c_int, pub cancel: extern fn(*mut git_transport), pub close: extern fn(*mut git_transport) -> c_int, pub free: extern fn(*mut git_transport), } git_enum! { pub enum git_smart_service_t { GIT_SERVICE_UPLOADPACK_LS = 1, GIT_SERVICE_UPLOADPACK = 2, GIT_SERVICE_RECEIVEPACK_LS = 3, GIT_SERVICE_RECEIVEPACK = 4, } } #[repr(C)] pub struct git_smart_subtransport_stream { pub subtransport: *mut git_smart_subtransport, pub read: extern fn(*mut git_smart_subtransport_stream, *mut c_char, size_t, *mut size_t) -> c_int, pub write: extern fn(*mut git_smart_subtransport_stream, *const c_char, size_t) -> c_int, pub free: extern fn(*mut git_smart_subtransport_stream), } #[repr(C)] pub struct git_smart_subtransport { pub action: extern fn(*mut *mut git_smart_subtransport_stream, *mut git_smart_subtransport, *const c_char, git_smart_service_t) -> c_int, pub close: extern fn(*mut git_smart_subtransport) -> c_int, pub free: extern fn(*mut git_smart_subtransport), } pub type git_smart_subtransport_cb = extern fn(*mut *mut git_smart_subtransport, *mut git_transport, *mut c_void) -> c_int; #[repr(C)] pub struct git_smart_subtransport_definition { pub callback: git_smart_subtransport_cb, pub rpc: c_uint, pub param: *mut c_void, } #[repr(C)] pub struct git_describe_options { pub version: c_uint, pub max_candidates_tags: c_uint, pub describe_strategy: c_uint, pub pattern: *const c_char, pub only_follow_first_parent: c_int, pub show_commit_oid_as_fallback: c_int, } git_enum! { pub enum git_describe_strategy_t { GIT_DESCRIBE_DEFAULT, GIT_DESCRIBE_TAGS, GIT_DESCRIBE_ALL, } } #[repr(C)] pub struct git_describe_format_options { pub version: c_uint, pub abbreviated_size: c_uint, pub always_use_long_format: c_int, pub dirty_suffix: *const c_char, } /// Initialize openssl for the libgit2 library #[cfg(all(unix, not(target_os = "macos"), feature = "https"))] pub fn openssl_init() { if !cfg!(target_os = "linux") && !cfg!(target_os = "freebsd") { return } // Currently, libgit2 leverages OpenSSL for SSL support when cloning // repositories over HTTPS. This means that we're picking up an OpenSSL // dependency on non-Windows platforms (where it has its own HTTPS // subsystem). As a result, we need to link to OpenSSL. // // Now actually *linking* to OpenSSL isn't so hard. We just need to make // sure to use pkg-config to discover any relevant system dependencies for // differences between distributions like CentOS and Ubuntu. The actual // trickiness comes about when we start *distributing* the resulting // binaries. Currently Cargo is distributed in binary form as nightlies, // which means we're distributing a binary with OpenSSL linked in. // // For historical reasons, the Linux nightly builder is running a CentOS // distribution in order to have as much ABI compatibility with other // distributions as possible. Sadly, however, this compatibility does not // extend to OpenSSL. Currently OpenSSL has two major versions, 0.9 and 1.0, // which are incompatible (many ABI differences). The CentOS builder we // build on has version 1.0, as do most distributions today. Some still have // 0.9, however. This means that if we are to distribute the binaries built // by the CentOS machine, we would only be compatible with OpenSSL 1.0 and // we would fail to run (a dynamic linker error at runtime) on systems with // only 9.8 installed (hopefully). // // But wait, the plot thickens! Apparently CentOS has dubbed their OpenSSL // library as `libssl.so.10`, notably the `10` is included at the end. On // the other hand Ubuntu, for example, only distributes `libssl.so`. This // means that the binaries created at CentOS are hard-wired to probe for a // file called `libssl.so.10` at runtime (using the LD_LIBRARY_PATH), which // will not be found on ubuntu. The conclusion of this is that binaries // built on CentOS cannot be distributed to Ubuntu and run successfully. // // There are a number of sneaky things we could do, including, but not // limited to: // // 1. Create a shim program which runs "just before" cargo runs. The // responsibility of this shim program would be to locate `libssl.so`, // whatever it's called, on the current system, make sure there's a // symlink *somewhere* called `libssl.so.10`, and then set up // LD_LIBRARY_PATH and run the actual cargo. // // This approach definitely seems unconventional, and is borderline // overkill for this problem. It's also dubious if we can find a // libssl.so reliably on the target system. // // 2. Somehow re-work the CentOS installation so that the linked-against // library is called libssl.so instead of libssl.so.10 // // The problem with this approach is that systems with 0.9 installed will // start to silently fail, due to also having libraries called libssl.so // (probably symlinked under a more appropriate version). // // 3. Compile Cargo against both OpenSSL 1.0 *and* OpenSSL 0.9, and // distribute both. Also make sure that the linked-against name of the // library is `libssl.so`. At runtime we determine which version is // installed, and we then the appropriate binary. // // This approach clearly has drawbacks in terms of infrastructure and // feasibility. // // 4. Build a nightly of Cargo for each distribution we'd like to support. // You would then pick the appropriate Cargo nightly to install locally. // // So, with all this in mind, the decision was made to *statically* link // OpenSSL. This solves any problem of relying on a downstream OpenSSL // version being available. This does, however, open a can of worms related // to security issues. It's generally a good idea to dynamically link // OpenSSL as you'll get security updates over time without having to do // anything (the system administrator will update the local openssl // package). By statically linking, we're forfeiting this feature. // // The conclusion was made it is likely appropriate for the Cargo nightlies // to statically link OpenSSL, but highly encourage distributions and // packagers of Cargo to dynamically link OpenSSL. Packagers are targeting // one system and are distributing to only that system, so none of the // problems mentioned above would arise. // // In order to support this, a new package was made: openssl-static-sys. // This package currently performs a fairly simple task: // // 1. Run pkg-config to discover where openssl is installed. // 2. If openssl is installed in a nonstandard location, *and* static copies // of the libraries are available, copy them to $OUT_DIR. // // This library will bring in libssl.a and libcrypto.a into the local build, // allowing them to be picked up by this crate. This allows us to configure // our own buildbots to have pkg-config point to these local pre-built // copies of a static OpenSSL (with very few dependencies) while allowing // most other builds of Cargo to naturally dynamically link OpenSSL. // // So in summary, if you're with me so far, we've statically linked OpenSSL // to the Cargo binary (or any binary, for that matter) and we're ready to // distribute it to *all* linux distributions. Remember that our original // intent for openssl was for HTTPS support, which implies that we need some // for of CA certificate store to validate certificates. This is normally // installed in a standard system location. // // Unfortunately, as one might imagine, OpenSSL is configured for where this // standard location is at *build time*, but it often varies widely // per-system. Consequently, it was discovered that OpenSSL will respect the // SSL_CERT_FILE and SSL_CERT_DIR environment variables in order to assist // in discovering the location of this file (hurray!). // // So, finally getting to the point, this function solely exists to support // our static builds of OpenSSL by probing for the "standard system // location" of certificates and setting relevant environment variable to // point to them. // // Ah, and as a final note, this is only a problem on Linux, not on OS X. On // OS X the OpenSSL binaries are stable enough that we can just rely on // dynamic linkage (plus they have some weird modifications to OpenSSL which // means we wouldn't want to link statically). openssl::probe::init_ssl_cert_env_vars(); } #[cfg(any(windows, target_os = "macos", not(feature = "https")))] pub fn openssl_init() {} extern { // threads pub fn git_libgit2_init() -> c_int; pub fn git_libgit2_shutdown() -> c_int; // repository pub fn git_repository_free(repo: *mut git_repository); pub fn git_repository_open(repo: *mut *mut git_repository, path: *const c_char) -> c_int; pub fn git_repository_init(repo: *mut *mut git_repository, path: *const c_char, is_bare: c_uint) -> c_int; pub fn git_repository_init_ext(out: *mut *mut git_repository, repo_path: *const c_char, opts: *mut git_repository_init_options) -> c_int; pub fn git_repository_init_init_options(opts: *mut git_repository_init_options, version: c_uint) -> c_int; pub fn git_repository_get_namespace(repo: *mut git_repository) -> *const c_char; pub fn git_repository_head(out: *mut *mut git_reference, repo: *mut git_repository) -> c_int; pub fn git_repository_set_head(repo: *mut git_repository, refname: *const c_char) -> c_int; pub fn git_repository_set_head_detached(repo: *mut git_repository, commitish: *const git_oid) -> c_int; pub fn git_repository_is_bare(repo: *mut git_repository) -> c_int; pub fn git_repository_is_empty(repo: *mut git_repository) -> c_int; pub fn git_repository_is_shallow(repo: *mut git_repository) -> c_int; pub fn git_repository_path(repo: *mut git_repository) -> *const c_char; pub fn git_repository_state(repo: *mut git_repository) -> c_int; pub fn git_repository_workdir(repo: *mut git_repository) -> *const c_char; pub fn git_repository_index(out: *mut *mut git_index, repo: *mut git_repository) -> c_int; pub fn git_repository_config(out: *mut *mut git_config, repo: *mut git_repository) -> c_int; pub fn git_repository_config_snapshot(out: *mut *mut git_config, repo: *mut git_repository) -> c_int; pub fn git_repository_discover(out: *mut git_buf, start_path: *const c_char, across_fs: c_int, ceiling_dirs: *const c_char) -> c_int; // revparse pub fn git_revparse(revspec: *mut git_revspec, repo: *mut git_repository, spec: *const c_char) -> c_int; pub fn git_revparse_single(out: *mut *mut git_object, repo: *mut git_repository, spec: *const c_char) -> c_int; pub fn git_revparse_ext(object_out: *mut *mut git_object, reference_out: *mut *mut git_reference, repo: *mut git_repository, spec: *const c_char) -> c_int; // object pub fn git_object_dup(dest: *mut *mut git_object, source: *mut git_object) -> c_int; pub fn git_object_id(obj: *const git_object) -> *const git_oid; pub fn git_object_free(object: *mut git_object); pub fn git_object_lookup(dest: *mut *mut git_object, repo: *mut git_repository, id: *const git_oid, kind: git_otype) -> c_int; pub fn git_object_type(obj: *const git_object) -> git_otype; pub fn git_object_peel(peeled: *mut *mut git_object, object: *const git_object, target_type: git_otype) -> c_int; pub fn git_object_short_id(out: *mut git_buf, obj: *const git_object) -> c_int; pub fn git_object_type2string(kind: git_otype) -> *const c_char; pub fn git_object_string2type(s: *const c_char) -> git_otype; pub fn git_object_typeisloose(kind: git_otype) -> c_int; // oid pub fn git_oid_fromraw(out: *mut git_oid, raw: *const c_uchar); pub fn git_oid_fromstrn(out: *mut git_oid, str: *const c_char, len: size_t) -> c_int; pub fn git_oid_tostr(out: *mut c_char, n: size_t, id: *const git_oid) -> *mut c_char; pub fn git_oid_cmp(a: *const git_oid, b: *const git_oid) -> c_int; pub fn git_oid_equal(a: *const git_oid, b: *const git_oid) -> c_int; pub fn git_oid_streq(id: *const git_oid, str: *const c_char) -> c_int; pub fn git_oid_iszero(id: *const git_oid) -> c_int; // giterr pub fn giterr_last() -> *const git_error; pub fn giterr_clear(); pub fn giterr_set_str(error_class: c_int, string: *const c_char); // remote pub fn git_remote_create(out: *mut *mut git_remote, repo: *mut git_repository, name: *const c_char, url: *const c_char) -> c_int; pub fn git_remote_lookup(out: *mut *mut git_remote, repo: *mut git_repository, name: *const c_char) -> c_int; pub fn git_remote_create_anonymous(out: *mut *mut git_remote, repo: *mut git_repository, url: *const c_char) -> c_int; pub fn git_remote_delete(repo: *mut git_repository, name: *const c_char) -> c_int; pub fn git_remote_free(remote: *mut git_remote); pub fn git_remote_name(remote: *const git_remote) -> *const c_char; pub fn git_remote_pushurl(remote: *const git_remote) -> *const c_char; pub fn git_remote_refspec_count(remote: *const git_remote) -> size_t; pub fn git_remote_url(remote: *const git_remote) -> *const c_char; pub fn git_remote_connect(remote: *mut git_remote, dir: git_direction, callbacks: *const git_remote_callbacks, custom_headers: *const git_strarray) -> c_int; pub fn git_remote_connected(remote: *const git_remote) -> c_int; pub fn git_remote_disconnect(remote: *mut git_remote); pub fn git_remote_add_fetch(repo: *mut git_repository, remote: *const c_char, refspec: *const c_char) -> c_int; pub fn git_remote_add_push(repo: *mut git_repository, remote: *const c_char, refspec: *const c_char) -> c_int; pub fn git_remote_download(remote: *mut git_remote, refspecs: *const git_strarray, opts: *const git_fetch_options) -> c_int; pub fn git_remote_stop(remote: *mut git_remote); pub fn git_remote_dup(dest: *mut *mut git_remote, source: *mut git_remote) -> c_int; pub fn git_remote_get_fetch_refspecs(array: *mut git_strarray, remote: *const git_remote) -> c_int; pub fn git_remote_get_refspec(remote: *const git_remote, n: size_t) -> *const git_refspec; pub fn git_remote_is_valid_name(remote_name: *const c_char) -> c_int; pub fn git_remote_list(out: *mut git_strarray, repo: *mut git_repository) -> c_int; pub fn git_remote_rename(problems: *mut git_strarray, repo: *mut git_repository, name: *const c_char, new_name: *const c_char) -> c_int; pub fn git_remote_fetch(remote: *mut git_remote, refspecs: *const git_strarray, opts: *const git_fetch_options, reflog_message: *const c_char) -> c_int; pub fn git_remote_push(remote: *mut git_remote, refspecs: *const git_strarray, opts: *const git_push_options) -> c_int; pub fn git_remote_update_tips(remote: *mut git_remote, callbacks: *const git_remote_callbacks, update_fetchead: c_int, download_tags: git_remote_autotag_option_t, reflog_message: *const c_char) -> c_int; pub fn git_remote_set_url(repo: *mut git_repository, remote: *const c_char, url: *const c_char) -> c_int; pub fn git_remote_set_pushurl(repo: *mut git_repository, remote: *const c_char, pushurl: *const c_char) -> c_int; pub fn git_remote_init_callbacks(opts: *mut git_remote_callbacks, version: c_uint) -> c_int; pub fn git_fetch_init_options(opts: *mut git_fetch_options, version: c_uint) -> c_int; pub fn git_remote_stats(remote: *mut git_remote) -> *const git_transfer_progress; pub fn git_remote_ls(out: *mut *mut *const git_remote_head, size: *mut size_t, remote: *mut git_remote) -> c_int; pub fn git_remote_set_autotag(repo: *mut git_repository, remote: *const c_char, value: git_remote_autotag_option_t) -> c_int; pub fn git_remote_prune(remote: *mut git_remote, callbacks: *const git_remote_callbacks) -> c_int; // refspec pub fn git_refspec_direction(spec: *const git_refspec) -> git_direction; pub fn git_refspec_dst(spec: *const git_refspec) -> *const c_char; pub fn git_refspec_dst_matches(spec: *const git_refspec, refname: *const c_char) -> c_int; pub fn git_refspec_src(spec: *const git_refspec) -> *const c_char; pub fn git_refspec_src_matches(spec: *const git_refspec, refname: *const c_char) -> c_int; pub fn git_refspec_force(spec: *const git_refspec) -> c_int; pub fn git_refspec_string(spec: *const git_refspec) -> *const c_char; // strarray pub fn git_strarray_free(array: *mut git_strarray); // oidarray pub fn git_oidarray_free(array: *mut git_oidarray); // signature pub fn git_signature_default(out: *mut *mut git_signature, repo: *mut git_repository) -> c_int; pub fn git_signature_free(sig: *mut git_signature); pub fn git_signature_new(out: *mut *mut git_signature, name: *const c_char, email: *const c_char, time: git_time_t, offset: c_int) -> c_int; pub fn git_signature_now(out: *mut *mut git_signature, name: *const c_char, email: *const c_char) -> c_int; pub fn git_signature_dup(dest: *mut *mut git_signature, sig: *const git_signature) -> c_int; // status pub fn git_status_list_new(out: *mut *mut git_status_list, repo: *mut git_repository, options: *const git_status_options) -> c_int; pub fn git_status_list_entrycount(list: *mut git_status_list) -> size_t; pub fn git_status_byindex(statuslist: *mut git_status_list, idx: size_t) -> *const git_status_entry; pub fn git_status_list_free(list: *mut git_status_list); pub fn git_status_init_options(opts: *mut git_status_options, version: c_uint) -> c_int; pub fn git_status_file(status_flags: *mut c_uint, repo: *mut git_repository, path: *const c_char) -> c_int; pub fn git_status_should_ignore(ignored: *mut c_int, repo: *mut git_repository, path: *const c_char) -> c_int; // clone pub fn git_clone(out: *mut *mut git_repository, url: *const c_char, local_path: *const c_char, options: *const git_clone_options) -> c_int; pub fn git_clone_init_options(opts: *mut git_clone_options, version: c_uint) -> c_int; // reset pub fn git_reset(repo: *mut git_repository, target: *mut git_object, reset_type: git_reset_t, checkout_opts: *const git_checkout_options) -> c_int; pub fn git_reset_default(repo: *mut git_repository, target: *mut git_object, pathspecs: *mut git_strarray) -> c_int; // reference pub fn git_reference_cmp(ref1: *const git_reference, ref2: *const git_reference) -> c_int; pub fn git_reference_delete(r: *mut git_reference) -> c_int; pub fn git_reference_free(r: *mut git_reference); pub fn git_reference_is_branch(r: *const git_reference) -> c_int; pub fn git_reference_is_note(r: *const git_reference) -> c_int; pub fn git_reference_is_remote(r: *const git_reference) -> c_int; pub fn git_reference_is_tag(r: *const git_reference) -> c_int; pub fn git_reference_is_valid_name(name: *const c_char) -> c_int; pub fn git_reference_lookup(out: *mut *mut git_reference, repo: *mut git_repository, name: *const c_char) -> c_int; pub fn git_reference_name(r: *const git_reference) -> *const c_char; pub fn git_reference_name_to_id(out: *mut git_oid, repo: *mut git_repository, name: *const c_char) -> c_int; pub fn git_reference_peel(out: *mut *mut git_object, r: *mut git_reference, otype: git_otype) -> c_int; pub fn git_reference_rename(new_ref: *mut *mut git_reference, r: *mut git_reference, new_name: *const c_char, force: c_int, log_message: *const c_char) -> c_int; pub fn git_reference_resolve(out: *mut *mut git_reference, r: *const git_reference) -> c_int; pub fn git_reference_shorthand(r: *const git_reference) -> *const c_char; pub fn git_reference_symbolic_target(r: *const git_reference) -> *const c_char; pub fn git_reference_target(r: *const git_reference) -> *const git_oid; pub fn git_reference_target_peel(r: *const git_reference) -> *const git_oid; pub fn git_reference_set_target(out: *mut *mut git_reference, r: *mut git_reference, id: *const git_oid, log_message: *const c_char) -> c_int; pub fn git_reference_type(r: *const git_reference) -> git_ref_t; pub fn git_reference_iterator_new(out: *mut *mut git_reference_iterator, repo: *mut git_repository) -> c_int; pub fn git_reference_iterator_glob_new(out: *mut *mut git_reference_iterator, repo: *mut git_repository, glob: *const c_char) -> c_int; pub fn git_reference_iterator_free(iter: *mut git_reference_iterator); pub fn git_reference_next(out: *mut *mut git_reference, iter: *mut git_reference_iterator) -> c_int; pub fn git_reference_next_name(out: *mut *const c_char, iter: *mut git_reference_iterator) -> c_int; pub fn git_reference_create(out: *mut *mut git_reference, repo: *mut git_repository, name: *const c_char, id: *const git_oid, force: c_int, log_message: *const c_char) -> c_int; pub fn git_reference_symbolic_create(out: *mut *mut git_reference, repo: *mut git_repository, name: *const c_char, target: *const c_char, force: c_int, log_message: *const c_char) -> c_int; // submodules pub fn git_submodule_add_finalize(submodule: *mut git_submodule) -> c_int; pub fn git_submodule_add_setup(submodule: *mut *mut git_submodule, repo: *mut git_repository, url: *const c_char, path: *const c_char, use_gitlink: c_int) -> c_int; pub fn git_submodule_add_to_index(submodule: *mut git_submodule, write_index: c_int) -> c_int; pub fn git_submodule_branch(submodule: *mut git_submodule) -> *const c_char; pub fn git_submodule_foreach(repo: *mut git_repository, callback: extern fn(*mut git_submodule, *const c_char, *mut c_void) -> c_int, payload: *mut c_void) -> c_int; pub fn git_submodule_free(submodule: *mut git_submodule); pub fn git_submodule_head_id(submodule: *mut git_submodule) -> *const git_oid; pub fn git_submodule_index_id(submodule: *mut git_submodule) -> *const git_oid; pub fn git_submodule_init(submodule: *mut git_submodule, overwrite: c_int) -> c_int; pub fn git_submodule_location(status: *mut c_uint, submodule: *mut git_submodule) -> c_int; pub fn git_submodule_lookup(out: *mut *mut git_submodule, repo: *mut git_repository, name: *const c_char) -> c_int; pub fn git_submodule_name(submodule: *mut git_submodule) -> *const c_char; pub fn git_submodule_open(repo: *mut *mut git_repository, submodule: *mut git_submodule) -> c_int; pub fn git_submodule_path(submodule: *mut git_submodule) -> *const c_char; pub fn git_submodule_reload(submodule: *mut git_submodule, force: c_int) -> c_int; pub fn git_submodule_set_ignore(repo: *mut git_repository, name: *const c_char, ignore: git_submodule_ignore_t) -> c_int; pub fn git_submodule_set_update(repo: *mut git_repository, name: *const c_char, update: git_submodule_update_t) -> c_int; pub fn git_submodule_set_url(repo: *mut git_repository, name: *const c_char, url: *const c_char) -> c_int; pub fn git_submodule_sync(submodule: *mut git_submodule) -> c_int; pub fn git_submodule_update_strategy(submodule: *mut git_submodule) -> git_submodule_update_t; // pub fn git_submodule_update(submodule: *mut git_submodule, // init: c_int, // options: *mut git_submodule_update_options) // -> c_int; pub fn git_submodule_url(submodule: *mut git_submodule) -> *const c_char; pub fn git_submodule_wd_id(submodule: *mut git_submodule) -> *const git_oid; pub fn git_submodule_status(status: *mut c_uint, repo: *mut git_repository, name: *const c_char, ignore: git_submodule_ignore_t) -> c_int; pub fn git_submodule_set_branch(repo: *mut git_repository, name: *const c_char, branch: *const c_char) -> c_int; // blob pub fn git_blob_free(blob: *mut git_blob); pub fn git_blob_id(blob: *const git_blob) -> *const git_oid; pub fn git_blob_is_binary(blob: *const git_blob) -> c_int; pub fn git_blob_lookup(blob: *mut *mut git_blob, repo: *mut git_repository, id: *const git_oid) -> c_int; pub fn git_blob_lookup_prefix(blob: *mut *mut git_blob, repo: *mut git_repository, id: *const git_oid, len: size_t) -> c_int; pub fn git_blob_rawcontent(blob: *const git_blob) -> *const c_void; pub fn git_blob_rawsize(blob: *const git_blob) -> git_off_t; pub fn git_blob_create_frombuffer(id: *mut git_oid, repo: *mut git_repository, buffer: *const c_void, len: size_t) -> c_int; pub fn git_blob_create_fromdisk(id: *mut git_oid, repo: *mut git_repository, path: *const c_char) -> c_int; pub fn git_blob_create_fromworkdir(id: *mut git_oid, repo: *mut git_repository, relative_path: *const c_char) -> c_int; // tree pub fn git_tree_entry_byid(tree: *const git_tree, id: *const git_oid) -> *const git_tree_entry; pub fn git_tree_entry_byindex(tree: *const git_tree, idx: size_t) -> *const git_tree_entry; pub fn git_tree_entry_byname(tree: *const git_tree, filename: *const c_char) -> *const git_tree_entry; pub fn git_tree_entry_bypath(out: *mut *mut git_tree_entry, tree: *const git_tree, filename: *const c_char) -> c_int; pub fn git_tree_entry_cmp(e1: *const git_tree_entry, e2: *const git_tree_entry) -> c_int; pub fn git_tree_entry_dup(dest: *mut *mut git_tree_entry, src: *const git_tree_entry) -> c_int; pub fn git_tree_entry_filemode(entry: *const git_tree_entry) -> git_filemode_t; pub fn git_tree_entry_filemode_raw(entry: *const git_tree_entry) -> git_filemode_t; pub fn git_tree_entry_free(entry: *mut git_tree_entry); pub fn git_tree_entry_id(entry: *const git_tree_entry) -> *const git_oid; pub fn git_tree_entry_name(entry: *const git_tree_entry) -> *const c_char; pub fn git_tree_entry_to_object(out: *mut *mut git_object, repo: *mut git_repository, entry: *const git_tree_entry) -> c_int; pub fn git_tree_entry_type(entry: *const git_tree_entry) -> git_otype; pub fn git_tree_entrycount(tree: *const git_tree) -> size_t; pub fn git_tree_free(tree: *mut git_tree); pub fn git_tree_id(tree: *const git_tree) -> *const git_oid; pub fn git_tree_lookup(tree: *mut *mut git_tree, repo: *mut git_repository, id: *const git_oid) -> c_int; pub fn git_tree_walk(tree: *const git_tree, mode: git_treewalk_mode, callback: git_treewalk_cb, payload: *mut c_void) -> c_int; // treebuilder pub fn git_treebuilder_new(out: *mut *mut git_treebuilder, repo: *mut git_repository, source: *const git_tree) -> c_int; pub fn git_treebuilder_clear(bld: *mut git_treebuilder); pub fn git_treebuilder_entrycount(bld: *mut git_treebuilder) -> c_uint; pub fn git_treebuilder_free(bld: *mut git_treebuilder); pub fn git_treebuilder_get(bld: *mut git_treebuilder, filename: *const c_char) -> *const git_tree_entry; pub fn git_treebuilder_insert(out: *mut *const git_tree_entry, bld: *mut git_treebuilder, filename: *const c_char, id: *const git_oid, filemode: git_filemode_t) -> c_int; pub fn git_treebuilder_remove(bld: *mut git_treebuilder, filename: *const c_char) -> c_int; pub fn git_treebuilder_filter(bld: *mut git_treebuilder, filter: git_treebuilder_filter_cb, payload: *mut c_void); pub fn git_treebuilder_write(id: *mut git_oid, bld: *mut git_treebuilder) -> c_int; // buf pub fn git_buf_free(buffer: *mut git_buf); pub fn git_buf_grow(buffer: *mut git_buf, target_size: size_t) -> c_int; pub fn git_buf_set(buffer: *mut git_buf, data: *const c_void, datalen: size_t) -> c_int; // commit pub fn git_commit_author(commit: *const git_commit) -> *const git_signature; pub fn git_commit_committer(commit: *const git_commit) -> *const git_signature; pub fn git_commit_free(commit: *mut git_commit); pub fn git_commit_id(commit: *const git_commit) -> *const git_oid; pub fn git_commit_lookup(commit: *mut *mut git_commit, repo: *mut git_repository, id: *const git_oid) -> c_int; pub fn git_commit_message(commit: *const git_commit) -> *const c_char; pub fn git_commit_message_encoding(commit: *const git_commit) -> *const c_char; pub fn git_commit_message_raw(commit: *const git_commit) -> *const c_char; pub fn git_commit_nth_gen_ancestor(commit: *mut *mut git_commit, commit: *const git_commit, n: c_uint) -> c_int; pub fn git_commit_parent(out: *mut *mut git_commit, commit: *const git_commit, n: c_uint) -> c_int; pub fn git_commit_parent_id(commit: *const git_commit, n: c_uint) -> *const git_oid; pub fn git_commit_parentcount(commit: *const git_commit) -> c_uint; pub fn git_commit_raw_header(commit: *const git_commit) -> *const c_char; pub fn git_commit_summary(commit: *mut git_commit) -> *const c_char; pub fn git_commit_time(commit: *const git_commit) -> git_time_t; pub fn git_commit_time_offset(commit: *const git_commit) -> c_int; pub fn git_commit_tree(tree_out: *mut *mut git_tree, commit: *const git_commit) -> c_int; pub fn git_commit_tree_id(commit: *const git_commit) -> *const git_oid; pub fn git_commit_amend(id: *mut git_oid, commit_to_amend: *const git_commit, update_ref: *const c_char, author: *const git_signature, committer: *const git_signature, message_encoding: *const c_char, message: *const c_char, tree: *const git_tree) -> c_int; pub fn git_commit_create(id: *mut git_oid, repo: *mut git_repository, update_ref: *const c_char, author: *const git_signature, committer: *const git_signature, message_encoding: *const c_char, message: *const c_char, tree: *const git_tree, parent_count: size_t, parents: *mut *const git_commit) -> c_int; pub fn git_commit_header_field(out: *mut git_buf, commit: *const git_commit, field: *const c_char) -> c_int; // branch pub fn git_branch_create(out: *mut *mut git_reference, repo: *mut git_repository, branch_name: *const c_char, target: *const git_commit, force: c_int) -> c_int; pub fn git_branch_delete(branch: *mut git_reference) -> c_int; pub fn git_branch_is_head(branch: *const git_reference) -> c_int; pub fn git_branch_iterator_free(iter: *mut git_branch_iterator); pub fn git_branch_iterator_new(iter: *mut *mut git_branch_iterator, repo: *mut git_repository, list_flags: git_branch_t) -> c_int; pub fn git_branch_lookup(out: *mut *mut git_reference, repo: *mut git_repository, branch_name: *const c_char, branch_type: git_branch_t) -> c_int; pub fn git_branch_move(out: *mut *mut git_reference, branch: *mut git_reference, new_branch_name: *const c_char, force: c_int) -> c_int; pub fn git_branch_name(out: *mut *const c_char, branch: *const git_reference) -> c_int; pub fn git_branch_next(out: *mut *mut git_reference, out_type: *mut git_branch_t, iter: *mut git_branch_iterator) -> c_int; pub fn git_branch_set_upstream(branch: *mut git_reference, upstream_name: *const c_char) -> c_int; pub fn git_branch_upstream(out: *mut *mut git_reference, branch: *const git_reference) -> c_int; // index pub fn git_index_add(index: *mut git_index, entry: *const git_index_entry) -> c_int; pub fn git_index_add_all(index: *mut git_index, pathspec: *const git_strarray, flags: c_uint, callback: Option, payload: *mut c_void) -> c_int; pub fn git_index_add_bypath(index: *mut git_index, path: *const c_char) -> c_int; pub fn git_index_add_frombuffer(index: *mut git_index, entry: *const git_index_entry, buffer: *const c_void, len: size_t) -> c_int; pub fn git_index_conflict_add(index: *mut git_index, ancestor_entry: *const git_index_entry, our_entry: *const git_index_entry, their_entry: *const git_index_entry) -> c_int; pub fn git_index_clear(index: *mut git_index) -> c_int; pub fn git_index_entry_stage(entry: *const git_index_entry) -> c_int; pub fn git_index_entrycount(entry: *const git_index) -> size_t; pub fn git_index_find(at_pos: *mut size_t, index: *mut git_index, path: *const c_char) -> c_int; pub fn git_index_free(index: *mut git_index); pub fn git_index_get_byindex(index: *mut git_index, n: size_t) -> *const git_index_entry; pub fn git_index_get_bypath(index: *mut git_index, path: *const c_char, stage: c_int) -> *const git_index_entry; pub fn git_index_new(index: *mut *mut git_index) -> c_int; pub fn git_index_open(index: *mut *mut git_index, index_path: *const c_char) -> c_int; pub fn git_index_path(index: *const git_index) -> *const c_char; pub fn git_index_read(index: *mut git_index, force: c_int) -> c_int; pub fn git_index_read_tree(index: *mut git_index, tree: *const git_tree) -> c_int; pub fn git_index_remove(index: *mut git_index, path: *const c_char, stage: c_int) -> c_int; pub fn git_index_remove_all(index: *mut git_index, pathspec: *const git_strarray, callback: Option, payload: *mut c_void) -> c_int; pub fn git_index_remove_bypath(index: *mut git_index, path: *const c_char) -> c_int; pub fn git_index_remove_directory(index: *mut git_index, dir: *const c_char, stage: c_int) -> c_int; pub fn git_index_update_all(index: *mut git_index, pathspec: *const git_strarray, callback: Option, payload: *mut c_void) -> c_int; pub fn git_index_write(index: *mut git_index) -> c_int; pub fn git_index_write_tree(out: *mut git_oid, index: *mut git_index) -> c_int; pub fn git_index_write_tree_to(out: *mut git_oid, index: *mut git_index, repo: *mut git_repository) -> c_int; // config pub fn git_config_add_file_ondisk(cfg: *mut git_config, path: *const c_char, level: git_config_level_t, force: c_int) -> c_int; pub fn git_config_delete_entry(cfg: *mut git_config, name: *const c_char) -> c_int; pub fn git_config_delete_multivar(cfg: *mut git_config, name: *const c_char, regexp: *const c_char) -> c_int; pub fn git_config_find_global(out: *mut git_buf) -> c_int; pub fn git_config_find_system(out: *mut git_buf) -> c_int; pub fn git_config_find_xdg(out: *mut git_buf) -> c_int; pub fn git_config_free(cfg: *mut git_config); pub fn git_config_get_bool(out: *mut c_int, cfg: *const git_config, name: *const c_char) -> c_int; pub fn git_config_get_entry(out: *mut *mut git_config_entry, cfg: *const git_config, name: *const c_char) -> c_int; pub fn git_config_get_int32(out: *mut i32, cfg: *const git_config, name: *const c_char) -> c_int; pub fn git_config_get_int64(out: *mut i64, cfg: *const git_config, name: *const c_char) -> c_int; pub fn git_config_get_string(out: *mut *const c_char, cfg: *const git_config, name: *const c_char) -> c_int; pub fn git_config_get_string_buf(out: *mut git_buf, cfg: *const git_config, name: *const c_char) -> c_int; pub fn git_config_get_path(out: *mut git_buf, cfg: *const git_config, name: *const c_char) -> c_int; pub fn git_config_iterator_free(iter: *mut git_config_iterator); pub fn git_config_iterator_glob_new(out: *mut *mut git_config_iterator, cfg: *const git_config, regexp: *const c_char) -> c_int; pub fn git_config_iterator_new(out: *mut *mut git_config_iterator, cfg: *const git_config) -> c_int; pub fn git_config_new(out: *mut *mut git_config) -> c_int; pub fn git_config_next(entry: *mut *mut git_config_entry, iter: *mut git_config_iterator) -> c_int; pub fn git_config_open_default(out: *mut *mut git_config) -> c_int; pub fn git_config_open_global(out: *mut *mut git_config, config: *mut git_config) -> c_int; pub fn git_config_open_level(out: *mut *mut git_config, parent: *const git_config, level: git_config_level_t) -> c_int; pub fn git_config_open_ondisk(out: *mut *mut git_config, path: *const c_char) -> c_int; pub fn git_config_parse_bool(out: *mut c_int, value: *const c_char) -> c_int; pub fn git_config_parse_int32(out: *mut i32, value: *const c_char) -> c_int; pub fn git_config_parse_int64(out: *mut i64, value: *const c_char) -> c_int; pub fn git_config_set_bool(cfg: *mut git_config, name: *const c_char, value: c_int) -> c_int; pub fn git_config_set_int32(cfg: *mut git_config, name: *const c_char, value: i32) -> c_int; pub fn git_config_set_int64(cfg: *mut git_config, name: *const c_char, value: i64) -> c_int; pub fn git_config_set_string(cfg: *mut git_config, name: *const c_char, value: *const c_char) -> c_int; pub fn git_config_snapshot(out: *mut *mut git_config, config: *mut git_config) -> c_int; pub fn git_config_entry_free(entry: *mut git_config_entry); // cred pub fn git_cred_default_new(out: *mut *mut git_cred) -> c_int; pub fn git_cred_has_username(cred: *mut git_cred) -> c_int; pub fn git_cred_ssh_custom_new(out: *mut *mut git_cred, username: *const c_char, publickey: *const c_char, publickey_len: size_t, sign_callback: git_cred_sign_callback, payload: *mut c_void) -> c_int; pub fn git_cred_ssh_interactive_new(out: *mut *mut git_cred, username: *const c_char, prompt_callback: git_cred_ssh_interactive_callback, payload: *mut c_void) -> c_int; pub fn git_cred_ssh_key_from_agent(out: *mut *mut git_cred, username: *const c_char) -> c_int; pub fn git_cred_ssh_key_new(out: *mut *mut git_cred, username: *const c_char, publickey: *const c_char, privatekey: *const c_char, passphrase: *const c_char) -> c_int; pub fn git_cred_ssh_key_memory_new(out: *mut *mut git_cred, username: *const c_char, publickey: *const c_char, privatekey: *const c_char, passphrase: *const c_char) -> c_int; pub fn git_cred_userpass(cred: *mut *mut git_cred, url: *const c_char, user_from_url: *const c_char, allowed_types: c_uint, payload: *mut c_void) -> c_int; pub fn git_cred_userpass_plaintext_new(out: *mut *mut git_cred, username: *const c_char, password: *const c_char) -> c_int; pub fn git_cred_username_new(cred: *mut *mut git_cred, username: *const c_char) -> c_int; // tags pub fn git_tag_annotation_create(oid: *mut git_oid, repo: *mut git_repository, tag_name: *const c_char, target: *const git_object, tagger: *const git_signature, message: *const c_char) -> c_int; pub fn git_tag_create(oid: *mut git_oid, repo: *mut git_repository, tag_name: *const c_char, target: *const git_object, tagger: *const git_signature, message: *const c_char, force: c_int) -> c_int; pub fn git_tag_create_frombuffer(oid: *mut git_oid, repo: *mut git_repository, buffer: *const c_char, force: c_int) -> c_int; pub fn git_tag_create_lightweight(oid: *mut git_oid, repo: *mut git_repository, tag_name: *const c_char, target: *const git_object, force: c_int) -> c_int; pub fn git_tag_delete(repo: *mut git_repository, tag_name: *const c_char) -> c_int; pub fn git_tag_foreach(repo: *mut git_repository, callback: git_tag_foreach_cb, payload: *mut c_void) -> c_int; pub fn git_tag_free(tag: *mut git_tag); pub fn git_tag_id(tag: *const git_tag) -> *const git_oid; pub fn git_tag_list(tag_names: *mut git_strarray, repo: *mut git_repository) -> c_int; pub fn git_tag_list_match(tag_names: *mut git_strarray, pattern: *const c_char, repo: *mut git_repository) -> c_int; pub fn git_tag_lookup(out: *mut *mut git_tag, repo: *mut git_repository, id: *const git_oid) -> c_int; pub fn git_tag_lookup_prefix(out: *mut *mut git_tag, repo: *mut git_repository, id: *const git_oid, len: size_t) -> c_int; pub fn git_tag_message(tag: *const git_tag) -> *const c_char; pub fn git_tag_name(tag: *const git_tag) -> *const c_char; pub fn git_tag_peel(tag_target_out: *mut *mut git_object, tag: *const git_tag) -> c_int; pub fn git_tag_tagger(tag: *const git_tag) -> *const git_signature; pub fn git_tag_target(target_out: *mut *mut git_object, tag: *const git_tag) -> c_int; pub fn git_tag_target_id(tag: *const git_tag) -> *const git_oid; pub fn git_tag_target_type(tag: *const git_tag) -> git_otype; // checkout pub fn git_checkout_head(repo: *mut git_repository, opts: *const git_checkout_options) -> c_int; pub fn git_checkout_index(repo: *mut git_repository, index: *mut git_index, opts: *const git_checkout_options) -> c_int; pub fn git_checkout_tree(repo: *mut git_repository, treeish: *const git_object, opts: *const git_checkout_options) -> c_int; pub fn git_checkout_init_options(opts: *mut git_checkout_options, version: c_uint) -> c_int; // merge pub fn git_annotated_commit_id(commit: *const git_annotated_commit) -> *const git_oid; pub fn git_annotated_commit_from_ref(out: *mut *mut git_annotated_commit, repo: *mut git_repository, reference: *const git_reference) -> c_int; pub fn git_annotated_commit_free(commit: *mut git_annotated_commit); pub fn git_merge_init_options(opts: *mut git_merge_options, version: c_uint) -> c_int; pub fn git_merge(repo: *mut git_repository, their_heads: *mut *const git_annotated_commit, len: size_t, merge_opts: *const git_merge_options, checkout_opts: *const git_checkout_options) -> c_int; pub fn git_merge_commits(out: *mut *mut git_index, repo: *mut git_repository, our_commit: *const git_commit, their_commit: *const git_commit, opts: *const git_merge_options) -> c_int; pub fn git_repository_state_cleanup(repo: *mut git_repository) -> c_int; // notes pub fn git_note_author(note: *const git_note) -> *const git_signature; pub fn git_note_committer(note: *const git_note) -> *const git_signature; pub fn git_note_create(out: *mut git_oid, repo: *mut git_repository, notes_ref: *const c_char, author: *const git_signature, committer: *const git_signature, oid: *const git_oid, note: *const c_char, force: c_int) -> c_int; pub fn git_note_default_ref(out: *mut git_buf, repo: *mut git_repository) -> c_int; pub fn git_note_free(note: *mut git_note); pub fn git_note_id(note: *const git_note) -> *const git_oid; pub fn git_note_iterator_free(it: *mut git_note_iterator); pub fn git_note_iterator_new(out: *mut *mut git_note_iterator, repo: *mut git_repository, notes_ref: *const c_char) -> c_int; pub fn git_note_message(note: *const git_note) -> *const c_char; pub fn git_note_next(note_id: *mut git_oid, annotated_id: *mut git_oid, it: *mut git_note_iterator) -> c_int; pub fn git_note_read(out: *mut *mut git_note, repo: *mut git_repository, notes_ref: *const c_char, oid: *const git_oid) -> c_int; pub fn git_note_remove(repo: *mut git_repository, notes_ref: *const c_char, author: *const git_signature, committer: *const git_signature, oid: *const git_oid) -> c_int; // blame pub fn git_blame_file(out: *mut *mut git_blame, repo: *mut git_repository, path: *const c_char, options: *mut git_blame_options) -> c_int; pub fn git_blame_free(blame: *mut git_blame); pub fn git_blame_init_options(opts: *mut git_blame_options, version: c_uint) -> c_int; pub fn git_blame_get_hunk_count(blame: *mut git_blame) -> u32; pub fn git_blame_get_hunk_byline(blame: *mut git_blame, lineno: u32) -> *const git_blame_hunk; pub fn git_blame_get_hunk_byindex(blame: *mut git_blame, index: u32) -> *const git_blame_hunk; // revwalk pub fn git_revwalk_new(out: *mut *mut git_revwalk, repo: *mut git_repository) -> c_int; pub fn git_revwalk_free(walk: *mut git_revwalk); pub fn git_revwalk_reset(walk: *mut git_revwalk); pub fn git_revwalk_sorting(walk: *mut git_revwalk, sort_mode: c_uint); pub fn git_revwalk_push_head(walk: *mut git_revwalk) -> c_int; pub fn git_revwalk_push(walk: *mut git_revwalk, oid: *const git_oid) -> c_int; pub fn git_revwalk_push_ref(walk: *mut git_revwalk, refname: *const c_char) -> c_int; pub fn git_revwalk_push_glob(walk: *mut git_revwalk, glob: *const c_char) -> c_int; pub fn git_revwalk_push_range(walk: *mut git_revwalk, range: *const c_char) -> c_int; pub fn git_revwalk_simplify_first_parent(walk: *mut git_revwalk); pub fn git_revwalk_hide_head(walk: *mut git_revwalk) -> c_int; pub fn git_revwalk_hide(walk: *mut git_revwalk, oid: *const git_oid) -> c_int; pub fn git_revwalk_hide_ref(walk: *mut git_revwalk, refname: *const c_char) -> c_int; pub fn git_revwalk_hide_glob(walk: *mut git_revwalk, refname: *const c_char) -> c_int; pub fn git_revwalk_next(out: *mut git_oid, walk: *mut git_revwalk) -> c_int; // merge pub fn git_merge_base(out: *mut git_oid, repo: *mut git_repository, one: *const git_oid, two: *const git_oid) -> c_int; pub fn git_merge_bases(out: *mut git_oidarray, repo: *mut git_repository, one: *const git_oid, two: *const git_oid) -> c_int; // pathspec pub fn git_pathspec_free(ps: *mut git_pathspec); pub fn git_pathspec_match_diff(out: *mut *mut git_pathspec_match_list, diff: *mut git_diff, flags: u32, ps: *mut git_pathspec) -> c_int; pub fn git_pathspec_match_index(out: *mut *mut git_pathspec_match_list, index: *mut git_index, flags: u32, ps: *mut git_pathspec) -> c_int; pub fn git_pathspec_match_list_diff_entry(m: *const git_pathspec_match_list, pos: size_t) -> *const git_diff_delta; pub fn git_pathspec_match_list_entry(m: *const git_pathspec_match_list, pos: size_t) -> *const c_char; pub fn git_pathspec_match_list_entrycount(m: *const git_pathspec_match_list) -> size_t; pub fn git_pathspec_match_list_failed_entry(m: *const git_pathspec_match_list, pos: size_t) -> *const c_char; pub fn git_pathspec_match_list_failed_entrycount( m: *const git_pathspec_match_list) -> size_t; pub fn git_pathspec_match_list_free(m: *mut git_pathspec_match_list); pub fn git_pathspec_match_tree(out: *mut *mut git_pathspec_match_list, tree: *mut git_tree, flags: u32, ps: *mut git_pathspec) -> c_int; pub fn git_pathspec_match_workdir(out: *mut *mut git_pathspec_match_list, repo: *mut git_repository, flags: u32, ps: *mut git_pathspec) -> c_int; pub fn git_pathspec_matches_path(ps: *const git_pathspec, flags: u32, path: *const c_char) -> c_int; pub fn git_pathspec_new(out: *mut *mut git_pathspec, pathspec: *const git_strarray) -> c_int; // diff pub fn git_diff_blob_to_buffer(old_blob: *const git_blob, old_as_path: *const c_char, buffer: *const c_char, buffer_len: size_t, buffer_as_path: *const c_char, options: *const git_diff_options, file_cb: git_diff_file_cb, binary_cb: git_diff_binary_cb, hunk_cb: git_diff_hunk_cb, line_cb: git_diff_line_cb, payload: *mut c_void) -> c_int; pub fn git_diff_blobs(old_blob: *const git_blob, old_as_path: *const c_char, new_blob: *const git_blob, new_as_path: *const c_char, options: *const git_diff_options, file_cb: git_diff_file_cb, binary_cb: git_diff_binary_cb, hunk_cb: git_diff_hunk_cb, line_cb: git_diff_line_cb, payload: *mut c_void) -> c_int; pub fn git_diff_buffers(old_buffer: *const c_void, old_len: size_t, old_as_path: *const c_char, new_buffer: *const c_void, new_len: size_t, new_as_path: *const c_char, options: *const git_diff_options, file_cb: git_diff_file_cb, binary_cb: git_diff_binary_cb, hunk_cb: git_diff_hunk_cb, line_cb: git_diff_line_cb, payload: *mut c_void) -> c_int; pub fn git_diff_find_similar(diff: *mut git_diff, options: *const git_diff_find_options) -> c_int; pub fn git_diff_find_init_options(opts: *mut git_diff_find_options, version: c_uint) -> c_int; pub fn git_diff_foreach(diff: *mut git_diff, file_cb: git_diff_file_cb, binary_cb: git_diff_binary_cb, hunk_cb: git_diff_hunk_cb, line_cb: git_diff_line_cb, payload: *mut c_void) -> c_int; pub fn git_diff_free(diff: *mut git_diff); pub fn git_diff_get_delta(diff: *const git_diff, idx: size_t) -> *const git_diff_delta; pub fn git_diff_get_stats(out: *mut *mut git_diff_stats, diff: *mut git_diff) -> c_int; pub fn git_diff_index_to_workdir(diff: *mut *mut git_diff, repo: *mut git_repository, index: *mut git_index, opts: *const git_diff_options) -> c_int; pub fn git_diff_init_options(opts: *mut git_diff_options, version: c_uint) -> c_int; pub fn git_diff_is_sorted_icase(diff: *const git_diff) -> c_int; pub fn git_diff_merge(onto: *mut git_diff, from: *const git_diff) -> c_int; pub fn git_diff_num_deltas(diff: *const git_diff) -> size_t; pub fn git_diff_num_deltas_of_type(diff: *const git_diff, delta: git_delta_t) -> size_t; pub fn git_diff_print(diff: *mut git_diff, format: git_diff_format_t, print_cb: git_diff_line_cb, payload: *mut c_void) -> c_int; pub fn git_diff_stats_deletions(stats: *const git_diff_stats) -> size_t; pub fn git_diff_stats_files_changed(stats: *const git_diff_stats) -> size_t; pub fn git_diff_stats_free(stats: *mut git_diff_stats); pub fn git_diff_stats_insertions(stats: *const git_diff_stats) -> size_t; pub fn git_diff_stats_to_buf(out: *mut git_buf, stats: *const git_diff_stats, format: git_diff_stats_format_t, width: size_t) -> c_int; pub fn git_diff_status_char(status: git_delta_t) -> c_char; pub fn git_diff_tree_to_index(diff: *mut *mut git_diff, repo: *mut git_repository, old_tree: *mut git_tree, index: *mut git_index, opts: *const git_diff_options) -> c_int; pub fn git_diff_tree_to_tree(diff: *mut *mut git_diff, repo: *mut git_repository, old_tree: *mut git_tree, new_tree: *mut git_tree, opts: *const git_diff_options) -> c_int; pub fn git_diff_tree_to_workdir(diff: *mut *mut git_diff, repo: *mut git_repository, old_tree: *mut git_tree, opts: *const git_diff_options) -> c_int; pub fn git_diff_tree_to_workdir_with_index(diff: *mut *mut git_diff, repo: *mut git_repository, old_tree: *mut git_tree, opts: *const git_diff_options) -> c_int; pub fn git_graph_ahead_behind(ahead: *mut size_t, behind: *mut size_t, repo: *mut git_repository, local: *const git_oid, upstream: *const git_oid) -> c_int; pub fn git_graph_descendant_of(repo: *mut git_repository, commit: *const git_oid, ancestor: *const git_oid) -> c_int; // reflog pub fn git_reflog_append(reflog: *mut git_reflog, id: *const git_oid, committer: *const git_signature, msg: *const c_char) -> c_int; pub fn git_reflog_delete(repo: *mut git_repository, name: *const c_char) -> c_int; pub fn git_reflog_drop(reflog: *mut git_reflog, idx: size_t, rewrite_previous_entry: c_int) -> c_int; pub fn git_reflog_entry_byindex(reflog: *const git_reflog, idx: size_t) -> *const git_reflog_entry; pub fn git_reflog_entry_committer(entry: *const git_reflog_entry) -> *const git_signature; pub fn git_reflog_entry_id_new(entry: *const git_reflog_entry) -> *const git_oid; pub fn git_reflog_entry_id_old(entry: *const git_reflog_entry) -> *const git_oid; pub fn git_reflog_entry_message(entry: *const git_reflog_entry) -> *const c_char; pub fn git_reflog_entrycount(reflog: *mut git_reflog) -> size_t; pub fn git_reflog_free(reflog: *mut git_reflog); pub fn git_reflog_read(out: *mut *mut git_reflog, repo: *mut git_repository, name: *const c_char) -> c_int; pub fn git_reflog_rename(repo: *mut git_repository, old_name: *const c_char, name: *const c_char) -> c_int; pub fn git_reflog_write(reflog: *mut git_reflog) -> c_int; // transport pub fn git_transport_register(prefix: *const c_char, cb: git_transport_cb, param: *mut c_void) -> c_int; pub fn git_transport_unregister(prefix: *const c_char) -> c_int; pub fn git_transport_smart(out: *mut *mut git_transport, owner: *mut git_remote, payload: *mut c_void) -> c_int; // describe pub fn git_describe_commit(result: *mut *mut git_describe_result, object: *mut git_object, opts: *mut git_describe_options) -> c_int; pub fn git_describe_format(buf: *mut git_buf, result: *const git_describe_result, opts: *const git_describe_format_options) -> c_int; pub fn git_describe_result_free(result: *mut git_describe_result); pub fn git_describe_workdir(out: *mut *mut git_describe_result, repo: *mut git_repository, opts: *mut git_describe_options) -> c_int; } #[test] fn smoke() { unsafe { git_threads_init(); } } deps/libgit2-sys-0.3.8/Cargo.toml0000664000175000017500000000226112624411345013502 0ustar [package] name = "libgit2-sys" version = "0.3.8" authors = ["Alex Crichton "] links = "git2" build = "build.rs" repository = "https://github.com/alexcrichton/git2-rs" license = "MIT/Apache-2.0" description = "Native bindings to the libgit2 library" [lib] name = "libgit2_sys" path = "lib.rs" [dependencies] libssh2-sys = { version = ">= 0", optional = true } libc = "0.2" libz-sys = ">= 0" [build-dependencies] pkg-config = "0.3" cmake = "0.1.2" [target.i686-unknown-linux-gnu.dependencies] openssl-sys = "0.7.0" [target.x86_64-unknown-linux-gnu.dependencies] openssl-sys = "0.7.0" [target.x86_64-unknown-linux-musl.dependencies] openssl-sys = "0.7.0" [target.aarch64-unknown-linux-gnu.dependencies] openssl-sys = "0.7.0" [target.arm-unknown-linux-gnueabihf.dependencies] openssl-sys = "0.7.0" [target.i686-unknown-freebsd.dependencies] openssl-sys = "0.7.0" [target.x86_64-unknown-freebsd.dependencies] openssl-sys = "0.7.0" [target.x86_64-unknown-bitrig.dependencies] openssl-sys = "0.7.0" [target.x86_64-unknown-openbsd.dependencies] openssl-sys = "0.7.0" [target.x86_64-unknown-dragonfly.dependencies] openssl-sys = "0.7.0" [features] ssh = ["libssh2-sys"] https = [] deps/libgit2-sys-0.3.8/build.rs0000664000175000017500000001120512611775731013225 0ustar extern crate pkg_config; extern crate cmake; use std::env; use std::fs::{self, File}; use std::io::prelude::*; use std::path::{Path, PathBuf}; use std::process::Command; macro_rules! t { ($e:expr) => (match $e{ Ok(e) => e, Err(e) => panic!("{} failed with {}", stringify!($e), e), }) } fn main() { let https = env::var("CARGO_FEATURE_HTTPS").is_ok(); let ssh = env::var("CARGO_FEATURE_SSH").is_ok(); if ssh { register_dep("SSH2"); } if https { register_dep("OPENSSL"); } let has_pkgconfig = Command::new("pkg-config").output().is_ok(); if env::var("LIBGIT2_SYS_USE_PKG_CONFIG").is_ok() { if pkg_config::find_library("libgit2").is_ok() { return } } let target = env::var("TARGET").unwrap(); let windows = target.contains("windows"); let msvc = target.contains("msvc"); let mut cfg = cmake::Config::new("libgit2"); if msvc { // libgit2 passes the /GL flag to enable whole program optimization, but // this requires that the /LTCG flag is passed to the linker later on, // and currently the compiler does not do that, so we disable whole // program optimization entirely. cfg.cflag("/GL-"); // Currently liblibc links to msvcrt which apparently is a dynamic CRT, // so we need to turn this off to get it to link right. cfg.define("STATIC_CRT", "OFF"); } // libgit2 uses pkg-config to discover libssh2, but this doesn't work on // windows as libssh2 doesn't come with a libssh2.pc file in that install // (or when pkg-config isn't found). As a result we just manually turn on // SSH support in libgit2 (a little jankily) here... if ssh && (windows || !has_pkgconfig) { if let Ok(libssh2_include) = env::var("DEP_SSH2_INCLUDE") { if msvc { cfg.cflag(format!("/I{}", libssh2_include)) .cflag("/DGIT_SSH"); } else { cfg.cflag(format!("-I{}", libssh2_include)) .cflag("-DGIT_SSH"); } } } if ssh { cfg.register_dep("SSH2"); } else { cfg.define("USE_SSH", "OFF"); } if https { cfg.register_dep("OPENSSL"); } else { cfg.define("USE_OPENSSL", "OFF"); } let _ = fs::remove_dir_all(env::var("OUT_DIR").unwrap()); t!(fs::create_dir_all(env::var("OUT_DIR").unwrap())); let dst = cfg.define("BUILD_SHARED_LIBS", "OFF") .define("BUILD_CLAR", "OFF") .define("CURL", "OFF") .register_dep("Z") .build(); // Make sure libssh2 was detected on unix systems, because it definitely // should have been! if ssh && !msvc { let flags = dst.join("build/CMakeFiles/git2.dir/flags.make"); let mut contents = String::new(); t!(t!(File::open(flags)).read_to_string(&mut contents)); if !contents.contains("-DGIT_SSH") { panic!("libgit2 failed to find libssh2, and SSH support is required"); } } if target.contains("windows") { println!("cargo:rustc-link-lib=winhttp"); println!("cargo:rustc-link-lib=rpcrt4"); println!("cargo:rustc-link-lib=ole32"); println!("cargo:rustc-link-lib=crypt32"); println!("cargo:rustc-link-lib=static=git2"); println!("cargo:rustc-link-search=native={}/lib", dst.display()); return } if env::var("HOST") == env::var("TARGET") { // libssh2 is linked in elsehwere, don't want it reported via pkg-config let pc = dst.join("lib/pkgconfig/libgit2.pc"); let mut contents = String::new(); t!(t!(File::open(&pc)).read_to_string(&mut contents)); let contents = contents.replace(" -lssh2 ", " "); t!(t!(File::create(&pc)).write_all(contents.as_bytes())); prepend("PKG_CONFIG_PATH", dst.join("lib/pkgconfig")); if pkg_config::Config::new().statik(true).find("libgit2").is_ok() { return } } println!("cargo:rustc-link-lib=static=git2"); println!("cargo:rustc-link-search=native={}", dst.join("lib").display()); if target.contains("apple") { println!("cargo:rustc-link-lib=iconv"); } } fn register_dep(dep: &str) { match env::var(&format!("DEP_{}_ROOT", dep)) { Ok(s) => { prepend("PKG_CONFIG_PATH", Path::new(&s).join("lib/pkgconfig")); } Err(..) => {} } } fn prepend(var: &str, val: PathBuf) { let prefix = env::var(var).unwrap_or(String::new()); let mut v = vec![val]; v.extend(env::split_paths(&prefix)); env::set_var(var, &env::join_paths(v).unwrap()); } deps/libgit2-sys-0.3.8/libgit2/0000755000000000000000000000000012666635521014673 5ustar rootrootdeps/libgit2-sys-0.3.8/libgit2/api.docurium0000664000175000017500000000042012426525445015432 0ustar { "name": "libgit2", "github": "libgit2/libgit2", "input": "include/git2", "prefix": "git_", "output": "docs", "branch": "gh-pages", "examples": "examples", "legacy": { "input": {"src/git": ["v0.1.0"], "src/git2": ["v0.2.0", "v0.3.0"]} } } deps/libgit2-sys-0.3.8/libgit2/libgit2.pc.in0000664000175000017500000000044712610310643015371 0ustar prefix=@PKGCONFIG_PREFIX@ libdir=@PKGCONFIG_LIBDIR@ includedir=@PKGCONFIG_INCLUDEDIR@ Name: libgit2 Description: The git library, take 2 Version: @LIBGIT2_VERSION_STRING@ Libs: -L${libdir} -lgit2 Libs.private: @LIBGIT2_PC_LIBS@ Requires.private: @LIBGIT2_PC_REQUIRES@ Cflags: -I${includedir} deps/libgit2-sys-0.3.8/libgit2/git.git-authors0000664000175000017500000000572212572105236016067 0ustar # This document lists the authors that have given voice to # their decision regarding relicensing the GPL'd code from # git.git to the GPL + gcc-exception license used by libgit2. # # Note that the permission is given for libgit2 use only. For # other uses, you must ask each of the contributors yourself. # # To show the owners of a file in git.git, one can run the # following command: # # git blame -C -C -M -- file | \ # sed -e 's/[^(]*(\([^0-9]*\).*/\1/' -e 's/[\t ]*$//' | \ # sort | uniq -c | sort -nr # # If everyone on the list that produces are on the list in # the recently added file "git.git-authors", it *should* be # safe to include that code in libgit2, but make sure to # read the file to ensure the code doesn't originate from # somewhere else. # # The format of this list is # "ok/no/ask/???""Author""" # # "ok" means the author consents to relicensing all their # contributed code (possibly with some exceptions) # "no" means the author does not consent # "ask" means that the contributor wants to give/withhold # his/her consent on a patch-by-patch basis. # "???" means the person is a prominent contributor who has # not yet made his/her standpoint clear. # # Please try to keep the list alphabetically ordered. It will # help in case we get all 600-ish git.git authors on it. # # (Paul Kocher is the author of the mozilla-sha1 implementation # but has otherwise not contributed to git.) # ok Adam Simpkins (http transport) ok Adrian Johnson ok Alexey Shumkin ok Andreas Ericsson ok Antoine Pelisse ok Boyd Lynn Gerber ok Brandon Casey ok Brian Downing ok Brian Gernhardt ok Christian Couder ok Daniel Barkalow ok Florian Forster ok Gustaf Hendeby ok Holger Weiss ok Jeff King ok Johannes Schindelin ok Johannes Sixt ask Jonathan Nieder ok Junio C Hamano ok Kristian Høgsberg ok Linus Torvalds ok Lukas Sandström ok Matthieu Moy ok Michael Haggerty ok Nicolas Pitre ok Paolo Bonzini ok Paul Kocher ok Peter Hagervall ok Petr Onderka ok Pierre Habouzit ok Pieter de Bie ok René Scharfe ok Sebastian Schuberth ok Shawn O. Pearce ok Steffen Prohaska ok Sven Verdoolaege ask Thomas Rast (ok before 6-Oct-2013) ok Torsten Bögershausen deps/libgit2-sys-0.3.8/libgit2/PROJECTS.md0000664000175000017500000001172012510265101014650 0ustar Projects For LibGit2 ==================== So, you want to start helping out with `libgit2`? That's fantastic! We welcome contributions and we promise we'll try to be nice. This is a list of libgit2 related projects that new contributors can take on. It includes a number of good starter projects and well as some larger ideas that no one is actively working on. ## Before You Start Please start by reading the [README.md](README.md), [CONTRIBUTING.md](CONTRIBUTING.md), and [CONVENTIONS.md](CONVENTIONS.md) files before diving into one of these projects. Those explain our work flow and coding conventions to help ensure that your work will be easily integrated into libgit2. Next, work through the build instructions and make sure you can clone the repository, compile it, and run the tests successfully. That will make sure that your development environment is set up correctly and you are ready to start on libgit2 development. ## Starter Projects These are good small projects to get started with libgit2. * Look at the `examples/` programs, find an existing one that mirrors a core Git command and add a missing command-line option. There are many gaps right now and this helps demonstrate how to use the library. Here are some specific ideas (though there are many more): * Fix the `examples/diff.c` implementation of the `-B` (a.k.a. `--break-rewrites`) command line option to actually look for the optional `[][/]` configuration values. There is an existing comment that reads `/* TODO: parse thresholds */`. The trick to this one will be doing it in a manner that is clean and simple, but still handles the various cases correctly (e.g. `-B/70%` is apparently a legal setting). * Implement the `--log-size` option for `examples/log.c`. I think all the data is available, you would just need to add the code into the `print_commit()` routine (along with a way of passing the option into that function). * As an extension to the matching idea for `examples/log.c`, add the `-i` option to use `strcasestr()` for matches. * For `examples/log.c`, implement the `--first-parent` option now that libgit2 supports it in the revwalk API. * Pick a Git command that is not already emulated in `examples/` and write a new example that mirrors the behavior. Examples don't have to be perfect emulations, but should demonstrate how to use the libgit2 APIs to get results that are similar to Git commands. This lets you (and us) easily exercise a particular facet of the API and measure compatability and feature parity with core git. * Submit a PR to clarify documentation! While we do try to document all of the APIs, your fresh eyes on the documentation will find areas that are confusing much more easily. If none of these appeal to you, take a look at our issues list to see if there are any unresolved issues you'd like to jump in on. ## Larger Projects These are ideas for larger projects mostly taken from our backlog of [Issues](https://github.com/libgit2/libgit2/issues). Please don't dive into one of these as a first project for libgit2 - we'd rather get to know you first by successfully shipping your work on one of the smaller projects above. Some of these projects are broken down into subprojects and/or have some incremental steps listed towards the larger goal. Those steps might make good smaller projects by themselves. * Port part of the Git test suite to run against the command line emulation in examples/ * Pick a Git command that is emulated in our examples/ area * Extract the Git tests that exercise that command * Convert the tests to call our emulation * These tests could go in examples/tests/... * Fix symlink support for files in the .git directory (i.e. don't overwrite the symlinks when writing the file contents back out) * Add hooks API to enumerate and manage hooks (not run them at this point) * Enumeration of available hooks * Lookup API to see which hooks have a script and get the script * Read/write API to load a hook script and write a hook script * Eventually, callback API to invoke a hook callback when libgit2 executes the action in question * Isolate logic of ignore evaluation into a standalone API * Upgrade internal libxdiff code to latest from core Git * Improve index internals with hashtable lookup for files instead of using binary search every time * Tree builder improvements: * Extend to allow building a tree hierarchy * Apply-patch API * Add a patch editing API to enable "git add -p" type operations * Textconv API to filter binary data before generating diffs (something like the current Filter API, probably). * Performance profiling and improvement * Support "git replace" ref replacements * Include conflicts in diff results and in status * GIT_DELTA_CONFLICT for items in conflict (with multiple files) * Appropriate flags for status * Support sparse checkout (i.e. "core.sparsecheckout" and ".git/info/sparse-checkout") deps/libgit2-sys-0.3.8/libgit2/cmake/0000755000000000000000000000000012666635520015752 5ustar rootrootdeps/libgit2-sys-0.3.8/libgit2/cmake/Modules/0000755000000000000000000000000012666635520017362 5ustar rootrootdeps/libgit2-sys-0.3.8/libgit2/cmake/Modules/AddCFlagIfSupported.cmake0000664000175000017500000000100712426525445022356 0ustar # - Append compiler flag to CMAKE_C_FLAGS if compiler supports it # ADD_C_FLAG_IF_SUPPORTED() # - the compiler flag to test # This internally calls the CHECK_C_COMPILER_FLAG macro. INCLUDE(CheckCCompilerFlag) MACRO(ADD_C_FLAG_IF_SUPPORTED _FLAG) STRING(TOUPPER ${_FLAG} UPCASE) STRING(REGEX REPLACE "^-" "" UPCASE_PRETTY ${UPCASE}) CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED) IF(IS_${UPCASE_PRETTY}_SUPPORTED) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}") ENDIF() ENDMACRO() deps/libgit2-sys-0.3.8/libgit2/cmake/Modules/FindSecurity.cmake0000664000175000017500000000042712555730137021220 0ustar IF (SECURITY_INCLUDE_DIR AND SECURITY_DIRS) SET(SECURITY_FOUND TRUE) ELSE () FIND_PATH(SECURITY_INCLUDE_DIR NAMES Security/Security.h) FIND_LIBRARY(SECURITY_DIRS NAMES Security) IF (SECURITY_INCLUDE_DIR AND SECURITY_DIRS) SET(SECURITY_FOUND TRUE) ENDIF () ENDIF () deps/libgit2-sys-0.3.8/libgit2/cmake/Modules/FindCoreFoundation.cmake0000664000175000017500000000051212555730137022323 0ustar IF (COREFOUNDATION_INCLUDE_DIR AND COREFOUNDATION_DIRS) SET(COREFOUNDATION_FOUND TRUE) ELSE () FIND_PATH(COREFOUNDATION_INCLUDE_DIR NAMES CoreFoundation.h) FIND_LIBRARY(COREFOUNDATION_DIRS NAMES CoreFoundation) IF (COREFOUNDATION_INCLUDE_DIR AND COREFOUNDATION_DIRS) SET(COREFOUNDATION_FOUND TRUE) ENDIF () ENDIF () deps/libgit2-sys-0.3.8/libgit2/cmake/Modules/FindIconv.cmake0000664000175000017500000000205112555730137020462 0ustar # - Try to find Iconv # Once done this will define # # ICONV_FOUND - system has Iconv # ICONV_INCLUDE_DIR - the Iconv include directory # ICONV_LIBRARIES - Link these to use Iconv # IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) # Already in cache, be silent SET(ICONV_FIND_QUIETLY TRUE) ENDIF() FIND_PATH(ICONV_INCLUDE_DIR iconv.h) FIND_LIBRARY(iconv_lib NAMES iconv libiconv libiconv-2 c) IF(ICONV_INCLUDE_DIR AND iconv_lib) SET(ICONV_FOUND TRUE) ENDIF() IF(ICONV_FOUND) # split iconv into -L and -l linker options, so we can set them for pkg-config GET_FILENAME_COMPONENT(iconv_path ${iconv_lib} PATH) GET_FILENAME_COMPONENT(iconv_name ${iconv_lib} NAME_WE) STRING(REGEX REPLACE "^lib" "" iconv_name ${iconv_name}) SET(ICONV_LIBRARIES "-L${iconv_path} -l${iconv_name}") IF(NOT ICONV_FIND_QUIETLY) MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}") ENDIF(NOT ICONV_FIND_QUIETLY) ELSE() IF(Iconv_FIND_REQUIRED) MESSAGE(FATAL_ERROR "Could not find Iconv") ENDIF(Iconv_FIND_REQUIRED) ENDIF() MARK_AS_ADVANCED( ICONV_INCLUDE_DIR ICONV_LIBRARIES ) deps/libgit2-sys-0.3.8/libgit2/cmake/Modules/FindGSSAPI.cmake0000664000175000017500000001744212426525445020405 0ustar # - Try to find GSSAPI # Once done this will define # # KRB5_CONFIG - Path to krb5-config # GSSAPI_ROOT_DIR - Set this variable to the root installation of GSSAPI # # Read-Only variables: # GSSAPI_FLAVOR_MIT - set to TURE if MIT Kerberos has been found # GSSAPI_FLAVOR_HEIMDAL - set to TRUE if Heimdal Keberos has been found # GSSAPI_FOUND - system has GSSAPI # GSSAPI_INCLUDE_DIR - the GSSAPI include directory # GSSAPI_LIBRARIES - Link these to use GSSAPI # GSSAPI_DEFINITIONS - Compiler switches required for using GSSAPI # #============================================================================= # Copyright (c) 2013 Andreas Schneider # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. # # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= # find_path(GSSAPI_ROOT_DIR NAMES include/gssapi.h include/gssapi/gssapi.h HINTS ${_GSSAPI_ROOT_HINTS} PATHS ${_GSSAPI_ROOT_PATHS} ) mark_as_advanced(GSSAPI_ROOT_DIR) if (UNIX) find_program(KRB5_CONFIG NAMES krb5-config PATHS ${GSSAPI_ROOT_DIR}/bin /opt/local/bin) mark_as_advanced(KRB5_CONFIG) if (KRB5_CONFIG) # Check if we have MIT KRB5 execute_process( COMMAND ${KRB5_CONFIG} --vendor RESULT_VARIABLE _GSSAPI_VENDOR_RESULT OUTPUT_VARIABLE _GSSAPI_VENDOR_STRING) if (_GSSAPI_VENDOR_STRING MATCHES ".*Massachusetts.*") set(GSSAPI_FLAVOR_MIT TRUE) else() execute_process( COMMAND ${KRB5_CONFIG} --libs gssapi RESULT_VARIABLE _GSSAPI_LIBS_RESULT OUTPUT_VARIABLE _GSSAPI_LIBS_STRING) if (_GSSAPI_LIBS_STRING MATCHES ".*roken.*") set(GSSAPI_FLAVOR_HEIMDAL TRUE) endif() endif() # Get the include dir execute_process( COMMAND ${KRB5_CONFIG} --cflags gssapi RESULT_VARIABLE _GSSAPI_INCLUDE_RESULT OUTPUT_VARIABLE _GSSAPI_INCLUDE_STRING) string(REGEX REPLACE "(\r?\n)+$" "" _GSSAPI_INCLUDE_STRING "${_GSSAPI_INCLUDE_STRING}") string(REGEX REPLACE " *-I" "" _GSSAPI_INCLUDEDIR "${_GSSAPI_INCLUDE_STRING}") endif() if (NOT GSSAPI_FLAVOR_MIT AND NOT GSSAPI_FLAVOR_HEIMDAL) # Check for HEIMDAL find_package(PkgConfig) if (PKG_CONFIG_FOUND) pkg_check_modules(_GSSAPI heimdal-gssapi) endif (PKG_CONFIG_FOUND) if (_GSSAPI_FOUND) set(GSSAPI_FLAVOR_HEIMDAL TRUE) else() find_path(_GSSAPI_ROKEN NAMES roken.h PATHS ${GSSAPI_ROOT_DIR}/include ${_GSSAPI_INCLUDEDIR}) if (_GSSAPI_ROKEN) set(GSSAPI_FLAVOR_HEIMDAL TRUE) endif() endif () endif() endif (UNIX) find_path(GSSAPI_INCLUDE_DIR NAMES gssapi.h gssapi/gssapi.h PATHS ${GSSAPI_ROOT_DIR}/include ${_GSSAPI_INCLUDEDIR} ) if (GSSAPI_FLAVOR_MIT) find_library(GSSAPI_LIBRARY NAMES gssapi_krb5 PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR} ) find_library(KRB5_LIBRARY NAMES krb5 PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR} ) find_library(K5CRYPTO_LIBRARY NAMES k5crypto PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR} ) find_library(COM_ERR_LIBRARY NAMES com_err PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR} ) if (GSSAPI_LIBRARY) set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${GSSAPI_LIBRARY} ) endif (GSSAPI_LIBRARY) if (KRB5_LIBRARY) set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${KRB5_LIBRARY} ) endif (KRB5_LIBRARY) if (K5CRYPTO_LIBRARY) set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${K5CRYPTO_LIBRARY} ) endif (K5CRYPTO_LIBRARY) if (COM_ERR_LIBRARY) set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${COM_ERR_LIBRARY} ) endif (COM_ERR_LIBRARY) endif (GSSAPI_FLAVOR_MIT) if (GSSAPI_FLAVOR_HEIMDAL) find_library(GSSAPI_LIBRARY NAMES gssapi PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR} ) find_library(KRB5_LIBRARY NAMES krb5 PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR} ) find_library(HCRYPTO_LIBRARY NAMES hcrypto PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR} ) find_library(COM_ERR_LIBRARY NAMES com_err PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR} ) find_library(HEIMNTLM_LIBRARY NAMES heimntlm PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR} ) find_library(HX509_LIBRARY NAMES hx509 PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR} ) find_library(ASN1_LIBRARY NAMES asn1 PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR} ) find_library(WIND_LIBRARY NAMES wind PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR} ) find_library(ROKEN_LIBRARY NAMES roken PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR} ) if (GSSAPI_LIBRARY) set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${GSSAPI_LIBRARY} ) endif (GSSAPI_LIBRARY) if (KRB5_LIBRARY) set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${KRB5_LIBRARY} ) endif (KRB5_LIBRARY) if (HCRYPTO_LIBRARY) set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${HCRYPTO_LIBRARY} ) endif (HCRYPTO_LIBRARY) if (COM_ERR_LIBRARY) set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${COM_ERR_LIBRARY} ) endif (COM_ERR_LIBRARY) if (HEIMNTLM_LIBRARY) set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${HEIMNTLM_LIBRARY} ) endif (HEIMNTLM_LIBRARY) if (HX509_LIBRARY) set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${HX509_LIBRARY} ) endif (HX509_LIBRARY) if (ASN1_LIBRARY) set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${ASN1_LIBRARY} ) endif (ASN1_LIBRARY) if (WIND_LIBRARY) set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${WIND_LIBRARY} ) endif (WIND_LIBRARY) if (ROKEN_LIBRARY) set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${WIND_LIBRARY} ) endif (ROKEN_LIBRARY) endif (GSSAPI_FLAVOR_HEIMDAL) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(GSSAPI DEFAULT_MSG GSSAPI_LIBRARIES GSSAPI_INCLUDE_DIR) if (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES) set(GSSAPI_FOUND TRUE) endif (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES) # show the GSSAPI_INCLUDE_DIRS and GSSAPI_LIBRARIES variables only in the advanced view mark_as_advanced(GSSAPI_INCLUDE_DIRS GSSAPI_LIBRARIES) deps/libgit2-sys-0.3.8/libgit2/cmake/Modules/FindHTTP_Parser.cmake0000664000175000017500000000316712426525445021511 0ustar # - Try to find http-parser # # Defines the following variables: # # HTTP_PARSER_FOUND - system has http-parser # HTTP_PARSER_INCLUDE_DIR - the http-parser include directory # HTTP_PARSER_LIBRARIES - Link these to use http-parser # HTTP_PARSER_VERSION_MAJOR - major version # HTTP_PARSER_VERSION_MINOR - minor version # HTTP_PARSER_VERSION_STRING - the version of http-parser found # Find the header and library FIND_PATH(HTTP_PARSER_INCLUDE_DIR NAMES http_parser.h) FIND_LIBRARY(HTTP_PARSER_LIBRARY NAMES http_parser libhttp_parser) # Found the header, read version if (HTTP_PARSER_INCLUDE_DIR AND EXISTS "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h") FILE(READ "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h" HTTP_PARSER_H) IF (HTTP_PARSER_H) STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MAJOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MAJOR "${HTTP_PARSER_H}") STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MINOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MINOR "${HTTP_PARSER_H}") SET(HTTP_PARSER_VERSION_STRING "${HTTP_PARSER_VERSION_MAJOR}.${HTTP_PARSER_VERSION_MINOR}") ENDIF() UNSET(HTTP_PARSER_H) ENDIF() # Handle the QUIETLY and REQUIRED arguments and set HTTP_PARSER_FOUND # to TRUE if all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(HTTP_Parser REQUIRED_VARS HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY) # Hide advanced variables MARK_AS_ADVANCED(HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY) # Set standard variables IF (HTTP_PARSER_FOUND) SET(HTTP_PARSER_LIBRARIES ${HTTP_PARSER_LIBRARY}) set(HTTP_PARSER_INCLUDE_DIRS ${HTTP_PARSER_INCLUDE_DIR}) ENDIF() deps/libgit2-sys-0.3.8/libgit2/README.md0000664000175000017500000002224612572105236014373 0ustar libgit2 - the Git linkable library ================================== [![Travis Build Status](https://secure.travis-ci.org/libgit2/libgit2.svg?branch=master)](http://travis-ci.org/libgit2/libgit2) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/xvof5b4t5480a2q3/branch/master?svg=true)](https://ci.appveyor.com/project/libgit2/libgit2/branch/master) [![Coverity Scan Build Status](https://scan.coverity.com/projects/639/badge.svg)](https://scan.coverity.com/projects/639) `libgit2` is a portable, pure C implementation of the Git core methods provided as a re-entrant linkable library with a solid API, allowing you to write native speed custom Git applications in any language with bindings. `libgit2` is licensed under a **very permissive license** (GPLv2 with a special Linking Exception). This basically means that you can link it (unmodified) with any kind of software without having to release its source code. Additionally, the example code has been released to the public domain (see the [separate license](examples/COPYING) for more information). * Website: [libgit2.github.com](http://libgit2.github.com) * StackOverflow Tag: [libgit2](http://stackoverflow.com/questions/tagged/libgit2) * Issues: [GitHub Issues](https://github.com/libgit2/libgit2/issues) (Right here!) * API documentation: * IRC: [#libgit2](irc://irc.freenode.net/libgit2) on irc.freenode.net. * Mailing list: The libgit2 mailing list was traditionally hosted in Librelist but has been deprecated. We encourage you to [use StackOverflow](http://stackoverflow.com/questions/tagged/libgit2) instead for any questions regarding the library, or [open an issue](https://github.com/libgit2/libgit2/issues) on GitHub for bug reports. The mailing list archives are still available at . What It Can Do ============== `libgit2` is already very usable and is being used in production for many applications including the GitHub.com site, in Plastic SCM and also powering Microsoft's Visual Studio tools for Git. The library provides: * SHA conversions, formatting and shortening * abstracted ODB backend system * commit, tag, tree and blob parsing, editing, and write-back * tree traversal * revision walking * index file (staging area) manipulation * reference management (including packed references) * config file management * high level repository management * thread safety and reentrancy * descriptive and detailed error messages * ...and more (over 175 different API calls) Optional dependencies ===================== While the library provides git functionality without the need for dependencies, it can make use of a few libraries to add to it: - pthreads (non-Windows) to enable threadsafe access as well as multi-threaded pack generation - OpenSSL (non-Windows) to talk over HTTPS and provide the SHA-1 functions - LibSSH2 to enable the SSH transport - iconv (OSX) to handle the HFS+ path encoding peculiarities Initialization =============== The library needs to keep track of some global state. Call git_libgit2_init(); before calling any other libgit2 functions. You can call this function many times. A matching number of calls to git_libgit2_shutdown(); will free the resources. Note that if you have worker threads, you should call `git_libgit2_shutdown` *after* those threads have exited. If you require assistance coordinating this, simply have the worker threads call `git_libgit2_init` at startup and `git_libgit2_shutdown` at shutdown. Threading ========= See [THREADING](THREADING.md) for information Building libgit2 - Using CMake ============================== `libgit2` builds cleanly on most platforms without any external dependencies. Under Unix-like systems, like Linux, \*BSD and Mac OS X, libgit2 expects `pthreads` to be available; they should be installed by default on all systems. Under Windows, libgit2 uses the native Windows API for threading. The `libgit2` library is built using [CMake]() (version 2.8 or newer) on all platforms. On most systems you can build the library using the following commands $ mkdir build && cd build $ cmake .. $ cmake --build . Alternatively you can point the CMake GUI tool to the CMakeLists.txt file and generate platform specific build project or IDE workspace. To install the library you can specify the install prefix by setting: $ cmake .. -DCMAKE_INSTALL_PREFIX=/install/prefix $ cmake --build . --target install For more advanced use or questions about CMake please read . The following CMake variables are declared: - `BIN_INSTALL_DIR`: Where to install binaries to. - `LIB_INSTALL_DIR`: Where to install libraries to. - `INCLUDE_INSTALL_DIR`: Where to install headers to. - `BUILD_SHARED_LIBS`: Build libgit2 as a Shared Library (defaults to ON) - `BUILD_CLAR`: Build [Clar](https://github.com/vmg/clar)-based test suite (defaults to ON) - `THREADSAFE`: Build libgit2 with threading support (defaults to ON) - `STDCALL`: Build libgit2 as `stdcall`. Turn off for `cdecl` (Windows; defaults to ON) Compiler and linker options --------------------------- CMake lets you specify a few variables to control the behavior of the compiler and linker. These flags are rarely used but can be useful for 64-bit to 32-bit cross-compilation. - `CMAKE_C_FLAGS`: Set your own compiler flags - `CMAKE_FIND_ROOT_PATH`: Override the search path for libraries - `ZLIB_LIBRARY`, `OPENSSL_SSL_LIBRARY` AND `OPENSSL_CRYPTO_LIBRARY`: Tell CMake where to find those specific libraries MacOS X ------- If you want to build a universal binary for Mac OS X, CMake sets it all up for you if you use `-DCMAKE_OSX_ARCHITECTURES="i386;x86_64"` when configuring. Windows ------- You need to run the CMake commands from the Visual Studio command prompt, not the regular or Windows SDK one. Select the right generator for your version with the `-G "Visual Studio X" option. See [the website](https://libgit2.github.com/docs/guides/build-and-link) for more detailed instructions. Android ------- Extract toolchain from NDK using, `make-standalone-toolchain.sh` script. Optionally, crosscompile and install OpenSSL inside of it. Then create CMake toolchain file that configures paths to your crosscompiler (substitute `{PATH}` with full path to the toolchain): SET(CMAKE_SYSTEM_NAME Linux) SET(CMAKE_SYSTEM_VERSION Android) SET(CMAKE_C_COMPILER {PATH}/bin/arm-linux-androideabi-gcc) SET(CMAKE_CXX_COMPILER {PATH}/bin/arm-linux-androideabi-g++) SET(CMAKE_FIND_ROOT_PATH {PATH}/sysroot/) SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) Add `-DCMAKE_TOOLCHAIN_FILE={pathToToolchainFile}` to cmake command when configuring. Language Bindings ================================== Here are the bindings to libgit2 that are currently available: * C++ * libqgit2, Qt bindings * Chicken Scheme * chicken-git * D * dlibgit * Delphi * GitForDelphi * Erlang * Geef * Go * git2go * GObject * libgit2-glib * Haskell * hgit2 * Java * Jagged * Julia * LibGit2.jl * Lua * luagit2 * .NET * libgit2sharp * Node.js * node-gitteh * nodegit * Objective-C * objective-git * OCaml * ocaml-libgit2 * Parrot Virtual Machine * parrot-libgit2 * Perl * Git-Raw * PHP * php-git * PowerShell * GitPowerShell * Python * pygit2 * R * git2r * Ruby * Rugged * Rust * git2-rs * Swift * Gift * Vala * libgit2.vapi If you start another language binding to libgit2, please let us know so we can add it to the list. How Can I Contribute? ================================== Check the [contribution guidelines](CONTRIBUTING.md) to understand our workflow, the libgit2 [coding conventions](CONVENTIONS.md), and out list of [good starting projects](PROJECTS.md). License ================================== `libgit2` is under GPL2 **with linking exception**. This means you can link to and use the library from any program, proprietary or open source; paid or gratis. However, you cannot modify libgit2 and distribute it without supplying the source. See the [COPYING file](COPYING) for the full license text. deps/libgit2-sys-0.3.8/libgit2/script/0000755000000000000000000000000012666635520016176 5ustar rootrootdeps/libgit2-sys-0.3.8/libgit2/script/cibuild.sh0000775000175000017500000000335312555730137016375 0ustar #!/bin/sh if [ -n "$COVERITY" ]; then ./script/coverity.sh; exit $?; fi mkdir _build cd _build # shellcheck disable=SC2086 cmake .. -DCMAKE_INSTALL_PREFIX=../_install $OPTIONS || exit $? make -j2 install || exit $? # If this platform doesn't support test execution, bail out now if [ -n "$SKIP_TESTS" ]; then exit $?; fi # Create a test repo which we can use for the online::push tests mkdir "$HOME"/_temp git init --bare "$HOME"/_temp/test.git git daemon --listen=localhost --export-all --enable=receive-pack --base-path="$HOME"/_temp "$HOME"/_temp 2>/dev/null & export GITTEST_REMOTE_URL="git://localhost/test.git" # Run the test suite ctest -V . || exit $? # Now that we've tested the raw git protocol, let's set up ssh to we # can do the push tests over it killall git-daemon if [ "$TRAVIS_OS_NAME" = "osx" ]; then echo 'PasswordAuthentication yes' | sudo tee -a /etc/sshd_config fi ssh-keygen -t rsa -f ~/.ssh/id_rsa -N "" -q cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys ssh-keyscan -t rsa localhost >>~/.ssh/known_hosts # Get the fingerprint for localhost and remove the colons so we can parse it as a hex number export GITTEST_REMOTE_SSH_FINGERPRINT=$(ssh-keygen -F localhost -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':') export GITTEST_REMOTE_URL="ssh://localhost/$HOME/_temp/test.git" export GITTEST_REMOTE_USER=$USER export GITTEST_REMOTE_SSH_KEY="$HOME/.ssh/id_rsa" export GITTEST_REMOTE_SSH_PUBKEY="$HOME/.ssh/id_rsa.pub" export GITTEST_REMOTE_SSH_PASSPHRASE="" if [ -e ./libgit2_clar ]; then ./libgit2_clar -sonline::push -sonline::clone::ssh_cert && ./libgit2_clar -sonline::clone::ssh_with_paths || exit $? if [ "$TRAVIS_OS_NAME" = "linux" ]; then ./libgit2_clar -sonline::clone::cred_callback || exit $? fi fi deps/libgit2-sys-0.3.8/libgit2/script/appveyor-mingw.sh0000775000175000017500000000143612510265101017727 0ustar #!/bin/sh set -e cd `dirname "$0"`/.. if [ "$ARCH" = "32" ]; then echo 'C:\MinGW\ /MinGW' > /etc/fstab elif [ "$ARCH" = "i686" ]; then f=i686-4.9.2-release-win32-sjlj-rt_v3-rev1.7z if ! [ -e $f ]; then curl -LsSO http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-win32/sjlj/$f fi 7z x $f > /dev/null mv mingw32 /MinGW else f=x86_64-4.9.2-release-win32-seh-rt_v3-rev1.7z if ! [ -e $f ]; then curl -LsSO http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-win32/seh/$f fi 7z x $f > /dev/null mv mingw64 /MinGW fi cd build cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON .. -G"$GENERATOR" cmake --build . --config RelWithDebInfo deps/libgit2-sys-0.3.8/libgit2/script/coverity.sh0000775000175000017500000000264212510265101016607 0ustar #!/bin/bash set -e # Environment check [ -z "$COVERITY_TOKEN" ] && echo "Need to set a coverity token" && exit 1 # Only run this on our branches echo "Pull request: $TRAVIS_PULL_REQUEST | Slug: $TRAVIS_REPO_SLUG" if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "libgit2/libgit2" ]; then echo "Only analyzing 'development' on the main repo." exit 0 fi COV_VERSION=6.6.1 case $(uname -m) in i?86) BITS=32 ;; amd64|x86_64) BITS=64 ;; esac SCAN_TOOL=https://scan.coverity.com/download/linux-${BITS} TOOL_BASE=$(pwd)/_coverity-scan # Install coverity tools if [ ! -d "$TOOL_BASE" ]; then echo "Downloading coverity..." mkdir -p "$TOOL_BASE" pushd "$TOOL_BASE" wget -O coverity_tool.tgz $SCAN_TOOL \ --post-data "project=libgit2&token=$COVERITY_TOKEN" tar xzf coverity_tool.tgz popd TOOL_DIR=$(find "$TOOL_BASE" -type d -name 'cov-analysis*') ln -s "$TOOL_DIR" "$TOOL_BASE"/cov-analysis fi COV_BUILD="$TOOL_BASE/cov-analysis/bin/cov-build" # Configure and build rm -rf _build mkdir _build cd _build cmake .. -DTHREADSAFE=ON COVERITY_UNSUPPORTED=1 \ $COV_BUILD --dir cov-int \ cmake --build . # Upload results tar czf libgit2.tgz cov-int SHA=$(git rev-parse --short HEAD) curl \ --form project=libgit2 \ --form token="$COVERITY_TOKEN" \ --form email=bs@github.com \ --form file=@libgit2.tgz \ --form version="$SHA" \ --form description="Travis build" \ http://scan5.coverity.com/cgi-bin/upload.py deps/libgit2-sys-0.3.8/libgit2/script/toolchain-mingw32.cmake0000664000175000017500000000064412510265101020652 0ustar # CMake toolchain file for Win32 cross-compile SET(CMAKE_SYSTEM_NAME Windows) SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc) SET(CMAKE_RC_COMPILER i586-mingw32msvc-windres) SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc) SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) SET(ENV{PKG_CONFIG_LIBDIR} ${CMAKE_FIND_ROOT_PATH}/lib/pkgconfig) deps/libgit2-sys-0.3.8/libgit2/script/install-deps-osx.sh0000775000175000017500000000006412572105236020157 0ustar #!/bin/sh set -x brew update brew install libssh2 deps/libgit2-sys-0.3.8/libgit2/docs/0000755000000000000000000000000012666635520015622 5ustar rootrootdeps/libgit2-sys-0.3.8/libgit2/docs/checkout-internals.md0000664000175000017500000003036612426525445020200 0ustar Checkout Internals ================== Checkout has to handle a lot of different cases. It examines the differences between the target tree, the baseline tree and the working directory, plus the contents of the index, and groups files into five categories: 1. UNMODIFIED - Files that match in all places. 2. SAFE - Files where the working directory and the baseline content match that can be safely updated to the target. 3. DIRTY/MISSING - Files where the working directory differs from the baseline but there is no conflicting change with the target. One example is a file that doesn't exist in the working directory - no data would be lost as a result of writing this file. Which action will be taken with these files depends on the options you use. 4. CONFLICTS - Files where changes in the working directory conflict with changes to be applied by the target. If conflicts are found, they prevent any other modifications from being made (although there are options to override that and force the update, of course). 5. UNTRACKED/IGNORED - Files in the working directory that are untracked or ignored (i.e. only in the working directory, not the other places). Right now, this classification is done via 3 iterators (for the three trees), with a final lookup in the index. At some point, this may move to a 4 iterator version to incorporate the index better. The actual checkout is done in five phases (at least right now). 1. The diff between the baseline and the target tree is used as a base list of possible updates to be applied. 2. Iterate through the diff and the working directory, building a list of actions to be taken (and sending notifications about conflicts and dirty files). 3. Remove any files / directories as needed (because alphabetical iteration means that an untracked directory will end up sorted *after* a blob that should be checked out with the same name). 4. Update all blobs. 5. Update all submodules (after 4 in case a new .gitmodules blob was checked out) Checkout could be driven either off a target-to-workdir diff or a baseline-to-target diff. There are pros and cons of each. Target-to-workdir means the diff includes every file that could be modified, which simplifies bookkeeping, but the code to constantly refer back to the baseline gets complicated. Baseline-to-target has simpler code because the diff defines the action to take, but needs special handling for untracked and ignored files, if they need to be removed. The current checkout implementation is based on a baseline-to-target diff. Picking Actions =============== The most interesting aspect of this is phase 2, picking the actions that should be taken. There are a lot of corner cases, so it may be easier to start by looking at the rules for a simple 2-iterator diff: Key --- - B1,B2,B3 - blobs with different SHAs, - Bi - ignored blob (WD only) - T1,T2,T3 - trees with different SHAs, - Ti - ignored tree (WD only) - x - nothing Diff with 2 non-workdir iterators --------------------------------- | | Old | New | | |----|-----|-----|------------------------------------------------------------| | 0 | x | x | nothing | | 1 | x | B1 | added blob | | 2 | x | T1 | added tree | | 3 | B1 | x | removed blob | | 4 | B1 | B1 | unmodified blob | | 5 | B1 | B2 | modified blob | | 6 | B1 | T1 | typechange blob -> tree | | 7 | T1 | x | removed tree | | 8 | T1 | B1 | typechange tree -> blob | | 9 | T1 | T1 | unmodified tree | | 10 | T1 | T2 | modified tree (implies modified/added/removed blob inside) | Now, let's make the "New" iterator into a working directory iterator, so we replace "added" items with either untracked or ignored, like this: Diff with non-work & workdir iterators -------------------------------------- | | Old | New | | |----|-----|-----|------------------------------------------------------------| | 0 | x | x | nothing | | 1 | x | B1 | untracked blob | | 2 | x | Bi | ignored file | | 3 | x | T1 | untracked tree | | 4 | x | Ti | ignored tree | | 5 | B1 | x | removed blob | | 6 | B1 | B1 | unmodified blob | | 7 | B1 | B2 | modified blob | | 8 | B1 | T1 | typechange blob -> tree | | 9 | B1 | Ti | removed blob AND ignored tree as separate items | | 10 | T1 | x | removed tree | | 11 | T1 | B1 | typechange tree -> blob | | 12 | T1 | Bi | removed tree AND ignored blob as separate items | | 13 | T1 | T1 | unmodified tree | | 14 | T1 | T2 | modified tree (implies modified/added/removed blob inside) | Note: if there is a corresponding entry in the old tree, then a working directory item won't be ignored (i.e. no Bi or Ti for tracked items). Now, expand this to three iterators: a baseline tree, a target tree, and an actual working directory tree: Checkout From 3 Iterators (2 not workdir, 1 workdir) ---------------------------------------------------- (base == old HEAD; target == what to checkout; actual == working dir) | |base | target | actual/workdir | | |-----|-----|------- |----------------|--------------------------------------------------------------------| | 0 | x | x | x | nothing | | 1 | x | x | B1/Bi/T1/Ti | untracked/ignored blob/tree (SAFE) | | 2+ | x | B1 | x | add blob (SAFE) | | 3 | x | B1 | B1 | independently added blob (FORCEABLE-2) | | 4* | x | B1 | B2/Bi/T1/Ti | add blob with content conflict (FORCEABLE-2) | | 5+ | x | T1 | x | add tree (SAFE) | | 6* | x | T1 | B1/Bi | add tree with blob conflict (FORCEABLE-2) | | 7 | x | T1 | T1/i | independently added tree (SAFE+MISSING) | | 8 | B1 | x | x | independently deleted blob (SAFE+MISSING) | | 9- | B1 | x | B1 | delete blob (SAFE) | | 10- | B1 | x | B2 | delete of modified blob (FORCEABLE-1) | | 11 | B1 | x | T1/Ti | independently deleted blob AND untrack/ign tree (SAFE+MISSING !!!) | | 12 | B1 | B1 | x | locally deleted blob (DIRTY || SAFE+CREATE) | | 13+ | B1 | B2 | x | update to deleted blob (SAFE+MISSING) | | 14 | B1 | B1 | B1 | unmodified file (SAFE) | | 15 | B1 | B1 | B2 | locally modified file (DIRTY) | | 16+ | B1 | B2 | B1 | update unmodified blob (SAFE) | | 17 | B1 | B2 | B2 | independently updated blob (FORCEABLE-1) | | 18+ | B1 | B2 | B3 | update to modified blob (FORCEABLE-1) | | 19 | B1 | B1 | T1/Ti | locally deleted blob AND untrack/ign tree (DIRTY) | | 20* | B1 | B2 | T1/Ti | update to deleted blob AND untrack/ign tree (F-1) | | 21+ | B1 | T1 | x | add tree with locally deleted blob (SAFE+MISSING) | | 22* | B1 | T1 | B1 | add tree AND deleted blob (SAFE) | | 23* | B1 | T1 | B2 | add tree with delete of modified blob (F-1) | | 24 | B1 | T1 | T1 | add tree with deleted blob (F-1) | | 25 | T1 | x | x | independently deleted tree (SAFE+MISSING) | | 26 | T1 | x | B1/Bi | independently deleted tree AND untrack/ign blob (F-1) | | 27- | T1 | x | T1 | deleted tree (MAYBE SAFE) | | 28+ | T1 | B1 | x | deleted tree AND added blob (SAFE+MISSING) | | 29 | T1 | B1 | B1 | independently typechanged tree -> blob (F-1) | | 30+ | T1 | B1 | B2 | typechange tree->blob with conflicting blob (F-1) | | 31* | T1 | B1 | T1/T2 | typechange tree->blob (MAYBE SAFE) | | 32+ | T1 | T1 | x | restore locally deleted tree (SAFE+MISSING) | | 33 | T1 | T1 | B1/Bi | locally typechange tree->untrack/ign blob (DIRTY) | | 34 | T1 | T1 | T1/T2 | unmodified tree (MAYBE SAFE) | | 35+ | T1 | T2 | x | update locally deleted tree (SAFE+MISSING) | | 36* | T1 | T2 | B1/Bi | update to tree with typechanged tree->blob conflict (F-1) | | 37 | T1 | T2 | T1/T2/T3 | update to existing tree (MAYBE SAFE) | The number is followed by ' ' if no change is needed or '+' if the case needs to write to disk or '-' if something must be deleted and '*' if there should be a delete followed by an write. There are four tiers of safe cases: * SAFE == completely safe to update * SAFE+MISSING == safe except the workdir is missing the expect content * MAYBE SAFE == safe if workdir tree matches (or is missing) baseline content, which is unknown at this point * FORCEABLE == conflict unless FORCE is given * DIRTY == no conflict but change is not applied unless FORCE Some slightly unusual circumstances: * 8 - parent dir is only deleted when file is, so parent will be left if empty even though it would be deleted if the file were present * 11 - core git does not consider this a conflict but attempts to delete T1 and gives "unable to unlink file" error yet does not skip the rest of the operation * 12 - without FORCE file is left deleted (i.e. not restored) so new wd is dirty (and warning message "D file" is printed), with FORCE, file is restored. * 24 - This should be considered MAYBE SAFE since effectively it is 7 and 8 combined, but core git considers this a conflict unless forced. * 26 - This combines two cases (1 & 25) (and also implied 8 for tree content) which are ok on their own, but core git treat this as a conflict. If not forced, this is a conflict. If forced, this actually doesn't have to write anything and leaves the new blob as an untracked file. * 32 - This is the only case where the baseline and target values match and yet we will still write to the working directory. In all other cases, if baseline == target, we don't touch the workdir (it is either already right or is "dirty"). However, since this case also implies that a ?/B1/x case will exist as well, it can be skipped. Cases 3, 17, 24, 26, and 29 are all considered conflicts even though none of them will require making any updates to the working directory. deps/libgit2-sys-0.3.8/libgit2/docs/error-handling.md0000664000175000017500000002434712426525445017313 0ustar Error reporting in libgit2 ========================== Libgit2 tries to follow the POSIX style: functions return an `int` value with 0 (zero) indicating success and negative values indicating an error. There are specific negative error codes for each "expected failure" (e.g. `GIT_ENOTFOUND` for files that take a path which might be missing) and a generic error code (-1) for all critical or non-specific failures (e.g. running out of memory or system corruption). When a negative value is returned, an error message is also set. The message can be accessed via the `giterr_last` function which will return a pointer to a `git_error` structure containing the error message text and the class of error (i.e. what part of the library generated the error). For instance: An object lookup by SHA prefix (`git_object_lookup_prefix`) has two expected failure cases: the SHA is not found at all which returns `GIT_ENOTFOUND` or the SHA prefix is ambiguous (i.e. two or more objects share the prefix) which returns `GIT_EAMBIGUOUS`. There are any number of critical failures (such as a packfile being corrupted, a loose object having the wrong access permissions, etc.) all of which will return -1. When the object lookup is successful, it will return 0. If libgit2 was compiled with threads enabled (`-DTHREADSAFE=ON` when using CMake), then the error message will be kept in thread-local storage, so it will not be modified by other threads. If threads are not enabled, then the error message is in global data. All of the error return codes, the `git_error` type, the error access functions, and the error classes are defined in `include/git2/errors.h`. See the documentation there for details on the APIs for accessing, clearing, and even setting error codes. When writing libgit2 code, please be smart and conservative when returning error codes. Functions usually have a maximum of two or three "expected errors" and in most cases only one. If you feel there are more possible expected error scenarios, then the API you are writing may be at too high a level for core libgit2. Example usage ------------- When using libgit2, you will typically capture the return value from functions using an `int` variable and check to see if it is negative. When that happens, you can, if you wish, look at the specific value or look at the error message that was generated. ~~~c { git_repository *repo; int error = git_repository_open(&repo, "path/to/repo"); if (error < 0) { fprintf(stderr, "Could not open repository: %s\n", giterr_last()->message); exit(1); } ... use `repo` here ... git_repository_free(repo); /* void function - no error return code */ } ~~~ Some of the error return values do have meaning. Optionally, you can look at the specific error values to decide what to do. ~~~c { git_repository *repo; const char *path = "path/to/repo"; int error = git_repository_open(&repo, path); if (error < 0) { if (error == GIT_ENOTFOUND) fprintf(stderr, "Could not find repository at path '%s'\n", path); else fprintf(stderr, "Unable to open repository: %s\n", giterr_last()->message); exit(1); } ... happy ... } ~~~ Some of the higher-level language bindings may use a range of information from libgit2 to convert error return codes into exceptions, including the specific error return codes and even the class of error and the error message returned by `giterr_last`, but the full range of that logic is beyond the scope of this document. Example internal implementation ------------------------------- Internally, libgit2 detects error scenarios, records error messages, and returns error values. Errors from low-level functions are generally passed upwards (unless the higher level can either handle the error or wants to translate the error into something more meaningful). ~~~c int git_repository_open(git_repository **repository, const char *path) { /* perform some logic to open the repository */ if (p_exists(path) < 0) { giterr_set(GITERR_REPOSITORY, "The path '%s' doesn't exist", path); return GIT_ENOTFOUND; } ... } ~~~ The public error API -------------------- - `const git_error *giterr_last(void)`: The main function used to look up the last error. This may return NULL if no error has occurred. Otherwise this should return a `git_error` object indicating the class of error and the error message that was generated by the library. The last error is stored in thread-local storage when libgit2 is compiled with thread support, so you do not have to worry about another thread overwriting the value. When thread support is off, the last error is a global value. _Note_ There are some known bugs in the library where this may return NULL even when an error code was generated. Please report these as bugs, but in the meantime, please code defensively and check for NULL when calling this function. - `void geterr_clear(void)`: This function clears the last error. The library will call this when an error is generated by low level function and the higher level function handles the error. _Note_ There are some known bugs in the library where a low level function's error message is not cleared by higher level code that handles the error and returns zero. Please report these as bugs, but in the meantime, a zero return value from a libgit2 API does not guarantee that `giterr_last()` will return NULL. - `void giterr_set_str(int error_class, const char *message)`: This function can be used when writing a custom backend module to set the libgit2 error message. See the documentation on this function for its use. Normal usage of libgit2 will probably never need to call this API. - `void giterr_set_oom(void)`: This is a standard function for reporting an out-of-memory error. It is written in a manner that it doesn't have to allocate any extra memory in order to record the error, so this is the best way to report that scenario. Deviations from the standard ---------------------------- There are some public functions that do not return `int` values. There are two primary cases: * `void` return values: If a function has a `void` return, then it will never fail. This primary will be used for object destructors. * `git_xyz *` return values: These are simple accessor functions where the only meaningful error would typically be looking something up by index and having the index be out of bounds. In those cases, the function will typically return NULL. * Boolean return values: There are some cases where a function cannot fail and wants to return a boolean value. In those cases, we try to return 1 for true and 0 for false. These cases are rare and the return value for the function should probably be an `unsigned int` to denote these cases. If you find an exception, please open an issue and let's fix it. There are a few other exceptions to these rules here and there in the library, but those are extremely rare and should probably be converted over to other to more standard patterns for usage. Feel free to open issues pointing these out. There are some known bugs in the library where some functions may return a negative value but not set an error message and some other functions may return zero (no error) and yet leave an error message set. Please report these cases as issues and they will be fixed. In the meanwhile, please code defensively, checking that the return value of `giterr_last` is not NULL before using it, and not relying on `giterr_last` to return NULL when a function returns 0 for success. The internal error API ---------------------- - `void giterr_set(int error_class, const char *fmt, ...)`: This is the main internal function for setting an error. It works like `printf` to format the error message. See the notes of `giterr_set_str` for a general description of how error messages are stored (and also about special handling for `error_class` of `GITERR_OS`). Writing error messages ---------------------- Here are some guidelines when writing error messages: - Use proper English, and an impersonal or past tenses: *The given path does not exist*, *Failed to lookup object in ODB* - Use short, direct and objective messages. **One line, max**. libgit2 is a low level library: think that all the messages reported will be thrown as Ruby or Python exceptions. Think how long are common exception messages in those languages. - **Do not add redundant information to the error message**, specially information that can be inferred from the context. E.g. in `git_repository_open`, do not report a message like "Failed to open repository: path not found". Somebody is calling that function. If it fails, they already know that the repository failed to open! General guidelines for error reporting -------------------------------------- - Libgit2 does not handle programming errors with these functions. Programming errors are `assert`ed, and when their source is internal, fixed as soon as possible. This is C, people. Example of programming errors that would **not** be handled: passing NULL to a function that expects a valid pointer; passing a `git_tree` to a function that expects a `git_commit`. All these cases need to be identified with `assert` and fixed asap. Example of a runtime error: failing to parse a `git_tree` because it contains invalid data. Failing to open a file because it doesn't exist on disk. These errors are handled, a meaningful error message is set, and an error code is returned. - In general, *do not* try to overwrite errors internally and *do* propagate error codes from lower level functions to the higher level. There are some cases where propagating an error code will be more confusing rather than less, so there are some exceptions to this rule, but the default behavior should be to simply clean up and pass the error on up to the caller. **WRONG** ~~~c int git_commit_parent(...) { ... if (git_commit_lookup(parent, repo, parent_id) < 0) { giterr_set(GITERR_COMMIT, "Overwrite lookup error message"); return -1; /* mask error code */ } ... } ~~~ **RIGHT** ~~~c int git_commit_parent(...) { ... error = git_commit_lookup(parent, repo, parent_id); if (error < 0) { /* cleanup intermediate objects if necessary */ /* leave error message and propagate error code */ return error; } ... } ~~~ deps/libgit2-sys-0.3.8/libgit2/docs/diff-internals.md0000664000175000017500000001113312426525445017272 0ustar Diff is broken into four phases: 1. Building a list of things that have changed. These changes are called deltas (git_diff_delta objects) and are grouped into a git_diff_list. 2. Applying file similarity measurement for rename and copy detection (and to potentially split files that have changed radically). This step is optional. 3. Computing the textual diff for each delta. Not all deltas have a meaningful textual diff. For those that do, the textual diff can either be generated on the fly and passed to output callbacks or can be turned into a git_diff_patch object. 4. Formatting the diff and/or patch into standard text formats (such as patches, raw lists, etc). In the source code, step 1 is implemented in `src/diff.c`, step 2 in `src/diff_tform.c`, step 3 in `src/diff_patch.c`, and step 4 in `src/diff_print.c`. Additionally, when it comes to accessing file content, everything goes through diff drivers that are implemented in `src/diff_driver.c`. External Objects ---------------- * `git_diff_options` represents user choices about how a diff should be performed and is passed to most diff generating functions. * `git_diff_file` represents an item on one side of a possible delta * `git_diff_delta` represents a pair of items that have changed in some way - it contains two `git_diff_file` plus a status and other stuff. * `git_diff_list` is a list of deltas along with information about how those particular deltas were found. * `git_diff_patch` represents the actual diff between a pair of items. In some cases, a delta may not have a corresponding patch, if the objects are binary, for example. The content of a patch will be a set of hunks and lines. * A `hunk` is range of lines described by a `git_diff_range` (i.e. "lines 10-20 in the old file became lines 12-23 in the new"). It will have a header that compactly represents that information, and it will have a number of lines of context surrounding added and deleted lines. * A `line` is simple a line of data along with a `git_diff_line_t` value that tells how the data should be interpreted (e.g. context or added). Internal Objects ---------------- * `git_diff_file_content` is an internal structure that represents the data on one side of an item to be diffed; it is an augmented `git_diff_file` with more flags and the actual file data. * it is created from a repository plus a) a git_diff_file, b) a git_blob, or c) raw data and size * there are three main operations on git_diff_file_content: * _initialization_ sets up the data structure and does what it can up to, but not including loading and looking at the actual data * _loading_ loads the data, preprocesses it (i.e. applies filters) and potentially analyzes it (to decide if binary) * _free_ releases loaded data and frees any allocated memory * The internal structure of a `git_diff_patch` stores the actual diff between a pair of `git_diff_file_content` items * it may be "unset" if the items are not diffable * "empty" if the items are the same * otherwise it will consist of a set of hunks each of which covers some number of lines of context, additions and deletions * a patch is created from two git_diff_file_content items * a patch is fully instantiated in three phases: * initial creation and initialization * loading of data and preliminary data examination * diffing of data and optional storage of diffs * (TBD) if a patch is asked to store the diffs and the size of the diff is significantly smaller than the raw data of the two sides, then the patch may be flattened using a pool of string data * `git_diff_output` is an internal structure that represents an output target for a `git_diff_patch` * It consists of file, hunk, and line callbacks, plus a payload * There is a standard flattened output that can be used for plain text output * Typically we use a `git_xdiff_output` which drives the callbacks via the xdiff code taken from core Git. * `git_diff_driver` is an internal structure that encapsulates the logic for a given type of file * a driver is looked up based on the name and mode of a file. * the driver can then be used to: * determine if a file is binary (by attributes, by git_diff_options settings, or by examining the content) * give you a function pointer that is used to evaluate function context for hunk headers * At some point, the logic for getting a filtered version of file content or calculating the OID of a file may be moved into the driver. deps/libgit2-sys-0.3.8/libgit2/docs/merge-df_conflicts.txt0000664000175000017500000000250212426525445020336 0ustar Anc / Our / Thr represent the ancestor / ours / theirs side of a merge from branch "branch" into HEAD. Workdir represents the expected files in the working directory. Index represents the expected files in the index, with stage markers. Anc Our Thr Workdir Index 1 D D D/F D/F D/F [0] 2 D D+ D~HEAD (mod/del) D/F [0] D/F D/F D [1] D [2] 3 D D D/F D/F [0] D/F 4 D D+ D~branch (mod/del) D/F [0] D/F D/F D [1] D [3] 5 D D/F (add/add) D/F [2] D/F D/F [3] D/F 6 D/F D/F D D [0] D 7 D/F D/F+ D/F (mod/del) D/F [1] D D~branch (fil/dir) D/F [2] D [3] 8 D/F D/F D D [0] D 9 D/F D/F+ D/F (mod/del) D/F [1] D D~HEAD (fil/dir) D [2] D/F [3] 10 D/F D/F (fil/dir) D/F [0] D D~HEAD D [2] D deps/libgit2-sys-0.3.8/libgit2/src/0000755000000000000000000000000012666635520015461 5ustar rootrootdeps/libgit2-sys-0.3.8/libgit2/src/curl_stream.h0000664000175000017500000000062412555730137016375 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_curl_stream_h__ #define INCLUDE_curl_stream_h__ #include "git2/sys/stream.h" extern int git_curl_stream_new(git_stream **out, const char *host, const char *port); #endif deps/libgit2-sys-0.3.8/libgit2/src/transport.c0000664000175000017500000001276012555730137016110 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "git2/types.h" #include "git2/remote.h" #include "git2/net.h" #include "git2/transport.h" #include "git2/sys/transport.h" #include "path.h" typedef struct transport_definition { char *prefix; git_transport_cb fn; void *param; } transport_definition; static git_smart_subtransport_definition http_subtransport_definition = { git_smart_subtransport_http, 1, NULL }; static git_smart_subtransport_definition git_subtransport_definition = { git_smart_subtransport_git, 0, NULL }; #ifdef GIT_SSH static git_smart_subtransport_definition ssh_subtransport_definition = { git_smart_subtransport_ssh, 0, NULL }; #endif static transport_definition local_transport_definition = { "file://", git_transport_local, NULL }; static transport_definition transports[] = { { "git://", git_transport_smart, &git_subtransport_definition }, { "http://", git_transport_smart, &http_subtransport_definition }, #if defined(GIT_OPENSSL) || defined(GIT_WINHTTP) || defined(GIT_SECURE_TRANSPORT) { "https://", git_transport_smart, &http_subtransport_definition }, #endif { "file://", git_transport_local, NULL }, #ifdef GIT_SSH { "ssh://", git_transport_smart, &ssh_subtransport_definition }, #endif { NULL, 0, 0 } }; static git_vector custom_transports = GIT_VECTOR_INIT; #define GIT_TRANSPORT_COUNT (sizeof(transports)/sizeof(transports[0])) - 1 static transport_definition * transport_find_by_url(const char *url) { size_t i = 0; transport_definition *d; /* Find a user transport who wants to deal with this URI */ git_vector_foreach(&custom_transports, i, d) { if (strncasecmp(url, d->prefix, strlen(d->prefix)) == 0) { return d; } } /* Find a system transport for this URI */ for (i = 0; i < GIT_TRANSPORT_COUNT; ++i) { d = &transports[i]; if (strncasecmp(url, d->prefix, strlen(d->prefix)) == 0) { return d; } } return NULL; } static int transport_find_fn( git_transport_cb *out, const char *url, void **param) { transport_definition *definition = transport_find_by_url(url); #ifdef GIT_WIN32 /* On Windows, it might not be possible to discern between absolute local * and ssh paths - first check if this is a valid local path that points * to a directory and if so assume local path, else assume SSH */ /* Check to see if the path points to a file on the local file system */ if (!definition && git_path_exists(url) && git_path_isdir(url)) definition = &local_transport_definition; #endif /* For other systems, perform the SSH check first, to avoid going to the * filesystem if it is not necessary */ /* It could be a SSH remote path. Check to see if there's a : * SSH is an unsupported transport mechanism in this version of libgit2 */ if (!definition && strrchr(url, ':')) { // re-search transports again with ssh:// as url so that we can find a third party ssh transport definition = transport_find_by_url("ssh://"); } #ifndef GIT_WIN32 /* Check to see if the path points to a file on the local file system */ if (!definition && git_path_exists(url) && git_path_isdir(url)) definition = &local_transport_definition; #endif if (!definition) return GIT_ENOTFOUND; *out = definition->fn; *param = definition->param; return 0; } /************** * Public API * **************/ int git_transport_new(git_transport **out, git_remote *owner, const char *url) { git_transport_cb fn; git_transport *transport; void *param; int error; if ((error = transport_find_fn(&fn, url, ¶m)) == GIT_ENOTFOUND) { giterr_set(GITERR_NET, "Unsupported URL protocol"); return -1; } else if (error < 0) return error; if ((error = fn(&transport, owner, param)) < 0) return error; GITERR_CHECK_VERSION(transport, GIT_TRANSPORT_VERSION, "git_transport"); *out = transport; return 0; } int git_transport_register( const char *scheme, git_transport_cb cb, void *param) { git_buf prefix = GIT_BUF_INIT; transport_definition *d, *definition = NULL; size_t i; int error = 0; assert(scheme); assert(cb); if ((error = git_buf_printf(&prefix, "%s://", scheme)) < 0) goto on_error; git_vector_foreach(&custom_transports, i, d) { if (strcasecmp(d->prefix, prefix.ptr) == 0) { error = GIT_EEXISTS; goto on_error; } } definition = git__calloc(1, sizeof(transport_definition)); GITERR_CHECK_ALLOC(definition); definition->prefix = git_buf_detach(&prefix); definition->fn = cb; definition->param = param; if (git_vector_insert(&custom_transports, definition) < 0) goto on_error; return 0; on_error: git_buf_free(&prefix); git__free(definition); return error; } int git_transport_unregister(const char *scheme) { git_buf prefix = GIT_BUF_INIT; transport_definition *d; size_t i; int error = 0; assert(scheme); if ((error = git_buf_printf(&prefix, "%s://", scheme)) < 0) goto done; git_vector_foreach(&custom_transports, i, d) { if (strcasecmp(d->prefix, prefix.ptr) == 0) { if ((error = git_vector_remove(&custom_transports, i)) < 0) goto done; git__free(d->prefix); git__free(d); if (!custom_transports.length) git_vector_free(&custom_transports); error = 0; goto done; } } error = GIT_ENOTFOUND; done: git_buf_free(&prefix); return error; } int git_transport_init(git_transport *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_transport, GIT_TRANSPORT_INIT); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/object.h0000664000175000017500000000153712426525445015330 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_object_h__ #define INCLUDE_object_h__ /** Base git object for inheritance */ struct git_object { git_cached_obj cached; git_repository *repo; }; /* fully free the object; internal method, DO NOT EXPORT */ void git_object__free(void *object); int git_object__from_odb_object( git_object **object_out, git_repository *repo, git_odb_object *odb_obj, git_otype type); int git_object__resolve_to_type(git_object **obj, git_otype type); int git_oid__parse(git_oid *oid, const char **buffer_out, const char *buffer_end, const char *header); void git_oid__writebuf(git_buf *buf, const char *header, const git_oid *oid); #endif deps/libgit2-sys-0.3.8/libgit2/src/diff_driver.c0000664000175000017500000003040012572105236016321 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "git2/attr.h" #include "diff.h" #include "diff_patch.h" #include "diff_driver.h" #include "strmap.h" #include "map.h" #include "buf_text.h" #include "config.h" #include "repository.h" GIT__USE_STRMAP typedef enum { DIFF_DRIVER_AUTO = 0, DIFF_DRIVER_BINARY = 1, DIFF_DRIVER_TEXT = 2, DIFF_DRIVER_PATTERNLIST = 3, } git_diff_driver_t; typedef struct { regex_t re; int flags; } git_diff_driver_pattern; enum { REG_NEGATE = (1 << 15) /* get out of the way of existing flags */ }; /* data for finding function context for a given file type */ struct git_diff_driver { git_diff_driver_t type; uint32_t binary_flags; uint32_t other_flags; git_array_t(git_diff_driver_pattern) fn_patterns; regex_t word_pattern; char name[GIT_FLEX_ARRAY]; }; #include "userdiff.h" struct git_diff_driver_registry { git_strmap *drivers; }; #define FORCE_DIFFABLE (GIT_DIFF_FORCE_TEXT | GIT_DIFF_FORCE_BINARY) static git_diff_driver global_drivers[3] = { { DIFF_DRIVER_AUTO, 0, 0, }, { DIFF_DRIVER_BINARY, GIT_DIFF_FORCE_BINARY, 0 }, { DIFF_DRIVER_TEXT, GIT_DIFF_FORCE_TEXT, 0 }, }; git_diff_driver_registry *git_diff_driver_registry_new() { git_diff_driver_registry *reg = git__calloc(1, sizeof(git_diff_driver_registry)); if (!reg) return NULL; if (git_strmap_alloc(®->drivers) < 0) { git_diff_driver_registry_free(reg); return NULL; } return reg; } void git_diff_driver_registry_free(git_diff_driver_registry *reg) { git_diff_driver *drv; if (!reg) return; git_strmap_foreach_value(reg->drivers, drv, git_diff_driver_free(drv)); git_strmap_free(reg->drivers); git__free(reg); } static int diff_driver_add_patterns( git_diff_driver *drv, const char *regex_str, int regex_flags) { int error = 0; const char *scan, *end; git_diff_driver_pattern *pat = NULL; git_buf buf = GIT_BUF_INIT; for (scan = regex_str; scan; scan = end) { /* get pattern to fill in */ if ((pat = git_array_alloc(drv->fn_patterns)) == NULL) { return -1; } pat->flags = regex_flags; if (*scan == '!') { pat->flags |= REG_NEGATE; ++scan; } if ((end = strchr(scan, '\n')) != NULL) { error = git_buf_set(&buf, scan, end - scan); end++; } else { error = git_buf_sets(&buf, scan); } if (error < 0) break; if ((error = regcomp(&pat->re, buf.ptr, regex_flags)) != 0) { /* * TODO: issue a warning */ } } if (error && pat != NULL) (void)git_array_pop(drv->fn_patterns); /* release last item */ git_buf_free(&buf); /* We want to ignore bad patterns, so return success regardless */ return 0; } static int diff_driver_xfuncname(const git_config_entry *entry, void *payload) { return diff_driver_add_patterns(payload, entry->value, REG_EXTENDED); } static int diff_driver_funcname(const git_config_entry *entry, void *payload) { return diff_driver_add_patterns(payload, entry->value, 0); } static git_diff_driver_registry *git_repository_driver_registry( git_repository *repo) { if (!repo->diff_drivers) { git_diff_driver_registry *reg = git_diff_driver_registry_new(); reg = git__compare_and_swap(&repo->diff_drivers, NULL, reg); if (reg != NULL) /* if we race, free losing allocation */ git_diff_driver_registry_free(reg); } if (!repo->diff_drivers) giterr_set(GITERR_REPOSITORY, "Unable to create diff driver registry"); return repo->diff_drivers; } static int diff_driver_alloc( git_diff_driver **out, size_t *namelen_out, const char *name) { git_diff_driver *driver; size_t driverlen = sizeof(git_diff_driver), namelen = strlen(name), alloclen; GITERR_CHECK_ALLOC_ADD(&alloclen, driverlen, namelen); GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); driver = git__calloc(1, alloclen); GITERR_CHECK_ALLOC(driver); memcpy(driver->name, name, namelen); *out = driver; if (namelen_out) *namelen_out = namelen; return 0; } static int git_diff_driver_builtin( git_diff_driver **out, git_diff_driver_registry *reg, const char *driver_name) { int error = 0; git_diff_driver_definition *ddef = NULL; git_diff_driver *drv = NULL; size_t idx; for (idx = 0; idx < ARRAY_SIZE(builtin_defs); ++idx) { if (!strcasecmp(driver_name, builtin_defs[idx].name)) { ddef = &builtin_defs[idx]; break; } } if (!ddef) goto done; if ((error = diff_driver_alloc(&drv, NULL, ddef->name)) < 0) goto done; drv->type = DIFF_DRIVER_PATTERNLIST; if (ddef->fns && (error = diff_driver_add_patterns( drv, ddef->fns, ddef->flags | REG_EXTENDED)) < 0) goto done; if (ddef->words && (error = regcomp( &drv->word_pattern, ddef->words, ddef->flags | REG_EXTENDED))) { error = giterr_set_regex(&drv->word_pattern, error); goto done; } git_strmap_insert(reg->drivers, drv->name, drv, error); if (error > 0) error = 0; done: if (error && drv) git_diff_driver_free(drv); else *out = drv; return error; } static int git_diff_driver_load( git_diff_driver **out, git_repository *repo, const char *driver_name) { int error = 0; git_diff_driver_registry *reg; git_diff_driver *drv = NULL; size_t namelen; khiter_t pos; git_config *cfg = NULL; git_buf name = GIT_BUF_INIT; git_config_entry *ce = NULL; bool found_driver = false; if ((reg = git_repository_driver_registry(repo)) == NULL) return -1; pos = git_strmap_lookup_index(reg->drivers, driver_name); if (git_strmap_valid_index(reg->drivers, pos)) { *out = git_strmap_value_at(reg->drivers, pos); return 0; } if ((error = diff_driver_alloc(&drv, &namelen, driver_name)) < 0) goto done; drv->type = DIFF_DRIVER_AUTO; /* if you can't read config for repo, just use default driver */ if (git_repository_config_snapshot(&cfg, repo) < 0) { giterr_clear(); goto done; } if ((error = git_buf_printf(&name, "diff.%s.binary", driver_name)) < 0) goto done; switch (git_config__get_bool_force(cfg, name.ptr, -1)) { case true: /* if diff..binary is true, just return the binary driver */ *out = &global_drivers[DIFF_DRIVER_BINARY]; goto done; case false: /* if diff..binary is false, force binary checks off */ /* but still may have custom function context patterns, etc. */ drv->binary_flags = GIT_DIFF_FORCE_TEXT; found_driver = true; break; default: /* diff..binary unspecified or "auto", so just continue */ break; } /* TODO: warn if diff..command or diff..textconv are set */ git_buf_truncate(&name, namelen + strlen("diff..")); git_buf_put(&name, "xfuncname", strlen("xfuncname")); if ((error = git_config_get_multivar_foreach( cfg, name.ptr, NULL, diff_driver_xfuncname, drv)) < 0) { if (error != GIT_ENOTFOUND) goto done; giterr_clear(); /* no diff..xfuncname, so just continue */ } git_buf_truncate(&name, namelen + strlen("diff..")); git_buf_put(&name, "funcname", strlen("funcname")); if ((error = git_config_get_multivar_foreach( cfg, name.ptr, NULL, diff_driver_funcname, drv)) < 0) { if (error != GIT_ENOTFOUND) goto done; giterr_clear(); /* no diff..funcname, so just continue */ } /* if we found any patterns, set driver type to use correct callback */ if (git_array_size(drv->fn_patterns) > 0) { drv->type = DIFF_DRIVER_PATTERNLIST; found_driver = true; } git_buf_truncate(&name, namelen + strlen("diff..")); git_buf_put(&name, "wordregex", strlen("wordregex")); if ((error = git_config__lookup_entry(&ce, cfg, name.ptr, false)) < 0) goto done; if (!ce || !ce->value) /* no diff..wordregex, so just continue */; else if (!(error = regcomp(&drv->word_pattern, ce->value, REG_EXTENDED))) found_driver = true; else { /* TODO: warn about bad regex instead of failure */ error = giterr_set_regex(&drv->word_pattern, error); goto done; } /* TODO: look up diff..algorithm to turn on minimal / patience * diff in drv->other_flags */ /* if no driver config found at all, fall back on AUTO driver */ if (!found_driver) goto done; /* store driver in registry */ git_strmap_insert(reg->drivers, drv->name, drv, error); if (error < 0) goto done; error = 0; *out = drv; done: git_config_entry_free(ce); git_buf_free(&name); git_config_free(cfg); if (!*out) { int error2 = git_diff_driver_builtin(out, reg, driver_name); if (!error) error = error2; } if (drv && drv != *out) git_diff_driver_free(drv); return error; } int git_diff_driver_lookup( git_diff_driver **out, git_repository *repo, const char *path) { int error = 0; const char *value; assert(out); *out = NULL; if (!repo || !path || !strlen(path)) /* just use the auto value */; else if ((error = git_attr_get(&value, repo, 0, path, "diff")) < 0) /* return error below */; else if (GIT_ATTR_UNSPECIFIED(value)) /* just use the auto value */; else if (GIT_ATTR_FALSE(value)) *out = &global_drivers[DIFF_DRIVER_BINARY]; else if (GIT_ATTR_TRUE(value)) *out = &global_drivers[DIFF_DRIVER_TEXT]; /* otherwise look for driver information in config and build driver */ else if ((error = git_diff_driver_load(out, repo, value)) < 0) { if (error == GIT_ENOTFOUND) { error = 0; giterr_clear(); } } if (!*out) *out = &global_drivers[DIFF_DRIVER_AUTO]; return error; } void git_diff_driver_free(git_diff_driver *driver) { size_t i; if (!driver) return; for (i = 0; i < git_array_size(driver->fn_patterns); ++i) regfree(& git_array_get(driver->fn_patterns, i)->re); git_array_clear(driver->fn_patterns); regfree(&driver->word_pattern); git__free(driver); } void git_diff_driver_update_options( uint32_t *option_flags, git_diff_driver *driver) { if ((*option_flags & FORCE_DIFFABLE) == 0) *option_flags |= driver->binary_flags; *option_flags |= driver->other_flags; } int git_diff_driver_content_is_binary( git_diff_driver *driver, const char *content, size_t content_len) { git_buf search = GIT_BUF_INIT; GIT_UNUSED(driver); git_buf_attach_notowned(&search, content, min(content_len, GIT_FILTER_BYTES_TO_CHECK_NUL)); /* TODO: provide encoding / binary detection callbacks that can * be UTF-8 aware, etc. For now, instead of trying to be smart, * let's just use the simple NUL-byte detection that core git uses. */ /* previously was: if (git_buf_text_is_binary(&search)) */ if (git_buf_text_contains_nul(&search)) return 1; return 0; } static int diff_context_line__simple( git_diff_driver *driver, git_buf *line) { char firstch = line->ptr[0]; GIT_UNUSED(driver); return (git__isalpha(firstch) || firstch == '_' || firstch == '$'); } static int diff_context_line__pattern_match( git_diff_driver *driver, git_buf *line) { size_t i, maxi = git_array_size(driver->fn_patterns); regmatch_t pmatch[2]; for (i = 0; i < maxi; ++i) { git_diff_driver_pattern *pat = git_array_get(driver->fn_patterns, i); if (!regexec(&pat->re, line->ptr, 2, pmatch, 0)) { if (pat->flags & REG_NEGATE) return false; /* use pmatch data to trim line data */ i = (pmatch[1].rm_so >= 0) ? 1 : 0; git_buf_consume(line, git_buf_cstr(line) + pmatch[i].rm_so); git_buf_truncate(line, pmatch[i].rm_eo - pmatch[i].rm_so); git_buf_rtrim(line); return true; } } return false; } static long diff_context_find( const char *line, long line_len, char *out, long out_size, void *payload) { git_diff_find_context_payload *ctxt = payload; if (git_buf_set(&ctxt->line, line, (size_t)line_len) < 0) return -1; git_buf_rtrim(&ctxt->line); if (!ctxt->line.size) return -1; if (!ctxt->match_line || !ctxt->match_line(ctxt->driver, &ctxt->line)) return -1; if (out_size > (long)ctxt->line.size) out_size = (long)ctxt->line.size; memcpy(out, ctxt->line.ptr, (size_t)out_size); return out_size; } void git_diff_find_context_init( git_diff_find_context_fn *findfn_out, git_diff_find_context_payload *payload_out, git_diff_driver *driver) { *findfn_out = driver ? diff_context_find : NULL; memset(payload_out, 0, sizeof(*payload_out)); if (driver) { payload_out->driver = driver; payload_out->match_line = (driver->type == DIFF_DRIVER_PATTERNLIST) ? diff_context_line__pattern_match : diff_context_line__simple; git_buf_init(&payload_out->line, 0); } } void git_diff_find_context_clear(git_diff_find_context_payload *payload) { if (payload) { git_buf_free(&payload->line); payload->driver = NULL; } } deps/libgit2-sys-0.3.8/libgit2/src/userdiff.h0000664000175000017500000001671212510265101015652 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_userdiff_h__ #define INCLUDE_userdiff_h__ /* * This file isolates the built in diff driver function name patterns. * Most of these patterns are taken from Git (with permission from the * original authors for relicensing to libgit2). */ typedef struct { const char *name; const char *fns; const char *words; int flags; } git_diff_driver_definition; #define WORD_DEFAULT "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+" /* * These builtin driver definition macros have same signature as in core * git userdiff.c so that the data can be extracted verbatim */ #define PATTERNS(NAME, FN_PATS, WORD_PAT) \ { NAME, FN_PATS, WORD_PAT WORD_DEFAULT, 0 } #define IPATTERN(NAME, FN_PATS, WORD_PAT) \ { NAME, FN_PATS, WORD_PAT WORD_DEFAULT, REG_ICASE } /* * The table of diff driver patterns * * Function name patterns are a list of newline separated patterns that * match a function declaration (i.e. the line you want in the hunk header), * or a negative pattern prefixed with a '!' to reject a pattern (such as * rejecting goto labels in C code). * * Word boundary patterns are just a simple pattern that will be OR'ed with * the default value above (i.e. whitespace or non-ASCII characters). */ static git_diff_driver_definition builtin_defs[] = { IPATTERN("ada", "!^(.*[ \t])?(is[ \t]+new|renames|is[ \t]+separate)([ \t].*)?$\n" "!^[ \t]*with[ \t].*$\n" "^[ \t]*((procedure|function)[ \t]+.*)$\n" "^[ \t]*((package|protected|task)[ \t]+.*)$", /* -- */ "[a-zA-Z][a-zA-Z0-9_]*" "|[-+]?[0-9][0-9#_.aAbBcCdDeEfF]*([eE][+-]?[0-9_]+)?" "|=>|\\.\\.|\\*\\*|:=|/=|>=|<=|<<|>>|<>"), IPATTERN("fortran", "!^([C*]|[ \t]*!)\n" "!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n" "^[ \t]*((END[ \t]+)?(PROGRAM|MODULE|BLOCK[ \t]+DATA" "|([^'\" \t]+[ \t]+)*(SUBROUTINE|FUNCTION))[ \t]+[A-Z].*)$", /* -- */ "[a-zA-Z][a-zA-Z0-9_]*" "|\\.([Ee][Qq]|[Nn][Ee]|[Gg][TtEe]|[Ll][TtEe]|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]|[Aa][Nn][Dd]|[Oo][Rr]|[Nn]?[Ee][Qq][Vv]|[Nn][Oo][Tt])\\." /* numbers and format statements like 2E14.4, or ES12.6, 9X. * Don't worry about format statements without leading digits since * they would have been matched above as a variable anyway. */ "|[-+]?[0-9.]+([AaIiDdEeFfLlTtXx][Ss]?[-+]?[0-9.]*)?(_[a-zA-Z0-9][a-zA-Z0-9_]*)?" "|//|\\*\\*|::|[/<>=]="), PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$", "[^<>= \t]+"), PATTERNS("java", "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n" "^[ \t]*(([A-Za-z_][A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$", /* -- */ "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), PATTERNS("matlab", "^[[:space:]]*((classdef|function)[[:space:]].*)$|^%%[[:space:]].*$", "[a-zA-Z_][a-zA-Z0-9_]*|[-+0-9.e]+|[=~<>]=|\\.[*/\\^']|\\|\\||&&"), PATTERNS("objc", /* Negate C statements that can look like functions */ "!^[ \t]*(do|for|if|else|return|switch|while)\n" /* Objective-C methods */ "^[ \t]*([-+][ \t]*\\([ \t]*[A-Za-z_][A-Za-z_0-9* \t]*\\)[ \t]*[A-Za-z_].*)$\n" /* C functions */ "^[ \t]*(([A-Za-z_][A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$\n" /* Objective-C class/protocol definitions */ "^(@(implementation|interface|protocol)[ \t].*)$", /* -- */ "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), PATTERNS("pascal", "^(((class[ \t]+)?(procedure|function)|constructor|destructor|interface|" "implementation|initialization|finalization)[ \t]*.*)$" "\n" "^(.*=[ \t]*(class|record).*)$", /* -- */ "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+" "|<>|<=|>=|:=|\\.\\."), PATTERNS("perl", "^package .*\n" "^sub [[:alnum:]_':]+[ \t]*" "(\\([^)]*\\)[ \t]*)?" /* prototype */ /* * Attributes. A regex can't count nested parentheses, * so just slurp up whatever we see, taking care not * to accept lines like "sub foo; # defined elsewhere". * * An attribute could contain a semicolon, but at that * point it seems reasonable enough to give up. */ "(:[^;#]*)?" "(\\{[ \t]*)?" /* brace can come here or on the next line */ "(#.*)?$\n" /* comment */ "^(BEGIN|END|INIT|CHECK|UNITCHECK|AUTOLOAD|DESTROY)[ \t]*" "(\\{[ \t]*)?" /* brace can come here or on the next line */ "(#.*)?$\n" "^=head[0-9] .*", /* POD */ /* -- */ "[[:alpha:]_'][[:alnum:]_']*" "|0[xb]?[0-9a-fA-F_]*" /* taking care not to interpret 3..5 as (3.)(.5) */ "|[0-9a-fA-F_]+(\\.[0-9a-fA-F_]+)?([eE][-+]?[0-9_]+)?" "|=>|-[rwxoRWXOezsfdlpSugkbctTBMAC>]|~~|::" "|&&=|\\|\\|=|//=|\\*\\*=" "|&&|\\|\\||//|\\+\\+|--|\\*\\*|\\.\\.\\.?" "|[-+*/%.^&<>=!|]=" "|=~|!~" "|<<|<>|<=>|>>"), PATTERNS("python", "^[ \t]*((class|def)[ \t].*)$", /* -- */ "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+[jJlL]?|0[xX]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=|//=?|<<=?|>>=?|\\*\\*=?"), PATTERNS("ruby", "^[ \t]*((class|module|def)[ \t].*)$", /* -- */ "(@|@@|\\$)?[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\?(\\\\C-)?(\\\\M-)?." "|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\.{1,3}|::|[!=]~"), PATTERNS("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$", "[={}\"]|[^={}\" \t]+"), PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$", "\\\\[a-zA-Z@]+|\\\\.|[a-zA-Z0-9\x80-\xff]+"), PATTERNS("cpp", /* Jump targets or access declarations */ "!^[ \t]*[A-Za-z_][A-Za-z_0-9]*:[[:space:]]*($|/[/*])\n" /* functions/methods, variables, and compounds at top level */ "^((::[[:space:]]*)?[A-Za-z_].*)$", /* -- */ "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lLuU]*" "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->\\*?|\\.\\*"), PATTERNS("csharp", /* Keywords */ "!^[ \t]*(do|while|for|if|else|instanceof|new|return|switch|case|throw|catch|using)\n" /* Methods and constructors */ "^[ \t]*(((static|public|internal|private|protected|new|virtual|sealed|override|unsafe)[ \t]+)*[][<>@.~_[:alnum:]]+[ \t]+[<>@._[:alnum:]]+[ \t]*\\(.*\\))[ \t]*$\n" /* Properties */ "^[ \t]*(((static|public|internal|private|protected|new|virtual|sealed|override|unsafe)[ \t]+)*[][<>@.~_[:alnum:]]+[ \t]+[@._[:alnum:]]+)[ \t]*$\n" /* Type definitions */ "^[ \t]*(((static|public|internal|private|protected|new|unsafe|sealed|abstract|partial)[ \t]+)*(class|enum|interface|struct)[ \t]+.*)$\n" /* Namespace */ "^[ \t]*(namespace[ \t]+.*)$", /* -- */ "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), PATTERNS("php", "^[ \t]*(((public|private|protected|static|final)[ \t]+)*((class|function)[ \t].*))$", /* -- */ "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+[fFlL]?|0[xX]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), PATTERNS("javascript", "([a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z0-9_$]+)*[ \t]*=[ \t]*function([ \t][a-zA-Z_$][a-zA-Z0-9_$]*)?[^\\{]*)\n" "([a-zA-Z_$][a-zA-Z0-9_$]*[ \t]*:[ \t]*function([ \t][a-zA-Z_$][a-zA-Z0-9_$]*)?[^\\{]*)\n" "[^a-zA-Z0-9_\\$](function([ \t][a-zA-Z_$][a-zA-Z0-9_$]*)?[^\\{]*)", /* -- */ "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+[fFlL]?|0[xX]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), }; #undef IPATTERN #undef PATTERNS #undef WORD_DEFAULT #endif deps/libgit2-sys-0.3.8/libgit2/src/refdb.c0000664000175000017500000001214312610310643015115 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "posix.h" #include "git2/object.h" #include "git2/refs.h" #include "git2/refdb.h" #include "git2/sys/refdb_backend.h" #include "hash.h" #include "refdb.h" #include "refs.h" #include "reflog.h" int git_refdb_new(git_refdb **out, git_repository *repo) { git_refdb *db; assert(out && repo); db = git__calloc(1, sizeof(*db)); GITERR_CHECK_ALLOC(db); db->repo = repo; *out = db; GIT_REFCOUNT_INC(db); return 0; } int git_refdb_open(git_refdb **out, git_repository *repo) { git_refdb *db; git_refdb_backend *dir; assert(out && repo); *out = NULL; if (git_refdb_new(&db, repo) < 0) return -1; /* Add the default (filesystem) backend */ if (git_refdb_backend_fs(&dir, repo) < 0) { git_refdb_free(db); return -1; } db->repo = repo; db->backend = dir; *out = db; return 0; } static void refdb_free_backend(git_refdb *db) { if (db->backend) db->backend->free(db->backend); } int git_refdb_set_backend(git_refdb *db, git_refdb_backend *backend) { refdb_free_backend(db); db->backend = backend; return 0; } int git_refdb_compress(git_refdb *db) { assert(db); if (db->backend->compress) return db->backend->compress(db->backend); return 0; } void git_refdb__free(git_refdb *db) { refdb_free_backend(db); git__memzero(db, sizeof(*db)); git__free(db); } void git_refdb_free(git_refdb *db) { if (db == NULL) return; GIT_REFCOUNT_DEC(db, git_refdb__free); } int git_refdb_exists(int *exists, git_refdb *refdb, const char *ref_name) { assert(exists && refdb && refdb->backend); return refdb->backend->exists(exists, refdb->backend, ref_name); } int git_refdb_lookup(git_reference **out, git_refdb *db, const char *ref_name) { git_reference *ref; int error; assert(db && db->backend && out && ref_name); error = db->backend->lookup(&ref, db->backend, ref_name); if (error < 0) return error; GIT_REFCOUNT_INC(db); ref->db = db; *out = ref; return 0; } int git_refdb_iterator(git_reference_iterator **out, git_refdb *db, const char *glob) { if (!db->backend || !db->backend->iterator) { giterr_set(GITERR_REFERENCE, "This backend doesn't support iterators"); return -1; } if (db->backend->iterator(out, db->backend, glob) < 0) return -1; GIT_REFCOUNT_INC(db); (*out)->db = db; return 0; } int git_refdb_iterator_next(git_reference **out, git_reference_iterator *iter) { int error; if ((error = iter->next(out, iter)) < 0) return error; GIT_REFCOUNT_INC(iter->db); (*out)->db = iter->db; return 0; } int git_refdb_iterator_next_name(const char **out, git_reference_iterator *iter) { return iter->next_name(out, iter); } void git_refdb_iterator_free(git_reference_iterator *iter) { GIT_REFCOUNT_DEC(iter->db, git_refdb__free); iter->free(iter); } int git_refdb_write(git_refdb *db, git_reference *ref, int force, const git_signature *who, const char *message, const git_oid *old_id, const char *old_target) { assert(db && db->backend); GIT_REFCOUNT_INC(db); ref->db = db; return db->backend->write(db->backend, ref, force, who, message, old_id, old_target); } int git_refdb_rename( git_reference **out, git_refdb *db, const char *old_name, const char *new_name, int force, const git_signature *who, const char *message) { int error; assert(db && db->backend); error = db->backend->rename(out, db->backend, old_name, new_name, force, who, message); if (error < 0) return error; if (out) { GIT_REFCOUNT_INC(db); (*out)->db = db; } return 0; } int git_refdb_delete(struct git_refdb *db, const char *ref_name, const git_oid *old_id, const char *old_target) { assert(db && db->backend); return db->backend->del(db->backend, ref_name, old_id, old_target); } int git_refdb_reflog_read(git_reflog **out, git_refdb *db, const char *name) { int error; assert(db && db->backend); if ((error = db->backend->reflog_read(out, db->backend, name)) < 0) return error; GIT_REFCOUNT_INC(db); (*out)->db = db; return 0; } int git_refdb_has_log(git_refdb *db, const char *refname) { assert(db && refname); return db->backend->has_log(db->backend, refname); } int git_refdb_ensure_log(git_refdb *db, const char *refname) { assert(db && refname); return db->backend->ensure_log(db->backend, refname); } int git_refdb_init_backend(git_refdb_backend *backend, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( backend, version, git_refdb_backend, GIT_REFDB_BACKEND_INIT); return 0; } int git_refdb_lock(void **payload, git_refdb *db, const char *refname) { assert(payload && db && refname); if (!db->backend->lock) { giterr_set(GITERR_REFERENCE, "backend does not support locking"); return -1; } return db->backend->lock(payload, db->backend, refname); } int git_refdb_unlock(git_refdb *db, void *payload, int success, int update_reflog, const git_reference *ref, const git_signature *sig, const char *message) { assert(db); return db->backend->unlock(db->backend, payload, success, update_reflog, ref, sig, message); } deps/libgit2-sys-0.3.8/libgit2/src/repository.c0000664000175000017500000015363012610310643016261 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include #include "git2/object.h" #include "git2/refdb.h" #include "git2/sys/repository.h" #include "common.h" #include "repository.h" #include "commit.h" #include "tag.h" #include "blob.h" #include "fileops.h" #include "sysdir.h" #include "filebuf.h" #include "index.h" #include "config.h" #include "refs.h" #include "filter.h" #include "odb.h" #include "remote.h" #include "merge.h" #include "diff_driver.h" #include "annotated_commit.h" #ifdef GIT_WIN32 # include "win32/w32_util.h" #endif static int check_repositoryformatversion(git_config *config); #define GIT_FILE_CONTENT_PREFIX "gitdir:" #define GIT_BRANCH_MASTER "master" #define GIT_REPO_VERSION 0 git_buf git_repository__reserved_names_win32[] = { { DOT_GIT, 0, CONST_STRLEN(DOT_GIT) }, { GIT_DIR_SHORTNAME, 0, CONST_STRLEN(GIT_DIR_SHORTNAME) } }; size_t git_repository__reserved_names_win32_len = 2; git_buf git_repository__reserved_names_posix[] = { { DOT_GIT, 0, CONST_STRLEN(DOT_GIT) }, }; size_t git_repository__reserved_names_posix_len = 1; static void set_odb(git_repository *repo, git_odb *odb) { if (odb) { GIT_REFCOUNT_OWN(odb, repo); GIT_REFCOUNT_INC(odb); } if ((odb = git__swap(repo->_odb, odb)) != NULL) { GIT_REFCOUNT_OWN(odb, NULL); git_odb_free(odb); } } static void set_refdb(git_repository *repo, git_refdb *refdb) { if (refdb) { GIT_REFCOUNT_OWN(refdb, repo); GIT_REFCOUNT_INC(refdb); } if ((refdb = git__swap(repo->_refdb, refdb)) != NULL) { GIT_REFCOUNT_OWN(refdb, NULL); git_refdb_free(refdb); } } static void set_config(git_repository *repo, git_config *config) { if (config) { GIT_REFCOUNT_OWN(config, repo); GIT_REFCOUNT_INC(config); } if ((config = git__swap(repo->_config, config)) != NULL) { GIT_REFCOUNT_OWN(config, NULL); git_config_free(config); } git_repository__cvar_cache_clear(repo); } static void set_index(git_repository *repo, git_index *index) { if (index) { GIT_REFCOUNT_OWN(index, repo); GIT_REFCOUNT_INC(index); } if ((index = git__swap(repo->_index, index)) != NULL) { GIT_REFCOUNT_OWN(index, NULL); git_index_free(index); } } void git_repository__cleanup(git_repository *repo) { assert(repo); git_cache_clear(&repo->objects); git_attr_cache_flush(repo); set_config(repo, NULL); set_index(repo, NULL); set_odb(repo, NULL); set_refdb(repo, NULL); } void git_repository_free(git_repository *repo) { size_t i; if (repo == NULL) return; git_repository__cleanup(repo); git_cache_free(&repo->objects); git_diff_driver_registry_free(repo->diff_drivers); repo->diff_drivers = NULL; for (i = 0; i < repo->reserved_names.size; i++) git_buf_free(git_array_get(repo->reserved_names, i)); git_array_clear(repo->reserved_names); git__free(repo->path_gitlink); git__free(repo->path_repository); git__free(repo->workdir); git__free(repo->namespace); git__free(repo->ident_name); git__free(repo->ident_email); git__memzero(repo, sizeof(*repo)); git__free(repo); } /* * Git repository open methods * * Open a repository object from its path */ static bool valid_repository_path(git_buf *repository_path) { /* Check OBJECTS_DIR first, since it will generate the longest path name */ if (git_path_contains_dir(repository_path, GIT_OBJECTS_DIR) == false) return false; /* Ensure HEAD file exists */ if (git_path_contains_file(repository_path, GIT_HEAD_FILE) == false) return false; if (git_path_contains_dir(repository_path, GIT_REFS_DIR) == false) return false; return true; } static git_repository *repository_alloc(void) { git_repository *repo = git__calloc(1, sizeof(git_repository)); if (repo == NULL || git_cache_init(&repo->objects) < 0) goto on_error; git_array_init_to_size(repo->reserved_names, 4); if (!repo->reserved_names.ptr) goto on_error; /* set all the entries in the cvar cache to `unset` */ git_repository__cvar_cache_clear(repo); return repo; on_error: if (repo) git_cache_free(&repo->objects); git__free(repo); return NULL; } int git_repository_new(git_repository **out) { git_repository *repo; *out = repo = repository_alloc(); GITERR_CHECK_ALLOC(repo); repo->is_bare = 1; return 0; } static int load_config_data(git_repository *repo, const git_config *config) { int is_bare; /* Try to figure out if it's bare, default to non-bare if it's not set */ if (git_config_get_bool(&is_bare, config, "core.bare") < 0) repo->is_bare = 0; else repo->is_bare = is_bare; return 0; } static int load_workdir(git_repository *repo, git_config *config, git_buf *parent_path) { int error; git_config_entry *ce; git_buf worktree = GIT_BUF_INIT; if (repo->is_bare) return 0; if ((error = git_config__lookup_entry( &ce, config, "core.worktree", false)) < 0) return error; if (ce && ce->value) { if ((error = git_path_prettify_dir( &worktree, ce->value, repo->path_repository)) < 0) goto cleanup; repo->workdir = git_buf_detach(&worktree); } else if (parent_path && git_path_isdir(parent_path->ptr)) repo->workdir = git_buf_detach(parent_path); else { if (git_path_dirname_r(&worktree, repo->path_repository) < 0 || git_path_to_dir(&worktree) < 0) { error = -1; goto cleanup; } repo->workdir = git_buf_detach(&worktree); } GITERR_CHECK_ALLOC(repo->workdir); cleanup: git_config_entry_free(ce); return error; } /* * This function returns furthest offset into path where a ceiling dir * is found, so we can stop processing the path at that point. * * Note: converting this to use git_bufs instead of GIT_PATH_MAX buffers on * the stack could remove directories name limits, but at the cost of doing * repeated malloc/frees inside the loop below, so let's not do it now. */ static int find_ceiling_dir_offset( const char *path, const char *ceiling_directories) { char buf[GIT_PATH_MAX + 1]; char buf2[GIT_PATH_MAX + 1]; const char *ceil, *sep; size_t len, max_len = 0, min_len; assert(path); min_len = (size_t)(git_path_root(path) + 1); if (ceiling_directories == NULL || min_len == 0) return (int)min_len; for (sep = ceil = ceiling_directories; *sep; ceil = sep + 1) { for (sep = ceil; *sep && *sep != GIT_PATH_LIST_SEPARATOR; sep++); len = sep - ceil; if (len == 0 || len >= sizeof(buf) || git_path_root(ceil) == -1) continue; strncpy(buf, ceil, len); buf[len] = '\0'; if (p_realpath(buf, buf2) == NULL) continue; len = strlen(buf2); if (len > 0 && buf2[len-1] == '/') buf[--len] = '\0'; if (!strncmp(path, buf2, len) && (path[len] == '/' || !path[len]) && len > max_len) { max_len = len; } } return (int)(max_len <= min_len ? min_len : max_len); } /* * Read the contents of `file_path` and set `path_out` to the repo dir that * it points to. Before calling, set `path_out` to the base directory that * should be used if the contents of `file_path` are a relative path. */ static int read_gitfile(git_buf *path_out, const char *file_path) { int error = 0; git_buf file = GIT_BUF_INIT; size_t prefix_len = strlen(GIT_FILE_CONTENT_PREFIX); assert(path_out && file_path); if (git_futils_readbuffer(&file, file_path) < 0) return -1; git_buf_rtrim(&file); /* apparently on Windows, some people use backslashes in paths */ git_path_mkposix(file.ptr); if (git_buf_len(&file) <= prefix_len || memcmp(git_buf_cstr(&file), GIT_FILE_CONTENT_PREFIX, prefix_len) != 0) { giterr_set(GITERR_REPOSITORY, "The `.git` file at '%s' is malformed", file_path); error = -1; } else if ((error = git_path_dirname_r(path_out, file_path)) >= 0) { const char *gitlink = git_buf_cstr(&file) + prefix_len; while (*gitlink && git__isspace(*gitlink)) gitlink++; error = git_path_prettify_dir( path_out, gitlink, git_buf_cstr(path_out)); } git_buf_free(&file); return error; } static int find_repo( git_buf *repo_path, git_buf *parent_path, git_buf *link_path, const char *start_path, uint32_t flags, const char *ceiling_dirs) { int error; git_buf path = GIT_BUF_INIT; struct stat st; dev_t initial_device = 0; bool try_with_dot_git = ((flags & GIT_REPOSITORY_OPEN_BARE) != 0); int ceiling_offset; git_buf_free(repo_path); if ((error = git_path_prettify(&path, start_path, NULL)) < 0) return error; ceiling_offset = find_ceiling_dir_offset(path.ptr, ceiling_dirs); if (!try_with_dot_git && (error = git_buf_joinpath(&path, path.ptr, DOT_GIT)) < 0) return error; while (!error && !git_buf_len(repo_path)) { if (p_stat(path.ptr, &st) == 0) { /* check that we have not crossed device boundaries */ if (initial_device == 0) initial_device = st.st_dev; else if (st.st_dev != initial_device && (flags & GIT_REPOSITORY_OPEN_CROSS_FS) == 0) break; if (S_ISDIR(st.st_mode)) { if (valid_repository_path(&path)) { git_path_to_dir(&path); git_buf_set(repo_path, path.ptr, path.size); break; } } else if (S_ISREG(st.st_mode)) { git_buf repo_link = GIT_BUF_INIT; if (!(error = read_gitfile(&repo_link, path.ptr))) { if (valid_repository_path(&repo_link)) { git_buf_swap(repo_path, &repo_link); if (link_path) error = git_buf_put(link_path, path.ptr, path.size); } git_buf_free(&repo_link); break; } git_buf_free(&repo_link); } } /* move up one directory level */ if (git_path_dirname_r(&path, path.ptr) < 0) { error = -1; break; } if (try_with_dot_git) { /* if we tried original dir with and without .git AND either hit * directory ceiling or NO_SEARCH was requested, then be done. */ if (path.ptr[ceiling_offset] == '\0' || (flags & GIT_REPOSITORY_OPEN_NO_SEARCH) != 0) break; /* otherwise look first for .git item */ error = git_buf_joinpath(&path, path.ptr, DOT_GIT); } try_with_dot_git = !try_with_dot_git; } if (!error && parent_path && !(flags & GIT_REPOSITORY_OPEN_BARE)) { if (!git_buf_len(repo_path)) git_buf_clear(parent_path); else { git_path_dirname_r(parent_path, path.ptr); git_path_to_dir(parent_path); } if (git_buf_oom(parent_path)) return -1; } git_buf_free(&path); if (!git_buf_len(repo_path) && !error) { giterr_set(GITERR_REPOSITORY, "Could not find repository from '%s'", start_path); error = GIT_ENOTFOUND; } return error; } int git_repository_open_bare( git_repository **repo_ptr, const char *bare_path) { int error; git_buf path = GIT_BUF_INIT; git_repository *repo = NULL; if ((error = git_path_prettify_dir(&path, bare_path, NULL)) < 0) return error; if (!valid_repository_path(&path)) { git_buf_free(&path); giterr_set(GITERR_REPOSITORY, "Path is not a repository: %s", bare_path); return GIT_ENOTFOUND; } repo = repository_alloc(); GITERR_CHECK_ALLOC(repo); repo->path_repository = git_buf_detach(&path); GITERR_CHECK_ALLOC(repo->path_repository); /* of course we're bare! */ repo->is_bare = 1; repo->workdir = NULL; *repo_ptr = repo; return 0; } int git_repository_open_ext( git_repository **repo_ptr, const char *start_path, unsigned int flags, const char *ceiling_dirs) { int error; git_buf path = GIT_BUF_INIT, parent = GIT_BUF_INIT, link_path = GIT_BUF_INIT; git_repository *repo; git_config *config = NULL; if (repo_ptr) *repo_ptr = NULL; error = find_repo( &path, &parent, &link_path, start_path, flags, ceiling_dirs); if (error < 0 || !repo_ptr) return error; repo = repository_alloc(); GITERR_CHECK_ALLOC(repo); repo->path_repository = git_buf_detach(&path); GITERR_CHECK_ALLOC(repo->path_repository); if (link_path.size) { repo->path_gitlink = git_buf_detach(&link_path); GITERR_CHECK_ALLOC(repo->path_gitlink); } /* * We'd like to have the config, but git doesn't particularly * care if it's not there, so we need to deal with that. */ error = git_repository_config_snapshot(&config, repo); if (error < 0 && error != GIT_ENOTFOUND) goto cleanup; if (config && (error = check_repositoryformatversion(config)) < 0) goto cleanup; if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0) repo->is_bare = 1; else { if (config && ((error = load_config_data(repo, config)) < 0 || (error = load_workdir(repo, config, &parent)) < 0)) goto cleanup; } cleanup: git_buf_free(&parent); git_config_free(config); if (error < 0) git_repository_free(repo); else *repo_ptr = repo; return error; } int git_repository_open(git_repository **repo_out, const char *path) { return git_repository_open_ext( repo_out, path, GIT_REPOSITORY_OPEN_NO_SEARCH, NULL); } int git_repository_wrap_odb(git_repository **repo_out, git_odb *odb) { git_repository *repo; repo = repository_alloc(); GITERR_CHECK_ALLOC(repo); git_repository_set_odb(repo, odb); *repo_out = repo; return 0; } int git_repository_discover( git_buf *out, const char *start_path, int across_fs, const char *ceiling_dirs) { uint32_t flags = across_fs ? GIT_REPOSITORY_OPEN_CROSS_FS : 0; assert(start_path); git_buf_sanitize(out); return find_repo(out, NULL, NULL, start_path, flags, ceiling_dirs); } static int load_config( git_config **out, git_repository *repo, const char *global_config_path, const char *xdg_config_path, const char *system_config_path) { int error; git_buf config_path = GIT_BUF_INIT; git_config *cfg = NULL; assert(repo && out); if ((error = git_config_new(&cfg)) < 0) return error; error = git_buf_joinpath( &config_path, repo->path_repository, GIT_CONFIG_FILENAME_INREPO); if (error < 0) goto on_error; if ((error = git_config_add_file_ondisk( cfg, config_path.ptr, GIT_CONFIG_LEVEL_LOCAL, 0)) < 0 && error != GIT_ENOTFOUND) goto on_error; git_buf_free(&config_path); if (global_config_path != NULL && (error = git_config_add_file_ondisk( cfg, global_config_path, GIT_CONFIG_LEVEL_GLOBAL, 0)) < 0 && error != GIT_ENOTFOUND) goto on_error; if (xdg_config_path != NULL && (error = git_config_add_file_ondisk( cfg, xdg_config_path, GIT_CONFIG_LEVEL_XDG, 0)) < 0 && error != GIT_ENOTFOUND) goto on_error; if (system_config_path != NULL && (error = git_config_add_file_ondisk( cfg, system_config_path, GIT_CONFIG_LEVEL_SYSTEM, 0)) < 0 && error != GIT_ENOTFOUND) goto on_error; giterr_clear(); /* clear any lingering ENOTFOUND errors */ *out = cfg; return 0; on_error: git_buf_free(&config_path); git_config_free(cfg); *out = NULL; return error; } static const char *path_unless_empty(git_buf *buf) { return git_buf_len(buf) > 0 ? git_buf_cstr(buf) : NULL; } int git_repository_config__weakptr(git_config **out, git_repository *repo) { int error = 0; if (repo->_config == NULL) { git_buf global_buf = GIT_BUF_INIT; git_buf xdg_buf = GIT_BUF_INIT; git_buf system_buf = GIT_BUF_INIT; git_config *config; git_config_find_global(&global_buf); git_config_find_xdg(&xdg_buf); git_config_find_system(&system_buf); /* If there is no global file, open a backend for it anyway */ if (git_buf_len(&global_buf) == 0) git_config__global_location(&global_buf); error = load_config( &config, repo, path_unless_empty(&global_buf), path_unless_empty(&xdg_buf), path_unless_empty(&system_buf)); if (!error) { GIT_REFCOUNT_OWN(config, repo); config = git__compare_and_swap(&repo->_config, NULL, config); if (config != NULL) { GIT_REFCOUNT_OWN(config, NULL); git_config_free(config); } } git_buf_free(&global_buf); git_buf_free(&xdg_buf); git_buf_free(&system_buf); } *out = repo->_config; return error; } int git_repository_config(git_config **out, git_repository *repo) { if (git_repository_config__weakptr(out, repo) < 0) return -1; GIT_REFCOUNT_INC(*out); return 0; } int git_repository_config_snapshot(git_config **out, git_repository *repo) { int error; git_config *weak; if ((error = git_repository_config__weakptr(&weak, repo)) < 0) return error; return git_config_snapshot(out, weak); } void git_repository_set_config(git_repository *repo, git_config *config) { assert(repo && config); set_config(repo, config); } int git_repository_odb__weakptr(git_odb **out, git_repository *repo) { int error = 0; assert(repo && out); if (repo->_odb == NULL) { git_buf odb_path = GIT_BUF_INIT; git_odb *odb; if ((error = git_buf_joinpath(&odb_path, repo->path_repository, GIT_OBJECTS_DIR)) < 0) return error; error = git_odb_open(&odb, odb_path.ptr); if (!error) { GIT_REFCOUNT_OWN(odb, repo); odb = git__compare_and_swap(&repo->_odb, NULL, odb); if (odb != NULL) { GIT_REFCOUNT_OWN(odb, NULL); git_odb_free(odb); } } git_buf_free(&odb_path); } *out = repo->_odb; return error; } int git_repository_odb(git_odb **out, git_repository *repo) { if (git_repository_odb__weakptr(out, repo) < 0) return -1; GIT_REFCOUNT_INC(*out); return 0; } void git_repository_set_odb(git_repository *repo, git_odb *odb) { assert(repo && odb); set_odb(repo, odb); } int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo) { int error = 0; assert(out && repo); if (repo->_refdb == NULL) { git_refdb *refdb; error = git_refdb_open(&refdb, repo); if (!error) { GIT_REFCOUNT_OWN(refdb, repo); refdb = git__compare_and_swap(&repo->_refdb, NULL, refdb); if (refdb != NULL) { GIT_REFCOUNT_OWN(refdb, NULL); git_refdb_free(refdb); } } } *out = repo->_refdb; return error; } int git_repository_refdb(git_refdb **out, git_repository *repo) { if (git_repository_refdb__weakptr(out, repo) < 0) return -1; GIT_REFCOUNT_INC(*out); return 0; } void git_repository_set_refdb(git_repository *repo, git_refdb *refdb) { assert(repo && refdb); set_refdb(repo, refdb); } int git_repository_index__weakptr(git_index **out, git_repository *repo) { int error = 0; assert(out && repo); if (repo->_index == NULL) { git_buf index_path = GIT_BUF_INIT; git_index *index; if ((error = git_buf_joinpath(&index_path, repo->path_repository, GIT_INDEX_FILE)) < 0) return error; error = git_index_open(&index, index_path.ptr); if (!error) { GIT_REFCOUNT_OWN(index, repo); index = git__compare_and_swap(&repo->_index, NULL, index); if (index != NULL) { GIT_REFCOUNT_OWN(index, NULL); git_index_free(index); } error = git_index_set_caps(repo->_index, GIT_INDEXCAP_FROM_OWNER); } git_buf_free(&index_path); } *out = repo->_index; return error; } int git_repository_index(git_index **out, git_repository *repo) { if (git_repository_index__weakptr(out, repo) < 0) return -1; GIT_REFCOUNT_INC(*out); return 0; } void git_repository_set_index(git_repository *repo, git_index *index) { assert(repo); set_index(repo, index); } int git_repository_set_namespace(git_repository *repo, const char *namespace) { git__free(repo->namespace); if (namespace == NULL) { repo->namespace = NULL; return 0; } return (repo->namespace = git__strdup(namespace)) ? 0 : -1; } const char *git_repository_get_namespace(git_repository *repo) { return repo->namespace; } #ifdef GIT_WIN32 static int reserved_names_add8dot3(git_repository *repo, const char *path) { char *name = git_win32_path_8dot3_name(path); const char *def = GIT_DIR_SHORTNAME; const char *def_dot_git = DOT_GIT; size_t name_len, def_len = CONST_STRLEN(GIT_DIR_SHORTNAME); size_t def_dot_git_len = CONST_STRLEN(DOT_GIT); git_buf *buf; if (!name) return 0; name_len = strlen(name); if ((name_len == def_len && memcmp(name, def, def_len) == 0) || (name_len == def_dot_git_len && memcmp(name, def_dot_git, def_dot_git_len) == 0)) { git__free(name); return 0; } if ((buf = git_array_alloc(repo->reserved_names)) == NULL) return -1; git_buf_attach(buf, name, name_len); return true; } bool git_repository__reserved_names( git_buf **out, size_t *outlen, git_repository *repo, bool include_ntfs) { GIT_UNUSED(include_ntfs); if (repo->reserved_names.size == 0) { git_buf *buf; size_t i; /* Add the static defaults */ for (i = 0; i < git_repository__reserved_names_win32_len; i++) { if ((buf = git_array_alloc(repo->reserved_names)) == NULL) goto on_error; buf->ptr = git_repository__reserved_names_win32[i].ptr; buf->size = git_repository__reserved_names_win32[i].size; } /* Try to add any repo-specific reserved names - the gitlink file * within a submodule or the repository (if the repository directory * is beneath the workdir). These are typically `.git`, but should * be protected in case they are not. Note, repo and workdir paths * are always prettified to end in `/`, so a prefixcmp is safe. */ if (!repo->is_bare) { int (*prefixcmp)(const char *, const char *); int error, ignorecase; error = git_repository__cvar( &ignorecase, repo, GIT_CVAR_IGNORECASE); prefixcmp = (error || ignorecase) ? git__prefixcmp_icase : git__prefixcmp; if (repo->path_gitlink && reserved_names_add8dot3(repo, repo->path_gitlink) < 0) goto on_error; if (repo->path_repository && prefixcmp(repo->path_repository, repo->workdir) == 0 && reserved_names_add8dot3(repo, repo->path_repository) < 0) goto on_error; } } *out = repo->reserved_names.ptr; *outlen = repo->reserved_names.size; return true; /* Always give good defaults, even on OOM */ on_error: *out = git_repository__reserved_names_win32; *outlen = git_repository__reserved_names_win32_len; return false; } #else bool git_repository__reserved_names( git_buf **out, size_t *outlen, git_repository *repo, bool include_ntfs) { GIT_UNUSED(repo); if (include_ntfs) { *out = git_repository__reserved_names_win32; *outlen = git_repository__reserved_names_win32_len; } else { *out = git_repository__reserved_names_posix; *outlen = git_repository__reserved_names_posix_len; } return true; } #endif static int check_repositoryformatversion(git_config *config) { int version, error; error = git_config_get_int32(&version, config, "core.repositoryformatversion"); /* git ignores this if the config variable isn't there */ if (error == GIT_ENOTFOUND) return 0; if (error < 0) return -1; if (GIT_REPO_VERSION < version) { giterr_set(GITERR_REPOSITORY, "Unsupported repository version %d. Only versions up to %d are supported.", version, GIT_REPO_VERSION); return -1; } return 0; } static int repo_init_create_head(const char *git_dir, const char *ref_name) { git_buf ref_path = GIT_BUF_INIT; git_filebuf ref = GIT_FILEBUF_INIT; const char *fmt; if (git_buf_joinpath(&ref_path, git_dir, GIT_HEAD_FILE) < 0 || git_filebuf_open(&ref, ref_path.ptr, 0, GIT_REFS_FILE_MODE) < 0) goto fail; if (!ref_name) ref_name = GIT_BRANCH_MASTER; if (git__prefixcmp(ref_name, GIT_REFS_DIR) == 0) fmt = "ref: %s\n"; else fmt = "ref: " GIT_REFS_HEADS_DIR "%s\n"; if (git_filebuf_printf(&ref, fmt, ref_name) < 0 || git_filebuf_commit(&ref) < 0) goto fail; git_buf_free(&ref_path); return 0; fail: git_buf_free(&ref_path); git_filebuf_cleanup(&ref); return -1; } static bool is_chmod_supported(const char *file_path) { struct stat st1, st2; if (p_stat(file_path, &st1) < 0) return false; if (p_chmod(file_path, st1.st_mode ^ S_IXUSR) < 0) return false; if (p_stat(file_path, &st2) < 0) return false; return (st1.st_mode != st2.st_mode); } static bool is_filesystem_case_insensitive(const char *gitdir_path) { git_buf path = GIT_BUF_INIT; int is_insensitive = -1; if (!git_buf_joinpath(&path, gitdir_path, "CoNfIg")) is_insensitive = git_path_exists(git_buf_cstr(&path)); git_buf_free(&path); return is_insensitive; } static bool are_symlinks_supported(const char *wd_path) { git_buf path = GIT_BUF_INIT; int fd; struct stat st; int symlinks_supported = -1; if ((fd = git_futils_mktmp(&path, wd_path, 0666)) < 0 || p_close(fd) < 0 || p_unlink(path.ptr) < 0 || p_symlink("testing", path.ptr) < 0 || p_lstat(path.ptr, &st) < 0) symlinks_supported = false; else symlinks_supported = (S_ISLNK(st.st_mode) != 0); (void)p_unlink(path.ptr); git_buf_free(&path); return symlinks_supported; } static int create_empty_file(const char *path, mode_t mode) { int fd; if ((fd = p_creat(path, mode)) < 0) { giterr_set(GITERR_OS, "Error while creating '%s'", path); return -1; } if (p_close(fd) < 0) { giterr_set(GITERR_OS, "Error while closing '%s'", path); return -1; } return 0; } static int repo_local_config( git_config **out, git_buf *config_dir, git_repository *repo, const char *repo_dir) { int error = 0; git_config *parent; const char *cfg_path; if (git_buf_joinpath(config_dir, repo_dir, GIT_CONFIG_FILENAME_INREPO) < 0) return -1; cfg_path = git_buf_cstr(config_dir); /* make LOCAL config if missing */ if (!git_path_isfile(cfg_path) && (error = create_empty_file(cfg_path, GIT_CONFIG_FILE_MODE)) < 0) return error; /* if no repo, just open that file directly */ if (!repo) return git_config_open_ondisk(out, cfg_path); /* otherwise, open parent config and get that level */ if ((error = git_repository_config__weakptr(&parent, repo)) < 0) return error; if (git_config_open_level(out, parent, GIT_CONFIG_LEVEL_LOCAL) < 0) { giterr_clear(); if (!(error = git_config_add_file_ondisk( parent, cfg_path, GIT_CONFIG_LEVEL_LOCAL, false))) error = git_config_open_level(out, parent, GIT_CONFIG_LEVEL_LOCAL); } git_config_free(parent); return error; } static int repo_init_fs_configs( git_config *cfg, const char *cfg_path, const char *repo_dir, const char *work_dir, bool update_ignorecase) { int error = 0; if (!work_dir) work_dir = repo_dir; if ((error = git_config_set_bool( cfg, "core.filemode", is_chmod_supported(cfg_path))) < 0) return error; if (!are_symlinks_supported(work_dir)) { if ((error = git_config_set_bool(cfg, "core.symlinks", false)) < 0) return error; } else if (git_config_delete_entry(cfg, "core.symlinks") < 0) giterr_clear(); if (update_ignorecase) { if (is_filesystem_case_insensitive(repo_dir)) { if ((error = git_config_set_bool(cfg, "core.ignorecase", true)) < 0) return error; } else if (git_config_delete_entry(cfg, "core.ignorecase") < 0) giterr_clear(); } #ifdef GIT_USE_ICONV if ((error = git_config_set_bool( cfg, "core.precomposeunicode", git_path_does_fs_decompose_unicode(work_dir))) < 0) return error; /* on non-iconv platforms, don't even set core.precomposeunicode */ #endif return 0; } static int repo_init_config( const char *repo_dir, const char *work_dir, uint32_t flags, uint32_t mode) { int error = 0; git_buf cfg_path = GIT_BUF_INIT, worktree_path = GIT_BUF_INIT; git_config *config = NULL; bool is_bare = ((flags & GIT_REPOSITORY_INIT_BARE) != 0); bool is_reinit = ((flags & GIT_REPOSITORY_INIT__IS_REINIT) != 0); if ((error = repo_local_config(&config, &cfg_path, NULL, repo_dir)) < 0) goto cleanup; if (is_reinit && (error = check_repositoryformatversion(config)) < 0) goto cleanup; #define SET_REPO_CONFIG(TYPE, NAME, VAL) do { \ if ((error = git_config_set_##TYPE(config, NAME, VAL)) < 0) \ goto cleanup; } while (0) SET_REPO_CONFIG(bool, "core.bare", is_bare); SET_REPO_CONFIG(int32, "core.repositoryformatversion", GIT_REPO_VERSION); if ((error = repo_init_fs_configs( config, cfg_path.ptr, repo_dir, work_dir, !is_reinit)) < 0) goto cleanup; if (!is_bare) { SET_REPO_CONFIG(bool, "core.logallrefupdates", true); if (!(flags & GIT_REPOSITORY_INIT__NATURAL_WD)) { if ((error = git_buf_sets(&worktree_path, work_dir)) < 0) goto cleanup; if ((flags & GIT_REPOSITORY_INIT_RELATIVE_GITLINK)) if ((error = git_path_make_relative(&worktree_path, repo_dir)) < 0) goto cleanup; SET_REPO_CONFIG(string, "core.worktree", worktree_path.ptr); } else if (is_reinit) { if (git_config_delete_entry(config, "core.worktree") < 0) giterr_clear(); } } if (mode == GIT_REPOSITORY_INIT_SHARED_GROUP) { SET_REPO_CONFIG(int32, "core.sharedrepository", 1); SET_REPO_CONFIG(bool, "receive.denyNonFastforwards", true); } else if (mode == GIT_REPOSITORY_INIT_SHARED_ALL) { SET_REPO_CONFIG(int32, "core.sharedrepository", 2); SET_REPO_CONFIG(bool, "receive.denyNonFastforwards", true); } cleanup: git_buf_free(&cfg_path); git_buf_free(&worktree_path); git_config_free(config); return error; } static int repo_reinit_submodule_fs(git_submodule *sm, const char *n, void *p) { git_repository *smrepo = NULL; GIT_UNUSED(n); GIT_UNUSED(p); if (git_submodule_open(&smrepo, sm) < 0 || git_repository_reinit_filesystem(smrepo, true) < 0) giterr_clear(); git_repository_free(smrepo); return 0; } int git_repository_reinit_filesystem(git_repository *repo, int recurse) { int error = 0; git_buf path = GIT_BUF_INIT; git_config *config = NULL; const char *repo_dir = git_repository_path(repo); if (!(error = repo_local_config(&config, &path, repo, repo_dir))) error = repo_init_fs_configs( config, path.ptr, repo_dir, git_repository_workdir(repo), true); git_config_free(config); git_buf_free(&path); git_repository__cvar_cache_clear(repo); if (!repo->is_bare && recurse) (void)git_submodule_foreach(repo, repo_reinit_submodule_fs, NULL); return error; } static int repo_write_template( const char *git_dir, bool allow_overwrite, const char *file, mode_t mode, bool hidden, const char *content) { git_buf path = GIT_BUF_INIT; int fd, error = 0, flags; if (git_buf_joinpath(&path, git_dir, file) < 0) return -1; if (allow_overwrite) flags = O_WRONLY | O_CREAT | O_TRUNC; else flags = O_WRONLY | O_CREAT | O_EXCL; fd = p_open(git_buf_cstr(&path), flags, mode); if (fd >= 0) { error = p_write(fd, content, strlen(content)); p_close(fd); } else if (errno != EEXIST) error = fd; #ifdef GIT_WIN32 if (!error && hidden) { if (git_win32__set_hidden(path.ptr, true) < 0) error = -1; } #else GIT_UNUSED(hidden); #endif git_buf_free(&path); if (error) giterr_set(GITERR_OS, "Failed to initialize repository with template '%s'", file); return error; } static int repo_write_gitlink( const char *in_dir, const char *to_repo, bool use_relative_path) { int error; git_buf buf = GIT_BUF_INIT; git_buf path_to_repo = GIT_BUF_INIT; struct stat st; git_path_dirname_r(&buf, to_repo); git_path_to_dir(&buf); if (git_buf_oom(&buf)) return -1; /* don't write gitlink to natural workdir */ if (git__suffixcmp(to_repo, "/" DOT_GIT "/") == 0 && strcmp(in_dir, buf.ptr) == 0) { error = GIT_PASSTHROUGH; goto cleanup; } if ((error = git_buf_joinpath(&buf, in_dir, DOT_GIT)) < 0) goto cleanup; if (!p_stat(buf.ptr, &st) && !S_ISREG(st.st_mode)) { giterr_set(GITERR_REPOSITORY, "Cannot overwrite gitlink file into path '%s'", in_dir); error = GIT_EEXISTS; goto cleanup; } git_buf_clear(&buf); error = git_buf_sets(&path_to_repo, to_repo); if (!error && use_relative_path) error = git_path_make_relative(&path_to_repo, in_dir); if (!error) error = git_buf_join(&buf, ' ', GIT_FILE_CONTENT_PREFIX, path_to_repo.ptr); if (!error) error = repo_write_template(in_dir, true, DOT_GIT, 0666, true, buf.ptr); cleanup: git_buf_free(&buf); git_buf_free(&path_to_repo); return error; } static mode_t pick_dir_mode(git_repository_init_options *opts) { if (opts->mode == GIT_REPOSITORY_INIT_SHARED_UMASK) return 0777; if (opts->mode == GIT_REPOSITORY_INIT_SHARED_GROUP) return (0775 | S_ISGID); if (opts->mode == GIT_REPOSITORY_INIT_SHARED_ALL) return (0777 | S_ISGID); return opts->mode; } #include "repo_template.h" static int repo_init_structure( const char *repo_dir, const char *work_dir, git_repository_init_options *opts) { int error = 0; repo_template_item *tpl; bool external_tpl = ((opts->flags & GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE) != 0); mode_t dmode = pick_dir_mode(opts); bool chmod = opts->mode != GIT_REPOSITORY_INIT_SHARED_UMASK; /* Hide the ".git" directory */ #ifdef GIT_WIN32 if ((opts->flags & GIT_REPOSITORY_INIT__HAS_DOTGIT) != 0) { if (git_win32__set_hidden(repo_dir, true) < 0) { giterr_set(GITERR_OS, "Failed to mark Git repository folder as hidden"); return -1; } } #endif /* Create the .git gitlink if appropriate */ if ((opts->flags & GIT_REPOSITORY_INIT_BARE) == 0 && (opts->flags & GIT_REPOSITORY_INIT__NATURAL_WD) == 0) { if (repo_write_gitlink(work_dir, repo_dir, opts->flags & GIT_REPOSITORY_INIT_RELATIVE_GITLINK) < 0) return -1; } /* Copy external template if requested */ if (external_tpl) { git_config *cfg = NULL; const char *tdir = NULL; bool default_template = false; git_buf template_buf = GIT_BUF_INIT; if (opts->template_path) tdir = opts->template_path; else if ((error = git_config_open_default(&cfg)) >= 0) { if (!git_config_get_path(&template_buf, cfg, "init.templatedir")) tdir = template_buf.ptr; giterr_clear(); } if (!tdir) { if (!(error = git_sysdir_find_template_dir(&template_buf))) tdir = template_buf.ptr; default_template = true; } if (tdir) { uint32_t cpflags = GIT_CPDIR_COPY_SYMLINKS | GIT_CPDIR_SIMPLE_TO_MODE; if (opts->mode != GIT_REPOSITORY_INIT_SHARED_UMASK) cpflags |= GIT_CPDIR_CHMOD_DIRS; error = git_futils_cp_r(tdir, repo_dir, cpflags, dmode); } git_buf_free(&template_buf); git_config_free(cfg); if (error < 0) { if (!default_template) return error; /* if template was default, ignore error and use internal */ giterr_clear(); external_tpl = false; error = 0; } } /* Copy internal template * - always ensure existence of dirs * - only create files if no external template was specified */ for (tpl = repo_template; !error && tpl->path; ++tpl) { if (!tpl->content) { uint32_t mkdir_flags = GIT_MKDIR_PATH; if (chmod) mkdir_flags |= GIT_MKDIR_CHMOD; error = git_futils_mkdir_relative( tpl->path, repo_dir, dmode, mkdir_flags, NULL); } else if (!external_tpl) { const char *content = tpl->content; if (opts->description && strcmp(tpl->path, GIT_DESC_FILE) == 0) content = opts->description; error = repo_write_template( repo_dir, false, tpl->path, tpl->mode, false, content); } } return error; } static int mkdir_parent(git_buf *buf, uint32_t mode, bool skip2) { /* When making parent directories during repository initialization * don't try to set gid or grant world write access */ return git_futils_mkdir( buf->ptr, mode & ~(S_ISGID | 0002), GIT_MKDIR_PATH | GIT_MKDIR_VERIFY_DIR | (skip2 ? GIT_MKDIR_SKIP_LAST2 : GIT_MKDIR_SKIP_LAST)); } static int repo_init_directories( git_buf *repo_path, git_buf *wd_path, const char *given_repo, git_repository_init_options *opts) { int error = 0; bool is_bare, add_dotgit, has_dotgit, natural_wd; mode_t dirmode; /* There are three possible rules for what we are allowed to create: * - MKPATH means anything we need * - MKDIR means just the .git directory and its parent and the workdir * - Neither means only the .git directory can be created * * There are 5 "segments" of path that we might need to deal with: * 1. The .git directory * 2. The parent of the .git directory * 3. Everything above the parent of the .git directory * 4. The working directory (often the same as #2) * 5. Everything above the working directory (often the same as #3) * * For all directories created, we start with the init_mode value for * permissions and then strip off bits in some cases: * * For MKPATH, we create #3 (and #5) paths without S_ISGID or S_IWOTH * For MKPATH and MKDIR, we create #2 (and #4) without S_ISGID * For all rules, we create #1 using the untouched init_mode */ /* set up repo path */ is_bare = ((opts->flags & GIT_REPOSITORY_INIT_BARE) != 0); add_dotgit = (opts->flags & GIT_REPOSITORY_INIT_NO_DOTGIT_DIR) == 0 && !is_bare && git__suffixcmp(given_repo, "/" DOT_GIT) != 0 && git__suffixcmp(given_repo, "/" GIT_DIR) != 0; if (git_buf_joinpath(repo_path, given_repo, add_dotgit ? GIT_DIR : "") < 0) return -1; has_dotgit = (git__suffixcmp(repo_path->ptr, "/" GIT_DIR) == 0); if (has_dotgit) opts->flags |= GIT_REPOSITORY_INIT__HAS_DOTGIT; /* set up workdir path */ if (!is_bare) { if (opts->workdir_path) { if (git_path_join_unrooted( wd_path, opts->workdir_path, repo_path->ptr, NULL) < 0) return -1; } else if (has_dotgit) { if (git_path_dirname_r(wd_path, repo_path->ptr) < 0) return -1; } else { giterr_set(GITERR_REPOSITORY, "Cannot pick working directory" " for non-bare repository that isn't a '.git' directory"); return -1; } if (git_path_to_dir(wd_path) < 0) return -1; } else { git_buf_clear(wd_path); } natural_wd = has_dotgit && wd_path->size > 0 && wd_path->size + strlen(GIT_DIR) == repo_path->size && memcmp(repo_path->ptr, wd_path->ptr, wd_path->size) == 0; if (natural_wd) opts->flags |= GIT_REPOSITORY_INIT__NATURAL_WD; /* create directories as needed / requested */ dirmode = pick_dir_mode(opts); if ((opts->flags & GIT_REPOSITORY_INIT_MKPATH) != 0) { /* create path #5 */ if (wd_path->size > 0 && (error = mkdir_parent(wd_path, dirmode, false)) < 0) return error; /* create path #3 (if not the same as #5) */ if (!natural_wd && (error = mkdir_parent(repo_path, dirmode, has_dotgit)) < 0) return error; } if ((opts->flags & GIT_REPOSITORY_INIT_MKDIR) != 0 || (opts->flags & GIT_REPOSITORY_INIT_MKPATH) != 0) { /* create path #4 */ if (wd_path->size > 0 && (error = git_futils_mkdir( wd_path->ptr, dirmode & ~S_ISGID, GIT_MKDIR_VERIFY_DIR)) < 0) return error; /* create path #2 (if not the same as #4) */ if (!natural_wd && (error = git_futils_mkdir( repo_path->ptr, dirmode & ~S_ISGID, GIT_MKDIR_VERIFY_DIR | GIT_MKDIR_SKIP_LAST)) < 0) return error; } if ((opts->flags & GIT_REPOSITORY_INIT_MKDIR) != 0 || (opts->flags & GIT_REPOSITORY_INIT_MKPATH) != 0 || has_dotgit) { /* create path #1 */ error = git_futils_mkdir(repo_path->ptr, dirmode, GIT_MKDIR_VERIFY_DIR | ((dirmode & S_ISGID) ? GIT_MKDIR_CHMOD : 0)); } /* prettify both directories now that they are created */ if (!error) { error = git_path_prettify_dir(repo_path, repo_path->ptr, NULL); if (!error && wd_path->size > 0) error = git_path_prettify_dir(wd_path, wd_path->ptr, NULL); } return error; } static int repo_init_create_origin(git_repository *repo, const char *url) { int error; git_remote *remote; if (!(error = git_remote_create(&remote, repo, GIT_REMOTE_ORIGIN, url))) { git_remote_free(remote); } return error; } int git_repository_init( git_repository **repo_out, const char *path, unsigned is_bare) { git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT; opts.flags = GIT_REPOSITORY_INIT_MKPATH; /* don't love this default */ if (is_bare) opts.flags |= GIT_REPOSITORY_INIT_BARE; return git_repository_init_ext(repo_out, path, &opts); } int git_repository_init_ext( git_repository **out, const char *given_repo, git_repository_init_options *opts) { int error; git_buf repo_path = GIT_BUF_INIT, wd_path = GIT_BUF_INIT; const char *wd; assert(out && given_repo && opts); GITERR_CHECK_VERSION(opts, GIT_REPOSITORY_INIT_OPTIONS_VERSION, "git_repository_init_options"); error = repo_init_directories(&repo_path, &wd_path, given_repo, opts); if (error < 0) goto cleanup; wd = (opts->flags & GIT_REPOSITORY_INIT_BARE) ? NULL : git_buf_cstr(&wd_path); if (valid_repository_path(&repo_path)) { if ((opts->flags & GIT_REPOSITORY_INIT_NO_REINIT) != 0) { giterr_set(GITERR_REPOSITORY, "Attempt to reinitialize '%s'", given_repo); error = GIT_EEXISTS; goto cleanup; } opts->flags |= GIT_REPOSITORY_INIT__IS_REINIT; error = repo_init_config( repo_path.ptr, wd, opts->flags, opts->mode); /* TODO: reinitialize the templates */ } else { if (!(error = repo_init_structure( repo_path.ptr, wd, opts)) && !(error = repo_init_config( repo_path.ptr, wd, opts->flags, opts->mode))) error = repo_init_create_head( repo_path.ptr, opts->initial_head); } if (error < 0) goto cleanup; error = git_repository_open(out, repo_path.ptr); if (!error && opts->origin_url) error = repo_init_create_origin(*out, opts->origin_url); cleanup: git_buf_free(&repo_path); git_buf_free(&wd_path); return error; } int git_repository_head_detached(git_repository *repo) { git_reference *ref; git_odb *odb = NULL; int exists; if (git_repository_odb__weakptr(&odb, repo) < 0) return -1; if (git_reference_lookup(&ref, repo, GIT_HEAD_FILE) < 0) return -1; if (git_reference_type(ref) == GIT_REF_SYMBOLIC) { git_reference_free(ref); return 0; } exists = git_odb_exists(odb, git_reference_target(ref)); git_reference_free(ref); return exists; } int git_repository_head(git_reference **head_out, git_repository *repo) { git_reference *head; int error; if ((error = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0) return error; if (git_reference_type(head) == GIT_REF_OID) { *head_out = head; return 0; } error = git_reference_lookup_resolved(head_out, repo, git_reference_symbolic_target(head), -1); git_reference_free(head); return error == GIT_ENOTFOUND ? GIT_EUNBORNBRANCH : error; } int git_repository_head_unborn(git_repository *repo) { git_reference *ref = NULL; int error; error = git_repository_head(&ref, repo); git_reference_free(ref); if (error == GIT_EUNBORNBRANCH) { giterr_clear(); return 1; } if (error < 0) return -1; return 0; } static int at_least_one_cb(const char *refname, void *payload) { GIT_UNUSED(refname); GIT_UNUSED(payload); return GIT_PASSTHROUGH; } static int repo_contains_no_reference(git_repository *repo) { int error = git_reference_foreach_name(repo, &at_least_one_cb, NULL); if (error == GIT_PASSTHROUGH) return 0; if (!error) return 1; return error; } int git_repository_is_empty(git_repository *repo) { git_reference *head = NULL; int is_empty = 0; if (git_reference_lookup(&head, repo, GIT_HEAD_FILE) < 0) return -1; if (git_reference_type(head) == GIT_REF_SYMBOLIC) is_empty = (strcmp(git_reference_symbolic_target(head), GIT_REFS_HEADS_DIR "master") == 0) && repo_contains_no_reference(repo); git_reference_free(head); return is_empty; } const char *git_repository_path(git_repository *repo) { assert(repo); return repo->path_repository; } const char *git_repository_workdir(git_repository *repo) { assert(repo); if (repo->is_bare) return NULL; return repo->workdir; } int git_repository_set_workdir( git_repository *repo, const char *workdir, int update_gitlink) { int error = 0; git_buf path = GIT_BUF_INIT; assert(repo && workdir); if (git_path_prettify_dir(&path, workdir, NULL) < 0) return -1; if (repo->workdir && strcmp(repo->workdir, path.ptr) == 0) return 0; if (update_gitlink) { git_config *config; if (git_repository_config__weakptr(&config, repo) < 0) return -1; error = repo_write_gitlink(path.ptr, git_repository_path(repo), false); /* passthrough error means gitlink is unnecessary */ if (error == GIT_PASSTHROUGH) error = git_config_delete_entry(config, "core.worktree"); else if (!error) error = git_config_set_string(config, "core.worktree", path.ptr); if (!error) error = git_config_set_bool(config, "core.bare", false); } if (!error) { char *old_workdir = repo->workdir; repo->workdir = git_buf_detach(&path); repo->is_bare = 0; git__free(old_workdir); } return error; } int git_repository_is_bare(git_repository *repo) { assert(repo); return repo->is_bare; } int git_repository_set_bare(git_repository *repo) { int error; git_config *config; assert(repo); if (repo->is_bare) return 0; if ((error = git_repository_config__weakptr(&config, repo)) < 0) return error; if ((error = git_config_set_bool(config, "core.bare", true)) < 0) return error; if ((error = git_config__update_entry(config, "core.worktree", NULL, true, true)) < 0) return error; git__free(repo->workdir); repo->workdir = NULL; repo->is_bare = 1; return 0; } int git_repository_head_tree(git_tree **tree, git_repository *repo) { git_reference *head; git_object *obj; int error; if ((error = git_repository_head(&head, repo)) < 0) return error; if ((error = git_reference_peel(&obj, head, GIT_OBJ_TREE)) < 0) goto cleanup; *tree = (git_tree *)obj; cleanup: git_reference_free(head); return error; } int git_repository__set_orig_head(git_repository *repo, const git_oid *orig_head) { git_filebuf file = GIT_FILEBUF_INIT; git_buf file_path = GIT_BUF_INIT; char orig_head_str[GIT_OID_HEXSZ]; int error = 0; git_oid_fmt(orig_head_str, orig_head); if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_ORIG_HEAD_FILE)) == 0 && (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) == 0 && (error = git_filebuf_printf(&file, "%.*s\n", GIT_OID_HEXSZ, orig_head_str)) == 0) error = git_filebuf_commit(&file); if (error < 0) git_filebuf_cleanup(&file); git_buf_free(&file_path); return error; } int git_repository_message(git_buf *out, git_repository *repo) { git_buf path = GIT_BUF_INIT; struct stat st; int error; git_buf_sanitize(out); if (git_buf_joinpath(&path, repo->path_repository, GIT_MERGE_MSG_FILE) < 0) return -1; if ((error = p_stat(git_buf_cstr(&path), &st)) < 0) { if (errno == ENOENT) error = GIT_ENOTFOUND; giterr_set(GITERR_OS, "Could not access message file"); } else { error = git_futils_readbuffer(out, git_buf_cstr(&path)); } git_buf_free(&path); return error; } int git_repository_message_remove(git_repository *repo) { git_buf path = GIT_BUF_INIT; int error; if (git_buf_joinpath(&path, repo->path_repository, GIT_MERGE_MSG_FILE) < 0) return -1; error = p_unlink(git_buf_cstr(&path)); git_buf_free(&path); return error; } int git_repository_hashfile( git_oid *out, git_repository *repo, const char *path, git_otype type, const char *as_path) { int error; git_filter_list *fl = NULL; git_file fd = -1; git_off_t len; git_buf full_path = GIT_BUF_INIT; assert(out && path && repo); /* as_path can be NULL */ /* At some point, it would be nice if repo could be NULL to just * apply filter rules defined in system and global files, but for * now that is not possible because git_filters_load() needs it. */ error = git_path_join_unrooted( &full_path, path, git_repository_workdir(repo), NULL); if (error < 0) return error; if (!as_path) as_path = path; /* passing empty string for "as_path" indicated --no-filters */ if (strlen(as_path) > 0) { error = git_filter_list_load( &fl, repo, NULL, as_path, GIT_FILTER_TO_ODB, GIT_FILTER_DEFAULT); if (error < 0) return error; } else { error = 0; } /* at this point, error is a count of the number of loaded filters */ fd = git_futils_open_ro(full_path.ptr); if (fd < 0) { error = fd; goto cleanup; } len = git_futils_filesize(fd); if (len < 0) { error = (int)len; goto cleanup; } if (!git__is_sizet(len)) { giterr_set(GITERR_OS, "File size overflow for 32-bit systems"); error = -1; goto cleanup; } error = git_odb__hashfd_filtered(out, fd, (size_t)len, type, fl); cleanup: if (fd >= 0) p_close(fd); git_filter_list_free(fl); git_buf_free(&full_path); return error; } static int checkout_message(git_buf *out, git_reference *old, const char *new) { git_buf_puts(out, "checkout: moving from "); if (git_reference_type(old) == GIT_REF_SYMBOLIC) git_buf_puts(out, git_reference__shorthand(git_reference_symbolic_target(old))); else git_buf_puts(out, git_oid_tostr_s(git_reference_target(old))); git_buf_puts(out, " to "); if (git_reference__is_branch(new)) git_buf_puts(out, git_reference__shorthand(new)); else git_buf_puts(out, new); if (git_buf_oom(out)) return -1; return 0; } int git_repository_set_head( git_repository* repo, const char* refname) { git_reference *ref = NULL, *current = NULL, *new_head = NULL; git_buf log_message = GIT_BUF_INIT; int error; assert(repo && refname); if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0) return error; if ((error = checkout_message(&log_message, current, refname)) < 0) goto cleanup; error = git_reference_lookup(&ref, repo, refname); if (error < 0 && error != GIT_ENOTFOUND) goto cleanup; if (!error) { if (git_reference_is_branch(ref)) { error = git_reference_symbolic_create(&new_head, repo, GIT_HEAD_FILE, git_reference_name(ref), true, git_buf_cstr(&log_message)); } else { error = git_repository_set_head_detached(repo, git_reference_target(ref)); } } else if (git_reference__is_branch(refname)) { error = git_reference_symbolic_create(&new_head, repo, GIT_HEAD_FILE, refname, true, git_buf_cstr(&log_message)); } cleanup: git_buf_free(&log_message); git_reference_free(current); git_reference_free(ref); git_reference_free(new_head); return error; } static int detach(git_repository *repo, const git_oid *id, const char *from) { int error; git_buf log_message = GIT_BUF_INIT; git_object *object = NULL, *peeled = NULL; git_reference *new_head = NULL, *current = NULL; assert(repo && id); if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0) return error; if ((error = git_object_lookup(&object, repo, id, GIT_OBJ_ANY)) < 0) goto cleanup; if ((error = git_object_peel(&peeled, object, GIT_OBJ_COMMIT)) < 0) goto cleanup; if (from == NULL) from = git_oid_tostr_s(git_object_id(peeled)); if ((error = checkout_message(&log_message, current, from)) < 0) goto cleanup; error = git_reference_create(&new_head, repo, GIT_HEAD_FILE, git_object_id(peeled), true, git_buf_cstr(&log_message)); cleanup: git_buf_free(&log_message); git_object_free(object); git_object_free(peeled); git_reference_free(current); git_reference_free(new_head); return error; } int git_repository_set_head_detached( git_repository* repo, const git_oid* commitish) { return detach(repo, commitish, NULL); } int git_repository_set_head_detached_from_annotated( git_repository *repo, const git_annotated_commit *commitish) { assert(repo && commitish); return detach(repo, git_annotated_commit_id(commitish), commitish->ref_name); } int git_repository_detach_head(git_repository* repo) { git_reference *old_head = NULL, *new_head = NULL, *current = NULL; git_object *object = NULL; git_buf log_message = GIT_BUF_INIT; int error; assert(repo); if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0) return error; if ((error = git_repository_head(&old_head, repo)) < 0) goto cleanup; if ((error = git_object_lookup(&object, repo, git_reference_target(old_head), GIT_OBJ_COMMIT)) < 0) goto cleanup; if ((error = checkout_message(&log_message, current, git_oid_tostr_s(git_object_id(object)))) < 0) goto cleanup; error = git_reference_create(&new_head, repo, GIT_HEAD_FILE, git_reference_target(old_head), 1, git_buf_cstr(&log_message)); cleanup: git_buf_free(&log_message); git_object_free(object); git_reference_free(old_head); git_reference_free(new_head); git_reference_free(current); return error; } /** * Loosely ported from git.git * https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh#L198-289 */ int git_repository_state(git_repository *repo) { git_buf repo_path = GIT_BUF_INIT; int state = GIT_REPOSITORY_STATE_NONE; assert(repo); if (git_buf_puts(&repo_path, repo->path_repository) < 0) return -1; if (git_path_contains_file(&repo_path, GIT_REBASE_MERGE_INTERACTIVE_FILE)) state = GIT_REPOSITORY_STATE_REBASE_INTERACTIVE; else if (git_path_contains_dir(&repo_path, GIT_REBASE_MERGE_DIR)) state = GIT_REPOSITORY_STATE_REBASE_MERGE; else if (git_path_contains_file(&repo_path, GIT_REBASE_APPLY_REBASING_FILE)) state = GIT_REPOSITORY_STATE_REBASE; else if (git_path_contains_file(&repo_path, GIT_REBASE_APPLY_APPLYING_FILE)) state = GIT_REPOSITORY_STATE_APPLY_MAILBOX; else if (git_path_contains_dir(&repo_path, GIT_REBASE_APPLY_DIR)) state = GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE; else if (git_path_contains_file(&repo_path, GIT_MERGE_HEAD_FILE)) state = GIT_REPOSITORY_STATE_MERGE; else if(git_path_contains_file(&repo_path, GIT_REVERT_HEAD_FILE)) state = GIT_REPOSITORY_STATE_REVERT; else if(git_path_contains_file(&repo_path, GIT_CHERRYPICK_HEAD_FILE)) state = GIT_REPOSITORY_STATE_CHERRYPICK; else if(git_path_contains_file(&repo_path, GIT_BISECT_LOG_FILE)) state = GIT_REPOSITORY_STATE_BISECT; git_buf_free(&repo_path); return state; } int git_repository__cleanup_files( git_repository *repo, const char *files[], size_t files_len) { git_buf buf = GIT_BUF_INIT; size_t i; int error; for (error = 0, i = 0; !error && i < files_len; ++i) { const char *path; if (git_buf_joinpath(&buf, repo->path_repository, files[i]) < 0) return -1; path = git_buf_cstr(&buf); if (git_path_isfile(path)) { error = p_unlink(path); } else if (git_path_isdir(path)) { error = git_futils_rmdir_r(path, NULL, GIT_RMDIR_REMOVE_FILES | GIT_RMDIR_REMOVE_BLOCKERS); } git_buf_clear(&buf); } git_buf_free(&buf); return error; } static const char *state_files[] = { GIT_MERGE_HEAD_FILE, GIT_MERGE_MODE_FILE, GIT_MERGE_MSG_FILE, GIT_REVERT_HEAD_FILE, GIT_CHERRYPICK_HEAD_FILE, GIT_BISECT_LOG_FILE, GIT_REBASE_MERGE_DIR, GIT_REBASE_APPLY_DIR, }; int git_repository_state_cleanup(git_repository *repo) { assert(repo); return git_repository__cleanup_files(repo, state_files, ARRAY_SIZE(state_files)); } int git_repository_is_shallow(git_repository *repo) { git_buf path = GIT_BUF_INIT; struct stat st; int error; if ((error = git_buf_joinpath(&path, repo->path_repository, "shallow")) < 0) return error; error = git_path_lstat(path.ptr, &st); git_buf_free(&path); if (error == GIT_ENOTFOUND) { giterr_clear(); return 0; } if (error < 0) return error; return st.st_size == 0 ? 0 : 1; } int git_repository_init_init_options( git_repository_init_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_repository_init_options, GIT_REPOSITORY_INIT_OPTIONS_INIT); return 0; } int git_repository_ident(const char **name, const char **email, const git_repository *repo) { *name = repo->ident_name; *email = repo->ident_email; return 0; } int git_repository_set_ident(git_repository *repo, const char *name, const char *email) { char *tmp_name = NULL, *tmp_email = NULL; if (name) { tmp_name = git__strdup(name); GITERR_CHECK_ALLOC(tmp_name); } if (email) { tmp_email = git__strdup(email); GITERR_CHECK_ALLOC(tmp_email); } tmp_name = git__swap(repo->ident_name, tmp_name); tmp_email = git__swap(repo->ident_email, tmp_email); git__free(tmp_name); git__free(tmp_email); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/object_api.c0000664000175000017500000000555412426525445016157 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/object.h" #include "common.h" #include "repository.h" #include "commit.h" #include "tree.h" #include "blob.h" #include "tag.h" /** * Blob */ int git_commit_lookup(git_commit **out, git_repository *repo, const git_oid *id) { return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_COMMIT); } int git_commit_lookup_prefix(git_commit **out, git_repository *repo, const git_oid *id, size_t len) { return git_object_lookup_prefix((git_object **)out, repo, id, len, GIT_OBJ_COMMIT); } void git_commit_free(git_commit *obj) { git_object_free((git_object *)obj); } const git_oid *git_commit_id(const git_commit *obj) { return git_object_id((const git_object *)obj); } git_repository *git_commit_owner(const git_commit *obj) { return git_object_owner((const git_object *)obj); } /** * Tree */ int git_tree_lookup(git_tree **out, git_repository *repo, const git_oid *id) { return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_TREE); } int git_tree_lookup_prefix(git_tree **out, git_repository *repo, const git_oid *id, size_t len) { return git_object_lookup_prefix((git_object **)out, repo, id, len, GIT_OBJ_TREE); } void git_tree_free(git_tree *obj) { git_object_free((git_object *)obj); } const git_oid *git_tree_id(const git_tree *obj) { return git_object_id((const git_object *)obj); } git_repository *git_tree_owner(const git_tree *obj) { return git_object_owner((const git_object *)obj); } /** * Tag */ int git_tag_lookup(git_tag **out, git_repository *repo, const git_oid *id) { return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_TAG); } int git_tag_lookup_prefix(git_tag **out, git_repository *repo, const git_oid *id, size_t len) { return git_object_lookup_prefix((git_object **)out, repo, id, len, GIT_OBJ_TAG); } void git_tag_free(git_tag *obj) { git_object_free((git_object *)obj); } const git_oid *git_tag_id(const git_tag *obj) { return git_object_id((const git_object *)obj); } git_repository *git_tag_owner(const git_tag *obj) { return git_object_owner((const git_object *)obj); } /** * Blob */ int git_blob_lookup(git_blob **out, git_repository *repo, const git_oid *id) { return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_BLOB); } int git_blob_lookup_prefix(git_blob **out, git_repository *repo, const git_oid *id, size_t len) { return git_object_lookup_prefix((git_object **)out, repo, id, len, GIT_OBJ_BLOB); } void git_blob_free(git_blob *obj) { git_object_free((git_object *)obj); } const git_oid *git_blob_id(const git_blob *obj) { return git_object_id((const git_object *)obj); } git_repository *git_blob_owner(const git_blob *obj) { return git_object_owner((const git_object *)obj); } deps/libgit2-sys-0.3.8/libgit2/src/status.c0000664000175000017500000003427012555730137015377 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "git2.h" #include "fileops.h" #include "hash.h" #include "vector.h" #include "tree.h" #include "status.h" #include "git2/status.h" #include "repository.h" #include "ignore.h" #include "index.h" #include "git2/diff.h" #include "diff.h" static unsigned int index_delta2status(const git_diff_delta *head2idx) { git_status_t st = GIT_STATUS_CURRENT; switch (head2idx->status) { case GIT_DELTA_ADDED: case GIT_DELTA_COPIED: st = GIT_STATUS_INDEX_NEW; break; case GIT_DELTA_DELETED: st = GIT_STATUS_INDEX_DELETED; break; case GIT_DELTA_MODIFIED: st = GIT_STATUS_INDEX_MODIFIED; break; case GIT_DELTA_RENAMED: st = GIT_STATUS_INDEX_RENAMED; if (!git_oid_equal(&head2idx->old_file.id, &head2idx->new_file.id)) st |= GIT_STATUS_INDEX_MODIFIED; break; case GIT_DELTA_TYPECHANGE: st = GIT_STATUS_INDEX_TYPECHANGE; break; case GIT_DELTA_CONFLICTED: st = GIT_STATUS_CONFLICTED; break; default: break; } return st; } static unsigned int workdir_delta2status( git_diff *diff, git_diff_delta *idx2wd) { git_status_t st = GIT_STATUS_CURRENT; switch (idx2wd->status) { case GIT_DELTA_ADDED: case GIT_DELTA_COPIED: case GIT_DELTA_UNTRACKED: st = GIT_STATUS_WT_NEW; break; case GIT_DELTA_UNREADABLE: st = GIT_STATUS_WT_UNREADABLE; break; case GIT_DELTA_DELETED: st = GIT_STATUS_WT_DELETED; break; case GIT_DELTA_MODIFIED: st = GIT_STATUS_WT_MODIFIED; break; case GIT_DELTA_IGNORED: st = GIT_STATUS_IGNORED; break; case GIT_DELTA_RENAMED: st = GIT_STATUS_WT_RENAMED; if (!git_oid_equal(&idx2wd->old_file.id, &idx2wd->new_file.id)) { /* if OIDs don't match, we might need to calculate them now to * discern between RENAMED vs RENAMED+MODIFED */ if (git_oid_iszero(&idx2wd->old_file.id) && diff->old_src == GIT_ITERATOR_TYPE_WORKDIR && !git_diff__oid_for_file( &idx2wd->old_file.id, diff, idx2wd->old_file.path, idx2wd->old_file.mode, idx2wd->old_file.size)) idx2wd->old_file.flags |= GIT_DIFF_FLAG_VALID_ID; if (git_oid_iszero(&idx2wd->new_file.id) && diff->new_src == GIT_ITERATOR_TYPE_WORKDIR && !git_diff__oid_for_file( &idx2wd->new_file.id, diff, idx2wd->new_file.path, idx2wd->new_file.mode, idx2wd->new_file.size)) idx2wd->new_file.flags |= GIT_DIFF_FLAG_VALID_ID; if (!git_oid_equal(&idx2wd->old_file.id, &idx2wd->new_file.id)) st |= GIT_STATUS_WT_MODIFIED; } break; case GIT_DELTA_TYPECHANGE: st = GIT_STATUS_WT_TYPECHANGE; break; case GIT_DELTA_CONFLICTED: st = GIT_STATUS_CONFLICTED; break; default: break; } return st; } static bool status_is_included( git_status_list *status, git_diff_delta *head2idx, git_diff_delta *idx2wd) { if (!(status->opts.flags & GIT_STATUS_OPT_EXCLUDE_SUBMODULES)) return 1; /* if excluding submodules and this is a submodule everywhere */ if (head2idx) { if (head2idx->status != GIT_DELTA_ADDED && head2idx->old_file.mode != GIT_FILEMODE_COMMIT) return 1; if (head2idx->status != GIT_DELTA_DELETED && head2idx->new_file.mode != GIT_FILEMODE_COMMIT) return 1; } if (idx2wd) { if (idx2wd->status != GIT_DELTA_ADDED && idx2wd->old_file.mode != GIT_FILEMODE_COMMIT) return 1; if (idx2wd->status != GIT_DELTA_DELETED && idx2wd->new_file.mode != GIT_FILEMODE_COMMIT) return 1; } /* only get here if every valid mode is GIT_FILEMODE_COMMIT */ return 0; } static git_status_t status_compute( git_status_list *status, git_diff_delta *head2idx, git_diff_delta *idx2wd) { git_status_t st = GIT_STATUS_CURRENT; if (head2idx) st |= index_delta2status(head2idx); if (idx2wd) st |= workdir_delta2status(status->idx2wd, idx2wd); return st; } static int status_collect( git_diff_delta *head2idx, git_diff_delta *idx2wd, void *payload) { git_status_list *status = payload; git_status_entry *status_entry; if (!status_is_included(status, head2idx, idx2wd)) return 0; status_entry = git__malloc(sizeof(git_status_entry)); GITERR_CHECK_ALLOC(status_entry); status_entry->status = status_compute(status, head2idx, idx2wd); status_entry->head_to_index = head2idx; status_entry->index_to_workdir = idx2wd; return git_vector_insert(&status->paired, status_entry); } GIT_INLINE(int) status_entry_cmp_base( const void *a, const void *b, int (*strcomp)(const char *a, const char *b)) { const git_status_entry *entry_a = a; const git_status_entry *entry_b = b; const git_diff_delta *delta_a, *delta_b; delta_a = entry_a->index_to_workdir ? entry_a->index_to_workdir : entry_a->head_to_index; delta_b = entry_b->index_to_workdir ? entry_b->index_to_workdir : entry_b->head_to_index; if (!delta_a && delta_b) return -1; if (delta_a && !delta_b) return 1; if (!delta_a && !delta_b) return 0; return strcomp(delta_a->new_file.path, delta_b->new_file.path); } static int status_entry_icmp(const void *a, const void *b) { return status_entry_cmp_base(a, b, git__strcasecmp); } static int status_entry_cmp(const void *a, const void *b) { return status_entry_cmp_base(a, b, git__strcmp); } static git_status_list *git_status_list_alloc(git_index *index) { git_status_list *status = NULL; int (*entrycmp)(const void *a, const void *b); if (!(status = git__calloc(1, sizeof(git_status_list)))) return NULL; entrycmp = index->ignore_case ? status_entry_icmp : status_entry_cmp; if (git_vector_init(&status->paired, 0, entrycmp) < 0) { git__free(status); return NULL; } return status; } static int status_validate_options(const git_status_options *opts) { if (!opts) return 0; GITERR_CHECK_VERSION(opts, GIT_STATUS_OPTIONS_VERSION, "git_status_options"); if (opts->show > GIT_STATUS_SHOW_WORKDIR_ONLY) { giterr_set(GITERR_INVALID, "Unknown status 'show' option"); return -1; } if ((opts->flags & GIT_STATUS_OPT_NO_REFRESH) != 0 && (opts->flags & GIT_STATUS_OPT_UPDATE_INDEX) != 0) { giterr_set(GITERR_INVALID, "Updating index from status " "is not allowed when index refresh is disabled"); return -1; } return 0; } int git_status_list_new( git_status_list **out, git_repository *repo, const git_status_options *opts) { git_index *index = NULL; git_status_list *status = NULL; git_diff_options diffopt = GIT_DIFF_OPTIONS_INIT; git_diff_find_options findopt = GIT_DIFF_FIND_OPTIONS_INIT; git_tree *head = NULL; git_status_show_t show = opts ? opts->show : GIT_STATUS_SHOW_INDEX_AND_WORKDIR; int error = 0; unsigned int flags = opts ? opts->flags : GIT_STATUS_OPT_DEFAULTS; *out = NULL; if (status_validate_options(opts) < 0) return -1; if ((error = git_repository__ensure_not_bare(repo, "status")) < 0 || (error = git_repository_index(&index, repo)) < 0) return error; /* if there is no HEAD, that's okay - we'll make an empty iterator */ if ((error = git_repository_head_tree(&head, repo)) < 0) { if (error != GIT_ENOTFOUND && error != GIT_EUNBORNBRANCH) goto done; giterr_clear(); } /* refresh index from disk unless prevented */ if ((flags & GIT_STATUS_OPT_NO_REFRESH) == 0 && git_index_read(index, false) < 0) giterr_clear(); status = git_status_list_alloc(index); GITERR_CHECK_ALLOC(status); if (opts) { memcpy(&status->opts, opts, sizeof(git_status_options)); memcpy(&diffopt.pathspec, &opts->pathspec, sizeof(diffopt.pathspec)); } diffopt.flags = GIT_DIFF_INCLUDE_TYPECHANGE; findopt.flags = GIT_DIFF_FIND_FOR_UNTRACKED; if ((flags & GIT_STATUS_OPT_INCLUDE_UNTRACKED) != 0) diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_UNTRACKED; if ((flags & GIT_STATUS_OPT_INCLUDE_IGNORED) != 0) diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_IGNORED; if ((flags & GIT_STATUS_OPT_INCLUDE_UNMODIFIED) != 0) diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_UNMODIFIED; if ((flags & GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS) != 0) diffopt.flags = diffopt.flags | GIT_DIFF_RECURSE_UNTRACKED_DIRS; if ((flags & GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH) != 0) diffopt.flags = diffopt.flags | GIT_DIFF_DISABLE_PATHSPEC_MATCH; if ((flags & GIT_STATUS_OPT_RECURSE_IGNORED_DIRS) != 0) diffopt.flags = diffopt.flags | GIT_DIFF_RECURSE_IGNORED_DIRS; if ((flags & GIT_STATUS_OPT_EXCLUDE_SUBMODULES) != 0) diffopt.flags = diffopt.flags | GIT_DIFF_IGNORE_SUBMODULES; if ((flags & GIT_STATUS_OPT_UPDATE_INDEX) != 0) diffopt.flags = diffopt.flags | GIT_DIFF_UPDATE_INDEX; if ((flags & GIT_STATUS_OPT_INCLUDE_UNREADABLE) != 0) diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_UNREADABLE; if ((flags & GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED) != 0) diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED; if ((flags & GIT_STATUS_OPT_RENAMES_FROM_REWRITES) != 0) findopt.flags = findopt.flags | GIT_DIFF_FIND_AND_BREAK_REWRITES | GIT_DIFF_FIND_RENAMES_FROM_REWRITES | GIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY; if (show != GIT_STATUS_SHOW_WORKDIR_ONLY) { if ((error = git_diff_tree_to_index( &status->head2idx, repo, head, index, &diffopt)) < 0) goto done; if ((flags & GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX) != 0 && (error = git_diff_find_similar(status->head2idx, &findopt)) < 0) goto done; } if (show != GIT_STATUS_SHOW_INDEX_ONLY) { if ((error = git_diff_index_to_workdir( &status->idx2wd, repo, index, &diffopt)) < 0) { goto done; } if ((flags & GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR) != 0 && (error = git_diff_find_similar(status->idx2wd, &findopt)) < 0) goto done; } error = git_diff__paired_foreach( status->head2idx, status->idx2wd, status_collect, status); if (error < 0) goto done; if (flags & GIT_STATUS_OPT_SORT_CASE_SENSITIVELY) git_vector_set_cmp(&status->paired, status_entry_cmp); if (flags & GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY) git_vector_set_cmp(&status->paired, status_entry_icmp); if ((flags & (GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX | GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR | GIT_STATUS_OPT_SORT_CASE_SENSITIVELY | GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY)) != 0) git_vector_sort(&status->paired); done: if (error < 0) { git_status_list_free(status); status = NULL; } *out = status; git_tree_free(head); git_index_free(index); return error; } size_t git_status_list_entrycount(git_status_list *status) { assert(status); return status->paired.length; } const git_status_entry *git_status_byindex(git_status_list *status, size_t i) { assert(status); return git_vector_get(&status->paired, i); } void git_status_list_free(git_status_list *status) { if (status == NULL) return; git_diff_free(status->head2idx); git_diff_free(status->idx2wd); git_vector_free_deep(&status->paired); git__memzero(status, sizeof(*status)); git__free(status); } int git_status_foreach_ext( git_repository *repo, const git_status_options *opts, git_status_cb cb, void *payload) { git_status_list *status; const git_status_entry *status_entry; size_t i; int error = 0; if ((error = git_status_list_new(&status, repo, opts)) < 0) { return error; } git_vector_foreach(&status->paired, i, status_entry) { const char *path = status_entry->head_to_index ? status_entry->head_to_index->old_file.path : status_entry->index_to_workdir->old_file.path; if ((error = cb(path, status_entry->status, payload)) != 0) { giterr_set_after_callback(error); break; } } git_status_list_free(status); return error; } int git_status_foreach(git_repository *repo, git_status_cb cb, void *payload) { return git_status_foreach_ext(repo, NULL, cb, payload); } struct status_file_info { char *expected; unsigned int count; unsigned int status; int fnm_flags; int ambiguous; }; static int get_one_status(const char *path, unsigned int status, void *data) { struct status_file_info *sfi = data; int (*strcomp)(const char *a, const char *b); sfi->count++; sfi->status = status; strcomp = (sfi->fnm_flags & FNM_CASEFOLD) ? git__strcasecmp : git__strcmp; if (sfi->count > 1 || (strcomp(sfi->expected, path) != 0 && p_fnmatch(sfi->expected, path, sfi->fnm_flags) != 0)) { sfi->ambiguous = true; return GIT_EAMBIGUOUS; /* giterr_set will be done by caller */ } return 0; } int git_status_file( unsigned int *status_flags, git_repository *repo, const char *path) { int error; git_status_options opts = GIT_STATUS_OPTIONS_INIT; struct status_file_info sfi = {0}; git_index *index; assert(status_flags && repo && path); if ((error = git_repository_index__weakptr(&index, repo)) < 0) return error; if ((sfi.expected = git__strdup(path)) == NULL) return -1; if (index->ignore_case) sfi.fnm_flags = FNM_CASEFOLD; opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR; opts.flags = GIT_STATUS_OPT_INCLUDE_IGNORED | GIT_STATUS_OPT_RECURSE_IGNORED_DIRS | GIT_STATUS_OPT_INCLUDE_UNTRACKED | GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS | GIT_STATUS_OPT_INCLUDE_UNMODIFIED | GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH; opts.pathspec.count = 1; opts.pathspec.strings = &sfi.expected; error = git_status_foreach_ext(repo, &opts, get_one_status, &sfi); if (error < 0 && sfi.ambiguous) { giterr_set(GITERR_INVALID, "Ambiguous path '%s' given to git_status_file", sfi.expected); error = GIT_EAMBIGUOUS; } if (!error && !sfi.count) { giterr_set(GITERR_INVALID, "Attempt to get status of nonexistent file '%s'", path); error = GIT_ENOTFOUND; } *status_flags = sfi.status; git__free(sfi.expected); return error; } int git_status_should_ignore( int *ignored, git_repository *repo, const char *path) { return git_ignore_path_is_ignored(ignored, repo, path); } int git_status_init_options(git_status_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_status_options, GIT_STATUS_OPTIONS_INIT); return 0; } int git_status_list_get_perfdata( git_diff_perfdata *out, const git_status_list *status) { assert(out); GITERR_CHECK_VERSION(out, GIT_DIFF_PERFDATA_VERSION, "git_diff_perfdata"); out->stat_calls = 0; out->oid_calculations = 0; if (status->head2idx) { out->stat_calls += status->head2idx->perf.stat_calls; out->oid_calculations += status->head2idx->perf.oid_calculations; } if (status->idx2wd) { out->stat_calls += status->idx2wd->perf.stat_calls; out->oid_calculations += status->idx2wd->perf.oid_calculations; } return 0; } deps/libgit2-sys-0.3.8/libgit2/src/diff_print.c0000664000175000017500000004066412610310643016170 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "diff.h" #include "diff_patch.h" #include "fileops.h" #include "zstream.h" #include "blob.h" #include "delta.h" #include "git2/sys/diff.h" typedef struct { git_diff *diff; git_diff_format_t format; git_diff_line_cb print_cb; void *payload; git_buf *buf; uint32_t flags; int oid_strlen; git_diff_line line; unsigned int content_loaded : 1, content_allocated : 1; git_diff_file_content *ofile; git_diff_file_content *nfile; } diff_print_info; static int diff_print_info_init__common( diff_print_info *pi, git_buf *out, git_repository *repo, git_diff_format_t format, git_diff_line_cb cb, void *payload) { pi->format = format; pi->print_cb = cb; pi->payload = payload; pi->buf = out; if (!pi->oid_strlen) { if (!repo) pi->oid_strlen = GIT_ABBREV_DEFAULT; else if (git_repository__cvar(&pi->oid_strlen, repo, GIT_CVAR_ABBREV) < 0) return -1; } pi->oid_strlen += 1; /* for NUL byte */ if (pi->oid_strlen > GIT_OID_HEXSZ + 1) pi->oid_strlen = GIT_OID_HEXSZ + 1; memset(&pi->line, 0, sizeof(pi->line)); pi->line.old_lineno = -1; pi->line.new_lineno = -1; pi->line.num_lines = 1; return 0; } static int diff_print_info_init_fromdiff( diff_print_info *pi, git_buf *out, git_diff *diff, git_diff_format_t format, git_diff_line_cb cb, void *payload) { git_repository *repo = diff ? diff->repo : NULL; memset(pi, 0, sizeof(diff_print_info)); pi->diff = diff; if (diff) { pi->flags = diff->opts.flags; pi->oid_strlen = diff->opts.id_abbrev; } return diff_print_info_init__common(pi, out, repo, format, cb, payload); } static int diff_print_info_init_frompatch( diff_print_info *pi, git_buf *out, git_patch *patch, git_diff_format_t format, git_diff_line_cb cb, void *payload) { git_repository *repo = patch && patch->diff ? patch->diff->repo : NULL; memset(pi, 0, sizeof(diff_print_info)); pi->diff = patch->diff; pi->flags = patch->diff_opts.flags; pi->oid_strlen = patch->diff_opts.id_abbrev; pi->content_loaded = 1; pi->ofile = &patch->ofile; pi->nfile = &patch->nfile; return diff_print_info_init__common(pi, out, repo, format, cb, payload); } static char diff_pick_suffix(int mode) { if (S_ISDIR(mode)) return '/'; else if (GIT_PERMS_IS_EXEC(mode)) /* -V536 */ /* in git, modes are very regular, so we must have 0100755 mode */ return '*'; else return ' '; } char git_diff_status_char(git_delta_t status) { char code; switch (status) { case GIT_DELTA_ADDED: code = 'A'; break; case GIT_DELTA_DELETED: code = 'D'; break; case GIT_DELTA_MODIFIED: code = 'M'; break; case GIT_DELTA_RENAMED: code = 'R'; break; case GIT_DELTA_COPIED: code = 'C'; break; case GIT_DELTA_IGNORED: code = 'I'; break; case GIT_DELTA_UNTRACKED: code = '?'; break; case GIT_DELTA_UNREADABLE: code = 'X'; break; default: code = ' '; break; } return code; } static int diff_print_one_name_only( const git_diff_delta *delta, float progress, void *data) { diff_print_info *pi = data; git_buf *out = pi->buf; GIT_UNUSED(progress); if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 && delta->status == GIT_DELTA_UNMODIFIED) return 0; git_buf_clear(out); git_buf_puts(out, delta->new_file.path); git_buf_putc(out, '\n'); if (git_buf_oom(out)) return -1; pi->line.origin = GIT_DIFF_LINE_FILE_HDR; pi->line.content = git_buf_cstr(out); pi->line.content_len = git_buf_len(out); return pi->print_cb(delta, NULL, &pi->line, pi->payload); } static int diff_print_one_name_status( const git_diff_delta *delta, float progress, void *data) { diff_print_info *pi = data; git_buf *out = pi->buf; char old_suffix, new_suffix, code = git_diff_status_char(delta->status); int (*strcomp)(const char *, const char *) = pi->diff ? pi->diff->strcomp : git__strcmp; GIT_UNUSED(progress); if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 && code == ' ') return 0; old_suffix = diff_pick_suffix(delta->old_file.mode); new_suffix = diff_pick_suffix(delta->new_file.mode); git_buf_clear(out); if (delta->old_file.path != delta->new_file.path && strcomp(delta->old_file.path,delta->new_file.path) != 0) git_buf_printf(out, "%c\t%s%c %s%c\n", code, delta->old_file.path, old_suffix, delta->new_file.path, new_suffix); else if (delta->old_file.mode != delta->new_file.mode && delta->old_file.mode != 0 && delta->new_file.mode != 0) git_buf_printf(out, "%c\t%s%c %s%c\n", code, delta->old_file.path, old_suffix, delta->new_file.path, new_suffix); else if (old_suffix != ' ') git_buf_printf(out, "%c\t%s%c\n", code, delta->old_file.path, old_suffix); else git_buf_printf(out, "%c\t%s\n", code, delta->old_file.path); if (git_buf_oom(out)) return -1; pi->line.origin = GIT_DIFF_LINE_FILE_HDR; pi->line.content = git_buf_cstr(out); pi->line.content_len = git_buf_len(out); return pi->print_cb(delta, NULL, &pi->line, pi->payload); } static int diff_print_one_raw( const git_diff_delta *delta, float progress, void *data) { diff_print_info *pi = data; git_buf *out = pi->buf; char code = git_diff_status_char(delta->status); char start_oid[GIT_OID_HEXSZ+1], end_oid[GIT_OID_HEXSZ+1]; GIT_UNUSED(progress); if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 && code == ' ') return 0; git_buf_clear(out); git_oid_tostr(start_oid, pi->oid_strlen, &delta->old_file.id); git_oid_tostr(end_oid, pi->oid_strlen, &delta->new_file.id); git_buf_printf( out, (pi->oid_strlen <= GIT_OID_HEXSZ) ? ":%06o %06o %s... %s... %c" : ":%06o %06o %s %s %c", delta->old_file.mode, delta->new_file.mode, start_oid, end_oid, code); if (delta->similarity > 0) git_buf_printf(out, "%03u", delta->similarity); if (delta->old_file.path != delta->new_file.path) git_buf_printf( out, "\t%s %s\n", delta->old_file.path, delta->new_file.path); else git_buf_printf( out, "\t%s\n", delta->old_file.path ? delta->old_file.path : delta->new_file.path); if (git_buf_oom(out)) return -1; pi->line.origin = GIT_DIFF_LINE_FILE_HDR; pi->line.content = git_buf_cstr(out); pi->line.content_len = git_buf_len(out); return pi->print_cb(delta, NULL, &pi->line, pi->payload); } static int diff_print_oid_range( git_buf *out, const git_diff_delta *delta, int oid_strlen) { char start_oid[GIT_OID_HEXSZ+1], end_oid[GIT_OID_HEXSZ+1]; git_oid_tostr(start_oid, oid_strlen, &delta->old_file.id); git_oid_tostr(end_oid, oid_strlen, &delta->new_file.id); /* TODO: Match git diff more closely */ if (delta->old_file.mode == delta->new_file.mode) { git_buf_printf(out, "index %s..%s %o\n", start_oid, end_oid, delta->old_file.mode); } else { if (delta->old_file.mode == 0) { git_buf_printf(out, "new file mode %o\n", delta->new_file.mode); } else if (delta->new_file.mode == 0) { git_buf_printf(out, "deleted file mode %o\n", delta->old_file.mode); } else { git_buf_printf(out, "old mode %o\n", delta->old_file.mode); git_buf_printf(out, "new mode %o\n", delta->new_file.mode); } git_buf_printf(out, "index %s..%s\n", start_oid, end_oid); } return git_buf_oom(out) ? -1 : 0; } static int diff_delta_format_with_paths( git_buf *out, const git_diff_delta *delta, const char *oldpfx, const char *newpfx, const char *template) { const char *oldpath = delta->old_file.path; const char *newpath = delta->new_file.path; if (git_oid_iszero(&delta->old_file.id)) { oldpfx = ""; oldpath = "/dev/null"; } if (git_oid_iszero(&delta->new_file.id)) { newpfx = ""; newpath = "/dev/null"; } return git_buf_printf(out, template, oldpfx, oldpath, newpfx, newpath); } int git_diff_delta__format_file_header( git_buf *out, const git_diff_delta *delta, const char *oldpfx, const char *newpfx, int oid_strlen) { if (!oldpfx) oldpfx = DIFF_OLD_PREFIX_DEFAULT; if (!newpfx) newpfx = DIFF_NEW_PREFIX_DEFAULT; if (!oid_strlen) oid_strlen = GIT_ABBREV_DEFAULT + 1; git_buf_clear(out); git_buf_printf(out, "diff --git %s%s %s%s\n", oldpfx, delta->old_file.path, newpfx, delta->new_file.path); GITERR_CHECK_ERROR(diff_print_oid_range(out, delta, oid_strlen)); if ((delta->flags & GIT_DIFF_FLAG_BINARY) == 0) diff_delta_format_with_paths( out, delta, oldpfx, newpfx, "--- %s%s\n+++ %s%s\n"); return git_buf_oom(out) ? -1 : 0; } static int format_binary( diff_print_info *pi, git_diff_binary_t type, const char *data, size_t datalen, size_t inflatedlen) { const char *typename = type == GIT_DIFF_BINARY_DELTA ? "delta" : "literal"; const char *scan, *end; git_buf_printf(pi->buf, "%s %" PRIuZ "\n", typename, inflatedlen); pi->line.num_lines++; for (scan = data, end = data + datalen; scan < end; ) { size_t chunk_len = end - scan; if (chunk_len > 52) chunk_len = 52; if (chunk_len <= 26) git_buf_putc(pi->buf, (char)chunk_len + 'A' - 1); else git_buf_putc(pi->buf, (char)chunk_len - 26 + 'a' - 1); git_buf_encode_base85(pi->buf, scan, chunk_len); git_buf_putc(pi->buf, '\n'); if (git_buf_oom(pi->buf)) return -1; scan += chunk_len; pi->line.num_lines++; } git_buf_putc(pi->buf, '\n'); return 0; } static int diff_print_load_content( diff_print_info *pi, git_diff_delta *delta) { git_diff_file_content *ofile, *nfile; int error; assert(pi->diff); ofile = git__calloc(1, sizeof(git_diff_file_content)); nfile = git__calloc(1, sizeof(git_diff_file_content)); GITERR_CHECK_ALLOC(ofile); GITERR_CHECK_ALLOC(nfile); if ((error = git_diff_file_content__init_from_diff( ofile, pi->diff, delta, true)) < 0 || (error = git_diff_file_content__init_from_diff( nfile, pi->diff, delta, true)) < 0) { git__free(ofile); git__free(nfile); return error; } pi->content_loaded = 1; pi->content_allocated = 1; pi->ofile = ofile; pi->nfile = nfile; return 0; } static int diff_print_patch_file_binary( diff_print_info *pi, git_diff_delta *delta, const char *old_pfx, const char *new_pfx, const git_diff_binary *binary) { size_t pre_binary_size; int error; if ((pi->flags & GIT_DIFF_SHOW_BINARY) == 0) goto noshow; if (!pi->content_loaded && (error = diff_print_load_content(pi, delta)) < 0) return error; pre_binary_size = pi->buf->size; git_buf_printf(pi->buf, "GIT binary patch\n"); pi->line.num_lines++; if ((error = format_binary(pi, binary->new_file.type, binary->new_file.data, binary->new_file.datalen, binary->new_file.inflatedlen)) < 0 || (error = format_binary(pi, binary->old_file.type, binary->old_file.data, binary->old_file.datalen, binary->old_file.inflatedlen)) < 0) { if (error == GIT_EBUFS) { giterr_clear(); git_buf_truncate(pi->buf, pre_binary_size); goto noshow; } } pi->line.num_lines++; return error; noshow: pi->line.num_lines = 1; return diff_delta_format_with_paths( pi->buf, delta, old_pfx, new_pfx, "Binary files %s%s and %s%s differ\n"); } static int diff_print_patch_file( const git_diff_delta *delta, float progress, void *data) { int error; diff_print_info *pi = data; const char *oldpfx = pi->diff ? pi->diff->opts.old_prefix : DIFF_OLD_PREFIX_DEFAULT; const char *newpfx = pi->diff ? pi->diff->opts.new_prefix : DIFF_NEW_PREFIX_DEFAULT; bool binary = (delta->flags & GIT_DIFF_FLAG_BINARY) || (pi->flags & GIT_DIFF_FORCE_BINARY); bool show_binary = !!(pi->flags & GIT_DIFF_SHOW_BINARY); int oid_strlen = binary && show_binary ? GIT_OID_HEXSZ + 1 : pi->oid_strlen; GIT_UNUSED(progress); if (S_ISDIR(delta->new_file.mode) || delta->status == GIT_DELTA_UNMODIFIED || delta->status == GIT_DELTA_IGNORED || delta->status == GIT_DELTA_UNREADABLE || (delta->status == GIT_DELTA_UNTRACKED && (pi->flags & GIT_DIFF_SHOW_UNTRACKED_CONTENT) == 0)) return 0; if ((error = git_diff_delta__format_file_header( pi->buf, delta, oldpfx, newpfx, oid_strlen)) < 0) return error; pi->line.origin = GIT_DIFF_LINE_FILE_HDR; pi->line.content = git_buf_cstr(pi->buf); pi->line.content_len = git_buf_len(pi->buf); return pi->print_cb(delta, NULL, &pi->line, pi->payload); } static int diff_print_patch_binary( const git_diff_delta *delta, const git_diff_binary *binary, void *data) { diff_print_info *pi = data; const char *old_pfx = pi->diff ? pi->diff->opts.old_prefix : DIFF_OLD_PREFIX_DEFAULT; const char *new_pfx = pi->diff ? pi->diff->opts.new_prefix : DIFF_NEW_PREFIX_DEFAULT; int error; git_buf_clear(pi->buf); if ((error = diff_print_patch_file_binary( pi, (git_diff_delta *)delta, old_pfx, new_pfx, binary)) < 0) return error; pi->line.origin = GIT_DIFF_LINE_BINARY; pi->line.content = git_buf_cstr(pi->buf); pi->line.content_len = git_buf_len(pi->buf); return pi->print_cb(delta, NULL, &pi->line, pi->payload); } static int diff_print_patch_hunk( const git_diff_delta *d, const git_diff_hunk *h, void *data) { diff_print_info *pi = data; if (S_ISDIR(d->new_file.mode)) return 0; pi->line.origin = GIT_DIFF_LINE_HUNK_HDR; pi->line.content = h->header; pi->line.content_len = h->header_len; return pi->print_cb(d, h, &pi->line, pi->payload); } static int diff_print_patch_line( const git_diff_delta *delta, const git_diff_hunk *hunk, const git_diff_line *line, void *data) { diff_print_info *pi = data; if (S_ISDIR(delta->new_file.mode)) return 0; return pi->print_cb(delta, hunk, line, pi->payload); } /* print a git_diff to an output callback */ int git_diff_print( git_diff *diff, git_diff_format_t format, git_diff_line_cb print_cb, void *payload) { int error; git_buf buf = GIT_BUF_INIT; diff_print_info pi; git_diff_file_cb print_file = NULL; git_diff_binary_cb print_binary = NULL; git_diff_hunk_cb print_hunk = NULL; git_diff_line_cb print_line = NULL; switch (format) { case GIT_DIFF_FORMAT_PATCH: print_file = diff_print_patch_file; print_binary = diff_print_patch_binary; print_hunk = diff_print_patch_hunk; print_line = diff_print_patch_line; break; case GIT_DIFF_FORMAT_PATCH_HEADER: print_file = diff_print_patch_file; break; case GIT_DIFF_FORMAT_RAW: print_file = diff_print_one_raw; break; case GIT_DIFF_FORMAT_NAME_ONLY: print_file = diff_print_one_name_only; break; case GIT_DIFF_FORMAT_NAME_STATUS: print_file = diff_print_one_name_status; break; default: giterr_set(GITERR_INVALID, "Unknown diff output format (%d)", format); return -1; } if (!(error = diff_print_info_init_fromdiff( &pi, &buf, diff, format, print_cb, payload))) { error = git_diff_foreach( diff, print_file, print_binary, print_hunk, print_line, &pi); if (error) /* make sure error message is set */ giterr_set_after_callback_function(error, "git_diff_print"); } git__free(pi.nfile); git__free(pi.ofile); git_buf_free(&buf); return error; } /* print a git_patch to an output callback */ int git_patch_print( git_patch *patch, git_diff_line_cb print_cb, void *payload) { int error; git_buf temp = GIT_BUF_INIT; diff_print_info pi; assert(patch && print_cb); if (!(error = diff_print_info_init_frompatch( &pi, &temp, patch, GIT_DIFF_FORMAT_PATCH, print_cb, payload))) { error = git_patch__invoke_callbacks( patch, diff_print_patch_file, diff_print_patch_binary, diff_print_patch_hunk, diff_print_patch_line, &pi); if (error) /* make sure error message is set */ giterr_set_after_callback_function(error, "git_patch_print"); } git_buf_free(&temp); return error; } int git_diff_print_callback__to_buf( const git_diff_delta *delta, const git_diff_hunk *hunk, const git_diff_line *line, void *payload) { git_buf *output = payload; GIT_UNUSED(delta); GIT_UNUSED(hunk); if (!output) { giterr_set(GITERR_INVALID, "Buffer pointer must be provided"); return -1; } if (line->origin == GIT_DIFF_LINE_ADDITION || line->origin == GIT_DIFF_LINE_DELETION || line->origin == GIT_DIFF_LINE_CONTEXT) git_buf_putc(output, line->origin); return git_buf_put(output, line->content, line->content_len); } int git_diff_print_callback__to_file_handle( const git_diff_delta *delta, const git_diff_hunk *hunk, const git_diff_line *line, void *payload) { FILE *fp = payload ? payload : stdout; GIT_UNUSED(delta); GIT_UNUSED(hunk); if (line->origin == GIT_DIFF_LINE_CONTEXT || line->origin == GIT_DIFF_LINE_ADDITION || line->origin == GIT_DIFF_LINE_DELETION) fputc(line->origin, fp); fwrite(line->content, 1, line->content_len, fp); return 0; } /* print a git_patch to a git_buf */ int git_patch_to_buf(git_buf *out, git_patch *patch) { assert(out && patch); git_buf_sanitize(out); return git_patch_print(patch, git_diff_print_callback__to_buf, out); } deps/libgit2-sys-0.3.8/libgit2/src/config.h0000664000175000017500000000624412572105236015321 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_config_h__ #define INCLUDE_config_h__ #include "git2.h" #include "git2/config.h" #include "vector.h" #include "repository.h" #define GIT_CONFIG_FILENAME_SYSTEM "gitconfig" #define GIT_CONFIG_FILENAME_GLOBAL ".gitconfig" #define GIT_CONFIG_FILENAME_XDG "config" #define GIT_CONFIG_FILENAME_INREPO "config" #define GIT_CONFIG_FILE_MODE 0666 struct git_config { git_refcount rc; git_vector files; }; extern int git_config__global_location(git_buf *buf); extern int git_config_rename_section( git_repository *repo, const char *old_section_name, /* eg "branch.dummy" */ const char *new_section_name); /* NULL to drop the old section */ /** * Create a configuration file backend for ondisk files * * These are the normal `.gitconfig` files that Core Git * processes. Note that you first have to add this file to a * configuration object before you can query it for configuration * variables. * * @param out the new backend * @param path where the config file is located */ extern int git_config_file__ondisk(git_config_backend **out, const char *path); extern int git_config__normalize_name(const char *in, char **out); /* internal only: does not normalize key and sets out to NULL if not found */ extern int git_config__lookup_entry( git_config_entry **out, const git_config *cfg, const char *key, bool no_errors); /* internal only: update and/or delete entry string with constraints */ extern int git_config__update_entry( git_config *cfg, const char *key, const char *value, bool overwrite_existing, bool only_if_existing); /* * Lookup functions that cannot fail. These functions look up a config * value and return a fallback value if the value is missing or if any * failures occur while trying to access the value. */ extern char *git_config__get_string_force( const git_config *cfg, const char *key, const char *fallback_value); extern int git_config__get_bool_force( const git_config *cfg, const char *key, int fallback_value); extern int git_config__get_int_force( const git_config *cfg, const char *key, int fallback_value); /* API for repository cvar-style lookups from config - not cached, but * uses cvar value maps and fallbacks */ extern int git_config__cvar( int *out, git_config *config, git_cvar_cached cvar); /** * The opposite of git_config_lookup_map_value, we take an enum value * and map it to the string or bool value on the config. */ int git_config_lookup_map_enum(git_cvar_t *type_out, const char **str_out, const git_cvar_map *maps, size_t map_n, int enum_val); /** * Unlock the backend with the highest priority * * Unlocking will allow other writers to updat the configuration * file. Optionally, any changes performed since the lock will be * applied to the configuration. * * @param cfg the configuration * @param commit boolean which indicates whether to commit any changes * done since locking * @return 0 or an error code */ GIT_EXTERN(int) git_config_unlock(git_config *cfg, int commit); #endif deps/libgit2-sys-0.3.8/libgit2/src/fnmatch.c0000664000175000017500000001573312555730137015477 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ /* * This file contains code originally derrived from OpenBSD fnmatch.c * * Copyright (c) 1989, 1993, 1994 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Guido van Rossum. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. Neither the name of the University 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 THE REGENTS AND CONTRIBUTORS ``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 THE REGENTS OR CONTRIBUTORS 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. */ /* * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6. * Compares a filename or pathname to a pattern. */ #include #include #include #include "fnmatch.h" #define EOS '\0' #define RANGE_MATCH 1 #define RANGE_NOMATCH 0 #define RANGE_ERROR (-1) static int rangematch(const char *, char, int, char **); static int p_fnmatchx(const char *pattern, const char *string, int flags, size_t recurs) { const char *stringstart; char *newp; char c, test; int recurs_flags = flags & ~FNM_PERIOD; if (recurs-- == 0) return FNM_NORES; for (stringstart = string;;) switch (c = *pattern++) { case EOS: if ((flags & FNM_LEADING_DIR) && *string == '/') return (0); return (*string == EOS ? 0 : FNM_NOMATCH); case '?': if (*string == EOS) return (FNM_NOMATCH); if (*string == '/' && (flags & FNM_PATHNAME)) return (FNM_NOMATCH); if (*string == '.' && (flags & FNM_PERIOD) && (string == stringstart || ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) return (FNM_NOMATCH); ++string; break; case '*': c = *pattern; /* Let '**' override PATHNAME match for this segment. * It will be restored if/when we recurse below. */ if (c == '*') { flags &= ~FNM_PATHNAME; while (c == '*') c = *++pattern; if (c == '/') c = *++pattern; } if (*string == '.' && (flags & FNM_PERIOD) && (string == stringstart || ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) return (FNM_NOMATCH); /* Optimize for pattern with * at end or before /. */ if (c == EOS) { if (flags & FNM_PATHNAME) return ((flags & FNM_LEADING_DIR) || strchr(string, '/') == NULL ? 0 : FNM_NOMATCH); else return (0); } else if (c == '/' && (flags & FNM_PATHNAME)) { if ((string = strchr(string, '/')) == NULL) return (FNM_NOMATCH); break; } /* General case, use recursion. */ while ((test = *string) != EOS) { int e; e = p_fnmatchx(pattern, string, recurs_flags, recurs); if (e != FNM_NOMATCH) return e; if (test == '/' && (flags & FNM_PATHNAME)) break; ++string; } return (FNM_NOMATCH); case '[': if (*string == EOS) return (FNM_NOMATCH); if (*string == '/' && (flags & FNM_PATHNAME)) return (FNM_NOMATCH); if (*string == '.' && (flags & FNM_PERIOD) && (string == stringstart || ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) return (FNM_NOMATCH); switch (rangematch(pattern, *string, flags, &newp)) { case RANGE_ERROR: /* not a good range, treat as normal text */ goto normal; case RANGE_MATCH: pattern = newp; break; case RANGE_NOMATCH: return (FNM_NOMATCH); } ++string; break; case '\\': if (!(flags & FNM_NOESCAPE)) { if ((c = *pattern++) == EOS) { c = '\\'; --pattern; } } /* FALLTHROUGH */ default: normal: if (c != *string && !((flags & FNM_CASEFOLD) && (git__tolower((unsigned char)c) == git__tolower((unsigned char)*string)))) return (FNM_NOMATCH); ++string; break; } /* NOTREACHED */ } static int rangematch(const char *pattern, char test, int flags, char **newp) { int negate, ok; char c, c2; /* * A bracket expression starting with an unquoted circumflex * character produces unspecified results (IEEE 1003.2-1992, * 3.13.2). This implementation treats it like '!', for * consistency with the regular expression syntax. * J.T. Conklin (conklin@ngai.kaleida.com) */ if ((negate = (*pattern == '!' || *pattern == '^')) != 0) ++pattern; if (flags & FNM_CASEFOLD) test = (char)git__tolower((unsigned char)test); /* * A right bracket shall lose its special meaning and represent * itself in a bracket expression if it occurs first in the list. * -- POSIX.2 2.8.3.2 */ ok = 0; c = *pattern++; do { if (c == '\\' && !(flags & FNM_NOESCAPE)) c = *pattern++; if (c == EOS) return (RANGE_ERROR); if (c == '/' && (flags & FNM_PATHNAME)) return (RANGE_NOMATCH); if ((flags & FNM_CASEFOLD)) c = (char)git__tolower((unsigned char)c); if (*pattern == '-' && (c2 = *(pattern+1)) != EOS && c2 != ']') { pattern += 2; if (c2 == '\\' && !(flags & FNM_NOESCAPE)) c2 = *pattern++; if (c2 == EOS) return (RANGE_ERROR); if (flags & FNM_CASEFOLD) c2 = (char)git__tolower((unsigned char)c2); if (c <= test && test <= c2) ok = 1; } else if (c == test) ok = 1; } while ((c = *pattern++) != ']'); *newp = (char *)pattern; return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH); } int p_fnmatch(const char *pattern, const char *string, int flags) { return p_fnmatchx(pattern, string, flags, 64); } deps/libgit2-sys-0.3.8/libgit2/src/refs.c0000664000175000017500000007006412555730137015014 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "refs.h" #include "hash.h" #include "repository.h" #include "fileops.h" #include "filebuf.h" #include "pack.h" #include "reflog.h" #include "refdb.h" #include #include #include #include #include #include #include #include #include GIT__USE_STRMAP #define DEFAULT_NESTING_LEVEL 5 #define MAX_NESTING_LEVEL 10 enum { GIT_PACKREF_HAS_PEEL = 1, GIT_PACKREF_WAS_LOOSE = 2 }; static git_reference *alloc_ref(const char *name) { git_reference *ref = NULL; size_t namelen = strlen(name), reflen; if (!GIT_ADD_SIZET_OVERFLOW(&reflen, sizeof(git_reference), namelen) && !GIT_ADD_SIZET_OVERFLOW(&reflen, reflen, 1) && (ref = git__calloc(1, reflen)) != NULL) memcpy(ref->name, name, namelen + 1); return ref; } git_reference *git_reference__alloc_symbolic( const char *name, const char *target) { git_reference *ref; assert(name && target); ref = alloc_ref(name); if (!ref) return NULL; ref->type = GIT_REF_SYMBOLIC; if ((ref->target.symbolic = git__strdup(target)) == NULL) { git__free(ref); return NULL; } return ref; } git_reference *git_reference__alloc( const char *name, const git_oid *oid, const git_oid *peel) { git_reference *ref; assert(name && oid); ref = alloc_ref(name); if (!ref) return NULL; ref->type = GIT_REF_OID; git_oid_cpy(&ref->target.oid, oid); if (peel != NULL) git_oid_cpy(&ref->peel, peel); return ref; } git_reference *git_reference__set_name( git_reference *ref, const char *name) { size_t namelen = strlen(name); size_t reflen; git_reference *rewrite = NULL; if (!GIT_ADD_SIZET_OVERFLOW(&reflen, sizeof(git_reference), namelen) && !GIT_ADD_SIZET_OVERFLOW(&reflen, reflen, 1) && (rewrite = git__realloc(ref, reflen)) != NULL) memcpy(rewrite->name, name, namelen + 1); return rewrite; } void git_reference_free(git_reference *reference) { if (reference == NULL) return; if (reference->type == GIT_REF_SYMBOLIC) git__free(reference->target.symbolic); if (reference->db) GIT_REFCOUNT_DEC(reference->db, git_refdb__free); git__free(reference); } int git_reference_delete(git_reference *ref) { const git_oid *old_id = NULL; const char *old_target = NULL; if (ref->type == GIT_REF_OID) old_id = &ref->target.oid; else old_target = ref->target.symbolic; return git_refdb_delete(ref->db, ref->name, old_id, old_target); } int git_reference_remove(git_repository *repo, const char *name) { git_refdb *db; int error; if ((error = git_repository_refdb__weakptr(&db, repo)) < 0) return error; return git_refdb_delete(db, name, NULL, NULL); } int git_reference_lookup(git_reference **ref_out, git_repository *repo, const char *name) { return git_reference_lookup_resolved(ref_out, repo, name, 0); } int git_reference_name_to_id( git_oid *out, git_repository *repo, const char *name) { int error; git_reference *ref; if ((error = git_reference_lookup_resolved(&ref, repo, name, -1)) < 0) return error; git_oid_cpy(out, git_reference_target(ref)); git_reference_free(ref); return 0; } static int reference_normalize_for_repo( git_refname_t out, git_repository *repo, const char *name) { int precompose; unsigned int flags = GIT_REF_FORMAT_ALLOW_ONELEVEL; if (!git_repository__cvar(&precompose, repo, GIT_CVAR_PRECOMPOSE) && precompose) flags |= GIT_REF_FORMAT__PRECOMPOSE_UNICODE; return git_reference_normalize_name(out, GIT_REFNAME_MAX, name, flags); } int git_reference_lookup_resolved( git_reference **ref_out, git_repository *repo, const char *name, int max_nesting) { git_refname_t scan_name; git_ref_t scan_type; int error = 0, nesting; git_reference *ref = NULL; git_refdb *refdb; assert(ref_out && repo && name); *ref_out = NULL; if (max_nesting > MAX_NESTING_LEVEL) max_nesting = MAX_NESTING_LEVEL; else if (max_nesting < 0) max_nesting = DEFAULT_NESTING_LEVEL; scan_type = GIT_REF_SYMBOLIC; if ((error = reference_normalize_for_repo(scan_name, repo, name)) < 0) return error; if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0) return error; for (nesting = max_nesting; nesting >= 0 && scan_type == GIT_REF_SYMBOLIC; nesting--) { if (nesting != max_nesting) { strncpy(scan_name, ref->target.symbolic, sizeof(scan_name)); git_reference_free(ref); } if ((error = git_refdb_lookup(&ref, refdb, scan_name)) < 0) return error; scan_type = ref->type; } if (scan_type != GIT_REF_OID && max_nesting != 0) { giterr_set(GITERR_REFERENCE, "Cannot resolve reference (>%u levels deep)", max_nesting); git_reference_free(ref); return -1; } *ref_out = ref; return 0; } int git_reference_dwim(git_reference **out, git_repository *repo, const char *refname) { int error = 0, i; bool fallbackmode = true, foundvalid = false; git_reference *ref; git_buf refnamebuf = GIT_BUF_INIT, name = GIT_BUF_INIT; static const char* formatters[] = { "%s", GIT_REFS_DIR "%s", GIT_REFS_TAGS_DIR "%s", GIT_REFS_HEADS_DIR "%s", GIT_REFS_REMOTES_DIR "%s", GIT_REFS_REMOTES_DIR "%s/" GIT_HEAD_FILE, NULL }; if (*refname) git_buf_puts(&name, refname); else { git_buf_puts(&name, GIT_HEAD_FILE); fallbackmode = false; } for (i = 0; formatters[i] && (fallbackmode || i == 0); i++) { git_buf_clear(&refnamebuf); if ((error = git_buf_printf(&refnamebuf, formatters[i], git_buf_cstr(&name))) < 0) goto cleanup; if (!git_reference_is_valid_name(git_buf_cstr(&refnamebuf))) { error = GIT_EINVALIDSPEC; continue; } foundvalid = true; error = git_reference_lookup_resolved(&ref, repo, git_buf_cstr(&refnamebuf), -1); if (!error) { *out = ref; error = 0; goto cleanup; } if (error != GIT_ENOTFOUND) goto cleanup; } cleanup: if (error && !foundvalid) { /* never found a valid reference name */ giterr_set(GITERR_REFERENCE, "Could not use '%s' as valid reference name", git_buf_cstr(&name)); } git_buf_free(&name); git_buf_free(&refnamebuf); return error; } /** * Getters */ git_ref_t git_reference_type(const git_reference *ref) { assert(ref); return ref->type; } const char *git_reference_name(const git_reference *ref) { assert(ref); return ref->name; } git_repository *git_reference_owner(const git_reference *ref) { assert(ref); return ref->db->repo; } const git_oid *git_reference_target(const git_reference *ref) { assert(ref); if (ref->type != GIT_REF_OID) return NULL; return &ref->target.oid; } const git_oid *git_reference_target_peel(const git_reference *ref) { assert(ref); if (ref->type != GIT_REF_OID || git_oid_iszero(&ref->peel)) return NULL; return &ref->peel; } const char *git_reference_symbolic_target(const git_reference *ref) { assert(ref); if (ref->type != GIT_REF_SYMBOLIC) return NULL; return ref->target.symbolic; } static int reference__create( git_reference **ref_out, git_repository *repo, const char *name, const git_oid *oid, const char *symbolic, int force, const git_signature *signature, const char *log_message, const git_oid *old_id, const char *old_target) { git_refname_t normalized; git_refdb *refdb; git_reference *ref = NULL; int error = 0; assert(repo && name); assert(symbolic || signature); if (ref_out) *ref_out = NULL; error = reference_normalize_for_repo(normalized, repo, name); if (error < 0) return error; error = git_repository_refdb__weakptr(&refdb, repo); if (error < 0) return error; if (oid != NULL) { git_odb *odb; assert(symbolic == NULL); /* Sanity check the reference being created - target must exist. */ if ((error = git_repository_odb__weakptr(&odb, repo)) < 0) return error; if (!git_odb_exists(odb, oid)) { giterr_set(GITERR_REFERENCE, "Target OID for the reference doesn't exist on the repository"); return -1; } ref = git_reference__alloc(normalized, oid, NULL); } else { git_refname_t normalized_target; if ((error = reference_normalize_for_repo(normalized_target, repo, symbolic)) < 0) return error; ref = git_reference__alloc_symbolic(normalized, normalized_target); } GITERR_CHECK_ALLOC(ref); if ((error = git_refdb_write(refdb, ref, force, signature, log_message, old_id, old_target)) < 0) { git_reference_free(ref); return error; } if (ref_out == NULL) git_reference_free(ref); else *ref_out = ref; return 0; } int configured_ident(git_signature **out, const git_repository *repo) { if (repo->ident_name && repo->ident_email) return git_signature_now(out, repo->ident_name, repo->ident_email); /* if not configured let us fall-through to the next method */ return -1; } int git_reference__log_signature(git_signature **out, git_repository *repo) { int error; git_signature *who; if(((error = configured_ident(&who, repo)) < 0) && ((error = git_signature_default(&who, repo)) < 0) && ((error = git_signature_now(&who, "unknown", "unknown")) < 0)) return error; *out = who; return 0; } int git_reference_create_matching( git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id, int force, const git_oid *old_id, const char *log_message) { int error; git_signature *who = NULL; assert(id); if ((error = git_reference__log_signature(&who, repo)) < 0) return error; error = reference__create( ref_out, repo, name, id, NULL, force, who, log_message, old_id, NULL); git_signature_free(who); return error; } int git_reference_create( git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id, int force, const char *log_message) { return git_reference_create_matching(ref_out, repo, name, id, force, NULL, log_message); } int git_reference_symbolic_create_matching( git_reference **ref_out, git_repository *repo, const char *name, const char *target, int force, const char *old_target, const char *log_message) { int error; git_signature *who = NULL; assert(target); if ((error = git_reference__log_signature(&who, repo)) < 0) return error; error = reference__create( ref_out, repo, name, NULL, target, force, who, log_message, NULL, old_target); git_signature_free(who); return error; } int git_reference_symbolic_create( git_reference **ref_out, git_repository *repo, const char *name, const char *target, int force, const char *log_message) { return git_reference_symbolic_create_matching(ref_out, repo, name, target, force, NULL, log_message); } static int ensure_is_an_updatable_direct_reference(git_reference *ref) { if (ref->type == GIT_REF_OID) return 0; giterr_set(GITERR_REFERENCE, "Cannot set OID on symbolic reference"); return -1; } int git_reference_set_target( git_reference **out, git_reference *ref, const git_oid *id, const char *log_message) { int error; git_repository *repo; assert(out && ref && id); repo = ref->db->repo; if ((error = ensure_is_an_updatable_direct_reference(ref)) < 0) return error; return git_reference_create_matching(out, repo, ref->name, id, 1, &ref->target.oid, log_message); } static int ensure_is_an_updatable_symbolic_reference(git_reference *ref) { if (ref->type == GIT_REF_SYMBOLIC) return 0; giterr_set(GITERR_REFERENCE, "Cannot set symbolic target on a direct reference"); return -1; } int git_reference_symbolic_set_target( git_reference **out, git_reference *ref, const char *target, const char *log_message) { int error; assert(out && ref && target); if ((error = ensure_is_an_updatable_symbolic_reference(ref)) < 0) return error; return git_reference_symbolic_create_matching( out, ref->db->repo, ref->name, target, 1, ref->target.symbolic, log_message); } static int reference__rename(git_reference **out, git_reference *ref, const char *new_name, int force, const git_signature *signature, const char *message) { git_refname_t normalized; bool should_head_be_updated = false; int error = 0; assert(ref && new_name && signature); if ((error = reference_normalize_for_repo( normalized, git_reference_owner(ref), new_name)) < 0) return error; /* Check if we have to update HEAD. */ if ((error = git_branch_is_head(ref)) < 0) return error; should_head_be_updated = (error > 0); if ((error = git_refdb_rename(out, ref->db, ref->name, normalized, force, signature, message)) < 0) return error; /* Update HEAD it was pointing to the reference being renamed */ if (should_head_be_updated && (error = git_repository_set_head(ref->db->repo, normalized)) < 0) { giterr_set(GITERR_REFERENCE, "Failed to update HEAD after renaming reference"); return error; } return 0; } int git_reference_rename( git_reference **out, git_reference *ref, const char *new_name, int force, const char *log_message) { git_signature *who; int error; if ((error = git_reference__log_signature(&who, ref->db->repo)) < 0) return error; error = reference__rename(out, ref, new_name, force, who, log_message); git_signature_free(who); return error; } int git_reference_resolve(git_reference **ref_out, const git_reference *ref) { switch (git_reference_type(ref)) { case GIT_REF_OID: return git_reference_lookup(ref_out, ref->db->repo, ref->name); case GIT_REF_SYMBOLIC: return git_reference_lookup_resolved(ref_out, ref->db->repo, ref->target.symbolic, -1); default: giterr_set(GITERR_REFERENCE, "Invalid reference"); return -1; } } int git_reference_foreach( git_repository *repo, git_reference_foreach_cb callback, void *payload) { git_reference_iterator *iter; git_reference *ref; int error; if ((error = git_reference_iterator_new(&iter, repo)) < 0) return error; while (!(error = git_reference_next(&ref, iter))) { if ((error = callback(ref, payload)) != 0) { giterr_set_after_callback(error); break; } } if (error == GIT_ITEROVER) error = 0; git_reference_iterator_free(iter); return error; } int git_reference_foreach_name( git_repository *repo, git_reference_foreach_name_cb callback, void *payload) { git_reference_iterator *iter; const char *refname; int error; if ((error = git_reference_iterator_new(&iter, repo)) < 0) return error; while (!(error = git_reference_next_name(&refname, iter))) { if ((error = callback(refname, payload)) != 0) { giterr_set_after_callback(error); break; } } if (error == GIT_ITEROVER) error = 0; git_reference_iterator_free(iter); return error; } int git_reference_foreach_glob( git_repository *repo, const char *glob, git_reference_foreach_name_cb callback, void *payload) { git_reference_iterator *iter; const char *refname; int error; if ((error = git_reference_iterator_glob_new(&iter, repo, glob)) < 0) return error; while (!(error = git_reference_next_name(&refname, iter))) { if ((error = callback(refname, payload)) != 0) { giterr_set_after_callback(error); break; } } if (error == GIT_ITEROVER) error = 0; git_reference_iterator_free(iter); return error; } int git_reference_iterator_new(git_reference_iterator **out, git_repository *repo) { git_refdb *refdb; if (git_repository_refdb__weakptr(&refdb, repo) < 0) return -1; return git_refdb_iterator(out, refdb, NULL); } int git_reference_iterator_glob_new( git_reference_iterator **out, git_repository *repo, const char *glob) { git_refdb *refdb; if (git_repository_refdb__weakptr(&refdb, repo) < 0) return -1; return git_refdb_iterator(out, refdb, glob); } int git_reference_next(git_reference **out, git_reference_iterator *iter) { return git_refdb_iterator_next(out, iter); } int git_reference_next_name(const char **out, git_reference_iterator *iter) { return git_refdb_iterator_next_name(out, iter); } void git_reference_iterator_free(git_reference_iterator *iter) { if (iter == NULL) return; git_refdb_iterator_free(iter); } static int cb__reflist_add(const char *ref, void *data) { char *name = git__strdup(ref); GITERR_CHECK_ALLOC(name); return git_vector_insert((git_vector *)data, name); } int git_reference_list( git_strarray *array, git_repository *repo) { git_vector ref_list; assert(array && repo); array->strings = NULL; array->count = 0; if (git_vector_init(&ref_list, 8, NULL) < 0) return -1; if (git_reference_foreach_name( repo, &cb__reflist_add, (void *)&ref_list) < 0) { git_vector_free(&ref_list); return -1; } array->strings = (char **)git_vector_detach(&array->count, NULL, &ref_list); return 0; } static int is_valid_ref_char(char ch) { if ((unsigned) ch <= ' ') return 0; switch (ch) { case '~': case '^': case ':': case '\\': case '?': case '[': case '*': return 0; default: return 1; } } static int ensure_segment_validity(const char *name) { const char *current = name; char prev = '\0'; const int lock_len = (int)strlen(GIT_FILELOCK_EXTENSION); int segment_len; if (*current == '.') return -1; /* Refname starts with "." */ for (current = name; ; current++) { if (*current == '\0' || *current == '/') break; if (!is_valid_ref_char(*current)) return -1; /* Illegal character in refname */ if (prev == '.' && *current == '.') return -1; /* Refname contains ".." */ if (prev == '@' && *current == '{') return -1; /* Refname contains "@{" */ prev = *current; } segment_len = (int)(current - name); /* A refname component can not end with ".lock" */ if (segment_len >= lock_len && !memcmp(current - lock_len, GIT_FILELOCK_EXTENSION, lock_len)) return -1; return segment_len; } static bool is_all_caps_and_underscore(const char *name, size_t len) { size_t i; char c; assert(name && len > 0); for (i = 0; i < len; i++) { c = name[i]; if ((c < 'A' || c > 'Z') && c != '_') return false; } if (*name == '_' || name[len - 1] == '_') return false; return true; } /* Inspired from https://github.com/git/git/blob/f06d47e7e0d9db709ee204ed13a8a7486149f494/refs.c#L36-100 */ int git_reference__normalize_name( git_buf *buf, const char *name, unsigned int flags) { const char *current; int segment_len, segments_count = 0, error = GIT_EINVALIDSPEC; unsigned int process_flags; bool normalize = (buf != NULL); #ifdef GIT_USE_ICONV git_path_iconv_t ic = GIT_PATH_ICONV_INIT; #endif assert(name); process_flags = flags; current = (char *)name; if (*current == '/') goto cleanup; if (normalize) git_buf_clear(buf); #ifdef GIT_USE_ICONV if ((flags & GIT_REF_FORMAT__PRECOMPOSE_UNICODE) != 0) { size_t namelen = strlen(current); if ((error = git_path_iconv_init_precompose(&ic)) < 0 || (error = git_path_iconv(&ic, ¤t, &namelen)) < 0) goto cleanup; error = GIT_EINVALIDSPEC; } #endif while (true) { segment_len = ensure_segment_validity(current); if (segment_len < 0) { if ((process_flags & GIT_REF_FORMAT_REFSPEC_PATTERN) && current[0] == '*' && (current[1] == '\0' || current[1] == '/')) { /* Accept one wildcard as a full refname component. */ process_flags &= ~GIT_REF_FORMAT_REFSPEC_PATTERN; segment_len = 1; } else goto cleanup; } if (segment_len > 0) { if (normalize) { size_t cur_len = git_buf_len(buf); git_buf_joinpath(buf, git_buf_cstr(buf), current); git_buf_truncate(buf, cur_len + segment_len + (segments_count ? 1 : 0)); if (git_buf_oom(buf)) { error = -1; goto cleanup; } } segments_count++; } /* No empty segment is allowed when not normalizing */ if (segment_len == 0 && !normalize) goto cleanup; if (current[segment_len] == '\0') break; current += segment_len + 1; } /* A refname can not be empty */ if (segment_len == 0 && segments_count == 0) goto cleanup; /* A refname can not end with "." */ if (current[segment_len - 1] == '.') goto cleanup; /* A refname can not end with "/" */ if (current[segment_len - 1] == '/') goto cleanup; if ((segments_count == 1 ) && !(flags & GIT_REF_FORMAT_ALLOW_ONELEVEL)) goto cleanup; if ((segments_count == 1 ) && !(flags & GIT_REF_FORMAT_REFSPEC_SHORTHAND) && !(is_all_caps_and_underscore(name, (size_t)segment_len) || ((flags & GIT_REF_FORMAT_REFSPEC_PATTERN) && !strcmp("*", name)))) goto cleanup; if ((segments_count > 1) && (is_all_caps_and_underscore(name, strchr(name, '/') - name))) goto cleanup; error = 0; cleanup: if (error == GIT_EINVALIDSPEC) giterr_set( GITERR_REFERENCE, "The given reference name '%s' is not valid", name); if (error && normalize) git_buf_free(buf); #ifdef GIT_USE_ICONV git_path_iconv_clear(&ic); #endif return error; } int git_reference_normalize_name( char *buffer_out, size_t buffer_size, const char *name, unsigned int flags) { git_buf buf = GIT_BUF_INIT; int error; if ((error = git_reference__normalize_name(&buf, name, flags)) < 0) goto cleanup; if (git_buf_len(&buf) > buffer_size - 1) { giterr_set( GITERR_REFERENCE, "The provided buffer is too short to hold the normalization of '%s'", name); error = GIT_EBUFS; goto cleanup; } git_buf_copy_cstr(buffer_out, buffer_size, &buf); error = 0; cleanup: git_buf_free(&buf); return error; } #define GIT_REF_TYPEMASK (GIT_REF_OID | GIT_REF_SYMBOLIC) int git_reference_cmp( const git_reference *ref1, const git_reference *ref2) { git_ref_t type1, type2; assert(ref1 && ref2); type1 = git_reference_type(ref1); type2 = git_reference_type(ref2); /* let's put symbolic refs before OIDs */ if (type1 != type2) return (type1 == GIT_REF_SYMBOLIC) ? -1 : 1; if (type1 == GIT_REF_SYMBOLIC) return strcmp(ref1->target.symbolic, ref2->target.symbolic); return git_oid__cmp(&ref1->target.oid, &ref2->target.oid); } /** * Get the end of a chain of references. If the final one is not * found, we return the reference just before that. */ static int get_terminal(git_reference **out, git_repository *repo, const char *ref_name, int nesting) { git_reference *ref; int error = 0; if (nesting > MAX_NESTING_LEVEL) { giterr_set(GITERR_REFERENCE, "Reference chain too deep (%d)", nesting); return GIT_ENOTFOUND; } /* set to NULL to let the caller know that they're at the end of the chain */ if ((error = git_reference_lookup(&ref, repo, ref_name)) < 0) { *out = NULL; return error; } if (git_reference_type(ref) == GIT_REF_OID) { *out = ref; error = 0; } else { error = get_terminal(out, repo, git_reference_symbolic_target(ref), nesting + 1); if (error == GIT_ENOTFOUND && !*out) *out = ref; else git_reference_free(ref); } return error; } /* * Starting with the reference given by `ref_name`, follows symbolic * references until a direct reference is found and updated the OID * on that direct reference to `oid`. */ int git_reference__update_terminal( git_repository *repo, const char *ref_name, const git_oid *oid, const git_signature *sig, const char *log_message) { git_reference *ref = NULL, *ref2 = NULL; git_signature *who = NULL; const git_signature *to_use; int error = 0; if (!sig && (error = git_reference__log_signature(&who, repo)) < 0) return error; to_use = sig ? sig : who; error = get_terminal(&ref, repo, ref_name, 0); /* found a dangling symref */ if (error == GIT_ENOTFOUND && ref) { assert(git_reference_type(ref) == GIT_REF_SYMBOLIC); giterr_clear(); error = reference__create(&ref2, repo, ref->target.symbolic, oid, NULL, 0, to_use, log_message, NULL, NULL); } else if (error == GIT_ENOTFOUND) { giterr_clear(); error = reference__create(&ref2, repo, ref_name, oid, NULL, 0, to_use, log_message, NULL, NULL); } else if (error == 0) { assert(git_reference_type(ref) == GIT_REF_OID); error = reference__create(&ref2, repo, ref->name, oid, NULL, 1, to_use, log_message, &ref->target.oid, NULL); } git_reference_free(ref2); git_reference_free(ref); git_signature_free(who); return error; } int git_reference__update_for_commit( git_repository *repo, git_reference *ref, const char *ref_name, const git_oid *id, const char *operation) { git_reference *ref_new = NULL; git_commit *commit = NULL; git_buf reflog_msg = GIT_BUF_INIT; const git_signature *who; int error; if ((error = git_commit_lookup(&commit, repo, id)) < 0 || (error = git_buf_printf(&reflog_msg, "%s%s: %s", operation ? operation : "commit", git_commit_parentcount(commit) == 0 ? " (initial)" : "", git_commit_summary(commit))) < 0) goto done; who = git_commit_committer(commit); if (ref) { if ((error = ensure_is_an_updatable_direct_reference(ref)) < 0) return error; error = reference__create(&ref_new, repo, ref->name, id, NULL, 1, who, git_buf_cstr(&reflog_msg), &ref->target.oid, NULL); } else error = git_reference__update_terminal( repo, ref_name, id, who, git_buf_cstr(&reflog_msg)); done: git_reference_free(ref_new); git_buf_free(&reflog_msg); git_commit_free(commit); return error; } int git_reference_has_log(git_repository *repo, const char *refname) { int error; git_refdb *refdb; assert(repo && refname); if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0) return error; return git_refdb_has_log(refdb, refname); } int git_reference_ensure_log(git_repository *repo, const char *refname) { int error; git_refdb *refdb; assert(repo && refname); if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0) return error; return git_refdb_ensure_log(refdb, refname); } int git_reference__is_branch(const char *ref_name) { return git__prefixcmp(ref_name, GIT_REFS_HEADS_DIR) == 0; } int git_reference_is_branch(const git_reference *ref) { assert(ref); return git_reference__is_branch(ref->name); } int git_reference__is_remote(const char *ref_name) { return git__prefixcmp(ref_name, GIT_REFS_REMOTES_DIR) == 0; } int git_reference_is_remote(const git_reference *ref) { assert(ref); return git_reference__is_remote(ref->name); } int git_reference__is_tag(const char *ref_name) { return git__prefixcmp(ref_name, GIT_REFS_TAGS_DIR) == 0; } int git_reference_is_tag(const git_reference *ref) { assert(ref); return git_reference__is_tag(ref->name); } int git_reference__is_note(const char *ref_name) { return git__prefixcmp(ref_name, GIT_REFS_NOTES_DIR) == 0; } int git_reference_is_note(const git_reference *ref) { assert(ref); return git_reference__is_note(ref->name); } static int peel_error(int error, git_reference *ref, const char* msg) { giterr_set( GITERR_INVALID, "The reference '%s' cannot be peeled - %s", git_reference_name(ref), msg); return error; } int git_reference_peel( git_object **peeled, git_reference *ref, git_otype target_type) { git_reference *resolved = NULL; git_object *target = NULL; int error; assert(ref); if (ref->type == GIT_REF_OID) { resolved = ref; } else { if ((error = git_reference_resolve(&resolved, ref)) < 0) return peel_error(error, ref, "Cannot resolve reference"); } if (!git_oid_iszero(&resolved->peel)) { error = git_object_lookup(&target, git_reference_owner(ref), &resolved->peel, GIT_OBJ_ANY); } else { error = git_object_lookup(&target, git_reference_owner(ref), &resolved->target.oid, GIT_OBJ_ANY); } if (error < 0) { peel_error(error, ref, "Cannot retrieve reference target"); goto cleanup; } if (target_type == GIT_OBJ_ANY && git_object_type(target) != GIT_OBJ_TAG) error = git_object_dup(peeled, target); else error = git_object_peel(peeled, target, target_type); cleanup: git_object_free(target); if (resolved != ref) git_reference_free(resolved); return error; } int git_reference__is_valid_name(const char *refname, unsigned int flags) { if (git_reference__normalize_name(NULL, refname, flags) < 0) { giterr_clear(); return false; } return true; } int git_reference_is_valid_name(const char *refname) { return git_reference__is_valid_name(refname, GIT_REF_FORMAT_ALLOW_ONELEVEL); } const char *git_reference__shorthand(const char *name) { if (!git__prefixcmp(name, GIT_REFS_HEADS_DIR)) return name + strlen(GIT_REFS_HEADS_DIR); else if (!git__prefixcmp(name, GIT_REFS_TAGS_DIR)) return name + strlen(GIT_REFS_TAGS_DIR); else if (!git__prefixcmp(name, GIT_REFS_REMOTES_DIR)) return name + strlen(GIT_REFS_REMOTES_DIR); else if (!git__prefixcmp(name, GIT_REFS_DIR)) return name + strlen(GIT_REFS_DIR); /* No shorthands are avaiable, so just return the name */ return name; } const char *git_reference_shorthand(const git_reference *ref) { return git_reference__shorthand(ref->name); } deps/libgit2-sys-0.3.8/libgit2/src/branch.h0000664000175000017500000000063712426525445015317 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_branch_h__ #define INCLUDE_branch_h__ #include "buffer.h" int git_branch_upstream__name( git_buf *tracking_name, git_repository *repo, const char *canonical_branch_name); #endif deps/libgit2-sys-0.3.8/libgit2/src/hash/0000755000000000000000000000000012666635520016404 5ustar rootrootdeps/libgit2-sys-0.3.8/libgit2/src/hash/hash_win32.h0000664000175000017500000000650212426525445016747 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_hash_win32_h__ #define INCLUDE_hash_win32_h__ #include "common.h" #include "hash.h" #include #include enum hash_win32_prov_type { INVALID = 0, CRYPTOAPI, CNG }; /* * CryptoAPI is available for hashing on Windows XP and newer. */ struct hash_cryptoapi_prov { HCRYPTPROV handle; }; /* * CNG (bcrypt.dll) is significantly more performant than CryptoAPI and is * preferred, however it is only available on Windows 2008 and newer and * must therefore be dynamically loaded, and we must inline constants that * would not exist when building in pre-Windows 2008 environments. */ #define GIT_HASH_CNG_DLL_NAME "bcrypt.dll" /* BCRYPT_SHA1_ALGORITHM */ #define GIT_HASH_CNG_HASH_TYPE L"SHA1" /* BCRYPT_OBJECT_LENGTH */ #define GIT_HASH_CNG_HASH_OBJECT_LEN L"ObjectLength" /* BCRYPT_HASH_REUSEABLE_FLAGS */ #define GIT_HASH_CNG_HASH_REUSABLE 0x00000020 /* Function declarations for CNG */ typedef NTSTATUS (WINAPI *hash_win32_cng_open_algorithm_provider_fn)( HANDLE /* BCRYPT_ALG_HANDLE */ *phAlgorithm, LPCWSTR pszAlgId, LPCWSTR pszImplementation, DWORD dwFlags); typedef NTSTATUS (WINAPI *hash_win32_cng_get_property_fn)( HANDLE /* BCRYPT_HANDLE */ hObject, LPCWSTR pszProperty, PUCHAR pbOutput, ULONG cbOutput, ULONG *pcbResult, ULONG dwFlags); typedef NTSTATUS (WINAPI *hash_win32_cng_create_hash_fn)( HANDLE /* BCRYPT_ALG_HANDLE */ hAlgorithm, HANDLE /* BCRYPT_HASH_HANDLE */ *phHash, PUCHAR pbHashObject, ULONG cbHashObject, PUCHAR pbSecret, ULONG cbSecret, ULONG dwFlags); typedef NTSTATUS (WINAPI *hash_win32_cng_finish_hash_fn)( HANDLE /* BCRYPT_HASH_HANDLE */ hHash, PUCHAR pbOutput, ULONG cbOutput, ULONG dwFlags); typedef NTSTATUS (WINAPI *hash_win32_cng_hash_data_fn)( HANDLE /* BCRYPT_HASH_HANDLE */ hHash, PUCHAR pbInput, ULONG cbInput, ULONG dwFlags); typedef NTSTATUS (WINAPI *hash_win32_cng_destroy_hash_fn)( HANDLE /* BCRYPT_HASH_HANDLE */ hHash); typedef NTSTATUS (WINAPI *hash_win32_cng_close_algorithm_provider_fn)( HANDLE /* BCRYPT_ALG_HANDLE */ hAlgorithm, ULONG dwFlags); struct hash_cng_prov { /* DLL for CNG */ HINSTANCE dll; /* Function pointers for CNG */ hash_win32_cng_open_algorithm_provider_fn open_algorithm_provider; hash_win32_cng_get_property_fn get_property; hash_win32_cng_create_hash_fn create_hash; hash_win32_cng_finish_hash_fn finish_hash; hash_win32_cng_hash_data_fn hash_data; hash_win32_cng_destroy_hash_fn destroy_hash; hash_win32_cng_close_algorithm_provider_fn close_algorithm_provider; HANDLE /* BCRYPT_ALG_HANDLE */ handle; DWORD hash_object_size; }; struct git_hash_prov { enum hash_win32_prov_type type; union { struct hash_cryptoapi_prov cryptoapi; struct hash_cng_prov cng; } prov; }; /* Hash contexts */ struct hash_cryptoapi_ctx { bool valid; HCRYPTHASH hash_handle; }; struct hash_cng_ctx { bool updated; HANDLE /* BCRYPT_HASH_HANDLE */ hash_handle; PBYTE hash_object; }; struct git_hash_ctx { enum hash_win32_prov_type type; git_hash_prov *prov; union { struct hash_cryptoapi_ctx cryptoapi; struct hash_cng_ctx cng; } ctx; }; #endif /* INCLUDE_hash_openssl_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/hash/hash_win32.c0000664000175000017500000001674412510265101016733 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "global.h" #include "hash.h" #include "hash/hash_win32.h" #include #include static struct git_hash_prov hash_prov = {0}; /* Hash initialization */ /* Initialize CNG, if available */ GIT_INLINE(int) hash_cng_prov_init(void) { char dll_path[MAX_PATH]; DWORD dll_path_len, size_len; /* Only use CNG on Windows 2008 / Vista SP1 or better (Windows 6.0 SP1) */ if (!git_has_win32_version(6, 0, 1)) return -1; /* Load bcrypt.dll explicitly from the system directory */ if ((dll_path_len = GetSystemDirectory(dll_path, MAX_PATH)) == 0 || dll_path_len > MAX_PATH || StringCchCat(dll_path, MAX_PATH, "\\") < 0 || StringCchCat(dll_path, MAX_PATH, GIT_HASH_CNG_DLL_NAME) < 0 || (hash_prov.prov.cng.dll = LoadLibrary(dll_path)) == NULL) return -1; /* Load the function addresses */ if ((hash_prov.prov.cng.open_algorithm_provider = (hash_win32_cng_open_algorithm_provider_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptOpenAlgorithmProvider")) == NULL || (hash_prov.prov.cng.get_property = (hash_win32_cng_get_property_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptGetProperty")) == NULL || (hash_prov.prov.cng.create_hash = (hash_win32_cng_create_hash_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptCreateHash")) == NULL || (hash_prov.prov.cng.finish_hash = (hash_win32_cng_finish_hash_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptFinishHash")) == NULL || (hash_prov.prov.cng.hash_data = (hash_win32_cng_hash_data_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptHashData")) == NULL || (hash_prov.prov.cng.destroy_hash = (hash_win32_cng_destroy_hash_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptDestroyHash")) == NULL || (hash_prov.prov.cng.close_algorithm_provider = (hash_win32_cng_close_algorithm_provider_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptCloseAlgorithmProvider")) == NULL) { FreeLibrary(hash_prov.prov.cng.dll); return -1; } /* Load the SHA1 algorithm */ if (hash_prov.prov.cng.open_algorithm_provider(&hash_prov.prov.cng.handle, GIT_HASH_CNG_HASH_TYPE, NULL, GIT_HASH_CNG_HASH_REUSABLE) < 0) { FreeLibrary(hash_prov.prov.cng.dll); return -1; } /* Get storage space for the hash object */ if (hash_prov.prov.cng.get_property(hash_prov.prov.cng.handle, GIT_HASH_CNG_HASH_OBJECT_LEN, (PBYTE)&hash_prov.prov.cng.hash_object_size, sizeof(DWORD), &size_len, 0) < 0) { hash_prov.prov.cng.close_algorithm_provider(hash_prov.prov.cng.handle, 0); FreeLibrary(hash_prov.prov.cng.dll); return -1; } hash_prov.type = CNG; return 0; } GIT_INLINE(void) hash_cng_prov_shutdown(void) { hash_prov.prov.cng.close_algorithm_provider(hash_prov.prov.cng.handle, 0); FreeLibrary(hash_prov.prov.cng.dll); hash_prov.type = INVALID; } /* Initialize CryptoAPI */ GIT_INLINE(int) hash_cryptoapi_prov_init() { if (!CryptAcquireContext(&hash_prov.prov.cryptoapi.handle, NULL, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) return -1; hash_prov.type = CRYPTOAPI; return 0; } GIT_INLINE(void) hash_cryptoapi_prov_shutdown(void) { CryptReleaseContext(hash_prov.prov.cryptoapi.handle, 0); hash_prov.type = INVALID; } static void git_hash_global_shutdown(void) { if (hash_prov.type == CNG) hash_cng_prov_shutdown(); else if(hash_prov.type == CRYPTOAPI) hash_cryptoapi_prov_shutdown(); } int git_hash_global_init(void) { int error = 0; if (hash_prov.type != INVALID) return 0; if ((error = hash_cng_prov_init()) < 0) error = hash_cryptoapi_prov_init(); git__on_shutdown(git_hash_global_shutdown); return error; } /* CryptoAPI: available in Windows XP and newer */ GIT_INLINE(int) hash_ctx_cryptoapi_init(git_hash_ctx *ctx) { ctx->type = CRYPTOAPI; ctx->prov = &hash_prov; return git_hash_init(ctx); } GIT_INLINE(int) hash_cryptoapi_init(git_hash_ctx *ctx) { if (ctx->ctx.cryptoapi.valid) CryptDestroyHash(ctx->ctx.cryptoapi.hash_handle); if (!CryptCreateHash(ctx->prov->prov.cryptoapi.handle, CALG_SHA1, 0, 0, &ctx->ctx.cryptoapi.hash_handle)) { ctx->ctx.cryptoapi.valid = 0; return -1; } ctx->ctx.cryptoapi.valid = 1; return 0; } GIT_INLINE(int) hash_cryptoapi_update(git_hash_ctx *ctx, const void *data, size_t len) { assert(ctx->ctx.cryptoapi.valid); if (!CryptHashData(ctx->ctx.cryptoapi.hash_handle, (const BYTE *)data, (DWORD)len, 0)) return -1; return 0; } GIT_INLINE(int) hash_cryptoapi_final(git_oid *out, git_hash_ctx *ctx) { DWORD len = 20; int error = 0; assert(ctx->ctx.cryptoapi.valid); if (!CryptGetHashParam(ctx->ctx.cryptoapi.hash_handle, HP_HASHVAL, out->id, &len, 0)) error = -1; CryptDestroyHash(ctx->ctx.cryptoapi.hash_handle); ctx->ctx.cryptoapi.valid = 0; return error; } GIT_INLINE(void) hash_ctx_cryptoapi_cleanup(git_hash_ctx *ctx) { if (ctx->ctx.cryptoapi.valid) CryptDestroyHash(ctx->ctx.cryptoapi.hash_handle); } /* CNG: Available in Windows Server 2008 and newer */ GIT_INLINE(int) hash_ctx_cng_init(git_hash_ctx *ctx) { if ((ctx->ctx.cng.hash_object = git__malloc(hash_prov.prov.cng.hash_object_size)) == NULL) return -1; if (hash_prov.prov.cng.create_hash(hash_prov.prov.cng.handle, &ctx->ctx.cng.hash_handle, ctx->ctx.cng.hash_object, hash_prov.prov.cng.hash_object_size, NULL, 0, 0) < 0) { git__free(ctx->ctx.cng.hash_object); return -1; } ctx->type = CNG; ctx->prov = &hash_prov; return 0; } GIT_INLINE(int) hash_cng_init(git_hash_ctx *ctx) { BYTE hash[GIT_OID_RAWSZ]; if (!ctx->ctx.cng.updated) return 0; /* CNG needs to be finished to restart */ if (ctx->prov->prov.cng.finish_hash(ctx->ctx.cng.hash_handle, hash, GIT_OID_RAWSZ, 0) < 0) return -1; ctx->ctx.cng.updated = 0; return 0; } GIT_INLINE(int) hash_cng_update(git_hash_ctx *ctx, const void *data, size_t len) { if (ctx->prov->prov.cng.hash_data(ctx->ctx.cng.hash_handle, (PBYTE)data, (ULONG)len, 0) < 0) return -1; return 0; } GIT_INLINE(int) hash_cng_final(git_oid *out, git_hash_ctx *ctx) { if (ctx->prov->prov.cng.finish_hash(ctx->ctx.cng.hash_handle, out->id, GIT_OID_RAWSZ, 0) < 0) return -1; ctx->ctx.cng.updated = 0; return 0; } GIT_INLINE(void) hash_ctx_cng_cleanup(git_hash_ctx *ctx) { ctx->prov->prov.cng.destroy_hash(ctx->ctx.cng.hash_handle); git__free(ctx->ctx.cng.hash_object); } /* Indirection between CryptoAPI and CNG */ int git_hash_ctx_init(git_hash_ctx *ctx) { int error = 0; assert(ctx); /* * When compiled with GIT_THREADS, the global hash_prov data is * initialized with git_libgit2_init. Otherwise, it must be initialized * at first use. */ if (hash_prov.type == INVALID && (error = git_hash_global_init()) < 0) return error; memset(ctx, 0x0, sizeof(git_hash_ctx)); return (hash_prov.type == CNG) ? hash_ctx_cng_init(ctx) : hash_ctx_cryptoapi_init(ctx); } int git_hash_init(git_hash_ctx *ctx) { assert(ctx && ctx->type); return (ctx->type == CNG) ? hash_cng_init(ctx) : hash_cryptoapi_init(ctx); } int git_hash_update(git_hash_ctx *ctx, const void *data, size_t len) { assert(ctx && ctx->type); return (ctx->type == CNG) ? hash_cng_update(ctx, data, len) : hash_cryptoapi_update(ctx, data, len); } int git_hash_final(git_oid *out, git_hash_ctx *ctx) { assert(ctx && ctx->type); return (ctx->type == CNG) ? hash_cng_final(out, ctx) : hash_cryptoapi_final(out, ctx); } void git_hash_ctx_cleanup(git_hash_ctx *ctx) { assert(ctx); if (ctx->type == CNG) hash_ctx_cng_cleanup(ctx); else if(ctx->type == CRYPTOAPI) hash_ctx_cryptoapi_cleanup(ctx); } deps/libgit2-sys-0.3.8/libgit2/src/hash/hash_generic.c0000664000175000017500000002052612510265101017376 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "hash.h" #include "hash/hash_generic.h" #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) /* * Force usage of rol or ror by selecting the one with the smaller constant. * It _can_ generate slightly smaller code (a constant of 1 is special), but * perhaps more importantly it's possibly faster on any uarch that does a * rotate with a loop. */ #define SHA_ASM(op, x, n) (__extension__ ({ unsigned int __res; __asm__(op " %1,%0":"=r" (__res):"i" (n), "0" (x)); __res; })) #define SHA_ROL(x,n) SHA_ASM("rol", x, n) #define SHA_ROR(x,n) SHA_ASM("ror", x, n) #else #define SHA_ROT(X,l,r) (((X) << (l)) | ((X) >> (r))) #define SHA_ROL(X,n) SHA_ROT(X,n,32-(n)) #define SHA_ROR(X,n) SHA_ROT(X,32-(n),n) #endif /* * If you have 32 registers or more, the compiler can (and should) * try to change the array[] accesses into registers. However, on * machines with less than ~25 registers, that won't really work, * and at least gcc will make an unholy mess of it. * * So to avoid that mess which just slows things down, we force * the stores to memory to actually happen (we might be better off * with a 'W(t)=(val);asm("":"+m" (W(t))' there instead, as * suggested by Artur Skawina - that will also make gcc unable to * try to do the silly "optimize away loads" part because it won't * see what the value will be). * * Ben Herrenschmidt reports that on PPC, the C version comes close * to the optimized asm with this (ie on PPC you don't want that * 'volatile', since there are lots of registers). * * On ARM we get the best code generation by forcing a full memory barrier * between each SHA_ROUND, otherwise gcc happily get wild with spilling and * the stack frame size simply explode and performance goes down the drain. */ #if defined(__i386__) || defined(__x86_64__) #define setW(x, val) (*(volatile unsigned int *)&W(x) = (val)) #elif defined(__GNUC__) && defined(__arm__) #define setW(x, val) do { W(x) = (val); __asm__("":::"memory"); } while (0) #else #define setW(x, val) (W(x) = (val)) #endif /* * Performance might be improved if the CPU architecture is OK with * unaligned 32-bit loads and a fast ntohl() is available. * Otherwise fall back to byte loads and shifts which is portable, * and is faster on architectures with memory alignment issues. */ #if defined(__i386__) || defined(__x86_64__) || \ defined(_M_IX86) || defined(_M_X64) || \ defined(__ppc__) || defined(__ppc64__) || \ defined(__powerpc__) || defined(__powerpc64__) || \ defined(__s390__) || defined(__s390x__) #define get_be32(p) ntohl(*(const unsigned int *)(p)) #define put_be32(p, v) do { *(unsigned int *)(p) = htonl(v); } while (0) #else #define get_be32(p) ( \ (*((const unsigned char *)(p) + 0) << 24) | \ (*((const unsigned char *)(p) + 1) << 16) | \ (*((const unsigned char *)(p) + 2) << 8) | \ (*((const unsigned char *)(p) + 3) << 0) ) #define put_be32(p, v) do { \ unsigned int __v = (v); \ *((unsigned char *)(p) + 0) = __v >> 24; \ *((unsigned char *)(p) + 1) = __v >> 16; \ *((unsigned char *)(p) + 2) = __v >> 8; \ *((unsigned char *)(p) + 3) = __v >> 0; } while (0) #endif /* This "rolls" over the 512-bit array */ #define W(x) (array[(x)&15]) /* * Where do we get the source from? The first 16 iterations get it from * the input data, the next mix it from the 512-bit array. */ #define SHA_SRC(t) get_be32(data + t) #define SHA_MIX(t) SHA_ROL(W(t+13) ^ W(t+8) ^ W(t+2) ^ W(t), 1) #define SHA_ROUND(t, input, fn, constant, A, B, C, D, E) do { \ unsigned int TEMP = input(t); setW(t, TEMP); \ E += TEMP + SHA_ROL(A,5) + (fn) + (constant); \ B = SHA_ROR(B, 2); } while (0) #define T_0_15(t, A, B, C, D, E) SHA_ROUND(t, SHA_SRC, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E ) #define T_16_19(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E ) #define T_20_39(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (B^C^D) , 0x6ed9eba1, A, B, C, D, E ) #define T_40_59(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, ((B&C)+(D&(B^C))) , 0x8f1bbcdc, A, B, C, D, E ) #define T_60_79(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (B^C^D) , 0xca62c1d6, A, B, C, D, E ) static void hash__block(git_hash_ctx *ctx, const unsigned int *data) { unsigned int A,B,C,D,E; unsigned int array[16]; A = ctx->H[0]; B = ctx->H[1]; C = ctx->H[2]; D = ctx->H[3]; E = ctx->H[4]; /* Round 1 - iterations 0-16 take their input from 'data' */ T_0_15( 0, A, B, C, D, E); T_0_15( 1, E, A, B, C, D); T_0_15( 2, D, E, A, B, C); T_0_15( 3, C, D, E, A, B); T_0_15( 4, B, C, D, E, A); T_0_15( 5, A, B, C, D, E); T_0_15( 6, E, A, B, C, D); T_0_15( 7, D, E, A, B, C); T_0_15( 8, C, D, E, A, B); T_0_15( 9, B, C, D, E, A); T_0_15(10, A, B, C, D, E); T_0_15(11, E, A, B, C, D); T_0_15(12, D, E, A, B, C); T_0_15(13, C, D, E, A, B); T_0_15(14, B, C, D, E, A); T_0_15(15, A, B, C, D, E); /* Round 1 - tail. Input from 512-bit mixing array */ T_16_19(16, E, A, B, C, D); T_16_19(17, D, E, A, B, C); T_16_19(18, C, D, E, A, B); T_16_19(19, B, C, D, E, A); /* Round 2 */ T_20_39(20, A, B, C, D, E); T_20_39(21, E, A, B, C, D); T_20_39(22, D, E, A, B, C); T_20_39(23, C, D, E, A, B); T_20_39(24, B, C, D, E, A); T_20_39(25, A, B, C, D, E); T_20_39(26, E, A, B, C, D); T_20_39(27, D, E, A, B, C); T_20_39(28, C, D, E, A, B); T_20_39(29, B, C, D, E, A); T_20_39(30, A, B, C, D, E); T_20_39(31, E, A, B, C, D); T_20_39(32, D, E, A, B, C); T_20_39(33, C, D, E, A, B); T_20_39(34, B, C, D, E, A); T_20_39(35, A, B, C, D, E); T_20_39(36, E, A, B, C, D); T_20_39(37, D, E, A, B, C); T_20_39(38, C, D, E, A, B); T_20_39(39, B, C, D, E, A); /* Round 3 */ T_40_59(40, A, B, C, D, E); T_40_59(41, E, A, B, C, D); T_40_59(42, D, E, A, B, C); T_40_59(43, C, D, E, A, B); T_40_59(44, B, C, D, E, A); T_40_59(45, A, B, C, D, E); T_40_59(46, E, A, B, C, D); T_40_59(47, D, E, A, B, C); T_40_59(48, C, D, E, A, B); T_40_59(49, B, C, D, E, A); T_40_59(50, A, B, C, D, E); T_40_59(51, E, A, B, C, D); T_40_59(52, D, E, A, B, C); T_40_59(53, C, D, E, A, B); T_40_59(54, B, C, D, E, A); T_40_59(55, A, B, C, D, E); T_40_59(56, E, A, B, C, D); T_40_59(57, D, E, A, B, C); T_40_59(58, C, D, E, A, B); T_40_59(59, B, C, D, E, A); /* Round 4 */ T_60_79(60, A, B, C, D, E); T_60_79(61, E, A, B, C, D); T_60_79(62, D, E, A, B, C); T_60_79(63, C, D, E, A, B); T_60_79(64, B, C, D, E, A); T_60_79(65, A, B, C, D, E); T_60_79(66, E, A, B, C, D); T_60_79(67, D, E, A, B, C); T_60_79(68, C, D, E, A, B); T_60_79(69, B, C, D, E, A); T_60_79(70, A, B, C, D, E); T_60_79(71, E, A, B, C, D); T_60_79(72, D, E, A, B, C); T_60_79(73, C, D, E, A, B); T_60_79(74, B, C, D, E, A); T_60_79(75, A, B, C, D, E); T_60_79(76, E, A, B, C, D); T_60_79(77, D, E, A, B, C); T_60_79(78, C, D, E, A, B); T_60_79(79, B, C, D, E, A); ctx->H[0] += A; ctx->H[1] += B; ctx->H[2] += C; ctx->H[3] += D; ctx->H[4] += E; } int git_hash_init(git_hash_ctx *ctx) { ctx->size = 0; /* Initialize H with the magic constants (see FIPS180 for constants) */ ctx->H[0] = 0x67452301; ctx->H[1] = 0xefcdab89; ctx->H[2] = 0x98badcfe; ctx->H[3] = 0x10325476; ctx->H[4] = 0xc3d2e1f0; return 0; } int git_hash_update(git_hash_ctx *ctx, const void *data, size_t len) { unsigned int lenW = ctx->size & 63; ctx->size += len; /* Read the data into W and process blocks as they get full */ if (lenW) { unsigned int left = 64 - lenW; if (len < left) left = (unsigned int)len; memcpy(lenW + (char *)ctx->W, data, left); lenW = (lenW + left) & 63; len -= left; data = ((const char *)data + left); if (lenW) return 0; hash__block(ctx, ctx->W); } while (len >= 64) { hash__block(ctx, data); data = ((const char *)data + 64); len -= 64; } if (len) memcpy(ctx->W, data, len); return 0; } int git_hash_final(git_oid *out, git_hash_ctx *ctx) { static const unsigned char pad[64] = { 0x80 }; unsigned int padlen[2]; int i; /* Pad with a binary 1 (ie 0x80), then zeroes, then length */ padlen[0] = htonl((uint32_t)(ctx->size >> 29)); padlen[1] = htonl((uint32_t)(ctx->size << 3)); i = ctx->size & 63; git_hash_update(ctx, pad, 1+ (63 & (55 - i))); git_hash_update(ctx, padlen, 8); /* Output hash */ for (i = 0; i < 5; i++) put_be32(out->id + i*4, ctx->H[i]); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/hash/hash_common_crypto.h0000664000175000017500000000165112510265101020655 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_hash_common_crypto_h__ #define INCLUDE_hash_common_crypto_h__ #include "hash.h" #include struct git_hash_ctx { CC_SHA1_CTX c; }; #define git_hash_global_init() 0 #define git_hash_ctx_init(ctx) git_hash_init(ctx) #define git_hash_ctx_cleanup(ctx) GIT_INLINE(int) git_hash_init(git_hash_ctx *ctx) { assert(ctx); CC_SHA1_Init(&ctx->c); return 0; } GIT_INLINE(int) git_hash_update(git_hash_ctx *ctx, const void *data, size_t len) { assert(ctx); CC_SHA1_Update(&ctx->c, data, len); return 0; } GIT_INLINE(int) git_hash_final(git_oid *out, git_hash_ctx *ctx) { assert(ctx); CC_SHA1_Final(out->id, &ctx->c); return 0; } #endif /* INCLUDE_hash_common_crypto_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/hash/hash_generic.h0000664000175000017500000000104712426525445017420 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_hash_generic_h__ #define INCLUDE_hash_generic_h__ #include "hash.h" struct git_hash_ctx { unsigned long long size; unsigned int H[5]; unsigned int W[16]; }; #define git_hash_global_init() 0 #define git_hash_ctx_init(ctx) git_hash_init(ctx) #define git_hash_ctx_cleanup(ctx) #endif /* INCLUDE_hash_generic_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/hash/hash_openssl.h0000664000175000017500000000157412426525445017474 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_hash_openssl_h__ #define INCLUDE_hash_openssl_h__ #include "hash.h" #include struct git_hash_ctx { SHA_CTX c; }; #define git_hash_global_init() 0 #define git_hash_ctx_init(ctx) git_hash_init(ctx) #define git_hash_ctx_cleanup(ctx) GIT_INLINE(int) git_hash_init(git_hash_ctx *ctx) { assert(ctx); SHA1_Init(&ctx->c); return 0; } GIT_INLINE(int) git_hash_update(git_hash_ctx *ctx, const void *data, size_t len) { assert(ctx); SHA1_Update(&ctx->c, data, len); return 0; } GIT_INLINE(int) git_hash_final(git_oid *out, git_hash_ctx *ctx) { assert(ctx); SHA1_Final(out->id, &ctx->c); return 0; } #endif /* INCLUDE_hash_openssl_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/diff_driver.h0000664000175000017500000000276412426525445016350 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_diff_driver_h__ #define INCLUDE_diff_driver_h__ #include "common.h" #include "buffer.h" typedef struct git_diff_driver_registry git_diff_driver_registry; git_diff_driver_registry *git_diff_driver_registry_new(void); void git_diff_driver_registry_free(git_diff_driver_registry *); typedef struct git_diff_driver git_diff_driver; int git_diff_driver_lookup(git_diff_driver **, git_repository *, const char *); void git_diff_driver_free(git_diff_driver *); /* diff option flags to force off and on for this driver */ void git_diff_driver_update_options(uint32_t *option_flags, git_diff_driver *); /* returns -1 meaning "unknown", 0 meaning not binary, 1 meaning binary */ int git_diff_driver_content_is_binary( git_diff_driver *, const char *content, size_t content_len); typedef long (*git_diff_find_context_fn)( const char *, long, char *, long, void *); typedef int (*git_diff_find_context_line)( git_diff_driver *, git_buf *); typedef struct { git_diff_driver *driver; git_diff_find_context_line match_line; git_buf line; } git_diff_find_context_payload; void git_diff_find_context_init( git_diff_find_context_fn *findfn_out, git_diff_find_context_payload *payload_out, git_diff_driver *driver); void git_diff_find_context_clear(git_diff_find_context_payload *); #endif deps/libgit2-sys-0.3.8/libgit2/src/oidarray.h0000664000175000017500000000073512510265101015653 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_oidarray_h__ #define INCLUDE_oidarray_h__ #include "common.h" #include "git2/oidarray.h" #include "array.h" typedef git_array_t(git_oid) git_array_oid_t; extern void git_oidarray__from_array(git_oidarray *arr, git_array_oid_t *array); #endif deps/libgit2-sys-0.3.8/libgit2/src/cache.c0000664000175000017500000001442312572105236015110 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "repository.h" #include "commit.h" #include "thread-utils.h" #include "util.h" #include "cache.h" #include "odb.h" #include "object.h" #include "git2/oid.h" GIT__USE_OIDMAP bool git_cache__enabled = true; ssize_t git_cache__max_storage = (256 * 1024 * 1024); git_atomic_ssize git_cache__current_storage = {0}; static size_t git_cache__max_object_size[8] = { 0, /* GIT_OBJ__EXT1 */ 4096, /* GIT_OBJ_COMMIT */ 4096, /* GIT_OBJ_TREE */ 0, /* GIT_OBJ_BLOB */ 4096, /* GIT_OBJ_TAG */ 0, /* GIT_OBJ__EXT2 */ 0, /* GIT_OBJ_OFS_DELTA */ 0 /* GIT_OBJ_REF_DELTA */ }; int git_cache_set_max_object_size(git_otype type, size_t size) { if (type < 0 || (size_t)type >= ARRAY_SIZE(git_cache__max_object_size)) { giterr_set(GITERR_INVALID, "type out of range"); return -1; } git_cache__max_object_size[type] = size; return 0; } void git_cache_dump_stats(git_cache *cache) { git_cached_obj *object; if (kh_size(cache->map) == 0) return; printf("Cache %p: %d items cached, %"PRIdZ" bytes\n", cache, kh_size(cache->map), cache->used_memory); kh_foreach_value(cache->map, object, { char oid_str[9]; printf(" %s%c %s (%"PRIuZ")\n", git_object_type2string(object->type), object->flags == GIT_CACHE_STORE_PARSED ? '*' : ' ', git_oid_tostr(oid_str, sizeof(oid_str), &object->oid), object->size ); }); } int git_cache_init(git_cache *cache) { memset(cache, 0, sizeof(*cache)); cache->map = git_oidmap_alloc(); GITERR_CHECK_ALLOC(cache->map); if (git_rwlock_init(&cache->lock)) { giterr_set(GITERR_OS, "Failed to initialize cache rwlock"); return -1; } return 0; } /* called with lock */ static void clear_cache(git_cache *cache) { git_cached_obj *evict = NULL; if (kh_size(cache->map) == 0) return; kh_foreach_value(cache->map, evict, { git_cached_obj_decref(evict); }); kh_clear(oid, cache->map); git_atomic_ssize_add(&git_cache__current_storage, -cache->used_memory); cache->used_memory = 0; } void git_cache_clear(git_cache *cache) { if (git_rwlock_wrlock(&cache->lock) < 0) return; clear_cache(cache); git_rwlock_wrunlock(&cache->lock); } void git_cache_free(git_cache *cache) { git_cache_clear(cache); git_oidmap_free(cache->map); git_rwlock_free(&cache->lock); git__memzero(cache, sizeof(*cache)); } /* Called with lock */ static void cache_evict_entries(git_cache *cache) { uint32_t seed = rand(); size_t evict_count = 8; ssize_t evicted_memory = 0; /* do not infinite loop if there's not enough entries to evict */ if (evict_count > kh_size(cache->map)) { clear_cache(cache); return; } while (evict_count > 0) { khiter_t pos = seed++ % kh_end(cache->map); if (kh_exist(cache->map, pos)) { git_cached_obj *evict = kh_val(cache->map, pos); evict_count--; evicted_memory += evict->size; git_cached_obj_decref(evict); kh_del(oid, cache->map, pos); } } cache->used_memory -= evicted_memory; git_atomic_ssize_add(&git_cache__current_storage, -evicted_memory); } static bool cache_should_store(git_otype object_type, size_t object_size) { size_t max_size = git_cache__max_object_size[object_type]; return git_cache__enabled && object_size < max_size; } static void *cache_get(git_cache *cache, const git_oid *oid, unsigned int flags) { khiter_t pos; git_cached_obj *entry = NULL; if (!git_cache__enabled || git_rwlock_rdlock(&cache->lock) < 0) return NULL; pos = kh_get(oid, cache->map, oid); if (pos != kh_end(cache->map)) { entry = kh_val(cache->map, pos); if (flags && entry->flags != flags) { entry = NULL; } else { git_cached_obj_incref(entry); } } git_rwlock_rdunlock(&cache->lock); return entry; } static void *cache_store(git_cache *cache, git_cached_obj *entry) { khiter_t pos; git_cached_obj_incref(entry); if (!git_cache__enabled && cache->used_memory > 0) { git_cache_clear(cache); return entry; } if (!cache_should_store(entry->type, entry->size)) return entry; if (git_rwlock_wrlock(&cache->lock) < 0) return entry; /* soften the load on the cache */ if (git_cache__current_storage.val > git_cache__max_storage) cache_evict_entries(cache); pos = kh_get(oid, cache->map, &entry->oid); /* not found */ if (pos == kh_end(cache->map)) { int rval; pos = kh_put(oid, cache->map, &entry->oid, &rval); if (rval >= 0) { kh_key(cache->map, pos) = &entry->oid; kh_val(cache->map, pos) = entry; git_cached_obj_incref(entry); cache->used_memory += entry->size; git_atomic_ssize_add(&git_cache__current_storage, (ssize_t)entry->size); } } /* found */ else { git_cached_obj *stored_entry = kh_val(cache->map, pos); if (stored_entry->flags == entry->flags) { git_cached_obj_decref(entry); git_cached_obj_incref(stored_entry); entry = stored_entry; } else if (stored_entry->flags == GIT_CACHE_STORE_RAW && entry->flags == GIT_CACHE_STORE_PARSED) { git_cached_obj_decref(stored_entry); git_cached_obj_incref(entry); kh_key(cache->map, pos) = &entry->oid; kh_val(cache->map, pos) = entry; } else { /* NO OP */ } } git_rwlock_wrunlock(&cache->lock); return entry; } void *git_cache_store_raw(git_cache *cache, git_odb_object *entry) { entry->cached.flags = GIT_CACHE_STORE_RAW; return cache_store(cache, (git_cached_obj *)entry); } void *git_cache_store_parsed(git_cache *cache, git_object *entry) { entry->cached.flags = GIT_CACHE_STORE_PARSED; return cache_store(cache, (git_cached_obj *)entry); } git_odb_object *git_cache_get_raw(git_cache *cache, const git_oid *oid) { return cache_get(cache, oid, GIT_CACHE_STORE_RAW); } git_object *git_cache_get_parsed(git_cache *cache, const git_oid *oid) { return cache_get(cache, oid, GIT_CACHE_STORE_PARSED); } void *git_cache_get_any(git_cache *cache, const git_oid *oid) { return cache_get(cache, oid, GIT_CACHE_STORE_ANY); } void git_cached_obj_decref(void *_obj) { git_cached_obj *obj = _obj; if (git_atomic_dec(&obj->refcount) == 0) { switch (obj->flags) { case GIT_CACHE_STORE_RAW: git_odb_object__free(_obj); break; case GIT_CACHE_STORE_PARSED: git_object__free(_obj); break; default: git__free(_obj); break; } } } deps/libgit2-sys-0.3.8/libgit2/src/tree.c0000664000175000017500000005473412555730137015022 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "commit.h" #include "tree.h" #include "git2/repository.h" #include "git2/object.h" #include "fileops.h" #include "tree-cache.h" #include "index.h" #define DEFAULT_TREE_SIZE 16 #define MAX_FILEMODE_BYTES 6 GIT__USE_STRMAP static bool valid_filemode(const int filemode) { return (filemode == GIT_FILEMODE_TREE || filemode == GIT_FILEMODE_BLOB || filemode == GIT_FILEMODE_BLOB_EXECUTABLE || filemode == GIT_FILEMODE_LINK || filemode == GIT_FILEMODE_COMMIT); } GIT_INLINE(git_filemode_t) normalize_filemode(git_filemode_t filemode) { /* Tree bits set, but it's not a commit */ if (GIT_MODE_TYPE(filemode) == GIT_FILEMODE_TREE) return GIT_FILEMODE_TREE; /* If any of the x bits are set */ if (GIT_PERMS_IS_EXEC(filemode)) return GIT_FILEMODE_BLOB_EXECUTABLE; /* 16XXXX means commit */ if (GIT_MODE_TYPE(filemode) == GIT_FILEMODE_COMMIT) return GIT_FILEMODE_COMMIT; /* 12XXXX means commit */ if (GIT_MODE_TYPE(filemode) == GIT_FILEMODE_LINK) return GIT_FILEMODE_LINK; /* Otherwise, return a blob */ return GIT_FILEMODE_BLOB; } static int valid_entry_name(git_repository *repo, const char *filename) { return *filename != '\0' && git_path_isvalid(repo, filename, GIT_PATH_REJECT_TRAVERSAL | GIT_PATH_REJECT_DOT_GIT | GIT_PATH_REJECT_SLASH); } static int entry_sort_cmp(const void *a, const void *b) { const git_tree_entry *e1 = (const git_tree_entry *)a; const git_tree_entry *e2 = (const git_tree_entry *)b; return git_path_cmp( e1->filename, e1->filename_len, git_tree_entry__is_tree(e1), e2->filename, e2->filename_len, git_tree_entry__is_tree(e2), git__strncmp); } int git_tree_entry_cmp(const git_tree_entry *e1, const git_tree_entry *e2) { return entry_sort_cmp(e1, e2); } int git_tree_entry_icmp(const git_tree_entry *e1, const git_tree_entry *e2) { return git_path_cmp( e1->filename, e1->filename_len, git_tree_entry__is_tree(e1), e2->filename, e2->filename_len, git_tree_entry__is_tree(e2), git__strncasecmp); } static git_tree_entry *alloc_entry(const char *filename) { git_tree_entry *entry = NULL; size_t filename_len = strlen(filename), tree_len; if (GIT_ADD_SIZET_OVERFLOW(&tree_len, sizeof(git_tree_entry), filename_len) || GIT_ADD_SIZET_OVERFLOW(&tree_len, tree_len, 1) || !(entry = git__malloc(tree_len))) return NULL; memset(entry, 0x0, sizeof(git_tree_entry)); memcpy(entry->filename, filename, filename_len); entry->filename[filename_len] = 0; entry->filename_len = filename_len; return entry; } struct tree_key_search { const char *filename; size_t filename_len; }; static int homing_search_cmp(const void *key, const void *array_member) { const struct tree_key_search *ksearch = key; const git_tree_entry *entry = array_member; const size_t len1 = ksearch->filename_len; const size_t len2 = entry->filename_len; return memcmp( ksearch->filename, entry->filename, len1 < len2 ? len1 : len2 ); } /* * Search for an entry in a given tree. * * Note that this search is performed in two steps because * of the way tree entries are sorted internally in git: * * Entries in a tree are not sorted alphabetically; two entries * with the same root prefix will have different positions * depending on whether they are folders (subtrees) or normal files. * * Consequently, it is not possible to find an entry on the tree * with a binary search if you don't know whether the filename * you're looking for is a folder or a normal file. * * To work around this, we first perform a homing binary search * on the tree, using the minimal length root prefix of our filename. * Once the comparisons for this homing search start becoming * ambiguous because of folder vs file sorting, we look linearly * around the area for our target file. */ static int tree_key_search( size_t *at_pos, git_vector *entries, const char *filename, size_t filename_len) { struct tree_key_search ksearch; const git_tree_entry *entry; size_t homing, i; ksearch.filename = filename; ksearch.filename_len = filename_len; /* Initial homing search; find an entry on the tree with * the same prefix as the filename we're looking for */ if (git_vector_bsearch2(&homing, entries, &homing_search_cmp, &ksearch) < 0) return GIT_ENOTFOUND; /* just a signal error; not passed back to user */ /* We found a common prefix. Look forward as long as * there are entries that share the common prefix */ for (i = homing; i < entries->length; ++i) { entry = entries->contents[i]; if (homing_search_cmp(&ksearch, entry) < 0) break; if (entry->filename_len == filename_len && memcmp(filename, entry->filename, filename_len) == 0) { if (at_pos) *at_pos = i; return 0; } } /* If we haven't found our filename yet, look backwards * too as long as we have entries with the same prefix */ if (homing > 0) { i = homing - 1; do { entry = entries->contents[i]; if (homing_search_cmp(&ksearch, entry) > 0) break; if (entry->filename_len == filename_len && memcmp(filename, entry->filename, filename_len) == 0) { if (at_pos) *at_pos = i; return 0; } } while (i-- > 0); } /* The filename doesn't exist at all */ return GIT_ENOTFOUND; } void git_tree_entry_free(git_tree_entry *entry) { if (entry == NULL) return; git__free(entry); } int git_tree_entry_dup(git_tree_entry **dest, const git_tree_entry *source) { size_t total_size; git_tree_entry *copy; assert(source); GITERR_CHECK_ALLOC_ADD(&total_size, sizeof(git_tree_entry), source->filename_len); GITERR_CHECK_ALLOC_ADD(&total_size, total_size, 1); copy = git__malloc(total_size); GITERR_CHECK_ALLOC(copy); memcpy(copy, source, total_size); *dest = copy; return 0; } void git_tree__free(void *_tree) { git_tree *tree = _tree; size_t i; git_tree_entry *e; git_vector_foreach(&tree->entries, i, e) git_tree_entry_free(e); git_vector_free(&tree->entries); git__free(tree); } git_filemode_t git_tree_entry_filemode(const git_tree_entry *entry) { return normalize_filemode(entry->attr); } git_filemode_t git_tree_entry_filemode_raw(const git_tree_entry *entry) { return entry->attr; } const char *git_tree_entry_name(const git_tree_entry *entry) { assert(entry); return entry->filename; } const git_oid *git_tree_entry_id(const git_tree_entry *entry) { assert(entry); return &entry->oid; } git_otype git_tree_entry_type(const git_tree_entry *entry) { assert(entry); if (S_ISGITLINK(entry->attr)) return GIT_OBJ_COMMIT; else if (S_ISDIR(entry->attr)) return GIT_OBJ_TREE; else return GIT_OBJ_BLOB; } int git_tree_entry_to_object( git_object **object_out, git_repository *repo, const git_tree_entry *entry) { assert(entry && object_out); return git_object_lookup(object_out, repo, &entry->oid, GIT_OBJ_ANY); } static const git_tree_entry *entry_fromname( const git_tree *tree, const char *name, size_t name_len) { size_t idx; /* be safe when we cast away constness - i.e. don't trigger a sort */ assert(git_vector_is_sorted(&tree->entries)); if (tree_key_search(&idx, (git_vector *)&tree->entries, name, name_len) < 0) return NULL; return git_vector_get(&tree->entries, idx); } const git_tree_entry *git_tree_entry_byname( const git_tree *tree, const char *filename) { assert(tree && filename); return entry_fromname(tree, filename, strlen(filename)); } const git_tree_entry *git_tree_entry_byindex( const git_tree *tree, size_t idx) { assert(tree); return git_vector_get(&tree->entries, idx); } const git_tree_entry *git_tree_entry_byid( const git_tree *tree, const git_oid *id) { size_t i; const git_tree_entry *e; assert(tree); git_vector_foreach(&tree->entries, i, e) { if (memcmp(&e->oid.id, &id->id, sizeof(id->id)) == 0) return e; } return NULL; } int git_tree__prefix_position(const git_tree *tree, const char *path) { const git_vector *entries = &tree->entries; struct tree_key_search ksearch; size_t at_pos; if (!path) return 0; ksearch.filename = path; ksearch.filename_len = strlen(path); /* be safe when we cast away constness - i.e. don't trigger a sort */ assert(git_vector_is_sorted(&tree->entries)); /* Find tree entry with appropriate prefix */ git_vector_bsearch2( &at_pos, (git_vector *)entries, &homing_search_cmp, &ksearch); for (; at_pos < entries->length; ++at_pos) { const git_tree_entry *entry = entries->contents[at_pos]; if (homing_search_cmp(&ksearch, entry) < 0) break; } for (; at_pos > 0; --at_pos) { const git_tree_entry *entry = entries->contents[at_pos - 1]; if (homing_search_cmp(&ksearch, entry) > 0) break; } return (int)at_pos; } size_t git_tree_entrycount(const git_tree *tree) { assert(tree); return tree->entries.length; } unsigned int git_treebuilder_entrycount(git_treebuilder *bld) { assert(bld); return git_strmap_num_entries(bld->map); } static int tree_error(const char *str, const char *path) { if (path) giterr_set(GITERR_TREE, "%s - %s", str, path); else giterr_set(GITERR_TREE, "%s", str); return -1; } int git_tree__parse(void *_tree, git_odb_object *odb_obj) { git_tree *tree = _tree; const char *buffer = git_odb_object_data(odb_obj); const char *buffer_end = buffer + git_odb_object_size(odb_obj); if (git_vector_init(&tree->entries, DEFAULT_TREE_SIZE, entry_sort_cmp) < 0) return -1; while (buffer < buffer_end) { git_tree_entry *entry; int attr; if (git__strtol32(&attr, buffer, &buffer, 8) < 0 || !buffer) return tree_error("Failed to parse tree. Can't parse filemode", NULL); if (*buffer++ != ' ') return tree_error("Failed to parse tree. Object is corrupted", NULL); if (memchr(buffer, 0, buffer_end - buffer) == NULL) return tree_error("Failed to parse tree. Object is corrupted", NULL); /** Allocate the entry and store it in the entries vector */ { entry = alloc_entry(buffer); GITERR_CHECK_ALLOC(entry); if (git_vector_insert(&tree->entries, entry) < 0) { git__free(entry); return -1; } entry->attr = attr; } while (buffer < buffer_end && *buffer != 0) buffer++; buffer++; git_oid_fromraw(&entry->oid, (const unsigned char *)buffer); buffer += GIT_OID_RAWSZ; } git_vector_sort(&tree->entries); return 0; } static size_t find_next_dir(const char *dirname, git_index *index, size_t start) { size_t dirlen, i, entries = git_index_entrycount(index); dirlen = strlen(dirname); for (i = start; i < entries; ++i) { const git_index_entry *entry = git_index_get_byindex(index, i); if (strlen(entry->path) < dirlen || memcmp(entry->path, dirname, dirlen) || (dirlen > 0 && entry->path[dirlen] != '/')) { break; } } return i; } static int append_entry( git_treebuilder *bld, const char *filename, const git_oid *id, git_filemode_t filemode) { git_tree_entry *entry; int error = 0; if (!valid_entry_name(bld->repo, filename)) return tree_error("Failed to insert entry. Invalid name for a tree entry", filename); entry = alloc_entry(filename); GITERR_CHECK_ALLOC(entry); git_oid_cpy(&entry->oid, id); entry->attr = (uint16_t)filemode; git_strmap_insert(bld->map, entry->filename, entry, error); if (error < 0) { git_tree_entry_free(entry); giterr_set(GITERR_TREE, "failed to append entry %s to the tree builder", filename); return -1; } return 0; } static int write_tree( git_oid *oid, git_repository *repo, git_index *index, const char *dirname, size_t start) { git_treebuilder *bld = NULL; size_t i, entries = git_index_entrycount(index); int error; size_t dirname_len = strlen(dirname); const git_tree_cache *cache; cache = git_tree_cache_get(index->tree, dirname); if (cache != NULL && cache->entry_count >= 0){ git_oid_cpy(oid, &cache->oid); return (int)find_next_dir(dirname, index, start); } if ((error = git_treebuilder_new(&bld, repo, NULL)) < 0 || bld == NULL) return -1; /* * This loop is unfortunate, but necessary. The index doesn't have * any directores, so we need to handle that manually, and we * need to keep track of the current position. */ for (i = start; i < entries; ++i) { const git_index_entry *entry = git_index_get_byindex(index, i); const char *filename, *next_slash; /* * If we've left our (sub)tree, exit the loop and return. The * first check is an early out (and security for the * third). The second check is a simple prefix comparison. The * third check catches situations where there is a directory * win32/sys and a file win32mmap.c. Without it, the following * code believes there is a file win32/mmap.c */ if (strlen(entry->path) < dirname_len || memcmp(entry->path, dirname, dirname_len) || (dirname_len > 0 && entry->path[dirname_len] != '/')) { break; } filename = entry->path + dirname_len; if (*filename == '/') filename++; next_slash = strchr(filename, '/'); if (next_slash) { git_oid sub_oid; int written; char *subdir, *last_comp; subdir = git__strndup(entry->path, next_slash - entry->path); GITERR_CHECK_ALLOC(subdir); /* Write out the subtree */ written = write_tree(&sub_oid, repo, index, subdir, i); if (written < 0) { git__free(subdir); goto on_error; } else { i = written - 1; /* -1 because of the loop increment */ } /* * We need to figure out what we want toinsert * into this tree. If we're traversing * deps/zlib/, then we only want to write * 'zlib' into the tree. */ last_comp = strrchr(subdir, '/'); if (last_comp) { last_comp++; /* Get rid of the '/' */ } else { last_comp = subdir; } error = append_entry(bld, last_comp, &sub_oid, S_IFDIR); git__free(subdir); if (error < 0) goto on_error; } else { error = append_entry(bld, filename, &entry->id, entry->mode); if (error < 0) goto on_error; } } if (git_treebuilder_write(oid, bld) < 0) goto on_error; git_treebuilder_free(bld); return (int)i; on_error: git_treebuilder_free(bld); return -1; } int git_tree__write_index( git_oid *oid, git_index *index, git_repository *repo) { int ret; git_tree *tree; bool old_ignore_case = false; assert(oid && index && repo); if (git_index_has_conflicts(index)) { giterr_set(GITERR_INDEX, "Cannot create a tree from a not fully merged index."); return GIT_EUNMERGED; } if (index->tree != NULL && index->tree->entry_count >= 0) { git_oid_cpy(oid, &index->tree->oid); return 0; } /* The tree cache didn't help us; we'll have to write * out a tree. If the index is ignore_case, we must * make it case-sensitive for the duration of the tree-write * operation. */ if (index->ignore_case) { old_ignore_case = true; git_index__set_ignore_case(index, false); } ret = write_tree(oid, repo, index, "", 0); if (old_ignore_case) git_index__set_ignore_case(index, true); index->tree = NULL; if (ret < 0) return ret; git_pool_clear(&index->tree_pool); if ((ret = git_tree_lookup(&tree, repo, oid)) < 0) return ret; /* Read the tree cache into the index */ ret = git_tree_cache_read_tree(&index->tree, tree, &index->tree_pool); git_tree_free(tree); return ret; } int git_treebuilder_new( git_treebuilder **builder_p, git_repository *repo, const git_tree *source) { git_treebuilder *bld; size_t i; assert(builder_p && repo); bld = git__calloc(1, sizeof(git_treebuilder)); GITERR_CHECK_ALLOC(bld); bld->repo = repo; if (git_strmap_alloc(&bld->map) < 0) { git__free(bld); return -1; } if (source != NULL) { git_tree_entry *entry_src; git_vector_foreach(&source->entries, i, entry_src) { if (append_entry( bld, entry_src->filename, &entry_src->oid, entry_src->attr) < 0) goto on_error; } } *builder_p = bld; return 0; on_error: git_treebuilder_free(bld); return -1; } int git_treebuilder_insert( const git_tree_entry **entry_out, git_treebuilder *bld, const char *filename, const git_oid *id, git_filemode_t filemode) { git_tree_entry *entry; int error; git_strmap_iter pos; assert(bld && id && filename); if (!valid_filemode(filemode)) return tree_error("Failed to insert entry. Invalid filemode for file", filename); if (!valid_entry_name(bld->repo, filename)) return tree_error("Failed to insert entry. Invalid name for a tree entry", filename); pos = git_strmap_lookup_index(bld->map, filename); if (git_strmap_valid_index(bld->map, pos)) { entry = git_strmap_value_at(bld->map, pos); } else { entry = alloc_entry(filename); GITERR_CHECK_ALLOC(entry); git_strmap_insert(bld->map, entry->filename, entry, error); if (error < 0) { git_tree_entry_free(entry); giterr_set(GITERR_TREE, "failed to insert %s", filename); return -1; } } git_oid_cpy(&entry->oid, id); entry->attr = filemode; if (entry_out) *entry_out = entry; return 0; } static git_tree_entry *treebuilder_get(git_treebuilder *bld, const char *filename) { git_tree_entry *entry = NULL; git_strmap_iter pos; assert(bld && filename); pos = git_strmap_lookup_index(bld->map, filename); if (git_strmap_valid_index(bld->map, pos)) entry = git_strmap_value_at(bld->map, pos); return entry; } const git_tree_entry *git_treebuilder_get(git_treebuilder *bld, const char *filename) { return treebuilder_get(bld, filename); } int git_treebuilder_remove(git_treebuilder *bld, const char *filename) { git_tree_entry *entry = treebuilder_get(bld, filename); if (entry == NULL) return tree_error("Failed to remove entry. File isn't in the tree", filename); git_strmap_delete(bld->map, filename); git_tree_entry_free(entry); return 0; } int git_treebuilder_write(git_oid *oid, git_treebuilder *bld) { int error = 0; size_t i, entrycount; git_buf tree = GIT_BUF_INIT; git_odb *odb; git_tree_entry *entry; git_vector entries; assert(bld); entrycount = git_strmap_num_entries(bld->map); if (git_vector_init(&entries, entrycount, entry_sort_cmp) < 0) return -1; git_strmap_foreach_value(bld->map, entry, { if (git_vector_insert(&entries, entry) < 0) return -1; }); git_vector_sort(&entries); /* Grow the buffer beforehand to an estimated size */ error = git_buf_grow(&tree, entrycount * 72); for (i = 0; i < entries.length && !error; ++i) { git_tree_entry *entry = git_vector_get(&entries, i); git_buf_printf(&tree, "%o ", entry->attr); git_buf_put(&tree, entry->filename, entry->filename_len + 1); git_buf_put(&tree, (char *)entry->oid.id, GIT_OID_RAWSZ); if (git_buf_oom(&tree)) error = -1; } git_vector_free(&entries); if (!error && !(error = git_repository_odb__weakptr(&odb, bld->repo))) error = git_odb_write(oid, odb, tree.ptr, tree.size, GIT_OBJ_TREE); git_buf_free(&tree); return error; } void git_treebuilder_filter( git_treebuilder *bld, git_treebuilder_filter_cb filter, void *payload) { const char *filename; git_tree_entry *entry; assert(bld && filter); git_strmap_foreach(bld->map, filename, entry, { if (filter(entry, payload)) { git_strmap_delete(bld->map, filename); git_tree_entry_free(entry); } }); } void git_treebuilder_clear(git_treebuilder *bld) { git_tree_entry *e; assert(bld); git_strmap_foreach_value(bld->map, e, git_tree_entry_free(e)); git_strmap_clear(bld->map); } void git_treebuilder_free(git_treebuilder *bld) { if (bld == NULL) return; git_treebuilder_clear(bld); git_strmap_free(bld->map); git__free(bld); } static size_t subpath_len(const char *path) { const char *slash_pos = strchr(path, '/'); if (slash_pos == NULL) return strlen(path); return slash_pos - path; } int git_tree_entry_bypath( git_tree_entry **entry_out, const git_tree *root, const char *path) { int error = 0; git_tree *subtree; const git_tree_entry *entry; size_t filename_len; /* Find how long is the current path component (i.e. * the filename between two slashes */ filename_len = subpath_len(path); if (filename_len == 0) { giterr_set(GITERR_TREE, "Invalid tree path given"); return GIT_ENOTFOUND; } entry = entry_fromname(root, path, filename_len); if (entry == NULL) { giterr_set(GITERR_TREE, "the path '%.*s' does not exist in the given tree", filename_len, path); return GIT_ENOTFOUND; } switch (path[filename_len]) { case '/': /* If there are more components in the path... * then this entry *must* be a tree */ if (!git_tree_entry__is_tree(entry)) { giterr_set(GITERR_TREE, "the path '%.*s' exists but is not a tree", filename_len, path); return GIT_ENOTFOUND; } /* If there's only a slash left in the path, we * return the current entry; otherwise, we keep * walking down the path */ if (path[filename_len + 1] != '\0') break; case '\0': /* If there are no more components in the path, return * this entry */ return git_tree_entry_dup(entry_out, entry); } if (git_tree_lookup(&subtree, root->object.repo, &entry->oid) < 0) return -1; error = git_tree_entry_bypath( entry_out, subtree, path + filename_len + 1 ); git_tree_free(subtree); return error; } static int tree_walk( const git_tree *tree, git_treewalk_cb callback, git_buf *path, void *payload, bool preorder) { int error = 0; size_t i; const git_tree_entry *entry; git_vector_foreach(&tree->entries, i, entry) { if (preorder) { error = callback(path->ptr, entry, payload); if (error < 0) { /* negative value stops iteration */ giterr_set_after_callback_function(error, "git_tree_walk"); break; } if (error > 0) { /* positive value skips this entry */ error = 0; continue; } } if (git_tree_entry__is_tree(entry)) { git_tree *subtree; size_t path_len = git_buf_len(path); error = git_tree_lookup(&subtree, tree->object.repo, &entry->oid); if (error < 0) break; /* append the next entry to the path */ git_buf_puts(path, entry->filename); git_buf_putc(path, '/'); if (git_buf_oom(path)) error = -1; else error = tree_walk(subtree, callback, path, payload, preorder); git_tree_free(subtree); if (error != 0) break; git_buf_truncate(path, path_len); } if (!preorder) { error = callback(path->ptr, entry, payload); if (error < 0) { /* negative value stops iteration */ giterr_set_after_callback_function(error, "git_tree_walk"); break; } error = 0; } } return error; } int git_tree_walk( const git_tree *tree, git_treewalk_mode mode, git_treewalk_cb callback, void *payload) { int error = 0; git_buf root_path = GIT_BUF_INIT; if (mode != GIT_TREEWALK_POST && mode != GIT_TREEWALK_PRE) { giterr_set(GITERR_INVALID, "Invalid walking mode for tree walk"); return -1; } error = tree_walk( tree, callback, &root_path, payload, (mode == GIT_TREEWALK_PRE)); git_buf_free(&root_path); return error; } deps/libgit2-sys-0.3.8/libgit2/src/merge.c0000664000175000017500000021627512610310643015146 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "posix.h" #include "buffer.h" #include "repository.h" #include "revwalk.h" #include "commit_list.h" #include "merge.h" #include "path.h" #include "refs.h" #include "object.h" #include "iterator.h" #include "refs.h" #include "diff.h" #include "checkout.h" #include "tree.h" #include "blob.h" #include "oid.h" #include "index.h" #include "filebuf.h" #include "config.h" #include "oidarray.h" #include "annotated_commit.h" #include "git2/types.h" #include "git2/repository.h" #include "git2/object.h" #include "git2/commit.h" #include "git2/merge.h" #include "git2/refs.h" #include "git2/reset.h" #include "git2/checkout.h" #include "git2/signature.h" #include "git2/config.h" #include "git2/tree.h" #include "git2/oidarray.h" #include "git2/annotated_commit.h" #include "git2/sys/index.h" #include "git2/sys/hashsig.h" #define GIT_MERGE_INDEX_ENTRY_EXISTS(X) ((X).mode != 0) #define GIT_MERGE_INDEX_ENTRY_ISFILE(X) S_ISREG((X).mode) typedef enum { TREE_IDX_ANCESTOR = 0, TREE_IDX_OURS = 1, TREE_IDX_THEIRS = 2 } merge_tree_index_t; /* Tracks D/F conflicts */ struct merge_diff_df_data { const char *df_path; const char *prev_path; git_merge_diff *prev_conflict; }; /* Merge base computation */ int merge_bases_many(git_commit_list **out, git_revwalk **walk_out, git_repository *repo, size_t length, const git_oid input_array[]) { git_revwalk *walk = NULL; git_vector list; git_commit_list *result = NULL; git_commit_list_node *commit; int error = -1; unsigned int i; if (length < 2) { giterr_set(GITERR_INVALID, "At least two commits are required to find an ancestor. Provided 'length' was %" PRIuZ ".", length); return -1; } if (git_vector_init(&list, length - 1, NULL) < 0) return -1; if (git_revwalk_new(&walk, repo) < 0) goto on_error; for (i = 1; i < length; i++) { commit = git_revwalk__commit_lookup(walk, &input_array[i]); if (commit == NULL) goto on_error; git_vector_insert(&list, commit); } commit = git_revwalk__commit_lookup(walk, &input_array[0]); if (commit == NULL) goto on_error; if (git_merge__bases_many(&result, walk, commit, &list) < 0) goto on_error; if (!result) { giterr_set(GITERR_MERGE, "No merge base found"); error = GIT_ENOTFOUND; goto on_error; } *out = result; *walk_out = walk; git_vector_free(&list); return 0; on_error: git_vector_free(&list); git_revwalk_free(walk); return error; } int git_merge_base_many(git_oid *out, git_repository *repo, size_t length, const git_oid input_array[]) { git_revwalk *walk; git_commit_list *result = NULL; int error = 0; assert(out && repo && input_array); if ((error = merge_bases_many(&result, &walk, repo, length, input_array)) < 0) return error; git_oid_cpy(out, &result->item->oid); git_commit_list_free(&result); git_revwalk_free(walk); return 0; } int git_merge_bases_many(git_oidarray *out, git_repository *repo, size_t length, const git_oid input_array[]) { git_revwalk *walk; git_commit_list *list, *result = NULL; int error = 0; git_array_oid_t array; assert(out && repo && input_array); if ((error = merge_bases_many(&result, &walk, repo, length, input_array)) < 0) return error; git_array_init(array); list = result; while (list) { git_oid *id = git_array_alloc(array); if (id == NULL) { error = -1; goto cleanup; } git_oid_cpy(id, &list->item->oid); list = list->next; } git_oidarray__from_array(out, &array); cleanup: git_commit_list_free(&result); git_revwalk_free(walk); return error; } int git_merge_base_octopus(git_oid *out, git_repository *repo, size_t length, const git_oid input_array[]) { git_oid result; unsigned int i; int error = -1; assert(out && repo && input_array); if (length < 2) { giterr_set(GITERR_INVALID, "At least two commits are required to find an ancestor. Provided 'length' was %" PRIuZ ".", length); return -1; } result = input_array[0]; for (i = 1; i < length; i++) { error = git_merge_base(&result, repo, &result, &input_array[i]); if (error < 0) return error; } *out = result; return 0; } static int merge_bases(git_commit_list **out, git_revwalk **walk_out, git_repository *repo, const git_oid *one, const git_oid *two) { git_revwalk *walk; git_vector list; git_commit_list *result = NULL; git_commit_list_node *commit; void *contents[1]; if (git_revwalk_new(&walk, repo) < 0) return -1; commit = git_revwalk__commit_lookup(walk, two); if (commit == NULL) goto on_error; /* This is just one value, so we can do it on the stack */ memset(&list, 0x0, sizeof(git_vector)); contents[0] = commit; list.length = 1; list.contents = contents; commit = git_revwalk__commit_lookup(walk, one); if (commit == NULL) goto on_error; if (git_merge__bases_many(&result, walk, commit, &list) < 0) goto on_error; if (!result) { git_revwalk_free(walk); giterr_set(GITERR_MERGE, "No merge base found"); return GIT_ENOTFOUND; } *out = result; *walk_out = walk; return 0; on_error: git_revwalk_free(walk); return -1; } int git_merge_base(git_oid *out, git_repository *repo, const git_oid *one, const git_oid *two) { int error; git_revwalk *walk; git_commit_list *result; if ((error = merge_bases(&result, &walk, repo, one, two)) < 0) return error; git_oid_cpy(out, &result->item->oid); git_commit_list_free(&result); git_revwalk_free(walk); return 0; } int git_merge_bases(git_oidarray *out, git_repository *repo, const git_oid *one, const git_oid *two) { int error; git_revwalk *walk; git_commit_list *result, *list; git_array_oid_t array; git_array_init(array); if ((error = merge_bases(&result, &walk, repo, one, two)) < 0) return error; list = result; while (list) { git_oid *id = git_array_alloc(array); if (id == NULL) goto on_error; git_oid_cpy(id, &list->item->oid); list = list->next; } git_oidarray__from_array(out, &array); git_commit_list_free(&result); git_revwalk_free(walk); return 0; on_error: git_commit_list_free(&result); git_revwalk_free(walk); return -1; } static int interesting(git_pqueue *list) { size_t i; for (i = 0; i < git_pqueue_size(list); i++) { git_commit_list_node *commit = git_pqueue_get(list, i); if ((commit->flags & STALE) == 0) return 1; } return 0; } int git_merge__bases_many(git_commit_list **out, git_revwalk *walk, git_commit_list_node *one, git_vector *twos) { int error; unsigned int i; git_commit_list_node *two; git_commit_list *result = NULL, *tmp = NULL; git_pqueue list; /* If there's only the one commit, there can be no merge bases */ if (twos->length == 0) { *out = NULL; return 0; } /* if the commit is repeated, we have a our merge base already */ git_vector_foreach(twos, i, two) { if (one == two) return git_commit_list_insert(one, out) ? 0 : -1; } if (git_pqueue_init(&list, 0, twos->length * 2, git_commit_list_time_cmp) < 0) return -1; if (git_commit_list_parse(walk, one) < 0) return -1; one->flags |= PARENT1; if (git_pqueue_insert(&list, one) < 0) return -1; git_vector_foreach(twos, i, two) { if (git_commit_list_parse(walk, two) < 0) return -1; two->flags |= PARENT2; if (git_pqueue_insert(&list, two) < 0) return -1; } /* as long as there are non-STALE commits */ while (interesting(&list)) { git_commit_list_node *commit = git_pqueue_pop(&list); int flags; if (commit == NULL) break; flags = commit->flags & (PARENT1 | PARENT2 | STALE); if (flags == (PARENT1 | PARENT2)) { if (!(commit->flags & RESULT)) { commit->flags |= RESULT; if (git_commit_list_insert(commit, &result) == NULL) return -1; } /* we mark the parents of a merge stale */ flags |= STALE; } for (i = 0; i < commit->out_degree; i++) { git_commit_list_node *p = commit->parents[i]; if ((p->flags & flags) == flags) continue; if ((error = git_commit_list_parse(walk, p)) < 0) return error; p->flags |= flags; if (git_pqueue_insert(&list, p) < 0) return -1; } } git_pqueue_free(&list); /* filter out any stale commits in the results */ tmp = result; result = NULL; while (tmp) { struct git_commit_list *next = tmp->next; if (!(tmp->item->flags & STALE)) if (git_commit_list_insert_by_date(tmp->item, &result) == NULL) return -1; git__free(tmp); tmp = next; } *out = result; return 0; } int git_repository_mergehead_foreach( git_repository *repo, git_repository_mergehead_foreach_cb cb, void *payload) { git_buf merge_head_path = GIT_BUF_INIT, merge_head_file = GIT_BUF_INIT; char *buffer, *line; size_t line_num = 1; git_oid oid; int error = 0; assert(repo && cb); if ((error = git_buf_joinpath(&merge_head_path, repo->path_repository, GIT_MERGE_HEAD_FILE)) < 0) return error; if ((error = git_futils_readbuffer(&merge_head_file, git_buf_cstr(&merge_head_path))) < 0) goto cleanup; buffer = merge_head_file.ptr; while ((line = git__strsep(&buffer, "\n")) != NULL) { if (strlen(line) != GIT_OID_HEXSZ) { giterr_set(GITERR_INVALID, "Unable to parse OID - invalid length"); error = -1; goto cleanup; } if ((error = git_oid_fromstr(&oid, line)) < 0) goto cleanup; if ((error = cb(&oid, payload)) != 0) { giterr_set_after_callback(error); goto cleanup; } ++line_num; } if (*buffer) { giterr_set(GITERR_MERGE, "No EOL at line %d", line_num); error = -1; goto cleanup; } cleanup: git_buf_free(&merge_head_path); git_buf_free(&merge_head_file); return error; } GIT_INLINE(int) index_entry_cmp(const git_index_entry *a, const git_index_entry *b) { int value = 0; if (a->path == NULL) return (b->path == NULL) ? 0 : 1; if ((value = a->mode - b->mode) == 0 && (value = git_oid__cmp(&a->id, &b->id)) == 0) value = strcmp(a->path, b->path); return value; } /* Conflict resolution */ static int merge_conflict_resolve_trivial( int *resolved, git_merge_diff_list *diff_list, const git_merge_diff *conflict) { int ours_empty, theirs_empty; int ours_changed, theirs_changed, ours_theirs_differ; git_index_entry const *result = NULL; int error = 0; assert(resolved && diff_list && conflict); *resolved = 0; if (conflict->type == GIT_MERGE_DIFF_DIRECTORY_FILE || conflict->type == GIT_MERGE_DIFF_RENAMED_ADDED) return 0; if (conflict->our_status == GIT_DELTA_RENAMED || conflict->their_status == GIT_DELTA_RENAMED) return 0; ours_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry); theirs_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry); ours_changed = (conflict->our_status != GIT_DELTA_UNMODIFIED); theirs_changed = (conflict->their_status != GIT_DELTA_UNMODIFIED); ours_theirs_differ = ours_changed && theirs_changed && index_entry_cmp(&conflict->our_entry, &conflict->their_entry); /* * Note: with only one ancestor, some cases are not distinct: * * 16: ancest:anc1/anc2, head:anc1, remote:anc2 = result:no merge * 3: ancest:(empty)^, head:head, remote:(empty) = result:no merge * 2: ancest:(empty)^, head:(empty), remote:remote = result:no merge * * Note that the two cases that take D/F conflicts into account * specifically do not need to be explicitly tested, as D/F conflicts * would fail the *empty* test: * * 3ALT: ancest:(empty)+, head:head, remote:*empty* = result:head * 2ALT: ancest:(empty)+, head:*empty*, remote:remote = result:remote * * Note that many of these cases need not be explicitly tested, as * they simply degrade to "all different" cases (eg, 11): * * 4: ancest:(empty)^, head:head, remote:remote = result:no merge * 7: ancest:ancest+, head:(empty), remote:remote = result:no merge * 9: ancest:ancest+, head:head, remote:(empty) = result:no merge * 11: ancest:ancest+, head:head, remote:remote = result:no merge */ /* 5ALT: ancest:*, head:head, remote:head = result:head */ if (ours_changed && !ours_empty && !ours_theirs_differ) result = &conflict->our_entry; /* 6: ancest:ancest+, head:(empty), remote:(empty) = result:no merge */ else if (ours_changed && ours_empty && theirs_empty) *resolved = 0; /* 8: ancest:ancest^, head:(empty), remote:ancest = result:no merge */ else if (ours_empty && !theirs_changed) *resolved = 0; /* 10: ancest:ancest^, head:ancest, remote:(empty) = result:no merge */ else if (!ours_changed && theirs_empty) *resolved = 0; /* 13: ancest:ancest+, head:head, remote:ancest = result:head */ else if (ours_changed && !theirs_changed) result = &conflict->our_entry; /* 14: ancest:ancest+, head:ancest, remote:remote = result:remote */ else if (!ours_changed && theirs_changed) result = &conflict->their_entry; else *resolved = 0; if (result != NULL && GIT_MERGE_INDEX_ENTRY_EXISTS(*result) && (error = git_vector_insert(&diff_list->staged, (void *)result)) >= 0) *resolved = 1; /* Note: trivial resolution does not update the REUC. */ return error; } static int merge_conflict_resolve_one_removed( int *resolved, git_merge_diff_list *diff_list, const git_merge_diff *conflict) { int ours_empty, theirs_empty; int ours_changed, theirs_changed; int error = 0; assert(resolved && diff_list && conflict); *resolved = 0; if (conflict->type == GIT_MERGE_DIFF_DIRECTORY_FILE || conflict->type == GIT_MERGE_DIFF_RENAMED_ADDED) return 0; ours_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry); theirs_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry); ours_changed = (conflict->our_status != GIT_DELTA_UNMODIFIED); theirs_changed = (conflict->their_status != GIT_DELTA_UNMODIFIED); /* Removed in both */ if (ours_changed && ours_empty && theirs_empty) *resolved = 1; /* Removed in ours */ else if (ours_empty && !theirs_changed) *resolved = 1; /* Removed in theirs */ else if (!ours_changed && theirs_empty) *resolved = 1; if (*resolved) git_vector_insert(&diff_list->resolved, (git_merge_diff *)conflict); return error; } static int merge_conflict_resolve_one_renamed( int *resolved, git_merge_diff_list *diff_list, const git_merge_diff *conflict) { int ours_renamed, theirs_renamed; int ours_changed, theirs_changed; git_index_entry *merged; int error = 0; assert(resolved && diff_list && conflict); *resolved = 0; if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) || !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry)) return 0; ours_renamed = (conflict->our_status == GIT_DELTA_RENAMED); theirs_renamed = (conflict->their_status == GIT_DELTA_RENAMED); if (!ours_renamed && !theirs_renamed) return 0; /* Reject one file in a 2->1 conflict */ if (conflict->type == GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1 || conflict->type == GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2 || conflict->type == GIT_MERGE_DIFF_RENAMED_ADDED) return 0; ours_changed = (git_oid__cmp(&conflict->ancestor_entry.id, &conflict->our_entry.id) != 0); theirs_changed = (git_oid__cmp(&conflict->ancestor_entry.id, &conflict->their_entry.id) != 0); /* if both are modified (and not to a common target) require a merge */ if (ours_changed && theirs_changed && git_oid__cmp(&conflict->our_entry.id, &conflict->their_entry.id) != 0) return 0; if ((merged = git_pool_malloc(&diff_list->pool, sizeof(git_index_entry))) == NULL) return -1; if (ours_changed) memcpy(merged, &conflict->our_entry, sizeof(git_index_entry)); else memcpy(merged, &conflict->their_entry, sizeof(git_index_entry)); if (ours_renamed) merged->path = conflict->our_entry.path; else merged->path = conflict->their_entry.path; *resolved = 1; git_vector_insert(&diff_list->staged, merged); git_vector_insert(&diff_list->resolved, (git_merge_diff *)conflict); return error; } static int merge_conflict_resolve_automerge( int *resolved, git_merge_diff_list *diff_list, const git_merge_diff *conflict, unsigned int merge_file_favor, unsigned int file_flags) { const git_index_entry *ancestor = NULL, *ours = NULL, *theirs = NULL; git_merge_file_options opts = GIT_MERGE_FILE_OPTIONS_INIT; git_merge_file_result result = {0}; git_index_entry *index_entry; git_odb *odb = NULL; git_oid automerge_oid; int error = 0; assert(resolved && diff_list && conflict); *resolved = 0; if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) || !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry)) return 0; /* Reject D/F conflicts */ if (conflict->type == GIT_MERGE_DIFF_DIRECTORY_FILE) return 0; /* Reject submodules. */ if (S_ISGITLINK(conflict->ancestor_entry.mode) || S_ISGITLINK(conflict->our_entry.mode) || S_ISGITLINK(conflict->their_entry.mode)) return 0; /* Reject link/file conflicts. */ if ((S_ISLNK(conflict->ancestor_entry.mode) ^ S_ISLNK(conflict->our_entry.mode)) || (S_ISLNK(conflict->ancestor_entry.mode) ^ S_ISLNK(conflict->their_entry.mode))) return 0; /* Reject name conflicts */ if (conflict->type == GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1 || conflict->type == GIT_MERGE_DIFF_RENAMED_ADDED) return 0; if ((conflict->our_status & GIT_DELTA_RENAMED) == GIT_DELTA_RENAMED && (conflict->their_status & GIT_DELTA_RENAMED) == GIT_DELTA_RENAMED && strcmp(conflict->ancestor_entry.path, conflict->their_entry.path) != 0) return 0; ancestor = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry) ? &conflict->ancestor_entry : NULL; ours = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ? &conflict->our_entry : NULL; theirs = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry) ? &conflict->their_entry : NULL; opts.favor = merge_file_favor; opts.flags = file_flags; if ((error = git_repository_odb(&odb, diff_list->repo)) < 0 || (error = git_merge_file_from_index(&result, diff_list->repo, ancestor, ours, theirs, &opts)) < 0 || !result.automergeable || (error = git_odb_write(&automerge_oid, odb, result.ptr, result.len, GIT_OBJ_BLOB)) < 0) goto done; if ((index_entry = git_pool_malloc(&diff_list->pool, sizeof(git_index_entry))) == NULL) GITERR_CHECK_ALLOC(index_entry); index_entry->path = git_pool_strdup(&diff_list->pool, result.path); GITERR_CHECK_ALLOC(index_entry->path); index_entry->file_size = result.len; index_entry->mode = result.mode; git_oid_cpy(&index_entry->id, &automerge_oid); git_vector_insert(&diff_list->staged, index_entry); git_vector_insert(&diff_list->resolved, (git_merge_diff *)conflict); *resolved = 1; done: git_merge_file_result_free(&result); git_odb_free(odb); return error; } static int merge_conflict_resolve( int *out, git_merge_diff_list *diff_list, const git_merge_diff *conflict, unsigned int merge_file_favor, unsigned int file_flags) { int resolved = 0; int error = 0; *out = 0; if ((error = merge_conflict_resolve_trivial(&resolved, diff_list, conflict)) < 0) goto done; if (!resolved && (error = merge_conflict_resolve_one_removed(&resolved, diff_list, conflict)) < 0) goto done; if (!resolved && (error = merge_conflict_resolve_one_renamed(&resolved, diff_list, conflict)) < 0) goto done; if (!resolved && (error = merge_conflict_resolve_automerge(&resolved, diff_list, conflict, merge_file_favor, file_flags)) < 0) goto done; *out = resolved; done: return error; } /* Rename detection and coalescing */ struct merge_diff_similarity { unsigned char similarity; size_t other_idx; }; static int index_entry_similarity_exact( git_repository *repo, git_index_entry *a, size_t a_idx, git_index_entry *b, size_t b_idx, void **cache, const git_merge_options *opts) { GIT_UNUSED(repo); GIT_UNUSED(a_idx); GIT_UNUSED(b_idx); GIT_UNUSED(cache); GIT_UNUSED(opts); if (git_oid__cmp(&a->id, &b->id) == 0) return 100; return 0; } static int index_entry_similarity_calc( void **out, git_repository *repo, git_index_entry *entry, const git_merge_options *opts) { git_blob *blob; git_diff_file diff_file = {{{0}}}; git_off_t blobsize; int error; *out = NULL; if ((error = git_blob_lookup(&blob, repo, &entry->id)) < 0) return error; git_oid_cpy(&diff_file.id, &entry->id); diff_file.path = entry->path; diff_file.size = entry->file_size; diff_file.mode = entry->mode; diff_file.flags = 0; blobsize = git_blob_rawsize(blob); /* file too big for rename processing */ if (!git__is_sizet(blobsize)) return 0; error = opts->metric->buffer_signature(out, &diff_file, git_blob_rawcontent(blob), (size_t)blobsize, opts->metric->payload); git_blob_free(blob); return error; } static int index_entry_similarity_inexact( git_repository *repo, git_index_entry *a, size_t a_idx, git_index_entry *b, size_t b_idx, void **cache, const git_merge_options *opts) { int score = 0; int error = 0; if (GIT_MODE_TYPE(a->mode) != GIT_MODE_TYPE(b->mode)) return 0; /* update signature cache if needed */ if (!cache[a_idx] && (error = index_entry_similarity_calc(&cache[a_idx], repo, a, opts)) < 0) return error; if (!cache[b_idx] && (error = index_entry_similarity_calc(&cache[b_idx], repo, b, opts)) < 0) return error; /* some metrics may not wish to process this file (too big / too small) */ if (!cache[a_idx] || !cache[b_idx]) return 0; /* compare signatures */ if (opts->metric->similarity( &score, cache[a_idx], cache[b_idx], opts->metric->payload) < 0) return -1; /* clip score */ if (score < 0) score = 0; else if (score > 100) score = 100; return score; } static int merge_diff_mark_similarity( git_repository *repo, git_merge_diff_list *diff_list, struct merge_diff_similarity *similarity_ours, struct merge_diff_similarity *similarity_theirs, int (*similarity_fn)(git_repository *, git_index_entry *, size_t, git_index_entry *, size_t, void **, const git_merge_options *), void **cache, const git_merge_options *opts) { size_t i, j; git_merge_diff *conflict_src, *conflict_tgt; int similarity; git_vector_foreach(&diff_list->conflicts, i, conflict_src) { /* Items can be the source of a rename iff they have an item in the * ancestor slot and lack an item in the ours or theirs slot. */ if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->ancestor_entry) || (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->our_entry) && GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->their_entry))) continue; git_vector_foreach(&diff_list->conflicts, j, conflict_tgt) { size_t our_idx = diff_list->conflicts.length + j; size_t their_idx = (diff_list->conflicts.length * 2) + j; if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->ancestor_entry)) continue; if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->our_entry) && !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->our_entry)) { similarity = similarity_fn(repo, &conflict_src->ancestor_entry, i, &conflict_tgt->our_entry, our_idx, cache, opts); if (similarity == GIT_EBUFS) continue; else if (similarity < 0) return similarity; if (similarity > similarity_ours[i].similarity && similarity > similarity_ours[j].similarity) { /* Clear previous best similarity */ if (similarity_ours[i].similarity > 0) similarity_ours[similarity_ours[i].other_idx].similarity = 0; if (similarity_ours[j].similarity > 0) similarity_ours[similarity_ours[j].other_idx].similarity = 0; similarity_ours[i].similarity = similarity; similarity_ours[i].other_idx = j; similarity_ours[j].similarity = similarity; similarity_ours[j].other_idx = i; } } if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->their_entry) && !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->their_entry)) { similarity = similarity_fn(repo, &conflict_src->ancestor_entry, i, &conflict_tgt->their_entry, their_idx, cache, opts); if (similarity > similarity_theirs[i].similarity && similarity > similarity_theirs[j].similarity) { /* Clear previous best similarity */ if (similarity_theirs[i].similarity > 0) similarity_theirs[similarity_theirs[i].other_idx].similarity = 0; if (similarity_theirs[j].similarity > 0) similarity_theirs[similarity_theirs[j].other_idx].similarity = 0; similarity_theirs[i].similarity = similarity; similarity_theirs[i].other_idx = j; similarity_theirs[j].similarity = similarity; similarity_theirs[j].other_idx = i; } } } } return 0; } /* * Rename conflicts: * * Ancestor Ours Theirs * * 0a A A A No rename * b A A* A No rename (ours was rewritten) * c A A A* No rename (theirs rewritten) * 1a A A B[A] Rename or rename/edit * b A B[A] A (automergeable) * 2 A B[A] B[A] Both renamed (automergeable) * 3a A B[A] Rename/delete * b A B[A] (same) * 4a A B[A] B Rename/add [B~ours B~theirs] * b A B B[A] (same) * 5 A B[A] C[A] Both renamed ("1 -> 2") * 6 A C[A] Both renamed ("2 -> 1") * B C[B] [C~ours C~theirs] (automergeable) */ static void merge_diff_mark_rename_conflict( git_merge_diff_list *diff_list, struct merge_diff_similarity *similarity_ours, bool ours_renamed, size_t ours_source_idx, struct merge_diff_similarity *similarity_theirs, bool theirs_renamed, size_t theirs_source_idx, git_merge_diff *target, const git_merge_options *opts) { git_merge_diff *ours_source = NULL, *theirs_source = NULL; if (ours_renamed) ours_source = diff_list->conflicts.contents[ours_source_idx]; if (theirs_renamed) theirs_source = diff_list->conflicts.contents[theirs_source_idx]; /* Detect 2->1 conflicts */ if (ours_renamed && theirs_renamed) { /* Both renamed to the same target name. */ if (ours_source_idx == theirs_source_idx) ours_source->type = GIT_MERGE_DIFF_BOTH_RENAMED; else { ours_source->type = GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1; theirs_source->type = GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1; } } else if (ours_renamed) { /* If our source was also renamed in theirs, this is a 1->2 */ if (similarity_theirs[ours_source_idx].similarity >= opts->rename_threshold) ours_source->type = GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2; else if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->their_entry)) { ours_source->type = GIT_MERGE_DIFF_RENAMED_ADDED; target->type = GIT_MERGE_DIFF_RENAMED_ADDED; } else if (!GIT_MERGE_INDEX_ENTRY_EXISTS(ours_source->their_entry)) ours_source->type = GIT_MERGE_DIFF_RENAMED_DELETED; else if (ours_source->type == GIT_MERGE_DIFF_MODIFIED_DELETED) ours_source->type = GIT_MERGE_DIFF_RENAMED_MODIFIED; } else if (theirs_renamed) { /* If their source was also renamed in ours, this is a 1->2 */ if (similarity_ours[theirs_source_idx].similarity >= opts->rename_threshold) theirs_source->type = GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2; else if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->our_entry)) { theirs_source->type = GIT_MERGE_DIFF_RENAMED_ADDED; target->type = GIT_MERGE_DIFF_RENAMED_ADDED; } else if (!GIT_MERGE_INDEX_ENTRY_EXISTS(theirs_source->our_entry)) theirs_source->type = GIT_MERGE_DIFF_RENAMED_DELETED; else if (theirs_source->type == GIT_MERGE_DIFF_MODIFIED_DELETED) theirs_source->type = GIT_MERGE_DIFF_RENAMED_MODIFIED; } } GIT_INLINE(void) merge_diff_coalesce_rename( git_index_entry *source_entry, git_delta_t *source_status, git_index_entry *target_entry, git_delta_t *target_status) { /* Coalesce the rename target into the rename source. */ memcpy(source_entry, target_entry, sizeof(git_index_entry)); *source_status = GIT_DELTA_RENAMED; memset(target_entry, 0x0, sizeof(git_index_entry)); *target_status = GIT_DELTA_UNMODIFIED; } static void merge_diff_list_coalesce_renames( git_merge_diff_list *diff_list, struct merge_diff_similarity *similarity_ours, struct merge_diff_similarity *similarity_theirs, const git_merge_options *opts) { size_t i; bool ours_renamed = 0, theirs_renamed = 0; size_t ours_source_idx = 0, theirs_source_idx = 0; git_merge_diff *ours_source, *theirs_source, *target; for (i = 0; i < diff_list->conflicts.length; i++) { target = diff_list->conflicts.contents[i]; ours_renamed = 0; theirs_renamed = 0; if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->our_entry) && similarity_ours[i].similarity >= opts->rename_threshold) { ours_source_idx = similarity_ours[i].other_idx; ours_source = diff_list->conflicts.contents[ours_source_idx]; merge_diff_coalesce_rename( &ours_source->our_entry, &ours_source->our_status, &target->our_entry, &target->our_status); similarity_ours[ours_source_idx].similarity = 0; similarity_ours[i].similarity = 0; ours_renamed = 1; } /* insufficient to determine direction */ if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->their_entry) && similarity_theirs[i].similarity >= opts->rename_threshold) { theirs_source_idx = similarity_theirs[i].other_idx; theirs_source = diff_list->conflicts.contents[theirs_source_idx]; merge_diff_coalesce_rename( &theirs_source->their_entry, &theirs_source->their_status, &target->their_entry, &target->their_status); similarity_theirs[theirs_source_idx].similarity = 0; similarity_theirs[i].similarity = 0; theirs_renamed = 1; } merge_diff_mark_rename_conflict(diff_list, similarity_ours, ours_renamed, ours_source_idx, similarity_theirs, theirs_renamed, theirs_source_idx, target, opts); } } static int merge_diff_empty(const git_vector *conflicts, size_t idx, void *p) { git_merge_diff *conflict = conflicts->contents[idx]; GIT_UNUSED(p); return (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry) && !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) && !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry)); } static void merge_diff_list_count_candidates( git_merge_diff_list *diff_list, size_t *src_count, size_t *tgt_count) { git_merge_diff *entry; size_t i; *src_count = 0; *tgt_count = 0; git_vector_foreach(&diff_list->conflicts, i, entry) { if (GIT_MERGE_INDEX_ENTRY_EXISTS(entry->ancestor_entry) && (!GIT_MERGE_INDEX_ENTRY_EXISTS(entry->our_entry) || !GIT_MERGE_INDEX_ENTRY_EXISTS(entry->their_entry))) (*src_count)++; else if (!GIT_MERGE_INDEX_ENTRY_EXISTS(entry->ancestor_entry)) (*tgt_count)++; } } int git_merge_diff_list__find_renames( git_repository *repo, git_merge_diff_list *diff_list, const git_merge_options *opts) { struct merge_diff_similarity *similarity_ours, *similarity_theirs; void **cache = NULL; size_t cache_size = 0; size_t src_count, tgt_count, i; int error = 0; assert(diff_list && opts); if ((opts->tree_flags & GIT_MERGE_TREE_FIND_RENAMES) == 0) return 0; similarity_ours = git__calloc(diff_list->conflicts.length, sizeof(struct merge_diff_similarity)); GITERR_CHECK_ALLOC(similarity_ours); similarity_theirs = git__calloc(diff_list->conflicts.length, sizeof(struct merge_diff_similarity)); GITERR_CHECK_ALLOC(similarity_theirs); /* Calculate similarity between items that were deleted from the ancestor * and added in the other branch. */ if ((error = merge_diff_mark_similarity(repo, diff_list, similarity_ours, similarity_theirs, index_entry_similarity_exact, NULL, opts)) < 0) goto done; if (diff_list->conflicts.length <= opts->target_limit) { GITERR_CHECK_ALLOC_MULTIPLY(&cache_size, diff_list->conflicts.length, 3); cache = git__calloc(cache_size, sizeof(void *)); GITERR_CHECK_ALLOC(cache); merge_diff_list_count_candidates(diff_list, &src_count, &tgt_count); if (src_count > opts->target_limit || tgt_count > opts->target_limit) { /* TODO: report! */ } else { if ((error = merge_diff_mark_similarity( repo, diff_list, similarity_ours, similarity_theirs, index_entry_similarity_inexact, cache, opts)) < 0) goto done; } } /* For entries that are appropriately similar, merge the new name's entry * into the old name. */ merge_diff_list_coalesce_renames(diff_list, similarity_ours, similarity_theirs, opts); /* And remove any entries that were merged and are now empty. */ git_vector_remove_matching(&diff_list->conflicts, merge_diff_empty, NULL); done: if (cache != NULL) { for (i = 0; i < cache_size; ++i) { if (cache[i] != NULL) opts->metric->free_signature(cache[i], opts->metric->payload); } git__free(cache); } git__free(similarity_ours); git__free(similarity_theirs); return error; } /* Directory/file conflict handling */ GIT_INLINE(const char *) merge_diff_path( const git_merge_diff *conflict) { if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry)) return conflict->ancestor_entry.path; else if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry)) return conflict->our_entry.path; else if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry)) return conflict->their_entry.path; return NULL; } GIT_INLINE(bool) merge_diff_any_side_added_or_modified( const git_merge_diff *conflict) { if (conflict->our_status == GIT_DELTA_ADDED || conflict->our_status == GIT_DELTA_MODIFIED || conflict->their_status == GIT_DELTA_ADDED || conflict->their_status == GIT_DELTA_MODIFIED) return true; return false; } GIT_INLINE(bool) path_is_prefixed(const char *parent, const char *child) { size_t child_len = strlen(child); size_t parent_len = strlen(parent); if (child_len < parent_len || strncmp(parent, child, parent_len) != 0) return 0; return (child[parent_len] == '/'); } GIT_INLINE(int) merge_diff_detect_df_conflict( struct merge_diff_df_data *df_data, git_merge_diff *conflict) { const char *cur_path = merge_diff_path(conflict); /* Determine if this is a D/F conflict or the child of one */ if (df_data->df_path && path_is_prefixed(df_data->df_path, cur_path)) conflict->type = GIT_MERGE_DIFF_DF_CHILD; else if(df_data->df_path) df_data->df_path = NULL; else if (df_data->prev_path && merge_diff_any_side_added_or_modified(df_data->prev_conflict) && merge_diff_any_side_added_or_modified(conflict) && path_is_prefixed(df_data->prev_path, cur_path)) { conflict->type = GIT_MERGE_DIFF_DF_CHILD; df_data->prev_conflict->type = GIT_MERGE_DIFF_DIRECTORY_FILE; df_data->df_path = df_data->prev_path; } df_data->prev_path = cur_path; df_data->prev_conflict = conflict; return 0; } /* Conflict handling */ GIT_INLINE(int) merge_diff_detect_type( git_merge_diff *conflict) { if (conflict->our_status == GIT_DELTA_ADDED && conflict->their_status == GIT_DELTA_ADDED) conflict->type = GIT_MERGE_DIFF_BOTH_ADDED; else if (conflict->our_status == GIT_DELTA_MODIFIED && conflict->their_status == GIT_DELTA_MODIFIED) conflict->type = GIT_MERGE_DIFF_BOTH_MODIFIED; else if (conflict->our_status == GIT_DELTA_DELETED && conflict->their_status == GIT_DELTA_DELETED) conflict->type = GIT_MERGE_DIFF_BOTH_DELETED; else if (conflict->our_status == GIT_DELTA_MODIFIED && conflict->their_status == GIT_DELTA_DELETED) conflict->type = GIT_MERGE_DIFF_MODIFIED_DELETED; else if (conflict->our_status == GIT_DELTA_DELETED && conflict->their_status == GIT_DELTA_MODIFIED) conflict->type = GIT_MERGE_DIFF_MODIFIED_DELETED; else conflict->type = GIT_MERGE_DIFF_NONE; return 0; } GIT_INLINE(int) index_entry_dup_pool( git_index_entry *out, git_pool *pool, const git_index_entry *src) { if (src != NULL) { memcpy(out, src, sizeof(git_index_entry)); if ((out->path = git_pool_strdup(pool, src->path)) == NULL) return -1; } return 0; } GIT_INLINE(int) merge_delta_type_from_index_entries( const git_index_entry *ancestor, const git_index_entry *other) { if (ancestor == NULL && other == NULL) return GIT_DELTA_UNMODIFIED; else if (ancestor == NULL && other != NULL) return GIT_DELTA_ADDED; else if (ancestor != NULL && other == NULL) return GIT_DELTA_DELETED; else if (S_ISDIR(ancestor->mode) ^ S_ISDIR(other->mode)) return GIT_DELTA_TYPECHANGE; else if(S_ISLNK(ancestor->mode) ^ S_ISLNK(other->mode)) return GIT_DELTA_TYPECHANGE; else if (git_oid__cmp(&ancestor->id, &other->id) || ancestor->mode != other->mode) return GIT_DELTA_MODIFIED; return GIT_DELTA_UNMODIFIED; } static git_merge_diff *merge_diff_from_index_entries( git_merge_diff_list *diff_list, const git_index_entry **entries) { git_merge_diff *conflict; git_pool *pool = &diff_list->pool; if ((conflict = git_pool_malloc(pool, sizeof(git_merge_diff))) == NULL) return NULL; if (index_entry_dup_pool(&conflict->ancestor_entry, pool, entries[TREE_IDX_ANCESTOR]) < 0 || index_entry_dup_pool(&conflict->our_entry, pool, entries[TREE_IDX_OURS]) < 0 || index_entry_dup_pool(&conflict->their_entry, pool, entries[TREE_IDX_THEIRS]) < 0) return NULL; conflict->our_status = merge_delta_type_from_index_entries( entries[TREE_IDX_ANCESTOR], entries[TREE_IDX_OURS]); conflict->their_status = merge_delta_type_from_index_entries( entries[TREE_IDX_ANCESTOR], entries[TREE_IDX_THEIRS]); return conflict; } /* Merge trees */ static int merge_diff_list_insert_conflict( git_merge_diff_list *diff_list, struct merge_diff_df_data *merge_df_data, const git_index_entry *tree_items[3]) { git_merge_diff *conflict; if ((conflict = merge_diff_from_index_entries(diff_list, tree_items)) == NULL || merge_diff_detect_type(conflict) < 0 || merge_diff_detect_df_conflict(merge_df_data, conflict) < 0 || git_vector_insert(&diff_list->conflicts, conflict) < 0) return -1; return 0; } static int merge_diff_list_insert_unmodified( git_merge_diff_list *diff_list, const git_index_entry *tree_items[3]) { int error = 0; git_index_entry *entry; entry = git_pool_malloc(&diff_list->pool, sizeof(git_index_entry)); GITERR_CHECK_ALLOC(entry); if ((error = index_entry_dup_pool(entry, &diff_list->pool, tree_items[0])) >= 0) error = git_vector_insert(&diff_list->staged, entry); return error; } struct merge_diff_find_data { git_merge_diff_list *diff_list; struct merge_diff_df_data df_data; }; static int queue_difference(const git_index_entry **entries, void *data) { struct merge_diff_find_data *find_data = data; bool item_modified = false; size_t i; if (!entries[0] || !entries[1] || !entries[2]) { item_modified = true; } else { for (i = 1; i < 3; i++) { if (index_entry_cmp(entries[0], entries[i]) != 0) { item_modified = true; break; } } } return item_modified ? merge_diff_list_insert_conflict( find_data->diff_list, &find_data->df_data, entries) : merge_diff_list_insert_unmodified(find_data->diff_list, entries); } int git_merge_diff_list__find_differences( git_merge_diff_list *diff_list, git_iterator *ancestor_iter, git_iterator *our_iter, git_iterator *their_iter) { git_iterator *iterators[3] = { ancestor_iter, our_iter, their_iter }; struct merge_diff_find_data find_data = { diff_list }; return git_iterator_walk(iterators, 3, queue_difference, &find_data); } git_merge_diff_list *git_merge_diff_list__alloc(git_repository *repo) { git_merge_diff_list *diff_list = git__calloc(1, sizeof(git_merge_diff_list)); if (diff_list == NULL) return NULL; diff_list->repo = repo; if (git_vector_init(&diff_list->staged, 0, NULL) < 0 || git_vector_init(&diff_list->conflicts, 0, NULL) < 0 || git_vector_init(&diff_list->resolved, 0, NULL) < 0 || git_pool_init(&diff_list->pool, 1, 0) < 0) { git_merge_diff_list__free(diff_list); return NULL; } return diff_list; } void git_merge_diff_list__free(git_merge_diff_list *diff_list) { if (!diff_list) return; git_vector_free(&diff_list->staged); git_vector_free(&diff_list->conflicts); git_vector_free(&diff_list->resolved); git_pool_clear(&diff_list->pool); git__free(diff_list); } static int merge_normalize_opts( git_repository *repo, git_merge_options *opts, const git_merge_options *given) { git_config *cfg = NULL; int error = 0; assert(repo && opts); if ((error = git_repository_config__weakptr(&cfg, repo)) < 0) return error; if (given != NULL) memcpy(opts, given, sizeof(git_merge_options)); else { git_merge_options init = GIT_MERGE_OPTIONS_INIT; memcpy(opts, &init, sizeof(init)); opts->tree_flags = GIT_MERGE_TREE_FIND_RENAMES; opts->rename_threshold = GIT_MERGE_TREE_RENAME_THRESHOLD; } if (!opts->target_limit) { int limit = git_config__get_int_force(cfg, "merge.renamelimit", 0); if (!limit) limit = git_config__get_int_force(cfg, "diff.renamelimit", 0); opts->target_limit = (limit <= 0) ? GIT_MERGE_TREE_TARGET_LIMIT : (unsigned int)limit; } /* assign the internal metric with whitespace flag as payload */ if (!opts->metric) { opts->metric = git__malloc(sizeof(git_diff_similarity_metric)); GITERR_CHECK_ALLOC(opts->metric); opts->metric->file_signature = git_diff_find_similar__hashsig_for_file; opts->metric->buffer_signature = git_diff_find_similar__hashsig_for_buf; opts->metric->free_signature = git_diff_find_similar__hashsig_free; opts->metric->similarity = git_diff_find_similar__calc_similarity; opts->metric->payload = (void *)GIT_HASHSIG_SMART_WHITESPACE; } return 0; } static int merge_index_insert_reuc( git_index *index, size_t idx, const git_index_entry *entry) { const git_index_reuc_entry *reuc; int mode[3] = { 0, 0, 0 }; git_oid const *oid[3] = { NULL, NULL, NULL }; size_t i; if (!GIT_MERGE_INDEX_ENTRY_EXISTS(*entry)) return 0; if ((reuc = git_index_reuc_get_bypath(index, entry->path)) != NULL) { for (i = 0; i < 3; i++) { mode[i] = reuc->mode[i]; oid[i] = &reuc->oid[i]; } } mode[idx] = entry->mode; oid[idx] = &entry->id; return git_index_reuc_add(index, entry->path, mode[0], oid[0], mode[1], oid[1], mode[2], oid[2]); } int index_from_diff_list(git_index **out, git_merge_diff_list *diff_list) { git_index *index; size_t i; git_index_entry *entry; git_merge_diff *conflict; int error = 0; *out = NULL; if ((error = git_index_new(&index)) < 0) return error; git_vector_foreach(&diff_list->staged, i, entry) { if ((error = git_index_add(index, entry)) < 0) goto on_error; } git_vector_foreach(&diff_list->conflicts, i, conflict) { const git_index_entry *ancestor = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry) ? &conflict->ancestor_entry : NULL; const git_index_entry *ours = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ? &conflict->our_entry : NULL; const git_index_entry *theirs = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry) ? &conflict->their_entry : NULL; if ((error = git_index_conflict_add(index, ancestor, ours, theirs)) < 0) goto on_error; } /* Add each rename entry to the rename portion of the index. */ git_vector_foreach(&diff_list->conflicts, i, conflict) { const char *ancestor_path, *our_path, *their_path; if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry)) continue; ancestor_path = conflict->ancestor_entry.path; our_path = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ? conflict->our_entry.path : NULL; their_path = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry) ? conflict->their_entry.path : NULL; if ((our_path && strcmp(ancestor_path, our_path) != 0) || (their_path && strcmp(ancestor_path, their_path) != 0)) { if ((error = git_index_name_add(index, ancestor_path, our_path, their_path)) < 0) goto on_error; } } /* Add each entry in the resolved conflict to the REUC independently, since * the paths may differ due to renames. */ git_vector_foreach(&diff_list->resolved, i, conflict) { const git_index_entry *ancestor = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry) ? &conflict->ancestor_entry : NULL; const git_index_entry *ours = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ? &conflict->our_entry : NULL; const git_index_entry *theirs = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry) ? &conflict->their_entry : NULL; if (ancestor != NULL && (error = merge_index_insert_reuc(index, TREE_IDX_ANCESTOR, ancestor)) < 0) goto on_error; if (ours != NULL && (error = merge_index_insert_reuc(index, TREE_IDX_OURS, ours)) < 0) goto on_error; if (theirs != NULL && (error = merge_index_insert_reuc(index, TREE_IDX_THEIRS, theirs)) < 0) goto on_error; } *out = index; return 0; on_error: git_index_free(index); return error; } static git_iterator *iterator_given_or_empty(git_iterator **empty, git_iterator *given) { git_iterator_options opts = GIT_ITERATOR_OPTIONS_INIT; if (given) return given; opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE; if (git_iterator_for_nothing(empty, &opts) < 0) return NULL; return *empty; } int git_merge__iterators( git_index **out, git_repository *repo, git_iterator *ancestor_iter, git_iterator *our_iter, git_iterator *theirs_iter, const git_merge_options *given_opts) { git_iterator *empty_ancestor = NULL, *empty_ours = NULL, *empty_theirs = NULL; git_merge_diff_list *diff_list; git_merge_options opts; git_merge_diff *conflict; git_vector changes; size_t i; int error = 0; assert(out && repo); *out = NULL; GITERR_CHECK_VERSION( given_opts, GIT_MERGE_OPTIONS_VERSION, "git_merge_options"); if ((error = merge_normalize_opts(repo, &opts, given_opts)) < 0) return error; diff_list = git_merge_diff_list__alloc(repo); GITERR_CHECK_ALLOC(diff_list); ancestor_iter = iterator_given_or_empty(&empty_ancestor, ancestor_iter); our_iter = iterator_given_or_empty(&empty_ours, our_iter); theirs_iter = iterator_given_or_empty(&empty_theirs, theirs_iter); if ((error = git_merge_diff_list__find_differences( diff_list, ancestor_iter, our_iter, theirs_iter)) < 0 || (error = git_merge_diff_list__find_renames(repo, diff_list, &opts)) < 0) goto done; memcpy(&changes, &diff_list->conflicts, sizeof(git_vector)); git_vector_clear(&diff_list->conflicts); git_vector_foreach(&changes, i, conflict) { int resolved = 0; if ((error = merge_conflict_resolve(&resolved, diff_list, conflict, opts.file_favor, opts.file_flags)) < 0) goto done; if (!resolved) git_vector_insert(&diff_list->conflicts, conflict); } if (!given_opts || !given_opts->metric) git__free(opts.metric); error = index_from_diff_list(out, diff_list); done: git_merge_diff_list__free(diff_list); git_iterator_free(empty_ancestor); git_iterator_free(empty_ours); git_iterator_free(empty_theirs); return error; } int git_merge_trees( git_index **out, git_repository *repo, const git_tree *ancestor_tree, const git_tree *our_tree, const git_tree *their_tree, const git_merge_options *merge_opts) { git_iterator *ancestor_iter = NULL, *our_iter = NULL, *their_iter = NULL; git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT; int error; iter_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE; if ((error = git_iterator_for_tree( &ancestor_iter, (git_tree *)ancestor_tree, &iter_opts)) < 0 || (error = git_iterator_for_tree( &our_iter, (git_tree *)our_tree, &iter_opts)) < 0 || (error = git_iterator_for_tree( &their_iter, (git_tree *)their_tree, &iter_opts)) < 0) goto done; error = git_merge__iterators( out, repo, ancestor_iter, our_iter, their_iter, merge_opts); done: git_iterator_free(ancestor_iter); git_iterator_free(our_iter); git_iterator_free(their_iter); return error; } int git_merge_commits( git_index **out, git_repository *repo, const git_commit *our_commit, const git_commit *their_commit, const git_merge_options *opts) { git_oid ancestor_oid; git_commit *ancestor_commit = NULL; git_tree *our_tree = NULL, *their_tree = NULL, *ancestor_tree = NULL; int error = 0; if ((error = git_merge_base(&ancestor_oid, repo, git_commit_id(our_commit), git_commit_id(their_commit))) < 0 && error == GIT_ENOTFOUND) giterr_clear(); else if (error < 0 || (error = git_commit_lookup(&ancestor_commit, repo, &ancestor_oid)) < 0 || (error = git_commit_tree(&ancestor_tree, ancestor_commit)) < 0) goto done; if ((error = git_commit_tree(&our_tree, our_commit)) < 0 || (error = git_commit_tree(&their_tree, their_commit)) < 0 || (error = git_merge_trees(out, repo, ancestor_tree, our_tree, their_tree, opts)) < 0) goto done; done: git_commit_free(ancestor_commit); git_tree_free(our_tree); git_tree_free(their_tree); git_tree_free(ancestor_tree); return error; } /* Merge setup / cleanup */ static int write_merge_head( git_repository *repo, const git_annotated_commit *heads[], size_t heads_len) { git_filebuf file = GIT_FILEBUF_INIT; git_buf file_path = GIT_BUF_INIT; size_t i; int error = 0; assert(repo && heads); if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_HEAD_FILE)) < 0 || (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) < 0) goto cleanup; for (i = 0; i < heads_len; i++) { if ((error = git_filebuf_printf(&file, "%s\n", heads[i]->id_str)) < 0) goto cleanup; } error = git_filebuf_commit(&file); cleanup: if (error < 0) git_filebuf_cleanup(&file); git_buf_free(&file_path); return error; } static int write_merge_mode(git_repository *repo) { git_filebuf file = GIT_FILEBUF_INIT; git_buf file_path = GIT_BUF_INIT; int error = 0; assert(repo); if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MODE_FILE)) < 0 || (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) < 0) goto cleanup; if ((error = git_filebuf_write(&file, "no-ff", 5)) < 0) goto cleanup; error = git_filebuf_commit(&file); cleanup: if (error < 0) git_filebuf_cleanup(&file); git_buf_free(&file_path); return error; } struct merge_msg_entry { const git_annotated_commit *merge_head; bool written; }; static int msg_entry_is_branch( const struct merge_msg_entry *entry, git_vector *entries) { GIT_UNUSED(entries); return (entry->written == 0 && entry->merge_head->remote_url == NULL && entry->merge_head->ref_name != NULL && git__strncmp(GIT_REFS_HEADS_DIR, entry->merge_head->ref_name, strlen(GIT_REFS_HEADS_DIR)) == 0); } static int msg_entry_is_tracking( const struct merge_msg_entry *entry, git_vector *entries) { GIT_UNUSED(entries); return (entry->written == 0 && entry->merge_head->remote_url == NULL && entry->merge_head->ref_name != NULL && git__strncmp(GIT_REFS_REMOTES_DIR, entry->merge_head->ref_name, strlen(GIT_REFS_REMOTES_DIR)) == 0); } static int msg_entry_is_tag( const struct merge_msg_entry *entry, git_vector *entries) { GIT_UNUSED(entries); return (entry->written == 0 && entry->merge_head->remote_url == NULL && entry->merge_head->ref_name != NULL && git__strncmp(GIT_REFS_TAGS_DIR, entry->merge_head->ref_name, strlen(GIT_REFS_TAGS_DIR)) == 0); } static int msg_entry_is_remote( const struct merge_msg_entry *entry, git_vector *entries) { if (entry->written == 0 && entry->merge_head->remote_url != NULL && entry->merge_head->ref_name != NULL && git__strncmp(GIT_REFS_HEADS_DIR, entry->merge_head->ref_name, strlen(GIT_REFS_HEADS_DIR)) == 0) { struct merge_msg_entry *existing; /* Match only branches from the same remote */ if (entries->length == 0) return 1; existing = git_vector_get(entries, 0); return (git__strcmp(existing->merge_head->remote_url, entry->merge_head->remote_url) == 0); } return 0; } static int msg_entry_is_oid( const struct merge_msg_entry *merge_msg_entry) { return (merge_msg_entry->written == 0 && merge_msg_entry->merge_head->ref_name == NULL && merge_msg_entry->merge_head->remote_url == NULL); } static int merge_msg_entry_written( const struct merge_msg_entry *merge_msg_entry) { return (merge_msg_entry->written == 1); } static int merge_msg_entries( git_vector *v, const struct merge_msg_entry *entries, size_t len, int (*match)(const struct merge_msg_entry *entry, git_vector *entries)) { size_t i; int matches, total = 0; git_vector_clear(v); for (i = 0; i < len; i++) { if ((matches = match(&entries[i], v)) < 0) return matches; else if (!matches) continue; git_vector_insert(v, (struct merge_msg_entry *)&entries[i]); total++; } return total; } static int merge_msg_write_entries( git_filebuf *file, git_vector *entries, const char *item_name, const char *item_plural_name, size_t ref_name_skip, const char *source, char sep) { struct merge_msg_entry *entry; size_t i; int error = 0; if (entries->length == 0) return 0; if (sep && (error = git_filebuf_printf(file, "%c ", sep)) < 0) goto done; if ((error = git_filebuf_printf(file, "%s ", (entries->length == 1) ? item_name : item_plural_name)) < 0) goto done; git_vector_foreach(entries, i, entry) { if (i > 0 && (error = git_filebuf_printf(file, "%s", (i == entries->length - 1) ? " and " : ", ")) < 0) goto done; if ((error = git_filebuf_printf(file, "'%s'", entry->merge_head->ref_name + ref_name_skip)) < 0) goto done; entry->written = 1; } if (source) error = git_filebuf_printf(file, " of %s", source); done: return error; } static int merge_msg_write_branches( git_filebuf *file, git_vector *entries, char sep) { return merge_msg_write_entries(file, entries, "branch", "branches", strlen(GIT_REFS_HEADS_DIR), NULL, sep); } static int merge_msg_write_tracking( git_filebuf *file, git_vector *entries, char sep) { return merge_msg_write_entries(file, entries, "remote-tracking branch", "remote-tracking branches", 0, NULL, sep); } static int merge_msg_write_tags( git_filebuf *file, git_vector *entries, char sep) { return merge_msg_write_entries(file, entries, "tag", "tags", strlen(GIT_REFS_TAGS_DIR), NULL, sep); } static int merge_msg_write_remotes( git_filebuf *file, git_vector *entries, char sep) { const char *source; if (entries->length == 0) return 0; source = ((struct merge_msg_entry *)entries->contents[0])->merge_head->remote_url; return merge_msg_write_entries(file, entries, "branch", "branches", strlen(GIT_REFS_HEADS_DIR), source, sep); } static int write_merge_msg( git_repository *repo, const git_annotated_commit *heads[], size_t heads_len) { git_filebuf file = GIT_FILEBUF_INIT; git_buf file_path = GIT_BUF_INIT; struct merge_msg_entry *entries; git_vector matching = GIT_VECTOR_INIT; size_t i; char sep = 0; int error = 0; assert(repo && heads); entries = git__calloc(heads_len, sizeof(struct merge_msg_entry)); GITERR_CHECK_ALLOC(entries); if (git_vector_init(&matching, heads_len, NULL) < 0) { git__free(entries); return -1; } for (i = 0; i < heads_len; i++) entries[i].merge_head = heads[i]; if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MSG_FILE)) < 0 || (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) < 0 || (error = git_filebuf_write(&file, "Merge ", 6)) < 0) goto cleanup; /* * This is to emulate the format of MERGE_MSG by core git. * * Core git will write all the commits specified by OID, in the order * provided, until the first named branch or tag is reached, at which * point all branches will be written in the order provided, then all * tags, then all remote tracking branches and finally all commits that * were specified by OID that were not already written. * * Yes. Really. */ for (i = 0; i < heads_len; i++) { if (!msg_entry_is_oid(&entries[i])) break; if ((error = git_filebuf_printf(&file, "%scommit '%s'", (i > 0) ? "; " : "", entries[i].merge_head->id_str)) < 0) goto cleanup; entries[i].written = 1; } if (i) sep = ';'; if ((error = merge_msg_entries(&matching, entries, heads_len, msg_entry_is_branch)) < 0 || (error = merge_msg_write_branches(&file, &matching, sep)) < 0) goto cleanup; if (matching.length) sep =','; if ((error = merge_msg_entries(&matching, entries, heads_len, msg_entry_is_tracking)) < 0 || (error = merge_msg_write_tracking(&file, &matching, sep)) < 0) goto cleanup; if (matching.length) sep =','; if ((error = merge_msg_entries(&matching, entries, heads_len, msg_entry_is_tag)) < 0 || (error = merge_msg_write_tags(&file, &matching, sep)) < 0) goto cleanup; if (matching.length) sep =','; /* We should never be called with multiple remote branches, but handle * it in case we are... */ while ((error = merge_msg_entries(&matching, entries, heads_len, msg_entry_is_remote)) > 0) { if ((error = merge_msg_write_remotes(&file, &matching, sep)) < 0) goto cleanup; if (matching.length) sep =','; } if (error < 0) goto cleanup; for (i = 0; i < heads_len; i++) { if (merge_msg_entry_written(&entries[i])) continue; if ((error = git_filebuf_printf(&file, "; commit '%s'", entries[i].merge_head->id_str)) < 0) goto cleanup; } if ((error = git_filebuf_printf(&file, "\n")) < 0 || (error = git_filebuf_commit(&file)) < 0) goto cleanup; cleanup: if (error < 0) git_filebuf_cleanup(&file); git_buf_free(&file_path); git_vector_free(&matching); git__free(entries); return error; } int git_merge__setup( git_repository *repo, const git_annotated_commit *our_head, const git_annotated_commit *heads[], size_t heads_len) { int error = 0; assert (repo && our_head && heads); if ((error = git_repository__set_orig_head(repo, git_annotated_commit_id(our_head))) == 0 && (error = write_merge_head(repo, heads, heads_len)) == 0 && (error = write_merge_mode(repo)) == 0) { error = write_merge_msg(repo, heads, heads_len); } return error; } /* Merge branches */ static int merge_ancestor_head( git_annotated_commit **ancestor_head, git_repository *repo, const git_annotated_commit *our_head, const git_annotated_commit **their_heads, size_t their_heads_len) { git_oid *oids, ancestor_oid; size_t i, alloc_len; int error = 0; assert(repo && our_head && their_heads); GITERR_CHECK_ALLOC_ADD(&alloc_len, their_heads_len, 1); oids = git__calloc(alloc_len, sizeof(git_oid)); GITERR_CHECK_ALLOC(oids); git_oid_cpy(&oids[0], git_commit_id(our_head->commit)); for (i = 0; i < their_heads_len; i++) git_oid_cpy(&oids[i + 1], git_annotated_commit_id(their_heads[i])); if ((error = git_merge_base_many(&ancestor_oid, repo, their_heads_len + 1, oids)) < 0) goto on_error; error = git_annotated_commit_lookup(ancestor_head, repo, &ancestor_oid); on_error: git__free(oids); return error; } const char *merge_their_label(const char *branchname) { const char *slash; if ((slash = strrchr(branchname, '/')) == NULL) return branchname; if (*(slash+1) == '\0') return "theirs"; return slash+1; } static int merge_normalize_checkout_opts( git_repository *repo, git_checkout_options *checkout_opts, const git_checkout_options *given_checkout_opts, const git_annotated_commit *ancestor_head, const git_annotated_commit *our_head, size_t their_heads_len, const git_annotated_commit **their_heads) { int error = 0; GIT_UNUSED(repo); if (given_checkout_opts != NULL) memcpy(checkout_opts, given_checkout_opts, sizeof(git_checkout_options)); else { git_checkout_options default_checkout_opts = GIT_CHECKOUT_OPTIONS_INIT; default_checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE; memcpy(checkout_opts, &default_checkout_opts, sizeof(git_checkout_options)); } /* TODO: for multiple ancestors in merge-recursive, this is "merged common ancestors" */ if (!checkout_opts->ancestor_label) { if (ancestor_head && ancestor_head->commit) checkout_opts->ancestor_label = git_commit_summary(ancestor_head->commit); else checkout_opts->ancestor_label = "ancestor"; } if (!checkout_opts->our_label) { if (our_head && our_head->ref_name) checkout_opts->our_label = our_head->ref_name; else checkout_opts->our_label = "ours"; } if (!checkout_opts->their_label) { if (their_heads_len == 1 && their_heads[0]->ref_name) checkout_opts->their_label = merge_their_label(their_heads[0]->ref_name); else if (their_heads_len == 1) checkout_opts->their_label = their_heads[0]->id_str; else checkout_opts->their_label = "theirs"; } return error; } static int merge_check_index(size_t *conflicts, git_repository *repo, git_index *index_new, git_vector *merged_paths) { git_tree *head_tree = NULL; git_index *index_repo = NULL; git_iterator *iter_repo = NULL, *iter_new = NULL; git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT; git_diff *staged_diff_list = NULL, *index_diff_list = NULL; git_diff_delta *delta; git_diff_options opts = GIT_DIFF_OPTIONS_INIT; git_vector staged_paths = GIT_VECTOR_INIT; size_t i; int error = 0; GIT_UNUSED(merged_paths); *conflicts = 0; /* No staged changes may exist unless the change staged is identical to * the result of the merge. This allows one to apply to merge manually, * then run merge. Any other staged change would be overwritten by * a reset merge. */ if ((error = git_repository_head_tree(&head_tree, repo)) < 0 || (error = git_repository_index(&index_repo, repo)) < 0 || (error = git_diff_tree_to_index(&staged_diff_list, repo, head_tree, index_repo, &opts)) < 0) goto done; if (staged_diff_list->deltas.length == 0) goto done; git_vector_foreach(&staged_diff_list->deltas, i, delta) { if ((error = git_vector_insert(&staged_paths, (char *)delta->new_file.path)) < 0) goto done; } iter_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE; iter_opts.pathlist.strings = (char **)staged_paths.contents; iter_opts.pathlist.count = staged_paths.length; if ((error = git_iterator_for_index(&iter_repo, index_repo, &iter_opts)) < 0 || (error = git_iterator_for_index(&iter_new, index_new, &iter_opts)) < 0 || (error = git_diff__from_iterators(&index_diff_list, repo, iter_repo, iter_new, &opts)) < 0) goto done; *conflicts = index_diff_list->deltas.length; done: git_tree_free(head_tree); git_index_free(index_repo); git_iterator_free(iter_repo); git_iterator_free(iter_new); git_diff_free(staged_diff_list); git_diff_free(index_diff_list); git_vector_free(&staged_paths); return error; } static int merge_check_workdir(size_t *conflicts, git_repository *repo, git_index *index_new, git_vector *merged_paths) { git_diff *wd_diff_list = NULL; git_diff_options opts = GIT_DIFF_OPTIONS_INIT; int error = 0; GIT_UNUSED(index_new); *conflicts = 0; /* We need to have merged at least 1 file for the possibility to exist to * have conflicts with the workdir. Passing 0 as the pathspec count paramter * will consider all files in the working directory, that is, we may detect * a conflict if there were untracked files in the workdir prior to starting * the merge. This typically happens when cherry-picking a commmit whose * changes have already been applied. */ if (merged_paths->length == 0) return 0; opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED; /* Workdir changes may exist iff they do not conflict with changes that * will be applied by the merge (including conflicts). Ensure that there * are no changes in the workdir to these paths. */ opts.flags |= GIT_DIFF_DISABLE_PATHSPEC_MATCH; opts.pathspec.count = merged_paths->length; opts.pathspec.strings = (char **)merged_paths->contents; if ((error = git_diff_index_to_workdir(&wd_diff_list, repo, NULL, &opts)) < 0) goto done; *conflicts = wd_diff_list->deltas.length; done: git_diff_free(wd_diff_list); return error; } int git_merge__check_result(git_repository *repo, git_index *index_new) { git_tree *head_tree = NULL; git_iterator *iter_head = NULL, *iter_new = NULL; git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT; git_diff *merged_list = NULL; git_diff_options opts = GIT_DIFF_OPTIONS_INIT; git_diff_delta *delta; git_vector paths = GIT_VECTOR_INIT; size_t i, index_conflicts = 0, wd_conflicts = 0, conflicts; const git_index_entry *e; int error = 0; iter_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE; if ((error = git_repository_head_tree(&head_tree, repo)) < 0 || (error = git_iterator_for_tree(&iter_head, head_tree, &iter_opts)) < 0 || (error = git_iterator_for_index(&iter_new, index_new, &iter_opts)) < 0 || (error = git_diff__from_iterators(&merged_list, repo, iter_head, iter_new, &opts)) < 0) goto done; git_vector_foreach(&merged_list->deltas, i, delta) { if ((error = git_vector_insert(&paths, (char *)delta->new_file.path)) < 0) goto done; } for (i = 0; i < git_index_entrycount(index_new); i++) { e = git_index_get_byindex(index_new, i); if (git_index_entry_is_conflict(e) && (git_vector_last(&paths) == NULL || strcmp(git_vector_last(&paths), e->path) != 0)) { if ((error = git_vector_insert(&paths, (char *)e->path)) < 0) goto done; } } /* Make sure the index and workdir state do not prevent merging */ if ((error = merge_check_index(&index_conflicts, repo, index_new, &paths)) < 0 || (error = merge_check_workdir(&wd_conflicts, repo, index_new, &paths)) < 0) goto done; if ((conflicts = index_conflicts + wd_conflicts) > 0) { giterr_set(GITERR_MERGE, "%" PRIuZ " uncommitted change%s would be overwritten by merge", conflicts, (conflicts != 1) ? "s" : ""); error = GIT_ECONFLICT; } done: git_vector_free(&paths); git_tree_free(head_tree); git_iterator_free(iter_head); git_iterator_free(iter_new); git_diff_free(merged_list); return error; } int git_merge__append_conflicts_to_merge_msg( git_repository *repo, git_index *index) { git_filebuf file = GIT_FILEBUF_INIT; git_buf file_path = GIT_BUF_INIT; const char *last = NULL; size_t i; int error; if (!git_index_has_conflicts(index)) return 0; if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MSG_FILE)) < 0 || (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_APPEND, GIT_MERGE_FILE_MODE)) < 0) goto cleanup; git_filebuf_printf(&file, "\nConflicts:\n"); for (i = 0; i < git_index_entrycount(index); i++) { const git_index_entry *e = git_index_get_byindex(index, i); if (!git_index_entry_is_conflict(e)) continue; if (last == NULL || strcmp(e->path, last) != 0) git_filebuf_printf(&file, "\t%s\n", e->path); last = e->path; } error = git_filebuf_commit(&file); cleanup: if (error < 0) git_filebuf_cleanup(&file); git_buf_free(&file_path); return error; } static int merge_state_cleanup(git_repository *repo) { const char *state_files[] = { GIT_MERGE_HEAD_FILE, GIT_MERGE_MODE_FILE, GIT_MERGE_MSG_FILE, }; return git_repository__cleanup_files(repo, state_files, ARRAY_SIZE(state_files)); } static int merge_heads( git_annotated_commit **ancestor_head_out, git_annotated_commit **our_head_out, git_repository *repo, const git_annotated_commit **their_heads, size_t their_heads_len) { git_annotated_commit *ancestor_head = NULL, *our_head = NULL; git_reference *our_ref = NULL; int error = 0; *ancestor_head_out = NULL; *our_head_out = NULL; if ((error = git_repository__ensure_not_bare(repo, "merge")) < 0) goto done; if ((error = git_reference_lookup(&our_ref, repo, GIT_HEAD_FILE)) < 0 || (error = git_annotated_commit_from_ref(&our_head, repo, our_ref)) < 0) goto done; if ((error = merge_ancestor_head(&ancestor_head, repo, our_head, their_heads, their_heads_len)) < 0) { if (error != GIT_ENOTFOUND) goto done; giterr_clear(); error = 0; } *ancestor_head_out = ancestor_head; *our_head_out = our_head; done: if (error < 0) { git_annotated_commit_free(ancestor_head); git_annotated_commit_free(our_head); } git_reference_free(our_ref); return error; } static int merge_preference(git_merge_preference_t *out, git_repository *repo) { git_config *config; const char *value; int bool_value, error = 0; *out = GIT_MERGE_PREFERENCE_NONE; if ((error = git_repository_config_snapshot(&config, repo)) < 0) goto done; if ((error = git_config_get_string(&value, config, "merge.ff")) < 0) { if (error == GIT_ENOTFOUND) { giterr_clear(); error = 0; } goto done; } if (git_config_parse_bool(&bool_value, value) == 0) { if (!bool_value) *out |= GIT_MERGE_PREFERENCE_NO_FASTFORWARD; } else { if (strcasecmp(value, "only") == 0) *out |= GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY; } done: git_config_free(config); return error; } int git_merge_analysis( git_merge_analysis_t *analysis_out, git_merge_preference_t *preference_out, git_repository *repo, const git_annotated_commit **their_heads, size_t their_heads_len) { git_annotated_commit *ancestor_head = NULL, *our_head = NULL; int error = 0; assert(analysis_out && preference_out && repo && their_heads); if (their_heads_len != 1) { giterr_set(GITERR_MERGE, "Can only merge a single branch"); error = -1; goto done; } *analysis_out = GIT_MERGE_ANALYSIS_NONE; if ((error = merge_preference(preference_out, repo)) < 0) goto done; if (git_repository_head_unborn(repo)) { *analysis_out |= GIT_MERGE_ANALYSIS_FASTFORWARD | GIT_MERGE_ANALYSIS_UNBORN; goto done; } if ((error = merge_heads(&ancestor_head, &our_head, repo, their_heads, their_heads_len)) < 0) goto done; /* We're up-to-date if we're trying to merge our own common ancestor. */ if (ancestor_head && git_oid_equal( git_annotated_commit_id(ancestor_head), git_annotated_commit_id(their_heads[0]))) *analysis_out |= GIT_MERGE_ANALYSIS_UP_TO_DATE; /* We're fastforwardable if we're our own common ancestor. */ else if (ancestor_head && git_oid_equal( git_annotated_commit_id(ancestor_head), git_annotated_commit_id(our_head))) *analysis_out |= GIT_MERGE_ANALYSIS_FASTFORWARD | GIT_MERGE_ANALYSIS_NORMAL; /* Otherwise, just a normal merge is possible. */ else *analysis_out |= GIT_MERGE_ANALYSIS_NORMAL; done: git_annotated_commit_free(ancestor_head); git_annotated_commit_free(our_head); return error; } int git_merge( git_repository *repo, const git_annotated_commit **their_heads, size_t their_heads_len, const git_merge_options *merge_opts, const git_checkout_options *given_checkout_opts) { git_reference *our_ref = NULL; git_checkout_options checkout_opts; git_annotated_commit *ancestor_head = NULL, *our_head = NULL; git_tree *ancestor_tree = NULL, *our_tree = NULL, **their_trees = NULL; git_index *index = NULL; git_indexwriter indexwriter = GIT_INDEXWRITER_INIT; size_t i; int error = 0; assert(repo && their_heads); if (their_heads_len != 1) { giterr_set(GITERR_MERGE, "Can only merge a single branch"); return -1; } their_trees = git__calloc(their_heads_len, sizeof(git_tree *)); GITERR_CHECK_ALLOC(their_trees); if ((error = merge_heads(&ancestor_head, &our_head, repo, their_heads, their_heads_len)) < 0 || (error = merge_normalize_checkout_opts(repo, &checkout_opts, given_checkout_opts, ancestor_head, our_head, their_heads_len, their_heads)) < 0 || (error = git_indexwriter_init_for_operation(&indexwriter, repo, &checkout_opts.checkout_strategy)) < 0) goto on_error; /* Write the merge files to the repository. */ if ((error = git_merge__setup(repo, our_head, their_heads, their_heads_len)) < 0) goto on_error; if (ancestor_head != NULL && (error = git_commit_tree(&ancestor_tree, ancestor_head->commit)) < 0) goto on_error; if ((error = git_commit_tree(&our_tree, our_head->commit)) < 0) goto on_error; for (i = 0; i < their_heads_len; i++) { if ((error = git_commit_tree(&their_trees[i], their_heads[i]->commit)) < 0) goto on_error; } /* TODO: recursive, octopus, etc... */ if ((error = git_merge_trees(&index, repo, ancestor_tree, our_tree, their_trees[0], merge_opts)) < 0 || (error = git_merge__check_result(repo, index)) < 0 || (error = git_merge__append_conflicts_to_merge_msg(repo, index)) < 0 || (error = git_checkout_index(repo, index, &checkout_opts)) < 0 || (error = git_indexwriter_commit(&indexwriter)) < 0) goto on_error; goto done; on_error: merge_state_cleanup(repo); done: git_indexwriter_cleanup(&indexwriter); git_index_free(index); git_tree_free(ancestor_tree); git_tree_free(our_tree); for (i = 0; i < their_heads_len; i++) git_tree_free(their_trees[i]); git__free(their_trees); git_annotated_commit_free(our_head); git_annotated_commit_free(ancestor_head); git_reference_free(our_ref); return error; } int git_merge_init_options(git_merge_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_merge_options, GIT_MERGE_OPTIONS_INIT); return 0; } int git_merge_file_init_input(git_merge_file_input *input, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( input, version, git_merge_file_input, GIT_MERGE_FILE_INPUT_INIT); return 0; } int git_merge_file_init_options( git_merge_file_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_merge_file_options, GIT_MERGE_FILE_OPTIONS_INIT); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/tree.h0000664000175000017500000000267412510265101015004 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_tree_h__ #define INCLUDE_tree_h__ #include "git2/tree.h" #include "repository.h" #include "odb.h" #include "vector.h" #include "strmap.h" struct git_tree_entry { uint16_t attr; git_oid oid; size_t filename_len; char filename[1]; }; struct git_tree { git_object object; git_vector entries; }; struct git_treebuilder { git_repository *repo; git_strmap *map; }; GIT_INLINE(bool) git_tree_entry__is_tree(const struct git_tree_entry *e) { return (S_ISDIR(e->attr) && !S_ISGITLINK(e->attr)); } extern int git_tree_entry_icmp(const git_tree_entry *e1, const git_tree_entry *e2); void git_tree__free(void *tree); int git_tree__parse(void *tree, git_odb_object *obj); /** * Lookup the first position in the tree with a given prefix. * * @param tree a previously loaded tree. * @param prefix the beginning of a path to find in the tree. * @return index of the first item at or after the given prefix. */ int git_tree__prefix_position(const git_tree *tree, const char *prefix); /** * Write a tree to the given repository */ int git_tree__write_index( git_oid *oid, git_index *index, git_repository *repo); /** * Obsolete mode kept for compatibility reasons */ #define GIT_FILEMODE_BLOB_GROUP_WRITABLE 0100664 #endif deps/libgit2-sys-0.3.8/libgit2/src/integer.h0000664000175000017500000000507412510265101015477 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_integer_h__ #define INCLUDE_integer_h__ /** @return true if p fits into the range of a size_t */ GIT_INLINE(int) git__is_sizet(git_off_t p) { size_t r = (size_t)p; return p == (git_off_t)r; } /** @return true if p fits into the range of an ssize_t */ GIT_INLINE(int) git__is_ssizet(size_t p) { ssize_t r = (ssize_t)p; return p == (size_t)r; } /** @return true if p fits into the range of a uint32_t */ GIT_INLINE(int) git__is_uint32(size_t p) { uint32_t r = (uint32_t)p; return p == (size_t)r; } /** @return true if p fits into the range of an unsigned long */ GIT_INLINE(int) git__is_ulong(git_off_t p) { unsigned long r = (unsigned long)p; return p == (git_off_t)r; } /** @return true if p fits into the range of an int */ GIT_INLINE(int) git__is_int(long long p) { int r = (int)p; return p == (long long)r; } /** * Sets `one + two` into `out`, unless the arithmetic would overflow. * @return true if the result fits in a `uint64_t`, false on overflow. */ GIT_INLINE(bool) git__add_uint64_overflow(uint64_t *out, uint64_t one, uint64_t two) { if (UINT64_MAX - one < two) return true; *out = one + two; return false; } /* Use clang/gcc compiler intrinsics whenever possible */ #if (SIZE_MAX == UINT_MAX) && __has_builtin(__builtin_uadd_overflow) # define git__add_sizet_overflow(out, one, two) \ __builtin_uadd_overflow(one, two, out) # define git__multiply_sizet_overflow(out, one, two) \ __builtin_umul_overflow(one, two, out) #elif (SIZE_MAX == ULONG_MAX) && __has_builtin(__builtin_uaddl_overflow) # define git__add_sizet_overflow(out, one, two) \ __builtin_uaddl_overflow(one, two, out) # define git__multiply_sizet_overflow(out, one, two) \ __builtin_umull_overflow(one, two, out) #else /** * Sets `one + two` into `out`, unless the arithmetic would overflow. * @return true if the result fits in a `size_t`, false on overflow. */ GIT_INLINE(bool) git__add_sizet_overflow(size_t *out, size_t one, size_t two) { if (SIZE_MAX - one < two) return true; *out = one + two; return false; } /** * Sets `one * two` into `out`, unless the arithmetic would overflow. * @return true if the result fits in a `size_t`, false on overflow. */ GIT_INLINE(bool) git__multiply_sizet_overflow(size_t *out, size_t one, size_t two) { if (one && SIZE_MAX / one < two) return true; *out = one * two; return false; } #endif #endif /* INCLUDE_integer_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/status.h0000664000175000017500000000071512426525445015402 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_status_h__ #define INCLUDE_status_h__ #include "diff.h" #include "git2/status.h" #include "git2/diff.h" struct git_status_list { git_status_options opts; git_diff *head2idx; git_diff *idx2wd; git_vector paired; }; #endif deps/libgit2-sys-0.3.8/libgit2/src/pack.c0000664000175000017500000010031212572105236014754 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "odb.h" #include "pack.h" #include "delta-apply.h" #include "sha1_lookup.h" #include "mwindow.h" #include "fileops.h" #include "oid.h" #include GIT__USE_OFFMAP GIT__USE_OIDMAP static int packfile_open(struct git_pack_file *p); static git_off_t nth_packed_object_offset(const struct git_pack_file *p, uint32_t n); int packfile_unpack_compressed( git_rawobj *obj, struct git_pack_file *p, git_mwindow **w_curs, git_off_t *curpos, size_t size, git_otype type); /* Can find the offset of an object given * a prefix of an identifier. * Throws GIT_EAMBIGUOUSOIDPREFIX if short oid * is ambiguous within the pack. * This method assumes that len is between * GIT_OID_MINPREFIXLEN and GIT_OID_HEXSZ. */ static int pack_entry_find_offset( git_off_t *offset_out, git_oid *found_oid, struct git_pack_file *p, const git_oid *short_oid, size_t len); static int packfile_error(const char *message) { giterr_set(GITERR_ODB, "Invalid pack file - %s", message); return -1; } /******************** * Delta base cache ********************/ static git_pack_cache_entry *new_cache_object(git_rawobj *source) { git_pack_cache_entry *e = git__calloc(1, sizeof(git_pack_cache_entry)); if (!e) return NULL; git_atomic_inc(&e->refcount); memcpy(&e->raw, source, sizeof(git_rawobj)); return e; } static void free_cache_object(void *o) { git_pack_cache_entry *e = (git_pack_cache_entry *)o; if (e != NULL) { assert(e->refcount.val == 0); git__free(e->raw.data); git__free(e); } } static void cache_free(git_pack_cache *cache) { khiter_t k; if (cache->entries) { for (k = kh_begin(cache->entries); k != kh_end(cache->entries); k++) { if (kh_exist(cache->entries, k)) free_cache_object(kh_value(cache->entries, k)); } git_offmap_free(cache->entries); cache->entries = NULL; } } static int cache_init(git_pack_cache *cache) { cache->entries = git_offmap_alloc(); GITERR_CHECK_ALLOC(cache->entries); cache->memory_limit = GIT_PACK_CACHE_MEMORY_LIMIT; if (git_mutex_init(&cache->lock)) { giterr_set(GITERR_OS, "Failed to initialize pack cache mutex"); git__free(cache->entries); cache->entries = NULL; return -1; } return 0; } static git_pack_cache_entry *cache_get(git_pack_cache *cache, git_off_t offset) { khiter_t k; git_pack_cache_entry *entry = NULL; if (git_mutex_lock(&cache->lock) < 0) return NULL; k = kh_get(off, cache->entries, offset); if (k != kh_end(cache->entries)) { /* found it */ entry = kh_value(cache->entries, k); git_atomic_inc(&entry->refcount); entry->last_usage = cache->use_ctr++; } git_mutex_unlock(&cache->lock); return entry; } /* Run with the cache lock held */ static void free_lowest_entry(git_pack_cache *cache) { git_pack_cache_entry *entry; khiter_t k; for (k = kh_begin(cache->entries); k != kh_end(cache->entries); k++) { if (!kh_exist(cache->entries, k)) continue; entry = kh_value(cache->entries, k); if (entry && entry->refcount.val == 0) { cache->memory_used -= entry->raw.len; kh_del(off, cache->entries, k); free_cache_object(entry); } } } static int cache_add( git_pack_cache_entry **cached_out, git_pack_cache *cache, git_rawobj *base, git_off_t offset) { git_pack_cache_entry *entry; int error, exists = 0; khiter_t k; if (base->len > GIT_PACK_CACHE_SIZE_LIMIT) return -1; entry = new_cache_object(base); if (entry) { if (git_mutex_lock(&cache->lock) < 0) { giterr_set(GITERR_OS, "failed to lock cache"); git__free(entry); return -1; } /* Add it to the cache if nobody else has */ exists = kh_get(off, cache->entries, offset) != kh_end(cache->entries); if (!exists) { while (cache->memory_used + base->len > cache->memory_limit) free_lowest_entry(cache); k = kh_put(off, cache->entries, offset, &error); assert(error != 0); kh_value(cache->entries, k) = entry; cache->memory_used += entry->raw.len; *cached_out = entry; } git_mutex_unlock(&cache->lock); /* Somebody beat us to adding it into the cache */ if (exists) { git__free(entry); return -1; } } return 0; } /*********************************************************** * * PACK INDEX METHODS * ***********************************************************/ static void pack_index_free(struct git_pack_file *p) { if (p->oids) { git__free(p->oids); p->oids = NULL; } if (p->index_map.data) { git_futils_mmap_free(&p->index_map); p->index_map.data = NULL; } } static int pack_index_check(const char *path, struct git_pack_file *p) { struct git_pack_idx_header *hdr; uint32_t version, nr, i, *index; void *idx_map; size_t idx_size; struct stat st; int error; /* TODO: properly open the file without access time using O_NOATIME */ git_file fd = git_futils_open_ro(path); if (fd < 0) return fd; if (p_fstat(fd, &st) < 0) { p_close(fd); giterr_set(GITERR_OS, "Unable to stat pack index '%s'", path); return -1; } if (!S_ISREG(st.st_mode) || !git__is_sizet(st.st_size) || (idx_size = (size_t)st.st_size) < 4 * 256 + 20 + 20) { p_close(fd); giterr_set(GITERR_ODB, "Invalid pack index '%s'", path); return -1; } error = git_futils_mmap_ro(&p->index_map, fd, 0, idx_size); p_close(fd); if (error < 0) return error; hdr = idx_map = p->index_map.data; if (hdr->idx_signature == htonl(PACK_IDX_SIGNATURE)) { version = ntohl(hdr->idx_version); if (version < 2 || version > 2) { git_futils_mmap_free(&p->index_map); return packfile_error("unsupported index version"); } } else version = 1; nr = 0; index = idx_map; if (version > 1) index += 2; /* skip index header */ for (i = 0; i < 256; i++) { uint32_t n = ntohl(index[i]); if (n < nr) { git_futils_mmap_free(&p->index_map); return packfile_error("index is non-monotonic"); } nr = n; } if (version == 1) { /* * Total size: * - 256 index entries 4 bytes each * - 24-byte entries * nr (20-byte sha1 + 4-byte offset) * - 20-byte SHA1 of the packfile * - 20-byte SHA1 file checksum */ if (idx_size != 4*256 + nr * 24 + 20 + 20) { git_futils_mmap_free(&p->index_map); return packfile_error("index is corrupted"); } } else if (version == 2) { /* * Minimum size: * - 8 bytes of header * - 256 index entries 4 bytes each * - 20-byte sha1 entry * nr * - 4-byte crc entry * nr * - 4-byte offset entry * nr * - 20-byte SHA1 of the packfile * - 20-byte SHA1 file checksum * And after the 4-byte offset table might be a * variable sized table containing 8-byte entries * for offsets larger than 2^31. */ unsigned long min_size = 8 + 4*256 + nr*(20 + 4 + 4) + 20 + 20; unsigned long max_size = min_size; if (nr) max_size += (nr - 1)*8; if (idx_size < min_size || idx_size > max_size) { git_futils_mmap_free(&p->index_map); return packfile_error("wrong index size"); } } p->num_objects = nr; p->index_version = version; return 0; } static int pack_index_open(struct git_pack_file *p) { int error = 0; size_t name_len; git_buf idx_name = GIT_BUF_INIT; if (p->index_version > -1) return 0; name_len = strlen(p->pack_name); assert(name_len > strlen(".pack")); /* checked by git_pack_file alloc */ git_buf_grow(&idx_name, name_len); git_buf_put(&idx_name, p->pack_name, name_len - strlen(".pack")); git_buf_puts(&idx_name, ".idx"); if (git_buf_oom(&idx_name)) { giterr_set_oom(); return -1; } if ((error = git_mutex_lock(&p->lock)) < 0) { git_buf_free(&idx_name); return error; } if (p->index_version == -1) error = pack_index_check(idx_name.ptr, p); git_buf_free(&idx_name); git_mutex_unlock(&p->lock); return error; } static unsigned char *pack_window_open( struct git_pack_file *p, git_mwindow **w_cursor, git_off_t offset, unsigned int *left) { if (p->mwf.fd == -1 && packfile_open(p) < 0) return NULL; /* Since packfiles end in a hash of their content and it's * pointless to ask for an offset into the middle of that * hash, and the pack_window_contains function above wouldn't match * don't allow an offset too close to the end of the file. */ if (offset > (p->mwf.size - 20)) return NULL; return git_mwindow_open(&p->mwf, w_cursor, offset, 20, left); } /* * The per-object header is a pretty dense thing, which is * - first byte: low four bits are "size", * then three bits of "type", * with the high bit being "size continues". * - each byte afterwards: low seven bits are size continuation, * with the high bit being "size continues" */ size_t git_packfile__object_header(unsigned char *hdr, size_t size, git_otype type) { unsigned char *hdr_base; unsigned char c; assert(type >= GIT_OBJ_COMMIT && type <= GIT_OBJ_REF_DELTA); /* TODO: add support for chunked objects; see git.git 6c0d19b1 */ c = (unsigned char)((type << 4) | (size & 15)); size >>= 4; hdr_base = hdr; while (size) { *hdr++ = c | 0x80; c = size & 0x7f; size >>= 7; } *hdr++ = c; return (hdr - hdr_base); } static int packfile_unpack_header1( unsigned long *usedp, size_t *sizep, git_otype *type, const unsigned char *buf, unsigned long len) { unsigned shift; unsigned long size, c; unsigned long used = 0; c = buf[used++]; *type = (c >> 4) & 7; size = c & 15; shift = 4; while (c & 0x80) { if (len <= used) { giterr_set(GITERR_ODB, "buffer too small"); return GIT_EBUFS; } if (bitsizeof(long) <= shift) { *usedp = 0; giterr_set(GITERR_ODB, "packfile corrupted"); return -1; } c = buf[used++]; size += (c & 0x7f) << shift; shift += 7; } *sizep = (size_t)size; *usedp = used; return 0; } int git_packfile_unpack_header( size_t *size_p, git_otype *type_p, git_mwindow_file *mwf, git_mwindow **w_curs, git_off_t *curpos) { unsigned char *base; unsigned int left; unsigned long used; int ret; /* pack_window_open() assures us we have [base, base + 20) available * as a range that we can look at at. (Its actually the hash * size that is assured.) With our object header encoding * the maximum deflated object size is 2^137, which is just * insane, so we know won't exceed what we have been given. */ /* base = pack_window_open(p, w_curs, *curpos, &left); */ base = git_mwindow_open(mwf, w_curs, *curpos, 20, &left); if (base == NULL) return GIT_EBUFS; ret = packfile_unpack_header1(&used, size_p, type_p, base, left); git_mwindow_close(w_curs); if (ret == GIT_EBUFS) return ret; else if (ret < 0) return packfile_error("header length is zero"); *curpos += used; return 0; } int git_packfile_resolve_header( size_t *size_p, git_otype *type_p, struct git_pack_file *p, git_off_t offset) { git_mwindow *w_curs = NULL; git_off_t curpos = offset; size_t size; git_otype type; git_off_t base_offset; int error; error = git_packfile_unpack_header(&size, &type, &p->mwf, &w_curs, &curpos); git_mwindow_close(&w_curs); if (error < 0) return error; if (type == GIT_OBJ_OFS_DELTA || type == GIT_OBJ_REF_DELTA) { size_t base_size; git_rawobj delta; base_offset = get_delta_base(p, &w_curs, &curpos, type, offset); git_mwindow_close(&w_curs); error = packfile_unpack_compressed(&delta, p, &w_curs, &curpos, size, type); git_mwindow_close(&w_curs); if (error < 0) return error; error = git__delta_read_header(delta.data, delta.len, &base_size, size_p); git__free(delta.data); if (error < 0) return error; } else *size_p = size; while (type == GIT_OBJ_OFS_DELTA || type == GIT_OBJ_REF_DELTA) { curpos = base_offset; error = git_packfile_unpack_header(&size, &type, &p->mwf, &w_curs, &curpos); git_mwindow_close(&w_curs); if (error < 0) return error; if (type != GIT_OBJ_OFS_DELTA && type != GIT_OBJ_REF_DELTA) break; base_offset = get_delta_base(p, &w_curs, &curpos, type, base_offset); git_mwindow_close(&w_curs); } *type_p = type; return error; } #define SMALL_STACK_SIZE 64 /** * Generate the chain of dependencies which we need to get to the * object at `off`. `chain` is used a stack, popping gives the right * order to apply deltas on. If an object is found in the pack's base * cache, we stop calculating there. */ static int pack_dependency_chain(git_dependency_chain *chain_out, git_pack_cache_entry **cached_out, git_off_t *cached_off, struct pack_chain_elem *small_stack, size_t *stack_sz, struct git_pack_file *p, git_off_t obj_offset) { git_dependency_chain chain = GIT_ARRAY_INIT; git_mwindow *w_curs = NULL; git_off_t curpos = obj_offset, base_offset; int error = 0, use_heap = 0; size_t size, elem_pos; git_otype type; elem_pos = 0; while (true) { struct pack_chain_elem *elem; git_pack_cache_entry *cached = NULL; /* if we have a base cached, we can stop here instead */ if ((cached = cache_get(&p->bases, obj_offset)) != NULL) { *cached_out = cached; *cached_off = obj_offset; break; } /* if we run out of space on the small stack, use the array */ if (elem_pos == SMALL_STACK_SIZE) { git_array_init_to_size(chain, elem_pos); GITERR_CHECK_ARRAY(chain); memcpy(chain.ptr, small_stack, elem_pos * sizeof(struct pack_chain_elem)); chain.size = elem_pos; use_heap = 1; } curpos = obj_offset; if (!use_heap) { elem = &small_stack[elem_pos]; } else { elem = git_array_alloc(chain); if (!elem) { error = -1; goto on_error; } } elem->base_key = obj_offset; error = git_packfile_unpack_header(&size, &type, &p->mwf, &w_curs, &curpos); git_mwindow_close(&w_curs); if (error < 0) goto on_error; elem->offset = curpos; elem->size = size; elem->type = type; elem->base_key = obj_offset; if (type != GIT_OBJ_OFS_DELTA && type != GIT_OBJ_REF_DELTA) break; base_offset = get_delta_base(p, &w_curs, &curpos, type, obj_offset); git_mwindow_close(&w_curs); if (base_offset == 0) { error = packfile_error("delta offset is zero"); goto on_error; } if (base_offset < 0) { /* must actually be an error code */ error = (int)base_offset; goto on_error; } /* we need to pass the pos *after* the delta-base bit */ elem->offset = curpos; /* go through the loop again, but with the new object */ obj_offset = base_offset; elem_pos++; } *stack_sz = elem_pos + 1; *chain_out = chain; return error; on_error: git_array_clear(chain); return error; } int git_packfile_unpack( git_rawobj *obj, struct git_pack_file *p, git_off_t *obj_offset) { git_mwindow *w_curs = NULL; git_off_t curpos = *obj_offset; int error, free_base = 0; git_dependency_chain chain = GIT_ARRAY_INIT; struct pack_chain_elem *elem = NULL, *stack; git_pack_cache_entry *cached = NULL; struct pack_chain_elem small_stack[SMALL_STACK_SIZE]; size_t stack_size = 0, elem_pos, alloclen; git_otype base_type; /* * TODO: optionally check the CRC on the packfile */ error = pack_dependency_chain(&chain, &cached, obj_offset, small_stack, &stack_size, p, *obj_offset); if (error < 0) return error; obj->data = NULL; obj->len = 0; obj->type = GIT_OBJ_BAD; /* let's point to the right stack */ stack = chain.ptr ? chain.ptr : small_stack; elem_pos = stack_size; if (cached) { memcpy(obj, &cached->raw, sizeof(git_rawobj)); base_type = obj->type; elem_pos--; /* stack_size includes the base, which isn't actually there */ } else { elem = &stack[--elem_pos]; base_type = elem->type; } switch (base_type) { case GIT_OBJ_COMMIT: case GIT_OBJ_TREE: case GIT_OBJ_BLOB: case GIT_OBJ_TAG: if (!cached) { curpos = elem->offset; error = packfile_unpack_compressed(obj, p, &w_curs, &curpos, elem->size, elem->type); git_mwindow_close(&w_curs); base_type = elem->type; } if (error < 0) goto cleanup; break; case GIT_OBJ_OFS_DELTA: case GIT_OBJ_REF_DELTA: error = packfile_error("dependency chain ends in a delta"); goto cleanup; default: error = packfile_error("invalid packfile type in header"); goto cleanup; } /* * Finding the object we want a cached base element is * problematic, as we need to make sure we don't accidentally * give the caller the cached object, which it would then feel * free to free, so we need to copy the data. */ if (cached && stack_size == 1) { void *data = obj->data; GITERR_CHECK_ALLOC_ADD(&alloclen, obj->len, 1); obj->data = git__malloc(alloclen); GITERR_CHECK_ALLOC(obj->data); memcpy(obj->data, data, obj->len + 1); git_atomic_dec(&cached->refcount); goto cleanup; } /* we now apply each consecutive delta until we run out */ while (elem_pos > 0 && !error) { git_rawobj base, delta; /* * We can now try to add the base to the cache, as * long as it's not already the cached one. */ if (!cached) free_base = !!cache_add(&cached, &p->bases, obj, elem->base_key); elem = &stack[elem_pos - 1]; curpos = elem->offset; error = packfile_unpack_compressed(&delta, p, &w_curs, &curpos, elem->size, elem->type); git_mwindow_close(&w_curs); if (error < 0) break; /* the current object becomes the new base, on which we apply the delta */ base = *obj; obj->data = NULL; obj->len = 0; obj->type = GIT_OBJ_BAD; error = git__delta_apply(obj, base.data, base.len, delta.data, delta.len); obj->type = base_type; /* * We usually don't want to free the base at this * point, as we put it into the cache in the previous * iteration. free_base lets us know that we got the * base object directly from the packfile, so we can free it. */ git__free(delta.data); if (free_base) { free_base = 0; git__free(base.data); } if (cached) { git_atomic_dec(&cached->refcount); cached = NULL; } if (error < 0) break; elem_pos--; } cleanup: if (error < 0) git__free(obj->data); if (elem) *obj_offset = curpos; git_array_clear(chain); return error; } static void *use_git_alloc(void *opaq, unsigned int count, unsigned int size) { GIT_UNUSED(opaq); return git__calloc(count, size); } static void use_git_free(void *opaq, void *ptr) { GIT_UNUSED(opaq); git__free(ptr); } int git_packfile_stream_open(git_packfile_stream *obj, struct git_pack_file *p, git_off_t curpos) { int st; memset(obj, 0, sizeof(git_packfile_stream)); obj->curpos = curpos; obj->p = p; obj->zstream.zalloc = use_git_alloc; obj->zstream.zfree = use_git_free; obj->zstream.next_in = Z_NULL; obj->zstream.next_out = Z_NULL; st = inflateInit(&obj->zstream); if (st != Z_OK) { git__free(obj); giterr_set(GITERR_ZLIB, "failed to init packfile stream"); return -1; } return 0; } ssize_t git_packfile_stream_read(git_packfile_stream *obj, void *buffer, size_t len) { unsigned char *in; size_t written; int st; if (obj->done) return 0; in = pack_window_open(obj->p, &obj->mw, obj->curpos, &obj->zstream.avail_in); if (in == NULL) return GIT_EBUFS; obj->zstream.next_out = buffer; obj->zstream.avail_out = (unsigned int)len; obj->zstream.next_in = in; st = inflate(&obj->zstream, Z_SYNC_FLUSH); git_mwindow_close(&obj->mw); obj->curpos += obj->zstream.next_in - in; written = len - obj->zstream.avail_out; if (st != Z_OK && st != Z_STREAM_END) { giterr_set(GITERR_ZLIB, "error reading from the zlib stream"); return -1; } if (st == Z_STREAM_END) obj->done = 1; /* If we didn't write anything out but we're not done, we need more data */ if (!written && st != Z_STREAM_END) return GIT_EBUFS; return written; } void git_packfile_stream_free(git_packfile_stream *obj) { inflateEnd(&obj->zstream); } int packfile_unpack_compressed( git_rawobj *obj, struct git_pack_file *p, git_mwindow **w_curs, git_off_t *curpos, size_t size, git_otype type) { size_t buf_size; int st; z_stream stream; unsigned char *buffer, *in; GITERR_CHECK_ALLOC_ADD(&buf_size, size, 1); buffer = git__calloc(1, buf_size); GITERR_CHECK_ALLOC(buffer); memset(&stream, 0, sizeof(stream)); stream.next_out = buffer; stream.avail_out = (uInt)buf_size; stream.zalloc = use_git_alloc; stream.zfree = use_git_free; st = inflateInit(&stream); if (st != Z_OK) { git__free(buffer); giterr_set(GITERR_ZLIB, "failed to init zlib stream on unpack"); return -1; } do { in = pack_window_open(p, w_curs, *curpos, &stream.avail_in); stream.next_in = in; st = inflate(&stream, Z_FINISH); git_mwindow_close(w_curs); if (!stream.avail_out) break; /* the payload is larger than it should be */ if (st == Z_BUF_ERROR && in == NULL) { inflateEnd(&stream); git__free(buffer); return GIT_EBUFS; } *curpos += stream.next_in - in; } while (st == Z_OK || st == Z_BUF_ERROR); inflateEnd(&stream); if ((st != Z_STREAM_END) || stream.total_out != size) { git__free(buffer); giterr_set(GITERR_ZLIB, "error inflating zlib stream"); return -1; } obj->type = type; obj->len = size; obj->data = buffer; return 0; } /* * curpos is where the data starts, delta_obj_offset is the where the * header starts */ git_off_t get_delta_base( struct git_pack_file *p, git_mwindow **w_curs, git_off_t *curpos, git_otype type, git_off_t delta_obj_offset) { unsigned int left = 0; unsigned char *base_info; git_off_t base_offset; git_oid unused; base_info = pack_window_open(p, w_curs, *curpos, &left); /* Assumption: the only reason this would fail is because the file is too small */ if (base_info == NULL) return GIT_EBUFS; /* pack_window_open() assured us we have [base_info, base_info + 20) * as a range that we can look at without walking off the * end of the mapped window. Its actually the hash size * that is assured. An OFS_DELTA longer than the hash size * is stupid, as then a REF_DELTA would be smaller to store. */ if (type == GIT_OBJ_OFS_DELTA) { unsigned used = 0; unsigned char c = base_info[used++]; base_offset = c & 127; while (c & 128) { if (left <= used) return GIT_EBUFS; base_offset += 1; if (!base_offset || MSB(base_offset, 7)) return 0; /* overflow */ c = base_info[used++]; base_offset = (base_offset << 7) + (c & 127); } base_offset = delta_obj_offset - base_offset; if (base_offset <= 0 || base_offset >= delta_obj_offset) return 0; /* out of bound */ *curpos += used; } else if (type == GIT_OBJ_REF_DELTA) { /* If we have the cooperative cache, search in it first */ if (p->has_cache) { khiter_t k; git_oid oid; git_oid_fromraw(&oid, base_info); k = kh_get(oid, p->idx_cache, &oid); if (k != kh_end(p->idx_cache)) { *curpos += 20; return ((struct git_pack_entry *)kh_value(p->idx_cache, k))->offset; } else { /* If we're building an index, don't try to find the pack * entry; we just haven't seen it yet. We'll make * progress again in the next loop. */ return GIT_PASSTHROUGH; } } /* The base entry _must_ be in the same pack */ if (pack_entry_find_offset(&base_offset, &unused, p, (git_oid *)base_info, GIT_OID_HEXSZ) < 0) return packfile_error("base entry delta is not in the same pack"); *curpos += 20; } else return 0; return base_offset; } /*********************************************************** * * PACKFILE METHODS * ***********************************************************/ void git_packfile_free(struct git_pack_file *p) { if (!p) return; cache_free(&p->bases); if (p->mwf.fd >= 0) { git_mwindow_free_all_locked(&p->mwf); p_close(p->mwf.fd); } pack_index_free(p); git__free(p->bad_object_sha1); git_mutex_free(&p->lock); git_mutex_free(&p->bases.lock); git__free(p); } static int packfile_open(struct git_pack_file *p) { struct stat st; struct git_pack_header hdr; git_oid sha1; unsigned char *idx_sha1; if (p->index_version == -1 && pack_index_open(p) < 0) return git_odb__error_notfound("failed to open packfile", NULL); /* if mwf opened by another thread, return now */ if (git_mutex_lock(&p->lock) < 0) return packfile_error("failed to get lock for open"); if (p->mwf.fd >= 0) { git_mutex_unlock(&p->lock); return 0; } /* TODO: open with noatime */ p->mwf.fd = git_futils_open_ro(p->pack_name); if (p->mwf.fd < 0) goto cleanup; if (p_fstat(p->mwf.fd, &st) < 0 || git_mwindow_file_register(&p->mwf) < 0) goto cleanup; /* If we created the struct before we had the pack we lack size. */ if (!p->mwf.size) { if (!S_ISREG(st.st_mode)) goto cleanup; p->mwf.size = (git_off_t)st.st_size; } else if (p->mwf.size != st.st_size) goto cleanup; #if 0 /* We leave these file descriptors open with sliding mmap; * there is no point keeping them open across exec(), though. */ fd_flag = fcntl(p->mwf.fd, F_GETFD, 0); if (fd_flag < 0) goto cleanup; fd_flag |= FD_CLOEXEC; if (fcntl(p->pack_fd, F_SETFD, fd_flag) == -1) goto cleanup; #endif /* Verify we recognize this pack file format. */ if (p_read(p->mwf.fd, &hdr, sizeof(hdr)) < 0 || hdr.hdr_signature != htonl(PACK_SIGNATURE) || !pack_version_ok(hdr.hdr_version)) goto cleanup; /* Verify the pack matches its index. */ if (p->num_objects != ntohl(hdr.hdr_entries) || p_lseek(p->mwf.fd, p->mwf.size - GIT_OID_RAWSZ, SEEK_SET) == -1 || p_read(p->mwf.fd, sha1.id, GIT_OID_RAWSZ) < 0) goto cleanup; idx_sha1 = ((unsigned char *)p->index_map.data) + p->index_map.len - 40; if (git_oid__cmp(&sha1, (git_oid *)idx_sha1) != 0) goto cleanup; git_mutex_unlock(&p->lock); return 0; cleanup: giterr_set(GITERR_OS, "Invalid packfile '%s'", p->pack_name); if (p->mwf.fd >= 0) p_close(p->mwf.fd); p->mwf.fd = -1; git_mutex_unlock(&p->lock); return -1; } int git_packfile__name(char **out, const char *path) { size_t path_len; git_buf buf = GIT_BUF_INIT; path_len = strlen(path); if (path_len < strlen(".idx")) return git_odb__error_notfound("invalid packfile path", NULL); if (git_buf_printf(&buf, "%.*s.pack", (int)(path_len - strlen(".idx")), path) < 0) return -1; *out = git_buf_detach(&buf); return 0; } int git_packfile_alloc(struct git_pack_file **pack_out, const char *path) { struct stat st; struct git_pack_file *p; size_t path_len = path ? strlen(path) : 0, alloc_len; *pack_out = NULL; if (path_len < strlen(".idx")) return git_odb__error_notfound("invalid packfile path", NULL); GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*p), path_len); GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2); p = git__calloc(1, alloc_len); GITERR_CHECK_ALLOC(p); memcpy(p->pack_name, path, path_len + 1); /* * Make sure a corresponding .pack file exists and that * the index looks sane. */ if (git__suffixcmp(path, ".idx") == 0) { size_t root_len = path_len - strlen(".idx"); memcpy(p->pack_name + root_len, ".keep", sizeof(".keep")); if (git_path_exists(p->pack_name) == true) p->pack_keep = 1; memcpy(p->pack_name + root_len, ".pack", sizeof(".pack")); } if (p_stat(p->pack_name, &st) < 0 || !S_ISREG(st.st_mode)) { git__free(p); return git_odb__error_notfound("packfile not found", NULL); } /* ok, it looks sane as far as we can check without * actually mapping the pack file. */ p->mwf.fd = -1; p->mwf.size = st.st_size; p->pack_local = 1; p->mtime = (git_time_t)st.st_mtime; p->index_version = -1; if (git_mutex_init(&p->lock)) { giterr_set(GITERR_OS, "Failed to initialize packfile mutex"); git__free(p); return -1; } if (cache_init(&p->bases) < 0) { git__free(p); return -1; } *pack_out = p; return 0; } /*********************************************************** * * PACKFILE ENTRY SEARCH INTERNALS * ***********************************************************/ static git_off_t nth_packed_object_offset(const struct git_pack_file *p, uint32_t n) { const unsigned char *index = p->index_map.data; index += 4 * 256; if (p->index_version == 1) { return ntohl(*((uint32_t *)(index + 24 * n))); } else { uint32_t off; index += 8 + p->num_objects * (20 + 4); off = ntohl(*((uint32_t *)(index + 4 * n))); if (!(off & 0x80000000)) return off; index += p->num_objects * 4 + (off & 0x7fffffff) * 8; return (((uint64_t)ntohl(*((uint32_t *)(index + 0)))) << 32) | ntohl(*((uint32_t *)(index + 4))); } } static int git__memcmp4(const void *a, const void *b) { return memcmp(a, b, 4); } int git_pack_foreach_entry( struct git_pack_file *p, git_odb_foreach_cb cb, void *data) { const unsigned char *index = p->index_map.data, *current; uint32_t i; int error = 0; if (index == NULL) { if ((error = pack_index_open(p)) < 0) return error; assert(p->index_map.data); index = p->index_map.data; } if (p->index_version > 1) { index += 8; } index += 4 * 256; if (p->oids == NULL) { git_vector offsets, oids; if ((error = git_vector_init(&oids, p->num_objects, NULL))) return error; if ((error = git_vector_init(&offsets, p->num_objects, git__memcmp4))) return error; if (p->index_version > 1) { const unsigned char *off = index + 24 * p->num_objects; for (i = 0; i < p->num_objects; i++) git_vector_insert(&offsets, (void*)&off[4 * i]); git_vector_sort(&offsets); git_vector_foreach(&offsets, i, current) git_vector_insert(&oids, (void*)&index[5 * (current - off)]); } else { for (i = 0; i < p->num_objects; i++) git_vector_insert(&offsets, (void*)&index[24 * i]); git_vector_sort(&offsets); git_vector_foreach(&offsets, i, current) git_vector_insert(&oids, (void*)¤t[4]); } git_vector_free(&offsets); p->oids = (git_oid **)git_vector_detach(NULL, NULL, &oids); } for (i = 0; i < p->num_objects; i++) if ((error = cb(p->oids[i], data)) != 0) return giterr_set_after_callback(error); return error; } static int pack_entry_find_offset( git_off_t *offset_out, git_oid *found_oid, struct git_pack_file *p, const git_oid *short_oid, size_t len) { const uint32_t *level1_ofs = p->index_map.data; const unsigned char *index = p->index_map.data; unsigned hi, lo, stride; int pos, found = 0; const unsigned char *current = 0; *offset_out = 0; if (p->index_version == -1) { int error; if ((error = pack_index_open(p)) < 0) return error; assert(p->index_map.data); index = p->index_map.data; level1_ofs = p->index_map.data; } if (p->index_version > 1) { level1_ofs += 2; index += 8; } index += 4 * 256; hi = ntohl(level1_ofs[(int)short_oid->id[0]]); lo = ((short_oid->id[0] == 0x0) ? 0 : ntohl(level1_ofs[(int)short_oid->id[0] - 1])); if (p->index_version > 1) { stride = 20; } else { stride = 24; index += 4; } #ifdef INDEX_DEBUG_LOOKUP printf("%02x%02x%02x... lo %u hi %u nr %d\n", short_oid->id[0], short_oid->id[1], short_oid->id[2], lo, hi, p->num_objects); #endif #ifdef GIT_USE_LOOKUP pos = sha1_entry_pos(index, stride, 0, lo, hi, p->num_objects, short_oid->id); #else pos = sha1_position(index, stride, lo, hi, short_oid->id); #endif if (pos >= 0) { /* An object matching exactly the oid was found */ found = 1; current = index + pos * stride; } else { /* No object was found */ /* pos refers to the object with the "closest" oid to short_oid */ pos = - 1 - pos; if (pos < (int)p->num_objects) { current = index + pos * stride; if (!git_oid_ncmp(short_oid, (const git_oid *)current, len)) found = 1; } } if (found && len != GIT_OID_HEXSZ && pos + 1 < (int)p->num_objects) { /* Check for ambiguousity */ const unsigned char *next = current + stride; if (!git_oid_ncmp(short_oid, (const git_oid *)next, len)) { found = 2; } } if (!found) return git_odb__error_notfound("failed to find offset for pack entry", short_oid); if (found > 1) return git_odb__error_ambiguous("found multiple offsets for pack entry"); *offset_out = nth_packed_object_offset(p, pos); git_oid_fromraw(found_oid, current); #ifdef INDEX_DEBUG_LOOKUP { unsigned char hex_sha1[GIT_OID_HEXSZ + 1]; git_oid_fmt(hex_sha1, found_oid); hex_sha1[GIT_OID_HEXSZ] = '\0'; printf("found lo=%d %s\n", lo, hex_sha1); } #endif return 0; } int git_pack_entry_find( struct git_pack_entry *e, struct git_pack_file *p, const git_oid *short_oid, size_t len) { git_off_t offset; git_oid found_oid; int error; assert(p); if (len == GIT_OID_HEXSZ && p->num_bad_objects) { unsigned i; for (i = 0; i < p->num_bad_objects; i++) if (git_oid__cmp(short_oid, &p->bad_object_sha1[i]) == 0) return packfile_error("bad object found in packfile"); } error = pack_entry_find_offset(&offset, &found_oid, p, short_oid, len); if (error < 0) return error; /* we found a unique entry in the index; * make sure the packfile backing the index * still exists on disk */ if (p->mwf.fd == -1 && (error = packfile_open(p)) < 0) return error; e->offset = offset; e->p = p; git_oid_cpy(&e->sha1, &found_oid); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/revparse.c0000664000175000017500000004713612510265101015671 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include #include "common.h" #include "buffer.h" #include "tree.h" #include "refdb.h" #include "git2.h" static int maybe_sha_or_abbrev(git_object** out, git_repository *repo, const char *spec, size_t speclen) { git_oid oid; if (git_oid_fromstrn(&oid, spec, speclen) < 0) return GIT_ENOTFOUND; return git_object_lookup_prefix(out, repo, &oid, speclen, GIT_OBJ_ANY); } static int maybe_sha(git_object** out, git_repository *repo, const char *spec) { size_t speclen = strlen(spec); if (speclen != GIT_OID_HEXSZ) return GIT_ENOTFOUND; return maybe_sha_or_abbrev(out, repo, spec, speclen); } static int maybe_abbrev(git_object** out, git_repository *repo, const char *spec) { size_t speclen = strlen(spec); return maybe_sha_or_abbrev(out, repo, spec, speclen); } static int build_regex(regex_t *regex, const char *pattern) { int error; if (*pattern == '\0') { giterr_set(GITERR_REGEX, "Empty pattern"); return GIT_EINVALIDSPEC; } error = regcomp(regex, pattern, REG_EXTENDED); if (!error) return 0; error = giterr_set_regex(regex, error); regfree(regex); return error; } static int maybe_describe(git_object**out, git_repository *repo, const char *spec) { const char *substr; int error; regex_t regex; substr = strstr(spec, "-g"); if (substr == NULL) return GIT_ENOTFOUND; if (build_regex(®ex, ".+-[0-9]+-g[0-9a-fA-F]+") < 0) return -1; error = regexec(®ex, spec, 0, NULL, 0); regfree(®ex); if (error) return GIT_ENOTFOUND; return maybe_abbrev(out, repo, substr+2); } static int revparse_lookup_object( git_object **object_out, git_reference **reference_out, git_repository *repo, const char *spec) { int error; git_reference *ref; if ((error = maybe_sha(object_out, repo, spec)) != GIT_ENOTFOUND) return error; error = git_reference_dwim(&ref, repo, spec); if (!error) { error = git_object_lookup( object_out, repo, git_reference_target(ref), GIT_OBJ_ANY); if (!error) *reference_out = ref; return error; } if (error != GIT_ENOTFOUND) return error; if ((strlen(spec) < GIT_OID_HEXSZ) && ((error = maybe_abbrev(object_out, repo, spec)) != GIT_ENOTFOUND)) return error; if ((error = maybe_describe(object_out, repo, spec)) != GIT_ENOTFOUND) return error; giterr_set(GITERR_REFERENCE, "Revspec '%s' not found.", spec); return GIT_ENOTFOUND; } static int try_parse_numeric(int *n, const char *curly_braces_content) { int32_t content; const char *end_ptr; if (git__strtol32(&content, curly_braces_content, &end_ptr, 10) < 0) return -1; if (*end_ptr != '\0') return -1; *n = (int)content; return 0; } static int retrieve_previously_checked_out_branch_or_revision(git_object **out, git_reference **base_ref, git_repository *repo, const char *identifier, size_t position) { git_reference *ref = NULL; git_reflog *reflog = NULL; regex_t preg; int error = -1; size_t i, numentries, cur; const git_reflog_entry *entry; const char *msg; regmatch_t regexmatches[2]; git_buf buf = GIT_BUF_INIT; cur = position; if (*identifier != '\0' || *base_ref != NULL) return GIT_EINVALIDSPEC; if (build_regex(&preg, "checkout: moving from (.*) to .*") < 0) return -1; if (git_reference_lookup(&ref, repo, GIT_HEAD_FILE) < 0) goto cleanup; if (git_reflog_read(&reflog, repo, GIT_HEAD_FILE) < 0) goto cleanup; numentries = git_reflog_entrycount(reflog); for (i = 0; i < numentries; i++) { entry = git_reflog_entry_byindex(reflog, i); msg = git_reflog_entry_message(entry); if (!msg) continue; if (regexec(&preg, msg, 2, regexmatches, 0)) continue; cur--; if (cur > 0) continue; git_buf_put(&buf, msg+regexmatches[1].rm_so, regexmatches[1].rm_eo - regexmatches[1].rm_so); if ((error = git_reference_dwim(base_ref, repo, git_buf_cstr(&buf))) == 0) goto cleanup; if (error < 0 && error != GIT_ENOTFOUND) goto cleanup; error = maybe_abbrev(out, repo, git_buf_cstr(&buf)); goto cleanup; } error = GIT_ENOTFOUND; cleanup: git_reference_free(ref); git_buf_free(&buf); regfree(&preg); git_reflog_free(reflog); return error; } static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, size_t identifier) { git_reflog *reflog; size_t numentries; const git_reflog_entry *entry; bool search_by_pos = (identifier <= 100000000); if (git_reflog_read(&reflog, git_reference_owner(ref), git_reference_name(ref)) < 0) return -1; numentries = git_reflog_entrycount(reflog); if (search_by_pos) { if (numentries < identifier + 1) goto notfound; entry = git_reflog_entry_byindex(reflog, identifier); git_oid_cpy(oid, git_reflog_entry_id_new(entry)); } else { size_t i; git_time commit_time; for (i = 0; i < numentries; i++) { entry = git_reflog_entry_byindex(reflog, i); commit_time = git_reflog_entry_committer(entry)->when; if (commit_time.time > (git_time_t)identifier) continue; git_oid_cpy(oid, git_reflog_entry_id_new(entry)); break; } if (i == numentries) goto notfound; } git_reflog_free(reflog); return 0; notfound: giterr_set( GITERR_REFERENCE, "Reflog for '%s' has only %"PRIuZ" entries, asked for %"PRIuZ, git_reference_name(ref), numentries, identifier); git_reflog_free(reflog); return GIT_ENOTFOUND; } static int retrieve_revobject_from_reflog(git_object **out, git_reference **base_ref, git_repository *repo, const char *identifier, size_t position) { git_reference *ref; git_oid oid; int error = -1; if (*base_ref == NULL) { if ((error = git_reference_dwim(&ref, repo, identifier)) < 0) return error; } else { ref = *base_ref; *base_ref = NULL; } if (position == 0) { error = git_object_lookup(out, repo, git_reference_target(ref), GIT_OBJ_ANY); goto cleanup; } if ((error = retrieve_oid_from_reflog(&oid, ref, position)) < 0) goto cleanup; error = git_object_lookup(out, repo, &oid, GIT_OBJ_ANY); cleanup: git_reference_free(ref); return error; } static int retrieve_remote_tracking_reference(git_reference **base_ref, const char *identifier, git_repository *repo) { git_reference *tracking, *ref; int error = -1; if (*base_ref == NULL) { if ((error = git_reference_dwim(&ref, repo, identifier)) < 0) return error; } else { ref = *base_ref; *base_ref = NULL; } if (!git_reference_is_branch(ref)) { error = GIT_EINVALIDSPEC; goto cleanup; } if ((error = git_branch_upstream(&tracking, ref)) < 0) goto cleanup; *base_ref = tracking; cleanup: git_reference_free(ref); return error; } static int handle_at_syntax(git_object **out, git_reference **ref, const char *spec, size_t identifier_len, git_repository* repo, const char *curly_braces_content) { bool is_numeric; int parsed = 0, error = -1; git_buf identifier = GIT_BUF_INIT; git_time_t timestamp; assert(*out == NULL); if (git_buf_put(&identifier, spec, identifier_len) < 0) return -1; is_numeric = !try_parse_numeric(&parsed, curly_braces_content); if (*curly_braces_content == '-' && (!is_numeric || parsed == 0)) { error = GIT_EINVALIDSPEC; goto cleanup; } if (is_numeric) { if (parsed < 0) error = retrieve_previously_checked_out_branch_or_revision(out, ref, repo, git_buf_cstr(&identifier), -parsed); else error = retrieve_revobject_from_reflog(out, ref, repo, git_buf_cstr(&identifier), parsed); goto cleanup; } if (!strcmp(curly_braces_content, "u") || !strcmp(curly_braces_content, "upstream")) { error = retrieve_remote_tracking_reference(ref, git_buf_cstr(&identifier), repo); goto cleanup; } if (git__date_parse(×tamp, curly_braces_content) < 0) goto cleanup; error = retrieve_revobject_from_reflog(out, ref, repo, git_buf_cstr(&identifier), (size_t)timestamp); cleanup: git_buf_free(&identifier); return error; } static git_otype parse_obj_type(const char *str) { if (!strcmp(str, "commit")) return GIT_OBJ_COMMIT; if (!strcmp(str, "tree")) return GIT_OBJ_TREE; if (!strcmp(str, "blob")) return GIT_OBJ_BLOB; if (!strcmp(str, "tag")) return GIT_OBJ_TAG; return GIT_OBJ_BAD; } static int dereference_to_non_tag(git_object **out, git_object *obj) { if (git_object_type(obj) == GIT_OBJ_TAG) return git_tag_peel(out, (git_tag *)obj); return git_object_dup(out, obj); } static int handle_caret_parent_syntax(git_object **out, git_object *obj, int n) { git_object *temp_commit = NULL; int error; if ((error = git_object_peel(&temp_commit, obj, GIT_OBJ_COMMIT)) < 0) return (error == GIT_EAMBIGUOUS || error == GIT_ENOTFOUND) ? GIT_EINVALIDSPEC : error; if (n == 0) { *out = temp_commit; return 0; } error = git_commit_parent((git_commit **)out, (git_commit*)temp_commit, n - 1); git_object_free(temp_commit); return error; } static int handle_linear_syntax(git_object **out, git_object *obj, int n) { git_object *temp_commit = NULL; int error; if ((error = git_object_peel(&temp_commit, obj, GIT_OBJ_COMMIT)) < 0) return (error == GIT_EAMBIGUOUS || error == GIT_ENOTFOUND) ? GIT_EINVALIDSPEC : error; error = git_commit_nth_gen_ancestor((git_commit **)out, (git_commit*)temp_commit, n); git_object_free(temp_commit); return error; } static int handle_colon_syntax( git_object **out, git_object *obj, const char *path) { git_object *tree; int error = -1; git_tree_entry *entry = NULL; if ((error = git_object_peel(&tree, obj, GIT_OBJ_TREE)) < 0) return error == GIT_ENOTFOUND ? GIT_EINVALIDSPEC : error; if (*path == '\0') { *out = tree; return 0; } /* * TODO: Handle the relative path syntax * (:./relative/path and :../relative/path) */ if ((error = git_tree_entry_bypath(&entry, (git_tree *)tree, path)) < 0) goto cleanup; error = git_tree_entry_to_object(out, git_object_owner(tree), entry); cleanup: git_tree_entry_free(entry); git_object_free(tree); return error; } static int walk_and_search(git_object **out, git_revwalk *walk, regex_t *regex) { int error; git_oid oid; git_object *obj; while (!(error = git_revwalk_next(&oid, walk))) { error = git_object_lookup(&obj, git_revwalk_repository(walk), &oid, GIT_OBJ_COMMIT); if ((error < 0) && (error != GIT_ENOTFOUND)) return -1; if (!regexec(regex, git_commit_message((git_commit*)obj), 0, NULL, 0)) { *out = obj; return 0; } git_object_free(obj); } if (error < 0 && error == GIT_ITEROVER) error = GIT_ENOTFOUND; return error; } static int handle_grep_syntax(git_object **out, git_repository *repo, const git_oid *spec_oid, const char *pattern) { regex_t preg; git_revwalk *walk = NULL; int error; if ((error = build_regex(&preg, pattern)) < 0) return error; if ((error = git_revwalk_new(&walk, repo)) < 0) goto cleanup; git_revwalk_sorting(walk, GIT_SORT_TIME); if (spec_oid == NULL) { if ((error = git_revwalk_push_glob(walk, "refs/*")) < 0) goto cleanup; } else if ((error = git_revwalk_push(walk, spec_oid)) < 0) goto cleanup; error = walk_and_search(out, walk, &preg); cleanup: regfree(&preg); git_revwalk_free(walk); return error; } static int handle_caret_curly_syntax(git_object **out, git_object *obj, const char *curly_braces_content) { git_otype expected_type; if (*curly_braces_content == '\0') return dereference_to_non_tag(out, obj); if (*curly_braces_content == '/') return handle_grep_syntax(out, git_object_owner(obj), git_object_id(obj), curly_braces_content + 1); expected_type = parse_obj_type(curly_braces_content); if (expected_type == GIT_OBJ_BAD) return GIT_EINVALIDSPEC; return git_object_peel(out, obj, expected_type); } static int extract_curly_braces_content(git_buf *buf, const char *spec, size_t *pos) { git_buf_clear(buf); assert(spec[*pos] == '^' || spec[*pos] == '@'); (*pos)++; if (spec[*pos] == '\0' || spec[*pos] != '{') return GIT_EINVALIDSPEC; (*pos)++; while (spec[*pos] != '}') { if (spec[*pos] == '\0') return GIT_EINVALIDSPEC; git_buf_putc(buf, spec[(*pos)++]); } (*pos)++; return 0; } static int extract_path(git_buf *buf, const char *spec, size_t *pos) { git_buf_clear(buf); assert(spec[*pos] == ':'); (*pos)++; if (git_buf_puts(buf, spec + *pos) < 0) return -1; *pos += git_buf_len(buf); return 0; } static int extract_how_many(int *n, const char *spec, size_t *pos) { const char *end_ptr; int parsed, accumulated; char kind = spec[*pos]; assert(spec[*pos] == '^' || spec[*pos] == '~'); accumulated = 0; do { do { (*pos)++; accumulated++; } while (spec[(*pos)] == kind && kind == '~'); if (git__isdigit(spec[*pos])) { if (git__strtol32(&parsed, spec + *pos, &end_ptr, 10) < 0) return GIT_EINVALIDSPEC; accumulated += (parsed - 1); *pos = end_ptr - spec; } } while (spec[(*pos)] == kind && kind == '~'); *n = accumulated; return 0; } static int object_from_reference(git_object **object, git_reference *reference) { git_reference *resolved = NULL; int error; if (git_reference_resolve(&resolved, reference) < 0) return -1; error = git_object_lookup(object, reference->db->repo, git_reference_target(resolved), GIT_OBJ_ANY); git_reference_free(resolved); return error; } static int ensure_base_rev_loaded(git_object **object, git_reference **reference, const char *spec, size_t identifier_len, git_repository *repo, bool allow_empty_identifier) { int error; git_buf identifier = GIT_BUF_INIT; if (*object != NULL) return 0; if (*reference != NULL) return object_from_reference(object, *reference); if (!allow_empty_identifier && identifier_len == 0) return GIT_EINVALIDSPEC; if (git_buf_put(&identifier, spec, identifier_len) < 0) return -1; error = revparse_lookup_object(object, reference, repo, git_buf_cstr(&identifier)); git_buf_free(&identifier); return error; } static int ensure_base_rev_is_not_known_yet(git_object *object) { if (object == NULL) return 0; return GIT_EINVALIDSPEC; } static bool any_left_hand_identifier(git_object *object, git_reference *reference, size_t identifier_len) { if (object != NULL) return true; if (reference != NULL) return true; if (identifier_len > 0) return true; return false; } static int ensure_left_hand_identifier_is_not_known_yet(git_object *object, git_reference *reference) { if (!ensure_base_rev_is_not_known_yet(object) && reference == NULL) return 0; return GIT_EINVALIDSPEC; } int revparse__ext( git_object **object_out, git_reference **reference_out, size_t *identifier_len_out, git_repository *repo, const char *spec) { size_t pos = 0, identifier_len = 0; int error = -1, n; git_buf buf = GIT_BUF_INIT; git_reference *reference = NULL; git_object *base_rev = NULL; bool should_return_reference = true; assert(object_out && reference_out && repo && spec); *object_out = NULL; *reference_out = NULL; while (spec[pos]) { switch (spec[pos]) { case '^': should_return_reference = false; if ((error = ensure_base_rev_loaded(&base_rev, &reference, spec, identifier_len, repo, false)) < 0) goto cleanup; if (spec[pos+1] == '{') { git_object *temp_object = NULL; if ((error = extract_curly_braces_content(&buf, spec, &pos)) < 0) goto cleanup; if ((error = handle_caret_curly_syntax(&temp_object, base_rev, git_buf_cstr(&buf))) < 0) goto cleanup; git_object_free(base_rev); base_rev = temp_object; } else { git_object *temp_object = NULL; if ((error = extract_how_many(&n, spec, &pos)) < 0) goto cleanup; if ((error = handle_caret_parent_syntax(&temp_object, base_rev, n)) < 0) goto cleanup; git_object_free(base_rev); base_rev = temp_object; } break; case '~': { git_object *temp_object = NULL; should_return_reference = false; if ((error = extract_how_many(&n, spec, &pos)) < 0) goto cleanup; if ((error = ensure_base_rev_loaded(&base_rev, &reference, spec, identifier_len, repo, false)) < 0) goto cleanup; if ((error = handle_linear_syntax(&temp_object, base_rev, n)) < 0) goto cleanup; git_object_free(base_rev); base_rev = temp_object; break; } case ':': { git_object *temp_object = NULL; should_return_reference = false; if ((error = extract_path(&buf, spec, &pos)) < 0) goto cleanup; if (any_left_hand_identifier(base_rev, reference, identifier_len)) { if ((error = ensure_base_rev_loaded(&base_rev, &reference, spec, identifier_len, repo, true)) < 0) goto cleanup; if ((error = handle_colon_syntax(&temp_object, base_rev, git_buf_cstr(&buf))) < 0) goto cleanup; } else { if (*git_buf_cstr(&buf) == '/') { if ((error = handle_grep_syntax(&temp_object, repo, NULL, git_buf_cstr(&buf) + 1)) < 0) goto cleanup; } else { /* * TODO: support merge-stage path lookup (":2:Makefile") * and plain index blob lookup (:i-am/a/blob) */ giterr_set(GITERR_INVALID, "Unimplemented"); error = GIT_ERROR; goto cleanup; } } git_object_free(base_rev); base_rev = temp_object; break; } case '@': { if (spec[pos+1] == '{') { git_object *temp_object = NULL; if ((error = extract_curly_braces_content(&buf, spec, &pos)) < 0) goto cleanup; if ((error = ensure_base_rev_is_not_known_yet(base_rev)) < 0) goto cleanup; if ((error = handle_at_syntax(&temp_object, &reference, spec, identifier_len, repo, git_buf_cstr(&buf))) < 0) goto cleanup; if (temp_object != NULL) base_rev = temp_object; break; } else { /* Fall through */ } } default: if ((error = ensure_left_hand_identifier_is_not_known_yet(base_rev, reference)) < 0) goto cleanup; pos++; identifier_len++; } } if ((error = ensure_base_rev_loaded(&base_rev, &reference, spec, identifier_len, repo, false)) < 0) goto cleanup; if (!should_return_reference) { git_reference_free(reference); reference = NULL; } *object_out = base_rev; *reference_out = reference; *identifier_len_out = identifier_len; error = 0; cleanup: if (error) { if (error == GIT_EINVALIDSPEC) giterr_set(GITERR_INVALID, "Failed to parse revision specifier - Invalid pattern '%s'", spec); git_object_free(base_rev); git_reference_free(reference); } git_buf_free(&buf); return error; } int git_revparse_ext( git_object **object_out, git_reference **reference_out, git_repository *repo, const char *spec) { int error; size_t identifier_len; git_object *obj = NULL; git_reference *ref = NULL; if ((error = revparse__ext(&obj, &ref, &identifier_len, repo, spec)) < 0) goto cleanup; *object_out = obj; *reference_out = ref; GIT_UNUSED(identifier_len); return 0; cleanup: git_object_free(obj); git_reference_free(ref); return error; } int git_revparse_single(git_object **out, git_repository *repo, const char *spec) { int error; git_object *obj = NULL; git_reference *ref = NULL; *out = NULL; if ((error = git_revparse_ext(&obj, &ref, repo, spec)) < 0) goto cleanup; git_reference_free(ref); *out = obj; return 0; cleanup: git_object_free(obj); git_reference_free(ref); return error; } int git_revparse( git_revspec *revspec, git_repository *repo, const char *spec) { const char *dotdot; int error = 0; assert(revspec && repo && spec); memset(revspec, 0x0, sizeof(*revspec)); if ((dotdot = strstr(spec, "..")) != NULL) { char *lstr; const char *rstr; revspec->flags = GIT_REVPARSE_RANGE; lstr = git__substrdup(spec, dotdot - spec); rstr = dotdot + 2; if (dotdot[2] == '.') { revspec->flags |= GIT_REVPARSE_MERGE_BASE; rstr++; } error = git_revparse_single(&revspec->from, repo, lstr); if (!error) error = git_revparse_single(&revspec->to, repo, rstr); git__free((void*)lstr); } else { revspec->flags = GIT_REVPARSE_SINGLE; error = git_revparse_single(&revspec->from, repo, spec); } return error; } deps/libgit2-sys-0.3.8/libgit2/src/config_file.c0000664000175000017500000013111412610310643016277 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "config.h" #include "filebuf.h" #include "sysdir.h" #include "buffer.h" #include "buf_text.h" #include "git2/config.h" #include "git2/sys/config.h" #include "git2/types.h" #include "strmap.h" #include "array.h" #include #include #include GIT__USE_STRMAP typedef struct cvar_t { struct cvar_t *next; git_config_entry *entry; bool included; /* whether this is part of [include] */ } cvar_t; typedef struct git_config_file_iter { git_config_iterator parent; git_strmap_iter iter; cvar_t* next_var; } git_config_file_iter; /* Max depth for [include] directives */ #define MAX_INCLUDE_DEPTH 10 #define CVAR_LIST_HEAD(list) ((list)->head) #define CVAR_LIST_TAIL(list) ((list)->tail) #define CVAR_LIST_NEXT(var) ((var)->next) #define CVAR_LIST_EMPTY(list) ((list)->head == NULL) #define CVAR_LIST_APPEND(list, var) do {\ if (CVAR_LIST_EMPTY(list)) {\ CVAR_LIST_HEAD(list) = CVAR_LIST_TAIL(list) = var;\ } else {\ CVAR_LIST_NEXT(CVAR_LIST_TAIL(list)) = var;\ CVAR_LIST_TAIL(list) = var;\ }\ } while(0) #define CVAR_LIST_REMOVE_HEAD(list) do {\ CVAR_LIST_HEAD(list) = CVAR_LIST_NEXT(CVAR_LIST_HEAD(list));\ } while(0) #define CVAR_LIST_REMOVE_AFTER(var) do {\ CVAR_LIST_NEXT(var) = CVAR_LIST_NEXT(CVAR_LIST_NEXT(var));\ } while(0) #define CVAR_LIST_FOREACH(list, iter)\ for ((iter) = CVAR_LIST_HEAD(list);\ (iter) != NULL;\ (iter) = CVAR_LIST_NEXT(iter)) /* * Inspired by the FreeBSD functions */ #define CVAR_LIST_FOREACH_SAFE(start, iter, tmp)\ for ((iter) = CVAR_LIST_HEAD(vars);\ (iter) && (((tmp) = CVAR_LIST_NEXT(iter) || 1));\ (iter) = (tmp)) struct reader { time_t file_mtime; size_t file_size; char *file_path; git_buf buffer; char *read_ptr; int line_number; int eof; }; typedef struct { git_atomic refcount; git_strmap *values; } refcounted_strmap; typedef struct { git_config_backend parent; /* mutex to coordinate accessing the values */ git_mutex values_mutex; refcounted_strmap *values; } diskfile_header; typedef struct { diskfile_header header; git_config_level_t level; git_array_t(struct reader) readers; bool locked; git_filebuf locked_buf; git_buf locked_content; char *file_path; } diskfile_backend; typedef struct { diskfile_header header; diskfile_backend *snapshot_from; } diskfile_readonly_backend; static int config_read(git_strmap *values, diskfile_backend *cfg_file, struct reader *reader, git_config_level_t level, int depth); static int config_write(diskfile_backend *cfg, const char *key, const regex_t *preg, const char *value); static char *escape_value(const char *ptr); int git_config_file__snapshot(git_config_backend **out, diskfile_backend *in); static int config_snapshot(git_config_backend **out, git_config_backend *in); static void set_parse_error(struct reader *reader, int col, const char *error_str) { giterr_set(GITERR_CONFIG, "Failed to parse config file: %s (in %s:%d, column %d)", error_str, reader->file_path, reader->line_number, col); } static int config_error_readonly(void) { giterr_set(GITERR_CONFIG, "this backend is read-only"); return -1; } static void cvar_free(cvar_t *var) { if (var == NULL) return; git__free((char*)var->entry->name); git__free((char *)var->entry->value); git__free(var->entry); git__free(var); } int git_config_file_normalize_section(char *start, char *end) { char *scan; if (start == end) return GIT_EINVALIDSPEC; /* Validate and downcase range */ for (scan = start; *scan; ++scan) { if (end && scan >= end) break; if (isalnum(*scan)) *scan = (char)git__tolower(*scan); else if (*scan != '-' || scan == start) return GIT_EINVALIDSPEC; } if (scan == start) return GIT_EINVALIDSPEC; return 0; } /* Add or append the new config option */ static int append_entry(git_strmap *values, cvar_t *var) { git_strmap_iter pos; cvar_t *existing; int error = 0; pos = git_strmap_lookup_index(values, var->entry->name); if (!git_strmap_valid_index(values, pos)) { git_strmap_insert(values, var->entry->name, var, error); } else { existing = git_strmap_value_at(values, pos); while (existing->next != NULL) { existing = existing->next; } existing->next = var; } if (error > 0) error = 0; return error; } static void free_vars(git_strmap *values) { cvar_t *var = NULL; if (values == NULL) return; git_strmap_foreach_value(values, var, while (var != NULL) { cvar_t *next = CVAR_LIST_NEXT(var); cvar_free(var); var = next; }); git_strmap_free(values); } static void refcounted_strmap_free(refcounted_strmap *map) { if (!map) return; if (git_atomic_dec(&map->refcount) != 0) return; free_vars(map->values); git__free(map); } /** * Take the current values map from the backend and increase its * refcount. This is its own function to make sure we use the mutex to * avoid the map pointer from changing under us. */ static refcounted_strmap *refcounted_strmap_take(diskfile_header *h) { refcounted_strmap *map; git_mutex_lock(&h->values_mutex); map = h->values; git_atomic_inc(&map->refcount); git_mutex_unlock(&h->values_mutex); return map; } static int refcounted_strmap_alloc(refcounted_strmap **out) { refcounted_strmap *map; int error; map = git__calloc(1, sizeof(refcounted_strmap)); GITERR_CHECK_ALLOC(map); git_atomic_set(&map->refcount, 1); if ((error = git_strmap_alloc(&map->values)) < 0) git__free(map); else *out = map; return error; } static int config_open(git_config_backend *cfg, git_config_level_t level) { int res; struct reader *reader; diskfile_backend *b = (diskfile_backend *)cfg; b->level = level; if ((res = refcounted_strmap_alloc(&b->header.values)) < 0) return res; git_array_init(b->readers); reader = git_array_alloc(b->readers); if (!reader) { refcounted_strmap_free(b->header.values); return -1; } memset(reader, 0, sizeof(struct reader)); reader->file_path = git__strdup(b->file_path); GITERR_CHECK_ALLOC(reader->file_path); git_buf_init(&reader->buffer, 0); res = git_futils_readbuffer_updated( &reader->buffer, b->file_path, &reader->file_mtime, &reader->file_size, NULL); /* It's fine if the file doesn't exist */ if (res == GIT_ENOTFOUND) return 0; if (res < 0 || (res = config_read(b->header.values->values, b, reader, level, 0)) < 0) { refcounted_strmap_free(b->header.values); b->header.values = NULL; } reader = git_array_get(b->readers, 0); git_buf_free(&reader->buffer); return res; } /* The meat of the refresh, as we want to use it in different places */ static int config__refresh(git_config_backend *cfg) { refcounted_strmap *values = NULL, *tmp; diskfile_backend *b = (diskfile_backend *)cfg; struct reader *reader = NULL; int error = 0; if ((error = refcounted_strmap_alloc(&values)) < 0) goto out; reader = git_array_get(b->readers, git_array_size(b->readers) - 1); GITERR_CHECK_ALLOC(reader); if ((error = config_read(values->values, b, reader, b->level, 0)) < 0) goto out; git_mutex_lock(&b->header.values_mutex); tmp = b->header.values; b->header.values = values; values = tmp; git_mutex_unlock(&b->header.values_mutex); out: refcounted_strmap_free(values); if (reader) git_buf_free(&reader->buffer); return error; } static int config_refresh(git_config_backend *cfg) { int error = 0, updated = 0, any_updated = 0; diskfile_backend *b = (diskfile_backend *)cfg; struct reader *reader = NULL; uint32_t i; for (i = 0; i < git_array_size(b->readers); i++) { reader = git_array_get(b->readers, i); error = git_futils_readbuffer_updated( &reader->buffer, reader->file_path, &reader->file_mtime, &reader->file_size, &updated); if (error < 0 && error != GIT_ENOTFOUND) return error; if (updated) any_updated = 1; } if (!any_updated) return (error == GIT_ENOTFOUND) ? 0 : error; return config__refresh(cfg); } static void backend_free(git_config_backend *_backend) { diskfile_backend *backend = (diskfile_backend *)_backend; uint32_t i; if (backend == NULL) return; for (i = 0; i < git_array_size(backend->readers); i++) { struct reader *r = git_array_get(backend->readers, i); git__free(r->file_path); } git_array_clear(backend->readers); git__free(backend->file_path); refcounted_strmap_free(backend->header.values); git_mutex_free(&backend->header.values_mutex); git__free(backend); } static void config_iterator_free( git_config_iterator* iter) { iter->backend->free(iter->backend); git__free(iter); } static int config_iterator_next( git_config_entry **entry, git_config_iterator *iter) { git_config_file_iter *it = (git_config_file_iter *) iter; diskfile_header *h = (diskfile_header *) it->parent.backend; git_strmap *values = h->values->values; int err = 0; cvar_t * var; if (it->next_var == NULL) { err = git_strmap_next((void**) &var, &(it->iter), values); } else { var = it->next_var; } if (err < 0) { it->next_var = NULL; return err; } *entry = var->entry; it->next_var = CVAR_LIST_NEXT(var); return 0; } static int config_iterator_new( git_config_iterator **iter, struct git_config_backend* backend) { diskfile_header *h; git_config_file_iter *it; git_config_backend *snapshot; diskfile_backend *b = (diskfile_backend *) backend; int error; if ((error = config_snapshot(&snapshot, backend)) < 0) return error; if ((error = snapshot->open(snapshot, b->level)) < 0) return error; it = git__calloc(1, sizeof(git_config_file_iter)); GITERR_CHECK_ALLOC(it); h = (diskfile_header *)snapshot; /* strmap_begin() is currently a macro returning 0 */ GIT_UNUSED(h); it->parent.backend = snapshot; it->iter = git_strmap_begin(h->values); it->next_var = NULL; it->parent.next = config_iterator_next; it->parent.free = config_iterator_free; *iter = (git_config_iterator *) it; return 0; } static int config_set(git_config_backend *cfg, const char *name, const char *value) { diskfile_backend *b = (diskfile_backend *)cfg; refcounted_strmap *map; git_strmap *values; char *key, *esc_value = NULL; khiter_t pos; int rval, ret; if ((rval = git_config__normalize_name(name, &key)) < 0) return rval; map = refcounted_strmap_take(&b->header); values = map->values; /* * Try to find it in the existing values and update it if it * only has one value. */ pos = git_strmap_lookup_index(values, key); if (git_strmap_valid_index(values, pos)) { cvar_t *existing = git_strmap_value_at(values, pos); if (existing->next != NULL) { giterr_set(GITERR_CONFIG, "Multivar incompatible with simple set"); ret = -1; goto out; } /* don't update if old and new values already match */ if ((!existing->entry->value && !value) || (existing->entry->value && value && !strcmp(existing->entry->value, value))) { ret = 0; goto out; } } /* No early returns due to sanity checks, let's write it out and refresh */ if (value) { esc_value = escape_value(value); GITERR_CHECK_ALLOC(esc_value); } if ((ret = config_write(b, key, NULL, esc_value)) < 0) goto out; ret = config_refresh(cfg); out: refcounted_strmap_free(map); git__free(esc_value); git__free(key); return ret; } /* release the map containing the entry as an equivalent to freeing it */ static void release_map(git_config_entry *entry) { refcounted_strmap *map = (refcounted_strmap *) entry->payload; refcounted_strmap_free(map); } /* * Internal function that actually gets the value in string form */ static int config_get(git_config_backend *cfg, const char *key, git_config_entry **out) { diskfile_header *h = (diskfile_header *)cfg; refcounted_strmap *map; git_strmap *values; khiter_t pos; cvar_t *var; int error = 0; if (!h->parent.readonly && ((error = config_refresh(cfg)) < 0)) return error; map = refcounted_strmap_take(h); values = map->values; pos = git_strmap_lookup_index(values, key); /* no error message; the config system will write one */ if (!git_strmap_valid_index(values, pos)) { refcounted_strmap_free(map); return GIT_ENOTFOUND; } var = git_strmap_value_at(values, pos); while (var->next) var = var->next; *out = var->entry; (*out)->free = release_map; (*out)->payload = map; return error; } static int config_set_multivar( git_config_backend *cfg, const char *name, const char *regexp, const char *value) { diskfile_backend *b = (diskfile_backend *)cfg; refcounted_strmap *map; git_strmap *values; char *key; regex_t preg; int result; khiter_t pos; assert(regexp); if ((result = git_config__normalize_name(name, &key)) < 0) return result; map = refcounted_strmap_take(&b->header); values = b->header.values->values; pos = git_strmap_lookup_index(values, key); if (!git_strmap_valid_index(values, pos)) { /* If we don't have it, behave like a normal set */ result = config_set(cfg, name, value); refcounted_strmap_free(map); git__free(key); return result; } result = regcomp(&preg, regexp, REG_EXTENDED); if (result != 0) { giterr_set_regex(&preg, result); result = -1; goto out; } /* If we do have it, set call config_write() and reload */ if ((result = config_write(b, key, &preg, value)) < 0) goto out; result = config_refresh(cfg); out: refcounted_strmap_free(map); git__free(key); regfree(&preg); return result; } static int config_delete(git_config_backend *cfg, const char *name) { cvar_t *var; diskfile_backend *b = (diskfile_backend *)cfg; refcounted_strmap *map; git_strmap *values; char *key; int result; khiter_t pos; if ((result = git_config__normalize_name(name, &key)) < 0) return result; map = refcounted_strmap_take(&b->header); values = b->header.values->values; pos = git_strmap_lookup_index(values, key); git__free(key); if (!git_strmap_valid_index(values, pos)) { refcounted_strmap_free(map); giterr_set(GITERR_CONFIG, "Could not find key '%s' to delete", name); return GIT_ENOTFOUND; } var = git_strmap_value_at(values, pos); refcounted_strmap_free(map); if (var->next != NULL) { giterr_set(GITERR_CONFIG, "Cannot delete multivar with a single delete"); return -1; } if ((result = config_write(b, var->entry->name, NULL, NULL)) < 0) return result; return config_refresh(cfg); } static int config_delete_multivar(git_config_backend *cfg, const char *name, const char *regexp) { diskfile_backend *b = (diskfile_backend *)cfg; refcounted_strmap *map; git_strmap *values; char *key; regex_t preg; int result; khiter_t pos; if ((result = git_config__normalize_name(name, &key)) < 0) return result; map = refcounted_strmap_take(&b->header); values = b->header.values->values; pos = git_strmap_lookup_index(values, key); if (!git_strmap_valid_index(values, pos)) { refcounted_strmap_free(map); git__free(key); giterr_set(GITERR_CONFIG, "Could not find key '%s' to delete", name); return GIT_ENOTFOUND; } refcounted_strmap_free(map); result = regcomp(&preg, regexp, REG_EXTENDED); if (result != 0) { giterr_set_regex(&preg, result); result = -1; goto out; } if ((result = config_write(b, key, &preg, NULL)) < 0) goto out; result = config_refresh(cfg); out: git__free(key); regfree(&preg); return result; } static int config_snapshot(git_config_backend **out, git_config_backend *in) { diskfile_backend *b = (diskfile_backend *) in; return git_config_file__snapshot(out, b); } static int config_lock(git_config_backend *_cfg) { diskfile_backend *cfg = (diskfile_backend *) _cfg; int error; if ((error = git_filebuf_open(&cfg->locked_buf, cfg->file_path, 0, GIT_CONFIG_FILE_MODE)) < 0) return error; error = git_futils_readbuffer(&cfg->locked_content, cfg->file_path); if (error < 0 && error != GIT_ENOTFOUND) { git_filebuf_cleanup(&cfg->locked_buf); return error; } cfg->locked = true; return 0; } static int config_unlock(git_config_backend *_cfg, int success) { diskfile_backend *cfg = (diskfile_backend *) _cfg; int error = 0; if (success) { git_filebuf_write(&cfg->locked_buf, cfg->locked_content.ptr, cfg->locked_content.size); error = git_filebuf_commit(&cfg->locked_buf); } git_filebuf_cleanup(&cfg->locked_buf); git_buf_free(&cfg->locked_content); cfg->locked = false; return error; } int git_config_file__ondisk(git_config_backend **out, const char *path) { diskfile_backend *backend; backend = git__calloc(1, sizeof(diskfile_backend)); GITERR_CHECK_ALLOC(backend); backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION; git_mutex_init(&backend->header.values_mutex); backend->file_path = git__strdup(path); GITERR_CHECK_ALLOC(backend->file_path); backend->header.parent.open = config_open; backend->header.parent.get = config_get; backend->header.parent.set = config_set; backend->header.parent.set_multivar = config_set_multivar; backend->header.parent.del = config_delete; backend->header.parent.del_multivar = config_delete_multivar; backend->header.parent.iterator = config_iterator_new; backend->header.parent.snapshot = config_snapshot; backend->header.parent.lock = config_lock; backend->header.parent.unlock = config_unlock; backend->header.parent.free = backend_free; *out = (git_config_backend *)backend; return 0; } static int config_set_readonly(git_config_backend *cfg, const char *name, const char *value) { GIT_UNUSED(cfg); GIT_UNUSED(name); GIT_UNUSED(value); return config_error_readonly(); } static int config_set_multivar_readonly( git_config_backend *cfg, const char *name, const char *regexp, const char *value) { GIT_UNUSED(cfg); GIT_UNUSED(name); GIT_UNUSED(regexp); GIT_UNUSED(value); return config_error_readonly(); } static int config_delete_multivar_readonly(git_config_backend *cfg, const char *name, const char *regexp) { GIT_UNUSED(cfg); GIT_UNUSED(name); GIT_UNUSED(regexp); return config_error_readonly(); } static int config_delete_readonly(git_config_backend *cfg, const char *name) { GIT_UNUSED(cfg); GIT_UNUSED(name); return config_error_readonly(); } static int config_lock_readonly(git_config_backend *_cfg) { GIT_UNUSED(_cfg); return config_error_readonly(); } static int config_unlock_readonly(git_config_backend *_cfg, int success) { GIT_UNUSED(_cfg); GIT_UNUSED(success); return config_error_readonly(); } static void backend_readonly_free(git_config_backend *_backend) { diskfile_backend *backend = (diskfile_backend *)_backend; if (backend == NULL) return; refcounted_strmap_free(backend->header.values); git_mutex_free(&backend->header.values_mutex); git__free(backend); } static int config_readonly_open(git_config_backend *cfg, git_config_level_t level) { diskfile_readonly_backend *b = (diskfile_readonly_backend *) cfg; diskfile_backend *src = b->snapshot_from; diskfile_header *src_header = &src->header; refcounted_strmap *src_map; int error; if (!src_header->parent.readonly && (error = config_refresh(&src_header->parent)) < 0) return error; /* We're just copying data, don't care about the level */ GIT_UNUSED(level); src_map = refcounted_strmap_take(src_header); b->header.values = src_map; return 0; } int git_config_file__snapshot(git_config_backend **out, diskfile_backend *in) { diskfile_readonly_backend *backend; backend = git__calloc(1, sizeof(diskfile_readonly_backend)); GITERR_CHECK_ALLOC(backend); backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION; git_mutex_init(&backend->header.values_mutex); backend->snapshot_from = in; backend->header.parent.readonly = 1; backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION; backend->header.parent.open = config_readonly_open; backend->header.parent.get = config_get; backend->header.parent.set = config_set_readonly; backend->header.parent.set_multivar = config_set_multivar_readonly; backend->header.parent.del = config_delete_readonly; backend->header.parent.del_multivar = config_delete_multivar_readonly; backend->header.parent.iterator = config_iterator_new; backend->header.parent.lock = config_lock_readonly; backend->header.parent.unlock = config_unlock_readonly; backend->header.parent.free = backend_readonly_free; *out = (git_config_backend *)backend; return 0; } static int reader_getchar_raw(struct reader *reader) { int c; c = *reader->read_ptr++; /* Win 32 line breaks: if we find a \r\n sequence, return only the \n as a newline */ if (c == '\r' && *reader->read_ptr == '\n') { reader->read_ptr++; c = '\n'; } if (c == '\n') reader->line_number++; if (c == 0) { reader->eof = 1; c = '\0'; } return c; } #define SKIP_WHITESPACE (1 << 1) #define SKIP_COMMENTS (1 << 2) static int reader_getchar(struct reader *reader, int flags) { const int skip_whitespace = (flags & SKIP_WHITESPACE); const int skip_comments = (flags & SKIP_COMMENTS); int c; assert(reader->read_ptr); do { c = reader_getchar_raw(reader); } while (c != '\n' && c != '\0' && skip_whitespace && git__isspace(c)); if (skip_comments && (c == '#' || c == ';')) { do { c = reader_getchar_raw(reader); } while (c != '\n' && c != '\0'); } return c; } /* * Read the next char, but don't move the reading pointer. */ static int reader_peek(struct reader *reader, int flags) { void *old_read_ptr; int old_lineno, old_eof; int ret; assert(reader->read_ptr); old_read_ptr = reader->read_ptr; old_lineno = reader->line_number; old_eof = reader->eof; ret = reader_getchar(reader, flags); reader->read_ptr = old_read_ptr; reader->line_number = old_lineno; reader->eof = old_eof; return ret; } /* * Read and consume a line, returning it in newly-allocated memory. */ static char *reader_readline(struct reader *reader, bool skip_whitespace) { char *line = NULL; char *line_src, *line_end; size_t line_len, alloc_len; line_src = reader->read_ptr; if (skip_whitespace) { /* Skip empty empty lines */ while (git__isspace(*line_src)) ++line_src; } line_end = strchr(line_src, '\n'); /* no newline at EOF */ if (line_end == NULL) line_end = strchr(line_src, 0); line_len = line_end - line_src; if (GIT_ADD_SIZET_OVERFLOW(&alloc_len, line_len, 1) || (line = git__malloc(alloc_len)) == NULL) { return NULL; } memcpy(line, line_src, line_len); do line[line_len] = '\0'; while (line_len-- > 0 && git__isspace(line[line_len])); if (*line_end == '\n') line_end++; if (*line_end == '\0') reader->eof = 1; reader->line_number++; reader->read_ptr = line_end; return line; } /* * Consume a line, without storing it anywhere */ static void reader_consume_line(struct reader *reader) { char *line_start, *line_end; line_start = reader->read_ptr; line_end = strchr(line_start, '\n'); /* No newline at EOF */ if(line_end == NULL){ line_end = strchr(line_start, '\0'); } if (*line_end == '\n') line_end++; if (*line_end == '\0') reader->eof = 1; reader->line_number++; reader->read_ptr = line_end; } GIT_INLINE(int) config_keychar(int c) { return isalnum(c) || c == '-'; } static int parse_section_header_ext(struct reader *reader, const char *line, const char *base_name, char **section_name) { int c, rpos; char *first_quote, *last_quote; git_buf buf = GIT_BUF_INIT; size_t quoted_len, alloc_len, base_name_len = strlen(base_name); /* * base_name is what came before the space. We should be at the * first quotation mark, except for now, line isn't being kept in * sync so we only really use it to calculate the length. */ first_quote = strchr(line, '"'); last_quote = strrchr(line, '"'); quoted_len = last_quote - first_quote; if (quoted_len == 0) { set_parse_error(reader, 0, "Missing closing quotation mark in section header"); return -1; } GITERR_CHECK_ALLOC_ADD(&alloc_len, base_name_len, quoted_len); GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2); git_buf_grow(&buf, alloc_len); git_buf_printf(&buf, "%s.", base_name); rpos = 0; line = first_quote; c = line[++rpos]; /* * At the end of each iteration, whatever is stored in c will be * added to the string. In case of error, jump to out */ do { switch (c) { case 0: set_parse_error(reader, 0, "Unexpected end-of-line in section header"); git_buf_free(&buf); return -1; case '"': goto end_parse; case '\\': c = line[++rpos]; if (c == 0) { set_parse_error(reader, rpos, "Unexpected end-of-line in section header"); git_buf_free(&buf); return -1; } default: break; } git_buf_putc(&buf, (char)c); c = line[++rpos]; } while (line + rpos < last_quote); end_parse: if (line[rpos] != '"' || line[rpos + 1] != ']') { set_parse_error(reader, rpos, "Unexpected text after closing quotes"); git_buf_free(&buf); return -1; } *section_name = git_buf_detach(&buf); return 0; } static int parse_section_header(struct reader *reader, char **section_out) { char *name, *name_end; int name_length, c, pos; int result; char *line; size_t line_len; line = reader_readline(reader, true); if (line == NULL) return -1; /* find the end of the variable's name */ name_end = strrchr(line, ']'); if (name_end == NULL) { git__free(line); set_parse_error(reader, 0, "Missing ']' in section header"); return -1; } GITERR_CHECK_ALLOC_ADD(&line_len, (size_t)(name_end - line), 1); name = git__malloc(line_len); GITERR_CHECK_ALLOC(name); name_length = 0; pos = 0; /* Make sure we were given a section header */ c = line[pos++]; assert(c == '['); c = line[pos++]; do { if (git__isspace(c)){ name[name_length] = '\0'; result = parse_section_header_ext(reader, line, name, section_out); git__free(line); git__free(name); return result; } if (!config_keychar(c) && c != '.') { set_parse_error(reader, pos, "Unexpected character in header"); goto fail_parse; } name[name_length++] = (char)git__tolower(c); } while ((c = line[pos++]) != ']'); if (line[pos - 1] != ']') { set_parse_error(reader, pos, "Unexpected end of file"); goto fail_parse; } git__free(line); name[name_length] = 0; *section_out = name; return 0; fail_parse: git__free(line); git__free(name); return -1; } static int skip_bom(struct reader *reader) { git_bom_t bom; int bom_offset = git_buf_text_detect_bom(&bom, &reader->buffer, reader->read_ptr - reader->buffer.ptr); if (bom == GIT_BOM_UTF8) reader->read_ptr += bom_offset; /* TODO: reference implementation is pretty stupid with BoM */ return 0; } /* (* basic types *) digit = "0".."9" integer = digit { digit } alphabet = "a".."z" + "A" .. "Z" section_char = alphabet | "." | "-" extension_char = (* any character except newline *) any_char = (* any character *) variable_char = "alphabet" | "-" (* actual grammar *) config = { section } section = header { definition } header = "[" section [subsection | subsection_ext] "]" subsection = "." section subsection_ext = "\"" extension "\"" section = section_char { section_char } extension = extension_char { extension_char } definition = variable_name ["=" variable_value] "\n" variable_name = variable_char { variable_char } variable_value = string | boolean | integer string = quoted_string | plain_string quoted_string = "\"" plain_string "\"" plain_string = { any_char } boolean = boolean_true | boolean_false boolean_true = "yes" | "1" | "true" | "on" boolean_false = "no" | "0" | "false" | "off" */ static int strip_comments(char *line, int in_quotes) { int quote_count = in_quotes, backslash_count = 0; char *ptr; for (ptr = line; *ptr; ++ptr) { if (ptr[0] == '"' && ptr > line && ptr[-1] != '\\') quote_count++; if ((ptr[0] == ';' || ptr[0] == '#') && (quote_count % 2) == 0 && (backslash_count % 2) == 0) { ptr[0] = '\0'; break; } if (ptr[0] == '\\') backslash_count++; else backslash_count = 0; } /* skip any space at the end */ while (ptr > line && git__isspace(ptr[-1])) { ptr--; } ptr[0] = '\0'; return quote_count; } static int included_path(git_buf *out, const char *dir, const char *path) { /* From the user's home */ if (path[0] == '~' && path[1] == '/') return git_sysdir_find_global_file(out, &path[1]); return git_path_join_unrooted(out, path, dir, NULL); } static const char *escapes = "ntb\"\\"; static const char *escaped = "\n\t\b\"\\"; /* Escape the values to write them to the file */ static char *escape_value(const char *ptr) { git_buf buf = GIT_BUF_INIT; size_t len; const char *esc; assert(ptr); len = strlen(ptr); if (!len) return git__calloc(1, sizeof(char)); git_buf_grow(&buf, len); while (*ptr != '\0') { if ((esc = strchr(escaped, *ptr)) != NULL) { git_buf_putc(&buf, '\\'); git_buf_putc(&buf, escapes[esc - escaped]); } else { git_buf_putc(&buf, *ptr); } ptr++; } if (git_buf_oom(&buf)) { git_buf_free(&buf); return NULL; } return git_buf_detach(&buf); } /* '\"' -> '"' etc */ static int unescape_line( char **out, bool *is_multi, const char *ptr, int quote_count) { char *str, *fixed, *esc; size_t ptr_len = strlen(ptr), alloc_len; *is_multi = false; if (GIT_ADD_SIZET_OVERFLOW(&alloc_len, ptr_len, 1) || (str = git__malloc(alloc_len)) == NULL) { return -1; } fixed = str; while (*ptr != '\0') { if (*ptr == '"') { quote_count++; } else if (*ptr != '\\') { *fixed++ = *ptr; } else { /* backslash, check the next char */ ptr++; /* if we're at the end, it's a multiline, so keep the backslash */ if (*ptr == '\0') { *is_multi = true; goto done; } if ((esc = strchr(escapes, *ptr)) != NULL) { *fixed++ = escaped[esc - escapes]; } else { git__free(str); giterr_set(GITERR_CONFIG, "Invalid escape at %s", ptr); return -1; } } ptr++; } done: *fixed = '\0'; *out = str; return 0; } static int parse_multiline_variable(struct reader *reader, git_buf *value, int in_quotes) { char *line = NULL, *proc_line = NULL; int quote_count; bool multiline; /* Check that the next line exists */ line = reader_readline(reader, false); if (line == NULL) return -1; /* We've reached the end of the file, there is no continuation. * (this is not an error). */ if (line[0] == '\0') { git__free(line); return 0; } quote_count = strip_comments(line, !!in_quotes); /* If it was just a comment, pretend it didn't exist */ if (line[0] == '\0') { git__free(line); return parse_multiline_variable(reader, value, quote_count); /* TODO: unbounded recursion. This **could** be exploitable */ } if (unescape_line(&proc_line, &multiline, line, in_quotes) < 0) { git__free(line); return -1; } /* add this line to the multiline var */ git_buf_puts(value, proc_line); git__free(line); git__free(proc_line); /* * If we need to continue reading the next line, let's just * keep putting stuff in the buffer */ if (multiline) return parse_multiline_variable(reader, value, quote_count); return 0; } GIT_INLINE(bool) is_namechar(char c) { return isalnum(c) || c == '-'; } static int parse_name( char **name, const char **value, struct reader *reader, const char *line) { const char *name_end = line, *value_start; *name = NULL; *value = NULL; while (*name_end && is_namechar(*name_end)) name_end++; if (line == name_end) { set_parse_error(reader, 0, "Invalid configuration key"); return -1; } value_start = name_end; while (*value_start && git__isspace(*value_start)) value_start++; if (*value_start == '=') { *value = value_start + 1; } else if (*value_start) { set_parse_error(reader, 0, "Invalid configuration key"); return -1; } if ((*name = git__strndup(line, name_end - line)) == NULL) return -1; return 0; } static int parse_variable(struct reader *reader, char **var_name, char **var_value) { const char *value_start = NULL; char *line; int quote_count; bool multiline; line = reader_readline(reader, true); if (line == NULL) return -1; quote_count = strip_comments(line, 0); /* If there is no value, boolean true is assumed */ *var_value = NULL; if (parse_name(var_name, &value_start, reader, line) < 0) goto on_error; /* * Now, let's try to parse the value */ if (value_start != NULL) { while (git__isspace(value_start[0])) value_start++; if (unescape_line(var_value, &multiline, value_start, 0) < 0) goto on_error; if (multiline) { git_buf multi_value = GIT_BUF_INIT; git_buf_attach(&multi_value, *var_value, 0); if (parse_multiline_variable(reader, &multi_value, quote_count) < 0 || git_buf_oom(&multi_value)) { git_buf_free(&multi_value); goto on_error; } *var_value = git_buf_detach(&multi_value); } } git__free(line); return 0; on_error: git__free(*var_name); git__free(line); return -1; } static int config_parse( struct reader *reader, int (*on_section)(struct reader **reader, const char *current_section, const char *line, size_t line_len, void *data), int (*on_variable)(struct reader **reader, const char *current_section, char *var_name, char *var_value, const char *line, size_t line_len, void *data), int (*on_comment)(struct reader **reader, const char *line, size_t line_len, void *data), int (*on_eof)(struct reader **reader, void *data), void *data) { char *current_section = NULL, *var_name, *var_value, *line_start; char c; size_t line_len; int result = 0; skip_bom(reader); while (result == 0 && !reader->eof) { line_start = reader->read_ptr; c = reader_peek(reader, SKIP_WHITESPACE); switch (c) { case '\0': /* EOF when peeking, set EOF in the reader to exit the loop */ reader->eof = 1; break; case '[': /* section header, new section begins */ git__free(current_section); current_section = NULL; if ((result = parse_section_header(reader, ¤t_section)) == 0 && on_section) { line_len = reader->read_ptr - line_start; result = on_section(&reader, current_section, line_start, line_len, data); } break; case '\n': /* comment or whitespace-only */ case ';': case '#': reader_consume_line(reader); if (on_comment) { line_len = reader->read_ptr - line_start; result = on_comment(&reader, line_start, line_len, data); } break; default: /* assume variable declaration */ if ((result = parse_variable(reader, &var_name, &var_value)) == 0 && on_variable) { line_len = reader->read_ptr - line_start; result = on_variable(&reader, current_section, var_name, var_value, line_start, line_len, data); } break; } } if (on_eof) result = on_eof(&reader, data); git__free(current_section); return result; } struct parse_data { git_strmap *values; diskfile_backend *cfg_file; uint32_t reader_idx; git_config_level_t level; int depth; }; static int read_on_variable( struct reader **reader, const char *current_section, char *var_name, char *var_value, const char *line, size_t line_len, void *data) { struct parse_data *parse_data = (struct parse_data *)data; git_buf buf = GIT_BUF_INIT; cvar_t *var; int result = 0; GIT_UNUSED(line); GIT_UNUSED(line_len); git__strtolower(var_name); git_buf_printf(&buf, "%s.%s", current_section, var_name); git__free(var_name); if (git_buf_oom(&buf)) { git__free(var_value); return -1; } var = git__calloc(1, sizeof(cvar_t)); GITERR_CHECK_ALLOC(var); var->entry = git__calloc(1, sizeof(git_config_entry)); GITERR_CHECK_ALLOC(var->entry); var->entry->name = git_buf_detach(&buf); var->entry->value = var_value; var->entry->level = parse_data->level; var->included = !!parse_data->depth; if ((result = append_entry(parse_data->values, var)) < 0) return result; result = 0; /* Add or append the new config option */ if (!git__strcmp(var->entry->name, "include.path")) { struct reader *r; git_buf path = GIT_BUF_INIT; char *dir; uint32_t index; r = git_array_alloc(parse_data->cfg_file->readers); /* The reader may have been reallocated */ *reader = git_array_get(parse_data->cfg_file->readers, parse_data->reader_idx); memset(r, 0, sizeof(struct reader)); if ((result = git_path_dirname_r(&path, (*reader)->file_path)) < 0) return result; /* We need to know our index in the array, as the next config_parse call may realloc */ index = git_array_size(parse_data->cfg_file->readers) - 1; dir = git_buf_detach(&path); result = included_path(&path, dir, var->entry->value); git__free(dir); if (result < 0) return result; r->file_path = git_buf_detach(&path); git_buf_init(&r->buffer, 0); result = git_futils_readbuffer_updated( &r->buffer, r->file_path, &r->file_mtime, &r->file_size, NULL); if (result == 0) { result = config_read(parse_data->values, parse_data->cfg_file, r, parse_data->level, parse_data->depth+1); r = git_array_get(parse_data->cfg_file->readers, index); *reader = git_array_get(parse_data->cfg_file->readers, parse_data->reader_idx); } else if (result == GIT_ENOTFOUND) { giterr_clear(); result = 0; } git_buf_free(&r->buffer); } return result; } static int config_read(git_strmap *values, diskfile_backend *cfg_file, struct reader *reader, git_config_level_t level, int depth) { struct parse_data parse_data; if (depth >= MAX_INCLUDE_DEPTH) { giterr_set(GITERR_CONFIG, "Maximum config include depth reached"); return -1; } /* Initialize the reading position */ reader->read_ptr = reader->buffer.ptr; reader->eof = 0; /* If the file is empty, there's nothing for us to do */ if (*reader->read_ptr == '\0') return 0; parse_data.values = values; parse_data.cfg_file = cfg_file; parse_data.reader_idx = git_array_size(cfg_file->readers) - 1; parse_data.level = level; parse_data.depth = depth; return config_parse(reader, NULL, read_on_variable, NULL, NULL, &parse_data); } static int write_section(git_buf *fbuf, const char *key) { int result; const char *dot; git_buf buf = GIT_BUF_INIT; /* All of this just for [section "subsection"] */ dot = strchr(key, '.'); git_buf_putc(&buf, '['); if (dot == NULL) { git_buf_puts(&buf, key); } else { char *escaped; git_buf_put(&buf, key, dot - key); escaped = escape_value(dot + 1); GITERR_CHECK_ALLOC(escaped); git_buf_printf(&buf, " \"%s\"", escaped); git__free(escaped); } git_buf_puts(&buf, "]\n"); if (git_buf_oom(&buf)) return -1; result = git_buf_put(fbuf, git_buf_cstr(&buf), buf.size); git_buf_free(&buf); return result; } static const char *quotes_for_value(const char *value) { const char *ptr; if (value[0] == ' ' || value[0] == '\0') return "\""; for (ptr = value; *ptr; ++ptr) { if (*ptr == ';' || *ptr == '#') return "\""; } if (ptr[-1] == ' ') return "\""; return ""; } struct write_data { git_buf *buf; git_buf buffered_comment; unsigned int in_section : 1, preg_replaced : 1; const char *section; const char *name; const regex_t *preg; const char *value; }; static int write_line_to(git_buf *buf, const char *line, size_t line_len) { int result = git_buf_put(buf, line, line_len); if (!result && line_len && line[line_len-1] != '\n') result = git_buf_printf(buf, "\n"); return result; } static int write_line(struct write_data *write_data, const char *line, size_t line_len) { return write_line_to(write_data->buf, line, line_len); } static int write_value(struct write_data *write_data) { const char *q; int result; q = quotes_for_value(write_data->value); result = git_buf_printf(write_data->buf, "\t%s = %s%s%s\n", write_data->name, q, write_data->value, q); /* If we are updating a single name/value, we're done. Setting `value` * to `NULL` will prevent us from trying to write it again later (in * `write_on_section`) if we see the same section repeated. */ if (!write_data->preg) write_data->value = NULL; return result; } static int write_on_section( struct reader **reader, const char *current_section, const char *line, size_t line_len, void *data) { struct write_data *write_data = (struct write_data *)data; int result = 0; GIT_UNUSED(reader); /* If we were previously in the correct section (but aren't anymore) * and haven't written our value (for a simple name/value set, not * a multivar), then append it to the end of the section before writing * the new one. */ if (write_data->in_section && !write_data->preg && write_data->value) result = write_value(write_data); write_data->in_section = strcmp(current_section, write_data->section) == 0; /* * If there were comments just before this section, dump them as well. */ if (!result) { result = git_buf_put(write_data->buf, write_data->buffered_comment.ptr, write_data->buffered_comment.size); git_buf_clear(&write_data->buffered_comment); } if (!result) result = write_line(write_data, line, line_len); return result; } static int write_on_variable( struct reader **reader, const char *current_section, char *var_name, char *var_value, const char *line, size_t line_len, void *data) { struct write_data *write_data = (struct write_data *)data; bool has_matched = false; int error; GIT_UNUSED(reader); GIT_UNUSED(current_section); /* * If there were comments just before this variable, let's dump them as well. */ if ((error = git_buf_put(write_data->buf, write_data->buffered_comment.ptr, write_data->buffered_comment.size)) < 0) return error; git_buf_clear(&write_data->buffered_comment); /* See if we are to update this name/value pair; first examine name */ if (write_data->in_section && strcasecmp(write_data->name, var_name) == 0) has_matched = true; /* If we have a regex to match the value, see if it matches */ if (has_matched && write_data->preg != NULL) has_matched = (regexec(write_data->preg, var_value, 0, NULL, 0) == 0); git__free(var_name); git__free(var_value); /* If this isn't the name/value we're looking for, simply dump the * existing data back out and continue on. */ if (!has_matched) return write_line(write_data, line, line_len); write_data->preg_replaced = 1; /* If value is NULL, we are deleting this value; write nothing. */ if (!write_data->value) return 0; return write_value(write_data); } static int write_on_comment(struct reader **reader, const char *line, size_t line_len, void *data) { struct write_data *write_data; GIT_UNUSED(reader); write_data = (struct write_data *)data; return write_line_to(&write_data->buffered_comment, line, line_len); } static int write_on_eof(struct reader **reader, void *data) { struct write_data *write_data = (struct write_data *)data; int result = 0; GIT_UNUSED(reader); /* * If we've buffered comments when reaching EOF, make sure to dump them. */ if ((result = git_buf_put(write_data->buf, write_data->buffered_comment.ptr, write_data->buffered_comment.size)) < 0) return result; /* If we are at the EOF and have not written our value (again, for a * simple name/value set, not a multivar) then we have never seen the * section in question and should create a new section and write the * value. */ if ((!write_data->preg || !write_data->preg_replaced) && write_data->value) { if ((result = write_section(write_data->buf, write_data->section)) == 0) result = write_value(write_data); } return result; } /* * This is pretty much the parsing, except we write out anything we don't have */ static int config_write(diskfile_backend *cfg, const char *key, const regex_t *preg, const char* value) { int result; char *section, *name, *ldot; git_filebuf file = GIT_FILEBUF_INIT; git_buf buf = GIT_BUF_INIT; struct reader *reader = git_array_get(cfg->readers, 0); struct write_data write_data; if (cfg->locked) { result = git_buf_puts(&reader->buffer, git_buf_cstr(&cfg->locked_content)); } else { /* Lock the file */ if ((result = git_filebuf_open( &file, cfg->file_path, 0, GIT_CONFIG_FILE_MODE)) < 0) { git_buf_free(&reader->buffer); return result; } /* We need to read in our own config file */ result = git_futils_readbuffer(&reader->buffer, cfg->file_path); } /* Initialise the reading position */ if (result == GIT_ENOTFOUND) { reader->read_ptr = NULL; reader->eof = 1; git_buf_clear(&reader->buffer); } else if (result == 0) { reader->read_ptr = reader->buffer.ptr; reader->eof = 0; } else { git_filebuf_cleanup(&file); return -1; /* OS error when reading the file */ } ldot = strrchr(key, '.'); name = ldot + 1; section = git__strndup(key, ldot - key); write_data.buf = &buf; git_buf_init(&write_data.buffered_comment, 0); write_data.section = section; write_data.in_section = 0; write_data.preg_replaced = 0; write_data.name = name; write_data.preg = preg; write_data.value = value; result = config_parse(reader, write_on_section, write_on_variable, write_on_comment, write_on_eof, &write_data); git__free(section); git_buf_free(&write_data.buffered_comment); if (result < 0) { git_filebuf_cleanup(&file); goto done; } if (cfg->locked) { size_t len = buf.asize; /* Update our copy with the modified contents */ git_buf_free(&cfg->locked_content); git_buf_attach(&cfg->locked_content, git_buf_detach(&buf), len); } else { git_filebuf_write(&file, git_buf_cstr(&buf), git_buf_len(&buf)); /* refresh stats - if this errors, then commit will error too */ (void)git_filebuf_stats(&reader->file_mtime, &reader->file_size, &file); result = git_filebuf_commit(&file); } done: git_buf_free(&buf); git_buf_free(&reader->buffer); return result; } deps/libgit2-sys-0.3.8/libgit2/src/odb_mempack.c0000664000175000017500000001012412610310643016271 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "git2/object.h" #include "git2/sys/odb_backend.h" #include "fileops.h" #include "hash.h" #include "odb.h" #include "array.h" #include "oidmap.h" #include "git2/odb_backend.h" #include "git2/types.h" #include "git2/pack.h" GIT__USE_OIDMAP struct memobject { git_oid oid; size_t len; git_otype type; char data[]; }; struct memory_packer_db { git_odb_backend parent; git_oidmap *objects; git_array_t(struct memobject *) commits; }; static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void *data, size_t len, git_otype type) { struct memory_packer_db *db = (struct memory_packer_db *)_backend; struct memobject *obj = NULL; khiter_t pos; size_t alloc_len; int rval; pos = kh_put(oid, db->objects, oid, &rval); if (rval < 0) return -1; if (rval == 0) return 0; GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(struct memobject), len); obj = git__malloc(alloc_len); GITERR_CHECK_ALLOC(obj); memcpy(obj->data, data, len); git_oid_cpy(&obj->oid, oid); obj->len = len; obj->type = type; kh_key(db->objects, pos) = &obj->oid; kh_val(db->objects, pos) = obj; if (type == GIT_OBJ_COMMIT) { struct memobject **store = git_array_alloc(db->commits); GITERR_CHECK_ALLOC(store); *store = obj; } return 0; } static int impl__exists(git_odb_backend *backend, const git_oid *oid) { struct memory_packer_db *db = (struct memory_packer_db *)backend; khiter_t pos; pos = kh_get(oid, db->objects, oid); if (pos != kh_end(db->objects)) return 1; return 0; } static int impl__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid) { struct memory_packer_db *db = (struct memory_packer_db *)backend; struct memobject *obj = NULL; khiter_t pos; pos = kh_get(oid, db->objects, oid); if (pos == kh_end(db->objects)) return GIT_ENOTFOUND; obj = kh_val(db->objects, pos); *len_p = obj->len; *type_p = obj->type; *buffer_p = git__malloc(obj->len); GITERR_CHECK_ALLOC(*buffer_p); memcpy(*buffer_p, obj->data, obj->len); return 0; } static int impl__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid) { struct memory_packer_db *db = (struct memory_packer_db *)backend; struct memobject *obj = NULL; khiter_t pos; pos = kh_get(oid, db->objects, oid); if (pos == kh_end(db->objects)) return GIT_ENOTFOUND; obj = kh_val(db->objects, pos); *len_p = obj->len; *type_p = obj->type; return 0; } int git_mempack_dump(git_buf *pack, git_repository *repo, git_odb_backend *_backend) { struct memory_packer_db *db = (struct memory_packer_db *)_backend; git_packbuilder *packbuilder; uint32_t i; int err = -1; if (git_packbuilder_new(&packbuilder, repo) < 0) return -1; for (i = 0; i < db->commits.size; ++i) { struct memobject *commit = db->commits.ptr[i]; err = git_packbuilder_insert_commit(packbuilder, &commit->oid); if (err < 0) goto cleanup; } err = git_packbuilder_write_buf(pack, packbuilder); cleanup: git_packbuilder_free(packbuilder); return err; } void git_mempack_reset(git_odb_backend *_backend) { struct memory_packer_db *db = (struct memory_packer_db *)_backend; struct memobject *object = NULL; kh_foreach_value(db->objects, object, { git__free(object); }); git_array_clear(db->commits); git_oidmap_clear(db->objects); } static void impl__free(git_odb_backend *_backend) { struct memory_packer_db *db = (struct memory_packer_db *)_backend; git_oidmap_free(db->objects); git__free(db); } int git_mempack_new(git_odb_backend **out) { struct memory_packer_db *db; assert(out); db = git__calloc(1, sizeof(struct memory_packer_db)); GITERR_CHECK_ALLOC(db); db->objects = git_oidmap_alloc(); db->parent.read = &impl__read; db->parent.write = &impl__write; db->parent.read_header = &impl__read_header; db->parent.exists = &impl__exists; db->parent.free = &impl__free; *out = (git_odb_backend *)db; return 0; } deps/libgit2-sys-0.3.8/libgit2/src/sysdir.h0000664000175000017500000000575212426525445015402 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sysdir_h__ #define INCLUDE_sysdir_h__ #include "common.h" #include "posix.h" #include "buffer.h" /** * Find a "global" file (i.e. one in a user's home directory). * * @param path buffer to write the full path into * @param filename name of file to find in the home directory * @return 0 if found, GIT_ENOTFOUND if not found, or -1 on other OS error */ extern int git_sysdir_find_global_file(git_buf *path, const char *filename); /** * Find an "XDG" file (i.e. one in user's XDG config path). * * @param path buffer to write the full path into * @param filename name of file to find in the home directory * @return 0 if found, GIT_ENOTFOUND if not found, or -1 on other OS error */ extern int git_sysdir_find_xdg_file(git_buf *path, const char *filename); /** * Find a "system" file (i.e. one shared for all users of the system). * * @param path buffer to write the full path into * @param filename name of file to find in the home directory * @return 0 if found, GIT_ENOTFOUND if not found, or -1 on other OS error */ extern int git_sysdir_find_system_file(git_buf *path, const char *filename); /** * Find template directory. * * @param path buffer to write the full path into * @return 0 if found, GIT_ENOTFOUND if not found, or -1 on other OS error */ extern int git_sysdir_find_template_dir(git_buf *path); typedef enum { GIT_SYSDIR_SYSTEM = 0, GIT_SYSDIR_GLOBAL = 1, GIT_SYSDIR_XDG = 2, GIT_SYSDIR_TEMPLATE = 3, GIT_SYSDIR__MAX = 4, } git_sysdir_t; /** * Configures global data for configuration file search paths. * * @return 0 on success, <0 on failure */ extern int git_sysdir_global_init(void); /** * Get the search path for global/system/xdg files * * @param out pointer to git_buf containing search path * @param which which list of paths to return * @return 0 on success, <0 on failure */ extern int git_sysdir_get(const git_buf **out, git_sysdir_t which); /** * Get search path into a preallocated buffer * * @param out String buffer to write into * @param outlen Size of string buffer * @param which Which search path to return * @return 0 on success, GIT_EBUFS if out is too small, <0 on other failure */ extern int git_sysdir_get_str(char *out, size_t outlen, git_sysdir_t which); /** * Set search paths for global/system/xdg files * * The first occurrence of the magic string "$PATH" in the new value will * be replaced with the old value of the search path. * * @param which Which search path to modify * @param paths New search path (separated by GIT_PATH_LIST_SEPARATOR) * @return 0 on success, <0 on failure (allocation error) */ extern int git_sysdir_set(git_sysdir_t which, const char *paths); /** * Free the configuration file search paths. */ extern void git_sysdir_global_shutdown(void); #endif /* INCLUDE_sysdir_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/netops.c0000664000175000017500000001530412555730137015361 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include #include "git2/errors.h" #include "common.h" #include "netops.h" #include "posix.h" #include "buffer.h" #include "http_parser.h" #include "global.h" int gitno_recv(gitno_buffer *buf) { return buf->recv(buf); } void gitno_buffer_setup_callback( gitno_buffer *buf, char *data, size_t len, int (*recv)(gitno_buffer *buf), void *cb_data) { memset(data, 0x0, len); buf->data = data; buf->len = len; buf->offset = 0; buf->recv = recv; buf->cb_data = cb_data; } static int recv_stream(gitno_buffer *buf) { git_stream *io = (git_stream *) buf->cb_data; int ret; ret = git_stream_read(io, buf->data + buf->offset, buf->len - buf->offset); if (ret < 0) return -1; buf->offset += ret; return ret; } void gitno_buffer_setup_fromstream(git_stream *st, gitno_buffer *buf, char *data, size_t len) { memset(data, 0x0, len); buf->data = data; buf->len = len; buf->offset = 0; buf->recv = recv_stream; buf->cb_data = st; } /* Consume up to ptr and move the rest of the buffer to the beginning */ void gitno_consume(gitno_buffer *buf, const char *ptr) { size_t consumed; assert(ptr - buf->data >= 0); assert(ptr - buf->data <= (int) buf->len); consumed = ptr - buf->data; memmove(buf->data, ptr, buf->offset - consumed); memset(buf->data + buf->offset, 0x0, buf->len - buf->offset); buf->offset -= consumed; } /* Consume const bytes and move the rest of the buffer to the beginning */ void gitno_consume_n(gitno_buffer *buf, size_t cons) { memmove(buf->data, buf->data + cons, buf->len - buf->offset); memset(buf->data + cons, 0x0, buf->len - buf->offset); buf->offset -= cons; } /* Match host names according to RFC 2818 rules */ int gitno__match_host(const char *pattern, const char *host) { for (;;) { char c = git__tolower(*pattern++); if (c == '\0') return *host ? -1 : 0; if (c == '*') { c = *pattern; /* '*' at the end matches everything left */ if (c == '\0') return 0; /* * We've found a pattern, so move towards the next matching * char. The '.' is handled specially because wildcards aren't * allowed to cross subdomains. */ while(*host) { char h = git__tolower(*host); if (c == h) return gitno__match_host(pattern, host++); if (h == '.') return gitno__match_host(pattern, host); host++; } return -1; } if (c != git__tolower(*host++)) return -1; } return -1; } static const char *prefix_http = "http://"; static const char *prefix_https = "https://"; int gitno_connection_data_from_url( gitno_connection_data *data, const char *url, const char *service_suffix) { int error = -1; const char *default_port = NULL, *path_search_start = NULL; char *original_host = NULL; /* service_suffix is optional */ assert(data && url); /* Save these for comparison later */ original_host = data->host; data->host = NULL; gitno_connection_data_free_ptrs(data); if (!git__prefixcmp(url, prefix_http)) { path_search_start = url + strlen(prefix_http); default_port = "80"; if (data->use_ssl) { giterr_set(GITERR_NET, "Redirect from HTTPS to HTTP is not allowed"); goto cleanup; } } else if (!git__prefixcmp(url, prefix_https)) { path_search_start = url + strlen(prefix_https); default_port = "443"; data->use_ssl = true; } else if (url[0] == '/') default_port = data->use_ssl ? "443" : "80"; if (!default_port) { giterr_set(GITERR_NET, "Unrecognized URL prefix"); goto cleanup; } error = gitno_extract_url_parts( &data->host, &data->port, &data->path, &data->user, &data->pass, url, default_port); if (url[0] == '/') { /* Relative redirect; reuse original host name and port */ path_search_start = url; git__free(data->host); data->host = original_host; original_host = NULL; } if (!error) { const char *path = strchr(path_search_start, '/'); size_t pathlen = strlen(path); size_t suffixlen = service_suffix ? strlen(service_suffix) : 0; if (suffixlen && !memcmp(path + pathlen - suffixlen, service_suffix, suffixlen)) { git__free(data->path); data->path = git__strndup(path, pathlen - suffixlen); } else { git__free(data->path); data->path = git__strdup(path); } /* Check for errors in the resulting data */ if (original_host && url[0] != '/' && strcmp(original_host, data->host)) { giterr_set(GITERR_NET, "Cross host redirect not allowed"); error = -1; } } cleanup: if (original_host) git__free(original_host); return error; } void gitno_connection_data_free_ptrs(gitno_connection_data *d) { git__free(d->host); d->host = NULL; git__free(d->port); d->port = NULL; git__free(d->path); d->path = NULL; git__free(d->user); d->user = NULL; git__free(d->pass); d->pass = NULL; } #define hex2c(c) ((c | 32) % 39 - 9) static char* unescape(char *str) { int x, y; int len = (int)strlen(str); for (x=y=0; str[y]; ++x, ++y) { if ((str[x] = str[y]) == '%') { if (y < len-2 && isxdigit(str[y+1]) && isxdigit(str[y+2])) { str[x] = (hex2c(str[y+1]) << 4) + hex2c(str[y+2]); y += 2; } } } str[x] = '\0'; return str; } int gitno_extract_url_parts( char **host, char **port, char **path, char **username, char **password, const char *url, const char *default_port) { struct http_parser_url u = {0}; const char *_host, *_port, *_path, *_userinfo; if (http_parser_parse_url(url, strlen(url), false, &u)) { giterr_set(GITERR_NET, "Malformed URL '%s'", url); return GIT_EINVALIDSPEC; } _host = url+u.field_data[UF_HOST].off; _port = url+u.field_data[UF_PORT].off; _path = url+u.field_data[UF_PATH].off; _userinfo = url+u.field_data[UF_USERINFO].off; if (u.field_set & (1 << UF_HOST)) { *host = git__substrdup(_host, u.field_data[UF_HOST].len); GITERR_CHECK_ALLOC(*host); } if (u.field_set & (1 << UF_PORT)) *port = git__substrdup(_port, u.field_data[UF_PORT].len); else *port = git__strdup(default_port); GITERR_CHECK_ALLOC(*port); if (u.field_set & (1 << UF_PATH)) { *path = git__substrdup(_path, u.field_data[UF_PATH].len); GITERR_CHECK_ALLOC(*path); } else { giterr_set(GITERR_NET, "invalid url, missing path"); return GIT_EINVALIDSPEC; } if (u.field_set & (1 << UF_USERINFO)) { const char *colon = memchr(_userinfo, ':', u.field_data[UF_USERINFO].len); if (colon) { *username = unescape(git__substrdup(_userinfo, colon - _userinfo)); *password = unescape(git__substrdup(colon+1, u.field_data[UF_USERINFO].len - (colon+1-_userinfo))); GITERR_CHECK_ALLOC(*password); } else { *username = git__substrdup(_userinfo, u.field_data[UF_USERINFO].len); } GITERR_CHECK_ALLOC(*username); } return 0; } deps/libgit2-sys-0.3.8/libgit2/src/merge_file.c0000664000175000017500000002170012610310643016130 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "repository.h" #include "posix.h" #include "fileops.h" #include "index.h" #include "diff_xdiff.h" #include "git2/repository.h" #include "git2/object.h" #include "git2/index.h" #include "git2/merge.h" #include "xdiff/xdiff.h" /* only examine the first 8000 bytes for binaryness. * https://github.com/git/git/blob/77bd3ea9f54f1584147b594abc04c26ca516d987/xdiff-interface.c#L197 */ #define GIT_MERGE_FILE_BINARY_SIZE 8000 #define GIT_MERGE_FILE_SIDE_EXISTS(X) ((X)->mode != 0) GIT_INLINE(const char *) merge_file_best_path( const git_merge_file_input *ancestor, const git_merge_file_input *ours, const git_merge_file_input *theirs) { if (!ancestor) { if (ours && theirs && strcmp(ours->path, theirs->path) == 0) return ours->path; return NULL; } if (ours && strcmp(ancestor->path, ours->path) == 0) return theirs ? theirs->path : NULL; else if(theirs && strcmp(ancestor->path, theirs->path) == 0) return ours ? ours->path : NULL; return NULL; } GIT_INLINE(int) merge_file_best_mode( const git_merge_file_input *ancestor, const git_merge_file_input *ours, const git_merge_file_input *theirs) { /* * If ancestor didn't exist and either ours or theirs is executable, * assume executable. Otherwise, if any mode changed from the ancestor, * use that one. */ if (!ancestor) { if ((ours && ours->mode == GIT_FILEMODE_BLOB_EXECUTABLE) || (theirs && theirs->mode == GIT_FILEMODE_BLOB_EXECUTABLE)) return GIT_FILEMODE_BLOB_EXECUTABLE; return GIT_FILEMODE_BLOB; } else if (ours && theirs) { if (ancestor->mode == ours->mode) return theirs->mode; return ours->mode; } return 0; } int git_merge_file__input_from_index( git_merge_file_input *input_out, git_odb_object **odb_object_out, git_odb *odb, const git_index_entry *entry) { int error = 0; assert(input_out && odb_object_out && odb && entry); if ((error = git_odb_read(odb_object_out, odb, &entry->id)) < 0) goto done; input_out->path = entry->path; input_out->mode = entry->mode; input_out->ptr = (char *)git_odb_object_data(*odb_object_out); input_out->size = git_odb_object_size(*odb_object_out); done: return error; } static void merge_file_normalize_opts( git_merge_file_options *out, const git_merge_file_options *given_opts) { if (given_opts) memcpy(out, given_opts, sizeof(git_merge_file_options)); else { git_merge_file_options default_opts = GIT_MERGE_FILE_OPTIONS_INIT; memcpy(out, &default_opts, sizeof(git_merge_file_options)); } } static int merge_file__xdiff( git_merge_file_result *out, const git_merge_file_input *ancestor, const git_merge_file_input *ours, const git_merge_file_input *theirs, const git_merge_file_options *given_opts) { xmparam_t xmparam; mmfile_t ancestor_mmfile = {0}, our_mmfile = {0}, their_mmfile = {0}; mmbuffer_t mmbuffer; git_merge_file_options options = GIT_MERGE_FILE_OPTIONS_INIT; const char *path; int xdl_result; int error = 0; memset(out, 0x0, sizeof(git_merge_file_result)); merge_file_normalize_opts(&options, given_opts); memset(&xmparam, 0x0, sizeof(xmparam_t)); if (ancestor) { xmparam.ancestor = (options.ancestor_label) ? options.ancestor_label : ancestor->path; ancestor_mmfile.ptr = (char *)ancestor->ptr; ancestor_mmfile.size = ancestor->size; } xmparam.file1 = (options.our_label) ? options.our_label : ours->path; our_mmfile.ptr = (char *)ours->ptr; our_mmfile.size = ours->size; xmparam.file2 = (options.their_label) ? options.their_label : theirs->path; their_mmfile.ptr = (char *)theirs->ptr; their_mmfile.size = theirs->size; if (options.favor == GIT_MERGE_FILE_FAVOR_OURS) xmparam.favor = XDL_MERGE_FAVOR_OURS; else if (options.favor == GIT_MERGE_FILE_FAVOR_THEIRS) xmparam.favor = XDL_MERGE_FAVOR_THEIRS; else if (options.favor == GIT_MERGE_FILE_FAVOR_UNION) xmparam.favor = XDL_MERGE_FAVOR_UNION; xmparam.level = (options.flags & GIT_MERGE_FILE_SIMPLIFY_ALNUM) ? XDL_MERGE_ZEALOUS_ALNUM : XDL_MERGE_ZEALOUS; if (options.flags & GIT_MERGE_FILE_STYLE_DIFF3) xmparam.style = XDL_MERGE_DIFF3; if (options.flags & GIT_MERGE_FILE_IGNORE_WHITESPACE) xmparam.xpp.flags |= XDF_IGNORE_WHITESPACE; if (options.flags & GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE) xmparam.xpp.flags |= XDF_IGNORE_WHITESPACE_CHANGE; if (options.flags & GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL) xmparam.xpp.flags |= XDF_IGNORE_WHITESPACE_AT_EOL; if (options.flags & GIT_MERGE_FILE_DIFF_PATIENCE) xmparam.xpp.flags |= XDF_PATIENCE_DIFF; if (options.flags & GIT_MERGE_FILE_DIFF_MINIMAL) xmparam.xpp.flags |= XDF_NEED_MINIMAL; if ((xdl_result = xdl_merge(&ancestor_mmfile, &our_mmfile, &their_mmfile, &xmparam, &mmbuffer)) < 0) { giterr_set(GITERR_MERGE, "Failed to merge files."); error = -1; goto done; } if ((path = merge_file_best_path(ancestor, ours, theirs)) != NULL && (out->path = strdup(path)) == NULL) { error = -1; goto done; } out->automergeable = (xdl_result == 0); out->ptr = (const char *)mmbuffer.ptr; out->len = mmbuffer.size; out->mode = merge_file_best_mode(ancestor, ours, theirs); done: if (error < 0) git_merge_file_result_free(out); return error; } static bool merge_file__is_binary(const git_merge_file_input *file) { size_t len = file ? file->size : 0; if (len > GIT_XDIFF_MAX_SIZE) return true; if (len > GIT_MERGE_FILE_BINARY_SIZE) len = GIT_MERGE_FILE_BINARY_SIZE; return len ? (memchr(file->ptr, 0, len) != NULL) : false; } static int merge_file__binary( git_merge_file_result *out, const git_merge_file_input *ours, const git_merge_file_input *theirs, const git_merge_file_options *given_opts) { const git_merge_file_input *favored = NULL; memset(out, 0x0, sizeof(git_merge_file_result)); if (given_opts && given_opts->favor == GIT_MERGE_FILE_FAVOR_OURS) favored = ours; else if (given_opts && given_opts->favor == GIT_MERGE_FILE_FAVOR_THEIRS) favored = theirs; else goto done; if ((out->path = git__strdup(favored->path)) == NULL || (out->ptr = git__malloc(favored->size)) == NULL) goto done; memcpy((char *)out->ptr, favored->ptr, favored->size); out->len = favored->size; out->mode = favored->mode; out->automergeable = 1; done: return 0; } static int merge_file__from_inputs( git_merge_file_result *out, const git_merge_file_input *ancestor, const git_merge_file_input *ours, const git_merge_file_input *theirs, const git_merge_file_options *given_opts) { if (merge_file__is_binary(ancestor) || merge_file__is_binary(ours) || merge_file__is_binary(theirs)) return merge_file__binary(out, ours, theirs, given_opts); return merge_file__xdiff(out, ancestor, ours, theirs, given_opts); } static git_merge_file_input *git_merge_file__normalize_inputs( git_merge_file_input *out, const git_merge_file_input *given) { memcpy(out, given, sizeof(git_merge_file_input)); if (!out->path) out->path = "file.txt"; if (!out->mode) out->mode = 0100644; return out; } int git_merge_file( git_merge_file_result *out, const git_merge_file_input *ancestor, const git_merge_file_input *ours, const git_merge_file_input *theirs, const git_merge_file_options *options) { git_merge_file_input inputs[3] = { {0} }; assert(out && ours && theirs); memset(out, 0x0, sizeof(git_merge_file_result)); if (ancestor) ancestor = git_merge_file__normalize_inputs(&inputs[0], ancestor); ours = git_merge_file__normalize_inputs(&inputs[1], ours); theirs = git_merge_file__normalize_inputs(&inputs[2], theirs); return merge_file__from_inputs(out, ancestor, ours, theirs, options); } int git_merge_file_from_index( git_merge_file_result *out, git_repository *repo, const git_index_entry *ancestor, const git_index_entry *ours, const git_index_entry *theirs, const git_merge_file_options *options) { git_merge_file_input *ancestor_ptr = NULL, ancestor_input = {0}, our_input = {0}, their_input = {0}; git_odb *odb = NULL; git_odb_object *odb_object[3] = { 0 }; int error = 0; assert(out && repo && ours && theirs); memset(out, 0x0, sizeof(git_merge_file_result)); if ((error = git_repository_odb(&odb, repo)) < 0) goto done; if (ancestor) { if ((error = git_merge_file__input_from_index( &ancestor_input, &odb_object[0], odb, ancestor)) < 0) goto done; ancestor_ptr = &ancestor_input; } if ((error = git_merge_file__input_from_index( &our_input, &odb_object[1], odb, ours)) < 0 || (error = git_merge_file__input_from_index( &their_input, &odb_object[2], odb, theirs)) < 0) goto done; error = merge_file__from_inputs(out, ancestor_ptr, &our_input, &their_input, options); done: git_odb_object_free(odb_object[0]); git_odb_object_free(odb_object[1]); git_odb_object_free(odb_object[2]); git_odb_free(odb); return error; } void git_merge_file_result_free(git_merge_file_result *result) { if (result == NULL) return; git__free((char *)result->path); git__free((char *)result->ptr); } deps/libgit2-sys-0.3.8/libgit2/src/repository.h0000664000175000017500000001436312555730137016301 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_repository_h__ #define INCLUDE_repository_h__ #include "git2/common.h" #include "git2/oid.h" #include "git2/odb.h" #include "git2/repository.h" #include "git2/object.h" #include "git2/config.h" #include "array.h" #include "cache.h" #include "refs.h" #include "buffer.h" #include "object.h" #include "attrcache.h" #include "submodule.h" #include "diff_driver.h" #define DOT_GIT ".git" #define GIT_DIR DOT_GIT "/" #define GIT_DIR_MODE 0755 #define GIT_BARE_DIR_MODE 0777 /* Default DOS-compatible 8.3 "short name" for a git repository, "GIT~1" */ #define GIT_DIR_SHORTNAME "GIT~1" /** Cvar cache identifiers */ typedef enum { GIT_CVAR_AUTO_CRLF = 0, /* core.autocrlf */ GIT_CVAR_EOL, /* core.eol */ GIT_CVAR_SYMLINKS, /* core.symlinks */ GIT_CVAR_IGNORECASE, /* core.ignorecase */ GIT_CVAR_FILEMODE, /* core.filemode */ GIT_CVAR_IGNORESTAT, /* core.ignorestat */ GIT_CVAR_TRUSTCTIME, /* core.trustctime */ GIT_CVAR_ABBREV, /* core.abbrev */ GIT_CVAR_PRECOMPOSE, /* core.precomposeunicode */ GIT_CVAR_SAFE_CRLF, /* core.safecrlf */ GIT_CVAR_LOGALLREFUPDATES, /* core.logallrefupdates */ GIT_CVAR_PROTECTHFS, /* core.protectHFS */ GIT_CVAR_PROTECTNTFS, /* core.protectNTFS */ GIT_CVAR_CACHE_MAX } git_cvar_cached; /** * CVAR value enumerations * * These are the values that are actually stored in the cvar cache, instead * of their string equivalents. These values are internal and symbolic; * make sure that none of them is set to `-1`, since that is the unique * identifier for "not cached" */ typedef enum { /* The value hasn't been loaded from the cache yet */ GIT_CVAR_NOT_CACHED = -1, /* core.safecrlf: false, 'fail', 'warn' */ GIT_SAFE_CRLF_FALSE = 0, GIT_SAFE_CRLF_FAIL = 1, GIT_SAFE_CRLF_WARN = 2, /* core.autocrlf: false, true, 'input; */ GIT_AUTO_CRLF_FALSE = 0, GIT_AUTO_CRLF_TRUE = 1, GIT_AUTO_CRLF_INPUT = 2, GIT_AUTO_CRLF_DEFAULT = GIT_AUTO_CRLF_FALSE, /* core.eol: unset, 'crlf', 'lf', 'native' */ GIT_EOL_UNSET = 0, GIT_EOL_CRLF = 1, GIT_EOL_LF = 2, #ifdef GIT_WIN32 GIT_EOL_NATIVE = GIT_EOL_CRLF, #else GIT_EOL_NATIVE = GIT_EOL_LF, #endif GIT_EOL_DEFAULT = GIT_EOL_NATIVE, /* core.symlinks: bool */ GIT_SYMLINKS_DEFAULT = GIT_CVAR_TRUE, /* core.ignorecase */ GIT_IGNORECASE_DEFAULT = GIT_CVAR_FALSE, /* core.filemode */ GIT_FILEMODE_DEFAULT = GIT_CVAR_TRUE, /* core.ignorestat */ GIT_IGNORESTAT_DEFAULT = GIT_CVAR_FALSE, /* core.trustctime */ GIT_TRUSTCTIME_DEFAULT = GIT_CVAR_TRUE, /* core.abbrev */ GIT_ABBREV_DEFAULT = 7, /* core.precomposeunicode */ GIT_PRECOMPOSE_DEFAULT = GIT_CVAR_FALSE, /* core.safecrlf */ GIT_SAFE_CRLF_DEFAULT = GIT_CVAR_FALSE, /* core.logallrefupdates */ GIT_LOGALLREFUPDATES_UNSET = 2, GIT_LOGALLREFUPDATES_DEFAULT = GIT_LOGALLREFUPDATES_UNSET, /* core.protectHFS */ GIT_PROTECTHFS_DEFAULT = GIT_CVAR_FALSE, /* core.protectNTFS */ GIT_PROTECTNTFS_DEFAULT = GIT_CVAR_FALSE, } git_cvar_value; /* internal repository init flags */ enum { GIT_REPOSITORY_INIT__HAS_DOTGIT = (1u << 16), GIT_REPOSITORY_INIT__NATURAL_WD = (1u << 17), GIT_REPOSITORY_INIT__IS_REINIT = (1u << 18), }; /** Internal structure for repository object */ struct git_repository { git_odb *_odb; git_refdb *_refdb; git_config *_config; git_index *_index; git_cache objects; git_attr_cache *attrcache; git_diff_driver_registry *diff_drivers; char *path_repository; char *path_gitlink; char *workdir; char *namespace; char *ident_name; char *ident_email; git_array_t(git_buf) reserved_names; unsigned is_bare:1; unsigned int lru_counter; git_atomic attr_session_key; git_cvar_value cvar_cache[GIT_CVAR_CACHE_MAX]; }; GIT_INLINE(git_attr_cache *) git_repository_attr_cache(git_repository *repo) { return repo->attrcache; } int git_repository_head_tree(git_tree **tree, git_repository *repo); /* * Weak pointers to repository internals. * * The returned pointers do not need to be freed. Do not keep * permanent references to these (i.e. between API calls), since they may * become invalidated if the user replaces a repository internal. */ int git_repository_config__weakptr(git_config **out, git_repository *repo); int git_repository_odb__weakptr(git_odb **out, git_repository *repo); int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo); int git_repository_index__weakptr(git_index **out, git_repository *repo); /* * CVAR cache * * Efficient access to the most used config variables of a repository. * The cache is cleared every time the config backend is replaced. */ int git_repository__cvar(int *out, git_repository *repo, git_cvar_cached cvar); void git_repository__cvar_cache_clear(git_repository *repo); GIT_INLINE(int) git_repository__ensure_not_bare( git_repository *repo, const char *operation_name) { if (!git_repository_is_bare(repo)) return 0; giterr_set( GITERR_REPOSITORY, "Cannot %s. This operation is not allowed against bare repositories.", operation_name); return GIT_EBAREREPO; } int git_repository__set_orig_head(git_repository *repo, const git_oid *orig_head); int git_repository__cleanup_files(git_repository *repo, const char *files[], size_t files_len); /* The default "reserved names" for a repository */ extern git_buf git_repository__reserved_names_win32[]; extern size_t git_repository__reserved_names_win32_len; extern git_buf git_repository__reserved_names_posix[]; extern size_t git_repository__reserved_names_posix_len; /* * Gets any "reserved names" in the repository. This will return paths * that should not be allowed in the repository (like ".git") to avoid * conflicting with the repository path, or with alternate mechanisms to * the repository path (eg, "GIT~1"). Every attempt will be made to look * up all possible reserved names - if there was a conflict for the shortname * GIT~1, for example, this function will try to look up the alternate * shortname. If that fails, this function returns false, but out and outlen * will still be populated with good defaults. */ bool git_repository__reserved_names( git_buf **out, size_t *outlen, git_repository *repo, bool include_ntfs); #endif deps/libgit2-sys-0.3.8/libgit2/src/sha1_lookup.c0000664000175000017500000001602412426525445016277 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include #include "sha1_lookup.h" #include "common.h" #include "oid.h" /* * Conventional binary search loop looks like this: * * unsigned lo, hi; * do { * unsigned mi = (lo + hi) / 2; * int cmp = "entry pointed at by mi" minus "target"; * if (!cmp) * return (mi is the wanted one) * if (cmp > 0) * hi = mi; "mi is larger than target" * else * lo = mi+1; "mi is smaller than target" * } while (lo < hi); * * The invariants are: * * - When entering the loop, lo points at a slot that is never * above the target (it could be at the target), hi points at a * slot that is guaranteed to be above the target (it can never * be at the target). * * - We find a point 'mi' between lo and hi (mi could be the same * as lo, but never can be as same as hi), and check if it hits * the target. There are three cases: * * - if it is a hit, we are happy. * * - if it is strictly higher than the target, we set it to hi, * and repeat the search. * * - if it is strictly lower than the target, we update lo to * one slot after it, because we allow lo to be at the target. * * If the loop exits, there is no matching entry. * * When choosing 'mi', we do not have to take the "middle" but * anywhere in between lo and hi, as long as lo <= mi < hi is * satisfied. When we somehow know that the distance between the * target and lo is much shorter than the target and hi, we could * pick mi that is much closer to lo than the midway. * * Now, we can take advantage of the fact that SHA-1 is a good hash * function, and as long as there are enough entries in the table, we * can expect uniform distribution. An entry that begins with for * example "deadbeef..." is much likely to appear much later than in * the midway of the table. It can reasonably be expected to be near * 87% (222/256) from the top of the table. * * However, we do not want to pick "mi" too precisely. If the entry at * the 87% in the above example turns out to be higher than the target * we are looking for, we would end up narrowing the search space down * only by 13%, instead of 50% we would get if we did a simple binary * search. So we would want to hedge our bets by being less aggressive. * * The table at "table" holds at least "nr" entries of "elem_size" * bytes each. Each entry has the SHA-1 key at "key_offset". The * table is sorted by the SHA-1 key of the entries. The caller wants * to find the entry with "key", and knows that the entry at "lo" is * not higher than the entry it is looking for, and that the entry at * "hi" is higher than the entry it is looking for. */ int sha1_entry_pos(const void *table, size_t elem_size, size_t key_offset, unsigned lo, unsigned hi, unsigned nr, const unsigned char *key) { const unsigned char *base = (const unsigned char*)table; const unsigned char *hi_key, *lo_key; unsigned ofs_0; if (!nr || lo >= hi) return -1; if (nr == hi) hi_key = NULL; else hi_key = base + elem_size * hi + key_offset; lo_key = base + elem_size * lo + key_offset; ofs_0 = 0; do { int cmp; unsigned ofs, mi, range; unsigned lov, hiv, kyv; const unsigned char *mi_key; range = hi - lo; if (hi_key) { for (ofs = ofs_0; ofs < 20; ofs++) if (lo_key[ofs] != hi_key[ofs]) break; ofs_0 = ofs; /* * byte 0 thru (ofs-1) are the same between * lo and hi; ofs is the first byte that is * different. * * If ofs==20, then no bytes are different, * meaning we have entries with duplicate * keys. We know that we are in a solid run * of this entry (because the entries are * sorted, and our lo and hi are the same, * there can be nothing but this single key * in between). So we can stop the search. * Either one of these entries is it (and * we do not care which), or we do not have * it. * * Furthermore, we know that one of our * endpoints must be the edge of the run of * duplicates. For example, given this * sequence: * * idx 0 1 2 3 4 5 * key A C C C C D * * If we are searching for "B", we might * hit the duplicate run at lo=1, hi=3 * (e.g., by first mi=3, then mi=0). But we * can never have lo > 1, because B < C. * That is, if our key is less than the * run, we know that "lo" is the edge, but * we can say nothing of "hi". Similarly, * if our key is greater than the run, we * know that "hi" is the edge, but we can * say nothing of "lo". * * Therefore if we do not find it, we also * know where it would go if it did exist: * just on the far side of the edge that we * know about. */ if (ofs == 20) { mi = lo; mi_key = base + elem_size * mi + key_offset; cmp = memcmp(mi_key, key, 20); if (!cmp) return mi; if (cmp < 0) return -1 - hi; else return -1 - lo; } hiv = hi_key[ofs_0]; if (ofs_0 < 19) hiv = (hiv << 8) | hi_key[ofs_0+1]; } else { hiv = 256; if (ofs_0 < 19) hiv <<= 8; } lov = lo_key[ofs_0]; kyv = key[ofs_0]; if (ofs_0 < 19) { lov = (lov << 8) | lo_key[ofs_0+1]; kyv = (kyv << 8) | key[ofs_0+1]; } assert(lov < hiv); if (kyv < lov) return -1 - lo; if (hiv < kyv) return -1 - hi; /* * Even if we know the target is much closer to 'hi' * than 'lo', if we pick too precisely and overshoot * (e.g. when we know 'mi' is closer to 'hi' than to * 'lo', pick 'mi' that is higher than the target), we * end up narrowing the search space by a smaller * amount (i.e. the distance between 'mi' and 'hi') * than what we would have (i.e. about half of 'lo' * and 'hi'). Hedge our bets to pick 'mi' less * aggressively, i.e. make 'mi' a bit closer to the * middle than we would otherwise pick. */ kyv = (kyv * 6 + lov + hiv) / 8; if (lov < hiv - 1) { if (kyv == lov) kyv++; else if (kyv == hiv) kyv--; } mi = (range - 1) * (kyv - lov) / (hiv - lov) + lo; #ifdef INDEX_DEBUG_LOOKUP printf("lo %u hi %u rg %u mi %u ", lo, hi, range, mi); printf("ofs %u lov %x, hiv %x, kyv %x\n", ofs_0, lov, hiv, kyv); #endif if (!(lo <= mi && mi < hi)) { giterr_set(GITERR_INVALID, "Assertion failure. Binary search invariant is false"); return -1; } mi_key = base + elem_size * mi + key_offset; cmp = memcmp(mi_key + ofs_0, key + ofs_0, 20 - ofs_0); if (!cmp) return mi; if (cmp > 0) { hi = mi; hi_key = mi_key; } else { lo = mi + 1; lo_key = mi_key + elem_size; } } while (lo < hi); return -((int)lo)-1; } int sha1_position(const void *table, size_t stride, unsigned lo, unsigned hi, const unsigned char *key) { const unsigned char *base = table; do { unsigned mi = (lo + hi) / 2; int cmp = git_oid__hashcmp(base + mi * stride, key); if (!cmp) return mi; if (cmp > 0) hi = mi; else lo = mi+1; } while (lo < hi); return -((int)lo)-1; } deps/libgit2-sys-0.3.8/libgit2/src/fetchhead.h0000664000175000017500000000143012510265101015745 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_fetchhead_h__ #define INCLUDE_fetchhead_h__ #include "vector.h" typedef struct git_fetchhead_ref { git_oid oid; unsigned int is_merge; char *ref_name; char *remote_url; } git_fetchhead_ref; int git_fetchhead_ref_create( git_fetchhead_ref **fetchhead_ref_out, git_oid *oid, unsigned int is_merge, const char *ref_name, const char *remote_url); int git_fetchhead_ref_cmp(const void *a, const void *b); int git_fetchhead_write(git_repository *repo, git_vector *fetchhead_refs); void git_fetchhead_ref_free(git_fetchhead_ref *fetchhead_ref); #endif deps/libgit2-sys-0.3.8/libgit2/src/settings.c0000664000175000017500000000710712555730137015713 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifdef GIT_OPENSSL # include #endif #include #include "common.h" #include "sysdir.h" #include "cache.h" #include "global.h" void git_libgit2_version(int *major, int *minor, int *rev) { *major = LIBGIT2_VER_MAJOR; *minor = LIBGIT2_VER_MINOR; *rev = LIBGIT2_VER_REVISION; } int git_libgit2_features() { return 0 #ifdef GIT_THREADS | GIT_FEATURE_THREADS #endif #if defined(GIT_OPENSSL) || defined(GIT_WINHTTP) || defined(GIT_SECURE_TRANSPORT) | GIT_FEATURE_HTTPS #endif #if defined(GIT_SSH) | GIT_FEATURE_SSH #endif ; } /* Declarations for tuneable settings */ extern size_t git_mwindow__window_size; extern size_t git_mwindow__mapped_limit; static int config_level_to_sysdir(int config_level) { int val = -1; switch (config_level) { case GIT_CONFIG_LEVEL_SYSTEM: val = GIT_SYSDIR_SYSTEM; break; case GIT_CONFIG_LEVEL_XDG: val = GIT_SYSDIR_XDG; break; case GIT_CONFIG_LEVEL_GLOBAL: val = GIT_SYSDIR_GLOBAL; break; default: giterr_set( GITERR_INVALID, "Invalid config path selector %d", config_level); } return val; } int git_libgit2_opts(int key, ...) { int error = 0; va_list ap; va_start(ap, key); switch (key) { case GIT_OPT_SET_MWINDOW_SIZE: git_mwindow__window_size = va_arg(ap, size_t); break; case GIT_OPT_GET_MWINDOW_SIZE: *(va_arg(ap, size_t *)) = git_mwindow__window_size; break; case GIT_OPT_SET_MWINDOW_MAPPED_LIMIT: git_mwindow__mapped_limit = va_arg(ap, size_t); break; case GIT_OPT_GET_MWINDOW_MAPPED_LIMIT: *(va_arg(ap, size_t *)) = git_mwindow__mapped_limit; break; case GIT_OPT_GET_SEARCH_PATH: if ((error = config_level_to_sysdir(va_arg(ap, int))) >= 0) { git_buf *out = va_arg(ap, git_buf *); const git_buf *tmp; git_buf_sanitize(out); if ((error = git_sysdir_get(&tmp, error)) < 0) break; error = git_buf_sets(out, tmp->ptr); } break; case GIT_OPT_SET_SEARCH_PATH: if ((error = config_level_to_sysdir(va_arg(ap, int))) >= 0) error = git_sysdir_set(error, va_arg(ap, const char *)); break; case GIT_OPT_SET_CACHE_OBJECT_LIMIT: { git_otype type = (git_otype)va_arg(ap, int); size_t size = va_arg(ap, size_t); error = git_cache_set_max_object_size(type, size); break; } case GIT_OPT_SET_CACHE_MAX_SIZE: git_cache__max_storage = va_arg(ap, ssize_t); break; case GIT_OPT_ENABLE_CACHING: git_cache__enabled = (va_arg(ap, int) != 0); break; case GIT_OPT_GET_CACHED_MEMORY: *(va_arg(ap, ssize_t *)) = git_cache__current_storage.val; *(va_arg(ap, ssize_t *)) = git_cache__max_storage; break; case GIT_OPT_GET_TEMPLATE_PATH: { git_buf *out = va_arg(ap, git_buf *); const git_buf *tmp; git_buf_sanitize(out); if ((error = git_sysdir_get(&tmp, GIT_SYSDIR_TEMPLATE)) < 0) break; error = git_buf_sets(out, tmp->ptr); } break; case GIT_OPT_SET_TEMPLATE_PATH: error = git_sysdir_set(GIT_SYSDIR_TEMPLATE, va_arg(ap, const char *)); break; case GIT_OPT_SET_SSL_CERT_LOCATIONS: #ifdef GIT_OPENSSL { const char *file = va_arg(ap, const char *); const char *path = va_arg(ap, const char *); if (!SSL_CTX_load_verify_locations(git__ssl_ctx, file, path)) { giterr_set(GITERR_NET, "SSL error: %s", ERR_error_string(ERR_get_error(), NULL)); error = -1; } } #else giterr_set(GITERR_NET, "Cannot set certificate locations: OpenSSL is not enabled"); error = -1; #endif break; } va_end(ap); return error; } deps/libgit2-sys-0.3.8/libgit2/src/commit_list.h0000664000175000017500000000273412610310643016370 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_commit_list_h__ #define INCLUDE_commit_list_h__ #include "git2/oid.h" #define PARENT1 (1 << 0) #define PARENT2 (1 << 1) #define RESULT (1 << 2) #define STALE (1 << 3) #define PARENTS_PER_COMMIT 2 #define COMMIT_ALLOC \ (sizeof(git_commit_list_node) + PARENTS_PER_COMMIT * sizeof(git_commit_list_node *)) #define FLAG_BITS 4 typedef struct git_commit_list_node { git_oid oid; int64_t time; unsigned int seen:1, uninteresting:1, topo_delay:1, parsed:1, flags : FLAG_BITS; unsigned short in_degree; unsigned short out_degree; struct git_commit_list_node **parents; } git_commit_list_node; typedef struct git_commit_list { git_commit_list_node *item; struct git_commit_list *next; } git_commit_list; git_commit_list_node *git_commit_list_alloc_node(git_revwalk *walk); int git_commit_list_time_cmp(const void *a, const void *b); void git_commit_list_free(git_commit_list **list_p); git_commit_list *git_commit_list_insert(git_commit_list_node *item, git_commit_list **list_p); git_commit_list *git_commit_list_insert_by_date(git_commit_list_node *item, git_commit_list **list_p); int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit); git_commit_list_node *git_commit_list_pop(git_commit_list **stack); #endif deps/libgit2-sys-0.3.8/libgit2/src/diff_xdiff.h0000664000175000017500000000167012610310643016133 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_diff_xdiff_h__ #define INCLUDE_diff_xdiff_h__ #include "diff.h" #include "diff_patch.h" #include "xdiff/xdiff.h" /* xdiff cannot cope with large files. these files should not be passed to * xdiff. callers should treat these large files as binary. */ #define GIT_XDIFF_MAX_SIZE (1024LL * 1024 * 1023) /* A git_xdiff_output is a git_diff_output with extra fields necessary * to use libxdiff. Calling git_xdiff_init() will set the diff_cb field * of the output to use xdiff to generate the diffs. */ typedef struct { git_diff_output output; xdemitconf_t config; xpparam_t params; xdemitcb_t callback; } git_xdiff_output; void git_xdiff_init(git_xdiff_output *xo, const git_diff_options *opts); #endif deps/libgit2-sys-0.3.8/libgit2/src/strmap.h0000664000175000017500000000442512510265101015347 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_strmap_h__ #define INCLUDE_strmap_h__ #include "common.h" #define kmalloc git__malloc #define kcalloc git__calloc #define krealloc git__realloc #define kreallocarray git__reallocarray #define kfree git__free #include "khash.h" __KHASH_TYPE(str, const char *, void *) typedef khash_t(str) git_strmap; typedef khiter_t git_strmap_iter; #define GIT__USE_STRMAP \ __KHASH_IMPL(str, static kh_inline, const char *, void *, 1, kh_str_hash_func, kh_str_hash_equal) #define git_strmap_alloc(hp) \ ((*(hp) = kh_init(str)) == NULL) ? giterr_set_oom(), -1 : 0 #define git_strmap_free(h) kh_destroy(str, h), h = NULL #define git_strmap_clear(h) kh_clear(str, h) #define git_strmap_num_entries(h) kh_size(h) #define git_strmap_lookup_index(h, k) kh_get(str, h, k) #define git_strmap_valid_index(h, idx) (idx != kh_end(h)) #define git_strmap_exists(h, k) (kh_get(str, h, k) != kh_end(h)) #define git_strmap_has_data(h, idx) kh_exist(h, idx) #define git_strmap_key(h, idx) kh_key(h, idx) #define git_strmap_value_at(h, idx) kh_val(h, idx) #define git_strmap_set_value_at(h, idx, v) kh_val(h, idx) = v #define git_strmap_delete_at(h, idx) kh_del(str, h, idx) #define git_strmap_insert(h, key, val, rval) do { \ khiter_t __pos = kh_put(str, h, key, &rval); \ if (rval >= 0) { \ if (rval == 0) kh_key(h, __pos) = key; \ kh_val(h, __pos) = val; \ } } while (0) #define git_strmap_insert2(h, key, val, oldv, rval) do { \ khiter_t __pos = kh_put(str, h, key, &rval); \ if (rval >= 0) { \ if (rval == 0) { \ oldv = kh_val(h, __pos); \ kh_key(h, __pos) = key; \ } else { oldv = NULL; } \ kh_val(h, __pos) = val; \ } } while (0) #define git_strmap_delete(h, key) do { \ khiter_t __pos = git_strmap_lookup_index(h, key); \ if (git_strmap_valid_index(h, __pos)) \ git_strmap_delete_at(h, __pos); } while (0) #define git_strmap_foreach kh_foreach #define git_strmap_foreach_value kh_foreach_value #define git_strmap_begin kh_begin #define git_strmap_end kh_end int git_strmap_next( void **data, git_strmap_iter* iter, git_strmap *map); #endif deps/libgit2-sys-0.3.8/libgit2/src/repo_template.h0000664000175000017500000000404212426525445016714 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_repo_template_h__ #define INCLUDE_repo_template_h__ #define GIT_OBJECTS_INFO_DIR GIT_OBJECTS_DIR "info/" #define GIT_OBJECTS_PACK_DIR GIT_OBJECTS_DIR "pack/" #define GIT_HOOKS_DIR "hooks/" #define GIT_HOOKS_DIR_MODE 0777 #define GIT_HOOKS_README_FILE GIT_HOOKS_DIR "README.sample" #define GIT_HOOKS_README_MODE 0777 #define GIT_HOOKS_README_CONTENT \ "#!/bin/sh\n"\ "#\n"\ "# Place appropriately named executable hook scripts into this directory\n"\ "# to intercept various actions that git takes. See `git help hooks` for\n"\ "# more information.\n" #define GIT_INFO_DIR "info/" #define GIT_INFO_DIR_MODE 0777 #define GIT_INFO_EXCLUDE_FILE GIT_INFO_DIR "exclude" #define GIT_INFO_EXCLUDE_MODE 0666 #define GIT_INFO_EXCLUDE_CONTENT \ "# File patterns to ignore; see `git help ignore` for more information.\n"\ "# Lines that start with '#' are comments.\n" #define GIT_DESC_FILE "description" #define GIT_DESC_MODE 0666 #define GIT_DESC_CONTENT \ "Unnamed repository; edit this file 'description' to name the repository.\n" typedef struct { const char *path; mode_t mode; const char *content; } repo_template_item; static repo_template_item repo_template[] = { { GIT_OBJECTS_INFO_DIR, GIT_OBJECT_DIR_MODE, NULL }, /* '/objects/info/' */ { GIT_OBJECTS_PACK_DIR, GIT_OBJECT_DIR_MODE, NULL }, /* '/objects/pack/' */ { GIT_REFS_HEADS_DIR, GIT_REFS_DIR_MODE, NULL }, /* '/refs/heads/' */ { GIT_REFS_TAGS_DIR, GIT_REFS_DIR_MODE, NULL }, /* '/refs/tags/' */ { GIT_HOOKS_DIR, GIT_HOOKS_DIR_MODE, NULL }, /* '/hooks/' */ { GIT_INFO_DIR, GIT_INFO_DIR_MODE, NULL }, /* '/info/' */ { GIT_DESC_FILE, GIT_DESC_MODE, GIT_DESC_CONTENT }, { GIT_HOOKS_README_FILE, GIT_HOOKS_README_MODE, GIT_HOOKS_README_CONTENT }, { GIT_INFO_EXCLUDE_FILE, GIT_INFO_EXCLUDE_MODE, GIT_INFO_EXCLUDE_CONTENT }, { NULL, 0, NULL } }; #endif deps/libgit2-sys-0.3.8/libgit2/src/message.h0000664000175000017500000000067312426525445015506 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_message_h__ #define INCLUDE_message_h__ #include "git2/message.h" #include "buffer.h" int git_message__prettify(git_buf *message_out, const char *message, int strip_comments); #endif /* INCLUDE_message_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/blame_git.h0000664000175000017500000000101112610310643015753 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_blame_git__ #define INCLUDE_blame_git__ #include "blame.h" int git_blame__get_origin( git_blame__origin **out, git_blame *sb, git_commit *commit, const char *path); void git_blame__free_entry(git_blame__entry *ent); int git_blame__like_git(git_blame *sb, uint32_t flags); #endif deps/libgit2-sys-0.3.8/libgit2/src/remote.h0000664000175000017500000000217712555730137015355 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_remote_h__ #define INCLUDE_remote_h__ #include "git2/remote.h" #include "git2/transport.h" #include "git2/sys/transport.h" #include "refspec.h" #include "vector.h" #define GIT_REMOTE_ORIGIN "origin" struct git_remote { char *name; char *url; char *pushurl; git_vector refs; git_vector refspecs; git_vector active_refspecs; git_vector passive_refspecs; git_transport *transport; git_repository *repo; git_push *push; git_transfer_progress stats; unsigned int need_pack; git_remote_autotag_option_t download_tags; int prune_refs; int passed_refspecs; }; const char* git_remote__urlfordirection(struct git_remote *remote, int direction); int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_url); git_refspec *git_remote__matching_refspec(git_remote *remote, const char *refname); git_refspec *git_remote__matching_dst_refspec(git_remote *remote, const char *refname); #endif deps/libgit2-sys-0.3.8/libgit2/src/filter.h0000664000175000017500000000217712510265101015330 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_filter_h__ #define INCLUDE_filter_h__ #include "common.h" #include "attr_file.h" #include "git2/filter.h" /* Amount of file to examine for NUL byte when checking binary-ness */ #define GIT_FILTER_BYTES_TO_CHECK_NUL 8000 /* Possible CRLF values */ typedef enum { GIT_CRLF_GUESS = -1, GIT_CRLF_BINARY = 0, GIT_CRLF_TEXT, GIT_CRLF_INPUT, GIT_CRLF_CRLF, GIT_CRLF_AUTO, } git_crlf_t; typedef struct { git_attr_session *attr_session; git_buf *temp_buf; uint32_t flags; } git_filter_options; #define GIT_FILTER_OPTIONS_INIT {0} extern void git_filter_free(git_filter *filter); extern int git_filter_list__load_ext( git_filter_list **filters, git_repository *repo, git_blob *blob, /* can be NULL */ const char *path, git_filter_mode_t mode, git_filter_options *filter_opts); /* * Available filters */ extern git_filter *git_crlf_filter_new(void); extern git_filter *git_ident_filter_new(void); #endif deps/libgit2-sys-0.3.8/libgit2/src/zstream.c0000664000175000017500000000715112510265101015520 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include #include "zstream.h" #include "buffer.h" #define ZSTREAM_BUFFER_SIZE (1024 * 1024) #define ZSTREAM_BUFFER_MIN_EXTRA 8 static int zstream_seterr(git_zstream *zs) { if (zs->zerr == Z_OK || zs->zerr == Z_STREAM_END) return 0; if (zs->zerr == Z_MEM_ERROR) giterr_set_oom(); else if (zs->z.msg) giterr_set(GITERR_ZLIB, zs->z.msg); else giterr_set(GITERR_ZLIB, "Unknown compression error"); return -1; } int git_zstream_init(git_zstream *zstream) { zstream->zerr = deflateInit(&zstream->z, Z_DEFAULT_COMPRESSION); return zstream_seterr(zstream); } void git_zstream_free(git_zstream *zstream) { deflateEnd(&zstream->z); } void git_zstream_reset(git_zstream *zstream) { deflateReset(&zstream->z); zstream->in = NULL; zstream->in_len = 0; zstream->zerr = Z_STREAM_END; } int git_zstream_set_input(git_zstream *zstream, const void *in, size_t in_len) { zstream->in = in; zstream->in_len = in_len; zstream->zerr = Z_OK; return 0; } bool git_zstream_done(git_zstream *zstream) { return (!zstream->in_len && zstream->zerr == Z_STREAM_END); } size_t git_zstream_suggest_output_len(git_zstream *zstream) { if (zstream->in_len > ZSTREAM_BUFFER_SIZE) return ZSTREAM_BUFFER_SIZE; else if (zstream->in_len > ZSTREAM_BUFFER_MIN_EXTRA) return zstream->in_len; else return ZSTREAM_BUFFER_MIN_EXTRA; } int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream) { int zflush = Z_FINISH; size_t out_remain = *out_len; while (out_remain > 0 && zstream->zerr != Z_STREAM_END) { size_t out_queued, in_queued, out_used, in_used; /* set up in data */ zstream->z.next_in = (Bytef *)zstream->in; zstream->z.avail_in = (uInt)zstream->in_len; if ((size_t)zstream->z.avail_in != zstream->in_len) { zstream->z.avail_in = INT_MAX; zflush = Z_NO_FLUSH; } else { zflush = Z_FINISH; } in_queued = (size_t)zstream->z.avail_in; /* set up out data */ zstream->z.next_out = out; zstream->z.avail_out = (uInt)out_remain; if ((size_t)zstream->z.avail_out != out_remain) zstream->z.avail_out = INT_MAX; out_queued = (size_t)zstream->z.avail_out; /* compress next chunk */ zstream->zerr = deflate(&zstream->z, zflush); if (zstream->zerr == Z_STREAM_ERROR) return zstream_seterr(zstream); out_used = (out_queued - zstream->z.avail_out); out_remain -= out_used; out = ((char *)out) + out_used; in_used = (in_queued - zstream->z.avail_in); zstream->in_len -= in_used; zstream->in += in_used; } /* either we finished the input or we did not flush the data */ assert(zstream->in_len > 0 || zflush == Z_FINISH); /* set out_size to number of bytes actually written to output */ *out_len = *out_len - out_remain; return 0; } int git_zstream_deflatebuf(git_buf *out, const void *in, size_t in_len) { git_zstream zs = GIT_ZSTREAM_INIT; int error = 0; if ((error = git_zstream_init(&zs)) < 0) return error; if ((error = git_zstream_set_input(&zs, in, in_len)) < 0) goto done; while (!git_zstream_done(&zs)) { size_t step = git_zstream_suggest_output_len(&zs), written; if ((error = git_buf_grow_by(out, step)) < 0) goto done; written = out->asize - out->size; if ((error = git_zstream_get_output( out->ptr + out->size, &written, &zs)) < 0) goto done; out->size += written; } /* NULL terminate for consistency if possible */ if (out->size < out->asize) out->ptr[out->size] = '\0'; done: git_zstream_free(&zs); return error; } deps/libgit2-sys-0.3.8/libgit2/src/fnmatch.h0000664000175000017500000000412312426525445015474 0ustar /* * Copyright (C) 2008 The Android Open Source Project * All rights reserved. * * 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. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "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 THE * COPYRIGHT OWNER OR CONTRIBUTORS 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 INCLUDE_fnmatch__compat_h__ #define INCLUDE_fnmatch__compat_h__ #include "common.h" #define FNM_NOMATCH 1 /* Match failed. */ #define FNM_NOSYS 2 /* Function not supported (unused). */ #define FNM_NORES 3 /* Out of resources */ #define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ #define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ #define FNM_PERIOD 0x04 /* Period must be matched by period. */ #define FNM_LEADING_DIR 0x08 /* Ignore / after Imatch. */ #define FNM_CASEFOLD 0x10 /* Case insensitive search. */ #define FNM_IGNORECASE FNM_CASEFOLD #define FNM_FILE_NAME FNM_PATHNAME extern int p_fnmatch(const char *pattern, const char *string, int flags); #endif /* _FNMATCH_H */ deps/libgit2-sys-0.3.8/libgit2/src/hashsig.c0000664000175000017500000001762212510265101015465 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/sys/hashsig.h" #include "fileops.h" #include "util.h" typedef uint32_t hashsig_t; typedef uint64_t hashsig_state; #define HASHSIG_SCALE 100 #define HASHSIG_MAX_RUN 80 #define HASHSIG_HASH_START 0x012345678ABCDEF0LL #define HASHSIG_HASH_SHIFT 5 #define HASHSIG_HASH_MIX(S,CH) \ (S) = ((S) << HASHSIG_HASH_SHIFT) - (S) + (hashsig_state)(CH) #define HASHSIG_HEAP_SIZE ((1 << 7) - 1) #define HASHSIG_HEAP_MIN_SIZE 4 typedef int (*hashsig_cmp)(const void *a, const void *b, void *); typedef struct { int size, asize; hashsig_cmp cmp; hashsig_t values[HASHSIG_HEAP_SIZE]; } hashsig_heap; struct git_hashsig { hashsig_heap mins; hashsig_heap maxs; size_t lines; git_hashsig_option_t opt; }; #define HEAP_LCHILD_OF(I) (((I)<<1)+1) #define HEAP_RCHILD_OF(I) (((I)<<1)+2) #define HEAP_PARENT_OF(I) (((I)-1)>>1) static void hashsig_heap_init(hashsig_heap *h, hashsig_cmp cmp) { h->size = 0; h->asize = HASHSIG_HEAP_SIZE; h->cmp = cmp; } static int hashsig_cmp_max(const void *a, const void *b, void *payload) { hashsig_t av = *(const hashsig_t *)a, bv = *(const hashsig_t *)b; GIT_UNUSED(payload); return (av < bv) ? -1 : (av > bv) ? 1 : 0; } static int hashsig_cmp_min(const void *a, const void *b, void *payload) { hashsig_t av = *(const hashsig_t *)a, bv = *(const hashsig_t *)b; GIT_UNUSED(payload); return (av > bv) ? -1 : (av < bv) ? 1 : 0; } static void hashsig_heap_up(hashsig_heap *h, int el) { int parent_el = HEAP_PARENT_OF(el); while (el > 0 && h->cmp(&h->values[parent_el], &h->values[el], NULL) > 0) { hashsig_t t = h->values[el]; h->values[el] = h->values[parent_el]; h->values[parent_el] = t; el = parent_el; parent_el = HEAP_PARENT_OF(el); } } static void hashsig_heap_down(hashsig_heap *h, int el) { hashsig_t v, lv, rv; /* 'el < h->size / 2' tests if el is bottom row of heap */ while (el < h->size / 2) { int lel = HEAP_LCHILD_OF(el), rel = HEAP_RCHILD_OF(el), swapel; v = h->values[el]; lv = h->values[lel]; rv = h->values[rel]; if (h->cmp(&v, &lv, NULL) < 0 && h->cmp(&v, &rv, NULL) < 0) break; swapel = (h->cmp(&lv, &rv, NULL) < 0) ? lel : rel; h->values[el] = h->values[swapel]; h->values[swapel] = v; el = swapel; } } static void hashsig_heap_sort(hashsig_heap *h) { /* only need to do this at the end for signature comparison */ git__qsort_r(h->values, h->size, sizeof(hashsig_t), h->cmp, NULL); } static void hashsig_heap_insert(hashsig_heap *h, hashsig_t val) { /* if heap is not full, insert new element */ if (h->size < h->asize) { h->values[h->size++] = val; hashsig_heap_up(h, h->size - 1); } /* if heap is full, pop top if new element should replace it */ else if (h->cmp(&val, &h->values[0], NULL) > 0) { h->size--; h->values[0] = h->values[h->size]; hashsig_heap_down(h, 0); } } typedef struct { int use_ignores; uint8_t ignore_ch[256]; } hashsig_in_progress; static void hashsig_in_progress_init( hashsig_in_progress *prog, git_hashsig *sig) { int i; /* no more than one can be set */ assert(!(sig->opt & GIT_HASHSIG_IGNORE_WHITESPACE) || !(sig->opt & GIT_HASHSIG_SMART_WHITESPACE)); if (sig->opt & GIT_HASHSIG_IGNORE_WHITESPACE) { for (i = 0; i < 256; ++i) prog->ignore_ch[i] = git__isspace_nonlf(i); prog->use_ignores = 1; } else if (sig->opt & GIT_HASHSIG_SMART_WHITESPACE) { for (i = 0; i < 256; ++i) prog->ignore_ch[i] = git__isspace(i); prog->use_ignores = 1; } else { memset(prog, 0, sizeof(*prog)); } } static int hashsig_add_hashes( git_hashsig *sig, const uint8_t *data, size_t size, hashsig_in_progress *prog) { const uint8_t *scan = data, *end = data + size; hashsig_state state = HASHSIG_HASH_START; int use_ignores = prog->use_ignores, len; uint8_t ch; while (scan < end) { state = HASHSIG_HASH_START; for (len = 0; scan < end && len < HASHSIG_MAX_RUN; ) { ch = *scan; if (use_ignores) for (; scan < end && git__isspace_nonlf(ch); ch = *scan) ++scan; else if (sig->opt & (GIT_HASHSIG_IGNORE_WHITESPACE | GIT_HASHSIG_SMART_WHITESPACE)) for (; scan < end && ch == '\r'; ch = *scan) ++scan; /* peek at next character to decide what to do next */ if (sig->opt & GIT_HASHSIG_SMART_WHITESPACE) use_ignores = (ch == '\n'); if (scan >= end) break; ++scan; /* check run terminator */ if (ch == '\n' || ch == '\0') { sig->lines++; break; } ++len; HASHSIG_HASH_MIX(state, ch); } if (len > 0) { hashsig_heap_insert(&sig->mins, (hashsig_t)state); hashsig_heap_insert(&sig->maxs, (hashsig_t)state); while (scan < end && (*scan == '\n' || !*scan)) ++scan; } } prog->use_ignores = use_ignores; return 0; } static int hashsig_finalize_hashes(git_hashsig *sig) { if (sig->mins.size < HASHSIG_HEAP_MIN_SIZE && !(sig->opt & GIT_HASHSIG_ALLOW_SMALL_FILES)) { giterr_set(GITERR_INVALID, "File too small for similarity signature calculation"); return GIT_EBUFS; } hashsig_heap_sort(&sig->mins); hashsig_heap_sort(&sig->maxs); return 0; } static git_hashsig *hashsig_alloc(git_hashsig_option_t opts) { git_hashsig *sig = git__calloc(1, sizeof(git_hashsig)); if (!sig) return NULL; hashsig_heap_init(&sig->mins, hashsig_cmp_min); hashsig_heap_init(&sig->maxs, hashsig_cmp_max); sig->opt = opts; return sig; } int git_hashsig_create( git_hashsig **out, const char *buf, size_t buflen, git_hashsig_option_t opts) { int error; hashsig_in_progress prog; git_hashsig *sig = hashsig_alloc(opts); GITERR_CHECK_ALLOC(sig); hashsig_in_progress_init(&prog, sig); error = hashsig_add_hashes(sig, (const uint8_t *)buf, buflen, &prog); if (!error) error = hashsig_finalize_hashes(sig); if (!error) *out = sig; else git_hashsig_free(sig); return error; } int git_hashsig_create_fromfile( git_hashsig **out, const char *path, git_hashsig_option_t opts) { uint8_t buf[0x1000]; ssize_t buflen = 0; int error = 0, fd; hashsig_in_progress prog; git_hashsig *sig = hashsig_alloc(opts); GITERR_CHECK_ALLOC(sig); if ((fd = git_futils_open_ro(path)) < 0) { git__free(sig); return fd; } hashsig_in_progress_init(&prog, sig); while (!error) { if ((buflen = p_read(fd, buf, sizeof(buf))) <= 0) { if ((error = (int)buflen) < 0) giterr_set(GITERR_OS, "Read error on '%s' calculating similarity hashes", path); break; } error = hashsig_add_hashes(sig, buf, buflen, &prog); } p_close(fd); if (!error) error = hashsig_finalize_hashes(sig); if (!error) *out = sig; else git_hashsig_free(sig); return error; } void git_hashsig_free(git_hashsig *sig) { git__free(sig); } static int hashsig_heap_compare(const hashsig_heap *a, const hashsig_heap *b) { int matches = 0, i, j, cmp; assert(a->cmp == b->cmp); /* hash heaps are sorted - just look for overlap vs total */ for (i = 0, j = 0; i < a->size && j < b->size; ) { cmp = a->cmp(&a->values[i], &b->values[j], NULL); if (cmp < 0) ++i; else if (cmp > 0) ++j; else { ++i; ++j; ++matches; } } return HASHSIG_SCALE * (matches * 2) / (a->size + b->size); } int git_hashsig_compare(const git_hashsig *a, const git_hashsig *b) { /* if we have no elements in either file then each file is either * empty or blank. if we're ignoring whitespace then the files are * similar, otherwise they're dissimilar. */ if (a->mins.size == 0 && b->mins.size == 0) { if ((!a->lines && !b->lines) || (a->opt & GIT_HASHSIG_IGNORE_WHITESPACE)) return HASHSIG_SCALE; else return 0; } /* if we have fewer than the maximum number of elements, then just use * one array since the two arrays will be the same */ if (a->mins.size < HASHSIG_HEAP_SIZE) return hashsig_heap_compare(&a->mins, &b->mins); else return (hashsig_heap_compare(&a->mins, &b->mins) + hashsig_heap_compare(&a->maxs, &b->maxs)) / 2; } deps/libgit2-sys-0.3.8/libgit2/src/config_file.h0000664000175000017500000000317312572105236016316 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_config_file_h__ #define INCLUDE_config_file_h__ #include "git2/config.h" GIT_INLINE(int) git_config_file_open(git_config_backend *cfg, unsigned int level) { return cfg->open(cfg, level); } GIT_INLINE(void) git_config_file_free(git_config_backend *cfg) { if (cfg) cfg->free(cfg); } GIT_INLINE(int) git_config_file_get_string( git_config_entry **out, git_config_backend *cfg, const char *name) { return cfg->get(cfg, name, out); } GIT_INLINE(int) git_config_file_set_string( git_config_backend *cfg, const char *name, const char *value) { return cfg->set(cfg, name, value); } GIT_INLINE(int) git_config_file_delete( git_config_backend *cfg, const char *name) { return cfg->del(cfg, name); } GIT_INLINE(int) git_config_file_foreach( git_config_backend *cfg, int (*fn)(const git_config_entry *entry, void *data), void *data) { return git_config_backend_foreach_match(cfg, NULL, fn, data); } GIT_INLINE(int) git_config_file_foreach_match( git_config_backend *cfg, const char *regexp, int (*fn)(const git_config_entry *entry, void *data), void *data) { return git_config_backend_foreach_match(cfg, regexp, fn, data); } GIT_INLINE(int) git_config_file_lock(git_config_backend *cfg) { return cfg->lock(cfg); } GIT_INLINE(int) git_config_file_unlock(git_config_backend *cfg, int success) { return cfg->unlock(cfg, success); } extern int git_config_file_normalize_section(char *start, char *end); #endif deps/libgit2-sys-0.3.8/libgit2/src/index.c0000664000175000017500000023757612610310643015165 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include #include "common.h" #include "repository.h" #include "index.h" #include "tree.h" #include "tree-cache.h" #include "hash.h" #include "iterator.h" #include "pathspec.h" #include "ignore.h" #include "blob.h" #include "idxmap.h" #include "git2/odb.h" #include "git2/oid.h" #include "git2/blob.h" #include "git2/config.h" #include "git2/sys/index.h" GIT__USE_IDXMAP GIT__USE_IDXMAP_ICASE #define INSERT_IN_MAP_EX(idx, map, e, err) do { \ if ((idx)->ignore_case) \ git_idxmap_icase_insert((khash_t(idxicase) *) (map), (e), (e), (err)); \ else \ git_idxmap_insert((map), (e), (e), (err)); \ } while (0) #define INSERT_IN_MAP(idx, e, err) INSERT_IN_MAP_EX(idx, (idx)->entries_map, e, err) #define LOOKUP_IN_MAP(p, idx, k) do { \ if ((idx)->ignore_case) \ (p) = git_idxmap_icase_lookup_index((khash_t(idxicase) *) index->entries_map, (k)); \ else \ (p) = git_idxmap_lookup_index(index->entries_map, (k)); \ } while (0) #define DELETE_IN_MAP(idx, e) do { \ if ((idx)->ignore_case) \ git_idxmap_icase_delete((khash_t(idxicase) *) (idx)->entries_map, (e)); \ else \ git_idxmap_delete((idx)->entries_map, (e)); \ } while (0) static int index_apply_to_wd_diff(git_index *index, int action, const git_strarray *paths, unsigned int flags, git_index_matched_path_cb cb, void *payload); #define entry_size(type,len) ((offsetof(type, path) + (len) + 8) & ~7) #define short_entry_size(len) entry_size(struct entry_short, len) #define long_entry_size(len) entry_size(struct entry_long, len) #define minimal_entry_size (offsetof(struct entry_short, path)) static const size_t INDEX_FOOTER_SIZE = GIT_OID_RAWSZ; static const size_t INDEX_HEADER_SIZE = 12; static const unsigned int INDEX_VERSION_NUMBER = 2; static const unsigned int INDEX_VERSION_NUMBER_EXT = 3; static const unsigned int INDEX_HEADER_SIG = 0x44495243; static const char INDEX_EXT_TREECACHE_SIG[] = {'T', 'R', 'E', 'E'}; static const char INDEX_EXT_UNMERGED_SIG[] = {'R', 'E', 'U', 'C'}; static const char INDEX_EXT_CONFLICT_NAME_SIG[] = {'N', 'A', 'M', 'E'}; #define INDEX_OWNER(idx) ((git_repository *)(GIT_REFCOUNT_OWNER(idx))) struct index_header { uint32_t signature; uint32_t version; uint32_t entry_count; }; struct index_extension { char signature[4]; uint32_t extension_size; }; struct entry_time { uint32_t seconds; uint32_t nanoseconds; }; struct entry_short { struct entry_time ctime; struct entry_time mtime; uint32_t dev; uint32_t ino; uint32_t mode; uint32_t uid; uint32_t gid; uint32_t file_size; git_oid oid; uint16_t flags; char path[1]; /* arbitrary length */ }; struct entry_long { struct entry_time ctime; struct entry_time mtime; uint32_t dev; uint32_t ino; uint32_t mode; uint32_t uid; uint32_t gid; uint32_t file_size; git_oid oid; uint16_t flags; uint16_t flags_extended; char path[1]; /* arbitrary length */ }; struct entry_srch_key { const char *path; size_t pathlen; int stage; }; struct entry_internal { git_index_entry entry; size_t pathlen; char path[GIT_FLEX_ARRAY]; }; struct reuc_entry_internal { git_index_reuc_entry entry; size_t pathlen; char path[GIT_FLEX_ARRAY]; }; /* local declarations */ static size_t read_extension(git_index *index, const char *buffer, size_t buffer_size); static int read_header(struct index_header *dest, const void *buffer); static int parse_index(git_index *index, const char *buffer, size_t buffer_size); static bool is_index_extended(git_index *index); static int write_index(git_oid *checksum, git_index *index, git_filebuf *file); static void index_entry_free(git_index_entry *entry); static void index_entry_reuc_free(git_index_reuc_entry *reuc); int git_index_entry_srch(const void *key, const void *array_member) { const struct entry_srch_key *srch_key = key; const struct entry_internal *entry = array_member; int cmp; size_t len1, len2, len; len1 = srch_key->pathlen; len2 = entry->pathlen; len = len1 < len2 ? len1 : len2; cmp = memcmp(srch_key->path, entry->path, len); if (cmp) return cmp; if (len1 < len2) return -1; if (len1 > len2) return 1; if (srch_key->stage != GIT_INDEX_STAGE_ANY) return srch_key->stage - GIT_IDXENTRY_STAGE(&entry->entry); return 0; } int git_index_entry_isrch(const void *key, const void *array_member) { const struct entry_srch_key *srch_key = key; const struct entry_internal *entry = array_member; int cmp; size_t len1, len2, len; len1 = srch_key->pathlen; len2 = entry->pathlen; len = len1 < len2 ? len1 : len2; cmp = strncasecmp(srch_key->path, entry->path, len); if (cmp) return cmp; if (len1 < len2) return -1; if (len1 > len2) return 1; if (srch_key->stage != GIT_INDEX_STAGE_ANY) return srch_key->stage - GIT_IDXENTRY_STAGE(&entry->entry); return 0; } static int index_entry_srch_path(const void *path, const void *array_member) { const git_index_entry *entry = array_member; return strcmp((const char *)path, entry->path); } static int index_entry_isrch_path(const void *path, const void *array_member) { const git_index_entry *entry = array_member; return strcasecmp((const char *)path, entry->path); } int git_index_entry_cmp(const void *a, const void *b) { int diff; const git_index_entry *entry_a = a; const git_index_entry *entry_b = b; diff = strcmp(entry_a->path, entry_b->path); if (diff == 0) diff = (GIT_IDXENTRY_STAGE(entry_a) - GIT_IDXENTRY_STAGE(entry_b)); return diff; } int git_index_entry_icmp(const void *a, const void *b) { int diff; const git_index_entry *entry_a = a; const git_index_entry *entry_b = b; diff = strcasecmp(entry_a->path, entry_b->path); if (diff == 0) diff = (GIT_IDXENTRY_STAGE(entry_a) - GIT_IDXENTRY_STAGE(entry_b)); return diff; } static int conflict_name_cmp(const void *a, const void *b) { const git_index_name_entry *name_a = a; const git_index_name_entry *name_b = b; if (name_a->ancestor && !name_b->ancestor) return 1; if (!name_a->ancestor && name_b->ancestor) return -1; if (name_a->ancestor) return strcmp(name_a->ancestor, name_b->ancestor); if (!name_a->ours || !name_b->ours) return 0; return strcmp(name_a->ours, name_b->ours); } /** * TODO: enable this when resolving case insensitive conflicts */ #if 0 static int conflict_name_icmp(const void *a, const void *b) { const git_index_name_entry *name_a = a; const git_index_name_entry *name_b = b; if (name_a->ancestor && !name_b->ancestor) return 1; if (!name_a->ancestor && name_b->ancestor) return -1; if (name_a->ancestor) return strcasecmp(name_a->ancestor, name_b->ancestor); if (!name_a->ours || !name_b->ours) return 0; return strcasecmp(name_a->ours, name_b->ours); } #endif static int reuc_srch(const void *key, const void *array_member) { const git_index_reuc_entry *reuc = array_member; return strcmp(key, reuc->path); } static int reuc_isrch(const void *key, const void *array_member) { const git_index_reuc_entry *reuc = array_member; return strcasecmp(key, reuc->path); } static int reuc_cmp(const void *a, const void *b) { const git_index_reuc_entry *info_a = a; const git_index_reuc_entry *info_b = b; return strcmp(info_a->path, info_b->path); } static int reuc_icmp(const void *a, const void *b) { const git_index_reuc_entry *info_a = a; const git_index_reuc_entry *info_b = b; return strcasecmp(info_a->path, info_b->path); } static void index_entry_reuc_free(git_index_reuc_entry *reuc) { git__free(reuc); } static void index_entry_free(git_index_entry *entry) { if (!entry) return; memset(&entry->id, 0, sizeof(entry->id)); git__free(entry); } unsigned int git_index__create_mode(unsigned int mode) { if (S_ISLNK(mode)) return S_IFLNK; if (S_ISDIR(mode) || (mode & S_IFMT) == (S_IFLNK | S_IFDIR)) return (S_IFLNK | S_IFDIR); return S_IFREG | GIT_PERMS_CANONICAL(mode); } static unsigned int index_merge_mode( git_index *index, git_index_entry *existing, unsigned int mode) { if (index->no_symlinks && S_ISREG(mode) && existing && S_ISLNK(existing->mode)) return existing->mode; if (index->distrust_filemode && S_ISREG(mode)) return (existing && S_ISREG(existing->mode)) ? existing->mode : git_index__create_mode(0666); return git_index__create_mode(mode); } static int index_sort_if_needed(git_index *index, bool need_lock) { /* not truly threadsafe because between when this checks and/or * sorts the array another thread could come in and unsort it */ if (git_vector_is_sorted(&index->entries)) return 0; if (need_lock && git_mutex_lock(&index->lock) < 0) { giterr_set(GITERR_OS, "Unable to lock index"); return -1; } git_vector_sort(&index->entries); if (need_lock) git_mutex_unlock(&index->lock); return 0; } GIT_INLINE(int) index_find_in_entries( size_t *out, git_vector *entries, git_vector_cmp entry_srch, const char *path, size_t path_len, int stage) { struct entry_srch_key srch_key; srch_key.path = path; srch_key.pathlen = !path_len ? strlen(path) : path_len; srch_key.stage = stage; return git_vector_bsearch2(out, entries, entry_srch, &srch_key); } GIT_INLINE(int) index_find( size_t *out, git_index *index, const char *path, size_t path_len, int stage, bool need_lock) { if (index_sort_if_needed(index, need_lock) < 0) return -1; return index_find_in_entries( out, &index->entries, index->entries_search, path, path_len, stage); } void git_index__set_ignore_case(git_index *index, bool ignore_case) { index->ignore_case = ignore_case; if (ignore_case) { index->entries_cmp_path = git__strcasecmp_cb; index->entries_search = git_index_entry_isrch; index->entries_search_path = index_entry_isrch_path; index->reuc_search = reuc_isrch; } else { index->entries_cmp_path = git__strcmp_cb; index->entries_search = git_index_entry_srch; index->entries_search_path = index_entry_srch_path; index->reuc_search = reuc_srch; } git_vector_set_cmp(&index->entries, ignore_case ? git_index_entry_icmp : git_index_entry_cmp); index_sort_if_needed(index, true); git_vector_set_cmp(&index->reuc, ignore_case ? reuc_icmp : reuc_cmp); git_vector_sort(&index->reuc); } int git_index_open(git_index **index_out, const char *index_path) { git_index *index; int error = -1; assert(index_out); index = git__calloc(1, sizeof(git_index)); GITERR_CHECK_ALLOC(index); if (git_mutex_init(&index->lock)) { giterr_set(GITERR_OS, "Failed to initialize lock"); git__free(index); return -1; } git_pool_init(&index->tree_pool, 1, 0); if (index_path != NULL) { index->index_file_path = git__strdup(index_path); if (!index->index_file_path) goto fail; /* Check if index file is stored on disk already */ if (git_path_exists(index->index_file_path) == true) index->on_disk = 1; } if (git_vector_init(&index->entries, 32, git_index_entry_cmp) < 0 || git_idxmap_alloc(&index->entries_map) < 0 || git_vector_init(&index->names, 8, conflict_name_cmp) < 0 || git_vector_init(&index->reuc, 8, reuc_cmp) < 0 || git_vector_init(&index->deleted, 8, git_index_entry_cmp) < 0) goto fail; index->entries_cmp_path = git__strcmp_cb; index->entries_search = git_index_entry_srch; index->entries_search_path = index_entry_srch_path; index->reuc_search = reuc_srch; if (index_path != NULL && (error = git_index_read(index, true)) < 0) goto fail; *index_out = index; GIT_REFCOUNT_INC(index); return 0; fail: git_pool_clear(&index->tree_pool); git_index_free(index); return error; } int git_index_new(git_index **out) { return git_index_open(out, NULL); } static void index_free(git_index *index) { /* index iterators increment the refcount of the index, so if we * get here then there should be no outstanding iterators. */ assert(!git_atomic_get(&index->readers)); git_index_clear(index); git_idxmap_free(index->entries_map); git_vector_free(&index->entries); git_vector_free(&index->names); git_vector_free(&index->reuc); git_vector_free(&index->deleted); git__free(index->index_file_path); git_mutex_free(&index->lock); git__memzero(index, sizeof(*index)); git__free(index); } void git_index_free(git_index *index) { if (index == NULL) return; GIT_REFCOUNT_DEC(index, index_free); } /* call with locked index */ static void index_free_deleted(git_index *index) { int readers = (int)git_atomic_get(&index->readers); size_t i; if (readers > 0 || !index->deleted.length) return; for (i = 0; i < index->deleted.length; ++i) { git_index_entry *ie = git__swap(index->deleted.contents[i], NULL); index_entry_free(ie); } git_vector_clear(&index->deleted); } /* call with locked index */ static int index_remove_entry(git_index *index, size_t pos) { int error = 0; git_index_entry *entry = git_vector_get(&index->entries, pos); if (entry != NULL) git_tree_cache_invalidate_path(index->tree, entry->path); DELETE_IN_MAP(index, entry); error = git_vector_remove(&index->entries, pos); if (!error) { if (git_atomic_get(&index->readers) > 0) { error = git_vector_insert(&index->deleted, entry); } else { index_entry_free(entry); } } return error; } int git_index_clear(git_index *index) { int error = 0; assert(index); index->tree = NULL; git_pool_clear(&index->tree_pool); if (git_mutex_lock(&index->lock) < 0) { giterr_set(GITERR_OS, "Failed to lock index"); return -1; } git_idxmap_clear(index->entries_map); while (!error && index->entries.length > 0) error = index_remove_entry(index, index->entries.length - 1); index_free_deleted(index); git_index_reuc_clear(index); git_index_name_clear(index); git_futils_filestamp_set(&index->stamp, NULL); git_mutex_unlock(&index->lock); return error; } static int create_index_error(int error, const char *msg) { giterr_set(GITERR_INDEX, msg); return error; } int git_index_set_caps(git_index *index, int caps) { unsigned int old_ignore_case; assert(index); old_ignore_case = index->ignore_case; if (caps == GIT_INDEXCAP_FROM_OWNER) { git_repository *repo = INDEX_OWNER(index); int val; if (!repo) return create_index_error( -1, "Cannot access repository to set index caps"); if (!git_repository__cvar(&val, repo, GIT_CVAR_IGNORECASE)) index->ignore_case = (val != 0); if (!git_repository__cvar(&val, repo, GIT_CVAR_FILEMODE)) index->distrust_filemode = (val == 0); if (!git_repository__cvar(&val, repo, GIT_CVAR_SYMLINKS)) index->no_symlinks = (val == 0); } else { index->ignore_case = ((caps & GIT_INDEXCAP_IGNORE_CASE) != 0); index->distrust_filemode = ((caps & GIT_INDEXCAP_NO_FILEMODE) != 0); index->no_symlinks = ((caps & GIT_INDEXCAP_NO_SYMLINKS) != 0); } if (old_ignore_case != index->ignore_case) { git_index__set_ignore_case(index, (bool)index->ignore_case); } return 0; } int git_index_caps(const git_index *index) { return ((index->ignore_case ? GIT_INDEXCAP_IGNORE_CASE : 0) | (index->distrust_filemode ? GIT_INDEXCAP_NO_FILEMODE : 0) | (index->no_symlinks ? GIT_INDEXCAP_NO_SYMLINKS : 0)); } const git_oid *git_index_checksum(git_index *index) { return &index->checksum; } /** * Returns 1 for changed, 0 for not changed and <0 for errors */ static int compare_checksum(git_index *index) { int fd, error; ssize_t bytes_read; git_oid checksum = {{ 0 }}; if ((fd = p_open(index->index_file_path, O_RDONLY)) < 0) return fd; if ((error = p_lseek(fd, -20, SEEK_END)) < 0) { p_close(fd); giterr_set(GITERR_OS, "failed to seek to end of file"); return -1; } bytes_read = p_read(fd, &checksum, GIT_OID_RAWSZ); p_close(fd); if (bytes_read < 0) return -1; return !!git_oid_cmp(&checksum, &index->checksum); } int git_index_read(git_index *index, int force) { int error = 0, updated; git_buf buffer = GIT_BUF_INIT; git_futils_filestamp stamp = index->stamp; if (!index->index_file_path) return create_index_error(-1, "Failed to read index: The index is in-memory only"); index->on_disk = git_path_exists(index->index_file_path); if (!index->on_disk) { if (force) return git_index_clear(index); return 0; } if ((updated = git_futils_filestamp_check(&stamp, index->index_file_path) < 0) || ((updated = compare_checksum(index)) < 0)) { giterr_set( GITERR_INDEX, "Failed to read index: '%s' no longer exists", index->index_file_path); return updated; } if (!updated && !force) return 0; error = git_futils_readbuffer(&buffer, index->index_file_path); if (error < 0) return error; index->tree = NULL; git_pool_clear(&index->tree_pool); error = git_index_clear(index); if (!error) error = parse_index(index, buffer.ptr, buffer.size); if (!error) git_futils_filestamp_set(&index->stamp, &stamp); git_buf_free(&buffer); return error; } int git_index__changed_relative_to( git_index *index, const git_oid *checksum) { /* attempt to update index (ignoring errors) */ if (git_index_read(index, false) < 0) giterr_clear(); return !!git_oid_cmp(&index->checksum, checksum); } static bool is_racy_timestamp(git_time_t stamp, git_index_entry *entry) { /* Git special-cases submodules in the check */ if (S_ISGITLINK(entry->mode)) return false; /* If we never read the index, we can't have this race either */ if (stamp == 0) return false; /* If the timestamp is the same or newer than the index, it's racy */ return ((int32_t) stamp) <= entry->mtime.seconds; } /* * Force the next diff to take a look at those entries which have the * same timestamp as the current index. */ static int truncate_racily_clean(git_index *index) { size_t i; int error; git_index_entry *entry; git_time_t ts = index->stamp.mtime; git_diff_options diff_opts = GIT_DIFF_OPTIONS_INIT; git_diff *diff; /* Nothing to do if there's no repo to talk about */ if (!INDEX_OWNER(index)) return 0; /* If there's no workdir, we can't know where to even check */ if (!git_repository_workdir(INDEX_OWNER(index))) return 0; diff_opts.flags |= GIT_DIFF_INCLUDE_TYPECHANGE | GIT_DIFF_IGNORE_SUBMODULES | GIT_DIFF_DISABLE_PATHSPEC_MATCH; git_vector_foreach(&index->entries, i, entry) { if (!is_racy_timestamp(ts, entry)) continue; /* TODO: use the (non-fnmatching) filelist iterator */ diff_opts.pathspec.count = 1; diff_opts.pathspec.strings = (char **) &entry->path; if ((error = git_diff_index_to_workdir(&diff, INDEX_OWNER(index), index, &diff_opts)) < 0) return error; if (git_diff_num_deltas(diff) > 0) entry->file_size = 0; git_diff_free(diff); } return 0; } int git_index_write(git_index *index) { git_indexwriter writer = GIT_INDEXWRITER_INIT; int error; truncate_racily_clean(index); if ((error = git_indexwriter_init(&writer, index)) == 0) error = git_indexwriter_commit(&writer); git_indexwriter_cleanup(&writer); return error; } const char * git_index_path(const git_index *index) { assert(index); return index->index_file_path; } int git_index_write_tree(git_oid *oid, git_index *index) { git_repository *repo; assert(oid && index); repo = INDEX_OWNER(index); if (repo == NULL) return create_index_error(-1, "Failed to write tree. " "The index file is not backed up by an existing repository"); return git_tree__write_index(oid, index, repo); } int git_index_write_tree_to( git_oid *oid, git_index *index, git_repository *repo) { assert(oid && index && repo); return git_tree__write_index(oid, index, repo); } size_t git_index_entrycount(const git_index *index) { assert(index); return index->entries.length; } const git_index_entry *git_index_get_byindex( git_index *index, size_t n) { assert(index); if (index_sort_if_needed(index, true) < 0) return NULL; return git_vector_get(&index->entries, n); } const git_index_entry *git_index_get_bypath( git_index *index, const char *path, int stage) { khiter_t pos; git_index_entry key = {{ 0 }}; assert(index); key.path = path; GIT_IDXENTRY_STAGE_SET(&key, stage); LOOKUP_IN_MAP(pos, index, &key); if (git_idxmap_valid_index(index->entries_map, pos)) return git_idxmap_value_at(index->entries_map, pos); giterr_set(GITERR_INDEX, "Index does not contain %s", path); return NULL; } void git_index_entry__init_from_stat( git_index_entry *entry, struct stat *st, bool trust_mode) { entry->ctime.seconds = (git_time_t)st->st_ctime; entry->mtime.seconds = (git_time_t)st->st_mtime; /* entry->mtime.nanoseconds = st->st_mtimensec; */ /* entry->ctime.nanoseconds = st->st_ctimensec; */ entry->dev = st->st_rdev; entry->ino = st->st_ino; entry->mode = (!trust_mode && S_ISREG(st->st_mode)) ? git_index__create_mode(0666) : git_index__create_mode(st->st_mode); entry->uid = st->st_uid; entry->gid = st->st_gid; entry->file_size = st->st_size; } static int index_entry_create( git_index_entry **out, git_repository *repo, const char *path) { size_t pathlen = strlen(path), alloclen; struct entry_internal *entry; if (!git_path_isvalid(repo, path, GIT_PATH_REJECT_DEFAULTS | GIT_PATH_REJECT_DOT_GIT)) { giterr_set(GITERR_INDEX, "Invalid path: '%s'", path); return -1; } GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(struct entry_internal), pathlen); GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); entry = git__calloc(1, alloclen); GITERR_CHECK_ALLOC(entry); entry->pathlen = pathlen; memcpy(entry->path, path, pathlen); entry->entry.path = entry->path; *out = (git_index_entry *)entry; return 0; } static int index_entry_init( git_index_entry **entry_out, git_index *index, const char *rel_path) { int error = 0; git_index_entry *entry = NULL; struct stat st; git_oid oid; if (INDEX_OWNER(index) == NULL) return create_index_error(-1, "Could not initialize index entry. " "Index is not backed up by an existing repository."); if (index_entry_create(&entry, INDEX_OWNER(index), rel_path) < 0) return -1; /* write the blob to disk and get the oid and stat info */ error = git_blob__create_from_paths( &oid, &st, INDEX_OWNER(index), NULL, rel_path, 0, true); if (error < 0) { index_entry_free(entry); return error; } entry->id = oid; git_index_entry__init_from_stat(entry, &st, !index->distrust_filemode); *entry_out = (git_index_entry *)entry; return 0; } static git_index_reuc_entry *reuc_entry_alloc(const char *path) { size_t pathlen = strlen(path), structlen = sizeof(struct reuc_entry_internal), alloclen; struct reuc_entry_internal *entry; if (GIT_ADD_SIZET_OVERFLOW(&alloclen, structlen, pathlen) || GIT_ADD_SIZET_OVERFLOW(&alloclen, alloclen, 1)) return NULL; entry = git__calloc(1, alloclen); if (!entry) return NULL; entry->pathlen = pathlen; memcpy(entry->path, path, pathlen); entry->entry.path = entry->path; return (git_index_reuc_entry *)entry; } static int index_entry_reuc_init(git_index_reuc_entry **reuc_out, const char *path, int ancestor_mode, const git_oid *ancestor_oid, int our_mode, const git_oid *our_oid, int their_mode, const git_oid *their_oid) { git_index_reuc_entry *reuc = NULL; assert(reuc_out && path); *reuc_out = reuc = reuc_entry_alloc(path); GITERR_CHECK_ALLOC(reuc); if ((reuc->mode[0] = ancestor_mode) > 0) git_oid_cpy(&reuc->oid[0], ancestor_oid); if ((reuc->mode[1] = our_mode) > 0) git_oid_cpy(&reuc->oid[1], our_oid); if ((reuc->mode[2] = their_mode) > 0) git_oid_cpy(&reuc->oid[2], their_oid); return 0; } static void index_entry_cpy( git_index_entry *tgt, git_index *index, const git_index_entry *src, bool update_path) { const char *tgt_path = tgt->path; memcpy(tgt, src, sizeof(*tgt)); /* keep the existing path buffer, but update the path to the one * given by the caller, if we trust it. */ tgt->path = tgt_path; if (index->ignore_case && update_path) memcpy((char *)tgt->path, src->path, strlen(tgt->path)); } static int index_entry_dup( git_index_entry **out, git_index *index, const git_index_entry *src) { git_index_entry *entry; if (!src) { *out = NULL; return 0; } if (index_entry_create(&entry, INDEX_OWNER(index), src->path) < 0) return -1; index_entry_cpy(entry, index, src, false); *out = entry; return 0; } static int has_file_name(git_index *index, const git_index_entry *entry, size_t pos, int ok_to_replace) { int retval = 0; size_t len = strlen(entry->path); int stage = GIT_IDXENTRY_STAGE(entry); const char *name = entry->path; while (pos < index->entries.length) { struct entry_internal *p = index->entries.contents[pos++]; if (len >= p->pathlen) break; if (memcmp(name, p->path, len)) break; if (GIT_IDXENTRY_STAGE(&p->entry) != stage) continue; if (p->path[len] != '/') continue; retval = -1; if (!ok_to_replace) break; if (index_remove_entry(index, --pos) < 0) break; } return retval; } /* * Do we have another file with a pathname that is a proper * subset of the name we're trying to add? */ static int has_dir_name(git_index *index, const git_index_entry *entry, int ok_to_replace) { int retval = 0; int stage = GIT_IDXENTRY_STAGE(entry); const char *name = entry->path; const char *slash = name + strlen(name); for (;;) { size_t len, pos; for (;;) { if (*--slash == '/') break; if (slash <= entry->path) return retval; } len = slash - name; if (!index_find(&pos, index, name, len, stage, false)) { retval = -1; if (!ok_to_replace) break; if (index_remove_entry(index, pos) < 0) break; continue; } /* * Trivial optimization: if we find an entry that * already matches the sub-directory, then we know * we're ok, and we can exit. */ for (; pos < index->entries.length; ++pos) { struct entry_internal *p = index->entries.contents[pos]; if (p->pathlen <= len || p->path[len] != '/' || memcmp(p->path, name, len)) break; /* not our subdirectory */ if (GIT_IDXENTRY_STAGE(&p->entry) == stage) return retval; } } return retval; } static int check_file_directory_collision(git_index *index, git_index_entry *entry, size_t pos, int ok_to_replace) { int retval = has_file_name(index, entry, pos, ok_to_replace); retval = retval + has_dir_name(index, entry, ok_to_replace); if (retval) { giterr_set(GITERR_INDEX, "'%s' appears as both a file and a directory", entry->path); return -1; } return 0; } static int canonicalize_directory_path( git_index *index, git_index_entry *entry, git_index_entry *existing) { const git_index_entry *match, *best = NULL; char *search, *sep; size_t pos, search_len, best_len; if (!index->ignore_case) return 0; /* item already exists in the index, simply re-use the existing case */ if (existing) { memcpy((char *)entry->path, existing->path, strlen(existing->path)); return 0; } /* nothing to do */ if (strchr(entry->path, '/') == NULL) return 0; if ((search = git__strdup(entry->path)) == NULL) return -1; /* starting at the parent directory and descending to the root, find the * common parent directory. */ while (!best && (sep = strrchr(search, '/'))) { sep[1] = '\0'; search_len = strlen(search); git_vector_bsearch2( &pos, &index->entries, index->entries_search_path, search); while ((match = git_vector_get(&index->entries, pos))) { if (GIT_IDXENTRY_STAGE(match) != 0) { /* conflicts do not contribute to canonical paths */ } else if (memcmp(search, match->path, search_len) == 0) { /* prefer an exact match to the input filename */ best = match; best_len = search_len; break; } else if (strncasecmp(search, match->path, search_len) == 0) { /* continue walking, there may be a path with an exact * (case sensitive) match later in the index, but use this * as the best match until that happens. */ if (!best) { best = match; best_len = search_len; } } else { break; } pos++; } sep[0] = '\0'; } if (best) memcpy((char *)entry->path, best->path, best_len); git__free(search); return 0; } static int index_no_dups(void **old, void *new) { const git_index_entry *entry = new; GIT_UNUSED(old); giterr_set(GITERR_INDEX, "'%s' appears multiple times at stage %d", entry->path, GIT_IDXENTRY_STAGE(entry)); return GIT_EEXISTS; } static void index_existing_and_best( const git_index_entry **existing, size_t *existing_position, const git_index_entry **best, git_index *index, const git_index_entry *entry) { const git_index_entry *e; size_t pos; int error; error = index_find(&pos, index, entry->path, 0, GIT_IDXENTRY_STAGE(entry), false); if (error == 0) { *existing = index->entries.contents[pos]; *existing_position = pos; *best = index->entries.contents[pos]; return; } *existing = NULL; *existing_position = 0; *best = NULL; if (GIT_IDXENTRY_STAGE(entry) == 0) { for (; pos < index->entries.length; pos++) { int (*strcomp)(const char *a, const char *b) = index->ignore_case ? git__strcasecmp : git__strcmp; e = index->entries.contents[pos]; if (strcomp(entry->path, e->path) != 0) break; if (GIT_IDXENTRY_STAGE(e) == GIT_INDEX_STAGE_ANCESTOR) { *best = e; continue; } else { *best = e; break; } } } } /* index_insert takes ownership of the new entry - if it can't insert * it, then it will return an error **and also free the entry**. When * it replaces an existing entry, it will update the entry_ptr with the * actual entry in the index (and free the passed in one). * trust_path is whether we use the given path, or whether (on case * insensitive systems only) we try to canonicalize the given path to * be within an existing directory. * trust_mode is whether we trust the mode in entry_ptr. */ static int index_insert( git_index *index, git_index_entry **entry_ptr, int replace, bool trust_path, bool trust_mode) { int error = 0; size_t path_length, position; git_index_entry *existing, *best, *entry; assert(index && entry_ptr); entry = *entry_ptr; /* make sure that the path length flag is correct */ path_length = ((struct entry_internal *)entry)->pathlen; entry->flags &= ~GIT_IDXENTRY_NAMEMASK; if (path_length < GIT_IDXENTRY_NAMEMASK) entry->flags |= path_length & GIT_IDXENTRY_NAMEMASK; else entry->flags |= GIT_IDXENTRY_NAMEMASK; if (git_mutex_lock(&index->lock) < 0) { giterr_set(GITERR_OS, "Unable to acquire index lock"); return -1; } git_vector_sort(&index->entries); /* look if an entry with this path already exists, either staged, or (if * this entry is a regular staged item) as the "ours" side of a conflict. */ index_existing_and_best(&existing, &position, &best, index, entry); /* update the file mode */ entry->mode = trust_mode ? git_index__create_mode(entry->mode) : index_merge_mode(index, best, entry->mode); /* canonicalize the directory name */ if (!trust_path) error = canonicalize_directory_path(index, entry, best); /* look for tree / blob name collisions, removing conflicts if requested */ if (!error) error = check_file_directory_collision(index, entry, position, replace); if (error < 0) /* skip changes */; /* if we are replacing an existing item, overwrite the existing entry * and return it in place of the passed in one. */ else if (existing) { if (replace) index_entry_cpy(existing, index, entry, trust_path); index_entry_free(entry); *entry_ptr = entry = existing; } else { /* if replace is not requested or no existing entry exists, insert * at the sorted position. (Since we re-sort after each insert to * check for dups, this is actually cheaper in the long run.) */ error = git_vector_insert_sorted(&index->entries, entry, index_no_dups); if (error == 0) { INSERT_IN_MAP(index, entry, error); } } if (error < 0) { index_entry_free(*entry_ptr); *entry_ptr = NULL; } git_mutex_unlock(&index->lock); return error; } static int index_conflict_to_reuc(git_index *index, const char *path) { const git_index_entry *conflict_entries[3]; int ancestor_mode, our_mode, their_mode; git_oid const *ancestor_oid, *our_oid, *their_oid; int ret; if ((ret = git_index_conflict_get(&conflict_entries[0], &conflict_entries[1], &conflict_entries[2], index, path)) < 0) return ret; ancestor_mode = conflict_entries[0] == NULL ? 0 : conflict_entries[0]->mode; our_mode = conflict_entries[1] == NULL ? 0 : conflict_entries[1]->mode; their_mode = conflict_entries[2] == NULL ? 0 : conflict_entries[2]->mode; ancestor_oid = conflict_entries[0] == NULL ? NULL : &conflict_entries[0]->id; our_oid = conflict_entries[1] == NULL ? NULL : &conflict_entries[1]->id; their_oid = conflict_entries[2] == NULL ? NULL : &conflict_entries[2]->id; if ((ret = git_index_reuc_add(index, path, ancestor_mode, ancestor_oid, our_mode, our_oid, their_mode, their_oid)) >= 0) ret = git_index_conflict_remove(index, path); return ret; } static bool valid_filemode(const int filemode) { return (filemode == GIT_FILEMODE_BLOB || filemode == GIT_FILEMODE_BLOB_EXECUTABLE || filemode == GIT_FILEMODE_LINK || filemode == GIT_FILEMODE_COMMIT); } int git_index_add_frombuffer( git_index *index, const git_index_entry *source_entry, const void *buffer, size_t len) { git_index_entry *entry = NULL; int error = 0; git_oid id; assert(index && source_entry->path); if (INDEX_OWNER(index) == NULL) return create_index_error(-1, "Could not initialize index entry. " "Index is not backed up by an existing repository."); if (!valid_filemode(source_entry->mode)) { giterr_set(GITERR_INDEX, "invalid filemode"); return -1; } if (index_entry_dup(&entry, index, source_entry) < 0) return -1; error = git_blob_create_frombuffer(&id, INDEX_OWNER(index), buffer, len); if (error < 0) { index_entry_free(entry); return error; } git_oid_cpy(&entry->id, &id); entry->file_size = len; if ((error = index_insert(index, &entry, 1, true, true)) < 0) return error; /* Adding implies conflict was resolved, move conflict entries to REUC */ if ((error = index_conflict_to_reuc(index, entry->path)) < 0 && error != GIT_ENOTFOUND) return error; git_tree_cache_invalidate_path(index->tree, entry->path); return 0; } static int add_repo_as_submodule(git_index_entry **out, git_index *index, const char *path) { git_repository *sub; git_buf abspath = GIT_BUF_INIT; git_repository *repo = INDEX_OWNER(index); git_reference *head; git_index_entry *entry; struct stat st; int error; if (index_entry_create(&entry, INDEX_OWNER(index), path) < 0) return -1; if ((error = git_buf_joinpath(&abspath, git_repository_workdir(repo), path)) < 0) return error; if ((error = p_stat(abspath.ptr, &st)) < 0) { giterr_set(GITERR_OS, "failed to stat repository dir"); return -1; } git_index_entry__init_from_stat(entry, &st, !index->distrust_filemode); if ((error = git_repository_open(&sub, abspath.ptr)) < 0) return error; if ((error = git_repository_head(&head, sub)) < 0) return error; git_oid_cpy(&entry->id, git_reference_target(head)); entry->mode = GIT_FILEMODE_COMMIT; git_reference_free(head); git_repository_free(sub); git_buf_free(&abspath); *out = entry; return 0; } int git_index_add_bypath(git_index *index, const char *path) { git_index_entry *entry = NULL; int ret; assert(index && path); if ((ret = index_entry_init(&entry, index, path)) == 0) ret = index_insert(index, &entry, 1, false, false); /* If we were given a directory, let's see if it's a submodule */ if (ret < 0 && ret != GIT_EDIRECTORY) return ret; if (ret == GIT_EDIRECTORY) { git_submodule *sm; git_error_state err; giterr_state_capture(&err, ret); ret = git_submodule_lookup(&sm, INDEX_OWNER(index), path); if (ret == GIT_ENOTFOUND) return giterr_state_restore(&err); giterr_state_free(&err); /* * EEXISTS means that there is a repository at that path, but it's not known * as a submodule. We add its HEAD as an entry and don't register it. */ if (ret == GIT_EEXISTS) { if ((ret = add_repo_as_submodule(&entry, index, path)) < 0) return ret; if ((ret = index_insert(index, &entry, 1, false, false)) < 0) return ret; } else if (ret < 0) { return ret; } else { ret = git_submodule_add_to_index(sm, false); git_submodule_free(sm); return ret; } } /* Adding implies conflict was resolved, move conflict entries to REUC */ if ((ret = index_conflict_to_reuc(index, path)) < 0 && ret != GIT_ENOTFOUND) return ret; git_tree_cache_invalidate_path(index->tree, entry->path); return 0; } int git_index_remove_bypath(git_index *index, const char *path) { int ret; assert(index && path); if (((ret = git_index_remove(index, path, 0)) < 0 && ret != GIT_ENOTFOUND) || ((ret = index_conflict_to_reuc(index, path)) < 0 && ret != GIT_ENOTFOUND)) return ret; if (ret == GIT_ENOTFOUND) giterr_clear(); return 0; } int git_index_add(git_index *index, const git_index_entry *source_entry) { git_index_entry *entry = NULL; int ret; assert(index && source_entry && source_entry->path); if (!valid_filemode(source_entry->mode)) { giterr_set(GITERR_INDEX, "invalid filemode"); return -1; } if ((ret = index_entry_dup(&entry, index, source_entry)) < 0 || (ret = index_insert(index, &entry, 1, true, true)) < 0) return ret; git_tree_cache_invalidate_path(index->tree, entry->path); return 0; } int git_index_remove(git_index *index, const char *path, int stage) { int error; size_t position; git_index_entry remove_key = {{ 0 }}; if (git_mutex_lock(&index->lock) < 0) { giterr_set(GITERR_OS, "Failed to lock index"); return -1; } remove_key.path = path; GIT_IDXENTRY_STAGE_SET(&remove_key, stage); DELETE_IN_MAP(index, &remove_key); if (index_find(&position, index, path, 0, stage, false) < 0) { giterr_set( GITERR_INDEX, "Index does not contain %s at stage %d", path, stage); error = GIT_ENOTFOUND; } else { error = index_remove_entry(index, position); } git_mutex_unlock(&index->lock); return error; } int git_index_remove_directory(git_index *index, const char *dir, int stage) { git_buf pfx = GIT_BUF_INIT; int error = 0; size_t pos; git_index_entry *entry; if (git_mutex_lock(&index->lock) < 0) { giterr_set(GITERR_OS, "Failed to lock index"); return -1; } if (!(error = git_buf_sets(&pfx, dir)) && !(error = git_path_to_dir(&pfx))) index_find(&pos, index, pfx.ptr, pfx.size, GIT_INDEX_STAGE_ANY, false); while (!error) { entry = git_vector_get(&index->entries, pos); if (!entry || git__prefixcmp(entry->path, pfx.ptr) != 0) break; if (GIT_IDXENTRY_STAGE(entry) != stage) { ++pos; continue; } error = index_remove_entry(index, pos); /* removed entry at 'pos' so we don't need to increment */ } git_mutex_unlock(&index->lock); git_buf_free(&pfx); return error; } int git_index_find_prefix(size_t *at_pos, git_index *index, const char *prefix) { int error = 0; size_t pos; const git_index_entry *entry; if (git_mutex_lock(&index->lock) < 0) { giterr_set(GITERR_OS, "Failed to lock index"); return -1; } index_find(&pos, index, prefix, strlen(prefix), GIT_INDEX_STAGE_ANY, false); entry = git_vector_get(&index->entries, pos); if (!entry || git__prefixcmp(entry->path, prefix) != 0) error = GIT_ENOTFOUND; if (!error && at_pos) *at_pos = pos; git_mutex_unlock(&index->lock); return error; } int git_index__find_pos( size_t *out, git_index *index, const char *path, size_t path_len, int stage) { assert(index && path); return index_find(out, index, path, path_len, stage, true); } int git_index_find(size_t *at_pos, git_index *index, const char *path) { size_t pos; assert(index && path); if (git_mutex_lock(&index->lock) < 0) { giterr_set(GITERR_OS, "Failed to lock index"); return -1; } if (git_vector_bsearch2( &pos, &index->entries, index->entries_search_path, path) < 0) { git_mutex_unlock(&index->lock); giterr_set(GITERR_INDEX, "Index does not contain %s", path); return GIT_ENOTFOUND; } /* Since our binary search only looked at path, we may be in the * middle of a list of stages. */ for (; pos > 0; --pos) { const git_index_entry *prev = git_vector_get(&index->entries, pos - 1); if (index->entries_cmp_path(prev->path, path) != 0) break; } if (at_pos) *at_pos = pos; git_mutex_unlock(&index->lock); return 0; } int git_index_conflict_add(git_index *index, const git_index_entry *ancestor_entry, const git_index_entry *our_entry, const git_index_entry *their_entry) { git_index_entry *entries[3] = { 0 }; unsigned short i; int ret = 0; assert (index); if ((ret = index_entry_dup(&entries[0], index, ancestor_entry)) < 0 || (ret = index_entry_dup(&entries[1], index, our_entry)) < 0 || (ret = index_entry_dup(&entries[2], index, their_entry)) < 0) goto on_error; /* Validate entries */ for (i = 0; i < 3; i++) { if (entries[i] && !valid_filemode(entries[i]->mode)) { giterr_set(GITERR_INDEX, "invalid filemode for stage %d entry", i); return -1; } } /* Remove existing index entries for each path */ for (i = 0; i < 3; i++) { if (entries[i] == NULL) continue; if ((ret = git_index_remove(index, entries[i]->path, 0)) != 0) { if (ret != GIT_ENOTFOUND) goto on_error; giterr_clear(); ret = 0; } } /* Add the conflict entries */ for (i = 0; i < 3; i++) { if (entries[i] == NULL) continue; /* Make sure stage is correct */ GIT_IDXENTRY_STAGE_SET(entries[i], i + 1); if ((ret = index_insert(index, &entries[i], 0, true, true)) < 0) goto on_error; entries[i] = NULL; /* don't free if later entry fails */ } return 0; on_error: for (i = 0; i < 3; i++) { if (entries[i] != NULL) index_entry_free(entries[i]); } return ret; } static int index_conflict__get_byindex( const git_index_entry **ancestor_out, const git_index_entry **our_out, const git_index_entry **their_out, git_index *index, size_t n) { const git_index_entry *conflict_entry; const char *path = NULL; size_t count; int stage, len = 0; assert(ancestor_out && our_out && their_out && index); *ancestor_out = NULL; *our_out = NULL; *their_out = NULL; for (count = git_index_entrycount(index); n < count; ++n) { conflict_entry = git_vector_get(&index->entries, n); if (path && index->entries_cmp_path(conflict_entry->path, path) != 0) break; stage = GIT_IDXENTRY_STAGE(conflict_entry); path = conflict_entry->path; switch (stage) { case 3: *their_out = conflict_entry; len++; break; case 2: *our_out = conflict_entry; len++; break; case 1: *ancestor_out = conflict_entry; len++; break; default: break; }; } return len; } int git_index_conflict_get( const git_index_entry **ancestor_out, const git_index_entry **our_out, const git_index_entry **their_out, git_index *index, const char *path) { size_t pos; int len = 0; assert(ancestor_out && our_out && their_out && index && path); *ancestor_out = NULL; *our_out = NULL; *their_out = NULL; if (git_index_find(&pos, index, path) < 0) return GIT_ENOTFOUND; if ((len = index_conflict__get_byindex( ancestor_out, our_out, their_out, index, pos)) < 0) return len; else if (len == 0) return GIT_ENOTFOUND; return 0; } static int index_conflict_remove(git_index *index, const char *path) { size_t pos = 0; git_index_entry *conflict_entry; int error = 0; if (path != NULL && git_index_find(&pos, index, path) < 0) return GIT_ENOTFOUND; if (git_mutex_lock(&index->lock) < 0) { giterr_set(GITERR_OS, "Unable to lock index"); return -1; } while ((conflict_entry = git_vector_get(&index->entries, pos)) != NULL) { if (path != NULL && index->entries_cmp_path(conflict_entry->path, path) != 0) break; if (GIT_IDXENTRY_STAGE(conflict_entry) == 0) { pos++; continue; } if ((error = index_remove_entry(index, pos)) < 0) break; } git_mutex_unlock(&index->lock); return error; } int git_index_conflict_remove(git_index *index, const char *path) { assert(index && path); return index_conflict_remove(index, path); } int git_index_conflict_cleanup(git_index *index) { assert(index); return index_conflict_remove(index, NULL); } int git_index_has_conflicts(const git_index *index) { size_t i; git_index_entry *entry; assert(index); git_vector_foreach(&index->entries, i, entry) { if (GIT_IDXENTRY_STAGE(entry) > 0) return 1; } return 0; } int git_index_conflict_iterator_new( git_index_conflict_iterator **iterator_out, git_index *index) { git_index_conflict_iterator *it = NULL; assert(iterator_out && index); it = git__calloc(1, sizeof(git_index_conflict_iterator)); GITERR_CHECK_ALLOC(it); it->index = index; *iterator_out = it; return 0; } int git_index_conflict_next( const git_index_entry **ancestor_out, const git_index_entry **our_out, const git_index_entry **their_out, git_index_conflict_iterator *iterator) { const git_index_entry *entry; int len; assert(ancestor_out && our_out && their_out && iterator); *ancestor_out = NULL; *our_out = NULL; *their_out = NULL; while (iterator->cur < iterator->index->entries.length) { entry = git_index_get_byindex(iterator->index, iterator->cur); if (git_index_entry_is_conflict(entry)) { if ((len = index_conflict__get_byindex( ancestor_out, our_out, their_out, iterator->index, iterator->cur)) < 0) return len; iterator->cur += len; return 0; } iterator->cur++; } return GIT_ITEROVER; } void git_index_conflict_iterator_free(git_index_conflict_iterator *iterator) { if (iterator == NULL) return; git__free(iterator); } size_t git_index_name_entrycount(git_index *index) { assert(index); return index->names.length; } const git_index_name_entry *git_index_name_get_byindex( git_index *index, size_t n) { assert(index); git_vector_sort(&index->names); return git_vector_get(&index->names, n); } static void index_name_entry_free(git_index_name_entry *ne) { if (!ne) return; git__free(ne->ancestor); git__free(ne->ours); git__free(ne->theirs); git__free(ne); } int git_index_name_add(git_index *index, const char *ancestor, const char *ours, const char *theirs) { git_index_name_entry *conflict_name; assert((ancestor && ours) || (ancestor && theirs) || (ours && theirs)); conflict_name = git__calloc(1, sizeof(git_index_name_entry)); GITERR_CHECK_ALLOC(conflict_name); if ((ancestor && !(conflict_name->ancestor = git__strdup(ancestor))) || (ours && !(conflict_name->ours = git__strdup(ours))) || (theirs && !(conflict_name->theirs = git__strdup(theirs))) || git_vector_insert(&index->names, conflict_name) < 0) { index_name_entry_free(conflict_name); return -1; } return 0; } void git_index_name_clear(git_index *index) { size_t i; git_index_name_entry *conflict_name; assert(index); git_vector_foreach(&index->names, i, conflict_name) index_name_entry_free(conflict_name); git_vector_clear(&index->names); } size_t git_index_reuc_entrycount(git_index *index) { assert(index); return index->reuc.length; } static int index_reuc_insert( git_index *index, git_index_reuc_entry *reuc, int replace) { git_index_reuc_entry **existing = NULL; size_t position; assert(index && reuc && reuc->path != NULL); if (!git_index_reuc_find(&position, index, reuc->path)) existing = (git_index_reuc_entry **)&index->reuc.contents[position]; if (!replace || !existing) return git_vector_insert(&index->reuc, reuc); /* exists, replace it */ git__free(*existing); *existing = reuc; return 0; } int git_index_reuc_add(git_index *index, const char *path, int ancestor_mode, const git_oid *ancestor_oid, int our_mode, const git_oid *our_oid, int their_mode, const git_oid *their_oid) { git_index_reuc_entry *reuc = NULL; int error = 0; assert(index && path); if ((error = index_entry_reuc_init(&reuc, path, ancestor_mode, ancestor_oid, our_mode, our_oid, their_mode, their_oid)) < 0 || (error = index_reuc_insert(index, reuc, 1)) < 0) index_entry_reuc_free(reuc); return error; } int git_index_reuc_find(size_t *at_pos, git_index *index, const char *path) { return git_vector_bsearch2(at_pos, &index->reuc, index->reuc_search, path); } const git_index_reuc_entry *git_index_reuc_get_bypath( git_index *index, const char *path) { size_t pos; assert(index && path); if (!index->reuc.length) return NULL; git_vector_sort(&index->reuc); if (git_index_reuc_find(&pos, index, path) < 0) return NULL; return git_vector_get(&index->reuc, pos); } const git_index_reuc_entry *git_index_reuc_get_byindex( git_index *index, size_t n) { assert(index); git_vector_sort(&index->reuc); return git_vector_get(&index->reuc, n); } int git_index_reuc_remove(git_index *index, size_t position) { int error; git_index_reuc_entry *reuc; git_vector_sort(&index->reuc); reuc = git_vector_get(&index->reuc, position); error = git_vector_remove(&index->reuc, position); if (!error) index_entry_reuc_free(reuc); return error; } void git_index_reuc_clear(git_index *index) { size_t i; assert(index); for (i = 0; i < index->reuc.length; ++i) index_entry_reuc_free(git__swap(index->reuc.contents[i], NULL)); git_vector_clear(&index->reuc); } static int index_error_invalid(const char *message) { giterr_set(GITERR_INDEX, "Invalid data in index - %s", message); return -1; } static int read_reuc(git_index *index, const char *buffer, size_t size) { const char *endptr; size_t len; int i; /* If called multiple times, the vector might already be initialized */ if (index->reuc._alloc_size == 0 && git_vector_init(&index->reuc, 16, reuc_cmp) < 0) return -1; while (size) { git_index_reuc_entry *lost; len = p_strnlen(buffer, size) + 1; if (size <= len) return index_error_invalid("reading reuc entries"); lost = reuc_entry_alloc(buffer); GITERR_CHECK_ALLOC(lost); size -= len; buffer += len; /* read 3 ASCII octal numbers for stage entries */ for (i = 0; i < 3; i++) { int tmp; if (git__strtol32(&tmp, buffer, &endptr, 8) < 0 || !endptr || endptr == buffer || *endptr || (unsigned)tmp > UINT_MAX) { index_entry_reuc_free(lost); return index_error_invalid("reading reuc entry stage"); } lost->mode[i] = tmp; len = (endptr + 1) - buffer; if (size <= len) { index_entry_reuc_free(lost); return index_error_invalid("reading reuc entry stage"); } size -= len; buffer += len; } /* read up to 3 OIDs for stage entries */ for (i = 0; i < 3; i++) { if (!lost->mode[i]) continue; if (size < 20) { index_entry_reuc_free(lost); return index_error_invalid("reading reuc entry oid"); } git_oid_fromraw(&lost->oid[i], (const unsigned char *) buffer); size -= 20; buffer += 20; } /* entry was read successfully - insert into reuc vector */ if (git_vector_insert(&index->reuc, lost) < 0) return -1; } /* entries are guaranteed to be sorted on-disk */ git_vector_set_sorted(&index->reuc, true); return 0; } static int read_conflict_names(git_index *index, const char *buffer, size_t size) { size_t len; /* This gets called multiple times, the vector might already be initialized */ if (index->names._alloc_size == 0 && git_vector_init(&index->names, 16, conflict_name_cmp) < 0) return -1; #define read_conflict_name(ptr) \ len = p_strnlen(buffer, size) + 1; \ if (size < len) \ return index_error_invalid("reading conflict name entries"); \ \ if (len == 1) \ ptr = NULL; \ else { \ ptr = git__malloc(len); \ GITERR_CHECK_ALLOC(ptr); \ memcpy(ptr, buffer, len); \ } \ \ buffer += len; \ size -= len; while (size) { git_index_name_entry *conflict_name = git__calloc(1, sizeof(git_index_name_entry)); GITERR_CHECK_ALLOC(conflict_name); read_conflict_name(conflict_name->ancestor); read_conflict_name(conflict_name->ours); read_conflict_name(conflict_name->theirs); if (git_vector_insert(&index->names, conflict_name) < 0) return -1; } #undef read_conflict_name /* entries are guaranteed to be sorted on-disk */ git_vector_set_sorted(&index->names, true); return 0; } static size_t read_entry( git_index_entry **out, git_index *index, const void *buffer, size_t buffer_size) { size_t path_length, entry_size; const char *path_ptr; struct entry_short source; git_index_entry entry = {{0}}; if (INDEX_FOOTER_SIZE + minimal_entry_size > buffer_size) return 0; /* buffer is not guaranteed to be aligned */ memcpy(&source, buffer, sizeof(struct entry_short)); entry.ctime.seconds = (git_time_t)ntohl(source.ctime.seconds); entry.ctime.nanoseconds = ntohl(source.ctime.nanoseconds); entry.mtime.seconds = (git_time_t)ntohl(source.mtime.seconds); entry.mtime.nanoseconds = ntohl(source.mtime.nanoseconds); entry.dev = ntohl(source.dev); entry.ino = ntohl(source.ino); entry.mode = ntohl(source.mode); entry.uid = ntohl(source.uid); entry.gid = ntohl(source.gid); entry.file_size = ntohl(source.file_size); git_oid_cpy(&entry.id, &source.oid); entry.flags = ntohs(source.flags); if (entry.flags & GIT_IDXENTRY_EXTENDED) { uint16_t flags_raw; size_t flags_offset; flags_offset = offsetof(struct entry_long, flags_extended); memcpy(&flags_raw, (const char *) buffer + flags_offset, sizeof(flags_raw)); flags_raw = ntohs(flags_raw); memcpy(&entry.flags_extended, &flags_raw, sizeof(flags_raw)); path_ptr = (const char *) buffer + offsetof(struct entry_long, path); } else path_ptr = (const char *) buffer + offsetof(struct entry_short, path); path_length = entry.flags & GIT_IDXENTRY_NAMEMASK; /* if this is a very long string, we must find its * real length without overflowing */ if (path_length == 0xFFF) { const char *path_end; path_end = memchr(path_ptr, '\0', buffer_size); if (path_end == NULL) return 0; path_length = path_end - path_ptr; } if (entry.flags & GIT_IDXENTRY_EXTENDED) entry_size = long_entry_size(path_length); else entry_size = short_entry_size(path_length); if (INDEX_FOOTER_SIZE + entry_size > buffer_size) return 0; entry.path = (char *)path_ptr; if (index_entry_dup(out, index, &entry) < 0) return 0; return entry_size; } static int read_header(struct index_header *dest, const void *buffer) { const struct index_header *source = buffer; dest->signature = ntohl(source->signature); if (dest->signature != INDEX_HEADER_SIG) return index_error_invalid("incorrect header signature"); dest->version = ntohl(source->version); if (dest->version != INDEX_VERSION_NUMBER_EXT && dest->version != INDEX_VERSION_NUMBER) return index_error_invalid("incorrect header version"); dest->entry_count = ntohl(source->entry_count); return 0; } static size_t read_extension(git_index *index, const char *buffer, size_t buffer_size) { struct index_extension dest; size_t total_size; /* buffer is not guaranteed to be aligned */ memcpy(&dest, buffer, sizeof(struct index_extension)); dest.extension_size = ntohl(dest.extension_size); total_size = dest.extension_size + sizeof(struct index_extension); if (dest.extension_size > total_size || buffer_size < total_size || buffer_size - total_size < INDEX_FOOTER_SIZE) return 0; /* optional extension */ if (dest.signature[0] >= 'A' && dest.signature[0] <= 'Z') { /* tree cache */ if (memcmp(dest.signature, INDEX_EXT_TREECACHE_SIG, 4) == 0) { if (git_tree_cache_read(&index->tree, buffer + 8, dest.extension_size, &index->tree_pool) < 0) return 0; } else if (memcmp(dest.signature, INDEX_EXT_UNMERGED_SIG, 4) == 0) { if (read_reuc(index, buffer + 8, dest.extension_size) < 0) return 0; } else if (memcmp(dest.signature, INDEX_EXT_CONFLICT_NAME_SIG, 4) == 0) { if (read_conflict_names(index, buffer + 8, dest.extension_size) < 0) return 0; } /* else, unsupported extension. We cannot parse this, but we can skip * it by returning `total_size */ } else { /* we cannot handle non-ignorable extensions; * in fact they aren't even defined in the standard */ return 0; } return total_size; } static int parse_index(git_index *index, const char *buffer, size_t buffer_size) { int error = 0; unsigned int i; struct index_header header = { 0 }; git_oid checksum_calculated, checksum_expected; #define seek_forward(_increase) { \ if (_increase >= buffer_size) { \ error = index_error_invalid("ran out of data while parsing"); \ goto done; } \ buffer += _increase; \ buffer_size -= _increase;\ } if (buffer_size < INDEX_HEADER_SIZE + INDEX_FOOTER_SIZE) return index_error_invalid("insufficient buffer space"); /* Precalculate the SHA1 of the files's contents -- we'll match it to * the provided SHA1 in the footer */ git_hash_buf(&checksum_calculated, buffer, buffer_size - INDEX_FOOTER_SIZE); /* Parse header */ if ((error = read_header(&header, buffer)) < 0) return error; seek_forward(INDEX_HEADER_SIZE); if (git_mutex_lock(&index->lock) < 0) { giterr_set(GITERR_OS, "Unable to acquire index lock"); return -1; } assert(!index->entries.length); if (index->ignore_case) kh_resize(idxicase, (khash_t(idxicase) *) index->entries_map, header.entry_count); else kh_resize(idx, index->entries_map, header.entry_count); /* Parse all the entries */ for (i = 0; i < header.entry_count && buffer_size > INDEX_FOOTER_SIZE; ++i) { git_index_entry *entry; size_t entry_size = read_entry(&entry, index, buffer, buffer_size); /* 0 bytes read means an object corruption */ if (entry_size == 0) { error = index_error_invalid("invalid entry"); goto done; } if ((error = git_vector_insert(&index->entries, entry)) < 0) { index_entry_free(entry); goto done; } INSERT_IN_MAP(index, entry, error); if (error < 0) { index_entry_free(entry); goto done; } seek_forward(entry_size); } if (i != header.entry_count) { error = index_error_invalid("header entries changed while parsing"); goto done; } /* There's still space for some extensions! */ while (buffer_size > INDEX_FOOTER_SIZE) { size_t extension_size; extension_size = read_extension(index, buffer, buffer_size); /* see if we have read any bytes from the extension */ if (extension_size == 0) { error = index_error_invalid("extension is truncated"); goto done; } seek_forward(extension_size); } if (buffer_size != INDEX_FOOTER_SIZE) { error = index_error_invalid( "buffer size does not match index footer size"); goto done; } /* 160-bit SHA-1 over the content of the index file before this checksum. */ git_oid_fromraw(&checksum_expected, (const unsigned char *)buffer); if (git_oid__cmp(&checksum_calculated, &checksum_expected) != 0) { error = index_error_invalid( "calculated checksum does not match expected"); goto done; } git_oid_cpy(&index->checksum, &checksum_calculated); #undef seek_forward /* Entries are stored case-sensitively on disk, so re-sort now if * in-memory index is supposed to be case-insensitive */ git_vector_set_sorted(&index->entries, !index->ignore_case); error = index_sort_if_needed(index, false); done: git_mutex_unlock(&index->lock); return error; } static bool is_index_extended(git_index *index) { size_t i, extended; git_index_entry *entry; extended = 0; git_vector_foreach(&index->entries, i, entry) { entry->flags &= ~GIT_IDXENTRY_EXTENDED; if (entry->flags_extended & GIT_IDXENTRY_EXTENDED_FLAGS) { extended++; entry->flags |= GIT_IDXENTRY_EXTENDED; } } return (extended > 0); } static int write_disk_entry(git_filebuf *file, git_index_entry *entry) { void *mem = NULL; struct entry_short *ondisk; size_t path_len, disk_size; char *path; path_len = ((struct entry_internal *)entry)->pathlen; if (entry->flags & GIT_IDXENTRY_EXTENDED) disk_size = long_entry_size(path_len); else disk_size = short_entry_size(path_len); if (git_filebuf_reserve(file, &mem, disk_size) < 0) return -1; ondisk = (struct entry_short *)mem; memset(ondisk, 0x0, disk_size); /** * Yes, we have to truncate. * * The on-disk format for Index entries clearly defines * the time and size fields to be 4 bytes each -- so even if * we store these values with 8 bytes on-memory, they must * be truncated to 4 bytes before writing to disk. * * In 2038 I will be either too dead or too rich to care about this */ ondisk->ctime.seconds = htonl((uint32_t)entry->ctime.seconds); ondisk->mtime.seconds = htonl((uint32_t)entry->mtime.seconds); ondisk->ctime.nanoseconds = htonl(entry->ctime.nanoseconds); ondisk->mtime.nanoseconds = htonl(entry->mtime.nanoseconds); ondisk->dev = htonl(entry->dev); ondisk->ino = htonl(entry->ino); ondisk->mode = htonl(entry->mode); ondisk->uid = htonl(entry->uid); ondisk->gid = htonl(entry->gid); ondisk->file_size = htonl((uint32_t)entry->file_size); git_oid_cpy(&ondisk->oid, &entry->id); ondisk->flags = htons(entry->flags); if (entry->flags & GIT_IDXENTRY_EXTENDED) { struct entry_long *ondisk_ext; ondisk_ext = (struct entry_long *)ondisk; ondisk_ext->flags_extended = htons(entry->flags_extended); path = ondisk_ext->path; } else path = ondisk->path; memcpy(path, entry->path, path_len); return 0; } static int write_entries(git_index *index, git_filebuf *file) { int error = 0; size_t i; git_vector case_sorted, *entries; git_index_entry *entry; if (git_mutex_lock(&index->lock) < 0) { giterr_set(GITERR_OS, "Failed to lock index"); return -1; } /* If index->entries is sorted case-insensitively, then we need * to re-sort it case-sensitively before writing */ if (index->ignore_case) { git_vector_dup(&case_sorted, &index->entries, git_index_entry_cmp); git_vector_sort(&case_sorted); entries = &case_sorted; } else { entries = &index->entries; } git_vector_foreach(entries, i, entry) if ((error = write_disk_entry(file, entry)) < 0) break; git_mutex_unlock(&index->lock); if (index->ignore_case) git_vector_free(&case_sorted); return error; } static int write_extension(git_filebuf *file, struct index_extension *header, git_buf *data) { struct index_extension ondisk; memset(&ondisk, 0x0, sizeof(struct index_extension)); memcpy(&ondisk, header, 4); ondisk.extension_size = htonl(header->extension_size); git_filebuf_write(file, &ondisk, sizeof(struct index_extension)); return git_filebuf_write(file, data->ptr, data->size); } static int create_name_extension_data(git_buf *name_buf, git_index_name_entry *conflict_name) { int error = 0; if (conflict_name->ancestor == NULL) error = git_buf_put(name_buf, "\0", 1); else error = git_buf_put(name_buf, conflict_name->ancestor, strlen(conflict_name->ancestor) + 1); if (error != 0) goto on_error; if (conflict_name->ours == NULL) error = git_buf_put(name_buf, "\0", 1); else error = git_buf_put(name_buf, conflict_name->ours, strlen(conflict_name->ours) + 1); if (error != 0) goto on_error; if (conflict_name->theirs == NULL) error = git_buf_put(name_buf, "\0", 1); else error = git_buf_put(name_buf, conflict_name->theirs, strlen(conflict_name->theirs) + 1); on_error: return error; } static int write_name_extension(git_index *index, git_filebuf *file) { git_buf name_buf = GIT_BUF_INIT; git_vector *out = &index->names; git_index_name_entry *conflict_name; struct index_extension extension; size_t i; int error = 0; git_vector_foreach(out, i, conflict_name) { if ((error = create_name_extension_data(&name_buf, conflict_name)) < 0) goto done; } memset(&extension, 0x0, sizeof(struct index_extension)); memcpy(&extension.signature, INDEX_EXT_CONFLICT_NAME_SIG, 4); extension.extension_size = (uint32_t)name_buf.size; error = write_extension(file, &extension, &name_buf); git_buf_free(&name_buf); done: return error; } static int create_reuc_extension_data(git_buf *reuc_buf, git_index_reuc_entry *reuc) { int i; int error = 0; if ((error = git_buf_put(reuc_buf, reuc->path, strlen(reuc->path) + 1)) < 0) return error; for (i = 0; i < 3; i++) { if ((error = git_buf_printf(reuc_buf, "%o", reuc->mode[i])) < 0 || (error = git_buf_put(reuc_buf, "\0", 1)) < 0) return error; } for (i = 0; i < 3; i++) { if (reuc->mode[i] && (error = git_buf_put(reuc_buf, (char *)&reuc->oid[i].id, GIT_OID_RAWSZ)) < 0) return error; } return 0; } static int write_reuc_extension(git_index *index, git_filebuf *file) { git_buf reuc_buf = GIT_BUF_INIT; git_vector *out = &index->reuc; git_index_reuc_entry *reuc; struct index_extension extension; size_t i; int error = 0; git_vector_foreach(out, i, reuc) { if ((error = create_reuc_extension_data(&reuc_buf, reuc)) < 0) goto done; } memset(&extension, 0x0, sizeof(struct index_extension)); memcpy(&extension.signature, INDEX_EXT_UNMERGED_SIG, 4); extension.extension_size = (uint32_t)reuc_buf.size; error = write_extension(file, &extension, &reuc_buf); git_buf_free(&reuc_buf); done: return error; } static int write_tree_extension(git_index *index, git_filebuf *file) { struct index_extension extension; git_buf buf = GIT_BUF_INIT; int error; if (index->tree == NULL) return 0; if ((error = git_tree_cache_write(&buf, index->tree)) < 0) return error; memset(&extension, 0x0, sizeof(struct index_extension)); memcpy(&extension.signature, INDEX_EXT_TREECACHE_SIG, 4); extension.extension_size = (uint32_t)buf.size; error = write_extension(file, &extension, &buf); git_buf_free(&buf); return error; } static int write_index(git_oid *checksum, git_index *index, git_filebuf *file) { git_oid hash_final; struct index_header header; bool is_extended; uint32_t index_version_number; assert(index && file); is_extended = is_index_extended(index); index_version_number = is_extended ? INDEX_VERSION_NUMBER_EXT : INDEX_VERSION_NUMBER; header.signature = htonl(INDEX_HEADER_SIG); header.version = htonl(index_version_number); header.entry_count = htonl((uint32_t)index->entries.length); if (git_filebuf_write(file, &header, sizeof(struct index_header)) < 0) return -1; if (write_entries(index, file) < 0) return -1; /* write the tree cache extension */ if (index->tree != NULL && write_tree_extension(index, file) < 0) return -1; /* write the rename conflict extension */ if (index->names.length > 0 && write_name_extension(index, file) < 0) return -1; /* write the reuc extension */ if (index->reuc.length > 0 && write_reuc_extension(index, file) < 0) return -1; /* get out the hash for all the contents we've appended to the file */ git_filebuf_hash(&hash_final, file); git_oid_cpy(checksum, &hash_final); /* write it at the end of the file */ return git_filebuf_write(file, hash_final.id, GIT_OID_RAWSZ); } int git_index_entry_stage(const git_index_entry *entry) { return GIT_IDXENTRY_STAGE(entry); } int git_index_entry_is_conflict(const git_index_entry *entry) { return (GIT_IDXENTRY_STAGE(entry) > 0); } typedef struct read_tree_data { git_index *index; git_vector *old_entries; git_vector *new_entries; git_vector_cmp entry_cmp; git_tree_cache *tree; } read_tree_data; static int read_tree_cb( const char *root, const git_tree_entry *tentry, void *payload) { read_tree_data *data = payload; git_index_entry *entry = NULL, *old_entry; git_buf path = GIT_BUF_INIT; size_t pos; if (git_tree_entry__is_tree(tentry)) return 0; if (git_buf_joinpath(&path, root, tentry->filename) < 0) return -1; if (index_entry_create(&entry, INDEX_OWNER(data->index), path.ptr) < 0) return -1; entry->mode = tentry->attr; entry->id = tentry->oid; /* look for corresponding old entry and copy data to new entry */ if (data->old_entries != NULL && !index_find_in_entries( &pos, data->old_entries, data->entry_cmp, path.ptr, 0, 0) && (old_entry = git_vector_get(data->old_entries, pos)) != NULL && entry->mode == old_entry->mode && git_oid_equal(&entry->id, &old_entry->id)) { index_entry_cpy(entry, data->index, old_entry, false); entry->flags_extended = 0; } if (path.size < GIT_IDXENTRY_NAMEMASK) entry->flags = path.size & GIT_IDXENTRY_NAMEMASK; else entry->flags = GIT_IDXENTRY_NAMEMASK; git_buf_free(&path); if (git_vector_insert(data->new_entries, entry) < 0) { index_entry_free(entry); return -1; } return 0; } int git_index_read_tree(git_index *index, const git_tree *tree) { int error = 0; git_vector entries = GIT_VECTOR_INIT; git_idxmap *entries_map; read_tree_data data; size_t i; git_index_entry *e; if (git_idxmap_alloc(&entries_map) < 0) return -1; git_vector_set_cmp(&entries, index->entries._cmp); /* match sort */ data.index = index; data.old_entries = &index->entries; data.new_entries = &entries; data.entry_cmp = index->entries_search; index->tree = NULL; git_pool_clear(&index->tree_pool); if (index_sort_if_needed(index, true) < 0) return -1; if ((error = git_tree_walk(tree, GIT_TREEWALK_POST, read_tree_cb, &data)) < 0) goto cleanup; if (index->ignore_case) kh_resize(idxicase, (khash_t(idxicase) *) entries_map, entries.length); else kh_resize(idx, entries_map, entries.length); git_vector_foreach(&entries, i, e) { INSERT_IN_MAP_EX(index, entries_map, e, error); if (error < 0) { giterr_set(GITERR_INDEX, "failed to insert entry into map"); return error; } } error = 0; git_vector_sort(&entries); if ((error = git_index_clear(index)) < 0) /* well, this isn't good */; else if (git_mutex_lock(&index->lock) < 0) { giterr_set(GITERR_OS, "Unable to acquire index lock"); error = -1; } else { git_vector_swap(&entries, &index->entries); entries_map = git__swap(index->entries_map, entries_map); git_mutex_unlock(&index->lock); } cleanup: git_vector_free(&entries); git_idxmap_free(entries_map); if (error < 0) return error; error = git_tree_cache_read_tree(&index->tree, tree, &index->tree_pool); return error; } int git_index_read_index( git_index *index, const git_index *new_index) { git_vector new_entries = GIT_VECTOR_INIT, remove_entries = GIT_VECTOR_INIT; git_iterator *index_iterator = NULL; git_iterator *new_iterator = NULL; git_iterator_options opts = GIT_ITERATOR_OPTIONS_INIT; const git_index_entry *old_entry, *new_entry; git_index_entry *entry; size_t i; int error; if ((error = git_vector_init(&new_entries, new_index->entries.length, index->entries._cmp)) < 0 || (error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0) goto done; opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE; if ((error = git_iterator_for_index(&index_iterator, index, &opts)) < 0 || (error = git_iterator_for_index(&new_iterator, (git_index *)new_index, &opts)) < 0) goto done; if (((error = git_iterator_current(&old_entry, index_iterator)) < 0 && error != GIT_ITEROVER) || ((error = git_iterator_current(&new_entry, new_iterator)) < 0 && error != GIT_ITEROVER)) goto done; while (true) { int diff; if (old_entry && new_entry) diff = git_index_entry_cmp(old_entry, new_entry); else if (!old_entry && new_entry) diff = 1; else if (old_entry && !new_entry) diff = -1; else break; if (diff < 0) { git_vector_insert(&remove_entries, (git_index_entry *)old_entry); } else if (diff > 0) { if ((error = index_entry_dup(&entry, index, new_entry)) < 0) goto done; git_vector_insert(&new_entries, entry); } else { /* Path and stage are equal, if the OID is equal, keep it to * keep the stat cache data. */ if (git_oid_equal(&old_entry->id, &new_entry->id)) { git_vector_insert(&new_entries, (git_index_entry *)old_entry); } else { if ((error = index_entry_dup(&entry, index, new_entry)) < 0) goto done; git_vector_insert(&new_entries, entry); git_vector_insert(&remove_entries, (git_index_entry *)old_entry); } } if (diff <= 0) { if ((error = git_iterator_advance(&old_entry, index_iterator)) < 0 && error != GIT_ITEROVER) goto done; } if (diff >= 0) { if ((error = git_iterator_advance(&new_entry, new_iterator)) < 0 && error != GIT_ITEROVER) goto done; } } git_index_name_clear(index); git_index_reuc_clear(index); git_vector_swap(&new_entries, &index->entries); git_vector_foreach(&remove_entries, i, entry) { if (index->tree) git_tree_cache_invalidate_path(index->tree, entry->path); index_entry_free(entry); } error = 0; done: git_vector_free(&new_entries); git_vector_free(&remove_entries); git_iterator_free(index_iterator); git_iterator_free(new_iterator); return error; } git_repository *git_index_owner(const git_index *index) { return INDEX_OWNER(index); } enum { INDEX_ACTION_NONE = 0, INDEX_ACTION_UPDATE = 1, INDEX_ACTION_REMOVE = 2, INDEX_ACTION_ADDALL = 3, }; int git_index_add_all( git_index *index, const git_strarray *paths, unsigned int flags, git_index_matched_path_cb cb, void *payload) { int error; git_repository *repo; git_iterator *wditer = NULL; git_pathspec ps; bool no_fnmatch = (flags & GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH) != 0; assert(index); repo = INDEX_OWNER(index); if ((error = git_repository__ensure_not_bare(repo, "index add all")) < 0) return error; if ((error = git_pathspec__init(&ps, paths)) < 0) return error; /* optionally check that pathspec doesn't mention any ignored files */ if ((flags & GIT_INDEX_ADD_CHECK_PATHSPEC) != 0 && (flags & GIT_INDEX_ADD_FORCE) == 0 && (error = git_ignore__check_pathspec_for_exact_ignores( repo, &ps.pathspec, no_fnmatch)) < 0) goto cleanup; error = index_apply_to_wd_diff(index, INDEX_ACTION_ADDALL, paths, flags, cb, payload); if (error) giterr_set_after_callback(error); cleanup: git_iterator_free(wditer); git_pathspec__clear(&ps); return error; } struct foreach_diff_data { git_index *index; const git_pathspec *pathspec; unsigned int flags; git_index_matched_path_cb cb; void *payload; }; static int apply_each_file(const git_diff_delta *delta, float progress, void *payload) { struct foreach_diff_data *data = payload; const char *match, *path; int error = 0; GIT_UNUSED(progress); path = delta->old_file.path; /* We only want those which match the pathspecs */ if (!git_pathspec__match( &data->pathspec->pathspec, path, false, (bool)data->index->ignore_case, &match, NULL)) return 0; if (data->cb) error = data->cb(path, match, data->payload); if (error > 0) /* skip this entry */ return 0; if (error < 0) /* actual error */ return error; /* If the workdir item does not exist, remove it from the index. */ if ((delta->new_file.flags & GIT_DIFF_FLAG_EXISTS) == 0) error = git_index_remove_bypath(data->index, path); else error = git_index_add_bypath(data->index, delta->new_file.path); return error; } static int index_apply_to_wd_diff(git_index *index, int action, const git_strarray *paths, unsigned int flags, git_index_matched_path_cb cb, void *payload) { int error; git_diff *diff; git_pathspec ps; git_repository *repo; git_diff_options opts = GIT_DIFF_OPTIONS_INIT; struct foreach_diff_data data = { index, NULL, flags, cb, payload, }; assert(index); assert(action == INDEX_ACTION_UPDATE || action == INDEX_ACTION_ADDALL); repo = INDEX_OWNER(index); if (!repo) { return create_index_error(-1, "cannot run update; the index is not backed up by a repository."); } /* * We do the matching ourselves intead of passing the list to * diff because we want to tell the callback which one * matched, which we do not know if we ask diff to filter for us. */ if ((error = git_pathspec__init(&ps, paths)) < 0) return error; opts.flags = GIT_DIFF_INCLUDE_TYPECHANGE; if (action == INDEX_ACTION_ADDALL) { opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_RECURSE_UNTRACKED_DIRS; if (flags == GIT_INDEX_ADD_FORCE) opts.flags |= GIT_DIFF_INCLUDE_IGNORED; } if ((error = git_diff_index_to_workdir(&diff, repo, index, &opts)) < 0) goto cleanup; data.pathspec = &ps; error = git_diff_foreach(diff, apply_each_file, NULL, NULL, NULL, &data); git_diff_free(diff); if (error) /* make sure error is set if callback stopped iteration */ giterr_set_after_callback(error); cleanup: git_pathspec__clear(&ps); return error; } static int index_apply_to_all( git_index *index, int action, const git_strarray *paths, git_index_matched_path_cb cb, void *payload) { int error = 0; size_t i; git_pathspec ps; const char *match; git_buf path = GIT_BUF_INIT; assert(index); if ((error = git_pathspec__init(&ps, paths)) < 0) return error; git_vector_sort(&index->entries); for (i = 0; !error && i < index->entries.length; ++i) { git_index_entry *entry = git_vector_get(&index->entries, i); /* check if path actually matches */ if (!git_pathspec__match( &ps.pathspec, entry->path, false, (bool)index->ignore_case, &match, NULL)) continue; /* issue notification callback if requested */ if (cb && (error = cb(entry->path, match, payload)) != 0) { if (error > 0) { /* return > 0 means skip this one */ error = 0; continue; } if (error < 0) /* return < 0 means abort */ break; } /* index manipulation may alter entry, so don't depend on it */ if ((error = git_buf_sets(&path, entry->path)) < 0) break; switch (action) { case INDEX_ACTION_NONE: break; case INDEX_ACTION_UPDATE: error = git_index_add_bypath(index, path.ptr); if (error == GIT_ENOTFOUND) { giterr_clear(); error = git_index_remove_bypath(index, path.ptr); if (!error) /* back up foreach if we removed this */ i--; } break; case INDEX_ACTION_REMOVE: if (!(error = git_index_remove_bypath(index, path.ptr))) i--; /* back up foreach if we removed this */ break; default: giterr_set(GITERR_INVALID, "Unknown index action %d", action); error = -1; break; } } git_buf_free(&path); git_pathspec__clear(&ps); return error; } int git_index_remove_all( git_index *index, const git_strarray *pathspec, git_index_matched_path_cb cb, void *payload) { int error = index_apply_to_all( index, INDEX_ACTION_REMOVE, pathspec, cb, payload); if (error) /* make sure error is set if callback stopped iteration */ giterr_set_after_callback(error); return error; } int git_index_update_all( git_index *index, const git_strarray *pathspec, git_index_matched_path_cb cb, void *payload) { int error = index_apply_to_wd_diff(index, INDEX_ACTION_UPDATE, pathspec, 0, cb, payload); if (error) /* make sure error is set if callback stopped iteration */ giterr_set_after_callback(error); return error; } int git_index_snapshot_new(git_vector *snap, git_index *index) { int error; GIT_REFCOUNT_INC(index); if (git_mutex_lock(&index->lock) < 0) { giterr_set(GITERR_OS, "Failed to lock index"); return -1; } git_atomic_inc(&index->readers); git_vector_sort(&index->entries); error = git_vector_dup(snap, &index->entries, index->entries._cmp); git_mutex_unlock(&index->lock); if (error < 0) git_index_free(index); return error; } void git_index_snapshot_release(git_vector *snap, git_index *index) { git_vector_free(snap); git_atomic_dec(&index->readers); if (!git_mutex_lock(&index->lock)) { index_free_deleted(index); /* try to free pending deleted items */ git_mutex_unlock(&index->lock); } git_index_free(index); } int git_index_snapshot_find( size_t *out, git_vector *entries, git_vector_cmp entry_srch, const char *path, size_t path_len, int stage) { return index_find_in_entries(out, entries, entry_srch, path, path_len, stage); } int git_indexwriter_init( git_indexwriter *writer, git_index *index) { int error; GIT_REFCOUNT_INC(index); writer->index = index; if (!index->index_file_path) return create_index_error(-1, "Failed to write index: The index is in-memory only"); if ((error = git_filebuf_open( &writer->file, index->index_file_path, GIT_FILEBUF_HASH_CONTENTS, GIT_INDEX_FILE_MODE)) < 0) { if (error == GIT_ELOCKED) giterr_set(GITERR_INDEX, "The index is locked. This might be due to a concurrent or crashed process"); return error; } writer->should_write = 1; return 0; } int git_indexwriter_init_for_operation( git_indexwriter *writer, git_repository *repo, unsigned int *checkout_strategy) { git_index *index; int error; if ((error = git_repository_index__weakptr(&index, repo)) < 0 || (error = git_indexwriter_init(writer, index)) < 0) return error; writer->should_write = (*checkout_strategy & GIT_CHECKOUT_DONT_WRITE_INDEX) == 0; *checkout_strategy |= GIT_CHECKOUT_DONT_WRITE_INDEX; return 0; } int git_indexwriter_commit(git_indexwriter *writer) { int error; git_oid checksum = {{ 0 }}; if (!writer->should_write) return 0; if (index_sort_if_needed(writer->index, true) < 0) return -1; git_vector_sort(&writer->index->reuc); if ((error = write_index(&checksum, writer->index, &writer->file)) < 0) { git_indexwriter_cleanup(writer); return error; } if ((error = git_filebuf_commit(&writer->file)) < 0) return error; if ((error = git_futils_filestamp_check( &writer->index->stamp, writer->index->index_file_path)) < 0) { giterr_set(GITERR_OS, "Could not read index timestamp"); return -1; } writer->index->on_disk = 1; git_oid_cpy(&writer->index->checksum, &checksum); git_index_free(writer->index); writer->index = NULL; return 0; } void git_indexwriter_cleanup(git_indexwriter *writer) { git_filebuf_cleanup(&writer->file); git_index_free(writer->index); writer->index = NULL; } deps/libgit2-sys-0.3.8/libgit2/src/netops.h0000664000175000017500000000466712555730137015400 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_netops_h__ #define INCLUDE_netops_h__ #include "posix.h" #include "common.h" #include "stream.h" #ifdef GIT_OPENSSL # include #endif typedef struct gitno_ssl { #ifdef GIT_OPENSSL SSL *ssl; #else size_t dummy; #endif } gitno_ssl; /* Represents a socket that may or may not be using SSL */ typedef struct gitno_socket { GIT_SOCKET socket; gitno_ssl ssl; } gitno_socket; typedef struct gitno_buffer { char *data; size_t len; size_t offset; int (*recv)(struct gitno_buffer *buffer); void *cb_data; } gitno_buffer; /* Flags to gitno_connect */ enum { /* Attempt to create an SSL connection. */ GITNO_CONNECT_SSL = 1, }; /** * Check if the name in a cert matches the wanted hostname * * Check if a pattern from a certificate matches the hostname we * wanted to connect to according to RFC2818 rules (which specifies * HTTP over TLS). Mainly, an asterisk matches anything, but is * limited to a single url component. * * Note that this does not set an error message. It expects the user * to provide the message for the user. */ int gitno__match_host(const char *pattern, const char *host); void gitno_buffer_setup_fromstream(git_stream *st, gitno_buffer *buf, char *data, size_t len); void gitno_buffer_setup_callback(gitno_buffer *buf, char *data, size_t len, int (*recv)(gitno_buffer *buf), void *cb_data); int gitno_recv(gitno_buffer *buf); void gitno_consume(gitno_buffer *buf, const char *ptr); void gitno_consume_n(gitno_buffer *buf, size_t cons); typedef struct gitno_connection_data { char *host; char *port; char *path; char *user; char *pass; bool use_ssl; } gitno_connection_data; /* * This replaces all the pointers in `data` with freshly-allocated strings, * that the caller is responsible for freeing. * `gitno_connection_data_free_ptrs` is good for this. */ int gitno_connection_data_from_url( gitno_connection_data *data, const char *url, const char *service_suffix); /* This frees all the pointers IN the struct, but not the struct itself. */ void gitno_connection_data_free_ptrs(gitno_connection_data *data); int gitno_extract_url_parts( char **host, char **port, char **path, char **username, char **password, const char *url, const char *default_port); #endif deps/libgit2-sys-0.3.8/libgit2/src/diff_file.h0000664000175000017500000000320112555730137015756 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_diff_file_h__ #define INCLUDE_diff_file_h__ #include "common.h" #include "diff.h" #include "diff_driver.h" #include "map.h" /* expanded information for one side of a delta */ typedef struct { git_repository *repo; git_diff_file *file; git_diff_driver *driver; uint32_t flags; uint32_t opts_flags; git_off_t opts_max_size; git_iterator_type_t src; const git_blob *blob; git_map map; } git_diff_file_content; extern int git_diff_file_content__init_from_diff( git_diff_file_content *fc, git_diff *diff, git_diff_delta *delta, bool use_old); typedef struct { const git_blob *blob; const void *buf; size_t buflen; const char *as_path; } git_diff_file_content_src; #define GIT_DIFF_FILE_CONTENT_SRC__BLOB(BLOB,PATH) { (BLOB),NULL,0,(PATH) } #define GIT_DIFF_FILE_CONTENT_SRC__BUF(BUF,LEN,PATH) { NULL,(BUF),(LEN),(PATH) } extern int git_diff_file_content__init_from_src( git_diff_file_content *fc, git_repository *repo, const git_diff_options *opts, const git_diff_file_content_src *src, git_diff_file *as_file); /* this loads the blob/file-on-disk as needed */ extern int git_diff_file_content__load( git_diff_file_content *fc, git_diff_options *diff_opts); /* this releases the blob/file-in-memory */ extern void git_diff_file_content__unload(git_diff_file_content *fc); /* this unloads and also releases any other resources */ extern void git_diff_file_content__clear(git_diff_file_content *fc); #endif deps/libgit2-sys-0.3.8/libgit2/src/refspec.c0000664000175000017500000002122012555730137015472 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/errors.h" #include "common.h" #include "refspec.h" #include "util.h" #include "posix.h" #include "refs.h" #include "vector.h" int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch) { // Ported from https://github.com/git/git/blob/f06d47e7e0d9db709ee204ed13a8a7486149f494/remote.c#L518-636 size_t llen; int is_glob = 0; const char *lhs, *rhs; int flags; assert(refspec && input); memset(refspec, 0x0, sizeof(git_refspec)); refspec->push = !is_fetch; lhs = input; if (*lhs == '+') { refspec->force = 1; lhs++; } rhs = strrchr(lhs, ':'); /* * Before going on, special case ":" (or "+:") as a refspec * for matching refs. */ if (!is_fetch && rhs == lhs && rhs[1] == '\0') { refspec->matching = 1; refspec->string = git__strdup(input); GITERR_CHECK_ALLOC(refspec->string); refspec->src = git__strdup(""); GITERR_CHECK_ALLOC(refspec->src); refspec->dst = git__strdup(""); GITERR_CHECK_ALLOC(refspec->dst); return 0; } if (rhs) { size_t rlen = strlen(++rhs); is_glob = (1 <= rlen && strchr(rhs, '*')); refspec->dst = git__strndup(rhs, rlen); } llen = (rhs ? (size_t)(rhs - lhs - 1) : strlen(lhs)); if (1 <= llen && memchr(lhs, '*', llen)) { if ((rhs && !is_glob) || (!rhs && is_fetch)) goto invalid; is_glob = 1; } else if (rhs && is_glob) goto invalid; refspec->pattern = is_glob; refspec->src = git__strndup(lhs, llen); flags = GIT_REF_FORMAT_ALLOW_ONELEVEL | GIT_REF_FORMAT_REFSPEC_SHORTHAND | (is_glob ? GIT_REF_FORMAT_REFSPEC_PATTERN : 0); if (is_fetch) { /* * LHS * - empty is allowed; it means HEAD. * - otherwise it must be a valid looking ref. */ if (!*refspec->src) ; /* empty is ok */ else if (!git_reference__is_valid_name(refspec->src, flags)) goto invalid; /* * RHS * - missing is ok, and is same as empty. * - empty is ok; it means not to store. * - otherwise it must be a valid looking ref. */ if (!refspec->dst) ; /* ok */ else if (!*refspec->dst) ; /* ok */ else if (!git_reference__is_valid_name(refspec->dst, flags)) goto invalid; } else { /* * LHS * - empty is allowed; it means delete. * - when wildcarded, it must be a valid looking ref. * - otherwise, it must be an extended SHA-1, but * there is no existing way to validate this. */ if (!*refspec->src) ; /* empty is ok */ else if (is_glob) { if (!git_reference__is_valid_name(refspec->src, flags)) goto invalid; } else { ; /* anything goes, for now */ } /* * RHS * - missing is allowed, but LHS then must be a * valid looking ref. * - empty is not allowed. * - otherwise it must be a valid looking ref. */ if (!refspec->dst) { if (!git_reference__is_valid_name(refspec->src, flags)) goto invalid; } else if (!*refspec->dst) { goto invalid; } else { if (!git_reference__is_valid_name(refspec->dst, flags)) goto invalid; } /* if the RHS is empty, then it's a copy of the LHS */ if (!refspec->dst) { refspec->dst = git__strdup(refspec->src); GITERR_CHECK_ALLOC(refspec->dst); } } refspec->string = git__strdup(input); GITERR_CHECK_ALLOC(refspec->string); return 0; invalid: giterr_set( GITERR_INVALID, "'%s' is not a valid refspec.", input); git_refspec__free(refspec); return -1; } void git_refspec__free(git_refspec *refspec) { if (refspec == NULL) return; git__free(refspec->src); git__free(refspec->dst); git__free(refspec->string); memset(refspec, 0x0, sizeof(git_refspec)); } const char *git_refspec_src(const git_refspec *refspec) { return refspec == NULL ? NULL : refspec->src; } const char *git_refspec_dst(const git_refspec *refspec) { return refspec == NULL ? NULL : refspec->dst; } const char *git_refspec_string(const git_refspec *refspec) { return refspec == NULL ? NULL : refspec->string; } int git_refspec_force(const git_refspec *refspec) { assert(refspec); return refspec->force; } int git_refspec_src_matches(const git_refspec *refspec, const char *refname) { if (refspec == NULL || refspec->src == NULL) return false; return (p_fnmatch(refspec->src, refname, 0) == 0); } int git_refspec_dst_matches(const git_refspec *refspec, const char *refname) { if (refspec == NULL || refspec->dst == NULL) return false; return (p_fnmatch(refspec->dst, refname, 0) == 0); } static int refspec_transform( git_buf *out, const char *from, const char *to, const char *name) { const char *from_star, *to_star; const char *name_slash, *from_slash; size_t replacement_len, star_offset; git_buf_sanitize(out); git_buf_clear(out); /* * There are two parts to each side of a refspec, the bit * before the star and the bit after it. The star can be in * the middle of the pattern, so we need to look at each bit * individually. */ from_star = strchr(from, '*'); to_star = strchr(to, '*'); assert(from_star && to_star); /* star offset, both in 'from' and in 'name' */ star_offset = from_star - from; /* the first half is copied over */ git_buf_put(out, to, to_star - to); /* then we copy over the replacement, from the star's offset to the next slash in 'name' */ name_slash = strchr(name + star_offset, '/'); if (!name_slash) name_slash = strrchr(name, '\0'); /* if there is no slash after the star in 'from', we want to copy everything over */ from_slash = strchr(from + star_offset, '/'); if (!from_slash) name_slash = strrchr(name, '\0'); replacement_len = (name_slash - name) - star_offset; git_buf_put(out, name + star_offset, replacement_len); return git_buf_puts(out, to_star + 1); } int git_refspec_transform(git_buf *out, const git_refspec *spec, const char *name) { assert(out && spec && name); git_buf_sanitize(out); if (!git_refspec_src_matches(spec, name)) { giterr_set(GITERR_INVALID, "ref '%s' doesn't match the source", name); return -1; } if (!spec->pattern) return git_buf_puts(out, spec->dst); return refspec_transform(out, spec->src, spec->dst, name); } int git_refspec_rtransform(git_buf *out, const git_refspec *spec, const char *name) { assert(out && spec && name); git_buf_sanitize(out); if (!git_refspec_dst_matches(spec, name)) { giterr_set(GITERR_INVALID, "ref '%s' doesn't match the destination", name); return -1; } if (!spec->pattern) return git_buf_puts(out, spec->src); return refspec_transform(out, spec->dst, spec->src, name); } int git_refspec__serialize(git_buf *out, const git_refspec *refspec) { if (refspec->force) git_buf_putc(out, '+'); git_buf_printf(out, "%s:%s", refspec->src != NULL ? refspec->src : "", refspec->dst != NULL ? refspec->dst : ""); return git_buf_oom(out) == false; } int git_refspec_is_wildcard(const git_refspec *spec) { assert(spec && spec->src); return (spec->src[strlen(spec->src) - 1] == '*'); } git_direction git_refspec_direction(const git_refspec *spec) { assert(spec); return spec->push; } int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs) { git_buf buf = GIT_BUF_INIT; size_t j, pos; git_remote_head key; const char* formatters[] = { GIT_REFS_DIR "%s", GIT_REFS_TAGS_DIR "%s", GIT_REFS_HEADS_DIR "%s", NULL }; git_refspec *cur = git__calloc(1, sizeof(git_refspec)); GITERR_CHECK_ALLOC(cur); cur->force = spec->force; cur->push = spec->push; cur->pattern = spec->pattern; cur->matching = spec->matching; cur->string = git__strdup(spec->string); /* shorthand on the lhs */ if (git__prefixcmp(spec->src, GIT_REFS_DIR)) { for (j = 0; formatters[j]; j++) { git_buf_clear(&buf); if (git_buf_printf(&buf, formatters[j], spec->src) < 0) return -1; key.name = (char *) git_buf_cstr(&buf); if (!git_vector_search(&pos, refs, &key)) { /* we found something to match the shorthand, set src to that */ cur->src = git_buf_detach(&buf); } } } /* No shorthands found, copy over the name */ if (cur->src == NULL && spec->src != NULL) { cur->src = git__strdup(spec->src); GITERR_CHECK_ALLOC(cur->src); } if (spec->dst && git__prefixcmp(spec->dst, GIT_REFS_DIR)) { /* if it starts with "remotes" then we just prepend "refs/" */ if (!git__prefixcmp(spec->dst, "remotes/")) { git_buf_puts(&buf, GIT_REFS_DIR); } else { git_buf_puts(&buf, GIT_REFS_HEADS_DIR); } if (git_buf_puts(&buf, spec->dst) < 0) return -1; cur->dst = git_buf_detach(&buf); } git_buf_free(&buf); if (cur->dst == NULL && spec->dst != NULL) { cur->dst = git__strdup(spec->dst); GITERR_CHECK_ALLOC(cur->dst); } return git_vector_insert(out, cur); } deps/libgit2-sys-0.3.8/libgit2/src/checkout.h0000664000175000017500000000125712510265101015646 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_checkout_h__ #define INCLUDE_checkout_h__ #include "git2/checkout.h" #include "iterator.h" #define GIT_CHECKOUT__NOTIFY_CONFLICT_TREE (1u << 12) /** * Update the working directory to match the target iterator. The * expected baseline value can be passed in via the checkout options * or else will default to the HEAD commit. */ extern int git_checkout_iterator( git_iterator *target, git_index *index, const git_checkout_options *opts); #endif deps/libgit2-sys-0.3.8/libgit2/src/annotated_commit.h0000664000175000017500000000074712510265101017371 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_annotated_commit_h__ #define INCLUDE_annotated_commit_h__ #include "git2/oid.h" /** Internal structure for merge inputs */ struct git_annotated_commit { git_commit *commit; char *ref_name; char *remote_url; char id_str[GIT_OID_HEXSZ+1]; }; #endif deps/libgit2-sys-0.3.8/libgit2/src/stransport_stream.h0000664000175000017500000000064612555730137017653 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_stransport_stream_h__ #define INCLUDE_stransport_stream_h__ #include "git2/sys/stream.h" extern int git_stransport_stream_new(git_stream **out, const char *host, const char *port); #endif deps/libgit2-sys-0.3.8/libgit2/src/delta.h0000664000175000017500000000705012426525445015147 0ustar /* * diff-delta code taken from git.git. See diff-delta.c for details. * */ #ifndef INCLUDE_git_delta_h__ #define INCLUDE_git_delta_h__ #include "common.h" /* opaque object for delta index */ struct git_delta_index; /* * create_delta_index: compute index data from given buffer * * This returns a pointer to a struct delta_index that should be passed to * subsequent create_delta() calls, or to free_delta_index(). A NULL pointer * is returned on failure. The given buffer must not be freed nor altered * before free_delta_index() is called. The returned pointer must be freed * using free_delta_index(). */ extern struct git_delta_index * git_delta_create_index(const void *buf, unsigned long bufsize); /* * free_delta_index: free the index created by create_delta_index() * * Given pointer must be what create_delta_index() returned, or NULL. */ extern void git_delta_free_index(struct git_delta_index *index); /* * sizeof_delta_index: returns memory usage of delta index * * Given pointer must be what create_delta_index() returned, or NULL. */ extern unsigned long git_delta_sizeof_index(struct git_delta_index *index); /* * create_delta: create a delta from given index for the given buffer * * This function may be called multiple times with different buffers using * the same delta_index pointer. If max_delta_size is non-zero and the * resulting delta is to be larger than max_delta_size then NULL is returned. * On success, a non-NULL pointer to the buffer with the delta data is * returned and *delta_size is updated with its size. The returned buffer * must be freed by the caller. */ extern void *git_delta_create( const struct git_delta_index *index, const void *buf, unsigned long bufsize, unsigned long *delta_size, unsigned long max_delta_size); /* * diff_delta: create a delta from source buffer to target buffer * * If max_delta_size is non-zero and the resulting delta is to be larger * than max_delta_size then NULL is returned. On success, a non-NULL * pointer to the buffer with the delta data is returned and *delta_size is * updated with its size. The returned buffer must be freed by the caller. */ GIT_INLINE(void *) git_delta( const void *src_buf, unsigned long src_bufsize, const void *trg_buf, unsigned long trg_bufsize, unsigned long *delta_size, unsigned long max_delta_size) { struct git_delta_index *index = git_delta_create_index(src_buf, src_bufsize); if (index) { void *delta = git_delta_create( index, trg_buf, trg_bufsize, delta_size, max_delta_size); git_delta_free_index(index); return delta; } return NULL; } /* * patch_delta: recreate target buffer given source buffer and delta data * * On success, a non-NULL pointer to the target buffer is returned and * *trg_bufsize is updated with its size. On failure a NULL pointer is * returned. The returned buffer must be freed by the caller. */ extern void *git_delta_patch( const void *src_buf, unsigned long src_size, const void *delta_buf, unsigned long delta_size, unsigned long *dst_size); /* the smallest possible delta size is 4 bytes */ #define GIT_DELTA_SIZE_MIN 4 /* * This must be called twice on the delta data buffer, first to get the * expected source buffer size, and again to get the target buffer size. */ GIT_INLINE(unsigned long) git_delta_get_hdr_size( const unsigned char **datap, const unsigned char *top) { const unsigned char *data = *datap; unsigned long cmd, size = 0; int i = 0; do { cmd = *data++; size |= (cmd & 0x7f) << i; i += 7; } while (cmd & 0x80 && data < top); *datap = data; return size; } #endif deps/libgit2-sys-0.3.8/libgit2/src/cc-compat.h0000664000175000017500000000363412510265101015710 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_compat_h__ #define INCLUDE_compat_h__ #include /* * See if our compiler is known to support flexible array members. */ #ifndef GIT_FLEX_ARRAY # if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) # define GIT_FLEX_ARRAY /* empty */ # elif defined(__GNUC__) # if (__GNUC__ >= 3) # define GIT_FLEX_ARRAY /* empty */ # else # define GIT_FLEX_ARRAY 0 /* older GNU extension */ # endif # endif /* Default to safer but a bit wasteful traditional style */ # ifndef GIT_FLEX_ARRAY # define GIT_FLEX_ARRAY 1 # endif #endif #ifdef __GNUC__ # define GIT_TYPEOF(x) (__typeof__(x)) #else # define GIT_TYPEOF(x) #endif #if defined(__GNUC__) # define GIT_ALIGN(x,size) x __attribute__ ((aligned(size))) #elif defined(_MSC_VER) # define GIT_ALIGN(x,size) __declspec(align(size)) x #else # define GIT_ALIGN(x,size) x #endif #define GIT_UNUSED(x) ((void)(x)) /* Define the printf format specifer to use for size_t output */ #if defined(_MSC_VER) || defined(__MINGW32__) # define PRIuZ "Iu" # define PRIxZ "Ix" # define PRIdZ "Id" #else # define PRIuZ "zu" # define PRIxZ "zx" # define PRIdZ "zd" #endif /* Micosoft Visual C/C++ */ #if defined(_MSC_VER) /* disable "deprecated function" warnings */ # pragma warning ( disable : 4996 ) /* disable "conditional expression is constant" level 4 warnings */ # pragma warning ( disable : 4127 ) #endif #if defined (_MSC_VER) typedef unsigned char bool; # ifndef true # define true 1 # endif # ifndef false # define false 0 # endif #else # include #endif #ifndef va_copy # ifdef __va_copy # define va_copy(dst, src) __va_copy(dst, src) # else # define va_copy(dst, src) ((dst) = (src)) # endif #endif #endif /* INCLUDE_compat_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/vector.c0000664000175000017500000001506212510265101015335 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "vector.h" /* In elements, not bytes */ #define MIN_ALLOCSIZE 8 GIT_INLINE(size_t) compute_new_size(git_vector *v) { size_t new_size = v->_alloc_size; /* Use a resize factor of 1.5, which is quick to compute using integer * instructions and less than the golden ratio (1.618...) */ if (new_size < MIN_ALLOCSIZE) new_size = MIN_ALLOCSIZE; else if (new_size <= (SIZE_MAX / 3) * 2) new_size += new_size / 2; else new_size = SIZE_MAX; return new_size; } GIT_INLINE(int) resize_vector(git_vector *v, size_t new_size) { void *new_contents; new_contents = git__reallocarray(v->contents, new_size, sizeof(void *)); GITERR_CHECK_ALLOC(new_contents); v->_alloc_size = new_size; v->contents = new_contents; return 0; } int git_vector_dup(git_vector *v, const git_vector *src, git_vector_cmp cmp) { size_t bytes; assert(v && src); GITERR_CHECK_ALLOC_MULTIPLY(&bytes, src->length, sizeof(void *)); v->_alloc_size = src->length; v->_cmp = cmp ? cmp : src->_cmp; v->length = src->length; v->flags = src->flags; if (cmp != src->_cmp) git_vector_set_sorted(v, 0); v->contents = git__malloc(bytes); GITERR_CHECK_ALLOC(v->contents); memcpy(v->contents, src->contents, bytes); return 0; } void git_vector_free(git_vector *v) { assert(v); git__free(v->contents); v->contents = NULL; v->length = 0; v->_alloc_size = 0; } void git_vector_free_deep(git_vector *v) { size_t i; assert(v); for (i = 0; i < v->length; ++i) { git__free(v->contents[i]); v->contents[i] = NULL; } git_vector_free(v); } int git_vector_init(git_vector *v, size_t initial_size, git_vector_cmp cmp) { assert(v); v->_alloc_size = 0; v->_cmp = cmp; v->length = 0; v->flags = GIT_VECTOR_SORTED; v->contents = NULL; return resize_vector(v, max(initial_size, MIN_ALLOCSIZE)); } void **git_vector_detach(size_t *size, size_t *asize, git_vector *v) { void **data = v->contents; if (size) *size = v->length; if (asize) *asize = v->_alloc_size; v->_alloc_size = 0; v->length = 0; v->contents = NULL; return data; } int git_vector_insert(git_vector *v, void *element) { assert(v); if (v->length >= v->_alloc_size && resize_vector(v, compute_new_size(v)) < 0) return -1; v->contents[v->length++] = element; git_vector_set_sorted(v, v->length <= 1); return 0; } int git_vector_insert_sorted( git_vector *v, void *element, int (*on_dup)(void **old, void *new)) { int result; size_t pos; assert(v && v->_cmp); if (!git_vector_is_sorted(v)) git_vector_sort(v); if (v->length >= v->_alloc_size && resize_vector(v, compute_new_size(v)) < 0) return -1; /* If we find the element and have a duplicate handler callback, * invoke it. If it returns non-zero, then cancel insert, otherwise * proceed with normal insert. */ if (!git__bsearch(v->contents, v->length, element, v->_cmp, &pos) && on_dup && (result = on_dup(&v->contents[pos], element)) < 0) return result; /* shift elements to the right */ if (pos < v->length) memmove(v->contents + pos + 1, v->contents + pos, (v->length - pos) * sizeof(void *)); v->contents[pos] = element; v->length++; return 0; } void git_vector_sort(git_vector *v) { assert(v); if (git_vector_is_sorted(v) || !v->_cmp) return; if (v->length > 1) git__tsort(v->contents, v->length, v->_cmp); git_vector_set_sorted(v, 1); } int git_vector_bsearch2( size_t *at_pos, git_vector *v, git_vector_cmp key_lookup, const void *key) { assert(v && key && key_lookup); /* need comparison function to sort the vector */ if (!v->_cmp) return -1; git_vector_sort(v); return git__bsearch(v->contents, v->length, key, key_lookup, at_pos); } int git_vector_search2( size_t *at_pos, const git_vector *v, git_vector_cmp key_lookup, const void *key) { size_t i; assert(v && key && key_lookup); for (i = 0; i < v->length; ++i) { if (key_lookup(key, v->contents[i]) == 0) { if (at_pos) *at_pos = i; return 0; } } return GIT_ENOTFOUND; } static int strict_comparison(const void *a, const void *b) { return (a == b) ? 0 : -1; } int git_vector_search(size_t *at_pos, const git_vector *v, const void *entry) { return git_vector_search2(at_pos, v, v->_cmp ? v->_cmp : strict_comparison, entry); } int git_vector_remove(git_vector *v, size_t idx) { size_t shift_count; assert(v); if (idx >= v->length) return GIT_ENOTFOUND; shift_count = v->length - idx - 1; if (shift_count) memmove(&v->contents[idx], &v->contents[idx + 1], shift_count * sizeof(void *)); v->length--; return 0; } void git_vector_pop(git_vector *v) { if (v->length > 0) v->length--; } void git_vector_uniq(git_vector *v, void (*git_free_cb)(void *)) { git_vector_cmp cmp; size_t i, j; if (v->length <= 1) return; git_vector_sort(v); cmp = v->_cmp ? v->_cmp : strict_comparison; for (i = 0, j = 1 ; j < v->length; ++j) if (!cmp(v->contents[i], v->contents[j])) { if (git_free_cb) git_free_cb(v->contents[i]); v->contents[i] = v->contents[j]; } else v->contents[++i] = v->contents[j]; v->length -= j - i - 1; } void git_vector_remove_matching( git_vector *v, int (*match)(const git_vector *v, size_t idx, void *payload), void *payload) { size_t i, j; for (i = 0, j = 0; j < v->length; ++j) { v->contents[i] = v->contents[j]; if (!match(v, i, payload)) i++; } v->length = i; } void git_vector_clear(git_vector *v) { assert(v); v->length = 0; git_vector_set_sorted(v, 1); } void git_vector_swap(git_vector *a, git_vector *b) { git_vector t; assert(a && b); if (a != b) { memcpy(&t, a, sizeof(t)); memcpy(a, b, sizeof(t)); memcpy(b, &t, sizeof(t)); } } int git_vector_resize_to(git_vector *v, size_t new_length) { if (new_length > v->_alloc_size && resize_vector(v, new_length) < 0) return -1; if (new_length > v->length) memset(&v->contents[v->length], 0, sizeof(void *) * (new_length - v->length)); v->length = new_length; return 0; } int git_vector_set(void **old, git_vector *v, size_t position, void *value) { if (position + 1 > v->length) { if (git_vector_resize_to(v, position + 1) < 0) return -1; } if (old != NULL) *old = v->contents[position]; v->contents[position] = value; return 0; } int git_vector_verify_sorted(const git_vector *v) { size_t i; if (!git_vector_is_sorted(v)) return -1; for (i = 1; i < v->length; ++i) { if (v->_cmp(v->contents[i - 1], v->contents[i]) > 0) return -1; } return 0; } deps/libgit2-sys-0.3.8/libgit2/src/submodule.c0000664000175000017500000015043412610310643016040 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "git2/config.h" #include "git2/sys/config.h" #include "git2/types.h" #include "git2/index.h" #include "buffer.h" #include "buf_text.h" #include "vector.h" #include "posix.h" #include "config_file.h" #include "config.h" #include "repository.h" #include "submodule.h" #include "tree.h" #include "iterator.h" #include "path.h" #include "index.h" #define GIT_MODULES_FILE ".gitmodules" static git_cvar_map _sm_update_map[] = { {GIT_CVAR_STRING, "checkout", GIT_SUBMODULE_UPDATE_CHECKOUT}, {GIT_CVAR_STRING, "rebase", GIT_SUBMODULE_UPDATE_REBASE}, {GIT_CVAR_STRING, "merge", GIT_SUBMODULE_UPDATE_MERGE}, {GIT_CVAR_STRING, "none", GIT_SUBMODULE_UPDATE_NONE}, {GIT_CVAR_FALSE, NULL, GIT_SUBMODULE_UPDATE_NONE}, {GIT_CVAR_TRUE, NULL, GIT_SUBMODULE_UPDATE_CHECKOUT}, }; static git_cvar_map _sm_ignore_map[] = { {GIT_CVAR_STRING, "none", GIT_SUBMODULE_IGNORE_NONE}, {GIT_CVAR_STRING, "untracked", GIT_SUBMODULE_IGNORE_UNTRACKED}, {GIT_CVAR_STRING, "dirty", GIT_SUBMODULE_IGNORE_DIRTY}, {GIT_CVAR_STRING, "all", GIT_SUBMODULE_IGNORE_ALL}, {GIT_CVAR_FALSE, NULL, GIT_SUBMODULE_IGNORE_NONE}, {GIT_CVAR_TRUE, NULL, GIT_SUBMODULE_IGNORE_ALL}, }; static git_cvar_map _sm_recurse_map[] = { {GIT_CVAR_STRING, "on-demand", GIT_SUBMODULE_RECURSE_ONDEMAND}, {GIT_CVAR_FALSE, NULL, GIT_SUBMODULE_RECURSE_NO}, {GIT_CVAR_TRUE, NULL, GIT_SUBMODULE_RECURSE_YES}, }; enum { CACHE_OK = 0, CACHE_REFRESH = 1, CACHE_FLUSH = 2 }; enum { GITMODULES_EXISTING = 0, GITMODULES_CREATE = 1, }; static kh_inline khint_t str_hash_no_trailing_slash(const char *s) { khint_t h; for (h = 0; *s; ++s) if (s[1] != '\0' || *s != '/') h = (h << 5) - h + *s; return h; } static kh_inline int str_equal_no_trailing_slash(const char *a, const char *b) { size_t alen = a ? strlen(a) : 0; size_t blen = b ? strlen(b) : 0; if (alen > 0 && a[alen - 1] == '/') alen--; if (blen > 0 && b[blen - 1] == '/') blen--; return (alen == blen && strncmp(a, b, alen) == 0); } __KHASH_IMPL( str, static kh_inline, const char *, void *, 1, str_hash_no_trailing_slash, str_equal_no_trailing_slash) static int submodule_alloc(git_submodule **out, git_repository *repo, const char *name); static git_config_backend *open_gitmodules(git_repository *repo, int gitmod); static git_config *gitmodules_snapshot(git_repository *repo); static int get_url_base(git_buf *url, git_repository *repo); static int lookup_head_remote_key(git_buf *remote_key, git_repository *repo); static int submodule_load_each(const git_config_entry *entry, void *payload); static int submodule_read_config(git_submodule *sm, git_config *cfg); static int submodule_load_from_wd_lite(git_submodule *); static void submodule_get_index_status(unsigned int *, git_submodule *); static void submodule_get_wd_status(unsigned int *, git_submodule *, git_repository *, git_submodule_ignore_t); static void submodule_update_from_index_entry(git_submodule *sm, const git_index_entry *ie); static void submodule_update_from_head_data(git_submodule *sm, mode_t mode, const git_oid *id); static int submodule_cmp(const void *a, const void *b) { return strcmp(((git_submodule *)a)->name, ((git_submodule *)b)->name); } static int submodule_config_key_trunc_puts(git_buf *key, const char *suffix) { ssize_t idx = git_buf_rfind(key, '.'); git_buf_truncate(key, (size_t)(idx + 1)); return git_buf_puts(key, suffix); } /* * PUBLIC APIS */ static void submodule_set_lookup_error(int error, const char *name) { if (!error) return; giterr_set(GITERR_SUBMODULE, (error == GIT_ENOTFOUND) ? "No submodule named '%s'" : "Submodule '%s' has not been added yet", name); } typedef struct { const char *path; char *name; } fbp_data; static int find_by_path(const git_config_entry *entry, void *payload) { fbp_data *data = payload; if (!strcmp(entry->value, data->path)) { const char *fdot, *ldot; fdot = strchr(entry->name, '.'); ldot = strrchr(entry->name, '.'); data->name = git__strndup(fdot + 1, ldot - fdot - 1); GITERR_CHECK_ALLOC(data->name); } return 0; } /** * Find out the name of a submodule from its path */ static int name_from_path(git_buf *out, git_config *cfg, const char *path) { const char *key = "submodule\\..*\\.path"; git_config_iterator *iter; git_config_entry *entry; int error; if ((error = git_config_iterator_glob_new(&iter, cfg, key)) < 0) return error; while ((error = git_config_next(&entry, iter)) == 0) { const char *fdot, *ldot; /* TODO: this should maybe be strcasecmp on a case-insensitive fs */ if (strcmp(path, entry->value) != 0) continue; fdot = strchr(entry->name, '.'); ldot = strrchr(entry->name, '.'); git_buf_clear(out); git_buf_put(out, fdot + 1, ldot - fdot - 1); goto cleanup; } if (error == GIT_ITEROVER) { giterr_set(GITERR_SUBMODULE, "could not find a submodule name for '%s'", path); error = GIT_ENOTFOUND; } cleanup: git_config_iterator_free(iter); return error; } int git_submodule_lookup( git_submodule **out, /* NULL if user only wants to test existence */ git_repository *repo, const char *name) /* trailing slash is allowed */ { int error; unsigned int location; git_submodule *sm; assert(repo && name); if ((error = submodule_alloc(&sm, repo, name)) < 0) return error; if ((error = git_submodule_reload(sm, false)) < 0) { git_submodule_free(sm); return error; } if ((error = git_submodule_location(&location, sm)) < 0) { git_submodule_free(sm); return error; } /* If it's not configured or we're looking by path */ if (location == 0 || location == GIT_SUBMODULE_STATUS_IN_WD) { git_config_backend *mods; const char *pattern = "submodule\\..*\\.path"; git_buf path = GIT_BUF_INIT; fbp_data data = { NULL, NULL }; git_buf_puts(&path, name); while (path.ptr[path.size-1] == '/') { path.ptr[--path.size] = '\0'; } data.path = path.ptr; mods = open_gitmodules(repo, GITMODULES_EXISTING); if (mods) error = git_config_file_foreach_match(mods, pattern, find_by_path, &data); git_config_file_free(mods); if (error < 0) { git_submodule_free(sm); git_buf_free(&path); return error; } if (data.name) { git__free(sm->name); sm->name = data.name; sm->path = git_buf_detach(&path); /* Try to load again with the right name */ if ((error = git_submodule_reload(sm, false)) < 0) { git_submodule_free(sm); return error; } } git_buf_free(&path); } if ((error = git_submodule_location(&location, sm)) < 0) { git_submodule_free(sm); return error; } /* If we still haven't found it, do the WD check */ if (location == 0 || location == GIT_SUBMODULE_STATUS_IN_WD) { git_submodule_free(sm); error = GIT_ENOTFOUND; /* If it's not configured, we still check if there's a repo at the path */ if (git_repository_workdir(repo)) { git_buf path = GIT_BUF_INIT; if (git_buf_join3(&path, '/', git_repository_workdir(repo), name, DOT_GIT) < 0) return -1; if (git_path_exists(path.ptr)) error = GIT_EEXISTS; git_buf_free(&path); } submodule_set_lookup_error(error, name); return error; } if (out) *out = sm; else git_submodule_free(sm); return 0; } static void submodule_free_dup(void *sm) { git_submodule_free(sm); } static int submodule_get_or_create(git_submodule **out, git_repository *repo, git_strmap *map, const char *name) { int error = 0; khiter_t pos; git_submodule *sm = NULL; pos = git_strmap_lookup_index(map, name); if (git_strmap_valid_index(map, pos)) { sm = git_strmap_value_at(map, pos); goto done; } /* if the submodule doesn't exist yet in the map, create it */ if ((error = submodule_alloc(&sm, repo, name)) < 0) return error; pos = kh_put(str, map, sm->name, &error); /* nobody can beat us to adding it */ assert(error != 0); if (error < 0) { git_submodule_free(sm); return error; } git_strmap_set_value_at(map, pos, sm); done: GIT_REFCOUNT_INC(sm); *out = sm; return 0; } static int submodules_from_index(git_strmap *map, git_index *idx, git_config *cfg) { int error; git_iterator *i; const git_index_entry *entry; git_buf name = GIT_BUF_INIT; if ((error = git_iterator_for_index(&i, idx, NULL)) < 0) return error; while (!(error = git_iterator_advance(&entry, i))) { khiter_t pos = git_strmap_lookup_index(map, entry->path); git_submodule *sm; git_buf_clear(&name); if (!name_from_path(&name, cfg, entry->path)) { git_strmap_lookup_index(map, name.ptr); } if (git_strmap_valid_index(map, pos)) { sm = git_strmap_value_at(map, pos); if (S_ISGITLINK(entry->mode)) submodule_update_from_index_entry(sm, entry); else sm->flags |= GIT_SUBMODULE_STATUS__INDEX_NOT_SUBMODULE; } else if (S_ISGITLINK(entry->mode)) { if (!submodule_get_or_create(&sm, git_index_owner(idx), map, name.ptr ? name.ptr : entry->path)) { submodule_update_from_index_entry(sm, entry); git_submodule_free(sm); } } } if (error == GIT_ITEROVER) error = 0; git_buf_free(&name); git_iterator_free(i); return error; } static int submodules_from_head(git_strmap *map, git_tree *head, git_config *cfg) { int error; git_iterator *i; const git_index_entry *entry; git_buf name = GIT_BUF_INIT; if ((error = git_iterator_for_tree(&i, head, NULL)) < 0) return error; while (!(error = git_iterator_advance(&entry, i))) { khiter_t pos = git_strmap_lookup_index(map, entry->path); git_submodule *sm; git_buf_clear(&name); if (!name_from_path(&name, cfg, entry->path)) { git_strmap_lookup_index(map, name.ptr); } if (git_strmap_valid_index(map, pos)) { sm = git_strmap_value_at(map, pos); if (S_ISGITLINK(entry->mode)) submodule_update_from_head_data(sm, entry->mode, &entry->id); else sm->flags |= GIT_SUBMODULE_STATUS__HEAD_NOT_SUBMODULE; } else if (S_ISGITLINK(entry->mode)) { if (!submodule_get_or_create(&sm, git_tree_owner(head), map, name.ptr ? name.ptr : entry->path)) { submodule_update_from_head_data( sm, entry->mode, &entry->id); git_submodule_free(sm); } } } if (error == GIT_ITEROVER) error = 0; git_buf_free(&name); git_iterator_free(i); return error; } /* If have_sm is true, sm is populated, otherwise map an repo are. */ typedef struct { git_config *mods; git_strmap *map; git_repository *repo; } lfc_data; static int all_submodules(git_repository *repo, git_strmap *map) { int error = 0; git_index *idx = NULL; git_tree *head = NULL; const char *wd = NULL; git_buf path = GIT_BUF_INIT; git_submodule *sm; git_config *mods = NULL; uint32_t mask; assert(repo && map); /* get sources that we will need to check */ if (git_repository_index(&idx, repo) < 0) giterr_clear(); if (git_repository_head_tree(&head, repo) < 0) giterr_clear(); wd = git_repository_workdir(repo); if (wd && (error = git_buf_joinpath(&path, wd, GIT_MODULES_FILE)) < 0) goto cleanup; /* clear submodule flags that are to be refreshed */ mask = 0; mask |= GIT_SUBMODULE_STATUS_IN_INDEX | GIT_SUBMODULE_STATUS__INDEX_FLAGS | GIT_SUBMODULE_STATUS__INDEX_OID_VALID | GIT_SUBMODULE_STATUS__INDEX_MULTIPLE_ENTRIES; mask |= GIT_SUBMODULE_STATUS_IN_HEAD | GIT_SUBMODULE_STATUS__HEAD_OID_VALID; mask |= GIT_SUBMODULE_STATUS_IN_CONFIG; if (mask != 0) mask |= GIT_SUBMODULE_STATUS_IN_WD | GIT_SUBMODULE_STATUS__WD_SCANNED | GIT_SUBMODULE_STATUS__WD_FLAGS | GIT_SUBMODULE_STATUS__WD_OID_VALID; /* add submodule information from .gitmodules */ if (wd) { lfc_data data = { 0 }; data.map = map; data.repo = repo; if ((mods = gitmodules_snapshot(repo)) == NULL) goto cleanup; data.mods = mods; if ((error = git_config_foreach( mods, submodule_load_each, &data)) < 0) goto cleanup; } /* add back submodule information from index */ if (idx) { if ((error = submodules_from_index(map, idx, mods)) < 0) goto cleanup; } /* add submodule information from HEAD */ if (head) { if ((error = submodules_from_head(map, head, mods)) < 0) goto cleanup; } /* shallow scan submodules in work tree as needed */ if (wd && mask != 0) { git_strmap_foreach_value(map, sm, { submodule_load_from_wd_lite(sm); }); } cleanup: git_config_free(mods); /* TODO: if we got an error, mark submodule config as invalid? */ git_index_free(idx); git_tree_free(head); git_buf_free(&path); return error; } int git_submodule_foreach( git_repository *repo, int (*callback)(git_submodule *sm, const char *name, void *payload), void *payload) { git_vector snapshot = GIT_VECTOR_INIT; git_strmap *submodules; git_submodule *sm; int error; size_t i; if ((error = git_strmap_alloc(&submodules)) < 0) return error; if ((error = all_submodules(repo, submodules)) < 0) goto done; if (!(error = git_vector_init( &snapshot, kh_size(submodules), submodule_cmp))) { git_strmap_foreach_value(submodules, sm, { if ((error = git_vector_insert(&snapshot, sm)) < 0) break; GIT_REFCOUNT_INC(sm); }); } if (error < 0) goto done; git_vector_uniq(&snapshot, submodule_free_dup); git_vector_foreach(&snapshot, i, sm) { if ((error = callback(sm, sm->name, payload)) != 0) { giterr_set_after_callback(error); break; } } done: git_vector_foreach(&snapshot, i, sm) git_submodule_free(sm); git_vector_free(&snapshot); git_strmap_foreach_value(submodules, sm, { git_submodule_free(sm); }); git_strmap_free(submodules); return error; } static int submodule_repo_init( git_repository **out, git_repository *parent_repo, const char *path, const char *url, bool use_gitlink) { int error = 0; git_buf workdir = GIT_BUF_INIT, repodir = GIT_BUF_INIT; git_repository_init_options initopt = GIT_REPOSITORY_INIT_OPTIONS_INIT; git_repository *subrepo = NULL; error = git_buf_joinpath(&workdir, git_repository_workdir(parent_repo), path); if (error < 0) goto cleanup; initopt.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_NO_REINIT; initopt.origin_url = url; /* init submodule repository and add origin remote as needed */ /* New style: sub-repo goes in /modules// with a * gitlink in the sub-repo workdir directory to that repository * * Old style: sub-repo goes directly into repo//.git/ */ if (use_gitlink) { error = git_buf_join3( &repodir, '/', git_repository_path(parent_repo), "modules", path); if (error < 0) goto cleanup; initopt.workdir_path = workdir.ptr; initopt.flags |= GIT_REPOSITORY_INIT_NO_DOTGIT_DIR | GIT_REPOSITORY_INIT_RELATIVE_GITLINK; error = git_repository_init_ext(&subrepo, repodir.ptr, &initopt); } else error = git_repository_init_ext(&subrepo, workdir.ptr, &initopt); cleanup: git_buf_free(&workdir); git_buf_free(&repodir); *out = subrepo; return error; } int git_submodule_add_setup( git_submodule **out, git_repository *repo, const char *url, const char *path, int use_gitlink) { int error = 0; git_config_backend *mods = NULL; git_submodule *sm = NULL; git_buf name = GIT_BUF_INIT, real_url = GIT_BUF_INIT; git_repository *subrepo = NULL; assert(repo && url && path); /* see if there is already an entry for this submodule */ if (git_submodule_lookup(NULL, repo, path) < 0) giterr_clear(); else { giterr_set(GITERR_SUBMODULE, "Attempt to add submodule '%s' that already exists", path); return GIT_EEXISTS; } /* validate and normalize path */ if (git__prefixcmp(path, git_repository_workdir(repo)) == 0) path += strlen(git_repository_workdir(repo)); if (git_path_root(path) >= 0) { giterr_set(GITERR_SUBMODULE, "Submodule path must be a relative path"); error = -1; goto cleanup; } /* update .gitmodules */ if (!(mods = open_gitmodules(repo, GITMODULES_CREATE))) { giterr_set(GITERR_SUBMODULE, "Adding submodules to a bare repository is not supported"); return -1; } if ((error = git_buf_printf(&name, "submodule.%s.path", path)) < 0 || (error = git_config_file_set_string(mods, name.ptr, path)) < 0) goto cleanup; if ((error = submodule_config_key_trunc_puts(&name, "url")) < 0 || (error = git_config_file_set_string(mods, name.ptr, url)) < 0) goto cleanup; git_buf_clear(&name); /* init submodule repository and add origin remote as needed */ error = git_buf_joinpath(&name, git_repository_workdir(repo), path); if (error < 0) goto cleanup; /* if the repo does not already exist, then init a new repo and add it. * Otherwise, just add the existing repo. */ if (!(git_path_exists(name.ptr) && git_path_contains(&name, DOT_GIT))) { /* resolve the actual URL to use */ if ((error = git_submodule_resolve_url(&real_url, repo, url)) < 0) goto cleanup; if ((error = submodule_repo_init(&subrepo, repo, path, real_url.ptr, use_gitlink)) < 0) goto cleanup; } if ((error = git_submodule_lookup(&sm, repo, path)) < 0) goto cleanup; error = git_submodule_init(sm, false); cleanup: if (error && sm) { git_submodule_free(sm); sm = NULL; } if (out != NULL) *out = sm; git_config_file_free(mods); git_repository_free(subrepo); git_buf_free(&real_url); git_buf_free(&name); return error; } int git_submodule_repo_init( git_repository **out, const git_submodule *sm, int use_gitlink) { int error; git_repository *sub_repo = NULL; const char *configured_url; git_config *cfg = NULL; git_buf buf = GIT_BUF_INIT; assert(out && sm); /* get the configured remote url of the submodule */ if ((error = git_buf_printf(&buf, "submodule.%s.url", sm->name)) < 0 || (error = git_repository_config_snapshot(&cfg, sm->repo)) < 0 || (error = git_config_get_string(&configured_url, cfg, buf.ptr)) < 0 || (error = submodule_repo_init(&sub_repo, sm->repo, sm->path, configured_url, use_gitlink)) < 0) goto done; *out = sub_repo; done: git_config_free(cfg); git_buf_free(&buf); return error; } int git_submodule_add_finalize(git_submodule *sm) { int error; git_index *index; assert(sm); if ((error = git_repository_index__weakptr(&index, sm->repo)) < 0 || (error = git_index_add_bypath(index, GIT_MODULES_FILE)) < 0) return error; return git_submodule_add_to_index(sm, true); } int git_submodule_add_to_index(git_submodule *sm, int write_index) { int error; git_repository *sm_repo = NULL; git_index *index; git_buf path = GIT_BUF_INIT; git_commit *head; git_index_entry entry; struct stat st; assert(sm); /* force reload of wd OID by git_submodule_open */ sm->flags = sm->flags & ~GIT_SUBMODULE_STATUS__WD_OID_VALID; if ((error = git_repository_index__weakptr(&index, sm->repo)) < 0 || (error = git_buf_joinpath( &path, git_repository_workdir(sm->repo), sm->path)) < 0 || (error = git_submodule_open(&sm_repo, sm)) < 0) goto cleanup; /* read stat information for submodule working directory */ if (p_stat(path.ptr, &st) < 0) { giterr_set(GITERR_SUBMODULE, "Cannot add submodule without working directory"); error = -1; goto cleanup; } memset(&entry, 0, sizeof(entry)); entry.path = sm->path; git_index_entry__init_from_stat( &entry, &st, !(git_index_caps(index) & GIT_INDEXCAP_NO_FILEMODE)); /* calling git_submodule_open will have set sm->wd_oid if possible */ if ((sm->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID) == 0) { giterr_set(GITERR_SUBMODULE, "Cannot add submodule without HEAD to index"); error = -1; goto cleanup; } git_oid_cpy(&entry.id, &sm->wd_oid); if ((error = git_commit_lookup(&head, sm_repo, &sm->wd_oid)) < 0) goto cleanup; entry.ctime.seconds = git_commit_time(head); entry.ctime.nanoseconds = 0; entry.mtime.seconds = git_commit_time(head); entry.mtime.nanoseconds = 0; git_commit_free(head); /* add it */ error = git_index_add(index, &entry); /* write it, if requested */ if (!error && write_index) { error = git_index_write(index); if (!error) git_oid_cpy(&sm->index_oid, &sm->wd_oid); } cleanup: git_repository_free(sm_repo); git_buf_free(&path); return error; } const char *git_submodule_update_to_str(git_submodule_update_t update) { int i; for (i = 0; i < (int)ARRAY_SIZE(_sm_update_map); ++i) if (_sm_update_map[i].map_value == (int)update) return _sm_update_map[i].str_match; return NULL; } git_repository *git_submodule_owner(git_submodule *submodule) { assert(submodule); return submodule->repo; } const char *git_submodule_name(git_submodule *submodule) { assert(submodule); return submodule->name; } const char *git_submodule_path(git_submodule *submodule) { assert(submodule); return submodule->path; } const char *git_submodule_url(git_submodule *submodule) { assert(submodule); return submodule->url; } int git_submodule_resolve_url(git_buf *out, git_repository *repo, const char *url) { int error = 0; git_buf normalized = GIT_BUF_INIT; assert(out && repo && url); git_buf_sanitize(out); /* We do this in all platforms in case someone on Windows created the .gitmodules */ if (strchr(url, '\\')) { if ((error = git_path_normalize_slashes(&normalized, url)) < 0) return error; url = normalized.ptr; } if (git_path_is_relative(url)) { if (!(error = get_url_base(out, repo))) error = git_path_apply_relative(out, url); } else if (strchr(url, ':') != NULL || url[0] == '/') { error = git_buf_sets(out, url); } else { giterr_set(GITERR_SUBMODULE, "Invalid format for submodule URL"); error = -1; } git_buf_free(&normalized); return error; } static int write_var(git_repository *repo, const char *name, const char *var, const char *val) { git_buf key = GIT_BUF_INIT; git_config_backend *mods; int error; mods = open_gitmodules(repo, GITMODULES_CREATE); if (!mods) return -1; if ((error = git_buf_printf(&key, "submodule.%s.%s", name, var)) < 0) goto cleanup; if (val) error = git_config_file_set_string(mods, key.ptr, val); else error = git_config_file_delete(mods, key.ptr); git_buf_free(&key); cleanup: git_config_file_free(mods); return error; } static int write_mapped_var(git_repository *repo, const char *name, git_cvar_map *maps, size_t nmaps, const char *var, int ival) { git_cvar_t type; const char *val; if (git_config_lookup_map_enum(&type, &val, maps, nmaps, ival) < 0) { giterr_set(GITERR_SUBMODULE, "invalid value for %s", var); return -1; } if (type == GIT_CVAR_TRUE) val = "true"; return write_var(repo, name, var, val); } const char *git_submodule_branch(git_submodule *submodule) { assert(submodule); return submodule->branch; } int git_submodule_set_branch(git_repository *repo, const char *name, const char *branch) { assert(repo && name); return write_var(repo, name, "branch", branch); } int git_submodule_set_url(git_repository *repo, const char *name, const char *url) { assert(repo && name && url); return write_var(repo, name, "url", url); } const git_oid *git_submodule_index_id(git_submodule *submodule) { assert(submodule); if (submodule->flags & GIT_SUBMODULE_STATUS__INDEX_OID_VALID) return &submodule->index_oid; else return NULL; } const git_oid *git_submodule_head_id(git_submodule *submodule) { assert(submodule); if (submodule->flags & GIT_SUBMODULE_STATUS__HEAD_OID_VALID) return &submodule->head_oid; else return NULL; } const git_oid *git_submodule_wd_id(git_submodule *submodule) { assert(submodule); /* load unless we think we have a valid oid */ if (!(submodule->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID)) { git_repository *subrepo; /* calling submodule open grabs the HEAD OID if possible */ if (!git_submodule_open_bare(&subrepo, submodule)) git_repository_free(subrepo); else giterr_clear(); } if (submodule->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID) return &submodule->wd_oid; else return NULL; } git_submodule_ignore_t git_submodule_ignore(git_submodule *submodule) { assert(submodule); return (submodule->ignore < GIT_SUBMODULE_IGNORE_NONE) ? GIT_SUBMODULE_IGNORE_NONE : submodule->ignore; } int git_submodule_set_ignore(git_repository *repo, const char *name, git_submodule_ignore_t ignore) { assert(repo && name); return write_mapped_var(repo, name, _sm_ignore_map, ARRAY_SIZE(_sm_ignore_map), "ignore", ignore); } git_submodule_update_t git_submodule_update_strategy(git_submodule *submodule) { assert(submodule); return (submodule->update < GIT_SUBMODULE_UPDATE_CHECKOUT) ? GIT_SUBMODULE_UPDATE_CHECKOUT : submodule->update; } int git_submodule_set_update(git_repository *repo, const char *name, git_submodule_update_t update) { assert(repo && name); return write_mapped_var(repo, name, _sm_update_map, ARRAY_SIZE(_sm_update_map), "update", update); } git_submodule_recurse_t git_submodule_fetch_recurse_submodules( git_submodule *submodule) { assert(submodule); return submodule->fetch_recurse; } int git_submodule_set_fetch_recurse_submodules(git_repository *repo, const char *name, git_submodule_recurse_t recurse) { assert(repo && name); return write_mapped_var(repo, name, _sm_recurse_map, ARRAY_SIZE(_sm_recurse_map), "fetchRecurseSubmodules", recurse); } static int submodule_repo_create( git_repository **out, git_repository *parent_repo, const char *path) { int error = 0; git_buf workdir = GIT_BUF_INIT, repodir = GIT_BUF_INIT; git_repository_init_options initopt = GIT_REPOSITORY_INIT_OPTIONS_INIT; git_repository *subrepo = NULL; initopt.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_NO_REINIT | GIT_REPOSITORY_INIT_NO_DOTGIT_DIR | GIT_REPOSITORY_INIT_RELATIVE_GITLINK; /* Workdir: path to sub-repo working directory */ error = git_buf_joinpath(&workdir, git_repository_workdir(parent_repo), path); if (error < 0) goto cleanup; initopt.workdir_path = workdir.ptr; /** * Repodir: path to the sub-repo. sub-repo goes in: * /modules// with a gitlink in the * sub-repo workdir directory to that repository. */ error = git_buf_join3( &repodir, '/', git_repository_path(parent_repo), "modules", path); if (error < 0) goto cleanup; error = git_repository_init_ext(&subrepo, repodir.ptr, &initopt); cleanup: git_buf_free(&workdir); git_buf_free(&repodir); *out = subrepo; return error; } /** * Callback to override sub-repository creation when * cloning a sub-repository. */ static int git_submodule_update_repo_init_cb( git_repository **out, const char *path, int bare, void *payload) { git_submodule *sm; GIT_UNUSED(bare); sm = payload; return submodule_repo_create(out, sm->repo, path); } int git_submodule_update_init_options(git_submodule_update_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_submodule_update_options, GIT_SUBMODULE_UPDATE_OPTIONS_INIT); return 0; } int git_submodule_update(git_submodule *sm, int init, git_submodule_update_options *_update_options) { int error; unsigned int submodule_status; git_config *config = NULL; const char *submodule_url; git_repository *sub_repo = NULL; git_remote *remote = NULL; git_object *target_commit = NULL; git_buf buf = GIT_BUF_INIT; git_submodule_update_options update_options = GIT_SUBMODULE_UPDATE_OPTIONS_INIT; git_clone_options clone_options = GIT_CLONE_OPTIONS_INIT; assert(sm); if (_update_options) memcpy(&update_options, _update_options, sizeof(git_submodule_update_options)); GITERR_CHECK_VERSION(&update_options, GIT_SUBMODULE_UPDATE_OPTIONS_VERSION, "git_submodule_update_options"); /* Copy over the remote callbacks */ memcpy(&clone_options.fetch_opts, &update_options.fetch_opts, sizeof(git_fetch_options)); /* Get the status of the submodule to determine if it is already initialized */ if ((error = git_submodule_status(&submodule_status, sm->repo, sm->name, GIT_SUBMODULE_IGNORE_UNSPECIFIED)) < 0) goto done; /* * If submodule work dir is not already initialized, check to see * what we need to do (initialize, clone, return error...) */ if (submodule_status & GIT_SUBMODULE_STATUS_WD_UNINITIALIZED) { /* * Work dir is not initialized, check to see if the submodule * info has been copied into .git/config */ if ((error = git_repository_config_snapshot(&config, sm->repo)) < 0 || (error = git_buf_printf(&buf, "submodule.%s.url", git_submodule_name(sm))) < 0) goto done; if ((error = git_config_get_string(&submodule_url, config, git_buf_cstr(&buf))) < 0) { /* * If the error is not "not found" or if it is "not found" and we are not * initializing the submodule, then return error. */ if (error != GIT_ENOTFOUND) goto done; if (error == GIT_ENOTFOUND && !init) { giterr_set(GITERR_SUBMODULE, "Submodule is not initialized."); error = GIT_ERROR; goto done; } /* The submodule has not been initialized yet - initialize it now.*/ if ((error = git_submodule_init(sm, 0)) < 0) goto done; git_config_free(config); config = NULL; if ((error = git_repository_config_snapshot(&config, sm->repo)) < 0 || (error = git_config_get_string(&submodule_url, config, git_buf_cstr(&buf))) < 0) goto done; } /** submodule is initialized - now clone it **/ /* override repo creation */ clone_options.repository_cb = git_submodule_update_repo_init_cb; clone_options.repository_cb_payload = sm; /* * Do not perform checkout as part of clone, instead we * will checkout the specific commit manually. */ clone_options.checkout_opts.checkout_strategy = GIT_CHECKOUT_NONE; update_options.checkout_opts.checkout_strategy = update_options.clone_checkout_strategy; if ((error = git_clone(&sub_repo, submodule_url, sm->path, &clone_options)) < 0 || (error = git_repository_set_head_detached(sub_repo, git_submodule_index_id(sm))) < 0 || (error = git_checkout_head(sub_repo, &update_options.checkout_opts)) != 0) goto done; } else { /** * Work dir is initialized - look up the commit in the parent repository's index, * update the workdir contents of the subrepository, and set the subrepository's * head to the new commit. */ if ((error = git_submodule_open(&sub_repo, sm)) < 0 || (error = git_object_lookup(&target_commit, sub_repo, git_submodule_index_id(sm), GIT_OBJ_COMMIT)) < 0 || (error = git_checkout_tree(sub_repo, target_commit, &update_options.checkout_opts)) != 0 || (error = git_repository_set_head_detached(sub_repo, git_submodule_index_id(sm))) < 0) goto done; /* Invalidate the wd flags as the workdir has been updated. */ sm->flags = sm->flags & ~(GIT_SUBMODULE_STATUS_IN_WD | GIT_SUBMODULE_STATUS__WD_OID_VALID | GIT_SUBMODULE_STATUS__WD_SCANNED); } done: git_buf_free(&buf); git_config_free(config); git_object_free(target_commit); git_remote_free(remote); git_repository_free(sub_repo); return error; } int git_submodule_init(git_submodule *sm, int overwrite) { int error; const char *val; git_buf key = GIT_BUF_INIT, effective_submodule_url = GIT_BUF_INIT; git_config *cfg = NULL; if (!sm->url) { giterr_set(GITERR_SUBMODULE, "No URL configured for submodule '%s'", sm->name); return -1; } if ((error = git_repository_config(&cfg, sm->repo)) < 0) return error; /* write "submodule.NAME.url" */ if ((error = git_submodule_resolve_url(&effective_submodule_url, sm->repo, sm->url)) < 0 || (error = git_buf_printf(&key, "submodule.%s.url", sm->name)) < 0 || (error = git_config__update_entry( cfg, key.ptr, effective_submodule_url.ptr, overwrite != 0, false)) < 0) goto cleanup; /* write "submodule.NAME.update" if not default */ val = (sm->update == GIT_SUBMODULE_UPDATE_CHECKOUT) ? NULL : git_submodule_update_to_str(sm->update); if ((error = git_buf_printf(&key, "submodule.%s.update", sm->name)) < 0 || (error = git_config__update_entry( cfg, key.ptr, val, overwrite != 0, false)) < 0) goto cleanup; /* success */ cleanup: git_config_free(cfg); git_buf_free(&key); git_buf_free(&effective_submodule_url); return error; } int git_submodule_sync(git_submodule *sm) { int error = 0; git_config *cfg = NULL; git_buf key = GIT_BUF_INIT; git_repository *smrepo = NULL; if (!sm->url) { giterr_set(GITERR_SUBMODULE, "No URL configured for submodule '%s'", sm->name); return -1; } /* copy URL over to config only if it already exists */ if (!(error = git_repository_config__weakptr(&cfg, sm->repo)) && !(error = git_buf_printf(&key, "submodule.%s.url", sm->name))) error = git_config__update_entry(cfg, key.ptr, sm->url, true, true); /* if submodule exists in the working directory, update remote url */ if (!error && (sm->flags & GIT_SUBMODULE_STATUS_IN_WD) != 0 && !(error = git_submodule_open(&smrepo, sm))) { git_buf remote_name = GIT_BUF_INIT; if ((error = git_repository_config__weakptr(&cfg, smrepo)) < 0) /* return error from reading submodule config */; else if ((error = lookup_head_remote_key(&remote_name, smrepo)) < 0) { giterr_clear(); error = git_buf_sets(&key, "remote.origin.url"); } else { error = git_buf_join3( &key, '.', "remote", remote_name.ptr, "url"); git_buf_free(&remote_name); } if (!error) error = git_config__update_entry(cfg, key.ptr, sm->url, true, false); git_repository_free(smrepo); } git_buf_free(&key); return error; } static int git_submodule__open( git_repository **subrepo, git_submodule *sm, bool bare) { int error; git_buf path = GIT_BUF_INIT; unsigned int flags = GIT_REPOSITORY_OPEN_NO_SEARCH; const char *wd; assert(sm && subrepo); if (git_repository__ensure_not_bare( sm->repo, "open submodule repository") < 0) return GIT_EBAREREPO; wd = git_repository_workdir(sm->repo); if (git_buf_joinpath(&path, wd, sm->path) < 0 || git_buf_joinpath(&path, path.ptr, DOT_GIT) < 0) return -1; sm->flags = sm->flags & ~(GIT_SUBMODULE_STATUS_IN_WD | GIT_SUBMODULE_STATUS__WD_OID_VALID | GIT_SUBMODULE_STATUS__WD_SCANNED); if (bare) flags |= GIT_REPOSITORY_OPEN_BARE; error = git_repository_open_ext(subrepo, path.ptr, flags, wd); /* if we opened the submodule successfully, grab HEAD OID, etc. */ if (!error) { sm->flags |= GIT_SUBMODULE_STATUS_IN_WD | GIT_SUBMODULE_STATUS__WD_SCANNED; if (!git_reference_name_to_id(&sm->wd_oid, *subrepo, GIT_HEAD_FILE)) sm->flags |= GIT_SUBMODULE_STATUS__WD_OID_VALID; else giterr_clear(); } else if (git_path_exists(path.ptr)) { sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED | GIT_SUBMODULE_STATUS_IN_WD; } else { git_buf_rtruncate_at_char(&path, '/'); /* remove "/.git" */ if (git_path_isdir(path.ptr)) sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED; } git_buf_free(&path); return error; } int git_submodule_open_bare(git_repository **subrepo, git_submodule *sm) { return git_submodule__open(subrepo, sm, true); } int git_submodule_open(git_repository **subrepo, git_submodule *sm) { return git_submodule__open(subrepo, sm, false); } static void submodule_update_from_index_entry( git_submodule *sm, const git_index_entry *ie) { bool already_found = (sm->flags & GIT_SUBMODULE_STATUS_IN_INDEX) != 0; if (!S_ISGITLINK(ie->mode)) { if (!already_found) sm->flags |= GIT_SUBMODULE_STATUS__INDEX_NOT_SUBMODULE; } else { if (already_found) sm->flags |= GIT_SUBMODULE_STATUS__INDEX_MULTIPLE_ENTRIES; else git_oid_cpy(&sm->index_oid, &ie->id); sm->flags |= GIT_SUBMODULE_STATUS_IN_INDEX | GIT_SUBMODULE_STATUS__INDEX_OID_VALID; } } static int submodule_update_index(git_submodule *sm) { git_index *index; const git_index_entry *ie; if (git_repository_index__weakptr(&index, sm->repo) < 0) return -1; sm->flags = sm->flags & ~(GIT_SUBMODULE_STATUS_IN_INDEX | GIT_SUBMODULE_STATUS__INDEX_OID_VALID); if (!(ie = git_index_get_bypath(index, sm->path, 0))) return 0; submodule_update_from_index_entry(sm, ie); return 0; } static void submodule_update_from_head_data( git_submodule *sm, mode_t mode, const git_oid *id) { if (!S_ISGITLINK(mode)) sm->flags |= GIT_SUBMODULE_STATUS__HEAD_NOT_SUBMODULE; else { git_oid_cpy(&sm->head_oid, id); sm->flags |= GIT_SUBMODULE_STATUS_IN_HEAD | GIT_SUBMODULE_STATUS__HEAD_OID_VALID; } } static int submodule_update_head(git_submodule *submodule) { git_tree *head = NULL; git_tree_entry *te = NULL; submodule->flags = submodule->flags & ~(GIT_SUBMODULE_STATUS_IN_HEAD | GIT_SUBMODULE_STATUS__HEAD_OID_VALID); /* if we can't look up file in current head, then done */ if (git_repository_head_tree(&head, submodule->repo) < 0 || git_tree_entry_bypath(&te, head, submodule->path) < 0) giterr_clear(); else submodule_update_from_head_data(submodule, te->attr, &te->oid); git_tree_entry_free(te); git_tree_free(head); return 0; } int git_submodule_reload(git_submodule *sm, int force) { int error = 0; git_config *mods; GIT_UNUSED(force); assert(sm); /* refresh index data */ if ((error = submodule_update_index(sm)) < 0) return error; /* refresh HEAD tree data */ if ((error = submodule_update_head(sm)) < 0) return error; /* done if bare */ if (git_repository_is_bare(sm->repo)) return error; /* refresh config data */ mods = gitmodules_snapshot(sm->repo); if (mods != NULL) { error = submodule_read_config(sm, mods); git_config_free(mods); if (error < 0) { return error; } } /* refresh wd data */ sm->flags &= ~(GIT_SUBMODULE_STATUS_IN_WD | GIT_SUBMODULE_STATUS__WD_OID_VALID | GIT_SUBMODULE_STATUS__WD_FLAGS); return submodule_load_from_wd_lite(sm); } static void submodule_copy_oid_maybe( git_oid *tgt, const git_oid *src, bool valid) { if (tgt) { if (valid) memcpy(tgt, src, sizeof(*tgt)); else memset(tgt, 0, sizeof(*tgt)); } } int git_submodule__status( unsigned int *out_status, git_oid *out_head_id, git_oid *out_index_id, git_oid *out_wd_id, git_submodule *sm, git_submodule_ignore_t ign) { unsigned int status; git_repository *smrepo = NULL; if (ign == GIT_SUBMODULE_IGNORE_UNSPECIFIED) ign = sm->ignore; /* only return location info if ignore == all */ if (ign == GIT_SUBMODULE_IGNORE_ALL) { *out_status = (sm->flags & GIT_SUBMODULE_STATUS__IN_FLAGS); return 0; } /* refresh the index OID */ if (submodule_update_index(sm) < 0) return -1; /* refresh the HEAD OID */ if (submodule_update_head(sm) < 0) return -1; /* for ignore == dirty, don't scan the working directory */ if (ign == GIT_SUBMODULE_IGNORE_DIRTY) { /* git_submodule_open_bare will load WD OID data */ if (git_submodule_open_bare(&smrepo, sm) < 0) giterr_clear(); else git_repository_free(smrepo); smrepo = NULL; } else if (git_submodule_open(&smrepo, sm) < 0) { giterr_clear(); smrepo = NULL; } status = GIT_SUBMODULE_STATUS__CLEAR_INTERNAL(sm->flags); submodule_get_index_status(&status, sm); submodule_get_wd_status(&status, sm, smrepo, ign); git_repository_free(smrepo); *out_status = status; submodule_copy_oid_maybe(out_head_id, &sm->head_oid, (sm->flags & GIT_SUBMODULE_STATUS__HEAD_OID_VALID) != 0); submodule_copy_oid_maybe(out_index_id, &sm->index_oid, (sm->flags & GIT_SUBMODULE_STATUS__INDEX_OID_VALID) != 0); submodule_copy_oid_maybe(out_wd_id, &sm->wd_oid, (sm->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID) != 0); return 0; } int git_submodule_status(unsigned int *status, git_repository *repo, const char *name, git_submodule_ignore_t ignore) { git_submodule *sm; int error; assert(status && repo && name); if ((error = git_submodule_lookup(&sm, repo, name)) < 0) return error; error = git_submodule__status(status, NULL, NULL, NULL, sm, ignore); git_submodule_free(sm); return error; } int git_submodule_location(unsigned int *location, git_submodule *sm) { assert(location && sm); return git_submodule__status( location, NULL, NULL, NULL, sm, GIT_SUBMODULE_IGNORE_ALL); } /* * INTERNAL FUNCTIONS */ static int submodule_alloc( git_submodule **out, git_repository *repo, const char *name) { size_t namelen; git_submodule *sm; if (!name || !(namelen = strlen(name))) { giterr_set(GITERR_SUBMODULE, "Invalid submodule name"); return -1; } sm = git__calloc(1, sizeof(git_submodule)); GITERR_CHECK_ALLOC(sm); sm->name = sm->path = git__strdup(name); if (!sm->name) { git__free(sm); return -1; } GIT_REFCOUNT_INC(sm); sm->ignore = sm->ignore_default = GIT_SUBMODULE_IGNORE_NONE; sm->update = sm->update_default = GIT_SUBMODULE_UPDATE_CHECKOUT; sm->fetch_recurse = sm->fetch_recurse_default = GIT_SUBMODULE_RECURSE_NO; sm->repo = repo; sm->branch = NULL; *out = sm; return 0; } static void submodule_release(git_submodule *sm) { if (!sm) return; if (sm->repo) { sm->repo = NULL; } if (sm->path != sm->name) git__free(sm->path); git__free(sm->name); git__free(sm->url); git__free(sm->branch); git__memzero(sm, sizeof(*sm)); git__free(sm); } void git_submodule_free(git_submodule *sm) { if (!sm) return; GIT_REFCOUNT_DEC(sm, submodule_release); } static int submodule_config_error(const char *property, const char *value) { giterr_set(GITERR_INVALID, "Invalid value for submodule '%s' property: '%s'", property, value); return -1; } int git_submodule_parse_ignore(git_submodule_ignore_t *out, const char *value) { int val; if (git_config_lookup_map_value( &val, _sm_ignore_map, ARRAY_SIZE(_sm_ignore_map), value) < 0) { *out = GIT_SUBMODULE_IGNORE_NONE; return submodule_config_error("ignore", value); } *out = (git_submodule_ignore_t)val; return 0; } int git_submodule_parse_update(git_submodule_update_t *out, const char *value) { int val; if (git_config_lookup_map_value( &val, _sm_update_map, ARRAY_SIZE(_sm_update_map), value) < 0) { *out = GIT_SUBMODULE_UPDATE_CHECKOUT; return submodule_config_error("update", value); } *out = (git_submodule_update_t)val; return 0; } int git_submodule_parse_recurse(git_submodule_recurse_t *out, const char *value) { int val; if (git_config_lookup_map_value( &val, _sm_recurse_map, ARRAY_SIZE(_sm_recurse_map), value) < 0) { *out = GIT_SUBMODULE_RECURSE_YES; return submodule_config_error("recurse", value); } *out = (git_submodule_recurse_t)val; return 0; } static int get_value(const char **out, git_config *cfg, git_buf *buf, const char *name, const char *field) { int error; git_buf_clear(buf); if ((error = git_buf_printf(buf, "submodule.%s.%s", name, field)) < 0 || (error = git_config_get_string(out, cfg, buf->ptr)) < 0) return error; return error; } static int submodule_read_config(git_submodule *sm, git_config *cfg) { git_buf key = GIT_BUF_INIT; const char *value; int error, in_config = 0; /* * TODO: Look up path in index and if it is present but not a GITLINK * then this should be deleted (at least to match git's behavior) */ if ((error = get_value(&value, cfg, &key, sm->name, "path")) == 0) { in_config = 1; /* * TODO: if case insensitive filesystem, then the following strcmp * should be strcasecmp */ if (strcmp(sm->name, value) != 0) { if (sm->path != sm->name) git__free(sm->path); sm->path = git__strdup(value); GITERR_CHECK_ALLOC(sm->path); } } else if (error != GIT_ENOTFOUND) { goto cleanup; } if ((error = get_value(&value, cfg, &key, sm->name, "url")) == 0) { in_config = 1; sm->url = git__strdup(value); GITERR_CHECK_ALLOC(sm->url); } else if (error != GIT_ENOTFOUND) { goto cleanup; } if ((error = get_value(&value, cfg, &key, sm->name, "branch")) == 0) { in_config = 1; sm->branch = git__strdup(value); GITERR_CHECK_ALLOC(sm->branch); } else if (error != GIT_ENOTFOUND) { goto cleanup; } if ((error = get_value(&value, cfg, &key, sm->name, "update")) == 0) { in_config = 1; if ((error = git_submodule_parse_update(&sm->update, value)) < 0) goto cleanup; sm->update_default = sm->update; } else if (error != GIT_ENOTFOUND) { goto cleanup; } if ((error = get_value(&value, cfg, &key, sm->name, "fetchRecurseSubmodules")) == 0) { in_config = 1; if ((error = git_submodule_parse_recurse(&sm->fetch_recurse, value)) < 0) goto cleanup; sm->fetch_recurse_default = sm->fetch_recurse; } else if (error != GIT_ENOTFOUND) { goto cleanup; } if ((error = get_value(&value, cfg, &key, sm->name, "ignore")) == 0) { in_config = 1; if ((error = git_submodule_parse_ignore(&sm->ignore, value)) < 0) goto cleanup; sm->ignore_default = sm->ignore; } else if (error != GIT_ENOTFOUND) { goto cleanup; } if (in_config) sm->flags |= GIT_SUBMODULE_STATUS_IN_CONFIG; error = 0; cleanup: git_buf_free(&key); return error; } static int submodule_load_each(const git_config_entry *entry, void *payload) { lfc_data *data = payload; const char *namestart, *property; git_strmap_iter pos; git_strmap *map = data->map; git_buf name = GIT_BUF_INIT; git_submodule *sm; int error; if (git__prefixcmp(entry->name, "submodule.") != 0) return 0; namestart = entry->name + strlen("submodule."); property = strrchr(namestart, '.'); if (!property || (property == namestart)) return 0; property++; if ((error = git_buf_set(&name, namestart, property - namestart -1)) < 0) return error; /* * Now that we have the submodule's name, we can use that to * figure out whether it's in the map. If it's not, we create * a new submodule, load the config and insert it. If it's * already inserted, we've already loaded it, so we skip. */ pos = git_strmap_lookup_index(map, name.ptr); if (git_strmap_valid_index(map, pos)) { error = 0; goto done; } if ((error = submodule_alloc(&sm, data->repo, name.ptr)) < 0) goto done; if ((error = submodule_read_config(sm, data->mods)) < 0) { git_submodule_free(sm); goto done; } git_strmap_insert(map, sm->name, sm, error); assert(error != 0); if (error < 0) goto done; error = 0; done: git_buf_free(&name); return error; } static int submodule_load_from_wd_lite(git_submodule *sm) { git_buf path = GIT_BUF_INIT; if (git_buf_joinpath(&path, git_repository_workdir(sm->repo), sm->path) < 0) return -1; if (git_path_isdir(path.ptr)) sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED; if (git_path_contains(&path, DOT_GIT)) sm->flags |= GIT_SUBMODULE_STATUS_IN_WD; git_buf_free(&path); return 0; } /** * Returns a snapshot of $WORK_TREE/.gitmodules. * * We ignore any errors and just pretend the file isn't there. */ static git_config *gitmodules_snapshot(git_repository *repo) { const char *workdir = git_repository_workdir(repo); git_config *mods = NULL, *snap = NULL; git_buf path = GIT_BUF_INIT; if (workdir != NULL) { if (git_buf_joinpath(&path, workdir, GIT_MODULES_FILE) != 0) return NULL; if (git_config_open_ondisk(&mods, path.ptr) < 0) mods = NULL; } git_buf_free(&path); if (mods) { git_config_snapshot(&snap, mods); git_config_free(mods); } return snap; } static git_config_backend *open_gitmodules( git_repository *repo, int okay_to_create) { const char *workdir = git_repository_workdir(repo); git_buf path = GIT_BUF_INIT; git_config_backend *mods = NULL; if (workdir != NULL) { if (git_buf_joinpath(&path, workdir, GIT_MODULES_FILE) != 0) return NULL; if (okay_to_create || git_path_isfile(path.ptr)) { /* git_config_file__ondisk should only fail if OOM */ if (git_config_file__ondisk(&mods, path.ptr) < 0) mods = NULL; /* open should only fail here if the file is malformed */ else if (git_config_file_open(mods, GIT_CONFIG_LEVEL_LOCAL) < 0) { git_config_file_free(mods); mods = NULL; } } } git_buf_free(&path); return mods; } /* Lookup name of remote of the local tracking branch HEAD points to */ static int lookup_head_remote_key(git_buf *remote_name, git_repository *repo) { int error; git_reference *head = NULL; git_buf upstream_name = GIT_BUF_INIT; /* lookup and dereference HEAD */ if ((error = git_repository_head(&head, repo)) < 0) return error; /** * If head does not refer to a branch, then return * GIT_ENOTFOUND to indicate that we could not find * a remote key for the local tracking branch HEAD points to. **/ if (!git_reference_is_branch(head)) { giterr_set(GITERR_INVALID, "HEAD does not refer to a branch."); error = GIT_ENOTFOUND; goto done; } /* lookup remote tracking branch of HEAD */ if ((error = git_branch_upstream_name( &upstream_name, repo, git_reference_name(head))) < 0) goto done; /* lookup remote of remote tracking branch */ if ((error = git_branch_remote_name(remote_name, repo, upstream_name.ptr)) < 0) goto done; done: git_buf_free(&upstream_name); git_reference_free(head); return error; } /* Lookup the remote of the local tracking branch HEAD points to */ static int lookup_head_remote(git_remote **remote, git_repository *repo) { int error; git_buf remote_name = GIT_BUF_INIT; /* lookup remote of remote tracking branch name */ if (!(error = lookup_head_remote_key(&remote_name, repo))) error = git_remote_lookup(remote, repo, remote_name.ptr); git_buf_free(&remote_name); return error; } /* Lookup remote, either from HEAD or fall back on origin */ static int lookup_default_remote(git_remote **remote, git_repository *repo) { int error = lookup_head_remote(remote, repo); /* if that failed, use 'origin' instead */ if (error == GIT_ENOTFOUND) error = git_remote_lookup(remote, repo, "origin"); if (error == GIT_ENOTFOUND) giterr_set( GITERR_SUBMODULE, "Cannot get default remote for submodule - no local tracking " "branch for HEAD and origin does not exist"); return error; } static int get_url_base(git_buf *url, git_repository *repo) { int error; git_remote *remote = NULL; if (!(error = lookup_default_remote(&remote, repo))) { error = git_buf_sets(url, git_remote_url(remote)); git_remote_free(remote); } else if (error == GIT_ENOTFOUND) { /* if repository does not have a default remote, use workdir instead */ giterr_clear(); error = git_buf_sets(url, git_repository_workdir(repo)); } return error; } static void submodule_get_index_status(unsigned int *status, git_submodule *sm) { const git_oid *head_oid = git_submodule_head_id(sm); const git_oid *index_oid = git_submodule_index_id(sm); *status = *status & ~GIT_SUBMODULE_STATUS__INDEX_FLAGS; if (!head_oid) { if (index_oid) *status |= GIT_SUBMODULE_STATUS_INDEX_ADDED; } else if (!index_oid) *status |= GIT_SUBMODULE_STATUS_INDEX_DELETED; else if (!git_oid_equal(head_oid, index_oid)) *status |= GIT_SUBMODULE_STATUS_INDEX_MODIFIED; } static void submodule_get_wd_status( unsigned int *status, git_submodule *sm, git_repository *sm_repo, git_submodule_ignore_t ign) { const git_oid *index_oid = git_submodule_index_id(sm); const git_oid *wd_oid = (sm->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID) ? &sm->wd_oid : NULL; git_tree *sm_head = NULL; git_index *index = NULL; git_diff_options opt = GIT_DIFF_OPTIONS_INIT; git_diff *diff; *status = *status & ~GIT_SUBMODULE_STATUS__WD_FLAGS; if (!index_oid) { if (wd_oid) *status |= GIT_SUBMODULE_STATUS_WD_ADDED; } else if (!wd_oid) { if ((sm->flags & GIT_SUBMODULE_STATUS__WD_SCANNED) != 0 && (sm->flags & GIT_SUBMODULE_STATUS_IN_WD) == 0) *status |= GIT_SUBMODULE_STATUS_WD_UNINITIALIZED; else *status |= GIT_SUBMODULE_STATUS_WD_DELETED; } else if (!git_oid_equal(index_oid, wd_oid)) *status |= GIT_SUBMODULE_STATUS_WD_MODIFIED; /* if we have no repo, then we're done */ if (!sm_repo) return; /* the diffs below could be optimized with an early termination * option to the git_diff functions, but for now this is sufficient * (and certainly no worse that what core git does). */ if (ign == GIT_SUBMODULE_IGNORE_NONE) opt.flags |= GIT_DIFF_INCLUDE_UNTRACKED; (void)git_repository_index__weakptr(&index, sm_repo); /* if we don't have an unborn head, check diff with index */ if (git_repository_head_tree(&sm_head, sm_repo) < 0) giterr_clear(); else { /* perform head to index diff on submodule */ if (git_diff_tree_to_index(&diff, sm_repo, sm_head, index, &opt) < 0) giterr_clear(); else { if (git_diff_num_deltas(diff) > 0) *status |= GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED; git_diff_free(diff); diff = NULL; } git_tree_free(sm_head); } /* perform index-to-workdir diff on submodule */ if (git_diff_index_to_workdir(&diff, sm_repo, index, &opt) < 0) giterr_clear(); else { size_t untracked = git_diff_num_deltas_of_type(diff, GIT_DELTA_UNTRACKED); if (untracked > 0) *status |= GIT_SUBMODULE_STATUS_WD_UNTRACKED; if (git_diff_num_deltas(diff) != untracked) *status |= GIT_SUBMODULE_STATUS_WD_WD_MODIFIED; git_diff_free(diff); diff = NULL; } } deps/libgit2-sys-0.3.8/libgit2/src/trace.h0000664000175000017500000000236512426525445015160 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_trace_h__ #define INCLUDE_trace_h__ #include #include "buffer.h" #ifdef GIT_TRACE struct git_trace_data { git_trace_level_t level; git_trace_callback callback; }; extern struct git_trace_data git_trace__data; GIT_INLINE(void) git_trace__write_fmt( git_trace_level_t level, const char *fmt, ...) { git_trace_callback callback = git_trace__data.callback; git_buf message = GIT_BUF_INIT; va_list ap; va_start(ap, fmt); git_buf_vprintf(&message, fmt, ap); va_end(ap); callback(level, git_buf_cstr(&message)); git_buf_free(&message); } #define git_trace_level() (git_trace__data.level) #define git_trace(l, ...) { \ if (git_trace__data.level >= l && \ git_trace__data.callback != NULL) { \ git_trace__write_fmt(l, __VA_ARGS__); \ } \ } #else GIT_INLINE(void) git_trace__null( git_trace_level_t level, const char *fmt, ...) { GIT_UNUSED(level); GIT_UNUSED(fmt); } #define git_trace_level() ((void)0) #define git_trace git_trace__null #endif #endif deps/libgit2-sys-0.3.8/libgit2/src/signature.c0000664000175000017500000001534312510265101016036 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "signature.h" #include "repository.h" #include "git2/common.h" #include "posix.h" void git_signature_free(git_signature *sig) { if (sig == NULL) return; git__free(sig->name); sig->name = NULL; git__free(sig->email); sig->email = NULL; git__free(sig); } static int signature_error(const char *msg) { giterr_set(GITERR_INVALID, "Failed to parse signature - %s", msg); return -1; } static bool contains_angle_brackets(const char *input) { return strchr(input, '<') != NULL || strchr(input, '>') != NULL; } static char *extract_trimmed(const char *ptr, size_t len) { while (len && git__isspace(ptr[0])) { ptr++; len--; } while (len && git__isspace(ptr[len - 1])) { len--; } return git__substrdup(ptr, len); } int git_signature_new(git_signature **sig_out, const char *name, const char *email, git_time_t time, int offset) { git_signature *p = NULL; assert(name && email); *sig_out = NULL; if (contains_angle_brackets(name) || contains_angle_brackets(email)) { return signature_error( "Neither `name` nor `email` should contain angle brackets chars."); } p = git__calloc(1, sizeof(git_signature)); GITERR_CHECK_ALLOC(p); p->name = extract_trimmed(name, strlen(name)); p->email = extract_trimmed(email, strlen(email)); if (p->name == NULL || p->email == NULL) return -1; /* oom */ if (p->name[0] == '\0' || p->email[0] == '\0') { git_signature_free(p); return signature_error("Signature cannot have an empty name or email"); } p->when.time = time; p->when.offset = offset; *sig_out = p; return 0; } int git_signature_dup(git_signature **dest, const git_signature *source) { git_signature *signature; if (source == NULL) return 0; signature = git__calloc(1, sizeof(git_signature)); GITERR_CHECK_ALLOC(signature); signature->name = git__strdup(source->name); GITERR_CHECK_ALLOC(signature->name); signature->email = git__strdup(source->email); GITERR_CHECK_ALLOC(signature->email); signature->when.time = source->when.time; signature->when.offset = source->when.offset; *dest = signature; return 0; } int git_signature__pdup(git_signature **dest, const git_signature *source, git_pool *pool) { git_signature *signature; if (source == NULL) return 0; signature = git_pool_mallocz(pool, sizeof(git_signature)); GITERR_CHECK_ALLOC(signature); signature->name = git_pool_strdup(pool, source->name); GITERR_CHECK_ALLOC(signature->name); signature->email = git_pool_strdup(pool, source->email); GITERR_CHECK_ALLOC(signature->email); signature->when.time = source->when.time; signature->when.offset = source->when.offset; *dest = signature; return 0; } int git_signature_now(git_signature **sig_out, const char *name, const char *email) { time_t now; time_t offset; struct tm *utc_tm; git_signature *sig; struct tm _utc; *sig_out = NULL; /* * Get the current time as seconds since the epoch and * transform that into a tm struct containing the time at * UTC. Give that to mktime which considers it a local time * (tm_isdst = -1 asks it to take DST into account) and gives * us that time as seconds since the epoch. The difference * between its return value and 'now' is our offset to UTC. */ time(&now); utc_tm = p_gmtime_r(&now, &_utc); utc_tm->tm_isdst = -1; offset = (time_t)difftime(now, mktime(utc_tm)); offset /= 60; if (git_signature_new(&sig, name, email, now, (int)offset) < 0) return -1; *sig_out = sig; return 0; } int git_signature_default(git_signature **out, git_repository *repo) { int error; git_config *cfg; const char *user_name, *user_email; if ((error = git_repository_config_snapshot(&cfg, repo)) < 0) return error; if (!(error = git_config_get_string(&user_name, cfg, "user.name")) && !(error = git_config_get_string(&user_email, cfg, "user.email"))) error = git_signature_now(out, user_name, user_email); git_config_free(cfg); return error; } int git_signature__parse(git_signature *sig, const char **buffer_out, const char *buffer_end, const char *header, char ender) { const char *buffer = *buffer_out; const char *email_start, *email_end; memset(sig, 0, sizeof(git_signature)); if ((buffer_end = memchr(buffer, ender, buffer_end - buffer)) == NULL) return signature_error("no newline given"); if (header) { const size_t header_len = strlen(header); if (buffer + header_len >= buffer_end || memcmp(buffer, header, header_len) != 0) return signature_error("expected prefix doesn't match actual"); buffer += header_len; } email_start = git__memrchr(buffer, '<', buffer_end - buffer); email_end = git__memrchr(buffer, '>', buffer_end - buffer); if (!email_start || !email_end || email_end <= email_start) return signature_error("malformed e-mail"); email_start += 1; sig->name = extract_trimmed(buffer, email_start - buffer - 1); sig->email = extract_trimmed(email_start, email_end - email_start); /* Do we even have a time at the end of the signature? */ if (email_end + 2 < buffer_end) { const char *time_start = email_end + 2; const char *time_end; if (git__strtol64(&sig->when.time, time_start, &time_end, 10) < 0) return signature_error("invalid Unix timestamp"); /* do we have a timezone? */ if (time_end + 1 < buffer_end) { int offset, hours, mins; const char *tz_start, *tz_end; tz_start = time_end + 1; if ((tz_start[0] != '-' && tz_start[0] != '+') || git__strtol32(&offset, tz_start + 1, &tz_end, 10) < 0) { //malformed timezone, just assume it's zero offset = 0; } hours = offset / 100; mins = offset % 100; /* * only store timezone if it's not overflowing; * see http://www.worldtimezone.com/faq.html */ if (hours < 14 && mins < 59) { sig->when.offset = (hours * 60) + mins; if (tz_start[0] == '-') sig->when.offset = -sig->when.offset; } } } *buffer_out = buffer_end + 1; return 0; } void git_signature__writebuf(git_buf *buf, const char *header, const git_signature *sig) { int offset, hours, mins; char sign; assert(buf && sig); offset = sig->when.offset; sign = (sig->when.offset < 0) ? '-' : '+'; if (offset < 0) offset = -offset; hours = offset / 60; mins = offset % 60; git_buf_printf(buf, "%s%s <%s> %u %c%02d%02d\n", header ? header : "", sig->name, sig->email, (unsigned)sig->when.time, sign, hours, mins); } bool git_signature__equal(const git_signature *one, const git_signature *two) { assert(one && two); return git__strcmp(one->name, two->name) == 0 && git__strcmp(one->email, two->email) == 0 && one->when.time == two->when.time && one->when.offset == two->when.offset; } deps/libgit2-sys-0.3.8/libgit2/src/hash.c0000664000175000017500000000160612426525445014775 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "hash.h" int git_hash_buf(git_oid *out, const void *data, size_t len) { git_hash_ctx ctx; int error = 0; if (git_hash_ctx_init(&ctx) < 0) return -1; if ((error = git_hash_update(&ctx, data, len)) >= 0) error = git_hash_final(out, &ctx); git_hash_ctx_cleanup(&ctx); return error; } int git_hash_vec(git_oid *out, git_buf_vec *vec, size_t n) { git_hash_ctx ctx; size_t i; int error = 0; if (git_hash_ctx_init(&ctx) < 0) return -1; for (i = 0; i < n; i++) { if ((error = git_hash_update(&ctx, vec[i].data, vec[i].len)) < 0) goto done; } error = git_hash_final(out, &ctx); done: git_hash_ctx_cleanup(&ctx); return error; } deps/libgit2-sys-0.3.8/libgit2/src/rebase.c0000664000175000017500000007215312572105236015312 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "buffer.h" #include "repository.h" #include "posix.h" #include "filebuf.h" #include "merge.h" #include "array.h" #include "config.h" #include "annotated_commit.h" #include "index.h" #include #include #include #include #include #include #include #define REBASE_APPLY_DIR "rebase-apply" #define REBASE_MERGE_DIR "rebase-merge" #define HEAD_NAME_FILE "head-name" #define ORIG_HEAD_FILE "orig-head" #define HEAD_FILE "head" #define ONTO_FILE "onto" #define ONTO_NAME_FILE "onto_name" #define QUIET_FILE "quiet" #define MSGNUM_FILE "msgnum" #define END_FILE "end" #define CMT_FILE_FMT "cmt.%" PRIuZ #define CURRENT_FILE "current" #define REWRITTEN_FILE "rewritten" #define ORIG_DETACHED_HEAD "detached HEAD" #define NOTES_DEFAULT_REF NULL #define REBASE_DIR_MODE 0777 #define REBASE_FILE_MODE 0666 typedef enum { GIT_REBASE_TYPE_NONE = 0, GIT_REBASE_TYPE_APPLY = 1, GIT_REBASE_TYPE_MERGE = 2, GIT_REBASE_TYPE_INTERACTIVE = 3, } git_rebase_type_t; struct git_rebase { git_repository *repo; git_rebase_options options; git_rebase_type_t type; char *state_path; int head_detached : 1, quiet : 1, started : 1; char *orig_head_name; git_oid orig_head_id; git_oid onto_id; char *onto_name; git_array_t(git_rebase_operation) operations; size_t current; }; #define GIT_REBASE_STATE_INIT {0} static int rebase_state_type( git_rebase_type_t *type_out, char **path_out, git_repository *repo) { git_buf path = GIT_BUF_INIT; git_rebase_type_t type = GIT_REBASE_TYPE_NONE; if (git_buf_joinpath(&path, repo->path_repository, REBASE_APPLY_DIR) < 0) return -1; if (git_path_isdir(git_buf_cstr(&path))) { type = GIT_REBASE_TYPE_APPLY; goto done; } git_buf_clear(&path); if (git_buf_joinpath(&path, repo->path_repository, REBASE_MERGE_DIR) < 0) return -1; if (git_path_isdir(git_buf_cstr(&path))) { type = GIT_REBASE_TYPE_MERGE; goto done; } done: *type_out = type; if (type != GIT_REBASE_TYPE_NONE && path_out) *path_out = git_buf_detach(&path); git_buf_free(&path); return 0; } GIT_INLINE(int) rebase_readfile( git_buf *out, git_buf *state_path, const char *filename) { size_t state_path_len = state_path->size; int error; git_buf_clear(out); if ((error = git_buf_joinpath(state_path, state_path->ptr, filename)) < 0 || (error = git_futils_readbuffer(out, state_path->ptr)) < 0) goto done; git_buf_rtrim(out); done: git_buf_truncate(state_path, state_path_len); return error; } GIT_INLINE(int) rebase_readint( size_t *out, git_buf *asc_out, git_buf *state_path, const char *filename) { int32_t num; const char *eol; int error = 0; if ((error = rebase_readfile(asc_out, state_path, filename)) < 0) return error; if (git__strtol32(&num, asc_out->ptr, &eol, 10) < 0 || num < 0 || *eol) { giterr_set(GITERR_REBASE, "The file '%s' contains an invalid numeric value", filename); return -1; } *out = (size_t) num; return 0; } GIT_INLINE(int) rebase_readoid( git_oid *out, git_buf *str_out, git_buf *state_path, const char *filename) { int error; if ((error = rebase_readfile(str_out, state_path, filename)) < 0) return error; if (str_out->size != GIT_OID_HEXSZ || git_oid_fromstr(out, str_out->ptr) < 0) { giterr_set(GITERR_REBASE, "The file '%s' contains an invalid object ID", filename); return -1; } return 0; } static git_rebase_operation *rebase_operation_alloc( git_rebase *rebase, git_rebase_operation_t type, git_oid *id, const char *exec) { git_rebase_operation *operation; assert((type == GIT_REBASE_OPERATION_EXEC) == !id); assert((type == GIT_REBASE_OPERATION_EXEC) == !!exec); if ((operation = git_array_alloc(rebase->operations)) == NULL) return NULL; operation->type = type; git_oid_cpy((git_oid *)&operation->id, id); operation->exec = exec; return operation; } static int rebase_open_merge(git_rebase *rebase) { git_buf state_path = GIT_BUF_INIT, buf = GIT_BUF_INIT, cmt = GIT_BUF_INIT; git_oid id; git_rebase_operation *operation; size_t i, msgnum = 0, end; int error; if ((error = git_buf_puts(&state_path, rebase->state_path)) < 0) goto done; /* Read 'msgnum' if it exists (otherwise, let msgnum = 0) */ if ((error = rebase_readint(&msgnum, &buf, &state_path, MSGNUM_FILE)) < 0 && error != GIT_ENOTFOUND) goto done; if (msgnum) { rebase->started = 1; rebase->current = msgnum - 1; } /* Read 'end' */ if ((error = rebase_readint(&end, &buf, &state_path, END_FILE)) < 0) goto done; /* Read 'current' if it exists */ if ((error = rebase_readoid(&id, &buf, &state_path, CURRENT_FILE)) < 0 && error != GIT_ENOTFOUND) goto done; /* Read cmt.* */ git_array_init_to_size(rebase->operations, end); GITERR_CHECK_ARRAY(rebase->operations); for (i = 0; i < end; i++) { git_buf_clear(&cmt); if ((error = git_buf_printf(&cmt, "cmt.%" PRIuZ, (i+1))) < 0 || (error = rebase_readoid(&id, &buf, &state_path, cmt.ptr)) < 0) goto done; operation = rebase_operation_alloc(rebase, GIT_REBASE_OPERATION_PICK, &id, NULL); GITERR_CHECK_ALLOC(operation); } /* Read 'onto_name' */ if ((error = rebase_readfile(&buf, &state_path, ONTO_NAME_FILE)) < 0) goto done; rebase->onto_name = git_buf_detach(&buf); done: git_buf_free(&cmt); git_buf_free(&state_path); git_buf_free(&buf); return error; } static git_rebase *rebase_alloc(const git_rebase_options *rebase_opts) { git_rebase *rebase = git__calloc(1, sizeof(git_rebase)); if (!rebase) return NULL; if (rebase_opts) memcpy(&rebase->options, rebase_opts, sizeof(git_rebase_options)); else git_rebase_init_options(&rebase->options, GIT_REBASE_OPTIONS_VERSION); if (rebase_opts && rebase_opts->rewrite_notes_ref) { if ((rebase->options.rewrite_notes_ref = git__strdup(rebase_opts->rewrite_notes_ref)) == NULL) return NULL; } if ((rebase->options.checkout_options.checkout_strategy & (GIT_CHECKOUT_SAFE | GIT_CHECKOUT_FORCE)) == 0) rebase->options.checkout_options.checkout_strategy = GIT_CHECKOUT_SAFE; return rebase; } static int rebase_check_versions(const git_rebase_options *given_opts) { GITERR_CHECK_VERSION(given_opts, GIT_REBASE_OPTIONS_VERSION, "git_rebase_options"); if (given_opts) GITERR_CHECK_VERSION(&given_opts->checkout_options, GIT_CHECKOUT_OPTIONS_VERSION, "git_checkout_options"); return 0; } int git_rebase_open( git_rebase **out, git_repository *repo, const git_rebase_options *given_opts) { git_rebase *rebase; git_buf path = GIT_BUF_INIT, orig_head_name = GIT_BUF_INIT, orig_head_id = GIT_BUF_INIT, onto_id = GIT_BUF_INIT; int state_path_len, error; assert(repo); if ((error = rebase_check_versions(given_opts)) < 0) return error; rebase = rebase_alloc(given_opts); GITERR_CHECK_ALLOC(rebase); rebase->repo = repo; if ((error = rebase_state_type(&rebase->type, &rebase->state_path, repo)) < 0) goto done; if (rebase->type == GIT_REBASE_TYPE_NONE) { giterr_set(GITERR_REBASE, "There is no rebase in progress"); error = GIT_ENOTFOUND; goto done; } if ((error = git_buf_puts(&path, rebase->state_path)) < 0) goto done; state_path_len = git_buf_len(&path); if ((error = git_buf_joinpath(&path, path.ptr, HEAD_NAME_FILE)) < 0 || (error = git_futils_readbuffer(&orig_head_name, path.ptr)) < 0) goto done; git_buf_rtrim(&orig_head_name); if (strcmp(ORIG_DETACHED_HEAD, orig_head_name.ptr) == 0) rebase->head_detached = 1; git_buf_truncate(&path, state_path_len); if ((error = git_buf_joinpath(&path, path.ptr, ORIG_HEAD_FILE)) < 0) goto done; if (!git_path_isfile(path.ptr)) { /* Previous versions of git.git used 'head' here; support that. */ git_buf_truncate(&path, state_path_len); if ((error = git_buf_joinpath(&path, path.ptr, HEAD_FILE)) < 0) goto done; } if ((error = git_futils_readbuffer(&orig_head_id, path.ptr)) < 0) goto done; git_buf_rtrim(&orig_head_id); if ((error = git_oid_fromstr(&rebase->orig_head_id, orig_head_id.ptr)) < 0) goto done; git_buf_truncate(&path, state_path_len); if ((error = git_buf_joinpath(&path, path.ptr, ONTO_FILE)) < 0 || (error = git_futils_readbuffer(&onto_id, path.ptr)) < 0) goto done; git_buf_rtrim(&onto_id); if ((error = git_oid_fromstr(&rebase->onto_id, onto_id.ptr)) < 0) goto done; if (!rebase->head_detached) rebase->orig_head_name = git_buf_detach(&orig_head_name); switch (rebase->type) { case GIT_REBASE_TYPE_INTERACTIVE: giterr_set(GITERR_REBASE, "Interactive rebase is not supported"); error = -1; break; case GIT_REBASE_TYPE_MERGE: error = rebase_open_merge(rebase); break; case GIT_REBASE_TYPE_APPLY: giterr_set(GITERR_REBASE, "Patch application rebase is not supported"); error = -1; break; default: abort(); } done: if (error == 0) *out = rebase; else git_rebase_free(rebase); git_buf_free(&path); git_buf_free(&orig_head_name); git_buf_free(&orig_head_id); git_buf_free(&onto_id); return error; } static int rebase_cleanup(git_rebase *rebase) { return git_path_isdir(rebase->state_path) ? git_futils_rmdir_r(rebase->state_path, NULL, GIT_RMDIR_REMOVE_FILES) : 0; } static int rebase_setupfile(git_rebase *rebase, const char *filename, int flags, const char *fmt, ...) { git_buf path = GIT_BUF_INIT, contents = GIT_BUF_INIT; va_list ap; int error; va_start(ap, fmt); git_buf_vprintf(&contents, fmt, ap); va_end(ap); if ((error = git_buf_joinpath(&path, rebase->state_path, filename)) == 0) error = git_futils_writebuffer(&contents, path.ptr, flags, REBASE_FILE_MODE); git_buf_free(&path); git_buf_free(&contents); return error; } static const char *rebase_onto_name(const git_annotated_commit *onto) { if (onto->ref_name && git__strncmp(onto->ref_name, "refs/heads/", 11) == 0) return onto->ref_name + 11; else if (onto->ref_name) return onto->ref_name; else return onto->id_str; } static int rebase_setupfiles_merge(git_rebase *rebase) { git_buf commit_filename = GIT_BUF_INIT; char id_str[GIT_OID_HEXSZ]; git_rebase_operation *operation; size_t i; int error = 0; if ((error = rebase_setupfile(rebase, END_FILE, -1, "%" PRIuZ "\n", git_array_size(rebase->operations))) < 0 || (error = rebase_setupfile(rebase, ONTO_NAME_FILE, -1, "%s\n", rebase->onto_name)) < 0) goto done; for (i = 0; i < git_array_size(rebase->operations); i++) { operation = git_array_get(rebase->operations, i); git_buf_clear(&commit_filename); git_buf_printf(&commit_filename, CMT_FILE_FMT, i+1); git_oid_fmt(id_str, &operation->id); if ((error = rebase_setupfile(rebase, commit_filename.ptr, -1, "%.*s\n", GIT_OID_HEXSZ, id_str)) < 0) goto done; } done: git_buf_free(&commit_filename); return error; } static int rebase_setupfiles(git_rebase *rebase) { char onto[GIT_OID_HEXSZ], orig_head[GIT_OID_HEXSZ]; git_oid_fmt(onto, &rebase->onto_id); git_oid_fmt(orig_head, &rebase->orig_head_id); if (p_mkdir(rebase->state_path, REBASE_DIR_MODE) < 0) { giterr_set(GITERR_OS, "Failed to create rebase directory '%s'", rebase->state_path); return -1; } if (git_repository__set_orig_head(rebase->repo, &rebase->orig_head_id) < 0 || rebase_setupfile(rebase, HEAD_NAME_FILE, -1, "%s\n", rebase->orig_head_name) < 0 || rebase_setupfile(rebase, ONTO_FILE, -1, "%.*s\n", GIT_OID_HEXSZ, onto) < 0 || rebase_setupfile(rebase, ORIG_HEAD_FILE, -1, "%.*s\n", GIT_OID_HEXSZ, orig_head) < 0 || rebase_setupfile(rebase, QUIET_FILE, -1, rebase->quiet ? "t\n" : "\n") < 0) return -1; return rebase_setupfiles_merge(rebase); } int git_rebase_init_options(git_rebase_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_rebase_options, GIT_REBASE_OPTIONS_INIT); return 0; } static int rebase_ensure_not_in_progress(git_repository *repo) { int error; git_rebase_type_t type; if ((error = rebase_state_type(&type, NULL, repo)) < 0) return error; if (type != GIT_REBASE_TYPE_NONE) { giterr_set(GITERR_REBASE, "There is an existing rebase in progress"); return -1; } return 0; } static int rebase_ensure_not_dirty( git_repository *repo, bool check_index, bool check_workdir, int fail_with) { git_tree *head = NULL; git_index *index = NULL; git_diff *diff = NULL; int error = 0; if (check_index) { if ((error = git_repository_head_tree(&head, repo)) < 0 || (error = git_repository_index(&index, repo)) < 0 || (error = git_diff_tree_to_index(&diff, repo, head, index, NULL)) < 0) goto done; if (git_diff_num_deltas(diff) > 0) { giterr_set(GITERR_REBASE, "Uncommitted changes exist in index"); error = fail_with; goto done; } git_diff_free(diff); diff = NULL; } if (check_workdir) { if ((error = git_diff_index_to_workdir(&diff, repo, index, NULL)) < 0) goto done; if (git_diff_num_deltas(diff) > 0) { giterr_set(GITERR_REBASE, "Unstaged changes exist in workdir"); error = fail_with; goto done; } } done: git_diff_free(diff); git_index_free(index); git_tree_free(head); return error; } static int rebase_init_operations( git_rebase *rebase, git_repository *repo, const git_annotated_commit *branch, const git_annotated_commit *upstream, const git_annotated_commit *onto) { git_revwalk *revwalk = NULL; git_commit *commit; git_oid id; bool merge; git_rebase_operation *operation; int error; if (!upstream) upstream = onto; if ((error = git_revwalk_new(&revwalk, rebase->repo)) < 0 || (error = git_revwalk_push(revwalk, git_annotated_commit_id(branch))) < 0 || (error = git_revwalk_hide(revwalk, git_annotated_commit_id(upstream))) < 0) goto done; git_revwalk_sorting(revwalk, GIT_SORT_REVERSE | GIT_SORT_TIME); while ((error = git_revwalk_next(&id, revwalk)) == 0) { if ((error = git_commit_lookup(&commit, repo, &id)) < 0) goto done; merge = (git_commit_parentcount(commit) > 1); git_commit_free(commit); if (merge) continue; operation = rebase_operation_alloc(rebase, GIT_REBASE_OPERATION_PICK, &id, NULL); GITERR_CHECK_ALLOC(operation); } error = 0; done: git_revwalk_free(revwalk); return error; } static int rebase_init_merge( git_rebase *rebase, git_repository *repo, const git_annotated_commit *branch, const git_annotated_commit *upstream, const git_annotated_commit *onto) { if (rebase_init_operations(rebase, repo, branch, upstream, onto) < 0) return -1; rebase->onto_name = git__strdup(rebase_onto_name(onto)); GITERR_CHECK_ALLOC(rebase->onto_name); return 0; } static int rebase_init( git_rebase *rebase, git_repository *repo, const git_annotated_commit *branch, const git_annotated_commit *upstream, const git_annotated_commit *onto) { git_reference *head_ref = NULL; git_annotated_commit *head_branch = NULL; git_buf state_path = GIT_BUF_INIT; int error; if ((error = git_buf_joinpath(&state_path, repo->path_repository, REBASE_MERGE_DIR)) < 0) goto done; if (!branch) { if ((error = git_repository_head(&head_ref, repo)) < 0 || (error = git_annotated_commit_from_ref(&head_branch, repo, head_ref)) < 0) goto done; branch = head_branch; } rebase->repo = repo; rebase->type = GIT_REBASE_TYPE_MERGE; rebase->state_path = git_buf_detach(&state_path); rebase->orig_head_name = git__strdup(branch->ref_name ? branch->ref_name : ORIG_DETACHED_HEAD); rebase->quiet = rebase->options.quiet; git_oid_cpy(&rebase->orig_head_id, git_annotated_commit_id(branch)); git_oid_cpy(&rebase->onto_id, git_annotated_commit_id(onto)); if (!rebase->orig_head_name || !rebase->state_path) return -1; error = rebase_init_merge(rebase, repo, branch, upstream, onto); git_buf_free(&state_path); done: git_reference_free(head_ref); git_annotated_commit_free(head_branch); return error; } int git_rebase_init( git_rebase **out, git_repository *repo, const git_annotated_commit *branch, const git_annotated_commit *upstream, const git_annotated_commit *onto, const git_rebase_options *given_opts) { git_rebase *rebase = NULL; git_buf reflog = GIT_BUF_INIT; git_commit *onto_commit = NULL; git_reference *head_ref = NULL; int error; assert(repo && (upstream || onto)); *out = NULL; if (!onto) onto = upstream; if ((error = rebase_check_versions(given_opts)) < 0 || (error = git_repository__ensure_not_bare(repo, "rebase")) < 0 || (error = rebase_ensure_not_in_progress(repo)) < 0 || (error = rebase_ensure_not_dirty(repo, true, true, GIT_ERROR)) < 0 || (error = git_commit_lookup( &onto_commit, repo, git_annotated_commit_id(onto))) < 0) return error; rebase = rebase_alloc(given_opts); if ((error = rebase_init( rebase, repo, branch, upstream, onto)) < 0 || (error = rebase_setupfiles(rebase)) < 0 || (error = git_buf_printf(&reflog, "rebase: checkout %s", rebase_onto_name(onto))) < 0 || (error = git_checkout_tree( repo, (git_object *)onto_commit, &rebase->options.checkout_options)) < 0 || (error = git_reference_create(&head_ref, repo, GIT_HEAD_FILE, git_annotated_commit_id(onto), 1, reflog.ptr)) < 0) goto done; *out = rebase; done: git_reference_free(head_ref); if (error < 0) { rebase_cleanup(rebase); git_rebase_free(rebase); } git_commit_free(onto_commit); git_buf_free(&reflog); return error; } static void normalize_checkout_options_for_apply( git_checkout_options *checkout_opts, git_rebase *rebase, git_commit *current_commit) { memcpy(checkout_opts, &rebase->options.checkout_options, sizeof(git_checkout_options)); if (!checkout_opts->ancestor_label) checkout_opts->ancestor_label = "ancestor"; if (rebase->type == GIT_REBASE_TYPE_MERGE) { if (!checkout_opts->our_label) checkout_opts->our_label = rebase->onto_name; if (!checkout_opts->their_label) checkout_opts->their_label = git_commit_summary(current_commit); } else { abort(); } } GIT_INLINE(int) rebase_movenext(git_rebase *rebase) { size_t next = rebase->started ? rebase->current + 1 : 0; if (next == git_array_size(rebase->operations)) return GIT_ITEROVER; rebase->started = 1; rebase->current = next; return 0; } static int rebase_next_merge( git_rebase_operation **out, git_rebase *rebase) { git_buf path = GIT_BUF_INIT; git_commit *current_commit = NULL, *parent_commit = NULL; git_tree *current_tree = NULL, *head_tree = NULL, *parent_tree = NULL; git_index *index = NULL; git_indexwriter indexwriter = GIT_INDEXWRITER_INIT; git_rebase_operation *operation; git_checkout_options checkout_opts; char current_idstr[GIT_OID_HEXSZ]; unsigned int parent_count; int error; *out = NULL; if ((error = rebase_movenext(rebase)) < 0) goto done; operation = git_array_get(rebase->operations, rebase->current); if ((error = git_commit_lookup(¤t_commit, rebase->repo, &operation->id)) < 0 || (error = git_commit_tree(¤t_tree, current_commit)) < 0 || (error = git_repository_head_tree(&head_tree, rebase->repo)) < 0) goto done; if ((parent_count = git_commit_parentcount(current_commit)) > 1) { giterr_set(GITERR_REBASE, "Cannot rebase a merge commit"); error = -1; goto done; } else if (parent_count) { if ((error = git_commit_parent(&parent_commit, current_commit, 0)) < 0 || (error = git_commit_tree(&parent_tree, parent_commit)) < 0) goto done; } git_oid_fmt(current_idstr, &operation->id); normalize_checkout_options_for_apply(&checkout_opts, rebase, current_commit); if ((error = git_indexwriter_init_for_operation(&indexwriter, rebase->repo, &checkout_opts.checkout_strategy)) < 0 || (error = rebase_setupfile(rebase, MSGNUM_FILE, -1, "%" PRIuZ "\n", rebase->current+1)) < 0 || (error = rebase_setupfile(rebase, CURRENT_FILE, -1, "%.*s\n", GIT_OID_HEXSZ, current_idstr)) < 0 || (error = git_merge_trees(&index, rebase->repo, parent_tree, head_tree, current_tree, NULL)) < 0 || (error = git_merge__check_result(rebase->repo, index)) < 0 || (error = git_checkout_index(rebase->repo, index, &checkout_opts)) < 0 || (error = git_indexwriter_commit(&indexwriter)) < 0) goto done; *out = operation; done: git_indexwriter_cleanup(&indexwriter); git_index_free(index); git_tree_free(current_tree); git_tree_free(head_tree); git_tree_free(parent_tree); git_commit_free(parent_commit); git_commit_free(current_commit); git_buf_free(&path); return error; } int git_rebase_next( git_rebase_operation **out, git_rebase *rebase) { int error; assert(out && rebase); switch (rebase->type) { case GIT_REBASE_TYPE_MERGE: error = rebase_next_merge(out, rebase); break; default: abort(); } return error; } static int rebase_commit_merge( git_oid *commit_id, git_rebase *rebase, const git_signature *author, const git_signature *committer, const char *message_encoding, const char *message) { git_index *index = NULL; git_reference *head = NULL; git_commit *current_commit = NULL, *head_commit = NULL, *commit = NULL; git_rebase_operation *operation; git_tree *head_tree = NULL, *tree = NULL; git_diff *diff = NULL; git_oid tree_id; git_buf reflog_msg = GIT_BUF_INIT; char old_idstr[GIT_OID_HEXSZ], new_idstr[GIT_OID_HEXSZ]; int error; operation = git_array_get(rebase->operations, rebase->current); assert(operation); if ((error = git_repository_index(&index, rebase->repo)) < 0) goto done; if (git_index_has_conflicts(index)) { giterr_set(GITERR_REBASE, "Conflicts have not been resolved"); error = GIT_EUNMERGED; goto done; } if ((error = rebase_ensure_not_dirty(rebase->repo, false, true, GIT_EUNMERGED)) < 0 || (error = git_commit_lookup(¤t_commit, rebase->repo, &operation->id)) < 0 || (error = git_repository_head(&head, rebase->repo)) < 0 || (error = git_reference_peel((git_object **)&head_commit, head, GIT_OBJ_COMMIT)) < 0 || (error = git_commit_tree(&head_tree, head_commit)) < 0 || (error = git_diff_tree_to_index(&diff, rebase->repo, head_tree, index, NULL)) < 0) goto done; if (git_diff_num_deltas(diff) == 0) { giterr_set(GITERR_REBASE, "This patch has already been applied"); error = GIT_EAPPLIED; goto done; } if ((error = git_index_write_tree(&tree_id, index)) < 0 || (error = git_tree_lookup(&tree, rebase->repo, &tree_id)) < 0) goto done; if (!author) author = git_commit_author(current_commit); if (!message) { message_encoding = git_commit_message_encoding(current_commit); message = git_commit_message(current_commit); } if ((error = git_commit_create(commit_id, rebase->repo, NULL, author, committer, message_encoding, message, tree, 1, (const git_commit **)&head_commit)) < 0 || (error = git_commit_lookup(&commit, rebase->repo, commit_id)) < 0 || (error = git_reference__update_for_commit( rebase->repo, NULL, "HEAD", commit_id, "rebase")) < 0) goto done; git_oid_fmt(old_idstr, git_commit_id(current_commit)); git_oid_fmt(new_idstr, commit_id); error = rebase_setupfile(rebase, REWRITTEN_FILE, O_CREAT|O_WRONLY|O_APPEND, "%.*s %.*s\n", GIT_OID_HEXSZ, old_idstr, GIT_OID_HEXSZ, new_idstr); done: git_buf_free(&reflog_msg); git_commit_free(commit); git_diff_free(diff); git_tree_free(tree); git_tree_free(head_tree); git_commit_free(head_commit); git_commit_free(current_commit); git_reference_free(head); git_index_free(index); return error; } int git_rebase_commit( git_oid *id, git_rebase *rebase, const git_signature *author, const git_signature *committer, const char *message_encoding, const char *message) { int error; assert(rebase && committer); switch (rebase->type) { case GIT_REBASE_TYPE_MERGE: error = rebase_commit_merge( id, rebase, author, committer, message_encoding, message); break; default: abort(); } return error; } int git_rebase_abort(git_rebase *rebase) { git_reference *orig_head_ref = NULL; git_commit *orig_head_commit = NULL; int error; assert(rebase); error = rebase->head_detached ? git_reference_create(&orig_head_ref, rebase->repo, GIT_HEAD_FILE, &rebase->orig_head_id, 1, "rebase: aborting") : git_reference_symbolic_create( &orig_head_ref, rebase->repo, GIT_HEAD_FILE, rebase->orig_head_name, 1, "rebase: aborting"); if (error < 0) goto done; if ((error = git_commit_lookup( &orig_head_commit, rebase->repo, &rebase->orig_head_id)) < 0 || (error = git_reset(rebase->repo, (git_object *)orig_head_commit, GIT_RESET_HARD, &rebase->options.checkout_options)) < 0) goto done; error = rebase_cleanup(rebase); done: git_commit_free(orig_head_commit); git_reference_free(orig_head_ref); return error; } static int notes_ref_lookup(git_buf *out, git_rebase *rebase) { git_config *config = NULL; int do_rewrite, error; if (rebase->options.rewrite_notes_ref) { git_buf_attach_notowned(out, rebase->options.rewrite_notes_ref, strlen(rebase->options.rewrite_notes_ref)); return 0; } if ((error = git_repository_config(&config, rebase->repo)) < 0 || (error = git_config_get_bool(&do_rewrite, config, "notes.rewrite.rebase")) < 0) { if (error != GIT_ENOTFOUND) goto done; giterr_clear(); do_rewrite = 1; } error = do_rewrite ? git_config_get_string_buf(out, config, "notes.rewriteref") : GIT_ENOTFOUND; done: git_config_free(config); return error; } static int rebase_copy_note( git_rebase *rebase, const char *notes_ref, git_oid *from, git_oid *to, const git_signature *committer) { git_note *note = NULL; git_oid note_id; git_signature *who = NULL; int error; if ((error = git_note_read(¬e, rebase->repo, notes_ref, from)) < 0) { if (error == GIT_ENOTFOUND) { giterr_clear(); error = 0; } goto done; } if (!committer) { if((error = git_signature_default(&who, rebase->repo)) < 0) { if (error != GIT_ENOTFOUND || (error = git_signature_now(&who, "unknown", "unknown")) < 0) goto done; giterr_clear(); } committer = who; } error = git_note_create(¬e_id, rebase->repo, notes_ref, git_note_author(note), committer, to, git_note_message(note), 0); done: git_note_free(note); git_signature_free(who); return error; } static int rebase_copy_notes( git_rebase *rebase, const git_signature *committer) { git_buf path = GIT_BUF_INIT, rewritten = GIT_BUF_INIT, notes_ref = GIT_BUF_INIT; char *pair_list, *fromstr, *tostr, *end; git_oid from, to; unsigned int linenum = 1; int error = 0; if ((error = notes_ref_lookup(¬es_ref, rebase)) < 0) { if (error == GIT_ENOTFOUND) { giterr_clear(); error = 0; } goto done; } if ((error = git_buf_joinpath(&path, rebase->state_path, REWRITTEN_FILE)) < 0 || (error = git_futils_readbuffer(&rewritten, path.ptr)) < 0) goto done; pair_list = rewritten.ptr; while (*pair_list) { fromstr = pair_list; if ((end = strchr(fromstr, '\n')) == NULL) goto on_error; pair_list = end+1; *end = '\0'; if ((end = strchr(fromstr, ' ')) == NULL) goto on_error; tostr = end+1; *end = '\0'; if (strlen(fromstr) != GIT_OID_HEXSZ || strlen(tostr) != GIT_OID_HEXSZ || git_oid_fromstr(&from, fromstr) < 0 || git_oid_fromstr(&to, tostr) < 0) goto on_error; if ((error = rebase_copy_note(rebase, notes_ref.ptr, &from, &to, committer)) < 0) goto done; linenum++; } goto done; on_error: giterr_set(GITERR_REBASE, "Invalid rewritten file at line %d", linenum); error = -1; done: git_buf_free(&rewritten); git_buf_free(&path); git_buf_free(¬es_ref); return error; } int git_rebase_finish( git_rebase *rebase, const git_signature *signature) { git_reference *terminal_ref = NULL, *branch_ref = NULL, *head_ref = NULL; git_commit *terminal_commit = NULL; git_buf branch_msg = GIT_BUF_INIT, head_msg = GIT_BUF_INIT; char onto[GIT_OID_HEXSZ]; int error; assert(rebase); git_oid_fmt(onto, &rebase->onto_id); if ((error = git_buf_printf(&branch_msg, "rebase finished: %s onto %.*s", rebase->orig_head_name, GIT_OID_HEXSZ, onto)) < 0 || (error = git_buf_printf(&head_msg, "rebase finished: returning to %s", rebase->orig_head_name)) < 0 || (error = git_repository_head(&terminal_ref, rebase->repo)) < 0 || (error = git_reference_peel((git_object **)&terminal_commit, terminal_ref, GIT_OBJ_COMMIT)) < 0 || (error = git_reference_create_matching(&branch_ref, rebase->repo, rebase->orig_head_name, git_commit_id(terminal_commit), 1, &rebase->orig_head_id, branch_msg.ptr)) < 0 || (error = git_reference_symbolic_create(&head_ref, rebase->repo, GIT_HEAD_FILE, rebase->orig_head_name, 1, head_msg.ptr)) < 0 || (error = rebase_copy_notes(rebase, signature)) < 0) goto done; error = rebase_cleanup(rebase); done: git_buf_free(&head_msg); git_buf_free(&branch_msg); git_commit_free(terminal_commit); git_reference_free(head_ref); git_reference_free(branch_ref); git_reference_free(terminal_ref); return error; } size_t git_rebase_operation_entrycount(git_rebase *rebase) { assert(rebase); return git_array_size(rebase->operations); } size_t git_rebase_operation_current(git_rebase *rebase) { assert(rebase); return rebase->started ? rebase->current : GIT_REBASE_NO_OPERATION; } git_rebase_operation *git_rebase_operation_byindex(git_rebase *rebase, size_t idx) { assert(rebase); return git_array_get(rebase->operations, idx); } void git_rebase_free(git_rebase *rebase) { if (rebase == NULL) return; git__free(rebase->onto_name); git__free(rebase->orig_head_name); git__free(rebase->state_path); git_array_clear(rebase->operations); git__free((char *)rebase->options.rewrite_notes_ref); git__free(rebase); } deps/libgit2-sys-0.3.8/libgit2/src/config.c0000664000175000017500000007320312572105236015313 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "sysdir.h" #include "config.h" #include "git2/config.h" #include "git2/sys/config.h" #include "vector.h" #include "buf_text.h" #include "config_file.h" #include "transaction.h" #if GIT_WIN32 # include #endif #include void git_config_entry_free(git_config_entry *entry) { if (!entry) return; entry->free(entry); } typedef struct { git_refcount rc; git_config_backend *file; git_config_level_t level; } file_internal; static void file_internal_free(file_internal *internal) { git_config_backend *file; file = internal->file; file->free(file); git__free(internal); } static void config_free(git_config *cfg) { size_t i; file_internal *internal; for (i = 0; i < cfg->files.length; ++i) { internal = git_vector_get(&cfg->files, i); GIT_REFCOUNT_DEC(internal, file_internal_free); } git_vector_free(&cfg->files); git__memzero(cfg, sizeof(*cfg)); git__free(cfg); } void git_config_free(git_config *cfg) { if (cfg == NULL) return; GIT_REFCOUNT_DEC(cfg, config_free); } static int config_backend_cmp(const void *a, const void *b) { const file_internal *bk_a = (const file_internal *)(a); const file_internal *bk_b = (const file_internal *)(b); return bk_b->level - bk_a->level; } int git_config_new(git_config **out) { git_config *cfg; cfg = git__malloc(sizeof(git_config)); GITERR_CHECK_ALLOC(cfg); memset(cfg, 0x0, sizeof(git_config)); if (git_vector_init(&cfg->files, 3, config_backend_cmp) < 0) { git__free(cfg); return -1; } *out = cfg; GIT_REFCOUNT_INC(cfg); return 0; } int git_config_add_file_ondisk( git_config *cfg, const char *path, git_config_level_t level, int force) { git_config_backend *file = NULL; struct stat st; int res; assert(cfg && path); res = p_stat(path, &st); if (res < 0 && errno != ENOENT) { giterr_set(GITERR_CONFIG, "Error stat'ing config file '%s'", path); return -1; } if (git_config_file__ondisk(&file, path) < 0) return -1; if ((res = git_config_add_backend(cfg, file, level, force)) < 0) { /* * free manually; the file is not owned by the config * instance yet and will not be freed on cleanup */ file->free(file); return res; } return 0; } int git_config_open_ondisk(git_config **out, const char *path) { int error; git_config *config; *out = NULL; if (git_config_new(&config) < 0) return -1; if ((error = git_config_add_file_ondisk(config, path, GIT_CONFIG_LEVEL_LOCAL, 0)) < 0) git_config_free(config); else *out = config; return error; } int git_config_snapshot(git_config **out, git_config *in) { int error = 0; size_t i; file_internal *internal; git_config *config; *out = NULL; if (git_config_new(&config) < 0) return -1; git_vector_foreach(&in->files, i, internal) { git_config_backend *b; if ((error = internal->file->snapshot(&b, internal->file)) < 0) break; if ((error = git_config_add_backend(config, b, internal->level, 0)) < 0) { b->free(b); break; } } if (error < 0) git_config_free(config); else *out = config; return error; } static int find_internal_file_by_level( file_internal **internal_out, const git_config *cfg, git_config_level_t level) { int pos = -1; file_internal *internal; size_t i; /* when passing GIT_CONFIG_HIGHEST_LEVEL, the idea is to get the config file * which has the highest level. As config files are stored in a vector * sorted by decreasing order of level, getting the file at position 0 * will do the job. */ if (level == GIT_CONFIG_HIGHEST_LEVEL) { pos = 0; } else { git_vector_foreach(&cfg->files, i, internal) { if (internal->level == level) pos = (int)i; } } if (pos == -1) { giterr_set(GITERR_CONFIG, "No config file exists for the given level '%i'", (int)level); return GIT_ENOTFOUND; } *internal_out = git_vector_get(&cfg->files, pos); return 0; } static int duplicate_level(void **old_raw, void *new_raw) { file_internal **old = (file_internal **)old_raw; GIT_UNUSED(new_raw); giterr_set(GITERR_CONFIG, "A file with the same level (%i) has already been added to the config", (int)(*old)->level); return GIT_EEXISTS; } static void try_remove_existing_file_internal( git_config *cfg, git_config_level_t level) { int pos = -1; file_internal *internal; size_t i; git_vector_foreach(&cfg->files, i, internal) { if (internal->level == level) pos = (int)i; } if (pos == -1) return; internal = git_vector_get(&cfg->files, pos); if (git_vector_remove(&cfg->files, pos) < 0) return; GIT_REFCOUNT_DEC(internal, file_internal_free); } static int git_config__add_internal( git_config *cfg, file_internal *internal, git_config_level_t level, int force) { int result; /* delete existing config file for level if it exists */ if (force) try_remove_existing_file_internal(cfg, level); if ((result = git_vector_insert_sorted(&cfg->files, internal, &duplicate_level)) < 0) return result; git_vector_sort(&cfg->files); internal->file->cfg = cfg; GIT_REFCOUNT_INC(internal); return 0; } int git_config_open_global(git_config **cfg_out, git_config *cfg) { if (!git_config_open_level(cfg_out, cfg, GIT_CONFIG_LEVEL_XDG)) return 0; return git_config_open_level(cfg_out, cfg, GIT_CONFIG_LEVEL_GLOBAL); } int git_config_open_level( git_config **cfg_out, const git_config *cfg_parent, git_config_level_t level) { git_config *cfg; file_internal *internal; int res; if ((res = find_internal_file_by_level(&internal, cfg_parent, level)) < 0) return res; if ((res = git_config_new(&cfg)) < 0) return res; if ((res = git_config__add_internal(cfg, internal, level, true)) < 0) { git_config_free(cfg); return res; } *cfg_out = cfg; return 0; } int git_config_add_backend( git_config *cfg, git_config_backend *file, git_config_level_t level, int force) { file_internal *internal; int result; assert(cfg && file); GITERR_CHECK_VERSION(file, GIT_CONFIG_BACKEND_VERSION, "git_config_backend"); if ((result = file->open(file, level)) < 0) return result; internal = git__malloc(sizeof(file_internal)); GITERR_CHECK_ALLOC(internal); memset(internal, 0x0, sizeof(file_internal)); internal->file = file; internal->level = level; if ((result = git_config__add_internal(cfg, internal, level, force)) < 0) { git__free(internal); return result; } return 0; } /* * Loop over all the variables */ typedef struct { git_config_iterator parent; git_config_iterator *current; const git_config *cfg; regex_t regex; size_t i; } all_iter; static int find_next_backend(size_t *out, const git_config *cfg, size_t i) { file_internal *internal; for (; i > 0; --i) { internal = git_vector_get(&cfg->files, i - 1); if (!internal || !internal->file) continue; *out = i; return 0; } return -1; } static int all_iter_next(git_config_entry **entry, git_config_iterator *_iter) { all_iter *iter = (all_iter *) _iter; file_internal *internal; git_config_backend *backend; size_t i; int error = 0; if (iter->current != NULL && (error = iter->current->next(entry, iter->current)) == 0) { return 0; } if (error < 0 && error != GIT_ITEROVER) return error; do { if (find_next_backend(&i, iter->cfg, iter->i) < 0) return GIT_ITEROVER; internal = git_vector_get(&iter->cfg->files, i - 1); backend = internal->file; iter->i = i - 1; if (iter->current) iter->current->free(iter->current); iter->current = NULL; error = backend->iterator(&iter->current, backend); if (error == GIT_ENOTFOUND) continue; if (error < 0) return error; error = iter->current->next(entry, iter->current); /* If this backend is empty, then keep going */ if (error == GIT_ITEROVER) continue; return error; } while(1); return GIT_ITEROVER; } static int all_iter_glob_next(git_config_entry **entry, git_config_iterator *_iter) { int error; all_iter *iter = (all_iter *) _iter; /* * We use the "normal" function to grab the next one across * backends and then apply the regex */ while ((error = all_iter_next(entry, _iter)) == 0) { /* skip non-matching keys if regexp was provided */ if (regexec(&iter->regex, (*entry)->name, 0, NULL, 0) != 0) continue; /* and simply return if we like the entry's name */ return 0; } return error; } static void all_iter_free(git_config_iterator *_iter) { all_iter *iter = (all_iter *) _iter; if (iter->current) iter->current->free(iter->current); git__free(iter); } static void all_iter_glob_free(git_config_iterator *_iter) { all_iter *iter = (all_iter *) _iter; regfree(&iter->regex); all_iter_free(_iter); } int git_config_iterator_new(git_config_iterator **out, const git_config *cfg) { all_iter *iter; iter = git__calloc(1, sizeof(all_iter)); GITERR_CHECK_ALLOC(iter); iter->parent.free = all_iter_free; iter->parent.next = all_iter_next; iter->i = cfg->files.length; iter->cfg = cfg; *out = (git_config_iterator *) iter; return 0; } int git_config_iterator_glob_new(git_config_iterator **out, const git_config *cfg, const char *regexp) { all_iter *iter; int result; if (regexp == NULL) return git_config_iterator_new(out, cfg); iter = git__calloc(1, sizeof(all_iter)); GITERR_CHECK_ALLOC(iter); if ((result = regcomp(&iter->regex, regexp, REG_EXTENDED)) != 0) { giterr_set_regex(&iter->regex, result); git__free(iter); return -1; } iter->parent.next = all_iter_glob_next; iter->parent.free = all_iter_glob_free; iter->i = cfg->files.length; iter->cfg = cfg; *out = (git_config_iterator *) iter; return 0; } int git_config_foreach( const git_config *cfg, git_config_foreach_cb cb, void *payload) { return git_config_foreach_match(cfg, NULL, cb, payload); } int git_config_backend_foreach_match( git_config_backend *backend, const char *regexp, git_config_foreach_cb cb, void *payload) { git_config_entry *entry; git_config_iterator* iter; regex_t regex; int error = 0; if (regexp != NULL) { if ((error = regcomp(®ex, regexp, REG_EXTENDED)) != 0) { giterr_set_regex(®ex, error); regfree(®ex); return -1; } } if ((error = backend->iterator(&iter, backend)) < 0) { iter = NULL; return -1; } while (!(iter->next(&entry, iter) < 0)) { /* skip non-matching keys if regexp was provided */ if (regexp && regexec(®ex, entry->name, 0, NULL, 0) != 0) continue; /* abort iterator on non-zero return value */ if ((error = cb(entry, payload)) != 0) { giterr_set_after_callback(error); break; } } if (regexp != NULL) regfree(®ex); iter->free(iter); return error; } int git_config_foreach_match( const git_config *cfg, const char *regexp, git_config_foreach_cb cb, void *payload) { int error; git_config_iterator *iter; git_config_entry *entry; if ((error = git_config_iterator_glob_new(&iter, cfg, regexp)) < 0) return error; while (!(error = git_config_next(&entry, iter))) { if ((error = cb(entry, payload)) != 0) { giterr_set_after_callback(error); break; } } git_config_iterator_free(iter); if (error == GIT_ITEROVER) error = 0; return error; } /************** * Setters **************/ static int config_error_nofiles(const char *name) { giterr_set(GITERR_CONFIG, "Cannot set value for '%s' when no config files exist", name); return GIT_ENOTFOUND; } int git_config_delete_entry(git_config *cfg, const char *name) { git_config_backend *file; file_internal *internal; internal = git_vector_get(&cfg->files, 0); if (!internal || !internal->file) return config_error_nofiles(name); file = internal->file; return file->del(file, name); } int git_config_set_int64(git_config *cfg, const char *name, int64_t value) { char str_value[32]; /* All numbers should fit in here */ p_snprintf(str_value, sizeof(str_value), "%" PRId64, value); return git_config_set_string(cfg, name, str_value); } int git_config_set_int32(git_config *cfg, const char *name, int32_t value) { return git_config_set_int64(cfg, name, (int64_t)value); } int git_config_set_bool(git_config *cfg, const char *name, int value) { return git_config_set_string(cfg, name, value ? "true" : "false"); } int git_config_set_string(git_config *cfg, const char *name, const char *value) { int error; git_config_backend *file; file_internal *internal; if (!value) { giterr_set(GITERR_CONFIG, "The value to set cannot be NULL"); return -1; } internal = git_vector_get(&cfg->files, 0); if (!internal || !internal->file) return config_error_nofiles(name); file = internal->file; error = file->set(file, name, value); if (!error && GIT_REFCOUNT_OWNER(cfg) != NULL) git_repository__cvar_cache_clear(GIT_REFCOUNT_OWNER(cfg)); return error; } int git_config__update_entry( git_config *config, const char *key, const char *value, bool overwrite_existing, bool only_if_existing) { int error = 0; git_config_entry *ce = NULL; if ((error = git_config__lookup_entry(&ce, config, key, false)) < 0) return error; if (!ce && only_if_existing) /* entry doesn't exist */ return 0; if (ce && !overwrite_existing) /* entry would be overwritten */ return 0; if (value && ce && ce->value && !strcmp(ce->value, value)) /* no change */ return 0; if (!value && (!ce || !ce->value)) /* asked to delete absent entry */ return 0; if (!value) error = git_config_delete_entry(config, key); else error = git_config_set_string(config, key, value); git_config_entry_free(ce); return error; } /*********** * Getters ***********/ static int config_error_notfound(const char *name) { giterr_set(GITERR_CONFIG, "Config value '%s' was not found", name); return GIT_ENOTFOUND; } enum { GET_ALL_ERRORS = 0, GET_NO_MISSING = 1, GET_NO_ERRORS = 2 }; static int get_entry( git_config_entry **out, const git_config *cfg, const char *name, bool normalize_name, int want_errors) { int res = GIT_ENOTFOUND; const char *key = name; char *normalized = NULL; size_t i; file_internal *internal; *out = NULL; if (normalize_name) { if ((res = git_config__normalize_name(name, &normalized)) < 0) goto cleanup; key = normalized; } res = GIT_ENOTFOUND; git_vector_foreach(&cfg->files, i, internal) { if (!internal || !internal->file) continue; res = internal->file->get(internal->file, key, out); if (res != GIT_ENOTFOUND) break; } git__free(normalized); cleanup: if (res == GIT_ENOTFOUND) res = (want_errors > GET_ALL_ERRORS) ? 0 : config_error_notfound(name); else if (res && (want_errors == GET_NO_ERRORS)) { giterr_clear(); res = 0; } return res; } int git_config_get_entry( git_config_entry **out, const git_config *cfg, const char *name) { return get_entry(out, cfg, name, true, GET_ALL_ERRORS); } int git_config__lookup_entry( git_config_entry **out, const git_config *cfg, const char *key, bool no_errors) { return get_entry( out, cfg, key, false, no_errors ? GET_NO_ERRORS : GET_NO_MISSING); } int git_config_get_mapped( int *out, const git_config *cfg, const char *name, const git_cvar_map *maps, size_t map_n) { git_config_entry *entry; int ret; if ((ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS)) < 0) return ret; ret = git_config_lookup_map_value(out, maps, map_n, entry->value); git_config_entry_free(entry); return ret; } int git_config_get_int64(int64_t *out, const git_config *cfg, const char *name) { git_config_entry *entry; int ret; if ((ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS)) < 0) return ret; ret = git_config_parse_int64(out, entry->value); git_config_entry_free(entry); return ret; } int git_config_get_int32(int32_t *out, const git_config *cfg, const char *name) { git_config_entry *entry; int ret; if ((ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS)) < 0) return ret; ret = git_config_parse_int32(out, entry->value); git_config_entry_free(entry); return ret; } int git_config_get_bool(int *out, const git_config *cfg, const char *name) { git_config_entry *entry; int ret; if ((ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS)) < 0) return ret; ret = git_config_parse_bool(out, entry->value); git_config_entry_free(entry); return ret; } static int is_readonly(const git_config *cfg) { size_t i; file_internal *internal; git_vector_foreach(&cfg->files, i, internal) { if (!internal || !internal->file) continue; if (!internal->file->readonly) return 0; } return 1; } int git_config_get_path(git_buf *out, const git_config *cfg, const char *name) { git_config_entry *entry; int error; if ((error = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS)) < 0) return error; error = git_config_parse_path(out, entry->value); git_config_entry_free(entry); return error; } int git_config_get_string( const char **out, const git_config *cfg, const char *name) { git_config_entry *entry; int ret; if (!is_readonly(cfg)) { giterr_set(GITERR_CONFIG, "get_string called on a live config object"); return -1; } ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS); *out = !ret ? (entry->value ? entry->value : "") : NULL; git_config_entry_free(entry); return ret; } int git_config_get_string_buf( git_buf *out, const git_config *cfg, const char *name) { git_config_entry *entry; int ret; const char *str; git_buf_sanitize(out); ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS); str = !ret ? (entry->value ? entry->value : "") : NULL; if (str) ret = git_buf_puts(out, str); git_config_entry_free(entry); return ret; } char *git_config__get_string_force( const git_config *cfg, const char *key, const char *fallback_value) { git_config_entry *entry; char *ret; get_entry(&entry, cfg, key, false, GET_NO_ERRORS); ret = (entry && entry->value) ? git__strdup(entry->value) : fallback_value ? git__strdup(fallback_value) : NULL; git_config_entry_free(entry); return ret; } int git_config__get_bool_force( const git_config *cfg, const char *key, int fallback_value) { int val = fallback_value; git_config_entry *entry; get_entry(&entry, cfg, key, false, GET_NO_ERRORS); if (entry && git_config_parse_bool(&val, entry->value) < 0) giterr_clear(); git_config_entry_free(entry); return val; } int git_config__get_int_force( const git_config *cfg, const char *key, int fallback_value) { int32_t val = (int32_t)fallback_value; git_config_entry *entry; get_entry(&entry, cfg, key, false, GET_NO_ERRORS); if (entry && git_config_parse_int32(&val, entry->value) < 0) giterr_clear(); git_config_entry_free(entry); return (int)val; } int git_config_get_multivar_foreach( const git_config *cfg, const char *name, const char *regexp, git_config_foreach_cb cb, void *payload) { int err, found; git_config_iterator *iter; git_config_entry *entry; if ((err = git_config_multivar_iterator_new(&iter, cfg, name, regexp)) < 0) return err; found = 0; while ((err = iter->next(&entry, iter)) == 0) { found = 1; if ((err = cb(entry, payload)) != 0) { giterr_set_after_callback(err); break; } } iter->free(iter); if (err == GIT_ITEROVER) err = 0; if (found == 0 && err == 0) err = config_error_notfound(name); return err; } typedef struct { git_config_iterator parent; git_config_iterator *iter; char *name; regex_t regex; int have_regex; } multivar_iter; static int multivar_iter_next(git_config_entry **entry, git_config_iterator *_iter) { multivar_iter *iter = (multivar_iter *) _iter; int error = 0; while ((error = iter->iter->next(entry, iter->iter)) == 0) { if (git__strcmp(iter->name, (*entry)->name)) continue; if (!iter->have_regex) return 0; if (regexec(&iter->regex, (*entry)->value, 0, NULL, 0) == 0) return 0; } return error; } void multivar_iter_free(git_config_iterator *_iter) { multivar_iter *iter = (multivar_iter *) _iter; iter->iter->free(iter->iter); git__free(iter->name); if (iter->have_regex) regfree(&iter->regex); git__free(iter); } int git_config_multivar_iterator_new(git_config_iterator **out, const git_config *cfg, const char *name, const char *regexp) { multivar_iter *iter = NULL; git_config_iterator *inner = NULL; int error; if ((error = git_config_iterator_new(&inner, cfg)) < 0) return error; iter = git__calloc(1, sizeof(multivar_iter)); GITERR_CHECK_ALLOC(iter); if ((error = git_config__normalize_name(name, &iter->name)) < 0) goto on_error; if (regexp != NULL) { error = regcomp(&iter->regex, regexp, REG_EXTENDED); if (error != 0) { giterr_set_regex(&iter->regex, error); error = -1; regfree(&iter->regex); goto on_error; } iter->have_regex = 1; } iter->iter = inner; iter->parent.free = multivar_iter_free; iter->parent.next = multivar_iter_next; *out = (git_config_iterator *) iter; return 0; on_error: inner->free(inner); git__free(iter); return error; } int git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value) { git_config_backend *file; file_internal *internal; internal = git_vector_get(&cfg->files, 0); if (!internal || !internal->file) return config_error_nofiles(name); file = internal->file; return file->set_multivar(file, name, regexp, value); } int git_config_delete_multivar(git_config *cfg, const char *name, const char *regexp) { git_config_backend *file; file_internal *internal; internal = git_vector_get(&cfg->files, 0); if (!internal || !internal->file) return config_error_nofiles(name); file = internal->file; return file->del_multivar(file, name, regexp); } int git_config_next(git_config_entry **entry, git_config_iterator *iter) { return iter->next(entry, iter); } void git_config_iterator_free(git_config_iterator *iter) { if (iter == NULL) return; iter->free(iter); } int git_config_find_global(git_buf *path) { git_buf_sanitize(path); return git_sysdir_find_global_file(path, GIT_CONFIG_FILENAME_GLOBAL); } int git_config_find_xdg(git_buf *path) { git_buf_sanitize(path); return git_sysdir_find_xdg_file(path, GIT_CONFIG_FILENAME_XDG); } int git_config_find_system(git_buf *path) { git_buf_sanitize(path); return git_sysdir_find_system_file(path, GIT_CONFIG_FILENAME_SYSTEM); } int git_config__global_location(git_buf *buf) { const git_buf *paths; const char *sep, *start; if (git_sysdir_get(&paths, GIT_SYSDIR_GLOBAL) < 0) return -1; /* no paths, so give up */ if (!paths || !git_buf_len(paths)) return -1; /* find unescaped separator or end of string */ for (sep = start = git_buf_cstr(paths); *sep; ++sep) { if (*sep == GIT_PATH_LIST_SEPARATOR && (sep <= start || sep[-1] != '\\')) break; } if (git_buf_set(buf, start, (size_t)(sep - start)) < 0) return -1; return git_buf_joinpath(buf, buf->ptr, GIT_CONFIG_FILENAME_GLOBAL); } int git_config_open_default(git_config **out) { int error; git_config *cfg = NULL; git_buf buf = GIT_BUF_INIT; if ((error = git_config_new(&cfg)) < 0) return error; if (!git_config_find_global(&buf) || !git_config__global_location(&buf)) { error = git_config_add_file_ondisk(cfg, buf.ptr, GIT_CONFIG_LEVEL_GLOBAL, 0); } if (!error && !git_config_find_xdg(&buf)) error = git_config_add_file_ondisk(cfg, buf.ptr, GIT_CONFIG_LEVEL_XDG, 0); if (!error && !git_config_find_system(&buf)) error = git_config_add_file_ondisk(cfg, buf.ptr, GIT_CONFIG_LEVEL_SYSTEM, 0); git_buf_free(&buf); if (error) { git_config_free(cfg); cfg = NULL; } *out = cfg; return error; } int git_config_lock(git_transaction **out, git_config *cfg) { int error; git_config_backend *file; file_internal *internal; internal = git_vector_get(&cfg->files, 0); if (!internal || !internal->file) { giterr_set(GITERR_CONFIG, "cannot lock; the config has no backends/files"); return -1; } file = internal->file; if ((error = file->lock(file)) < 0) return error; return git_transaction_config_new(out, cfg); } int git_config_unlock(git_config *cfg, int commit) { git_config_backend *file; file_internal *internal; internal = git_vector_get(&cfg->files, 0); if (!internal || !internal->file) { giterr_set(GITERR_CONFIG, "cannot lock; the config has no backends/files"); return -1; } file = internal->file; return file->unlock(file, commit); } /*********** * Parsers ***********/ int git_config_lookup_map_value( int *out, const git_cvar_map *maps, size_t map_n, const char *value) { size_t i; if (!value) goto fail_parse; for (i = 0; i < map_n; ++i) { const git_cvar_map *m = maps + i; switch (m->cvar_type) { case GIT_CVAR_FALSE: case GIT_CVAR_TRUE: { int bool_val; if (git__parse_bool(&bool_val, value) == 0 && bool_val == (int)m->cvar_type) { *out = m->map_value; return 0; } break; } case GIT_CVAR_INT32: if (git_config_parse_int32(out, value) == 0) return 0; break; case GIT_CVAR_STRING: if (strcasecmp(value, m->str_match) == 0) { *out = m->map_value; return 0; } break; } } fail_parse: giterr_set(GITERR_CONFIG, "Failed to map '%s'", value); return -1; } int git_config_lookup_map_enum(git_cvar_t *type_out, const char **str_out, const git_cvar_map *maps, size_t map_n, int enum_val) { size_t i; for (i = 0; i < map_n; i++) { const git_cvar_map *m = &maps[i]; if (m->map_value != enum_val) continue; *type_out = m->cvar_type; *str_out = m->str_match; return 0; } giterr_set(GITERR_CONFIG, "invalid enum value"); return GIT_ENOTFOUND; } int git_config_parse_bool(int *out, const char *value) { if (git__parse_bool(out, value) == 0) return 0; if (git_config_parse_int32(out, value) == 0) { *out = !!(*out); return 0; } giterr_set(GITERR_CONFIG, "Failed to parse '%s' as a boolean value", value); return -1; } int git_config_parse_int64(int64_t *out, const char *value) { const char *num_end; int64_t num; if (!value || git__strtol64(&num, value, &num_end, 0) < 0) goto fail_parse; switch (*num_end) { case 'g': case 'G': num *= 1024; /* fallthrough */ case 'm': case 'M': num *= 1024; /* fallthrough */ case 'k': case 'K': num *= 1024; /* check that that there are no more characters after the * given modifier suffix */ if (num_end[1] != '\0') return -1; /* fallthrough */ case '\0': *out = num; return 0; default: goto fail_parse; } fail_parse: giterr_set(GITERR_CONFIG, "Failed to parse '%s' as an integer", value ? value : "(null)"); return -1; } int git_config_parse_int32(int32_t *out, const char *value) { int64_t tmp; int32_t truncate; if (git_config_parse_int64(&tmp, value) < 0) goto fail_parse; truncate = tmp & 0xFFFFFFFF; if (truncate != tmp) goto fail_parse; *out = truncate; return 0; fail_parse: giterr_set(GITERR_CONFIG, "Failed to parse '%s' as a 32-bit integer", value ? value : "(null)"); return -1; } int git_config_parse_path(git_buf *out, const char *value) { int error = 0; const git_buf *home; assert(out && value); git_buf_sanitize(out); if (value[0] == '~') { if (value[1] != '\0' && value[1] != '/') { giterr_set(GITERR_CONFIG, "retrieving a homedir by name is not supported"); return -1; } if ((error = git_sysdir_get(&home, GIT_SYSDIR_GLOBAL)) < 0) return error; git_buf_sets(out, home->ptr); git_buf_puts(out, value + 1); if (git_buf_oom(out)) return -1; return 0; } return git_buf_sets(out, value); } /* Take something the user gave us and make it nice for our hash function */ int git_config__normalize_name(const char *in, char **out) { char *name, *fdot, *ldot; assert(in && out); name = git__strdup(in); GITERR_CHECK_ALLOC(name); fdot = strchr(name, '.'); ldot = strrchr(name, '.'); if (fdot == NULL || fdot == name || ldot == NULL || !ldot[1]) goto invalid; /* Validate and downcase up to first dot and after last dot */ if (git_config_file_normalize_section(name, fdot) < 0 || git_config_file_normalize_section(ldot + 1, NULL) < 0) goto invalid; /* If there is a middle range, make sure it doesn't have newlines */ while (fdot < ldot) if (*fdot++ == '\n') goto invalid; *out = name; return 0; invalid: git__free(name); giterr_set(GITERR_CONFIG, "Invalid config item name '%s'", in); return GIT_EINVALIDSPEC; } struct rename_data { git_config *config; git_buf *name; size_t old_len; }; static int rename_config_entries_cb( const git_config_entry *entry, void *payload) { int error = 0; struct rename_data *data = (struct rename_data *)payload; size_t base_len = git_buf_len(data->name); if (base_len > 0 && !(error = git_buf_puts(data->name, entry->name + data->old_len))) { error = git_config_set_string( data->config, git_buf_cstr(data->name), entry->value); git_buf_truncate(data->name, base_len); } if (!error) error = git_config_delete_entry(data->config, entry->name); return error; } int git_config_rename_section( git_repository *repo, const char *old_section_name, const char *new_section_name) { git_config *config; git_buf pattern = GIT_BUF_INIT, replace = GIT_BUF_INIT; int error = 0; struct rename_data data; git_buf_text_puts_escape_regex(&pattern, old_section_name); if ((error = git_buf_puts(&pattern, "\\..+")) < 0) goto cleanup; if ((error = git_repository_config__weakptr(&config, repo)) < 0) goto cleanup; data.config = config; data.name = &replace; data.old_len = strlen(old_section_name) + 1; if ((error = git_buf_join(&replace, '.', new_section_name, "")) < 0) goto cleanup; if (new_section_name != NULL && (error = git_config_file_normalize_section( replace.ptr, strchr(replace.ptr, '.'))) < 0) { giterr_set( GITERR_CONFIG, "Invalid config section '%s'", new_section_name); goto cleanup; } error = git_config_foreach_match( config, git_buf_cstr(&pattern), rename_config_entries_cb, &data); cleanup: git_buf_free(&pattern); git_buf_free(&replace); return error; } int git_config_init_backend(git_config_backend *backend, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( backend, version, git_config_backend, GIT_CONFIG_BACKEND_INIT); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/ignore.c0000664000175000017500000003226212610310643015322 0ustar #include "git2/ignore.h" #include "common.h" #include "ignore.h" #include "attrcache.h" #include "path.h" #include "config.h" #include "fnmatch.h" #define GIT_IGNORE_INTERNAL "[internal]exclude" #define GIT_IGNORE_DEFAULT_RULES ".\n..\n.git\n" /** * A negative ignore pattern can match a positive one without * wildcards if its pattern equals the tail of the positive * pattern. Thus * * foo/bar * !bar * * would result in foo/bar being unignored again. */ static int does_negate_pattern(git_attr_fnmatch *rule, git_attr_fnmatch *neg) { char *p; if ((rule->flags & GIT_ATTR_FNMATCH_NEGATIVE) == 0 && (neg->flags & GIT_ATTR_FNMATCH_NEGATIVE) != 0) { /* * no chance of matching if rule is shorter than * the negated one */ if (rule->length < neg->length) return false; /* * shift pattern so its tail aligns with the * negated pattern */ p = rule->pattern + rule->length - neg->length; if (strcmp(p, neg->pattern) == 0) return true; } return false; } /** * A negative ignore can only unignore a file which is given explicitly before, thus * * foo * !foo/bar * * does not unignore 'foo/bar' as it's not in the list. However * * foo/ * !foo/bar * * does unignore 'foo/bar', as it is contained within the 'foo/' rule. */ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match) { int error = 0; size_t i; git_attr_fnmatch *rule; char *path; git_buf buf = GIT_BUF_INIT; *out = 0; /* path of the file relative to the workdir, so we match the rules in subdirs */ if (match->containing_dir) { git_buf_puts(&buf, match->containing_dir); } if (git_buf_puts(&buf, match->pattern) < 0) return -1; path = git_buf_detach(&buf); git_vector_foreach(rules, i, rule) { if (!(rule->flags & GIT_ATTR_FNMATCH_HASWILD)) { if (does_negate_pattern(rule, match)) { error = 0; *out = 1; goto out; } else continue; } /* * When dealing with a directory, we add '/' so * p_fnmatch() honours FNM_PATHNAME. Checking for LEADINGDIR * alone isn't enough as that's also set for nagations, so we * need to check that NEGATIVE is off. */ git_buf_clear(&buf); if (rule->containing_dir) { git_buf_puts(&buf, rule->containing_dir); } error = git_buf_puts(&buf, rule->pattern); if ((rule->flags & (GIT_ATTR_FNMATCH_LEADINGDIR | GIT_ATTR_FNMATCH_NEGATIVE)) == GIT_ATTR_FNMATCH_LEADINGDIR) error = git_buf_PUTS(&buf, "/*"); if (error < 0) goto out; if ((error = p_fnmatch(git_buf_cstr(&buf), path, FNM_PATHNAME)) < 0) { giterr_set(GITERR_INVALID, "error matching pattern"); goto out; } /* if we found a match, we want to keep this rule */ if (error != FNM_NOMATCH) { *out = 1; error = 0; goto out; } } error = 0; out: git__free(path); git_buf_free(&buf); return error; } static int parse_ignore_file( git_repository *repo, git_attr_file *attrs, const char *data) { int error = 0; int ignore_case = false; const char *scan = data, *context = NULL; git_attr_fnmatch *match = NULL; if (git_repository__cvar(&ignore_case, repo, GIT_CVAR_IGNORECASE) < 0) giterr_clear(); /* if subdir file path, convert context for file paths */ if (attrs->entry && git_path_root(attrs->entry->path) < 0 && !git__suffixcmp(attrs->entry->path, "/" GIT_IGNORE_FILE)) context = attrs->entry->path; if (git_mutex_lock(&attrs->lock) < 0) { giterr_set(GITERR_OS, "Failed to lock ignore file"); return -1; } while (!error && *scan) { int valid_rule = 1; if (!match && !(match = git__calloc(1, sizeof(*match)))) { error = -1; break; } match->flags = GIT_ATTR_FNMATCH_ALLOWSPACE | GIT_ATTR_FNMATCH_ALLOWNEG; if (!(error = git_attr_fnmatch__parse( match, &attrs->pool, context, &scan))) { match->flags |= GIT_ATTR_FNMATCH_IGNORE; if (ignore_case) match->flags |= GIT_ATTR_FNMATCH_ICASE; scan = git__next_line(scan); /* if a negative match doesn't actually do anything, throw it away */ if (match->flags & GIT_ATTR_FNMATCH_NEGATIVE) error = does_negate_rule(&valid_rule, &attrs->rules, match); if (!error && valid_rule) error = git_vector_insert(&attrs->rules, match); } if (error != 0 || !valid_rule) { match->pattern = NULL; if (error == GIT_ENOTFOUND) error = 0; } else { match = NULL; /* vector now "owns" the match */ } } git_mutex_unlock(&attrs->lock); git__free(match); return error; } static int push_ignore_file( git_ignores *ignores, git_vector *which_list, const char *base, const char *filename) { int error = 0; git_attr_file *file = NULL; error = git_attr_cache__get( &file, ignores->repo, NULL, GIT_ATTR_FILE__FROM_FILE, base, filename, parse_ignore_file); if (error < 0) return error; if (file != NULL) { if ((error = git_vector_insert(which_list, file)) < 0) git_attr_file__free(file); } return error; } static int push_one_ignore(void *payload, const char *path) { git_ignores *ign = payload; ign->depth++; return push_ignore_file(ign, &ign->ign_path, path, GIT_IGNORE_FILE); } static int get_internal_ignores(git_attr_file **out, git_repository *repo) { int error; if ((error = git_attr_cache__init(repo)) < 0) return error; error = git_attr_cache__get( out, repo, NULL, GIT_ATTR_FILE__IN_MEMORY, NULL, GIT_IGNORE_INTERNAL, NULL); /* if internal rules list is empty, insert default rules */ if (!error && !(*out)->rules.length) error = parse_ignore_file(repo, *out, GIT_IGNORE_DEFAULT_RULES); return error; } int git_ignore__for_path( git_repository *repo, const char *path, git_ignores *ignores) { int error = 0; const char *workdir = git_repository_workdir(repo); assert(ignores && path); memset(ignores, 0, sizeof(*ignores)); ignores->repo = repo; /* Read the ignore_case flag */ if ((error = git_repository__cvar( &ignores->ignore_case, repo, GIT_CVAR_IGNORECASE)) < 0) goto cleanup; if ((error = git_attr_cache__init(repo)) < 0) goto cleanup; /* given a unrooted path in a non-bare repo, resolve it */ if (workdir && git_path_root(path) < 0) error = git_path_find_dir(&ignores->dir, path, workdir); else error = git_buf_joinpath(&ignores->dir, path, ""); if (error < 0) goto cleanup; if (workdir && !git__prefixcmp(ignores->dir.ptr, workdir)) ignores->dir_root = strlen(workdir); /* set up internals */ if ((error = get_internal_ignores(&ignores->ign_internal, repo)) < 0) goto cleanup; /* load .gitignore up the path */ if (workdir != NULL) { error = git_path_walk_up( &ignores->dir, workdir, push_one_ignore, ignores); if (error < 0) goto cleanup; } /* load .git/info/exclude */ error = push_ignore_file( ignores, &ignores->ign_global, git_repository_path(repo), GIT_IGNORE_FILE_INREPO); if (error < 0) goto cleanup; /* load core.excludesfile */ if (git_repository_attr_cache(repo)->cfg_excl_file != NULL) error = push_ignore_file( ignores, &ignores->ign_global, NULL, git_repository_attr_cache(repo)->cfg_excl_file); cleanup: if (error < 0) git_ignore__free(ignores); return error; } int git_ignore__push_dir(git_ignores *ign, const char *dir) { if (git_buf_joinpath(&ign->dir, ign->dir.ptr, dir) < 0) return -1; ign->depth++; return push_ignore_file( ign, &ign->ign_path, ign->dir.ptr, GIT_IGNORE_FILE); } int git_ignore__pop_dir(git_ignores *ign) { if (ign->ign_path.length > 0) { git_attr_file *file = git_vector_last(&ign->ign_path); const char *start = file->entry->path, *end; /* - ign->dir looks something like "/home/user/a/b/" (or "a/b/c/d/") * - file->path looks something like "a/b/.gitignore * * We are popping the last directory off ign->dir. We also want * to remove the file from the vector if the popped directory * matches the ignore path. We need to test if the "a/b" part of * the file key matches the path we are about to pop. */ if ((end = strrchr(start, '/')) != NULL) { size_t dirlen = (end - start) + 1; const char *relpath = ign->dir.ptr + ign->dir_root; size_t pathlen = ign->dir.size - ign->dir_root; if (pathlen == dirlen && !memcmp(relpath, start, dirlen)) { git_vector_pop(&ign->ign_path); git_attr_file__free(file); } } } if (--ign->depth > 0) { git_buf_rtruncate_at_char(&ign->dir, '/'); git_path_to_dir(&ign->dir); } return 0; } void git_ignore__free(git_ignores *ignores) { unsigned int i; git_attr_file *file; git_attr_file__free(ignores->ign_internal); git_vector_foreach(&ignores->ign_path, i, file) { git_attr_file__free(file); ignores->ign_path.contents[i] = NULL; } git_vector_free(&ignores->ign_path); git_vector_foreach(&ignores->ign_global, i, file) { git_attr_file__free(file); ignores->ign_global.contents[i] = NULL; } git_vector_free(&ignores->ign_global); git_buf_free(&ignores->dir); } static bool ignore_lookup_in_rules( int *ignored, git_attr_file *file, git_attr_path *path) { size_t j; git_attr_fnmatch *match; git_vector_rforeach(&file->rules, j, match) { if (git_attr_fnmatch__match(match, path)) { *ignored = ((match->flags & GIT_ATTR_FNMATCH_NEGATIVE) == 0) ? GIT_IGNORE_TRUE : GIT_IGNORE_FALSE; return true; } } return false; } int git_ignore__lookup( int *out, git_ignores *ignores, const char *pathname, git_dir_flag dir_flag) { unsigned int i; git_attr_file *file; git_attr_path path; *out = GIT_IGNORE_NOTFOUND; if (git_attr_path__init( &path, pathname, git_repository_workdir(ignores->repo), dir_flag) < 0) return -1; /* first process builtins - success means path was found */ if (ignore_lookup_in_rules(out, ignores->ign_internal, &path)) goto cleanup; /* next process files in the path */ git_vector_foreach(&ignores->ign_path, i, file) { if (ignore_lookup_in_rules(out, file, &path)) goto cleanup; } /* last process global ignores */ git_vector_foreach(&ignores->ign_global, i, file) { if (ignore_lookup_in_rules(out, file, &path)) goto cleanup; } cleanup: git_attr_path__free(&path); return 0; } int git_ignore_add_rule(git_repository *repo, const char *rules) { int error; git_attr_file *ign_internal = NULL; if ((error = get_internal_ignores(&ign_internal, repo)) < 0) return error; error = parse_ignore_file(repo, ign_internal, rules); git_attr_file__free(ign_internal); return error; } int git_ignore_clear_internal_rules(git_repository *repo) { int error; git_attr_file *ign_internal; if ((error = get_internal_ignores(&ign_internal, repo)) < 0) return error; if (!(error = git_attr_file__clear_rules(ign_internal, true))) error = parse_ignore_file( repo, ign_internal, GIT_IGNORE_DEFAULT_RULES); git_attr_file__free(ign_internal); return error; } int git_ignore_path_is_ignored( int *ignored, git_repository *repo, const char *pathname) { int error; const char *workdir; git_attr_path path; git_ignores ignores; unsigned int i; git_attr_file *file; assert(ignored && pathname); workdir = repo ? git_repository_workdir(repo) : NULL; memset(&path, 0, sizeof(path)); memset(&ignores, 0, sizeof(ignores)); if ((error = git_attr_path__init(&path, pathname, workdir, GIT_DIR_FLAG_UNKNOWN)) < 0 || (error = git_ignore__for_path(repo, path.path, &ignores)) < 0) goto cleanup; while (1) { /* first process builtins - success means path was found */ if (ignore_lookup_in_rules(ignored, ignores.ign_internal, &path)) goto cleanup; /* next process files in the path */ git_vector_foreach(&ignores.ign_path, i, file) { if (ignore_lookup_in_rules(ignored, file, &path)) goto cleanup; } /* last process global ignores */ git_vector_foreach(&ignores.ign_global, i, file) { if (ignore_lookup_in_rules(ignored, file, &path)) goto cleanup; } /* move up one directory */ if (path.basename == path.path) break; path.basename[-1] = '\0'; while (path.basename > path.path && *path.basename != '/') path.basename--; if (path.basename > path.path) path.basename++; path.is_dir = 1; if ((error = git_ignore__pop_dir(&ignores)) < 0) break; } *ignored = 0; cleanup: git_attr_path__free(&path); git_ignore__free(&ignores); return error; } int git_ignore__check_pathspec_for_exact_ignores( git_repository *repo, git_vector *vspec, bool no_fnmatch) { int error = 0; size_t i; git_attr_fnmatch *match; int ignored; git_buf path = GIT_BUF_INIT; const char *wd, *filename; git_index *idx; if ((error = git_repository__ensure_not_bare( repo, "validate pathspec")) < 0 || (error = git_repository_index(&idx, repo)) < 0) return error; wd = git_repository_workdir(repo); git_vector_foreach(vspec, i, match) { /* skip wildcard matches (if they are being used) */ if ((match->flags & GIT_ATTR_FNMATCH_HASWILD) != 0 && !no_fnmatch) continue; filename = match->pattern; /* if file is already in the index, it's fine */ if (git_index_get_bypath(idx, filename, 0) != NULL) continue; if ((error = git_buf_joinpath(&path, wd, filename)) < 0) break; /* is there a file on disk that matches this exactly? */ if (!git_path_isfile(path.ptr)) continue; /* is that file ignored? */ if ((error = git_ignore_path_is_ignored(&ignored, repo, filename)) < 0) break; if (ignored) { giterr_set(GITERR_INVALID, "pathspec contains ignored file '%s'", filename); error = GIT_EINVALIDSPEC; break; } } git_index_free(idx); git_buf_free(&path); return error; } deps/libgit2-sys-0.3.8/libgit2/src/commit_list.c0000664000175000017500000001143612610310643016362 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "commit_list.h" #include "common.h" #include "revwalk.h" #include "pool.h" #include "odb.h" int git_commit_list_time_cmp(const void *a, const void *b) { const git_commit_list_node *commit_a = a; const git_commit_list_node *commit_b = b; return (commit_a->time < commit_b->time); } git_commit_list *git_commit_list_insert(git_commit_list_node *item, git_commit_list **list_p) { git_commit_list *new_list = git__malloc(sizeof(git_commit_list)); if (new_list != NULL) { new_list->item = item; new_list->next = *list_p; } *list_p = new_list; return new_list; } git_commit_list *git_commit_list_insert_by_date(git_commit_list_node *item, git_commit_list **list_p) { git_commit_list **pp = list_p; git_commit_list *p; while ((p = *pp) != NULL) { if (git_commit_list_time_cmp(p->item, item) > 0) break; pp = &p->next; } return git_commit_list_insert(item, pp); } git_commit_list_node *git_commit_list_alloc_node(git_revwalk *walk) { return (git_commit_list_node *)git_pool_malloc(&walk->commit_pool, COMMIT_ALLOC); } static int commit_error(git_commit_list_node *commit, const char *msg) { char commit_oid[GIT_OID_HEXSZ + 1]; git_oid_fmt(commit_oid, &commit->oid); commit_oid[GIT_OID_HEXSZ] = '\0'; giterr_set(GITERR_ODB, "Failed to parse commit %s - %s", commit_oid, msg); return -1; } static git_commit_list_node **alloc_parents( git_revwalk *walk, git_commit_list_node *commit, size_t n_parents) { if (n_parents <= PARENTS_PER_COMMIT) return (git_commit_list_node **)((char *)commit + sizeof(git_commit_list_node)); return (git_commit_list_node **)git_pool_malloc( &walk->commit_pool, (uint32_t)(n_parents * sizeof(git_commit_list_node *))); } void git_commit_list_free(git_commit_list **list_p) { git_commit_list *list = *list_p; if (list == NULL) return; while (list) { git_commit_list *temp = list; list = temp->next; git__free(temp); } *list_p = NULL; } git_commit_list_node *git_commit_list_pop(git_commit_list **stack) { git_commit_list *top = *stack; git_commit_list_node *item = top ? top->item : NULL; if (top) { *stack = top->next; git__free(top); } return item; } static int commit_quick_parse( git_revwalk *walk, git_commit_list_node *commit, const uint8_t *buffer, size_t buffer_len) { const size_t parent_len = strlen("parent ") + GIT_OID_HEXSZ + 1; const uint8_t *buffer_end = buffer + buffer_len; const uint8_t *parents_start, *committer_start; int i, parents = 0; int64_t commit_time; buffer += strlen("tree ") + GIT_OID_HEXSZ + 1; parents_start = buffer; while (buffer + parent_len < buffer_end && memcmp(buffer, "parent ", strlen("parent ")) == 0) { parents++; buffer += parent_len; } commit->parents = alloc_parents(walk, commit, parents); GITERR_CHECK_ALLOC(commit->parents); buffer = parents_start; for (i = 0; i < parents; ++i) { git_oid oid; if (git_oid_fromstr(&oid, (const char *)buffer + strlen("parent ")) < 0) return -1; commit->parents[i] = git_revwalk__commit_lookup(walk, &oid); if (commit->parents[i] == NULL) return -1; buffer += parent_len; } commit->out_degree = (unsigned short)parents; if ((committer_start = buffer = memchr(buffer, '\n', buffer_end - buffer)) == NULL) return commit_error(commit, "object is corrupted"); buffer++; if ((buffer = memchr(buffer, '\n', buffer_end - buffer)) == NULL) return commit_error(commit, "object is corrupted"); /* Skip trailing spaces */ while (buffer > committer_start && git__isspace(*buffer)) buffer--; /* Seek for the beginning of the pack of digits */ while (buffer > committer_start && git__isdigit(*buffer)) buffer--; /* Skip potential timezone offset */ if ((buffer > committer_start) && (*buffer == '+' || *buffer == '-')) { buffer--; while (buffer > committer_start && git__isspace(*buffer)) buffer--; while (buffer > committer_start && git__isdigit(*buffer)) buffer--; } if ((buffer == committer_start) || (git__strtol64(&commit_time, (char *)(buffer + 1), NULL, 10) < 0)) return commit_error(commit, "cannot parse commit time"); commit->time = commit_time; commit->parsed = 1; return 0; } int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit) { git_odb_object *obj; int error; if (commit->parsed) return 0; if ((error = git_odb_read(&obj, walk->odb, &commit->oid)) < 0) return error; if (obj->cached.type != GIT_OBJ_COMMIT) { giterr_set(GITERR_INVALID, "Object is no commit object"); error = -1; } else error = commit_quick_parse( walk, commit, (const uint8_t *)git_odb_object_data(obj), git_odb_object_size(obj)); git_odb_object_free(obj); return error; } deps/libgit2-sys-0.3.8/libgit2/src/oid.h0000664000175000017500000000212612426525445014630 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_oid_h__ #define INCLUDE_oid_h__ #include "git2/oid.h" /** * Format a git_oid into a newly allocated c-string. * * The c-string is owned by the caller and needs to be manually freed. * * @param id the oid structure to format * @return the c-string; NULL if memory is exhausted. Caller must * deallocate the string with git__free(). */ char *git_oid_allocfmt(const git_oid *id); GIT_INLINE(int) git_oid__hashcmp(const unsigned char *sha1, const unsigned char *sha2) { int i; for (i = 0; i < GIT_OID_RAWSZ; i++, sha1++, sha2++) { if (*sha1 != *sha2) return *sha1 - *sha2; } return 0; } /* * Compare two oid structures. * * @param a first oid structure. * @param b second oid structure. * @return <0, 0, >0 if a < b, a == b, a > b. */ GIT_INLINE(int) git_oid__cmp(const git_oid *a, const git_oid *b) { return git_oid__hashcmp(a->id, b->id); } #endif deps/libgit2-sys-0.3.8/libgit2/src/diff.c0000664000175000017500000014257612610310643014761 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "diff.h" #include "fileops.h" #include "config.h" #include "attr_file.h" #include "filter.h" #include "pathspec.h" #include "index.h" #include "odb.h" #include "submodule.h" #define DIFF_FLAG_IS_SET(DIFF,FLAG) (((DIFF)->opts.flags & (FLAG)) != 0) #define DIFF_FLAG_ISNT_SET(DIFF,FLAG) (((DIFF)->opts.flags & (FLAG)) == 0) #define DIFF_FLAG_SET(DIFF,FLAG,VAL) (DIFF)->opts.flags = \ (VAL) ? ((DIFF)->opts.flags | (FLAG)) : ((DIFF)->opts.flags & ~(VAL)) static git_diff_delta *diff_delta__alloc( git_diff *diff, git_delta_t status, const char *path) { git_diff_delta *delta = git__calloc(1, sizeof(git_diff_delta)); if (!delta) return NULL; delta->old_file.path = git_pool_strdup(&diff->pool, path); if (delta->old_file.path == NULL) { git__free(delta); return NULL; } delta->new_file.path = delta->old_file.path; if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) { switch (status) { case GIT_DELTA_ADDED: status = GIT_DELTA_DELETED; break; case GIT_DELTA_DELETED: status = GIT_DELTA_ADDED; break; default: break; /* leave other status values alone */ } } delta->status = status; return delta; } static int diff_insert_delta( git_diff *diff, git_diff_delta *delta, const char *matched_pathspec) { int error = 0; if (diff->opts.notify_cb) { error = diff->opts.notify_cb( diff, delta, matched_pathspec, diff->opts.notify_payload); if (error) { git__free(delta); if (error > 0) /* positive value means to skip this delta */ return 0; else /* negative value means to cancel diff */ return giterr_set_after_callback_function(error, "git_diff"); } } if ((error = git_vector_insert(&diff->deltas, delta)) < 0) git__free(delta); return error; } static bool diff_pathspec_match( const char **matched_pathspec, git_diff *diff, const git_index_entry *entry) { bool disable_pathspec_match = DIFF_FLAG_IS_SET(diff, GIT_DIFF_DISABLE_PATHSPEC_MATCH); /* If we're disabling fnmatch, then the iterator has already applied * the filters to the files for us and we don't have to do anything. * However, this only applies to *files* - the iterator will include * directories that we need to recurse into when not autoexpanding, * so we still need to apply the pathspec match to directories. */ if ((S_ISLNK(entry->mode) || S_ISREG(entry->mode)) && disable_pathspec_match) { *matched_pathspec = entry->path; return true; } return git_pathspec__match( &diff->pathspec, entry->path, disable_pathspec_match, DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_CASE), matched_pathspec, NULL); } static int diff_delta__from_one( git_diff *diff, git_delta_t status, const git_index_entry *oitem, const git_index_entry *nitem) { const git_index_entry *entry = nitem; bool has_old = false; git_diff_delta *delta; const char *matched_pathspec; assert((oitem != NULL) ^ (nitem != NULL)); if (oitem) { entry = oitem; has_old = true; } if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) has_old = !has_old; if ((entry->flags & GIT_IDXENTRY_VALID) != 0) return 0; if (status == GIT_DELTA_IGNORED && DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_IGNORED)) return 0; if (status == GIT_DELTA_UNTRACKED && DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_UNTRACKED)) return 0; if (status == GIT_DELTA_UNREADABLE && DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_UNREADABLE)) return 0; if (!diff_pathspec_match(&matched_pathspec, diff, entry)) return 0; delta = diff_delta__alloc(diff, status, entry->path); GITERR_CHECK_ALLOC(delta); /* This fn is just for single-sided diffs */ assert(status != GIT_DELTA_MODIFIED); delta->nfiles = 1; if (has_old) { delta->old_file.mode = entry->mode; delta->old_file.size = entry->file_size; delta->old_file.flags |= GIT_DIFF_FLAG_EXISTS; git_oid_cpy(&delta->old_file.id, &entry->id); } else /* ADDED, IGNORED, UNTRACKED */ { delta->new_file.mode = entry->mode; delta->new_file.size = entry->file_size; delta->new_file.flags |= GIT_DIFF_FLAG_EXISTS; git_oid_cpy(&delta->new_file.id, &entry->id); } delta->old_file.flags |= GIT_DIFF_FLAG_VALID_ID; if (has_old || !git_oid_iszero(&delta->new_file.id)) delta->new_file.flags |= GIT_DIFF_FLAG_VALID_ID; return diff_insert_delta(diff, delta, matched_pathspec); } static int diff_delta__from_two( git_diff *diff, git_delta_t status, const git_index_entry *old_entry, uint32_t old_mode, const git_index_entry *new_entry, uint32_t new_mode, const git_oid *new_id, const char *matched_pathspec) { const git_oid *old_id = &old_entry->id; git_diff_delta *delta; const char *canonical_path = old_entry->path; if (status == GIT_DELTA_UNMODIFIED && DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_UNMODIFIED)) return 0; if (!new_id) new_id = &new_entry->id; if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) { uint32_t temp_mode = old_mode; const git_index_entry *temp_entry = old_entry; const git_oid *temp_id = old_id; old_entry = new_entry; new_entry = temp_entry; old_mode = new_mode; new_mode = temp_mode; old_id = new_id; new_id = temp_id; } delta = diff_delta__alloc(diff, status, canonical_path); GITERR_CHECK_ALLOC(delta); delta->nfiles = 2; if (!git_index_entry_is_conflict(old_entry)) { delta->old_file.size = old_entry->file_size; delta->old_file.mode = old_mode; git_oid_cpy(&delta->old_file.id, old_id); delta->old_file.flags |= GIT_DIFF_FLAG_VALID_ID | GIT_DIFF_FLAG_EXISTS; } if (!git_index_entry_is_conflict(new_entry)) { git_oid_cpy(&delta->new_file.id, new_id); delta->new_file.size = new_entry->file_size; delta->new_file.mode = new_mode; delta->old_file.flags |= GIT_DIFF_FLAG_EXISTS; delta->new_file.flags |= GIT_DIFF_FLAG_EXISTS; if (!git_oid_iszero(&new_entry->id)) delta->new_file.flags |= GIT_DIFF_FLAG_VALID_ID; } return diff_insert_delta(diff, delta, matched_pathspec); } static git_diff_delta *diff_delta__last_for_item( git_diff *diff, const git_index_entry *item) { git_diff_delta *delta = git_vector_last(&diff->deltas); if (!delta) return NULL; switch (delta->status) { case GIT_DELTA_UNMODIFIED: case GIT_DELTA_DELETED: if (git_oid__cmp(&delta->old_file.id, &item->id) == 0) return delta; break; case GIT_DELTA_ADDED: if (git_oid__cmp(&delta->new_file.id, &item->id) == 0) return delta; break; case GIT_DELTA_UNREADABLE: case GIT_DELTA_UNTRACKED: if (diff->strcomp(delta->new_file.path, item->path) == 0 && git_oid__cmp(&delta->new_file.id, &item->id) == 0) return delta; break; case GIT_DELTA_MODIFIED: if (git_oid__cmp(&delta->old_file.id, &item->id) == 0 || git_oid__cmp(&delta->new_file.id, &item->id) == 0) return delta; break; default: break; } return NULL; } static char *diff_strdup_prefix(git_pool *pool, const char *prefix) { size_t len = strlen(prefix); /* append '/' at end if needed */ if (len > 0 && prefix[len - 1] != '/') return git_pool_strcat(pool, prefix, "/"); else return git_pool_strndup(pool, prefix, len + 1); } GIT_INLINE(const char *) diff_delta__path(const git_diff_delta *delta) { const char *str = delta->old_file.path; if (!str || delta->status == GIT_DELTA_ADDED || delta->status == GIT_DELTA_RENAMED || delta->status == GIT_DELTA_COPIED) str = delta->new_file.path; return str; } const char *git_diff_delta__path(const git_diff_delta *delta) { return diff_delta__path(delta); } int git_diff_delta__cmp(const void *a, const void *b) { const git_diff_delta *da = a, *db = b; int val = strcmp(diff_delta__path(da), diff_delta__path(db)); return val ? val : ((int)da->status - (int)db->status); } int git_diff_delta__casecmp(const void *a, const void *b) { const git_diff_delta *da = a, *db = b; int val = strcasecmp(diff_delta__path(da), diff_delta__path(db)); return val ? val : ((int)da->status - (int)db->status); } GIT_INLINE(const char *) diff_delta__i2w_path(const git_diff_delta *delta) { return delta->old_file.path ? delta->old_file.path : delta->new_file.path; } int git_diff_delta__i2w_cmp(const void *a, const void *b) { const git_diff_delta *da = a, *db = b; int val = strcmp(diff_delta__i2w_path(da), diff_delta__i2w_path(db)); return val ? val : ((int)da->status - (int)db->status); } int git_diff_delta__i2w_casecmp(const void *a, const void *b) { const git_diff_delta *da = a, *db = b; int val = strcasecmp(diff_delta__i2w_path(da), diff_delta__i2w_path(db)); return val ? val : ((int)da->status - (int)db->status); } bool git_diff_delta__should_skip( const git_diff_options *opts, const git_diff_delta *delta) { uint32_t flags = opts ? opts->flags : 0; if (delta->status == GIT_DELTA_UNMODIFIED && (flags & GIT_DIFF_INCLUDE_UNMODIFIED) == 0) return true; if (delta->status == GIT_DELTA_IGNORED && (flags & GIT_DIFF_INCLUDE_IGNORED) == 0) return true; if (delta->status == GIT_DELTA_UNTRACKED && (flags & GIT_DIFF_INCLUDE_UNTRACKED) == 0) return true; if (delta->status == GIT_DELTA_UNREADABLE && (flags & GIT_DIFF_INCLUDE_UNREADABLE) == 0) return true; return false; } static const char *diff_mnemonic_prefix( git_iterator_type_t type, bool left_side) { const char *pfx = ""; switch (type) { case GIT_ITERATOR_TYPE_EMPTY: pfx = "c"; break; case GIT_ITERATOR_TYPE_TREE: pfx = "c"; break; case GIT_ITERATOR_TYPE_INDEX: pfx = "i"; break; case GIT_ITERATOR_TYPE_WORKDIR: pfx = "w"; break; case GIT_ITERATOR_TYPE_FS: pfx = left_side ? "1" : "2"; break; default: break; } /* note: without a deeper look at pathspecs, there is no easy way * to get the (o)bject / (w)ork tree mnemonics working... */ return pfx; } static int diff_entry_cmp(const void *a, const void *b) { const git_index_entry *entry_a = a; const git_index_entry *entry_b = b; return strcmp(entry_a->path, entry_b->path); } static int diff_entry_icmp(const void *a, const void *b) { const git_index_entry *entry_a = a; const git_index_entry *entry_b = b; return strcasecmp(entry_a->path, entry_b->path); } static void diff_set_ignore_case(git_diff *diff, bool ignore_case) { if (!ignore_case) { diff->opts.flags &= ~GIT_DIFF_IGNORE_CASE; diff->strcomp = git__strcmp; diff->strncomp = git__strncmp; diff->pfxcomp = git__prefixcmp; diff->entrycomp = diff_entry_cmp; git_vector_set_cmp(&diff->deltas, git_diff_delta__cmp); } else { diff->opts.flags |= GIT_DIFF_IGNORE_CASE; diff->strcomp = git__strcasecmp; diff->strncomp = git__strncasecmp; diff->pfxcomp = git__prefixcmp_icase; diff->entrycomp = diff_entry_icmp; git_vector_set_cmp(&diff->deltas, git_diff_delta__casecmp); } git_vector_sort(&diff->deltas); } static git_diff *diff_list_alloc( git_repository *repo, git_iterator *old_iter, git_iterator *new_iter) { git_diff_options dflt = GIT_DIFF_OPTIONS_INIT; git_diff *diff = git__calloc(1, sizeof(git_diff)); if (!diff) return NULL; assert(repo && old_iter && new_iter); GIT_REFCOUNT_INC(diff); diff->repo = repo; diff->old_src = old_iter->type; diff->new_src = new_iter->type; memcpy(&diff->opts, &dflt, sizeof(diff->opts)); if (git_vector_init(&diff->deltas, 0, git_diff_delta__cmp) < 0 || git_pool_init(&diff->pool, 1, 0) < 0) { git_diff_free(diff); return NULL; } /* Use case-insensitive compare if either iterator has * the ignore_case bit set */ diff_set_ignore_case( diff, git_iterator_ignore_case(old_iter) || git_iterator_ignore_case(new_iter)); return diff; } static int diff_list_apply_options( git_diff *diff, const git_diff_options *opts) { git_config *cfg = NULL; git_repository *repo = diff->repo; git_pool *pool = &diff->pool; int val; if (opts) { /* copy user options (except case sensitivity info from iterators) */ bool icase = DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_CASE); memcpy(&diff->opts, opts, sizeof(diff->opts)); DIFF_FLAG_SET(diff, GIT_DIFF_IGNORE_CASE, icase); /* initialize pathspec from options */ if (git_pathspec__vinit(&diff->pathspec, &opts->pathspec, pool) < 0) return -1; } /* flag INCLUDE_TYPECHANGE_TREES implies INCLUDE_TYPECHANGE */ if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE_TREES)) diff->opts.flags |= GIT_DIFF_INCLUDE_TYPECHANGE; /* flag INCLUDE_UNTRACKED_CONTENT implies INCLUDE_UNTRACKED */ if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_SHOW_UNTRACKED_CONTENT)) diff->opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED; /* load config values that affect diff behavior */ if ((val = git_repository_config_snapshot(&cfg, repo)) < 0) return val; if (!git_config__cvar(&val, cfg, GIT_CVAR_SYMLINKS) && val) diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_HAS_SYMLINKS; if (!git_config__cvar(&val, cfg, GIT_CVAR_IGNORESTAT) && val) diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_IGNORE_STAT; if ((diff->opts.flags & GIT_DIFF_IGNORE_FILEMODE) == 0 && !git_config__cvar(&val, cfg, GIT_CVAR_FILEMODE) && val) diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_TRUST_MODE_BITS; if (!git_config__cvar(&val, cfg, GIT_CVAR_TRUSTCTIME) && val) diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_TRUST_CTIME; /* Don't set GIT_DIFFCAPS_USE_DEV - compile time option in core git */ /* Set GIT_DIFFCAPS_TRUST_NANOSECS on a platform basis */ diff->diffcaps = diff->diffcaps | GIT_DIFFCAPS_TRUST_NANOSECS; /* If not given explicit `opts`, check `diff.xyz` configs */ if (!opts) { int context = git_config__get_int_force(cfg, "diff.context", 3); diff->opts.context_lines = context >= 0 ? (uint32_t)context : 3; /* add other defaults here */ } /* Reverse src info if diff is reversed */ if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) { git_iterator_type_t tmp_src = diff->old_src; diff->old_src = diff->new_src; diff->new_src = tmp_src; } /* Unset UPDATE_INDEX unless diffing workdir and index */ if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_UPDATE_INDEX) && (!(diff->old_src == GIT_ITERATOR_TYPE_WORKDIR || diff->new_src == GIT_ITERATOR_TYPE_WORKDIR) || !(diff->old_src == GIT_ITERATOR_TYPE_INDEX || diff->new_src == GIT_ITERATOR_TYPE_INDEX))) diff->opts.flags &= ~GIT_DIFF_UPDATE_INDEX; /* if ignore_submodules not explicitly set, check diff config */ if (diff->opts.ignore_submodules <= 0) { git_config_entry *entry; git_config__lookup_entry(&entry, cfg, "diff.ignoresubmodules", true); if (entry && git_submodule_parse_ignore( &diff->opts.ignore_submodules, entry->value) < 0) giterr_clear(); git_config_entry_free(entry); } /* if either prefix is not set, figure out appropriate value */ if (!diff->opts.old_prefix || !diff->opts.new_prefix) { const char *use_old = DIFF_OLD_PREFIX_DEFAULT; const char *use_new = DIFF_NEW_PREFIX_DEFAULT; if (git_config__get_bool_force(cfg, "diff.noprefix", 0)) use_old = use_new = ""; else if (git_config__get_bool_force(cfg, "diff.mnemonicprefix", 0)) { use_old = diff_mnemonic_prefix(diff->old_src, true); use_new = diff_mnemonic_prefix(diff->new_src, false); } if (!diff->opts.old_prefix) diff->opts.old_prefix = use_old; if (!diff->opts.new_prefix) diff->opts.new_prefix = use_new; } /* strdup prefix from pool so we're not dependent on external data */ diff->opts.old_prefix = diff_strdup_prefix(pool, diff->opts.old_prefix); diff->opts.new_prefix = diff_strdup_prefix(pool, diff->opts.new_prefix); if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) { const char *tmp_prefix = diff->opts.old_prefix; diff->opts.old_prefix = diff->opts.new_prefix; diff->opts.new_prefix = tmp_prefix; } git_config_free(cfg); /* check strdup results for error */ return (!diff->opts.old_prefix || !diff->opts.new_prefix) ? -1 : 0; } static void diff_list_free(git_diff *diff) { git_vector_free_deep(&diff->deltas); git_pathspec__vfree(&diff->pathspec); git_pool_clear(&diff->pool); git__memzero(diff, sizeof(*diff)); git__free(diff); } void git_diff_free(git_diff *diff) { if (!diff) return; GIT_REFCOUNT_DEC(diff, diff_list_free); } void git_diff_addref(git_diff *diff) { GIT_REFCOUNT_INC(diff); } int git_diff__oid_for_file( git_oid *out, git_diff *diff, const char *path, uint16_t mode, git_off_t size) { git_index_entry entry; memset(&entry, 0, sizeof(entry)); entry.mode = mode; entry.file_size = size; entry.path = (char *)path; return git_diff__oid_for_entry(out, diff, &entry, mode, NULL); } int git_diff__oid_for_entry( git_oid *out, git_diff *diff, const git_index_entry *src, uint16_t mode, const git_oid *update_match) { int error = 0; git_buf full_path = GIT_BUF_INIT; git_index_entry entry = *src; git_filter_list *fl = NULL; memset(out, 0, sizeof(*out)); if (git_buf_joinpath( &full_path, git_repository_workdir(diff->repo), entry.path) < 0) return -1; if (!mode) { struct stat st; diff->perf.stat_calls++; if (p_stat(full_path.ptr, &st) < 0) { error = git_path_set_error(errno, entry.path, "stat"); git_buf_free(&full_path); return error; } git_index_entry__init_from_stat( &entry, &st, (diff->diffcaps & GIT_DIFFCAPS_TRUST_MODE_BITS) != 0); } /* calculate OID for file if possible */ if (S_ISGITLINK(mode)) { git_submodule *sm; if (!git_submodule_lookup(&sm, diff->repo, entry.path)) { const git_oid *sm_oid = git_submodule_wd_id(sm); if (sm_oid) git_oid_cpy(out, sm_oid); git_submodule_free(sm); } else { /* if submodule lookup failed probably just in an intermediate * state where some init hasn't happened, so ignore the error */ giterr_clear(); } } else if (S_ISLNK(mode)) { error = git_odb__hashlink(out, full_path.ptr); diff->perf.oid_calculations++; } else if (!git__is_sizet(entry.file_size)) { giterr_set(GITERR_OS, "File size overflow (for 32-bits) on '%s'", entry.path); error = -1; } else if (!(error = git_filter_list_load( &fl, diff->repo, NULL, entry.path, GIT_FILTER_TO_ODB, GIT_FILTER_ALLOW_UNSAFE))) { int fd = git_futils_open_ro(full_path.ptr); if (fd < 0) error = fd; else { error = git_odb__hashfd_filtered( out, fd, (size_t)entry.file_size, GIT_OBJ_BLOB, fl); p_close(fd); diff->perf.oid_calculations++; } git_filter_list_free(fl); } /* update index for entry if requested */ if (!error && update_match && git_oid_equal(out, update_match)) { git_index *idx; git_index_entry updated_entry; memcpy(&updated_entry, &entry, sizeof(git_index_entry)); updated_entry.mode = mode; git_oid_cpy(&updated_entry.id, out); if (!(error = git_repository_index__weakptr(&idx, diff->repo))) { error = git_index_add(idx, &updated_entry); diff->index_updated = true; } } git_buf_free(&full_path); return error; } static bool diff_time_eq( const git_index_time *a, const git_index_time *b, bool use_nanos) { return a->seconds == b->seconds && (!use_nanos || a->nanoseconds == b->nanoseconds); } typedef struct { git_repository *repo; git_iterator *old_iter; git_iterator *new_iter; const git_index_entry *oitem; const git_index_entry *nitem; } diff_in_progress; #define MODE_BITS_MASK 0000777 static int maybe_modified_submodule( git_delta_t *status, git_oid *found_oid, git_diff *diff, diff_in_progress *info) { int error = 0; git_submodule *sub; unsigned int sm_status = 0; git_submodule_ignore_t ign = diff->opts.ignore_submodules; *status = GIT_DELTA_UNMODIFIED; if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_SUBMODULES) || ign == GIT_SUBMODULE_IGNORE_ALL) return 0; if ((error = git_submodule_lookup( &sub, diff->repo, info->nitem->path)) < 0) { /* GIT_EEXISTS means dir with .git in it was found - ignore it */ if (error == GIT_EEXISTS) { giterr_clear(); error = 0; } return error; } if (ign <= 0 && git_submodule_ignore(sub) == GIT_SUBMODULE_IGNORE_ALL) /* ignore it */; else if ((error = git_submodule__status( &sm_status, NULL, NULL, found_oid, sub, ign)) < 0) /* return error below */; /* check IS_WD_UNMODIFIED because this case is only used * when the new side of the diff is the working directory */ else if (!GIT_SUBMODULE_STATUS_IS_WD_UNMODIFIED(sm_status)) *status = GIT_DELTA_MODIFIED; /* now that we have a HEAD OID, check if HEAD moved */ else if ((sm_status & GIT_SUBMODULE_STATUS_IN_WD) != 0 && !git_oid_equal(&info->oitem->id, found_oid)) *status = GIT_DELTA_MODIFIED; git_submodule_free(sub); return error; } static int maybe_modified( git_diff *diff, diff_in_progress *info) { git_oid noid; git_delta_t status = GIT_DELTA_MODIFIED; const git_index_entry *oitem = info->oitem; const git_index_entry *nitem = info->nitem; unsigned int omode = oitem->mode; unsigned int nmode = nitem->mode; bool new_is_workdir = (info->new_iter->type == GIT_ITERATOR_TYPE_WORKDIR); bool modified_uncertain = false; const char *matched_pathspec; int error = 0; if (!diff_pathspec_match(&matched_pathspec, diff, oitem)) return 0; memset(&noid, 0, sizeof(noid)); /* on platforms with no symlinks, preserve mode of existing symlinks */ if (S_ISLNK(omode) && S_ISREG(nmode) && new_is_workdir && !(diff->diffcaps & GIT_DIFFCAPS_HAS_SYMLINKS)) nmode = omode; /* on platforms with no execmode, just preserve old mode */ if (!(diff->diffcaps & GIT_DIFFCAPS_TRUST_MODE_BITS) && (nmode & MODE_BITS_MASK) != (omode & MODE_BITS_MASK) && new_is_workdir) nmode = (nmode & ~MODE_BITS_MASK) | (omode & MODE_BITS_MASK); /* if one side is a conflict, mark the whole delta as conflicted */ if (git_index_entry_is_conflict(oitem) || git_index_entry_is_conflict(nitem)) { status = GIT_DELTA_CONFLICTED; /* support "assume unchanged" (poorly, b/c we still stat everything) */ } else if ((oitem->flags & GIT_IDXENTRY_VALID) != 0) { status = GIT_DELTA_UNMODIFIED; /* support "skip worktree" index bit */ } else if ((oitem->flags_extended & GIT_IDXENTRY_SKIP_WORKTREE) != 0) { status = GIT_DELTA_UNMODIFIED; /* if basic type of file changed, then split into delete and add */ } else if (GIT_MODE_TYPE(omode) != GIT_MODE_TYPE(nmode)) { if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE)) { status = GIT_DELTA_TYPECHANGE; } else if (nmode == GIT_FILEMODE_UNREADABLE) { if (!(error = diff_delta__from_one(diff, GIT_DELTA_DELETED, oitem, NULL))) error = diff_delta__from_one(diff, GIT_DELTA_UNREADABLE, NULL, nitem); return error; } else { if (!(error = diff_delta__from_one(diff, GIT_DELTA_DELETED, oitem, NULL))) error = diff_delta__from_one(diff, GIT_DELTA_ADDED, NULL, nitem); return error; } /* if oids and modes match (and are valid), then file is unmodified */ } else if (git_oid_equal(&oitem->id, &nitem->id) && omode == nmode && !git_oid_iszero(&oitem->id)) { status = GIT_DELTA_UNMODIFIED; /* if we have an unknown OID and a workdir iterator, then check some * circumstances that can accelerate things or need special handling */ } else if (git_oid_iszero(&nitem->id) && new_is_workdir) { bool use_ctime = ((diff->diffcaps & GIT_DIFFCAPS_TRUST_CTIME) != 0); bool use_nanos = ((diff->diffcaps & GIT_DIFFCAPS_TRUST_NANOSECS) != 0); git_index *index; git_iterator_index(&index, info->new_iter); status = GIT_DELTA_UNMODIFIED; if (S_ISGITLINK(nmode)) { if ((error = maybe_modified_submodule(&status, &noid, diff, info)) < 0) return error; } /* if the stat data looks different, then mark modified - this just * means that the OID will be recalculated below to confirm change */ else if (omode != nmode || oitem->file_size != nitem->file_size) { status = GIT_DELTA_MODIFIED; modified_uncertain = (oitem->file_size <= 0 && nitem->file_size > 0); } else if (!diff_time_eq(&oitem->mtime, &nitem->mtime, use_nanos) || (use_ctime && !diff_time_eq(&oitem->ctime, &nitem->ctime, use_nanos)) || oitem->ino != nitem->ino || oitem->uid != nitem->uid || oitem->gid != nitem->gid || (index && nitem->mtime.seconds >= index->stamp.mtime)) { status = GIT_DELTA_MODIFIED; modified_uncertain = true; } /* if mode is GITLINK and submodules are ignored, then skip */ } else if (S_ISGITLINK(nmode) && DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_SUBMODULES)) { status = GIT_DELTA_UNMODIFIED; } /* if we got here and decided that the files are modified, but we * haven't calculated the OID of the new item, then calculate it now */ if (modified_uncertain && git_oid_iszero(&nitem->id)) { const git_oid *update_check = DIFF_FLAG_IS_SET(diff, GIT_DIFF_UPDATE_INDEX) && omode == nmode ? &oitem->id : NULL; if ((error = git_diff__oid_for_entry( &noid, diff, nitem, nmode, update_check)) < 0) return error; /* if oid matches, then mark unmodified (except submodules, where * the filesystem content may be modified even if the oid still * matches between the index and the workdir HEAD) */ if (omode == nmode && !S_ISGITLINK(omode) && git_oid_equal(&oitem->id, &noid)) status = GIT_DELTA_UNMODIFIED; } /* If we want case changes, then break this into a delete of the old * and an add of the new so that consumers can act accordingly (eg, * checkout will update the case on disk.) */ if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_CASE) && DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_CASECHANGE) && strcmp(oitem->path, nitem->path) != 0) { if (!(error = diff_delta__from_one(diff, GIT_DELTA_DELETED, oitem, NULL))) error = diff_delta__from_one(diff, GIT_DELTA_ADDED, NULL, nitem); return error; } return diff_delta__from_two( diff, status, oitem, omode, nitem, nmode, git_oid_iszero(&noid) ? NULL : &noid, matched_pathspec); } static bool entry_is_prefixed( git_diff *diff, const git_index_entry *item, const git_index_entry *prefix_item) { size_t pathlen; if (!item || diff->pfxcomp(item->path, prefix_item->path) != 0) return false; pathlen = strlen(prefix_item->path); return (prefix_item->path[pathlen - 1] == '/' || item->path[pathlen] == '\0' || item->path[pathlen] == '/'); } static int iterator_current( const git_index_entry **entry, git_iterator *iterator) { int error; if ((error = git_iterator_current(entry, iterator)) == GIT_ITEROVER) { *entry = NULL; error = 0; } return error; } static int iterator_advance( const git_index_entry **entry, git_iterator *iterator) { const git_index_entry *prev_entry = *entry; int cmp, error; /* if we're looking for conflicts, we only want to report * one conflict for each file, instead of all three sides. * so if this entry is a conflict for this file, and the * previous one was a conflict for the same file, skip it. */ while ((error = git_iterator_advance(entry, iterator)) == 0) { if (!(iterator->flags & GIT_ITERATOR_INCLUDE_CONFLICTS) || !git_index_entry_is_conflict(prev_entry) || !git_index_entry_is_conflict(*entry)) break; cmp = (iterator->flags & GIT_ITERATOR_IGNORE_CASE) ? strcasecmp(prev_entry->path, (*entry)->path) : strcmp(prev_entry->path, (*entry)->path); if (cmp) break; } if (error == GIT_ITEROVER) { *entry = NULL; error = 0; } return error; } static int iterator_advance_into( const git_index_entry **entry, git_iterator *iterator) { int error; if ((error = git_iterator_advance_into(entry, iterator)) == GIT_ITEROVER) { *entry = NULL; error = 0; } return error; } static int iterator_advance_over_with_status( const git_index_entry **entry, git_iterator_status_t *status, git_iterator *iterator) { int error; if ((error = git_iterator_advance_over_with_status( entry, status, iterator)) == GIT_ITEROVER) { *entry = NULL; error = 0; } return error; } static int handle_unmatched_new_item( git_diff *diff, diff_in_progress *info) { int error = 0; const git_index_entry *nitem = info->nitem; git_delta_t delta_type = GIT_DELTA_UNTRACKED; bool contains_oitem; /* check if this is a prefix of the other side */ contains_oitem = entry_is_prefixed(diff, info->oitem, nitem); /* update delta_type if this item is conflicted */ if (git_index_entry_is_conflict(nitem)) delta_type = GIT_DELTA_CONFLICTED; /* update delta_type if this item is ignored */ else if (git_iterator_current_is_ignored(info->new_iter)) delta_type = GIT_DELTA_IGNORED; if (nitem->mode == GIT_FILEMODE_TREE) { bool recurse_into_dir = contains_oitem; /* check if user requests recursion into this type of dir */ recurse_into_dir = contains_oitem || (delta_type == GIT_DELTA_UNTRACKED && DIFF_FLAG_IS_SET(diff, GIT_DIFF_RECURSE_UNTRACKED_DIRS)) || (delta_type == GIT_DELTA_IGNORED && DIFF_FLAG_IS_SET(diff, GIT_DIFF_RECURSE_IGNORED_DIRS)); /* do not advance into directories that contain a .git file */ if (recurse_into_dir && !contains_oitem) { git_buf *full = NULL; if (git_iterator_current_workdir_path(&full, info->new_iter) < 0) return -1; if (full && git_path_contains(full, DOT_GIT)) { /* TODO: warning if not a valid git repository */ recurse_into_dir = false; } } /* still have to look into untracked directories to match core git - * with no untracked files, directory is treated as ignored */ if (!recurse_into_dir && delta_type == GIT_DELTA_UNTRACKED && DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_ENABLE_FAST_UNTRACKED_DIRS)) { git_diff_delta *last; git_iterator_status_t untracked_state; /* attempt to insert record for this directory */ if ((error = diff_delta__from_one(diff, delta_type, NULL, nitem)) != 0) return error; /* if delta wasn't created (because of rules), just skip ahead */ last = diff_delta__last_for_item(diff, nitem); if (!last) return iterator_advance(&info->nitem, info->new_iter); /* iterate into dir looking for an actual untracked file */ if ((error = iterator_advance_over_with_status( &info->nitem, &untracked_state, info->new_iter)) < 0) return error; /* if we found nothing that matched our pathlist filter, exclude */ if (untracked_state == GIT_ITERATOR_STATUS_FILTERED) { git_vector_pop(&diff->deltas); git__free(last); } /* if we found nothing or just ignored items, update the record */ if (untracked_state == GIT_ITERATOR_STATUS_IGNORED || untracked_state == GIT_ITERATOR_STATUS_EMPTY) { last->status = GIT_DELTA_IGNORED; /* remove the record if we don't want ignored records */ if (DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_IGNORED)) { git_vector_pop(&diff->deltas); git__free(last); } } return 0; } /* try to advance into directory if necessary */ if (recurse_into_dir) { error = iterator_advance_into(&info->nitem, info->new_iter); /* if real error or no error, proceed with iteration */ if (error != GIT_ENOTFOUND) return error; giterr_clear(); /* if directory is empty, can't advance into it, so either skip * it or ignore it */ if (contains_oitem) return iterator_advance(&info->nitem, info->new_iter); delta_type = GIT_DELTA_IGNORED; } } else if (delta_type == GIT_DELTA_IGNORED && DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_RECURSE_IGNORED_DIRS) && git_iterator_current_tree_is_ignored(info->new_iter)) /* item contained in ignored directory, so skip over it */ return iterator_advance(&info->nitem, info->new_iter); else if (info->new_iter->type != GIT_ITERATOR_TYPE_WORKDIR) { if (delta_type != GIT_DELTA_CONFLICTED) delta_type = GIT_DELTA_ADDED; } else if (nitem->mode == GIT_FILEMODE_COMMIT) { /* ignore things that are not actual submodules */ if (git_submodule_lookup(NULL, info->repo, nitem->path) != 0) { giterr_clear(); delta_type = GIT_DELTA_IGNORED; /* if this contains a tracked item, treat as normal TREE */ if (contains_oitem) { error = iterator_advance_into(&info->nitem, info->new_iter); if (error != GIT_ENOTFOUND) return error; giterr_clear(); return iterator_advance(&info->nitem, info->new_iter); } } } else if (nitem->mode == GIT_FILEMODE_UNREADABLE) { if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED)) delta_type = GIT_DELTA_UNTRACKED; else delta_type = GIT_DELTA_UNREADABLE; } /* Actually create the record for this item if necessary */ if ((error = diff_delta__from_one(diff, delta_type, NULL, nitem)) != 0) return error; /* If user requested TYPECHANGE records, then check for that instead of * just generating an ADDED/UNTRACKED record */ if (delta_type != GIT_DELTA_IGNORED && DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE_TREES) && contains_oitem) { /* this entry was prefixed with a tree - make TYPECHANGE */ git_diff_delta *last = diff_delta__last_for_item(diff, nitem); if (last) { last->status = GIT_DELTA_TYPECHANGE; last->old_file.mode = GIT_FILEMODE_TREE; } } return iterator_advance(&info->nitem, info->new_iter); } static int handle_unmatched_old_item( git_diff *diff, diff_in_progress *info) { git_delta_t delta_type = GIT_DELTA_DELETED; int error; /* update delta_type if this item is conflicted */ if (git_index_entry_is_conflict(info->oitem)) delta_type = GIT_DELTA_CONFLICTED; if ((error = diff_delta__from_one(diff, delta_type, info->oitem, NULL)) < 0) return error; /* if we are generating TYPECHANGE records then check for that * instead of just generating a DELETE record */ if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE_TREES) && entry_is_prefixed(diff, info->nitem, info->oitem)) { /* this entry has become a tree! convert to TYPECHANGE */ git_diff_delta *last = diff_delta__last_for_item(diff, info->oitem); if (last) { last->status = GIT_DELTA_TYPECHANGE; last->new_file.mode = GIT_FILEMODE_TREE; } /* If new_iter is a workdir iterator, then this situation * will certainly be followed by a series of untracked items. * Unless RECURSE_UNTRACKED_DIRS is set, skip over them... */ if (S_ISDIR(info->nitem->mode) && DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_RECURSE_UNTRACKED_DIRS)) return iterator_advance(&info->nitem, info->new_iter); } return iterator_advance(&info->oitem, info->old_iter); } static int handle_matched_item( git_diff *diff, diff_in_progress *info) { int error = 0; if ((error = maybe_modified(diff, info)) < 0) return error; if (!(error = iterator_advance(&info->oitem, info->old_iter))) error = iterator_advance(&info->nitem, info->new_iter); return error; } int git_diff__from_iterators( git_diff **diff_ptr, git_repository *repo, git_iterator *old_iter, git_iterator *new_iter, const git_diff_options *opts) { int error = 0; diff_in_progress info; git_diff *diff; *diff_ptr = NULL; diff = diff_list_alloc(repo, old_iter, new_iter); GITERR_CHECK_ALLOC(diff); info.repo = repo; info.old_iter = old_iter; info.new_iter = new_iter; /* make iterators have matching icase behavior */ if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_CASE)) { if ((error = git_iterator_set_ignore_case(old_iter, true)) < 0 || (error = git_iterator_set_ignore_case(new_iter, true)) < 0) goto cleanup; } /* finish initialization */ if ((error = diff_list_apply_options(diff, opts)) < 0) goto cleanup; if ((error = iterator_current(&info.oitem, old_iter)) < 0 || (error = iterator_current(&info.nitem, new_iter)) < 0) goto cleanup; /* run iterators building diffs */ while (!error && (info.oitem || info.nitem)) { int cmp = info.oitem ? (info.nitem ? diff->entrycomp(info.oitem, info.nitem) : -1) : 1; /* create DELETED records for old items not matched in new */ if (cmp < 0) error = handle_unmatched_old_item(diff, &info); /* create ADDED, TRACKED, or IGNORED records for new items not * matched in old (and/or descend into directories as needed) */ else if (cmp > 0) error = handle_unmatched_new_item(diff, &info); /* otherwise item paths match, so create MODIFIED record * (or ADDED and DELETED pair if type changed) */ else error = handle_matched_item(diff, &info); } diff->perf.stat_calls += old_iter->stat_calls + new_iter->stat_calls; cleanup: if (!error) *diff_ptr = diff; else git_diff_free(diff); return error; } #define DIFF_FROM_ITERATORS(MAKE_FIRST, FLAGS_FIRST, MAKE_SECOND, FLAGS_SECOND) do { \ git_iterator *a = NULL, *b = NULL; \ char *pfx = (opts && !(opts->flags & GIT_DIFF_DISABLE_PATHSPEC_MATCH)) ? \ git_pathspec_prefix(&opts->pathspec) : NULL; \ git_iterator_options a_opts = GIT_ITERATOR_OPTIONS_INIT, \ b_opts = GIT_ITERATOR_OPTIONS_INIT; \ a_opts.flags = FLAGS_FIRST; \ a_opts.start = pfx; \ a_opts.end = pfx; \ b_opts.flags = FLAGS_SECOND; \ b_opts.start = pfx; \ b_opts.end = pfx; \ GITERR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options"); \ if (opts && (opts->flags & GIT_DIFF_DISABLE_PATHSPEC_MATCH)) { \ a_opts.pathlist.strings = opts->pathspec.strings; \ a_opts.pathlist.count = opts->pathspec.count; \ b_opts.pathlist.strings = opts->pathspec.strings; \ b_opts.pathlist.count = opts->pathspec.count; \ } \ if (!error && !(error = MAKE_FIRST) && !(error = MAKE_SECOND)) \ error = git_diff__from_iterators(diff, repo, a, b, opts); \ git__free(pfx); git_iterator_free(a); git_iterator_free(b); \ } while (0) int git_diff_tree_to_tree( git_diff **diff, git_repository *repo, git_tree *old_tree, git_tree *new_tree, const git_diff_options *opts) { git_iterator_flag_t iflag = GIT_ITERATOR_DONT_IGNORE_CASE; int error = 0; assert(diff && repo); /* for tree to tree diff, be case sensitive even if the index is * currently case insensitive, unless the user explicitly asked * for case insensitivity */ if (opts && (opts->flags & GIT_DIFF_IGNORE_CASE) != 0) iflag = GIT_ITERATOR_IGNORE_CASE; DIFF_FROM_ITERATORS( git_iterator_for_tree(&a, old_tree, &a_opts), iflag, git_iterator_for_tree(&b, new_tree, &b_opts), iflag ); return error; } static int diff_load_index(git_index **index, git_repository *repo) { int error = git_repository_index__weakptr(index, repo); /* reload the repository index when user did not pass one in */ if (!error && git_index_read(*index, false) < 0) giterr_clear(); return error; } int git_diff_tree_to_index( git_diff **diff, git_repository *repo, git_tree *old_tree, git_index *index, const git_diff_options *opts) { git_iterator_flag_t iflag = GIT_ITERATOR_DONT_IGNORE_CASE | GIT_ITERATOR_INCLUDE_CONFLICTS; bool index_ignore_case = false; int error = 0; assert(diff && repo); if (!index && (error = diff_load_index(&index, repo)) < 0) return error; index_ignore_case = index->ignore_case; DIFF_FROM_ITERATORS( git_iterator_for_tree(&a, old_tree, &a_opts), iflag, git_iterator_for_index(&b, index, &b_opts), iflag ); /* if index is in case-insensitive order, re-sort deltas to match */ if (!error && index_ignore_case) diff_set_ignore_case(*diff, true); return error; } int git_diff_index_to_workdir( git_diff **diff, git_repository *repo, git_index *index, const git_diff_options *opts) { int error = 0; assert(diff && repo); if (!index && (error = diff_load_index(&index, repo)) < 0) return error; DIFF_FROM_ITERATORS( git_iterator_for_index(&a, index, &a_opts), GIT_ITERATOR_INCLUDE_CONFLICTS, git_iterator_for_workdir(&b, repo, index, NULL, &b_opts), GIT_ITERATOR_DONT_AUTOEXPAND ); if (!error && DIFF_FLAG_IS_SET(*diff, GIT_DIFF_UPDATE_INDEX) && (*diff)->index_updated) error = git_index_write(index); return error; } int git_diff_tree_to_workdir( git_diff **diff, git_repository *repo, git_tree *old_tree, const git_diff_options *opts) { int error = 0; git_index *index; assert(diff && repo); if ((error = git_repository_index__weakptr(&index, repo))) return error; DIFF_FROM_ITERATORS( git_iterator_for_tree(&a, old_tree, &a_opts), 0, git_iterator_for_workdir(&b, repo, index, old_tree, &b_opts), GIT_ITERATOR_DONT_AUTOEXPAND ); return error; } int git_diff_tree_to_workdir_with_index( git_diff **diff, git_repository *repo, git_tree *old_tree, const git_diff_options *opts) { int error = 0; git_diff *d1 = NULL, *d2 = NULL; git_index *index = NULL; assert(diff && repo); if ((error = diff_load_index(&index, repo)) < 0) return error; if (!(error = git_diff_tree_to_index(&d1, repo, old_tree, index, opts)) && !(error = git_diff_index_to_workdir(&d2, repo, index, opts))) error = git_diff_merge(d1, d2); git_diff_free(d2); if (error) { git_diff_free(d1); d1 = NULL; } *diff = d1; return error; } int git_diff_index_to_index( git_diff **diff, git_repository *repo, git_index *old_index, git_index *new_index, const git_diff_options *opts) { int error = 0; assert(diff && old_index && new_index); DIFF_FROM_ITERATORS( git_iterator_for_index(&a, old_index, &a_opts), GIT_ITERATOR_DONT_IGNORE_CASE, git_iterator_for_index(&b, new_index, &b_opts), GIT_ITERATOR_DONT_IGNORE_CASE ); /* if index is in case-insensitive order, re-sort deltas to match */ if (!error && (old_index->ignore_case || new_index->ignore_case)) diff_set_ignore_case(*diff, true); return error; } size_t git_diff_num_deltas(const git_diff *diff) { assert(diff); return diff->deltas.length; } size_t git_diff_num_deltas_of_type(const git_diff *diff, git_delta_t type) { size_t i, count = 0; const git_diff_delta *delta; assert(diff); git_vector_foreach(&diff->deltas, i, delta) { count += (delta->status == type); } return count; } const git_diff_delta *git_diff_get_delta(const git_diff *diff, size_t idx) { assert(diff); return git_vector_get(&diff->deltas, idx); } int git_diff_is_sorted_icase(const git_diff *diff) { return (diff->opts.flags & GIT_DIFF_IGNORE_CASE) != 0; } int git_diff_get_perfdata(git_diff_perfdata *out, const git_diff *diff) { assert(out); GITERR_CHECK_VERSION(out, GIT_DIFF_PERFDATA_VERSION, "git_diff_perfdata"); out->stat_calls = diff->perf.stat_calls; out->oid_calculations = diff->perf.oid_calculations; return 0; } int git_diff__paired_foreach( git_diff *head2idx, git_diff *idx2wd, int (*cb)(git_diff_delta *h2i, git_diff_delta *i2w, void *payload), void *payload) { int cmp, error = 0; git_diff_delta *h2i, *i2w; size_t i, j, i_max, j_max; int (*strcomp)(const char *, const char *) = git__strcmp; bool h2i_icase, i2w_icase, icase_mismatch; i_max = head2idx ? head2idx->deltas.length : 0; j_max = idx2wd ? idx2wd->deltas.length : 0; if (!i_max && !j_max) return 0; /* At some point, tree-to-index diffs will probably never ignore case, * even if that isn't true now. Index-to-workdir diffs may or may not * ignore case, but the index filename for the idx2wd diff should * still be using the canonical case-preserving name. * * Therefore the main thing we need to do here is make sure the diffs * are traversed in a compatible order. To do this, we temporarily * resort a mismatched diff to get the order correct. * * In order to traverse renames in the index->workdir, we need to * ensure that we compare the index name on both sides, so we * always sort by the old name in the i2w list. */ h2i_icase = head2idx != NULL && (head2idx->opts.flags & GIT_DIFF_IGNORE_CASE) != 0; i2w_icase = idx2wd != NULL && (idx2wd->opts.flags & GIT_DIFF_IGNORE_CASE) != 0; icase_mismatch = (head2idx != NULL && idx2wd != NULL && h2i_icase != i2w_icase); if (icase_mismatch && h2i_icase) { git_vector_set_cmp(&head2idx->deltas, git_diff_delta__cmp); git_vector_sort(&head2idx->deltas); } if (i2w_icase && !icase_mismatch) { strcomp = git__strcasecmp; git_vector_set_cmp(&idx2wd->deltas, git_diff_delta__i2w_casecmp); git_vector_sort(&idx2wd->deltas); } else if (idx2wd != NULL) { git_vector_set_cmp(&idx2wd->deltas, git_diff_delta__i2w_cmp); git_vector_sort(&idx2wd->deltas); } for (i = 0, j = 0; i < i_max || j < j_max; ) { h2i = head2idx ? GIT_VECTOR_GET(&head2idx->deltas, i) : NULL; i2w = idx2wd ? GIT_VECTOR_GET(&idx2wd->deltas, j) : NULL; cmp = !i2w ? -1 : !h2i ? 1 : strcomp(h2i->new_file.path, i2w->old_file.path); if (cmp < 0) { i++; i2w = NULL; } else if (cmp > 0) { j++; h2i = NULL; } else { i++; j++; } if ((error = cb(h2i, i2w, payload)) != 0) { giterr_set_after_callback(error); break; } } /* restore case-insensitive delta sort */ if (icase_mismatch && h2i_icase) { git_vector_set_cmp(&head2idx->deltas, git_diff_delta__casecmp); git_vector_sort(&head2idx->deltas); } /* restore idx2wd sort by new path */ if (idx2wd != NULL) { git_vector_set_cmp(&idx2wd->deltas, i2w_icase ? git_diff_delta__casecmp : git_diff_delta__cmp); git_vector_sort(&idx2wd->deltas); } return error; } int git_diff__commit( git_diff **diff, git_repository *repo, const git_commit *commit, const git_diff_options *opts) { git_commit *parent = NULL; git_diff *commit_diff = NULL; git_tree *old_tree = NULL, *new_tree = NULL; size_t parents; int error = 0; if ((parents = git_commit_parentcount(commit)) > 1) { char commit_oidstr[GIT_OID_HEXSZ + 1]; error = -1; giterr_set(GITERR_INVALID, "Commit %s is a merge commit", git_oid_tostr(commit_oidstr, GIT_OID_HEXSZ + 1, git_commit_id(commit))); goto on_error; } if (parents > 0) if ((error = git_commit_parent(&parent, commit, 0)) < 0 || (error = git_commit_tree(&old_tree, parent)) < 0) goto on_error; if ((error = git_commit_tree(&new_tree, commit)) < 0 || (error = git_diff_tree_to_tree(&commit_diff, repo, old_tree, new_tree, opts)) < 0) goto on_error; *diff = commit_diff; on_error: git_tree_free(new_tree); git_tree_free(old_tree); git_commit_free(parent); return error; } int git_diff_format_email__append_header_tobuf( git_buf *out, const git_oid *id, const git_signature *author, const char *summary, size_t patch_no, size_t total_patches, bool exclude_patchno_marker) { char idstr[GIT_OID_HEXSZ + 1]; char date_str[GIT_DATE_RFC2822_SZ]; int error = 0; git_oid_fmt(idstr, id); idstr[GIT_OID_HEXSZ] = '\0'; if ((error = git__date_rfc2822_fmt(date_str, sizeof(date_str), &author->when)) < 0) return error; error = git_buf_printf(out, "From %s Mon Sep 17 00:00:00 2001\n" \ "From: %s <%s>\n" \ "Date: %s\n" \ "Subject: ", idstr, author->name, author->email, date_str); if (error < 0) return error; if (!exclude_patchno_marker) { if (total_patches == 1) { error = git_buf_puts(out, "[PATCH] "); } else { error = git_buf_printf(out, "[PATCH %"PRIuZ"/%"PRIuZ"] ", patch_no, total_patches); } if (error < 0) return error; } error = git_buf_printf(out, "%s\n\n", summary); return error; } int git_diff_format_email__append_patches_tobuf( git_buf *out, git_diff *diff) { size_t i, deltas; int error = 0; deltas = git_diff_num_deltas(diff); for (i = 0; i < deltas; ++i) { git_patch *patch = NULL; if ((error = git_patch_from_diff(&patch, diff, i)) >= 0) error = git_patch_to_buf(out, patch); git_patch_free(patch); if (error < 0) break; } return error; } int git_diff_format_email( git_buf *out, git_diff *diff, const git_diff_format_email_options *opts) { git_diff_stats *stats = NULL; char *summary = NULL, *loc = NULL; bool ignore_marker; unsigned int format_flags = 0; size_t allocsize; int error; assert(out && diff && opts); assert(opts->summary && opts->id && opts->author); GITERR_CHECK_VERSION(opts, GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION, "git_format_email_options"); if ((ignore_marker = opts->flags & GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER) == false) { if (opts->patch_no > opts->total_patches) { giterr_set(GITERR_INVALID, "patch %"PRIuZ" out of range. max %"PRIuZ, opts->patch_no, opts->total_patches); return -1; } if (opts->patch_no == 0) { giterr_set(GITERR_INVALID, "invalid patch no %"PRIuZ". should be >0", opts->patch_no); return -1; } } /* the summary we receive may not be clean. * it could potentially contain new line characters * or not be set, sanitize, */ if ((loc = strpbrk(opts->summary, "\r\n")) != NULL) { size_t offset = 0; if ((offset = (loc - opts->summary)) == 0) { giterr_set(GITERR_INVALID, "summary is empty"); error = -1; goto on_error; } GITERR_CHECK_ALLOC_ADD(&allocsize, offset, 1); summary = git__calloc(allocsize, sizeof(char)); GITERR_CHECK_ALLOC(summary); strncpy(summary, opts->summary, offset); } error = git_diff_format_email__append_header_tobuf(out, opts->id, opts->author, summary == NULL ? opts->summary : summary, opts->patch_no, opts->total_patches, ignore_marker); if (error < 0) goto on_error; format_flags = GIT_DIFF_STATS_FULL | GIT_DIFF_STATS_INCLUDE_SUMMARY; if ((error = git_buf_puts(out, "---\n")) < 0 || (error = git_diff_get_stats(&stats, diff)) < 0 || (error = git_diff_stats_to_buf(out, stats, format_flags, 0)) < 0 || (error = git_buf_putc(out, '\n')) < 0 || (error = git_diff_format_email__append_patches_tobuf(out, diff)) < 0) goto on_error; error = git_buf_puts(out, "--\nlibgit2 " LIBGIT2_VERSION "\n\n"); on_error: git__free(summary); git_diff_stats_free(stats); return error; } int git_diff_commit_as_email( git_buf *out, git_repository *repo, git_commit *commit, size_t patch_no, size_t total_patches, git_diff_format_email_flags_t flags, const git_diff_options *diff_opts) { git_diff *diff = NULL; git_diff_format_email_options opts = GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT; int error; assert (out && repo && commit); opts.flags = flags; opts.patch_no = patch_no; opts.total_patches = total_patches; opts.id = git_commit_id(commit); opts.summary = git_commit_summary(commit); opts.author = git_commit_author(commit); if ((error = git_diff__commit(&diff, repo, commit, diff_opts)) < 0) return error; error = git_diff_format_email(out, diff, &opts); git_diff_free(diff); return error; } int git_diff_init_options(git_diff_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_diff_options, GIT_DIFF_OPTIONS_INIT); return 0; } int git_diff_find_init_options( git_diff_find_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_diff_find_options, GIT_DIFF_FIND_OPTIONS_INIT); return 0; } int git_diff_format_email_init_options( git_diff_format_email_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_diff_format_email_options, GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/diff_file.c0000664000175000017500000002546612555730137015772 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "git2/blob.h" #include "git2/submodule.h" #include "diff.h" #include "diff_file.h" #include "odb.h" #include "fileops.h" #include "filter.h" #define DIFF_MAX_FILESIZE 0x20000000 static bool diff_file_content_binary_by_size(git_diff_file_content *fc) { /* if we have diff opts, check max_size vs file size */ if ((fc->file->flags & DIFF_FLAGS_KNOWN_BINARY) == 0 && fc->opts_max_size > 0 && fc->file->size > fc->opts_max_size) fc->file->flags |= GIT_DIFF_FLAG_BINARY; return ((fc->file->flags & GIT_DIFF_FLAG_BINARY) != 0); } static void diff_file_content_binary_by_content(git_diff_file_content *fc) { if ((fc->file->flags & DIFF_FLAGS_KNOWN_BINARY) != 0) return; switch (git_diff_driver_content_is_binary( fc->driver, fc->map.data, fc->map.len)) { case 0: fc->file->flags |= GIT_DIFF_FLAG_NOT_BINARY; break; case 1: fc->file->flags |= GIT_DIFF_FLAG_BINARY; break; default: break; } } static int diff_file_content_init_common( git_diff_file_content *fc, const git_diff_options *opts) { fc->opts_flags = opts ? opts->flags : GIT_DIFF_NORMAL; if (opts && opts->max_size >= 0) fc->opts_max_size = opts->max_size ? opts->max_size : DIFF_MAX_FILESIZE; if (fc->src == GIT_ITERATOR_TYPE_EMPTY) fc->src = GIT_ITERATOR_TYPE_TREE; if (!fc->driver && git_diff_driver_lookup(&fc->driver, fc->repo, fc->file->path) < 0) return -1; /* give driver a chance to modify options */ git_diff_driver_update_options(&fc->opts_flags, fc->driver); /* make sure file is conceivable mmap-able */ if ((git_off_t)((size_t)fc->file->size) != fc->file->size) fc->file->flags |= GIT_DIFF_FLAG_BINARY; /* check if user is forcing text diff the file */ else if (fc->opts_flags & GIT_DIFF_FORCE_TEXT) { fc->file->flags &= ~GIT_DIFF_FLAG_BINARY; fc->file->flags |= GIT_DIFF_FLAG_NOT_BINARY; } /* check if user is forcing binary diff the file */ else if (fc->opts_flags & GIT_DIFF_FORCE_BINARY) { fc->file->flags &= ~GIT_DIFF_FLAG_NOT_BINARY; fc->file->flags |= GIT_DIFF_FLAG_BINARY; } diff_file_content_binary_by_size(fc); if ((fc->flags & GIT_DIFF_FLAG__NO_DATA) != 0) { fc->flags |= GIT_DIFF_FLAG__LOADED; fc->map.len = 0; fc->map.data = ""; } if ((fc->flags & GIT_DIFF_FLAG__LOADED) != 0) diff_file_content_binary_by_content(fc); return 0; } int git_diff_file_content__init_from_diff( git_diff_file_content *fc, git_diff *diff, git_diff_delta *delta, bool use_old) { bool has_data = true; memset(fc, 0, sizeof(*fc)); fc->repo = diff->repo; fc->file = use_old ? &delta->old_file : &delta->new_file; fc->src = use_old ? diff->old_src : diff->new_src; if (git_diff_driver_lookup(&fc->driver, fc->repo, fc->file->path) < 0) return -1; switch (delta->status) { case GIT_DELTA_ADDED: has_data = !use_old; break; case GIT_DELTA_DELETED: has_data = use_old; break; case GIT_DELTA_UNTRACKED: has_data = !use_old && (diff->opts.flags & GIT_DIFF_SHOW_UNTRACKED_CONTENT) != 0; break; case GIT_DELTA_UNREADABLE: case GIT_DELTA_MODIFIED: case GIT_DELTA_COPIED: case GIT_DELTA_RENAMED: break; default: has_data = false; break; } if (!has_data) fc->flags |= GIT_DIFF_FLAG__NO_DATA; return diff_file_content_init_common(fc, &diff->opts); } int git_diff_file_content__init_from_src( git_diff_file_content *fc, git_repository *repo, const git_diff_options *opts, const git_diff_file_content_src *src, git_diff_file *as_file) { memset(fc, 0, sizeof(*fc)); fc->repo = repo; fc->file = as_file; fc->blob = src->blob; if (!src->blob && !src->buf) { fc->flags |= GIT_DIFF_FLAG__NO_DATA; } else { fc->flags |= GIT_DIFF_FLAG__LOADED; fc->file->flags |= GIT_DIFF_FLAG_VALID_ID; fc->file->mode = GIT_FILEMODE_BLOB; if (src->blob) { fc->file->size = git_blob_rawsize(src->blob); git_oid_cpy(&fc->file->id, git_blob_id(src->blob)); fc->map.len = (size_t)fc->file->size; fc->map.data = (char *)git_blob_rawcontent(src->blob); } else { fc->file->size = src->buflen; git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJ_BLOB); fc->map.len = src->buflen; fc->map.data = (char *)src->buf; } } return diff_file_content_init_common(fc, opts); } static int diff_file_content_commit_to_str( git_diff_file_content *fc, bool check_status) { char oid[GIT_OID_HEXSZ+1]; git_buf content = GIT_BUF_INIT; const char *status = ""; if (check_status) { int error = 0; git_submodule *sm = NULL; unsigned int sm_status = 0; const git_oid *sm_head; if ((error = git_submodule_lookup(&sm, fc->repo, fc->file->path)) < 0) { /* GIT_EEXISTS means a "submodule" that has not been git added */ if (error == GIT_EEXISTS) { giterr_clear(); error = 0; } return error; } if ((error = git_submodule_status(&sm_status, fc->repo, fc->file->path, GIT_SUBMODULE_IGNORE_UNSPECIFIED)) < 0) { git_submodule_free(sm); return error; } /* update OID if we didn't have it previously */ if ((fc->file->flags & GIT_DIFF_FLAG_VALID_ID) == 0 && ((sm_head = git_submodule_wd_id(sm)) != NULL || (sm_head = git_submodule_head_id(sm)) != NULL)) { git_oid_cpy(&fc->file->id, sm_head); fc->file->flags |= GIT_DIFF_FLAG_VALID_ID; } if (GIT_SUBMODULE_STATUS_IS_WD_DIRTY(sm_status)) status = "-dirty"; git_submodule_free(sm); } git_oid_tostr(oid, sizeof(oid), &fc->file->id); if (git_buf_printf(&content, "Subproject commit %s%s\n", oid, status) < 0) return -1; fc->map.len = git_buf_len(&content); fc->map.data = git_buf_detach(&content); fc->flags |= GIT_DIFF_FLAG__FREE_DATA; return 0; } static int diff_file_content_load_blob( git_diff_file_content *fc, git_diff_options *opts) { int error = 0; git_odb_object *odb_obj = NULL; if (git_oid_iszero(&fc->file->id)) return 0; if (fc->file->mode == GIT_FILEMODE_COMMIT) return diff_file_content_commit_to_str(fc, false); /* if we don't know size, try to peek at object header first */ if (!fc->file->size) { if ((error = git_diff_file__resolve_zero_size( fc->file, &odb_obj, fc->repo)) < 0) return error; } if ((opts->flags & GIT_DIFF_SHOW_BINARY) == 0 && diff_file_content_binary_by_size(fc)) return 0; if (odb_obj != NULL) { error = git_object__from_odb_object( (git_object **)&fc->blob, fc->repo, odb_obj, GIT_OBJ_BLOB); git_odb_object_free(odb_obj); } else { error = git_blob_lookup( (git_blob **)&fc->blob, fc->repo, &fc->file->id); } if (!error) { fc->flags |= GIT_DIFF_FLAG__FREE_BLOB; fc->map.data = (void *)git_blob_rawcontent(fc->blob); fc->map.len = (size_t)git_blob_rawsize(fc->blob); } return error; } static int diff_file_content_load_workdir_symlink( git_diff_file_content *fc, git_buf *path) { ssize_t alloc_len, read_len; /* link path on disk could be UTF-16, so prepare a buffer that is * big enough to handle some UTF-8 data expansion */ alloc_len = (ssize_t)(fc->file->size * 2) + 1; fc->map.data = git__calloc(alloc_len, sizeof(char)); GITERR_CHECK_ALLOC(fc->map.data); fc->flags |= GIT_DIFF_FLAG__FREE_DATA; read_len = p_readlink(git_buf_cstr(path), fc->map.data, alloc_len); if (read_len < 0) { giterr_set(GITERR_OS, "Failed to read symlink '%s'", fc->file->path); return -1; } fc->map.len = read_len; return 0; } static int diff_file_content_load_workdir_file( git_diff_file_content *fc, git_buf *path, git_diff_options *diff_opts) { int error = 0; git_filter_list *fl = NULL; git_file fd = git_futils_open_ro(git_buf_cstr(path)); git_buf raw = GIT_BUF_INIT; if (fd < 0) return fd; if (!fc->file->size && !(fc->file->size = git_futils_filesize(fd))) goto cleanup; if ((diff_opts->flags & GIT_DIFF_SHOW_BINARY) == 0 && diff_file_content_binary_by_size(fc)) goto cleanup; if ((error = git_filter_list_load( &fl, fc->repo, NULL, fc->file->path, GIT_FILTER_TO_ODB, GIT_FILTER_ALLOW_UNSAFE)) < 0) goto cleanup; /* if there are no filters, try to mmap the file */ if (fl == NULL) { if (!(error = git_futils_mmap_ro( &fc->map, fd, 0, (size_t)fc->file->size))) { fc->flags |= GIT_DIFF_FLAG__UNMAP_DATA; goto cleanup; } /* if mmap failed, fall through to try readbuffer below */ giterr_clear(); } if (!(error = git_futils_readbuffer_fd(&raw, fd, (size_t)fc->file->size))) { git_buf out = GIT_BUF_INIT; error = git_filter_list_apply_to_data(&out, fl, &raw); if (out.ptr != raw.ptr) git_buf_free(&raw); if (!error) { fc->map.len = out.size; fc->map.data = out.ptr; fc->flags |= GIT_DIFF_FLAG__FREE_DATA; } } cleanup: git_filter_list_free(fl); p_close(fd); return error; } static int diff_file_content_load_workdir( git_diff_file_content *fc, git_diff_options *diff_opts) { int error = 0; git_buf path = GIT_BUF_INIT; if (fc->file->mode == GIT_FILEMODE_COMMIT) return diff_file_content_commit_to_str(fc, true); if (fc->file->mode == GIT_FILEMODE_TREE) return 0; if (git_buf_joinpath( &path, git_repository_workdir(fc->repo), fc->file->path) < 0) return -1; if (S_ISLNK(fc->file->mode)) error = diff_file_content_load_workdir_symlink(fc, &path); else error = diff_file_content_load_workdir_file(fc, &path, diff_opts); /* once data is loaded, update OID if we didn't have it previously */ if (!error && (fc->file->flags & GIT_DIFF_FLAG_VALID_ID) == 0) { error = git_odb_hash( &fc->file->id, fc->map.data, fc->map.len, GIT_OBJ_BLOB); fc->file->flags |= GIT_DIFF_FLAG_VALID_ID; } git_buf_free(&path); return error; } int git_diff_file_content__load( git_diff_file_content *fc, git_diff_options *diff_opts) { int error = 0; if ((fc->flags & GIT_DIFF_FLAG__LOADED) != 0) return 0; if ((fc->file->flags & GIT_DIFF_FLAG_BINARY) != 0 && (diff_opts->flags & GIT_DIFF_SHOW_BINARY) == 0) return 0; if (fc->src == GIT_ITERATOR_TYPE_WORKDIR) error = diff_file_content_load_workdir(fc, diff_opts); else error = diff_file_content_load_blob(fc, diff_opts); if (error) return error; fc->flags |= GIT_DIFF_FLAG__LOADED; diff_file_content_binary_by_content(fc); return 0; } void git_diff_file_content__unload(git_diff_file_content *fc) { if ((fc->flags & GIT_DIFF_FLAG__LOADED) == 0) return; if (fc->flags & GIT_DIFF_FLAG__FREE_DATA) { git__free(fc->map.data); fc->map.data = ""; fc->map.len = 0; fc->flags &= ~GIT_DIFF_FLAG__FREE_DATA; } else if (fc->flags & GIT_DIFF_FLAG__UNMAP_DATA) { git_futils_mmap_free(&fc->map); fc->map.data = ""; fc->map.len = 0; fc->flags &= ~GIT_DIFF_FLAG__UNMAP_DATA; } if (fc->flags & GIT_DIFF_FLAG__FREE_BLOB) { git_blob_free((git_blob *)fc->blob); fc->blob = NULL; fc->flags &= ~GIT_DIFF_FLAG__FREE_BLOB; } fc->flags &= ~GIT_DIFF_FLAG__LOADED; } void git_diff_file_content__clear(git_diff_file_content *fc) { git_diff_file_content__unload(fc); /* for now, nothing else to do */ } deps/libgit2-sys-0.3.8/libgit2/src/openssl_stream.h0000664000175000017500000000063512510265101017076 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_openssl_stream_h__ #define INCLUDE_openssl_stream_h__ #include "git2/sys/stream.h" extern int git_openssl_stream_new(git_stream **out, const char *host, const char *port); #endif deps/libgit2-sys-0.3.8/libgit2/src/ignore.h0000664000175000017500000000367112555730137015345 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_ignore_h__ #define INCLUDE_ignore_h__ #include "repository.h" #include "vector.h" #include "attr_file.h" #define GIT_IGNORE_FILE ".gitignore" #define GIT_IGNORE_FILE_INREPO "info/exclude" #define GIT_IGNORE_FILE_XDG "ignore" /* The git_ignores structure maintains three sets of ignores: * - internal ignores * - per directory ignores * - global ignores (at lower priority than the others) * As you traverse from one directory to another, you can push and pop * directories onto git_ignores list efficiently. */ typedef struct { git_repository *repo; git_buf dir; /* current directory reflected in ign_path */ git_attr_file *ign_internal; git_vector ign_path; git_vector ign_global; size_t dir_root; /* offset in dir to repo root */ int ignore_case; int depth; } git_ignores; extern int git_ignore__for_path( git_repository *repo, const char *path, git_ignores *ign); extern int git_ignore__push_dir(git_ignores *ign, const char *dir); extern int git_ignore__pop_dir(git_ignores *ign); extern void git_ignore__free(git_ignores *ign); enum { GIT_IGNORE_UNCHECKED = -2, GIT_IGNORE_NOTFOUND = -1, GIT_IGNORE_FALSE = 0, GIT_IGNORE_TRUE = 1, }; extern int git_ignore__lookup(int *out, git_ignores *ign, const char *path, git_dir_flag dir_flag); /* command line Git sometimes generates an error message if given a * pathspec that contains an exact match to an ignored file (provided * --force isn't also given). This makes it easy to check it that has * happened. Returns GIT_EINVALIDSPEC if the pathspec contains ignored * exact matches (that are not already present in the index). */ extern int git_ignore__check_pathspec_for_exact_ignores( git_repository *repo, git_vector *pathspec, bool no_fnmatch); #endif deps/libgit2-sys-0.3.8/libgit2/src/odb.c0000664000175000017500000006730012610310643014604 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include #include "git2/object.h" #include "git2/sys/odb_backend.h" #include "fileops.h" #include "hash.h" #include "odb.h" #include "delta-apply.h" #include "filter.h" #include "repository.h" #include "git2/odb_backend.h" #include "git2/oid.h" #define GIT_ALTERNATES_FILE "info/alternates" /* * We work under the assumption that most objects for long-running * operations will be packed */ #define GIT_LOOSE_PRIORITY 1 #define GIT_PACKED_PRIORITY 2 #define GIT_ALTERNATES_MAX_DEPTH 5 typedef struct { git_odb_backend *backend; int priority; bool is_alternate; ino_t disk_inode; } backend_internal; static git_cache *odb_cache(git_odb *odb) { if (odb->rc.owner != NULL) { git_repository *owner = odb->rc.owner; return &owner->objects; } return &odb->own_cache; } static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_depth); int git_odb__format_object_header(char *hdr, size_t n, git_off_t obj_len, git_otype obj_type) { const char *type_str = git_object_type2string(obj_type); int len = p_snprintf(hdr, n, "%s %lld", type_str, (long long)obj_len); assert(len > 0 && len <= (int)n); return len+1; } int git_odb__hashobj(git_oid *id, git_rawobj *obj) { git_buf_vec vec[2]; char header[64]; int hdrlen; assert(id && obj); if (!git_object_typeisloose(obj->type)) return -1; if (!obj->data && obj->len != 0) return -1; hdrlen = git_odb__format_object_header(header, sizeof(header), obj->len, obj->type); vec[0].data = header; vec[0].len = hdrlen; vec[1].data = obj->data; vec[1].len = obj->len; git_hash_vec(id, vec, 2); return 0; } static git_odb_object *odb_object__alloc(const git_oid *oid, git_rawobj *source) { git_odb_object *object = git__calloc(1, sizeof(git_odb_object)); if (object != NULL) { git_oid_cpy(&object->cached.oid, oid); object->cached.type = source->type; object->cached.size = source->len; object->buffer = source->data; } return object; } void git_odb_object__free(void *object) { if (object != NULL) { git__free(((git_odb_object *)object)->buffer); git__free(object); } } const git_oid *git_odb_object_id(git_odb_object *object) { return &object->cached.oid; } const void *git_odb_object_data(git_odb_object *object) { return object->buffer; } size_t git_odb_object_size(git_odb_object *object) { return object->cached.size; } git_otype git_odb_object_type(git_odb_object *object) { return object->cached.type; } int git_odb_object_dup(git_odb_object **dest, git_odb_object *source) { git_cached_obj_incref(source); *dest = source; return 0; } void git_odb_object_free(git_odb_object *object) { if (object == NULL) return; git_cached_obj_decref(object); } int git_odb__hashfd(git_oid *out, git_file fd, size_t size, git_otype type) { int hdr_len; char hdr[64], buffer[FILEIO_BUFSIZE]; git_hash_ctx ctx; ssize_t read_len = 0; int error = 0; if (!git_object_typeisloose(type)) { giterr_set(GITERR_INVALID, "Invalid object type for hash"); return -1; } if ((error = git_hash_ctx_init(&ctx)) < 0) return -1; hdr_len = git_odb__format_object_header(hdr, sizeof(hdr), size, type); if ((error = git_hash_update(&ctx, hdr, hdr_len)) < 0) goto done; while (size > 0 && (read_len = p_read(fd, buffer, sizeof(buffer))) > 0) { if ((error = git_hash_update(&ctx, buffer, read_len)) < 0) goto done; size -= read_len; } /* If p_read returned an error code, the read obviously failed. * If size is not zero, the file was truncated after we originally * stat'd it, so we consider this a read failure too */ if (read_len < 0 || size > 0) { giterr_set(GITERR_OS, "Error reading file for hashing"); error = -1; goto done; } error = git_hash_final(out, &ctx); done: git_hash_ctx_cleanup(&ctx); return error; } int git_odb__hashfd_filtered( git_oid *out, git_file fd, size_t size, git_otype type, git_filter_list *fl) { int error; git_buf raw = GIT_BUF_INIT; if (!fl) return git_odb__hashfd(out, fd, size, type); /* size of data is used in header, so we have to read the whole file * into memory to apply filters before beginning to calculate the hash */ if (!(error = git_futils_readbuffer_fd(&raw, fd, size))) { git_buf post = GIT_BUF_INIT; error = git_filter_list_apply_to_data(&post, fl, &raw); git_buf_free(&raw); if (!error) error = git_odb_hash(out, post.ptr, post.size, type); git_buf_free(&post); } return error; } int git_odb__hashlink(git_oid *out, const char *path) { struct stat st; int size; int result; if (git_path_lstat(path, &st) < 0) return -1; if (!git__is_int(st.st_size) || (int)st.st_size < 0) { giterr_set(GITERR_FILESYSTEM, "File size overflow for 32-bit systems"); return -1; } size = (int)st.st_size; if (S_ISLNK(st.st_mode)) { char *link_data; int read_len; size_t alloc_size; GITERR_CHECK_ALLOC_ADD(&alloc_size, size, 1); link_data = git__malloc(alloc_size); GITERR_CHECK_ALLOC(link_data); read_len = p_readlink(path, link_data, size); link_data[size] = '\0'; if (read_len != size) { giterr_set(GITERR_OS, "Failed to read symlink data for '%s'", path); git__free(link_data); return -1; } result = git_odb_hash(out, link_data, size, GIT_OBJ_BLOB); git__free(link_data); } else { int fd = git_futils_open_ro(path); if (fd < 0) return -1; result = git_odb__hashfd(out, fd, size, GIT_OBJ_BLOB); p_close(fd); } return result; } int git_odb_hashfile(git_oid *out, const char *path, git_otype type) { git_off_t size; int result, fd = git_futils_open_ro(path); if (fd < 0) return fd; if ((size = git_futils_filesize(fd)) < 0 || !git__is_sizet(size)) { giterr_set(GITERR_OS, "File size overflow for 32-bit systems"); p_close(fd); return -1; } result = git_odb__hashfd(out, fd, (size_t)size, type); p_close(fd); return result; } int git_odb_hash(git_oid *id, const void *data, size_t len, git_otype type) { git_rawobj raw; assert(id); raw.data = (void *)data; raw.len = len; raw.type = type; return git_odb__hashobj(id, &raw); } /** * FAKE WSTREAM */ typedef struct { git_odb_stream stream; char *buffer; size_t size, written; git_otype type; } fake_wstream; static int fake_wstream__fwrite(git_odb_stream *_stream, const git_oid *oid) { fake_wstream *stream = (fake_wstream *)_stream; return _stream->backend->write(_stream->backend, oid, stream->buffer, stream->size, stream->type); } static int fake_wstream__write(git_odb_stream *_stream, const char *data, size_t len) { fake_wstream *stream = (fake_wstream *)_stream; if (stream->written + len > stream->size) return -1; memcpy(stream->buffer + stream->written, data, len); stream->written += len; return 0; } static void fake_wstream__free(git_odb_stream *_stream) { fake_wstream *stream = (fake_wstream *)_stream; git__free(stream->buffer); git__free(stream); } static int init_fake_wstream(git_odb_stream **stream_p, git_odb_backend *backend, git_off_t size, git_otype type) { fake_wstream *stream; if (!git__is_ssizet(size)) { giterr_set(GITERR_ODB, "object size too large to keep in memory"); return -1; } stream = git__calloc(1, sizeof(fake_wstream)); GITERR_CHECK_ALLOC(stream); stream->size = size; stream->type = type; stream->buffer = git__malloc(size); if (stream->buffer == NULL) { git__free(stream); return -1; } stream->stream.backend = backend; stream->stream.read = NULL; /* read only */ stream->stream.write = &fake_wstream__write; stream->stream.finalize_write = &fake_wstream__fwrite; stream->stream.free = &fake_wstream__free; stream->stream.mode = GIT_STREAM_WRONLY; *stream_p = (git_odb_stream *)stream; return 0; } /*********************************************************** * * OBJECT DATABASE PUBLIC API * * Public calls for the ODB functionality * ***********************************************************/ static int backend_sort_cmp(const void *a, const void *b) { const backend_internal *backend_a = (const backend_internal *)(a); const backend_internal *backend_b = (const backend_internal *)(b); if (backend_b->priority == backend_a->priority) { if (backend_a->is_alternate) return -1; if (backend_b->is_alternate) return 1; return 0; } return (backend_b->priority - backend_a->priority); } int git_odb_new(git_odb **out) { git_odb *db = git__calloc(1, sizeof(*db)); GITERR_CHECK_ALLOC(db); if (git_cache_init(&db->own_cache) < 0 || git_vector_init(&db->backends, 4, backend_sort_cmp) < 0) { git__free(db); return -1; } *out = db; GIT_REFCOUNT_INC(db); return 0; } static int add_backend_internal( git_odb *odb, git_odb_backend *backend, int priority, bool is_alternate, ino_t disk_inode) { backend_internal *internal; assert(odb && backend); GITERR_CHECK_VERSION(backend, GIT_ODB_BACKEND_VERSION, "git_odb_backend"); /* Check if the backend is already owned by another ODB */ assert(!backend->odb || backend->odb == odb); internal = git__malloc(sizeof(backend_internal)); GITERR_CHECK_ALLOC(internal); internal->backend = backend; internal->priority = priority; internal->is_alternate = is_alternate; internal->disk_inode = disk_inode; if (git_vector_insert(&odb->backends, internal) < 0) { git__free(internal); return -1; } git_vector_sort(&odb->backends); internal->backend->odb = odb; return 0; } int git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority) { return add_backend_internal(odb, backend, priority, false, 0); } int git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority) { return add_backend_internal(odb, backend, priority, true, 0); } size_t git_odb_num_backends(git_odb *odb) { assert(odb); return odb->backends.length; } static int git_odb__error_unsupported_in_backend(const char *action) { giterr_set(GITERR_ODB, "Cannot %s - unsupported in the loaded odb backends", action); return -1; } int git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos) { backend_internal *internal; assert(out && odb); internal = git_vector_get(&odb->backends, pos); if (internal && internal->backend) { *out = internal->backend; return 0; } giterr_set(GITERR_ODB, "No ODB backend loaded at index %" PRIuZ, pos); return GIT_ENOTFOUND; } static int add_default_backends( git_odb *db, const char *objects_dir, bool as_alternates, int alternate_depth) { size_t i; struct stat st; ino_t inode; git_odb_backend *loose, *packed; /* TODO: inodes are not really relevant on Win32, so we need to find * a cross-platform workaround for this */ #ifdef GIT_WIN32 GIT_UNUSED(i); GIT_UNUSED(st); inode = 0; #else if (p_stat(objects_dir, &st) < 0) { if (as_alternates) return 0; giterr_set(GITERR_ODB, "Failed to load object database in '%s'", objects_dir); return -1; } inode = st.st_ino; for (i = 0; i < db->backends.length; ++i) { backend_internal *backend = git_vector_get(&db->backends, i); if (backend->disk_inode == inode) return 0; } #endif /* add the loose object backend */ if (git_odb_backend_loose(&loose, objects_dir, -1, 0, 0, 0) < 0 || add_backend_internal(db, loose, GIT_LOOSE_PRIORITY, as_alternates, inode) < 0) return -1; /* add the packed file backend */ if (git_odb_backend_pack(&packed, objects_dir) < 0 || add_backend_internal(db, packed, GIT_PACKED_PRIORITY, as_alternates, inode) < 0) return -1; return load_alternates(db, objects_dir, alternate_depth); } static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_depth) { git_buf alternates_path = GIT_BUF_INIT; git_buf alternates_buf = GIT_BUF_INIT; char *buffer; const char *alternate; int result = 0; /* Git reports an error, we just ignore anything deeper */ if (alternate_depth > GIT_ALTERNATES_MAX_DEPTH) return 0; if (git_buf_joinpath(&alternates_path, objects_dir, GIT_ALTERNATES_FILE) < 0) return -1; if (git_path_exists(alternates_path.ptr) == false) { git_buf_free(&alternates_path); return 0; } if (git_futils_readbuffer(&alternates_buf, alternates_path.ptr) < 0) { git_buf_free(&alternates_path); return -1; } buffer = (char *)alternates_buf.ptr; /* add each alternate as a new backend; one alternate per line */ while ((alternate = git__strtok(&buffer, "\r\n")) != NULL) { if (*alternate == '\0' || *alternate == '#') continue; /* * Relative path: build based on the current `objects` * folder. However, relative paths are only allowed in * the current repository. */ if (*alternate == '.' && !alternate_depth) { if ((result = git_buf_joinpath(&alternates_path, objects_dir, alternate)) < 0) break; alternate = git_buf_cstr(&alternates_path); } if ((result = add_default_backends(odb, alternate, true, alternate_depth + 1)) < 0) break; } git_buf_free(&alternates_path); git_buf_free(&alternates_buf); return result; } int git_odb_add_disk_alternate(git_odb *odb, const char *path) { return add_default_backends(odb, path, true, 0); } int git_odb_open(git_odb **out, const char *objects_dir) { git_odb *db; assert(out && objects_dir); *out = NULL; if (git_odb_new(&db) < 0) return -1; if (add_default_backends(db, objects_dir, 0, 0) < 0) { git_odb_free(db); return -1; } *out = db; return 0; } static void odb_free(git_odb *db) { size_t i; for (i = 0; i < db->backends.length; ++i) { backend_internal *internal = git_vector_get(&db->backends, i); git_odb_backend *backend = internal->backend; backend->free(backend); git__free(internal); } git_vector_free(&db->backends); git_cache_free(&db->own_cache); git__memzero(db, sizeof(*db)); git__free(db); } void git_odb_free(git_odb *db) { if (db == NULL) return; GIT_REFCOUNT_DEC(db, odb_free); } static int odb_exists_1(git_odb *db, const git_oid *id, bool only_refreshed) { size_t i; bool found = false; for (i = 0; i < db->backends.length && !found; ++i) { backend_internal *internal = git_vector_get(&db->backends, i); git_odb_backend *b = internal->backend; if (only_refreshed && !b->refresh) continue; if (b->exists != NULL) found = (bool)b->exists(b, id); } return (int)found; } int git_odb_exists(git_odb *db, const git_oid *id) { git_odb_object *object; assert(db && id); if ((object = git_cache_get_raw(odb_cache(db), id)) != NULL) { git_odb_object_free(object); return (int)true; } if (odb_exists_1(db, id, false)) return 1; if (!git_odb_refresh(db)) return odb_exists_1(db, id, true); /* Failed to refresh, hence not found */ return 0; } static int odb_exists_prefix_1(git_oid *out, git_odb *db, const git_oid *key, size_t len, bool only_refreshed) { size_t i; int error = GIT_ENOTFOUND, num_found = 0; git_oid last_found = {{0}}, found; for (i = 0; i < db->backends.length; ++i) { backend_internal *internal = git_vector_get(&db->backends, i); git_odb_backend *b = internal->backend; if (only_refreshed && !b->refresh) continue; if (!b->exists_prefix) continue; error = b->exists_prefix(&found, b, key, len); if (error == GIT_ENOTFOUND || error == GIT_PASSTHROUGH) continue; if (error) return error; /* make sure found item doesn't introduce ambiguity */ if (num_found) { if (git_oid__cmp(&last_found, &found)) return git_odb__error_ambiguous("multiple matches for prefix"); } else { git_oid_cpy(&last_found, &found); num_found++; } } if (!num_found) return GIT_ENOTFOUND; if (out) git_oid_cpy(out, &last_found); return 0; } int git_odb_exists_prefix( git_oid *out, git_odb *db, const git_oid *short_id, size_t len) { int error; git_oid key = {{0}}; assert(db && short_id); if (len < GIT_OID_MINPREFIXLEN) return git_odb__error_ambiguous("prefix length too short"); if (len > GIT_OID_HEXSZ) len = GIT_OID_HEXSZ; if (len == GIT_OID_HEXSZ) { if (git_odb_exists(db, short_id)) { if (out) git_oid_cpy(out, short_id); return 0; } else { return git_odb__error_notfound("no match for id prefix", short_id); } } /* just copy valid part of short_id */ memcpy(&key.id, short_id->id, (len + 1) / 2); if (len & 1) key.id[len / 2] &= 0xF0; error = odb_exists_prefix_1(out, db, &key, len, false); if (error == GIT_ENOTFOUND && !git_odb_refresh(db)) error = odb_exists_prefix_1(out, db, &key, len, true); if (error == GIT_ENOTFOUND) return git_odb__error_notfound("no match for id prefix", &key); return error; } int git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id) { int error; git_odb_object *object; error = git_odb__read_header_or_object(&object, len_p, type_p, db, id); if (object) git_odb_object_free(object); return error; } int git_odb__read_header_or_object( git_odb_object **out, size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id) { size_t i; int error = GIT_ENOTFOUND; git_odb_object *object; assert(db && id && out && len_p && type_p); if ((object = git_cache_get_raw(odb_cache(db), id)) != NULL) { *len_p = object->cached.size; *type_p = object->cached.type; *out = object; return 0; } *out = NULL; for (i = 0; i < db->backends.length && error < 0; ++i) { backend_internal *internal = git_vector_get(&db->backends, i); git_odb_backend *b = internal->backend; if (b->read_header != NULL) error = b->read_header(len_p, type_p, b, id); } if (!error || error == GIT_PASSTHROUGH) return 0; /* * no backend could read only the header. * try reading the whole object and freeing the contents */ if ((error = git_odb_read(&object, db, id)) < 0) return error; /* error already set - pass along */ *len_p = object->cached.size; *type_p = object->cached.type; *out = object; return 0; } static git_oid empty_blob = {{ 0xe6, 0x9d, 0xe2, 0x9b, 0xb2, 0xd1, 0xd6, 0x43, 0x4b, 0x8b, 0x29, 0xae, 0x77, 0x5a, 0xd8, 0xc2, 0xe4, 0x8c, 0x53, 0x91 }}; static git_oid empty_tree = {{ 0x4b, 0x82, 0x5d, 0xc6, 0x42, 0xcb, 0x6e, 0xb9, 0xa0, 0x60, 0xe5, 0x4b, 0xf8, 0xd6, 0x92, 0x88, 0xfb, 0xee, 0x49, 0x04 }}; static int hardcoded_objects(git_rawobj *raw, const git_oid *id) { if (!git_oid_cmp(id, &empty_blob)) { raw->type = GIT_OBJ_BLOB; raw->len = 0; raw->data = git__calloc(1, sizeof(uint8_t)); return 0; } else if (!git_oid_cmp(id, &empty_tree)) { raw->type = GIT_OBJ_TREE; raw->len = 0; raw->data = git__calloc(1, sizeof(uint8_t)); return 0; } else { return GIT_ENOTFOUND; } } static int odb_read_1(git_odb_object **out, git_odb *db, const git_oid *id, bool only_refreshed) { size_t i; git_rawobj raw; git_odb_object *object; bool found = false; if (!hardcoded_objects(&raw, id)) found = true; for (i = 0; i < db->backends.length && !found; ++i) { backend_internal *internal = git_vector_get(&db->backends, i); git_odb_backend *b = internal->backend; if (only_refreshed && !b->refresh) continue; if (b->read != NULL) { int error = b->read(&raw.data, &raw.len, &raw.type, b, id); if (error == GIT_PASSTHROUGH || error == GIT_ENOTFOUND) continue; if (error < 0) return error; found = true; } } if (!found) return GIT_ENOTFOUND; giterr_clear(); if ((object = odb_object__alloc(id, &raw)) == NULL) return -1; *out = git_cache_store_raw(odb_cache(db), object); return 0; } int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id) { int error; assert(out && db && id); *out = git_cache_get_raw(odb_cache(db), id); if (*out != NULL) return 0; error = odb_read_1(out, db, id, false); if (error == GIT_ENOTFOUND && !git_odb_refresh(db)) error = odb_read_1(out, db, id, true); if (error == GIT_ENOTFOUND) return git_odb__error_notfound("no match for id", id); return error; } static int read_prefix_1(git_odb_object **out, git_odb *db, const git_oid *key, size_t len, bool only_refreshed) { size_t i; int error = GIT_ENOTFOUND; git_oid found_full_oid = {{0}}; git_rawobj raw; void *data = NULL; bool found = false; git_odb_object *object; for (i = 0; i < db->backends.length; ++i) { backend_internal *internal = git_vector_get(&db->backends, i); git_odb_backend *b = internal->backend; if (only_refreshed && !b->refresh) continue; if (b->read_prefix != NULL) { git_oid full_oid; error = b->read_prefix(&full_oid, &raw.data, &raw.len, &raw.type, b, key, len); if (error == GIT_ENOTFOUND || error == GIT_PASSTHROUGH) continue; if (error) return error; git__free(data); data = raw.data; if (found && git_oid__cmp(&full_oid, &found_full_oid)) { git__free(raw.data); return git_odb__error_ambiguous("multiple matches for prefix"); } found_full_oid = full_oid; found = true; } } if (!found) return GIT_ENOTFOUND; if ((object = odb_object__alloc(&found_full_oid, &raw)) == NULL) return -1; *out = git_cache_store_raw(odb_cache(db), object); return 0; } int git_odb_read_prefix( git_odb_object **out, git_odb *db, const git_oid *short_id, size_t len) { git_oid key = {{0}}; int error; assert(out && db); if (len < GIT_OID_MINPREFIXLEN) return git_odb__error_ambiguous("prefix length too short"); if (len > GIT_OID_HEXSZ) len = GIT_OID_HEXSZ; if (len == GIT_OID_HEXSZ) { *out = git_cache_get_raw(odb_cache(db), short_id); if (*out != NULL) return 0; } /* just copy valid part of short_id */ memcpy(&key.id, short_id->id, (len + 1) / 2); if (len & 1) key.id[len / 2] &= 0xF0; error = read_prefix_1(out, db, &key, len, false); if (error == GIT_ENOTFOUND && !git_odb_refresh(db)) error = read_prefix_1(out, db, &key, len, true); if (error == GIT_ENOTFOUND) return git_odb__error_notfound("no match for prefix", &key); return error; } int git_odb_foreach(git_odb *db, git_odb_foreach_cb cb, void *payload) { unsigned int i; backend_internal *internal; git_vector_foreach(&db->backends, i, internal) { git_odb_backend *b = internal->backend; int error = b->foreach(b, cb, payload); if (error < 0) return error; } return 0; } int git_odb_write( git_oid *oid, git_odb *db, const void *data, size_t len, git_otype type) { size_t i; int error = GIT_ERROR; git_odb_stream *stream; assert(oid && db); git_odb_hash(oid, data, len, type); if (git_odb_exists(db, oid)) return 0; for (i = 0; i < db->backends.length && error < 0; ++i) { backend_internal *internal = git_vector_get(&db->backends, i); git_odb_backend *b = internal->backend; /* we don't write in alternates! */ if (internal->is_alternate) continue; if (b->write != NULL) error = b->write(b, oid, data, len, type); } if (!error || error == GIT_PASSTHROUGH) return 0; /* if no backends were able to write the object directly, we try a * streaming write to the backends; just write the whole object into the * stream in one push */ if ((error = git_odb_open_wstream(&stream, db, len, type)) != 0) return error; stream->write(stream, data, len); error = stream->finalize_write(stream, oid); git_odb_stream_free(stream); return error; } static void hash_header(git_hash_ctx *ctx, git_off_t size, git_otype type) { char header[64]; int hdrlen; hdrlen = git_odb__format_object_header(header, sizeof(header), size, type); git_hash_update(ctx, header, hdrlen); } int git_odb_open_wstream( git_odb_stream **stream, git_odb *db, git_off_t size, git_otype type) { size_t i, writes = 0; int error = GIT_ERROR; git_hash_ctx *ctx = NULL; assert(stream && db); for (i = 0; i < db->backends.length && error < 0; ++i) { backend_internal *internal = git_vector_get(&db->backends, i); git_odb_backend *b = internal->backend; /* we don't write in alternates! */ if (internal->is_alternate) continue; if (b->writestream != NULL) { ++writes; error = b->writestream(stream, b, size, type); } else if (b->write != NULL) { ++writes; error = init_fake_wstream(stream, b, size, type); } } if (error < 0) { if (error == GIT_PASSTHROUGH) error = 0; else if (!writes) error = git_odb__error_unsupported_in_backend("write object"); goto done; } ctx = git__malloc(sizeof(git_hash_ctx)); GITERR_CHECK_ALLOC(ctx); if ((error = git_hash_ctx_init(ctx)) < 0) goto done; hash_header(ctx, size, type); (*stream)->hash_ctx = ctx; (*stream)->declared_size = size; (*stream)->received_bytes = 0; done: return error; } static int git_odb_stream__invalid_length( const git_odb_stream *stream, const char *action) { giterr_set(GITERR_ODB, "Cannot %s - " "Invalid length. %"PRIuZ" was expected. The " "total size of the received chunks amounts to %"PRIuZ".", action, stream->declared_size, stream->received_bytes); return -1; } int git_odb_stream_write(git_odb_stream *stream, const char *buffer, size_t len) { git_hash_update(stream->hash_ctx, buffer, len); stream->received_bytes += len; if (stream->received_bytes > stream->declared_size) return git_odb_stream__invalid_length(stream, "stream_write()"); return stream->write(stream, buffer, len); } int git_odb_stream_finalize_write(git_oid *out, git_odb_stream *stream) { if (stream->received_bytes != stream->declared_size) return git_odb_stream__invalid_length(stream, "stream_finalize_write()"); git_hash_final(out, stream->hash_ctx); if (git_odb_exists(stream->backend->odb, out)) return 0; return stream->finalize_write(stream, out); } int git_odb_stream_read(git_odb_stream *stream, char *buffer, size_t len) { return stream->read(stream, buffer, len); } void git_odb_stream_free(git_odb_stream *stream) { if (stream == NULL) return; git_hash_ctx_cleanup(stream->hash_ctx); git__free(stream->hash_ctx); stream->free(stream); } int git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const git_oid *oid) { size_t i, reads = 0; int error = GIT_ERROR; assert(stream && db); for (i = 0; i < db->backends.length && error < 0; ++i) { backend_internal *internal = git_vector_get(&db->backends, i); git_odb_backend *b = internal->backend; if (b->readstream != NULL) { ++reads; error = b->readstream(stream, b, oid); } } if (error == GIT_PASSTHROUGH) error = 0; if (error < 0 && !reads) error = git_odb__error_unsupported_in_backend("read object streamed"); return error; } int git_odb_write_pack(struct git_odb_writepack **out, git_odb *db, git_transfer_progress_cb progress_cb, void *progress_payload) { size_t i, writes = 0; int error = GIT_ERROR; assert(out && db); for (i = 0; i < db->backends.length && error < 0; ++i) { backend_internal *internal = git_vector_get(&db->backends, i); git_odb_backend *b = internal->backend; /* we don't write in alternates! */ if (internal->is_alternate) continue; if (b->writepack != NULL) { ++writes; error = b->writepack(out, b, db, progress_cb, progress_payload); } } if (error == GIT_PASSTHROUGH) error = 0; if (error < 0 && !writes) error = git_odb__error_unsupported_in_backend("write pack"); return error; } void *git_odb_backend_malloc(git_odb_backend *backend, size_t len) { GIT_UNUSED(backend); return git__malloc(len); } int git_odb_refresh(struct git_odb *db) { size_t i; assert(db); for (i = 0; i < db->backends.length; ++i) { backend_internal *internal = git_vector_get(&db->backends, i); git_odb_backend *b = internal->backend; if (b->refresh != NULL) { int error = b->refresh(b); if (error < 0) return error; } } return 0; } int git_odb__error_notfound(const char *message, const git_oid *oid) { if (oid != NULL) { char oid_str[GIT_OID_HEXSZ + 1]; git_oid_tostr(oid_str, sizeof(oid_str), oid); giterr_set(GITERR_ODB, "Object not found - %s (%s)", message, oid_str); } else giterr_set(GITERR_ODB, "Object not found - %s", message); return GIT_ENOTFOUND; } int git_odb__error_ambiguous(const char *message) { giterr_set(GITERR_ODB, "Ambiguous SHA1 prefix - %s", message); return GIT_EAMBIGUOUS; } int git_odb_init_backend(git_odb_backend *backend, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( backend, version, git_odb_backend, GIT_ODB_BACKEND_INIT); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/oidmap.h0000664000175000017500000000261012610310643015307 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_oidmap_h__ #define INCLUDE_oidmap_h__ #include "common.h" #include "git2/oid.h" #define kmalloc git__malloc #define kcalloc git__calloc #define krealloc git__realloc #define kreallocarray git__reallocarray #define kfree git__free #include "khash.h" __KHASH_TYPE(oid, const git_oid *, void *) typedef khash_t(oid) git_oidmap; GIT_INLINE(khint_t) git_oidmap_hash(const git_oid *oid) { khint_t h; memcpy(&h, oid, sizeof(khint_t)); return h; } #define GIT__USE_OIDMAP \ __KHASH_IMPL(oid, static kh_inline, const git_oid *, void *, 1, git_oidmap_hash, git_oid_equal) #define git_oidmap_alloc() kh_init(oid) #define git_oidmap_free(h) kh_destroy(oid,h), h = NULL #define git_oidmap_lookup_index(h, k) kh_get(oid, h, k) #define git_oidmap_valid_index(h, idx) (idx != kh_end(h)) #define git_oidmap_value_at(h, idx) kh_val(h, idx) #define git_oidmap_insert(h, key, val, rval) do { \ khiter_t __pos = kh_put(oid, h, key, &rval); \ if (rval >= 0) { \ if (rval == 0) kh_key(h, __pos) = key; \ kh_val(h, __pos) = val; \ } } while (0) #define git_oidmap_foreach_value kh_foreach_value #define git_oidmap_size(h) kh_size(h) #define git_oidmap_clear(h) kh_clear(oid, h) #endif deps/libgit2-sys-0.3.8/libgit2/src/attrcache.c0000664000175000017500000002473112510265101015774 0ustar #include "common.h" #include "repository.h" #include "attr_file.h" #include "config.h" #include "sysdir.h" #include "ignore.h" GIT__USE_STRMAP GIT_INLINE(int) attr_cache_lock(git_attr_cache *cache) { GIT_UNUSED(cache); /* avoid warning if threading is off */ if (git_mutex_lock(&cache->lock) < 0) { giterr_set(GITERR_OS, "Unable to get attr cache lock"); return -1; } return 0; } GIT_INLINE(void) attr_cache_unlock(git_attr_cache *cache) { GIT_UNUSED(cache); /* avoid warning if threading is off */ git_mutex_unlock(&cache->lock); } GIT_INLINE(git_attr_file_entry *) attr_cache_lookup_entry( git_attr_cache *cache, const char *path) { khiter_t pos = git_strmap_lookup_index(cache->files, path); if (git_strmap_valid_index(cache->files, pos)) return git_strmap_value_at(cache->files, pos); else return NULL; } int git_attr_cache__alloc_file_entry( git_attr_file_entry **out, const char *base, const char *path, git_pool *pool) { size_t baselen = 0, pathlen = strlen(path); size_t cachesize = sizeof(git_attr_file_entry) + pathlen + 1; git_attr_file_entry *ce; if (base != NULL && git_path_root(path) < 0) { baselen = strlen(base); cachesize += baselen; if (baselen && base[baselen - 1] != '/') cachesize++; } ce = git_pool_mallocz(pool, (uint32_t)cachesize); GITERR_CHECK_ALLOC(ce); if (baselen) { memcpy(ce->fullpath, base, baselen); if (base[baselen - 1] != '/') ce->fullpath[baselen++] = '/'; } memcpy(&ce->fullpath[baselen], path, pathlen); ce->path = &ce->fullpath[baselen]; *out = ce; return 0; } /* call with attrcache locked */ static int attr_cache_make_entry( git_attr_file_entry **out, git_repository *repo, const char *path) { int error = 0; git_attr_cache *cache = git_repository_attr_cache(repo); git_attr_file_entry *entry = NULL; error = git_attr_cache__alloc_file_entry( &entry, git_repository_workdir(repo), path, &cache->pool); if (!error) { git_strmap_insert(cache->files, entry->path, entry, error); if (error > 0) error = 0; } *out = entry; return error; } /* insert entry or replace existing if we raced with another thread */ static int attr_cache_upsert(git_attr_cache *cache, git_attr_file *file) { git_attr_file_entry *entry; git_attr_file *old; if (attr_cache_lock(cache) < 0) return -1; entry = attr_cache_lookup_entry(cache, file->entry->path); GIT_REFCOUNT_OWN(file, entry); GIT_REFCOUNT_INC(file); old = git__compare_and_swap( &entry->file[file->source], entry->file[file->source], file); if (old) { GIT_REFCOUNT_OWN(old, NULL); git_attr_file__free(old); } attr_cache_unlock(cache); return 0; } static int attr_cache_remove(git_attr_cache *cache, git_attr_file *file) { int error = 0; git_attr_file_entry *entry; if (!file) return 0; if ((error = attr_cache_lock(cache)) < 0) return error; if ((entry = attr_cache_lookup_entry(cache, file->entry->path)) != NULL) file = git__compare_and_swap(&entry->file[file->source], file, NULL); attr_cache_unlock(cache); if (file) { GIT_REFCOUNT_OWN(file, NULL); git_attr_file__free(file); } return error; } /* Look up cache entry and file. * - If entry is not present, create it while the cache is locked. * - If file is present, increment refcount before returning it, so the * cache can be unlocked and it won't go away. */ static int attr_cache_lookup( git_attr_file **out_file, git_attr_file_entry **out_entry, git_repository *repo, git_attr_session *attr_session, git_attr_file_source source, const char *base, const char *filename) { int error = 0; git_buf path = GIT_BUF_INIT; const char *wd = git_repository_workdir(repo), *relfile; git_attr_cache *cache = git_repository_attr_cache(repo); git_attr_file_entry *entry = NULL; git_attr_file *file = NULL; /* join base and path as needed */ if (base != NULL && git_path_root(filename) < 0) { git_buf *p = attr_session ? &attr_session->tmp : &path; if (git_buf_joinpath(p, base, filename) < 0) return -1; filename = p->ptr; } relfile = filename; if (wd && !git__prefixcmp(relfile, wd)) relfile += strlen(wd); /* check cache for existing entry */ if ((error = attr_cache_lock(cache)) < 0) goto cleanup; entry = attr_cache_lookup_entry(cache, relfile); if (!entry) error = attr_cache_make_entry(&entry, repo, relfile); else if (entry->file[source] != NULL) { file = entry->file[source]; GIT_REFCOUNT_INC(file); } attr_cache_unlock(cache); cleanup: *out_file = file; *out_entry = entry; git_buf_free(&path); return error; } int git_attr_cache__get( git_attr_file **out, git_repository *repo, git_attr_session *attr_session, git_attr_file_source source, const char *base, const char *filename, git_attr_file_parser parser) { int error = 0; git_attr_cache *cache = git_repository_attr_cache(repo); git_attr_file_entry *entry = NULL; git_attr_file *file = NULL, *updated = NULL; if ((error = attr_cache_lookup( &file, &entry, repo, attr_session, source, base, filename)) < 0) return error; /* load file if we don't have one or if existing one is out of date */ if (!file || (error = git_attr_file__out_of_date(repo, attr_session, file)) > 0) error = git_attr_file__load(&updated, repo, attr_session, entry, source, parser); /* if we loaded the file, insert into and/or update cache */ if (updated) { if ((error = attr_cache_upsert(cache, updated)) < 0) git_attr_file__free(updated); else { git_attr_file__free(file); /* offset incref from lookup */ file = updated; } } /* if file could not be loaded */ if (error < 0) { /* remove existing entry */ if (file) { attr_cache_remove(cache, file); git_attr_file__free(file); /* offset incref from lookup */ file = NULL; } /* no error if file simply doesn't exist */ if (error == GIT_ENOTFOUND) { giterr_clear(); error = 0; } } *out = file; return error; } bool git_attr_cache__is_cached( git_repository *repo, git_attr_file_source source, const char *filename) { git_attr_cache *cache = git_repository_attr_cache(repo); git_strmap *files; khiter_t pos; git_attr_file_entry *entry; if (!cache || !(files = cache->files)) return false; pos = git_strmap_lookup_index(files, filename); if (!git_strmap_valid_index(files, pos)) return false; entry = git_strmap_value_at(files, pos); return entry && (entry->file[source] != NULL); } static int attr_cache__lookup_path( char **out, git_config *cfg, const char *key, const char *fallback) { git_buf buf = GIT_BUF_INIT; int error; git_config_entry *entry = NULL; *out = NULL; if ((error = git_config__lookup_entry(&entry, cfg, key, false)) < 0) return error; if (entry) { const char *cfgval = entry->value; /* expand leading ~/ as needed */ if (cfgval && cfgval[0] == '~' && cfgval[1] == '/' && !git_sysdir_find_global_file(&buf, &cfgval[2])) *out = git_buf_detach(&buf); else if (cfgval) *out = git__strdup(cfgval); } else if (!git_sysdir_find_xdg_file(&buf, fallback)) *out = git_buf_detach(&buf); git_config_entry_free(entry); git_buf_free(&buf); return error; } static void attr_cache__free(git_attr_cache *cache) { bool unlock; if (!cache) return; unlock = (git_mutex_lock(&cache->lock) == 0); if (cache->files != NULL) { git_attr_file_entry *entry; git_attr_file *file; int i; git_strmap_foreach_value(cache->files, entry, { for (i = 0; i < GIT_ATTR_FILE_NUM_SOURCES; ++i) { if ((file = git__swap(entry->file[i], NULL)) != NULL) { GIT_REFCOUNT_OWN(file, NULL); git_attr_file__free(file); } } }); git_strmap_free(cache->files); } if (cache->macros != NULL) { git_attr_rule *rule; git_strmap_foreach_value(cache->macros, rule, { git_attr_rule__free(rule); }); git_strmap_free(cache->macros); } git_pool_clear(&cache->pool); git__free(cache->cfg_attr_file); cache->cfg_attr_file = NULL; git__free(cache->cfg_excl_file); cache->cfg_excl_file = NULL; if (unlock) git_mutex_unlock(&cache->lock); git_mutex_free(&cache->lock); git__free(cache); } int git_attr_cache__do_init(git_repository *repo) { int ret = 0; git_attr_cache *cache = git_repository_attr_cache(repo); git_config *cfg = NULL; if (cache) return 0; cache = git__calloc(1, sizeof(git_attr_cache)); GITERR_CHECK_ALLOC(cache); /* set up lock */ if (git_mutex_init(&cache->lock) < 0) { giterr_set(GITERR_OS, "Unable to initialize lock for attr cache"); git__free(cache); return -1; } if ((ret = git_repository_config_snapshot(&cfg, repo)) < 0) goto cancel; /* cache config settings for attributes and ignores */ ret = attr_cache__lookup_path( &cache->cfg_attr_file, cfg, GIT_ATTR_CONFIG, GIT_ATTR_FILE_XDG); if (ret < 0) goto cancel; ret = attr_cache__lookup_path( &cache->cfg_excl_file, cfg, GIT_IGNORE_CONFIG, GIT_IGNORE_FILE_XDG); if (ret < 0) goto cancel; /* allocate hashtable for attribute and ignore file contents, * hashtable for attribute macros, and string pool */ if ((ret = git_strmap_alloc(&cache->files)) < 0 || (ret = git_strmap_alloc(&cache->macros)) < 0 || (ret = git_pool_init(&cache->pool, 1, 0)) < 0) goto cancel; cache = git__compare_and_swap(&repo->attrcache, NULL, cache); if (cache) goto cancel; /* raced with another thread, free this but no error */ git_config_free(cfg); /* insert default macros */ return git_attr_add_macro(repo, "binary", "-diff -crlf -text"); cancel: attr_cache__free(cache); git_config_free(cfg); return ret; } void git_attr_cache_flush(git_repository *repo) { git_attr_cache *cache; /* this could be done less expensively, but for now, we'll just free * the entire attrcache and let the next use reinitialize it... */ if (repo && (cache = git__swap(repo->attrcache, NULL)) != NULL) attr_cache__free(cache); } int git_attr_cache__insert_macro(git_repository *repo, git_attr_rule *macro) { git_attr_cache *cache = git_repository_attr_cache(repo); git_strmap *macros = cache->macros; int error; /* TODO: generate warning log if (macro->assigns.length == 0) */ if (macro->assigns.length == 0) return 0; if (git_mutex_lock(&cache->lock) < 0) { giterr_set(GITERR_OS, "Unable to get attr cache lock"); error = -1; } else { git_strmap_insert(macros, macro->match.pattern, macro, error); git_mutex_unlock(&cache->lock); } return (error < 0) ? -1 : 0; } git_attr_rule *git_attr_cache__lookup_macro( git_repository *repo, const char *name) { git_strmap *macros = git_repository_attr_cache(repo)->macros; khiter_t pos; pos = git_strmap_lookup_index(macros, name); if (!git_strmap_valid_index(macros, pos)) return NULL; return (git_attr_rule *)git_strmap_value_at(macros, pos); } deps/libgit2-sys-0.3.8/libgit2/src/delta-apply.c0000664000175000017500000000622612510265101016251 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "git2/odb.h" #include "delta-apply.h" /* * This file was heavily cribbed from BinaryDelta.java in JGit, which * itself was heavily cribbed from patch-delta.c in the * GIT project. The original delta patching code was written by * Nicolas Pitre . */ static int hdr_sz( size_t *size, const unsigned char **delta, const unsigned char *end) { const unsigned char *d = *delta; size_t r = 0; unsigned int c, shift = 0; do { if (d == end) return -1; c = *d++; r |= (c & 0x7f) << shift; shift += 7; } while (c & 0x80); *delta = d; *size = r; return 0; } int git__delta_read_header( const unsigned char *delta, size_t delta_len, size_t *base_sz, size_t *res_sz) { const unsigned char *delta_end = delta + delta_len; if ((hdr_sz(base_sz, &delta, delta_end) < 0) || (hdr_sz(res_sz, &delta, delta_end) < 0)) return -1; return 0; } int git__delta_apply( git_rawobj *out, const unsigned char *base, size_t base_len, const unsigned char *delta, size_t delta_len) { const unsigned char *delta_end = delta + delta_len; size_t base_sz, res_sz, alloc_sz; unsigned char *res_dp; /* Check that the base size matches the data we were given; * if not we would underflow while accessing data from the * base object, resulting in data corruption or segfault. */ if ((hdr_sz(&base_sz, &delta, delta_end) < 0) || (base_sz != base_len)) { giterr_set(GITERR_INVALID, "Failed to apply delta. Base size does not match given data"); return -1; } if (hdr_sz(&res_sz, &delta, delta_end) < 0) { giterr_set(GITERR_INVALID, "Failed to apply delta. Base size does not match given data"); return -1; } GITERR_CHECK_ALLOC_ADD(&alloc_sz, res_sz, 1); res_dp = git__malloc(alloc_sz); GITERR_CHECK_ALLOC(res_dp); res_dp[res_sz] = '\0'; out->data = res_dp; out->len = res_sz; while (delta < delta_end) { unsigned char cmd = *delta++; if (cmd & 0x80) { /* cmd is a copy instruction; copy from the base. */ size_t off = 0, len = 0; if (cmd & 0x01) off = *delta++; if (cmd & 0x02) off |= *delta++ << 8; if (cmd & 0x04) off |= *delta++ << 16; if (cmd & 0x08) off |= *delta++ << 24; if (cmd & 0x10) len = *delta++; if (cmd & 0x20) len |= *delta++ << 8; if (cmd & 0x40) len |= *delta++ << 16; if (!len) len = 0x10000; if (base_len < off + len || res_sz < len) goto fail; memcpy(res_dp, base + off, len); res_dp += len; res_sz -= len; } else if (cmd) { /* cmd is a literal insert instruction; copy from * the delta stream itself. */ if (delta_end - delta < cmd || res_sz < cmd) goto fail; memcpy(res_dp, delta, cmd); delta += cmd; res_dp += cmd; res_sz -= cmd; } else { /* cmd == 0 is reserved for future encodings. */ goto fail; } } if (delta != delta_end || res_sz) goto fail; return 0; fail: git__free(out->data); out->data = NULL; giterr_set(GITERR_INVALID, "Failed to apply delta"); return -1; } deps/libgit2-sys-0.3.8/libgit2/src/refspec.h0000664000175000017500000000213112426525445015500 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_refspec_h__ #define INCLUDE_refspec_h__ #include "git2/refspec.h" #include "buffer.h" #include "vector.h" struct git_refspec { char *string; char *src; char *dst; unsigned int force :1, push : 1, pattern :1, matching :1; }; #define GIT_REFSPEC_TAGS "refs/tags/*:refs/tags/*" int git_refspec__parse( struct git_refspec *refspec, const char *str, bool is_fetch); void git_refspec__free(git_refspec *refspec); int git_refspec__serialize(git_buf *out, const git_refspec *refspec); /** * Determines if a refspec is a wildcard refspec. * * @param spec the refspec * @return 1 if the refspec is a wildcard, 0 otherwise */ int git_refspec_is_wildcard(const git_refspec *spec); /** * DWIM `spec` with `refs` existing on the remote, append the dwim'ed * result in `out`. */ int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs); #endif deps/libgit2-sys-0.3.8/libgit2/src/posix.h0000664000175000017500000000704312555730137015221 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_posix_h__ #define INCLUDE_posix_h__ #include "common.h" #include #include #include "fnmatch.h" /* stat: file mode type testing macros */ #ifndef S_IFGITLINK #define S_IFGITLINK 0160000 #define S_ISGITLINK(m) (((m) & S_IFMT) == S_IFGITLINK) #endif #ifndef S_IFLNK #define S_IFLNK 0120000 #undef _S_IFLNK #define _S_IFLNK S_IFLNK #endif #ifndef S_IXUSR #define S_IXUSR 00100 #endif #ifndef S_ISLNK #define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK) #endif #ifndef S_ISDIR #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) #endif #ifndef S_ISREG #define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) #endif #ifndef S_ISFIFO #define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO) #endif /* if S_ISGID is not defined, then don't try to set it */ #ifndef S_ISGID #define S_ISGID 0 #endif #ifndef O_BINARY #define O_BINARY 0 #endif #ifndef O_CLOEXEC #define O_CLOEXEC 0 #endif /* access() mode parameter #defines */ #ifndef F_OK #define F_OK 0 /* existence check */ #endif #ifndef W_OK #define W_OK 2 /* write mode check */ #endif #ifndef R_OK #define R_OK 4 /* read mode check */ #endif /* Determine whether an errno value indicates that a read or write failed * because the descriptor is blocked. */ #if defined(EWOULDBLOCK) #define GIT_ISBLOCKED(e) ((e) == EAGAIN || (e) == EWOULDBLOCK) #else #define GIT_ISBLOCKED(e) ((e) == EAGAIN) #endif /* define some standard errnos that the runtime may be missing. for example, * mingw lacks EAFNOSUPPORT. */ #ifndef EAFNOSUPPORT #define EAFNOSUPPORT (INT_MAX-1) #endif typedef int git_file; /** * Standard POSIX Methods * * All the methods starting with the `p_` prefix are * direct ports of the standard POSIX methods. * * Some of the methods are slightly wrapped to provide * saner defaults. Some of these methods are emulated * in Windows platforms. * * Use your manpages to check the docs on these. */ extern ssize_t p_read(git_file fd, void *buf, size_t cnt); extern int p_write(git_file fd, const void *buf, size_t cnt); #define p_close(fd) close(fd) #define p_umask(m) umask(m) extern int p_open(const char *path, int flags, ...); extern int p_creat(const char *path, mode_t mode); extern int p_getcwd(char *buffer_out, size_t size); extern int p_rename(const char *from, const char *to); extern int git__page_size(size_t *page_size); /** * Platform-dependent methods */ #ifdef GIT_WIN32 # include "win32/posix.h" #else # include "unix/posix.h" #endif #include "strnlen.h" #ifdef NO_READDIR_R GIT_INLINE(int) p_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) { GIT_UNUSED(entry); *result = readdir(dirp); return 0; } #else /* NO_READDIR_R */ # define p_readdir_r(d,e,r) readdir_r(d,e,r) #endif #ifdef NO_ADDRINFO # include struct addrinfo { struct hostent *ai_hostent; struct servent *ai_servent; struct sockaddr_in ai_addr_in; struct sockaddr *ai_addr; size_t ai_addrlen; int ai_family; int ai_socktype; int ai_protocol; long ai_port; struct addrinfo *ai_next; }; extern int p_getaddrinfo(const char *host, const char *port, struct addrinfo *hints, struct addrinfo **info); extern void p_freeaddrinfo(struct addrinfo *info); extern const char *p_gai_strerror(int ret); #else # define p_getaddrinfo(a, b, c, d) getaddrinfo(a, b, c, d) # define p_freeaddrinfo(a) freeaddrinfo(a) # define p_gai_strerror(c) gai_strerror(c) #endif /* NO_ADDRINFO */ #endif deps/libgit2-sys-0.3.8/libgit2/src/diff_tform.c0000664000175000017500000007221712555730137016176 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "git2/config.h" #include "git2/blob.h" #include "git2/sys/hashsig.h" #include "diff.h" #include "path.h" #include "fileops.h" #include "config.h" git_diff_delta *git_diff__delta_dup( const git_diff_delta *d, git_pool *pool) { git_diff_delta *delta = git__malloc(sizeof(git_diff_delta)); if (!delta) return NULL; memcpy(delta, d, sizeof(git_diff_delta)); GIT_DIFF_FLAG__CLEAR_INTERNAL(delta->flags); if (d->old_file.path != NULL) { delta->old_file.path = git_pool_strdup(pool, d->old_file.path); if (delta->old_file.path == NULL) goto fail; } if (d->new_file.path != d->old_file.path && d->new_file.path != NULL) { delta->new_file.path = git_pool_strdup(pool, d->new_file.path); if (delta->new_file.path == NULL) goto fail; } else { delta->new_file.path = delta->old_file.path; } return delta; fail: git__free(delta); return NULL; } git_diff_delta *git_diff__merge_like_cgit( const git_diff_delta *a, const git_diff_delta *b, git_pool *pool) { git_diff_delta *dup; /* Emulate C git for merging two diffs (a la 'git diff '). * * When C git does a diff between the work dir and a tree, it actually * diffs with the index but uses the workdir contents. This emulates * those choices so we can emulate the type of diff. * * We have three file descriptions here, let's call them: * f1 = a->old_file * f2 = a->new_file AND b->old_file * f3 = b->new_file */ /* If one of the diffs is a conflict, just dup it */ if (b->status == GIT_DELTA_CONFLICTED) return git_diff__delta_dup(b, pool); if (a->status == GIT_DELTA_CONFLICTED) return git_diff__delta_dup(a, pool); /* if f2 == f3 or f2 is deleted, then just dup the 'a' diff */ if (b->status == GIT_DELTA_UNMODIFIED || a->status == GIT_DELTA_DELETED) return git_diff__delta_dup(a, pool); /* otherwise, base this diff on the 'b' diff */ if ((dup = git_diff__delta_dup(b, pool)) == NULL) return NULL; /* If 'a' status is uninteresting, then we're done */ if (a->status == GIT_DELTA_UNMODIFIED || a->status == GIT_DELTA_UNTRACKED || a->status == GIT_DELTA_UNREADABLE) return dup; assert(b->status != GIT_DELTA_UNMODIFIED); /* A cgit exception is that the diff of a file that is only in the * index (i.e. not in HEAD nor workdir) is given as empty. */ if (dup->status == GIT_DELTA_DELETED) { if (a->status == GIT_DELTA_ADDED) { dup->status = GIT_DELTA_UNMODIFIED; dup->nfiles = 2; } /* else don't overwrite DELETE status */ } else { dup->status = a->status; dup->nfiles = a->nfiles; } git_oid_cpy(&dup->old_file.id, &a->old_file.id); dup->old_file.mode = a->old_file.mode; dup->old_file.size = a->old_file.size; dup->old_file.flags = a->old_file.flags; return dup; } int git_diff__merge( git_diff *onto, const git_diff *from, git_diff__merge_cb cb) { int error = 0; git_pool onto_pool; git_vector onto_new; git_diff_delta *delta; bool ignore_case, reversed; unsigned int i, j; assert(onto && from); if (!from->deltas.length) return 0; ignore_case = ((onto->opts.flags & GIT_DIFF_IGNORE_CASE) != 0); reversed = ((onto->opts.flags & GIT_DIFF_REVERSE) != 0); if (ignore_case != ((from->opts.flags & GIT_DIFF_IGNORE_CASE) != 0) || reversed != ((from->opts.flags & GIT_DIFF_REVERSE) != 0)) { giterr_set(GITERR_INVALID, "Attempt to merge diffs created with conflicting options"); return -1; } if (git_vector_init( &onto_new, onto->deltas.length, git_diff_delta__cmp) < 0 || git_pool_init(&onto_pool, 1, 0) < 0) return -1; for (i = 0, j = 0; i < onto->deltas.length || j < from->deltas.length; ) { git_diff_delta *o = GIT_VECTOR_GET(&onto->deltas, i); const git_diff_delta *f = GIT_VECTOR_GET(&from->deltas, j); int cmp = !f ? -1 : !o ? 1 : STRCMP_CASESELECT(ignore_case, o->old_file.path, f->old_file.path); if (cmp < 0) { delta = git_diff__delta_dup(o, &onto_pool); i++; } else if (cmp > 0) { delta = git_diff__delta_dup(f, &onto_pool); j++; } else { const git_diff_delta *left = reversed ? f : o; const git_diff_delta *right = reversed ? o : f; delta = cb(left, right, &onto_pool); i++; j++; } /* the ignore rules for the target may not match the source * or the result of a merged delta could be skippable... */ if (delta && git_diff_delta__should_skip(&onto->opts, delta)) { git__free(delta); continue; } if ((error = !delta ? -1 : git_vector_insert(&onto_new, delta)) < 0) break; } if (!error) { git_vector_swap(&onto->deltas, &onto_new); git_pool_swap(&onto->pool, &onto_pool); if ((onto->opts.flags & GIT_DIFF_REVERSE) != 0) onto->old_src = from->old_src; else onto->new_src = from->new_src; /* prefix strings also come from old pool, so recreate those.*/ onto->opts.old_prefix = git_pool_strdup_safe(&onto->pool, onto->opts.old_prefix); onto->opts.new_prefix = git_pool_strdup_safe(&onto->pool, onto->opts.new_prefix); } git_vector_free_deep(&onto_new); git_pool_clear(&onto_pool); return error; } int git_diff_merge(git_diff *onto, const git_diff *from) { return git_diff__merge(onto, from, git_diff__merge_like_cgit); } int git_diff_find_similar__hashsig_for_file( void **out, const git_diff_file *f, const char *path, void *p) { git_hashsig_option_t opt = (git_hashsig_option_t)(intptr_t)p; GIT_UNUSED(f); return git_hashsig_create_fromfile((git_hashsig **)out, path, opt); } int git_diff_find_similar__hashsig_for_buf( void **out, const git_diff_file *f, const char *buf, size_t len, void *p) { git_hashsig_option_t opt = (git_hashsig_option_t)(intptr_t)p; GIT_UNUSED(f); return git_hashsig_create((git_hashsig **)out, buf, len, opt); } void git_diff_find_similar__hashsig_free(void *sig, void *payload) { GIT_UNUSED(payload); git_hashsig_free(sig); } int git_diff_find_similar__calc_similarity( int *score, void *siga, void *sigb, void *payload) { int error; GIT_UNUSED(payload); error = git_hashsig_compare(siga, sigb); if (error < 0) return error; *score = error; return 0; } #define DEFAULT_THRESHOLD 50 #define DEFAULT_BREAK_REWRITE_THRESHOLD 60 #define DEFAULT_RENAME_LIMIT 200 static int normalize_find_opts( git_diff *diff, git_diff_find_options *opts, const git_diff_find_options *given) { git_config *cfg = NULL; git_hashsig_option_t hashsig_opts; GITERR_CHECK_VERSION(given, GIT_DIFF_FIND_OPTIONS_VERSION, "git_diff_find_options"); if (diff->repo != NULL && git_repository_config__weakptr(&cfg, diff->repo) < 0) return -1; if (given) memcpy(opts, given, sizeof(*opts)); if (!given || (given->flags & GIT_DIFF_FIND_ALL) == GIT_DIFF_FIND_BY_CONFIG) { char *rule = git_config__get_string_force(cfg, "diff.renames", "true"); int boolval; if (!git__parse_bool(&boolval, rule) && !boolval) /* don't set FIND_RENAMES if bool value is false */; else if (!strcasecmp(rule, "copies") || !strcasecmp(rule, "copy")) opts->flags |= GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES; else opts->flags |= GIT_DIFF_FIND_RENAMES; git__free(rule); } /* some flags imply others */ if (opts->flags & GIT_DIFF_FIND_EXACT_MATCH_ONLY) { /* if we are only looking for exact matches, then don't turn * MODIFIED items into ADD/DELETE pairs because it's too picky */ opts->flags &= ~(GIT_DIFF_FIND_REWRITES | GIT_DIFF_BREAK_REWRITES); /* similarly, don't look for self-rewrites to split */ opts->flags &= ~GIT_DIFF_FIND_RENAMES_FROM_REWRITES; } if (opts->flags & GIT_DIFF_FIND_RENAMES_FROM_REWRITES) opts->flags |= GIT_DIFF_FIND_RENAMES; if (opts->flags & GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED) opts->flags |= GIT_DIFF_FIND_COPIES; if (opts->flags & GIT_DIFF_BREAK_REWRITES) opts->flags |= GIT_DIFF_FIND_REWRITES; #define USE_DEFAULT(X) ((X) == 0 || (X) > 100) if (USE_DEFAULT(opts->rename_threshold)) opts->rename_threshold = DEFAULT_THRESHOLD; if (USE_DEFAULT(opts->rename_from_rewrite_threshold)) opts->rename_from_rewrite_threshold = DEFAULT_THRESHOLD; if (USE_DEFAULT(opts->copy_threshold)) opts->copy_threshold = DEFAULT_THRESHOLD; if (USE_DEFAULT(opts->break_rewrite_threshold)) opts->break_rewrite_threshold = DEFAULT_BREAK_REWRITE_THRESHOLD; #undef USE_DEFAULT if (!opts->rename_limit) { opts->rename_limit = git_config__get_int_force( cfg, "diff.renamelimit", DEFAULT_RENAME_LIMIT); if (opts->rename_limit <= 0) opts->rename_limit = DEFAULT_RENAME_LIMIT; } /* assign the internal metric with whitespace flag as payload */ if (!opts->metric) { opts->metric = git__malloc(sizeof(git_diff_similarity_metric)); GITERR_CHECK_ALLOC(opts->metric); opts->metric->file_signature = git_diff_find_similar__hashsig_for_file; opts->metric->buffer_signature = git_diff_find_similar__hashsig_for_buf; opts->metric->free_signature = git_diff_find_similar__hashsig_free; opts->metric->similarity = git_diff_find_similar__calc_similarity; if (opts->flags & GIT_DIFF_FIND_IGNORE_WHITESPACE) hashsig_opts = GIT_HASHSIG_IGNORE_WHITESPACE; else if (opts->flags & GIT_DIFF_FIND_DONT_IGNORE_WHITESPACE) hashsig_opts = GIT_HASHSIG_NORMAL; else hashsig_opts = GIT_HASHSIG_SMART_WHITESPACE; hashsig_opts |= GIT_HASHSIG_ALLOW_SMALL_FILES; opts->metric->payload = (void *)hashsig_opts; } return 0; } static int insert_delete_side_of_split( git_diff *diff, git_vector *onto, const git_diff_delta *delta) { /* make new record for DELETED side of split */ git_diff_delta *deleted = git_diff__delta_dup(delta, &diff->pool); GITERR_CHECK_ALLOC(deleted); deleted->status = GIT_DELTA_DELETED; deleted->nfiles = 1; memset(&deleted->new_file, 0, sizeof(deleted->new_file)); deleted->new_file.path = deleted->old_file.path; deleted->new_file.flags |= GIT_DIFF_FLAG_VALID_ID; return git_vector_insert(onto, deleted); } static int apply_splits_and_deletes( git_diff *diff, size_t expected_size, bool actually_split) { git_vector onto = GIT_VECTOR_INIT; size_t i; git_diff_delta *delta; if (git_vector_init(&onto, expected_size, git_diff_delta__cmp) < 0) return -1; /* build new delta list without TO_DELETE and splitting TO_SPLIT */ git_vector_foreach(&diff->deltas, i, delta) { if ((delta->flags & GIT_DIFF_FLAG__TO_DELETE) != 0) continue; if ((delta->flags & GIT_DIFF_FLAG__TO_SPLIT) != 0 && actually_split) { delta->similarity = 0; if (insert_delete_side_of_split(diff, &onto, delta) < 0) goto on_error; if (diff->new_src == GIT_ITERATOR_TYPE_WORKDIR) delta->status = GIT_DELTA_UNTRACKED; else delta->status = GIT_DELTA_ADDED; delta->nfiles = 1; memset(&delta->old_file, 0, sizeof(delta->old_file)); delta->old_file.path = delta->new_file.path; delta->old_file.flags |= GIT_DIFF_FLAG_VALID_ID; } /* clean up delta before inserting into new list */ GIT_DIFF_FLAG__CLEAR_INTERNAL(delta->flags); if (delta->status != GIT_DELTA_COPIED && delta->status != GIT_DELTA_RENAMED && (delta->status != GIT_DELTA_MODIFIED || actually_split)) delta->similarity = 0; /* insert into new list */ if (git_vector_insert(&onto, delta) < 0) goto on_error; } /* cannot return an error past this point */ /* free deltas from old list that didn't make it to the new one */ git_vector_foreach(&diff->deltas, i, delta) { if ((delta->flags & GIT_DIFF_FLAG__TO_DELETE) != 0) git__free(delta); } /* swap new delta list into place */ git_vector_swap(&diff->deltas, &onto); git_vector_free(&onto); git_vector_sort(&diff->deltas); return 0; on_error: git_vector_free_deep(&onto); return -1; } GIT_INLINE(git_diff_file *) similarity_get_file(git_diff *diff, size_t idx) { git_diff_delta *delta = git_vector_get(&diff->deltas, idx / 2); return (idx & 1) ? &delta->new_file : &delta->old_file; } typedef struct { size_t idx; git_iterator_type_t src; git_repository *repo; git_diff_file *file; git_buf data; git_odb_object *odb_obj; git_blob *blob; } similarity_info; static int similarity_init( similarity_info *info, git_diff *diff, size_t file_idx) { info->idx = file_idx; info->src = (file_idx & 1) ? diff->new_src : diff->old_src; info->repo = diff->repo; info->file = similarity_get_file(diff, file_idx); info->odb_obj = NULL; info->blob = NULL; git_buf_init(&info->data, 0); if (info->file->size > 0 || info->src == GIT_ITERATOR_TYPE_WORKDIR) return 0; return git_diff_file__resolve_zero_size( info->file, &info->odb_obj, info->repo); } static int similarity_sig( similarity_info *info, const git_diff_find_options *opts, void **cache) { int error = 0; git_diff_file *file = info->file; if (info->src == GIT_ITERATOR_TYPE_WORKDIR) { if ((error = git_buf_joinpath( &info->data, git_repository_workdir(info->repo), file->path)) < 0) return error; /* if path is not a regular file, just skip this item */ if (!git_path_isfile(info->data.ptr)) return 0; /* TODO: apply wd-to-odb filters to file data if necessary */ error = opts->metric->file_signature( &cache[info->idx], info->file, info->data.ptr, opts->metric->payload); } else { /* if we didn't initially know the size, we might have an odb_obj * around from earlier, so convert that, otherwise load the blob now */ if (info->odb_obj != NULL) error = git_object__from_odb_object( (git_object **)&info->blob, info->repo, info->odb_obj, GIT_OBJ_BLOB); else error = git_blob_lookup(&info->blob, info->repo, &file->id); if (error < 0) { /* if lookup fails, just skip this item in similarity calc */ giterr_clear(); } else { size_t sz; /* index size may not be actual blob size if filtered */ if (file->size != git_blob_rawsize(info->blob)) file->size = git_blob_rawsize(info->blob); sz = (size_t)(git__is_sizet(file->size) ? file->size : -1); error = opts->metric->buffer_signature( &cache[info->idx], info->file, git_blob_rawcontent(info->blob), sz, opts->metric->payload); } } return error; } static void similarity_unload(similarity_info *info) { if (info->odb_obj) git_odb_object_free(info->odb_obj); if (info->blob) git_blob_free(info->blob); else git_buf_free(&info->data); } #define FLAG_SET(opts,flag_name) (((opts)->flags & flag_name) != 0) /* - score < 0 means files cannot be compared * - score >= 100 means files are exact match * - score == 0 means files are completely different */ static int similarity_measure( int *score, git_diff *diff, const git_diff_find_options *opts, void **cache, size_t a_idx, size_t b_idx) { git_diff_file *a_file = similarity_get_file(diff, a_idx); git_diff_file *b_file = similarity_get_file(diff, b_idx); bool exact_match = FLAG_SET(opts, GIT_DIFF_FIND_EXACT_MATCH_ONLY); int error = 0; similarity_info a_info, b_info; *score = -1; /* don't try to compare files of different types */ if (GIT_MODE_TYPE(a_file->mode) != GIT_MODE_TYPE(b_file->mode)) return 0; /* if exact match is requested, force calculation of missing OIDs now */ if (exact_match) { if (git_oid_iszero(&a_file->id) && diff->old_src == GIT_ITERATOR_TYPE_WORKDIR && !git_diff__oid_for_file(&a_file->id, diff, a_file->path, a_file->mode, a_file->size)) a_file->flags |= GIT_DIFF_FLAG_VALID_ID; if (git_oid_iszero(&b_file->id) && diff->new_src == GIT_ITERATOR_TYPE_WORKDIR && !git_diff__oid_for_file(&b_file->id, diff, b_file->path, b_file->mode, b_file->size)) b_file->flags |= GIT_DIFF_FLAG_VALID_ID; } /* check OID match as a quick test */ if (git_oid__cmp(&a_file->id, &b_file->id) == 0) { *score = 100; return 0; } /* don't calculate signatures if we are doing exact match */ if (exact_match) { *score = 0; return 0; } memset(&a_info, 0, sizeof(a_info)); memset(&b_info, 0, sizeof(b_info)); /* set up similarity data (will try to update missing file sizes) */ if (!cache[a_idx] && (error = similarity_init(&a_info, diff, a_idx)) < 0) return error; if (!cache[b_idx] && (error = similarity_init(&b_info, diff, b_idx)) < 0) goto cleanup; /* check if file sizes are nowhere near each other */ if (a_file->size > 127 && b_file->size > 127 && (a_file->size > (b_file->size << 3) || b_file->size > (a_file->size << 3))) goto cleanup; /* update signature cache if needed */ if (!cache[a_idx]) { if ((error = similarity_sig(&a_info, opts, cache)) < 0) goto cleanup; } if (!cache[b_idx]) { if ((error = similarity_sig(&b_info, opts, cache)) < 0) goto cleanup; } /* calculate similarity provided that the metric choose to process * both the a and b files (some may not if file is too big, etc). */ if (cache[a_idx] && cache[b_idx]) error = opts->metric->similarity( score, cache[a_idx], cache[b_idx], opts->metric->payload); cleanup: similarity_unload(&a_info); similarity_unload(&b_info); return error; } static int calc_self_similarity( git_diff *diff, const git_diff_find_options *opts, size_t delta_idx, void **cache) { int error, similarity = -1; git_diff_delta *delta = GIT_VECTOR_GET(&diff->deltas, delta_idx); if ((delta->flags & GIT_DIFF_FLAG__HAS_SELF_SIMILARITY) != 0) return 0; error = similarity_measure( &similarity, diff, opts, cache, 2 * delta_idx, 2 * delta_idx + 1); if (error < 0) return error; if (similarity >= 0) { delta->similarity = (uint16_t)similarity; delta->flags |= GIT_DIFF_FLAG__HAS_SELF_SIMILARITY; } return 0; } static bool is_rename_target( git_diff *diff, const git_diff_find_options *opts, size_t delta_idx, void **cache) { git_diff_delta *delta = GIT_VECTOR_GET(&diff->deltas, delta_idx); /* skip things that aren't plain blobs */ if (!GIT_MODE_ISBLOB(delta->new_file.mode)) return false; /* only consider ADDED, RENAMED, COPIED, and split MODIFIED as * targets; maybe include UNTRACKED if requested. */ switch (delta->status) { case GIT_DELTA_UNMODIFIED: case GIT_DELTA_DELETED: case GIT_DELTA_IGNORED: case GIT_DELTA_CONFLICTED: return false; case GIT_DELTA_MODIFIED: if (!FLAG_SET(opts, GIT_DIFF_FIND_REWRITES) && !FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES)) return false; if (calc_self_similarity(diff, opts, delta_idx, cache) < 0) return false; if (FLAG_SET(opts, GIT_DIFF_BREAK_REWRITES) && delta->similarity < opts->break_rewrite_threshold) { delta->flags |= GIT_DIFF_FLAG__TO_SPLIT; break; } if (FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES) && delta->similarity < opts->rename_from_rewrite_threshold) break; return false; case GIT_DELTA_UNTRACKED: if (!FLAG_SET(opts, GIT_DIFF_FIND_FOR_UNTRACKED)) return false; break; default: /* all other status values should be checked */ break; } delta->flags |= GIT_DIFF_FLAG__IS_RENAME_TARGET; return true; } static bool is_rename_source( git_diff *diff, const git_diff_find_options *opts, size_t delta_idx, void **cache) { git_diff_delta *delta = GIT_VECTOR_GET(&diff->deltas, delta_idx); /* skip things that aren't blobs */ if (!GIT_MODE_ISBLOB(delta->old_file.mode)) return false; switch (delta->status) { case GIT_DELTA_ADDED: case GIT_DELTA_UNTRACKED: case GIT_DELTA_UNREADABLE: case GIT_DELTA_IGNORED: case GIT_DELTA_CONFLICTED: return false; case GIT_DELTA_DELETED: case GIT_DELTA_TYPECHANGE: break; case GIT_DELTA_UNMODIFIED: if (!FLAG_SET(opts, GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED)) return false; if (FLAG_SET(opts, GIT_DIFF_FIND_REMOVE_UNMODIFIED)) delta->flags |= GIT_DIFF_FLAG__TO_DELETE; break; default: /* MODIFIED, RENAMED, COPIED */ /* if we're finding copies, this could be a source */ if (FLAG_SET(opts, GIT_DIFF_FIND_COPIES)) break; /* otherwise, this is only a source if we can split it */ if (!FLAG_SET(opts, GIT_DIFF_FIND_REWRITES) && !FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES)) return false; if (calc_self_similarity(diff, opts, delta_idx, cache) < 0) return false; if (FLAG_SET(opts, GIT_DIFF_BREAK_REWRITES) && delta->similarity < opts->break_rewrite_threshold) { delta->flags |= GIT_DIFF_FLAG__TO_SPLIT; break; } if (FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES) && delta->similarity < opts->rename_from_rewrite_threshold) break; return false; } delta->flags |= GIT_DIFF_FLAG__IS_RENAME_SOURCE; return true; } GIT_INLINE(bool) delta_is_split(git_diff_delta *delta) { return (delta->status == GIT_DELTA_TYPECHANGE || (delta->flags & GIT_DIFF_FLAG__TO_SPLIT) != 0); } GIT_INLINE(bool) delta_is_new_only(git_diff_delta *delta) { return (delta->status == GIT_DELTA_ADDED || delta->status == GIT_DELTA_UNTRACKED || delta->status == GIT_DELTA_UNREADABLE || delta->status == GIT_DELTA_IGNORED); } GIT_INLINE(void) delta_make_rename( git_diff_delta *to, const git_diff_delta *from, uint16_t similarity) { to->status = GIT_DELTA_RENAMED; to->similarity = similarity; to->nfiles = 2; memcpy(&to->old_file, &from->old_file, sizeof(to->old_file)); to->flags &= ~GIT_DIFF_FLAG__TO_SPLIT; } typedef struct { size_t idx; uint16_t similarity; } diff_find_match; int git_diff_find_similar( git_diff *diff, const git_diff_find_options *given_opts) { size_t s, t; int error = 0, result; uint16_t similarity; git_diff_delta *src, *tgt; git_diff_find_options opts = GIT_DIFF_FIND_OPTIONS_INIT; size_t num_deltas, num_srcs = 0, num_tgts = 0; size_t tried_srcs = 0, tried_tgts = 0; size_t num_rewrites = 0, num_updates = 0, num_bumped = 0; size_t sigcache_size; void **sigcache = NULL; /* cache of similarity metric file signatures */ diff_find_match *tgt2src = NULL; diff_find_match *src2tgt = NULL; diff_find_match *tgt2src_copy = NULL; diff_find_match *best_match; git_diff_file swap; if ((error = normalize_find_opts(diff, &opts, given_opts)) < 0) return error; num_deltas = diff->deltas.length; /* TODO: maybe abort if deltas.length > rename_limit ??? */ if (!git__is_uint32(num_deltas)) goto cleanup; /* No flags set; nothing to do */ if ((opts.flags & GIT_DIFF_FIND_ALL) == 0) goto cleanup; GITERR_CHECK_ALLOC_MULTIPLY(&sigcache_size, num_deltas, 2); sigcache = git__calloc(sigcache_size, sizeof(void *)); GITERR_CHECK_ALLOC(sigcache); /* Label rename sources and targets * * This will also set self-similarity scores for MODIFIED files and * mark them for splitting if break-rewrites is enabled */ git_vector_foreach(&diff->deltas, t, tgt) { if (is_rename_source(diff, &opts, t, sigcache)) ++num_srcs; if (is_rename_target(diff, &opts, t, sigcache)) ++num_tgts; if ((tgt->flags & GIT_DIFF_FLAG__TO_SPLIT) != 0) num_rewrites++; } /* if there are no candidate srcs or tgts, we're done */ if (!num_srcs || !num_tgts) goto cleanup; src2tgt = git__calloc(num_deltas, sizeof(diff_find_match)); GITERR_CHECK_ALLOC(src2tgt); tgt2src = git__calloc(num_deltas, sizeof(diff_find_match)); GITERR_CHECK_ALLOC(tgt2src); if (FLAG_SET(&opts, GIT_DIFF_FIND_COPIES)) { tgt2src_copy = git__calloc(num_deltas, sizeof(diff_find_match)); GITERR_CHECK_ALLOC(tgt2src_copy); } /* * Find best-fit matches for rename / copy candidates */ find_best_matches: tried_tgts = num_bumped = 0; git_vector_foreach(&diff->deltas, t, tgt) { /* skip things that are not rename targets */ if ((tgt->flags & GIT_DIFF_FLAG__IS_RENAME_TARGET) == 0) continue; tried_srcs = 0; git_vector_foreach(&diff->deltas, s, src) { /* skip things that are not rename sources */ if ((src->flags & GIT_DIFF_FLAG__IS_RENAME_SOURCE) == 0) continue; /* calculate similarity for this pair and find best match */ if (s == t) result = -1; /* don't measure self-similarity here */ else if ((error = similarity_measure( &result, diff, &opts, sigcache, 2 * s, 2 * t + 1)) < 0) goto cleanup; if (result < 0) continue; similarity = (uint16_t)result; /* is this a better rename? */ if (tgt2src[t].similarity < similarity && src2tgt[s].similarity < similarity) { /* eject old mapping */ if (src2tgt[s].similarity > 0) { tgt2src[src2tgt[s].idx].similarity = 0; num_bumped++; } if (tgt2src[t].similarity > 0) { src2tgt[tgt2src[t].idx].similarity = 0; num_bumped++; } /* write new mapping */ tgt2src[t].idx = s; tgt2src[t].similarity = similarity; src2tgt[s].idx = t; src2tgt[s].similarity = similarity; } /* keep best absolute match for copies */ if (tgt2src_copy != NULL && tgt2src_copy[t].similarity < similarity) { tgt2src_copy[t].idx = s; tgt2src_copy[t].similarity = similarity; } if (++tried_srcs >= num_srcs) break; /* cap on maximum targets we'll examine (per "tgt" file) */ if (tried_srcs > opts.rename_limit) break; } if (++tried_tgts >= num_tgts) break; } if (num_bumped > 0) /* try again if we bumped some items */ goto find_best_matches; /* * Rewrite the diffs with renames / copies */ git_vector_foreach(&diff->deltas, t, tgt) { /* skip things that are not rename targets */ if ((tgt->flags & GIT_DIFF_FLAG__IS_RENAME_TARGET) == 0) continue; /* check if this delta was the target of a similarity */ if (tgt2src[t].similarity) best_match = &tgt2src[t]; else if (tgt2src_copy && tgt2src_copy[t].similarity) best_match = &tgt2src_copy[t]; else continue; s = best_match->idx; src = GIT_VECTOR_GET(&diff->deltas, s); /* possible scenarios: * 1. from DELETE to ADD/UNTRACK/IGNORE = RENAME * 2. from DELETE to SPLIT/TYPECHANGE = RENAME + DELETE * 3. from SPLIT/TYPECHANGE to ADD/UNTRACK/IGNORE = ADD + RENAME * 4. from SPLIT/TYPECHANGE to SPLIT/TYPECHANGE = RENAME + SPLIT * 5. from OTHER to ADD/UNTRACK/IGNORE = OTHER + COPY */ if (src->status == GIT_DELTA_DELETED) { if (delta_is_new_only(tgt)) { if (best_match->similarity < opts.rename_threshold) continue; delta_make_rename(tgt, src, best_match->similarity); src->flags |= GIT_DIFF_FLAG__TO_DELETE; num_rewrites++; } else { assert(delta_is_split(tgt)); if (best_match->similarity < opts.rename_from_rewrite_threshold) continue; memcpy(&swap, &tgt->old_file, sizeof(swap)); delta_make_rename(tgt, src, best_match->similarity); num_rewrites--; assert(src->status == GIT_DELTA_DELETED); memcpy(&src->old_file, &swap, sizeof(src->old_file)); memset(&src->new_file, 0, sizeof(src->new_file)); src->new_file.path = src->old_file.path; src->new_file.flags |= GIT_DIFF_FLAG_VALID_ID; num_updates++; if (src2tgt[t].similarity > 0 && src2tgt[t].idx > t) { /* what used to be at src t is now at src s */ tgt2src[src2tgt[t].idx].idx = s; } } } else if (delta_is_split(src)) { if (delta_is_new_only(tgt)) { if (best_match->similarity < opts.rename_threshold) continue; delta_make_rename(tgt, src, best_match->similarity); src->status = (diff->new_src == GIT_ITERATOR_TYPE_WORKDIR) ? GIT_DELTA_UNTRACKED : GIT_DELTA_ADDED; src->nfiles = 1; memset(&src->old_file, 0, sizeof(src->old_file)); src->old_file.path = src->new_file.path; src->old_file.flags |= GIT_DIFF_FLAG_VALID_ID; src->flags &= ~GIT_DIFF_FLAG__TO_SPLIT; num_rewrites--; num_updates++; } else { assert(delta_is_split(src)); if (best_match->similarity < opts.rename_from_rewrite_threshold) continue; memcpy(&swap, &tgt->old_file, sizeof(swap)); delta_make_rename(tgt, src, best_match->similarity); num_rewrites--; num_updates++; memcpy(&src->old_file, &swap, sizeof(src->old_file)); /* if we've just swapped the new element into the correct * place, clear the SPLIT flag */ if (tgt2src[s].idx == t && tgt2src[s].similarity > opts.rename_from_rewrite_threshold) { src->status = GIT_DELTA_RENAMED; src->similarity = tgt2src[s].similarity; tgt2src[s].similarity = 0; src->flags &= ~GIT_DIFF_FLAG__TO_SPLIT; num_rewrites--; } /* otherwise, if we just overwrote a source, update mapping */ else if (src2tgt[t].similarity > 0 && src2tgt[t].idx > t) { /* what used to be at src t is now at src s */ tgt2src[src2tgt[t].idx].idx = s; } num_updates++; } } else if (FLAG_SET(&opts, GIT_DIFF_FIND_COPIES)) { if (tgt2src_copy[t].similarity < opts.copy_threshold) continue; /* always use best possible source for copy */ best_match = &tgt2src_copy[t]; src = GIT_VECTOR_GET(&diff->deltas, best_match->idx); if (delta_is_split(tgt)) { error = insert_delete_side_of_split(diff, &diff->deltas, tgt); if (error < 0) goto cleanup; num_rewrites--; } if (!delta_is_split(tgt) && !delta_is_new_only(tgt)) continue; tgt->status = GIT_DELTA_COPIED; tgt->similarity = best_match->similarity; tgt->nfiles = 2; memcpy(&tgt->old_file, &src->old_file, sizeof(tgt->old_file)); tgt->flags &= ~GIT_DIFF_FLAG__TO_SPLIT; num_updates++; } } /* * Actually split and delete entries as needed */ if (num_rewrites > 0 || num_updates > 0) error = apply_splits_and_deletes( diff, diff->deltas.length - num_rewrites, FLAG_SET(&opts, GIT_DIFF_BREAK_REWRITES) && !FLAG_SET(&opts, GIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY)); cleanup: git__free(tgt2src); git__free(src2tgt); git__free(tgt2src_copy); if (sigcache) { for (t = 0; t < num_deltas * 2; ++t) { if (sigcache[t] != NULL) opts.metric->free_signature(sigcache[t], opts.metric->payload); } git__free(sigcache); } if (!given_opts || !given_opts->metric) git__free(opts.metric); return error; } #undef FLAG_SET deps/libgit2-sys-0.3.8/libgit2/src/blob.c0000664000175000017500000002065212572105236014764 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/common.h" #include "git2/object.h" #include "git2/repository.h" #include "git2/odb_backend.h" #include "common.h" #include "filebuf.h" #include "blob.h" #include "filter.h" #include "buf_text.h" const void *git_blob_rawcontent(const git_blob *blob) { assert(blob); return git_odb_object_data(blob->odb_object); } git_off_t git_blob_rawsize(const git_blob *blob) { assert(blob); return (git_off_t)git_odb_object_size(blob->odb_object); } int git_blob__getbuf(git_buf *buffer, git_blob *blob) { return git_buf_set( buffer, git_odb_object_data(blob->odb_object), git_odb_object_size(blob->odb_object)); } void git_blob__free(void *blob) { git_odb_object_free(((git_blob *)blob)->odb_object); git__free(blob); } int git_blob__parse(void *blob, git_odb_object *odb_obj) { assert(blob); git_cached_obj_incref((git_cached_obj *)odb_obj); ((git_blob *)blob)->odb_object = odb_obj; return 0; } int git_blob_create_frombuffer( git_oid *id, git_repository *repo, const void *buffer, size_t len) { int error; git_odb *odb; git_odb_stream *stream; assert(id && repo); if ((error = git_repository_odb__weakptr(&odb, repo)) < 0 || (error = git_odb_open_wstream(&stream, odb, len, GIT_OBJ_BLOB)) < 0) return error; if ((error = git_odb_stream_write(stream, buffer, len)) == 0) error = git_odb_stream_finalize_write(id, stream); git_odb_stream_free(stream); return error; } static int write_file_stream( git_oid *id, git_odb *odb, const char *path, git_off_t file_size) { int fd, error; char buffer[FILEIO_BUFSIZE]; git_odb_stream *stream = NULL; ssize_t read_len = -1; git_off_t written = 0; if ((error = git_odb_open_wstream( &stream, odb, file_size, GIT_OBJ_BLOB)) < 0) return error; if ((fd = git_futils_open_ro(path)) < 0) { git_odb_stream_free(stream); return -1; } while (!error && (read_len = p_read(fd, buffer, sizeof(buffer))) > 0) { error = git_odb_stream_write(stream, buffer, read_len); written += read_len; } p_close(fd); if (written != file_size || read_len < 0) { giterr_set(GITERR_OS, "Failed to read file into stream"); error = -1; } if (!error) error = git_odb_stream_finalize_write(id, stream); git_odb_stream_free(stream); return error; } static int write_file_filtered( git_oid *id, git_off_t *size, git_odb *odb, const char *full_path, git_filter_list *fl) { int error; git_buf tgt = GIT_BUF_INIT; error = git_filter_list_apply_to_file(&tgt, fl, NULL, full_path); /* Write the file to disk if it was properly filtered */ if (!error) { *size = tgt.size; error = git_odb_write(id, odb, tgt.ptr, tgt.size, GIT_OBJ_BLOB); } git_buf_free(&tgt); return error; } static int write_symlink( git_oid *id, git_odb *odb, const char *path, size_t link_size) { char *link_data; ssize_t read_len; int error; link_data = git__malloc(link_size); GITERR_CHECK_ALLOC(link_data); read_len = p_readlink(path, link_data, link_size); if (read_len != (ssize_t)link_size) { giterr_set(GITERR_OS, "Failed to create blob. Can't read symlink '%s'", path); git__free(link_data); return -1; } error = git_odb_write(id, odb, (void *)link_data, link_size, GIT_OBJ_BLOB); git__free(link_data); return error; } int git_blob__create_from_paths( git_oid *id, struct stat *out_st, git_repository *repo, const char *content_path, const char *hint_path, mode_t hint_mode, bool try_load_filters) { int error; struct stat st; git_odb *odb = NULL; git_off_t size; mode_t mode; git_buf path = GIT_BUF_INIT; assert(hint_path || !try_load_filters); if (!content_path) { if (git_repository__ensure_not_bare(repo, "create blob from file") < 0) return GIT_EBAREREPO; if (git_buf_joinpath( &path, git_repository_workdir(repo), hint_path) < 0) return -1; content_path = path.ptr; } if ((error = git_path_lstat(content_path, &st)) < 0 || (error = git_repository_odb(&odb, repo)) < 0) goto done; if (S_ISDIR(st.st_mode)) { giterr_set(GITERR_ODB, "cannot create blob from '%s'; it is a directory", content_path); error = GIT_EDIRECTORY; goto done; } if (out_st) memcpy(out_st, &st, sizeof(st)); size = st.st_size; mode = hint_mode ? hint_mode : st.st_mode; if (S_ISLNK(mode)) { error = write_symlink(id, odb, content_path, (size_t)size); } else { git_filter_list *fl = NULL; if (try_load_filters) /* Load the filters for writing this file to the ODB */ error = git_filter_list_load( &fl, repo, NULL, hint_path, GIT_FILTER_TO_ODB, GIT_FILTER_DEFAULT); if (error < 0) /* well, that didn't work */; else if (fl == NULL) /* No filters need to be applied to the document: we can stream * directly from disk */ error = write_file_stream(id, odb, content_path, size); else { /* We need to apply one or more filters */ error = write_file_filtered(id, &size, odb, content_path, fl); git_filter_list_free(fl); } /* * TODO: eventually support streaming filtered files, for files * which are bigger than a given threshold. This is not a priority * because applying a filter in streaming mode changes the final * size of the blob, and without knowing its final size, the blob * cannot be written in stream mode to the ODB. * * The plan is to do streaming writes to a tempfile on disk and then * opening streaming that file to the ODB, using * `write_file_stream`. * * CAREFULLY DESIGNED APIS YO */ } done: git_odb_free(odb); git_buf_free(&path); return error; } int git_blob_create_fromworkdir( git_oid *id, git_repository *repo, const char *path) { return git_blob__create_from_paths(id, NULL, repo, NULL, path, 0, true); } int git_blob_create_fromdisk( git_oid *id, git_repository *repo, const char *path) { int error; git_buf full_path = GIT_BUF_INIT; const char *workdir, *hintpath; if ((error = git_path_prettify(&full_path, path, NULL)) < 0) { git_buf_free(&full_path); return error; } hintpath = git_buf_cstr(&full_path); workdir = git_repository_workdir(repo); if (workdir && !git__prefixcmp(hintpath, workdir)) hintpath += strlen(workdir); error = git_blob__create_from_paths( id, NULL, repo, git_buf_cstr(&full_path), hintpath, 0, true); git_buf_free(&full_path); return error; } #define BUFFER_SIZE 4096 int git_blob_create_fromchunks( git_oid *id, git_repository *repo, const char *hintpath, int (*source_cb)(char *content, size_t max_length, void *payload), void *payload) { int error; char *content = NULL; git_filebuf file = GIT_FILEBUF_INIT; git_buf path = GIT_BUF_INIT; assert(id && repo && source_cb); if ((error = git_buf_joinpath( &path, git_repository_path(repo), GIT_OBJECTS_DIR "streamed")) < 0) goto cleanup; content = git__malloc(BUFFER_SIZE); GITERR_CHECK_ALLOC(content); if ((error = git_filebuf_open( &file, git_buf_cstr(&path), GIT_FILEBUF_TEMPORARY, 0666)) < 0) goto cleanup; while (1) { int read_bytes = source_cb(content, BUFFER_SIZE, payload); if (!read_bytes) break; if (read_bytes > BUFFER_SIZE) { giterr_set(GITERR_OBJECT, "Invalid chunk size while creating blob"); error = GIT_EBUFS; } else if (read_bytes < 0) { error = giterr_set_after_callback(read_bytes); } else { error = git_filebuf_write(&file, content, read_bytes); } if (error < 0) goto cleanup; } if ((error = git_filebuf_flush(&file)) < 0) goto cleanup; error = git_blob__create_from_paths( id, NULL, repo, file.path_lock, hintpath, 0, hintpath != NULL); cleanup: git_buf_free(&path); git_filebuf_cleanup(&file); git__free(content); return error; } int git_blob_is_binary(const git_blob *blob) { git_buf content = GIT_BUF_INIT; assert(blob); git_buf_attach_notowned(&content, blob->odb_object->buffer, min(blob->odb_object->cached.size, GIT_FILTER_BYTES_TO_CHECK_NUL)); return git_buf_text_is_binary(&content); } int git_blob_filtered_content( git_buf *out, git_blob *blob, const char *path, int check_for_binary_data) { int error = 0; git_filter_list *fl = NULL; assert(blob && path && out); git_buf_sanitize(out); if (check_for_binary_data && git_blob_is_binary(blob)) return 0; if (!(error = git_filter_list_load( &fl, git_blob_owner(blob), blob, path, GIT_FILTER_TO_WORKTREE, GIT_FILTER_DEFAULT))) { error = git_filter_list_apply_to_blob(out, fl, blob); git_filter_list_free(fl); } return error; } deps/libgit2-sys-0.3.8/libgit2/src/khash.h0000664000175000017500000005170712572105236015156 0ustar /* The MIT License Copyright (c) 2008, 2009, 2011 by Attractive Chaos Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* An example: #include "khash.h" KHASH_MAP_INIT_INT(32, char) int main() { int ret, is_missing; khiter_t k; khash_t(32) *h = kh_init(32); k = kh_put(32, h, 5, &ret); kh_value(h, k) = 10; k = kh_get(32, h, 10); is_missing = (k == kh_end(h)); k = kh_get(32, h, 5); kh_del(32, h, k); for (k = kh_begin(h); k != kh_end(h); ++k) if (kh_exist(h, k)) kh_value(h, k) = 1; kh_destroy(32, h); return 0; } */ /* 2013-05-02 (0.2.8): * Use quadratic probing. When the capacity is power of 2, stepping function i*(i+1)/2 guarantees to traverse each bucket. It is better than double hashing on cache performance and is more robust than linear probing. In theory, double hashing should be more robust than quadratic probing. However, my implementation is probably not for large hash tables, because the second hash function is closely tied to the first hash function, which reduce the effectiveness of double hashing. Reference: http://research.cs.vt.edu/AVresearch/hashing/quadratic.php 2011-12-29 (0.2.7): * Minor code clean up; no actual effect. 2011-09-16 (0.2.6): * The capacity is a power of 2. This seems to dramatically improve the speed for simple keys. Thank Zilong Tan for the suggestion. Reference: - http://code.google.com/p/ulib/ - http://nothings.org/computer/judy/ * Allow to optionally use linear probing which usually has better performance for random input. Double hashing is still the default as it is more robust to certain non-random input. * Added Wang's integer hash function (not used by default). This hash function is more robust to certain non-random input. 2011-02-14 (0.2.5): * Allow to declare global functions. 2009-09-26 (0.2.4): * Improve portability 2008-09-19 (0.2.3): * Corrected the example * Improved interfaces 2008-09-11 (0.2.2): * Improved speed a little in kh_put() 2008-09-10 (0.2.1): * Added kh_clear() * Fixed a compiling error 2008-09-02 (0.2.0): * Changed to token concatenation which increases flexibility. 2008-08-31 (0.1.2): * Fixed a bug in kh_get(), which has not been tested previously. 2008-08-31 (0.1.1): * Added destructor */ #ifndef __AC_KHASH_H #define __AC_KHASH_H /*! @header Generic hash table library. */ #define AC_VERSION_KHASH_H "0.2.8" #include #include #include /* compiler specific configuration */ #if UINT_MAX == 0xffffffffu typedef unsigned int khint32_t; #elif ULONG_MAX == 0xffffffffu typedef unsigned long khint32_t; #endif #if ULONG_MAX == ULLONG_MAX typedef unsigned long khint64_t; #else typedef unsigned long long khint64_t; #endif #ifndef kh_inline #ifdef _MSC_VER #define kh_inline __inline #else #define kh_inline inline #endif #endif /* kh_inline */ typedef khint32_t khint_t; typedef khint_t khiter_t; #define __ac_isempty(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&2) #define __ac_isdel(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&1) #define __ac_iseither(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&3) #define __ac_set_isdel_false(flag, i) (flag[i>>4]&=~(1ul<<((i&0xfU)<<1))) #define __ac_set_isempty_false(flag, i) (flag[i>>4]&=~(2ul<<((i&0xfU)<<1))) #define __ac_set_isboth_false(flag, i) (flag[i>>4]&=~(3ul<<((i&0xfU)<<1))) #define __ac_set_isdel_true(flag, i) (flag[i>>4]|=1ul<<((i&0xfU)<<1)) #define __ac_fsize(m) ((m) < 16? 1 : (m)>>4) #ifndef kroundup32 #define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x)) #endif #ifndef kcalloc #define kcalloc(N,Z) calloc(N,Z) #endif #ifndef kmalloc #define kmalloc(Z) malloc(Z) #endif #ifndef krealloc #define krealloc(P,Z) realloc(P,Z) #endif #ifndef kreallocarray #define kreallocarray(P,N,Z) ((SIZE_MAX - N < Z) ? NULL : krealloc(P, (N*Z))) #endif #ifndef kfree #define kfree(P) free(P) #endif static const double __ac_HASH_UPPER = 0.77; #define __KHASH_TYPE(name, khkey_t, khval_t) \ typedef struct kh_##name##_s { \ khint_t n_buckets, size, n_occupied, upper_bound; \ khint32_t *flags; \ khkey_t *keys; \ khval_t *vals; \ } kh_##name##_t; #define __KHASH_PROTOTYPES(name, khkey_t, khval_t) \ extern kh_##name##_t *kh_init_##name(void); \ extern void kh_destroy_##name(kh_##name##_t *h); \ extern void kh_clear_##name(kh_##name##_t *h); \ extern khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key); \ extern int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets); \ extern khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret); \ extern void kh_del_##name(kh_##name##_t *h, khint_t x); #define __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \ SCOPE kh_##name##_t *kh_init_##name(void) { \ return (kh_##name##_t*)kcalloc(1, sizeof(kh_##name##_t)); \ } \ SCOPE void kh_destroy_##name(kh_##name##_t *h) \ { \ if (h) { \ kfree((void *)h->keys); kfree(h->flags); \ kfree((void *)h->vals); \ kfree(h); \ } \ } \ SCOPE void kh_clear_##name(kh_##name##_t *h) \ { \ if (h && h->flags) { \ memset(h->flags, 0xaa, __ac_fsize(h->n_buckets) * sizeof(khint32_t)); \ h->size = h->n_occupied = 0; \ } \ } \ SCOPE khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key) \ { \ if (h->n_buckets) { \ khint_t k, i, last, mask, step = 0; \ mask = h->n_buckets - 1; \ k = __hash_func(key); i = k & mask; \ last = i; \ while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \ i = (i + (++step)) & mask; \ if (i == last) return h->n_buckets; \ } \ return __ac_iseither(h->flags, i)? h->n_buckets : i; \ } else return 0; \ } \ SCOPE int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \ { /* This function uses 0.25*n_buckets bytes of working space instead of [sizeof(key_t+val_t)+.25]*n_buckets. */ \ khint32_t *new_flags = 0; \ khint_t j = 1; \ { \ kroundup32(new_n_buckets); \ if (new_n_buckets < 4) new_n_buckets = 4; \ if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) j = 0; /* requested size is too small */ \ else { /* hash table size to be changed (shrink or expand); rehash */ \ new_flags = (khint32_t*)kreallocarray(NULL, __ac_fsize(new_n_buckets), sizeof(khint32_t)); \ if (!new_flags) return -1; \ memset(new_flags, 0xaa, __ac_fsize(new_n_buckets) * sizeof(khint32_t)); \ if (h->n_buckets < new_n_buckets) { /* expand */ \ khkey_t *new_keys = (khkey_t*)kreallocarray((void *)h->keys, new_n_buckets, sizeof(khkey_t)); \ if (!new_keys) { kfree(new_flags); return -1; } \ h->keys = new_keys; \ if (kh_is_map) { \ khval_t *new_vals = (khval_t*)kreallocarray((void *)h->vals, new_n_buckets, sizeof(khval_t)); \ if (!new_vals) { kfree(new_flags); return -1; } \ h->vals = new_vals; \ } \ } /* otherwise shrink */ \ } \ } \ if (j) { /* rehashing is needed */ \ for (j = 0; j != h->n_buckets; ++j) { \ if (__ac_iseither(h->flags, j) == 0) { \ khkey_t key = h->keys[j]; \ khval_t val; \ khint_t new_mask; \ new_mask = new_n_buckets - 1; \ if (kh_is_map) val = h->vals[j]; \ __ac_set_isdel_true(h->flags, j); \ while (1) { /* kick-out process; sort of like in Cuckoo hashing */ \ khint_t k, i, step = 0; \ k = __hash_func(key); \ i = k & new_mask; \ while (!__ac_isempty(new_flags, i)) i = (i + (++step)) & new_mask; \ __ac_set_isempty_false(new_flags, i); \ if (i < h->n_buckets && __ac_iseither(h->flags, i) == 0) { /* kick out the existing element */ \ { khkey_t tmp = h->keys[i]; h->keys[i] = key; key = tmp; } \ if (kh_is_map) { khval_t tmp = h->vals[i]; h->vals[i] = val; val = tmp; } \ __ac_set_isdel_true(h->flags, i); /* mark it as deleted in the old hash table */ \ } else { /* write the element and jump out of the loop */ \ h->keys[i] = key; \ if (kh_is_map) h->vals[i] = val; \ break; \ } \ } \ } \ } \ if (h->n_buckets > new_n_buckets) { /* shrink the hash table */ \ h->keys = (khkey_t*)kreallocarray((void *)h->keys, new_n_buckets, sizeof(khkey_t)); \ if (kh_is_map) h->vals = (khval_t*)kreallocarray((void *)h->vals, new_n_buckets, sizeof(khval_t)); \ } \ kfree(h->flags); /* free the working space */ \ h->flags = new_flags; \ h->n_buckets = new_n_buckets; \ h->n_occupied = h->size; \ h->upper_bound = (khint_t)(h->n_buckets * __ac_HASH_UPPER + 0.5); \ } \ return 0; \ } \ SCOPE khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret) \ { \ khint_t x; \ if (h->n_occupied >= h->upper_bound) { /* update the hash table */ \ if (h->n_buckets > (h->size<<1)) { \ if (kh_resize_##name(h, h->n_buckets - 1) < 0) { /* clear "deleted" elements */ \ *ret = -1; return h->n_buckets; \ } \ } else if (kh_resize_##name(h, h->n_buckets + 1) < 0) { /* expand the hash table */ \ *ret = -1; return h->n_buckets; \ } \ } /* TODO: to implement automatically shrinking; resize() already support shrinking */ \ { \ khint_t k, i, site, last, mask = h->n_buckets - 1, step = 0; \ x = site = h->n_buckets; k = __hash_func(key); i = k & mask; \ if (__ac_isempty(h->flags, i)) x = i; /* for speed up */ \ else { \ last = i; \ while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \ if (__ac_isdel(h->flags, i)) site = i; \ i = (i + (++step)) & mask; \ if (i == last) { x = site; break; } \ } \ if (x == h->n_buckets) { \ if (__ac_isempty(h->flags, i) && site != h->n_buckets) x = site; \ else x = i; \ } \ } \ } \ if (__ac_isempty(h->flags, x)) { /* not present at all */ \ h->keys[x] = key; \ __ac_set_isboth_false(h->flags, x); \ ++h->size; ++h->n_occupied; \ *ret = 1; \ } else if (__ac_isdel(h->flags, x)) { /* deleted */ \ h->keys[x] = key; \ __ac_set_isboth_false(h->flags, x); \ ++h->size; \ *ret = 2; \ } else *ret = 0; /* Don't touch h->keys[x] if present and not deleted */ \ return x; \ } \ SCOPE void kh_del_##name(kh_##name##_t *h, khint_t x) \ { \ if (x != h->n_buckets && !__ac_iseither(h->flags, x)) { \ __ac_set_isdel_true(h->flags, x); \ --h->size; \ } \ } #define KHASH_DECLARE(name, khkey_t, khval_t) \ __KHASH_TYPE(name, khkey_t, khval_t) \ __KHASH_PROTOTYPES(name, khkey_t, khval_t) #define KHASH_INIT2(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \ __KHASH_TYPE(name, khkey_t, khval_t) \ __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) #define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \ KHASH_INIT2(name, static kh_inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) /* --- BEGIN OF HASH FUNCTIONS --- */ /*! @function @abstract Integer hash function @param key The integer [khint32_t] @return The hash value [khint_t] */ #define kh_int_hash_func(key) (khint32_t)(key) /*! @function @abstract Integer comparison function */ #define kh_int_hash_equal(a, b) ((a) == (b)) /*! @function @abstract 64-bit integer hash function @param key The integer [khint64_t] @return The hash value [khint_t] */ #define kh_int64_hash_func(key) (khint32_t)((key)>>33^(key)^(key)<<11) /*! @function @abstract 64-bit integer comparison function */ #define kh_int64_hash_equal(a, b) ((a) == (b)) /*! @function @abstract const char* hash function @param s Pointer to a null terminated string @return The hash value */ static kh_inline khint_t __ac_X31_hash_string(const char *s) { khint_t h = (khint_t)*s; if (h) for (++s ; *s; ++s) h = (h << 5) - h + (khint_t)*s; return h; } /*! @function @abstract Another interface to const char* hash function @param key Pointer to a null terminated string [const char*] @return The hash value [khint_t] */ #define kh_str_hash_func(key) __ac_X31_hash_string(key) /*! @function @abstract Const char* comparison function */ #define kh_str_hash_equal(a, b) (strcmp(a, b) == 0) static kh_inline khint_t __ac_Wang_hash(khint_t key) { key += ~(key << 15); key ^= (key >> 10); key += (key << 3); key ^= (key >> 6); key += ~(key << 11); key ^= (key >> 16); return key; } #define kh_int_hash_func2(k) __ac_Wang_hash((khint_t)key) /* --- END OF HASH FUNCTIONS --- */ /* Other convenient macros... */ /*! @abstract Type of the hash table. @param name Name of the hash table [symbol] */ #define khash_t(name) kh_##name##_t /*! @function @abstract Initiate a hash table. @param name Name of the hash table [symbol] @return Pointer to the hash table [khash_t(name)*] */ #define kh_init(name) kh_init_##name() /*! @function @abstract Destroy a hash table. @param name Name of the hash table [symbol] @param h Pointer to the hash table [khash_t(name)*] */ #define kh_destroy(name, h) kh_destroy_##name(h) /*! @function @abstract Reset a hash table without deallocating memory. @param name Name of the hash table [symbol] @param h Pointer to the hash table [khash_t(name)*] */ #define kh_clear(name, h) kh_clear_##name(h) /*! @function @abstract Resize a hash table. @param name Name of the hash table [symbol] @param h Pointer to the hash table [khash_t(name)*] @param s New size [khint_t] */ #define kh_resize(name, h, s) kh_resize_##name(h, s) /*! @function @abstract Insert a key to the hash table. @param name Name of the hash table [symbol] @param h Pointer to the hash table [khash_t(name)*] @param k Key [type of keys] @param r Extra return code: -1 if the operation failed; 0 if the key is present in the hash table; 1 if the bucket is empty (never used); 2 if the element in the bucket has been deleted [int*] @return Iterator to the inserted element [khint_t] */ #define kh_put(name, h, k, r) kh_put_##name(h, k, r) /*! @function @abstract Retrieve a key from the hash table. @param name Name of the hash table [symbol] @param h Pointer to the hash table [khash_t(name)*] @param k Key [type of keys] @return Iterator to the found element, or kh_end(h) if the element is absent [khint_t] */ #define kh_get(name, h, k) kh_get_##name(h, k) /*! @function @abstract Remove a key from the hash table. @param name Name of the hash table [symbol] @param h Pointer to the hash table [khash_t(name)*] @param k Iterator to the element to be deleted [khint_t] */ #define kh_del(name, h, k) kh_del_##name(h, k) /*! @function @abstract Test whether a bucket contains data. @param h Pointer to the hash table [khash_t(name)*] @param x Iterator to the bucket [khint_t] @return 1 if containing data; 0 otherwise [int] */ #define kh_exist(h, x) (!__ac_iseither((h)->flags, (x))) /*! @function @abstract Get key given an iterator @param h Pointer to the hash table [khash_t(name)*] @param x Iterator to the bucket [khint_t] @return Key [type of keys] */ #define kh_key(h, x) ((h)->keys[x]) /*! @function @abstract Get value given an iterator @param h Pointer to the hash table [khash_t(name)*] @param x Iterator to the bucket [khint_t] @return Value [type of values] @discussion For hash sets, calling this results in segfault. */ #define kh_val(h, x) ((h)->vals[x]) /*! @function @abstract Alias of kh_val() */ #define kh_value(h, x) ((h)->vals[x]) /*! @function @abstract Get the start iterator @param h Pointer to the hash table [khash_t(name)*] @return The start iterator [khint_t] */ #define kh_begin(h) (khint_t)(0) /*! @function @abstract Get the end iterator @param h Pointer to the hash table [khash_t(name)*] @return The end iterator [khint_t] */ #define kh_end(h) ((h)->n_buckets) /*! @function @abstract Get the number of elements in the hash table @param h Pointer to the hash table [khash_t(name)*] @return Number of elements in the hash table [khint_t] */ #define kh_size(h) ((h)->size) /*! @function @abstract Get the number of buckets in the hash table @param h Pointer to the hash table [khash_t(name)*] @return Number of buckets in the hash table [khint_t] */ #define kh_n_buckets(h) ((h)->n_buckets) /*! @function @abstract Iterate over the entries in the hash table @param h Pointer to the hash table [khash_t(name)*] @param kvar Variable to which key will be assigned @param vvar Variable to which value will be assigned @param code Block of code to execute */ #define kh_foreach(h, kvar, vvar, code) { khint_t __i; \ for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \ if (!kh_exist(h,__i)) continue; \ (kvar) = kh_key(h,__i); \ (vvar) = kh_val(h,__i); \ code; \ } } /*! @function @abstract Iterate over the values in the hash table @param h Pointer to the hash table [khash_t(name)*] @param vvar Variable to which value will be assigned @param code Block of code to execute */ #define kh_foreach_value(h, vvar, code) { khint_t __i; \ for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \ if (!kh_exist(h,__i)) continue; \ (vvar) = kh_val(h,__i); \ code; \ } } /* More conenient interfaces */ /*! @function @abstract Instantiate a hash set containing integer keys @param name Name of the hash table [symbol] */ #define KHASH_SET_INIT_INT(name) \ KHASH_INIT(name, khint32_t, char, 0, kh_int_hash_func, kh_int_hash_equal) /*! @function @abstract Instantiate a hash map containing integer keys @param name Name of the hash table [symbol] @param khval_t Type of values [type] */ #define KHASH_MAP_INIT_INT(name, khval_t) \ KHASH_INIT(name, khint32_t, khval_t, 1, kh_int_hash_func, kh_int_hash_equal) /*! @function @abstract Instantiate a hash map containing 64-bit integer keys @param name Name of the hash table [symbol] */ #define KHASH_SET_INIT_INT64(name) \ KHASH_INIT(name, khint64_t, char, 0, kh_int64_hash_func, kh_int64_hash_equal) /*! @function @abstract Instantiate a hash map containing 64-bit integer keys @param name Name of the hash table [symbol] @param khval_t Type of values [type] */ #define KHASH_MAP_INIT_INT64(name, khval_t) \ KHASH_INIT(name, khint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal) typedef const char *kh_cstr_t; /*! @function @abstract Instantiate a hash map containing const char* keys @param name Name of the hash table [symbol] */ #define KHASH_SET_INIT_STR(name) \ KHASH_INIT(name, kh_cstr_t, char, 0, kh_str_hash_func, kh_str_hash_equal) /*! @function @abstract Instantiate a hash map containing const char* keys @param name Name of the hash table [symbol] @param khval_t Type of values [type] */ #define KHASH_MAP_INIT_STR(name, khval_t) \ KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_str_hash_func, kh_str_hash_equal) #endif /* __AC_KHASH_H */ deps/libgit2-sys-0.3.8/libgit2/src/ident.c0000664000175000017500000000604212555730137015153 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/sys/filter.h" #include "filter.h" #include "buffer.h" #include "buf_text.h" static int ident_find_id( const char **id_start, const char **id_end, const char *start, size_t len) { const char *end = start + len, *found = NULL; while (len > 3 && (found = memchr(start, '$', len)) != NULL) { size_t remaining = (size_t)(end - found) - 1; if (remaining < 3) return GIT_ENOTFOUND; start = found + 1; len = remaining; if (start[0] == 'I' && start[1] == 'd') break; } if (len < 3 || !found) return GIT_ENOTFOUND; *id_start = found; if ((found = memchr(start + 2, '$', len - 2)) == NULL) return GIT_ENOTFOUND; *id_end = found + 1; return 0; } static int ident_insert_id( git_buf *to, const git_buf *from, const git_filter_source *src) { char oid[GIT_OID_HEXSZ+1]; const char *id_start, *id_end, *from_end = from->ptr + from->size; size_t need_size; /* replace $Id$ with blob id */ if (!git_filter_source_id(src)) return GIT_PASSTHROUGH; git_oid_tostr(oid, sizeof(oid), git_filter_source_id(src)); if (ident_find_id(&id_start, &id_end, from->ptr, from->size) < 0) return GIT_PASSTHROUGH; need_size = (size_t)(id_start - from->ptr) + 5 /* "$Id: " */ + GIT_OID_HEXSZ + 2 /* " $" */ + (size_t)(from_end - id_end); if (git_buf_grow(to, need_size) < 0) return -1; git_buf_set(to, from->ptr, (size_t)(id_start - from->ptr)); git_buf_put(to, "$Id: ", 5); git_buf_put(to, oid, GIT_OID_HEXSZ); git_buf_put(to, " $", 2); git_buf_put(to, id_end, (size_t)(from_end - id_end)); return git_buf_oom(to) ? -1 : 0; } static int ident_remove_id( git_buf *to, const git_buf *from) { const char *id_start, *id_end, *from_end = from->ptr + from->size; size_t need_size; if (ident_find_id(&id_start, &id_end, from->ptr, from->size) < 0) return GIT_PASSTHROUGH; need_size = (size_t)(id_start - from->ptr) + 4 /* "$Id$" */ + (size_t)(from_end - id_end); if (git_buf_grow(to, need_size) < 0) return -1; git_buf_set(to, from->ptr, (size_t)(id_start - from->ptr)); git_buf_put(to, "$Id$", 4); git_buf_put(to, id_end, (size_t)(from_end - id_end)); return git_buf_oom(to) ? -1 : 0; } static int ident_apply( git_filter *self, void **payload, git_buf *to, const git_buf *from, const git_filter_source *src) { GIT_UNUSED(self); GIT_UNUSED(payload); /* Don't filter binary files */ if (git_buf_text_is_binary(from)) return GIT_PASSTHROUGH; if (git_filter_source_mode(src) == GIT_FILTER_SMUDGE) return ident_insert_id(to, from, src); else return ident_remove_id(to, from); } git_filter *git_ident_filter_new(void) { git_filter *f = git__calloc(1, sizeof(git_filter)); if (f == NULL) return NULL; f->version = GIT_FILTER_VERSION; f->attributes = "+ident"; /* apply to files with ident attribute set */ f->shutdown = git_filter_free; f->apply = ident_apply; return f; } deps/libgit2-sys-0.3.8/libgit2/src/diff_patch.h0000664000175000017500000000435412555730137016150 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_diff_patch_h__ #define INCLUDE_diff_patch_h__ #include "common.h" #include "diff.h" #include "diff_file.h" #include "array.h" #include "git2/patch.h" /* cached information about a hunk in a diff */ typedef struct diff_patch_hunk { git_diff_hunk hunk; size_t line_start; size_t line_count; } diff_patch_hunk; enum { GIT_DIFF_PATCH_ALLOCATED = (1 << 0), GIT_DIFF_PATCH_INITIALIZED = (1 << 1), GIT_DIFF_PATCH_LOADED = (1 << 2), /* the two sides are different */ GIT_DIFF_PATCH_DIFFABLE = (1 << 3), /* the difference between the two sides has been computed */ GIT_DIFF_PATCH_DIFFED = (1 << 4), GIT_DIFF_PATCH_FLATTENED = (1 << 5), }; struct git_patch { git_refcount rc; git_diff *diff; /* for refcount purposes, maybe NULL for blob diffs */ git_diff_options diff_opts; git_diff_delta *delta; size_t delta_index; git_diff_file_content ofile; git_diff_file_content nfile; uint32_t flags; git_diff_binary binary; git_array_t(diff_patch_hunk) hunks; git_array_t(git_diff_line) lines; size_t content_size, context_size, header_size; git_pool flattened; }; extern git_diff *git_patch__diff(git_patch *); extern git_diff_driver *git_patch__driver(git_patch *); extern void git_patch__old_data(char **, size_t *, git_patch *); extern void git_patch__new_data(char **, size_t *, git_patch *); extern int git_patch__invoke_callbacks( git_patch *patch, git_diff_file_cb file_cb, git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb line_cb, void *payload); typedef struct git_diff_output git_diff_output; struct git_diff_output { /* these callbacks are issued with the diff data */ git_diff_file_cb file_cb; git_diff_binary_cb binary_cb; git_diff_hunk_cb hunk_cb; git_diff_line_cb data_cb; void *payload; /* this records the actual error in cases where it may be obscured */ int error; /* this callback is used to do the diff and drive the other callbacks. * see diff_xdiff.h for how to use this in practice for now. */ int (*diff_cb)(git_diff_output *output, git_patch *patch); }; #endif deps/libgit2-sys-0.3.8/libgit2/src/attrcache.h0000664000175000017500000000312312510265101015771 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_attrcache_h__ #define INCLUDE_attrcache_h__ #include "attr_file.h" #include "strmap.h" #define GIT_ATTR_CONFIG "core.attributesfile" #define GIT_IGNORE_CONFIG "core.excludesfile" typedef struct { char *cfg_attr_file; /* cached value of core.attributesfile */ char *cfg_excl_file; /* cached value of core.excludesfile */ git_strmap *files; /* hash path to git_attr_cache_entry records */ git_strmap *macros; /* hash name to vector */ git_mutex lock; git_pool pool; } git_attr_cache; extern int git_attr_cache__do_init(git_repository *repo); #define git_attr_cache__init(REPO) \ (git_repository_attr_cache(REPO) ? 0 : git_attr_cache__do_init(REPO)) /* get file - loading and reload as needed */ extern int git_attr_cache__get( git_attr_file **file, git_repository *repo, git_attr_session *attr_session, git_attr_file_source source, const char *base, const char *filename, git_attr_file_parser parser); extern bool git_attr_cache__is_cached( git_repository *repo, git_attr_file_source source, const char *path); extern int git_attr_cache__alloc_file_entry( git_attr_file_entry **out, const char *base, const char *path, git_pool *pool); extern int git_attr_cache__insert_macro( git_repository *repo, git_attr_rule *macro); extern git_attr_rule *git_attr_cache__lookup_macro( git_repository *repo, const char *name); #endif deps/libgit2-sys-0.3.8/libgit2/src/blame.c0000664000175000017500000003306312610310643015117 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "blame.h" #include "git2/commit.h" #include "git2/revparse.h" #include "git2/revwalk.h" #include "git2/tree.h" #include "git2/diff.h" #include "git2/blob.h" #include "git2/signature.h" #include "util.h" #include "repository.h" #include "blame_git.h" static int hunk_byfinalline_search_cmp(const void *key, const void *entry) { git_blame_hunk *hunk = (git_blame_hunk*)entry; size_t lineno = *(size_t*)key; size_t lines_in_hunk = (size_t)hunk->lines_in_hunk; size_t final_start_line_number = (size_t)hunk->final_start_line_number; if (lineno < final_start_line_number) return -1; if (lineno >= final_start_line_number + lines_in_hunk) return 1; return 0; } static int paths_cmp(const void *a, const void *b) { return git__strcmp((char*)a, (char*)b); } static int hunk_cmp(const void *_a, const void *_b) { git_blame_hunk *a = (git_blame_hunk*)_a, *b = (git_blame_hunk*)_b; return a->final_start_line_number - b->final_start_line_number; } static bool hunk_ends_at_or_before_line(git_blame_hunk *hunk, size_t line) { return line >= (size_t)(hunk->final_start_line_number + hunk->lines_in_hunk - 1); } static bool hunk_starts_at_or_after_line(git_blame_hunk *hunk, size_t line) { return line <= hunk->final_start_line_number; } static git_blame_hunk* new_hunk( uint16_t start, uint16_t lines, uint16_t orig_start, const char *path) { git_blame_hunk *hunk = git__calloc(1, sizeof(git_blame_hunk)); if (!hunk) return NULL; hunk->lines_in_hunk = lines; hunk->final_start_line_number = start; hunk->orig_start_line_number = orig_start; hunk->orig_path = path ? git__strdup(path) : NULL; return hunk; } static git_blame_hunk* dup_hunk(git_blame_hunk *hunk) { git_blame_hunk *newhunk = new_hunk( hunk->final_start_line_number, hunk->lines_in_hunk, hunk->orig_start_line_number, hunk->orig_path); if (!newhunk) return NULL; git_oid_cpy(&newhunk->orig_commit_id, &hunk->orig_commit_id); git_oid_cpy(&newhunk->final_commit_id, &hunk->final_commit_id); newhunk->boundary = hunk->boundary; git_signature_dup(&newhunk->final_signature, hunk->final_signature); git_signature_dup(&newhunk->orig_signature, hunk->orig_signature); return newhunk; } static void free_hunk(git_blame_hunk *hunk) { git__free((void*)hunk->orig_path); git_signature_free(hunk->final_signature); git_signature_free(hunk->orig_signature); git__free(hunk); } /* Starting with the hunk that includes start_line, shift all following hunks' * final_start_line by shift_by lines */ static void shift_hunks_by(git_vector *v, size_t start_line, int shift_by) { size_t i; if (!git_vector_bsearch2(&i, v, hunk_byfinalline_search_cmp, &start_line)) { for (; i < v->length; i++) { git_blame_hunk *hunk = (git_blame_hunk*)v->contents[i]; hunk->final_start_line_number += shift_by; } } } git_blame* git_blame__alloc( git_repository *repo, git_blame_options opts, const char *path) { git_blame *gbr = git__calloc(1, sizeof(git_blame)); if (!gbr) return NULL; gbr->repository = repo; gbr->options = opts; if (git_vector_init(&gbr->hunks, 8, hunk_cmp) < 0 || git_vector_init(&gbr->paths, 8, paths_cmp) < 0 || (gbr->path = git__strdup(path)) == NULL || git_vector_insert(&gbr->paths, git__strdup(path)) < 0) { git_blame_free(gbr); return NULL; } return gbr; } void git_blame_free(git_blame *blame) { size_t i; git_blame_hunk *hunk; if (!blame) return; git_vector_foreach(&blame->hunks, i, hunk) free_hunk(hunk); git_vector_free(&blame->hunks); git_vector_free_deep(&blame->paths); git_array_clear(blame->line_index); git__free(blame->path); git_blob_free(blame->final_blob); git__free(blame); } uint32_t git_blame_get_hunk_count(git_blame *blame) { assert(blame); return (uint32_t)blame->hunks.length; } const git_blame_hunk *git_blame_get_hunk_byindex(git_blame *blame, uint32_t index) { assert(blame); return (git_blame_hunk*)git_vector_get(&blame->hunks, index); } const git_blame_hunk *git_blame_get_hunk_byline(git_blame *blame, uint32_t lineno) { size_t i, new_lineno = (size_t)lineno; assert(blame); if (!git_vector_bsearch2(&i, &blame->hunks, hunk_byfinalline_search_cmp, &new_lineno)) { return git_blame_get_hunk_byindex(blame, (uint32_t)i); } return NULL; } static void normalize_options( git_blame_options *out, const git_blame_options *in, git_repository *repo) { git_blame_options dummy = GIT_BLAME_OPTIONS_INIT; if (!in) in = &dummy; memcpy(out, in, sizeof(git_blame_options)); /* No newest_commit => HEAD */ if (git_oid_iszero(&out->newest_commit)) { git_reference_name_to_id(&out->newest_commit, repo, "HEAD"); } /* min_line 0 really means 1 */ if (!out->min_line) out->min_line = 1; /* max_line 0 really means N, but we don't know N yet */ /* Fix up option implications */ if (out->flags & GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES) out->flags |= GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES; if (out->flags & GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES) out->flags |= GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES; if (out->flags & GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES) out->flags |= GIT_BLAME_TRACK_COPIES_SAME_FILE; } static git_blame_hunk *split_hunk_in_vector( git_vector *vec, git_blame_hunk *hunk, size_t rel_line, bool return_new) { size_t new_line_count; git_blame_hunk *nh; /* Don't split if already at a boundary */ if (rel_line <= 0 || rel_line >= hunk->lines_in_hunk) { return hunk; } new_line_count = hunk->lines_in_hunk - rel_line; nh = new_hunk((uint16_t)(hunk->final_start_line_number+rel_line), (uint16_t)new_line_count, (uint16_t)(hunk->orig_start_line_number+rel_line), hunk->orig_path); if (!nh) return NULL; git_oid_cpy(&nh->final_commit_id, &hunk->final_commit_id); git_oid_cpy(&nh->orig_commit_id, &hunk->orig_commit_id); /* Adjust hunk that was split */ hunk->lines_in_hunk -= (uint16_t)new_line_count; git_vector_insert_sorted(vec, nh, NULL); { git_blame_hunk *ret = return_new ? nh : hunk; return ret; } } /* * Construct a list of char indices for where lines begin * Adapted from core git: * https://github.com/gitster/git/blob/be5c9fb9049ed470e7005f159bb923a5f4de1309/builtin/blame.c#L1760-L1789 */ static int index_blob_lines(git_blame *blame) { const char *buf = blame->final_buf; git_off_t len = blame->final_buf_size; int num = 0, incomplete = 0, bol = 1; size_t *i; if (len && buf[len-1] != '\n') incomplete++; /* incomplete line at the end */ while (len--) { if (bol) { i = git_array_alloc(blame->line_index); GITERR_CHECK_ALLOC(i); *i = buf - blame->final_buf; bol = 0; } if (*buf++ == '\n') { num++; bol = 1; } } i = git_array_alloc(blame->line_index); GITERR_CHECK_ALLOC(i); *i = buf - blame->final_buf; blame->num_lines = num + incomplete; return blame->num_lines; } static git_blame_hunk* hunk_from_entry(git_blame__entry *e) { git_blame_hunk *h = new_hunk( e->lno+1, e->num_lines, e->s_lno+1, e->suspect->path); if (!h) return NULL; git_oid_cpy(&h->final_commit_id, git_commit_id(e->suspect->commit)); git_oid_cpy(&h->orig_commit_id, git_commit_id(e->suspect->commit)); git_signature_dup(&h->final_signature, git_commit_author(e->suspect->commit)); git_signature_dup(&h->orig_signature, git_commit_author(e->suspect->commit)); h->boundary = e->is_boundary ? 1 : 0; return h; } static int load_blob(git_blame *blame) { int error; if (blame->final_blob) return 0; error = git_commit_lookup(&blame->final, blame->repository, &blame->options.newest_commit); if (error < 0) goto cleanup; error = git_object_lookup_bypath((git_object**)&blame->final_blob, (git_object*)blame->final, blame->path, GIT_OBJ_BLOB); cleanup: return error; } static int blame_internal(git_blame *blame) { int error; git_blame__entry *ent = NULL; git_blame__origin *o; if ((error = load_blob(blame)) < 0 || (error = git_blame__get_origin(&o, blame, blame->final, blame->path)) < 0) goto cleanup; blame->final_buf = git_blob_rawcontent(blame->final_blob); blame->final_buf_size = git_blob_rawsize(blame->final_blob); ent = git__calloc(1, sizeof(git_blame__entry)); GITERR_CHECK_ALLOC(ent); ent->num_lines = index_blob_lines(blame); ent->lno = blame->options.min_line - 1; ent->num_lines = ent->num_lines - blame->options.min_line + 1; if (blame->options.max_line > 0) ent->num_lines = blame->options.max_line - blame->options.min_line + 1; ent->s_lno = ent->lno; ent->suspect = o; blame->ent = ent; error = git_blame__like_git(blame, blame->options.flags); cleanup: for (ent = blame->ent; ent; ) { git_blame__entry *e = ent->next; git_blame_hunk *h = hunk_from_entry(ent); git_vector_insert(&blame->hunks, h); git_blame__free_entry(ent); ent = e; } return error; } /******************************************************************************* * File blaming ******************************************************************************/ int git_blame_file( git_blame **out, git_repository *repo, const char *path, git_blame_options *options) { int error = -1; git_blame_options normOptions = GIT_BLAME_OPTIONS_INIT; git_blame *blame = NULL; assert(out && repo && path); normalize_options(&normOptions, options, repo); blame = git_blame__alloc(repo, normOptions, path); GITERR_CHECK_ALLOC(blame); if ((error = load_blob(blame)) < 0) goto on_error; if ((error = blame_internal(blame)) < 0) goto on_error; *out = blame; return 0; on_error: git_blame_free(blame); return error; } /******************************************************************************* * Buffer blaming *******************************************************************************/ static bool hunk_is_bufferblame(git_blame_hunk *hunk) { return git_oid_iszero(&hunk->final_commit_id); } static int buffer_hunk_cb( const git_diff_delta *delta, const git_diff_hunk *hunk, void *payload) { git_blame *blame = (git_blame*)payload; uint32_t wedge_line; GIT_UNUSED(delta); wedge_line = (hunk->old_lines == 0) ? hunk->new_start : hunk->old_start; blame->current_diff_line = wedge_line; blame->current_hunk = (git_blame_hunk*)git_blame_get_hunk_byline(blame, wedge_line); if (!blame->current_hunk) { /* Line added at the end of the file */ blame->current_hunk = new_hunk(wedge_line, 0, wedge_line, blame->path); GITERR_CHECK_ALLOC(blame->current_hunk); git_vector_insert(&blame->hunks, blame->current_hunk); } else if (!hunk_starts_at_or_after_line(blame->current_hunk, wedge_line)){ /* If this hunk doesn't start between existing hunks, split a hunk up so it does */ blame->current_hunk = split_hunk_in_vector(&blame->hunks, blame->current_hunk, wedge_line - blame->current_hunk->orig_start_line_number, true); GITERR_CHECK_ALLOC(blame->current_hunk); } return 0; } static int ptrs_equal_cmp(const void *a, const void *b) { return ab ? 1 : 0; } static int buffer_line_cb( const git_diff_delta *delta, const git_diff_hunk *hunk, const git_diff_line *line, void *payload) { git_blame *blame = (git_blame*)payload; GIT_UNUSED(delta); GIT_UNUSED(hunk); GIT_UNUSED(line); if (line->origin == GIT_DIFF_LINE_ADDITION) { if (hunk_is_bufferblame(blame->current_hunk) && hunk_ends_at_or_before_line(blame->current_hunk, blame->current_diff_line)) { /* Append to the current buffer-blame hunk */ blame->current_hunk->lines_in_hunk++; shift_hunks_by(&blame->hunks, blame->current_diff_line+1, 1); } else { /* Create a new buffer-blame hunk with this line */ shift_hunks_by(&blame->hunks, blame->current_diff_line, 1); blame->current_hunk = new_hunk((uint16_t)blame->current_diff_line, 1, 0, blame->path); GITERR_CHECK_ALLOC(blame->current_hunk); git_vector_insert_sorted(&blame->hunks, blame->current_hunk, NULL); } blame->current_diff_line++; } if (line->origin == GIT_DIFF_LINE_DELETION) { /* Trim the line from the current hunk; remove it if it's now empty */ size_t shift_base = blame->current_diff_line + blame->current_hunk->lines_in_hunk+1; if (--(blame->current_hunk->lines_in_hunk) == 0) { size_t i; shift_base--; if (!git_vector_search2(&i, &blame->hunks, ptrs_equal_cmp, blame->current_hunk)) { git_vector_remove(&blame->hunks, i); free_hunk(blame->current_hunk); blame->current_hunk = (git_blame_hunk*)git_blame_get_hunk_byindex(blame, (uint32_t)i); } } shift_hunks_by(&blame->hunks, shift_base, -1); } return 0; } int git_blame_buffer( git_blame **out, git_blame *reference, const char *buffer, size_t buffer_len) { git_blame *blame; git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT; size_t i; git_blame_hunk *hunk; diffopts.context_lines = 0; assert(out && reference && buffer && buffer_len); blame = git_blame__alloc(reference->repository, reference->options, reference->path); GITERR_CHECK_ALLOC(blame); /* Duplicate all of the hunk structures in the reference blame */ git_vector_foreach(&reference->hunks, i, hunk) { git_blame_hunk *h = dup_hunk(hunk); GITERR_CHECK_ALLOC(h); git_vector_insert(&blame->hunks, h); } /* Diff to the reference blob */ git_diff_blob_to_buffer(reference->final_blob, blame->path, buffer, buffer_len, blame->path, &diffopts, NULL, NULL, buffer_hunk_cb, buffer_line_cb, blame); *out = blame; return 0; } int git_blame_init_options(git_blame_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_blame_options, GIT_BLAME_OPTIONS_INIT); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/tls_stream.c0000664000175000017500000000127612555730137016231 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/errors.h" #include "common.h" #include "openssl_stream.h" #include "stransport_stream.h" int git_tls_stream_new(git_stream **out, const char *host, const char *port) { #ifdef GIT_SECURE_TRANSPORT return git_stransport_stream_new(out, host, port); #elif defined(GIT_OPENSSL) return git_openssl_stream_new(out, host, port); #else GIT_UNUSED(out); GIT_UNUSED(host); GIT_UNUSED(port); giterr_set(GITERR_SSL, "there is no TLS stream available"); return -1; #endif } deps/libgit2-sys-0.3.8/libgit2/src/cache.h0000664000175000017500000000317712510265101015107 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_cache_h__ #define INCLUDE_cache_h__ #include "git2/common.h" #include "git2/oid.h" #include "git2/odb.h" #include "thread-utils.h" #include "oidmap.h" enum { GIT_CACHE_STORE_ANY = 0, GIT_CACHE_STORE_RAW = 1, GIT_CACHE_STORE_PARSED = 2 }; typedef struct { git_oid oid; int16_t type; /* git_otype value */ uint16_t flags; /* GIT_CACHE_STORE value */ size_t size; git_atomic refcount; } git_cached_obj; typedef struct { git_oidmap *map; git_rwlock lock; ssize_t used_memory; } git_cache; extern bool git_cache__enabled; extern ssize_t git_cache__max_storage; extern git_atomic_ssize git_cache__current_storage; int git_cache_set_max_object_size(git_otype type, size_t size); int git_cache_init(git_cache *cache); void git_cache_free(git_cache *cache); void git_cache_clear(git_cache *cache); void *git_cache_store_raw(git_cache *cache, git_odb_object *entry); void *git_cache_store_parsed(git_cache *cache, git_object *entry); git_odb_object *git_cache_get_raw(git_cache *cache, const git_oid *oid); git_object *git_cache_get_parsed(git_cache *cache, const git_oid *oid); void *git_cache_get_any(git_cache *cache, const git_oid *oid); GIT_INLINE(size_t) git_cache_size(git_cache *cache) { return (size_t)kh_size(cache->map); } GIT_INLINE(void) git_cached_obj_incref(void *_obj) { git_cached_obj *obj = _obj; git_atomic_inc(&obj->refcount); } void git_cached_obj_decref(void *_obj); #endif deps/libgit2-sys-0.3.8/libgit2/src/refdb.h0000664000175000017500000000350312510265101015117 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_refdb_h__ #define INCLUDE_refdb_h__ #include "git2/refdb.h" #include "repository.h" struct git_refdb { git_refcount rc; git_repository *repo; git_refdb_backend *backend; }; void git_refdb__free(git_refdb *db); int git_refdb_exists( int *exists, git_refdb *refdb, const char *ref_name); int git_refdb_lookup( git_reference **out, git_refdb *refdb, const char *ref_name); int git_refdb_rename( git_reference **out, git_refdb *db, const char *old_name, const char *new_name, int force, const git_signature *who, const char *message); int git_refdb_iterator(git_reference_iterator **out, git_refdb *db, const char *glob); int git_refdb_iterator_next(git_reference **out, git_reference_iterator *iter); int git_refdb_iterator_next_name(const char **out, git_reference_iterator *iter); void git_refdb_iterator_free(git_reference_iterator *iter); int git_refdb_write(git_refdb *refdb, git_reference *ref, int force, const git_signature *who, const char *message, const git_oid *old_id, const char *old_target); int git_refdb_delete(git_refdb *refdb, const char *ref_name, const git_oid *old_id, const char *old_target); int git_refdb_reflog_read(git_reflog **out, git_refdb *db, const char *name); int git_refdb_reflog_write(git_reflog *reflog); int git_refdb_has_log(git_refdb *db, const char *refname); int git_refdb_ensure_log(git_refdb *refdb, const char *refname); int git_refdb_lock(void **payload, git_refdb *db, const char *refname); int git_refdb_unlock(git_refdb *db, void *payload, int success, int update_reflog, const git_reference *ref, const git_signature *sig, const char *message); #endif deps/libgit2-sys-0.3.8/libgit2/src/clone.c0000664000175000017500000003323112572105236015143 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include #include "git2/clone.h" #include "git2/remote.h" #include "git2/revparse.h" #include "git2/branch.h" #include "git2/config.h" #include "git2/checkout.h" #include "git2/commit.h" #include "git2/tree.h" #include "common.h" #include "remote.h" #include "fileops.h" #include "refs.h" #include "path.h" #include "repository.h" #include "odb.h" static int clone_local_into(git_repository *repo, git_remote *remote, const git_fetch_options *fetch_opts, const git_checkout_options *co_opts, const char *branch, int link); static int create_branch( git_reference **branch, git_repository *repo, const git_oid *target, const char *name, const char *log_message) { git_commit *head_obj = NULL; git_reference *branch_ref = NULL; git_buf refname = GIT_BUF_INIT; int error; /* Find the target commit */ if ((error = git_commit_lookup(&head_obj, repo, target)) < 0) return error; /* Create the new branch */ if ((error = git_buf_printf(&refname, GIT_REFS_HEADS_DIR "%s", name)) < 0) return error; error = git_reference_create(&branch_ref, repo, git_buf_cstr(&refname), target, 0, log_message); git_buf_free(&refname); git_commit_free(head_obj); if (!error) *branch = branch_ref; else git_reference_free(branch_ref); return error; } static int setup_tracking_config( git_repository *repo, const char *branch_name, const char *remote_name, const char *merge_target) { git_config *cfg; git_buf remote_key = GIT_BUF_INIT, merge_key = GIT_BUF_INIT; int error = -1; if (git_repository_config__weakptr(&cfg, repo) < 0) return -1; if (git_buf_printf(&remote_key, "branch.%s.remote", branch_name) < 0) goto cleanup; if (git_buf_printf(&merge_key, "branch.%s.merge", branch_name) < 0) goto cleanup; if (git_config_set_string(cfg, git_buf_cstr(&remote_key), remote_name) < 0) goto cleanup; if (git_config_set_string(cfg, git_buf_cstr(&merge_key), merge_target) < 0) goto cleanup; error = 0; cleanup: git_buf_free(&remote_key); git_buf_free(&merge_key); return error; } static int create_tracking_branch( git_reference **branch, git_repository *repo, const git_oid *target, const char *branch_name, const char *log_message) { int error; if ((error = create_branch(branch, repo, target, branch_name, log_message)) < 0) return error; return setup_tracking_config( repo, branch_name, GIT_REMOTE_ORIGIN, git_reference_name(*branch)); } static int update_head_to_new_branch( git_repository *repo, const git_oid *target, const char *name, const char *reflog_message) { git_reference *tracking_branch = NULL; int error; if (!git__prefixcmp(name, GIT_REFS_HEADS_DIR)) name += strlen(GIT_REFS_HEADS_DIR); error = create_tracking_branch(&tracking_branch, repo, target, name, reflog_message); if (!error) error = git_repository_set_head( repo, git_reference_name(tracking_branch)); git_reference_free(tracking_branch); /* if it already existed, then the user's refspec created it for us, ignore it' */ if (error == GIT_EEXISTS) error = 0; return error; } static int update_head_to_remote( git_repository *repo, git_remote *remote, const char *reflog_message) { int error = 0; size_t refs_len; git_refspec *refspec; const git_remote_head *remote_head, **refs; const git_oid *remote_head_id; git_buf remote_master_name = GIT_BUF_INIT; git_buf branch = GIT_BUF_INIT; if ((error = git_remote_ls(&refs, &refs_len, remote)) < 0) return error; /* We cloned an empty repository or one with an unborn HEAD */ if (refs_len == 0 || strcmp(refs[0]->name, GIT_HEAD_FILE)) return setup_tracking_config( repo, "master", GIT_REMOTE_ORIGIN, GIT_REFS_HEADS_MASTER_FILE); /* We know we have HEAD, let's see where it points */ remote_head = refs[0]; assert(remote_head); remote_head_id = &remote_head->oid; error = git_remote_default_branch(&branch, remote); if (error == GIT_ENOTFOUND) { error = git_repository_set_head_detached( repo, remote_head_id); goto cleanup; } refspec = git_remote__matching_refspec(remote, git_buf_cstr(&branch)); if (refspec == NULL) { giterr_set(GITERR_NET, "the remote's default branch does not fit the refspec configuration"); error = GIT_EINVALIDSPEC; goto cleanup; } /* Determine the remote tracking reference name from the local master */ if ((error = git_refspec_transform( &remote_master_name, refspec, git_buf_cstr(&branch))) < 0) goto cleanup; error = update_head_to_new_branch( repo, remote_head_id, git_buf_cstr(&branch), reflog_message); cleanup: git_buf_free(&remote_master_name); git_buf_free(&branch); return error; } static int update_head_to_branch( git_repository *repo, const char *remote_name, const char *branch, const char *reflog_message) { int retcode; git_buf remote_branch_name = GIT_BUF_INIT; git_reference* remote_ref = NULL; assert(remote_name && branch); if ((retcode = git_buf_printf(&remote_branch_name, GIT_REFS_REMOTES_DIR "%s/%s", remote_name, branch)) < 0 ) goto cleanup; if ((retcode = git_reference_lookup(&remote_ref, repo, git_buf_cstr(&remote_branch_name))) < 0) goto cleanup; retcode = update_head_to_new_branch(repo, git_reference_target(remote_ref), branch, reflog_message); cleanup: git_reference_free(remote_ref); git_buf_free(&remote_branch_name); return retcode; } static int default_repository_create(git_repository **out, const char *path, int bare, void *payload) { GIT_UNUSED(payload); return git_repository_init(out, path, bare); } static int default_remote_create( git_remote **out, git_repository *repo, const char *name, const char *url, void *payload) { GIT_UNUSED(payload); return git_remote_create(out, repo, name, url); } /* * submodules? */ static int create_and_configure_origin( git_remote **out, git_repository *repo, const char *url, const git_clone_options *options) { int error; git_remote *origin = NULL; char buf[GIT_PATH_MAX]; git_remote_create_cb remote_create = options->remote_cb; void *payload = options->remote_cb_payload; /* If the path exists and is a dir, the url should be the absolute path */ if (git_path_root(url) < 0 && git_path_exists(url) && git_path_isdir(url)) { if (p_realpath(url, buf) == NULL) return -1; url = buf; } if (!remote_create) { remote_create = default_remote_create; payload = NULL; } if ((error = remote_create(&origin, repo, "origin", url, payload)) < 0) goto on_error; *out = origin; return 0; on_error: git_remote_free(origin); return error; } static bool should_checkout( git_repository *repo, bool is_bare, const git_checkout_options *opts) { if (is_bare) return false; if (!opts) return false; if (opts->checkout_strategy == GIT_CHECKOUT_NONE) return false; return !git_repository_head_unborn(repo); } static int checkout_branch(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, const char *reflog_message) { int error; if (branch) error = update_head_to_branch(repo, git_remote_name(remote), branch, reflog_message); /* Point HEAD to the same ref as the remote's head */ else error = update_head_to_remote(repo, remote, reflog_message); if (!error && should_checkout(repo, git_repository_is_bare(repo), co_opts)) error = git_checkout_head(repo, co_opts); return error; } static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch_options *opts, const git_checkout_options *co_opts, const char *branch) { int error; git_buf reflog_message = GIT_BUF_INIT; git_fetch_options fetch_opts; git_remote *remote; assert(repo && _remote); if (!git_repository_is_empty(repo)) { giterr_set(GITERR_INVALID, "the repository is not empty"); return -1; } if ((error = git_remote_dup(&remote, _remote)) < 0) return error; memcpy(&fetch_opts, opts, sizeof(git_fetch_options)); fetch_opts.update_fetchhead = 0; fetch_opts.download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL; git_buf_printf(&reflog_message, "clone: from %s", git_remote_url(remote)); if ((error = git_remote_fetch(remote, NULL, &fetch_opts, git_buf_cstr(&reflog_message))) != 0) goto cleanup; error = checkout_branch(repo, remote, co_opts, branch, git_buf_cstr(&reflog_message)); cleanup: git_remote_free(remote); git_buf_free(&reflog_message); return error; } int git_clone__should_clone_local(const char *url_or_path, git_clone_local_t local) { git_buf fromurl = GIT_BUF_INIT; const char *path = url_or_path; bool is_url, is_local; if (local == GIT_CLONE_NO_LOCAL) return 0; if ((is_url = git_path_is_local_file_url(url_or_path)) != 0) { if (git_path_fromurl(&fromurl, url_or_path) < 0) { is_local = -1; goto done; } path = fromurl.ptr; } is_local = (!is_url || local != GIT_CLONE_LOCAL_AUTO) && git_path_isdir(path); done: git_buf_free(&fromurl); return is_local; } int git_clone( git_repository **out, const char *url, const char *local_path, const git_clone_options *_options) { int error = 0; git_repository *repo = NULL; git_remote *origin; git_clone_options options = GIT_CLONE_OPTIONS_INIT; uint32_t rmdir_flags = GIT_RMDIR_REMOVE_FILES; git_repository_create_cb repository_cb; assert(out && url && local_path); if (_options) memcpy(&options, _options, sizeof(git_clone_options)); GITERR_CHECK_VERSION(&options, GIT_CLONE_OPTIONS_VERSION, "git_clone_options"); /* Only clone to a new directory or an empty directory */ if (git_path_exists(local_path) && !git_path_is_empty_dir(local_path)) { giterr_set(GITERR_INVALID, "'%s' exists and is not an empty directory", local_path); return GIT_EEXISTS; } /* Only remove the root directory on failure if we create it */ if (git_path_exists(local_path)) rmdir_flags |= GIT_RMDIR_SKIP_ROOT; if (options.repository_cb) repository_cb = options.repository_cb; else repository_cb = default_repository_create; if ((error = repository_cb(&repo, local_path, options.bare, options.repository_cb_payload)) < 0) return error; if (!(error = create_and_configure_origin(&origin, repo, url, &options))) { int clone_local = git_clone__should_clone_local(url, options.local); int link = options.local != GIT_CLONE_LOCAL_NO_LINKS; if (clone_local == 1) error = clone_local_into( repo, origin, &options.fetch_opts, &options.checkout_opts, options.checkout_branch, link); else if (clone_local == 0) error = clone_into( repo, origin, &options.fetch_opts, &options.checkout_opts, options.checkout_branch); else error = -1; git_remote_free(origin); } if (error != 0) { git_error_state last_error = {0}; giterr_state_capture(&last_error, error); git_repository_free(repo); repo = NULL; (void)git_futils_rmdir_r(local_path, NULL, rmdir_flags); giterr_state_restore(&last_error); } *out = repo; return error; } int git_clone_init_options(git_clone_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_clone_options, GIT_CLONE_OPTIONS_INIT); return 0; } static const char *repository_base(git_repository *repo) { if (git_repository_is_bare(repo)) return git_repository_path(repo); return git_repository_workdir(repo); } static bool can_link(const char *src, const char *dst, int link) { #ifdef GIT_WIN32 GIT_UNUSED(src); GIT_UNUSED(dst); GIT_UNUSED(link); return false; #else struct stat st_src, st_dst; if (!link) return false; if (p_stat(src, &st_src) < 0) return false; if (p_stat(dst, &st_dst) < 0) return false; return st_src.st_dev == st_dst.st_dev; #endif } static int clone_local_into(git_repository *repo, git_remote *remote, const git_fetch_options *fetch_opts, const git_checkout_options *co_opts, const char *branch, int link) { int error, flags; git_repository *src; git_buf src_odb = GIT_BUF_INIT, dst_odb = GIT_BUF_INIT, src_path = GIT_BUF_INIT; git_buf reflog_message = GIT_BUF_INIT; assert(repo && remote); if (!git_repository_is_empty(repo)) { giterr_set(GITERR_INVALID, "the repository is not empty"); return -1; } /* * Let's figure out what path we should use for the source * repo, if it's not rooted, the path should be relative to * the repository's worktree/gitdir. */ if ((error = git_path_from_url_or_path(&src_path, git_remote_url(remote))) < 0) return error; /* Copy .git/objects/ from the source to the target */ if ((error = git_repository_open(&src, git_buf_cstr(&src_path))) < 0) { git_buf_free(&src_path); return error; } git_buf_joinpath(&src_odb, git_repository_path(src), GIT_OBJECTS_DIR); git_buf_joinpath(&dst_odb, git_repository_path(repo), GIT_OBJECTS_DIR); if (git_buf_oom(&src_odb) || git_buf_oom(&dst_odb)) { error = -1; goto cleanup; } flags = 0; if (can_link(git_repository_path(src), git_repository_path(repo), link)) flags |= GIT_CPDIR_LINK_FILES; error = git_futils_cp_r(git_buf_cstr(&src_odb), git_buf_cstr(&dst_odb), flags, GIT_OBJECT_DIR_MODE); /* * can_link() doesn't catch all variations, so if we hit an * error and did want to link, let's try again without trying * to link. */ if (error < 0 && link) { flags &= ~GIT_CPDIR_LINK_FILES; error = git_futils_cp_r(git_buf_cstr(&src_odb), git_buf_cstr(&dst_odb), flags, GIT_OBJECT_DIR_MODE); } if (error < 0) goto cleanup; git_buf_printf(&reflog_message, "clone: from %s", git_remote_url(remote)); if ((error = git_remote_fetch(remote, NULL, fetch_opts, git_buf_cstr(&reflog_message))) != 0) goto cleanup; error = checkout_branch(repo, remote, co_opts, branch, git_buf_cstr(&reflog_message)); cleanup: git_buf_free(&reflog_message); git_buf_free(&src_path); git_buf_free(&src_odb); git_buf_free(&dst_odb); git_repository_free(src); return error; } deps/libgit2-sys-0.3.8/libgit2/src/tls_stream.h0000664000175000017500000000115412555730137016231 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_tls_stream_h__ #define INCLUDE_tls_stream_h__ #include "git2/sys/stream.h" /** * Create a TLS stream with the most appropriate backend available for * the current platform. * * This allows us to ask for a SecureTransport or OpenSSL stream * according to being on general Unix vs OS X. */ extern int git_tls_stream_new(git_stream **out, const char *host, const char *port); #endif deps/libgit2-sys-0.3.8/libgit2/src/errors.c0000664000175000017500000000756512572105236015372 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "global.h" #include "posix.h" #include "buffer.h" /******************************************** * New error handling ********************************************/ static git_error g_git_oom_error = { "Out of memory", GITERR_NOMEMORY }; static void set_error_from_buffer(int error_class) { git_error *error = &GIT_GLOBAL->error_t; git_buf *buf = &GIT_GLOBAL->error_buf; error->message = buf->ptr; error->klass = error_class; GIT_GLOBAL->last_error = error; } static void set_error(int error_class, char *string) { git_buf *buf = &GIT_GLOBAL->error_buf; git_buf_clear(buf); if (string) { git_buf_puts(buf, string); git__free(string); } set_error_from_buffer(error_class); } void giterr_set_oom(void) { GIT_GLOBAL->last_error = &g_git_oom_error; } void giterr_set(int error_class, const char *string, ...) { va_list arglist; #ifdef GIT_WIN32 DWORD win32_error_code = (error_class == GITERR_OS) ? GetLastError() : 0; #endif int error_code = (error_class == GITERR_OS) ? errno : 0; git_buf *buf = &GIT_GLOBAL->error_buf; git_buf_clear(buf); if (string) { va_start(arglist, string); git_buf_vprintf(buf, string, arglist); va_end(arglist); if (error_class == GITERR_OS) git_buf_PUTS(buf, ": "); } if (error_class == GITERR_OS) { #ifdef GIT_WIN32 char * win32_error = git_win32_get_error_message(win32_error_code); if (win32_error) { git_buf_puts(buf, win32_error); git__free(win32_error); SetLastError(0); } else #endif if (error_code) git_buf_puts(buf, strerror(error_code)); if (error_code) errno = 0; } if (!git_buf_oom(buf)) set_error_from_buffer(error_class); } void giterr_set_str(int error_class, const char *string) { git_buf *buf = &GIT_GLOBAL->error_buf; assert(string); if (!string) return; git_buf_clear(buf); git_buf_puts(buf, string); if (!git_buf_oom(buf)) set_error_from_buffer(error_class); } int giterr_set_regex(const regex_t *regex, int error_code) { char error_buf[1024]; assert(error_code); regerror(error_code, regex, error_buf, sizeof(error_buf)); giterr_set_str(GITERR_REGEX, error_buf); if (error_code == REG_NOMATCH) return GIT_ENOTFOUND; return GIT_EINVALIDSPEC; } void giterr_clear(void) { if (GIT_GLOBAL->last_error != NULL) { set_error(0, NULL); GIT_GLOBAL->last_error = NULL; } errno = 0; #ifdef GIT_WIN32 SetLastError(0); #endif } const git_error *giterr_last(void) { return GIT_GLOBAL->last_error; } int giterr_state_capture(git_error_state *state, int error_code) { git_error *error = GIT_GLOBAL->last_error; git_buf *error_buf = &GIT_GLOBAL->error_buf; memset(state, 0, sizeof(git_error_state)); if (!error_code) return 0; state->error_code = error_code; state->oom = (error == &g_git_oom_error); if (error) { state->error_msg.klass = error->klass; if (state->oom) state->error_msg.message = g_git_oom_error.message; else state->error_msg.message = git_buf_detach(error_buf); } giterr_clear(); return error_code; } int giterr_state_restore(git_error_state *state) { int ret = 0; giterr_clear(); if (state && state->error_msg.message) { if (state->oom) giterr_set_oom(); else set_error(state->error_msg.klass, state->error_msg.message); ret = state->error_code; memset(state, 0, sizeof(git_error_state)); } return ret; } void giterr_state_free(git_error_state *state) { if (!state) return; if (!state->oom) git__free(state->error_msg.message); memset(state, 0, sizeof(git_error_state)); } int giterr_system_last(void) { #ifdef GIT_WIN32 return GetLastError(); #else return errno; #endif } void giterr_system_set(int code) { #ifdef GIT_WIN32 SetLastError(code); #else errno = code; #endif } deps/libgit2-sys-0.3.8/libgit2/src/mwindow.h0000664000175000017500000000301612426525445015540 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_mwindow__ #define INCLUDE_mwindow__ #include "map.h" #include "vector.h" typedef struct git_mwindow { struct git_mwindow *next; git_map window_map; git_off_t offset; size_t last_used; size_t inuse_cnt; } git_mwindow; typedef struct git_mwindow_file { git_mwindow *windows; int fd; git_off_t size; } git_mwindow_file; typedef struct git_mwindow_ctl { size_t mapped; unsigned int open_windows; unsigned int mmap_calls; unsigned int peak_open_windows; size_t peak_mapped; size_t used_ctr; git_vector windowfiles; } git_mwindow_ctl; int git_mwindow_contains(git_mwindow *win, git_off_t offset); void git_mwindow_free_all(git_mwindow_file *mwf); /* locks */ void git_mwindow_free_all_locked(git_mwindow_file *mwf); /* run under lock */ unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor, git_off_t offset, size_t extra, unsigned int *left); int git_mwindow_file_register(git_mwindow_file *mwf); void git_mwindow_file_deregister(git_mwindow_file *mwf); void git_mwindow_close(git_mwindow **w_cursor); int git_mwindow_files_init(void); void git_mwindow_files_free(void); struct git_pack_file; /* just declaration to avoid cyclical includes */ int git_mwindow_get_pack(struct git_pack_file **out, const char *path); void git_mwindow_put_pack(struct git_pack_file *pack); #endif deps/libgit2-sys-0.3.8/libgit2/src/pqueue.h0000664000175000017500000000262312426525445015363 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_pqueue_h__ #define INCLUDE_pqueue_h__ #include "vector.h" typedef git_vector git_pqueue; enum { /* flag meaning: don't grow heap, keep highest values only */ GIT_PQUEUE_FIXED_SIZE = (GIT_VECTOR_FLAG_MAX << 1), }; /** * Initialize priority queue * * @param pq The priority queue struct to initialize * @param flags Flags (see above) to control queue behavior * @param init_size The initial queue size * @param cmp The entry priority comparison function * @return 0 on success, <0 on error */ extern int git_pqueue_init( git_pqueue *pq, uint32_t flags, size_t init_size, git_vector_cmp cmp); #define git_pqueue_free git_vector_free #define git_pqueue_clear git_vector_clear #define git_pqueue_size git_vector_length #define git_pqueue_get git_vector_get /** * Insert a new item into the queue * * @param pq The priority queue * @param item Pointer to the item data * @return 0 on success, <0 on failure */ extern int git_pqueue_insert(git_pqueue *pq, void *item); /** * Remove the top item in the priority queue * * @param pq The priority queue * @return item from heap on success, NULL if queue is empty */ extern void *git_pqueue_pop(git_pqueue *pq); #endif deps/libgit2-sys-0.3.8/libgit2/src/buf_text.c0000664000175000017500000001527112555730137015674 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "buf_text.h" int git_buf_text_puts_escaped( git_buf *buf, const char *string, const char *esc_chars, const char *esc_with) { const char *scan; size_t total = 0, esc_len = strlen(esc_with), count, alloclen; if (!string) return 0; for (scan = string; *scan; ) { /* count run of non-escaped characters */ count = strcspn(scan, esc_chars); total += count; scan += count; /* count run of escaped characters */ count = strspn(scan, esc_chars); total += count * (esc_len + 1); scan += count; } GITERR_CHECK_ALLOC_ADD(&alloclen, total, 1); if (git_buf_grow_by(buf, alloclen) < 0) return -1; for (scan = string; *scan; ) { count = strcspn(scan, esc_chars); memmove(buf->ptr + buf->size, scan, count); scan += count; buf->size += count; for (count = strspn(scan, esc_chars); count > 0; --count) { /* copy escape sequence */ memmove(buf->ptr + buf->size, esc_with, esc_len); buf->size += esc_len; /* copy character to be escaped */ buf->ptr[buf->size] = *scan; buf->size++; scan++; } } buf->ptr[buf->size] = '\0'; return 0; } void git_buf_text_unescape(git_buf *buf) { buf->size = git__unescape(buf->ptr); } int git_buf_text_crlf_to_lf(git_buf *tgt, const git_buf *src) { const char *scan = src->ptr; const char *scan_end = src->ptr + src->size; const char *next = memchr(scan, '\r', src->size); size_t new_size; char *out; assert(tgt != src); if (!next) return git_buf_set(tgt, src->ptr, src->size); /* reduce reallocs while in the loop */ GITERR_CHECK_ALLOC_ADD(&new_size, src->size, 1); if (git_buf_grow(tgt, new_size) < 0) return -1; out = tgt->ptr; tgt->size = 0; /* Find the next \r and copy whole chunk up to there to tgt */ for (; next; scan = next + 1, next = memchr(scan, '\r', scan_end - scan)) { if (next > scan) { size_t copylen = (size_t)(next - scan); memcpy(out, scan, copylen); out += copylen; } /* Do not drop \r unless it is followed by \n */ if (next + 1 == scan_end || next[1] != '\n') *out++ = '\r'; } /* Copy remaining input into dest */ if (scan < scan_end) { size_t remaining = (size_t)(scan_end - scan); memcpy(out, scan, remaining); out += remaining; } tgt->size = (size_t)(out - tgt->ptr); tgt->ptr[tgt->size] = '\0'; return 0; } int git_buf_text_lf_to_crlf(git_buf *tgt, const git_buf *src) { const char *start = src->ptr; const char *end = start + src->size; const char *scan = start; const char *next = memchr(scan, '\n', src->size); size_t alloclen; assert(tgt != src); if (!next) return git_buf_set(tgt, src->ptr, src->size); /* attempt to reduce reallocs while in the loop */ GITERR_CHECK_ALLOC_ADD(&alloclen, src->size, src->size >> 4); GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); if (git_buf_grow(tgt, alloclen) < 0) return -1; tgt->size = 0; for (; next; scan = next + 1, next = memchr(scan, '\n', end - scan)) { size_t copylen = next - scan; /* if we find mixed line endings, carry on */ if (copylen && next[-1] == '\r') copylen--; GITERR_CHECK_ALLOC_ADD(&alloclen, copylen, 3); if (git_buf_grow_by(tgt, alloclen) < 0) return -1; if (copylen) { memcpy(tgt->ptr + tgt->size, scan, copylen); tgt->size += copylen; } tgt->ptr[tgt->size++] = '\r'; tgt->ptr[tgt->size++] = '\n'; } tgt->ptr[tgt->size] = '\0'; return git_buf_put(tgt, scan, end - scan); } int git_buf_text_common_prefix(git_buf *buf, const git_strarray *strings) { size_t i; const char *str, *pfx; git_buf_clear(buf); if (!strings || !strings->count) return 0; /* initialize common prefix to first string */ if (git_buf_sets(buf, strings->strings[0]) < 0) return -1; /* go through the rest of the strings, truncating to shared prefix */ for (i = 1; i < strings->count; ++i) { for (str = strings->strings[i], pfx = buf->ptr; *str && *str == *pfx; str++, pfx++) /* scanning */; git_buf_truncate(buf, pfx - buf->ptr); if (!buf->size) break; } return 0; } bool git_buf_text_is_binary(const git_buf *buf) { const char *scan = buf->ptr, *end = buf->ptr + buf->size; git_bom_t bom; int printable = 0, nonprintable = 0; scan += git_buf_text_detect_bom(&bom, buf, 0); if (bom > GIT_BOM_UTF8) return 1; while (scan < end) { unsigned char c = *scan++; /* Printable characters are those above SPACE (0x1F) excluding DEL, * and including BS, ESC and FF. */ if ((c > 0x1F && c != 127) || c == '\b' || c == '\033' || c == '\014') printable++; else if (c == '\0') return true; else if (!git__isspace(c)) nonprintable++; } return ((printable >> 7) < nonprintable); } bool git_buf_text_contains_nul(const git_buf *buf) { return (memchr(buf->ptr, '\0', buf->size) != NULL); } int git_buf_text_detect_bom(git_bom_t *bom, const git_buf *buf, size_t offset) { const char *ptr; size_t len; *bom = GIT_BOM_NONE; /* need at least 2 bytes after offset to look for any BOM */ if (buf->size < offset + 2) return 0; ptr = buf->ptr + offset; len = buf->size - offset; switch (*ptr++) { case 0: if (len >= 4 && ptr[0] == 0 && ptr[1] == '\xFE' && ptr[2] == '\xFF') { *bom = GIT_BOM_UTF32_BE; return 4; } break; case '\xEF': if (len >= 3 && ptr[0] == '\xBB' && ptr[1] == '\xBF') { *bom = GIT_BOM_UTF8; return 3; } break; case '\xFE': if (*ptr == '\xFF') { *bom = GIT_BOM_UTF16_BE; return 2; } break; case '\xFF': if (*ptr != '\xFE') break; if (len >= 4 && ptr[1] == 0 && ptr[2] == 0) { *bom = GIT_BOM_UTF32_LE; return 4; } else { *bom = GIT_BOM_UTF16_LE; return 2; } break; default: break; } return 0; } bool git_buf_text_gather_stats( git_buf_text_stats *stats, const git_buf *buf, bool skip_bom) { const char *scan = buf->ptr, *end = buf->ptr + buf->size; int skip; memset(stats, 0, sizeof(*stats)); /* BOM detection */ skip = git_buf_text_detect_bom(&stats->bom, buf, 0); if (skip_bom) scan += skip; /* Ignore EOF character */ if (buf->size > 0 && end[-1] == '\032') end--; /* Counting loop */ while (scan < end) { unsigned char c = *scan++; if (c > 0x1F && c != 0x7F) stats->printable++; else switch (c) { case '\0': stats->nul++; stats->nonprintable++; break; case '\n': stats->lf++; break; case '\r': stats->cr++; if (scan < end && *scan == '\n') stats->crlf++; break; case '\t': case '\f': case '\v': case '\b': case 0x1b: /*ESC*/ stats->printable++; break; default: stats->nonprintable++; break; } } return (stats->nul > 0 || ((stats->printable >> 7) < stats->nonprintable)); } deps/libgit2-sys-0.3.8/libgit2/src/sysdir.c0000664000175000017500000001400712572105236015360 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "sysdir.h" #include "global.h" #include "buffer.h" #include "path.h" #include #if GIT_WIN32 #include "win32/findfile.h" #endif static int git_sysdir_guess_system_dirs(git_buf *out) { #ifdef GIT_WIN32 return git_win32__find_system_dirs(out, L"etc\\"); #else return git_buf_sets(out, "/etc"); #endif } static int git_sysdir_guess_global_dirs(git_buf *out) { #ifdef GIT_WIN32 return git_win32__find_global_dirs(out); #else int error = git__getenv(out, "HOME"); if (error == GIT_ENOTFOUND) { giterr_clear(); error = 0; } return error; #endif } static int git_sysdir_guess_xdg_dirs(git_buf *out) { #ifdef GIT_WIN32 return git_win32__find_xdg_dirs(out); #else git_buf env = GIT_BUF_INIT; int error; if ((error = git__getenv(&env, "XDG_CONFIG_HOME")) == 0) error = git_buf_joinpath(out, env.ptr, "git"); if (error == GIT_ENOTFOUND && (error = git__getenv(&env, "HOME")) == 0) error = git_buf_joinpath(out, env.ptr, ".config/git"); if (error == GIT_ENOTFOUND) { giterr_clear(); error = 0; } git_buf_free(&env); return error; #endif } static int git_sysdir_guess_template_dirs(git_buf *out) { #ifdef GIT_WIN32 return git_win32__find_system_dirs(out, L"share\\git-core\\templates"); #else return git_buf_sets(out, "/usr/share/git-core/templates"); #endif } typedef int (*git_sysdir_guess_cb)(git_buf *out); static git_buf git_sysdir__dirs[GIT_SYSDIR__MAX] = { GIT_BUF_INIT, GIT_BUF_INIT, GIT_BUF_INIT, GIT_BUF_INIT }; static git_sysdir_guess_cb git_sysdir__dir_guess[GIT_SYSDIR__MAX] = { git_sysdir_guess_system_dirs, git_sysdir_guess_global_dirs, git_sysdir_guess_xdg_dirs, git_sysdir_guess_template_dirs, }; static int git_sysdir__dirs_shutdown_set = 0; int git_sysdir_global_init(void) { git_sysdir_t i; const git_buf *path; int error = 0; for (i = 0; !error && i < GIT_SYSDIR__MAX; i++) error = git_sysdir_get(&path, i); return error; } void git_sysdir_global_shutdown(void) { int i; for (i = 0; i < GIT_SYSDIR__MAX; ++i) git_buf_free(&git_sysdir__dirs[i]); git_sysdir__dirs_shutdown_set = 0; } static int git_sysdir_check_selector(git_sysdir_t which) { if (which < GIT_SYSDIR__MAX) return 0; giterr_set(GITERR_INVALID, "config directory selector out of range"); return -1; } int git_sysdir_get(const git_buf **out, git_sysdir_t which) { assert(out); *out = NULL; GITERR_CHECK_ERROR(git_sysdir_check_selector(which)); if (!git_buf_len(&git_sysdir__dirs[which])) { /* prepare shutdown if we're going to need it */ if (!git_sysdir__dirs_shutdown_set) { git__on_shutdown(git_sysdir_global_shutdown); git_sysdir__dirs_shutdown_set = 1; } GITERR_CHECK_ERROR( git_sysdir__dir_guess[which](&git_sysdir__dirs[which])); } *out = &git_sysdir__dirs[which]; return 0; } int git_sysdir_get_str( char *out, size_t outlen, git_sysdir_t which) { const git_buf *path = NULL; GITERR_CHECK_ERROR(git_sysdir_check_selector(which)); GITERR_CHECK_ERROR(git_sysdir_get(&path, which)); if (!out || path->size >= outlen) { giterr_set(GITERR_NOMEMORY, "Buffer is too short for the path"); return GIT_EBUFS; } git_buf_copy_cstr(out, outlen, path); return 0; } #define PATH_MAGIC "$PATH" int git_sysdir_set(git_sysdir_t which, const char *search_path) { const char *expand_path = NULL; git_buf merge = GIT_BUF_INIT; GITERR_CHECK_ERROR(git_sysdir_check_selector(which)); if (search_path != NULL) expand_path = strstr(search_path, PATH_MAGIC); /* init with default if not yet done and needed (ignoring error) */ if ((!search_path || expand_path) && !git_buf_len(&git_sysdir__dirs[which])) git_sysdir__dir_guess[which](&git_sysdir__dirs[which]); /* if $PATH is not referenced, then just set the path */ if (!expand_path) return git_buf_sets(&git_sysdir__dirs[which], search_path); /* otherwise set to join(before $PATH, old value, after $PATH) */ if (expand_path > search_path) git_buf_set(&merge, search_path, expand_path - search_path); if (git_buf_len(&git_sysdir__dirs[which])) git_buf_join(&merge, GIT_PATH_LIST_SEPARATOR, merge.ptr, git_sysdir__dirs[which].ptr); expand_path += strlen(PATH_MAGIC); if (*expand_path) git_buf_join(&merge, GIT_PATH_LIST_SEPARATOR, merge.ptr, expand_path); git_buf_swap(&git_sysdir__dirs[which], &merge); git_buf_free(&merge); return git_buf_oom(&git_sysdir__dirs[which]) ? -1 : 0; } static int git_sysdir_find_in_dirlist( git_buf *path, const char *name, git_sysdir_t which, const char *label) { size_t len; const char *scan, *next = NULL; const git_buf *syspath; GITERR_CHECK_ERROR(git_sysdir_get(&syspath, which)); if (!syspath || !git_buf_len(syspath)) goto done; for (scan = git_buf_cstr(syspath); scan; scan = next) { /* find unescaped separator or end of string */ for (next = scan; *next; ++next) { if (*next == GIT_PATH_LIST_SEPARATOR && (next <= scan || next[-1] != '\\')) break; } len = (size_t)(next - scan); next = (*next ? next + 1 : NULL); if (!len) continue; GITERR_CHECK_ERROR(git_buf_set(path, scan, len)); if (name) GITERR_CHECK_ERROR(git_buf_joinpath(path, path->ptr, name)); if (git_path_exists(path->ptr)) return 0; } done: git_buf_free(path); giterr_set(GITERR_OS, "The %s file '%s' doesn't exist", label, name); return GIT_ENOTFOUND; } int git_sysdir_find_system_file(git_buf *path, const char *filename) { return git_sysdir_find_in_dirlist( path, filename, GIT_SYSDIR_SYSTEM, "system"); } int git_sysdir_find_global_file(git_buf *path, const char *filename) { return git_sysdir_find_in_dirlist( path, filename, GIT_SYSDIR_GLOBAL, "global"); } int git_sysdir_find_xdg_file(git_buf *path, const char *filename) { return git_sysdir_find_in_dirlist( path, filename, GIT_SYSDIR_XDG, "global/xdg"); } int git_sysdir_find_template_dir(git_buf *path) { return git_sysdir_find_in_dirlist( path, NULL, GIT_SYSDIR_TEMPLATE, "template"); } deps/libgit2-sys-0.3.8/libgit2/src/unix/0000755000000000000000000000000012666635520016444 5ustar rootrootdeps/libgit2-sys-0.3.8/libgit2/src/unix/realpath.c0000664000175000017500000000122312426525445016630 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include #ifndef GIT_WIN32 #include #include #include #include char *p_realpath(const char *pathname, char *resolved) { char *ret; if ((ret = realpath(pathname, resolved)) == NULL) return NULL; #ifdef __OpenBSD__ /* The OpenBSD realpath function behaves differently, * figure out if the file exists */ if (access(ret, F_OK) < 0) ret = NULL; #endif return ret; } #endif deps/libgit2-sys-0.3.8/libgit2/src/unix/map.c0000664000175000017500000000252112510265101015567 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include #if !defined(GIT_WIN32) && !defined(NO_MMAP) #include "map.h" #include #include #include int git__page_size(size_t *page_size) { long sc_page_size = sysconf(_SC_PAGE_SIZE); if (sc_page_size < 0) { giterr_set_str(GITERR_OS, "Can't determine system page size"); return -1; } *page_size = (size_t) sc_page_size; return 0; } int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset) { int mprot = PROT_READ; int mflag = 0; GIT_MMAP_VALIDATE(out, len, prot, flags); out->data = NULL; out->len = 0; if (prot & GIT_PROT_WRITE) mprot |= PROT_WRITE; if ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED) mflag = MAP_SHARED; else if ((flags & GIT_MAP_TYPE) == GIT_MAP_PRIVATE) mflag = MAP_PRIVATE; else mflag = MAP_SHARED; out->data = mmap(NULL, len, mprot, mflag, fd, offset); if (!out->data || out->data == MAP_FAILED) { giterr_set(GITERR_OS, "Failed to mmap. Could not write data"); return -1; } out->len = len; return 0; } int p_munmap(git_map *map) { assert(map != NULL); munmap(map->data, map->len); return 0; } #endif deps/libgit2-sys-0.3.8/libgit2/src/unix/posix.h0000664000175000017500000000357212610310643016173 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_posix__unix_h__ #define INCLUDE_posix__unix_h__ #include #include #include #include #include typedef int GIT_SOCKET; #define INVALID_SOCKET -1 #define p_lseek(f,n,w) lseek(f, n, w) #define p_fstat(f,b) fstat(f, b) #define p_lstat(p,b) lstat(p,b) #define p_stat(p,b) stat(p, b) #define p_utimes(f, t) utimes(f, t) #define p_readlink(a, b, c) readlink(a, b, c) #define p_symlink(o,n) symlink(o, n) #define p_link(o,n) link(o, n) #define p_unlink(p) unlink(p) #define p_mkdir(p,m) mkdir(p, m) #define p_fsync(fd) fsync(fd) extern char *p_realpath(const char *, char *); #define p_recv(s,b,l,f) recv(s,b,l,f) #define p_send(s,b,l,f) send(s,b,l,f) #define p_inet_pton(a, b, c) inet_pton(a, b, c) #define p_strcasecmp(s1, s2) strcasecmp(s1, s2) #define p_strncasecmp(s1, s2, c) strncasecmp(s1, s2, c) #define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a) #define p_snprintf(b, c, f, ...) snprintf(b, c, f, __VA_ARGS__) #define p_mkstemp(p) mkstemp(p) #define p_chdir(p) chdir(p) #define p_chmod(p,m) chmod(p, m) #define p_rmdir(p) rmdir(p) #define p_access(p,m) access(p,m) #define p_ftruncate(fd, sz) ftruncate(fd, sz) /* see win32/posix.h for explanation about why this exists */ #define p_lstat_posixly(p,b) lstat(p,b) #define p_localtime_r(c, r) localtime_r(c, r) #define p_gmtime_r(c, r) gmtime_r(c, r) #ifdef HAVE_FUTIMENS GIT_INLINE(int) p_futimes(int f, const struct timeval t[2]) { struct timespec s[2]; s[0].tv_sec = t[0].tv_sec; s[0].tv_nsec = t[0].tv_usec * 1000; s[1].tv_sec = t[1].tv_sec; s[1].tv_nsec = t[1].tv_usec * 1000; return futimens(f, s); } #else # define p_futimes futimes #endif #endif deps/libgit2-sys-0.3.8/libgit2/src/curl_stream.c0000664000175000017500000001335012572105236016363 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifdef GIT_CURL #include #include "stream.h" #include "git2/transport.h" #include "buffer.h" #include "vector.h" typedef struct { git_stream parent; CURL *handle; curl_socket_t socket; char curl_error[CURL_ERROR_SIZE + 1]; git_cert_x509 cert_info; git_strarray cert_info_strings; } curl_stream; static int seterr_curl(curl_stream *s) { giterr_set(GITERR_NET, "curl error: %s\n", s->curl_error); return -1; } static int curls_connect(git_stream *stream) { curl_stream *s = (curl_stream *) stream; long sockextr; int failed_cert = 0; CURLcode res; res = curl_easy_perform(s->handle); if (res != CURLE_OK && res != CURLE_PEER_FAILED_VERIFICATION) return seterr_curl(s); if (res == CURLE_PEER_FAILED_VERIFICATION) failed_cert = 1; if ((res = curl_easy_getinfo(s->handle, CURLINFO_LASTSOCKET, &sockextr)) != CURLE_OK) return seterr_curl(s); s->socket = sockextr; if (s->parent.encrypted && failed_cert) return GIT_ECERTIFICATE; return 0; } static int curls_certificate(git_cert **out, git_stream *stream) { int error; CURLcode res; struct curl_slist *slist; struct curl_certinfo *certinfo; git_vector strings = GIT_VECTOR_INIT; curl_stream *s = (curl_stream *) stream; if ((res = curl_easy_getinfo(s->handle, CURLINFO_CERTINFO, &certinfo)) != CURLE_OK) return seterr_curl(s); /* No information is available, can happen with SecureTransport */ if (certinfo->num_of_certs == 0) { s->cert_info.parent.cert_type = GIT_CERT_NONE; s->cert_info.data = NULL; s->cert_info.len = 0; return 0; } if ((error = git_vector_init(&strings, 8, NULL)) < 0) return error; for (slist = certinfo->certinfo[0]; slist; slist = slist->next) { char *str = git__strdup(slist->data); GITERR_CHECK_ALLOC(str); } /* Copy the contents of the vector into a strarray so we can expose them */ s->cert_info_strings.strings = (char **) strings.contents; s->cert_info_strings.count = strings.length; s->cert_info.parent.cert_type = GIT_CERT_STRARRAY; s->cert_info.data = &s->cert_info_strings; s->cert_info.len = strings.length; *out = &s->cert_info.parent; return 0; } static int curls_set_proxy(git_stream *stream, const char *proxy_url) { CURLcode res; curl_stream *s = (curl_stream *) stream; if ((res = curl_easy_setopt(s->handle, CURLOPT_PROXY, proxy_url)) != CURLE_OK) return seterr_curl(s); return 0; } static int wait_for(curl_socket_t fd, bool reading) { int ret; fd_set infd, outfd, errfd; FD_ZERO(&infd); FD_ZERO(&outfd); FD_ZERO(&errfd); FD_SET(fd, &errfd); if (reading) FD_SET(fd, &infd); else FD_SET(fd, &outfd); if ((ret = select(fd + 1, &infd, &outfd, &errfd, NULL)) < 0) { giterr_set(GITERR_OS, "error in select"); return -1; } return 0; } static ssize_t curls_write(git_stream *stream, const char *data, size_t len, int flags) { int error; size_t off = 0, sent; CURLcode res; curl_stream *s = (curl_stream *) stream; GIT_UNUSED(flags); do { if ((error = wait_for(s->socket, false)) < 0) return error; res = curl_easy_send(s->handle, data + off, len - off, &sent); if (res == CURLE_OK) off += sent; } while ((res == CURLE_OK || res == CURLE_AGAIN) && off < len); if (res != CURLE_OK) return seterr_curl(s); return len; } static ssize_t curls_read(git_stream *stream, void *data, size_t len) { int error; size_t read; CURLcode res; curl_stream *s = (curl_stream *) stream; do { if ((error = wait_for(s->socket, true)) < 0) return error; res = curl_easy_recv(s->handle, data, len, &read); } while (res == CURLE_AGAIN); if (res != CURLE_OK) return seterr_curl(s); return read; } static int curls_close(git_stream *stream) { curl_stream *s = (curl_stream *) stream; if (!s->handle) return 0; curl_easy_cleanup(s->handle); s->handle = NULL; s->socket = 0; return 0; } static void curls_free(git_stream *stream) { curl_stream *s = (curl_stream *) stream; curls_close(stream); git_strarray_free(&s->cert_info_strings); git__free(s); } int git_curl_stream_new(git_stream **out, const char *host, const char *port) { curl_stream *st; CURL *handle; int iport = 0, error; st = git__calloc(1, sizeof(curl_stream)); GITERR_CHECK_ALLOC(st); handle = curl_easy_init(); if (handle == NULL) { giterr_set(GITERR_NET, "failed to create curl handle"); return -1; } if ((error = git__strtol32(&iport, port, NULL, 10)) < 0) return error; curl_easy_setopt(handle, CURLOPT_URL, host); curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, st->curl_error); curl_easy_setopt(handle, CURLOPT_PORT, iport); curl_easy_setopt(handle, CURLOPT_CONNECT_ONLY, 1); curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 1); curl_easy_setopt(handle, CURLOPT_CERTINFO, 1); curl_easy_setopt(handle, CURLOPT_HTTPPROXYTUNNEL, 1); curl_easy_setopt(handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY); /* curl_easy_setopt(handle, CURLOPT_VERBOSE, 1); */ st->parent.version = GIT_STREAM_VERSION; st->parent.encrypted = 0; /* we don't encrypt ourselves */ st->parent.proxy_support = 1; st->parent.connect = curls_connect; st->parent.certificate = curls_certificate; st->parent.set_proxy = curls_set_proxy; st->parent.read = curls_read; st->parent.write = curls_write; st->parent.close = curls_close; st->parent.free = curls_free; st->handle = handle; *out = (git_stream *) st; return 0; } #else #include "stream.h" int git_curl_stream_new(git_stream **out, const char *host, const char *port) { GIT_UNUSED(out); GIT_UNUSED(host); GIT_UNUSED(port); giterr_set(GITERR_NET, "curl is not supported in this version"); return -1; } #endif deps/libgit2-sys-0.3.8/libgit2/src/delta-apply.h0000664000175000017500000000301512426525445016267 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_delta_apply_h__ #define INCLUDE_delta_apply_h__ #include "odb.h" /** * Apply a git binary delta to recover the original content. * * @param out the output buffer to receive the original data. * Only out->data and out->len are populated, as this is * the only information available in the delta. * @param base the base to copy from during copy instructions. * @param base_len number of bytes available at base. * @param delta the delta to execute copy/insert instructions from. * @param delta_len total number of bytes in the delta. * @return * - 0 on a successful delta unpack. * - GIT_ERROR if the delta is corrupt or doesn't match the base. */ extern int git__delta_apply( git_rawobj *out, const unsigned char *base, size_t base_len, const unsigned char *delta, size_t delta_len); /** * Read the header of a git binary delta. * * @param delta the delta to execute copy/insert instructions from. * @param delta_len total number of bytes in the delta. * @param base_sz pointer to store the base size field. * @param res_sz pointer to store the result size field. * @return * - 0 on a successful decoding the header. * - GIT_ERROR if the delta is corrupt. */ extern int git__delta_read_header( const unsigned char *delta, size_t delta_len, size_t *base_sz, size_t *res_sz); #endif deps/libgit2-sys-0.3.8/libgit2/src/filebuf.h0000664000175000017500000000531612572105236015467 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_filebuf_h__ #define INCLUDE_filebuf_h__ #include "fileops.h" #include "hash.h" #include #ifdef GIT_THREADS # define GIT_FILEBUF_THREADS #endif #define GIT_FILEBUF_HASH_CONTENTS (1 << 0) #define GIT_FILEBUF_APPEND (1 << 2) #define GIT_FILEBUF_FORCE (1 << 3) #define GIT_FILEBUF_TEMPORARY (1 << 4) #define GIT_FILEBUF_DO_NOT_BUFFER (1 << 5) #define GIT_FILEBUF_DEFLATE_SHIFT (6) #define GIT_FILELOCK_EXTENSION ".lock\0" #define GIT_FILELOCK_EXTLENGTH 6 typedef struct git_filebuf git_filebuf; struct git_filebuf { char *path_original; char *path_lock; int (*write)(git_filebuf *file, void *source, size_t len); bool compute_digest; git_hash_ctx digest; unsigned char *buffer; unsigned char *z_buf; z_stream zs; int flush_mode; size_t buf_size, buf_pos; git_file fd; bool fd_is_open; bool created_lock; bool did_rename; bool do_not_buffer; int last_error; }; #define GIT_FILEBUF_INIT {0} /* * The git_filebuf object lifecycle is: * - Allocate git_filebuf, preferably using GIT_FILEBUF_INIT. * * - Call git_filebuf_open() to initialize the filebuf for use. * * - Make as many calls to git_filebuf_write(), git_filebuf_printf(), * git_filebuf_reserve() as you like. The error codes for these * functions don't need to be checked. They are stored internally * by the file buffer. * * - While you are writing, you may call git_filebuf_hash() to get * the hash of all you have written so far. This function will * fail if any of the previous writes to the buffer failed. * * - To close the git_filebuf, you may call git_filebuf_commit() or * git_filebuf_commit_at() to save the file, or * git_filebuf_cleanup() to abandon the file. All of these will * free the git_filebuf object. Likewise, all of these will fail * if any of the previous writes to the buffer failed, and set * an error code accordingly. */ int git_filebuf_write(git_filebuf *lock, const void *buff, size_t len); int git_filebuf_reserve(git_filebuf *file, void **buff, size_t len); int git_filebuf_printf(git_filebuf *file, const char *format, ...) GIT_FORMAT_PRINTF(2, 3); int git_filebuf_open(git_filebuf *lock, const char *path, int flags, mode_t mode); int git_filebuf_commit(git_filebuf *lock); int git_filebuf_commit_at(git_filebuf *lock, const char *path); void git_filebuf_cleanup(git_filebuf *lock); int git_filebuf_hash(git_oid *oid, git_filebuf *file); int git_filebuf_flush(git_filebuf *file); int git_filebuf_stats(time_t *mtime, size_t *size, git_filebuf *file); #endif deps/libgit2-sys-0.3.8/libgit2/src/stream.h0000664000175000017500000000264612555730137015356 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_stream_h__ #define INCLUDE_stream_h__ #include "common.h" #include "git2/sys/stream.h" GIT_INLINE(int) git_stream_connect(git_stream *st) { return st->connect(st); } GIT_INLINE(int) git_stream_is_encrypted(git_stream *st) { return st->encrypted; } GIT_INLINE(int) git_stream_certificate(git_cert **out, git_stream *st) { if (!st->encrypted) { giterr_set(GITERR_INVALID, "an unencrypted stream does not have a certificate"); return -1; } return st->certificate(out, st); } GIT_INLINE(int) git_stream_supports_proxy(git_stream *st) { return st->proxy_support; } GIT_INLINE(int) git_stream_set_proxy(git_stream *st, const char *proxy_url) { if (!st->proxy_support) { giterr_set(GITERR_INVALID, "proxy not supported on this stream"); return -1; } return st->set_proxy(st, proxy_url); } GIT_INLINE(ssize_t) git_stream_read(git_stream *st, void *data, size_t len) { return st->read(st, data, len); } GIT_INLINE(ssize_t) git_stream_write(git_stream *st, const char *data, size_t len, int flags) { return st->write(st, data, len, flags); } GIT_INLINE(int) git_stream_close(git_stream *st) { return st->close(st); } GIT_INLINE(void) git_stream_free(git_stream *st) { st->free(st); } #endif deps/libgit2-sys-0.3.8/libgit2/src/array.h0000664000175000017500000000425712510265101015162 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_array_h__ #define INCLUDE_array_h__ #include "common.h" /* * Use this to declare a typesafe resizable array of items, a la: * * git_array_t(int) my_ints = GIT_ARRAY_INIT; * ... * int *i = git_array_alloc(my_ints); * GITERR_CHECK_ALLOC(i); * ... * git_array_clear(my_ints); * * You may also want to do things like: * * typedef git_array_t(my_struct) my_struct_array_t; */ #define git_array_t(type) struct { type *ptr; size_t size, asize; } #define GIT_ARRAY_INIT { NULL, 0, 0 } #define git_array_init(a) \ do { (a).size = (a).asize = 0; (a).ptr = NULL; } while (0) #define git_array_init_to_size(a, desired) \ do { (a).size = 0; (a).asize = desired; (a).ptr = git__calloc(desired, sizeof(*(a).ptr)); } while (0) #define git_array_clear(a) \ do { git__free((a).ptr); git_array_init(a); } while (0) #define GITERR_CHECK_ARRAY(a) GITERR_CHECK_ALLOC((a).ptr) typedef git_array_t(char) git_array_generic_t; /* use a generic array for growth so this can return the new item */ GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size) { volatile git_array_generic_t *a = _a; size_t new_size; char *new_array; if (a->size < 8) { new_size = 8; } else { if (GIT_MULTIPLY_SIZET_OVERFLOW(&new_size, a->size, 3)) goto on_oom; new_size /= 2; } if ((new_array = git__reallocarray(a->ptr, new_size, item_size)) == NULL) goto on_oom; a->ptr = new_array; a->asize = new_size; a->size++; return a->ptr + (a->size - 1) * item_size; on_oom: git_array_clear(*a); return NULL; } #define git_array_alloc(a) \ (((a).size >= (a).asize) ? \ git_array_grow(&(a), sizeof(*(a).ptr)) : \ ((a).ptr ? &(a).ptr[(a).size++] : NULL)) #define git_array_last(a) ((a).size ? &(a).ptr[(a).size - 1] : NULL) #define git_array_pop(a) ((a).size ? &(a).ptr[--(a).size] : NULL) #define git_array_get(a, i) (((i) < (a).size) ? &(a).ptr[(i)] : NULL) #define git_array_size(a) (a).size #define git_array_valid_index(a, i) ((i) < (a).size) #endif deps/libgit2-sys-0.3.8/libgit2/src/tree-cache.c0000664000175000017500000001421412510265101016031 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "tree-cache.h" #include "pool.h" #include "tree.h" static git_tree_cache *find_child( const git_tree_cache *tree, const char *path, const char *end) { size_t i, dirlen = end ? (size_t)(end - path) : strlen(path); for (i = 0; i < tree->children_count; ++i) { git_tree_cache *child = tree->children[i]; if (child->namelen == dirlen && !memcmp(path, child->name, dirlen)) return child; } return NULL; } void git_tree_cache_invalidate_path(git_tree_cache *tree, const char *path) { const char *ptr = path, *end; if (tree == NULL) return; tree->entry_count = -1; while (ptr != NULL) { end = strchr(ptr, '/'); if (end == NULL) /* End of path */ break; tree = find_child(tree, ptr, end); if (tree == NULL) /* We don't have that tree */ return; tree->entry_count = -1; ptr = end + 1; } } const git_tree_cache *git_tree_cache_get(const git_tree_cache *tree, const char *path) { const char *ptr = path, *end; if (tree == NULL) { return NULL; } while (1) { end = strchr(ptr, '/'); tree = find_child(tree, ptr, end); if (tree == NULL) /* Can't find it */ return NULL; if (end == NULL || *end + 1 == '\0') return tree; ptr = end + 1; } } static int read_tree_internal(git_tree_cache **out, const char **buffer_in, const char *buffer_end, git_pool *pool) { git_tree_cache *tree = NULL; const char *name_start, *buffer; int count; buffer = name_start = *buffer_in; if ((buffer = memchr(buffer, '\0', buffer_end - buffer)) == NULL) goto corrupted; if (++buffer >= buffer_end) goto corrupted; if (git_tree_cache_new(&tree, name_start, pool) < 0) return -1; /* Blank-terminated ASCII decimal number of entries in this tree */ if (git__strtol32(&count, buffer, &buffer, 10) < 0) goto corrupted; tree->entry_count = count; if (*buffer != ' ' || ++buffer >= buffer_end) goto corrupted; /* Number of children of the tree, newline-terminated */ if (git__strtol32(&count, buffer, &buffer, 10) < 0 || count < 0) goto corrupted; tree->children_count = count; if (*buffer != '\n' || ++buffer > buffer_end) goto corrupted; /* The SHA1 is only there if it's not invalidated */ if (tree->entry_count >= 0) { /* 160-bit SHA-1 for this tree and it's children */ if (buffer + GIT_OID_RAWSZ > buffer_end) goto corrupted; git_oid_fromraw(&tree->oid, (const unsigned char *)buffer); buffer += GIT_OID_RAWSZ; } /* Parse children: */ if (tree->children_count > 0) { unsigned int i; tree->children = git_pool_malloc(pool, tree->children_count * sizeof(git_tree_cache *)); GITERR_CHECK_ALLOC(tree->children); memset(tree->children, 0x0, tree->children_count * sizeof(git_tree_cache *)); for (i = 0; i < tree->children_count; ++i) { if (read_tree_internal(&tree->children[i], &buffer, buffer_end, pool) < 0) goto corrupted; } } *buffer_in = buffer; *out = tree; return 0; corrupted: giterr_set(GITERR_INDEX, "Corrupted TREE extension in index"); return -1; } int git_tree_cache_read(git_tree_cache **tree, const char *buffer, size_t buffer_size, git_pool *pool) { const char *buffer_end = buffer + buffer_size; if (read_tree_internal(tree, &buffer, buffer_end, pool) < 0) return -1; if (buffer < buffer_end) { giterr_set(GITERR_INDEX, "Corrupted TREE extension in index (unexpected trailing data)"); return -1; } return 0; } static int read_tree_recursive(git_tree_cache *cache, const git_tree *tree, git_pool *pool) { git_repository *repo; size_t i, j, nentries, ntrees; int error; repo = git_tree_owner(tree); git_oid_cpy(&cache->oid, git_tree_id(tree)); nentries = git_tree_entrycount(tree); /* * We make sure we know how many trees we need to allocate for * so we don't have to realloc and change the pointers for the * parents. */ ntrees = 0; for (i = 0; i < nentries; i++) { const git_tree_entry *entry; entry = git_tree_entry_byindex(tree, i); if (git_tree_entry_filemode(entry) == GIT_FILEMODE_TREE) ntrees++; } cache->children_count = ntrees; cache->children = git_pool_mallocz(pool, ntrees * sizeof(git_tree_cache *)); GITERR_CHECK_ALLOC(cache->children); j = 0; for (i = 0; i < nentries; i++) { const git_tree_entry *entry; git_tree *subtree; entry = git_tree_entry_byindex(tree, i); if (git_tree_entry_filemode(entry) != GIT_FILEMODE_TREE) { cache->entry_count++; continue; } if ((error = git_tree_cache_new(&cache->children[j], git_tree_entry_name(entry), pool)) < 0) return error; if ((error = git_tree_lookup(&subtree, repo, git_tree_entry_id(entry))) < 0) return error; error = read_tree_recursive(cache->children[j], subtree, pool); git_tree_free(subtree); cache->entry_count += cache->children[j]->entry_count; j++; if (error < 0) return error; } return 0; } int git_tree_cache_read_tree(git_tree_cache **out, const git_tree *tree, git_pool *pool) { int error; git_tree_cache *cache; if ((error = git_tree_cache_new(&cache, "", pool)) < 0) return error; if ((error = read_tree_recursive(cache, tree, pool)) < 0) return error; *out = cache; return 0; } int git_tree_cache_new(git_tree_cache **out, const char *name, git_pool *pool) { size_t name_len; git_tree_cache *tree; name_len = strlen(name); tree = git_pool_malloc(pool, sizeof(git_tree_cache) + name_len + 1); GITERR_CHECK_ALLOC(tree); memset(tree, 0x0, sizeof(git_tree_cache)); /* NUL-terminated tree name */ tree->namelen = name_len; memcpy(tree->name, name, name_len); tree->name[name_len] = '\0'; *out = tree; return 0; } static void write_tree(git_buf *out, git_tree_cache *tree) { size_t i; git_buf_printf(out, "%s%c%"PRIdZ" %"PRIuZ"\n", tree->name, 0, tree->entry_count, tree->children_count); if (tree->entry_count != -1) git_buf_put(out, (const char *) &tree->oid, GIT_OID_RAWSZ); for (i = 0; i < tree->children_count; i++) write_tree(out, tree->children[i]); } int git_tree_cache_write(git_buf *out, git_tree_cache *tree) { write_tree(out, tree); return git_buf_oom(out) ? -1 : 0; } deps/libgit2-sys-0.3.8/libgit2/src/attr.h0000664000175000017500000000050012426525445015021 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_attr_h__ #define INCLUDE_attr_h__ #include "attr_file.h" #include "attrcache.h" #endif deps/libgit2-sys-0.3.8/libgit2/src/iterator.h0000664000175000017500000002300112572105236015673 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_iterator_h__ #define INCLUDE_iterator_h__ #include "common.h" #include "git2/index.h" #include "vector.h" #include "buffer.h" #include "ignore.h" typedef struct git_iterator git_iterator; typedef enum { GIT_ITERATOR_TYPE_EMPTY = 0, GIT_ITERATOR_TYPE_TREE = 1, GIT_ITERATOR_TYPE_INDEX = 2, GIT_ITERATOR_TYPE_WORKDIR = 3, GIT_ITERATOR_TYPE_FS = 4, } git_iterator_type_t; typedef enum { /** ignore case for entry sort order */ GIT_ITERATOR_IGNORE_CASE = (1u << 0), /** force case sensitivity for entry sort order */ GIT_ITERATOR_DONT_IGNORE_CASE = (1u << 1), /** return tree items in addition to blob items */ GIT_ITERATOR_INCLUDE_TREES = (1u << 2), /** don't flatten trees, requiring advance_into (implies INCLUDE_TREES) */ GIT_ITERATOR_DONT_AUTOEXPAND = (1u << 3), /** convert precomposed unicode to decomposed unicode */ GIT_ITERATOR_PRECOMPOSE_UNICODE = (1u << 4), /** include conflicts */ GIT_ITERATOR_INCLUDE_CONFLICTS = (1u << 5), } git_iterator_flag_t; typedef struct { const char *start; const char *end; /* paths to include in the iterator (literal). if set, any paths not * listed here will be excluded from iteration. */ git_strarray pathlist; /* flags, from above */ unsigned int flags; } git_iterator_options; #define GIT_ITERATOR_OPTIONS_INIT {0} typedef struct { int (*current)(const git_index_entry **, git_iterator *); int (*advance)(const git_index_entry **, git_iterator *); int (*advance_into)(const git_index_entry **, git_iterator *); int (*seek)(git_iterator *, const char *prefix); int (*reset)(git_iterator *, const char *start, const char *end); int (*at_end)(git_iterator *); void (*free)(git_iterator *); } git_iterator_callbacks; struct git_iterator { git_iterator_type_t type; git_iterator_callbacks *cb; git_repository *repo; char *start; char *end; git_vector pathlist; size_t pathlist_walk_idx; int (*strcomp)(const char *a, const char *b); int (*strncomp)(const char *a, const char *b, size_t n); int (*prefixcomp)(const char *str, const char *prefix); size_t stat_calls; unsigned int flags; }; extern int git_iterator_for_nothing( git_iterator **out, git_iterator_options *options); /* tree iterators will match the ignore_case value from the index of the * repository, unless you override with a non-zero flag value */ extern int git_iterator_for_tree( git_iterator **out, git_tree *tree, git_iterator_options *options); /* index iterators will take the ignore_case value from the index; the * ignore_case flags are not used */ extern int git_iterator_for_index( git_iterator **out, git_index *index, git_iterator_options *options); extern int git_iterator_for_workdir_ext( git_iterator **out, git_repository *repo, const char *repo_workdir, git_index *index, git_tree *tree, git_iterator_options *options); /* workdir iterators will match the ignore_case value from the index of the * repository, unless you override with a non-zero flag value */ GIT_INLINE(int) git_iterator_for_workdir( git_iterator **out, git_repository *repo, git_index *index, git_tree *tree, git_iterator_options *options) { return git_iterator_for_workdir_ext(out, repo, NULL, index, tree, options); } /* for filesystem iterators, you have to explicitly pass in the ignore_case * behavior that you desire */ extern int git_iterator_for_filesystem( git_iterator **out, const char *root, git_iterator_options *options); extern void git_iterator_free(git_iterator *iter); /* Return a git_index_entry structure for the current value the iterator * is looking at or NULL if the iterator is at the end. * * The entry may noy be fully populated. Tree iterators will only have a * value mode, OID, and path. Workdir iterators will not have an OID (but * you can use `git_iterator_current_oid()` to calculate it on demand). * * You do not need to free the entry. It is still "owned" by the iterator. * Once you call `git_iterator_advance()` then the old entry is no longer * guaranteed to be valid - it may be freed or just overwritten in place. */ GIT_INLINE(int) git_iterator_current( const git_index_entry **entry, git_iterator *iter) { return iter->cb->current(entry, iter); } /** * Advance to the next item for the iterator. * * If GIT_ITERATOR_INCLUDE_TREES is set, this may be a tree item. If * GIT_ITERATOR_DONT_AUTOEXPAND is set, calling this again when on a tree * item will skip over all the items under that tree. */ GIT_INLINE(int) git_iterator_advance( const git_index_entry **entry, git_iterator *iter) { return iter->cb->advance(entry, iter); } /** * Iterate into a tree item (when GIT_ITERATOR_DONT_AUTOEXPAND is set). * * git_iterator_advance() steps through all items being iterated over * (either with or without trees, depending on GIT_ITERATOR_INCLUDE_TREES), * but if GIT_ITERATOR_DONT_AUTOEXPAND is set, it will skip to the next * sibling of a tree instead of going to the first child of the tree. In * that case, use this function to advance to the first child of the tree. * * If the current item is not a tree, this is a no-op. * * For filesystem and working directory iterators, a tree (i.e. directory) * can be empty. In that case, this function returns GIT_ENOTFOUND and * does not advance. That can't happen for tree and index iterators. */ GIT_INLINE(int) git_iterator_advance_into( const git_index_entry **entry, git_iterator *iter) { return iter->cb->advance_into(entry, iter); } /** * Advance into a tree or skip over it if it is empty. * * Because `git_iterator_advance_into` may return GIT_ENOTFOUND if the * directory is empty (only with filesystem and working directory * iterators) and a common response is to just call `git_iterator_advance` * when that happens, this bundles the two into a single simple call. */ GIT_INLINE(int) git_iterator_advance_into_or_over( const git_index_entry **entry, git_iterator *iter) { int error = iter->cb->advance_into(entry, iter); if (error == GIT_ENOTFOUND) { giterr_clear(); error = iter->cb->advance(entry, iter); } return error; } /* Seek is currently unimplemented */ GIT_INLINE(int) git_iterator_seek( git_iterator *iter, const char *prefix) { return iter->cb->seek(iter, prefix); } /** * Go back to the start of the iteration. * * This resets the iterator to the start of the iteration. It also allows * you to reset the `start` and `end` pathname boundaries of the iteration * when doing so. */ GIT_INLINE(int) git_iterator_reset( git_iterator *iter, const char *start, const char *end) { return iter->cb->reset(iter, start, end); } /** * Check if the iterator is at the end * * @return 0 if not at end, >0 if at end */ GIT_INLINE(int) git_iterator_at_end(git_iterator *iter) { return iter->cb->at_end(iter); } GIT_INLINE(git_iterator_type_t) git_iterator_type(git_iterator *iter) { return iter->type; } GIT_INLINE(git_repository *) git_iterator_owner(git_iterator *iter) { return iter->repo; } GIT_INLINE(git_iterator_flag_t) git_iterator_flags(git_iterator *iter) { return iter->flags; } GIT_INLINE(bool) git_iterator_ignore_case(git_iterator *iter) { return ((iter->flags & GIT_ITERATOR_IGNORE_CASE) != 0); } extern int git_iterator_set_ignore_case(git_iterator *iter, bool ignore_case); extern int git_iterator_current_tree_entry( const git_tree_entry **entry_out, git_iterator *iter); extern int git_iterator_current_parent_tree( const git_tree **tree_out, git_iterator *iter, const char *parent_path); extern bool git_iterator_current_is_ignored(git_iterator *iter); extern bool git_iterator_current_tree_is_ignored(git_iterator *iter); extern int git_iterator_cmp( git_iterator *iter, const char *path_prefix); /** * Get full path of the current item from a workdir iterator. This will * return NULL for a non-workdir iterator. The git_buf is still owned by * the iterator; this is exposed just for efficiency. */ extern int git_iterator_current_workdir_path( git_buf **path, git_iterator *iter); /* Return index pointer if index iterator, else NULL */ extern git_index *git_iterator_get_index(git_iterator *iter); typedef enum { GIT_ITERATOR_STATUS_NORMAL = 0, GIT_ITERATOR_STATUS_IGNORED = 1, GIT_ITERATOR_STATUS_EMPTY = 2, GIT_ITERATOR_STATUS_FILTERED = 3 } git_iterator_status_t; /* Advance over a directory and check if it contains no files or just * ignored files. * * In a tree or the index, all directories will contain files, but in the * working directory it is possible to have an empty directory tree or a * tree that only contains ignored files. Many Git operations treat these * cases specially. This advances over a directory (presumably an * untracked directory) but checks during the scan if there are any files * and any non-ignored files. */ extern int git_iterator_advance_over_with_status( const git_index_entry **entry, git_iterator_status_t *status, git_iterator *iter); /** * Retrieve the index stored in the iterator. * * Only implemented for the workdir iterator */ extern int git_iterator_index(git_index **out, git_iterator *iter); typedef int (*git_iterator_walk_cb)( const git_index_entry **entries, void *data); /** * Walk the given iterators in lock-step. The given callback will be * called for each unique path, with the index entry in each iterator * (or NULL if the given iterator does not contain that path). */ extern int git_iterator_walk( git_iterator **iterators, size_t cnt, git_iterator_walk_cb cb, void *data); #endif deps/libgit2-sys-0.3.8/libgit2/src/pathspec.h0000664000175000017500000000364112426525445015667 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_pathspec_h__ #define INCLUDE_pathspec_h__ #include "common.h" #include #include "buffer.h" #include "vector.h" #include "pool.h" #include "array.h" /* public compiled pathspec */ struct git_pathspec { git_refcount rc; char *prefix; git_vector pathspec; git_pool pool; }; enum { PATHSPEC_DATATYPE_STRINGS = 0, PATHSPEC_DATATYPE_DIFF = 1, }; typedef git_array_t(char *) git_pathspec_string_array_t; /* public interface to pathspec matching */ struct git_pathspec_match_list { git_pathspec *pathspec; git_array_t(void *) matches; git_pathspec_string_array_t failures; git_pool pool; int datatype; }; /* what is the common non-wildcard prefix for all items in the pathspec */ extern char *git_pathspec_prefix(const git_strarray *pathspec); /* is there anything in the spec that needs to be filtered on */ extern bool git_pathspec_is_empty(const git_strarray *pathspec); /* build a vector of fnmatch patterns to evaluate efficiently */ extern int git_pathspec__vinit( git_vector *vspec, const git_strarray *strspec, git_pool *strpool); /* free data from the pathspec vector */ extern void git_pathspec__vfree(git_vector *vspec); #define GIT_PATHSPEC_NOMATCH ((size_t)-1) /* * Match a path against the vectorized pathspec. * The matched pathspec is passed back into the `matched_pathspec` parameter, * unless it is passed as NULL by the caller. */ extern bool git_pathspec__match( const git_vector *vspec, const char *path, bool disable_fnmatch, bool casefold, const char **matched_pathspec, size_t *matched_at); /* easy pathspec setup */ extern int git_pathspec__init(git_pathspec *ps, const git_strarray *paths); extern void git_pathspec__clear(git_pathspec *ps); #endif deps/libgit2-sys-0.3.8/libgit2/src/stash.c0000664000175000017500000006377312572105236015203 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "repository.h" #include "commit.h" #include "message.h" #include "tree.h" #include "reflog.h" #include "git2/diff.h" #include "git2/stash.h" #include "git2/status.h" #include "git2/checkout.h" #include "git2/index.h" #include "git2/transaction.h" #include "git2/merge.h" #include "index.h" #include "signature.h" #include "iterator.h" #include "merge.h" #include "diff.h" static int create_error(int error, const char *msg) { giterr_set(GITERR_STASH, "Cannot stash changes - %s", msg); return error; } static int retrieve_head(git_reference **out, git_repository *repo) { int error = git_repository_head(out, repo); if (error == GIT_EUNBORNBRANCH) return create_error(error, "You do not have the initial commit yet."); return error; } static int append_abbreviated_oid(git_buf *out, const git_oid *b_commit) { char *formatted_oid; formatted_oid = git_oid_allocfmt(b_commit); GITERR_CHECK_ALLOC(formatted_oid); git_buf_put(out, formatted_oid, 7); git__free(formatted_oid); return git_buf_oom(out) ? -1 : 0; } static int append_commit_description(git_buf *out, git_commit* commit) { const char *summary = git_commit_summary(commit); GITERR_CHECK_ALLOC(summary); if (append_abbreviated_oid(out, git_commit_id(commit)) < 0) return -1; git_buf_putc(out, ' '); git_buf_puts(out, summary); git_buf_putc(out, '\n'); return git_buf_oom(out) ? -1 : 0; } static int retrieve_base_commit_and_message( git_commit **b_commit, git_buf *stash_message, git_repository *repo) { git_reference *head = NULL; int error; if ((error = retrieve_head(&head, repo)) < 0) return error; if (strcmp("HEAD", git_reference_name(head)) == 0) error = git_buf_puts(stash_message, "(no branch): "); else error = git_buf_printf( stash_message, "%s: ", git_reference_name(head) + strlen(GIT_REFS_HEADS_DIR)); if (error < 0) goto cleanup; if ((error = git_commit_lookup( b_commit, repo, git_reference_target(head))) < 0) goto cleanup; if ((error = append_commit_description(stash_message, *b_commit)) < 0) goto cleanup; cleanup: git_reference_free(head); return error; } static int build_tree_from_index(git_tree **out, git_index *index) { int error; git_oid i_tree_oid; if ((error = git_index_write_tree(&i_tree_oid, index)) < 0) return error; return git_tree_lookup(out, git_index_owner(index), &i_tree_oid); } static int commit_index( git_commit **i_commit, git_index *index, const git_signature *stasher, const char *message, const git_commit *parent) { git_tree *i_tree = NULL; git_oid i_commit_oid; git_buf msg = GIT_BUF_INIT; int error; if ((error = build_tree_from_index(&i_tree, index)) < 0) goto cleanup; if ((error = git_buf_printf(&msg, "index on %s\n", message)) < 0) goto cleanup; if ((error = git_commit_create( &i_commit_oid, git_index_owner(index), NULL, stasher, stasher, NULL, git_buf_cstr(&msg), i_tree, 1, &parent)) < 0) goto cleanup; error = git_commit_lookup(i_commit, git_index_owner(index), &i_commit_oid); cleanup: git_tree_free(i_tree); git_buf_free(&msg); return error; } struct stash_update_rules { bool include_changed; bool include_untracked; bool include_ignored; }; static int stash_update_index_from_diff( git_index *index, const git_diff *diff, struct stash_update_rules *data) { int error = 0; size_t d, max_d = git_diff_num_deltas(diff); for (d = 0; !error && d < max_d; ++d) { const char *add_path = NULL; const git_diff_delta *delta = git_diff_get_delta(diff, d); switch (delta->status) { case GIT_DELTA_IGNORED: if (data->include_ignored) add_path = delta->new_file.path; break; case GIT_DELTA_UNTRACKED: if (data->include_untracked && delta->new_file.mode != GIT_FILEMODE_TREE) add_path = delta->new_file.path; break; case GIT_DELTA_ADDED: case GIT_DELTA_MODIFIED: if (data->include_changed) add_path = delta->new_file.path; break; case GIT_DELTA_DELETED: if (data->include_changed && !git_index_find(NULL, index, delta->old_file.path)) error = git_index_remove(index, delta->old_file.path, 0); break; default: /* Unimplemented */ giterr_set( GITERR_INVALID, "Cannot update index. Unimplemented status (%d)", delta->status); return -1; } if (add_path != NULL) error = git_index_add_bypath(index, add_path); } return error; } static int build_untracked_tree( git_tree **tree_out, git_index *index, git_commit *i_commit, uint32_t flags) { git_tree *i_tree = NULL; git_diff *diff = NULL; git_diff_options opts = GIT_DIFF_OPTIONS_INIT; struct stash_update_rules data = {0}; int error; git_index_clear(index); if (flags & GIT_STASH_INCLUDE_UNTRACKED) { opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_RECURSE_UNTRACKED_DIRS; data.include_untracked = true; } if (flags & GIT_STASH_INCLUDE_IGNORED) { opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_RECURSE_IGNORED_DIRS; data.include_ignored = true; } if ((error = git_commit_tree(&i_tree, i_commit)) < 0) goto cleanup; if ((error = git_diff_tree_to_workdir( &diff, git_index_owner(index), i_tree, &opts)) < 0) goto cleanup; if ((error = stash_update_index_from_diff(index, diff, &data)) < 0) goto cleanup; error = build_tree_from_index(tree_out, index); cleanup: git_diff_free(diff); git_tree_free(i_tree); return error; } static int commit_untracked( git_commit **u_commit, git_index *index, const git_signature *stasher, const char *message, git_commit *i_commit, uint32_t flags) { git_tree *u_tree = NULL; git_oid u_commit_oid; git_buf msg = GIT_BUF_INIT; int error; if ((error = build_untracked_tree(&u_tree, index, i_commit, flags)) < 0) goto cleanup; if ((error = git_buf_printf(&msg, "untracked files on %s\n", message)) < 0) goto cleanup; if ((error = git_commit_create( &u_commit_oid, git_index_owner(index), NULL, stasher, stasher, NULL, git_buf_cstr(&msg), u_tree, 0, NULL)) < 0) goto cleanup; error = git_commit_lookup(u_commit, git_index_owner(index), &u_commit_oid); cleanup: git_tree_free(u_tree); git_buf_free(&msg); return error; } static git_diff_delta *stash_delta_merge( const git_diff_delta *a, const git_diff_delta *b, git_pool *pool) { /* Special case for stash: if a file is deleted in the index, but exists * in the working tree, we need to stash the workdir copy for the workdir. */ if (a->status == GIT_DELTA_DELETED && b->status == GIT_DELTA_UNTRACKED) { git_diff_delta *dup = git_diff__delta_dup(b, pool); if (dup) dup->status = GIT_DELTA_MODIFIED; return dup; } return git_diff__merge_like_cgit(a, b, pool); } static int build_workdir_tree( git_tree **tree_out, git_index *index, git_commit *b_commit) { git_repository *repo = git_index_owner(index); git_tree *b_tree = NULL; git_diff *diff = NULL, *idx_to_wd = NULL; git_diff_options opts = GIT_DIFF_OPTIONS_INIT; struct stash_update_rules data = {0}; int error; opts.flags = GIT_DIFF_IGNORE_SUBMODULES | GIT_DIFF_INCLUDE_UNTRACKED; if ((error = git_commit_tree(&b_tree, b_commit)) < 0) goto cleanup; if ((error = git_diff_tree_to_index(&diff, repo, b_tree, index, &opts)) < 0 || (error = git_diff_index_to_workdir(&idx_to_wd, repo, index, &opts)) < 0 || (error = git_diff__merge(diff, idx_to_wd, stash_delta_merge)) < 0) goto cleanup; data.include_changed = true; if ((error = stash_update_index_from_diff(index, diff, &data)) < 0) goto cleanup; error = build_tree_from_index(tree_out, index); cleanup: git_diff_free(idx_to_wd); git_diff_free(diff); git_tree_free(b_tree); return error; } static int commit_worktree( git_oid *w_commit_oid, git_index *index, const git_signature *stasher, const char *message, git_commit *i_commit, git_commit *b_commit, git_commit *u_commit) { int error = 0; git_tree *w_tree = NULL, *i_tree = NULL; const git_commit *parents[] = { NULL, NULL, NULL }; parents[0] = b_commit; parents[1] = i_commit; parents[2] = u_commit; if ((error = git_commit_tree(&i_tree, i_commit)) < 0) goto cleanup; if ((error = git_index_read_tree(index, i_tree)) < 0) goto cleanup; if ((error = build_workdir_tree(&w_tree, index, b_commit)) < 0) goto cleanup; error = git_commit_create( w_commit_oid, git_index_owner(index), NULL, stasher, stasher, NULL, message, w_tree, u_commit ? 3 : 2, parents); cleanup: git_tree_free(i_tree); git_tree_free(w_tree); return error; } static int prepare_worktree_commit_message( git_buf* msg, const char *user_message) { git_buf buf = GIT_BUF_INIT; int error; if ((error = git_buf_set(&buf, git_buf_cstr(msg), git_buf_len(msg))) < 0) return error; git_buf_clear(msg); if (!user_message) git_buf_printf(msg, "WIP on %s", git_buf_cstr(&buf)); else { const char *colon; if ((colon = strchr(git_buf_cstr(&buf), ':')) == NULL) goto cleanup; git_buf_puts(msg, "On "); git_buf_put(msg, git_buf_cstr(&buf), colon - buf.ptr); git_buf_printf(msg, ": %s\n", user_message); } error = (git_buf_oom(msg) || git_buf_oom(&buf)) ? -1 : 0; cleanup: git_buf_free(&buf); return error; } static int update_reflog( git_oid *w_commit_oid, git_repository *repo, const char *message) { git_reference *stash; int error; if ((error = git_reference_ensure_log(repo, GIT_REFS_STASH_FILE)) < 0) return error; error = git_reference_create(&stash, repo, GIT_REFS_STASH_FILE, w_commit_oid, 1, message); git_reference_free(stash); return error; } static int is_dirty_cb(const char *path, unsigned int status, void *payload) { GIT_UNUSED(path); GIT_UNUSED(status); GIT_UNUSED(payload); return GIT_PASSTHROUGH; } static int ensure_there_are_changes_to_stash( git_repository *repo, bool include_untracked_files, bool include_ignored_files) { int error; git_status_options opts = GIT_STATUS_OPTIONS_INIT; opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR; opts.flags = GIT_STATUS_OPT_EXCLUDE_SUBMODULES; if (include_untracked_files) opts.flags |= GIT_STATUS_OPT_INCLUDE_UNTRACKED | GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS; if (include_ignored_files) opts.flags |= GIT_STATUS_OPT_INCLUDE_IGNORED | GIT_STATUS_OPT_RECURSE_IGNORED_DIRS; error = git_status_foreach_ext(repo, &opts, is_dirty_cb, NULL); if (error == GIT_PASSTHROUGH) return 0; if (!error) return create_error(GIT_ENOTFOUND, "There is nothing to stash."); return error; } static int reset_index_and_workdir( git_repository *repo, git_commit *commit, bool remove_untracked, bool remove_ignored) { git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; opts.checkout_strategy = GIT_CHECKOUT_FORCE; if (remove_untracked) opts.checkout_strategy |= GIT_CHECKOUT_REMOVE_UNTRACKED; if (remove_ignored) opts.checkout_strategy |= GIT_CHECKOUT_REMOVE_IGNORED; return git_checkout_tree(repo, (git_object *)commit, &opts); } int git_stash_save( git_oid *out, git_repository *repo, const git_signature *stasher, const char *message, uint32_t flags) { git_index *index = NULL; git_commit *b_commit = NULL, *i_commit = NULL, *u_commit = NULL; git_buf msg = GIT_BUF_INIT; int error; assert(out && repo && stasher); if ((error = git_repository__ensure_not_bare(repo, "stash save")) < 0) return error; if ((error = retrieve_base_commit_and_message(&b_commit, &msg, repo)) < 0) goto cleanup; if ((error = ensure_there_are_changes_to_stash( repo, (flags & GIT_STASH_INCLUDE_UNTRACKED) != 0, (flags & GIT_STASH_INCLUDE_IGNORED) != 0)) < 0) goto cleanup; if ((error = git_repository_index(&index, repo)) < 0) goto cleanup; if ((error = commit_index( &i_commit, index, stasher, git_buf_cstr(&msg), b_commit)) < 0) goto cleanup; if ((flags & (GIT_STASH_INCLUDE_UNTRACKED | GIT_STASH_INCLUDE_IGNORED)) && (error = commit_untracked( &u_commit, index, stasher, git_buf_cstr(&msg), i_commit, flags)) < 0) goto cleanup; if ((error = prepare_worktree_commit_message(&msg, message)) < 0) goto cleanup; if ((error = commit_worktree( out, index, stasher, git_buf_cstr(&msg), i_commit, b_commit, u_commit)) < 0) goto cleanup; git_buf_rtrim(&msg); if ((error = update_reflog(out, repo, git_buf_cstr(&msg))) < 0) goto cleanup; if ((error = reset_index_and_workdir( repo, ((flags & GIT_STASH_KEEP_INDEX) != 0) ? i_commit : b_commit, (flags & GIT_STASH_INCLUDE_UNTRACKED) != 0, (flags & GIT_STASH_INCLUDE_IGNORED) != 0)) < 0) goto cleanup; cleanup: git_buf_free(&msg); git_commit_free(i_commit); git_commit_free(b_commit); git_commit_free(u_commit); git_index_free(index); return error; } static int retrieve_stash_commit( git_commit **commit, git_repository *repo, size_t index) { git_reference *stash = NULL; git_reflog *reflog = NULL; int error; size_t max; const git_reflog_entry *entry; if ((error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE)) < 0) goto cleanup; if ((error = git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)) < 0) goto cleanup; max = git_reflog_entrycount(reflog); if (!max || index > max - 1) { error = GIT_ENOTFOUND; giterr_set(GITERR_STASH, "No stashed state at position %" PRIuZ, index); goto cleanup; } entry = git_reflog_entry_byindex(reflog, index); if ((error = git_commit_lookup(commit, repo, git_reflog_entry_id_new(entry))) < 0) goto cleanup; cleanup: git_reference_free(stash); git_reflog_free(reflog); return error; } static int retrieve_stash_trees( git_tree **out_stash_tree, git_tree **out_base_tree, git_tree **out_index_tree, git_tree **out_index_parent_tree, git_tree **out_untracked_tree, git_commit *stash_commit) { git_tree *stash_tree = NULL; git_commit *base_commit = NULL; git_tree *base_tree = NULL; git_commit *index_commit = NULL; git_tree *index_tree = NULL; git_commit *index_parent_commit = NULL; git_tree *index_parent_tree = NULL; git_commit *untracked_commit = NULL; git_tree *untracked_tree = NULL; int error; if ((error = git_commit_tree(&stash_tree, stash_commit)) < 0) goto cleanup; if ((error = git_commit_parent(&base_commit, stash_commit, 0)) < 0) goto cleanup; if ((error = git_commit_tree(&base_tree, base_commit)) < 0) goto cleanup; if ((error = git_commit_parent(&index_commit, stash_commit, 1)) < 0) goto cleanup; if ((error = git_commit_tree(&index_tree, index_commit)) < 0) goto cleanup; if ((error = git_commit_parent(&index_parent_commit, index_commit, 0)) < 0) goto cleanup; if ((error = git_commit_tree(&index_parent_tree, index_parent_commit)) < 0) goto cleanup; if (git_commit_parentcount(stash_commit) == 3) { if ((error = git_commit_parent(&untracked_commit, stash_commit, 2)) < 0) goto cleanup; if ((error = git_commit_tree(&untracked_tree, untracked_commit)) < 0) goto cleanup; } *out_stash_tree = stash_tree; *out_base_tree = base_tree; *out_index_tree = index_tree; *out_index_parent_tree = index_parent_tree; *out_untracked_tree = untracked_tree; cleanup: git_commit_free(untracked_commit); git_commit_free(index_parent_commit); git_commit_free(index_commit); git_commit_free(base_commit); if (error < 0) { git_tree_free(stash_tree); git_tree_free(base_tree); git_tree_free(index_tree); git_tree_free(index_parent_tree); git_tree_free(untracked_tree); } return error; } static int merge_indexes( git_index **out, git_repository *repo, git_tree *ancestor_tree, git_index *ours_index, git_index *theirs_index) { git_iterator *ancestor = NULL, *ours = NULL, *theirs = NULL; git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT; int error; iter_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE; if ((error = git_iterator_for_tree(&ancestor, ancestor_tree, &iter_opts)) < 0 || (error = git_iterator_for_index(&ours, ours_index, &iter_opts)) < 0 || (error = git_iterator_for_index(&theirs, theirs_index, &iter_opts)) < 0) goto done; error = git_merge__iterators(out, repo, ancestor, ours, theirs, NULL); done: git_iterator_free(ancestor); git_iterator_free(ours); git_iterator_free(theirs); return error; } static int merge_index_and_tree( git_index **out, git_repository *repo, git_tree *ancestor_tree, git_index *ours_index, git_tree *theirs_tree) { git_iterator *ancestor = NULL, *ours = NULL, *theirs = NULL; git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT; int error; iter_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE; if ((error = git_iterator_for_tree(&ancestor, ancestor_tree, &iter_opts)) < 0 || (error = git_iterator_for_index(&ours, ours_index, &iter_opts)) < 0 || (error = git_iterator_for_tree(&theirs, theirs_tree, &iter_opts)) < 0) goto done; error = git_merge__iterators(out, repo, ancestor, ours, theirs, NULL); done: git_iterator_free(ancestor); git_iterator_free(ours); git_iterator_free(theirs); return error; } static void normalize_apply_options( git_stash_apply_options *opts, const git_stash_apply_options *given_apply_opts) { if (given_apply_opts != NULL) { memcpy(opts, given_apply_opts, sizeof(git_stash_apply_options)); } else { git_stash_apply_options default_apply_opts = GIT_STASH_APPLY_OPTIONS_INIT; memcpy(opts, &default_apply_opts, sizeof(git_stash_apply_options)); } if ((opts->checkout_options.checkout_strategy & (GIT_CHECKOUT_SAFE | GIT_CHECKOUT_FORCE)) == 0) opts->checkout_options.checkout_strategy = GIT_CHECKOUT_SAFE; if (!opts->checkout_options.our_label) opts->checkout_options.our_label = "Updated upstream"; if (!opts->checkout_options.their_label) opts->checkout_options.their_label = "Stashed changes"; } int git_stash_apply_init_options(git_stash_apply_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_stash_apply_options, GIT_STASH_APPLY_OPTIONS_INIT); return 0; } #define NOTIFY_PROGRESS(opts, progress_type) \ do { \ if ((opts).progress_cb && \ (error = (opts).progress_cb((progress_type), (opts).progress_payload))) { \ error = (error < 0) ? error : -1; \ goto cleanup; \ } \ } while(false); static int ensure_clean_index(git_repository *repo, git_index *index) { git_tree *head_tree = NULL; git_diff *index_diff = NULL; int error = 0; if ((error = git_repository_head_tree(&head_tree, repo)) < 0 || (error = git_diff_tree_to_index( &index_diff, repo, head_tree, index, NULL)) < 0) goto done; if (git_diff_num_deltas(index_diff) > 0) { giterr_set(GITERR_STASH, "%" PRIuZ " uncommitted changes exist in the index", git_diff_num_deltas(index_diff)); error = GIT_EUNCOMMITTED; } done: git_diff_free(index_diff); git_tree_free(head_tree); return error; } static int stage_new_file(const git_index_entry **entries, void *data) { git_index *index = data; if(entries[0] == NULL) return git_index_add(index, entries[1]); else return git_index_add(index, entries[0]); } static int stage_new_files( git_index **out, git_tree *parent_tree, git_tree *tree) { git_iterator *iterators[2] = { NULL, NULL }; git_iterator_options iterator_options = GIT_ITERATOR_OPTIONS_INIT; git_index *index = NULL; int error; if ((error = git_index_new(&index)) < 0 || (error = git_iterator_for_tree( &iterators[0], parent_tree, &iterator_options)) < 0 || (error = git_iterator_for_tree( &iterators[1], tree, &iterator_options)) < 0) goto done; error = git_iterator_walk(iterators, 2, stage_new_file, index); done: if (error < 0) git_index_free(index); else *out = index; git_iterator_free(iterators[0]); git_iterator_free(iterators[1]); return error; } int git_stash_apply( git_repository *repo, size_t index, const git_stash_apply_options *given_opts) { git_stash_apply_options opts; unsigned int checkout_strategy; git_commit *stash_commit = NULL; git_tree *stash_tree = NULL; git_tree *stash_parent_tree = NULL; git_tree *index_tree = NULL; git_tree *index_parent_tree = NULL; git_tree *untracked_tree = NULL; git_index *stash_adds = NULL; git_index *repo_index = NULL; git_index *unstashed_index = NULL; git_index *modified_index = NULL; git_index *untracked_index = NULL; int error; GITERR_CHECK_VERSION(given_opts, GIT_STASH_APPLY_OPTIONS_VERSION, "git_stash_apply_options"); normalize_apply_options(&opts, given_opts); checkout_strategy = opts.checkout_options.checkout_strategy; NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_LOADING_STASH); /* Retrieve commit corresponding to the given stash */ if ((error = retrieve_stash_commit(&stash_commit, repo, index)) < 0) goto cleanup; /* Retrieve all trees in the stash */ if ((error = retrieve_stash_trees( &stash_tree, &stash_parent_tree, &index_tree, &index_parent_tree, &untracked_tree, stash_commit)) < 0) goto cleanup; /* Load repo index */ if ((error = git_repository_index(&repo_index, repo)) < 0) goto cleanup; NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_ANALYZE_INDEX); if ((error = ensure_clean_index(repo, repo_index)) < 0) goto cleanup; /* Restore index if required */ if ((opts.flags & GIT_STASH_APPLY_REINSTATE_INDEX) && git_oid_cmp(git_tree_id(stash_parent_tree), git_tree_id(index_tree))) { if ((error = merge_index_and_tree( &unstashed_index, repo, index_parent_tree, repo_index, index_tree)) < 0) goto cleanup; if (git_index_has_conflicts(unstashed_index)) { error = GIT_ECONFLICT; goto cleanup; } /* Otherwise, stage any new files in the stash tree. (Note: their * previously unstaged contents are staged, not the previously staged.) */ } else if ((opts.flags & GIT_STASH_APPLY_REINSTATE_INDEX) == 0) { if ((error = stage_new_files( &stash_adds, stash_parent_tree, stash_tree)) < 0 || (error = merge_indexes( &unstashed_index, repo, stash_parent_tree, repo_index, stash_adds)) < 0) goto cleanup; } NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_ANALYZE_MODIFIED); /* Restore modified files in workdir */ if ((error = merge_index_and_tree( &modified_index, repo, stash_parent_tree, repo_index, stash_tree)) < 0) goto cleanup; /* If applicable, restore untracked / ignored files in workdir */ if (untracked_tree) { NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_ANALYZE_UNTRACKED); if ((error = merge_index_and_tree(&untracked_index, repo, NULL, repo_index, untracked_tree)) < 0) goto cleanup; } if (untracked_index) { opts.checkout_options.checkout_strategy |= GIT_CHECKOUT_DONT_UPDATE_INDEX; NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_CHECKOUT_UNTRACKED); if ((error = git_checkout_index(repo, untracked_index, &opts.checkout_options)) < 0) goto cleanup; opts.checkout_options.checkout_strategy = checkout_strategy; } /* If there are conflicts in the modified index, then we need to actually * check that out as the repo's index. Otherwise, we don't update the * index. */ if (!git_index_has_conflicts(modified_index)) opts.checkout_options.checkout_strategy |= GIT_CHECKOUT_DONT_UPDATE_INDEX; /* Check out the modified index using the existing repo index as baseline, * so that existing modifications in the index can be rewritten even when * checking out safely. */ opts.checkout_options.baseline_index = repo_index; NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_CHECKOUT_MODIFIED); if ((error = git_checkout_index(repo, modified_index, &opts.checkout_options)) < 0) goto cleanup; if (unstashed_index && !git_index_has_conflicts(modified_index)) { if ((error = git_index_read_index(repo_index, unstashed_index)) < 0) goto cleanup; } NOTIFY_PROGRESS(opts, GIT_STASH_APPLY_PROGRESS_DONE); error = git_index_write(repo_index); cleanup: git_index_free(untracked_index); git_index_free(modified_index); git_index_free(unstashed_index); git_index_free(stash_adds); git_index_free(repo_index); git_tree_free(untracked_tree); git_tree_free(index_parent_tree); git_tree_free(index_tree); git_tree_free(stash_parent_tree); git_tree_free(stash_tree); git_commit_free(stash_commit); return error; } int git_stash_foreach( git_repository *repo, git_stash_cb callback, void *payload) { git_reference *stash; git_reflog *reflog = NULL; int error; size_t i, max; const git_reflog_entry *entry; error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE); if (error == GIT_ENOTFOUND) { giterr_clear(); return 0; } if (error < 0) goto cleanup; if ((error = git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)) < 0) goto cleanup; max = git_reflog_entrycount(reflog); for (i = 0; i < max; i++) { entry = git_reflog_entry_byindex(reflog, i); error = callback(i, git_reflog_entry_message(entry), git_reflog_entry_id_new(entry), payload); if (error) { giterr_set_after_callback(error); break; } } cleanup: git_reference_free(stash); git_reflog_free(reflog); return error; } int git_stash_drop( git_repository *repo, size_t index) { git_transaction *tx; git_reference *stash = NULL; git_reflog *reflog = NULL; size_t max; int error; if ((error = git_transaction_new(&tx, repo)) < 0) return error; if ((error = git_transaction_lock_ref(tx, GIT_REFS_STASH_FILE)) < 0) goto cleanup; if ((error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE)) < 0) goto cleanup; if ((error = git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)) < 0) goto cleanup; max = git_reflog_entrycount(reflog); if (!max || index > max - 1) { error = GIT_ENOTFOUND; giterr_set(GITERR_STASH, "No stashed state at position %" PRIuZ, index); goto cleanup; } if ((error = git_reflog_drop(reflog, index, true)) < 0) goto cleanup; if ((error = git_transaction_set_reflog(tx, GIT_REFS_STASH_FILE, reflog)) < 0) goto cleanup; if (max == 1) { if ((error = git_transaction_remove(tx, GIT_REFS_STASH_FILE)) < 0) goto cleanup; } else if (index == 0) { const git_reflog_entry *entry; entry = git_reflog_entry_byindex(reflog, 0); if ((error = git_transaction_set_target(tx, GIT_REFS_STASH_FILE, &entry->oid_cur, NULL, NULL)) < 0) goto cleanup; } error = git_transaction_commit(tx); cleanup: git_reference_free(stash); git_transaction_free(tx); git_reflog_free(reflog); return error; } int git_stash_pop( git_repository *repo, size_t index, const git_stash_apply_options *options) { int error; if ((error = git_stash_apply(repo, index, options)) < 0) return error; return git_stash_drop(repo, index); } deps/libgit2-sys-0.3.8/libgit2/src/push.c0000664000175000017500000004000612610310643015011 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2.h" #include "common.h" #include "pack.h" #include "pack-objects.h" #include "remote.h" #include "vector.h" #include "push.h" #include "tree.h" static int push_spec_rref_cmp(const void *a, const void *b) { const push_spec *push_spec_a = a, *push_spec_b = b; return strcmp(push_spec_a->refspec.dst, push_spec_b->refspec.dst); } static int push_status_ref_cmp(const void *a, const void *b) { const push_status *push_status_a = a, *push_status_b = b; return strcmp(push_status_a->ref, push_status_b->ref); } int git_push_new(git_push **out, git_remote *remote) { git_push *p; *out = NULL; p = git__calloc(1, sizeof(*p)); GITERR_CHECK_ALLOC(p); p->repo = remote->repo; p->remote = remote; p->report_status = 1; p->pb_parallelism = 1; if (git_vector_init(&p->specs, 0, push_spec_rref_cmp) < 0) { git__free(p); return -1; } if (git_vector_init(&p->status, 0, push_status_ref_cmp) < 0) { git_vector_free(&p->specs); git__free(p); return -1; } if (git_vector_init(&p->updates, 0, NULL) < 0) { git_vector_free(&p->status); git_vector_free(&p->specs); git__free(p); return -1; } *out = p; return 0; } int git_push_set_options(git_push *push, const git_push_options *opts) { if (!push || !opts) return -1; GITERR_CHECK_VERSION(opts, GIT_PUSH_OPTIONS_VERSION, "git_push_options"); push->pb_parallelism = opts->pb_parallelism; push->custom_headers = &opts->custom_headers; return 0; } static void free_refspec(push_spec *spec) { if (spec == NULL) return; git_refspec__free(&spec->refspec); git__free(spec); } static int check_rref(char *ref) { if (git__prefixcmp(ref, "refs/")) { giterr_set(GITERR_INVALID, "Not a valid reference '%s'", ref); return -1; } return 0; } static int check_lref(git_push *push, char *ref) { /* lref must be resolvable to an existing object */ git_object *obj; int error = git_revparse_single(&obj, push->repo, ref); git_object_free(obj); if (!error) return 0; if (error == GIT_ENOTFOUND) giterr_set(GITERR_REFERENCE, "src refspec '%s' does not match any existing object", ref); else giterr_set(GITERR_INVALID, "Not a valid reference '%s'", ref); return -1; } static int parse_refspec(git_push *push, push_spec **spec, const char *str) { push_spec *s; *spec = NULL; s = git__calloc(1, sizeof(*s)); GITERR_CHECK_ALLOC(s); if (git_refspec__parse(&s->refspec, str, false) < 0) { giterr_set(GITERR_INVALID, "invalid refspec %s", str); goto on_error; } if (s->refspec.src && s->refspec.src[0] != '\0' && check_lref(push, s->refspec.src) < 0) { goto on_error; } if (check_rref(s->refspec.dst) < 0) goto on_error; *spec = s; return 0; on_error: free_refspec(s); return -1; } int git_push_add_refspec(git_push *push, const char *refspec) { push_spec *spec; if (parse_refspec(push, &spec, refspec) < 0 || git_vector_insert(&push->specs, spec) < 0) return -1; return 0; } int git_push_update_tips(git_push *push, const git_remote_callbacks *callbacks) { git_buf remote_ref_name = GIT_BUF_INIT; size_t i, j; git_refspec *fetch_spec; push_spec *push_spec = NULL; git_reference *remote_ref; push_status *status; int error = 0; git_vector_foreach(&push->status, i, status) { int fire_callback = 1; /* Skip unsuccessful updates which have non-empty messages */ if (status->msg) continue; /* Find the corresponding remote ref */ fetch_spec = git_remote__matching_refspec(push->remote, status->ref); if (!fetch_spec) continue; if ((error = git_refspec_transform(&remote_ref_name, fetch_spec, status->ref)) < 0) goto on_error; /* Find matching push ref spec */ git_vector_foreach(&push->specs, j, push_spec) { if (!strcmp(push_spec->refspec.dst, status->ref)) break; } /* Could not find the corresponding push ref spec for this push update */ if (j == push->specs.length) continue; /* Update the remote ref */ if (git_oid_iszero(&push_spec->loid)) { error = git_reference_lookup(&remote_ref, push->remote->repo, git_buf_cstr(&remote_ref_name)); if (error >= 0) { error = git_reference_delete(remote_ref); git_reference_free(remote_ref); } } else { error = git_reference_create(NULL, push->remote->repo, git_buf_cstr(&remote_ref_name), &push_spec->loid, 1, "update by push"); } if (error < 0) { if (error != GIT_ENOTFOUND) goto on_error; giterr_clear(); fire_callback = 0; } if (fire_callback && callbacks && callbacks->update_tips) { error = callbacks->update_tips(git_buf_cstr(&remote_ref_name), &push_spec->roid, &push_spec->loid, callbacks->payload); if (error < 0) goto on_error; } } error = 0; on_error: git_buf_free(&remote_ref_name); return error; } /** * Insert all tags until we find a non-tag object, which is returned * in `out`. */ static int enqueue_tag(git_object **out, git_push *push, git_oid *id) { git_object *obj = NULL, *target = NULL; int error; if ((error = git_object_lookup(&obj, push->repo, id, GIT_OBJ_TAG)) < 0) return error; while (git_object_type(obj) == GIT_OBJ_TAG) { if ((error = git_packbuilder_insert(push->pb, git_object_id(obj), NULL)) < 0) break; if ((error = git_tag_target(&target, (git_tag *) obj)) < 0) break; git_object_free(obj); obj = target; } if (error < 0) git_object_free(obj); else *out = obj; return error; } static int revwalk(git_vector *commits, git_push *push) { git_remote_head *head; push_spec *spec; git_revwalk *rw; git_oid oid; unsigned int i; int error = -1; if (git_revwalk_new(&rw, push->repo) < 0) return -1; git_revwalk_sorting(rw, GIT_SORT_TIME); git_vector_foreach(&push->specs, i, spec) { git_otype type; size_t size; if (git_oid_iszero(&spec->loid)) /* * Delete reference on remote side; * nothing to do here. */ continue; if (git_oid_equal(&spec->loid, &spec->roid)) continue; /* up-to-date */ if (git_odb_read_header(&size, &type, push->repo->_odb, &spec->loid) < 0) goto on_error; if (type == GIT_OBJ_TAG) { git_object *target; if ((error = enqueue_tag(&target, push, &spec->loid)) < 0) goto on_error; if (git_object_type(target) == GIT_OBJ_COMMIT) { if (git_revwalk_push(rw, git_object_id(target)) < 0) { git_object_free(target); goto on_error; } } else { if (git_packbuilder_insert( push->pb, git_object_id(target), NULL) < 0) { git_object_free(target); goto on_error; } } git_object_free(target); } else if (git_revwalk_push(rw, &spec->loid) < 0) goto on_error; if (!spec->refspec.force) { git_oid base; if (git_oid_iszero(&spec->roid)) continue; if (!git_odb_exists(push->repo->_odb, &spec->roid)) { giterr_set(GITERR_REFERENCE, "Cannot push because a reference that you are trying to update on the remote contains commits that are not present locally."); error = GIT_ENONFASTFORWARD; goto on_error; } error = git_merge_base(&base, push->repo, &spec->loid, &spec->roid); if (error == GIT_ENOTFOUND || (!error && !git_oid_equal(&base, &spec->roid))) { giterr_set(GITERR_REFERENCE, "Cannot push non-fastforwardable reference"); error = GIT_ENONFASTFORWARD; goto on_error; } if (error < 0) goto on_error; } } git_vector_foreach(&push->remote->refs, i, head) { if (git_oid_iszero(&head->oid)) continue; /* TODO */ git_revwalk_hide(rw, &head->oid); } while ((error = git_revwalk_next(&oid, rw)) == 0) { git_oid *o = git__malloc(GIT_OID_RAWSZ); if (!o) { error = -1; goto on_error; } git_oid_cpy(o, &oid); if ((error = git_vector_insert(commits, o)) < 0) goto on_error; } on_error: git_revwalk_free(rw); return error == GIT_ITEROVER ? 0 : error; } static int enqueue_object( const git_tree_entry *entry, git_packbuilder *pb) { switch (git_tree_entry_type(entry)) { case GIT_OBJ_COMMIT: return 0; case GIT_OBJ_TREE: return git_packbuilder_insert_tree(pb, &entry->oid); default: return git_packbuilder_insert(pb, &entry->oid, entry->filename); } } static int queue_differences( git_tree *base, git_tree *delta, git_packbuilder *pb) { git_tree *b_child = NULL, *d_child = NULL; size_t b_length = git_tree_entrycount(base); size_t d_length = git_tree_entrycount(delta); size_t i = 0, j = 0; int error; while (i < b_length && j < d_length) { const git_tree_entry *b_entry = git_tree_entry_byindex(base, i); const git_tree_entry *d_entry = git_tree_entry_byindex(delta, j); int cmp = 0; if (!git_oid__cmp(&b_entry->oid, &d_entry->oid)) goto loop; cmp = strcmp(b_entry->filename, d_entry->filename); /* If the entries are both trees and they have the same name but are * different, then we'll recurse after adding the right-hand entry */ if (!cmp && git_tree_entry__is_tree(b_entry) && git_tree_entry__is_tree(d_entry)) { /* Add the right-hand entry */ if ((error = git_packbuilder_insert(pb, &d_entry->oid, d_entry->filename)) < 0) goto on_error; /* Acquire the subtrees and recurse */ if ((error = git_tree_lookup(&b_child, git_tree_owner(base), &b_entry->oid)) < 0 || (error = git_tree_lookup(&d_child, git_tree_owner(delta), &d_entry->oid)) < 0 || (error = queue_differences(b_child, d_child, pb)) < 0) goto on_error; git_tree_free(b_child); b_child = NULL; git_tree_free(d_child); d_child = NULL; } /* If the object is new or different in the right-hand tree, * then enumerate it */ else if (cmp >= 0 && (error = enqueue_object(d_entry, pb)) < 0) goto on_error; loop: if (cmp <= 0) i++; if (cmp >= 0) j++; } /* Drain the right-hand tree of entries */ for (; j < d_length; j++) if ((error = enqueue_object(git_tree_entry_byindex(delta, j), pb)) < 0) goto on_error; error = 0; on_error: if (b_child) git_tree_free(b_child); if (d_child) git_tree_free(d_child); return error; } static int queue_objects(git_push *push) { git_vector commits = GIT_VECTOR_INIT; git_oid *oid; size_t i; unsigned j; int error; if ((error = revwalk(&commits, push)) < 0) goto on_error; git_vector_foreach(&commits, i, oid) { git_commit *parent = NULL, *commit; git_tree *tree = NULL, *ptree = NULL; size_t parentcount; if ((error = git_commit_lookup(&commit, push->repo, oid)) < 0) goto on_error; /* Insert the commit */ if ((error = git_packbuilder_insert(push->pb, oid, NULL)) < 0) goto loop_error; parentcount = git_commit_parentcount(commit); if (!parentcount) { if ((error = git_packbuilder_insert_tree(push->pb, git_commit_tree_id(commit))) < 0) goto loop_error; } else { if ((error = git_tree_lookup(&tree, push->repo, git_commit_tree_id(commit))) < 0 || (error = git_packbuilder_insert(push->pb, git_commit_tree_id(commit), NULL)) < 0) goto loop_error; /* For each parent, add the items which are different */ for (j = 0; j < parentcount; j++) { if ((error = git_commit_parent(&parent, commit, j)) < 0 || (error = git_commit_tree(&ptree, parent)) < 0 || (error = queue_differences(ptree, tree, push->pb)) < 0) goto loop_error; git_tree_free(ptree); ptree = NULL; git_commit_free(parent); parent = NULL; } } error = 0; loop_error: if (tree) git_tree_free(tree); if (ptree) git_tree_free(ptree); if (parent) git_commit_free(parent); git_commit_free(commit); if (error < 0) goto on_error; } error = 0; on_error: git_vector_free_deep(&commits); return error; } static int add_update(git_push *push, push_spec *spec) { git_push_update *u = git__calloc(1, sizeof(git_push_update)); GITERR_CHECK_ALLOC(u); u->src_refname = git__strdup(spec->refspec.src); GITERR_CHECK_ALLOC(u->src_refname); u->dst_refname = git__strdup(spec->refspec.dst); GITERR_CHECK_ALLOC(u->dst_refname); git_oid_cpy(&u->src, &spec->roid); git_oid_cpy(&u->dst, &spec->loid); return git_vector_insert(&push->updates, u); } static int calculate_work(git_push *push) { git_remote_head *head; push_spec *spec; unsigned int i, j; /* Update local and remote oids*/ git_vector_foreach(&push->specs, i, spec) { if (spec->refspec.src && spec->refspec.src[0]!= '\0') { /* This is a create or update. Local ref must exist. */ if (git_reference_name_to_id( &spec->loid, push->repo, spec->refspec.src) < 0) { giterr_set(GITERR_REFERENCE, "No such reference '%s'", spec->refspec.src); return -1; } } /* Remote ref may or may not (e.g. during create) already exist. */ git_vector_foreach(&push->remote->refs, j, head) { if (!strcmp(spec->refspec.dst, head->name)) { git_oid_cpy(&spec->roid, &head->oid); break; } } if (add_update(push, spec) < 0) return -1; } return 0; } static int do_push(git_push *push, const git_remote_callbacks *callbacks) { int error = 0; git_transport *transport = push->remote->transport; if (!transport->push) { giterr_set(GITERR_NET, "Remote transport doesn't support push"); error = -1; goto on_error; } /* * A pack-file MUST be sent if either create or update command * is used, even if the server already has all the necessary * objects. In this case the client MUST send an empty pack-file. */ if ((error = git_packbuilder_new(&push->pb, push->repo)) < 0) goto on_error; git_packbuilder_set_threads(push->pb, push->pb_parallelism); if (callbacks && callbacks->pack_progress) if ((error = git_packbuilder_set_callbacks(push->pb, callbacks->pack_progress, callbacks->payload)) < 0) goto on_error; if ((error = calculate_work(push)) < 0) goto on_error; if (callbacks && callbacks->push_negotiation && (error = callbacks->push_negotiation((const git_push_update **) push->updates.contents, push->updates.length, callbacks->payload)) < 0) goto on_error; if ((error = queue_objects(push)) < 0 || (error = transport->push(transport, push, callbacks)) < 0) goto on_error; on_error: git_packbuilder_free(push->pb); return error; } static int filter_refs(git_remote *remote) { const git_remote_head **heads; size_t heads_len, i; git_vector_clear(&remote->refs); if (git_remote_ls(&heads, &heads_len, remote) < 0) return -1; for (i = 0; i < heads_len; i++) { if (git_vector_insert(&remote->refs, (void *)heads[i]) < 0) return -1; } return 0; } int git_push_finish(git_push *push, const git_remote_callbacks *callbacks) { int error; if (!git_remote_connected(push->remote) && (error = git_remote_connect(push->remote, GIT_DIRECTION_PUSH, callbacks, push->custom_headers)) < 0) return error; if ((error = filter_refs(push->remote)) < 0 || (error = do_push(push, callbacks)) < 0) return error; if (!push->unpack_ok) { error = -1; giterr_set(GITERR_NET, "unpacking the sent packfile failed on the remote"); } return error; } int git_push_status_foreach(git_push *push, int (*cb)(const char *ref, const char *msg, void *data), void *data) { push_status *status; unsigned int i; git_vector_foreach(&push->status, i, status) { int error = cb(status->ref, status->msg, data); if (error) return giterr_set_after_callback(error); } return 0; } void git_push_status_free(push_status *status) { if (status == NULL) return; git__free(status->msg); git__free(status->ref); git__free(status); } void git_push_free(git_push *push) { push_spec *spec; push_status *status; git_push_update *update; unsigned int i; if (push == NULL) return; git_vector_foreach(&push->specs, i, spec) { free_refspec(spec); } git_vector_free(&push->specs); git_vector_foreach(&push->status, i, status) { git_push_status_free(status); } git_vector_free(&push->status); git_vector_foreach(&push->updates, i, update) { git__free(update->src_refname); git__free(update->dst_refname); git__free(update); } git_vector_free(&push->updates); git__free(push); } int git_push_init_options(git_push_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_push_options, GIT_PUSH_OPTIONS_INIT); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/transaction.c0000664000175000017500000002064512610310643016366 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "repository.h" #include "strmap.h" #include "refdb.h" #include "pool.h" #include "reflog.h" #include "signature.h" #include "config.h" #include "git2/transaction.h" #include "git2/signature.h" #include "git2/sys/refs.h" #include "git2/sys/refdb_backend.h" GIT__USE_STRMAP typedef enum { TRANSACTION_NONE, TRANSACTION_REFS, TRANSACTION_CONFIG, } transaction_t; typedef struct { const char *name; void *payload; git_ref_t ref_type; union { git_oid id; char *symbolic; } target; git_reflog *reflog; const char *message; git_signature *sig; unsigned int committed :1, remove :1; } transaction_node; struct git_transaction { transaction_t type; git_repository *repo; git_refdb *db; git_config *cfg; git_strmap *locks; git_pool pool; }; int git_transaction_config_new(git_transaction **out, git_config *cfg) { git_transaction *tx; assert(out && cfg); tx = git__calloc(1, sizeof(git_transaction)); GITERR_CHECK_ALLOC(tx); tx->type = TRANSACTION_CONFIG; tx->cfg = cfg; *out = tx; return 0; } int git_transaction_new(git_transaction **out, git_repository *repo) { int error; git_pool pool; git_transaction *tx = NULL; assert(out && repo); if ((error = git_pool_init(&pool, 1, 0)) < 0) return error; tx = git_pool_mallocz(&pool, sizeof(git_transaction)); if (!tx) { error = -1; goto on_error; } if ((error = git_strmap_alloc(&tx->locks)) < 0) { error = -1; goto on_error; } if ((error = git_repository_refdb(&tx->db, repo)) < 0) goto on_error; tx->type = TRANSACTION_REFS; memcpy(&tx->pool, &pool, sizeof(git_pool)); tx->repo = repo; *out = tx; return 0; on_error: git_pool_clear(&pool); return error; } int git_transaction_lock_ref(git_transaction *tx, const char *refname) { int error; transaction_node *node; assert(tx && refname); node = git_pool_mallocz(&tx->pool, sizeof(transaction_node)); GITERR_CHECK_ALLOC(node); node->name = git_pool_strdup(&tx->pool, refname); GITERR_CHECK_ALLOC(node->name); if ((error = git_refdb_lock(&node->payload, tx->db, refname)) < 0) return error; git_strmap_insert(tx->locks, node->name, node, error); if (error < 0) goto cleanup; return 0; cleanup: git_refdb_unlock(tx->db, node->payload, false, false, NULL, NULL, NULL); return error; } static int find_locked(transaction_node **out, git_transaction *tx, const char *refname) { git_strmap_iter pos; transaction_node *node; pos = git_strmap_lookup_index(tx->locks, refname); if (!git_strmap_valid_index(tx->locks, pos)) { giterr_set(GITERR_REFERENCE, "the specified reference is not locked"); return GIT_ENOTFOUND; } node = git_strmap_value_at(tx->locks, pos); *out = node; return 0; } static int copy_common(transaction_node *node, git_transaction *tx, const git_signature *sig, const char *msg) { if (sig && git_signature__pdup(&node->sig, sig, &tx->pool) < 0) return -1; if (!node->sig) { git_signature *tmp; int error; if (git_reference__log_signature(&tmp, tx->repo) < 0) return -1; /* make sure the sig we use is in our pool */ error = git_signature__pdup(&node->sig, tmp, &tx->pool); git_signature_free(tmp); if (error < 0) return error; } if (msg) { node->message = git_pool_strdup(&tx->pool, msg); GITERR_CHECK_ALLOC(node->message); } return 0; } int git_transaction_set_target(git_transaction *tx, const char *refname, const git_oid *target, const git_signature *sig, const char *msg) { int error; transaction_node *node; assert(tx && refname && target); if ((error = find_locked(&node, tx, refname)) < 0) return error; if ((error = copy_common(node, tx, sig, msg)) < 0) return error; git_oid_cpy(&node->target.id, target); node->ref_type = GIT_REF_OID; return 0; } int git_transaction_set_symbolic_target(git_transaction *tx, const char *refname, const char *target, const git_signature *sig, const char *msg) { int error; transaction_node *node; assert(tx && refname && target); if ((error = find_locked(&node, tx, refname)) < 0) return error; if ((error = copy_common(node, tx, sig, msg)) < 0) return error; node->target.symbolic = git_pool_strdup(&tx->pool, target); GITERR_CHECK_ALLOC(node->target.symbolic); node->ref_type = GIT_REF_SYMBOLIC; return 0; } int git_transaction_remove(git_transaction *tx, const char *refname) { int error; transaction_node *node; if ((error = find_locked(&node, tx, refname)) < 0) return error; node->remove = true; node->ref_type = GIT_REF_OID; /* the id will be ignored */ return 0; } static int dup_reflog(git_reflog **out, const git_reflog *in, git_pool *pool) { git_reflog *reflog; git_reflog_entry *entries; size_t len, i; reflog = git_pool_mallocz(pool, sizeof(git_reflog)); GITERR_CHECK_ALLOC(reflog); reflog->ref_name = git_pool_strdup(pool, in->ref_name); GITERR_CHECK_ALLOC(reflog->ref_name); len = in->entries.length; reflog->entries.length = len; reflog->entries.contents = git_pool_mallocz(pool, len * sizeof(void *)); GITERR_CHECK_ALLOC(reflog->entries.contents); entries = git_pool_mallocz(pool, len * sizeof(git_reflog_entry)); GITERR_CHECK_ALLOC(entries); for (i = 0; i < len; i++) { const git_reflog_entry *src; git_reflog_entry *tgt; tgt = &entries[i]; reflog->entries.contents[i] = tgt; src = git_vector_get(&in->entries, i); git_oid_cpy(&tgt->oid_old, &src->oid_old); git_oid_cpy(&tgt->oid_cur, &src->oid_cur); tgt->msg = git_pool_strdup(pool, src->msg); GITERR_CHECK_ALLOC(tgt->msg); if (git_signature__pdup(&tgt->committer, src->committer, pool) < 0) return -1; } *out = reflog; return 0; } int git_transaction_set_reflog(git_transaction *tx, const char *refname, const git_reflog *reflog) { int error; transaction_node *node; assert(tx && refname && reflog); if ((error = find_locked(&node, tx, refname)) < 0) return error; if ((error = dup_reflog(&node->reflog, reflog, &tx->pool)) < 0) return error; return 0; } static int update_target(git_refdb *db, transaction_node *node) { git_reference *ref; int error, update_reflog; if (node->ref_type == GIT_REF_OID) { ref = git_reference__alloc(node->name, &node->target.id, NULL); } else if (node->ref_type == GIT_REF_SYMBOLIC) { ref = git_reference__alloc_symbolic(node->name, node->target.symbolic); } else { abort(); } GITERR_CHECK_ALLOC(ref); update_reflog = node->reflog == NULL; if (node->remove) { error = git_refdb_unlock(db, node->payload, 2, false, ref, NULL, NULL); } else if (node->ref_type == GIT_REF_OID) { error = git_refdb_unlock(db, node->payload, true, update_reflog, ref, node->sig, node->message); } else if (node->ref_type == GIT_REF_SYMBOLIC) { error = git_refdb_unlock(db, node->payload, true, update_reflog, ref, node->sig, node->message); } else { abort(); } git_reference_free(ref); node->committed = true; return error; } int git_transaction_commit(git_transaction *tx) { transaction_node *node; git_strmap_iter pos; int error = 0; assert(tx); if (tx->type == TRANSACTION_CONFIG) { error = git_config_unlock(tx->cfg, true); tx->cfg = NULL; return error; } for (pos = kh_begin(tx->locks); pos < kh_end(tx->locks); pos++) { if (!git_strmap_has_data(tx->locks, pos)) continue; node = git_strmap_value_at(tx->locks, pos); if (node->reflog) { if ((error = tx->db->backend->reflog_write(tx->db->backend, node->reflog)) < 0) return error; } if (node->ref_type != GIT_REF_INVALID) { if ((error = update_target(tx->db, node)) < 0) return error; } } return 0; } void git_transaction_free(git_transaction *tx) { transaction_node *node; git_pool pool; git_strmap_iter pos; assert(tx); if (tx->type == TRANSACTION_CONFIG) { if (tx->cfg) { git_config_unlock(tx->cfg, false); git_config_free(tx->cfg); } git__free(tx); return; } /* start by unlocking the ones we've left hanging, if any */ for (pos = kh_begin(tx->locks); pos < kh_end(tx->locks); pos++) { if (!git_strmap_has_data(tx->locks, pos)) continue; node = git_strmap_value_at(tx->locks, pos); if (node->committed) continue; git_refdb_unlock(tx->db, node->payload, false, false, NULL, NULL, NULL); } git_refdb_free(tx->db); git_strmap_free(tx->locks); /* tx is inside the pool, so we need to extract the data */ memcpy(&pool, &tx->pool, sizeof(git_pool)); git_pool_clear(&pool); } deps/libgit2-sys-0.3.8/libgit2/src/diff.h0000664000175000017500000001252312555730137014766 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_diff_h__ #define INCLUDE_diff_h__ #include "git2/diff.h" #include "git2/sys/diff.h" #include "git2/oid.h" #include #include "vector.h" #include "buffer.h" #include "iterator.h" #include "repository.h" #include "pool.h" #include "odb.h" #define DIFF_OLD_PREFIX_DEFAULT "a/" #define DIFF_NEW_PREFIX_DEFAULT "b/" enum { GIT_DIFFCAPS_HAS_SYMLINKS = (1 << 0), /* symlinks on platform? */ GIT_DIFFCAPS_IGNORE_STAT = (1 << 1), /* use stat? */ GIT_DIFFCAPS_TRUST_MODE_BITS = (1 << 2), /* use st_mode? */ GIT_DIFFCAPS_TRUST_CTIME = (1 << 3), /* use st_ctime? */ GIT_DIFFCAPS_USE_DEV = (1 << 4), /* use st_dev? */ GIT_DIFFCAPS_TRUST_NANOSECS = (1 << 5), /* use stat time nanoseconds */ }; #define DIFF_FLAGS_KNOWN_BINARY (GIT_DIFF_FLAG_BINARY|GIT_DIFF_FLAG_NOT_BINARY) #define DIFF_FLAGS_NOT_BINARY (GIT_DIFF_FLAG_NOT_BINARY|GIT_DIFF_FLAG__NO_DATA) enum { GIT_DIFF_FLAG__FREE_PATH = (1 << 7), /* `path` is allocated memory */ GIT_DIFF_FLAG__FREE_DATA = (1 << 8), /* internal file data is allocated */ GIT_DIFF_FLAG__UNMAP_DATA = (1 << 9), /* internal file data is mmap'ed */ GIT_DIFF_FLAG__NO_DATA = (1 << 10), /* file data should not be loaded */ GIT_DIFF_FLAG__FREE_BLOB = (1 << 11), /* release the blob when done */ GIT_DIFF_FLAG__LOADED = (1 << 12), /* file data has been loaded */ GIT_DIFF_FLAG__TO_DELETE = (1 << 16), /* delete entry during rename det. */ GIT_DIFF_FLAG__TO_SPLIT = (1 << 17), /* split entry during rename det. */ GIT_DIFF_FLAG__IS_RENAME_TARGET = (1 << 18), GIT_DIFF_FLAG__IS_RENAME_SOURCE = (1 << 19), GIT_DIFF_FLAG__HAS_SELF_SIMILARITY = (1 << 20), }; #define GIT_DIFF_FLAG__CLEAR_INTERNAL(F) (F) = ((F) & 0x00FFFF) #define GIT_DIFF__VERBOSE (1 << 30) struct git_diff { git_refcount rc; git_repository *repo; git_diff_options opts; git_vector pathspec; git_vector deltas; /* vector of git_diff_delta */ git_pool pool; git_iterator_type_t old_src; git_iterator_type_t new_src; uint32_t diffcaps; git_diff_perfdata perf; bool index_updated; int (*strcomp)(const char *, const char *); int (*strncomp)(const char *, const char *, size_t); int (*pfxcomp)(const char *str, const char *pfx); int (*entrycomp)(const void *a, const void *b); }; extern void git_diff__cleanup_modes( uint32_t diffcaps, uint32_t *omode, uint32_t *nmode); extern void git_diff_addref(git_diff *diff); extern int git_diff_delta__cmp(const void *a, const void *b); extern int git_diff_delta__casecmp(const void *a, const void *b); extern const char *git_diff_delta__path(const git_diff_delta *delta); extern bool git_diff_delta__should_skip( const git_diff_options *opts, const git_diff_delta *delta); extern int git_diff_delta__format_file_header( git_buf *out, const git_diff_delta *delta, const char *oldpfx, const char *newpfx, int oid_strlen); extern int git_diff__oid_for_file( git_oid *out, git_diff *, const char *, uint16_t, git_off_t); extern int git_diff__oid_for_entry( git_oid *out, git_diff *, const git_index_entry *, uint16_t, const git_oid *update); extern int git_diff__from_iterators( git_diff **diff_ptr, git_repository *repo, git_iterator *old_iter, git_iterator *new_iter, const git_diff_options *opts); extern int git_diff__paired_foreach( git_diff *idx2head, git_diff *wd2idx, int (*cb)(git_diff_delta *i2h, git_diff_delta *w2i, void *payload), void *payload); extern int git_diff_find_similar__hashsig_for_file( void **out, const git_diff_file *f, const char *path, void *p); extern int git_diff_find_similar__hashsig_for_buf( void **out, const git_diff_file *f, const char *buf, size_t len, void *p); extern void git_diff_find_similar__hashsig_free(void *sig, void *payload); extern int git_diff_find_similar__calc_similarity( int *score, void *siga, void *sigb, void *payload); extern int git_diff__commit( git_diff **diff, git_repository *repo, const git_commit *commit, const git_diff_options *opts); /* Merge two `git_diff`s according to the callback given by `cb`. */ typedef git_diff_delta *(*git_diff__merge_cb)( const git_diff_delta *left, const git_diff_delta *right, git_pool *pool); extern int git_diff__merge( git_diff *onto, const git_diff *from, git_diff__merge_cb cb); extern git_diff_delta *git_diff__merge_like_cgit( const git_diff_delta *a, const git_diff_delta *b, git_pool *pool); /* Duplicate a `git_diff_delta` out of the `git_pool` */ extern git_diff_delta *git_diff__delta_dup( const git_diff_delta *d, git_pool *pool); /* * Sometimes a git_diff_file will have a zero size; this attempts to * fill in the size without loading the blob if possible. If that is * not possible, then it will return the git_odb_object that had to be * loaded and the caller can use it or dispose of it as needed. */ GIT_INLINE(int) git_diff_file__resolve_zero_size( git_diff_file *file, git_odb_object **odb_obj, git_repository *repo) { int error; git_odb *odb; size_t len; git_otype type; if ((error = git_repository_odb(&odb, repo)) < 0) return error; error = git_odb__read_header_or_object( odb_obj, &len, &type, odb, &file->id); git_odb_free(odb); if (!error) file->size = (git_off_t)len; return error; } #endif deps/libgit2-sys-0.3.8/libgit2/src/blob.h0000664000175000017500000000137712426525445015002 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_blob_h__ #define INCLUDE_blob_h__ #include "git2/blob.h" #include "repository.h" #include "odb.h" #include "fileops.h" struct git_blob { git_object object; git_odb_object *odb_object; }; void git_blob__free(void *blob); int git_blob__parse(void *blob, git_odb_object *obj); int git_blob__getbuf(git_buf *buffer, git_blob *blob); extern int git_blob__create_from_paths( git_oid *out_oid, struct stat *out_st, git_repository *repo, const char *full_path, const char *hint_path, mode_t hint_mode, bool apply_filters); #endif deps/libgit2-sys-0.3.8/libgit2/src/iterator.c0000664000175000017500000015416512610310643015677 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "iterator.h" #include "tree.h" #include "index.h" #include "ignore.h" #include "buffer.h" #include "submodule.h" #include #define ITERATOR_SET_CB(P,NAME_LC) do { \ (P)->cb.current = NAME_LC ## _iterator__current; \ (P)->cb.advance = NAME_LC ## _iterator__advance; \ (P)->cb.advance_into = NAME_LC ## _iterator__advance_into; \ (P)->cb.seek = NAME_LC ## _iterator__seek; \ (P)->cb.reset = NAME_LC ## _iterator__reset; \ (P)->cb.at_end = NAME_LC ## _iterator__at_end; \ (P)->cb.free = NAME_LC ## _iterator__free; \ } while (0) #define ITERATOR_CASE_FLAGS \ (GIT_ITERATOR_IGNORE_CASE | GIT_ITERATOR_DONT_IGNORE_CASE) #define ITERATOR_BASE_INIT(P,NAME_LC,NAME_UC,REPO) do { \ (P)->base.type = GIT_ITERATOR_TYPE_ ## NAME_UC; \ (P)->base.cb = &(P)->cb; \ ITERATOR_SET_CB(P,NAME_LC); \ (P)->base.repo = (REPO); \ (P)->base.start = options && options->start ? \ git__strdup(options->start) : NULL; \ (P)->base.end = options && options->end ? \ git__strdup(options->end) : NULL; \ if ((options && options->start && !(P)->base.start) || \ (options && options->end && !(P)->base.end)) { \ git__free(P); return -1; } \ (P)->base.strcomp = git__strcmp; \ (P)->base.strncomp = git__strncmp; \ (P)->base.prefixcomp = git__prefixcmp; \ (P)->base.flags = options ? options->flags & ~ITERATOR_CASE_FLAGS : 0; \ if ((P)->base.flags & GIT_ITERATOR_DONT_AUTOEXPAND) \ (P)->base.flags |= GIT_ITERATOR_INCLUDE_TREES; \ if (options && options->pathlist.count && \ iterator_pathlist__init(&P->base, &options->pathlist) < 0) { \ git__free(P); return -1; } \ } while (0) #define iterator__flag(I,F) ((((git_iterator *)(I))->flags & GIT_ITERATOR_ ## F) != 0) #define iterator__ignore_case(I) iterator__flag(I,IGNORE_CASE) #define iterator__include_trees(I) iterator__flag(I,INCLUDE_TREES) #define iterator__dont_autoexpand(I) iterator__flag(I,DONT_AUTOEXPAND) #define iterator__do_autoexpand(I) !iterator__flag(I,DONT_AUTOEXPAND) #define iterator__include_conflicts(I) iterator__flag(I, INCLUDE_CONFLICTS) #define GIT_ITERATOR_FIRST_ACCESS (1 << 15) #define iterator__has_been_accessed(I) iterator__flag(I,FIRST_ACCESS) #define iterator__end(I) ((git_iterator *)(I))->end #define iterator__past_end(I,PATH) \ (iterator__end(I) && ((git_iterator *)(I))->prefixcomp((PATH),iterator__end(I)) > 0) typedef enum { ITERATOR_PATHLIST_NONE = 0, ITERATOR_PATHLIST_MATCH = 1, ITERATOR_PATHLIST_MATCH_DIRECTORY = 2, ITERATOR_PATHLIST_MATCH_CHILD = 3, } iterator_pathlist__match_t; static int iterator_pathlist__init(git_iterator *iter, git_strarray *pathspec) { size_t i; if (git_vector_init(&iter->pathlist, pathspec->count, (git_vector_cmp)iter->strcomp) < 0) return -1; for (i = 0; i < pathspec->count; i++) { if (!pathspec->strings[i]) continue; if (git_vector_insert(&iter->pathlist, pathspec->strings[i]) < 0) return -1; } git_vector_sort(&iter->pathlist); return 0; } static iterator_pathlist__match_t iterator_pathlist__match( git_iterator *iter, const char *path, size_t path_len) { const char *p; size_t idx; int error; error = git_vector_bsearch2(&idx, &iter->pathlist, (git_vector_cmp)iter->strcomp, path); if (error == 0) return ITERATOR_PATHLIST_MATCH; /* at this point, the path we're examining may be a directory (though we * don't know that yet, since we're avoiding a stat unless it's necessary) * so see if the pathlist contains a file beneath this directory. */ while ((p = git_vector_get(&iter->pathlist, idx)) != NULL) { if (iter->prefixcomp(p, path) != 0) break; /* an exact match would have been matched by the bsearch above */ assert(p[path_len]); /* is this a literal directory entry (eg `foo/`) or a file beneath */ if (p[path_len] == '/') { return (p[path_len+1] == '\0') ? ITERATOR_PATHLIST_MATCH_DIRECTORY : ITERATOR_PATHLIST_MATCH_CHILD; } if (p[path_len] > '/') break; idx++; } return ITERATOR_PATHLIST_NONE; } static void iterator_pathlist_walk__reset(git_iterator *iter) { iter->pathlist_walk_idx = 0; } /* walker for the index iterator that allows it to walk the sorted pathlist * entries alongside the sorted index entries. the `iter->pathlist_walk_idx` * stores the starting position for subsequent calls, the position is advanced * along with the index iterator, with a special case for handling directories * in the pathlist that are specified without trailing '/'. (eg, `foo`). * we do not advance over these entries until we're certain that the index * iterator will not ask us for a file beneath that directory (eg, `foo/bar`). */ static bool iterator_pathlist_walk__contains(git_iterator *iter, const char *path) { size_t i; char *p; size_t p_len; int cmp; for (i = iter->pathlist_walk_idx; i < iter->pathlist.length; i++) { p = iter->pathlist.contents[i]; p_len = strlen(p); /* see if the pathlist entry is a prefix of this path */ cmp = iter->strncomp(p, path, p_len); /* this pathlist entry sorts before the given path, try the next */ if (!p_len || cmp < 0) iter->pathlist_walk_idx++; /* this pathlist sorts after the given path, no match. */ else if (cmp > 0) return false; /* match! an exact match (`foo` vs `foo`), the path is a child of an * explicit directory in the pathlist (`foo/` vs `foo/bar`) or the path * is a child of an entry in the pathlist (`foo` vs `foo/bar`) */ else if (path[p_len] == '\0' || p[p_len - 1] == '/' || path[p_len] == '/') return true; /* only advance the start index for future callers if we know that we * will not see a child of this path. eg, a pathlist entry `foo` is * a prefix for `foo.txt` and `foo/bar`. don't advance the start * pathlist index when we see `foo.txt` or we would miss a subsequent * inspection of `foo/bar`. only advance when there are no more * potential children. */ else if (path[p_len] > '/') iter->pathlist_walk_idx++; } return false; } static void iterator_pathlist__update_ignore_case(git_iterator *iter) { git_vector_set_cmp(&iter->pathlist, (git_vector_cmp)iter->strcomp); git_vector_sort(&iter->pathlist); iter->pathlist_walk_idx = 0; } static int iterator__reset_range( git_iterator *iter, const char *start, const char *end) { if (start) { if (iter->start) git__free(iter->start); iter->start = git__strdup(start); GITERR_CHECK_ALLOC(iter->start); } if (end) { if (iter->end) git__free(iter->end); iter->end = git__strdup(end); GITERR_CHECK_ALLOC(iter->end); } iter->flags &= ~GIT_ITERATOR_FIRST_ACCESS; return 0; } static int iterator__update_ignore_case( git_iterator *iter, git_iterator_flag_t flags) { bool ignore_case; int error; if ((flags & GIT_ITERATOR_IGNORE_CASE) != 0) ignore_case = true; else if ((flags & GIT_ITERATOR_DONT_IGNORE_CASE) != 0) ignore_case = false; else { git_index *index; if ((error = git_repository_index__weakptr(&index, iter->repo)) < 0) return error; ignore_case = (index->ignore_case == 1); } if (ignore_case) { iter->flags = (iter->flags | GIT_ITERATOR_IGNORE_CASE); iter->strcomp = git__strcasecmp; iter->strncomp = git__strncasecmp; iter->prefixcomp = git__prefixcmp_icase; } else { iter->flags = (iter->flags & ~GIT_ITERATOR_IGNORE_CASE); iter->strcomp = git__strcmp; iter->strncomp = git__strncmp; iter->prefixcomp = git__prefixcmp; } iterator_pathlist__update_ignore_case(iter); return 0; } GIT_INLINE(void) iterator__clear_entry(const git_index_entry **entry) { if (entry) *entry = NULL; } static int empty_iterator__noop(const git_index_entry **e, git_iterator *i) { GIT_UNUSED(i); iterator__clear_entry(e); return GIT_ITEROVER; } static int empty_iterator__seek(git_iterator *i, const char *p) { GIT_UNUSED(i); GIT_UNUSED(p); return -1; } static int empty_iterator__reset(git_iterator *i, const char *s, const char *e) { GIT_UNUSED(i); GIT_UNUSED(s); GIT_UNUSED(e); return 0; } static int empty_iterator__at_end(git_iterator *i) { GIT_UNUSED(i); return 1; } static void empty_iterator__free(git_iterator *i) { GIT_UNUSED(i); } typedef struct { git_iterator base; git_iterator_callbacks cb; } empty_iterator; int git_iterator_for_nothing( git_iterator **iter, git_iterator_options *options) { empty_iterator *i = git__calloc(1, sizeof(empty_iterator)); GITERR_CHECK_ALLOC(i); #define empty_iterator__current empty_iterator__noop #define empty_iterator__advance empty_iterator__noop #define empty_iterator__advance_into empty_iterator__noop ITERATOR_BASE_INIT(i, empty, EMPTY, NULL); if (options && (options->flags & GIT_ITERATOR_IGNORE_CASE) != 0) i->base.flags |= GIT_ITERATOR_IGNORE_CASE; *iter = (git_iterator *)i; return 0; } typedef struct tree_iterator_entry tree_iterator_entry; struct tree_iterator_entry { tree_iterator_entry *parent; const git_tree_entry *te; git_tree *tree; }; typedef struct tree_iterator_frame tree_iterator_frame; struct tree_iterator_frame { tree_iterator_frame *up, *down; size_t n_entries; /* items in this frame */ size_t current; /* start of currently active range in frame */ size_t next; /* start of next range in frame */ const char *start; size_t startlen; tree_iterator_entry *entries[GIT_FLEX_ARRAY]; }; typedef struct { git_iterator base; git_iterator_callbacks cb; tree_iterator_frame *head, *root; git_pool pool; git_index_entry entry; git_buf path; int path_ambiguities; bool path_has_filename; bool entry_is_current; } tree_iterator; static char *tree_iterator__current_filename( tree_iterator *ti, const git_tree_entry *te) { if (!ti->path_has_filename) { if (git_buf_joinpath(&ti->path, ti->path.ptr, te->filename) < 0) return NULL; if (git_tree_entry__is_tree(te) && git_buf_putc(&ti->path, '/') < 0) return NULL; ti->path_has_filename = true; } return ti->path.ptr; } static void tree_iterator__rewrite_filename(tree_iterator *ti) { tree_iterator_entry *scan = ti->head->entries[ti->head->current]; ssize_t strpos = ti->path.size; const git_tree_entry *te; if (strpos && ti->path.ptr[strpos - 1] == '/') strpos--; for (; scan && (te = scan->te); scan = scan->parent) { strpos -= te->filename_len; memcpy(&ti->path.ptr[strpos], te->filename, te->filename_len); strpos -= 1; /* separator */ } } static int tree_iterator__te_cmp( const git_tree_entry *a, const git_tree_entry *b, int (*compare)(const char *, const char *, size_t)) { return git_path_cmp( a->filename, a->filename_len, a->attr == GIT_FILEMODE_TREE, b->filename, b->filename_len, b->attr == GIT_FILEMODE_TREE, compare); } static int tree_iterator__ci_cmp(const void *a, const void *b, void *p) { const tree_iterator_entry *ae = a, *be = b; int cmp = tree_iterator__te_cmp(ae->te, be->te, git__strncasecmp); if (!cmp) { /* stabilize sort order among equivalent names */ if (!ae->parent->te || !be->parent->te) cmp = tree_iterator__te_cmp(ae->te, be->te, git__strncmp); else cmp = tree_iterator__ci_cmp(ae->parent, be->parent, p); } return cmp; } static int tree_iterator__search_cmp(const void *key, const void *val, void *p) { const tree_iterator_frame *tf = key; const git_tree_entry *te = ((tree_iterator_entry *)val)->te; return git_path_cmp( tf->start, tf->startlen, false, te->filename, te->filename_len, te->attr == GIT_FILEMODE_TREE, ((git_iterator *)p)->strncomp); } static bool tree_iterator__move_to_next( tree_iterator *ti, tree_iterator_frame *tf) { if (tf->next > tf->current + 1) ti->path_ambiguities--; if (!tf->up) { /* at root */ tf->current = tf->next; return false; } for (; tf->current < tf->next; tf->current++) { git_tree_free(tf->entries[tf->current]->tree); tf->entries[tf->current]->tree = NULL; } return (tf->current < tf->n_entries); } static int tree_iterator__set_next(tree_iterator *ti, tree_iterator_frame *tf) { int error = 0; const git_tree_entry *te, *last = NULL; tf->next = tf->current; for (; tf->next < tf->n_entries; tf->next++, last = te) { te = tf->entries[tf->next]->te; if (last && tree_iterator__te_cmp(last, te, ti->base.strncomp)) break; /* try to load trees for items in [current,next) range */ if (!error && git_tree_entry__is_tree(te)) error = git_tree_lookup( &tf->entries[tf->next]->tree, ti->base.repo, &te->oid); } if (tf->next > tf->current + 1) ti->path_ambiguities++; /* if a tree lookup failed, advance over this span and return failure */ if (error < 0) { tree_iterator__move_to_next(ti, tf); return error; } if (last && !tree_iterator__current_filename(ti, last)) return -1; /* must have been allocation failure */ return 0; } GIT_INLINE(bool) tree_iterator__at_tree(tree_iterator *ti) { return (ti->head->current < ti->head->n_entries && ti->head->entries[ti->head->current]->tree != NULL); } static int tree_iterator__push_frame(tree_iterator *ti) { int error = 0; tree_iterator_frame *head = ti->head, *tf = NULL; size_t i, n_entries = 0, alloclen; if (head->current >= head->n_entries || !head->entries[head->current]->tree) return GIT_ITEROVER; for (i = head->current; i < head->next; ++i) n_entries += git_tree_entrycount(head->entries[i]->tree); GITERR_CHECK_ALLOC_MULTIPLY(&alloclen, sizeof(tree_iterator_entry *), n_entries); GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, sizeof(tree_iterator_frame)); tf = git__calloc(1, alloclen); GITERR_CHECK_ALLOC(tf); tf->n_entries = n_entries; tf->up = head; head->down = tf; ti->head = tf; for (i = head->current, n_entries = 0; i < head->next; ++i) { git_tree *tree = head->entries[i]->tree; size_t j, max_j = git_tree_entrycount(tree); for (j = 0; j < max_j; ++j) { tree_iterator_entry *entry = git_pool_malloc(&ti->pool, 1); GITERR_CHECK_ALLOC(entry); entry->parent = head->entries[i]; entry->te = git_tree_entry_byindex(tree, j); entry->tree = NULL; tf->entries[n_entries++] = entry; } } /* if ignore_case, sort entries case insensitively */ if (iterator__ignore_case(ti)) git__tsort_r( (void **)tf->entries, tf->n_entries, tree_iterator__ci_cmp, tf); /* pick tf->current based on "start" (or start at zero) */ if (head->startlen > 0) { git__bsearch_r((void **)tf->entries, tf->n_entries, head, tree_iterator__search_cmp, ti, &tf->current); while (tf->current && !tree_iterator__search_cmp(head, tf->entries[tf->current-1], ti)) tf->current--; if ((tf->start = strchr(head->start, '/')) != NULL) { tf->start++; tf->startlen = strlen(tf->start); } } ti->path_has_filename = ti->entry_is_current = false; if ((error = tree_iterator__set_next(ti, tf)) < 0) return error; /* autoexpand as needed */ if (!iterator__include_trees(ti) && tree_iterator__at_tree(ti)) return tree_iterator__push_frame(ti); return 0; } static bool tree_iterator__pop_frame(tree_iterator *ti, bool final) { tree_iterator_frame *tf = ti->head; if (!tf->up) return false; ti->head = tf->up; ti->head->down = NULL; tree_iterator__move_to_next(ti, tf); if (!final) { /* if final, don't bother to clean up */ git_pool_free_array(&ti->pool, tf->n_entries, (void **)tf->entries); git_buf_rtruncate_at_char(&ti->path, '/'); } git__free(tf); return true; } static void tree_iterator__pop_all(tree_iterator *ti, bool to_end, bool final) { while (tree_iterator__pop_frame(ti, final)) /* pop to root */; if (!final) { ti->head->current = to_end ? ti->head->n_entries : 0; ti->path_ambiguities = 0; git_buf_clear(&ti->path); } } static int tree_iterator__update_entry(tree_iterator *ti) { tree_iterator_frame *tf; const git_tree_entry *te; if (ti->entry_is_current) return 0; tf = ti->head; te = tf->entries[tf->current]->te; ti->entry.mode = te->attr; git_oid_cpy(&ti->entry.id, &te->oid); ti->entry.path = tree_iterator__current_filename(ti, te); GITERR_CHECK_ALLOC(ti->entry.path); if (ti->path_ambiguities > 0) tree_iterator__rewrite_filename(ti); if (iterator__past_end(ti, ti->entry.path)) { tree_iterator__pop_all(ti, true, false); return GIT_ITEROVER; } ti->entry_is_current = true; return 0; } static int tree_iterator__current_internal( const git_index_entry **entry, git_iterator *self) { int error; tree_iterator *ti = (tree_iterator *)self; tree_iterator_frame *tf = ti->head; iterator__clear_entry(entry); if (tf->current >= tf->n_entries) return GIT_ITEROVER; if ((error = tree_iterator__update_entry(ti)) < 0) return error; if (entry) *entry = &ti->entry; ti->base.flags |= GIT_ITERATOR_FIRST_ACCESS; return 0; } static int tree_iterator__advance_into_internal(git_iterator *self) { int error = 0; tree_iterator *ti = (tree_iterator *)self; if (tree_iterator__at_tree(ti)) error = tree_iterator__push_frame(ti); return error; } static int tree_iterator__advance_internal(git_iterator *self) { int error; tree_iterator *ti = (tree_iterator *)self; tree_iterator_frame *tf = ti->head; if (tf->current >= tf->n_entries) return GIT_ITEROVER; if (!iterator__has_been_accessed(ti)) return 0; if (iterator__do_autoexpand(ti) && iterator__include_trees(ti) && tree_iterator__at_tree(ti)) return tree_iterator__advance_into_internal(self); if (ti->path_has_filename) { git_buf_rtruncate_at_char(&ti->path, '/'); ti->path_has_filename = ti->entry_is_current = false; } /* scan forward and up, advancing in frame or popping frame when done */ while (!tree_iterator__move_to_next(ti, tf) && tree_iterator__pop_frame(ti, false)) tf = ti->head; /* find next and load trees */ if ((error = tree_iterator__set_next(ti, tf)) < 0) return error; /* deal with include_trees / auto_expand as needed */ if (!iterator__include_trees(ti) && tree_iterator__at_tree(ti)) return tree_iterator__advance_into_internal(self); return 0; } static int tree_iterator__current( const git_index_entry **out, git_iterator *self) { const git_index_entry *entry = NULL; iterator_pathlist__match_t m; int error; do { if ((error = tree_iterator__current_internal(&entry, self)) < 0) return error; if (self->pathlist.length) { m = iterator_pathlist__match( self, entry->path, strlen(entry->path)); if (m != ITERATOR_PATHLIST_MATCH) { if ((error = tree_iterator__advance_internal(self)) < 0) return error; entry = NULL; } } } while (!entry); if (out) *out = entry; return error; } static int tree_iterator__advance( const git_index_entry **entry, git_iterator *self) { int error = tree_iterator__advance_internal(self); iterator__clear_entry(entry); if (error < 0) return error; return tree_iterator__current(entry, self); } static int tree_iterator__advance_into( const git_index_entry **entry, git_iterator *self) { int error = tree_iterator__advance_into_internal(self); iterator__clear_entry(entry); if (error < 0) return error; return tree_iterator__current(entry, self); } static int tree_iterator__seek(git_iterator *self, const char *prefix) { GIT_UNUSED(self); GIT_UNUSED(prefix); return -1; } static int tree_iterator__reset( git_iterator *self, const char *start, const char *end) { tree_iterator *ti = (tree_iterator *)self; tree_iterator__pop_all(ti, false, false); if (iterator__reset_range(self, start, end) < 0) return -1; return tree_iterator__push_frame(ti); /* re-expand root tree */ } static int tree_iterator__at_end(git_iterator *self) { tree_iterator *ti = (tree_iterator *)self; return (ti->head->current >= ti->head->n_entries); } static void tree_iterator__free(git_iterator *self) { tree_iterator *ti = (tree_iterator *)self; tree_iterator__pop_all(ti, true, false); git_tree_free(ti->head->entries[0]->tree); git__free(ti->head); git_pool_clear(&ti->pool); git_buf_free(&ti->path); } static int tree_iterator__create_root_frame(tree_iterator *ti, git_tree *tree) { size_t sz = sizeof(tree_iterator_frame) + sizeof(tree_iterator_entry); tree_iterator_frame *root = git__calloc(sz, sizeof(char)); GITERR_CHECK_ALLOC(root); root->n_entries = 1; root->next = 1; root->start = ti->base.start; root->startlen = root->start ? strlen(root->start) : 0; root->entries[0] = git_pool_mallocz(&ti->pool, 1); GITERR_CHECK_ALLOC(root->entries[0]); root->entries[0]->tree = tree; ti->head = ti->root = root; return 0; } int git_iterator_for_tree( git_iterator **iter, git_tree *tree, git_iterator_options *options) { int error; tree_iterator *ti; if (tree == NULL) return git_iterator_for_nothing(iter, options); if ((error = git_object_dup((git_object **)&tree, (git_object *)tree)) < 0) return error; ti = git__calloc(1, sizeof(tree_iterator)); GITERR_CHECK_ALLOC(ti); ITERATOR_BASE_INIT(ti, tree, TREE, git_tree_owner(tree)); if ((error = iterator__update_ignore_case((git_iterator *)ti, options ? options->flags : 0)) < 0) goto fail; if ((error = git_pool_init(&ti->pool, sizeof(tree_iterator_entry),0)) < 0 || (error = tree_iterator__create_root_frame(ti, tree)) < 0 || (error = tree_iterator__push_frame(ti)) < 0) /* expand root now */ goto fail; *iter = (git_iterator *)ti; return 0; fail: git_iterator_free((git_iterator *)ti); return error; } typedef struct { git_iterator base; git_iterator_callbacks cb; git_index *index; git_vector entries; git_vector_cmp entry_srch; size_t current; /* when limiting with a pathlist, this is the current index into it */ size_t pathlist_idx; /* when not in autoexpand mode, use these to represent "tree" state */ git_buf partial; size_t partial_pos; char restore_terminator; git_index_entry tree_entry; } index_iterator; static const git_index_entry *index_iterator__index_entry(index_iterator *ii) { const git_index_entry *ie = git_vector_get(&ii->entries, ii->current); if (ie != NULL && iterator__past_end(ii, ie->path)) { ii->current = git_vector_length(&ii->entries); ie = NULL; } return ie; } static const git_index_entry *index_iterator__advance_over_unwanted( index_iterator *ii) { const git_index_entry *ie = index_iterator__index_entry(ii); bool match; while (ie) { if (!iterator__include_conflicts(ii) && git_index_entry_is_conflict(ie)) { ii->current++; ie = index_iterator__index_entry(ii); continue; } /* if we have a pathlist, this entry's path must be in it to be * returned. walk the pathlist in unison with the index to * compare paths. */ if (ii->base.pathlist.length) { match = iterator_pathlist_walk__contains(&ii->base, ie->path); if (!match) { ii->current++; ie = index_iterator__index_entry(ii); continue; } } break; } return ie; } static void index_iterator__next_prefix_tree(index_iterator *ii) { const char *slash; if (!iterator__include_trees(ii)) return; slash = strchr(&ii->partial.ptr[ii->partial_pos], '/'); if (slash != NULL) { ii->partial_pos = (slash - ii->partial.ptr) + 1; ii->restore_terminator = ii->partial.ptr[ii->partial_pos]; ii->partial.ptr[ii->partial_pos] = '\0'; } else { ii->partial_pos = ii->partial.size; } if (index_iterator__index_entry(ii) == NULL) ii->partial_pos = ii->partial.size; } static int index_iterator__first_prefix_tree(index_iterator *ii) { const git_index_entry *ie = index_iterator__advance_over_unwanted(ii); const char *scan, *prior, *slash; if (!ie || !iterator__include_trees(ii)) return 0; /* find longest common prefix with prior index entry */ for (scan = slash = ie->path, prior = ii->partial.ptr; *scan && *scan == *prior; ++scan, ++prior) if (*scan == '/') slash = scan; if (git_buf_sets(&ii->partial, ie->path) < 0) return -1; ii->partial_pos = (slash - ie->path) + 1; index_iterator__next_prefix_tree(ii); return 0; } #define index_iterator__at_tree(I) \ (iterator__include_trees(I) && (I)->partial_pos < (I)->partial.size) static int index_iterator__current( const git_index_entry **entry, git_iterator *self) { index_iterator *ii = (index_iterator *)self; const git_index_entry *ie = git_vector_get(&ii->entries, ii->current); if (ie != NULL && index_iterator__at_tree(ii)) { ii->tree_entry.path = ii->partial.ptr; ie = &ii->tree_entry; } if (entry) *entry = ie; ii->base.flags |= GIT_ITERATOR_FIRST_ACCESS; return (ie != NULL) ? 0 : GIT_ITEROVER; } static int index_iterator__at_end(git_iterator *self) { index_iterator *ii = (index_iterator *)self; return (ii->current >= git_vector_length(&ii->entries)); } static int index_iterator__advance( const git_index_entry **entry, git_iterator *self) { index_iterator *ii = (index_iterator *)self; size_t entrycount = git_vector_length(&ii->entries); const git_index_entry *ie; if (!iterator__has_been_accessed(ii)) return index_iterator__current(entry, self); if (index_iterator__at_tree(ii)) { if (iterator__do_autoexpand(ii)) { ii->partial.ptr[ii->partial_pos] = ii->restore_terminator; index_iterator__next_prefix_tree(ii); } else { /* advance to sibling tree (i.e. find entry with new prefix) */ while (ii->current < entrycount) { ii->current++; if (!(ie = git_vector_get(&ii->entries, ii->current)) || ii->base.prefixcomp(ie->path, ii->partial.ptr) != 0) break; } if (index_iterator__first_prefix_tree(ii) < 0) return -1; } } else { if (ii->current < entrycount) ii->current++; if (index_iterator__first_prefix_tree(ii) < 0) return -1; } return index_iterator__current(entry, self); } static int index_iterator__advance_into( const git_index_entry **entry, git_iterator *self) { index_iterator *ii = (index_iterator *)self; const git_index_entry *ie = git_vector_get(&ii->entries, ii->current); if (ie != NULL && index_iterator__at_tree(ii)) { if (ii->restore_terminator) ii->partial.ptr[ii->partial_pos] = ii->restore_terminator; index_iterator__next_prefix_tree(ii); } return index_iterator__current(entry, self); } static int index_iterator__seek(git_iterator *self, const char *prefix) { GIT_UNUSED(self); GIT_UNUSED(prefix); return -1; } static int index_iterator__reset( git_iterator *self, const char *start, const char *end) { index_iterator *ii = (index_iterator *)self; const git_index_entry *ie; if (iterator__reset_range(self, start, end) < 0) return -1; ii->current = 0; iterator_pathlist_walk__reset(self); /* if we're given a start prefix, find it; if we're given a pathlist, find * the first of those. start at the later of the two. */ if (ii->base.start) git_index_snapshot_find( &ii->current, &ii->entries, ii->entry_srch, ii->base.start, 0, 0); if ((ie = index_iterator__advance_over_unwanted(ii)) == NULL) return 0; if (git_buf_sets(&ii->partial, ie->path) < 0) return -1; ii->partial_pos = 0; if (ii->base.start) { size_t startlen = strlen(ii->base.start); ii->partial_pos = (startlen > ii->partial.size) ? ii->partial.size : startlen; } index_iterator__next_prefix_tree(ii); return 0; } static void index_iterator__free(git_iterator *self) { index_iterator *ii = (index_iterator *)self; git_index_snapshot_release(&ii->entries, ii->index); ii->index = NULL; git_buf_free(&ii->partial); } int git_iterator_for_index( git_iterator **iter, git_index *index, git_iterator_options *options) { int error = 0; index_iterator *ii = git__calloc(1, sizeof(index_iterator)); GITERR_CHECK_ALLOC(ii); if ((error = git_index_snapshot_new(&ii->entries, index)) < 0) { git__free(ii); return error; } ii->index = index; ITERATOR_BASE_INIT(ii, index, INDEX, git_index_owner(index)); if ((error = iterator__update_ignore_case((git_iterator *)ii, options ? options->flags : 0)) < 0) { git_iterator_free((git_iterator *)ii); return error; } ii->entry_srch = iterator__ignore_case(ii) ? git_index_entry_isrch : git_index_entry_srch; git_vector_set_cmp(&ii->entries, iterator__ignore_case(ii) ? git_index_entry_icmp : git_index_entry_cmp); git_vector_sort(&ii->entries); git_buf_init(&ii->partial, 0); ii->tree_entry.mode = GIT_FILEMODE_TREE; index_iterator__reset((git_iterator *)ii, NULL, NULL); *iter = (git_iterator *)ii; return 0; } typedef struct fs_iterator_frame fs_iterator_frame; struct fs_iterator_frame { fs_iterator_frame *next; git_vector entries; size_t index; int is_ignored; }; typedef struct fs_iterator fs_iterator; struct fs_iterator { git_iterator base; git_iterator_callbacks cb; fs_iterator_frame *stack; git_index_entry entry; git_buf path; size_t root_len; uint32_t dirload_flags; int depth; iterator_pathlist__match_t pathlist_match; int (*enter_dir_cb)(fs_iterator *self); int (*leave_dir_cb)(fs_iterator *self); int (*update_entry_cb)(fs_iterator *self); }; #define FS_MAX_DEPTH 100 typedef struct { struct stat st; iterator_pathlist__match_t pathlist_match; size_t path_len; char path[GIT_FLEX_ARRAY]; } fs_iterator_path_with_stat; static int fs_iterator_path_with_stat_cmp(const void *a, const void *b) { const fs_iterator_path_with_stat *psa = a, *psb = b; return strcmp(psa->path, psb->path); } static int fs_iterator_path_with_stat_cmp_icase(const void *a, const void *b) { const fs_iterator_path_with_stat *psa = a, *psb = b; return strcasecmp(psa->path, psb->path); } static fs_iterator_frame *fs_iterator__alloc_frame(fs_iterator *fi) { fs_iterator_frame *ff = git__calloc(1, sizeof(fs_iterator_frame)); git_vector_cmp entry_compare = CASESELECT( iterator__ignore_case(fi), fs_iterator_path_with_stat_cmp_icase, fs_iterator_path_with_stat_cmp); if (ff && git_vector_init(&ff->entries, 0, entry_compare) < 0) { git__free(ff); ff = NULL; } return ff; } static void fs_iterator__free_frame(fs_iterator_frame *ff) { git_vector_free_deep(&ff->entries); git__free(ff); } static void fs_iterator__pop_frame( fs_iterator *fi, fs_iterator_frame *ff, bool pop_last) { if (fi && fi->stack == ff) { if (!ff->next && !pop_last) { memset(&fi->entry, 0, sizeof(fi->entry)); return; } if (fi->leave_dir_cb) (void)fi->leave_dir_cb(fi); fi->stack = ff->next; fi->depth--; } fs_iterator__free_frame(ff); } static int fs_iterator__update_entry(fs_iterator *fi); static int fs_iterator__advance_over( const git_index_entry **entry, git_iterator *self); static int fs_iterator__entry_cmp(const void *i, const void *item) { const fs_iterator *fi = (const fs_iterator *)i; const fs_iterator_path_with_stat *ps = item; return fi->base.prefixcomp(fi->base.start, ps->path); } static void fs_iterator__seek_frame_start( fs_iterator *fi, fs_iterator_frame *ff) { if (!ff) return; if (fi->base.start) git_vector_bsearch2( &ff->index, &ff->entries, fs_iterator__entry_cmp, fi); else ff->index = 0; } static int dirload_with_stat(git_vector *contents, fs_iterator *fi) { git_path_diriter diriter = GIT_PATH_DIRITER_INIT; const char *path; size_t start_len = fi->base.start ? strlen(fi->base.start) : 0; size_t end_len = fi->base.end ? strlen(fi->base.end) : 0; fs_iterator_path_with_stat *ps; size_t path_len, cmp_len, ps_size; iterator_pathlist__match_t pathlist_match = ITERATOR_PATHLIST_MATCH; int error; /* Any error here is equivalent to the dir not existing, skip over it */ if ((error = git_path_diriter_init( &diriter, fi->path.ptr, fi->dirload_flags)) < 0) { error = GIT_ENOTFOUND; goto done; } while ((error = git_path_diriter_next(&diriter)) == 0) { if ((error = git_path_diriter_fullpath(&path, &path_len, &diriter)) < 0) goto done; assert(path_len > fi->root_len); /* remove the prefix if requested */ path += fi->root_len; path_len -= fi->root_len; /* skip if before start_stat or after end_stat */ cmp_len = min(start_len, path_len); if (cmp_len && fi->base.strncomp(path, fi->base.start, cmp_len) < 0) continue; /* skip if after end_stat */ cmp_len = min(end_len, path_len); if (cmp_len && fi->base.strncomp(path, fi->base.end, cmp_len) > 0) continue; /* if we have a pathlist that we're limiting to, examine this path. * if the frame has already deemed us inside the path (eg, we're in * `foo/bar` and the pathlist previously was detected to say `foo/`) * then simply continue. otherwise, examine the pathlist looking for * this path or children of this path. */ if (fi->base.pathlist.length && fi->pathlist_match != ITERATOR_PATHLIST_MATCH && fi->pathlist_match != ITERATOR_PATHLIST_MATCH_DIRECTORY && !(pathlist_match = iterator_pathlist__match(&fi->base, path, path_len))) continue; /* Make sure to append two bytes, one for the path's null * termination, one for a possible trailing '/' for folders. */ GITERR_CHECK_ALLOC_ADD(&ps_size, sizeof(fs_iterator_path_with_stat), path_len); GITERR_CHECK_ALLOC_ADD(&ps_size, ps_size, 2); ps = git__calloc(1, ps_size); ps->path_len = path_len; memcpy(ps->path, path, path_len); /* TODO: don't stat if assume unchanged for this path */ if ((error = git_path_diriter_stat(&ps->st, &diriter)) < 0) { if (error == GIT_ENOTFOUND) { /* file was removed between readdir and lstat */ git__free(ps); continue; } if (pathlist_match == ITERATOR_PATHLIST_MATCH_DIRECTORY) { /* were looking for a directory, but this is a file */ git__free(ps); continue; } /* Treat the file as unreadable if we get any other error */ memset(&ps->st, 0, sizeof(ps->st)); ps->st.st_mode = GIT_FILEMODE_UNREADABLE; giterr_clear(); error = 0; } else if (S_ISDIR(ps->st.st_mode)) { /* Suffix directory paths with a '/' */ ps->path[ps->path_len++] = '/'; ps->path[ps->path_len] = '\0'; } else if(!S_ISREG(ps->st.st_mode) && !S_ISLNK(ps->st.st_mode)) { /* Ignore wacky things in the filesystem */ git__free(ps); continue; } /* record whether this path was explicitly found in the path list * or whether we're only examining it because something beneath it * is in the path list. */ ps->pathlist_match = pathlist_match; git_vector_insert(contents, ps); } if (error == GIT_ITEROVER) error = 0; /* sort now that directory suffix is added */ git_vector_sort(contents); done: git_path_diriter_free(&diriter); return error; } static int fs_iterator__expand_dir(fs_iterator *fi) { int error; fs_iterator_frame *ff; if (fi->depth > FS_MAX_DEPTH) { giterr_set(GITERR_REPOSITORY, "Directory nesting is too deep (%d)", fi->depth); return -1; } ff = fs_iterator__alloc_frame(fi); GITERR_CHECK_ALLOC(ff); error = dirload_with_stat(&ff->entries, fi); if (error < 0) { git_error_state last_error = { 0 }; giterr_state_capture(&last_error, error); /* these callbacks may clear the error message */ fs_iterator__free_frame(ff); fs_iterator__advance_over(NULL, (git_iterator *)fi); /* next time return value we skipped to */ fi->base.flags &= ~GIT_ITERATOR_FIRST_ACCESS; return giterr_state_restore(&last_error); } if (ff->entries.length == 0) { fs_iterator__free_frame(ff); return GIT_ENOTFOUND; } fi->base.stat_calls += ff->entries.length; fs_iterator__seek_frame_start(fi, ff); ff->next = fi->stack; fi->stack = ff; fi->depth++; if (fi->enter_dir_cb && (error = fi->enter_dir_cb(fi)) < 0) return error; return fs_iterator__update_entry(fi); } static int fs_iterator__current( const git_index_entry **entry, git_iterator *self) { fs_iterator *fi = (fs_iterator *)self; const git_index_entry *fe = (fi->entry.path == NULL) ? NULL : &fi->entry; if (entry) *entry = fe; fi->base.flags |= GIT_ITERATOR_FIRST_ACCESS; return (fe != NULL) ? 0 : GIT_ITEROVER; } static int fs_iterator__at_end(git_iterator *self) { return (((fs_iterator *)self)->entry.path == NULL); } static int fs_iterator__advance_into( const git_index_entry **entry, git_iterator *iter) { int error = 0; fs_iterator *fi = (fs_iterator *)iter; iterator__clear_entry(entry); /* Allow you to explicitly advance into a commit/submodule (as well as a * tree) to avoid cases where an entry is mislabeled as a submodule in * the working directory. The fs iterator will never have COMMMIT * entries on it's own, but a wrapper might add them. */ if (fi->entry.path != NULL && (fi->entry.mode == GIT_FILEMODE_TREE || fi->entry.mode == GIT_FILEMODE_COMMIT)) /* returns GIT_ENOTFOUND if the directory is empty */ error = fs_iterator__expand_dir(fi); if (!error && entry) error = fs_iterator__current(entry, iter); if (!error && !fi->entry.path) error = GIT_ITEROVER; return error; } static void fs_iterator__advance_over_internal(git_iterator *self) { fs_iterator *fi = (fs_iterator *)self; fs_iterator_frame *ff; fs_iterator_path_with_stat *next; while (fi->entry.path != NULL) { ff = fi->stack; next = git_vector_get(&ff->entries, ++ff->index); if (next != NULL) break; fs_iterator__pop_frame(fi, ff, false); } } static int fs_iterator__advance_over( const git_index_entry **entry, git_iterator *self) { int error; if (entry != NULL) *entry = NULL; fs_iterator__advance_over_internal(self); error = fs_iterator__update_entry((fs_iterator *)self); if (!error && entry != NULL) error = fs_iterator__current(entry, self); return error; } static int fs_iterator__advance( const git_index_entry **entry, git_iterator *self) { fs_iterator *fi = (fs_iterator *)self; if (!iterator__has_been_accessed(fi)) return fs_iterator__current(entry, self); /* given include_trees & autoexpand, we might have to go into a tree */ if (iterator__do_autoexpand(fi) && fi->entry.path != NULL && fi->entry.mode == GIT_FILEMODE_TREE) { int error = fs_iterator__advance_into(entry, self); if (error != GIT_ENOTFOUND) return error; /* continue silently past empty directories if autoexpanding */ giterr_clear(); } return fs_iterator__advance_over(entry, self); } static int fs_iterator__seek(git_iterator *self, const char *prefix) { GIT_UNUSED(self); GIT_UNUSED(prefix); /* pop stack until matching prefix */ /* find prefix item in current frame */ /* push subdirectories as deep as possible while matching */ return 0; } static int fs_iterator__reset( git_iterator *self, const char *start, const char *end) { int error; fs_iterator *fi = (fs_iterator *)self; while (fi->stack != NULL && fi->stack->next != NULL) fs_iterator__pop_frame(fi, fi->stack, false); fi->depth = 0; if ((error = iterator__reset_range(self, start, end)) < 0) return error; fs_iterator__seek_frame_start(fi, fi->stack); error = fs_iterator__update_entry(fi); if (error == GIT_ITEROVER) error = 0; return error; } static void fs_iterator__free(git_iterator *self) { fs_iterator *fi = (fs_iterator *)self; while (fi->stack != NULL) fs_iterator__pop_frame(fi, fi->stack, true); git_buf_free(&fi->path); } static int fs_iterator__update_entry(fs_iterator *fi) { fs_iterator_path_with_stat *ps; while (true) { memset(&fi->entry, 0, sizeof(fi->entry)); if (!fi->stack) return GIT_ITEROVER; ps = git_vector_get(&fi->stack->entries, fi->stack->index); if (!ps) return GIT_ITEROVER; git_buf_truncate(&fi->path, fi->root_len); if (git_buf_put(&fi->path, ps->path, ps->path_len) < 0) return -1; if (iterator__past_end(fi, fi->path.ptr + fi->root_len)) return GIT_ITEROVER; fi->entry.path = ps->path; fi->pathlist_match = ps->pathlist_match; git_index_entry__init_from_stat(&fi->entry, &ps->st, true); /* need different mode here to keep directories during iteration */ fi->entry.mode = git_futils_canonical_mode(ps->st.st_mode); /* allow wrapper to check/update the entry (can force skip) */ if (fi->update_entry_cb && fi->update_entry_cb(fi) == GIT_ENOTFOUND) { fs_iterator__advance_over_internal(&fi->base); continue; } /* if this is a tree and trees aren't included, then skip */ if (fi->entry.mode == GIT_FILEMODE_TREE && !iterator__include_trees(fi)) { int error = fs_iterator__advance_into(NULL, &fi->base); if (error != GIT_ENOTFOUND) return error; giterr_clear(); fs_iterator__advance_over_internal(&fi->base); continue; } break; } return 0; } static int fs_iterator__initialize( git_iterator **out, fs_iterator *fi, const char *root) { int error; if (git_buf_sets(&fi->path, root) < 0 || git_path_to_dir(&fi->path) < 0) { git__free(fi); return -1; } fi->root_len = fi->path.size; fi->pathlist_match = ITERATOR_PATHLIST_MATCH_CHILD; fi->dirload_flags = (iterator__ignore_case(fi) ? GIT_PATH_DIR_IGNORE_CASE : 0) | (iterator__flag(fi, PRECOMPOSE_UNICODE) ? GIT_PATH_DIR_PRECOMPOSE_UNICODE : 0); if ((error = fs_iterator__expand_dir(fi)) < 0) { if (error == GIT_ENOTFOUND || error == GIT_ITEROVER) { giterr_clear(); error = 0; } else { git_iterator_free((git_iterator *)fi); fi = NULL; } } *out = (git_iterator *)fi; return error; } int git_iterator_for_filesystem( git_iterator **out, const char *root, git_iterator_options *options) { fs_iterator *fi = git__calloc(1, sizeof(fs_iterator)); GITERR_CHECK_ALLOC(fi); ITERATOR_BASE_INIT(fi, fs, FS, NULL); if (options && (options->flags & GIT_ITERATOR_IGNORE_CASE) != 0) fi->base.flags |= GIT_ITERATOR_IGNORE_CASE; return fs_iterator__initialize(out, fi, root); } typedef struct { fs_iterator fi; git_ignores ignores; int is_ignored; /* * We may have a tree or the index+snapshot to compare against * when checking for submodules. */ git_tree *tree; git_index *index; git_vector index_snapshot; git_vector_cmp entry_srch; } workdir_iterator; GIT_INLINE(bool) workdir_path_is_dotgit(const git_buf *path) { size_t len; if (!path || (len = path->size) < 4) return false; if (path->ptr[len - 1] == '/') len--; if (git__tolower(path->ptr[len - 1]) != 't' || git__tolower(path->ptr[len - 2]) != 'i' || git__tolower(path->ptr[len - 3]) != 'g' || git__tolower(path->ptr[len - 4]) != '.') return false; return (len == 4 || path->ptr[len - 5] == '/'); } /** * Figure out if an entry is a submodule. * * We consider it a submodule if the path is listed as a submodule in * either the tree or the index. */ static int is_submodule(workdir_iterator *wi, fs_iterator_path_with_stat *ie) { int error, is_submodule = 0; if (wi->tree) { git_tree_entry *e; /* remove the trailing slash for finding */ ie->path[ie->path_len-1] = '\0'; error = git_tree_entry_bypath(&e, wi->tree, ie->path); ie->path[ie->path_len-1] = '/'; if (error < 0 && error != GIT_ENOTFOUND) return 0; if (!error) { is_submodule = e->attr == GIT_FILEMODE_COMMIT; git_tree_entry_free(e); } } if (!is_submodule && wi->index) { git_index_entry *e; size_t pos; error = git_index_snapshot_find(&pos, &wi->index_snapshot, wi->entry_srch, ie->path, ie->path_len-1, 0); if (error < 0 && error != GIT_ENOTFOUND) return 0; if (!error) { e = git_vector_get(&wi->index_snapshot, pos); is_submodule = e->mode == GIT_FILEMODE_COMMIT; } } return is_submodule; } GIT_INLINE(git_dir_flag) git_entry__dir_flag(git_index_entry *entry) { #if defined(GIT_WIN32) && !defined(__MINGW32__) return (entry && entry->mode) ? S_ISDIR(entry->mode) ? GIT_DIR_FLAG_TRUE : GIT_DIR_FLAG_FALSE : GIT_DIR_FLAG_UNKNOWN; #else GIT_UNUSED(entry); return GIT_DIR_FLAG_UNKNOWN; #endif } static int workdir_iterator__enter_dir(fs_iterator *fi) { workdir_iterator *wi = (workdir_iterator *)fi; fs_iterator_frame *ff = fi->stack; size_t pos; fs_iterator_path_with_stat *entry; bool found_submodules = false; git_dir_flag dir_flag = git_entry__dir_flag(&fi->entry); /* check if this directory is ignored */ if (git_ignore__lookup(&ff->is_ignored, &wi->ignores, fi->path.ptr + fi->root_len, dir_flag) < 0) { giterr_clear(); ff->is_ignored = GIT_IGNORE_NOTFOUND; } /* if this is not the top level directory... */ if (ff->next != NULL) { ssize_t slash_pos = git_buf_rfind_next(&fi->path, '/'); /* inherit ignored from parent if no rule specified */ if (ff->is_ignored <= GIT_IGNORE_NOTFOUND) ff->is_ignored = ff->next->is_ignored; /* push new ignores for files in this directory */ (void)git_ignore__push_dir(&wi->ignores, &fi->path.ptr[slash_pos + 1]); } /* convert submodules to GITLINK and remove trailing slashes */ git_vector_foreach(&ff->entries, pos, entry) { if (!S_ISDIR(entry->st.st_mode) || !strcmp(GIT_DIR, entry->path)) continue; if (is_submodule(wi, entry)) { entry->st.st_mode = GIT_FILEMODE_COMMIT; entry->path_len--; entry->path[entry->path_len] = '\0'; found_submodules = true; } } /* if we renamed submodules, re-sort and re-seek to start */ if (found_submodules) { git_vector_set_sorted(&ff->entries, 0); git_vector_sort(&ff->entries); fs_iterator__seek_frame_start(fi, ff); } return 0; } static int workdir_iterator__leave_dir(fs_iterator *fi) { workdir_iterator *wi = (workdir_iterator *)fi; git_ignore__pop_dir(&wi->ignores); return 0; } static int workdir_iterator__update_entry(fs_iterator *fi) { workdir_iterator *wi = (workdir_iterator *)fi; /* skip over .git entries */ if (workdir_path_is_dotgit(&fi->path)) return GIT_ENOTFOUND; /* reset is_ignored since we haven't checked yet */ wi->is_ignored = GIT_IGNORE_UNCHECKED; return 0; } static void workdir_iterator__free(git_iterator *self) { workdir_iterator *wi = (workdir_iterator *)self; if (wi->index) git_index_snapshot_release(&wi->index_snapshot, wi->index); git_tree_free(wi->tree); fs_iterator__free(self); git_ignore__free(&wi->ignores); } int git_iterator_for_workdir_ext( git_iterator **out, git_repository *repo, const char *repo_workdir, git_index *index, git_tree *tree, git_iterator_options *options) { int error, precompose = 0; workdir_iterator *wi; if (!repo_workdir) { if (git_repository__ensure_not_bare(repo, "scan working directory") < 0) return GIT_EBAREREPO; repo_workdir = git_repository_workdir(repo); } /* initialize as an fs iterator then do overrides */ wi = git__calloc(1, sizeof(workdir_iterator)); GITERR_CHECK_ALLOC(wi); ITERATOR_BASE_INIT((&wi->fi), fs, FS, repo); wi->fi.base.type = GIT_ITERATOR_TYPE_WORKDIR; wi->fi.cb.free = workdir_iterator__free; wi->fi.enter_dir_cb = workdir_iterator__enter_dir; wi->fi.leave_dir_cb = workdir_iterator__leave_dir; wi->fi.update_entry_cb = workdir_iterator__update_entry; if ((error = iterator__update_ignore_case((git_iterator *)wi, options ? options->flags : 0)) < 0 || (error = git_ignore__for_path(repo, ".gitignore", &wi->ignores)) < 0) { git_iterator_free((git_iterator *)wi); return error; } if (tree && (error = git_object_dup((git_object **)&wi->tree, (git_object *)tree)) < 0) return error; wi->index = index; if (index && (error = git_index_snapshot_new(&wi->index_snapshot, index)) < 0) { git_iterator_free((git_iterator *)wi); return error; } wi->entry_srch = iterator__ignore_case(wi) ? git_index_entry_isrch : git_index_entry_srch; /* try to look up precompose and set flag if appropriate */ if (git_repository__cvar(&precompose, repo, GIT_CVAR_PRECOMPOSE) < 0) giterr_clear(); else if (precompose) wi->fi.base.flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE; return fs_iterator__initialize(out, &wi->fi, repo_workdir); } void git_iterator_free(git_iterator *iter) { if (iter == NULL) return; iter->cb->free(iter); git_vector_free(&iter->pathlist); git__free(iter->start); git__free(iter->end); memset(iter, 0, sizeof(*iter)); git__free(iter); } int git_iterator_set_ignore_case(git_iterator *iter, bool ignore_case) { bool desire_ignore_case = (ignore_case != 0); if (iterator__ignore_case(iter) == desire_ignore_case) return 0; if (iter->type == GIT_ITERATOR_TYPE_EMPTY) { if (desire_ignore_case) iter->flags |= GIT_ITERATOR_IGNORE_CASE; else iter->flags &= ~GIT_ITERATOR_IGNORE_CASE; } else { giterr_set(GITERR_INVALID, "Cannot currently set ignore case on non-empty iterators"); return -1; } return 0; } git_index *git_iterator_get_index(git_iterator *iter) { if (iter->type == GIT_ITERATOR_TYPE_INDEX) return ((index_iterator *)iter)->index; return NULL; } int git_iterator_current_tree_entry( const git_tree_entry **tree_entry, git_iterator *iter) { if (iter->type != GIT_ITERATOR_TYPE_TREE) *tree_entry = NULL; else { tree_iterator_frame *tf = ((tree_iterator *)iter)->head; *tree_entry = (tf->current < tf->n_entries) ? tf->entries[tf->current]->te : NULL; } return 0; } int git_iterator_current_parent_tree( const git_tree **tree_ptr, git_iterator *iter, const char *parent_path) { tree_iterator *ti = (tree_iterator *)iter; tree_iterator_frame *tf; const char *scan = parent_path; const git_tree_entry *te; *tree_ptr = NULL; if (iter->type != GIT_ITERATOR_TYPE_TREE) return 0; for (tf = ti->root; *scan; ) { if (!(tf = tf->down) || tf->current >= tf->n_entries || !(te = tf->entries[tf->current]->te) || ti->base.strncomp(scan, te->filename, te->filename_len) != 0) return 0; scan += te->filename_len; if (*scan == '/') scan++; } *tree_ptr = tf->entries[tf->current]->tree; return 0; } static void workdir_iterator_update_is_ignored(workdir_iterator *wi) { git_dir_flag dir_flag = git_entry__dir_flag(&wi->fi.entry); if (git_ignore__lookup(&wi->is_ignored, &wi->ignores, wi->fi.entry.path, dir_flag) < 0) { giterr_clear(); wi->is_ignored = GIT_IGNORE_NOTFOUND; } /* use ignore from containing frame stack */ if (wi->is_ignored <= GIT_IGNORE_NOTFOUND) wi->is_ignored = wi->fi.stack->is_ignored; } bool git_iterator_current_is_ignored(git_iterator *iter) { workdir_iterator *wi = (workdir_iterator *)iter; if (iter->type != GIT_ITERATOR_TYPE_WORKDIR) return false; if (wi->is_ignored != GIT_IGNORE_UNCHECKED) return (bool)(wi->is_ignored == GIT_IGNORE_TRUE); workdir_iterator_update_is_ignored(wi); return (bool)(wi->is_ignored == GIT_IGNORE_TRUE); } bool git_iterator_current_tree_is_ignored(git_iterator *iter) { workdir_iterator *wi = (workdir_iterator *)iter; if (iter->type != GIT_ITERATOR_TYPE_WORKDIR) return false; return (bool)(wi->fi.stack->is_ignored == GIT_IGNORE_TRUE); } int git_iterator_cmp(git_iterator *iter, const char *path_prefix) { const git_index_entry *entry; /* a "done" iterator is after every prefix */ if (git_iterator_current(&entry, iter) < 0 || entry == NULL) return 1; /* a NULL prefix is after any valid iterator */ if (!path_prefix) return -1; return iter->prefixcomp(entry->path, path_prefix); } int git_iterator_current_workdir_path(git_buf **path, git_iterator *iter) { workdir_iterator *wi = (workdir_iterator *)iter; if (iter->type != GIT_ITERATOR_TYPE_WORKDIR || !wi->fi.entry.path) *path = NULL; else *path = &wi->fi.path; return 0; } int git_iterator_index(git_index **out, git_iterator *iter) { workdir_iterator *wi = (workdir_iterator *)iter; if (iter->type != GIT_ITERATOR_TYPE_WORKDIR) *out = NULL; *out = wi->index; return 0; } int git_iterator_advance_over_with_status( const git_index_entry **entryptr, git_iterator_status_t *status, git_iterator *iter) { int error = 0; workdir_iterator *wi = (workdir_iterator *)iter; char *base = NULL; const git_index_entry *entry; *status = GIT_ITERATOR_STATUS_NORMAL; if (iter->type != GIT_ITERATOR_TYPE_WORKDIR) return git_iterator_advance(entryptr, iter); if ((error = git_iterator_current(&entry, iter)) < 0) return error; if (!S_ISDIR(entry->mode)) { workdir_iterator_update_is_ignored(wi); if (wi->is_ignored == GIT_IGNORE_TRUE) *status = GIT_ITERATOR_STATUS_IGNORED; return git_iterator_advance(entryptr, iter); } *status = GIT_ITERATOR_STATUS_EMPTY; base = git__strdup(entry->path); GITERR_CHECK_ALLOC(base); /* scan inside directory looking for a non-ignored item */ while (entry && !iter->prefixcomp(entry->path, base)) { workdir_iterator_update_is_ignored(wi); /* if we found an explicitly ignored item, then update from * EMPTY to IGNORED */ if (wi->is_ignored == GIT_IGNORE_TRUE) *status = GIT_ITERATOR_STATUS_IGNORED; else if (S_ISDIR(entry->mode)) { error = git_iterator_advance_into(&entry, iter); if (!error) continue; else if (error == GIT_ENOTFOUND) { /* we entered this directory only hoping to find child matches to * our pathlist (eg, this is `foo` and we had a pathlist entry for * `foo/bar`). it should not be ignored, it should be excluded. */ if (wi->fi.pathlist_match == ITERATOR_PATHLIST_MATCH_CHILD) *status = GIT_ITERATOR_STATUS_FILTERED; else wi->is_ignored = GIT_IGNORE_TRUE; /* mark empty dirs ignored */ error = 0; } else break; /* real error, stop here */ } else { /* we found a non-ignored item, treat parent as untracked */ *status = GIT_ITERATOR_STATUS_NORMAL; break; } if ((error = git_iterator_advance(&entry, iter)) < 0) break; } /* wrap up scan back to base directory */ while (entry && !iter->prefixcomp(entry->path, base)) if ((error = git_iterator_advance(&entry, iter)) < 0) break; *entryptr = entry; git__free(base); return error; } int git_iterator_walk( git_iterator **iterators, size_t cnt, git_iterator_walk_cb cb, void *data) { const git_index_entry **iterator_item; /* next in each iterator */ const git_index_entry **cur_items; /* current path in each iter */ const git_index_entry *first_match; size_t i, j; int error = 0; iterator_item = git__calloc(cnt, sizeof(git_index_entry *)); cur_items = git__calloc(cnt, sizeof(git_index_entry *)); GITERR_CHECK_ALLOC(iterator_item); GITERR_CHECK_ALLOC(cur_items); /* Set up the iterators */ for (i = 0; i < cnt; i++) { error = git_iterator_current(&iterator_item[i], iterators[i]); if (error < 0 && error != GIT_ITEROVER) goto done; } while (true) { for (i = 0; i < cnt; i++) cur_items[i] = NULL; first_match = NULL; /* Find the next path(s) to consume from each iterator */ for (i = 0; i < cnt; i++) { if (iterator_item[i] == NULL) continue; if (first_match == NULL) { first_match = iterator_item[i]; cur_items[i] = iterator_item[i]; } else { int path_diff = git_index_entry_cmp(iterator_item[i], first_match); if (path_diff < 0) { /* Found an index entry that sorts before the one we're * looking at. Forget that we've seen the other and * look at the other iterators for this path. */ for (j = 0; j < i; j++) cur_items[j] = NULL; first_match = iterator_item[i]; cur_items[i] = iterator_item[i]; } else if (path_diff == 0) { cur_items[i] = iterator_item[i]; } } } if (first_match == NULL) break; if ((error = cb(cur_items, data)) != 0) goto done; /* Advance each iterator that participated */ for (i = 0; i < cnt; i++) { if (cur_items[i] == NULL) continue; error = git_iterator_advance(&iterator_item[i], iterators[i]); if (error < 0 && error != GIT_ITEROVER) goto done; } } done: git__free((git_index_entry **)iterator_item); git__free((git_index_entry **)cur_items); if (error == GIT_ITEROVER) error = 0; return error; } deps/libgit2-sys-0.3.8/libgit2/src/strnlen.h0000664000175000017500000000121312426525445015536 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_strlen_h__ #define INCLUDE_strlen_h__ #if defined(__MINGW32__) || defined(__sun) || defined(__APPLE__) || defined(__MidnightBSD__) ||\ (defined(_MSC_VER) && _MSC_VER < 1500) # define NO_STRNLEN #endif #ifdef NO_STRNLEN GIT_INLINE(size_t) p_strnlen(const char *s, size_t maxlen) { const char *end = memchr(s, 0, maxlen); return end ? (size_t)(end - s) : maxlen; } #else # define p_strnlen strnlen #endif #endif deps/libgit2-sys-0.3.8/libgit2/src/buffer.h0000664000175000017500000001544312555730137015333 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_buffer_h__ #define INCLUDE_buffer_h__ #include "common.h" #include "git2/strarray.h" #include "git2/buffer.h" /* typedef struct { * char *ptr; * size_t asize, size; * } git_buf; */ extern char git_buf__initbuf[]; extern char git_buf__oom[]; /* Use to initialize buffer structure when git_buf is on stack */ #define GIT_BUF_INIT { git_buf__initbuf, 0, 0 } GIT_INLINE(bool) git_buf_is_allocated(const git_buf *buf) { return (buf->ptr != NULL && buf->asize > 0); } /** * Initialize a git_buf structure. * * For the cases where GIT_BUF_INIT cannot be used to do static * initialization. */ extern void git_buf_init(git_buf *buf, size_t initial_size); /** * Resize the buffer allocation to make more space. * * This will attempt to grow the buffer to accommodate the additional size. * It is similar to `git_buf_grow`, but performs the new size calculation, * checking for overflow. * * Like `git_buf_grow`, if this is a user-supplied buffer, this will allocate * a new buffer. */ extern int git_buf_grow_by(git_buf *buffer, size_t additional_size); /** * Attempt to grow the buffer to hold at least `target_size` bytes. * * If the allocation fails, this will return an error. If `mark_oom` is true, * this will mark the buffer as invalid for future operations; if false, * existing buffer content will be preserved, but calling code must handle * that buffer was not expanded. If `preserve_external` is true, then any * existing data pointed to be `ptr` even if `asize` is zero will be copied * into the newly allocated buffer. */ extern int git_buf_try_grow( git_buf *buf, size_t target_size, bool mark_oom); /** * Sanitizes git_buf structures provided from user input. Users of the * library, when providing git_buf's, may wish to provide a NULL ptr for * ease of handling. The buffer routines, however, expect a non-NULL ptr * always. This helper method simply handles NULL input, converting to a * git_buf__initbuf. */ extern void git_buf_sanitize(git_buf *buf); extern void git_buf_swap(git_buf *buf_a, git_buf *buf_b); extern char *git_buf_detach(git_buf *buf); extern void git_buf_attach(git_buf *buf, char *ptr, size_t asize); /* Populates a `git_buf` where the contents are not "owned" by the * buffer, and calls to `git_buf_free` will not free the given buf. */ extern void git_buf_attach_notowned( git_buf *buf, const char *ptr, size_t size); /** * Test if there have been any reallocation failures with this git_buf. * * Any function that writes to a git_buf can fail due to memory allocation * issues. If one fails, the git_buf will be marked with an OOM error and * further calls to modify the buffer will fail. Check git_buf_oom() at the * end of your sequence and it will be true if you ran out of memory at any * point with that buffer. * * @return false if no error, true if allocation error */ GIT_INLINE(bool) git_buf_oom(const git_buf *buf) { return (buf->ptr == git_buf__oom); } /* * Functions below that return int value error codes will return 0 on * success or -1 on failure (which generally means an allocation failed). * Using a git_buf where the allocation has failed with result in -1 from * all further calls using that buffer. As a result, you can ignore the * return code of these functions and call them in a series then just call * git_buf_oom at the end. */ int git_buf_sets(git_buf *buf, const char *string); int git_buf_putc(git_buf *buf, char c); int git_buf_putcn(git_buf *buf, char c, size_t len); int git_buf_put(git_buf *buf, const char *data, size_t len); int git_buf_puts(git_buf *buf, const char *string); int git_buf_printf(git_buf *buf, const char *format, ...) GIT_FORMAT_PRINTF(2, 3); int git_buf_vprintf(git_buf *buf, const char *format, va_list ap); void git_buf_clear(git_buf *buf); void git_buf_consume(git_buf *buf, const char *end); void git_buf_truncate(git_buf *buf, size_t len); void git_buf_shorten(git_buf *buf, size_t amount); void git_buf_rtruncate_at_char(git_buf *path, char separator); /** General join with separator */ int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...); /** Fast join of two strings - first may legally point into `buf` data */ int git_buf_join(git_buf *buf, char separator, const char *str_a, const char *str_b); /** Fast join of three strings - cannot reference `buf` data */ int git_buf_join3(git_buf *buf, char separator, const char *str_a, const char *str_b, const char *str_c); /** * Join two strings as paths, inserting a slash between as needed. * @return 0 on success, -1 on failure */ GIT_INLINE(int) git_buf_joinpath(git_buf *buf, const char *a, const char *b) { return git_buf_join(buf, '/', a, b); } GIT_INLINE(const char *) git_buf_cstr(const git_buf *buf) { return buf->ptr; } GIT_INLINE(size_t) git_buf_len(const git_buf *buf) { return buf->size; } void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf); #define git_buf_PUTS(buf, str) git_buf_put(buf, str, sizeof(str) - 1) GIT_INLINE(ssize_t) git_buf_rfind_next(const git_buf *buf, char ch) { ssize_t idx = (ssize_t)buf->size - 1; while (idx >= 0 && buf->ptr[idx] == ch) idx--; while (idx >= 0 && buf->ptr[idx] != ch) idx--; return idx; } GIT_INLINE(ssize_t) git_buf_rfind(const git_buf *buf, char ch) { ssize_t idx = (ssize_t)buf->size - 1; while (idx >= 0 && buf->ptr[idx] != ch) idx--; return idx; } GIT_INLINE(ssize_t) git_buf_find(const git_buf *buf, char ch) { void *found = memchr(buf->ptr, ch, buf->size); return found ? (ssize_t)((const char *)found - buf->ptr) : -1; } /* Remove whitespace from the end of the buffer */ void git_buf_rtrim(git_buf *buf); int git_buf_cmp(const git_buf *a, const git_buf *b); /* Write data as base64 encoded in buffer */ int git_buf_encode_base64(git_buf *buf, const char *data, size_t len); /* Decode the given bas64 and write the result to the buffer */ int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len); /* Write data as "base85" encoded in buffer */ int git_buf_encode_base85(git_buf *buf, const char *data, size_t len); /* * Insert, remove or replace a portion of the buffer. * * @param buf The buffer to work with * * @param where The location in the buffer where the transformation * should be applied. * * @param nb_to_remove The number of chars to be removed. 0 to not * remove any character in the buffer. * * @param data A pointer to the data which should be inserted. * * @param nb_to_insert The number of chars to be inserted. 0 to not * insert any character from the buffer. * * @return 0 or an error code. */ int git_buf_splice( git_buf *buf, size_t where, size_t nb_to_remove, const char *data, size_t nb_to_insert); #endif deps/libgit2-sys-0.3.8/libgit2/src/oidarray.c0000664000175000017500000000074212510265101015644 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/oidarray.h" #include "oidarray.h" #include "array.h" void git_oidarray_free(git_oidarray *arr) { git__free(arr->ids); } void git_oidarray__from_array(git_oidarray *arr, git_array_oid_t *array) { arr->count = array->size; arr->ids = array->ptr; } deps/libgit2-sys-0.3.8/libgit2/src/config_cache.c0000664000175000017500000000752112510265101016424 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "fileops.h" #include "repository.h" #include "config.h" #include "git2/config.h" #include "vector.h" #include "filter.h" struct map_data { const char *cvar_name; git_cvar_map *maps; size_t map_count; int default_value; }; /* * core.eol * Sets the line ending type to use in the working directory for * files that have the text property set. Alternatives are lf, crlf * and native, which uses the platform's native line ending. The default * value is native. See gitattributes(5) for more information on * end-of-line conversion. */ static git_cvar_map _cvar_map_eol[] = { {GIT_CVAR_FALSE, NULL, GIT_EOL_UNSET}, {GIT_CVAR_STRING, "lf", GIT_EOL_LF}, {GIT_CVAR_STRING, "crlf", GIT_EOL_CRLF}, {GIT_CVAR_STRING, "native", GIT_EOL_NATIVE} }; /* * core.autocrlf * Setting this variable to "true" is almost the same as setting * the text attribute to "auto" on all files except that text files are * not guaranteed to be normalized: files that contain CRLF in the * repository will not be touched. Use this setting if you want to have * CRLF line endings in your working directory even though the repository * does not have normalized line endings. This variable can be set to input, * in which case no output conversion is performed. */ static git_cvar_map _cvar_map_autocrlf[] = { {GIT_CVAR_FALSE, NULL, GIT_AUTO_CRLF_FALSE}, {GIT_CVAR_TRUE, NULL, GIT_AUTO_CRLF_TRUE}, {GIT_CVAR_STRING, "input", GIT_AUTO_CRLF_INPUT} }; static git_cvar_map _cvar_map_safecrlf[] = { {GIT_CVAR_FALSE, NULL, GIT_SAFE_CRLF_FALSE}, {GIT_CVAR_TRUE, NULL, GIT_SAFE_CRLF_FAIL}, {GIT_CVAR_STRING, "warn", GIT_SAFE_CRLF_WARN} }; /* * Generic map for integer values */ static git_cvar_map _cvar_map_int[] = { {GIT_CVAR_INT32, NULL, 0}, }; static struct map_data _cvar_maps[] = { {"core.autocrlf", _cvar_map_autocrlf, ARRAY_SIZE(_cvar_map_autocrlf), GIT_AUTO_CRLF_DEFAULT}, {"core.eol", _cvar_map_eol, ARRAY_SIZE(_cvar_map_eol), GIT_EOL_DEFAULT}, {"core.symlinks", NULL, 0, GIT_SYMLINKS_DEFAULT }, {"core.ignorecase", NULL, 0, GIT_IGNORECASE_DEFAULT }, {"core.filemode", NULL, 0, GIT_FILEMODE_DEFAULT }, {"core.ignorestat", NULL, 0, GIT_IGNORESTAT_DEFAULT }, {"core.trustctime", NULL, 0, GIT_TRUSTCTIME_DEFAULT }, {"core.abbrev", _cvar_map_int, 1, GIT_ABBREV_DEFAULT }, {"core.precomposeunicode", NULL, 0, GIT_PRECOMPOSE_DEFAULT }, {"core.safecrlf", _cvar_map_safecrlf, ARRAY_SIZE(_cvar_map_safecrlf), GIT_SAFE_CRLF_DEFAULT}, {"core.logallrefupdates", NULL, 0, GIT_LOGALLREFUPDATES_DEFAULT }, {"core.protecthfs", NULL, 0, GIT_PROTECTHFS_DEFAULT }, {"core.protectntfs", NULL, 0, GIT_PROTECTNTFS_DEFAULT }, }; int git_config__cvar(int *out, git_config *config, git_cvar_cached cvar) { int error = 0; struct map_data *data = &_cvar_maps[(int)cvar]; git_config_entry *entry; git_config__lookup_entry(&entry, config, data->cvar_name, false); if (!entry) *out = data->default_value; else if (data->maps) error = git_config_lookup_map_value( out, data->maps, data->map_count, entry->value); else error = git_config_parse_bool(out, entry->value); git_config_entry_free(entry); return error; } int git_repository__cvar(int *out, git_repository *repo, git_cvar_cached cvar) { *out = repo->cvar_cache[(int)cvar]; if (*out == GIT_CVAR_NOT_CACHED) { int error; git_config *config; if ((error = git_repository_config__weakptr(&config, repo)) < 0 || (error = git_config__cvar(out, config, cvar)) < 0) return error; repo->cvar_cache[(int)cvar] = *out; } return 0; } void git_repository__cvar_cache_clear(git_repository *repo) { int i; for (i = 0; i < GIT_CVAR_CACHE_MAX; ++i) repo->cvar_cache[i] = GIT_CVAR_NOT_CACHED; } deps/libgit2-sys-0.3.8/libgit2/src/notes.c0000664000175000017500000003505412572105236015200 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "notes.h" #include "git2.h" #include "refs.h" #include "config.h" #include "iterator.h" #include "signature.h" static int note_error_notfound(void) { giterr_set(GITERR_INVALID, "Note could not be found"); return GIT_ENOTFOUND; } static int find_subtree_in_current_level( git_tree **out, git_repository *repo, git_tree *parent, const char *annotated_object_sha, int fanout) { size_t i; const git_tree_entry *entry; *out = NULL; if (parent == NULL) return note_error_notfound(); for (i = 0; i < git_tree_entrycount(parent); i++) { entry = git_tree_entry_byindex(parent, i); if (!git__ishex(git_tree_entry_name(entry))) continue; if (S_ISDIR(git_tree_entry_filemode(entry)) && strlen(git_tree_entry_name(entry)) == 2 && !strncmp(git_tree_entry_name(entry), annotated_object_sha + fanout, 2)) return git_tree_lookup(out, repo, git_tree_entry_id(entry)); /* Not a DIR, so do we have an already existing blob? */ if (!strcmp(git_tree_entry_name(entry), annotated_object_sha + fanout)) return GIT_EEXISTS; } return note_error_notfound(); } static int find_subtree_r(git_tree **out, git_tree *root, git_repository *repo, const char *target, int *fanout) { int error; git_tree *subtree = NULL; *out = NULL; error = find_subtree_in_current_level(&subtree, repo, root, target, *fanout); if (error == GIT_EEXISTS) return git_tree_lookup(out, repo, git_tree_id(root)); if (error < 0) return error; *fanout += 2; error = find_subtree_r(out, subtree, repo, target, fanout); git_tree_free(subtree); return error; } static int find_blob(git_oid *blob, git_tree *tree, const char *target) { size_t i; const git_tree_entry *entry; for (i=0; iid, note_oid); if (git_signature_dup(¬e->author, git_commit_author(commit)) < 0 || git_signature_dup(¬e->committer, git_commit_committer(commit)) < 0) return -1; note->message = git__strndup(git_blob_rawcontent(blob), git_blob_rawsize(blob)); GITERR_CHECK_ALLOC(note->message); *out = note; return 0; } static int note_lookup( git_note **out, git_repository *repo, git_commit *commit, git_tree *tree, const char *target) { int error, fanout = 0; git_oid oid; git_blob *blob = NULL; git_note *note = NULL; git_tree *subtree = NULL; if ((error = find_subtree_r(&subtree, tree, repo, target, &fanout)) < 0) goto cleanup; if ((error = find_blob(&oid, subtree, target + fanout)) < 0) goto cleanup; if ((error = git_blob_lookup(&blob, repo, &oid)) < 0) goto cleanup; if ((error = note_new(¬e, &oid, commit, blob)) < 0) goto cleanup; *out = note; cleanup: git_tree_free(subtree); git_blob_free(blob); return error; } static int note_remove(git_repository *repo, const git_signature *author, const git_signature *committer, const char *notes_ref, git_tree *tree, const char *target, git_commit **parents) { int error; git_tree *tree_after_removal = NULL; git_oid oid; if ((error = manipulate_note_in_tree_r( &tree_after_removal, repo, tree, NULL, target, 0, remove_note_in_tree_eexists_cb, remove_note_in_tree_enotfound_cb)) < 0) goto cleanup; error = git_commit_create(&oid, repo, notes_ref, author, committer, NULL, GIT_NOTES_DEFAULT_MSG_RM, tree_after_removal, *parents == NULL ? 0 : 1, (const git_commit **) parents); cleanup: git_tree_free(tree_after_removal); return error; } static int note_get_default_ref(char **out, git_repository *repo) { git_config *cfg; int ret = git_repository_config__weakptr(&cfg, repo); *out = (ret != 0) ? NULL : git_config__get_string_force( cfg, "core.notesref", GIT_NOTES_DEFAULT_REF); return ret; } static int normalize_namespace(char **out, git_repository *repo, const char *notes_ref) { if (notes_ref) { *out = git__strdup(notes_ref); GITERR_CHECK_ALLOC(*out); return 0; } return note_get_default_ref(out, repo); } static int retrieve_note_tree_and_commit( git_tree **tree_out, git_commit **commit_out, char **notes_ref_out, git_repository *repo, const char *notes_ref) { int error; git_oid oid; if ((error = normalize_namespace(notes_ref_out, repo, notes_ref)) < 0) return error; if ((error = git_reference_name_to_id(&oid, repo, *notes_ref_out)) < 0) return error; if (git_commit_lookup(commit_out, repo, &oid) < 0) return error; if ((error = git_commit_tree(tree_out, *commit_out)) < 0) return error; return 0; } int git_note_read(git_note **out, git_repository *repo, const char *notes_ref_in, const git_oid *oid) { int error; char *target = NULL, *notes_ref = NULL; git_tree *tree = NULL; git_commit *commit = NULL; target = git_oid_allocfmt(oid); GITERR_CHECK_ALLOC(target); if (!(error = retrieve_note_tree_and_commit( &tree, &commit, ¬es_ref, repo, notes_ref_in))) error = note_lookup(out, repo, commit, tree, target); git__free(notes_ref); git__free(target); git_tree_free(tree); git_commit_free(commit); return error; } int git_note_create( git_oid *out, git_repository *repo, const char *notes_ref_in, const git_signature *author, const git_signature *committer, const git_oid *oid, const char *note, int allow_note_overwrite) { int error; char *target = NULL, *notes_ref = NULL; git_commit *commit = NULL; git_tree *tree = NULL; target = git_oid_allocfmt(oid); GITERR_CHECK_ALLOC(target); error = retrieve_note_tree_and_commit(&tree, &commit, ¬es_ref, repo, notes_ref_in); if (error < 0 && error != GIT_ENOTFOUND) goto cleanup; error = note_write(out, repo, author, committer, notes_ref, note, tree, target, &commit, allow_note_overwrite); cleanup: git__free(notes_ref); git__free(target); git_commit_free(commit); git_tree_free(tree); return error; } int git_note_remove(git_repository *repo, const char *notes_ref_in, const git_signature *author, const git_signature *committer, const git_oid *oid) { int error; char *target = NULL, *notes_ref; git_commit *commit = NULL; git_tree *tree = NULL; target = git_oid_allocfmt(oid); GITERR_CHECK_ALLOC(target); if (!(error = retrieve_note_tree_and_commit( &tree, &commit, ¬es_ref, repo, notes_ref_in))) error = note_remove( repo, author, committer, notes_ref, tree, target, &commit); git__free(notes_ref); git__free(target); git_commit_free(commit); git_tree_free(tree); return error; } int git_note_default_ref(git_buf *out, git_repository *repo) { char *default_ref; int error; assert(out && repo); git_buf_sanitize(out); if ((error = note_get_default_ref(&default_ref, repo)) < 0) return error; git_buf_attach(out, default_ref, strlen(default_ref)); return 0; } const git_signature *git_note_committer(const git_note *note) { assert(note); return note->committer; } const git_signature *git_note_author(const git_note *note) { assert(note); return note->author; } const char * git_note_message(const git_note *note) { assert(note); return note->message; } const git_oid * git_note_id(const git_note *note) { assert(note); return ¬e->id; } void git_note_free(git_note *note) { if (note == NULL) return; git_signature_free(note->committer); git_signature_free(note->author); git__free(note->message); git__free(note); } static int process_entry_path( const char* entry_path, git_oid *annotated_object_id) { int error = 0; size_t i = 0, j = 0, len; git_buf buf = GIT_BUF_INIT; if ((error = git_buf_puts(&buf, entry_path)) < 0) goto cleanup; len = git_buf_len(&buf); while (i < len) { if (buf.ptr[i] == '/') { i++; continue; } if (git__fromhex(buf.ptr[i]) < 0) { /* This is not a note entry */ goto cleanup; } if (i != j) buf.ptr[j] = buf.ptr[i]; i++; j++; } buf.ptr[j] = '\0'; buf.size = j; if (j != GIT_OID_HEXSZ) { /* This is not a note entry */ goto cleanup; } error = git_oid_fromstr(annotated_object_id, buf.ptr); cleanup: git_buf_free(&buf); return error; } int git_note_foreach( git_repository *repo, const char *notes_ref, git_note_foreach_cb note_cb, void *payload) { int error; git_note_iterator *iter = NULL; git_oid note_id, annotated_id; if ((error = git_note_iterator_new(&iter, repo, notes_ref)) < 0) return error; while (!(error = git_note_next(¬e_id, &annotated_id, iter))) { if ((error = note_cb(¬e_id, &annotated_id, payload)) != 0) { giterr_set_after_callback(error); break; } } if (error == GIT_ITEROVER) error = 0; git_note_iterator_free(iter); return error; } void git_note_iterator_free(git_note_iterator *it) { if (it == NULL) return; git_iterator_free(it); } int git_note_iterator_new( git_note_iterator **it, git_repository *repo, const char *notes_ref_in) { int error; git_commit *commit = NULL; git_tree *tree = NULL; char *notes_ref; error = retrieve_note_tree_and_commit(&tree, &commit, ¬es_ref, repo, notes_ref_in); if (error < 0) goto cleanup; if ((error = git_iterator_for_tree(it, tree, NULL)) < 0) git_iterator_free(*it); cleanup: git__free(notes_ref); git_tree_free(tree); git_commit_free(commit); return error; } int git_note_next( git_oid* note_id, git_oid* annotated_id, git_note_iterator *it) { int error; const git_index_entry *item; if ((error = git_iterator_current(&item, it)) < 0) return error; git_oid_cpy(note_id, &item->id); if (!(error = process_entry_path(item->path, annotated_id))) git_iterator_advance(NULL, it); return error; } deps/libgit2-sys-0.3.8/libgit2/src/fetchhead.c0000664000175000017500000001520612426525445015766 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/types.h" #include "git2/oid.h" #include "fetchhead.h" #include "common.h" #include "buffer.h" #include "fileops.h" #include "filebuf.h" #include "refs.h" #include "repository.h" int git_fetchhead_ref_cmp(const void *a, const void *b) { const git_fetchhead_ref *one = (const git_fetchhead_ref *)a; const git_fetchhead_ref *two = (const git_fetchhead_ref *)b; if (one->is_merge && !two->is_merge) return -1; if (two->is_merge && !one->is_merge) return 1; if (one->ref_name && two->ref_name) return strcmp(one->ref_name, two->ref_name); else if (one->ref_name) return -1; else if (two->ref_name) return 1; return 0; } int git_fetchhead_ref_create( git_fetchhead_ref **out, git_oid *oid, unsigned int is_merge, const char *ref_name, const char *remote_url) { git_fetchhead_ref *fetchhead_ref; assert(out && oid); *out = NULL; fetchhead_ref = git__malloc(sizeof(git_fetchhead_ref)); GITERR_CHECK_ALLOC(fetchhead_ref); memset(fetchhead_ref, 0x0, sizeof(git_fetchhead_ref)); git_oid_cpy(&fetchhead_ref->oid, oid); fetchhead_ref->is_merge = is_merge; if (ref_name) fetchhead_ref->ref_name = git__strdup(ref_name); if (remote_url) fetchhead_ref->remote_url = git__strdup(remote_url); *out = fetchhead_ref; return 0; } static int fetchhead_ref_write( git_filebuf *file, git_fetchhead_ref *fetchhead_ref) { char oid[GIT_OID_HEXSZ + 1]; const char *type, *name; int head = 0; assert(file && fetchhead_ref); git_oid_fmt(oid, &fetchhead_ref->oid); oid[GIT_OID_HEXSZ] = '\0'; if (git__prefixcmp(fetchhead_ref->ref_name, GIT_REFS_HEADS_DIR) == 0) { type = "branch "; name = fetchhead_ref->ref_name + strlen(GIT_REFS_HEADS_DIR); } else if(git__prefixcmp(fetchhead_ref->ref_name, GIT_REFS_TAGS_DIR) == 0) { type = "tag "; name = fetchhead_ref->ref_name + strlen(GIT_REFS_TAGS_DIR); } else if (!git__strcmp(fetchhead_ref->ref_name, GIT_HEAD_FILE)) { head = 1; } else { type = ""; name = fetchhead_ref->ref_name; } if (head) return git_filebuf_printf(file, "%s\t\t%s\n", oid, fetchhead_ref->remote_url); return git_filebuf_printf(file, "%s\t%s\t%s'%s' of %s\n", oid, (fetchhead_ref->is_merge) ? "" : "not-for-merge", type, name, fetchhead_ref->remote_url); } int git_fetchhead_write(git_repository *repo, git_vector *fetchhead_refs) { git_filebuf file = GIT_FILEBUF_INIT; git_buf path = GIT_BUF_INIT; unsigned int i; git_fetchhead_ref *fetchhead_ref; assert(repo && fetchhead_refs); if (git_buf_joinpath(&path, repo->path_repository, GIT_FETCH_HEAD_FILE) < 0) return -1; if (git_filebuf_open(&file, path.ptr, GIT_FILEBUF_FORCE, GIT_REFS_FILE_MODE) < 0) { git_buf_free(&path); return -1; } git_buf_free(&path); git_vector_sort(fetchhead_refs); git_vector_foreach(fetchhead_refs, i, fetchhead_ref) fetchhead_ref_write(&file, fetchhead_ref); return git_filebuf_commit(&file); } static int fetchhead_ref_parse( git_oid *oid, unsigned int *is_merge, git_buf *ref_name, const char **remote_url, char *line, size_t line_num) { char *oid_str, *is_merge_str, *desc, *name = NULL; const char *type = NULL; int error = 0; *remote_url = NULL; if (!*line) { giterr_set(GITERR_FETCHHEAD, "Empty line in FETCH_HEAD line %d", line_num); return -1; } /* Compat with old git clients that wrote FETCH_HEAD like a loose ref. */ if ((oid_str = git__strsep(&line, "\t")) == NULL) { oid_str = line; line += strlen(line); *is_merge = 1; } if (strlen(oid_str) != GIT_OID_HEXSZ) { giterr_set(GITERR_FETCHHEAD, "Invalid object ID in FETCH_HEAD line %d", line_num); return -1; } if (git_oid_fromstr(oid, oid_str) < 0) { const git_error *oid_err = giterr_last(); const char *err_msg = oid_err ? oid_err->message : "Invalid object ID"; giterr_set(GITERR_FETCHHEAD, "%s in FETCH_HEAD line %d", err_msg, line_num); return -1; } /* Parse new data from newer git clients */ if (*line) { if ((is_merge_str = git__strsep(&line, "\t")) == NULL) { giterr_set(GITERR_FETCHHEAD, "Invalid description data in FETCH_HEAD line %d", line_num); return -1; } if (*is_merge_str == '\0') *is_merge = 1; else if (strcmp(is_merge_str, "not-for-merge") == 0) *is_merge = 0; else { giterr_set(GITERR_FETCHHEAD, "Invalid for-merge entry in FETCH_HEAD line %d", line_num); return -1; } if ((desc = line) == NULL) { giterr_set(GITERR_FETCHHEAD, "Invalid description in FETCH_HEAD line %d", line_num); return -1; } if (git__prefixcmp(desc, "branch '") == 0) { type = GIT_REFS_HEADS_DIR; name = desc + 8; } else if (git__prefixcmp(desc, "tag '") == 0) { type = GIT_REFS_TAGS_DIR; name = desc + 5; } else if (git__prefixcmp(desc, "'") == 0) name = desc + 1; if (name) { if ((desc = strstr(name, "' ")) == NULL || git__prefixcmp(desc, "' of ") != 0) { giterr_set(GITERR_FETCHHEAD, "Invalid description in FETCH_HEAD line %d", line_num); return -1; } *desc = '\0'; desc += 5; } *remote_url = desc; } git_buf_clear(ref_name); if (type) git_buf_join(ref_name, '/', type, name); else if(name) git_buf_puts(ref_name, name); return error; } int git_repository_fetchhead_foreach(git_repository *repo, git_repository_fetchhead_foreach_cb cb, void *payload) { git_buf path = GIT_BUF_INIT, file = GIT_BUF_INIT, name = GIT_BUF_INIT; const char *ref_name; git_oid oid; const char *remote_url; unsigned int is_merge = 0; char *buffer, *line; size_t line_num = 0; int error = 0; assert(repo && cb); if (git_buf_joinpath(&path, repo->path_repository, GIT_FETCH_HEAD_FILE) < 0) return -1; if ((error = git_futils_readbuffer(&file, git_buf_cstr(&path))) < 0) goto done; buffer = file.ptr; while ((line = git__strsep(&buffer, "\n")) != NULL) { ++line_num; if ((error = fetchhead_ref_parse( &oid, &is_merge, &name, &remote_url, line, line_num)) < 0) goto done; if (git_buf_len(&name) > 0) ref_name = git_buf_cstr(&name); else ref_name = NULL; error = cb(ref_name, remote_url, &oid, is_merge, payload); if (error) { giterr_set_after_callback(error); goto done; } } if (*buffer) { giterr_set(GITERR_FETCHHEAD, "No EOL at line %d", line_num+1); error = -1; goto done; } done: git_buf_free(&file); git_buf_free(&path); git_buf_free(&name); return error; } void git_fetchhead_ref_free(git_fetchhead_ref *fetchhead_ref) { if (fetchhead_ref == NULL) return; git__free(fetchhead_ref->remote_url); git__free(fetchhead_ref->ref_name); git__free(fetchhead_ref); } deps/libgit2-sys-0.3.8/libgit2/src/posix.c0000664000175000017500000001134712510265101015177 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "posix.h" #include "path.h" #include #include #ifndef GIT_WIN32 #ifdef NO_ADDRINFO int p_getaddrinfo( const char *host, const char *port, struct addrinfo *hints, struct addrinfo **info) { struct addrinfo *ainfo, *ai; int p = 0; GIT_UNUSED(hints); if ((ainfo = malloc(sizeof(struct addrinfo))) == NULL) return -1; if ((ainfo->ai_hostent = gethostbyname(host)) == NULL) { free(ainfo); return -2; } ainfo->ai_servent = getservbyname(port, 0); if (ainfo->ai_servent) ainfo->ai_port = ainfo->ai_servent->s_port; else ainfo->ai_port = atol(port); memcpy(&ainfo->ai_addr_in.sin_addr, ainfo->ai_hostent->h_addr_list[0], ainfo->ai_hostent->h_length); ainfo->ai_protocol = 0; ainfo->ai_socktype = hints->ai_socktype; ainfo->ai_family = ainfo->ai_hostent->h_addrtype; ainfo->ai_addr_in.sin_family = ainfo->ai_family; ainfo->ai_addr_in.sin_port = ainfo->ai_port; ainfo->ai_addr = (struct addrinfo *)&ainfo->ai_addr_in; ainfo->ai_addrlen = sizeof(struct sockaddr_in); *info = ainfo; if (ainfo->ai_hostent->h_addr_list[1] == NULL) { ainfo->ai_next = NULL; return 0; } ai = ainfo; for (p = 1; ainfo->ai_hostent->h_addr_list[p] != NULL; p++) { ai->ai_next = malloc(sizeof(struct addrinfo)); memcpy(&ai->ai_next, ainfo, sizeof(struct addrinfo)); memcpy(&ai->ai_next->ai_addr_in.sin_addr, ainfo->ai_hostent->h_addr_list[p], ainfo->ai_hostent->h_length); ai->ai_next->ai_addr = (struct addrinfo *)&ai->ai_next->ai_addr_in; ai = ai->ai_next; } ai->ai_next = NULL; return 0; } void p_freeaddrinfo(struct addrinfo *info) { struct addrinfo *p, *next; p = info; while(p != NULL) { next = p->ai_next; free(p); p = next; } } const char *p_gai_strerror(int ret) { switch(ret) { case -1: return "Out of memory"; break; case -2: return "Address lookup failed"; break; default: return "Unknown error"; break; } } #endif /* NO_ADDRINFO */ int p_open(const char *path, volatile int flags, ...) { mode_t mode = 0; if (flags & O_CREAT) { va_list arg_list; va_start(arg_list, flags); mode = (mode_t)va_arg(arg_list, int); va_end(arg_list); } return open(path, flags | O_BINARY | O_CLOEXEC, mode); } int p_creat(const char *path, mode_t mode) { return open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_CLOEXEC, mode); } int p_getcwd(char *buffer_out, size_t size) { char *cwd_buffer; assert(buffer_out && size > 0); cwd_buffer = getcwd(buffer_out, size); if (cwd_buffer == NULL) return -1; git_path_mkposix(buffer_out); git_path_string_to_dir(buffer_out, size); /* append trailing slash */ return 0; } int p_rename(const char *from, const char *to) { if (!link(from, to)) { p_unlink(from); return 0; } if (!rename(from, to)) return 0; return -1; } #endif /* GIT_WIN32 */ ssize_t p_read(git_file fd, void *buf, size_t cnt) { char *b = buf; if (!git__is_ssizet(cnt)) { #ifdef GIT_WIN32 SetLastError(ERROR_INVALID_PARAMETER); #endif errno = EINVAL; return -1; } while (cnt) { ssize_t r; #ifdef GIT_WIN32 r = read(fd, b, cnt > INT_MAX ? INT_MAX : (unsigned int)cnt); #else r = read(fd, b, cnt); #endif if (r < 0) { if (errno == EINTR || errno == EAGAIN) continue; return -1; } if (!r) break; cnt -= r; b += r; } return (b - (char *)buf); } int p_write(git_file fd, const void *buf, size_t cnt) { const char *b = buf; while (cnt) { ssize_t r; #ifdef GIT_WIN32 assert((size_t)((unsigned int)cnt) == cnt); r = write(fd, b, (unsigned int)cnt); #else r = write(fd, b, cnt); #endif if (r < 0) { if (errno == EINTR || GIT_ISBLOCKED(errno)) continue; return -1; } if (!r) { errno = EPIPE; return -1; } cnt -= r; b += r; } return 0; } #ifdef NO_MMAP #include "map.h" int git__page_size(size_t *page_size) { /* dummy; here we don't need any alignment anyway */ *page_size = 4096; return 0; } int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset) { GIT_MMAP_VALIDATE(out, len, prot, flags); out->data = NULL; out->len = 0; if ((prot & GIT_PROT_WRITE) && ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED)) { giterr_set(GITERR_OS, "Trying to map shared-writeable"); return -1; } out->data = malloc(len); GITERR_CHECK_ALLOC(out->data); if (!git__is_ssizet(len) || (p_lseek(fd, offset, SEEK_SET) < 0) || (p_read(fd, out->data, len) != (ssize_t)len)) { giterr_set(GITERR_OS, "mmap emulation failed"); return -1; } out->len = len; return 0; } int p_munmap(git_map *map) { assert(map != NULL); free(map->data); return 0; } #endif deps/libgit2-sys-0.3.8/libgit2/src/submodule.h0000664000175000017500000001224712555730137016060 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_submodule_h__ #define INCLUDE_submodule_h__ #include "git2/submodule.h" #include "git2/repository.h" #include "fileops.h" /* Notes: * * Submodule information can be in four places: the index, the config files * (both .git/config and .gitmodules), the HEAD tree, and the working * directory. * * In the index: * - submodule is found by path * - may be missing, present, or of the wrong type * - will have an oid if present * * In the HEAD tree: * - submodule is found by path * - may be missing, present, or of the wrong type * - will have an oid if present * * In the config files: * - submodule is found by submodule "name" which is usually the path * - may be missing or present * - will have a name, path, url, and other properties * * In the working directory: * - submodule is found by path * - may be missing, an empty directory, a checked out directory, * or of the wrong type * - if checked out, will have a HEAD oid * - if checked out, will have git history that can be used to compare oids * - if checked out, may have modified files and/or untracked files */ /** * Description of submodule * * This record describes a submodule found in a repository. There should be * an entry for every submodule found in the HEAD and index, and for every * submodule described in .gitmodules. The fields are as follows: * * - `rc` tracks the refcount of how many hash table entries in the * git_submodule_cache there are for this submodule. It only comes into * play if the name and path of the submodule differ. * * - `name` is the name of the submodule from .gitmodules. * - `path` is the path to the submodule from the repo root. It is almost * always the same as `name`. * - `url` is the url for the submodule. * - `update` is a git_submodule_update_t value - see gitmodules(5) update. * - `update_default` is the update value from the config * - `ignore` is a git_submodule_ignore_t value - see gitmodules(5) ignore. * - `ignore_default` is the ignore value from the config * - `fetch_recurse` is a git_submodule_recurse_t value - see gitmodules(5) * fetchRecurseSubmodules. * - `fetch_recurse_default` is the recurse value from the config * * - `repo` is the parent repository that contains this submodule. * - `flags` after for internal use, tracking where this submodule has been * found (head, index, config, workdir) and known status info, etc. * - `head_oid` is the SHA1 for the submodule path in the repo HEAD. * - `index_oid` is the SHA1 for the submodule recorded in the index. * - `wd_oid` is the SHA1 for the HEAD of the checked out submodule. * * If the submodule has been added to .gitmodules but not yet git added, * then the `index_oid` will be zero but still marked valid. If the * submodule has been deleted, but the delete has not been committed yet, * then the `index_oid` will be set, but the `url` will be NULL. */ struct git_submodule { git_refcount rc; /* information from config */ char *name; char *path; /* important: may just point to "name" string */ char *url; char *branch; git_submodule_update_t update; git_submodule_update_t update_default; git_submodule_ignore_t ignore; git_submodule_ignore_t ignore_default; git_submodule_recurse_t fetch_recurse; git_submodule_recurse_t fetch_recurse_default; /* internal information */ git_repository *repo; uint32_t flags; git_oid head_oid; git_oid index_oid; git_oid wd_oid; }; /* Force revalidation of submodule data cache (alloc as needed) */ extern int git_submodule_cache_refresh(git_repository *repo); /* Release all submodules */ extern void git_submodule_cache_free(git_repository *repo); /* Additional flags on top of public GIT_SUBMODULE_STATUS values */ enum { GIT_SUBMODULE_STATUS__WD_SCANNED = (1u << 20), GIT_SUBMODULE_STATUS__HEAD_OID_VALID = (1u << 21), GIT_SUBMODULE_STATUS__INDEX_OID_VALID = (1u << 22), GIT_SUBMODULE_STATUS__WD_OID_VALID = (1u << 23), GIT_SUBMODULE_STATUS__HEAD_NOT_SUBMODULE = (1u << 24), GIT_SUBMODULE_STATUS__INDEX_NOT_SUBMODULE = (1u << 25), GIT_SUBMODULE_STATUS__WD_NOT_SUBMODULE = (1u << 26), GIT_SUBMODULE_STATUS__INDEX_MULTIPLE_ENTRIES = (1u << 27), }; #define GIT_SUBMODULE_STATUS__CLEAR_INTERNAL(S) \ ((S) & ~(0xFFFFFFFFu << 20)) /* Internal lookup does not attempt to refresh cached data */ extern int git_submodule__lookup( git_submodule **out, git_repository *repo, const char *path); /* Internal status fn returns status and optionally the various OIDs */ extern int git_submodule__status( unsigned int *out_status, git_oid *out_head_id, git_oid *out_index_id, git_oid *out_wd_id, git_submodule *sm, git_submodule_ignore_t ign); /* Open submodule repository as bare repo for quick HEAD check, etc. */ extern int git_submodule_open_bare( git_repository **repo, git_submodule *submodule); extern int git_submodule_parse_ignore( git_submodule_ignore_t *out, const char *value); extern int git_submodule_parse_update( git_submodule_update_t *out, const char *value); #endif deps/libgit2-sys-0.3.8/libgit2/src/delta.c0000664000175000017500000003451212510265101015125 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "delta.h" /* maximum hash entry list for the same hash bucket */ #define HASH_LIMIT 64 #define RABIN_SHIFT 23 #define RABIN_WINDOW 16 static const unsigned int T[256] = { 0x00000000, 0xab59b4d1, 0x56b369a2, 0xfdeadd73, 0x063f6795, 0xad66d344, 0x508c0e37, 0xfbd5bae6, 0x0c7ecf2a, 0xa7277bfb, 0x5acda688, 0xf1941259, 0x0a41a8bf, 0xa1181c6e, 0x5cf2c11d, 0xf7ab75cc, 0x18fd9e54, 0xb3a42a85, 0x4e4ef7f6, 0xe5174327, 0x1ec2f9c1, 0xb59b4d10, 0x48719063, 0xe32824b2, 0x1483517e, 0xbfdae5af, 0x423038dc, 0xe9698c0d, 0x12bc36eb, 0xb9e5823a, 0x440f5f49, 0xef56eb98, 0x31fb3ca8, 0x9aa28879, 0x6748550a, 0xcc11e1db, 0x37c45b3d, 0x9c9defec, 0x6177329f, 0xca2e864e, 0x3d85f382, 0x96dc4753, 0x6b369a20, 0xc06f2ef1, 0x3bba9417, 0x90e320c6, 0x6d09fdb5, 0xc6504964, 0x2906a2fc, 0x825f162d, 0x7fb5cb5e, 0xd4ec7f8f, 0x2f39c569, 0x846071b8, 0x798aaccb, 0xd2d3181a, 0x25786dd6, 0x8e21d907, 0x73cb0474, 0xd892b0a5, 0x23470a43, 0x881ebe92, 0x75f463e1, 0xdeadd730, 0x63f67950, 0xc8afcd81, 0x354510f2, 0x9e1ca423, 0x65c91ec5, 0xce90aa14, 0x337a7767, 0x9823c3b6, 0x6f88b67a, 0xc4d102ab, 0x393bdfd8, 0x92626b09, 0x69b7d1ef, 0xc2ee653e, 0x3f04b84d, 0x945d0c9c, 0x7b0be704, 0xd05253d5, 0x2db88ea6, 0x86e13a77, 0x7d348091, 0xd66d3440, 0x2b87e933, 0x80de5de2, 0x7775282e, 0xdc2c9cff, 0x21c6418c, 0x8a9ff55d, 0x714a4fbb, 0xda13fb6a, 0x27f92619, 0x8ca092c8, 0x520d45f8, 0xf954f129, 0x04be2c5a, 0xafe7988b, 0x5432226d, 0xff6b96bc, 0x02814bcf, 0xa9d8ff1e, 0x5e738ad2, 0xf52a3e03, 0x08c0e370, 0xa39957a1, 0x584ced47, 0xf3155996, 0x0eff84e5, 0xa5a63034, 0x4af0dbac, 0xe1a96f7d, 0x1c43b20e, 0xb71a06df, 0x4ccfbc39, 0xe79608e8, 0x1a7cd59b, 0xb125614a, 0x468e1486, 0xedd7a057, 0x103d7d24, 0xbb64c9f5, 0x40b17313, 0xebe8c7c2, 0x16021ab1, 0xbd5bae60, 0x6cb54671, 0xc7ecf2a0, 0x3a062fd3, 0x915f9b02, 0x6a8a21e4, 0xc1d39535, 0x3c394846, 0x9760fc97, 0x60cb895b, 0xcb923d8a, 0x3678e0f9, 0x9d215428, 0x66f4eece, 0xcdad5a1f, 0x3047876c, 0x9b1e33bd, 0x7448d825, 0xdf116cf4, 0x22fbb187, 0x89a20556, 0x7277bfb0, 0xd92e0b61, 0x24c4d612, 0x8f9d62c3, 0x7836170f, 0xd36fa3de, 0x2e857ead, 0x85dcca7c, 0x7e09709a, 0xd550c44b, 0x28ba1938, 0x83e3ade9, 0x5d4e7ad9, 0xf617ce08, 0x0bfd137b, 0xa0a4a7aa, 0x5b711d4c, 0xf028a99d, 0x0dc274ee, 0xa69bc03f, 0x5130b5f3, 0xfa690122, 0x0783dc51, 0xacda6880, 0x570fd266, 0xfc5666b7, 0x01bcbbc4, 0xaae50f15, 0x45b3e48d, 0xeeea505c, 0x13008d2f, 0xb85939fe, 0x438c8318, 0xe8d537c9, 0x153feaba, 0xbe665e6b, 0x49cd2ba7, 0xe2949f76, 0x1f7e4205, 0xb427f6d4, 0x4ff24c32, 0xe4abf8e3, 0x19412590, 0xb2189141, 0x0f433f21, 0xa41a8bf0, 0x59f05683, 0xf2a9e252, 0x097c58b4, 0xa225ec65, 0x5fcf3116, 0xf49685c7, 0x033df00b, 0xa86444da, 0x558e99a9, 0xfed72d78, 0x0502979e, 0xae5b234f, 0x53b1fe3c, 0xf8e84aed, 0x17bea175, 0xbce715a4, 0x410dc8d7, 0xea547c06, 0x1181c6e0, 0xbad87231, 0x4732af42, 0xec6b1b93, 0x1bc06e5f, 0xb099da8e, 0x4d7307fd, 0xe62ab32c, 0x1dff09ca, 0xb6a6bd1b, 0x4b4c6068, 0xe015d4b9, 0x3eb80389, 0x95e1b758, 0x680b6a2b, 0xc352defa, 0x3887641c, 0x93ded0cd, 0x6e340dbe, 0xc56db96f, 0x32c6cca3, 0x999f7872, 0x6475a501, 0xcf2c11d0, 0x34f9ab36, 0x9fa01fe7, 0x624ac294, 0xc9137645, 0x26459ddd, 0x8d1c290c, 0x70f6f47f, 0xdbaf40ae, 0x207afa48, 0x8b234e99, 0x76c993ea, 0xdd90273b, 0x2a3b52f7, 0x8162e626, 0x7c883b55, 0xd7d18f84, 0x2c043562, 0x875d81b3, 0x7ab75cc0, 0xd1eee811 }; static const unsigned int U[256] = { 0x00000000, 0x7eb5200d, 0x5633f4cb, 0x2886d4c6, 0x073e5d47, 0x798b7d4a, 0x510da98c, 0x2fb88981, 0x0e7cba8e, 0x70c99a83, 0x584f4e45, 0x26fa6e48, 0x0942e7c9, 0x77f7c7c4, 0x5f711302, 0x21c4330f, 0x1cf9751c, 0x624c5511, 0x4aca81d7, 0x347fa1da, 0x1bc7285b, 0x65720856, 0x4df4dc90, 0x3341fc9d, 0x1285cf92, 0x6c30ef9f, 0x44b63b59, 0x3a031b54, 0x15bb92d5, 0x6b0eb2d8, 0x4388661e, 0x3d3d4613, 0x39f2ea38, 0x4747ca35, 0x6fc11ef3, 0x11743efe, 0x3eccb77f, 0x40799772, 0x68ff43b4, 0x164a63b9, 0x378e50b6, 0x493b70bb, 0x61bda47d, 0x1f088470, 0x30b00df1, 0x4e052dfc, 0x6683f93a, 0x1836d937, 0x250b9f24, 0x5bbebf29, 0x73386bef, 0x0d8d4be2, 0x2235c263, 0x5c80e26e, 0x740636a8, 0x0ab316a5, 0x2b7725aa, 0x55c205a7, 0x7d44d161, 0x03f1f16c, 0x2c4978ed, 0x52fc58e0, 0x7a7a8c26, 0x04cfac2b, 0x73e5d470, 0x0d50f47d, 0x25d620bb, 0x5b6300b6, 0x74db8937, 0x0a6ea93a, 0x22e87dfc, 0x5c5d5df1, 0x7d996efe, 0x032c4ef3, 0x2baa9a35, 0x551fba38, 0x7aa733b9, 0x041213b4, 0x2c94c772, 0x5221e77f, 0x6f1ca16c, 0x11a98161, 0x392f55a7, 0x479a75aa, 0x6822fc2b, 0x1697dc26, 0x3e1108e0, 0x40a428ed, 0x61601be2, 0x1fd53bef, 0x3753ef29, 0x49e6cf24, 0x665e46a5, 0x18eb66a8, 0x306db26e, 0x4ed89263, 0x4a173e48, 0x34a21e45, 0x1c24ca83, 0x6291ea8e, 0x4d29630f, 0x339c4302, 0x1b1a97c4, 0x65afb7c9, 0x446b84c6, 0x3adea4cb, 0x1258700d, 0x6ced5000, 0x4355d981, 0x3de0f98c, 0x15662d4a, 0x6bd30d47, 0x56ee4b54, 0x285b6b59, 0x00ddbf9f, 0x7e689f92, 0x51d01613, 0x2f65361e, 0x07e3e2d8, 0x7956c2d5, 0x5892f1da, 0x2627d1d7, 0x0ea10511, 0x7014251c, 0x5facac9d, 0x21198c90, 0x099f5856, 0x772a785b, 0x4c921c31, 0x32273c3c, 0x1aa1e8fa, 0x6414c8f7, 0x4bac4176, 0x3519617b, 0x1d9fb5bd, 0x632a95b0, 0x42eea6bf, 0x3c5b86b2, 0x14dd5274, 0x6a687279, 0x45d0fbf8, 0x3b65dbf5, 0x13e30f33, 0x6d562f3e, 0x506b692d, 0x2ede4920, 0x06589de6, 0x78edbdeb, 0x5755346a, 0x29e01467, 0x0166c0a1, 0x7fd3e0ac, 0x5e17d3a3, 0x20a2f3ae, 0x08242768, 0x76910765, 0x59298ee4, 0x279caee9, 0x0f1a7a2f, 0x71af5a22, 0x7560f609, 0x0bd5d604, 0x235302c2, 0x5de622cf, 0x725eab4e, 0x0ceb8b43, 0x246d5f85, 0x5ad87f88, 0x7b1c4c87, 0x05a96c8a, 0x2d2fb84c, 0x539a9841, 0x7c2211c0, 0x029731cd, 0x2a11e50b, 0x54a4c506, 0x69998315, 0x172ca318, 0x3faa77de, 0x411f57d3, 0x6ea7de52, 0x1012fe5f, 0x38942a99, 0x46210a94, 0x67e5399b, 0x19501996, 0x31d6cd50, 0x4f63ed5d, 0x60db64dc, 0x1e6e44d1, 0x36e89017, 0x485db01a, 0x3f77c841, 0x41c2e84c, 0x69443c8a, 0x17f11c87, 0x38499506, 0x46fcb50b, 0x6e7a61cd, 0x10cf41c0, 0x310b72cf, 0x4fbe52c2, 0x67388604, 0x198da609, 0x36352f88, 0x48800f85, 0x6006db43, 0x1eb3fb4e, 0x238ebd5d, 0x5d3b9d50, 0x75bd4996, 0x0b08699b, 0x24b0e01a, 0x5a05c017, 0x728314d1, 0x0c3634dc, 0x2df207d3, 0x534727de, 0x7bc1f318, 0x0574d315, 0x2acc5a94, 0x54797a99, 0x7cffae5f, 0x024a8e52, 0x06852279, 0x78300274, 0x50b6d6b2, 0x2e03f6bf, 0x01bb7f3e, 0x7f0e5f33, 0x57888bf5, 0x293dabf8, 0x08f998f7, 0x764cb8fa, 0x5eca6c3c, 0x207f4c31, 0x0fc7c5b0, 0x7172e5bd, 0x59f4317b, 0x27411176, 0x1a7c5765, 0x64c97768, 0x4c4fa3ae, 0x32fa83a3, 0x1d420a22, 0x63f72a2f, 0x4b71fee9, 0x35c4dee4, 0x1400edeb, 0x6ab5cde6, 0x42331920, 0x3c86392d, 0x133eb0ac, 0x6d8b90a1, 0x450d4467, 0x3bb8646a }; struct index_entry { const unsigned char *ptr; unsigned int val; struct index_entry *next; }; struct git_delta_index { unsigned long memsize; const void *src_buf; unsigned long src_size; unsigned int hash_mask; struct index_entry *hash[GIT_FLEX_ARRAY]; }; static int lookup_index_alloc( void **out, unsigned long *out_len, size_t entries, size_t hash_count) { size_t entries_len, hash_len, index_len; GITERR_CHECK_ALLOC_MULTIPLY(&entries_len, entries, sizeof(struct index_entry)); GITERR_CHECK_ALLOC_MULTIPLY(&hash_len, hash_count, sizeof(struct index_entry *)); GITERR_CHECK_ALLOC_ADD(&index_len, sizeof(struct git_delta_index), entries_len); GITERR_CHECK_ALLOC_ADD(&index_len, index_len, hash_len); if (!git__is_ulong(index_len)) { giterr_set(GITERR_NOMEMORY, "Overly large delta"); return -1; } *out = git__malloc(index_len); GITERR_CHECK_ALLOC(*out); *out_len = index_len; return 0; } struct git_delta_index * git_delta_create_index(const void *buf, unsigned long bufsize) { unsigned int i, hsize, hmask, entries, prev_val, *hash_count; const unsigned char *data, *buffer = buf; struct git_delta_index *index; struct index_entry *entry, **hash; void *mem; unsigned long memsize; if (!buf || !bufsize) return NULL; /* Determine index hash size. Note that indexing skips the first byte to allow for optimizing the rabin polynomial initialization in create_delta(). */ entries = (unsigned int)(bufsize - 1) / RABIN_WINDOW; if (bufsize >= 0xffffffffUL) { /* * Current delta format can't encode offsets into * reference buffer with more than 32 bits. */ entries = 0xfffffffeU / RABIN_WINDOW; } hsize = entries / 4; for (i = 4; i < 31 && (1u << i) < hsize; i++); hsize = 1 << i; hmask = hsize - 1; if (lookup_index_alloc(&mem, &memsize, entries, hsize) < 0) return NULL; index = mem; mem = index->hash; hash = mem; mem = hash + hsize; entry = mem; index->memsize = memsize; index->src_buf = buf; index->src_size = bufsize; index->hash_mask = hmask; memset(hash, 0, hsize * sizeof(*hash)); /* allocate an array to count hash entries */ hash_count = git__calloc(hsize, sizeof(*hash_count)); if (!hash_count) { git__free(index); return NULL; } /* then populate the index */ prev_val = ~0; for (data = buffer + entries * RABIN_WINDOW - RABIN_WINDOW; data >= buffer; data -= RABIN_WINDOW) { unsigned int val = 0; for (i = 1; i <= RABIN_WINDOW; i++) val = ((val << 8) | data[i]) ^ T[val >> RABIN_SHIFT]; if (val == prev_val) { /* keep the lowest of consecutive identical blocks */ entry[-1].ptr = data + RABIN_WINDOW; } else { prev_val = val; i = val & hmask; entry->ptr = data + RABIN_WINDOW; entry->val = val; entry->next = hash[i]; hash[i] = entry++; hash_count[i]++; } } /* * Determine a limit on the number of entries in the same hash * bucket. This guard us against patological data sets causing * really bad hash distribution with most entries in the same hash * bucket that would bring us to O(m*n) computing costs (m and n * corresponding to reference and target buffer sizes). * * Make sure none of the hash buckets has more entries than * we're willing to test. Otherwise we cull the entry list * uniformly to still preserve a good repartition across * the reference buffer. */ for (i = 0; i < hsize; i++) { if (hash_count[i] < HASH_LIMIT) continue; entry = hash[i]; do { struct index_entry *keep = entry; int skip = hash_count[i] / HASH_LIMIT / 2; do { entry = entry->next; } while(--skip && entry); keep->next = entry; } while (entry); } git__free(hash_count); return index; } void git_delta_free_index(struct git_delta_index *index) { git__free(index); } unsigned long git_delta_sizeof_index(struct git_delta_index *index) { if (index) return index->memsize; else return 0; } /* * The maximum size for any opcode sequence, including the initial header * plus rabin window plus biggest copy. */ #define MAX_OP_SIZE (5 + 5 + 1 + RABIN_WINDOW + 7) void * git_delta_create( const struct git_delta_index *index, const void *trg_buf, unsigned long trg_size, unsigned long *delta_size, unsigned long max_size) { unsigned int i, outpos, outsize, moff, msize, val; int inscnt; const unsigned char *ref_data, *ref_top, *data, *top; unsigned char *out; if (!trg_buf || !trg_size) return NULL; outpos = 0; outsize = 8192; if (max_size && outsize >= max_size) outsize = (unsigned int)(max_size + MAX_OP_SIZE + 1); out = git__malloc(outsize); if (!out) return NULL; /* store reference buffer size */ i = index->src_size; while (i >= 0x80) { out[outpos++] = i | 0x80; i >>= 7; } out[outpos++] = i; /* store target buffer size */ i = trg_size; while (i >= 0x80) { out[outpos++] = i | 0x80; i >>= 7; } out[outpos++] = i; ref_data = index->src_buf; ref_top = ref_data + index->src_size; data = trg_buf; top = (const unsigned char *) trg_buf + trg_size; outpos++; val = 0; for (i = 0; i < RABIN_WINDOW && data < top; i++, data++) { out[outpos++] = *data; val = ((val << 8) | *data) ^ T[val >> RABIN_SHIFT]; } inscnt = i; moff = 0; msize = 0; while (data < top) { if (msize < 4096) { struct index_entry *entry; val ^= U[data[-RABIN_WINDOW]]; val = ((val << 8) | *data) ^ T[val >> RABIN_SHIFT]; i = val & index->hash_mask; for (entry = index->hash[i]; entry; entry = entry->next) { const unsigned char *ref = entry->ptr; const unsigned char *src = data; unsigned int ref_size = (unsigned int)(ref_top - ref); if (entry->val != val) continue; if (ref_size > (unsigned int)(top - src)) ref_size = (unsigned int)(top - src); if (ref_size <= msize) break; while (ref_size-- && *src++ == *ref) ref++; if (msize < (unsigned int)(ref - entry->ptr)) { /* this is our best match so far */ msize = (unsigned int)(ref - entry->ptr); moff = (unsigned int)(entry->ptr - ref_data); if (msize >= 4096) /* good enough */ break; } } } if (msize < 4) { if (!inscnt) outpos++; out[outpos++] = *data++; inscnt++; if (inscnt == 0x7f) { out[outpos - inscnt - 1] = inscnt; inscnt = 0; } msize = 0; } else { unsigned int left; unsigned char *op; if (inscnt) { while (moff && ref_data[moff-1] == data[-1]) { /* we can match one byte back */ msize++; moff--; data--; outpos--; if (--inscnt) continue; outpos--; /* remove count slot */ inscnt--; /* make it -1 */ break; } out[outpos - inscnt - 1] = inscnt; inscnt = 0; } /* A copy op is currently limited to 64KB (pack v2) */ left = (msize < 0x10000) ? 0 : (msize - 0x10000); msize -= left; op = out + outpos++; i = 0x80; if (moff & 0x000000ff) out[outpos++] = moff >> 0, i |= 0x01; if (moff & 0x0000ff00) out[outpos++] = moff >> 8, i |= 0x02; if (moff & 0x00ff0000) out[outpos++] = moff >> 16, i |= 0x04; if (moff & 0xff000000) out[outpos++] = moff >> 24, i |= 0x08; if (msize & 0x00ff) out[outpos++] = msize >> 0, i |= 0x10; if (msize & 0xff00) out[outpos++] = msize >> 8, i |= 0x20; *op = i; data += msize; moff += msize; msize = left; if (msize < 4096) { int j; val = 0; for (j = -RABIN_WINDOW; j < 0; j++) val = ((val << 8) | data[j]) ^ T[val >> RABIN_SHIFT]; } } if (outpos >= outsize - MAX_OP_SIZE) { void *tmp = out; outsize = outsize * 3 / 2; if (max_size && outsize >= max_size) outsize = max_size + MAX_OP_SIZE + 1; if (max_size && outpos > max_size) break; out = git__realloc(out, outsize); if (!out) { git__free(tmp); return NULL; } } } if (inscnt) out[outpos - inscnt - 1] = inscnt; if (max_size && outpos > max_size) { git__free(out); return NULL; } *delta_size = outpos; return out; } deps/libgit2-sys-0.3.8/libgit2/src/notes.h0000664000175000017500000000126612510265101015171 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_note_h__ #define INCLUDE_note_h__ #include "common.h" #include "git2/oid.h" #include "git2/types.h" #define GIT_NOTES_DEFAULT_REF "refs/notes/commits" #define GIT_NOTES_DEFAULT_MSG_ADD \ "Notes added by 'git_note_create' from libgit2" #define GIT_NOTES_DEFAULT_MSG_RM \ "Notes removed by 'git_note_remove' from libgit2" struct git_note { git_oid id; git_signature *author; git_signature *committer; char *message; }; #endif /* INCLUDE_notes_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/blame_git.c0000664000175000017500000004020712610310643015760 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "blame_git.h" #include "commit.h" #include "blob.h" #include "xdiff/xinclude.h" #include "diff_xdiff.h" /* * Origin is refcounted and usually we keep the blob contents to be * reused. */ static git_blame__origin *origin_incref(git_blame__origin *o) { if (o) o->refcnt++; return o; } static void origin_decref(git_blame__origin *o) { if (o && --o->refcnt <= 0) { if (o->previous) origin_decref(o->previous); git_blob_free(o->blob); git_commit_free(o->commit); git__free(o); } } /* Given a commit and a path in it, create a new origin structure. */ static int make_origin(git_blame__origin **out, git_commit *commit, const char *path) { git_blame__origin *o; size_t path_len = strlen(path), alloc_len; int error = 0; GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*o), path_len); GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 1); o = git__calloc(1, alloc_len); GITERR_CHECK_ALLOC(o); o->commit = commit; o->refcnt = 1; strcpy(o->path, path); if (!(error = git_object_lookup_bypath((git_object**)&o->blob, (git_object*)commit, path, GIT_OBJ_BLOB))) { *out = o; } else { origin_decref(o); } return error; } /* Locate an existing origin or create a new one. */ int git_blame__get_origin( git_blame__origin **out, git_blame *blame, git_commit *commit, const char *path) { git_blame__entry *e; for (e = blame->ent; e; e = e->next) { if (e->suspect->commit == commit && !strcmp(e->suspect->path, path)) { *out = origin_incref(e->suspect); } } return make_origin(out, commit, path); } typedef struct blame_chunk_cb_data { git_blame *blame; git_blame__origin *target; git_blame__origin *parent; long tlno; long plno; }blame_chunk_cb_data; static bool same_suspect(git_blame__origin *a, git_blame__origin *b) { if (a == b) return true; if (git_oid_cmp(git_commit_id(a->commit), git_commit_id(b->commit))) return false; return 0 == strcmp(a->path, b->path); } /* find the line number of the last line the target is suspected for */ static int find_last_in_target(git_blame *blame, git_blame__origin *target) { git_blame__entry *e; int last_in_target = -1; for (e=blame->ent; e; e=e->next) { if (e->guilty || !same_suspect(e->suspect, target)) continue; if (last_in_target < e->s_lno + e->num_lines) last_in_target = e->s_lno + e->num_lines; } return last_in_target; } /* * It is known that lines between tlno to same came from parent, and e * has an overlap with that range. it also is known that parent's * line plno corresponds to e's line tlno. * * <---- e -----> * <------> (entirely within) * <------------> (extends past) * <------------> (starts before) * <------------------> (entirely encloses) * * Split e into potentially three parts; before this chunk, the chunk * to be blamed for the parent, and after that portion. */ static void split_overlap(git_blame__entry *split, git_blame__entry *e, int tlno, int plno, int same, git_blame__origin *parent) { int chunk_end_lno; if (e->s_lno < tlno) { /* there is a pre-chunk part not blamed on the parent */ split[0].suspect = origin_incref(e->suspect); split[0].lno = e->lno; split[0].s_lno = e->s_lno; split[0].num_lines = tlno - e->s_lno; split[1].lno = e->lno + tlno - e->s_lno; split[1].s_lno = plno; } else { split[1].lno = e->lno; split[1].s_lno = plno + (e->s_lno - tlno); } if (same < e->s_lno + e->num_lines) { /* there is a post-chunk part not blamed on parent */ split[2].suspect = origin_incref(e->suspect); split[2].lno = e->lno + (same - e->s_lno); split[2].s_lno = e->s_lno + (same - e->s_lno); split[2].num_lines = e->s_lno + e->num_lines - same; chunk_end_lno = split[2].lno; } else { chunk_end_lno = e->lno + e->num_lines; } split[1].num_lines = chunk_end_lno - split[1].lno; /* * if it turns out there is nothing to blame the parent for, forget about * the splitting. !split[1].suspect signals this. */ if (split[1].num_lines < 1) return; split[1].suspect = origin_incref(parent); } /* * Link in a new blame entry to the scoreboard. Entries that cover the same * line range have been removed from the scoreboard previously. */ static void add_blame_entry(git_blame *blame, git_blame__entry *e) { git_blame__entry *ent, *prev = NULL; origin_incref(e->suspect); for (ent = blame->ent; ent && ent->lno < e->lno; ent = ent->next) prev = ent; /* prev, if not NULL, is the last one that is below e */ e->prev = prev; if (prev) { e->next = prev->next; prev->next = e; } else { e->next = blame->ent; blame->ent = e; } if (e->next) e->next->prev = e; } /* * src typically is on-stack; we want to copy the information in it to * a malloced blame_entry that is already on the linked list of the scoreboard. * The origin of dst loses a refcnt while the origin of src gains one. */ static void dup_entry(git_blame__entry *dst, git_blame__entry *src) { git_blame__entry *p, *n; p = dst->prev; n = dst->next; origin_incref(src->suspect); origin_decref(dst->suspect); memcpy(dst, src, sizeof(*src)); dst->prev = p; dst->next = n; dst->score = 0; } /* * split_overlap() divided an existing blame e into up to three parts in split. * Adjust the linked list of blames in the scoreboard to reflect the split. */ static void split_blame(git_blame *blame, git_blame__entry *split, git_blame__entry *e) { git_blame__entry *new_entry; if (split[0].suspect && split[2].suspect) { /* The first part (reuse storage for the existing entry e */ dup_entry(e, &split[0]); /* The last part -- me */ new_entry = git__malloc(sizeof(*new_entry)); memcpy(new_entry, &(split[2]), sizeof(git_blame__entry)); add_blame_entry(blame, new_entry); /* ... and the middle part -- parent */ new_entry = git__malloc(sizeof(*new_entry)); memcpy(new_entry, &(split[1]), sizeof(git_blame__entry)); add_blame_entry(blame, new_entry); } else if (!split[0].suspect && !split[2].suspect) { /* * The parent covers the entire area; reuse storage for e and replace it * with the parent */ dup_entry(e, &split[1]); } else if (split[0].suspect) { /* me and then parent */ dup_entry(e, &split[0]); new_entry = git__malloc(sizeof(*new_entry)); memcpy(new_entry, &(split[1]), sizeof(git_blame__entry)); add_blame_entry(blame, new_entry); } else { /* parent and then me */ dup_entry(e, &split[1]); new_entry = git__malloc(sizeof(*new_entry)); memcpy(new_entry, &(split[2]), sizeof(git_blame__entry)); add_blame_entry(blame, new_entry); } } /* * After splitting the blame, the origins used by the on-stack blame_entry * should lose one refcnt each. */ static void decref_split(git_blame__entry *split) { int i; for (i=0; i<3; i++) origin_decref(split[i].suspect); } /* * Helper for blame_chunk(). blame_entry e is known to overlap with the patch * hunk; split it and pass blame to the parent. */ static void blame_overlap( git_blame *blame, git_blame__entry *e, int tlno, int plno, int same, git_blame__origin *parent) { git_blame__entry split[3] = {{0}}; split_overlap(split, e, tlno, plno, same, parent); if (split[1].suspect) split_blame(blame, split, e); decref_split(split); } /* * Process one hunk from the patch between the current suspect for blame_entry * e and its parent. Find and split the overlap, and pass blame to the * overlapping part to the parent. */ static void blame_chunk( git_blame *blame, int tlno, int plno, int same, git_blame__origin *target, git_blame__origin *parent) { git_blame__entry *e; for (e = blame->ent; e; e = e->next) { if (e->guilty || !same_suspect(e->suspect, target)) continue; if (same <= e->s_lno) continue; if (tlno < e->s_lno + e->num_lines) { blame_overlap(blame, e, tlno, plno, same, parent); } } } static int my_emit( long start_a, long count_a, long start_b, long count_b, void *cb_data) { blame_chunk_cb_data *d = (blame_chunk_cb_data *)cb_data; blame_chunk(d->blame, d->tlno, d->plno, start_b, d->target, d->parent); d->plno = start_a + count_a; d->tlno = start_b + count_b; return 0; } static void trim_common_tail(mmfile_t *a, mmfile_t *b, long ctx) { const int blk = 1024; long trimmed = 0, recovered = 0; char *ap = a->ptr + a->size; char *bp = b->ptr + b->size; long smaller = (long)((a->size < b->size) ? a->size : b->size); if (ctx) return; while (blk + trimmed <= smaller && !memcmp(ap - blk, bp - blk, blk)) { trimmed += blk; ap -= blk; bp -= blk; } while (recovered < trimmed) if (ap[recovered++] == '\n') break; a->size -= trimmed - recovered; b->size -= trimmed - recovered; } static int diff_hunks(mmfile_t file_a, mmfile_t file_b, void *cb_data) { xpparam_t xpp = {0}; xdemitconf_t xecfg = {0}; xdemitcb_t ecb = {0}; xecfg.hunk_func = my_emit; ecb.priv = cb_data; trim_common_tail(&file_a, &file_b, 0); if (file_a.size > GIT_XDIFF_MAX_SIZE || file_b.size > GIT_XDIFF_MAX_SIZE) { giterr_set(GITERR_INVALID, "file too large to blame"); return -1; } return xdl_diff(&file_a, &file_b, &xpp, &xecfg, &ecb); } static void fill_origin_blob(git_blame__origin *o, mmfile_t *file) { memset(file, 0, sizeof(*file)); if (o->blob) { file->ptr = (char*)git_blob_rawcontent(o->blob); file->size = (size_t)git_blob_rawsize(o->blob); } } static int pass_blame_to_parent( git_blame *blame, git_blame__origin *target, git_blame__origin *parent) { int last_in_target; mmfile_t file_p, file_o; blame_chunk_cb_data d = { blame, target, parent, 0, 0 }; last_in_target = find_last_in_target(blame, target); if (last_in_target < 0) return 1; /* nothing remains for this target */ fill_origin_blob(parent, &file_p); fill_origin_blob(target, &file_o); if (diff_hunks(file_p, file_o, &d) < 0) return -1; /* The reset (i.e. anything after tlno) are the same as the parent */ blame_chunk(blame, d.tlno, d.plno, last_in_target, target, parent); return 0; } static int paths_on_dup(void **old, void *new) { GIT_UNUSED(old); git__free(new); return -1; } static git_blame__origin* find_origin( git_blame *blame, git_commit *parent, git_blame__origin *origin) { git_blame__origin *porigin = NULL; git_diff *difflist = NULL; git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT; git_tree *otree=NULL, *ptree=NULL; /* Get the trees from this commit and its parent */ if (0 != git_commit_tree(&otree, origin->commit) || 0 != git_commit_tree(&ptree, parent)) goto cleanup; /* Configure the diff */ diffopts.context_lines = 0; diffopts.flags = GIT_DIFF_SKIP_BINARY_CHECK; /* Check to see if files we're interested have changed */ diffopts.pathspec.count = blame->paths.length; diffopts.pathspec.strings = (char**)blame->paths.contents; if (0 != git_diff_tree_to_tree(&difflist, blame->repository, ptree, otree, &diffopts)) goto cleanup; if (!git_diff_num_deltas(difflist)) { /* No changes; copy data */ git_blame__get_origin(&porigin, blame, parent, origin->path); } else { git_diff_find_options findopts = GIT_DIFF_FIND_OPTIONS_INIT; int i; /* Generate a full diff between the two trees */ git_diff_free(difflist); diffopts.pathspec.count = 0; if (0 != git_diff_tree_to_tree(&difflist, blame->repository, ptree, otree, &diffopts)) goto cleanup; /* Let diff find renames */ findopts.flags = GIT_DIFF_FIND_RENAMES; if (0 != git_diff_find_similar(difflist, &findopts)) goto cleanup; /* Find one that matches */ for (i=0; i<(int)git_diff_num_deltas(difflist); i++) { const git_diff_delta *delta = git_diff_get_delta(difflist, i); if (!git_vector_bsearch(NULL, &blame->paths, delta->new_file.path)) { git_vector_insert_sorted(&blame->paths, (void*)git__strdup(delta->old_file.path), paths_on_dup); make_origin(&porigin, parent, delta->old_file.path); } } } cleanup: git_diff_free(difflist); git_tree_free(otree); git_tree_free(ptree); return porigin; } /* * The blobs of origin and porigin exactly match, so everything origin is * suspected for can be blamed on the parent. */ static void pass_whole_blame(git_blame *blame, git_blame__origin *origin, git_blame__origin *porigin) { git_blame__entry *e; if (!porigin->blob) git_object_lookup((git_object**)&porigin->blob, blame->repository, git_blob_id(origin->blob), GIT_OBJ_BLOB); for (e=blame->ent; e; e=e->next) { if (!same_suspect(e->suspect, origin)) continue; origin_incref(porigin); origin_decref(e->suspect); e->suspect = porigin; } } static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt) { git_commit *commit = origin->commit; int i, num_parents; git_blame__origin *sg_buf[16]; git_blame__origin *porigin, **sg_origin = sg_buf; int ret, error = 0; num_parents = git_commit_parentcount(commit); if (!git_oid_cmp(git_commit_id(commit), &blame->options.oldest_commit)) /* Stop at oldest specified commit */ num_parents = 0; else if (opt & GIT_BLAME_FIRST_PARENT && num_parents > 1) /* Limit search to the first parent */ num_parents = 1; if (!num_parents) { git_oid_cpy(&blame->options.oldest_commit, git_commit_id(commit)); goto finish; } else if (num_parents < (int)ARRAY_SIZE(sg_buf)) memset(sg_buf, 0, sizeof(sg_buf)); else sg_origin = git__calloc(num_parents, sizeof(*sg_origin)); for (i=0; icommit, i); porigin = find_origin(blame, p, origin); if (!porigin) continue; if (porigin->blob && origin->blob && !git_oid_cmp(git_blob_id(porigin->blob), git_blob_id(origin->blob))) { pass_whole_blame(blame, origin, porigin); origin_decref(porigin); goto finish; } for (j = same = 0; jblob), git_blob_id(porigin->blob))) { same = 1; break; } if (!same) sg_origin[i] = porigin; else origin_decref(porigin); } /* Standard blame */ for (i=0; iprevious) { origin_incref(porigin); origin->previous = porigin; } if ((ret = pass_blame_to_parent(blame, origin, porigin)) != 0) { if (ret < 0) error = -1; goto finish; } } /* TODO: optionally find moves in parents' files */ /* TODO: optionally find copies in parents' files */ finish: for (i=0; i pair), * merge them together. */ static void coalesce(git_blame *blame) { git_blame__entry *ent, *next; for (ent=blame->ent; ent && (next = ent->next); ent = next) { if (same_suspect(ent->suspect, next->suspect) && ent->guilty == next->guilty && ent->s_lno + ent->num_lines == next->s_lno) { ent->num_lines += next->num_lines; ent->next = next->next; if (ent->next) ent->next->prev = ent; origin_decref(next->suspect); git__free(next); ent->score = 0; next = ent; /* again */ } } } int git_blame__like_git(git_blame *blame, uint32_t opt) { while (true) { git_blame__entry *ent; git_blame__origin *suspect = NULL; /* Find a suspect to break down */ for (ent = blame->ent; !suspect && ent; ent = ent->next) if (!ent->guilty) suspect = ent->suspect; if (!suspect) return 0; /* all done */ /* We'll use this suspect later in the loop, so hold on to it for now. */ origin_incref(suspect); if (pass_blame(blame, suspect, opt) < 0) return -1; /* Take responsibility for the remaining entries */ for (ent = blame->ent; ent; ent = ent->next) { if (same_suspect(ent->suspect, suspect)) { ent->guilty = true; ent->is_boundary = !git_oid_cmp( git_commit_id(suspect->commit), &blame->options.oldest_commit); } } origin_decref(suspect); } coalesce(blame); return 0; } void git_blame__free_entry(git_blame__entry *ent) { if (!ent) return; origin_decref(ent->suspect); git__free(ent); } deps/libgit2-sys-0.3.8/libgit2/src/util.c0000664000175000017500000004230512610310643015013 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include #include "common.h" #include #include #include "posix.h" #ifdef GIT_WIN32 # include "win32/w32_buffer.h" #endif #ifdef _MSC_VER # include #endif void git_strarray_free(git_strarray *array) { size_t i; if (array == NULL) return; for (i = 0; i < array->count; ++i) git__free(array->strings[i]); git__free(array->strings); memset(array, 0, sizeof(*array)); } int git_strarray_copy(git_strarray *tgt, const git_strarray *src) { size_t i; assert(tgt && src); memset(tgt, 0, sizeof(*tgt)); if (!src->count) return 0; tgt->strings = git__calloc(src->count, sizeof(char *)); GITERR_CHECK_ALLOC(tgt->strings); for (i = 0; i < src->count; ++i) { if (!src->strings[i]) continue; tgt->strings[tgt->count] = git__strdup(src->strings[i]); if (!tgt->strings[tgt->count]) { git_strarray_free(tgt); memset(tgt, 0, sizeof(*tgt)); return -1; } tgt->count++; } return 0; } int git__strtol64(int64_t *result, const char *nptr, const char **endptr, int base) { const char *p; int64_t n, nn; int c, ovfl, v, neg, ndig; p = nptr; neg = 0; n = 0; ndig = 0; ovfl = 0; /* * White space */ while (git__isspace(*p)) p++; /* * Sign */ if (*p == '-' || *p == '+') if (*p++ == '-') neg = 1; /* * Base */ if (base == 0) { if (*p != '0') base = 10; else { base = 8; if (p[1] == 'x' || p[1] == 'X') { p += 2; base = 16; } } } else if (base == 16 && *p == '0') { if (p[1] == 'x' || p[1] == 'X') p += 2; } else if (base < 0 || 36 < base) goto Return; /* * Non-empty sequence of digits */ for (;; p++,ndig++) { c = *p; v = base; if ('0'<=c && c<='9') v = c - '0'; else if ('a'<=c && c<='z') v = c - 'a' + 10; else if ('A'<=c && c<='Z') v = c - 'A' + 10; if (v >= base) break; nn = n*base + v; if (nn < n) ovfl = 1; n = nn; } Return: if (ndig == 0) { giterr_set(GITERR_INVALID, "Failed to convert string to long. Not a number"); return -1; } if (endptr) *endptr = p; if (ovfl) { giterr_set(GITERR_INVALID, "Failed to convert string to long. Overflow error"); return -1; } *result = neg ? -n : n; return 0; } int git__strtol32(int32_t *result, const char *nptr, const char **endptr, int base) { int error; int32_t tmp_int; int64_t tmp_long; if ((error = git__strtol64(&tmp_long, nptr, endptr, base)) < 0) return error; tmp_int = tmp_long & 0xFFFFFFFF; if (tmp_int != tmp_long) { giterr_set(GITERR_INVALID, "Failed to convert. '%s' is too large", nptr); return -1; } *result = tmp_int; return error; } int git__strcmp(const char *a, const char *b) { while (*a && *b && *a == *b) ++a, ++b; return (int)(*(const unsigned char *)a) - (int)(*(const unsigned char *)b); } int git__strcasecmp(const char *a, const char *b) { while (*a && *b && git__tolower(*a) == git__tolower(*b)) ++a, ++b; return ((unsigned char)git__tolower(*a) - (unsigned char)git__tolower(*b)); } int git__strcasesort_cmp(const char *a, const char *b) { int cmp = 0; while (*a && *b) { if (*a != *b) { if (git__tolower(*a) != git__tolower(*b)) break; /* use case in sort order even if not in equivalence */ if (!cmp) cmp = (int)(*(const uint8_t *)a) - (int)(*(const uint8_t *)b); } ++a, ++b; } if (*a || *b) return (unsigned char)git__tolower(*a) - (unsigned char)git__tolower(*b); return cmp; } int git__strncmp(const char *a, const char *b, size_t sz) { while (sz && *a && *b && *a == *b) --sz, ++a, ++b; if (!sz) return 0; return (int)(*(const unsigned char *)a) - (int)(*(const unsigned char *)b); } int git__strncasecmp(const char *a, const char *b, size_t sz) { int al, bl; do { al = (unsigned char)git__tolower(*a); bl = (unsigned char)git__tolower(*b); ++a, ++b; } while (--sz && al && al == bl); return al - bl; } void git__strntolower(char *str, size_t len) { size_t i; for (i = 0; i < len; ++i) { str[i] = (char)git__tolower(str[i]); } } void git__strtolower(char *str) { git__strntolower(str, strlen(str)); } int git__prefixcmp(const char *str, const char *prefix) { for (;;) { unsigned char p = *(prefix++), s; if (!p) return 0; if ((s = *(str++)) != p) return s - p; } } int git__prefixcmp_icase(const char *str, const char *prefix) { return strncasecmp(str, prefix, strlen(prefix)); } int git__prefixncmp_icase(const char *str, size_t str_n, const char *prefix) { int s, p; while(str_n--) { s = (unsigned char)git__tolower(*str++); p = (unsigned char)git__tolower(*prefix++); if (s != p) return s - p; } return (0 - *prefix); } int git__suffixcmp(const char *str, const char *suffix) { size_t a = strlen(str); size_t b = strlen(suffix); if (a < b) return -1; return strcmp(str + (a - b), suffix); } char *git__strtok(char **end, const char *sep) { char *ptr = *end; while (*ptr && strchr(sep, *ptr)) ++ptr; if (*ptr) { char *start = ptr; *end = start + 1; while (**end && !strchr(sep, **end)) ++*end; if (**end) { **end = '\0'; ++*end; } return start; } return NULL; } /* Similar to strtok, but does not collapse repeated tokens. */ char *git__strsep(char **end, const char *sep) { char *start = *end, *ptr = *end; while (*ptr && !strchr(sep, *ptr)) ++ptr; if (*ptr) { *end = ptr + 1; *ptr = '\0'; return start; } return NULL; } void git__hexdump(const char *buffer, size_t len) { static const size_t LINE_WIDTH = 16; size_t line_count, last_line, i, j; const char *line; line_count = (len / LINE_WIDTH); last_line = (len % LINE_WIDTH); for (i = 0; i < line_count; ++i) { line = buffer + (i * LINE_WIDTH); for (j = 0; j < LINE_WIDTH; ++j, ++line) printf("%02X ", (unsigned char)*line & 0xFF); printf("| "); line = buffer + (i * LINE_WIDTH); for (j = 0; j < LINE_WIDTH; ++j, ++line) printf("%c", (*line >= 32 && *line <= 126) ? *line : '.'); printf("\n"); } if (last_line > 0) { line = buffer + (line_count * LINE_WIDTH); for (j = 0; j < last_line; ++j, ++line) printf("%02X ", (unsigned char)*line & 0xFF); for (j = 0; j < (LINE_WIDTH - last_line); ++j) printf(" "); printf("| "); line = buffer + (line_count * LINE_WIDTH); for (j = 0; j < last_line; ++j, ++line) printf("%c", (*line >= 32 && *line <= 126) ? *line : '.'); printf("\n"); } printf("\n"); } #ifdef GIT_LEGACY_HASH uint32_t git__hash(const void *key, int len, unsigned int seed) { const uint32_t m = 0x5bd1e995; const int r = 24; uint32_t h = seed ^ len; const unsigned char *data = (const unsigned char *)key; while(len >= 4) { uint32_t k = *(uint32_t *)data; k *= m; k ^= k >> r; k *= m; h *= m; h ^= k; data += 4; len -= 4; } switch(len) { case 3: h ^= data[2] << 16; case 2: h ^= data[1] << 8; case 1: h ^= data[0]; h *= m; }; h ^= h >> 13; h *= m; h ^= h >> 15; return h; } #else /* Cross-platform version of Murmurhash3 http://code.google.com/p/smhasher/wiki/MurmurHash3 by Austin Appleby (aappleby@gmail.com) This code is on the public domain. */ uint32_t git__hash(const void *key, int len, uint32_t seed) { #define MURMUR_BLOCK() {\ k1 *= c1; \ k1 = git__rotl(k1,11);\ k1 *= c2;\ h1 ^= k1;\ h1 = h1*3 + 0x52dce729;\ c1 = c1*5 + 0x7b7d159c;\ c2 = c2*5 + 0x6bce6396;\ } const uint8_t *data = (const uint8_t*)key; const int nblocks = len / 4; const uint32_t *blocks = (const uint32_t *)(data + nblocks * 4); const uint8_t *tail = (const uint8_t *)(data + nblocks * 4); uint32_t h1 = 0x971e137b ^ seed; uint32_t k1; uint32_t c1 = 0x95543787; uint32_t c2 = 0x2ad7eb25; int i; for (i = -nblocks; i; i++) { k1 = blocks[i]; MURMUR_BLOCK(); } k1 = 0; switch(len & 3) { case 3: k1 ^= tail[2] << 16; case 2: k1 ^= tail[1] << 8; case 1: k1 ^= tail[0]; MURMUR_BLOCK(); } h1 ^= len; h1 ^= h1 >> 16; h1 *= 0x85ebca6b; h1 ^= h1 >> 13; h1 *= 0xc2b2ae35; h1 ^= h1 >> 16; return h1; } #endif /** * A modified `bsearch` from the BSD glibc. * * Copyright (c) 1990 Regents of the University of California. * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. [rescinded 22 July 1999] * 4. Neither the name of the University 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 THE REGENTS AND CONTRIBUTORS ``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 THE REGENTS OR CONTRIBUTORS 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. */ int git__bsearch( void **array, size_t array_len, const void *key, int (*compare)(const void *, const void *), size_t *position) { size_t lim; int cmp = -1; void **part, **base = array; for (lim = array_len; lim != 0; lim >>= 1) { part = base + (lim >> 1); cmp = (*compare)(key, *part); if (cmp == 0) { base = part; break; } if (cmp > 0) { /* key > p; take right partition */ base = part + 1; lim--; } /* else take left partition */ } if (position) *position = (base - array); return (cmp == 0) ? 0 : GIT_ENOTFOUND; } int git__bsearch_r( void **array, size_t array_len, const void *key, int (*compare_r)(const void *, const void *, void *), void *payload, size_t *position) { size_t lim; int cmp = -1; void **part, **base = array; for (lim = array_len; lim != 0; lim >>= 1) { part = base + (lim >> 1); cmp = (*compare_r)(key, *part, payload); if (cmp == 0) { base = part; break; } if (cmp > 0) { /* key > p; take right partition */ base = part + 1; lim--; } /* else take left partition */ } if (position) *position = (base - array); return (cmp == 0) ? 0 : GIT_ENOTFOUND; } /** * A strcmp wrapper * * We don't want direct pointers to the CRT on Windows, we may * get stdcall conflicts. */ int git__strcmp_cb(const void *a, const void *b) { return strcmp((const char *)a, (const char *)b); } int git__strcasecmp_cb(const void *a, const void *b) { return strcasecmp((const char *)a, (const char *)b); } int git__parse_bool(int *out, const char *value) { /* A missing value means true */ if (value == NULL || !strcasecmp(value, "true") || !strcasecmp(value, "yes") || !strcasecmp(value, "on")) { *out = 1; return 0; } if (!strcasecmp(value, "false") || !strcasecmp(value, "no") || !strcasecmp(value, "off") || value[0] == '\0') { *out = 0; return 0; } return -1; } size_t git__unescape(char *str) { char *scan, *pos = str; if (!str) return 0; for (scan = str; *scan; pos++, scan++) { if (*scan == '\\' && *(scan + 1) != '\0') scan++; /* skip '\' but include next char */ if (pos != scan) *pos = *scan; } if (pos != scan) { *pos = '\0'; } return (pos - str); } #if defined(HAVE_QSORT_S) || (defined(HAVE_QSORT_R) && defined(BSD)) typedef struct { git__sort_r_cmp cmp; void *payload; } git__qsort_r_glue; static int GIT_STDLIB_CALL git__qsort_r_glue_cmp( void *payload, const void *a, const void *b) { git__qsort_r_glue *glue = payload; return glue->cmp(a, b, glue->payload); } #endif void git__qsort_r( void *els, size_t nel, size_t elsize, git__sort_r_cmp cmp, void *payload) { #if defined(HAVE_QSORT_R) && defined(BSD) git__qsort_r_glue glue = { cmp, payload }; qsort_r(els, nel, elsize, &glue, git__qsort_r_glue_cmp); #elif defined(HAVE_QSORT_R) && defined(__GLIBC__) qsort_r(els, nel, elsize, cmp, payload); #elif defined(HAVE_QSORT_S) git__qsort_r_glue glue = { cmp, payload }; qsort_s(els, nel, elsize, git__qsort_r_glue_cmp, &glue); #else git__insertsort_r(els, nel, elsize, NULL, cmp, payload); #endif } void git__insertsort_r( void *els, size_t nel, size_t elsize, void *swapel, git__sort_r_cmp cmp, void *payload) { uint8_t *base = els; uint8_t *end = base + nel * elsize; uint8_t *i, *j; bool freeswap = !swapel; if (freeswap) swapel = git__malloc(elsize); for (i = base + elsize; i < end; i += elsize) for (j = i; j > base && cmp(j, j - elsize, payload) < 0; j -= elsize) { memcpy(swapel, j, elsize); memcpy(j, j - elsize, elsize); memcpy(j - elsize, swapel, elsize); } if (freeswap) git__free(swapel); } /* * git__utf8_iterate is taken from the utf8proc project, * http://www.public-software-group.org/utf8proc * * Copyright (c) 2009 Public Software Group e. V., Berlin, Germany * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the ""Software""), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ static const int8_t utf8proc_utf8class[256] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0 }; int git__utf8_charlen(const uint8_t *str, int str_len) { int length, i; length = utf8proc_utf8class[str[0]]; if (!length) return -1; if (str_len >= 0 && length > str_len) return -str_len; for (i = 1; i < length; i++) { if ((str[i] & 0xC0) != 0x80) return -i; } return length; } int git__utf8_iterate(const uint8_t *str, int str_len, int32_t *dst) { int length; int32_t uc = -1; *dst = -1; length = git__utf8_charlen(str, str_len); if (length < 0) return -1; switch (length) { case 1: uc = str[0]; break; case 2: uc = ((str[0] & 0x1F) << 6) + (str[1] & 0x3F); if (uc < 0x80) uc = -1; break; case 3: uc = ((str[0] & 0x0F) << 12) + ((str[1] & 0x3F) << 6) + (str[2] & 0x3F); if (uc < 0x800 || (uc >= 0xD800 && uc < 0xE000) || (uc >= 0xFDD0 && uc < 0xFDF0)) uc = -1; break; case 4: uc = ((str[0] & 0x07) << 18) + ((str[1] & 0x3F) << 12) + ((str[2] & 0x3F) << 6) + (str[3] & 0x3F); if (uc < 0x10000 || uc >= 0x110000) uc = -1; break; } if (uc < 0 || ((uc & 0xFFFF) >= 0xFFFE)) return -1; *dst = uc; return length; } #ifdef GIT_WIN32 int git__getenv(git_buf *out, const char *name) { wchar_t *wide_name = NULL, *wide_value = NULL; DWORD value_len; int error = -1; git_buf_clear(out); if (git__utf8_to_16_alloc(&wide_name, name) < 0) return -1; if ((value_len = GetEnvironmentVariableW(wide_name, NULL, 0)) > 0) { wide_value = git__malloc(value_len * sizeof(wchar_t)); GITERR_CHECK_ALLOC(wide_value); value_len = GetEnvironmentVariableW(wide_name, wide_value, value_len); } if (value_len) error = git_buf_put_w(out, wide_value, value_len); else if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) error = GIT_ENOTFOUND; else giterr_set(GITERR_OS, "could not read environment variable '%s'", name); git__free(wide_name); git__free(wide_value); return error; } #else int git__getenv(git_buf *out, const char *name) { const char *val = getenv(name); git_buf_clear(out); if (!val) return GIT_ENOTFOUND; return git_buf_puts(out, val); } #endif deps/libgit2-sys-0.3.8/libgit2/src/crlf.c0000664000175000017500000002140312555730137014774 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/attr.h" #include "git2/blob.h" #include "git2/index.h" #include "git2/sys/filter.h" #include "common.h" #include "fileops.h" #include "hash.h" #include "filter.h" #include "buf_text.h" #include "repository.h" struct crlf_attrs { int crlf_action; int eol; int auto_crlf; int safe_crlf; }; struct crlf_filter { git_filter f; }; static int check_crlf(const char *value) { if (GIT_ATTR_TRUE(value)) return GIT_CRLF_TEXT; if (GIT_ATTR_FALSE(value)) return GIT_CRLF_BINARY; if (GIT_ATTR_UNSPECIFIED(value)) return GIT_CRLF_GUESS; if (strcmp(value, "input") == 0) return GIT_CRLF_INPUT; if (strcmp(value, "auto") == 0) return GIT_CRLF_AUTO; return GIT_CRLF_GUESS; } static int check_eol(const char *value) { if (GIT_ATTR_UNSPECIFIED(value)) return GIT_EOL_UNSET; if (strcmp(value, "lf") == 0) return GIT_EOL_LF; if (strcmp(value, "crlf") == 0) return GIT_EOL_CRLF; return GIT_EOL_UNSET; } static int crlf_input_action(struct crlf_attrs *ca) { if (ca->crlf_action == GIT_CRLF_BINARY) return GIT_CRLF_BINARY; if (ca->eol == GIT_EOL_LF) return GIT_CRLF_INPUT; if (ca->eol == GIT_EOL_CRLF) return GIT_CRLF_CRLF; return ca->crlf_action; } static int has_cr_in_index(const git_filter_source *src) { git_repository *repo = git_filter_source_repo(src); const char *path = git_filter_source_path(src); git_index *index; const git_index_entry *entry; git_blob *blob; const void *blobcontent; git_off_t blobsize; bool found_cr; if (!path) return false; if (git_repository_index__weakptr(&index, repo) < 0) { giterr_clear(); return false; } if (!(entry = git_index_get_bypath(index, path, 0)) && !(entry = git_index_get_bypath(index, path, 1))) return false; if (!S_ISREG(entry->mode)) /* don't crlf filter non-blobs */ return true; if (git_blob_lookup(&blob, repo, &entry->id) < 0) return false; blobcontent = git_blob_rawcontent(blob); blobsize = git_blob_rawsize(blob); if (!git__is_sizet(blobsize)) blobsize = (size_t)-1; found_cr = (blobcontent != NULL && blobsize > 0 && memchr(blobcontent, '\r', (size_t)blobsize) != NULL); git_blob_free(blob); return found_cr; } static int crlf_apply_to_odb( struct crlf_attrs *ca, git_buf *to, const git_buf *from, const git_filter_source *src) { /* Empty file? Nothing to do */ if (!git_buf_len(from)) return 0; /* Heuristics to see if we can skip the conversion. * Straight from Core Git. */ if (ca->crlf_action == GIT_CRLF_AUTO || ca->crlf_action == GIT_CRLF_GUESS) { git_buf_text_stats stats; /* Check heuristics for binary vs text - returns true if binary */ if (git_buf_text_gather_stats(&stats, from, false)) return GIT_PASSTHROUGH; /* If there are no CR characters to filter out, then just pass */ if (!stats.cr) return GIT_PASSTHROUGH; /* If safecrlf is enabled, sanity-check the result. */ if (stats.cr != stats.crlf || stats.lf != stats.crlf) { switch (ca->safe_crlf) { case GIT_SAFE_CRLF_FAIL: giterr_set( GITERR_FILTER, "LF would be replaced by CRLF in '%s'", git_filter_source_path(src)); return -1; case GIT_SAFE_CRLF_WARN: /* TODO: issue warning when warning API is available */; break; default: break; } } /* * We're currently not going to even try to convert stuff * that has bare CR characters. Does anybody do that crazy * stuff? */ if (stats.cr != stats.crlf) return GIT_PASSTHROUGH; if (ca->crlf_action == GIT_CRLF_GUESS) { /* * If the file in the index has any CR in it, do not convert. * This is the new safer autocrlf handling. */ if (has_cr_in_index(src)) return GIT_PASSTHROUGH; } if (!stats.cr) return GIT_PASSTHROUGH; } /* Actually drop the carriage returns */ return git_buf_text_crlf_to_lf(to, from); } static const char *line_ending(struct crlf_attrs *ca) { switch (ca->crlf_action) { case GIT_CRLF_BINARY: case GIT_CRLF_INPUT: return "\n"; case GIT_CRLF_CRLF: return "\r\n"; case GIT_CRLF_GUESS: if (ca->auto_crlf == GIT_AUTO_CRLF_FALSE) return "\n"; break; case GIT_CRLF_AUTO: case GIT_CRLF_TEXT: break; default: goto line_ending_error; } if (ca->auto_crlf == GIT_AUTO_CRLF_TRUE) return "\r\n"; else if (ca->auto_crlf == GIT_AUTO_CRLF_INPUT) return "\n"; else if (ca->eol == GIT_EOL_UNSET) return GIT_EOL_NATIVE == GIT_EOL_CRLF ? "\r\n" : "\n"; else if (ca->eol == GIT_EOL_LF) return "\n"; else if (ca->eol == GIT_EOL_CRLF) return "\r\n"; line_ending_error: giterr_set(GITERR_INVALID, "Invalid input to line ending filter"); return NULL; } static int crlf_apply_to_workdir( struct crlf_attrs *ca, git_buf *to, const git_buf *from) { git_buf_text_stats stats; const char *workdir_ending = NULL; bool is_binary; /* Empty file? Nothing to do. */ if (git_buf_len(from) == 0) return 0; /* Determine proper line ending */ workdir_ending = line_ending(ca); if (!workdir_ending) return -1; /* only LF->CRLF conversion is supported, do nothing on LF platforms */ if (strcmp(workdir_ending, "\r\n") != 0) return GIT_PASSTHROUGH; /* If there are no LFs, or all LFs are part of a CRLF, nothing to do */ is_binary = git_buf_text_gather_stats(&stats, from, false); if (stats.lf == 0 || stats.lf == stats.crlf) return GIT_PASSTHROUGH; if (ca->crlf_action == GIT_CRLF_AUTO || ca->crlf_action == GIT_CRLF_GUESS) { /* If we have any existing CR or CRLF line endings, do nothing */ if (ca->crlf_action == GIT_CRLF_GUESS && stats.cr > 0 && stats.crlf > 0) return GIT_PASSTHROUGH; /* If we have bare CR characters, do nothing */ if (stats.cr != stats.crlf) return GIT_PASSTHROUGH; /* Don't filter binary files */ if (is_binary) return GIT_PASSTHROUGH; } return git_buf_text_lf_to_crlf(to, from); } static int crlf_check( git_filter *self, void **payload, /* points to NULL ptr on entry, may be set */ const git_filter_source *src, const char **attr_values) { int error; struct crlf_attrs ca; GIT_UNUSED(self); if (!attr_values) { ca.crlf_action = GIT_CRLF_GUESS; ca.eol = GIT_EOL_UNSET; } else { ca.crlf_action = check_crlf(attr_values[2]); /* text */ if (ca.crlf_action == GIT_CRLF_GUESS) ca.crlf_action = check_crlf(attr_values[0]); /* clrf */ ca.eol = check_eol(attr_values[1]); /* eol */ } ca.auto_crlf = GIT_AUTO_CRLF_DEFAULT; /* * Use the core Git logic to see if we should perform CRLF for this file * based on its attributes & the value of `core.autocrlf` */ ca.crlf_action = crlf_input_action(&ca); if (ca.crlf_action == GIT_CRLF_BINARY) return GIT_PASSTHROUGH; if (ca.crlf_action == GIT_CRLF_GUESS || ((ca.crlf_action == GIT_CRLF_AUTO || ca.crlf_action == GIT_CRLF_TEXT) && git_filter_source_mode(src) == GIT_FILTER_SMUDGE)) { error = git_repository__cvar( &ca.auto_crlf, git_filter_source_repo(src), GIT_CVAR_AUTO_CRLF); if (error < 0) return error; if (ca.crlf_action == GIT_CRLF_GUESS && ca.auto_crlf == GIT_AUTO_CRLF_FALSE) return GIT_PASSTHROUGH; if (ca.auto_crlf == GIT_AUTO_CRLF_INPUT && git_filter_source_mode(src) == GIT_FILTER_SMUDGE) return GIT_PASSTHROUGH; } if (git_filter_source_mode(src) == GIT_FILTER_CLEAN) { error = git_repository__cvar( &ca.safe_crlf, git_filter_source_repo(src), GIT_CVAR_SAFE_CRLF); if (error < 0) return error; /* downgrade FAIL to WARN if ALLOW_UNSAFE option is used */ if ((git_filter_source_flags(src) & GIT_FILTER_ALLOW_UNSAFE) && ca.safe_crlf == GIT_SAFE_CRLF_FAIL) ca.safe_crlf = GIT_SAFE_CRLF_WARN; } *payload = git__malloc(sizeof(ca)); GITERR_CHECK_ALLOC(*payload); memcpy(*payload, &ca, sizeof(ca)); return 0; } static int crlf_apply( git_filter *self, void **payload, /* may be read and/or set */ git_buf *to, const git_buf *from, const git_filter_source *src) { /* initialize payload in case `check` was bypassed */ if (!*payload) { int error = crlf_check(self, payload, src, NULL); if (error < 0 && error != GIT_PASSTHROUGH) return error; } if (git_filter_source_mode(src) == GIT_FILTER_SMUDGE) return crlf_apply_to_workdir(*payload, to, from); else return crlf_apply_to_odb(*payload, to, from, src); } static void crlf_cleanup( git_filter *self, void *payload) { GIT_UNUSED(self); git__free(payload); } git_filter *git_crlf_filter_new(void) { struct crlf_filter *f = git__calloc(1, sizeof(struct crlf_filter)); if (f == NULL) return NULL; f->f.version = GIT_FILTER_VERSION; f->f.attributes = "crlf eol text"; f->f.initialize = NULL; f->f.shutdown = git_filter_free; f->f.check = crlf_check; f->f.apply = crlf_apply; f->f.cleanup = crlf_cleanup; return (git_filter *)f; } deps/libgit2-sys-0.3.8/libgit2/src/reset.c0000664000175000017500000001203612555730137015172 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "commit.h" #include "tag.h" #include "merge.h" #include "diff.h" #include "annotated_commit.h" #include "git2/reset.h" #include "git2/checkout.h" #include "git2/merge.h" #include "git2/refs.h" #define ERROR_MSG "Cannot perform reset" int git_reset_default( git_repository *repo, git_object *target, git_strarray* pathspecs) { git_object *commit = NULL; git_tree *tree = NULL; git_diff *diff = NULL; git_diff_options opts = GIT_DIFF_OPTIONS_INIT; size_t i, max_i; git_index_entry entry; int error; git_index *index = NULL; assert(pathspecs != NULL && pathspecs->count > 0); memset(&entry, 0, sizeof(git_index_entry)); if ((error = git_repository_index(&index, repo)) < 0) goto cleanup; if (target) { if (git_object_owner(target) != repo) { giterr_set(GITERR_OBJECT, "%s_default - The given target does not belong to this repository.", ERROR_MSG); return -1; } if ((error = git_object_peel(&commit, target, GIT_OBJ_COMMIT)) < 0 || (error = git_commit_tree(&tree, (git_commit *)commit)) < 0) goto cleanup; } opts.pathspec = *pathspecs; opts.flags = GIT_DIFF_REVERSE; if ((error = git_diff_tree_to_index( &diff, repo, tree, index, &opts)) < 0) goto cleanup; for (i = 0, max_i = git_diff_num_deltas(diff); i < max_i; ++i) { const git_diff_delta *delta = git_diff_get_delta(diff, i); assert(delta->status == GIT_DELTA_ADDED || delta->status == GIT_DELTA_MODIFIED || delta->status == GIT_DELTA_CONFLICTED || delta->status == GIT_DELTA_DELETED); error = git_index_conflict_remove(index, delta->old_file.path); if (error < 0) { if (delta->status == GIT_DELTA_ADDED && error == GIT_ENOTFOUND) giterr_clear(); else goto cleanup; } if (delta->status == GIT_DELTA_DELETED) { if ((error = git_index_remove(index, delta->old_file.path, 0)) < 0) goto cleanup; } else { entry.mode = delta->new_file.mode; git_oid_cpy(&entry.id, &delta->new_file.id); entry.path = (char *)delta->new_file.path; if ((error = git_index_add(index, &entry)) < 0) goto cleanup; } } error = git_index_write(index); cleanup: git_object_free(commit); git_tree_free(tree); git_index_free(index); git_diff_free(diff); return error; } static int reset( git_repository *repo, git_object *target, const char *to, git_reset_t reset_type, const git_checkout_options *checkout_opts) { git_object *commit = NULL; git_index *index = NULL; git_tree *tree = NULL; int error = 0; git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; git_buf log_message = GIT_BUF_INIT; assert(repo && target); if (checkout_opts) opts = *checkout_opts; if (git_object_owner(target) != repo) { giterr_set(GITERR_OBJECT, "%s - The given target does not belong to this repository.", ERROR_MSG); return -1; } if (reset_type != GIT_RESET_SOFT && (error = git_repository__ensure_not_bare(repo, reset_type == GIT_RESET_MIXED ? "reset mixed" : "reset hard")) < 0) return error; if ((error = git_object_peel(&commit, target, GIT_OBJ_COMMIT)) < 0 || (error = git_repository_index(&index, repo)) < 0 || (error = git_commit_tree(&tree, (git_commit *)commit)) < 0) goto cleanup; if (reset_type == GIT_RESET_SOFT && (git_repository_state(repo) == GIT_REPOSITORY_STATE_MERGE || git_index_has_conflicts(index))) { giterr_set(GITERR_OBJECT, "%s (soft) in the middle of a merge.", ERROR_MSG); error = GIT_EUNMERGED; goto cleanup; } if ((error = git_buf_printf(&log_message, "reset: moving to %s", to)) < 0) return error; /* move HEAD to the new target */ if ((error = git_reference__update_terminal(repo, GIT_HEAD_FILE, git_object_id(commit), NULL, git_buf_cstr(&log_message))) < 0) goto cleanup; if (reset_type == GIT_RESET_HARD) { /* overwrite working directory with HEAD */ opts.checkout_strategy = GIT_CHECKOUT_FORCE; if ((error = git_checkout_tree(repo, (git_object *)tree, &opts)) < 0) goto cleanup; } if (reset_type > GIT_RESET_SOFT) { /* reset index to the target content */ if ((error = git_index_read_tree(index, tree)) < 0 || (error = git_index_write(index)) < 0) goto cleanup; if ((error = git_repository_state_cleanup(repo)) < 0) { giterr_set(GITERR_INDEX, "%s - failed to clean up merge data", ERROR_MSG); goto cleanup; } } cleanup: git_object_free(commit); git_index_free(index); git_tree_free(tree); git_buf_free(&log_message); return error; } int git_reset( git_repository *repo, git_object *target, git_reset_t reset_type, const git_checkout_options *checkout_opts) { return reset(repo, target, git_oid_tostr_s(git_object_id(target)), reset_type, checkout_opts); } int git_reset_from_annotated( git_repository *repo, git_annotated_commit *commit, git_reset_t reset_type, const git_checkout_options *checkout_opts) { return reset(repo, (git_object *) commit->commit, commit->ref_name, reset_type, checkout_opts); } deps/libgit2-sys-0.3.8/libgit2/src/fetch.h0000664000175000017500000000102212555730137015137 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_fetch_h__ #define INCLUDE_fetch_h__ #include "netops.h" int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts); int git_fetch_download_pack(git_remote *remote, const git_remote_callbacks *callbacks); int git_fetch_setup_walk(git_revwalk **out, git_repository *repo); #endif deps/libgit2-sys-0.3.8/libgit2/src/pathspec.c0000664000175000017500000004145212572105236015656 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/pathspec.h" #include "git2/diff.h" #include "pathspec.h" #include "buf_text.h" #include "attr_file.h" #include "iterator.h" #include "repository.h" #include "index.h" #include "bitvec.h" #include "diff.h" /* what is the common non-wildcard prefix for all items in the pathspec */ char *git_pathspec_prefix(const git_strarray *pathspec) { git_buf prefix = GIT_BUF_INIT; const char *scan; if (!pathspec || !pathspec->count || git_buf_text_common_prefix(&prefix, pathspec) < 0) return NULL; /* diff prefix will only be leading non-wildcards */ for (scan = prefix.ptr; *scan; ++scan) { if (git__iswildcard(*scan) && (scan == prefix.ptr || (*(scan - 1) != '\\'))) break; } git_buf_truncate(&prefix, scan - prefix.ptr); if (prefix.size <= 0) { git_buf_free(&prefix); return NULL; } git_buf_text_unescape(&prefix); return git_buf_detach(&prefix); } /* is there anything in the spec that needs to be filtered on */ bool git_pathspec_is_empty(const git_strarray *pathspec) { size_t i; if (pathspec == NULL) return true; for (i = 0; i < pathspec->count; ++i) { const char *str = pathspec->strings[i]; if (str && str[0]) return false; } return true; } /* build a vector of fnmatch patterns to evaluate efficiently */ int git_pathspec__vinit( git_vector *vspec, const git_strarray *strspec, git_pool *strpool) { size_t i; memset(vspec, 0, sizeof(*vspec)); if (git_pathspec_is_empty(strspec)) return 0; if (git_vector_init(vspec, strspec->count, NULL) < 0) return -1; for (i = 0; i < strspec->count; ++i) { int ret; const char *pattern = strspec->strings[i]; git_attr_fnmatch *match = git__calloc(1, sizeof(git_attr_fnmatch)); if (!match) return -1; match->flags = GIT_ATTR_FNMATCH_ALLOWSPACE | GIT_ATTR_FNMATCH_ALLOWNEG | GIT_ATTR_FNMATCH_NOLEADINGDIR; ret = git_attr_fnmatch__parse(match, strpool, NULL, &pattern); if (ret == GIT_ENOTFOUND) { git__free(match); continue; } else if (ret < 0) { git__free(match); return ret; } if (git_vector_insert(vspec, match) < 0) return -1; } return 0; } /* free data from the pathspec vector */ void git_pathspec__vfree(git_vector *vspec) { git_vector_free_deep(vspec); } struct pathspec_match_context { int fnmatch_flags; int (*strcomp)(const char *, const char *); int (*strncomp)(const char *, const char *, size_t); }; static void pathspec_match_context_init( struct pathspec_match_context *ctxt, bool disable_fnmatch, bool casefold) { if (disable_fnmatch) ctxt->fnmatch_flags = -1; else if (casefold) ctxt->fnmatch_flags = FNM_CASEFOLD; else ctxt->fnmatch_flags = 0; if (casefold) { ctxt->strcomp = git__strcasecmp; ctxt->strncomp = git__strncasecmp; } else { ctxt->strcomp = git__strcmp; ctxt->strncomp = git__strncmp; } } static int pathspec_match_one( const git_attr_fnmatch *match, struct pathspec_match_context *ctxt, const char *path) { int result = (match->flags & GIT_ATTR_FNMATCH_MATCH_ALL) ? 0 : FNM_NOMATCH; if (result == FNM_NOMATCH) result = ctxt->strcomp(match->pattern, path) ? FNM_NOMATCH : 0; if (ctxt->fnmatch_flags >= 0 && result == FNM_NOMATCH) result = p_fnmatch(match->pattern, path, ctxt->fnmatch_flags); /* if we didn't match, look for exact dirname prefix match */ if (result == FNM_NOMATCH && (match->flags & GIT_ATTR_FNMATCH_HASWILD) == 0 && ctxt->strncomp(path, match->pattern, match->length) == 0 && path[match->length] == '/') result = 0; /* if we didn't match and this is a negative match, check for exact * match of filename with leading '!' */ if (result == FNM_NOMATCH && (match->flags & GIT_ATTR_FNMATCH_NEGATIVE) != 0 && *path == '!' && ctxt->strncomp(path + 1, match->pattern, match->length) == 0 && (!path[match->length + 1] || path[match->length + 1] == '/')) return 1; if (result == 0) return (match->flags & GIT_ATTR_FNMATCH_NEGATIVE) ? 0 : 1; return -1; } static int git_pathspec__match_at( size_t *matched_at, const git_vector *vspec, struct pathspec_match_context *ctxt, const char *path0, const char *path1) { int result = GIT_ENOTFOUND; size_t i = 0; const git_attr_fnmatch *match; git_vector_foreach(vspec, i, match) { if (path0 && (result = pathspec_match_one(match, ctxt, path0)) >= 0) break; if (path1 && (result = pathspec_match_one(match, ctxt, path1)) >= 0) break; } *matched_at = i; return result; } /* match a path against the vectorized pathspec */ bool git_pathspec__match( const git_vector *vspec, const char *path, bool disable_fnmatch, bool casefold, const char **matched_pathspec, size_t *matched_at) { int result; size_t pos; struct pathspec_match_context ctxt; if (matched_pathspec) *matched_pathspec = NULL; if (matched_at) *matched_at = GIT_PATHSPEC_NOMATCH; if (!vspec || !vspec->length) return true; pathspec_match_context_init(&ctxt, disable_fnmatch, casefold); result = git_pathspec__match_at(&pos, vspec, &ctxt, path, NULL); if (result >= 0) { if (matched_pathspec) { const git_attr_fnmatch *match = git_vector_get(vspec, pos); *matched_pathspec = match->pattern; } if (matched_at) *matched_at = pos; } return (result > 0); } int git_pathspec__init(git_pathspec *ps, const git_strarray *paths) { int error = 0; memset(ps, 0, sizeof(*ps)); ps->prefix = git_pathspec_prefix(paths); if ((error = git_pool_init(&ps->pool, 1, 0)) < 0 || (error = git_pathspec__vinit(&ps->pathspec, paths, &ps->pool)) < 0) git_pathspec__clear(ps); return error; } void git_pathspec__clear(git_pathspec *ps) { git__free(ps->prefix); git_pathspec__vfree(&ps->pathspec); git_pool_clear(&ps->pool); memset(ps, 0, sizeof(*ps)); } int git_pathspec_new(git_pathspec **out, const git_strarray *pathspec) { int error = 0; git_pathspec *ps = git__malloc(sizeof(git_pathspec)); GITERR_CHECK_ALLOC(ps); if ((error = git_pathspec__init(ps, pathspec)) < 0) { git__free(ps); return error; } GIT_REFCOUNT_INC(ps); *out = ps; return 0; } static void pathspec_free(git_pathspec *ps) { git_pathspec__clear(ps); git__free(ps); } void git_pathspec_free(git_pathspec *ps) { if (!ps) return; GIT_REFCOUNT_DEC(ps, pathspec_free); } int git_pathspec_matches_path( const git_pathspec *ps, uint32_t flags, const char *path) { bool no_fnmatch = (flags & GIT_PATHSPEC_NO_GLOB) != 0; bool casefold = (flags & GIT_PATHSPEC_IGNORE_CASE) != 0; assert(ps && path); return (0 != git_pathspec__match( &ps->pathspec, path, no_fnmatch, casefold, NULL, NULL)); } static void pathspec_match_free(git_pathspec_match_list *m) { if (!m) return; git_pathspec_free(m->pathspec); m->pathspec = NULL; git_array_clear(m->matches); git_array_clear(m->failures); git_pool_clear(&m->pool); git__free(m); } static git_pathspec_match_list *pathspec_match_alloc( git_pathspec *ps, int datatype) { git_pathspec_match_list *m = git__calloc(1, sizeof(git_pathspec_match_list)); if (m != NULL && git_pool_init(&m->pool, 1, 0) < 0) { pathspec_match_free(m); m = NULL; } if (!m) return NULL; /* need to keep reference to pathspec and increment refcount because * failures array stores pointers to the pattern strings of the * pathspec that had no matches */ GIT_REFCOUNT_INC(ps); m->pathspec = ps; m->datatype = datatype; return m; } GIT_INLINE(size_t) pathspec_mark_pattern(git_bitvec *used, size_t pos) { if (!git_bitvec_get(used, pos)) { git_bitvec_set(used, pos, true); return 1; } return 0; } static size_t pathspec_mark_remaining( git_bitvec *used, git_vector *patterns, struct pathspec_match_context *ctxt, size_t start, const char *path0, const char *path1) { size_t count = 0; if (path1 == path0) path1 = NULL; for (; start < patterns->length; ++start) { const git_attr_fnmatch *pat = git_vector_get(patterns, start); if (git_bitvec_get(used, start)) continue; if (path0 && pathspec_match_one(pat, ctxt, path0) > 0) count += pathspec_mark_pattern(used, start); else if (path1 && pathspec_match_one(pat, ctxt, path1) > 0) count += pathspec_mark_pattern(used, start); } return count; } static int pathspec_build_failure_array( git_pathspec_string_array_t *failures, git_vector *patterns, git_bitvec *used, git_pool *pool) { size_t pos; char **failed; const git_attr_fnmatch *pat; for (pos = 0; pos < patterns->length; ++pos) { if (git_bitvec_get(used, pos)) continue; if ((failed = git_array_alloc(*failures)) == NULL) return -1; pat = git_vector_get(patterns, pos); if ((*failed = git_pool_strdup(pool, pat->pattern)) == NULL) return -1; } return 0; } static int pathspec_match_from_iterator( git_pathspec_match_list **out, git_iterator *iter, uint32_t flags, git_pathspec *ps) { int error = 0; git_pathspec_match_list *m = NULL; const git_index_entry *entry = NULL; struct pathspec_match_context ctxt; git_vector *patterns = &ps->pathspec; bool find_failures = out && (flags & GIT_PATHSPEC_FIND_FAILURES) != 0; bool failures_only = !out || (flags & GIT_PATHSPEC_FAILURES_ONLY) != 0; size_t pos, used_ct = 0, found_files = 0; git_index *index = NULL; git_bitvec used_patterns; char **file; if (git_bitvec_init(&used_patterns, patterns->length) < 0) return -1; if (out) { *out = m = pathspec_match_alloc(ps, PATHSPEC_DATATYPE_STRINGS); GITERR_CHECK_ALLOC(m); } if ((error = git_iterator_reset(iter, ps->prefix, ps->prefix)) < 0) goto done; if (git_iterator_type(iter) == GIT_ITERATOR_TYPE_WORKDIR && (error = git_repository_index__weakptr( &index, git_iterator_owner(iter))) < 0) goto done; pathspec_match_context_init( &ctxt, (flags & GIT_PATHSPEC_NO_GLOB) != 0, git_iterator_ignore_case(iter)); while (!(error = git_iterator_advance(&entry, iter))) { /* search for match with entry->path */ int result = git_pathspec__match_at( &pos, patterns, &ctxt, entry->path, NULL); /* no matches for this path */ if (result < 0) continue; /* if result was a negative pattern match, then don't list file */ if (!result) { used_ct += pathspec_mark_pattern(&used_patterns, pos); continue; } /* check if path is ignored and untracked */ if (index != NULL && git_iterator_current_is_ignored(iter) && git_index__find_pos(NULL, index, entry->path, 0, GIT_INDEX_STAGE_ANY) < 0) continue; /* mark the matched pattern as used */ used_ct += pathspec_mark_pattern(&used_patterns, pos); ++found_files; /* if find_failures is on, check if any later patterns also match */ if (find_failures && used_ct < patterns->length) used_ct += pathspec_mark_remaining( &used_patterns, patterns, &ctxt, pos + 1, entry->path, NULL); /* if only looking at failures, exit early or just continue */ if (failures_only || !out) { if (used_ct == patterns->length) break; continue; } /* insert matched path into matches array */ if ((file = (char **)git_array_alloc(m->matches)) == NULL || (*file = git_pool_strdup(&m->pool, entry->path)) == NULL) { error = -1; goto done; } } if (error < 0 && error != GIT_ITEROVER) goto done; error = 0; /* insert patterns that had no matches into failures array */ if (find_failures && used_ct < patterns->length && (error = pathspec_build_failure_array( &m->failures, patterns, &used_patterns, &m->pool)) < 0) goto done; /* if every pattern failed to match, then we have failed */ if ((flags & GIT_PATHSPEC_NO_MATCH_ERROR) != 0 && !found_files) { giterr_set(GITERR_INVALID, "No matching files were found"); error = GIT_ENOTFOUND; } done: git_bitvec_free(&used_patterns); if (error < 0) { pathspec_match_free(m); if (out) *out = NULL; } return error; } static git_iterator_flag_t pathspec_match_iter_flags(uint32_t flags) { git_iterator_flag_t f = 0; if ((flags & GIT_PATHSPEC_IGNORE_CASE) != 0) f |= GIT_ITERATOR_IGNORE_CASE; else if ((flags & GIT_PATHSPEC_USE_CASE) != 0) f |= GIT_ITERATOR_DONT_IGNORE_CASE; return f; } int git_pathspec_match_workdir( git_pathspec_match_list **out, git_repository *repo, uint32_t flags, git_pathspec *ps) { git_iterator *iter; git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT; int error = 0; assert(repo); iter_opts.flags = pathspec_match_iter_flags(flags); if (!(error = git_iterator_for_workdir(&iter, repo, NULL, NULL, &iter_opts))) { error = pathspec_match_from_iterator(out, iter, flags, ps); git_iterator_free(iter); } return error; } int git_pathspec_match_index( git_pathspec_match_list **out, git_index *index, uint32_t flags, git_pathspec *ps) { git_iterator *iter; git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT; int error = 0; assert(index); iter_opts.flags = pathspec_match_iter_flags(flags); if (!(error = git_iterator_for_index(&iter, index, &iter_opts))) { error = pathspec_match_from_iterator(out, iter, flags, ps); git_iterator_free(iter); } return error; } int git_pathspec_match_tree( git_pathspec_match_list **out, git_tree *tree, uint32_t flags, git_pathspec *ps) { git_iterator *iter; git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT; int error = 0; assert(tree); iter_opts.flags = pathspec_match_iter_flags(flags); if (!(error = git_iterator_for_tree(&iter, tree, &iter_opts))) { error = pathspec_match_from_iterator(out, iter, flags, ps); git_iterator_free(iter); } return error; } int git_pathspec_match_diff( git_pathspec_match_list **out, git_diff *diff, uint32_t flags, git_pathspec *ps) { int error = 0; git_pathspec_match_list *m = NULL; struct pathspec_match_context ctxt; git_vector *patterns = &ps->pathspec; bool find_failures = out && (flags & GIT_PATHSPEC_FIND_FAILURES) != 0; bool failures_only = !out || (flags & GIT_PATHSPEC_FAILURES_ONLY) != 0; size_t i, pos, used_ct = 0, found_deltas = 0; const git_diff_delta *delta, **match; git_bitvec used_patterns; assert(diff); if (git_bitvec_init(&used_patterns, patterns->length) < 0) return -1; if (out) { *out = m = pathspec_match_alloc(ps, PATHSPEC_DATATYPE_DIFF); GITERR_CHECK_ALLOC(m); } pathspec_match_context_init( &ctxt, (flags & GIT_PATHSPEC_NO_GLOB) != 0, git_diff_is_sorted_icase(diff)); git_vector_foreach(&diff->deltas, i, delta) { /* search for match with delta */ int result = git_pathspec__match_at( &pos, patterns, &ctxt, delta->old_file.path, delta->new_file.path); /* no matches for this path */ if (result < 0) continue; /* mark the matched pattern as used */ used_ct += pathspec_mark_pattern(&used_patterns, pos); /* if result was a negative pattern match, then don't list file */ if (!result) continue; ++found_deltas; /* if find_failures is on, check if any later patterns also match */ if (find_failures && used_ct < patterns->length) used_ct += pathspec_mark_remaining( &used_patterns, patterns, &ctxt, pos + 1, delta->old_file.path, delta->new_file.path); /* if only looking at failures, exit early or just continue */ if (failures_only || !out) { if (used_ct == patterns->length) break; continue; } /* insert matched delta into matches array */ if (!(match = (const git_diff_delta **)git_array_alloc(m->matches))) { error = -1; goto done; } else { *match = delta; } } /* insert patterns that had no matches into failures array */ if (find_failures && used_ct < patterns->length && (error = pathspec_build_failure_array( &m->failures, patterns, &used_patterns, &m->pool)) < 0) goto done; /* if every pattern failed to match, then we have failed */ if ((flags & GIT_PATHSPEC_NO_MATCH_ERROR) != 0 && !found_deltas) { giterr_set(GITERR_INVALID, "No matching deltas were found"); error = GIT_ENOTFOUND; } done: git_bitvec_free(&used_patterns); if (error < 0) { pathspec_match_free(m); if (out) *out = NULL; } return error; } void git_pathspec_match_list_free(git_pathspec_match_list *m) { if (m) pathspec_match_free(m); } size_t git_pathspec_match_list_entrycount( const git_pathspec_match_list *m) { return m ? git_array_size(m->matches) : 0; } const char *git_pathspec_match_list_entry( const git_pathspec_match_list *m, size_t pos) { if (!m || m->datatype != PATHSPEC_DATATYPE_STRINGS || !git_array_valid_index(m->matches, pos)) return NULL; return *((const char **)git_array_get(m->matches, pos)); } const git_diff_delta *git_pathspec_match_list_diff_entry( const git_pathspec_match_list *m, size_t pos) { if (!m || m->datatype != PATHSPEC_DATATYPE_DIFF || !git_array_valid_index(m->matches, pos)) return NULL; return *((const git_diff_delta **)git_array_get(m->matches, pos)); } size_t git_pathspec_match_list_failed_entrycount( const git_pathspec_match_list *m) { return m ? git_array_size(m->failures) : 0; } const char * git_pathspec_match_list_failed_entry( const git_pathspec_match_list *m, size_t pos) { char **entry = m ? git_array_get(m->failures, pos) : NULL; return entry ? *entry : NULL; } deps/libgit2-sys-0.3.8/libgit2/src/path.c0000664000175000017500000011323312610310643014771 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "path.h" #include "posix.h" #include "repository.h" #ifdef GIT_WIN32 #include "win32/posix.h" #include "win32/w32_buffer.h" #include "win32/w32_util.h" #include "win32/version.h" #else #include #endif #include #include #define LOOKS_LIKE_DRIVE_PREFIX(S) (git__isalpha((S)[0]) && (S)[1] == ':') #ifdef GIT_WIN32 static bool looks_like_network_computer_name(const char *path, int pos) { if (pos < 3) return false; if (path[0] != '/' || path[1] != '/') return false; while (pos-- > 2) { if (path[pos] == '/') return false; } return true; } #endif /* * Based on the Android implementation, BSD licensed. * http://android.git.kernel.org/ * * Copyright (C) 2008 The Android Open Source Project * All rights reserved. * * 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. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 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 THE * COPYRIGHT OWNER OR CONTRIBUTORS 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. */ int git_path_basename_r(git_buf *buffer, const char *path) { const char *endp, *startp; int len, result; /* Empty or NULL string gets treated as "." */ if (path == NULL || *path == '\0') { startp = "."; len = 1; goto Exit; } /* Strip trailing slashes */ endp = path + strlen(path) - 1; while (endp > path && *endp == '/') endp--; /* All slashes becomes "/" */ if (endp == path && *endp == '/') { startp = "/"; len = 1; goto Exit; } /* Find the start of the base */ startp = endp; while (startp > path && *(startp - 1) != '/') startp--; /* Cast is safe because max path < max int */ len = (int)(endp - startp + 1); Exit: result = len; if (buffer != NULL && git_buf_set(buffer, startp, len) < 0) return -1; return result; } /* * Based on the Android implementation, BSD licensed. * Check http://android.git.kernel.org/ */ int git_path_dirname_r(git_buf *buffer, const char *path) { const char *endp; int result, len; /* Empty or NULL string gets treated as "." */ if (path == NULL || *path == '\0') { path = "."; len = 1; goto Exit; } /* Strip trailing slashes */ endp = path + strlen(path) - 1; while (endp > path && *endp == '/') endp--; /* Find the start of the dir */ while (endp > path && *endp != '/') endp--; /* Either the dir is "/" or there are no slashes */ if (endp == path) { path = (*endp == '/') ? "/" : "."; len = 1; goto Exit; } do { endp--; } while (endp > path && *endp == '/'); /* Cast is safe because max path < max int */ len = (int)(endp - path + 1); #ifdef GIT_WIN32 /* Mimic unix behavior where '/.git' returns '/': 'C:/.git' will return 'C:/' here */ if (len == 2 && LOOKS_LIKE_DRIVE_PREFIX(path)) { len = 3; goto Exit; } /* Similarly checks if we're dealing with a network computer name '//computername/.git' will return '//computername/' */ if (looks_like_network_computer_name(path, len)) { len++; goto Exit; } #endif Exit: result = len; if (buffer != NULL && git_buf_set(buffer, path, len) < 0) return -1; return result; } char *git_path_dirname(const char *path) { git_buf buf = GIT_BUF_INIT; char *dirname; git_path_dirname_r(&buf, path); dirname = git_buf_detach(&buf); git_buf_free(&buf); /* avoid memleak if error occurs */ return dirname; } char *git_path_basename(const char *path) { git_buf buf = GIT_BUF_INIT; char *basename; git_path_basename_r(&buf, path); basename = git_buf_detach(&buf); git_buf_free(&buf); /* avoid memleak if error occurs */ return basename; } size_t git_path_basename_offset(git_buf *buffer) { ssize_t slash; if (!buffer || buffer->size <= 0) return 0; slash = git_buf_rfind_next(buffer, '/'); if (slash >= 0 && buffer->ptr[slash] == '/') return (size_t)(slash + 1); return 0; } const char *git_path_topdir(const char *path) { size_t len; ssize_t i; assert(path); len = strlen(path); if (!len || path[len - 1] != '/') return NULL; for (i = (ssize_t)len - 2; i >= 0; --i) if (path[i] == '/') break; return &path[i + 1]; } int git_path_root(const char *path) { int offset = 0; /* Does the root of the path look like a windows drive ? */ if (LOOKS_LIKE_DRIVE_PREFIX(path)) offset += 2; #ifdef GIT_WIN32 /* Are we dealing with a windows network path? */ else if ((path[0] == '/' && path[1] == '/' && path[2] != '/') || (path[0] == '\\' && path[1] == '\\' && path[2] != '\\')) { offset += 2; /* Skip the computer name segment */ while (path[offset] && path[offset] != '/' && path[offset] != '\\') offset++; } #endif if (path[offset] == '/' || path[offset] == '\\') return offset; return -1; /* Not a real error - signals that path is not rooted */ } void git_path_trim_slashes(git_buf *path) { int ceiling = git_path_root(path->ptr) + 1; assert(ceiling >= 0); while (path->size > (size_t)ceiling) { if (path->ptr[path->size-1] != '/') break; path->ptr[path->size-1] = '\0'; path->size--; } } int git_path_join_unrooted( git_buf *path_out, const char *path, const char *base, ssize_t *root_at) { ssize_t root; assert(path && path_out); root = (ssize_t)git_path_root(path); if (base != NULL && root < 0) { if (git_buf_joinpath(path_out, base, path) < 0) return -1; root = (ssize_t)strlen(base); } else { if (git_buf_sets(path_out, path) < 0) return -1; if (root < 0) root = 0; else if (base) git_path_equal_or_prefixed(base, path, &root); } if (root_at) *root_at = root; return 0; } int git_path_prettify(git_buf *path_out, const char *path, const char *base) { char buf[GIT_PATH_MAX]; assert(path && path_out); /* construct path if needed */ if (base != NULL && git_path_root(path) < 0) { if (git_buf_joinpath(path_out, base, path) < 0) return -1; path = path_out->ptr; } if (p_realpath(path, buf) == NULL) { /* giterr_set resets the errno when dealing with a GITERR_OS kind of error */ int error = (errno == ENOENT || errno == ENOTDIR) ? GIT_ENOTFOUND : -1; giterr_set(GITERR_OS, "Failed to resolve path '%s'", path); git_buf_clear(path_out); return error; } return git_buf_sets(path_out, buf); } int git_path_prettify_dir(git_buf *path_out, const char *path, const char *base) { int error = git_path_prettify(path_out, path, base); return (error < 0) ? error : git_path_to_dir(path_out); } int git_path_to_dir(git_buf *path) { if (path->asize > 0 && git_buf_len(path) > 0 && path->ptr[git_buf_len(path) - 1] != '/') git_buf_putc(path, '/'); return git_buf_oom(path) ? -1 : 0; } void git_path_string_to_dir(char* path, size_t size) { size_t end = strlen(path); if (end && path[end - 1] != '/' && end < size) { path[end] = '/'; path[end + 1] = '\0'; } } int git__percent_decode(git_buf *decoded_out, const char *input) { int len, hi, lo, i; assert(decoded_out && input); len = (int)strlen(input); git_buf_clear(decoded_out); for(i = 0; i < len; i++) { char c = input[i]; if (c != '%') goto append; if (i >= len - 2) goto append; hi = git__fromhex(input[i + 1]); lo = git__fromhex(input[i + 2]); if (hi < 0 || lo < 0) goto append; c = (char)(hi << 4 | lo); i += 2; append: if (git_buf_putc(decoded_out, c) < 0) return -1; } return 0; } static int error_invalid_local_file_uri(const char *uri) { giterr_set(GITERR_CONFIG, "'%s' is not a valid local file URI", uri); return -1; } static int local_file_url_prefixlen(const char *file_url) { int len = -1; if (git__prefixcmp(file_url, "file://") == 0) { if (file_url[7] == '/') len = 8; else if (git__prefixcmp(file_url + 7, "localhost/") == 0) len = 17; } return len; } bool git_path_is_local_file_url(const char *file_url) { return (local_file_url_prefixlen(file_url) > 0); } int git_path_fromurl(git_buf *local_path_out, const char *file_url) { int offset; assert(local_path_out && file_url); if ((offset = local_file_url_prefixlen(file_url)) < 0 || file_url[offset] == '\0' || file_url[offset] == '/') return error_invalid_local_file_uri(file_url); #ifndef GIT_WIN32 offset--; /* A *nix absolute path starts with a forward slash */ #endif git_buf_clear(local_path_out); return git__percent_decode(local_path_out, file_url + offset); } int git_path_walk_up( git_buf *path, const char *ceiling, int (*cb)(void *data, const char *), void *data) { int error = 0; git_buf iter; ssize_t stop = 0, scan; char oldc = '\0'; assert(path && cb); if (ceiling != NULL) { if (git__prefixcmp(path->ptr, ceiling) == 0) stop = (ssize_t)strlen(ceiling); else stop = git_buf_len(path); } scan = git_buf_len(path); /* empty path: yield only once */ if (!scan) { error = cb(data, ""); if (error) giterr_set_after_callback(error); return error; } iter.ptr = path->ptr; iter.size = git_buf_len(path); iter.asize = path->asize; while (scan >= stop) { error = cb(data, iter.ptr); iter.ptr[scan] = oldc; if (error) { giterr_set_after_callback(error); break; } scan = git_buf_rfind_next(&iter, '/'); if (scan >= 0) { scan++; oldc = iter.ptr[scan]; iter.size = scan; iter.ptr[scan] = '\0'; } } if (scan >= 0) iter.ptr[scan] = oldc; /* relative path: yield for the last component */ if (!error && stop == 0 && iter.ptr[0] != '/') { error = cb(data, ""); if (error) giterr_set_after_callback(error); } return error; } bool git_path_exists(const char *path) { assert(path); return p_access(path, F_OK) == 0; } bool git_path_isdir(const char *path) { struct stat st; if (p_stat(path, &st) < 0) return false; return S_ISDIR(st.st_mode) != 0; } bool git_path_isfile(const char *path) { struct stat st; assert(path); if (p_stat(path, &st) < 0) return false; return S_ISREG(st.st_mode) != 0; } bool git_path_islink(const char *path) { struct stat st; assert(path); if (p_lstat(path, &st) < 0) return false; return S_ISLNK(st.st_mode) != 0; } #ifdef GIT_WIN32 bool git_path_is_empty_dir(const char *path) { git_win32_path filter_w; bool empty = false; if (git_win32__findfirstfile_filter(filter_w, path)) { WIN32_FIND_DATAW findData; HANDLE hFind = FindFirstFileW(filter_w, &findData); /* FindFirstFile will fail if there are no children to the given * path, which can happen if the given path is a file (and obviously * has no children) or if the given path is an empty mount point. * (Most directories have at least directory entries '.' and '..', * but ridiculously another volume mounted in another drive letter's * path space do not, and thus have nothing to enumerate.) If * FindFirstFile fails, check if this is a directory-like thing * (a mount point). */ if (hFind == INVALID_HANDLE_VALUE) return git_path_isdir(path); /* If the find handle was created successfully, then it's a directory */ empty = true; do { /* Allow the enumeration to return . and .. and still be considered * empty. In the special case of drive roots (i.e. C:\) where . and * .. do not occur, we can still consider the path to be an empty * directory if there's nothing there. */ if (!git_path_is_dot_or_dotdotW(findData.cFileName)) { empty = false; break; } } while (FindNextFileW(hFind, &findData)); FindClose(hFind); } return empty; } #else static int path_found_entry(void *payload, git_buf *path) { GIT_UNUSED(payload); return !git_path_is_dot_or_dotdot(path->ptr); } bool git_path_is_empty_dir(const char *path) { int error; git_buf dir = GIT_BUF_INIT; if (!git_path_isdir(path)) return false; if ((error = git_buf_sets(&dir, path)) != 0) giterr_clear(); else error = git_path_direach(&dir, 0, path_found_entry, NULL); git_buf_free(&dir); return !error; } #endif int git_path_set_error(int errno_value, const char *path, const char *action) { switch (errno_value) { case ENOENT: case ENOTDIR: giterr_set(GITERR_OS, "Could not find '%s' to %s", path, action); return GIT_ENOTFOUND; case EINVAL: case ENAMETOOLONG: giterr_set(GITERR_OS, "Invalid path for filesystem '%s'", path); return GIT_EINVALIDSPEC; case EEXIST: giterr_set(GITERR_OS, "Failed %s - '%s' already exists", action, path); return GIT_EEXISTS; default: giterr_set(GITERR_OS, "Could not %s '%s'", action, path); return -1; } } int git_path_lstat(const char *path, struct stat *st) { if (p_lstat(path, st) == 0) return 0; return git_path_set_error(errno, path, "stat"); } static bool _check_dir_contents( git_buf *dir, const char *sub, bool (*predicate)(const char *)) { bool result; size_t dir_size = git_buf_len(dir); size_t sub_size = strlen(sub); size_t alloc_size; /* leave base valid even if we could not make space for subdir */ if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, dir_size, sub_size) || GIT_ADD_SIZET_OVERFLOW(&alloc_size, alloc_size, 2) || git_buf_try_grow(dir, alloc_size, false) < 0) return false; /* save excursion */ git_buf_joinpath(dir, dir->ptr, sub); result = predicate(dir->ptr); /* restore path */ git_buf_truncate(dir, dir_size); return result; } bool git_path_contains(git_buf *dir, const char *item) { return _check_dir_contents(dir, item, &git_path_exists); } bool git_path_contains_dir(git_buf *base, const char *subdir) { return _check_dir_contents(base, subdir, &git_path_isdir); } bool git_path_contains_file(git_buf *base, const char *file) { return _check_dir_contents(base, file, &git_path_isfile); } int git_path_find_dir(git_buf *dir, const char *path, const char *base) { int error = git_path_join_unrooted(dir, path, base, NULL); if (!error) { char buf[GIT_PATH_MAX]; if (p_realpath(dir->ptr, buf) != NULL) error = git_buf_sets(dir, buf); } /* call dirname if this is not a directory */ if (!error) /* && git_path_isdir(dir->ptr) == false) */ error = (git_path_dirname_r(dir, dir->ptr) < 0) ? -1 : 0; if (!error) error = git_path_to_dir(dir); return error; } int git_path_resolve_relative(git_buf *path, size_t ceiling) { char *base, *to, *from, *next; size_t len; if (!path || git_buf_oom(path)) return -1; if (ceiling > path->size) ceiling = path->size; /* recognize drive prefixes, etc. that should not be backed over */ if (ceiling == 0) ceiling = git_path_root(path->ptr) + 1; /* recognize URL prefixes that should not be backed over */ if (ceiling == 0) { for (next = path->ptr; *next && git__isalpha(*next); ++next); if (next[0] == ':' && next[1] == '/' && next[2] == '/') ceiling = (next + 3) - path->ptr; } base = to = from = path->ptr + ceiling; while (*from) { for (next = from; *next && *next != '/'; ++next); len = next - from; if (len == 1 && from[0] == '.') /* do nothing with singleton dot */; else if (len == 2 && from[0] == '.' && from[1] == '.') { /* error out if trying to up one from a hard base */ if (to == base && ceiling != 0) { giterr_set(GITERR_INVALID, "Cannot strip root component off url"); return -1; } /* no more path segments to strip, * use '../' as a new base path */ if (to == base) { if (*next == '/') len++; if (to != from) memmove(to, from, len); to += len; /* this is now the base, can't back up from a * relative prefix */ base = to; } else { /* back up a path segment */ while (to > base && to[-1] == '/') to--; while (to > base && to[-1] != '/') to--; } } else { if (*next == '/' && *from != '/') len++; if (to != from) memmove(to, from, len); to += len; } from += len; while (*from == '/') from++; } *to = '\0'; path->size = to - path->ptr; return 0; } int git_path_apply_relative(git_buf *target, const char *relpath) { git_buf_joinpath(target, git_buf_cstr(target), relpath); return git_path_resolve_relative(target, 0); } int git_path_cmp( const char *name1, size_t len1, int isdir1, const char *name2, size_t len2, int isdir2, int (*compare)(const char *, const char *, size_t)) { unsigned char c1, c2; size_t len = len1 < len2 ? len1 : len2; int cmp; cmp = compare(name1, name2, len); if (cmp) return cmp; c1 = name1[len]; c2 = name2[len]; if (c1 == '\0' && isdir1) c1 = '/'; if (c2 == '\0' && isdir2) c2 = '/'; return (c1 < c2) ? -1 : (c1 > c2) ? 1 : 0; } int git_path_make_relative(git_buf *path, const char *parent) { const char *p, *q, *p_dirsep, *q_dirsep; size_t plen = path->size, newlen, alloclen, depth = 1, i, offset; for (p_dirsep = p = path->ptr, q_dirsep = q = parent; *p && *q; p++, q++) { if (*p == '/' && *q == '/') { p_dirsep = p; q_dirsep = q; } else if (*p != *q) break; } /* need at least 1 common path segment */ if ((p_dirsep == path->ptr || q_dirsep == parent) && (*p_dirsep != '/' || *q_dirsep != '/')) { giterr_set(GITERR_INVALID, "%s is not a parent of %s", parent, path->ptr); return GIT_ENOTFOUND; } if (*p == '/' && !*q) p++; else if (!*p && *q == '/') q++; else if (!*p && !*q) return git_buf_clear(path), 0; else { p = p_dirsep + 1; q = q_dirsep + 1; } plen -= (p - path->ptr); if (!*q) return git_buf_set(path, p, plen); for (; (q = strchr(q, '/')) && *(q + 1); q++) depth++; GITERR_CHECK_ALLOC_MULTIPLY(&newlen, depth, 3); GITERR_CHECK_ALLOC_ADD(&newlen, newlen, plen); GITERR_CHECK_ALLOC_ADD(&alloclen, newlen, 1); /* save the offset as we might realllocate the pointer */ offset = p - path->ptr; if (git_buf_try_grow(path, alloclen, 1) < 0) return -1; p = path->ptr + offset; memmove(path->ptr + (depth * 3), p, plen + 1); for (i = 0; i < depth; i++) memcpy(path->ptr + (i * 3), "../", 3); path->size = newlen; return 0; } bool git_path_has_non_ascii(const char *path, size_t pathlen) { const uint8_t *scan = (const uint8_t *)path, *end; for (end = scan + pathlen; scan < end; ++scan) if (*scan & 0x80) return true; return false; } #ifdef GIT_USE_ICONV int git_path_iconv_init_precompose(git_path_iconv_t *ic) { git_buf_init(&ic->buf, 0); ic->map = iconv_open(GIT_PATH_REPO_ENCODING, GIT_PATH_NATIVE_ENCODING); return 0; } void git_path_iconv_clear(git_path_iconv_t *ic) { if (ic) { if (ic->map != (iconv_t)-1) iconv_close(ic->map); git_buf_free(&ic->buf); } } int git_path_iconv(git_path_iconv_t *ic, const char **in, size_t *inlen) { char *nfd = (char*)*in, *nfc; size_t nfdlen = *inlen, nfclen, wantlen = nfdlen, alloclen, rv; int retry = 1; if (!ic || ic->map == (iconv_t)-1 || !git_path_has_non_ascii(*in, *inlen)) return 0; git_buf_clear(&ic->buf); while (1) { GITERR_CHECK_ALLOC_ADD(&alloclen, wantlen, 1); if (git_buf_grow(&ic->buf, alloclen) < 0) return -1; nfc = ic->buf.ptr + ic->buf.size; nfclen = ic->buf.asize - ic->buf.size; rv = iconv(ic->map, &nfd, &nfdlen, &nfc, &nfclen); ic->buf.size = (nfc - ic->buf.ptr); if (rv != (size_t)-1) break; /* if we cannot convert the data (probably because iconv thinks * it is not valid UTF-8 source data), then use original data */ if (errno != E2BIG) return 0; /* make space for 2x the remaining data to be converted * (with per retry overhead to avoid infinite loops) */ wantlen = ic->buf.size + max(nfclen, nfdlen) * 2 + (size_t)(retry * 4); if (retry++ > 4) goto fail; } ic->buf.ptr[ic->buf.size] = '\0'; *in = ic->buf.ptr; *inlen = ic->buf.size; return 0; fail: giterr_set(GITERR_OS, "Unable to convert unicode path data"); return -1; } static const char *nfc_file = "\xC3\x85\x73\x74\x72\xC3\xB6\x6D.XXXXXX"; static const char *nfd_file = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D.XXXXXX"; /* Check if the platform is decomposing unicode data for us. We will * emulate core Git and prefer to use precomposed unicode data internally * on these platforms, composing the decomposed unicode on the fly. * * This mainly happens on the Mac where HDFS stores filenames as * decomposed unicode. Even on VFAT and SAMBA file systems, the Mac will * return decomposed unicode from readdir() even when the actual * filesystem is storing precomposed unicode. */ bool git_path_does_fs_decompose_unicode(const char *root) { git_buf path = GIT_BUF_INIT; int fd; bool found_decomposed = false; char tmp[6]; /* Create a file using a precomposed path and then try to find it * using the decomposed name. If the lookup fails, then we will mark * that we should precompose unicode for this repository. */ if (git_buf_joinpath(&path, root, nfc_file) < 0 || (fd = p_mkstemp(path.ptr)) < 0) goto done; p_close(fd); /* record trailing digits generated by mkstemp */ memcpy(tmp, path.ptr + path.size - sizeof(tmp), sizeof(tmp)); /* try to look up as NFD path */ if (git_buf_joinpath(&path, root, nfd_file) < 0) goto done; memcpy(path.ptr + path.size - sizeof(tmp), tmp, sizeof(tmp)); found_decomposed = git_path_exists(path.ptr); /* remove temporary file (using original precomposed path) */ if (git_buf_joinpath(&path, root, nfc_file) < 0) goto done; memcpy(path.ptr + path.size - sizeof(tmp), tmp, sizeof(tmp)); (void)p_unlink(path.ptr); done: git_buf_free(&path); return found_decomposed; } #else bool git_path_does_fs_decompose_unicode(const char *root) { GIT_UNUSED(root); return false; } #endif #if defined(__sun) || defined(__GNU__) typedef char path_dirent_data[sizeof(struct dirent) + FILENAME_MAX + 1]; #else typedef struct dirent path_dirent_data; #endif int git_path_direach( git_buf *path, uint32_t flags, int (*fn)(void *, git_buf *), void *arg) { int error = 0; ssize_t wd_len; DIR *dir; struct dirent *de; #ifdef GIT_USE_ICONV git_path_iconv_t ic = GIT_PATH_ICONV_INIT; #endif GIT_UNUSED(flags); if (git_path_to_dir(path) < 0) return -1; wd_len = git_buf_len(path); if ((dir = opendir(path->ptr)) == NULL) { giterr_set(GITERR_OS, "Failed to open directory '%s'", path->ptr); if (errno == ENOENT) return GIT_ENOTFOUND; return -1; } #ifdef GIT_USE_ICONV if ((flags & GIT_PATH_DIR_PRECOMPOSE_UNICODE) != 0) (void)git_path_iconv_init_precompose(&ic); #endif while ((de = readdir(dir)) != NULL) { const char *de_path = de->d_name; size_t de_len = strlen(de_path); if (git_path_is_dot_or_dotdot(de_path)) continue; #ifdef GIT_USE_ICONV if ((error = git_path_iconv(&ic, &de_path, &de_len)) < 0) break; #endif if ((error = git_buf_put(path, de_path, de_len)) < 0) break; giterr_clear(); error = fn(arg, path); git_buf_truncate(path, wd_len); /* restore path */ /* Only set our own error if the callback did not set one already */ if (error != 0) { if (!giterr_last()) giterr_set_after_callback(error); break; } } closedir(dir); #ifdef GIT_USE_ICONV git_path_iconv_clear(&ic); #endif return error; } #if defined(GIT_WIN32) && !defined(__MINGW32__) /* Using _FIND_FIRST_EX_LARGE_FETCH may increase performance in Windows 7 * and better. */ #ifndef FIND_FIRST_EX_LARGE_FETCH # define FIND_FIRST_EX_LARGE_FETCH 2 #endif int git_path_diriter_init( git_path_diriter *diriter, const char *path, unsigned int flags) { git_win32_path path_filter; git_buf hack = {0}; static int is_win7_or_later = -1; if (is_win7_or_later < 0) is_win7_or_later = git_has_win32_version(6, 1, 0); assert(diriter && path); memset(diriter, 0, sizeof(git_path_diriter)); diriter->handle = INVALID_HANDLE_VALUE; if (git_buf_puts(&diriter->path_utf8, path) < 0) return -1; git_path_trim_slashes(&diriter->path_utf8); if (diriter->path_utf8.size == 0) { giterr_set(GITERR_FILESYSTEM, "Could not open directory '%s'", path); return -1; } if ((diriter->parent_len = git_win32_path_from_utf8(diriter->path, diriter->path_utf8.ptr)) < 0 || !git_win32__findfirstfile_filter(path_filter, diriter->path_utf8.ptr)) { giterr_set(GITERR_OS, "Could not parse the directory path '%s'", path); return -1; } diriter->handle = FindFirstFileExW( path_filter, is_win7_or_later ? FindExInfoBasic : FindExInfoStandard, &diriter->current, FindExSearchNameMatch, NULL, is_win7_or_later ? FIND_FIRST_EX_LARGE_FETCH : 0); if (diriter->handle == INVALID_HANDLE_VALUE) { giterr_set(GITERR_OS, "Could not open directory '%s'", path); return -1; } diriter->parent_utf8_len = diriter->path_utf8.size; diriter->flags = flags; return 0; } static int diriter_update_paths(git_path_diriter *diriter) { size_t filename_len, path_len; filename_len = wcslen(diriter->current.cFileName); if (GIT_ADD_SIZET_OVERFLOW(&path_len, diriter->parent_len, filename_len) || GIT_ADD_SIZET_OVERFLOW(&path_len, path_len, 2)) return -1; if (path_len > GIT_WIN_PATH_UTF16) { giterr_set(GITERR_FILESYSTEM, "invalid path '%.*ls\\%ls' (path too long)", diriter->parent_len, diriter->path, diriter->current.cFileName); return -1; } diriter->path[diriter->parent_len] = L'\\'; memcpy(&diriter->path[diriter->parent_len+1], diriter->current.cFileName, filename_len * sizeof(wchar_t)); diriter->path[path_len-1] = L'\0'; git_buf_truncate(&diriter->path_utf8, diriter->parent_utf8_len); if (diriter->parent_utf8_len > 0 && diriter->path_utf8.ptr[diriter->parent_utf8_len-1] != '/') git_buf_putc(&diriter->path_utf8, '/'); git_buf_put_w(&diriter->path_utf8, diriter->current.cFileName, filename_len); if (git_buf_oom(&diriter->path_utf8)) return -1; return 0; } int git_path_diriter_next(git_path_diriter *diriter) { bool skip_dot = !(diriter->flags & GIT_PATH_DIR_INCLUDE_DOT_AND_DOTDOT); do { /* Our first time through, we already have the data from * FindFirstFileW. Use it, otherwise get the next file. */ if (!diriter->needs_next) diriter->needs_next = 1; else if (!FindNextFileW(diriter->handle, &diriter->current)) return GIT_ITEROVER; } while (skip_dot && git_path_is_dot_or_dotdotW(diriter->current.cFileName)); if (diriter_update_paths(diriter) < 0) return -1; return 0; } int git_path_diriter_filename( const char **out, size_t *out_len, git_path_diriter *diriter) { assert(out && out_len && diriter); assert(diriter->path_utf8.size > diriter->parent_utf8_len); *out = &diriter->path_utf8.ptr[diriter->parent_utf8_len+1]; *out_len = diriter->path_utf8.size - diriter->parent_utf8_len - 1; return 0; } int git_path_diriter_fullpath( const char **out, size_t *out_len, git_path_diriter *diriter) { assert(out && out_len && diriter); *out = diriter->path_utf8.ptr; *out_len = diriter->path_utf8.size; return 0; } int git_path_diriter_stat(struct stat *out, git_path_diriter *diriter) { assert(out && diriter); return git_win32__file_attribute_to_stat(out, (WIN32_FILE_ATTRIBUTE_DATA *)&diriter->current, diriter->path); } void git_path_diriter_free(git_path_diriter *diriter) { if (diriter == NULL) return; git_buf_free(&diriter->path_utf8); if (diriter->handle != INVALID_HANDLE_VALUE) { FindClose(diriter->handle); diriter->handle = INVALID_HANDLE_VALUE; } } #else int git_path_diriter_init( git_path_diriter *diriter, const char *path, unsigned int flags) { assert(diriter && path); memset(diriter, 0, sizeof(git_path_diriter)); if (git_buf_puts(&diriter->path, path) < 0) return -1; git_path_trim_slashes(&diriter->path); if (diriter->path.size == 0) { giterr_set(GITERR_FILESYSTEM, "Could not open directory '%s'", path); return -1; } if ((diriter->dir = opendir(diriter->path.ptr)) == NULL) { git_buf_free(&diriter->path); giterr_set(GITERR_OS, "Failed to open directory '%s'", path); return -1; } #ifdef GIT_USE_ICONV if ((flags & GIT_PATH_DIR_PRECOMPOSE_UNICODE) != 0) (void)git_path_iconv_init_precompose(&diriter->ic); #endif diriter->parent_len = diriter->path.size; diriter->flags = flags; return 0; } int git_path_diriter_next(git_path_diriter *diriter) { struct dirent *de; const char *filename; size_t filename_len; bool skip_dot = !(diriter->flags & GIT_PATH_DIR_INCLUDE_DOT_AND_DOTDOT); int error = 0; assert(diriter); errno = 0; do { if ((de = readdir(diriter->dir)) == NULL) { if (!errno) return GIT_ITEROVER; giterr_set(GITERR_OS, "Could not read directory '%s'", diriter->path); return -1; } } while (skip_dot && git_path_is_dot_or_dotdot(de->d_name)); filename = de->d_name; filename_len = strlen(filename); #ifdef GIT_USE_ICONV if ((diriter->flags & GIT_PATH_DIR_PRECOMPOSE_UNICODE) != 0 && (error = git_path_iconv(&diriter->ic, &filename, &filename_len)) < 0) return error; #endif git_buf_truncate(&diriter->path, diriter->parent_len); if (diriter->parent_len > 0 && diriter->path.ptr[diriter->parent_len-1] != '/') git_buf_putc(&diriter->path, '/'); git_buf_put(&diriter->path, filename, filename_len); if (git_buf_oom(&diriter->path)) return -1; return error; } int git_path_diriter_filename( const char **out, size_t *out_len, git_path_diriter *diriter) { assert(out && out_len && diriter); assert(diriter->path.size > diriter->parent_len); *out = &diriter->path.ptr[diriter->parent_len+1]; *out_len = diriter->path.size - diriter->parent_len - 1; return 0; } int git_path_diriter_fullpath( const char **out, size_t *out_len, git_path_diriter *diriter) { assert(out && out_len && diriter); *out = diriter->path.ptr; *out_len = diriter->path.size; return 0; } int git_path_diriter_stat(struct stat *out, git_path_diriter *diriter) { assert(out && diriter); return git_path_lstat(diriter->path.ptr, out); } void git_path_diriter_free(git_path_diriter *diriter) { if (diriter == NULL) return; if (diriter->dir) { closedir(diriter->dir); diriter->dir = NULL; } #ifdef GIT_USE_ICONV git_path_iconv_clear(&diriter->ic); #endif git_buf_free(&diriter->path); } #endif int git_path_dirload( git_vector *contents, const char *path, size_t prefix_len, unsigned int flags) { git_path_diriter iter = GIT_PATH_DIRITER_INIT; const char *name; size_t name_len; char *dup; int error; assert(contents && path); if ((error = git_path_diriter_init(&iter, path, flags)) < 0) return error; while ((error = git_path_diriter_next(&iter)) == 0) { if ((error = git_path_diriter_fullpath(&name, &name_len, &iter)) < 0) break; assert(name_len > prefix_len); dup = git__strndup(name + prefix_len, name_len - prefix_len); GITERR_CHECK_ALLOC(dup); if ((error = git_vector_insert(contents, dup)) < 0) break; } if (error == GIT_ITEROVER) error = 0; git_path_diriter_free(&iter); return error; } int git_path_from_url_or_path(git_buf *local_path_out, const char *url_or_path) { if (git_path_is_local_file_url(url_or_path)) return git_path_fromurl(local_path_out, url_or_path); else return git_buf_sets(local_path_out, url_or_path); } /* Reject paths like AUX or COM1, or those versions that end in a dot or * colon. ("AUX." or "AUX:") */ GIT_INLINE(bool) verify_dospath( const char *component, size_t len, const char dospath[3], bool trailing_num) { size_t last = trailing_num ? 4 : 3; if (len < last || git__strncasecmp(component, dospath, 3) != 0) return true; if (trailing_num && (component[3] < '1' || component[3] > '9')) return true; return (len > last && component[last] != '.' && component[last] != ':'); } static int32_t next_hfs_char(const char **in, size_t *len) { while (*len) { int32_t codepoint; int cp_len = git__utf8_iterate((const uint8_t *)(*in), (int)(*len), &codepoint); if (cp_len < 0) return -1; (*in) += cp_len; (*len) -= cp_len; /* these code points are ignored completely */ switch (codepoint) { case 0x200c: /* ZERO WIDTH NON-JOINER */ case 0x200d: /* ZERO WIDTH JOINER */ case 0x200e: /* LEFT-TO-RIGHT MARK */ case 0x200f: /* RIGHT-TO-LEFT MARK */ case 0x202a: /* LEFT-TO-RIGHT EMBEDDING */ case 0x202b: /* RIGHT-TO-LEFT EMBEDDING */ case 0x202c: /* POP DIRECTIONAL FORMATTING */ case 0x202d: /* LEFT-TO-RIGHT OVERRIDE */ case 0x202e: /* RIGHT-TO-LEFT OVERRIDE */ case 0x206a: /* INHIBIT SYMMETRIC SWAPPING */ case 0x206b: /* ACTIVATE SYMMETRIC SWAPPING */ case 0x206c: /* INHIBIT ARABIC FORM SHAPING */ case 0x206d: /* ACTIVATE ARABIC FORM SHAPING */ case 0x206e: /* NATIONAL DIGIT SHAPES */ case 0x206f: /* NOMINAL DIGIT SHAPES */ case 0xfeff: /* ZERO WIDTH NO-BREAK SPACE */ continue; } /* fold into lowercase -- this will only fold characters in * the ASCII range, which is perfectly fine, because the * git folder name can only be composed of ascii characters */ return git__tolower(codepoint); } return 0; /* NULL byte -- end of string */ } static bool verify_dotgit_hfs(const char *path, size_t len) { if (next_hfs_char(&path, &len) != '.' || next_hfs_char(&path, &len) != 'g' || next_hfs_char(&path, &len) != 'i' || next_hfs_char(&path, &len) != 't' || next_hfs_char(&path, &len) != 0) return true; return false; } GIT_INLINE(bool) verify_dotgit_ntfs(git_repository *repo, const char *path, size_t len) { git_buf *reserved = git_repository__reserved_names_win32; size_t reserved_len = git_repository__reserved_names_win32_len; size_t start = 0, i; if (repo) git_repository__reserved_names(&reserved, &reserved_len, repo, true); for (i = 0; i < reserved_len; i++) { git_buf *r = &reserved[i]; if (len >= r->size && strncasecmp(path, r->ptr, r->size) == 0) { start = r->size; break; } } if (!start) return true; /* Reject paths like ".git\" */ if (path[start] == '\\') return false; /* Reject paths like '.git ' or '.git.' */ for (i = start; i < len; i++) { if (path[i] != ' ' && path[i] != '.') return true; } return false; } GIT_INLINE(bool) verify_char(unsigned char c, unsigned int flags) { if ((flags & GIT_PATH_REJECT_BACKSLASH) && c == '\\') return false; if ((flags & GIT_PATH_REJECT_SLASH) && c == '/') return false; if (flags & GIT_PATH_REJECT_NT_CHARS) { if (c < 32) return false; switch (c) { case '<': case '>': case ':': case '"': case '|': case '?': case '*': return false; } } return true; } /* * We fundamentally don't like some paths when dealing with user-inputted * strings (in checkout or ref names): we don't want dot or dot-dot * anywhere, we want to avoid writing weird paths on Windows that can't * be handled by tools that use the non-\\?\ APIs, we don't want slashes * or double slashes at the end of paths that can make them ambiguous. * * For checkout, we don't want to recurse into ".git" either. */ static bool verify_component( git_repository *repo, const char *component, size_t len, unsigned int flags) { if (len == 0) return false; if ((flags & GIT_PATH_REJECT_TRAVERSAL) && len == 1 && component[0] == '.') return false; if ((flags & GIT_PATH_REJECT_TRAVERSAL) && len == 2 && component[0] == '.' && component[1] == '.') return false; if ((flags & GIT_PATH_REJECT_TRAILING_DOT) && component[len-1] == '.') return false; if ((flags & GIT_PATH_REJECT_TRAILING_SPACE) && component[len-1] == ' ') return false; if ((flags & GIT_PATH_REJECT_TRAILING_COLON) && component[len-1] == ':') return false; if (flags & GIT_PATH_REJECT_DOS_PATHS) { if (!verify_dospath(component, len, "CON", false) || !verify_dospath(component, len, "PRN", false) || !verify_dospath(component, len, "AUX", false) || !verify_dospath(component, len, "NUL", false) || !verify_dospath(component, len, "COM", true) || !verify_dospath(component, len, "LPT", true)) return false; } if (flags & GIT_PATH_REJECT_DOT_GIT_HFS && !verify_dotgit_hfs(component, len)) return false; if (flags & GIT_PATH_REJECT_DOT_GIT_NTFS && !verify_dotgit_ntfs(repo, component, len)) return false; if ((flags & GIT_PATH_REJECT_DOT_GIT_HFS) == 0 && (flags & GIT_PATH_REJECT_DOT_GIT_NTFS) == 0 && (flags & GIT_PATH_REJECT_DOT_GIT) && len == 4 && component[0] == '.' && (component[1] == 'g' || component[1] == 'G') && (component[2] == 'i' || component[2] == 'I') && (component[3] == 't' || component[3] == 'T')) return false; return true; } GIT_INLINE(unsigned int) dotgit_flags( git_repository *repo, unsigned int flags) { int protectHFS = 0, protectNTFS = 0; #ifdef __APPLE__ protectHFS = 1; #endif #ifdef GIT_WIN32 protectNTFS = 1; #endif if (repo && !protectHFS) git_repository__cvar(&protectHFS, repo, GIT_CVAR_PROTECTHFS); if (protectHFS) flags |= GIT_PATH_REJECT_DOT_GIT_HFS; if (repo && !protectNTFS) git_repository__cvar(&protectNTFS, repo, GIT_CVAR_PROTECTNTFS); if (protectNTFS) flags |= GIT_PATH_REJECT_DOT_GIT_NTFS; return flags; } bool git_path_isvalid( git_repository *repo, const char *path, unsigned int flags) { const char *start, *c; /* Upgrade the ".git" checks based on platform */ if ((flags & GIT_PATH_REJECT_DOT_GIT)) flags = dotgit_flags(repo, flags); for (start = c = path; *c; c++) { if (!verify_char(*c, flags)) return false; if (*c == '/') { if (!verify_component(repo, start, (c - start), flags)) return false; start = c+1; } } return verify_component(repo, start, (c - start), flags); } int git_path_normalize_slashes(git_buf *out, const char *path) { int error; char *p; if ((error = git_buf_puts(out, path)) < 0) return error; for (p = out->ptr; *p; p++) { if (*p == '\\') *p = '/'; } return 0; } deps/libgit2-sys-0.3.8/libgit2/src/odb.h0000664000175000017500000000534212555730137014623 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_odb_h__ #define INCLUDE_odb_h__ #include "git2/odb.h" #include "git2/oid.h" #include "git2/types.h" #include "vector.h" #include "cache.h" #include "posix.h" #include "filter.h" #define GIT_OBJECTS_DIR "objects/" #define GIT_OBJECT_DIR_MODE 0777 #define GIT_OBJECT_FILE_MODE 0444 /* DO NOT EXPORT */ typedef struct { void *data; /**< Raw, decompressed object data. */ size_t len; /**< Total number of bytes in data. */ git_otype type; /**< Type of this object. */ } git_rawobj; /* EXPORT */ struct git_odb_object { git_cached_obj cached; void *buffer; }; /* EXPORT */ struct git_odb { git_refcount rc; git_vector backends; git_cache own_cache; }; /* * Hash a git_rawobj internally. * The `git_rawobj` is supposed to be previously initialized */ int git_odb__hashobj(git_oid *id, git_rawobj *obj); /* * Format the object header such as it would appear in the on-disk object */ int git_odb__format_object_header(char *hdr, size_t n, git_off_t obj_len, git_otype obj_type); /* * Hash an open file descriptor. * This is a performance call when the contents of a fd need to be hashed, * but the fd is already open and we have the size of the contents. * * Saves us some `stat` calls. * * The fd is never closed, not even on error. It must be opened and closed * by the caller */ int git_odb__hashfd(git_oid *out, git_file fd, size_t size, git_otype type); /* * Hash an open file descriptor applying an array of filters * Acts just like git_odb__hashfd with the addition of filters... */ int git_odb__hashfd_filtered( git_oid *out, git_file fd, size_t len, git_otype type, git_filter_list *fl); /* * Hash a `path`, assuming it could be a POSIX symlink: if the path is a * symlink, then the raw contents of the symlink will be hashed. Otherwise, * this will fallback to `git_odb__hashfd`. * * The hash type for this call is always `GIT_OBJ_BLOB` because symlinks may * only point to blobs. */ int git_odb__hashlink(git_oid *out, const char *path); /* * Generate a GIT_ENOTFOUND error for the ODB. */ int git_odb__error_notfound(const char *message, const git_oid *oid); /* * Generate a GIT_EAMBIGUOUS error for the ODB. */ int git_odb__error_ambiguous(const char *message); /* * Attempt to read object header or just return whole object if it could * not be read. */ int git_odb__read_header_or_object( git_odb_object **out, size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id); /* fully free the object; internal method, DO NOT EXPORT */ void git_odb_object__free(void *object); #endif deps/libgit2-sys-0.3.8/libgit2/src/revwalk.c0000664000175000017500000003406612572105236015525 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "commit.h" #include "odb.h" #include "pool.h" #include "revwalk.h" #include "git2/revparse.h" #include "merge.h" GIT__USE_OIDMAP git_commit_list_node *git_revwalk__commit_lookup( git_revwalk *walk, const git_oid *oid) { git_commit_list_node *commit; khiter_t pos; int ret; /* lookup and reserve space if not already present */ pos = kh_get(oid, walk->commits, oid); if (pos != kh_end(walk->commits)) return kh_value(walk->commits, pos); commit = git_commit_list_alloc_node(walk); if (commit == NULL) return NULL; git_oid_cpy(&commit->oid, oid); pos = kh_put(oid, walk->commits, &commit->oid, &ret); assert(ret != 0); kh_value(walk->commits, pos) = commit; return commit; } typedef git_array_t(git_commit_list_node*) commit_list_node_array; static bool interesting_arr(commit_list_node_array arr) { git_commit_list_node **n; size_t i = 0, size; size = git_array_size(arr); for (i = 0; i < size; i++) { n = git_array_get(arr, i); if (!*n) break; if (!(*n)->uninteresting) return true; } return false; } static int mark_uninteresting(git_revwalk *walk, git_commit_list_node *commit) { int error; unsigned short i; commit_list_node_array pending = GIT_ARRAY_INIT; git_commit_list_node **tmp; assert(commit); do { commit->uninteresting = 1; if ((error = git_commit_list_parse(walk, commit)) < 0) return error; for (i = 0; i < commit->out_degree; ++i) if (!commit->parents[i]->uninteresting) { git_commit_list_node **node = git_array_alloc(pending); GITERR_CHECK_ALLOC(node); *node = commit->parents[i]; } tmp = git_array_pop(pending); commit = tmp ? *tmp : NULL; } while (commit != NULL && !interesting_arr(pending)); git_array_clear(pending); return 0; } static int process_commit(git_revwalk *walk, git_commit_list_node *commit, int hide) { int error; if (!hide && walk->hide_cb) hide = walk->hide_cb(&commit->oid, walk->hide_cb_payload); if (hide && mark_uninteresting(walk, commit) < 0) return -1; if (commit->seen) return 0; commit->seen = 1; if ((error = git_commit_list_parse(walk, commit)) < 0) return error; if (!hide) return walk->enqueue(walk, commit); return 0; } static int process_commit_parents(git_revwalk *walk, git_commit_list_node *commit) { unsigned short i, max; int error = 0; max = commit->out_degree; if (walk->first_parent && commit->out_degree) max = 1; for (i = 0; i < max && !error; ++i) error = process_commit(walk, commit->parents[i], commit->uninteresting); return error; } static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting, int from_glob) { git_oid commit_id; int error; git_object *obj, *oobj; git_commit_list_node *commit; git_commit_list *list; if ((error = git_object_lookup(&oobj, walk->repo, oid, GIT_OBJ_ANY)) < 0) return error; error = git_object_peel(&obj, oobj, GIT_OBJ_COMMIT); git_object_free(oobj); if (error == GIT_ENOTFOUND || error == GIT_EINVALIDSPEC || error == GIT_EPEEL) { /* If this comes from e.g. push_glob("tags"), ignore this */ if (from_glob) return 0; giterr_set(GITERR_INVALID, "Object is not a committish"); return -1; } if (error < 0) return error; git_oid_cpy(&commit_id, git_object_id(obj)); git_object_free(obj); commit = git_revwalk__commit_lookup(walk, &commit_id); if (commit == NULL) return -1; /* error already reported by failed lookup */ /* A previous hide already told us we don't want this commit */ if (commit->uninteresting) return 0; if (uninteresting) walk->did_hide = 1; else walk->did_push = 1; commit->uninteresting = uninteresting; list = walk->user_input; if (git_commit_list_insert(commit, &list) == NULL) { giterr_set_oom(); return -1; } walk->user_input = list; return 0; } int git_revwalk_push(git_revwalk *walk, const git_oid *oid) { assert(walk && oid); return push_commit(walk, oid, 0, false); } int git_revwalk_hide(git_revwalk *walk, const git_oid *oid) { assert(walk && oid); return push_commit(walk, oid, 1, false); } static int push_ref(git_revwalk *walk, const char *refname, int hide, int from_glob) { git_oid oid; if (git_reference_name_to_id(&oid, walk->repo, refname) < 0) return -1; return push_commit(walk, &oid, hide, from_glob); } static int push_glob(git_revwalk *walk, const char *glob, int hide) { int error = 0; git_buf buf = GIT_BUF_INIT; git_reference *ref; git_reference_iterator *iter; size_t wildcard; assert(walk && glob); /* refs/ is implied if not given in the glob */ if (git__prefixcmp(glob, GIT_REFS_DIR) != 0) git_buf_joinpath(&buf, GIT_REFS_DIR, glob); else git_buf_puts(&buf, glob); if (git_buf_oom(&buf)) return -1; /* If no '?', '*' or '[' exist, we append '/ *' to the glob */ wildcard = strcspn(glob, "?*["); if (!glob[wildcard]) git_buf_put(&buf, "/*", 2); if ((error = git_reference_iterator_glob_new(&iter, walk->repo, buf.ptr)) < 0) goto out; while ((error = git_reference_next(&ref, iter)) == 0) { error = push_ref(walk, git_reference_name(ref), hide, true); git_reference_free(ref); if (error < 0) break; } git_reference_iterator_free(iter); if (error == GIT_ITEROVER) error = 0; out: git_buf_free(&buf); return error; } int git_revwalk_push_glob(git_revwalk *walk, const char *glob) { assert(walk && glob); return push_glob(walk, glob, 0); } int git_revwalk_hide_glob(git_revwalk *walk, const char *glob) { assert(walk && glob); return push_glob(walk, glob, 1); } int git_revwalk_push_head(git_revwalk *walk) { assert(walk); return push_ref(walk, GIT_HEAD_FILE, 0, false); } int git_revwalk_hide_head(git_revwalk *walk) { assert(walk); return push_ref(walk, GIT_HEAD_FILE, 1, false); } int git_revwalk_push_ref(git_revwalk *walk, const char *refname) { assert(walk && refname); return push_ref(walk, refname, 0, false); } int git_revwalk_push_range(git_revwalk *walk, const char *range) { git_revspec revspec; int error = 0; if ((error = git_revparse(&revspec, walk->repo, range))) return error; if (revspec.flags & GIT_REVPARSE_MERGE_BASE) { /* TODO: support "..." */ giterr_set(GITERR_INVALID, "Symmetric differences not implemented in revwalk"); return GIT_EINVALIDSPEC; } if ((error = push_commit(walk, git_object_id(revspec.from), 1, false))) goto out; error = push_commit(walk, git_object_id(revspec.to), 0, false); out: git_object_free(revspec.from); git_object_free(revspec.to); return error; } int git_revwalk_hide_ref(git_revwalk *walk, const char *refname) { assert(walk && refname); return push_ref(walk, refname, 1, false); } static int revwalk_enqueue_timesort(git_revwalk *walk, git_commit_list_node *commit) { return git_pqueue_insert(&walk->iterator_time, commit); } static int revwalk_enqueue_unsorted(git_revwalk *walk, git_commit_list_node *commit) { return git_commit_list_insert(commit, &walk->iterator_rand) ? 0 : -1; } static int revwalk_next_timesort(git_commit_list_node **object_out, git_revwalk *walk) { int error; git_commit_list_node *next; while ((next = git_pqueue_pop(&walk->iterator_time)) != NULL) if (!next->uninteresting) { if ((error = process_commit_parents(walk, next)) < 0) return error; *object_out = next; return 0; } giterr_clear(); return GIT_ITEROVER; } static int revwalk_next_unsorted(git_commit_list_node **object_out, git_revwalk *walk) { int error; git_commit_list_node *next; while ((next = git_commit_list_pop(&walk->iterator_rand)) != NULL) if (!next->uninteresting) { if ((error = process_commit_parents(walk, next)) < 0) return error; *object_out = next; return 0; } giterr_clear(); return GIT_ITEROVER; } static int revwalk_next_toposort(git_commit_list_node **object_out, git_revwalk *walk) { git_commit_list_node *next; unsigned short i, max; for (;;) { next = git_commit_list_pop(&walk->iterator_topo); if (next == NULL) { giterr_clear(); return GIT_ITEROVER; } if (next->in_degree > 0) { next->topo_delay = 1; continue; } max = next->out_degree; if (walk->first_parent && next->out_degree) max = 1; for (i = 0; i < max; ++i) { git_commit_list_node *parent = next->parents[i]; if (--parent->in_degree == 0 && parent->topo_delay) { parent->topo_delay = 0; if (git_commit_list_insert(parent, &walk->iterator_topo) == NULL) return -1; } } *object_out = next; return 0; } } static int revwalk_next_reverse(git_commit_list_node **object_out, git_revwalk *walk) { *object_out = git_commit_list_pop(&walk->iterator_reverse); return *object_out ? 0 : GIT_ITEROVER; } static int interesting(git_pqueue *list) { size_t i; for (i = 0; i < git_pqueue_size(list); i++) { git_commit_list_node *commit = git_pqueue_get(list, i); if (!commit->uninteresting) return 1; } return 0; } static int contains(git_pqueue *list, git_commit_list_node *node) { size_t i; for (i = 0; i < git_pqueue_size(list); i++) { git_commit_list_node *commit = git_pqueue_get(list, i); if (commit == node) return 1; } return 0; } static int premark_uninteresting(git_revwalk *walk) { int error = 0; unsigned short i; git_pqueue q; git_commit_list *list; git_commit_list_node *commit, *parent; if ((error = git_pqueue_init(&q, 0, 8, git_commit_list_time_cmp)) < 0) return error; for (list = walk->user_input; list; list = list->next) { if ((error = git_commit_list_parse(walk, list->item)) < 0) goto cleanup; if ((error = git_pqueue_insert(&q, list->item)) < 0) goto cleanup; } while (interesting(&q)) { commit = git_pqueue_pop(&q); for (i = 0; i < commit->out_degree; i++) { parent = commit->parents[i]; if ((error = git_commit_list_parse(walk, parent)) < 0) goto cleanup; if (commit->uninteresting) parent->uninteresting = 1; if (contains(&q, parent)) continue; if ((error = git_pqueue_insert(&q, parent)) < 0) goto cleanup; } } cleanup: git_pqueue_free(&q); return error; } static int prepare_walk(git_revwalk *walk) { int error; git_commit_list *list; git_commit_list_node *next; /* If there were no pushes, we know that the walk is already over */ if (!walk->did_push) { giterr_clear(); return GIT_ITEROVER; } if (walk->did_hide && (error = premark_uninteresting(walk)) < 0) return error; for (list = walk->user_input; list; list = list->next) { if (process_commit(walk, list->item, list->item->uninteresting) < 0) return -1; } if (walk->sorting & GIT_SORT_TOPOLOGICAL) { unsigned short i; while ((error = walk->get_next(&next, walk)) == 0) { for (i = 0; i < next->out_degree; ++i) { git_commit_list_node *parent = next->parents[i]; parent->in_degree++; } if (git_commit_list_insert(next, &walk->iterator_topo) == NULL) return -1; } if (error != GIT_ITEROVER) return error; walk->get_next = &revwalk_next_toposort; } if (walk->sorting & GIT_SORT_REVERSE) { while ((error = walk->get_next(&next, walk)) == 0) if (git_commit_list_insert(next, &walk->iterator_reverse) == NULL) return -1; if (error != GIT_ITEROVER) return error; walk->get_next = &revwalk_next_reverse; } walk->walking = 1; return 0; } int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo) { git_revwalk *walk = git__calloc(1, sizeof(git_revwalk)); GITERR_CHECK_ALLOC(walk); walk->commits = git_oidmap_alloc(); GITERR_CHECK_ALLOC(walk->commits); if (git_pqueue_init( &walk->iterator_time, 0, 8, git_commit_list_time_cmp) < 0 || git_pool_init(&walk->commit_pool, 1, git_pool__suggest_items_per_page(COMMIT_ALLOC) * COMMIT_ALLOC) < 0) return -1; walk->get_next = &revwalk_next_unsorted; walk->enqueue = &revwalk_enqueue_unsorted; walk->repo = repo; if (git_repository_odb(&walk->odb, repo) < 0) { git_revwalk_free(walk); return -1; } *revwalk_out = walk; return 0; } void git_revwalk_free(git_revwalk *walk) { if (walk == NULL) return; git_revwalk_reset(walk); git_odb_free(walk->odb); git_oidmap_free(walk->commits); git_pool_clear(&walk->commit_pool); git_pqueue_free(&walk->iterator_time); git__free(walk); } git_repository *git_revwalk_repository(git_revwalk *walk) { assert(walk); return walk->repo; } void git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode) { assert(walk); if (walk->walking) git_revwalk_reset(walk); walk->sorting = sort_mode; if (walk->sorting & GIT_SORT_TIME) { walk->get_next = &revwalk_next_timesort; walk->enqueue = &revwalk_enqueue_timesort; } else { walk->get_next = &revwalk_next_unsorted; walk->enqueue = &revwalk_enqueue_unsorted; } } void git_revwalk_simplify_first_parent(git_revwalk *walk) { walk->first_parent = 1; } int git_revwalk_next(git_oid *oid, git_revwalk *walk) { int error; git_commit_list_node *next; assert(walk && oid); if (!walk->walking) { if ((error = prepare_walk(walk)) < 0) return error; } error = walk->get_next(&next, walk); if (error == GIT_ITEROVER) { git_revwalk_reset(walk); giterr_clear(); return GIT_ITEROVER; } if (!error) git_oid_cpy(oid, &next->oid); return error; } void git_revwalk_reset(git_revwalk *walk) { git_commit_list_node *commit; assert(walk); kh_foreach_value(walk->commits, commit, { commit->seen = 0; commit->in_degree = 0; commit->topo_delay = 0; commit->uninteresting = 0; commit->flags = 0; }); git_pqueue_clear(&walk->iterator_time); git_commit_list_free(&walk->iterator_topo); git_commit_list_free(&walk->iterator_rand); git_commit_list_free(&walk->iterator_reverse); git_commit_list_free(&walk->user_input); walk->first_parent = 0; walk->walking = 0; walk->did_push = walk->did_hide = 0; } int git_revwalk_add_hide_cb( git_revwalk *walk, git_revwalk_hide_cb hide_cb, void *payload) { assert(walk); if (walk->walking) git_revwalk_reset(walk); if (walk->hide_cb) { /* There is already a callback added */ giterr_set(GITERR_INVALID, "There is already a callback added to hide commits in revision walker."); return -1; } walk->hide_cb = hide_cb; walk->hide_cb_payload = payload; return 0; } deps/libgit2-sys-0.3.8/libgit2/src/buf_text.h0000664000175000017500000000670412555730137015702 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_buf_text_h__ #define INCLUDE_buf_text_h__ #include "buffer.h" typedef enum { GIT_BOM_NONE = 0, GIT_BOM_UTF8 = 1, GIT_BOM_UTF16_LE = 2, GIT_BOM_UTF16_BE = 3, GIT_BOM_UTF32_LE = 4, GIT_BOM_UTF32_BE = 5 } git_bom_t; typedef struct { git_bom_t bom; /* BOM found at head of text */ unsigned int nul, cr, lf, crlf; /* NUL, CR, LF and CRLF counts */ unsigned int printable, nonprintable; /* These are just approximations! */ } git_buf_text_stats; /** * Append string to buffer, prefixing each character from `esc_chars` with * `esc_with` string. * * @param buf Buffer to append data to * @param string String to escape and append * @param esc_chars Characters to be escaped * @param esc_with String to insert in from of each found character * @return 0 on success, <0 on failure (probably allocation problem) */ extern int git_buf_text_puts_escaped( git_buf *buf, const char *string, const char *esc_chars, const char *esc_with); /** * Append string escaping characters that are regex special */ GIT_INLINE(int) git_buf_text_puts_escape_regex(git_buf *buf, const char *string) { return git_buf_text_puts_escaped(buf, string, "^.[]$()|*+?{}\\", "\\"); } /** * Unescape all characters in a buffer in place * * I.e. remove backslashes */ extern void git_buf_text_unescape(git_buf *buf); /** * Replace all \r\n with \n. * * @return 0 on success, -1 on memory error */ extern int git_buf_text_crlf_to_lf(git_buf *tgt, const git_buf *src); /** * Replace all \n with \r\n. Does not modify existing \r\n. * * @return 0 on success, -1 on memory error */ extern int git_buf_text_lf_to_crlf(git_buf *tgt, const git_buf *src); /** * Fill buffer with the common prefix of a array of strings * * Buffer will be set to empty if there is no common prefix */ extern int git_buf_text_common_prefix(git_buf *buf, const git_strarray *strs); /** * Check quickly if buffer looks like it contains binary data * * @param buf Buffer to check * @return true if buffer looks like non-text data */ extern bool git_buf_text_is_binary(const git_buf *buf); /** * Check quickly if buffer contains a NUL byte * * @param buf Buffer to check * @return true if buffer contains a NUL byte */ extern bool git_buf_text_contains_nul(const git_buf *buf); /** * Check if a buffer begins with a UTF BOM * * @param bom Set to the type of BOM detected or GIT_BOM_NONE * @param buf Buffer in which to check the first bytes for a BOM * @param offset Offset into buffer to look for BOM * @return Number of bytes of BOM data (or 0 if no BOM found) */ extern int git_buf_text_detect_bom( git_bom_t *bom, const git_buf *buf, size_t offset); /** * Gather stats for a piece of text * * Fill the `stats` structure with counts of unreadable characters, carriage * returns, etc, so it can be used in heuristics. This automatically skips * a trailing EOF (\032 character). Also it will look for a BOM at the * start of the text and can be told to skip that as well. * * @param stats Structure to be filled in * @param buf Text to process * @param skip_bom Exclude leading BOM from stats if true * @return Does the buffer heuristically look like binary data */ extern bool git_buf_text_gather_stats( git_buf_text_stats *stats, const git_buf *buf, bool skip_bom); #endif deps/libgit2-sys-0.3.8/libgit2/src/sortedcache.h0000664000175000017500000001361012426525445016341 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sorted_cache_h__ #define INCLUDE_sorted_cache_h__ #include "util.h" #include "fileops.h" #include "vector.h" #include "thread-utils.h" #include "pool.h" #include "strmap.h" #include /* * The purpose of this data structure is to cache the parsed contents of a * file (a.k.a. the backing file) where each item in the file can be * identified by a key string and you want to both look them up by name * and traverse them in sorted order. Each item is assumed to itself end * in a GIT_FLEX_ARRAY. */ typedef void (*git_sortedcache_free_item_fn)(void *payload, void *item); typedef struct { git_refcount rc; git_rwlock lock; size_t item_path_offset; git_sortedcache_free_item_fn free_item; void *free_item_payload; git_pool pool; git_vector items; git_strmap *map; git_futils_filestamp stamp; char path[GIT_FLEX_ARRAY]; } git_sortedcache; /* Create a new sortedcache * * Even though every sortedcache stores items with a GIT_FLEX_ARRAY at * the end containing their key string, you have to provide the item_cmp * sorting function because the sorting function doesn't get a payload * and therefore can't know the offset to the item key string. :-( * * @param out The allocated git_sortedcache * @param item_path_offset Offset to the GIT_FLEX_ARRAY item key in the * struct - use offsetof(struct mine, key-field) to get this * @param free_item Optional callback to free each item * @param free_item_payload Optional payload passed to free_item callback * @param item_cmp Compare the keys of two items * @param path The path to the backing store file for this cache; this * may be NULL. The cache makes it easy to load this and check * if it has been modified since the last load and/or write. */ int git_sortedcache_new( git_sortedcache **out, size_t item_path_offset, /* use offsetof(struct, path-field) macro */ git_sortedcache_free_item_fn free_item, void *free_item_payload, git_vector_cmp item_cmp, const char *path); /* Copy a sorted cache * * - `copy_item` can be NULL to just use memcpy * - if `lock`, grabs read lock on `src` during copy and releases after */ int git_sortedcache_copy( git_sortedcache **out, git_sortedcache *src, bool lock, int (*copy_item)(void *payload, void *tgt_item, void *src_item), void *payload); /* Free sorted cache (first calling `free_item` callbacks) * * Don't call on a locked collection - it may acquire a write lock */ void git_sortedcache_free(git_sortedcache *sc); /* Increment reference count - balance with call to free */ void git_sortedcache_incref(git_sortedcache *sc); /* Get the pathname associated with this cache at creation time */ const char *git_sortedcache_path(git_sortedcache *sc); /* * CACHE WRITE FUNCTIONS * * The following functions require you to have a writer lock to make the * modification. Some of the functions take a `wlock` parameter and * will optionally lock and unlock for you if that is passed as true. * */ /* Lock sortedcache for write */ int git_sortedcache_wlock(git_sortedcache *sc); /* Unlock sorted cache when done with write */ void git_sortedcache_wunlock(git_sortedcache *sc); /* Lock cache and load backing file into a buffer. * * This grabs a write lock on the cache then looks at the modification * time and size of the file on disk. * * If the file appears to have changed, this loads the file contents into * the buffer and returns a positive value leaving the cache locked - the * caller should parse the file content, update the cache as needed, then * release the lock. NOTE: In this case, the caller MUST unlock the cache. * * If the file appears to be unchanged, then this automatically releases * the lock on the cache, clears the buffer, and returns 0. * * @return 0 if up-to-date, 1 if out-of-date, <0 on error */ int git_sortedcache_lockandload(git_sortedcache *sc, git_buf *buf); /* Refresh file timestamp after write completes * You should already be holding the write lock when you call this. */ void git_sortedcache_updated(git_sortedcache *sc); /* Release all items in sorted cache * * If `wlock` is true, grabs write lock and releases when done, otherwise * you should already be holding a write lock when you call this. */ int git_sortedcache_clear(git_sortedcache *sc, bool wlock); /* Find and/or insert item, returning pointer to item data. * You should already be holding the write lock when you call this. */ int git_sortedcache_upsert( void **out, git_sortedcache *sc, const char *key); /* Removes entry at pos from cache * You should already be holding the write lock when you call this. */ int git_sortedcache_remove(git_sortedcache *sc, size_t pos); /* * CACHE READ FUNCTIONS * * The following functions access items in the cache. To prevent the * results from being invalidated before they can be used, you should be * holding either a read lock or a write lock when using these functions. * */ /* Lock sortedcache for read */ int git_sortedcache_rlock(git_sortedcache *sc); /* Unlock sorted cache when done with read */ void git_sortedcache_runlock(git_sortedcache *sc); /* Lookup item by key - returns NULL if not found */ void *git_sortedcache_lookup(const git_sortedcache *sc, const char *key); /* Get how many items are in the cache * * You can call this function without holding a lock, but be aware * that it may change before you use it. */ size_t git_sortedcache_entrycount(const git_sortedcache *sc); /* Lookup item by index - returns NULL if out of range */ void *git_sortedcache_entry(git_sortedcache *sc, size_t pos); /* Lookup index of item by key - returns GIT_ENOTFOUND if not found */ int git_sortedcache_lookup_index( size_t *out, git_sortedcache *sc, const char *key); #endif deps/libgit2-sys-0.3.8/libgit2/src/index.h0000664000175000017500000000765712610310643015165 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_index_h__ #define INCLUDE_index_h__ #include "fileops.h" #include "filebuf.h" #include "vector.h" #include "idxmap.h" #include "tree-cache.h" #include "git2/odb.h" #include "git2/index.h" #define GIT_INDEX_FILE "index" #define GIT_INDEX_FILE_MODE 0666 struct git_index { git_refcount rc; char *index_file_path; git_futils_filestamp stamp; git_oid checksum; /* checksum at the end of the file */ git_vector entries; git_idxmap *entries_map; git_mutex lock; /* lock held while entries is being changed */ git_vector deleted; /* deleted entries if readers > 0 */ git_atomic readers; /* number of active iterators */ unsigned int on_disk:1; unsigned int ignore_case:1; unsigned int distrust_filemode:1; unsigned int no_symlinks:1; git_tree_cache *tree; git_pool tree_pool; git_vector names; git_vector reuc; git_vector_cmp entries_cmp_path; git_vector_cmp entries_search; git_vector_cmp entries_search_path; git_vector_cmp reuc_search; }; struct git_index_conflict_iterator { git_index *index; size_t cur; }; extern void git_index_entry__init_from_stat( git_index_entry *entry, struct stat *st, bool trust_mode); /* Index entry comparison functions for array sorting */ extern int git_index_entry_cmp(const void *a, const void *b); extern int git_index_entry_icmp(const void *a, const void *b); /* Index entry search functions for search using a search spec */ extern int git_index_entry_srch(const void *a, const void *b); extern int git_index_entry_isrch(const void *a, const void *b); /* Search index for `path`, returning GIT_ENOTFOUND if it does not exist * (but not setting an error message). * * `at_pos` is set to the position where it is or would be inserted. * Pass `path_len` as strlen of path or 0 to call strlen internally. */ extern int git_index__find_pos( size_t *at_pos, git_index *index, const char *path, size_t path_len, int stage); extern void git_index__set_ignore_case(git_index *index, bool ignore_case); extern unsigned int git_index__create_mode(unsigned int mode); GIT_INLINE(const git_futils_filestamp *) git_index__filestamp(git_index *index) { return &index->stamp; } extern int git_index__changed_relative_to(git_index *index, const git_oid *checksum); /* Copy the current entries vector *and* increment the index refcount. * Call `git_index__release_snapshot` when done. */ extern int git_index_snapshot_new(git_vector *snap, git_index *index); extern void git_index_snapshot_release(git_vector *snap, git_index *index); /* Allow searching in a snapshot; entries must already be sorted! */ extern int git_index_snapshot_find( size_t *at_pos, git_vector *snap, git_vector_cmp entry_srch, const char *path, size_t path_len, int stage); /* Replace an index with a new index */ int git_index_read_index(git_index *index, const git_index *new_index); typedef struct { git_index *index; git_filebuf file; unsigned int should_write:1; } git_indexwriter; #define GIT_INDEXWRITER_INIT { NULL, GIT_FILEBUF_INIT } /* Lock the index for eventual writing. */ extern int git_indexwriter_init(git_indexwriter *writer, git_index *index); /* Lock the index for eventual writing by a repository operation: a merge, * revert, cherry-pick or a rebase. Note that the given checkout strategy * will be updated for the operation's use so that checkout will not write * the index. */ extern int git_indexwriter_init_for_operation( git_indexwriter *writer, git_repository *repo, unsigned int *checkout_strategy); /* Write the index and unlock it. */ extern int git_indexwriter_commit(git_indexwriter *writer); /* Cleanup an index writing session, unlocking the file (if it is still * locked and freeing any data structures. */ extern void git_indexwriter_cleanup(git_indexwriter *writer); #endif deps/libgit2-sys-0.3.8/libgit2/src/filebuf.c0000664000175000017500000003021612610310643015450 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "filebuf.h" #include "fileops.h" static const size_t WRITE_BUFFER_SIZE = (4096 * 2); enum buferr_t { BUFERR_OK = 0, BUFERR_WRITE, BUFERR_ZLIB, BUFERR_MEM }; #define ENSURE_BUF_OK(buf) if ((buf)->last_error != BUFERR_OK) { return -1; } static int verify_last_error(git_filebuf *file) { switch (file->last_error) { case BUFERR_WRITE: giterr_set(GITERR_OS, "Failed to write out file"); return -1; case BUFERR_MEM: giterr_set_oom(); return -1; case BUFERR_ZLIB: giterr_set(GITERR_ZLIB, "Buffer error when writing out ZLib data"); return -1; default: return 0; } } static int lock_file(git_filebuf *file, int flags, mode_t mode) { if (git_path_exists(file->path_lock) == true) { if (flags & GIT_FILEBUF_FORCE) p_unlink(file->path_lock); else { giterr_clear(); /* actual OS error code just confuses */ giterr_set(GITERR_OS, "Failed to lock file '%s' for writing", file->path_lock); return GIT_ELOCKED; } } /* create path to the file buffer is required */ if (flags & GIT_FILEBUF_FORCE) { /* XXX: Should dirmode here be configurable? Or is 0777 always fine? */ file->fd = git_futils_creat_locked_withpath(file->path_lock, 0777, mode); } else { file->fd = git_futils_creat_locked(file->path_lock, mode); } if (file->fd < 0) return file->fd; file->fd_is_open = true; if ((flags & GIT_FILEBUF_APPEND) && git_path_exists(file->path_original) == true) { git_file source; char buffer[FILEIO_BUFSIZE]; ssize_t read_bytes; source = p_open(file->path_original, O_RDONLY); if (source < 0) { giterr_set(GITERR_OS, "Failed to open file '%s' for reading", file->path_original); return -1; } while ((read_bytes = p_read(source, buffer, sizeof(buffer))) > 0) { p_write(file->fd, buffer, read_bytes); if (file->compute_digest) git_hash_update(&file->digest, buffer, read_bytes); } p_close(source); if (read_bytes < 0) { giterr_set(GITERR_OS, "Failed to read file '%s'", file->path_original); return -1; } } return 0; } void git_filebuf_cleanup(git_filebuf *file) { if (file->fd_is_open && file->fd >= 0) p_close(file->fd); if (file->created_lock && !file->did_rename && file->path_lock && git_path_exists(file->path_lock)) p_unlink(file->path_lock); if (file->compute_digest) { git_hash_ctx_cleanup(&file->digest); file->compute_digest = 0; } if (file->buffer) git__free(file->buffer); /* use the presence of z_buf to decide if we need to deflateEnd */ if (file->z_buf) { git__free(file->z_buf); deflateEnd(&file->zs); } if (file->path_original) git__free(file->path_original); if (file->path_lock) git__free(file->path_lock); memset(file, 0x0, sizeof(git_filebuf)); file->fd = -1; } GIT_INLINE(int) flush_buffer(git_filebuf *file) { int result = file->write(file, file->buffer, file->buf_pos); file->buf_pos = 0; return result; } int git_filebuf_flush(git_filebuf *file) { return flush_buffer(file); } static int write_normal(git_filebuf *file, void *source, size_t len) { if (len > 0) { if (p_write(file->fd, (void *)source, len) < 0) { file->last_error = BUFERR_WRITE; return -1; } if (file->compute_digest) git_hash_update(&file->digest, source, len); } return 0; } static int write_deflate(git_filebuf *file, void *source, size_t len) { z_stream *zs = &file->zs; if (len > 0 || file->flush_mode == Z_FINISH) { zs->next_in = source; zs->avail_in = (uInt)len; do { size_t have; zs->next_out = file->z_buf; zs->avail_out = (uInt)file->buf_size; if (deflate(zs, file->flush_mode) == Z_STREAM_ERROR) { file->last_error = BUFERR_ZLIB; return -1; } have = file->buf_size - (size_t)zs->avail_out; if (p_write(file->fd, file->z_buf, have) < 0) { file->last_error = BUFERR_WRITE; return -1; } } while (zs->avail_out == 0); assert(zs->avail_in == 0); if (file->compute_digest) git_hash_update(&file->digest, source, len); } return 0; } #define MAX_SYMLINK_DEPTH 5 static int resolve_symlink(git_buf *out, const char *path) { int i, error, root; ssize_t ret; struct stat st; git_buf curpath = GIT_BUF_INIT, target = GIT_BUF_INIT; if ((error = git_buf_grow(&target, GIT_PATH_MAX + 1)) < 0 || (error = git_buf_puts(&curpath, path)) < 0) return error; for (i = 0; i < MAX_SYMLINK_DEPTH; i++) { error = p_lstat(curpath.ptr, &st); if (error < 0 && errno == ENOENT) { error = git_buf_puts(out, curpath.ptr); goto cleanup; } if (error < 0) { giterr_set(GITERR_OS, "failed to stat '%s'", curpath.ptr); error = -1; goto cleanup; } if (!S_ISLNK(st.st_mode)) { error = git_buf_puts(out, curpath.ptr); goto cleanup; } ret = p_readlink(curpath.ptr, target.ptr, GIT_PATH_MAX); if (ret < 0) { giterr_set(GITERR_OS, "failed to read symlink '%s'", curpath.ptr); error = -1; goto cleanup; } if (ret == GIT_PATH_MAX) { giterr_set(GITERR_INVALID, "symlink target too long"); error = -1; goto cleanup; } /* readlink(2) won't NUL-terminate for us */ target.ptr[ret] = '\0'; target.size = ret; root = git_path_root(target.ptr); if (root >= 0) { if ((error = git_buf_puts(&curpath, target.ptr)) < 0) goto cleanup; } else { git_buf dir = GIT_BUF_INIT; if ((error = git_path_dirname_r(&dir, curpath.ptr)) < 0) goto cleanup; git_buf_swap(&curpath, &dir); git_buf_free(&dir); if ((error = git_path_apply_relative(&curpath, target.ptr)) < 0) goto cleanup; } } giterr_set(GITERR_INVALID, "maximum symlink depth reached"); error = -1; cleanup: git_buf_free(&curpath); git_buf_free(&target); return error; } int git_filebuf_open(git_filebuf *file, const char *path, int flags, mode_t mode) { int compression, error = -1; size_t path_len, alloc_len; /* opening an already open buffer is a programming error; * assert that this never happens instead of returning * an error code */ assert(file && path && file->buffer == NULL); memset(file, 0x0, sizeof(git_filebuf)); if (flags & GIT_FILEBUF_DO_NOT_BUFFER) file->do_not_buffer = true; file->buf_size = WRITE_BUFFER_SIZE; file->buf_pos = 0; file->fd = -1; file->last_error = BUFERR_OK; /* Allocate the main cache buffer */ if (!file->do_not_buffer) { file->buffer = git__malloc(file->buf_size); GITERR_CHECK_ALLOC(file->buffer); } /* If we are hashing on-write, allocate a new hash context */ if (flags & GIT_FILEBUF_HASH_CONTENTS) { file->compute_digest = 1; if (git_hash_ctx_init(&file->digest) < 0) goto cleanup; } compression = flags >> GIT_FILEBUF_DEFLATE_SHIFT; /* If we are deflating on-write, */ if (compression != 0) { /* Initialize the ZLib stream */ if (deflateInit(&file->zs, compression) != Z_OK) { giterr_set(GITERR_ZLIB, "Failed to initialize zlib"); goto cleanup; } /* Allocate the Zlib cache buffer */ file->z_buf = git__malloc(file->buf_size); GITERR_CHECK_ALLOC(file->z_buf); /* Never flush */ file->flush_mode = Z_NO_FLUSH; file->write = &write_deflate; } else { file->write = &write_normal; } /* If we are writing to a temp file */ if (flags & GIT_FILEBUF_TEMPORARY) { git_buf tmp_path = GIT_BUF_INIT; /* Open the file as temporary for locking */ file->fd = git_futils_mktmp(&tmp_path, path, mode); if (file->fd < 0) { git_buf_free(&tmp_path); goto cleanup; } file->fd_is_open = true; file->created_lock = true; /* No original path */ file->path_original = NULL; file->path_lock = git_buf_detach(&tmp_path); GITERR_CHECK_ALLOC(file->path_lock); } else { git_buf resolved_path = GIT_BUF_INIT; if ((error = resolve_symlink(&resolved_path, path)) < 0) goto cleanup; /* Save the original path of the file */ path_len = resolved_path.size; file->path_original = git_buf_detach(&resolved_path); /* create the locking path by appending ".lock" to the original */ GITERR_CHECK_ALLOC_ADD(&alloc_len, path_len, GIT_FILELOCK_EXTLENGTH); file->path_lock = git__malloc(alloc_len); GITERR_CHECK_ALLOC(file->path_lock); memcpy(file->path_lock, file->path_original, path_len); memcpy(file->path_lock + path_len, GIT_FILELOCK_EXTENSION, GIT_FILELOCK_EXTLENGTH); /* open the file for locking */ if ((error = lock_file(file, flags, mode)) < 0) goto cleanup; file->created_lock = true; } return 0; cleanup: git_filebuf_cleanup(file); return error; } int git_filebuf_hash(git_oid *oid, git_filebuf *file) { assert(oid && file && file->compute_digest); flush_buffer(file); if (verify_last_error(file) < 0) return -1; git_hash_final(oid, &file->digest); git_hash_ctx_cleanup(&file->digest); file->compute_digest = 0; return 0; } int git_filebuf_commit_at(git_filebuf *file, const char *path) { git__free(file->path_original); file->path_original = git__strdup(path); GITERR_CHECK_ALLOC(file->path_original); return git_filebuf_commit(file); } int git_filebuf_commit(git_filebuf *file) { /* temporary files cannot be committed */ assert(file && file->path_original); file->flush_mode = Z_FINISH; flush_buffer(file); if (verify_last_error(file) < 0) goto on_error; file->fd_is_open = false; if (p_close(file->fd) < 0) { giterr_set(GITERR_OS, "Failed to close file at '%s'", file->path_lock); goto on_error; } file->fd = -1; if (p_rename(file->path_lock, file->path_original) < 0) { giterr_set(GITERR_OS, "Failed to rename lockfile to '%s'", file->path_original); goto on_error; } file->did_rename = true; git_filebuf_cleanup(file); return 0; on_error: git_filebuf_cleanup(file); return -1; } GIT_INLINE(void) add_to_cache(git_filebuf *file, const void *buf, size_t len) { memcpy(file->buffer + file->buf_pos, buf, len); file->buf_pos += len; } int git_filebuf_write(git_filebuf *file, const void *buff, size_t len) { const unsigned char *buf = buff; ENSURE_BUF_OK(file); if (file->do_not_buffer) return file->write(file, (void *)buff, len); for (;;) { size_t space_left = file->buf_size - file->buf_pos; /* cache if it's small */ if (space_left > len) { add_to_cache(file, buf, len); return 0; } add_to_cache(file, buf, space_left); if (flush_buffer(file) < 0) return -1; len -= space_left; buf += space_left; } } int git_filebuf_reserve(git_filebuf *file, void **buffer, size_t len) { size_t space_left = file->buf_size - file->buf_pos; *buffer = NULL; ENSURE_BUF_OK(file); if (len > file->buf_size) { file->last_error = BUFERR_MEM; return -1; } if (space_left <= len) { if (flush_buffer(file) < 0) return -1; } *buffer = (file->buffer + file->buf_pos); file->buf_pos += len; return 0; } int git_filebuf_printf(git_filebuf *file, const char *format, ...) { va_list arglist; size_t space_left, len, alloclen; int written, res; char *tmp_buffer; ENSURE_BUF_OK(file); space_left = file->buf_size - file->buf_pos; do { va_start(arglist, format); written = p_vsnprintf((char *)file->buffer + file->buf_pos, space_left, format, arglist); va_end(arglist); if (written < 0) { file->last_error = BUFERR_MEM; return -1; } len = written; if (len + 1 <= space_left) { file->buf_pos += len; return 0; } if (flush_buffer(file) < 0) return -1; space_left = file->buf_size - file->buf_pos; } while (len + 1 <= space_left); if (GIT_ADD_SIZET_OVERFLOW(&alloclen, len, 1) || !(tmp_buffer = git__malloc(alloclen))) { file->last_error = BUFERR_MEM; return -1; } va_start(arglist, format); written = p_vsnprintf(tmp_buffer, len + 1, format, arglist); va_end(arglist); if (written < 0) { git__free(tmp_buffer); file->last_error = BUFERR_MEM; return -1; } res = git_filebuf_write(file, tmp_buffer, len); git__free(tmp_buffer); return res; } int git_filebuf_stats(time_t *mtime, size_t *size, git_filebuf *file) { int res; struct stat st; if (file->fd_is_open) res = p_fstat(file->fd, &st); else res = p_stat(file->path_original, &st); if (res < 0) { giterr_set(GITERR_OS, "Could not get stat info for '%s'", file->path_original); return res; } if (mtime) *mtime = st.st_mtime; if (size) *size = (size_t)st.st_size; return 0; } deps/libgit2-sys-0.3.8/libgit2/src/remote.c0000664000175000017500000016705712610310643015345 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/config.h" #include "git2/types.h" #include "git2/oid.h" #include "git2/net.h" #include "common.h" #include "config.h" #include "repository.h" #include "remote.h" #include "fetch.h" #include "refs.h" #include "refspec.h" #include "fetchhead.h" #include "push.h" #define CONFIG_URL_FMT "remote.%s.url" #define CONFIG_PUSHURL_FMT "remote.%s.pushurl" #define CONFIG_FETCH_FMT "remote.%s.fetch" #define CONFIG_PUSH_FMT "remote.%s.push" #define CONFIG_TAGOPT_FMT "remote.%s.tagopt" static int dwim_refspecs(git_vector *out, git_vector *refspecs, git_vector *refs); static int lookup_remote_prune_config(git_remote *remote, git_config *config, const char *name); char *apply_insteadof(git_config *config, const char *url, int direction); static int add_refspec_to(git_vector *vector, const char *string, bool is_fetch) { git_refspec *spec; spec = git__calloc(1, sizeof(git_refspec)); GITERR_CHECK_ALLOC(spec); if (git_refspec__parse(spec, string, is_fetch) < 0) { git__free(spec); return -1; } spec->push = !is_fetch; if (git_vector_insert(vector, spec) < 0) { git_refspec__free(spec); git__free(spec); return -1; } return 0; } static int add_refspec(git_remote *remote, const char *string, bool is_fetch) { return add_refspec_to(&remote->refspecs, string, is_fetch); } static int download_tags_value(git_remote *remote, git_config *cfg) { git_config_entry *ce; git_buf buf = GIT_BUF_INIT; int error; if (git_buf_printf(&buf, "remote.%s.tagopt", remote->name) < 0) return -1; error = git_config__lookup_entry(&ce, cfg, git_buf_cstr(&buf), false); git_buf_free(&buf); if (!error && ce && ce->value) { if (!strcmp(ce->value, "--no-tags")) remote->download_tags = GIT_REMOTE_DOWNLOAD_TAGS_NONE; else if (!strcmp(ce->value, "--tags")) remote->download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL; } git_config_entry_free(ce); return error; } static int ensure_remote_name_is_valid(const char *name) { int error = 0; if (!git_remote_is_valid_name(name)) { giterr_set( GITERR_CONFIG, "'%s' is not a valid remote name.", name ? name : "(null)"); error = GIT_EINVALIDSPEC; } return error; } static int write_add_refspec(git_repository *repo, const char *name, const char *refspec, bool fetch) { git_config *cfg; git_buf var = GIT_BUF_INIT; git_refspec spec; const char *fmt; int error; if ((error = git_repository_config__weakptr(&cfg, repo)) < 0) return error; fmt = fetch ? CONFIG_FETCH_FMT : CONFIG_PUSH_FMT; if ((error = ensure_remote_name_is_valid(name)) < 0) return error; if ((error = git_refspec__parse(&spec, refspec, fetch)) < 0) { if (giterr_last()->klass != GITERR_NOMEMORY) error = GIT_EINVALIDSPEC; return error; } git_refspec__free(&spec); if ((error = git_buf_printf(&var, fmt, name)) < 0) return error; /* * "$^" is a unmatcheable regexp: it will not match anything at all, so * all values will be considered new and we will not replace any * present value. */ if ((error = git_config_set_multivar(cfg, var.ptr, "$^", refspec)) < 0) { goto cleanup; } cleanup: git_buf_free(&var); return 0; } #if 0 /* We could export this as a helper */ static int get_check_cert(int *out, git_repository *repo) { git_config *cfg; const char *val; int error = 0; assert(out && repo); /* By default, we *DO* want to verify the certificate. */ *out = 1; /* Go through the possible sources for SSL verification settings, from * most specific to least specific. */ /* GIT_SSL_NO_VERIFY environment variable */ if ((val = p_getenv("GIT_SSL_NO_VERIFY")) != NULL) return git_config_parse_bool(out, val); /* http.sslVerify config setting */ if ((error = git_repository_config__weakptr(&cfg, repo)) < 0) return error; *out = git_config__get_bool_force(cfg, "http.sslverify", 1); return 0; } #endif static int canonicalize_url(git_buf *out, const char *in) { if (in == NULL || strlen(in) == 0) { giterr_set(GITERR_INVALID, "cannot set empty URL"); return GIT_EINVALIDSPEC; } #ifdef GIT_WIN32 /* Given a UNC path like \\server\path, we need to convert this * to //server/path for compatibility with core git. */ if (in[0] == '\\' && in[1] == '\\' && (git__isalpha(in[2]) || git__isdigit(in[2]))) { const char *c; for (c = in; *c; c++) git_buf_putc(out, *c == '\\' ? '/' : *c); return git_buf_oom(out) ? -1 : 0; } #endif return git_buf_puts(out, in); } static int create_internal(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch) { git_remote *remote; git_config *config = NULL; git_buf canonical_url = GIT_BUF_INIT; git_buf var = GIT_BUF_INIT; int error = -1; /* name is optional */ assert(out && repo && url); if ((error = git_repository_config__weakptr(&config, repo)) < 0) return error; remote = git__calloc(1, sizeof(git_remote)); GITERR_CHECK_ALLOC(remote); remote->repo = repo; if (git_vector_init(&remote->refs, 32, NULL) < 0 || canonicalize_url(&canonical_url, url) < 0) goto on_error; remote->url = apply_insteadof(repo->_config, canonical_url.ptr, GIT_DIRECTION_FETCH); if (name != NULL) { remote->name = git__strdup(name); GITERR_CHECK_ALLOC(remote->name); if ((error = git_buf_printf(&var, CONFIG_URL_FMT, name)) < 0) goto on_error; if ((error = git_config_set_string(config, var.ptr, canonical_url.ptr)) < 0) goto on_error; } if (fetch != NULL) { if ((error = add_refspec(remote, fetch, true)) < 0) goto on_error; /* only write for non-anonymous remotes */ if (name && (error = write_add_refspec(repo, name, fetch, true)) < 0) goto on_error; if ((error = git_repository_config_snapshot(&config, repo)) < 0) goto on_error; if ((error = lookup_remote_prune_config(remote, config, name)) < 0) goto on_error; /* Move the data over to where the matching functions can find them */ if ((error = dwim_refspecs(&remote->active_refspecs, &remote->refspecs, &remote->refs)) < 0) goto on_error; } /* A remote without a name doesn't download tags */ if (!name) remote->download_tags = GIT_REMOTE_DOWNLOAD_TAGS_NONE; else remote->download_tags = GIT_REMOTE_DOWNLOAD_TAGS_AUTO; git_buf_free(&var); *out = remote; error = 0; on_error: if (error) git_remote_free(remote); git_config_free(config); git_buf_free(&canonical_url); git_buf_free(&var); return error; } static int ensure_remote_doesnot_exist(git_repository *repo, const char *name) { int error; git_remote *remote; error = git_remote_lookup(&remote, repo, name); if (error == GIT_ENOTFOUND) return 0; if (error < 0) return error; git_remote_free(remote); giterr_set( GITERR_CONFIG, "Remote '%s' already exists.", name); return GIT_EEXISTS; } int git_remote_create(git_remote **out, git_repository *repo, const char *name, const char *url) { git_buf buf = GIT_BUF_INIT; int error; if (git_buf_printf(&buf, "+refs/heads/*:refs/remotes/%s/*", name) < 0) return -1; error = git_remote_create_with_fetchspec(out, repo, name, url, git_buf_cstr(&buf)); git_buf_free(&buf); return error; } int git_remote_create_with_fetchspec(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch) { git_remote *remote = NULL; int error; if ((error = ensure_remote_name_is_valid(name)) < 0) return error; if ((error = ensure_remote_doesnot_exist(repo, name)) < 0) return error; if (create_internal(&remote, repo, name, url, fetch) < 0) goto on_error; *out = remote; return 0; on_error: git_remote_free(remote); return -1; } int git_remote_create_anonymous(git_remote **out, git_repository *repo, const char *url) { return create_internal(out, repo, NULL, url, NULL); } int git_remote_dup(git_remote **dest, git_remote *source) { size_t i; int error = 0; git_refspec *spec; git_remote *remote = git__calloc(1, sizeof(git_remote)); GITERR_CHECK_ALLOC(remote); if (source->name != NULL) { remote->name = git__strdup(source->name); GITERR_CHECK_ALLOC(remote->name); } if (source->url != NULL) { remote->url = git__strdup(source->url); GITERR_CHECK_ALLOC(remote->url); } if (source->pushurl != NULL) { remote->pushurl = git__strdup(source->pushurl); GITERR_CHECK_ALLOC(remote->pushurl); } remote->repo = source->repo; remote->download_tags = source->download_tags; remote->prune_refs = source->prune_refs; if (git_vector_init(&remote->refs, 32, NULL) < 0 || git_vector_init(&remote->refspecs, 2, NULL) < 0 || git_vector_init(&remote->active_refspecs, 2, NULL) < 0) { error = -1; goto cleanup; } git_vector_foreach(&source->refspecs, i, spec) { if ((error = add_refspec(remote, spec->string, !spec->push)) < 0) goto cleanup; } *dest = remote; cleanup: if (error < 0) git__free(remote); return error; } struct refspec_cb_data { git_remote *remote; int fetch; }; static int refspec_cb(const git_config_entry *entry, void *payload) { struct refspec_cb_data *data = (struct refspec_cb_data *)payload; return add_refspec(data->remote, entry->value, data->fetch); } static int get_optional_config( bool *found, git_config *config, git_buf *buf, git_config_foreach_cb cb, void *payload) { int error = 0; const char *key = git_buf_cstr(buf); if (git_buf_oom(buf)) return -1; if (cb != NULL) error = git_config_get_multivar_foreach(config, key, NULL, cb, payload); else error = git_config_get_string(payload, config, key); if (found) *found = !error; if (error == GIT_ENOTFOUND) { giterr_clear(); error = 0; } return error; } int git_remote_lookup(git_remote **out, git_repository *repo, const char *name) { git_remote *remote; git_buf buf = GIT_BUF_INIT; const char *val; int error = 0; git_config *config; struct refspec_cb_data data = { NULL }; bool optional_setting_found = false, found; assert(out && repo && name); if ((error = ensure_remote_name_is_valid(name)) < 0) return error; if ((error = git_repository_config_snapshot(&config, repo)) < 0) return error; remote = git__calloc(1, sizeof(git_remote)); GITERR_CHECK_ALLOC(remote); remote->name = git__strdup(name); GITERR_CHECK_ALLOC(remote->name); if (git_vector_init(&remote->refs, 32, NULL) < 0 || git_vector_init(&remote->refspecs, 2, NULL) < 0 || git_vector_init(&remote->passive_refspecs, 2, NULL) < 0 || git_vector_init(&remote->active_refspecs, 2, NULL) < 0) { error = -1; goto cleanup; } if ((error = git_buf_printf(&buf, "remote.%s.url", name)) < 0) goto cleanup; if ((error = get_optional_config(&found, config, &buf, NULL, (void *)&val)) < 0) goto cleanup; optional_setting_found |= found; remote->repo = repo; remote->download_tags = GIT_REMOTE_DOWNLOAD_TAGS_AUTO; if (found && strlen(val) > 0) { remote->url = apply_insteadof(config, val, GIT_DIRECTION_FETCH); GITERR_CHECK_ALLOC(remote->url); } val = NULL; git_buf_clear(&buf); git_buf_printf(&buf, "remote.%s.pushurl", name); if ((error = get_optional_config(&found, config, &buf, NULL, (void *)&val)) < 0) goto cleanup; optional_setting_found |= found; if (!optional_setting_found) { error = GIT_ENOTFOUND; giterr_set(GITERR_CONFIG, "Remote '%s' does not exist.", name); goto cleanup; } if (found && strlen(val) > 0) { remote->pushurl = apply_insteadof(config, val, GIT_DIRECTION_PUSH); GITERR_CHECK_ALLOC(remote->pushurl); } data.remote = remote; data.fetch = true; git_buf_clear(&buf); git_buf_printf(&buf, "remote.%s.fetch", name); if ((error = get_optional_config(NULL, config, &buf, refspec_cb, &data)) < 0) goto cleanup; data.fetch = false; git_buf_clear(&buf); git_buf_printf(&buf, "remote.%s.push", name); if ((error = get_optional_config(NULL, config, &buf, refspec_cb, &data)) < 0) goto cleanup; if (download_tags_value(remote, config) < 0) goto cleanup; if ((error = lookup_remote_prune_config(remote, config, name)) < 0) goto cleanup; /* Move the data over to where the matching functions can find them */ if ((error = dwim_refspecs(&remote->active_refspecs, &remote->refspecs, &remote->refs)) < 0) goto cleanup; *out = remote; cleanup: git_config_free(config); git_buf_free(&buf); if (error < 0) git_remote_free(remote); return error; } static int lookup_remote_prune_config(git_remote *remote, git_config *config, const char *name) { git_buf buf = GIT_BUF_INIT; int error = 0; git_buf_printf(&buf, "remote.%s.prune", name); if ((error = git_config_get_bool(&remote->prune_refs, config, git_buf_cstr(&buf))) < 0) { if (error == GIT_ENOTFOUND) { giterr_clear(); if ((error = git_config_get_bool(&remote->prune_refs, config, "fetch.prune")) < 0) { if (error == GIT_ENOTFOUND) { giterr_clear(); error = 0; } } } } git_buf_free(&buf); return error; } static int update_config_refspec(const git_remote *remote, git_config *config, int direction) { git_buf name = GIT_BUF_INIT; unsigned int push; const char *dir; size_t i; int error = 0; const char *cname; push = direction == GIT_DIRECTION_PUSH; dir = push ? "push" : "fetch"; if (git_buf_printf(&name, "remote.%s.%s", remote->name, dir) < 0) return -1; cname = git_buf_cstr(&name); /* Clear out the existing config */ while (!error) error = git_config_delete_multivar(config, cname, ".*"); if (error != GIT_ENOTFOUND) return error; for (i = 0; i < remote->refspecs.length; i++) { git_refspec *spec = git_vector_get(&remote->refspecs, i); if (spec->push != push) continue; // "$^" is a unmatcheable regexp: it will not match anything at all, so // all values will be considered new and we will not replace any // present value. if ((error = git_config_set_multivar( config, cname, "$^", spec->string)) < 0) { goto cleanup; } } giterr_clear(); error = 0; cleanup: git_buf_free(&name); return error; } const char *git_remote_name(const git_remote *remote) { assert(remote); return remote->name; } git_repository *git_remote_owner(const git_remote *remote) { assert(remote); return remote->repo; } const char *git_remote_url(const git_remote *remote) { assert(remote); return remote->url; } static int set_url(git_repository *repo, const char *remote, const char *pattern, const char *url) { git_config *cfg; git_buf buf = GIT_BUF_INIT, canonical_url = GIT_BUF_INIT; int error; assert(repo && remote); if ((error = ensure_remote_name_is_valid(remote)) < 0) return error; if ((error = git_repository_config__weakptr(&cfg, repo)) < 0) return error; if ((error = git_buf_printf(&buf, pattern, remote)) < 0) return error; if (url) { if ((error = canonicalize_url(&canonical_url, url)) < 0) goto cleanup; error = git_config_set_string(cfg, buf.ptr, url); } else { error = git_config_delete_entry(cfg, buf.ptr); } cleanup: git_buf_free(&canonical_url); git_buf_free(&buf); return error; } int git_remote_set_url(git_repository *repo, const char *remote, const char *url) { return set_url(repo, remote, CONFIG_URL_FMT, url); } const char *git_remote_pushurl(const git_remote *remote) { assert(remote); return remote->pushurl; } int git_remote_set_pushurl(git_repository *repo, const char *remote, const char* url) { return set_url(repo, remote, CONFIG_PUSHURL_FMT, url); } const char* git_remote__urlfordirection(git_remote *remote, int direction) { assert(remote); assert(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH); if (direction == GIT_DIRECTION_FETCH) { return remote->url; } if (direction == GIT_DIRECTION_PUSH) { return remote->pushurl ? remote->pushurl : remote->url; } return NULL; } int set_transport_callbacks(git_transport *t, const git_remote_callbacks *cbs) { if (!t->set_callbacks || !cbs) return 0; return t->set_callbacks(t, cbs->sideband_progress, NULL, cbs->certificate_check, cbs->payload); } static int set_transport_custom_headers(git_transport *t, const git_strarray *custom_headers) { if (!t->set_custom_headers) return 0; return t->set_custom_headers(t, custom_headers); } int git_remote_connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_strarray *custom_headers) { git_transport *t; const char *url; int flags = GIT_TRANSPORTFLAGS_NONE; int error; void *payload = NULL; git_cred_acquire_cb credentials = NULL; git_transport_cb transport = NULL; assert(remote); if (callbacks) { GITERR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks"); credentials = callbacks->credentials; transport = callbacks->transport; payload = callbacks->payload; } t = remote->transport; url = git_remote__urlfordirection(remote, direction); if (url == NULL) { giterr_set(GITERR_INVALID, "Malformed remote '%s' - missing URL", remote->name); return -1; } /* If we don't have a transport object yet, and the caller specified a * custom transport factory, use that */ if (!t && transport && (error = transport(&t, remote, payload)) < 0) return error; /* If we still don't have a transport, then use the global * transport registrations which map URI schemes to transport factories */ if (!t && (error = git_transport_new(&t, remote, url)) < 0) return error; if ((error = set_transport_custom_headers(t, custom_headers)) != 0) goto on_error; if ((error = set_transport_callbacks(t, callbacks)) < 0 || (error = t->connect(t, url, credentials, payload, direction, flags)) != 0) goto on_error; remote->transport = t; return 0; on_error: t->free(t); if (t == remote->transport) remote->transport = NULL; return error; } int git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote) { assert(remote); if (!remote->transport) { giterr_set(GITERR_NET, "this remote has never connected"); return -1; } return remote->transport->ls(out, size, remote->transport); } int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_url) { git_config *cfg; git_config_entry *ce = NULL; git_buf val = GIT_BUF_INIT; int error; assert(remote); if (!proxy_url || !remote->repo) return -1; *proxy_url = NULL; if ((error = git_repository_config__weakptr(&cfg, remote->repo)) < 0) return error; /* Go through the possible sources for proxy configuration, from most specific * to least specific. */ /* remote..proxy config setting */ if (remote->name && remote->name[0]) { git_buf buf = GIT_BUF_INIT; if ((error = git_buf_printf(&buf, "remote.%s.proxy", remote->name)) < 0) return error; error = git_config__lookup_entry(&ce, cfg, git_buf_cstr(&buf), false); git_buf_free(&buf); if (error < 0) return error; if (ce && ce->value) { *proxy_url = git__strdup(ce->value); goto found; } } /* http.proxy config setting */ if ((error = git_config__lookup_entry(&ce, cfg, "http.proxy", false)) < 0) return error; if (ce && ce->value) { *proxy_url = git__strdup(ce->value); goto found; } /* HTTP_PROXY / HTTPS_PROXY environment variables */ error = git__getenv(&val, use_ssl ? "HTTPS_PROXY" : "HTTP_PROXY"); if (error < 0) { if (error == GIT_ENOTFOUND) { giterr_clear(); error = 0; } return error; } *proxy_url = git_buf_detach(&val); found: GITERR_CHECK_ALLOC(*proxy_url); git_config_entry_free(ce); return 0; } /* DWIM `refspecs` based on `refs` and append the output to `out` */ static int dwim_refspecs(git_vector *out, git_vector *refspecs, git_vector *refs) { size_t i; git_refspec *spec; git_vector_foreach(refspecs, i, spec) { if (git_refspec__dwim_one(out, spec, refs) < 0) return -1; } return 0; } static void free_refspecs(git_vector *vec) { size_t i; git_refspec *spec; git_vector_foreach(vec, i, spec) { git_refspec__free(spec); git__free(spec); } git_vector_clear(vec); } static int remote_head_cmp(const void *_a, const void *_b) { const git_remote_head *a = (git_remote_head *) _a; const git_remote_head *b = (git_remote_head *) _b; return git__strcmp_cb(a->name, b->name); } static int ls_to_vector(git_vector *out, git_remote *remote) { git_remote_head **heads; size_t heads_len, i; if (git_remote_ls((const git_remote_head ***)&heads, &heads_len, remote) < 0) return -1; if (git_vector_init(out, heads_len, remote_head_cmp) < 0) return -1; for (i = 0; i < heads_len; i++) { if (git_vector_insert(out, heads[i]) < 0) return -1; } return 0; } int git_remote_download(git_remote *remote, const git_strarray *refspecs, const git_fetch_options *opts) { int error = -1; size_t i; git_vector *to_active, specs = GIT_VECTOR_INIT, refs = GIT_VECTOR_INIT; const git_remote_callbacks *cbs = NULL; const git_strarray *custom_headers = NULL; assert(remote); if (opts) { GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks"); cbs = &opts->callbacks; custom_headers = &opts->custom_headers; } if (!git_remote_connected(remote) && (error = git_remote_connect(remote, GIT_DIRECTION_FETCH, cbs, custom_headers)) < 0) goto on_error; if (ls_to_vector(&refs, remote) < 0) return -1; if ((git_vector_init(&specs, 0, NULL)) < 0) goto on_error; remote->passed_refspecs = 0; if (!refspecs || !refspecs->count) { to_active = &remote->refspecs; } else { for (i = 0; i < refspecs->count; i++) { if ((error = add_refspec_to(&specs, refspecs->strings[i], true)) < 0) goto on_error; } to_active = &specs; remote->passed_refspecs = 1; } free_refspecs(&remote->passive_refspecs); if ((error = dwim_refspecs(&remote->passive_refspecs, &remote->refspecs, &refs)) < 0) goto on_error; free_refspecs(&remote->active_refspecs); error = dwim_refspecs(&remote->active_refspecs, to_active, &refs); git_vector_free(&refs); free_refspecs(&specs); git_vector_free(&specs); if (error < 0) return error; if (remote->push) { git_push_free(remote->push); remote->push = NULL; } if ((error = git_fetch_negotiate(remote, opts)) < 0) return error; return git_fetch_download_pack(remote, cbs); on_error: git_vector_free(&refs); free_refspecs(&specs); git_vector_free(&specs); return error; } int git_remote_fetch( git_remote *remote, const git_strarray *refspecs, const git_fetch_options *opts, const char *reflog_message) { int error, update_fetchhead = 1; git_remote_autotag_option_t tagopt = remote->download_tags; bool prune = false; git_buf reflog_msg_buf = GIT_BUF_INIT; const git_remote_callbacks *cbs = NULL; const git_strarray *custom_headers = NULL; if (opts) { GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks"); cbs = &opts->callbacks; custom_headers = &opts->custom_headers; update_fetchhead = opts->update_fetchhead; tagopt = opts->download_tags; } /* Connect and download everything */ if ((error = git_remote_connect(remote, GIT_DIRECTION_FETCH, cbs, custom_headers)) != 0) return error; error = git_remote_download(remote, refspecs, opts); /* We don't need to be connected anymore */ git_remote_disconnect(remote); /* If the download failed, return the error */ if (error != 0) return error; /* Default reflog message */ if (reflog_message) git_buf_sets(&reflog_msg_buf, reflog_message); else { git_buf_printf(&reflog_msg_buf, "fetch %s", remote->name ? remote->name : remote->url); } /* Create "remote/foo" branches for all remote branches */ error = git_remote_update_tips(remote, cbs, update_fetchhead, tagopt, git_buf_cstr(&reflog_msg_buf)); git_buf_free(&reflog_msg_buf); if (error < 0) return error; if (opts && opts->prune == GIT_FETCH_PRUNE) prune = true; else if (opts && opts->prune == GIT_FETCH_PRUNE_UNSPECIFIED && remote->prune_refs) prune = true; else if (opts && opts->prune == GIT_FETCH_NO_PRUNE) prune = false; else prune = remote->prune_refs; if (prune) error = git_remote_prune(remote, cbs); return error; } static int remote_head_for_fetchspec_src(git_remote_head **out, git_vector *update_heads, const char *fetchspec_src) { unsigned int i; git_remote_head *remote_ref; assert(update_heads && fetchspec_src); *out = NULL; git_vector_foreach(update_heads, i, remote_ref) { if (strcmp(remote_ref->name, fetchspec_src) == 0) { *out = remote_ref; break; } } return 0; } static int ref_to_update(int *update, git_buf *remote_name, git_remote *remote, git_refspec *spec, const char *ref_name) { int error = 0; git_repository *repo; git_buf upstream_remote = GIT_BUF_INIT; git_buf upstream_name = GIT_BUF_INIT; repo = git_remote_owner(remote); if ((!git_reference__is_branch(ref_name)) || !git_remote_name(remote) || (error = git_branch_upstream_remote(&upstream_remote, repo, ref_name) < 0) || git__strcmp(git_remote_name(remote), git_buf_cstr(&upstream_remote)) || (error = git_branch_upstream_name(&upstream_name, repo, ref_name)) < 0 || !git_refspec_dst_matches(spec, git_buf_cstr(&upstream_name)) || (error = git_refspec_rtransform(remote_name, spec, upstream_name.ptr)) < 0) { /* Not an error if there is no upstream */ if (error == GIT_ENOTFOUND) { giterr_clear(); error = 0; } *update = 0; } else { *update = 1; } git_buf_free(&upstream_remote); git_buf_free(&upstream_name); return error; } static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_refspec *spec, git_vector *update_heads, git_reference *ref) { git_reference *resolved_ref = NULL; git_buf remote_name = GIT_BUF_INIT; git_config *config = NULL; const char *ref_name; int error = 0, update; assert(out && spec && ref); *out = NULL; error = git_reference_resolve(&resolved_ref, ref); /* If we're in an unborn branch, let's pretend nothing happened */ if (error == GIT_ENOTFOUND && git_reference_type(ref) == GIT_REF_SYMBOLIC) { ref_name = git_reference_symbolic_target(ref); error = 0; } else { ref_name = git_reference_name(resolved_ref); } if ((error = ref_to_update(&update, &remote_name, remote, spec, ref_name)) < 0) goto cleanup; if (update) error = remote_head_for_fetchspec_src(out, update_heads, git_buf_cstr(&remote_name)); cleanup: git_buf_free(&remote_name); git_reference_free(resolved_ref); git_config_free(config); return error; } static int git_remote_write_fetchhead(git_remote *remote, git_refspec *spec, git_vector *update_heads) { git_reference *head_ref = NULL; git_fetchhead_ref *fetchhead_ref; git_remote_head *remote_ref, *merge_remote_ref; git_vector fetchhead_refs; bool include_all_fetchheads; unsigned int i = 0; int error = 0; assert(remote); /* no heads, nothing to do */ if (update_heads->length == 0) return 0; if (git_vector_init(&fetchhead_refs, update_heads->length, git_fetchhead_ref_cmp) < 0) return -1; /* Iff refspec is * (but not subdir slash star), include tags */ include_all_fetchheads = (strcmp(GIT_REFS_HEADS_DIR "*", git_refspec_src(spec)) == 0); /* Determine what to merge: if refspec was a wildcard, just use HEAD */ if (git_refspec_is_wildcard(spec)) { if ((error = git_reference_lookup(&head_ref, remote->repo, GIT_HEAD_FILE)) < 0 || (error = remote_head_for_ref(&merge_remote_ref, remote, spec, update_heads, head_ref)) < 0) goto cleanup; } else { /* If we're fetching a single refspec, that's the only thing that should be in FETCH_HEAD. */ if ((error = remote_head_for_fetchspec_src(&merge_remote_ref, update_heads, git_refspec_src(spec))) < 0) goto cleanup; } /* Create the FETCH_HEAD file */ git_vector_foreach(update_heads, i, remote_ref) { int merge_this_fetchhead = (merge_remote_ref == remote_ref); if (!include_all_fetchheads && !git_refspec_src_matches(spec, remote_ref->name) && !merge_this_fetchhead) continue; if (git_fetchhead_ref_create(&fetchhead_ref, &remote_ref->oid, merge_this_fetchhead, remote_ref->name, git_remote_url(remote)) < 0) goto cleanup; if (git_vector_insert(&fetchhead_refs, fetchhead_ref) < 0) goto cleanup; } git_fetchhead_write(remote->repo, &fetchhead_refs); cleanup: for (i = 0; i < fetchhead_refs.length; ++i) git_fetchhead_ref_free(fetchhead_refs.contents[i]); git_vector_free(&fetchhead_refs); git_reference_free(head_ref); return error; } /** * Generate a list of candidates for pruning by getting a list of * references which match the rhs of an active refspec. */ static int prune_candidates(git_vector *candidates, git_remote *remote) { git_strarray arr = { 0 }; size_t i; int error; if ((error = git_reference_list(&arr, remote->repo)) < 0) return error; for (i = 0; i < arr.count; i++) { const char *refname = arr.strings[i]; char *refname_dup; if (!git_remote__matching_dst_refspec(remote, refname)) continue; refname_dup = git__strdup(refname); GITERR_CHECK_ALLOC(refname_dup); if ((error = git_vector_insert(candidates, refname_dup)) < 0) goto out; } out: git_strarray_free(&arr); return error; } static int find_head(const void *_a, const void *_b) { git_remote_head *a = (git_remote_head *) _a; git_remote_head *b = (git_remote_head *) _b; return strcmp(a->name, b->name); } int git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks) { size_t i, j; git_vector remote_refs = GIT_VECTOR_INIT; git_vector candidates = GIT_VECTOR_INIT; const git_refspec *spec; const char *refname; int error; git_oid zero_id = {{ 0 }}; if (callbacks) GITERR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks"); if ((error = ls_to_vector(&remote_refs, remote)) < 0) goto cleanup; git_vector_set_cmp(&remote_refs, find_head); if ((error = prune_candidates(&candidates, remote)) < 0) goto cleanup; /* * Remove those entries from the candidate list for which we * can find a remote reference in at least one refspec. */ git_vector_foreach(&candidates, i, refname) { git_vector_foreach(&remote->active_refspecs, j, spec) { git_buf buf = GIT_BUF_INIT; size_t pos; char *src_name; git_remote_head key = {0}; if (!git_refspec_dst_matches(spec, refname)) continue; if ((error = git_refspec_rtransform(&buf, spec, refname)) < 0) goto cleanup; key.name = (char *) git_buf_cstr(&buf); error = git_vector_search(&pos, &remote_refs, &key); git_buf_free(&buf); if (error < 0 && error != GIT_ENOTFOUND) goto cleanup; if (error == GIT_ENOTFOUND) continue; /* if we did find a source, remove it from the candiates */ if ((error = git_vector_set((void **) &src_name, &candidates, i, NULL)) < 0) goto cleanup; git__free(src_name); break; } } /* * For those candidates still left in the list, we need to * remove them. We do not remove symrefs, as those are for * stuff like origin/HEAD which will never match, but we do * not want to remove them. */ git_vector_foreach(&candidates, i, refname) { git_reference *ref; git_oid id; if (refname == NULL) continue; error = git_reference_lookup(&ref, remote->repo, refname); /* as we want it gone, let's not consider this an error */ if (error == GIT_ENOTFOUND) continue; if (error < 0) goto cleanup; if (git_reference_type(ref) == GIT_REF_SYMBOLIC) { git_reference_free(ref); continue; } git_oid_cpy(&id, git_reference_target(ref)); error = git_reference_delete(ref); git_reference_free(ref); if (error < 0) goto cleanup; if (callbacks && callbacks->update_tips) error = callbacks->update_tips(refname, &id, &zero_id, callbacks->payload); if (error < 0) goto cleanup; } cleanup: git_vector_free(&remote_refs); git_vector_free_deep(&candidates); return error; } static int update_tips_for_spec( git_remote *remote, const git_remote_callbacks *callbacks, int update_fetchhead, git_remote_autotag_option_t tagopt, git_refspec *spec, git_vector *refs, const char *log_message) { int error = 0, autotag; unsigned int i = 0; git_buf refname = GIT_BUF_INIT; git_oid old; git_odb *odb; git_remote_head *head; git_reference *ref; git_refspec tagspec; git_vector update_heads; assert(remote); if (git_repository_odb__weakptr(&odb, remote->repo) < 0) return -1; if (git_refspec__parse(&tagspec, GIT_REFSPEC_TAGS, true) < 0) return -1; /* Make a copy of the transport's refs */ if (git_vector_init(&update_heads, 16, NULL) < 0) return -1; for (; i < refs->length; ++i) { head = git_vector_get(refs, i); autotag = 0; git_buf_clear(&refname); /* Ignore malformed ref names (which also saves us from tag^{} */ if (!git_reference_is_valid_name(head->name)) continue; /* If we have a tag, see if the auto-follow rules say to update it */ if (git_refspec_src_matches(&tagspec, head->name)) { if (tagopt != GIT_REMOTE_DOWNLOAD_TAGS_NONE) { if (tagopt == GIT_REMOTE_DOWNLOAD_TAGS_AUTO) autotag = 1; git_buf_clear(&refname); if (git_buf_puts(&refname, head->name) < 0) goto on_error; } } /* If we didn't want to auto-follow the tag, check if the refspec matches */ if (!autotag && git_refspec_src_matches(spec, head->name)) { if (spec->dst) { if (git_refspec_transform(&refname, spec, head->name) < 0) goto on_error; } else { /* * no rhs mans store it in FETCH_HEAD, even if we don't update anything else. */ if ((error = git_vector_insert(&update_heads, head)) < 0) goto on_error; continue; } } /* If we still don't have a refname, we don't want it */ if (git_buf_len(&refname) == 0) { continue; } /* In autotag mode, only create tags for objects already in db */ if (autotag && !git_odb_exists(odb, &head->oid)) continue; if (!autotag && git_vector_insert(&update_heads, head) < 0) goto on_error; error = git_reference_name_to_id(&old, remote->repo, refname.ptr); if (error < 0 && error != GIT_ENOTFOUND) goto on_error; if (error == GIT_ENOTFOUND) { memset(&old, 0, GIT_OID_RAWSZ); if (autotag && git_vector_insert(&update_heads, head) < 0) goto on_error; } if (!git_oid__cmp(&old, &head->oid)) continue; /* In autotag mode, don't overwrite any locally-existing tags */ error = git_reference_create(&ref, remote->repo, refname.ptr, &head->oid, !autotag, log_message); if (error < 0 && error != GIT_EEXISTS) goto on_error; git_reference_free(ref); if (callbacks && callbacks->update_tips != NULL) { if (callbacks->update_tips(refname.ptr, &old, &head->oid, callbacks->payload) < 0) goto on_error; } } if (update_fetchhead && (error = git_remote_write_fetchhead(remote, spec, &update_heads)) < 0) goto on_error; git_vector_free(&update_heads); git_refspec__free(&tagspec); git_buf_free(&refname); return 0; on_error: git_vector_free(&update_heads); git_refspec__free(&tagspec); git_buf_free(&refname); return -1; } /** * Iteration over the three vectors, with a pause whenever we find a match * * On each stop, we store the iteration stat in the inout i,j,k * parameters, and return the currently matching passive refspec as * well as the head which we matched. */ static int next_head(const git_remote *remote, git_vector *refs, git_refspec **out_spec, git_remote_head **out_head, size_t *out_i, size_t *out_j, size_t *out_k) { const git_vector *active, *passive; git_remote_head *head; git_refspec *spec, *passive_spec; size_t i, j, k; active = &remote->active_refspecs; passive = &remote->passive_refspecs; i = *out_i; j = *out_j; k = *out_k; for (; i < refs->length; i++) { head = git_vector_get(refs, i); if (!git_reference_is_valid_name(head->name)) continue; for (; j < active->length; j++) { spec = git_vector_get(active, j); if (!git_refspec_src_matches(spec, head->name)) continue; for (; k < passive->length; k++) { passive_spec = git_vector_get(passive, k); if (!git_refspec_src_matches(passive_spec, head->name)) continue; *out_spec = passive_spec; *out_head = head; *out_i = i; *out_j = j; *out_k = k + 1; return 0; } k = 0; } j = 0; } return GIT_ITEROVER; } static int opportunistic_updates(const git_remote *remote, const git_remote_callbacks *callbacks, git_vector *refs, const char *msg) { size_t i, j, k; git_refspec *spec; git_remote_head *head; git_reference *ref; git_buf refname = GIT_BUF_INIT; int error = 0; i = j = k = 0; while ((error = next_head(remote, refs, &spec, &head, &i, &j, &k)) == 0) { git_oid old = {{ 0 }}; /* * If we got here, there is a refspec which was used * for fetching which matches the source of one of the * passive refspecs, so we should update that * remote-tracking branch, but not add it to * FETCH_HEAD */ git_buf_clear(&refname); if ((error = git_refspec_transform(&refname, spec, head->name)) < 0) goto cleanup; error = git_reference_name_to_id(&old, remote->repo, refname.ptr); if (error < 0 && error != GIT_ENOTFOUND) goto cleanup; if (!git_oid_cmp(&old, &head->oid)) continue; /* If we did find a current reference, make sure we haven't lost a race */ if (error) error = git_reference_create(&ref, remote->repo, refname.ptr, &head->oid, true, msg); else error = git_reference_create_matching(&ref, remote->repo, refname.ptr, &head->oid, true, &old, msg); git_reference_free(ref); if (error < 0) goto cleanup; if (callbacks && callbacks->update_tips != NULL) { if (callbacks->update_tips(refname.ptr, &old, &head->oid, callbacks->payload) < 0) goto cleanup; } } if (error == GIT_ITEROVER) error = 0; cleanup: git_buf_free(&refname); return error; } int git_remote_update_tips( git_remote *remote, const git_remote_callbacks *callbacks, int update_fetchhead, git_remote_autotag_option_t download_tags, const char *reflog_message) { git_refspec *spec, tagspec; git_vector refs = GIT_VECTOR_INIT; git_remote_autotag_option_t tagopt; int error; size_t i; /* push has its own logic hidden away in the push object */ if (remote->push) { return git_push_update_tips(remote->push, callbacks); } if (git_refspec__parse(&tagspec, GIT_REFSPEC_TAGS, true) < 0) return -1; if ((error = ls_to_vector(&refs, remote)) < 0) goto out; if (download_tags == GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED) tagopt = remote->download_tags; else tagopt = download_tags; if (tagopt == GIT_REMOTE_DOWNLOAD_TAGS_ALL) { if ((error = update_tips_for_spec(remote, callbacks, update_fetchhead, tagopt, &tagspec, &refs, reflog_message)) < 0) goto out; } git_vector_foreach(&remote->active_refspecs, i, spec) { if (spec->push) continue; if ((error = update_tips_for_spec(remote, callbacks, update_fetchhead, tagopt, spec, &refs, reflog_message)) < 0) goto out; } /* only try to do opportunisitic updates if the refpec lists differ */ if (remote->passed_refspecs) error = opportunistic_updates(remote, callbacks, &refs, reflog_message); out: git_vector_free(&refs); git_refspec__free(&tagspec); return error; } int git_remote_connected(const git_remote *remote) { assert(remote); if (!remote->transport || !remote->transport->is_connected) return 0; /* Ask the transport if it's connected. */ return remote->transport->is_connected(remote->transport); } void git_remote_stop(git_remote *remote) { assert(remote); if (remote->transport && remote->transport->cancel) remote->transport->cancel(remote->transport); } void git_remote_disconnect(git_remote *remote) { assert(remote); if (git_remote_connected(remote)) remote->transport->close(remote->transport); } void git_remote_free(git_remote *remote) { if (remote == NULL) return; if (remote->transport != NULL) { git_remote_disconnect(remote); remote->transport->free(remote->transport); remote->transport = NULL; } git_vector_free(&remote->refs); free_refspecs(&remote->refspecs); git_vector_free(&remote->refspecs); free_refspecs(&remote->active_refspecs); git_vector_free(&remote->active_refspecs); free_refspecs(&remote->passive_refspecs); git_vector_free(&remote->passive_refspecs); git_push_free(remote->push); git__free(remote->url); git__free(remote->pushurl); git__free(remote->name); git__free(remote); } static int remote_list_cb(const git_config_entry *entry, void *payload) { git_vector *list = payload; const char *name = entry->name + strlen("remote."); size_t namelen = strlen(name); char *remote_name; /* we know name matches "remote..(push)?url" */ if (!strcmp(&name[namelen - 4], ".url")) remote_name = git__strndup(name, namelen - 4); /* strip ".url" */ else remote_name = git__strndup(name, namelen - 8); /* strip ".pushurl" */ GITERR_CHECK_ALLOC(remote_name); return git_vector_insert(list, remote_name); } int git_remote_list(git_strarray *remotes_list, git_repository *repo) { int error; git_config *cfg; git_vector list = GIT_VECTOR_INIT; if ((error = git_repository_config__weakptr(&cfg, repo)) < 0) return error; if ((error = git_vector_init(&list, 4, git__strcmp_cb)) < 0) return error; error = git_config_foreach_match( cfg, "^remote\\..*\\.(push)?url$", remote_list_cb, &list); if (error < 0) { git_vector_free_deep(&list); return error; } git_vector_uniq(&list, git__free); remotes_list->strings = (char **)git_vector_detach(&remotes_list->count, NULL, &list); return 0; } const git_transfer_progress* git_remote_stats(git_remote *remote) { assert(remote); return &remote->stats; } git_remote_autotag_option_t git_remote_autotag(const git_remote *remote) { return remote->download_tags; } int git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_autotag_option_t value) { git_buf var = GIT_BUF_INIT; git_config *config; int error; assert(repo && remote); if ((error = ensure_remote_name_is_valid(remote)) < 0) return error; if ((error = git_repository_config__weakptr(&config, repo)) < 0) return error; if ((error = git_buf_printf(&var, CONFIG_TAGOPT_FMT, remote))) return error; switch (value) { case GIT_REMOTE_DOWNLOAD_TAGS_NONE: error = git_config_set_string(config, var.ptr, "--no-tags"); break; case GIT_REMOTE_DOWNLOAD_TAGS_ALL: error = git_config_set_string(config, var.ptr, "--tags"); break; case GIT_REMOTE_DOWNLOAD_TAGS_AUTO: error = git_config_delete_entry(config, var.ptr); if (error == GIT_ENOTFOUND) error = 0; break; default: giterr_set(GITERR_INVALID, "Invalid value for the tagopt setting"); error = -1; } git_buf_free(&var); return error; } int git_remote_prune_refs(const git_remote *remote) { return remote->prune_refs; } static int rename_remote_config_section( git_repository *repo, const char *old_name, const char *new_name) { git_buf old_section_name = GIT_BUF_INIT, new_section_name = GIT_BUF_INIT; int error = -1; if (git_buf_printf(&old_section_name, "remote.%s", old_name) < 0) goto cleanup; if (new_name && (git_buf_printf(&new_section_name, "remote.%s", new_name) < 0)) goto cleanup; error = git_config_rename_section( repo, git_buf_cstr(&old_section_name), new_name ? git_buf_cstr(&new_section_name) : NULL); cleanup: git_buf_free(&old_section_name); git_buf_free(&new_section_name); return error; } struct update_data { git_config *config; const char *old_remote_name; const char *new_remote_name; }; static int update_config_entries_cb( const git_config_entry *entry, void *payload) { struct update_data *data = (struct update_data *)payload; if (strcmp(entry->value, data->old_remote_name)) return 0; return git_config_set_string( data->config, entry->name, data->new_remote_name); } static int update_branch_remote_config_entry( git_repository *repo, const char *old_name, const char *new_name) { int error; struct update_data data = { NULL }; if ((error = git_repository_config__weakptr(&data.config, repo)) < 0) return error; data.old_remote_name = old_name; data.new_remote_name = new_name; return git_config_foreach_match( data.config, "branch\\..+\\.remote", update_config_entries_cb, &data); } static int rename_one_remote_reference( git_reference *reference_in, const char *old_remote_name, const char *new_remote_name) { int error; git_reference *ref = NULL, *dummy = NULL; git_buf namespace = GIT_BUF_INIT, old_namespace = GIT_BUF_INIT; git_buf new_name = GIT_BUF_INIT; git_buf log_message = GIT_BUF_INIT; size_t pfx_len; const char *target; if ((error = git_buf_printf(&namespace, GIT_REFS_REMOTES_DIR "%s/", new_remote_name)) < 0) return error; pfx_len = strlen(GIT_REFS_REMOTES_DIR) + strlen(old_remote_name) + 1; git_buf_puts(&new_name, namespace.ptr); if ((error = git_buf_puts(&new_name, git_reference_name(reference_in) + pfx_len)) < 0) goto cleanup; if ((error = git_buf_printf(&log_message, "renamed remote %s to %s", old_remote_name, new_remote_name)) < 0) goto cleanup; if ((error = git_reference_rename(&ref, reference_in, git_buf_cstr(&new_name), 1, git_buf_cstr(&log_message))) < 0) goto cleanup; if (git_reference_type(ref) != GIT_REF_SYMBOLIC) goto cleanup; /* Handle refs like origin/HEAD -> origin/master */ target = git_reference_symbolic_target(ref); if ((error = git_buf_printf(&old_namespace, GIT_REFS_REMOTES_DIR "%s/", old_remote_name)) < 0) goto cleanup; if (git__prefixcmp(target, old_namespace.ptr)) goto cleanup; git_buf_clear(&new_name); git_buf_puts(&new_name, namespace.ptr); if ((error = git_buf_puts(&new_name, target + pfx_len)) < 0) goto cleanup; error = git_reference_symbolic_set_target(&dummy, ref, git_buf_cstr(&new_name), git_buf_cstr(&log_message)); git_reference_free(dummy); cleanup: git_reference_free(reference_in); git_reference_free(ref); git_buf_free(&namespace); git_buf_free(&old_namespace); git_buf_free(&new_name); git_buf_free(&log_message); return error; } static int rename_remote_references( git_repository *repo, const char *old_name, const char *new_name) { int error; git_buf buf = GIT_BUF_INIT; git_reference *ref; git_reference_iterator *iter; if ((error = git_buf_printf(&buf, GIT_REFS_REMOTES_DIR "%s/*", old_name)) < 0) return error; error = git_reference_iterator_glob_new(&iter, repo, git_buf_cstr(&buf)); git_buf_free(&buf); if (error < 0) return error; while ((error = git_reference_next(&ref, iter)) == 0) { if ((error = rename_one_remote_reference(ref, old_name, new_name)) < 0) break; } git_reference_iterator_free(iter); return (error == GIT_ITEROVER) ? 0 : error; } static int rename_fetch_refspecs(git_vector *problems, git_remote *remote, const char *new_name) { git_config *config; git_buf base = GIT_BUF_INIT, var = GIT_BUF_INIT, val = GIT_BUF_INIT; const git_refspec *spec; size_t i; int error = 0; if ((error = git_repository_config__weakptr(&config, remote->repo)) < 0) return error; if ((error = git_vector_init(problems, 1, NULL)) < 0) return error; if ((error = git_buf_printf( &base, "+refs/heads/*:refs/remotes/%s/*", remote->name)) < 0) return error; git_vector_foreach(&remote->refspecs, i, spec) { if (spec->push) continue; /* Does the dst part of the refspec follow the expected format? */ if (strcmp(git_buf_cstr(&base), spec->string)) { char *dup; dup = git__strdup(spec->string); GITERR_CHECK_ALLOC(dup); if ((error = git_vector_insert(problems, dup)) < 0) break; continue; } /* If we do want to move it to the new section */ git_buf_clear(&val); git_buf_clear(&var); if (git_buf_printf( &val, "+refs/heads/*:refs/remotes/%s/*", new_name) < 0 || git_buf_printf(&var, "remote.%s.fetch", new_name) < 0) { error = -1; break; } if ((error = git_config_set_string( config, git_buf_cstr(&var), git_buf_cstr(&val))) < 0) break; } git_buf_free(&base); git_buf_free(&var); git_buf_free(&val); if (error < 0) { char *str; git_vector_foreach(problems, i, str) git__free(str); git_vector_free(problems); } return error; } int git_remote_rename(git_strarray *out, git_repository *repo, const char *name, const char *new_name) { int error; git_vector problem_refspecs = GIT_VECTOR_INIT; git_remote *remote = NULL; assert(out && repo && name && new_name); if ((error = git_remote_lookup(&remote, repo, name)) < 0) return error; if ((error = ensure_remote_name_is_valid(new_name)) < 0) goto cleanup; if ((error = ensure_remote_doesnot_exist(repo, new_name)) < 0) goto cleanup; if ((error = rename_remote_config_section(repo, name, new_name)) < 0) goto cleanup; if ((error = update_branch_remote_config_entry(repo, name, new_name)) < 0) goto cleanup; if ((error = rename_remote_references(repo, name, new_name)) < 0) goto cleanup; if ((error = rename_fetch_refspecs(&problem_refspecs, remote, new_name)) < 0) goto cleanup; out->count = problem_refspecs.length; out->strings = (char **) problem_refspecs.contents; cleanup: if (error < 0) git_vector_free(&problem_refspecs); git_remote_free(remote); return error; } int git_remote_is_valid_name( const char *remote_name) { git_buf buf = GIT_BUF_INIT; git_refspec refspec; int error = -1; if (!remote_name || *remote_name == '\0') return 0; git_buf_printf(&buf, "refs/heads/test:refs/remotes/%s/test", remote_name); error = git_refspec__parse(&refspec, git_buf_cstr(&buf), true); git_buf_free(&buf); git_refspec__free(&refspec); giterr_clear(); return error == 0; } git_refspec *git_remote__matching_refspec(git_remote *remote, const char *refname) { git_refspec *spec; size_t i; git_vector_foreach(&remote->active_refspecs, i, spec) { if (spec->push) continue; if (git_refspec_src_matches(spec, refname)) return spec; } return NULL; } git_refspec *git_remote__matching_dst_refspec(git_remote *remote, const char *refname) { git_refspec *spec; size_t i; git_vector_foreach(&remote->active_refspecs, i, spec) { if (spec->push) continue; if (git_refspec_dst_matches(spec, refname)) return spec; } return NULL; } int git_remote_add_fetch(git_repository *repo, const char *remote, const char *refspec) { return write_add_refspec(repo, remote, refspec, true); } int git_remote_add_push(git_repository *repo, const char *remote, const char *refspec) { return write_add_refspec(repo, remote, refspec, false); } static int set_refspecs(git_remote *remote, git_strarray *array, int push) { git_vector *vec = &remote->refspecs; git_refspec *spec; size_t i; /* Start by removing any refspecs of the same type */ for (i = 0; i < vec->length; i++) { spec = git_vector_get(vec, i); if (spec->push != push) continue; git_refspec__free(spec); git__free(spec); git_vector_remove(vec, i); i--; } /* And now we add the new ones */ for (i = 0; i < array->count; i++) { if (add_refspec(remote, array->strings[i], !push) < 0) return -1; } return 0; } static int copy_refspecs(git_strarray *array, const git_remote *remote, unsigned int push) { size_t i; git_vector refspecs; git_refspec *spec; char *dup; if (git_vector_init(&refspecs, remote->refspecs.length, NULL) < 0) return -1; git_vector_foreach(&remote->refspecs, i, spec) { if (spec->push != push) continue; if ((dup = git__strdup(spec->string)) == NULL) goto on_error; if (git_vector_insert(&refspecs, dup) < 0) { git__free(dup); goto on_error; } } array->strings = (char **)refspecs.contents; array->count = refspecs.length; return 0; on_error: git_vector_free_deep(&refspecs); return -1; } int git_remote_get_fetch_refspecs(git_strarray *array, const git_remote *remote) { return copy_refspecs(array, remote, false); } int git_remote_get_push_refspecs(git_strarray *array, const git_remote *remote) { return copy_refspecs(array, remote, true); } size_t git_remote_refspec_count(const git_remote *remote) { return remote->refspecs.length; } const git_refspec *git_remote_get_refspec(const git_remote *remote, size_t n) { return git_vector_get(&remote->refspecs, n); } int git_remote_init_callbacks(git_remote_callbacks *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_remote_callbacks, GIT_REMOTE_CALLBACKS_INIT); return 0; } /* asserts a branch..remote format */ static const char *name_offset(size_t *len_out, const char *name) { size_t prefix_len; const char *dot; prefix_len = strlen("remote."); dot = strchr(name + prefix_len, '.'); assert(dot); *len_out = dot - name - prefix_len; return name + prefix_len; } static int remove_branch_config_related_entries( git_repository *repo, const char *remote_name) { int error; git_config *config; git_config_entry *entry; git_config_iterator *iter; git_buf buf = GIT_BUF_INIT; if ((error = git_repository_config__weakptr(&config, repo)) < 0) return error; if ((error = git_config_iterator_glob_new(&iter, config, "branch\\..+\\.remote")) < 0) return error; /* find any branches with us as upstream and remove that config */ while ((error = git_config_next(&entry, iter)) == 0) { const char *branch; size_t branch_len; if (strcmp(remote_name, entry->value)) continue; branch = name_offset(&branch_len, entry->name); git_buf_clear(&buf); if (git_buf_printf(&buf, "branch.%.*s.merge", (int)branch_len, branch) < 0) break; if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) break; git_buf_clear(&buf); if (git_buf_printf(&buf, "branch.%.*s.remote", (int)branch_len, branch) < 0) break; if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) break; } if (error == GIT_ITEROVER) error = 0; git_buf_free(&buf); git_config_iterator_free(iter); return error; } static int remove_refs(git_repository *repo, const git_refspec *spec) { git_reference_iterator *iter = NULL; git_vector refs; const char *name; char *dup; int error; size_t i; if ((error = git_vector_init(&refs, 8, NULL)) < 0) return error; if ((error = git_reference_iterator_new(&iter, repo)) < 0) goto cleanup; while ((error = git_reference_next_name(&name, iter)) == 0) { if (!git_refspec_dst_matches(spec, name)) continue; dup = git__strdup(name); if (!dup) { error = -1; goto cleanup; } if ((error = git_vector_insert(&refs, dup)) < 0) goto cleanup; } if (error == GIT_ITEROVER) error = 0; if (error < 0) goto cleanup; git_vector_foreach(&refs, i, name) { if ((error = git_reference_remove(repo, name)) < 0) break; } cleanup: git_reference_iterator_free(iter); git_vector_foreach(&refs, i, dup) { git__free(dup); } git_vector_free(&refs); return error; } static int remove_remote_tracking(git_repository *repo, const char *remote_name) { git_remote *remote; int error; size_t i, count; /* we want to use what's on the config, regardless of changes to the instance in memory */ if ((error = git_remote_lookup(&remote, repo, remote_name)) < 0) return error; count = git_remote_refspec_count(remote); for (i = 0; i < count; i++) { const git_refspec *refspec = git_remote_get_refspec(remote, i); /* shouldn't ever actually happen */ if (refspec == NULL) continue; if ((error = remove_refs(repo, refspec)) < 0) break; } git_remote_free(remote); return error; } int git_remote_delete(git_repository *repo, const char *name) { int error; assert(repo && name); if ((error = remove_branch_config_related_entries(repo, name)) < 0 || (error = remove_remote_tracking(repo, name)) < 0 || (error = rename_remote_config_section(repo, name, NULL)) < 0) return error; return 0; } int git_remote_default_branch(git_buf *out, git_remote *remote) { const git_remote_head **heads; const git_remote_head *guess = NULL; const git_oid *head_id; size_t heads_len, i; int error; assert(out); if ((error = git_remote_ls(&heads, &heads_len, remote)) < 0) return error; if (heads_len == 0) return GIT_ENOTFOUND; if (strcmp(heads[0]->name, GIT_HEAD_FILE)) return GIT_ENOTFOUND; git_buf_sanitize(out); /* the first one must be HEAD so if that has the symref info, we're done */ if (heads[0]->symref_target) return git_buf_puts(out, heads[0]->symref_target); /* * If there's no symref information, we have to look over them * and guess. We return the first match unless the master * branch is a candidate. Then we return the master branch. */ head_id = &heads[0]->oid; for (i = 1; i < heads_len; i++) { if (git_oid_cmp(head_id, &heads[i]->oid)) continue; if (git__prefixcmp(heads[i]->name, GIT_REFS_HEADS_DIR)) continue; if (!guess) { guess = heads[i]; continue; } if (!git__strcmp(GIT_REFS_HEADS_MASTER_FILE, heads[i]->name)) { guess = heads[i]; break; } } if (!guess) return GIT_ENOTFOUND; return git_buf_puts(out, guess->name); } int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const git_push_options *opts) { size_t i; int error; git_push *push; git_refspec *spec; const git_remote_callbacks *cbs = NULL; const git_strarray *custom_headers = NULL; assert(remote); if (opts) { cbs = &opts->callbacks; custom_headers = &opts->custom_headers; } if (!git_remote_connected(remote) && (error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, custom_headers)) < 0) goto cleanup; free_refspecs(&remote->active_refspecs); if ((error = dwim_refspecs(&remote->active_refspecs, &remote->refspecs, &remote->refs)) < 0) goto cleanup; if (remote->push) { git_push_free(remote->push); remote->push = NULL; } if ((error = git_push_new(&remote->push, remote)) < 0) return error; push = remote->push; if (opts && (error = git_push_set_options(push, opts)) < 0) goto cleanup; if (refspecs && refspecs->count > 0) { for (i = 0; i < refspecs->count; i++) { if ((error = git_push_add_refspec(push, refspecs->strings[i])) < 0) goto cleanup; } } else { git_vector_foreach(&remote->refspecs, i, spec) { if (!spec->push) continue; if ((error = git_push_add_refspec(push, spec->string)) < 0) goto cleanup; } } if ((error = git_push_finish(push, cbs)) < 0) goto cleanup; if (cbs && cbs->push_update_reference && (error = git_push_status_foreach(push, cbs->push_update_reference, cbs->payload)) < 0) goto cleanup; cleanup: return error; } int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_push_options *opts) { int error; const git_remote_callbacks *cbs = NULL; const git_strarray *custom_headers = NULL; if (opts) { GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks"); cbs = &opts->callbacks; custom_headers = &opts->custom_headers; } assert(remote && refspecs); if ((error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, custom_headers)) < 0) return error; if ((error = git_remote_upload(remote, refspecs, opts)) < 0) return error; error = git_remote_update_tips(remote, cbs, 0, 0, NULL); git_remote_disconnect(remote); return error; } #define PREFIX "url" #define SUFFIX_FETCH "insteadof" #define SUFFIX_PUSH "pushinsteadof" char *apply_insteadof(git_config *config, const char *url, int direction) { size_t match_length, prefix_length, suffix_length; char *replacement = NULL; const char *regexp; git_buf result = GIT_BUF_INIT; git_config_entry *entry; git_config_iterator *iter; assert(config); assert(url); assert(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH); /* Add 1 to prefix/suffix length due to the additional escaped dot */ prefix_length = strlen(PREFIX) + 1; if (direction == GIT_DIRECTION_FETCH) { regexp = PREFIX "\\..*\\." SUFFIX_FETCH; suffix_length = strlen(SUFFIX_FETCH) + 1; } else { regexp = PREFIX "\\..*\\." SUFFIX_PUSH; suffix_length = strlen(SUFFIX_PUSH) + 1; } if (git_config_iterator_glob_new(&iter, config, regexp) < 0) return NULL; match_length = 0; while (git_config_next(&entry, iter) == 0) { size_t n, replacement_length; /* Check if entry value is a prefix of URL */ if (git__prefixcmp(url, entry->value)) continue; /* Check if entry value is longer than previous * prefixes */ if ((n = strlen(entry->value)) <= match_length) continue; git__free(replacement); match_length = n; /* Cut off prefix and suffix of the value */ replacement_length = strlen(entry->name) - (prefix_length + suffix_length); replacement = git__strndup(entry->name + prefix_length, replacement_length); } git_config_iterator_free(iter); if (match_length == 0) return git__strdup(url); git_buf_printf(&result, "%s%s", replacement, url + match_length); git__free(replacement); return result.ptr; } deps/libgit2-sys-0.3.8/libgit2/src/global.h0000664000175000017500000000146612572105236015315 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_global_h__ #define INCLUDE_global_h__ #include "common.h" #include "mwindow.h" #include "hash.h" typedef struct { git_error *last_error; git_error error_t; git_buf error_buf; char oid_fmt[GIT_OID_HEXSZ+1]; } git_global_st; #ifdef GIT_OPENSSL # include extern SSL_CTX *git__ssl_ctx; #endif git_global_st *git__global_state(void); extern git_mutex git__mwindow_mutex; #define GIT_GLOBAL (git__global_state()) typedef void (*git_global_shutdown_fn)(void); extern void git__on_shutdown(git_global_shutdown_fn callback); extern void git__free_tls_data(void); #endif deps/libgit2-sys-0.3.8/libgit2/src/refdb_fs.c0000664000175000017500000013635212610310643015616 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "refs.h" #include "hash.h" #include "repository.h" #include "fileops.h" #include "filebuf.h" #include "pack.h" #include "reflog.h" #include "refdb.h" #include "refdb_fs.h" #include "iterator.h" #include "sortedcache.h" #include "signature.h" #include #include #include #include #include #include #include GIT__USE_STRMAP #define DEFAULT_NESTING_LEVEL 5 #define MAX_NESTING_LEVEL 10 enum { PACKREF_HAS_PEEL = 1, PACKREF_WAS_LOOSE = 2, PACKREF_CANNOT_PEEL = 4, PACKREF_SHADOWED = 8, }; enum { PEELING_NONE = 0, PEELING_STANDARD, PEELING_FULL }; struct packref { git_oid oid; git_oid peel; char flags; char name[GIT_FLEX_ARRAY]; }; typedef struct refdb_fs_backend { git_refdb_backend parent; git_repository *repo; char *path; git_sortedcache *refcache; int peeling_mode; git_iterator_flag_t iterator_flags; uint32_t direach_flags; } refdb_fs_backend; static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name); static int packref_cmp(const void *a_, const void *b_) { const struct packref *a = a_, *b = b_; return strcmp(a->name, b->name); } static int packed_reload(refdb_fs_backend *backend) { int error; git_buf packedrefs = GIT_BUF_INIT; char *scan, *eof, *eol; if (!backend->path) return 0; error = git_sortedcache_lockandload(backend->refcache, &packedrefs); /* * If we can't find the packed-refs, clear table and return. * Any other error just gets passed through. * If no error, and file wasn't changed, just return. * Anything else means we need to refresh the packed refs. */ if (error <= 0) { if (error == GIT_ENOTFOUND) { git_sortedcache_clear(backend->refcache, true); giterr_clear(); error = 0; } return error; } /* At this point, refresh the packed refs from the loaded buffer. */ git_sortedcache_clear(backend->refcache, false); scan = (char *)packedrefs.ptr; eof = scan + packedrefs.size; backend->peeling_mode = PEELING_NONE; if (*scan == '#') { static const char *traits_header = "# pack-refs with: "; if (git__prefixcmp(scan, traits_header) == 0) { scan += strlen(traits_header); eol = strchr(scan, '\n'); if (!eol) goto parse_failed; *eol = '\0'; if (strstr(scan, " fully-peeled ") != NULL) { backend->peeling_mode = PEELING_FULL; } else if (strstr(scan, " peeled ") != NULL) { backend->peeling_mode = PEELING_STANDARD; } scan = eol + 1; } } while (scan < eof && *scan == '#') { if (!(eol = strchr(scan, '\n'))) goto parse_failed; scan = eol + 1; } while (scan < eof) { struct packref *ref; git_oid oid; /* parse " \n" */ if (git_oid_fromstr(&oid, scan) < 0) goto parse_failed; scan += GIT_OID_HEXSZ; if (*scan++ != ' ') goto parse_failed; if (!(eol = strchr(scan, '\n'))) goto parse_failed; *eol = '\0'; if (eol[-1] == '\r') eol[-1] = '\0'; if (git_sortedcache_upsert((void **)&ref, backend->refcache, scan) < 0) goto parse_failed; scan = eol + 1; git_oid_cpy(&ref->oid, &oid); /* look for optional "^\n" */ if (*scan == '^') { if (git_oid_fromstr(&oid, scan + 1) < 0) goto parse_failed; scan += GIT_OID_HEXSZ + 1; if (scan < eof) { if (!(eol = strchr(scan, '\n'))) goto parse_failed; scan = eol + 1; } git_oid_cpy(&ref->peel, &oid); ref->flags |= PACKREF_HAS_PEEL; } else if (backend->peeling_mode == PEELING_FULL || (backend->peeling_mode == PEELING_STANDARD && git__prefixcmp(ref->name, GIT_REFS_TAGS_DIR) == 0)) ref->flags |= PACKREF_CANNOT_PEEL; } git_sortedcache_wunlock(backend->refcache); git_buf_free(&packedrefs); return 0; parse_failed: giterr_set(GITERR_REFERENCE, "Corrupted packed references file"); git_sortedcache_clear(backend->refcache, false); git_sortedcache_wunlock(backend->refcache); git_buf_free(&packedrefs); return -1; } static int loose_parse_oid( git_oid *oid, const char *filename, git_buf *file_content) { const char *str = git_buf_cstr(file_content); if (git_buf_len(file_content) < GIT_OID_HEXSZ) goto corrupted; /* we need to get 40 OID characters from the file */ if (git_oid_fromstr(oid, str) < 0) goto corrupted; /* If the file is longer than 40 chars, the 41st must be a space */ str += GIT_OID_HEXSZ; if (*str == '\0' || git__isspace(*str)) return 0; corrupted: giterr_set(GITERR_REFERENCE, "Corrupted loose reference file: %s", filename); return -1; } static int loose_readbuffer(git_buf *buf, const char *base, const char *path) { int error; /* build full path to file */ if ((error = git_buf_joinpath(buf, base, path)) < 0 || (error = git_futils_readbuffer(buf, buf->ptr)) < 0) git_buf_free(buf); return error; } static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name) { int error = 0; git_buf ref_file = GIT_BUF_INIT; struct packref *ref = NULL; git_oid oid; /* if we fail to load the loose reference, assume someone changed * the filesystem under us and skip it... */ if (loose_readbuffer(&ref_file, backend->path, name) < 0) { giterr_clear(); goto done; } /* skip symbolic refs */ if (!git__prefixcmp(git_buf_cstr(&ref_file), GIT_SYMREF)) goto done; /* parse OID from file */ if ((error = loose_parse_oid(&oid, name, &ref_file)) < 0) goto done; git_sortedcache_wlock(backend->refcache); if (!(error = git_sortedcache_upsert( (void **)&ref, backend->refcache, name))) { git_oid_cpy(&ref->oid, &oid); ref->flags = PACKREF_WAS_LOOSE; } git_sortedcache_wunlock(backend->refcache); done: git_buf_free(&ref_file); return error; } static int _dirent_loose_load(void *payload, git_buf *full_path) { refdb_fs_backend *backend = payload; const char *file_path; if (git__suffixcmp(full_path->ptr, ".lock") == 0) return 0; if (git_path_isdir(full_path->ptr)) { int error = git_path_direach( full_path, backend->direach_flags, _dirent_loose_load, backend); /* Race with the filesystem, ignore it */ if (error == GIT_ENOTFOUND) { giterr_clear(); return 0; } return error; } file_path = full_path->ptr + strlen(backend->path); return loose_lookup_to_packfile(backend, file_path); } /* * Load all the loose references from the repository * into the in-memory Packfile, and build a vector with * all the references so it can be written back to * disk. */ static int packed_loadloose(refdb_fs_backend *backend) { int error; git_buf refs_path = GIT_BUF_INIT; if (git_buf_joinpath(&refs_path, backend->path, GIT_REFS_DIR) < 0) return -1; /* * Load all the loose files from disk into the Packfile table. * This will overwrite any old packed entries with their * updated loose versions */ error = git_path_direach( &refs_path, backend->direach_flags, _dirent_loose_load, backend); git_buf_free(&refs_path); return error; } static int refdb_fs_backend__exists( int *exists, git_refdb_backend *_backend, const char *ref_name) { refdb_fs_backend *backend = (refdb_fs_backend *)_backend; git_buf ref_path = GIT_BUF_INIT; assert(backend); if (packed_reload(backend) < 0 || git_buf_joinpath(&ref_path, backend->path, ref_name) < 0) return -1; *exists = git_path_isfile(ref_path.ptr) || (git_sortedcache_lookup(backend->refcache, ref_name) != NULL); git_buf_free(&ref_path); return 0; } static const char *loose_parse_symbolic(git_buf *file_content) { const unsigned int header_len = (unsigned int)strlen(GIT_SYMREF); const char *refname_start; refname_start = (const char *)file_content->ptr; if (git_buf_len(file_content) < header_len + 1) { giterr_set(GITERR_REFERENCE, "Corrupted loose reference file"); return NULL; } /* * Assume we have already checked for the header * before calling this function */ refname_start += header_len; return refname_start; } static int loose_lookup( git_reference **out, refdb_fs_backend *backend, const char *ref_name) { git_buf ref_file = GIT_BUF_INIT; int error = 0; if (out) *out = NULL; if ((error = loose_readbuffer(&ref_file, backend->path, ref_name)) < 0) /* cannot read loose ref file - gah */; else if (git__prefixcmp(git_buf_cstr(&ref_file), GIT_SYMREF) == 0) { const char *target; git_buf_rtrim(&ref_file); if (!(target = loose_parse_symbolic(&ref_file))) error = -1; else if (out != NULL) *out = git_reference__alloc_symbolic(ref_name, target); } else { git_oid oid; if (!(error = loose_parse_oid(&oid, ref_name, &ref_file)) && out != NULL) *out = git_reference__alloc(ref_name, &oid, NULL); } git_buf_free(&ref_file); return error; } static int ref_error_notfound(const char *name) { giterr_set(GITERR_REFERENCE, "Reference '%s' not found", name); return GIT_ENOTFOUND; } static int packed_lookup( git_reference **out, refdb_fs_backend *backend, const char *ref_name) { int error = 0; struct packref *entry; if (packed_reload(backend) < 0) return -1; if (git_sortedcache_rlock(backend->refcache) < 0) return -1; entry = git_sortedcache_lookup(backend->refcache, ref_name); if (!entry) { error = ref_error_notfound(ref_name); } else { *out = git_reference__alloc(ref_name, &entry->oid, &entry->peel); if (!*out) error = -1; } git_sortedcache_runlock(backend->refcache); return error; } static int refdb_fs_backend__lookup( git_reference **out, git_refdb_backend *_backend, const char *ref_name) { refdb_fs_backend *backend = (refdb_fs_backend *)_backend; int error; assert(backend); if (!(error = loose_lookup(out, backend, ref_name))) return 0; /* only try to lookup this reference on the packfile if it * wasn't found on the loose refs; not if there was a critical error */ if (error == GIT_ENOTFOUND) { giterr_clear(); error = packed_lookup(out, backend, ref_name); } return error; } typedef struct { git_reference_iterator parent; char *glob; git_pool pool; git_vector loose; git_sortedcache *cache; size_t loose_pos; size_t packed_pos; } refdb_fs_iter; static void refdb_fs_backend__iterator_free(git_reference_iterator *_iter) { refdb_fs_iter *iter = (refdb_fs_iter *) _iter; git_vector_free(&iter->loose); git_pool_clear(&iter->pool); git_sortedcache_free(iter->cache); git__free(iter); } static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter) { int error = 0; git_buf path = GIT_BUF_INIT; git_iterator *fsit = NULL; git_iterator_options fsit_opts = GIT_ITERATOR_OPTIONS_INIT; const git_index_entry *entry = NULL; if (!backend->path) /* do nothing if no path for loose refs */ return 0; fsit_opts.flags = backend->iterator_flags; if ((error = git_buf_printf(&path, "%s/refs", backend->path)) < 0 || (error = git_iterator_for_filesystem(&fsit, path.ptr, &fsit_opts)) < 0) { git_buf_free(&path); return error; } error = git_buf_sets(&path, GIT_REFS_DIR); while (!error && !git_iterator_advance(&entry, fsit)) { const char *ref_name; struct packref *ref; char *ref_dup; git_buf_truncate(&path, strlen(GIT_REFS_DIR)); git_buf_puts(&path, entry->path); ref_name = git_buf_cstr(&path); if (git__suffixcmp(ref_name, ".lock") == 0 || (iter->glob && p_fnmatch(iter->glob, ref_name, 0) != 0)) continue; git_sortedcache_rlock(backend->refcache); ref = git_sortedcache_lookup(backend->refcache, ref_name); if (ref) ref->flags |= PACKREF_SHADOWED; git_sortedcache_runlock(backend->refcache); ref_dup = git_pool_strdup(&iter->pool, ref_name); if (!ref_dup) error = -1; else error = git_vector_insert(&iter->loose, ref_dup); } git_iterator_free(fsit); git_buf_free(&path); return error; } static int refdb_fs_backend__iterator_next( git_reference **out, git_reference_iterator *_iter) { int error = GIT_ITEROVER; refdb_fs_iter *iter = (refdb_fs_iter *)_iter; refdb_fs_backend *backend = (refdb_fs_backend *)iter->parent.db->backend; struct packref *ref; while (iter->loose_pos < iter->loose.length) { const char *path = git_vector_get(&iter->loose, iter->loose_pos++); if (loose_lookup(out, backend, path) == 0) return 0; giterr_clear(); } if (!iter->cache) { if ((error = git_sortedcache_copy(&iter->cache, backend->refcache, 1, NULL, NULL)) < 0) return error; } error = GIT_ITEROVER; while (iter->packed_pos < git_sortedcache_entrycount(iter->cache)) { ref = git_sortedcache_entry(iter->cache, iter->packed_pos++); if (!ref) /* stop now if another thread deleted refs and we past end */ break; if (ref->flags & PACKREF_SHADOWED) continue; if (iter->glob && p_fnmatch(iter->glob, ref->name, 0) != 0) continue; *out = git_reference__alloc(ref->name, &ref->oid, &ref->peel); error = (*out != NULL) ? 0 : -1; break; } return error; } static int refdb_fs_backend__iterator_next_name( const char **out, git_reference_iterator *_iter) { int error = GIT_ITEROVER; refdb_fs_iter *iter = (refdb_fs_iter *)_iter; refdb_fs_backend *backend = (refdb_fs_backend *)iter->parent.db->backend; struct packref *ref; while (iter->loose_pos < iter->loose.length) { const char *path = git_vector_get(&iter->loose, iter->loose_pos++); if (loose_lookup(NULL, backend, path) == 0) { *out = path; return 0; } giterr_clear(); } if (!iter->cache) { if ((error = git_sortedcache_copy(&iter->cache, backend->refcache, 1, NULL, NULL)) < 0) return error; } error = GIT_ITEROVER; while (iter->packed_pos < git_sortedcache_entrycount(iter->cache)) { ref = git_sortedcache_entry(iter->cache, iter->packed_pos++); if (!ref) /* stop now if another thread deleted refs and we past end */ break; if (ref->flags & PACKREF_SHADOWED) continue; if (iter->glob && p_fnmatch(iter->glob, ref->name, 0) != 0) continue; *out = ref->name; error = 0; break; } return error; } static int refdb_fs_backend__iterator( git_reference_iterator **out, git_refdb_backend *_backend, const char *glob) { refdb_fs_iter *iter; refdb_fs_backend *backend = (refdb_fs_backend *)_backend; assert(backend); if (packed_reload(backend) < 0) return -1; iter = git__calloc(1, sizeof(refdb_fs_iter)); GITERR_CHECK_ALLOC(iter); if (git_pool_init(&iter->pool, 1, 0) < 0 || git_vector_init(&iter->loose, 8, NULL) < 0) goto fail; if (glob != NULL && (iter->glob = git_pool_strdup(&iter->pool, glob)) == NULL) goto fail; iter->parent.next = refdb_fs_backend__iterator_next; iter->parent.next_name = refdb_fs_backend__iterator_next_name; iter->parent.free = refdb_fs_backend__iterator_free; if (iter_load_loose_paths(backend, iter) < 0) goto fail; *out = (git_reference_iterator *)iter; return 0; fail: refdb_fs_backend__iterator_free((git_reference_iterator *)iter); return -1; } static bool ref_is_available( const char *old_ref, const char *new_ref, const char *this_ref) { if (old_ref == NULL || strcmp(old_ref, this_ref)) { size_t reflen = strlen(this_ref); size_t newlen = strlen(new_ref); size_t cmplen = reflen < newlen ? reflen : newlen; const char *lead = reflen < newlen ? new_ref : this_ref; if (!strncmp(new_ref, this_ref, cmplen) && lead[cmplen] == '/') { return false; } } return true; } static int reference_path_available( refdb_fs_backend *backend, const char *new_ref, const char* old_ref, int force) { size_t i; if (packed_reload(backend) < 0) return -1; if (!force) { int exists; if (refdb_fs_backend__exists( &exists, (git_refdb_backend *)backend, new_ref) < 0) return -1; if (exists) { giterr_set(GITERR_REFERENCE, "Failed to write reference '%s': a reference with " "that name already exists.", new_ref); return GIT_EEXISTS; } } git_sortedcache_rlock(backend->refcache); for (i = 0; i < git_sortedcache_entrycount(backend->refcache); ++i) { struct packref *ref = git_sortedcache_entry(backend->refcache, i); if (ref && !ref_is_available(old_ref, new_ref, ref->name)) { git_sortedcache_runlock(backend->refcache); giterr_set(GITERR_REFERENCE, "Path to reference '%s' collides with existing one", new_ref); return -1; } } git_sortedcache_runlock(backend->refcache); return 0; } static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *name) { int error; git_buf ref_path = GIT_BUF_INIT; assert(file && backend && name); if (!git_path_isvalid(backend->repo, name, GIT_PATH_REJECT_DEFAULTS)) { giterr_set(GITERR_INVALID, "Invalid reference name '%s'.", name); return GIT_EINVALIDSPEC; } /* Remove a possibly existing empty directory hierarchy * which name would collide with the reference name */ if (git_futils_rmdir_r(name, backend->path, GIT_RMDIR_SKIP_NONEMPTY) < 0) return -1; if (git_buf_joinpath(&ref_path, backend->path, name) < 0) return -1; error = git_filebuf_open(file, ref_path.ptr, GIT_FILEBUF_FORCE, GIT_REFS_FILE_MODE); git_buf_free(&ref_path); return error; } static int loose_commit(git_filebuf *file, const git_reference *ref) { assert(file && ref); if (ref->type == GIT_REF_OID) { char oid[GIT_OID_HEXSZ + 1]; git_oid_nfmt(oid, sizeof(oid), &ref->target.oid); git_filebuf_printf(file, "%s\n", oid); } else if (ref->type == GIT_REF_SYMBOLIC) { git_filebuf_printf(file, GIT_SYMREF "%s\n", ref->target.symbolic); } else { assert(0); /* don't let this happen */ } return git_filebuf_commit(file); } static int refdb_fs_backend__lock(void **out, git_refdb_backend *_backend, const char *refname) { int error; git_filebuf *lock; refdb_fs_backend *backend = (refdb_fs_backend *) _backend; lock = git__calloc(1, sizeof(git_filebuf)); GITERR_CHECK_ALLOC(lock); if ((error = loose_lock(lock, backend, refname)) < 0) { git__free(lock); return error; } *out = lock; return 0; } static int refdb_fs_backend__write_tail( git_refdb_backend *_backend, const git_reference *ref, git_filebuf *file, int update_reflog, const git_signature *who, const char *message, const git_oid *old_id, const char *old_target); static int refdb_fs_backend__delete_tail( git_refdb_backend *_backend, git_filebuf *file, const char *ref_name, const git_oid *old_id, const char *old_target); static int refdb_fs_backend__unlock(git_refdb_backend *backend, void *payload, int success, int update_reflog, const git_reference *ref, const git_signature *sig, const char *message) { git_filebuf *lock = (git_filebuf *) payload; int error = 0; if (success == 2) error = refdb_fs_backend__delete_tail(backend, lock, ref->name, NULL, NULL); else if (success) error = refdb_fs_backend__write_tail(backend, ref, lock, update_reflog, sig, message, NULL, NULL); else git_filebuf_cleanup(lock); git__free(lock); return error; } /* * Find out what object this reference resolves to. * * For references that point to a 'big' tag (e.g. an * actual tag object on the repository), we need to * cache on the packfile the OID of the object to * which that 'big tag' is pointing to. */ static int packed_find_peel(refdb_fs_backend *backend, struct packref *ref) { git_object *object; if (ref->flags & PACKREF_HAS_PEEL || ref->flags & PACKREF_CANNOT_PEEL) return 0; /* * Find the tagged object in the repository */ if (git_object_lookup(&object, backend->repo, &ref->oid, GIT_OBJ_ANY) < 0) return -1; /* * If the tagged object is a Tag object, we need to resolve it; * if the ref is actually a 'weak' ref, we don't need to resolve * anything. */ if (git_object_type(object) == GIT_OBJ_TAG) { git_tag *tag = (git_tag *)object; /* * Find the object pointed at by this tag */ git_oid_cpy(&ref->peel, git_tag_target_id(tag)); ref->flags |= PACKREF_HAS_PEEL; /* * The reference has now cached the resolved OID, and is * marked at such. When written to the packfile, it'll be * accompanied by this resolved oid */ } git_object_free(object); return 0; } /* * Write a single reference into a packfile */ static int packed_write_ref(struct packref *ref, git_filebuf *file) { char oid[GIT_OID_HEXSZ + 1]; git_oid_nfmt(oid, sizeof(oid), &ref->oid); /* * For references that peel to an object in the repo, we must * write the resulting peel on a separate line, e.g. * * 6fa8a902cc1d18527e1355773c86721945475d37 refs/tags/libgit2-0.4 * ^2ec0cb7959b0bf965d54f95453f5b4b34e8d3100 * * This obviously only applies to tags. * The required peels have already been loaded into `ref->peel_target`. */ if (ref->flags & PACKREF_HAS_PEEL) { char peel[GIT_OID_HEXSZ + 1]; git_oid_nfmt(peel, sizeof(peel), &ref->peel); if (git_filebuf_printf(file, "%s %s\n^%s\n", oid, ref->name, peel) < 0) return -1; } else { if (git_filebuf_printf(file, "%s %s\n", oid, ref->name) < 0) return -1; } return 0; } /* * Remove all loose references * * Once we have successfully written a packfile, * all the loose references that were packed must be * removed from disk. * * This is a dangerous method; make sure the packfile * is well-written, because we are destructing references * here otherwise. */ static int packed_remove_loose(refdb_fs_backend *backend) { size_t i; git_buf full_path = GIT_BUF_INIT; int failed = 0; /* backend->refcache is already locked when this is called */ for (i = 0; i < git_sortedcache_entrycount(backend->refcache); ++i) { struct packref *ref = git_sortedcache_entry(backend->refcache, i); if (!ref || !(ref->flags & PACKREF_WAS_LOOSE)) continue; if (git_buf_joinpath(&full_path, backend->path, ref->name) < 0) return -1; /* critical; do not try to recover on oom */ if (git_path_exists(full_path.ptr) && p_unlink(full_path.ptr) < 0) { if (failed) continue; giterr_set(GITERR_REFERENCE, "Failed to remove loose reference '%s' after packing: %s", full_path.ptr, strerror(errno)); failed = 1; } /* * if we fail to remove a single file, this is *not* good, * but we should keep going and remove as many as possible. * After we've removed as many files as possible, we return * the error code anyway. */ } git_buf_free(&full_path); return failed ? -1 : 0; } /* * Write all the contents in the in-memory packfile to disk. */ static int packed_write(refdb_fs_backend *backend) { git_sortedcache *refcache = backend->refcache; git_filebuf pack_file = GIT_FILEBUF_INIT; size_t i; /* lock the cache to updates while we do this */ if (git_sortedcache_wlock(refcache) < 0) return -1; /* Open the file! */ if (git_filebuf_open(&pack_file, git_sortedcache_path(refcache), 0, GIT_PACKEDREFS_FILE_MODE) < 0) goto fail; /* Packfiles have a header... apparently * This is in fact not required, but we might as well print it * just for kicks */ if (git_filebuf_printf(&pack_file, "%s\n", GIT_PACKEDREFS_HEADER) < 0) goto fail; for (i = 0; i < git_sortedcache_entrycount(refcache); ++i) { struct packref *ref = git_sortedcache_entry(refcache, i); if (packed_find_peel(backend, ref) < 0) goto fail; if (packed_write_ref(ref, &pack_file) < 0) goto fail; } /* if we've written all the references properly, we can commit * the packfile to make the changes effective */ if (git_filebuf_commit(&pack_file) < 0) goto fail; /* when and only when the packfile has been properly written, * we can go ahead and remove the loose refs */ if (packed_remove_loose(backend) < 0) goto fail; git_sortedcache_updated(refcache); git_sortedcache_wunlock(refcache); /* we're good now */ return 0; fail: git_filebuf_cleanup(&pack_file); git_sortedcache_wunlock(refcache); return -1; } static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, const git_oid *old, const git_oid *new, const git_signature *author, const char *message); static int has_reflog(git_repository *repo, const char *name); /* We only write if it's under heads/, remotes/ or notes/ or if it already has a log */ static int should_write_reflog(int *write, git_repository *repo, const char *name) { int error, logall; error = git_repository__cvar(&logall, repo, GIT_CVAR_LOGALLREFUPDATES); if (error < 0) return error; /* Defaults to the opposite of the repo being bare */ if (logall == GIT_LOGALLREFUPDATES_UNSET) logall = !git_repository_is_bare(repo); if (!logall) { *write = 0; } else if (has_reflog(repo, name)) { *write = 1; } else if (!git__prefixcmp(name, GIT_REFS_HEADS_DIR) || !git__strcmp(name, GIT_HEAD_FILE) || !git__prefixcmp(name, GIT_REFS_REMOTES_DIR) || !git__prefixcmp(name, GIT_REFS_NOTES_DIR)) { *write = 1; } else { *write = 0; } return 0; } static int cmp_old_ref(int *cmp, git_refdb_backend *backend, const char *name, const git_oid *old_id, const char *old_target) { int error = 0; git_reference *old_ref = NULL; *cmp = 0; /* It "matches" if there is no old value to compare against */ if (!old_id && !old_target) return 0; if ((error = refdb_fs_backend__lookup(&old_ref, backend, name)) < 0) goto out; /* If the types don't match, there's no way the values do */ if (old_id && old_ref->type != GIT_REF_OID) { *cmp = -1; goto out; } if (old_target && old_ref->type != GIT_REF_SYMBOLIC) { *cmp = 1; goto out; } if (old_id && old_ref->type == GIT_REF_OID) *cmp = git_oid_cmp(old_id, &old_ref->target.oid); if (old_target && old_ref->type == GIT_REF_SYMBOLIC) *cmp = git__strcmp(old_target, old_ref->target.symbolic); out: git_reference_free(old_ref); return error; } /* * The git.git comment regarding this, for your viewing pleasure: * * Special hack: If a branch is updated directly and HEAD * points to it (may happen on the remote side of a push * for example) then logically the HEAD reflog should be * updated too. * A generic solution implies reverse symref information, * but finding all symrefs pointing to the given branch * would be rather costly for this rare event (the direct * update of a branch) to be worth it. So let's cheat and * check with HEAD only which should cover 99% of all usage * scenarios (even 100% of the default ones). */ static int maybe_append_head(refdb_fs_backend *backend, const git_reference *ref, const git_signature *who, const char *message) { int error; git_oid old_id = {{0}}; git_reference *tmp = NULL, *head = NULL, *peeled = NULL; const char *name; if (ref->type == GIT_REF_SYMBOLIC) return 0; /* if we can't resolve, we use {0}*40 as old id */ git_reference_name_to_id(&old_id, backend->repo, ref->name); if ((error = git_reference_lookup(&head, backend->repo, GIT_HEAD_FILE)) < 0) return error; if (git_reference_type(head) == GIT_REF_OID) goto cleanup; if ((error = git_reference_lookup(&tmp, backend->repo, GIT_HEAD_FILE)) < 0) goto cleanup; /* Go down the symref chain until we find the branch */ while (git_reference_type(tmp) == GIT_REF_SYMBOLIC) { error = git_reference_lookup(&peeled, backend->repo, git_reference_symbolic_target(tmp)); if (error < 0) break; git_reference_free(tmp); tmp = peeled; } if (error == GIT_ENOTFOUND) { error = 0; name = git_reference_symbolic_target(tmp); } else if (error < 0) { goto cleanup; } else { name = git_reference_name(tmp); } if (strcmp(name, ref->name)) goto cleanup; error = reflog_append(backend, head, &old_id, git_reference_target(ref), who, message); cleanup: git_reference_free(tmp); git_reference_free(head); return error; } static int refdb_fs_backend__write( git_refdb_backend *_backend, const git_reference *ref, int force, const git_signature *who, const char *message, const git_oid *old_id, const char *old_target) { refdb_fs_backend *backend = (refdb_fs_backend *)_backend; git_filebuf file = GIT_FILEBUF_INIT; int error = 0; assert(backend); error = reference_path_available(backend, ref->name, NULL, force); if (error < 0) return error; /* We need to perform the reflog append and old value check under the ref's lock */ if ((error = loose_lock(&file, backend, ref->name)) < 0) return error; return refdb_fs_backend__write_tail(_backend, ref, &file, true, who, message, old_id, old_target); } static int refdb_fs_backend__write_tail( git_refdb_backend *_backend, const git_reference *ref, git_filebuf *file, int update_reflog, const git_signature *who, const char *message, const git_oid *old_id, const char *old_target) { refdb_fs_backend *backend = (refdb_fs_backend *)_backend; int error = 0, cmp = 0, should_write; const char *new_target = NULL; const git_oid *new_id = NULL; if ((error = cmp_old_ref(&cmp, _backend, ref->name, old_id, old_target)) < 0) goto on_error; if (cmp) { giterr_set(GITERR_REFERENCE, "old reference value does not match"); error = GIT_EMODIFIED; goto on_error; } if (ref->type == GIT_REF_SYMBOLIC) new_target = ref->target.symbolic; else new_id = &ref->target.oid; error = cmp_old_ref(&cmp, _backend, ref->name, new_id, new_target); if (error < 0 && error != GIT_ENOTFOUND) goto on_error; /* Don't update if we have the same value */ if (!error && !cmp) { error = 0; goto on_error; /* not really error */ } if (update_reflog) { if ((error = should_write_reflog(&should_write, backend->repo, ref->name)) < 0) goto on_error; if (should_write) { if ((error = reflog_append(backend, ref, NULL, NULL, who, message)) < 0) goto on_error; if ((error = maybe_append_head(backend, ref, who, message)) < 0) goto on_error; } } return loose_commit(file, ref); on_error: git_filebuf_cleanup(file); return error; } static int refdb_fs_backend__delete( git_refdb_backend *_backend, const char *ref_name, const git_oid *old_id, const char *old_target) { refdb_fs_backend *backend = (refdb_fs_backend *)_backend; git_filebuf file = GIT_FILEBUF_INIT; int error = 0; assert(backend && ref_name); if ((error = loose_lock(&file, backend, ref_name)) < 0) return error; if ((error = refdb_reflog_fs__delete(_backend, ref_name)) < 0) { git_filebuf_cleanup(&file); return error; } return refdb_fs_backend__delete_tail(_backend, &file, ref_name, old_id, old_target); } static int refdb_fs_backend__delete_tail( git_refdb_backend *_backend, git_filebuf *file, const char *ref_name, const git_oid *old_id, const char *old_target) { refdb_fs_backend *backend = (refdb_fs_backend *)_backend; git_buf loose_path = GIT_BUF_INIT; size_t pack_pos; int error = 0, cmp = 0; bool loose_deleted = 0; error = cmp_old_ref(&cmp, _backend, ref_name, old_id, old_target); if (error < 0) goto cleanup; if (cmp) { giterr_set(GITERR_REFERENCE, "old reference value does not match"); error = GIT_EMODIFIED; goto cleanup; } /* If a loose reference exists, remove it from the filesystem */ if (git_buf_joinpath(&loose_path, backend->path, ref_name) < 0) return -1; if (git_path_isfile(loose_path.ptr)) { error = p_unlink(loose_path.ptr); loose_deleted = 1; } git_buf_free(&loose_path); if (error != 0) goto cleanup; if ((error = packed_reload(backend)) < 0) goto cleanup; /* If a packed reference exists, remove it from the packfile and repack */ if ((error = git_sortedcache_wlock(backend->refcache)) < 0) goto cleanup; if (!(error = git_sortedcache_lookup_index( &pack_pos, backend->refcache, ref_name))) error = git_sortedcache_remove(backend->refcache, pack_pos); git_sortedcache_wunlock(backend->refcache); if (error == GIT_ENOTFOUND) { error = loose_deleted ? 0 : ref_error_notfound(ref_name); goto cleanup; } error = packed_write(backend); cleanup: git_filebuf_cleanup(file); return error; } static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_name, const char *new_name); static int refdb_fs_backend__rename( git_reference **out, git_refdb_backend *_backend, const char *old_name, const char *new_name, int force, const git_signature *who, const char *message) { refdb_fs_backend *backend = (refdb_fs_backend *)_backend; git_reference *old, *new; git_filebuf file = GIT_FILEBUF_INIT; int error; assert(backend); if ((error = reference_path_available( backend, new_name, old_name, force)) < 0 || (error = refdb_fs_backend__lookup(&old, _backend, old_name)) < 0) return error; if ((error = refdb_fs_backend__delete(_backend, old_name, NULL, NULL)) < 0) { git_reference_free(old); return error; } new = git_reference__set_name(old, new_name); if (!new) { git_reference_free(old); return -1; } if ((error = loose_lock(&file, backend, new->name)) < 0) { git_reference_free(new); return error; } /* Try to rename the refog; it's ok if the old doesn't exist */ error = refdb_reflog_fs__rename(_backend, old_name, new_name); if (((error == 0) || (error == GIT_ENOTFOUND)) && ((error = reflog_append(backend, new, git_reference_target(new), NULL, who, message)) < 0)) { git_reference_free(new); git_filebuf_cleanup(&file); return error; } if (error < 0) { git_reference_free(new); git_filebuf_cleanup(&file); return error; } if ((error = loose_commit(&file, new)) < 0 || out == NULL) { git_reference_free(new); return error; } *out = new; return 0; } static int refdb_fs_backend__compress(git_refdb_backend *_backend) { refdb_fs_backend *backend = (refdb_fs_backend *)_backend; assert(backend); if (packed_reload(backend) < 0 || /* load the existing packfile */ packed_loadloose(backend) < 0 || /* add all the loose refs */ packed_write(backend) < 0) /* write back to disk */ return -1; return 0; } static void refdb_fs_backend__free(git_refdb_backend *_backend) { refdb_fs_backend *backend = (refdb_fs_backend *)_backend; assert(backend); git_sortedcache_free(backend->refcache); git__free(backend->path); git__free(backend); } static int setup_namespace(git_buf *path, git_repository *repo) { char *parts, *start, *end; /* Not all repositories have a path */ if (repo->path_repository == NULL) return 0; /* Load the path to the repo first */ git_buf_puts(path, repo->path_repository); /* if the repo is not namespaced, nothing else to do */ if (repo->namespace == NULL) return 0; parts = end = git__strdup(repo->namespace); if (parts == NULL) return -1; /* * From `man gitnamespaces`: * namespaces which include a / will expand to a hierarchy * of namespaces; for example, GIT_NAMESPACE=foo/bar will store * refs under refs/namespaces/foo/refs/namespaces/bar/ */ while ((start = git__strsep(&end, "/")) != NULL) { git_buf_printf(path, "refs/namespaces/%s/", start); } git_buf_printf(path, "refs/namespaces/%s/refs", end); git__free(parts); /* Make sure that the folder with the namespace exists */ if (git_futils_mkdir_relative(git_buf_cstr(path), repo->path_repository, 0777, GIT_MKDIR_PATH, NULL) < 0) return -1; /* Return root of the namespaced path, i.e. without the trailing '/refs' */ git_buf_rtruncate_at_char(path, '/'); return 0; } static int reflog_alloc(git_reflog **reflog, const char *name) { git_reflog *log; *reflog = NULL; log = git__calloc(1, sizeof(git_reflog)); GITERR_CHECK_ALLOC(log); log->ref_name = git__strdup(name); GITERR_CHECK_ALLOC(log->ref_name); if (git_vector_init(&log->entries, 0, NULL) < 0) { git__free(log->ref_name); git__free(log); return -1; } *reflog = log; return 0; } static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size) { const char *ptr; git_reflog_entry *entry; #define seek_forward(_increase) do { \ if (_increase >= buf_size) { \ giterr_set(GITERR_INVALID, "Ran out of data while parsing reflog"); \ goto fail; \ } \ buf += _increase; \ buf_size -= _increase; \ } while (0) while (buf_size > GIT_REFLOG_SIZE_MIN) { entry = git__calloc(1, sizeof(git_reflog_entry)); GITERR_CHECK_ALLOC(entry); entry->committer = git__malloc(sizeof(git_signature)); GITERR_CHECK_ALLOC(entry->committer); if (git_oid_fromstrn(&entry->oid_old, buf, GIT_OID_HEXSZ) < 0) goto fail; seek_forward(GIT_OID_HEXSZ + 1); if (git_oid_fromstrn(&entry->oid_cur, buf, GIT_OID_HEXSZ) < 0) goto fail; seek_forward(GIT_OID_HEXSZ + 1); ptr = buf; /* Seek forward to the end of the signature. */ while (*buf && *buf != '\t' && *buf != '\n') seek_forward(1); if (git_signature__parse(entry->committer, &ptr, buf + 1, NULL, *buf) < 0) goto fail; if (*buf == '\t') { /* We got a message. Read everything till we reach LF. */ seek_forward(1); ptr = buf; while (*buf && *buf != '\n') seek_forward(1); entry->msg = git__strndup(ptr, buf - ptr); GITERR_CHECK_ALLOC(entry->msg); } else entry->msg = NULL; while (*buf && *buf == '\n' && buf_size > 1) seek_forward(1); if (git_vector_insert(&log->entries, entry) < 0) goto fail; } return 0; #undef seek_forward fail: if (entry) git_reflog_entry__free(entry); return -1; } static int create_new_reflog_file(const char *filepath) { int fd, error; if ((error = git_futils_mkpath2file(filepath, GIT_REFLOG_DIR_MODE)) < 0) return error; if ((fd = p_open(filepath, O_WRONLY | O_CREAT, GIT_REFLOG_FILE_MODE)) < 0) return -1; return p_close(fd); } GIT_INLINE(int) retrieve_reflog_path(git_buf *path, git_repository *repo, const char *name) { return git_buf_join3(path, '/', repo->path_repository, GIT_REFLOG_DIR, name); } static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *name) { refdb_fs_backend *backend; git_repository *repo; git_buf path = GIT_BUF_INIT; int error; assert(_backend && name); backend = (refdb_fs_backend *) _backend; repo = backend->repo; if ((error = retrieve_reflog_path(&path, repo, name)) < 0) return error; error = create_new_reflog_file(git_buf_cstr(&path)); git_buf_free(&path); return error; } static int has_reflog(git_repository *repo, const char *name) { int ret = 0; git_buf path = GIT_BUF_INIT; if (retrieve_reflog_path(&path, repo, name) < 0) goto cleanup; ret = git_path_isfile(git_buf_cstr(&path)); cleanup: git_buf_free(&path); return ret; } static int refdb_reflog_fs__has_log(git_refdb_backend *_backend, const char *name) { refdb_fs_backend *backend; assert(_backend && name); backend = (refdb_fs_backend *) _backend; return has_reflog(backend->repo, name); } static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend, const char *name) { int error = -1; git_buf log_path = GIT_BUF_INIT; git_buf log_file = GIT_BUF_INIT; git_reflog *log = NULL; git_repository *repo; refdb_fs_backend *backend; assert(out && _backend && name); backend = (refdb_fs_backend *) _backend; repo = backend->repo; if (reflog_alloc(&log, name) < 0) return -1; if (retrieve_reflog_path(&log_path, repo, name) < 0) goto cleanup; error = git_futils_readbuffer(&log_file, git_buf_cstr(&log_path)); if (error < 0 && error != GIT_ENOTFOUND) goto cleanup; if ((error == GIT_ENOTFOUND) && ((error = create_new_reflog_file(git_buf_cstr(&log_path))) < 0)) goto cleanup; if ((error = reflog_parse(log, git_buf_cstr(&log_file), git_buf_len(&log_file))) < 0) goto cleanup; *out = log; goto success; cleanup: git_reflog_free(log); success: git_buf_free(&log_file); git_buf_free(&log_path); return error; } static int serialize_reflog_entry( git_buf *buf, const git_oid *oid_old, const git_oid *oid_new, const git_signature *committer, const char *msg) { char raw_old[GIT_OID_HEXSZ+1]; char raw_new[GIT_OID_HEXSZ+1]; git_oid_tostr(raw_old, GIT_OID_HEXSZ+1, oid_old); git_oid_tostr(raw_new, GIT_OID_HEXSZ+1, oid_new); git_buf_clear(buf); git_buf_puts(buf, raw_old); git_buf_putc(buf, ' '); git_buf_puts(buf, raw_new); git_signature__writebuf(buf, " ", committer); /* drop trailing LF */ git_buf_rtrim(buf); if (msg) { git_buf_putc(buf, '\t'); git_buf_puts(buf, msg); } git_buf_putc(buf, '\n'); return git_buf_oom(buf); } static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char *refname) { git_repository *repo; git_buf log_path = GIT_BUF_INIT; int error; repo = backend->repo; if (!git_path_isvalid(backend->repo, refname, GIT_PATH_REJECT_DEFAULTS)) { giterr_set(GITERR_INVALID, "Invalid reference name '%s'.", refname); return GIT_EINVALIDSPEC; } if (retrieve_reflog_path(&log_path, repo, refname) < 0) return -1; if (!git_path_isfile(git_buf_cstr(&log_path))) { giterr_set(GITERR_INVALID, "Log file for reference '%s' doesn't exist.", refname); error = -1; goto cleanup; } error = git_filebuf_open(file, git_buf_cstr(&log_path), 0, GIT_REFLOG_FILE_MODE); cleanup: git_buf_free(&log_path); return error; } static int refdb_reflog_fs__write(git_refdb_backend *_backend, git_reflog *reflog) { int error = -1; unsigned int i; git_reflog_entry *entry; refdb_fs_backend *backend; git_buf log = GIT_BUF_INIT; git_filebuf fbuf = GIT_FILEBUF_INIT; assert(_backend && reflog); backend = (refdb_fs_backend *) _backend; if ((error = lock_reflog(&fbuf, backend, reflog->ref_name)) < 0) return -1; git_vector_foreach(&reflog->entries, i, entry) { if (serialize_reflog_entry(&log, &(entry->oid_old), &(entry->oid_cur), entry->committer, entry->msg) < 0) goto cleanup; if ((error = git_filebuf_write(&fbuf, log.ptr, log.size)) < 0) goto cleanup; } error = git_filebuf_commit(&fbuf); goto success; cleanup: git_filebuf_cleanup(&fbuf); success: git_buf_free(&log); return error; } /* Append to the reflog, must be called under reference lock */ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, const git_oid *old, const git_oid *new, const git_signature *who, const char *message) { int error, is_symbolic; git_oid old_id = {{0}}, new_id = {{0}}; git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT; git_repository *repo = backend->repo; is_symbolic = ref->type == GIT_REF_SYMBOLIC; /* "normal" symbolic updates do not write */ if (is_symbolic && strcmp(ref->name, GIT_HEAD_FILE) && !(old && new)) return 0; /* From here on is_symoblic also means that it's HEAD */ if (old) { git_oid_cpy(&old_id, old); } else { error = git_reference_name_to_id(&old_id, repo, ref->name); if (error < 0 && error != GIT_ENOTFOUND) return error; } if (new) { git_oid_cpy(&new_id, new); } else { if (!is_symbolic) { git_oid_cpy(&new_id, git_reference_target(ref)); } else { error = git_reference_name_to_id(&new_id, repo, git_reference_symbolic_target(ref)); if (error < 0 && error != GIT_ENOTFOUND) return error; /* detaching HEAD does not create an entry */ if (error == GIT_ENOTFOUND) return 0; giterr_clear(); } } if ((error = serialize_reflog_entry(&buf, &old_id, &new_id, who, message)) < 0) goto cleanup; if ((error = retrieve_reflog_path(&path, repo, ref->name)) < 0) goto cleanup; if (((error = git_futils_mkpath2file(git_buf_cstr(&path), 0777)) < 0) && (error != GIT_EEXISTS)) { goto cleanup; } /* If the new branch matches part of the namespace of a previously deleted branch, * there maybe an obsolete/unused directory (or directory hierarchy) in the way. */ if (git_path_isdir(git_buf_cstr(&path)) && (git_futils_rmdir_r(git_buf_cstr(&path), NULL, GIT_RMDIR_SKIP_NONEMPTY) < 0)) { error = -1; goto cleanup; } error = git_futils_writebuffer(&buf, git_buf_cstr(&path), O_WRONLY|O_CREAT|O_APPEND, GIT_REFLOG_FILE_MODE); cleanup: git_buf_free(&buf); git_buf_free(&path); return error; } static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_name, const char *new_name) { int error = 0, fd; git_buf old_path = GIT_BUF_INIT; git_buf new_path = GIT_BUF_INIT; git_buf temp_path = GIT_BUF_INIT; git_buf normalized = GIT_BUF_INIT; git_repository *repo; refdb_fs_backend *backend; assert(_backend && old_name && new_name); backend = (refdb_fs_backend *) _backend; repo = backend->repo; if ((error = git_reference__normalize_name( &normalized, new_name, GIT_REF_FORMAT_ALLOW_ONELEVEL)) < 0) return error; if (git_buf_joinpath(&temp_path, repo->path_repository, GIT_REFLOG_DIR) < 0) return -1; if (git_buf_joinpath(&old_path, git_buf_cstr(&temp_path), old_name) < 0) return -1; if (git_buf_joinpath(&new_path, git_buf_cstr(&temp_path), git_buf_cstr(&normalized)) < 0) return -1; if (!git_path_exists(git_buf_cstr(&old_path))) { error = GIT_ENOTFOUND; goto cleanup; } /* * Move the reflog to a temporary place. This two-phase renaming is required * in order to cope with funny renaming use cases when one tries to move a reference * to a partially colliding namespace: * - a/b -> a/b/c * - a/b/c/d -> a/b/c */ if (git_buf_joinpath(&temp_path, git_buf_cstr(&temp_path), "temp_reflog") < 0) return -1; if ((fd = git_futils_mktmp(&temp_path, git_buf_cstr(&temp_path), GIT_REFLOG_FILE_MODE)) < 0) { error = -1; goto cleanup; } p_close(fd); if (p_rename(git_buf_cstr(&old_path), git_buf_cstr(&temp_path)) < 0) { giterr_set(GITERR_OS, "Failed to rename reflog for %s", new_name); error = -1; goto cleanup; } if (git_path_isdir(git_buf_cstr(&new_path)) && (git_futils_rmdir_r(git_buf_cstr(&new_path), NULL, GIT_RMDIR_SKIP_NONEMPTY) < 0)) { error = -1; goto cleanup; } if (git_futils_mkpath2file(git_buf_cstr(&new_path), GIT_REFLOG_DIR_MODE) < 0) { error = -1; goto cleanup; } if (p_rename(git_buf_cstr(&temp_path), git_buf_cstr(&new_path)) < 0) { giterr_set(GITERR_OS, "Failed to rename reflog for %s", new_name); error = -1; } cleanup: git_buf_free(&temp_path); git_buf_free(&old_path); git_buf_free(&new_path); git_buf_free(&normalized); return error; } static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name) { int error; git_buf path = GIT_BUF_INIT; git_repository *repo; refdb_fs_backend *backend; assert(_backend && name); backend = (refdb_fs_backend *) _backend; repo = backend->repo; error = retrieve_reflog_path(&path, repo, name); if (!error && git_path_exists(path.ptr)) error = p_unlink(path.ptr); git_buf_free(&path); return error; } int git_refdb_backend_fs( git_refdb_backend **backend_out, git_repository *repository) { int t = 0; git_buf path = GIT_BUF_INIT; refdb_fs_backend *backend; backend = git__calloc(1, sizeof(refdb_fs_backend)); GITERR_CHECK_ALLOC(backend); backend->repo = repository; if (setup_namespace(&path, repository) < 0) goto fail; backend->path = git_buf_detach(&path); if (git_buf_joinpath(&path, backend->path, GIT_PACKEDREFS_FILE) < 0 || git_sortedcache_new( &backend->refcache, offsetof(struct packref, name), NULL, NULL, packref_cmp, git_buf_cstr(&path)) < 0) goto fail; git_buf_free(&path); if (!git_repository__cvar(&t, backend->repo, GIT_CVAR_IGNORECASE) && t) { backend->iterator_flags |= GIT_ITERATOR_IGNORE_CASE; backend->direach_flags |= GIT_PATH_DIR_IGNORE_CASE; } if (!git_repository__cvar(&t, backend->repo, GIT_CVAR_PRECOMPOSE) && t) { backend->iterator_flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE; backend->direach_flags |= GIT_PATH_DIR_PRECOMPOSE_UNICODE; } backend->parent.exists = &refdb_fs_backend__exists; backend->parent.lookup = &refdb_fs_backend__lookup; backend->parent.iterator = &refdb_fs_backend__iterator; backend->parent.write = &refdb_fs_backend__write; backend->parent.del = &refdb_fs_backend__delete; backend->parent.rename = &refdb_fs_backend__rename; backend->parent.compress = &refdb_fs_backend__compress; backend->parent.lock = &refdb_fs_backend__lock; backend->parent.unlock = &refdb_fs_backend__unlock; backend->parent.has_log = &refdb_reflog_fs__has_log; backend->parent.ensure_log = &refdb_reflog_fs__ensure_log; backend->parent.free = &refdb_fs_backend__free; backend->parent.reflog_read = &refdb_reflog_fs__read; backend->parent.reflog_write = &refdb_reflog_fs__write; backend->parent.reflog_rename = &refdb_reflog_fs__rename; backend->parent.reflog_delete = &refdb_reflog_fs__delete; *backend_out = (git_refdb_backend *)backend; return 0; fail: git_buf_free(&path); git__free(backend->path); git__free(backend); return -1; } deps/libgit2-sys-0.3.8/libgit2/src/cherrypick.c0000664000175000017500000001460712510265101016202 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "repository.h" #include "filebuf.h" #include "merge.h" #include "vector.h" #include "index.h" #include "git2/types.h" #include "git2/merge.h" #include "git2/cherrypick.h" #include "git2/commit.h" #include "git2/sys/commit.h" #define GIT_CHERRYPICK_FILE_MODE 0666 static int write_cherrypick_head( git_repository *repo, const char *commit_oidstr) { git_filebuf file = GIT_FILEBUF_INIT; git_buf file_path = GIT_BUF_INIT; int error = 0; if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_CHERRYPICK_HEAD_FILE)) >= 0 && (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_CHERRYPICK_FILE_MODE)) >= 0 && (error = git_filebuf_printf(&file, "%s\n", commit_oidstr)) >= 0) error = git_filebuf_commit(&file); if (error < 0) git_filebuf_cleanup(&file); git_buf_free(&file_path); return error; } static int write_merge_msg( git_repository *repo, const char *commit_msg) { git_filebuf file = GIT_FILEBUF_INIT; git_buf file_path = GIT_BUF_INIT; int error = 0; if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MSG_FILE)) < 0 || (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_CHERRYPICK_FILE_MODE)) < 0 || (error = git_filebuf_printf(&file, "%s", commit_msg)) < 0) goto cleanup; error = git_filebuf_commit(&file); cleanup: if (error < 0) git_filebuf_cleanup(&file); git_buf_free(&file_path); return error; } static int cherrypick_normalize_opts( git_repository *repo, git_cherrypick_options *opts, const git_cherrypick_options *given, const char *their_label) { int error = 0; unsigned int default_checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_ALLOW_CONFLICTS; GIT_UNUSED(repo); if (given != NULL) memcpy(opts, given, sizeof(git_cherrypick_options)); else { git_cherrypick_options default_opts = GIT_CHERRYPICK_OPTIONS_INIT; memcpy(opts, &default_opts, sizeof(git_cherrypick_options)); } if (!opts->checkout_opts.checkout_strategy) opts->checkout_opts.checkout_strategy = default_checkout_strategy; if (!opts->checkout_opts.our_label) opts->checkout_opts.our_label = "HEAD"; if (!opts->checkout_opts.their_label) opts->checkout_opts.their_label = their_label; return error; } static int cherrypick_state_cleanup(git_repository *repo) { const char *state_files[] = { GIT_CHERRYPICK_HEAD_FILE, GIT_MERGE_MSG_FILE }; return git_repository__cleanup_files(repo, state_files, ARRAY_SIZE(state_files)); } static int cherrypick_seterr(git_commit *commit, const char *fmt) { char commit_oidstr[GIT_OID_HEXSZ + 1]; giterr_set(GITERR_CHERRYPICK, fmt, git_oid_tostr(commit_oidstr, GIT_OID_HEXSZ + 1, git_commit_id(commit))); return -1; } int git_cherrypick_commit( git_index **out, git_repository *repo, git_commit *cherrypick_commit, git_commit *our_commit, unsigned int mainline, const git_merge_options *merge_opts) { git_commit *parent_commit = NULL; git_tree *parent_tree = NULL, *our_tree = NULL, *cherrypick_tree = NULL; int parent = 0, error = 0; assert(out && repo && cherrypick_commit && our_commit); if (git_commit_parentcount(cherrypick_commit) > 1) { if (!mainline) return cherrypick_seterr(cherrypick_commit, "Mainline branch is not specified but %s is a merge commit"); parent = mainline; } else { if (mainline) return cherrypick_seterr(cherrypick_commit, "Mainline branch specified but %s is not a merge commit"); parent = git_commit_parentcount(cherrypick_commit); } if (parent && ((error = git_commit_parent(&parent_commit, cherrypick_commit, (parent - 1))) < 0 || (error = git_commit_tree(&parent_tree, parent_commit)) < 0)) goto done; if ((error = git_commit_tree(&cherrypick_tree, cherrypick_commit)) < 0 || (error = git_commit_tree(&our_tree, our_commit)) < 0) goto done; error = git_merge_trees(out, repo, parent_tree, our_tree, cherrypick_tree, merge_opts); done: git_tree_free(parent_tree); git_tree_free(our_tree); git_tree_free(cherrypick_tree); git_commit_free(parent_commit); return error; } int git_cherrypick( git_repository *repo, git_commit *commit, const git_cherrypick_options *given_opts) { git_cherrypick_options opts; git_reference *our_ref = NULL; git_commit *our_commit = NULL; char commit_oidstr[GIT_OID_HEXSZ + 1]; const char *commit_msg, *commit_summary; git_buf their_label = GIT_BUF_INIT; git_index *index = NULL; git_indexwriter indexwriter = GIT_INDEXWRITER_INIT; int error = 0; assert(repo && commit); GITERR_CHECK_VERSION(given_opts, GIT_CHERRYPICK_OPTIONS_VERSION, "git_cherrypick_options"); if ((error = git_repository__ensure_not_bare(repo, "cherry-pick")) < 0) return error; if ((commit_msg = git_commit_message(commit)) == NULL || (commit_summary = git_commit_summary(commit)) == NULL) { error = -1; goto on_error; } git_oid_nfmt(commit_oidstr, sizeof(commit_oidstr), git_commit_id(commit)); if ((error = write_merge_msg(repo, commit_msg)) < 0 || (error = git_buf_printf(&their_label, "%.7s... %s", commit_oidstr, commit_summary)) < 0 || (error = cherrypick_normalize_opts(repo, &opts, given_opts, git_buf_cstr(&their_label))) < 0 || (error = git_indexwriter_init_for_operation(&indexwriter, repo, &opts.checkout_opts.checkout_strategy)) < 0 || (error = write_cherrypick_head(repo, commit_oidstr)) < 0 || (error = git_repository_head(&our_ref, repo)) < 0 || (error = git_reference_peel((git_object **)&our_commit, our_ref, GIT_OBJ_COMMIT)) < 0 || (error = git_cherrypick_commit(&index, repo, commit, our_commit, opts.mainline, &opts.merge_opts)) < 0 || (error = git_merge__check_result(repo, index)) < 0 || (error = git_merge__append_conflicts_to_merge_msg(repo, index)) < 0 || (error = git_checkout_index(repo, index, &opts.checkout_opts)) < 0 || (error = git_indexwriter_commit(&indexwriter)) < 0) goto on_error; goto done; on_error: cherrypick_state_cleanup(repo); done: git_indexwriter_cleanup(&indexwriter); git_index_free(index); git_commit_free(our_commit); git_reference_free(our_ref); git_buf_free(&their_label); return error; } int git_cherrypick_init_options( git_cherrypick_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_cherrypick_options, GIT_CHERRYPICK_OPTIONS_INIT); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/global.c0000664000175000017500000002243712572105236015311 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "global.h" #include "hash.h" #include "sysdir.h" #include "git2/global.h" #include "git2/sys/openssl.h" #include "thread-utils.h" #if defined(GIT_MSVC_CRTDBG) #include "win32/w32_stack.h" #include "win32/w32_crtdbg_stacktrace.h" #endif git_mutex git__mwindow_mutex; #define MAX_SHUTDOWN_CB 8 #ifdef GIT_OPENSSL # include SSL_CTX *git__ssl_ctx; # ifdef GIT_THREADS static git_mutex *openssl_locks; # endif #endif static git_global_shutdown_fn git__shutdown_callbacks[MAX_SHUTDOWN_CB]; static git_atomic git__n_shutdown_callbacks; static git_atomic git__n_inits; void git__on_shutdown(git_global_shutdown_fn callback) { int count = git_atomic_inc(&git__n_shutdown_callbacks); assert(count <= MAX_SHUTDOWN_CB && count > 0); git__shutdown_callbacks[count - 1] = callback; } static void git__global_state_cleanup(git_global_st *st) { if (!st) return; git__free(st->error_t.message); st->error_t.message = NULL; } static void git__shutdown(void) { int pos; /* Shutdown subsystems that have registered */ for (pos = git_atomic_get(&git__n_shutdown_callbacks); pos > 0; pos = git_atomic_dec(&git__n_shutdown_callbacks)) { git_global_shutdown_fn cb = git__swap(git__shutdown_callbacks[pos - 1], NULL); if (cb != NULL) cb(); } } #if defined(GIT_THREADS) && defined(GIT_OPENSSL) void openssl_locking_function(int mode, int n, const char *file, int line) { int lock; GIT_UNUSED(file); GIT_UNUSED(line); lock = mode & CRYPTO_LOCK; if (lock) { git_mutex_lock(&openssl_locks[n]); } else { git_mutex_unlock(&openssl_locks[n]); } } static void shutdown_ssl_locking(void) { int num_locks, i; num_locks = CRYPTO_num_locks(); CRYPTO_set_locking_callback(NULL); for (i = 0; i < num_locks; ++i) git_mutex_free(openssl_locks); git__free(openssl_locks); } #endif static void init_ssl(void) { #ifdef GIT_OPENSSL long ssl_opts = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3; /* Older OpenSSL and MacOS OpenSSL doesn't have this */ #ifdef SSL_OP_NO_COMPRESSION ssl_opts |= SSL_OP_NO_COMPRESSION; #endif SSL_load_error_strings(); OpenSSL_add_ssl_algorithms(); /* * Load SSLv{2,3} and TLSv1 so that we can talk with servers * which use the SSL hellos, which are often used for * compatibility. We then disable SSL so we only allow OpenSSL * to speak TLSv1 to perform the encryption itself. */ git__ssl_ctx = SSL_CTX_new(SSLv23_method()); SSL_CTX_set_options(git__ssl_ctx, ssl_opts); SSL_CTX_set_mode(git__ssl_ctx, SSL_MODE_AUTO_RETRY); SSL_CTX_set_verify(git__ssl_ctx, SSL_VERIFY_NONE, NULL); if (!SSL_CTX_set_default_verify_paths(git__ssl_ctx)) { SSL_CTX_free(git__ssl_ctx); git__ssl_ctx = NULL; } #endif } /** * This function aims to clean-up the SSL context which * we allocated. */ static void uninit_ssl(void) { #ifdef GIT_OPENSSL if (git__ssl_ctx) { SSL_CTX_free(git__ssl_ctx); git__ssl_ctx = NULL; } #endif } int git_openssl_set_locking(void) { #ifdef GIT_OPENSSL # ifdef GIT_THREADS int num_locks, i; num_locks = CRYPTO_num_locks(); openssl_locks = git__calloc(num_locks, sizeof(git_mutex)); GITERR_CHECK_ALLOC(openssl_locks); for (i = 0; i < num_locks; i++) { if (git_mutex_init(&openssl_locks[i]) != 0) { giterr_set(GITERR_SSL, "failed to initialize openssl locks"); return -1; } } CRYPTO_set_locking_callback(openssl_locking_function); git__on_shutdown(shutdown_ssl_locking); return 0; # else giterr_set(GITERR_THREAD, "libgit2 as not built with threads"); return -1; # endif #else giterr_set(GITERR_SSL, "libgit2 was not built with OpenSSL support"); return -1; #endif } /** * Handle the global state with TLS * * If libgit2 is built with GIT_THREADS enabled, * the `git_libgit2_init()` function must be called * before calling any other function of the library. * * This function allocates a TLS index (using pthreads * or the native Win32 API) to store the global state * on a per-thread basis. * * Any internal method that requires global state will * then call `git__global_state()` which returns a pointer * to the global state structure; this pointer is lazily * allocated on each thread. * * Before shutting down the library, the * `git_libgit2_shutdown` method must be called to free * the previously reserved TLS index. * * If libgit2 is built without threading support, the * `git__global_statestate()` call returns a pointer to a single, * statically allocated global state. The `git_thread_` * functions are not available in that case. */ /* * `git_libgit2_init()` allows subsystems to perform global setup, * which may take place in the global scope. An explicit memory * fence exists at the exit of `git_libgit2_init()`. Without this, * CPU cores are free to reorder cache invalidation of `_tls_init` * before cache invalidation of the subsystems' newly written global * state. */ #if defined(GIT_THREADS) && defined(GIT_WIN32) static DWORD _tls_index; static volatile LONG _mutex = 0; static int synchronized_threads_init(void) { int error; _tls_index = TlsAlloc(); if (git_mutex_init(&git__mwindow_mutex)) return -1; /* Initialize any other subsystems that have global state */ if ((error = git_hash_global_init()) >= 0) error = git_sysdir_global_init(); win32_pthread_initialize(); return error; } int git_libgit2_init(void) { int ret; /* Enter the lock */ while (InterlockedCompareExchange(&_mutex, 1, 0)) { Sleep(0); } /* Only do work on a 0 -> 1 transition of the refcount */ if ((ret = git_atomic_inc(&git__n_inits)) == 1) { #if defined(GIT_MSVC_CRTDBG) git_win32__crtdbg_stacktrace_init(); git_win32__stack_init(); #endif if (synchronized_threads_init() < 0) ret = -1; } /* Exit the lock */ InterlockedExchange(&_mutex, 0); return ret; } static void synchronized_threads_shutdown(void) { /* Shut down any subsystems that have global state */ git__shutdown(); git__free_tls_data(); TlsFree(_tls_index); git_mutex_free(&git__mwindow_mutex); } int git_libgit2_shutdown(void) { int ret; /* Enter the lock */ while (InterlockedCompareExchange(&_mutex, 1, 0)) { Sleep(0); } /* Only do work on a 1 -> 0 transition of the refcount */ if ((ret = git_atomic_dec(&git__n_inits)) == 0) { synchronized_threads_shutdown(); #if defined(GIT_MSVC_CRTDBG) git_win32__crtdbg_stacktrace_cleanup(); git_win32__stack_cleanup(); #endif } /* Exit the lock */ InterlockedExchange(&_mutex, 0); return ret; } git_global_st *git__global_state(void) { git_global_st *ptr; assert(git_atomic_get(&git__n_inits) > 0); if ((ptr = TlsGetValue(_tls_index)) != NULL) return ptr; ptr = git__calloc(1, sizeof(git_global_st)); if (!ptr) return NULL; git_buf_init(&ptr->error_buf, 0); TlsSetValue(_tls_index, ptr); return ptr; } /** * Free the TLS data associated with this thread. * This should only be used by the thread as it * is exiting. */ void git__free_tls_data(void) { void *ptr = TlsGetValue(_tls_index); if (!ptr) return; git__global_state_cleanup(ptr); git__free(ptr); TlsSetValue(_tls_index, NULL); } #elif defined(GIT_THREADS) && defined(_POSIX_THREADS) static pthread_key_t _tls_key; static pthread_once_t _once_init = PTHREAD_ONCE_INIT; int init_error = 0; static void cb__free_status(void *st) { git__global_state_cleanup(st); git__free(st); } static void init_once(void) { if ((init_error = git_mutex_init(&git__mwindow_mutex)) != 0) return; pthread_key_create(&_tls_key, &cb__free_status); /* Initialize any other subsystems that have global state */ if ((init_error = git_hash_global_init()) >= 0) init_error = git_sysdir_global_init(); /* OpenSSL needs to be initialized from the main thread */ init_ssl(); GIT_MEMORY_BARRIER; } int git_libgit2_init(void) { int ret; ret = git_atomic_inc(&git__n_inits); pthread_once(&_once_init, init_once); return init_error ? init_error : ret; } int git_libgit2_shutdown(void) { void *ptr = NULL; pthread_once_t new_once = PTHREAD_ONCE_INIT; int ret; if ((ret = git_atomic_dec(&git__n_inits)) != 0) return ret; /* Shut down any subsystems that have global state */ git__shutdown(); uninit_ssl(); ptr = pthread_getspecific(_tls_key); pthread_setspecific(_tls_key, NULL); git__global_state_cleanup(ptr); git__free(ptr); pthread_key_delete(_tls_key); git_mutex_free(&git__mwindow_mutex); _once_init = new_once; return 0; } git_global_st *git__global_state(void) { git_global_st *ptr; assert(git_atomic_get(&git__n_inits) > 0); if ((ptr = pthread_getspecific(_tls_key)) != NULL) return ptr; ptr = git__calloc(1, sizeof(git_global_st)); if (!ptr) return NULL; git_buf_init(&ptr->error_buf, 0); pthread_setspecific(_tls_key, ptr); return ptr; } #else static git_global_st __state; int git_libgit2_init(void) { static int ssl_inited = 0; if (!ssl_inited) { init_ssl(); ssl_inited = 1; } git_buf_init(&__state.error_buf, 0); return git_atomic_inc(&git__n_inits); } int git_libgit2_shutdown(void) { int ret; /* Shut down any subsystems that have global state */ if ((ret = git_atomic_dec(&git__n_inits)) != 0) return ret; git__shutdown(); git__global_state_cleanup(&__state); uninit_ssl(); return 0; } git_global_st *git__global_state(void) { return &__state; } #endif /* GIT_THREADS */ deps/libgit2-sys-0.3.8/libgit2/src/push.h0000664000175000017500000000610712610310643015022 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_push_h__ #define INCLUDE_push_h__ #include "git2.h" #include "refspec.h" typedef struct push_spec { struct git_refspec refspec; git_oid loid; git_oid roid; } push_spec; typedef struct push_status { bool ok; char *ref; char *msg; } push_status; struct git_push { git_repository *repo; git_packbuilder *pb; git_remote *remote; git_vector specs; git_vector updates; bool report_status; /* report-status */ bool unpack_ok; git_vector status; /* options */ unsigned pb_parallelism; const git_strarray *custom_headers; }; /** * Free the given push status object * * @param status The push status object */ void git_push_status_free(push_status *status); /** * Create a new push object * * @param out New push object * @param remote Remote instance * * @return 0 or an error code */ int git_push_new(git_push **out, git_remote *remote); /** * Set options on a push object * * @param push The push object * @param opts The options to set on the push object * * @return 0 or an error code */ int git_push_set_options( git_push *push, const git_push_options *opts); /** * Add a refspec to be pushed * * @param push The push object * @param refspec Refspec string * * @return 0 or an error code */ int git_push_add_refspec(git_push *push, const char *refspec); /** * Update remote tips after a push * * @param push The push object * @param callbacks the callbacks to use for this connection * * @return 0 or an error code */ int git_push_update_tips(git_push *push, const git_remote_callbacks *callbacks); /** * Perform the push * * This function will return an error in case of a protocol error or * the server being unable to unpack the data we sent. * * The return value does not reflect whether the server accepted or * refused any reference updates. Use `git_push_status_foreach()` in * order to find out which updates were accepted or rejected. * * @param push The push object * @param callbacks the callbacks to use for this connection * * @return 0 or an error code */ int git_push_finish(git_push *push, const git_remote_callbacks *callbacks); /** * Invoke callback `cb' on each status entry * * For each of the updated references, we receive a status report in the * form of `ok refs/heads/master` or `ng refs/heads/master `. * `msg != NULL` means the reference has not been updated for the given * reason. * * Return a non-zero value from the callback to stop the loop. * * @param push The push object * @param cb The callback to call on each object * @param data The payload passed to the callback * * @return 0 on success, non-zero callback return value, or error code */ int git_push_status_foreach(git_push *push, int (*cb)(const char *ref, const char *msg, void *data), void *data); /** * Free the given push object * * @param push The push object */ void git_push_free(git_push *push); #endif deps/libgit2-sys-0.3.8/libgit2/src/message.c0000664000175000017500000000316512426525445015500 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "message.h" static size_t line_length_without_trailing_spaces(const char *line, size_t len) { while (len) { unsigned char c = line[len - 1]; if (!git__isspace(c)) break; len--; } return len; } /* Greatly inspired from git.git "stripspace" */ /* see https://github.com/git/git/blob/497215d8811ac7b8955693ceaad0899ecd894ed2/builtin/stripspace.c#L4-67 */ int git_message_prettify(git_buf *message_out, const char *message, int strip_comments, char comment_char) { const size_t message_len = strlen(message); int consecutive_empty_lines = 0; size_t i, line_length, rtrimmed_line_length; char *next_newline; git_buf_sanitize(message_out); for (i = 0; i < strlen(message); i += line_length) { next_newline = memchr(message + i, '\n', message_len - i); if (next_newline != NULL) { line_length = next_newline - (message + i) + 1; } else { line_length = message_len - i; } if (strip_comments && line_length && message[i] == comment_char) continue; rtrimmed_line_length = line_length_without_trailing_spaces(message + i, line_length); if (!rtrimmed_line_length) { consecutive_empty_lines++; continue; } if (consecutive_empty_lines > 0 && message_out->size > 0) git_buf_putc(message_out, '\n'); consecutive_empty_lines = 0; git_buf_put(message_out, message + i, rtrimmed_line_length); git_buf_putc(message_out, '\n'); } return git_buf_oom(message_out) ? -1 : 0; } deps/libgit2-sys-0.3.8/libgit2/src/zstream.h0000664000175000017500000000170612426525445015545 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_zstream_h__ #define INCLUDE_zstream_h__ #include #include "common.h" #include "buffer.h" typedef struct { z_stream z; const char *in; size_t in_len; int zerr; } git_zstream; #define GIT_ZSTREAM_INIT {{0}} int git_zstream_init(git_zstream *zstream); void git_zstream_free(git_zstream *zstream); int git_zstream_set_input(git_zstream *zstream, const void *in, size_t in_len); size_t git_zstream_suggest_output_len(git_zstream *zstream); int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream); bool git_zstream_done(git_zstream *zstream); void git_zstream_reset(git_zstream *zstream); int git_zstream_deflatebuf(git_buf *out, const void *in, size_t in_len); #endif /* INCLUDE_zstream_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/sha1_lookup.h0000664000175000017500000000110112426525445016272 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sha1_lookup_h__ #define INCLUDE_sha1_lookup_h__ #include int sha1_entry_pos(const void *table, size_t elem_size, size_t key_offset, unsigned lo, unsigned hi, unsigned nr, const unsigned char *key); int sha1_position(const void *table, size_t stride, unsigned lo, unsigned hi, const unsigned char *key); #endif deps/libgit2-sys-0.3.8/libgit2/src/signature.h0000664000175000017500000000140112510265101016031 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_signature_h__ #define INCLUDE_signature_h__ #include "git2/common.h" #include "git2/signature.h" #include "repository.h" #include int git_signature__parse(git_signature *sig, const char **buffer_out, const char *buffer_end, const char *header, char ender); void git_signature__writebuf(git_buf *buf, const char *header, const git_signature *sig); bool git_signature__equal(const git_signature *one, const git_signature *two); int git_signature__pdup(git_signature **dest, const git_signature *source, git_pool *pool); #endif deps/libgit2-sys-0.3.8/libgit2/src/tsort.c0000664000175000017500000002043512510265101015206 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" /** * An array-of-pointers implementation of Python's Timsort * Based on code by Christopher Swenson under the MIT license * * Copyright (c) 2010 Christopher Swenson * Copyright (c) 2011 Vicent Marti */ #ifndef MAX # define MAX(x,y) (((x) > (y) ? (x) : (y))) #endif #ifndef MIN # define MIN(x,y) (((x) < (y) ? (x) : (y))) #endif static int binsearch( void **dst, const void *x, size_t size, git__sort_r_cmp cmp, void *payload) { int l, c, r; void *lx, *cx; assert(size > 0); l = 0; r = (int)size - 1; c = r >> 1; lx = dst[l]; /* check for beginning conditions */ if (cmp(x, lx, payload) < 0) return 0; else if (cmp(x, lx, payload) == 0) { int i = 1; while (cmp(x, dst[i], payload) == 0) i++; return i; } /* guaranteed not to be >= rx */ cx = dst[c]; while (1) { const int val = cmp(x, cx, payload); if (val < 0) { if (c - l <= 1) return c; r = c; } else if (val > 0) { if (r - c <= 1) return c + 1; l = c; lx = cx; } else { do { cx = dst[++c]; } while (cmp(x, cx, payload) == 0); return c; } c = l + ((r - l) >> 1); cx = dst[c]; } } /* Binary insertion sort, but knowing that the first "start" entries are sorted. Used in timsort. */ static void bisort( void **dst, size_t start, size_t size, git__sort_r_cmp cmp, void *payload) { size_t i; void *x; int location; for (i = start; i < size; i++) { int j; /* If this entry is already correct, just move along */ if (cmp(dst[i - 1], dst[i], payload) <= 0) continue; /* Else we need to find the right place, shift everything over, and squeeze in */ x = dst[i]; location = binsearch(dst, x, i, cmp, payload); for (j = (int)i - 1; j >= location; j--) { dst[j + 1] = dst[j]; } dst[location] = x; } } /* timsort implementation, based on timsort.txt */ struct tsort_run { ssize_t start; ssize_t length; }; struct tsort_store { size_t alloc; git__sort_r_cmp cmp; void *payload; void **storage; }; static void reverse_elements(void **dst, ssize_t start, ssize_t end) { while (start < end) { void *tmp = dst[start]; dst[start] = dst[end]; dst[end] = tmp; start++; end--; } } static ssize_t count_run( void **dst, ssize_t start, ssize_t size, struct tsort_store *store) { ssize_t curr = start + 2; if (size - start == 1) return 1; if (start >= size - 2) { if (store->cmp(dst[size - 2], dst[size - 1], store->payload) > 0) { void *tmp = dst[size - 1]; dst[size - 1] = dst[size - 2]; dst[size - 2] = tmp; } return 2; } if (store->cmp(dst[start], dst[start + 1], store->payload) <= 0) { while (curr < size - 1 && store->cmp(dst[curr - 1], dst[curr], store->payload) <= 0) curr++; return curr - start; } else { while (curr < size - 1 && store->cmp(dst[curr - 1], dst[curr], store->payload) > 0) curr++; /* reverse in-place */ reverse_elements(dst, start, curr - 1); return curr - start; } } static size_t compute_minrun(size_t n) { int r = 0; while (n >= 64) { r |= n & 1; n >>= 1; } return n + r; } static int check_invariant(struct tsort_run *stack, ssize_t stack_curr) { if (stack_curr < 2) return 1; else if (stack_curr == 2) { const ssize_t A = stack[stack_curr - 2].length; const ssize_t B = stack[stack_curr - 1].length; return (A > B); } else { const ssize_t A = stack[stack_curr - 3].length; const ssize_t B = stack[stack_curr - 2].length; const ssize_t C = stack[stack_curr - 1].length; return !((A <= B + C) || (B <= C)); } } static int resize(struct tsort_store *store, size_t new_size) { if (store->alloc < new_size) { void **tempstore; tempstore = git__reallocarray(store->storage, new_size, sizeof(void *)); /** * Do not propagate on OOM; this will abort the sort and * leave the array unsorted, but no error code will be * raised */ if (tempstore == NULL) return -1; store->storage = tempstore; store->alloc = new_size; } return 0; } static void merge(void **dst, const struct tsort_run *stack, ssize_t stack_curr, struct tsort_store *store) { const ssize_t A = stack[stack_curr - 2].length; const ssize_t B = stack[stack_curr - 1].length; const ssize_t curr = stack[stack_curr - 2].start; void **storage; ssize_t i, j, k; if (resize(store, MIN(A, B)) < 0) return; storage = store->storage; /* left merge */ if (A < B) { memcpy(storage, &dst[curr], A * sizeof(void *)); i = 0; j = curr + A; for (k = curr; k < curr + A + B; k++) { if ((i < A) && (j < curr + A + B)) { if (store->cmp(storage[i], dst[j], store->payload) <= 0) dst[k] = storage[i++]; else dst[k] = dst[j++]; } else if (i < A) { dst[k] = storage[i++]; } else dst[k] = dst[j++]; } } else { memcpy(storage, &dst[curr + A], B * sizeof(void *)); i = B - 1; j = curr + A - 1; for (k = curr + A + B - 1; k >= curr; k--) { if ((i >= 0) && (j >= curr)) { if (store->cmp(dst[j], storage[i], store->payload) > 0) dst[k] = dst[j--]; else dst[k] = storage[i--]; } else if (i >= 0) dst[k] = storage[i--]; else dst[k] = dst[j--]; } } } static ssize_t collapse(void **dst, struct tsort_run *stack, ssize_t stack_curr, struct tsort_store *store, ssize_t size) { ssize_t A, B, C; while (1) { /* if the stack only has one thing on it, we are done with the collapse */ if (stack_curr <= 1) break; /* if this is the last merge, just do it */ if ((stack_curr == 2) && (stack[0].length + stack[1].length == size)) { merge(dst, stack, stack_curr, store); stack[0].length += stack[1].length; stack_curr--; break; } /* check if the invariant is off for a stack of 2 elements */ else if ((stack_curr == 2) && (stack[0].length <= stack[1].length)) { merge(dst, stack, stack_curr, store); stack[0].length += stack[1].length; stack_curr--; break; } else if (stack_curr == 2) break; A = stack[stack_curr - 3].length; B = stack[stack_curr - 2].length; C = stack[stack_curr - 1].length; /* check first invariant */ if (A <= B + C) { if (A < C) { merge(dst, stack, stack_curr - 1, store); stack[stack_curr - 3].length += stack[stack_curr - 2].length; stack[stack_curr - 2] = stack[stack_curr - 1]; stack_curr--; } else { merge(dst, stack, stack_curr, store); stack[stack_curr - 2].length += stack[stack_curr - 1].length; stack_curr--; } } else if (B <= C) { merge(dst, stack, stack_curr, store); stack[stack_curr - 2].length += stack[stack_curr - 1].length; stack_curr--; } else break; } return stack_curr; } #define PUSH_NEXT() do {\ len = count_run(dst, curr, size, store);\ run = minrun;\ if (run < minrun) run = minrun;\ if (run > (ssize_t)size - curr) run = size - curr;\ if (run > len) {\ bisort(&dst[curr], len, run, cmp, payload);\ len = run;\ }\ run_stack[stack_curr].start = curr;\ run_stack[stack_curr++].length = len;\ curr += len;\ if (curr == (ssize_t)size) {\ /* finish up */ \ while (stack_curr > 1) { \ merge(dst, run_stack, stack_curr, store); \ run_stack[stack_curr - 2].length += run_stack[stack_curr - 1].length; \ stack_curr--; \ } \ if (store->storage != NULL) {\ git__free(store->storage);\ store->storage = NULL;\ }\ return;\ }\ }\ while (0) void git__tsort_r( void **dst, size_t size, git__sort_r_cmp cmp, void *payload) { struct tsort_store _store, *store = &_store; struct tsort_run run_stack[128]; ssize_t stack_curr = 0; ssize_t len, run; ssize_t curr = 0; ssize_t minrun; if (size < 64) { bisort(dst, 1, size, cmp, payload); return; } /* compute the minimum run length */ minrun = (ssize_t)compute_minrun(size); /* temporary storage for merges */ store->alloc = 0; store->storage = NULL; store->cmp = cmp; store->payload = payload; PUSH_NEXT(); PUSH_NEXT(); PUSH_NEXT(); while (1) { if (!check_invariant(run_stack, stack_curr)) { stack_curr = collapse(dst, run_stack, stack_curr, store, size); continue; } PUSH_NEXT(); } } static int tsort_r_cmp(const void *a, const void *b, void *payload) { return ((git__tsort_cmp)payload)(a, b); } void git__tsort(void **dst, size_t size, git__tsort_cmp cmp) { git__tsort_r(dst, size, tsort_r_cmp, cmp); } deps/libgit2-sys-0.3.8/libgit2/src/checkout.c0000664000175000017500000021650712610310643015652 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include #include "checkout.h" #include "git2/repository.h" #include "git2/refs.h" #include "git2/tree.h" #include "git2/blob.h" #include "git2/config.h" #include "git2/diff.h" #include "git2/submodule.h" #include "git2/sys/index.h" #include "git2/sys/filter.h" #include "git2/merge.h" #include "refs.h" #include "repository.h" #include "index.h" #include "filter.h" #include "blob.h" #include "diff.h" #include "pathspec.h" #include "buf_text.h" #include "diff_xdiff.h" #include "path.h" #include "attr.h" #include "pool.h" #include "strmap.h" GIT__USE_STRMAP /* See docs/checkout-internals.md for more information */ enum { CHECKOUT_ACTION__NONE = 0, CHECKOUT_ACTION__REMOVE = 1, CHECKOUT_ACTION__UPDATE_BLOB = 2, CHECKOUT_ACTION__UPDATE_SUBMODULE = 4, CHECKOUT_ACTION__CONFLICT = 8, CHECKOUT_ACTION__REMOVE_CONFLICT = 16, CHECKOUT_ACTION__UPDATE_CONFLICT = 32, CHECKOUT_ACTION__MAX = 32, CHECKOUT_ACTION__DEFER_REMOVE = 64, CHECKOUT_ACTION__REMOVE_AND_UPDATE = (CHECKOUT_ACTION__UPDATE_BLOB | CHECKOUT_ACTION__REMOVE), }; typedef struct { git_repository *repo; git_iterator *target; git_diff *diff; git_checkout_options opts; bool opts_free_baseline; char *pfx; git_index *index; git_pool pool; git_vector removes; git_vector remove_conflicts; git_vector update_conflicts; git_vector *update_reuc; git_vector *update_names; git_buf path; size_t workdir_len; git_buf tmp; unsigned int strategy; int can_symlink; bool reload_submodules; size_t total_steps; size_t completed_steps; git_checkout_perfdata perfdata; git_strmap *mkdir_map; git_attr_session attr_session; } checkout_data; typedef struct { const git_index_entry *ancestor; const git_index_entry *ours; const git_index_entry *theirs; int name_collision:1, directoryfile:1, one_to_two:1, binary:1, submodule:1; } checkout_conflictdata; static int checkout_notify( checkout_data *data, git_checkout_notify_t why, const git_diff_delta *delta, const git_index_entry *wditem) { git_diff_file wdfile; const git_diff_file *baseline = NULL, *target = NULL, *workdir = NULL; const char *path = NULL; if (!data->opts.notify_cb || (why & data->opts.notify_flags) == 0) return 0; if (wditem) { memset(&wdfile, 0, sizeof(wdfile)); git_oid_cpy(&wdfile.id, &wditem->id); wdfile.path = wditem->path; wdfile.size = wditem->file_size; wdfile.flags = GIT_DIFF_FLAG_VALID_ID; wdfile.mode = wditem->mode; workdir = &wdfile; path = wditem->path; } if (delta) { switch (delta->status) { case GIT_DELTA_UNMODIFIED: case GIT_DELTA_MODIFIED: case GIT_DELTA_TYPECHANGE: default: baseline = &delta->old_file; target = &delta->new_file; break; case GIT_DELTA_ADDED: case GIT_DELTA_IGNORED: case GIT_DELTA_UNTRACKED: case GIT_DELTA_UNREADABLE: target = &delta->new_file; break; case GIT_DELTA_DELETED: baseline = &delta->old_file; break; } path = delta->old_file.path; } { int error = data->opts.notify_cb( why, path, baseline, target, workdir, data->opts.notify_payload); return giterr_set_after_callback_function( error, "git_checkout notification"); } } GIT_INLINE(bool) is_workdir_base_or_new( const git_oid *workdir_id, const git_diff_file *baseitem, const git_diff_file *newitem) { return (git_oid__cmp(&baseitem->id, workdir_id) == 0 || git_oid__cmp(&newitem->id, workdir_id) == 0); } static bool checkout_is_workdir_modified( checkout_data *data, const git_diff_file *baseitem, const git_diff_file *newitem, const git_index_entry *wditem) { git_oid oid; const git_index_entry *ie; /* handle "modified" submodule */ if (wditem->mode == GIT_FILEMODE_COMMIT) { git_submodule *sm; unsigned int sm_status = 0; const git_oid *sm_oid = NULL; bool rval = false; if (git_submodule_lookup(&sm, data->repo, wditem->path) < 0) { giterr_clear(); return true; } if (git_submodule_status(&sm_status, data->repo, wditem->path, GIT_SUBMODULE_IGNORE_UNSPECIFIED) < 0 || GIT_SUBMODULE_STATUS_IS_WD_DIRTY(sm_status)) rval = true; else if ((sm_oid = git_submodule_wd_id(sm)) == NULL) rval = false; else rval = (git_oid__cmp(&baseitem->id, sm_oid) != 0); git_submodule_free(sm); return rval; } /* Look at the cache to decide if the workdir is modified. If not, * we can simply compare the oid in the cache to the baseitem instead * of hashing the file. If so, we allow the checkout to proceed if the * oid is identical (ie, the staged item is what we're trying to check * out.) */ if ((ie = git_index_get_bypath(data->index, wditem->path, 0)) != NULL) { if (wditem->mtime.seconds == ie->mtime.seconds && wditem->mtime.nanoseconds == ie->mtime.nanoseconds && wditem->file_size == ie->file_size) return !is_workdir_base_or_new(&ie->id, baseitem, newitem); } /* depending on where base is coming from, we may or may not know * the actual size of the data, so we can't rely on this shortcut. */ if (baseitem->size && wditem->file_size != baseitem->size) return true; if (git_diff__oid_for_entry(&oid, data->diff, wditem, wditem->mode, NULL) < 0) return false; /* Allow the checkout if the workdir is not modified *or* if the checkout * target's contents are already in the working directory. */ return !is_workdir_base_or_new(&oid, baseitem, newitem); } #define CHECKOUT_ACTION_IF(FLAG,YES,NO) \ ((data->strategy & GIT_CHECKOUT_##FLAG) ? CHECKOUT_ACTION__##YES : CHECKOUT_ACTION__##NO) static int checkout_action_common( int *action, checkout_data *data, const git_diff_delta *delta, const git_index_entry *wd) { git_checkout_notify_t notify = GIT_CHECKOUT_NOTIFY_NONE; if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0) *action = (*action & ~CHECKOUT_ACTION__REMOVE); if ((*action & CHECKOUT_ACTION__UPDATE_BLOB) != 0) { if (S_ISGITLINK(delta->new_file.mode)) *action = (*action & ~CHECKOUT_ACTION__UPDATE_BLOB) | CHECKOUT_ACTION__UPDATE_SUBMODULE; /* to "update" a symlink, we must remove the old one first */ if (delta->new_file.mode == GIT_FILEMODE_LINK && wd != NULL) *action |= CHECKOUT_ACTION__REMOVE; /* if the file is on disk and doesn't match our mode, force update */ if (wd && GIT_PERMS_IS_EXEC(wd->mode) != GIT_PERMS_IS_EXEC(delta->new_file.mode)) *action |= CHECKOUT_ACTION__REMOVE; notify = GIT_CHECKOUT_NOTIFY_UPDATED; } if ((*action & CHECKOUT_ACTION__CONFLICT) != 0) notify = GIT_CHECKOUT_NOTIFY_CONFLICT; return checkout_notify(data, notify, delta, wd); } static int checkout_action_no_wd( int *action, checkout_data *data, const git_diff_delta *delta) { int error = 0; *action = CHECKOUT_ACTION__NONE; switch (delta->status) { case GIT_DELTA_UNMODIFIED: /* case 12 */ error = checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, NULL); if (error) return error; *action = CHECKOUT_ACTION_IF(RECREATE_MISSING, UPDATE_BLOB, NONE); break; case GIT_DELTA_ADDED: /* case 2 or 28 (and 5 but not really) */ *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE); break; case GIT_DELTA_MODIFIED: /* case 13 (and 35 but not really) */ *action = CHECKOUT_ACTION_IF(RECREATE_MISSING, UPDATE_BLOB, CONFLICT); break; case GIT_DELTA_TYPECHANGE: /* case 21 (B->T) and 28 (T->B)*/ if (delta->new_file.mode == GIT_FILEMODE_TREE) *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE); break; case GIT_DELTA_DELETED: /* case 8 or 25 */ *action = CHECKOUT_ACTION_IF(SAFE, REMOVE, NONE); break; default: /* impossible */ break; } return checkout_action_common(action, data, delta, NULL); } static bool wd_item_is_removable(git_iterator *iter, const git_index_entry *wd) { git_buf *full = NULL; if (wd->mode != GIT_FILEMODE_TREE) return true; if (git_iterator_current_workdir_path(&full, iter) < 0) return true; return !full || !git_path_contains(full, DOT_GIT); } static int checkout_queue_remove(checkout_data *data, const char *path) { char *copy = git_pool_strdup(&data->pool, path); GITERR_CHECK_ALLOC(copy); return git_vector_insert(&data->removes, copy); } /* note that this advances the iterator over the wd item */ static int checkout_action_wd_only( checkout_data *data, git_iterator *workdir, const git_index_entry **wditem, git_vector *pathspec) { int error = 0; bool remove = false; git_checkout_notify_t notify = GIT_CHECKOUT_NOTIFY_NONE; const git_index_entry *wd = *wditem; if (!git_pathspec__match( pathspec, wd->path, (data->strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH) != 0, git_iterator_ignore_case(workdir), NULL, NULL)) return git_iterator_advance(wditem, workdir); /* check if item is tracked in the index but not in the checkout diff */ if (data->index != NULL) { size_t pos; error = git_index__find_pos( &pos, data->index, wd->path, 0, GIT_INDEX_STAGE_ANY); if (wd->mode != GIT_FILEMODE_TREE) { if (!error) { /* found by git_index__find_pos call */ notify = GIT_CHECKOUT_NOTIFY_DIRTY; remove = ((data->strategy & GIT_CHECKOUT_FORCE) != 0); } else if (error != GIT_ENOTFOUND) return error; else error = 0; /* git_index__find_pos does not set error msg */ } else { /* for tree entries, we have to see if there are any index * entries that are contained inside that tree */ const git_index_entry *e = git_index_get_byindex(data->index, pos); if (e != NULL && data->diff->pfxcomp(e->path, wd->path) == 0) { notify = GIT_CHECKOUT_NOTIFY_DIRTY; remove = ((data->strategy & GIT_CHECKOUT_FORCE) != 0); } } } if (notify != GIT_CHECKOUT_NOTIFY_NONE) { /* if we found something in the index, notify and advance */ if ((error = checkout_notify(data, notify, NULL, wd)) != 0) return error; if (remove && wd_item_is_removable(workdir, wd)) error = checkout_queue_remove(data, wd->path); if (!error) error = git_iterator_advance(wditem, workdir); } else { /* untracked or ignored - can't know which until we advance through */ bool over = false, removable = wd_item_is_removable(workdir, wd); git_iterator_status_t untracked_state; /* copy the entry for issuing notification callback later */ git_index_entry saved_wd = *wd; git_buf_sets(&data->tmp, wd->path); saved_wd.path = data->tmp.ptr; error = git_iterator_advance_over_with_status( wditem, &untracked_state, workdir); if (error == GIT_ITEROVER) over = true; else if (error < 0) return error; if (untracked_state == GIT_ITERATOR_STATUS_IGNORED) { notify = GIT_CHECKOUT_NOTIFY_IGNORED; remove = ((data->strategy & GIT_CHECKOUT_REMOVE_IGNORED) != 0); } else { notify = GIT_CHECKOUT_NOTIFY_UNTRACKED; remove = ((data->strategy & GIT_CHECKOUT_REMOVE_UNTRACKED) != 0); } if ((error = checkout_notify(data, notify, NULL, &saved_wd)) != 0) return error; if (remove && removable) error = checkout_queue_remove(data, saved_wd.path); if (!error && over) /* restore ITEROVER if needed */ error = GIT_ITEROVER; } return error; } static bool submodule_is_config_only( checkout_data *data, const char *path) { git_submodule *sm = NULL; unsigned int sm_loc = 0; bool rval = false; if (git_submodule_lookup(&sm, data->repo, path) < 0) return true; if (git_submodule_location(&sm_loc, sm) < 0 || sm_loc == GIT_SUBMODULE_STATUS_IN_CONFIG) rval = true; git_submodule_free(sm); return rval; } static bool checkout_is_empty_dir(checkout_data *data, const char *path) { git_buf_truncate(&data->path, data->workdir_len); if (git_buf_puts(&data->path, path) < 0) return false; return git_path_is_empty_dir(data->path.ptr); } static int checkout_action_with_wd( int *action, checkout_data *data, const git_diff_delta *delta, git_iterator *workdir, const git_index_entry *wd) { *action = CHECKOUT_ACTION__NONE; switch (delta->status) { case GIT_DELTA_UNMODIFIED: /* case 14/15 or 33 */ if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd)) { GITERR_CHECK_ERROR( checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, wd) ); *action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, NONE); } break; case GIT_DELTA_ADDED: /* case 3, 4 or 6 */ if (git_iterator_current_is_ignored(workdir)) *action = CHECKOUT_ACTION_IF(DONT_OVERWRITE_IGNORED, CONFLICT, UPDATE_BLOB); else *action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, CONFLICT); break; case GIT_DELTA_DELETED: /* case 9 or 10 (or 26 but not really) */ if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd)) *action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT); else *action = CHECKOUT_ACTION_IF(SAFE, REMOVE, NONE); break; case GIT_DELTA_MODIFIED: /* case 16, 17, 18 (or 36 but not really) */ if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd)) *action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, CONFLICT); else *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE); break; case GIT_DELTA_TYPECHANGE: /* case 22, 23, 29, 30 */ if (delta->old_file.mode == GIT_FILEMODE_TREE) { if (wd->mode == GIT_FILEMODE_TREE) /* either deleting items in old tree will delete the wd dir, * or we'll get a conflict when we attempt blob update... */ *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE); else if (wd->mode == GIT_FILEMODE_COMMIT) { /* workdir is possibly a "phantom" submodule - treat as a * tree if the only submodule info came from the config */ if (submodule_is_config_only(data, wd->path)) *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE); else *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT); } else *action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT); } else if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd)) *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT); else *action = CHECKOUT_ACTION_IF(SAFE, REMOVE_AND_UPDATE, NONE); /* don't update if the typechange is to a tree */ if (delta->new_file.mode == GIT_FILEMODE_TREE) *action = (*action & ~CHECKOUT_ACTION__UPDATE_BLOB); break; default: /* impossible */ break; } return checkout_action_common(action, data, delta, wd); } static int checkout_action_with_wd_blocker( int *action, checkout_data *data, const git_diff_delta *delta, const git_index_entry *wd) { *action = CHECKOUT_ACTION__NONE; switch (delta->status) { case GIT_DELTA_UNMODIFIED: /* should show delta as dirty / deleted */ GITERR_CHECK_ERROR( checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, wd) ); *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, NONE); break; case GIT_DELTA_ADDED: case GIT_DELTA_MODIFIED: *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT); break; case GIT_DELTA_DELETED: *action = CHECKOUT_ACTION_IF(FORCE, REMOVE, CONFLICT); break; case GIT_DELTA_TYPECHANGE: /* not 100% certain about this... */ *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT); break; default: /* impossible */ break; } return checkout_action_common(action, data, delta, wd); } static int checkout_action_with_wd_dir( int *action, checkout_data *data, const git_diff_delta *delta, git_iterator *workdir, const git_index_entry *wd) { *action = CHECKOUT_ACTION__NONE; switch (delta->status) { case GIT_DELTA_UNMODIFIED: /* case 19 or 24 (or 34 but not really) */ GITERR_CHECK_ERROR( checkout_notify(data, GIT_CHECKOUT_NOTIFY_DIRTY, delta, NULL)); GITERR_CHECK_ERROR( checkout_notify(data, GIT_CHECKOUT_NOTIFY_UNTRACKED, NULL, wd)); *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, NONE); break; case GIT_DELTA_ADDED:/* case 4 (and 7 for dir) */ case GIT_DELTA_MODIFIED: /* case 20 (or 37 but not really) */ if (delta->old_file.mode == GIT_FILEMODE_COMMIT) /* expected submodule (and maybe found one) */; else if (delta->new_file.mode != GIT_FILEMODE_TREE) *action = git_iterator_current_is_ignored(workdir) ? CHECKOUT_ACTION_IF(DONT_OVERWRITE_IGNORED, CONFLICT, REMOVE_AND_UPDATE) : CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT); break; case GIT_DELTA_DELETED: /* case 11 (and 27 for dir) */ if (delta->old_file.mode != GIT_FILEMODE_TREE) GITERR_CHECK_ERROR( checkout_notify(data, GIT_CHECKOUT_NOTIFY_UNTRACKED, NULL, wd)); break; case GIT_DELTA_TYPECHANGE: /* case 24 or 31 */ if (delta->old_file.mode == GIT_FILEMODE_TREE) { /* For typechange from dir, remove dir and add blob, but it is * not safe to remove dir if it contains modified files. * However, safely removing child files will remove the parent * directory if is it left empty, so we can defer removing the * dir and it will succeed if no children are left. */ *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE); } else if (delta->new_file.mode != GIT_FILEMODE_TREE) /* For typechange to dir, dir is already created so no action */ *action = CHECKOUT_ACTION_IF(FORCE, REMOVE_AND_UPDATE, CONFLICT); break; default: /* impossible */ break; } return checkout_action_common(action, data, delta, wd); } static int checkout_action_with_wd_dir_empty( int *action, checkout_data *data, const git_diff_delta *delta) { int error = checkout_action_no_wd(action, data, delta); /* We can always safely remove an empty directory. */ if (error == 0 && *action != CHECKOUT_ACTION__NONE) *action |= CHECKOUT_ACTION__REMOVE; return error; } static int checkout_action( int *action, checkout_data *data, git_diff_delta *delta, git_iterator *workdir, const git_index_entry **wditem, git_vector *pathspec) { int cmp = -1, error; int (*strcomp)(const char *, const char *) = data->diff->strcomp; int (*pfxcomp)(const char *str, const char *pfx) = data->diff->pfxcomp; int (*advance)(const git_index_entry **, git_iterator *) = NULL; /* move workdir iterator to follow along with deltas */ while (1) { const git_index_entry *wd = *wditem; if (!wd) return checkout_action_no_wd(action, data, delta); cmp = strcomp(wd->path, delta->old_file.path); /* 1. wd before delta ("a/a" before "a/b") * 2. wd prefixes delta & should expand ("a/" before "a/b") * 3. wd prefixes delta & cannot expand ("a/b" before "a/b/c") * 4. wd equals delta ("a/b" and "a/b") * 5. wd after delta & delta prefixes wd ("a/b/c" after "a/b/" or "a/b") * 6. wd after delta ("a/c" after "a/b") */ if (cmp < 0) { cmp = pfxcomp(delta->old_file.path, wd->path); if (cmp == 0) { if (wd->mode == GIT_FILEMODE_TREE) { /* case 2 - entry prefixed by workdir tree */ error = git_iterator_advance_into_or_over(wditem, workdir); if (error < 0 && error != GIT_ITEROVER) goto done; continue; } /* case 3 maybe - wd contains non-dir where dir expected */ if (delta->old_file.path[strlen(wd->path)] == '/') { error = checkout_action_with_wd_blocker( action, data, delta, wd); advance = git_iterator_advance; goto done; } } /* case 1 - handle wd item (if it matches pathspec) */ error = checkout_action_wd_only(data, workdir, wditem, pathspec); if (error && error != GIT_ITEROVER) goto done; continue; } if (cmp == 0) { /* case 4 */ error = checkout_action_with_wd(action, data, delta, workdir, wd); advance = git_iterator_advance; goto done; } cmp = pfxcomp(wd->path, delta->old_file.path); if (cmp == 0) { /* case 5 */ if (wd->path[strlen(delta->old_file.path)] != '/') return checkout_action_no_wd(action, data, delta); if (delta->status == GIT_DELTA_TYPECHANGE) { if (delta->old_file.mode == GIT_FILEMODE_TREE) { error = checkout_action_with_wd(action, data, delta, workdir, wd); advance = git_iterator_advance_into; goto done; } if (delta->new_file.mode == GIT_FILEMODE_TREE || delta->new_file.mode == GIT_FILEMODE_COMMIT || delta->old_file.mode == GIT_FILEMODE_COMMIT) { error = checkout_action_with_wd(action, data, delta, workdir, wd); advance = git_iterator_advance; goto done; } } return checkout_is_empty_dir(data, wd->path) ? checkout_action_with_wd_dir_empty(action, data, delta) : checkout_action_with_wd_dir(action, data, delta, workdir, wd); } /* case 6 - wd is after delta */ return checkout_action_no_wd(action, data, delta); } done: if (!error && advance != NULL && (error = advance(wditem, workdir)) < 0) { *wditem = NULL; if (error == GIT_ITEROVER) error = 0; } return error; } static int checkout_remaining_wd_items( checkout_data *data, git_iterator *workdir, const git_index_entry *wd, git_vector *spec) { int error = 0; while (wd && !error) error = checkout_action_wd_only(data, workdir, &wd, spec); if (error == GIT_ITEROVER) error = 0; return error; } GIT_INLINE(int) checkout_idxentry_cmp( const git_index_entry *a, const git_index_entry *b) { if (!a && !b) return 0; else if (!a && b) return -1; else if(a && !b) return 1; else return strcmp(a->path, b->path); } static int checkout_conflictdata_cmp(const void *a, const void *b) { const checkout_conflictdata *ca = a; const checkout_conflictdata *cb = b; int diff; if ((diff = checkout_idxentry_cmp(ca->ancestor, cb->ancestor)) == 0 && (diff = checkout_idxentry_cmp(ca->ours, cb->theirs)) == 0) diff = checkout_idxentry_cmp(ca->theirs, cb->theirs); return diff; } int checkout_conflictdata_empty( const git_vector *conflicts, size_t idx, void *payload) { checkout_conflictdata *conflict; GIT_UNUSED(payload); if ((conflict = git_vector_get(conflicts, idx)) == NULL) return -1; if (conflict->ancestor || conflict->ours || conflict->theirs) return 0; git__free(conflict); return 1; } GIT_INLINE(bool) conflict_pathspec_match( checkout_data *data, git_iterator *workdir, git_vector *pathspec, const git_index_entry *ancestor, const git_index_entry *ours, const git_index_entry *theirs) { /* if the pathspec matches ours *or* theirs, proceed */ if (ours && git_pathspec__match(pathspec, ours->path, (data->strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH) != 0, git_iterator_ignore_case(workdir), NULL, NULL)) return true; if (theirs && git_pathspec__match(pathspec, theirs->path, (data->strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH) != 0, git_iterator_ignore_case(workdir), NULL, NULL)) return true; if (ancestor && git_pathspec__match(pathspec, ancestor->path, (data->strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH) != 0, git_iterator_ignore_case(workdir), NULL, NULL)) return true; return false; } GIT_INLINE(int) checkout_conflict_detect_submodule(checkout_conflictdata *conflict) { conflict->submodule = ((conflict->ancestor && S_ISGITLINK(conflict->ancestor->mode)) || (conflict->ours && S_ISGITLINK(conflict->ours->mode)) || (conflict->theirs && S_ISGITLINK(conflict->theirs->mode))); return 0; } GIT_INLINE(int) checkout_conflict_detect_binary(git_repository *repo, checkout_conflictdata *conflict) { git_blob *ancestor_blob = NULL, *our_blob = NULL, *their_blob = NULL; int error = 0; if (conflict->submodule) return 0; if (conflict->ancestor) { if ((error = git_blob_lookup(&ancestor_blob, repo, &conflict->ancestor->id)) < 0) goto done; conflict->binary = git_blob_is_binary(ancestor_blob); } if (!conflict->binary && conflict->ours) { if ((error = git_blob_lookup(&our_blob, repo, &conflict->ours->id)) < 0) goto done; conflict->binary = git_blob_is_binary(our_blob); } if (!conflict->binary && conflict->theirs) { if ((error = git_blob_lookup(&their_blob, repo, &conflict->theirs->id)) < 0) goto done; conflict->binary = git_blob_is_binary(their_blob); } done: git_blob_free(ancestor_blob); git_blob_free(our_blob); git_blob_free(their_blob); return error; } static int checkout_conflict_append_update( const git_index_entry *ancestor, const git_index_entry *ours, const git_index_entry *theirs, void *payload) { checkout_data *data = payload; checkout_conflictdata *conflict; int error; conflict = git__calloc(1, sizeof(checkout_conflictdata)); GITERR_CHECK_ALLOC(conflict); conflict->ancestor = ancestor; conflict->ours = ours; conflict->theirs = theirs; if ((error = checkout_conflict_detect_submodule(conflict)) < 0 || (error = checkout_conflict_detect_binary(data->repo, conflict)) < 0) { git__free(conflict); return error; } if (git_vector_insert(&data->update_conflicts, conflict)) return -1; return 0; } static int checkout_conflicts_foreach( checkout_data *data, git_index *index, git_iterator *workdir, git_vector *pathspec, int (*cb)(const git_index_entry *, const git_index_entry *, const git_index_entry *, void *), void *payload) { git_index_conflict_iterator *iterator = NULL; const git_index_entry *ancestor, *ours, *theirs; int error = 0; if ((error = git_index_conflict_iterator_new(&iterator, index)) < 0) goto done; /* Collect the conflicts */ while ((error = git_index_conflict_next(&ancestor, &ours, &theirs, iterator)) == 0) { if (!conflict_pathspec_match(data, workdir, pathspec, ancestor, ours, theirs)) continue; if ((error = cb(ancestor, ours, theirs, payload)) < 0) goto done; } if (error == GIT_ITEROVER) error = 0; done: git_index_conflict_iterator_free(iterator); return error; } static int checkout_conflicts_load(checkout_data *data, git_iterator *workdir, git_vector *pathspec) { git_index *index; /* Only write conficts from sources that have them: indexes. */ if ((index = git_iterator_get_index(data->target)) == NULL) return 0; data->update_conflicts._cmp = checkout_conflictdata_cmp; if (checkout_conflicts_foreach(data, index, workdir, pathspec, checkout_conflict_append_update, data) < 0) return -1; /* Collect the REUC and NAME entries */ data->update_reuc = &index->reuc; data->update_names = &index->names; return 0; } GIT_INLINE(int) checkout_conflicts_cmp_entry( const char *path, const git_index_entry *entry) { return strcmp((const char *)path, entry->path); } static int checkout_conflicts_cmp_ancestor(const void *p, const void *c) { const char *path = p; const checkout_conflictdata *conflict = c; if (!conflict->ancestor) return 1; return checkout_conflicts_cmp_entry(path, conflict->ancestor); } static checkout_conflictdata *checkout_conflicts_search_ancestor( checkout_data *data, const char *path) { size_t pos; if (git_vector_bsearch2(&pos, &data->update_conflicts, checkout_conflicts_cmp_ancestor, path) < 0) return NULL; return git_vector_get(&data->update_conflicts, pos); } static checkout_conflictdata *checkout_conflicts_search_branch( checkout_data *data, const char *path) { checkout_conflictdata *conflict; size_t i; git_vector_foreach(&data->update_conflicts, i, conflict) { int cmp = -1; if (conflict->ancestor) break; if (conflict->ours) cmp = checkout_conflicts_cmp_entry(path, conflict->ours); else if (conflict->theirs) cmp = checkout_conflicts_cmp_entry(path, conflict->theirs); if (cmp == 0) return conflict; } return NULL; } static int checkout_conflicts_load_byname_entry( checkout_conflictdata **ancestor_out, checkout_conflictdata **ours_out, checkout_conflictdata **theirs_out, checkout_data *data, const git_index_name_entry *name_entry) { checkout_conflictdata *ancestor, *ours = NULL, *theirs = NULL; int error = 0; *ancestor_out = NULL; *ours_out = NULL; *theirs_out = NULL; if (!name_entry->ancestor) { giterr_set(GITERR_INDEX, "A NAME entry exists without an ancestor"); error = -1; goto done; } if (!name_entry->ours && !name_entry->theirs) { giterr_set(GITERR_INDEX, "A NAME entry exists without an ours or theirs"); error = -1; goto done; } if ((ancestor = checkout_conflicts_search_ancestor(data, name_entry->ancestor)) == NULL) { giterr_set(GITERR_INDEX, "A NAME entry referenced ancestor entry '%s' which does not exist in the main index", name_entry->ancestor); error = -1; goto done; } if (name_entry->ours) { if (strcmp(name_entry->ancestor, name_entry->ours) == 0) ours = ancestor; else if ((ours = checkout_conflicts_search_branch(data, name_entry->ours)) == NULL || ours->ours == NULL) { giterr_set(GITERR_INDEX, "A NAME entry referenced our entry '%s' which does not exist in the main index", name_entry->ours); error = -1; goto done; } } if (name_entry->theirs) { if (strcmp(name_entry->ancestor, name_entry->theirs) == 0) theirs = ancestor; else if (name_entry->ours && strcmp(name_entry->ours, name_entry->theirs) == 0) theirs = ours; else if ((theirs = checkout_conflicts_search_branch(data, name_entry->theirs)) == NULL || theirs->theirs == NULL) { giterr_set(GITERR_INDEX, "A NAME entry referenced their entry '%s' which does not exist in the main index", name_entry->theirs); error = -1; goto done; } } *ancestor_out = ancestor; *ours_out = ours; *theirs_out = theirs; done: return error; } static int checkout_conflicts_coalesce_renames( checkout_data *data) { git_index *index; const git_index_name_entry *name_entry; checkout_conflictdata *ancestor_conflict, *our_conflict, *their_conflict; size_t i, names; int error = 0; if ((index = git_iterator_get_index(data->target)) == NULL) return 0; /* Juggle entries based on renames */ names = git_index_name_entrycount(index); for (i = 0; i < names; i++) { name_entry = git_index_name_get_byindex(index, i); if ((error = checkout_conflicts_load_byname_entry( &ancestor_conflict, &our_conflict, &their_conflict, data, name_entry)) < 0) goto done; if (our_conflict && our_conflict != ancestor_conflict) { ancestor_conflict->ours = our_conflict->ours; our_conflict->ours = NULL; if (our_conflict->theirs) our_conflict->name_collision = 1; if (our_conflict->name_collision) ancestor_conflict->name_collision = 1; } if (their_conflict && their_conflict != ancestor_conflict) { ancestor_conflict->theirs = their_conflict->theirs; their_conflict->theirs = NULL; if (their_conflict->ours) their_conflict->name_collision = 1; if (their_conflict->name_collision) ancestor_conflict->name_collision = 1; } if (our_conflict && our_conflict != ancestor_conflict && their_conflict && their_conflict != ancestor_conflict) ancestor_conflict->one_to_two = 1; } git_vector_remove_matching( &data->update_conflicts, checkout_conflictdata_empty, NULL); done: return error; } static int checkout_conflicts_mark_directoryfile( checkout_data *data) { git_index *index; checkout_conflictdata *conflict; const git_index_entry *entry; size_t i, j, len; const char *path; int prefixed, error = 0; if ((index = git_iterator_get_index(data->target)) == NULL) return 0; len = git_index_entrycount(index); /* Find d/f conflicts */ git_vector_foreach(&data->update_conflicts, i, conflict) { if ((conflict->ours && conflict->theirs) || (!conflict->ours && !conflict->theirs)) continue; path = conflict->ours ? conflict->ours->path : conflict->theirs->path; if ((error = git_index_find(&j, index, path)) < 0) { if (error == GIT_ENOTFOUND) giterr_set(GITERR_INDEX, "Index inconsistency, could not find entry for expected conflict '%s'", path); goto done; } for (; j < len; j++) { if ((entry = git_index_get_byindex(index, j)) == NULL) { giterr_set(GITERR_INDEX, "Index inconsistency, truncated index while loading expected conflict '%s'", path); error = -1; goto done; } prefixed = git_path_equal_or_prefixed(path, entry->path, NULL); if (prefixed == GIT_PATH_EQUAL) continue; if (prefixed == GIT_PATH_PREFIX) conflict->directoryfile = 1; break; } } done: return error; } static int checkout_get_update_conflicts( checkout_data *data, git_iterator *workdir, git_vector *pathspec) { int error = 0; if (data->strategy & GIT_CHECKOUT_SKIP_UNMERGED) return 0; if ((error = checkout_conflicts_load(data, workdir, pathspec)) < 0 || (error = checkout_conflicts_coalesce_renames(data)) < 0 || (error = checkout_conflicts_mark_directoryfile(data)) < 0) goto done; done: return error; } static int checkout_conflict_append_remove( const git_index_entry *ancestor, const git_index_entry *ours, const git_index_entry *theirs, void *payload) { checkout_data *data = payload; const char *name; assert(ancestor || ours || theirs); if (ancestor) name = git__strdup(ancestor->path); else if (ours) name = git__strdup(ours->path); else if (theirs) name = git__strdup(theirs->path); else abort(); GITERR_CHECK_ALLOC(name); return git_vector_insert(&data->remove_conflicts, (char *)name); } static int checkout_get_remove_conflicts( checkout_data *data, git_iterator *workdir, git_vector *pathspec) { if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) != 0) return 0; return checkout_conflicts_foreach(data, data->index, workdir, pathspec, checkout_conflict_append_remove, data); } static int checkout_verify_paths( git_repository *repo, int action, git_diff_delta *delta) { unsigned int flags = GIT_PATH_REJECT_DEFAULTS | GIT_PATH_REJECT_DOT_GIT; if (action & CHECKOUT_ACTION__REMOVE) { if (!git_path_isvalid(repo, delta->old_file.path, flags)) { giterr_set(GITERR_CHECKOUT, "Cannot remove invalid path '%s'", delta->old_file.path); return -1; } } if (action & ~CHECKOUT_ACTION__REMOVE) { if (!git_path_isvalid(repo, delta->new_file.path, flags)) { giterr_set(GITERR_CHECKOUT, "Cannot checkout to invalid path '%s'", delta->new_file.path); return -1; } } return 0; } static int checkout_get_actions( uint32_t **actions_ptr, size_t **counts_ptr, checkout_data *data, git_iterator *workdir) { int error = 0, act; const git_index_entry *wditem; git_vector pathspec = GIT_VECTOR_INIT, *deltas; git_pool pathpool = GIT_POOL_INIT_STRINGPOOL; git_diff_delta *delta; size_t i, *counts = NULL; uint32_t *actions = NULL; if (data->opts.paths.count > 0 && git_pathspec__vinit(&pathspec, &data->opts.paths, &pathpool) < 0) return -1; if ((error = git_iterator_current(&wditem, workdir)) < 0 && error != GIT_ITEROVER) goto fail; deltas = &data->diff->deltas; *counts_ptr = counts = git__calloc(CHECKOUT_ACTION__MAX+1, sizeof(size_t)); *actions_ptr = actions = git__calloc( deltas->length ? deltas->length : 1, sizeof(uint32_t)); if (!counts || !actions) { error = -1; goto fail; } git_vector_foreach(deltas, i, delta) { if ((error = checkout_action(&act, data, delta, workdir, &wditem, &pathspec)) == 0) error = checkout_verify_paths(data->repo, act, delta); if (error != 0) goto fail; actions[i] = act; if (act & CHECKOUT_ACTION__REMOVE) counts[CHECKOUT_ACTION__REMOVE]++; if (act & CHECKOUT_ACTION__UPDATE_BLOB) counts[CHECKOUT_ACTION__UPDATE_BLOB]++; if (act & CHECKOUT_ACTION__UPDATE_SUBMODULE) counts[CHECKOUT_ACTION__UPDATE_SUBMODULE]++; if (act & CHECKOUT_ACTION__CONFLICT) counts[CHECKOUT_ACTION__CONFLICT]++; } error = checkout_remaining_wd_items(data, workdir, wditem, &pathspec); if (error) goto fail; counts[CHECKOUT_ACTION__REMOVE] += data->removes.length; if (counts[CHECKOUT_ACTION__CONFLICT] > 0 && (data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) == 0) { giterr_set(GITERR_CHECKOUT, "%"PRIuZ" %s checkout", counts[CHECKOUT_ACTION__CONFLICT], counts[CHECKOUT_ACTION__CONFLICT] == 1 ? "conflict prevents" : "conflicts prevent"); error = GIT_ECONFLICT; goto fail; } if ((error = checkout_get_remove_conflicts(data, workdir, &pathspec)) < 0 || (error = checkout_get_update_conflicts(data, workdir, &pathspec)) < 0) goto fail; counts[CHECKOUT_ACTION__REMOVE_CONFLICT] = git_vector_length(&data->remove_conflicts); counts[CHECKOUT_ACTION__UPDATE_CONFLICT] = git_vector_length(&data->update_conflicts); git_pathspec__vfree(&pathspec); git_pool_clear(&pathpool); return 0; fail: *counts_ptr = NULL; git__free(counts); *actions_ptr = NULL; git__free(actions); git_pathspec__vfree(&pathspec); git_pool_clear(&pathpool); return error; } static bool should_remove_existing(checkout_data *data) { int ignorecase = 0; git_repository__cvar(&ignorecase, data->repo, GIT_CVAR_IGNORECASE); return (ignorecase && (data->strategy & GIT_CHECKOUT_DONT_REMOVE_EXISTING) == 0); } #define MKDIR_NORMAL \ GIT_MKDIR_PATH | GIT_MKDIR_VERIFY_DIR #define MKDIR_REMOVE_EXISTING \ MKDIR_NORMAL | GIT_MKDIR_REMOVE_FILES | GIT_MKDIR_REMOVE_SYMLINKS static int checkout_mkdir( checkout_data *data, const char *path, const char *base, mode_t mode, unsigned int flags) { struct git_futils_mkdir_options mkdir_opts = {0}; int error; mkdir_opts.dir_map = data->mkdir_map; mkdir_opts.pool = &data->pool; error = git_futils_mkdir_relative( path, base, mode, flags, &mkdir_opts); data->perfdata.mkdir_calls += mkdir_opts.perfdata.mkdir_calls; data->perfdata.stat_calls += mkdir_opts.perfdata.stat_calls; data->perfdata.chmod_calls += mkdir_opts.perfdata.chmod_calls; return error; } static int mkpath2file( checkout_data *data, const char *path, unsigned int mode) { struct stat st; bool remove_existing = should_remove_existing(data); unsigned int flags = (remove_existing ? MKDIR_REMOVE_EXISTING : MKDIR_NORMAL) | GIT_MKDIR_SKIP_LAST; int error; if ((error = checkout_mkdir( data, path, data->opts.target_directory, mode, flags)) < 0) return error; if (remove_existing) { data->perfdata.stat_calls++; if (p_lstat(path, &st) == 0) { /* Some file, symlink or folder already exists at this name. * We would have removed it in remove_the_old unless we're on * a case inensitive filesystem (or the user has asked us not * to). Remove the similarly named file to write the new. */ error = git_futils_rmdir_r(path, NULL, GIT_RMDIR_REMOVE_FILES); } else if (errno != ENOENT) { giterr_set(GITERR_OS, "Failed to stat file '%s'", path); return GIT_EEXISTS; } else { giterr_clear(); } } return error; } struct checkout_stream { git_writestream base; const char *path; int fd; int open; }; static int checkout_stream_write( git_writestream *s, const char *buffer, size_t len) { struct checkout_stream *stream = (struct checkout_stream *)s; int ret; if ((ret = p_write(stream->fd, buffer, len)) < 0) giterr_set(GITERR_OS, "Could not write to '%s'", stream->path); return ret; } static int checkout_stream_close(git_writestream *s) { struct checkout_stream *stream = (struct checkout_stream *)s; assert(stream && stream->open); stream->open = 0; return p_close(stream->fd); } static void checkout_stream_free(git_writestream *s) { GIT_UNUSED(s); } static int blob_content_to_file( checkout_data *data, struct stat *st, git_blob *blob, const char *path, const char *hint_path, mode_t entry_filemode) { int flags = data->opts.file_open_flags; mode_t file_mode = data->opts.file_mode ? data->opts.file_mode : entry_filemode; git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT; struct checkout_stream writer; mode_t mode; git_filter_list *fl = NULL; int fd; int error = 0; if (hint_path == NULL) hint_path = path; if ((error = mkpath2file(data, path, data->opts.dir_mode)) < 0) return error; if (flags <= 0) flags = O_CREAT | O_TRUNC | O_WRONLY; if (!(mode = file_mode)) mode = GIT_FILEMODE_BLOB; if ((fd = p_open(path, flags, mode)) < 0) { giterr_set(GITERR_OS, "Could not open '%s' for writing", path); return fd; } filter_opts.attr_session = &data->attr_session; filter_opts.temp_buf = &data->tmp; if (!data->opts.disable_filters && (error = git_filter_list__load_ext( &fl, data->repo, blob, hint_path, GIT_FILTER_TO_WORKTREE, &filter_opts))) return error; /* setup the writer */ memset(&writer, 0, sizeof(struct checkout_stream)); writer.base.write = checkout_stream_write; writer.base.close = checkout_stream_close; writer.base.free = checkout_stream_free; writer.path = path; writer.fd = fd; writer.open = 1; error = git_filter_list_stream_blob(fl, blob, &writer.base); assert(writer.open == 0); git_filter_list_free(fl); if (error < 0) return error; if (st) { data->perfdata.stat_calls++; if ((error = p_stat(path, st)) < 0) { giterr_set(GITERR_OS, "Error statting '%s'", path); return error; } st->st_mode = entry_filemode; } return 0; } static int blob_content_to_link( checkout_data *data, struct stat *st, git_blob *blob, const char *path) { git_buf linktarget = GIT_BUF_INIT; int error; if ((error = mkpath2file(data, path, data->opts.dir_mode)) < 0) return error; if ((error = git_blob__getbuf(&linktarget, blob)) < 0) return error; if (data->can_symlink) { if ((error = p_symlink(git_buf_cstr(&linktarget), path)) < 0) giterr_set(GITERR_OS, "Could not create symlink %s", path); } else { error = git_futils_fake_symlink(git_buf_cstr(&linktarget), path); } if (!error) { data->perfdata.stat_calls++; if ((error = p_lstat(path, st)) < 0) giterr_set(GITERR_CHECKOUT, "Could not stat symlink %s", path); st->st_mode = GIT_FILEMODE_LINK; } git_buf_free(&linktarget); return error; } static int checkout_update_index( checkout_data *data, const git_diff_file *file, struct stat *st) { git_index_entry entry; if (!data->index) return 0; memset(&entry, 0, sizeof(entry)); entry.path = (char *)file->path; /* cast to prevent warning */ git_index_entry__init_from_stat(&entry, st, true); git_oid_cpy(&entry.id, &file->id); return git_index_add(data->index, &entry); } static int checkout_submodule_update_index( checkout_data *data, const git_diff_file *file) { struct stat st; /* update the index unless prevented */ if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) != 0) return 0; git_buf_truncate(&data->path, data->workdir_len); if (git_buf_puts(&data->path, file->path) < 0) return -1; data->perfdata.stat_calls++; if (p_stat(git_buf_cstr(&data->path), &st) < 0) { giterr_set( GITERR_CHECKOUT, "Could not stat submodule %s\n", file->path); return GIT_ENOTFOUND; } st.st_mode = GIT_FILEMODE_COMMIT; return checkout_update_index(data, file, &st); } static int checkout_submodule( checkout_data *data, const git_diff_file *file) { bool remove_existing = should_remove_existing(data); int error = 0; /* Until submodules are supported, UPDATE_ONLY means do nothing here */ if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0) return 0; if ((error = checkout_mkdir( data, file->path, data->opts.target_directory, data->opts.dir_mode, remove_existing ? MKDIR_REMOVE_EXISTING : MKDIR_NORMAL)) < 0) return error; if ((error = git_submodule_lookup(NULL, data->repo, file->path)) < 0) { /* I've observed repos with submodules in the tree that do not * have a .gitmodules - core Git just makes an empty directory */ if (error == GIT_ENOTFOUND) { giterr_clear(); return checkout_submodule_update_index(data, file); } return error; } /* TODO: Support checkout_strategy options. Two circumstances: * 1 - submodule already checked out, but we need to move the HEAD * to the new OID, or * 2 - submodule not checked out and we should recursively check it out * * Checkout will not execute a pull on the submodule, but a clone * command should probably be able to. Do we need a submodule callback? */ return checkout_submodule_update_index(data, file); } static void report_progress( checkout_data *data, const char *path) { if (data->opts.progress_cb) data->opts.progress_cb( path, data->completed_steps, data->total_steps, data->opts.progress_payload); } static int checkout_safe_for_update_only( checkout_data *data, const char *path, mode_t expected_mode) { struct stat st; data->perfdata.stat_calls++; if (p_lstat(path, &st) < 0) { /* if doesn't exist, then no error and no update */ if (errno == ENOENT || errno == ENOTDIR) return 0; /* otherwise, stat error and no update */ giterr_set(GITERR_OS, "Failed to stat file '%s'", path); return -1; } /* only safe for update if this is the same type of file */ if ((st.st_mode & ~0777) == (expected_mode & ~0777)) return 1; return 0; } static int checkout_write_content( checkout_data *data, const git_oid *oid, const char *full_path, const char *hint_path, unsigned int mode, struct stat *st) { int error = 0; git_blob *blob; if ((error = git_blob_lookup(&blob, data->repo, oid)) < 0) return error; if (S_ISLNK(mode)) error = blob_content_to_link(data, st, blob, full_path); else error = blob_content_to_file(data, st, blob, full_path, hint_path, mode); git_blob_free(blob); /* if we try to create the blob and an existing directory blocks it from * being written, then there must have been a typechange conflict in a * parent directory - suppress the error and try to continue. */ if ((data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) != 0 && (error == GIT_ENOTFOUND || error == GIT_EEXISTS)) { giterr_clear(); error = 0; } return error; } static int checkout_blob( checkout_data *data, const git_diff_file *file) { int error = 0; struct stat st; git_buf_truncate(&data->path, data->workdir_len); if (git_buf_puts(&data->path, file->path) < 0) return -1; if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0) { int rval = checkout_safe_for_update_only( data, git_buf_cstr(&data->path), file->mode); if (rval <= 0) return rval; } error = checkout_write_content( data, &file->id, git_buf_cstr(&data->path), NULL, file->mode, &st); /* update the index unless prevented */ if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0) error = checkout_update_index(data, file, &st); /* update the submodule data if this was a new .gitmodules file */ if (!error && strcmp(file->path, ".gitmodules") == 0) data->reload_submodules = true; return error; } static int checkout_remove_the_old( unsigned int *actions, checkout_data *data) { int error = 0; git_diff_delta *delta; const char *str; size_t i; const char *workdir = git_buf_cstr(&data->path); uint32_t flg = GIT_RMDIR_EMPTY_PARENTS | GIT_RMDIR_REMOVE_FILES | GIT_RMDIR_REMOVE_BLOCKERS; if (data->opts.checkout_strategy & GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES) flg |= GIT_RMDIR_SKIP_NONEMPTY; git_buf_truncate(&data->path, data->workdir_len); git_vector_foreach(&data->diff->deltas, i, delta) { if (actions[i] & CHECKOUT_ACTION__REMOVE) { error = git_futils_rmdir_r(delta->old_file.path, workdir, flg); if (error < 0) return error; data->completed_steps++; report_progress(data, delta->old_file.path); if ((actions[i] & CHECKOUT_ACTION__UPDATE_BLOB) == 0 && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0 && data->index != NULL) { (void)git_index_remove(data->index, delta->old_file.path, 0); } } } git_vector_foreach(&data->removes, i, str) { error = git_futils_rmdir_r(str, workdir, flg); if (error < 0) return error; data->completed_steps++; report_progress(data, str); if ((data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0 && data->index != NULL) { if (str[strlen(str) - 1] == '/') (void)git_index_remove_directory(data->index, str, 0); else (void)git_index_remove(data->index, str, 0); } } return 0; } static int checkout_deferred_remove(git_repository *repo, const char *path) { #if 0 int error = git_futils_rmdir_r( path, data->opts.target_directory, GIT_RMDIR_EMPTY_PARENTS); if (error == GIT_ENOTFOUND) { error = 0; giterr_clear(); } return error; #else GIT_UNUSED(repo); GIT_UNUSED(path); assert(false); return 0; #endif } static int checkout_create_the_new( unsigned int *actions, checkout_data *data) { int error = 0; git_diff_delta *delta; size_t i; git_vector_foreach(&data->diff->deltas, i, delta) { if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) { /* this had a blocker directory that should only be removed iff * all of the contents of the directory were safely removed */ if ((error = checkout_deferred_remove( data->repo, delta->old_file.path)) < 0) return error; } if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB) { error = checkout_blob(data, &delta->new_file); if (error < 0) return error; data->completed_steps++; report_progress(data, delta->new_file.path); } } return 0; } static int checkout_create_submodules( unsigned int *actions, checkout_data *data) { int error = 0; git_diff_delta *delta; size_t i; git_vector_foreach(&data->diff->deltas, i, delta) { if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) { /* this has a blocker directory that should only be removed iff * all of the contents of the directory were safely removed */ if ((error = checkout_deferred_remove( data->repo, delta->old_file.path)) < 0) return error; } if (actions[i] & CHECKOUT_ACTION__UPDATE_SUBMODULE) { int error = checkout_submodule(data, &delta->new_file); if (error < 0) return error; data->completed_steps++; report_progress(data, delta->new_file.path); } } return 0; } static int checkout_lookup_head_tree(git_tree **out, git_repository *repo) { int error = 0; git_reference *ref = NULL; git_object *head; if (!(error = git_repository_head(&ref, repo)) && !(error = git_reference_peel(&head, ref, GIT_OBJ_TREE))) *out = (git_tree *)head; git_reference_free(ref); return error; } static int conflict_entry_name( git_buf *out, const char *side_name, const char *filename) { if (git_buf_puts(out, side_name) < 0 || git_buf_putc(out, ':') < 0 || git_buf_puts(out, filename) < 0) return -1; return 0; } static int checkout_path_suffixed(git_buf *path, const char *suffix) { size_t path_len; int i = 0, error = 0; if ((error = git_buf_putc(path, '~')) < 0 || (error = git_buf_puts(path, suffix)) < 0) return -1; path_len = git_buf_len(path); while (git_path_exists(git_buf_cstr(path)) && i < INT_MAX) { git_buf_truncate(path, path_len); if ((error = git_buf_putc(path, '_')) < 0 || (error = git_buf_printf(path, "%d", i)) < 0) return error; i++; } if (i == INT_MAX) { git_buf_truncate(path, path_len); giterr_set(GITERR_CHECKOUT, "Could not write '%s': working directory file exists", path); return GIT_EEXISTS; } return 0; } static int checkout_write_entry( checkout_data *data, checkout_conflictdata *conflict, const git_index_entry *side) { const char *hint_path = NULL, *suffix; struct stat st; int error; assert (side == conflict->ours || side == conflict->theirs); git_buf_truncate(&data->path, data->workdir_len); if (git_buf_puts(&data->path, side->path) < 0) return -1; if ((conflict->name_collision || conflict->directoryfile) && (data->strategy & GIT_CHECKOUT_USE_OURS) == 0 && (data->strategy & GIT_CHECKOUT_USE_THEIRS) == 0) { if (side == conflict->ours) suffix = data->opts.our_label ? data->opts.our_label : "ours"; else suffix = data->opts.their_label ? data->opts.their_label : "theirs"; if (checkout_path_suffixed(&data->path, suffix) < 0) return -1; hint_path = side->path; } if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 && (error = checkout_safe_for_update_only(data, git_buf_cstr(&data->path), side->mode)) <= 0) return error; return checkout_write_content(data, &side->id, git_buf_cstr(&data->path), hint_path, side->mode, &st); } static int checkout_write_entries( checkout_data *data, checkout_conflictdata *conflict) { int error = 0; if ((error = checkout_write_entry(data, conflict, conflict->ours)) >= 0) error = checkout_write_entry(data, conflict, conflict->theirs); return error; } static int checkout_merge_path( git_buf *out, checkout_data *data, checkout_conflictdata *conflict, git_merge_file_result *result) { const char *our_label_raw, *their_label_raw, *suffix; int error = 0; if ((error = git_buf_joinpath(out, git_repository_workdir(data->repo), result->path)) < 0) return error; /* Most conflicts simply use the filename in the index */ if (!conflict->name_collision) return 0; /* Rename 2->1 conflicts need the branch name appended */ our_label_raw = data->opts.our_label ? data->opts.our_label : "ours"; their_label_raw = data->opts.their_label ? data->opts.their_label : "theirs"; suffix = strcmp(result->path, conflict->ours->path) == 0 ? our_label_raw : their_label_raw; if ((error = checkout_path_suffixed(out, suffix)) < 0) return error; return 0; } static int checkout_write_merge( checkout_data *data, checkout_conflictdata *conflict) { git_buf our_label = GIT_BUF_INIT, their_label = GIT_BUF_INIT, path_suffixed = GIT_BUF_INIT, path_workdir = GIT_BUF_INIT, in_data = GIT_BUF_INIT, out_data = GIT_BUF_INIT; git_merge_file_options opts = GIT_MERGE_FILE_OPTIONS_INIT; git_merge_file_result result = {0}; git_filebuf output = GIT_FILEBUF_INIT; git_filter_list *fl = NULL; git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT; int error = 0; if (data->opts.checkout_strategy & GIT_CHECKOUT_CONFLICT_STYLE_DIFF3) opts.flags |= GIT_MERGE_FILE_STYLE_DIFF3; opts.ancestor_label = data->opts.ancestor_label ? data->opts.ancestor_label : "ancestor"; opts.our_label = data->opts.our_label ? data->opts.our_label : "ours"; opts.their_label = data->opts.their_label ? data->opts.their_label : "theirs"; /* If all the paths are identical, decorate the diff3 file with the branch * names. Otherwise, append branch_name:path. */ if (conflict->ours && conflict->theirs && strcmp(conflict->ours->path, conflict->theirs->path) != 0) { if ((error = conflict_entry_name( &our_label, opts.our_label, conflict->ours->path)) < 0 || (error = conflict_entry_name( &their_label, opts.their_label, conflict->theirs->path)) < 0) goto done; opts.our_label = git_buf_cstr(&our_label); opts.their_label = git_buf_cstr(&their_label); } if ((error = git_merge_file_from_index(&result, data->repo, conflict->ancestor, conflict->ours, conflict->theirs, &opts)) < 0) goto done; if (result.path == NULL || result.mode == 0) { giterr_set(GITERR_CHECKOUT, "Could not merge contents of file"); error = GIT_ECONFLICT; goto done; } if ((error = checkout_merge_path(&path_workdir, data, conflict, &result)) < 0) goto done; if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 && (error = checkout_safe_for_update_only(data, git_buf_cstr(&path_workdir), result.mode)) <= 0) goto done; if (!data->opts.disable_filters) { in_data.ptr = (char *)result.ptr; in_data.size = result.len; filter_opts.attr_session = &data->attr_session; filter_opts.temp_buf = &data->tmp; if ((error = git_filter_list__load_ext( &fl, data->repo, NULL, git_buf_cstr(&path_workdir), GIT_FILTER_TO_WORKTREE, &filter_opts)) < 0 || (error = git_filter_list_apply_to_data(&out_data, fl, &in_data)) < 0) goto done; } else { out_data.ptr = (char *)result.ptr; out_data.size = result.len; } if ((error = mkpath2file(data, path_workdir.ptr, data->opts.dir_mode)) < 0 || (error = git_filebuf_open(&output, git_buf_cstr(&path_workdir), GIT_FILEBUF_DO_NOT_BUFFER, result.mode)) < 0 || (error = git_filebuf_write(&output, out_data.ptr, out_data.size)) < 0 || (error = git_filebuf_commit(&output)) < 0) goto done; done: git_filter_list_free(fl); git_buf_free(&out_data); git_buf_free(&our_label); git_buf_free(&their_label); git_merge_file_result_free(&result); git_buf_free(&path_workdir); git_buf_free(&path_suffixed); return error; } static int checkout_conflict_add( checkout_data *data, const git_index_entry *conflict) { int error = git_index_remove(data->index, conflict->path, 0); if (error == GIT_ENOTFOUND) giterr_clear(); else if (error < 0) return error; return git_index_add(data->index, conflict); } static int checkout_conflict_update_index( checkout_data *data, checkout_conflictdata *conflict) { int error = 0; if (conflict->ancestor) error = checkout_conflict_add(data, conflict->ancestor); if (!error && conflict->ours) error = checkout_conflict_add(data, conflict->ours); if (!error && conflict->theirs) error = checkout_conflict_add(data, conflict->theirs); return error; } static int checkout_create_conflicts(checkout_data *data) { checkout_conflictdata *conflict; size_t i; int error = 0; git_vector_foreach(&data->update_conflicts, i, conflict) { /* Both deleted: nothing to do */ if (conflict->ours == NULL && conflict->theirs == NULL) error = 0; else if ((data->strategy & GIT_CHECKOUT_USE_OURS) && conflict->ours) error = checkout_write_entry(data, conflict, conflict->ours); else if ((data->strategy & GIT_CHECKOUT_USE_THEIRS) && conflict->theirs) error = checkout_write_entry(data, conflict, conflict->theirs); /* Ignore the other side of name collisions. */ else if ((data->strategy & GIT_CHECKOUT_USE_OURS) && !conflict->ours && conflict->name_collision) error = 0; else if ((data->strategy & GIT_CHECKOUT_USE_THEIRS) && !conflict->theirs && conflict->name_collision) error = 0; /* For modify/delete, name collisions and d/f conflicts, write * the file (potentially with the name mangled. */ else if (conflict->ours != NULL && conflict->theirs == NULL) error = checkout_write_entry(data, conflict, conflict->ours); else if (conflict->ours == NULL && conflict->theirs != NULL) error = checkout_write_entry(data, conflict, conflict->theirs); /* Add/add conflicts and rename 1->2 conflicts, write the * ours/theirs sides (potentially name mangled). */ else if (conflict->one_to_two) error = checkout_write_entries(data, conflict); /* If all sides are links, write the ours side */ else if (S_ISLNK(conflict->ours->mode) && S_ISLNK(conflict->theirs->mode)) error = checkout_write_entry(data, conflict, conflict->ours); /* Link/file conflicts, write the file side */ else if (S_ISLNK(conflict->ours->mode)) error = checkout_write_entry(data, conflict, conflict->theirs); else if (S_ISLNK(conflict->theirs->mode)) error = checkout_write_entry(data, conflict, conflict->ours); /* If any side is a gitlink, do nothing. */ else if (conflict->submodule) error = 0; /* If any side is binary, write the ours side */ else if (conflict->binary) error = checkout_write_entry(data, conflict, conflict->ours); else if (!error) error = checkout_write_merge(data, conflict); /* Update the index extensions (REUC and NAME) if we're checking * out a different index. (Otherwise just leave them there.) */ if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0) error = checkout_conflict_update_index(data, conflict); if (error) break; data->completed_steps++; report_progress(data, conflict->ours ? conflict->ours->path : (conflict->theirs ? conflict->theirs->path : conflict->ancestor->path)); } return error; } static int checkout_remove_conflicts(checkout_data *data) { const char *conflict; size_t i; git_vector_foreach(&data->remove_conflicts, i, conflict) { if (git_index_conflict_remove(data->index, conflict) < 0) return -1; data->completed_steps++; } return 0; } static int checkout_extensions_update_index(checkout_data *data) { const git_index_reuc_entry *reuc_entry; const git_index_name_entry *name_entry; size_t i; int error = 0; if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0) return 0; if (data->update_reuc) { git_vector_foreach(data->update_reuc, i, reuc_entry) { if ((error = git_index_reuc_add(data->index, reuc_entry->path, reuc_entry->mode[0], &reuc_entry->oid[0], reuc_entry->mode[1], &reuc_entry->oid[1], reuc_entry->mode[2], &reuc_entry->oid[2])) < 0) goto done; } } if (data->update_names) { git_vector_foreach(data->update_names, i, name_entry) { if ((error = git_index_name_add(data->index, name_entry->ancestor, name_entry->ours, name_entry->theirs)) < 0) goto done; } } done: return error; } static void checkout_data_clear(checkout_data *data) { if (data->opts_free_baseline) { git_tree_free(data->opts.baseline); data->opts.baseline = NULL; } git_vector_free(&data->removes); git_pool_clear(&data->pool); git_vector_free_deep(&data->remove_conflicts); git_vector_free_deep(&data->update_conflicts); git__free(data->pfx); data->pfx = NULL; git_strmap_free(data->mkdir_map); git_buf_free(&data->path); git_buf_free(&data->tmp); git_index_free(data->index); data->index = NULL; git_strmap_free(data->mkdir_map); git_attr_session__free(&data->attr_session); } static int checkout_data_init( checkout_data *data, git_iterator *target, const git_checkout_options *proposed) { int error = 0; git_repository *repo = git_iterator_owner(target); memset(data, 0, sizeof(*data)); if (!repo) { giterr_set(GITERR_CHECKOUT, "Cannot checkout nothing"); return -1; } if ((!proposed || !proposed->target_directory) && (error = git_repository__ensure_not_bare(repo, "checkout")) < 0) return error; data->repo = repo; data->target = target; GITERR_CHECK_VERSION( proposed, GIT_CHECKOUT_OPTIONS_VERSION, "git_checkout_options"); if (!proposed) GIT_INIT_STRUCTURE(&data->opts, GIT_CHECKOUT_OPTIONS_VERSION); else memmove(&data->opts, proposed, sizeof(git_checkout_options)); if (!data->opts.target_directory) data->opts.target_directory = git_repository_workdir(repo); else if (!git_path_isdir(data->opts.target_directory) && (error = checkout_mkdir(data, data->opts.target_directory, NULL, GIT_DIR_MODE, GIT_MKDIR_VERIFY_DIR)) < 0) goto cleanup; /* refresh config and index content unless NO_REFRESH is given */ if ((data->opts.checkout_strategy & GIT_CHECKOUT_NO_REFRESH) == 0) { git_config *cfg; if ((error = git_repository_config__weakptr(&cfg, repo)) < 0) goto cleanup; /* Get the repository index and reload it (unless we're checking * out the index; then it has the changes we're trying to check * out and those should not be overwritten.) */ if ((error = git_repository_index(&data->index, data->repo)) < 0) goto cleanup; if (data->index != git_iterator_get_index(target)) { if ((error = git_index_read(data->index, true)) < 0) goto cleanup; /* cannot checkout if unresolved conflicts exist */ if ((data->opts.checkout_strategy & GIT_CHECKOUT_FORCE) == 0 && git_index_has_conflicts(data->index)) { error = GIT_ECONFLICT; giterr_set(GITERR_CHECKOUT, "unresolved conflicts exist in the index"); goto cleanup; } /* clean conflict data in the current index */ git_index_name_clear(data->index); git_index_reuc_clear(data->index); } } /* if you are forcing, allow all safe updates, plus recreate missing */ if ((data->opts.checkout_strategy & GIT_CHECKOUT_FORCE) != 0) data->opts.checkout_strategy |= GIT_CHECKOUT_SAFE | GIT_CHECKOUT_RECREATE_MISSING; /* if the repository does not actually have an index file, then this * is an initial checkout (perhaps from clone), so we allow safe updates */ if (!data->index->on_disk && (data->opts.checkout_strategy & GIT_CHECKOUT_SAFE) != 0) data->opts.checkout_strategy |= GIT_CHECKOUT_RECREATE_MISSING; data->strategy = data->opts.checkout_strategy; /* opts->disable_filters is false by default */ if (!data->opts.dir_mode) data->opts.dir_mode = GIT_DIR_MODE; if (!data->opts.file_open_flags) data->opts.file_open_flags = O_CREAT | O_TRUNC | O_WRONLY; data->pfx = git_pathspec_prefix(&data->opts.paths); if ((error = git_repository__cvar( &data->can_symlink, repo, GIT_CVAR_SYMLINKS)) < 0) goto cleanup; if (!data->opts.baseline && !data->opts.baseline_index) { data->opts_free_baseline = true; error = checkout_lookup_head_tree(&data->opts.baseline, repo); if (error == GIT_EUNBORNBRANCH) { error = 0; giterr_clear(); } if (error < 0) goto cleanup; } if ((data->opts.checkout_strategy & (GIT_CHECKOUT_CONFLICT_STYLE_MERGE | GIT_CHECKOUT_CONFLICT_STYLE_DIFF3)) == 0) { git_config_entry *conflict_style = NULL; git_config *cfg = NULL; if ((error = git_repository_config__weakptr(&cfg, repo)) < 0 || (error = git_config_get_entry(&conflict_style, cfg, "merge.conflictstyle")) < 0 || error == GIT_ENOTFOUND) ; else if (error) goto cleanup; else if (strcmp(conflict_style->value, "merge") == 0) data->opts.checkout_strategy |= GIT_CHECKOUT_CONFLICT_STYLE_MERGE; else if (strcmp(conflict_style->value, "diff3") == 0) data->opts.checkout_strategy |= GIT_CHECKOUT_CONFLICT_STYLE_DIFF3; else { giterr_set(GITERR_CHECKOUT, "unknown style '%s' given for 'merge.conflictstyle'", conflict_style); error = -1; git_config_entry_free(conflict_style); goto cleanup; } git_config_entry_free(conflict_style); } if ((error = git_vector_init(&data->removes, 0, git__strcmp_cb)) < 0 || (error = git_vector_init(&data->remove_conflicts, 0, NULL)) < 0 || (error = git_vector_init(&data->update_conflicts, 0, NULL)) < 0 || (error = git_pool_init(&data->pool, 1, 0)) < 0 || (error = git_buf_puts(&data->path, data->opts.target_directory)) < 0 || (error = git_path_to_dir(&data->path)) < 0 || (error = git_strmap_alloc(&data->mkdir_map)) < 0) goto cleanup; data->workdir_len = git_buf_len(&data->path); git_attr_session__init(&data->attr_session, data->repo); cleanup: if (error < 0) checkout_data_clear(data); return error; } #define CHECKOUT_INDEX_DONT_WRITE_MASK \ (GIT_CHECKOUT_DONT_UPDATE_INDEX | GIT_CHECKOUT_DONT_WRITE_INDEX) int git_checkout_iterator( git_iterator *target, git_index *index, const git_checkout_options *opts) { int error = 0; git_iterator *baseline = NULL, *workdir = NULL; git_iterator_options baseline_opts = GIT_ITERATOR_OPTIONS_INIT, workdir_opts = GIT_ITERATOR_OPTIONS_INIT; checkout_data data = {0}; git_diff_options diff_opts = GIT_DIFF_OPTIONS_INIT; uint32_t *actions = NULL; size_t *counts = NULL; /* initialize structures and options */ error = checkout_data_init(&data, target, opts); if (error < 0) return error; diff_opts.flags = GIT_DIFF_INCLUDE_UNMODIFIED | GIT_DIFF_INCLUDE_UNREADABLE | GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_RECURSE_UNTRACKED_DIRS | /* needed to match baseline */ GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_TYPECHANGE | GIT_DIFF_INCLUDE_TYPECHANGE_TREES | GIT_DIFF_SKIP_BINARY_CHECK | GIT_DIFF_INCLUDE_CASECHANGE; if (data.opts.checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH) diff_opts.flags |= GIT_DIFF_DISABLE_PATHSPEC_MATCH; if (data.opts.paths.count > 0) diff_opts.pathspec = data.opts.paths; /* set up iterators */ workdir_opts.flags = git_iterator_ignore_case(target) ? GIT_ITERATOR_IGNORE_CASE : GIT_ITERATOR_DONT_IGNORE_CASE; workdir_opts.flags |= GIT_ITERATOR_DONT_AUTOEXPAND; workdir_opts.start = data.pfx; workdir_opts.end = data.pfx; if ((error = git_iterator_reset(target, data.pfx, data.pfx)) < 0 || (error = git_iterator_for_workdir_ext( &workdir, data.repo, data.opts.target_directory, index, NULL, &workdir_opts)) < 0) goto cleanup; baseline_opts.flags = git_iterator_ignore_case(target) ? GIT_ITERATOR_IGNORE_CASE : GIT_ITERATOR_DONT_IGNORE_CASE; baseline_opts.start = data.pfx; baseline_opts.end = data.pfx; if (data.opts.baseline_index) { if ((error = git_iterator_for_index( &baseline, data.opts.baseline_index, &baseline_opts)) < 0) goto cleanup; } else { if ((error = git_iterator_for_tree( &baseline, data.opts.baseline, &baseline_opts)) < 0) goto cleanup; } /* Should not have case insensitivity mismatch */ assert(git_iterator_ignore_case(workdir) == git_iterator_ignore_case(baseline)); /* Generate baseline-to-target diff which will include an entry for * every possible update that might need to be made. */ if ((error = git_diff__from_iterators( &data.diff, data.repo, baseline, target, &diff_opts)) < 0) goto cleanup; /* Loop through diff (and working directory iterator) building a list of * actions to be taken, plus look for conflicts and send notifications, * then loop through conflicts. */ if ((error = checkout_get_actions(&actions, &counts, &data, workdir)) != 0) goto cleanup; data.total_steps = counts[CHECKOUT_ACTION__REMOVE] + counts[CHECKOUT_ACTION__REMOVE_CONFLICT] + counts[CHECKOUT_ACTION__UPDATE_BLOB] + counts[CHECKOUT_ACTION__UPDATE_SUBMODULE] + counts[CHECKOUT_ACTION__UPDATE_CONFLICT]; report_progress(&data, NULL); /* establish 0 baseline */ /* To deal with some order dependencies, perform remaining checkout * in three passes: removes, then update blobs, then update submodules. */ if (counts[CHECKOUT_ACTION__REMOVE] > 0 && (error = checkout_remove_the_old(actions, &data)) < 0) goto cleanup; if (counts[CHECKOUT_ACTION__REMOVE_CONFLICT] > 0 && (error = checkout_remove_conflicts(&data)) < 0) goto cleanup; if (counts[CHECKOUT_ACTION__UPDATE_BLOB] > 0 && (error = checkout_create_the_new(actions, &data)) < 0) goto cleanup; if (counts[CHECKOUT_ACTION__UPDATE_SUBMODULE] > 0 && (error = checkout_create_submodules(actions, &data)) < 0) goto cleanup; if (counts[CHECKOUT_ACTION__UPDATE_CONFLICT] > 0 && (error = checkout_create_conflicts(&data)) < 0) goto cleanup; if (data.index != git_iterator_get_index(target) && (error = checkout_extensions_update_index(&data)) < 0) goto cleanup; assert(data.completed_steps == data.total_steps); if (data.opts.perfdata_cb) data.opts.perfdata_cb(&data.perfdata, data.opts.perfdata_payload); cleanup: if (!error && data.index != NULL && (data.strategy & CHECKOUT_INDEX_DONT_WRITE_MASK) == 0) error = git_index_write(data.index); git_diff_free(data.diff); git_iterator_free(workdir); git_iterator_free(baseline); git__free(actions); git__free(counts); checkout_data_clear(&data); return error; } int git_checkout_index( git_repository *repo, git_index *index, const git_checkout_options *opts) { int error, owned = 0; git_iterator *index_i; if (!index && !repo) { giterr_set(GITERR_CHECKOUT, "Must provide either repository or index to checkout"); return -1; } if (index && repo && git_index_owner(index) && git_index_owner(index) != repo) { giterr_set(GITERR_CHECKOUT, "Index to checkout does not match repository"); return -1; } else if(index && repo && !git_index_owner(index)) { GIT_REFCOUNT_OWN(index, repo); owned = 1; } if (!repo) repo = git_index_owner(index); if (!index && (error = git_repository_index__weakptr(&index, repo)) < 0) return error; GIT_REFCOUNT_INC(index); if (!(error = git_iterator_for_index(&index_i, index, NULL))) error = git_checkout_iterator(index_i, index, opts); if (owned) GIT_REFCOUNT_OWN(index, NULL); git_iterator_free(index_i); git_index_free(index); return error; } int git_checkout_tree( git_repository *repo, const git_object *treeish, const git_checkout_options *opts) { int error; git_index *index; git_tree *tree = NULL; git_iterator *tree_i = NULL; git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT; if (!treeish && !repo) { giterr_set(GITERR_CHECKOUT, "Must provide either repository or tree to checkout"); return -1; } if (treeish && repo && git_object_owner(treeish) != repo) { giterr_set(GITERR_CHECKOUT, "Object to checkout does not match repository"); return -1; } if (!repo) repo = git_object_owner(treeish); if (treeish) { if (git_object_peel((git_object **)&tree, treeish, GIT_OBJ_TREE) < 0) { giterr_set( GITERR_CHECKOUT, "Provided object cannot be peeled to a tree"); return -1; } } else { if ((error = checkout_lookup_head_tree(&tree, repo)) < 0) { if (error != GIT_EUNBORNBRANCH) giterr_set( GITERR_CHECKOUT, "HEAD could not be peeled to a tree and no treeish given"); return error; } } if ((error = git_repository_index(&index, repo)) < 0) return error; if ((opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) { iter_opts.pathlist.count = opts->paths.count; iter_opts.pathlist.strings = opts->paths.strings; } if (!(error = git_iterator_for_tree(&tree_i, tree, &iter_opts))) error = git_checkout_iterator(tree_i, index, opts); git_iterator_free(tree_i); git_index_free(index); git_tree_free(tree); return error; } int git_checkout_head( git_repository *repo, const git_checkout_options *opts) { assert(repo); return git_checkout_tree(repo, NULL, opts); } int git_checkout_init_options(git_checkout_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_checkout_options, GIT_CHECKOUT_OPTIONS_INIT); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/indexer.c0000664000175000017500000006216312572105236015507 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/indexer.h" #include "git2/object.h" #include "common.h" #include "pack.h" #include "mwindow.h" #include "posix.h" #include "pack.h" #include "filebuf.h" #include "oid.h" #include "oidmap.h" #include "zstream.h" GIT__USE_OIDMAP extern git_mutex git__mwindow_mutex; #define UINT31_MAX (0x7FFFFFFF) struct entry { git_oid oid; uint32_t crc; uint32_t offset; uint64_t offset_long; }; struct git_indexer { unsigned int parsed_header :1, opened_pack :1, have_stream :1, have_delta :1; struct git_pack_header hdr; struct git_pack_file *pack; unsigned int mode; git_off_t off; git_off_t entry_start; git_packfile_stream stream; size_t nr_objects; git_vector objects; git_vector deltas; unsigned int fanout[256]; git_hash_ctx hash_ctx; git_oid hash; git_transfer_progress_cb progress_cb; void *progress_payload; char objbuf[8*1024]; /* Needed to look up objects which we want to inject to fix a thin pack */ git_odb *odb; /* Fields for calculating the packfile trailer (hash of everything before it) */ char inbuf[GIT_OID_RAWSZ]; size_t inbuf_len; git_hash_ctx trailer; }; struct delta_info { git_off_t delta_off; }; const git_oid *git_indexer_hash(const git_indexer *idx) { return &idx->hash; } static int parse_header(struct git_pack_header *hdr, struct git_pack_file *pack) { int error; git_map map; if ((error = p_mmap(&map, sizeof(*hdr), GIT_PROT_READ, GIT_MAP_SHARED, pack->mwf.fd, 0)) < 0) return error; memcpy(hdr, map.data, sizeof(*hdr)); p_munmap(&map); /* Verify we recognize this pack file format. */ if (hdr->hdr_signature != ntohl(PACK_SIGNATURE)) { giterr_set(GITERR_INDEXER, "Wrong pack signature"); return -1; } if (!pack_version_ok(hdr->hdr_version)) { giterr_set(GITERR_INDEXER, "Wrong pack version"); return -1; } return 0; } static int objects_cmp(const void *a, const void *b) { const struct entry *entrya = a; const struct entry *entryb = b; return git_oid__cmp(&entrya->oid, &entryb->oid); } int git_indexer_new( git_indexer **out, const char *prefix, unsigned int mode, git_odb *odb, git_transfer_progress_cb progress_cb, void *progress_payload) { git_indexer *idx; git_buf path = GIT_BUF_INIT, tmp_path = GIT_BUF_INIT; static const char suff[] = "/pack"; int error, fd = -1; idx = git__calloc(1, sizeof(git_indexer)); GITERR_CHECK_ALLOC(idx); idx->odb = odb; idx->progress_cb = progress_cb; idx->progress_payload = progress_payload; idx->mode = mode ? mode : GIT_PACK_FILE_MODE; git_hash_ctx_init(&idx->hash_ctx); git_hash_ctx_init(&idx->trailer); error = git_buf_joinpath(&path, prefix, suff); if (error < 0) goto cleanup; fd = git_futils_mktmp(&tmp_path, git_buf_cstr(&path), idx->mode); git_buf_free(&path); if (fd < 0) goto cleanup; error = git_packfile_alloc(&idx->pack, git_buf_cstr(&tmp_path)); git_buf_free(&tmp_path); if (error < 0) goto cleanup; idx->pack->mwf.fd = fd; if ((error = git_mwindow_file_register(&idx->pack->mwf)) < 0) goto cleanup; *out = idx; return 0; cleanup: if (fd != -1) p_close(fd); git_buf_free(&path); git_buf_free(&tmp_path); git__free(idx); return -1; } /* Try to store the delta so we can try to resolve it later */ static int store_delta(git_indexer *idx) { struct delta_info *delta; delta = git__calloc(1, sizeof(struct delta_info)); GITERR_CHECK_ALLOC(delta); delta->delta_off = idx->entry_start; if (git_vector_insert(&idx->deltas, delta) < 0) return -1; return 0; } static void hash_header(git_hash_ctx *ctx, git_off_t len, git_otype type) { char buffer[64]; size_t hdrlen; hdrlen = git_odb__format_object_header(buffer, sizeof(buffer), (size_t)len, type); git_hash_update(ctx, buffer, hdrlen); } static int hash_object_stream(git_indexer*idx, git_packfile_stream *stream) { ssize_t read; assert(idx && stream); do { if ((read = git_packfile_stream_read(stream, idx->objbuf, sizeof(idx->objbuf))) < 0) break; git_hash_update(&idx->hash_ctx, idx->objbuf, read); } while (read > 0); if (read < 0) return (int)read; return 0; } /* In order to create the packfile stream, we need to skip over the delta base description */ static int advance_delta_offset(git_indexer *idx, git_otype type) { git_mwindow *w = NULL; assert(type == GIT_OBJ_REF_DELTA || type == GIT_OBJ_OFS_DELTA); if (type == GIT_OBJ_REF_DELTA) { idx->off += GIT_OID_RAWSZ; } else { git_off_t base_off = get_delta_base(idx->pack, &w, &idx->off, type, idx->entry_start); git_mwindow_close(&w); if (base_off < 0) return (int)base_off; } return 0; } /* Read from the stream and discard any output */ static int read_object_stream(git_indexer *idx, git_packfile_stream *stream) { ssize_t read; assert(stream); do { read = git_packfile_stream_read(stream, idx->objbuf, sizeof(idx->objbuf)); } while (read > 0); if (read < 0) return (int)read; return 0; } static int crc_object(uint32_t *crc_out, git_mwindow_file *mwf, git_off_t start, git_off_t size) { void *ptr; uint32_t crc; unsigned int left, len; git_mwindow *w = NULL; crc = crc32(0L, Z_NULL, 0); while (size) { ptr = git_mwindow_open(mwf, &w, start, (size_t)size, &left); if (ptr == NULL) return -1; len = min(left, (unsigned int)size); crc = crc32(crc, ptr, len); size -= len; start += len; git_mwindow_close(&w); } *crc_out = htonl(crc); return 0; } static int store_object(git_indexer *idx) { int i, error; khiter_t k; git_oid oid; struct entry *entry; git_off_t entry_size; struct git_pack_entry *pentry; git_off_t entry_start = idx->entry_start; entry = git__calloc(1, sizeof(*entry)); GITERR_CHECK_ALLOC(entry); pentry = git__calloc(1, sizeof(struct git_pack_entry)); GITERR_CHECK_ALLOC(pentry); git_hash_final(&oid, &idx->hash_ctx); entry_size = idx->off - entry_start; if (entry_start > UINT31_MAX) { entry->offset = UINT32_MAX; entry->offset_long = entry_start; } else { entry->offset = (uint32_t)entry_start; } git_oid_cpy(&pentry->sha1, &oid); pentry->offset = entry_start; k = kh_put(oid, idx->pack->idx_cache, &pentry->sha1, &error); if (error == -1) { git__free(pentry); giterr_set_oom(); goto on_error; } if (error == 0) { giterr_set(GITERR_INDEXER, "duplicate object %s found in pack", git_oid_tostr_s(&pentry->sha1)); git__free(pentry); goto on_error; } kh_value(idx->pack->idx_cache, k) = pentry; git_oid_cpy(&entry->oid, &oid); if (crc_object(&entry->crc, &idx->pack->mwf, entry_start, entry_size) < 0) goto on_error; /* Add the object to the list */ if (git_vector_insert(&idx->objects, entry) < 0) goto on_error; for (i = oid.id[0]; i < 256; ++i) { idx->fanout[i]++; } return 0; on_error: git__free(entry); return -1; } GIT_INLINE(bool) has_entry(git_indexer *idx, git_oid *id) { khiter_t k; k = kh_get(oid, idx->pack->idx_cache, id); return (k != kh_end(idx->pack->idx_cache)); } static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_entry *pentry, git_off_t entry_start) { int i, error; khiter_t k; if (entry_start > UINT31_MAX) { entry->offset = UINT32_MAX; entry->offset_long = entry_start; } else { entry->offset = (uint32_t)entry_start; } pentry->offset = entry_start; k = kh_put(oid, idx->pack->idx_cache, &pentry->sha1, &error); if (error <= 0) { giterr_set(GITERR_INDEXER, "cannot insert object into pack"); return -1; } kh_value(idx->pack->idx_cache, k) = pentry; /* Add the object to the list */ if (git_vector_insert(&idx->objects, entry) < 0) return -1; for (i = entry->oid.id[0]; i < 256; ++i) { idx->fanout[i]++; } return 0; } static int hash_and_save(git_indexer *idx, git_rawobj *obj, git_off_t entry_start) { git_oid oid; size_t entry_size; struct entry *entry; struct git_pack_entry *pentry = NULL; entry = git__calloc(1, sizeof(*entry)); GITERR_CHECK_ALLOC(entry); if (git_odb__hashobj(&oid, obj) < 0) { giterr_set(GITERR_INDEXER, "Failed to hash object"); goto on_error; } pentry = git__calloc(1, sizeof(struct git_pack_entry)); GITERR_CHECK_ALLOC(pentry); git_oid_cpy(&pentry->sha1, &oid); git_oid_cpy(&entry->oid, &oid); entry->crc = crc32(0L, Z_NULL, 0); entry_size = (size_t)(idx->off - entry_start); if (crc_object(&entry->crc, &idx->pack->mwf, entry_start, entry_size) < 0) goto on_error; return save_entry(idx, entry, pentry, entry_start); on_error: git__free(pentry); git__free(entry); git__free(obj->data); return -1; } static int do_progress_callback(git_indexer *idx, git_transfer_progress *stats) { if (idx->progress_cb) return giterr_set_after_callback_function( idx->progress_cb(stats, idx->progress_payload), "indexer progress"); return 0; } /* Hash everything but the last 20B of input */ static void hash_partially(git_indexer *idx, const uint8_t *data, size_t size) { size_t to_expell, to_keep; if (size == 0) return; /* Easy case, dump the buffer and the data minus the last 20 bytes */ if (size >= GIT_OID_RAWSZ) { git_hash_update(&idx->trailer, idx->inbuf, idx->inbuf_len); git_hash_update(&idx->trailer, data, size - GIT_OID_RAWSZ); data += size - GIT_OID_RAWSZ; memcpy(idx->inbuf, data, GIT_OID_RAWSZ); idx->inbuf_len = GIT_OID_RAWSZ; return; } /* We can just append */ if (idx->inbuf_len + size <= GIT_OID_RAWSZ) { memcpy(idx->inbuf + idx->inbuf_len, data, size); idx->inbuf_len += size; return; } /* We need to partially drain the buffer and then append */ to_keep = GIT_OID_RAWSZ - size; to_expell = idx->inbuf_len - to_keep; git_hash_update(&idx->trailer, idx->inbuf, to_expell); memmove(idx->inbuf, idx->inbuf + to_expell, to_keep); memcpy(idx->inbuf + to_keep, data, size); idx->inbuf_len += size - to_expell; } static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t size) { git_file fd = idx->pack->mwf.fd; size_t page_size; size_t page_offset; git_off_t page_start; unsigned char *map_data; git_map map; int error; assert(data && size); if ((error = git__page_size(&page_size)) < 0) return error; /* the offset needs to be at the beginning of the a page boundary */ page_offset = offset % page_size; page_start = offset - page_offset; if ((error = p_mmap(&map, page_offset + size, GIT_PROT_WRITE, GIT_MAP_SHARED, fd, page_start)) < 0) return error; map_data = (unsigned char *)map.data; memcpy(map_data + page_offset, data, size); p_munmap(&map); return 0; } static int append_to_pack(git_indexer *idx, const void *data, size_t size) { git_off_t current_size = idx->pack->mwf.size; int fd = idx->pack->mwf.fd; if (!size) return 0; if (p_lseek(fd, current_size + size - 1, SEEK_SET) < 0 || p_write(idx->pack->mwf.fd, data, 1) < 0) { giterr_set(GITERR_OS, "cannot extend packfile '%s'", idx->pack->pack_name); return -1; } return write_at(idx, data, idx->pack->mwf.size, size); } int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_transfer_progress *stats) { int error = -1; size_t processed; struct git_pack_header *hdr = &idx->hdr; git_mwindow_file *mwf = &idx->pack->mwf; assert(idx && data && stats); processed = stats->indexed_objects; if ((error = append_to_pack(idx, data, size)) < 0) return error; hash_partially(idx, data, (int)size); /* Make sure we set the new size of the pack */ idx->pack->mwf.size += size; if (!idx->parsed_header) { unsigned int total_objects; if ((unsigned)idx->pack->mwf.size < sizeof(struct git_pack_header)) return 0; if ((error = parse_header(&idx->hdr, idx->pack)) < 0) return error; idx->parsed_header = 1; idx->nr_objects = ntohl(hdr->hdr_entries); idx->off = sizeof(struct git_pack_header); /* for now, limit to 2^32 objects */ assert(idx->nr_objects == (size_t)((unsigned int)idx->nr_objects)); if (idx->nr_objects == (size_t)((unsigned int)idx->nr_objects)) total_objects = (unsigned int)idx->nr_objects; else total_objects = UINT_MAX; idx->pack->idx_cache = git_oidmap_alloc(); GITERR_CHECK_ALLOC(idx->pack->idx_cache); idx->pack->has_cache = 1; if (git_vector_init(&idx->objects, total_objects, objects_cmp) < 0) return -1; if (git_vector_init(&idx->deltas, total_objects / 2, NULL) < 0) return -1; stats->received_objects = 0; stats->local_objects = 0; stats->total_deltas = 0; stats->indexed_deltas = 0; processed = stats->indexed_objects = 0; stats->total_objects = total_objects; if ((error = do_progress_callback(idx, stats)) != 0) return error; } /* Now that we have data in the pack, let's try to parse it */ /* As the file grows any windows we try to use will be out of date */ git_mwindow_free_all(mwf); while (processed < idx->nr_objects) { git_packfile_stream *stream = &idx->stream; git_off_t entry_start = idx->off; size_t entry_size; git_otype type; git_mwindow *w = NULL; if (idx->pack->mwf.size <= idx->off + 20) return 0; if (!idx->have_stream) { error = git_packfile_unpack_header(&entry_size, &type, mwf, &w, &idx->off); if (error == GIT_EBUFS) { idx->off = entry_start; return 0; } if (error < 0) goto on_error; git_mwindow_close(&w); idx->entry_start = entry_start; git_hash_init(&idx->hash_ctx); if (type == GIT_OBJ_REF_DELTA || type == GIT_OBJ_OFS_DELTA) { error = advance_delta_offset(idx, type); if (error == GIT_EBUFS) { idx->off = entry_start; return 0; } if (error < 0) goto on_error; idx->have_delta = 1; } else { idx->have_delta = 0; hash_header(&idx->hash_ctx, entry_size, type); } idx->have_stream = 1; error = git_packfile_stream_open(stream, idx->pack, idx->off); if (error < 0) goto on_error; } if (idx->have_delta) { error = read_object_stream(idx, stream); } else { error = hash_object_stream(idx, stream); } idx->off = stream->curpos; if (error == GIT_EBUFS) return 0; /* We want to free the stream reasorces no matter what here */ idx->have_stream = 0; git_packfile_stream_free(stream); if (error < 0) goto on_error; if (idx->have_delta) { error = store_delta(idx); } else { error = store_object(idx); } if (error < 0) goto on_error; if (!idx->have_delta) { stats->indexed_objects = (unsigned int)++processed; } stats->received_objects++; if ((error = do_progress_callback(idx, stats)) != 0) goto on_error; } return 0; on_error: git_mwindow_free_all(mwf); return error; } static int index_path(git_buf *path, git_indexer *idx, const char *suffix) { const char prefix[] = "pack-"; size_t slash = (size_t)path->size; /* search backwards for '/' */ while (slash > 0 && path->ptr[slash - 1] != '/') slash--; if (git_buf_grow(path, slash + 1 + strlen(prefix) + GIT_OID_HEXSZ + strlen(suffix) + 1) < 0) return -1; git_buf_truncate(path, slash); git_buf_puts(path, prefix); git_oid_fmt(path->ptr + git_buf_len(path), &idx->hash); path->size += GIT_OID_HEXSZ; git_buf_puts(path, suffix); return git_buf_oom(path) ? -1 : 0; } /** * Rewind the packfile by the trailer, as we might need to fix the * packfile by injecting objects at the tail and must overwrite it. */ static void seek_back_trailer(git_indexer *idx) { idx->pack->mwf.size -= GIT_OID_RAWSZ; git_mwindow_free_all(&idx->pack->mwf); } static int inject_object(git_indexer *idx, git_oid *id) { git_odb_object *obj; struct entry *entry; struct git_pack_entry *pentry = NULL; git_oid foo = {{0}}; unsigned char hdr[64]; git_buf buf = GIT_BUF_INIT; git_off_t entry_start; const void *data; size_t len, hdr_len; int error; seek_back_trailer(idx); entry_start = idx->pack->mwf.size; if (git_odb_read(&obj, idx->odb, id) < 0) { giterr_set(GITERR_INDEXER, "missing delta bases"); return -1; } data = git_odb_object_data(obj); len = git_odb_object_size(obj); entry = git__calloc(1, sizeof(*entry)); GITERR_CHECK_ALLOC(entry); entry->crc = crc32(0L, Z_NULL, 0); /* Write out the object header */ hdr_len = git_packfile__object_header(hdr, len, git_odb_object_type(obj)); if ((error = append_to_pack(idx, hdr, hdr_len)) < 0) goto cleanup; idx->pack->mwf.size += hdr_len; entry->crc = crc32(entry->crc, hdr, (uInt)hdr_len); if ((error = git_zstream_deflatebuf(&buf, data, len)) < 0) goto cleanup; /* And then the compressed object */ if ((error = append_to_pack(idx, buf.ptr, buf.size)) < 0) goto cleanup; idx->pack->mwf.size += buf.size; entry->crc = htonl(crc32(entry->crc, (unsigned char *)buf.ptr, (uInt)buf.size)); git_buf_free(&buf); /* Write a fake trailer so the pack functions play ball */ if ((error = append_to_pack(idx, &foo, GIT_OID_RAWSZ)) < 0) goto cleanup; idx->pack->mwf.size += GIT_OID_RAWSZ; pentry = git__calloc(1, sizeof(struct git_pack_entry)); GITERR_CHECK_ALLOC(pentry); git_oid_cpy(&pentry->sha1, id); git_oid_cpy(&entry->oid, id); idx->off = entry_start + hdr_len + len; error = save_entry(idx, entry, pentry, entry_start); cleanup: if (error) { git__free(entry); git__free(pentry); } git_odb_object_free(obj); return error; } static int fix_thin_pack(git_indexer *idx, git_transfer_progress *stats) { int error, found_ref_delta = 0; unsigned int i; struct delta_info *delta; size_t size; git_otype type; git_mwindow *w = NULL; git_off_t curpos = 0; unsigned char *base_info; unsigned int left = 0; git_oid base; assert(git_vector_length(&idx->deltas) > 0); if (idx->odb == NULL) { giterr_set(GITERR_INDEXER, "cannot fix a thin pack without an ODB"); return -1; } /* Loop until we find the first REF delta */ git_vector_foreach(&idx->deltas, i, delta) { if (!delta) continue; curpos = delta->delta_off; error = git_packfile_unpack_header(&size, &type, &idx->pack->mwf, &w, &curpos); git_mwindow_close(&w); if (error < 0) return error; if (type == GIT_OBJ_REF_DELTA) { found_ref_delta = 1; break; } } if (!found_ref_delta) { giterr_set(GITERR_INDEXER, "no REF_DELTA found, cannot inject object"); return -1; } /* curpos now points to the base information, which is an OID */ base_info = git_mwindow_open(&idx->pack->mwf, &w, curpos, GIT_OID_RAWSZ, &left); if (base_info == NULL) { giterr_set(GITERR_INDEXER, "failed to map delta information"); return -1; } git_oid_fromraw(&base, base_info); git_mwindow_close(&w); if (has_entry(idx, &base)) return 0; if (inject_object(idx, &base) < 0) return -1; stats->local_objects++; return 0; } static int resolve_deltas(git_indexer *idx, git_transfer_progress *stats) { unsigned int i; struct delta_info *delta; int progressed = 0, non_null = 0, progress_cb_result; while (idx->deltas.length > 0) { progressed = 0; non_null = 0; git_vector_foreach(&idx->deltas, i, delta) { git_rawobj obj = {NULL}; if (!delta) continue; non_null = 1; idx->off = delta->delta_off; if (git_packfile_unpack(&obj, idx->pack, &idx->off) < 0) continue; if (hash_and_save(idx, &obj, delta->delta_off) < 0) continue; git__free(obj.data); stats->indexed_objects++; stats->indexed_deltas++; progressed = 1; if ((progress_cb_result = do_progress_callback(idx, stats)) < 0) return progress_cb_result; /* remove from the list */ git_vector_set(NULL, &idx->deltas, i, NULL); git__free(delta); } /* if none were actually set, we're done */ if (!non_null) break; if (!progressed && (fix_thin_pack(idx, stats) < 0)) { return -1; } } return 0; } static int update_header_and_rehash(git_indexer *idx, git_transfer_progress *stats) { void *ptr; size_t chunk = 1024*1024; git_off_t hashed = 0; git_mwindow *w = NULL; git_mwindow_file *mwf; unsigned int left; mwf = &idx->pack->mwf; git_hash_init(&idx->trailer); /* Update the header to include the numer of local objects we injected */ idx->hdr.hdr_entries = htonl(stats->total_objects + stats->local_objects); if (write_at(idx, &idx->hdr, 0, sizeof(struct git_pack_header)) < 0) return -1; /* * We now use the same technique as before to determine the * hash. We keep reading up to the end and let * hash_partially() keep the existing trailer out of the * calculation. */ git_mwindow_free_all(mwf); idx->inbuf_len = 0; while (hashed < mwf->size) { ptr = git_mwindow_open(mwf, &w, hashed, chunk, &left); if (ptr == NULL) return -1; hash_partially(idx, ptr, left); hashed += left; git_mwindow_close(&w); } return 0; } int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats) { git_mwindow *w = NULL; unsigned int i, long_offsets = 0, left; int error; struct git_pack_idx_header hdr; git_buf filename = GIT_BUF_INIT; struct entry *entry; git_oid trailer_hash, file_hash; git_hash_ctx ctx; git_filebuf index_file = {0}; void *packfile_trailer; if (git_hash_ctx_init(&ctx) < 0) return -1; /* Test for this before resolve_deltas(), as it plays with idx->off */ if (idx->off < idx->pack->mwf.size - 20) { giterr_set(GITERR_INDEXER, "Unexpected data at the end of the pack"); return -1; } packfile_trailer = git_mwindow_open(&idx->pack->mwf, &w, idx->pack->mwf.size - GIT_OID_RAWSZ, GIT_OID_RAWSZ, &left); if (packfile_trailer == NULL) { git_mwindow_close(&w); goto on_error; } /* Compare the packfile trailer as it was sent to us and what we calculated */ git_oid_fromraw(&file_hash, packfile_trailer); git_mwindow_close(&w); git_hash_final(&trailer_hash, &idx->trailer); if (git_oid_cmp(&file_hash, &trailer_hash)) { giterr_set(GITERR_INDEXER, "packfile trailer mismatch"); return -1; } /* Freeze the number of deltas */ stats->total_deltas = stats->total_objects - stats->indexed_objects; if ((error = resolve_deltas(idx, stats)) < 0) return error; if (stats->indexed_objects != stats->total_objects) { giterr_set(GITERR_INDEXER, "early EOF"); return -1; } if (stats->local_objects > 0) { if (update_header_and_rehash(idx, stats) < 0) return -1; git_hash_final(&trailer_hash, &idx->trailer); write_at(idx, &trailer_hash, idx->pack->mwf.size - GIT_OID_RAWSZ, GIT_OID_RAWSZ); } git_vector_sort(&idx->objects); git_buf_sets(&filename, idx->pack->pack_name); git_buf_shorten(&filename, strlen("pack")); git_buf_puts(&filename, "idx"); if (git_buf_oom(&filename)) return -1; if (git_filebuf_open(&index_file, filename.ptr, GIT_FILEBUF_HASH_CONTENTS, idx->mode) < 0) goto on_error; /* Write out the header */ hdr.idx_signature = htonl(PACK_IDX_SIGNATURE); hdr.idx_version = htonl(2); git_filebuf_write(&index_file, &hdr, sizeof(hdr)); /* Write out the fanout table */ for (i = 0; i < 256; ++i) { uint32_t n = htonl(idx->fanout[i]); git_filebuf_write(&index_file, &n, sizeof(n)); } /* Write out the object names (SHA-1 hashes) */ git_vector_foreach(&idx->objects, i, entry) { git_filebuf_write(&index_file, &entry->oid, sizeof(git_oid)); git_hash_update(&ctx, &entry->oid, GIT_OID_RAWSZ); } git_hash_final(&idx->hash, &ctx); /* Write out the CRC32 values */ git_vector_foreach(&idx->objects, i, entry) { git_filebuf_write(&index_file, &entry->crc, sizeof(uint32_t)); } /* Write out the offsets */ git_vector_foreach(&idx->objects, i, entry) { uint32_t n; if (entry->offset == UINT32_MAX) n = htonl(0x80000000 | long_offsets++); else n = htonl(entry->offset); git_filebuf_write(&index_file, &n, sizeof(uint32_t)); } /* Write out the long offsets */ git_vector_foreach(&idx->objects, i, entry) { uint32_t split[2]; if (entry->offset != UINT32_MAX) continue; split[0] = htonl(entry->offset_long >> 32); split[1] = htonl(entry->offset_long & 0xffffffff); git_filebuf_write(&index_file, &split, sizeof(uint32_t) * 2); } /* Write out the packfile trailer to the index */ if (git_filebuf_write(&index_file, &trailer_hash, GIT_OID_RAWSZ) < 0) goto on_error; /* Write out the hash of the idx */ if (git_filebuf_hash(&trailer_hash, &index_file) < 0) goto on_error; git_filebuf_write(&index_file, &trailer_hash, sizeof(git_oid)); /* Figure out what the final name should be */ if (index_path(&filename, idx, ".idx") < 0) goto on_error; /* Commit file */ if (git_filebuf_commit_at(&index_file, filename.ptr) < 0) goto on_error; git_mwindow_free_all(&idx->pack->mwf); /* We need to close the descriptor here so Windows doesn't choke on commit_at */ if (p_close(idx->pack->mwf.fd) < 0) { giterr_set(GITERR_OS, "failed to close packfile"); goto on_error; } idx->pack->mwf.fd = -1; if (index_path(&filename, idx, ".pack") < 0) goto on_error; /* And don't forget to rename the packfile to its new place. */ p_rename(idx->pack->pack_name, git_buf_cstr(&filename)); git_buf_free(&filename); git_hash_ctx_cleanup(&ctx); return 0; on_error: git_mwindow_free_all(&idx->pack->mwf); git_filebuf_cleanup(&index_file); git_buf_free(&filename); git_hash_ctx_cleanup(&ctx); return -1; } void git_indexer_free(git_indexer *idx) { if (idx == NULL) return; git_vector_free_deep(&idx->objects); if (idx->pack && idx->pack->idx_cache) { struct git_pack_entry *pentry; kh_foreach_value( idx->pack->idx_cache, pentry, { git__free(pentry); }); git_oidmap_free(idx->pack->idx_cache); } git_vector_free_deep(&idx->deltas); if (!git_mutex_lock(&git__mwindow_mutex)) { git_packfile_free(idx->pack); git_mutex_unlock(&git__mwindow_mutex); } git_hash_ctx_cleanup(&idx->trailer); git_hash_ctx_cleanup(&idx->hash_ctx); git__free(idx); } deps/libgit2-sys-0.3.8/libgit2/src/mwindow.c0000664000175000017500000002235612510265101015523 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "mwindow.h" #include "vector.h" #include "fileops.h" #include "map.h" #include "global.h" #include "strmap.h" #include "pack.h" GIT__USE_STRMAP #define DEFAULT_WINDOW_SIZE \ (sizeof(void*) >= 8 \ ? 1 * 1024 * 1024 * 1024 \ : 32 * 1024 * 1024) #define DEFAULT_MAPPED_LIMIT \ ((1024 * 1024) * (sizeof(void*) >= 8 ? 8192ULL : 256UL)) size_t git_mwindow__window_size = DEFAULT_WINDOW_SIZE; size_t git_mwindow__mapped_limit = DEFAULT_MAPPED_LIMIT; /* Whenever you want to read or modify this, grab git__mwindow_mutex */ static git_mwindow_ctl mem_ctl; /* Global list of mwindow files, to open packs once across repos */ git_strmap *git__pack_cache = NULL; /** * Run under mwindow lock */ int git_mwindow_files_init(void) { if (git__pack_cache) return 0; git__on_shutdown(git_mwindow_files_free); return git_strmap_alloc(&git__pack_cache); } void git_mwindow_files_free(void) { git_strmap *tmp = git__pack_cache; git__pack_cache = NULL; git_strmap_free(tmp); } int git_mwindow_get_pack(struct git_pack_file **out, const char *path) { int error; char *packname; git_strmap_iter pos; struct git_pack_file *pack; if ((error = git_packfile__name(&packname, path)) < 0) return error; if (git_mutex_lock(&git__mwindow_mutex) < 0) { giterr_set(GITERR_OS, "failed to lock mwindow mutex"); return -1; } if (git_mwindow_files_init() < 0) { git_mutex_unlock(&git__mwindow_mutex); git__free(packname); return -1; } pos = git_strmap_lookup_index(git__pack_cache, packname); git__free(packname); if (git_strmap_valid_index(git__pack_cache, pos)) { pack = git_strmap_value_at(git__pack_cache, pos); git_atomic_inc(&pack->refcount); git_mutex_unlock(&git__mwindow_mutex); *out = pack; return 0; } /* If we didn't find it, we need to create it */ if ((error = git_packfile_alloc(&pack, path)) < 0) { git_mutex_unlock(&git__mwindow_mutex); return error; } git_atomic_inc(&pack->refcount); git_strmap_insert(git__pack_cache, pack->pack_name, pack, error); git_mutex_unlock(&git__mwindow_mutex); if (error < 0) { git_packfile_free(pack); return -1; } *out = pack; return 0; } void git_mwindow_put_pack(struct git_pack_file *pack) { int count; git_strmap_iter pos; if (git_mutex_lock(&git__mwindow_mutex) < 0) return; /* put before get would be a corrupted state */ assert(git__pack_cache); pos = git_strmap_lookup_index(git__pack_cache, pack->pack_name); /* if we cannot find it, the state is corrupted */ assert(git_strmap_valid_index(git__pack_cache, pos)); count = git_atomic_dec(&pack->refcount); if (count == 0) { git_strmap_delete_at(git__pack_cache, pos); git_packfile_free(pack); } git_mutex_unlock(&git__mwindow_mutex); return; } void git_mwindow_free_all(git_mwindow_file *mwf) { if (git_mutex_lock(&git__mwindow_mutex)) { giterr_set(GITERR_THREAD, "unable to lock mwindow mutex"); return; } git_mwindow_free_all_locked(mwf); git_mutex_unlock(&git__mwindow_mutex); } /* * Free all the windows in a sequence, typically because we're done * with the file */ void git_mwindow_free_all_locked(git_mwindow_file *mwf) { git_mwindow_ctl *ctl = &mem_ctl; size_t i; /* * Remove these windows from the global list */ for (i = 0; i < ctl->windowfiles.length; ++i){ if (git_vector_get(&ctl->windowfiles, i) == mwf) { git_vector_remove(&ctl->windowfiles, i); break; } } if (ctl->windowfiles.length == 0) { git_vector_free(&ctl->windowfiles); ctl->windowfiles.contents = NULL; } while (mwf->windows) { git_mwindow *w = mwf->windows; assert(w->inuse_cnt == 0); ctl->mapped -= w->window_map.len; ctl->open_windows--; git_futils_mmap_free(&w->window_map); mwf->windows = w->next; git__free(w); } } /* * Check if a window 'win' contains the address 'offset' */ int git_mwindow_contains(git_mwindow *win, git_off_t offset) { git_off_t win_off = win->offset; return win_off <= offset && offset <= (git_off_t)(win_off + win->window_map.len); } /* * Find the least-recently-used window in a file */ static void git_mwindow_scan_lru( git_mwindow_file *mwf, git_mwindow **lru_w, git_mwindow **lru_l) { git_mwindow *w, *w_l; for (w_l = NULL, w = mwf->windows; w; w = w->next) { if (!w->inuse_cnt) { /* * If the current one is more recent than the last one, * store it in the output parameter. If lru_w is NULL, * it's the first loop, so store it as well. */ if (!*lru_w || w->last_used < (*lru_w)->last_used) { *lru_w = w; *lru_l = w_l; } } w_l = w; } } /* * Close the least recently used window. You should check to see if * the file descriptors need closing from time to time. Called under * lock from new_window. */ static int git_mwindow_close_lru(git_mwindow_file *mwf) { git_mwindow_ctl *ctl = &mem_ctl; size_t i; git_mwindow *lru_w = NULL, *lru_l = NULL, **list = &mwf->windows; /* FIXME: Does this give us any advantage? */ if(mwf->windows) git_mwindow_scan_lru(mwf, &lru_w, &lru_l); for (i = 0; i < ctl->windowfiles.length; ++i) { git_mwindow *last = lru_w; git_mwindow_file *cur = git_vector_get(&ctl->windowfiles, i); git_mwindow_scan_lru(cur, &lru_w, &lru_l); if (lru_w != last) list = &cur->windows; } if (!lru_w) { giterr_set(GITERR_OS, "Failed to close memory window. Couldn't find LRU"); return -1; } ctl->mapped -= lru_w->window_map.len; git_futils_mmap_free(&lru_w->window_map); if (lru_l) lru_l->next = lru_w->next; else *list = lru_w->next; git__free(lru_w); ctl->open_windows--; return 0; } /* This gets called under lock from git_mwindow_open */ static git_mwindow *new_window( git_mwindow_file *mwf, git_file fd, git_off_t size, git_off_t offset) { git_mwindow_ctl *ctl = &mem_ctl; size_t walign = git_mwindow__window_size / 2; git_off_t len; git_mwindow *w; w = git__malloc(sizeof(*w)); if (w == NULL) return NULL; memset(w, 0x0, sizeof(*w)); w->offset = (offset / walign) * walign; len = size - w->offset; if (len > (git_off_t)git_mwindow__window_size) len = (git_off_t)git_mwindow__window_size; ctl->mapped += (size_t)len; while (git_mwindow__mapped_limit < ctl->mapped && git_mwindow_close_lru(mwf) == 0) /* nop */; /* * We treat `mapped_limit` as a soft limit. If we can't find a * window to close and are above the limit, we still mmap the new * window. */ if (git_futils_mmap_ro(&w->window_map, fd, w->offset, (size_t)len) < 0) { git__free(w); return NULL; } ctl->mmap_calls++; ctl->open_windows++; if (ctl->mapped > ctl->peak_mapped) ctl->peak_mapped = ctl->mapped; if (ctl->open_windows > ctl->peak_open_windows) ctl->peak_open_windows = ctl->open_windows; return w; } /* * Open a new window, closing the least recenty used until we have * enough space. Don't forget to add it to your list */ unsigned char *git_mwindow_open( git_mwindow_file *mwf, git_mwindow **cursor, git_off_t offset, size_t extra, unsigned int *left) { git_mwindow_ctl *ctl = &mem_ctl; git_mwindow *w = *cursor; if (git_mutex_lock(&git__mwindow_mutex)) { giterr_set(GITERR_THREAD, "unable to lock mwindow mutex"); return NULL; } if (!w || !(git_mwindow_contains(w, offset) && git_mwindow_contains(w, offset + extra))) { if (w) { w->inuse_cnt--; } for (w = mwf->windows; w; w = w->next) { if (git_mwindow_contains(w, offset) && git_mwindow_contains(w, offset + extra)) break; } /* * If there isn't a suitable window, we need to create a new * one. */ if (!w) { w = new_window(mwf, mwf->fd, mwf->size, offset); if (w == NULL) { git_mutex_unlock(&git__mwindow_mutex); return NULL; } w->next = mwf->windows; mwf->windows = w; } } /* If we changed w, store it in the cursor */ if (w != *cursor) { w->last_used = ctl->used_ctr++; w->inuse_cnt++; *cursor = w; } offset -= w->offset; if (left) *left = (unsigned int)(w->window_map.len - offset); git_mutex_unlock(&git__mwindow_mutex); return (unsigned char *) w->window_map.data + offset; } int git_mwindow_file_register(git_mwindow_file *mwf) { git_mwindow_ctl *ctl = &mem_ctl; int ret; if (git_mutex_lock(&git__mwindow_mutex)) { giterr_set(GITERR_THREAD, "unable to lock mwindow mutex"); return -1; } if (ctl->windowfiles.length == 0 && git_vector_init(&ctl->windowfiles, 8, NULL) < 0) { git_mutex_unlock(&git__mwindow_mutex); return -1; } ret = git_vector_insert(&ctl->windowfiles, mwf); git_mutex_unlock(&git__mwindow_mutex); return ret; } void git_mwindow_file_deregister(git_mwindow_file *mwf) { git_mwindow_ctl *ctl = &mem_ctl; git_mwindow_file *cur; size_t i; if (git_mutex_lock(&git__mwindow_mutex)) return; git_vector_foreach(&ctl->windowfiles, i, cur) { if (cur == mwf) { git_vector_remove(&ctl->windowfiles, i); git_mutex_unlock(&git__mwindow_mutex); return; } } git_mutex_unlock(&git__mwindow_mutex); } void git_mwindow_close(git_mwindow **window) { git_mwindow *w = *window; if (w) { if (git_mutex_lock(&git__mwindow_mutex)) { giterr_set(GITERR_THREAD, "unable to lock mwindow mutex"); return; } w->inuse_cnt--; git_mutex_unlock(&git__mwindow_mutex); *window = NULL; } } deps/libgit2-sys-0.3.8/libgit2/src/idxmap.h0000664000175000017500000000624012610310643015323 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_idxmap_h__ #define INCLUDE_idxmap_h__ #include #include "common.h" #include "git2/index.h" #define kmalloc git__malloc #define kcalloc git__calloc #define krealloc git__realloc #define kreallocarray git__reallocarray #define kfree git__free #include "khash.h" __KHASH_TYPE(idx, const git_index_entry *, git_index_entry *) __KHASH_TYPE(idxicase, const git_index_entry *, git_index_entry *) typedef khash_t(idx) git_idxmap; typedef khash_t(idxicase) git_idxmap_icase; typedef khiter_t git_idxmap_iter; /* This is __ac_X31_hash_string but with tolower and it takes the entry's stage into account */ static kh_inline khint_t idxentry_hash(const git_index_entry *e) { const char *s = e->path; khint_t h = (khint_t)git__tolower(*s); if (h) for (++s ; *s; ++s) h = (h << 5) - h + (khint_t)git__tolower(*s); return h + GIT_IDXENTRY_STAGE(e); } #define idxentry_equal(a, b) (GIT_IDXENTRY_STAGE(a) == GIT_IDXENTRY_STAGE(b) && strcmp(a->path, b->path) == 0) #define idxentry_icase_equal(a, b) (GIT_IDXENTRY_STAGE(a) == GIT_IDXENTRY_STAGE(b) && strcasecmp(a->path, b->path) == 0) #define GIT__USE_IDXMAP \ __KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal) #define GIT__USE_IDXMAP_ICASE \ __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal) #define git_idxmap_alloc(hp) \ ((*(hp) = kh_init(idx)) == NULL) ? giterr_set_oom(), -1 : 0 #define git_idxmap_icase_alloc(hp) \ ((*(hp) = kh_init(idxicase)) == NULL) ? giterr_set_oom(), -1 : 0 #define git_idxmap_insert(h, key, val, rval) do { \ khiter_t __pos = kh_put(idx, h, key, &rval); \ if (rval >= 0) { \ if (rval == 0) kh_key(h, __pos) = key; \ kh_val(h, __pos) = val; \ } } while (0) #define git_idxmap_icase_insert(h, key, val, rval) do { \ khiter_t __pos = kh_put(idxicase, h, key, &rval); \ if (rval >= 0) { \ if (rval == 0) kh_key(h, __pos) = key; \ kh_val(h, __pos) = val; \ } } while (0) #define git_idxmap_lookup_index(h, k) kh_get(idx, h, k) #define git_idxmap_icase_lookup_index(h, k) kh_get(idxicase, h, k) #define git_idxmap_value_at(h, idx) kh_val(h, idx) #define git_idxmap_valid_index(h, idx) (idx != kh_end(h)) #define git_idxmap_has_data(h, idx) kh_exist(h, idx) #define git_idxmap_free(h) kh_destroy(idx, h), h = NULL #define git_idxmap_clear(h) kh_clear(idx, h) #define git_idxmap_delete_at(h, id) kh_del(idx, h, id) #define git_idxmap_icase_delete_at(h, id) kh_del(idxicase, h, id) #define git_idxmap_delete(h, key) do { \ khiter_t __pos = git_idxmap_lookup_index(h, key); \ if (git_idxmap_valid_index(h, __pos)) \ git_idxmap_delete_at(h, __pos); } while (0) #define git_idxmap_icase_delete(h, key) do { \ khiter_t __pos = git_idxmap_icase_lookup_index(h, key); \ if (git_idxmap_valid_index(h, __pos)) \ git_idxmap_icase_delete_at(h, __pos); } while (0) #define git_idxmap_begin kh_begin #define git_idxmap_end kh_end #endif deps/libgit2-sys-0.3.8/libgit2/src/fileops.h0000664000175000017500000002642312610310643015507 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_fileops_h__ #define INCLUDE_fileops_h__ #include "common.h" #include "map.h" #include "posix.h" #include "path.h" #include "pool.h" #include "strmap.h" /** * Filebuffer methods * * Read whole files into an in-memory buffer for processing */ extern int git_futils_readbuffer(git_buf *obj, const char *path); extern int git_futils_readbuffer_updated( git_buf *obj, const char *path, time_t *mtime, size_t *size, int *updated); extern int git_futils_readbuffer_fd(git_buf *obj, git_file fd, size_t len); extern int git_futils_writebuffer( const git_buf *buf, const char *path, int open_flags, mode_t mode); /** * File utils * * These are custom filesystem-related helper methods. They are * rather high level, and wrap the underlying POSIX methods * * All these methods return 0 on success, * or an error code on failure and an error message is set. */ /** * Create and open a file, while also * creating all the folders in its path */ extern int git_futils_creat_withpath(const char *path, const mode_t dirmode, const mode_t mode); /** * Create an open a process-locked file */ extern int git_futils_creat_locked(const char *path, const mode_t mode); /** * Create an open a process-locked file, while * also creating all the folders in its path */ extern int git_futils_creat_locked_withpath(const char *path, const mode_t dirmode, const mode_t mode); /** * Create a path recursively. */ extern int git_futils_mkdir_r(const char *path, const mode_t mode); /** * Flags to pass to `git_futils_mkdir`. * * * GIT_MKDIR_EXCL is "exclusive" - i.e. generate an error if dir exists. * * GIT_MKDIR_PATH says to make all components in the path. * * GIT_MKDIR_CHMOD says to chmod the final directory entry after creation * * GIT_MKDIR_CHMOD_PATH says to chmod each directory component in the path * * GIT_MKDIR_SKIP_LAST says to leave off the last element of the path * * GIT_MKDIR_SKIP_LAST2 says to leave off the last 2 elements of the path * * GIT_MKDIR_VERIFY_DIR says confirm final item is a dir, not just EEXIST * * GIT_MKDIR_REMOVE_FILES says to remove files and recreate dirs * * GIT_MKDIR_REMOVE_SYMLINKS says to remove symlinks and recreate dirs * * Note that the chmod options will be executed even if the directory already * exists, unless GIT_MKDIR_EXCL is given. */ typedef enum { GIT_MKDIR_EXCL = 1, GIT_MKDIR_PATH = 2, GIT_MKDIR_CHMOD = 4, GIT_MKDIR_CHMOD_PATH = 8, GIT_MKDIR_SKIP_LAST = 16, GIT_MKDIR_SKIP_LAST2 = 32, GIT_MKDIR_VERIFY_DIR = 64, GIT_MKDIR_REMOVE_FILES = 128, GIT_MKDIR_REMOVE_SYMLINKS = 256, } git_futils_mkdir_flags; struct git_futils_mkdir_perfdata { size_t stat_calls; size_t mkdir_calls; size_t chmod_calls; }; struct git_futils_mkdir_options { git_strmap *dir_map; git_pool *pool; struct git_futils_mkdir_perfdata perfdata; }; /** * Create a directory or entire path. * * This makes a directory (and the entire path leading up to it if requested), * and optionally chmods the directory immediately after (or each part of the * path if requested). * * @param path The path to create, relative to base. * @param base Root for relative path. These directories will never be made. * @param mode The mode to use for created directories. * @param flags Combination of the mkdir flags above. * @param opts Extended options, or null. * @return 0 on success, else error code */ extern int git_futils_mkdir_relative(const char *path, const char *base, mode_t mode, uint32_t flags, struct git_futils_mkdir_options *opts); /** * Create a directory or entire path. Similar to `git_futils_mkdir_relative` * without performance data. */ extern int git_futils_mkdir(const char *path, mode_t mode, uint32_t flags); /** * Create all the folders required to contain * the full path of a file */ extern int git_futils_mkpath2file(const char *path, const mode_t mode); /** * Flags to pass to `git_futils_rmdir_r`. * * * GIT_RMDIR_EMPTY_HIERARCHY - the default; remove hierarchy of empty * dirs and generate error if any files are found. * * GIT_RMDIR_REMOVE_FILES - attempt to remove files in the hierarchy. * * GIT_RMDIR_SKIP_NONEMPTY - skip non-empty directories with no error. * * GIT_RMDIR_EMPTY_PARENTS - remove containing directories up to base * if removing this item leaves them empty * * GIT_RMDIR_REMOVE_BLOCKERS - remove blocking file that causes ENOTDIR * * GIT_RMDIR_SKIP_ROOT - don't remove root directory itself */ typedef enum { GIT_RMDIR_EMPTY_HIERARCHY = 0, GIT_RMDIR_REMOVE_FILES = (1 << 0), GIT_RMDIR_SKIP_NONEMPTY = (1 << 1), GIT_RMDIR_EMPTY_PARENTS = (1 << 2), GIT_RMDIR_REMOVE_BLOCKERS = (1 << 3), GIT_RMDIR_SKIP_ROOT = (1 << 4), } git_futils_rmdir_flags; /** * Remove path and any files and directories beneath it. * * @param path Path to the top level directory to process. * @param base Root for relative path. * @param flags Combination of git_futils_rmdir_flags values * @return 0 on success; -1 on error. */ extern int git_futils_rmdir_r(const char *path, const char *base, uint32_t flags); /** * Create and open a temporary file with a `_git2_` suffix. * Writes the filename into path_out. * @return On success, an open file descriptor, else an error code < 0. */ extern int git_futils_mktmp(git_buf *path_out, const char *filename, mode_t mode); /** * Move a file on the filesystem, create the * destination path if it doesn't exist */ extern int git_futils_mv_withpath(const char *from, const char *to, const mode_t dirmode); /** * Copy a file * * The filemode will be used for the newly created file. */ extern int git_futils_cp( const char *from, const char *to, mode_t filemode); /** * Flags that can be passed to `git_futils_cp_r`. * * - GIT_CPDIR_CREATE_EMPTY_DIRS: create directories even if there are no * files under them (otherwise directories will only be created lazily * when a file inside them is copied). * - GIT_CPDIR_COPY_SYMLINKS: copy symlinks, otherwise they are ignored. * - GIT_CPDIR_COPY_DOTFILES: copy files with leading '.', otherwise ignored. * - GIT_CPDIR_OVERWRITE: overwrite pre-existing files with source content, * otherwise they are silently skipped. * - GIT_CPDIR_CHMOD_DIRS: explicitly chmod directories to `dirmode` * - GIT_CPDIR_SIMPLE_TO_MODE: default tries to replicate the mode of the * source file to the target; with this flag, always use 0666 (or 0777 if * source has exec bits set) for target. * - GIT_CPDIR_LINK_FILES will try to use hardlinks for the files */ typedef enum { GIT_CPDIR_CREATE_EMPTY_DIRS = (1u << 0), GIT_CPDIR_COPY_SYMLINKS = (1u << 1), GIT_CPDIR_COPY_DOTFILES = (1u << 2), GIT_CPDIR_OVERWRITE = (1u << 3), GIT_CPDIR_CHMOD_DIRS = (1u << 4), GIT_CPDIR_SIMPLE_TO_MODE = (1u << 5), GIT_CPDIR_LINK_FILES = (1u << 6), } git_futils_cpdir_flags; /** * Copy a directory tree. * * This copies directories and files from one root to another. You can * pass a combinationof GIT_CPDIR flags as defined above. * * If you pass the CHMOD flag, then the dirmode will be applied to all * directories that are created during the copy, overiding the natural * permissions. If you do not pass the CHMOD flag, then the dirmode * will actually be copied from the source files and the `dirmode` arg * will be ignored. */ extern int git_futils_cp_r( const char *from, const char *to, uint32_t flags, mode_t dirmode); /** * Open a file readonly and set error if needed. */ extern int git_futils_open_ro(const char *path); /** * Get the filesize in bytes of a file */ extern git_off_t git_futils_filesize(git_file fd); #define GIT_PERMS_IS_EXEC(MODE) (((MODE) & 0111) != 0) #define GIT_PERMS_CANONICAL(MODE) (GIT_PERMS_IS_EXEC(MODE) ? 0755 : 0644) #define GIT_PERMS_FOR_WRITE(MODE) (GIT_PERMS_IS_EXEC(MODE) ? 0777 : 0666) #define GIT_MODE_PERMS_MASK 0777 #define GIT_MODE_TYPE_MASK 0170000 #define GIT_MODE_TYPE(MODE) ((MODE) & GIT_MODE_TYPE_MASK) #define GIT_MODE_ISBLOB(MODE) (GIT_MODE_TYPE(MODE) == GIT_MODE_TYPE(GIT_FILEMODE_BLOB)) /** * Convert a mode_t from the OS to a legal git mode_t value. */ extern mode_t git_futils_canonical_mode(mode_t raw_mode); /** * Read-only map all or part of a file into memory. * When possible this function should favor a virtual memory * style mapping over some form of malloc()+read(), as the * data access will be random and is not likely to touch the * majority of the region requested. * * @param out buffer to populate with the mapping information. * @param fd open descriptor to configure the mapping from. * @param begin first byte to map, this should be page aligned. * @param len number of bytes to map. * @return * - 0 on success; * - -1 on error. */ extern int git_futils_mmap_ro( git_map *out, git_file fd, git_off_t begin, size_t len); /** * Read-only map an entire file. * * @param out buffer to populate with the mapping information. * @param path path to file to be opened. * @return * - 0 on success; * - GIT_ENOTFOUND if not found; * - -1 on an unspecified OS related error. */ extern int git_futils_mmap_ro_file( git_map *out, const char *path); /** * Release the memory associated with a previous memory mapping. * @param map the mapping description previously configured. */ extern void git_futils_mmap_free(git_map *map); /** * Create a "fake" symlink (text file containing the target path). * * @param new symlink file to be created * @param old original symlink target * @return 0 on success, -1 on error */ extern int git_futils_fake_symlink(const char *new, const char *old); /** * A file stamp represents a snapshot of information about a file that can * be used to test if the file changes. This portable implementation is * based on stat data about that file, but it is possible that OS specific * versions could be implemented in the future. */ typedef struct { git_time_t mtime; git_off_t size; unsigned int ino; } git_futils_filestamp; /** * Compare stat information for file with reference info. * * This function updates the file stamp to current data for the given path * and returns 0 if the file is up-to-date relative to the prior setting, * 1 if the file has been changed, or GIT_ENOTFOUND if the file doesn't * exist. This will not call giterr_set, so you must set the error if you * plan to return an error. * * @param stamp File stamp to be checked * @param path Path to stat and check if changed * @return 0 if up-to-date, 1 if out-of-date, GIT_ENOTFOUND if cannot stat */ extern int git_futils_filestamp_check( git_futils_filestamp *stamp, const char *path); /** * Set or reset file stamp data * * This writes the target file stamp. If the source is NULL, this will set * the target stamp to values that will definitely be out of date. If the * source is not NULL, this copies the source values to the target. * * @param tgt File stamp to write to * @param src File stamp to copy from or NULL to clear the target */ extern void git_futils_filestamp_set( git_futils_filestamp *tgt, const git_futils_filestamp *src); /** * Set file stamp data from stat structure */ extern void git_futils_filestamp_set_from_stat( git_futils_filestamp *stamp, struct stat *st); #endif /* INCLUDE_fileops_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/date.c0000664000175000017500000004661212426525445014775 0ustar /* * GIT - The information manager from hell * * Copyright (C) Linus Torvalds, 2005 */ #include "common.h" #ifndef GIT_WIN32 #include #endif #include "util.h" #include "cache.h" #include "posix.h" #include #include typedef enum { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT, DATE_LOCAL, DATE_ISO8601, DATE_RFC2822, DATE_RAW } date_mode; /* * This is like mktime, but without normalization of tm_wday and tm_yday. */ static git_time_t tm_to_time_t(const struct tm *tm) { static const int mdays[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; int year = tm->tm_year - 70; int month = tm->tm_mon; int day = tm->tm_mday; if (year < 0 || year > 129) /* algo only works for 1970-2099 */ return -1; if (month < 0 || month > 11) /* array bounds */ return -1; if (month < 2 || (year + 2) % 4) day--; if (tm->tm_hour < 0 || tm->tm_min < 0 || tm->tm_sec < 0) return -1; return (year * 365 + (year + 1) / 4 + mdays[month] + day) * 24*60*60UL + tm->tm_hour * 60*60 + tm->tm_min * 60 + tm->tm_sec; } static const char *month_names[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; static const char *weekday_names[] = { "Sundays", "Mondays", "Tuesdays", "Wednesdays", "Thursdays", "Fridays", "Saturdays" }; /* * Check these. And note how it doesn't do the summer-time conversion. * * In my world, it's always summer, and things are probably a bit off * in other ways too. */ static const struct { const char *name; int offset; int dst; } timezone_names[] = { { "IDLW", -12, 0, }, /* International Date Line West */ { "NT", -11, 0, }, /* Nome */ { "CAT", -10, 0, }, /* Central Alaska */ { "HST", -10, 0, }, /* Hawaii Standard */ { "HDT", -10, 1, }, /* Hawaii Daylight */ { "YST", -9, 0, }, /* Yukon Standard */ { "YDT", -9, 1, }, /* Yukon Daylight */ { "PST", -8, 0, }, /* Pacific Standard */ { "PDT", -8, 1, }, /* Pacific Daylight */ { "MST", -7, 0, }, /* Mountain Standard */ { "MDT", -7, 1, }, /* Mountain Daylight */ { "CST", -6, 0, }, /* Central Standard */ { "CDT", -6, 1, }, /* Central Daylight */ { "EST", -5, 0, }, /* Eastern Standard */ { "EDT", -5, 1, }, /* Eastern Daylight */ { "AST", -3, 0, }, /* Atlantic Standard */ { "ADT", -3, 1, }, /* Atlantic Daylight */ { "WAT", -1, 0, }, /* West Africa */ { "GMT", 0, 0, }, /* Greenwich Mean */ { "UTC", 0, 0, }, /* Universal (Coordinated) */ { "Z", 0, 0, }, /* Zulu, alias for UTC */ { "WET", 0, 0, }, /* Western European */ { "BST", 0, 1, }, /* British Summer */ { "CET", +1, 0, }, /* Central European */ { "MET", +1, 0, }, /* Middle European */ { "MEWT", +1, 0, }, /* Middle European Winter */ { "MEST", +1, 1, }, /* Middle European Summer */ { "CEST", +1, 1, }, /* Central European Summer */ { "MESZ", +1, 1, }, /* Middle European Summer */ { "FWT", +1, 0, }, /* French Winter */ { "FST", +1, 1, }, /* French Summer */ { "EET", +2, 0, }, /* Eastern Europe */ { "EEST", +2, 1, }, /* Eastern European Daylight */ { "WAST", +7, 0, }, /* West Australian Standard */ { "WADT", +7, 1, }, /* West Australian Daylight */ { "CCT", +8, 0, }, /* China Coast */ { "JST", +9, 0, }, /* Japan Standard */ { "EAST", +10, 0, }, /* Eastern Australian Standard */ { "EADT", +10, 1, }, /* Eastern Australian Daylight */ { "GST", +10, 0, }, /* Guam Standard */ { "NZT", +12, 0, }, /* New Zealand */ { "NZST", +12, 0, }, /* New Zealand Standard */ { "NZDT", +12, 1, }, /* New Zealand Daylight */ { "IDLE", +12, 0, }, /* International Date Line East */ }; static size_t match_string(const char *date, const char *str) { size_t i = 0; for (i = 0; *date; date++, str++, i++) { if (*date == *str) continue; if (toupper(*date) == toupper(*str)) continue; if (!isalnum(*date)) break; return 0; } return i; } static int skip_alpha(const char *date) { int i = 0; do { i++; } while (isalpha(date[i])); return i; } /* * Parse month, weekday, or timezone name */ static size_t match_alpha(const char *date, struct tm *tm, int *offset) { unsigned int i; for (i = 0; i < 12; i++) { size_t match = match_string(date, month_names[i]); if (match >= 3) { tm->tm_mon = i; return match; } } for (i = 0; i < 7; i++) { size_t match = match_string(date, weekday_names[i]); if (match >= 3) { tm->tm_wday = i; return match; } } for (i = 0; i < ARRAY_SIZE(timezone_names); i++) { size_t match = match_string(date, timezone_names[i].name); if (match >= 3 || match == strlen(timezone_names[i].name)) { int off = timezone_names[i].offset; /* This is bogus, but we like summer */ off += timezone_names[i].dst; /* Only use the tz name offset if we don't have anything better */ if (*offset == -1) *offset = 60*off; return match; } } if (match_string(date, "PM") == 2) { tm->tm_hour = (tm->tm_hour % 12) + 12; return 2; } if (match_string(date, "AM") == 2) { tm->tm_hour = (tm->tm_hour % 12) + 0; return 2; } /* BAD */ return skip_alpha(date); } static int is_date(int year, int month, int day, struct tm *now_tm, time_t now, struct tm *tm) { if (month > 0 && month < 13 && day > 0 && day < 32) { struct tm check = *tm; struct tm *r = (now_tm ? &check : tm); time_t specified; r->tm_mon = month - 1; r->tm_mday = day; if (year == -1) { if (!now_tm) return 1; r->tm_year = now_tm->tm_year; } else if (year >= 1970 && year < 2100) r->tm_year = year - 1900; else if (year > 70 && year < 100) r->tm_year = year; else if (year < 38) r->tm_year = year + 100; else return 0; if (!now_tm) return 1; specified = tm_to_time_t(r); /* Be it commit time or author time, it does not make * sense to specify timestamp way into the future. Make * sure it is not later than ten days from now... */ if (now + 10*24*3600 < specified) return 0; tm->tm_mon = r->tm_mon; tm->tm_mday = r->tm_mday; if (year != -1) tm->tm_year = r->tm_year; return 1; } return 0; } static size_t match_multi_number(unsigned long num, char c, const char *date, char *end, struct tm *tm) { time_t now; struct tm now_tm; struct tm *refuse_future; long num2, num3; num2 = strtol(end+1, &end, 10); num3 = -1; if (*end == c && isdigit(end[1])) num3 = strtol(end+1, &end, 10); /* Time? Date? */ switch (c) { case ':': if (num3 < 0) num3 = 0; if (num < 25 && num2 >= 0 && num2 < 60 && num3 >= 0 && num3 <= 60) { tm->tm_hour = num; tm->tm_min = num2; tm->tm_sec = num3; break; } return 0; case '-': case '/': case '.': now = time(NULL); refuse_future = NULL; if (p_gmtime_r(&now, &now_tm)) refuse_future = &now_tm; if (num > 70) { /* yyyy-mm-dd? */ if (is_date(num, num2, num3, refuse_future, now, tm)) break; /* yyyy-dd-mm? */ if (is_date(num, num3, num2, refuse_future, now, tm)) break; } /* Our eastern European friends say dd.mm.yy[yy] * is the norm there, so giving precedence to * mm/dd/yy[yy] form only when separator is not '.' */ if (c != '.' && is_date(num3, num, num2, refuse_future, now, tm)) break; /* European dd.mm.yy[yy] or funny US dd/mm/yy[yy] */ if (is_date(num3, num2, num, refuse_future, now, tm)) break; /* Funny European mm.dd.yy */ if (c == '.' && is_date(num3, num, num2, refuse_future, now, tm)) break; return 0; } return end - date; } /* * Have we filled in any part of the time/date yet? * We just do a binary 'and' to see if the sign bit * is set in all the values. */ static int nodate(struct tm *tm) { return (tm->tm_year & tm->tm_mon & tm->tm_mday & tm->tm_hour & tm->tm_min & tm->tm_sec) < 0; } /* * We've seen a digit. Time? Year? Date? */ static size_t match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt) { size_t n; char *end; unsigned long num; num = strtoul(date, &end, 10); /* * Seconds since 1970? We trigger on that for any numbers with * more than 8 digits. This is because we don't want to rule out * numbers like 20070606 as a YYYYMMDD date. */ if (num >= 100000000 && nodate(tm)) { time_t time = num; if (p_gmtime_r(&time, tm)) { *tm_gmt = 1; return end - date; } } /* * Check for special formats: num[-.:/]num[same]num */ switch (*end) { case ':': case '.': case '/': case '-': if (isdigit(end[1])) { size_t match = match_multi_number(num, *end, date, end, tm); if (match) return match; } } /* * None of the special formats? Try to guess what * the number meant. We use the number of digits * to make a more educated guess.. */ n = 0; do { n++; } while (isdigit(date[n])); /* Four-digit year or a timezone? */ if (n == 4) { if (num <= 1400 && *offset == -1) { unsigned int minutes = num % 100; unsigned int hours = num / 100; *offset = hours*60 + minutes; } else if (num > 1900 && num < 2100) tm->tm_year = num - 1900; return n; } /* * Ignore lots of numerals. We took care of 4-digit years above. * Days or months must be one or two digits. */ if (n > 2) return n; /* * NOTE! We will give precedence to day-of-month over month or * year numbers in the 1-12 range. So 05 is always "mday 5", * unless we already have a mday.. * * IOW, 01 Apr 05 parses as "April 1st, 2005". */ if (num > 0 && num < 32 && tm->tm_mday < 0) { tm->tm_mday = num; return n; } /* Two-digit year? */ if (n == 2 && tm->tm_year < 0) { if (num < 10 && tm->tm_mday >= 0) { tm->tm_year = num + 100; return n; } if (num >= 70) { tm->tm_year = num; return n; } } if (num > 0 && num < 13 && tm->tm_mon < 0) tm->tm_mon = num-1; return n; } static size_t match_tz(const char *date, int *offp) { char *end; int hour = strtoul(date + 1, &end, 10); size_t n = end - (date + 1); int min = 0; if (n == 4) { /* hhmm */ min = hour % 100; hour = hour / 100; } else if (n != 2) { min = 99; /* random stuff */ } else if (*end == ':') { /* hh:mm? */ min = strtoul(end + 1, &end, 10); if (end - (date + 1) != 5) min = 99; /* random stuff */ } /* otherwise we parsed "hh" */ /* * Don't accept any random stuff. Even though some places have * offset larger than 12 hours (e.g. Pacific/Kiritimati is at * UTC+14), there is something wrong if hour part is much * larger than that. We might also want to check that the * minutes are divisible by 15 or something too. (Offset of * Kathmandu, Nepal is UTC+5:45) */ if (min < 60 && hour < 24) { int offset = hour * 60 + min; if (*date == '-') offset = -offset; *offp = offset; } return end - date; } /* * Parse a string like "0 +0000" as ancient timestamp near epoch, but * only when it appears not as part of any other string. */ static int match_object_header_date(const char *date, git_time_t *timestamp, int *offset) { char *end; unsigned long stamp; int ofs; if (*date < '0' || '9' <= *date) return -1; stamp = strtoul(date, &end, 10); if (*end != ' ' || stamp == ULONG_MAX || (end[1] != '+' && end[1] != '-')) return -1; date = end + 2; ofs = strtol(date, &end, 10); if ((*end != '\0' && (*end != '\n')) || end != date + 4) return -1; ofs = (ofs / 100) * 60 + (ofs % 100); if (date[-1] == '-') ofs = -ofs; *timestamp = stamp; *offset = ofs; return 0; } /* Gr. strptime is crap for this; it doesn't have a way to require RFC2822 (i.e. English) day/month names, and it doesn't work correctly with %z. */ static int parse_date_basic(const char *date, git_time_t *timestamp, int *offset) { struct tm tm; int tm_gmt; git_time_t dummy_timestamp; int dummy_offset; if (!timestamp) timestamp = &dummy_timestamp; if (!offset) offset = &dummy_offset; memset(&tm, 0, sizeof(tm)); tm.tm_year = -1; tm.tm_mon = -1; tm.tm_mday = -1; tm.tm_isdst = -1; tm.tm_hour = -1; tm.tm_min = -1; tm.tm_sec = -1; *offset = -1; tm_gmt = 0; if (*date == '@' && !match_object_header_date(date + 1, timestamp, offset)) return 0; /* success */ for (;;) { size_t match = 0; unsigned char c = *date; /* Stop at end of string or newline */ if (!c || c == '\n') break; if (isalpha(c)) match = match_alpha(date, &tm, offset); else if (isdigit(c)) match = match_digit(date, &tm, offset, &tm_gmt); else if ((c == '-' || c == '+') && isdigit(date[1])) match = match_tz(date, offset); if (!match) { /* BAD */ match = 1; } date += match; } /* mktime uses local timezone */ *timestamp = tm_to_time_t(&tm); if (*offset == -1) *offset = (int)((time_t)*timestamp - mktime(&tm)) / 60; if (*timestamp == (git_time_t)-1) return -1; if (!tm_gmt) *timestamp -= *offset * 60; return 0; /* success */ } /* * Relative time update (eg "2 days ago"). If we haven't set the time * yet, we need to set it from current time. */ static git_time_t update_tm(struct tm *tm, struct tm *now, unsigned long sec) { time_t n; if (tm->tm_mday < 0) tm->tm_mday = now->tm_mday; if (tm->tm_mon < 0) tm->tm_mon = now->tm_mon; if (tm->tm_year < 0) { tm->tm_year = now->tm_year; if (tm->tm_mon > now->tm_mon) tm->tm_year--; } n = mktime(tm) - sec; p_localtime_r(&n, tm); return n; } static void date_now(struct tm *tm, struct tm *now, int *num) { GIT_UNUSED(num); update_tm(tm, now, 0); } static void date_yesterday(struct tm *tm, struct tm *now, int *num) { GIT_UNUSED(num); update_tm(tm, now, 24*60*60); } static void date_time(struct tm *tm, struct tm *now, int hour) { if (tm->tm_hour < hour) date_yesterday(tm, now, NULL); tm->tm_hour = hour; tm->tm_min = 0; tm->tm_sec = 0; } static void date_midnight(struct tm *tm, struct tm *now, int *num) { GIT_UNUSED(num); date_time(tm, now, 0); } static void date_noon(struct tm *tm, struct tm *now, int *num) { GIT_UNUSED(num); date_time(tm, now, 12); } static void date_tea(struct tm *tm, struct tm *now, int *num) { GIT_UNUSED(num); date_time(tm, now, 17); } static void date_pm(struct tm *tm, struct tm *now, int *num) { int hour, n = *num; *num = 0; GIT_UNUSED(now); hour = tm->tm_hour; if (n) { hour = n; tm->tm_min = 0; tm->tm_sec = 0; } tm->tm_hour = (hour % 12) + 12; } static void date_am(struct tm *tm, struct tm *now, int *num) { int hour, n = *num; *num = 0; GIT_UNUSED(now); hour = tm->tm_hour; if (n) { hour = n; tm->tm_min = 0; tm->tm_sec = 0; } tm->tm_hour = (hour % 12); } static void date_never(struct tm *tm, struct tm *now, int *num) { time_t n = 0; GIT_UNUSED(now); GIT_UNUSED(num); p_localtime_r(&n, tm); } static const struct special { const char *name; void (*fn)(struct tm *, struct tm *, int *); } special[] = { { "yesterday", date_yesterday }, { "noon", date_noon }, { "midnight", date_midnight }, { "tea", date_tea }, { "PM", date_pm }, { "AM", date_am }, { "never", date_never }, { "now", date_now }, { NULL } }; static const char *number_name[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", }; static const struct typelen { const char *type; int length; } typelen[] = { { "seconds", 1 }, { "minutes", 60 }, { "hours", 60*60 }, { "days", 24*60*60 }, { "weeks", 7*24*60*60 }, { NULL } }; static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm *now, int *num, int *touched) { const struct typelen *tl; const struct special *s; const char *end = date; int i; while (isalpha(*++end)) /* scan to non-alpha */; for (i = 0; i < 12; i++) { size_t match = match_string(date, month_names[i]); if (match >= 3) { tm->tm_mon = i; *touched = 1; return end; } } for (s = special; s->name; s++) { size_t len = strlen(s->name); if (match_string(date, s->name) == len) { s->fn(tm, now, num); *touched = 1; return end; } } if (!*num) { for (i = 1; i < 11; i++) { size_t len = strlen(number_name[i]); if (match_string(date, number_name[i]) == len) { *num = i; *touched = 1; return end; } } if (match_string(date, "last") == 4) { *num = 1; *touched = 1; } return end; } tl = typelen; while (tl->type) { size_t len = strlen(tl->type); if (match_string(date, tl->type) >= len-1) { update_tm(tm, now, tl->length * *num); *num = 0; *touched = 1; return end; } tl++; } for (i = 0; i < 7; i++) { size_t match = match_string(date, weekday_names[i]); if (match >= 3) { int diff, n = *num -1; *num = 0; diff = tm->tm_wday - i; if (diff <= 0) n++; diff += 7*n; update_tm(tm, now, diff * 24 * 60 * 60); *touched = 1; return end; } } if (match_string(date, "months") >= 5) { int n; update_tm(tm, now, 0); /* fill in date fields if needed */ n = tm->tm_mon - *num; *num = 0; while (n < 0) { n += 12; tm->tm_year--; } tm->tm_mon = n; *touched = 1; return end; } if (match_string(date, "years") >= 4) { update_tm(tm, now, 0); /* fill in date fields if needed */ tm->tm_year -= *num; *num = 0; *touched = 1; return end; } return end; } static const char *approxidate_digit(const char *date, struct tm *tm, int *num) { char *end; unsigned long number = strtoul(date, &end, 10); switch (*end) { case ':': case '.': case '/': case '-': if (isdigit(end[1])) { size_t match = match_multi_number(number, *end, date, end, tm); if (match) return date + match; } } /* Accept zero-padding only for small numbers ("Dec 02", never "Dec 0002") */ if (date[0] != '0' || end - date <= 2) *num = number; return end; } /* * Do we have a pending number at the end, or when * we see a new one? Let's assume it's a month day, * as in "Dec 6, 1992" */ static void pending_number(struct tm *tm, int *num) { int number = *num; if (number) { *num = 0; if (tm->tm_mday < 0 && number < 32) tm->tm_mday = number; else if (tm->tm_mon < 0 && number < 13) tm->tm_mon = number-1; else if (tm->tm_year < 0) { if (number > 1969 && number < 2100) tm->tm_year = number - 1900; else if (number > 69 && number < 100) tm->tm_year = number; else if (number < 38) tm->tm_year = 100 + number; /* We mess up for number = 00 ? */ } } } static git_time_t approxidate_str(const char *date, time_t time_sec, int *error_ret) { int number = 0; int touched = 0; struct tm tm = {0}, now; p_localtime_r(&time_sec, &tm); now = tm; tm.tm_year = -1; tm.tm_mon = -1; tm.tm_mday = -1; for (;;) { unsigned char c = *date; if (!c) break; date++; if (isdigit(c)) { pending_number(&tm, &number); date = approxidate_digit(date-1, &tm, &number); touched = 1; continue; } if (isalpha(c)) date = approxidate_alpha(date-1, &tm, &now, &number, &touched); } pending_number(&tm, &number); if (!touched) *error_ret = 1; return update_tm(&tm, &now, 0); } int git__date_parse(git_time_t *out, const char *date) { time_t time_sec; git_time_t timestamp; int offset, error_ret=0; if (!parse_date_basic(date, ×tamp, &offset)) { *out = timestamp; return 0; } if (time(&time_sec) == -1) return -1; *out = approxidate_str(date, time_sec, &error_ret); return error_ret; } int git__date_rfc2822_fmt(char *out, size_t len, const git_time *date) { int written; struct tm gmt; time_t t; assert(out && date); t = (time_t) (date->time + date->offset * 60); if (p_gmtime_r (&t, &gmt) == NULL) return -1; written = p_snprintf(out, len, "%.3s, %u %.3s %.4u %02u:%02u:%02u %+03d%02d", weekday_names[gmt.tm_wday], gmt.tm_mday, month_names[gmt.tm_mon], gmt.tm_year + 1900, gmt.tm_hour, gmt.tm_min, gmt.tm_sec, date->offset / 60, date->offset % 60); if (written < 0 || (written > (int) len - 1)) return -1; return 0; } deps/libgit2-sys-0.3.8/libgit2/src/pack-objects.h0000664000175000017500000000447512555730137016432 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_pack_objects_h__ #define INCLUDE_pack_objects_h__ #include "common.h" #include "buffer.h" #include "hash.h" #include "oidmap.h" #include "netops.h" #include "zstream.h" #include "pool.h" #include "git2/oid.h" #include "git2/pack.h" #define GIT_PACK_WINDOW 10 /* number of objects to possibly delta against */ #define GIT_PACK_DEPTH 50 /* max delta depth */ #define GIT_PACK_DELTA_CACHE_SIZE (256 * 1024 * 1024) #define GIT_PACK_DELTA_CACHE_LIMIT 1000 #define GIT_PACK_BIG_FILE_THRESHOLD (512 * 1024 * 1024) typedef struct git_pobject { git_oid id; git_otype type; git_off_t offset; size_t size; unsigned int hash; /* name hint hash */ struct git_pobject *delta; /* delta base object */ struct git_pobject *delta_child; /* deltified objects who bases me */ struct git_pobject *delta_sibling; /* other deltified objects * who uses the same base as * me */ void *delta_data; unsigned long delta_size; unsigned long z_delta_size; int written:1, recursing:1, tagged:1, filled:1; } git_pobject; typedef struct { git_oid id; unsigned int uninteresting:1, seen:1; } git_walk_object; struct git_packbuilder { git_repository *repo; /* associated repository */ git_odb *odb; /* associated object database */ git_hash_ctx ctx; git_zstream zstream; uint32_t nr_objects, nr_deltified, nr_alloc, nr_written, nr_remaining; git_pobject *object_list; git_oidmap *object_ix; git_oidmap *walk_objects; git_pool object_pool; git_oid pack_oid; /* hash of written pack */ /* synchronization objects */ git_mutex cache_mutex; git_mutex progress_mutex; git_cond progress_cond; /* configs */ uint64_t delta_cache_size; uint64_t max_delta_cache_size; uint64_t cache_max_small_delta_size; uint64_t big_file_threshold; uint64_t window_memory_limit; int nr_threads; /* nr of threads to use */ git_packbuilder_progress progress_cb; void *progress_cb_payload; double last_progress_report_time; /* the time progress was last reported */ bool done; }; int git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb); #endif /* INCLUDE_pack_objects_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/xdiff/0000755000000000000000000000000012666635520016561 5ustar rootrootdeps/libgit2-sys-0.3.8/libgit2/src/xdiff/xmacros.h0000664000175000017500000000365612426525445016642 0ustar /* * LibXDiff by Davide Libenzi ( File Differential Library ) * Copyright (C) 2003 Davide Libenzi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Davide Libenzi * */ #if !defined(XMACROS_H) #define XMACROS_H #define XDL_MIN(a, b) ((a) < (b) ? (a): (b)) #define XDL_MAX(a, b) ((a) > (b) ? (a): (b)) #define XDL_ABS(v) ((v) >= 0 ? (v): -(v)) #define XDL_ISDIGIT(c) ((c) >= '0' && (c) <= '9') #define XDL_ISSPACE(c) (isspace((unsigned char)(c))) #define XDL_ADDBITS(v,b) ((v) + ((v) >> (b))) #define XDL_MASKBITS(b) ((1UL << (b)) - 1) #define XDL_HASHLONG(v,b) (XDL_ADDBITS((unsigned long)(v), b) & XDL_MASKBITS(b)) #define XDL_PTRFREE(p) do { if (p) { xdl_free(p); (p) = NULL; } } while (0) #define XDL_LE32_PUT(p, v) \ do { \ unsigned char *__p = (unsigned char *) (p); \ *__p++ = (unsigned char) (v); \ *__p++ = (unsigned char) ((v) >> 8); \ *__p++ = (unsigned char) ((v) >> 16); \ *__p = (unsigned char) ((v) >> 24); \ } while (0) #define XDL_LE32_GET(p, v) \ do { \ unsigned char const *__p = (unsigned char const *) (p); \ (v) = (unsigned long) __p[0] | ((unsigned long) __p[1]) << 8 | \ ((unsigned long) __p[2]) << 16 | ((unsigned long) __p[3]) << 24; \ } while (0) #endif /* #if !defined(XMACROS_H) */ deps/libgit2-sys-0.3.8/libgit2/src/xdiff/xdiffi.h0000664000175000017500000000372112572105236016422 0ustar /* * LibXDiff by Davide Libenzi ( File Differential Library ) * Copyright (C) 2003 Davide Libenzi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Davide Libenzi * */ #if !defined(XDIFFI_H) #define XDIFFI_H typedef struct s_diffdata { long nrec; unsigned long const *ha; long *rindex; char *rchg; } diffdata_t; typedef struct s_xdalgoenv { long mxcost; long snake_cnt; long heur_min; } xdalgoenv_t; typedef struct s_xdchange { struct s_xdchange *next; long i1, i2; long chg1, chg2; int ignore; } xdchange_t; int xdl_recs_cmp(diffdata_t *dd1, long off1, long lim1, diffdata_t *dd2, long off2, long lim2, long *kvdf, long *kvdb, int need_min, xdalgoenv_t *xenv); int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdfenv_t *xe); int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags); int xdl_build_script(xdfenv_t *xe, xdchange_t **xscr); void xdl_free_script(xdchange_t *xscr); int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, xdemitconf_t const *xecfg); int xdl_do_patience_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdfenv_t *env); int xdl_do_histogram_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdfenv_t *env); #endif /* #if !defined(XDIFFI_H) */ deps/libgit2-sys-0.3.8/libgit2/src/xdiff/xprepare.h0000664000175000017500000000214312426525445017002 0ustar /* * LibXDiff by Davide Libenzi ( File Differential Library ) * Copyright (C) 2003 Davide Libenzi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Davide Libenzi * */ #if !defined(XPREPARE_H) #define XPREPARE_H int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdfenv_t *xe); void xdl_free_env(xdfenv_t *xe); #endif /* #if !defined(XPREPARE_H) */ deps/libgit2-sys-0.3.8/libgit2/src/xdiff/xemit.c0000664000175000017500000001600712572105236016273 0ustar /* * LibXDiff by Davide Libenzi ( File Differential Library ) * Copyright (C) 2003 Davide Libenzi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Davide Libenzi * */ #include "xinclude.h" static long xdl_get_rec(xdfile_t *xdf, long ri, char const **rec); static int xdl_emit_record(xdfile_t *xdf, long ri, char const *pre, xdemitcb_t *ecb); static long xdl_get_rec(xdfile_t *xdf, long ri, char const **rec) { *rec = xdf->recs[ri]->ptr; return xdf->recs[ri]->size; } static int xdl_emit_record(xdfile_t *xdf, long ri, char const *pre, xdemitcb_t *ecb) { long size, psize = (long)strlen(pre); char const *rec; size = xdl_get_rec(xdf, ri, &rec); if (xdl_emit_diffrec(rec, size, pre, psize, ecb) < 0) { return -1; } return 0; } /* * Starting at the passed change atom, find the latest change atom to be included * inside the differential hunk according to the specified configuration. * Also advance xscr if the first changes must be discarded. */ xdchange_t *xdl_get_hunk(xdchange_t **xscr, xdemitconf_t const *xecfg) { xdchange_t *xch, *xchp, *lxch; long max_common = 2 * xecfg->ctxlen + xecfg->interhunkctxlen; long max_ignorable = xecfg->ctxlen; unsigned long ignored = 0; /* number of ignored blank lines */ /* remove ignorable changes that are too far before other changes */ for (xchp = *xscr; xchp && xchp->ignore; xchp = xchp->next) { xch = xchp->next; if (xch == NULL || xch->i1 - (xchp->i1 + xchp->chg1) >= max_ignorable) *xscr = xch; } if (*xscr == NULL) return NULL; lxch = *xscr; for (xchp = *xscr, xch = xchp->next; xch; xchp = xch, xch = xch->next) { long distance = xch->i1 - (xchp->i1 + xchp->chg1); if (distance > max_common) break; if (distance < max_ignorable && (!xch->ignore || lxch == xchp)) { lxch = xch; ignored = 0; } else if (distance < max_ignorable && xch->ignore) { ignored += xch->chg2; } else if (lxch != xchp && xch->i1 + ignored - (lxch->i1 + lxch->chg1) > (unsigned long)max_common) { break; } else if (!xch->ignore) { lxch = xch; ignored = 0; } else { ignored += xch->chg2; } } return lxch; } static long def_ff(const char *rec, long len, char *buf, long sz, void *priv) { (void)priv; if (len > 0 && (isalpha((unsigned char)*rec) || /* identifier? */ *rec == '_' || /* also identifier? */ *rec == '$')) { /* identifiers from VMS and other esoterico */ if (len > sz) len = sz; while (0 < len && isspace((unsigned char)rec[len - 1])) len--; memcpy(buf, rec, len); return len; } return -1; } static int xdl_emit_common(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, xdemitconf_t const *xecfg) { xdfile_t *xdf = &xe->xdf2; const char *rchg = xdf->rchg; long ix; (void)xscr; (void)xecfg; for (ix = 0; ix < xdf->nrec; ix++) { if (rchg[ix]) continue; if (xdl_emit_record(xdf, ix, "", ecb)) return -1; } return 0; } struct func_line { long len; char buf[80]; }; static long get_func_line(xdfenv_t *xe, xdemitconf_t const *xecfg, struct func_line *func_line, long start, long limit) { find_func_t ff = xecfg->find_func ? xecfg->find_func : def_ff; long l, size, step = (start > limit) ? -1 : 1; char *buf, dummy[1]; buf = func_line ? func_line->buf : dummy; size = func_line ? sizeof(func_line->buf) : sizeof(dummy); for (l = start; l != limit && 0 <= l && l < xe->xdf1.nrec; l += step) { const char *rec; long reclen = xdl_get_rec(&xe->xdf1, l, &rec); long len = ff(rec, reclen, buf, size, xecfg->find_func_priv); if (len >= 0) { if (func_line) func_line->len = len; return l; } } return -1; } int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, xdemitconf_t const *xecfg) { long s1, s2, e1, e2, lctx; xdchange_t *xch, *xche; long funclineprev = -1; struct func_line func_line = { 0 }; if (xecfg->flags & XDL_EMIT_COMMON) return xdl_emit_common(xe, xscr, ecb, xecfg); for (xch = xscr; xch; xch = xche->next) { xche = xdl_get_hunk(&xch, xecfg); if (!xch) break; s1 = XDL_MAX(xch->i1 - xecfg->ctxlen, 0); s2 = XDL_MAX(xch->i2 - xecfg->ctxlen, 0); if (xecfg->flags & XDL_EMIT_FUNCCONTEXT) { long fs1 = get_func_line(xe, xecfg, NULL, xch->i1, -1); if (fs1 < 0) fs1 = 0; if (fs1 < s1) { s2 -= s1 - fs1; s1 = fs1; } } again: lctx = xecfg->ctxlen; lctx = XDL_MIN(lctx, xe->xdf1.nrec - (xche->i1 + xche->chg1)); lctx = XDL_MIN(lctx, xe->xdf2.nrec - (xche->i2 + xche->chg2)); e1 = xche->i1 + xche->chg1 + lctx; e2 = xche->i2 + xche->chg2 + lctx; if (xecfg->flags & XDL_EMIT_FUNCCONTEXT) { long fe1 = get_func_line(xe, xecfg, NULL, xche->i1 + xche->chg1, xe->xdf1.nrec); if (fe1 < 0) fe1 = xe->xdf1.nrec; if (fe1 > e1) { e2 += fe1 - e1; e1 = fe1; } /* * Overlap with next change? Then include it * in the current hunk and start over to find * its new end. */ if (xche->next) { long l = xche->next->i1; if (l <= e1 || get_func_line(xe, xecfg, NULL, l, e1) < 0) { xche = xche->next; goto again; } } } /* * Emit current hunk header. */ if (xecfg->flags & XDL_EMIT_FUNCNAMES) { get_func_line(xe, xecfg, &func_line, s1 - 1, funclineprev); funclineprev = s1 - 1; } if (xdl_emit_hunk_hdr(s1 + 1, e1 - s1, s2 + 1, e2 - s2, func_line.buf, func_line.len, ecb) < 0) return -1; /* * Emit pre-context. */ for (; s2 < xch->i2; s2++) if (xdl_emit_record(&xe->xdf2, s2, " ", ecb) < 0) return -1; for (s1 = xch->i1, s2 = xch->i2;; xch = xch->next) { /* * Merge previous with current change atom. */ for (; s1 < xch->i1 && s2 < xch->i2; s1++, s2++) if (xdl_emit_record(&xe->xdf2, s2, " ", ecb) < 0) return -1; /* * Removes lines from the first file. */ for (s1 = xch->i1; s1 < xch->i1 + xch->chg1; s1++) if (xdl_emit_record(&xe->xdf1, s1, "-", ecb) < 0) return -1; /* * Adds lines from the second file. */ for (s2 = xch->i2; s2 < xch->i2 + xch->chg2; s2++) if (xdl_emit_record(&xe->xdf2, s2, "+", ecb) < 0) return -1; if (xch == xche) break; s1 = xch->i1 + xch->chg1; s2 = xch->i2 + xch->chg2; } /* * Emit post-context. */ for (s2 = xche->i2 + xche->chg2; s2 < e2; s2++) if (xdl_emit_record(&xe->xdf2, s2, " ", ecb) < 0) return -1; } return 0; } deps/libgit2-sys-0.3.8/libgit2/src/xdiff/xdiffi.c0000664000175000017500000003765612610310643016424 0ustar /* * LibXDiff by Davide Libenzi ( File Differential Library ) * Copyright (C) 2003 Davide Libenzi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Davide Libenzi * */ #include "xinclude.h" #include "common.h" #include "integer.h" #define XDL_MAX_COST_MIN 256 #define XDL_HEUR_MIN_COST 256 #define XDL_LINE_MAX (long)((1UL << (CHAR_BIT * sizeof(long) - 1)) - 1) #define XDL_SNAKE_CNT 20 #define XDL_K_HEUR 4 typedef struct s_xdpsplit { long i1, i2; int min_lo, min_hi; } xdpsplit_t; static long xdl_split(unsigned long const *ha1, long off1, long lim1, unsigned long const *ha2, long off2, long lim2, long *kvdf, long *kvdb, int need_min, xdpsplit_t *spl, xdalgoenv_t *xenv); static xdchange_t *xdl_add_change(xdchange_t *xscr, long i1, long i2, long chg1, long chg2); /* * See "An O(ND) Difference Algorithm and its Variations", by Eugene Myers. * Basically considers a "box" (off1, off2, lim1, lim2) and scan from both * the forward diagonal starting from (off1, off2) and the backward diagonal * starting from (lim1, lim2). If the K values on the same diagonal crosses * returns the furthest point of reach. We might end up having to expensive * cases using this algorithm is full, so a little bit of heuristic is needed * to cut the search and to return a suboptimal point. */ static long xdl_split(unsigned long const *ha1, long off1, long lim1, unsigned long const *ha2, long off2, long lim2, long *kvdf, long *kvdb, int need_min, xdpsplit_t *spl, xdalgoenv_t *xenv) { long dmin = off1 - lim2, dmax = lim1 - off2; long fmid = off1 - off2, bmid = lim1 - lim2; long odd = (fmid - bmid) & 1; long fmin = fmid, fmax = fmid; long bmin = bmid, bmax = bmid; long ec, d, i1, i2, prev1, best, dd, v, k; /* * Set initial diagonal values for both forward and backward path. */ kvdf[fmid] = off1; kvdb[bmid] = lim1; for (ec = 1;; ec++) { int got_snake = 0; /* * We need to extent the diagonal "domain" by one. If the next * values exits the box boundaries we need to change it in the * opposite direction because (max - min) must be a power of two. * Also we initialize the external K value to -1 so that we can * avoid extra conditions check inside the core loop. */ if (fmin > dmin) kvdf[--fmin - 1] = -1; else ++fmin; if (fmax < dmax) kvdf[++fmax + 1] = -1; else --fmax; for (d = fmax; d >= fmin; d -= 2) { if (kvdf[d - 1] >= kvdf[d + 1]) i1 = kvdf[d - 1] + 1; else i1 = kvdf[d + 1]; prev1 = i1; i2 = i1 - d; for (; i1 < lim1 && i2 < lim2 && ha1[i1] == ha2[i2]; i1++, i2++); if (i1 - prev1 > xenv->snake_cnt) got_snake = 1; kvdf[d] = i1; if (odd && bmin <= d && d <= bmax && kvdb[d] <= i1) { spl->i1 = i1; spl->i2 = i2; spl->min_lo = spl->min_hi = 1; return ec; } } /* * We need to extent the diagonal "domain" by one. If the next * values exits the box boundaries we need to change it in the * opposite direction because (max - min) must be a power of two. * Also we initialize the external K value to -1 so that we can * avoid extra conditions check inside the core loop. */ if (bmin > dmin) kvdb[--bmin - 1] = XDL_LINE_MAX; else ++bmin; if (bmax < dmax) kvdb[++bmax + 1] = XDL_LINE_MAX; else --bmax; for (d = bmax; d >= bmin; d -= 2) { if (kvdb[d - 1] < kvdb[d + 1]) i1 = kvdb[d - 1]; else i1 = kvdb[d + 1] - 1; prev1 = i1; i2 = i1 - d; for (; i1 > off1 && i2 > off2 && ha1[i1 - 1] == ha2[i2 - 1]; i1--, i2--); if (prev1 - i1 > xenv->snake_cnt) got_snake = 1; kvdb[d] = i1; if (!odd && fmin <= d && d <= fmax && i1 <= kvdf[d]) { spl->i1 = i1; spl->i2 = i2; spl->min_lo = spl->min_hi = 1; return ec; } } if (need_min) continue; /* * If the edit cost is above the heuristic trigger and if * we got a good snake, we sample current diagonals to see * if some of the, have reached an "interesting" path. Our * measure is a function of the distance from the diagonal * corner (i1 + i2) penalized with the distance from the * mid diagonal itself. If this value is above the current * edit cost times a magic factor (XDL_K_HEUR) we consider * it interesting. */ if (got_snake && ec > xenv->heur_min) { for (best = 0, d = fmax; d >= fmin; d -= 2) { dd = d > fmid ? d - fmid: fmid - d; i1 = kvdf[d]; i2 = i1 - d; v = (i1 - off1) + (i2 - off2) - dd; if (v > XDL_K_HEUR * ec && v > best && off1 + xenv->snake_cnt <= i1 && i1 < lim1 && off2 + xenv->snake_cnt <= i2 && i2 < lim2) { for (k = 1; ha1[i1 - k] == ha2[i2 - k]; k++) if (k == xenv->snake_cnt) { best = v; spl->i1 = i1; spl->i2 = i2; break; } } } if (best > 0) { spl->min_lo = 1; spl->min_hi = 0; return ec; } for (best = 0, d = bmax; d >= bmin; d -= 2) { dd = d > bmid ? d - bmid: bmid - d; i1 = kvdb[d]; i2 = i1 - d; v = (lim1 - i1) + (lim2 - i2) - dd; if (v > XDL_K_HEUR * ec && v > best && off1 < i1 && i1 <= lim1 - xenv->snake_cnt && off2 < i2 && i2 <= lim2 - xenv->snake_cnt) { for (k = 0; ha1[i1 + k] == ha2[i2 + k]; k++) if (k == xenv->snake_cnt - 1) { best = v; spl->i1 = i1; spl->i2 = i2; break; } } } if (best > 0) { spl->min_lo = 0; spl->min_hi = 1; return ec; } } /* * Enough is enough. We spent too much time here and now we collect * the furthest reaching path using the (i1 + i2) measure. */ if (ec >= xenv->mxcost) { long fbest, fbest1, bbest, bbest1; fbest = fbest1 = -1; for (d = fmax; d >= fmin; d -= 2) { i1 = XDL_MIN(kvdf[d], lim1); i2 = i1 - d; if (lim2 < i2) i1 = lim2 + d, i2 = lim2; if (fbest < i1 + i2) { fbest = i1 + i2; fbest1 = i1; } } bbest = bbest1 = XDL_LINE_MAX; for (d = bmax; d >= bmin; d -= 2) { i1 = XDL_MAX(off1, kvdb[d]); i2 = i1 - d; if (i2 < off2) i1 = off2 + d, i2 = off2; if (i1 + i2 < bbest) { bbest = i1 + i2; bbest1 = i1; } } if ((lim1 + lim2) - bbest < fbest - (off1 + off2)) { spl->i1 = fbest1; spl->i2 = fbest - fbest1; spl->min_lo = 1; spl->min_hi = 0; } else { spl->i1 = bbest1; spl->i2 = bbest - bbest1; spl->min_lo = 0; spl->min_hi = 1; } return ec; } } } /* * Rule: "Divide et Impera". Recursively split the box in sub-boxes by calling * the box splitting function. Note that the real job (marking changed lines) * is done in the two boundary reaching checks. */ int xdl_recs_cmp(diffdata_t *dd1, long off1, long lim1, diffdata_t *dd2, long off2, long lim2, long *kvdf, long *kvdb, int need_min, xdalgoenv_t *xenv) { unsigned long const *ha1 = dd1->ha, *ha2 = dd2->ha; /* * Shrink the box by walking through each diagonal snake (SW and NE). */ for (; off1 < lim1 && off2 < lim2 && ha1[off1] == ha2[off2]; off1++, off2++); for (; off1 < lim1 && off2 < lim2 && ha1[lim1 - 1] == ha2[lim2 - 1]; lim1--, lim2--); /* * If one dimension is empty, then all records on the other one must * be obviously changed. */ if (off1 == lim1) { char *rchg2 = dd2->rchg; long *rindex2 = dd2->rindex; for (; off2 < lim2; off2++) rchg2[rindex2[off2]] = 1; } else if (off2 == lim2) { char *rchg1 = dd1->rchg; long *rindex1 = dd1->rindex; for (; off1 < lim1; off1++) rchg1[rindex1[off1]] = 1; } else { xdpsplit_t spl; spl.i1 = spl.i2 = 0; /* * Divide ... */ if (xdl_split(ha1, off1, lim1, ha2, off2, lim2, kvdf, kvdb, need_min, &spl, xenv) < 0) { return -1; } /* * ... et Impera. */ if (xdl_recs_cmp(dd1, off1, spl.i1, dd2, off2, spl.i2, kvdf, kvdb, spl.min_lo, xenv) < 0 || xdl_recs_cmp(dd1, spl.i1, lim1, dd2, spl.i2, lim2, kvdf, kvdb, spl.min_hi, xenv) < 0) { return -1; } } return 0; } int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdfenv_t *xe) { size_t ndiags, allocsize; long *kvd, *kvdf, *kvdb; xdalgoenv_t xenv; diffdata_t dd1, dd2; if (XDF_DIFF_ALG(xpp->flags) == XDF_PATIENCE_DIFF) return xdl_do_patience_diff(mf1, mf2, xpp, xe); if (XDF_DIFF_ALG(xpp->flags) == XDF_HISTOGRAM_DIFF) return xdl_do_histogram_diff(mf1, mf2, xpp, xe); if (xdl_prepare_env(mf1, mf2, xpp, xe) < 0) { return -1; } /* * Allocate and setup K vectors to be used by the differential algorithm. * One is to store the forward path and one to store the backward path. */ GITERR_CHECK_ALLOC_ADD3(&ndiags, xe->xdf1.nreff, xe->xdf2.nreff, 3); GITERR_CHECK_ALLOC_MULTIPLY(&allocsize, ndiags, 2); GITERR_CHECK_ALLOC_ADD(&allocsize, allocsize, 2); GITERR_CHECK_ALLOC_MULTIPLY(&allocsize, allocsize, sizeof(long)); if (!(kvd = (long *) xdl_malloc(allocsize))) { xdl_free_env(xe); return -1; } kvdf = kvd; kvdb = kvdf + ndiags; kvdf += xe->xdf2.nreff + 1; kvdb += xe->xdf2.nreff + 1; xenv.mxcost = xdl_bogosqrt(ndiags); if (xenv.mxcost < XDL_MAX_COST_MIN) xenv.mxcost = XDL_MAX_COST_MIN; xenv.snake_cnt = XDL_SNAKE_CNT; xenv.heur_min = XDL_HEUR_MIN_COST; dd1.nrec = xe->xdf1.nreff; dd1.ha = xe->xdf1.ha; dd1.rchg = xe->xdf1.rchg; dd1.rindex = xe->xdf1.rindex; dd2.nrec = xe->xdf2.nreff; dd2.ha = xe->xdf2.ha; dd2.rchg = xe->xdf2.rchg; dd2.rindex = xe->xdf2.rindex; if (xdl_recs_cmp(&dd1, 0, dd1.nrec, &dd2, 0, dd2.nrec, kvdf, kvdb, (xpp->flags & XDF_NEED_MINIMAL) != 0, &xenv) < 0) { xdl_free(kvd); xdl_free_env(xe); return -1; } xdl_free(kvd); return 0; } static xdchange_t *xdl_add_change(xdchange_t *xscr, long i1, long i2, long chg1, long chg2) { xdchange_t *xch; if (!(xch = (xdchange_t *) xdl_malloc(sizeof(xdchange_t)))) return NULL; xch->next = xscr; xch->i1 = i1; xch->i2 = i2; xch->chg1 = chg1; xch->chg2 = chg2; xch->ignore = 0; return xch; } int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) { long ix, ixo, ixs, ixref, grpsiz, nrec = xdf->nrec; char *rchg = xdf->rchg, *rchgo = xdfo->rchg; xrecord_t **recs = xdf->recs; /* * This is the same of what GNU diff does. Move back and forward * change groups for a consistent and pretty diff output. This also * helps in finding joinable change groups and reduce the diff size. */ for (ix = ixo = 0;;) { /* * Find the first changed line in the to-be-compacted file. * We need to keep track of both indexes, so if we find a * changed lines group on the other file, while scanning the * to-be-compacted file, we need to skip it properly. Note * that loops that are testing for changed lines on rchg* do * not need index bounding since the array is prepared with * a zero at position -1 and N. */ for (; ix < nrec && !rchg[ix]; ix++) while (rchgo[ixo++]); if (ix == nrec) break; /* * Record the start of a changed-group in the to-be-compacted file * and find the end of it, on both to-be-compacted and other file * indexes (ix and ixo). */ ixs = ix; for (ix++; rchg[ix]; ix++); for (; rchgo[ixo]; ixo++); do { grpsiz = ix - ixs; /* * If the line before the current change group, is equal to * the last line of the current change group, shift backward * the group. */ while (ixs > 0 && recs[ixs - 1]->ha == recs[ix - 1]->ha && xdl_recmatch(recs[ixs - 1]->ptr, recs[ixs - 1]->size, recs[ix - 1]->ptr, recs[ix - 1]->size, flags)) { rchg[--ixs] = 1; rchg[--ix] = 0; /* * This change might have joined two change groups, * so we try to take this scenario in account by moving * the start index accordingly (and so the other-file * end-of-group index). */ for (; rchg[ixs - 1]; ixs--); while (rchgo[--ixo]); } /* * Record the end-of-group position in case we are matched * with a group of changes in the other file (that is, the * change record before the end-of-group index in the other * file is set). */ ixref = rchgo[ixo - 1] ? ix: nrec; /* * If the first line of the current change group, is equal to * the line next of the current change group, shift forward * the group. */ while (ix < nrec && recs[ixs]->ha == recs[ix]->ha && xdl_recmatch(recs[ixs]->ptr, recs[ixs]->size, recs[ix]->ptr, recs[ix]->size, flags)) { rchg[ixs++] = 0; rchg[ix++] = 1; /* * This change might have joined two change groups, * so we try to take this scenario in account by moving * the start index accordingly (and so the other-file * end-of-group index). Keep tracking the reference * index in case we are shifting together with a * corresponding group of changes in the other file. */ for (; rchg[ix]; ix++); while (rchgo[++ixo]) ixref = ix; } } while (grpsiz != ix - ixs); /* * Try to move back the possibly merged group of changes, to match * the recorded position in the other file. */ while (ixref < ix) { rchg[--ixs] = 1; rchg[--ix] = 0; while (rchgo[--ixo]); } } return 0; } int xdl_build_script(xdfenv_t *xe, xdchange_t **xscr) { xdchange_t *cscr = NULL, *xch; char *rchg1 = xe->xdf1.rchg, *rchg2 = xe->xdf2.rchg; long i1, i2, l1, l2; /* * Trivial. Collects "groups" of changes and creates an edit script. */ for (i1 = xe->xdf1.nrec, i2 = xe->xdf2.nrec; i1 >= 0 || i2 >= 0; i1--, i2--) if (rchg1[i1 - 1] || rchg2[i2 - 1]) { for (l1 = i1; rchg1[i1 - 1]; i1--); for (l2 = i2; rchg2[i2 - 1]; i2--); if (!(xch = xdl_add_change(cscr, i1, i2, l1 - i1, l2 - i2))) { xdl_free_script(cscr); return -1; } cscr = xch; } *xscr = cscr; return 0; } void xdl_free_script(xdchange_t *xscr) { xdchange_t *xch; while ((xch = xscr) != NULL) { xscr = xscr->next; xdl_free(xch); } } static int xdl_call_hunk_func(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, xdemitconf_t const *xecfg) { xdchange_t *xch, *xche; (void)xe; for (xch = xscr; xch; xch = xche->next) { xche = xdl_get_hunk(&xch, xecfg); if (!xch) break; if (xecfg->hunk_func(xch->i1, xche->i1 + xche->chg1 - xch->i1, xch->i2, xche->i2 + xche->chg2 - xch->i2, ecb->priv) < 0) return -1; } return 0; } static void xdl_mark_ignorable(xdchange_t *xscr, xdfenv_t *xe, long flags) { xdchange_t *xch; for (xch = xscr; xch; xch = xch->next) { int ignore = 1; xrecord_t **rec; long i; rec = &xe->xdf1.recs[xch->i1]; for (i = 0; i < xch->chg1 && ignore; i++) ignore = xdl_blankline(rec[i]->ptr, rec[i]->size, flags); rec = &xe->xdf2.recs[xch->i2]; for (i = 0; i < xch->chg2 && ignore; i++) ignore = xdl_blankline(rec[i]->ptr, rec[i]->size, flags); xch->ignore = ignore; } } int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t const *xecfg, xdemitcb_t *ecb) { xdchange_t *xscr; xdfenv_t xe; emit_func_t ef = xecfg->hunk_func ? xdl_call_hunk_func : xdl_emit_diff; if (xdl_do_diff(mf1, mf2, xpp, &xe) < 0) { return -1; } if (xdl_change_compact(&xe.xdf1, &xe.xdf2, xpp->flags) < 0 || xdl_change_compact(&xe.xdf2, &xe.xdf1, xpp->flags) < 0 || xdl_build_script(&xe, &xscr) < 0) { xdl_free_env(&xe); return -1; } if (xscr) { if (xpp->flags & XDF_IGNORE_BLANK_LINES) xdl_mark_ignorable(xscr, &xe, xpp->flags); if (ef(&xe, xscr, ecb, xecfg) < 0) { xdl_free_script(xscr); xdl_free_env(&xe); return -1; } xdl_free_script(xscr); } xdl_free_env(&xe); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/xdiff/xpatience.c0000664000175000017500000002357412572105236017134 0ustar /* * LibXDiff by Davide Libenzi ( File Differential Library ) * Copyright (C) 2003-2009 Davide Libenzi, Johannes E. Schindelin * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Davide Libenzi * */ #include "xinclude.h" #include "xtypes.h" #include "xdiff.h" /* * The basic idea of patience diff is to find lines that are unique in * both files. These are intuitively the ones that we want to see as * common lines. * * The maximal ordered sequence of such line pairs (where ordered means * that the order in the sequence agrees with the order of the lines in * both files) naturally defines an initial set of common lines. * * Now, the algorithm tries to extend the set of common lines by growing * the line ranges where the files have identical lines. * * Between those common lines, the patience diff algorithm is applied * recursively, until no unique line pairs can be found; these line ranges * are handled by the well-known Myers algorithm. */ #define NON_UNIQUE ULONG_MAX /* * This is a hash mapping from line hash to line numbers in the first and * second file. */ struct hashmap { int nr, alloc; struct entry { unsigned long hash; /* * 0 = unused entry, 1 = first line, 2 = second, etc. * line2 is NON_UNIQUE if the line is not unique * in either the first or the second file. */ unsigned long line1, line2; /* * "next" & "previous" are used for the longest common * sequence; * initially, "next" reflects only the order in file1. */ struct entry *next, *previous; } *entries, *first, *last; /* were common records found? */ unsigned long has_matches; mmfile_t *file1, *file2; xdfenv_t *env; xpparam_t const *xpp; }; /* The argument "pass" is 1 for the first file, 2 for the second. */ static void insert_record(int line, struct hashmap *map, int pass) { xrecord_t **records = pass == 1 ? map->env->xdf1.recs : map->env->xdf2.recs; xrecord_t *record = records[line - 1], *other; /* * After xdl_prepare_env() (or more precisely, due to * xdl_classify_record()), the "ha" member of the records (AKA lines) * is _not_ the hash anymore, but a linearized version of it. In * other words, the "ha" member is guaranteed to start with 0 and * the second record's ha can only be 0 or 1, etc. * * So we multiply ha by 2 in the hope that the hashing was * "unique enough". */ int index = (int)((record->ha << 1) % map->alloc); while (map->entries[index].line1) { other = map->env->xdf1.recs[map->entries[index].line1 - 1]; if (map->entries[index].hash != record->ha || !xdl_recmatch(record->ptr, record->size, other->ptr, other->size, map->xpp->flags)) { if (++index >= map->alloc) index = 0; continue; } if (pass == 2) map->has_matches = 1; if (pass == 1 || map->entries[index].line2) map->entries[index].line2 = NON_UNIQUE; else map->entries[index].line2 = line; return; } if (pass == 2) return; map->entries[index].line1 = line; map->entries[index].hash = record->ha; if (!map->first) map->first = map->entries + index; if (map->last) { map->last->next = map->entries + index; map->entries[index].previous = map->last; } map->last = map->entries + index; map->nr++; } /* * This function has to be called for each recursion into the inter-hunk * parts, as previously non-unique lines can become unique when being * restricted to a smaller part of the files. * * It is assumed that env has been prepared using xdl_prepare(). */ static int fill_hashmap(mmfile_t *file1, mmfile_t *file2, xpparam_t const *xpp, xdfenv_t *env, struct hashmap *result, int line1, int count1, int line2, int count2) { result->file1 = file1; result->file2 = file2; result->xpp = xpp; result->env = env; /* We know exactly how large we want the hash map */ result->alloc = count1 * 2; result->entries = (struct entry *) xdl_malloc(result->alloc * sizeof(struct entry)); if (!result->entries) return -1; memset(result->entries, 0, result->alloc * sizeof(struct entry)); /* First, fill with entries from the first file */ while (count1--) insert_record(line1++, result, 1); /* Then search for matches in the second file */ while (count2--) insert_record(line2++, result, 2); return 0; } /* * Find the longest sequence with a smaller last element (meaning a smaller * line2, as we construct the sequence with entries ordered by line1). */ static int binary_search(struct entry **sequence, int longest, struct entry *entry) { int left = -1, right = longest; while (left + 1 < right) { int middle = (left + right) / 2; /* by construction, no two entries can be equal */ if (sequence[middle]->line2 > entry->line2) right = middle; else left = middle; } /* return the index in "sequence", _not_ the sequence length */ return left; } /* * The idea is to start with the list of common unique lines sorted by * the order in file1. For each of these pairs, the longest (partial) * sequence whose last element's line2 is smaller is determined. * * For efficiency, the sequences are kept in a list containing exactly one * item per sequence length: the sequence with the smallest last * element (in terms of line2). */ static struct entry *find_longest_common_sequence(struct hashmap *map) { struct entry **sequence = xdl_malloc(map->nr * sizeof(struct entry *)); int longest = 0, i; struct entry *entry; for (entry = map->first; entry; entry = entry->next) { if (!entry->line2 || entry->line2 == NON_UNIQUE) continue; i = binary_search(sequence, longest, entry); entry->previous = i < 0 ? NULL : sequence[i]; sequence[++i] = entry; if (i == longest) longest++; } /* No common unique lines were found */ if (!longest) { xdl_free(sequence); return NULL; } /* Iterate starting at the last element, adjusting the "next" members */ entry = sequence[longest - 1]; entry->next = NULL; while (entry->previous) { entry->previous->next = entry; entry = entry->previous; } xdl_free(sequence); return entry; } static int match(struct hashmap *map, int line1, int line2) { xrecord_t *record1 = map->env->xdf1.recs[line1 - 1]; xrecord_t *record2 = map->env->xdf2.recs[line2 - 1]; return xdl_recmatch(record1->ptr, record1->size, record2->ptr, record2->size, map->xpp->flags); } static int patience_diff(mmfile_t *file1, mmfile_t *file2, xpparam_t const *xpp, xdfenv_t *env, int line1, int count1, int line2, int count2); static int walk_common_sequence(struct hashmap *map, struct entry *first, int line1, int count1, int line2, int count2) { int end1 = line1 + count1, end2 = line2 + count2; int next1, next2; for (;;) { /* Try to grow the line ranges of common lines */ if (first) { next1 = first->line1; next2 = first->line2; while (next1 > line1 && next2 > line2 && match(map, next1 - 1, next2 - 1)) { next1--; next2--; } } else { next1 = end1; next2 = end2; } while (line1 < next1 && line2 < next2 && match(map, line1, line2)) { line1++; line2++; } /* Recurse */ if (next1 > line1 || next2 > line2) { struct hashmap submap; memset(&submap, 0, sizeof(submap)); if (patience_diff(map->file1, map->file2, map->xpp, map->env, line1, next1 - line1, line2, next2 - line2)) return -1; } if (!first) return 0; while (first->next && first->next->line1 == first->line1 + 1 && first->next->line2 == first->line2 + 1) first = first->next; line1 = first->line1 + 1; line2 = first->line2 + 1; first = first->next; } } static int fall_back_to_classic_diff(struct hashmap *map, int line1, int count1, int line2, int count2) { xpparam_t xpp; xpp.flags = map->xpp->flags & ~XDF_DIFF_ALGORITHM_MASK; return xdl_fall_back_diff(map->env, &xpp, line1, count1, line2, count2); } /* * Recursively find the longest common sequence of unique lines, * and if none was found, ask xdl_do_diff() to do the job. * * This function assumes that env was prepared with xdl_prepare_env(). */ static int patience_diff(mmfile_t *file1, mmfile_t *file2, xpparam_t const *xpp, xdfenv_t *env, int line1, int count1, int line2, int count2) { struct hashmap map; struct entry *first; int result = 0; /* trivial case: one side is empty */ if (!count1) { while(count2--) env->xdf2.rchg[line2++ - 1] = 1; return 0; } else if (!count2) { while(count1--) env->xdf1.rchg[line1++ - 1] = 1; return 0; } memset(&map, 0, sizeof(map)); if (fill_hashmap(file1, file2, xpp, env, &map, line1, count1, line2, count2)) return -1; /* are there any matching lines at all? */ if (!map.has_matches) { while(count1--) env->xdf1.rchg[line1++ - 1] = 1; while(count2--) env->xdf2.rchg[line2++ - 1] = 1; xdl_free(map.entries); return 0; } first = find_longest_common_sequence(&map); if (first) result = walk_common_sequence(&map, first, line1, count1, line2, count2); else result = fall_back_to_classic_diff(&map, line1, count1, line2, count2); xdl_free(map.entries); return result; } int xdl_do_patience_diff(mmfile_t *file1, mmfile_t *file2, xpparam_t const *xpp, xdfenv_t *env) { if (xdl_prepare_env(file1, file2, xpp, env) < 0) return -1; /* environment is cleaned up in xdl_diff() */ return patience_diff(file1, file2, xpp, env, 1, env->xdf1.nrec, 1, env->xdf2.nrec); } deps/libgit2-sys-0.3.8/libgit2/src/xdiff/xutils.h0000664000175000017500000000366212572105236016505 0ustar /* * LibXDiff by Davide Libenzi ( File Differential Library ) * Copyright (C) 2003 Davide Libenzi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Davide Libenzi * */ #if !defined(XUTILS_H) #define XUTILS_H long xdl_bogosqrt(long n); int xdl_emit_diffrec(char const *rec, long size, char const *pre, long psize, xdemitcb_t *ecb); int xdl_cha_init(chastore_t *cha, long isize, long icount); void xdl_cha_free(chastore_t *cha); void *xdl_cha_alloc(chastore_t *cha); void *xdl_cha_first(chastore_t *cha); void *xdl_cha_next(chastore_t *cha); long xdl_guess_lines(mmfile_t *mf, long sample); int xdl_blankline(const char *line, long size, long flags); int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags); unsigned long xdl_hash_record(char const **data, char const *top, long flags); unsigned int xdl_hashbits(unsigned int size); int xdl_num_out(char *out, long val); long xdl_atol(char const *str, char const **next); int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, const char *func, long funclen, xdemitcb_t *ecb); int xdl_fall_back_diff(xdfenv_t *diff_env, xpparam_t const *xpp, int line1, int count1, int line2, int count2); #endif /* #if !defined(XUTILS_H) */ deps/libgit2-sys-0.3.8/libgit2/src/xdiff/xtypes.h0000664000175000017500000000307212426525445016512 0ustar /* * LibXDiff by Davide Libenzi ( File Differential Library ) * Copyright (C) 2003 Davide Libenzi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Davide Libenzi * */ #if !defined(XTYPES_H) #define XTYPES_H typedef struct s_chanode { struct s_chanode *next; long icurr; } chanode_t; typedef struct s_chastore { chanode_t *head, *tail; long isize, nsize; chanode_t *ancur; chanode_t *sncur; long scurr; } chastore_t; typedef struct s_xrecord { struct s_xrecord *next; char const *ptr; long size; unsigned long ha; } xrecord_t; typedef struct s_xdfile { chastore_t rcha; long nrec; unsigned int hbits; xrecord_t **rhash; long dstart, dend; xrecord_t **recs; char *rchg; long *rindex; long nreff; unsigned long *ha; } xdfile_t; typedef struct s_xdfenv { xdfile_t xdf1, xdf2; } xdfenv_t; #endif /* #if !defined(XTYPES_H) */ deps/libgit2-sys-0.3.8/libgit2/src/xdiff/xmerge.c0000664000175000017500000004026312610310643016426 0ustar /* * LibXDiff by Davide Libenzi ( File Differential Library ) * Copyright (C) 2003-2006 Davide Libenzi, Johannes E. Schindelin * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Davide Libenzi * */ #include "xinclude.h" #include "common.h" typedef struct s_xdmerge { struct s_xdmerge *next; /* * 0 = conflict, * 1 = no conflict, take first, * 2 = no conflict, take second. * 3 = no conflict, take both. */ int mode; /* * These point at the respective postimages. E.g. is * how side #1 wants to change the common ancestor; if there is no * overlap, lines before i1 in the postimage of side #1 appear * in the merge result as a region touched by neither side. */ long i1, i2; long chg1, chg2; /* * These point at the preimage; of course there is just one * preimage, that is from the shared common ancestor. */ long i0; long chg0; } xdmerge_t; static int xdl_append_merge(xdmerge_t **merge, int mode, long i0, long chg0, long i1, long chg1, long i2, long chg2) { xdmerge_t *m = *merge; if (m && (i1 <= m->i1 + m->chg1 || i2 <= m->i2 + m->chg2)) { if (mode != m->mode) m->mode = 0; m->chg0 = i0 + chg0 - m->i0; m->chg1 = i1 + chg1 - m->i1; m->chg2 = i2 + chg2 - m->i2; } else { m = xdl_malloc(sizeof(xdmerge_t)); if (!m) return -1; m->next = NULL; m->mode = mode; m->i0 = i0; m->chg0 = chg0; m->i1 = i1; m->chg1 = chg1; m->i2 = i2; m->chg2 = chg2; if (*merge) (*merge)->next = m; *merge = m; } return 0; } static int xdl_cleanup_merge(xdmerge_t *c) { int count = 0; xdmerge_t *next_c; /* were there conflicts? */ for (; c; c = next_c) { if (c->mode == 0) count++; next_c = c->next; free(c); } return count; } static int xdl_merge_cmp_lines(xdfenv_t *xe1, int i1, xdfenv_t *xe2, int i2, int line_count, long flags) { int i; xrecord_t **rec1 = xe1->xdf2.recs + i1; xrecord_t **rec2 = xe2->xdf2.recs + i2; for (i = 0; i < line_count; i++) { int result = xdl_recmatch(rec1[i]->ptr, rec1[i]->size, rec2[i]->ptr, rec2[i]->size, flags); if (!result) return -1; } return 0; } static int xdl_recs_copy_0(size_t *out, int use_orig, xdfenv_t *xe, int i, int count, int add_nl, char *dest) { xrecord_t **recs; size_t size = 0; *out = 0; recs = (use_orig ? xe->xdf1.recs : xe->xdf2.recs) + i; if (count < 1) return 0; for (i = 0; i < count; ) { if (dest) memcpy(dest + size, recs[i]->ptr, recs[i]->size); GITERR_CHECK_ALLOC_ADD(&size, size, recs[i++]->size); } if (add_nl) { i = recs[count - 1]->size; if (i == 0 || recs[count - 1]->ptr[i - 1] != '\n') { if (dest) dest[size] = '\n'; GITERR_CHECK_ALLOC_ADD(&size, size, 1); } } *out = size; return 0; } static int xdl_recs_copy(size_t *out, xdfenv_t *xe, int i, int count, int add_nl, char *dest) { return xdl_recs_copy_0(out, 0, xe, i, count, add_nl, dest); } static int xdl_orig_copy(size_t *out, xdfenv_t *xe, int i, int count, int add_nl, char *dest) { return xdl_recs_copy_0(out, 1, xe, i, count, add_nl, dest); } static int fill_conflict_hunk(size_t *out, xdfenv_t *xe1, const char *name1, xdfenv_t *xe2, const char *name2, const char *name3, size_t size, int i, int style, xdmerge_t *m, char *dest, int marker_size) { int marker1_size = (name1 ? (int)strlen(name1) + 1 : 0); int marker2_size = (name2 ? (int)strlen(name2) + 1 : 0); int marker3_size = (name3 ? (int)strlen(name3) + 1 : 0); size_t copied; *out = 0; if (marker_size <= 0) marker_size = DEFAULT_CONFLICT_MARKER_SIZE; /* Before conflicting part */ if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0, dest ? dest + size : NULL) < 0) return -1; GITERR_CHECK_ALLOC_ADD(&size, size, copied); if (!dest) { GITERR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, marker1_size); } else { memset(dest + size, '<', marker_size); size += marker_size; if (marker1_size) { dest[size] = ' '; memcpy(dest + size + 1, name1, marker1_size - 1); size += marker1_size; } dest[size++] = '\n'; } /* Postimage from side #1 */ if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, 1, dest ? dest + size : NULL) < 0) return -1; GITERR_CHECK_ALLOC_ADD(&size, size, copied); if (style == XDL_MERGE_DIFF3) { /* Shared preimage */ if (!dest) { GITERR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, marker3_size); } else { memset(dest + size, '|', marker_size); size += marker_size; if (marker3_size) { dest[size] = ' '; memcpy(dest + size + 1, name3, marker3_size - 1); size += marker3_size; } dest[size++] = '\n'; } if (xdl_orig_copy(&copied, xe1, m->i0, m->chg0, 1, dest ? dest + size : NULL) < 0) return -1; GITERR_CHECK_ALLOC_ADD(&size, size, copied); } if (!dest) { GITERR_CHECK_ALLOC_ADD3(&size, size, marker_size, 1); } else { memset(dest + size, '=', marker_size); size += marker_size; dest[size++] = '\n'; } /* Postimage from side #2 */ if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, 1, dest ? dest + size : NULL) < 0) return -1; GITERR_CHECK_ALLOC_ADD(&size, size, copied); if (!dest) { GITERR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, marker2_size); } else { memset(dest + size, '>', marker_size); size += marker_size; if (marker2_size) { dest[size] = ' '; memcpy(dest + size + 1, name2, marker2_size - 1); size += marker2_size; } dest[size++] = '\n'; } *out = size; return 0; } static int xdl_fill_merge_buffer(size_t *out, xdfenv_t *xe1, const char *name1, xdfenv_t *xe2, const char *name2, const char *ancestor_name, int favor, xdmerge_t *m, char *dest, int style, int marker_size) { size_t size, copied; int i; *out = 0; for (size = i = 0; m; m = m->next) { if (favor && !m->mode) m->mode = favor; if (m->mode == 0) { if (fill_conflict_hunk(&size, xe1, name1, xe2, name2, ancestor_name, size, i, style, m, dest, marker_size) < 0) return -1; } else if (m->mode & 3) { /* Before conflicting part */ if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0, dest ? dest + size : NULL) < 0) return -1; GITERR_CHECK_ALLOC_ADD(&size, size, copied); /* Postimage from side #1 */ if (m->mode & 1) { if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, (m->mode & 2), dest ? dest + size : NULL) < 0) return -1; GITERR_CHECK_ALLOC_ADD(&size, size, copied); } /* Postimage from side #2 */ if (m->mode & 2) { if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, 0, dest ? dest + size : NULL) < 0) return -1; GITERR_CHECK_ALLOC_ADD(&size, size, copied); } } else continue; i = m->i1 + m->chg1; } if (xdl_recs_copy(&copied, xe1, i, xe1->xdf2.nrec - i, 0, dest ? dest + size : NULL) < 0) return -1; GITERR_CHECK_ALLOC_ADD(&size, size, copied); *out = size; return 0; } /* * Sometimes, changes are not quite identical, but differ in only a few * lines. Try hard to show only these few lines as conflicting. */ static int xdl_refine_conflicts(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m, xpparam_t const *xpp) { for (; m; m = m->next) { mmfile_t t1, t2; xdfenv_t xe; xdchange_t *xscr, *x; int i1 = m->i1, i2 = m->i2; /* let's handle just the conflicts */ if (m->mode) continue; /* no sense refining a conflict when one side is empty */ if (m->chg1 == 0 || m->chg2 == 0) continue; /* * This probably does not work outside git, since * we have a very simple mmfile structure. */ t1.ptr = (char *)xe1->xdf2.recs[m->i1]->ptr; t1.size = xe1->xdf2.recs[m->i1 + m->chg1 - 1]->ptr + xe1->xdf2.recs[m->i1 + m->chg1 - 1]->size - t1.ptr; t2.ptr = (char *)xe2->xdf2.recs[m->i2]->ptr; t2.size = xe2->xdf2.recs[m->i2 + m->chg2 - 1]->ptr + xe2->xdf2.recs[m->i2 + m->chg2 - 1]->size - t2.ptr; if (xdl_do_diff(&t1, &t2, xpp, &xe) < 0) return -1; if (xdl_change_compact(&xe.xdf1, &xe.xdf2, xpp->flags) < 0 || xdl_change_compact(&xe.xdf2, &xe.xdf1, xpp->flags) < 0 || xdl_build_script(&xe, &xscr) < 0) { xdl_free_env(&xe); return -1; } if (!xscr) { /* If this happens, the changes are identical. */ xdl_free_env(&xe); m->mode = 4; continue; } x = xscr; m->i1 = xscr->i1 + i1; m->chg1 = xscr->chg1; m->i2 = xscr->i2 + i2; m->chg2 = xscr->chg2; while (xscr->next) { xdmerge_t *m2 = xdl_malloc(sizeof(xdmerge_t)); if (!m2) { xdl_free_env(&xe); xdl_free_script(x); return -1; } xscr = xscr->next; m2->next = m->next; m->next = m2; m = m2; m->mode = 0; m->i1 = xscr->i1 + i1; m->chg1 = xscr->chg1; m->i2 = xscr->i2 + i2; m->chg2 = xscr->chg2; } xdl_free_env(&xe); xdl_free_script(x); } return 0; } static int line_contains_alnum(const char *ptr, long size) { while (size--) if (isalnum((unsigned char)*(ptr++))) return 1; return 0; } static int lines_contain_alnum(xdfenv_t *xe, int i, int chg) { for (; chg; chg--, i++) if (line_contains_alnum(xe->xdf2.recs[i]->ptr, xe->xdf2.recs[i]->size)) return 1; return 0; } /* * This function merges m and m->next, marking everything between those hunks * as conflicting, too. */ static void xdl_merge_two_conflicts(xdmerge_t *m) { xdmerge_t *next_m = m->next; m->chg1 = next_m->i1 + next_m->chg1 - m->i1; m->chg2 = next_m->i2 + next_m->chg2 - m->i2; m->next = next_m->next; free(next_m); } /* * If there are less than 3 non-conflicting lines between conflicts, * it appears simpler -- because it takes up less (or as many) lines -- * if the lines are moved into the conflicts. */ static int xdl_simplify_non_conflicts(xdfenv_t *xe1, xdmerge_t *m, int simplify_if_no_alnum) { int result = 0; if (!m) return result; for (;;) { xdmerge_t *next_m = m->next; int begin, end; if (!next_m) return result; begin = m->i1 + m->chg1; end = next_m->i1; if (m->mode != 0 || next_m->mode != 0 || (end - begin > 3 && (!simplify_if_no_alnum || lines_contain_alnum(xe1, begin, end - begin)))) { m = next_m; } else { result++; xdl_merge_two_conflicts(m); } } } /* * level == 0: mark all overlapping changes as conflict * level == 1: mark overlapping changes as conflict only if not identical * level == 2: analyze non-identical changes for minimal conflict set * level == 3: analyze non-identical changes for minimal conflict set, but * treat hunks not containing any letter or number as conflicting * * returns < 0 on error, == 0 for no conflicts, else number of conflicts */ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, xdfenv_t *xe2, xdchange_t *xscr2, xmparam_t const *xmp, mmbuffer_t *result) { xdmerge_t *changes, *c; xpparam_t const *xpp = &xmp->xpp; const char *const ancestor_name = xmp->ancestor; const char *const name1 = xmp->file1; const char *const name2 = xmp->file2; int i0, i1, i2, chg0, chg1, chg2; int level = xmp->level; int style = xmp->style; int favor = xmp->favor; if (style == XDL_MERGE_DIFF3) { /* * "diff3 -m" output does not make sense for anything * more aggressive than XDL_MERGE_EAGER. */ if (XDL_MERGE_EAGER < level) level = XDL_MERGE_EAGER; } c = changes = NULL; while (xscr1 && xscr2) { if (!changes) changes = c; if (xscr1->i1 + xscr1->chg1 < xscr2->i1) { i0 = xscr1->i1; i1 = xscr1->i2; i2 = xscr2->i2 - xscr2->i1 + xscr1->i1; chg0 = xscr1->chg1; chg1 = xscr1->chg2; chg2 = xscr1->chg1; if (xdl_append_merge(&c, 1, i0, chg0, i1, chg1, i2, chg2)) { xdl_cleanup_merge(changes); return -1; } xscr1 = xscr1->next; continue; } if (xscr2->i1 + xscr2->chg1 < xscr1->i1) { i0 = xscr2->i1; i1 = xscr1->i2 - xscr1->i1 + xscr2->i1; i2 = xscr2->i2; chg0 = xscr2->chg1; chg1 = xscr2->chg1; chg2 = xscr2->chg2; if (xdl_append_merge(&c, 2, i0, chg0, i1, chg1, i2, chg2)) { xdl_cleanup_merge(changes); return -1; } xscr2 = xscr2->next; continue; } if (level == XDL_MERGE_MINIMAL || xscr1->i1 != xscr2->i1 || xscr1->chg1 != xscr2->chg1 || xscr1->chg2 != xscr2->chg2 || xdl_merge_cmp_lines(xe1, xscr1->i2, xe2, xscr2->i2, xscr1->chg2, xpp->flags)) { /* conflict */ int off = xscr1->i1 - xscr2->i1; int ffo = off + xscr1->chg1 - xscr2->chg1; i0 = xscr1->i1; i1 = xscr1->i2; i2 = xscr2->i2; if (off > 0) { i0 -= off; i1 -= off; } else i2 += off; chg0 = xscr1->i1 + xscr1->chg1 - i0; chg1 = xscr1->i2 + xscr1->chg2 - i1; chg2 = xscr2->i2 + xscr2->chg2 - i2; if (ffo < 0) { chg0 -= ffo; chg1 -= ffo; } else chg2 += ffo; if (xdl_append_merge(&c, 0, i0, chg0, i1, chg1, i2, chg2)) { xdl_cleanup_merge(changes); return -1; } } i1 = xscr1->i1 + xscr1->chg1; i2 = xscr2->i1 + xscr2->chg1; if (i1 >= i2) xscr2 = xscr2->next; if (i2 >= i1) xscr1 = xscr1->next; } while (xscr1) { if (!changes) changes = c; i0 = xscr1->i1; i1 = xscr1->i2; i2 = xscr1->i1 + xe2->xdf2.nrec - xe2->xdf1.nrec; chg0 = xscr1->chg1; chg1 = xscr1->chg2; chg2 = xscr1->chg1; if (xdl_append_merge(&c, 1, i0, chg0, i1, chg1, i2, chg2)) { xdl_cleanup_merge(changes); return -1; } xscr1 = xscr1->next; } while (xscr2) { if (!changes) changes = c; i0 = xscr2->i1; i1 = xscr2->i1 + xe1->xdf2.nrec - xe1->xdf1.nrec; i2 = xscr2->i2; chg0 = xscr2->chg1; chg1 = xscr2->chg1; chg2 = xscr2->chg2; if (xdl_append_merge(&c, 2, i0, chg0, i1, chg1, i2, chg2)) { xdl_cleanup_merge(changes); return -1; } xscr2 = xscr2->next; } if (!changes) changes = c; /* refine conflicts */ if (XDL_MERGE_ZEALOUS <= level && (xdl_refine_conflicts(xe1, xe2, changes, xpp) < 0 || xdl_simplify_non_conflicts(xe1, changes, XDL_MERGE_ZEALOUS < level) < 0)) { xdl_cleanup_merge(changes); return -1; } /* output */ if (result) { int marker_size = xmp->marker_size; size_t size; if (xdl_fill_merge_buffer(&size, xe1, name1, xe2, name2, ancestor_name, favor, changes, NULL, style, marker_size) < 0) return -1; result->ptr = xdl_malloc(size); if (!result->ptr) { xdl_cleanup_merge(changes); return -1; } result->size = size; if (xdl_fill_merge_buffer(&size, xe1, name1, xe2, name2, ancestor_name, favor, changes, result->ptr, style, marker_size) < 0) return -1; } return xdl_cleanup_merge(changes); } int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2, xmparam_t const *xmp, mmbuffer_t *result) { xdchange_t *xscr1, *xscr2; xdfenv_t xe1, xe2; int status; xpparam_t const *xpp = &xmp->xpp; result->ptr = NULL; result->size = 0; if (xdl_do_diff(orig, mf1, xpp, &xe1) < 0 || xdl_do_diff(orig, mf2, xpp, &xe2) < 0) { return -1; } if (xdl_change_compact(&xe1.xdf1, &xe1.xdf2, xpp->flags) < 0 || xdl_change_compact(&xe1.xdf2, &xe1.xdf1, xpp->flags) < 0 || xdl_build_script(&xe1, &xscr1) < 0) { xdl_free_env(&xe1); return -1; } if (xdl_change_compact(&xe2.xdf1, &xe2.xdf2, xpp->flags) < 0 || xdl_change_compact(&xe2.xdf2, &xe2.xdf1, xpp->flags) < 0 || xdl_build_script(&xe2, &xscr2) < 0) { xdl_free_env(&xe2); return -1; } status = 0; if (!xscr1) { result->ptr = xdl_malloc(mf2->size); memcpy(result->ptr, mf2->ptr, mf2->size); result->size = mf2->size; } else if (!xscr2) { result->ptr = xdl_malloc(mf1->size); memcpy(result->ptr, mf1->ptr, mf1->size); result->size = mf1->size; } else { status = xdl_do_merge(&xe1, xscr1, &xe2, xscr2, xmp, result); } xdl_free_script(xscr1); xdl_free_script(xscr2); xdl_free_env(&xe1); xdl_free_env(&xe2); return status; } deps/libgit2-sys-0.3.8/libgit2/src/xdiff/xdiff.h0000664000175000017500000000720512610310643016243 0ustar /* * LibXDiff by Davide Libenzi ( File Differential Library ) * Copyright (C) 2003 Davide Libenzi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Davide Libenzi * */ #include "util.h" #if !defined(XDIFF_H) #define XDIFF_H #ifdef __cplusplus extern "C" { #endif /* #ifdef __cplusplus */ #define XDF_NEED_MINIMAL (1 << 1) #define XDF_IGNORE_WHITESPACE (1 << 2) #define XDF_IGNORE_WHITESPACE_CHANGE (1 << 3) #define XDF_IGNORE_WHITESPACE_AT_EOL (1 << 4) #define XDF_WHITESPACE_FLAGS (XDF_IGNORE_WHITESPACE | XDF_IGNORE_WHITESPACE_CHANGE | XDF_IGNORE_WHITESPACE_AT_EOL) #define XDF_PATIENCE_DIFF (1 << 5) #define XDF_HISTOGRAM_DIFF (1 << 6) #define XDF_DIFF_ALGORITHM_MASK (XDF_PATIENCE_DIFF | XDF_HISTOGRAM_DIFF) #define XDF_DIFF_ALG(x) ((x) & XDF_DIFF_ALGORITHM_MASK) #define XDF_IGNORE_BLANK_LINES (1 << 7) #define XDL_EMIT_FUNCNAMES (1 << 0) #define XDL_EMIT_COMMON (1 << 1) #define XDL_EMIT_FUNCCONTEXT (1 << 2) #define XDL_MMB_READONLY (1 << 0) #define XDL_MMF_ATOMIC (1 << 0) #define XDL_BDOP_INS 1 #define XDL_BDOP_CPY 2 #define XDL_BDOP_INSB 3 /* merge simplification levels */ #define XDL_MERGE_MINIMAL 0 #define XDL_MERGE_EAGER 1 #define XDL_MERGE_ZEALOUS 2 #define XDL_MERGE_ZEALOUS_ALNUM 3 /* merge favor modes */ #define XDL_MERGE_FAVOR_OURS 1 #define XDL_MERGE_FAVOR_THEIRS 2 #define XDL_MERGE_FAVOR_UNION 3 /* merge output styles */ #define XDL_MERGE_DIFF3 1 typedef struct s_mmfile { char *ptr; size_t size; } mmfile_t; typedef struct s_mmbuffer { char *ptr; size_t size; } mmbuffer_t; typedef struct s_xpparam { unsigned long flags; } xpparam_t; typedef struct s_xdemitcb { void *priv; int (*outf)(void *, mmbuffer_t *, int); } xdemitcb_t; typedef long (*find_func_t)(const char *line, long line_len, char *buffer, long buffer_size, void *priv); typedef int (*xdl_emit_hunk_consume_func_t)(long start_a, long count_a, long start_b, long count_b, void *cb_data); typedef struct s_xdemitconf { long ctxlen; long interhunkctxlen; unsigned long flags; find_func_t find_func; void *find_func_priv; xdl_emit_hunk_consume_func_t hunk_func; } xdemitconf_t; typedef struct s_bdiffparam { long bsize; } bdiffparam_t; #define xdl_malloc(x) git__malloc(x) #define xdl_free(ptr) git__free(ptr) #define xdl_realloc(ptr,x) git__realloc(ptr,x) void *xdl_mmfile_first(mmfile_t *mmf, long *size); long xdl_mmfile_size(mmfile_t *mmf); int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t const *xecfg, xdemitcb_t *ecb); typedef struct s_xmparam { xpparam_t xpp; int marker_size; int level; int favor; int style; const char *ancestor; /* label for orig */ const char *file1; /* label for mf1 */ const char *file2; /* label for mf2 */ } xmparam_t; #define DEFAULT_CONFLICT_MARKER_SIZE 7 int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2, xmparam_t const *xmp, mmbuffer_t *result); #ifdef __cplusplus } #endif /* #ifdef __cplusplus */ #endif /* #if !defined(XDIFF_H) */ deps/libgit2-sys-0.3.8/libgit2/src/xdiff/xutils.c0000664000175000017500000002132412572105236016473 0ustar /* * LibXDiff by Davide Libenzi ( File Differential Library ) * Copyright (C) 2003 Davide Libenzi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Davide Libenzi * */ #include "xinclude.h" long xdl_bogosqrt(long n) { long i; /* * Classical integer square root approximation using shifts. */ for (i = 1; n > 0; n >>= 2) i <<= 1; return i; } int xdl_emit_diffrec(char const *rec, long size, char const *pre, long psize, xdemitcb_t *ecb) { int i = 2; mmbuffer_t mb[3]; mb[0].ptr = (char *) pre; mb[0].size = psize; mb[1].ptr = (char *) rec; mb[1].size = size; if (size > 0 && rec[size - 1] != '\n') { mb[2].ptr = (char *) "\n\\ No newline at end of file\n"; mb[2].size = strlen(mb[2].ptr); i++; } if (ecb->outf(ecb->priv, mb, i) < 0) { return -1; } return 0; } void *xdl_mmfile_first(mmfile_t *mmf, long *size) { *size = (long)mmf->size; return mmf->ptr; } long xdl_mmfile_size(mmfile_t *mmf) { return (long)mmf->size; } int xdl_cha_init(chastore_t *cha, long isize, long icount) { cha->head = cha->tail = NULL; cha->isize = isize; cha->nsize = icount * isize; cha->ancur = cha->sncur = NULL; cha->scurr = 0; return 0; } void xdl_cha_free(chastore_t *cha) { chanode_t *cur, *tmp; for (cur = cha->head; (tmp = cur) != NULL;) { cur = cur->next; xdl_free(tmp); } } void *xdl_cha_alloc(chastore_t *cha) { chanode_t *ancur; void *data; if (!(ancur = cha->ancur) || ancur->icurr == cha->nsize) { if (!(ancur = (chanode_t *) xdl_malloc(sizeof(chanode_t) + cha->nsize))) { return NULL; } ancur->icurr = 0; ancur->next = NULL; if (cha->tail) cha->tail->next = ancur; if (!cha->head) cha->head = ancur; cha->tail = ancur; cha->ancur = ancur; } data = (char *) ancur + sizeof(chanode_t) + ancur->icurr; ancur->icurr += cha->isize; return data; } long xdl_guess_lines(mmfile_t *mf, long sample) { long nl = 0, size, tsize = 0; char const *data, *cur, *top; if ((cur = data = xdl_mmfile_first(mf, &size)) != NULL) { for (top = data + size; nl < sample && cur < top; ) { nl++; if (!(cur = memchr(cur, '\n', top - cur))) cur = top; else cur++; } tsize += (long) (cur - data); } if (nl && tsize) nl = xdl_mmfile_size(mf) / (tsize / nl); return nl + 1; } int xdl_blankline(const char *line, long size, long flags) { long i; if (!(flags & XDF_WHITESPACE_FLAGS)) return (size <= 1); for (i = 0; i < size && XDL_ISSPACE(line[i]); i++) ; return (i == size); } int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags) { int i1, i2; if (s1 == s2 && !memcmp(l1, l2, s1)) return 1; if (!(flags & XDF_WHITESPACE_FLAGS)) return 0; i1 = 0; i2 = 0; /* * -w matches everything that matches with -b, and -b in turn * matches everything that matches with --ignore-space-at-eol. * * Each flavor of ignoring needs different logic to skip whitespaces * while we have both sides to compare. */ if (flags & XDF_IGNORE_WHITESPACE) { goto skip_ws; while (i1 < s1 && i2 < s2) { if (l1[i1++] != l2[i2++]) return 0; skip_ws: while (i1 < s1 && XDL_ISSPACE(l1[i1])) i1++; while (i2 < s2 && XDL_ISSPACE(l2[i2])) i2++; } } else if (flags & XDF_IGNORE_WHITESPACE_CHANGE) { while (i1 < s1 && i2 < s2) { if (XDL_ISSPACE(l1[i1]) && XDL_ISSPACE(l2[i2])) { /* Skip matching spaces and try again */ while (i1 < s1 && XDL_ISSPACE(l1[i1])) i1++; while (i2 < s2 && XDL_ISSPACE(l2[i2])) i2++; continue; } if (l1[i1++] != l2[i2++]) return 0; } } else if (flags & XDF_IGNORE_WHITESPACE_AT_EOL) { while (i1 < s1 && i2 < s2 && l1[i1++] == l2[i2++]) ; /* keep going */ } /* * After running out of one side, the remaining side must have * nothing but whitespace for the lines to match. Note that * ignore-whitespace-at-eol case may break out of the loop * while there still are characters remaining on both lines. */ if (i1 < s1) { while (i1 < s1 && XDL_ISSPACE(l1[i1])) i1++; if (s1 != i1) return 0; } if (i2 < s2) { while (i2 < s2 && XDL_ISSPACE(l2[i2])) i2++; return (s2 == i2); } return 1; } static unsigned long xdl_hash_record_with_whitespace(char const **data, char const *top, long flags) { unsigned long ha = 5381; char const *ptr = *data; for (; ptr < top && *ptr != '\n'; ptr++) { if (XDL_ISSPACE(*ptr)) { const char *ptr2 = ptr; int at_eol; while (ptr + 1 < top && XDL_ISSPACE(ptr[1]) && ptr[1] != '\n') ptr++; at_eol = (top <= ptr + 1 || ptr[1] == '\n'); if (flags & XDF_IGNORE_WHITESPACE) ; /* already handled */ else if (flags & XDF_IGNORE_WHITESPACE_CHANGE && !at_eol) { ha += (ha << 5); ha ^= (unsigned long) ' '; } else if (flags & XDF_IGNORE_WHITESPACE_AT_EOL && !at_eol) { while (ptr2 != ptr + 1) { ha += (ha << 5); ha ^= (unsigned long) *ptr2; ptr2++; } } continue; } ha += (ha << 5); ha ^= (unsigned long) *ptr; } *data = ptr < top ? ptr + 1: ptr; return ha; } unsigned long xdl_hash_record(char const **data, char const *top, long flags) { unsigned long ha = 5381; char const *ptr = *data; if (flags & XDF_WHITESPACE_FLAGS) return xdl_hash_record_with_whitespace(data, top, flags); for (; ptr < top && *ptr != '\n'; ptr++) { ha += (ha << 5); ha ^= (unsigned long) *ptr; } *data = ptr < top ? ptr + 1: ptr; return ha; } unsigned int xdl_hashbits(unsigned int size) { unsigned int val = 1, bits = 0; for (; val < size && bits < CHAR_BIT * sizeof(unsigned int); val <<= 1, bits++); return bits ? bits: 1; } int xdl_num_out(char *out, long val) { char *ptr, *str = out; char buf[32]; ptr = buf + sizeof(buf) - 1; *ptr = '\0'; if (val < 0) { *--ptr = '-'; val = -val; } for (; val && ptr > buf; val /= 10) *--ptr = "0123456789"[val % 10]; if (*ptr) for (; *ptr; ptr++, str++) *str = *ptr; else *str++ = '0'; *str = '\0'; return (int)(str - out); } long xdl_atol(char const *str, char const **next) { long val, base; char const *top; for (top = str; XDL_ISDIGIT(*top); top++); if (next) *next = top; for (val = 0, base = 1, top--; top >= str; top--, base *= 10) val += base * (long)(*top - '0'); return val; } int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, const char *func, long funclen, xdemitcb_t *ecb) { int nb = 0; mmbuffer_t mb; char buf[128]; memcpy(buf, "@@ -", 4); nb += 4; nb += xdl_num_out(buf + nb, c1 ? s1: s1 - 1); if (c1 != 1) { memcpy(buf + nb, ",", 1); nb += 1; nb += xdl_num_out(buf + nb, c1); } memcpy(buf + nb, " +", 2); nb += 2; nb += xdl_num_out(buf + nb, c2 ? s2: s2 - 1); if (c2 != 1) { memcpy(buf + nb, ",", 1); nb += 1; nb += xdl_num_out(buf + nb, c2); } memcpy(buf + nb, " @@", 3); nb += 3; if (func && funclen) { buf[nb++] = ' '; if (funclen > (long)sizeof(buf) - nb - 1) funclen = (long)sizeof(buf) - nb - 1; memcpy(buf + nb, func, funclen); nb += funclen; } buf[nb++] = '\n'; mb.ptr = buf; mb.size = nb; if (ecb->outf(ecb->priv, &mb, 1) < 0) return -1; return 0; } int xdl_fall_back_diff(xdfenv_t *diff_env, xpparam_t const *xpp, int line1, int count1, int line2, int count2) { /* * This probably does not work outside Git, since * we have a very simple mmfile structure. * * Note: ideally, we would reuse the prepared environment, but * the libxdiff interface does not (yet) allow for diffing only * ranges of lines instead of the whole files. */ mmfile_t subfile1, subfile2; xdfenv_t env; subfile1.ptr = (char *)diff_env->xdf1.recs[line1 - 1]->ptr; subfile1.size = diff_env->xdf1.recs[line1 + count1 - 2]->ptr + diff_env->xdf1.recs[line1 + count1 - 2]->size - subfile1.ptr; subfile2.ptr = (char *)diff_env->xdf2.recs[line2 - 1]->ptr; subfile2.size = diff_env->xdf2.recs[line2 + count2 - 2]->ptr + diff_env->xdf2.recs[line2 + count2 - 2]->size - subfile2.ptr; if (xdl_do_diff(&subfile1, &subfile2, xpp, &env) < 0) return -1; memcpy(diff_env->xdf1.rchg + line1 - 1, env.xdf1.rchg, count1); memcpy(diff_env->xdf2.rchg + line2 - 1, env.xdf2.rchg, count2); xdl_free_env(&env); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/xdiff/xhistogram.c0000664000175000017500000002227112610310643017323 0ustar /* * Copyright (C) 2010, Google Inc. * and other copyright owners as documented in JGit's IP log. * * This program and the accompanying materials are made available * under the terms of the Eclipse Distribution License v1.0 which * accompanies this distribution, is reproduced below, and is * available at http://www.eclipse.org/org/documents/edl-v10.php * * All rights reserved. * * 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 the Eclipse Foundation, 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 THE COPYRIGHT HOLDERS AND * CONTRIBUTORS "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 THE COPYRIGHT OWNER OR * CONTRIBUTORS 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. */ #include "xinclude.h" #include "xtypes.h" #include "xdiff.h" #include "common.h" #define MAX_PTR UINT_MAX #define MAX_CNT UINT_MAX #define LINE_END(n) (line##n + count##n - 1) #define LINE_END_PTR(n) (*line##n + *count##n - 1) struct histindex { struct record { unsigned int ptr, cnt; struct record *next; } **records, /* an occurrence */ **line_map; /* map of line to record chain */ chastore_t rcha; unsigned int *next_ptrs; unsigned int table_bits, records_size, line_map_size; unsigned int max_chain_length, key_shift, ptr_shift; unsigned int cnt, has_common; xdfenv_t *env; xpparam_t const *xpp; }; struct region { unsigned int begin1, end1; unsigned int begin2, end2; }; #define LINE_MAP(i, a) (i->line_map[(a) - i->ptr_shift]) #define NEXT_PTR(index, ptr) \ (index->next_ptrs[(ptr) - index->ptr_shift]) #define CNT(index, ptr) \ ((LINE_MAP(index, ptr))->cnt) #define REC(env, s, l) \ (env->xdf##s.recs[l - 1]) static int cmp_recs(xpparam_t const *xpp, xrecord_t *r1, xrecord_t *r2) { return r1->ha == r2->ha && xdl_recmatch(r1->ptr, r1->size, r2->ptr, r2->size, xpp->flags); } #define CMP_ENV(xpp, env, s1, l1, s2, l2) \ (cmp_recs(xpp, REC(env, s1, l1), REC(env, s2, l2))) #define CMP(i, s1, l1, s2, l2) \ (cmp_recs(i->xpp, REC(i->env, s1, l1), REC(i->env, s2, l2))) #define TABLE_HASH(index, side, line) \ XDL_HASHLONG((REC(index->env, side, line))->ha, index->table_bits) static int scanA(struct histindex *index, unsigned int line1, unsigned int count1) { unsigned int ptr; unsigned int tbl_idx; unsigned int chain_len; struct record **rec_chain, *rec; for (ptr = LINE_END(1); line1 <= ptr; ptr--) { tbl_idx = TABLE_HASH(index, 1, ptr); rec_chain = index->records + tbl_idx; rec = *rec_chain; chain_len = 0; while (rec) { if (CMP(index, 1, rec->ptr, 1, ptr)) { /* * ptr is identical to another element. Insert * it onto the front of the existing element * chain. */ NEXT_PTR(index, ptr) = rec->ptr; rec->ptr = ptr; /* cap rec->cnt at MAX_CNT */ rec->cnt = XDL_MIN(MAX_CNT, rec->cnt + 1); LINE_MAP(index, ptr) = rec; goto continue_scan; } rec = rec->next; chain_len++; } if (chain_len == index->max_chain_length) return -1; /* * This is the first time we have ever seen this particular * element in the sequence. Construct a new chain for it. */ if (!(rec = xdl_cha_alloc(&index->rcha))) return -1; rec->ptr = ptr; rec->cnt = 1; rec->next = *rec_chain; *rec_chain = rec; LINE_MAP(index, ptr) = rec; continue_scan: ; /* no op */ } return 0; } static int try_lcs( struct histindex *index, struct region *lcs, unsigned int b_ptr, unsigned int line1, unsigned int count1, unsigned int line2, unsigned int count2) { unsigned int b_next = b_ptr + 1; struct record *rec = index->records[TABLE_HASH(index, 2, b_ptr)]; unsigned int as, ae, bs, be, np, rc; int should_break; for (; rec; rec = rec->next) { if (rec->cnt > index->cnt) { if (!index->has_common) index->has_common = CMP(index, 1, rec->ptr, 2, b_ptr); continue; } as = rec->ptr; if (!CMP(index, 1, as, 2, b_ptr)) continue; index->has_common = 1; for (;;) { should_break = 0; np = NEXT_PTR(index, as); bs = b_ptr; ae = as; be = bs; rc = rec->cnt; while (line1 < as && line2 < bs && CMP(index, 1, as - 1, 2, bs - 1)) { as--; bs--; if (1 < rc) rc = XDL_MIN(rc, CNT(index, as)); } while (ae < LINE_END(1) && be < LINE_END(2) && CMP(index, 1, ae + 1, 2, be + 1)) { ae++; be++; if (1 < rc) rc = XDL_MIN(rc, CNT(index, ae)); } if (b_next <= be) b_next = be + 1; if (lcs->end1 - lcs->begin1 < ae - as || rc < index->cnt) { lcs->begin1 = as; lcs->begin2 = bs; lcs->end1 = ae; lcs->end2 = be; index->cnt = rc; } if (np == 0) break; while (np <= ae) { np = NEXT_PTR(index, np); if (np == 0) { should_break = 1; break; } } if (should_break) break; as = np; } } return b_next; } static int find_lcs( struct histindex *index, struct region *lcs, unsigned int line1, unsigned int count1, unsigned int line2, unsigned int count2) { unsigned int b_ptr; if (scanA(index, line1, count1)) return -1; index->cnt = index->max_chain_length + 1; for (b_ptr = line2; b_ptr <= LINE_END(2); ) b_ptr = try_lcs(index, lcs, b_ptr, line1, count1, line2, count2); return index->has_common && index->max_chain_length < index->cnt; } static int fall_back_to_classic_diff(struct histindex *index, int line1, int count1, int line2, int count2) { xpparam_t xpp; xpp.flags = index->xpp->flags & ~XDF_DIFF_ALGORITHM_MASK; return xdl_fall_back_diff(index->env, &xpp, line1, count1, line2, count2); } static int histogram_diff( xpparam_t const *xpp, xdfenv_t *env, unsigned int line1, unsigned int count1, unsigned int line2, unsigned int count2) { struct histindex index; struct region lcs; size_t sz; int result = -1; if (count1 <= 0 && count2 <= 0) return 0; if (LINE_END(1) >= MAX_PTR) return -1; if (!count1) { while(count2--) env->xdf2.rchg[line2++ - 1] = 1; return 0; } else if (!count2) { while(count1--) env->xdf1.rchg[line1++ - 1] = 1; return 0; } memset(&index, 0, sizeof(index)); index.env = env; index.xpp = xpp; index.records = NULL; index.line_map = NULL; /* in case of early xdl_cha_free() */ index.rcha.head = NULL; index.table_bits = xdl_hashbits(count1); sz = index.records_size = 1 << index.table_bits; GITERR_CHECK_ALLOC_MULTIPLY(&sz, sz, sizeof(struct record *)); if (!(index.records = (struct record **) xdl_malloc(sz))) goto cleanup; memset(index.records, 0, sz); sz = index.line_map_size = count1; sz *= sizeof(struct record *); if (!(index.line_map = (struct record **) xdl_malloc(sz))) goto cleanup; memset(index.line_map, 0, sz); sz = index.line_map_size; sz *= sizeof(unsigned int); if (!(index.next_ptrs = (unsigned int *) xdl_malloc(sz))) goto cleanup; memset(index.next_ptrs, 0, sz); /* lines / 4 + 1 comes from xprepare.c:xdl_prepare_ctx() */ if (xdl_cha_init(&index.rcha, sizeof(struct record), count1 / 4 + 1) < 0) goto cleanup; index.ptr_shift = line1; index.max_chain_length = 64; memset(&lcs, 0, sizeof(lcs)); if (find_lcs(&index, &lcs, line1, count1, line2, count2)) result = fall_back_to_classic_diff(&index, line1, count1, line2, count2); else { if (lcs.begin1 == 0 && lcs.begin2 == 0) { while (count1--) env->xdf1.rchg[line1++ - 1] = 1; while (count2--) env->xdf2.rchg[line2++ - 1] = 1; result = 0; } else { result = histogram_diff(xpp, env, line1, lcs.begin1 - line1, line2, lcs.begin2 - line2); if (result) goto cleanup; result = histogram_diff(xpp, env, lcs.end1 + 1, LINE_END(1) - lcs.end1, lcs.end2 + 1, LINE_END(2) - lcs.end2); if (result) goto cleanup; } } cleanup: xdl_free(index.records); xdl_free(index.line_map); xdl_free(index.next_ptrs); xdl_cha_free(&index.rcha); return result; } int xdl_do_histogram_diff(mmfile_t *file1, mmfile_t *file2, xpparam_t const *xpp, xdfenv_t *env) { if (xdl_prepare_env(file1, file2, xpp, env) < 0) return -1; return histogram_diff(xpp, env, env->xdf1.dstart + 1, env->xdf1.dend - env->xdf1.dstart + 1, env->xdf2.dstart + 1, env->xdf2.dend - env->xdf2.dstart + 1); } deps/libgit2-sys-0.3.8/libgit2/src/xdiff/xinclude.h0000664000175000017500000000240212426525445016765 0ustar /* * LibXDiff by Davide Libenzi ( File Differential Library ) * Copyright (C) 2003 Davide Libenzi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Davide Libenzi * */ #if !defined(XINCLUDE_H) #define XINCLUDE_H #include #include #include #include #include #ifdef _WIN32 #else #include #endif #include "xmacros.h" #include "xdiff.h" #include "xtypes.h" #include "xutils.h" #include "xprepare.h" #include "xdiffi.h" #include "xemit.h" #endif /* #if !defined(XINCLUDE_H) */ deps/libgit2-sys-0.3.8/libgit2/src/xdiff/xemit.h0000664000175000017500000000236512572105236016302 0ustar /* * LibXDiff by Davide Libenzi ( File Differential Library ) * Copyright (C) 2003 Davide Libenzi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Davide Libenzi * */ #if !defined(XEMIT_H) #define XEMIT_H typedef int (*emit_func_t)(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, xdemitconf_t const *xecfg); xdchange_t *xdl_get_hunk(xdchange_t **xscr, xdemitconf_t const *xecfg); int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, xdemitconf_t const *xecfg); #endif /* #if !defined(XEMIT_H) */ deps/libgit2-sys-0.3.8/libgit2/src/xdiff/xprepare.c0000664000175000017500000002775312572105236017005 0ustar /* * LibXDiff by Davide Libenzi ( File Differential Library ) * Copyright (C) 2003 Davide Libenzi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Davide Libenzi * */ #include "xinclude.h" #define XDL_KPDIS_RUN 4 #define XDL_MAX_EQLIMIT 1024 #define XDL_SIMSCAN_WINDOW 100 #define XDL_GUESS_NLINES1 256 #define XDL_GUESS_NLINES2 20 typedef struct s_xdlclass { struct s_xdlclass *next; unsigned long ha; char const *line; long size; long idx; long len1, len2; } xdlclass_t; typedef struct s_xdlclassifier { unsigned int hbits; long hsize; xdlclass_t **rchash; chastore_t ncha; xdlclass_t **rcrecs; long alloc; long count; long flags; } xdlclassifier_t; static int xdl_init_classifier(xdlclassifier_t *cf, long size, long flags); static void xdl_free_classifier(xdlclassifier_t *cf); static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t **rhash, unsigned int hbits, xrecord_t *rec); static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_t const *xpp, xdlclassifier_t *cf, xdfile_t *xdf); static void xdl_free_ctx(xdfile_t *xdf); static int xdl_clean_mmatch(char const *dis, long i, long s, long e); static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xdf2); static int xdl_trim_ends(xdfile_t *xdf1, xdfile_t *xdf2); static int xdl_optimize_ctxs(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xdf2); static int xdl_init_classifier(xdlclassifier_t *cf, long size, long flags) { cf->flags = flags; cf->hbits = xdl_hashbits((unsigned int) size); cf->hsize = 1 << cf->hbits; if (xdl_cha_init(&cf->ncha, sizeof(xdlclass_t), size / 4 + 1) < 0) { return -1; } if (!(cf->rchash = (xdlclass_t **) xdl_malloc(cf->hsize * sizeof(xdlclass_t *)))) { xdl_cha_free(&cf->ncha); return -1; } memset(cf->rchash, 0, cf->hsize * sizeof(xdlclass_t *)); cf->alloc = size; if (!(cf->rcrecs = (xdlclass_t **) xdl_malloc(cf->alloc * sizeof(xdlclass_t *)))) { xdl_free(cf->rchash); xdl_cha_free(&cf->ncha); return -1; } cf->count = 0; return 0; } static void xdl_free_classifier(xdlclassifier_t *cf) { xdl_free(cf->rcrecs); xdl_free(cf->rchash); xdl_cha_free(&cf->ncha); } static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t **rhash, unsigned int hbits, xrecord_t *rec) { long hi; char const *line; xdlclass_t *rcrec; xdlclass_t **rcrecs; line = rec->ptr; hi = (long) XDL_HASHLONG(rec->ha, cf->hbits); for (rcrec = cf->rchash[hi]; rcrec; rcrec = rcrec->next) if (rcrec->ha == rec->ha && xdl_recmatch(rcrec->line, rcrec->size, rec->ptr, rec->size, cf->flags)) break; if (!rcrec) { if (!(rcrec = xdl_cha_alloc(&cf->ncha))) { return -1; } rcrec->idx = cf->count++; if (cf->count > cf->alloc) { cf->alloc *= 2; if (!(rcrecs = (xdlclass_t **) xdl_realloc(cf->rcrecs, cf->alloc * sizeof(xdlclass_t *)))) { return -1; } cf->rcrecs = rcrecs; } cf->rcrecs[rcrec->idx] = rcrec; rcrec->line = line; rcrec->size = rec->size; rcrec->ha = rec->ha; rcrec->len1 = rcrec->len2 = 0; rcrec->next = cf->rchash[hi]; cf->rchash[hi] = rcrec; } (pass == 1) ? rcrec->len1++ : rcrec->len2++; rec->ha = (unsigned long) rcrec->idx; hi = (long) XDL_HASHLONG(rec->ha, hbits); rec->next = rhash[hi]; rhash[hi] = rec; return 0; } static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_t const *xpp, xdlclassifier_t *cf, xdfile_t *xdf) { unsigned int hbits; long nrec, hsize, bsize; unsigned long hav; char const *blk, *cur, *top, *prev; xrecord_t *crec; xrecord_t **recs, **rrecs; xrecord_t **rhash; unsigned long *ha; char *rchg; long *rindex; ha = NULL; rindex = NULL; rchg = NULL; rhash = NULL; recs = NULL; if (xdl_cha_init(&xdf->rcha, sizeof(xrecord_t), narec / 4 + 1) < 0) goto abort; if (!(recs = (xrecord_t **) xdl_malloc(narec * sizeof(xrecord_t *)))) goto abort; if (XDF_DIFF_ALG(xpp->flags) == XDF_HISTOGRAM_DIFF) hbits = hsize = 0; else { hbits = xdl_hashbits((unsigned int) narec); hsize = 1 << hbits; if (!(rhash = (xrecord_t **) xdl_malloc(hsize * sizeof(xrecord_t *)))) goto abort; memset(rhash, 0, hsize * sizeof(xrecord_t *)); } nrec = 0; if ((cur = blk = xdl_mmfile_first(mf, &bsize)) != NULL) { for (top = blk + bsize; cur < top; ) { prev = cur; hav = xdl_hash_record(&cur, top, xpp->flags); if (nrec >= narec) { narec *= 2; if (!(rrecs = (xrecord_t **) xdl_realloc(recs, narec * sizeof(xrecord_t *)))) goto abort; recs = rrecs; } if (!(crec = xdl_cha_alloc(&xdf->rcha))) goto abort; crec->ptr = prev; crec->size = (long) (cur - prev); crec->ha = hav; recs[nrec++] = crec; if ((XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF) && xdl_classify_record(pass, cf, rhash, hbits, crec) < 0) goto abort; } } if (!(rchg = (char *) xdl_malloc((nrec + 2) * sizeof(char)))) goto abort; memset(rchg, 0, (nrec + 2) * sizeof(char)); if (!(rindex = (long *) xdl_malloc((nrec + 1) * sizeof(long)))) goto abort; if (!(ha = (unsigned long *) xdl_malloc((nrec + 1) * sizeof(unsigned long)))) goto abort; xdf->nrec = nrec; xdf->recs = recs; xdf->hbits = hbits; xdf->rhash = rhash; xdf->rchg = rchg + 1; xdf->rindex = rindex; xdf->nreff = 0; xdf->ha = ha; xdf->dstart = 0; xdf->dend = nrec - 1; return 0; abort: xdl_free(ha); xdl_free(rindex); xdl_free(rchg); xdl_free(rhash); xdl_free(recs); xdl_cha_free(&xdf->rcha); return -1; } static void xdl_free_ctx(xdfile_t *xdf) { xdl_free(xdf->rhash); xdl_free(xdf->rindex); xdl_free(xdf->rchg - 1); xdl_free(xdf->ha); xdl_free(xdf->recs); xdl_cha_free(&xdf->rcha); } int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdfenv_t *xe) { long enl1, enl2, sample; xdlclassifier_t cf; memset(&cf, 0, sizeof(cf)); /* * For histogram diff, we can afford a smaller sample size and * thus a poorer estimate of the number of lines, as the hash * table (rhash) won't be filled up/grown. The number of lines * (nrecs) will be updated correctly anyway by * xdl_prepare_ctx(). */ sample = (XDF_DIFF_ALG(xpp->flags) == XDF_HISTOGRAM_DIFF ? XDL_GUESS_NLINES2 : XDL_GUESS_NLINES1); enl1 = xdl_guess_lines(mf1, sample) + 1; enl2 = xdl_guess_lines(mf2, sample) + 1; if (XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF && xdl_init_classifier(&cf, enl1 + enl2 + 1, xpp->flags) < 0) return -1; if (xdl_prepare_ctx(1, mf1, enl1, xpp, &cf, &xe->xdf1) < 0) { xdl_free_classifier(&cf); return -1; } if (xdl_prepare_ctx(2, mf2, enl2, xpp, &cf, &xe->xdf2) < 0) { xdl_free_ctx(&xe->xdf1); xdl_free_classifier(&cf); return -1; } if ((XDF_DIFF_ALG(xpp->flags) != XDF_PATIENCE_DIFF) && (XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF) && xdl_optimize_ctxs(&cf, &xe->xdf1, &xe->xdf2) < 0) { xdl_free_ctx(&xe->xdf2); xdl_free_ctx(&xe->xdf1); return -1; } if (!(xpp->flags & XDF_HISTOGRAM_DIFF)) xdl_free_classifier(&cf); return 0; } void xdl_free_env(xdfenv_t *xe) { xdl_free_ctx(&xe->xdf2); xdl_free_ctx(&xe->xdf1); } static int xdl_clean_mmatch(char const *dis, long i, long s, long e) { long r, rdis0, rpdis0, rdis1, rpdis1; /* * Limits the window the is examined during the similar-lines * scan. The loops below stops when dis[i - r] == 1 (line that * has no match), but there are corner cases where the loop * proceed all the way to the extremities by causing huge * performance penalties in case of big files. */ if (i - s > XDL_SIMSCAN_WINDOW) s = i - XDL_SIMSCAN_WINDOW; if (e - i > XDL_SIMSCAN_WINDOW) e = i + XDL_SIMSCAN_WINDOW; /* * Scans the lines before 'i' to find a run of lines that either * have no match (dis[j] == 0) or have multiple matches (dis[j] > 1). * Note that we always call this function with dis[i] > 1, so the * current line (i) is already a multimatch line. */ for (r = 1, rdis0 = 0, rpdis0 = 1; (i - r) >= s; r++) { if (!dis[i - r]) rdis0++; else if (dis[i - r] == 2) rpdis0++; else break; } /* * If the run before the line 'i' found only multimatch lines, we * return 0 and hence we don't make the current line (i) discarded. * We want to discard multimatch lines only when they appear in the * middle of runs with nomatch lines (dis[j] == 0). */ if (rdis0 == 0) return 0; for (r = 1, rdis1 = 0, rpdis1 = 1; (i + r) <= e; r++) { if (!dis[i + r]) rdis1++; else if (dis[i + r] == 2) rpdis1++; else break; } /* * If the run after the line 'i' found only multimatch lines, we * return 0 and hence we don't make the current line (i) discarded. */ if (rdis1 == 0) return 0; rdis1 += rdis0; rpdis1 += rpdis0; return rpdis1 * XDL_KPDIS_RUN < (rpdis1 + rdis1); } /* * Try to reduce the problem complexity, discard records that have no * matches on the other file. Also, lines that have multiple matches * might be potentially discarded if they happear in a run of discardable. */ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xdf2) { long i, nm, nreff, mlim; xrecord_t **recs; xdlclass_t *rcrec; char *dis, *dis1, *dis2; if (!(dis = (char *) xdl_malloc(xdf1->nrec + xdf2->nrec + 2))) { return -1; } memset(dis, 0, xdf1->nrec + xdf2->nrec + 2); dis1 = dis; dis2 = dis1 + xdf1->nrec + 1; if ((mlim = xdl_bogosqrt(xdf1->nrec)) > XDL_MAX_EQLIMIT) mlim = XDL_MAX_EQLIMIT; for (i = xdf1->dstart, recs = &xdf1->recs[xdf1->dstart]; i <= xdf1->dend; i++, recs++) { rcrec = cf->rcrecs[(*recs)->ha]; nm = rcrec ? rcrec->len2 : 0; dis1[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1; } if ((mlim = xdl_bogosqrt(xdf2->nrec)) > XDL_MAX_EQLIMIT) mlim = XDL_MAX_EQLIMIT; for (i = xdf2->dstart, recs = &xdf2->recs[xdf2->dstart]; i <= xdf2->dend; i++, recs++) { rcrec = cf->rcrecs[(*recs)->ha]; nm = rcrec ? rcrec->len1 : 0; dis2[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1; } for (nreff = 0, i = xdf1->dstart, recs = &xdf1->recs[xdf1->dstart]; i <= xdf1->dend; i++, recs++) { if (dis1[i] == 1 || (dis1[i] == 2 && !xdl_clean_mmatch(dis1, i, xdf1->dstart, xdf1->dend))) { xdf1->rindex[nreff] = i; xdf1->ha[nreff] = (*recs)->ha; nreff++; } else xdf1->rchg[i] = 1; } xdf1->nreff = nreff; for (nreff = 0, i = xdf2->dstart, recs = &xdf2->recs[xdf2->dstart]; i <= xdf2->dend; i++, recs++) { if (dis2[i] == 1 || (dis2[i] == 2 && !xdl_clean_mmatch(dis2, i, xdf2->dstart, xdf2->dend))) { xdf2->rindex[nreff] = i; xdf2->ha[nreff] = (*recs)->ha; nreff++; } else xdf2->rchg[i] = 1; } xdf2->nreff = nreff; xdl_free(dis); return 0; } /* * Early trim initial and terminal matching records. */ static int xdl_trim_ends(xdfile_t *xdf1, xdfile_t *xdf2) { long i, lim; xrecord_t **recs1, **recs2; recs1 = xdf1->recs; recs2 = xdf2->recs; for (i = 0, lim = XDL_MIN(xdf1->nrec, xdf2->nrec); i < lim; i++, recs1++, recs2++) if ((*recs1)->ha != (*recs2)->ha) break; xdf1->dstart = xdf2->dstart = i; recs1 = xdf1->recs + xdf1->nrec - 1; recs2 = xdf2->recs + xdf2->nrec - 1; for (lim -= i, i = 0; i < lim; i++, recs1--, recs2--) if ((*recs1)->ha != (*recs2)->ha) break; xdf1->dend = xdf1->nrec - i - 1; xdf2->dend = xdf2->nrec - i - 1; return 0; } static int xdl_optimize_ctxs(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xdf2) { if (xdl_trim_ends(xdf1, xdf2) < 0 || xdl_cleanup_records(cf, xdf1, xdf2) < 0) { return -1; } return 0; } deps/libgit2-sys-0.3.8/libgit2/src/commit.h0000664000175000017500000000130612426525445015344 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_commit_h__ #define INCLUDE_commit_h__ #include "git2/commit.h" #include "tree.h" #include "repository.h" #include "array.h" #include struct git_commit { git_object object; git_array_t(git_oid) parent_ids; git_oid tree_id; git_signature *author; git_signature *committer; char *message_encoding; char *raw_message; char *raw_header; char *summary; }; void git_commit__free(void *commit); int git_commit__parse(void *commit, git_odb_object *obj); #endif deps/libgit2-sys-0.3.8/libgit2/src/diff_xdiff.c0000664000175000017500000001542012610310643016124 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/errors.h" #include "common.h" #include "diff.h" #include "diff_driver.h" #include "diff_patch.h" #include "diff_xdiff.h" static int git_xdiff_scan_int(const char **str, int *value) { const char *scan = *str; int v = 0, digits = 0; /* find next digit */ for (scan = *str; *scan && !git__isdigit(*scan); scan++); /* parse next number */ for (; git__isdigit(*scan); scan++, digits++) v = (v * 10) + (*scan - '0'); *str = scan; *value = v; return (digits > 0) ? 0 : -1; } static int git_xdiff_parse_hunk(git_diff_hunk *hunk, const char *header) { /* expect something of the form "@@ -%d[,%d] +%d[,%d] @@" */ if (*header != '@') goto fail; if (git_xdiff_scan_int(&header, &hunk->old_start) < 0) goto fail; if (*header == ',') { if (git_xdiff_scan_int(&header, &hunk->old_lines) < 0) goto fail; } else hunk->old_lines = 1; if (git_xdiff_scan_int(&header, &hunk->new_start) < 0) goto fail; if (*header == ',') { if (git_xdiff_scan_int(&header, &hunk->new_lines) < 0) goto fail; } else hunk->new_lines = 1; if (hunk->old_start < 0 || hunk->new_start < 0) goto fail; return 0; fail: giterr_set(GITERR_INVALID, "Malformed hunk header from xdiff"); return -1; } typedef struct { git_xdiff_output *xo; git_patch *patch; git_diff_hunk hunk; int old_lineno, new_lineno; mmfile_t xd_old_data, xd_new_data; } git_xdiff_info; static int diff_update_lines( git_xdiff_info *info, git_diff_line *line, const char *content, size_t content_len) { const char *scan = content, *scan_end = content + content_len; for (line->num_lines = 0; scan < scan_end; ++scan) if (*scan == '\n') ++line->num_lines; line->content = content; line->content_len = content_len; /* expect " "/"-"/"+", then data */ switch (line->origin) { case GIT_DIFF_LINE_ADDITION: case GIT_DIFF_LINE_DEL_EOFNL: line->old_lineno = -1; line->new_lineno = info->new_lineno; info->new_lineno += (int)line->num_lines; break; case GIT_DIFF_LINE_DELETION: case GIT_DIFF_LINE_ADD_EOFNL: line->old_lineno = info->old_lineno; line->new_lineno = -1; info->old_lineno += (int)line->num_lines; break; case GIT_DIFF_LINE_CONTEXT: case GIT_DIFF_LINE_CONTEXT_EOFNL: line->old_lineno = info->old_lineno; line->new_lineno = info->new_lineno; info->old_lineno += (int)line->num_lines; info->new_lineno += (int)line->num_lines; break; default: giterr_set(GITERR_INVALID, "Unknown diff line origin %02x", (unsigned int)line->origin); return -1; } return 0; } static int git_xdiff_cb(void *priv, mmbuffer_t *bufs, int len) { git_xdiff_info *info = priv; git_patch *patch = info->patch; const git_diff_delta *delta = git_patch_get_delta(patch); git_diff_output *output = &info->xo->output; git_diff_line line; if (len == 1) { output->error = git_xdiff_parse_hunk(&info->hunk, bufs[0].ptr); if (output->error < 0) return output->error; info->hunk.header_len = bufs[0].size; if (info->hunk.header_len >= sizeof(info->hunk.header)) info->hunk.header_len = sizeof(info->hunk.header) - 1; memcpy(info->hunk.header, bufs[0].ptr, info->hunk.header_len); info->hunk.header[info->hunk.header_len] = '\0'; if (output->hunk_cb != NULL && (output->error = output->hunk_cb( delta, &info->hunk, output->payload))) return output->error; info->old_lineno = info->hunk.old_start; info->new_lineno = info->hunk.new_start; } if (len == 2 || len == 3) { /* expect " "/"-"/"+", then data */ line.origin = (*bufs[0].ptr == '+') ? GIT_DIFF_LINE_ADDITION : (*bufs[0].ptr == '-') ? GIT_DIFF_LINE_DELETION : GIT_DIFF_LINE_CONTEXT; if (line.origin == GIT_DIFF_LINE_ADDITION) line.content_offset = bufs[1].ptr - info->xd_new_data.ptr; else if (line.origin == GIT_DIFF_LINE_DELETION) line.content_offset = bufs[1].ptr - info->xd_old_data.ptr; else line.content_offset = -1; output->error = diff_update_lines( info, &line, bufs[1].ptr, bufs[1].size); if (!output->error && output->data_cb != NULL) output->error = output->data_cb( delta, &info->hunk, &line, output->payload); } if (len == 3 && !output->error) { /* If we have a '+' and a third buf, then we have added a line * without a newline and the old code had one, so DEL_EOFNL. * If we have a '-' and a third buf, then we have removed a line * with out a newline but added a blank line, so ADD_EOFNL. */ line.origin = (*bufs[0].ptr == '+') ? GIT_DIFF_LINE_DEL_EOFNL : (*bufs[0].ptr == '-') ? GIT_DIFF_LINE_ADD_EOFNL : GIT_DIFF_LINE_CONTEXT_EOFNL; line.content_offset = -1; output->error = diff_update_lines( info, &line, bufs[2].ptr, bufs[2].size); if (!output->error && output->data_cb != NULL) output->error = output->data_cb( delta, &info->hunk, &line, output->payload); } return output->error; } static int git_xdiff(git_diff_output *output, git_patch *patch) { git_xdiff_output *xo = (git_xdiff_output *)output; git_xdiff_info info; git_diff_find_context_payload findctxt; memset(&info, 0, sizeof(info)); info.patch = patch; info.xo = xo; xo->callback.priv = &info; git_diff_find_context_init( &xo->config.find_func, &findctxt, git_patch__driver(patch)); xo->config.find_func_priv = &findctxt; if (xo->config.find_func != NULL) xo->config.flags |= XDL_EMIT_FUNCNAMES; else xo->config.flags &= ~XDL_EMIT_FUNCNAMES; /* TODO: check ofile.opts_flags to see if driver-specific per-file * updates are needed to xo->params.flags */ git_patch__old_data(&info.xd_old_data.ptr, &info.xd_old_data.size, patch); git_patch__new_data(&info.xd_new_data.ptr, &info.xd_new_data.size, patch); if (info.xd_old_data.size > GIT_XDIFF_MAX_SIZE || info.xd_new_data.size > GIT_XDIFF_MAX_SIZE) { giterr_set(GITERR_INVALID, "files too large for diff"); return -1; } xdl_diff(&info.xd_old_data, &info.xd_new_data, &xo->params, &xo->config, &xo->callback); git_diff_find_context_clear(&findctxt); return xo->output.error; } void git_xdiff_init(git_xdiff_output *xo, const git_diff_options *opts) { uint32_t flags = opts ? opts->flags : 0; xo->output.diff_cb = git_xdiff; xo->config.ctxlen = opts ? opts->context_lines : 3; xo->config.interhunkctxlen = opts ? opts->interhunk_lines : 0; if (flags & GIT_DIFF_IGNORE_WHITESPACE) xo->params.flags |= XDF_WHITESPACE_FLAGS; if (flags & GIT_DIFF_IGNORE_WHITESPACE_CHANGE) xo->params.flags |= XDF_IGNORE_WHITESPACE_CHANGE; if (flags & GIT_DIFF_IGNORE_WHITESPACE_EOL) xo->params.flags |= XDF_IGNORE_WHITESPACE_AT_EOL; if (flags & GIT_DIFF_PATIENCE) xo->params.flags |= XDF_PATIENCE_DIFF; if (flags & GIT_DIFF_MINIMAL) xo->params.flags |= XDF_NEED_MINIMAL; xo->callback.outf = git_xdiff_cb; } deps/libgit2-sys-0.3.8/libgit2/src/openssl_stream.c0000664000175000017500000002356012610310643017076 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifdef GIT_OPENSSL #include #include "global.h" #include "posix.h" #include "stream.h" #include "socket_stream.h" #include "netops.h" #include "git2/transport.h" #ifdef GIT_CURL # include "curl_stream.h" #endif #ifndef GIT_WIN32 # include # include # include #endif #include #include #include #include static int bio_create(BIO *b) { b->init = 1; b->num = 0; b->ptr = NULL; b->flags = 0; return 1; } static int bio_destroy(BIO *b) { if (!b) return 0; b->init = 0; b->num = 0; b->ptr = NULL; b->flags = 0; return 1; } static int bio_read(BIO *b, char *buf, int len) { git_stream *io = (git_stream *) b->ptr; return (int) git_stream_read(io, buf, len); } static int bio_write(BIO *b, const char *buf, int len) { git_stream *io = (git_stream *) b->ptr; return (int) git_stream_write(io, buf, len, 0); } static long bio_ctrl(BIO *b, int cmd, long num, void *ptr) { GIT_UNUSED(b); GIT_UNUSED(num); GIT_UNUSED(ptr); if (cmd == BIO_CTRL_FLUSH) return 1; return 0; } static int bio_gets(BIO *b, char *buf, int len) { GIT_UNUSED(b); GIT_UNUSED(buf); GIT_UNUSED(len); return -1; } static int bio_puts(BIO *b, const char *str) { return bio_write(b, str, strlen(str)); } static BIO_METHOD git_stream_bio_method = { BIO_TYPE_SOURCE_SINK, "git_stream", bio_write, bio_read, bio_puts, bio_gets, bio_ctrl, bio_create, bio_destroy }; static int ssl_set_error(SSL *ssl, int error) { int err; unsigned long e; err = SSL_get_error(ssl, error); assert(err != SSL_ERROR_WANT_READ); assert(err != SSL_ERROR_WANT_WRITE); switch (err) { case SSL_ERROR_WANT_CONNECT: case SSL_ERROR_WANT_ACCEPT: giterr_set(GITERR_NET, "SSL error: connection failure\n"); break; case SSL_ERROR_WANT_X509_LOOKUP: giterr_set(GITERR_NET, "SSL error: x509 error\n"); break; case SSL_ERROR_SYSCALL: e = ERR_get_error(); if (e > 0) { giterr_set(GITERR_NET, "SSL error: %s", ERR_error_string(e, NULL)); break; } else if (error < 0) { giterr_set(GITERR_OS, "SSL error: syscall failure"); break; } giterr_set(GITERR_NET, "SSL error: received early EOF"); return GIT_EEOF; break; case SSL_ERROR_SSL: e = ERR_get_error(); giterr_set(GITERR_NET, "SSL error: %s", ERR_error_string(e, NULL)); break; case SSL_ERROR_NONE: case SSL_ERROR_ZERO_RETURN: default: giterr_set(GITERR_NET, "SSL error: unknown error"); break; } return -1; } static int ssl_teardown(SSL *ssl) { int ret; ret = SSL_shutdown(ssl); if (ret < 0) ret = ssl_set_error(ssl, ret); else ret = 0; SSL_free(ssl); return ret; } static int check_host_name(const char *name, const char *host) { if (!strcasecmp(name, host)) return 0; if (gitno__match_host(name, host) < 0) return -1; return 0; } static int verify_server_cert(SSL *ssl, const char *host) { X509 *cert; X509_NAME *peer_name; ASN1_STRING *str; unsigned char *peer_cn = NULL; int matched = -1, type = GEN_DNS; GENERAL_NAMES *alts; struct in6_addr addr6; struct in_addr addr4; void *addr; int i = -1,j; if (SSL_get_verify_result(ssl) != X509_V_OK) { giterr_set(GITERR_SSL, "The SSL certificate is invalid"); return GIT_ECERTIFICATE; } /* Try to parse the host as an IP address to see if it is */ if (p_inet_pton(AF_INET, host, &addr4)) { type = GEN_IPADD; addr = &addr4; } else { if(p_inet_pton(AF_INET6, host, &addr6)) { type = GEN_IPADD; addr = &addr6; } } cert = SSL_get_peer_certificate(ssl); if (!cert) { giterr_set(GITERR_SSL, "the server did not provide a certificate"); return -1; } /* Check the alternative names */ alts = X509_get_ext_d2i(cert, NID_subject_alt_name, NULL, NULL); if (alts) { int num; num = sk_GENERAL_NAME_num(alts); for (i = 0; i < num && matched != 1; i++) { const GENERAL_NAME *gn = sk_GENERAL_NAME_value(alts, i); const char *name = (char *) ASN1_STRING_data(gn->d.ia5); size_t namelen = (size_t) ASN1_STRING_length(gn->d.ia5); /* Skip any names of a type we're not looking for */ if (gn->type != type) continue; if (type == GEN_DNS) { /* If it contains embedded NULs, don't even try */ if (memchr(name, '\0', namelen)) continue; if (check_host_name(name, host) < 0) matched = 0; else matched = 1; } else if (type == GEN_IPADD) { /* Here name isn't so much a name but a binary representation of the IP */ matched = !!memcmp(name, addr, namelen); } } } GENERAL_NAMES_free(alts); if (matched == 0) goto cert_fail_name; if (matched == 1) return 0; /* If no alternative names are available, check the common name */ peer_name = X509_get_subject_name(cert); if (peer_name == NULL) goto on_error; if (peer_name) { /* Get the index of the last CN entry */ while ((j = X509_NAME_get_index_by_NID(peer_name, NID_commonName, i)) >= 0) i = j; } if (i < 0) goto on_error; str = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(peer_name, i)); if (str == NULL) goto on_error; /* Work around a bug in OpenSSL whereby ASN1_STRING_to_UTF8 fails if it's already in utf-8 */ if (ASN1_STRING_type(str) == V_ASN1_UTF8STRING) { int size = ASN1_STRING_length(str); if (size > 0) { peer_cn = OPENSSL_malloc(size + 1); GITERR_CHECK_ALLOC(peer_cn); memcpy(peer_cn, ASN1_STRING_data(str), size); peer_cn[size] = '\0'; } } else { int size = ASN1_STRING_to_UTF8(&peer_cn, str); GITERR_CHECK_ALLOC(peer_cn); if (memchr(peer_cn, '\0', size)) goto cert_fail_name; } if (check_host_name((char *)peer_cn, host) < 0) goto cert_fail_name; OPENSSL_free(peer_cn); return 0; on_error: OPENSSL_free(peer_cn); return ssl_set_error(ssl, 0); cert_fail_name: OPENSSL_free(peer_cn); giterr_set(GITERR_SSL, "hostname does not match certificate"); return GIT_ECERTIFICATE; } typedef struct { git_stream parent; git_stream *io; bool connected; char *host; SSL *ssl; git_cert_x509 cert_info; } openssl_stream; int openssl_close(git_stream *stream); int openssl_connect(git_stream *stream) { int ret; BIO *bio; openssl_stream *st = (openssl_stream *) stream; if ((ret = git_stream_connect(st->io)) < 0) return ret; st->connected = true; bio = BIO_new(&git_stream_bio_method); GITERR_CHECK_ALLOC(bio); bio->ptr = st->io; SSL_set_bio(st->ssl, bio, bio); /* specify the host in case SNI is needed */ #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME SSL_set_tlsext_host_name(st->ssl, st->host); #endif if ((ret = SSL_connect(st->ssl)) <= 0) return ssl_set_error(st->ssl, ret); return verify_server_cert(st->ssl, st->host); } int openssl_certificate(git_cert **out, git_stream *stream) { openssl_stream *st = (openssl_stream *) stream; int len; X509 *cert = SSL_get_peer_certificate(st->ssl); unsigned char *guard, *encoded_cert; /* Retrieve the length of the certificate first */ len = i2d_X509(cert, NULL); if (len < 0) { giterr_set(GITERR_NET, "failed to retrieve certificate information"); return -1; } encoded_cert = git__malloc(len); GITERR_CHECK_ALLOC(encoded_cert); /* i2d_X509 makes 'guard' point to just after the data */ guard = encoded_cert; len = i2d_X509(cert, &guard); if (len < 0) { git__free(encoded_cert); giterr_set(GITERR_NET, "failed to retrieve certificate information"); return -1; } st->cert_info.parent.cert_type = GIT_CERT_X509; st->cert_info.data = encoded_cert; st->cert_info.len = len; *out = &st->cert_info.parent; return 0; } static int openssl_set_proxy(git_stream *stream, const char *proxy_url) { openssl_stream *st = (openssl_stream *) stream; return git_stream_set_proxy(st->io, proxy_url); } ssize_t openssl_write(git_stream *stream, const char *data, size_t len, int flags) { openssl_stream *st = (openssl_stream *) stream; int ret; GIT_UNUSED(flags); if ((ret = SSL_write(st->ssl, data, len)) <= 0) { return ssl_set_error(st->ssl, ret); } return ret; } ssize_t openssl_read(git_stream *stream, void *data, size_t len) { openssl_stream *st = (openssl_stream *) stream; int ret; if ((ret = SSL_read(st->ssl, data, len)) <= 0) ssl_set_error(st->ssl, ret); return ret; } int openssl_close(git_stream *stream) { openssl_stream *st = (openssl_stream *) stream; int ret; if (st->connected && (ret = ssl_teardown(st->ssl)) < 0) return -1; st->connected = false; return git_stream_close(st->io); } void openssl_free(git_stream *stream) { openssl_stream *st = (openssl_stream *) stream; git__free(st->host); git__free(st->cert_info.data); git_stream_free(st->io); git__free(st); } int git_openssl_stream_new(git_stream **out, const char *host, const char *port) { int error; openssl_stream *st; st = git__calloc(1, sizeof(openssl_stream)); GITERR_CHECK_ALLOC(st); #ifdef GIT_CURL error = git_curl_stream_new(&st->io, host, port); #else error = git_socket_stream_new(&st->io, host, port); #endif if (error < 0) return error; st->ssl = SSL_new(git__ssl_ctx); if (st->ssl == NULL) { giterr_set(GITERR_SSL, "failed to create ssl object"); return -1; } st->host = git__strdup(host); GITERR_CHECK_ALLOC(st->host); st->parent.version = GIT_STREAM_VERSION; st->parent.encrypted = 1; st->parent.proxy_support = git_stream_supports_proxy(st->io); st->parent.connect = openssl_connect; st->parent.certificate = openssl_certificate; st->parent.set_proxy = openssl_set_proxy; st->parent.read = openssl_read; st->parent.write = openssl_write; st->parent.close = openssl_close; st->parent.free = openssl_free; *out = (git_stream *) st; return 0; } #else #include "stream.h" int git_openssl_stream_new(git_stream **out, const char *host, const char *port) { GIT_UNUSED(out); GIT_UNUSED(host); GIT_UNUSED(port); giterr_set(GITERR_SSL, "openssl is not supported in this version"); return -1; } #endif deps/libgit2-sys-0.3.8/libgit2/src/map.h0000664000175000017500000000222512510265101014612 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_map_h__ #define INCLUDE_map_h__ #include "common.h" /* p_mmap() prot values */ #define GIT_PROT_NONE 0x0 #define GIT_PROT_READ 0x1 #define GIT_PROT_WRITE 0x2 #define GIT_PROT_EXEC 0x4 /* git__mmmap() flags values */ #define GIT_MAP_FILE 0 #define GIT_MAP_SHARED 1 #define GIT_MAP_PRIVATE 2 #define GIT_MAP_TYPE 0xf #define GIT_MAP_FIXED 0x10 #ifdef __amigaos4__ #define MAP_FAILED 0 #endif typedef struct { /* memory mapped buffer */ void *data; /* data bytes */ size_t len; /* data length */ #ifdef GIT_WIN32 HANDLE fmh; /* file mapping handle */ #endif } git_map; #define GIT_MMAP_VALIDATE(out, len, prot, flags) do { \ assert(out != NULL && len > 0); \ assert((prot & GIT_PROT_WRITE) || (prot & GIT_PROT_READ)); \ assert((flags & GIT_MAP_FIXED) == 0); } while (0) extern int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset); extern int p_munmap(git_map *map); #endif /* INCLUDE_map_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/thread-utils.h0000664000175000017500000001561112510265101016445 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_thread_utils_h__ #define INCLUDE_thread_utils_h__ /* Common operations even if threading has been disabled */ typedef struct { #if defined(GIT_WIN32) volatile long val; #else volatile int val; #endif } git_atomic; #ifdef GIT_ARCH_64 typedef struct { #if defined(GIT_WIN32) __int64 val; #else int64_t val; #endif } git_atomic64; typedef git_atomic64 git_atomic_ssize; #define git_atomic_ssize_add git_atomic64_add #else typedef git_atomic git_atomic_ssize; #define git_atomic_ssize_add git_atomic_add #endif #ifdef GIT_THREADS #if !defined(GIT_WIN32) typedef struct { pthread_t thread; } git_thread; #define git_thread_create(git_thread_ptr, attr, start_routine, arg) \ pthread_create(&(git_thread_ptr)->thread, attr, start_routine, arg) #define git_thread_join(git_thread_ptr, status) \ pthread_join((git_thread_ptr)->thread, status) #endif /* Pthreads Mutex */ #define git_mutex pthread_mutex_t #define git_mutex_init(a) pthread_mutex_init(a, NULL) #define git_mutex_lock(a) pthread_mutex_lock(a) #define git_mutex_unlock(a) pthread_mutex_unlock(a) #define git_mutex_free(a) pthread_mutex_destroy(a) /* Pthreads condition vars */ #define git_cond pthread_cond_t #define git_cond_init(c) pthread_cond_init(c, NULL) #define git_cond_free(c) pthread_cond_destroy(c) #define git_cond_wait(c, l) pthread_cond_wait(c, l) #define git_cond_signal(c) pthread_cond_signal(c) #define git_cond_broadcast(c) pthread_cond_broadcast(c) /* Pthread (-ish) rwlock * * This differs from normal pthreads rwlocks in two ways: * 1. Separate APIs for releasing read locks and write locks (as * opposed to the pure POSIX API which only has one unlock fn) * 2. You should not use recursive read locks (i.e. grabbing a read * lock in a thread that already holds a read lock) because the * Windows implementation doesn't support it */ #define git_rwlock pthread_rwlock_t #define git_rwlock_init(a) pthread_rwlock_init(a, NULL) #define git_rwlock_rdlock(a) pthread_rwlock_rdlock(a) #define git_rwlock_rdunlock(a) pthread_rwlock_rdunlock(a) #define git_rwlock_wrlock(a) pthread_rwlock_wrlock(a) #define git_rwlock_wrunlock(a) pthread_rwlock_wrunlock(a) #define git_rwlock_free(a) pthread_rwlock_destroy(a) #define GIT_RWLOCK_STATIC_INIT PTHREAD_RWLOCK_INITIALIZER #ifndef GIT_WIN32 #define pthread_rwlock_rdunlock pthread_rwlock_unlock #define pthread_rwlock_wrunlock pthread_rwlock_unlock #endif GIT_INLINE(void) git_atomic_set(git_atomic *a, int val) { #if defined(GIT_WIN32) InterlockedExchange(&a->val, (LONG)val); #elif defined(__GNUC__) __sync_lock_test_and_set(&a->val, val); #else # error "Unsupported architecture for atomic operations" #endif } GIT_INLINE(int) git_atomic_inc(git_atomic *a) { #if defined(GIT_WIN32) return InterlockedIncrement(&a->val); #elif defined(__GNUC__) return __sync_add_and_fetch(&a->val, 1); #else # error "Unsupported architecture for atomic operations" #endif } GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend) { #if defined(GIT_WIN32) return InterlockedExchangeAdd(&a->val, addend); #elif defined(__GNUC__) return __sync_add_and_fetch(&a->val, addend); #else # error "Unsupported architecture for atomic operations" #endif } GIT_INLINE(int) git_atomic_dec(git_atomic *a) { #if defined(GIT_WIN32) return InterlockedDecrement(&a->val); #elif defined(__GNUC__) return __sync_sub_and_fetch(&a->val, 1); #else # error "Unsupported architecture for atomic operations" #endif } GIT_INLINE(void *) git___compare_and_swap( void * volatile *ptr, void *oldval, void *newval) { volatile void *foundval; #if defined(GIT_WIN32) foundval = InterlockedCompareExchangePointer((volatile PVOID *)ptr, newval, oldval); #elif defined(__GNUC__) foundval = __sync_val_compare_and_swap(ptr, oldval, newval); #else # error "Unsupported architecture for atomic operations" #endif return (foundval == oldval) ? oldval : newval; } GIT_INLINE(volatile void *) git___swap( void * volatile *ptr, void *newval) { #if defined(GIT_WIN32) return InterlockedExchangePointer(ptr, newval); #else return __sync_lock_test_and_set(ptr, newval); #endif } #ifdef GIT_ARCH_64 GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend) { #if defined(GIT_WIN32) return InterlockedExchangeAdd64(&a->val, addend); #elif defined(__GNUC__) return __sync_add_and_fetch(&a->val, addend); #else # error "Unsupported architecture for atomic operations" #endif } #endif #else #define git_thread unsigned int #define git_thread_create(thread, attr, start_routine, arg) 0 #define git_thread_join(id, status) (void)0 /* Pthreads Mutex */ #define git_mutex unsigned int GIT_INLINE(int) git_mutex_init(git_mutex *mutex) \ { GIT_UNUSED(mutex); return 0; } GIT_INLINE(int) git_mutex_lock(git_mutex *mutex) \ { GIT_UNUSED(mutex); return 0; } #define git_mutex_unlock(a) (void)0 #define git_mutex_free(a) (void)0 /* Pthreads condition vars */ #define git_cond unsigned int #define git_cond_init(c, a) (void)0 #define git_cond_free(c) (void)0 #define git_cond_wait(c, l) (void)0 #define git_cond_signal(c) (void)0 #define git_cond_broadcast(c) (void)0 /* Pthreads rwlock */ #define git_rwlock unsigned int #define git_rwlock_init(a) 0 #define git_rwlock_rdlock(a) 0 #define git_rwlock_rdunlock(a) (void)0 #define git_rwlock_wrlock(a) 0 #define git_rwlock_wrunlock(a) (void)0 #define git_rwlock_free(a) (void)0 #define GIT_RWLOCK_STATIC_INIT 0 GIT_INLINE(void) git_atomic_set(git_atomic *a, int val) { a->val = val; } GIT_INLINE(int) git_atomic_inc(git_atomic *a) { return ++a->val; } GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend) { a->val += addend; return a->val; } GIT_INLINE(int) git_atomic_dec(git_atomic *a) { return --a->val; } GIT_INLINE(void *) git___compare_and_swap( void * volatile *ptr, void *oldval, void *newval) { if (*ptr == oldval) *ptr = newval; else oldval = newval; return oldval; } GIT_INLINE(volatile void *) git___swap( void * volatile *ptr, void *newval) { volatile void *old = *ptr; *ptr = newval; return old; } #ifdef GIT_ARCH_64 GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend) { a->val += addend; return a->val; } #endif #endif GIT_INLINE(int) git_atomic_get(git_atomic *a) { return (int)a->val; } /* Atomically replace oldval with newval * @return oldval if it was replaced or newval if it was not */ #define git__compare_and_swap(P,O,N) \ git___compare_and_swap((void * volatile *)P, O, N) #define git__swap(ptr, val) (void *)git___swap((void * volatile *)&ptr, val) extern int git_online_cpus(void); #if defined(GIT_THREADS) && defined(GIT_WIN32) # define GIT_MEMORY_BARRIER MemoryBarrier() #elif defined(GIT_THREADS) # define GIT_MEMORY_BARRIER __sync_synchronize() #else # define GIT_MEMORY_BARRIER /* noop */ #endif #endif /* INCLUDE_thread_utils_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/trace.c0000664000175000017500000000142112426525445015143 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "buffer.h" #include "common.h" #include "global.h" #include "trace.h" #include "git2/trace.h" #ifdef GIT_TRACE struct git_trace_data git_trace__data = {0}; #endif int git_trace_set(git_trace_level_t level, git_trace_callback callback) { #ifdef GIT_TRACE assert(level == 0 || callback != NULL); git_trace__data.level = level; git_trace__data.callback = callback; GIT_MEMORY_BARRIER; return 0; #else GIT_UNUSED(level); GIT_UNUSED(callback); giterr_set(GITERR_INVALID, "This version of libgit2 was not built with tracing."); return -1; #endif } deps/libgit2-sys-0.3.8/libgit2/src/pool.h0000664000175000017500000001041512510265101015006 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_pool_h__ #define INCLUDE_pool_h__ #include "common.h" typedef struct git_pool_page git_pool_page; /** * Chunked allocator. * * A `git_pool` can be used when you want to cheaply allocate * multiple items of the same type and are willing to free them * all together with a single call. The two most common cases * are a set of fixed size items (such as lots of OIDs) or a * bunch of strings. * * Internally, a `git_pool` allocates pages of memory and then * deals out blocks from the trailing unused portion of each page. * The pages guarantee that the number of actual allocations done * will be much smaller than the number of items needed. * * For examples of how to set up a `git_pool` see `git_pool_init`. */ typedef struct { git_pool_page *open; /* pages with space left */ git_pool_page *full; /* pages with no space left */ void *free_list; /* optional: list of freed blocks */ uint32_t item_size; /* size of single alloc unit in bytes */ uint32_t page_size; /* size of page in bytes */ uint32_t items; unsigned has_string_alloc : 1; /* was the strdup function used */ unsigned has_multi_item_alloc : 1; /* was items ever > 1 in malloc */ unsigned has_large_page_alloc : 1; /* are any pages > page_size */ } git_pool; #define GIT_POOL_INIT_STRINGPOOL { 0, 0, 0, 1, 4000, 0, 0, 0, 0 } /** * Initialize a pool. * * To allocation strings, use like this: * * git_pool_init(&string_pool, 1, 0); * my_string = git_pool_strdup(&string_pool, your_string); * * To allocate items of fixed size, use like this: * * git_pool_init(&pool, sizeof(item), 0); * my_item = git_pool_malloc(&pool, 1); * * Of course, you can use this in other ways, but those are the * two most common patterns. */ extern int git_pool_init( git_pool *pool, uint32_t item_size, uint32_t items_per_page); /** * Free all items in pool */ extern void git_pool_clear(git_pool *pool); /** * Swap two pools with one another */ extern void git_pool_swap(git_pool *a, git_pool *b); /** * Allocate space for one or more items from a pool. */ extern void *git_pool_malloc(git_pool *pool, uint32_t items); /** * Allocate space and zero it out. */ GIT_INLINE(void *) git_pool_mallocz(git_pool *pool, uint32_t items) { void *ptr = git_pool_malloc(pool, items); if (ptr) memset(ptr, 0, (size_t)items * (size_t)pool->item_size); return ptr; } /** * Allocate space and duplicate string data into it. * * This is allowed only for pools with item_size == sizeof(char) */ extern char *git_pool_strndup(git_pool *pool, const char *str, size_t n); /** * Allocate space and duplicate a string into it. * * This is allowed only for pools with item_size == sizeof(char) */ extern char *git_pool_strdup(git_pool *pool, const char *str); /** * Allocate space and duplicate a string into it, NULL is no error. * * This is allowed only for pools with item_size == sizeof(char) */ extern char *git_pool_strdup_safe(git_pool *pool, const char *str); /** * Allocate space for the concatenation of two strings. * * This is allowed only for pools with item_size == sizeof(char) */ extern char *git_pool_strcat(git_pool *pool, const char *a, const char *b); /** * Push a block back onto the free list for the pool. * * This is allowed only if the item_size is >= sizeof(void*). * * In some cases, it is helpful to "release" an allocated block * for reuse. Pools don't support a general purpose free, but * they will keep a simple free blocks linked list provided the * native block size is large enough to hold a void pointer */ extern void git_pool_free(git_pool *pool, void *ptr); /** * Push an array of pool allocated blocks efficiently onto the free list. * * This has the same constraints as `git_pool_free()` above. */ extern void git_pool_free_array(git_pool *pool, size_t count, void **ptrs); /* * Misc utilities */ extern uint32_t git_pool__open_pages(git_pool *pool); extern uint32_t git_pool__full_pages(git_pool *pool); extern bool git_pool__ptr_in_pool(git_pool *pool, void *ptr); extern uint32_t git_pool__suggest_items_per_page(uint32_t item_size); #endif deps/libgit2-sys-0.3.8/libgit2/src/buffer.c0000664000175000017500000004104212555730137015320 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "buffer.h" #include "posix.h" #include "git2/buffer.h" #include "buf_text.h" #include /* Used as default value for git_buf->ptr so that people can always * assume ptr is non-NULL and zero terminated even for new git_bufs. */ char git_buf__initbuf[1]; char git_buf__oom[1]; #define ENSURE_SIZE(b, d) \ if ((d) > buf->asize && git_buf_grow(b, (d)) < 0)\ return -1; void git_buf_init(git_buf *buf, size_t initial_size) { buf->asize = 0; buf->size = 0; buf->ptr = git_buf__initbuf; if (initial_size) git_buf_grow(buf, initial_size); } int git_buf_try_grow( git_buf *buf, size_t target_size, bool mark_oom) { char *new_ptr; size_t new_size; if (buf->ptr == git_buf__oom) return -1; if (buf->asize == 0 && buf->size != 0) { giterr_set(GITERR_INVALID, "cannot grow a borrowed buffer"); return GIT_EINVALID; } if (!target_size) target_size = buf->size; if (target_size <= buf->asize) return 0; if (buf->asize == 0) { new_size = target_size; new_ptr = NULL; } else { new_size = buf->asize; new_ptr = buf->ptr; } /* grow the buffer size by 1.5, until it's big enough * to fit our target size */ while (new_size < target_size) new_size = (new_size << 1) - (new_size >> 1); /* round allocation up to multiple of 8 */ new_size = (new_size + 7) & ~7; if (new_size < buf->size) { if (mark_oom) buf->ptr = git_buf__oom; giterr_set_oom(); return -1; } new_ptr = git__realloc(new_ptr, new_size); if (!new_ptr) { if (mark_oom) { if (buf->ptr && (buf->ptr != git_buf__initbuf)) git__free(buf->ptr); buf->ptr = git_buf__oom; } return -1; } buf->asize = new_size; buf->ptr = new_ptr; /* truncate the existing buffer size if necessary */ if (buf->size >= buf->asize) buf->size = buf->asize - 1; buf->ptr[buf->size] = '\0'; return 0; } int git_buf_grow(git_buf *buffer, size_t target_size) { return git_buf_try_grow(buffer, target_size, true); } int git_buf_grow_by(git_buf *buffer, size_t additional_size) { size_t newsize; if (GIT_ADD_SIZET_OVERFLOW(&newsize, buffer->size, additional_size)) { buffer->ptr = git_buf__oom; return -1; } return git_buf_try_grow(buffer, newsize, true); } void git_buf_free(git_buf *buf) { if (!buf) return; if (buf->asize > 0 && buf->ptr != NULL && buf->ptr != git_buf__oom) git__free(buf->ptr); git_buf_init(buf, 0); } void git_buf_sanitize(git_buf *buf) { if (buf->ptr == NULL) { assert(buf->size == 0 && buf->asize == 0); buf->ptr = git_buf__initbuf; } else if (buf->asize > buf->size) buf->ptr[buf->size] = '\0'; } void git_buf_clear(git_buf *buf) { buf->size = 0; if (!buf->ptr) { buf->ptr = git_buf__initbuf; buf->asize = 0; } if (buf->asize > 0) buf->ptr[0] = '\0'; } int git_buf_set(git_buf *buf, const void *data, size_t len) { size_t alloclen; if (len == 0 || data == NULL) { git_buf_clear(buf); } else { if (data != buf->ptr) { GITERR_CHECK_ALLOC_ADD(&alloclen, len, 1); ENSURE_SIZE(buf, alloclen); memmove(buf->ptr, data, len); } buf->size = len; if (buf->asize > buf->size) buf->ptr[buf->size] = '\0'; } return 0; } int git_buf_is_binary(const git_buf *buf) { return git_buf_text_is_binary(buf); } int git_buf_contains_nul(const git_buf *buf) { return git_buf_text_contains_nul(buf); } int git_buf_sets(git_buf *buf, const char *string) { return git_buf_set(buf, string, string ? strlen(string) : 0); } int git_buf_putc(git_buf *buf, char c) { size_t new_size; GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, 2); ENSURE_SIZE(buf, new_size); buf->ptr[buf->size++] = c; buf->ptr[buf->size] = '\0'; return 0; } int git_buf_putcn(git_buf *buf, char c, size_t len) { size_t new_size; GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, len); GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); ENSURE_SIZE(buf, new_size); memset(buf->ptr + buf->size, c, len); buf->size += len; buf->ptr[buf->size] = '\0'; return 0; } int git_buf_put(git_buf *buf, const char *data, size_t len) { if (len) { size_t new_size; assert(data); GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, len); GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); ENSURE_SIZE(buf, new_size); memmove(buf->ptr + buf->size, data, len); buf->size += len; buf->ptr[buf->size] = '\0'; } return 0; } int git_buf_puts(git_buf *buf, const char *string) { assert(string); return git_buf_put(buf, string, strlen(string)); } static const char base64_encode[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; int git_buf_encode_base64(git_buf *buf, const char *data, size_t len) { size_t extra = len % 3; uint8_t *write, a, b, c; const uint8_t *read = (const uint8_t *)data; size_t blocks = (len / 3) + !!extra, alloclen; GITERR_CHECK_ALLOC_ADD(&blocks, blocks, 1); GITERR_CHECK_ALLOC_MULTIPLY(&alloclen, blocks, 4); GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, buf->size); ENSURE_SIZE(buf, alloclen); write = (uint8_t *)&buf->ptr[buf->size]; /* convert each run of 3 bytes into 4 output bytes */ for (len -= extra; len > 0; len -= 3) { a = *read++; b = *read++; c = *read++; *write++ = base64_encode[a >> 2]; *write++ = base64_encode[(a & 0x03) << 4 | b >> 4]; *write++ = base64_encode[(b & 0x0f) << 2 | c >> 6]; *write++ = base64_encode[c & 0x3f]; } if (extra > 0) { a = *read++; b = (extra > 1) ? *read++ : 0; *write++ = base64_encode[a >> 2]; *write++ = base64_encode[(a & 0x03) << 4 | b >> 4]; *write++ = (extra > 1) ? base64_encode[(b & 0x0f) << 2] : '='; *write++ = '='; } buf->size = ((char *)write) - buf->ptr; buf->ptr[buf->size] = '\0'; return 0; } /* The inverse of base64_encode, offset by '+' == 43. */ static const int8_t base64_decode[] = { 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 }; #define BASE64_DECODE_VALUE(c) (((c) < 43 || (c) > 122) ? -1 : base64_decode[c - 43]) int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len) { size_t i; int8_t a, b, c, d; size_t orig_size = buf->size, new_size; assert(len % 4 == 0); GITERR_CHECK_ALLOC_ADD(&new_size, (len / 4 * 3), buf->size); GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); ENSURE_SIZE(buf, new_size); for (i = 0; i < len; i += 4) { if ((a = BASE64_DECODE_VALUE(base64[i])) < 0 || (b = BASE64_DECODE_VALUE(base64[i+1])) < 0 || (c = BASE64_DECODE_VALUE(base64[i+2])) < 0 || (d = BASE64_DECODE_VALUE(base64[i+3])) < 0) { buf->size = orig_size; buf->ptr[buf->size] = '\0'; giterr_set(GITERR_INVALID, "Invalid base64 input"); return -1; } buf->ptr[buf->size++] = ((a << 2) | (b & 0x30) >> 4); buf->ptr[buf->size++] = ((b & 0x0f) << 4) | ((c & 0x3c) >> 2); buf->ptr[buf->size++] = (c & 0x03) << 6 | (d & 0x3f); } buf->ptr[buf->size] = '\0'; return 0; } static const char b85str[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"; int git_buf_encode_base85(git_buf *buf, const char *data, size_t len) { size_t blocks = (len / 4) + !!(len % 4), alloclen; GITERR_CHECK_ALLOC_MULTIPLY(&alloclen, blocks, 5); GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, buf->size); GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); ENSURE_SIZE(buf, alloclen); while (len) { uint32_t acc = 0; char b85[5]; int i; for (i = 24; i >= 0; i -= 8) { uint8_t ch = *data++; acc |= ch << i; if (--len == 0) break; } for (i = 4; i >= 0; i--) { int val = acc % 85; acc /= 85; b85[i] = b85str[val]; } for (i = 0; i < 5; i++) buf->ptr[buf->size++] = b85[i]; } buf->ptr[buf->size] = '\0'; return 0; } int git_buf_vprintf(git_buf *buf, const char *format, va_list ap) { size_t expected_size, new_size; int len; GITERR_CHECK_ALLOC_MULTIPLY(&expected_size, strlen(format), 2); GITERR_CHECK_ALLOC_ADD(&expected_size, expected_size, buf->size); ENSURE_SIZE(buf, expected_size); while (1) { va_list args; va_copy(args, ap); len = p_vsnprintf( buf->ptr + buf->size, buf->asize - buf->size, format, args ); va_end(args); if (len < 0) { git__free(buf->ptr); buf->ptr = git_buf__oom; return -1; } if ((size_t)len + 1 <= buf->asize - buf->size) { buf->size += len; break; } GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, len); GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); ENSURE_SIZE(buf, new_size); } return 0; } int git_buf_printf(git_buf *buf, const char *format, ...) { int r; va_list ap; va_start(ap, format); r = git_buf_vprintf(buf, format, ap); va_end(ap); return r; } void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf) { size_t copylen; assert(data && datasize && buf); data[0] = '\0'; if (buf->size == 0 || buf->asize <= 0) return; copylen = buf->size; if (copylen > datasize - 1) copylen = datasize - 1; memmove(data, buf->ptr, copylen); data[copylen] = '\0'; } void git_buf_consume(git_buf *buf, const char *end) { if (end > buf->ptr && end <= buf->ptr + buf->size) { size_t consumed = end - buf->ptr; memmove(buf->ptr, end, buf->size - consumed); buf->size -= consumed; buf->ptr[buf->size] = '\0'; } } void git_buf_truncate(git_buf *buf, size_t len) { if (len >= buf->size) return; buf->size = len; if (buf->size < buf->asize) buf->ptr[buf->size] = '\0'; } void git_buf_shorten(git_buf *buf, size_t amount) { if (buf->size > amount) git_buf_truncate(buf, buf->size - amount); else git_buf_clear(buf); } void git_buf_rtruncate_at_char(git_buf *buf, char separator) { ssize_t idx = git_buf_rfind_next(buf, separator); git_buf_truncate(buf, idx < 0 ? 0 : (size_t)idx); } void git_buf_swap(git_buf *buf_a, git_buf *buf_b) { git_buf t = *buf_a; *buf_a = *buf_b; *buf_b = t; } char *git_buf_detach(git_buf *buf) { char *data = buf->ptr; if (buf->asize == 0 || buf->ptr == git_buf__oom) return NULL; git_buf_init(buf, 0); return data; } void git_buf_attach(git_buf *buf, char *ptr, size_t asize) { git_buf_free(buf); if (ptr) { buf->ptr = ptr; buf->size = strlen(ptr); if (asize) buf->asize = (asize < buf->size) ? buf->size + 1 : asize; else /* pass 0 to fall back on strlen + 1 */ buf->asize = buf->size + 1; } else { git_buf_grow(buf, asize); } } void git_buf_attach_notowned(git_buf *buf, const char *ptr, size_t size) { if (git_buf_is_allocated(buf)) git_buf_free(buf); if (!size) { git_buf_init(buf, 0); } else { buf->ptr = (char *)ptr; buf->asize = 0; buf->size = size; } } int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...) { va_list ap; int i; size_t total_size = 0, original_size = buf->size; char *out, *original = buf->ptr; if (buf->size > 0 && buf->ptr[buf->size - 1] != separator) ++total_size; /* space for initial separator */ /* Make two passes to avoid multiple reallocation */ va_start(ap, nbuf); for (i = 0; i < nbuf; ++i) { const char* segment; size_t segment_len; segment = va_arg(ap, const char *); if (!segment) continue; segment_len = strlen(segment); GITERR_CHECK_ALLOC_ADD(&total_size, total_size, segment_len); if (segment_len == 0 || segment[segment_len - 1] != separator) GITERR_CHECK_ALLOC_ADD(&total_size, total_size, 1); } va_end(ap); /* expand buffer if needed */ if (total_size == 0) return 0; GITERR_CHECK_ALLOC_ADD(&total_size, total_size, 1); if (git_buf_grow_by(buf, total_size) < 0) return -1; out = buf->ptr + buf->size; /* append separator to existing buf if needed */ if (buf->size > 0 && out[-1] != separator) *out++ = separator; va_start(ap, nbuf); for (i = 0; i < nbuf; ++i) { const char* segment; size_t segment_len; segment = va_arg(ap, const char *); if (!segment) continue; /* deal with join that references buffer's original content */ if (segment >= original && segment < original + original_size) { size_t offset = (segment - original); segment = buf->ptr + offset; segment_len = original_size - offset; } else { segment_len = strlen(segment); } /* skip leading separators */ if (out > buf->ptr && out[-1] == separator) while (segment_len > 0 && *segment == separator) { segment++; segment_len--; } /* copy over next buffer */ if (segment_len > 0) { memmove(out, segment, segment_len); out += segment_len; } /* append trailing separator (except for last item) */ if (i < nbuf - 1 && out > buf->ptr && out[-1] != separator) *out++ = separator; } va_end(ap); /* set size based on num characters actually written */ buf->size = out - buf->ptr; buf->ptr[buf->size] = '\0'; return 0; } int git_buf_join( git_buf *buf, char separator, const char *str_a, const char *str_b) { size_t strlen_a = str_a ? strlen(str_a) : 0; size_t strlen_b = strlen(str_b); size_t alloc_len; int need_sep = 0; ssize_t offset_a = -1; /* not safe to have str_b point internally to the buffer */ assert(str_b < buf->ptr || str_b >= buf->ptr + buf->size); /* figure out if we need to insert a separator */ if (separator && strlen_a) { while (*str_b == separator) { str_b++; strlen_b--; } if (str_a[strlen_a - 1] != separator) need_sep = 1; } /* str_a could be part of the buffer */ if (str_a >= buf->ptr && str_a < buf->ptr + buf->size) offset_a = str_a - buf->ptr; GITERR_CHECK_ALLOC_ADD(&alloc_len, strlen_a, strlen_b); GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, need_sep); GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 1); if (git_buf_grow(buf, alloc_len) < 0) return -1; assert(buf->ptr); /* fix up internal pointers */ if (offset_a >= 0) str_a = buf->ptr + offset_a; /* do the actual copying */ if (offset_a != 0 && str_a) memmove(buf->ptr, str_a, strlen_a); if (need_sep) buf->ptr[strlen_a] = separator; memcpy(buf->ptr + strlen_a + need_sep, str_b, strlen_b); buf->size = strlen_a + strlen_b + need_sep; buf->ptr[buf->size] = '\0'; return 0; } int git_buf_join3( git_buf *buf, char separator, const char *str_a, const char *str_b, const char *str_c) { size_t len_a = strlen(str_a), len_b = strlen(str_b), len_c = strlen(str_c), len_total; int sep_a = 0, sep_b = 0; char *tgt; /* for this function, disallow pointers into the existing buffer */ assert(str_a < buf->ptr || str_a >= buf->ptr + buf->size); assert(str_b < buf->ptr || str_b >= buf->ptr + buf->size); assert(str_c < buf->ptr || str_c >= buf->ptr + buf->size); if (separator) { if (len_a > 0) { while (*str_b == separator) { str_b++; len_b--; } sep_a = (str_a[len_a - 1] != separator); } if (len_a > 0 || len_b > 0) while (*str_c == separator) { str_c++; len_c--; } if (len_b > 0) sep_b = (str_b[len_b - 1] != separator); } GITERR_CHECK_ALLOC_ADD(&len_total, len_a, sep_a); GITERR_CHECK_ALLOC_ADD(&len_total, len_total, len_b); GITERR_CHECK_ALLOC_ADD(&len_total, len_total, sep_b); GITERR_CHECK_ALLOC_ADD(&len_total, len_total, len_c); GITERR_CHECK_ALLOC_ADD(&len_total, len_total, 1); if (git_buf_grow(buf, len_total) < 0) return -1; tgt = buf->ptr; if (len_a) { memcpy(tgt, str_a, len_a); tgt += len_a; } if (sep_a) *tgt++ = separator; if (len_b) { memcpy(tgt, str_b, len_b); tgt += len_b; } if (sep_b) *tgt++ = separator; if (len_c) memcpy(tgt, str_c, len_c); buf->size = len_a + sep_a + len_b + sep_b + len_c; buf->ptr[buf->size] = '\0'; return 0; } void git_buf_rtrim(git_buf *buf) { while (buf->size > 0) { if (!git__isspace(buf->ptr[buf->size - 1])) break; buf->size--; } if (buf->asize > buf->size) buf->ptr[buf->size] = '\0'; } int git_buf_cmp(const git_buf *a, const git_buf *b) { int result = memcmp(a->ptr, b->ptr, min(a->size, b->size)); return (result != 0) ? result : (a->size < b->size) ? -1 : (a->size > b->size) ? 1 : 0; } int git_buf_splice( git_buf *buf, size_t where, size_t nb_to_remove, const char *data, size_t nb_to_insert) { char *splice_loc; size_t new_size, alloc_size; assert(buf && where <= buf->size && nb_to_remove <= buf->size - where); splice_loc = buf->ptr + where; /* Ported from git.git * https://github.com/git/git/blob/16eed7c/strbuf.c#L159-176 */ GITERR_CHECK_ALLOC_ADD(&new_size, (buf->size - nb_to_remove), nb_to_insert); GITERR_CHECK_ALLOC_ADD(&alloc_size, new_size, 1); ENSURE_SIZE(buf, alloc_size); memmove(splice_loc + nb_to_insert, splice_loc + nb_to_remove, buf->size - where - nb_to_remove); memcpy(splice_loc, data, nb_to_insert); buf->size = new_size; buf->ptr[buf->size] = '\0'; return 0; } deps/libgit2-sys-0.3.8/libgit2/src/win32/0000755000000000000000000000000012666635520016423 5ustar rootrootdeps/libgit2-sys-0.3.8/libgit2/src/win32/dir.c0000664000175000017500000000446012510265101015553 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #define GIT__WIN32_NO_WRAP_DIR #include "posix.h" git__DIR *git__opendir(const char *dir) { git_win32_path filter_w; git__DIR *new = NULL; size_t dirlen, alloclen; if (!dir || !git_win32__findfirstfile_filter(filter_w, dir)) return NULL; dirlen = strlen(dir); if (GIT_ADD_SIZET_OVERFLOW(&alloclen, sizeof(*new), dirlen) || GIT_ADD_SIZET_OVERFLOW(&alloclen, alloclen, 1) || !(new = git__calloc(1, alloclen))) return NULL; memcpy(new->dir, dir, dirlen); new->h = FindFirstFileW(filter_w, &new->f); if (new->h == INVALID_HANDLE_VALUE) { giterr_set(GITERR_OS, "Could not open directory '%s'", dir); git__free(new); return NULL; } new->first = 1; return new; } int git__readdir_ext( git__DIR *d, struct git__dirent *entry, struct git__dirent **result, int *is_dir) { if (!d || !entry || !result || d->h == INVALID_HANDLE_VALUE) return -1; *result = NULL; if (d->first) d->first = 0; else if (!FindNextFileW(d->h, &d->f)) { if (GetLastError() == ERROR_NO_MORE_FILES) return 0; giterr_set(GITERR_OS, "Could not read from directory '%s'", d->dir); return -1; } /* Convert the path to UTF-8 */ if (git_win32_path_to_utf8(entry->d_name, d->f.cFileName) < 0) return -1; entry->d_ino = 0; *result = entry; if (is_dir != NULL) *is_dir = ((d->f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0); return 0; } struct git__dirent *git__readdir(git__DIR *d) { struct git__dirent *result; if (git__readdir_ext(d, &d->entry, &result, NULL) < 0) return NULL; return result; } void git__rewinddir(git__DIR *d) { git_win32_path filter_w; if (!d) return; if (d->h != INVALID_HANDLE_VALUE) { FindClose(d->h); d->h = INVALID_HANDLE_VALUE; d->first = 0; } if (!git_win32__findfirstfile_filter(filter_w, d->dir)) return; d->h = FindFirstFileW(filter_w, &d->f); if (d->h == INVALID_HANDLE_VALUE) giterr_set(GITERR_OS, "Could not open directory '%s'", d->dir); else d->first = 1; } int git__closedir(git__DIR *d) { if (!d) return 0; if (d->h != INVALID_HANDLE_VALUE) { FindClose(d->h); d->h = INVALID_HANDLE_VALUE; } git__free(d); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/win32/path_w32.c0000664000175000017500000002232612610310643016430 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "path.h" #include "path_w32.h" #include "utf-conv.h" #include "posix.h" #include "reparse.h" #include "dir.h" #define PATH__NT_NAMESPACE L"\\\\?\\" #define PATH__NT_NAMESPACE_LEN 4 #define PATH__ABSOLUTE_LEN 3 #define path__is_dirsep(p) ((p) == '/' || (p) == '\\') #define path__is_absolute(p) \ (git__isalpha((p)[0]) && (p)[1] == ':' && ((p)[2] == '\\' || (p)[2] == '/')) #define path__is_nt_namespace(p) \ (((p)[0] == '\\' && (p)[1] == '\\' && (p)[2] == '?' && (p)[3] == '\\') || \ ((p)[0] == '/' && (p)[1] == '/' && (p)[2] == '?' && (p)[3] == '/')) #define path__is_unc(p) \ (((p)[0] == '\\' && (p)[1] == '\\') || ((p)[0] == '/' && (p)[1] == '/')) GIT_INLINE(int) path__cwd(wchar_t *path, int size) { int len; if ((len = GetCurrentDirectoryW(size, path)) == 0) { errno = GetLastError() == ERROR_ACCESS_DENIED ? EACCES : ENOENT; return -1; } else if (len > size) { errno = ENAMETOOLONG; return -1; } /* The Win32 APIs may return "\\?\" once you've used it first. * But it may not. What a gloriously predictible API! */ if (wcsncmp(path, PATH__NT_NAMESPACE, PATH__NT_NAMESPACE_LEN)) return len; len -= PATH__NT_NAMESPACE_LEN; memmove(path, path + PATH__NT_NAMESPACE_LEN, sizeof(wchar_t) * len); return len; } static wchar_t *path__skip_server(wchar_t *path) { wchar_t *c; for (c = path; *c; c++) { if (path__is_dirsep(*c)) return c + 1; } return c; } static wchar_t *path__skip_prefix(wchar_t *path) { if (path__is_nt_namespace(path)) { path += PATH__NT_NAMESPACE_LEN; if (wcsncmp(path, L"UNC\\", 4) == 0) path = path__skip_server(path + 4); else if (path__is_absolute(path)) path += PATH__ABSOLUTE_LEN; } else if (path__is_absolute(path)) { path += PATH__ABSOLUTE_LEN; } else if (path__is_unc(path)) { path = path__skip_server(path + 2); } return path; } int git_win32_path_canonicalize(git_win32_path path) { wchar_t *base, *from, *to, *next; size_t len; base = to = path__skip_prefix(path); /* Unposixify if the prefix */ for (from = path; from < to; from++) { if (*from == L'/') *from = L'\\'; } while (*from) { for (next = from; *next; ++next) { if (*next == L'/') { *next = L'\\'; break; } if (*next == L'\\') break; } len = next - from; if (len == 1 && from[0] == L'.') /* do nothing with singleton dot */; else if (len == 2 && from[0] == L'.' && from[1] == L'.') { if (to == base) { /* no more path segments to strip, eat the "../" */ if (*next == L'\\') len++; base = to; } else { /* back up a path segment */ while (to > base && to[-1] == L'\\') to--; while (to > base && to[-1] != L'\\') to--; } } else { if (*next == L'\\' && *from != L'\\') len++; if (to != from) memmove(to, from, sizeof(wchar_t) * len); to += len; } from += len; while (*from == L'\\') from++; } /* Strip trailing backslashes */ while (to > base && to[-1] == L'\\') to--; *to = L'\0'; return (to - path); } int git_win32_path__cwd(wchar_t *out, size_t len) { int cwd_len; if ((cwd_len = path__cwd(out, len)) < 0) return -1; /* UNC paths */ if (wcsncmp(L"\\\\", out, 2) == 0) { /* Our buffer must be at least 5 characters larger than the * current working directory: we swallow one of the leading * '\'s, but we we add a 'UNC' specifier to the path, plus * a trailing directory separator, plus a NUL. */ if (cwd_len > MAX_PATH - 4) { errno = ENAMETOOLONG; return -1; } memmove(out+2, out, sizeof(wchar_t) * cwd_len); out[0] = L'U'; out[1] = L'N'; out[2] = L'C'; cwd_len += 2; } /* Our buffer must be at least 2 characters larger than the current * working directory. (One character for the directory separator, * one for the null. */ else if (cwd_len > MAX_PATH - 2) { errno = ENAMETOOLONG; return -1; } return cwd_len; } int git_win32_path_from_utf8(git_win32_path out, const char *src) { wchar_t *dest = out; /* All win32 paths are in NT-prefixed format, beginning with "\\?\". */ memcpy(dest, PATH__NT_NAMESPACE, sizeof(wchar_t) * PATH__NT_NAMESPACE_LEN); dest += PATH__NT_NAMESPACE_LEN; /* See if this is an absolute path (beginning with a drive letter) */ if (path__is_absolute(src)) { if (git__utf8_to_16(dest, MAX_PATH, src) < 0) goto on_error; } /* File-prefixed NT-style paths beginning with \\?\ */ else if (path__is_nt_namespace(src)) { /* Skip the NT prefix, the destination already contains it */ if (git__utf8_to_16(dest, MAX_PATH, src + PATH__NT_NAMESPACE_LEN) < 0) goto on_error; } /* UNC paths */ else if (path__is_unc(src)) { memcpy(dest, L"UNC\\", sizeof(wchar_t) * 4); dest += 4; /* Skip the leading "\\" */ if (git__utf8_to_16(dest, MAX_PATH - 2, src + 2) < 0) goto on_error; } /* Absolute paths omitting the drive letter */ else if (src[0] == '\\' || src[0] == '/') { if (path__cwd(dest, MAX_PATH) < 0) goto on_error; if (!path__is_absolute(dest)) { errno = ENOENT; goto on_error; } /* Skip the drive letter specification ("C:") */ if (git__utf8_to_16(dest + 2, MAX_PATH - 2, src) < 0) goto on_error; } /* Relative paths */ else { int cwd_len; if ((cwd_len = git_win32_path__cwd(dest, MAX_PATH)) < 0) goto on_error; dest[cwd_len++] = L'\\'; if (git__utf8_to_16(dest + cwd_len, MAX_PATH - cwd_len, src) < 0) goto on_error; } return git_win32_path_canonicalize(out); on_error: /* set windows error code so we can use its error message */ if (errno == ENAMETOOLONG) SetLastError(ERROR_FILENAME_EXCED_RANGE); return -1; } int git_win32_path_to_utf8(git_win32_utf8_path dest, const wchar_t *src) { char *out = dest; int len; /* Strip NT namespacing "\\?\" */ if (path__is_nt_namespace(src)) { src += 4; /* "\\?\UNC\server\share" -> "\\server\share" */ if (wcsncmp(src, L"UNC\\", 4) == 0) { src += 4; memcpy(dest, "\\\\", 2); out = dest + 2; } } if ((len = git__utf16_to_8(out, GIT_WIN_PATH_UTF8, src)) < 0) return len; git_path_mkposix(dest); return len; } char *git_win32_path_8dot3_name(const char *path) { git_win32_path longpath, shortpath; wchar_t *start; char *shortname; int len, namelen = 1; if (git_win32_path_from_utf8(longpath, path) < 0) return NULL; len = GetShortPathNameW(longpath, shortpath, GIT_WIN_PATH_UTF16); while (len && shortpath[len-1] == L'\\') shortpath[--len] = L'\0'; if (len == 0 || len >= GIT_WIN_PATH_UTF16) return NULL; for (start = shortpath + (len - 1); start > shortpath && *(start-1) != '/' && *(start-1) != '\\'; start--) namelen++; /* We may not have actually been given a short name. But if we have, * it will be in the ASCII byte range, so we don't need to worry about * multi-byte sequences and can allocate naively. */ if (namelen > 12 || (shortname = git__malloc(namelen + 1)) == NULL) return NULL; if ((len = git__utf16_to_8(shortname, namelen + 1, start)) < 0) return NULL; return shortname; } static bool path_is_volume(wchar_t *target, size_t target_len) { return (target_len && wcsncmp(target, L"\\??\\Volume{", 11) == 0); } /* On success, returns the length, in characters, of the path stored in dest. * On failure, returns a negative value. */ int git_win32_path_readlink_w(git_win32_path dest, const git_win32_path path) { BYTE buf[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; GIT_REPARSE_DATA_BUFFER *reparse_buf = (GIT_REPARSE_DATA_BUFFER *)buf; HANDLE handle = NULL; DWORD ioctl_ret; wchar_t *target; size_t target_len; int error = -1; handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); if (handle == INVALID_HANDLE_VALUE) { errno = ENOENT; return -1; } if (!DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, NULL, 0, reparse_buf, sizeof(buf), &ioctl_ret, NULL)) { errno = EINVAL; goto on_error; } switch (reparse_buf->ReparseTag) { case IO_REPARSE_TAG_SYMLINK: target = reparse_buf->SymbolicLinkReparseBuffer.PathBuffer + (reparse_buf->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(WCHAR)); target_len = reparse_buf->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(WCHAR); break; case IO_REPARSE_TAG_MOUNT_POINT: target = reparse_buf->MountPointReparseBuffer.PathBuffer + (reparse_buf->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR)); target_len = reparse_buf->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR); break; default: errno = EINVAL; goto on_error; } if (path_is_volume(target, target_len)) { /* This path is a reparse point that represents another volume mounted * at this location, it is not a symbolic link our input was canonical. */ errno = EINVAL; error = -1; } else if (target_len) { /* The path may need to have a prefix removed. */ target_len = git_win32__canonicalize_path(target, target_len); /* Need one additional character in the target buffer * for the terminating NULL. */ if (GIT_WIN_PATH_UTF16 > target_len) { wcscpy(dest, target); error = (int)target_len; } } on_error: CloseHandle(handle); return error; } deps/libgit2-sys-0.3.8/libgit2/src/win32/precompiled.h0000664000175000017500000000056312426525445017325 0ustar #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef GIT_THREADS #include "win32/pthread.h" #endif #include "git2.h" #include "common.h" deps/libgit2-sys-0.3.8/libgit2/src/win32/posix_w32.c0000664000175000017500000003635312610310643016643 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "../posix.h" #include "../fileops.h" #include "path.h" #include "path_w32.h" #include "utf-conv.h" #include "repository.h" #include "reparse.h" #include "global.h" #include "buffer.h" #include #include #include #include #ifndef FILE_NAME_NORMALIZED # define FILE_NAME_NORMALIZED 0 #endif #ifndef IO_REPARSE_TAG_SYMLINK #define IO_REPARSE_TAG_SYMLINK (0xA000000CL) #endif /* Options which we always provide to _wopen. * * _O_BINARY - Raw access; no translation of CR or LF characters * _O_NOINHERIT - Do not mark the created handle as inheritable by child processes. * The Windows default is 'not inheritable', but the CRT's default (following * POSIX convention) is 'inheritable'. We have no desire for our handles to be * inheritable on Windows, so specify the flag to get default behavior back. */ #define STANDARD_OPEN_FLAGS (_O_BINARY | _O_NOINHERIT) /* Allowable mode bits on Win32. Using mode bits that are not supported on * Win32 (eg S_IRWXU) is generally ignored, but Wine warns loudly about it * so we simply remove them. */ #define WIN32_MODE_MASK (_S_IREAD | _S_IWRITE) /* GetFinalPathNameByHandleW signature */ typedef DWORD(WINAPI *PFGetFinalPathNameByHandleW)(HANDLE, LPWSTR, DWORD, DWORD); /** * Truncate or extend file. * * We now take a "git_off_t" rather than "long" because * files may be longer than 2Gb. */ int p_ftruncate(int fd, git_off_t size) { if (size < 0) { errno = EINVAL; return -1; } #if !defined(__MINGW32__) || defined(MINGW_HAS_SECURE_API) return ((_chsize_s(fd, size) == 0) ? 0 : -1); #else /* TODO MINGW32 Find a replacement for _chsize() that handles big files. */ if (size > INT32_MAX) { errno = EFBIG; return -1; } return _chsize(fd, (long)size); #endif } int p_mkdir(const char *path, mode_t mode) { git_win32_path buf; GIT_UNUSED(mode); if (git_win32_path_from_utf8(buf, path) < 0) return -1; return _wmkdir(buf); } int p_link(const char *old, const char *new) { GIT_UNUSED(old); GIT_UNUSED(new); errno = ENOSYS; return -1; } int p_unlink(const char *path) { git_win32_path buf; int error; if (git_win32_path_from_utf8(buf, path) < 0) return -1; error = _wunlink(buf); /* If the file could not be deleted because it was * read-only, clear the bit and try again */ if (error == -1 && errno == EACCES) { _wchmod(buf, 0666); error = _wunlink(buf); } return error; } int p_fsync(int fd) { HANDLE fh = (HANDLE)_get_osfhandle(fd); if (fh == INVALID_HANDLE_VALUE) { errno = EBADF; return -1; } if (!FlushFileBuffers(fh)) { DWORD code = GetLastError(); if (code == ERROR_INVALID_HANDLE) errno = EINVAL; else errno = EIO; return -1; } return 0; } #define WIN32_IS_WSEP(CH) ((CH) == L'/' || (CH) == L'\\') static int lstat_w( wchar_t *path, struct stat *buf, bool posix_enotdir) { WIN32_FILE_ATTRIBUTE_DATA fdata; if (GetFileAttributesExW(path, GetFileExInfoStandard, &fdata)) { if (!buf) return 0; return git_win32__file_attribute_to_stat(buf, &fdata, path); } switch (GetLastError()) { case ERROR_ACCESS_DENIED: errno = EACCES; break; default: errno = ENOENT; break; } /* To match POSIX behavior, set ENOTDIR when any of the folders in the * file path is a regular file, otherwise set ENOENT. */ if (errno == ENOENT && posix_enotdir) { size_t path_len = wcslen(path); /* scan up path until we find an existing item */ while (1) { DWORD attrs; /* remove last directory component */ for (path_len--; path_len > 0 && !WIN32_IS_WSEP(path[path_len]); path_len--); if (path_len <= 0) break; path[path_len] = L'\0'; attrs = GetFileAttributesW(path); if (attrs != INVALID_FILE_ATTRIBUTES) { if (!(attrs & FILE_ATTRIBUTE_DIRECTORY)) errno = ENOTDIR; break; } } } return -1; } static int do_lstat(const char *path, struct stat *buf, bool posixly_correct) { git_win32_path path_w; int len; if ((len = git_win32_path_from_utf8(path_w, path)) < 0) return -1; git_win32__path_trim_end(path_w, len); return lstat_w(path_w, buf, posixly_correct); } int p_lstat(const char *filename, struct stat *buf) { return do_lstat(filename, buf, false); } int p_lstat_posixly(const char *filename, struct stat *buf) { return do_lstat(filename, buf, true); } int p_utimes(const char *filename, const struct timeval times[2]) { int fd, error; if ((fd = p_open(filename, O_RDWR)) < 0) return fd; error = p_futimes(fd, times); close(fd); return error; } int p_futimes(int fd, const struct timeval times[2]) { HANDLE handle; FILETIME atime = {0}, mtime = {0}; if (times == NULL) { SYSTEMTIME st; GetSystemTime(&st); SystemTimeToFileTime(&st, &atime); SystemTimeToFileTime(&st, &mtime); } else { git_win32__timeval_to_filetime(&atime, times[0]); git_win32__timeval_to_filetime(&mtime, times[1]); } if ((handle = (HANDLE)_get_osfhandle(fd)) == INVALID_HANDLE_VALUE) return -1; if (SetFileTime(handle, NULL, &atime, &mtime) == 0) return -1; return 0; } int p_readlink(const char *path, char *buf, size_t bufsiz) { git_win32_path path_w, target_w; git_win32_utf8_path target; int len; /* readlink(2) does not NULL-terminate the string written * to the target buffer. Furthermore, the target buffer need * not be large enough to hold the entire result. A truncated * result should be written in this case. Since this truncation * could occur in the middle of the encoding of a code point, * we need to buffer the result on the stack. */ if (git_win32_path_from_utf8(path_w, path) < 0 || git_win32_path_readlink_w(target_w, path_w) < 0 || (len = git_win32_path_to_utf8(target, target_w)) < 0) return -1; bufsiz = min((size_t)len, bufsiz); memcpy(buf, target, bufsiz); return (int)bufsiz; } int p_symlink(const char *old, const char *new) { /* Real symlinks on NTFS require admin privileges. Until this changes, * libgit2 just creates a text file with the link target in the contents. */ return git_futils_fake_symlink(old, new); } int p_open(const char *path, int flags, ...) { git_win32_path buf; mode_t mode = 0; if (git_win32_path_from_utf8(buf, path) < 0) return -1; if (flags & O_CREAT) { va_list arg_list; va_start(arg_list, flags); mode = (mode_t)va_arg(arg_list, int); va_end(arg_list); } return _wopen(buf, flags | STANDARD_OPEN_FLAGS, mode & WIN32_MODE_MASK); } int p_creat(const char *path, mode_t mode) { git_win32_path buf; if (git_win32_path_from_utf8(buf, path) < 0) return -1; return _wopen(buf, _O_WRONLY | _O_CREAT | _O_TRUNC | STANDARD_OPEN_FLAGS, mode & WIN32_MODE_MASK); } int p_getcwd(char *buffer_out, size_t size) { git_win32_path buf; wchar_t *cwd = _wgetcwd(buf, GIT_WIN_PATH_UTF16); if (!cwd) return -1; /* Convert the working directory back to UTF-8 */ if (git__utf16_to_8(buffer_out, size, cwd) < 0) { DWORD code = GetLastError(); if (code == ERROR_INSUFFICIENT_BUFFER) errno = ERANGE; else errno = EINVAL; return -1; } return 0; } /* * Returns the address of the GetFinalPathNameByHandleW function. * This function is available on Windows Vista and higher. */ static PFGetFinalPathNameByHandleW get_fpnbyhandle(void) { static PFGetFinalPathNameByHandleW pFunc = NULL; PFGetFinalPathNameByHandleW toReturn = pFunc; if (!toReturn) { HMODULE hModule = GetModuleHandleW(L"kernel32"); if (hModule) toReturn = (PFGetFinalPathNameByHandleW)GetProcAddress(hModule, "GetFinalPathNameByHandleW"); pFunc = toReturn; } assert(toReturn); return toReturn; } static int getfinalpath_w( git_win32_path dest, const wchar_t *path) { PFGetFinalPathNameByHandleW pgfp = get_fpnbyhandle(); HANDLE hFile; DWORD dwChars; if (!pgfp) return -1; /* Use FILE_FLAG_BACKUP_SEMANTICS so we can open a directory. Do not * specify FILE_FLAG_OPEN_REPARSE_POINT; we want to open a handle to the * target of the link. */ hFile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); if (INVALID_HANDLE_VALUE == hFile) return -1; /* Call GetFinalPathNameByHandle */ dwChars = pgfp(hFile, dest, GIT_WIN_PATH_UTF16, FILE_NAME_NORMALIZED); CloseHandle(hFile); if (!dwChars || dwChars >= GIT_WIN_PATH_UTF16) return -1; /* The path may be delivered to us with a prefix; canonicalize */ return (int)git_win32__canonicalize_path(dest, dwChars); } static int follow_and_lstat_link(git_win32_path path, struct stat* buf) { git_win32_path target_w; if (getfinalpath_w(target_w, path) < 0) return -1; return lstat_w(target_w, buf, false); } int p_stat(const char* path, struct stat* buf) { git_win32_path path_w; int len; if ((len = git_win32_path_from_utf8(path_w, path)) < 0 || lstat_w(path_w, buf, false) < 0) return -1; /* The item is a symbolic link or mount point. No need to iterate * to follow multiple links; use GetFinalPathNameFromHandle. */ if (S_ISLNK(buf->st_mode)) return follow_and_lstat_link(path_w, buf); return 0; } int p_chdir(const char* path) { git_win32_path buf; if (git_win32_path_from_utf8(buf, path) < 0) return -1; return _wchdir(buf); } int p_chmod(const char* path, mode_t mode) { git_win32_path buf; if (git_win32_path_from_utf8(buf, path) < 0) return -1; return _wchmod(buf, mode); } int p_rmdir(const char* path) { git_win32_path buf; int error; if (git_win32_path_from_utf8(buf, path) < 0) return -1; error = _wrmdir(buf); if (error == -1) { switch (GetLastError()) { /* _wrmdir() is documented to return EACCES if "A program has an open * handle to the directory." This sounds like what everybody else calls * EBUSY. Let's convert appropriate error codes. */ case ERROR_SHARING_VIOLATION: errno = EBUSY; break; /* This error can be returned when trying to rmdir an extant file. */ case ERROR_DIRECTORY: errno = ENOTDIR; break; } } return error; } char *p_realpath(const char *orig_path, char *buffer) { git_win32_path orig_path_w, buffer_w; if (git_win32_path_from_utf8(orig_path_w, orig_path) < 0) return NULL; /* Note that if the path provided is a relative path, then the current directory * is used to resolve the path -- which is a concurrency issue because the current * directory is a process-wide variable. */ if (!GetFullPathNameW(orig_path_w, GIT_WIN_PATH_UTF16, buffer_w, NULL)) { if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) errno = ENAMETOOLONG; else errno = EINVAL; return NULL; } /* The path must exist. */ if (GetFileAttributesW(buffer_w) == INVALID_FILE_ATTRIBUTES) { errno = ENOENT; return NULL; } if (!buffer && !(buffer = git__malloc(GIT_WIN_PATH_UTF8))) { errno = ENOMEM; return NULL; } /* Convert the path to UTF-8. If the caller provided a buffer, then it * is assumed to be GIT_WIN_PATH_UTF8 characters in size. If it isn't, * then we may overflow. */ if (git_win32_path_to_utf8(buffer, buffer_w) < 0) return NULL; git_path_mkposix(buffer); return buffer; } int p_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr) { #if defined(_MSC_VER) int len; if (count == 0) return _vscprintf(format, argptr); #if _MSC_VER >= 1500 len = _vsnprintf_s(buffer, count, _TRUNCATE, format, argptr); #else len = _vsnprintf(buffer, count, format, argptr); #endif if (len < 0) return _vscprintf(format, argptr); return len; #else /* MinGW */ return vsnprintf(buffer, count, format, argptr); #endif } int p_snprintf(char *buffer, size_t count, const char *format, ...) { va_list va; int r; va_start(va, format); r = p_vsnprintf(buffer, count, format, va); va_end(va); return r; } /* TODO: wut? */ int p_mkstemp(char *tmp_path) { #if defined(_MSC_VER) && _MSC_VER >= 1500 if (_mktemp_s(tmp_path, strlen(tmp_path) + 1) != 0) return -1; #else if (_mktemp(tmp_path) == NULL) return -1; #endif return p_open(tmp_path, O_RDWR | O_CREAT | O_EXCL, 0744); //-V536 } int p_access(const char* path, mode_t mode) { git_win32_path buf; if (git_win32_path_from_utf8(buf, path) < 0) return -1; return _waccess(buf, mode & WIN32_MODE_MASK); } static int ensure_writable(wchar_t *fpath) { DWORD attrs; attrs = GetFileAttributesW(fpath); if (attrs == INVALID_FILE_ATTRIBUTES) { if (GetLastError() == ERROR_FILE_NOT_FOUND) return 0; giterr_set(GITERR_OS, "failed to get attributes"); return -1; } if (!(attrs & FILE_ATTRIBUTE_READONLY)) return 0; attrs &= ~FILE_ATTRIBUTE_READONLY; if (!SetFileAttributesW(fpath, attrs)) { giterr_set(GITERR_OS, "failed to set attributes"); return -1; } return 0; } int p_rename(const char *from, const char *to) { git_win32_path wfrom; git_win32_path wto; int rename_tries; int rename_succeeded; int error; if (git_win32_path_from_utf8(wfrom, from) < 0 || git_win32_path_from_utf8(wto, to) < 0) return -1; /* wait up to 50ms if file is locked by another thread or process */ rename_tries = 0; rename_succeeded = 0; while (rename_tries < 10) { if (ensure_writable(wto) == 0 && MoveFileExW(wfrom, wto, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED) != 0) { rename_succeeded = 1; break; } error = GetLastError(); if (error == ERROR_SHARING_VIOLATION || error == ERROR_ACCESS_DENIED) { Sleep(5); rename_tries++; } else break; } return rename_succeeded ? 0 : -1; } int p_recv(GIT_SOCKET socket, void *buffer, size_t length, int flags) { if ((size_t)((int)length) != length) return -1; /* giterr_set will be done by caller */ return recv(socket, buffer, (int)length, flags); } int p_send(GIT_SOCKET socket, const void *buffer, size_t length, int flags) { if ((size_t)((int)length) != length) return -1; /* giterr_set will be done by caller */ return send(socket, buffer, (int)length, flags); } /** * Borrowed from http://old.nabble.com/Porting-localtime_r-and-gmtime_r-td15282276.html * On Win32, `gmtime_r` doesn't exist but `gmtime` is threadsafe, so we can use that */ struct tm * p_localtime_r (const time_t *timer, struct tm *result) { struct tm *local_result; local_result = localtime (timer); if (local_result == NULL || result == NULL) return NULL; memcpy (result, local_result, sizeof (struct tm)); return result; } struct tm * p_gmtime_r (const time_t *timer, struct tm *result) { struct tm *local_result; local_result = gmtime (timer); if (local_result == NULL || result == NULL) return NULL; memcpy (result, local_result, sizeof (struct tm)); return result; } int p_inet_pton(int af, const char *src, void *dst) { struct sockaddr_storage sin; void *addr; int sin_len = sizeof(struct sockaddr_storage), addr_len; int error = 0; if (af == AF_INET) { addr = &((struct sockaddr_in *)&sin)->sin_addr; addr_len = sizeof(struct in_addr); } else if (af == AF_INET6) { addr = &((struct sockaddr_in6 *)&sin)->sin6_addr; addr_len = sizeof(struct in6_addr); } else { errno = EAFNOSUPPORT; return -1; } if ((error = WSAStringToAddressA((LPSTR)src, af, NULL, (LPSOCKADDR)&sin, &sin_len)) == 0) { memcpy(dst, addr, addr_len); return 1; } switch(WSAGetLastError()) { case WSAEINVAL: return 0; case WSAEFAULT: errno = ENOSPC; return -1; case WSA_NOT_ENOUGH_MEMORY: errno = ENOMEM; return -1; } errno = EINVAL; return -1; } deps/libgit2-sys-0.3.8/libgit2/src/win32/findfile.c0000664000175000017500000001242212510265101016552 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "path_w32.h" #include "utf-conv.h" #include "path.h" #include "findfile.h" #define REG_MSYSGIT_INSTALL_LOCAL L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Git_is1" #ifndef _WIN64 #define REG_MSYSGIT_INSTALL REG_MSYSGIT_INSTALL_LOCAL #else #define REG_MSYSGIT_INSTALL L"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Git_is1" #endif typedef struct { git_win32_path path; DWORD len; } _findfile_path; static int git_win32__expand_path(_findfile_path *dest, const wchar_t *src) { dest->len = ExpandEnvironmentStringsW(src, dest->path, ARRAY_SIZE(dest->path)); if (!dest->len || dest->len > ARRAY_SIZE(dest->path)) return -1; return 0; } static int win32_path_to_8(git_buf *dest, const wchar_t *src) { git_win32_utf8_path utf8_path; if (git_win32_path_to_utf8(utf8_path, src) < 0) { giterr_set(GITERR_OS, "Unable to convert path to UTF-8"); return -1; } /* Convert backslashes to forward slashes */ git_path_mkposix(utf8_path); return git_buf_sets(dest, utf8_path); } static wchar_t* win32_walkpath(wchar_t *path, wchar_t *buf, size_t buflen) { wchar_t term, *base = path; assert(path && buf && buflen); term = (*path == L'"') ? *path++ : L';'; for (buflen--; *path && *path != term && buflen; buflen--) *buf++ = *path++; *buf = L'\0'; /* reserved a byte via initial subtract */ while (*path == term || *path == L';') path++; return (path != base) ? path : NULL; } static int win32_find_git_in_path(git_buf *buf, const wchar_t *gitexe, const wchar_t *subdir) { wchar_t *env = _wgetenv(L"PATH"), lastch; _findfile_path root; size_t gitexe_len = wcslen(gitexe); if (!env) return -1; while ((env = win32_walkpath(env, root.path, MAX_PATH-1)) && *root.path) { root.len = (DWORD)wcslen(root.path); lastch = root.path[root.len - 1]; /* ensure trailing slash (MAX_PATH-1 to walkpath guarantees space) */ if (lastch != L'/' && lastch != L'\\') { root.path[root.len++] = L'\\'; root.path[root.len] = L'\0'; } if (root.len + gitexe_len >= MAX_PATH) continue; wcscpy(&root.path[root.len], gitexe); if (_waccess(root.path, F_OK) == 0 && root.len > 5) { /* replace "bin\\" or "cmd\\" with subdir */ wcscpy(&root.path[root.len - 4], subdir); win32_path_to_8(buf, root.path); return 0; } } return GIT_ENOTFOUND; } static int win32_find_git_in_registry( git_buf *buf, const HKEY hive, const wchar_t *key, const wchar_t *subdir) { HKEY hKey; int error = GIT_ENOTFOUND; assert(buf); if (!RegOpenKeyExW(hive, key, 0, KEY_READ, &hKey)) { DWORD dwType, cbData; git_win32_path path; /* Ensure that the buffer is big enough to have the suffix attached * after we receive the result. */ cbData = (DWORD)(sizeof(path) - wcslen(subdir) * sizeof(wchar_t)); /* InstallLocation points to the root of the git directory */ if (!RegQueryValueExW(hKey, L"InstallLocation", NULL, &dwType, (LPBYTE)path, &cbData) && dwType == REG_SZ) { /* Append the suffix */ wcscat(path, subdir); /* Convert to UTF-8, with forward slashes, and output the path * to the provided buffer */ if (!win32_path_to_8(buf, path)) error = 0; } RegCloseKey(hKey); } return error; } static int win32_find_existing_dirs( git_buf *out, const wchar_t *tmpl[]) { _findfile_path path16; git_buf buf = GIT_BUF_INIT; git_buf_clear(out); for (; *tmpl != NULL; tmpl++) { if (!git_win32__expand_path(&path16, *tmpl) && path16.path[0] != L'%' && !_waccess(path16.path, F_OK)) { win32_path_to_8(&buf, path16.path); if (buf.size) git_buf_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, buf.ptr); } } git_buf_free(&buf); return (git_buf_oom(out) ? -1 : 0); } int git_win32__find_system_dirs(git_buf *out, const wchar_t *subdir) { git_buf buf = GIT_BUF_INIT; /* directories where git.exe & git.cmd are found */ if (!win32_find_git_in_path(&buf, L"git.exe", subdir) && buf.size) git_buf_set(out, buf.ptr, buf.size); else git_buf_clear(out); if (!win32_find_git_in_path(&buf, L"git.cmd", subdir) && buf.size) git_buf_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, buf.ptr); /* directories where git is installed according to registry */ if (!win32_find_git_in_registry( &buf, HKEY_CURRENT_USER, REG_MSYSGIT_INSTALL_LOCAL, subdir) && buf.size) git_buf_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, buf.ptr); if (!win32_find_git_in_registry( &buf, HKEY_LOCAL_MACHINE, REG_MSYSGIT_INSTALL, subdir) && buf.size) git_buf_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, buf.ptr); git_buf_free(&buf); return (git_buf_oom(out) ? -1 : 0); } int git_win32__find_global_dirs(git_buf *out) { static const wchar_t *global_tmpls[4] = { L"%HOME%\\", L"%HOMEDRIVE%%HOMEPATH%\\", L"%USERPROFILE%\\", NULL, }; return win32_find_existing_dirs(out, global_tmpls); } int git_win32__find_xdg_dirs(git_buf *out) { static const wchar_t *global_tmpls[7] = { L"%XDG_CONFIG_HOME%\\git", L"%APPDATA%\\git", L"%LOCALAPPDATA%\\git", L"%HOME%\\.config\\git", L"%HOMEDRIVE%%HOMEPATH%\\.config\\git", L"%USERPROFILE%\\.config\\git", NULL, }; return win32_find_existing_dirs(out, global_tmpls); } deps/libgit2-sys-0.3.8/libgit2/src/win32/dir.h0000664000175000017500000000207212426525445015575 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_dir_h__ #define INCLUDE_dir_h__ #include "common.h" #include "w32_util.h" struct git__dirent { int d_ino; git_win32_utf8_path d_name; }; typedef struct { HANDLE h; WIN32_FIND_DATAW f; struct git__dirent entry; int first; char dir[GIT_FLEX_ARRAY]; } git__DIR; extern git__DIR *git__opendir(const char *); extern struct git__dirent *git__readdir(git__DIR *); extern int git__readdir_ext( git__DIR *, struct git__dirent *, struct git__dirent **, int *); extern void git__rewinddir(git__DIR *); extern int git__closedir(git__DIR *); # ifndef GIT__WIN32_NO_WRAP_DIR # define dirent git__dirent # define DIR git__DIR # define opendir git__opendir # define readdir git__readdir # define readdir_r(d,e,r) git__readdir_ext((d),(e),(r),NULL) # define rewinddir git__rewinddir # define closedir git__closedir # endif #endif /* INCLUDE_dir_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/win32/mingw-compat.h0000664000175000017500000000121212510265101017374 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_mingw_compat__ #define INCLUDE_mingw_compat__ #if defined(__MINGW32__) #undef stat #if _WIN32_WINNT >= 0x0601 #define stat __stat64 #else #define stat _stati64 #endif #if _WIN32_WINNT < 0x0600 && !defined(__MINGW64_VERSION_MAJOR) #undef MemoryBarrier void __mingworg_MemoryBarrier(void); #define MemoryBarrier __mingworg_MemoryBarrier #define VOLUME_NAME_DOS 0x0 #endif #endif #endif /* INCLUDE_mingw_compat__ */ deps/libgit2-sys-0.3.8/libgit2/src/win32/w32_stack.c0000664000175000017500000001211312572105236016601 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #if defined(GIT_MSVC_CRTDBG) #include "Windows.h" #include "Dbghelp.h" #include "win32/posix.h" #include "w32_stack.h" #include "hash.h" /** * This is supposedly defined in WinBase.h (from Windows.h) but there were linker issues. */ USHORT WINAPI RtlCaptureStackBackTrace(ULONG, ULONG, PVOID*, PULONG); static bool g_win32_stack_initialized = false; static HANDLE g_win32_stack_process = INVALID_HANDLE_VALUE; static git_win32__stack__aux_cb_alloc g_aux_cb_alloc = NULL; static git_win32__stack__aux_cb_lookup g_aux_cb_lookup = NULL; int git_win32__stack__set_aux_cb( git_win32__stack__aux_cb_alloc cb_alloc, git_win32__stack__aux_cb_lookup cb_lookup) { g_aux_cb_alloc = cb_alloc; g_aux_cb_lookup = cb_lookup; return 0; } void git_win32__stack_init(void) { if (!g_win32_stack_initialized) { g_win32_stack_process = GetCurrentProcess(); SymSetOptions(SYMOPT_LOAD_LINES); SymInitialize(g_win32_stack_process, NULL, TRUE); g_win32_stack_initialized = true; } } void git_win32__stack_cleanup(void) { if (g_win32_stack_initialized) { SymCleanup(g_win32_stack_process); g_win32_stack_process = INVALID_HANDLE_VALUE; g_win32_stack_initialized = false; } } int git_win32__stack_capture(git_win32__stack__raw_data *pdata, int skip) { if (!g_win32_stack_initialized) { giterr_set(GITERR_INVALID, "git_win32_stack not initialized."); return GIT_ERROR; } memset(pdata, 0, sizeof(*pdata)); pdata->nr_frames = RtlCaptureStackBackTrace( skip+1, GIT_WIN32__STACK__MAX_FRAMES, pdata->frames, NULL); /* If an "aux" data provider was registered, ask it to capture * whatever data it needs and give us an "aux_id" to it so that * we can refer to it later when reporting. */ if (g_aux_cb_alloc) (g_aux_cb_alloc)(&pdata->aux_id); return 0; } int git_win32__stack_compare( git_win32__stack__raw_data *d1, git_win32__stack__raw_data *d2) { return memcmp(d1, d2, sizeof(*d1)); } int git_win32__stack_format( char *pbuf, int buf_len, const git_win32__stack__raw_data *pdata, const char *prefix, const char *suffix) { #define MY_MAX_FILENAME 255 /* SYMBOL_INFO has char FileName[1] at the end. The docs say to * to malloc it with extra space for your desired max filename. */ struct { SYMBOL_INFO symbol; char extra[MY_MAX_FILENAME + 1]; } s; IMAGEHLP_LINE64 line; int buf_used = 0; unsigned int k; char detail[MY_MAX_FILENAME * 2]; /* filename plus space for function name and formatting */ int detail_len; if (!g_win32_stack_initialized) { giterr_set(GITERR_INVALID, "git_win32_stack not initialized."); return GIT_ERROR; } if (!prefix) prefix = "\t"; if (!suffix) suffix = "\n"; memset(pbuf, 0, buf_len); memset(&s, 0, sizeof(s)); s.symbol.MaxNameLen = MY_MAX_FILENAME; s.symbol.SizeOfStruct = sizeof(SYMBOL_INFO); memset(&line, 0, sizeof(line)); line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); for (k=0; k < pdata->nr_frames; k++) { DWORD64 frame_k = (DWORD64)pdata->frames[k]; DWORD dwUnused; if (SymFromAddr(g_win32_stack_process, frame_k, 0, &s.symbol) && SymGetLineFromAddr64(g_win32_stack_process, frame_k, &dwUnused, &line)) { const char *pslash; const char *pfile; pslash = strrchr(line.FileName, '\\'); pfile = ((pslash) ? (pslash+1) : line.FileName); p_snprintf(detail, sizeof(detail), "%s%s:%d> %s%s", prefix, pfile, line.LineNumber, s.symbol.Name, suffix); } else { /* This happens when we cross into another module. * For example, in CLAR tests, this is typically * the CRT startup code. Just print an unknown * frame and continue. */ p_snprintf(detail, sizeof(detail), "%s??%s", prefix, suffix); } detail_len = strlen(detail); if (buf_len < (buf_used + detail_len + 1)) { /* we don't have room for this frame in the buffer, so just stop. */ break; } memcpy(&pbuf[buf_used], detail, detail_len); buf_used += detail_len; } /* "aux_id" 0 is reserved to mean no aux data. This is needed to handle * allocs that occur before the aux callbacks were registered. */ if (pdata->aux_id > 0) { p_snprintf(detail, sizeof(detail), "%saux_id: %d%s", prefix, pdata->aux_id, suffix); detail_len = strlen(detail); if ((buf_used + detail_len + 1) < buf_len) { memcpy(&pbuf[buf_used], detail, detail_len); buf_used += detail_len; } /* If an "aux" data provider is still registered, ask it to append its detailed * data to the end of ours using the "aux_id" it gave us when this de-duped * item was created. */ if (g_aux_cb_lookup) (g_aux_cb_lookup)(pdata->aux_id, &pbuf[buf_used], (buf_len - buf_used - 1)); } return GIT_OK; } int git_win32__stack( char * pbuf, int buf_len, int skip, const char *prefix, const char *suffix) { git_win32__stack__raw_data data; int error; if ((error = git_win32__stack_capture(&data, skip)) < 0) return error; if ((error = git_win32__stack_format(pbuf, buf_len, &data, prefix, suffix)) < 0) return error; return 0; } #endif deps/libgit2-sys-0.3.8/libgit2/src/win32/utf-conv.c0000664000175000017500000001121012555730137016544 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "utf-conv.h" GIT_INLINE(DWORD) get_wc_flags(void) { static char inited = 0; static DWORD flags; /* Invalid code point check supported on Vista+ only */ if (!inited) { flags = git_has_win32_version(6, 0, 0) ? WC_ERR_INVALID_CHARS : 0; inited = 1; } return flags; } GIT_INLINE(void) git__set_errno(void) { if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) errno = ENAMETOOLONG; else errno = EINVAL; } /** * Converts a UTF-8 string to wide characters. * * @param dest The buffer to receive the wide string. * @param dest_size The size of the buffer, in characters. * @param src The UTF-8 string to convert. * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure */ int git__utf8_to_16(wchar_t *dest, size_t dest_size, const char *src) { int len; /* Length of -1 indicates NULL termination of the input string. Subtract 1 from the result to * turn 0 into -1 (an error code) and to not count the NULL terminator as part of the string's * length. MultiByteToWideChar never returns int's minvalue, so underflow is not possible */ if ((len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, src, -1, dest, (int)dest_size) - 1) < 0) git__set_errno(); return len; } /** * Converts a wide string to UTF-8. * * @param dest The buffer to receive the UTF-8 string. * @param dest_size The size of the buffer, in bytes. * @param src The wide string to convert. * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure */ int git__utf16_to_8(char *dest, size_t dest_size, const wchar_t *src) { int len; /* Length of -1 indicates NULL termination of the input string. Subtract 1 from the result to * turn 0 into -1 (an error code) and to not count the NULL terminator as part of the string's * length. WideCharToMultiByte never returns int's minvalue, so underflow is not possible */ if ((len = WideCharToMultiByte(CP_UTF8, get_wc_flags(), src, -1, dest, (int)dest_size, NULL, NULL) - 1) < 0) git__set_errno(); return len; } /** * Converts a UTF-8 string to wide characters. * Memory is allocated to hold the converted string. * The caller is responsible for freeing the string with git__free. * * @param dest Receives a pointer to the wide string. * @param src The UTF-8 string to convert. * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure */ int git__utf8_to_16_alloc(wchar_t **dest, const char *src) { int utf16_size; *dest = NULL; /* Length of -1 indicates NULL termination of the input string */ utf16_size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, src, -1, NULL, 0); if (!utf16_size) { git__set_errno(); return -1; } if (!(*dest = git__mallocarray(utf16_size, sizeof(wchar_t)))) { errno = ENOMEM; return -1; } utf16_size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, src, -1, *dest, utf16_size); if (!utf16_size) { git__set_errno(); git__free(*dest); *dest = NULL; } /* Subtract 1 from the result to turn 0 into -1 (an error code) and to not count the NULL * terminator as part of the string's length. MultiByteToWideChar never returns int's minvalue, * so underflow is not possible */ return utf16_size - 1; } /** * Converts a wide string to UTF-8. * Memory is allocated to hold the converted string. * The caller is responsible for freeing the string with git__free. * * @param dest Receives a pointer to the UTF-8 string. * @param src The wide string to convert. * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure */ int git__utf16_to_8_alloc(char **dest, const wchar_t *src) { int utf8_size; DWORD dwFlags = get_wc_flags(); *dest = NULL; /* Length of -1 indicates NULL termination of the input string */ utf8_size = WideCharToMultiByte(CP_UTF8, dwFlags, src, -1, NULL, 0, NULL, NULL); if (!utf8_size) { git__set_errno(); return -1; } *dest = git__malloc(utf8_size); if (!*dest) { errno = ENOMEM; return -1; } utf8_size = WideCharToMultiByte(CP_UTF8, dwFlags, src, -1, *dest, utf8_size, NULL, NULL); if (!utf8_size) { git__set_errno(); git__free(*dest); *dest = NULL; } /* Subtract 1 from the result to turn 0 into -1 (an error code) and to not count the NULL * terminator as part of the string's length. MultiByteToWideChar never returns int's minvalue, * so underflow is not possible */ return utf8_size - 1; } deps/libgit2-sys-0.3.8/libgit2/src/win32/map.c0000664000175000017500000000501312510265101015545 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "map.h" #include #ifndef NO_MMAP static DWORD get_page_size(void) { static DWORD page_size; SYSTEM_INFO sys; if (!page_size) { GetSystemInfo(&sys); page_size = sys.dwAllocationGranularity; } return page_size; } int git__page_size(size_t *page_size) { *page_size = get_page_size(); return 0; } int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset) { HANDLE fh = (HANDLE)_get_osfhandle(fd); DWORD page_size = get_page_size(); DWORD fmap_prot = 0; DWORD view_prot = 0; DWORD off_low = 0; DWORD off_hi = 0; git_off_t page_start; git_off_t page_offset; GIT_MMAP_VALIDATE(out, len, prot, flags); out->data = NULL; out->len = 0; out->fmh = NULL; if (fh == INVALID_HANDLE_VALUE) { errno = EBADF; giterr_set(GITERR_OS, "Failed to mmap. Invalid handle value"); return -1; } if (prot & GIT_PROT_WRITE) fmap_prot |= PAGE_READWRITE; else if (prot & GIT_PROT_READ) fmap_prot |= PAGE_READONLY; if (prot & GIT_PROT_WRITE) view_prot |= FILE_MAP_WRITE; if (prot & GIT_PROT_READ) view_prot |= FILE_MAP_READ; page_start = (offset / page_size) * page_size; page_offset = offset - page_start; if (page_offset != 0) { /* offset must be multiple of page size */ errno = EINVAL; giterr_set(GITERR_OS, "Failed to mmap. Offset must be multiple of page size"); return -1; } out->fmh = CreateFileMapping(fh, NULL, fmap_prot, 0, 0, NULL); if (!out->fmh || out->fmh == INVALID_HANDLE_VALUE) { giterr_set(GITERR_OS, "Failed to mmap. Invalid handle value"); out->fmh = NULL; return -1; } assert(sizeof(git_off_t) == 8); off_low = (DWORD)(page_start); off_hi = (DWORD)(page_start >> 32); out->data = MapViewOfFile(out->fmh, view_prot, off_hi, off_low, len); if (!out->data) { giterr_set(GITERR_OS, "Failed to mmap. No data written"); CloseHandle(out->fmh); out->fmh = NULL; return -1; } out->len = len; return 0; } int p_munmap(git_map *map) { int error = 0; assert(map != NULL); if (map->data) { if (!UnmapViewOfFile(map->data)) { giterr_set(GITERR_OS, "Failed to munmap. Could not unmap view of file"); error = -1; } map->data = NULL; } if (map->fmh) { if (!CloseHandle(map->fmh)) { giterr_set(GITERR_OS, "Failed to munmap. Could not close handle"); error = -1; } map->fmh = NULL; } return error; } #endif deps/libgit2-sys-0.3.8/libgit2/src/win32/w32_stack.h0000664000175000017500000001052612572105236016614 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_w32_stack_h__ #define INCLUDE_w32_stack_h__ #if defined(GIT_MSVC_CRTDBG) /** * This type defines a callback to be used to augment a C stacktrace * with "aux" data. This can be used, for example, to allow LibGit2Sharp * (or other interpreted consumer libraries) to give us C# stacktrace * data for the PInvoke. * * This callback will be called during crtdbg-instrumented allocs. * * @param aux_id [out] A returned "aux_id" representing a unique * (de-duped at the C# layer) stacktrace. "aux_id" 0 is reserved * to mean no aux stacktrace data. */ typedef void (*git_win32__stack__aux_cb_alloc)(unsigned int *aux_id); /** * This type defines a callback to be used to augment the output of * a stacktrace. This will be used to request the C# layer format * the C# stacktrace associated with "aux_id" into the provided * buffer. * * This callback will be called during leak reporting. * * @param aux_id The "aux_id" key associated with a stacktrace. * @param aux_msg A buffer where a formatted message should be written. * @param aux_msg_len The size of the buffer. */ typedef void (*git_win32__stack__aux_cb_lookup)(unsigned int aux_id, char *aux_msg, unsigned int aux_msg_len); /** * Register an "aux" data provider to augment our C stacktrace data. * * This can be used, for example, to allow LibGit2Sharp (or other * interpreted consumer libraries) to give us the C# stacktrace of * the PInvoke. * * If you choose to use this feature, it should be registered during * initialization and not changed for the duration of the process. */ GIT_EXTERN(int) git_win32__stack__set_aux_cb( git_win32__stack__aux_cb_alloc cb_alloc, git_win32__stack__aux_cb_lookup cb_lookup); /** * Maximum number of stackframes to record for a * single stacktrace. */ #define GIT_WIN32__STACK__MAX_FRAMES 30 /** * Wrapper containing the raw unprocessed stackframe * data for a single stacktrace and any "aux_id". * * I put the aux_id first so leaks will be sorted by it. * So, for example, if a specific callstack in C# leaks * a repo handle, all of the pointers within the associated * repo pointer will be grouped together. */ typedef struct { unsigned int aux_id; unsigned int nr_frames; void *frames[GIT_WIN32__STACK__MAX_FRAMES]; } git_win32__stack__raw_data; /** * Load symbol table data. This should be done in the primary * thread at startup (under a lock if there are other threads * active). */ void git_win32__stack_init(void); /** * Cleanup symbol table data. This should be done in the * primary thead at shutdown (under a lock if there are other * threads active). */ void git_win32__stack_cleanup(void); /** * Capture raw stack trace data for the current process/thread. * * @param skip Number of initial frames to skip. Pass 0 to * begin with the caller of this routine. Pass 1 to begin * with its caller. And so on. */ int git_win32__stack_capture(git_win32__stack__raw_data *pdata, int skip); /** * Compare 2 raw stacktraces with the usual -1,0,+1 result. * This includes any "aux_id" values in the comparison, so that * our de-dup is also "aux" context relative. */ int git_win32__stack_compare( git_win32__stack__raw_data *d1, git_win32__stack__raw_data *d2); /** * Format raw stacktrace data into buffer WITHOUT using any mallocs. * * @param prefix String written before each frame; defaults to "\t". * @param suffix String written after each frame; defaults to "\n". */ int git_win32__stack_format( char *pbuf, int buf_len, const git_win32__stack__raw_data *pdata, const char *prefix, const char *suffix); /** * Convenience routine to capture and format stacktrace into * a buffer WITHOUT using any mallocs. This is primarily a * wrapper for testing. * * @param skip Number of initial frames to skip. Pass 0 to * begin with the caller of this routine. Pass 1 to begin * with its caller. And so on. * @param prefix String written before each frame; defaults to "\t". * @param suffix String written after each frame; defaults to "\n". */ int git_win32__stack( char * pbuf, int buf_len, int skip, const char *prefix, const char *suffix); #endif /* GIT_MSVC_CRTDBG */ #endif /* INCLUDE_w32_stack_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/win32/w32_buffer.c0000664000175000017500000000240212572105236016745 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "w32_buffer.h" #include "../buffer.h" #include "utf-conv.h" GIT_INLINE(int) handle_wc_error(void) { if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) errno = ENAMETOOLONG; else errno = EINVAL; return -1; } int git_buf_put_w(git_buf *buf, const wchar_t *string_w, size_t len_w) { int utf8_len, utf8_write_len; size_t new_size; if (!len_w) return 0; assert(string_w); /* Measure the string necessary for conversion */ if ((utf8_len = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, string_w, len_w, NULL, 0, NULL, NULL)) == 0) return 0; assert(utf8_len > 0); GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, (size_t)utf8_len); GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); if (git_buf_grow(buf, new_size) < 0) return -1; if ((utf8_write_len = WideCharToMultiByte( CP_UTF8, WC_ERR_INVALID_CHARS, string_w, len_w, &buf->ptr[buf->size], utf8_len, NULL, NULL)) == 0) return handle_wc_error(); assert(utf8_write_len == utf8_len); buf->size += utf8_write_len; buf->ptr[buf->size] = '\0'; return 0; } deps/libgit2-sys-0.3.8/libgit2/src/win32/pthread.h0000664000175000017500000000450312426525445016447 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef GIT_PTHREAD_H #define GIT_PTHREAD_H #include "../common.h" #if defined (_MSC_VER) # define GIT_RESTRICT __restrict #else # define GIT_RESTRICT __restrict__ #endif typedef struct { HANDLE thread; void *(*proc)(void *); void *param; void *result; } git_win32_thread; typedef int pthread_mutexattr_t; typedef int pthread_condattr_t; typedef int pthread_attr_t; typedef int pthread_rwlockattr_t; typedef CRITICAL_SECTION pthread_mutex_t; typedef HANDLE pthread_cond_t; typedef struct { void *Ptr; } GIT_SRWLOCK; typedef struct { union { GIT_SRWLOCK srwl; CRITICAL_SECTION csec; } native; } pthread_rwlock_t; #define PTHREAD_MUTEX_INITIALIZER {(void*)-1} int git_win32__thread_create( git_win32_thread *GIT_RESTRICT, const pthread_attr_t *GIT_RESTRICT, void *(*) (void *), void *GIT_RESTRICT); int git_win32__thread_join( git_win32_thread *, void **); #ifdef GIT_THREADS typedef git_win32_thread git_thread; #define git_thread_create(git_thread_ptr, attr, start_routine, arg) \ git_win32__thread_create(git_thread_ptr, attr, start_routine, arg) #define git_thread_join(git_thread_ptr, status) \ git_win32__thread_join(git_thread_ptr, status) #endif int pthread_mutex_init( pthread_mutex_t *GIT_RESTRICT mutex, const pthread_mutexattr_t *GIT_RESTRICT mutexattr); int pthread_mutex_destroy(pthread_mutex_t *); int pthread_mutex_lock(pthread_mutex_t *); int pthread_mutex_unlock(pthread_mutex_t *); int pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *); int pthread_cond_destroy(pthread_cond_t *); int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *); int pthread_cond_signal(pthread_cond_t *); /* pthread_cond_broadcast is not supported on Win32 yet. */ int pthread_num_processors_np(void); int pthread_rwlock_init( pthread_rwlock_t *GIT_RESTRICT lock, const pthread_rwlockattr_t *GIT_RESTRICT attr); int pthread_rwlock_rdlock(pthread_rwlock_t *); int pthread_rwlock_rdunlock(pthread_rwlock_t *); int pthread_rwlock_wrlock(pthread_rwlock_t *); int pthread_rwlock_wrunlock(pthread_rwlock_t *); int pthread_rwlock_destroy(pthread_rwlock_t *); extern int win32_pthread_initialize(void); #endif deps/libgit2-sys-0.3.8/libgit2/src/win32/w32_buffer.h0000664000175000017500000000074712572105236016764 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_win32_buffer_h__ #define INCLUDE_git_win32_buffer_h__ #include "../buffer.h" /** * Convert a wide character string to UTF-8 and append the results to the * buffer. */ int git_buf_put_w(git_buf *buf, const wchar_t *string_w, size_t len_w); #endif deps/libgit2-sys-0.3.8/libgit2/src/win32/w32_crtdbg_stacktrace.c0000664000175000017500000002365712572105236021164 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #if defined(GIT_MSVC_CRTDBG) #include "w32_stack.h" #include "w32_crtdbg_stacktrace.h" #define CRTDBG_STACKTRACE__UID_LEN (15) /** * The stacktrace of an allocation can be distilled * to a unique id based upon the stackframe pointers * and ignoring any size arguments. We will use these * UIDs as the (char const*) __FILE__ argument we * give to the CRT malloc routines. */ typedef struct { char uid[CRTDBG_STACKTRACE__UID_LEN + 1]; } git_win32__crtdbg_stacktrace__uid; /** * All mallocs with the same stacktrace will be de-duped * and aggregated into this row. */ typedef struct { git_win32__crtdbg_stacktrace__uid uid; /* must be first */ git_win32__stack__raw_data raw_data; unsigned int count_allocs; /* times this alloc signature seen since init */ unsigned int count_allocs_at_last_checkpoint; /* times since last mark */ unsigned int transient_count_leaks; /* sum of leaks */ } git_win32__crtdbg_stacktrace__row; static CRITICAL_SECTION g_crtdbg_stacktrace_cs; /** * CRTDBG memory leak tracking takes a "char const * const file_name" * and stores the pointer in the heap data (instead of allocing a copy * for itself). Normally, this is not a problem, since we usually pass * in __FILE__. But I'm going to lie to it and pass in the address of * the UID in place of the file_name. Also, I do not want to alloc the * stacktrace data (because we are called from inside our alloc routines). * Therefore, I'm creating a very large static pool array to store row * data. This also eliminates the temptation to realloc it (and move the * UID pointers). * * And to efficiently look for duplicates we need an index on the rows * so we can bsearch it. Again, without mallocing. * * If we observe more than MY_ROW_LIMIT unique malloc signatures, we * fall through and use the traditional __FILE__ processing and don't * try to de-dup them. If your testing hits this limit, just increase * it and try again. */ #define MY_ROW_LIMIT (1024 * 1024) static git_win32__crtdbg_stacktrace__row g_cs_rows[MY_ROW_LIMIT]; static git_win32__crtdbg_stacktrace__row *g_cs_index[MY_ROW_LIMIT]; static unsigned int g_cs_end = MY_ROW_LIMIT; static unsigned int g_cs_ins = 0; /* insertion point == unique allocs seen */ static unsigned int g_count_total_allocs = 0; /* number of allocs seen */ static unsigned int g_transient_count_total_leaks = 0; /* number of total leaks */ static unsigned int g_transient_count_dedup_leaks = 0; /* number of unique leaks */ static bool g_limit_reached = false; /* had allocs after we filled row table */ static unsigned int g_checkpoint_id = 0; /* to better label leak checkpoints */ static bool g_transient_leaks_since_mark = false; /* payload for hook */ /** * Compare function for bsearch on g_cs_index table. */ static int row_cmp(const void *v1, const void *v2) { git_win32__stack__raw_data *d1 = (git_win32__stack__raw_data*)v1; git_win32__crtdbg_stacktrace__row *r2 = (git_win32__crtdbg_stacktrace__row *)v2; return (git_win32__stack_compare(d1, &r2->raw_data)); } /** * Unique insert the new data into the row and index tables. * We have to sort by the stackframe data itself, not the uid. */ static git_win32__crtdbg_stacktrace__row * insert_unique( const git_win32__stack__raw_data *pdata) { size_t pos; if (git__bsearch(g_cs_index, g_cs_ins, pdata, row_cmp, &pos) < 0) { /* Append new unique item to row table. */ memcpy(&g_cs_rows[g_cs_ins].raw_data, pdata, sizeof(*pdata)); sprintf(g_cs_rows[g_cs_ins].uid.uid, "##%08lx", g_cs_ins); /* Insert pointer to it into the proper place in the index table. */ if (pos < g_cs_ins) memmove(&g_cs_index[pos+1], &g_cs_index[pos], (g_cs_ins - pos)*sizeof(g_cs_index[0])); g_cs_index[pos] = &g_cs_rows[g_cs_ins]; g_cs_ins++; } g_cs_index[pos]->count_allocs++; return g_cs_index[pos]; } /** * Hook function to receive leak data from the CRT. (This includes * both ":()" data, but also each of the * various headers and fields. * * Scan this for the special "##" UID forms that we substituted * for the "". Map back to the row data and * increment its leak count. * * See https://msdn.microsoft.com/en-us/library/74kabxyx.aspx * * We suppress the actual crtdbg output. */ static int __cdecl report_hook(int nRptType, char *szMsg, int *retVal) { static int hook_result = TRUE; /* FALSE to get stock dump; TRUE to suppress. */ unsigned int pos; *retVal = 0; /* do not invoke debugger */ if ((szMsg[0] != '#') || (szMsg[1] != '#')) return hook_result; if (sscanf(&szMsg[2], "%08lx", &pos) < 1) return hook_result; if (pos >= g_cs_ins) return hook_result; if (g_transient_leaks_since_mark) { if (g_cs_rows[pos].count_allocs == g_cs_rows[pos].count_allocs_at_last_checkpoint) return hook_result; } g_cs_rows[pos].transient_count_leaks++; if (g_cs_rows[pos].transient_count_leaks == 1) g_transient_count_dedup_leaks++; g_transient_count_total_leaks++; return hook_result; } /** * Write leak data to all of the various places we need. * We force the caller to sprintf() the message first * because we want to avoid fprintf() because it allocs. */ static void my_output(const char *buf) { fwrite(buf, strlen(buf), 1, stderr); OutputDebugString(buf); } /** * For each row with leaks, dump a stacktrace for it. */ static void dump_summary(const char *label) { unsigned int k; char buf[10 * 1024]; if (g_transient_count_total_leaks == 0) return; fflush(stdout); fflush(stderr); my_output("\n"); if (g_limit_reached) { sprintf(buf, "LEAK SUMMARY: de-dup row table[%d] filled. Increase MY_ROW_LIMIT.\n", MY_ROW_LIMIT); my_output(buf); } if (!label) label = ""; if (g_transient_leaks_since_mark) { sprintf(buf, "LEAK CHECKPOINT %d: leaks %d unique %d: %s\n", g_checkpoint_id, g_transient_count_total_leaks, g_transient_count_dedup_leaks, label); my_output(buf); } else { sprintf(buf, "LEAK SUMMARY: TOTAL leaks %d de-duped %d: %s\n", g_transient_count_total_leaks, g_transient_count_dedup_leaks, label); my_output(buf); } my_output("\n"); for (k = 0; k < g_cs_ins; k++) { if (g_cs_rows[k].transient_count_leaks > 0) { sprintf(buf, "LEAK: %s leaked %d of %d times:\n", g_cs_rows[k].uid.uid, g_cs_rows[k].transient_count_leaks, g_cs_rows[k].count_allocs); my_output(buf); if (git_win32__stack_format( buf, sizeof(buf), &g_cs_rows[k].raw_data, NULL, NULL) >= 0) { my_output(buf); } my_output("\n"); } } fflush(stderr); } void git_win32__crtdbg_stacktrace_init(void) { InitializeCriticalSection(&g_crtdbg_stacktrace_cs); EnterCriticalSection(&g_crtdbg_stacktrace_cs); _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); LeaveCriticalSection(&g_crtdbg_stacktrace_cs); } int git_win32__crtdbg_stacktrace__dump( git_win32__crtdbg_stacktrace_options opt, const char *label) { _CRT_REPORT_HOOK old; unsigned int k; int r = 0; #define IS_BIT_SET(o,b) (((o) & (b)) != 0) bool b_set_mark = IS_BIT_SET(opt, GIT_WIN32__CRTDBG_STACKTRACE__SET_MARK); bool b_leaks_since_mark = IS_BIT_SET(opt, GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_SINCE_MARK); bool b_leaks_total = IS_BIT_SET(opt, GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_TOTAL); bool b_quiet = IS_BIT_SET(opt, GIT_WIN32__CRTDBG_STACKTRACE__QUIET); if (b_leaks_since_mark && b_leaks_total) { giterr_set(GITERR_INVALID, "Cannot combine LEAKS_SINCE_MARK and LEAKS_TOTAL."); return GIT_ERROR; } if (!b_set_mark && !b_leaks_since_mark && !b_leaks_total) { giterr_set(GITERR_INVALID, "Nothing to do."); return GIT_ERROR; } EnterCriticalSection(&g_crtdbg_stacktrace_cs); if (b_leaks_since_mark || b_leaks_total) { /* All variables with "transient" in the name are per-dump counters * and reset before each dump. This lets us handle checkpoints. */ g_transient_count_total_leaks = 0; g_transient_count_dedup_leaks = 0; for (k = 0; k < g_cs_ins; k++) { g_cs_rows[k].transient_count_leaks = 0; } } g_transient_leaks_since_mark = b_leaks_since_mark; old = _CrtSetReportHook(report_hook); _CrtDumpMemoryLeaks(); _CrtSetReportHook(old); if (b_leaks_since_mark || b_leaks_total) { r = g_transient_count_dedup_leaks; if (!b_quiet) dump_summary(label); } if (b_set_mark) { for (k = 0; k < g_cs_ins; k++) { g_cs_rows[k].count_allocs_at_last_checkpoint = g_cs_rows[k].count_allocs; } g_checkpoint_id++; } LeaveCriticalSection(&g_crtdbg_stacktrace_cs); return r; } void git_win32__crtdbg_stacktrace_cleanup(void) { /* At shutdown/cleanup, dump cummulative leak info * with everything since startup. This might generate * extra noise if the caller has been doing checkpoint * dumps, but it might also eliminate some false * positives for resources previously reported during * checkpoints. */ git_win32__crtdbg_stacktrace__dump( GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_TOTAL, "CLEANUP"); DeleteCriticalSection(&g_crtdbg_stacktrace_cs); } const char *git_win32__crtdbg_stacktrace(int skip, const char *file) { git_win32__stack__raw_data new_data; git_win32__crtdbg_stacktrace__row *row; const char * result = file; if (git_win32__stack_capture(&new_data, skip+1) < 0) return result; EnterCriticalSection(&g_crtdbg_stacktrace_cs); if (g_cs_ins < g_cs_end) { row = insert_unique(&new_data); result = row->uid.uid; } else { g_limit_reached = true; } g_count_total_allocs++; LeaveCriticalSection(&g_crtdbg_stacktrace_cs); return result; } #endif deps/libgit2-sys-0.3.8/libgit2/src/win32/version.h0000664000175000017500000000237412426525445016511 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_win32_version_h__ #define INCLUDE_win32_version_h__ #include GIT_INLINE(int) git_has_win32_version(int major, int minor, int service_pack) { OSVERSIONINFOEX version_test = {0}; DWORD version_test_mask; DWORDLONG version_condition_mask = 0; version_test.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); version_test.dwMajorVersion = major; version_test.dwMinorVersion = minor; version_test.wServicePackMajor = (WORD)service_pack; version_test.wServicePackMinor = 0; version_test_mask = (VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR); VER_SET_CONDITION(version_condition_mask, VER_MAJORVERSION, VER_GREATER_EQUAL); VER_SET_CONDITION(version_condition_mask, VER_MINORVERSION, VER_GREATER_EQUAL); VER_SET_CONDITION(version_condition_mask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); VER_SET_CONDITION(version_condition_mask, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL); if (!VerifyVersionInfo(&version_test, version_test_mask, version_condition_mask)) return 0; return 1; } #endif deps/libgit2-sys-0.3.8/libgit2/src/win32/posix.h0000664000175000017500000000444212555730137016163 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_posix__w32_h__ #define INCLUDE_posix__w32_h__ #include "common.h" #include "../posix.h" #include "path_w32.h" #include "utf-conv.h" #include "dir.h" typedef SOCKET GIT_SOCKET; #define p_lseek(f,n,w) _lseeki64(f, n, w) #define p_fstat(f,b) _fstat64(f, b) extern int p_lstat(const char *file_name, struct stat *buf); extern int p_stat(const char* path, struct stat* buf); extern int p_utimes(const char *filename, const struct timeval times[2]); extern int p_futimes(int fd, const struct timeval times[2]); extern int p_readlink(const char *path, char *buf, size_t bufsiz); extern int p_symlink(const char *old, const char *new); extern int p_link(const char *old, const char *new); extern int p_unlink(const char *path); extern int p_mkdir(const char *path, mode_t mode); extern int p_fsync(int fd); extern char *p_realpath(const char *orig_path, char *buffer); extern int p_recv(GIT_SOCKET socket, void *buffer, size_t length, int flags); extern int p_send(GIT_SOCKET socket, const void *buffer, size_t length, int flags); extern int p_inet_pton(int af, const char* src, void* dst); extern int p_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr); extern int p_snprintf(char *buffer, size_t count, const char *format, ...) GIT_FORMAT_PRINTF(3, 4); extern int p_mkstemp(char *tmp_path); extern int p_chdir(const char* path); extern int p_chmod(const char* path, mode_t mode); extern int p_rmdir(const char* path); extern int p_access(const char* path, mode_t mode); extern int p_ftruncate(int fd, git_off_t size); /* p_lstat is almost but not quite POSIX correct. Specifically, the use of * ENOTDIR is wrong, in that it does not mean precisely that a non-directory * entry was encountered. Making it correct is potentially expensive, * however, so this is a separate version of p_lstat to use when correct * POSIX ENOTDIR semantics is required. */ extern int p_lstat_posixly(const char *filename, struct stat *buf); extern struct tm * p_localtime_r(const time_t *timer, struct tm *result); extern struct tm * p_gmtime_r(const time_t *timer, struct tm *result); #endif deps/libgit2-sys-0.3.8/libgit2/src/win32/findfile.h0000664000175000017500000000073312426525445016601 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_findfile_h__ #define INCLUDE_git_findfile_h__ extern int git_win32__find_system_dirs(git_buf *out, const wchar_t *subpath); extern int git_win32__find_global_dirs(git_buf *out); extern int git_win32__find_xdg_dirs(git_buf *out); #endif deps/libgit2-sys-0.3.8/libgit2/src/win32/reparse.h0000664000175000017500000000273412426525445016465 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_win32_reparse_h__ #define INCLUDE_git_win32_reparse_h__ /* This structure is defined on MSDN at * http://msdn.microsoft.com/en-us/library/windows/hardware/ff552012(v=vs.85).aspx * * It was formerly included in the Windows 2000 SDK and remains defined in * MinGW, so we must define it with a silly name to avoid conflicting. */ typedef struct _GIT_REPARSE_DATA_BUFFER { ULONG ReparseTag; USHORT ReparseDataLength; USHORT Reserved; union { struct { USHORT SubstituteNameOffset; USHORT SubstituteNameLength; USHORT PrintNameOffset; USHORT PrintNameLength; ULONG Flags; WCHAR PathBuffer[1]; } SymbolicLinkReparseBuffer; struct { USHORT SubstituteNameOffset; USHORT SubstituteNameLength; USHORT PrintNameOffset; USHORT PrintNameLength; WCHAR PathBuffer[1]; } MountPointReparseBuffer; struct { UCHAR DataBuffer[1]; } GenericReparseBuffer; }; } GIT_REPARSE_DATA_BUFFER; #define REPARSE_DATA_HEADER_SIZE 8 #define REPARSE_DATA_MOUNTPOINT_HEADER_SIZE 8 #define REPARSE_DATA_UNION_SIZE 12 /* Missing in MinGW */ #ifndef FSCTL_GET_REPARSE_POINT # define FSCTL_GET_REPARSE_POINT 0x000900a8 #endif /* Missing in MinGW */ #ifndef FSCTL_SET_REPARSE_POINT # define FSCTL_SET_REPARSE_POINT 0x000900a4 #endif #endif deps/libgit2-sys-0.3.8/libgit2/src/win32/error.h0000664000175000017500000000054512426525445016153 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_win32_error_h__ #define INCLUDE_git_win32_error_h__ extern char *git_win32_get_error_message(DWORD error_code); #endif deps/libgit2-sys-0.3.8/libgit2/src/win32/msvc-compat.h0000664000175000017500000000115512510265101017231 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_msvc_compat__ #define INCLUDE_msvc_compat__ #if defined(_MSC_VER) /* 64-bit stat information, regardless of USE_32BIT_TIME_T define */ #define stat __stat64 typedef unsigned short mode_t; typedef SSIZE_T ssize_t; #define strcasecmp(s1, s2) _stricmp(s1, s2) #define strncasecmp(s1, s2, c) _strnicmp(s1, s2, c) #endif #define GIT_STDLIB_CALL __cdecl #endif /* INCLUDE_msvc_compat__ */ deps/libgit2-sys-0.3.8/libgit2/src/win32/w32_util.h0000664000175000017500000001037312572105236016464 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_w32_util_h__ #define INCLUDE_w32_util_h__ #include "utf-conv.h" #include "posix.h" #include "path_w32.h" /* #include "common.h" #include "path.h" #include "path_w32.h" #include "utf-conv.h" #include "posix.h" #include "reparse.h" #include "dir.h" */ GIT_INLINE(bool) git_win32__isalpha(wchar_t c) { return ((c >= L'A' && c <= L'Z') || (c >= L'a' && c <= L'z')); } /** * Creates a FindFirstFile(Ex) filter string from a UTF-8 path. * The filter string enumerates all items in the directory. * * @param dest The buffer to receive the filter string. * @param src The UTF-8 path of the directory to enumerate. * @return True if the filter string was created successfully; false otherwise */ bool git_win32__findfirstfile_filter(git_win32_path dest, const char *src); /** * Ensures the given path (file or folder) has the +H (hidden) attribute set * or unset. * * @param path The path that should receive the +H bit. * @param hidden true to set +H, false to unset it * @return 0 on success; -1 on failure */ extern int git_win32__set_hidden(const char *path, bool hidden); /** * Determines if the given file or folder has the hidden attribute set. * @param hidden pointer to store hidden value * @param path The path that should be queried for hiddenness. * @return 0 on success or an error code. */ extern int git_win32__hidden(bool *hidden, const char *path); /** * Removes any trailing backslashes from a path, except in the case of a drive * letter path (C:\, D:\, etc.). This function cannot fail. * * @param path The path which should be trimmed. * @return The length of the modified string (<= the input length) */ size_t git_win32__path_trim_end(wchar_t *str, size_t len); /** * Removes any of the following namespace prefixes from a path, * if found: "\??\", "\\?\", "\\?\UNC\". This function cannot fail. * * @param path The path which should be converted. * @return The length of the modified string (<= the input length) */ size_t git_win32__canonicalize_path(wchar_t *str, size_t len); /** * Converts a FILETIME structure to a time_t. * * @param FILETIME A pointer to a FILETIME * @return A time_t containing the same time */ GIT_INLINE(time_t) git_win32__filetime_to_time_t(const FILETIME *ft) { long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime; winTime -= 116444736000000000LL; /* Windows to Unix Epoch conversion */ winTime /= 10000000; /* Nano to seconds resolution */ return (time_t)winTime; } GIT_INLINE(void) git_win32__timeval_to_filetime( FILETIME *ft, const struct timeval tv) { long long ticks = (tv.tv_sec * 10000000LL) + (tv.tv_usec * 10LL) + 116444736000000000LL; ft->dwHighDateTime = ((ticks >> 32) & 0xffffffffLL); ft->dwLowDateTime = (ticks & 0xffffffffLL); } GIT_INLINE(int) git_win32__file_attribute_to_stat( struct stat *st, const WIN32_FILE_ATTRIBUTE_DATA *attrdata, const wchar_t *path) { mode_t mode = S_IREAD; if (attrdata->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) mode |= S_IFDIR; else mode |= S_IFREG; if ((attrdata->dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0) mode |= S_IWRITE; st->st_ino = 0; st->st_gid = 0; st->st_uid = 0; st->st_nlink = 1; st->st_mode = mode; st->st_size = ((git_off_t)attrdata->nFileSizeHigh << 32) + attrdata->nFileSizeLow; st->st_dev = _getdrive() - 1; st->st_rdev = st->st_dev; st->st_atime = git_win32__filetime_to_time_t(&(attrdata->ftLastAccessTime)); st->st_mtime = git_win32__filetime_to_time_t(&(attrdata->ftLastWriteTime)); st->st_ctime = git_win32__filetime_to_time_t(&(attrdata->ftCreationTime)); if (attrdata->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && path) { git_win32_path target; if (git_win32_path_readlink_w(target, path) >= 0) { st->st_mode = (st->st_mode & ~S_IFMT) | S_IFLNK; /* st_size gets the UTF-8 length of the target name, in bytes, * not counting the NULL terminator */ if ((st->st_size = git__utf16_to_8(NULL, 0, target)) < 0) { giterr_set(GITERR_OS, "Could not convert reparse point name for '%s'", path); return -1; } } } return 0; } #endif deps/libgit2-sys-0.3.8/libgit2/src/win32/path_w32.h0000664000175000017500000000625512555730137016454 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_path_w32_h__ #define INCLUDE_git_path_w32_h__ #include "common.h" #include "vector.h" /* * Provides a large enough buffer to support Windows paths: MAX_PATH is * 260, corresponding to a maximum path length of 259 characters plus a * NULL terminator. Prefixing with "\\?\" adds 4 characters, but if the * original was a UNC path, then we turn "\\server\share" into * "\\?\UNC\server\share". So we replace the first two characters with * 8 characters, a net gain of 6, so the maximum length is MAX_PATH+6. */ #define GIT_WIN_PATH_UTF16 MAX_PATH+6 /* Maximum size of a UTF-8 Win32 path. We remove the "\\?\" or "\\?\UNC\" * prefixes for presentation, bringing us back to 259 (non-NULL) * characters. UTF-8 does have 4-byte sequences, but they are encoded in * UTF-16 using surrogate pairs, which takes up the space of two characters. * Two characters in the range U+0800 -> U+FFFF take up more space in UTF-8 * (6 bytes) than one surrogate pair (4 bytes). */ #define GIT_WIN_PATH_UTF8 (259 * 3 + 1) /* * The length of a Windows "shortname", for 8.3 compatibility. */ #define GIT_WIN_PATH_SHORTNAME 13 /* Win32 path types */ typedef wchar_t git_win32_path[GIT_WIN_PATH_UTF16]; typedef char git_win32_utf8_path[GIT_WIN_PATH_UTF8]; /** * Create a Win32 path (in UCS-2 format) from a UTF-8 string. * * @param dest The buffer to receive the wide string. * @param src The UTF-8 string to convert. * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure */ extern int git_win32_path_from_utf8(git_win32_path dest, const char *src); /** * Canonicalize a Win32 UCS-2 path so that it is suitable for delivery to the * Win32 APIs: remove multiple directory separators, squashing to a single one, * strip trailing directory separators, ensure directory separators are all * canonical (always backslashes, never forward slashes) and process any * directory entries of '.' or '..'. * * This processes the buffer in place. * * @param path The buffer to process * @return The new length of the buffer, in wchar_t's (not counting the NULL terminator) */ extern int git_win32_path_canonicalize(git_win32_path path); /** * Create an internal format (posix-style) UTF-8 path from a Win32 UCS-2 path. * * @param dest The buffer to receive the UTF-8 string. * @param src The wide string to convert. * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure */ extern int git_win32_path_to_utf8(git_win32_utf8_path dest, const wchar_t *src); /** * Get the short name for the terminal path component in the given path. * For example, given "C:\Foo\Bar\Asdf.txt", this will return the short name * for the file "Asdf.txt". * * @param path The given path in UTF-8 * @return The name of the shortname for the given path */ extern char *git_win32_path_8dot3_name(const char *path); extern int git_win32_path_readlink_w(git_win32_path dest, const git_win32_path path); #endif deps/libgit2-sys-0.3.8/libgit2/src/win32/precompiled.c0000664000175000017500000000003112426525445017306 0ustar #include "precompiled.h" deps/libgit2-sys-0.3.8/libgit2/src/win32/pthread.c0000664000175000017500000001360412555730137016443 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "pthread.h" #include "../global.h" #define CLEAN_THREAD_EXIT 0x6F012842 /* The thread procedure stub used to invoke the caller's procedure * and capture the return value for later collection. Windows will * only hold a DWORD, but we need to be able to store an entire * void pointer. This requires the indirection. */ static DWORD WINAPI git_win32__threadproc(LPVOID lpParameter) { git_win32_thread *thread = lpParameter; thread->result = thread->proc(thread->param); git__free_tls_data(); return CLEAN_THREAD_EXIT; } int git_win32__thread_create( git_win32_thread *GIT_RESTRICT thread, const pthread_attr_t *GIT_RESTRICT attr, void *(*start_routine)(void*), void *GIT_RESTRICT arg) { GIT_UNUSED(attr); thread->result = NULL; thread->param = arg; thread->proc = start_routine; thread->thread = CreateThread( NULL, 0, git_win32__threadproc, thread, 0, NULL); return thread->thread ? 0 : -1; } int git_win32__thread_join( git_win32_thread *thread, void **value_ptr) { DWORD exit; if (WaitForSingleObject(thread->thread, INFINITE) != WAIT_OBJECT_0) return -1; if (!GetExitCodeThread(thread->thread, &exit)) { CloseHandle(thread->thread); return -1; } /* Check for the thread having exited uncleanly. If exit was unclean, * then we don't have a return value to give back to the caller. */ if (exit != CLEAN_THREAD_EXIT) { assert(false); thread->result = NULL; } if (value_ptr) *value_ptr = thread->result; CloseHandle(thread->thread); return 0; } int pthread_mutex_init( pthread_mutex_t *GIT_RESTRICT mutex, const pthread_mutexattr_t *GIT_RESTRICT mutexattr) { GIT_UNUSED(mutexattr); InitializeCriticalSection(mutex); return 0; } int pthread_mutex_destroy(pthread_mutex_t *mutex) { DeleteCriticalSection(mutex); return 0; } int pthread_mutex_lock(pthread_mutex_t *mutex) { EnterCriticalSection(mutex); return 0; } int pthread_mutex_unlock(pthread_mutex_t *mutex) { LeaveCriticalSection(mutex); return 0; } int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) { /* We don't support non-default attributes. */ if (attr) return EINVAL; /* This is an auto-reset event. */ *cond = CreateEventW(NULL, FALSE, FALSE, NULL); assert(*cond); /* If we can't create the event, claim that the reason was out-of-memory. * The actual reason can be fetched with GetLastError(). */ return *cond ? 0 : ENOMEM; } int pthread_cond_destroy(pthread_cond_t *cond) { BOOL closed; if (!cond) return EINVAL; closed = CloseHandle(*cond); assert(closed); GIT_UNUSED(closed); *cond = NULL; return 0; } int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { int error; DWORD wait_result; if (!cond || !mutex) return EINVAL; /* The caller must be holding the mutex. */ error = pthread_mutex_unlock(mutex); if (error) return error; wait_result = WaitForSingleObject(*cond, INFINITE); assert(WAIT_OBJECT_0 == wait_result); GIT_UNUSED(wait_result); return pthread_mutex_lock(mutex); } int pthread_cond_signal(pthread_cond_t *cond) { BOOL signaled; if (!cond) return EINVAL; signaled = SetEvent(*cond); assert(signaled); GIT_UNUSED(signaled); return 0; } /* pthread_cond_broadcast is not implemented because doing so with just * Win32 events is quite complicated, and no caller in libgit2 uses it * yet. */ int pthread_num_processors_np(void) { DWORD_PTR p, s; int n = 0; if (GetProcessAffinityMask(GetCurrentProcess(), &p, &s)) for (; p; p >>= 1) n += p&1; return n ? n : 1; } typedef void (WINAPI *win32_srwlock_fn)(GIT_SRWLOCK *); static win32_srwlock_fn win32_srwlock_initialize; static win32_srwlock_fn win32_srwlock_acquire_shared; static win32_srwlock_fn win32_srwlock_release_shared; static win32_srwlock_fn win32_srwlock_acquire_exclusive; static win32_srwlock_fn win32_srwlock_release_exclusive; int pthread_rwlock_init( pthread_rwlock_t *GIT_RESTRICT lock, const pthread_rwlockattr_t *GIT_RESTRICT attr) { GIT_UNUSED(attr); if (win32_srwlock_initialize) win32_srwlock_initialize(&lock->native.srwl); else InitializeCriticalSection(&lock->native.csec); return 0; } int pthread_rwlock_rdlock(pthread_rwlock_t *lock) { if (win32_srwlock_acquire_shared) win32_srwlock_acquire_shared(&lock->native.srwl); else EnterCriticalSection(&lock->native.csec); return 0; } int pthread_rwlock_rdunlock(pthread_rwlock_t *lock) { if (win32_srwlock_release_shared) win32_srwlock_release_shared(&lock->native.srwl); else LeaveCriticalSection(&lock->native.csec); return 0; } int pthread_rwlock_wrlock(pthread_rwlock_t *lock) { if (win32_srwlock_acquire_exclusive) win32_srwlock_acquire_exclusive(&lock->native.srwl); else EnterCriticalSection(&lock->native.csec); return 0; } int pthread_rwlock_wrunlock(pthread_rwlock_t *lock) { if (win32_srwlock_release_exclusive) win32_srwlock_release_exclusive(&lock->native.srwl); else LeaveCriticalSection(&lock->native.csec); return 0; } int pthread_rwlock_destroy(pthread_rwlock_t *lock) { if (!win32_srwlock_initialize) DeleteCriticalSection(&lock->native.csec); git__memzero(lock, sizeof(*lock)); return 0; } int win32_pthread_initialize(void) { HMODULE hModule = GetModuleHandleW(L"kernel32"); if (hModule) { win32_srwlock_initialize = (win32_srwlock_fn) GetProcAddress(hModule, "InitializeSRWLock"); win32_srwlock_acquire_shared = (win32_srwlock_fn) GetProcAddress(hModule, "AcquireSRWLockShared"); win32_srwlock_release_shared = (win32_srwlock_fn) GetProcAddress(hModule, "ReleaseSRWLockShared"); win32_srwlock_acquire_exclusive = (win32_srwlock_fn) GetProcAddress(hModule, "AcquireSRWLockExclusive"); win32_srwlock_release_exclusive = (win32_srwlock_fn) GetProcAddress(hModule, "ReleaseSRWLockExclusive"); } return 0; } deps/libgit2-sys-0.3.8/libgit2/src/win32/error.c0000664000175000017500000000241012426525445016137 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "error.h" #include "utf-conv.h" #ifdef GIT_WINHTTP # include #endif char *git_win32_get_error_message(DWORD error_code) { LPWSTR lpMsgBuf = NULL; HMODULE hModule = NULL; char *utf8_msg = NULL; DWORD dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS; if (!error_code) return NULL; #ifdef GIT_WINHTTP /* Errors raised by WinHTTP are not in the system resource table */ if (error_code >= WINHTTP_ERROR_BASE && error_code <= WINHTTP_ERROR_LAST) hModule = GetModuleHandleW(L"winhttp"); #endif GIT_UNUSED(hModule); if (hModule) dwFlags |= FORMAT_MESSAGE_FROM_HMODULE; else dwFlags |= FORMAT_MESSAGE_FROM_SYSTEM; if (FormatMessageW(dwFlags, hModule, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&lpMsgBuf, 0, NULL)) { /* Convert the message to UTF-8. If this fails, we will * return NULL, which is a condition expected by the caller */ if (git__utf16_to_8_alloc(&utf8_msg, lpMsgBuf) < 0) utf8_msg = NULL; LocalFree(lpMsgBuf); } return utf8_msg; } deps/libgit2-sys-0.3.8/libgit2/src/win32/w32_crtdbg_stacktrace.h0000664000175000017500000000534112572105236021157 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_w32_crtdbg_stacktrace_h__ #define INCLUDE_w32_crtdbg_stacktrace_h__ #if defined(GIT_MSVC_CRTDBG) /** * Initialize our memory leak tracking and de-dup data structures. * This should ONLY be called by git_libgit2_init(). */ void git_win32__crtdbg_stacktrace_init(void); /** * Shutdown our memory leak tracking and dump summary data. * This should ONLY be called by git_libgit2_shutdown(). * * We explicitly call _CrtDumpMemoryLeaks() during here so * that we can compute summary data for the leaks. We print * the stacktrace of each unique leak. * * This cleanup does not happen if the app calls exit() * without calling the libgit2 shutdown code. * * This info we print here is independent of any automatic * reporting during exit() caused by _CRTDBG_LEAK_CHECK_DF. * Set it in your app if you also want traditional reporting. */ void git_win32__crtdbg_stacktrace_cleanup(void); /** * Checkpoint options. */ typedef enum git_win32__crtdbg_stacktrace_options { /** * Set checkpoint marker. */ GIT_WIN32__CRTDBG_STACKTRACE__SET_MARK = (1 << 0), /** * Dump leaks since last checkpoint marker. * May not be combined with __LEAKS_TOTAL. * * Note that this may generate false positives for global TLS * error state and other global caches that aren't cleaned up * until the thread/process terminates. So when using this * around a region of interest, also check the final (at exit) * dump before digging into leaks reported here. */ GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_SINCE_MARK = (1 << 1), /** * Dump leaks since init. May not be combined * with __LEAKS_SINCE_MARK. */ GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_TOTAL = (1 << 2), /** * Suppress printing during dumps. * Just return leak count. */ GIT_WIN32__CRTDBG_STACKTRACE__QUIET = (1 << 3), } git_win32__crtdbg_stacktrace_options; /** * Checkpoint memory state and/or dump unique stack traces of * current memory leaks. * * @return number of unique leaks (relative to requested starting * point) or error. */ GIT_EXTERN(int) git_win32__crtdbg_stacktrace__dump( git_win32__crtdbg_stacktrace_options opt, const char *label); /** * Construct stacktrace and append it to the global buffer. * Return pointer to start of this string. On any error or * lack of buffer space, just return the given file buffer * so it will behave as usual. * * This should ONLY be called by our internal memory allocations * routines. */ const char *git_win32__crtdbg_stacktrace(int skip, const char *file); #endif #endif deps/libgit2-sys-0.3.8/libgit2/src/win32/w32_util.c0000664000175000017500000001046312572105236016457 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "w32_util.h" /** * Creates a FindFirstFile(Ex) filter string from a UTF-8 path. * The filter string enumerates all items in the directory. * * @param dest The buffer to receive the filter string. * @param src The UTF-8 path of the directory to enumerate. * @return True if the filter string was created successfully; false otherwise */ bool git_win32__findfirstfile_filter(git_win32_path dest, const char *src) { static const wchar_t suffix[] = L"\\*"; int len = git_win32_path_from_utf8(dest, src); /* Ensure the path was converted */ if (len < 0) return false; /* Ensure that the path does not end with a trailing slash, * because we're about to add one. Don't rely our trim_end * helper, because we want to remove the backslash even for * drive letter paths, in this case. */ if (len > 0 && (dest[len - 1] == L'/' || dest[len - 1] == L'\\')) { dest[len - 1] = L'\0'; len--; } /* Ensure we have enough room to add the suffix */ if ((size_t)len >= GIT_WIN_PATH_UTF16 - CONST_STRLEN(suffix)) return false; wcscat(dest, suffix); return true; } /** * Ensures the given path (file or folder) has the +H (hidden) attribute set. * * @param path The path which should receive the +H bit. * @return 0 on success; -1 on failure */ int git_win32__set_hidden(const char *path, bool hidden) { git_win32_path buf; DWORD attrs, newattrs; if (git_win32_path_from_utf8(buf, path) < 0) return -1; attrs = GetFileAttributesW(buf); /* Ensure the path exists */ if (attrs == INVALID_FILE_ATTRIBUTES) return -1; if (hidden) newattrs = attrs | FILE_ATTRIBUTE_HIDDEN; else newattrs = attrs & ~FILE_ATTRIBUTE_HIDDEN; if (attrs != newattrs && !SetFileAttributesW(buf, newattrs)) { giterr_set(GITERR_OS, "Failed to %s hidden bit for '%s'", hidden ? "set" : "unset", path); return -1; } return 0; } int git_win32__hidden(bool *out, const char *path) { git_win32_path buf; DWORD attrs; if (git_win32_path_from_utf8(buf, path) < 0) return -1; attrs = GetFileAttributesW(buf); /* Ensure the path exists */ if (attrs == INVALID_FILE_ATTRIBUTES) return -1; *out = (attrs & FILE_ATTRIBUTE_HIDDEN) ? true : false; return 0; } /** * Removes any trailing backslashes from a path, except in the case of a drive * letter path (C:\, D:\, etc.). This function cannot fail. * * @param path The path which should be trimmed. * @return The length of the modified string (<= the input length) */ size_t git_win32__path_trim_end(wchar_t *str, size_t len) { while (1) { if (!len || str[len - 1] != L'\\') break; /* Don't trim backslashes from drive letter paths, which * are 3 characters long and of the form C:\, D:\, etc. */ if (len == 3 && git_win32__isalpha(str[0]) && str[1] == ':') break; len--; } str[len] = L'\0'; return len; } /** * Removes any of the following namespace prefixes from a path, * if found: "\??\", "\\?\", "\\?\UNC\". This function cannot fail. * * @param path The path which should be converted. * @return The length of the modified string (<= the input length) */ size_t git_win32__canonicalize_path(wchar_t *str, size_t len) { static const wchar_t dosdevices_prefix[] = L"\\\?\?\\"; static const wchar_t nt_prefix[] = L"\\\\?\\"; static const wchar_t unc_prefix[] = L"UNC\\"; size_t to_advance = 0; /* "\??\" -- DOS Devices prefix */ if (len >= CONST_STRLEN(dosdevices_prefix) && !wcsncmp(str, dosdevices_prefix, CONST_STRLEN(dosdevices_prefix))) { to_advance += CONST_STRLEN(dosdevices_prefix); len -= CONST_STRLEN(dosdevices_prefix); } /* "\\?\" -- NT namespace prefix */ else if (len >= CONST_STRLEN(nt_prefix) && !wcsncmp(str, nt_prefix, CONST_STRLEN(nt_prefix))) { to_advance += CONST_STRLEN(nt_prefix); len -= CONST_STRLEN(nt_prefix); } /* "\??\UNC\", "\\?\UNC\" -- UNC prefix */ if (to_advance && len >= CONST_STRLEN(unc_prefix) && !wcsncmp(str + to_advance, unc_prefix, CONST_STRLEN(unc_prefix))) { to_advance += CONST_STRLEN(unc_prefix); len -= CONST_STRLEN(unc_prefix); } if (to_advance) { memmove(str, str + to_advance, len * sizeof(wchar_t)); str[len] = L'\0'; } return git_win32__path_trim_end(str, len); } deps/libgit2-sys-0.3.8/libgit2/src/win32/git2.rc0000664000175000017500000000252212510265101016021 0ustar #include #include "../../include/git2/version.h" #ifndef LIBGIT2_FILENAME # define LIBGIT2_FILENAME "git2" #endif #ifndef LIBGIT2_COMMENTS # define LIBGIT2_COMMENTS "For more information visit http://libgit2.github.com/" #endif VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE FILEVERSION LIBGIT2_VER_MAJOR,LIBGIT2_VER_MINOR,LIBGIT2_VER_REVISION,LIBGIT2_VER_PATCH PRODUCTVERSION LIBGIT2_VER_MAJOR,LIBGIT2_VER_MINOR,LIBGIT2_VER_REVISION,LIBGIT2_VER_PATCH FILEFLAGSMASK VS_FFI_FILEFLAGSMASK #ifdef _DEBUG FILEFLAGS VS_FF_DEBUG #else FILEFLAGS 0 #endif FILEOS VOS_NT_WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE VFT2_UNKNOWN BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904E4" //language ID = U.S. English, char set = Windows, Multilingual BEGIN VALUE "FileDescription", "libgit2 - the Git linkable library\0" VALUE "FileVersion", LIBGIT2_VERSION "\0" VALUE "InternalName", LIBGIT2_FILENAME ".dll\0" VALUE "LegalCopyright", "Copyright (C) the libgit2 contributors. All rights reserved.\0" VALUE "OriginalFilename", LIBGIT2_FILENAME ".dll\0" VALUE "ProductName", "libgit2\0" VALUE "ProductVersion", LIBGIT2_VERSION "\0" VALUE "Comments", LIBGIT2_COMMENTS "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x0409, 1252 END END deps/libgit2-sys-0.3.8/libgit2/src/win32/utf-conv.h0000664000175000017500000000400612555730137016556 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_utfconv_h__ #define INCLUDE_git_utfconv_h__ #include #include "common.h" #ifndef WC_ERR_INVALID_CHARS # define WC_ERR_INVALID_CHARS 0x80 #endif /** * Converts a UTF-8 string to wide characters. * * @param dest The buffer to receive the wide string. * @param dest_size The size of the buffer, in characters. * @param src The UTF-8 string to convert. * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure */ int git__utf8_to_16(wchar_t *dest, size_t dest_size, const char *src); /** * Converts a wide string to UTF-8. * * @param dest The buffer to receive the UTF-8 string. * @param dest_size The size of the buffer, in bytes. * @param src The wide string to convert. * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure */ int git__utf16_to_8(char *dest, size_t dest_size, const wchar_t *src); /** * Converts a UTF-8 string to wide characters. * Memory is allocated to hold the converted string. * The caller is responsible for freeing the string with git__free. * * @param dest Receives a pointer to the wide string. * @param src The UTF-8 string to convert. * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure */ int git__utf8_to_16_alloc(wchar_t **dest, const char *src); /** * Converts a wide string to UTF-8. * Memory is allocated to hold the converted string. * The caller is responsible for freeing the string with git__free. * * @param dest Receives a pointer to the UTF-8 string. * @param src The wide string to convert. * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure */ int git__utf16_to_8_alloc(char **dest, const wchar_t *src); #endif deps/libgit2-sys-0.3.8/libgit2/src/clone.h0000664000175000017500000000055012426525445015154 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_clone_h__ #define INCLUDE_clone_h__ extern int git_clone__should_clone_local(const char *url, git_clone_local_t local); #endif deps/libgit2-sys-0.3.8/libgit2/src/reflog.h0000664000175000017500000000144212426525445015333 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_reflog_h__ #define INCLUDE_reflog_h__ #include "common.h" #include "git2/reflog.h" #include "vector.h" #define GIT_REFLOG_DIR "logs/" #define GIT_REFLOG_DIR_MODE 0777 #define GIT_REFLOG_FILE_MODE 0666 #define GIT_REFLOG_SIZE_MIN (2*GIT_OID_HEXSZ+2+17) struct git_reflog_entry { git_oid oid_old; git_oid oid_cur; git_signature *committer; char *msg; }; struct git_reflog { git_refdb *db; char *ref_name; git_vector entries; }; GIT_INLINE(size_t) reflog_inverse_index(size_t idx, size_t total) { return (total - 1) - idx; } #endif /* INCLUDE_reflog_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/attr_file.c0000664000175000017500000005224612555730137016030 0ustar #include "common.h" #include "repository.h" #include "filebuf.h" #include "attr_file.h" #include "attrcache.h" #include "git2/blob.h" #include "git2/tree.h" #include "index.h" #include static void attr_file_free(git_attr_file *file) { bool unlock = !git_mutex_lock(&file->lock); git_attr_file__clear_rules(file, false); git_pool_clear(&file->pool); if (unlock) git_mutex_unlock(&file->lock); git_mutex_free(&file->lock); git__memzero(file, sizeof(*file)); git__free(file); } int git_attr_file__new( git_attr_file **out, git_attr_file_entry *entry, git_attr_file_source source) { git_attr_file *attrs = git__calloc(1, sizeof(git_attr_file)); GITERR_CHECK_ALLOC(attrs); if (git_mutex_init(&attrs->lock) < 0) { giterr_set(GITERR_OS, "Failed to initialize lock"); git__free(attrs); return -1; } if (git_pool_init(&attrs->pool, 1, 0) < 0) { attr_file_free(attrs); return -1; } GIT_REFCOUNT_INC(attrs); attrs->entry = entry; attrs->source = source; *out = attrs; return 0; } int git_attr_file__clear_rules(git_attr_file *file, bool need_lock) { unsigned int i; git_attr_rule *rule; if (need_lock && git_mutex_lock(&file->lock) < 0) { giterr_set(GITERR_OS, "Failed to lock attribute file"); return -1; } git_vector_foreach(&file->rules, i, rule) git_attr_rule__free(rule); git_vector_free(&file->rules); if (need_lock) git_mutex_unlock(&file->lock); return 0; } void git_attr_file__free(git_attr_file *file) { if (!file) return; GIT_REFCOUNT_DEC(file, attr_file_free); } static int attr_file_oid_from_index( git_oid *oid, git_repository *repo, const char *path) { int error; git_index *idx; size_t pos; const git_index_entry *entry; if ((error = git_repository_index__weakptr(&idx, repo)) < 0 || (error = git_index__find_pos(&pos, idx, path, 0, 0)) < 0) return error; if (!(entry = git_index_get_byindex(idx, pos))) return GIT_ENOTFOUND; *oid = entry->id; return 0; } int git_attr_file__load( git_attr_file **out, git_repository *repo, git_attr_session *attr_session, git_attr_file_entry *entry, git_attr_file_source source, git_attr_file_parser parser) { int error = 0; git_blob *blob = NULL; git_buf content = GIT_BUF_INIT; git_attr_file *file; struct stat st; bool nonexistent = false; *out = NULL; switch (source) { case GIT_ATTR_FILE__IN_MEMORY: /* in-memory attribute file doesn't need data */ break; case GIT_ATTR_FILE__FROM_INDEX: { git_oid id; if ((error = attr_file_oid_from_index(&id, repo, entry->path)) < 0 || (error = git_blob_lookup(&blob, repo, &id)) < 0) return error; /* Do not assume that data straight from the ODB is NULL-terminated; * copy the contents of a file to a buffer to work on */ git_buf_put(&content, git_blob_rawcontent(blob), git_blob_rawsize(blob)); break; } case GIT_ATTR_FILE__FROM_FILE: { int fd; /* For open or read errors, pretend that we got ENOTFOUND. */ /* TODO: issue warning when warning API is available */ if (p_stat(entry->fullpath, &st) < 0 || S_ISDIR(st.st_mode) || (fd = git_futils_open_ro(entry->fullpath)) < 0 || (error = git_futils_readbuffer_fd(&content, fd, (size_t)st.st_size)) < 0) nonexistent = true; else p_close(fd); break; } default: giterr_set(GITERR_INVALID, "Unknown file source %d", source); return -1; } if ((error = git_attr_file__new(&file, entry, source)) < 0) goto cleanup; /* store the key of the attr_reader; don't bother with cache * invalidation during the same attr reader session. */ if (attr_session) file->session_key = attr_session->key; if (parser && (error = parser(repo, file, git_buf_cstr(&content))) < 0) { git_attr_file__free(file); goto cleanup; } /* write cache breakers */ if (nonexistent) file->nonexistent = 1; else if (source == GIT_ATTR_FILE__FROM_INDEX) git_oid_cpy(&file->cache_data.oid, git_blob_id(blob)); else if (source == GIT_ATTR_FILE__FROM_FILE) git_futils_filestamp_set_from_stat(&file->cache_data.stamp, &st); /* else always cacheable */ *out = file; cleanup: git_blob_free(blob); git_buf_free(&content); return error; } int git_attr_file__out_of_date( git_repository *repo, git_attr_session *attr_session, git_attr_file *file) { if (!file) return 1; /* we are never out of date if we just created this data in the same * attr_session; otherwise, nonexistent files must be invalidated */ if (attr_session && attr_session->key == file->session_key) return 0; else if (file->nonexistent) return 1; switch (file->source) { case GIT_ATTR_FILE__IN_MEMORY: return 0; case GIT_ATTR_FILE__FROM_FILE: return git_futils_filestamp_check( &file->cache_data.stamp, file->entry->fullpath); case GIT_ATTR_FILE__FROM_INDEX: { int error; git_oid id; if ((error = attr_file_oid_from_index( &id, repo, file->entry->path)) < 0) return error; return (git_oid__cmp(&file->cache_data.oid, &id) != 0); } default: giterr_set(GITERR_INVALID, "Invalid file type %d", file->source); return -1; } } static int sort_by_hash_and_name(const void *a_raw, const void *b_raw); static void git_attr_rule__clear(git_attr_rule *rule); static bool parse_optimized_patterns( git_attr_fnmatch *spec, git_pool *pool, const char *pattern); int git_attr_file__parse_buffer( git_repository *repo, git_attr_file *attrs, const char *data) { int error = 0; const char *scan = data, *context = NULL; git_attr_rule *rule = NULL; /* if subdir file path, convert context for file paths */ if (attrs->entry && git_path_root(attrs->entry->path) < 0 && !git__suffixcmp(attrs->entry->path, "/" GIT_ATTR_FILE)) context = attrs->entry->path; if (git_mutex_lock(&attrs->lock) < 0) { giterr_set(GITERR_OS, "Failed to lock attribute file"); return -1; } while (!error && *scan) { /* allocate rule if needed */ if (!rule && !(rule = git__calloc(1, sizeof(*rule)))) { error = -1; break; } rule->match.flags = GIT_ATTR_FNMATCH_ALLOWNEG | GIT_ATTR_FNMATCH_ALLOWMACRO; /* parse the next "pattern attr attr attr" line */ if (!(error = git_attr_fnmatch__parse( &rule->match, &attrs->pool, context, &scan)) && !(error = git_attr_assignment__parse( repo, &attrs->pool, &rule->assigns, &scan))) { if (rule->match.flags & GIT_ATTR_FNMATCH_MACRO) /* TODO: warning if macro found in file below repo root */ error = git_attr_cache__insert_macro(repo, rule); else error = git_vector_insert(&attrs->rules, rule); } /* if the rule wasn't a pattern, on to the next */ if (error < 0) { git_attr_rule__clear(rule); /* reset rule contents */ if (error == GIT_ENOTFOUND) error = 0; } else { rule = NULL; /* vector now "owns" the rule */ } } git_mutex_unlock(&attrs->lock); git_attr_rule__free(rule); return error; } uint32_t git_attr_file__name_hash(const char *name) { uint32_t h = 5381; int c; assert(name); while ((c = (int)*name++) != 0) h = ((h << 5) + h) + c; return h; } int git_attr_file__lookup_one( git_attr_file *file, git_attr_path *path, const char *attr, const char **value) { size_t i; git_attr_name name; git_attr_rule *rule; *value = NULL; name.name = attr; name.name_hash = git_attr_file__name_hash(attr); git_attr_file__foreach_matching_rule(file, path, i, rule) { size_t pos; if (!git_vector_bsearch(&pos, &rule->assigns, &name)) { *value = ((git_attr_assignment *) git_vector_get(&rule->assigns, pos))->value; break; } } return 0; } int git_attr_file__load_standalone(git_attr_file **out, const char *path) { int error; git_attr_file *file; git_buf content = GIT_BUF_INIT; error = git_attr_file__new(&file, NULL, GIT_ATTR_FILE__FROM_FILE); if (error < 0) return error; error = git_attr_cache__alloc_file_entry( &file->entry, NULL, path, &file->pool); if (error < 0) { git_attr_file__free(file); return error; } /* because the cache entry is allocated from the file's own pool, we * don't have to free it - freeing file+pool will free cache entry, too. */ if (!(error = git_futils_readbuffer(&content, path))) { error = git_attr_file__parse_buffer(NULL, file, content.ptr); git_buf_free(&content); } if (error < 0) git_attr_file__free(file); else *out = file; return error; } bool git_attr_fnmatch__match( git_attr_fnmatch *match, git_attr_path *path) { const char *relpath = path->path; const char *filename; int flags = 0; /* * If the rule was generated in a subdirectory, we must only * use it for paths inside that directory. We can thus return * a non-match if the prefixes don't match. */ if (match->containing_dir) { if (match->flags & GIT_ATTR_FNMATCH_ICASE) { if (git__strncasecmp(path->path, match->containing_dir, match->containing_dir_length)) return 0; } else { if (git__prefixcmp(path->path, match->containing_dir)) return 0; } relpath += match->containing_dir_length; } if (match->flags & GIT_ATTR_FNMATCH_ICASE) flags |= FNM_CASEFOLD; if (match->flags & GIT_ATTR_FNMATCH_LEADINGDIR) flags |= FNM_LEADING_DIR; if (match->flags & GIT_ATTR_FNMATCH_FULLPATH) { filename = relpath; flags |= FNM_PATHNAME; } else { filename = path->basename; if (path->is_dir) flags |= FNM_LEADING_DIR; } if ((match->flags & GIT_ATTR_FNMATCH_DIRECTORY) && !path->is_dir) { bool samename; /* for attribute checks or root ignore checks, fail match */ if (!(match->flags & GIT_ATTR_FNMATCH_IGNORE) || path->basename == path->path) return false; flags |= FNM_LEADING_DIR; /* fail match if this is a file with same name as ignored folder */ samename = (match->flags & GIT_ATTR_FNMATCH_ICASE) ? !strcasecmp(match->pattern, relpath) : !strcmp(match->pattern, relpath); if (samename) return false; return (p_fnmatch(match->pattern, relpath, flags) != FNM_NOMATCH); } /* if path is a directory prefix of a negated pattern, then match */ if ((match->flags & GIT_ATTR_FNMATCH_NEGATIVE) && path->is_dir) { size_t pathlen = strlen(relpath); bool prefixed = (pathlen <= match->length) && ((match->flags & GIT_ATTR_FNMATCH_ICASE) ? !strncasecmp(match->pattern, relpath, pathlen) : !strncmp(match->pattern, relpath, pathlen)); if (prefixed && git_path_at_end_of_segment(&match->pattern[pathlen])) return true; } return (p_fnmatch(match->pattern, filename, flags) != FNM_NOMATCH); } bool git_attr_rule__match( git_attr_rule *rule, git_attr_path *path) { bool matched = git_attr_fnmatch__match(&rule->match, path); if (rule->match.flags & GIT_ATTR_FNMATCH_NEGATIVE) matched = !matched; return matched; } git_attr_assignment *git_attr_rule__lookup_assignment( git_attr_rule *rule, const char *name) { size_t pos; git_attr_name key; key.name = name; key.name_hash = git_attr_file__name_hash(name); if (git_vector_bsearch(&pos, &rule->assigns, &key)) return NULL; return git_vector_get(&rule->assigns, pos); } int git_attr_path__init( git_attr_path *info, const char *path, const char *base, git_dir_flag dir_flag) { ssize_t root; /* build full path as best we can */ git_buf_init(&info->full, 0); if (git_path_join_unrooted(&info->full, path, base, &root) < 0) return -1; info->path = info->full.ptr + root; /* remove trailing slashes */ while (info->full.size > 0) { if (info->full.ptr[info->full.size - 1] != '/') break; info->full.size--; } info->full.ptr[info->full.size] = '\0'; /* skip leading slashes in path */ while (*info->path == '/') info->path++; /* find trailing basename component */ info->basename = strrchr(info->path, '/'); if (info->basename) info->basename++; if (!info->basename || !*info->basename) info->basename = info->path; switch (dir_flag) { case GIT_DIR_FLAG_FALSE: info->is_dir = 0; break; case GIT_DIR_FLAG_TRUE: info->is_dir = 1; break; case GIT_DIR_FLAG_UNKNOWN: default: info->is_dir = (int)git_path_isdir(info->full.ptr); break; } return 0; } void git_attr_path__free(git_attr_path *info) { git_buf_free(&info->full); info->path = NULL; info->basename = NULL; } /* * From gitattributes(5): * * Patterns have the following format: * * - A blank line matches no files, so it can serve as a separator for * readability. * * - A line starting with # serves as a comment. * * - An optional prefix ! which negates the pattern; any matching file * excluded by a previous pattern will become included again. If a negated * pattern matches, this will override lower precedence patterns sources. * * - If the pattern ends with a slash, it is removed for the purpose of the * following description, but it would only find a match with a directory. In * other words, foo/ will match a directory foo and paths underneath it, but * will not match a regular file or a symbolic link foo (this is consistent * with the way how pathspec works in general in git). * * - If the pattern does not contain a slash /, git treats it as a shell glob * pattern and checks for a match against the pathname without leading * directories. * * - Otherwise, git treats the pattern as a shell glob suitable for consumption * by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will * not match a / in the pathname. For example, "Documentation/\*.html" matches * "Documentation/git.html" but not "Documentation/ppc/ppc.html". A leading * slash matches the beginning of the pathname; for example, "/\*.c" matches * "cat-file.c" but not "mozilla-sha1/sha1.c". */ /* * This will return 0 if the spec was filled out, * GIT_ENOTFOUND if the fnmatch does not require matching, or * another error code there was an actual problem. */ int git_attr_fnmatch__parse( git_attr_fnmatch *spec, git_pool *pool, const char *context, const char **base) { const char *pattern, *scan; int slash_count, allow_space; assert(spec && base && *base); if (parse_optimized_patterns(spec, pool, *base)) return 0; spec->flags = (spec->flags & GIT_ATTR_FNMATCH__INCOMING); allow_space = ((spec->flags & GIT_ATTR_FNMATCH_ALLOWSPACE) != 0); pattern = *base; while (git__isspace(*pattern)) pattern++; if (!*pattern || *pattern == '#') { *base = git__next_line(pattern); return GIT_ENOTFOUND; } if (*pattern == '[' && (spec->flags & GIT_ATTR_FNMATCH_ALLOWMACRO) != 0) { if (strncmp(pattern, "[attr]", 6) == 0) { spec->flags = spec->flags | GIT_ATTR_FNMATCH_MACRO; pattern += 6; } /* else a character range like [a-e]* which is accepted */ } if (*pattern == '!' && (spec->flags & GIT_ATTR_FNMATCH_ALLOWNEG) != 0) { spec->flags = spec->flags | GIT_ATTR_FNMATCH_NEGATIVE | GIT_ATTR_FNMATCH_LEADINGDIR; pattern++; } slash_count = 0; for (scan = pattern; *scan != '\0'; ++scan) { /* scan until (non-escaped) white space */ if (git__isspace(*scan) && *(scan - 1) != '\\') { if (!allow_space || (*scan != ' ' && *scan != '\t' && *scan != '\r')) break; } if (*scan == '/') { spec->flags = spec->flags | GIT_ATTR_FNMATCH_FULLPATH; slash_count++; if (pattern == scan) pattern++; } /* remember if we see an unescaped wildcard in pattern */ else if (git__iswildcard(*scan) && (scan == pattern || (*(scan - 1) != '\\'))) spec->flags = spec->flags | GIT_ATTR_FNMATCH_HASWILD; } *base = scan; if ((spec->length = scan - pattern) == 0) return GIT_ENOTFOUND; /* * Remove one trailing \r in case this is a CRLF delimited * file, in the case of Icon\r\r\n, we still leave the first * \r there to match against. */ if (pattern[spec->length - 1] == '\r') if (--spec->length == 0) return GIT_ENOTFOUND; if (pattern[spec->length - 1] == '/') { spec->length--; spec->flags = spec->flags | GIT_ATTR_FNMATCH_DIRECTORY; if (--slash_count <= 0) spec->flags = spec->flags & ~GIT_ATTR_FNMATCH_FULLPATH; } if ((spec->flags & GIT_ATTR_FNMATCH_NOLEADINGDIR) == 0 && spec->length >= 2 && pattern[spec->length - 1] == '*' && pattern[spec->length - 2] == '/') { spec->length -= 2; spec->flags = spec->flags | GIT_ATTR_FNMATCH_LEADINGDIR; /* leave FULLPATH match on, however */ } if (context) { char *slash = strrchr(context, '/'); size_t len; if (slash) { /* include the slash for easier matching */ len = slash - context + 1; spec->containing_dir = git_pool_strndup(pool, context, len); spec->containing_dir_length = len; } } spec->pattern = git_pool_strndup(pool, pattern, spec->length); if (!spec->pattern) { *base = git__next_line(pattern); return -1; } else { /* strip '\' that might have be used for internal whitespace */ spec->length = git__unescape(spec->pattern); /* TODO: convert remaining '\' into '/' for POSIX ??? */ } return 0; } static bool parse_optimized_patterns( git_attr_fnmatch *spec, git_pool *pool, const char *pattern) { if (!pattern[1] && (pattern[0] == '*' || pattern[0] == '.')) { spec->flags = GIT_ATTR_FNMATCH_MATCH_ALL; spec->pattern = git_pool_strndup(pool, pattern, 1); spec->length = 1; return true; } return false; } static int sort_by_hash_and_name(const void *a_raw, const void *b_raw) { const git_attr_name *a = a_raw; const git_attr_name *b = b_raw; if (b->name_hash < a->name_hash) return 1; else if (b->name_hash > a->name_hash) return -1; else return strcmp(b->name, a->name); } static void git_attr_assignment__free(git_attr_assignment *assign) { /* name and value are stored in a git_pool associated with the * git_attr_file, so they do not need to be freed here */ assign->name = NULL; assign->value = NULL; git__free(assign); } static int merge_assignments(void **old_raw, void *new_raw) { git_attr_assignment **old = (git_attr_assignment **)old_raw; git_attr_assignment *new = (git_attr_assignment *)new_raw; GIT_REFCOUNT_DEC(*old, git_attr_assignment__free); *old = new; return GIT_EEXISTS; } int git_attr_assignment__parse( git_repository *repo, git_pool *pool, git_vector *assigns, const char **base) { int error; const char *scan = *base; git_attr_assignment *assign = NULL; assert(assigns && !assigns->length); git_vector_set_cmp(assigns, sort_by_hash_and_name); while (*scan && *scan != '\n') { const char *name_start, *value_start; /* skip leading blanks */ while (git__isspace(*scan) && *scan != '\n') scan++; /* allocate assign if needed */ if (!assign) { assign = git__calloc(1, sizeof(git_attr_assignment)); GITERR_CHECK_ALLOC(assign); GIT_REFCOUNT_INC(assign); } assign->name_hash = 5381; assign->value = git_attr__true; /* look for magic name prefixes */ if (*scan == '-') { assign->value = git_attr__false; scan++; } else if (*scan == '!') { assign->value = git_attr__unset; /* explicit unspecified state */ scan++; } else if (*scan == '#') /* comment rest of line */ break; /* find the name */ name_start = scan; while (*scan && !git__isspace(*scan) && *scan != '=') { assign->name_hash = ((assign->name_hash << 5) + assign->name_hash) + *scan; scan++; } if (scan == name_start) { /* must have found lone prefix (" - ") or leading = ("=foo") * or end of buffer -- advance until whitespace and continue */ while (*scan && !git__isspace(*scan)) scan++; continue; } /* allocate permanent storage for name */ assign->name = git_pool_strndup(pool, name_start, scan - name_start); GITERR_CHECK_ALLOC(assign->name); /* if there is an equals sign, find the value */ if (*scan == '=') { for (value_start = ++scan; *scan && !git__isspace(*scan); ++scan); /* if we found a value, allocate permanent storage for it */ if (scan > value_start) { assign->value = git_pool_strndup(pool, value_start, scan - value_start); GITERR_CHECK_ALLOC(assign->value); } } /* expand macros (if given a repo with a macro cache) */ if (repo != NULL && assign->value == git_attr__true) { git_attr_rule *macro = git_attr_cache__lookup_macro(repo, assign->name); if (macro != NULL) { unsigned int i; git_attr_assignment *massign; git_vector_foreach(¯o->assigns, i, massign) { GIT_REFCOUNT_INC(massign); error = git_vector_insert_sorted( assigns, massign, &merge_assignments); if (error < 0 && error != GIT_EEXISTS) { git_attr_assignment__free(assign); return error; } } } } /* insert allocated assign into vector */ error = git_vector_insert_sorted(assigns, assign, &merge_assignments); if (error < 0 && error != GIT_EEXISTS) return error; /* clear assign since it is now "owned" by the vector */ assign = NULL; } if (assign != NULL) git_attr_assignment__free(assign); *base = git__next_line(scan); return (assigns->length == 0) ? GIT_ENOTFOUND : 0; } static void git_attr_rule__clear(git_attr_rule *rule) { unsigned int i; git_attr_assignment *assign; if (!rule) return; if (!(rule->match.flags & GIT_ATTR_FNMATCH_IGNORE)) { git_vector_foreach(&rule->assigns, i, assign) GIT_REFCOUNT_DEC(assign, git_attr_assignment__free); git_vector_free(&rule->assigns); } /* match.pattern is stored in a git_pool, so no need to free */ rule->match.pattern = NULL; rule->match.length = 0; } void git_attr_rule__free(git_attr_rule *rule) { git_attr_rule__clear(rule); git__free(rule); } int git_attr_session__init(git_attr_session *session, git_repository *repo) { assert(repo); session->key = git_atomic_inc(&repo->attr_session_key); return 0; } void git_attr_session__free(git_attr_session *session) { if (!session) return; git_buf_free(&session->sysdir); git_buf_free(&session->tmp); memset(session, 0, sizeof(git_attr_session)); } deps/libgit2-sys-0.3.8/libgit2/src/common.h0000664000175000017500000001366112610310643015336 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_common_h__ #define INCLUDE_common_h__ #include "git2/common.h" #include "cc-compat.h" /** Declare a function as always inlined. */ #if defined(_MSC_VER) # define GIT_INLINE(type) static __inline type #else # define GIT_INLINE(type) static inline type #endif /** Support for gcc/clang __has_builtin intrinsic */ #ifndef __has_builtin # define __has_builtin(x) 0 #endif #include #include #include #include #include #include #include #include #ifdef GIT_WIN32 # include # include # include # include # include # include "win32/msvc-compat.h" # include "win32/mingw-compat.h" # include "win32/error.h" # include "win32/version.h" # ifdef GIT_THREADS # include "win32/pthread.h" # endif # if defined(GIT_MSVC_CRTDBG) # include "win32/w32_stack.h" # include "win32/w32_crtdbg_stacktrace.h" # endif #else # include # include # ifdef GIT_THREADS # include # include # endif #define GIT_STDLIB_CALL # include #endif #include "git2/types.h" #include "git2/errors.h" #include "thread-utils.h" #include "integer.h" #include #define DEFAULT_BUFSIZE 65536 #define FILEIO_BUFSIZE DEFAULT_BUFSIZE #define FILTERIO_BUFSIZE DEFAULT_BUFSIZE #define NETIO_BUFSIZE DEFAULT_BUFSIZE /** * Check a pointer allocation result, returning -1 if it failed. */ #define GITERR_CHECK_ALLOC(ptr) if (ptr == NULL) { return -1; } /** * Check a return value and propagate result if non-zero. */ #define GITERR_CHECK_ERROR(code) \ do { int _err = (code); if (_err) return _err; } while (0) /** * Set the error message for this thread, formatting as needed. */ void giterr_set(int error_class, const char *string, ...); /** * Set the error message for a regex failure, using the internal regex * error code lookup and return a libgit error code. */ int giterr_set_regex(const regex_t *regex, int error_code); /** * Set error message for user callback if needed. * * If the error code in non-zero and no error message is set, this * sets a generic error message. * * @return This always returns the `error_code` parameter. */ GIT_INLINE(int) giterr_set_after_callback_function( int error_code, const char *action) { if (error_code) { const git_error *e = giterr_last(); if (!e || !e->message) giterr_set(e ? e->klass : GITERR_CALLBACK, "%s callback returned %d", action, error_code); } return error_code; } #ifdef GIT_WIN32 #define giterr_set_after_callback(code) \ giterr_set_after_callback_function((code), __FUNCTION__) #else #define giterr_set_after_callback(code) \ giterr_set_after_callback_function((code), __func__) #endif /** * Gets the system error code for this thread. */ int giterr_system_last(void); /** * Sets the system error code for this thread. */ void giterr_system_set(int code); /** * Structure to preserve libgit2 error state */ typedef struct { int error_code; unsigned int oom : 1; git_error error_msg; } git_error_state; /** * Capture current error state to restore later, returning error code. * If `error_code` is zero, this does not clear the current error state. * You must either restore this error state, or free it. */ extern int giterr_state_capture(git_error_state *state, int error_code); /** * Restore error state to a previous value, returning saved error code. */ extern int giterr_state_restore(git_error_state *state); /** Free an error state. */ extern void giterr_state_free(git_error_state *state); /** * Check a versioned structure for validity */ GIT_INLINE(int) giterr__check_version(const void *structure, unsigned int expected_max, const char *name) { unsigned int actual; if (!structure) return 0; actual = *(const unsigned int*)structure; if (actual > 0 && actual <= expected_max) return 0; giterr_set(GITERR_INVALID, "Invalid version %d on %s", actual, name); return -1; } #define GITERR_CHECK_VERSION(S,V,N) if (giterr__check_version(S,V,N) < 0) return -1 /** * Initialize a structure with a version. */ GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int version) { memset(structure, 0, len); *((int*)structure) = version; } #define GIT_INIT_STRUCTURE(S,V) git__init_structure(S, sizeof(*S), V) #define GIT_INIT_STRUCTURE_FROM_TEMPLATE(PTR,VERSION,TYPE,TPL) do { \ TYPE _tmpl = TPL; \ GITERR_CHECK_VERSION(&(VERSION), _tmpl.version, #TYPE); \ memcpy((PTR), &_tmpl, sizeof(_tmpl)); } while (0) /** Check for additive overflow, setting an error if would occur. */ #define GIT_ADD_SIZET_OVERFLOW(out, one, two) \ (git__add_sizet_overflow(out, one, two) ? (giterr_set_oom(), 1) : 0) /** Check for additive overflow, setting an error if would occur. */ #define GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize) \ (git__multiply_sizet_overflow(out, nelem, elsize) ? (giterr_set_oom(), 1) : 0) /** Check for additive overflow, failing if it would occur. */ #define GITERR_CHECK_ALLOC_ADD(out, one, two) \ if (GIT_ADD_SIZET_OVERFLOW(out, one, two)) { return -1; } #define GITERR_CHECK_ALLOC_ADD3(out, one, two, three) \ if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \ GIT_ADD_SIZET_OVERFLOW(out, *(out), three)) { return -1; } #define GITERR_CHECK_ALLOC_ADD4(out, one, two, three, four) \ if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \ GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \ GIT_ADD_SIZET_OVERFLOW(out, *(out), four)) { return -1; } /** Check for multiplicative overflow, failing if it would occur. */ #define GITERR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \ if (GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize)) { return -1; } /* NOTE: other giterr functions are in the public errors.h header file */ #include "util.h" #endif /* INCLUDE_common_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/strmap.c0000664000175000017500000000106712426525445015361 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "strmap.h" int git_strmap_next( void **data, git_strmap_iter* iter, git_strmap *map) { if (!map) return GIT_ERROR; while (*iter != git_strmap_end(map)) { if (!(git_strmap_has_data(map, *iter))) { ++(*iter); continue; } *data = git_strmap_value_at(map, *iter); ++(*iter); return GIT_OK; } return GIT_ITEROVER; } deps/libgit2-sys-0.3.8/libgit2/src/refs.h0000664000175000017500000000755512510265101015007 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_refs_h__ #define INCLUDE_refs_h__ #include "common.h" #include "git2/oid.h" #include "git2/refs.h" #include "git2/refdb.h" #include "strmap.h" #include "buffer.h" #include "oid.h" #define GIT_REFS_DIR "refs/" #define GIT_REFS_HEADS_DIR GIT_REFS_DIR "heads/" #define GIT_REFS_TAGS_DIR GIT_REFS_DIR "tags/" #define GIT_REFS_REMOTES_DIR GIT_REFS_DIR "remotes/" #define GIT_REFS_NOTES_DIR GIT_REFS_DIR "notes/" #define GIT_REFS_DIR_MODE 0777 #define GIT_REFS_FILE_MODE 0666 #define GIT_RENAMED_REF_FILE GIT_REFS_DIR "RENAMED-REF" #define GIT_SYMREF "ref: " #define GIT_PACKEDREFS_FILE "packed-refs" #define GIT_PACKEDREFS_HEADER "# pack-refs with: peeled fully-peeled " #define GIT_PACKEDREFS_FILE_MODE 0666 #define GIT_HEAD_FILE "HEAD" #define GIT_ORIG_HEAD_FILE "ORIG_HEAD" #define GIT_FETCH_HEAD_FILE "FETCH_HEAD" #define GIT_MERGE_HEAD_FILE "MERGE_HEAD" #define GIT_REVERT_HEAD_FILE "REVERT_HEAD" #define GIT_CHERRYPICK_HEAD_FILE "CHERRY_PICK_HEAD" #define GIT_BISECT_LOG_FILE "BISECT_LOG" #define GIT_REBASE_MERGE_DIR "rebase-merge/" #define GIT_REBASE_MERGE_INTERACTIVE_FILE GIT_REBASE_MERGE_DIR "interactive" #define GIT_REBASE_APPLY_DIR "rebase-apply/" #define GIT_REBASE_APPLY_REBASING_FILE GIT_REBASE_APPLY_DIR "rebasing" #define GIT_REBASE_APPLY_APPLYING_FILE GIT_REBASE_APPLY_DIR "applying" #define GIT_REFS_HEADS_MASTER_FILE GIT_REFS_HEADS_DIR "master" #define GIT_STASH_FILE "stash" #define GIT_REFS_STASH_FILE GIT_REFS_DIR GIT_STASH_FILE #define GIT_REF_FORMAT__PRECOMPOSE_UNICODE (1u << 16) #define GIT_REFNAME_MAX 1024 typedef char git_refname_t[GIT_REFNAME_MAX]; struct git_reference { git_refdb *db; git_ref_t type; union { git_oid oid; char *symbolic; } target; git_oid peel; char name[GIT_FLEX_ARRAY]; }; git_reference *git_reference__set_name(git_reference *ref, const char *name); int git_reference__normalize_name(git_buf *buf, const char *name, unsigned int flags); int git_reference__update_terminal(git_repository *repo, const char *ref_name, const git_oid *oid, const git_signature *sig, const char *log_message); int git_reference__is_valid_name(const char *refname, unsigned int flags); int git_reference__is_branch(const char *ref_name); int git_reference__is_remote(const char *ref_name); int git_reference__is_tag(const char *ref_name); const char *git_reference__shorthand(const char *name); /** * Lookup a reference by name and try to resolve to an OID. * * You can control how many dereferences this will attempt to resolve the * reference with the `max_deref` parameter, or pass -1 to use a sane * default. If you pass 0 for `max_deref`, this will not attempt to resolve * the reference. For any value of `max_deref` other than 0, not * successfully resolving the reference will be reported as an error. * The generated reference must be freed by the user. * * @param reference_out Pointer to the looked-up reference * @param repo The repository to look up the reference * @param name The long name for the reference (e.g. HEAD, ref/heads/master, refs/tags/v0.1.0, ...) * @param max_deref Maximum number of dereferences to make of symbolic refs, 0 means simple lookup, < 0 means use default reasonable value * @return 0 on success or < 0 on error; not being able to resolve the reference is an error unless 0 was passed for max_deref */ int git_reference_lookup_resolved( git_reference **reference_out, git_repository *repo, const char *name, int max_deref); int git_reference__log_signature(git_signature **out, git_repository *repo); /** Update a reference after a commit. */ int git_reference__update_for_commit( git_repository *repo, git_reference *ref, const char *ref_name, const git_oid *id, const char *operation); #endif deps/libgit2-sys-0.3.8/libgit2/src/pool.c0000664000175000017500000001616412510265101015010 0ustar #include "pool.h" #include "posix.h" #ifndef GIT_WIN32 #include #endif struct git_pool_page { git_pool_page *next; uint32_t size; uint32_t avail; GIT_ALIGN(char data[GIT_FLEX_ARRAY], 8); }; struct pool_freelist { struct pool_freelist *next; }; #define GIT_POOL_MIN_USABLE 4 #define GIT_POOL_MIN_PAGESZ 2 * sizeof(void*) static void *pool_alloc_page(git_pool *pool, uint32_t size); static void pool_insert_page(git_pool *pool, git_pool_page *page); int git_pool_init( git_pool *pool, uint32_t item_size, uint32_t items_per_page) { assert(pool); if (!item_size) item_size = 1; /* round up item_size for decent object alignment */ if (item_size > 4) item_size = (item_size + 7) & ~7; else if (item_size == 3) item_size = 4; if (!items_per_page) items_per_page = git_pool__suggest_items_per_page(item_size); if (item_size * items_per_page < GIT_POOL_MIN_PAGESZ) items_per_page = (GIT_POOL_MIN_PAGESZ + item_size - 1) / item_size; memset(pool, 0, sizeof(git_pool)); pool->item_size = item_size; pool->page_size = item_size * items_per_page; return 0; } void git_pool_clear(git_pool *pool) { git_pool_page *scan, *next; for (scan = pool->open; scan != NULL; scan = next) { next = scan->next; git__free(scan); } pool->open = NULL; for (scan = pool->full; scan != NULL; scan = next) { next = scan->next; git__free(scan); } pool->full = NULL; pool->free_list = NULL; pool->items = 0; pool->has_string_alloc = 0; pool->has_multi_item_alloc = 0; pool->has_large_page_alloc = 0; } void git_pool_swap(git_pool *a, git_pool *b) { git_pool temp; if (a == b) return; memcpy(&temp, a, sizeof(temp)); memcpy(a, b, sizeof(temp)); memcpy(b, &temp, sizeof(temp)); } static void pool_insert_page(git_pool *pool, git_pool_page *page) { git_pool_page *scan; /* If there are no open pages or this page has the most open space, * insert it at the beginning of the list. This is the common case. */ if (pool->open == NULL || pool->open->avail < page->avail) { page->next = pool->open; pool->open = page; return; } /* Otherwise insert into sorted position. */ for (scan = pool->open; scan->next && scan->next->avail > page->avail; scan = scan->next); page->next = scan->next; scan->next = page; } static void *pool_alloc_page(git_pool *pool, uint32_t size) { git_pool_page *page; uint32_t new_page_size; size_t alloc_size; if (size <= pool->page_size) new_page_size = pool->page_size; else { new_page_size = size; pool->has_large_page_alloc = 1; } if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, new_page_size, sizeof(git_pool_page)) || !(page = git__calloc(1, alloc_size))) return NULL; page->size = new_page_size; page->avail = new_page_size - size; if (page->avail > 0) pool_insert_page(pool, page); else { page->next = pool->full; pool->full = page; } pool->items++; return page->data; } GIT_INLINE(void) pool_remove_page( git_pool *pool, git_pool_page *page, git_pool_page *prev) { if (prev == NULL) pool->open = page->next; else prev->next = page->next; } void *git_pool_malloc(git_pool *pool, uint32_t items) { git_pool_page *scan = pool->open, *prev; uint32_t size = ((items * pool->item_size) + 7) & ~7; void *ptr = NULL; pool->has_string_alloc = 0; if (items > 1) pool->has_multi_item_alloc = 1; else if (pool->free_list != NULL) { ptr = pool->free_list; pool->free_list = ((struct pool_freelist *)pool->free_list)->next; return ptr; } /* just add a block if there is no open one to accommodate this */ if (size >= pool->page_size || !scan || scan->avail < size) return pool_alloc_page(pool, size); pool->items++; /* find smallest block in free list with space */ for (scan = pool->open, prev = NULL; scan->next && scan->next->avail >= size; prev = scan, scan = scan->next); /* allocate space from the block */ ptr = &scan->data[scan->size - scan->avail]; scan->avail -= size; /* move to full list if there is almost no space left */ if (scan->avail < pool->item_size || scan->avail < GIT_POOL_MIN_USABLE) { pool_remove_page(pool, scan, prev); scan->next = pool->full; pool->full = scan; } /* reorder list if block is now smaller than the one after it */ else if (scan->next != NULL && scan->next->avail > scan->avail) { pool_remove_page(pool, scan, prev); pool_insert_page(pool, scan); } return ptr; } char *git_pool_strndup(git_pool *pool, const char *str, size_t n) { char *ptr = NULL; assert(pool && str && pool->item_size == sizeof(char)); if ((uint32_t)(n + 1) < n) return NULL; if ((ptr = git_pool_malloc(pool, (uint32_t)(n + 1))) != NULL) { memcpy(ptr, str, n); ptr[n] = '\0'; } pool->has_string_alloc = 1; return ptr; } char *git_pool_strdup(git_pool *pool, const char *str) { assert(pool && str && pool->item_size == sizeof(char)); return git_pool_strndup(pool, str, strlen(str)); } char *git_pool_strdup_safe(git_pool *pool, const char *str) { return str ? git_pool_strdup(pool, str) : NULL; } char *git_pool_strcat(git_pool *pool, const char *a, const char *b) { void *ptr; size_t len_a, len_b; assert(pool && pool->item_size == sizeof(char)); len_a = a ? strlen(a) : 0; len_b = b ? strlen(b) : 0; if ((ptr = git_pool_malloc(pool, (uint32_t)(len_a + len_b + 1))) != NULL) { if (len_a) memcpy(ptr, a, len_a); if (len_b) memcpy(((char *)ptr) + len_a, b, len_b); *(((char *)ptr) + len_a + len_b) = '\0'; } pool->has_string_alloc = 1; return ptr; } void git_pool_free(git_pool *pool, void *ptr) { struct pool_freelist *item = ptr; assert(pool && pool->item_size >= sizeof(void*)); if (item) { item->next = pool->free_list; pool->free_list = item; } } void git_pool_free_array(git_pool *pool, size_t count, void **ptrs) { struct pool_freelist **items = (struct pool_freelist **)ptrs; size_t i; assert(pool && ptrs && pool->item_size >= sizeof(void*)); if (!count) return; for (i = count - 1; i > 0; --i) items[i]->next = items[i - 1]; items[i]->next = pool->free_list; pool->free_list = items[count - 1]; } uint32_t git_pool__open_pages(git_pool *pool) { uint32_t ct = 0; git_pool_page *scan; for (scan = pool->open; scan != NULL; scan = scan->next) ct++; return ct; } uint32_t git_pool__full_pages(git_pool *pool) { uint32_t ct = 0; git_pool_page *scan; for (scan = pool->full; scan != NULL; scan = scan->next) ct++; return ct; } bool git_pool__ptr_in_pool(git_pool *pool, void *ptr) { git_pool_page *scan; for (scan = pool->open; scan != NULL; scan = scan->next) if ((void *)scan->data <= ptr && (void *)(((char *)scan->data) + scan->size) > ptr) return true; for (scan = pool->full; scan != NULL; scan = scan->next) if ((void *)scan->data <= ptr && (void *)(((char *)scan->data) + scan->size) > ptr) return true; return false; } uint32_t git_pool__system_page_size(void) { static uint32_t size = 0; if (!size) { size_t page_size; if (git__page_size(&page_size) < 0) page_size = 4096; size = page_size - 2 * sizeof(void *); /* allow space for malloc overhead */ } return size; } uint32_t git_pool__suggest_items_per_page(uint32_t item_size) { uint32_t page_bytes = git_pool__system_page_size() - sizeof(git_pool_page); return page_bytes / item_size; } deps/libgit2-sys-0.3.8/libgit2/src/socket_stream.c0000664000175000017500000001046512510265101016700 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "posix.h" #include "netops.h" #include "stream.h" #include "socket_stream.h" #ifndef _WIN32 # include # include # include # include # include # include # include #else # include # include # ifdef _MSC_VER # pragma comment(lib, "ws2_32") # endif #endif #ifdef GIT_WIN32 static void net_set_error(const char *str) { int error = WSAGetLastError(); char * win32_error = git_win32_get_error_message(error); if (win32_error) { giterr_set(GITERR_NET, "%s: %s", str, win32_error); git__free(win32_error); } else { giterr_set(GITERR_NET, str); } } #else static void net_set_error(const char *str) { giterr_set(GITERR_NET, "%s: %s", str, strerror(errno)); } #endif static int close_socket(GIT_SOCKET s) { if (s == INVALID_SOCKET) return 0; #ifdef GIT_WIN32 if (SOCKET_ERROR == closesocket(s)) return -1; if (0 != WSACleanup()) { giterr_set(GITERR_OS, "Winsock cleanup failed"); return -1; } return 0; #else return close(s); #endif } int socket_connect(git_stream *stream) { struct addrinfo *info = NULL, *p; struct addrinfo hints; git_socket_stream *st = (git_socket_stream *) stream; GIT_SOCKET s = INVALID_SOCKET; int ret; #ifdef GIT_WIN32 /* on win32, the WSA context needs to be initialized * before any socket calls can be performed */ WSADATA wsd; if (WSAStartup(MAKEWORD(2,2), &wsd) != 0) { giterr_set(GITERR_OS, "Winsock init failed"); return -1; } if (LOBYTE(wsd.wVersion) != 2 || HIBYTE(wsd.wVersion) != 2) { WSACleanup(); giterr_set(GITERR_OS, "Winsock init failed"); return -1; } #endif memset(&hints, 0x0, sizeof(struct addrinfo)); hints.ai_socktype = SOCK_STREAM; hints.ai_family = AF_UNSPEC; if ((ret = p_getaddrinfo(st->host, st->port, &hints, &info)) != 0) { giterr_set(GITERR_NET, "Failed to resolve address for %s: %s", st->host, p_gai_strerror(ret)); return -1; } for (p = info; p != NULL; p = p->ai_next) { s = socket(p->ai_family, p->ai_socktype, p->ai_protocol); if (s == INVALID_SOCKET) { net_set_error("error creating socket"); break; } if (connect(s, p->ai_addr, (socklen_t)p->ai_addrlen) == 0) break; /* If we can't connect, try the next one */ close_socket(s); s = INVALID_SOCKET; } /* Oops, we couldn't connect to any address */ if (s == INVALID_SOCKET && p == NULL) { giterr_set(GITERR_OS, "Failed to connect to %s", st->host); p_freeaddrinfo(info); return -1; } st->s = s; p_freeaddrinfo(info); return 0; } ssize_t socket_write(git_stream *stream, const char *data, size_t len, int flags) { ssize_t ret; size_t off = 0; git_socket_stream *st = (git_socket_stream *) stream; while (off < len) { errno = 0; ret = p_send(st->s, data + off, len - off, flags); if (ret < 0) { net_set_error("Error sending data"); return -1; } off += ret; } return off; } ssize_t socket_read(git_stream *stream, void *data, size_t len) { ssize_t ret; git_socket_stream *st = (git_socket_stream *) stream; if ((ret = p_recv(st->s, data, len, 0)) < 0) net_set_error("Error receiving socket data"); return ret; } int socket_close(git_stream *stream) { git_socket_stream *st = (git_socket_stream *) stream; int error; error = close_socket(st->s); st->s = INVALID_SOCKET; return error; } void socket_free(git_stream *stream) { git_socket_stream *st = (git_socket_stream *) stream; git__free(st->host); git__free(st->port); git__free(st); } int git_socket_stream_new(git_stream **out, const char *host, const char *port) { git_socket_stream *st; assert(out && host); st = git__calloc(1, sizeof(git_socket_stream)); GITERR_CHECK_ALLOC(st); st->host = git__strdup(host); GITERR_CHECK_ALLOC(st->host); if (port) { st->port = git__strdup(port); GITERR_CHECK_ALLOC(st->port); } st->parent.version = GIT_STREAM_VERSION; st->parent.connect = socket_connect; st->parent.write = socket_write; st->parent.read = socket_read; st->parent.close = socket_close; st->parent.free = socket_free; st->s = INVALID_SOCKET; *out = (git_stream *) st; return 0; } deps/libgit2-sys-0.3.8/libgit2/src/pack.h0000664000175000017500000001053412510265101014755 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_pack_h__ #define INCLUDE_pack_h__ #include #include "git2/oid.h" #include "common.h" #include "map.h" #include "mwindow.h" #include "odb.h" #include "oidmap.h" #include "array.h" #define GIT_PACK_FILE_MODE 0444 #define PACK_SIGNATURE 0x5041434b /* "PACK" */ #define PACK_VERSION 2 #define pack_version_ok(v) ((v) == htonl(2) || (v) == htonl(3)) struct git_pack_header { uint32_t hdr_signature; uint32_t hdr_version; uint32_t hdr_entries; }; /* * The first four bytes of index formats later than version 1 should * start with this signature, as all older git binaries would find this * value illegal and abort reading the file. * * This is the case because the number of objects in a packfile * cannot exceed 1,431,660,000 as every object would need at least * 3 bytes of data and the overall packfile cannot exceed 4 GiB with * version 1 of the index file due to the offsets limited to 32 bits. * Clearly the signature exceeds this maximum. * * Very old git binaries will also compare the first 4 bytes to the * next 4 bytes in the index and abort with a "non-monotonic index" * error if the second 4 byte word is smaller than the first 4 * byte word. This would be true in the proposed future index * format as idx_signature would be greater than idx_version. */ #define PACK_IDX_SIGNATURE 0xff744f63 /* "\377tOc" */ struct git_pack_idx_header { uint32_t idx_signature; uint32_t idx_version; }; typedef struct git_pack_cache_entry { size_t last_usage; /* enough? */ git_atomic refcount; git_rawobj raw; } git_pack_cache_entry; struct pack_chain_elem { git_off_t base_key; git_off_t offset; size_t size; git_otype type; }; typedef git_array_t(struct pack_chain_elem) git_dependency_chain; #include "offmap.h" #include "oidmap.h" #define GIT_PACK_CACHE_MEMORY_LIMIT 16 * 1024 * 1024 #define GIT_PACK_CACHE_SIZE_LIMIT 1024 * 1024 /* don't bother caching anything over 1MB */ typedef struct { size_t memory_used; size_t memory_limit; size_t use_ctr; git_mutex lock; git_offmap *entries; } git_pack_cache; struct git_pack_file { git_mwindow_file mwf; git_map index_map; git_mutex lock; /* protect updates to mwf and index_map */ git_atomic refcount; uint32_t num_objects; uint32_t num_bad_objects; git_oid *bad_object_sha1; /* array of git_oid */ int index_version; git_time_t mtime; unsigned pack_local:1, pack_keep:1, has_cache:1; git_oidmap *idx_cache; git_oid **oids; git_pack_cache bases; /* delta base cache */ /* something like ".git/objects/pack/xxxxx.pack" */ char pack_name[GIT_FLEX_ARRAY]; /* more */ }; struct git_pack_entry { git_off_t offset; git_oid sha1; struct git_pack_file *p; }; typedef struct git_packfile_stream { git_off_t curpos; int done; z_stream zstream; struct git_pack_file *p; git_mwindow *mw; } git_packfile_stream; size_t git_packfile__object_header(unsigned char *hdr, size_t size, git_otype type); int git_packfile__name(char **out, const char *path); int git_packfile_unpack_header( size_t *size_p, git_otype *type_p, git_mwindow_file *mwf, git_mwindow **w_curs, git_off_t *curpos); int git_packfile_resolve_header( size_t *size_p, git_otype *type_p, struct git_pack_file *p, git_off_t offset); int git_packfile_unpack(git_rawobj *obj, struct git_pack_file *p, git_off_t *obj_offset); int packfile_unpack_compressed( git_rawobj *obj, struct git_pack_file *p, git_mwindow **w_curs, git_off_t *curpos, size_t size, git_otype type); int git_packfile_stream_open(git_packfile_stream *obj, struct git_pack_file *p, git_off_t curpos); ssize_t git_packfile_stream_read(git_packfile_stream *obj, void *buffer, size_t len); void git_packfile_stream_free(git_packfile_stream *obj); git_off_t get_delta_base(struct git_pack_file *p, git_mwindow **w_curs, git_off_t *curpos, git_otype type, git_off_t delta_obj_offset); void git_packfile_free(struct git_pack_file *p); int git_packfile_alloc(struct git_pack_file **pack_out, const char *path); int git_pack_entry_find( struct git_pack_entry *e, struct git_pack_file *p, const git_oid *short_oid, size_t len); int git_pack_foreach_entry( struct git_pack_file *p, git_odb_foreach_cb cb, void *data); #endif deps/libgit2-sys-0.3.8/libgit2/src/offmap.h0000664000175000017500000000370312510265101015307 0ustar /* * Copyright (C) 2012 the libgit2 contributors * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_offmap_h__ #define INCLUDE_offmap_h__ #include "common.h" #include "git2/types.h" #define kmalloc git__malloc #define kcalloc git__calloc #define krealloc git__realloc #define kreallocarray git__reallocarray #define kfree git__free #include "khash.h" __KHASH_TYPE(off, git_off_t, void *) typedef khash_t(off) git_offmap; #define GIT__USE_OFFMAP \ __KHASH_IMPL(off, static kh_inline, git_off_t, void *, 1, kh_int64_hash_func, kh_int64_hash_equal) #define git_offmap_alloc() kh_init(off) #define git_offmap_free(h) kh_destroy(off, h), h = NULL #define git_offmap_clear(h) kh_clear(off, h) #define git_offmap_num_entries(h) kh_size(h) #define git_offmap_lookup_index(h, k) kh_get(off, h, k) #define git_offmap_valid_index(h, idx) (idx != kh_end(h)) #define git_offmap_exists(h, k) (kh_get(off, h, k) != kh_end(h)) #define git_offmap_value_at(h, idx) kh_val(h, idx) #define git_offmap_set_value_at(h, idx, v) kh_val(h, idx) = v #define git_offmap_delete_at(h, idx) kh_del(off, h, idx) #define git_offmap_insert(h, key, val, rval) do { \ khiter_t __pos = kh_put(off, h, key, &rval); \ if (rval >= 0) { \ if (rval == 0) kh_key(h, __pos) = key; \ kh_val(h, __pos) = val; \ } } while (0) #define git_offmap_insert2(h, key, val, oldv, rval) do { \ khiter_t __pos = kh_put(off, h, key, &rval); \ if (rval >= 0) { \ if (rval == 0) { \ oldv = kh_val(h, __pos); \ kh_key(h, __pos) = key; \ } else { oldv = NULL; } \ kh_val(h, __pos) = val; \ } } while (0) #define git_offmap_delete(h, key) do { \ khiter_t __pos = git_offmap_lookup_index(h, key); \ if (git_offmap_valid_index(h, __pos)) \ git_offmap_delete_at(h, __pos); } while (0) #define git_offmap_foreach kh_foreach #define git_offmap_foreach_value kh_foreach_value #endif deps/libgit2-sys-0.3.8/libgit2/src/thread-utils.c0000664000175000017500000000243112572105236016446 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "thread-utils.h" #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN #endif # include #elif defined(hpux) || defined(__hpux) || defined(_hpux) # include #endif /* * By doing this in two steps we can at least get * the function to be somewhat coherent, even * with this disgusting nest of #ifdefs. */ #ifndef _SC_NPROCESSORS_ONLN # ifdef _SC_NPROC_ONLN # define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN # elif defined _SC_CRAY_NCPU # define _SC_NPROCESSORS_ONLN _SC_CRAY_NCPU # endif #endif int git_online_cpus(void) { #ifdef _SC_NPROCESSORS_ONLN long ncpus; #endif #ifdef _WIN32 SYSTEM_INFO info; GetSystemInfo(&info); if ((int)info.dwNumberOfProcessors > 0) return (int)info.dwNumberOfProcessors; #elif defined(hpux) || defined(__hpux) || defined(_hpux) struct pst_dynamic psd; if (!pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0)) return (int)psd.psd_proc_cnt; #endif #ifdef _SC_NPROCESSORS_ONLN if ((ncpus = (long)sysconf(_SC_NPROCESSORS_ONLN)) > 0) return (int)ncpus; #endif return 1; } deps/libgit2-sys-0.3.8/libgit2/src/fileops.c0000664000175000017500000006070712610310643015505 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "fileops.h" #include "global.h" #include "strmap.h" #include #if GIT_WIN32 #include "win32/findfile.h" #endif GIT__USE_STRMAP int git_futils_mkpath2file(const char *file_path, const mode_t mode) { return git_futils_mkdir( file_path, mode, GIT_MKDIR_PATH | GIT_MKDIR_SKIP_LAST | GIT_MKDIR_VERIFY_DIR); } int git_futils_mktmp(git_buf *path_out, const char *filename, mode_t mode) { int fd; mode_t mask; p_umask(mask = p_umask(0)); git_buf_sets(path_out, filename); git_buf_puts(path_out, "_git2_XXXXXX"); if (git_buf_oom(path_out)) return -1; if ((fd = p_mkstemp(path_out->ptr)) < 0) { giterr_set(GITERR_OS, "Failed to create temporary file '%s'", path_out->ptr); return -1; } if (p_chmod(path_out->ptr, (mode & ~mask))) { giterr_set(GITERR_OS, "Failed to set permissions on file '%s'", path_out->ptr); return -1; } return fd; } int git_futils_creat_withpath(const char *path, const mode_t dirmode, const mode_t mode) { int fd; if (git_futils_mkpath2file(path, dirmode) < 0) return -1; fd = p_creat(path, mode); if (fd < 0) { giterr_set(GITERR_OS, "Failed to create file '%s'", path); return -1; } return fd; } int git_futils_creat_locked(const char *path, const mode_t mode) { int fd = p_open(path, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL | O_BINARY | O_CLOEXEC, mode); if (fd < 0) { giterr_set(GITERR_OS, "Failed to create locked file '%s'", path); return errno == EEXIST ? GIT_ELOCKED : -1; } return fd; } int git_futils_creat_locked_withpath(const char *path, const mode_t dirmode, const mode_t mode) { if (git_futils_mkpath2file(path, dirmode) < 0) return -1; return git_futils_creat_locked(path, mode); } int git_futils_open_ro(const char *path) { int fd = p_open(path, O_RDONLY); if (fd < 0) return git_path_set_error(errno, path, "open"); return fd; } git_off_t git_futils_filesize(git_file fd) { struct stat sb; if (p_fstat(fd, &sb)) { giterr_set(GITERR_OS, "Failed to stat file descriptor"); return -1; } return sb.st_size; } mode_t git_futils_canonical_mode(mode_t raw_mode) { if (S_ISREG(raw_mode)) return S_IFREG | GIT_PERMS_CANONICAL(raw_mode); else if (S_ISLNK(raw_mode)) return S_IFLNK; else if (S_ISGITLINK(raw_mode)) return S_IFGITLINK; else if (S_ISDIR(raw_mode)) return S_IFDIR; else return 0; } int git_futils_readbuffer_fd(git_buf *buf, git_file fd, size_t len) { ssize_t read_size = 0; size_t alloc_len; git_buf_clear(buf); if (!git__is_ssizet(len)) { giterr_set(GITERR_INVALID, "Read too large."); return -1; } GITERR_CHECK_ALLOC_ADD(&alloc_len, len, 1); if (git_buf_grow(buf, alloc_len) < 0) return -1; /* p_read loops internally to read len bytes */ read_size = p_read(fd, buf->ptr, len); if (read_size != (ssize_t)len) { giterr_set(GITERR_OS, "Failed to read descriptor"); git_buf_free(buf); return -1; } buf->ptr[read_size] = '\0'; buf->size = read_size; return 0; } int git_futils_readbuffer_updated( git_buf *buf, const char *path, time_t *mtime, size_t *size, int *updated) { git_file fd; struct stat st; bool changed = false; assert(buf && path && *path); if (updated != NULL) *updated = 0; if (p_stat(path, &st) < 0) return git_path_set_error(errno, path, "stat"); if (S_ISDIR(st.st_mode)) { giterr_set(GITERR_INVALID, "requested file is a directory"); return GIT_ENOTFOUND; } if (!git__is_sizet(st.st_size+1)) { giterr_set(GITERR_OS, "Invalid regular file stat for '%s'", path); return -1; } /* * If we were given a time and/or a size, we only want to read the file * if it has been modified. */ if (size && *size != (size_t)st.st_size) changed = true; if (mtime && *mtime != (time_t)st.st_mtime) changed = true; if (!size && !mtime) changed = true; if (!changed) { return 0; } if (mtime != NULL) *mtime = st.st_mtime; if (size != NULL) *size = (size_t)st.st_size; if ((fd = git_futils_open_ro(path)) < 0) return fd; if (git_futils_readbuffer_fd(buf, fd, (size_t)st.st_size) < 0) { p_close(fd); return -1; } p_close(fd); if (updated != NULL) *updated = 1; return 0; } int git_futils_readbuffer(git_buf *buf, const char *path) { return git_futils_readbuffer_updated(buf, path, NULL, NULL, NULL); } int git_futils_writebuffer( const git_buf *buf, const char *path, int flags, mode_t mode) { int fd, error = 0; if (flags <= 0) flags = O_CREAT | O_TRUNC | O_WRONLY; if (!mode) mode = GIT_FILEMODE_BLOB; if ((fd = p_open(path, flags, mode)) < 0) { giterr_set(GITERR_OS, "Could not open '%s' for writing", path); return fd; } if ((error = p_write(fd, git_buf_cstr(buf), git_buf_len(buf))) < 0) { giterr_set(GITERR_OS, "Could not write to '%s'", path); (void)p_close(fd); return error; } if ((error = p_close(fd)) < 0) giterr_set(GITERR_OS, "Error while closing '%s'", path); return error; } int git_futils_mv_withpath(const char *from, const char *to, const mode_t dirmode) { if (git_futils_mkpath2file(to, dirmode) < 0) return -1; if (p_rename(from, to) < 0) { giterr_set(GITERR_OS, "Failed to rename '%s' to '%s'", from, to); return -1; } return 0; } int git_futils_mmap_ro(git_map *out, git_file fd, git_off_t begin, size_t len) { return p_mmap(out, len, GIT_PROT_READ, GIT_MAP_SHARED, fd, begin); } int git_futils_mmap_ro_file(git_map *out, const char *path) { git_file fd = git_futils_open_ro(path); git_off_t len; int result; if (fd < 0) return fd; len = git_futils_filesize(fd); if (!git__is_sizet(len)) { giterr_set(GITERR_OS, "File `%s` too large to mmap", path); return -1; } result = git_futils_mmap_ro(out, fd, 0, (size_t)len); p_close(fd); return result; } void git_futils_mmap_free(git_map *out) { p_munmap(out); } GIT_INLINE(int) mkdir_validate_dir( const char *path, struct stat *st, mode_t mode, uint32_t flags, struct git_futils_mkdir_options *opts) { /* with exclusive create, existing dir is an error */ if ((flags & GIT_MKDIR_EXCL) != 0) { giterr_set(GITERR_FILESYSTEM, "Failed to make directory '%s': directory exists", path); return GIT_EEXISTS; } if ((S_ISREG(st->st_mode) && (flags & GIT_MKDIR_REMOVE_FILES)) || (S_ISLNK(st->st_mode) && (flags & GIT_MKDIR_REMOVE_SYMLINKS))) { if (p_unlink(path) < 0) { giterr_set(GITERR_OS, "Failed to remove %s '%s'", S_ISLNK(st->st_mode) ? "symlink" : "file", path); return GIT_EEXISTS; } opts->perfdata.mkdir_calls++; if (p_mkdir(path, mode) < 0) { giterr_set(GITERR_OS, "Failed to make directory '%s'", path); return GIT_EEXISTS; } } else if (S_ISLNK(st->st_mode)) { /* Re-stat the target, make sure it's a directory */ opts->perfdata.stat_calls++; if (p_stat(path, st) < 0) { giterr_set(GITERR_OS, "Failed to make directory '%s'", path); return GIT_EEXISTS; } } else if (!S_ISDIR(st->st_mode)) { giterr_set(GITERR_FILESYSTEM, "Failed to make directory '%s': directory exists", path); return GIT_EEXISTS; } return 0; } GIT_INLINE(int) mkdir_validate_mode( const char *path, struct stat *st, bool terminal_path, mode_t mode, uint32_t flags, struct git_futils_mkdir_options *opts) { if (((terminal_path && (flags & GIT_MKDIR_CHMOD) != 0) || (flags & GIT_MKDIR_CHMOD_PATH) != 0) && st->st_mode != mode) { opts->perfdata.chmod_calls++; if (p_chmod(path, mode) < 0) { giterr_set(GITERR_OS, "failed to set permissions on '%s'", path); return -1; } } return 0; } GIT_INLINE(int) mkdir_canonicalize( git_buf *path, uint32_t flags) { ssize_t root_len; if (path->size == 0) { giterr_set(GITERR_OS, "attempt to create empty path"); return -1; } /* Trim trailing slashes (except the root) */ if ((root_len = git_path_root(path->ptr)) < 0) root_len = 0; else root_len++; while (path->size > (size_t)root_len && path->ptr[path->size - 1] == '/') path->ptr[--path->size] = '\0'; /* if we are not supposed to made the last element, truncate it */ if ((flags & GIT_MKDIR_SKIP_LAST2) != 0) { git_path_dirname_r(path, path->ptr); flags |= GIT_MKDIR_SKIP_LAST; } if ((flags & GIT_MKDIR_SKIP_LAST) != 0) { git_path_dirname_r(path, path->ptr); } /* We were either given the root path (or trimmed it to * the root), we don't have anything to do. */ if (path->size <= (size_t)root_len) git_buf_clear(path); return 0; } int git_futils_mkdir( const char *path, mode_t mode, uint32_t flags) { git_buf make_path = GIT_BUF_INIT, parent_path = GIT_BUF_INIT; const char *relative; struct git_futils_mkdir_options opts = { 0 }; struct stat st; size_t depth = 0; int len = 0, root_len, error; if ((error = git_buf_puts(&make_path, path)) < 0 || (error = mkdir_canonicalize(&make_path, flags)) < 0 || (error = git_buf_puts(&parent_path, make_path.ptr)) < 0 || make_path.size == 0) goto done; root_len = git_path_root(make_path.ptr); /* find the first parent directory that exists. this will be used * as the base to dirname_relative. */ for (relative = make_path.ptr; parent_path.size; ) { error = p_lstat(parent_path.ptr, &st); if (error == 0) { break; } else if (errno != ENOENT) { giterr_set(GITERR_OS, "failed to stat '%s'", parent_path.ptr); goto done; } depth++; /* examine the parent of the current path */ if ((len = git_path_dirname_r(&parent_path, parent_path.ptr)) < 0) { error = len; goto done; } assert(len); /* we've walked all the given path's parents and it's either relative * or rooted. either way, give up and make the entire path. */ if ((len == 1 && parent_path.ptr[0] == '.') || len == root_len+1) { relative = make_path.ptr; break; } relative = make_path.ptr + len + 1; /* not recursive? just make this directory relative to its parent. */ if ((flags & GIT_MKDIR_PATH) == 0) break; } /* we found an item at the location we're trying to create, * validate it. */ if (depth == 0) { error = mkdir_validate_dir(make_path.ptr, &st, mode, flags, &opts); if (!error) error = mkdir_validate_mode( make_path.ptr, &st, true, mode, flags, &opts); goto done; } /* we already took `SKIP_LAST` and `SKIP_LAST2` into account when * canonicalizing `make_path`. */ flags &= ~(GIT_MKDIR_SKIP_LAST2 | GIT_MKDIR_SKIP_LAST); error = git_futils_mkdir_relative(relative, parent_path.size ? parent_path.ptr : NULL, mode, flags, &opts); done: git_buf_free(&make_path); git_buf_free(&parent_path); return error; } int git_futils_mkdir_r(const char *path, const mode_t mode) { return git_futils_mkdir(path, mode, GIT_MKDIR_PATH); } int git_futils_mkdir_relative( const char *relative_path, const char *base, mode_t mode, uint32_t flags, struct git_futils_mkdir_options *opts) { git_buf make_path = GIT_BUF_INIT; ssize_t root = 0, min_root_len; char lastch = '/', *tail; struct stat st; struct git_futils_mkdir_options empty_opts = {0}; int error; if (!opts) opts = &empty_opts; /* build path and find "root" where we should start calling mkdir */ if (git_path_join_unrooted(&make_path, relative_path, base, &root) < 0) return -1; if ((error = mkdir_canonicalize(&make_path, flags)) < 0 || make_path.size == 0) goto done; /* if we are not supposed to make the whole path, reset root */ if ((flags & GIT_MKDIR_PATH) == 0) root = git_buf_rfind(&make_path, '/'); /* advance root past drive name or network mount prefix */ min_root_len = git_path_root(make_path.ptr); if (root < min_root_len) root = min_root_len; while (root >= 0 && make_path.ptr[root] == '/') ++root; /* clip root to make_path length */ if (root > (ssize_t)make_path.size) root = (ssize_t)make_path.size; /* i.e. NUL byte of string */ if (root < 0) root = 0; /* walk down tail of path making each directory */ for (tail = &make_path.ptr[root]; *tail; *tail = lastch) { bool mkdir_attempted = false; /* advance tail to include next path component */ while (*tail == '/') tail++; while (*tail && *tail != '/') tail++; /* truncate path at next component */ lastch = *tail; *tail = '\0'; st.st_mode = 0; if (opts->dir_map && git_strmap_exists(opts->dir_map, make_path.ptr)) continue; /* See what's going on with this path component */ opts->perfdata.stat_calls++; retry_lstat: if (p_lstat(make_path.ptr, &st) < 0) { if (mkdir_attempted || errno != ENOENT) { giterr_set(GITERR_OS, "Cannot access component in path '%s'", make_path.ptr); error = -1; goto done; } giterr_clear(); opts->perfdata.mkdir_calls++; mkdir_attempted = true; if (p_mkdir(make_path.ptr, mode) < 0) { if (errno == EEXIST) goto retry_lstat; giterr_set(GITERR_OS, "Failed to make directory '%s'", make_path.ptr); error = -1; goto done; } } else { if ((error = mkdir_validate_dir( make_path.ptr, &st, mode, flags, opts)) < 0) goto done; } /* chmod if requested and necessary */ if ((error = mkdir_validate_mode( make_path.ptr, &st, (lastch == '\0'), mode, flags, opts)) < 0) goto done; if (opts->dir_map && opts->pool) { char *cache_path; size_t alloc_size; GITERR_CHECK_ALLOC_ADD(&alloc_size, make_path.size, 1); if (!git__is_uint32(alloc_size)) return -1; cache_path = git_pool_malloc(opts->pool, (uint32_t)alloc_size); GITERR_CHECK_ALLOC(cache_path); memcpy(cache_path, make_path.ptr, make_path.size + 1); git_strmap_insert(opts->dir_map, cache_path, cache_path, error); if (error < 0) goto done; } } error = 0; /* check that full path really is a directory if requested & needed */ if ((flags & GIT_MKDIR_VERIFY_DIR) != 0 && lastch != '\0') { opts->perfdata.stat_calls++; if (p_stat(make_path.ptr, &st) < 0 || !S_ISDIR(st.st_mode)) { giterr_set(GITERR_OS, "Path is not a directory '%s'", make_path.ptr); error = GIT_ENOTFOUND; } } done: git_buf_free(&make_path); return error; } typedef struct { const char *base; size_t baselen; uint32_t flags; int depth; } futils__rmdir_data; #define FUTILS_MAX_DEPTH 100 static int futils__error_cannot_rmdir(const char *path, const char *filemsg) { if (filemsg) giterr_set(GITERR_OS, "Could not remove directory. File '%s' %s", path, filemsg); else giterr_set(GITERR_OS, "Could not remove directory '%s'", path); return -1; } static int futils__rm_first_parent(git_buf *path, const char *ceiling) { int error = GIT_ENOTFOUND; struct stat st; while (error == GIT_ENOTFOUND) { git_buf_rtruncate_at_char(path, '/'); if (!path->size || git__prefixcmp(path->ptr, ceiling) != 0) error = 0; else if (p_lstat_posixly(path->ptr, &st) == 0) { if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) error = p_unlink(path->ptr); else if (!S_ISDIR(st.st_mode)) error = -1; /* fail to remove non-regular file */ } else if (errno != ENOTDIR) error = -1; } if (error) futils__error_cannot_rmdir(path->ptr, "cannot remove parent"); return error; } static int futils__rmdir_recurs_foreach(void *opaque, git_buf *path) { int error = 0; futils__rmdir_data *data = opaque; struct stat st; if (data->depth > FUTILS_MAX_DEPTH) error = futils__error_cannot_rmdir( path->ptr, "directory nesting too deep"); else if ((error = p_lstat_posixly(path->ptr, &st)) < 0) { if (errno == ENOENT) error = 0; else if (errno == ENOTDIR) { /* asked to remove a/b/c/d/e and a/b is a normal file */ if ((data->flags & GIT_RMDIR_REMOVE_BLOCKERS) != 0) error = futils__rm_first_parent(path, data->base); else futils__error_cannot_rmdir( path->ptr, "parent is not directory"); } else error = git_path_set_error(errno, path->ptr, "rmdir"); } else if (S_ISDIR(st.st_mode)) { data->depth++; error = git_path_direach(path, 0, futils__rmdir_recurs_foreach, data); data->depth--; if (error < 0) return error; if (data->depth == 0 && (data->flags & GIT_RMDIR_SKIP_ROOT) != 0) return error; if ((error = p_rmdir(path->ptr)) < 0) { if ((data->flags & GIT_RMDIR_SKIP_NONEMPTY) != 0 && (errno == ENOTEMPTY || errno == EEXIST || errno == EBUSY)) error = 0; else error = git_path_set_error(errno, path->ptr, "rmdir"); } } else if ((data->flags & GIT_RMDIR_REMOVE_FILES) != 0) { if (p_unlink(path->ptr) < 0) error = git_path_set_error(errno, path->ptr, "remove"); } else if ((data->flags & GIT_RMDIR_SKIP_NONEMPTY) == 0) error = futils__error_cannot_rmdir(path->ptr, "still present"); return error; } static int futils__rmdir_empty_parent(void *opaque, const char *path) { futils__rmdir_data *data = opaque; int error = 0; if (strlen(path) <= data->baselen) error = GIT_ITEROVER; else if (p_rmdir(path) < 0) { int en = errno; if (en == ENOENT || en == ENOTDIR) { /* do nothing */ } else if (en == ENOTEMPTY || en == EEXIST || en == EBUSY) { error = GIT_ITEROVER; } else { error = git_path_set_error(errno, path, "rmdir"); } } return error; } int git_futils_rmdir_r( const char *path, const char *base, uint32_t flags) { int error; git_buf fullpath = GIT_BUF_INIT; futils__rmdir_data data; /* build path and find "root" where we should start calling mkdir */ if (git_path_join_unrooted(&fullpath, path, base, NULL) < 0) return -1; memset(&data, 0, sizeof(data)); data.base = base ? base : ""; data.baselen = base ? strlen(base) : 0; data.flags = flags; error = futils__rmdir_recurs_foreach(&data, &fullpath); /* remove now-empty parents if requested */ if (!error && (flags & GIT_RMDIR_EMPTY_PARENTS) != 0) error = git_path_walk_up( &fullpath, base, futils__rmdir_empty_parent, &data); if (error == GIT_ITEROVER) { giterr_clear(); error = 0; } git_buf_free(&fullpath); return error; } int git_futils_fake_symlink(const char *old, const char *new) { int retcode = GIT_ERROR; int fd = git_futils_creat_withpath(new, 0755, 0644); if (fd >= 0) { retcode = p_write(fd, old, strlen(old)); p_close(fd); } return retcode; } static int cp_by_fd(int ifd, int ofd, bool close_fd_when_done) { int error = 0; char buffer[FILEIO_BUFSIZE]; ssize_t len = 0; while (!error && (len = p_read(ifd, buffer, sizeof(buffer))) > 0) /* p_write() does not have the same semantics as write(). It loops * internally and will return 0 when it has completed writing. */ error = p_write(ofd, buffer, len); if (len < 0) { giterr_set(GITERR_OS, "Read error while copying file"); error = (int)len; } if (error < 0) giterr_set(GITERR_OS, "write error while copying file"); if (close_fd_when_done) { p_close(ifd); p_close(ofd); } return error; } int git_futils_cp(const char *from, const char *to, mode_t filemode) { int ifd, ofd; if ((ifd = git_futils_open_ro(from)) < 0) return ifd; if ((ofd = p_open(to, O_WRONLY | O_CREAT | O_EXCL, filemode)) < 0) { p_close(ifd); return git_path_set_error(errno, to, "open for writing"); } return cp_by_fd(ifd, ofd, true); } static int cp_link(const char *from, const char *to, size_t link_size) { int error = 0; ssize_t read_len; char *link_data; size_t alloc_size; GITERR_CHECK_ALLOC_ADD(&alloc_size, link_size, 1); link_data = git__malloc(alloc_size); GITERR_CHECK_ALLOC(link_data); read_len = p_readlink(from, link_data, link_size); if (read_len != (ssize_t)link_size) { giterr_set(GITERR_OS, "Failed to read symlink data for '%s'", from); error = -1; } else { link_data[read_len] = '\0'; if (p_symlink(link_data, to) < 0) { giterr_set(GITERR_OS, "Could not symlink '%s' as '%s'", link_data, to); error = -1; } } git__free(link_data); return error; } typedef struct { const char *to_root; git_buf to; ssize_t from_prefix; uint32_t flags; uint32_t mkdir_flags; mode_t dirmode; } cp_r_info; #define GIT_CPDIR__MKDIR_DONE_FOR_TO_ROOT (1u << 10) static int _cp_r_mkdir(cp_r_info *info, git_buf *from) { int error = 0; /* create root directory the first time we need to create a directory */ if ((info->flags & GIT_CPDIR__MKDIR_DONE_FOR_TO_ROOT) == 0) { error = git_futils_mkdir( info->to_root, info->dirmode, (info->flags & GIT_CPDIR_CHMOD_DIRS) ? GIT_MKDIR_CHMOD : 0); info->flags |= GIT_CPDIR__MKDIR_DONE_FOR_TO_ROOT; } /* create directory with root as base to prevent excess chmods */ if (!error) error = git_futils_mkdir_relative( from->ptr + info->from_prefix, info->to_root, info->dirmode, info->mkdir_flags, NULL); return error; } static int _cp_r_callback(void *ref, git_buf *from) { int error = 0; cp_r_info *info = ref; struct stat from_st, to_st; bool exists = false; if ((info->flags & GIT_CPDIR_COPY_DOTFILES) == 0 && from->ptr[git_path_basename_offset(from)] == '.') return 0; if ((error = git_buf_joinpath( &info->to, info->to_root, from->ptr + info->from_prefix)) < 0) return error; if (!(error = git_path_lstat(info->to.ptr, &to_st))) exists = true; else if (error != GIT_ENOTFOUND) return error; else { giterr_clear(); error = 0; } if ((error = git_path_lstat(from->ptr, &from_st)) < 0) return error; if (S_ISDIR(from_st.st_mode)) { mode_t oldmode = info->dirmode; /* if we are not chmod'ing, then overwrite dirmode */ if ((info->flags & GIT_CPDIR_CHMOD_DIRS) == 0) info->dirmode = from_st.st_mode; /* make directory now if CREATE_EMPTY_DIRS is requested and needed */ if (!exists && (info->flags & GIT_CPDIR_CREATE_EMPTY_DIRS) != 0) error = _cp_r_mkdir(info, from); /* recurse onto target directory */ if (!error && (!exists || S_ISDIR(to_st.st_mode))) error = git_path_direach(from, 0, _cp_r_callback, info); if (oldmode != 0) info->dirmode = oldmode; return error; } if (exists) { if ((info->flags & GIT_CPDIR_OVERWRITE) == 0) return 0; if (p_unlink(info->to.ptr) < 0) { giterr_set(GITERR_OS, "Cannot overwrite existing file '%s'", info->to.ptr); return GIT_EEXISTS; } } /* Done if this isn't a regular file or a symlink */ if (!S_ISREG(from_st.st_mode) && (!S_ISLNK(from_st.st_mode) || (info->flags & GIT_CPDIR_COPY_SYMLINKS) == 0)) return 0; /* Make container directory on demand if needed */ if ((info->flags & GIT_CPDIR_CREATE_EMPTY_DIRS) == 0 && (error = _cp_r_mkdir(info, from)) < 0) return error; /* make symlink or regular file */ if (info->flags & GIT_CPDIR_LINK_FILES) { if ((error = p_link(from->ptr, info->to.ptr)) < 0) giterr_set(GITERR_OS, "failed to link '%s'", from->ptr); } else if (S_ISLNK(from_st.st_mode)) { error = cp_link(from->ptr, info->to.ptr, (size_t)from_st.st_size); } else { mode_t usemode = from_st.st_mode; if ((info->flags & GIT_CPDIR_SIMPLE_TO_MODE) != 0) usemode = GIT_PERMS_FOR_WRITE(usemode); error = git_futils_cp(from->ptr, info->to.ptr, usemode); } return error; } int git_futils_cp_r( const char *from, const char *to, uint32_t flags, mode_t dirmode) { int error; git_buf path = GIT_BUF_INIT; cp_r_info info; if (git_buf_joinpath(&path, from, "") < 0) /* ensure trailing slash */ return -1; memset(&info, 0, sizeof(info)); info.to_root = to; info.flags = flags; info.dirmode = dirmode; info.from_prefix = path.size; git_buf_init(&info.to, 0); /* precalculate mkdir flags */ if ((flags & GIT_CPDIR_CREATE_EMPTY_DIRS) == 0) { /* if not creating empty dirs, then use mkdir to create the path on * demand right before files are copied. */ info.mkdir_flags = GIT_MKDIR_PATH | GIT_MKDIR_SKIP_LAST; if ((flags & GIT_CPDIR_CHMOD_DIRS) != 0) info.mkdir_flags |= GIT_MKDIR_CHMOD_PATH; } else { /* otherwise, we will do simple mkdir as directories are encountered */ info.mkdir_flags = ((flags & GIT_CPDIR_CHMOD_DIRS) != 0) ? GIT_MKDIR_CHMOD : 0; } error = _cp_r_callback(&info, &path); git_buf_free(&path); git_buf_free(&info.to); return error; } int git_futils_filestamp_check( git_futils_filestamp *stamp, const char *path) { struct stat st; /* if the stamp is NULL, then always reload */ if (stamp == NULL) return 1; if (p_stat(path, &st) < 0) return GIT_ENOTFOUND; if (stamp->mtime == (git_time_t)st.st_mtime && stamp->size == (git_off_t)st.st_size && stamp->ino == (unsigned int)st.st_ino) return 0; stamp->mtime = (git_time_t)st.st_mtime; stamp->size = (git_off_t)st.st_size; stamp->ino = (unsigned int)st.st_ino; return 1; } void git_futils_filestamp_set( git_futils_filestamp *target, const git_futils_filestamp *source) { assert(target); if (source) memcpy(target, source, sizeof(*target)); else memset(target, 0, sizeof(*target)); } void git_futils_filestamp_set_from_stat( git_futils_filestamp *stamp, struct stat *st) { if (st) { stamp->mtime = (git_time_t)st->st_mtime; stamp->size = (git_off_t)st->st_size; stamp->ino = (unsigned int)st->st_ino; } else { memset(stamp, 0, sizeof(*stamp)); } } deps/libgit2-sys-0.3.8/libgit2/src/annotated_commit.c0000664000175000017500000000637512510265101017367 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "annotated_commit.h" #include "git2/commit.h" #include "git2/refs.h" #include "git2/repository.h" #include "git2/annotated_commit.h" #include "git2/revparse.h" static int annotated_commit_init( git_annotated_commit **out, git_repository *repo, const git_oid *id, const char *ref_name, const char *remote_url) { git_annotated_commit *annotated_commit; int error = 0; assert(out && id); *out = NULL; annotated_commit = git__calloc(1, sizeof(git_annotated_commit)); GITERR_CHECK_ALLOC(annotated_commit); if (ref_name) { annotated_commit->ref_name = git__strdup(ref_name); GITERR_CHECK_ALLOC(annotated_commit->ref_name); } if (remote_url) { annotated_commit->remote_url = git__strdup(remote_url); GITERR_CHECK_ALLOC(annotated_commit->remote_url); } git_oid_fmt(annotated_commit->id_str, id); annotated_commit->id_str[GIT_OID_HEXSZ] = '\0'; if ((error = git_commit_lookup(&annotated_commit->commit, repo, id)) < 0) { git_annotated_commit_free(annotated_commit); return error; } *out = annotated_commit; return error; } int git_annotated_commit_from_ref( git_annotated_commit **out, git_repository *repo, const git_reference *ref) { git_reference *resolved; int error = 0; assert(out && repo && ref); *out = NULL; if ((error = git_reference_resolve(&resolved, ref)) < 0) return error; error = annotated_commit_init(out, repo, git_reference_target(resolved), git_reference_name(ref), NULL); git_reference_free(resolved); return error; } int git_annotated_commit_lookup( git_annotated_commit **out, git_repository *repo, const git_oid *id) { assert(out && repo && id); return annotated_commit_init(out, repo, id, NULL, NULL); } int git_annotated_commit_from_fetchhead( git_annotated_commit **out, git_repository *repo, const char *branch_name, const char *remote_url, const git_oid *id) { assert(repo && id && branch_name && remote_url); return annotated_commit_init(out, repo, id, branch_name, remote_url); } int git_annotated_commit_from_revspec( git_annotated_commit **out, git_repository *repo, const char *revspec) { git_object *obj, *commit; int error; assert(out && repo && revspec); if ((error = git_revparse_single(&obj, repo, revspec)) < 0) return error; if ((error = git_object_peel(&commit, obj, GIT_OBJ_COMMIT))) { git_object_free(obj); return error; } error = annotated_commit_init(out, repo, git_object_id(commit), revspec, NULL); git_object_free(obj); git_object_free(commit); return error; } const git_oid *git_annotated_commit_id( const git_annotated_commit *annotated_commit) { assert(annotated_commit); return git_commit_id(annotated_commit->commit); } void git_annotated_commit_free(git_annotated_commit *annotated_commit) { if (annotated_commit == NULL) return; if (annotated_commit->commit != NULL) git_commit_free(annotated_commit->commit); if (annotated_commit->ref_name != NULL) git__free(annotated_commit->ref_name); if (annotated_commit->remote_url != NULL) git__free(annotated_commit->remote_url); git__free(annotated_commit); } deps/libgit2-sys-0.3.8/libgit2/src/attr.c0000664000175000017500000002774712555730137015041 0ustar #include "common.h" #include "repository.h" #include "sysdir.h" #include "config.h" #include "attr_file.h" #include "ignore.h" #include "git2/oid.h" #include GIT__USE_STRMAP const char *git_attr__true = "[internal]__TRUE__"; const char *git_attr__false = "[internal]__FALSE__"; const char *git_attr__unset = "[internal]__UNSET__"; git_attr_t git_attr_value(const char *attr) { if (attr == NULL || attr == git_attr__unset) return GIT_ATTR_UNSPECIFIED_T; if (attr == git_attr__true) return GIT_ATTR_TRUE_T; if (attr == git_attr__false) return GIT_ATTR_FALSE_T; return GIT_ATTR_VALUE_T; } static int collect_attr_files( git_repository *repo, git_attr_session *attr_session, uint32_t flags, const char *path, git_vector *files); static void release_attr_files(git_vector *files); int git_attr_get( const char **value, git_repository *repo, uint32_t flags, const char *pathname, const char *name) { int error; git_attr_path path; git_vector files = GIT_VECTOR_INIT; size_t i, j; git_attr_file *file; git_attr_name attr; git_attr_rule *rule; assert(value && repo && name); *value = NULL; if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), GIT_DIR_FLAG_UNKNOWN) < 0) return -1; if ((error = collect_attr_files(repo, NULL, flags, pathname, &files)) < 0) goto cleanup; memset(&attr, 0, sizeof(attr)); attr.name = name; attr.name_hash = git_attr_file__name_hash(name); git_vector_foreach(&files, i, file) { git_attr_file__foreach_matching_rule(file, &path, j, rule) { size_t pos; if (!git_vector_bsearch(&pos, &rule->assigns, &attr)) { *value = ((git_attr_assignment *)git_vector_get( &rule->assigns, pos))->value; goto cleanup; } } } cleanup: release_attr_files(&files); git_attr_path__free(&path); return error; } typedef struct { git_attr_name name; git_attr_assignment *found; } attr_get_many_info; int git_attr_get_many_with_session( const char **values, git_repository *repo, git_attr_session *attr_session, uint32_t flags, const char *pathname, size_t num_attr, const char **names) { int error; git_attr_path path; git_vector files = GIT_VECTOR_INIT; size_t i, j, k; git_attr_file *file; git_attr_rule *rule; attr_get_many_info *info = NULL; size_t num_found = 0; if (!num_attr) return 0; assert(values && repo && names); if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), GIT_DIR_FLAG_UNKNOWN) < 0) return -1; if ((error = collect_attr_files(repo, attr_session, flags, pathname, &files)) < 0) goto cleanup; info = git__calloc(num_attr, sizeof(attr_get_many_info)); GITERR_CHECK_ALLOC(info); git_vector_foreach(&files, i, file) { git_attr_file__foreach_matching_rule(file, &path, j, rule) { for (k = 0; k < num_attr; k++) { size_t pos; if (info[k].found != NULL) /* already found assignment */ continue; if (!info[k].name.name) { info[k].name.name = names[k]; info[k].name.name_hash = git_attr_file__name_hash(names[k]); } if (!git_vector_bsearch(&pos, &rule->assigns, &info[k].name)) { info[k].found = (git_attr_assignment *) git_vector_get(&rule->assigns, pos); values[k] = info[k].found->value; if (++num_found == num_attr) goto cleanup; } } } } for (k = 0; k < num_attr; k++) { if (!info[k].found) values[k] = NULL; } cleanup: release_attr_files(&files); git_attr_path__free(&path); git__free(info); return error; } int git_attr_get_many( const char **values, git_repository *repo, uint32_t flags, const char *pathname, size_t num_attr, const char **names) { return git_attr_get_many_with_session( values, repo, NULL, flags, pathname, num_attr, names); } int git_attr_foreach( git_repository *repo, uint32_t flags, const char *pathname, int (*callback)(const char *name, const char *value, void *payload), void *payload) { int error; git_attr_path path; git_vector files = GIT_VECTOR_INIT; size_t i, j, k; git_attr_file *file; git_attr_rule *rule; git_attr_assignment *assign; git_strmap *seen = NULL; assert(repo && callback); if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), GIT_DIR_FLAG_UNKNOWN) < 0) return -1; if ((error = collect_attr_files(repo, NULL, flags, pathname, &files)) < 0 || (error = git_strmap_alloc(&seen)) < 0) goto cleanup; git_vector_foreach(&files, i, file) { git_attr_file__foreach_matching_rule(file, &path, j, rule) { git_vector_foreach(&rule->assigns, k, assign) { /* skip if higher priority assignment was already seen */ if (git_strmap_exists(seen, assign->name)) continue; git_strmap_insert(seen, assign->name, assign, error); if (error < 0) goto cleanup; error = callback(assign->name, assign->value, payload); if (error) { giterr_set_after_callback(error); goto cleanup; } } } } cleanup: git_strmap_free(seen); release_attr_files(&files); git_attr_path__free(&path); return error; } static int preload_attr_file( git_repository *repo, git_attr_session *attr_session, git_attr_file_source source, const char *base, const char *file) { int error; git_attr_file *preload = NULL; if (!file) return 0; if (!(error = git_attr_cache__get( &preload, repo, attr_session, source, base, file, git_attr_file__parse_buffer))) git_attr_file__free(preload); return error; } static int system_attr_file( git_buf *out, git_attr_session *attr_session) { int error; if (!attr_session) { error = git_sysdir_find_system_file(out, GIT_ATTR_FILE_SYSTEM); if (error == GIT_ENOTFOUND) giterr_clear(); return error; } if (!attr_session->init_sysdir) { error = git_sysdir_find_system_file(&attr_session->sysdir, GIT_ATTR_FILE_SYSTEM); if (error == GIT_ENOTFOUND) giterr_clear(); else if (error) return error; attr_session->init_sysdir = 1; } if (attr_session->sysdir.size == 0) return GIT_ENOTFOUND; /* We can safely provide a git_buf with no allocation (asize == 0) to * a consumer. This allows them to treat this as a regular `git_buf`, * but their call to `git_buf_free` will not attempt to free it. */ git_buf_attach_notowned( out, attr_session->sysdir.ptr, attr_session->sysdir.size); return 0; } static int attr_setup(git_repository *repo, git_attr_session *attr_session) { int error = 0; const char *workdir = git_repository_workdir(repo); git_index *idx = NULL; git_buf sys = GIT_BUF_INIT; if (attr_session && attr_session->init_setup) return 0; if ((error = git_attr_cache__init(repo)) < 0) return error; /* preload attribute files that could contain macros so the * definitions will be available for later file parsing */ error = system_attr_file(&sys, attr_session); if (error == 0) error = preload_attr_file( repo, attr_session, GIT_ATTR_FILE__FROM_FILE, NULL, sys.ptr); if (error != GIT_ENOTFOUND) return error; git_buf_free(&sys); if ((error = preload_attr_file( repo, attr_session, GIT_ATTR_FILE__FROM_FILE, NULL, git_repository_attr_cache(repo)->cfg_attr_file)) < 0) return error; if ((error = preload_attr_file( repo, attr_session, GIT_ATTR_FILE__FROM_FILE, git_repository_path(repo), GIT_ATTR_FILE_INREPO)) < 0) return error; if (workdir != NULL && (error = preload_attr_file( repo, attr_session, GIT_ATTR_FILE__FROM_FILE, workdir, GIT_ATTR_FILE)) < 0) return error; if ((error = git_repository_index__weakptr(&idx, repo)) < 0 || (error = preload_attr_file( repo, attr_session, GIT_ATTR_FILE__FROM_INDEX, NULL, GIT_ATTR_FILE)) < 0) return error; if (attr_session) attr_session->init_setup = 1; return error; } int git_attr_add_macro( git_repository *repo, const char *name, const char *values) { int error; git_attr_rule *macro = NULL; git_pool *pool; if ((error = git_attr_cache__init(repo)) < 0) return error; macro = git__calloc(1, sizeof(git_attr_rule)); GITERR_CHECK_ALLOC(macro); pool = &git_repository_attr_cache(repo)->pool; macro->match.pattern = git_pool_strdup(pool, name); GITERR_CHECK_ALLOC(macro->match.pattern); macro->match.length = strlen(macro->match.pattern); macro->match.flags = GIT_ATTR_FNMATCH_MACRO; error = git_attr_assignment__parse(repo, pool, ¯o->assigns, &values); if (!error) error = git_attr_cache__insert_macro(repo, macro); if (error < 0) git_attr_rule__free(macro); return error; } typedef struct { git_repository *repo; git_attr_session *attr_session; uint32_t flags; const char *workdir; git_index *index; git_vector *files; } attr_walk_up_info; static int attr_decide_sources( uint32_t flags, bool has_wd, bool has_index, git_attr_file_source *srcs) { int count = 0; switch (flags & 0x03) { case GIT_ATTR_CHECK_FILE_THEN_INDEX: if (has_wd) srcs[count++] = GIT_ATTR_FILE__FROM_FILE; if (has_index) srcs[count++] = GIT_ATTR_FILE__FROM_INDEX; break; case GIT_ATTR_CHECK_INDEX_THEN_FILE: if (has_index) srcs[count++] = GIT_ATTR_FILE__FROM_INDEX; if (has_wd) srcs[count++] = GIT_ATTR_FILE__FROM_FILE; break; case GIT_ATTR_CHECK_INDEX_ONLY: if (has_index) srcs[count++] = GIT_ATTR_FILE__FROM_INDEX; break; } return count; } static int push_attr_file( git_repository *repo, git_attr_session *attr_session, git_vector *list, git_attr_file_source source, const char *base, const char *filename) { int error = 0; git_attr_file *file = NULL; error = git_attr_cache__get(&file, repo, attr_session, source, base, filename, git_attr_file__parse_buffer); if (error < 0) return error; if (file != NULL) { if ((error = git_vector_insert(list, file)) < 0) git_attr_file__free(file); } return error; } static int push_one_attr(void *ref, const char *path) { int error = 0, n_src, i; attr_walk_up_info *info = (attr_walk_up_info *)ref; git_attr_file_source src[2]; n_src = attr_decide_sources( info->flags, info->workdir != NULL, info->index != NULL, src); for (i = 0; !error && i < n_src; ++i) error = push_attr_file(info->repo, info->attr_session, info->files, src[i], path, GIT_ATTR_FILE); return error; } static void release_attr_files(git_vector *files) { size_t i; git_attr_file *file; git_vector_foreach(files, i, file) { git_attr_file__free(file); files->contents[i] = NULL; } git_vector_free(files); } static int collect_attr_files( git_repository *repo, git_attr_session *attr_session, uint32_t flags, const char *path, git_vector *files) { int error = 0; git_buf dir = GIT_BUF_INIT; const char *workdir = git_repository_workdir(repo); attr_walk_up_info info = { NULL }; if ((error = attr_setup(repo, attr_session)) < 0) return error; /* Resolve path in a non-bare repo */ if (workdir != NULL) error = git_path_find_dir(&dir, path, workdir); else error = git_path_dirname_r(&dir, path); if (error < 0) goto cleanup; /* in precendence order highest to lowest: * - $GIT_DIR/info/attributes * - path components with .gitattributes * - config core.attributesfile * - $GIT_PREFIX/etc/gitattributes */ error = push_attr_file( repo, attr_session, files, GIT_ATTR_FILE__FROM_FILE, git_repository_path(repo), GIT_ATTR_FILE_INREPO); if (error < 0) goto cleanup; info.repo = repo; info.attr_session = attr_session; info.flags = flags; info.workdir = workdir; if (git_repository_index__weakptr(&info.index, repo) < 0) giterr_clear(); /* no error even if there is no index */ info.files = files; if (!strcmp(dir.ptr, ".")) error = push_one_attr(&info, ""); else error = git_path_walk_up(&dir, workdir, push_one_attr, &info); if (error < 0) goto cleanup; if (git_repository_attr_cache(repo)->cfg_attr_file != NULL) { error = push_attr_file( repo, attr_session, files, GIT_ATTR_FILE__FROM_FILE, NULL, git_repository_attr_cache(repo)->cfg_attr_file); if (error < 0) goto cleanup; } if ((flags & GIT_ATTR_CHECK_NO_SYSTEM) == 0) { error = system_attr_file(&dir, attr_session); if (!error) error = push_attr_file( repo, attr_session, files, GIT_ATTR_FILE__FROM_FILE, NULL, dir.ptr); else if (error == GIT_ENOTFOUND) error = 0; } cleanup: if (error < 0) release_attr_files(files); git_buf_free(&dir); return error; } deps/libgit2-sys-0.3.8/libgit2/src/refdb_fs.h0000664000175000017500000000055112426525445015627 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_refdb_fs_h__ #define INCLUDE_refdb_fs_h__ typedef struct { git_strmap *packfile; time_t packfile_time; } git_refcache; #endif deps/libgit2-sys-0.3.8/libgit2/src/commit.c0000664000175000017500000003314112555730137015340 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/common.h" #include "git2/object.h" #include "git2/repository.h" #include "git2/signature.h" #include "git2/sys/commit.h" #include "common.h" #include "odb.h" #include "commit.h" #include "signature.h" #include "message.h" #include "refs.h" void git_commit__free(void *_commit) { git_commit *commit = _commit; git_array_clear(commit->parent_ids); git_signature_free(commit->author); git_signature_free(commit->committer); git__free(commit->raw_header); git__free(commit->raw_message); git__free(commit->message_encoding); git__free(commit->summary); git__free(commit); } int git_commit_create_from_callback( git_oid *id, git_repository *repo, const char *update_ref, const git_signature *author, const git_signature *committer, const char *message_encoding, const char *message, const git_oid *tree, git_commit_parent_callback parent_cb, void *parent_payload) { git_reference *ref = NULL; int error = 0, matched_parent = 0; const git_oid *current_id = NULL; git_buf commit = GIT_BUF_INIT; size_t i = 0; git_odb *odb; const git_oid *parent; assert(id && repo && tree && parent_cb); if (update_ref) { error = git_reference_lookup_resolved(&ref, repo, update_ref, 10); if (error < 0 && error != GIT_ENOTFOUND) return error; } giterr_clear(); if (ref) current_id = git_reference_target(ref); git_oid__writebuf(&commit, "tree ", tree); while ((parent = parent_cb(i, parent_payload)) != NULL) { git_oid__writebuf(&commit, "parent ", parent); if (i == 0 && current_id && git_oid_equal(current_id, parent)) matched_parent = 1; i++; } if (ref && !matched_parent) { git_reference_free(ref); git_buf_free(&commit); giterr_set(GITERR_OBJECT, "failed to create commit: current tip is not the first parent"); return GIT_EMODIFIED; } git_signature__writebuf(&commit, "author ", author); git_signature__writebuf(&commit, "committer ", committer); if (message_encoding != NULL) git_buf_printf(&commit, "encoding %s\n", message_encoding); git_buf_putc(&commit, '\n'); if (git_buf_puts(&commit, message) < 0) goto on_error; if (git_repository_odb__weakptr(&odb, repo) < 0) goto on_error; if (git_odb_write(id, odb, commit.ptr, commit.size, GIT_OBJ_COMMIT) < 0) goto on_error; git_buf_free(&commit); if (update_ref != NULL) { error = git_reference__update_for_commit( repo, ref, update_ref, id, "commit"); git_reference_free(ref); return error; } return 0; on_error: git_buf_free(&commit); giterr_set(GITERR_OBJECT, "Failed to create commit."); return -1; } typedef struct { size_t total; va_list args; } commit_parent_varargs; static const git_oid *commit_parent_from_varargs(size_t curr, void *payload) { commit_parent_varargs *data = payload; const git_commit *commit; if (curr >= data->total) return NULL; commit = va_arg(data->args, const git_commit *); return commit ? git_commit_id(commit) : NULL; } int git_commit_create_v( git_oid *id, git_repository *repo, const char *update_ref, const git_signature *author, const git_signature *committer, const char *message_encoding, const char *message, const git_tree *tree, size_t parent_count, ...) { int error = 0; commit_parent_varargs data; assert(tree && git_tree_owner(tree) == repo); data.total = parent_count; va_start(data.args, parent_count); error = git_commit_create_from_callback( id, repo, update_ref, author, committer, message_encoding, message, git_tree_id(tree), commit_parent_from_varargs, &data); va_end(data.args); return error; } typedef struct { size_t total; const git_oid **parents; } commit_parent_oids; static const git_oid *commit_parent_from_ids(size_t curr, void *payload) { commit_parent_oids *data = payload; return (curr < data->total) ? data->parents[curr] : NULL; } int git_commit_create_from_ids( git_oid *id, git_repository *repo, const char *update_ref, const git_signature *author, const git_signature *committer, const char *message_encoding, const char *message, const git_oid *tree, size_t parent_count, const git_oid *parents[]) { commit_parent_oids data = { parent_count, parents }; return git_commit_create_from_callback( id, repo, update_ref, author, committer, message_encoding, message, tree, commit_parent_from_ids, &data); } typedef struct { size_t total; const git_commit **parents; git_repository *repo; } commit_parent_data; static const git_oid *commit_parent_from_array(size_t curr, void *payload) { commit_parent_data *data = payload; const git_commit *commit; if (curr >= data->total) return NULL; commit = data->parents[curr]; if (git_commit_owner(commit) != data->repo) return NULL; return git_commit_id(commit); } int git_commit_create( git_oid *id, git_repository *repo, const char *update_ref, const git_signature *author, const git_signature *committer, const char *message_encoding, const char *message, const git_tree *tree, size_t parent_count, const git_commit *parents[]) { commit_parent_data data = { parent_count, parents, repo }; assert(tree && git_tree_owner(tree) == repo); return git_commit_create_from_callback( id, repo, update_ref, author, committer, message_encoding, message, git_tree_id(tree), commit_parent_from_array, &data); } static const git_oid *commit_parent_for_amend(size_t curr, void *payload) { const git_commit *commit_to_amend = payload; if (curr >= git_array_size(commit_to_amend->parent_ids)) return NULL; return git_array_get(commit_to_amend->parent_ids, curr); } int git_commit_amend( git_oid *id, const git_commit *commit_to_amend, const char *update_ref, const git_signature *author, const git_signature *committer, const char *message_encoding, const char *message, const git_tree *tree) { git_repository *repo; git_oid tree_id; git_reference *ref; int error; assert(id && commit_to_amend); repo = git_commit_owner(commit_to_amend); if (!author) author = git_commit_author(commit_to_amend); if (!committer) committer = git_commit_committer(commit_to_amend); if (!message_encoding) message_encoding = git_commit_message_encoding(commit_to_amend); if (!message) message = git_commit_message(commit_to_amend); if (!tree) { git_tree *old_tree; GITERR_CHECK_ERROR( git_commit_tree(&old_tree, commit_to_amend) ); git_oid_cpy(&tree_id, git_tree_id(old_tree)); git_tree_free(old_tree); } else { assert(git_tree_owner(tree) == repo); git_oid_cpy(&tree_id, git_tree_id(tree)); } if (update_ref) { if ((error = git_reference_lookup_resolved(&ref, repo, update_ref, 5)) < 0) return error; if (git_oid_cmp(git_commit_id(commit_to_amend), git_reference_target(ref))) { git_reference_free(ref); giterr_set(GITERR_REFERENCE, "commit to amend is not the tip of the given branch"); return -1; } } error = git_commit_create_from_callback( id, repo, NULL, author, committer, message_encoding, message, &tree_id, commit_parent_for_amend, (void *)commit_to_amend); if (!error && update_ref) { error = git_reference__update_for_commit( repo, ref, NULL, id, "commit"); git_reference_free(ref); } return error; } int git_commit__parse(void *_commit, git_odb_object *odb_obj) { git_commit *commit = _commit; const char *buffer_start = git_odb_object_data(odb_obj), *buffer; const char *buffer_end = buffer_start + git_odb_object_size(odb_obj); git_oid parent_id; size_t header_len; git_signature dummy_sig; buffer = buffer_start; /* Allocate for one, which will allow not to realloc 90% of the time */ git_array_init_to_size(commit->parent_ids, 1); GITERR_CHECK_ARRAY(commit->parent_ids); /* The tree is always the first field */ if (git_oid__parse(&commit->tree_id, &buffer, buffer_end, "tree ") < 0) goto bad_buffer; /* * TODO: commit grafts! */ while (git_oid__parse(&parent_id, &buffer, buffer_end, "parent ") == 0) { git_oid *new_id = git_array_alloc(commit->parent_ids); GITERR_CHECK_ALLOC(new_id); git_oid_cpy(new_id, &parent_id); } commit->author = git__malloc(sizeof(git_signature)); GITERR_CHECK_ALLOC(commit->author); if (git_signature__parse(commit->author, &buffer, buffer_end, "author ", '\n') < 0) return -1; /* Some tools create multiple author fields, ignore the extra ones */ while ((size_t)(buffer_end - buffer) >= strlen("author ") && !git__prefixcmp(buffer, "author ")) { if (git_signature__parse(&dummy_sig, &buffer, buffer_end, "author ", '\n') < 0) return -1; git__free(dummy_sig.name); git__free(dummy_sig.email); } /* Always parse the committer; we need the commit time */ commit->committer = git__malloc(sizeof(git_signature)); GITERR_CHECK_ALLOC(commit->committer); if (git_signature__parse(commit->committer, &buffer, buffer_end, "committer ", '\n') < 0) return -1; /* Parse add'l header entries */ while (buffer < buffer_end) { const char *eoln = buffer; if (buffer[-1] == '\n' && buffer[0] == '\n') break; while (eoln < buffer_end && *eoln != '\n') ++eoln; if (git__prefixcmp(buffer, "encoding ") == 0) { buffer += strlen("encoding "); commit->message_encoding = git__strndup(buffer, eoln - buffer); GITERR_CHECK_ALLOC(commit->message_encoding); } if (eoln < buffer_end && *eoln == '\n') ++eoln; buffer = eoln; } header_len = buffer - buffer_start; commit->raw_header = git__strndup(buffer_start, header_len); GITERR_CHECK_ALLOC(commit->raw_header); /* point "buffer" to data after header, +1 for the final LF */ buffer = buffer_start + header_len + 1; /* extract commit message */ if (buffer <= buffer_end) { commit->raw_message = git__strndup(buffer, buffer_end - buffer); GITERR_CHECK_ALLOC(commit->raw_message); } return 0; bad_buffer: giterr_set(GITERR_OBJECT, "Failed to parse bad commit object"); return -1; } #define GIT_COMMIT_GETTER(_rvalue, _name, _return) \ _rvalue git_commit_##_name(const git_commit *commit) \ {\ assert(commit); \ return _return; \ } GIT_COMMIT_GETTER(const git_signature *, author, commit->author) GIT_COMMIT_GETTER(const git_signature *, committer, commit->committer) GIT_COMMIT_GETTER(const char *, message_raw, commit->raw_message) GIT_COMMIT_GETTER(const char *, message_encoding, commit->message_encoding) GIT_COMMIT_GETTER(const char *, raw_header, commit->raw_header) GIT_COMMIT_GETTER(git_time_t, time, commit->committer->when.time) GIT_COMMIT_GETTER(int, time_offset, commit->committer->when.offset) GIT_COMMIT_GETTER(unsigned int, parentcount, (unsigned int)git_array_size(commit->parent_ids)) GIT_COMMIT_GETTER(const git_oid *, tree_id, &commit->tree_id) const char *git_commit_message(const git_commit *commit) { const char *message; assert(commit); message = commit->raw_message; /* trim leading newlines from raw message */ while (*message && *message == '\n') ++message; return message; } const char *git_commit_summary(git_commit *commit) { git_buf summary = GIT_BUF_INIT; const char *msg, *space; assert(commit); if (!commit->summary) { for (msg = git_commit_message(commit), space = NULL; *msg; ++msg) { if (msg[0] == '\n' && (!msg[1] || msg[1] == '\n')) break; else if (msg[0] == '\n') git_buf_putc(&summary, ' '); else if (git__isspace(msg[0])) space = space ? space : msg; else if (space) { git_buf_put(&summary, space, (msg - space) + 1); space = NULL; } else git_buf_putc(&summary, *msg); } commit->summary = git_buf_detach(&summary); if (!commit->summary) commit->summary = git__strdup(""); } return commit->summary; } int git_commit_tree(git_tree **tree_out, const git_commit *commit) { assert(commit); return git_tree_lookup(tree_out, commit->object.repo, &commit->tree_id); } const git_oid *git_commit_parent_id( const git_commit *commit, unsigned int n) { assert(commit); return git_array_get(commit->parent_ids, n); } int git_commit_parent( git_commit **parent, const git_commit *commit, unsigned int n) { const git_oid *parent_id; assert(commit); parent_id = git_commit_parent_id(commit, n); if (parent_id == NULL) { giterr_set(GITERR_INVALID, "Parent %u does not exist", n); return GIT_ENOTFOUND; } return git_commit_lookup(parent, commit->object.repo, parent_id); } int git_commit_nth_gen_ancestor( git_commit **ancestor, const git_commit *commit, unsigned int n) { git_commit *current, *parent = NULL; int error; assert(ancestor && commit); if (git_object_dup((git_object **) ¤t, (git_object *) commit) < 0) return -1; if (n == 0) { *ancestor = current; return 0; } while (n--) { error = git_commit_parent(&parent, current, 0); git_commit_free(current); if (error < 0) return error; current = parent; } *ancestor = parent; return 0; } int git_commit_header_field(git_buf *out, const git_commit *commit, const char *field) { const char *buf = commit->raw_header; const char *h, *eol; git_buf_sanitize(out); while ((h = strchr(buf, '\n')) && h[1] != '\0' && h[1] != '\n') { h++; if (git__prefixcmp(h, field)) { buf = h; continue; } h += strlen(field); eol = strchr(h, '\n'); if (h[0] != ' ') { buf = h; continue; } if (!eol) goto malformed; h++; /* skip the SP */ git_buf_put(out, h, eol - h); if (git_buf_oom(out)) goto oom; /* If the next line starts with SP, it's multi-line, we must continue */ while (eol[1] == ' ') { git_buf_putc(out, '\n'); h = eol + 2; eol = strchr(h, '\n'); if (!eol) goto malformed; git_buf_put(out, h, eol - h); } if (git_buf_oom(out)) goto oom; return 0; } return GIT_ENOTFOUND; malformed: giterr_set(GITERR_OBJECT, "malformed header"); return -1; oom: giterr_set_oom(); return -1; } deps/libgit2-sys-0.3.8/libgit2/src/odb_pack.c0000664000175000017500000003762712610310643015613 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include #include "git2/repository.h" #include "git2/indexer.h" #include "git2/sys/odb_backend.h" #include "fileops.h" #include "hash.h" #include "odb.h" #include "delta-apply.h" #include "sha1_lookup.h" #include "mwindow.h" #include "pack.h" #include "git2/odb_backend.h" struct pack_backend { git_odb_backend parent; git_vector packs; struct git_pack_file *last_found; char *pack_folder; }; struct pack_writepack { struct git_odb_writepack parent; git_indexer *indexer; }; /** * The wonderful tale of a Packed Object lookup query * =================================================== * A riveting and epic story of epicness and ASCII * art, presented by yours truly, * Sir Vicent of Marti * * * Chapter 1: Once upon a time... * Initialization of the Pack Backend * -------------------------------------------------- * * # git_odb_backend_pack * | Creates the pack backend structure, initializes the * | callback pointers to our default read() and exist() methods, * | and tries to preload all the known packfiles in the ODB. * | * |-# packfile_load_all * | Tries to find the `pack` folder, if it exists. ODBs without * | a pack folder are ignored altogether. If there's a `pack` folder * | we run a `dirent` callback through every file in the pack folder * | to find our packfiles. The packfiles are then sorted according * | to a sorting callback. * | * |-# packfile_load__cb * | | This callback is called from `dirent` with every single file * | | inside the pack folder. We find the packs by actually locating * | | their index (ends in ".idx"). From that index, we verify that * | | the corresponding packfile exists and is valid, and if so, we * | | add it to the pack list. * | | * | |-# packfile_check * | Make sure that there's a packfile to back this index, and store * | some very basic information regarding the packfile itself, * | such as the full path, the size, and the modification time. * | We don't actually open the packfile to check for internal consistency. * | * |-# packfile_sort__cb * Sort all the preloaded packs according to some specific criteria: * we prioritize the "newer" packs because it's more likely they * contain the objects we are looking for, and we prioritize local * packs over remote ones. * * * * Chapter 2: To be, or not to be... * A standard packed `exist` query for an OID * -------------------------------------------------- * * # pack_backend__exists * | Check if the given SHA1 oid exists in any of the packs * | that have been loaded for our ODB. * | * |-# pack_entry_find * | Iterate through all the packs that have been preloaded * | (starting by the pack where the latest object was found) * | to try to find the OID in one of them. * | * |-# pack_entry_find1 * | Check the index of an individual pack to see if the SHA1 * | OID can be found. If we can find the offset to that SHA1 * | inside of the index, that means the object is contained * | inside of the packfile and we can stop searching. * | Before returning, we verify that the packfile behing the * | index we are searching still exists on disk. * | * |-# pack_entry_find_offset * | | Mmap the actual index file to disk if it hasn't been opened * | | yet, and run a binary search through it to find the OID. * | | See for specifics * | | on the Packfile Index format and how do we find entries in it. * | | * | |-# pack_index_open * | | Guess the name of the index based on the full path to the * | | packfile, open it and verify its contents. Only if the index * | | has not been opened already. * | | * | |-# pack_index_check * | Mmap the index file and do a quick run through the header * | to guess the index version (right now we support v1 and v2), * | and to verify that the size of the index makes sense. * | * |-# packfile_open * See `packfile_open` in Chapter 3 * * * * Chapter 3: The neverending story... * A standard packed `lookup` query for an OID * -------------------------------------------------- * TODO * */ /*********************************************************** * * FORWARD DECLARATIONS * ***********************************************************/ static int packfile_sort__cb(const void *a_, const void *b_); static int packfile_load__cb(void *_data, git_buf *path); static int pack_entry_find(struct git_pack_entry *e, struct pack_backend *backend, const git_oid *oid); /* Can find the offset of an object given * a prefix of an identifier. * Sets GIT_EAMBIGUOUS if short oid is ambiguous. * This method assumes that len is between * GIT_OID_MINPREFIXLEN and GIT_OID_HEXSZ. */ static int pack_entry_find_prefix( struct git_pack_entry *e, struct pack_backend *backend, const git_oid *short_oid, size_t len); /*********************************************************** * * PACK WINDOW MANAGEMENT * ***********************************************************/ static int packfile_sort__cb(const void *a_, const void *b_) { const struct git_pack_file *a = a_; const struct git_pack_file *b = b_; int st; /* * Local packs tend to contain objects specific to our * variant of the project than remote ones. In addition, * remote ones could be on a network mounted filesystem. * Favor local ones for these reasons. */ st = a->pack_local - b->pack_local; if (st) return -st; /* * Younger packs tend to contain more recent objects, * and more recent objects tend to get accessed more * often. */ if (a->mtime < b->mtime) return 1; else if (a->mtime == b->mtime) return 0; return -1; } static int packfile_load__cb(void *data, git_buf *path) { struct pack_backend *backend = data; struct git_pack_file *pack; const char *path_str = git_buf_cstr(path); size_t i, cmp_len = git_buf_len(path); int error; if (cmp_len <= strlen(".idx") || git__suffixcmp(path_str, ".idx") != 0) return 0; /* not an index */ cmp_len -= strlen(".idx"); for (i = 0; i < backend->packs.length; ++i) { struct git_pack_file *p = git_vector_get(&backend->packs, i); if (memcmp(p->pack_name, path_str, cmp_len) == 0) return 0; } error = git_mwindow_get_pack(&pack, path->ptr); /* ignore missing .pack file as git does */ if (error == GIT_ENOTFOUND) { giterr_clear(); return 0; } if (!error) error = git_vector_insert(&backend->packs, pack); return error; } static int pack_entry_find_inner( struct git_pack_entry *e, struct pack_backend *backend, const git_oid *oid, struct git_pack_file *last_found) { size_t i; if (last_found && git_pack_entry_find(e, last_found, oid, GIT_OID_HEXSZ) == 0) return 0; for (i = 0; i < backend->packs.length; ++i) { struct git_pack_file *p; p = git_vector_get(&backend->packs, i); if (p == last_found) continue; if (git_pack_entry_find(e, p, oid, GIT_OID_HEXSZ) == 0) { backend->last_found = p; return 0; } } return -1; } static int pack_entry_find(struct git_pack_entry *e, struct pack_backend *backend, const git_oid *oid) { struct git_pack_file *last_found = backend->last_found; if (backend->last_found && git_pack_entry_find(e, backend->last_found, oid, GIT_OID_HEXSZ) == 0) return 0; if (!pack_entry_find_inner(e, backend, oid, last_found)) return 0; return git_odb__error_notfound("failed to find pack entry", oid); } static int pack_entry_find_prefix( struct git_pack_entry *e, struct pack_backend *backend, const git_oid *short_oid, size_t len) { int error; size_t i; git_oid found_full_oid = {{0}}; bool found = false; struct git_pack_file *last_found = backend->last_found; if (last_found) { error = git_pack_entry_find(e, last_found, short_oid, len); if (error == GIT_EAMBIGUOUS) return error; if (!error) { git_oid_cpy(&found_full_oid, &e->sha1); found = true; } } for (i = 0; i < backend->packs.length; ++i) { struct git_pack_file *p; p = git_vector_get(&backend->packs, i); if (p == last_found) continue; error = git_pack_entry_find(e, p, short_oid, len); if (error == GIT_EAMBIGUOUS) return error; if (!error) { if (found && git_oid_cmp(&e->sha1, &found_full_oid)) return git_odb__error_ambiguous("found multiple pack entries"); git_oid_cpy(&found_full_oid, &e->sha1); found = true; backend->last_found = p; } } if (!found) return git_odb__error_notfound("no matching pack entry for prefix", short_oid); else return 0; } /*********************************************************** * * PACKED BACKEND PUBLIC API * * Implement the git_odb_backend API calls * ***********************************************************/ static int pack_backend__refresh(git_odb_backend *backend_) { int error; struct stat st; git_buf path = GIT_BUF_INIT; struct pack_backend *backend = (struct pack_backend *)backend_; if (backend->pack_folder == NULL) return 0; if (p_stat(backend->pack_folder, &st) < 0 || !S_ISDIR(st.st_mode)) return git_odb__error_notfound("failed to refresh packfiles", NULL); git_buf_sets(&path, backend->pack_folder); /* reload all packs */ error = git_path_direach(&path, 0, packfile_load__cb, backend); git_buf_free(&path); git_vector_sort(&backend->packs); return error; } static int pack_backend__read_header( size_t *len_p, git_otype *type_p, struct git_odb_backend *backend, const git_oid *oid) { struct git_pack_entry e; int error; assert(len_p && type_p && backend && oid); if ((error = pack_entry_find(&e, (struct pack_backend *)backend, oid)) < 0) return error; return git_packfile_resolve_header(len_p, type_p, e.p, e.offset); } static int pack_backend__read( void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid) { struct git_pack_entry e; git_rawobj raw = {NULL}; int error; if ((error = pack_entry_find(&e, (struct pack_backend *)backend, oid)) < 0 || (error = git_packfile_unpack(&raw, e.p, &e.offset)) < 0) return error; *buffer_p = raw.data; *len_p = raw.len; *type_p = raw.type; return 0; } static int pack_backend__read_prefix( git_oid *out_oid, void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *short_oid, size_t len) { int error = 0; if (len < GIT_OID_MINPREFIXLEN) error = git_odb__error_ambiguous("prefix length too short"); else if (len >= GIT_OID_HEXSZ) { /* We can fall back to regular read method */ error = pack_backend__read(buffer_p, len_p, type_p, backend, short_oid); if (!error) git_oid_cpy(out_oid, short_oid); } else { struct git_pack_entry e; git_rawobj raw; if ((error = pack_entry_find_prefix( &e, (struct pack_backend *)backend, short_oid, len)) == 0 && (error = git_packfile_unpack(&raw, e.p, &e.offset)) == 0) { *buffer_p = raw.data; *len_p = raw.len; *type_p = raw.type; git_oid_cpy(out_oid, &e.sha1); } } return error; } static int pack_backend__exists(git_odb_backend *backend, const git_oid *oid) { struct git_pack_entry e; return pack_entry_find(&e, (struct pack_backend *)backend, oid) == 0; } static int pack_backend__exists_prefix( git_oid *out, git_odb_backend *backend, const git_oid *short_id, size_t len) { int error; struct pack_backend *pb = (struct pack_backend *)backend; struct git_pack_entry e = {0}; error = pack_entry_find_prefix(&e, pb, short_id, len); git_oid_cpy(out, &e.sha1); return error; } static int pack_backend__foreach(git_odb_backend *_backend, git_odb_foreach_cb cb, void *data) { int error; struct git_pack_file *p; struct pack_backend *backend; unsigned int i; assert(_backend && cb); backend = (struct pack_backend *)_backend; /* Make sure we know about the packfiles */ if ((error = pack_backend__refresh(_backend)) < 0) return error; git_vector_foreach(&backend->packs, i, p) { if ((error = git_pack_foreach_entry(p, cb, data)) < 0) return error; } return 0; } static int pack_backend__writepack_append(struct git_odb_writepack *_writepack, const void *data, size_t size, git_transfer_progress *stats) { struct pack_writepack *writepack = (struct pack_writepack *)_writepack; assert(writepack); return git_indexer_append(writepack->indexer, data, size, stats); } static int pack_backend__writepack_commit(struct git_odb_writepack *_writepack, git_transfer_progress *stats) { struct pack_writepack *writepack = (struct pack_writepack *)_writepack; assert(writepack); return git_indexer_commit(writepack->indexer, stats); } static void pack_backend__writepack_free(struct git_odb_writepack *_writepack) { struct pack_writepack *writepack = (struct pack_writepack *)_writepack; assert(writepack); git_indexer_free(writepack->indexer); git__free(writepack); } static int pack_backend__writepack(struct git_odb_writepack **out, git_odb_backend *_backend, git_odb *odb, git_transfer_progress_cb progress_cb, void *progress_payload) { struct pack_backend *backend; struct pack_writepack *writepack; assert(out && _backend); *out = NULL; backend = (struct pack_backend *)_backend; writepack = git__calloc(1, sizeof(struct pack_writepack)); GITERR_CHECK_ALLOC(writepack); if (git_indexer_new(&writepack->indexer, backend->pack_folder, 0, odb, progress_cb, progress_payload) < 0) { git__free(writepack); return -1; } writepack->parent.backend = _backend; writepack->parent.append = pack_backend__writepack_append; writepack->parent.commit = pack_backend__writepack_commit; writepack->parent.free = pack_backend__writepack_free; *out = (git_odb_writepack *)writepack; return 0; } static void pack_backend__free(git_odb_backend *_backend) { struct pack_backend *backend; size_t i; assert(_backend); backend = (struct pack_backend *)_backend; for (i = 0; i < backend->packs.length; ++i) { struct git_pack_file *p = git_vector_get(&backend->packs, i); git_mwindow_put_pack(p); } git_vector_free(&backend->packs); git__free(backend->pack_folder); git__free(backend); } static int pack_backend__alloc(struct pack_backend **out, size_t initial_size) { struct pack_backend *backend = git__calloc(1, sizeof(struct pack_backend)); GITERR_CHECK_ALLOC(backend); if (git_vector_init(&backend->packs, initial_size, packfile_sort__cb) < 0) { git__free(backend); return -1; } backend->parent.version = GIT_ODB_BACKEND_VERSION; backend->parent.read = &pack_backend__read; backend->parent.read_prefix = &pack_backend__read_prefix; backend->parent.read_header = &pack_backend__read_header; backend->parent.exists = &pack_backend__exists; backend->parent.exists_prefix = &pack_backend__exists_prefix; backend->parent.refresh = &pack_backend__refresh; backend->parent.foreach = &pack_backend__foreach; backend->parent.writepack = &pack_backend__writepack; backend->parent.free = &pack_backend__free; *out = backend; return 0; } int git_odb_backend_one_pack(git_odb_backend **backend_out, const char *idx) { struct pack_backend *backend = NULL; struct git_pack_file *packfile = NULL; if (pack_backend__alloc(&backend, 1) < 0) return -1; if (git_mwindow_get_pack(&packfile, idx) < 0 || git_vector_insert(&backend->packs, packfile) < 0) { pack_backend__free((git_odb_backend *)backend); return -1; } *backend_out = (git_odb_backend *)backend; return 0; } int git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir) { int error = 0; struct pack_backend *backend = NULL; git_buf path = GIT_BUF_INIT; if (git_mwindow_files_init() < 0) return -1; if (pack_backend__alloc(&backend, 8) < 0) return -1; if (!(error = git_buf_joinpath(&path, objects_dir, "pack")) && git_path_isdir(git_buf_cstr(&path))) { backend->pack_folder = git_buf_detach(&path); error = pack_backend__refresh((git_odb_backend *)backend); } if (error < 0) { pack_backend__free((git_odb_backend *)backend); backend = NULL; } *backend_out = (git_odb_backend *)backend; git_buf_free(&path); return error; } deps/libgit2-sys-0.3.8/libgit2/src/attr_file.h0000664000175000017500000001257012555730137016031 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_attr_file_h__ #define INCLUDE_attr_file_h__ #include "git2/oid.h" #include "git2/attr.h" #include "vector.h" #include "pool.h" #include "buffer.h" #include "fileops.h" #define GIT_ATTR_FILE ".gitattributes" #define GIT_ATTR_FILE_INREPO "info/attributes" #define GIT_ATTR_FILE_SYSTEM "gitattributes" #define GIT_ATTR_FILE_XDG "attributes" #define GIT_ATTR_FNMATCH_NEGATIVE (1U << 0) #define GIT_ATTR_FNMATCH_DIRECTORY (1U << 1) #define GIT_ATTR_FNMATCH_FULLPATH (1U << 2) #define GIT_ATTR_FNMATCH_MACRO (1U << 3) #define GIT_ATTR_FNMATCH_IGNORE (1U << 4) #define GIT_ATTR_FNMATCH_HASWILD (1U << 5) #define GIT_ATTR_FNMATCH_ALLOWSPACE (1U << 6) #define GIT_ATTR_FNMATCH_ICASE (1U << 7) #define GIT_ATTR_FNMATCH_MATCH_ALL (1U << 8) #define GIT_ATTR_FNMATCH_ALLOWNEG (1U << 9) #define GIT_ATTR_FNMATCH_ALLOWMACRO (1U << 10) #define GIT_ATTR_FNMATCH_LEADINGDIR (1U << 11) #define GIT_ATTR_FNMATCH_NOLEADINGDIR (1U << 12) #define GIT_ATTR_FNMATCH__INCOMING \ (GIT_ATTR_FNMATCH_ALLOWSPACE | GIT_ATTR_FNMATCH_ALLOWNEG | \ GIT_ATTR_FNMATCH_ALLOWMACRO | GIT_ATTR_FNMATCH_NOLEADINGDIR) typedef enum { GIT_ATTR_FILE__IN_MEMORY = 0, GIT_ATTR_FILE__FROM_FILE = 1, GIT_ATTR_FILE__FROM_INDEX = 2, GIT_ATTR_FILE_NUM_SOURCES = 3 } git_attr_file_source; extern const char *git_attr__true; extern const char *git_attr__false; extern const char *git_attr__unset; typedef struct { char *pattern; size_t length; char *containing_dir; size_t containing_dir_length; unsigned int flags; } git_attr_fnmatch; typedef struct { git_attr_fnmatch match; git_vector assigns; /* vector of */ } git_attr_rule; typedef struct { git_refcount unused; const char *name; uint32_t name_hash; } git_attr_name; typedef struct { git_refcount rc; /* for macros */ char *name; uint32_t name_hash; const char *value; } git_attr_assignment; typedef struct git_attr_file_entry git_attr_file_entry; typedef struct { git_refcount rc; git_mutex lock; git_attr_file_entry *entry; git_attr_file_source source; git_vector rules; /* vector of or */ git_pool pool; unsigned int nonexistent:1; int session_key; union { git_oid oid; git_futils_filestamp stamp; } cache_data; } git_attr_file; struct git_attr_file_entry { git_attr_file *file[GIT_ATTR_FILE_NUM_SOURCES]; const char *path; /* points into fullpath */ char fullpath[GIT_FLEX_ARRAY]; }; typedef struct { git_buf full; char *path; char *basename; int is_dir; } git_attr_path; /* A git_attr_session can provide an "instance" of reading, to prevent cache * invalidation during a single operation instance (like checkout). */ typedef struct { int key; unsigned int init_setup:1, init_sysdir:1; git_buf sysdir; git_buf tmp; } git_attr_session; extern int git_attr_session__init(git_attr_session *attr_session, git_repository *repo); extern void git_attr_session__free(git_attr_session *session); extern int git_attr_get_many_with_session( const char **values_out, git_repository *repo, git_attr_session *attr_session, uint32_t flags, const char *path, size_t num_attr, const char **names); typedef int (*git_attr_file_parser)( git_repository *repo, git_attr_file *file, const char *data); /* * git_attr_file API */ int git_attr_file__new( git_attr_file **out, git_attr_file_entry *entry, git_attr_file_source source); void git_attr_file__free(git_attr_file *file); int git_attr_file__load( git_attr_file **out, git_repository *repo, git_attr_session *attr_session, git_attr_file_entry *ce, git_attr_file_source source, git_attr_file_parser parser); int git_attr_file__load_standalone( git_attr_file **out, const char *path); int git_attr_file__out_of_date( git_repository *repo, git_attr_session *session, git_attr_file *file); int git_attr_file__parse_buffer( git_repository *repo, git_attr_file *attrs, const char *data); int git_attr_file__clear_rules( git_attr_file *file, bool need_lock); int git_attr_file__lookup_one( git_attr_file *file, git_attr_path *path, const char *attr, const char **value); /* loop over rules in file from bottom to top */ #define git_attr_file__foreach_matching_rule(file, path, iter, rule) \ git_vector_rforeach(&(file)->rules, (iter), (rule)) \ if (git_attr_rule__match((rule), (path))) uint32_t git_attr_file__name_hash(const char *name); /* * other utilities */ extern int git_attr_fnmatch__parse( git_attr_fnmatch *spec, git_pool *pool, const char *source, const char **base); extern bool git_attr_fnmatch__match( git_attr_fnmatch *rule, git_attr_path *path); extern void git_attr_rule__free(git_attr_rule *rule); extern bool git_attr_rule__match( git_attr_rule *rule, git_attr_path *path); extern git_attr_assignment *git_attr_rule__lookup_assignment( git_attr_rule *rule, const char *name); typedef enum { GIT_DIR_FLAG_TRUE = 1, GIT_DIR_FLAG_FALSE = 0, GIT_DIR_FLAG_UNKNOWN = -1 } git_dir_flag; extern int git_attr_path__init( git_attr_path *info, const char *path, const char *base, git_dir_flag is_dir); extern void git_attr_path__free(git_attr_path *info); extern int git_attr_assignment__parse( git_repository *repo, /* needed to expand macros */ git_pool *pool, git_vector *assigns, const char **scan); #endif deps/libgit2-sys-0.3.8/libgit2/src/blame.h0000664000175000017500000000401312426525445015132 0ustar #ifndef INCLUDE_blame_h__ #define INCLUDE_blame_h__ #include "git2/blame.h" #include "common.h" #include "vector.h" #include "diff.h" #include "array.h" #include "git2/oid.h" /* * One blob in a commit that is being suspected */ typedef struct git_blame__origin { int refcnt; struct git_blame__origin *previous; git_commit *commit; git_blob *blob; char path[GIT_FLEX_ARRAY]; } git_blame__origin; /* * Each group of lines is described by a git_blame__entry; it can be split * as we pass blame to the parents. They form a linked list in the * scoreboard structure, sorted by the target line number. */ typedef struct git_blame__entry { struct git_blame__entry *prev; struct git_blame__entry *next; /* the first line of this group in the final image; * internally all line numbers are 0 based. */ int lno; /* how many lines this group has */ int num_lines; /* the commit that introduced this group into the final image */ git_blame__origin *suspect; /* true if the suspect is truly guilty; false while we have not * checked if the group came from one of its parents. */ bool guilty; /* true if the entry has been scanned for copies in the current parent */ bool scanned; /* the line number of the first line of this group in the * suspect's file; internally all line numbers are 0 based. */ int s_lno; /* how significant this entry is -- cached to avoid * scanning the lines over and over. */ unsigned score; /* Whether this entry has been tracked to a boundary commit. */ bool is_boundary; } git_blame__entry; struct git_blame { char *path; git_repository *repository; git_blame_options options; git_vector hunks; git_vector paths; git_blob *final_blob; git_array_t(size_t) line_index; size_t current_diff_line; git_blame_hunk *current_hunk; /* Scoreboard fields */ git_commit *final; git_blame__entry *ent; int num_lines; const char *final_buf; git_off_t final_buf_size; }; git_blame *git_blame__alloc( git_repository *repo, git_blame_options opts, const char *path); #endif deps/libgit2-sys-0.3.8/libgit2/src/odb_loose.c0000664000175000017500000005560512610310643016012 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include #include "git2/object.h" #include "git2/sys/odb_backend.h" #include "fileops.h" #include "hash.h" #include "odb.h" #include "delta-apply.h" #include "filebuf.h" #include "git2/odb_backend.h" #include "git2/types.h" typedef struct { /* object header data */ git_otype type; /* object type */ size_t size; /* object size */ } obj_hdr; typedef struct { git_odb_stream stream; git_filebuf fbuf; } loose_writestream; typedef struct loose_backend { git_odb_backend parent; int object_zlib_level; /** loose object zlib compression level. */ int fsync_object_files; /** loose object file fsync flag. */ mode_t object_file_mode; mode_t object_dir_mode; size_t objects_dirlen; char objects_dir[GIT_FLEX_ARRAY]; } loose_backend; /* State structure for exploring directories, * in order to locate objects matching a short oid. */ typedef struct { size_t dir_len; unsigned char short_oid[GIT_OID_HEXSZ]; /* hex formatted oid to match */ size_t short_oid_len; int found; /* number of matching * objects already found */ unsigned char res_oid[GIT_OID_HEXSZ]; /* hex formatted oid of * the object found */ } loose_locate_object_state; /*********************************************************** * * MISCELLANEOUS HELPER FUNCTIONS * ***********************************************************/ static int object_file_name( git_buf *name, const loose_backend *be, const git_oid *id) { size_t alloclen; /* expand length for object root + 40 hex sha1 chars + 2 * '/' + '\0' */ GITERR_CHECK_ALLOC_ADD(&alloclen, be->objects_dirlen, GIT_OID_HEXSZ); GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 3); if (git_buf_grow(name, alloclen) < 0) return -1; git_buf_set(name, be->objects_dir, be->objects_dirlen); git_path_to_dir(name); /* loose object filename: aa/aaa... (41 bytes) */ git_oid_pathfmt(name->ptr + name->size, id); name->size += GIT_OID_HEXSZ + 1; name->ptr[name->size] = '\0'; return 0; } static int object_mkdir(const git_buf *name, const loose_backend *be) { return git_futils_mkdir_relative( name->ptr + be->objects_dirlen, be->objects_dir, be->object_dir_mode, GIT_MKDIR_PATH | GIT_MKDIR_SKIP_LAST | GIT_MKDIR_VERIFY_DIR, NULL); } static size_t get_binary_object_header(obj_hdr *hdr, git_buf *obj) { unsigned char c; unsigned char *data = (unsigned char *)obj->ptr; size_t shift, size, used = 0; if (git_buf_len(obj) == 0) return 0; c = data[used++]; hdr->type = (c >> 4) & 7; size = c & 15; shift = 4; while (c & 0x80) { if (git_buf_len(obj) <= used) return 0; if (sizeof(size_t) * 8 <= shift) return 0; c = data[used++]; size += (c & 0x7f) << shift; shift += 7; } hdr->size = size; return used; } static size_t get_object_header(obj_hdr *hdr, unsigned char *data) { char c, typename[10]; size_t size, used = 0; /* * type name string followed by space. */ while ((c = data[used]) != ' ') { typename[used++] = c; if (used >= sizeof(typename)) return 0; } typename[used] = 0; if (used == 0) return 0; hdr->type = git_object_string2type(typename); used++; /* consume the space */ /* * length follows immediately in decimal (without * leading zeros). */ size = data[used++] - '0'; if (size > 9) return 0; if (size) { while ((c = data[used]) != '\0') { size_t d = c - '0'; if (d > 9) break; used++; size = size * 10 + d; } } hdr->size = size; /* * the length must be followed by a zero byte */ if (data[used++] != '\0') return 0; return used; } /*********************************************************** * * ZLIB RELATED FUNCTIONS * ***********************************************************/ static void init_stream(z_stream *s, void *out, size_t len) { memset(s, 0, sizeof(*s)); s->next_out = out; s->avail_out = (uInt)len; } static void set_stream_input(z_stream *s, void *in, size_t len) { s->next_in = in; s->avail_in = (uInt)len; } static void set_stream_output(z_stream *s, void *out, size_t len) { s->next_out = out; s->avail_out = (uInt)len; } static int start_inflate(z_stream *s, git_buf *obj, void *out, size_t len) { int status; init_stream(s, out, len); set_stream_input(s, obj->ptr, git_buf_len(obj)); if ((status = inflateInit(s)) < Z_OK) return status; return inflate(s, 0); } static int finish_inflate(z_stream *s) { int status = Z_OK; while (status == Z_OK) status = inflate(s, Z_FINISH); inflateEnd(s); if ((status != Z_STREAM_END) || (s->avail_in != 0)) { giterr_set(GITERR_ZLIB, "Failed to finish ZLib inflation. Stream aborted prematurely"); return -1; } return 0; } static int is_zlib_compressed_data(unsigned char *data) { unsigned int w; w = ((unsigned int)(data[0]) << 8) + data[1]; return (data[0] & 0x8F) == 0x08 && !(w % 31); } static int inflate_buffer(void *in, size_t inlen, void *out, size_t outlen) { z_stream zs; int status = Z_OK; memset(&zs, 0x0, sizeof(zs)); zs.next_out = out; zs.avail_out = (uInt)outlen; zs.next_in = in; zs.avail_in = (uInt)inlen; if (inflateInit(&zs) < Z_OK) { giterr_set(GITERR_ZLIB, "Failed to inflate buffer"); return -1; } while (status == Z_OK) status = inflate(&zs, Z_FINISH); inflateEnd(&zs); if (status != Z_STREAM_END /* || zs.avail_in != 0 */ || zs.total_out != outlen) { giterr_set(GITERR_ZLIB, "Failed to inflate buffer. Stream aborted prematurely"); return -1; } return 0; } static void *inflate_tail(z_stream *s, void *hb, size_t used, obj_hdr *hdr) { unsigned char *buf, *head = hb; size_t tail, alloc_size; /* * allocate a buffer to hold the inflated data and copy the * initial sequence of inflated data from the tail of the * head buffer, if any. */ if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, hdr->size, 1) || (buf = git__malloc(alloc_size)) == NULL) { inflateEnd(s); return NULL; } tail = s->total_out - used; if (used > 0 && tail > 0) { if (tail > hdr->size) tail = hdr->size; memcpy(buf, head + used, tail); } used = tail; /* * inflate the remainder of the object data, if any */ if (hdr->size < used) inflateEnd(s); else { set_stream_output(s, buf + used, hdr->size - used); if (finish_inflate(s)) { git__free(buf); return NULL; } } return buf; } /* * At one point, there was a loose object format that was intended to * mimic the format used in pack-files. This was to allow easy copying * of loose object data into packs. This format is no longer used, but * we must still read it. */ static int inflate_packlike_loose_disk_obj(git_rawobj *out, git_buf *obj) { unsigned char *in, *buf; obj_hdr hdr; size_t len, used, alloclen; /* * read the object header, which is an (uncompressed) * binary encoding of the object type and size. */ if ((used = get_binary_object_header(&hdr, obj)) == 0 || !git_object_typeisloose(hdr.type)) { giterr_set(GITERR_ODB, "Failed to inflate loose object."); return -1; } /* * allocate a buffer and inflate the data into it */ GITERR_CHECK_ALLOC_ADD(&alloclen, hdr.size, 1); buf = git__malloc(alloclen); GITERR_CHECK_ALLOC(buf); in = ((unsigned char *)obj->ptr) + used; len = obj->size - used; if (inflate_buffer(in, len, buf, hdr.size) < 0) { git__free(buf); return -1; } buf[hdr.size] = '\0'; out->data = buf; out->len = hdr.size; out->type = hdr.type; return 0; } static int inflate_disk_obj(git_rawobj *out, git_buf *obj) { unsigned char head[64], *buf; z_stream zs; obj_hdr hdr; size_t used; /* * check for a pack-like loose object */ if (!is_zlib_compressed_data((unsigned char *)obj->ptr)) return inflate_packlike_loose_disk_obj(out, obj); /* * inflate the initial part of the io buffer in order * to parse the object header (type and size). */ if (start_inflate(&zs, obj, head, sizeof(head)) < Z_OK || (used = get_object_header(&hdr, head)) == 0 || !git_object_typeisloose(hdr.type)) { giterr_set(GITERR_ODB, "Failed to inflate disk object."); return -1; } /* * allocate a buffer and inflate the object data into it * (including the initial sequence in the head buffer). */ if ((buf = inflate_tail(&zs, head, used, &hdr)) == NULL) return -1; buf[hdr.size] = '\0'; out->data = buf; out->len = hdr.size; out->type = hdr.type; return 0; } /*********************************************************** * * ODB OBJECT READING & WRITING * * Backend for the public API; read headers and full objects * from the ODB. Write raw data to the ODB. * ***********************************************************/ static int read_loose(git_rawobj *out, git_buf *loc) { int error; git_buf obj = GIT_BUF_INIT; assert(out && loc); if (git_buf_oom(loc)) return -1; out->data = NULL; out->len = 0; out->type = GIT_OBJ_BAD; if (!(error = git_futils_readbuffer(&obj, loc->ptr))) error = inflate_disk_obj(out, &obj); git_buf_free(&obj); return error; } static int read_header_loose(git_rawobj *out, git_buf *loc) { int error = 0, z_return = Z_ERRNO, read_bytes; git_file fd; z_stream zs; obj_hdr header_obj; unsigned char raw_buffer[16], inflated_buffer[64]; assert(out && loc); if (git_buf_oom(loc)) return -1; out->data = NULL; if ((fd = git_futils_open_ro(loc->ptr)) < 0) return fd; init_stream(&zs, inflated_buffer, sizeof(inflated_buffer)); z_return = inflateInit(&zs); while (z_return == Z_OK) { if ((read_bytes = p_read(fd, raw_buffer, sizeof(raw_buffer))) > 0) { set_stream_input(&zs, raw_buffer, read_bytes); z_return = inflate(&zs, 0); } else z_return = Z_STREAM_END; } if ((z_return != Z_STREAM_END && z_return != Z_BUF_ERROR) || get_object_header(&header_obj, inflated_buffer) == 0 || git_object_typeisloose(header_obj.type) == 0) { giterr_set(GITERR_ZLIB, "Failed to read loose object header"); error = -1; } else { out->len = header_obj.size; out->type = header_obj.type; } finish_inflate(&zs); p_close(fd); return error; } static int locate_object( git_buf *object_location, loose_backend *backend, const git_oid *oid) { int error = object_file_name(object_location, backend, oid); if (!error && !git_path_exists(object_location->ptr)) return GIT_ENOTFOUND; return error; } /* Explore an entry of a directory and see if it matches a short oid */ static int fn_locate_object_short_oid(void *state, git_buf *pathbuf) { loose_locate_object_state *sstate = (loose_locate_object_state *)state; if (git_buf_len(pathbuf) - sstate->dir_len != GIT_OID_HEXSZ - 2) { /* Entry cannot be an object. Continue to next entry */ return 0; } if (git_path_isdir(pathbuf->ptr) == false) { /* We are already in the directory matching the 2 first hex characters, * compare the first ncmp characters of the oids */ if (!memcmp(sstate->short_oid + 2, (unsigned char *)pathbuf->ptr + sstate->dir_len, sstate->short_oid_len - 2)) { if (!sstate->found) { sstate->res_oid[0] = sstate->short_oid[0]; sstate->res_oid[1] = sstate->short_oid[1]; memcpy(sstate->res_oid+2, pathbuf->ptr+sstate->dir_len, GIT_OID_HEXSZ-2); } sstate->found++; } } if (sstate->found > 1) return GIT_EAMBIGUOUS; return 0; } /* Locate an object matching a given short oid */ static int locate_object_short_oid( git_buf *object_location, git_oid *res_oid, loose_backend *backend, const git_oid *short_oid, size_t len) { char *objects_dir = backend->objects_dir; size_t dir_len = strlen(objects_dir), alloc_len; loose_locate_object_state state; int error; /* prealloc memory for OBJ_DIR/xx/xx..38x..xx */ GITERR_CHECK_ALLOC_ADD(&alloc_len, dir_len, GIT_OID_HEXSZ); GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 3); if (git_buf_grow(object_location, alloc_len) < 0) return -1; git_buf_set(object_location, objects_dir, dir_len); git_path_to_dir(object_location); /* save adjusted position at end of dir so it can be restored later */ dir_len = git_buf_len(object_location); /* Convert raw oid to hex formatted oid */ git_oid_fmt((char *)state.short_oid, short_oid); /* Explore OBJ_DIR/xx/ where xx is the beginning of hex formatted short oid */ if (git_buf_put(object_location, (char *)state.short_oid, 3) < 0) return -1; object_location->ptr[object_location->size - 1] = '/'; /* Check that directory exists */ if (git_path_isdir(object_location->ptr) == false) return git_odb__error_notfound("no matching loose object for prefix", short_oid); state.dir_len = git_buf_len(object_location); state.short_oid_len = len; state.found = 0; /* Explore directory to find a unique object matching short_oid */ error = git_path_direach( object_location, 0, fn_locate_object_short_oid, &state); if (error < 0 && error != GIT_EAMBIGUOUS) return error; if (!state.found) return git_odb__error_notfound("no matching loose object for prefix", short_oid); if (state.found > 1) return git_odb__error_ambiguous("multiple matches in loose objects"); /* Convert obtained hex formatted oid to raw */ error = git_oid_fromstr(res_oid, (char *)state.res_oid); if (error) return error; /* Update the location according to the oid obtained */ GITERR_CHECK_ALLOC_ADD(&alloc_len, dir_len, GIT_OID_HEXSZ); GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2); git_buf_truncate(object_location, dir_len); if (git_buf_grow(object_location, alloc_len) < 0) return -1; git_oid_pathfmt(object_location->ptr + dir_len, res_oid); object_location->size += GIT_OID_HEXSZ + 1; object_location->ptr[object_location->size] = '\0'; return 0; } /*********************************************************** * * LOOSE BACKEND PUBLIC API * * Implement the git_odb_backend API calls * ***********************************************************/ static int loose_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid) { git_buf object_path = GIT_BUF_INIT; git_rawobj raw; int error; assert(backend && oid); raw.len = 0; raw.type = GIT_OBJ_BAD; if (locate_object(&object_path, (loose_backend *)backend, oid) < 0) error = git_odb__error_notfound("no matching loose object", oid); else if ((error = read_header_loose(&raw, &object_path)) == 0) { *len_p = raw.len; *type_p = raw.type; } git_buf_free(&object_path); return error; } static int loose_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid) { git_buf object_path = GIT_BUF_INIT; git_rawobj raw; int error = 0; assert(backend && oid); if (locate_object(&object_path, (loose_backend *)backend, oid) < 0) error = git_odb__error_notfound("no matching loose object", oid); else if ((error = read_loose(&raw, &object_path)) == 0) { *buffer_p = raw.data; *len_p = raw.len; *type_p = raw.type; } git_buf_free(&object_path); return error; } static int loose_backend__read_prefix( git_oid *out_oid, void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *short_oid, size_t len) { int error = 0; assert(len >= GIT_OID_MINPREFIXLEN && len <= GIT_OID_HEXSZ); if (len == GIT_OID_HEXSZ) { /* We can fall back to regular read method */ error = loose_backend__read(buffer_p, len_p, type_p, backend, short_oid); if (!error) git_oid_cpy(out_oid, short_oid); } else { git_buf object_path = GIT_BUF_INIT; git_rawobj raw; assert(backend && short_oid); if ((error = locate_object_short_oid(&object_path, out_oid, (loose_backend *)backend, short_oid, len)) == 0 && (error = read_loose(&raw, &object_path)) == 0) { *buffer_p = raw.data; *len_p = raw.len; *type_p = raw.type; } git_buf_free(&object_path); } return error; } static int loose_backend__exists(git_odb_backend *backend, const git_oid *oid) { git_buf object_path = GIT_BUF_INIT; int error; assert(backend && oid); error = locate_object(&object_path, (loose_backend *)backend, oid); git_buf_free(&object_path); return !error; } static int loose_backend__exists_prefix( git_oid *out, git_odb_backend *backend, const git_oid *short_id, size_t len) { git_buf object_path = GIT_BUF_INIT; int error; assert(backend && out && short_id && len >= GIT_OID_MINPREFIXLEN); error = locate_object_short_oid( &object_path, out, (loose_backend *)backend, short_id, len); git_buf_free(&object_path); return error; } struct foreach_state { size_t dir_len; git_odb_foreach_cb cb; void *data; }; GIT_INLINE(int) filename_to_oid(git_oid *oid, const char *ptr) { int v, i = 0; if (strlen(ptr) != GIT_OID_HEXSZ+1) return -1; if (ptr[2] != '/') { return -1; } v = (git__fromhex(ptr[i]) << 4) | git__fromhex(ptr[i+1]); if (v < 0) return -1; oid->id[0] = (unsigned char) v; ptr += 3; for (i = 0; i < 38; i += 2) { v = (git__fromhex(ptr[i]) << 4) | git__fromhex(ptr[i + 1]); if (v < 0) return -1; oid->id[1 + i/2] = (unsigned char) v; } return 0; } static int foreach_object_dir_cb(void *_state, git_buf *path) { git_oid oid; struct foreach_state *state = (struct foreach_state *) _state; if (filename_to_oid(&oid, path->ptr + state->dir_len) < 0) return 0; return giterr_set_after_callback_function( state->cb(&oid, state->data), "git_odb_foreach"); } static int foreach_cb(void *_state, git_buf *path) { struct foreach_state *state = (struct foreach_state *) _state; /* non-dir is some stray file, ignore it */ if (!git_path_isdir(git_buf_cstr(path))) return 0; return git_path_direach(path, 0, foreach_object_dir_cb, state); } static int loose_backend__foreach(git_odb_backend *_backend, git_odb_foreach_cb cb, void *data) { char *objects_dir; int error; git_buf buf = GIT_BUF_INIT; struct foreach_state state; loose_backend *backend = (loose_backend *) _backend; assert(backend && cb); objects_dir = backend->objects_dir; git_buf_sets(&buf, objects_dir); git_path_to_dir(&buf); if (git_buf_oom(&buf)) return -1; memset(&state, 0, sizeof(state)); state.cb = cb; state.data = data; state.dir_len = git_buf_len(&buf); error = git_path_direach(&buf, 0, foreach_cb, &state); git_buf_free(&buf); return error; } static int loose_backend__stream_fwrite(git_odb_stream *_stream, const git_oid *oid) { loose_writestream *stream = (loose_writestream *)_stream; loose_backend *backend = (loose_backend *)_stream->backend; git_buf final_path = GIT_BUF_INIT; int error = 0; if (object_file_name(&final_path, backend, oid) < 0 || object_mkdir(&final_path, backend) < 0) error = -1; else error = git_filebuf_commit_at( &stream->fbuf, final_path.ptr); git_buf_free(&final_path); return error; } static int loose_backend__stream_write(git_odb_stream *_stream, const char *data, size_t len) { loose_writestream *stream = (loose_writestream *)_stream; return git_filebuf_write(&stream->fbuf, data, len); } static void loose_backend__stream_free(git_odb_stream *_stream) { loose_writestream *stream = (loose_writestream *)_stream; git_filebuf_cleanup(&stream->fbuf); git__free(stream); } static int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_backend, git_off_t length, git_otype type) { loose_backend *backend; loose_writestream *stream = NULL; char hdr[64]; git_buf tmp_path = GIT_BUF_INIT; int hdrlen; assert(_backend && length >= 0); backend = (loose_backend *)_backend; *stream_out = NULL; hdrlen = git_odb__format_object_header(hdr, sizeof(hdr), length, type); stream = git__calloc(1, sizeof(loose_writestream)); GITERR_CHECK_ALLOC(stream); stream->stream.backend = _backend; stream->stream.read = NULL; /* read only */ stream->stream.write = &loose_backend__stream_write; stream->stream.finalize_write = &loose_backend__stream_fwrite; stream->stream.free = &loose_backend__stream_free; stream->stream.mode = GIT_STREAM_WRONLY; if (git_buf_joinpath(&tmp_path, backend->objects_dir, "tmp_object") < 0 || git_filebuf_open(&stream->fbuf, tmp_path.ptr, GIT_FILEBUF_TEMPORARY | (backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT), backend->object_file_mode) < 0 || stream->stream.write((git_odb_stream *)stream, hdr, hdrlen) < 0) { git_filebuf_cleanup(&stream->fbuf); git__free(stream); stream = NULL; } git_buf_free(&tmp_path); *stream_out = (git_odb_stream *)stream; return !stream ? -1 : 0; } static int loose_backend__write(git_odb_backend *_backend, const git_oid *oid, const void *data, size_t len, git_otype type) { int error = 0, header_len; git_buf final_path = GIT_BUF_INIT; char header[64]; git_filebuf fbuf = GIT_FILEBUF_INIT; loose_backend *backend; backend = (loose_backend *)_backend; /* prepare the header for the file */ header_len = git_odb__format_object_header(header, sizeof(header), len, type); if (git_buf_joinpath(&final_path, backend->objects_dir, "tmp_object") < 0 || git_filebuf_open(&fbuf, final_path.ptr, GIT_FILEBUF_TEMPORARY | (backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT), backend->object_file_mode) < 0) { error = -1; goto cleanup; } git_filebuf_write(&fbuf, header, header_len); git_filebuf_write(&fbuf, data, len); if (object_file_name(&final_path, backend, oid) < 0 || object_mkdir(&final_path, backend) < 0 || git_filebuf_commit_at(&fbuf, final_path.ptr) < 0) error = -1; cleanup: if (error < 0) git_filebuf_cleanup(&fbuf); git_buf_free(&final_path); return error; } static void loose_backend__free(git_odb_backend *_backend) { loose_backend *backend; assert(_backend); backend = (loose_backend *)_backend; git__free(backend); } int git_odb_backend_loose( git_odb_backend **backend_out, const char *objects_dir, int compression_level, int do_fsync, unsigned int dir_mode, unsigned int file_mode) { loose_backend *backend; size_t objects_dirlen, alloclen; assert(backend_out && objects_dir); objects_dirlen = strlen(objects_dir); GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(loose_backend), objects_dirlen); GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 2); backend = git__calloc(1, alloclen); GITERR_CHECK_ALLOC(backend); backend->parent.version = GIT_ODB_BACKEND_VERSION; backend->objects_dirlen = objects_dirlen; memcpy(backend->objects_dir, objects_dir, objects_dirlen); if (backend->objects_dir[backend->objects_dirlen - 1] != '/') backend->objects_dir[backend->objects_dirlen++] = '/'; if (compression_level < 0) compression_level = Z_BEST_SPEED; if (dir_mode == 0) dir_mode = GIT_OBJECT_DIR_MODE; if (file_mode == 0) file_mode = GIT_OBJECT_FILE_MODE; backend->object_zlib_level = compression_level; backend->fsync_object_files = do_fsync; backend->object_dir_mode = dir_mode; backend->object_file_mode = file_mode; backend->parent.read = &loose_backend__read; backend->parent.write = &loose_backend__write; backend->parent.read_prefix = &loose_backend__read_prefix; backend->parent.read_header = &loose_backend__read_header; backend->parent.writestream = &loose_backend__stream; backend->parent.exists = &loose_backend__exists; backend->parent.exists_prefix = &loose_backend__exists_prefix; backend->parent.foreach = &loose_backend__foreach; backend->parent.free = &loose_backend__free; *backend_out = (git_odb_backend *)backend; return 0; } deps/libgit2-sys-0.3.8/libgit2/src/diff_patch.c0000664000175000017500000006704012610310643016130 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "git2/blob.h" #include "diff.h" #include "diff_file.h" #include "diff_driver.h" #include "diff_patch.h" #include "diff_xdiff.h" #include "delta.h" #include "zstream.h" #include "fileops.h" static void diff_output_init( git_diff_output*, const git_diff_options*, git_diff_file_cb, git_diff_binary_cb, git_diff_hunk_cb, git_diff_line_cb, void*); static void diff_output_to_patch(git_diff_output *, git_patch *); static void diff_patch_update_binary(git_patch *patch) { if ((patch->delta->flags & DIFF_FLAGS_KNOWN_BINARY) != 0) return; if ((patch->ofile.file->flags & GIT_DIFF_FLAG_BINARY) != 0 || (patch->nfile.file->flags & GIT_DIFF_FLAG_BINARY) != 0) patch->delta->flags |= GIT_DIFF_FLAG_BINARY; else if (patch->ofile.file->size > GIT_XDIFF_MAX_SIZE || patch->nfile.file->size > GIT_XDIFF_MAX_SIZE) patch->delta->flags |= GIT_DIFF_FLAG_BINARY; else if ((patch->ofile.file->flags & DIFF_FLAGS_NOT_BINARY) != 0 && (patch->nfile.file->flags & DIFF_FLAGS_NOT_BINARY) != 0) patch->delta->flags |= GIT_DIFF_FLAG_NOT_BINARY; } static void diff_patch_init_common(git_patch *patch) { diff_patch_update_binary(patch); patch->flags |= GIT_DIFF_PATCH_INITIALIZED; if (patch->diff) git_diff_addref(patch->diff); } static int diff_patch_normalize_options( git_diff_options *out, const git_diff_options *opts) { if (opts) { GITERR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options"); memcpy(out, opts, sizeof(git_diff_options)); } else { git_diff_options default_opts = GIT_DIFF_OPTIONS_INIT; memcpy(out, &default_opts, sizeof(git_diff_options)); } out->old_prefix = opts && opts->old_prefix ? git__strdup(opts->old_prefix) : git__strdup(DIFF_OLD_PREFIX_DEFAULT); out->new_prefix = opts && opts->new_prefix ? git__strdup(opts->new_prefix) : git__strdup(DIFF_NEW_PREFIX_DEFAULT); GITERR_CHECK_ALLOC(out->old_prefix); GITERR_CHECK_ALLOC(out->new_prefix); return 0; } static int diff_patch_init_from_diff( git_patch *patch, git_diff *diff, size_t delta_index) { int error = 0; memset(patch, 0, sizeof(*patch)); patch->diff = diff; patch->delta = git_vector_get(&diff->deltas, delta_index); patch->delta_index = delta_index; if ((error = diff_patch_normalize_options( &patch->diff_opts, &diff->opts)) < 0 || (error = git_diff_file_content__init_from_diff( &patch->ofile, diff, patch->delta, true)) < 0 || (error = git_diff_file_content__init_from_diff( &patch->nfile, diff, patch->delta, false)) < 0) return error; diff_patch_init_common(patch); return 0; } static int diff_patch_alloc_from_diff( git_patch **out, git_diff *diff, size_t delta_index) { int error; git_patch *patch = git__calloc(1, sizeof(git_patch)); GITERR_CHECK_ALLOC(patch); if (!(error = diff_patch_init_from_diff(patch, diff, delta_index))) { patch->flags |= GIT_DIFF_PATCH_ALLOCATED; GIT_REFCOUNT_INC(patch); } else { git__free(patch); patch = NULL; } *out = patch; return error; } GIT_INLINE(bool) should_skip_binary(git_patch *patch, git_diff_file *file) { if ((patch->diff_opts.flags & GIT_DIFF_SHOW_BINARY) != 0) return false; return (file->flags & GIT_DIFF_FLAG_BINARY) != 0; } static bool diff_patch_diffable(git_patch *patch) { size_t olen, nlen; if (patch->delta->status == GIT_DELTA_UNMODIFIED) return false; /* if we've determined this to be binary (and we are not showing binary * data) then we have skipped loading the map data. instead, query the * file data itself. */ if ((patch->delta->flags & GIT_DIFF_FLAG_BINARY) != 0 && (patch->diff_opts.flags & GIT_DIFF_SHOW_BINARY) == 0) { olen = (size_t)patch->ofile.file->size; nlen = (size_t)patch->nfile.file->size; } else { olen = patch->ofile.map.len; nlen = patch->nfile.map.len; } /* if both sides are empty, files are identical */ if (!olen && !nlen) return false; /* otherwise, check the file sizes and the oid */ return (olen != nlen || !git_oid_equal(&patch->ofile.file->id, &patch->nfile.file->id)); } static int diff_patch_load(git_patch *patch, git_diff_output *output) { int error = 0; bool incomplete_data; if ((patch->flags & GIT_DIFF_PATCH_LOADED) != 0) return 0; /* if no hunk and data callbacks and user doesn't care if data looks * binary, then there is no need to actually load the data */ if ((patch->ofile.opts_flags & GIT_DIFF_SKIP_BINARY_CHECK) != 0 && output && !output->binary_cb && !output->hunk_cb && !output->data_cb) return 0; incomplete_data = (((patch->ofile.flags & GIT_DIFF_FLAG__NO_DATA) != 0 || (patch->ofile.file->flags & GIT_DIFF_FLAG_VALID_ID) != 0) && ((patch->nfile.flags & GIT_DIFF_FLAG__NO_DATA) != 0 || (patch->nfile.file->flags & GIT_DIFF_FLAG_VALID_ID) != 0)); /* always try to load workdir content first because filtering may * need 2x data size and this minimizes peak memory footprint */ if (patch->ofile.src == GIT_ITERATOR_TYPE_WORKDIR) { if ((error = git_diff_file_content__load( &patch->ofile, &patch->diff_opts)) < 0 || should_skip_binary(patch, patch->ofile.file)) goto cleanup; } if (patch->nfile.src == GIT_ITERATOR_TYPE_WORKDIR) { if ((error = git_diff_file_content__load( &patch->nfile, &patch->diff_opts)) < 0 || should_skip_binary(patch, patch->nfile.file)) goto cleanup; } /* once workdir has been tried, load other data as needed */ if (patch->ofile.src != GIT_ITERATOR_TYPE_WORKDIR) { if ((error = git_diff_file_content__load( &patch->ofile, &patch->diff_opts)) < 0 || should_skip_binary(patch, patch->ofile.file)) goto cleanup; } if (patch->nfile.src != GIT_ITERATOR_TYPE_WORKDIR) { if ((error = git_diff_file_content__load( &patch->nfile, &patch->diff_opts)) < 0 || should_skip_binary(patch, patch->nfile.file)) goto cleanup; } /* if previously missing an oid, and now that we have it the two sides * are the same (and not submodules), update MODIFIED -> UNMODIFIED */ if (incomplete_data && patch->ofile.file->mode == patch->nfile.file->mode && patch->ofile.file->mode != GIT_FILEMODE_COMMIT && git_oid_equal(&patch->ofile.file->id, &patch->nfile.file->id) && patch->delta->status == GIT_DELTA_MODIFIED) /* not RENAMED/COPIED! */ patch->delta->status = GIT_DELTA_UNMODIFIED; cleanup: diff_patch_update_binary(patch); if (!error) { if (diff_patch_diffable(patch)) patch->flags |= GIT_DIFF_PATCH_DIFFABLE; patch->flags |= GIT_DIFF_PATCH_LOADED; } return error; } static int diff_patch_invoke_file_callback( git_patch *patch, git_diff_output *output) { float progress = patch->diff ? ((float)patch->delta_index / patch->diff->deltas.length) : 1.0f; if (!output->file_cb) return 0; return giterr_set_after_callback_function( output->file_cb(patch->delta, progress, output->payload), "git_patch"); } static int create_binary( git_diff_binary_t *out_type, char **out_data, size_t *out_datalen, size_t *out_inflatedlen, const char *a_data, size_t a_datalen, const char *b_data, size_t b_datalen) { git_buf deflate = GIT_BUF_INIT, delta = GIT_BUF_INIT; unsigned long delta_data_len; int error; /* The git_delta function accepts unsigned long only */ if (!git__is_ulong(a_datalen) || !git__is_ulong(b_datalen)) return GIT_EBUFS; if ((error = git_zstream_deflatebuf(&deflate, b_data, b_datalen)) < 0) goto done; /* The git_delta function accepts unsigned long only */ if (!git__is_ulong(deflate.size)) { error = GIT_EBUFS; goto done; } if (a_datalen && b_datalen) { void *delta_data = git_delta( a_data, (unsigned long)a_datalen, b_data, (unsigned long)b_datalen, &delta_data_len, (unsigned long)deflate.size); if (delta_data) { error = git_zstream_deflatebuf( &delta, delta_data, (size_t)delta_data_len); git__free(delta_data); if (error < 0) goto done; } } if (delta.size && delta.size < deflate.size) { *out_type = GIT_DIFF_BINARY_DELTA; *out_datalen = delta.size; *out_data = git_buf_detach(&delta); *out_inflatedlen = delta_data_len; } else { *out_type = GIT_DIFF_BINARY_LITERAL; *out_datalen = deflate.size; *out_data = git_buf_detach(&deflate); *out_inflatedlen = b_datalen; } done: git_buf_free(&deflate); git_buf_free(&delta); return error; } static int diff_binary(git_diff_output *output, git_patch *patch) { git_diff_binary binary = {{0}}; const char *old_data = patch->ofile.map.data; const char *new_data = patch->nfile.map.data; size_t old_len = patch->ofile.map.len, new_len = patch->nfile.map.len; int error; /* Create the old->new delta (as the "new" side of the patch), * and the new->old delta (as the "old" side) */ if ((error = create_binary(&binary.old_file.type, (char **)&binary.old_file.data, &binary.old_file.datalen, &binary.old_file.inflatedlen, new_data, new_len, old_data, old_len)) < 0 || (error = create_binary(&binary.new_file.type, (char **)&binary.new_file.data, &binary.new_file.datalen, &binary.new_file.inflatedlen, old_data, old_len, new_data, new_len)) < 0) return error; error = giterr_set_after_callback_function( output->binary_cb(patch->delta, &binary, output->payload), "git_patch"); git__free((char *) binary.old_file.data); git__free((char *) binary.new_file.data); return error; } static int diff_patch_generate(git_patch *patch, git_diff_output *output) { int error = 0; if ((patch->flags & GIT_DIFF_PATCH_DIFFED) != 0) return 0; /* if we are not looking at the binary or text data, don't do the diff */ if (!output->binary_cb && !output->hunk_cb && !output->data_cb) return 0; if ((patch->flags & GIT_DIFF_PATCH_LOADED) == 0 && (error = diff_patch_load(patch, output)) < 0) return error; if ((patch->flags & GIT_DIFF_PATCH_DIFFABLE) == 0) return 0; if ((patch->delta->flags & GIT_DIFF_FLAG_BINARY) != 0) { if (output->binary_cb) error = diff_binary(output, patch); } else { if (output->diff_cb) error = output->diff_cb(output, patch); } patch->flags |= GIT_DIFF_PATCH_DIFFED; return error; } static void diff_patch_free(git_patch *patch) { git_diff_file_content__clear(&patch->ofile); git_diff_file_content__clear(&patch->nfile); git_array_clear(patch->lines); git_array_clear(patch->hunks); git_diff_free(patch->diff); /* decrements refcount */ patch->diff = NULL; git_pool_clear(&patch->flattened); git__free((char *)patch->diff_opts.old_prefix); git__free((char *)patch->diff_opts.new_prefix); git__free((char *)patch->binary.old_file.data); git__free((char *)patch->binary.new_file.data); if (patch->flags & GIT_DIFF_PATCH_ALLOCATED) git__free(patch); } static int diff_required(git_diff *diff, const char *action) { if (diff) return 0; giterr_set(GITERR_INVALID, "Must provide valid diff to %s", action); return -1; } int git_diff_foreach( git_diff *diff, git_diff_file_cb file_cb, git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb data_cb, void *payload) { int error = 0; git_xdiff_output xo; size_t idx; git_patch patch; if ((error = diff_required(diff, "git_diff_foreach")) < 0) return error; memset(&xo, 0, sizeof(xo)); memset(&patch, 0, sizeof(patch)); diff_output_init( &xo.output, &diff->opts, file_cb, binary_cb, hunk_cb, data_cb, payload); git_xdiff_init(&xo, &diff->opts); git_vector_foreach(&diff->deltas, idx, patch.delta) { /* check flags against patch status */ if (git_diff_delta__should_skip(&diff->opts, patch.delta)) continue; if (binary_cb || hunk_cb || data_cb) { if ((error = diff_patch_init_from_diff(&patch, diff, idx)) != 0 || (error = diff_patch_load(&patch, &xo.output)) != 0) return error; } if ((error = diff_patch_invoke_file_callback(&patch, &xo.output)) == 0) { if (binary_cb || hunk_cb || data_cb) error = diff_patch_generate(&patch, &xo.output); } git_patch_free(&patch); if (error) break; } return error; } typedef struct { git_patch patch; git_diff_delta delta; char paths[GIT_FLEX_ARRAY]; } diff_patch_with_delta; static int diff_single_generate(diff_patch_with_delta *pd, git_xdiff_output *xo) { int error = 0; git_patch *patch = &pd->patch; bool has_old = ((patch->ofile.flags & GIT_DIFF_FLAG__NO_DATA) == 0); bool has_new = ((patch->nfile.flags & GIT_DIFF_FLAG__NO_DATA) == 0); pd->delta.status = has_new ? (has_old ? GIT_DELTA_MODIFIED : GIT_DELTA_ADDED) : (has_old ? GIT_DELTA_DELETED : GIT_DELTA_UNTRACKED); if (git_oid_equal(&patch->nfile.file->id, &patch->ofile.file->id)) pd->delta.status = GIT_DELTA_UNMODIFIED; patch->delta = &pd->delta; diff_patch_init_common(patch); if (pd->delta.status == GIT_DELTA_UNMODIFIED && !(patch->ofile.opts_flags & GIT_DIFF_INCLUDE_UNMODIFIED)) return error; error = diff_patch_invoke_file_callback(patch, (git_diff_output *)xo); if (!error) error = diff_patch_generate(patch, (git_diff_output *)xo); return error; } static int diff_patch_from_sources( diff_patch_with_delta *pd, git_xdiff_output *xo, git_diff_file_content_src *oldsrc, git_diff_file_content_src *newsrc, const git_diff_options *opts) { int error = 0; git_repository *repo = oldsrc->blob ? git_blob_owner(oldsrc->blob) : newsrc->blob ? git_blob_owner(newsrc->blob) : NULL; git_diff_file *lfile = &pd->delta.old_file, *rfile = &pd->delta.new_file; git_diff_file_content *ldata = &pd->patch.ofile, *rdata = &pd->patch.nfile; if ((error = diff_patch_normalize_options(&pd->patch.diff_opts, opts)) < 0) return error; if (opts && (opts->flags & GIT_DIFF_REVERSE) != 0) { void *tmp = lfile; lfile = rfile; rfile = tmp; tmp = ldata; ldata = rdata; rdata = tmp; } pd->patch.delta = &pd->delta; if (!oldsrc->as_path) { if (newsrc->as_path) oldsrc->as_path = newsrc->as_path; else oldsrc->as_path = newsrc->as_path = "file"; } else if (!newsrc->as_path) newsrc->as_path = oldsrc->as_path; lfile->path = oldsrc->as_path; rfile->path = newsrc->as_path; if ((error = git_diff_file_content__init_from_src( ldata, repo, opts, oldsrc, lfile)) < 0 || (error = git_diff_file_content__init_from_src( rdata, repo, opts, newsrc, rfile)) < 0) return error; return diff_single_generate(pd, xo); } static int diff_patch_with_delta_alloc( diff_patch_with_delta **out, const char **old_path, const char **new_path) { diff_patch_with_delta *pd; size_t old_len = *old_path ? strlen(*old_path) : 0; size_t new_len = *new_path ? strlen(*new_path) : 0; size_t alloc_len; GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*pd), old_len); GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, new_len); GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2); *out = pd = git__calloc(1, alloc_len); GITERR_CHECK_ALLOC(pd); pd->patch.flags = GIT_DIFF_PATCH_ALLOCATED; if (*old_path) { memcpy(&pd->paths[0], *old_path, old_len); *old_path = &pd->paths[0]; } else if (*new_path) *old_path = &pd->paths[old_len + 1]; if (*new_path) { memcpy(&pd->paths[old_len + 1], *new_path, new_len); *new_path = &pd->paths[old_len + 1]; } else if (*old_path) *new_path = &pd->paths[0]; return 0; } static int diff_from_sources( git_diff_file_content_src *oldsrc, git_diff_file_content_src *newsrc, const git_diff_options *opts, git_diff_file_cb file_cb, git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb data_cb, void *payload) { int error = 0; diff_patch_with_delta pd; git_xdiff_output xo; memset(&xo, 0, sizeof(xo)); diff_output_init( &xo.output, opts, file_cb, binary_cb, hunk_cb, data_cb, payload); git_xdiff_init(&xo, opts); memset(&pd, 0, sizeof(pd)); error = diff_patch_from_sources(&pd, &xo, oldsrc, newsrc, opts); git_patch_free(&pd.patch); return error; } static int patch_from_sources( git_patch **out, git_diff_file_content_src *oldsrc, git_diff_file_content_src *newsrc, const git_diff_options *opts) { int error = 0; diff_patch_with_delta *pd; git_xdiff_output xo; assert(out); *out = NULL; if ((error = diff_patch_with_delta_alloc( &pd, &oldsrc->as_path, &newsrc->as_path)) < 0) return error; memset(&xo, 0, sizeof(xo)); diff_output_to_patch(&xo.output, &pd->patch); git_xdiff_init(&xo, opts); if (!(error = diff_patch_from_sources(pd, &xo, oldsrc, newsrc, opts))) *out = (git_patch *)pd; else git_patch_free((git_patch *)pd); return error; } int git_diff_blobs( const git_blob *old_blob, const char *old_path, const git_blob *new_blob, const char *new_path, const git_diff_options *opts, git_diff_file_cb file_cb, git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb data_cb, void *payload) { git_diff_file_content_src osrc = GIT_DIFF_FILE_CONTENT_SRC__BLOB(old_blob, old_path); git_diff_file_content_src nsrc = GIT_DIFF_FILE_CONTENT_SRC__BLOB(new_blob, new_path); return diff_from_sources( &osrc, &nsrc, opts, file_cb, binary_cb, hunk_cb, data_cb, payload); } int git_patch_from_blobs( git_patch **out, const git_blob *old_blob, const char *old_path, const git_blob *new_blob, const char *new_path, const git_diff_options *opts) { git_diff_file_content_src osrc = GIT_DIFF_FILE_CONTENT_SRC__BLOB(old_blob, old_path); git_diff_file_content_src nsrc = GIT_DIFF_FILE_CONTENT_SRC__BLOB(new_blob, new_path); return patch_from_sources(out, &osrc, &nsrc, opts); } int git_diff_blob_to_buffer( const git_blob *old_blob, const char *old_path, const char *buf, size_t buflen, const char *buf_path, const git_diff_options *opts, git_diff_file_cb file_cb, git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb data_cb, void *payload) { git_diff_file_content_src osrc = GIT_DIFF_FILE_CONTENT_SRC__BLOB(old_blob, old_path); git_diff_file_content_src nsrc = GIT_DIFF_FILE_CONTENT_SRC__BUF(buf, buflen, buf_path); return diff_from_sources( &osrc, &nsrc, opts, file_cb, binary_cb, hunk_cb, data_cb, payload); } int git_patch_from_blob_and_buffer( git_patch **out, const git_blob *old_blob, const char *old_path, const char *buf, size_t buflen, const char *buf_path, const git_diff_options *opts) { git_diff_file_content_src osrc = GIT_DIFF_FILE_CONTENT_SRC__BLOB(old_blob, old_path); git_diff_file_content_src nsrc = GIT_DIFF_FILE_CONTENT_SRC__BUF(buf, buflen, buf_path); return patch_from_sources(out, &osrc, &nsrc, opts); } int git_diff_buffers( const void *old_buf, size_t old_len, const char *old_path, const void *new_buf, size_t new_len, const char *new_path, const git_diff_options *opts, git_diff_file_cb file_cb, git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb data_cb, void *payload) { git_diff_file_content_src osrc = GIT_DIFF_FILE_CONTENT_SRC__BUF(old_buf, old_len, old_path); git_diff_file_content_src nsrc = GIT_DIFF_FILE_CONTENT_SRC__BUF(new_buf, new_len, new_path); return diff_from_sources( &osrc, &nsrc, opts, file_cb, binary_cb, hunk_cb, data_cb, payload); } int git_patch_from_buffers( git_patch **out, const void *old_buf, size_t old_len, const char *old_path, const char *new_buf, size_t new_len, const char *new_path, const git_diff_options *opts) { git_diff_file_content_src osrc = GIT_DIFF_FILE_CONTENT_SRC__BUF(old_buf, old_len, old_path); git_diff_file_content_src nsrc = GIT_DIFF_FILE_CONTENT_SRC__BUF(new_buf, new_len, new_path); return patch_from_sources(out, &osrc, &nsrc, opts); } int git_patch_from_diff( git_patch **patch_ptr, git_diff *diff, size_t idx) { int error = 0; git_xdiff_output xo; git_diff_delta *delta = NULL; git_patch *patch = NULL; if (patch_ptr) *patch_ptr = NULL; if (diff_required(diff, "git_patch_from_diff") < 0) return -1; delta = git_vector_get(&diff->deltas, idx); if (!delta) { giterr_set(GITERR_INVALID, "Index out of range for delta in diff"); return GIT_ENOTFOUND; } if (git_diff_delta__should_skip(&diff->opts, delta)) return 0; /* don't load the patch data unless we need it for binary check */ if (!patch_ptr && ((delta->flags & DIFF_FLAGS_KNOWN_BINARY) != 0 || (diff->opts.flags & GIT_DIFF_SKIP_BINARY_CHECK) != 0)) return 0; if ((error = diff_patch_alloc_from_diff(&patch, diff, idx)) < 0) return error; memset(&xo, 0, sizeof(xo)); diff_output_to_patch(&xo.output, patch); git_xdiff_init(&xo, &diff->opts); error = diff_patch_invoke_file_callback(patch, &xo.output); if (!error) error = diff_patch_generate(patch, &xo.output); if (!error) { /* TODO: if cumulative diff size is < 0.5 total size, flatten patch */ /* TODO: and unload the file content */ } if (error || !patch_ptr) git_patch_free(patch); else *patch_ptr = patch; return error; } void git_patch_free(git_patch *patch) { if (patch) GIT_REFCOUNT_DEC(patch, diff_patch_free); } const git_diff_delta *git_patch_get_delta(const git_patch *patch) { assert(patch); return patch->delta; } size_t git_patch_num_hunks(const git_patch *patch) { assert(patch); return git_array_size(patch->hunks); } int git_patch_line_stats( size_t *total_ctxt, size_t *total_adds, size_t *total_dels, const git_patch *patch) { size_t totals[3], idx; memset(totals, 0, sizeof(totals)); for (idx = 0; idx < git_array_size(patch->lines); ++idx) { git_diff_line *line = git_array_get(patch->lines, idx); if (!line) continue; switch (line->origin) { case GIT_DIFF_LINE_CONTEXT: totals[0]++; break; case GIT_DIFF_LINE_ADDITION: totals[1]++; break; case GIT_DIFF_LINE_DELETION: totals[2]++; break; default: /* diff --stat and --numstat don't count EOFNL marks because * they will always be paired with a ADDITION or DELETION line. */ break; } } if (total_ctxt) *total_ctxt = totals[0]; if (total_adds) *total_adds = totals[1]; if (total_dels) *total_dels = totals[2]; return 0; } static int diff_error_outofrange(const char *thing) { giterr_set(GITERR_INVALID, "Diff patch %s index out of range", thing); return GIT_ENOTFOUND; } int git_patch_get_hunk( const git_diff_hunk **out, size_t *lines_in_hunk, git_patch *patch, size_t hunk_idx) { diff_patch_hunk *hunk; assert(patch); hunk = git_array_get(patch->hunks, hunk_idx); if (!hunk) { if (out) *out = NULL; if (lines_in_hunk) *lines_in_hunk = 0; return diff_error_outofrange("hunk"); } if (out) *out = &hunk->hunk; if (lines_in_hunk) *lines_in_hunk = hunk->line_count; return 0; } int git_patch_num_lines_in_hunk(const git_patch *patch, size_t hunk_idx) { diff_patch_hunk *hunk; assert(patch); if (!(hunk = git_array_get(patch->hunks, hunk_idx))) return diff_error_outofrange("hunk"); return (int)hunk->line_count; } int git_patch_get_line_in_hunk( const git_diff_line **out, git_patch *patch, size_t hunk_idx, size_t line_of_hunk) { diff_patch_hunk *hunk; git_diff_line *line; assert(patch); if (!(hunk = git_array_get(patch->hunks, hunk_idx))) { if (out) *out = NULL; return diff_error_outofrange("hunk"); } if (line_of_hunk >= hunk->line_count || !(line = git_array_get( patch->lines, hunk->line_start + line_of_hunk))) { if (out) *out = NULL; return diff_error_outofrange("line"); } if (out) *out = line; return 0; } size_t git_patch_size( git_patch *patch, int include_context, int include_hunk_headers, int include_file_headers) { size_t out; assert(patch); out = patch->content_size; if (!include_context) out -= patch->context_size; if (include_hunk_headers) out += patch->header_size; if (include_file_headers) { git_buf file_header = GIT_BUF_INIT; if (git_diff_delta__format_file_header( &file_header, patch->delta, NULL, NULL, 0) < 0) giterr_clear(); else out += git_buf_len(&file_header); git_buf_free(&file_header); } return out; } git_diff *git_patch__diff(git_patch *patch) { return patch->diff; } git_diff_driver *git_patch__driver(git_patch *patch) { /* ofile driver is representative for whole patch */ return patch->ofile.driver; } void git_patch__old_data( char **ptr, size_t *len, git_patch *patch) { *ptr = patch->ofile.map.data; *len = patch->ofile.map.len; } void git_patch__new_data( char **ptr, size_t *len, git_patch *patch) { *ptr = patch->nfile.map.data; *len = patch->nfile.map.len; } int git_patch__invoke_callbacks( git_patch *patch, git_diff_file_cb file_cb, git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb line_cb, void *payload) { int error = 0; uint32_t i, j; if (file_cb) error = file_cb(patch->delta, 0, payload); if ((patch->delta->flags & GIT_DIFF_FLAG_BINARY) != 0) { if (binary_cb) error = binary_cb(patch->delta, &patch->binary, payload); return error; } if (!hunk_cb && !line_cb) return error; for (i = 0; !error && i < git_array_size(patch->hunks); ++i) { diff_patch_hunk *h = git_array_get(patch->hunks, i); if (hunk_cb) error = hunk_cb(patch->delta, &h->hunk, payload); if (!line_cb) continue; for (j = 0; !error && j < h->line_count; ++j) { git_diff_line *l = git_array_get(patch->lines, h->line_start + j); error = line_cb(patch->delta, &h->hunk, l, payload); } } return error; } static int diff_patch_file_cb( const git_diff_delta *delta, float progress, void *payload) { GIT_UNUSED(delta); GIT_UNUSED(progress); GIT_UNUSED(payload); return 0; } static int diff_patch_binary_cb( const git_diff_delta *delta, const git_diff_binary *binary, void *payload) { git_patch *patch = payload; GIT_UNUSED(delta); memcpy(&patch->binary, binary, sizeof(git_diff_binary)); if (binary->old_file.data) { patch->binary.old_file.data = git__malloc(binary->old_file.datalen); GITERR_CHECK_ALLOC(patch->binary.old_file.data); memcpy((char *)patch->binary.old_file.data, binary->old_file.data, binary->old_file.datalen); } if (binary->new_file.data) { patch->binary.new_file.data = git__malloc(binary->new_file.datalen); GITERR_CHECK_ALLOC(patch->binary.new_file.data); memcpy((char *)patch->binary.new_file.data, binary->new_file.data, binary->new_file.datalen); } return 0; } static int diff_patch_hunk_cb( const git_diff_delta *delta, const git_diff_hunk *hunk_, void *payload) { git_patch *patch = payload; diff_patch_hunk *hunk; GIT_UNUSED(delta); hunk = git_array_alloc(patch->hunks); GITERR_CHECK_ALLOC(hunk); memcpy(&hunk->hunk, hunk_, sizeof(hunk->hunk)); patch->header_size += hunk_->header_len; hunk->line_start = git_array_size(patch->lines); hunk->line_count = 0; return 0; } static int diff_patch_line_cb( const git_diff_delta *delta, const git_diff_hunk *hunk_, const git_diff_line *line_, void *payload) { git_patch *patch = payload; diff_patch_hunk *hunk; git_diff_line *line; GIT_UNUSED(delta); GIT_UNUSED(hunk_); hunk = git_array_last(patch->hunks); assert(hunk); /* programmer error if no hunk is available */ line = git_array_alloc(patch->lines); GITERR_CHECK_ALLOC(line); memcpy(line, line_, sizeof(*line)); /* do some bookkeeping so we can provide old/new line numbers */ patch->content_size += line->content_len; if (line->origin == GIT_DIFF_LINE_ADDITION || line->origin == GIT_DIFF_LINE_DELETION) patch->content_size += 1; else if (line->origin == GIT_DIFF_LINE_CONTEXT) { patch->content_size += 1; patch->context_size += line->content_len + 1; } else if (line->origin == GIT_DIFF_LINE_CONTEXT_EOFNL) patch->context_size += line->content_len; hunk->line_count++; return 0; } static void diff_output_init( git_diff_output *out, const git_diff_options *opts, git_diff_file_cb file_cb, git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb data_cb, void *payload) { GIT_UNUSED(opts); memset(out, 0, sizeof(*out)); out->file_cb = file_cb; out->binary_cb = binary_cb; out->hunk_cb = hunk_cb; out->data_cb = data_cb; out->payload = payload; } static void diff_output_to_patch(git_diff_output *out, git_patch *patch) { diff_output_init( out, NULL, diff_patch_file_cb, diff_patch_binary_cb, diff_patch_hunk_cb, diff_patch_line_cb, patch); } deps/libgit2-sys-0.3.8/libgit2/src/revert.c0000664000175000017500000001441012510265101015336 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "repository.h" #include "filebuf.h" #include "merge.h" #include "index.h" #include "git2/types.h" #include "git2/merge.h" #include "git2/revert.h" #include "git2/commit.h" #include "git2/sys/commit.h" #define GIT_REVERT_FILE_MODE 0666 static int write_revert_head( git_repository *repo, const char *commit_oidstr) { git_filebuf file = GIT_FILEBUF_INIT; git_buf file_path = GIT_BUF_INIT; int error = 0; if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_REVERT_HEAD_FILE)) >= 0 && (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_REVERT_FILE_MODE)) >= 0 && (error = git_filebuf_printf(&file, "%s\n", commit_oidstr)) >= 0) error = git_filebuf_commit(&file); if (error < 0) git_filebuf_cleanup(&file); git_buf_free(&file_path); return error; } static int write_merge_msg( git_repository *repo, const char *commit_oidstr, const char *commit_msgline) { git_filebuf file = GIT_FILEBUF_INIT; git_buf file_path = GIT_BUF_INIT; int error = 0; if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MSG_FILE)) < 0 || (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_REVERT_FILE_MODE)) < 0 || (error = git_filebuf_printf(&file, "Revert \"%s\"\n\nThis reverts commit %s.\n", commit_msgline, commit_oidstr)) < 0) goto cleanup; error = git_filebuf_commit(&file); cleanup: if (error < 0) git_filebuf_cleanup(&file); git_buf_free(&file_path); return error; } static int revert_normalize_opts( git_repository *repo, git_revert_options *opts, const git_revert_options *given, const char *their_label) { int error = 0; unsigned int default_checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_ALLOW_CONFLICTS; GIT_UNUSED(repo); if (given != NULL) memcpy(opts, given, sizeof(git_revert_options)); else { git_revert_options default_opts = GIT_REVERT_OPTIONS_INIT; memcpy(opts, &default_opts, sizeof(git_revert_options)); } if (!opts->checkout_opts.checkout_strategy) opts->checkout_opts.checkout_strategy = default_checkout_strategy; if (!opts->checkout_opts.our_label) opts->checkout_opts.our_label = "HEAD"; if (!opts->checkout_opts.their_label) opts->checkout_opts.their_label = their_label; return error; } static int revert_state_cleanup(git_repository *repo) { const char *state_files[] = { GIT_REVERT_HEAD_FILE, GIT_MERGE_MSG_FILE }; return git_repository__cleanup_files(repo, state_files, ARRAY_SIZE(state_files)); } static int revert_seterr(git_commit *commit, const char *fmt) { char commit_oidstr[GIT_OID_HEXSZ + 1]; git_oid_fmt(commit_oidstr, git_commit_id(commit)); commit_oidstr[GIT_OID_HEXSZ] = '\0'; giterr_set(GITERR_REVERT, fmt, commit_oidstr); return -1; } int git_revert_commit( git_index **out, git_repository *repo, git_commit *revert_commit, git_commit *our_commit, unsigned int mainline, const git_merge_options *merge_opts) { git_commit *parent_commit = NULL; git_tree *parent_tree = NULL, *our_tree = NULL, *revert_tree = NULL; int parent = 0, error = 0; assert(out && repo && revert_commit && our_commit); if (git_commit_parentcount(revert_commit) > 1) { if (!mainline) return revert_seterr(revert_commit, "Mainline branch is not specified but %s is a merge commit"); parent = mainline; } else { if (mainline) return revert_seterr(revert_commit, "Mainline branch specified but %s is not a merge commit"); parent = git_commit_parentcount(revert_commit); } if (parent && ((error = git_commit_parent(&parent_commit, revert_commit, (parent - 1))) < 0 || (error = git_commit_tree(&parent_tree, parent_commit)) < 0)) goto done; if ((error = git_commit_tree(&revert_tree, revert_commit)) < 0 || (error = git_commit_tree(&our_tree, our_commit)) < 0) goto done; error = git_merge_trees(out, repo, revert_tree, our_tree, parent_tree, merge_opts); done: git_tree_free(parent_tree); git_tree_free(our_tree); git_tree_free(revert_tree); git_commit_free(parent_commit); return error; } int git_revert( git_repository *repo, git_commit *commit, const git_revert_options *given_opts) { git_revert_options opts; git_reference *our_ref = NULL; git_commit *our_commit = NULL; char commit_oidstr[GIT_OID_HEXSZ + 1]; const char *commit_msg; git_buf their_label = GIT_BUF_INIT; git_index *index = NULL; git_indexwriter indexwriter = GIT_INDEXWRITER_INIT; int error; assert(repo && commit); GITERR_CHECK_VERSION(given_opts, GIT_REVERT_OPTIONS_VERSION, "git_revert_options"); if ((error = git_repository__ensure_not_bare(repo, "revert")) < 0) return error; git_oid_fmt(commit_oidstr, git_commit_id(commit)); commit_oidstr[GIT_OID_HEXSZ] = '\0'; if ((commit_msg = git_commit_summary(commit)) == NULL) { error = -1; goto on_error; } if ((error = git_buf_printf(&their_label, "parent of %.7s... %s", commit_oidstr, commit_msg)) < 0 || (error = revert_normalize_opts(repo, &opts, given_opts, git_buf_cstr(&their_label))) < 0 || (error = git_indexwriter_init_for_operation(&indexwriter, repo, &opts.checkout_opts.checkout_strategy)) < 0 || (error = write_revert_head(repo, commit_oidstr)) < 0 || (error = write_merge_msg(repo, commit_oidstr, commit_msg)) < 0 || (error = git_repository_head(&our_ref, repo)) < 0 || (error = git_reference_peel((git_object **)&our_commit, our_ref, GIT_OBJ_COMMIT)) < 0 || (error = git_revert_commit(&index, repo, commit, our_commit, opts.mainline, &opts.merge_opts)) < 0 || (error = git_merge__check_result(repo, index)) < 0 || (error = git_merge__append_conflicts_to_merge_msg(repo, index)) < 0 || (error = git_checkout_index(repo, index, &opts.checkout_opts)) < 0 || (error = git_indexwriter_commit(&indexwriter)) < 0) goto on_error; goto done; on_error: revert_state_cleanup(repo); done: git_indexwriter_cleanup(&indexwriter); git_index_free(index); git_commit_free(our_commit); git_reference_free(our_ref); git_buf_free(&their_label); return error; } int git_revert_init_options(git_revert_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_revert_options, GIT_REVERT_OPTIONS_INIT); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/oid.c0000664000175000017500000002241012510265101014601 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "git2/oid.h" #include "repository.h" #include "global.h" #include #include static char to_hex[] = "0123456789abcdef"; static int oid_error_invalid(const char *msg) { giterr_set(GITERR_INVALID, "Unable to parse OID - %s", msg); return -1; } int git_oid_fromstrn(git_oid *out, const char *str, size_t length) { size_t p; int v; assert(out && str); if (!length) return oid_error_invalid("too short"); if (length > GIT_OID_HEXSZ) return oid_error_invalid("too long"); memset(out->id, 0, GIT_OID_RAWSZ); for (p = 0; p < length; p++) { v = git__fromhex(str[p]); if (v < 0) return oid_error_invalid("contains invalid characters"); out->id[p / 2] |= (unsigned char)(v << (p % 2 ? 0 : 4)); } return 0; } int git_oid_fromstrp(git_oid *out, const char *str) { return git_oid_fromstrn(out, str, strlen(str)); } int git_oid_fromstr(git_oid *out, const char *str) { return git_oid_fromstrn(out, str, GIT_OID_HEXSZ); } GIT_INLINE(char) *fmt_one(char *str, unsigned int val) { *str++ = to_hex[val >> 4]; *str++ = to_hex[val & 0xf]; return str; } void git_oid_nfmt(char *str, size_t n, const git_oid *oid) { size_t i, max_i; if (!oid) { memset(str, 0, n); return; } if (n > GIT_OID_HEXSZ) { memset(&str[GIT_OID_HEXSZ], 0, n - GIT_OID_HEXSZ); n = GIT_OID_HEXSZ; } max_i = n / 2; for (i = 0; i < max_i; i++) str = fmt_one(str, oid->id[i]); if (n & 1) *str++ = to_hex[oid->id[i] >> 4]; } void git_oid_fmt(char *str, const git_oid *oid) { git_oid_nfmt(str, GIT_OID_HEXSZ, oid); } void git_oid_pathfmt(char *str, const git_oid *oid) { size_t i; str = fmt_one(str, oid->id[0]); *str++ = '/'; for (i = 1; i < sizeof(oid->id); i++) str = fmt_one(str, oid->id[i]); } char *git_oid_tostr_s(const git_oid *oid) { char *str = GIT_GLOBAL->oid_fmt; git_oid_nfmt(str, GIT_OID_HEXSZ + 1, oid); return str; } char *git_oid_allocfmt(const git_oid *oid) { char *str = git__malloc(GIT_OID_HEXSZ + 1); if (!str) return NULL; git_oid_nfmt(str, GIT_OID_HEXSZ + 1, oid); return str; } char *git_oid_tostr(char *out, size_t n, const git_oid *oid) { if (!out || n == 0) return ""; if (n > GIT_OID_HEXSZ + 1) n = GIT_OID_HEXSZ + 1; git_oid_nfmt(out, n - 1, oid); /* allow room for terminating NUL */ out[n - 1] = '\0'; return out; } int git_oid__parse( git_oid *oid, const char **buffer_out, const char *buffer_end, const char *header) { const size_t sha_len = GIT_OID_HEXSZ; const size_t header_len = strlen(header); const char *buffer = *buffer_out; if (buffer + (header_len + sha_len + 1) > buffer_end) return -1; if (memcmp(buffer, header, header_len) != 0) return -1; if (buffer[header_len + sha_len] != '\n') return -1; if (git_oid_fromstr(oid, buffer + header_len) < 0) return -1; *buffer_out = buffer + (header_len + sha_len + 1); return 0; } void git_oid__writebuf(git_buf *buf, const char *header, const git_oid *oid) { char hex_oid[GIT_OID_HEXSZ]; git_oid_fmt(hex_oid, oid); git_buf_puts(buf, header); git_buf_put(buf, hex_oid, GIT_OID_HEXSZ); git_buf_putc(buf, '\n'); } void git_oid_fromraw(git_oid *out, const unsigned char *raw) { memcpy(out->id, raw, sizeof(out->id)); } void git_oid_cpy(git_oid *out, const git_oid *src) { memcpy(out->id, src->id, sizeof(out->id)); } int git_oid_cmp(const git_oid *a, const git_oid *b) { return git_oid__cmp(a, b); } int git_oid_equal(const git_oid *a, const git_oid *b) { return (git_oid__cmp(a, b) == 0); } int git_oid_ncmp(const git_oid *oid_a, const git_oid *oid_b, size_t len) { const unsigned char *a = oid_a->id; const unsigned char *b = oid_b->id; if (len > GIT_OID_HEXSZ) len = GIT_OID_HEXSZ; while (len > 1) { if (*a != *b) return 1; a++; b++; len -= 2; }; if (len) if ((*a ^ *b) & 0xf0) return 1; return 0; } int git_oid_strcmp(const git_oid *oid_a, const char *str) { const unsigned char *a; unsigned char strval; int hexval; for (a = oid_a->id; *str && (a - oid_a->id) < GIT_OID_RAWSZ; ++a) { if ((hexval = git__fromhex(*str++)) < 0) return -1; strval = (unsigned char)(hexval << 4); if (*str) { if ((hexval = git__fromhex(*str++)) < 0) return -1; strval |= hexval; } if (*a != strval) return (*a - strval); } return 0; } int git_oid_streq(const git_oid *oid_a, const char *str) { return git_oid_strcmp(oid_a, str) == 0 ? 0 : -1; } int git_oid_iszero(const git_oid *oid_a) { const unsigned char *a = oid_a->id; unsigned int i; for (i = 0; i < GIT_OID_RAWSZ; ++i, ++a) if (*a != 0) return 0; return 1; } typedef short node_index; typedef union { const char *tail; node_index children[16]; } trie_node; struct git_oid_shorten { trie_node *nodes; size_t node_count, size; int min_length, full; }; static int resize_trie(git_oid_shorten *self, size_t new_size) { self->nodes = git__reallocarray(self->nodes, new_size, sizeof(trie_node)); GITERR_CHECK_ALLOC(self->nodes); if (new_size > self->size) { memset(&self->nodes[self->size], 0x0, (new_size - self->size) * sizeof(trie_node)); } self->size = new_size; return 0; } static trie_node *push_leaf(git_oid_shorten *os, node_index idx, int push_at, const char *oid) { trie_node *node, *leaf; node_index idx_leaf; if (os->node_count >= os->size) { if (resize_trie(os, os->size * 2) < 0) return NULL; } idx_leaf = (node_index)os->node_count++; if (os->node_count == SHRT_MAX) { os->full = 1; return NULL; } node = &os->nodes[idx]; node->children[push_at] = -idx_leaf; leaf = &os->nodes[idx_leaf]; leaf->tail = oid; return node; } git_oid_shorten *git_oid_shorten_new(size_t min_length) { git_oid_shorten *os; assert((size_t)((int)min_length) == min_length); os = git__calloc(1, sizeof(git_oid_shorten)); if (os == NULL) return NULL; if (resize_trie(os, 16) < 0) { git__free(os); return NULL; } os->node_count = 1; os->min_length = (int)min_length; return os; } void git_oid_shorten_free(git_oid_shorten *os) { if (os == NULL) return; git__free(os->nodes); git__free(os); } /* * What wizardry is this? * * This is just a memory-optimized trie: basically a very fancy * 16-ary tree, which is used to store the prefixes of the OID * strings. * * Read more: http://en.wikipedia.org/wiki/Trie * * Magic that happens in this method: * * - Each node in the trie is an union, so it can work both as * a normal node, or as a leaf. * * - Each normal node points to 16 children (one for each possible * character in the oid). This is *not* stored in an array of * pointers, because in a 64-bit arch this would be sucking * 16*sizeof(void*) = 128 bytes of memory per node, which is * insane. What we do is store Node Indexes, and use these indexes * to look up each node in the om->index array. These indexes are * signed shorts, so this limits the amount of unique OIDs that * fit in the structure to about 20000 (assuming a more or less uniform * distribution). * * - All the nodes in om->index array are stored contiguously in * memory, and each of them is 32 bytes, so we fit 2x nodes per * cache line. Convenient for speed. * * - To differentiate the leafs from the normal nodes, we store all * the indexes towards a leaf as a negative index (indexes to normal * nodes are positives). When we find that one of the children for * a node has a negative value, that means it's going to be a leaf. * This reduces the amount of indexes we have by two, but also reduces * the size of each node by 1-4 bytes (the amount we would need to * add a `is_leaf` field): this is good because it allows the nodes * to fit cleanly in cache lines. * * - Once we reach an empty children, instead of continuing to insert * new nodes for each remaining character of the OID, we store a pointer * to the tail in the leaf; if the leaf is reached again, we turn it * into a normal node and use the tail to create a new leaf. * * This is a pretty good balance between performance and memory usage. */ int git_oid_shorten_add(git_oid_shorten *os, const char *text_oid) { int i; bool is_leaf; node_index idx; if (os->full) { giterr_set(GITERR_INVALID, "Unable to shorten OID - OID set full"); return -1; } if (text_oid == NULL) return os->min_length; idx = 0; is_leaf = false; for (i = 0; i < GIT_OID_HEXSZ; ++i) { int c = git__fromhex(text_oid[i]); trie_node *node; if (c == -1) { giterr_set(GITERR_INVALID, "Unable to shorten OID - invalid hex value"); return -1; } node = &os->nodes[idx]; if (is_leaf) { const char *tail; tail = node->tail; node->tail = NULL; node = push_leaf(os, idx, git__fromhex(tail[0]), &tail[1]); if (node == NULL) { if (os->full) giterr_set(GITERR_INVALID, "Unable to shorten OID - OID set full"); return -1; } } if (node->children[c] == 0) { if (push_leaf(os, idx, c, &text_oid[i + 1]) == NULL) { if (os->full) giterr_set(GITERR_INVALID, "Unable to shorten OID - OID set full"); return -1; } break; } idx = node->children[c]; is_leaf = false; if (idx < 0) { node->children[c] = idx = -idx; is_leaf = true; } } if (++i > os->min_length) os->min_length = i; return os->min_length; } deps/libgit2-sys-0.3.8/libgit2/src/revwalk.h0000664000175000017500000000211712510265101015510 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_revwalk_h__ #define INCLUDE_revwalk_h__ #include "git2/revwalk.h" #include "oidmap.h" #include "commit_list.h" #include "pqueue.h" #include "pool.h" #include "vector.h" #include "oidmap.h" struct git_revwalk { git_repository *repo; git_odb *odb; git_oidmap *commits; git_pool commit_pool; git_commit_list *iterator_topo; git_commit_list *iterator_rand; git_commit_list *iterator_reverse; git_pqueue iterator_time; int (*get_next)(git_commit_list_node **, git_revwalk *); int (*enqueue)(git_revwalk *, git_commit_list_node *); unsigned walking:1, first_parent: 1, did_hide: 1, did_push: 1; unsigned int sorting; /* the pushes and hides */ git_commit_list *user_input; /* hide callback */ git_revwalk_hide_cb hide_cb; void *hide_cb_payload; }; git_commit_list_node *git_revwalk__commit_lookup(git_revwalk *walk, const git_oid *oid); #endif deps/libgit2-sys-0.3.8/libgit2/src/filter.c0000664000175000017500000005153412572105236015336 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "fileops.h" #include "hash.h" #include "filter.h" #include "repository.h" #include "global.h" #include "git2/sys/filter.h" #include "git2/config.h" #include "blob.h" #include "attr_file.h" #include "array.h" struct git_filter_source { git_repository *repo; const char *path; git_oid oid; /* zero if unknown (which is likely) */ uint16_t filemode; /* zero if unknown */ git_filter_mode_t mode; uint32_t flags; }; typedef struct { const char *filter_name; git_filter *filter; void *payload; } git_filter_entry; struct git_filter_list { git_array_t(git_filter_entry) filters; git_filter_source source; git_buf *temp_buf; char path[GIT_FLEX_ARRAY]; }; typedef struct { char *filter_name; git_filter *filter; int priority; int initialized; size_t nattrs, nmatches; char *attrdata; const char *attrs[GIT_FLEX_ARRAY]; } git_filter_def; static int filter_def_priority_cmp(const void *a, const void *b) { int pa = ((const git_filter_def *)a)->priority; int pb = ((const git_filter_def *)b)->priority; return (pa < pb) ? -1 : (pa > pb) ? 1 : 0; } struct filter_registry { git_vector filters; }; static struct filter_registry *git__filter_registry = NULL; static void filter_registry_shutdown(void) { struct filter_registry *reg = NULL; size_t pos; git_filter_def *fdef; if ((reg = git__swap(git__filter_registry, NULL)) == NULL) return; git_vector_foreach(®->filters, pos, fdef) { if (fdef->filter && fdef->filter->shutdown) { fdef->filter->shutdown(fdef->filter); fdef->initialized = false; } git__free(fdef->filter_name); git__free(fdef->attrdata); git__free(fdef); } git_vector_free(®->filters); git__free(reg); } static int filter_registry_initialize(void) { int error = 0; struct filter_registry *reg; if (git__filter_registry) return 0; reg = git__calloc(1, sizeof(struct filter_registry)); GITERR_CHECK_ALLOC(reg); if ((error = git_vector_init( ®->filters, 2, filter_def_priority_cmp)) < 0) goto cleanup; reg = git__compare_and_swap(&git__filter_registry, NULL, reg); if (reg != NULL) goto cleanup; git__on_shutdown(filter_registry_shutdown); /* try to register both default filters */ { git_filter *crlf = git_crlf_filter_new(); git_filter *ident = git_ident_filter_new(); if (crlf && git_filter_register( GIT_FILTER_CRLF, crlf, GIT_FILTER_CRLF_PRIORITY) < 0) crlf = NULL; if (ident && git_filter_register( GIT_FILTER_IDENT, ident, GIT_FILTER_IDENT_PRIORITY) < 0) ident = NULL; if (!crlf || !ident) return -1; } return 0; cleanup: git_vector_free(®->filters); git__free(reg); return error; } static int filter_def_scan_attrs( git_buf *attrs, size_t *nattr, size_t *nmatch, const char *attr_str) { const char *start, *scan = attr_str; int has_eq; *nattr = *nmatch = 0; if (!scan) return 0; while (*scan) { while (git__isspace(*scan)) scan++; for (start = scan, has_eq = 0; *scan && !git__isspace(*scan); ++scan) { if (*scan == '=') has_eq = 1; } if (scan > start) { (*nattr)++; if (has_eq || *start == '-' || *start == '+' || *start == '!') (*nmatch)++; if (has_eq) git_buf_putc(attrs, '='); git_buf_put(attrs, start, scan - start); git_buf_putc(attrs, '\0'); } } return 0; } static void filter_def_set_attrs(git_filter_def *fdef) { char *scan = fdef->attrdata; size_t i; for (i = 0; i < fdef->nattrs; ++i) { const char *name, *value; switch (*scan) { case '=': name = scan + 1; for (scan++; *scan != '='; scan++) /* find '=' */; *scan++ = '\0'; value = scan; break; case '-': name = scan + 1; value = git_attr__false; break; case '+': name = scan + 1; value = git_attr__true; break; case '!': name = scan + 1; value = git_attr__unset; break; default: name = scan; value = NULL; break; } fdef->attrs[i] = name; fdef->attrs[i + fdef->nattrs] = value; scan += strlen(scan) + 1; } } static int filter_def_name_key_check(const void *key, const void *fdef) { const char *name = fdef ? ((const git_filter_def *)fdef)->filter_name : NULL; return name ? git__strcmp(key, name) : -1; } static int filter_def_filter_key_check(const void *key, const void *fdef) { const void *filter = fdef ? ((const git_filter_def *)fdef)->filter : NULL; return (key == filter) ? 0 : -1; } static int filter_registry_find(size_t *pos, const char *name) { return git_vector_search2( pos, &git__filter_registry->filters, filter_def_name_key_check, name); } static git_filter_def *filter_registry_lookup(size_t *pos, const char *name) { git_filter_def *fdef = NULL; if (!filter_registry_find(pos, name)) fdef = git_vector_get(&git__filter_registry->filters, *pos); return fdef; } int git_filter_register( const char *name, git_filter *filter, int priority) { git_filter_def *fdef; size_t nattr = 0, nmatch = 0, alloc_len; git_buf attrs = GIT_BUF_INIT; assert(name && filter); if (filter_registry_initialize() < 0) return -1; if (!filter_registry_find(NULL, name)) { giterr_set( GITERR_FILTER, "Attempt to reregister existing filter '%s'", name); return GIT_EEXISTS; } if (filter_def_scan_attrs(&attrs, &nattr, &nmatch, filter->attributes) < 0) return -1; GITERR_CHECK_ALLOC_MULTIPLY(&alloc_len, nattr, 2); GITERR_CHECK_ALLOC_MULTIPLY(&alloc_len, alloc_len, sizeof(char *)); GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, sizeof(git_filter_def)); fdef = git__calloc(1, alloc_len); GITERR_CHECK_ALLOC(fdef); fdef->filter_name = git__strdup(name); GITERR_CHECK_ALLOC(fdef->filter_name); fdef->filter = filter; fdef->priority = priority; fdef->nattrs = nattr; fdef->nmatches = nmatch; fdef->attrdata = git_buf_detach(&attrs); filter_def_set_attrs(fdef); if (git_vector_insert(&git__filter_registry->filters, fdef) < 0) { git__free(fdef->filter_name); git__free(fdef->attrdata); git__free(fdef); return -1; } git_vector_sort(&git__filter_registry->filters); return 0; } int git_filter_unregister(const char *name) { size_t pos; git_filter_def *fdef; assert(name); /* cannot unregister default filters */ if (!strcmp(GIT_FILTER_CRLF, name) || !strcmp(GIT_FILTER_IDENT, name)) { giterr_set(GITERR_FILTER, "Cannot unregister filter '%s'", name); return -1; } if ((fdef = filter_registry_lookup(&pos, name)) == NULL) { giterr_set(GITERR_FILTER, "Cannot find filter '%s' to unregister", name); return GIT_ENOTFOUND; } (void)git_vector_remove(&git__filter_registry->filters, pos); if (fdef->initialized && fdef->filter && fdef->filter->shutdown) { fdef->filter->shutdown(fdef->filter); fdef->initialized = false; } git__free(fdef->filter_name); git__free(fdef->attrdata); git__free(fdef); return 0; } static int filter_initialize(git_filter_def *fdef) { int error = 0; if (!fdef->initialized && fdef->filter && fdef->filter->initialize && (error = fdef->filter->initialize(fdef->filter)) < 0) { /* auto-unregister if initialize fails */ git_filter_unregister(fdef->filter_name); return error; } fdef->initialized = true; return 0; } git_filter *git_filter_lookup(const char *name) { size_t pos; git_filter_def *fdef; if (filter_registry_initialize() < 0) return NULL; if ((fdef = filter_registry_lookup(&pos, name)) == NULL) return NULL; if (!fdef->initialized && filter_initialize(fdef) < 0) return NULL; return fdef->filter; } void git_filter_free(git_filter *filter) { git__free(filter); } git_repository *git_filter_source_repo(const git_filter_source *src) { return src->repo; } const char *git_filter_source_path(const git_filter_source *src) { return src->path; } uint16_t git_filter_source_filemode(const git_filter_source *src) { return src->filemode; } const git_oid *git_filter_source_id(const git_filter_source *src) { return git_oid_iszero(&src->oid) ? NULL : &src->oid; } git_filter_mode_t git_filter_source_mode(const git_filter_source *src) { return src->mode; } uint32_t git_filter_source_flags(const git_filter_source *src) { return src->flags; } static int filter_list_new( git_filter_list **out, const git_filter_source *src) { git_filter_list *fl = NULL; size_t pathlen = src->path ? strlen(src->path) : 0, alloclen; GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_filter_list), pathlen); GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); fl = git__calloc(1, alloclen); GITERR_CHECK_ALLOC(fl); if (src->path) memcpy(fl->path, src->path, pathlen); fl->source.repo = src->repo; fl->source.path = fl->path; fl->source.mode = src->mode; fl->source.flags = src->flags; *out = fl; return 0; } static int filter_list_check_attributes( const char ***out, git_repository *repo, git_attr_session *attr_session, git_filter_def *fdef, const git_filter_source *src) { int error; size_t i; const char **strs = git__calloc(fdef->nattrs, sizeof(const char *)); GITERR_CHECK_ALLOC(strs); error = git_attr_get_many_with_session( strs, repo, attr_session, 0, src->path, fdef->nattrs, fdef->attrs); /* if no values were found but no matches are needed, it's okay! */ if (error == GIT_ENOTFOUND && !fdef->nmatches) { giterr_clear(); git__free((void *)strs); return 0; } for (i = 0; !error && i < fdef->nattrs; ++i) { const char *want = fdef->attrs[fdef->nattrs + i]; git_attr_t want_type, found_type; if (!want) continue; want_type = git_attr_value(want); found_type = git_attr_value(strs[i]); if (want_type != found_type) error = GIT_ENOTFOUND; else if (want_type == GIT_ATTR_VALUE_T && strcmp(want, strs[i]) && strcmp(want, "*")) error = GIT_ENOTFOUND; } if (error) git__free((void *)strs); else *out = strs; return error; } int git_filter_list_new( git_filter_list **out, git_repository *repo, git_filter_mode_t mode, uint32_t flags) { git_filter_source src = { 0 }; src.repo = repo; src.path = NULL; src.mode = mode; src.flags = flags; return filter_list_new(out, &src); } int git_filter_list__load_ext( git_filter_list **filters, git_repository *repo, git_blob *blob, /* can be NULL */ const char *path, git_filter_mode_t mode, git_filter_options *filter_opts) { int error = 0; git_filter_list *fl = NULL; git_filter_source src = { 0 }; git_filter_entry *fe; size_t idx; git_filter_def *fdef; if (filter_registry_initialize() < 0) return -1; src.repo = repo; src.path = path; src.mode = mode; src.flags = filter_opts->flags; if (blob) git_oid_cpy(&src.oid, git_blob_id(blob)); git_vector_foreach(&git__filter_registry->filters, idx, fdef) { const char **values = NULL; void *payload = NULL; if (!fdef || !fdef->filter) continue; if (fdef->nattrs > 0) { error = filter_list_check_attributes( &values, repo, filter_opts->attr_session, fdef, &src); if (error == GIT_ENOTFOUND) { error = 0; continue; } else if (error < 0) break; } if (!fdef->initialized && (error = filter_initialize(fdef)) < 0) break; if (fdef->filter->check) error = fdef->filter->check( fdef->filter, &payload, &src, values); git__free((void *)values); if (error == GIT_PASSTHROUGH) error = 0; else if (error < 0) break; else { if (!fl) { if ((error = filter_list_new(&fl, &src)) < 0) return error; fl->temp_buf = filter_opts->temp_buf; } fe = git_array_alloc(fl->filters); GITERR_CHECK_ALLOC(fe); fe->filter = fdef->filter; fe->filter_name = fdef->filter_name; fe->payload = payload; } } if (error && fl != NULL) { git_array_clear(fl->filters); git__free(fl); fl = NULL; } *filters = fl; return error; } int git_filter_list_load( git_filter_list **filters, git_repository *repo, git_blob *blob, /* can be NULL */ const char *path, git_filter_mode_t mode, uint32_t flags) { git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT; filter_opts.flags = flags; return git_filter_list__load_ext( filters, repo, blob, path, mode, &filter_opts); } void git_filter_list_free(git_filter_list *fl) { uint32_t i; if (!fl) return; for (i = 0; i < git_array_size(fl->filters); ++i) { git_filter_entry *fe = git_array_get(fl->filters, i); if (fe->filter->cleanup) fe->filter->cleanup(fe->filter, fe->payload); } git_array_clear(fl->filters); git__free(fl); } int git_filter_list_contains( git_filter_list *fl, const char *name) { size_t i; assert(name); if (!fl) return 0; for (i = 0; i < fl->filters.size; i++) { if (strcmp(fl->filters.ptr[i].filter_name, name) == 0) return 1; } return 0; } int git_filter_list_push( git_filter_list *fl, git_filter *filter, void *payload) { int error = 0; size_t pos; git_filter_def *fdef; git_filter_entry *fe; assert(fl && filter); if (git_vector_search2( &pos, &git__filter_registry->filters, filter_def_filter_key_check, filter) < 0) { giterr_set(GITERR_FILTER, "Cannot use an unregistered filter"); return -1; } fdef = git_vector_get(&git__filter_registry->filters, pos); if (!fdef->initialized && (error = filter_initialize(fdef)) < 0) return error; fe = git_array_alloc(fl->filters); GITERR_CHECK_ALLOC(fe); fe->filter = filter; fe->payload = payload; return 0; } size_t git_filter_list_length(const git_filter_list *fl) { return fl ? git_array_size(fl->filters) : 0; } struct buf_stream { git_writestream parent; git_buf *target; bool complete; }; static int buf_stream_write( git_writestream *s, const char *buffer, size_t len) { struct buf_stream *buf_stream = (struct buf_stream *)s; assert(buf_stream); assert(buf_stream->complete == 0); return git_buf_put(buf_stream->target, buffer, len); } static int buf_stream_close(git_writestream *s) { struct buf_stream *buf_stream = (struct buf_stream *)s; assert(buf_stream); assert(buf_stream->complete == 0); buf_stream->complete = 1; return 0; } static void buf_stream_free(git_writestream *s) { GIT_UNUSED(s); } static void buf_stream_init(struct buf_stream *writer, git_buf *target) { memset(writer, 0, sizeof(struct buf_stream)); writer->parent.write = buf_stream_write; writer->parent.close = buf_stream_close; writer->parent.free = buf_stream_free; writer->target = target; git_buf_clear(target); } int git_filter_list_apply_to_data( git_buf *tgt, git_filter_list *filters, git_buf *src) { struct buf_stream writer; int error; git_buf_sanitize(tgt); git_buf_sanitize(src); if (!filters) { git_buf_attach_notowned(tgt, src->ptr, src->size); return 0; } buf_stream_init(&writer, tgt); if ((error = git_filter_list_stream_data(filters, src, &writer.parent)) < 0) return error; assert(writer.complete); return error; } int git_filter_list_apply_to_file( git_buf *out, git_filter_list *filters, git_repository *repo, const char *path) { struct buf_stream writer; int error; buf_stream_init(&writer, out); if ((error = git_filter_list_stream_file( filters, repo, path, &writer.parent)) < 0) return error; assert(writer.complete); return error; } static int buf_from_blob(git_buf *out, git_blob *blob) { git_off_t rawsize = git_blob_rawsize(blob); if (!git__is_sizet(rawsize)) { giterr_set(GITERR_OS, "Blob is too large to filter"); return -1; } git_buf_attach_notowned(out, git_blob_rawcontent(blob), (size_t)rawsize); return 0; } int git_filter_list_apply_to_blob( git_buf *out, git_filter_list *filters, git_blob *blob) { struct buf_stream writer; int error; buf_stream_init(&writer, out); if ((error = git_filter_list_stream_blob( filters, blob, &writer.parent)) < 0) return error; assert(writer.complete); return error; } struct proxy_stream { git_writestream parent; git_filter *filter; const git_filter_source *source; void **payload; git_buf input; git_buf temp_buf; git_buf *output; git_writestream *target; }; static int proxy_stream_write( git_writestream *s, const char *buffer, size_t len) { struct proxy_stream *proxy_stream = (struct proxy_stream *)s; assert(proxy_stream); return git_buf_put(&proxy_stream->input, buffer, len); } static int proxy_stream_close(git_writestream *s) { struct proxy_stream *proxy_stream = (struct proxy_stream *)s; git_buf *writebuf; int error; assert(proxy_stream); error = proxy_stream->filter->apply( proxy_stream->filter, proxy_stream->payload, proxy_stream->output, &proxy_stream->input, proxy_stream->source); if (error == GIT_PASSTHROUGH) { writebuf = &proxy_stream->input; } else if (error == 0) { git_buf_sanitize(proxy_stream->output); writebuf = proxy_stream->output; } else { return error; } if ((error = proxy_stream->target->write( proxy_stream->target, writebuf->ptr, writebuf->size)) == 0) error = proxy_stream->target->close(proxy_stream->target); return error; } static void proxy_stream_free(git_writestream *s) { struct proxy_stream *proxy_stream = (struct proxy_stream *)s; assert(proxy_stream); git_buf_free(&proxy_stream->input); git_buf_free(&proxy_stream->temp_buf); git__free(proxy_stream); } static int proxy_stream_init( git_writestream **out, git_filter *filter, git_buf *temp_buf, void **payload, const git_filter_source *source, git_writestream *target) { struct proxy_stream *proxy_stream = git__calloc(1, sizeof(struct proxy_stream)); GITERR_CHECK_ALLOC(proxy_stream); proxy_stream->parent.write = proxy_stream_write; proxy_stream->parent.close = proxy_stream_close; proxy_stream->parent.free = proxy_stream_free; proxy_stream->filter = filter; proxy_stream->payload = payload; proxy_stream->source = source; proxy_stream->target = target; proxy_stream->output = temp_buf ? temp_buf : &proxy_stream->temp_buf; if (temp_buf) git_buf_clear(temp_buf); *out = (git_writestream *)proxy_stream; return 0; } static int stream_list_init( git_writestream **out, git_vector *streams, git_filter_list *filters, git_writestream *target) { git_writestream *last_stream = target; size_t i; int error = 0; *out = NULL; if (!filters) { *out = target; return 0; } /* Create filters last to first to get the chaining direction */ for (i = 0; i < git_array_size(filters->filters); ++i) { size_t filter_idx = (filters->source.mode == GIT_FILTER_TO_WORKTREE) ? git_array_size(filters->filters) - 1 - i : i; git_filter_entry *fe = git_array_get(filters->filters, filter_idx); git_writestream *filter_stream; assert(fe->filter->stream || fe->filter->apply); /* If necessary, create a stream that proxies the traditional * application. */ if (fe->filter->stream) error = fe->filter->stream(&filter_stream, fe->filter, &fe->payload, &filters->source, last_stream); else /* Create a stream that proxies the one-shot apply */ error = proxy_stream_init(&filter_stream, fe->filter, filters->temp_buf, &fe->payload, &filters->source, last_stream); if (error < 0) return error; git_vector_insert(streams, filter_stream); last_stream = filter_stream; } *out = last_stream; return 0; } void stream_list_free(git_vector *streams) { git_writestream *stream; size_t i; git_vector_foreach(streams, i, stream) stream->free(stream); git_vector_free(streams); } int git_filter_list_stream_file( git_filter_list *filters, git_repository *repo, const char *path, git_writestream *target) { char buf[FILTERIO_BUFSIZE]; git_buf abspath = GIT_BUF_INIT; const char *base = repo ? git_repository_workdir(repo) : NULL; git_vector filter_streams = GIT_VECTOR_INIT; git_writestream *stream_start; ssize_t readlen; int fd = -1, error; if ((error = stream_list_init( &stream_start, &filter_streams, filters, target)) < 0 || (error = git_path_join_unrooted(&abspath, path, base, NULL)) < 0) goto done; if ((fd = git_futils_open_ro(abspath.ptr)) < 0) { error = fd; goto done; } while ((readlen = p_read(fd, buf, sizeof(buf))) > 0) { if ((error = stream_start->write(stream_start, buf, readlen)) < 0) goto done; } if (!readlen) error = stream_start->close(stream_start); else if (readlen < 0) error = readlen; done: if (fd >= 0) p_close(fd); stream_list_free(&filter_streams); git_buf_free(&abspath); return error; } int git_filter_list_stream_data( git_filter_list *filters, git_buf *data, git_writestream *target) { git_vector filter_streams = GIT_VECTOR_INIT; git_writestream *stream_start; int error = 0, close_error; git_buf_sanitize(data); if ((error = stream_list_init(&stream_start, &filter_streams, filters, target)) < 0) goto out; error = stream_start->write(stream_start, data->ptr, data->size); out: close_error = stream_start->close(stream_start); stream_list_free(&filter_streams); /* propagate the stream init or write error */ return error < 0 ? error : close_error; } int git_filter_list_stream_blob( git_filter_list *filters, git_blob *blob, git_writestream *target) { git_buf in = GIT_BUF_INIT; if (buf_from_blob(&in, blob) < 0) return -1; if (filters) git_oid_cpy(&filters->source.oid, git_blob_id(blob)); return git_filter_list_stream_data(filters, &in, target); } deps/libgit2-sys-0.3.8/libgit2/src/sortedcache.c0000664000175000017500000002067212510265101016322 0ustar #include "sortedcache.h" GIT__USE_STRMAP int git_sortedcache_new( git_sortedcache **out, size_t item_path_offset, git_sortedcache_free_item_fn free_item, void *free_item_payload, git_vector_cmp item_cmp, const char *path) { git_sortedcache *sc; size_t pathlen, alloclen; pathlen = path ? strlen(path) : 0; GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_sortedcache), pathlen); GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); sc = git__calloc(1, alloclen); GITERR_CHECK_ALLOC(sc); if (git_pool_init(&sc->pool, 1, 0) < 0 || git_vector_init(&sc->items, 4, item_cmp) < 0 || git_strmap_alloc(&sc->map) < 0) goto fail; if (git_rwlock_init(&sc->lock)) { giterr_set(GITERR_OS, "Failed to initialize lock"); goto fail; } sc->item_path_offset = item_path_offset; sc->free_item = free_item; sc->free_item_payload = free_item_payload; GIT_REFCOUNT_INC(sc); if (pathlen) memcpy(sc->path, path, pathlen); *out = sc; return 0; fail: git_strmap_free(sc->map); git_vector_free(&sc->items); git_pool_clear(&sc->pool); git__free(sc); return -1; } void git_sortedcache_incref(git_sortedcache *sc) { GIT_REFCOUNT_INC(sc); } const char *git_sortedcache_path(git_sortedcache *sc) { return sc->path; } static void sortedcache_clear(git_sortedcache *sc) { git_strmap_clear(sc->map); if (sc->free_item) { size_t i; void *item; git_vector_foreach(&sc->items, i, item) { sc->free_item(sc->free_item_payload, item); } } git_vector_clear(&sc->items); git_pool_clear(&sc->pool); } static void sortedcache_free(git_sortedcache *sc) { /* acquire write lock to make sure everyone else is done */ if (git_sortedcache_wlock(sc) < 0) return; sortedcache_clear(sc); git_vector_free(&sc->items); git_strmap_free(sc->map); git_sortedcache_wunlock(sc); git_rwlock_free(&sc->lock); git__free(sc); } void git_sortedcache_free(git_sortedcache *sc) { if (!sc) return; GIT_REFCOUNT_DEC(sc, sortedcache_free); } static int sortedcache_copy_item(void *payload, void *tgt_item, void *src_item) { git_sortedcache *sc = payload; /* path will already have been copied by upsert */ memcpy(tgt_item, src_item, sc->item_path_offset); return 0; } /* copy a sorted cache */ int git_sortedcache_copy( git_sortedcache **out, git_sortedcache *src, bool lock, int (*copy_item)(void *payload, void *tgt_item, void *src_item), void *payload) { int error = 0; git_sortedcache *tgt; size_t i; void *src_item, *tgt_item; /* just use memcpy if no special copy fn is passed in */ if (!copy_item) { copy_item = sortedcache_copy_item; payload = src; } if ((error = git_sortedcache_new( &tgt, src->item_path_offset, src->free_item, src->free_item_payload, src->items._cmp, src->path)) < 0) return error; if (lock && git_sortedcache_rlock(src) < 0) { git_sortedcache_free(tgt); return -1; } git_vector_foreach(&src->items, i, src_item) { char *path = ((char *)src_item) + src->item_path_offset; if ((error = git_sortedcache_upsert(&tgt_item, tgt, path)) < 0 || (error = copy_item(payload, tgt_item, src_item)) < 0) break; } if (lock) git_sortedcache_runlock(src); if (error) git_sortedcache_free(tgt); *out = !error ? tgt : NULL; return error; } /* lock sortedcache while making modifications */ int git_sortedcache_wlock(git_sortedcache *sc) { GIT_UNUSED(sc); /* prevent warning when compiled w/o threads */ if (git_rwlock_wrlock(&sc->lock) < 0) { giterr_set(GITERR_OS, "Unable to acquire write lock on cache"); return -1; } return 0; } /* unlock sorted cache when done with modifications */ void git_sortedcache_wunlock(git_sortedcache *sc) { git_vector_sort(&sc->items); git_rwlock_wrunlock(&sc->lock); } /* lock sortedcache for read */ int git_sortedcache_rlock(git_sortedcache *sc) { GIT_UNUSED(sc); /* prevent warning when compiled w/o threads */ if (git_rwlock_rdlock(&sc->lock) < 0) { giterr_set(GITERR_OS, "Unable to acquire read lock on cache"); return -1; } return 0; } /* unlock sorted cache when done reading */ void git_sortedcache_runlock(git_sortedcache *sc) { GIT_UNUSED(sc); /* prevent warning when compiled w/o threads */ git_rwlock_rdunlock(&sc->lock); } /* if the file has changed, lock cache and load file contents into buf; * returns <0 on error, >0 if file has not changed */ int git_sortedcache_lockandload(git_sortedcache *sc, git_buf *buf) { int error, fd; if ((error = git_sortedcache_wlock(sc)) < 0) return error; if ((error = git_futils_filestamp_check(&sc->stamp, sc->path)) <= 0) goto unlock; if (!git__is_sizet(sc->stamp.size)) { giterr_set(GITERR_INVALID, "Unable to load file larger than size_t"); error = -1; goto unlock; } if ((fd = git_futils_open_ro(sc->path)) < 0) { error = fd; goto unlock; } if (buf) error = git_futils_readbuffer_fd(buf, fd, (size_t)sc->stamp.size); (void)p_close(fd); if (error < 0) goto unlock; return 1; /* return 1 -> file needs reload and was successfully loaded */ unlock: git_sortedcache_wunlock(sc); return error; } void git_sortedcache_updated(git_sortedcache *sc) { /* update filestamp to latest value */ git_futils_filestamp_check(&sc->stamp, sc->path); } /* release all items in sorted cache */ int git_sortedcache_clear(git_sortedcache *sc, bool wlock) { if (wlock && git_sortedcache_wlock(sc) < 0) return -1; sortedcache_clear(sc); if (wlock) git_sortedcache_wunlock(sc); return 0; } /* find and/or insert item, returning pointer to item data */ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key) { int error = 0; khiter_t pos; void *item; size_t keylen, itemlen; char *item_key; pos = git_strmap_lookup_index(sc->map, key); if (git_strmap_valid_index(sc->map, pos)) { item = git_strmap_value_at(sc->map, pos); goto done; } keylen = strlen(key); itemlen = sc->item_path_offset + keylen + 1; itemlen = (itemlen + 7) & ~7; if ((item = git_pool_mallocz(&sc->pool, (uint32_t)itemlen)) == NULL) { /* don't use GITERR_CHECK_ALLOC b/c of lock */ error = -1; goto done; } /* one strange thing is that even if the vector or hash table insert * fail, there is no way to free the pool item so we just abandon it */ item_key = ((char *)item) + sc->item_path_offset; memcpy(item_key, key, keylen); pos = kh_put(str, sc->map, item_key, &error); if (error < 0) goto done; if (!error) kh_key(sc->map, pos) = item_key; kh_val(sc->map, pos) = item; error = git_vector_insert(&sc->items, item); if (error < 0) git_strmap_delete_at(sc->map, pos); done: if (out) *out = !error ? item : NULL; return error; } /* lookup item by key */ void *git_sortedcache_lookup(const git_sortedcache *sc, const char *key) { khiter_t pos = git_strmap_lookup_index(sc->map, key); if (git_strmap_valid_index(sc->map, pos)) return git_strmap_value_at(sc->map, pos); return NULL; } /* find out how many items are in the cache */ size_t git_sortedcache_entrycount(const git_sortedcache *sc) { return git_vector_length(&sc->items); } /* lookup item by index */ void *git_sortedcache_entry(git_sortedcache *sc, size_t pos) { /* make sure the items are sorted so this gets the correct item */ if (!git_vector_is_sorted(&sc->items)) git_vector_sort(&sc->items); return git_vector_get(&sc->items, pos); } /* helper struct so bsearch callback can know offset + key value for cmp */ struct sortedcache_magic_key { size_t offset; const char *key; }; static int sortedcache_magic_cmp(const void *key, const void *value) { const struct sortedcache_magic_key *magic = key; const char *value_key = ((const char *)value) + magic->offset; return strcmp(magic->key, value_key); } /* lookup index of item by key */ int git_sortedcache_lookup_index( size_t *out, git_sortedcache *sc, const char *key) { struct sortedcache_magic_key magic; magic.offset = sc->item_path_offset; magic.key = key; return git_vector_bsearch2(out, &sc->items, sortedcache_magic_cmp, &magic); } /* remove entry from cache */ int git_sortedcache_remove(git_sortedcache *sc, size_t pos) { char *item; khiter_t mappos; /* because of pool allocation, this can't actually remove the item, * but we can remove it from the items vector and the hash table. */ if ((item = git_vector_get(&sc->items, pos)) == NULL) { giterr_set(GITERR_INVALID, "Removing item out of range"); return GIT_ENOTFOUND; } (void)git_vector_remove(&sc->items, pos); mappos = git_strmap_lookup_index(sc->map, item + sc->item_path_offset); git_strmap_delete_at(sc->map, mappos); if (sc->free_item) sc->free_item(sc->free_item_payload, item); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/tag.c0000664000175000017500000002675712510265101014623 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "commit.h" #include "tag.h" #include "signature.h" #include "message.h" #include "git2/object.h" #include "git2/repository.h" #include "git2/signature.h" #include "git2/odb_backend.h" void git_tag__free(void *_tag) { git_tag *tag = _tag; git_signature_free(tag->tagger); git__free(tag->message); git__free(tag->tag_name); git__free(tag); } int git_tag_target(git_object **target, const git_tag *t) { assert(t); return git_object_lookup(target, t->object.repo, &t->target, t->type); } const git_oid *git_tag_target_id(const git_tag *t) { assert(t); return &t->target; } git_otype git_tag_target_type(const git_tag *t) { assert(t); return t->type; } const char *git_tag_name(const git_tag *t) { assert(t); return t->tag_name; } const git_signature *git_tag_tagger(const git_tag *t) { return t->tagger; } const char *git_tag_message(const git_tag *t) { assert(t); return t->message; } static int tag_error(const char *str) { giterr_set(GITERR_TAG, "Failed to parse tag. %s", str); return -1; } static int tag_parse(git_tag *tag, const char *buffer, const char *buffer_end) { static const char *tag_types[] = { NULL, "commit\n", "tree\n", "blob\n", "tag\n" }; unsigned int i; size_t text_len, alloc_len; char *search; if (git_oid__parse(&tag->target, &buffer, buffer_end, "object ") < 0) return tag_error("Object field invalid"); if (buffer + 5 >= buffer_end) return tag_error("Object too short"); if (memcmp(buffer, "type ", 5) != 0) return tag_error("Type field not found"); buffer += 5; tag->type = GIT_OBJ_BAD; for (i = 1; i < ARRAY_SIZE(tag_types); ++i) { size_t type_length = strlen(tag_types[i]); if (buffer + type_length >= buffer_end) return tag_error("Object too short"); if (memcmp(buffer, tag_types[i], type_length) == 0) { tag->type = i; buffer += type_length; break; } } if (tag->type == GIT_OBJ_BAD) return tag_error("Invalid object type"); if (buffer + 4 >= buffer_end) return tag_error("Object too short"); if (memcmp(buffer, "tag ", 4) != 0) return tag_error("Tag field not found"); buffer += 4; search = memchr(buffer, '\n', buffer_end - buffer); if (search == NULL) return tag_error("Object too short"); text_len = search - buffer; GITERR_CHECK_ALLOC_ADD(&alloc_len, text_len, 1); tag->tag_name = git__malloc(alloc_len); GITERR_CHECK_ALLOC(tag->tag_name); memcpy(tag->tag_name, buffer, text_len); tag->tag_name[text_len] = '\0'; buffer = search + 1; tag->tagger = NULL; if (buffer < buffer_end && *buffer != '\n') { tag->tagger = git__malloc(sizeof(git_signature)); GITERR_CHECK_ALLOC(tag->tagger); if (git_signature__parse(tag->tagger, &buffer, buffer_end, "tagger ", '\n') < 0) return -1; } tag->message = NULL; if (buffer < buffer_end) { if( *buffer != '\n' ) return tag_error("No new line before message"); text_len = buffer_end - ++buffer; GITERR_CHECK_ALLOC_ADD(&alloc_len, text_len, 1); tag->message = git__malloc(alloc_len); GITERR_CHECK_ALLOC(tag->message); memcpy(tag->message, buffer, text_len); tag->message[text_len] = '\0'; } return 0; } int git_tag__parse(void *_tag, git_odb_object *odb_obj) { git_tag *tag = _tag; const char *buffer = git_odb_object_data(odb_obj); const char *buffer_end = buffer + git_odb_object_size(odb_obj); return tag_parse(tag, buffer, buffer_end); } static int retrieve_tag_reference( git_reference **tag_reference_out, git_buf *ref_name_out, git_repository *repo, const char *tag_name) { git_reference *tag_ref; int error; *tag_reference_out = NULL; if (git_buf_joinpath(ref_name_out, GIT_REFS_TAGS_DIR, tag_name) < 0) return -1; error = git_reference_lookup(&tag_ref, repo, ref_name_out->ptr); if (error < 0) return error; /* Be it not foundo or corrupted */ *tag_reference_out = tag_ref; return 0; } static int retrieve_tag_reference_oid( git_oid *oid, git_buf *ref_name_out, git_repository *repo, const char *tag_name) { if (git_buf_joinpath(ref_name_out, GIT_REFS_TAGS_DIR, tag_name) < 0) return -1; return git_reference_name_to_id(oid, repo, ref_name_out->ptr); } static int write_tag_annotation( git_oid *oid, git_repository *repo, const char *tag_name, const git_object *target, const git_signature *tagger, const char *message) { git_buf tag = GIT_BUF_INIT; git_odb *odb; git_oid__writebuf(&tag, "object ", git_object_id(target)); git_buf_printf(&tag, "type %s\n", git_object_type2string(git_object_type(target))); git_buf_printf(&tag, "tag %s\n", tag_name); git_signature__writebuf(&tag, "tagger ", tagger); git_buf_putc(&tag, '\n'); if (git_buf_puts(&tag, message) < 0) goto on_error; if (git_repository_odb__weakptr(&odb, repo) < 0) goto on_error; if (git_odb_write(oid, odb, tag.ptr, tag.size, GIT_OBJ_TAG) < 0) goto on_error; git_buf_free(&tag); return 0; on_error: git_buf_free(&tag); giterr_set(GITERR_OBJECT, "Failed to create tag annotation."); return -1; } static int git_tag_create__internal( git_oid *oid, git_repository *repo, const char *tag_name, const git_object *target, const git_signature *tagger, const char *message, int allow_ref_overwrite, int create_tag_annotation) { git_reference *new_ref = NULL; git_buf ref_name = GIT_BUF_INIT; int error; assert(repo && tag_name && target); assert(!create_tag_annotation || (tagger && message)); if (git_object_owner(target) != repo) { giterr_set(GITERR_INVALID, "The given target does not belong to this repository"); return -1; } error = retrieve_tag_reference_oid(oid, &ref_name, repo, tag_name); if (error < 0 && error != GIT_ENOTFOUND) goto cleanup; /** Ensure the tag name doesn't conflict with an already existing * reference unless overwriting has explicitly been requested **/ if (error == 0 && !allow_ref_overwrite) { git_buf_free(&ref_name); giterr_set(GITERR_TAG, "Tag already exists"); return GIT_EEXISTS; } if (create_tag_annotation) { if (write_tag_annotation(oid, repo, tag_name, target, tagger, message) < 0) return -1; } else git_oid_cpy(oid, git_object_id(target)); error = git_reference_create(&new_ref, repo, ref_name.ptr, oid, allow_ref_overwrite, NULL); cleanup: git_reference_free(new_ref); git_buf_free(&ref_name); return error; } int git_tag_create( git_oid *oid, git_repository *repo, const char *tag_name, const git_object *target, const git_signature *tagger, const char *message, int allow_ref_overwrite) { return git_tag_create__internal(oid, repo, tag_name, target, tagger, message, allow_ref_overwrite, 1); } int git_tag_annotation_create( git_oid *oid, git_repository *repo, const char *tag_name, const git_object *target, const git_signature *tagger, const char *message) { assert(oid && repo && tag_name && target && tagger && message); return write_tag_annotation(oid, repo, tag_name, target, tagger, message); } int git_tag_create_lightweight( git_oid *oid, git_repository *repo, const char *tag_name, const git_object *target, int allow_ref_overwrite) { return git_tag_create__internal(oid, repo, tag_name, target, NULL, NULL, allow_ref_overwrite, 0); } int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *buffer, int allow_ref_overwrite) { git_tag tag; int error; git_odb *odb; git_odb_stream *stream; git_odb_object *target_obj; git_reference *new_ref = NULL; git_buf ref_name = GIT_BUF_INIT; assert(oid && buffer); memset(&tag, 0, sizeof(tag)); if (git_repository_odb__weakptr(&odb, repo) < 0) return -1; /* validate the buffer */ if (tag_parse(&tag, buffer, buffer + strlen(buffer)) < 0) return -1; /* validate the target */ if (git_odb_read(&target_obj, odb, &tag.target) < 0) goto on_error; if (tag.type != target_obj->cached.type) { giterr_set(GITERR_TAG, "The type for the given target is invalid"); goto on_error; } error = retrieve_tag_reference_oid(oid, &ref_name, repo, tag.tag_name); if (error < 0 && error != GIT_ENOTFOUND) goto on_error; /* We don't need these objects after this */ git_signature_free(tag.tagger); git__free(tag.tag_name); git__free(tag.message); git_odb_object_free(target_obj); /** Ensure the tag name doesn't conflict with an already existing * reference unless overwriting has explictly been requested **/ if (error == 0 && !allow_ref_overwrite) { giterr_set(GITERR_TAG, "Tag already exists"); return GIT_EEXISTS; } /* write the buffer */ if ((error = git_odb_open_wstream( &stream, odb, strlen(buffer), GIT_OBJ_TAG)) < 0) return error; if (!(error = git_odb_stream_write(stream, buffer, strlen(buffer)))) error = git_odb_stream_finalize_write(oid, stream); git_odb_stream_free(stream); if (error < 0) { git_buf_free(&ref_name); return error; } error = git_reference_create( &new_ref, repo, ref_name.ptr, oid, allow_ref_overwrite, NULL); git_reference_free(new_ref); git_buf_free(&ref_name); return error; on_error: git_signature_free(tag.tagger); git__free(tag.tag_name); git__free(tag.message); git_odb_object_free(target_obj); return -1; } int git_tag_delete(git_repository *repo, const char *tag_name) { git_reference *tag_ref; git_buf ref_name = GIT_BUF_INIT; int error; error = retrieve_tag_reference(&tag_ref, &ref_name, repo, tag_name); git_buf_free(&ref_name); if (error < 0) return error; error = git_reference_delete(tag_ref); git_reference_free(tag_ref); return error; } typedef struct { git_repository *repo; git_tag_foreach_cb cb; void *cb_data; } tag_cb_data; static int tags_cb(const char *ref, void *data) { int error; git_oid oid; tag_cb_data *d = (tag_cb_data *)data; if (git__prefixcmp(ref, GIT_REFS_TAGS_DIR) != 0) return 0; /* no tag */ if (!(error = git_reference_name_to_id(&oid, d->repo, ref))) { if ((error = d->cb(ref, &oid, d->cb_data)) != 0) giterr_set_after_callback_function(error, "git_tag_foreach"); } return error; } int git_tag_foreach(git_repository *repo, git_tag_foreach_cb cb, void *cb_data) { tag_cb_data data; assert(repo && cb); data.cb = cb; data.cb_data = cb_data; data.repo = repo; return git_reference_foreach_name(repo, &tags_cb, &data); } typedef struct { git_vector *taglist; const char *pattern; } tag_filter_data; #define GIT_REFS_TAGS_DIR_LEN strlen(GIT_REFS_TAGS_DIR) static int tag_list_cb(const char *tag_name, git_oid *oid, void *data) { tag_filter_data *filter = (tag_filter_data *)data; GIT_UNUSED(oid); if (!*filter->pattern || p_fnmatch(filter->pattern, tag_name + GIT_REFS_TAGS_DIR_LEN, 0) == 0) { char *matched = git__strdup(tag_name + GIT_REFS_TAGS_DIR_LEN); GITERR_CHECK_ALLOC(matched); return git_vector_insert(filter->taglist, matched); } return 0; } int git_tag_list_match(git_strarray *tag_names, const char *pattern, git_repository *repo) { int error; tag_filter_data filter; git_vector taglist; assert(tag_names && repo && pattern); if ((error = git_vector_init(&taglist, 8, NULL)) < 0) return error; filter.taglist = &taglist; filter.pattern = pattern; error = git_tag_foreach(repo, &tag_list_cb, (void *)&filter); if (error < 0) git_vector_free(&taglist); tag_names->strings = (char **)git_vector_detach(&tag_names->count, NULL, &taglist); return 0; } int git_tag_list(git_strarray *tag_names, git_repository *repo) { return git_tag_list_match(tag_names, "", repo); } int git_tag_peel(git_object **tag_target, const git_tag *tag) { return git_object_peel(tag_target, (const git_object *)tag, GIT_OBJ_ANY); } deps/libgit2-sys-0.3.8/libgit2/src/hash.h0000664000175000017500000000211012510265101014751 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_hash_h__ #define INCLUDE_hash_h__ #include "git2/oid.h" typedef struct git_hash_prov git_hash_prov; typedef struct git_hash_ctx git_hash_ctx; int git_hash_global_init(void); int git_hash_ctx_init(git_hash_ctx *ctx); void git_hash_ctx_cleanup(git_hash_ctx *ctx); #if defined(GIT_COMMON_CRYPTO) # include "hash/hash_common_crypto.h" #elif defined(OPENSSL_SHA1) # include "hash/hash_openssl.h" #elif defined(WIN32_SHA1) # include "hash/hash_win32.h" #else # include "hash/hash_generic.h" #endif typedef struct { void *data; size_t len; } git_buf_vec; int git_hash_init(git_hash_ctx *c); int git_hash_update(git_hash_ctx *c, const void *data, size_t len); int git_hash_final(git_oid *out, git_hash_ctx *c); int git_hash_buf(git_oid *out, const void *data, size_t len); int git_hash_vec(git_oid *out, git_buf_vec *vec, size_t n); #endif /* INCLUDE_hash_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/merge.h0000664000175000017500000001100012555730137015142 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_merge_h__ #define INCLUDE_merge_h__ #include "vector.h" #include "commit_list.h" #include "pool.h" #include "iterator.h" #include "git2/merge.h" #include "git2/types.h" #define GIT_MERGE_MSG_FILE "MERGE_MSG" #define GIT_MERGE_MODE_FILE "MERGE_MODE" #define GIT_MERGE_FILE_MODE 0666 #define GIT_MERGE_TREE_RENAME_THRESHOLD 50 #define GIT_MERGE_TREE_TARGET_LIMIT 1000 /** Types of changes when files are merged from branch to branch. */ typedef enum { /* No conflict - a change only occurs in one branch. */ GIT_MERGE_DIFF_NONE = 0, /* Occurs when a file is modified in both branches. */ GIT_MERGE_DIFF_BOTH_MODIFIED = (1 << 0), /* Occurs when a file is added in both branches. */ GIT_MERGE_DIFF_BOTH_ADDED = (1 << 1), /* Occurs when a file is deleted in both branches. */ GIT_MERGE_DIFF_BOTH_DELETED = (1 << 2), /* Occurs when a file is modified in one branch and deleted in the other. */ GIT_MERGE_DIFF_MODIFIED_DELETED = (1 << 3), /* Occurs when a file is renamed in one branch and modified in the other. */ GIT_MERGE_DIFF_RENAMED_MODIFIED = (1 << 4), /* Occurs when a file is renamed in one branch and deleted in the other. */ GIT_MERGE_DIFF_RENAMED_DELETED = (1 << 5), /* Occurs when a file is renamed in one branch and a file with the same * name is added in the other. Eg, A->B and new file B. Core git calls * this a "rename/delete". */ GIT_MERGE_DIFF_RENAMED_ADDED = (1 << 6), /* Occurs when both a file is renamed to the same name in the ours and * theirs branches. Eg, A->B and A->B in both. Automergeable. */ GIT_MERGE_DIFF_BOTH_RENAMED = (1 << 7), /* Occurs when a file is renamed to different names in the ours and theirs * branches. Eg, A->B and A->C. */ GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2 = (1 << 8), /* Occurs when two files are renamed to the same name in the ours and * theirs branches. Eg, A->C and B->C. */ GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1 = (1 << 9), /* Occurs when an item at a path in one branch is a directory, and an * item at the same path in a different branch is a file. */ GIT_MERGE_DIFF_DIRECTORY_FILE = (1 << 10), /* The child of a folder that is in a directory/file conflict. */ GIT_MERGE_DIFF_DF_CHILD = (1 << 11), } git_merge_diff_type_t; typedef struct { git_repository *repo; git_pool pool; /* Vector of git_index_entry that represent the merged items that * have been staged, either because only one side changed, or because * the two changes were non-conflicting and mergeable. These items * will be written as staged entries in the main index. */ git_vector staged; /* Vector of git_merge_diff entries that represent the conflicts that * have not been automerged. These items will be written to high-stage * entries in the main index. */ git_vector conflicts; /* Vector of git_merge_diff that have been automerged. These items * will be written to the REUC when the index is produced. */ git_vector resolved; } git_merge_diff_list; /** * Description of changes to one file across three trees. */ typedef struct { git_merge_diff_type_t type; git_index_entry ancestor_entry; git_index_entry our_entry; git_delta_t our_status; git_index_entry their_entry; git_delta_t their_status; } git_merge_diff; int git_merge__bases_many( git_commit_list **out, git_revwalk *walk, git_commit_list_node *one, git_vector *twos); /* * Three-way tree differencing */ git_merge_diff_list *git_merge_diff_list__alloc(git_repository *repo); int git_merge_diff_list__find_differences( git_merge_diff_list *merge_diff_list, git_iterator *ancestor_iterator, git_iterator *ours_iter, git_iterator *theirs_iter); int git_merge_diff_list__find_renames(git_repository *repo, git_merge_diff_list *merge_diff_list, const git_merge_options *opts); void git_merge_diff_list__free(git_merge_diff_list *diff_list); /* Merge metadata setup */ int git_merge__setup( git_repository *repo, const git_annotated_commit *our_head, const git_annotated_commit *heads[], size_t heads_len); int git_merge__iterators( git_index **out, git_repository *repo, git_iterator *ancestor_iter, git_iterator *our_iter, git_iterator *their_iter, const git_merge_options *given_opts); int git_merge__check_result(git_repository *repo, git_index *index_new); int git_merge__append_conflicts_to_merge_msg(git_repository *repo, git_index *index); #endif deps/libgit2-sys-0.3.8/libgit2/src/pqueue.c0000664000175000017500000000467412426525445015366 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "pqueue.h" #include "util.h" #define PQUEUE_LCHILD_OF(I) (((I)<<1)+1) #define PQUEUE_RCHILD_OF(I) (((I)<<1)+2) #define PQUEUE_PARENT_OF(I) (((I)-1)>>1) int git_pqueue_init( git_pqueue *pq, uint32_t flags, size_t init_size, git_vector_cmp cmp) { int error = git_vector_init(pq, init_size, cmp); if (!error) { /* mix in our flags */ pq->flags |= flags; /* if fixed size heap, pretend vector is exactly init_size elements */ if ((flags & GIT_PQUEUE_FIXED_SIZE) && init_size > 0) pq->_alloc_size = init_size; } return error; } static void pqueue_up(git_pqueue *pq, size_t el) { size_t parent_el = PQUEUE_PARENT_OF(el); void *kid = git_vector_get(pq, el); while (el > 0) { void *parent = pq->contents[parent_el]; if (pq->_cmp(parent, kid) <= 0) break; pq->contents[el] = parent; el = parent_el; parent_el = PQUEUE_PARENT_OF(el); } pq->contents[el] = kid; } static void pqueue_down(git_pqueue *pq, size_t el) { void *parent = git_vector_get(pq, el), *kid, *rkid; while (1) { size_t kid_el = PQUEUE_LCHILD_OF(el); if ((kid = git_vector_get(pq, kid_el)) == NULL) break; if ((rkid = git_vector_get(pq, kid_el + 1)) != NULL && pq->_cmp(kid, rkid) > 0) { kid = rkid; kid_el += 1; } if (pq->_cmp(parent, kid) <= 0) break; pq->contents[el] = kid; el = kid_el; } pq->contents[el] = parent; } int git_pqueue_insert(git_pqueue *pq, void *item) { int error = 0; /* if heap is full, pop the top element if new one should replace it */ if ((pq->flags & GIT_PQUEUE_FIXED_SIZE) != 0 && pq->length >= pq->_alloc_size) { /* skip this item if below min item in heap */ if (pq->_cmp(item, git_vector_get(pq, 0)) <= 0) return 0; /* otherwise remove the min item before inserting new */ (void)git_pqueue_pop(pq); } if (!(error = git_vector_insert(pq, item))) pqueue_up(pq, pq->length - 1); return error; } void *git_pqueue_pop(git_pqueue *pq) { void *rval = git_pqueue_get(pq, 0); if (git_pqueue_size(pq) > 1) { /* move last item to top of heap, shrink, and push item down */ pq->contents[0] = git_vector_last(pq); git_vector_pop(pq); pqueue_down(pq, 0); } else { /* all we need to do is shrink the heap in this case */ git_vector_pop(pq); } return rval; } deps/libgit2-sys-0.3.8/libgit2/src/graph.c0000664000175000017500000001036112510265101015131 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "revwalk.h" #include "merge.h" #include "git2/graph.h" static int interesting(git_pqueue *list, git_commit_list *roots) { unsigned int i; for (i = 0; i < git_pqueue_size(list); i++) { git_commit_list_node *commit = git_pqueue_get(list, i); if ((commit->flags & STALE) == 0) return 1; } while(roots) { if ((roots->item->flags & STALE) == 0) return 1; roots = roots->next; } return 0; } static int mark_parents(git_revwalk *walk, git_commit_list_node *one, git_commit_list_node *two) { unsigned int i; git_commit_list *roots = NULL; git_pqueue list; /* if the commit is repeated, we have a our merge base already */ if (one == two) { one->flags |= PARENT1 | PARENT2 | RESULT; return 0; } if (git_pqueue_init(&list, 0, 2, git_commit_list_time_cmp) < 0) return -1; if (git_commit_list_parse(walk, one) < 0) goto on_error; one->flags |= PARENT1; if (git_pqueue_insert(&list, one) < 0) goto on_error; if (git_commit_list_parse(walk, two) < 0) goto on_error; two->flags |= PARENT2; if (git_pqueue_insert(&list, two) < 0) goto on_error; /* as long as there are non-STALE commits */ while (interesting(&list, roots)) { git_commit_list_node *commit = git_pqueue_pop(&list); int flags; if (commit == NULL) break; flags = commit->flags & (PARENT1 | PARENT2 | STALE); if (flags == (PARENT1 | PARENT2)) { if (!(commit->flags & RESULT)) commit->flags |= RESULT; /* we mark the parents of a merge stale */ flags |= STALE; } for (i = 0; i < commit->out_degree; i++) { git_commit_list_node *p = commit->parents[i]; if ((p->flags & flags) == flags) continue; if (git_commit_list_parse(walk, p) < 0) goto on_error; p->flags |= flags; if (git_pqueue_insert(&list, p) < 0) goto on_error; } /* Keep track of root commits, to make sure the path gets marked */ if (commit->out_degree == 0) { if (git_commit_list_insert(commit, &roots) == NULL) goto on_error; } } git_commit_list_free(&roots); git_pqueue_free(&list); return 0; on_error: git_commit_list_free(&roots); git_pqueue_free(&list); return -1; } static int ahead_behind(git_commit_list_node *one, git_commit_list_node *two, size_t *ahead, size_t *behind) { git_commit_list_node *commit; git_pqueue pq; int error = 0, i; *ahead = 0; *behind = 0; if (git_pqueue_init(&pq, 0, 2, git_commit_list_time_cmp) < 0) return -1; if ((error = git_pqueue_insert(&pq, one)) < 0 || (error = git_pqueue_insert(&pq, two)) < 0) goto done; while ((commit = git_pqueue_pop(&pq)) != NULL) { if (commit->flags & RESULT || (commit->flags & (PARENT1 | PARENT2)) == (PARENT1 | PARENT2)) continue; else if (commit->flags & PARENT1) (*ahead)++; else if (commit->flags & PARENT2) (*behind)++; for (i = 0; i < commit->out_degree; i++) { git_commit_list_node *p = commit->parents[i]; if ((error = git_pqueue_insert(&pq, p)) < 0) goto done; } commit->flags |= RESULT; } done: git_pqueue_free(&pq); return error; } int git_graph_ahead_behind(size_t *ahead, size_t *behind, git_repository *repo, const git_oid *local, const git_oid *upstream) { git_revwalk *walk; git_commit_list_node *commit_u, *commit_l; if (git_revwalk_new(&walk, repo) < 0) return -1; commit_u = git_revwalk__commit_lookup(walk, upstream); if (commit_u == NULL) goto on_error; commit_l = git_revwalk__commit_lookup(walk, local); if (commit_l == NULL) goto on_error; if (mark_parents(walk, commit_l, commit_u) < 0) goto on_error; if (ahead_behind(commit_l, commit_u, ahead, behind) < 0) goto on_error; git_revwalk_free(walk); return 0; on_error: git_revwalk_free(walk); return -1; } int git_graph_descendant_of(git_repository *repo, const git_oid *commit, const git_oid *ancestor) { git_oid merge_base; int error; if (git_oid_equal(commit, ancestor)) return 0; error = git_merge_base(&merge_base, repo, commit, ancestor); /* No merge-base found, it's not a descendant */ if (error == GIT_ENOTFOUND) return 0; if (error < 0) return error; return git_oid_equal(&merge_base, ancestor); } deps/libgit2-sys-0.3.8/libgit2/src/util.h0000664000175000017500000004100412572105236015022 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_util_h__ #define INCLUDE_util_h__ #include "git2/buffer.h" #include "buffer.h" #if defined(GIT_MSVC_CRTDBG) /* Enable MSVC CRTDBG memory leak reporting. * * We DO NOT use the "_CRTDBG_MAP_ALLOC" macro described in the MSVC * documentation because all allocs/frees in libgit2 already go through * the "git__" routines defined in this file. Simply using the normal * reporting mechanism causes all leaks to be attributed to a routine * here in util.h (ie, the actual call to calloc()) rather than the * caller of git__calloc(). * * Therefore, we declare a set of "git__crtdbg__" routines to replace * the corresponding "git__" routines and re-define the "git__" symbols * as macros. This allows us to get and report the file:line info of * the real caller. * * We DO NOT replace the "git__free" routine because it needs to remain * a function pointer because it is used as a function argument when * setting up various structure "destructors". * * We also DO NOT use the "_CRTDBG_MAP_ALLOC" macro because it causes * "free" to be remapped to "_free_dbg" and this causes problems for * structures which define a field named "free". * * Finally, CRTDBG must be explicitly enabled and configured at program * startup. See tests/main.c for an example. */ #include #include #include "win32/w32_crtdbg_stacktrace.h" #endif #include "common.h" #include "strnlen.h" #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) #define bitsizeof(x) (CHAR_BIT * sizeof(x)) #define MSB(x, bits) ((x) & (~0ULL << (bitsizeof(x) - (bits)))) #ifndef min # define min(a,b) ((a) < (b) ? (a) : (b)) #endif #ifndef max # define max(a,b) ((a) > (b) ? (a) : (b)) #endif #define GIT_DATE_RFC2822_SZ 32 /** * Return the length of a constant string. * We are aware that `strlen` performs the same task and is usually * optimized away by the compiler, whilst being safer because it returns * valid values when passed a pointer instead of a constant string; however * this macro will transparently work with wide-char and single-char strings. */ #define CONST_STRLEN(x) ((sizeof(x)/sizeof(x[0])) - 1) #if defined(GIT_MSVC_CRTDBG) GIT_INLINE(void *) git__crtdbg__malloc(size_t len, const char *file, int line) { void *ptr = _malloc_dbg(len, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line); if (!ptr) giterr_set_oom(); return ptr; } GIT_INLINE(void *) git__crtdbg__calloc(size_t nelem, size_t elsize, const char *file, int line) { void *ptr = _calloc_dbg(nelem, elsize, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line); if (!ptr) giterr_set_oom(); return ptr; } GIT_INLINE(char *) git__crtdbg__strdup(const char *str, const char *file, int line) { char *ptr = _strdup_dbg(str, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line); if (!ptr) giterr_set_oom(); return ptr; } GIT_INLINE(char *) git__crtdbg__strndup(const char *str, size_t n, const char *file, int line) { size_t length = 0, alloclength; char *ptr; length = p_strnlen(str, n); if (GIT_ADD_SIZET_OVERFLOW(&alloclength, length, 1) || !(ptr = git__crtdbg__malloc(alloclength, file, line))) return NULL; if (length) memcpy(ptr, str, length); ptr[length] = '\0'; return ptr; } GIT_INLINE(char *) git__crtdbg__substrdup(const char *start, size_t n, const char *file, int line) { char *ptr; size_t alloclen; if (GIT_ADD_SIZET_OVERFLOW(&alloclen, n, 1) || !(ptr = git__crtdbg__malloc(alloclen, file, line))) return NULL; memcpy(ptr, start, n); ptr[n] = '\0'; return ptr; } GIT_INLINE(void *) git__crtdbg__realloc(void *ptr, size_t size, const char *file, int line) { void *new_ptr = _realloc_dbg(ptr, size, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line); if (!new_ptr) giterr_set_oom(); return new_ptr; } GIT_INLINE(void *) git__crtdbg__reallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line) { size_t newsize; return GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize) ? NULL : _realloc_dbg(ptr, newsize, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line); } GIT_INLINE(void *) git__crtdbg__mallocarray(size_t nelem, size_t elsize, const char *file, int line) { return git__crtdbg__reallocarray(NULL, nelem, elsize, file, line); } #define git__malloc(len) git__crtdbg__malloc(len, __FILE__, __LINE__) #define git__calloc(nelem, elsize) git__crtdbg__calloc(nelem, elsize, __FILE__, __LINE__) #define git__strdup(str) git__crtdbg__strdup(str, __FILE__, __LINE__) #define git__strndup(str, n) git__crtdbg__strndup(str, n, __FILE__, __LINE__) #define git__substrdup(str, n) git__crtdbg__substrdup(str, n, __FILE__, __LINE__) #define git__realloc(ptr, size) git__crtdbg__realloc(ptr, size, __FILE__, __LINE__) #define git__reallocarray(ptr, nelem, elsize) git__crtdbg__reallocarray(ptr, nelem, elsize, __FILE__, __LINE__) #define git__mallocarray(nelem, elsize) git__crtdbg__mallocarray(nelem, elsize, __FILE__, __LINE__) #else /* * Custom memory allocation wrappers * that set error code and error message * on allocation failure */ GIT_INLINE(void *) git__malloc(size_t len) { void *ptr = malloc(len); if (!ptr) giterr_set_oom(); return ptr; } GIT_INLINE(void *) git__calloc(size_t nelem, size_t elsize) { void *ptr = calloc(nelem, elsize); if (!ptr) giterr_set_oom(); return ptr; } GIT_INLINE(char *) git__strdup(const char *str) { char *ptr = strdup(str); if (!ptr) giterr_set_oom(); return ptr; } GIT_INLINE(char *) git__strndup(const char *str, size_t n) { size_t length = 0, alloclength; char *ptr; length = p_strnlen(str, n); if (GIT_ADD_SIZET_OVERFLOW(&alloclength, length, 1) || !(ptr = git__malloc(alloclength))) return NULL; if (length) memcpy(ptr, str, length); ptr[length] = '\0'; return ptr; } /* NOTE: This doesn't do null or '\0' checking. Watch those boundaries! */ GIT_INLINE(char *) git__substrdup(const char *start, size_t n) { char *ptr; size_t alloclen; if (GIT_ADD_SIZET_OVERFLOW(&alloclen, n, 1) || !(ptr = git__malloc(alloclen))) return NULL; memcpy(ptr, start, n); ptr[n] = '\0'; return ptr; } GIT_INLINE(void *) git__realloc(void *ptr, size_t size) { void *new_ptr = realloc(ptr, size); if (!new_ptr) giterr_set_oom(); return new_ptr; } /** * Similar to `git__realloc`, except that it is suitable for reallocing an * array to a new number of elements of `nelem`, each of size `elsize`. * The total size calculation is checked for overflow. */ GIT_INLINE(void *) git__reallocarray(void *ptr, size_t nelem, size_t elsize) { size_t newsize; return GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize) ? NULL : realloc(ptr, newsize); } /** * Similar to `git__calloc`, except that it does not zero memory. */ GIT_INLINE(void *) git__mallocarray(size_t nelem, size_t elsize) { return git__reallocarray(NULL, nelem, elsize); } #endif /* !MSVC_CTRDBG */ GIT_INLINE(void) git__free(void *ptr) { free(ptr); } #define STRCMP_CASESELECT(IGNORE_CASE, STR1, STR2) \ ((IGNORE_CASE) ? strcasecmp((STR1), (STR2)) : strcmp((STR1), (STR2))) #define CASESELECT(IGNORE_CASE, ICASE, CASE) \ ((IGNORE_CASE) ? (ICASE) : (CASE)) extern int git__prefixcmp(const char *str, const char *prefix); extern int git__prefixcmp_icase(const char *str, const char *prefix); extern int git__prefixncmp_icase(const char *str, size_t str_n, const char *prefix); extern int git__suffixcmp(const char *str, const char *suffix); GIT_INLINE(int) git__signum(int val) { return ((val > 0) - (val < 0)); } extern int git__strtol32(int32_t *n, const char *buff, const char **end_buf, int base); extern int git__strtol64(int64_t *n, const char *buff, const char **end_buf, int base); extern void git__hexdump(const char *buffer, size_t n); extern uint32_t git__hash(const void *key, int len, uint32_t seed); /* 32-bit cross-platform rotl */ #ifdef _MSC_VER /* use built-in method in MSVC */ # define git__rotl(v, s) (uint32_t)_rotl(v, s) #else /* use bitops in GCC; with o2 this gets optimized to a rotl instruction */ # define git__rotl(v, s) (uint32_t)(((uint32_t)(v) << (s)) | ((uint32_t)(v) >> (32 - (s)))) #endif extern char *git__strtok(char **end, const char *sep); extern char *git__strsep(char **end, const char *sep); extern void git__strntolower(char *str, size_t len); extern void git__strtolower(char *str); #ifdef GIT_WIN32 GIT_INLINE(int) git__tolower(int c) { return (c >= 'A' && c <= 'Z') ? (c + 32) : c; } #else # define git__tolower(a) tolower(a) #endif GIT_INLINE(const char *) git__next_line(const char *s) { while (*s && *s != '\n') s++; while (*s == '\n' || *s == '\r') s++; return s; } GIT_INLINE(const void *) git__memrchr(const void *s, int c, size_t n) { const unsigned char *cp; if (n != 0) { cp = (unsigned char *)s + n; do { if (*(--cp) == (unsigned char)c) return cp; } while (--n != 0); } return NULL; } typedef int (*git__tsort_cmp)(const void *a, const void *b); extern void git__tsort(void **dst, size_t size, git__tsort_cmp cmp); typedef int (*git__sort_r_cmp)(const void *a, const void *b, void *payload); extern void git__tsort_r( void **dst, size_t size, git__sort_r_cmp cmp, void *payload); extern void git__qsort_r( void *els, size_t nel, size_t elsize, git__sort_r_cmp cmp, void *payload); extern void git__insertsort_r( void *els, size_t nel, size_t elsize, void *swapel, git__sort_r_cmp cmp, void *payload); /** * @param position If non-NULL, this will be set to the position where the * element is or would be inserted if not found. * @return 0 if found; GIT_ENOTFOUND if not found */ extern int git__bsearch( void **array, size_t array_len, const void *key, int (*compare)(const void *key, const void *element), size_t *position); extern int git__bsearch_r( void **array, size_t array_len, const void *key, int (*compare_r)(const void *key, const void *element, void *payload), void *payload, size_t *position); extern int git__strcmp_cb(const void *a, const void *b); extern int git__strcasecmp_cb(const void *a, const void *b); extern int git__strcmp(const char *a, const char *b); extern int git__strcasecmp(const char *a, const char *b); extern int git__strncmp(const char *a, const char *b, size_t sz); extern int git__strncasecmp(const char *a, const char *b, size_t sz); extern int git__strcasesort_cmp(const char *a, const char *b); #include "thread-utils.h" typedef struct { git_atomic refcount; void *owner; } git_refcount; typedef void (*git_refcount_freeptr)(void *r); #define GIT_REFCOUNT_INC(r) { \ git_atomic_inc(&((git_refcount *)(r))->refcount); \ } #define GIT_REFCOUNT_DEC(_r, do_free) { \ git_refcount *r = (git_refcount *)(_r); \ int val = git_atomic_dec(&r->refcount); \ if (val <= 0 && r->owner == NULL) { do_free(_r); } \ } #define GIT_REFCOUNT_OWN(r, o) { \ ((git_refcount *)(r))->owner = o; \ } #define GIT_REFCOUNT_OWNER(r) (((git_refcount *)(r))->owner) #define GIT_REFCOUNT_VAL(r) git_atomic_get(&((git_refcount *)(r))->refcount) static signed char from_hex[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 00 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 10 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 20 */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, /* 30 */ -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 40 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 50 */ -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 60 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 70 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 80 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 90 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* a0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* b0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* c0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* d0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* e0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* f0 */ }; GIT_INLINE(int) git__fromhex(char h) { return from_hex[(unsigned char) h]; } GIT_INLINE(int) git__ishex(const char *str) { unsigned i; for (i=0; str[i] != '\0'; i++) if (git__fromhex(str[i]) < 0) return 0; return 1; } GIT_INLINE(size_t) git__size_t_bitmask(size_t v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; return v; } GIT_INLINE(size_t) git__size_t_powerof2(size_t v) { return git__size_t_bitmask(v) + 1; } GIT_INLINE(bool) git__isupper(int c) { return (c >= 'A' && c <= 'Z'); } GIT_INLINE(bool) git__isalpha(int c) { return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); } GIT_INLINE(bool) git__isdigit(int c) { return (c >= '0' && c <= '9'); } GIT_INLINE(bool) git__isspace(int c) { return (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r' || c == '\v'); } GIT_INLINE(bool) git__isspace_nonlf(int c) { return (c == ' ' || c == '\t' || c == '\f' || c == '\r' || c == '\v'); } GIT_INLINE(bool) git__iswildcard(int c) { return (c == '*' || c == '?' || c == '['); } /* * Parse a string value as a boolean, just like Core Git does. * * Valid values for true are: 'true', 'yes', 'on' * Valid values for false are: 'false', 'no', 'off' */ extern int git__parse_bool(int *out, const char *value); /* * Parse a string into a value as a git_time_t. * * Sample valid input: * - "yesterday" * - "July 17, 2003" * - "2003-7-17 08:23" */ extern int git__date_parse(git_time_t *out, const char *date); /* * Format a git_time as a RFC2822 string * * @param out buffer to store formatted date; a '\\0' terminator will automatically be added. * @param len size of the buffer; should be atleast `GIT_DATE_RFC2822_SZ` in size; * @param date the date to be formatted * @return 0 if successful; -1 on error */ extern int git__date_rfc2822_fmt(char *out, size_t len, const git_time *date); /* * Unescapes a string in-place. * * Edge cases behavior: * - "jackie\" -> "jacky\" * - "chan\\" -> "chan\" */ extern size_t git__unescape(char *str); /* * Iterate through an UTF-8 string, yielding one * codepoint at a time. * * @param str current position in the string * @param str_len size left in the string; -1 if the string is NULL-terminated * @param dst pointer where to store the current codepoint * @return length in bytes of the read codepoint; -1 if the codepoint was invalid */ extern int git__utf8_iterate(const uint8_t *str, int str_len, int32_t *dst); /* * Safely zero-out memory, making sure that the compiler * doesn't optimize away the operation. */ GIT_INLINE(void) git__memzero(void *data, size_t size) { #ifdef _MSC_VER SecureZeroMemory((PVOID)data, size); #else volatile uint8_t *scan = (volatile uint8_t *)data; while (size--) *scan++ = 0x0; #endif } #ifdef GIT_WIN32 GIT_INLINE(double) git__timer(void) { /* We need the initial tick count to detect if the tick * count has rolled over. */ static DWORD initial_tick_count = 0; /* GetTickCount returns the number of milliseconds that have * elapsed since the system was started. */ DWORD count = GetTickCount(); if(initial_tick_count == 0) { initial_tick_count = count; } else if (count < initial_tick_count) { /* The tick count has rolled over - adjust for it. */ count = (0xFFFFFFFF - initial_tick_count) + count; } return (double) count / (double) 1000; } #elif __APPLE__ #include GIT_INLINE(double) git__timer(void) { uint64_t time = mach_absolute_time(); static double scaling_factor = 0; if (scaling_factor == 0) { mach_timebase_info_data_t info; (void)mach_timebase_info(&info); scaling_factor = (double)info.numer / (double)info.denom; } return (double)time * scaling_factor / 1.0E9; } #elif defined(AMIGA) #include GIT_INLINE(double) git__timer(void) { struct TimeVal tv; ITimer->GetUpTime(&tv); return (double)tv.Seconds + (double)tv.Microseconds / 1.0E6; } #else #include GIT_INLINE(double) git__timer(void) { struct timespec tp; if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) { return (double) tp.tv_sec + (double) tp.tv_nsec / 1.0E9; } else { /* Fall back to using gettimeofday */ struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz); return (double)tv.tv_sec + (double)tv.tv_usec / 1.0E6; } } #endif extern int git__getenv(git_buf *out, const char *name); #endif /* INCLUDE_util_h__ */ deps/libgit2-sys-0.3.8/libgit2/src/socket_stream.h0000664000175000017500000000076512510265101016707 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_socket_stream_h__ #define INCLUDE_socket_stream_h__ #include "netops.h" typedef struct { git_stream parent; char *host; char *port; GIT_SOCKET s; } git_socket_stream; extern int git_socket_stream_new(git_stream **out, const char *host, const char *port); #endif deps/libgit2-sys-0.3.8/libgit2/src/tag.h0000664000175000017500000000105112426525445014624 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_tag_h__ #define INCLUDE_tag_h__ #include "git2/tag.h" #include "repository.h" #include "odb.h" struct git_tag { git_object object; git_oid target; git_otype type; char *tag_name; git_signature *tagger; char *message; }; void git_tag__free(void *tag); int git_tag__parse(void *tag, git_odb_object *obj); #endif deps/libgit2-sys-0.3.8/libgit2/src/vector.h0000664000175000017500000000726212426525445015365 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_vector_h__ #define INCLUDE_vector_h__ #include "common.h" typedef int (*git_vector_cmp)(const void *, const void *); enum { GIT_VECTOR_SORTED = (1u << 0), GIT_VECTOR_FLAG_MAX = (1u << 1), }; typedef struct git_vector { size_t _alloc_size; git_vector_cmp _cmp; void **contents; size_t length; uint32_t flags; } git_vector; #define GIT_VECTOR_INIT {0} int git_vector_init(git_vector *v, size_t initial_size, git_vector_cmp cmp); void git_vector_free(git_vector *v); void git_vector_free_deep(git_vector *v); /* free each entry and self */ void git_vector_clear(git_vector *v); int git_vector_dup(git_vector *v, const git_vector *src, git_vector_cmp cmp); void git_vector_swap(git_vector *a, git_vector *b); void **git_vector_detach(size_t *size, size_t *asize, git_vector *v); void git_vector_sort(git_vector *v); /** Linear search for matching entry using internal comparison function */ int git_vector_search(size_t *at_pos, const git_vector *v, const void *entry); /** Linear search for matching entry using explicit comparison function */ int git_vector_search2(size_t *at_pos, const git_vector *v, git_vector_cmp cmp, const void *key); /** * Binary search for matching entry using explicit comparison function that * returns position where item would go if not found. */ int git_vector_bsearch2( size_t *at_pos, git_vector *v, git_vector_cmp cmp, const void *key); /** Binary search for matching entry using internal comparison function */ GIT_INLINE(int) git_vector_bsearch(size_t *at_pos, git_vector *v, const void *key) { return git_vector_bsearch2(at_pos, v, v->_cmp, key); } GIT_INLINE(void *) git_vector_get(const git_vector *v, size_t position) { return (position < v->length) ? v->contents[position] : NULL; } #define GIT_VECTOR_GET(V,I) ((I) < (V)->length ? (V)->contents[(I)] : NULL) GIT_INLINE(size_t) git_vector_length(const git_vector *v) { return v->length; } GIT_INLINE(void *) git_vector_last(const git_vector *v) { return (v->length > 0) ? git_vector_get(v, v->length - 1) : NULL; } #define git_vector_foreach(v, iter, elem) \ for ((iter) = 0; (iter) < (v)->length && ((elem) = (v)->contents[(iter)], 1); (iter)++ ) #define git_vector_rforeach(v, iter, elem) \ for ((iter) = (v)->length - 1; (iter) < SIZE_MAX && ((elem) = (v)->contents[(iter)], 1); (iter)-- ) int git_vector_insert(git_vector *v, void *element); int git_vector_insert_sorted(git_vector *v, void *element, int (*on_dup)(void **old, void *new)); int git_vector_remove(git_vector *v, size_t idx); void git_vector_pop(git_vector *v); void git_vector_uniq(git_vector *v, void (*git_free_cb)(void *)); void git_vector_remove_matching( git_vector *v, int (*match)(const git_vector *v, size_t idx, void *payload), void *payload); int git_vector_resize_to(git_vector *v, size_t new_length); int git_vector_set(void **old, git_vector *v, size_t position, void *value); /** Check if vector is sorted */ #define git_vector_is_sorted(V) (((V)->flags & GIT_VECTOR_SORTED) != 0) /** Directly set sorted state of vector */ #define git_vector_set_sorted(V,S) do { \ (V)->flags = (S) ? ((V)->flags | GIT_VECTOR_SORTED) : \ ((V)->flags & ~GIT_VECTOR_SORTED); } while (0) /** Set the comparison function used for sorting the vector */ GIT_INLINE(void) git_vector_set_cmp(git_vector *v, git_vector_cmp cmp) { if (cmp != v->_cmp) { v->_cmp = cmp; git_vector_set_sorted(v, 0); } } /* Just use this in tests, not for realz. returns -1 if not sorted */ int git_vector_verify_sorted(const git_vector *v); #endif deps/libgit2-sys-0.3.8/libgit2/src/transports/0000755000000000000000000000000012666635520017700 5ustar rootrootdeps/libgit2-sys-0.3.8/libgit2/src/transports/cred_helpers.c0000664000175000017500000000301412510265101020703 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "git2/cred_helpers.h" int git_cred_userpass( git_cred **cred, const char *url, const char *user_from_url, unsigned int allowed_types, void *payload) { git_cred_userpass_payload *userpass = (git_cred_userpass_payload*)payload; const char *effective_username = NULL; GIT_UNUSED(url); if (!userpass || !userpass->password) return -1; /* Username resolution: a username can be passed with the URL, the * credentials payload, or both. Here's what we do. Note that if we get * this far, we know that any password the url may contain has already * failed at least once, so we ignore it. * * | Payload | URL | Used | * +-------------+----------+-----------+ * | yes | no | payload | * | yes | yes | payload | * | no | yes | url | * | no | no | FAIL | */ if (userpass->username) effective_username = userpass->username; else if (user_from_url) effective_username = user_from_url; else return -1; if (GIT_CREDTYPE_USERNAME & allowed_types) return git_cred_username_new(cred, effective_username); if ((GIT_CREDTYPE_USERPASS_PLAINTEXT & allowed_types) == 0 || git_cred_userpass_plaintext_new(cred, effective_username, userpass->password) < 0) return -1; return 0; } deps/libgit2-sys-0.3.8/libgit2/src/transports/local.c0000664000175000017500000004117612555730137017370 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "git2/types.h" #include "git2/net.h" #include "git2/repository.h" #include "git2/object.h" #include "git2/tag.h" #include "git2/transport.h" #include "git2/revwalk.h" #include "git2/odb_backend.h" #include "git2/pack.h" #include "git2/commit.h" #include "git2/revparse.h" #include "pack-objects.h" #include "refs.h" #include "posix.h" #include "path.h" #include "buffer.h" #include "repository.h" #include "odb.h" #include "push.h" #include "remote.h" typedef struct { git_transport parent; git_remote *owner; char *url; int direction; int flags; git_atomic cancelled; git_repository *repo; git_transport_message_cb progress_cb; git_transport_message_cb error_cb; void *message_cb_payload; git_vector refs; unsigned connected : 1, have_refs : 1; } transport_local; static void free_head(git_remote_head *head) { git__free(head->name); git__free(head->symref_target); git__free(head); } static void free_heads(git_vector *heads) { git_remote_head *head; size_t i; git_vector_foreach(heads, i, head) free_head(head); git_vector_free(heads); } static int add_ref(transport_local *t, const char *name) { const char peeled[] = "^{}"; git_reference *ref, *resolved; git_remote_head *head; git_oid obj_id; git_object *obj = NULL, *target = NULL; git_buf buf = GIT_BUF_INIT; int error; if ((error = git_reference_lookup(&ref, t->repo, name)) < 0) return error; error = git_reference_resolve(&resolved, ref); if (error < 0) { git_reference_free(ref); if (!strcmp(name, GIT_HEAD_FILE) && error == GIT_ENOTFOUND) { /* This is actually okay. Empty repos often have a HEAD that * points to a nonexistent "refs/heads/master". */ giterr_clear(); return 0; } return error; } git_oid_cpy(&obj_id, git_reference_target(resolved)); git_reference_free(resolved); head = git__calloc(1, sizeof(git_remote_head)); GITERR_CHECK_ALLOC(head); head->name = git__strdup(name); GITERR_CHECK_ALLOC(head->name); git_oid_cpy(&head->oid, &obj_id); if (git_reference_type(ref) == GIT_REF_SYMBOLIC) { head->symref_target = git__strdup(git_reference_symbolic_target(ref)); GITERR_CHECK_ALLOC(head->symref_target); } git_reference_free(ref); if ((error = git_vector_insert(&t->refs, head)) < 0) { free_head(head); return error; } /* If it's not a tag, we don't need to try to peel it */ if (git__prefixcmp(name, GIT_REFS_TAGS_DIR)) return 0; if ((error = git_object_lookup(&obj, t->repo, &head->oid, GIT_OBJ_ANY)) < 0) return error; head = NULL; /* If it's not an annotated tag, or if we're mocking * git-receive-pack, just get out */ if (git_object_type(obj) != GIT_OBJ_TAG || t->direction != GIT_DIRECTION_FETCH) { git_object_free(obj); return 0; } /* And if it's a tag, peel it, and add it to the list */ head = git__calloc(1, sizeof(git_remote_head)); GITERR_CHECK_ALLOC(head); if (git_buf_join(&buf, 0, name, peeled) < 0) { free_head(head); return -1; } head->name = git_buf_detach(&buf); if (!(error = git_tag_peel(&target, (git_tag *)obj))) { git_oid_cpy(&head->oid, git_object_id(target)); if ((error = git_vector_insert(&t->refs, head)) < 0) { free_head(head); } } git_object_free(obj); git_object_free(target); return error; } static int store_refs(transport_local *t) { size_t i; git_remote_head *head; git_strarray ref_names = {0}; assert(t); if (git_reference_list(&ref_names, t->repo) < 0) goto on_error; /* Clear all heads we might have fetched in a previous connect */ git_vector_foreach(&t->refs, i, head) { git__free(head->name); git__free(head); } /* Clear the vector so we can reuse it */ git_vector_clear(&t->refs); /* Sort the references first */ git__tsort((void **)ref_names.strings, ref_names.count, &git__strcmp_cb); /* Add HEAD iff direction is fetch */ if (t->direction == GIT_DIRECTION_FETCH && add_ref(t, GIT_HEAD_FILE) < 0) goto on_error; for (i = 0; i < ref_names.count; ++i) { if (add_ref(t, ref_names.strings[i]) < 0) goto on_error; } t->have_refs = 1; git_strarray_free(&ref_names); return 0; on_error: git_vector_free(&t->refs); git_strarray_free(&ref_names); return -1; } /* * Try to open the url as a git directory. The direction doesn't * matter in this case because we're calculating the heads ourselves. */ static int local_connect( git_transport *transport, const char *url, git_cred_acquire_cb cred_acquire_cb, void *cred_acquire_payload, int direction, int flags) { git_repository *repo; int error; transport_local *t = (transport_local *) transport; const char *path; git_buf buf = GIT_BUF_INIT; GIT_UNUSED(cred_acquire_cb); GIT_UNUSED(cred_acquire_payload); if (t->connected) return 0; free_heads(&t->refs); t->url = git__strdup(url); GITERR_CHECK_ALLOC(t->url); t->direction = direction; t->flags = flags; /* 'url' may be a url or path; convert to a path */ if ((error = git_path_from_url_or_path(&buf, url)) < 0) { git_buf_free(&buf); return error; } path = git_buf_cstr(&buf); error = git_repository_open(&repo, path); git_buf_free(&buf); if (error < 0) return -1; t->repo = repo; if (store_refs(t) < 0) return -1; t->connected = 1; return 0; } static int local_ls(const git_remote_head ***out, size_t *size, git_transport *transport) { transport_local *t = (transport_local *)transport; if (!t->have_refs) { giterr_set(GITERR_NET, "The transport has not yet loaded the refs"); return -1; } *out = (const git_remote_head **)t->refs.contents; *size = t->refs.length; return 0; } static int local_negotiate_fetch( git_transport *transport, git_repository *repo, const git_remote_head * const *refs, size_t count) { transport_local *t = (transport_local*)transport; git_remote_head *rhead; unsigned int i; GIT_UNUSED(refs); GIT_UNUSED(count); /* Fill in the loids */ git_vector_foreach(&t->refs, i, rhead) { git_object *obj; int error = git_revparse_single(&obj, repo, rhead->name); if (!error) git_oid_cpy(&rhead->loid, git_object_id(obj)); else if (error != GIT_ENOTFOUND) return error; else giterr_clear(); git_object_free(obj); } return 0; } static int local_push_update_remote_ref( git_repository *remote_repo, const char *lref, const char *rref, git_oid *loid, git_oid *roid) { int error; git_reference *remote_ref = NULL; /* check for lhs, if it's empty it means to delete */ if (lref[0] != '\0') { /* Create or update a ref */ error = git_reference_create(NULL, remote_repo, rref, loid, !git_oid_iszero(roid), NULL); } else { /* Delete a ref */ if ((error = git_reference_lookup(&remote_ref, remote_repo, rref)) < 0) { if (error == GIT_ENOTFOUND) error = 0; return error; } error = git_reference_delete(remote_ref); git_reference_free(remote_ref); } return error; } static int transfer_to_push_transfer(const git_transfer_progress *stats, void *payload) { const git_remote_callbacks *cbs = payload; if (!cbs || !cbs->push_transfer_progress) return 0; return cbs->push_transfer_progress(stats->received_objects, stats->total_objects, stats->received_bytes, cbs->payload); } static int local_push( git_transport *transport, git_push *push, const git_remote_callbacks *cbs) { transport_local *t = (transport_local *)transport; git_repository *remote_repo = NULL; push_spec *spec; char *url = NULL; const char *path; git_buf buf = GIT_BUF_INIT, odb_path = GIT_BUF_INIT; int error; size_t j; GIT_UNUSED(cbs); /* 'push->remote->url' may be a url or path; convert to a path */ if ((error = git_path_from_url_or_path(&buf, push->remote->url)) < 0) { git_buf_free(&buf); return error; } path = git_buf_cstr(&buf); error = git_repository_open(&remote_repo, path); git_buf_free(&buf); if (error < 0) return error; /* We don't currently support pushing locally to non-bare repos. Proper non-bare repo push support would require checking configs to see if we should override the default 'don't let this happen' behavior. Note that this is only an issue when pushing to the current branch, but we forbid all pushes just in case */ if (!remote_repo->is_bare) { error = GIT_EBAREREPO; giterr_set(GITERR_INVALID, "Local push doesn't (yet) support pushing to non-bare repos."); goto on_error; } if ((error = git_buf_joinpath(&odb_path, git_repository_path(remote_repo), "objects/pack")) < 0) goto on_error; error = git_packbuilder_write(push->pb, odb_path.ptr, 0, transfer_to_push_transfer, (void *) cbs); git_buf_free(&odb_path); if (error < 0) goto on_error; push->unpack_ok = 1; git_vector_foreach(&push->specs, j, spec) { push_status *status; const git_error *last; char *ref = spec->refspec.dst; status = git__calloc(1, sizeof(push_status)); if (!status) goto on_error; status->ref = git__strdup(ref); if (!status->ref) { git_push_status_free(status); goto on_error; } error = local_push_update_remote_ref(remote_repo, spec->refspec.src, spec->refspec.dst, &spec->loid, &spec->roid); switch (error) { case GIT_OK: break; case GIT_EINVALIDSPEC: status->msg = git__strdup("funny refname"); break; case GIT_ENOTFOUND: status->msg = git__strdup("Remote branch not found to delete"); break; default: last = giterr_last(); if (last && last->message) status->msg = git__strdup(last->message); else status->msg = git__strdup("Unspecified error encountered"); break; } /* failed to allocate memory for a status message */ if (error < 0 && !status->msg) { git_push_status_free(status); goto on_error; } /* failed to insert the ref update status */ if ((error = git_vector_insert(&push->status, status)) < 0) { git_push_status_free(status); goto on_error; } } if (push->specs.length) { int flags = t->flags; url = git__strdup(t->url); if (!url || t->parent.close(&t->parent) < 0 || t->parent.connect(&t->parent, url, NULL, NULL, GIT_DIRECTION_PUSH, flags)) goto on_error; } error = 0; on_error: git_repository_free(remote_repo); git__free(url); return error; } typedef struct foreach_data { git_transfer_progress *stats; git_transfer_progress_cb progress_cb; void *progress_payload; git_odb_writepack *writepack; } foreach_data; static int foreach_cb(void *buf, size_t len, void *payload) { foreach_data *data = (foreach_data*)payload; data->stats->received_bytes += len; return data->writepack->append(data->writepack, buf, len, data->stats); } static const char *counting_objects_fmt = "Counting objects %d\r"; static const char *compressing_objects_fmt = "Compressing objects: %.0f%% (%d/%d)"; static int local_counting(int stage, unsigned int current, unsigned int total, void *payload) { git_buf progress_info = GIT_BUF_INIT; transport_local *t = payload; int error; if (!t->progress_cb) return 0; if (stage == GIT_PACKBUILDER_ADDING_OBJECTS) { git_buf_printf(&progress_info, counting_objects_fmt, current); } else if (stage == GIT_PACKBUILDER_DELTAFICATION) { float perc = (((float) current) / total) * 100; git_buf_printf(&progress_info, compressing_objects_fmt, perc, current, total); if (current == total) git_buf_printf(&progress_info, ", done\n"); else git_buf_putc(&progress_info, '\r'); } if (git_buf_oom(&progress_info)) return -1; error = t->progress_cb(git_buf_cstr(&progress_info), git_buf_len(&progress_info), t->message_cb_payload); git_buf_free(&progress_info); return error; } static int local_download_pack( git_transport *transport, git_repository *repo, git_transfer_progress *stats, git_transfer_progress_cb progress_cb, void *progress_payload) { transport_local *t = (transport_local*)transport; git_revwalk *walk = NULL; git_remote_head *rhead; unsigned int i; int error = -1; git_packbuilder *pack = NULL; git_odb_writepack *writepack = NULL; git_odb *odb = NULL; git_buf progress_info = GIT_BUF_INIT; if ((error = git_revwalk_new(&walk, t->repo)) < 0) goto cleanup; git_revwalk_sorting(walk, GIT_SORT_TIME); if ((error = git_packbuilder_new(&pack, t->repo)) < 0) goto cleanup; git_packbuilder_set_callbacks(pack, local_counting, t); stats->total_objects = 0; stats->indexed_objects = 0; stats->received_objects = 0; stats->received_bytes = 0; git_vector_foreach(&t->refs, i, rhead) { git_object *obj; if ((error = git_object_lookup(&obj, t->repo, &rhead->oid, GIT_OBJ_ANY)) < 0) goto cleanup; if (git_object_type(obj) == GIT_OBJ_COMMIT) { /* Revwalker includes only wanted commits */ error = git_revwalk_push(walk, &rhead->oid); if (!error && !git_oid_iszero(&rhead->loid)) { error = git_revwalk_hide(walk, &rhead->loid); if (error == GIT_ENOTFOUND) error = 0; } } else { /* Tag or some other wanted object. Add it on its own */ error = git_packbuilder_insert_recur(pack, &rhead->oid, rhead->name); } git_object_free(obj); if (error < 0) goto cleanup; } if ((error = git_packbuilder_insert_walk(pack, walk))) goto cleanup; if ((error = git_buf_printf(&progress_info, counting_objects_fmt, git_packbuilder_object_count(pack))) < 0) goto cleanup; if (t->progress_cb && (error = t->progress_cb(git_buf_cstr(&progress_info), git_buf_len(&progress_info), t->message_cb_payload)) < 0) goto cleanup; /* Walk the objects, building a packfile */ if ((error = git_repository_odb__weakptr(&odb, repo)) < 0) goto cleanup; /* One last one with the newline */ git_buf_clear(&progress_info); git_buf_printf(&progress_info, counting_objects_fmt, git_packbuilder_object_count(pack)); if ((error = git_buf_putc(&progress_info, '\n')) < 0) goto cleanup; if (t->progress_cb && (error = t->progress_cb(git_buf_cstr(&progress_info), git_buf_len(&progress_info), t->message_cb_payload)) < 0) goto cleanup; if ((error = git_odb_write_pack(&writepack, odb, progress_cb, progress_payload)) != 0) goto cleanup; /* Write the data to the ODB */ { foreach_data data = {0}; data.stats = stats; data.progress_cb = progress_cb; data.progress_payload = progress_payload; data.writepack = writepack; /* autodetect */ git_packbuilder_set_threads(pack, 0); if ((error = git_packbuilder_foreach(pack, foreach_cb, &data)) != 0) goto cleanup; } error = writepack->commit(writepack, stats); cleanup: if (writepack) writepack->free(writepack); git_buf_free(&progress_info); git_packbuilder_free(pack); git_revwalk_free(walk); return error; } static int local_set_callbacks( git_transport *transport, git_transport_message_cb progress_cb, git_transport_message_cb error_cb, git_transport_certificate_check_cb certificate_check_cb, void *message_cb_payload) { transport_local *t = (transport_local *)transport; GIT_UNUSED(certificate_check_cb); t->progress_cb = progress_cb; t->error_cb = error_cb; t->message_cb_payload = message_cb_payload; return 0; } static int local_is_connected(git_transport *transport) { transport_local *t = (transport_local *)transport; return t->connected; } static int local_read_flags(git_transport *transport, int *flags) { transport_local *t = (transport_local *)transport; *flags = t->flags; return 0; } static void local_cancel(git_transport *transport) { transport_local *t = (transport_local *)transport; git_atomic_set(&t->cancelled, 1); } static int local_close(git_transport *transport) { transport_local *t = (transport_local *)transport; t->connected = 0; if (t->repo) { git_repository_free(t->repo); t->repo = NULL; } if (t->url) { git__free(t->url); t->url = NULL; } return 0; } static void local_free(git_transport *transport) { transport_local *t = (transport_local *)transport; free_heads(&t->refs); /* Close the transport, if it's still open. */ local_close(transport); /* Free the transport */ git__free(t); } /************** * Public API * **************/ int git_transport_local(git_transport **out, git_remote *owner, void *param) { int error; transport_local *t; GIT_UNUSED(param); t = git__calloc(1, sizeof(transport_local)); GITERR_CHECK_ALLOC(t); t->parent.version = GIT_TRANSPORT_VERSION; t->parent.set_callbacks = local_set_callbacks; t->parent.connect = local_connect; t->parent.negotiate_fetch = local_negotiate_fetch; t->parent.download_pack = local_download_pack; t->parent.push = local_push; t->parent.close = local_close; t->parent.free = local_free; t->parent.ls = local_ls; t->parent.is_connected = local_is_connected; t->parent.read_flags = local_read_flags; t->parent.cancel = local_cancel; if ((error = git_vector_init(&t->refs, 0, NULL)) < 0) { git__free(t); return error; } t->owner = owner; *out = (git_transport *) t; return 0; } deps/libgit2-sys-0.3.8/libgit2/src/transports/cred.h0000664000175000017500000000054712510265101017176 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_cred_h__ #define INCLUDE_git_cred_h__ #include "git2/transport.h" const char *git_cred__username(git_cred *cred); #endif deps/libgit2-sys-0.3.8/libgit2/src/transports/http.c0000664000175000017500000006052512610310643017240 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef GIT_WINHTTP #include "git2.h" #include "http_parser.h" #include "buffer.h" #include "netops.h" #include "remote.h" #include "smart.h" #include "auth.h" #include "auth_negotiate.h" #include "tls_stream.h" #include "socket_stream.h" #include "curl_stream.h" git_http_auth_scheme auth_schemes[] = { { GIT_AUTHTYPE_NEGOTIATE, "Negotiate", GIT_CREDTYPE_DEFAULT, git_http_auth_negotiate }, { GIT_AUTHTYPE_BASIC, "Basic", GIT_CREDTYPE_USERPASS_PLAINTEXT, git_http_auth_basic }, }; static const char *upload_pack_service = "upload-pack"; static const char *upload_pack_ls_service_url = "/info/refs?service=git-upload-pack"; static const char *upload_pack_service_url = "/git-upload-pack"; static const char *receive_pack_service = "receive-pack"; static const char *receive_pack_ls_service_url = "/info/refs?service=git-receive-pack"; static const char *receive_pack_service_url = "/git-receive-pack"; static const char *get_verb = "GET"; static const char *post_verb = "POST"; #define OWNING_SUBTRANSPORT(s) ((http_subtransport *)(s)->parent.subtransport) #define PARSE_ERROR_GENERIC -1 #define PARSE_ERROR_REPLAY -2 /** Look at the user field */ #define PARSE_ERROR_EXT -3 #define CHUNK_SIZE 4096 enum last_cb { NONE, FIELD, VALUE }; typedef struct { git_smart_subtransport_stream parent; const char *service; const char *service_url; char *redirect_url; const char *verb; char *chunk_buffer; unsigned chunk_buffer_len; unsigned sent_request : 1, received_response : 1, chunked : 1, redirect_count : 3; } http_stream; typedef struct { git_smart_subtransport parent; transport_smart *owner; git_stream *io; gitno_connection_data connection_data; bool connected; /* Parser structures */ http_parser parser; http_parser_settings settings; gitno_buffer parse_buffer; git_buf parse_header_name; git_buf parse_header_value; char parse_buffer_data[NETIO_BUFSIZE]; char *content_type; char *location; git_vector www_authenticate; enum last_cb last_cb; int parse_error; int error; unsigned parse_finished : 1; /* Authentication */ git_cred *cred; git_cred *url_cred; git_vector auth_contexts; } http_subtransport; typedef struct { http_stream *s; http_subtransport *t; /* Target buffer details from read() */ char *buffer; size_t buf_size; size_t *bytes_read; } parser_context; static bool credtype_match(git_http_auth_scheme *scheme, void *data) { unsigned int credtype = *(unsigned int *)data; return !!(scheme->credtypes & credtype); } static bool challenge_match(git_http_auth_scheme *scheme, void *data) { const char *scheme_name = scheme->name; const char *challenge = (const char *)data; size_t scheme_len; scheme_len = strlen(scheme_name); return (strncmp(challenge, scheme_name, scheme_len) == 0 && (challenge[scheme_len] == '\0' || challenge[scheme_len] == ' ')); } static int auth_context_match( git_http_auth_context **out, http_subtransport *t, bool (*scheme_match)(git_http_auth_scheme *scheme, void *data), void *data) { git_http_auth_scheme *scheme = NULL; git_http_auth_context *context = NULL, *c; size_t i; *out = NULL; for (i = 0; i < ARRAY_SIZE(auth_schemes); i++) { if (scheme_match(&auth_schemes[i], data)) { scheme = &auth_schemes[i]; break; } } if (!scheme) return 0; /* See if authentication has already started for this scheme */ git_vector_foreach(&t->auth_contexts, i, c) { if (c->type == scheme->type) { context = c; break; } } if (!context) { if (scheme->init_context(&context, &t->connection_data) < 0) return -1; else if (!context) return 0; else if (git_vector_insert(&t->auth_contexts, context) < 0) return -1; } *out = context; return 0; } static int apply_credentials(git_buf *buf, http_subtransport *t) { git_cred *cred = t->cred; git_http_auth_context *context; /* Apply the credentials given to us in the URL */ if (!cred && t->connection_data.user && t->connection_data.pass) { if (!t->url_cred && git_cred_userpass_plaintext_new(&t->url_cred, t->connection_data.user, t->connection_data.pass) < 0) return -1; cred = t->url_cred; } if (!cred) return 0; /* Get or create a context for the best scheme for this cred type */ if (auth_context_match(&context, t, credtype_match, &cred->credtype) < 0) return -1; return context->next_token(buf, context, cred); } static int gen_request( git_buf *buf, http_stream *s, size_t content_length) { http_subtransport *t = OWNING_SUBTRANSPORT(s); const char *path = t->connection_data.path ? t->connection_data.path : "/"; size_t i; git_buf_printf(buf, "%s %s%s HTTP/1.1\r\n", s->verb, path, s->service_url); git_buf_puts(buf, "User-Agent: git/1.0 (libgit2 " LIBGIT2_VERSION ")\r\n"); git_buf_printf(buf, "Host: %s\r\n", t->connection_data.host); if (s->chunked || content_length > 0) { git_buf_printf(buf, "Accept: application/x-git-%s-result\r\n", s->service); git_buf_printf(buf, "Content-Type: application/x-git-%s-request\r\n", s->service); if (s->chunked) git_buf_puts(buf, "Transfer-Encoding: chunked\r\n"); else git_buf_printf(buf, "Content-Length: %"PRIuZ "\r\n", content_length); } else git_buf_puts(buf, "Accept: */*\r\n"); for (i = 0; i < t->owner->custom_headers.count; i++) { if (t->owner->custom_headers.strings[i]) git_buf_printf(buf, "%s\r\n", t->owner->custom_headers.strings[i]); } /* Apply credentials to the request */ if (apply_credentials(buf, t) < 0) return -1; git_buf_puts(buf, "\r\n"); if (git_buf_oom(buf)) return -1; return 0; } static int parse_authenticate_response( git_vector *www_authenticate, http_subtransport *t, int *allowed_types) { git_http_auth_context *context; char *challenge; size_t i; git_vector_foreach(www_authenticate, i, challenge) { if (auth_context_match(&context, t, challenge_match, challenge) < 0) return -1; else if (!context) continue; if (context->set_challenge && context->set_challenge(context, challenge) < 0) return -1; *allowed_types |= context->credtypes; } return 0; } static int on_header_ready(http_subtransport *t) { git_buf *name = &t->parse_header_name; git_buf *value = &t->parse_header_value; if (!strcasecmp("Content-Type", git_buf_cstr(name))) { if (!t->content_type) { t->content_type = git__strdup(git_buf_cstr(value)); GITERR_CHECK_ALLOC(t->content_type); } } else if (!strcasecmp("WWW-Authenticate", git_buf_cstr(name))) { char *dup = git__strdup(git_buf_cstr(value)); GITERR_CHECK_ALLOC(dup); git_vector_insert(&t->www_authenticate, dup); } else if (!strcasecmp("Location", git_buf_cstr(name))) { if (!t->location) { t->location = git__strdup(git_buf_cstr(value)); GITERR_CHECK_ALLOC(t->location); } } return 0; } static int on_header_field(http_parser *parser, const char *str, size_t len) { parser_context *ctx = (parser_context *) parser->data; http_subtransport *t = ctx->t; /* Both parse_header_name and parse_header_value are populated * and ready for consumption */ if (VALUE == t->last_cb) if (on_header_ready(t) < 0) return t->parse_error = PARSE_ERROR_GENERIC; if (NONE == t->last_cb || VALUE == t->last_cb) git_buf_clear(&t->parse_header_name); if (git_buf_put(&t->parse_header_name, str, len) < 0) return t->parse_error = PARSE_ERROR_GENERIC; t->last_cb = FIELD; return 0; } static int on_header_value(http_parser *parser, const char *str, size_t len) { parser_context *ctx = (parser_context *) parser->data; http_subtransport *t = ctx->t; assert(NONE != t->last_cb); if (FIELD == t->last_cb) git_buf_clear(&t->parse_header_value); if (git_buf_put(&t->parse_header_value, str, len) < 0) return t->parse_error = PARSE_ERROR_GENERIC; t->last_cb = VALUE; return 0; } static int on_headers_complete(http_parser *parser) { parser_context *ctx = (parser_context *) parser->data; http_subtransport *t = ctx->t; http_stream *s = ctx->s; git_buf buf = GIT_BUF_INIT; int error = 0, no_callback = 0, allowed_auth_types = 0; /* Both parse_header_name and parse_header_value are populated * and ready for consumption. */ if (VALUE == t->last_cb) if (on_header_ready(t) < 0) return t->parse_error = PARSE_ERROR_GENERIC; /* Capture authentication headers which may be a 401 (authentication * is not complete) or a 200 (simply informing us that auth *is* * complete.) */ if (parse_authenticate_response(&t->www_authenticate, t, &allowed_auth_types) < 0) return t->parse_error = PARSE_ERROR_GENERIC; /* Check for an authentication failure. */ if (parser->status_code == 401 && get_verb == s->verb) { if (!t->owner->cred_acquire_cb) { no_callback = 1; } else { if (allowed_auth_types) { if (t->cred) { t->cred->free(t->cred); t->cred = NULL; } error = t->owner->cred_acquire_cb(&t->cred, t->owner->url, t->connection_data.user, allowed_auth_types, t->owner->cred_acquire_payload); if (error == GIT_PASSTHROUGH) { no_callback = 1; } else if (error < 0) { t->error = error; return t->parse_error = PARSE_ERROR_EXT; } else { assert(t->cred); if (!(t->cred->credtype & allowed_auth_types)) { giterr_set(GITERR_NET, "credentials callback returned an invalid cred type"); return t->parse_error = PARSE_ERROR_GENERIC; } /* Successfully acquired a credential. */ t->parse_error = PARSE_ERROR_REPLAY; return 0; } } } if (no_callback) { giterr_set(GITERR_NET, "authentication required but no callback set"); return t->parse_error = PARSE_ERROR_GENERIC; } } /* Check for a redirect. * Right now we only permit a redirect to the same hostname. */ if ((parser->status_code == 301 || parser->status_code == 302 || (parser->status_code == 303 && get_verb == s->verb) || parser->status_code == 307) && t->location) { if (s->redirect_count >= 7) { giterr_set(GITERR_NET, "Too many redirects"); return t->parse_error = PARSE_ERROR_GENERIC; } if (gitno_connection_data_from_url(&t->connection_data, t->location, s->service_url) < 0) return t->parse_error = PARSE_ERROR_GENERIC; /* Set the redirect URL on the stream. This is a transfer of * ownership of the memory. */ if (s->redirect_url) git__free(s->redirect_url); s->redirect_url = t->location; t->location = NULL; t->connected = 0; s->redirect_count++; t->parse_error = PARSE_ERROR_REPLAY; return 0; } /* Check for a 200 HTTP status code. */ if (parser->status_code != 200) { giterr_set(GITERR_NET, "Unexpected HTTP status code: %d", parser->status_code); return t->parse_error = PARSE_ERROR_GENERIC; } /* The response must contain a Content-Type header. */ if (!t->content_type) { giterr_set(GITERR_NET, "No Content-Type header in response"); return t->parse_error = PARSE_ERROR_GENERIC; } /* The Content-Type header must match our expectation. */ if (get_verb == s->verb) git_buf_printf(&buf, "application/x-git-%s-advertisement", ctx->s->service); else git_buf_printf(&buf, "application/x-git-%s-result", ctx->s->service); if (git_buf_oom(&buf)) return t->parse_error = PARSE_ERROR_GENERIC; if (strcmp(t->content_type, git_buf_cstr(&buf))) { git_buf_free(&buf); giterr_set(GITERR_NET, "Invalid Content-Type: %s", t->content_type); return t->parse_error = PARSE_ERROR_GENERIC; } git_buf_free(&buf); return 0; } static int on_message_complete(http_parser *parser) { parser_context *ctx = (parser_context *) parser->data; http_subtransport *t = ctx->t; t->parse_finished = 1; return 0; } static int on_body_fill_buffer(http_parser *parser, const char *str, size_t len) { parser_context *ctx = (parser_context *) parser->data; http_subtransport *t = ctx->t; /* If our goal is to replay the request (either an auth failure or * a redirect) then don't bother buffering since we're ignoring the * content anyway. */ if (t->parse_error == PARSE_ERROR_REPLAY) return 0; if (ctx->buf_size < len) { giterr_set(GITERR_NET, "Can't fit data in the buffer"); return t->parse_error = PARSE_ERROR_GENERIC; } memcpy(ctx->buffer, str, len); *(ctx->bytes_read) += len; ctx->buffer += len; ctx->buf_size -= len; return 0; } static void clear_parser_state(http_subtransport *t) { http_parser_init(&t->parser, HTTP_RESPONSE); gitno_buffer_setup_fromstream(t->io, &t->parse_buffer, t->parse_buffer_data, sizeof(t->parse_buffer_data)); t->last_cb = NONE; t->parse_error = 0; t->parse_finished = 0; git_buf_free(&t->parse_header_name); git_buf_init(&t->parse_header_name, 0); git_buf_free(&t->parse_header_value); git_buf_init(&t->parse_header_value, 0); git__free(t->content_type); t->content_type = NULL; git__free(t->location); t->location = NULL; git_vector_free_deep(&t->www_authenticate); } static int write_chunk(git_stream *io, const char *buffer, size_t len) { git_buf buf = GIT_BUF_INIT; /* Chunk header */ git_buf_printf(&buf, "%" PRIxZ "\r\n", len); if (git_buf_oom(&buf)) return -1; if (git_stream_write(io, buf.ptr, buf.size, 0) < 0) { git_buf_free(&buf); return -1; } git_buf_free(&buf); /* Chunk body */ if (len > 0 && git_stream_write(io, buffer, len, 0) < 0) return -1; /* Chunk footer */ if (git_stream_write(io, "\r\n", 2, 0) < 0) return -1; return 0; } static int http_connect(http_subtransport *t) { int error; char *proxy_url; if (t->connected && http_should_keep_alive(&t->parser) && t->parse_finished) return 0; if (t->io) { git_stream_close(t->io); git_stream_free(t->io); t->io = NULL; } if (t->connection_data.use_ssl) { error = git_tls_stream_new(&t->io, t->connection_data.host, t->connection_data.port); } else { #ifdef GIT_CURL error = git_curl_stream_new(&t->io, t->connection_data.host, t->connection_data.port); #else error = git_socket_stream_new(&t->io, t->connection_data.host, t->connection_data.port); #endif } if (error < 0) return error; GITERR_CHECK_VERSION(t->io, GIT_STREAM_VERSION, "git_stream"); if (git_stream_supports_proxy(t->io) && !git_remote__get_http_proxy(t->owner->owner, !!t->connection_data.use_ssl, &proxy_url)) { error = git_stream_set_proxy(t->io, proxy_url); git__free(proxy_url); if (error < 0) return error; } error = git_stream_connect(t->io); #if defined(GIT_OPENSSL) || defined(GIT_SECURE_TRANSPORT) || defined(GIT_CURL) if ((!error || error == GIT_ECERTIFICATE) && t->owner->certificate_check_cb != NULL && git_stream_is_encrypted(t->io)) { git_cert *cert; int is_valid; if ((error = git_stream_certificate(&cert, t->io)) < 0) return error; giterr_clear(); is_valid = error != GIT_ECERTIFICATE; error = t->owner->certificate_check_cb(cert, is_valid, t->connection_data.host, t->owner->message_cb_payload); if (error < 0) { if (!giterr_last()) giterr_set(GITERR_NET, "user cancelled certificate check"); return error; } } #endif if (error < 0) return error; t->connected = 1; return 0; } static int http_stream_read( git_smart_subtransport_stream *stream, char *buffer, size_t buf_size, size_t *bytes_read) { http_stream *s = (http_stream *)stream; http_subtransport *t = OWNING_SUBTRANSPORT(s); parser_context ctx; size_t bytes_parsed; replay: *bytes_read = 0; assert(t->connected); if (!s->sent_request) { git_buf request = GIT_BUF_INIT; clear_parser_state(t); if (gen_request(&request, s, 0) < 0) return -1; if (git_stream_write(t->io, request.ptr, request.size, 0) < 0) { git_buf_free(&request); return -1; } git_buf_free(&request); s->sent_request = 1; } if (!s->received_response) { if (s->chunked) { assert(s->verb == post_verb); /* Flush, if necessary */ if (s->chunk_buffer_len > 0 && write_chunk(t->io, s->chunk_buffer, s->chunk_buffer_len) < 0) return -1; s->chunk_buffer_len = 0; /* Write the final chunk. */ if (git_stream_write(t->io, "0\r\n\r\n", 5, 0) < 0) return -1; } s->received_response = 1; } while (!*bytes_read && !t->parse_finished) { size_t data_offset; int error; /* * Make the parse_buffer think it's as full of data as * the buffer, so it won't try to recv more data than * we can put into it. * * data_offset is the actual data offset from which we * should tell the parser to start reading. */ if (buf_size >= t->parse_buffer.len) { t->parse_buffer.offset = 0; } else { t->parse_buffer.offset = t->parse_buffer.len - buf_size; } data_offset = t->parse_buffer.offset; if (gitno_recv(&t->parse_buffer) < 0) return -1; /* This call to http_parser_execute will result in invocations of the * on_* family of callbacks. The most interesting of these is * on_body_fill_buffer, which is called when data is ready to be copied * into the target buffer. We need to marshal the buffer, buf_size, and * bytes_read parameters to this callback. */ ctx.t = t; ctx.s = s; ctx.buffer = buffer; ctx.buf_size = buf_size; ctx.bytes_read = bytes_read; /* Set the context, call the parser, then unset the context. */ t->parser.data = &ctx; bytes_parsed = http_parser_execute(&t->parser, &t->settings, t->parse_buffer.data + data_offset, t->parse_buffer.offset - data_offset); t->parser.data = NULL; /* If there was a handled authentication failure, then parse_error * will have signaled us that we should replay the request. */ if (PARSE_ERROR_REPLAY == t->parse_error) { s->sent_request = 0; if ((error = http_connect(t)) < 0) return error; goto replay; } if (t->parse_error == PARSE_ERROR_EXT) { return t->error; } if (t->parse_error < 0) return -1; if (bytes_parsed != t->parse_buffer.offset - data_offset) { giterr_set(GITERR_NET, "HTTP parser error: %s", http_errno_description((enum http_errno)t->parser.http_errno)); return -1; } } return 0; } static int http_stream_write_chunked( git_smart_subtransport_stream *stream, const char *buffer, size_t len) { http_stream *s = (http_stream *)stream; http_subtransport *t = OWNING_SUBTRANSPORT(s); assert(t->connected); /* Send the request, if necessary */ if (!s->sent_request) { git_buf request = GIT_BUF_INIT; clear_parser_state(t); if (gen_request(&request, s, 0) < 0) return -1; if (git_stream_write(t->io, request.ptr, request.size, 0) < 0) { git_buf_free(&request); return -1; } git_buf_free(&request); s->sent_request = 1; } if (len > CHUNK_SIZE) { /* Flush, if necessary */ if (s->chunk_buffer_len > 0) { if (write_chunk(t->io, s->chunk_buffer, s->chunk_buffer_len) < 0) return -1; s->chunk_buffer_len = 0; } /* Write chunk directly */ if (write_chunk(t->io, buffer, len) < 0) return -1; } else { /* Append as much to the buffer as we can */ int count = min(CHUNK_SIZE - s->chunk_buffer_len, len); if (!s->chunk_buffer) s->chunk_buffer = git__malloc(CHUNK_SIZE); memcpy(s->chunk_buffer + s->chunk_buffer_len, buffer, count); s->chunk_buffer_len += count; buffer += count; len -= count; /* Is the buffer full? If so, then flush */ if (CHUNK_SIZE == s->chunk_buffer_len) { if (write_chunk(t->io, s->chunk_buffer, s->chunk_buffer_len) < 0) return -1; s->chunk_buffer_len = 0; if (len > 0) { memcpy(s->chunk_buffer, buffer, len); s->chunk_buffer_len = len; } } } return 0; } static int http_stream_write_single( git_smart_subtransport_stream *stream, const char *buffer, size_t len) { http_stream *s = (http_stream *)stream; http_subtransport *t = OWNING_SUBTRANSPORT(s); git_buf request = GIT_BUF_INIT; assert(t->connected); if (s->sent_request) { giterr_set(GITERR_NET, "Subtransport configured for only one write"); return -1; } clear_parser_state(t); if (gen_request(&request, s, len) < 0) return -1; if (git_stream_write(t->io, request.ptr, request.size, 0) < 0) goto on_error; if (len && git_stream_write(t->io, buffer, len, 0) < 0) goto on_error; git_buf_free(&request); s->sent_request = 1; return 0; on_error: git_buf_free(&request); return -1; } static void http_stream_free(git_smart_subtransport_stream *stream) { http_stream *s = (http_stream *)stream; if (s->chunk_buffer) git__free(s->chunk_buffer); if (s->redirect_url) git__free(s->redirect_url); git__free(s); } static int http_stream_alloc(http_subtransport *t, git_smart_subtransport_stream **stream) { http_stream *s; if (!stream) return -1; s = git__calloc(sizeof(http_stream), 1); GITERR_CHECK_ALLOC(s); s->parent.subtransport = &t->parent; s->parent.read = http_stream_read; s->parent.write = http_stream_write_single; s->parent.free = http_stream_free; *stream = (git_smart_subtransport_stream *)s; return 0; } static int http_uploadpack_ls( http_subtransport *t, git_smart_subtransport_stream **stream) { http_stream *s; if (http_stream_alloc(t, stream) < 0) return -1; s = (http_stream *)*stream; s->service = upload_pack_service; s->service_url = upload_pack_ls_service_url; s->verb = get_verb; return 0; } static int http_uploadpack( http_subtransport *t, git_smart_subtransport_stream **stream) { http_stream *s; if (http_stream_alloc(t, stream) < 0) return -1; s = (http_stream *)*stream; s->service = upload_pack_service; s->service_url = upload_pack_service_url; s->verb = post_verb; return 0; } static int http_receivepack_ls( http_subtransport *t, git_smart_subtransport_stream **stream) { http_stream *s; if (http_stream_alloc(t, stream) < 0) return -1; s = (http_stream *)*stream; s->service = receive_pack_service; s->service_url = receive_pack_ls_service_url; s->verb = get_verb; return 0; } static int http_receivepack( http_subtransport *t, git_smart_subtransport_stream **stream) { http_stream *s; if (http_stream_alloc(t, stream) < 0) return -1; s = (http_stream *)*stream; /* Use Transfer-Encoding: chunked for this request */ s->chunked = 1; s->parent.write = http_stream_write_chunked; s->service = receive_pack_service; s->service_url = receive_pack_service_url; s->verb = post_verb; return 0; } static int http_action( git_smart_subtransport_stream **stream, git_smart_subtransport *subtransport, const char *url, git_smart_service_t action) { http_subtransport *t = (http_subtransport *)subtransport; int ret; if (!stream) return -1; if ((!t->connection_data.host || !t->connection_data.port || !t->connection_data.path) && (ret = gitno_connection_data_from_url(&t->connection_data, url, NULL)) < 0) return ret; if ((ret = http_connect(t)) < 0) return ret; switch (action) { case GIT_SERVICE_UPLOADPACK_LS: return http_uploadpack_ls(t, stream); case GIT_SERVICE_UPLOADPACK: return http_uploadpack(t, stream); case GIT_SERVICE_RECEIVEPACK_LS: return http_receivepack_ls(t, stream); case GIT_SERVICE_RECEIVEPACK: return http_receivepack(t, stream); } *stream = NULL; return -1; } static int http_close(git_smart_subtransport *subtransport) { http_subtransport *t = (http_subtransport *) subtransport; git_http_auth_context *context; size_t i; clear_parser_state(t); if (t->io) { git_stream_close(t->io); git_stream_free(t->io); t->io = NULL; } if (t->cred) { t->cred->free(t->cred); t->cred = NULL; } if (t->url_cred) { t->url_cred->free(t->url_cred); t->url_cred = NULL; } git_vector_foreach(&t->auth_contexts, i, context) { if (context->free) context->free(context); } git_vector_clear(&t->auth_contexts); gitno_connection_data_free_ptrs(&t->connection_data); memset(&t->connection_data, 0x0, sizeof(gitno_connection_data)); return 0; } static void http_free(git_smart_subtransport *subtransport) { http_subtransport *t = (http_subtransport *) subtransport; http_close(subtransport); git_vector_free(&t->auth_contexts); git__free(t); } int git_smart_subtransport_http(git_smart_subtransport **out, git_transport *owner, void *param) { http_subtransport *t; GIT_UNUSED(param); if (!out) return -1; t = git__calloc(sizeof(http_subtransport), 1); GITERR_CHECK_ALLOC(t); t->owner = (transport_smart *)owner; t->parent.action = http_action; t->parent.close = http_close; t->parent.free = http_free; t->settings.on_header_field = on_header_field; t->settings.on_header_value = on_header_value; t->settings.on_headers_complete = on_headers_complete; t->settings.on_body = on_body_fill_buffer; t->settings.on_message_complete = on_message_complete; *out = (git_smart_subtransport *) t; return 0; } #endif /* !GIT_WINHTTP */ deps/libgit2-sys-0.3.8/libgit2/src/transports/smart_protocol.c0000664000175000017500000005761012572105236021340 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2.h" #include "git2/odb_backend.h" #include "smart.h" #include "refs.h" #include "repository.h" #include "push.h" #include "pack-objects.h" #include "remote.h" #include "util.h" #define NETWORK_XFER_THRESHOLD (100*1024) /* The minimal interval between progress updates (in seconds). */ #define MIN_PROGRESS_UPDATE_INTERVAL 0.5 int git_smart__store_refs(transport_smart *t, int flushes) { gitno_buffer *buf = &t->buffer; git_vector *refs = &t->refs; int error, flush = 0, recvd; const char *line_end = NULL; git_pkt *pkt = NULL; size_t i; /* Clear existing refs in case git_remote_connect() is called again * after git_remote_disconnect(). */ git_vector_foreach(refs, i, pkt) { git_pkt_free(pkt); } git_vector_clear(refs); pkt = NULL; do { if (buf->offset > 0) error = git_pkt_parse_line(&pkt, buf->data, &line_end, buf->offset); else error = GIT_EBUFS; if (error < 0 && error != GIT_EBUFS) return error; if (error == GIT_EBUFS) { if ((recvd = gitno_recv(buf)) < 0) return recvd; if (recvd == 0 && !flush) { giterr_set(GITERR_NET, "early EOF"); return GIT_EEOF; } continue; } gitno_consume(buf, line_end); if (pkt->type == GIT_PKT_ERR) { giterr_set(GITERR_NET, "Remote error: %s", ((git_pkt_err *)pkt)->error); git__free(pkt); return -1; } if (pkt->type != GIT_PKT_FLUSH && git_vector_insert(refs, pkt) < 0) return -1; if (pkt->type == GIT_PKT_FLUSH) { flush++; git_pkt_free(pkt); } } while (flush < flushes); return flush; } static int append_symref(const char **out, git_vector *symrefs, const char *ptr) { int error; const char *end; git_buf buf = GIT_BUF_INIT; git_refspec *mapping = NULL; ptr += strlen(GIT_CAP_SYMREF); if (*ptr != '=') goto on_invalid; ptr++; if (!(end = strchr(ptr, ' ')) && !(end = strchr(ptr, '\0'))) goto on_invalid; if ((error = git_buf_put(&buf, ptr, end - ptr)) < 0) return error; /* symref mapping has refspec format */ mapping = git__calloc(1, sizeof(git_refspec)); GITERR_CHECK_ALLOC(mapping); error = git_refspec__parse(mapping, git_buf_cstr(&buf), true); git_buf_free(&buf); /* if the error isn't OOM, then it's a parse error; let's use a nicer message */ if (error < 0) { if (giterr_last()->klass != GITERR_NOMEMORY) goto on_invalid; return error; } if ((error = git_vector_insert(symrefs, mapping)) < 0) return error; *out = end; return 0; on_invalid: giterr_set(GITERR_NET, "remote sent invalid symref"); git_refspec__free(mapping); return -1; } int git_smart__detect_caps(git_pkt_ref *pkt, transport_smart_caps *caps, git_vector *symrefs) { const char *ptr; /* No refs or capabilites, odd but not a problem */ if (pkt == NULL || pkt->capabilities == NULL) return 0; ptr = pkt->capabilities; while (ptr != NULL && *ptr != '\0') { if (*ptr == ' ') ptr++; if (!git__prefixcmp(ptr, GIT_CAP_OFS_DELTA)) { caps->common = caps->ofs_delta = 1; ptr += strlen(GIT_CAP_OFS_DELTA); continue; } /* Keep multi_ack_detailed before multi_ack */ if (!git__prefixcmp(ptr, GIT_CAP_MULTI_ACK_DETAILED)) { caps->common = caps->multi_ack_detailed = 1; ptr += strlen(GIT_CAP_MULTI_ACK_DETAILED); continue; } if (!git__prefixcmp(ptr, GIT_CAP_MULTI_ACK)) { caps->common = caps->multi_ack = 1; ptr += strlen(GIT_CAP_MULTI_ACK); continue; } if (!git__prefixcmp(ptr, GIT_CAP_INCLUDE_TAG)) { caps->common = caps->include_tag = 1; ptr += strlen(GIT_CAP_INCLUDE_TAG); continue; } /* Keep side-band check after side-band-64k */ if (!git__prefixcmp(ptr, GIT_CAP_SIDE_BAND_64K)) { caps->common = caps->side_band_64k = 1; ptr += strlen(GIT_CAP_SIDE_BAND_64K); continue; } if (!git__prefixcmp(ptr, GIT_CAP_SIDE_BAND)) { caps->common = caps->side_band = 1; ptr += strlen(GIT_CAP_SIDE_BAND); continue; } if (!git__prefixcmp(ptr, GIT_CAP_DELETE_REFS)) { caps->common = caps->delete_refs = 1; ptr += strlen(GIT_CAP_DELETE_REFS); continue; } if (!git__prefixcmp(ptr, GIT_CAP_THIN_PACK)) { caps->common = caps->thin_pack = 1; ptr += strlen(GIT_CAP_THIN_PACK); continue; } if (!git__prefixcmp(ptr, GIT_CAP_SYMREF)) { int error; if ((error = append_symref(&ptr, symrefs, ptr)) < 0) return error; continue; } /* We don't know this capability, so skip it */ ptr = strchr(ptr, ' '); } return 0; } static int recv_pkt(git_pkt **out, gitno_buffer *buf) { const char *ptr = buf->data, *line_end = ptr; git_pkt *pkt = NULL; int pkt_type, error = 0, ret; do { if (buf->offset > 0) error = git_pkt_parse_line(&pkt, ptr, &line_end, buf->offset); else error = GIT_EBUFS; if (error == 0) break; /* return the pkt */ if (error < 0 && error != GIT_EBUFS) return error; if ((ret = gitno_recv(buf)) < 0) return ret; } while (error); gitno_consume(buf, line_end); pkt_type = pkt->type; if (out != NULL) *out = pkt; else git__free(pkt); return pkt_type; } static int store_common(transport_smart *t) { git_pkt *pkt = NULL; gitno_buffer *buf = &t->buffer; int error; do { if ((error = recv_pkt(&pkt, buf)) < 0) return error; if (pkt->type == GIT_PKT_ACK) { if (git_vector_insert(&t->common, pkt) < 0) return -1; } else { git__free(pkt); return 0; } } while (1); return 0; } static int fetch_setup_walk(git_revwalk **out, git_repository *repo) { git_revwalk *walk = NULL; git_strarray refs; unsigned int i; git_reference *ref; int error; if ((error = git_reference_list(&refs, repo)) < 0) return error; if ((error = git_revwalk_new(&walk, repo)) < 0) return error; git_revwalk_sorting(walk, GIT_SORT_TIME); for (i = 0; i < refs.count; ++i) { /* No tags */ if (!git__prefixcmp(refs.strings[i], GIT_REFS_TAGS_DIR)) continue; if ((error = git_reference_lookup(&ref, repo, refs.strings[i])) < 0) goto on_error; if (git_reference_type(ref) == GIT_REF_SYMBOLIC) continue; if ((error = git_revwalk_push(walk, git_reference_target(ref))) < 0) goto on_error; git_reference_free(ref); } git_strarray_free(&refs); *out = walk; return 0; on_error: git_revwalk_free(walk); git_reference_free(ref); git_strarray_free(&refs); return error; } static int wait_while_ack(gitno_buffer *buf) { int error; git_pkt_ack *pkt = NULL; while (1) { git__free(pkt); if ((error = recv_pkt((git_pkt **)&pkt, buf)) < 0) return error; if (pkt->type == GIT_PKT_NAK) break; if (pkt->type == GIT_PKT_ACK && (pkt->status != GIT_ACK_CONTINUE && pkt->status != GIT_ACK_COMMON)) { git__free(pkt); return 0; } } git__free(pkt); return 0; } int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, const git_remote_head * const *wants, size_t count) { transport_smart *t = (transport_smart *)transport; gitno_buffer *buf = &t->buffer; git_buf data = GIT_BUF_INIT; git_revwalk *walk = NULL; int error = -1, pkt_type; unsigned int i; git_oid oid; if ((error = git_pkt_buffer_wants(wants, count, &t->caps, &data)) < 0) return error; if ((error = fetch_setup_walk(&walk, repo)) < 0) goto on_error; /* * Our support for ACK extensions is simply to parse them. On * the first ACK we will accept that as enough common * objects. We give up if we haven't found an answer in the * first 256 we send. */ i = 0; while (i < 256) { error = git_revwalk_next(&oid, walk); if (error < 0) { if (GIT_ITEROVER == error) break; goto on_error; } git_pkt_buffer_have(&oid, &data); i++; if (i % 20 == 0) { if (t->cancelled.val) { giterr_set(GITERR_NET, "The fetch was cancelled by the user"); error = GIT_EUSER; goto on_error; } git_pkt_buffer_flush(&data); if (git_buf_oom(&data)) { error = -1; goto on_error; } if ((error = git_smart__negotiation_step(&t->parent, data.ptr, data.size)) < 0) goto on_error; git_buf_clear(&data); if (t->caps.multi_ack || t->caps.multi_ack_detailed) { if ((error = store_common(t)) < 0) goto on_error; } else { pkt_type = recv_pkt(NULL, buf); if (pkt_type == GIT_PKT_ACK) { break; } else if (pkt_type == GIT_PKT_NAK) { continue; } else if (pkt_type < 0) { /* recv_pkt returned an error */ error = pkt_type; goto on_error; } else { giterr_set(GITERR_NET, "Unexpected pkt type"); error = -1; goto on_error; } } } if (t->common.length > 0) break; if (i % 20 == 0 && t->rpc) { git_pkt_ack *pkt; unsigned int i; if ((error = git_pkt_buffer_wants(wants, count, &t->caps, &data)) < 0) goto on_error; git_vector_foreach(&t->common, i, pkt) { if ((error = git_pkt_buffer_have(&pkt->oid, &data)) < 0) goto on_error; } if (git_buf_oom(&data)) { error = -1; goto on_error; } } } /* Tell the other end that we're done negotiating */ if (t->rpc && t->common.length > 0) { git_pkt_ack *pkt; unsigned int i; if ((error = git_pkt_buffer_wants(wants, count, &t->caps, &data)) < 0) goto on_error; git_vector_foreach(&t->common, i, pkt) { if ((error = git_pkt_buffer_have(&pkt->oid, &data)) < 0) goto on_error; } if (git_buf_oom(&data)) { error = -1; goto on_error; } } if ((error = git_pkt_buffer_done(&data)) < 0) goto on_error; if (t->cancelled.val) { giterr_set(GITERR_NET, "The fetch was cancelled by the user"); error = GIT_EUSER; goto on_error; } if ((error = git_smart__negotiation_step(&t->parent, data.ptr, data.size)) < 0) goto on_error; git_buf_free(&data); git_revwalk_free(walk); /* Now let's eat up whatever the server gives us */ if (!t->caps.multi_ack && !t->caps.multi_ack_detailed) { pkt_type = recv_pkt(NULL, buf); if (pkt_type < 0) { return pkt_type; } else if (pkt_type != GIT_PKT_ACK && pkt_type != GIT_PKT_NAK) { giterr_set(GITERR_NET, "Unexpected pkt type"); return -1; } } else { error = wait_while_ack(buf); } return error; on_error: git_revwalk_free(walk); git_buf_free(&data); return error; } static int no_sideband(transport_smart *t, struct git_odb_writepack *writepack, gitno_buffer *buf, git_transfer_progress *stats) { int recvd; do { if (t->cancelled.val) { giterr_set(GITERR_NET, "The fetch was cancelled by the user"); return GIT_EUSER; } if (writepack->append(writepack, buf->data, buf->offset, stats) < 0) return -1; gitno_consume_n(buf, buf->offset); if ((recvd = gitno_recv(buf)) < 0) return recvd; } while(recvd > 0); if (writepack->commit(writepack, stats) < 0) return -1; return 0; } struct network_packetsize_payload { git_transfer_progress_cb callback; void *payload; git_transfer_progress *stats; size_t last_fired_bytes; }; static int network_packetsize(size_t received, void *payload) { struct network_packetsize_payload *npp = (struct network_packetsize_payload*)payload; /* Accumulate bytes */ npp->stats->received_bytes += received; /* Fire notification if the threshold is reached */ if ((npp->stats->received_bytes - npp->last_fired_bytes) > NETWORK_XFER_THRESHOLD) { npp->last_fired_bytes = npp->stats->received_bytes; if (npp->callback(npp->stats, npp->payload)) return GIT_EUSER; } return 0; } int git_smart__download_pack( git_transport *transport, git_repository *repo, git_transfer_progress *stats, git_transfer_progress_cb transfer_progress_cb, void *progress_payload) { transport_smart *t = (transport_smart *)transport; gitno_buffer *buf = &t->buffer; git_odb *odb; struct git_odb_writepack *writepack = NULL; int error = 0; struct network_packetsize_payload npp = {0}; memset(stats, 0, sizeof(git_transfer_progress)); if (transfer_progress_cb) { npp.callback = transfer_progress_cb; npp.payload = progress_payload; npp.stats = stats; t->packetsize_cb = &network_packetsize; t->packetsize_payload = &npp; /* We might have something in the buffer already from negotiate_fetch */ if (t->buffer.offset > 0 && !t->cancelled.val) if (t->packetsize_cb(t->buffer.offset, t->packetsize_payload)) git_atomic_set(&t->cancelled, 1); } if ((error = git_repository_odb__weakptr(&odb, repo)) < 0 || ((error = git_odb_write_pack(&writepack, odb, transfer_progress_cb, progress_payload)) != 0)) goto done; /* * If the remote doesn't support the side-band, we can feed * the data directly to the pack writer. Otherwise, we need to * check which one belongs there. */ if (!t->caps.side_band && !t->caps.side_band_64k) { error = no_sideband(t, writepack, buf, stats); goto done; } do { git_pkt *pkt = NULL; /* Check cancellation before network call */ if (t->cancelled.val) { giterr_clear(); error = GIT_EUSER; goto done; } if ((error = recv_pkt(&pkt, buf)) >= 0) { /* Check cancellation after network call */ if (t->cancelled.val) { giterr_clear(); error = GIT_EUSER; } else if (pkt->type == GIT_PKT_PROGRESS) { if (t->progress_cb) { git_pkt_progress *p = (git_pkt_progress *) pkt; error = t->progress_cb(p->data, p->len, t->message_cb_payload); } } else if (pkt->type == GIT_PKT_DATA) { git_pkt_data *p = (git_pkt_data *) pkt; if (p->len) error = writepack->append(writepack, p->data, p->len, stats); } else if (pkt->type == GIT_PKT_FLUSH) { /* A flush indicates the end of the packfile */ git__free(pkt); break; } } git__free(pkt); if (error < 0) goto done; } while (1); /* * Trailing execution of transfer_progress_cb, if necessary... * Only the callback through the npp datastructure currently * updates the last_fired_bytes value. It is possible that * progress has already been reported with the correct * "received_bytes" value, but until (if?) this is unified * then we will report progress again to be sure that the * correct last received_bytes value is reported. */ if (npp.callback && npp.stats->received_bytes > npp.last_fired_bytes) { error = npp.callback(npp.stats, npp.payload); if (error != 0) goto done; } error = writepack->commit(writepack, stats); done: if (writepack) writepack->free(writepack); if (transfer_progress_cb) { t->packetsize_cb = NULL; t->packetsize_payload = NULL; } return error; } static int gen_pktline(git_buf *buf, git_push *push) { push_spec *spec; size_t i, len; char old_id[GIT_OID_HEXSZ+1], new_id[GIT_OID_HEXSZ+1]; old_id[GIT_OID_HEXSZ] = '\0'; new_id[GIT_OID_HEXSZ] = '\0'; git_vector_foreach(&push->specs, i, spec) { len = 2*GIT_OID_HEXSZ + 7 + strlen(spec->refspec.dst); if (i == 0) { ++len; /* '\0' */ if (push->report_status) len += strlen(GIT_CAP_REPORT_STATUS) + 1; len += strlen(GIT_CAP_SIDE_BAND_64K) + 1; } git_oid_fmt(old_id, &spec->roid); git_oid_fmt(new_id, &spec->loid); git_buf_printf(buf, "%04"PRIxZ"%s %s %s", len, old_id, new_id, spec->refspec.dst); if (i == 0) { git_buf_putc(buf, '\0'); /* Core git always starts their capabilities string with a space */ if (push->report_status) { git_buf_putc(buf, ' '); git_buf_printf(buf, GIT_CAP_REPORT_STATUS); } git_buf_putc(buf, ' '); git_buf_printf(buf, GIT_CAP_SIDE_BAND_64K); } git_buf_putc(buf, '\n'); } git_buf_puts(buf, "0000"); return git_buf_oom(buf) ? -1 : 0; } static int add_push_report_pkt(git_push *push, git_pkt *pkt) { push_status *status; switch (pkt->type) { case GIT_PKT_OK: status = git__calloc(1, sizeof(push_status)); GITERR_CHECK_ALLOC(status); status->msg = NULL; status->ref = git__strdup(((git_pkt_ok *)pkt)->ref); if (!status->ref || git_vector_insert(&push->status, status) < 0) { git_push_status_free(status); return -1; } break; case GIT_PKT_NG: status = git__calloc(1, sizeof(push_status)); GITERR_CHECK_ALLOC(status); status->ref = git__strdup(((git_pkt_ng *)pkt)->ref); status->msg = git__strdup(((git_pkt_ng *)pkt)->msg); if (!status->ref || !status->msg || git_vector_insert(&push->status, status) < 0) { git_push_status_free(status); return -1; } break; case GIT_PKT_UNPACK: push->unpack_ok = ((git_pkt_unpack *)pkt)->unpack_ok; break; case GIT_PKT_FLUSH: return GIT_ITEROVER; default: giterr_set(GITERR_NET, "report-status: protocol error"); return -1; } return 0; } static int add_push_report_sideband_pkt(git_push *push, git_pkt_data *data_pkt) { git_pkt *pkt; const char *line = data_pkt->data, *line_end; size_t line_len = data_pkt->len; int error; while (line_len > 0) { error = git_pkt_parse_line(&pkt, line, &line_end, line_len); if (error < 0) return error; /* Advance in the buffer */ line_len -= (line_end - line); line = line_end; error = add_push_report_pkt(push, pkt); git_pkt_free(pkt); if (error < 0 && error != GIT_ITEROVER) return error; } return 0; } static int parse_report(transport_smart *transport, git_push *push) { git_pkt *pkt = NULL; const char *line_end = NULL; gitno_buffer *buf = &transport->buffer; int error, recvd; for (;;) { if (buf->offset > 0) error = git_pkt_parse_line(&pkt, buf->data, &line_end, buf->offset); else error = GIT_EBUFS; if (error < 0 && error != GIT_EBUFS) return -1; if (error == GIT_EBUFS) { if ((recvd = gitno_recv(buf)) < 0) return recvd; if (recvd == 0) { giterr_set(GITERR_NET, "early EOF"); return GIT_EEOF; } continue; } gitno_consume(buf, line_end); error = 0; switch (pkt->type) { case GIT_PKT_DATA: /* This is a sideband packet which contains other packets */ error = add_push_report_sideband_pkt(push, (git_pkt_data *)pkt); break; case GIT_PKT_ERR: giterr_set(GITERR_NET, "report-status: Error reported: %s", ((git_pkt_err *)pkt)->error); error = -1; break; case GIT_PKT_PROGRESS: if (transport->progress_cb) { git_pkt_progress *p = (git_pkt_progress *) pkt; error = transport->progress_cb(p->data, p->len, transport->message_cb_payload); } break; default: error = add_push_report_pkt(push, pkt); break; } git_pkt_free(pkt); /* add_push_report_pkt returns GIT_ITEROVER when it receives a flush */ if (error == GIT_ITEROVER) return 0; if (error < 0) return error; } } static int add_ref_from_push_spec(git_vector *refs, push_spec *push_spec) { git_pkt_ref *added = git__calloc(1, sizeof(git_pkt_ref)); GITERR_CHECK_ALLOC(added); added->type = GIT_PKT_REF; git_oid_cpy(&added->head.oid, &push_spec->loid); added->head.name = git__strdup(push_spec->refspec.dst); if (!added->head.name || git_vector_insert(refs, added) < 0) { git_pkt_free((git_pkt *)added); return -1; } return 0; } static int update_refs_from_report( git_vector *refs, git_vector *push_specs, git_vector *push_report) { git_pkt_ref *ref; push_spec *push_spec; push_status *push_status; size_t i, j, refs_len; int cmp; /* For each push spec we sent to the server, we should have * gotten back a status packet in the push report */ if (push_specs->length != push_report->length) { giterr_set(GITERR_NET, "report-status: protocol error"); return -1; } /* We require that push_specs be sorted with push_spec_rref_cmp, * and that push_report be sorted with push_status_ref_cmp */ git_vector_sort(push_specs); git_vector_sort(push_report); git_vector_foreach(push_specs, i, push_spec) { push_status = git_vector_get(push_report, i); /* For each push spec we sent to the server, we should have * gotten back a status packet in the push report which matches */ if (strcmp(push_spec->refspec.dst, push_status->ref)) { giterr_set(GITERR_NET, "report-status: protocol error"); return -1; } } /* We require that refs be sorted with ref_name_cmp */ git_vector_sort(refs); i = j = 0; refs_len = refs->length; /* Merge join push_specs with refs */ while (i < push_specs->length && j < refs_len) { push_spec = git_vector_get(push_specs, i); push_status = git_vector_get(push_report, i); ref = git_vector_get(refs, j); cmp = strcmp(push_spec->refspec.dst, ref->head.name); /* Iterate appropriately */ if (cmp <= 0) i++; if (cmp >= 0) j++; /* Add case */ if (cmp < 0 && !push_status->msg && add_ref_from_push_spec(refs, push_spec) < 0) return -1; /* Update case, delete case */ if (cmp == 0 && !push_status->msg) git_oid_cpy(&ref->head.oid, &push_spec->loid); } for (; i < push_specs->length; i++) { push_spec = git_vector_get(push_specs, i); push_status = git_vector_get(push_report, i); /* Add case */ if (!push_status->msg && add_ref_from_push_spec(refs, push_spec) < 0) return -1; } /* Remove any refs which we updated to have a zero OID. */ git_vector_rforeach(refs, i, ref) { if (git_oid_iszero(&ref->head.oid)) { git_vector_remove(refs, i); git_pkt_free((git_pkt *)ref); } } git_vector_sort(refs); return 0; } struct push_packbuilder_payload { git_smart_subtransport_stream *stream; git_packbuilder *pb; git_push_transfer_progress cb; void *cb_payload; size_t last_bytes; double last_progress_report_time; }; static int stream_thunk(void *buf, size_t size, void *data) { int error = 0; struct push_packbuilder_payload *payload = data; if ((error = payload->stream->write(payload->stream, (const char *)buf, size)) < 0) return error; if (payload->cb) { double current_time = git__timer(); payload->last_bytes += size; if ((current_time - payload->last_progress_report_time) >= MIN_PROGRESS_UPDATE_INTERVAL) { payload->last_progress_report_time = current_time; error = payload->cb(payload->pb->nr_written, payload->pb->nr_objects, payload->last_bytes, payload->cb_payload); } } return error; } int git_smart__push(git_transport *transport, git_push *push, const git_remote_callbacks *cbs) { transport_smart *t = (transport_smart *)transport; struct push_packbuilder_payload packbuilder_payload = {0}; git_buf pktline = GIT_BUF_INIT; int error = 0, need_pack = 0; push_spec *spec; unsigned int i; packbuilder_payload.pb = push->pb; if (cbs && cbs->push_transfer_progress) { packbuilder_payload.cb = cbs->push_transfer_progress; packbuilder_payload.cb_payload = cbs->payload; } #ifdef PUSH_DEBUG { git_remote_head *head; char hex[GIT_OID_HEXSZ+1]; hex[GIT_OID_HEXSZ] = '\0'; git_vector_foreach(&push->remote->refs, i, head) { git_oid_fmt(hex, &head->oid); fprintf(stderr, "%s (%s)\n", hex, head->name); } git_vector_foreach(&push->specs, i, spec) { git_oid_fmt(hex, &spec->roid); fprintf(stderr, "%s (%s) -> ", hex, spec->lref); git_oid_fmt(hex, &spec->loid); fprintf(stderr, "%s (%s)\n", hex, spec->rref ? spec->rref : spec->lref); } } #endif /* * Figure out if we need to send a packfile; which is in all * cases except when we only send delete commands */ git_vector_foreach(&push->specs, i, spec) { if (spec->refspec.src && spec->refspec.src[0] != '\0') { need_pack = 1; break; } } if ((error = git_smart__get_push_stream(t, &packbuilder_payload.stream)) < 0 || (error = gen_pktline(&pktline, push)) < 0 || (error = packbuilder_payload.stream->write(packbuilder_payload.stream, git_buf_cstr(&pktline), git_buf_len(&pktline))) < 0) goto done; if (need_pack && (error = git_packbuilder_foreach(push->pb, &stream_thunk, &packbuilder_payload)) < 0) goto done; /* If we sent nothing or the server doesn't support report-status, then * we consider the pack to have been unpacked successfully */ if (!push->specs.length || !push->report_status) push->unpack_ok = 1; else if ((error = parse_report(t, push)) < 0) goto done; /* If progress is being reported write the final report */ if (cbs && cbs->push_transfer_progress) { error = cbs->push_transfer_progress( push->pb->nr_written, push->pb->nr_objects, packbuilder_payload.last_bytes, cbs->payload); if (error < 0) goto done; } if (push->status.length) { error = update_refs_from_report(&t->refs, &push->specs, &push->status); if (error < 0) goto done; error = git_smart__update_heads(t, NULL); } done: git_buf_free(&pktline); return error; } deps/libgit2-sys-0.3.8/libgit2/src/transports/git.c0000664000175000017500000001650112572105236017046 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2.h" #include "buffer.h" #include "netops.h" #include "git2/sys/transport.h" #include "stream.h" #include "socket_stream.h" #define OWNING_SUBTRANSPORT(s) ((git_subtransport *)(s)->parent.subtransport) static const char prefix_git[] = "git://"; static const char cmd_uploadpack[] = "git-upload-pack"; static const char cmd_receivepack[] = "git-receive-pack"; typedef struct { git_smart_subtransport_stream parent; git_stream *io; const char *cmd; char *url; unsigned sent_command : 1; } git_proto_stream; typedef struct { git_smart_subtransport parent; git_transport *owner; git_proto_stream *current_stream; } git_subtransport; /* * Create a git protocol request. * * For example: 0035git-upload-pack /libgit2/libgit2\0host=github.com\0 */ static int gen_proto(git_buf *request, const char *cmd, const char *url) { char *delim, *repo; char host[] = "host="; size_t len; delim = strchr(url, '/'); if (delim == NULL) { giterr_set(GITERR_NET, "Malformed URL"); return -1; } repo = delim; if (repo[1] == '~') ++repo; delim = strchr(url, ':'); if (delim == NULL) delim = strchr(url, '/'); len = 4 + strlen(cmd) + 1 + strlen(repo) + 1 + strlen(host) + (delim - url) + 1; git_buf_grow(request, len); git_buf_printf(request, "%04x%s %s%c%s", (unsigned int)(len & 0x0FFFF), cmd, repo, 0, host); git_buf_put(request, url, delim - url); git_buf_putc(request, '\0'); if (git_buf_oom(request)) return -1; return 0; } static int send_command(git_proto_stream *s) { int error; git_buf request = GIT_BUF_INIT; error = gen_proto(&request, s->cmd, s->url); if (error < 0) goto cleanup; error = git_stream_write(s->io, request.ptr, request.size, 0); if (error >= 0) s->sent_command = 1; cleanup: git_buf_free(&request); return error; } static int git_proto_stream_read( git_smart_subtransport_stream *stream, char *buffer, size_t buf_size, size_t *bytes_read) { int error; git_proto_stream *s = (git_proto_stream *)stream; gitno_buffer buf; *bytes_read = 0; if (!s->sent_command && (error = send_command(s)) < 0) return error; gitno_buffer_setup_fromstream(s->io, &buf, buffer, buf_size); if ((error = gitno_recv(&buf)) < 0) return error; *bytes_read = buf.offset; return 0; } static int git_proto_stream_write( git_smart_subtransport_stream *stream, const char *buffer, size_t len) { int error; git_proto_stream *s = (git_proto_stream *)stream; if (!s->sent_command && (error = send_command(s)) < 0) return error; return git_stream_write(s->io, buffer, len, 0); } static void git_proto_stream_free(git_smart_subtransport_stream *stream) { git_proto_stream *s = (git_proto_stream *)stream; git_subtransport *t = OWNING_SUBTRANSPORT(s); int ret; GIT_UNUSED(ret); t->current_stream = NULL; git_stream_close(s->io); git_stream_free(s->io); git__free(s->url); git__free(s); } static int git_proto_stream_alloc( git_subtransport *t, const char *url, const char *cmd, const char *host, const char *port, git_smart_subtransport_stream **stream) { git_proto_stream *s; if (!stream) return -1; s = git__calloc(1, sizeof(git_proto_stream)); GITERR_CHECK_ALLOC(s); s->parent.subtransport = &t->parent; s->parent.read = git_proto_stream_read; s->parent.write = git_proto_stream_write; s->parent.free = git_proto_stream_free; s->cmd = cmd; s->url = git__strdup(url); if (!s->url) { git__free(s); return -1; } if ((git_socket_stream_new(&s->io, host, port)) < 0) return -1; GITERR_CHECK_VERSION(s->io, GIT_STREAM_VERSION, "git_stream"); *stream = &s->parent; return 0; } static int _git_uploadpack_ls( git_subtransport *t, const char *url, git_smart_subtransport_stream **stream) { char *host=NULL, *port=NULL, *path=NULL, *user=NULL, *pass=NULL; const char *stream_url = url; git_proto_stream *s; int error; *stream = NULL; if (!git__prefixcmp(url, prefix_git)) stream_url += strlen(prefix_git); if ((error = gitno_extract_url_parts(&host, &port, &path, &user, &pass, url, GIT_DEFAULT_PORT)) < 0) return error; error = git_proto_stream_alloc(t, stream_url, cmd_uploadpack, host, port, stream); git__free(host); git__free(port); git__free(path); git__free(user); git__free(pass); if (error < 0) { git_proto_stream_free(*stream); return error; } s = (git_proto_stream *) *stream; if ((error = git_stream_connect(s->io)) < 0) { git_proto_stream_free(*stream); return error; } t->current_stream = s; return 0; } static int _git_uploadpack( git_subtransport *t, const char *url, git_smart_subtransport_stream **stream) { GIT_UNUSED(url); if (t->current_stream) { *stream = &t->current_stream->parent; return 0; } giterr_set(GITERR_NET, "Must call UPLOADPACK_LS before UPLOADPACK"); return -1; } static int _git_receivepack_ls( git_subtransport *t, const char *url, git_smart_subtransport_stream **stream) { char *host=NULL, *port=NULL, *path=NULL, *user=NULL, *pass=NULL; const char *stream_url = url; git_proto_stream *s; int error; *stream = NULL; if (!git__prefixcmp(url, prefix_git)) stream_url += strlen(prefix_git); if ((error = gitno_extract_url_parts(&host, &port, &path, &user, &pass, url, GIT_DEFAULT_PORT)) < 0) return error; error = git_proto_stream_alloc(t, stream_url, cmd_receivepack, host, port, stream); git__free(host); git__free(port); git__free(path); git__free(user); git__free(pass); if (error < 0) { git_proto_stream_free(*stream); return error; } s = (git_proto_stream *) *stream; if ((error = git_stream_connect(s->io)) < 0) return error; t->current_stream = s; return 0; } static int _git_receivepack( git_subtransport *t, const char *url, git_smart_subtransport_stream **stream) { GIT_UNUSED(url); if (t->current_stream) { *stream = &t->current_stream->parent; return 0; } giterr_set(GITERR_NET, "Must call RECEIVEPACK_LS before RECEIVEPACK"); return -1; } static int _git_action( git_smart_subtransport_stream **stream, git_smart_subtransport *subtransport, const char *url, git_smart_service_t action) { git_subtransport *t = (git_subtransport *) subtransport; switch (action) { case GIT_SERVICE_UPLOADPACK_LS: return _git_uploadpack_ls(t, url, stream); case GIT_SERVICE_UPLOADPACK: return _git_uploadpack(t, url, stream); case GIT_SERVICE_RECEIVEPACK_LS: return _git_receivepack_ls(t, url, stream); case GIT_SERVICE_RECEIVEPACK: return _git_receivepack(t, url, stream); } *stream = NULL; return -1; } static int _git_close(git_smart_subtransport *subtransport) { git_subtransport *t = (git_subtransport *) subtransport; assert(!t->current_stream); GIT_UNUSED(t); return 0; } static void _git_free(git_smart_subtransport *subtransport) { git_subtransport *t = (git_subtransport *) subtransport; assert(!t->current_stream); git__free(t); } int git_smart_subtransport_git(git_smart_subtransport **out, git_transport *owner, void *param) { git_subtransport *t; GIT_UNUSED(param); if (!out) return -1; t = git__calloc(1, sizeof(git_subtransport)); GITERR_CHECK_ALLOC(t); t->owner = owner; t->parent.action = _git_action; t->parent.close = _git_close; t->parent.free = _git_free; *out = (git_smart_subtransport *) t; return 0; } deps/libgit2-sys-0.3.8/libgit2/src/transports/smart.c0000664000175000017500000003035312610310643017403 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2.h" #include "smart.h" #include "refs.h" #include "refspec.h" static int git_smart__recv_cb(gitno_buffer *buf) { transport_smart *t = (transport_smart *) buf->cb_data; size_t old_len, bytes_read; int error; assert(t->current_stream); old_len = buf->offset; if ((error = t->current_stream->read(t->current_stream, buf->data + buf->offset, buf->len - buf->offset, &bytes_read)) < 0) return error; buf->offset += bytes_read; if (t->packetsize_cb && !t->cancelled.val) { error = t->packetsize_cb(bytes_read, t->packetsize_payload); if (error) { git_atomic_set(&t->cancelled, 1); return GIT_EUSER; } } return (int)(buf->offset - old_len); } GIT_INLINE(int) git_smart__reset_stream(transport_smart *t, bool close_subtransport) { if (t->current_stream) { t->current_stream->free(t->current_stream); t->current_stream = NULL; } if (close_subtransport && t->wrapped->close(t->wrapped) < 0) return -1; return 0; } static int git_smart__set_callbacks( git_transport *transport, git_transport_message_cb progress_cb, git_transport_message_cb error_cb, git_transport_certificate_check_cb certificate_check_cb, void *message_cb_payload) { transport_smart *t = (transport_smart *)transport; t->progress_cb = progress_cb; t->error_cb = error_cb; t->certificate_check_cb = certificate_check_cb; t->message_cb_payload = message_cb_payload; return 0; } static int http_header_name_length(const char *http_header) { const char *colon = strchr(http_header, ':'); if (!colon) return 0; return colon - http_header; } static bool is_malformed_http_header(const char *http_header) { const char *c; int name_len; // Disallow \r and \n c = strchr(http_header, '\r'); if (c) return true; c = strchr(http_header, '\n'); if (c) return true; // Require a header name followed by : name_len = http_header_name_length(http_header); if (name_len < 1) return true; return false; } static char *forbidden_custom_headers[] = { "User-Agent", "Host", "Accept", "Content-Type", "Transfer-Encoding", "Content-Length", }; static bool is_forbidden_custom_header(const char *custom_header) { unsigned long i; int name_len = http_header_name_length(custom_header); // Disallow headers that we set for (i = 0; i < ARRAY_SIZE(forbidden_custom_headers); i++) if (strncmp(forbidden_custom_headers[i], custom_header, name_len) == 0) return true; return false; } static int git_smart__set_custom_headers( git_transport *transport, const git_strarray *custom_headers) { transport_smart *t = (transport_smart *)transport; size_t i; if (t->custom_headers.count) git_strarray_free(&t->custom_headers); if (!custom_headers) return 0; for (i = 0; i < custom_headers->count; i++) { if (is_malformed_http_header(custom_headers->strings[i])) { giterr_set(GITERR_INVALID, "custom HTTP header '%s' is malformed", custom_headers->strings[i]); return -1; } if (is_forbidden_custom_header(custom_headers->strings[i])) { giterr_set(GITERR_INVALID, "custom HTTP header '%s' is already set by libgit2", custom_headers->strings[i]); return -1; } } return git_strarray_copy(&t->custom_headers, custom_headers); } int git_smart__update_heads(transport_smart *t, git_vector *symrefs) { size_t i; git_pkt *pkt; git_vector_clear(&t->heads); git_vector_foreach(&t->refs, i, pkt) { git_pkt_ref *ref = (git_pkt_ref *) pkt; if (pkt->type != GIT_PKT_REF) continue; if (symrefs) { git_refspec *spec; git_buf buf = GIT_BUF_INIT; size_t j; int error = 0; git_vector_foreach(symrefs, j, spec) { git_buf_clear(&buf); if (git_refspec_src_matches(spec, ref->head.name) && !(error = git_refspec_transform(&buf, spec, ref->head.name))) ref->head.symref_target = git_buf_detach(&buf); } git_buf_free(&buf); if (error < 0) return error; } if (git_vector_insert(&t->heads, &ref->head) < 0) return -1; } return 0; } static void free_symrefs(git_vector *symrefs) { git_refspec *spec; size_t i; git_vector_foreach(symrefs, i, spec) { git_refspec__free(spec); git__free(spec); } git_vector_free(symrefs); } static int git_smart__connect( git_transport *transport, const char *url, git_cred_acquire_cb cred_acquire_cb, void *cred_acquire_payload, int direction, int flags) { transport_smart *t = (transport_smart *)transport; git_smart_subtransport_stream *stream; int error; git_pkt *pkt; git_pkt_ref *first; git_vector symrefs; git_smart_service_t service; if (git_smart__reset_stream(t, true) < 0) return -1; t->url = git__strdup(url); GITERR_CHECK_ALLOC(t->url); t->direction = direction; t->flags = flags; t->cred_acquire_cb = cred_acquire_cb; t->cred_acquire_payload = cred_acquire_payload; if (GIT_DIRECTION_FETCH == t->direction) service = GIT_SERVICE_UPLOADPACK_LS; else if (GIT_DIRECTION_PUSH == t->direction) service = GIT_SERVICE_RECEIVEPACK_LS; else { giterr_set(GITERR_NET, "Invalid direction"); return -1; } if ((error = t->wrapped->action(&stream, t->wrapped, t->url, service)) < 0) return error; /* Save off the current stream (i.e. socket) that we are working with */ t->current_stream = stream; gitno_buffer_setup_callback(&t->buffer, t->buffer_data, sizeof(t->buffer_data), git_smart__recv_cb, t); /* 2 flushes for RPC; 1 for stateful */ if ((error = git_smart__store_refs(t, t->rpc ? 2 : 1)) < 0) return error; /* Strip the comment packet for RPC */ if (t->rpc) { pkt = (git_pkt *)git_vector_get(&t->refs, 0); if (!pkt || GIT_PKT_COMMENT != pkt->type) { giterr_set(GITERR_NET, "Invalid response"); return -1; } else { /* Remove the comment pkt from the list */ git_vector_remove(&t->refs, 0); git__free(pkt); } } /* We now have loaded the refs. */ t->have_refs = 1; first = (git_pkt_ref *)git_vector_get(&t->refs, 0); if ((error = git_vector_init(&symrefs, 1, NULL)) < 0) return error; /* Detect capabilities */ if (git_smart__detect_caps(first, &t->caps, &symrefs) < 0) return -1; /* If the only ref in the list is capabilities^{} with OID_ZERO, remove it */ if (1 == t->refs.length && !strcmp(first->head.name, "capabilities^{}") && git_oid_iszero(&first->head.oid)) { git_vector_clear(&t->refs); git_pkt_free((git_pkt *)first); } /* Keep a list of heads for _ls */ git_smart__update_heads(t, &symrefs); free_symrefs(&symrefs); if (t->rpc && git_smart__reset_stream(t, false) < 0) return -1; /* We're now logically connected. */ t->connected = 1; return 0; } static int git_smart__ls(const git_remote_head ***out, size_t *size, git_transport *transport) { transport_smart *t = (transport_smart *)transport; if (!t->have_refs) { giterr_set(GITERR_NET, "The transport has not yet loaded the refs"); return -1; } *out = (const git_remote_head **) t->heads.contents; *size = t->heads.length; return 0; } int git_smart__negotiation_step(git_transport *transport, void *data, size_t len) { transport_smart *t = (transport_smart *)transport; git_smart_subtransport_stream *stream; int error; if (t->rpc && git_smart__reset_stream(t, false) < 0) return -1; if (GIT_DIRECTION_FETCH != t->direction) { giterr_set(GITERR_NET, "This operation is only valid for fetch"); return -1; } if ((error = t->wrapped->action(&stream, t->wrapped, t->url, GIT_SERVICE_UPLOADPACK)) < 0) return error; /* If this is a stateful implementation, the stream we get back should be the same */ assert(t->rpc || t->current_stream == stream); /* Save off the current stream (i.e. socket) that we are working with */ t->current_stream = stream; if ((error = stream->write(stream, (const char *)data, len)) < 0) return error; gitno_buffer_setup_callback(&t->buffer, t->buffer_data, sizeof(t->buffer_data), git_smart__recv_cb, t); return 0; } int git_smart__get_push_stream(transport_smart *t, git_smart_subtransport_stream **stream) { int error; if (t->rpc && git_smart__reset_stream(t, false) < 0) return -1; if (GIT_DIRECTION_PUSH != t->direction) { giterr_set(GITERR_NET, "This operation is only valid for push"); return -1; } if ((error = t->wrapped->action(stream, t->wrapped, t->url, GIT_SERVICE_RECEIVEPACK)) < 0) return error; /* If this is a stateful implementation, the stream we get back should be the same */ assert(t->rpc || t->current_stream == *stream); /* Save off the current stream (i.e. socket) that we are working with */ t->current_stream = *stream; gitno_buffer_setup_callback(&t->buffer, t->buffer_data, sizeof(t->buffer_data), git_smart__recv_cb, t); return 0; } static void git_smart__cancel(git_transport *transport) { transport_smart *t = (transport_smart *)transport; git_atomic_set(&t->cancelled, 1); } static int git_smart__is_connected(git_transport *transport) { transport_smart *t = (transport_smart *)transport; return t->connected; } static int git_smart__read_flags(git_transport *transport, int *flags) { transport_smart *t = (transport_smart *)transport; *flags = t->flags; return 0; } static int git_smart__close(git_transport *transport) { transport_smart *t = (transport_smart *)transport; git_vector *common = &t->common; unsigned int i; git_pkt *p; int ret; git_smart_subtransport_stream *stream; const char flush[] = "0000"; /* * If we're still connected at this point and not using RPC, * we should say goodbye by sending a flush, or git-daemon * will complain that we disconnected unexpectedly. */ if (t->connected && !t->rpc && !t->wrapped->action(&stream, t->wrapped, t->url, GIT_SERVICE_UPLOADPACK)) { t->current_stream->write(t->current_stream, flush, 4); } ret = git_smart__reset_stream(t, true); git_vector_foreach(common, i, p) git_pkt_free(p); git_vector_free(common); if (t->url) { git__free(t->url); t->url = NULL; } t->connected = 0; return ret; } static void git_smart__free(git_transport *transport) { transport_smart *t = (transport_smart *)transport; git_vector *refs = &t->refs; unsigned int i; git_pkt *p; /* Make sure that the current stream is closed, if we have one. */ git_smart__close(transport); /* Free the subtransport */ t->wrapped->free(t->wrapped); git_vector_free(&t->heads); git_vector_foreach(refs, i, p) git_pkt_free(p); git_vector_free(refs); git_strarray_free(&t->custom_headers); git__free(t); } static int ref_name_cmp(const void *a, const void *b) { const git_pkt_ref *ref_a = a, *ref_b = b; return strcmp(ref_a->head.name, ref_b->head.name); } int git_transport_smart_certificate_check(git_transport *transport, git_cert *cert, int valid, const char *hostname) { transport_smart *t = (transport_smart *)transport; return t->certificate_check_cb(cert, valid, hostname, t->message_cb_payload); } int git_transport_smart_credentials(git_cred **out, git_transport *transport, const char *user, int methods) { transport_smart *t = (transport_smart *)transport; return t->cred_acquire_cb(out, t->url, user, methods, t->cred_acquire_payload); } int git_transport_smart(git_transport **out, git_remote *owner, void *param) { transport_smart *t; git_smart_subtransport_definition *definition = (git_smart_subtransport_definition *)param; if (!param) return -1; t = git__calloc(1, sizeof(transport_smart)); GITERR_CHECK_ALLOC(t); t->parent.version = GIT_TRANSPORT_VERSION; t->parent.set_callbacks = git_smart__set_callbacks; t->parent.set_custom_headers = git_smart__set_custom_headers; t->parent.connect = git_smart__connect; t->parent.close = git_smart__close; t->parent.free = git_smart__free; t->parent.negotiate_fetch = git_smart__negotiate_fetch; t->parent.download_pack = git_smart__download_pack; t->parent.push = git_smart__push; t->parent.ls = git_smart__ls; t->parent.is_connected = git_smart__is_connected; t->parent.read_flags = git_smart__read_flags; t->parent.cancel = git_smart__cancel; t->owner = owner; t->rpc = definition->rpc; if (git_vector_init(&t->refs, 16, ref_name_cmp) < 0) { git__free(t); return -1; } if (git_vector_init(&t->heads, 16, ref_name_cmp) < 0) { git__free(t); return -1; } if (definition->callback(&t->wrapped, &t->parent, definition->param) < 0) { git__free(t); return -1; } *out = (git_transport *) t; return 0; } deps/libgit2-sys-0.3.8/libgit2/src/transports/smart_pkt.c0000664000175000017500000003031612572105236020267 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "git2/types.h" #include "git2/errors.h" #include "git2/refs.h" #include "git2/revwalk.h" #include "smart.h" #include "util.h" #include "netops.h" #include "posix.h" #include "buffer.h" #include #define PKT_LEN_SIZE 4 static const char pkt_done_str[] = "0009done\n"; static const char pkt_flush_str[] = "0000"; static const char pkt_have_prefix[] = "0032have "; static const char pkt_want_prefix[] = "0032want "; static int flush_pkt(git_pkt **out) { git_pkt *pkt; pkt = git__malloc(sizeof(git_pkt)); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_FLUSH; *out = pkt; return 0; } /* the rest of the line will be useful for multi_ack and multi_ack_detailed */ static int ack_pkt(git_pkt **out, const char *line, size_t len) { git_pkt_ack *pkt; GIT_UNUSED(line); GIT_UNUSED(len); pkt = git__calloc(1, sizeof(git_pkt_ack)); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_ACK; line += 3; len -= 3; if (len >= GIT_OID_HEXSZ) { git_oid_fromstr(&pkt->oid, line + 1); line += GIT_OID_HEXSZ + 1; len -= GIT_OID_HEXSZ + 1; } if (len >= 7) { if (!git__prefixcmp(line + 1, "continue")) pkt->status = GIT_ACK_CONTINUE; if (!git__prefixcmp(line + 1, "common")) pkt->status = GIT_ACK_COMMON; if (!git__prefixcmp(line + 1, "ready")) pkt->status = GIT_ACK_READY; } *out = (git_pkt *) pkt; return 0; } static int nak_pkt(git_pkt **out) { git_pkt *pkt; pkt = git__malloc(sizeof(git_pkt)); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_NAK; *out = pkt; return 0; } static int pack_pkt(git_pkt **out) { git_pkt *pkt; pkt = git__malloc(sizeof(git_pkt)); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_PACK; *out = pkt; return 0; } static int comment_pkt(git_pkt **out, const char *line, size_t len) { git_pkt_comment *pkt; size_t alloclen; GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_comment), len); GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); pkt = git__malloc(alloclen); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_COMMENT; memcpy(pkt->comment, line, len); pkt->comment[len] = '\0'; *out = (git_pkt *) pkt; return 0; } static int err_pkt(git_pkt **out, const char *line, size_t len) { git_pkt_err *pkt; size_t alloclen; /* Remove "ERR " from the line */ line += 4; len -= 4; GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_progress), len); GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); pkt = git__malloc(alloclen); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_ERR; pkt->len = (int)len; memcpy(pkt->error, line, len); pkt->error[len] = '\0'; *out = (git_pkt *) pkt; return 0; } static int data_pkt(git_pkt **out, const char *line, size_t len) { git_pkt_data *pkt; size_t alloclen; line++; len--; GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_progress), len); pkt = git__malloc(alloclen); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_DATA; pkt->len = (int) len; memcpy(pkt->data, line, len); *out = (git_pkt *) pkt; return 0; } static int sideband_progress_pkt(git_pkt **out, const char *line, size_t len) { git_pkt_progress *pkt; size_t alloclen; line++; len--; GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_progress), len); pkt = git__malloc(alloclen); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_PROGRESS; pkt->len = (int) len; memcpy(pkt->data, line, len); *out = (git_pkt *) pkt; return 0; } static int sideband_error_pkt(git_pkt **out, const char *line, size_t len) { git_pkt_err *pkt; size_t alloc_len; line++; len--; GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(git_pkt_err), len); GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 1); pkt = git__malloc(alloc_len); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_ERR; pkt->len = (int)len; memcpy(pkt->error, line, len); pkt->error[len] = '\0'; *out = (git_pkt *)pkt; return 0; } /* * Parse an other-ref line. */ static int ref_pkt(git_pkt **out, const char *line, size_t len) { int error; git_pkt_ref *pkt; size_t alloclen; pkt = git__malloc(sizeof(git_pkt_ref)); GITERR_CHECK_ALLOC(pkt); memset(pkt, 0x0, sizeof(git_pkt_ref)); pkt->type = GIT_PKT_REF; if ((error = git_oid_fromstr(&pkt->head.oid, line)) < 0) goto error_out; /* Check for a bit of consistency */ if (line[GIT_OID_HEXSZ] != ' ') { giterr_set(GITERR_NET, "Error parsing pkt-line"); error = -1; goto error_out; } /* Jump from the name */ line += GIT_OID_HEXSZ + 1; len -= (GIT_OID_HEXSZ + 1); if (line[len - 1] == '\n') --len; GITERR_CHECK_ALLOC_ADD(&alloclen, len, 1); pkt->head.name = git__malloc(alloclen); GITERR_CHECK_ALLOC(pkt->head.name); memcpy(pkt->head.name, line, len); pkt->head.name[len] = '\0'; if (strlen(pkt->head.name) < len) { pkt->capabilities = strchr(pkt->head.name, '\0') + 1; } *out = (git_pkt *)pkt; return 0; error_out: git__free(pkt); return error; } static int ok_pkt(git_pkt **out, const char *line, size_t len) { git_pkt_ok *pkt; const char *ptr; size_t alloc_len; pkt = git__malloc(sizeof(*pkt)); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_OK; line += 3; /* skip "ok " */ if (!(ptr = strchr(line, '\n'))) { giterr_set(GITERR_NET, "Invalid packet line"); return -1; } len = ptr - line; GITERR_CHECK_ALLOC_ADD(&alloc_len, len, 1); pkt->ref = git__malloc(alloc_len); GITERR_CHECK_ALLOC(pkt->ref); memcpy(pkt->ref, line, len); pkt->ref[len] = '\0'; *out = (git_pkt *)pkt; return 0; } static int ng_pkt(git_pkt **out, const char *line, size_t len) { git_pkt_ng *pkt; const char *ptr; size_t alloclen; pkt = git__malloc(sizeof(*pkt)); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_NG; line += 3; /* skip "ng " */ if (!(ptr = strchr(line, ' '))) { giterr_set(GITERR_NET, "Invalid packet line"); return -1; } len = ptr - line; GITERR_CHECK_ALLOC_ADD(&alloclen, len, 1); pkt->ref = git__malloc(alloclen); GITERR_CHECK_ALLOC(pkt->ref); memcpy(pkt->ref, line, len); pkt->ref[len] = '\0'; line = ptr + 1; if (!(ptr = strchr(line, '\n'))) { giterr_set(GITERR_NET, "Invalid packet line"); return -1; } len = ptr - line; GITERR_CHECK_ALLOC_ADD(&alloclen, len, 1); pkt->msg = git__malloc(alloclen); GITERR_CHECK_ALLOC(pkt->msg); memcpy(pkt->msg, line, len); pkt->msg[len] = '\0'; *out = (git_pkt *)pkt; return 0; } static int unpack_pkt(git_pkt **out, const char *line, size_t len) { git_pkt_unpack *pkt; GIT_UNUSED(len); pkt = git__malloc(sizeof(*pkt)); GITERR_CHECK_ALLOC(pkt); pkt->type = GIT_PKT_UNPACK; if (!git__prefixcmp(line, "unpack ok")) pkt->unpack_ok = 1; else pkt->unpack_ok = 0; *out = (git_pkt *)pkt; return 0; } static int32_t parse_len(const char *line) { char num[PKT_LEN_SIZE + 1]; int i, k, error; int32_t len; const char *num_end; memcpy(num, line, PKT_LEN_SIZE); num[PKT_LEN_SIZE] = '\0'; for (i = 0; i < PKT_LEN_SIZE; ++i) { if (!isxdigit(num[i])) { /* Make sure there are no special characters before passing to error message */ for (k = 0; k < PKT_LEN_SIZE; ++k) { if(!isprint(num[k])) { num[k] = '.'; } } giterr_set(GITERR_NET, "invalid hex digit in length: '%s'", num); return -1; } } if ((error = git__strtol32(&len, num, &num_end, 16)) < 0) return error; return len; } /* * As per the documentation, the syntax is: * * pkt-line = data-pkt / flush-pkt * data-pkt = pkt-len pkt-payload * pkt-len = 4*(HEXDIG) * pkt-payload = (pkt-len -4)*(OCTET) * flush-pkt = "0000" * * Which means that the first four bytes are the length of the line, * in ASCII hexadecimal (including itself) */ int git_pkt_parse_line( git_pkt **head, const char *line, const char **out, size_t bufflen) { int ret; int32_t len; /* Not even enough for the length */ if (bufflen > 0 && bufflen < PKT_LEN_SIZE) return GIT_EBUFS; len = parse_len(line); if (len < 0) { /* * If we fail to parse the length, it might be because the * server is trying to send us the packfile already. */ if (bufflen >= 4 && !git__prefixcmp(line, "PACK")) { giterr_clear(); *out = line; return pack_pkt(head); } return (int)len; } /* * If we were given a buffer length, then make sure there is * enough in the buffer to satisfy this line */ if (bufflen > 0 && bufflen < (size_t)len) return GIT_EBUFS; line += PKT_LEN_SIZE; /* * TODO: How do we deal with empty lines? Try again? with the next * line? */ if (len == PKT_LEN_SIZE) { *out = line; return 0; } if (len == 0) { /* Flush pkt */ *out = line; return flush_pkt(head); } len -= PKT_LEN_SIZE; /* the encoded length includes its own size */ if (*line == GIT_SIDE_BAND_DATA) ret = data_pkt(head, line, len); else if (*line == GIT_SIDE_BAND_PROGRESS) ret = sideband_progress_pkt(head, line, len); else if (*line == GIT_SIDE_BAND_ERROR) ret = sideband_error_pkt(head, line, len); else if (!git__prefixcmp(line, "ACK")) ret = ack_pkt(head, line, len); else if (!git__prefixcmp(line, "NAK")) ret = nak_pkt(head); else if (!git__prefixcmp(line, "ERR ")) ret = err_pkt(head, line, len); else if (*line == '#') ret = comment_pkt(head, line, len); else if (!git__prefixcmp(line, "ok")) ret = ok_pkt(head, line, len); else if (!git__prefixcmp(line, "ng")) ret = ng_pkt(head, line, len); else if (!git__prefixcmp(line, "unpack")) ret = unpack_pkt(head, line, len); else ret = ref_pkt(head, line, len); *out = line + len; return ret; } void git_pkt_free(git_pkt *pkt) { if (pkt->type == GIT_PKT_REF) { git_pkt_ref *p = (git_pkt_ref *) pkt; git__free(p->head.name); git__free(p->head.symref_target); } if (pkt->type == GIT_PKT_OK) { git_pkt_ok *p = (git_pkt_ok *) pkt; git__free(p->ref); } if (pkt->type == GIT_PKT_NG) { git_pkt_ng *p = (git_pkt_ng *) pkt; git__free(p->ref); git__free(p->msg); } git__free(pkt); } int git_pkt_buffer_flush(git_buf *buf) { return git_buf_put(buf, pkt_flush_str, strlen(pkt_flush_str)); } static int buffer_want_with_caps(const git_remote_head *head, transport_smart_caps *caps, git_buf *buf) { git_buf str = GIT_BUF_INIT; char oid[GIT_OID_HEXSZ +1] = {0}; size_t len; /* Prefer multi_ack_detailed */ if (caps->multi_ack_detailed) git_buf_puts(&str, GIT_CAP_MULTI_ACK_DETAILED " "); else if (caps->multi_ack) git_buf_puts(&str, GIT_CAP_MULTI_ACK " "); /* Prefer side-band-64k if the server supports both */ if (caps->side_band_64k) git_buf_printf(&str, "%s ", GIT_CAP_SIDE_BAND_64K); else if (caps->side_band) git_buf_printf(&str, "%s ", GIT_CAP_SIDE_BAND); if (caps->include_tag) git_buf_puts(&str, GIT_CAP_INCLUDE_TAG " "); if (caps->thin_pack) git_buf_puts(&str, GIT_CAP_THIN_PACK " "); if (caps->ofs_delta) git_buf_puts(&str, GIT_CAP_OFS_DELTA " "); if (git_buf_oom(&str)) return -1; len = strlen("XXXXwant ") + GIT_OID_HEXSZ + 1 /* NUL */ + git_buf_len(&str) + 1 /* LF */; if (len > 0xffff) { giterr_set(GITERR_NET, "Tried to produce packet with invalid length %" PRIuZ, len); return -1; } git_buf_grow_by(buf, len); git_oid_fmt(oid, &head->oid); git_buf_printf(buf, "%04xwant %s %s\n", (unsigned int)len, oid, git_buf_cstr(&str)); git_buf_free(&str); return git_buf_oom(buf); } /* * All "want" packets have the same length and format, so what we do * is overwrite the OID each time. */ int git_pkt_buffer_wants( const git_remote_head * const *refs, size_t count, transport_smart_caps *caps, git_buf *buf) { size_t i = 0; const git_remote_head *head; if (caps->common) { for (; i < count; ++i) { head = refs[i]; if (!head->local) break; } if (buffer_want_with_caps(refs[i], caps, buf) < 0) return -1; i++; } for (; i < count; ++i) { char oid[GIT_OID_HEXSZ]; head = refs[i]; if (head->local) continue; git_oid_fmt(oid, &head->oid); git_buf_put(buf, pkt_want_prefix, strlen(pkt_want_prefix)); git_buf_put(buf, oid, GIT_OID_HEXSZ); git_buf_putc(buf, '\n'); if (git_buf_oom(buf)) return -1; } return git_pkt_buffer_flush(buf); } int git_pkt_buffer_have(git_oid *oid, git_buf *buf) { char oidhex[GIT_OID_HEXSZ + 1]; memset(oidhex, 0x0, sizeof(oidhex)); git_oid_fmt(oidhex, oid); return git_buf_printf(buf, "%s%s\n", pkt_have_prefix, oidhex); } int git_pkt_buffer_done(git_buf *buf) { return git_buf_puts(buf, pkt_done_str); } deps/libgit2-sys-0.3.8/libgit2/src/transports/ssh.c0000664000175000017500000004506312610310643017056 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifdef GIT_SSH #include #endif #include "git2.h" #include "buffer.h" #include "netops.h" #include "smart.h" #include "cred.h" #include "socket_stream.h" #ifdef GIT_SSH #define OWNING_SUBTRANSPORT(s) ((ssh_subtransport *)(s)->parent.subtransport) static const char prefix_ssh[] = "ssh://"; static const char cmd_uploadpack[] = "git-upload-pack"; static const char cmd_receivepack[] = "git-receive-pack"; typedef struct { git_smart_subtransport_stream parent; git_stream *io; LIBSSH2_SESSION *session; LIBSSH2_CHANNEL *channel; const char *cmd; char *url; unsigned sent_command : 1; } ssh_stream; typedef struct { git_smart_subtransport parent; transport_smart *owner; ssh_stream *current_stream; git_cred *cred; char *cmd_uploadpack; char *cmd_receivepack; } ssh_subtransport; static int list_auth_methods(int *out, LIBSSH2_SESSION *session, const char *username); static void ssh_error(LIBSSH2_SESSION *session, const char *errmsg) { char *ssherr; libssh2_session_last_error(session, &ssherr, NULL, 0); giterr_set(GITERR_SSH, "%s: %s", errmsg, ssherr); } /* * Create a git protocol request. * * For example: git-upload-pack '/libgit2/libgit2' */ static int gen_proto(git_buf *request, const char *cmd, const char *url) { char *repo; int len; if (!git__prefixcmp(url, prefix_ssh)) { url = url + strlen(prefix_ssh); repo = strchr(url, '/'); if (repo && repo[1] == '~') ++repo; } else { repo = strchr(url, ':'); if (repo) repo++; } if (!repo) { giterr_set(GITERR_NET, "Malformed git protocol URL"); return -1; } len = strlen(cmd) + 1 /* Space */ + 1 /* Quote */ + strlen(repo) + 1 /* Quote */ + 1; git_buf_grow(request, len); git_buf_printf(request, "%s '%s'", cmd, repo); git_buf_putc(request, '\0'); if (git_buf_oom(request)) return -1; return 0; } static int send_command(ssh_stream *s) { int error; git_buf request = GIT_BUF_INIT; error = gen_proto(&request, s->cmd, s->url); if (error < 0) goto cleanup; error = libssh2_channel_exec(s->channel, request.ptr); if (error < LIBSSH2_ERROR_NONE) { ssh_error(s->session, "SSH could not execute request"); goto cleanup; } s->sent_command = 1; cleanup: git_buf_free(&request); return error; } static int ssh_stream_read( git_smart_subtransport_stream *stream, char *buffer, size_t buf_size, size_t *bytes_read) { int rc; ssh_stream *s = (ssh_stream *)stream; *bytes_read = 0; if (!s->sent_command && send_command(s) < 0) return -1; if ((rc = libssh2_channel_read(s->channel, buffer, buf_size)) < LIBSSH2_ERROR_NONE) { ssh_error(s->session, "SSH could not read data"); return -1; } /* * If we can't get anything out of stdout, it's typically a * not-found error, so read from stderr and signal EOF on * stderr. */ if (rc == 0 && (rc = libssh2_channel_read_stderr(s->channel, buffer, buf_size)) > 0) { giterr_set(GITERR_SSH, "%*s", rc, buffer); return GIT_EEOF; } *bytes_read = rc; return 0; } static int ssh_stream_write( git_smart_subtransport_stream *stream, const char *buffer, size_t len) { ssh_stream *s = (ssh_stream *)stream; size_t off = 0; ssize_t ret = 0; if (!s->sent_command && send_command(s) < 0) return -1; do { ret = libssh2_channel_write(s->channel, buffer + off, len - off); if (ret < 0) break; off += ret; } while (off < len); if (ret < 0) { ssh_error(s->session, "SSH could not write data"); return -1; } return 0; } static void ssh_stream_free(git_smart_subtransport_stream *stream) { ssh_stream *s = (ssh_stream *)stream; ssh_subtransport *t; if (!stream) return; t = OWNING_SUBTRANSPORT(s); t->current_stream = NULL; if (s->channel) { libssh2_channel_close(s->channel); libssh2_channel_free(s->channel); s->channel = NULL; } if (s->session) { libssh2_session_free(s->session); s->session = NULL; } if (s->io) { git_stream_close(s->io); git_stream_free(s->io); s->io = NULL; } git__free(s->url); git__free(s); } static int ssh_stream_alloc( ssh_subtransport *t, const char *url, const char *cmd, git_smart_subtransport_stream **stream) { ssh_stream *s; assert(stream); s = git__calloc(sizeof(ssh_stream), 1); GITERR_CHECK_ALLOC(s); s->parent.subtransport = &t->parent; s->parent.read = ssh_stream_read; s->parent.write = ssh_stream_write; s->parent.free = ssh_stream_free; s->cmd = cmd; s->url = git__strdup(url); if (!s->url) { git__free(s); return -1; } *stream = &s->parent; return 0; } static int git_ssh_extract_url_parts( char **host, char **username, const char *url) { char *colon, *at; const char *start; colon = strchr(url, ':'); at = strchr(url, '@'); if (at) { start = at + 1; *username = git__substrdup(url, at - url); GITERR_CHECK_ALLOC(*username); } else { start = url; *username = NULL; } if (colon == NULL || (colon < start)) { giterr_set(GITERR_NET, "Malformed URL"); return -1; } *host = git__substrdup(start, colon - start); GITERR_CHECK_ALLOC(*host); return 0; } static int ssh_agent_auth(LIBSSH2_SESSION *session, git_cred_ssh_key *c) { int rc = LIBSSH2_ERROR_NONE; struct libssh2_agent_publickey *curr, *prev = NULL; LIBSSH2_AGENT *agent = libssh2_agent_init(session); if (agent == NULL) return -1; rc = libssh2_agent_connect(agent); if (rc != LIBSSH2_ERROR_NONE) goto shutdown; rc = libssh2_agent_list_identities(agent); if (rc != LIBSSH2_ERROR_NONE) goto shutdown; while (1) { rc = libssh2_agent_get_identity(agent, &curr, prev); if (rc < 0) goto shutdown; /* rc is set to 1 whenever the ssh agent ran out of keys to check. * Set the error code to authentication failure rather than erroring * out with an untranslatable error code. */ if (rc == 1) { rc = LIBSSH2_ERROR_AUTHENTICATION_FAILED; goto shutdown; } rc = libssh2_agent_userauth(agent, c->username, curr); if (rc == 0) break; prev = curr; } shutdown: if (rc != LIBSSH2_ERROR_NONE) ssh_error(session, "error authenticating"); libssh2_agent_disconnect(agent); libssh2_agent_free(agent); return rc; } static int _git_ssh_authenticate_session( LIBSSH2_SESSION* session, git_cred* cred) { int rc; do { giterr_clear(); switch (cred->credtype) { case GIT_CREDTYPE_USERPASS_PLAINTEXT: { git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred; rc = libssh2_userauth_password(session, c->username, c->password); break; } case GIT_CREDTYPE_SSH_KEY: { git_cred_ssh_key *c = (git_cred_ssh_key *)cred; if (c->privatekey) rc = libssh2_userauth_publickey_fromfile( session, c->username, c->publickey, c->privatekey, c->passphrase); else rc = ssh_agent_auth(session, c); break; } case GIT_CREDTYPE_SSH_CUSTOM: { git_cred_ssh_custom *c = (git_cred_ssh_custom *)cred; rc = libssh2_userauth_publickey( session, c->username, (const unsigned char *)c->publickey, c->publickey_len, c->sign_callback, &c->payload); break; } case GIT_CREDTYPE_SSH_INTERACTIVE: { void **abstract = libssh2_session_abstract(session); git_cred_ssh_interactive *c = (git_cred_ssh_interactive *)cred; /* ideally, we should be able to set this by calling * libssh2_session_init_ex() instead of libssh2_session_init(). * libssh2's API is inconsistent here i.e. libssh2_userauth_publickey() * allows you to pass the `abstract` as part of the call, whereas * libssh2_userauth_keyboard_interactive() does not! * * The only way to set the `abstract` pointer is by calling * libssh2_session_abstract(), which will replace the existing * pointer as is done below. This is safe for now (at time of writing), * but may not be valid in future. */ *abstract = c->payload; rc = libssh2_userauth_keyboard_interactive( session, c->username, c->prompt_callback); break; } #ifdef GIT_SSH_MEMORY_CREDENTIALS case GIT_CREDTYPE_SSH_MEMORY: { git_cred_ssh_key *c = (git_cred_ssh_key *)cred; assert(c->username); assert(c->privatekey); rc = libssh2_userauth_publickey_frommemory( session, c->username, strlen(c->username), c->publickey, c->publickey ? strlen(c->publickey) : 0, c->privatekey, strlen(c->privatekey), c->passphrase); break; } #endif default: rc = LIBSSH2_ERROR_AUTHENTICATION_FAILED; } } while (LIBSSH2_ERROR_EAGAIN == rc || LIBSSH2_ERROR_TIMEOUT == rc); if (rc == LIBSSH2_ERROR_PASSWORD_EXPIRED || rc == LIBSSH2_ERROR_AUTHENTICATION_FAILED) return GIT_EAUTH; if (rc != LIBSSH2_ERROR_NONE) { if (!giterr_last()) ssh_error(session, "Failed to authenticate SSH session"); return -1; } return 0; } static int request_creds(git_cred **out, ssh_subtransport *t, const char *user, int auth_methods) { int error, no_callback = 0; git_cred *cred = NULL; if (!t->owner->cred_acquire_cb) { no_callback = 1; } else { error = t->owner->cred_acquire_cb(&cred, t->owner->url, user, auth_methods, t->owner->cred_acquire_payload); if (error == GIT_PASSTHROUGH) no_callback = 1; else if (error < 0) return error; else if (!cred) { giterr_set(GITERR_SSH, "Callback failed to initialize SSH credentials"); return -1; } } if (no_callback) { giterr_set(GITERR_SSH, "authentication required but no callback set"); return -1; } if (!(cred->credtype & auth_methods)) { cred->free(cred); giterr_set(GITERR_SSH, "callback returned unsupported credentials type"); return -1; } *out = cred; return 0; } static int _git_ssh_session_create( LIBSSH2_SESSION** session, git_stream *io) { int rc = 0; LIBSSH2_SESSION* s; git_socket_stream *socket = (git_socket_stream *) io; assert(session); s = libssh2_session_init(); if (!s) { giterr_set(GITERR_NET, "Failed to initialize SSH session"); return -1; } do { rc = libssh2_session_startup(s, socket->s); } while (LIBSSH2_ERROR_EAGAIN == rc || LIBSSH2_ERROR_TIMEOUT == rc); if (rc != LIBSSH2_ERROR_NONE) { ssh_error(s, "Failed to start SSH session"); libssh2_session_free(s); return -1; } libssh2_session_set_blocking(s, 1); *session = s; return 0; } static int _git_ssh_setup_conn( ssh_subtransport *t, const char *url, const char *cmd, git_smart_subtransport_stream **stream) { char *host=NULL, *port=NULL, *path=NULL, *user=NULL, *pass=NULL; const char *default_port="22"; int auth_methods, error = 0; ssh_stream *s; git_cred *cred = NULL; LIBSSH2_SESSION* session=NULL; LIBSSH2_CHANNEL* channel=NULL; t->current_stream = NULL; *stream = NULL; if (ssh_stream_alloc(t, url, cmd, stream) < 0) return -1; s = (ssh_stream *)*stream; s->session = NULL; s->channel = NULL; if (!git__prefixcmp(url, prefix_ssh)) { if ((error = gitno_extract_url_parts(&host, &port, &path, &user, &pass, url, default_port)) < 0) goto done; } else { if ((error = git_ssh_extract_url_parts(&host, &user, url)) < 0) goto done; port = git__strdup(default_port); GITERR_CHECK_ALLOC(port); } if ((error = git_socket_stream_new(&s->io, host, port)) < 0 || (error = git_stream_connect(s->io)) < 0) goto done; if ((error = _git_ssh_session_create(&session, s->io)) < 0) goto done; if (t->owner->certificate_check_cb != NULL) { git_cert_hostkey cert = {{ 0 }}, *cert_ptr; const char *key; cert.parent.cert_type = GIT_CERT_HOSTKEY_LIBSSH2; key = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); if (key != NULL) { cert.type |= GIT_CERT_SSH_SHA1; memcpy(&cert.hash_sha1, key, 20); } key = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); if (key != NULL) { cert.type |= GIT_CERT_SSH_MD5; memcpy(&cert.hash_md5, key, 16); } if (cert.type == 0) { giterr_set(GITERR_SSH, "unable to get the host key"); error = -1; goto done; } /* We don't currently trust any hostkeys */ giterr_clear(); cert_ptr = &cert; error = t->owner->certificate_check_cb((git_cert *) cert_ptr, 0, host, t->owner->message_cb_payload); if (error < 0) { if (!giterr_last()) giterr_set(GITERR_NET, "user cancelled hostkey check"); goto done; } } /* we need the username to ask for auth methods */ if (!user) { if ((error = request_creds(&cred, t, NULL, GIT_CREDTYPE_USERNAME)) < 0) goto done; user = git__strdup(((git_cred_username *) cred)->username); cred->free(cred); cred = NULL; if (!user) goto done; } else if (user && pass) { if ((error = git_cred_userpass_plaintext_new(&cred, user, pass)) < 0) goto done; } if ((error = list_auth_methods(&auth_methods, session, user)) < 0) goto done; error = GIT_EAUTH; /* if we already have something to try */ if (cred && auth_methods & cred->credtype) error = _git_ssh_authenticate_session(session, cred); while (error == GIT_EAUTH) { if (cred) { cred->free(cred); cred = NULL; } if ((error = request_creds(&cred, t, user, auth_methods)) < 0) goto done; if (strcmp(user, git_cred__username(cred))) { giterr_set(GITERR_SSH, "username does not match previous request"); error = -1; goto done; } error = _git_ssh_authenticate_session(session, cred); } if (error < 0) goto done; channel = libssh2_channel_open_session(session); if (!channel) { error = -1; ssh_error(session, "Failed to open SSH channel"); goto done; } libssh2_channel_set_blocking(channel, 1); s->session = session; s->channel = channel; t->current_stream = s; done: if (error < 0) { ssh_stream_free(*stream); if (session) libssh2_session_free(session); } if (cred) cred->free(cred); git__free(host); git__free(port); git__free(path); git__free(user); git__free(pass); return error; } static int ssh_uploadpack_ls( ssh_subtransport *t, const char *url, git_smart_subtransport_stream **stream) { const char *cmd = t->cmd_uploadpack ? t->cmd_uploadpack : cmd_uploadpack; return _git_ssh_setup_conn(t, url, cmd, stream); } static int ssh_uploadpack( ssh_subtransport *t, const char *url, git_smart_subtransport_stream **stream) { GIT_UNUSED(url); if (t->current_stream) { *stream = &t->current_stream->parent; return 0; } giterr_set(GITERR_NET, "Must call UPLOADPACK_LS before UPLOADPACK"); return -1; } static int ssh_receivepack_ls( ssh_subtransport *t, const char *url, git_smart_subtransport_stream **stream) { const char *cmd = t->cmd_receivepack ? t->cmd_receivepack : cmd_receivepack; return _git_ssh_setup_conn(t, url, cmd, stream); } static int ssh_receivepack( ssh_subtransport *t, const char *url, git_smart_subtransport_stream **stream) { GIT_UNUSED(url); if (t->current_stream) { *stream = &t->current_stream->parent; return 0; } giterr_set(GITERR_NET, "Must call RECEIVEPACK_LS before RECEIVEPACK"); return -1; } static int _ssh_action( git_smart_subtransport_stream **stream, git_smart_subtransport *subtransport, const char *url, git_smart_service_t action) { ssh_subtransport *t = (ssh_subtransport *) subtransport; switch (action) { case GIT_SERVICE_UPLOADPACK_LS: return ssh_uploadpack_ls(t, url, stream); case GIT_SERVICE_UPLOADPACK: return ssh_uploadpack(t, url, stream); case GIT_SERVICE_RECEIVEPACK_LS: return ssh_receivepack_ls(t, url, stream); case GIT_SERVICE_RECEIVEPACK: return ssh_receivepack(t, url, stream); } *stream = NULL; return -1; } static int _ssh_close(git_smart_subtransport *subtransport) { ssh_subtransport *t = (ssh_subtransport *) subtransport; assert(!t->current_stream); GIT_UNUSED(t); return 0; } static void _ssh_free(git_smart_subtransport *subtransport) { ssh_subtransport *t = (ssh_subtransport *) subtransport; assert(!t->current_stream); git__free(t->cmd_uploadpack); git__free(t->cmd_receivepack); git__free(t); } #define SSH_AUTH_PUBLICKEY "publickey" #define SSH_AUTH_PASSWORD "password" #define SSH_AUTH_KEYBOARD_INTERACTIVE "keyboard-interactive" static int list_auth_methods(int *out, LIBSSH2_SESSION *session, const char *username) { const char *list, *ptr; *out = 0; list = libssh2_userauth_list(session, username, strlen(username)); /* either error, or the remote accepts NONE auth, which is bizarre, let's punt */ if (list == NULL && !libssh2_userauth_authenticated(session)) { ssh_error(session, "Failed to retrieve list of SSH authentication methods"); return -1; } ptr = list; while (ptr) { if (*ptr == ',') ptr++; if (!git__prefixcmp(ptr, SSH_AUTH_PUBLICKEY)) { *out |= GIT_CREDTYPE_SSH_KEY; *out |= GIT_CREDTYPE_SSH_CUSTOM; #ifdef GIT_SSH_MEMORY_CREDENTIALS *out |= GIT_CREDTYPE_SSH_MEMORY; #endif ptr += strlen(SSH_AUTH_PUBLICKEY); continue; } if (!git__prefixcmp(ptr, SSH_AUTH_PASSWORD)) { *out |= GIT_CREDTYPE_USERPASS_PLAINTEXT; ptr += strlen(SSH_AUTH_PASSWORD); continue; } if (!git__prefixcmp(ptr, SSH_AUTH_KEYBOARD_INTERACTIVE)) { *out |= GIT_CREDTYPE_SSH_INTERACTIVE; ptr += strlen(SSH_AUTH_KEYBOARD_INTERACTIVE); continue; } /* Skipt it if we don't know it */ ptr = strchr(ptr, ','); } return 0; } #endif int git_smart_subtransport_ssh( git_smart_subtransport **out, git_transport *owner, void *param) { #ifdef GIT_SSH ssh_subtransport *t; assert(out); GIT_UNUSED(param); t = git__calloc(sizeof(ssh_subtransport), 1); GITERR_CHECK_ALLOC(t); t->owner = (transport_smart *)owner; t->parent.action = _ssh_action; t->parent.close = _ssh_close; t->parent.free = _ssh_free; *out = (git_smart_subtransport *) t; return 0; #else GIT_UNUSED(owner); GIT_UNUSED(param); assert(out); *out = NULL; giterr_set(GITERR_INVALID, "Cannot create SSH transport. Library was built without SSH support"); return -1; #endif } int git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *payload) { #ifdef GIT_SSH git_strarray *paths = (git_strarray *) payload; git_transport *transport; transport_smart *smart; ssh_subtransport *t; int error; git_smart_subtransport_definition ssh_definition = { git_smart_subtransport_ssh, 0, /* no RPC */ NULL, }; if (paths->count != 2) { giterr_set(GITERR_SSH, "invalid ssh paths, must be two strings"); return GIT_EINVALIDSPEC; } if ((error = git_transport_smart(&transport, owner, &ssh_definition)) < 0) return error; smart = (transport_smart *) transport; t = (ssh_subtransport *) smart->wrapped; t->cmd_uploadpack = git__strdup(paths->strings[0]); GITERR_CHECK_ALLOC(t->cmd_uploadpack); t->cmd_receivepack = git__strdup(paths->strings[1]); GITERR_CHECK_ALLOC(t->cmd_receivepack); *out = transport; return 0; #else GIT_UNUSED(owner); GIT_UNUSED(payload); assert(out); *out = NULL; giterr_set(GITERR_INVALID, "Cannot create SSH transport. Library was built without SSH support"); return -1; #endif } deps/libgit2-sys-0.3.8/libgit2/src/transports/auth_negotiate.h0000664000175000017500000000104712426525445021275 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_auth_negotiate_h__ #define INCLUDE_auth_negotiate_h__ #include "git2.h" #include "auth.h" #ifdef GIT_GSSAPI extern int git_http_auth_negotiate( git_http_auth_context **out, const gitno_connection_data *connection_data); #else #define git_http_auth_negotiate git_http_auth_dummy #endif /* GIT_GSSAPI */ #endif deps/libgit2-sys-0.3.8/libgit2/src/transports/auth.h0000664000175000017500000000307412426525445017240 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_http_auth_h__ #define INCLUDE_http_auth_h__ #include "git2.h" #include "netops.h" typedef enum { GIT_AUTHTYPE_BASIC = 1, GIT_AUTHTYPE_NEGOTIATE = 2, } git_http_authtype_t; typedef struct git_http_auth_context git_http_auth_context; struct git_http_auth_context { /** Type of scheme */ git_http_authtype_t type; /** Supported credentials */ git_credtype_t credtypes; /** Sets the challenge on the authentication context */ int (*set_challenge)(git_http_auth_context *ctx, const char *challenge); /** Gets the next authentication token from the context */ int (*next_token)(git_buf *out, git_http_auth_context *ctx, git_cred *cred); /** Frees the authentication context */ void (*free)(git_http_auth_context *ctx); }; typedef struct { /** Type of scheme */ git_http_authtype_t type; /** Name of the scheme (as used in the Authorization header) */ const char *name; /** Credential types this scheme supports */ git_credtype_t credtypes; /** Function to initialize an authentication context */ int (*init_context)( git_http_auth_context **out, const gitno_connection_data *connection_data); } git_http_auth_scheme; int git_http_auth_dummy( git_http_auth_context **out, const gitno_connection_data *connection_data); int git_http_auth_basic( git_http_auth_context **out, const gitno_connection_data *connection_data); #endif deps/libgit2-sys-0.3.8/libgit2/src/transports/auth_negotiate.c0000664000175000017500000001474112426525445021275 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifdef GIT_GSSAPI #include "git2.h" #include "common.h" #include "buffer.h" #include "auth.h" #include #include static gss_OID_desc negotiate_oid_spnego = { 6, (void *) "\x2b\x06\x01\x05\x05\x02" }; static gss_OID_desc negotiate_oid_krb5 = { 9, (void *) "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02" }; static gss_OID negotiate_oids[] = { &negotiate_oid_spnego, &negotiate_oid_krb5, NULL }; typedef struct { git_http_auth_context parent; unsigned configured : 1, complete : 1; git_buf target; char *challenge; gss_ctx_id_t gss_context; gss_OID oid; } http_auth_negotiate_context; static void negotiate_err_set( OM_uint32 status_major, OM_uint32 status_minor, const char *message) { gss_buffer_desc buffer = GSS_C_EMPTY_BUFFER; OM_uint32 status_display, context = 0; if (gss_display_status(&status_display, status_major, GSS_C_GSS_CODE, GSS_C_NO_OID, &context, &buffer) == GSS_S_COMPLETE) { giterr_set(GITERR_NET, "%s: %.*s (%d.%d)", message, (int)buffer.length, (const char *)buffer.value, status_major, status_minor); gss_release_buffer(&status_minor, &buffer); } else { giterr_set(GITERR_NET, "%s: unknown negotiate error (%d.%d)", message, status_major, status_minor); } } static int negotiate_set_challenge( git_http_auth_context *c, const char *challenge) { http_auth_negotiate_context *ctx = (http_auth_negotiate_context *)c; assert(ctx && ctx->configured && challenge); git__free(ctx->challenge); ctx->challenge = git__strdup(challenge); GITERR_CHECK_ALLOC(ctx->challenge); return 0; } static int negotiate_next_token( git_buf *buf, git_http_auth_context *c, git_cred *cred) { http_auth_negotiate_context *ctx = (http_auth_negotiate_context *)c; OM_uint32 status_major, status_minor; gss_buffer_desc target_buffer = GSS_C_EMPTY_BUFFER, input_token = GSS_C_EMPTY_BUFFER, output_token = GSS_C_EMPTY_BUFFER; gss_buffer_t input_token_ptr = GSS_C_NO_BUFFER; git_buf input_buf = GIT_BUF_INIT; gss_name_t server = NULL; gss_OID mech; size_t challenge_len; int error = 0; assert(buf && ctx && ctx->configured && cred && cred->credtype == GIT_CREDTYPE_DEFAULT); if (ctx->complete) return 0; target_buffer.value = (void *)ctx->target.ptr; target_buffer.length = ctx->target.size; status_major = gss_import_name(&status_minor, &target_buffer, GSS_C_NT_HOSTBASED_SERVICE, &server); if (GSS_ERROR(status_major)) { negotiate_err_set(status_major, status_minor, "Could not parse principal"); error = -1; goto done; } challenge_len = ctx->challenge ? strlen(ctx->challenge) : 0; if (challenge_len < 9) { giterr_set(GITERR_NET, "No negotiate challenge sent from server"); error = -1; goto done; } else if (challenge_len > 9) { if (git_buf_decode_base64(&input_buf, ctx->challenge + 10, challenge_len - 10) < 0) { giterr_set(GITERR_NET, "Invalid negotiate challenge from server"); error = -1; goto done; } input_token.value = input_buf.ptr; input_token.length = input_buf.size; input_token_ptr = &input_token; } else if (ctx->gss_context != GSS_C_NO_CONTEXT) { giterr_set(GITERR_NET, "Could not restart authentication"); error = -1; goto done; } mech = &negotiate_oid_spnego; if (GSS_ERROR(status_major = gss_init_sec_context( &status_minor, GSS_C_NO_CREDENTIAL, &ctx->gss_context, server, mech, GSS_C_DELEG_FLAG | GSS_C_MUTUAL_FLAG, GSS_C_INDEFINITE, GSS_C_NO_CHANNEL_BINDINGS, input_token_ptr, NULL, &output_token, NULL, NULL))) { negotiate_err_set(status_major, status_minor, "Negotiate failure"); error = -1; goto done; } /* This message merely told us auth was complete; we do not respond. */ if (status_major == GSS_S_COMPLETE) { ctx->complete = 1; goto done; } git_buf_puts(buf, "Authorization: Negotiate "); git_buf_encode_base64(buf, output_token.value, output_token.length); git_buf_puts(buf, "\r\n"); if (git_buf_oom(buf)) error = -1; done: gss_release_name(&status_minor, &server); gss_release_buffer(&status_minor, (gss_buffer_t) &output_token); git_buf_free(&input_buf); return error; } static void negotiate_context_free(git_http_auth_context *c) { http_auth_negotiate_context *ctx = (http_auth_negotiate_context *)c; OM_uint32 status_minor; if (ctx->gss_context != GSS_C_NO_CONTEXT) { gss_delete_sec_context( &status_minor, &ctx->gss_context, GSS_C_NO_BUFFER); ctx->gss_context = GSS_C_NO_CONTEXT; } git_buf_free(&ctx->target); git__free(ctx->challenge); ctx->configured = 0; ctx->complete = 0; ctx->oid = NULL; git__free(ctx); } static int negotiate_init_context( http_auth_negotiate_context *ctx, const gitno_connection_data *connection_data) { OM_uint32 status_major, status_minor; gss_OID item, *oid; gss_OID_set mechanism_list; size_t i; /* Query supported mechanisms looking for SPNEGO) */ if (GSS_ERROR(status_major = gss_indicate_mechs(&status_minor, &mechanism_list))) { negotiate_err_set(status_major, status_minor, "could not query mechanisms"); return -1; } if (mechanism_list) { for (oid = negotiate_oids; *oid; oid++) { for (i = 0; i < mechanism_list->count; i++) { item = &mechanism_list->elements[i]; if (item->length == (*oid)->length && memcmp(item->elements, (*oid)->elements, item->length) == 0) { ctx->oid = *oid; break; } } if (ctx->oid) break; } } gss_release_oid_set(&status_minor, &mechanism_list); if (!ctx->oid) { giterr_set(GITERR_NET, "Negotiate authentication is not supported"); return -1; } git_buf_puts(&ctx->target, "HTTP@"); git_buf_puts(&ctx->target, connection_data->host); if (git_buf_oom(&ctx->target)) return -1; ctx->gss_context = GSS_C_NO_CONTEXT; ctx->configured = 1; return 0; } int git_http_auth_negotiate( git_http_auth_context **out, const gitno_connection_data *connection_data) { http_auth_negotiate_context *ctx; *out = NULL; ctx = git__calloc(1, sizeof(http_auth_negotiate_context)); GITERR_CHECK_ALLOC(ctx); if (negotiate_init_context(ctx, connection_data) < 0) { git__free(ctx); return -1; } ctx->parent.type = GIT_AUTHTYPE_NEGOTIATE; ctx->parent.credtypes = GIT_CREDTYPE_DEFAULT; ctx->parent.set_challenge = negotiate_set_challenge; ctx->parent.next_token = negotiate_next_token; ctx->parent.free = negotiate_context_free; *out = (git_http_auth_context *)ctx; return 0; } #endif /* GIT_GSSAPI */ deps/libgit2-sys-0.3.8/libgit2/src/transports/smart.h0000664000175000017500000001066312610310643017412 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2.h" #include "vector.h" #include "netops.h" #include "buffer.h" #include "push.h" #include "git2/sys/transport.h" #define GIT_SIDE_BAND_DATA 1 #define GIT_SIDE_BAND_PROGRESS 2 #define GIT_SIDE_BAND_ERROR 3 #define GIT_CAP_OFS_DELTA "ofs-delta" #define GIT_CAP_MULTI_ACK "multi_ack" #define GIT_CAP_MULTI_ACK_DETAILED "multi_ack_detailed" #define GIT_CAP_SIDE_BAND "side-band" #define GIT_CAP_SIDE_BAND_64K "side-band-64k" #define GIT_CAP_INCLUDE_TAG "include-tag" #define GIT_CAP_DELETE_REFS "delete-refs" #define GIT_CAP_REPORT_STATUS "report-status" #define GIT_CAP_THIN_PACK "thin-pack" #define GIT_CAP_SYMREF "symref" enum git_pkt_type { GIT_PKT_CMD, GIT_PKT_FLUSH, GIT_PKT_REF, GIT_PKT_HAVE, GIT_PKT_ACK, GIT_PKT_NAK, GIT_PKT_PACK, GIT_PKT_COMMENT, GIT_PKT_ERR, GIT_PKT_DATA, GIT_PKT_PROGRESS, GIT_PKT_OK, GIT_PKT_NG, GIT_PKT_UNPACK, }; /* Used for multi_ack and mutli_ack_detailed */ enum git_ack_status { GIT_ACK_NONE, GIT_ACK_CONTINUE, GIT_ACK_COMMON, GIT_ACK_READY }; /* This would be a flush pkt */ typedef struct { enum git_pkt_type type; } git_pkt; struct git_pkt_cmd { enum git_pkt_type type; char *cmd; char *path; char *host; }; /* This is a pkt-line with some info in it */ typedef struct { enum git_pkt_type type; git_remote_head head; char *capabilities; } git_pkt_ref; /* Useful later */ typedef struct { enum git_pkt_type type; git_oid oid; enum git_ack_status status; } git_pkt_ack; typedef struct { enum git_pkt_type type; char comment[GIT_FLEX_ARRAY]; } git_pkt_comment; typedef struct { enum git_pkt_type type; int len; char data[GIT_FLEX_ARRAY]; } git_pkt_data; typedef git_pkt_data git_pkt_progress; typedef struct { enum git_pkt_type type; int len; char error[GIT_FLEX_ARRAY]; } git_pkt_err; typedef struct { enum git_pkt_type type; char *ref; } git_pkt_ok; typedef struct { enum git_pkt_type type; char *ref; char *msg; } git_pkt_ng; typedef struct { enum git_pkt_type type; int unpack_ok; } git_pkt_unpack; typedef struct transport_smart_caps { int common:1, ofs_delta:1, multi_ack: 1, multi_ack_detailed: 1, side_band:1, side_band_64k:1, include_tag:1, delete_refs:1, report_status:1, thin_pack:1; } transport_smart_caps; typedef int (*packetsize_cb)(size_t received, void *payload); typedef struct { git_transport parent; git_remote *owner; char *url; git_cred_acquire_cb cred_acquire_cb; void *cred_acquire_payload; int direction; int flags; git_transport_message_cb progress_cb; git_transport_message_cb error_cb; git_transport_certificate_check_cb certificate_check_cb; void *message_cb_payload; git_strarray custom_headers; git_smart_subtransport *wrapped; git_smart_subtransport_stream *current_stream; transport_smart_caps caps; git_vector refs; git_vector heads; git_vector common; git_atomic cancelled; packetsize_cb packetsize_cb; void *packetsize_payload; unsigned rpc : 1, have_refs : 1, connected : 1; gitno_buffer buffer; char buffer_data[65536]; } transport_smart; /* smart_protocol.c */ int git_smart__store_refs(transport_smart *t, int flushes); int git_smart__detect_caps(git_pkt_ref *pkt, transport_smart_caps *caps, git_vector *symrefs); int git_smart__push(git_transport *transport, git_push *push, const git_remote_callbacks *cbs); int git_smart__negotiate_fetch( git_transport *transport, git_repository *repo, const git_remote_head * const *refs, size_t count); int git_smart__download_pack( git_transport *transport, git_repository *repo, git_transfer_progress *stats, git_transfer_progress_cb progress_cb, void *progress_payload); /* smart.c */ int git_smart__negotiation_step(git_transport *transport, void *data, size_t len); int git_smart__get_push_stream(transport_smart *t, git_smart_subtransport_stream **out); int git_smart__update_heads(transport_smart *t, git_vector *symrefs); /* smart_pkt.c */ int git_pkt_parse_line(git_pkt **head, const char *line, const char **out, size_t len); int git_pkt_buffer_flush(git_buf *buf); int git_pkt_send_flush(GIT_SOCKET s); int git_pkt_buffer_done(git_buf *buf); int git_pkt_buffer_wants(const git_remote_head * const *refs, size_t count, transport_smart_caps *caps, git_buf *buf); int git_pkt_buffer_have(git_oid *oid, git_buf *buf); void git_pkt_free(git_pkt *pkt); deps/libgit2-sys-0.3.8/libgit2/src/transports/winhttp.c0000664000175000017500000010354612610310643017757 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifdef GIT_WINHTTP #include "git2.h" #include "git2/transport.h" #include "buffer.h" #include "posix.h" #include "netops.h" #include "smart.h" #include "remote.h" #include "repository.h" #include #include /* For IInternetSecurityManager zone check */ #include #include #define WIDEN2(s) L ## s #define WIDEN(s) WIDEN2(s) #define MAX_CONTENT_TYPE_LEN 100 #define WINHTTP_OPTION_PEERDIST_EXTENSION_STATE 109 #define CACHED_POST_BODY_BUF_SIZE 4096 #define UUID_LENGTH_CCH 32 #define TIMEOUT_INFINITE -1 #define DEFAULT_CONNECT_TIMEOUT 60000 #ifndef WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH #define WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH 0 #endif static const char *prefix_https = "https://"; static const char *upload_pack_service = "upload-pack"; static const char *upload_pack_ls_service_url = "/info/refs?service=git-upload-pack"; static const char *upload_pack_service_url = "/git-upload-pack"; static const char *receive_pack_service = "receive-pack"; static const char *receive_pack_ls_service_url = "/info/refs?service=git-receive-pack"; static const char *receive_pack_service_url = "/git-receive-pack"; static const wchar_t *get_verb = L"GET"; static const wchar_t *post_verb = L"POST"; static const wchar_t *pragma_nocache = L"Pragma: no-cache"; static const wchar_t *transfer_encoding = L"Transfer-Encoding: chunked"; static const int no_check_cert_flags = SECURITY_FLAG_IGNORE_CERT_CN_INVALID | SECURITY_FLAG_IGNORE_CERT_DATE_INVALID | SECURITY_FLAG_IGNORE_UNKNOWN_CA; #if defined(__MINGW32__) const CLSID CLSID_InternetSecurityManager = { 0x7B8A2D94, 0x0AC9, 0x11D1, { 0x89, 0x6C, 0x00, 0xC0, 0x4F, 0xB6, 0xBF, 0xC4 } }; const IID IID_IInternetSecurityManager = { 0x79EAC9EE, 0xBAF9, 0x11CE, { 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B } }; #endif #define OWNING_SUBTRANSPORT(s) ((winhttp_subtransport *)(s)->parent.subtransport) typedef enum { GIT_WINHTTP_AUTH_BASIC = 1, GIT_WINHTTP_AUTH_NEGOTIATE = 2, } winhttp_authmechanism_t; typedef struct { git_smart_subtransport_stream parent; const char *service; const char *service_url; const wchar_t *verb; HINTERNET request; wchar_t *request_uri; char *chunk_buffer; unsigned chunk_buffer_len; HANDLE post_body; DWORD post_body_len; unsigned sent_request : 1, received_response : 1, chunked : 1; } winhttp_stream; typedef struct { git_smart_subtransport parent; transport_smart *owner; gitno_connection_data connection_data; git_cred *cred; git_cred *url_cred; int auth_mechanism; HINTERNET session; HINTERNET connection; } winhttp_subtransport; static int apply_basic_credential(HINTERNET request, git_cred *cred) { git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred; git_buf buf = GIT_BUF_INIT, raw = GIT_BUF_INIT; wchar_t *wide = NULL; int error = -1, wide_len; git_buf_printf(&raw, "%s:%s", c->username, c->password); if (git_buf_oom(&raw) || git_buf_puts(&buf, "Authorization: Basic ") < 0 || git_buf_encode_base64(&buf, git_buf_cstr(&raw), raw.size) < 0) goto on_error; if ((wide_len = git__utf8_to_16_alloc(&wide, git_buf_cstr(&buf))) < 0) { giterr_set(GITERR_OS, "Failed to convert string to wide form"); goto on_error; } if (!WinHttpAddRequestHeaders(request, wide, (ULONG) -1L, WINHTTP_ADDREQ_FLAG_ADD)) { giterr_set(GITERR_OS, "Failed to add a header to the request"); goto on_error; } error = 0; on_error: /* We were dealing with plaintext passwords, so clean up after ourselves a bit. */ if (wide) memset(wide, 0x0, wide_len * sizeof(wchar_t)); if (buf.size) memset(buf.ptr, 0x0, buf.size); if (raw.size) memset(raw.ptr, 0x0, raw.size); git__free(wide); git_buf_free(&buf); git_buf_free(&raw); return error; } static int apply_default_credentials(HINTERNET request) { /* Either the caller explicitly requested that default credentials be passed, * or our fallback credential callback was invoked and checked that the target * URI was in the appropriate Internet Explorer security zone. By setting this * flag, we guarantee that the credentials are delivered by WinHTTP. The default * is "medium" which applies to the intranet and sounds like it would correspond * to Internet Explorer security zones, but in fact does not. */ DWORD data = WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW; if (!WinHttpSetOption(request, WINHTTP_OPTION_AUTOLOGON_POLICY, &data, sizeof(DWORD))) return -1; return 0; } static int fallback_cred_acquire_cb( git_cred **cred, const char *url, const char *username_from_url, unsigned int allowed_types, void *payload) { int error = 1; GIT_UNUSED(username_from_url); GIT_UNUSED(payload); /* If the target URI supports integrated Windows authentication * as an authentication mechanism */ if (GIT_CREDTYPE_DEFAULT & allowed_types) { wchar_t *wide_url; /* Convert URL to wide characters */ if (git__utf8_to_16_alloc(&wide_url, url) < 0) { giterr_set(GITERR_OS, "Failed to convert string to wide form"); return -1; } if (SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED))) { IInternetSecurityManager* pISM; /* And if the target URI is in the My Computer, Intranet, or Trusted zones */ if (SUCCEEDED(CoCreateInstance(&CLSID_InternetSecurityManager, NULL, CLSCTX_ALL, &IID_IInternetSecurityManager, (void **)&pISM))) { DWORD dwZone; if (SUCCEEDED(pISM->lpVtbl->MapUrlToZone(pISM, wide_url, &dwZone, 0)) && (URLZONE_LOCAL_MACHINE == dwZone || URLZONE_INTRANET == dwZone || URLZONE_TRUSTED == dwZone)) { git_cred *existing = *cred; if (existing) existing->free(existing); /* Then use default Windows credentials to authenticate this request */ error = git_cred_default_new(cred); } pISM->lpVtbl->Release(pISM); } CoUninitialize(); } git__free(wide_url); } return error; } static int certificate_check(winhttp_stream *s, int valid) { int error; winhttp_subtransport *t = OWNING_SUBTRANSPORT(s); PCERT_CONTEXT cert_ctx; DWORD cert_ctx_size = sizeof(cert_ctx); git_cert_x509 cert; /* If there is no override, we should fail if WinHTTP doesn't think it's fine */ if (t->owner->certificate_check_cb == NULL && !valid) return GIT_ECERTIFICATE; if (t->owner->certificate_check_cb == NULL || !t->connection_data.use_ssl) return 0; if (!WinHttpQueryOption(s->request, WINHTTP_OPTION_SERVER_CERT_CONTEXT, &cert_ctx, &cert_ctx_size)) { giterr_set(GITERR_OS, "failed to get server certificate"); return -1; } giterr_clear(); cert.parent.cert_type = GIT_CERT_X509; cert.data = cert_ctx->pbCertEncoded; cert.len = cert_ctx->cbCertEncoded; error = t->owner->certificate_check_cb((git_cert *) &cert, valid, t->connection_data.host, t->owner->cred_acquire_payload); CertFreeCertificateContext(cert_ctx); if (error < 0 && !giterr_last()) giterr_set(GITERR_NET, "user cancelled certificate check"); return error; } static void winhttp_stream_close(winhttp_stream *s) { if (s->chunk_buffer) { git__free(s->chunk_buffer); s->chunk_buffer = NULL; } if (s->post_body) { CloseHandle(s->post_body); s->post_body = NULL; } if (s->request_uri) { git__free(s->request_uri); s->request_uri = NULL; } if (s->request) { WinHttpCloseHandle(s->request); s->request = NULL; } s->sent_request = 0; } static int winhttp_stream_connect(winhttp_stream *s) { winhttp_subtransport *t = OWNING_SUBTRANSPORT(s); git_buf buf = GIT_BUF_INIT; char *proxy_url = NULL; wchar_t ct[MAX_CONTENT_TYPE_LEN]; LPCWSTR types[] = { L"*/*", NULL }; BOOL peerdist = FALSE; int error = -1; unsigned long disable_redirects = WINHTTP_DISABLE_REDIRECTS; int default_timeout = TIMEOUT_INFINITE; int default_connect_timeout = DEFAULT_CONNECT_TIMEOUT; int i; /* Prepare URL */ git_buf_printf(&buf, "%s%s", t->connection_data.path, s->service_url); if (git_buf_oom(&buf)) return -1; /* Convert URL to wide characters */ if (git__utf8_to_16_alloc(&s->request_uri, git_buf_cstr(&buf)) < 0) { giterr_set(GITERR_OS, "Failed to convert string to wide form"); goto on_error; } /* Establish request */ s->request = WinHttpOpenRequest( t->connection, s->verb, s->request_uri, NULL, WINHTTP_NO_REFERER, types, t->connection_data.use_ssl ? WINHTTP_FLAG_SECURE : 0); if (!s->request) { giterr_set(GITERR_OS, "Failed to open request"); goto on_error; } if (!WinHttpSetTimeouts(s->request, default_timeout, default_connect_timeout, default_timeout, default_timeout)) { giterr_set(GITERR_OS, "Failed to set timeouts for WinHTTP"); goto on_error; } /* Set proxy if necessary */ if (git_remote__get_http_proxy(t->owner->owner, !!t->connection_data.use_ssl, &proxy_url) < 0) goto on_error; if (proxy_url) { WINHTTP_PROXY_INFO proxy_info; wchar_t *proxy_wide; /* Convert URL to wide characters */ int proxy_wide_len = git__utf8_to_16_alloc(&proxy_wide, proxy_url); if (proxy_wide_len < 0) { giterr_set(GITERR_OS, "Failed to convert string to wide form"); goto on_error; } /* Strip any trailing forward slash on the proxy URL; * WinHTTP doesn't like it if one is present */ if (proxy_wide_len > 1 && L'/' == proxy_wide[proxy_wide_len - 2]) proxy_wide[proxy_wide_len - 2] = L'\0'; proxy_info.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY; proxy_info.lpszProxy = proxy_wide; proxy_info.lpszProxyBypass = NULL; if (!WinHttpSetOption(s->request, WINHTTP_OPTION_PROXY, &proxy_info, sizeof(WINHTTP_PROXY_INFO))) { giterr_set(GITERR_OS, "Failed to set proxy"); git__free(proxy_wide); goto on_error; } git__free(proxy_wide); } /* Disable WinHTTP redirects so we can handle them manually. Why, you ask? * http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/b2ff8879-ab9f-4218-8f09-16d25dff87ae */ if (!WinHttpSetOption(s->request, WINHTTP_OPTION_DISABLE_FEATURE, &disable_redirects, sizeof(disable_redirects))) { giterr_set(GITERR_OS, "Failed to disable redirects"); goto on_error; } /* Strip unwanted headers (X-P2P-PeerDist, X-P2P-PeerDistEx) that WinHTTP * adds itself. This option may not be supported by the underlying * platform, so we do not error-check it */ WinHttpSetOption(s->request, WINHTTP_OPTION_PEERDIST_EXTENSION_STATE, &peerdist, sizeof(peerdist)); /* Send Pragma: no-cache header */ if (!WinHttpAddRequestHeaders(s->request, pragma_nocache, (ULONG) -1L, WINHTTP_ADDREQ_FLAG_ADD)) { giterr_set(GITERR_OS, "Failed to add a header to the request"); goto on_error; } if (post_verb == s->verb) { /* Send Content-Type and Accept headers -- only necessary on a POST */ git_buf_clear(&buf); if (git_buf_printf(&buf, "Content-Type: application/x-git-%s-request", s->service) < 0) goto on_error; if (git__utf8_to_16(ct, MAX_CONTENT_TYPE_LEN, git_buf_cstr(&buf)) < 0) { giterr_set(GITERR_OS, "Failed to convert content-type to wide characters"); goto on_error; } if (!WinHttpAddRequestHeaders(s->request, ct, (ULONG)-1L, WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE)) { giterr_set(GITERR_OS, "Failed to add a header to the request"); goto on_error; } git_buf_clear(&buf); if (git_buf_printf(&buf, "Accept: application/x-git-%s-result", s->service) < 0) goto on_error; if (git__utf8_to_16(ct, MAX_CONTENT_TYPE_LEN, git_buf_cstr(&buf)) < 0) { giterr_set(GITERR_OS, "Failed to convert accept header to wide characters"); goto on_error; } if (!WinHttpAddRequestHeaders(s->request, ct, (ULONG)-1L, WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE)) { giterr_set(GITERR_OS, "Failed to add a header to the request"); goto on_error; } } for (i = 0; i < t->owner->custom_headers.count; i++) { if (t->owner->custom_headers.strings[i]) { git_buf_clear(&buf); git_buf_puts(&buf, t->owner->custom_headers.strings[i]); if (git__utf8_to_16(ct, MAX_CONTENT_TYPE_LEN, git_buf_cstr(&buf)) < 0) { giterr_set(GITERR_OS, "Failed to convert custom header to wide characters"); goto on_error; } if (!WinHttpAddRequestHeaders(s->request, ct, (ULONG)-1L, WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE)) { giterr_set(GITERR_OS, "Failed to add a header to the request"); goto on_error; } } } /* If requested, disable certificate validation */ if (t->connection_data.use_ssl) { int flags; if (t->owner->parent.read_flags(&t->owner->parent, &flags) < 0) goto on_error; } /* If we have a credential on the subtransport, apply it to the request */ if (t->cred && t->cred->credtype == GIT_CREDTYPE_USERPASS_PLAINTEXT && t->auth_mechanism == GIT_WINHTTP_AUTH_BASIC && apply_basic_credential(s->request, t->cred) < 0) goto on_error; else if (t->cred && t->cred->credtype == GIT_CREDTYPE_DEFAULT && t->auth_mechanism == GIT_WINHTTP_AUTH_NEGOTIATE && apply_default_credentials(s->request) < 0) goto on_error; /* If no other credentials have been applied and the URL has username and * password, use those */ if (!t->cred && t->connection_data.user && t->connection_data.pass) { if (!t->url_cred && git_cred_userpass_plaintext_new(&t->url_cred, t->connection_data.user, t->connection_data.pass) < 0) goto on_error; if (apply_basic_credential(s->request, t->url_cred) < 0) goto on_error; } /* We've done everything up to calling WinHttpSendRequest. */ error = 0; on_error: if (error < 0) winhttp_stream_close(s); git__free(proxy_url); git_buf_free(&buf); return error; } static int parse_unauthorized_response( HINTERNET request, int *allowed_types, int *auth_mechanism) { DWORD supported, first, target; *allowed_types = 0; *auth_mechanism = 0; /* WinHttpQueryHeaders() must be called before WinHttpQueryAuthSchemes(). * We can assume this was already done, since we know we are unauthorized. */ if (!WinHttpQueryAuthSchemes(request, &supported, &first, &target)) { giterr_set(GITERR_OS, "Failed to parse supported auth schemes"); return -1; } if (WINHTTP_AUTH_SCHEME_BASIC & supported) { *allowed_types |= GIT_CREDTYPE_USERPASS_PLAINTEXT; *auth_mechanism = GIT_WINHTTP_AUTH_BASIC; } if ((WINHTTP_AUTH_SCHEME_NTLM & supported) || (WINHTTP_AUTH_SCHEME_NEGOTIATE & supported)) { *allowed_types |= GIT_CREDTYPE_DEFAULT; *auth_mechanism = GIT_WINHTTP_AUTH_NEGOTIATE; } return 0; } static int write_chunk(HINTERNET request, const char *buffer, size_t len) { DWORD bytes_written; git_buf buf = GIT_BUF_INIT; /* Chunk header */ git_buf_printf(&buf, "%X\r\n", len); if (git_buf_oom(&buf)) return -1; if (!WinHttpWriteData(request, git_buf_cstr(&buf), (DWORD)git_buf_len(&buf), &bytes_written)) { git_buf_free(&buf); giterr_set(GITERR_OS, "Failed to write chunk header"); return -1; } git_buf_free(&buf); /* Chunk body */ if (!WinHttpWriteData(request, buffer, (DWORD)len, &bytes_written)) { giterr_set(GITERR_OS, "Failed to write chunk"); return -1; } /* Chunk footer */ if (!WinHttpWriteData(request, "\r\n", 2, &bytes_written)) { giterr_set(GITERR_OS, "Failed to write chunk footer"); return -1; } return 0; } static int winhttp_close_connection(winhttp_subtransport *t) { int ret = 0; if (t->connection) { if (!WinHttpCloseHandle(t->connection)) { giterr_set(GITERR_OS, "Unable to close connection"); ret = -1; } t->connection = NULL; } if (t->session) { if (!WinHttpCloseHandle(t->session)) { giterr_set(GITERR_OS, "Unable to close session"); ret = -1; } t->session = NULL; } return ret; } static int winhttp_connect( winhttp_subtransport *t) { wchar_t *ua = L"git/1.0 (libgit2 " WIDEN(LIBGIT2_VERSION) L")"; wchar_t *wide_host; int32_t port; int error = -1; int default_timeout = TIMEOUT_INFINITE; int default_connect_timeout = DEFAULT_CONNECT_TIMEOUT; t->session = NULL; t->connection = NULL; /* Prepare port */ if (git__strtol32(&port, t->connection_data.port, NULL, 10) < 0) return -1; /* Prepare host */ if (git__utf8_to_16_alloc(&wide_host, t->connection_data.host) < 0) { giterr_set(GITERR_OS, "Unable to convert host to wide characters"); return -1; } /* Establish session */ t->session = WinHttpOpen( ua, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0); if (!t->session) { giterr_set(GITERR_OS, "Failed to init WinHTTP"); goto on_error; } if (!WinHttpSetTimeouts(t->session, default_timeout, default_connect_timeout, default_timeout, default_timeout)) { giterr_set(GITERR_OS, "Failed to set timeouts for WinHTTP"); goto on_error; } /* Establish connection */ t->connection = WinHttpConnect( t->session, wide_host, (INTERNET_PORT) port, 0); if (!t->connection) { giterr_set(GITERR_OS, "Failed to connect to host"); goto on_error; } error = 0; on_error: if (error < 0) winhttp_close_connection(t); git__free(wide_host); return error; } static int do_send_request(winhttp_stream *s, size_t len, int ignore_length) { if (ignore_length) { if (!WinHttpSendRequest(s->request, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH, 0)) { return -1; } } else { if (!WinHttpSendRequest(s->request, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, len, 0)) { return -1; } } return 0; } static int send_request(winhttp_stream *s, size_t len, int ignore_length) { int request_failed = 0, cert_valid = 1, error = 0; DWORD ignore_flags; if ((error = do_send_request(s, len, ignore_length)) < 0) request_failed = 1; if (request_failed) { if (GetLastError() != ERROR_WINHTTP_SECURE_FAILURE) { giterr_set(GITERR_OS, "failed to send request"); return -1; } else { cert_valid = 0; } } giterr_clear(); if ((error = certificate_check(s, cert_valid)) < 0) { if (!giterr_last()) giterr_set(GITERR_OS, "user cancelled certificate check"); return error; } /* if neither the request nor the certificate check returned errors, we're done */ if (!request_failed) return 0; ignore_flags = no_check_cert_flags; if (!WinHttpSetOption(s->request, WINHTTP_OPTION_SECURITY_FLAGS, &ignore_flags, sizeof(ignore_flags))) { giterr_set(GITERR_OS, "failed to set security options"); return -1; } if ((error = do_send_request(s, len, ignore_length)) < 0) giterr_set(GITERR_OS, "failed to send request"); return error; } static int winhttp_stream_read( git_smart_subtransport_stream *stream, char *buffer, size_t buf_size, size_t *bytes_read) { winhttp_stream *s = (winhttp_stream *)stream; winhttp_subtransport *t = OWNING_SUBTRANSPORT(s); DWORD dw_bytes_read; char replay_count = 0; int error; replay: /* Enforce a reasonable cap on the number of replays */ if (++replay_count >= 7) { giterr_set(GITERR_NET, "Too many redirects or authentication replays"); return -1; } /* Connect if necessary */ if (!s->request && winhttp_stream_connect(s) < 0) return -1; if (!s->received_response) { DWORD status_code, status_code_length, content_type_length, bytes_written; char expected_content_type_8[MAX_CONTENT_TYPE_LEN]; wchar_t expected_content_type[MAX_CONTENT_TYPE_LEN], content_type[MAX_CONTENT_TYPE_LEN]; if (!s->sent_request) { if ((error = send_request(s, s->post_body_len, 0)) < 0) return error; s->sent_request = 1; } if (s->chunked) { assert(s->verb == post_verb); /* Flush, if necessary */ if (s->chunk_buffer_len > 0 && write_chunk(s->request, s->chunk_buffer, s->chunk_buffer_len) < 0) return -1; s->chunk_buffer_len = 0; /* Write the final chunk. */ if (!WinHttpWriteData(s->request, "0\r\n\r\n", 5, &bytes_written)) { giterr_set(GITERR_OS, "Failed to write final chunk"); return -1; } } else if (s->post_body) { char *buffer; DWORD len = s->post_body_len, bytes_read; if (INVALID_SET_FILE_POINTER == SetFilePointer(s->post_body, 0, 0, FILE_BEGIN) && NO_ERROR != GetLastError()) { giterr_set(GITERR_OS, "Failed to reset file pointer"); return -1; } buffer = git__malloc(CACHED_POST_BODY_BUF_SIZE); while (len > 0) { DWORD bytes_written; if (!ReadFile(s->post_body, buffer, min(CACHED_POST_BODY_BUF_SIZE, len), &bytes_read, NULL) || !bytes_read) { git__free(buffer); giterr_set(GITERR_OS, "Failed to read from temp file"); return -1; } if (!WinHttpWriteData(s->request, buffer, bytes_read, &bytes_written)) { git__free(buffer); giterr_set(GITERR_OS, "Failed to write data"); return -1; } len -= bytes_read; assert(bytes_read == bytes_written); } git__free(buffer); /* Eagerly close the temp file */ CloseHandle(s->post_body); s->post_body = NULL; } if (!WinHttpReceiveResponse(s->request, 0)) { giterr_set(GITERR_OS, "Failed to receive response"); return -1; } /* Verify that we got a 200 back */ status_code_length = sizeof(status_code); if (!WinHttpQueryHeaders(s->request, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, WINHTTP_HEADER_NAME_BY_INDEX, &status_code, &status_code_length, WINHTTP_NO_HEADER_INDEX)) { giterr_set(GITERR_OS, "Failed to retrieve status code"); return -1; } /* The implementation of WinHTTP prior to Windows 7 will not * redirect to an identical URI. Some Git hosters use self-redirects * as part of their DoS mitigation strategy. Check first to see if we * have a redirect status code, and that we haven't already streamed * a post body. (We can't replay a streamed POST.) */ if (!s->chunked && (HTTP_STATUS_MOVED == status_code || HTTP_STATUS_REDIRECT == status_code || (HTTP_STATUS_REDIRECT_METHOD == status_code && get_verb == s->verb) || HTTP_STATUS_REDIRECT_KEEP_VERB == status_code)) { /* Check for Windows 7. This workaround is only necessary on * Windows Vista and earlier. Windows 7 is version 6.1. */ wchar_t *location; DWORD location_length; char *location8; /* OK, fetch the Location header from the redirect. */ if (WinHttpQueryHeaders(s->request, WINHTTP_QUERY_LOCATION, WINHTTP_HEADER_NAME_BY_INDEX, WINHTTP_NO_OUTPUT_BUFFER, &location_length, WINHTTP_NO_HEADER_INDEX) || GetLastError() != ERROR_INSUFFICIENT_BUFFER) { giterr_set(GITERR_OS, "Failed to read Location header"); return -1; } location = git__malloc(location_length); GITERR_CHECK_ALLOC(location); if (!WinHttpQueryHeaders(s->request, WINHTTP_QUERY_LOCATION, WINHTTP_HEADER_NAME_BY_INDEX, location, &location_length, WINHTTP_NO_HEADER_INDEX)) { giterr_set(GITERR_OS, "Failed to read Location header"); git__free(location); return -1; } /* Convert the Location header to UTF-8 */ if (git__utf16_to_8_alloc(&location8, location) < 0) { giterr_set(GITERR_OS, "Failed to convert Location header to UTF-8"); git__free(location); return -1; } git__free(location); /* Replay the request */ winhttp_stream_close(s); if (!git__prefixcmp_icase(location8, prefix_https)) { /* Upgrade to secure connection; disconnect and start over */ if (gitno_connection_data_from_url(&t->connection_data, location8, s->service_url) < 0) { git__free(location8); return -1; } winhttp_close_connection(t); if (winhttp_connect(t) < 0) return -1; } git__free(location8); goto replay; } /* Handle authentication failures */ if (HTTP_STATUS_DENIED == status_code && get_verb == s->verb) { int allowed_types; if (parse_unauthorized_response(s->request, &allowed_types, &t->auth_mechanism) < 0) return -1; if (allowed_types && (!t->cred || 0 == (t->cred->credtype & allowed_types))) { int cred_error = 1; /* Start with the user-supplied credential callback, if present */ if (t->owner->cred_acquire_cb) { cred_error = t->owner->cred_acquire_cb(&t->cred, t->owner->url, t->connection_data.user, allowed_types, t->owner->cred_acquire_payload); if (cred_error < 0) return cred_error; } /* Invoke the fallback credentials acquisition callback if necessary */ if (cred_error > 0) { cred_error = fallback_cred_acquire_cb(&t->cred, t->owner->url, t->connection_data.user, allowed_types, NULL); if (cred_error < 0) return cred_error; } if (!cred_error) { assert(t->cred); winhttp_stream_close(s); /* Successfully acquired a credential */ goto replay; } } } if (HTTP_STATUS_OK != status_code) { giterr_set(GITERR_NET, "Request failed with status code: %d", status_code); return -1; } /* Verify that we got the correct content-type back */ if (post_verb == s->verb) p_snprintf(expected_content_type_8, MAX_CONTENT_TYPE_LEN, "application/x-git-%s-result", s->service); else p_snprintf(expected_content_type_8, MAX_CONTENT_TYPE_LEN, "application/x-git-%s-advertisement", s->service); if (git__utf8_to_16(expected_content_type, MAX_CONTENT_TYPE_LEN, expected_content_type_8) < 0) { giterr_set(GITERR_OS, "Failed to convert expected content-type to wide characters"); return -1; } content_type_length = sizeof(content_type); if (!WinHttpQueryHeaders(s->request, WINHTTP_QUERY_CONTENT_TYPE, WINHTTP_HEADER_NAME_BY_INDEX, &content_type, &content_type_length, WINHTTP_NO_HEADER_INDEX)) { giterr_set(GITERR_OS, "Failed to retrieve response content-type"); return -1; } if (wcscmp(expected_content_type, content_type)) { giterr_set(GITERR_NET, "Received unexpected content-type"); return -1; } s->received_response = 1; } if (!WinHttpReadData(s->request, (LPVOID)buffer, (DWORD)buf_size, &dw_bytes_read)) { giterr_set(GITERR_OS, "Failed to read data"); return -1; } *bytes_read = dw_bytes_read; return 0; } static int winhttp_stream_write_single( git_smart_subtransport_stream *stream, const char *buffer, size_t len) { winhttp_stream *s = (winhttp_stream *)stream; DWORD bytes_written; int error; if (!s->request && winhttp_stream_connect(s) < 0) return -1; /* This implementation of write permits only a single call. */ if (s->sent_request) { giterr_set(GITERR_NET, "Subtransport configured for only one write"); return -1; } if ((error = send_request(s, len, 0)) < 0) return error; s->sent_request = 1; if (!WinHttpWriteData(s->request, (LPCVOID)buffer, (DWORD)len, &bytes_written)) { giterr_set(GITERR_OS, "Failed to write data"); return -1; } assert((DWORD)len == bytes_written); return 0; } static int put_uuid_string(LPWSTR buffer, size_t buffer_len_cch) { UUID uuid; RPC_STATUS status = UuidCreate(&uuid); int result; if (RPC_S_OK != status && RPC_S_UUID_LOCAL_ONLY != status && RPC_S_UUID_NO_ADDRESS != status) { giterr_set(GITERR_NET, "Unable to generate name for temp file"); return -1; } if (buffer_len_cch < UUID_LENGTH_CCH + 1) { giterr_set(GITERR_NET, "Buffer too small for name of temp file"); return -1; } #if !defined(__MINGW32__) || defined(MINGW_HAS_SECURE_API) result = swprintf_s(buffer, buffer_len_cch, #else result = wsprintfW(buffer, #endif L"%08x%04x%04x%02x%02x%02x%02x%02x%02x%02x%02x", uuid.Data1, uuid.Data2, uuid.Data3, uuid.Data4[0], uuid.Data4[1], uuid.Data4[2], uuid.Data4[3], uuid.Data4[4], uuid.Data4[5], uuid.Data4[6], uuid.Data4[7]); if (result < UUID_LENGTH_CCH) { giterr_set(GITERR_OS, "Unable to generate name for temp file"); return -1; } return 0; } static int get_temp_file(LPWSTR buffer, DWORD buffer_len_cch) { size_t len; if (!GetTempPathW(buffer_len_cch, buffer)) { giterr_set(GITERR_OS, "Failed to get temp path"); return -1; } len = wcslen(buffer); if (buffer[len - 1] != '\\' && len < buffer_len_cch) buffer[len++] = '\\'; if (put_uuid_string(&buffer[len], (size_t)buffer_len_cch - len) < 0) return -1; return 0; } static int winhttp_stream_write_buffered( git_smart_subtransport_stream *stream, const char *buffer, size_t len) { winhttp_stream *s = (winhttp_stream *)stream; DWORD bytes_written; if (!s->request && winhttp_stream_connect(s) < 0) return -1; /* Buffer the payload, using a temporary file so we delegate * memory management of the data to the operating system. */ if (!s->post_body) { wchar_t temp_path[MAX_PATH + 1]; if (get_temp_file(temp_path, MAX_PATH + 1) < 0) return -1; s->post_body = CreateFileW(temp_path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE, NULL, CREATE_NEW, FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (INVALID_HANDLE_VALUE == s->post_body) { s->post_body = NULL; giterr_set(GITERR_OS, "Failed to create temporary file"); return -1; } } if (!WriteFile(s->post_body, buffer, (DWORD)len, &bytes_written, NULL)) { giterr_set(GITERR_OS, "Failed to write to temporary file"); return -1; } assert((DWORD)len == bytes_written); s->post_body_len += bytes_written; return 0; } static int winhttp_stream_write_chunked( git_smart_subtransport_stream *stream, const char *buffer, size_t len) { winhttp_stream *s = (winhttp_stream *)stream; int error; if (!s->request && winhttp_stream_connect(s) < 0) return -1; if (!s->sent_request) { /* Send Transfer-Encoding: chunked header */ if (!WinHttpAddRequestHeaders(s->request, transfer_encoding, (ULONG) -1L, WINHTTP_ADDREQ_FLAG_ADD)) { giterr_set(GITERR_OS, "Failed to add a header to the request"); return -1; } if ((error = send_request(s, 0, 1)) < 0) return error; s->sent_request = 1; } if (len > CACHED_POST_BODY_BUF_SIZE) { /* Flush, if necessary */ if (s->chunk_buffer_len > 0) { if (write_chunk(s->request, s->chunk_buffer, s->chunk_buffer_len) < 0) return -1; s->chunk_buffer_len = 0; } /* Write chunk directly */ if (write_chunk(s->request, buffer, len) < 0) return -1; } else { /* Append as much to the buffer as we can */ int count = (int)min(CACHED_POST_BODY_BUF_SIZE - s->chunk_buffer_len, len); if (!s->chunk_buffer) s->chunk_buffer = git__malloc(CACHED_POST_BODY_BUF_SIZE); memcpy(s->chunk_buffer + s->chunk_buffer_len, buffer, count); s->chunk_buffer_len += count; buffer += count; len -= count; /* Is the buffer full? If so, then flush */ if (CACHED_POST_BODY_BUF_SIZE == s->chunk_buffer_len) { if (write_chunk(s->request, s->chunk_buffer, s->chunk_buffer_len) < 0) return -1; s->chunk_buffer_len = 0; /* Is there any remaining data from the source? */ if (len > 0) { memcpy(s->chunk_buffer, buffer, len); s->chunk_buffer_len = (unsigned int)len; } } } return 0; } static void winhttp_stream_free(git_smart_subtransport_stream *stream) { winhttp_stream *s = (winhttp_stream *)stream; winhttp_stream_close(s); git__free(s); } static int winhttp_stream_alloc(winhttp_subtransport *t, winhttp_stream **stream) { winhttp_stream *s; if (!stream) return -1; s = git__calloc(1, sizeof(winhttp_stream)); GITERR_CHECK_ALLOC(s); s->parent.subtransport = &t->parent; s->parent.read = winhttp_stream_read; s->parent.write = winhttp_stream_write_single; s->parent.free = winhttp_stream_free; *stream = s; return 0; } static int winhttp_uploadpack_ls( winhttp_subtransport *t, winhttp_stream *s) { GIT_UNUSED(t); s->service = upload_pack_service; s->service_url = upload_pack_ls_service_url; s->verb = get_verb; return 0; } static int winhttp_uploadpack( winhttp_subtransport *t, winhttp_stream *s) { GIT_UNUSED(t); s->service = upload_pack_service; s->service_url = upload_pack_service_url; s->verb = post_verb; return 0; } static int winhttp_receivepack_ls( winhttp_subtransport *t, winhttp_stream *s) { GIT_UNUSED(t); s->service = receive_pack_service; s->service_url = receive_pack_ls_service_url; s->verb = get_verb; return 0; } static int winhttp_receivepack( winhttp_subtransport *t, winhttp_stream *s) { GIT_UNUSED(t); /* WinHTTP only supports Transfer-Encoding: chunked * on Windows Vista (NT 6.0) and higher. */ s->chunked = git_has_win32_version(6, 0, 0); if (s->chunked) s->parent.write = winhttp_stream_write_chunked; else s->parent.write = winhttp_stream_write_buffered; s->service = receive_pack_service; s->service_url = receive_pack_service_url; s->verb = post_verb; return 0; } static int winhttp_action( git_smart_subtransport_stream **stream, git_smart_subtransport *subtransport, const char *url, git_smart_service_t action) { winhttp_subtransport *t = (winhttp_subtransport *)subtransport; winhttp_stream *s; int ret = -1; if (!t->connection) if ((ret = gitno_connection_data_from_url(&t->connection_data, url, NULL)) < 0 || (ret = winhttp_connect(t)) < 0) return ret; if (winhttp_stream_alloc(t, &s) < 0) return -1; if (!stream) return -1; switch (action) { case GIT_SERVICE_UPLOADPACK_LS: ret = winhttp_uploadpack_ls(t, s); break; case GIT_SERVICE_UPLOADPACK: ret = winhttp_uploadpack(t, s); break; case GIT_SERVICE_RECEIVEPACK_LS: ret = winhttp_receivepack_ls(t, s); break; case GIT_SERVICE_RECEIVEPACK: ret = winhttp_receivepack(t, s); break; default: assert(0); } if (!ret) *stream = &s->parent; return ret; } static int winhttp_close(git_smart_subtransport *subtransport) { winhttp_subtransport *t = (winhttp_subtransport *)subtransport; gitno_connection_data_free_ptrs(&t->connection_data); memset(&t->connection_data, 0x0, sizeof(gitno_connection_data)); if (t->cred) { t->cred->free(t->cred); t->cred = NULL; } if (t->url_cred) { t->url_cred->free(t->url_cred); t->url_cred = NULL; } return winhttp_close_connection(t); } static void winhttp_free(git_smart_subtransport *subtransport) { winhttp_subtransport *t = (winhttp_subtransport *)subtransport; winhttp_close(subtransport); git__free(t); } int git_smart_subtransport_http(git_smart_subtransport **out, git_transport *owner, void *param) { winhttp_subtransport *t; GIT_UNUSED(param); if (!out) return -1; t = git__calloc(1, sizeof(winhttp_subtransport)); GITERR_CHECK_ALLOC(t); t->owner = (transport_smart *)owner; t->parent.action = winhttp_action; t->parent.close = winhttp_close; t->parent.free = winhttp_free; *out = (git_smart_subtransport *) t; return 0; } #endif /* GIT_WINHTTP */ deps/libgit2-sys-0.3.8/libgit2/src/transports/auth.c0000664000175000017500000000273212426525445017233 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2.h" #include "buffer.h" #include "auth.h" static int basic_next_token( git_buf *out, git_http_auth_context *ctx, git_cred *c) { git_cred_userpass_plaintext *cred; git_buf raw = GIT_BUF_INIT; int error = -1; GIT_UNUSED(ctx); if (c->credtype != GIT_CREDTYPE_USERPASS_PLAINTEXT) { giterr_set(GITERR_INVALID, "invalid credential type for basic auth"); goto on_error; } cred = (git_cred_userpass_plaintext *)c; git_buf_printf(&raw, "%s:%s", cred->username, cred->password); if (git_buf_oom(&raw) || git_buf_puts(out, "Authorization: Basic ") < 0 || git_buf_encode_base64(out, git_buf_cstr(&raw), raw.size) < 0 || git_buf_puts(out, "\r\n") < 0) goto on_error; error = 0; on_error: if (raw.size) git__memzero(raw.ptr, raw.size); git_buf_free(&raw); return error; } static git_http_auth_context basic_context = { GIT_AUTHTYPE_BASIC, GIT_CREDTYPE_USERPASS_PLAINTEXT, NULL, basic_next_token, NULL }; int git_http_auth_basic( git_http_auth_context **out, const gitno_connection_data *connection_data) { GIT_UNUSED(connection_data); *out = &basic_context; return 0; } int git_http_auth_dummy( git_http_auth_context **out, const gitno_connection_data *connection_data) { GIT_UNUSED(connection_data); *out = NULL; return 0; } deps/libgit2-sys-0.3.8/libgit2/src/transports/cred.c0000664000175000017500000001724012572105236017201 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2.h" #include "smart.h" #include "git2/cred_helpers.h" static int git_cred_ssh_key_type_new( git_cred **cred, const char *username, const char *publickey, const char *privatekey, const char *passphrase, git_credtype_t credtype); int git_cred_has_username(git_cred *cred) { if (cred->credtype == GIT_CREDTYPE_DEFAULT) return 0; return 1; } const char *git_cred__username(git_cred *cred) { switch (cred->credtype) { case GIT_CREDTYPE_USERNAME: { git_cred_username *c = (git_cred_username *) cred; return c->username; } case GIT_CREDTYPE_USERPASS_PLAINTEXT: { git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *) cred; return c->username; } case GIT_CREDTYPE_SSH_KEY: case GIT_CREDTYPE_SSH_MEMORY: { git_cred_ssh_key *c = (git_cred_ssh_key *) cred; return c->username; } case GIT_CREDTYPE_SSH_CUSTOM: { git_cred_ssh_custom *c = (git_cred_ssh_custom *) cred; return c->username; } case GIT_CREDTYPE_SSH_INTERACTIVE: { git_cred_ssh_interactive *c = (git_cred_ssh_interactive *) cred; return c->username; } default: return NULL; } } static void plaintext_free(struct git_cred *cred) { git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred; git__free(c->username); /* Zero the memory which previously held the password */ if (c->password) { size_t pass_len = strlen(c->password); git__memzero(c->password, pass_len); git__free(c->password); } git__free(c); } int git_cred_userpass_plaintext_new( git_cred **cred, const char *username, const char *password) { git_cred_userpass_plaintext *c; assert(cred && username && password); c = git__malloc(sizeof(git_cred_userpass_plaintext)); GITERR_CHECK_ALLOC(c); c->parent.credtype = GIT_CREDTYPE_USERPASS_PLAINTEXT; c->parent.free = plaintext_free; c->username = git__strdup(username); if (!c->username) { git__free(c); return -1; } c->password = git__strdup(password); if (!c->password) { git__free(c->username); git__free(c); return -1; } *cred = &c->parent; return 0; } static void ssh_key_free(struct git_cred *cred) { git_cred_ssh_key *c = (git_cred_ssh_key *)cred; git__free(c->username); if (c->privatekey) { /* Zero the memory which previously held the private key */ size_t key_len = strlen(c->privatekey); git__memzero(c->privatekey, key_len); git__free(c->privatekey); } if (c->passphrase) { /* Zero the memory which previously held the passphrase */ size_t pass_len = strlen(c->passphrase); git__memzero(c->passphrase, pass_len); git__free(c->passphrase); } if (c->publickey) { /* Zero the memory which previously held the public key */ size_t key_len = strlen(c->publickey); git__memzero(c->publickey, key_len); git__free(c->publickey); } git__free(c); } static void ssh_interactive_free(struct git_cred *cred) { git_cred_ssh_interactive *c = (git_cred_ssh_interactive *)cred; git__free(c->username); git__free(c); } static void ssh_custom_free(struct git_cred *cred) { git_cred_ssh_custom *c = (git_cred_ssh_custom *)cred; git__free(c->username); if (c->publickey) { /* Zero the memory which previously held the publickey */ size_t key_len = strlen(c->publickey); git__memzero(c->publickey, key_len); git__free(c->publickey); } git__free(c); } static void default_free(struct git_cred *cred) { git_cred_default *c = (git_cred_default *)cred; git__free(c); } static void username_free(struct git_cred *cred) { git__free(cred); } int git_cred_ssh_key_new( git_cred **cred, const char *username, const char *publickey, const char *privatekey, const char *passphrase) { return git_cred_ssh_key_type_new( cred, username, publickey, privatekey, passphrase, GIT_CREDTYPE_SSH_KEY); } int git_cred_ssh_key_memory_new( git_cred **cred, const char *username, const char *publickey, const char *privatekey, const char *passphrase) { #ifdef GIT_SSH_MEMORY_CREDENTIALS return git_cred_ssh_key_type_new( cred, username, publickey, privatekey, passphrase, GIT_CREDTYPE_SSH_MEMORY); #else GIT_UNUSED(cred); GIT_UNUSED(username); GIT_UNUSED(publickey); GIT_UNUSED(privatekey); GIT_UNUSED(passphrase); giterr_set(GITERR_INVALID, "This version of libgit2 was not built with ssh memory credentials."); return -1; #endif } static int git_cred_ssh_key_type_new( git_cred **cred, const char *username, const char *publickey, const char *privatekey, const char *passphrase, git_credtype_t credtype) { git_cred_ssh_key *c; assert(username && cred && privatekey); c = git__calloc(1, sizeof(git_cred_ssh_key)); GITERR_CHECK_ALLOC(c); c->parent.credtype = credtype; c->parent.free = ssh_key_free; c->username = git__strdup(username); GITERR_CHECK_ALLOC(c->username); c->privatekey = git__strdup(privatekey); GITERR_CHECK_ALLOC(c->privatekey); if (publickey) { c->publickey = git__strdup(publickey); GITERR_CHECK_ALLOC(c->publickey); } if (passphrase) { c->passphrase = git__strdup(passphrase); GITERR_CHECK_ALLOC(c->passphrase); } *cred = &c->parent; return 0; } int git_cred_ssh_interactive_new( git_cred **out, const char *username, git_cred_ssh_interactive_callback prompt_callback, void *payload) { git_cred_ssh_interactive *c; assert(out && username && prompt_callback); c = git__calloc(1, sizeof(git_cred_ssh_interactive)); GITERR_CHECK_ALLOC(c); c->parent.credtype = GIT_CREDTYPE_SSH_INTERACTIVE; c->parent.free = ssh_interactive_free; c->username = git__strdup(username); GITERR_CHECK_ALLOC(c->username); c->prompt_callback = prompt_callback; c->payload = payload; *out = &c->parent; return 0; } int git_cred_ssh_key_from_agent(git_cred **cred, const char *username) { git_cred_ssh_key *c; assert(username && cred); c = git__calloc(1, sizeof(git_cred_ssh_key)); GITERR_CHECK_ALLOC(c); c->parent.credtype = GIT_CREDTYPE_SSH_KEY; c->parent.free = ssh_key_free; c->username = git__strdup(username); GITERR_CHECK_ALLOC(c->username); c->privatekey = NULL; *cred = &c->parent; return 0; } int git_cred_ssh_custom_new( git_cred **cred, const char *username, const char *publickey, size_t publickey_len, git_cred_sign_callback sign_callback, void *payload) { git_cred_ssh_custom *c; assert(username && cred); c = git__calloc(1, sizeof(git_cred_ssh_custom)); GITERR_CHECK_ALLOC(c); c->parent.credtype = GIT_CREDTYPE_SSH_CUSTOM; c->parent.free = ssh_custom_free; c->username = git__strdup(username); GITERR_CHECK_ALLOC(c->username); if (publickey_len > 0) { c->publickey = git__malloc(publickey_len); GITERR_CHECK_ALLOC(c->publickey); memcpy(c->publickey, publickey, publickey_len); } c->publickey_len = publickey_len; c->sign_callback = sign_callback; c->payload = payload; *cred = &c->parent; return 0; } int git_cred_default_new(git_cred **cred) { git_cred_default *c; assert(cred); c = git__calloc(1, sizeof(git_cred_default)); GITERR_CHECK_ALLOC(c); c->credtype = GIT_CREDTYPE_DEFAULT; c->free = default_free; *cred = c; return 0; } int git_cred_username_new(git_cred **cred, const char *username) { git_cred_username *c; size_t len, allocsize; assert(cred); len = strlen(username); GITERR_CHECK_ALLOC_ADD(&allocsize, sizeof(git_cred_username), len); GITERR_CHECK_ALLOC_ADD(&allocsize, allocsize, 1); c = git__malloc(allocsize); GITERR_CHECK_ALLOC(c); c->parent.credtype = GIT_CREDTYPE_USERNAME; c->parent.free = username_free; memcpy(c->username, username, len + 1); *cred = (git_cred *) c; return 0; } void git_cred_free(git_cred *cred) { if (!cred) return; cred->free(cred); } deps/libgit2-sys-0.3.8/libgit2/src/describe.c0000664000175000017500000005022512572105236015625 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/describe.h" #include "git2/strarray.h" #include "git2/diff.h" #include "git2/status.h" #include "common.h" #include "commit.h" #include "commit_list.h" #include "oidmap.h" #include "refs.h" #include "revwalk.h" #include "tag.h" #include "vector.h" #include "repository.h" GIT__USE_OIDMAP /* Ported from https://github.com/git/git/blob/89dde7882f71f846ccd0359756d27bebc31108de/builtin/describe.c */ struct commit_name { git_tag *tag; unsigned prio:2; /* annotated tag = 2, tag = 1, head = 0 */ unsigned name_checked:1; git_oid sha1; char *path; /* Khash workaround. They original key has to still be reachable */ git_oid peeled; }; static void *oidmap_value_bykey(git_oidmap *map, const git_oid *key) { khint_t pos = git_oidmap_lookup_index(map, key); if (!git_oidmap_valid_index(map, pos)) return NULL; return git_oidmap_value_at(map, pos); } static struct commit_name *find_commit_name( git_oidmap *names, const git_oid *peeled) { return (struct commit_name *)(oidmap_value_bykey(names, peeled)); } static int replace_name( git_tag **tag, git_repository *repo, struct commit_name *e, unsigned int prio, const git_oid *sha1) { git_time_t e_time = 0, t_time = 0; if (!e || e->prio < prio) return 1; if (e->prio == 2 && prio == 2) { /* Multiple annotated tags point to the same commit. * Select one to keep based upon their tagger date. */ git_tag *t = NULL; if (!e->tag) { if (git_tag_lookup(&t, repo, &e->sha1) < 0) return 1; e->tag = t; } if (git_tag_lookup(&t, repo, sha1) < 0) return 0; *tag = t; if (e->tag->tagger) e_time = e->tag->tagger->when.time; if (t->tagger) t_time = t->tagger->when.time; if (e_time < t_time) return 1; } return 0; } static int add_to_known_names( git_repository *repo, git_oidmap *names, const char *path, const git_oid *peeled, unsigned int prio, const git_oid *sha1) { struct commit_name *e = find_commit_name(names, peeled); bool found = (e != NULL); git_tag *tag = NULL; if (replace_name(&tag, repo, e, prio, sha1)) { if (!found) { e = git__malloc(sizeof(struct commit_name)); GITERR_CHECK_ALLOC(e); e->path = NULL; e->tag = NULL; } if (e->tag) git_tag_free(e->tag); e->tag = tag; e->prio = prio; e->name_checked = 0; git_oid_cpy(&e->sha1, sha1); git__free(e->path); e->path = git__strdup(path); git_oid_cpy(&e->peeled, peeled); if (!found) { int ret; git_oidmap_insert(names, &e->peeled, e, ret); if (ret < 0) return -1; } } else git_tag_free(tag); return 0; } static int retrieve_peeled_tag_or_object_oid( git_oid *peeled_out, git_oid *ref_target_out, git_repository *repo, const char *refname) { git_reference *ref; git_object *peeled = NULL; int error; if ((error = git_reference_lookup_resolved(&ref, repo, refname, -1)) < 0) return error; if ((error = git_reference_peel(&peeled, ref, GIT_OBJ_ANY)) < 0) goto cleanup; git_oid_cpy(ref_target_out, git_reference_target(ref)); git_oid_cpy(peeled_out, git_object_id(peeled)); if (git_oid_cmp(ref_target_out, peeled_out) != 0) error = 1; /* The reference was pointing to a annotated tag */ else error = 0; /* Any other object */ cleanup: git_reference_free(ref); git_object_free(peeled); return error; } struct git_describe_result { int dirty; int exact_match; int fallback_to_id; git_oid commit_id; git_repository *repo; struct commit_name *name; struct possible_tag *tag; }; struct get_name_data { git_describe_options *opts; git_repository *repo; git_oidmap *names; git_describe_result *result; }; static int commit_name_dup(struct commit_name **out, struct commit_name *in) { struct commit_name *name; name = git__malloc(sizeof(struct commit_name)); GITERR_CHECK_ALLOC(name); memcpy(name, in, sizeof(struct commit_name)); name->tag = NULL; name->path = NULL; if (in->tag && git_object_dup((git_object **) &name->tag, (git_object *) in->tag) < 0) return -1; name->path = git__strdup(in->path); GITERR_CHECK_ALLOC(name->path); *out = name; return 0; } static int get_name(const char *refname, void *payload) { struct get_name_data *data; bool is_tag, is_annotated, all; git_oid peeled, sha1; unsigned int prio; int error = 0; data = (struct get_name_data *)payload; is_tag = !git__prefixcmp(refname, GIT_REFS_TAGS_DIR); all = data->opts->describe_strategy == GIT_DESCRIBE_ALL; /* Reject anything outside refs/tags/ unless --all */ if (!all && !is_tag) return 0; /* Accept only tags that match the pattern, if given */ if (data->opts->pattern && (!is_tag || p_fnmatch(data->opts->pattern, refname + strlen(GIT_REFS_TAGS_DIR), 0))) return 0; /* Is it annotated? */ if ((error = retrieve_peeled_tag_or_object_oid( &peeled, &sha1, data->repo, refname)) < 0) return error; is_annotated = error; /* * By default, we only use annotated tags, but with --tags * we fall back to lightweight ones (even without --tags, * we still remember lightweight ones, only to give hints * in an error message). --all allows any refs to be used. */ if (is_annotated) prio = 2; else if (is_tag) prio = 1; else prio = 0; add_to_known_names(data->repo, data->names, all ? refname + strlen(GIT_REFS_DIR) : refname + strlen(GIT_REFS_TAGS_DIR), &peeled, prio, &sha1); return 0; } struct possible_tag { struct commit_name *name; int depth; int found_order; unsigned flag_within; }; static int possible_tag_dup(struct possible_tag **out, struct possible_tag *in) { struct possible_tag *tag; int error; tag = git__malloc(sizeof(struct possible_tag)); GITERR_CHECK_ALLOC(tag); memcpy(tag, in, sizeof(struct possible_tag)); tag->name = NULL; if ((error = commit_name_dup(&tag->name, in->name)) < 0) { git__free(tag); *out = NULL; return error; } *out = tag; return 0; } static int compare_pt(const void *a_, const void *b_) { struct possible_tag *a = (struct possible_tag *)a_; struct possible_tag *b = (struct possible_tag *)b_; if (a->depth != b->depth) return a->depth - b->depth; if (a->found_order != b->found_order) return a->found_order - b->found_order; return 0; } #define SEEN (1u << 0) static unsigned long finish_depth_computation( git_pqueue *list, git_revwalk *walk, struct possible_tag *best) { unsigned long seen_commits = 0; int error, i; while (git_pqueue_size(list) > 0) { git_commit_list_node *c = git_pqueue_pop(list); seen_commits++; if (c->flags & best->flag_within) { size_t index = 0; while (git_pqueue_size(list) > index) { git_commit_list_node *i = git_pqueue_get(list, index); if (!(i->flags & best->flag_within)) break; index++; } if (index > git_pqueue_size(list)) break; } else best->depth++; for (i = 0; i < c->out_degree; i++) { git_commit_list_node *p = c->parents[i]; if ((error = git_commit_list_parse(walk, p)) < 0) return error; if (!(p->flags & SEEN)) if ((error = git_pqueue_insert(list, p)) < 0) return error; p->flags |= c->flags; } } return seen_commits; } static int display_name(git_buf *buf, git_repository *repo, struct commit_name *n) { if (n->prio == 2 && !n->tag) { if (git_tag_lookup(&n->tag, repo, &n->sha1) < 0) { giterr_set(GITERR_TAG, "Annotated tag '%s' not available", n->path); return -1; } } if (n->tag && !n->name_checked) { if (!git_tag_name(n->tag)) { giterr_set(GITERR_TAG, "Annotated tag '%s' has no embedded name", n->path); return -1; } /* TODO: Cope with warnings if (strcmp(n->tag->tag, all ? n->path + 5 : n->path)) warning(_("tag '%s' is really '%s' here"), n->tag->tag, n->path); */ n->name_checked = 1; } if (n->tag) git_buf_printf(buf, "%s", git_tag_name(n->tag)); else git_buf_printf(buf, "%s", n->path); return 0; } static int find_unique_abbrev_size( int *out, git_repository *repo, const git_oid *oid_in, int abbreviated_size) { size_t size = abbreviated_size; git_odb *odb; git_oid dummy; int error; if ((error = git_repository_odb__weakptr(&odb, repo)) < 0) return error; while (size < GIT_OID_HEXSZ) { if ((error = git_odb_exists_prefix(&dummy, odb, oid_in, size)) == 0) { *out = (int) size; return 0; } /* If the error wasn't that it's not unique, then it's a proper error */ if (error != GIT_EAMBIGUOUS) return error; /* Try again with a larger size */ size++; } /* If we didn't find any shorter prefix, we have to do the whole thing */ *out = GIT_OID_HEXSZ; return 0; } static int show_suffix( git_buf *buf, int depth, git_repository *repo, const git_oid* id, size_t abbrev_size) { int error, size = 0; char hex_oid[GIT_OID_HEXSZ]; if ((error = find_unique_abbrev_size(&size, repo, id, abbrev_size)) < 0) return error; git_oid_fmt(hex_oid, id); git_buf_printf(buf, "-%d-g", depth); git_buf_put(buf, hex_oid, size); return git_buf_oom(buf) ? -1 : 0; } #define MAX_CANDIDATES_TAGS FLAG_BITS - 1 static int describe_not_found(const git_oid *oid, const char *message_format) { char oid_str[GIT_OID_HEXSZ + 1]; git_oid_tostr(oid_str, sizeof(oid_str), oid); giterr_set(GITERR_DESCRIBE, message_format, oid_str); return GIT_ENOTFOUND; } static int describe( struct get_name_data *data, git_commit *commit) { struct commit_name *n; struct possible_tag *best; bool all, tags; git_revwalk *walk = NULL; git_pqueue list; git_commit_list_node *cmit, *gave_up_on = NULL; git_vector all_matches = GIT_VECTOR_INIT; unsigned int match_cnt = 0, annotated_cnt = 0, cur_match; unsigned long seen_commits = 0; /* TODO: Check long */ unsigned int unannotated_cnt = 0; int error; if (git_vector_init(&all_matches, MAX_CANDIDATES_TAGS, compare_pt) < 0) return -1; if ((error = git_pqueue_init(&list, 0, 2, git_commit_list_time_cmp)) < 0) goto cleanup; all = data->opts->describe_strategy == GIT_DESCRIBE_ALL; tags = data->opts->describe_strategy == GIT_DESCRIBE_TAGS; git_oid_cpy(&data->result->commit_id, git_commit_id(commit)); n = find_commit_name(data->names, git_commit_id(commit)); if (n && (tags || all || n->prio == 2)) { /* * Exact match to an existing ref. */ data->result->exact_match = 1; if ((error = commit_name_dup(&data->result->name, n)) < 0) goto cleanup; goto cleanup; } if (!data->opts->max_candidates_tags) { error = describe_not_found( git_commit_id(commit), "Cannot describe - no tag exactly matches '%s'"); goto cleanup; } if ((error = git_revwalk_new(&walk, git_commit_owner(commit))) < 0) goto cleanup; if ((cmit = git_revwalk__commit_lookup(walk, git_commit_id(commit))) == NULL) goto cleanup; if ((error = git_commit_list_parse(walk, cmit)) < 0) goto cleanup; cmit->flags = SEEN; if ((error = git_pqueue_insert(&list, cmit)) < 0) goto cleanup; while (git_pqueue_size(&list) > 0) { int i; git_commit_list_node *c = (git_commit_list_node *)git_pqueue_pop(&list); seen_commits++; n = find_commit_name(data->names, &c->oid); if (n) { if (!tags && !all && n->prio < 2) { unannotated_cnt++; } else if (match_cnt < data->opts->max_candidates_tags) { struct possible_tag *t = git__malloc(sizeof(struct commit_name)); GITERR_CHECK_ALLOC(t); if ((error = git_vector_insert(&all_matches, t)) < 0) goto cleanup; match_cnt++; t->name = n; t->depth = seen_commits - 1; t->flag_within = 1u << match_cnt; t->found_order = match_cnt; c->flags |= t->flag_within; if (n->prio == 2) annotated_cnt++; } else { gave_up_on = c; break; } } for (cur_match = 0; cur_match < match_cnt; cur_match++) { struct possible_tag *t = git_vector_get(&all_matches, cur_match); if (!(c->flags & t->flag_within)) t->depth++; } if (annotated_cnt && (git_pqueue_size(&list) == 0)) { /* if (debug) { char oid_str[GIT_OID_HEXSZ + 1]; git_oid_tostr(oid_str, sizeof(oid_str), &c->oid); fprintf(stderr, "finished search at %s\n", oid_str); } */ break; } for (i = 0; i < c->out_degree; i++) { git_commit_list_node *p = c->parents[i]; if ((error = git_commit_list_parse(walk, p)) < 0) goto cleanup; if (!(p->flags & SEEN)) if ((error = git_pqueue_insert(&list, p)) < 0) goto cleanup; p->flags |= c->flags; if (data->opts->only_follow_first_parent) break; } } if (!match_cnt) { if (data->opts->show_commit_oid_as_fallback) { data->result->fallback_to_id = 1; git_oid_cpy(&data->result->commit_id, &cmit->oid); goto cleanup; } if (unannotated_cnt) { error = describe_not_found(git_commit_id(commit), "Cannot describe - " "No annotated tags can describe '%s'." "However, there were unannotated tags."); goto cleanup; } else { error = describe_not_found(git_commit_id(commit), "Cannot describe - " "No tags can describe '%s'."); goto cleanup; } } git_vector_sort(&all_matches); best = (struct possible_tag *)git_vector_get(&all_matches, 0); if (gave_up_on) { git_pqueue_insert(&list, gave_up_on); seen_commits--; } if ((error = finish_depth_computation( &list, walk, best)) < 0) goto cleanup; seen_commits += error; if ((error = possible_tag_dup(&data->result->tag, best)) < 0) goto cleanup; /* { static const char *prio_names[] = { "head", "lightweight", "annotated", }; char oid_str[GIT_OID_HEXSZ + 1]; if (debug) { for (cur_match = 0; cur_match < match_cnt; cur_match++) { struct possible_tag *t = (struct possible_tag *)git_vector_get(&all_matches, cur_match); fprintf(stderr, " %-11s %8d %s\n", prio_names[t->name->prio], t->depth, t->name->path); } fprintf(stderr, "traversed %lu commits\n", seen_commits); if (gave_up_on) { git_oid_tostr(oid_str, sizeof(oid_str), &gave_up_on->oid); fprintf(stderr, "more than %i tags found; listed %i most recent\n" "gave up search at %s\n", data->opts->max_candidates_tags, data->opts->max_candidates_tags, oid_str); } } } */ git_oid_cpy(&data->result->commit_id, &cmit->oid); cleanup: { size_t i; struct possible_tag *match; git_vector_foreach(&all_matches, i, match) { git__free(match); } } git_vector_free(&all_matches); git_pqueue_free(&list); git_revwalk_free(walk); return error; } static int normalize_options( git_describe_options *dst, const git_describe_options *src) { git_describe_options default_options = GIT_DESCRIBE_OPTIONS_INIT; if (!src) src = &default_options; *dst = *src; if (dst->max_candidates_tags > GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS) dst->max_candidates_tags = GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS; return 0; } int git_describe_commit( git_describe_result **result, git_object *committish, git_describe_options *opts) { struct get_name_data data; struct commit_name *name; git_commit *commit; int error = -1; git_describe_options normalized; assert(committish); data.result = git__calloc(1, sizeof(git_describe_result)); GITERR_CHECK_ALLOC(data.result); data.result->repo = git_object_owner(committish); data.repo = git_object_owner(committish); if ((error = normalize_options(&normalized, opts)) < 0) return error; GITERR_CHECK_VERSION( &normalized, GIT_DESCRIBE_OPTIONS_VERSION, "git_describe_options"); data.opts = &normalized; data.names = git_oidmap_alloc(); GITERR_CHECK_ALLOC(data.names); /** TODO: contains to be implemented */ if ((error = git_object_peel((git_object **)(&commit), committish, GIT_OBJ_COMMIT)) < 0) goto cleanup; if ((error = git_reference_foreach_name( git_object_owner(committish), get_name, &data)) < 0) goto cleanup; if (git_oidmap_size(data.names) == 0 && !opts->show_commit_oid_as_fallback) { giterr_set(GITERR_DESCRIBE, "Cannot describe - " "No reference found, cannot describe anything."); error = -1; goto cleanup; } if ((error = describe(&data, commit)) < 0) goto cleanup; cleanup: git_commit_free(commit); git_oidmap_foreach_value(data.names, name, { git_tag_free(name->tag); git__free(name->path); git__free(name); }); git_oidmap_free(data.names); if (error < 0) git_describe_result_free(data.result); else *result = data.result; return error; } int git_describe_workdir( git_describe_result **out, git_repository *repo, git_describe_options *opts) { int error; git_oid current_id; git_status_list *status = NULL; git_status_options status_opts = GIT_STATUS_OPTIONS_INIT; git_describe_result *result = NULL; git_object *commit; if ((error = git_reference_name_to_id(¤t_id, repo, GIT_HEAD_FILE)) < 0) return error; if ((error = git_object_lookup(&commit, repo, ¤t_id, GIT_OBJ_COMMIT)) < 0) return error; /* The first step is to perform a describe of HEAD, so we can leverage this */ if ((error = git_describe_commit(&result, commit, opts)) < 0) goto out; if ((error = git_status_list_new(&status, repo, &status_opts)) < 0) goto out; if (git_status_list_entrycount(status) > 0) result->dirty = 1; out: git_object_free(commit); git_status_list_free(status); if (error < 0) git_describe_result_free(result); else *out = result; return error; } static int normalize_format_options( git_describe_format_options *dst, const git_describe_format_options *src) { if (!src) { git_describe_init_format_options(dst, GIT_DESCRIBE_FORMAT_OPTIONS_VERSION); return 0; } memcpy(dst, src, sizeof(git_describe_format_options)); return 0; } int git_describe_format(git_buf *out, const git_describe_result *result, const git_describe_format_options *given) { int error; git_repository *repo; struct commit_name *name; git_describe_format_options opts; assert(out && result); GITERR_CHECK_VERSION(given, GIT_DESCRIBE_FORMAT_OPTIONS_VERSION, "git_describe_format_options"); normalize_format_options(&opts, given); git_buf_sanitize(out); if (opts.always_use_long_format && opts.abbreviated_size == 0) { giterr_set(GITERR_DESCRIBE, "Cannot describe - " "'always_use_long_format' is incompatible with a zero" "'abbreviated_size'"); return -1; } repo = result->repo; /* If we did find an exact match, then it's the easier method */ if (result->exact_match) { name = result->name; if ((error = display_name(out, repo, name)) < 0) return error; if (opts.always_use_long_format) { const git_oid *id = name->tag ? git_tag_target_id(name->tag) : &result->commit_id; if ((error = show_suffix(out, 0, repo, id, opts.abbreviated_size)) < 0) return error; } if (result->dirty && opts.dirty_suffix) git_buf_puts(out, opts.dirty_suffix); return git_buf_oom(out) ? -1 : 0; } /* If we didn't find *any* tags, we fall back to the commit's id */ if (result->fallback_to_id) { char hex_oid[GIT_OID_HEXSZ + 1] = {0}; int size = 0; if ((error = find_unique_abbrev_size( &size, repo, &result->commit_id, opts.abbreviated_size)) < 0) return -1; git_oid_fmt(hex_oid, &result->commit_id); git_buf_put(out, hex_oid, size); if (result->dirty && opts.dirty_suffix) git_buf_puts(out, opts.dirty_suffix); return git_buf_oom(out) ? -1 : 0; } /* Lastly, if we found a matching tag, we show that */ name = result->tag->name; if ((error = display_name(out, repo, name)) < 0) return error; if (opts.abbreviated_size) { if ((error = show_suffix(out, result->tag->depth, repo, &result->commit_id, opts.abbreviated_size)) < 0) return error; } if (result->dirty && opts.dirty_suffix) { git_buf_puts(out, opts.dirty_suffix); } return git_buf_oom(out) ? -1 : 0; } void git_describe_result_free(git_describe_result *result) { if (result == NULL) return; if (result->name) { git_tag_free(result->name->tag); git__free(result->name->path); git__free(result->name); } if (result->tag) { git_tag_free(result->tag->name->tag); git__free(result->tag->name->path); git__free(result->tag->name); git__free(result->tag); } git__free(result); } int git_describe_init_options(git_describe_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_describe_options, GIT_DESCRIBE_OPTIONS_INIT); return 0; } int git_describe_init_format_options(git_describe_format_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_describe_format_options, GIT_DESCRIBE_FORMAT_OPTIONS_INIT); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/diff_stats.c0000664000175000017500000001705512426525445016205 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "vector.h" #include "diff.h" #include "diff_patch.h" #define DIFF_RENAME_FILE_SEPARATOR " => " #define STATS_FULL_MIN_SCALE 7 typedef struct { size_t insertions; size_t deletions; } diff_file_stats; struct git_diff_stats { git_diff *diff; diff_file_stats *filestats; size_t files_changed; size_t insertions; size_t deletions; size_t renames; size_t max_name; size_t max_filestat; int max_digits; }; static int digits_for_value(size_t val) { int count = 1; size_t placevalue = 10; while (val >= placevalue) { ++count; placevalue *= 10; } return count; } int git_diff_file_stats__full_to_buf( git_buf *out, const git_diff_delta *delta, const diff_file_stats *filestat, const git_diff_stats *stats, size_t width) { const char *old_path = NULL, *new_path = NULL; size_t padding, old_size, new_size; old_path = delta->old_file.path; new_path = delta->new_file.path; old_size = delta->old_file.size; new_size = delta->new_file.size; if (git_buf_printf(out, " %s", old_path) < 0) goto on_error; if (strcmp(old_path, new_path) != 0) { padding = stats->max_name - strlen(old_path) - strlen(new_path); if (git_buf_printf(out, DIFF_RENAME_FILE_SEPARATOR "%s", new_path) < 0) goto on_error; } else { padding = stats->max_name - strlen(old_path); if (stats->renames > 0) padding += strlen(DIFF_RENAME_FILE_SEPARATOR); } if (git_buf_putcn(out, ' ', padding) < 0 || git_buf_puts(out, " | ") < 0) goto on_error; if (delta->flags & GIT_DIFF_FLAG_BINARY) { if (git_buf_printf(out, "Bin %" PRIuZ " -> %" PRIuZ " bytes", old_size, new_size) < 0) goto on_error; } else { if (git_buf_printf(out, "%*" PRIuZ, stats->max_digits, filestat->insertions + filestat->deletions) < 0) goto on_error; if (filestat->insertions || filestat->deletions) { if (git_buf_putc(out, ' ') < 0) goto on_error; if (!width) { if (git_buf_putcn(out, '+', filestat->insertions) < 0 || git_buf_putcn(out, '-', filestat->deletions) < 0) goto on_error; } else { size_t total = filestat->insertions + filestat->deletions; size_t full = (total * width + stats->max_filestat / 2) / stats->max_filestat; size_t plus = full * filestat->insertions / total; size_t minus = full - plus; if (git_buf_putcn(out, '+', max(plus, 1)) < 0 || git_buf_putcn(out, '-', max(minus, 1)) < 0) goto on_error; } } } git_buf_putc(out, '\n'); on_error: return (git_buf_oom(out) ? -1 : 0); } int git_diff_file_stats__number_to_buf( git_buf *out, const git_diff_delta *delta, const diff_file_stats *filestats) { int error; const char *path = delta->new_file.path; if (delta->flags & GIT_DIFF_FLAG_BINARY) error = git_buf_printf(out, "%-8c" "%-8c" "%s\n", '-', '-', path); else error = git_buf_printf(out, "%-8" PRIuZ "%-8" PRIuZ "%s\n", filestats->insertions, filestats->deletions, path); return error; } int git_diff_file_stats__summary_to_buf( git_buf *out, const git_diff_delta *delta) { if (delta->old_file.mode != delta->new_file.mode) { if (delta->old_file.mode == 0) { git_buf_printf(out, " create mode %06o %s\n", delta->new_file.mode, delta->new_file.path); } else if (delta->new_file.mode == 0) { git_buf_printf(out, " delete mode %06o %s\n", delta->old_file.mode, delta->old_file.path); } else { git_buf_printf(out, " mode change %06o => %06o %s\n", delta->old_file.mode, delta->new_file.mode, delta->new_file.path); } } return 0; } int git_diff_get_stats( git_diff_stats **out, git_diff *diff) { size_t i, deltas; size_t total_insertions = 0, total_deletions = 0; git_diff_stats *stats = NULL; int error = 0; assert(out && diff); stats = git__calloc(1, sizeof(git_diff_stats)); GITERR_CHECK_ALLOC(stats); deltas = git_diff_num_deltas(diff); stats->filestats = git__calloc(deltas, sizeof(diff_file_stats)); if (!stats->filestats) { git__free(stats); return -1; } stats->diff = diff; GIT_REFCOUNT_INC(diff); for (i = 0; i < deltas && !error; ++i) { git_patch *patch = NULL; size_t add = 0, remove = 0, namelen; const git_diff_delta *delta; if ((error = git_patch_from_diff(&patch, diff, i)) < 0) break; /* keep a count of renames because it will affect formatting */ delta = git_patch_get_delta(patch); namelen = strlen(delta->new_file.path); if (strcmp(delta->old_file.path, delta->new_file.path) != 0) { namelen += strlen(delta->old_file.path); stats->renames++; } /* and, of course, count the line stats */ error = git_patch_line_stats(NULL, &add, &remove, patch); git_patch_free(patch); stats->filestats[i].insertions = add; stats->filestats[i].deletions = remove; total_insertions += add; total_deletions += remove; if (stats->max_name < namelen) stats->max_name = namelen; if (stats->max_filestat < add + remove) stats->max_filestat = add + remove; } stats->files_changed = deltas; stats->insertions = total_insertions; stats->deletions = total_deletions; stats->max_digits = digits_for_value(stats->max_filestat + 1); if (error < 0) { git_diff_stats_free(stats); stats = NULL; } *out = stats; return error; } size_t git_diff_stats_files_changed( const git_diff_stats *stats) { assert(stats); return stats->files_changed; } size_t git_diff_stats_insertions( const git_diff_stats *stats) { assert(stats); return stats->insertions; } size_t git_diff_stats_deletions( const git_diff_stats *stats) { assert(stats); return stats->deletions; } int git_diff_stats_to_buf( git_buf *out, const git_diff_stats *stats, git_diff_stats_format_t format, size_t width) { int error = 0; size_t i; const git_diff_delta *delta; assert(out && stats); if (format & GIT_DIFF_STATS_NUMBER) { for (i = 0; i < stats->files_changed; ++i) { if ((delta = git_diff_get_delta(stats->diff, i)) == NULL) continue; error = git_diff_file_stats__number_to_buf( out, delta, &stats->filestats[i]); if (error < 0) return error; } } if (format & GIT_DIFF_STATS_FULL) { if (width > 0) { if (width > stats->max_name + stats->max_digits + 5) width -= (stats->max_name + stats->max_digits + 5); if (width < STATS_FULL_MIN_SCALE) width = STATS_FULL_MIN_SCALE; } if (width > stats->max_filestat) width = 0; for (i = 0; i < stats->files_changed; ++i) { if ((delta = git_diff_get_delta(stats->diff, i)) == NULL) continue; error = git_diff_file_stats__full_to_buf( out, delta, &stats->filestats[i], stats, width); if (error < 0) return error; } } if (format & GIT_DIFF_STATS_FULL || format & GIT_DIFF_STATS_SHORT) { error = git_buf_printf( out, " %" PRIuZ " file%s changed, %" PRIuZ " insertion%s(+), %" PRIuZ " deletion%s(-)\n", stats->files_changed, stats->files_changed != 1 ? "s" : "", stats->insertions, stats->insertions != 1 ? "s" : "", stats->deletions, stats->deletions != 1 ? "s" : ""); if (error < 0) return error; } if (format & GIT_DIFF_STATS_INCLUDE_SUMMARY) { for (i = 0; i < stats->files_changed; ++i) { if ((delta = git_diff_get_delta(stats->diff, i)) == NULL) continue; error = git_diff_file_stats__summary_to_buf(out, delta); if (error < 0) return error; } } return error; } void git_diff_stats_free(git_diff_stats *stats) { if (stats == NULL) return; git_diff_free(stats->diff); /* bumped refcount in constructor */ git__free(stats->filestats); git__free(stats); } deps/libgit2-sys-0.3.8/libgit2/src/fetch.c0000664000175000017500000000757712555730137015157 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/oid.h" #include "git2/refs.h" #include "git2/revwalk.h" #include "git2/transport.h" #include "common.h" #include "remote.h" #include "refspec.h" #include "pack.h" #include "fetch.h" #include "netops.h" #include "repository.h" #include "refs.h" static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, git_refspec *tagspec, git_remote_autotag_option_t tagopt) { int match = 0; if (!git_reference_is_valid_name(head->name)) return 0; if (tagopt == GIT_REMOTE_DOWNLOAD_TAGS_ALL) { /* * If tagopt is --tags, always request tags * in addition to the remote's refspecs */ if (git_refspec_src_matches(tagspec, head->name)) match = 1; } if (!match && git_remote__matching_refspec(remote, head->name)) match = 1; if (!match) return 0; /* If we have the object, mark it so we don't ask for it */ if (git_odb_exists(odb, &head->oid)) { head->local = 1; } else remote->need_pack = 1; return git_vector_insert(&remote->refs, head); } static int filter_wants(git_remote *remote, const git_fetch_options *opts) { git_remote_head **heads; git_refspec tagspec, head; int error = 0; git_odb *odb; size_t i, heads_len; git_remote_autotag_option_t tagopt = remote->download_tags; if (opts && opts->download_tags != GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED) tagopt = opts->download_tags; git_vector_clear(&remote->refs); if ((error = git_refspec__parse(&tagspec, GIT_REFSPEC_TAGS, true)) < 0) return error; /* * The fetch refspec can be NULL, and what this means is that the * user didn't specify one. This is fine, as it means that we're * not interested in any particular branch but just the remote's * HEAD, which will be stored in FETCH_HEAD after the fetch. */ if (remote->active_refspecs.length == 0) { if ((error = git_refspec__parse(&head, "HEAD", true)) < 0) goto cleanup; error = git_refspec__dwim_one(&remote->active_refspecs, &head, &remote->refs); git_refspec__free(&head); if (error < 0) goto cleanup; } if (git_repository_odb__weakptr(&odb, remote->repo) < 0) goto cleanup; if (git_remote_ls((const git_remote_head ***)&heads, &heads_len, remote) < 0) goto cleanup; for (i = 0; i < heads_len; i++) { if ((error = maybe_want(remote, heads[i], odb, &tagspec, tagopt)) < 0) break; } cleanup: git_refspec__free(&tagspec); return error; } /* * In this first version, we push all our refs in and start sending * them out. When we get an ACK we hide that commit and continue * traversing until we're done */ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts) { git_transport *t = remote->transport; remote->need_pack = 0; if (filter_wants(remote, opts) < 0) { giterr_set(GITERR_NET, "Failed to filter the reference list for wants"); return -1; } /* Don't try to negotiate when we don't want anything */ if (!remote->need_pack) return 0; /* * Now we have everything set up so we can start tell the * server what we want and what we have. */ return t->negotiate_fetch(t, remote->repo, (const git_remote_head * const *)remote->refs.contents, remote->refs.length); } int git_fetch_download_pack(git_remote *remote, const git_remote_callbacks *callbacks) { git_transport *t = remote->transport; git_transfer_progress_cb progress = NULL; void *payload = NULL; if (!remote->need_pack) return 0; if (callbacks) { progress = callbacks->transfer_progress; payload = callbacks->payload; } return t->download_pack(t, remote->repo, &remote->stats, progress, payload); } int git_fetch_init_options(git_fetch_options *opts, unsigned int version) { GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_fetch_options, GIT_FETCH_OPTIONS_INIT); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/pack-objects.c0000664000175000017500000011715512572105236016420 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "pack-objects.h" #include "zstream.h" #include "delta.h" #include "iterator.h" #include "netops.h" #include "pack.h" #include "thread-utils.h" #include "tree.h" #include "util.h" #include "revwalk.h" #include "commit_list.h" #include "git2/pack.h" #include "git2/commit.h" #include "git2/tag.h" #include "git2/indexer.h" #include "git2/config.h" struct unpacked { git_pobject *object; void *data; struct git_delta_index *index; int depth; }; struct tree_walk_context { git_packbuilder *pb; git_buf buf; }; struct pack_write_context { git_indexer *indexer; git_transfer_progress *stats; }; GIT__USE_OIDMAP #ifdef GIT_THREADS #define GIT_PACKBUILDER__MUTEX_OP(pb, mtx, op) do { \ int result = git_mutex_##op(&(pb)->mtx); \ assert(!result); \ GIT_UNUSED(result); \ } while (0) #else #define GIT_PACKBUILDER__MUTEX_OP(pb,mtx,op) GIT_UNUSED(pb) #endif /* GIT_THREADS */ #define git_packbuilder__cache_lock(pb) GIT_PACKBUILDER__MUTEX_OP(pb, cache_mutex, lock) #define git_packbuilder__cache_unlock(pb) GIT_PACKBUILDER__MUTEX_OP(pb, cache_mutex, unlock) #define git_packbuilder__progress_lock(pb) GIT_PACKBUILDER__MUTEX_OP(pb, progress_mutex, lock) #define git_packbuilder__progress_unlock(pb) GIT_PACKBUILDER__MUTEX_OP(pb, progress_mutex, unlock) /* The minimal interval between progress updates (in seconds). */ #define MIN_PROGRESS_UPDATE_INTERVAL 0.5 /* Size of the buffer to feed to zlib */ #define COMPRESS_BUFLEN (1024 * 1024) static unsigned name_hash(const char *name) { unsigned c, hash = 0; if (!name) return 0; /* * This effectively just creates a sortable number from the * last sixteen non-whitespace characters. Last characters * count "most", so things that end in ".c" sort together. */ while ((c = *name++) != 0) { if (git__isspace(c)) continue; hash = (hash >> 2) + (c << 24); } return hash; } static int packbuilder_config(git_packbuilder *pb) { git_config *config; int ret; int64_t val; if ((ret = git_repository_config_snapshot(&config, pb->repo)) < 0) return ret; #define config_get(KEY,DST,DFLT) do { \ ret = git_config_get_int64(&val, config, KEY); \ if (!ret) (DST) = val; \ else if (ret == GIT_ENOTFOUND) (DST) = (DFLT); \ else if (ret < 0) return -1; } while (0) config_get("pack.deltaCacheSize", pb->max_delta_cache_size, GIT_PACK_DELTA_CACHE_SIZE); config_get("pack.deltaCacheLimit", pb->cache_max_small_delta_size, GIT_PACK_DELTA_CACHE_LIMIT); config_get("pack.deltaCacheSize", pb->big_file_threshold, GIT_PACK_BIG_FILE_THRESHOLD); config_get("pack.windowMemory", pb->window_memory_limit, 0); #undef config_get git_config_free(config); return 0; } int git_packbuilder_new(git_packbuilder **out, git_repository *repo) { git_packbuilder *pb; *out = NULL; pb = git__calloc(1, sizeof(*pb)); GITERR_CHECK_ALLOC(pb); pb->object_ix = git_oidmap_alloc(); if (!pb->object_ix) goto on_error; pb->walk_objects = git_oidmap_alloc(); if (!pb->walk_objects) goto on_error; if (git_pool_init(&pb->object_pool, sizeof(git_walk_object), 0) < 0) goto on_error; pb->repo = repo; pb->nr_threads = 1; /* do not spawn any thread by default */ if (git_hash_ctx_init(&pb->ctx) < 0 || git_zstream_init(&pb->zstream) < 0 || git_repository_odb(&pb->odb, repo) < 0 || packbuilder_config(pb) < 0) goto on_error; #ifdef GIT_THREADS if (git_mutex_init(&pb->cache_mutex) || git_mutex_init(&pb->progress_mutex) || git_cond_init(&pb->progress_cond)) { giterr_set(GITERR_OS, "Failed to initialize packbuilder mutex"); goto on_error; } #endif *out = pb; return 0; on_error: git_packbuilder_free(pb); return -1; } unsigned int git_packbuilder_set_threads(git_packbuilder *pb, unsigned int n) { assert(pb); #ifdef GIT_THREADS pb->nr_threads = n; #else GIT_UNUSED(n); assert(1 == pb->nr_threads); #endif return pb->nr_threads; } static void rehash(git_packbuilder *pb) { git_pobject *po; khiter_t pos; unsigned int i; int ret; kh_clear(oid, pb->object_ix); for (i = 0, po = pb->object_list; i < pb->nr_objects; i++, po++) { pos = kh_put(oid, pb->object_ix, &po->id, &ret); kh_value(pb->object_ix, pos) = po; } } int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid, const char *name) { git_pobject *po; khiter_t pos; size_t newsize; int ret; assert(pb && oid); /* If the object already exists in the hash table, then we don't * have any work to do */ pos = kh_get(oid, pb->object_ix, oid); if (pos != kh_end(pb->object_ix)) return 0; if (pb->nr_objects >= pb->nr_alloc) { GITERR_CHECK_ALLOC_ADD(&newsize, pb->nr_alloc, 1024); GITERR_CHECK_ALLOC_MULTIPLY(&newsize, newsize, 3 / 2); if (!git__is_uint32(newsize)) { giterr_set(GITERR_NOMEMORY, "Packfile too large to fit in memory."); return -1; } pb->nr_alloc = (uint32_t)newsize; pb->object_list = git__reallocarray(pb->object_list, pb->nr_alloc, sizeof(*po)); GITERR_CHECK_ALLOC(pb->object_list); rehash(pb); } po = pb->object_list + pb->nr_objects; memset(po, 0x0, sizeof(*po)); if ((ret = git_odb_read_header(&po->size, &po->type, pb->odb, oid)) < 0) return ret; pb->nr_objects++; git_oid_cpy(&po->id, oid); po->hash = name_hash(name); pos = kh_put(oid, pb->object_ix, &po->id, &ret); if (ret < 0) { giterr_set_oom(); return ret; } assert(ret != 0); kh_value(pb->object_ix, pos) = po; pb->done = false; if (pb->progress_cb) { double current_time = git__timer(); double elapsed = current_time - pb->last_progress_report_time; if (elapsed >= MIN_PROGRESS_UPDATE_INTERVAL) { pb->last_progress_report_time = current_time; ret = pb->progress_cb( GIT_PACKBUILDER_ADDING_OBJECTS, pb->nr_objects, 0, pb->progress_cb_payload); if (ret) return giterr_set_after_callback(ret); } } return 0; } static int get_delta(void **out, git_odb *odb, git_pobject *po) { git_odb_object *src = NULL, *trg = NULL; unsigned long delta_size; void *delta_buf; *out = NULL; if (git_odb_read(&src, odb, &po->delta->id) < 0 || git_odb_read(&trg, odb, &po->id) < 0) goto on_error; delta_buf = git_delta( git_odb_object_data(src), (unsigned long)git_odb_object_size(src), git_odb_object_data(trg), (unsigned long)git_odb_object_size(trg), &delta_size, 0); if (!delta_buf || delta_size != po->delta_size) { giterr_set(GITERR_INVALID, "Delta size changed"); goto on_error; } *out = delta_buf; git_odb_object_free(src); git_odb_object_free(trg); return 0; on_error: git_odb_object_free(src); git_odb_object_free(trg); return -1; } static int write_object( git_packbuilder *pb, git_pobject *po, int (*write_cb)(void *buf, size_t size, void *cb_data), void *cb_data) { git_odb_object *obj = NULL; git_otype type; unsigned char hdr[10], *zbuf = NULL; void *data = NULL; size_t hdr_len, zbuf_len = COMPRESS_BUFLEN, data_len; int error; /* * If we have a delta base, let's use the delta to save space. * Otherwise load the whole object. 'data' ends up pointing to * whatever data we want to put into the packfile. */ if (po->delta) { if (po->delta_data) data = po->delta_data; else if ((error = get_delta(&data, pb->odb, po)) < 0) goto done; data_len = po->delta_size; type = GIT_OBJ_REF_DELTA; } else { if ((error = git_odb_read(&obj, pb->odb, &po->id)) < 0) goto done; data = (void *)git_odb_object_data(obj); data_len = git_odb_object_size(obj); type = git_odb_object_type(obj); } /* Write header */ hdr_len = git_packfile__object_header(hdr, data_len, type); if ((error = write_cb(hdr, hdr_len, cb_data)) < 0 || (error = git_hash_update(&pb->ctx, hdr, hdr_len)) < 0) goto done; if (type == GIT_OBJ_REF_DELTA) { if ((error = write_cb(po->delta->id.id, GIT_OID_RAWSZ, cb_data)) < 0 || (error = git_hash_update(&pb->ctx, po->delta->id.id, GIT_OID_RAWSZ)) < 0) goto done; } /* Write data */ if (po->z_delta_size) { data_len = po->z_delta_size; if ((error = write_cb(data, data_len, cb_data)) < 0 || (error = git_hash_update(&pb->ctx, data, data_len)) < 0) goto done; } else { zbuf = git__malloc(zbuf_len); GITERR_CHECK_ALLOC(zbuf); git_zstream_reset(&pb->zstream); git_zstream_set_input(&pb->zstream, data, data_len); while (!git_zstream_done(&pb->zstream)) { if ((error = git_zstream_get_output(zbuf, &zbuf_len, &pb->zstream)) < 0 || (error = write_cb(zbuf, zbuf_len, cb_data)) < 0 || (error = git_hash_update(&pb->ctx, zbuf, zbuf_len)) < 0) goto done; zbuf_len = COMPRESS_BUFLEN; /* reuse buffer */ } } /* * If po->delta is true, data is a delta and it is our * responsibility to free it (otherwise it's a git_object's * data). We set po->delta_data to NULL in case we got the * data from there instead of get_delta(). If we didn't, * there's no harm. */ if (po->delta) { git__free(data); po->delta_data = NULL; } pb->nr_written++; done: git__free(zbuf); git_odb_object_free(obj); return error; } enum write_one_status { WRITE_ONE_SKIP = -1, /* already written */ WRITE_ONE_BREAK = 0, /* writing this will bust the limit; not written */ WRITE_ONE_WRITTEN = 1, /* normal */ WRITE_ONE_RECURSIVE = 2 /* already scheduled to be written */ }; static int write_one( enum write_one_status *status, git_packbuilder *pb, git_pobject *po, int (*write_cb)(void *buf, size_t size, void *cb_data), void *cb_data) { int error; if (po->recursing) { *status = WRITE_ONE_RECURSIVE; return 0; } else if (po->written) { *status = WRITE_ONE_SKIP; return 0; } if (po->delta) { po->recursing = 1; if ((error = write_one(status, pb, po->delta, write_cb, cb_data)) < 0) return error; /* we cannot depend on this one */ if (*status == WRITE_ONE_RECURSIVE) po->delta = NULL; } *status = WRITE_ONE_WRITTEN; po->written = 1; po->recursing = 0; return write_object(pb, po, write_cb, cb_data); } GIT_INLINE(void) add_to_write_order(git_pobject **wo, unsigned int *endp, git_pobject *po) { if (po->filled) return; wo[(*endp)++] = po; po->filled = 1; } static void add_descendants_to_write_order(git_pobject **wo, unsigned int *endp, git_pobject *po) { int add_to_order = 1; while (po) { if (add_to_order) { git_pobject *s; /* add this node... */ add_to_write_order(wo, endp, po); /* all its siblings... */ for (s = po->delta_sibling; s; s = s->delta_sibling) { add_to_write_order(wo, endp, s); } } /* drop down a level to add left subtree nodes if possible */ if (po->delta_child) { add_to_order = 1; po = po->delta_child; } else { add_to_order = 0; /* our sibling might have some children, it is next */ if (po->delta_sibling) { po = po->delta_sibling; continue; } /* go back to our parent node */ po = po->delta; while (po && !po->delta_sibling) { /* we're on the right side of a subtree, keep * going up until we can go right again */ po = po->delta; } if (!po) { /* done- we hit our original root node */ return; } /* pass it off to sibling at this level */ po = po->delta_sibling; } }; } static void add_family_to_write_order(git_pobject **wo, unsigned int *endp, git_pobject *po) { git_pobject *root; for (root = po; root->delta; root = root->delta) ; /* nothing */ add_descendants_to_write_order(wo, endp, root); } static int cb_tag_foreach(const char *name, git_oid *oid, void *data) { git_packbuilder *pb = data; git_pobject *po; khiter_t pos; GIT_UNUSED(name); pos = kh_get(oid, pb->object_ix, oid); if (pos == kh_end(pb->object_ix)) return 0; po = kh_value(pb->object_ix, pos); po->tagged = 1; /* TODO: peel objects */ return 0; } static git_pobject **compute_write_order(git_packbuilder *pb) { unsigned int i, wo_end, last_untagged; git_pobject **wo; if ((wo = git__mallocarray(pb->nr_objects, sizeof(*wo))) == NULL) return NULL; for (i = 0; i < pb->nr_objects; i++) { git_pobject *po = pb->object_list + i; po->tagged = 0; po->filled = 0; po->delta_child = NULL; po->delta_sibling = NULL; } /* * Fully connect delta_child/delta_sibling network. * Make sure delta_sibling is sorted in the original * recency order. */ for (i = pb->nr_objects; i > 0;) { git_pobject *po = &pb->object_list[--i]; if (!po->delta) continue; /* Mark me as the first child */ po->delta_sibling = po->delta->delta_child; po->delta->delta_child = po; } /* * Mark objects that are at the tip of tags. */ if (git_tag_foreach(pb->repo, &cb_tag_foreach, pb) < 0) { git__free(wo); return NULL; } /* * Give the objects in the original recency order until * we see a tagged tip. */ for (i = wo_end = 0; i < pb->nr_objects; i++) { git_pobject *po = pb->object_list + i; if (po->tagged) break; add_to_write_order(wo, &wo_end, po); } last_untagged = i; /* * Then fill all the tagged tips. */ for (; i < pb->nr_objects; i++) { git_pobject *po = pb->object_list + i; if (po->tagged) add_to_write_order(wo, &wo_end, po); } /* * And then all remaining commits and tags. */ for (i = last_untagged; i < pb->nr_objects; i++) { git_pobject *po = pb->object_list + i; if (po->type != GIT_OBJ_COMMIT && po->type != GIT_OBJ_TAG) continue; add_to_write_order(wo, &wo_end, po); } /* * And then all the trees. */ for (i = last_untagged; i < pb->nr_objects; i++) { git_pobject *po = pb->object_list + i; if (po->type != GIT_OBJ_TREE) continue; add_to_write_order(wo, &wo_end, po); } /* * Finally all the rest in really tight order */ for (i = last_untagged; i < pb->nr_objects; i++) { git_pobject *po = pb->object_list + i; if (!po->filled) add_family_to_write_order(wo, &wo_end, po); } if (wo_end != pb->nr_objects) { giterr_set(GITERR_INVALID, "invalid write order"); return NULL; } return wo; } static int write_pack(git_packbuilder *pb, int (*write_cb)(void *buf, size_t size, void *cb_data), void *cb_data) { git_pobject **write_order; git_pobject *po; enum write_one_status status; struct git_pack_header ph; git_oid entry_oid; unsigned int i = 0; int error = 0; write_order = compute_write_order(pb); if (write_order == NULL) { error = -1; goto done; } /* Write pack header */ ph.hdr_signature = htonl(PACK_SIGNATURE); ph.hdr_version = htonl(PACK_VERSION); ph.hdr_entries = htonl(pb->nr_objects); if ((error = write_cb(&ph, sizeof(ph), cb_data)) < 0 || (error = git_hash_update(&pb->ctx, &ph, sizeof(ph))) < 0) goto done; pb->nr_remaining = pb->nr_objects; do { pb->nr_written = 0; for ( ; i < pb->nr_objects; ++i) { po = write_order[i]; if ((error = write_one(&status, pb, po, write_cb, cb_data)) < 0) goto done; } pb->nr_remaining -= pb->nr_written; } while (pb->nr_remaining && i < pb->nr_objects); if ((error = git_hash_final(&entry_oid, &pb->ctx)) < 0) goto done; error = write_cb(entry_oid.id, GIT_OID_RAWSZ, cb_data); done: /* if callback cancelled writing, we must still free delta_data */ for ( ; i < pb->nr_objects; ++i) { po = write_order[i]; if (po->delta_data) { git__free(po->delta_data); po->delta_data = NULL; } } git__free(write_order); return error; } static int write_pack_buf(void *buf, size_t size, void *data) { git_buf *b = (git_buf *)data; return git_buf_put(b, buf, size); } static int type_size_sort(const void *_a, const void *_b) { const git_pobject *a = (git_pobject *)_a; const git_pobject *b = (git_pobject *)_b; if (a->type > b->type) return -1; if (a->type < b->type) return 1; if (a->hash > b->hash) return -1; if (a->hash < b->hash) return 1; /* * TODO * if (a->preferred_base > b->preferred_base) return -1; if (a->preferred_base < b->preferred_base) return 1; */ if (a->size > b->size) return -1; if (a->size < b->size) return 1; return a < b ? -1 : (a > b); /* newest first */ } static int delta_cacheable(git_packbuilder *pb, unsigned long src_size, unsigned long trg_size, unsigned long delta_size) { if (pb->max_delta_cache_size && pb->delta_cache_size + delta_size > pb->max_delta_cache_size) return 0; if (delta_size < pb->cache_max_small_delta_size) return 1; /* cache delta, if objects are large enough compared to delta size */ if ((src_size >> 20) + (trg_size >> 21) > (delta_size >> 10)) return 1; return 0; } static int try_delta(git_packbuilder *pb, struct unpacked *trg, struct unpacked *src, int max_depth, unsigned long *mem_usage, int *ret) { git_pobject *trg_object = trg->object; git_pobject *src_object = src->object; git_odb_object *obj; unsigned long trg_size, src_size, delta_size, sizediff, max_size, sz; unsigned int ref_depth; void *delta_buf; /* Don't bother doing diffs between different types */ if (trg_object->type != src_object->type) { *ret = -1; return 0; } *ret = 0; /* TODO: support reuse-delta */ /* Let's not bust the allowed depth. */ if (src->depth >= max_depth) return 0; /* Now some size filtering heuristics. */ trg_size = (unsigned long)trg_object->size; if (!trg_object->delta) { max_size = trg_size/2 - 20; ref_depth = 1; } else { max_size = trg_object->delta_size; ref_depth = trg->depth; } max_size = (uint64_t)max_size * (max_depth - src->depth) / (max_depth - ref_depth + 1); if (max_size == 0) return 0; src_size = (unsigned long)src_object->size; sizediff = src_size < trg_size ? trg_size - src_size : 0; if (sizediff >= max_size) return 0; if (trg_size < src_size / 32) return 0; /* Load data if not already done */ if (!trg->data) { if (git_odb_read(&obj, pb->odb, &trg_object->id) < 0) return -1; sz = (unsigned long)git_odb_object_size(obj); trg->data = git__malloc(sz); GITERR_CHECK_ALLOC(trg->data); memcpy(trg->data, git_odb_object_data(obj), sz); git_odb_object_free(obj); if (sz != trg_size) { giterr_set(GITERR_INVALID, "Inconsistent target object length"); return -1; } *mem_usage += sz; } if (!src->data) { size_t obj_sz; if (git_odb_read(&obj, pb->odb, &src_object->id) < 0 || !git__is_ulong(obj_sz = git_odb_object_size(obj))) return -1; sz = (unsigned long)obj_sz; src->data = git__malloc(sz); GITERR_CHECK_ALLOC(src->data); memcpy(src->data, git_odb_object_data(obj), sz); git_odb_object_free(obj); if (sz != src_size) { giterr_set(GITERR_INVALID, "Inconsistent source object length"); return -1; } *mem_usage += sz; } if (!src->index) { src->index = git_delta_create_index(src->data, src_size); if (!src->index) return 0; /* suboptimal pack - out of memory */ *mem_usage += git_delta_sizeof_index(src->index); } delta_buf = git_delta_create(src->index, trg->data, trg_size, &delta_size, max_size); if (!delta_buf) return 0; if (trg_object->delta) { /* Prefer only shallower same-sized deltas. */ if (delta_size == trg_object->delta_size && src->depth + 1 >= trg->depth) { git__free(delta_buf); return 0; } } git_packbuilder__cache_lock(pb); if (trg_object->delta_data) { git__free(trg_object->delta_data); pb->delta_cache_size -= trg_object->delta_size; trg_object->delta_data = NULL; } if (delta_cacheable(pb, src_size, trg_size, delta_size)) { bool overflow = git__add_uint64_overflow( &pb->delta_cache_size, pb->delta_cache_size, delta_size); git_packbuilder__cache_unlock(pb); if (overflow || !(trg_object->delta_data = git__realloc(delta_buf, delta_size))) return -1; } else { /* create delta when writing the pack */ git_packbuilder__cache_unlock(pb); git__free(delta_buf); } trg_object->delta = src_object; trg_object->delta_size = delta_size; trg->depth = src->depth + 1; *ret = 1; return 0; } static unsigned int check_delta_limit(git_pobject *me, unsigned int n) { git_pobject *child = me->delta_child; unsigned int m = n; while (child) { unsigned int c = check_delta_limit(child, n + 1); if (m < c) m = c; child = child->delta_sibling; } return m; } static unsigned long free_unpacked(struct unpacked *n) { unsigned long freed_mem = git_delta_sizeof_index(n->index); git_delta_free_index(n->index); n->index = NULL; if (n->data) { freed_mem += (unsigned long)n->object->size; git__free(n->data); n->data = NULL; } n->object = NULL; n->depth = 0; return freed_mem; } static int report_delta_progress(git_packbuilder *pb, uint32_t count, bool force) { int ret; if (pb->progress_cb) { double current_time = git__timer(); double elapsed = current_time - pb->last_progress_report_time; if (force || elapsed >= MIN_PROGRESS_UPDATE_INTERVAL) { pb->last_progress_report_time = current_time; ret = pb->progress_cb( GIT_PACKBUILDER_DELTAFICATION, count, pb->nr_objects, pb->progress_cb_payload); if (ret) return giterr_set_after_callback(ret); } } return 0; } static int find_deltas(git_packbuilder *pb, git_pobject **list, unsigned int *list_size, unsigned int window, int depth) { git_pobject *po; git_buf zbuf = GIT_BUF_INIT; struct unpacked *array; uint32_t idx = 0, count = 0; unsigned long mem_usage = 0; unsigned int i; int error = -1; array = git__calloc(window, sizeof(struct unpacked)); GITERR_CHECK_ALLOC(array); for (;;) { struct unpacked *n = array + idx; int max_depth, j, best_base = -1; git_packbuilder__progress_lock(pb); if (!*list_size) { git_packbuilder__progress_unlock(pb); break; } pb->nr_deltified += 1; report_delta_progress(pb, pb->nr_deltified, false); po = *list++; (*list_size)--; git_packbuilder__progress_unlock(pb); mem_usage -= free_unpacked(n); n->object = po; while (pb->window_memory_limit && mem_usage > pb->window_memory_limit && count > 1) { uint32_t tail = (idx + window - count) % window; mem_usage -= free_unpacked(array + tail); count--; } /* * If the current object is at pack edge, take the depth the * objects that depend on the current object into account * otherwise they would become too deep. */ max_depth = depth; if (po->delta_child) { max_depth -= check_delta_limit(po, 0); if (max_depth <= 0) goto next; } j = window; while (--j > 0) { int ret; uint32_t other_idx = idx + j; struct unpacked *m; if (other_idx >= window) other_idx -= window; m = array + other_idx; if (!m->object) break; if (try_delta(pb, n, m, max_depth, &mem_usage, &ret) < 0) goto on_error; if (ret < 0) break; else if (ret > 0) best_base = other_idx; } /* * If we decided to cache the delta data, then it is best * to compress it right away. First because we have to do * it anyway, and doing it here while we're threaded will * save a lot of time in the non threaded write phase, * as well as allow for caching more deltas within * the same cache size limit. * ... * But only if not writing to stdout, since in that case * the network is most likely throttling writes anyway, * and therefore it is best to go to the write phase ASAP * instead, as we can afford spending more time compressing * between writes at that moment. */ if (po->delta_data) { if (git_zstream_deflatebuf(&zbuf, po->delta_data, po->delta_size) < 0) goto on_error; git__free(po->delta_data); po->delta_data = git__malloc(zbuf.size); GITERR_CHECK_ALLOC(po->delta_data); memcpy(po->delta_data, zbuf.ptr, zbuf.size); po->z_delta_size = (unsigned long)zbuf.size; git_buf_clear(&zbuf); git_packbuilder__cache_lock(pb); pb->delta_cache_size -= po->delta_size; pb->delta_cache_size += po->z_delta_size; git_packbuilder__cache_unlock(pb); } /* * If we made n a delta, and if n is already at max * depth, leaving it in the window is pointless. we * should evict it first. */ if (po->delta && max_depth <= n->depth) continue; /* * Move the best delta base up in the window, after the * currently deltified object, to keep it longer. It will * be the first base object to be attempted next. */ if (po->delta) { struct unpacked swap = array[best_base]; int dist = (window + idx - best_base) % window; int dst = best_base; while (dist--) { int src = (dst + 1) % window; array[dst] = array[src]; dst = src; } array[dst] = swap; } next: idx++; if (count + 1 < window) count++; if (idx >= window) idx = 0; } error = 0; on_error: for (i = 0; i < window; ++i) { git__free(array[i].index); git__free(array[i].data); } git__free(array); git_buf_free(&zbuf); return error; } #ifdef GIT_THREADS struct thread_params { git_thread thread; git_packbuilder *pb; git_pobject **list; git_cond cond; git_mutex mutex; unsigned int list_size; unsigned int remaining; int window; int depth; int working; int data_ready; }; static void *threaded_find_deltas(void *arg) { struct thread_params *me = arg; while (me->remaining) { if (find_deltas(me->pb, me->list, &me->remaining, me->window, me->depth) < 0) { ; /* TODO */ } git_packbuilder__progress_lock(me->pb); me->working = 0; git_cond_signal(&me->pb->progress_cond); git_packbuilder__progress_unlock(me->pb); if (git_mutex_lock(&me->mutex)) { giterr_set(GITERR_THREAD, "unable to lock packfile condition mutex"); return NULL; } while (!me->data_ready) git_cond_wait(&me->cond, &me->mutex); /* * We must not set ->data_ready before we wait on the * condition because the main thread may have set it to 1 * before we get here. In order to be sure that new * work is available if we see 1 in ->data_ready, it * was initialized to 0 before this thread was spawned * and we reset it to 0 right away. */ me->data_ready = 0; git_mutex_unlock(&me->mutex); } /* leave ->working 1 so that this doesn't get more work assigned */ return NULL; } static int ll_find_deltas(git_packbuilder *pb, git_pobject **list, unsigned int list_size, unsigned int window, int depth) { struct thread_params *p; int i, ret, active_threads = 0; if (!pb->nr_threads) pb->nr_threads = git_online_cpus(); if (pb->nr_threads <= 1) { find_deltas(pb, list, &list_size, window, depth); return 0; } p = git__mallocarray(pb->nr_threads, sizeof(*p)); GITERR_CHECK_ALLOC(p); /* Partition the work among the threads */ for (i = 0; i < pb->nr_threads; ++i) { unsigned sub_size = list_size / (pb->nr_threads - i); /* don't use too small segments or no deltas will be found */ if (sub_size < 2*window && i+1 < pb->nr_threads) sub_size = 0; p[i].pb = pb; p[i].window = window; p[i].depth = depth; p[i].working = 1; p[i].data_ready = 0; /* try to split chunks on "path" boundaries */ while (sub_size && sub_size < list_size && list[sub_size]->hash && list[sub_size]->hash == list[sub_size-1]->hash) sub_size++; p[i].list = list; p[i].list_size = sub_size; p[i].remaining = sub_size; list += sub_size; list_size -= sub_size; } /* Start work threads */ for (i = 0; i < pb->nr_threads; ++i) { if (!p[i].list_size) continue; git_mutex_init(&p[i].mutex); git_cond_init(&p[i].cond); ret = git_thread_create(&p[i].thread, NULL, threaded_find_deltas, &p[i]); if (ret) { giterr_set(GITERR_THREAD, "unable to create thread"); return -1; } active_threads++; } /* * Now let's wait for work completion. Each time a thread is done * with its work, we steal half of the remaining work from the * thread with the largest number of unprocessed objects and give * it to that newly idle thread. This ensure good load balancing * until the remaining object list segments are simply too short * to be worth splitting anymore. */ while (active_threads) { struct thread_params *target = NULL; struct thread_params *victim = NULL; unsigned sub_size = 0; /* Start by locating a thread that has transitioned its * 'working' flag from 1 -> 0. This indicates that it is * ready to receive more work using our work-stealing * algorithm. */ git_packbuilder__progress_lock(pb); for (;;) { for (i = 0; !target && i < pb->nr_threads; i++) if (!p[i].working) target = &p[i]; if (target) break; git_cond_wait(&pb->progress_cond, &pb->progress_mutex); } /* At this point we hold the progress lock and have located * a thread to receive more work. We still need to locate a * thread from which to steal work (the victim). */ for (i = 0; i < pb->nr_threads; i++) if (p[i].remaining > 2*window && (!victim || victim->remaining < p[i].remaining)) victim = &p[i]; if (victim) { sub_size = victim->remaining / 2; list = victim->list + victim->list_size - sub_size; while (sub_size && list[0]->hash && list[0]->hash == list[-1]->hash) { list++; sub_size--; } if (!sub_size) { /* * It is possible for some "paths" to have * so many objects that no hash boundary * might be found. Let's just steal the * exact half in that case. */ sub_size = victim->remaining / 2; list -= sub_size; } target->list = list; victim->list_size -= sub_size; victim->remaining -= sub_size; } target->list_size = sub_size; target->remaining = sub_size; target->working = 1; git_packbuilder__progress_unlock(pb); if (git_mutex_lock(&target->mutex)) { giterr_set(GITERR_THREAD, "unable to lock packfile condition mutex"); git__free(p); return -1; } target->data_ready = 1; git_cond_signal(&target->cond); git_mutex_unlock(&target->mutex); if (!sub_size) { git_thread_join(&target->thread, NULL); git_cond_free(&target->cond); git_mutex_free(&target->mutex); active_threads--; } } git__free(p); return 0; } #else #define ll_find_deltas(pb, l, ls, w, d) find_deltas(pb, l, &ls, w, d) #endif static int prepare_pack(git_packbuilder *pb) { git_pobject **delta_list; unsigned int i, n = 0; if (pb->nr_objects == 0 || pb->done) return 0; /* nothing to do */ /* * Although we do not report progress during deltafication, we * at least report that we are in the deltafication stage */ if (pb->progress_cb) pb->progress_cb(GIT_PACKBUILDER_DELTAFICATION, 0, pb->nr_objects, pb->progress_cb_payload); delta_list = git__mallocarray(pb->nr_objects, sizeof(*delta_list)); GITERR_CHECK_ALLOC(delta_list); for (i = 0; i < pb->nr_objects; ++i) { git_pobject *po = pb->object_list + i; /* Make sure the item is within our size limits */ if (po->size < 50 || po->size > pb->big_file_threshold) continue; delta_list[n++] = po; } if (n > 1) { git__tsort((void **)delta_list, n, type_size_sort); if (ll_find_deltas(pb, delta_list, n, GIT_PACK_WINDOW + 1, GIT_PACK_DEPTH) < 0) { git__free(delta_list); return -1; } } report_delta_progress(pb, pb->nr_objects, true); pb->done = true; git__free(delta_list); return 0; } #define PREPARE_PACK if (prepare_pack(pb) < 0) { return -1; } int git_packbuilder_foreach(git_packbuilder *pb, int (*cb)(void *buf, size_t size, void *payload), void *payload) { PREPARE_PACK; return write_pack(pb, cb, payload); } int git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb) { PREPARE_PACK; git_buf_sanitize(buf); return write_pack(pb, &write_pack_buf, buf); } static int write_cb(void *buf, size_t len, void *payload) { struct pack_write_context *ctx = payload; return git_indexer_append(ctx->indexer, buf, len, ctx->stats); } int git_packbuilder_write( git_packbuilder *pb, const char *path, unsigned int mode, git_transfer_progress_cb progress_cb, void *progress_cb_payload) { git_indexer *indexer; git_transfer_progress stats; struct pack_write_context ctx; PREPARE_PACK; if (git_indexer_new( &indexer, path, mode, pb->odb, progress_cb, progress_cb_payload) < 0) return -1; ctx.indexer = indexer; ctx.stats = &stats; if (git_packbuilder_foreach(pb, write_cb, &ctx) < 0 || git_indexer_commit(indexer, &stats) < 0) { git_indexer_free(indexer); return -1; } git_oid_cpy(&pb->pack_oid, git_indexer_hash(indexer)); git_indexer_free(indexer); return 0; } #undef PREPARE_PACK const git_oid *git_packbuilder_hash(git_packbuilder *pb) { return &pb->pack_oid; } static int cb_tree_walk( const char *root, const git_tree_entry *entry, void *payload) { int error; struct tree_walk_context *ctx = payload; /* A commit inside a tree represents a submodule commit and should be skipped. */ if (git_tree_entry_type(entry) == GIT_OBJ_COMMIT) return 0; if (!(error = git_buf_sets(&ctx->buf, root)) && !(error = git_buf_puts(&ctx->buf, git_tree_entry_name(entry)))) error = git_packbuilder_insert( ctx->pb, git_tree_entry_id(entry), git_buf_cstr(&ctx->buf)); return error; } int git_packbuilder_insert_commit(git_packbuilder *pb, const git_oid *oid) { git_commit *commit; if (git_commit_lookup(&commit, pb->repo, oid) < 0 || git_packbuilder_insert(pb, oid, NULL) < 0) return -1; if (git_packbuilder_insert_tree(pb, git_commit_tree_id(commit)) < 0) return -1; git_commit_free(commit); return 0; } int git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *oid) { int error; git_tree *tree = NULL; struct tree_walk_context context = { pb, GIT_BUF_INIT }; if (!(error = git_tree_lookup(&tree, pb->repo, oid)) && !(error = git_packbuilder_insert(pb, oid, NULL))) error = git_tree_walk(tree, GIT_TREEWALK_PRE, cb_tree_walk, &context); git_tree_free(tree); git_buf_free(&context.buf); return error; } int git_packbuilder_insert_recur(git_packbuilder *pb, const git_oid *id, const char *name) { git_object *obj; int error; assert(pb && id); if ((error = git_object_lookup(&obj, pb->repo, id, GIT_OBJ_ANY)) < 0) return error; switch (git_object_type(obj)) { case GIT_OBJ_BLOB: error = git_packbuilder_insert(pb, id, name); break; case GIT_OBJ_TREE: error = git_packbuilder_insert_tree(pb, id); break; case GIT_OBJ_COMMIT: error = git_packbuilder_insert_commit(pb, id); break; case GIT_OBJ_TAG: if ((error = git_packbuilder_insert(pb, id, name)) < 0) goto cleanup; error = git_packbuilder_insert_recur(pb, git_tag_target_id((git_tag *) obj), NULL); break; default: giterr_set(GITERR_INVALID, "unknown object type"); error = -1; } cleanup: git_object_free(obj); return error; } uint32_t git_packbuilder_object_count(git_packbuilder *pb) { return pb->nr_objects; } uint32_t git_packbuilder_written(git_packbuilder *pb) { return pb->nr_written; } int lookup_walk_object(git_walk_object **out, git_packbuilder *pb, const git_oid *id) { git_walk_object *obj; obj = git_pool_mallocz(&pb->object_pool, 1); if (!obj) { giterr_set_oom(); return -1; } git_oid_cpy(&obj->id, id); *out = obj; return 0; } static int retrieve_object(git_walk_object **out, git_packbuilder *pb, const git_oid *id) { int error; khiter_t pos; git_walk_object *obj; pos = git_oidmap_lookup_index(pb->walk_objects, id); if (git_oidmap_valid_index(pb->walk_objects, pos)) { obj = git_oidmap_value_at(pb->walk_objects, pos); } else { if ((error = lookup_walk_object(&obj, pb, id)) < 0) return error; git_oidmap_insert(pb->walk_objects, &obj->id, obj, error); } *out = obj; return 0; } static int mark_blob_uninteresting(git_packbuilder *pb, const git_oid *id) { int error; git_walk_object *obj; if ((error = retrieve_object(&obj, pb, id)) < 0) return error; obj->uninteresting = 1; return 0; } static int mark_tree_uninteresting(git_packbuilder *pb, const git_oid *id) { git_walk_object *obj; git_tree *tree; int error; size_t i; if ((error = retrieve_object(&obj, pb, id)) < 0) return error; if (obj->uninteresting) return 0; obj->uninteresting = 1; if ((error = git_tree_lookup(&tree, pb->repo, id)) < 0) return error; for (i = 0; i < git_tree_entrycount(tree); i++) { const git_tree_entry *entry = git_tree_entry_byindex(tree, i); const git_oid *entry_id = git_tree_entry_id(entry); switch (git_tree_entry_type(entry)) { case GIT_OBJ_TREE: if ((error = mark_tree_uninteresting(pb, entry_id)) < 0) goto cleanup; break; case GIT_OBJ_BLOB: if ((error = mark_blob_uninteresting(pb, entry_id)) < 0) goto cleanup; break; default: /* it's a submodule or something unknown, we don't want it */ ; } } cleanup: git_tree_free(tree); return error; } /* * Mark the edges of the graph uninteresting. Since we start from a * git_revwalk, the commits are already uninteresting, but we need to * mark the trees and blobs. */ static int mark_edges_uninteresting(git_packbuilder *pb, git_commit_list *commits) { int error; git_commit_list *list; git_commit *commit; for (list = commits; list; list = list->next) { if (!list->item->uninteresting) continue; if ((error = git_commit_lookup(&commit, pb->repo, &list->item->oid)) < 0) return error; error = mark_tree_uninteresting(pb, git_commit_tree_id(commit)); git_commit_free(commit); if (error < 0) return error; } return 0; } int insert_tree(git_packbuilder *pb, git_tree *tree) { size_t i; int error; git_tree *subtree; git_walk_object *obj; const char *name; if ((error = retrieve_object(&obj, pb, git_tree_id(tree))) < 0) return error; if (obj->seen) return 0; obj->seen = 1; if ((error = git_packbuilder_insert(pb, &obj->id, NULL))) return error; for (i = 0; i < git_tree_entrycount(tree); i++) { const git_tree_entry *entry = git_tree_entry_byindex(tree, i); const git_oid *entry_id = git_tree_entry_id(entry); switch (git_tree_entry_type(entry)) { case GIT_OBJ_TREE: if ((error = git_tree_lookup(&subtree, pb->repo, entry_id)) < 0) return error; error = insert_tree(pb, subtree); git_tree_free(subtree); if (error < 0) return error; break; case GIT_OBJ_BLOB: name = git_tree_entry_name(entry); if ((error = git_packbuilder_insert(pb, entry_id, name)) < 0) return error; break; default: /* it's a submodule or something unknown, we don't want it */ ; } } return error; } int insert_commit(git_packbuilder *pb, git_walk_object *obj) { int error; git_commit *commit = NULL; git_tree *tree = NULL; obj->seen = 1; if ((error = git_packbuilder_insert(pb, &obj->id, NULL)) < 0) return error; if ((error = git_commit_lookup(&commit, pb->repo, &obj->id)) < 0) return error; if ((error = git_tree_lookup(&tree, pb->repo, git_commit_tree_id(commit))) < 0) goto cleanup; if ((error = insert_tree(pb, tree)) < 0) goto cleanup; cleanup: git_commit_free(commit); git_tree_free(tree); return error; } int git_packbuilder_insert_walk(git_packbuilder *pb, git_revwalk *walk) { int error; git_oid id; git_walk_object *obj; assert(pb && walk); if ((error = mark_edges_uninteresting(pb, walk->user_input)) < 0) return error; /* * TODO: git marks the parents of the edges * uninteresting. This may provide a speed advantage, but does * seem to assume the remote does not have a single-commit * history on the other end. */ /* walk down each tree up to the blobs and insert them, stopping when uninteresting */ while ((error = git_revwalk_next(&id, walk)) == 0) { if ((error = retrieve_object(&obj, pb, &id)) < 0) return error; if (obj->seen || obj->uninteresting) continue; if ((error = insert_commit(pb, obj)) < 0) return error; } if (error == GIT_ITEROVER) error = 0; return 0; } int git_packbuilder_set_callbacks(git_packbuilder *pb, git_packbuilder_progress progress_cb, void *progress_cb_payload) { if (!pb) return -1; pb->progress_cb = progress_cb; pb->progress_cb_payload = progress_cb_payload; return 0; } void git_packbuilder_free(git_packbuilder *pb) { if (pb == NULL) return; #ifdef GIT_THREADS git_mutex_free(&pb->cache_mutex); git_mutex_free(&pb->progress_mutex); git_cond_free(&pb->progress_cond); #endif if (pb->odb) git_odb_free(pb->odb); if (pb->object_ix) git_oidmap_free(pb->object_ix); if (pb->object_list) git__free(pb->object_list); git_oidmap_free(pb->walk_objects); git_pool_clear(&pb->object_pool); git_hash_ctx_cleanup(&pb->ctx); git_zstream_free(&pb->zstream); git__free(pb); } deps/libgit2-sys-0.3.8/libgit2/src/bitvec.h0000664000175000017500000000334012426525445015330 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_bitvec_h__ #define INCLUDE_bitvec_h__ #include "common.h" /* * This is a silly little fixed length bit vector type that will store * vectors of 64 bits or less directly in the structure and allocate * memory for vectors longer than 64 bits. You can use the two versions * transparently through the API and avoid heap allocation completely when * using a short bit vector as a result. */ typedef struct { size_t length; union { uint64_t *words; uint64_t bits; } u; } git_bitvec; GIT_INLINE(int) git_bitvec_init(git_bitvec *bv, size_t capacity) { memset(bv, 0x0, sizeof(*bv)); if (capacity >= 64) { bv->length = (capacity / 64) + 1; bv->u.words = git__calloc(bv->length, sizeof(uint64_t)); if (!bv->u.words) return -1; } return 0; } #define GIT_BITVEC_MASK(BIT) ((uint64_t)1 << (BIT % 64)) #define GIT_BITVEC_WORD(BV, BIT) (BV->length ? &BV->u.words[BIT / 64] : &BV->u.bits) GIT_INLINE(void) git_bitvec_set(git_bitvec *bv, size_t bit, bool on) { uint64_t *word = GIT_BITVEC_WORD(bv, bit); uint64_t mask = GIT_BITVEC_MASK(bit); if (on) *word |= mask; else *word &= ~mask; } GIT_INLINE(bool) git_bitvec_get(git_bitvec *bv, size_t bit) { uint64_t *word = GIT_BITVEC_WORD(bv, bit); return (*word & GIT_BITVEC_MASK(bit)) != 0; } GIT_INLINE(void) git_bitvec_clear(git_bitvec *bv) { if (!bv->length) bv->u.bits = 0; else memset(bv->u.words, 0x0, bv->length * sizeof(uint64_t)); } GIT_INLINE(void) git_bitvec_free(git_bitvec *bv) { if (bv->length) git__free(bv->u.words); } #endif deps/libgit2-sys-0.3.8/libgit2/src/reflog.c0000664000175000017500000001170712555730137015332 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "reflog.h" #include "repository.h" #include "filebuf.h" #include "signature.h" #include "refdb.h" #include git_reflog_entry *git_reflog_entry__alloc(void) { return git__calloc(1, sizeof(git_reflog_entry)); } void git_reflog_entry__free(git_reflog_entry *entry) { git_signature_free(entry->committer); git__free(entry->msg); git__free(entry); } void git_reflog_free(git_reflog *reflog) { size_t i; git_reflog_entry *entry; if (reflog == NULL) return; if (reflog->db) GIT_REFCOUNT_DEC(reflog->db, git_refdb__free); for (i=0; i < reflog->entries.length; i++) { entry = git_vector_get(&reflog->entries, i); git_reflog_entry__free(entry); } git_vector_free(&reflog->entries); git__free(reflog->ref_name); git__free(reflog); } int git_reflog_read(git_reflog **reflog, git_repository *repo, const char *name) { git_refdb *refdb; int error; assert(reflog && repo && name); if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0) return error; return git_refdb_reflog_read(reflog, refdb, name); } int git_reflog_write(git_reflog *reflog) { git_refdb *db; assert(reflog && reflog->db); db = reflog->db; return db->backend->reflog_write(db->backend, reflog); } int git_reflog_append(git_reflog *reflog, const git_oid *new_oid, const git_signature *committer, const char *msg) { git_reflog_entry *entry; const git_reflog_entry *previous; const char *newline; assert(reflog && new_oid && committer); entry = git__calloc(1, sizeof(git_reflog_entry)); GITERR_CHECK_ALLOC(entry); if ((git_signature_dup(&entry->committer, committer)) < 0) goto cleanup; if (msg != NULL) { if ((entry->msg = git__strdup(msg)) == NULL) goto cleanup; newline = strchr(msg, '\n'); if (newline) { if (newline[1] != '\0') { giterr_set(GITERR_INVALID, "Reflog message cannot contain newline"); goto cleanup; } entry->msg[newline - msg] = '\0'; } } previous = git_reflog_entry_byindex(reflog, 0); if (previous == NULL) git_oid_fromstr(&entry->oid_old, GIT_OID_HEX_ZERO); else git_oid_cpy(&entry->oid_old, &previous->oid_cur); git_oid_cpy(&entry->oid_cur, new_oid); if (git_vector_insert(&reflog->entries, entry) < 0) goto cleanup; return 0; cleanup: git_reflog_entry__free(entry); return -1; } int git_reflog_rename(git_repository *repo, const char *old_name, const char *new_name) { git_refdb *refdb; int error; if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0) return -1; return refdb->backend->reflog_rename(refdb->backend, old_name, new_name); } int git_reflog_delete(git_repository *repo, const char *name) { git_refdb *refdb; int error; if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0) return -1; return refdb->backend->reflog_delete(refdb->backend, name); } size_t git_reflog_entrycount(git_reflog *reflog) { assert(reflog); return reflog->entries.length; } const git_reflog_entry * git_reflog_entry_byindex(const git_reflog *reflog, size_t idx) { assert(reflog); if (idx >= reflog->entries.length) return NULL; return git_vector_get( &reflog->entries, reflog_inverse_index(idx, reflog->entries.length)); } const git_oid * git_reflog_entry_id_old(const git_reflog_entry *entry) { assert(entry); return &entry->oid_old; } const git_oid * git_reflog_entry_id_new(const git_reflog_entry *entry) { assert(entry); return &entry->oid_cur; } const git_signature * git_reflog_entry_committer(const git_reflog_entry *entry) { assert(entry); return entry->committer; } const char * git_reflog_entry_message(const git_reflog_entry *entry) { assert(entry); return entry->msg; } int git_reflog_drop(git_reflog *reflog, size_t idx, int rewrite_previous_entry) { size_t entrycount; git_reflog_entry *entry, *previous; entrycount = git_reflog_entrycount(reflog); entry = (git_reflog_entry *)git_reflog_entry_byindex(reflog, idx); if (entry == NULL) { giterr_set(GITERR_REFERENCE, "No reflog entry at index %"PRIuZ, idx); return GIT_ENOTFOUND; } git_reflog_entry__free(entry); if (git_vector_remove( &reflog->entries, reflog_inverse_index(idx, entrycount)) < 0) return -1; if (!rewrite_previous_entry) return 0; /* No need to rewrite anything when removing the most recent entry */ if (idx == 0) return 0; /* Have the latest entry just been dropped? */ if (entrycount == 1) return 0; entry = (git_reflog_entry *)git_reflog_entry_byindex(reflog, idx - 1); /* If the oldest entry has just been removed... */ if (idx == entrycount - 1) { /* ...clear the oid_old member of the "new" oldest entry */ if (git_oid_fromstr(&entry->oid_old, GIT_OID_HEX_ZERO) < 0) return -1; return 0; } previous = (git_reflog_entry *)git_reflog_entry_byindex(reflog, idx); git_oid_cpy(&entry->oid_old, &previous->oid_cur); return 0; } deps/libgit2-sys-0.3.8/libgit2/src/object.c0000664000175000017500000002530512510265101015302 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "git2/object.h" #include "common.h" #include "repository.h" #include "commit.h" #include "tree.h" #include "blob.h" #include "tag.h" static const int OBJECT_BASE_SIZE = 4096; typedef struct { const char *str; /* type name string */ size_t size; /* size in bytes of the object structure */ int (*parse)(void *self, git_odb_object *obj); void (*free)(void *self); } git_object_def; static git_object_def git_objects_table[] = { /* 0 = GIT_OBJ__EXT1 */ { "", 0, NULL, NULL }, /* 1 = GIT_OBJ_COMMIT */ { "commit", sizeof(git_commit), git_commit__parse, git_commit__free }, /* 2 = GIT_OBJ_TREE */ { "tree", sizeof(git_tree), git_tree__parse, git_tree__free }, /* 3 = GIT_OBJ_BLOB */ { "blob", sizeof(git_blob), git_blob__parse, git_blob__free }, /* 4 = GIT_OBJ_TAG */ { "tag", sizeof(git_tag), git_tag__parse, git_tag__free }, /* 5 = GIT_OBJ__EXT2 */ { "", 0, NULL, NULL }, /* 6 = GIT_OBJ_OFS_DELTA */ { "OFS_DELTA", 0, NULL, NULL }, /* 7 = GIT_OBJ_REF_DELTA */ { "REF_DELTA", 0, NULL, NULL }, }; int git_object__from_odb_object( git_object **object_out, git_repository *repo, git_odb_object *odb_obj, git_otype type) { int error; size_t object_size; git_object_def *def; git_object *object = NULL; assert(object_out); *object_out = NULL; /* Validate type match */ if (type != GIT_OBJ_ANY && type != odb_obj->cached.type) { giterr_set(GITERR_INVALID, "The requested type does not match the type in the ODB"); return GIT_ENOTFOUND; } if ((object_size = git_object__size(odb_obj->cached.type)) == 0) { giterr_set(GITERR_INVALID, "The requested type is invalid"); return GIT_ENOTFOUND; } /* Allocate and initialize base object */ object = git__calloc(1, object_size); GITERR_CHECK_ALLOC(object); git_oid_cpy(&object->cached.oid, &odb_obj->cached.oid); object->cached.type = odb_obj->cached.type; object->cached.size = odb_obj->cached.size; object->repo = repo; /* Parse raw object data */ def = &git_objects_table[odb_obj->cached.type]; assert(def->free && def->parse); if ((error = def->parse(object, odb_obj)) < 0) def->free(object); else *object_out = git_cache_store_parsed(&repo->objects, object); return error; } void git_object__free(void *obj) { git_otype type = ((git_object *)obj)->cached.type; if (type < 0 || ((size_t)type) >= ARRAY_SIZE(git_objects_table) || !git_objects_table[type].free) git__free(obj); else git_objects_table[type].free(obj); } int git_object_lookup_prefix( git_object **object_out, git_repository *repo, const git_oid *id, size_t len, git_otype type) { git_object *object = NULL; git_odb *odb = NULL; git_odb_object *odb_obj = NULL; int error = 0; assert(repo && object_out && id); if (len < GIT_OID_MINPREFIXLEN) { giterr_set(GITERR_OBJECT, "Ambiguous lookup - OID prefix is too short"); return GIT_EAMBIGUOUS; } error = git_repository_odb__weakptr(&odb, repo); if (error < 0) return error; if (len > GIT_OID_HEXSZ) len = GIT_OID_HEXSZ; if (len == GIT_OID_HEXSZ) { git_cached_obj *cached = NULL; /* We want to match the full id : we can first look up in the cache, * since there is no need to check for non ambiguousity */ cached = git_cache_get_any(&repo->objects, id); if (cached != NULL) { if (cached->flags == GIT_CACHE_STORE_PARSED) { object = (git_object *)cached; if (type != GIT_OBJ_ANY && type != object->cached.type) { git_object_free(object); giterr_set(GITERR_INVALID, "The requested type does not match the type in ODB"); return GIT_ENOTFOUND; } *object_out = object; return 0; } else if (cached->flags == GIT_CACHE_STORE_RAW) { odb_obj = (git_odb_object *)cached; } else { assert(!"Wrong caching type in the global object cache"); } } else { /* Object was not found in the cache, let's explore the backends. * We could just use git_odb_read_unique_short_oid, * it is the same cost for packed and loose object backends, * but it may be much more costly for sqlite and hiredis. */ error = git_odb_read(&odb_obj, odb, id); } } else { git_oid short_oid; /* We copy the first len*4 bits from id and fill the remaining with 0s */ memcpy(short_oid.id, id->id, (len + 1) / 2); if (len % 2) short_oid.id[len / 2] &= 0xF0; memset(short_oid.id + (len + 1) / 2, 0, (GIT_OID_HEXSZ - len) / 2); /* If len < GIT_OID_HEXSZ (a strict short oid was given), we have * 2 options : * - We always search in the cache first. If we find that short oid is * ambiguous, we can stop. But in all the other cases, we must then * explore all the backends (to find an object if there was match, * or to check that oid is not ambiguous if we have found 1 match in * the cache) * - We never explore the cache, go right to exploring the backends * We chose the latter : we explore directly the backends. */ error = git_odb_read_prefix(&odb_obj, odb, &short_oid, len); } if (error < 0) return error; error = git_object__from_odb_object(object_out, repo, odb_obj, type); git_odb_object_free(odb_obj); return error; } int git_object_lookup(git_object **object_out, git_repository *repo, const git_oid *id, git_otype type) { return git_object_lookup_prefix(object_out, repo, id, GIT_OID_HEXSZ, type); } void git_object_free(git_object *object) { if (object == NULL) return; git_cached_obj_decref(object); } const git_oid *git_object_id(const git_object *obj) { assert(obj); return &obj->cached.oid; } git_otype git_object_type(const git_object *obj) { assert(obj); return obj->cached.type; } git_repository *git_object_owner(const git_object *obj) { assert(obj); return obj->repo; } const char *git_object_type2string(git_otype type) { if (type < 0 || ((size_t) type) >= ARRAY_SIZE(git_objects_table)) return ""; return git_objects_table[type].str; } git_otype git_object_string2type(const char *str) { size_t i; if (!str || !*str) return GIT_OBJ_BAD; for (i = 0; i < ARRAY_SIZE(git_objects_table); i++) if (!strcmp(str, git_objects_table[i].str)) return (git_otype)i; return GIT_OBJ_BAD; } int git_object_typeisloose(git_otype type) { if (type < 0 || ((size_t) type) >= ARRAY_SIZE(git_objects_table)) return 0; return (git_objects_table[type].size > 0) ? 1 : 0; } size_t git_object__size(git_otype type) { if (type < 0 || ((size_t) type) >= ARRAY_SIZE(git_objects_table)) return 0; return git_objects_table[type].size; } static int dereference_object(git_object **dereferenced, git_object *obj) { git_otype type = git_object_type(obj); switch (type) { case GIT_OBJ_COMMIT: return git_commit_tree((git_tree **)dereferenced, (git_commit*)obj); case GIT_OBJ_TAG: return git_tag_target(dereferenced, (git_tag*)obj); case GIT_OBJ_BLOB: case GIT_OBJ_TREE: return GIT_EPEEL; default: return GIT_EINVALIDSPEC; } } static int peel_error(int error, const git_oid *oid, git_otype type) { const char *type_name; char hex_oid[GIT_OID_HEXSZ + 1]; type_name = git_object_type2string(type); git_oid_fmt(hex_oid, oid); hex_oid[GIT_OID_HEXSZ] = '\0'; giterr_set(GITERR_OBJECT, "The git_object of id '%s' can not be " "successfully peeled into a %s (git_otype=%i).", hex_oid, type_name, type); return error; } static int check_type_combination(git_otype type, git_otype target) { if (type == target) return 0; switch (type) { case GIT_OBJ_BLOB: case GIT_OBJ_TREE: /* a blob or tree can never be peeled to anything but themselves */ return GIT_EINVALIDSPEC; break; case GIT_OBJ_COMMIT: /* a commit can only be peeled to a tree */ if (target != GIT_OBJ_TREE && target != GIT_OBJ_ANY) return GIT_EINVALIDSPEC; break; case GIT_OBJ_TAG: /* a tag may point to anything, so we let anything through */ break; default: return GIT_EINVALIDSPEC; } return 0; } int git_object_peel( git_object **peeled, const git_object *object, git_otype target_type) { git_object *source, *deref = NULL; int error; assert(object && peeled); assert(target_type == GIT_OBJ_TAG || target_type == GIT_OBJ_COMMIT || target_type == GIT_OBJ_TREE || target_type == GIT_OBJ_BLOB || target_type == GIT_OBJ_ANY); if ((error = check_type_combination(git_object_type(object), target_type)) < 0) return peel_error(error, git_object_id(object), target_type); if (git_object_type(object) == target_type) return git_object_dup(peeled, (git_object *)object); source = (git_object *)object; while (!(error = dereference_object(&deref, source))) { if (source != object) git_object_free(source); if (git_object_type(deref) == target_type) { *peeled = deref; return 0; } if (target_type == GIT_OBJ_ANY && git_object_type(deref) != git_object_type(object)) { *peeled = deref; return 0; } source = deref; deref = NULL; } if (source != object) git_object_free(source); git_object_free(deref); if (error) error = peel_error(error, git_object_id(object), target_type); return error; } int git_object_dup(git_object **dest, git_object *source) { git_cached_obj_incref(source); *dest = source; return 0; } int git_object_lookup_bypath( git_object **out, const git_object *treeish, const char *path, git_otype type) { int error = -1; git_tree *tree = NULL; git_tree_entry *entry = NULL; assert(out && treeish && path); if ((error = git_object_peel((git_object**)&tree, treeish, GIT_OBJ_TREE)) < 0 || (error = git_tree_entry_bypath(&entry, tree, path)) < 0) { goto cleanup; } if (type != GIT_OBJ_ANY && git_tree_entry_type(entry) != type) { giterr_set(GITERR_OBJECT, "object at path '%s' is not of the asked-for type %d", path, type); error = GIT_EINVALIDSPEC; goto cleanup; } error = git_tree_entry_to_object(out, git_object_owner(treeish), entry); cleanup: git_tree_entry_free(entry); git_tree_free(tree); return error; } int git_object_short_id(git_buf *out, const git_object *obj) { git_repository *repo; int len = GIT_ABBREV_DEFAULT, error; git_oid id = {{0}}; git_odb *odb; assert(out && obj); git_buf_sanitize(out); repo = git_object_owner(obj); if ((error = git_repository__cvar(&len, repo, GIT_CVAR_ABBREV)) < 0) return error; if ((error = git_repository_odb(&odb, repo)) < 0) return error; while (len < GIT_OID_HEXSZ) { /* set up short oid */ memcpy(&id.id, &obj->cached.oid.id, (len + 1) / 2); if (len & 1) id.id[len / 2] &= 0xf0; error = git_odb_exists_prefix(NULL, odb, &id, len); if (error != GIT_EAMBIGUOUS) break; giterr_clear(); len++; } if (!error && !(error = git_buf_grow(out, len + 1))) { git_oid_tostr(out->ptr, len + 1, &id); out->size = len; } git_odb_free(odb); return error; } deps/libgit2-sys-0.3.8/libgit2/src/branch.c0000664000175000017500000003670012572105236015304 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #include "common.h" #include "commit.h" #include "tag.h" #include "config.h" #include "refspec.h" #include "refs.h" #include "remote.h" #include "annotated_commit.h" #include "git2/branch.h" static int retrieve_branch_reference( git_reference **branch_reference_out, git_repository *repo, const char *branch_name, int is_remote) { git_reference *branch = NULL; int error = 0; char *prefix; git_buf ref_name = GIT_BUF_INIT; prefix = is_remote ? GIT_REFS_REMOTES_DIR : GIT_REFS_HEADS_DIR; if ((error = git_buf_joinpath(&ref_name, prefix, branch_name)) < 0) /* OOM */; else if ((error = git_reference_lookup(&branch, repo, ref_name.ptr)) < 0) giterr_set( GITERR_REFERENCE, "Cannot locate %s branch '%s'", is_remote ? "remote-tracking" : "local", branch_name); *branch_reference_out = branch; /* will be NULL on error */ git_buf_free(&ref_name); return error; } static int not_a_local_branch(const char *reference_name) { giterr_set( GITERR_INVALID, "Reference '%s' is not a local branch.", reference_name); return -1; } static int create_branch( git_reference **ref_out, git_repository *repository, const char *branch_name, const git_commit *commit, const char *from, int force) { int is_head = 0; git_reference *branch = NULL; git_buf canonical_branch_name = GIT_BUF_INIT, log_message = GIT_BUF_INIT; int error = -1; assert(branch_name && commit && ref_out); assert(git_object_owner((const git_object *)commit) == repository); if (force && git_branch_lookup(&branch, repository, branch_name, GIT_BRANCH_LOCAL) == 0) { error = git_branch_is_head(branch); git_reference_free(branch); branch = NULL; if (error < 0) goto cleanup; is_head = error; } if (is_head && force) { giterr_set(GITERR_REFERENCE, "Cannot force update branch '%s' as it is " "the current HEAD of the repository.", branch_name); error = -1; goto cleanup; } if (git_buf_joinpath(&canonical_branch_name, GIT_REFS_HEADS_DIR, branch_name) < 0) goto cleanup; if (git_buf_printf(&log_message, "branch: Created from %s", from) < 0) goto cleanup; error = git_reference_create(&branch, repository, git_buf_cstr(&canonical_branch_name), git_commit_id(commit), force, git_buf_cstr(&log_message)); if (!error) *ref_out = branch; cleanup: git_buf_free(&canonical_branch_name); git_buf_free(&log_message); return error; } int git_branch_create( git_reference **ref_out, git_repository *repository, const char *branch_name, const git_commit *commit, int force) { return create_branch(ref_out, repository, branch_name, commit, git_oid_tostr_s(git_commit_id(commit)), force); } int git_branch_create_from_annotated( git_reference **ref_out, git_repository *repository, const char *branch_name, const git_annotated_commit *commit, int force) { return create_branch(ref_out, repository, branch_name, commit->commit, commit->ref_name, force); } int git_branch_delete(git_reference *branch) { int is_head; git_buf config_section = GIT_BUF_INIT; int error = -1; assert(branch); if (!git_reference_is_branch(branch) && !git_reference_is_remote(branch)) { giterr_set(GITERR_INVALID, "Reference '%s' is not a valid branch.", git_reference_name(branch)); return GIT_ENOTFOUND; } if ((is_head = git_branch_is_head(branch)) < 0) return is_head; if (is_head) { giterr_set(GITERR_REFERENCE, "Cannot delete branch '%s' as it is " "the current HEAD of the repository.", git_reference_name(branch)); return -1; } if (git_buf_join(&config_section, '.', "branch", git_reference_name(branch) + strlen(GIT_REFS_HEADS_DIR)) < 0) goto on_error; if (git_config_rename_section( git_reference_owner(branch), git_buf_cstr(&config_section), NULL) < 0) goto on_error; error = git_reference_delete(branch); on_error: git_buf_free(&config_section); return error; } typedef struct { git_reference_iterator *iter; unsigned int flags; } branch_iter; int git_branch_next(git_reference **out, git_branch_t *out_type, git_branch_iterator *_iter) { branch_iter *iter = (branch_iter *) _iter; git_reference *ref; int error; while ((error = git_reference_next(&ref, iter->iter)) == 0) { if ((iter->flags & GIT_BRANCH_LOCAL) && !git__prefixcmp(ref->name, GIT_REFS_HEADS_DIR)) { *out = ref; *out_type = GIT_BRANCH_LOCAL; return 0; } else if ((iter->flags & GIT_BRANCH_REMOTE) && !git__prefixcmp(ref->name, GIT_REFS_REMOTES_DIR)) { *out = ref; *out_type = GIT_BRANCH_REMOTE; return 0; } else { git_reference_free(ref); } } return error; } int git_branch_iterator_new( git_branch_iterator **out, git_repository *repo, git_branch_t list_flags) { branch_iter *iter; iter = git__calloc(1, sizeof(branch_iter)); GITERR_CHECK_ALLOC(iter); iter->flags = list_flags; if (git_reference_iterator_new(&iter->iter, repo) < 0) { git__free(iter); return -1; } *out = (git_branch_iterator *) iter; return 0; } void git_branch_iterator_free(git_branch_iterator *_iter) { branch_iter *iter = (branch_iter *) _iter; if (iter == NULL) return; git_reference_iterator_free(iter->iter); git__free(iter); } int git_branch_move( git_reference **out, git_reference *branch, const char *new_branch_name, int force) { git_buf new_reference_name = GIT_BUF_INIT, old_config_section = GIT_BUF_INIT, new_config_section = GIT_BUF_INIT, log_message = GIT_BUF_INIT; int error; assert(branch && new_branch_name); if (!git_reference_is_branch(branch)) return not_a_local_branch(git_reference_name(branch)); if ((error = git_buf_joinpath(&new_reference_name, GIT_REFS_HEADS_DIR, new_branch_name)) < 0) goto done; if ((error = git_buf_printf(&log_message, "branch: renamed %s to %s", git_reference_name(branch), git_buf_cstr(&new_reference_name))) < 0) goto done; /* first update ref then config so failure won't trash config */ error = git_reference_rename( out, branch, git_buf_cstr(&new_reference_name), force, git_buf_cstr(&log_message)); if (error < 0) goto done; git_buf_join(&old_config_section, '.', "branch", git_reference_name(branch) + strlen(GIT_REFS_HEADS_DIR)); git_buf_join(&new_config_section, '.', "branch", new_branch_name); error = git_config_rename_section( git_reference_owner(branch), git_buf_cstr(&old_config_section), git_buf_cstr(&new_config_section)); done: git_buf_free(&new_reference_name); git_buf_free(&old_config_section); git_buf_free(&new_config_section); git_buf_free(&log_message); return error; } int git_branch_lookup( git_reference **ref_out, git_repository *repo, const char *branch_name, git_branch_t branch_type) { assert(ref_out && repo && branch_name); return retrieve_branch_reference(ref_out, repo, branch_name, branch_type == GIT_BRANCH_REMOTE); } int git_branch_name( const char **out, const git_reference *ref) { const char *branch_name; assert(out && ref); branch_name = ref->name; if (git_reference_is_branch(ref)) { branch_name += strlen(GIT_REFS_HEADS_DIR); } else if (git_reference_is_remote(ref)) { branch_name += strlen(GIT_REFS_REMOTES_DIR); } else { giterr_set(GITERR_INVALID, "Reference '%s' is neither a local nor a remote branch.", ref->name); return -1; } *out = branch_name; return 0; } static int retrieve_upstream_configuration( git_buf *out, const git_config *config, const char *canonical_branch_name, const char *format) { git_buf buf = GIT_BUF_INIT; int error; if (git_buf_printf(&buf, format, canonical_branch_name + strlen(GIT_REFS_HEADS_DIR)) < 0) return -1; error = git_config_get_string_buf(out, config, git_buf_cstr(&buf)); git_buf_free(&buf); return error; } int git_branch_upstream_name( git_buf *out, git_repository *repo, const char *refname) { git_buf remote_name = GIT_BUF_INIT; git_buf merge_name = GIT_BUF_INIT; git_buf buf = GIT_BUF_INIT; int error = -1; git_remote *remote = NULL; const git_refspec *refspec; git_config *config; assert(out && refname); git_buf_sanitize(out); if (!git_reference__is_branch(refname)) return not_a_local_branch(refname); if ((error = git_repository_config_snapshot(&config, repo)) < 0) return error; if ((error = retrieve_upstream_configuration( &remote_name, config, refname, "branch.%s.remote")) < 0) goto cleanup; if ((error = retrieve_upstream_configuration( &merge_name, config, refname, "branch.%s.merge")) < 0) goto cleanup; if (git_buf_len(&remote_name) == 0 || git_buf_len(&merge_name) == 0) { giterr_set(GITERR_REFERENCE, "branch '%s' does not have an upstream", refname); error = GIT_ENOTFOUND; goto cleanup; } if (strcmp(".", git_buf_cstr(&remote_name)) != 0) { if ((error = git_remote_lookup(&remote, repo, git_buf_cstr(&remote_name))) < 0) goto cleanup; refspec = git_remote__matching_refspec(remote, git_buf_cstr(&merge_name)); if (!refspec) { error = GIT_ENOTFOUND; goto cleanup; } if (git_refspec_transform(&buf, refspec, git_buf_cstr(&merge_name)) < 0) goto cleanup; } else if (git_buf_set(&buf, git_buf_cstr(&merge_name), git_buf_len(&merge_name)) < 0) goto cleanup; error = git_buf_set(out, git_buf_cstr(&buf), git_buf_len(&buf)); cleanup: git_config_free(config); git_remote_free(remote); git_buf_free(&remote_name); git_buf_free(&merge_name); git_buf_free(&buf); return error; } int git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *refname) { int error; git_config *cfg; if (!git_reference__is_branch(refname)) return not_a_local_branch(refname); if ((error = git_repository_config__weakptr(&cfg, repo)) < 0) return error; git_buf_sanitize(buf); if ((error = retrieve_upstream_configuration(buf, cfg, refname, "branch.%s.remote")) < 0) return error; if (git_buf_len(buf) == 0) { giterr_set(GITERR_REFERENCE, "branch '%s' does not have an upstream remote", refname); error = GIT_ENOTFOUND; git_buf_clear(buf); } return error; } int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refname) { git_strarray remote_list = {0}; size_t i; git_remote *remote; const git_refspec *fetchspec; int error = 0; char *remote_name = NULL; assert(buf && repo && refname); git_buf_sanitize(buf); /* Verify that this is a remote branch */ if (!git_reference__is_remote(refname)) { giterr_set(GITERR_INVALID, "Reference '%s' is not a remote branch.", refname); error = GIT_ERROR; goto cleanup; } /* Get the remotes */ if ((error = git_remote_list(&remote_list, repo)) < 0) goto cleanup; /* Find matching remotes */ for (i = 0; i < remote_list.count; i++) { if ((error = git_remote_lookup(&remote, repo, remote_list.strings[i])) < 0) continue; fetchspec = git_remote__matching_dst_refspec(remote, refname); if (fetchspec) { /* If we have not already set out yet, then set * it to the matching remote name. Otherwise * multiple remotes match this reference, and it * is ambiguous. */ if (!remote_name) { remote_name = remote_list.strings[i]; } else { git_remote_free(remote); giterr_set(GITERR_REFERENCE, "Reference '%s' is ambiguous", refname); error = GIT_EAMBIGUOUS; goto cleanup; } } git_remote_free(remote); } if (remote_name) { git_buf_clear(buf); error = git_buf_puts(buf, remote_name); } else { giterr_set(GITERR_REFERENCE, "Could not determine remote for '%s'", refname); error = GIT_ENOTFOUND; } cleanup: if (error < 0) git_buf_free(buf); git_strarray_free(&remote_list); return error; } int git_branch_upstream( git_reference **tracking_out, const git_reference *branch) { int error; git_buf tracking_name = GIT_BUF_INIT; if ((error = git_branch_upstream_name(&tracking_name, git_reference_owner(branch), git_reference_name(branch))) < 0) return error; error = git_reference_lookup( tracking_out, git_reference_owner(branch), git_buf_cstr(&tracking_name)); git_buf_free(&tracking_name); return error; } static int unset_upstream(git_config *config, const char *shortname) { git_buf buf = GIT_BUF_INIT; if (git_buf_printf(&buf, "branch.%s.remote", shortname) < 0) return -1; if (git_config_delete_entry(config, git_buf_cstr(&buf)) < 0) goto on_error; git_buf_clear(&buf); if (git_buf_printf(&buf, "branch.%s.merge", shortname) < 0) goto on_error; if (git_config_delete_entry(config, git_buf_cstr(&buf)) < 0) goto on_error; git_buf_free(&buf); return 0; on_error: git_buf_free(&buf); return -1; } int git_branch_set_upstream(git_reference *branch, const char *upstream_name) { git_buf key = GIT_BUF_INIT, value = GIT_BUF_INIT; git_reference *upstream; git_repository *repo; git_remote *remote = NULL; git_config *config; const char *name, *shortname; int local, error; const git_refspec *fetchspec; name = git_reference_name(branch); if (!git_reference__is_branch(name)) return not_a_local_branch(name); if (git_repository_config__weakptr(&config, git_reference_owner(branch)) < 0) return -1; shortname = name + strlen(GIT_REFS_HEADS_DIR); if (upstream_name == NULL) return unset_upstream(config, shortname); repo = git_reference_owner(branch); /* First we need to figure out whether it's a branch or remote-tracking */ if (git_branch_lookup(&upstream, repo, upstream_name, GIT_BRANCH_LOCAL) == 0) local = 1; else if (git_branch_lookup(&upstream, repo, upstream_name, GIT_BRANCH_REMOTE) == 0) local = 0; else { giterr_set(GITERR_REFERENCE, "Cannot set upstream for branch '%s'", shortname); return GIT_ENOTFOUND; } /* * If it's local, the remote is "." and the branch name is * simply the refname. Otherwise we need to figure out what * the remote-tracking branch's name on the remote is and use * that. */ if (local) error = git_buf_puts(&value, "."); else error = git_branch_remote_name(&value, repo, git_reference_name(upstream)); if (error < 0) goto on_error; if (git_buf_printf(&key, "branch.%s.remote", shortname) < 0) goto on_error; if (git_config_set_string(config, git_buf_cstr(&key), git_buf_cstr(&value)) < 0) goto on_error; if (local) { git_buf_clear(&value); if (git_buf_puts(&value, git_reference_name(upstream)) < 0) goto on_error; } else { /* Get the remoe-tracking branch's refname in its repo */ if (git_remote_lookup(&remote, repo, git_buf_cstr(&value)) < 0) goto on_error; fetchspec = git_remote__matching_dst_refspec(remote, git_reference_name(upstream)); git_buf_clear(&value); if (!fetchspec || git_refspec_rtransform(&value, fetchspec, git_reference_name(upstream)) < 0) goto on_error; git_remote_free(remote); remote = NULL; } git_buf_clear(&key); if (git_buf_printf(&key, "branch.%s.merge", shortname) < 0) goto on_error; if (git_config_set_string(config, git_buf_cstr(&key), git_buf_cstr(&value)) < 0) goto on_error; git_reference_free(upstream); git_buf_free(&key); git_buf_free(&value); return 0; on_error: git_reference_free(upstream); git_buf_free(&key); git_buf_free(&value); git_remote_free(remote); return -1; } int git_branch_is_head( const git_reference *branch) { git_reference *head; bool is_same = false; int error; assert(branch); if (!git_reference_is_branch(branch)) return false; error = git_repository_head(&head, git_reference_owner(branch)); if (error == GIT_EUNBORNBRANCH || error == GIT_ENOTFOUND) return false; if (error < 0) return -1; is_same = strcmp( git_reference_name(branch), git_reference_name(head)) == 0; git_reference_free(head); return is_same; } deps/libgit2-sys-0.3.8/libgit2/src/stransport_stream.c0000664000175000017500000001630612572105236017641 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifdef GIT_SECURE_TRANSPORT #include #include #include #include "git2/transport.h" #include "socket_stream.h" #include "curl_stream.h" int stransport_error(OSStatus ret) { CFStringRef message; if (ret == noErr || ret == errSSLClosedGraceful) { giterr_clear(); return 0; } #if !TARGET_OS_IPHONE message = SecCopyErrorMessageString(ret, NULL); GITERR_CHECK_ALLOC(message); giterr_set(GITERR_NET, "SecureTransport error: %s", CFStringGetCStringPtr(message, kCFStringEncodingUTF8)); CFRelease(message); #else giterr_set(GITERR_NET, "SecureTransport error: OSStatus %d", (unsigned int)ret); #endif return -1; } typedef struct { git_stream parent; git_stream *io; SSLContextRef ctx; CFDataRef der_data; git_cert_x509 cert_info; } stransport_stream; int stransport_connect(git_stream *stream) { stransport_stream *st = (stransport_stream *) stream; int error; SecTrustRef trust = NULL; SecTrustResultType sec_res; OSStatus ret; if ((error = git_stream_connect(st->io)) < 0) return error; ret = SSLHandshake(st->ctx); if (ret != errSSLServerAuthCompleted) { giterr_set(GITERR_SSL, "unexpected return value from ssl handshake %d", ret); return -1; } if ((ret = SSLCopyPeerTrust(st->ctx, &trust)) != noErr) goto on_error; if ((ret = SecTrustEvaluate(trust, &sec_res)) != noErr) goto on_error; CFRelease(trust); if (sec_res == kSecTrustResultInvalid || sec_res == kSecTrustResultOtherError) { giterr_set(GITERR_SSL, "internal security trust error"); return -1; } if (sec_res == kSecTrustResultDeny || sec_res == kSecTrustResultRecoverableTrustFailure || sec_res == kSecTrustResultFatalTrustFailure) return GIT_ECERTIFICATE; return 0; on_error: if (trust) CFRelease(trust); return stransport_error(ret); } int stransport_certificate(git_cert **out, git_stream *stream) { stransport_stream *st = (stransport_stream *) stream; SecTrustRef trust = NULL; SecCertificateRef sec_cert; OSStatus ret; if ((ret = SSLCopyPeerTrust(st->ctx, &trust)) != noErr) return stransport_error(ret); sec_cert = SecTrustGetCertificateAtIndex(trust, 0); st->der_data = SecCertificateCopyData(sec_cert); CFRelease(trust); if (st->der_data == NULL) { giterr_set(GITERR_SSL, "retrieved invalid certificate data"); return -1; } st->cert_info.parent.cert_type = GIT_CERT_X509; st->cert_info.data = (void *) CFDataGetBytePtr(st->der_data); st->cert_info.len = CFDataGetLength(st->der_data); *out = (git_cert *)&st->cert_info; return 0; } int stransport_set_proxy(git_stream *stream, const char *proxy) { stransport_stream *st = (stransport_stream *) stream; return git_stream_set_proxy(st->io, proxy); } /* * Contrary to typical network IO callbacks, Secure Transport write callback is * expected to write *all* passed data, not just as much as it can, and any * other case would be considered a failure. * * This behavior is actually not specified in the Apple documentation, but is * required for things to work correctly (and incidentally, that's also how * Apple implements it in its projects at opensource.apple.com). * * Libgit2 streams happen to already have this very behavior so this is just * passthrough. */ static OSStatus write_cb(SSLConnectionRef conn, const void *data, size_t *len) { git_stream *io = (git_stream *) conn; if (git_stream_write(io, data, *len, 0) < 0) { return -36; /* "ioErr" from MacErrors.h which is not available on iOS */ } return noErr; } ssize_t stransport_write(git_stream *stream, const char *data, size_t len, int flags) { stransport_stream *st = (stransport_stream *) stream; size_t data_len, processed; OSStatus ret; GIT_UNUSED(flags); data_len = len; if ((ret = SSLWrite(st->ctx, data, data_len, &processed)) != noErr) return stransport_error(ret); return processed; } /* * Contrary to typical network IO callbacks, Secure Transport read callback is * expected to read *exactly* the requested number of bytes, not just as much * as it can, and any other case would be considered a failure. * * This behavior is actually not specified in the Apple documentation, but is * required for things to work correctly (and incidentally, that's also how * Apple implements it in its projects at opensource.apple.com). */ static OSStatus read_cb(SSLConnectionRef conn, void *data, size_t *len) { git_stream *io = (git_stream *) conn; OSStatus error = noErr; size_t off = 0; ssize_t ret; do { ret = git_stream_read(io, data + off, *len - off); if (ret < 0) { error = -36; /* "ioErr" from MacErrors.h which is not available on iOS */ break; } if (ret == 0) { error = errSSLClosedGraceful; break; } off += ret; } while (off < *len); *len = off; return error; } ssize_t stransport_read(git_stream *stream, void *data, size_t len) { stransport_stream *st = (stransport_stream *) stream; size_t processed; OSStatus ret; if ((ret = SSLRead(st->ctx, data, len, &processed)) != noErr) return stransport_error(ret); return processed; } int stransport_close(git_stream *stream) { stransport_stream *st = (stransport_stream *) stream; OSStatus ret; ret = SSLClose(st->ctx); if (ret != noErr && ret != errSSLClosedGraceful) return stransport_error(ret); return git_stream_close(st->io); } void stransport_free(git_stream *stream) { stransport_stream *st = (stransport_stream *) stream; git_stream_free(st->io); CFRelease(st->ctx); if (st->der_data) CFRelease(st->der_data); git__free(st); } int git_stransport_stream_new(git_stream **out, const char *host, const char *port) { stransport_stream *st; int error; OSStatus ret; assert(out && host); st = git__calloc(1, sizeof(stransport_stream)); GITERR_CHECK_ALLOC(st); #ifdef GIT_CURL error = git_curl_stream_new(&st->io, host, port); #else error = git_socket_stream_new(&st->io, host, port); #endif if (error < 0){ git__free(st); return error; } st->ctx = SSLCreateContext(NULL, kSSLClientSide, kSSLStreamType); if (!st->ctx) { giterr_set(GITERR_NET, "failed to create SSL context"); return -1; } if ((ret = SSLSetIOFuncs(st->ctx, read_cb, write_cb)) != noErr || (ret = SSLSetConnection(st->ctx, st->io)) != noErr || (ret = SSLSetSessionOption(st->ctx, kSSLSessionOptionBreakOnServerAuth, true)) != noErr || (ret = SSLSetProtocolVersionMin(st->ctx, kTLSProtocol1)) != noErr || (ret = SSLSetProtocolVersionMax(st->ctx, kTLSProtocol12)) != noErr || (ret = SSLSetPeerDomainName(st->ctx, host, strlen(host))) != noErr) { git_stream_free((git_stream *)st); return stransport_error(ret); } st->parent.version = GIT_STREAM_VERSION; st->parent.encrypted = 1; st->parent.proxy_support = git_stream_supports_proxy(st->io); st->parent.connect = stransport_connect; st->parent.certificate = stransport_certificate; st->parent.set_proxy = stransport_set_proxy; st->parent.read = stransport_read; st->parent.write = stransport_write; st->parent.close = stransport_close; st->parent.free = stransport_free; *out = (git_stream *) st; return 0; } #endif deps/libgit2-sys-0.3.8/libgit2/src/transaction.h0000664000175000017500000000057512572105236016402 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_transaction_h__ #define INCLUDE_transaction_h__ #include "common.h" int git_transaction_config_new(git_transaction **out, git_config *cfg); #endif deps/libgit2-sys-0.3.8/libgit2/src/path.h0000664000175000017500000004251512610310643015002 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_path_h__ #define INCLUDE_path_h__ #include "common.h" #include "posix.h" #include "buffer.h" #include "vector.h" /** * Path manipulation utils * * These are path utilities that munge paths without actually * looking at the real filesystem. */ /* * The dirname() function shall take a pointer to a character string * that contains a pathname, and return a pointer to a string that is a * pathname of the parent directory of that file. Trailing '/' characters * in the path are not counted as part of the path. * * If path does not contain a '/', then dirname() shall return a pointer to * the string ".". If path is a null pointer or points to an empty string, * dirname() shall return a pointer to the string "." . * * The `git_path_dirname` implementation is thread safe. The returned * string must be manually free'd. * * The `git_path_dirname_r` implementation writes the dirname to a `git_buf` * if the buffer pointer is not NULL. * It returns an error code < 0 if there is an allocation error, otherwise * the length of the dirname (which will be > 0). */ extern char *git_path_dirname(const char *path); extern int git_path_dirname_r(git_buf *buffer, const char *path); /* * This function returns the basename of the file, which is the last * part of its full name given by fname, with the drive letter and * leading directories stripped off. For example, the basename of * c:/foo/bar/file.ext is file.ext, and the basename of a:foo is foo. * * Trailing slashes and backslashes are significant: the basename of * c:/foo/bar/ is an empty string after the rightmost slash. * * The `git_path_basename` implementation is thread safe. The returned * string must be manually free'd. * * The `git_path_basename_r` implementation writes the basename to a `git_buf`. * It returns an error code < 0 if there is an allocation error, otherwise * the length of the basename (which will be >= 0). */ extern char *git_path_basename(const char *path); extern int git_path_basename_r(git_buf *buffer, const char *path); /* Return the offset of the start of the basename. Unlike the other * basename functions, this returns 0 if the path is empty. */ extern size_t git_path_basename_offset(git_buf *buffer); extern const char *git_path_topdir(const char *path); /** * Find offset to root of path if path has one. * * This will return a number >= 0 which is the offset to the start of the * path, if the path is rooted (i.e. "/rooted/path" returns 0 and * "c:/windows/rooted/path" returns 2). If the path is not rooted, this * returns -1. */ extern int git_path_root(const char *path); /** * Ensure path has a trailing '/'. */ extern int git_path_to_dir(git_buf *path); /** * Ensure string has a trailing '/' if there is space for it. */ extern void git_path_string_to_dir(char* path, size_t size); /** * Taken from git.git; returns nonzero if the given path is "." or "..". */ GIT_INLINE(int) git_path_is_dot_or_dotdot(const char *name) { return (name[0] == '.' && (name[1] == '\0' || (name[1] == '.' && name[2] == '\0'))); } #ifdef GIT_WIN32 GIT_INLINE(int) git_path_is_dot_or_dotdotW(const wchar_t *name) { return (name[0] == L'.' && (name[1] == L'\0' || (name[1] == L'.' && name[2] == L'\0'))); } /** * Convert backslashes in path to forward slashes. */ GIT_INLINE(void) git_path_mkposix(char *path) { while (*path) { if (*path == '\\') *path = '/'; path++; } } #else # define git_path_mkposix(p) /* blank */ #endif /** * Check if string is a relative path (i.e. starts with "./" or "../") */ GIT_INLINE(int) git_path_is_relative(const char *p) { return (p[0] == '.' && (p[1] == '/' || (p[1] == '.' && p[2] == '/'))); } /** * Check if string is at end of path segment (i.e. looking at '/' or '\0') */ GIT_INLINE(int) git_path_at_end_of_segment(const char *p) { return !*p || *p == '/'; } extern int git__percent_decode(git_buf *decoded_out, const char *input); /** * Extract path from file:// URL. */ extern int git_path_fromurl(git_buf *local_path_out, const char *file_url); /** * Path filesystem utils * * These are path utilities that actually access the filesystem. */ /** * Check if a file exists and can be accessed. * @return true or false */ extern bool git_path_exists(const char *path); /** * Check if the given path points to a directory. * @return true or false */ extern bool git_path_isdir(const char *path); /** * Check if the given path points to a regular file. * @return true or false */ extern bool git_path_isfile(const char *path); /** * Check if the given path points to a symbolic link. * @return true or false */ extern bool git_path_islink(const char *path); /** * Check if the given path is a directory, and is empty. */ extern bool git_path_is_empty_dir(const char *path); /** * Stat a file and/or link and set error if needed. */ extern int git_path_lstat(const char *path, struct stat *st); /** * Check if the parent directory contains the item. * * @param dir Directory to check. * @param item Item that might be in the directory. * @return 0 if item exists in directory, <0 otherwise. */ extern bool git_path_contains(git_buf *dir, const char *item); /** * Check if the given path contains the given subdirectory. * * @param parent Directory path that might contain subdir * @param subdir Subdirectory name to look for in parent * @return true if subdirectory exists, false otherwise. */ extern bool git_path_contains_dir(git_buf *parent, const char *subdir); /** * Make the path relative to the given parent path. * * @param path The path to make relative * @param parent The parent path to make path relative to * @return 0 if path was made relative, GIT_ENOTFOUND * if there was not common root between the paths, * or <0. */ extern int git_path_make_relative(git_buf *path, const char *parent); /** * Check if the given path contains the given file. * * @param dir Directory path that might contain file * @param file File name to look for in parent * @return true if file exists, false otherwise. */ extern bool git_path_contains_file(git_buf *dir, const char *file); /** * Prepend base to unrooted path or just copy path over. * * This will optionally return the index into the path where the "root" * is, either the end of the base directory prefix or the path root. */ extern int git_path_join_unrooted( git_buf *path_out, const char *path, const char *base, ssize_t *root_at); /** * Clean up path, prepending base if it is not already rooted. */ extern int git_path_prettify(git_buf *path_out, const char *path, const char *base); /** * Clean up path, prepending base if it is not already rooted and * appending a slash. */ extern int git_path_prettify_dir(git_buf *path_out, const char *path, const char *base); /** * Get a directory from a path. * * If path is a directory, this acts like `git_path_prettify_dir` * (cleaning up path and appending a '/'). If path is a normal file, * this prettifies it, then removed the filename a la dirname and * appends the trailing '/'. If the path does not exist, it is * treated like a regular filename. */ extern int git_path_find_dir(git_buf *dir, const char *path, const char *base); /** * Resolve relative references within a path. * * This eliminates "./" and "../" relative references inside a path, * as well as condensing multiple slashes into single ones. It will * not touch the path before the "ceiling" length. * * Additionally, this will recognize an "c:/" drive prefix or a "xyz://" URL * prefix and not touch that part of the path. */ extern int git_path_resolve_relative(git_buf *path, size_t ceiling); /** * Apply a relative path to base path. * * Note that the base path could be a filename or a URL and this * should still work. The relative path is walked segment by segment * with three rules: series of slashes will be condensed to a single * slash, "." will be eaten with no change, and ".." will remove a * segment from the base path. */ extern int git_path_apply_relative(git_buf *target, const char *relpath); enum { GIT_PATH_DIR_IGNORE_CASE = (1u << 0), GIT_PATH_DIR_PRECOMPOSE_UNICODE = (1u << 1), GIT_PATH_DIR_INCLUDE_DOT_AND_DOTDOT = (1u << 2), }; /** * Walk each directory entry, except '.' and '..', calling fn(state). * * @param pathbuf Buffer the function reads the initial directory * path from, and updates with each successive entry's name. * @param flags Combination of GIT_PATH_DIR flags. * @param callback Callback for each entry. Passed the `payload` and each * successive path inside the directory as a full path. This may * safely append text to the pathbuf if needed. Return non-zero to * cancel iteration (and return value will be propagated back). * @param payload Passed to callback as first argument. * @return 0 on success or error code from OS error or from callback */ extern int git_path_direach( git_buf *pathbuf, uint32_t flags, int (*callback)(void *payload, git_buf *path), void *payload); /** * Sort function to order two paths */ extern int git_path_cmp( const char *name1, size_t len1, int isdir1, const char *name2, size_t len2, int isdir2, int (*compare)(const char *, const char *, size_t)); /** * Invoke callback up path directory by directory until the ceiling is * reached (inclusive of a final call at the root_path). * * Returning anything other than 0 from the callback function * will stop the iteration and propagate the error to the caller. * * @param pathbuf Buffer the function reads the directory from and * and updates with each successive name. * @param ceiling Prefix of path at which to stop walking up. If NULL, * this will walk all the way up to the root. If not a prefix of * pathbuf, the callback will be invoked a single time on the * original input path. * @param callback Function to invoke on each path. Passed the `payload` * and the buffer containing the current path. The path should not * be modified in any way. Return non-zero to stop iteration. * @param payload Passed to fn as the first ath. */ extern int git_path_walk_up( git_buf *pathbuf, const char *ceiling, int (*callback)(void *payload, const char *path), void *payload); enum { GIT_PATH_NOTEQUAL = 0, GIT_PATH_EQUAL = 1, GIT_PATH_PREFIX = 2 }; /* * Determines if a path is equal to or potentially a child of another. * @param parent The possible parent * @param child The possible child */ GIT_INLINE(int) git_path_equal_or_prefixed( const char *parent, const char *child, ssize_t *prefixlen) { const char *p = parent, *c = child; int lastslash = 0; while (*p && *c) { lastslash = (*p == '/'); if (*p++ != *c++) return GIT_PATH_NOTEQUAL; } if (*p != '\0') return GIT_PATH_NOTEQUAL; if (*c == '\0') { if (prefixlen) *prefixlen = p - parent; return GIT_PATH_EQUAL; } if (*c == '/' || lastslash) { if (prefixlen) *prefixlen = (p - parent) - lastslash; return GIT_PATH_PREFIX; } return GIT_PATH_NOTEQUAL; } /* translate errno to libgit2 error code and set error message */ extern int git_path_set_error( int errno_value, const char *path, const char *action); /* check if non-ascii characters are present in filename */ extern bool git_path_has_non_ascii(const char *path, size_t pathlen); #define GIT_PATH_REPO_ENCODING "UTF-8" #ifdef __APPLE__ #define GIT_PATH_NATIVE_ENCODING "UTF-8-MAC" #else #define GIT_PATH_NATIVE_ENCODING "UTF-8" #endif #ifdef GIT_USE_ICONV #include typedef struct { iconv_t map; git_buf buf; } git_path_iconv_t; #define GIT_PATH_ICONV_INIT { (iconv_t)-1, GIT_BUF_INIT } /* Init iconv data for converting decomposed UTF-8 to precomposed */ extern int git_path_iconv_init_precompose(git_path_iconv_t *ic); /* Clear allocated iconv data */ extern void git_path_iconv_clear(git_path_iconv_t *ic); /* * Rewrite `in` buffer using iconv map if necessary, replacing `in` * pointer internal iconv buffer if rewrite happened. The `in` pointer * will be left unchanged if no rewrite was needed. */ extern int git_path_iconv(git_path_iconv_t *ic, const char **in, size_t *inlen); #endif /* GIT_USE_ICONV */ extern bool git_path_does_fs_decompose_unicode(const char *root); typedef struct git_path_diriter git_path_diriter; #if defined(GIT_WIN32) && !defined(__MINGW32__) struct git_path_diriter { git_win32_path path; size_t parent_len; git_buf path_utf8; size_t parent_utf8_len; HANDLE handle; unsigned int flags; WIN32_FIND_DATAW current; unsigned int needs_next; }; #define GIT_PATH_DIRITER_INIT { {0}, 0, GIT_BUF_INIT, 0, INVALID_HANDLE_VALUE } #else struct git_path_diriter { git_buf path; size_t parent_len; unsigned int flags; DIR *dir; #ifdef GIT_USE_ICONV git_path_iconv_t ic; #endif }; #define GIT_PATH_DIRITER_INIT { GIT_BUF_INIT } #endif /** * Initialize a directory iterator. * * @param diriter Pointer to a diriter structure that will be setup. * @param path The path that will be iterated over * @param flags Directory reader flags * @return 0 or an error code */ extern int git_path_diriter_init( git_path_diriter *diriter, const char *path, unsigned int flags); /** * Advance the directory iterator. Will return GIT_ITEROVER when * the iteration has completed successfully. * * @param diriter The directory iterator * @return 0, GIT_ITEROVER, or an error code */ extern int git_path_diriter_next(git_path_diriter *diriter); /** * Returns the file name of the current item in the iterator. * * @param out Pointer to store the path in * @param out_len Pointer to store the length of the path in * @param diriter The directory iterator * @return 0 or an error code */ extern int git_path_diriter_filename( const char **out, size_t *out_len, git_path_diriter *diriter); /** * Returns the full path of the current item in the iterator; that * is the current filename plus the path of the directory that the * iterator was constructed with. * * @param out Pointer to store the path in * @param out_len Pointer to store the length of the path in * @param diriter The directory iterator * @return 0 or an error code */ extern int git_path_diriter_fullpath( const char **out, size_t *out_len, git_path_diriter *diriter); /** * Performs an `lstat` on the current item in the iterator. * * @param out Pointer to store the stat data in * @param diriter The directory iterator * @return 0 or an error code */ extern int git_path_diriter_stat(struct stat *out, git_path_diriter *diriter); /** * Closes the directory iterator. * * @param diriter The directory iterator */ extern void git_path_diriter_free(git_path_diriter *diriter); /** * Load all directory entries (except '.' and '..') into a vector. * * For cases where `git_path_direach()` is not appropriate, this * allows you to load the filenames in a directory into a vector * of strings. That vector can then be sorted, iterated, or whatever. * Remember to free alloc of the allocated strings when you are done. * * @param contents Vector to fill with directory entry names. * @param path The directory to read from. * @param prefix_len When inserting entries, the trailing part of path * will be prefixed after this length. I.e. given path "/a/b" and * prefix_len 3, the entries will look like "b/e1", "b/e2", etc. * @param flags Combination of GIT_PATH_DIR flags. */ extern int git_path_dirload( git_vector *contents, const char *path, size_t prefix_len, uint32_t flags); /* Used for paths to repositories on the filesystem */ extern bool git_path_is_local_file_url(const char *file_url); extern int git_path_from_url_or_path(git_buf *local_path_out, const char *url_or_path); /* Flags to determine path validity in `git_path_isvalid` */ #define GIT_PATH_REJECT_TRAVERSAL (1 << 0) #define GIT_PATH_REJECT_DOT_GIT (1 << 1) #define GIT_PATH_REJECT_SLASH (1 << 2) #define GIT_PATH_REJECT_BACKSLASH (1 << 3) #define GIT_PATH_REJECT_TRAILING_DOT (1 << 4) #define GIT_PATH_REJECT_TRAILING_SPACE (1 << 5) #define GIT_PATH_REJECT_TRAILING_COLON (1 << 6) #define GIT_PATH_REJECT_DOS_PATHS (1 << 7) #define GIT_PATH_REJECT_NT_CHARS (1 << 8) #define GIT_PATH_REJECT_DOT_GIT_HFS (1 << 9) #define GIT_PATH_REJECT_DOT_GIT_NTFS (1 << 10) /* Default path safety for writing files to disk: since we use the * Win32 "File Namespace" APIs ("\\?\") we need to protect from * paths that the normal Win32 APIs would not write. */ #ifdef GIT_WIN32 # define GIT_PATH_REJECT_DEFAULTS \ GIT_PATH_REJECT_TRAVERSAL | \ GIT_PATH_REJECT_BACKSLASH | \ GIT_PATH_REJECT_TRAILING_DOT | \ GIT_PATH_REJECT_TRAILING_SPACE | \ GIT_PATH_REJECT_TRAILING_COLON | \ GIT_PATH_REJECT_DOS_PATHS | \ GIT_PATH_REJECT_NT_CHARS #else # define GIT_PATH_REJECT_DEFAULTS GIT_PATH_REJECT_TRAVERSAL #endif /* * Determine whether a path is a valid git path or not - this must not contain * a '.' or '..' component, or a component that is ".git" (in any case). * * `repo` is optional. If specified, it will be used to determine the short * path name to reject (if `GIT_PATH_REJECT_DOS_SHORTNAME` is specified), * in addition to the default of "git~1". */ extern bool git_path_isvalid( git_repository *repo, const char *path, unsigned int flags); /** * Convert any backslashes into slashes */ int git_path_normalize_slashes(git_buf *out, const char *path); #endif deps/libgit2-sys-0.3.8/libgit2/src/tree-cache.h0000664000175000017500000000224512510265101016037 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_tree_cache_h__ #define INCLUDE_tree_cache_h__ #include "common.h" #include "pool.h" #include "buffer.h" #include "git2/oid.h" typedef struct git_tree_cache { struct git_tree_cache **children; size_t children_count; ssize_t entry_count; git_oid oid; size_t namelen; char name[GIT_FLEX_ARRAY]; } git_tree_cache; int git_tree_cache_write(git_buf *out, git_tree_cache *tree); int git_tree_cache_read(git_tree_cache **tree, const char *buffer, size_t buffer_size, git_pool *pool); void git_tree_cache_invalidate_path(git_tree_cache *tree, const char *path); const git_tree_cache *git_tree_cache_get(const git_tree_cache *tree, const char *path); int git_tree_cache_new(git_tree_cache **out, const char *name, git_pool *pool); /** * Read a tree as the root of the tree cache (like for `git read-tree`) */ int git_tree_cache_read_tree(git_tree_cache **out, const git_tree *tree, git_pool *pool); void git_tree_cache_free(git_tree_cache *tree); #endif deps/libgit2-sys-0.3.8/libgit2/CMakeLists.txt0000664000175000017500000005457012610310643015652 0ustar # CMake build script for the libgit2 project # # Building (out of source build): # > mkdir build && cd build # > cmake .. [-DSETTINGS=VALUE] # > cmake --build . # # Testing: # > ctest -V # # Install: # > cmake --build . --target install PROJECT(libgit2 C) CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_POLICY(SET CMP0015 NEW) # Add find modules to the path SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/") INCLUDE(CheckLibraryExists) INCLUDE(CheckFunctionExists) INCLUDE(AddCFlagIfSupported) INCLUDE(FindPkgConfig) # Build options # OPTION( SONAME "Set the (SO)VERSION of the target" ON ) OPTION( BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON ) OPTION( THREADSAFE "Build libgit2 as threadsafe" ON ) OPTION( BUILD_CLAR "Build Tests using the Clar suite" ON ) OPTION( BUILD_EXAMPLES "Build library usage example apps" OFF ) OPTION( TAGS "Generate tags" OFF ) OPTION( PROFILE "Generate profiling information" OFF ) OPTION( ENABLE_TRACE "Enables tracing support" OFF ) OPTION( LIBGIT2_FILENAME "Name of the produced binary" OFF ) OPTION( USE_ICONV "Link with and use iconv library" OFF ) OPTION( USE_SSH "Link with libssh to enable SSH support" ON ) OPTION( USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF ) OPTION( VALGRIND "Configure build for valgrind" OFF ) OPTION( CURL "User curl for HTTP if available" ON) IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") SET( USE_ICONV ON ) FIND_PACKAGE(Security) FIND_PACKAGE(CoreFoundation REQUIRED) ENDIF() IF(MSVC) # This option is only available when building with MSVC. By default, libgit2 # is build using the cdecl calling convention, which is useful if you're # writing C. However, the CLR and Win32 API both expect stdcall. # # If you are writing a CLR program and want to link to libgit2, you'll want # to turn this on by invoking CMake with the "-DSTDCALL=ON" argument. OPTION( STDCALL "Build libgit2 with the __stdcall convention" OFF ) # This option must match the settings used in your program, in particular if you # are linking statically OPTION( STATIC_CRT "Link the static CRT libraries" ON ) # If you want to embed a copy of libssh2 into libgit2, pass a # path to libssh2 OPTION( EMBED_SSH_PATH "Path to libssh2 to embed (Windows)" OFF ) ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS) ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE) ENDIF() IF(WIN32) # By default, libgit2 is built with WinHTTP. To use the built-in # HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument. OPTION( WINHTTP "Use Win32 WinHTTP routines" ON ) ENDIF() IF(MSVC) # Enable MSVC CRTDBG memory leak reporting when in debug mode. OPTION(MSVC_CRTDBG "Enable CRTDBG memory leak reporting" OFF) ENDIF() IF (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") OPTION( USE_OPENSSL "Link with and use openssl library" ON ) ENDIF() # This variable will contain the libraries we need to put into # libgit2.pc's Requires.private. That is, what we're linking to or # what someone who's statically linking us needs to link to. SET(LIBGIT2_PC_REQUIRES "") # This will be set later if we use the system's http-parser library or # use iconv (OSX) and will be written to the Libs.private field in the # pc file. SET(LIBGIT2_PC_LIBS "") # Installation paths # SET(BIN_INSTALL_DIR bin CACHE PATH "Where to install binaries to.") SET(LIB_INSTALL_DIR lib CACHE PATH "Where to install libraries to.") SET(INCLUDE_INSTALL_DIR include CACHE PATH "Where to install headers to.") # Set a couple variables to be substituted inside the .pc file. # We can't just use LIB_INSTALL_DIR in the .pc file, as passing them as absolue # or relative paths is both valid and supported by cmake. SET (PKGCONFIG_PREFIX ${CMAKE_INSTALL_PREFIX}) IF(IS_ABSOLUTE ${LIB_INSTALL_DIR}) SET (PKGCONFIG_LIBDIR ${LIB_INSTALL_DIR}) ELSE(IS_ABSOLUTE ${LIB_INSTALL_DIR}) SET (PKGCONFIG_LIBDIR "\${prefix}/${LIB_INSTALL_DIR}") ENDIF (IS_ABSOLUTE ${LIB_INSTALL_DIR}) IF(IS_ABSOLUTE ${INCLUDE_INSTALL_DIR}) SET (PKGCONFIG_INCLUDEDIR ${INCLUDE_INSTALL_DIR}) ELSE(IS_ABSOLUTE ${INCLUDE_INSTALL_DIR}) SET (PKGCONFIG_INCLUDEDIR "\${prefix}/${INCLUDE_INSTALL_DIR}") ENDIF(IS_ABSOLUTE ${INCLUDE_INSTALL_DIR}) FUNCTION(TARGET_OS_LIBRARIES target) IF(WIN32) TARGET_LINK_LIBRARIES(${target} ws2_32) ELSEIF(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") TARGET_LINK_LIBRARIES(${target} socket nsl) LIST(APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl") SET(LIBGIT2_PC_LIBS ${LIBGIT2_PC_LIBS} PARENT_SCOPE) ENDIF() CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" NEED_LIBRT) IF(NEED_LIBRT) TARGET_LINK_LIBRARIES(${target} rt) LIST(APPEND LIBGIT2_PC_LIBS "-lrt") SET(LIBGIT2_PC_LIBS ${LIBGIT2_PC_LIBS} PARENT_SCOPE) ENDIF() IF(THREADSAFE) TARGET_LINK_LIBRARIES(${target} ${CMAKE_THREAD_LIBS_INIT}) ENDIF() ENDFUNCTION() # For the MSVC IDE, this function splits up the source files like windows # explorer does. This is esp. useful with the libgit2_clar project, were # usually 2 or more files share the same name. Sadly, this file grouping # is a per-directory option in cmake and not per-target, resulting in # empty virtual folders "tests" for the git2.dll FUNCTION(MSVC_SPLIT_SOURCES target) IF(MSVC_IDE) GET_TARGET_PROPERTY(sources ${target} SOURCES) FOREACH(source ${sources}) IF(source MATCHES ".*/") STRING(REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/ "" rel ${source}) IF(rel) STRING(REGEX REPLACE "/([^/]*)$" "" rel ${rel}) IF(rel) STRING(REPLACE "/" "\\\\" rel ${rel}) SOURCE_GROUP(${rel} FILES ${source}) ENDIF() ENDIF() ENDIF() ENDFOREACH() ENDIF() ENDFUNCTION() FILE(STRINGS "include/git2/version.h" GIT2_HEADER REGEX "^#define LIBGIT2_VERSION \"[^\"]*\"$") STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"([0-9]+).*$" "\\1" LIBGIT2_VERSION_MAJOR "${GIT2_HEADER}") STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_MINOR "${GIT2_HEADER}") STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_REV "${GIT2_HEADER}") SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${LIBGIT2_VERSION_REV}") FILE(STRINGS "include/git2/version.h" GIT2_HEADER_SOVERSION REGEX "^#define LIBGIT2_SOVERSION [0-9]+$") STRING(REGEX REPLACE "^.*LIBGIT2_SOVERSION ([0-9]+)$" "\\1" LIBGIT2_SOVERSION "${GIT2_HEADER_SOVERSION}") # Find required dependencies INCLUDE_DIRECTORIES(src include) IF (SECURITY_FOUND) # OS X 10.7 and older do not have some functions we use, fall back to OpenSSL there CHECK_LIBRARY_EXISTS("${SECURITY_DIRS}" SSLCreateContext "Security/SecureTransport.h" HAVE_NEWER_SECURITY) IF (HAVE_NEWER_SECURITY) MESSAGE("-- Found Security ${SECURITY_DIRS}") LIST(APPEND LIBGIT2_PC_LIBS "-framework Security") ELSE() MESSAGE("-- Security framework is too old, falling back to OpenSSL") SET(SECURITY_FOUND "NO") SET(SECURITY_DIRS "") SET(SECURITY_DIR "") SET(USE_OPENSSL "ON") ENDIF() ENDIF() IF (COREFOUNDATION_FOUND) MESSAGE("-- Found CoreFoundation ${COREFOUNDATION_DIRS}") LIST(APPEND LIBGIT2_PC_LIBS "-framework CoreFoundation") ENDIF() IF (WIN32 AND EMBED_SSH_PATH) FILE(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c") INCLUDE_DIRECTORIES("${EMBED_SSH_PATH}/include") FILE(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"") ADD_DEFINITIONS(-DGIT_SSH) ENDIF() IF (WIN32 AND WINHTTP) ADD_DEFINITIONS(-DGIT_WINHTTP) INCLUDE_DIRECTORIES(deps/http-parser) FILE(GLOB SRC_HTTP deps/http-parser/*.c deps/http-parser/*.h) # Since MinGW does not come with headers or an import library for winhttp, # we have to include a private header and generate our own import library IF (MINGW) FIND_PROGRAM(DLLTOOL dlltool CMAKE_FIND_ROOT_PATH_BOTH) IF (NOT DLLTOOL) MESSAGE(FATAL_ERROR "Could not find dlltool command") ENDIF () SET(LIBWINHTTP_PATH "${CMAKE_CURRENT_BINARY_DIR}/deps/winhttp") FILE(MAKE_DIRECTORY ${LIBWINHTTP_PATH}) IF ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") set(WINHTTP_DEF "${CMAKE_CURRENT_SOURCE_DIR}/deps/winhttp/winhttp64.def") ELSE() set(WINHTTP_DEF "${CMAKE_CURRENT_SOURCE_DIR}/deps/winhttp/winhttp.def") ENDIF() ADD_CUSTOM_COMMAND( OUTPUT ${LIBWINHTTP_PATH}/libwinhttp.a COMMAND ${DLLTOOL} -d ${WINHTTP_DEF} -k -D winhttp.dll -l libwinhttp.a DEPENDS ${WINHTTP_DEF} WORKING_DIRECTORY ${LIBWINHTTP_PATH} ) SET_SOURCE_FILES_PROPERTIES( ${CMAKE_CURRENT_SOURCE_DIR}/src/transports/winhttp.c PROPERTIES OBJECT_DEPENDS ${LIBWINHTTP_PATH}/libwinhttp.a ) INCLUDE_DIRECTORIES(deps/winhttp) LINK_DIRECTORIES(${LIBWINHTTP_PATH}) ENDIF () LINK_LIBRARIES(winhttp rpcrt4 crypt32) ELSE () IF (CURL) PKG_CHECK_MODULES(CURL libcurl) ENDIF () IF (NOT AMIGA AND USE_OPENSSL) FIND_PACKAGE(OpenSSL) ENDIF () IF (CURL_FOUND) ADD_DEFINITIONS(-DGIT_CURL) INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS}) LINK_LIBRARIES(${CURL_LIBRARIES}) LIST(APPEND LIBGIT2_PC_LIBS ${CURL_LDFLAGS}) ENDIF() FIND_PACKAGE(HTTP_Parser) IF (HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2) INCLUDE_DIRECTORIES(${HTTP_PARSER_INCLUDE_DIRS}) LINK_LIBRARIES(${HTTP_PARSER_LIBRARIES}) LIST(APPEND LIBGIT2_PC_LIBS "-lhttp_parser") ELSE() MESSAGE(STATUS "http-parser was not found or is too old; using bundled 3rd-party sources.") INCLUDE_DIRECTORIES(deps/http-parser) FILE(GLOB SRC_HTTP deps/http-parser/*.c deps/http-parser/*.h) ENDIF() ENDIF() # Specify sha1 implementation IF (WIN32 AND NOT MINGW AND NOT SHA1_TYPE STREQUAL "builtin") ADD_DEFINITIONS(-DWIN32_SHA1) FILE(GLOB SRC_SHA1 src/hash/hash_win32.c) ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") ADD_DEFINITIONS(-DGIT_COMMON_CRYPTO) ELSEIF (OPENSSL_FOUND AND NOT SHA1_TYPE STREQUAL "builtin") ADD_DEFINITIONS(-DOPENSSL_SHA1) IF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") LIST(APPEND LIBGIT2_PC_LIBS "-lssl") ELSE() SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} openssl") ENDIF () ELSE() FILE(GLOB SRC_SHA1 src/hash/hash_generic.c) ENDIF() # Enable tracing IF (ENABLE_TRACE STREQUAL "ON") ADD_DEFINITIONS(-DGIT_TRACE) ENDIF() # Include POSIX regex when it is required IF(WIN32 OR AMIGA OR CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") INCLUDE_DIRECTORIES(deps/regex) SET(SRC_REGEX deps/regex/regex.c) ENDIF() # Optional external dependency: zlib FIND_PACKAGE(ZLIB) IF (ZLIB_FOUND) INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS}) LINK_LIBRARIES(${ZLIB_LIBRARIES}) IF(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD") LIST(APPEND LIBGIT2_PC_LIBS "-lz") ELSE() SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} zlib") ENDIF() ELSE() MESSAGE(STATUS "zlib was not found; using bundled 3rd-party sources." ) INCLUDE_DIRECTORIES(deps/zlib) ADD_DEFINITIONS(-DNO_VIZ -DSTDC -DNO_GZIP) FILE(GLOB SRC_ZLIB deps/zlib/*.c deps/zlib/*.h) ENDIF() # Optional external dependency: libssh2 IF (USE_SSH) PKG_CHECK_MODULES(LIBSSH2 libssh2) ENDIF() IF (LIBSSH2_FOUND) ADD_DEFINITIONS(-DGIT_SSH) INCLUDE_DIRECTORIES(${LIBSSH2_INCLUDE_DIRS}) LINK_DIRECTORIES(${LIBSSH2_LIBRARY_DIRS}) LIST(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS}) #SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} ${LIBSSH2_LDFLAGS}") SET(SSH_LIBRARIES ${LIBSSH2_LIBRARIES}) CHECK_LIBRARY_EXISTS("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS) IF (HAVE_LIBSSH2_MEMORY_CREDENTIALS) ADD_DEFINITIONS(-DGIT_SSH_MEMORY_CREDENTIALS) ENDIF() ELSE() MESSAGE(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.") ENDIF() # Optional external dependency: libgssapi IF (USE_GSSAPI) FIND_PACKAGE(GSSAPI) ENDIF() IF (GSSAPI_FOUND) ADD_DEFINITIONS(-DGIT_GSSAPI) ENDIF() # Optional external dependency: iconv IF (USE_ICONV) FIND_PACKAGE(Iconv) ENDIF() IF (ICONV_FOUND) ADD_DEFINITIONS(-DGIT_USE_ICONV) INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR}) LIST(APPEND LIBGIT2_PC_LIBS ${ICONV_LIBRARIES}) ENDIF() # Platform specific compilation flags IF (MSVC) STRING(REPLACE "/Zm1000" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") # /GF - String pooling # /MP - Parallel build SET(CMAKE_C_FLAGS "/GF /MP /nologo ${CMAKE_C_FLAGS}") IF (STDCALL) # /Gz - stdcall calling convention SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gz") ENDIF () IF (STATIC_CRT) SET(CRT_FLAG_DEBUG "/MTd") SET(CRT_FLAG_RELEASE "/MT") ELSE() SET(CRT_FLAG_DEBUG "/MDd") SET(CRT_FLAG_RELEASE "/MD") ENDIF() IF (MSVC_CRTDBG) SET(CRT_FLAG_DEBUG "${CRT_FLAG_DEBUG} /DGIT_MSVC_CRTDBG") SET(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES}" "Dbghelp.lib") ENDIF() # /Zi - Create debugging information # /Od - Disable optimization # /D_DEBUG - #define _DEBUG # /MTd - Statically link the multithreaded debug version of the CRT # /MDd - Dynamically link the multithreaded debug version of the CRT # /RTC1 - Run time checks SET(CMAKE_C_FLAGS_DEBUG "/Zi /Od /D_DEBUG /RTC1 ${CRT_FLAG_DEBUG}") # /DNDEBUG - Disables asserts # /MT - Statically link the multithreaded release version of the CRT # /MD - Dynamically link the multithreaded release version of the CRT # /O2 - Optimize for speed # /Oy - Enable frame pointer omission (FPO) (otherwise CMake will automatically turn it off) # /GL - Link time code generation (whole program optimization) # /Gy - Function-level linking SET(CMAKE_C_FLAGS_RELEASE "/DNDEBUG /O2 /Oy /GL /Gy ${CRT_FLAG_RELEASE}") # /Oy- - Disable frame pointer omission (FPO) SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/DNDEBUG /Zi /O2 /Oy- /GL /Gy ${CRT_FLAG_RELEASE}") # /O1 - Optimize for size SET(CMAKE_C_FLAGS_MINSIZEREL "/DNDEBUG /O1 /Oy /GL /Gy ${CRT_FLAG_RELEASE}") # /DYNAMICBASE - Address space load randomization (ASLR) # /NXCOMPAT - Data execution prevention (DEP) # /LARGEADDRESSAWARE - >2GB user address space on x86 # /VERSION - Embed version information in PE header SET(CMAKE_EXE_LINKER_FLAGS "/DYNAMICBASE /NXCOMPAT /LARGEADDRESSAWARE /VERSION:${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}") # /DEBUG - Create a PDB # /LTCG - Link time code generation (whole program optimization) # /OPT:REF /OPT:ICF - Fold out duplicate code at link step # /INCREMENTAL:NO - Required to use /LTCG # /DEBUGTYPE:cv,fixup - Additional data embedded in the PDB (requires /INCREMENTAL:NO, so not on for Debug) SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG") SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO") SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup") SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO") # Same linker settings for DLL as EXE SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}") SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}") SET(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}") SET(WIN_RC "src/win32/git2.rc") # Precompiled headers ELSE () SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -Wall -Wextra ${CMAKE_C_FLAGS}") IF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") SET(CMAKE_C_FLAGS "-std=c99 -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS ${CMAKE_C_FLAGS}") ENDIF() IF (WIN32 AND NOT CYGWIN) SET(CMAKE_C_FLAGS_DEBUG "-D_DEBUG") ENDIF () IF (MINGW) # MinGW always does PIC and complains if we tell it to STRING(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}") # MinGW >= 3.14 uses the C99-style stdio functions # automatically, but forks like mingw-w64 still want # us to define this in order to use them ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO=1) ELSEIF (BUILD_SHARED_LIBS) ADD_C_FLAG_IF_SUPPORTED(-fvisibility=hidden) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") ENDIF () ADD_C_FLAG_IF_SUPPORTED(-Wdocumentation) ADD_C_FLAG_IF_SUPPORTED(-Wno-missing-field-initializers) ADD_C_FLAG_IF_SUPPORTED(-Wstrict-aliasing=2) ADD_C_FLAG_IF_SUPPORTED(-Wstrict-prototypes) ADD_C_FLAG_IF_SUPPORTED(-Wdeclaration-after-statement) ADD_C_FLAG_IF_SUPPORTED(-Wno-unused-const-variable) ADD_C_FLAG_IF_SUPPORTED(-Wno-unused-function) IF (APPLE) # Apple deprecated OpenSSL ADD_C_FLAG_IF_SUPPORTED(-Wno-deprecated-declarations) ENDIF() IF (PROFILE) SET(CMAKE_C_FLAGS "-pg ${CMAKE_C_FLAGS}") SET(CMAKE_EXE_LINKER_FLAGS "-pg ${CMAKE_EXE_LINKER_FLAGS}") ENDIF () ENDIF() CHECK_FUNCTION_EXISTS(futimens HAVE_FUTIMENS) IF (HAVE_FUTIMENS) ADD_DEFINITIONS(-DHAVE_FUTIMENS) ENDIF () CHECK_FUNCTION_EXISTS(qsort_r HAVE_QSORT_R) IF (HAVE_QSORT_R) ADD_DEFINITIONS(-DHAVE_QSORT_R) ENDIF () CHECK_FUNCTION_EXISTS(qsort_s HAVE_QSORT_S) IF (HAVE_QSORT_S) ADD_DEFINITIONS(-DHAVE_QSORT_S) ENDIF () IF( NOT CMAKE_CONFIGURATION_TYPES ) # Build Debug by default IF (NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) ENDIF () ELSE() # Using a multi-configuration generator eg MSVC or Xcode # that uses CMAKE_CONFIGURATION_TYPES and not CMAKE_BUILD_TYPE ENDIF() IF (SECURITY_FOUND) ADD_DEFINITIONS(-DGIT_SECURE_TRANSPORT) INCLUDE_DIRECTORIES(${SECURITY_INCLUDE_DIR}) ENDIF () IF (OPENSSL_FOUND) ADD_DEFINITIONS(-DGIT_OPENSSL) INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR}) SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES}) ENDIF() IF (THREADSAFE) IF (NOT WIN32) FIND_PACKAGE(Threads REQUIRED) ENDIF() ADD_DEFINITIONS(-DGIT_THREADS) ENDIF() ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64) # Collect sourcefiles FILE(GLOB SRC_H include/git2.h include/git2/*.h include/git2/sys/*.h) # On Windows use specific platform sources IF (WIN32 AND NOT CYGWIN) ADD_DEFINITIONS(-DWIN32 -D_WIN32_WINNT=0x0501) FILE(GLOB SRC_OS src/win32/*.c src/win32/*.h) ELSEIF (AMIGA) ADD_DEFINITIONS(-DNO_ADDRINFO -DNO_READDIR_R -DNO_MMAP) ELSE() IF (VALGRIND) ADD_DEFINITIONS(-DNO_MMAP) ENDIF() FILE(GLOB SRC_OS src/unix/*.c src/unix/*.h) ENDIF() FILE(GLOB SRC_GIT2 src/*.c src/*.h src/transports/*.c src/transports/*.h src/xdiff/*.c src/xdiff/*.h) # Determine architecture of the machine IF (CMAKE_SIZEOF_VOID_P EQUAL 8) ADD_DEFINITIONS(-DGIT_ARCH_64) ELSEIF (CMAKE_SIZEOF_VOID_P EQUAL 4) ADD_DEFINITIONS(-DGIT_ARCH_32) ELSE() MESSAGE(FATAL_ERROR "Unsupported architecture") ENDIF() # Compile and link libgit2 ADD_LIBRARY(git2 ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SSH} ${SRC_SHA1} ${WIN_RC}) TARGET_LINK_LIBRARIES(git2 ${SECURITY_DIRS}) TARGET_LINK_LIBRARIES(git2 ${COREFOUNDATION_DIRS}) TARGET_LINK_LIBRARIES(git2 ${SSL_LIBRARIES}) TARGET_LINK_LIBRARIES(git2 ${SSH_LIBRARIES}) TARGET_LINK_LIBRARIES(git2 ${GSSAPI_LIBRARIES}) TARGET_LINK_LIBRARIES(git2 ${ICONV_LIBRARIES}) TARGET_OS_LIBRARIES(git2) # Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240) # Win64+MSVC+static libs = linker error IF(MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS) SET_TARGET_PROPERTIES(git2 PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64") ENDIF() MSVC_SPLIT_SOURCES(git2) IF (SONAME) SET_TARGET_PROPERTIES(git2 PROPERTIES VERSION ${LIBGIT2_VERSION_STRING}) SET_TARGET_PROPERTIES(git2 PROPERTIES SOVERSION ${LIBGIT2_SOVERSION}) IF (LIBGIT2_FILENAME) ADD_DEFINITIONS(-DLIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\") SET_TARGET_PROPERTIES(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME}) ENDIF() ENDIF() STRING(REPLACE ";" " " LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS}") CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libgit2.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libgit2.pc @ONLY) IF (MSVC_IDE) # Precompiled headers SET_TARGET_PROPERTIES(git2 PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h") SET_SOURCE_FILES_PROPERTIES(src/win32/precompiled.c COMPILE_FLAGS "/Ycprecompiled.h") ENDIF () # Install INSTALL(TARGETS git2 RUNTIME DESTINATION ${BIN_INSTALL_DIR} LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR} ) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgit2.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig ) INSTALL(DIRECTORY include/git2 DESTINATION ${INCLUDE_INSTALL_DIR} ) INSTALL(FILES include/git2.h DESTINATION ${INCLUDE_INSTALL_DIR} ) # Tests IF (BUILD_CLAR) FIND_PACKAGE(PythonInterp) IF(NOT PYTHONINTERP_FOUND) MESSAGE(FATAL_ERROR "Could not find a python interpeter, which is needed to build the tests. " "Make sure python is available, or pass -DBUILD_CLAR=OFF to skip building the tests") ENDIF() SET(CLAR_FIXTURES "${CMAKE_CURRENT_SOURCE_DIR}/tests/resources/") SET(CLAR_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tests") SET(CLAR_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/tests/resources" CACHE PATH "Path to test resources.") ADD_DEFINITIONS(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\") ADD_DEFINITIONS(-DCLAR_RESOURCES=\"${TEST_RESOURCES}\") ADD_DEFINITIONS(-DCLAR_TMPDIR=\"libgit2_tests\") INCLUDE_DIRECTORIES(${CLAR_PATH}) FILE(GLOB_RECURSE SRC_TEST ${CLAR_PATH}/*/*.c ${CLAR_PATH}/*/*.h) SET(SRC_CLAR "${CLAR_PATH}/main.c" "${CLAR_PATH}/clar_libgit2.c" "${CLAR_PATH}/clar_libgit2_trace.c" "${CLAR_PATH}/clar_libgit2_timer.c" "${CLAR_PATH}/clar.c") ADD_CUSTOM_COMMAND( OUTPUT ${CLAR_PATH}/clar.suite COMMAND ${PYTHON_EXECUTABLE} generate.py -f -xonline -xstress . DEPENDS ${SRC_TEST} WORKING_DIRECTORY ${CLAR_PATH} ) SET_SOURCE_FILES_PROPERTIES( ${CLAR_PATH}/clar.c PROPERTIES OBJECT_DEPENDS ${CLAR_PATH}/clar.suite) ADD_EXECUTABLE(libgit2_clar ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_CLAR} ${SRC_TEST} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SSH} ${SRC_SHA1}) TARGET_LINK_LIBRARIES(libgit2_clar ${COREFOUNDATION_DIRS}) TARGET_LINK_LIBRARIES(libgit2_clar ${SECURITY_DIRS}) TARGET_LINK_LIBRARIES(libgit2_clar ${SSL_LIBRARIES}) TARGET_LINK_LIBRARIES(libgit2_clar ${SSH_LIBRARIES}) TARGET_LINK_LIBRARIES(libgit2_clar ${GSSAPI_LIBRARIES}) TARGET_LINK_LIBRARIES(libgit2_clar ${ICONV_LIBRARIES}) TARGET_OS_LIBRARIES(libgit2_clar) MSVC_SPLIT_SOURCES(libgit2_clar) IF (MSVC_IDE) # Precompiled headers SET_TARGET_PROPERTIES(libgit2_clar PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h") ENDIF () ENABLE_TESTING() IF (WINHTTP OR OPENSSL_FOUND OR SECURITY_FOUND) ADD_TEST(libgit2_clar libgit2_clar -ionline) ELSE () ADD_TEST(libgit2_clar libgit2_clar -v) ENDIF () ENDIF () IF (TAGS) FIND_PROGRAM(CTAGS ctags) IF (NOT CTAGS) MESSAGE(FATAL_ERROR "Could not find ctags command") ENDIF () FILE(GLOB_RECURSE SRC_ALL *.[ch]) ADD_CUSTOM_COMMAND( OUTPUT tags COMMAND ${CTAGS} -a ${SRC_ALL} DEPENDS ${SRC_ALL} ) ADD_CUSTOM_TARGET( do_tags ALL DEPENDS tags ) ENDIF () IF (BUILD_EXAMPLES) ADD_SUBDIRECTORY(examples) ENDIF () deps/libgit2-sys-0.3.8/libgit2/CONTRIBUTING.md0000664000175000017500000001404712510265101015333 0ustar # Welcome to libgit2! We're making it easy to do interesting things with git, and we'd love to have your help. ## Licensing By contributing to libgit2, you agree to release your contribution under the terms of the license. Except for the `examples` directory, all code is released under the [GPL v2 with linking exception](COPYING). The `examples` code is governed by the [CC0 Public Domain Dedication](examples/COPYING), so that you may copy from them into your own application. ## Discussion & Chat We hang out in the [`#libgit2`](http://webchat.freenode.net/?channels=#libgit2)) channel on irc.freenode.net. Also, feel free to open an [Issue](https://github.com/libgit2/libgit2/issues/new) to start a discussion about any concerns you have. We like to use Issues for that so there is an easily accessible permanent record of the conversation. ## Libgit2 Versions The `master` branch is the main branch where development happens. Releases are tagged (e.g. [v0.21.0](https://github.com/libgit2/libgit2/releases/tag/v0.21.0) ) and when a critical bug fix needs to be backported, it will be done on a `-maint` maintenance branch. ## Reporting Bugs First, know which version of libgit2 your problem is in and include it in your bug report. This can either be a tag (e.g. [v0.17.0](https://github.com/libgit2/libgit2/releases/tag/v0.17.0)) or a commit SHA (e.g. [01be7863](https://github.com/libgit2/libgit2/commit/01be7863)). Using [`git describe`](http://git-scm.com/docs/git-describe) is a great way to tell us what version you're working with. If you're not running against the latest `master` branch version, please compile and test against that to avoid re-reporting an issue that's already been fixed. It's *incredibly* helpful to be able to reproduce the problem. Please include a list of steps, a bit of code, and/or a zipped repository (if possible). Note that some of the libgit2 developers are employees of GitHub, so if your repository is private, find us on IRC and we'll figure out a way to help you. ## Pull Requests Our work flow is a [typical GitHub flow](https://guides.github.com/introduction/flow/index.html), where contributors fork the [libgit2 repository](https://github.com/libgit2/libgit2), make their changes on branch, and submit a [Pull Request](https://help.github.com/articles/using-pull-requests) (a.k.a. "PR"). Pull requests should usually be targeted at the `master` branch. Life will be a lot easier for you (and us) if you follow this pattern (i.e. fork, named branch, submit PR). If you use your fork's `master` branch directly, things can get messy. Please include a nice description of your changes when you submit your PR; if we have to read the whole diff to figure out why you're contributing in the first place, you're less likely to get feedback and have your change merged in. If you are starting to work on a particular area, feel free to submit a PR that highlights your work in progress (and note in the PR title that it's not ready to merge). These early PRs are welcome and will help in getting visibility for your fix, allow others to comment early on the changes and also let others know that you are currently working on something. Before wrapping up a PR, you should be sure to: * Write tests to cover any functional changes * Update documentation for any changed public APIs * Add to the [`CHANGELOG.md`](CHANGELOG.md) file describing any major changes ## Unit Tests We believe that our unit tests allow us to keep the quality of libgit2 high: any new changes must not cause unit test failures, and new changes should include unit tests that cover the bug fixes or new features. For bug fixes, we prefer unit tests that illustrate the failure before the change, but pass with your changes. In addition to new tests, please ensure that your changes do not cause any other test failures. Running the entire test suite is helpful before you submit a pull request. When you build libgit2, the test suite will also be built. You can run all tests by simply running the resultant `libgit2_clar` binary. If you want to run a specific unit test, you can name it with the `-s` option. For example: libgit2_clar -sstatus::worktree::long_filenames Or you can run an entire class of tests. For example, to run all the worktree status tests: libgit2_clar -sstatus::worktree ## Porting Code From Other Open-Source Projects `libgit2` is licensed under the terms of the GPL v2 with a linking exception. Any code brought in must be compatible with those terms. The most common case is porting code from core Git. Git is a pure GPL project, which means that in order to port code to this project, we need the explicit permission of the author. Check the [`git.git-authors`](https://github.com/libgit2/libgit2/blob/development/git.git-authors) file for authors who have already consented. Other licenses have other requirements; check the license of the library you're porting code *from* to see what you need to do. As a general rule, MIT and BSD (3-clause) licenses are typically no problem. Apache 2.0 license typically doesn't work due to GPL incompatibility. If your pull request uses code from core Git, another project, or code from a forum / Stack Overflow, then *please* flag this in your PR and make sure you've given proper credit to the original author in the code snippet. ## Style Guide The public API of `libgit2` is [ANSI C](http://en.wikipedia.org/wiki/ANSI_C) (a.k.a. C89) compatible. Internally, `libgit2` is written using a portable subset of C99 - in order to compile with GCC, Clang, MSVC, etc., we keep local variable declarations at the tops of blocks only and avoid `//` style comments. Additionally, `libgit2` follows some extra conventions for function and type naming, code formatting, and testing. We like to keep the source code consistent and easy to read. Maintaining this takes some discipline, but it's been more than worth it. Take a look at the [conventions file](https://github.com/libgit2/libgit2/blob/development/CONVENTIONS.md). ## Starter Projects See our [projects list](https://github.com/libgit2/libgit2/blob/development/PROJECTS.md). deps/libgit2-sys-0.3.8/libgit2/appveyor.yml0000664000175000017500000000172612555730137015511 0ustar version: '{build}' branches: only: - master - /^maint.*/ environment: GITTEST_INVASIVE_FS_STRUCTURE: 1 GITTEST_INVASIVE_FS_SIZE: 1 matrix: - GENERATOR: "Visual Studio 11" ARCH: 32 - GENERATOR: "Visual Studio 11 Win64" ARCH: 64 - GENERATOR: "MSYS Makefiles" ARCH: 32 - GENERATOR: "MSYS Makefiles" ARCH: i686 # this is for 32-bit MinGW-w64 - GENERATOR: "MSYS Makefiles" ARCH: 64 matrix: allow_failures: - GENERATOR: "MSYS Makefiles" ARCH: 32 cache: - i686-4.9.2-release-win32-sjlj-rt_v3-rev1.7z - x86_64-4.9.2-release-win32-seh-rt_v3-rev1.7z build_script: - ps: | mkdir build cd build if ($env:GENERATOR -ne "MSYS Makefiles") { cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON -D MSVC_CRTDBG=ON .. -G"$env:GENERATOR" cmake --build . --config Debug } - cmd: | if "%GENERATOR%"=="MSYS Makefiles" (C:\MinGW\msys\1.0\bin\sh --login /c/projects/libgit2/script/appveyor-mingw.sh) test_script: - ps: ctest -V . deps/libgit2-sys-0.3.8/libgit2/CHANGELOG.md0000664000175000017500000005401512610310643014715 0ustar v0.23 + 1 ------- ### Changes or improvements * Custom filters can now be registered with wildcard attributes, for example `filter=*`. Consumers should examine the attributes parameter of the `check` function for details. * Symlinks are now followed when locking a file, which can be necessary when multiple worktrees share a base repository. ### API additions * `git_config_lock()` has been added, which allow for transactional/atomic complex updates to the configuration, removing the opportunity for concurrent operations and not committing any changes until the unlock. ### API removals ### Breaking API changes * `git_cert` descendent types now have a proper `parent` member * It is the responsibility of the refdb backend to decide what to do with the reflog on ref deletion. The file-based backend must delete it, a database-backed one may wish to archive it. * `git_config_backend` has gained two entries. `lock` and `unlock` with which to implement the transactional/atomic semantics for the configuration backend. * `git_index_add` will now use the case as provided by the caller on case insensitive systems. Previous versions would keep the case as it existed in the index. This does not affect the higher-level `git_index_add_bypath` or `git_index_add_frombuffer` functions. v0.23 ------ ### Changes or improvements * Patience and minimal diff drivers can now be used for merges. * Merges can now ignore whitespace changes. * Updated binary identification in CRLF filtering to avoid false positives in UTF-8 files. * Rename and copy detection is enabled for small files. * Checkout can now handle an initial checkout of a repository, making `GIT_CHECKOUT_SAFE_CREATE` unnecessary for users of clone. * The signature parameter in the ref-modifying functions has been removed. Use `git_repository_set_ident()` and `git_repository_ident()` to override the signature to be used. * The local transport now auto-scales the number of threads to use when creating the packfile instead of sticking to one. * Reference renaming now uses the right id for the old value. * The annotated version of branch creation, HEAD detaching and reset allow for specifying the expression from the user to be put into the reflog. * `git_rebase_commit` now returns `GIT_EUNMERGED` when you attempt to commit with unstaged changes. * On Mac OS X, we now use SecureTransport to provide the cryptographic support for HTTPS connections insead of OpenSSL. * Checkout can now accept an index for the baseline computations via the `baseline_index` member. * The configuration for fetching is no longer stored inside the `git_remote` struct but has been moved to a `git_fetch_options`. The remote functions now take these options or the callbacks instead of setting them beforehand. * `git_submodule` instances are no longer cached or shared across lookup. Each submodule represents the configuration at the time of loading. * The index now uses diffs for `add_all()` and `update_all()` which gives it a speed boost and closer semantics to git. * The ssh transport now reports the stderr output from the server as the error message, which allows you to get the "repository not found" messages. * `git_index_conflict_add()` will remove staged entries that exist for conflicted paths. * The flags for a `git_diff_file` will now have the `GIT_DIFF_FLAG_EXISTS` bit set when a file exists on that side of the diff. This is useful for understanding whether a side of the diff exists in the presence of a conflict. * The constructor for a write-stream into the odb now takes `git_off_t` instead of `size_t` for the size of the blob, which allows putting large files into the odb on 32-bit systems. * The remote's push and pull URLs now honor the url.$URL.insteadOf configuration. This allows modifying URL prefixes to a custom value via gitconfig. * `git_diff_foreach`, `git_diff_blobs`, `git_diff_blob_to_buffer`, and `git_diff_buffers` now accept a new binary callback of type `git_diff_binary_cb` that includes the binary diff information. * The race condition mitigations described in `racy-git.txt` have been implemented. * If libcurl is installed, we will use it to connect to HTTP(S) servers. ### API additions * The `git_merge_options` gained a `file_flags` member. * Parsing and retrieving a configuration value as a path is exposed via `git_config_parse_path()` and `git_config_get_path()` respectively. * `git_repository_set_ident()` and `git_repository_ident()` serve to set and query which identity will be used when writing to the reflog. * `git_config_entry_free()` frees a config entry. * `git_config_get_string_buf()` provides a way to safely retrieve a string from a non-snapshot configuration. * `git_annotated_commit_from_revspec()` allows to get an annotated commit from an extended sha synatx string. * `git_repository_set_head_detached_from_annotated()`, `git_branch_create_from_annotated()` and `git_reset_from_annotated()` allow for the caller to provide an annotated commit through which they can control what expression is put into the reflog as the source/target. * `git_index_add_frombuffer()` can now create a blob from memory buffer and add it to the index which is attached to a repository. * The structure `git_fetch_options` has been added to determine the runtime configuration for fetching, such as callbacks, pruning and autotag behaviour. It has the runtime initializer `git_fetch_init_options()`. * The enum `git_fetch_prune_t` has been added, letting you specify the pruning behaviour for a fetch. * A push operation will notify the caller of what updates it indends to perform on the remote, which provides similar information to git's pre-push hook. * `git_stash_apply()` can now apply a stashed state from the stash list, placing the data into the working directory and index. * `git_stash_pop()` will apply a stashed state (like `git_stash_apply()`) but will remove the stashed state after a successful application. * A new error code `GIT_EEOF` indicates an early EOF from the server. This typically indicates an error with the URL or configuration of the server, and tools can use this to show messages about failing to communicate with the server. * A new error code `GIT_EINVALID` indicates that an argument to a function is invalid, or an invalid operation was requested. * `git_diff_index_to_workdir()` and `git_diff_tree_to_index()` will now produce deltas of type `GIT_DELTA_CONFLICTED` to indicate that the index side of the delta is a conflict. * The `git_status` family of functions will now produce status of type `GIT_STATUS_CONFLICTED` to indicate that a conflict exists for that file in the index. * `git_index_entry_is_conflict()` is a utility function to determine if a given index entry has a non-zero stage entry, indicating that it is one side of a conflict. * It is now possible to pass a keypair via a buffer instead of a path. For this, `GIT_CREDTYPE_SSH_MEMORY` and `git_cred_ssh_key_memory_new()` have been added. * `git_filter_list_contains` will indicate whether a particular filter will be run in the given filter list. * `git_commit_header_field()` has been added, which allows retrieving the contents of an arbitrary header field. * `git_submodule_set_branch()` allows to set the configured branch for a submodule. ### API removals * `git_remote_save()` and `git_remote_clear_refspecs()` have been removed. Remote's configuration is changed via the configuration directly or through a convenience function which performs changes to the configuration directly. * `git_remote_set_callbacks()`, `git_remote_get_callbacks()` and `git_remote_set_transport()` have been removed and the remote no longer stores this configuration. * `git_remote_set_fetch_refpecs()` and `git_remote_set_push_refspecs()` have been removed. There is no longer a way to set the base refspecs at run-time. * `git_submodule_save()` has been removed. The submodules are no longer configured via the objects. * `git_submodule_reload_all()` has been removed as we no longer cache submodules. ### Breaking API changes * `git_smart_subtransport_cb` now has a `param` parameter. * The `git_merge_options` structure member `flags` has been renamed to `tree_flags`. * The `git_merge_file_options` structure member `flags` is now an unsigned int. It was previously a `git_merge_file_flags_t`. * `GIT_CHECKOUT_SAFE_CREATE` has been removed. Most users will generally be able to switch to `GIT_CHECKOUT_SAFE`, but if you require missing file handling during checkout, you may now use `GIT_CHECKOUT_SAFE | GIT_CHECKOUT_RECREATE_MISSING`. * The `git_clone_options` and `git_submodule_update_options` structures no longer have a `signature` field. * The following functions have removed the signature and/or log message parameters in favour of git-emulating ones. * `git_branch_create()`, `git_branch_move()` * `git_rebase_init()`, `git_rebase_abort()` * `git_reference_symbolic_create_matching()`, `git_reference_symbolic_create()`, `git_reference_create()`, `git_reference_create_matching()`, `git_reference_symbolic_set_target()`, `git_reference_set_target()`, `git_reference_rename()` * `git_remote_update_tips()`, `git_remote_fetch()`, `git_remote_push()` * `git_repository_set_head()`, `git_repository_set_head_detached()`, `git_repository_detach_head()` * `git_reset()` * `git_config_get_entry()` now gives back a ref-counted `git_config_entry`. You must free it when you no longer need it. * `git_config_get_string()` will return an error if used on a non-snapshot configuration, as there can be no guarantee that the returned pointer is valid. * `git_note_default_ref()` now uses a `git_buf` to return the string, as the string is otherwise not guaranteed to stay allocated. * `git_rebase_operation_current()` will return `GIT_REBASE_NO_OPERATION` if it is called immediately after creating a rebase session but before you have applied the first patch. * `git_rebase_options` now contains a `git_checkout_options` struct that will be used for functions that modify the working directory, namely `git_checkout_init`, `git_checkout_next` and `git_checkout_abort`. As a result, `git_rebase_open` now also takes a `git_rebase_options` and only the `git_rebase_init` and `git_rebase_open` functions take a `git_rebase_options`, where they will persist the options to subsequent `git_rebase` calls. * The `git_clone_options` struct now has fetch options in a `fetch_opts` field instead of remote callbacks in `remote_callbacks`. * The remote callbacks has gained a new member `push_negotiation` which gets called before sending the update commands to the server. * The following functions no longer act on a remote instance but change the repository's configuration. Their signatures have changed accordingly: * `git_remote_set_url()`, `git_remote_seturl()` * `git_remote_add_fetch()`, `git_remote_add_push()` and * `git_remote_set_autotag()` * `git_remote_connect()` and `git_remote_prune()` now take a pointer to the callbacks. * `git_remote_fetch()` and `git_remote_download()` now take a pointer to fetch options which determine the runtime configuration. * The `git_remote_autotag_option_t` values have been changed. It has gained a `_UNSPECIFIED` default value to specify no override for the configured setting. * `git_remote_update_tips()` now takes a pointer to the callbacks as well as a boolean whether to write `FETCH_HEAD` and the autotag setting. * `git_remote_create_anonymous()` no longer takes a fetch refspec as url-only remotes cannot have configured refspecs. * The `git_submodule_update_options` struct now has fetch options in the `fetch_opts` field instead of callbacks in the `remote_callbacks` field. * The following functions no longer act on a submodule instance but change the repository's configuration. Their signatures have changed accordingly: * `git_submodule_set_url()`, `git_submodule_set_ignore()`, `git_submodule_set_update()`, `git_submodule_set_fetch_recurse_submodules()`. * `git_submodule_status()` no longer takes a submodule instance but a repsitory, a submodule name and an ignore setting. * The `push` function in the `git_transport` interface now takes a pointer to the remote callbacks. * The `git_index_entry` struct's fields' types have been changed to more accurately reflect what is in fact stored in the index. Specifically, time and file size are 32 bits intead of 64, as these values are truncated. * `GIT_EMERGECONFLICT` is now `GIT_ECONFLICT`, which more accurately describes the nature of the error. * It is no longer allowed to call `git_buf_grow()` on buffers borrowing the memory they point to. v0.22 ------ ### Changes or improvements * `git_signature_new()` now requires a non-empty email address. * Use CommonCrypto libraries for SHA-1 calculation on Mac OS X. * Disable SSL compression and SSLv2 and SSLv3 ciphers in favor of TLSv1 in OpenSSL. * The fetch behavior of remotes with autotag set to `GIT_REMOTE_DOWNLOAD_TAGS_ALL` has been changed to match git 1.9.0 and later. In this mode, libgit2 now fetches all tags in addition to whatever else needs to be fetched. * `git_checkout()` now handles case-changing renames correctly on case-insensitive filesystems; for example renaming "readme" to "README". * The search for libssh2 is now done via pkg-config instead of a custom search of a few directories. * Add support for core.protectHFS and core.protectNTFS. Add more validation for filenames which we write such as references. * The local transport now generates textual progress output like git-upload-pack does ("counting objects"). * `git_checkout_index()` can now check out an in-memory index that is not necessarily the repository's index, so you may check out an index that was produced by git_merge and friends while retaining the cached information. * Remove the default timeout for receiving / sending data over HTTP using the WinHTTP transport layer. * Add SPNEGO (Kerberos) authentication using GSSAPI on Unix systems. * Provide built-in objects for the empty blob (e69de29) and empty tree (4b825dc) objects. * The index' tree cache is now filled upon read-tree and write-tree and the cache is written to disk. * LF -> CRLF filter refuses to handle mixed-EOL files * LF -> CRLF filter now runs when * text = auto (with Git for Windows 1.9.4) * File unlocks are atomic again via rename. Read-only files on Windows are made read-write if necessary. * Share open packfiles across repositories to share descriptors and mmaps. * Use a map for the treebuilder, making insertion O(1) * The build system now accepts an option EMBED_SSH_PATH which when set tells it to include a copy of libssh2 at the given location. This is enabled for MSVC. * Add support for refspecs with the asterisk in the middle of a pattern. * Fetching now performs opportunistic updates. To achieve this, we introduce a difference between active and passive refspecs, which make `git_remote_download()` and `git_remote_fetch()` to take a list of resfpecs to be the active list, similarly to how git fetch accepts a list on the command-line. * The THREADSAFE option to build libgit2 with threading support has been flipped to be on by default. * The remote object has learnt to prune remote-tracking branches. If the remote is configured to do so, this will happen via `git_remote_fetch()`. You can also call `git_remote_prune()` after connecting or fetching to perform the prune. ### API additions * Introduce `git_buf_text_is_binary()` and `git_buf_text_contains_nul()` for consumers to perform binary detection on a git_buf. * `git_branch_upstream_remote()` has been introduced to provide the branch..remote configuration value. * Introduce `git_describe_commit()` and `git_describe_workdir()` to provide a description of the current commit (and working tree, respectively) based on the nearest tag or reference * Introduce `git_merge_bases()` and the `git_oidarray` type to expose all merge bases between two commits. * Introduce `git_merge_bases_many()` to expose all merge bases between multiple commits. * Introduce rebase functionality (using the merge algorithm only). Introduce `git_rebase_init()` to begin a new rebase session, `git_rebase_open()` to open an in-progress rebase session, `git_rebase_commit()` to commit the current rebase operation, `git_rebase_next()` to apply the next rebase operation, `git_rebase_abort()` to abort an in-progress rebase and `git_rebase_finish()` to complete a rebase operation. * Introduce `git_note_author()` and `git_note_committer()` to get the author and committer information on a `git_note`, respectively. * A factory function for ssh has been added which allows to change the path of the programs to execute for receive-pack and upload-pack on the server, `git_transport_ssh_with_paths()`. * The ssh transport supports asking the remote host for accepted credential types as well as multiple challeges using a single connection. This requires to know which username you want to connect as, so this introduces the USERNAME credential type which the ssh transport will use to ask for the username. * The `GIT_EPEEL` error code has been introduced when we cannot peel a tag to the requested object type; if the given object otherwise cannot be peeled, `GIT_EINVALIDSPEC` is returned. * Introduce `GIT_REPOSITORY_INIT_RELATIVE_GITLINK` to use relative paths when writing gitlinks, as is used by git core for submodules. * `git_remote_prune()` has been added. See above for description. * Introduce reference transactions, which allow multiple references to be locked at the same time and updates be queued. This also allows us to safely update a reflog with arbitrary contents, as we need to do for stash. ### API removals * `git_remote_supported_url()` and `git_remote_is_valid_url()` have been removed as they have become essentially useless with rsync-style ssh paths. * `git_clone_into()` and `git_clone_local_into()` have been removed from the public API in favour of `git_clone callbacks`. * The option to ignore certificate errors via `git_remote_cert_check()` is no longer present. Instead, `git_remote_callbacks` has gained a new entry which lets the user perform their own certificate checks. ### Breaking API changes * `git_cherry_pick()` is now `git_cherrypick()`. * The `git_submodule_update()` function was renamed to `git_submodule_update_strategy()`. `git_submodule_update()` is now used to provide functionalty similar to "git submodule update". * `git_treebuilder_create()` was renamed to `git_treebuilder_new()` to better reflect it being a constructor rather than something which writes to disk. * `git_treebuilder_new()` (was `git_treebuilder_create()`) now takes a repository so that it can query repository configuration. Subsequently, `git_treebuilder_write()` no longer takes a repository. * `git_threads_init()` and `git_threads_shutdown()` have been renamed to `git_libgit2_init()` and `git_libgit2_shutdown()` to better explain what their purpose is, as it's grown to be more than just about threads. * `git_libgit2_init()` and `git_libgit2_shutdown()` now return the number of initializations of the library, so consumers may schedule work on the first initialization. * The `git_transport_register()` function no longer takes a priority and takes a URL scheme name (eg "http") instead of a prefix like "http://" * `git_index_name_entrycount()` and `git_index_reuc_entrycount()` now return size_t instead of unsigned int. * The `context_lines` and `interhunk_lines` fields in `git_diff`_options are now `uint32_t` instead of `uint16_t`. This allows to set them to `UINT_MAX`, in effect asking for "infinite" context e.g. to iterate over all the unmodified lines of a diff. * `git_status_file()` now takes an exact path. Use `git_status_list_new()` if pathspec searching is needed. * `git_note_create()` has changed the position of the notes reference name to match `git_note_remove()`. * Rename `git_remote_load()` to `git_remote_lookup()` to bring it in line with the rest of the lookup functions. * `git_remote_rename()` now takes the repository and the remote's current name. Accepting a remote indicates we want to change it, which we only did partially. It is much clearer if we accept a name and no loaded objects are changed. * `git_remote_delete()` now accepts the repository and the remote's name instead of a loaded remote. * `git_merge_head` is now `git_annotated_commit`, to better reflect its usage for multiple functions (including rebase) * The `git_clone_options` struct no longer provides the `ignore_cert_errors` or `remote_name` members for remote customization. Instead, the `git_clone_options` struct has two new members, `remote_cb` and `remote_cb_payload`, which allow the caller to completely override the remote creation process. If needed, the caller can use this callback to give their remote a name other than the default (origin) or disable cert checking. The `remote_callbacks` member has been preserved for convenience, although it is not used when a remote creation callback is supplied. * The `git_clone`_options struct now provides `repository_cb` and `repository_cb_payload` to allow the user to create a repository with custom options. * The `git_push` struct to perform a push has been replaced with `git_remote_upload()`. The refspecs and options are passed as a function argument. `git_push_update_tips()` is now also `git_remote_update_tips()` and the callbacks are in the same struct as the rest. * The `git_remote_set_transport()` function now sets a transport factory function, rather than a pre-existing transport instance. * The `git_transport` structure definition has moved into the sys/transport.h file. * libgit2 no longer automatically sets the OpenSSL locking functions. This is not something which we can know to do. A last-resort convenience function is provided in sys/openssl.h, `git_openssl_set_locking()` which can be used to set the locking. deps/libgit2-sys-0.3.8/libgit2/AUTHORS0000664000175000017500000000235712555730137014172 0ustar The following people contribute or have contributed to the libgit2 project (sorted alphabetically): Alex Budovski Alexei Sholik Andreas Ericsson Anton "antong" Gyllenberg Ankur Sethi Arthur Schreiber Ben Noordhuis Ben Straub Benjamin C Meyer Brian Downing Brian Lopez Carlos Martín Nieto Colin Timmermans Daniel Huckstep Dave Borowitz David Boyce David Glesser Dmitry Kakurin Dmitry Kovega Emeric Fermas Emmanuel Rodriguez Florian Forster Holger Weiss Ingmar Vanhassel J. David Ibáñez Jacques Germishuys Jakob Pfender Jason Penny Jason R. McNeil Jerome Lambourg Johan 't Hart John Wiegley Jonathan "Duke" Leto Julien Miotte Julio Espinoza-Sokal Justin Love Kelly "kelly.leahy" Leahy Kirill A. Shutemov Lambert CLARA Luc Bertrand Marc Pegon Marcel Groothuis Marco Villegas Michael "schu" Schubert Microsoft Corporation Olivier Ramonat Peter Drahoš Pierre Habouzit Pierre-Olivier Latour Przemyslaw Pawelczyk Ramsay Jones Robert G. Jakabosky Romain Geissler Romain Muller Russell Belfer Sakari Jokinen Samuel Charles "Sam" Day Sarath Lakshman Sascha Cunz Sascha Peilicke Scott Chacon Sebastian Schuberth Sergey Nikishin Shawn O. Pearce Shuhei Tanuma Steve Frécinaux Sven Strickroth Tim Branyen Tim Clem Tim Harder Torsten Bögershausen Trent Mick Vicent Marti deps/libgit2-sys-0.3.8/libgit2/COPYING0000664000175000017500000014101212572105236014140 0ustar libgit2 is Copyright (C) the libgit2 contributors, unless otherwise stated. See the AUTHORS file for details. Note that the only valid version of the GPL as far as this project is concerned is _this_ particular version of the license (ie v2, not v2.2 or v3.x or whatever), unless explicitly otherwise stated. ---------------------------------------------------------------------- LINKING EXCEPTION In addition to the permissions in the GNU General Public License, the authors give you unlimited permission to link the compiled version of this library into combinations with other programs, and to distribute those combinations without any restriction coming from the use of this file. (The General Public License restrictions do apply in other respects; for example, they cover modification of the file, and distribution when not linked into a combined executable.) ---------------------------------------------------------------------- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. ---------------------------------------------------------------------- The bundled ZLib code is licensed under the ZLib license: Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Jean-loup Gailly Mark Adler jloup@gzip.org madler@alumni.caltech.edu ---------------------------------------------------------------------- The Clar framework is licensed under the ISC license: Copyright (c) 2011-2015 Vicent Marti Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ---------------------------------------------------------------------- The regex library (deps/regex/) is licensed under the GNU LGPL (available at the end of this file). Definitions for data structures and routines for the regular expression library. Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006,2008 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ---------------------------------------------------------------------- The bundled winhttp definition files (deps/winhttp/) are licensed under the GNU LGPL (available at the end of this file). Copyright (C) 2007 Francois Gouget This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA ---------------------------------------------------------------------- GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! ---------------------------------------------------------------------- deps/libgit2-sys-0.3.8/libgit2/THREADING.md0000664000175000017500000001063312555730137014745 0ustar Threads in libgit2 ================== You may safely use any libgit2 object from any thread, though there may be issues depending on the cryptographic libraries libgit2 or its dependencies link to (more on this later). For libgit2 itself, provided you take the following into consideration you won't run into issues: Sharing objects --------------- Use an object from a single thread at a time. Most data structures do not guard against concurrent access themselves. This is because they are rarely used in isolation and it makes more sense to synchronize access via a larger lock or similar mechanism. There are some objects which are read-only/immutable and are thus safe to share across threads, such as references and configuration snapshots. Error messages -------------- The error message is thread-local. The `giterr_last()` call must happen on the same thread as the error in order to get the message. Often this will be the case regardless, but if you use something like the [GCD](http://en.wikipedia.org/wiki/Grand_Central_Dispatch) on Mac OS X (where code is executed on an arbitrary thread), the code must make sure to retrieve the error code on the thread where the error happened. Threads and cryptographic libraries ======================================= On Windows ---------- When built as a native Windows DLL, libgit2 uses WinCNG and WinHTTP, both of which are thread-safe. You do not need to do anything special. When using libssh2 which itself uses WinCNG, there are no special steps necessary. If you are using a MinGW or similar environment where libssh2 uses OpenSSL or libgcrypt, then the general case affects you. On Mac OS X ----------- By default we use libcurl to perform the encryption. The system-provided libcurl uses SecureTransport, so no special steps are necessary. If you link against another libcurl (e.g. from homebrew) refer to the general case. If the option to use libcurl was deactivated, the library makes use of CommonCrypto and SecureTransport for cryptographic support. These are thread-safe and you do not need to do anything special. Note that libssh2 may still use OpenSSL itself. In that case, the general case still affects you if you use ssh. General Case ------------ By default we use libcurl, which has its own ![recommendations for thread safety](http://curl.haxx.se/libcurl/c/libcurl-tutorial.html#Multi-threading). If libcurl was not found or was disabled, libgit2 uses OpenSSL to be able to use HTTPS as a transport. This library is made to be thread-implementation agnostic, and the users of the library must set which locking function it should use. This means that libgit2 cannot know what to set as the user of libgit2 may use OpenSSL independently and the locking settings must survive libgit2 shutting down. libgit2 does provide a last-resort convenience function `git_openssl_set_locking()` (available in `sys/openssl.h`) to use the platform-native mutex mechanisms to perform the locking, which you may rely on if you do not want to use OpenSSL outside of libgit2, or you know that libgit2 will outlive the rest of the operations. It is not safe to use OpenSSL multi-threaded after libgit2's shutdown function has been called. If your programming language offers a package/bindings for OpenSSL, you should very strongly prefer to use that in order to set up locking, as they provide a level of coördination which is impossible when using this function. See the [OpenSSL documentation](https://www.openssl.org/docs/crypto/threads.html) on threading for more details. Be also aware that libgit2 does not always link against OpenSSL if there are alternatives provided by the system. libssh2 may be linked against OpenSSL or libgcrypt. If it uses OpenSSL, you only need to set up threading for OpenSSL once and the above paragraphs are enough. If it uses libgcrypt, then you need to set up its locking before using it multi-threaded. libgit2 has no direct connection to libgcrypt and thus has not convenience functions for it (but libgcrypt has macros). Read libgcrypt's [threading documentation for more information](http://www.gnupg.org/documentation/manuals/gcrypt/Multi_002dThreading.html) It is your responsibility as an application author or packager to know what your dependencies are linked against and to take the appropriate steps to ensure the cryptographic libraries are thread-safe. We agree that this situation is far from ideal but at this time it is something the application authors need to deal with. deps/libgit2-sys-0.3.8/libgit2/CONVENTIONS.md0000664000175000017500000001676712426525445015264 0ustar # Libgit2 Conventions We like to keep the source consistent and readable. Herein are some guidelines that should help with that. ## Compatibility `libgit2` runs on many different platforms with many different compilers. The public API of `libgit2` is [ANSI C](http://en.wikipedia.org/wiki/ANSI_C) (a.k.a. C89) compatible. Internally, `libgit2` is written using a portable subset of C99 - in order to maximize compatibility (e.g. with MSVC) we avoid certain C99 extensions. Specifically, we keep local variable declarations at the tops of blocks only and we avoid `//` style comments. Also, to the greatest extent possible, we try to avoid lots of `#ifdef`s inside the core code base. This is somewhat unavoidable, but since it can really hamper maintainability, we keep it to a minimum. ## Match Surrounding Code If there is one rule to take away from this document, it is *new code should match the surrounding code in a way that makes it impossible to distinguish the new from the old.* Consistency is more important to us than anyone's personal opinion about where braces should be placed or spaces vs. tabs. If a section of code is being completely rewritten, it is okay to bring it in line with the standards that are laid out here, but we will not accept submissions that contain a large number of changes that are merely reformatting. ## Naming Things All external types and functions start with `git_` and all `#define` macros start with `GIT_`. The `libgit2` API is mostly broken into related functional modules each with a corresponding header. All functions in a module should be named like `git_modulename_functioname()` (e.g. `git_repository_open()`). Functions with a single output parameter should name that parameter `out`. Multiple outputs should be named `foo_out`, `bar_out`, etc. Parameters of type `git_oid` should be named `id`, or `foo_id`. Calls that return an OID should be named `git_foo_id`. Where a callback function is used, the function should also include a user-supplied extra input that is a `void *` named "payload" that will be passed through to the callback at each invocation. ## Typedefs Wherever possible, use `typedef`. In some cases, if a structure is just a collection of function pointers, the pointer types don't need to be separately typedef'd, but loose function pointer types should be. ## Exports All exported functions must be declared as: ```c GIT_EXTERN(result_type) git_modulename_functionname(arg_list); ``` ## Internals Functions whose *modulename* is followed by two underscores, for example `git_odb__read_packed`, are semi-private functions. They are primarily intended for use within the library itself, and may disappear or change their signature in a future release. ## Parameters Out parameters come first. Whenever possible, pass argument pointers as `const`. Some structures (such as `git_repository` and `git_index`) have mutable internal structure that prevents this. Callbacks should always take a `void *` payload as their last parameter. Callback pointers are grouped with their payloads, and typically come last when passed as arguments: ```c int git_foo(git_repository *repo, git_foo_cb callback, void *payload); ``` ## Memory Ownership Some APIs allocate memory which the caller is responsible for freeing; others return a pointer into a buffer that's owned by some other object. Make this explicit in the documentation. ## Return codes Most public APIs should return an `int` error code. As is typical with most C library functions, a zero value indicates success and a negative value indicates failure. Some bindings will transform these returned error codes into exception types, so returning a semantically appropriate error code is important. Check [`include/git2/errors.h`](https://github.com/libgit2/libgit2/blob/development/include/git2/errors.h) for the return codes already defined. In your implementation, use `giterr_set()` to provide extended error information to callers. If a `libgit2` function internally invokes another function that reports an error, but the error is not propagated up, use `giterr_clear()` to prevent callers from getting the wrong error message later on. ## Structs Most public types should be opaque, e.g.: ```C typedef struct git_odb git_odb; ``` ...with allocation functions returning an "instance" created within the library, and not within the application. This allows the type to grow (or shrink) in size without rebuilding client code. To preserve ABI compatibility, include an `int version` field in all opaque structures, and initialize to the latest version in the construction call. Increment the "latest" version whenever the structure changes, and try to only append to the end of the structure. ## Option Structures If a function's parameter count is too high, it may be desirable to package up the options in a structure. Make them transparent, include a version field, and provide an initializer constant or constructor. Using these structures should be this easy: ```C git_foo_options opts = GIT_FOO_OPTIONS_INIT; opts.baz = BAZ_OPTION_ONE; git_foo(&opts); ``` ## Enumerations Typedef all enumerated types. If each option stands alone, use the enum type for passing them as parameters; if they are flags to be OR'ed together, pass them as `unsigned int` or `uint32_t` or some appropriate type. ## Code Layout Try to keep lines less than 80 characters long. This is a loose requirement, but going significantly over 80 columns is not nice. Use common sense to wrap most code lines; public function declarations can use a couple of different styles: ```c /** All on one line is okay if it fits */ GIT_EXTERN(int) git_foo_simple(git_oid *id); /** Otherwise one argument per line is a good next step */ GIT_EXTERN(int) git_foo_id( git_oid **out, int a, int b); ``` Indent with tabs; set your editor's tab width to 4 for best effect. Avoid trailing whitespace and only commit Unix-style newlines (i.e. no CRLF in the repository - just set `core.autocrlf` to true if you are writing code on a Windows machine). ## Documentation All comments should conform to Doxygen "javadoc" style conventions for formatting the public API documentation. Try to document every parameter, and keep the comments up to date if you change the parameter list. ## Public Header Template Use this template when creating a new public header. ```C #ifndef INCLUDE_git_${filename}_h__ #define INCLUDE_git_${filename}_h__ #include "git/common.h" /** * @file git/${filename}.h * @brief Git some description * @defgroup git_${filename} some description routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /* ... definitions ... */ /** @} */ GIT_END_DECL #endif ``` ## Inlined functions All inlined functions must be declared as: ```C GIT_INLINE(result_type) git_modulename_functionname(arg_list); ``` `GIT_INLINE` (or `inline`) should not be used in public headers in order to preserve ANSI C compatibility. ## Tests `libgit2` uses the [clar](https://github.com/vmg/clar) testing framework. All PRs should have corresponding tests. * If the PR fixes an existing issue, the test should fail prior to applying the PR and succeed after applying it. * If the PR is for new functionality, then the tests should exercise that new functionality to a certain extent. We don't require 100% coverage right now (although we are getting stricter over time). When adding new tests, we prefer if you attempt to reuse existing test data (in `tests-clar/resources/`) if possible. If you are going to add new test repositories, please try to strip them of unnecessary files (e.g. sample hooks, etc). deps/libgit2-sys-0.3.8/libgit2/Makefile.embed0000664000175000017500000000231012426525445015623 0ustar PLATFORM=$(shell uname -s) ifneq (,$(CROSS_COMPILE)) PREFIX=$(CROSS_COMPILE)- else PREFIX= endif MINGW=0 ifneq (,$(findstring MINGW32,$(PLATFORM))) MINGW=1 endif ifneq (,$(findstring mingw,$(CROSS_COMPILE))) MINGW=1 endif rm=rm -f AR=$(PREFIX)ar cq RANLIB=$(PREFIX)ranlib LIBNAME=libgit2.a ifeq ($(MINGW),1) CC=gcc else CC=cc endif CC:=$(PREFIX)$(CC) INCLUDES= -I. -Isrc -Iinclude -Ideps/http-parser -Ideps/zlib DEFINES= $(INCLUDES) -DNO_VIZ -DSTDC -DNO_GZIP -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $(EXTRA_DEFINES) CFLAGS= -g $(DEFINES) -Wall -Wextra -Wno-missing-field-initializers -O2 $(EXTRA_CFLAGS) SRCS = $(wildcard src/*.c) $(wildcard src/transports/*.c) $(wildcard src/xdiff/*.c) $(wildcard deps/http-parser/*.c) $(wildcard deps/zlib/*.c) src/hash/hash_generic.c ifeq ($(MINGW),1) SRCS += $(wildcard src/win32/*.c) $(wildcard src/compat/*.c) deps/regex/regex.c INCLUDES += -Ideps/regex DEFINES += -DWIN32 -D_WIN32_WINNT=0x0501 -D__USE_MINGW_ANSI_STDIO=1 else SRCS += $(wildcard src/unix/*.c) CFLAGS += -fPIC endif OBJS = $(patsubst %.c,%.o,$(SRCS)) %.c.o: $(CC) $(CFLAGS) -c $*.c all: $(LIBNAME) $(LIBNAME): $(OBJS) $(rm) $@ $(AR) $@ $(OBJS) $(RANLIB) $@ clean: $(rm) $(OBJS) $(LIBNAME) deps/libgit2-sys-0.3.8/libgit2/libgit2_clar.supp0000664000175000017500000000076212426525445016367 0ustar { ignore-zlib-errors-cond Memcheck:Cond obj:*libz.so* } { ignore-giterr-set-leak Memcheck:Leak ... fun:giterr_set } { ignore-git-global-state-leak Memcheck:Leak ... fun:git__global_state } { ignore-openssl-ssl-leak Memcheck:Leak ... obj:*libssl.so* ... } { ignore-openssl-crypto-leak Memcheck:Leak ... obj:*libcrypto.so* ... } { ignore-openssl-crypto-cond Memcheck:Cond obj:*libcrypto.so* ... } { ignore-glibc-getaddrinfo-cache Memcheck:Leak ... fun:__check_pf } deps/libgit2-sys-0.3.8/libgit2/include/0000755000000000000000000000000012666635520016315 5ustar rootrootdeps/libgit2-sys-0.3.8/libgit2/include/git2/0000755000000000000000000000000012666635520017162 5ustar rootrootdeps/libgit2-sys-0.3.8/libgit2/include/git2/object.h0000664000175000017500000001630112510265101017004 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_object_h__ #define INCLUDE_git_object_h__ #include "common.h" #include "types.h" #include "oid.h" #include "buffer.h" /** * @file git2/object.h * @brief Git revision object management routines * @defgroup git_object Git revision object management routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Lookup a reference to one of the objects in a repository. * * The generated reference is owned by the repository and * should be closed with the `git_object_free` method * instead of free'd manually. * * The 'type' parameter must match the type of the object * in the odb; the method will fail otherwise. * The special value 'GIT_OBJ_ANY' may be passed to let * the method guess the object's type. * * @param object pointer to the looked-up object * @param repo the repository to look up the object * @param id the unique identifier for the object * @param type the type of the object * @return 0 or an error code */ GIT_EXTERN(int) git_object_lookup( git_object **object, git_repository *repo, const git_oid *id, git_otype type); /** * Lookup a reference to one of the objects in a repository, * given a prefix of its identifier (short id). * * The object obtained will be so that its identifier * matches the first 'len' hexadecimal characters * (packets of 4 bits) of the given 'id'. * 'len' must be at least GIT_OID_MINPREFIXLEN, and * long enough to identify a unique object matching * the prefix; otherwise the method will fail. * * The generated reference is owned by the repository and * should be closed with the `git_object_free` method * instead of free'd manually. * * The 'type' parameter must match the type of the object * in the odb; the method will fail otherwise. * The special value 'GIT_OBJ_ANY' may be passed to let * the method guess the object's type. * * @param object_out pointer where to store the looked-up object * @param repo the repository to look up the object * @param id a short identifier for the object * @param len the length of the short identifier * @param type the type of the object * @return 0 or an error code */ GIT_EXTERN(int) git_object_lookup_prefix( git_object **object_out, git_repository *repo, const git_oid *id, size_t len, git_otype type); /** * Lookup an object that represents a tree entry. * * @param out buffer that receives a pointer to the object (which must be freed * by the caller) * @param treeish root object that can be peeled to a tree * @param path relative path from the root object to the desired object * @param type type of object desired * @return 0 on success, or an error code */ GIT_EXTERN(int) git_object_lookup_bypath( git_object **out, const git_object *treeish, const char *path, git_otype type); /** * Get the id (SHA1) of a repository object * * @param obj the repository object * @return the SHA1 id */ GIT_EXTERN(const git_oid *) git_object_id(const git_object *obj); /** * Get a short abbreviated OID string for the object * * This starts at the "core.abbrev" length (default 7 characters) and * iteratively extends to a longer string if that length is ambiguous. * The result will be unambiguous (at least until new objects are added to * the repository). * * @param out Buffer to write string into * @param obj The object to get an ID for * @return 0 on success, <0 for error */ GIT_EXTERN(int) git_object_short_id(git_buf *out, const git_object *obj); /** * Get the object type of an object * * @param obj the repository object * @return the object's type */ GIT_EXTERN(git_otype) git_object_type(const git_object *obj); /** * Get the repository that owns this object * * Freeing or calling `git_repository_close` on the * returned pointer will invalidate the actual object. * * Any other operation may be run on the repository without * affecting the object. * * @param obj the object * @return the repository who owns this object */ GIT_EXTERN(git_repository *) git_object_owner(const git_object *obj); /** * Close an open object * * This method instructs the library to close an existing * object; note that git_objects are owned and cached by the repository * so the object may or may not be freed after this library call, * depending on how aggressive is the caching mechanism used * by the repository. * * IMPORTANT: * It *is* necessary to call this method when you stop using * an object. Failure to do so will cause a memory leak. * * @param object the object to close */ GIT_EXTERN(void) git_object_free(git_object *object); /** * Convert an object type to its string representation. * * The result is a pointer to a string in static memory and * should not be free()'ed. * * @param type object type to convert. * @return the corresponding string representation. */ GIT_EXTERN(const char *) git_object_type2string(git_otype type); /** * Convert a string object type representation to it's git_otype. * * @param str the string to convert. * @return the corresponding git_otype. */ GIT_EXTERN(git_otype) git_object_string2type(const char *str); /** * Determine if the given git_otype is a valid loose object type. * * @param type object type to test. * @return true if the type represents a valid loose object type, * false otherwise. */ GIT_EXTERN(int) git_object_typeisloose(git_otype type); /** * Get the size in bytes for the structure which * acts as an in-memory representation of any given * object type. * * For all the core types, this would the equivalent * of calling `sizeof(git_commit)` if the core types * were not opaque on the external API. * * @param type object type to get its size * @return size in bytes of the object */ GIT_EXTERN(size_t) git_object__size(git_otype type); /** * Recursively peel an object until an object of the specified type is met. * * If the query cannot be satisfied due to the object model, * GIT_EINVALIDSPEC will be returned (e.g. trying to peel a blob to a * tree). * * If you pass `GIT_OBJ_ANY` as the target type, then the object will * be peeled until the type changes. A tag will be peeled until the * referenced object is no longer a tag, and a commit will be peeled * to a tree. Any other object type will return GIT_EINVALIDSPEC. * * If peeling a tag we discover an object which cannot be peeled to * the target type due to the object model, GIT_EPEEL will be * returned. * * You must free the returned object. * * @param peeled Pointer to the peeled git_object * @param object The object to be processed * @param target_type The type of the requested object (a GIT_OBJ_ value) * @return 0 on success, GIT_EINVALIDSPEC, GIT_EPEEL, or an error code */ GIT_EXTERN(int) git_object_peel( git_object **peeled, const git_object *object, git_otype target_type); /** * Create an in-memory copy of a Git object. The copy must be * explicitly free'd or it will leak. * * @param dest Pointer to store the copy of the object * @param source Original object to copy */ GIT_EXTERN(int) git_object_dup(git_object **dest, git_object *source); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/errors.h0000664000175000017500000001202112572105236017057 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_errors_h__ #define INCLUDE_git_errors_h__ #include "common.h" /** * @file git2/errors.h * @brief Git error handling routines and variables * @ingroup Git * @{ */ GIT_BEGIN_DECL /** Generic return codes */ typedef enum { GIT_OK = 0, /**< No error */ GIT_ERROR = -1, /**< Generic error */ GIT_ENOTFOUND = -3, /**< Requested object could not be found */ GIT_EEXISTS = -4, /**< Object exists preventing operation */ GIT_EAMBIGUOUS = -5, /**< More than one object matches */ GIT_EBUFS = -6, /**< Output buffer too short to hold data */ /* GIT_EUSER is a special error that is never generated by libgit2 * code. You can return it from a callback (e.g to stop an iteration) * to know that it was generated by the callback and not by libgit2. */ GIT_EUSER = -7, GIT_EBAREREPO = -8, /**< Operation not allowed on bare repository */ GIT_EUNBORNBRANCH = -9, /**< HEAD refers to branch with no commits */ GIT_EUNMERGED = -10, /**< Merge in progress prevented operation */ GIT_ENONFASTFORWARD = -11, /**< Reference was not fast-forwardable */ GIT_EINVALIDSPEC = -12, /**< Name/ref spec was not in a valid format */ GIT_ECONFLICT = -13, /**< Checkout conflicts prevented operation */ GIT_ELOCKED = -14, /**< Lock file prevented operation */ GIT_EMODIFIED = -15, /**< Reference value does not match expected */ GIT_EAUTH = -16, /**< Authentication error */ GIT_ECERTIFICATE = -17, /**< Server certificate is invalid */ GIT_EAPPLIED = -18, /**< Patch/merge has already been applied */ GIT_EPEEL = -19, /**< The requested peel operation is not possible */ GIT_EEOF = -20, /**< Unexpected EOF */ GIT_EINVALID = -21, /**< Invalid operation or input */ GIT_EUNCOMMITTED = -22, /**< Uncommitted changes in index prevented operation */ GIT_EDIRECTORY = -23, /**< The operation is not valid for a directory */ GIT_PASSTHROUGH = -30, /**< Internal only */ GIT_ITEROVER = -31, /**< Signals end of iteration with iterator */ } git_error_code; /** * Structure to store extra details of the last error that occurred. * * This is kept on a per-thread basis if GIT_THREADS was defined when the * library was build, otherwise one is kept globally for the library */ typedef struct { char *message; int klass; } git_error; /** Error classes */ typedef enum { GITERR_NONE = 0, GITERR_NOMEMORY, GITERR_OS, GITERR_INVALID, GITERR_REFERENCE, GITERR_ZLIB, GITERR_REPOSITORY, GITERR_CONFIG, GITERR_REGEX, GITERR_ODB, GITERR_INDEX, GITERR_OBJECT, GITERR_NET, GITERR_TAG, GITERR_TREE, GITERR_INDEXER, GITERR_SSL, GITERR_SUBMODULE, GITERR_THREAD, GITERR_STASH, GITERR_CHECKOUT, GITERR_FETCHHEAD, GITERR_MERGE, GITERR_SSH, GITERR_FILTER, GITERR_REVERT, GITERR_CALLBACK, GITERR_CHERRYPICK, GITERR_DESCRIBE, GITERR_REBASE, GITERR_FILESYSTEM } git_error_t; /** * Return the last `git_error` object that was generated for the * current thread or NULL if no error has occurred. * * @return A git_error object. */ GIT_EXTERN(const git_error *) giterr_last(void); /** * Clear the last library error that occurred for this thread. */ GIT_EXTERN(void) giterr_clear(void); /** * Set the error message string for this thread. * * This function is public so that custom ODB backends and the like can * relay an error message through libgit2. Most regular users of libgit2 * will never need to call this function -- actually, calling it in most * circumstances (for example, calling from within a callback function) * will just end up having the value overwritten by libgit2 internals. * * This error message is stored in thread-local storage and only applies * to the particular thread that this libgit2 call is made from. * * NOTE: Passing the `error_class` as GITERR_OS has a special behavior: we * attempt to append the system default error message for the last OS error * that occurred and then clear the last error. The specific implementation * of looking up and clearing this last OS error will vary by platform. * * @param error_class One of the `git_error_t` enum above describing the * general subsystem that is responsible for the error. * @param string The formatted error message to keep */ GIT_EXTERN(void) giterr_set_str(int error_class, const char *string); /** * Set the error message to a special value for memory allocation failure. * * The normal `giterr_set_str()` function attempts to `strdup()` the string * that is passed in. This is not a good idea when the error in question * is a memory allocation failure. That circumstance has a special setter * function that sets the error string to a known and statically allocated * internal value. */ GIT_EXTERN(void) giterr_set_oom(void); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/config.h0000664000175000017500000005605712572105236017031 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_config_h__ #define INCLUDE_git_config_h__ #include "common.h" #include "types.h" #include "buffer.h" /** * @file git2/config.h * @brief Git config management routines * @defgroup git_config Git config management routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Priority level of a config file. * These priority levels correspond to the natural escalation logic * (from higher to lower) when searching for config entries in git.git. * * git_config_open_default() and git_repository_config() honor those * priority levels as well. */ typedef enum { /** System-wide configuration file; /etc/gitconfig on Linux systems */ GIT_CONFIG_LEVEL_SYSTEM = 1, /** XDG compatible configuration file; typically ~/.config/git/config */ GIT_CONFIG_LEVEL_XDG = 2, /** User-specific configuration file (also called Global configuration * file); typically ~/.gitconfig */ GIT_CONFIG_LEVEL_GLOBAL = 3, /** Repository specific configuration file; $WORK_DIR/.git/config on * non-bare repos */ GIT_CONFIG_LEVEL_LOCAL = 4, /** Application specific configuration file; freely defined by applications */ GIT_CONFIG_LEVEL_APP = 5, /** Represents the highest level available config file (i.e. the most * specific config file available that actually is loaded) */ GIT_CONFIG_HIGHEST_LEVEL = -1, } git_config_level_t; /** * An entry in a configuration file */ typedef struct git_config_entry { const char *name; /**< Name of the entry (normalised) */ const char *value; /**< String value of the entry */ git_config_level_t level; /**< Which config file this was found in */ void (*free)(struct git_config_entry *entry); /**< Free function for this entry */ void *payload; /**< Opaque value for the free function. Do not read or write */ } git_config_entry; /** * Free a config entry */ GIT_EXTERN(void) git_config_entry_free(git_config_entry *); typedef int (*git_config_foreach_cb)(const git_config_entry *, void *); typedef struct git_config_iterator git_config_iterator; /** * Config var type */ typedef enum { GIT_CVAR_FALSE = 0, GIT_CVAR_TRUE = 1, GIT_CVAR_INT32, GIT_CVAR_STRING } git_cvar_t; /** * Mapping from config variables to values. */ typedef struct { git_cvar_t cvar_type; const char *str_match; int map_value; } git_cvar_map; /** * Locate the path to the global configuration file * * The user or global configuration file is usually * located in `$HOME/.gitconfig`. * * This method will try to guess the full path to that * file, if the file exists. The returned path * may be used on any `git_config` call to load the * global configuration file. * * This method will not guess the path to the xdg compatible * config file (.config/git/config). * * @param out Pointer to a user-allocated git_buf in which to store the path * @return 0 if a global configuration file has been found. Its path will be stored in `out`. */ GIT_EXTERN(int) git_config_find_global(git_buf *out); /** * Locate the path to the global xdg compatible configuration file * * The xdg compatible configuration file is usually * located in `$HOME/.config/git/config`. * * This method will try to guess the full path to that * file, if the file exists. The returned path * may be used on any `git_config` call to load the * xdg compatible configuration file. * * @param out Pointer to a user-allocated git_buf in which to store the path * @return 0 if a xdg compatible configuration file has been * found. Its path will be stored in `out`. */ GIT_EXTERN(int) git_config_find_xdg(git_buf *out); /** * Locate the path to the system configuration file * * If /etc/gitconfig doesn't exist, it will look for * %PROGRAMFILES%\Git\etc\gitconfig. * * @param out Pointer to a user-allocated git_buf in which to store the path * @return 0 if a system configuration file has been * found. Its path will be stored in `out`. */ GIT_EXTERN(int) git_config_find_system(git_buf *out); /** * Open the global, XDG and system configuration files * * Utility wrapper that finds the global, XDG and system configuration files * and opens them into a single prioritized config object that can be * used when accessing default config data outside a repository. * * @param out Pointer to store the config instance * @return 0 or an error code */ GIT_EXTERN(int) git_config_open_default(git_config **out); /** * Allocate a new configuration object * * This object is empty, so you have to add a file to it before you * can do anything with it. * * @param out pointer to the new configuration * @return 0 or an error code */ GIT_EXTERN(int) git_config_new(git_config **out); /** * Add an on-disk config file instance to an existing config * * The on-disk file pointed at by `path` will be opened and * parsed; it's expected to be a native Git config file following * the default Git config syntax (see man git-config). * * If the file does not exist, the file will still be added and it * will be created the first time we write to it. * * Note that the configuration object will free the file * automatically. * * Further queries on this config object will access each * of the config file instances in order (instances with * a higher priority level will be accessed first). * * @param cfg the configuration to add the file to * @param path path to the configuration file to add * @param level the priority level of the backend * @param force replace config file at the given priority level * @return 0 on success, GIT_EEXISTS when adding more than one file * for a given priority level (and force_replace set to 0), * GIT_ENOTFOUND when the file doesn't exist or error code */ GIT_EXTERN(int) git_config_add_file_ondisk( git_config *cfg, const char *path, git_config_level_t level, int force); /** * Create a new config instance containing a single on-disk file * * This method is a simple utility wrapper for the following sequence * of calls: * - git_config_new * - git_config_add_file_ondisk * * @param out The configuration instance to create * @param path Path to the on-disk file to open * @return 0 on success, or an error code */ GIT_EXTERN(int) git_config_open_ondisk(git_config **out, const char *path); /** * Build a single-level focused config object from a multi-level one. * * The returned config object can be used to perform get/set/delete operations * on a single specific level. * * Getting several times the same level from the same parent multi-level config * will return different config instances, but containing the same config_file * instance. * * @param out The configuration instance to create * @param parent Multi-level config to search for the given level * @param level Configuration level to search for * @return 0, GIT_ENOTFOUND if the passed level cannot be found in the * multi-level parent config, or an error code */ GIT_EXTERN(int) git_config_open_level( git_config **out, const git_config *parent, git_config_level_t level); /** * Open the global/XDG configuration file according to git's rules * * Git allows you to store your global configuration at * `$HOME/.config` or `$XDG_CONFIG_HOME/git/config`. For backwards * compatability, the XDG file shouldn't be used unless the use has * created it explicitly. With this function you'll open the correct * one to write to. * * @param out pointer in which to store the config object * @param config the config object in which to look */ GIT_EXTERN(int) git_config_open_global(git_config **out, git_config *config); /** * Create a snapshot of the configuration * * Create a snapshot of the current state of a configuration, which * allows you to look into a consistent view of the configuration for * looking up complex values (e.g. a remote, submodule). * * The string returned when querying such a config object is valid * until it is freed. * * @param out pointer in which to store the snapshot config object * @param config configuration to snapshot * @return 0 or an error code */ GIT_EXTERN(int) git_config_snapshot(git_config **out, git_config *config); /** * Free the configuration and its associated memory and files * * @param cfg the configuration to free */ GIT_EXTERN(void) git_config_free(git_config *cfg); /** * Get the git_config_entry of a config variable. * * Free the git_config_entry after use with `git_config_entry_free()`. * * @param out pointer to the variable git_config_entry * @param cfg where to look for the variable * @param name the variable's name * @return 0 or an error code */ GIT_EXTERN(int) git_config_get_entry( git_config_entry **out, const git_config *cfg, const char *name); /** * Get the value of an integer config variable. * * All config files will be looked into, in the order of their * defined level. A higher level means a higher priority. The * first occurrence of the variable will be returned here. * * @param out pointer to the variable where the value should be stored * @param cfg where to look for the variable * @param name the variable's name * @return 0 or an error code */ GIT_EXTERN(int) git_config_get_int32(int32_t *out, const git_config *cfg, const char *name); /** * Get the value of a long integer config variable. * * All config files will be looked into, in the order of their * defined level. A higher level means a higher priority. The * first occurrence of the variable will be returned here. * * @param out pointer to the variable where the value should be stored * @param cfg where to look for the variable * @param name the variable's name * @return 0 or an error code */ GIT_EXTERN(int) git_config_get_int64(int64_t *out, const git_config *cfg, const char *name); /** * Get the value of a boolean config variable. * * This function uses the usual C convention of 0 being false and * anything else true. * * All config files will be looked into, in the order of their * defined level. A higher level means a higher priority. The * first occurrence of the variable will be returned here. * * @param out pointer to the variable where the value should be stored * @param cfg where to look for the variable * @param name the variable's name * @return 0 or an error code */ GIT_EXTERN(int) git_config_get_bool(int *out, const git_config *cfg, const char *name); /** * Get the value of a path config variable. * * A leading '~' will be expanded to the global search path (which * defaults to the user's home directory but can be overridden via * `git_libgit2_opts()`. * * All config files will be looked into, in the order of their * defined level. A higher level means a higher priority. The * first occurrence of the variable will be returned here. * * @param out the buffer in which to store the result * @param cfg where to look for the variable * @param name the variable's name * @return 0 or an error code */ GIT_EXTERN(int) git_config_get_path(git_buf *out, const git_config *cfg, const char *name); /** * Get the value of a string config variable. * * This function can only be used on snapshot config objects. The * string is owned by the config and should not be freed by the * user. The pointer will be valid until the config is freed. * * All config files will be looked into, in the order of their * defined level. A higher level means a higher priority. The * first occurrence of the variable will be returned here. * * @param out pointer to the string * @param cfg where to look for the variable * @param name the variable's name * @return 0 or an error code */ GIT_EXTERN(int) git_config_get_string(const char **out, const git_config *cfg, const char *name); /** * Get the value of a string config variable. * * The value of the config will be copied into the buffer. * * All config files will be looked into, in the order of their * defined level. A higher level means a higher priority. The * first occurrence of the variable will be returned here. * * @param out buffer in which to store the string * @param cfg where to look for the variable * @param name the variable's name * @return 0 or an error code */ GIT_EXTERN(int) git_config_get_string_buf(git_buf *out, const git_config *cfg, const char *name); /** * Get each value of a multivar in a foreach callback * * The callback will be called on each variable found * * @param cfg where to look for the variable * @param name the variable's name * @param regexp regular expression to filter which variables we're * interested in. Use NULL to indicate all * @param callback the function to be called on each value of the variable * @param payload opaque pointer to pass to the callback */ GIT_EXTERN(int) git_config_get_multivar_foreach(const git_config *cfg, const char *name, const char *regexp, git_config_foreach_cb callback, void *payload); /** * Get each value of a multivar * * @param out pointer to store the iterator * @param cfg where to look for the variable * @param name the variable's name * @param regexp regular expression to filter which variables we're * interested in. Use NULL to indicate all */ GIT_EXTERN(int) git_config_multivar_iterator_new(git_config_iterator **out, const git_config *cfg, const char *name, const char *regexp); /** * Return the current entry and advance the iterator * * The pointers returned by this function are valid until the iterator * is freed. * * @param entry pointer to store the entry * @param iter the iterator * @return 0 or an error code. GIT_ITEROVER if the iteration has completed */ GIT_EXTERN(int) git_config_next(git_config_entry **entry, git_config_iterator *iter); /** * Free a config iterator * * @param iter the iterator to free */ GIT_EXTERN(void) git_config_iterator_free(git_config_iterator *iter); /** * Set the value of an integer config variable in the config file * with the highest level (usually the local one). * * @param cfg where to look for the variable * @param name the variable's name * @param value Integer value for the variable * @return 0 or an error code */ GIT_EXTERN(int) git_config_set_int32(git_config *cfg, const char *name, int32_t value); /** * Set the value of a long integer config variable in the config file * with the highest level (usually the local one). * * @param cfg where to look for the variable * @param name the variable's name * @param value Long integer value for the variable * @return 0 or an error code */ GIT_EXTERN(int) git_config_set_int64(git_config *cfg, const char *name, int64_t value); /** * Set the value of a boolean config variable in the config file * with the highest level (usually the local one). * * @param cfg where to look for the variable * @param name the variable's name * @param value the value to store * @return 0 or an error code */ GIT_EXTERN(int) git_config_set_bool(git_config *cfg, const char *name, int value); /** * Set the value of a string config variable in the config file * with the highest level (usually the local one). * * A copy of the string is made and the user is free to use it * afterwards. * * @param cfg where to look for the variable * @param name the variable's name * @param value the string to store. * @return 0 or an error code */ GIT_EXTERN(int) git_config_set_string(git_config *cfg, const char *name, const char *value); /** * Set a multivar in the local config file. * * @param cfg where to look for the variable * @param name the variable's name * @param regexp a regular expression to indicate which values to replace * @param value the new value. */ GIT_EXTERN(int) git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value); /** * Delete a config variable from the config file * with the highest level (usually the local one). * * @param cfg the configuration * @param name the variable to delete */ GIT_EXTERN(int) git_config_delete_entry(git_config *cfg, const char *name); /** * Deletes one or several entries from a multivar in the local config file. * * @param cfg where to look for the variables * @param name the variable's name * @param regexp a regular expression to indicate which values to delete * * @return 0 or an error code */ GIT_EXTERN(int) git_config_delete_multivar(git_config *cfg, const char *name, const char *regexp); /** * Perform an operation on each config variable. * * The callback receives the normalized name and value of each variable * in the config backend, and the data pointer passed to this function. * If the callback returns a non-zero value, the function stops iterating * and returns that value to the caller. * * The pointers passed to the callback are only valid as long as the * iteration is ongoing. * * @param cfg where to get the variables from * @param callback the function to call on each variable * @param payload the data to pass to the callback * @return 0 on success, non-zero callback return value, or error code */ GIT_EXTERN(int) git_config_foreach( const git_config *cfg, git_config_foreach_cb callback, void *payload); /** * Iterate over all the config variables * * Use `git_config_next` to advance the iteration and * `git_config_iterator_free` when done. * * @param out pointer to store the iterator * @param cfg where to ge the variables from */ GIT_EXTERN(int) git_config_iterator_new(git_config_iterator **out, const git_config *cfg); /** * Iterate over all the config variables whose name matches a pattern * * Use `git_config_next` to advance the iteration and * `git_config_iterator_free` when done. * * @param out pointer to store the iterator * @param cfg where to ge the variables from * @param regexp regular expression to match the names */ GIT_EXTERN(int) git_config_iterator_glob_new(git_config_iterator **out, const git_config *cfg, const char *regexp); /** * Perform an operation on each config variable matching a regular expression. * * This behaviors like `git_config_foreach` with an additional filter of a * regular expression that filters which config keys are passed to the * callback. * * The pointers passed to the callback are only valid as long as the * iteration is ongoing. * * @param cfg where to get the variables from * @param regexp regular expression to match against config names * @param callback the function to call on each variable * @param payload the data to pass to the callback * @return 0 or the return value of the callback which didn't return 0 */ GIT_EXTERN(int) git_config_foreach_match( const git_config *cfg, const char *regexp, git_config_foreach_cb callback, void *payload); /** * Query the value of a config variable and return it mapped to * an integer constant. * * This is a helper method to easily map different possible values * to a variable to integer constants that easily identify them. * * A mapping array looks as follows: * * git_cvar_map autocrlf_mapping[] = { * {GIT_CVAR_FALSE, NULL, GIT_AUTO_CRLF_FALSE}, * {GIT_CVAR_TRUE, NULL, GIT_AUTO_CRLF_TRUE}, * {GIT_CVAR_STRING, "input", GIT_AUTO_CRLF_INPUT}, * {GIT_CVAR_STRING, "default", GIT_AUTO_CRLF_DEFAULT}}; * * On any "false" value for the variable (e.g. "false", "FALSE", "no"), the * mapping will store `GIT_AUTO_CRLF_FALSE` in the `out` parameter. * * The same thing applies for any "true" value such as "true", "yes" or "1", storing * the `GIT_AUTO_CRLF_TRUE` variable. * * Otherwise, if the value matches the string "input" (with case insensitive comparison), * the given constant will be stored in `out`, and likewise for "default". * * If not a single match can be made to store in `out`, an error code will be * returned. * * @param out place to store the result of the mapping * @param cfg config file to get the variables from * @param name name of the config variable to lookup * @param maps array of `git_cvar_map` objects specifying the possible mappings * @param map_n number of mapping objects in `maps` * @return 0 on success, error code otherwise */ GIT_EXTERN(int) git_config_get_mapped( int *out, const git_config *cfg, const char *name, const git_cvar_map *maps, size_t map_n); /** * Maps a string value to an integer constant * * @param out place to store the result of the parsing * @param maps array of `git_cvar_map` objects specifying the possible mappings * @param map_n number of mapping objects in `maps` * @param value value to parse */ GIT_EXTERN(int) git_config_lookup_map_value( int *out, const git_cvar_map *maps, size_t map_n, const char *value); /** * Parse a string value as a bool. * * Valid values for true are: 'true', 'yes', 'on', 1 or any * number different from 0 * Valid values for false are: 'false', 'no', 'off', 0 * * @param out place to store the result of the parsing * @param value value to parse */ GIT_EXTERN(int) git_config_parse_bool(int *out, const char *value); /** * Parse a string value as an int32. * * An optional value suffix of 'k', 'm', or 'g' will * cause the value to be multiplied by 1024, 1048576, * or 1073741824 prior to output. * * @param out place to store the result of the parsing * @param value value to parse */ GIT_EXTERN(int) git_config_parse_int32(int32_t *out, const char *value); /** * Parse a string value as an int64. * * An optional value suffix of 'k', 'm', or 'g' will * cause the value to be multiplied by 1024, 1048576, * or 1073741824 prior to output. * * @param out place to store the result of the parsing * @param value value to parse */ GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value); /** * Parse a string value as a path. * * A leading '~' will be expanded to the global search path (which * defaults to the user's home directory but can be overridden via * `git_libgit2_opts()`. * * If the value does not begin with a tilde, the input will be * returned. * * @param out placae to store the result of parsing * @param value the path to evaluate */ GIT_EXTERN(int) git_config_parse_path(git_buf *out, const char *value); /** * Perform an operation on each config variable in given config backend * matching a regular expression. * * This behaviors like `git_config_foreach_match` except instead of all config * entries it just enumerates through the given backend entry. * * @param backend where to get the variables from * @param regexp regular expression to match against config names (can be NULL) * @param callback the function to call on each variable * @param payload the data to pass to the callback */ GIT_EXTERN(int) git_config_backend_foreach_match( git_config_backend *backend, const char *regexp, git_config_foreach_cb callback, void *payload); /** * Lock the backend with the highest priority * * Locking disallows anybody else from writing to that backend. Any * updates made after locking will not be visible to a reader until * the file is unlocked. * * You can apply the changes by calling `git_transaction_commit()` * before freeing the transaction. Either of these actions will unlock * the config. * * @param tx the resulting transaction, use this to commit or undo the * changes * @param cfg the configuration in which to lock * @return 0 or an error code */ GIT_EXTERN(int) git_config_lock(git_transaction **tx, git_config *cfg); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/branch.h0000664000175000017500000002002012510265101016764 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_branch_h__ #define INCLUDE_git_branch_h__ #include "common.h" #include "oid.h" #include "types.h" /** * @file git2/branch.h * @brief Git branch parsing routines * @defgroup git_branch Git branch management * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Create a new branch pointing at a target commit * * A new direct reference will be created pointing to * this target commit. If `force` is true and a reference * already exists with the given name, it'll be replaced. * * The returned reference must be freed by the user. * * The branch name will be checked for validity. * See `git_tag_create()` for rules about valid names. * * @param out Pointer where to store the underlying reference. * * @param branch_name Name for the branch; this name is * validated for consistency. It should also not conflict with * an already existing branch name. * * @param target Commit to which this branch should point. This object * must belong to the given `repo`. * * @param force Overwrite existing branch. * * @return 0, GIT_EINVALIDSPEC or an error code. * A proper reference is written in the refs/heads namespace * pointing to the provided target commit. */ GIT_EXTERN(int) git_branch_create( git_reference **out, git_repository *repo, const char *branch_name, const git_commit *target, int force); /** * Create a new branch pointing at a target commit * * This behaves like `git_branch_create()` but takes an annotated * commit, which lets you specify which extended sha syntax string was * specified by a user, allowing for more exact reflog messages. * * See the documentation for `git_branch_create()`. * * @see git_branch_create */ GIT_EXTERN(int) git_branch_create_from_annotated( git_reference **ref_out, git_repository *repository, const char *branch_name, const git_annotated_commit *commit, int force); /** * Delete an existing branch reference. * * If the branch is successfully deleted, the passed reference * object will be invalidated. The reference must be freed manually * by the user. * * @param branch A valid reference representing a branch * @return 0 on success, or an error code. */ GIT_EXTERN(int) git_branch_delete(git_reference *branch); /** Iterator type for branches */ typedef struct git_branch_iterator git_branch_iterator; /** * Create an iterator which loops over the requested branches. * * @param out the iterator * @param repo Repository where to find the branches. * @param list_flags Filtering flags for the branch * listing. Valid values are GIT_BRANCH_LOCAL, GIT_BRANCH_REMOTE * or GIT_BRANCH_ALL. * * @return 0 on success or an error code */ GIT_EXTERN(int) git_branch_iterator_new( git_branch_iterator **out, git_repository *repo, git_branch_t list_flags); /** * Retrieve the next branch from the iterator * * @param out the reference * @param out_type the type of branch (local or remote-tracking) * @param iter the branch iterator * @return 0 on success, GIT_ITEROVER if there are no more branches or an error code. */ GIT_EXTERN(int) git_branch_next(git_reference **out, git_branch_t *out_type, git_branch_iterator *iter); /** * Free a branch iterator * * @param iter the iterator to free */ GIT_EXTERN(void) git_branch_iterator_free(git_branch_iterator *iter); /** * Move/rename an existing local branch reference. * * The new branch name will be checked for validity. * See `git_tag_create()` for rules about valid names. * * @param branch Current underlying reference of the branch. * * @param new_branch_name Target name of the branch once the move * is performed; this name is validated for consistency. * * @param force Overwrite existing branch. * * @return 0 on success, GIT_EINVALIDSPEC or an error code. */ GIT_EXTERN(int) git_branch_move( git_reference **out, git_reference *branch, const char *new_branch_name, int force); /** * Lookup a branch by its name in a repository. * * The generated reference must be freed by the user. * * The branch name will be checked for validity. * See `git_tag_create()` for rules about valid names. * * @param out pointer to the looked-up branch reference * * @param repo the repository to look up the branch * * @param branch_name Name of the branch to be looked-up; * this name is validated for consistency. * * @param branch_type Type of the considered branch. This should * be valued with either GIT_BRANCH_LOCAL or GIT_BRANCH_REMOTE. * * @return 0 on success; GIT_ENOTFOUND when no matching branch * exists, GIT_EINVALIDSPEC, otherwise an error code. */ GIT_EXTERN(int) git_branch_lookup( git_reference **out, git_repository *repo, const char *branch_name, git_branch_t branch_type); /** * Return the name of the given local or remote branch. * * The name of the branch matches the definition of the name * for git_branch_lookup. That is, if the returned name is given * to git_branch_lookup() then the reference is returned that * was given to this function. * * @param out where the pointer of branch name is stored; * this is valid as long as the ref is not freed. * @param ref the reference ideally pointing to a branch * * @return 0 on success; otherwise an error code (e.g., if the * ref is no local or remote branch). */ GIT_EXTERN(int) git_branch_name( const char **out, const git_reference *ref); /** * Return the reference supporting the remote tracking branch, * given a local branch reference. * * @param out Pointer where to store the retrieved * reference. * * @param branch Current underlying reference of the branch. * * @return 0 on success; GIT_ENOTFOUND when no remote tracking * reference exists, otherwise an error code. */ GIT_EXTERN(int) git_branch_upstream( git_reference **out, const git_reference *branch); /** * Set the upstream configuration for a given local branch * * @param branch the branch to configure * * @param upstream_name remote-tracking or local branch to set as * upstream. Pass NULL to unset. * * @return 0 or an error code */ GIT_EXTERN(int) git_branch_set_upstream(git_reference *branch, const char *upstream_name); /** * Return the name of the reference supporting the remote tracking branch, * given the name of a local branch reference. * * @param out Pointer to the user-allocated git_buf which will be * filled with the name of the reference. * * @param repo the repository where the branches live * * @param refname reference name of the local branch. * * @return 0, GIT_ENOTFOUND when no remote tracking reference exists, * otherwise an error code. */ GIT_EXTERN(int) git_branch_upstream_name( git_buf *out, git_repository *repo, const char *refname); /** * Determine if the current local branch is pointed at by HEAD. * * @param branch Current underlying reference of the branch. * * @return 1 if HEAD points at the branch, 0 if it isn't, * error code otherwise. */ GIT_EXTERN(int) git_branch_is_head( const git_reference *branch); /** * Return the name of remote that the remote tracking branch belongs to. * * @param out Pointer to the user-allocated git_buf which will be filled with the name of the remote. * * @param repo The repository where the branch lives. * * @param canonical_branch_name name of the remote tracking branch. * * @return 0, GIT_ENOTFOUND * when no remote matching remote was found, * GIT_EAMBIGUOUS when the branch maps to several remotes, * otherwise an error code. */ GIT_EXTERN(int) git_branch_remote_name( git_buf *out, git_repository *repo, const char *canonical_branch_name); /** * Retrieve the name fo the upstream remote of a local branch * * @param buf the buffer into which to write the name * @param repo the repository in which to look * @param refname the full name of the branch * @return 0 or an error code */ GIT_EXTERN(int) git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *refname); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/oidarray.h0000664000175000017500000000174012510265101017351 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_oidarray_h__ #define INCLUDE_git_oidarray_h__ #include "common.h" #include "oid.h" GIT_BEGIN_DECL /** Array of object ids */ typedef struct git_oidarray { git_oid *ids; size_t count; } git_oidarray; /** * Free the OID array * * This method must (and must only) be called on `git_oidarray` * objects where the array is allocated by the library. Not doing so, * will result in a memory leak. * * This does not free the `git_oidarray` itself, since the library will * never allocate that object directly itself (it is more commonly embedded * inside another struct or created on the stack). * * @param array git_oidarray from which to free oid data */ GIT_EXTERN(void) git_oidarray_free(git_oidarray *array); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/tree.h0000664000175000017500000003022512510265101016476 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_tree_h__ #define INCLUDE_git_tree_h__ #include "common.h" #include "types.h" #include "oid.h" #include "object.h" /** * @file git2/tree.h * @brief Git tree parsing, loading routines * @defgroup git_tree Git tree parsing, loading routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Lookup a tree object from the repository. * * @param out Pointer to the looked up tree * @param repo The repo to use when locating the tree. * @param id Identity of the tree to locate. * @return 0 or an error code */ GIT_EXTERN(int) git_tree_lookup( git_tree **out, git_repository *repo, const git_oid *id); /** * Lookup a tree object from the repository, * given a prefix of its identifier (short id). * * @see git_object_lookup_prefix * * @param out pointer to the looked up tree * @param repo the repo to use when locating the tree. * @param id identity of the tree to locate. * @param len the length of the short identifier * @return 0 or an error code */ GIT_EXTERN(int) git_tree_lookup_prefix( git_tree **out, git_repository *repo, const git_oid *id, size_t len); /** * Close an open tree * * You can no longer use the git_tree pointer after this call. * * IMPORTANT: You MUST call this method when you stop using a tree to * release memory. Failure to do so will cause a memory leak. * * @param tree The tree to close */ GIT_EXTERN(void) git_tree_free(git_tree *tree); /** * Get the id of a tree. * * @param tree a previously loaded tree. * @return object identity for the tree. */ GIT_EXTERN(const git_oid *) git_tree_id(const git_tree *tree); /** * Get the repository that contains the tree. * * @param tree A previously loaded tree. * @return Repository that contains this tree. */ GIT_EXTERN(git_repository *) git_tree_owner(const git_tree *tree); /** * Get the number of entries listed in a tree * * @param tree a previously loaded tree. * @return the number of entries in the tree */ GIT_EXTERN(size_t) git_tree_entrycount(const git_tree *tree); /** * Lookup a tree entry by its filename * * This returns a git_tree_entry that is owned by the git_tree. You don't * have to free it, but you must not use it after the git_tree is released. * * @param tree a previously loaded tree. * @param filename the filename of the desired entry * @return the tree entry; NULL if not found */ GIT_EXTERN(const git_tree_entry *) git_tree_entry_byname( const git_tree *tree, const char *filename); /** * Lookup a tree entry by its position in the tree * * This returns a git_tree_entry that is owned by the git_tree. You don't * have to free it, but you must not use it after the git_tree is released. * * @param tree a previously loaded tree. * @param idx the position in the entry list * @return the tree entry; NULL if not found */ GIT_EXTERN(const git_tree_entry *) git_tree_entry_byindex( const git_tree *tree, size_t idx); /** * Lookup a tree entry by SHA value. * * This returns a git_tree_entry that is owned by the git_tree. You don't * have to free it, but you must not use it after the git_tree is released. * * Warning: this must examine every entry in the tree, so it is not fast. * * @param tree a previously loaded tree. * @param id the sha being looked for * @return the tree entry; NULL if not found */ GIT_EXTERN(const git_tree_entry *) git_tree_entry_byid( const git_tree *tree, const git_oid *id); /** * Retrieve a tree entry contained in a tree or in any of its subtrees, * given its relative path. * * Unlike the other lookup functions, the returned tree entry is owned by * the user and must be freed explicitly with `git_tree_entry_free()`. * * @param out Pointer where to store the tree entry * @param root Previously loaded tree which is the root of the relative path * @param path Path to the contained entry * @return 0 on success; GIT_ENOTFOUND if the path does not exist */ GIT_EXTERN(int) git_tree_entry_bypath( git_tree_entry **out, const git_tree *root, const char *path); /** * Duplicate a tree entry * * Create a copy of a tree entry. The returned copy is owned by the user, * and must be freed explicitly with `git_tree_entry_free()`. * * @param dest pointer where to store the copy * @param source tree entry to duplicate * @return 0 or an error code */ GIT_EXTERN(int) git_tree_entry_dup(git_tree_entry **dest, const git_tree_entry *source); /** * Free a user-owned tree entry * * IMPORTANT: This function is only needed for tree entries owned by the * user, such as the ones returned by `git_tree_entry_dup()` or * `git_tree_entry_bypath()`. * * @param entry The entry to free */ GIT_EXTERN(void) git_tree_entry_free(git_tree_entry *entry); /** * Get the filename of a tree entry * * @param entry a tree entry * @return the name of the file */ GIT_EXTERN(const char *) git_tree_entry_name(const git_tree_entry *entry); /** * Get the id of the object pointed by the entry * * @param entry a tree entry * @return the oid of the object */ GIT_EXTERN(const git_oid *) git_tree_entry_id(const git_tree_entry *entry); /** * Get the type of the object pointed by the entry * * @param entry a tree entry * @return the type of the pointed object */ GIT_EXTERN(git_otype) git_tree_entry_type(const git_tree_entry *entry); /** * Get the UNIX file attributes of a tree entry * * @param entry a tree entry * @return filemode as an integer */ GIT_EXTERN(git_filemode_t) git_tree_entry_filemode(const git_tree_entry *entry); /** * Get the raw UNIX file attributes of a tree entry * * This function does not perform any normalization and is only useful * if you need to be able to recreate the original tree object. * * @param entry a tree entry * @return filemode as an integer */ GIT_EXTERN(git_filemode_t) git_tree_entry_filemode_raw(const git_tree_entry *entry); /** * Compare two tree entries * * @param e1 first tree entry * @param e2 second tree entry * @return <0 if e1 is before e2, 0 if e1 == e2, >0 if e1 is after e2 */ GIT_EXTERN(int) git_tree_entry_cmp(const git_tree_entry *e1, const git_tree_entry *e2); /** * Convert a tree entry to the git_object it points to. * * You must call `git_object_free()` on the object when you are done with it. * * @param object_out pointer to the converted object * @param repo repository where to lookup the pointed object * @param entry a tree entry * @return 0 or an error code */ GIT_EXTERN(int) git_tree_entry_to_object( git_object **object_out, git_repository *repo, const git_tree_entry *entry); /** * Create a new tree builder. * * The tree builder can be used to create or modify trees in memory and * write them as tree objects to the database. * * If the `source` parameter is not NULL, the tree builder will be * initialized with the entries of the given tree. * * If the `source` parameter is NULL, the tree builder will start with no * entries and will have to be filled manually. * * @param out Pointer where to store the tree builder * @param repo Repository in which to store the object * @param source Source tree to initialize the builder (optional) * @return 0 on success; error code otherwise */ GIT_EXTERN(int) git_treebuilder_new( git_treebuilder **out, git_repository *repo, const git_tree *source); /** * Clear all the entires in the builder * * @param bld Builder to clear */ GIT_EXTERN(void) git_treebuilder_clear(git_treebuilder *bld); /** * Get the number of entries listed in a treebuilder * * @param bld a previously loaded treebuilder. * @return the number of entries in the treebuilder */ GIT_EXTERN(unsigned int) git_treebuilder_entrycount(git_treebuilder *bld); /** * Free a tree builder * * This will clear all the entries and free to builder. * Failing to free the builder after you're done using it * will result in a memory leak * * @param bld Builder to free */ GIT_EXTERN(void) git_treebuilder_free(git_treebuilder *bld); /** * Get an entry from the builder from its filename * * The returned entry is owned by the builder and should * not be freed manually. * * @param bld Tree builder * @param filename Name of the entry * @return pointer to the entry; NULL if not found */ GIT_EXTERN(const git_tree_entry *) git_treebuilder_get( git_treebuilder *bld, const char *filename); /** * Add or update an entry to the builder * * Insert a new entry for `filename` in the builder with the * given attributes. * * If an entry named `filename` already exists, its attributes * will be updated with the given ones. * * The optional pointer `out` can be used to retrieve a pointer to the * newly created/updated entry. Pass NULL if you do not need it. The * pointer may not be valid past the next operation in this * builder. Duplicate the entry if you want to keep it. * * No attempt is being made to ensure that the provided oid points * to an existing git object in the object database, nor that the * attributes make sense regarding the type of the pointed at object. * * @param out Pointer to store the entry (optional) * @param bld Tree builder * @param filename Filename of the entry * @param id SHA1 oid of the entry * @param filemode Folder attributes of the entry. This parameter must * be valued with one of the following entries: 0040000, 0100644, * 0100755, 0120000 or 0160000. * @return 0 or an error code */ GIT_EXTERN(int) git_treebuilder_insert( const git_tree_entry **out, git_treebuilder *bld, const char *filename, const git_oid *id, git_filemode_t filemode); /** * Remove an entry from the builder by its filename * * @param bld Tree builder * @param filename Filename of the entry to remove */ GIT_EXTERN(int) git_treebuilder_remove( git_treebuilder *bld, const char *filename); /** * Callback for git_treebuilder_filter * * The return value is treated as a boolean, with zero indicating that the * entry should be left alone and any non-zero value meaning that the * entry should be removed from the treebuilder list (i.e. filtered out). */ typedef int (*git_treebuilder_filter_cb)( const git_tree_entry *entry, void *payload); /** * Selectively remove entries in the tree * * The `filter` callback will be called for each entry in the tree with a * pointer to the entry and the provided `payload`; if the callback returns * non-zero, the entry will be filtered (removed from the builder). * * @param bld Tree builder * @param filter Callback to filter entries * @param payload Extra data to pass to filter callback */ GIT_EXTERN(void) git_treebuilder_filter( git_treebuilder *bld, git_treebuilder_filter_cb filter, void *payload); /** * Write the contents of the tree builder as a tree object * * The tree builder will be written to the given `repo`, and its * identifying SHA1 hash will be stored in the `id` pointer. * * @param id Pointer to store the OID of the newly written tree * @param bld Tree builder to write * @return 0 or an error code */ GIT_EXTERN(int) git_treebuilder_write( git_oid *id, git_treebuilder *bld); /** Callback for the tree traversal method */ typedef int (*git_treewalk_cb)( const char *root, const git_tree_entry *entry, void *payload); /** Tree traversal modes */ typedef enum { GIT_TREEWALK_PRE = 0, /* Pre-order */ GIT_TREEWALK_POST = 1, /* Post-order */ } git_treewalk_mode; /** * Traverse the entries in a tree and its subtrees in post or pre order. * * The entries will be traversed in the specified order, children subtrees * will be automatically loaded as required, and the `callback` will be * called once per entry with the current (relative) root for the entry and * the entry data itself. * * If the callback returns a positive value, the passed entry will be * skipped on the traversal (in pre mode). A negative value stops the walk. * * @param tree The tree to walk * @param mode Traversal mode (pre or post-order) * @param callback Function to call on each tree entry * @param payload Opaque pointer to be passed on each callback * @return 0 or an error code */ GIT_EXTERN(int) git_tree_walk( const git_tree *tree, git_treewalk_mode mode, git_treewalk_cb callback, void *payload); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/status.h0000664000175000017500000003430212555730137017101 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_status_h__ #define INCLUDE_git_status_h__ #include "common.h" #include "types.h" /** * @file git2/status.h * @brief Git file status routines * @defgroup git_status Git file status routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Status flags for a single file. * * A combination of these values will be returned to indicate the status of * a file. Status compares the working directory, the index, and the * current HEAD of the repository. The `GIT_STATUS_INDEX` set of flags * represents the status of file in the index relative to the HEAD, and the * `GIT_STATUS_WT` set of flags represent the status of the file in the * working directory relative to the index. */ typedef enum { GIT_STATUS_CURRENT = 0, GIT_STATUS_INDEX_NEW = (1u << 0), GIT_STATUS_INDEX_MODIFIED = (1u << 1), GIT_STATUS_INDEX_DELETED = (1u << 2), GIT_STATUS_INDEX_RENAMED = (1u << 3), GIT_STATUS_INDEX_TYPECHANGE = (1u << 4), GIT_STATUS_WT_NEW = (1u << 7), GIT_STATUS_WT_MODIFIED = (1u << 8), GIT_STATUS_WT_DELETED = (1u << 9), GIT_STATUS_WT_TYPECHANGE = (1u << 10), GIT_STATUS_WT_RENAMED = (1u << 11), GIT_STATUS_WT_UNREADABLE = (1u << 12), GIT_STATUS_IGNORED = (1u << 14), GIT_STATUS_CONFLICTED = (1u << 15), } git_status_t; /** * Function pointer to receive status on individual files * * `path` is the relative path to the file from the root of the repository. * * `status_flags` is a combination of `git_status_t` values that apply. * * `payload` is the value you passed to the foreach function as payload. */ typedef int (*git_status_cb)( const char *path, unsigned int status_flags, void *payload); /** * Select the files on which to report status. * * With `git_status_foreach_ext`, this will control which changes get * callbacks. With `git_status_list_new`, these will control which * changes are included in the list. * * - GIT_STATUS_SHOW_INDEX_AND_WORKDIR is the default. This roughly * matches `git status --porcelain` regarding which files are * included and in what order. * - GIT_STATUS_SHOW_INDEX_ONLY only gives status based on HEAD to index * comparison, not looking at working directory changes. * - GIT_STATUS_SHOW_WORKDIR_ONLY only gives status based on index to * working directory comparison, not comparing the index to the HEAD. */ typedef enum { GIT_STATUS_SHOW_INDEX_AND_WORKDIR = 0, GIT_STATUS_SHOW_INDEX_ONLY = 1, GIT_STATUS_SHOW_WORKDIR_ONLY = 2, } git_status_show_t; /** * Flags to control status callbacks * * - GIT_STATUS_OPT_INCLUDE_UNTRACKED says that callbacks should be made * on untracked files. These will only be made if the workdir files are * included in the status "show" option. * - GIT_STATUS_OPT_INCLUDE_IGNORED says that ignored files get callbacks. * Again, these callbacks will only be made if the workdir files are * included in the status "show" option. * - GIT_STATUS_OPT_INCLUDE_UNMODIFIED indicates that callback should be * made even on unmodified files. * - GIT_STATUS_OPT_EXCLUDE_SUBMODULES indicates that submodules should be * skipped. This only applies if there are no pending typechanges to * the submodule (either from or to another type). * - GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS indicates that all files in * untracked directories should be included. Normally if an entire * directory is new, then just the top-level directory is included (with * a trailing slash on the entry name). This flag says to include all * of the individual files in the directory instead. * - GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH indicates that the given path * should be treated as a literal path, and not as a pathspec pattern. * - GIT_STATUS_OPT_RECURSE_IGNORED_DIRS indicates that the contents of * ignored directories should be included in the status. This is like * doing `git ls-files -o -i --exclude-standard` with core git. * - GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX indicates that rename detection * should be processed between the head and the index and enables * the GIT_STATUS_INDEX_RENAMED as a possible status flag. * - GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR indicates that rename * detection should be run between the index and the working directory * and enabled GIT_STATUS_WT_RENAMED as a possible status flag. * - GIT_STATUS_OPT_SORT_CASE_SENSITIVELY overrides the native case * sensitivity for the file system and forces the output to be in * case-sensitive order * - GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY overrides the native case * sensitivity for the file system and forces the output to be in * case-insensitive order * - GIT_STATUS_OPT_RENAMES_FROM_REWRITES indicates that rename detection * should include rewritten files * - GIT_STATUS_OPT_NO_REFRESH bypasses the default status behavior of * doing a "soft" index reload (i.e. reloading the index data if the * file on disk has been modified outside libgit2). * - GIT_STATUS_OPT_UPDATE_INDEX tells libgit2 to refresh the stat cache * in the index for files that are unchanged but have out of date stat * information in the index. It will result in less work being done on * subsequent calls to get status. This is mutually exclusive with the * NO_REFRESH option. * * Calling `git_status_foreach()` is like calling the extended version * with: GIT_STATUS_OPT_INCLUDE_IGNORED, GIT_STATUS_OPT_INCLUDE_UNTRACKED, * and GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS. Those options are bundled * together as `GIT_STATUS_OPT_DEFAULTS` if you want them as a baseline. */ typedef enum { GIT_STATUS_OPT_INCLUDE_UNTRACKED = (1u << 0), GIT_STATUS_OPT_INCLUDE_IGNORED = (1u << 1), GIT_STATUS_OPT_INCLUDE_UNMODIFIED = (1u << 2), GIT_STATUS_OPT_EXCLUDE_SUBMODULES = (1u << 3), GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS = (1u << 4), GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH = (1u << 5), GIT_STATUS_OPT_RECURSE_IGNORED_DIRS = (1u << 6), GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX = (1u << 7), GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR = (1u << 8), GIT_STATUS_OPT_SORT_CASE_SENSITIVELY = (1u << 9), GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY = (1u << 10), GIT_STATUS_OPT_RENAMES_FROM_REWRITES = (1u << 11), GIT_STATUS_OPT_NO_REFRESH = (1u << 12), GIT_STATUS_OPT_UPDATE_INDEX = (1u << 13), GIT_STATUS_OPT_INCLUDE_UNREADABLE = (1u << 14), GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED = (1u << 15), } git_status_opt_t; #define GIT_STATUS_OPT_DEFAULTS \ (GIT_STATUS_OPT_INCLUDE_IGNORED | \ GIT_STATUS_OPT_INCLUDE_UNTRACKED | \ GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS) /** * Options to control how `git_status_foreach_ext()` will issue callbacks. * * This structure is set so that zeroing it out will give you relatively * sane defaults. * * The `show` value is one of the `git_status_show_t` constants that * control which files to scan and in what order. * * The `flags` value is an OR'ed combination of the `git_status_opt_t` * values above. * * The `pathspec` is an array of path patterns to match (using * fnmatch-style matching), or just an array of paths to match exactly if * `GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH` is specified in the flags. */ typedef struct { unsigned int version; git_status_show_t show; unsigned int flags; git_strarray pathspec; } git_status_options; #define GIT_STATUS_OPTIONS_VERSION 1 #define GIT_STATUS_OPTIONS_INIT {GIT_STATUS_OPTIONS_VERSION} /** * Initializes a `git_status_options` with default values. Equivalent to * creating an instance with GIT_STATUS_OPTIONS_INIT. * * @param opts The `git_status_options` instance to initialize. * @param version Version of struct; pass `GIT_STATUS_OPTIONS_VERSION` * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_status_init_options( git_status_options *opts, unsigned int version); /** * A status entry, providing the differences between the file as it exists * in HEAD and the index, and providing the differences between the index * and the working directory. * * The `status` value provides the status flags for this file. * * The `head_to_index` value provides detailed information about the * differences between the file in HEAD and the file in the index. * * The `index_to_workdir` value provides detailed information about the * differences between the file in the index and the file in the * working directory. */ typedef struct { git_status_t status; git_diff_delta *head_to_index; git_diff_delta *index_to_workdir; } git_status_entry; /** * Gather file statuses and run a callback for each one. * * The callback is passed the path of the file, the status (a combination of * the `git_status_t` values above) and the `payload` data pointer passed * into this function. * * If the callback returns a non-zero value, this function will stop looping * and return that value to caller. * * @param repo A repository object * @param callback The function to call on each file * @param payload Pointer to pass through to callback function * @return 0 on success, non-zero callback return value, or error code */ GIT_EXTERN(int) git_status_foreach( git_repository *repo, git_status_cb callback, void *payload); /** * Gather file status information and run callbacks as requested. * * This is an extended version of the `git_status_foreach()` API that * allows for more granular control over which paths will be processed and * in what order. See the `git_status_options` structure for details * about the additional controls that this makes available. * * Note that if a `pathspec` is given in the `git_status_options` to filter * the status, then the results from rename detection (if you enable it) may * not be accurate. To do rename detection properly, this must be called * with no `pathspec` so that all files can be considered. * * @param repo Repository object * @param opts Status options structure * @param callback The function to call on each file * @param payload Pointer to pass through to callback function * @return 0 on success, non-zero callback return value, or error code */ GIT_EXTERN(int) git_status_foreach_ext( git_repository *repo, const git_status_options *opts, git_status_cb callback, void *payload); /** * Get file status for a single file. * * This tries to get status for the filename that you give. If no files * match that name (in either the HEAD, index, or working directory), this * returns GIT_ENOTFOUND. * * If the name matches multiple files (for example, if the `path` names a * directory or if running on a case- insensitive filesystem and yet the * HEAD has two entries that both match the path), then this returns * GIT_EAMBIGUOUS because it cannot give correct results. * * This does not do any sort of rename detection. Renames require a set of * targets and because of the path filtering, there is not enough * information to check renames correctly. To check file status with rename * detection, there is no choice but to do a full `git_status_list_new` and * scan through looking for the path that you are interested in. * * @param status_flags Output combination of git_status_t values for file * @param repo A repository object * @param path The exact path to retrieve status for relative to the * repository working directory * @return 0 on success, GIT_ENOTFOUND if the file is not found in the HEAD, * index, and work tree, GIT_EAMBIGUOUS if `path` matches multiple files * or if it refers to a folder, and -1 on other errors. */ GIT_EXTERN(int) git_status_file( unsigned int *status_flags, git_repository *repo, const char *path); /** * Gather file status information and populate the `git_status_list`. * * Note that if a `pathspec` is given in the `git_status_options` to filter * the status, then the results from rename detection (if you enable it) may * not be accurate. To do rename detection properly, this must be called * with no `pathspec` so that all files can be considered. * * @param out Pointer to store the status results in * @param repo Repository object * @param opts Status options structure * @return 0 on success or error code */ GIT_EXTERN(int) git_status_list_new( git_status_list **out, git_repository *repo, const git_status_options *opts); /** * Gets the count of status entries in this list. * * If there are no changes in status (at least according the options given * when the status list was created), this can return 0. * * @param statuslist Existing status list object * @return the number of status entries */ GIT_EXTERN(size_t) git_status_list_entrycount( git_status_list *statuslist); /** * Get a pointer to one of the entries in the status list. * * The entry is not modifiable and should not be freed. * * @param statuslist Existing status list object * @param idx Position of the entry * @return Pointer to the entry; NULL if out of bounds */ GIT_EXTERN(const git_status_entry *) git_status_byindex( git_status_list *statuslist, size_t idx); /** * Free an existing status list * * @param statuslist Existing status list object */ GIT_EXTERN(void) git_status_list_free( git_status_list *statuslist); /** * Test if the ignore rules apply to a given file. * * This function checks the ignore rules to see if they would apply to the * given file. This indicates if the file would be ignored regardless of * whether the file is already in the index or committed to the repository. * * One way to think of this is if you were to do "git add ." on the * directory containing the file, would it be added or not? * * @param ignored Boolean returning 0 if the file is not ignored, 1 if it is * @param repo A repository object * @param path The file to check ignores for, rooted at the repo's workdir. * @return 0 if ignore rules could be processed for the file (regardless * of whether it exists or not), or an error < 0 if they could not. */ GIT_EXTERN(int) git_status_should_ignore( int *ignored, git_repository *repo, const char *path); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/patch.h0000664000175000017500000002260212510265101016636 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_patch_h__ #define INCLUDE_git_patch_h__ #include "common.h" #include "types.h" #include "oid.h" #include "diff.h" /** * @file git2/patch.h * @brief Patch handling routines. * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * The diff patch is used to store all the text diffs for a delta. * * You can easily loop over the content of patches and get information about * them. */ typedef struct git_patch git_patch; /** * Return a patch for an entry in the diff list. * * The `git_patch` is a newly created object contains the text diffs * for the delta. You have to call `git_patch_free()` when you are * done with it. You can use the patch object to loop over all the hunks * and lines in the diff of the one delta. * * For an unchanged file or a binary file, no `git_patch` will be * created, the output will be set to NULL, and the `binary` flag will be * set true in the `git_diff_delta` structure. * * It is okay to pass NULL for either of the output parameters; if you pass * NULL for the `git_patch`, then the text diff will not be calculated. * * @param out Output parameter for the delta patch object * @param diff Diff list object * @param idx Index into diff list * @return 0 on success, other value < 0 on error */ GIT_EXTERN(int) git_patch_from_diff( git_patch **out, git_diff *diff, size_t idx); /** * Directly generate a patch from the difference between two blobs. * * This is just like `git_diff_blobs()` except it generates a patch object * for the difference instead of directly making callbacks. You can use the * standard `git_patch` accessor functions to read the patch data, and * you must call `git_patch_free()` on the patch when done. * * @param out The generated patch; NULL on error * @param old_blob Blob for old side of diff, or NULL for empty blob * @param old_as_path Treat old blob as if it had this filename; can be NULL * @param new_blob Blob for new side of diff, or NULL for empty blob * @param new_as_path Treat new blob as if it had this filename; can be NULL * @param opts Options for diff, or NULL for default options * @return 0 on success or error code < 0 */ GIT_EXTERN(int) git_patch_from_blobs( git_patch **out, const git_blob *old_blob, const char *old_as_path, const git_blob *new_blob, const char *new_as_path, const git_diff_options *opts); /** * Directly generate a patch from the difference between a blob and a buffer. * * This is just like `git_diff_blob_to_buffer()` except it generates a patch * object for the difference instead of directly making callbacks. You can * use the standard `git_patch` accessor functions to read the patch * data, and you must call `git_patch_free()` on the patch when done. * * @param out The generated patch; NULL on error * @param old_blob Blob for old side of diff, or NULL for empty blob * @param old_as_path Treat old blob as if it had this filename; can be NULL * @param buffer Raw data for new side of diff, or NULL for empty * @param buffer_len Length of raw data for new side of diff * @param buffer_as_path Treat buffer as if it had this filename; can be NULL * @param opts Options for diff, or NULL for default options * @return 0 on success or error code < 0 */ GIT_EXTERN(int) git_patch_from_blob_and_buffer( git_patch **out, const git_blob *old_blob, const char *old_as_path, const char *buffer, size_t buffer_len, const char *buffer_as_path, const git_diff_options *opts); /** * Directly generate a patch from the difference between two buffers. * * This is just like `git_diff_buffers()` except it generates a patch * object for the difference instead of directly making callbacks. You can * use the standard `git_patch` accessor functions to read the patch * data, and you must call `git_patch_free()` on the patch when done. * * @param out The generated patch; NULL on error * @param old_buffer Raw data for old side of diff, or NULL for empty * @param old_len Length of the raw data for old side of the diff * @param old_as_path Treat old buffer as if it had this filename; can be NULL * @param new_buffer Raw data for new side of diff, or NULL for empty * @param new_len Length of raw data for new side of diff * @param new_as_path Treat buffer as if it had this filename; can be NULL * @param opts Options for diff, or NULL for default options * @return 0 on success or error code < 0 */ GIT_EXTERN(int) git_patch_from_buffers( git_patch **out, const void *old_buffer, size_t old_len, const char *old_as_path, const char *new_buffer, size_t new_len, const char *new_as_path, const git_diff_options *opts); /** * Free a git_patch object. */ GIT_EXTERN(void) git_patch_free(git_patch *patch); /** * Get the delta associated with a patch. This delta points to internal * data and you do not have to release it when you are done with it. */ GIT_EXTERN(const git_diff_delta *) git_patch_get_delta(const git_patch *patch); /** * Get the number of hunks in a patch */ GIT_EXTERN(size_t) git_patch_num_hunks(const git_patch *patch); /** * Get line counts of each type in a patch. * * This helps imitate a diff --numstat type of output. For that purpose, * you only need the `total_additions` and `total_deletions` values, but we * include the `total_context` line count in case you want the total number * of lines of diff output that will be generated. * * All outputs are optional. Pass NULL if you don't need a particular count. * * @param total_context Count of context lines in output, can be NULL. * @param total_additions Count of addition lines in output, can be NULL. * @param total_deletions Count of deletion lines in output, can be NULL. * @param patch The git_patch object * @return 0 on success, <0 on error */ GIT_EXTERN(int) git_patch_line_stats( size_t *total_context, size_t *total_additions, size_t *total_deletions, const git_patch *patch); /** * Get the information about a hunk in a patch * * Given a patch and a hunk index into the patch, this returns detailed * information about that hunk. Any of the output pointers can be passed * as NULL if you don't care about that particular piece of information. * * @param out Output pointer to git_diff_hunk of hunk * @param lines_in_hunk Output count of total lines in this hunk * @param patch Input pointer to patch object * @param hunk_idx Input index of hunk to get information about * @return 0 on success, GIT_ENOTFOUND if hunk_idx out of range, <0 on error */ GIT_EXTERN(int) git_patch_get_hunk( const git_diff_hunk **out, size_t *lines_in_hunk, git_patch *patch, size_t hunk_idx); /** * Get the number of lines in a hunk. * * @param patch The git_patch object * @param hunk_idx Index of the hunk * @return Number of lines in hunk or -1 if invalid hunk index */ GIT_EXTERN(int) git_patch_num_lines_in_hunk( const git_patch *patch, size_t hunk_idx); /** * Get data about a line in a hunk of a patch. * * Given a patch, a hunk index, and a line index in the hunk, this * will return a lot of details about that line. If you pass a hunk * index larger than the number of hunks or a line index larger than * the number of lines in the hunk, this will return -1. * * @param out The git_diff_line data for this line * @param patch The patch to look in * @param hunk_idx The index of the hunk * @param line_of_hunk The index of the line in the hunk * @return 0 on success, <0 on failure */ GIT_EXTERN(int) git_patch_get_line_in_hunk( const git_diff_line **out, git_patch *patch, size_t hunk_idx, size_t line_of_hunk); /** * Look up size of patch diff data in bytes * * This returns the raw size of the patch data. This only includes the * actual data from the lines of the diff, not the file or hunk headers. * * If you pass `include_context` as true (non-zero), this will be the size * of all of the diff output; if you pass it as false (zero), this will * only include the actual changed lines (as if `context_lines` was 0). * * @param patch A git_patch representing changes to one file * @param include_context Include context lines in size if non-zero * @param include_hunk_headers Include hunk header lines if non-zero * @param include_file_headers Include file header lines if non-zero * @return The number of bytes of data */ GIT_EXTERN(size_t) git_patch_size( git_patch *patch, int include_context, int include_hunk_headers, int include_file_headers); /** * Serialize the patch to text via callback. * * Returning a non-zero value from the callback will terminate the iteration * and return that value to the caller. * * @param patch A git_patch representing changes to one file * @param print_cb Callback function to output lines of the patch. Will be * called for file headers, hunk headers, and diff lines. * @param payload Reference pointer that will be passed to your callbacks. * @return 0 on success, non-zero callback return value, or error code */ GIT_EXTERN(int) git_patch_print( git_patch *patch, git_diff_line_cb print_cb, void *payload); /** * Get the content of a patch as a single diff text. * * @param out The git_buf to be filled in * @param patch A git_patch representing changes to one file * @return 0 on success, <0 on failure. */ GIT_EXTERN(int) git_patch_to_buf( git_buf *out, git_patch *patch); GIT_END_DECL /**@}*/ #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/repository.h0000664000175000017500000006441112572105236017774 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_repository_h__ #define INCLUDE_git_repository_h__ #include "common.h" #include "types.h" #include "oid.h" #include "buffer.h" /** * @file git2/repository.h * @brief Git repository management routines * @defgroup git_repository Git repository management routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Open a git repository. * * The 'path' argument must point to either a git repository * folder, or an existing work dir. * * The method will automatically detect if 'path' is a normal * or bare repository or fail is 'path' is neither. * * @param out pointer to the repo which will be opened * @param path the path to the repository * @return 0 or an error code */ GIT_EXTERN(int) git_repository_open(git_repository **out, const char *path); /** * Create a "fake" repository to wrap an object database * * Create a repository object to wrap an object database to be used * with the API when all you have is an object database. This doesn't * have any paths associated with it, so use with care. * * @param out pointer to the repo * @param odb the object database to wrap * @return 0 or an error code */ GIT_EXTERN(int) git_repository_wrap_odb(git_repository **out, git_odb *odb); /** * Look for a git repository and copy its path in the given buffer. * The lookup start from base_path and walk across parent directories * if nothing has been found. The lookup ends when the first repository * is found, or when reaching a directory referenced in ceiling_dirs * or when the filesystem changes (in case across_fs is true). * * The method will automatically detect if the repository is bare * (if there is a repository). * * @param out A pointer to a user-allocated git_buf which will contain * the found path. * * @param start_path The base path where the lookup starts. * * @param across_fs If true, then the lookup will not stop when a * filesystem device change is detected while exploring parent directories. * * @param ceiling_dirs A GIT_PATH_LIST_SEPARATOR separated list of * absolute symbolic link free paths. The lookup will stop when any * of this paths is reached. Note that the lookup always performs on * start_path no matter start_path appears in ceiling_dirs ceiling_dirs * might be NULL (which is equivalent to an empty string) * * @return 0 or an error code */ GIT_EXTERN(int) git_repository_discover( git_buf *out, const char *start_path, int across_fs, const char *ceiling_dirs); /** * Option flags for `git_repository_open_ext`. * * * GIT_REPOSITORY_OPEN_NO_SEARCH - Only open the repository if it can be * immediately found in the start_path. Do not walk up from the * start_path looking at parent directories. * * GIT_REPOSITORY_OPEN_CROSS_FS - Unless this flag is set, open will not * continue searching across filesystem boundaries (i.e. when `st_dev` * changes from the `stat` system call). (E.g. Searching in a user's home * directory "/home/user/source/" will not return "/.git/" as the found * repo if "/" is a different filesystem than "/home".) * * GIT_REPOSITORY_OPEN_BARE - Open repository as a bare repo regardless * of core.bare config, and defer loading config file for faster setup. * Unlike `git_repository_open_bare`, this can follow gitlinks. */ typedef enum { GIT_REPOSITORY_OPEN_NO_SEARCH = (1 << 0), GIT_REPOSITORY_OPEN_CROSS_FS = (1 << 1), GIT_REPOSITORY_OPEN_BARE = (1 << 2), } git_repository_open_flag_t; /** * Find and open a repository with extended controls. * * @param out Pointer to the repo which will be opened. This can * actually be NULL if you only want to use the error code to * see if a repo at this path could be opened. * @param path Path to open as git repository. If the flags * permit "searching", then this can be a path to a subdirectory * inside the working directory of the repository. * @param flags A combination of the GIT_REPOSITORY_OPEN flags above. * @param ceiling_dirs A GIT_PATH_LIST_SEPARATOR delimited list of path * prefixes at which the search for a containing repository should * terminate. * @return 0 on success, GIT_ENOTFOUND if no repository could be found, * or -1 if there was a repository but open failed for some reason * (such as repo corruption or system errors). */ GIT_EXTERN(int) git_repository_open_ext( git_repository **out, const char *path, unsigned int flags, const char *ceiling_dirs); /** * Open a bare repository on the serverside. * * This is a fast open for bare repositories that will come in handy * if you're e.g. hosting git repositories and need to access them * efficiently * * @param out Pointer to the repo which will be opened. * @param bare_path Direct path to the bare repository * @return 0 on success, or an error code */ GIT_EXTERN(int) git_repository_open_bare(git_repository **out, const char *bare_path); /** * Free a previously allocated repository * * Note that after a repository is free'd, all the objects it has spawned * will still exist until they are manually closed by the user * with `git_object_free`, but accessing any of the attributes of * an object without a backing repository will result in undefined * behavior * * @param repo repository handle to close. If NULL nothing occurs. */ GIT_EXTERN(void) git_repository_free(git_repository *repo); /** * Creates a new Git repository in the given folder. * * TODO: * - Reinit the repository * * @param out pointer to the repo which will be created or reinitialized * @param path the path to the repository * @param is_bare if true, a Git repository without a working directory is * created at the pointed path. If false, provided path will be * considered as the working directory into which the .git directory * will be created. * * @return 0 or an error code */ GIT_EXTERN(int) git_repository_init( git_repository **out, const char *path, unsigned is_bare); /** * Option flags for `git_repository_init_ext`. * * These flags configure extra behaviors to `git_repository_init_ext`. * In every case, the default behavior is the zero value (i.e. flag is * not set). Just OR the flag values together for the `flags` parameter * when initializing a new repo. Details of individual values are: * * * BARE - Create a bare repository with no working directory. * * NO_REINIT - Return an GIT_EEXISTS error if the repo_path appears to * already be an git repository. * * NO_DOTGIT_DIR - Normally a "/.git/" will be appended to the repo * path for non-bare repos (if it is not already there), but * passing this flag prevents that behavior. * * MKDIR - Make the repo_path (and workdir_path) as needed. Init is * always willing to create the ".git" directory even without this * flag. This flag tells init to create the trailing component of * the repo and workdir paths as needed. * * MKPATH - Recursively make all components of the repo and workdir * paths as necessary. * * EXTERNAL_TEMPLATE - libgit2 normally uses internal templates to * initialize a new repo. This flags enables external templates, * looking the "template_path" from the options if set, or the * `init.templatedir` global config if not, or falling back on * "/usr/share/git-core/templates" if it exists. * * GIT_REPOSITORY_INIT_RELATIVE_GITLINK - If an alternate workdir is * specified, use relative paths for the gitdir and core.worktree. */ typedef enum { GIT_REPOSITORY_INIT_BARE = (1u << 0), GIT_REPOSITORY_INIT_NO_REINIT = (1u << 1), GIT_REPOSITORY_INIT_NO_DOTGIT_DIR = (1u << 2), GIT_REPOSITORY_INIT_MKDIR = (1u << 3), GIT_REPOSITORY_INIT_MKPATH = (1u << 4), GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = (1u << 5), GIT_REPOSITORY_INIT_RELATIVE_GITLINK = (1u << 6), } git_repository_init_flag_t; /** * Mode options for `git_repository_init_ext`. * * Set the mode field of the `git_repository_init_options` structure * either to the custom mode that you would like, or to one of the * following modes: * * * SHARED_UMASK - Use permissions configured by umask - the default. * * SHARED_GROUP - Use "--shared=group" behavior, chmod'ing the new repo * to be group writable and "g+sx" for sticky group assignment. * * SHARED_ALL - Use "--shared=all" behavior, adding world readability. * * Anything else - Set to custom value. */ typedef enum { GIT_REPOSITORY_INIT_SHARED_UMASK = 0, GIT_REPOSITORY_INIT_SHARED_GROUP = 0002775, GIT_REPOSITORY_INIT_SHARED_ALL = 0002777, } git_repository_init_mode_t; /** * Extended options structure for `git_repository_init_ext`. * * This contains extra options for `git_repository_init_ext` that enable * additional initialization features. The fields are: * * * flags - Combination of GIT_REPOSITORY_INIT flags above. * * mode - Set to one of the standard GIT_REPOSITORY_INIT_SHARED_... * constants above, or to a custom value that you would like. * * workdir_path - The path to the working dir or NULL for default (i.e. * repo_path parent on non-bare repos). IF THIS IS RELATIVE PATH, * IT WILL BE EVALUATED RELATIVE TO THE REPO_PATH. If this is not * the "natural" working directory, a .git gitlink file will be * created here linking to the repo_path. * * description - If set, this will be used to initialize the "description" * file in the repository, instead of using the template content. * * template_path - When GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE is set, * this contains the path to use for the template directory. If * this is NULL, the config or default directory options will be * used instead. * * initial_head - The name of the head to point HEAD at. If NULL, then * this will be treated as "master" and the HEAD ref will be set * to "refs/heads/master". If this begins with "refs/" it will be * used verbatim; otherwise "refs/heads/" will be prefixed. * * origin_url - If this is non-NULL, then after the rest of the * repository initialization is completed, an "origin" remote * will be added pointing to this URL. */ typedef struct { unsigned int version; uint32_t flags; uint32_t mode; const char *workdir_path; const char *description; const char *template_path; const char *initial_head; const char *origin_url; } git_repository_init_options; #define GIT_REPOSITORY_INIT_OPTIONS_VERSION 1 #define GIT_REPOSITORY_INIT_OPTIONS_INIT {GIT_REPOSITORY_INIT_OPTIONS_VERSION} /** * Initializes a `git_repository_init_options` with default values. Equivalent * to creating an instance with GIT_REPOSITORY_INIT_OPTIONS_INIT. * * @param opts the `git_repository_init_options` struct to initialize * @param version Version of struct; pass `GIT_REPOSITORY_INIT_OPTIONS_VERSION` * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_repository_init_init_options( git_repository_init_options *opts, unsigned int version); /** * Create a new Git repository in the given folder with extended controls. * * This will initialize a new git repository (creating the repo_path * if requested by flags) and working directory as needed. It will * auto-detect the case sensitivity of the file system and if the * file system supports file mode bits correctly. * * @param out Pointer to the repo which will be created or reinitialized. * @param repo_path The path to the repository. * @param opts Pointer to git_repository_init_options struct. * @return 0 or an error code on failure. */ GIT_EXTERN(int) git_repository_init_ext( git_repository **out, const char *repo_path, git_repository_init_options *opts); /** * Retrieve and resolve the reference pointed at by HEAD. * * The returned `git_reference` will be owned by caller and * `git_reference_free()` must be called when done with it to release the * allocated memory and prevent a leak. * * @param out pointer to the reference which will be retrieved * @param repo a repository object * * @return 0 on success, GIT_EUNBORNBRANCH when HEAD points to a non existing * branch, GIT_ENOTFOUND when HEAD is missing; an error code otherwise */ GIT_EXTERN(int) git_repository_head(git_reference **out, git_repository *repo); /** * Check if a repository's HEAD is detached * * A repository's HEAD is detached when it points directly to a commit * instead of a branch. * * @param repo Repo to test * @return 1 if HEAD is detached, 0 if it's not; error code if there * was an error. */ GIT_EXTERN(int) git_repository_head_detached(git_repository *repo); /** * Check if the current branch is unborn * * An unborn branch is one named from HEAD but which doesn't exist in * the refs namespace, because it doesn't have any commit to point to. * * @param repo Repo to test * @return 1 if the current branch is unborn, 0 if it's not; error * code if there was an error */ GIT_EXTERN(int) git_repository_head_unborn(git_repository *repo); /** * Check if a repository is empty * * An empty repository has just been initialized and contains no references * apart from HEAD, which must be pointing to the unborn master branch. * * @param repo Repo to test * @return 1 if the repository is empty, 0 if it isn't, error code * if the repository is corrupted */ GIT_EXTERN(int) git_repository_is_empty(git_repository *repo); /** * Get the path of this repository * * This is the path of the `.git` folder for normal repositories, * or of the repository itself for bare repositories. * * @param repo A repository object * @return the path to the repository */ GIT_EXTERN(const char *) git_repository_path(git_repository *repo); /** * Get the path of the working directory for this repository * * If the repository is bare, this function will always return * NULL. * * @param repo A repository object * @return the path to the working dir, if it exists */ GIT_EXTERN(const char *) git_repository_workdir(git_repository *repo); /** * Set the path to the working directory for this repository * * The working directory doesn't need to be the same one * that contains the `.git` folder for this repository. * * If this repository is bare, setting its working directory * will turn it into a normal repository, capable of performing * all the common workdir operations (checkout, status, index * manipulation, etc). * * @param repo A repository object * @param workdir The path to a working directory * @param update_gitlink Create/update gitlink in workdir and set config * "core.worktree" (if workdir is not the parent of the .git directory) * @return 0, or an error code */ GIT_EXTERN(int) git_repository_set_workdir( git_repository *repo, const char *workdir, int update_gitlink); /** * Check if a repository is bare * * @param repo Repo to test * @return 1 if the repository is bare, 0 otherwise. */ GIT_EXTERN(int) git_repository_is_bare(git_repository *repo); /** * Get the configuration file for this repository. * * If a configuration file has not been set, the default * config set for the repository will be returned, including * global and system configurations (if they are available). * * The configuration file must be freed once it's no longer * being used by the user. * * @param out Pointer to store the loaded configuration * @param repo A repository object * @return 0, or an error code */ GIT_EXTERN(int) git_repository_config(git_config **out, git_repository *repo); /** * Get a snapshot of the repository's configuration * * Convenience function to take a snapshot from the repository's * configuration. The contents of this snapshot will not change, * even if the underlying config files are modified. * * The configuration file must be freed once it's no longer * being used by the user. * * @param out Pointer to store the loaded configuration * @param repo the repository * @return 0, or an error code */ GIT_EXTERN(int) git_repository_config_snapshot(git_config **out, git_repository *repo); /** * Get the Object Database for this repository. * * If a custom ODB has not been set, the default * database for the repository will be returned (the one * located in `.git/objects`). * * The ODB must be freed once it's no longer being used by * the user. * * @param out Pointer to store the loaded ODB * @param repo A repository object * @return 0, or an error code */ GIT_EXTERN(int) git_repository_odb(git_odb **out, git_repository *repo); /** * Get the Reference Database Backend for this repository. * * If a custom refsdb has not been set, the default database for * the repository will be returned (the one that manipulates loose * and packed references in the `.git` directory). * * The refdb must be freed once it's no longer being used by * the user. * * @param out Pointer to store the loaded refdb * @param repo A repository object * @return 0, or an error code */ GIT_EXTERN(int) git_repository_refdb(git_refdb **out, git_repository *repo); /** * Get the Index file for this repository. * * If a custom index has not been set, the default * index for the repository will be returned (the one * located in `.git/index`). * * The index must be freed once it's no longer being used by * the user. * * @param out Pointer to store the loaded index * @param repo A repository object * @return 0, or an error code */ GIT_EXTERN(int) git_repository_index(git_index **out, git_repository *repo); /** * Retrieve git's prepared message * * Operations such as git revert/cherry-pick/merge with the -n option * stop just short of creating a commit with the changes and save * their prepared message in .git/MERGE_MSG so the next git-commit * execution can present it to the user for them to amend if they * wish. * * Use this function to get the contents of this file. Don't forget to * remove the file after you create the commit. * * @param out git_buf to write data into * @param repo Repository to read prepared message from * @return 0, GIT_ENOTFOUND if no message exists or an error code */ GIT_EXTERN(int) git_repository_message(git_buf *out, git_repository *repo); /** * Remove git's prepared message. * * Remove the message that `git_repository_message` retrieves. */ GIT_EXTERN(int) git_repository_message_remove(git_repository *repo); /** * Remove all the metadata associated with an ongoing command like merge, * revert, cherry-pick, etc. For example: MERGE_HEAD, MERGE_MSG, etc. * * @param repo A repository object * @return 0 on success, or error */ GIT_EXTERN(int) git_repository_state_cleanup(git_repository *repo); typedef int (*git_repository_fetchhead_foreach_cb)(const char *ref_name, const char *remote_url, const git_oid *oid, unsigned int is_merge, void *payload); /** * Invoke 'callback' for each entry in the given FETCH_HEAD file. * * Return a non-zero value from the callback to stop the loop. * * @param repo A repository object * @param callback Callback function * @param payload Pointer to callback data (optional) * @return 0 on success, non-zero callback return value, GIT_ENOTFOUND if * there is no FETCH_HEAD file, or other error code. */ GIT_EXTERN(int) git_repository_fetchhead_foreach( git_repository *repo, git_repository_fetchhead_foreach_cb callback, void *payload); typedef int (*git_repository_mergehead_foreach_cb)(const git_oid *oid, void *payload); /** * If a merge is in progress, invoke 'callback' for each commit ID in the * MERGE_HEAD file. * * Return a non-zero value from the callback to stop the loop. * * @param repo A repository object * @param callback Callback function * @param payload Pointer to callback data (optional) * @return 0 on success, non-zero callback return value, GIT_ENOTFOUND if * there is no MERGE_HEAD file, or other error code. */ GIT_EXTERN(int) git_repository_mergehead_foreach( git_repository *repo, git_repository_mergehead_foreach_cb callback, void *payload); /** * Calculate hash of file using repository filtering rules. * * If you simply want to calculate the hash of a file on disk with no filters, * you can just use the `git_odb_hashfile()` API. However, if you want to * hash a file in the repository and you want to apply filtering rules (e.g. * crlf filters) before generating the SHA, then use this function. * * Note: if the repository has `core.safecrlf` set to fail and the * filtering triggers that failure, then this function will return an * error and not calculate the hash of the file. * * @param out Output value of calculated SHA * @param repo Repository pointer * @param path Path to file on disk whose contents should be hashed. If the * repository is not NULL, this can be a relative path. * @param type The object type to hash as (e.g. GIT_OBJ_BLOB) * @param as_path The path to use to look up filtering rules. If this is * NULL, then the `path` parameter will be used instead. If * this is passed as the empty string, then no filters will be * applied when calculating the hash. * @return 0 on success, or an error code */ GIT_EXTERN(int) git_repository_hashfile( git_oid *out, git_repository *repo, const char *path, git_otype type, const char *as_path); /** * Make the repository HEAD point to the specified reference. * * If the provided reference points to a Tree or a Blob, the HEAD is * unaltered and -1 is returned. * * If the provided reference points to a branch, the HEAD will point * to that branch, staying attached, or become attached if it isn't yet. * If the branch doesn't exist yet, no error will be return. The HEAD * will then be attached to an unborn branch. * * Otherwise, the HEAD will be detached and will directly point to * the Commit. * * @param repo Repository pointer * @param refname Canonical name of the reference the HEAD should point at * @return 0 on success, or an error code */ GIT_EXTERN(int) git_repository_set_head( git_repository* repo, const char* refname); /** * Make the repository HEAD directly point to the Commit. * * If the provided committish cannot be found in the repository, the HEAD * is unaltered and GIT_ENOTFOUND is returned. * * If the provided commitish cannot be peeled into a commit, the HEAD * is unaltered and -1 is returned. * * Otherwise, the HEAD will eventually be detached and will directly point to * the peeled Commit. * * @param repo Repository pointer * @param commitish Object id of the Commit the HEAD should point to * @return 0 on success, or an error code */ GIT_EXTERN(int) git_repository_set_head_detached( git_repository* repo, const git_oid* commitish); /** * Make the repository HEAD directly point to the Commit. * * This behaves like `git_repository_set_head_detached()` but takes an * annotated commit, which lets you specify which extended sha syntax * string was specified by a user, allowing for more exact reflog * messages. * * See the documentation for `git_repository_set_head_detached()`. * * @see git_repository_set_head_detached */ GIT_EXTERN(int) git_repository_set_head_detached_from_annotated( git_repository *repo, const git_annotated_commit *commitish); /** * Detach the HEAD. * * If the HEAD is already detached and points to a Commit, 0 is returned. * * If the HEAD is already detached and points to a Tag, the HEAD is * updated into making it point to the peeled Commit, and 0 is returned. * * If the HEAD is already detached and points to a non commitish, the HEAD is * unaltered, and -1 is returned. * * Otherwise, the HEAD will be detached and point to the peeled Commit. * * @param repo Repository pointer * @return 0 on success, GIT_EUNBORNBRANCH when HEAD points to a non existing * branch or an error code */ GIT_EXTERN(int) git_repository_detach_head( git_repository* repo); /** * Repository state * * These values represent possible states for the repository to be in, * based on the current operation which is ongoing. */ typedef enum { GIT_REPOSITORY_STATE_NONE, GIT_REPOSITORY_STATE_MERGE, GIT_REPOSITORY_STATE_REVERT, GIT_REPOSITORY_STATE_CHERRYPICK, GIT_REPOSITORY_STATE_BISECT, GIT_REPOSITORY_STATE_REBASE, GIT_REPOSITORY_STATE_REBASE_INTERACTIVE, GIT_REPOSITORY_STATE_REBASE_MERGE, GIT_REPOSITORY_STATE_APPLY_MAILBOX, GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE, } git_repository_state_t; /** * Determines the status of a git repository - ie, whether an operation * (merge, cherry-pick, etc) is in progress. * * @param repo Repository pointer * @return The state of the repository */ GIT_EXTERN(int) git_repository_state(git_repository *repo); /** * Sets the active namespace for this Git Repository * * This namespace affects all reference operations for the repo. * See `man gitnamespaces` * * @param repo The repo * @param nmspace The namespace. This should not include the refs * folder, e.g. to namespace all references under `refs/namespaces/foo/`, * use `foo` as the namespace. * @return 0 on success, -1 on error */ GIT_EXTERN(int) git_repository_set_namespace(git_repository *repo, const char *nmspace); /** * Get the currently active namespace for this repository * * @param repo The repo * @return the active namespace, or NULL if there isn't one */ GIT_EXTERN(const char *) git_repository_get_namespace(git_repository *repo); /** * Determine if the repository was a shallow clone * * @param repo The repository * @return 1 if shallow, zero if not */ GIT_EXTERN(int) git_repository_is_shallow(git_repository *repo); /** * Retrieve the configured identity to use for reflogs * * The memory is owned by the repository and must not be freed by the * user. * * @param name where to store the pointer to the name * @param email where to store the pointer to the email * @param repo the repository */ GIT_EXTERN(int) git_repository_ident(const char **name, const char **email, const git_repository *repo); /** * Set the identity to be used for writing reflogs * * If both are set, this name and email will be used to write to the * reflog. Pass NULL to unset. When unset, the identity will be taken * from the repository's configuration. * * @param repo the repository to configure * @param name the name to use for the reflog entries * @param email the email to use for the reflog entries */ GIT_EXTERN(int) git_repository_set_ident(git_repository *repo, const char *name, const char *email); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/odb_backend.h0000664000175000017500000000730512555730137017774 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_odb_backend_h__ #define INCLUDE_git_odb_backend_h__ #include "common.h" #include "types.h" /** * @file git2/backend.h * @brief Git custom backend functions * @defgroup git_odb Git object database routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /* * Constructors for in-box ODB backends. */ /** * Create a backend for the packfiles. * * @param out location to store the odb backend pointer * @param objects_dir the Git repository's objects directory * * @return 0 or an error code */ GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend **out, const char *objects_dir); /** * Create a backend for loose objects * * @param out location to store the odb backend pointer * @param objects_dir the Git repository's objects directory * @param compression_level zlib compression level to use * @param do_fsync whether to do an fsync() after writing (currently ignored) * @param dir_mode permissions to use creating a directory or 0 for defaults * @param file_mode permissions to use creating a file or 0 for defaults * * @return 0 or an error code */ GIT_EXTERN(int) git_odb_backend_loose( git_odb_backend **out, const char *objects_dir, int compression_level, int do_fsync, unsigned int dir_mode, unsigned int file_mode); /** * Create a backend out of a single packfile * * This can be useful for inspecting the contents of a single * packfile. * * @param out location to store the odb backend pointer * @param index_file path to the packfile's .idx file * * @return 0 or an error code */ GIT_EXTERN(int) git_odb_backend_one_pack(git_odb_backend **out, const char *index_file); /** Streaming mode */ typedef enum { GIT_STREAM_RDONLY = (1 << 1), GIT_STREAM_WRONLY = (1 << 2), GIT_STREAM_RW = (GIT_STREAM_RDONLY | GIT_STREAM_WRONLY), } git_odb_stream_t; /** * A stream to read/write from a backend. * * This represents a stream of data being written to or read from a * backend. When writing, the frontend functions take care of * calculating the object's id and all `finalize_write` needs to do is * store the object with the id it is passed. */ struct git_odb_stream { git_odb_backend *backend; unsigned int mode; void *hash_ctx; git_off_t declared_size; git_off_t received_bytes; /** * Write at most `len` bytes into `buffer` and advance the stream. */ int (*read)(git_odb_stream *stream, char *buffer, size_t len); /** * Write `len` bytes from `buffer` into the stream. */ int (*write)(git_odb_stream *stream, const char *buffer, size_t len); /** * Store the contents of the stream as an object with the id * specified in `oid`. * * This method might not be invoked if: * - an error occurs earlier with the `write` callback, * - the object referred to by `oid` already exists in any backend, or * - the final number of received bytes differs from the size declared * with `git_odb_open_wstream()` */ int (*finalize_write)(git_odb_stream *stream, const git_oid *oid); /** * Free the stream's memory. * * This method might be called without a call to `finalize_write` if * an error occurs or if the object is already present in the ODB. */ void (*free)(git_odb_stream *stream); }; /** A stream to write a pack file to the ODB */ struct git_odb_writepack { git_odb_backend *backend; int (*append)(git_odb_writepack *writepack, const void *data, size_t size, git_transfer_progress *stats); int (*commit)(git_odb_writepack *writepack, git_transfer_progress *stats); void (*free)(git_odb_writepack *writepack); }; GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/inttypes.h0000664000175000017500000001753112426525445017443 0ustar // ISO C9x compliant inttypes.h for Microsoft Visual Studio // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 // // Copyright (c) 2006 Alexander Chemeris // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // 2. 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. // // 3. The name of the author may be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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 _MSC_VER // [ #error "Use this header only with Microsoft Visual C++ compilers!" #endif // _MSC_VER ] #ifndef _MSC_INTTYPES_H_ // [ #define _MSC_INTTYPES_H_ #if _MSC_VER > 1000 #pragma once #endif #if _MSC_VER >= 1600 #include #else #include "stdint.h" #endif // 7.8 Format conversion of integer types typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t; // 7.8.1 Macros for format specifiers #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198 // The fprintf macros for signed integers are: #define PRId8 "d" #define PRIi8 "i" #define PRIdLEAST8 "d" #define PRIiLEAST8 "i" #define PRIdFAST8 "d" #define PRIiFAST8 "i" #define PRId16 "hd" #define PRIi16 "hi" #define PRIdLEAST16 "hd" #define PRIiLEAST16 "hi" #define PRIdFAST16 "hd" #define PRIiFAST16 "hi" #define PRId32 "I32d" #define PRIi32 "I32i" #define PRIdLEAST32 "I32d" #define PRIiLEAST32 "I32i" #define PRIdFAST32 "I32d" #define PRIiFAST32 "I32i" #define PRId64 "I64d" #define PRIi64 "I64i" #define PRIdLEAST64 "I64d" #define PRIiLEAST64 "I64i" #define PRIdFAST64 "I64d" #define PRIiFAST64 "I64i" #define PRIdMAX "I64d" #define PRIiMAX "I64i" #define PRIdPTR "Id" #define PRIiPTR "Ii" // The fprintf macros for unsigned integers are: #define PRIo8 "o" #define PRIu8 "u" #define PRIx8 "x" #define PRIX8 "X" #define PRIoLEAST8 "o" #define PRIuLEAST8 "u" #define PRIxLEAST8 "x" #define PRIXLEAST8 "X" #define PRIoFAST8 "o" #define PRIuFAST8 "u" #define PRIxFAST8 "x" #define PRIXFAST8 "X" #define PRIo16 "ho" #define PRIu16 "hu" #define PRIx16 "hx" #define PRIX16 "hX" #define PRIoLEAST16 "ho" #define PRIuLEAST16 "hu" #define PRIxLEAST16 "hx" #define PRIXLEAST16 "hX" #define PRIoFAST16 "ho" #define PRIuFAST16 "hu" #define PRIxFAST16 "hx" #define PRIXFAST16 "hX" #define PRIo32 "I32o" #define PRIu32 "I32u" #define PRIx32 "I32x" #define PRIX32 "I32X" #define PRIoLEAST32 "I32o" #define PRIuLEAST32 "I32u" #define PRIxLEAST32 "I32x" #define PRIXLEAST32 "I32X" #define PRIoFAST32 "I32o" #define PRIuFAST32 "I32u" #define PRIxFAST32 "I32x" #define PRIXFAST32 "I32X" #define PRIo64 "I64o" #define PRIu64 "I64u" #define PRIx64 "I64x" #define PRIX64 "I64X" #define PRIoLEAST64 "I64o" #define PRIuLEAST64 "I64u" #define PRIxLEAST64 "I64x" #define PRIXLEAST64 "I64X" #define PRIoFAST64 "I64o" #define PRIuFAST64 "I64u" #define PRIxFAST64 "I64x" #define PRIXFAST64 "I64X" #define PRIoMAX "I64o" #define PRIuMAX "I64u" #define PRIxMAX "I64x" #define PRIXMAX "I64X" #define PRIoPTR "Io" #define PRIuPTR "Iu" #define PRIxPTR "Ix" #define PRIXPTR "IX" // The fscanf macros for signed integers are: #define SCNd8 "d" #define SCNi8 "i" #define SCNdLEAST8 "d" #define SCNiLEAST8 "i" #define SCNdFAST8 "d" #define SCNiFAST8 "i" #define SCNd16 "hd" #define SCNi16 "hi" #define SCNdLEAST16 "hd" #define SCNiLEAST16 "hi" #define SCNdFAST16 "hd" #define SCNiFAST16 "hi" #define SCNd32 "ld" #define SCNi32 "li" #define SCNdLEAST32 "ld" #define SCNiLEAST32 "li" #define SCNdFAST32 "ld" #define SCNiFAST32 "li" #define SCNd64 "I64d" #define SCNi64 "I64i" #define SCNdLEAST64 "I64d" #define SCNiLEAST64 "I64i" #define SCNdFAST64 "I64d" #define SCNiFAST64 "I64i" #define SCNdMAX "I64d" #define SCNiMAX "I64i" #ifdef _WIN64 // [ # define SCNdPTR "I64d" # define SCNiPTR "I64i" #else // _WIN64 ][ # define SCNdPTR "ld" # define SCNiPTR "li" #endif // _WIN64 ] // The fscanf macros for unsigned integers are: #define SCNo8 "o" #define SCNu8 "u" #define SCNx8 "x" #define SCNX8 "X" #define SCNoLEAST8 "o" #define SCNuLEAST8 "u" #define SCNxLEAST8 "x" #define SCNXLEAST8 "X" #define SCNoFAST8 "o" #define SCNuFAST8 "u" #define SCNxFAST8 "x" #define SCNXFAST8 "X" #define SCNo16 "ho" #define SCNu16 "hu" #define SCNx16 "hx" #define SCNX16 "hX" #define SCNoLEAST16 "ho" #define SCNuLEAST16 "hu" #define SCNxLEAST16 "hx" #define SCNXLEAST16 "hX" #define SCNoFAST16 "ho" #define SCNuFAST16 "hu" #define SCNxFAST16 "hx" #define SCNXFAST16 "hX" #define SCNo32 "lo" #define SCNu32 "lu" #define SCNx32 "lx" #define SCNX32 "lX" #define SCNoLEAST32 "lo" #define SCNuLEAST32 "lu" #define SCNxLEAST32 "lx" #define SCNXLEAST32 "lX" #define SCNoFAST32 "lo" #define SCNuFAST32 "lu" #define SCNxFAST32 "lx" #define SCNXFAST32 "lX" #define SCNo64 "I64o" #define SCNu64 "I64u" #define SCNx64 "I64x" #define SCNX64 "I64X" #define SCNoLEAST64 "I64o" #define SCNuLEAST64 "I64u" #define SCNxLEAST64 "I64x" #define SCNXLEAST64 "I64X" #define SCNoFAST64 "I64o" #define SCNuFAST64 "I64u" #define SCNxFAST64 "I64x" #define SCNXFAST64 "I64X" #define SCNoMAX "I64o" #define SCNuMAX "I64u" #define SCNxMAX "I64x" #define SCNXMAX "I64X" #ifdef _WIN64 // [ # define SCNoPTR "I64o" # define SCNuPTR "I64u" # define SCNxPTR "I64x" # define SCNXPTR "I64X" #else // _WIN64 ][ # define SCNoPTR "lo" # define SCNuPTR "lu" # define SCNxPTR "lx" # define SCNXPTR "lX" #endif // _WIN64 ] #endif // __STDC_FORMAT_MACROS ] // 7.8.2 Functions for greatest-width integer types // 7.8.2.1 The imaxabs function #define imaxabs _abs64 // 7.8.2.2 The imaxdiv function // This is modified version of div() function from Microsoft's div.c found // in %MSVC.NET%\crt\src\div.c #ifdef STATIC_IMAXDIV // [ static #else // STATIC_IMAXDIV ][ _inline #endif // STATIC_IMAXDIV ] imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom) { imaxdiv_t result; result.quot = numer / denom; result.rem = numer % denom; if (numer < 0 && result.rem > 0) { // did division wrong; must fix up ++result.quot; result.rem -= denom; } return result; } // 7.8.2.3 The strtoimax and strtoumax functions #define strtoimax _strtoi64 #define strtoumax _strtoui64 // 7.8.2.4 The wcstoimax and wcstoumax functions #define wcstoimax _wcstoi64 #define wcstoumax _wcstoui64 #endif // _MSC_INTTYPES_H_ ] deps/libgit2-sys-0.3.8/libgit2/include/git2/message.h0000664000175000017500000000225212426525445017202 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_message_h__ #define INCLUDE_git_message_h__ #include "common.h" #include "buffer.h" /** * @file git2/message.h * @brief Git message management routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Clean up message from excess whitespace and make sure that the last line * ends with a '\n'. * * Optionally, can remove lines starting with a "#". * * @param out The user-allocated git_buf which will be filled with the * cleaned up message. * * @param message The message to be prettified. * * @param strip_comments Non-zero to remove comment lines, 0 to leave them in. * * @param comment_char Comment character. Lines starting with this character * are considered to be comments and removed if `strip_comments` is non-zero. * * @return 0 or an error code. */ GIT_EXTERN(int) git_message_prettify(git_buf *out, const char *message, int strip_comments, char comment_char); /** @} */ GIT_END_DECL #endif /* INCLUDE_git_message_h__ */ deps/libgit2-sys-0.3.8/libgit2/include/git2/remote.h0000664000175000017500000005735012610310643017045 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_remote_h__ #define INCLUDE_git_remote_h__ #include "common.h" #include "repository.h" #include "refspec.h" #include "net.h" #include "indexer.h" #include "strarray.h" #include "transport.h" #include "pack.h" /** * @file git2/remote.h * @brief Git remote management functions * @defgroup git_remote remote management functions * @ingroup Git * @{ */ GIT_BEGIN_DECL typedef int (*git_remote_rename_problem_cb)(const char *problematic_refspec, void *payload); /** * Add a remote with the default fetch refspec to the repository's configuration. * * @param out the resulting remote * @param repo the repository in which to create the remote * @param name the remote's name * @param url the remote's url * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code */ GIT_EXTERN(int) git_remote_create( git_remote **out, git_repository *repo, const char *name, const char *url); /** * Add a remote with the provided fetch refspec (or default if NULL) to the repository's * configuration. * * @param out the resulting remote * @param repo the repository in which to create the remote * @param name the remote's name * @param url the remote's url * @param fetch the remote fetch value * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code */ GIT_EXTERN(int) git_remote_create_with_fetchspec( git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch); /** * Create an anonymous remote * * Create a remote with the given url in-memory. You can use this when * you have a URL instead of a remote's name. * * @param out pointer to the new remote objects * @param repo the associated repository * @param url the remote repository's URL * @return 0 or an error code */ GIT_EXTERN(int) git_remote_create_anonymous( git_remote **out, git_repository *repo, const char *url); /** * Get the information for a particular remote * * The name will be checked for validity. * See `git_tag_create()` for rules about valid names. * * @param out pointer to the new remote object * @param repo the associated repository * @param name the remote's name * @return 0, GIT_ENOTFOUND, GIT_EINVALIDSPEC or an error code */ GIT_EXTERN(int) git_remote_lookup(git_remote **out, git_repository *repo, const char *name); /** * Create a copy of an existing remote. All internal strings are also * duplicated. Callbacks are not duplicated. * * Call `git_remote_free` to free the data. * * @param dest pointer where to store the copy * @param source object to copy * @return 0 or an error code */ GIT_EXTERN(int) git_remote_dup(git_remote **dest, git_remote *source); /** * Get the remote's repository * * @param remote the remote * @return a pointer to the repository */ GIT_EXTERN(git_repository *) git_remote_owner(const git_remote *remote); /** * Get the remote's name * * @param remote the remote * @return a pointer to the name or NULL for in-memory remotes */ GIT_EXTERN(const char *) git_remote_name(const git_remote *remote); /** * Get the remote's url * * If url.*.insteadOf has been configured for this URL, it will * return the modified URL. * * @param remote the remote * @return a pointer to the url */ GIT_EXTERN(const char *) git_remote_url(const git_remote *remote); /** * Get the remote's url for pushing * * If url.*.pushInsteadOf has been configured for this URL, it * will return the modified URL. * * @param remote the remote * @return a pointer to the url or NULL if no special url for pushing is set */ GIT_EXTERN(const char *) git_remote_pushurl(const git_remote *remote); /** * Set the remote's url in the configuration * * Remote objects already in memory will not be affected. This assumes * the common case of a single-url remote and will otherwise return an error. * * @param repo the repository in which to perform the change * @param remote the remote's name * @param url the url to set * @return 0 or an error value */ GIT_EXTERN(int) git_remote_set_url(git_repository *repo, const char *remote, const char* url); /** * Set the remote's url for pushing in the configuration. * * Remote objects already in memory will not be affected. This assumes * the common case of a single-url remote and will otherwise return an error. * * * @param repo the repository in which to perform the change * @param remote the remote's name * @param url the url to set */ GIT_EXTERN(int) git_remote_set_pushurl(git_repository *repo, const char *remote, const char* url); /** * Add a fetch refspec to the remote's configuration * * Add the given refspec to the fetch list in the configuration. No * loaded remote instances will be affected. * * @param repo the repository in which to change the configuration * @param remote the name of the remote to change * @param refspec the new fetch refspec * @return 0, GIT_EINVALIDSPEC if refspec is invalid or an error value */ GIT_EXTERN(int) git_remote_add_fetch(git_repository *repo, const char *remote, const char *refspec); /** * Get the remote's list of fetch refspecs * * The memory is owned by the user and should be freed with * `git_strarray_free`. * * @param array pointer to the array in which to store the strings * @param remote the remote to query */ GIT_EXTERN(int) git_remote_get_fetch_refspecs(git_strarray *array, const git_remote *remote); /** * Add a push refspec to the remote's configuration * * Add the given refspec to the push list in the configuration. No * loaded remote instances will be affected. * * @param repo the repository in which to change the configuration * @param remote the name of the remote to change * @param refspec the new push refspec * @return 0, GIT_EINVALIDSPEC if refspec is invalid or an error value */ GIT_EXTERN(int) git_remote_add_push(git_repository *repo, const char *remote, const char *refspec); /** * Get the remote's list of push refspecs * * The memory is owned by the user and should be freed with * `git_strarray_free`. * * @param array pointer to the array in which to store the strings * @param remote the remote to query */ GIT_EXTERN(int) git_remote_get_push_refspecs(git_strarray *array, const git_remote *remote); /** * Get the number of refspecs for a remote * * @param remote the remote * @return the amount of refspecs configured in this remote */ GIT_EXTERN(size_t) git_remote_refspec_count(const git_remote *remote); /** * Get a refspec from the remote * * @param remote the remote to query * @param n the refspec to get * @return the nth refspec */ GIT_EXTERN(const git_refspec *)git_remote_get_refspec(const git_remote *remote, size_t n); /** * Open a connection to a remote * * The transport is selected based on the URL. The direction argument * is due to a limitation of the git protocol (over TCP or SSH) which * starts up a specific binary which can only do the one or the other. * * @param remote the remote to connect to * @param direction GIT_DIRECTION_FETCH if you want to fetch or * GIT_DIRECTION_PUSH if you want to push * @param callbacks the callbacks to use for this connection * @param custom_headers extra HTTP headers to use in this connection * @return 0 or an error code */ GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_strarray *custom_headers); /** * Get the remote repository's reference advertisement list * * Get the list of references with which the server responds to a new * connection. * * The remote (or more exactly its transport) must have connected to * the remote repository. This list is available as soon as the * connection to the remote is initiated and it remains available * after disconnecting. * * The memory belongs to the remote. The pointer will be valid as long * as a new connection is not initiated, but it is recommended that * you make a copy in order to make use of the data. * * @param out pointer to the array * @param size the number of remote heads * @param remote the remote * @return 0 on success, or an error code */ GIT_EXTERN(int) git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote); /** * Check whether the remote is connected * * Check whether the remote's underlying transport is connected to the * remote host. * * @param remote the remote * @return 1 if it's connected, 0 otherwise. */ GIT_EXTERN(int) git_remote_connected(const git_remote *remote); /** * Cancel the operation * * At certain points in its operation, the network code checks whether * the operation has been cancelled and if so stops the operation. * * @param remote the remote */ GIT_EXTERN(void) git_remote_stop(git_remote *remote); /** * Disconnect from the remote * * Close the connection to the remote. * * @param remote the remote to disconnect from */ GIT_EXTERN(void) git_remote_disconnect(git_remote *remote); /** * Free the memory associated with a remote * * This also disconnects from the remote, if the connection * has not been closed yet (using git_remote_disconnect). * * @param remote the remote to free */ GIT_EXTERN(void) git_remote_free(git_remote *remote); /** * Get a list of the configured remotes for a repo * * The string array must be freed by the user. * * @param out a string array which receives the names of the remotes * @param repo the repository to query * @return 0 or an error code */ GIT_EXTERN(int) git_remote_list(git_strarray *out, git_repository *repo); /** * Argument to the completion callback which tells it which operation * finished. */ typedef enum git_remote_completion_type { GIT_REMOTE_COMPLETION_DOWNLOAD, GIT_REMOTE_COMPLETION_INDEXING, GIT_REMOTE_COMPLETION_ERROR, } git_remote_completion_type; /** Push network progress notification function */ typedef int (*git_push_transfer_progress)( unsigned int current, unsigned int total, size_t bytes, void* payload); /** * Represents an update which will be performed on the remote during push */ typedef struct { /** * The source name of the reference */ char *src_refname; /** * The name of the reference to update on the server */ char *dst_refname; /** * The current target of the reference */ git_oid src; /** * The new target for the reference */ git_oid dst; } git_push_update; /** * @param updates an array containing the updates which will be sent * as commands to the destination. * @param len number of elements in `updates` * @param payload Payload provided by the caller */ typedef int (*git_push_negotiation)(const git_push_update **updates, size_t len, void *payload); /** * The callback settings structure * * Set the callbacks to be called by the remote when informing the user * about the progress of the network operations. */ struct git_remote_callbacks { unsigned int version; /** * Textual progress from the remote. Text send over the * progress side-band will be passed to this function (this is * the 'counting objects' output. */ git_transport_message_cb sideband_progress; /** * Completion is called when different parts of the download * process are done (currently unused). */ int (*completion)(git_remote_completion_type type, void *data); /** * This will be called if the remote host requires * authentication in order to connect to it. * * Returning GIT_PASSTHROUGH will make libgit2 behave as * though this field isn't set. */ git_cred_acquire_cb credentials; /** * If cert verification fails, this will be called to let the * user make the final decision of whether to allow the * connection to proceed. Returns 1 to allow the connection, 0 * to disallow it or a negative value to indicate an error. */ git_transport_certificate_check_cb certificate_check; /** * During the download of new data, this will be regularly * called with the current count of progress done by the * indexer. */ git_transfer_progress_cb transfer_progress; /** * Each time a reference is updated locally, this function * will be called with information about it. */ int (*update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data); /** * Function to call with progress information during pack * building. Be aware that this is called inline with pack * building operations, so performance may be affected. */ git_packbuilder_progress pack_progress; /** * Function to call with progress information during the * upload portion of a push. Be aware that this is called * inline with pack building operations, so performance may be * affected. */ git_push_transfer_progress push_transfer_progress; /** * Called for each updated reference on push. If `status` is * not `NULL`, the update was rejected by the remote server * and `status` contains the reason given. */ int (*push_update_reference)(const char *refname, const char *status, void *data); /** * Called once between the negotiation step and the upload. It * provides information about what updates will be performed. */ git_push_negotiation push_negotiation; /** * Create the transport to use for this operation. Leave NULL * to auto-detect. */ git_transport_cb transport; /** * This will be passed to each of the callbacks in this struct * as the last parameter. */ void *payload; }; #define GIT_REMOTE_CALLBACKS_VERSION 1 #define GIT_REMOTE_CALLBACKS_INIT {GIT_REMOTE_CALLBACKS_VERSION} /** * Initializes a `git_remote_callbacks` with default values. Equivalent to * creating an instance with GIT_REMOTE_CALLBACKS_INIT. * * @param opts the `git_remote_callbacks` struct to initialize * @param version Version of struct; pass `GIT_REMOTE_CALLBACKS_VERSION` * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_remote_init_callbacks( git_remote_callbacks *opts, unsigned int version); typedef enum { /** * Use the setting from the configuration */ GIT_FETCH_PRUNE_UNSPECIFIED, /** * Force pruning on */ GIT_FETCH_PRUNE, /** * Force pruning off */ GIT_FETCH_NO_PRUNE, } git_fetch_prune_t; /** * Automatic tag following option * * Lets us select the --tags option to use. */ typedef enum { /** * Use the setting from the configuration. */ GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED = 0, /** * Ask the server for tags pointing to objects we're already * downloading. */ GIT_REMOTE_DOWNLOAD_TAGS_AUTO, /** * Don't ask for any tags beyond the refspecs. */ GIT_REMOTE_DOWNLOAD_TAGS_NONE, /** * Ask for the all the tags. */ GIT_REMOTE_DOWNLOAD_TAGS_ALL, } git_remote_autotag_option_t; /** * Fetch options structure. * * Zero out for defaults. Initialize with `GIT_FETCH_OPTIONS_INIT` macro to * correctly set the `version` field. E.g. * * git_fetch_options opts = GIT_FETCH_OPTIONS_INIT; */ typedef struct { int version; /** * Callbacks to use for this fetch operation */ git_remote_callbacks callbacks; /** * Whether to perform a prune after the fetch */ git_fetch_prune_t prune; /** * Whether to write the results to FETCH_HEAD. Defaults to * on. Leave this default in order to behave like git. */ int update_fetchhead; /** * Determines how to behave regarding tags on the remote, such * as auto-downloading tags for objects we're downloading or * downloading all of them. * * The default is to auto-follow tags. */ git_remote_autotag_option_t download_tags; /** * Extra headers for this fetch operation */ git_strarray custom_headers; } git_fetch_options; #define GIT_FETCH_OPTIONS_VERSION 1 #define GIT_FETCH_OPTIONS_INIT { GIT_FETCH_OPTIONS_VERSION, GIT_REMOTE_CALLBACKS_INIT, GIT_FETCH_PRUNE_UNSPECIFIED, 1 } /** * Initializes a `git_fetch_options` with default values. Equivalent to * creating an instance with GIT_FETCH_OPTIONS_INIT. * * @param opts the `git_push_options` instance to initialize. * @param version the version of the struct; you should pass * `GIT_FETCH_OPTIONS_VERSION` here. * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_fetch_init_options( git_fetch_options *opts, unsigned int version); /** * Controls the behavior of a git_push object. */ typedef struct { unsigned int version; /** * If the transport being used to push to the remote requires the creation * of a pack file, this controls the number of worker threads used by * the packbuilder when creating that pack file to be sent to the remote. * * If set to 0, the packbuilder will auto-detect the number of threads * to create. The default value is 1. */ unsigned int pb_parallelism; /** * Callbacks to use for this push operation */ git_remote_callbacks callbacks; /** * Extra headers for this push operation */ git_strarray custom_headers; } git_push_options; #define GIT_PUSH_OPTIONS_VERSION 1 #define GIT_PUSH_OPTIONS_INIT { GIT_PUSH_OPTIONS_VERSION, 0, GIT_REMOTE_CALLBACKS_INIT } /** * Initializes a `git_push_options` with default values. Equivalent to * creating an instance with GIT_PUSH_OPTIONS_INIT. * * @param opts the `git_push_options` instance to initialize. * @param version the version of the struct; you should pass * `GIT_PUSH_OPTIONS_VERSION` here. * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_push_init_options( git_push_options *opts, unsigned int version); /** * Download and index the packfile * * Connect to the remote if it hasn't been done yet, negotiate with * the remote git which objects are missing, download and index the * packfile. * * The .idx file will be created and both it and the packfile with be * renamed to their final name. * * @param remote the remote * @param refspecs the refspecs to use for this negotiation and * download. Use NULL or an empty array to use the base refspecs * @param opts the options to use for this fetch * @return 0 or an error code */ GIT_EXTERN(int) git_remote_download(git_remote *remote, const git_strarray *refspecs, const git_fetch_options *opts); /** * Create a packfile and send it to the server * * Connect to the remote if it hasn't been done yet, negotiate with * the remote git which objects are missing, create a packfile with the missing objects and send it. * * @param remote the remote * @param refspecs the refspecs to use for this negotiation and * upload. Use NULL or an empty array to use the base refspecs * @param opts the options to use for this push * @return 0 or an error code */ GIT_EXTERN(int) git_remote_upload(git_remote *remote, const git_strarray *refspecs, const git_push_options *opts); /** * Update the tips to the new state * * @param remote the remote to update * @param reflog_message The message to insert into the reflogs. If * NULL and fetching, the default is "fetch ", where is * the name of the remote (or its url, for in-memory remotes). This * parameter is ignored when pushing. * @param callbacks pointer to the callback structure to use * @param update_fetchhead whether to write to FETCH_HEAD. Pass 1 to behave like git. * @param download_tags what the behaviour for downloading tags is for this fetch. This is * ignored for push. This must be the same value passed to `git_remote_download()`. * @return 0 or an error code */ GIT_EXTERN(int) git_remote_update_tips( git_remote *remote, const git_remote_callbacks *callbacks, int update_fetchhead, git_remote_autotag_option_t download_tags, const char *reflog_message); /** * Download new data and update tips * * Convenience function to connect to a remote, download the data, * disconnect and update the remote-tracking branches. * * @param remote the remote to fetch from * @param refspecs the refspecs to use for this fetch. Pass NULL or an * empty array to use the base refspecs. * @param opts options to use for this fetch * @param reflog_message The message to insert into the reflogs. If NULL, the * default is "fetch" * @return 0 or an error code */ GIT_EXTERN(int) git_remote_fetch( git_remote *remote, const git_strarray *refspecs, const git_fetch_options *opts, const char *reflog_message); /** * Prune tracking refs that are no longer present on remote * * @param remote the remote to prune * @param callbacks callbacks to use for this prune * @return 0 or an error code */ GIT_EXTERN(int) git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks); /** * Perform a push * * Peform all the steps from a push. * * @param remote the remote to push to * @param refspecs the refspecs to use for pushing. If none are * passed, the configured refspecs will be used * @param opts options to use for this push */ GIT_EXTERN(int) git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_push_options *opts); /** * Get the statistics structure that is filled in by the fetch operation. */ GIT_EXTERN(const git_transfer_progress *) git_remote_stats(git_remote *remote); /** * Retrieve the tag auto-follow setting * * @param remote the remote to query * @return the auto-follow setting */ GIT_EXTERN(git_remote_autotag_option_t) git_remote_autotag(const git_remote *remote); /** * Set the remote's tag following setting. * * The change will be made in the configuration. No loaded remotes * will be affected. * * @param repo the repository in which to make the change * @param remote the name of the remote * @param value the new value to take. */ GIT_EXTERN(int) git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_autotag_option_t value); /** * Retrieve the ref-prune setting * * @param remote the remote to query * @return the ref-prune setting */ GIT_EXTERN(int) git_remote_prune_refs(const git_remote *remote); /** * Give the remote a new name * * All remote-tracking branches and configuration settings * for the remote are updated. * * The new name will be checked for validity. * See `git_tag_create()` for rules about valid names. * * No loaded instances of a the remote with the old name will change * their name or their list of refspecs. * * @param problems non-default refspecs cannot be renamed and will be * stored here for further processing by the caller. Always free this * strarray on successful return. * @param repo the repository in which to rename * @param name the current name of the remote * @param new_name the new name the remote should bear * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code */ GIT_EXTERN(int) git_remote_rename( git_strarray *problems, git_repository *repo, const char *name, const char *new_name); /** * Ensure the remote name is well-formed. * * @param remote_name name to be checked. * @return 1 if the reference name is acceptable; 0 if it isn't */ GIT_EXTERN(int) git_remote_is_valid_name(const char *remote_name); /** * Delete an existing persisted remote. * * All remote-tracking branches and configuration settings * for the remote will be removed. * * @param repo the repository in which to act * @param name the name of the remove to delete * @return 0 on success, or an error code. */ GIT_EXTERN(int) git_remote_delete(git_repository *repo, const char *name); /** * Retrieve the name of the remote's default branch * * The default branch of a repository is the branch which HEAD points * to. If the remote does not support reporting this information * directly, it performs the guess as git does; that is, if there are * multiple branches which point to the same commit, the first one is * chosen. If the master branch is a candidate, it wins. * * This function must only be called after connecting. * * @param out the buffern in which to store the reference name * @param remote the remote * @return 0, GIT_ENOTFOUND if the remote does not have any references * or none of them point to HEAD's commit, or an error message. */ GIT_EXTERN(int) git_remote_default_branch(git_buf *out, git_remote *remote); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/filter.h0000664000175000017500000001507412555730137017050 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_filter_h__ #define INCLUDE_git_filter_h__ #include "common.h" #include "types.h" #include "oid.h" #include "buffer.h" /** * @file git2/filter.h * @brief Git filter APIs * * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Filters are applied in one of two directions: smudging - which is * exporting a file from the Git object database to the working directory, * and cleaning - which is importing a file from the working directory to * the Git object database. These values control which direction of * change is being applied. */ typedef enum { GIT_FILTER_TO_WORKTREE = 0, GIT_FILTER_SMUDGE = GIT_FILTER_TO_WORKTREE, GIT_FILTER_TO_ODB = 1, GIT_FILTER_CLEAN = GIT_FILTER_TO_ODB, } git_filter_mode_t; /** * Filter option flags. */ typedef enum { GIT_FILTER_DEFAULT = 0u, GIT_FILTER_ALLOW_UNSAFE = (1u << 0), } git_filter_flag_t; /** * A filter that can transform file data * * This represents a filter that can be used to transform or even replace * file data. Libgit2 includes one built in filter and it is possible to * write your own (see git2/sys/filter.h for information on that). * * The two builtin filters are: * * * "crlf" which uses the complex rules with the "text", "eol", and * "crlf" file attributes to decide how to convert between LF and CRLF * line endings * * "ident" which replaces "$Id$" in a blob with "$Id: $" upon * checkout and replaced "$Id: $" with "$Id$" on checkin. */ typedef struct git_filter git_filter; /** * List of filters to be applied * * This represents a list of filters to be applied to a file / blob. You * can build the list with one call, apply it with another, and dispose it * with a third. In typical usage, there are not many occasions where a * git_filter_list is needed directly since the library will generally * handle conversions for you, but it can be convenient to be able to * build and apply the list sometimes. */ typedef struct git_filter_list git_filter_list; /** * Load the filter list for a given path. * * This will return 0 (success) but set the output git_filter_list to NULL * if no filters are requested for the given file. * * @param filters Output newly created git_filter_list (or NULL) * @param repo Repository object that contains `path` * @param blob The blob to which the filter will be applied (if known) * @param path Relative path of the file to be filtered * @param mode Filtering direction (WT->ODB or ODB->WT) * @param flags Combination of `git_filter_flag_t` flags * @return 0 on success (which could still return NULL if no filters are * needed for the requested file), <0 on error */ GIT_EXTERN(int) git_filter_list_load( git_filter_list **filters, git_repository *repo, git_blob *blob, /* can be NULL */ const char *path, git_filter_mode_t mode, uint32_t flags); /** * Query the filter list to see if a given filter (by name) will run. * The built-in filters "crlf" and "ident" can be queried, otherwise this * is the name of the filter specified by the filter attribute. * * This will return 0 if the given filter is not in the list, or 1 if * the filter will be applied. * * @param filters A loaded git_filter_list (or NULL) * @param name The name of the filter to query * @return 1 if the filter is in the list, 0 otherwise */ GIT_EXTERN(int) git_filter_list_contains( git_filter_list *filters, const char *name); /** * Apply filter list to a data buffer. * * See `git2/buffer.h` for background on `git_buf` objects. * * If the `in` buffer holds data allocated by libgit2 (i.e. `in->asize` is * not zero), then it will be overwritten when applying the filters. If * not, then it will be left untouched. * * If there are no filters to apply (or `filters` is NULL), then the `out` * buffer will reference the `in` buffer data (with `asize` set to zero) * instead of allocating data. This keeps allocations to a minimum, but * it means you have to be careful about freeing the `in` data since `out` * may be pointing to it! * * @param out Buffer to store the result of the filtering * @param filters A loaded git_filter_list (or NULL) * @param in Buffer containing the data to filter * @return 0 on success, an error code otherwise */ GIT_EXTERN(int) git_filter_list_apply_to_data( git_buf *out, git_filter_list *filters, git_buf *in); /** * Apply a filter list to the contents of a file on disk * * @param out buffer into which to store the filtered file * @param filters the list of filters to apply * @param repo the repository in which to perform the filtering * @param path the path of the file to filter, a relative path will be * taken as relative to the workdir */ GIT_EXTERN(int) git_filter_list_apply_to_file( git_buf *out, git_filter_list *filters, git_repository *repo, const char *path); /** * Apply a filter list to the contents of a blob * * @param out buffer into which to store the filtered file * @param filters the list of filters to apply * @param blob the blob to filter */ GIT_EXTERN(int) git_filter_list_apply_to_blob( git_buf *out, git_filter_list *filters, git_blob *blob); /** * Apply a filter list to an arbitrary buffer as a stream * * @param filters the list of filters to apply * @param data the buffer to filter * @param target the stream into which the data will be written */ GIT_EXTERN(int) git_filter_list_stream_data( git_filter_list *filters, git_buf *data, git_writestream *target); /** * Apply a filter list to a file as a stream * * @param filters the list of filters to apply * @param repo the repository in which to perform the filtering * @param path the path of the file to filter, a relative path will be * taken as relative to the workdir * @param target the stream into which the data will be written */ GIT_EXTERN(int) git_filter_list_stream_file( git_filter_list *filters, git_repository *repo, const char *path, git_writestream *target); /** * Apply a filter list to a blob as a stream * * @param filters the list of filters to apply * @param blob the blob to filter * @param target the stream into which the data will be written */ GIT_EXTERN(int) git_filter_list_stream_blob( git_filter_list *filters, git_blob *blob, git_writestream *target); /** * Free a git_filter_list * * @param filters A git_filter_list created by `git_filter_list_load` */ GIT_EXTERN(void) git_filter_list_free(git_filter_list *filters); GIT_END_DECL /** @} */ #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/checkout.h0000664000175000017500000003220512555730137017363 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_checkout_h__ #define INCLUDE_git_checkout_h__ #include "common.h" #include "types.h" #include "diff.h" /** * @file git2/checkout.h * @brief Git checkout routines * @defgroup git_checkout Git checkout routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Checkout behavior flags * * In libgit2, checkout is used to update the working directory and index * to match a target tree. Unlike git checkout, it does not move the HEAD * commit for you - use `git_repository_set_head` or the like to do that. * * Checkout looks at (up to) four things: the "target" tree you want to * check out, the "baseline" tree of what was checked out previously, the * working directory for actual files, and the index for staged changes. * * You give checkout one of three strategies for update: * * - `GIT_CHECKOUT_NONE` is a dry-run strategy that checks for conflicts, * etc., but doesn't make any actual changes. * * - `GIT_CHECKOUT_FORCE` is at the opposite extreme, taking any action to * make the working directory match the target (including potentially * discarding modified files). * * - `GIT_CHECKOUT_SAFE` is between these two options, it will only make * modifications that will not lose changes. * * | target == baseline | target != baseline | * ---------------------|-----------------------|----------------------| * workdir == baseline | no action | create, update, or | * | | delete file | * ---------------------|-----------------------|----------------------| * workdir exists and | no action | conflict (notify | * is != baseline | notify dirty MODIFIED | and cancel checkout) | * ---------------------|-----------------------|----------------------| * workdir missing, | notify dirty DELETED | create file | * baseline present | | | * ---------------------|-----------------------|----------------------| * * To emulate `git checkout`, use `GIT_CHECKOUT_SAFE` with a checkout * notification callback (see below) that displays information about dirty * files. The default behavior will cancel checkout on conflicts. * * To emulate `git checkout-index`, use `GIT_CHECKOUT_SAFE` with a * notification callback that cancels the operation if a dirty-but-existing * file is found in the working directory. This core git command isn't * quite "force" but is sensitive about some types of changes. * * To emulate `git checkout -f`, use `GIT_CHECKOUT_FORCE`. * * * There are some additional flags to modified the behavior of checkout: * * - GIT_CHECKOUT_ALLOW_CONFLICTS makes SAFE mode apply safe file updates * even if there are conflicts (instead of cancelling the checkout). * * - GIT_CHECKOUT_REMOVE_UNTRACKED means remove untracked files (i.e. not * in target, baseline, or index, and not ignored) from the working dir. * * - GIT_CHECKOUT_REMOVE_IGNORED means remove ignored files (that are also * untracked) from the working directory as well. * * - GIT_CHECKOUT_UPDATE_ONLY means to only update the content of files that * already exist. Files will not be created nor deleted. This just skips * applying adds, deletes, and typechanges. * * - GIT_CHECKOUT_DONT_UPDATE_INDEX prevents checkout from writing the * updated files' information to the index. * * - Normally, checkout will reload the index and git attributes from disk * before any operations. GIT_CHECKOUT_NO_REFRESH prevents this reload. * * - Unmerged index entries are conflicts. GIT_CHECKOUT_SKIP_UNMERGED skips * files with unmerged index entries instead. GIT_CHECKOUT_USE_OURS and * GIT_CHECKOUT_USE_THEIRS to proceed with the checkout using either the * stage 2 ("ours") or stage 3 ("theirs") version of files in the index. * * - GIT_CHECKOUT_DONT_OVERWRITE_IGNORED prevents ignored files from being * overwritten. Normally, files that are ignored in the working directory * are not considered "precious" and may be overwritten if the checkout * target contains that file. * * - GIT_CHECKOUT_DONT_REMOVE_EXISTING prevents checkout from removing * files or folders that fold to the same name on case insensitive * filesystems. This can cause files to retain their existing names * and write through existing symbolic links. */ typedef enum { GIT_CHECKOUT_NONE = 0, /**< default is a dry run, no actual updates */ /** Allow safe updates that cannot overwrite uncommitted data */ GIT_CHECKOUT_SAFE = (1u << 0), /** Allow all updates to force working directory to look like index */ GIT_CHECKOUT_FORCE = (1u << 1), /** Allow checkout to recreate missing files */ GIT_CHECKOUT_RECREATE_MISSING = (1u << 2), /** Allow checkout to make safe updates even if conflicts are found */ GIT_CHECKOUT_ALLOW_CONFLICTS = (1u << 4), /** Remove untracked files not in index (that are not ignored) */ GIT_CHECKOUT_REMOVE_UNTRACKED = (1u << 5), /** Remove ignored files not in index */ GIT_CHECKOUT_REMOVE_IGNORED = (1u << 6), /** Only update existing files, don't create new ones */ GIT_CHECKOUT_UPDATE_ONLY = (1u << 7), /** * Normally checkout updates index entries as it goes; this stops that. * Implies `GIT_CHECKOUT_DONT_WRITE_INDEX`. */ GIT_CHECKOUT_DONT_UPDATE_INDEX = (1u << 8), /** Don't refresh index/config/etc before doing checkout */ GIT_CHECKOUT_NO_REFRESH = (1u << 9), /** Allow checkout to skip unmerged files */ GIT_CHECKOUT_SKIP_UNMERGED = (1u << 10), /** For unmerged files, checkout stage 2 from index */ GIT_CHECKOUT_USE_OURS = (1u << 11), /** For unmerged files, checkout stage 3 from index */ GIT_CHECKOUT_USE_THEIRS = (1u << 12), /** Treat pathspec as simple list of exact match file paths */ GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH = (1u << 13), /** Ignore directories in use, they will be left empty */ GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES = (1u << 18), /** Don't overwrite ignored files that exist in the checkout target */ GIT_CHECKOUT_DONT_OVERWRITE_IGNORED = (1u << 19), /** Write normal merge files for conflicts */ GIT_CHECKOUT_CONFLICT_STYLE_MERGE = (1u << 20), /** Include common ancestor data in diff3 format files for conflicts */ GIT_CHECKOUT_CONFLICT_STYLE_DIFF3 = (1u << 21), /** Don't overwrite existing files or folders */ GIT_CHECKOUT_DONT_REMOVE_EXISTING = (1u << 22), /** Normally checkout writes the index upon completion; this prevents that. */ GIT_CHECKOUT_DONT_WRITE_INDEX = (1u << 23), /** * THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED */ /** Recursively checkout submodules with same options (NOT IMPLEMENTED) */ GIT_CHECKOUT_UPDATE_SUBMODULES = (1u << 16), /** Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED) */ GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = (1u << 17), } git_checkout_strategy_t; /** * Checkout notification flags * * Checkout will invoke an options notification callback (`notify_cb`) for * certain cases - you pick which ones via `notify_flags`: * * - GIT_CHECKOUT_NOTIFY_CONFLICT invokes checkout on conflicting paths. * * - GIT_CHECKOUT_NOTIFY_DIRTY notifies about "dirty" files, i.e. those that * do not need an update but no longer match the baseline. Core git * displays these files when checkout runs, but won't stop the checkout. * * - GIT_CHECKOUT_NOTIFY_UPDATED sends notification for any file changed. * * - GIT_CHECKOUT_NOTIFY_UNTRACKED notifies about untracked files. * * - GIT_CHECKOUT_NOTIFY_IGNORED notifies about ignored files. * * Returning a non-zero value from this callback will cancel the checkout. * The non-zero return value will be propagated back and returned by the * git_checkout_... call. * * Notification callbacks are made prior to modifying any files on disk, * so canceling on any notification will still happen prior to any files * being modified. */ typedef enum { GIT_CHECKOUT_NOTIFY_NONE = 0, GIT_CHECKOUT_NOTIFY_CONFLICT = (1u << 0), GIT_CHECKOUT_NOTIFY_DIRTY = (1u << 1), GIT_CHECKOUT_NOTIFY_UPDATED = (1u << 2), GIT_CHECKOUT_NOTIFY_UNTRACKED = (1u << 3), GIT_CHECKOUT_NOTIFY_IGNORED = (1u << 4), GIT_CHECKOUT_NOTIFY_ALL = 0x0FFFFu } git_checkout_notify_t; typedef struct { size_t mkdir_calls; size_t stat_calls; size_t chmod_calls; } git_checkout_perfdata; /** Checkout notification callback function */ typedef int (*git_checkout_notify_cb)( git_checkout_notify_t why, const char *path, const git_diff_file *baseline, const git_diff_file *target, const git_diff_file *workdir, void *payload); /** Checkout progress notification function */ typedef void (*git_checkout_progress_cb)( const char *path, size_t completed_steps, size_t total_steps, void *payload); /** Checkout perfdata notification function */ typedef void (*git_checkout_perfdata_cb)( const git_checkout_perfdata *perfdata, void *payload); /** * Checkout options structure * * Zero out for defaults. Initialize with `GIT_CHECKOUT_OPTIONS_INIT` macro to * correctly set the `version` field. E.g. * * git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; */ typedef struct git_checkout_options { unsigned int version; unsigned int checkout_strategy; /**< default will be a dry run */ int disable_filters; /**< don't apply filters like CRLF conversion */ unsigned int dir_mode; /**< default is 0755 */ unsigned int file_mode; /**< default is 0644 or 0755 as dictated by blob */ int file_open_flags; /**< default is O_CREAT | O_TRUNC | O_WRONLY */ unsigned int notify_flags; /**< see `git_checkout_notify_t` above */ git_checkout_notify_cb notify_cb; void *notify_payload; /** Optional callback to notify the consumer of checkout progress. */ git_checkout_progress_cb progress_cb; void *progress_payload; /** When not zeroed out, array of fnmatch patterns specifying which * paths should be taken into account, otherwise all files. Use * GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH to treat as simple list. */ git_strarray paths; /** The expected content of the working directory; defaults to HEAD. * If the working directory does not match this baseline information, * that will produce a checkout conflict. */ git_tree *baseline; /** Like `baseline` above, though expressed as an index. This * option overrides `baseline`. */ git_index *baseline_index; /**< expected content of workdir, expressed as an index. */ const char *target_directory; /**< alternative checkout path to workdir */ const char *ancestor_label; /**< the name of the common ancestor side of conflicts */ const char *our_label; /**< the name of the "our" side of conflicts */ const char *their_label; /**< the name of the "their" side of conflicts */ /** Optional callback to notify the consumer of performance data. */ git_checkout_perfdata_cb perfdata_cb; void *perfdata_payload; } git_checkout_options; #define GIT_CHECKOUT_OPTIONS_VERSION 1 #define GIT_CHECKOUT_OPTIONS_INIT {GIT_CHECKOUT_OPTIONS_VERSION} /** * Initializes a `git_checkout_options` with default values. Equivalent to * creating an instance with GIT_CHECKOUT_OPTIONS_INIT. * * @param opts the `git_checkout_options` struct to initialize. * @param version Version of struct; pass `GIT_CHECKOUT_OPTIONS_VERSION` * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_checkout_init_options( git_checkout_options *opts, unsigned int version); /** * Updates files in the index and the working tree to match the content of * the commit pointed at by HEAD. * * @param repo repository to check out (must be non-bare) * @param opts specifies checkout options (may be NULL) * @return 0 on success, GIT_EUNBORNBRANCH if HEAD points to a non * existing branch, non-zero value returned by `notify_cb`, or * other error code < 0 (use giterr_last for error details) */ GIT_EXTERN(int) git_checkout_head( git_repository *repo, const git_checkout_options *opts); /** * Updates files in the working tree to match the content of the index. * * @param repo repository into which to check out (must be non-bare) * @param index index to be checked out (or NULL to use repository index) * @param opts specifies checkout options (may be NULL) * @return 0 on success, non-zero return value from `notify_cb`, or error * code < 0 (use giterr_last for error details) */ GIT_EXTERN(int) git_checkout_index( git_repository *repo, git_index *index, const git_checkout_options *opts); /** * Updates files in the index and working tree to match the content of the * tree pointed at by the treeish. * * @param repo repository to check out (must be non-bare) * @param treeish a commit, tag or tree which content will be used to update * the working directory (or NULL to use HEAD) * @param opts specifies checkout options (may be NULL) * @return 0 on success, non-zero return value from `notify_cb`, or error * code < 0 (use giterr_last for error details) */ GIT_EXTERN(int) git_checkout_tree( git_repository *repo, const git_object *treeish, const git_checkout_options *opts); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/annotated_commit.h0000664000175000017500000000707212510265101021070 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_annotated_commit_h__ #define INCLUDE_git_annotated_commit_h__ #include "common.h" #include "repository.h" #include "types.h" /** * @file git2/annotated_commit.h * @brief Git annotated commit routines * @defgroup git_annotated_commit Git annotated commit routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Creates a `git_annotated_commit` from the given reference. * The resulting git_annotated_commit must be freed with * `git_annotated_commit_free`. * * @param out pointer to store the git_annotated_commit result in * @param repo repository that contains the given reference * @param ref reference to use to lookup the git_annotated_commit * @return 0 on success or error code */ GIT_EXTERN(int) git_annotated_commit_from_ref( git_annotated_commit **out, git_repository *repo, const git_reference *ref); /** * Creates a `git_annotated_commit` from the given fetch head data. * The resulting git_annotated_commit must be freed with * `git_annotated_commit_free`. * * @param out pointer to store the git_annotated_commit result in * @param repo repository that contains the given commit * @param branch_name name of the (remote) branch * @param remote_url url of the remote * @param id the commit object id of the remote branch * @return 0 on success or error code */ GIT_EXTERN(int) git_annotated_commit_from_fetchhead( git_annotated_commit **out, git_repository *repo, const char *branch_name, const char *remote_url, const git_oid *id); /** * Creates a `git_annotated_commit` from the given commit id. * The resulting git_annotated_commit must be freed with * `git_annotated_commit_free`. * * An annotated commit contains information about how it was * looked up, which may be useful for functions like merge or * rebase to provide context to the operation. For example, * conflict files will include the name of the source or target * branches being merged. It is therefore preferable to use the * most specific function (eg `git_annotated_commit_from_ref`) * instead of this one when that data is known. * * @param out pointer to store the git_annotated_commit result in * @param repo repository that contains the given commit * @param id the commit object id to lookup * @return 0 on success or error code */ GIT_EXTERN(int) git_annotated_commit_lookup( git_annotated_commit **out, git_repository *repo, const git_oid *id); /** * Creates a `git_annotated_comit` from a revision string. * * See `man gitrevisions`, or * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for * information on the syntax accepted. * * @param out pointer to store the git_annotated_commit result in * @param repo repository that contains the given commit * @param revspec the extended sha syntax string to use to lookup the commit * @return 0 on success or error code */ GIT_EXTERN(int) git_annotated_commit_from_revspec( git_annotated_commit **out, git_repository *repo, const char *revspec); /** * Gets the commit ID that the given `git_annotated_commit` refers to. * * @param commit the given annotated commit * @return commit id */ GIT_EXTERN(const git_oid *) git_annotated_commit_id( const git_annotated_commit *commit); /** * Frees a `git_annotated_commit`. * * @param commit annotated commit to free */ GIT_EXTERN(void) git_annotated_commit_free( git_annotated_commit *commit); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/trace.h0000664000175000017500000000335512426525445016661 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_trace_h__ #define INCLUDE_git_trace_h__ #include "common.h" #include "types.h" /** * @file git2/trace.h * @brief Git tracing configuration routines * @defgroup git_trace Git tracing configuration routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Available tracing levels. When tracing is set to a particular level, * callers will be provided tracing at the given level and all lower levels. */ typedef enum { /** No tracing will be performed. */ GIT_TRACE_NONE = 0, /** Severe errors that may impact the program's execution */ GIT_TRACE_FATAL = 1, /** Errors that do not impact the program's execution */ GIT_TRACE_ERROR = 2, /** Warnings that suggest abnormal data */ GIT_TRACE_WARN = 3, /** Informational messages about program execution */ GIT_TRACE_INFO = 4, /** Detailed data that allows for debugging */ GIT_TRACE_DEBUG = 5, /** Exceptionally detailed debugging data */ GIT_TRACE_TRACE = 6 } git_trace_level_t; /** * An instance for a tracing function */ typedef void (*git_trace_callback)(git_trace_level_t level, const char *msg); /** * Sets the system tracing configuration to the specified level with the * specified callback. When system events occur at a level equal to, or * lower than, the given level they will be reported to the given callback. * * @param level Level to set tracing to * @param cb Function to call with trace data * @return 0 or an error code */ GIT_EXTERN(int) git_trace_set(git_trace_level_t level, git_trace_callback cb); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/oid.h0000664000175000017500000002021612510265101016311 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_oid_h__ #define INCLUDE_git_oid_h__ #include "common.h" #include "types.h" /** * @file git2/oid.h * @brief Git object id routines * @defgroup git_oid Git object id routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** Size (in bytes) of a raw/binary oid */ #define GIT_OID_RAWSZ 20 /** Size (in bytes) of a hex formatted oid */ #define GIT_OID_HEXSZ (GIT_OID_RAWSZ * 2) /** Minimum length (in number of hex characters, * i.e. packets of 4 bits) of an oid prefix */ #define GIT_OID_MINPREFIXLEN 4 /** Unique identity of any object (commit, tree, blob, tag). */ typedef struct git_oid { /** raw binary formatted id */ unsigned char id[GIT_OID_RAWSZ]; } git_oid; /** * Parse a hex formatted object id into a git_oid. * * @param out oid structure the result is written into. * @param str input hex string; must be pointing at the start of * the hex sequence and have at least the number of bytes * needed for an oid encoded in hex (40 bytes). * @return 0 or an error code */ GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str); /** * Parse a hex formatted null-terminated string into a git_oid. * * @param out oid structure the result is written into. * @param str input hex string; must be at least 4 characters * long and null-terminated. * @return 0 or an error code */ GIT_EXTERN(int) git_oid_fromstrp(git_oid *out, const char *str); /** * Parse N characters of a hex formatted object id into a git_oid * * If N is odd, N-1 characters will be parsed instead. * The remaining space in the git_oid will be set to zero. * * @param out oid structure the result is written into. * @param str input hex string of at least size `length` * @param length length of the input string * @return 0 or an error code */ GIT_EXTERN(int) git_oid_fromstrn(git_oid *out, const char *str, size_t length); /** * Copy an already raw oid into a git_oid structure. * * @param out oid structure the result is written into. * @param raw the raw input bytes to be copied. */ GIT_EXTERN(void) git_oid_fromraw(git_oid *out, const unsigned char *raw); /** * Format a git_oid into a hex string. * * @param out output hex string; must be pointing at the start of * the hex sequence and have at least the number of bytes * needed for an oid encoded in hex (40 bytes). Only the * oid digits are written; a '\\0' terminator must be added * by the caller if it is required. * @param id oid structure to format. */ GIT_EXTERN(void) git_oid_fmt(char *out, const git_oid *id); /** * Format a git_oid into a partial hex string. * * @param out output hex string; you say how many bytes to write. * If the number of bytes is > GIT_OID_HEXSZ, extra bytes * will be zeroed; if not, a '\0' terminator is NOT added. * @param n number of characters to write into out string * @param id oid structure to format. */ GIT_EXTERN(void) git_oid_nfmt(char *out, size_t n, const git_oid *id); /** * Format a git_oid into a loose-object path string. * * The resulting string is "aa/...", where "aa" is the first two * hex digits of the oid and "..." is the remaining 38 digits. * * @param out output hex string; must be pointing at the start of * the hex sequence and have at least the number of bytes * needed for an oid encoded in hex (41 bytes). Only the * oid digits are written; a '\\0' terminator must be added * by the caller if it is required. * @param id oid structure to format. */ GIT_EXTERN(void) git_oid_pathfmt(char *out, const git_oid *id); /** * Format a git_oid into a statically allocated c-string. * * The c-string is owned by the library and should not be freed * by the user. If libgit2 is built with thread support, the string * will be stored in TLS (i.e. one buffer per thread) to allow for * concurrent calls of the function. * * @param oid The oid structure to format * @return the c-string */ GIT_EXTERN(char *) git_oid_tostr_s(const git_oid *oid); /** * Format a git_oid into a buffer as a hex format c-string. * * If the buffer is smaller than GIT_OID_HEXSZ+1, then the resulting * oid c-string will be truncated to n-1 characters (but will still be * NUL-byte terminated). * * If there are any input parameter errors (out == NULL, n == 0, oid == * NULL), then a pointer to an empty string is returned, so that the * return value can always be printed. * * @param out the buffer into which the oid string is output. * @param n the size of the out buffer. * @param id the oid structure to format. * @return the out buffer pointer, assuming no input parameter * errors, otherwise a pointer to an empty string. */ GIT_EXTERN(char *) git_oid_tostr(char *out, size_t n, const git_oid *id); /** * Copy an oid from one structure to another. * * @param out oid structure the result is written into. * @param src oid structure to copy from. */ GIT_EXTERN(void) git_oid_cpy(git_oid *out, const git_oid *src); /** * Compare two oid structures. * * @param a first oid structure. * @param b second oid structure. * @return <0, 0, >0 if a < b, a == b, a > b. */ GIT_EXTERN(int) git_oid_cmp(const git_oid *a, const git_oid *b); /** * Compare two oid structures for equality * * @param a first oid structure. * @param b second oid structure. * @return true if equal, false otherwise */ GIT_EXTERN(int) git_oid_equal(const git_oid *a, const git_oid *b); /** * Compare the first 'len' hexadecimal characters (packets of 4 bits) * of two oid structures. * * @param a first oid structure. * @param b second oid structure. * @param len the number of hex chars to compare * @return 0 in case of a match */ GIT_EXTERN(int) git_oid_ncmp(const git_oid *a, const git_oid *b, size_t len); /** * Check if an oid equals an hex formatted object id. * * @param id oid structure. * @param str input hex string of an object id. * @return 0 in case of a match, -1 otherwise. */ GIT_EXTERN(int) git_oid_streq(const git_oid *id, const char *str); /** * Compare an oid to an hex formatted object id. * * @param id oid structure. * @param str input hex string of an object id. * @return -1 if str is not valid, <0 if id sorts before str, * 0 if id matches str, >0 if id sorts after str. */ GIT_EXTERN(int) git_oid_strcmp(const git_oid *id, const char *str); /** * Check is an oid is all zeros. * * @return 1 if all zeros, 0 otherwise. */ GIT_EXTERN(int) git_oid_iszero(const git_oid *id); /** * OID Shortener object */ typedef struct git_oid_shorten git_oid_shorten; /** * Create a new OID shortener. * * The OID shortener is used to process a list of OIDs * in text form and return the shortest length that would * uniquely identify all of them. * * E.g. look at the result of `git log --abbrev`. * * @param min_length The minimal length for all identifiers, * which will be used even if shorter OIDs would still * be unique. * @return a `git_oid_shorten` instance, NULL if OOM */ GIT_EXTERN(git_oid_shorten *) git_oid_shorten_new(size_t min_length); /** * Add a new OID to set of shortened OIDs and calculate * the minimal length to uniquely identify all the OIDs in * the set. * * The OID is expected to be a 40-char hexadecimal string. * The OID is owned by the user and will not be modified * or freed. * * For performance reasons, there is a hard-limit of how many * OIDs can be added to a single set (around ~32000, assuming * a mostly randomized distribution), which should be enough * for any kind of program, and keeps the algorithm fast and * memory-efficient. * * Attempting to add more than those OIDs will result in a * GITERR_INVALID error * * @param os a `git_oid_shorten` instance * @param text_id an OID in text form * @return the minimal length to uniquely identify all OIDs * added so far to the set; or an error code (<0) if an * error occurs. */ GIT_EXTERN(int) git_oid_shorten_add(git_oid_shorten *os, const char *text_id); /** * Free an OID shortener instance * * @param os a `git_oid_shorten` instance */ GIT_EXTERN(void) git_oid_shorten_free(git_oid_shorten *os); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/rebase.h0000664000175000017500000002236712555730137017027 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_rebase_h__ #define INCLUDE_git_rebase_h__ #include "common.h" #include "types.h" #include "oid.h" #include "annotated_commit.h" /** * @file git2/rebase.h * @brief Git rebase routines * @defgroup git_rebase Git merge routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Rebase options * * Use to tell the rebase machinery how to operate. */ typedef struct { unsigned int version; /** * Used by `git_rebase_init`, this will instruct other clients working * on this rebase that you want a quiet rebase experience, which they * may choose to provide in an application-specific manner. This has no * effect upon libgit2 directly, but is provided for interoperability * between Git tools. */ int quiet; /** * Used by `git_rebase_finish`, this is the name of the notes reference * used to rewrite notes for rebased commits when finishing the rebase; * if NULL, the contents of the coniguration option `notes.rewriteRef` * is examined, unless the configuration option `notes.rewrite.rebase` * is set to false. If `notes.rewriteRef` is also NULL, notes will * not be rewritten. */ const char *rewrite_notes_ref; /** * Options to control how files are written during `git_rebase_init`, * `git_checkout_next` and `git_checkout_abort`. Note that a minimum * strategy of `GIT_CHECKOUT_SAFE` is defaulted in `init` and `next`, * and a minimum strategy of `GIT_CHECKOUT_FORCE` is defaulted in * `abort` to match git semantics. */ git_checkout_options checkout_options; } git_rebase_options; /** * Type of rebase operation in-progress after calling `git_rebase_next`. */ typedef enum { /** * The given commit is to be cherry-picked. The client should commit * the changes and continue if there are no conflicts. */ GIT_REBASE_OPERATION_PICK = 0, /** * The given commit is to be cherry-picked, but the client should prompt * the user to provide an updated commit message. */ GIT_REBASE_OPERATION_REWORD, /** * The given commit is to be cherry-picked, but the client should stop * to allow the user to edit the changes before committing them. */ GIT_REBASE_OPERATION_EDIT, /** * The given commit is to be squashed into the previous commit. The * commit message will be merged with the previous message. */ GIT_REBASE_OPERATION_SQUASH, /** * The given commit is to be squashed into the previous commit. The * commit message from this commit will be discarded. */ GIT_REBASE_OPERATION_FIXUP, /** * No commit will be cherry-picked. The client should run the given * command and (if successful) continue. */ GIT_REBASE_OPERATION_EXEC, } git_rebase_operation_t; #define GIT_REBASE_OPTIONS_VERSION 1 #define GIT_REBASE_OPTIONS_INIT \ {GIT_REBASE_OPTIONS_VERSION, 0, NULL, GIT_CHECKOUT_OPTIONS_INIT} /** Indicates that a rebase operation is not (yet) in progress. */ #define GIT_REBASE_NO_OPERATION SIZE_MAX /** * A rebase operation * * Describes a single instruction/operation to be performed during the * rebase. */ typedef struct { /** The type of rebase operation. */ git_rebase_operation_t type; /** * The commit ID being cherry-picked. This will be populated for * all operations except those of type `GIT_REBASE_OPERATION_EXEC`. */ const git_oid id; /** * The executable the user has requested be run. This will only * be populated for operations of type `GIT_REBASE_OPERATION_EXEC`. */ const char *exec; } git_rebase_operation; /** * Initializes a `git_rebase_options` with default values. Equivalent to * creating an instance with GIT_REBASE_OPTIONS_INIT. * * @param opts the `git_rebase_options` instance to initialize. * @param version the version of the struct; you should pass * `GIT_REBASE_OPTIONS_VERSION` here. * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_rebase_init_options( git_rebase_options *opts, unsigned int version); /** * Initializes a rebase operation to rebase the changes in `branch` * relative to `upstream` onto another branch. To begin the rebase * process, call `git_rebase_next`. When you have finished with this * object, call `git_rebase_free`. * * @param out Pointer to store the rebase object * @param repo The repository to perform the rebase * @param branch The terminal commit to rebase, or NULL to rebase the * current branch * @param upstream The commit to begin rebasing from, or NULL to rebase all * reachable commits * @param onto The branch to rebase onto, or NULL to rebase onto the given * upstream * @param opts Options to specify how rebase is performed, or NULL * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_rebase_init( git_rebase **out, git_repository *repo, const git_annotated_commit *branch, const git_annotated_commit *upstream, const git_annotated_commit *onto, const git_rebase_options *opts); /** * Opens an existing rebase that was previously started by either an * invocation of `git_rebase_init` or by another client. * * @param out Pointer to store the rebase object * @param repo The repository that has a rebase in-progress * @param opts Options to specify how rebase is performed * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_rebase_open( git_rebase **out, git_repository *repo, const git_rebase_options *opts); /** * Gets the count of rebase operations that are to be applied. * * @param rebase The in-progress rebase * @return The number of rebase operations in total */ GIT_EXTERN(size_t) git_rebase_operation_entrycount(git_rebase *rebase); /** * Gets the index of the rebase operation that is currently being applied. * If the first operation has not yet been applied (because you have * called `init` but not yet `next`) then this returns * `GIT_REBASE_NO_OPERATION`. * * @param rebase The in-progress rebase * @return The index of the rebase operation currently being applied. */ GIT_EXTERN(size_t) git_rebase_operation_current(git_rebase *rebase); /** * Gets the rebase operation specified by the given index. * * @param rebase The in-progress rebase * @param idx The index of the rebase operation to retrieve * @return The rebase operation or NULL if `idx` was out of bounds */ GIT_EXTERN(git_rebase_operation *) git_rebase_operation_byindex( git_rebase *rebase, size_t idx); /** * Performs the next rebase operation and returns the information about it. * If the operation is one that applies a patch (which is any operation except * GIT_REBASE_OPERATION_EXEC) then the patch will be applied and the index and * working directory will be updated with the changes. If there are conflicts, * you will need to address those before committing the changes. * * @param operation Pointer to store the rebase operation that is to be performed next * @param rebase The rebase in progress * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_rebase_next( git_rebase_operation **operation, git_rebase *rebase); /** * Commits the current patch. You must have resolved any conflicts that * were introduced during the patch application from the `git_rebase_next` * invocation. * * @param id Pointer in which to store the OID of the newly created commit * @param rebase The rebase that is in-progress * @param author The author of the updated commit, or NULL to keep the * author from the original commit * @param committer The committer of the rebase * @param message_encoding The encoding for the message in the commit, * represented with a standard encoding name. If message is NULL, * this should also be NULL, and the encoding from the original * commit will be maintained. If message is specified, this may be * NULL to indicate that "UTF-8" is to be used. * @param message The message for this commit, or NULL to use the message * from the original commit. * @return Zero on success, GIT_EUNMERGED if there are unmerged changes in * the index, GIT_EAPPLIED if the current commit has already * been applied to the upstream and there is nothing to commit, * -1 on failure. */ GIT_EXTERN(int) git_rebase_commit( git_oid *id, git_rebase *rebase, const git_signature *author, const git_signature *committer, const char *message_encoding, const char *message); /** * Aborts a rebase that is currently in progress, resetting the repository * and working directory to their state before rebase began. * * @param rebase The rebase that is in-progress * @return Zero on success; GIT_ENOTFOUND if a rebase is not in progress, * -1 on other errors. */ GIT_EXTERN(int) git_rebase_abort(git_rebase *rebase); /** * Finishes a rebase that is currently in progress once all patches have * been applied. * * @param rebase The rebase that is in-progress * @param signature The identity that is finishing the rebase (optional) * @return Zero on success; -1 on error */ GIT_EXTERN(int) git_rebase_finish( git_rebase *rebase, const git_signature *signature); /** * Frees the `git_rebase` object. * * @param rebase The rebase object */ GIT_EXTERN(void) git_rebase_free(git_rebase *rebase); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/ignore.h0000664000175000017500000000505312426525445017043 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_ignore_h__ #define INCLUDE_git_ignore_h__ #include "common.h" #include "types.h" GIT_BEGIN_DECL /** * Add ignore rules for a repository. * * Excludesfile rules (i.e. .gitignore rules) are generally read from * .gitignore files in the repository tree or from a shared system file * only if a "core.excludesfile" config value is set. The library also * keeps a set of per-repository internal ignores that can be configured * in-memory and will not persist. This function allows you to add to * that internal rules list. * * Example usage: * * error = git_ignore_add_rule(myrepo, "*.c\ndir/\nFile with space\n"); * * This would add three rules to the ignores. * * @param repo The repository to add ignore rules to. * @param rules Text of rules, a la the contents of a .gitignore file. * It is okay to have multiple rules in the text; if so, * each rule should be terminated with a newline. * @return 0 on success */ GIT_EXTERN(int) git_ignore_add_rule( git_repository *repo, const char *rules); /** * Clear ignore rules that were explicitly added. * * Resets to the default internal ignore rules. This will not turn off * rules in .gitignore files that actually exist in the filesystem. * * The default internal ignores ignore ".", ".." and ".git" entries. * * @param repo The repository to remove ignore rules from. * @return 0 on success */ GIT_EXTERN(int) git_ignore_clear_internal_rules( git_repository *repo); /** * Test if the ignore rules apply to a given path. * * This function checks the ignore rules to see if they would apply to the * given file. This indicates if the file would be ignored regardless of * whether the file is already in the index or committed to the repository. * * One way to think of this is if you were to do "git add ." on the * directory containing the file, would it be added or not? * * @param ignored boolean returning 0 if the file is not ignored, 1 if it is * @param repo a repository object * @param path the file to check ignores for, relative to the repo's workdir. * @return 0 if ignore rules could be processed for the file (regardless * of whether it exists or not), or an error < 0 if they could not. */ GIT_EXTERN(int) git_ignore_path_is_ignored( int *ignored, git_repository *repo, const char *path); GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/version.h0000664000175000017500000000072312555730137017243 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_version_h__ #define INCLUDE_git_version_h__ #define LIBGIT2_VERSION "0.23.0" #define LIBGIT2_VER_MAJOR 0 #define LIBGIT2_VER_MINOR 23 #define LIBGIT2_VER_REVISION 0 #define LIBGIT2_VER_PATCH 0 #define LIBGIT2_SOVERSION 23 #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/refspec.h0000664000175000017500000000534412426525445017212 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_refspec_h__ #define INCLUDE_git_refspec_h__ #include "common.h" #include "types.h" #include "net.h" #include "buffer.h" /** * @file git2/refspec.h * @brief Git refspec attributes * @defgroup git_refspec Git refspec attributes * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Get the source specifier * * @param refspec the refspec * @return the refspec's source specifier */ GIT_EXTERN(const char *) git_refspec_src(const git_refspec *refspec); /** * Get the destination specifier * * @param refspec the refspec * @return the refspec's destination specifier */ GIT_EXTERN(const char *) git_refspec_dst(const git_refspec *refspec); /** * Get the refspec's string * * @param refspec the refspec * @returns the refspec's original string */ GIT_EXTERN(const char *) git_refspec_string(const git_refspec *refspec); /** * Get the force update setting * * @param refspec the refspec * @return 1 if force update has been set, 0 otherwise */ GIT_EXTERN(int) git_refspec_force(const git_refspec *refspec); /** * Get the refspec's direction. * * @param spec refspec * @return GIT_DIRECTION_FETCH or GIT_DIRECTION_PUSH */ GIT_EXTERN(git_direction) git_refspec_direction(const git_refspec *spec); /** * Check if a refspec's source descriptor matches a reference * * @param refspec the refspec * @param refname the name of the reference to check * @return 1 if the refspec matches, 0 otherwise */ GIT_EXTERN(int) git_refspec_src_matches(const git_refspec *refspec, const char *refname); /** * Check if a refspec's destination descriptor matches a reference * * @param refspec the refspec * @param refname the name of the reference to check * @return 1 if the refspec matches, 0 otherwise */ GIT_EXTERN(int) git_refspec_dst_matches(const git_refspec *refspec, const char *refname); /** * Transform a reference to its target following the refspec's rules * * @param out where to store the target name * @param spec the refspec * @param name the name of the reference to transform * @return 0, GIT_EBUFS or another error */ GIT_EXTERN(int) git_refspec_transform(git_buf *out, const git_refspec *spec, const char *name); /** * Transform a target reference to its source reference following the refspec's rules * * @param out where to store the source reference name * @param spec the refspec * @param name the name of the reference to transform * @return 0, GIT_EBUFS or another error */ GIT_EXTERN(int) git_refspec_rtransform(git_buf *out, const git_refspec *spec, const char *name); GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/types.h0000664000175000017500000003352212555730137016725 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_types_h__ #define INCLUDE_git_types_h__ #include "common.h" /** * @file git2/types.h * @brief libgit2 base & compatibility types * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Cross-platform compatibility types for off_t / time_t * * NOTE: This needs to be in a public header so that both the library * implementation and client applications both agree on the same types. * Otherwise we get undefined behavior. * * Use the "best" types that each platform provides. Currently we truncate * these intermediate representations for compatibility with the git ABI, but * if and when it changes to support 64 bit types, our code will naturally * adapt. * NOTE: These types should match those that are returned by our internal * stat() functions, for all platforms. */ #include #ifdef __amigaos4__ #include #endif #if defined(_MSC_VER) typedef __int64 git_off_t; typedef __time64_t git_time_t; #elif defined(__MINGW32__) typedef off64_t git_off_t; typedef __time64_t git_time_t; #elif defined(__HAIKU__) typedef __haiku_std_int64 git_off_t; typedef __haiku_std_int64 git_time_t; #else /* POSIX */ /* * Note: Can't use off_t since if a client program includes * before us (directly or indirectly), they'll get 32 bit off_t in their client * app, even though /we/ define _FILE_OFFSET_BITS=64. */ typedef int64_t git_off_t; typedef int64_t git_time_t; #endif /** Basic type (loose or packed) of any Git object. */ typedef enum { GIT_OBJ_ANY = -2, /**< Object can be any of the following */ GIT_OBJ_BAD = -1, /**< Object is invalid. */ GIT_OBJ__EXT1 = 0, /**< Reserved for future use. */ GIT_OBJ_COMMIT = 1, /**< A commit object. */ GIT_OBJ_TREE = 2, /**< A tree (directory listing) object. */ GIT_OBJ_BLOB = 3, /**< A file revision object. */ GIT_OBJ_TAG = 4, /**< An annotated tag object. */ GIT_OBJ__EXT2 = 5, /**< Reserved for future use. */ GIT_OBJ_OFS_DELTA = 6, /**< A delta, base is given by an offset. */ GIT_OBJ_REF_DELTA = 7, /**< A delta, base is given by object id. */ } git_otype; /** An open object database handle. */ typedef struct git_odb git_odb; /** A custom backend in an ODB */ typedef struct git_odb_backend git_odb_backend; /** An object read from the ODB */ typedef struct git_odb_object git_odb_object; /** A stream to read/write from the ODB */ typedef struct git_odb_stream git_odb_stream; /** A stream to write a packfile to the ODB */ typedef struct git_odb_writepack git_odb_writepack; /** An open refs database handle. */ typedef struct git_refdb git_refdb; /** A custom backend for refs */ typedef struct git_refdb_backend git_refdb_backend; /** * Representation of an existing git repository, * including all its object contents */ typedef struct git_repository git_repository; /** Representation of a generic object in a repository */ typedef struct git_object git_object; /** Representation of an in-progress walk through the commits in a repo */ typedef struct git_revwalk git_revwalk; /** Parsed representation of a tag object. */ typedef struct git_tag git_tag; /** In-memory representation of a blob object. */ typedef struct git_blob git_blob; /** Parsed representation of a commit object. */ typedef struct git_commit git_commit; /** Representation of each one of the entries in a tree object. */ typedef struct git_tree_entry git_tree_entry; /** Representation of a tree object. */ typedef struct git_tree git_tree; /** Constructor for in-memory trees */ typedef struct git_treebuilder git_treebuilder; /** Memory representation of an index file. */ typedef struct git_index git_index; /** An iterator for conflicts in the index. */ typedef struct git_index_conflict_iterator git_index_conflict_iterator; /** Memory representation of a set of config files */ typedef struct git_config git_config; /** Interface to access a configuration file */ typedef struct git_config_backend git_config_backend; /** Representation of a reference log entry */ typedef struct git_reflog_entry git_reflog_entry; /** Representation of a reference log */ typedef struct git_reflog git_reflog; /** Representation of a git note */ typedef struct git_note git_note; /** Representation of a git packbuilder */ typedef struct git_packbuilder git_packbuilder; /** Time in a signature */ typedef struct git_time { git_time_t time; /**< time in seconds from epoch */ int offset; /**< timezone offset, in minutes */ } git_time; /** An action signature (e.g. for committers, taggers, etc) */ typedef struct git_signature { char *name; /**< full name of the author */ char *email; /**< email of the author */ git_time when; /**< time when the action happened */ } git_signature; /** In-memory representation of a reference. */ typedef struct git_reference git_reference; /** Iterator for references */ typedef struct git_reference_iterator git_reference_iterator; /** Transactional interface to references */ typedef struct git_transaction git_transaction; /** Annotated commits, the input to merge and rebase. */ typedef struct git_annotated_commit git_annotated_commit; /** Merge result */ typedef struct git_merge_result git_merge_result; /** Representation of a status collection */ typedef struct git_status_list git_status_list; /** Representation of a rebase */ typedef struct git_rebase git_rebase; /** Basic type of any Git reference. */ typedef enum { GIT_REF_INVALID = 0, /**< Invalid reference */ GIT_REF_OID = 1, /**< A reference which points at an object id */ GIT_REF_SYMBOLIC = 2, /**< A reference which points at another reference */ GIT_REF_LISTALL = GIT_REF_OID|GIT_REF_SYMBOLIC, } git_ref_t; /** Basic type of any Git branch. */ typedef enum { GIT_BRANCH_LOCAL = 1, GIT_BRANCH_REMOTE = 2, GIT_BRANCH_ALL = GIT_BRANCH_LOCAL|GIT_BRANCH_REMOTE, } git_branch_t; /** Valid modes for index and tree entries. */ typedef enum { GIT_FILEMODE_UNREADABLE = 0000000, GIT_FILEMODE_TREE = 0040000, GIT_FILEMODE_BLOB = 0100644, GIT_FILEMODE_BLOB_EXECUTABLE = 0100755, GIT_FILEMODE_LINK = 0120000, GIT_FILEMODE_COMMIT = 0160000, } git_filemode_t; /* * A refspec specifies the mapping between remote and local reference * names when fetch or pushing. */ typedef struct git_refspec git_refspec; /** * Git's idea of a remote repository. A remote can be anonymous (in * which case it does not have backing configuration entires). */ typedef struct git_remote git_remote; /** * Interface which represents a transport to communicate with a * remote. */ typedef struct git_transport git_transport; /** * Preparation for a push operation. Can be used to configure what to * push and the level of parallelism of the packfile builder. */ typedef struct git_push git_push; /* documentation in the definition */ typedef struct git_remote_head git_remote_head; typedef struct git_remote_callbacks git_remote_callbacks; /** * This is passed as the first argument to the callback to allow the * user to see the progress. * * - total_objects: number of objects in the packfile being downloaded * - indexed_objects: received objects that have been hashed * - received_objects: objects which have been downloaded * - local_objects: locally-available objects that have been injected * in order to fix a thin pack. * - received-bytes: size of the packfile received up to now */ typedef struct git_transfer_progress { unsigned int total_objects; unsigned int indexed_objects; unsigned int received_objects; unsigned int local_objects; unsigned int total_deltas; unsigned int indexed_deltas; size_t received_bytes; } git_transfer_progress; /** * Type for progress callbacks during indexing. Return a value less than zero * to cancel the transfer. * * @param stats Structure containing information about the state of the transfer * @param payload Payload provided by caller */ typedef int (*git_transfer_progress_cb)(const git_transfer_progress *stats, void *payload); /** * Type for messages delivered by the transport. Return a negative value * to cancel the network operation. * * @param str The message from the transport * @param len The length of the message * @param payload Payload provided by the caller */ typedef int (*git_transport_message_cb)(const char *str, int len, void *payload); /** * Type of host certificate structure that is passed to the check callback */ typedef enum git_cert_t { /** * No information about the certificate is available. This may * happen when using curl. */ GIT_CERT_NONE, /** * The `data` argument to the callback will be a pointer to * the DER-encoded data. */ GIT_CERT_X509, /** * The `data` argument to the callback will be a pointer to a * `git_cert_hostkey` structure. */ GIT_CERT_HOSTKEY_LIBSSH2, /** * The `data` argument to the callback will be a pointer to a * `git_strarray` with `name:content` strings containing * information about the certificate. This is used when using * curl. */ GIT_CERT_STRARRAY, } git_cert_t; /** * Parent type for `git_cert_hostkey` and `git_cert_x509`. */ typedef struct { /** * Type of certificate. A `GIT_CERT_` value. */ git_cert_t cert_type; } git_cert; /** * Callback for the user's custom certificate checks. * * @param cert The host certificate * @param valid Whether the libgit2 checks (OpenSSL or WinHTTP) think * this certificate is valid * @param host Hostname of the host libgit2 connected to * @param payload Payload provided by the caller */ typedef int (*git_transport_certificate_check_cb)(git_cert *cert, int valid, const char *host, void *payload); /** * Opaque structure representing a submodule. */ typedef struct git_submodule git_submodule; /** * Submodule update values * * These values represent settings for the `submodule.$name.update` * configuration value which says how to handle `git submodule update` for * this submodule. The value is usually set in the ".gitmodules" file and * copied to ".git/config" when the submodule is initialized. * * You can override this setting on a per-submodule basis with * `git_submodule_set_update()` and write the changed value to disk using * `git_submodule_save()`. If you have overwritten the value, you can * revert it by passing `GIT_SUBMODULE_UPDATE_RESET` to the set function. * * The values are: * * - GIT_SUBMODULE_UPDATE_CHECKOUT: the default; when a submodule is * updated, checkout the new detached HEAD to the submodule directory. * - GIT_SUBMODULE_UPDATE_REBASE: update by rebasing the current checked * out branch onto the commit from the superproject. * - GIT_SUBMODULE_UPDATE_MERGE: update by merging the commit in the * superproject into the current checkout out branch of the submodule. * - GIT_SUBMODULE_UPDATE_NONE: do not update this submodule even when * the commit in the superproject is updated. * - GIT_SUBMODULE_UPDATE_DEFAULT: not used except as static initializer * when we don't want any particular update rule to be specified. */ typedef enum { GIT_SUBMODULE_UPDATE_CHECKOUT = 1, GIT_SUBMODULE_UPDATE_REBASE = 2, GIT_SUBMODULE_UPDATE_MERGE = 3, GIT_SUBMODULE_UPDATE_NONE = 4, GIT_SUBMODULE_UPDATE_DEFAULT = 0 } git_submodule_update_t; /** * Submodule ignore values * * These values represent settings for the `submodule.$name.ignore` * configuration value which says how deeply to look at the working * directory when getting submodule status. * * You can override this value in memory on a per-submodule basis with * `git_submodule_set_ignore()` and can write the changed value to disk * with `git_submodule_save()`. If you have overwritten the value, you * can revert to the on disk value by using `GIT_SUBMODULE_IGNORE_RESET`. * * The values are: * * - GIT_SUBMODULE_IGNORE_UNSPECIFIED: use the submodule's configuration * - GIT_SUBMODULE_IGNORE_NONE: don't ignore any change - i.e. even an * untracked file, will mark the submodule as dirty. Ignored files are * still ignored, of course. * - GIT_SUBMODULE_IGNORE_UNTRACKED: ignore untracked files; only changes * to tracked files, or the index or the HEAD commit will matter. * - GIT_SUBMODULE_IGNORE_DIRTY: ignore changes in the working directory, * only considering changes if the HEAD of submodule has moved from the * value in the superproject. * - GIT_SUBMODULE_IGNORE_ALL: never check if the submodule is dirty * - GIT_SUBMODULE_IGNORE_DEFAULT: not used except as static initializer * when we don't want any particular ignore rule to be specified. */ typedef enum { GIT_SUBMODULE_IGNORE_UNSPECIFIED = -1, /**< use the submodule's configuration */ GIT_SUBMODULE_IGNORE_NONE = 1, /**< any change or untracked == dirty */ GIT_SUBMODULE_IGNORE_UNTRACKED = 2, /**< dirty if tracked files change */ GIT_SUBMODULE_IGNORE_DIRTY = 3, /**< only dirty if HEAD moved */ GIT_SUBMODULE_IGNORE_ALL = 4, /**< never dirty */ } git_submodule_ignore_t; /** * Options for submodule recurse. * * Represent the value of `submodule.$name.fetchRecurseSubmodules` * * * GIT_SUBMODULE_RECURSE_NO - do no recurse into submodules * * GIT_SUBMODULE_RECURSE_YES - recurse into submodules * * GIT_SUBMODULE_RECURSE_ONDEMAND - recurse into submodules only when * commit not already in local clone */ typedef enum { GIT_SUBMODULE_RECURSE_NO = 0, GIT_SUBMODULE_RECURSE_YES = 1, GIT_SUBMODULE_RECURSE_ONDEMAND = 2, } git_submodule_recurse_t; /** A type to write in a streaming fashion, for example, for filters. */ typedef struct git_writestream git_writestream; struct git_writestream { int (*write)(git_writestream *stream, const char *buffer, size_t len); int (*close)(git_writestream *stream); void (*free)(git_writestream *stream); }; /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/revert.h0000664000175000017500000000476512510265101017060 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_revert_h__ #define INCLUDE_git_revert_h__ #include "common.h" #include "types.h" #include "merge.h" /** * @file git2/revert.h * @brief Git revert routines * @defgroup git_revert Git revert routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Options for revert */ typedef struct { unsigned int version; /** For merge commits, the "mainline" is treated as the parent. */ unsigned int mainline; git_merge_options merge_opts; /**< Options for the merging */ git_checkout_options checkout_opts; /**< Options for the checkout */ } git_revert_options; #define GIT_REVERT_OPTIONS_VERSION 1 #define GIT_REVERT_OPTIONS_INIT {GIT_REVERT_OPTIONS_VERSION, 0, GIT_MERGE_OPTIONS_INIT, GIT_CHECKOUT_OPTIONS_INIT} /** * Initializes a `git_revert_options` with default values. Equivalent to * creating an instance with GIT_REVERT_OPTIONS_INIT. * * @param opts the `git_revert_options` struct to initialize * @param version Version of struct; pass `GIT_REVERT_OPTIONS_VERSION` * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_revert_init_options( git_revert_options *opts, unsigned int version); /** * Reverts the given commit against the given "our" commit, producing an * index that reflects the result of the revert. * * The returned index must be freed explicitly with `git_index_free`. * * @param out pointer to store the index result in * @param repo the repository that contains the given commits * @param revert_commit the commit to revert * @param our_commit the commit to revert against (eg, HEAD) * @param mainline the parent of the revert commit, if it is a merge * @param merge_options the merge options (or null for defaults) * @return zero on success, -1 on failure. */ GIT_EXTERN(int) git_revert_commit( git_index **out, git_repository *repo, git_commit *revert_commit, git_commit *our_commit, unsigned int mainline, const git_merge_options *merge_options); /** * Reverts the given commit, producing changes in the index and working directory. * * @param repo the repository to revert * @param commit the commit to revert * @param given_opts merge flags * @return zero on success, -1 on failure. */ GIT_EXTERN(int) git_revert( git_repository *repo, git_commit *commit, const git_revert_options *given_opts); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/graph.h0000664000175000017500000000315212426525445016657 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_graph_h__ #define INCLUDE_git_graph_h__ #include "common.h" #include "types.h" #include "oid.h" /** * @file git2/graph.h * @brief Git graph traversal routines * @defgroup git_revwalk Git graph traversal routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Count the number of unique commits between two commit objects * * There is no need for branches containing the commits to have any * upstream relationship, but it helps to think of one as a branch and * the other as its upstream, the `ahead` and `behind` values will be * what git would report for the branches. * * @param ahead number of unique from commits in `upstream` * @param behind number of unique from commits in `local` * @param repo the repository where the commits exist * @param local the commit for local * @param upstream the commit for upstream */ GIT_EXTERN(int) git_graph_ahead_behind(size_t *ahead, size_t *behind, git_repository *repo, const git_oid *local, const git_oid *upstream); /** * Determine if a commit is the descendant of another commit. * * @param commit a previously loaded commit. * @param ancestor a potential ancestor commit. * @return 1 if the given commit is a descendant of the potential ancestor, * 0 if not, error code otherwise. */ GIT_EXTERN(int) git_graph_descendant_of( git_repository *repo, const git_oid *commit, const git_oid *ancestor); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/refdb.h0000664000175000017500000000346312426525445016645 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_refdb_h__ #define INCLUDE_git_refdb_h__ #include "common.h" #include "types.h" #include "oid.h" #include "refs.h" /** * @file git2/refdb.h * @brief Git custom refs backend functions * @defgroup git_refdb Git custom refs backend API * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Create a new reference database with no backends. * * Before the Ref DB can be used for read/writing, a custom database * backend must be manually set using `git_refdb_set_backend()` * * @param out location to store the database pointer, if opened. * Set to NULL if the open failed. * @param repo the repository * @return 0 or an error code */ GIT_EXTERN(int) git_refdb_new(git_refdb **out, git_repository *repo); /** * Create a new reference database and automatically add * the default backends: * * - git_refdb_dir: read and write loose and packed refs * from disk, assuming the repository dir as the folder * * @param out location to store the database pointer, if opened. * Set to NULL if the open failed. * @param repo the repository * @return 0 or an error code */ GIT_EXTERN(int) git_refdb_open(git_refdb **out, git_repository *repo); /** * Suggests that the given refdb compress or optimize its references. * This mechanism is implementation specific. For on-disk reference * databases, for example, this may pack all loose references. */ GIT_EXTERN(int) git_refdb_compress(git_refdb *refdb); /** * Close an open reference database. * * @param refdb reference database pointer or NULL */ GIT_EXTERN(void) git_refdb_free(git_refdb *refdb); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/stash.h0000664000175000017500000001672612555730137016712 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_stash_h__ #define INCLUDE_git_stash_h__ #include "common.h" #include "types.h" /** * @file git2/stash.h * @brief Git stash management routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Stash flags */ typedef enum { /** * No option, default */ GIT_STASH_DEFAULT = 0, /** * All changes already added to the index are left intact in * the working directory */ GIT_STASH_KEEP_INDEX = (1 << 0), /** * All untracked files are also stashed and then cleaned up * from the working directory */ GIT_STASH_INCLUDE_UNTRACKED = (1 << 1), /** * All ignored files are also stashed and then cleaned up from * the working directory */ GIT_STASH_INCLUDE_IGNORED = (1 << 2), } git_stash_flags; /** * Save the local modifications to a new stash. * * @param out Object id of the commit containing the stashed state. * This commit is also the target of the direct reference refs/stash. * * @param repo The owning repository. * * @param stasher The identity of the person performing the stashing. * * @param message Optional description along with the stashed state. * * @param flags Flags to control the stashing process. (see GIT_STASH_* above) * * @return 0 on success, GIT_ENOTFOUND where there's nothing to stash, * or error code. */ GIT_EXTERN(int) git_stash_save( git_oid *out, git_repository *repo, const git_signature *stasher, const char *message, unsigned int flags); /** Stash application flags. */ typedef enum { GIT_STASH_APPLY_DEFAULT = 0, /* Try to reinstate not only the working tree's changes, * but also the index's changes. */ GIT_STASH_APPLY_REINSTATE_INDEX = (1 << 0), } git_stash_apply_flags; typedef enum { GIT_STASH_APPLY_PROGRESS_NONE = 0, /** Loading the stashed data from the object database. */ GIT_STASH_APPLY_PROGRESS_LOADING_STASH, /** The stored index is being analyzed. */ GIT_STASH_APPLY_PROGRESS_ANALYZE_INDEX, /** The modified files are being analyzed. */ GIT_STASH_APPLY_PROGRESS_ANALYZE_MODIFIED, /** The untracked and ignored files are being analyzed. */ GIT_STASH_APPLY_PROGRESS_ANALYZE_UNTRACKED, /** The untracked files are being written to disk. */ GIT_STASH_APPLY_PROGRESS_CHECKOUT_UNTRACKED, /** The modified files are being written to disk. */ GIT_STASH_APPLY_PROGRESS_CHECKOUT_MODIFIED, /** The stash was applied successfully. */ GIT_STASH_APPLY_PROGRESS_DONE, } git_stash_apply_progress_t; /** * Stash application progress notification function. * Return 0 to continue processing, or a negative value to * abort the stash application. */ typedef int (*git_stash_apply_progress_cb)( git_stash_apply_progress_t progress, void *payload); /** Stash application options structure. * * Initialize with the `GIT_STASH_APPLY_OPTIONS_INIT` macro to set * sensible defaults; for example: * * git_stash_apply_options opts = GIT_STASH_APPLY_OPTIONS_INIT; */ typedef struct git_stash_apply_options { unsigned int version; /** See `git_stash_apply_flags_t`, above. */ git_stash_apply_flags flags; /** Options to use when writing files to the working directory. */ git_checkout_options checkout_options; /** Optional callback to notify the consumer of application progress. */ git_stash_apply_progress_cb progress_cb; void *progress_payload; } git_stash_apply_options; #define GIT_STASH_APPLY_OPTIONS_VERSION 1 #define GIT_STASH_APPLY_OPTIONS_INIT { \ GIT_STASH_APPLY_OPTIONS_VERSION, \ GIT_STASH_APPLY_DEFAULT, \ GIT_CHECKOUT_OPTIONS_INIT } /** * Initializes a `git_stash_apply_options` with default values. Equivalent to * creating an instance with GIT_STASH_APPLY_OPTIONS_INIT. * * @param opts the `git_stash_apply_options` instance to initialize. * @param version the version of the struct; you should pass * `GIT_STASH_APPLY_OPTIONS_INIT` here. * @return Zero on success; -1 on failure. */ int git_stash_apply_init_options( git_stash_apply_options *opts, unsigned int version); /** * Apply a single stashed state from the stash list. * * If local changes in the working directory conflict with changes in the * stash then GIT_EMERGECONFLICT will be returned. In this case, the index * will always remain unmodified and all files in the working directory will * remain unmodified. However, if you are restoring untracked files or * ignored files and there is a conflict when applying the modified files, * then those files will remain in the working directory. * * If passing the GIT_STASH_APPLY_REINSTATE_INDEX flag and there would be * conflicts when reinstating the index, the function will return * GIT_EMERGECONFLICT and both the working directory and index will be left * unmodified. * * Note that a minimum checkout strategy of `GIT_CHECKOUT_SAFE` is implied. * * @param repo The owning repository. * @param index The position within the stash list. 0 points to the * most recent stashed state. * @param options Options to control how stashes are applied. * * @return 0 on success, GIT_ENOTFOUND if there's no stashed state for the * given index, GIT_EMERGECONFLICT if changes exist in the working * directory, or an error code */ GIT_EXTERN(int) git_stash_apply( git_repository *repo, size_t index, const git_stash_apply_options *options); /** * This is a callback function you can provide to iterate over all the * stashed states that will be invoked per entry. * * @param index The position within the stash list. 0 points to the * most recent stashed state. * @param message The stash message. * @param stash_id The commit oid of the stashed state. * @param payload Extra parameter to callback function. * @return 0 to continue iterating or non-zero to stop. */ typedef int (*git_stash_cb)( size_t index, const char* message, const git_oid *stash_id, void *payload); /** * Loop over all the stashed states and issue a callback for each one. * * If the callback returns a non-zero value, this will stop looping. * * @param repo Repository where to find the stash. * * @param callback Callback to invoke per found stashed state. The most * recent stash state will be enumerated first. * * @param payload Extra parameter to callback function. * * @return 0 on success, non-zero callback return value, or error code. */ GIT_EXTERN(int) git_stash_foreach( git_repository *repo, git_stash_cb callback, void *payload); /** * Remove a single stashed state from the stash list. * * @param repo The owning repository. * * @param index The position within the stash list. 0 points to the * most recent stashed state. * * @return 0 on success, GIT_ENOTFOUND if there's no stashed state for the given * index, or error code. */ GIT_EXTERN(int) git_stash_drop( git_repository *repo, size_t index); /** * Apply a single stashed state from the stash list and remove it from the list * if successful. * * @param repo The owning repository. * @param index The position within the stash list. 0 points to the * most recent stashed state. * @param options Options to control how stashes are applied. * * @return 0 on success, GIT_ENOTFOUND if there's no stashed state for the given * index, or error code. (see git_stash_apply() above for details) */ GIT_EXTERN(int) git_stash_pop( git_repository *repo, size_t index, const git_stash_apply_options *options); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/stdint.h0000664000175000017500000001704712426525445017073 0ustar // ISO C9x compliant stdint.h for Microsoft Visual Studio // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 // // Copyright (c) 2006-2008 Alexander Chemeris // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // 2. 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. // // 3. The name of the author may be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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 _MSC_VER // [ #error "Use this header only with Microsoft Visual C++ compilers!" #endif // _MSC_VER ] #ifndef _MSC_STDINT_H_ // [ #define _MSC_STDINT_H_ #if _MSC_VER > 1000 #pragma once #endif #include // For Visual Studio 6 in C++ mode and for many Visual Studio versions when // compiling for ARM we should wrap include with 'extern "C++" {}' // or compiler give many errors like this: // error C2733: second C linkage of overloaded function 'wmemchr' not allowed #ifdef __cplusplus extern "C" { #endif # include #ifdef __cplusplus } #endif // Define _W64 macros to mark types changing their size, like intptr_t. #ifndef _W64 # if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 # define _W64 __w64 # else # define _W64 # endif #endif // 7.18.1 Integer types // 7.18.1.1 Exact-width integer types // Visual Studio 6 and Embedded Visual C++ 4 doesn't // realize that, e.g. char has the same size as __int8 // so we give up on __intX for them. #if (_MSC_VER < 1300) typedef signed char int8_t; typedef signed short int16_t; typedef signed int int32_t; typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #else typedef signed __int8 int8_t; typedef signed __int16 int16_t; typedef signed __int32 int32_t; typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; #endif typedef signed __int64 int64_t; typedef unsigned __int64 uint64_t; // 7.18.1.2 Minimum-width integer types typedef int8_t int_least8_t; typedef int16_t int_least16_t; typedef int32_t int_least32_t; typedef int64_t int_least64_t; typedef uint8_t uint_least8_t; typedef uint16_t uint_least16_t; typedef uint32_t uint_least32_t; typedef uint64_t uint_least64_t; // 7.18.1.3 Fastest minimum-width integer types typedef int8_t int_fast8_t; typedef int16_t int_fast16_t; typedef int32_t int_fast32_t; typedef int64_t int_fast64_t; typedef uint8_t uint_fast8_t; typedef uint16_t uint_fast16_t; typedef uint32_t uint_fast32_t; typedef uint64_t uint_fast64_t; // 7.18.1.4 Integer types capable of holding object pointers #ifdef _WIN64 // [ typedef signed __int64 intptr_t; typedef unsigned __int64 uintptr_t; #else // _WIN64 ][ typedef _W64 signed int intptr_t; typedef _W64 unsigned int uintptr_t; #endif // _WIN64 ] // 7.18.1.5 Greatest-width integer types typedef int64_t intmax_t; typedef uint64_t uintmax_t; // 7.18.2 Limits of specified-width integer types #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 // 7.18.2.1 Limits of exact-width integer types #define INT8_MIN ((int8_t)_I8_MIN) #define INT8_MAX _I8_MAX #define INT16_MIN ((int16_t)_I16_MIN) #define INT16_MAX _I16_MAX #define INT32_MIN ((int32_t)_I32_MIN) #define INT32_MAX _I32_MAX #define INT64_MIN ((int64_t)_I64_MIN) #define INT64_MAX _I64_MAX #define UINT8_MAX _UI8_MAX #define UINT16_MAX _UI16_MAX #define UINT32_MAX _UI32_MAX #define UINT64_MAX _UI64_MAX // 7.18.2.2 Limits of minimum-width integer types #define INT_LEAST8_MIN INT8_MIN #define INT_LEAST8_MAX INT8_MAX #define INT_LEAST16_MIN INT16_MIN #define INT_LEAST16_MAX INT16_MAX #define INT_LEAST32_MIN INT32_MIN #define INT_LEAST32_MAX INT32_MAX #define INT_LEAST64_MIN INT64_MIN #define INT_LEAST64_MAX INT64_MAX #define UINT_LEAST8_MAX UINT8_MAX #define UINT_LEAST16_MAX UINT16_MAX #define UINT_LEAST32_MAX UINT32_MAX #define UINT_LEAST64_MAX UINT64_MAX // 7.18.2.3 Limits of fastest minimum-width integer types #define INT_FAST8_MIN INT8_MIN #define INT_FAST8_MAX INT8_MAX #define INT_FAST16_MIN INT16_MIN #define INT_FAST16_MAX INT16_MAX #define INT_FAST32_MIN INT32_MIN #define INT_FAST32_MAX INT32_MAX #define INT_FAST64_MIN INT64_MIN #define INT_FAST64_MAX INT64_MAX #define UINT_FAST8_MAX UINT8_MAX #define UINT_FAST16_MAX UINT16_MAX #define UINT_FAST32_MAX UINT32_MAX #define UINT_FAST64_MAX UINT64_MAX // 7.18.2.4 Limits of integer types capable of holding object pointers #ifdef _WIN64 // [ # define INTPTR_MIN INT64_MIN # define INTPTR_MAX INT64_MAX # define UINTPTR_MAX UINT64_MAX #else // _WIN64 ][ # define INTPTR_MIN INT32_MIN # define INTPTR_MAX INT32_MAX # define UINTPTR_MAX UINT32_MAX #endif // _WIN64 ] // 7.18.2.5 Limits of greatest-width integer types #define INTMAX_MIN INT64_MIN #define INTMAX_MAX INT64_MAX #define UINTMAX_MAX UINT64_MAX // 7.18.3 Limits of other integer types #ifdef _WIN64 // [ # define PTRDIFF_MIN _I64_MIN # define PTRDIFF_MAX _I64_MAX #else // _WIN64 ][ # define PTRDIFF_MIN _I32_MIN # define PTRDIFF_MAX _I32_MAX #endif // _WIN64 ] #define SIG_ATOMIC_MIN INT_MIN #define SIG_ATOMIC_MAX INT_MAX #ifndef SIZE_MAX // [ # ifdef _WIN64 // [ # define SIZE_MAX _UI64_MAX # else // _WIN64 ][ # define SIZE_MAX _UI32_MAX # endif // _WIN64 ] #endif // SIZE_MAX ] // WCHAR_MIN and WCHAR_MAX are also defined in #ifndef WCHAR_MIN // [ # define WCHAR_MIN 0 #endif // WCHAR_MIN ] #ifndef WCHAR_MAX // [ # define WCHAR_MAX _UI16_MAX #endif // WCHAR_MAX ] #define WINT_MIN 0 #define WINT_MAX _UI16_MAX #endif // __STDC_LIMIT_MACROS ] // 7.18.4 Limits of other integer types #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 // 7.18.4.1 Macros for minimum-width integer constants #define INT8_C(val) val##i8 #define INT16_C(val) val##i16 #define INT32_C(val) val##i32 #define INT64_C(val) val##i64 #define UINT8_C(val) val##ui8 #define UINT16_C(val) val##ui16 #define UINT32_C(val) val##ui32 #define UINT64_C(val) val##ui64 // 7.18.4.2 Macros for greatest-width integer constants #define INTMAX_C INT64_C #define UINTMAX_C UINT64_C #endif // __STDC_CONSTANT_MACROS ] #endif // _MSC_STDINT_H_ ] deps/libgit2-sys-0.3.8/libgit2/include/git2/attr.h0000664000175000017500000002067612426525445016542 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_attr_h__ #define INCLUDE_git_attr_h__ #include "common.h" #include "types.h" /** * @file git2/attr.h * @brief Git attribute management routines * @defgroup git_attr Git attribute management routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * GIT_ATTR_TRUE checks if an attribute is set on. In core git * parlance, this the value for "Set" attributes. * * For example, if the attribute file contains: * * *.c foo * * Then for file `xyz.c` looking up attribute "foo" gives a value for * which `GIT_ATTR_TRUE(value)` is true. */ #define GIT_ATTR_TRUE(attr) (git_attr_value(attr) == GIT_ATTR_TRUE_T) /** * GIT_ATTR_FALSE checks if an attribute is set off. In core git * parlance, this is the value for attributes that are "Unset" (not to * be confused with values that a "Unspecified"). * * For example, if the attribute file contains: * * *.h -foo * * Then for file `zyx.h` looking up attribute "foo" gives a value for * which `GIT_ATTR_FALSE(value)` is true. */ #define GIT_ATTR_FALSE(attr) (git_attr_value(attr) == GIT_ATTR_FALSE_T) /** * GIT_ATTR_UNSPECIFIED checks if an attribute is unspecified. This * may be due to the attribute not being mentioned at all or because * the attribute was explicitly set unspecified via the `!` operator. * * For example, if the attribute file contains: * * *.c foo * *.h -foo * onefile.c !foo * * Then for `onefile.c` looking up attribute "foo" yields a value with * `GIT_ATTR_UNSPECIFIED(value)` of true. Also, looking up "foo" on * file `onefile.rb` or looking up "bar" on any file will all give * `GIT_ATTR_UNSPECIFIED(value)` of true. */ #define GIT_ATTR_UNSPECIFIED(attr) (git_attr_value(attr) == GIT_ATTR_UNSPECIFIED_T) /** * GIT_ATTR_HAS_VALUE checks if an attribute is set to a value (as * opposed to TRUE, FALSE or UNSPECIFIED). This would be the case if * for a file with something like: * * *.txt eol=lf * * Given this, looking up "eol" for `onefile.txt` will give back the * string "lf" and `GIT_ATTR_SET_TO_VALUE(attr)` will return true. */ #define GIT_ATTR_HAS_VALUE(attr) (git_attr_value(attr) == GIT_ATTR_VALUE_T) /** * Possible states for an attribute */ typedef enum { GIT_ATTR_UNSPECIFIED_T = 0, /**< The attribute has been left unspecified */ GIT_ATTR_TRUE_T, /**< The attribute has been set */ GIT_ATTR_FALSE_T, /**< The attribute has been unset */ GIT_ATTR_VALUE_T, /**< This attribute has a value */ } git_attr_t; /** * Return the value type for a given attribute. * * This can be either `TRUE`, `FALSE`, `UNSPECIFIED` (if the attribute * was not set at all), or `VALUE`, if the attribute was set to an * actual string. * * If the attribute has a `VALUE` string, it can be accessed normally * as a NULL-terminated C string. * * @param attr The attribute * @return the value type for the attribute */ GIT_EXTERN(git_attr_t) git_attr_value(const char *attr); /** * Check attribute flags: Reading values from index and working directory. * * When checking attributes, it is possible to check attribute files * in both the working directory (if there is one) and the index (if * there is one). You can explicitly choose where to check and in * which order using the following flags. * * Core git usually checks the working directory then the index, * except during a checkout when it checks the index first. It will * use index only for creating archives or for a bare repo (if an * index has been specified for the bare repo). */ #define GIT_ATTR_CHECK_FILE_THEN_INDEX 0 #define GIT_ATTR_CHECK_INDEX_THEN_FILE 1 #define GIT_ATTR_CHECK_INDEX_ONLY 2 /** * Check attribute flags: Using the system attributes file. * * Normally, attribute checks include looking in the /etc (or system * equivalent) directory for a `gitattributes` file. Passing this * flag will cause attribute checks to ignore that file. */ #define GIT_ATTR_CHECK_NO_SYSTEM (1 << 2) /** * Look up the value of one git attribute for path. * * @param value_out Output of the value of the attribute. Use the GIT_ATTR_... * macros to test for TRUE, FALSE, UNSPECIFIED, etc. or just * use the string value for attributes set to a value. You * should NOT modify or free this value. * @param repo The repository containing the path. * @param flags A combination of GIT_ATTR_CHECK... flags. * @param path The path to check for attributes. Relative paths are * interpreted relative to the repo root. The file does * not have to exist, but if it does not, then it will be * treated as a plain file (not a directory). * @param name The name of the attribute to look up. */ GIT_EXTERN(int) git_attr_get( const char **value_out, git_repository *repo, uint32_t flags, const char *path, const char *name); /** * Look up a list of git attributes for path. * * Use this if you have a known list of attributes that you want to * look up in a single call. This is somewhat more efficient than * calling `git_attr_get()` multiple times. * * For example, you might write: * * const char *attrs[] = { "crlf", "diff", "foo" }; * const char **values[3]; * git_attr_get_many(values, repo, 0, "my/fun/file.c", 3, attrs); * * Then you could loop through the 3 values to get the settings for * the three attributes you asked about. * * @param values_out An array of num_attr entries that will have string * pointers written into it for the values of the attributes. * You should not modify or free the values that are written * into this array (although of course, you should free the * array itself if you allocated it). * @param repo The repository containing the path. * @param flags A combination of GIT_ATTR_CHECK... flags. * @param path The path inside the repo to check attributes. This * does not have to exist, but if it does not, then * it will be treated as a plain file (i.e. not a directory). * @param num_attr The number of attributes being looked up * @param names An array of num_attr strings containing attribute names. */ GIT_EXTERN(int) git_attr_get_many( const char **values_out, git_repository *repo, uint32_t flags, const char *path, size_t num_attr, const char **names); typedef int (*git_attr_foreach_cb)(const char *name, const char *value, void *payload); /** * Loop over all the git attributes for a path. * * @param repo The repository containing the path. * @param flags A combination of GIT_ATTR_CHECK... flags. * @param path Path inside the repo to check attributes. This does not have * to exist, but if it does not, then it will be treated as a * plain file (i.e. not a directory). * @param callback Function to invoke on each attribute name and value. The * value may be NULL is the attribute is explicitly set to * UNSPECIFIED using the '!' sign. Callback will be invoked * only once per attribute name, even if there are multiple * rules for a given file. The highest priority rule will be * used. Return a non-zero value from this to stop looping. * The value will be returned from `git_attr_foreach`. * @param payload Passed on as extra parameter to callback function. * @return 0 on success, non-zero callback return value, or error code */ GIT_EXTERN(int) git_attr_foreach( git_repository *repo, uint32_t flags, const char *path, git_attr_foreach_cb callback, void *payload); /** * Flush the gitattributes cache. * * Call this if you have reason to believe that the attributes files on * disk no longer match the cached contents of memory. This will cause * the attributes files to be reloaded the next time that an attribute * access function is called. */ GIT_EXTERN(void) git_attr_cache_flush( git_repository *repo); /** * Add a macro definition. * * Macros will automatically be loaded from the top level `.gitattributes` * file of the repository (plus the build-in "binary" macro). This * function allows you to add others. For example, to add the default * macro, you would call: * * git_attr_add_macro(repo, "binary", "-diff -crlf"); */ GIT_EXTERN(int) git_attr_add_macro( git_repository *repo, const char *name, const char *values); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/pathspec.h0000664000175000017500000002261312426525445017370 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_pathspec_h__ #define INCLUDE_git_pathspec_h__ #include "common.h" #include "types.h" #include "strarray.h" #include "diff.h" GIT_BEGIN_DECL /** * Compiled pathspec */ typedef struct git_pathspec git_pathspec; /** * List of filenames matching a pathspec */ typedef struct git_pathspec_match_list git_pathspec_match_list; /** * Options controlling how pathspec match should be executed * * - GIT_PATHSPEC_IGNORE_CASE forces match to ignore case; otherwise * match will use native case sensitivity of platform filesystem * - GIT_PATHSPEC_USE_CASE forces case sensitive match; otherwise * match will use native case sensitivity of platform filesystem * - GIT_PATHSPEC_NO_GLOB disables glob patterns and just uses simple * string comparison for matching * - GIT_PATHSPEC_NO_MATCH_ERROR means the match functions return error * code GIT_ENOTFOUND if no matches are found; otherwise no matches is * still success (return 0) but `git_pathspec_match_list_entrycount` * will indicate 0 matches. * - GIT_PATHSPEC_FIND_FAILURES means that the `git_pathspec_match_list` * should track which patterns matched which files so that at the end of * the match we can identify patterns that did not match any files. * - GIT_PATHSPEC_FAILURES_ONLY means that the `git_pathspec_match_list` * does not need to keep the actual matching filenames. Use this to * just test if there were any matches at all or in combination with * GIT_PATHSPEC_FIND_FAILURES to validate a pathspec. */ typedef enum { GIT_PATHSPEC_DEFAULT = 0, GIT_PATHSPEC_IGNORE_CASE = (1u << 0), GIT_PATHSPEC_USE_CASE = (1u << 1), GIT_PATHSPEC_NO_GLOB = (1u << 2), GIT_PATHSPEC_NO_MATCH_ERROR = (1u << 3), GIT_PATHSPEC_FIND_FAILURES = (1u << 4), GIT_PATHSPEC_FAILURES_ONLY = (1u << 5), } git_pathspec_flag_t; /** * Compile a pathspec * * @param out Output of the compiled pathspec * @param pathspec A git_strarray of the paths to match * @return 0 on success, <0 on failure */ GIT_EXTERN(int) git_pathspec_new( git_pathspec **out, const git_strarray *pathspec); /** * Free a pathspec * * @param ps The compiled pathspec */ GIT_EXTERN(void) git_pathspec_free(git_pathspec *ps); /** * Try to match a path against a pathspec * * Unlike most of the other pathspec matching functions, this will not * fall back on the native case-sensitivity for your platform. You must * explicitly pass flags to control case sensitivity or else this will * fall back on being case sensitive. * * @param ps The compiled pathspec * @param flags Combination of git_pathspec_flag_t options to control match * @param path The pathname to attempt to match * @return 1 is path matches spec, 0 if it does not */ GIT_EXTERN(int) git_pathspec_matches_path( const git_pathspec *ps, uint32_t flags, const char *path); /** * Match a pathspec against the working directory of a repository. * * This matches the pathspec against the current files in the working * directory of the repository. It is an error to invoke this on a bare * repo. This handles git ignores (i.e. ignored files will not be * considered to match the `pathspec` unless the file is tracked in the * index). * * If `out` is not NULL, this returns a `git_patchspec_match_list`. That * contains the list of all matched filenames (unless you pass the * `GIT_PATHSPEC_FAILURES_ONLY` flag) and may also contain the list of * pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES` * flag). You must call `git_pathspec_match_list_free()` on this object. * * @param out Output list of matches; pass NULL to just get return value * @param repo The repository in which to match; bare repo is an error * @param flags Combination of git_pathspec_flag_t options to control match * @param ps Pathspec to be matched * @return 0 on success, -1 on error, GIT_ENOTFOUND if no matches and * the GIT_PATHSPEC_NO_MATCH_ERROR flag was given */ GIT_EXTERN(int) git_pathspec_match_workdir( git_pathspec_match_list **out, git_repository *repo, uint32_t flags, git_pathspec *ps); /** * Match a pathspec against entries in an index. * * This matches the pathspec against the files in the repository index. * * NOTE: At the moment, the case sensitivity of this match is controlled * by the current case-sensitivity of the index object itself and the * USE_CASE and IGNORE_CASE flags will have no effect. This behavior will * be corrected in a future release. * * If `out` is not NULL, this returns a `git_patchspec_match_list`. That * contains the list of all matched filenames (unless you pass the * `GIT_PATHSPEC_FAILURES_ONLY` flag) and may also contain the list of * pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES` * flag). You must call `git_pathspec_match_list_free()` on this object. * * @param out Output list of matches; pass NULL to just get return value * @param index The index to match against * @param flags Combination of git_pathspec_flag_t options to control match * @param ps Pathspec to be matched * @return 0 on success, -1 on error, GIT_ENOTFOUND if no matches and * the GIT_PATHSPEC_NO_MATCH_ERROR flag is used */ GIT_EXTERN(int) git_pathspec_match_index( git_pathspec_match_list **out, git_index *index, uint32_t flags, git_pathspec *ps); /** * Match a pathspec against files in a tree. * * This matches the pathspec against the files in the given tree. * * If `out` is not NULL, this returns a `git_patchspec_match_list`. That * contains the list of all matched filenames (unless you pass the * `GIT_PATHSPEC_FAILURES_ONLY` flag) and may also contain the list of * pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES` * flag). You must call `git_pathspec_match_list_free()` on this object. * * @param out Output list of matches; pass NULL to just get return value * @param tree The root-level tree to match against * @param flags Combination of git_pathspec_flag_t options to control match * @param ps Pathspec to be matched * @return 0 on success, -1 on error, GIT_ENOTFOUND if no matches and * the GIT_PATHSPEC_NO_MATCH_ERROR flag is used */ GIT_EXTERN(int) git_pathspec_match_tree( git_pathspec_match_list **out, git_tree *tree, uint32_t flags, git_pathspec *ps); /** * Match a pathspec against files in a diff list. * * This matches the pathspec against the files in the given diff list. * * If `out` is not NULL, this returns a `git_patchspec_match_list`. That * contains the list of all matched filenames (unless you pass the * `GIT_PATHSPEC_FAILURES_ONLY` flag) and may also contain the list of * pathspecs with no match (if you used the `GIT_PATHSPEC_FIND_FAILURES` * flag). You must call `git_pathspec_match_list_free()` on this object. * * @param out Output list of matches; pass NULL to just get return value * @param diff A generated diff list * @param flags Combination of git_pathspec_flag_t options to control match * @param ps Pathspec to be matched * @return 0 on success, -1 on error, GIT_ENOTFOUND if no matches and * the GIT_PATHSPEC_NO_MATCH_ERROR flag is used */ GIT_EXTERN(int) git_pathspec_match_diff( git_pathspec_match_list **out, git_diff *diff, uint32_t flags, git_pathspec *ps); /** * Free memory associates with a git_pathspec_match_list * * @param m The git_pathspec_match_list to be freed */ GIT_EXTERN(void) git_pathspec_match_list_free(git_pathspec_match_list *m); /** * Get the number of items in a match list. * * @param m The git_pathspec_match_list object * @return Number of items in match list */ GIT_EXTERN(size_t) git_pathspec_match_list_entrycount( const git_pathspec_match_list *m); /** * Get a matching filename by position. * * This routine cannot be used if the match list was generated by * `git_pathspec_match_diff`. If so, it will always return NULL. * * @param m The git_pathspec_match_list object * @param pos The index into the list * @return The filename of the match */ GIT_EXTERN(const char *) git_pathspec_match_list_entry( const git_pathspec_match_list *m, size_t pos); /** * Get a matching diff delta by position. * * This routine can only be used if the match list was generated by * `git_pathspec_match_diff`. Otherwise it will always return NULL. * * @param m The git_pathspec_match_list object * @param pos The index into the list * @return The filename of the match */ GIT_EXTERN(const git_diff_delta *) git_pathspec_match_list_diff_entry( const git_pathspec_match_list *m, size_t pos); /** * Get the number of pathspec items that did not match. * * This will be zero unless you passed GIT_PATHSPEC_FIND_FAILURES when * generating the git_pathspec_match_list. * * @param m The git_pathspec_match_list object * @return Number of items in original pathspec that had no matches */ GIT_EXTERN(size_t) git_pathspec_match_list_failed_entrycount( const git_pathspec_match_list *m); /** * Get an original pathspec string that had no matches. * * This will be return NULL for positions out of range. * * @param m The git_pathspec_match_list object * @param pos The index into the failed items * @return The pathspec pattern that didn't match anything */ GIT_EXTERN(const char *) git_pathspec_match_list_failed_entry( const git_pathspec_match_list *m, size_t pos); GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/diff.h0000664000175000017500000014171512572105236016470 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_diff_h__ #define INCLUDE_git_diff_h__ #include "common.h" #include "types.h" #include "oid.h" #include "tree.h" #include "refs.h" /** * @file git2/diff.h * @brief Git tree and file differencing routines. * * Overview * -------- * * Calculating diffs is generally done in two phases: building a list of * diffs then traversing it. This makes is easier to share logic across * the various types of diffs (tree vs tree, workdir vs index, etc.), and * also allows you to insert optional diff post-processing phases, * such as rename detection, in between the steps. When you are done with * a diff object, it must be freed. * * Terminology * ----------- * * To understand the diff APIs, you should know the following terms: * * - A `diff` represents the cumulative list of differences between two * snapshots of a repository (possibly filtered by a set of file name * patterns). This is the `git_diff` object. * * - A `delta` is a file pair with an old and new revision. The old version * may be absent if the file was just created and the new version may be * absent if the file was deleted. A diff is mostly just a list of deltas. * * - A `binary` file / delta is a file (or pair) for which no text diffs * should be generated. A diff can contain delta entries that are * binary, but no diff content will be output for those files. There is * a base heuristic for binary detection and you can further tune the * behavior with git attributes or diff flags and option settings. * * - A `hunk` is a span of modified lines in a delta along with some stable * surrounding context. You can configure the amount of context and other * properties of how hunks are generated. Each hunk also comes with a * header that described where it starts and ends in both the old and new * versions in the delta. * * - A `line` is a range of characters inside a hunk. It could be a context * line (i.e. in both old and new versions), an added line (i.e. only in * the new version), or a removed line (i.e. only in the old version). * Unfortunately, we don't know anything about the encoding of data in the * file being diffed, so we cannot tell you much about the line content. * Line data will not be NUL-byte terminated, however, because it will be * just a span of bytes inside the larger file. * * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Flags for diff options. A combination of these flags can be passed * in via the `flags` value in the `git_diff_options`. */ typedef enum { /** Normal diff, the default */ GIT_DIFF_NORMAL = 0, /* * Options controlling which files will be in the diff */ /** Reverse the sides of the diff */ GIT_DIFF_REVERSE = (1u << 0), /** Include ignored files in the diff */ GIT_DIFF_INCLUDE_IGNORED = (1u << 1), /** Even with GIT_DIFF_INCLUDE_IGNORED, an entire ignored directory * will be marked with only a single entry in the diff; this flag * adds all files under the directory as IGNORED entries, too. */ GIT_DIFF_RECURSE_IGNORED_DIRS = (1u << 2), /** Include untracked files in the diff */ GIT_DIFF_INCLUDE_UNTRACKED = (1u << 3), /** Even with GIT_DIFF_INCLUDE_UNTRACKED, an entire untracked * directory will be marked with only a single entry in the diff * (a la what core Git does in `git status`); this flag adds *all* * files under untracked directories as UNTRACKED entries, too. */ GIT_DIFF_RECURSE_UNTRACKED_DIRS = (1u << 4), /** Include unmodified files in the diff */ GIT_DIFF_INCLUDE_UNMODIFIED = (1u << 5), /** Normally, a type change between files will be converted into a * DELETED record for the old and an ADDED record for the new; this * options enabled the generation of TYPECHANGE delta records. */ GIT_DIFF_INCLUDE_TYPECHANGE = (1u << 6), /** Even with GIT_DIFF_INCLUDE_TYPECHANGE, blob->tree changes still * generally show as a DELETED blob. This flag tries to correctly * label blob->tree transitions as TYPECHANGE records with new_file's * mode set to tree. Note: the tree SHA will not be available. */ GIT_DIFF_INCLUDE_TYPECHANGE_TREES = (1u << 7), /** Ignore file mode changes */ GIT_DIFF_IGNORE_FILEMODE = (1u << 8), /** Treat all submodules as unmodified */ GIT_DIFF_IGNORE_SUBMODULES = (1u << 9), /** Use case insensitive filename comparisons */ GIT_DIFF_IGNORE_CASE = (1u << 10), /** May be combined with `GIT_DIFF_IGNORE_CASE` to specify that a file * that has changed case will be returned as an add/delete pair. */ GIT_DIFF_INCLUDE_CASECHANGE = (1u << 11), /** If the pathspec is set in the diff options, this flags indicates * that the paths will be treated as literal paths instead of * fnmatch patterns. Each path in the list must either be a full * path to a file or a directory. (A trailing slash indicates that * the path will _only_ match a directory). If a directory is * specified, all children will be included. */ GIT_DIFF_DISABLE_PATHSPEC_MATCH = (1u << 12), /** Disable updating of the `binary` flag in delta records. This is * useful when iterating over a diff if you don't need hunk and data * callbacks and want to avoid having to load file completely. */ GIT_DIFF_SKIP_BINARY_CHECK = (1u << 13), /** When diff finds an untracked directory, to match the behavior of * core Git, it scans the contents for IGNORED and UNTRACKED files. * If *all* contents are IGNORED, then the directory is IGNORED; if * any contents are not IGNORED, then the directory is UNTRACKED. * This is extra work that may not matter in many cases. This flag * turns off that scan and immediately labels an untracked directory * as UNTRACKED (changing the behavior to not match core Git). */ GIT_DIFF_ENABLE_FAST_UNTRACKED_DIRS = (1u << 14), /** When diff finds a file in the working directory with stat * information different from the index, but the OID ends up being the * same, write the correct stat information into the index. Note: * without this flag, diff will always leave the index untouched. */ GIT_DIFF_UPDATE_INDEX = (1u << 15), /** Include unreadable files in the diff */ GIT_DIFF_INCLUDE_UNREADABLE = (1u << 16), /** Include unreadable files in the diff */ GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED = (1u << 17), /* * Options controlling how output will be generated */ /** Treat all files as text, disabling binary attributes & detection */ GIT_DIFF_FORCE_TEXT = (1u << 20), /** Treat all files as binary, disabling text diffs */ GIT_DIFF_FORCE_BINARY = (1u << 21), /** Ignore all whitespace */ GIT_DIFF_IGNORE_WHITESPACE = (1u << 22), /** Ignore changes in amount of whitespace */ GIT_DIFF_IGNORE_WHITESPACE_CHANGE = (1u << 23), /** Ignore whitespace at end of line */ GIT_DIFF_IGNORE_WHITESPACE_EOL = (1u << 24), /** When generating patch text, include the content of untracked * files. This automatically turns on GIT_DIFF_INCLUDE_UNTRACKED but * it does not turn on GIT_DIFF_RECURSE_UNTRACKED_DIRS. Add that * flag if you want the content of every single UNTRACKED file. */ GIT_DIFF_SHOW_UNTRACKED_CONTENT = (1u << 25), /** When generating output, include the names of unmodified files if * they are included in the git_diff. Normally these are skipped in * the formats that list files (e.g. name-only, name-status, raw). * Even with this, these will not be included in patch format. */ GIT_DIFF_SHOW_UNMODIFIED = (1u << 26), /** Use the "patience diff" algorithm */ GIT_DIFF_PATIENCE = (1u << 28), /** Take extra time to find minimal diff */ GIT_DIFF_MINIMAL = (1 << 29), /** Include the necessary deflate / delta information so that `git-apply` * can apply given diff information to binary files. */ GIT_DIFF_SHOW_BINARY = (1 << 30), } git_diff_option_t; /** * The diff object that contains all individual file deltas. * * This is an opaque structure which will be allocated by one of the diff * generator functions below (such as `git_diff_tree_to_tree`). You are * responsible for releasing the object memory when done, using the * `git_diff_free()` function. */ typedef struct git_diff git_diff; /** * Flags for the delta object and the file objects on each side. * * These flags are used for both the `flags` value of the `git_diff_delta` * and the flags for the `git_diff_file` objects representing the old and * new sides of the delta. Values outside of this public range should be * considered reserved for internal or future use. */ typedef enum { GIT_DIFF_FLAG_BINARY = (1u << 0), /**< file(s) treated as binary data */ GIT_DIFF_FLAG_NOT_BINARY = (1u << 1), /**< file(s) treated as text data */ GIT_DIFF_FLAG_VALID_ID = (1u << 2), /**< `id` value is known correct */ GIT_DIFF_FLAG_EXISTS = (1u << 3), /**< file exists at this side of the delta */ } git_diff_flag_t; /** * What type of change is described by a git_diff_delta? * * `GIT_DELTA_RENAMED` and `GIT_DELTA_COPIED` will only show up if you run * `git_diff_find_similar()` on the diff object. * * `GIT_DELTA_TYPECHANGE` only shows up given `GIT_DIFF_INCLUDE_TYPECHANGE` * in the option flags (otherwise type changes will be split into ADDED / * DELETED pairs). */ typedef enum { GIT_DELTA_UNMODIFIED = 0, /**< no changes */ GIT_DELTA_ADDED = 1, /**< entry does not exist in old version */ GIT_DELTA_DELETED = 2, /**< entry does not exist in new version */ GIT_DELTA_MODIFIED = 3, /**< entry content changed between old and new */ GIT_DELTA_RENAMED = 4, /**< entry was renamed between old and new */ GIT_DELTA_COPIED = 5, /**< entry was copied from another old entry */ GIT_DELTA_IGNORED = 6, /**< entry is ignored item in workdir */ GIT_DELTA_UNTRACKED = 7, /**< entry is untracked item in workdir */ GIT_DELTA_TYPECHANGE = 8, /**< type of entry changed between old and new */ GIT_DELTA_UNREADABLE = 9, /**< entry is unreadable */ GIT_DELTA_CONFLICTED = 10, /**< entry in the index is conflicted */ } git_delta_t; /** * Description of one side of a delta. * * Although this is called a "file", it could represent a file, a symbolic * link, a submodule commit id, or even a tree (although that only if you * are tracking type changes or ignored/untracked directories). * * The `oid` is the `git_oid` of the item. If the entry represents an * absent side of a diff (e.g. the `old_file` of a `GIT_DELTA_ADDED` delta), * then the oid will be zeroes. * * `path` is the NUL-terminated path to the entry relative to the working * directory of the repository. * * `size` is the size of the entry in bytes. * * `flags` is a combination of the `git_diff_flag_t` types * * `mode` is, roughly, the stat() `st_mode` value for the item. This will * be restricted to one of the `git_filemode_t` values. */ typedef struct { git_oid id; const char *path; git_off_t size; uint32_t flags; uint16_t mode; } git_diff_file; /** * Description of changes to one entry. * * When iterating over a diff, this will be passed to most callbacks and * you can use the contents to understand exactly what has changed. * * The `old_file` represents the "from" side of the diff and the `new_file` * represents to "to" side of the diff. What those means depend on the * function that was used to generate the diff and will be documented below. * You can also use the `GIT_DIFF_REVERSE` flag to flip it around. * * Although the two sides of the delta are named "old_file" and "new_file", * they actually may correspond to entries that represent a file, a symbolic * link, a submodule commit id, or even a tree (if you are tracking type * changes or ignored/untracked directories). * * Under some circumstances, in the name of efficiency, not all fields will * be filled in, but we generally try to fill in as much as possible. One * example is that the "flags" field may not have either the `BINARY` or the * `NOT_BINARY` flag set to avoid examining file contents if you do not pass * in hunk and/or line callbacks to the diff foreach iteration function. It * will just use the git attributes for those files. * * The similarity score is zero unless you call `git_diff_find_similar()` * which does a similarity analysis of files in the diff. Use that * function to do rename and copy detection, and to split heavily modified * files in add/delete pairs. After that call, deltas with a status of * GIT_DELTA_RENAMED or GIT_DELTA_COPIED will have a similarity score * between 0 and 100 indicating how similar the old and new sides are. * * If you ask `git_diff_find_similar` to find heavily modified files to * break, but to not *actually* break the records, then GIT_DELTA_MODIFIED * records may have a non-zero similarity score if the self-similarity is * below the split threshold. To display this value like core Git, invert * the score (a la `printf("M%03d", 100 - delta->similarity)`). */ typedef struct { git_delta_t status; uint32_t flags; /**< git_diff_flag_t values */ uint16_t similarity; /**< for RENAMED and COPIED, value 0-100 */ uint16_t nfiles; /**< number of files in this delta */ git_diff_file old_file; git_diff_file new_file; } git_diff_delta; /** * Diff notification callback function. * * The callback will be called for each file, just before the `git_delta_t` * gets inserted into the diff. * * When the callback: * - returns < 0, the diff process will be aborted. * - returns > 0, the delta will not be inserted into the diff, but the * diff process continues. * - returns 0, the delta is inserted into the diff, and the diff process * continues. */ typedef int (*git_diff_notify_cb)( const git_diff *diff_so_far, const git_diff_delta *delta_to_add, const char *matched_pathspec, void *payload); /** * Structure describing options about how the diff should be executed. * * Setting all values of the structure to zero will yield the default * values. Similarly, passing NULL for the options structure will * give the defaults. The default values are marked below. * * - `flags` is a combination of the `git_diff_option_t` values above * - `context_lines` is the number of unchanged lines that define the * boundary of a hunk (and to display before and after) * - `interhunk_lines` is the maximum number of unchanged lines between * hunk boundaries before the hunks will be merged into a one. * - `old_prefix` is the virtual "directory" to prefix to old file names * in hunk headers (default "a") * - `new_prefix` is the virtual "directory" to prefix to new file names * in hunk headers (default "b") * - `pathspec` is an array of paths / fnmatch patterns to constrain diff * - `max_size` is a file size (in bytes) above which a blob will be marked * as binary automatically; pass a negative value to disable. * - `notify_cb` is an optional callback function, notifying the consumer of * which files are being examined as the diff is generated * - `notify_payload` is the payload data to pass to the `notify_cb` function * - `ignore_submodules` overrides the submodule ignore setting for all * submodules in the diff. */ typedef struct { unsigned int version; /**< version for the struct */ uint32_t flags; /**< defaults to GIT_DIFF_NORMAL */ /* options controlling which files are in the diff */ git_submodule_ignore_t ignore_submodules; /**< submodule ignore rule */ git_strarray pathspec; /**< defaults to include all paths */ git_diff_notify_cb notify_cb; void *notify_payload; /* options controlling how to diff text is generated */ uint32_t context_lines; /**< defaults to 3 */ uint32_t interhunk_lines; /**< defaults to 0 */ uint16_t id_abbrev; /**< default 'core.abbrev' or 7 if unset */ git_off_t max_size; /**< defaults to 512MB */ const char *old_prefix; /**< defaults to "a" */ const char *new_prefix; /**< defaults to "b" */ } git_diff_options; /* The current version of the diff options structure */ #define GIT_DIFF_OPTIONS_VERSION 1 /* Stack initializer for diff options. Alternatively use * `git_diff_options_init` programmatic initialization. */ #define GIT_DIFF_OPTIONS_INIT \ {GIT_DIFF_OPTIONS_VERSION, 0, GIT_SUBMODULE_IGNORE_UNSPECIFIED, {NULL,0}, NULL, NULL, 3} /** * Initializes a `git_diff_options` with default values. Equivalent to * creating an instance with GIT_DIFF_OPTIONS_INIT. * * @param opts The `git_diff_options` struct to initialize * @param version Version of struct; pass `GIT_DIFF_OPTIONS_VERSION` * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_diff_init_options( git_diff_options *opts, unsigned int version); /** * When iterating over a diff, callback that will be made per file. * * @param delta A pointer to the delta data for the file * @param progress Goes from 0 to 1 over the diff * @param payload User-specified pointer from foreach function */ typedef int (*git_diff_file_cb)( const git_diff_delta *delta, float progress, void *payload); /** * When producing a binary diff, the binary data returned will be * either the deflated full ("literal") contents of the file, or * the deflated binary delta between the two sides (whichever is * smaller). */ typedef enum { /** There is no binary delta. */ GIT_DIFF_BINARY_NONE, /** The binary data is the literal contents of the file. */ GIT_DIFF_BINARY_LITERAL, /** The binary data is the delta from one side to the other. */ GIT_DIFF_BINARY_DELTA, } git_diff_binary_t; /** The contents of one of the files in a binary diff. */ typedef struct { /** The type of binary data for this file. */ git_diff_binary_t type; /** The binary data, deflated. */ const char *data; /** The length of the binary data. */ size_t datalen; /** The length of the binary data after inflation. */ size_t inflatedlen; } git_diff_binary_file; /** Structure describing the binary contents of a diff. */ typedef struct { git_diff_binary_file old_file; /**< The contents of the old file. */ git_diff_binary_file new_file; /**< The contents of the new file. */ } git_diff_binary; /** * When iterating over a diff, callback that will be made for * binary content within the diff. */ typedef int(*git_diff_binary_cb)( const git_diff_delta *delta, const git_diff_binary *binary, void *payload); /** * Structure describing a hunk of a diff. */ typedef struct { int old_start; /**< Starting line number in old_file */ int old_lines; /**< Number of lines in old_file */ int new_start; /**< Starting line number in new_file */ int new_lines; /**< Number of lines in new_file */ size_t header_len; /**< Number of bytes in header text */ char header[128]; /**< Header text, NUL-byte terminated */ } git_diff_hunk; /** * When iterating over a diff, callback that will be made per hunk. */ typedef int (*git_diff_hunk_cb)( const git_diff_delta *delta, const git_diff_hunk *hunk, void *payload); /** * Line origin constants. * * These values describe where a line came from and will be passed to * the git_diff_line_cb when iterating over a diff. There are some * special origin constants at the end that are used for the text * output callbacks to demarcate lines that are actually part of * the file or hunk headers. */ typedef enum { /* These values will be sent to `git_diff_line_cb` along with the line */ GIT_DIFF_LINE_CONTEXT = ' ', GIT_DIFF_LINE_ADDITION = '+', GIT_DIFF_LINE_DELETION = '-', GIT_DIFF_LINE_CONTEXT_EOFNL = '=', /**< Both files have no LF at end */ GIT_DIFF_LINE_ADD_EOFNL = '>', /**< Old has no LF at end, new does */ GIT_DIFF_LINE_DEL_EOFNL = '<', /**< Old has LF at end, new does not */ /* The following values will only be sent to a `git_diff_line_cb` when * the content of a diff is being formatted through `git_diff_print`. */ GIT_DIFF_LINE_FILE_HDR = 'F', GIT_DIFF_LINE_HUNK_HDR = 'H', GIT_DIFF_LINE_BINARY = 'B' /**< For "Binary files x and y differ" */ } git_diff_line_t; /** * Structure describing a line (or data span) of a diff. */ typedef struct { char origin; /**< A git_diff_line_t value */ int old_lineno; /**< Line number in old file or -1 for added line */ int new_lineno; /**< Line number in new file or -1 for deleted line */ int num_lines; /**< Number of newline characters in content */ size_t content_len; /**< Number of bytes of data */ git_off_t content_offset; /**< Offset in the original file to the content */ const char *content; /**< Pointer to diff text, not NUL-byte terminated */ } git_diff_line; /** * When iterating over a diff, callback that will be made per text diff * line. In this context, the provided range will be NULL. * * When printing a diff, callback that will be made to output each line * of text. This uses some extra GIT_DIFF_LINE_... constants for output * of lines of file and hunk headers. */ typedef int (*git_diff_line_cb)( const git_diff_delta *delta, /**< delta that contains this data */ const git_diff_hunk *hunk, /**< hunk containing this data */ const git_diff_line *line, /**< line data */ void *payload); /**< user reference data */ /** * Flags to control the behavior of diff rename/copy detection. */ typedef enum { /** Obey `diff.renames`. Overridden by any other GIT_DIFF_FIND_... flag. */ GIT_DIFF_FIND_BY_CONFIG = 0, /** Look for renames? (`--find-renames`) */ GIT_DIFF_FIND_RENAMES = (1u << 0), /** Consider old side of MODIFIED for renames? (`--break-rewrites=N`) */ GIT_DIFF_FIND_RENAMES_FROM_REWRITES = (1u << 1), /** Look for copies? (a la `--find-copies`). */ GIT_DIFF_FIND_COPIES = (1u << 2), /** Consider UNMODIFIED as copy sources? (`--find-copies-harder`). * * For this to work correctly, use GIT_DIFF_INCLUDE_UNMODIFIED when * the initial `git_diff` is being generated. */ GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED = (1u << 3), /** Mark significant rewrites for split (`--break-rewrites=/M`) */ GIT_DIFF_FIND_REWRITES = (1u << 4), /** Actually split large rewrites into delete/add pairs */ GIT_DIFF_BREAK_REWRITES = (1u << 5), /** Mark rewrites for split and break into delete/add pairs */ GIT_DIFF_FIND_AND_BREAK_REWRITES = (GIT_DIFF_FIND_REWRITES | GIT_DIFF_BREAK_REWRITES), /** Find renames/copies for UNTRACKED items in working directory. * * For this to work correctly, use GIT_DIFF_INCLUDE_UNTRACKED when the * initial `git_diff` is being generated (and obviously the diff must * be against the working directory for this to make sense). */ GIT_DIFF_FIND_FOR_UNTRACKED = (1u << 6), /** Turn on all finding features. */ GIT_DIFF_FIND_ALL = (0x0ff), /** Measure similarity ignoring leading whitespace (default) */ GIT_DIFF_FIND_IGNORE_LEADING_WHITESPACE = 0, /** Measure similarity ignoring all whitespace */ GIT_DIFF_FIND_IGNORE_WHITESPACE = (1u << 12), /** Measure similarity including all data */ GIT_DIFF_FIND_DONT_IGNORE_WHITESPACE = (1u << 13), /** Measure similarity only by comparing SHAs (fast and cheap) */ GIT_DIFF_FIND_EXACT_MATCH_ONLY = (1u << 14), /** Do not break rewrites unless they contribute to a rename. * * Normally, GIT_DIFF_FIND_AND_BREAK_REWRITES will measure the self- * similarity of modified files and split the ones that have changed a * lot into a DELETE / ADD pair. Then the sides of that pair will be * considered candidates for rename and copy detection. * * If you add this flag in and the split pair is *not* used for an * actual rename or copy, then the modified record will be restored to * a regular MODIFIED record instead of being split. */ GIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY = (1u << 15), /** Remove any UNMODIFIED deltas after find_similar is done. * * Using GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED to emulate the * --find-copies-harder behavior requires building a diff with the * GIT_DIFF_INCLUDE_UNMODIFIED flag. If you do not want UNMODIFIED * records in the final result, pass this flag to have them removed. */ GIT_DIFF_FIND_REMOVE_UNMODIFIED = (1u << 16), } git_diff_find_t; /** * Pluggable similarity metric */ typedef struct { int (*file_signature)( void **out, const git_diff_file *file, const char *fullpath, void *payload); int (*buffer_signature)( void **out, const git_diff_file *file, const char *buf, size_t buflen, void *payload); void (*free_signature)(void *sig, void *payload); int (*similarity)(int *score, void *siga, void *sigb, void *payload); void *payload; } git_diff_similarity_metric; /** * Control behavior of rename and copy detection * * These options mostly mimic parameters that can be passed to git-diff. * * - `rename_threshold` is the same as the -M option with a value * - `copy_threshold` is the same as the -C option with a value * - `rename_from_rewrite_threshold` matches the top of the -B option * - `break_rewrite_threshold` matches the bottom of the -B option * - `rename_limit` is the maximum number of matches to consider for * a particular file. This is a little different from the `-l` option * to regular Git because we will still process up to this many matches * before abandoning the search. * * The `metric` option allows you to plug in a custom similarity metric. * Set it to NULL for the default internal metric which is based on sampling * hashes of ranges of data in the file. The default metric is a pretty * good similarity approximation that should work fairly well for both text * and binary data, and is pretty fast with fixed memory overhead. */ typedef struct { unsigned int version; /** * Combination of git_diff_find_t values (default GIT_DIFF_FIND_BY_CONFIG). * NOTE: if you don't explicitly set this, `diff.renames` could be set * to false, resulting in `git_diff_find_similar` doing nothing. */ uint32_t flags; /** Similarity to consider a file renamed (default 50) */ uint16_t rename_threshold; /** Similarity of modified to be eligible rename source (default 50) */ uint16_t rename_from_rewrite_threshold; /** Similarity to consider a file a copy (default 50) */ uint16_t copy_threshold; /** Similarity to split modify into delete/add pair (default 60) */ uint16_t break_rewrite_threshold; /** Maximum similarity sources to examine for a file (somewhat like * git-diff's `-l` option or `diff.renameLimit` config) (default 200) */ size_t rename_limit; /** Pluggable similarity metric; pass NULL to use internal metric */ git_diff_similarity_metric *metric; } git_diff_find_options; #define GIT_DIFF_FIND_OPTIONS_VERSION 1 #define GIT_DIFF_FIND_OPTIONS_INIT {GIT_DIFF_FIND_OPTIONS_VERSION} /** * Initializes a `git_diff_find_options` with default values. Equivalent to * creating an instance with GIT_DIFF_FIND_OPTIONS_INIT. * * @param opts The `git_diff_find_options` struct to initialize * @param version Version of struct; pass `GIT_DIFF_FIND_OPTIONS_VERSION` * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_diff_find_init_options( git_diff_find_options *opts, unsigned int version); /** @name Diff Generator Functions * * These are the functions you would use to create (or destroy) a * git_diff from various objects in a repository. */ /**@{*/ /** * Deallocate a diff. * * @param diff The previously created diff; cannot be used after free. */ GIT_EXTERN(void) git_diff_free(git_diff *diff); /** * Create a diff with the difference between two tree objects. * * This is equivalent to `git diff ` * * The first tree will be used for the "old_file" side of the delta and the * second tree will be used for the "new_file" side of the delta. You can * pass NULL to indicate an empty tree, although it is an error to pass * NULL for both the `old_tree` and `new_tree`. * * @param diff Output pointer to a git_diff pointer to be allocated. * @param repo The repository containing the trees. * @param old_tree A git_tree object to diff from, or NULL for empty tree. * @param new_tree A git_tree object to diff to, or NULL for empty tree. * @param opts Structure with options to influence diff or NULL for defaults. */ GIT_EXTERN(int) git_diff_tree_to_tree( git_diff **diff, git_repository *repo, git_tree *old_tree, git_tree *new_tree, const git_diff_options *opts); /**< can be NULL for defaults */ /** * Create a diff between a tree and repository index. * * This is equivalent to `git diff --cached ` or if you pass * the HEAD tree, then like `git diff --cached`. * * The tree you pass will be used for the "old_file" side of the delta, and * the index will be used for the "new_file" side of the delta. * * If you pass NULL for the index, then the existing index of the `repo` * will be used. In this case, the index will be refreshed from disk * (if it has changed) before the diff is generated. * * @param diff Output pointer to a git_diff pointer to be allocated. * @param repo The repository containing the tree and index. * @param old_tree A git_tree object to diff from, or NULL for empty tree. * @param index The index to diff with; repo index used if NULL. * @param opts Structure with options to influence diff or NULL for defaults. */ GIT_EXTERN(int) git_diff_tree_to_index( git_diff **diff, git_repository *repo, git_tree *old_tree, git_index *index, const git_diff_options *opts); /**< can be NULL for defaults */ /** * Create a diff between the repository index and the workdir directory. * * This matches the `git diff` command. See the note below on * `git_diff_tree_to_workdir` for a discussion of the difference between * `git diff` and `git diff HEAD` and how to emulate a `git diff ` * using libgit2. * * The index will be used for the "old_file" side of the delta, and the * working directory will be used for the "new_file" side of the delta. * * If you pass NULL for the index, then the existing index of the `repo` * will be used. In this case, the index will be refreshed from disk * (if it has changed) before the diff is generated. * * @param diff Output pointer to a git_diff pointer to be allocated. * @param repo The repository. * @param index The index to diff from; repo index used if NULL. * @param opts Structure with options to influence diff or NULL for defaults. */ GIT_EXTERN(int) git_diff_index_to_workdir( git_diff **diff, git_repository *repo, git_index *index, const git_diff_options *opts); /**< can be NULL for defaults */ /** * Create a diff between a tree and the working directory. * * The tree you provide will be used for the "old_file" side of the delta, * and the working directory will be used for the "new_file" side. * * This is not the same as `git diff ` or `git diff-index * `. Those commands use information from the index, whereas this * function strictly returns the differences between the tree and the files * in the working directory, regardless of the state of the index. Use * `git_diff_tree_to_workdir_with_index` to emulate those commands. * * To see difference between this and `git_diff_tree_to_workdir_with_index`, * consider the example of a staged file deletion where the file has then * been put back into the working dir and further modified. The * tree-to-workdir diff for that file is 'modified', but `git diff` would * show status 'deleted' since there is a staged delete. * * @param diff A pointer to a git_diff pointer that will be allocated. * @param repo The repository containing the tree. * @param old_tree A git_tree object to diff from, or NULL for empty tree. * @param opts Structure with options to influence diff or NULL for defaults. */ GIT_EXTERN(int) git_diff_tree_to_workdir( git_diff **diff, git_repository *repo, git_tree *old_tree, const git_diff_options *opts); /**< can be NULL for defaults */ /** * Create a diff between a tree and the working directory using index data * to account for staged deletes, tracked files, etc. * * This emulates `git diff ` by diffing the tree to the index and * the index to the working directory and blending the results into a * single diff that includes staged deleted, etc. * * @param diff A pointer to a git_diff pointer that will be allocated. * @param repo The repository containing the tree. * @param old_tree A git_tree object to diff from, or NULL for empty tree. * @param opts Structure with options to influence diff or NULL for defaults. */ GIT_EXTERN(int) git_diff_tree_to_workdir_with_index( git_diff **diff, git_repository *repo, git_tree *old_tree, const git_diff_options *opts); /**< can be NULL for defaults */ /** * Create a diff with the difference between two index objects. * * The first index will be used for the "old_file" side of the delta and the * second index will be used for the "new_file" side of the delta. * * @param diff Output pointer to a git_diff pointer to be allocated. * @param repo The repository containing the indexes. * @param old_index A git_index object to diff from. * @param new_index A git_index object to diff to. * @param opts Structure with options to influence diff or NULL for defaults. */ GIT_EXTERN(int) git_diff_index_to_index( git_diff **diff, git_repository *repo, git_index *old_index, git_index *new_index, const git_diff_options *opts); /**< can be NULL for defaults */ /** * Merge one diff into another. * * This merges items from the "from" list into the "onto" list. The * resulting diff will have all items that appear in either list. * If an item appears in both lists, then it will be "merged" to appear * as if the old version was from the "onto" list and the new version * is from the "from" list (with the exception that if the item has a * pending DELETE in the middle, then it will show as deleted). * * @param onto Diff to merge into. * @param from Diff to merge. */ GIT_EXTERN(int) git_diff_merge( git_diff *onto, const git_diff *from); /** * Transform a diff marking file renames, copies, etc. * * This modifies a diff in place, replacing old entries that look * like renames or copies with new entries reflecting those changes. * This also will, if requested, break modified files into add/remove * pairs if the amount of change is above a threshold. * * @param diff diff to run detection algorithms on * @param options Control how detection should be run, NULL for defaults * @return 0 on success, -1 on failure */ GIT_EXTERN(int) git_diff_find_similar( git_diff *diff, const git_diff_find_options *options); /**@}*/ /** @name Diff Processor Functions * * These are the functions you apply to a diff to process it * or read it in some way. */ /**@{*/ /** * Query how many diff records are there in a diff. * * @param diff A git_diff generated by one of the above functions * @return Count of number of deltas in the list */ GIT_EXTERN(size_t) git_diff_num_deltas(const git_diff *diff); /** * Query how many diff deltas are there in a diff filtered by type. * * This works just like `git_diff_entrycount()` with an extra parameter * that is a `git_delta_t` and returns just the count of how many deltas * match that particular type. * * @param diff A git_diff generated by one of the above functions * @param type A git_delta_t value to filter the count * @return Count of number of deltas matching delta_t type */ GIT_EXTERN(size_t) git_diff_num_deltas_of_type( const git_diff *diff, git_delta_t type); /** * Return the diff delta for an entry in the diff list. * * The `git_diff_delta` pointer points to internal data and you do not * have to release it when you are done with it. It will go away when * the * `git_diff` (or any associated `git_patch`) goes away. * * Note that the flags on the delta related to whether it has binary * content or not may not be set if there are no attributes set for the * file and there has been no reason to load the file data at this point. * For now, if you need those flags to be up to date, your only option is * to either use `git_diff_foreach` or create a `git_patch`. * * @param diff Diff list object * @param idx Index into diff list * @return Pointer to git_diff_delta (or NULL if `idx` out of range) */ GIT_EXTERN(const git_diff_delta *) git_diff_get_delta( const git_diff *diff, size_t idx); /** * Check if deltas are sorted case sensitively or insensitively. * * @param diff diff to check * @return 0 if case sensitive, 1 if case is ignored */ GIT_EXTERN(int) git_diff_is_sorted_icase(const git_diff *diff); /** * Loop over all deltas in a diff issuing callbacks. * * This will iterate through all of the files described in a diff. You * should provide a file callback to learn about each file. * * The "hunk" and "line" callbacks are optional, and the text diff of the * files will only be calculated if they are not NULL. Of course, these * callbacks will not be invoked for binary files on the diff or for * files whose only changed is a file mode change. * * Returning a non-zero value from any of the callbacks will terminate * the iteration and return the value to the user. * * @param diff A git_diff generated by one of the above functions. * @param file_cb Callback function to make per file in the diff. * @param binary_cb Optional callback to make for binary files. * @param hunk_cb Optional callback to make per hunk of text diff. This * callback is called to describe a range of lines in the * diff. It will not be issued for binary files. * @param line_cb Optional callback to make per line of diff text. This * same callback will be made for context lines, added, and * removed lines, and even for a deleted trailing newline. * @param payload Reference pointer that will be passed to your callbacks. * @return 0 on success, non-zero callback return value, or error code */ GIT_EXTERN(int) git_diff_foreach( git_diff *diff, git_diff_file_cb file_cb, git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb line_cb, void *payload); /** * Look up the single character abbreviation for a delta status code. * * When you run `git diff --name-status` it uses single letter codes in * the output such as 'A' for added, 'D' for deleted, 'M' for modified, * etc. This function converts a git_delta_t value into these letters for * your own purposes. GIT_DELTA_UNTRACKED will return a space (i.e. ' '). * * @param status The git_delta_t value to look up * @return The single character label for that code */ GIT_EXTERN(char) git_diff_status_char(git_delta_t status); /** * Possible output formats for diff data */ typedef enum { GIT_DIFF_FORMAT_PATCH = 1u, /**< full git diff */ GIT_DIFF_FORMAT_PATCH_HEADER = 2u, /**< just the file headers of patch */ GIT_DIFF_FORMAT_RAW = 3u, /**< like git diff --raw */ GIT_DIFF_FORMAT_NAME_ONLY = 4u, /**< like git diff --name-only */ GIT_DIFF_FORMAT_NAME_STATUS = 5u, /**< like git diff --name-status */ } git_diff_format_t; /** * Iterate over a diff generating formatted text output. * * Returning a non-zero value from the callbacks will terminate the * iteration and return the non-zero value to the caller. * * @param diff A git_diff generated by one of the above functions. * @param format A git_diff_format_t value to pick the text format. * @param print_cb Callback to make per line of diff text. * @param payload Reference pointer that will be passed to your callback. * @return 0 on success, non-zero callback return value, or error code */ GIT_EXTERN(int) git_diff_print( git_diff *diff, git_diff_format_t format, git_diff_line_cb print_cb, void *payload); /**@}*/ /* * Misc */ /** * Directly run a diff on two blobs. * * Compared to a file, a blob lacks some contextual information. As such, * the `git_diff_file` given to the callback will have some fake data; i.e. * `mode` will be 0 and `path` will be NULL. * * NULL is allowed for either `old_blob` or `new_blob` and will be treated * as an empty blob, with the `oid` set to NULL in the `git_diff_file` data. * Passing NULL for both blobs is a noop; no callbacks will be made at all. * * We do run a binary content check on the blob content and if either blob * looks like binary data, the `git_diff_delta` binary attribute will be set * to 1 and no call to the hunk_cb nor line_cb will be made (unless you pass * `GIT_DIFF_FORCE_TEXT` of course). * * @param old_blob Blob for old side of diff, or NULL for empty blob * @param old_as_path Treat old blob as if it had this filename; can be NULL * @param new_blob Blob for new side of diff, or NULL for empty blob * @param new_as_path Treat new blob as if it had this filename; can be NULL * @param options Options for diff, or NULL for default options * @param file_cb Callback for "file"; made once if there is a diff; can be NULL * @param binary_cb Callback for binary files; can be NULL * @param hunk_cb Callback for each hunk in diff; can be NULL * @param line_cb Callback for each line in diff; can be NULL * @param payload Payload passed to each callback function * @return 0 on success, non-zero callback return value, or error code */ GIT_EXTERN(int) git_diff_blobs( const git_blob *old_blob, const char *old_as_path, const git_blob *new_blob, const char *new_as_path, const git_diff_options *options, git_diff_file_cb file_cb, git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb line_cb, void *payload); /** * Directly run a diff between a blob and a buffer. * * As with `git_diff_blobs`, comparing a blob and buffer lacks some context, * so the `git_diff_file` parameters to the callbacks will be faked a la the * rules for `git_diff_blobs()`. * * Passing NULL for `old_blob` will be treated as an empty blob (i.e. the * `file_cb` will be invoked with GIT_DELTA_ADDED and the diff will be the * entire content of the buffer added). Passing NULL to the buffer will do * the reverse, with GIT_DELTA_REMOVED and blob content removed. * * @param old_blob Blob for old side of diff, or NULL for empty blob * @param old_as_path Treat old blob as if it had this filename; can be NULL * @param buffer Raw data for new side of diff, or NULL for empty * @param buffer_len Length of raw data for new side of diff * @param buffer_as_path Treat buffer as if it had this filename; can be NULL * @param options Options for diff, or NULL for default options * @param file_cb Callback for "file"; made once if there is a diff; can be NULL * @param binary_cb Callback for binary files; can be NULL * @param hunk_cb Callback for each hunk in diff; can be NULL * @param line_cb Callback for each line in diff; can be NULL * @param payload Payload passed to each callback function * @return 0 on success, non-zero callback return value, or error code */ GIT_EXTERN(int) git_diff_blob_to_buffer( const git_blob *old_blob, const char *old_as_path, const char *buffer, size_t buffer_len, const char *buffer_as_path, const git_diff_options *options, git_diff_file_cb file_cb, git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb line_cb, void *payload); /** * Directly run a diff between two buffers. * * Even more than with `git_diff_blobs`, comparing two buffer lacks * context, so the `git_diff_file` parameters to the callbacks will be * faked a la the rules for `git_diff_blobs()`. * * @param old_buffer Raw data for old side of diff, or NULL for empty * @param old_len Length of the raw data for old side of the diff * @param old_as_path Treat old buffer as if it had this filename; can be NULL * @param new_buffer Raw data for new side of diff, or NULL for empty * @param new_len Length of raw data for new side of diff * @param new_as_path Treat buffer as if it had this filename; can be NULL * @param options Options for diff, or NULL for default options * @param file_cb Callback for "file"; made once if there is a diff; can be NULL * @param binary_cb Callback for binary files; can be NULL * @param hunk_cb Callback for each hunk in diff; can be NULL * @param line_cb Callback for each line in diff; can be NULL * @param payload Payload passed to each callback function * @return 0 on success, non-zero callback return value, or error code */ GIT_EXTERN(int) git_diff_buffers( const void *old_buffer, size_t old_len, const char *old_as_path, const void *new_buffer, size_t new_len, const char *new_as_path, const git_diff_options *options, git_diff_file_cb file_cb, git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb line_cb, void *payload); /** * This is an opaque structure which is allocated by `git_diff_get_stats`. * You are responsible for releasing the object memory when done, using the * `git_diff_stats_free()` function. */ typedef struct git_diff_stats git_diff_stats; /** * Formatting options for diff stats */ typedef enum { /** No stats*/ GIT_DIFF_STATS_NONE = 0, /** Full statistics, equivalent of `--stat` */ GIT_DIFF_STATS_FULL = (1u << 0), /** Short statistics, equivalent of `--shortstat` */ GIT_DIFF_STATS_SHORT = (1u << 1), /** Number statistics, equivalent of `--numstat` */ GIT_DIFF_STATS_NUMBER = (1u << 2), /** Extended header information such as creations, renames and mode changes, equivalent of `--summary` */ GIT_DIFF_STATS_INCLUDE_SUMMARY = (1u << 3), } git_diff_stats_format_t; /** * Accumlate diff statistics for all patches. * * @param out Structure containg the diff statistics. * @param diff A git_diff generated by one of the above functions. * @return 0 on success; non-zero on error */ GIT_EXTERN(int) git_diff_get_stats( git_diff_stats **out, git_diff *diff); /** * Get the total number of files changed in a diff * * @param stats A `git_diff_stats` generated by one of the above functions. * @return total number of files changed in the diff */ GIT_EXTERN(size_t) git_diff_stats_files_changed( const git_diff_stats *stats); /** * Get the total number of insertions in a diff * * @param stats A `git_diff_stats` generated by one of the above functions. * @return total number of insertions in the diff */ GIT_EXTERN(size_t) git_diff_stats_insertions( const git_diff_stats *stats); /** * Get the total number of deletions in a diff * * @param stats A `git_diff_stats` generated by one of the above functions. * @return total number of deletions in the diff */ GIT_EXTERN(size_t) git_diff_stats_deletions( const git_diff_stats *stats); /** * Print diff statistics to a `git_buf`. * * @param out buffer to store the formatted diff statistics in. * @param stats A `git_diff_stats` generated by one of the above functions. * @param format Formatting option. * @param width Target width for output (only affects GIT_DIFF_STATS_FULL) * @return 0 on success; non-zero on error */ GIT_EXTERN(int) git_diff_stats_to_buf( git_buf *out, const git_diff_stats *stats, git_diff_stats_format_t format, size_t width); /** * Deallocate a `git_diff_stats`. * * @param stats The previously created statistics object; * cannot be used after free. */ GIT_EXTERN(void) git_diff_stats_free(git_diff_stats *stats); /** * Formatting options for diff e-mail generation */ typedef enum { /** Normal patch, the default */ GIT_DIFF_FORMAT_EMAIL_NONE = 0, /** Don't insert "[PATCH]" in the subject header*/ GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER = (1 << 0), } git_diff_format_email_flags_t; /** * Options for controlling the formatting of the generated e-mail. */ typedef struct { unsigned int version; git_diff_format_email_flags_t flags; /** This patch number */ size_t patch_no; /** Total number of patches in this series */ size_t total_patches; /** id to use for the commit */ const git_oid *id; /** Summary of the change */ const char *summary; /** Author of the change */ const git_signature *author; } git_diff_format_email_options; #define GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION 1 #define GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT {GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION, 0, 1, 1, NULL, NULL, NULL} /** * Create an e-mail ready patch from a diff. * * @param out buffer to store the e-mail patch in * @param diff containing the commit * @param opts structure with options to influence content and formatting. * @return 0 or an error code */ GIT_EXTERN(int) git_diff_format_email( git_buf *out, git_diff *diff, const git_diff_format_email_options *opts); /** * Create an e-mail ready patch for a commit. * * Does not support creating patches for merge commits (yet). * * @param out buffer to store the e-mail patch in * @param repo containing the commit * @param commit pointer to up commit * @param patch_no patch number of the commit * @param total_patches total number of patches in the patch set * @param flags determines the formatting of the e-mail * @param diff_opts structure with options to influence diff or NULL for defaults. * @return 0 or an error code */ GIT_EXTERN(int) git_diff_commit_as_email( git_buf *out, git_repository *repo, git_commit *commit, size_t patch_no, size_t total_patches, git_diff_format_email_flags_t flags, const git_diff_options *diff_opts); /** * Initializes a `git_diff_format_email_options` with default values. * * Equivalent to creating an instance with GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT. * * @param opts The `git_diff_format_email_options` struct to initialize * @param version Version of struct; pass `GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION` * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_diff_format_email_init_options( git_diff_format_email_options *opts, unsigned int version); GIT_END_DECL /** @} */ #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/blob.h0000664000175000017500000001570512555730137016502 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_blob_h__ #define INCLUDE_git_blob_h__ #include "common.h" #include "types.h" #include "oid.h" #include "object.h" #include "buffer.h" /** * @file git2/blob.h * @brief Git blob load and write routines * @defgroup git_blob Git blob load and write routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Lookup a blob object from a repository. * * @param blob pointer to the looked up blob * @param repo the repo to use when locating the blob. * @param id identity of the blob to locate. * @return 0 or an error code */ GIT_EXTERN(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git_oid *id); /** * Lookup a blob object from a repository, * given a prefix of its identifier (short id). * * @see git_object_lookup_prefix * * @param blob pointer to the looked up blob * @param repo the repo to use when locating the blob. * @param id identity of the blob to locate. * @param len the length of the short identifier * @return 0 or an error code */ GIT_EXTERN(int) git_blob_lookup_prefix(git_blob **blob, git_repository *repo, const git_oid *id, size_t len); /** * Close an open blob * * This is a wrapper around git_object_free() * * IMPORTANT: * It *is* necessary to call this method when you stop * using a blob. Failure to do so will cause a memory leak. * * @param blob the blob to close */ GIT_EXTERN(void) git_blob_free(git_blob *blob); /** * Get the id of a blob. * * @param blob a previously loaded blob. * @return SHA1 hash for this blob. */ GIT_EXTERN(const git_oid *) git_blob_id(const git_blob *blob); /** * Get the repository that contains the blob. * * @param blob A previously loaded blob. * @return Repository that contains this blob. */ GIT_EXTERN(git_repository *) git_blob_owner(const git_blob *blob); /** * Get a read-only buffer with the raw content of a blob. * * A pointer to the raw content of a blob is returned; * this pointer is owned internally by the object and shall * not be free'd. The pointer may be invalidated at a later * time. * * @param blob pointer to the blob * @return the pointer */ GIT_EXTERN(const void *) git_blob_rawcontent(const git_blob *blob); /** * Get the size in bytes of the contents of a blob * * @param blob pointer to the blob * @return size on bytes */ GIT_EXTERN(git_off_t) git_blob_rawsize(const git_blob *blob); /** * Get a buffer with the filtered content of a blob. * * This applies filters as if the blob was being checked out to the * working directory under the specified filename. This may apply * CRLF filtering or other types of changes depending on the file * attributes set for the blob and the content detected in it. * * The output is written into a `git_buf` which the caller must free * when done (via `git_buf_free`). * * If no filters need to be applied, then the `out` buffer will just * be populated with a pointer to the raw content of the blob. In * that case, be careful to *not* free the blob until done with the * buffer or copy it into memory you own. * * @param out The git_buf to be filled in * @param blob Pointer to the blob * @param as_path Path used for file attribute lookups, etc. * @param check_for_binary_data Should this test if blob content contains * NUL bytes / looks like binary data before applying filters? * @return 0 on success or an error code */ GIT_EXTERN(int) git_blob_filtered_content( git_buf *out, git_blob *blob, const char *as_path, int check_for_binary_data); /** * Read a file from the working folder of a repository * and write it to the Object Database as a loose blob * * @param id return the id of the written blob * @param repo repository where the blob will be written. * this repository cannot be bare * @param relative_path file from which the blob will be created, * relative to the repository's working dir * @return 0 or an error code */ GIT_EXTERN(int) git_blob_create_fromworkdir(git_oid *id, git_repository *repo, const char *relative_path); /** * Read a file from the filesystem and write its content * to the Object Database as a loose blob * * @param id return the id of the written blob * @param repo repository where the blob will be written. * this repository can be bare or not * @param path file from which the blob will be created * @return 0 or an error code */ GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *id, git_repository *repo, const char *path); typedef int (*git_blob_chunk_cb)(char *content, size_t max_length, void *payload); /** * Write a loose blob to the Object Database from a * provider of chunks of data. * * If the `hintpath` parameter is filled, it will be used to determine * what git filters should be applied to the object before it is written * to the object database. * * The implementation of the callback MUST respect the following rules: * * - `content` must be filled by the callback. The maximum number of * bytes that the buffer can accept per call is defined by the * `max_length` parameter. Allocation and freeing of the buffer will * be taken care of by libgit2. * * - The `callback` must return the number of bytes that have been * written to the `content` buffer. * * - When there is no more data to stream, `callback` should return * 0. This will prevent it from being invoked anymore. * * - If an error occurs, the callback should return a negative value. * This value will be returned to the caller. * * @param id Return the id of the written blob * @param repo Repository where the blob will be written. * This repository can be bare or not. * @param hintpath If not NULL, will be used to select data filters * to apply onto the content of the blob to be created. * @return 0 or error code (from either libgit2 or callback function) */ GIT_EXTERN(int) git_blob_create_fromchunks( git_oid *id, git_repository *repo, const char *hintpath, git_blob_chunk_cb callback, void *payload); /** * Write an in-memory buffer to the ODB as a blob * * @param id return the id of the written blob * @param repo repository where to blob will be written * @param buffer data to be written into the blob * @param len length of the data * @return 0 or an error code */ GIT_EXTERN(int) git_blob_create_frombuffer( git_oid *id, git_repository *repo, const void *buffer, size_t len); /** * Determine if the blob content is most certainly binary or not. * * The heuristic used to guess if a file is binary is taken from core git: * Searching for NUL bytes and looking for a reasonable ratio of printable * to non-printable characters among the first 8000 bytes. * * @param blob The blob which content should be analyzed * @return 1 if the content of the blob is detected * as binary; 0 otherwise. */ GIT_EXTERN(int) git_blob_is_binary(const git_blob *blob); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/buffer.h0000664000175000017500000001020712510265101017006 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_buf_h__ #define INCLUDE_git_buf_h__ #include "common.h" /** * @file git2/buffer.h * @brief Buffer export structure * * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * A data buffer for exporting data from libgit2 * * Sometimes libgit2 wants to return an allocated data buffer to the * caller and have the caller take responsibility for freeing that memory. * This can be awkward if the caller does not have easy access to the same * allocation functions that libgit2 is using. In those cases, libgit2 * will fill in a `git_buf` and the caller can use `git_buf_free()` to * release it when they are done. * * A `git_buf` may also be used for the caller to pass in a reference to * a block of memory they hold. In this case, libgit2 will not resize or * free the memory, but will read from it as needed. * * A `git_buf` is a public structure with three fields: * * - `ptr` points to the start of the allocated memory. If it is NULL, * then the `git_buf` is considered empty and libgit2 will feel free * to overwrite it with new data. * * - `size` holds the size (in bytes) of the data that is actually used. * * - `asize` holds the known total amount of allocated memory if the `ptr` * was allocated by libgit2. It may be larger than `size`. If `ptr` * was not allocated by libgit2 and should not be resized and/or freed, * then `asize` will be set to zero. * * Some APIs may occasionally do something slightly unusual with a buffer, * such as setting `ptr` to a value that was passed in by the user. In * those cases, the behavior will be clearly documented by the API. */ typedef struct { char *ptr; size_t asize, size; } git_buf; /** * Static initializer for git_buf from static buffer */ #define GIT_BUF_INIT_CONST(STR,LEN) { (char *)(STR), 0, (size_t)(LEN) } /** * Free the memory referred to by the git_buf. * * Note that this does not free the `git_buf` itself, just the memory * pointed to by `buffer->ptr`. This will not free the memory if it looks * like it was not allocated internally, but it will clear the buffer back * to the empty state. * * @param buffer The buffer to deallocate */ GIT_EXTERN(void) git_buf_free(git_buf *buffer); /** * Resize the buffer allocation to make more space. * * This will attempt to grow the buffer to accommodate the target size. * * If the buffer refers to memory that was not allocated by libgit2 (i.e. * the `asize` field is zero), then `ptr` will be replaced with a newly * allocated block of data. Be careful so that memory allocated by the * caller is not lost. As a special variant, if you pass `target_size` as * 0 and the memory is not allocated by libgit2, this will allocate a new * buffer of size `size` and copy the external data into it. * * Currently, this will never shrink a buffer, only expand it. * * If the allocation fails, this will return an error and the buffer will be * marked as invalid for future operations, invaliding the contents. * * @param buffer The buffer to be resized; may or may not be allocated yet * @param target_size The desired available size * @return 0 on success, -1 on allocation failure */ GIT_EXTERN(int) git_buf_grow(git_buf *buffer, size_t target_size); /** * Set buffer to a copy of some raw data. * * @param buffer The buffer to set * @param data The data to copy into the buffer * @param datalen The length of the data to copy into the buffer * @return 0 on success, -1 on allocation failure */ GIT_EXTERN(int) git_buf_set( git_buf *buffer, const void *data, size_t datalen); /** * Check quickly if buffer looks like it contains binary data * * @param buf Buffer to check * @return 1 if buffer looks like non-text data */ GIT_EXTERN(int) git_buf_is_binary(const git_buf *buf); /** * Check quickly if buffer contains a NUL byte * * @param buf Buffer to check * @return 1 if buffer contains a NUL byte */ GIT_EXTERN(int) git_buf_contains_nul(const git_buf *buf); GIT_END_DECL /** @} */ #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/submodule.h0000664000175000017500000005566612555730137017575 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_submodule_h__ #define INCLUDE_git_submodule_h__ #include "common.h" #include "types.h" #include "oid.h" #include "remote.h" #include "checkout.h" /** * @file git2/submodule.h * @brief Git submodule management utilities * * Submodule support in libgit2 builds a list of known submodules and keeps * it in the repository. The list is built from the .gitmodules file, the * .git/config file, the index, and the HEAD tree. Items in the working * directory that look like submodules (i.e. a git repo) but are not * mentioned in those places won't be tracked. * * @defgroup git_submodule Git submodule management routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Return codes for submodule status. * * A combination of these flags will be returned to describe the status of a * submodule. Depending on the "ignore" property of the submodule, some of * the flags may never be returned because they indicate changes that are * supposed to be ignored. * * Submodule info is contained in 4 places: the HEAD tree, the index, config * files (both .git/config and .gitmodules), and the working directory. Any * or all of those places might be missing information about the submodule * depending on what state the repo is in. We consider all four places to * build the combination of status flags. * * There are four values that are not really status, but give basic info * about what sources of submodule data are available. These will be * returned even if ignore is set to "ALL". * * * IN_HEAD - superproject head contains submodule * * IN_INDEX - superproject index contains submodule * * IN_CONFIG - superproject gitmodules has submodule * * IN_WD - superproject workdir has submodule * * The following values will be returned so long as ignore is not "ALL". * * * INDEX_ADDED - in index, not in head * * INDEX_DELETED - in head, not in index * * INDEX_MODIFIED - index and head don't match * * WD_UNINITIALIZED - workdir contains empty directory * * WD_ADDED - in workdir, not index * * WD_DELETED - in index, not workdir * * WD_MODIFIED - index and workdir head don't match * * The following can only be returned if ignore is "NONE" or "UNTRACKED". * * * WD_INDEX_MODIFIED - submodule workdir index is dirty * * WD_WD_MODIFIED - submodule workdir has modified files * * Lastly, the following will only be returned for ignore "NONE". * * * WD_UNTRACKED - wd contains untracked files */ typedef enum { GIT_SUBMODULE_STATUS_IN_HEAD = (1u << 0), GIT_SUBMODULE_STATUS_IN_INDEX = (1u << 1), GIT_SUBMODULE_STATUS_IN_CONFIG = (1u << 2), GIT_SUBMODULE_STATUS_IN_WD = (1u << 3), GIT_SUBMODULE_STATUS_INDEX_ADDED = (1u << 4), GIT_SUBMODULE_STATUS_INDEX_DELETED = (1u << 5), GIT_SUBMODULE_STATUS_INDEX_MODIFIED = (1u << 6), GIT_SUBMODULE_STATUS_WD_UNINITIALIZED = (1u << 7), GIT_SUBMODULE_STATUS_WD_ADDED = (1u << 8), GIT_SUBMODULE_STATUS_WD_DELETED = (1u << 9), GIT_SUBMODULE_STATUS_WD_MODIFIED = (1u << 10), GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED = (1u << 11), GIT_SUBMODULE_STATUS_WD_WD_MODIFIED = (1u << 12), GIT_SUBMODULE_STATUS_WD_UNTRACKED = (1u << 13), } git_submodule_status_t; #define GIT_SUBMODULE_STATUS__IN_FLAGS 0x000Fu #define GIT_SUBMODULE_STATUS__INDEX_FLAGS 0x0070u #define GIT_SUBMODULE_STATUS__WD_FLAGS 0x3F80u #define GIT_SUBMODULE_STATUS_IS_UNMODIFIED(S) \ (((S) & ~GIT_SUBMODULE_STATUS__IN_FLAGS) == 0) #define GIT_SUBMODULE_STATUS_IS_INDEX_UNMODIFIED(S) \ (((S) & GIT_SUBMODULE_STATUS__INDEX_FLAGS) == 0) #define GIT_SUBMODULE_STATUS_IS_WD_UNMODIFIED(S) \ (((S) & (GIT_SUBMODULE_STATUS__WD_FLAGS & \ ~GIT_SUBMODULE_STATUS_WD_UNINITIALIZED)) == 0) #define GIT_SUBMODULE_STATUS_IS_WD_DIRTY(S) \ (((S) & (GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED | \ GIT_SUBMODULE_STATUS_WD_WD_MODIFIED | \ GIT_SUBMODULE_STATUS_WD_UNTRACKED)) != 0) /** * Submodule update options structure * * Use the GIT_SUBMODULE_UPDATE_OPTIONS_INIT to get the default settings, * like this: * * git_submodule_update_options opts = GIT_SUBMODULE_UPDATE_OPTIONS_INIT; */ typedef struct git_submodule_update_options { unsigned int version; /** * These options are passed to the checkout step. To disable * checkout, set the `checkout_strategy` to * `GIT_CHECKOUT_NONE`. Generally you will want the use * GIT_CHECKOUT_SAFE to update files in the working * directory. Use the `clone_checkout_strategy` field * to set the checkout strategy that will be used in * the case where update needs to clone the repository. */ git_checkout_options checkout_opts; /** * Options which control the fetch, including callbacks. * * The callbacks to use for reporting fetch progress, and for acquiring * credentials in the event they are needed. */ git_fetch_options fetch_opts; /** * The checkout strategy to use when the sub repository needs to * be cloned. Use GIT_CHECKOUT_SAFE to create all files * in the working directory for the newly cloned repository. */ unsigned int clone_checkout_strategy; } git_submodule_update_options; #define GIT_SUBMODULE_UPDATE_OPTIONS_VERSION 1 #define GIT_SUBMODULE_UPDATE_OPTIONS_INIT \ { GIT_CHECKOUT_OPTIONS_VERSION, \ { GIT_CHECKOUT_OPTIONS_VERSION, GIT_CHECKOUT_SAFE }, \ GIT_FETCH_OPTIONS_INIT, GIT_CHECKOUT_SAFE } /** * Initializes a `git_submodule_update_options` with default values. * Equivalent to creating an instance with GIT_SUBMODULE_UPDATE_OPTIONS_INIT. * * @param opts The `git_submodule_update_options` instance to initialize. * @param version Version of struct; pass `GIT_SUBMODULE_UPDATE_OPTIONS_VERSION` * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_submodule_update_init_options( git_submodule_update_options *opts, unsigned int version); /** * Update a submodule. This will clone a missing submodule and * checkout the subrepository to the commit specified in the index of * containing repository. * * @param submodule Submodule object * @param init If the submodule is not initialized, setting this flag to true * will initialize the submodule before updating. Otherwise, this will * return an error if attempting to update an uninitialzed repository. * but setting this to true forces them to be updated. * @param options configuration options for the update. If NULL, the * function works as though GIT_SUBMODULE_UPDATE_OPTIONS_INIT was passed. * @return 0 on success, any non-zero return value from a callback * function, or a negative value to indicate an error (use * `giterr_last` for a detailed error message). */ GIT_EXTERN(int) git_submodule_update(git_submodule *submodule, int init, git_submodule_update_options *options); /** * Lookup submodule information by name or path. * * Given either the submodule name or path (they are usually the same), this * returns a structure describing the submodule. * * There are two expected error scenarios: * * - The submodule is not mentioned in the HEAD, the index, and the config, * but does "exist" in the working directory (i.e. there is a subdirectory * that appears to be a Git repository). In this case, this function * returns GIT_EEXISTS to indicate a sub-repository exists but not in a * state where a git_submodule can be instantiated. * - The submodule is not mentioned in the HEAD, index, or config and the * working directory doesn't contain a value git repo at that path. * There may or may not be anything else at that path, but nothing that * looks like a submodule. In this case, this returns GIT_ENOTFOUND. * * You must call `git_submodule_free` when done with the submodule. * * @param out Output ptr to submodule; pass NULL to just get return code * @param repo The parent repository * @param name The name of or path to the submodule; trailing slashes okay * @return 0 on success, GIT_ENOTFOUND if submodule does not exist, * GIT_EEXISTS if a repository is found in working directory only, * -1 on other errors. */ GIT_EXTERN(int) git_submodule_lookup( git_submodule **out, git_repository *repo, const char *name); /** * Release a submodule * * @param submodule Submodule object */ GIT_EXTERN(void) git_submodule_free(git_submodule *submodule); /** * Iterate over all tracked submodules of a repository. * * See the note on `git_submodule` above. This iterates over the tracked * submodules as described therein. * * If you are concerned about items in the working directory that look like * submodules but are not tracked, the diff API will generate a diff record * for workdir items that look like submodules but are not tracked, showing * them as added in the workdir. Also, the status API will treat the entire * subdirectory of a contained git repo as a single GIT_STATUS_WT_NEW item. * * @param repo The repository * @param callback Function to be called with the name of each submodule. * Return a non-zero value to terminate the iteration. * @param payload Extra data to pass to callback * @return 0 on success, -1 on error, or non-zero return value of callback */ GIT_EXTERN(int) git_submodule_foreach( git_repository *repo, int (*callback)(git_submodule *sm, const char *name, void *payload), void *payload); /** * Set up a new git submodule for checkout. * * This does "git submodule add" up to the fetch and checkout of the * submodule contents. It preps a new submodule, creates an entry in * .gitmodules and creates an empty initialized repository either at the * given path in the working directory or in .git/modules with a gitlink * from the working directory to the new repo. * * To fully emulate "git submodule add" call this function, then open the * submodule repo and perform the clone step as needed. Lastly, call * `git_submodule_add_finalize()` to wrap up adding the new submodule and * .gitmodules to the index to be ready to commit. * * You must call `git_submodule_free` on the submodule object when done. * * @param out The newly created submodule ready to open for clone * @param repo The repository in which you want to create the submodule * @param url URL for the submodule's remote * @param path Path at which the submodule should be created * @param use_gitlink Should workdir contain a gitlink to the repo in * .git/modules vs. repo directly in workdir. * @return 0 on success, GIT_EEXISTS if submodule already exists, * -1 on other errors. */ GIT_EXTERN(int) git_submodule_add_setup( git_submodule **out, git_repository *repo, const char *url, const char *path, int use_gitlink); /** * Resolve the setup of a new git submodule. * * This should be called on a submodule once you have called add setup * and done the clone of the submodule. This adds the .gitmodules file * and the newly cloned submodule to the index to be ready to be committed * (but doesn't actually do the commit). * * @param submodule The submodule to finish adding. */ GIT_EXTERN(int) git_submodule_add_finalize(git_submodule *submodule); /** * Add current submodule HEAD commit to index of superproject. * * @param submodule The submodule to add to the index * @param write_index Boolean if this should immediately write the index * file. If you pass this as false, you will have to get the * git_index and explicitly call `git_index_write()` on it to * save the change. * @return 0 on success, <0 on failure */ GIT_EXTERN(int) git_submodule_add_to_index( git_submodule *submodule, int write_index); /** * Get the containing repository for a submodule. * * This returns a pointer to the repository that contains the submodule. * This is a just a reference to the repository that was passed to the * original `git_submodule_lookup()` call, so if that repository has been * freed, then this may be a dangling reference. * * @param submodule Pointer to submodule object * @return Pointer to `git_repository` */ GIT_EXTERN(git_repository *) git_submodule_owner(git_submodule *submodule); /** * Get the name of submodule. * * @param submodule Pointer to submodule object * @return Pointer to the submodule name */ GIT_EXTERN(const char *) git_submodule_name(git_submodule *submodule); /** * Get the path to the submodule. * * The path is almost always the same as the submodule name, but the * two are actually not required to match. * * @param submodule Pointer to submodule object * @return Pointer to the submodule path */ GIT_EXTERN(const char *) git_submodule_path(git_submodule *submodule); /** * Get the URL for the submodule. * * @param submodule Pointer to submodule object * @return Pointer to the submodule url */ GIT_EXTERN(const char *) git_submodule_url(git_submodule *submodule); /** * Resolve a submodule url relative to the given repository. * * @param out buffer to store the absolute submodule url in * @param repo Pointer to repository object * @param url Relative url * @return 0 or an error code */ GIT_EXTERN(int) git_submodule_resolve_url(git_buf *out, git_repository *repo, const char *url); /** * Get the branch for the submodule. * * @param submodule Pointer to submodule object * @return Pointer to the submodule branch */ GIT_EXTERN(const char *) git_submodule_branch(git_submodule *submodule); /** * Set the branch for the submodule in the configuration * * After calling this, you may wish to call `git_submodule_sync()` to * write the changes to the checked out submodule repository. * * @param repo the repository to affect * @param name the name of the submodule to configure * @param branch Branch that should be used for the submodule * @return 0 on success, <0 on failure */ GIT_EXTERN(int) git_submodule_set_branch(git_repository *repo, const char *name, const char *branch); /** * Set the URL for the submodule in the configuration * * * After calling this, you may wish to call `git_submodule_sync()` to * write the changes to the checked out submodule repository. * * @param repo the repository to affect * @param name the name of the submodule to configure * @param url URL that should be used for the submodule * @return 0 on success, <0 on failure */ GIT_EXTERN(int) git_submodule_set_url(git_repository *repo, const char *name, const char *url); /** * Get the OID for the submodule in the index. * * @param submodule Pointer to submodule object * @return Pointer to git_oid or NULL if submodule is not in index. */ GIT_EXTERN(const git_oid *) git_submodule_index_id(git_submodule *submodule); /** * Get the OID for the submodule in the current HEAD tree. * * @param submodule Pointer to submodule object * @return Pointer to git_oid or NULL if submodule is not in the HEAD. */ GIT_EXTERN(const git_oid *) git_submodule_head_id(git_submodule *submodule); /** * Get the OID for the submodule in the current working directory. * * This returns the OID that corresponds to looking up 'HEAD' in the checked * out submodule. If there are pending changes in the index or anything * else, this won't notice that. You should call `git_submodule_status()` * for a more complete picture about the state of the working directory. * * @param submodule Pointer to submodule object * @return Pointer to git_oid or NULL if submodule is not checked out. */ GIT_EXTERN(const git_oid *) git_submodule_wd_id(git_submodule *submodule); /** * Get the ignore rule that will be used for the submodule. * * These values control the behavior of `git_submodule_status()` for this * submodule. There are four ignore values: * * - **GIT_SUBMODULE_IGNORE_NONE** will consider any change to the contents * of the submodule from a clean checkout to be dirty, including the * addition of untracked files. This is the default if unspecified. * - **GIT_SUBMODULE_IGNORE_UNTRACKED** examines the contents of the * working tree (i.e. call `git_status_foreach()` on the submodule) but * UNTRACKED files will not count as making the submodule dirty. * - **GIT_SUBMODULE_IGNORE_DIRTY** means to only check if the HEAD of the * submodule has moved for status. This is fast since it does not need to * scan the working tree of the submodule at all. * - **GIT_SUBMODULE_IGNORE_ALL** means not to open the submodule repo. * The working directory will be consider clean so long as there is a * checked out version present. * * @param submodule The submodule to check * @return The current git_submodule_ignore_t valyue what will be used for * this submodule. */ GIT_EXTERN(git_submodule_ignore_t) git_submodule_ignore( git_submodule *submodule); /** * Set the ignore rule for the submodule in the configuration * * This does not affect any currently-loaded instances. * * @param repo the repository to affect * @param name the name of the submdule * @param ignore The new value for the ignore rule * @return 0 or an error code */ GIT_EXTERN(int) git_submodule_set_ignore( git_repository *repo, const char *name, git_submodule_ignore_t ignore); /** * Get the update rule that will be used for the submodule. * * This value controls the behavior of the `git submodule update` command. * There are four useful values documented with `git_submodule_update_t`. * * @param submodule The submodule to check * @return The current git_submodule_update_t value that will be used * for this submodule. */ GIT_EXTERN(git_submodule_update_t) git_submodule_update_strategy( git_submodule *submodule); /** * Set the update rule for the submodule in the configuration * * This setting won't affect any existing instances. * * @param repo the repository to affect * @param name the name of the submodule to configure * @param update The new value to use * @return 0 or an error code */ GIT_EXTERN(int) git_submodule_set_update( git_repository *repo, const char *name, git_submodule_update_t update); /** * Read the fetchRecurseSubmodules rule for a submodule. * * This accesses the submodule..fetchRecurseSubmodules value for * the submodule that controls fetching behavior for the submodule. * * Note that at this time, libgit2 does not honor this setting and the * fetch functionality current ignores submodules. * * @return 0 if fetchRecurseSubmodules is false, 1 if true */ GIT_EXTERN(git_submodule_recurse_t) git_submodule_fetch_recurse_submodules( git_submodule *submodule); /** * Set the fetchRecurseSubmodules rule for a submodule in the configuration * * This setting won't affect any existing instances. * * @param repo the repository to affect * @param name the submodule to configure * @param fetch_recurse_submodules Boolean value * @return old value for fetchRecurseSubmodules */ GIT_EXTERN(int) git_submodule_set_fetch_recurse_submodules( git_repository *repo, const char *name, git_submodule_recurse_t fetch_recurse_submodules); /** * Copy submodule info into ".git/config" file. * * Just like "git submodule init", this copies information about the * submodule into ".git/config". You can use the accessor functions * above to alter the in-memory git_submodule object and control what * is written to the config, overriding what is in .gitmodules. * * @param submodule The submodule to write into the superproject config * @param overwrite By default, existing entries will not be overwritten, * but setting this to true forces them to be updated. * @return 0 on success, <0 on failure. */ GIT_EXTERN(int) git_submodule_init(git_submodule *submodule, int overwrite); /** * Set up the subrepository for a submodule in preparation for clone. * * This function can be called to init and set up a submodule * repository from a submodule in preparation to clone it from * its remote. * * @param out Output pointer to the created git repository. * @param sm The submodule to create a new subrepository from. * @param use_gitlink Should the workdir contain a gitlink to * the repo in .git/modules vs. repo directly in workdir. * @return 0 on success, <0 on failure. */ GIT_EXTERN(int) git_submodule_repo_init( git_repository **out, const git_submodule *sm, int use_gitlink); /** * Copy submodule remote info into submodule repo. * * This copies the information about the submodules URL into the checked out * submodule config, acting like "git submodule sync". This is useful if * you have altered the URL for the submodule (or it has been altered by a * fetch of upstream changes) and you need to update your local repo. */ GIT_EXTERN(int) git_submodule_sync(git_submodule *submodule); /** * Open the repository for a submodule. * * This is a newly opened repository object. The caller is responsible for * calling `git_repository_free()` on it when done. Multiple calls to this * function will return distinct `git_repository` objects. This will only * work if the submodule is checked out into the working directory. * * @param repo Pointer to the submodule repo which was opened * @param submodule Submodule to be opened * @return 0 on success, <0 if submodule repo could not be opened. */ GIT_EXTERN(int) git_submodule_open( git_repository **repo, git_submodule *submodule); /** * Reread submodule info from config, index, and HEAD. * * Call this to reread cached submodule information for this submodule if * you have reason to believe that it has changed. * * @param submodule The submodule to reload * @param force Force reload even if the data doesn't seem out of date * @return 0 on success, <0 on error */ GIT_EXTERN(int) git_submodule_reload(git_submodule *submodule, int force); /** * Get the status for a submodule. * * This looks at a submodule and tries to determine the status. It * will return a combination of the `GIT_SUBMODULE_STATUS` values above. * How deeply it examines the working directory to do this will depend * on the `git_submodule_ignore_t` value for the submodule. * * @param status Combination of `GIT_SUBMODULE_STATUS` flags * @param repo the repository in which to look * @param name name of the submodule * @param ignore the ignore rules to follow * @return 0 on success, <0 on error */ GIT_EXTERN(int) git_submodule_status( unsigned int *status, git_repository *repo, const char *name, git_submodule_ignore_t ignore); /** * Get the locations of submodule information. * * This is a bit like a very lightweight version of `git_submodule_status`. * It just returns a made of the first four submodule status values (i.e. * the ones like GIT_SUBMODULE_STATUS_IN_HEAD, etc) that tell you where the * submodule data comes from (i.e. the HEAD commit, gitmodules file, etc.). * This can be useful if you want to know if the submodule is present in the * working directory at this point in time, etc. * * @param location_status Combination of first four `GIT_SUBMODULE_STATUS` flags * @param submodule Submodule for which to get status * @return 0 on success, <0 on error */ GIT_EXTERN(int) git_submodule_location( unsigned int *location_status, git_submodule *submodule); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/sys/0000755000000000000000000000000012666635520020000 5ustar rootrootdeps/libgit2-sys-0.3.8/libgit2/include/git2/sys/config.h0000664000175000017500000000761212572105236017640 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sys_git_config_backend_h__ #define INCLUDE_sys_git_config_backend_h__ #include "git2/common.h" #include "git2/types.h" #include "git2/config.h" /** * @file git2/sys/config.h * @brief Git config backend routines * @defgroup git_backend Git custom backend APIs * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Every iterator must have this struct as its first element, so the * API can talk to it. You'd define your iterator as * * struct my_iterator { * git_config_iterator parent; * ... * } * * and assign `iter->parent.backend` to your `git_config_backend`. */ struct git_config_iterator { git_config_backend *backend; unsigned int flags; /** * Return the current entry and advance the iterator. The * memory belongs to the library. */ int (*next)(git_config_entry **entry, git_config_iterator *iter); /** * Free the iterator */ void (*free)(git_config_iterator *iter); }; /** * Generic backend that implements the interface to * access a configuration file */ struct git_config_backend { unsigned int version; /** True if this backend is for a snapshot */ int readonly; struct git_config *cfg; /* Open means open the file/database and parse if necessary */ int (*open)(struct git_config_backend *, git_config_level_t level); int (*get)(struct git_config_backend *, const char *key, git_config_entry **entry); int (*set)(struct git_config_backend *, const char *key, const char *value); int (*set_multivar)(git_config_backend *cfg, const char *name, const char *regexp, const char *value); int (*del)(struct git_config_backend *, const char *key); int (*del_multivar)(struct git_config_backend *, const char *key, const char *regexp); int (*iterator)(git_config_iterator **, struct git_config_backend *); /** Produce a read-only version of this backend */ int (*snapshot)(struct git_config_backend **, struct git_config_backend *); /** * Lock this backend. * * Prevent any writes to the data store backing this * backend. Any updates must not be visible to any other * readers. */ int (*lock)(struct git_config_backend *); /** * Unlock the data store backing this backend. If success is * true, the changes should be committed, otherwise rolled * back. */ int (*unlock)(struct git_config_backend *, int success); void (*free)(struct git_config_backend *); }; #define GIT_CONFIG_BACKEND_VERSION 1 #define GIT_CONFIG_BACKEND_INIT {GIT_CONFIG_BACKEND_VERSION} /** * Initializes a `git_config_backend` with default values. Equivalent to * creating an instance with GIT_CONFIG_BACKEND_INIT. * * @param backend the `git_config_backend` struct to initialize. * @param version Version of struct; pass `GIT_CONFIG_BACKEND_VERSION` * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_config_init_backend( git_config_backend *backend, unsigned int version); /** * Add a generic config file instance to an existing config * * Note that the configuration object will free the file * automatically. * * Further queries on this config object will access each * of the config file instances in order (instances with * a higher priority level will be accessed first). * * @param cfg the configuration to add the file to * @param file the configuration file (backend) to add * @param level the priority level of the backend * @param force if a config file already exists for the given * priority level, replace it * @return 0 on success, GIT_EEXISTS when adding more than one file * for a given priority level (and force_replace set to 0), or error code */ GIT_EXTERN(int) git_config_add_backend( git_config *cfg, git_config_backend *file, git_config_level_t level, int force); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/sys/mempack.h0000664000175000017500000000522212510265101017771 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sys_git_odb_mempack_h__ #define INCLUDE_sys_git_odb_mempack_h__ #include "git2/common.h" #include "git2/types.h" #include "git2/oid.h" #include "git2/odb.h" /** * @file git2/sys/mempack.h * @brief Custom ODB backend that permits packing objects in-memory * @defgroup git_backend Git custom backend APIs * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Instantiate a new mempack backend. * * The backend must be added to an existing ODB with the highest * priority. * * git_mempack_new(&mempacker); * git_repository_odb(&odb, repository); * git_odb_add_backend(odb, mempacker, 999); * * Once the backend has been loaded, all writes to the ODB will * instead be queued in memory, and can be finalized with * `git_mempack_dump`. * * Subsequent reads will also be served from the in-memory store * to ensure consistency, until the memory store is dumped. * * @param out Poiter where to store the ODB backend * @return 0 on success; error code otherwise */ int git_mempack_new(git_odb_backend **out); /** * Dump all the queued in-memory writes to a packfile. * * The contents of the packfile will be stored in the given buffer. * It is the caller's responsibility to ensure that the generated * packfile is available to the repository (e.g. by writing it * to disk, or doing something crazy like distributing it across * several copies of the repository over a network). * * Once the generated packfile is available to the repository, * call `git_mempack_reset` to cleanup the memory store. * * Calling `git_mempack_reset` before the packfile has been * written to disk will result in an inconsistent repository * (the objects in the memory store won't be accessible). * * @param pack Buffer where to store the raw packfile * @param repo The active repository where the backend is loaded * @param backend The mempack backend * @return 0 on success; error code otherwise */ int git_mempack_dump(git_buf *pack, git_repository *repo, git_odb_backend *backend); /** * Reset the memory packer by clearing all the queued objects. * * This assumes that `git_mempack_dump` has been called before to * store all the queued objects into a single packfile. * * Alternatively, call `reset` without a previous dump to "undo" * all the recently written objects, giving transaction-like * semantics to the Git repository. * * @param backend The mempack backend */ void git_mempack_reset(git_odb_backend *backend); GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/sys/repository.h0000664000175000017500000001053012510265101020571 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sys_git_repository_h__ #define INCLUDE_sys_git_repository_h__ #include "git2/common.h" #include "git2/types.h" /** * @file git2/sys/repository.h * @brief Git repository custom implementation routines * @defgroup git_backend Git custom backend APIs * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Create a new repository with neither backends nor config object * * Note that this is only useful if you wish to associate the repository * with a non-filesystem-backed object database and config store. * * @param out The blank repository * @return 0 on success, or an error code */ GIT_EXTERN(int) git_repository_new(git_repository **out); /** * Reset all the internal state in a repository. * * This will free all the mapped memory and internal objects * of the repository and leave it in a "blank" state. * * There's no need to call this function directly unless you're * trying to aggressively cleanup the repo before its * deallocation. `git_repository_free` already performs this operation * before deallocation the repo. */ GIT_EXTERN(void) git_repository__cleanup(git_repository *repo); /** * Update the filesystem config settings for an open repository * * When a repository is initialized, config values are set based on the * properties of the filesystem that the repository is on, such as * "core.ignorecase", "core.filemode", "core.symlinks", etc. If the * repository is moved to a new filesystem, these properties may no * longer be correct and API calls may not behave as expected. This * call reruns the phase of repository initialization that sets those * properties to compensate for the current filesystem of the repo. * * @param repo A repository object * @param recurse_submodules Should submodules be updated recursively * @return 0 on success, < 0 on error */ GIT_EXTERN(int) git_repository_reinit_filesystem( git_repository *repo, int recurse_submodules); /** * Set the configuration file for this repository * * This configuration file will be used for all configuration * queries involving this repository. * * The repository will keep a reference to the config file; * the user must still free the config after setting it * to the repository, or it will leak. * * @param repo A repository object * @param config A Config object */ GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *config); /** * Set the Object Database for this repository * * The ODB will be used for all object-related operations * involving this repository. * * The repository will keep a reference to the ODB; the user * must still free the ODB object after setting it to the * repository, or it will leak. * * @param repo A repository object * @param odb An ODB object */ GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb); /** * Set the Reference Database Backend for this repository * * The refdb will be used for all reference related operations * involving this repository. * * The repository will keep a reference to the refdb; the user * must still free the refdb object after setting it to the * repository, or it will leak. * * @param repo A repository object * @param refdb An refdb object */ GIT_EXTERN(void) git_repository_set_refdb(git_repository *repo, git_refdb *refdb); /** * Set the index file for this repository * * This index will be used for all index-related operations * involving this repository. * * The repository will keep a reference to the index file; * the user must still free the index after setting it * to the repository, or it will leak. * * @param repo A repository object * @param index An index object */ GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index); /** * Set a repository to be bare. * * Clear the working directory and set core.bare to true. You may also * want to call `git_repository_set_index(repo, NULL)` since a bare repo * typically does not have an index, but this function will not do that * for you. * * @param repo Repo to make bare * @return 0 on success, <0 on failure */ GIT_EXTERN(int) git_repository_set_bare(git_repository *repo); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/sys/odb_backend.h0000664000175000017500000000652312610310643020577 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sys_git_odb_backend_h__ #define INCLUDE_sys_git_odb_backend_h__ #include "git2/common.h" #include "git2/types.h" #include "git2/oid.h" #include "git2/odb.h" /** * @file git2/sys/backend.h * @brief Git custom backend implementors functions * @defgroup git_backend Git custom backend APIs * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * An instance for a custom backend */ struct git_odb_backend { unsigned int version; git_odb *odb; /* read and read_prefix each return to libgit2 a buffer which * will be freed later. The buffer should be allocated using * the function git_odb_backend_malloc to ensure that it can * be safely freed later. */ int (* read)( void **, size_t *, git_otype *, git_odb_backend *, const git_oid *); /* To find a unique object given a prefix of its oid. The oid given * must be so that the remaining (GIT_OID_HEXSZ - len)*4 bits are 0s. */ int (* read_prefix)( git_oid *, void **, size_t *, git_otype *, git_odb_backend *, const git_oid *, size_t); int (* read_header)( size_t *, git_otype *, git_odb_backend *, const git_oid *); /** * Write an object into the backend. The id of the object has * already been calculated and is passed in. */ int (* write)( git_odb_backend *, const git_oid *, const void *, size_t, git_otype); int (* writestream)( git_odb_stream **, git_odb_backend *, git_off_t, git_otype); int (* readstream)( git_odb_stream **, git_odb_backend *, const git_oid *); int (* exists)( git_odb_backend *, const git_oid *); int (* exists_prefix)( git_oid *, git_odb_backend *, const git_oid *, size_t); /** * If the backend implements a refreshing mechanism, it should be exposed * through this endpoint. Each call to `git_odb_refresh()` will invoke it. * * However, the backend implementation should try to stay up-to-date as much * as possible by itself as libgit2 will not automatically invoke * `git_odb_refresh()`. For instance, a potential strategy for the backend * implementation to achieve this could be to internally invoke this * endpoint on failed lookups (ie. `exists()`, `read()`, `read_header()`). */ int (* refresh)(git_odb_backend *); int (* foreach)( git_odb_backend *, git_odb_foreach_cb cb, void *payload); int (* writepack)( git_odb_writepack **, git_odb_backend *, git_odb *odb, git_transfer_progress_cb progress_cb, void *progress_payload); /** * Frees any resources held by the odb (including the `git_odb_backend` * itself). An odb backend implementation must provide this function. */ void (* free)(git_odb_backend *); }; #define GIT_ODB_BACKEND_VERSION 1 #define GIT_ODB_BACKEND_INIT {GIT_ODB_BACKEND_VERSION} /** * Initializes a `git_odb_backend` with default values. Equivalent to * creating an instance with GIT_ODB_BACKEND_INIT. * * @param backend the `git_odb_backend` struct to initialize. * @param version Version the struct; pass `GIT_ODB_BACKEND_VERSION` * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_odb_init_backend( git_odb_backend *backend, unsigned int version); GIT_EXTERN(void *) git_odb_backend_malloc(git_odb_backend *backend, size_t len); GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/sys/openssl.h0000664000175000017500000000212112510265101020032 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_openssl_h__ #define INCLUDE_git_openssl_h__ #include "git2/common.h" GIT_BEGIN_DECL /** * Initialize the OpenSSL locks * * OpenSSL requires the application to determine how it performs * locking. * * This is a last-resort convenience function which libgit2 provides for * allocating and initializing the locks as well as setting the * locking function to use the system's native locking functions. * * The locking function will be cleared and the memory will be freed * when you call git_threads_sutdown(). * * If your programming language has an OpenSSL package/bindings, it * likely sets up locking. You should very strongly prefer that over * this function. * * @return 0 on success, -1 if there are errors or if libgit2 was not * built with OpenSSL and threading support. */ GIT_EXTERN(int) git_openssl_set_locking(void); GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/sys/filter.h0000664000175000017500000002501712572105236017657 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sys_git_filter_h__ #define INCLUDE_sys_git_filter_h__ #include "git2/filter.h" /** * @file git2/sys/filter.h * @brief Git filter backend and plugin routines * @defgroup git_backend Git custom backend APIs * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Look up a filter by name * * @param name The name of the filter * @return Pointer to the filter object or NULL if not found */ GIT_EXTERN(git_filter *) git_filter_lookup(const char *name); #define GIT_FILTER_CRLF "crlf" #define GIT_FILTER_IDENT "ident" /** * This is priority that the internal CRLF filter will be registered with */ #define GIT_FILTER_CRLF_PRIORITY 0 /** * This is priority that the internal ident filter will be registered with */ #define GIT_FILTER_IDENT_PRIORITY 100 /** * This is priority to use with a custom filter to imitate a core Git * filter driver, so that it will be run last on checkout and first on * checkin. You do not have to use this, but it helps compatibility. */ #define GIT_FILTER_DRIVER_PRIORITY 200 /** * Create a new empty filter list * * Normally you won't use this because `git_filter_list_load` will create * the filter list for you, but you can use this in combination with the * `git_filter_lookup` and `git_filter_list_push` functions to assemble * your own chains of filters. */ GIT_EXTERN(int) git_filter_list_new( git_filter_list **out, git_repository *repo, git_filter_mode_t mode, uint32_t options); /** * Add a filter to a filter list with the given payload. * * Normally you won't have to do this because the filter list is created * by calling the "check" function on registered filters when the filter * attributes are set, but this does allow more direct manipulation of * filter lists when desired. * * Note that normally the "check" function can set up a payload for the * filter. Using this function, you can either pass in a payload if you * know the expected payload format, or you can pass NULL. Some filters * may fail with a NULL payload. Good luck! */ GIT_EXTERN(int) git_filter_list_push( git_filter_list *fl, git_filter *filter, void *payload); /** * Look up how many filters are in the list * * We will attempt to apply all of these filters to any data passed in, * but note that the filter apply action still has the option of skipping * data that is passed in (for example, the CRLF filter will skip data * that appears to be binary). * * @param fl A filter list * @return The number of filters in the list */ GIT_EXTERN(size_t) git_filter_list_length(const git_filter_list *fl); /** * A filter source represents a file/blob to be processed */ typedef struct git_filter_source git_filter_source; /** * Get the repository that the source data is coming from. */ GIT_EXTERN(git_repository *) git_filter_source_repo(const git_filter_source *src); /** * Get the path that the source data is coming from. */ GIT_EXTERN(const char *) git_filter_source_path(const git_filter_source *src); /** * Get the file mode of the source file * If the mode is unknown, this will return 0 */ GIT_EXTERN(uint16_t) git_filter_source_filemode(const git_filter_source *src); /** * Get the OID of the source * If the OID is unknown (often the case with GIT_FILTER_CLEAN) then * this will return NULL. */ GIT_EXTERN(const git_oid *) git_filter_source_id(const git_filter_source *src); /** * Get the git_filter_mode_t to be used */ GIT_EXTERN(git_filter_mode_t) git_filter_source_mode(const git_filter_source *src); /** * Get the combination git_filter_flag_t options to be applied */ GIT_EXTERN(uint32_t) git_filter_source_flags(const git_filter_source *src); /* * struct git_filter * * The filter lifecycle: * - initialize - first use of filter * - shutdown - filter removed/unregistered from system * - check - considering filter for file * - apply - apply filter to file contents * - cleanup - done with file */ /** * Initialize callback on filter * * Specified as `filter.initialize`, this is an optional callback invoked * before a filter is first used. It will be called once at most. * * If non-NULL, the filter's `initialize` callback will be invoked right * before the first use of the filter, so you can defer expensive * initialization operations (in case libgit2 is being used in a way that * doesn't need the filter). */ typedef int (*git_filter_init_fn)(git_filter *self); /** * Shutdown callback on filter * * Specified as `filter.shutdown`, this is an optional callback invoked * when the filter is unregistered or when libgit2 is shutting down. It * will be called once at most and should release resources as needed. * This may be called even if the `initialize` callback was not made. * * Typically this function will free the `git_filter` object itself. */ typedef void (*git_filter_shutdown_fn)(git_filter *self); /** * Callback to decide if a given source needs this filter * * Specified as `filter.check`, this is an optional callback that checks * if filtering is needed for a given source. * * It should return 0 if the filter should be applied (i.e. success), * GIT_PASSTHROUGH if the filter should not be applied, or an error code * to fail out of the filter processing pipeline and return to the caller. * * The `attr_values` will be set to the values of any attributes given in * the filter definition. See `git_filter` below for more detail. * * The `payload` will be a pointer to a reference payload for the filter. * This will start as NULL, but `check` can assign to this pointer for * later use by the `apply` callback. Note that the value should be heap * allocated (not stack), so that it doesn't go away before the `apply` * callback can use it. If a filter allocates and assigns a value to the * `payload`, it will need a `cleanup` callback to free the payload. */ typedef int (*git_filter_check_fn)( git_filter *self, void **payload, /* points to NULL ptr on entry, may be set */ const git_filter_source *src, const char **attr_values); /** * Callback to actually perform the data filtering * * Specified as `filter.apply`, this is the callback that actually filters * data. If it successfully writes the output, it should return 0. Like * `check`, it can return GIT_PASSTHROUGH to indicate that the filter * doesn't want to run. Other error codes will stop filter processing and * return to the caller. * * The `payload` value will refer to any payload that was set by the * `check` callback. It may be read from or written to as needed. */ typedef int (*git_filter_apply_fn)( git_filter *self, void **payload, /* may be read and/or set */ git_buf *to, const git_buf *from, const git_filter_source *src); typedef int (*git_filter_stream_fn)( git_writestream **out, git_filter *self, void **payload, const git_filter_source *src, git_writestream *next); /** * Callback to clean up after filtering has been applied * * Specified as `filter.cleanup`, this is an optional callback invoked * after the filter has been applied. If the `check` or `apply` callbacks * allocated a `payload` to keep per-source filter state, use this * callback to free that payload and release resources as required. */ typedef void (*git_filter_cleanup_fn)( git_filter *self, void *payload); /** * Filter structure used to register custom filters. * * To associate extra data with a filter, allocate extra data and put the * `git_filter` struct at the start of your data buffer, then cast the * `self` pointer to your larger structure when your callback is invoked. * * `version` should be set to GIT_FILTER_VERSION * * `attributes` is a whitespace-separated list of attribute names to check * for this filter (e.g. "eol crlf text"). If the attribute name is bare, * it will be simply loaded and passed to the `check` callback. If it has * a value (i.e. "name=value"), the attribute must match that value for * the filter to be applied. The value may be a wildcard (eg, "name=*"), * in which case the filter will be invoked for any value for the given * attribute name. See the attribute parameter of the `check` callback * for the attribute value that was specified. * * The `initialize`, `shutdown`, `check`, `apply`, and `cleanup` callbacks * are all documented above with the respective function pointer typedefs. */ struct git_filter { unsigned int version; const char *attributes; git_filter_init_fn initialize; git_filter_shutdown_fn shutdown; git_filter_check_fn check; git_filter_apply_fn apply; git_filter_stream_fn stream; git_filter_cleanup_fn cleanup; }; #define GIT_FILTER_VERSION 1 /** * Register a filter under a given name with a given priority. * * As mentioned elsewhere, the initialize callback will not be invoked * immediately. It is deferred until the filter is used in some way. * * A filter's attribute checks and `check` and `apply` callbacks will be * issued in order of `priority` on smudge (to workdir), and in reverse * order of `priority` on clean (to odb). * * Two filters are preregistered with libgit2: * - GIT_FILTER_CRLF with priority 0 * - GIT_FILTER_IDENT with priority 100 * * Currently the filter registry is not thread safe, so any registering or * deregistering of filters must be done outside of any possible usage of * the filters (i.e. during application setup or shutdown). * * @param name A name by which the filter can be referenced. Attempting * to register with an in-use name will return GIT_EEXISTS. * @param filter The filter definition. This pointer will be stored as is * by libgit2 so it must be a durable allocation (either static * or on the heap). * @param priority The priority for filter application * @return 0 on successful registry, error code <0 on failure */ GIT_EXTERN(int) git_filter_register( const char *name, git_filter *filter, int priority); /** * Remove the filter with the given name * * Attempting to remove the builtin libgit2 filters is not permitted and * will return an error. * * Currently the filter registry is not thread safe, so any registering or * deregistering of filters must be done outside of any possible usage of * the filters (i.e. during application setup or shutdown). * * @param name The name under which the filter was registered * @return 0 on success, error code <0 on failure */ GIT_EXTERN(int) git_filter_unregister(const char *name); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/sys/stream.h0000664000175000017500000000210512555730137017663 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sys_git_stream_h__ #define INCLUDE_sys_git_stream_h__ #include "git2/common.h" #include "git2/types.h" GIT_BEGIN_DECL #define GIT_STREAM_VERSION 1 /** * Every stream must have this struct as its first element, so the * API can talk to it. You'd define your stream as * * struct my_stream { * git_stream parent; * ... * } * * and fill the functions */ typedef struct git_stream { int version; int encrypted; int proxy_support; int (*connect)(struct git_stream *); int (*certificate)(git_cert **, struct git_stream *); int (*set_proxy)(struct git_stream *, const char *proxy_url); ssize_t (*read)(struct git_stream *, void *, size_t); ssize_t (*write)(struct git_stream *, const char *, size_t, int); int (*close)(struct git_stream *); void (*free)(struct git_stream *); } git_stream; GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/sys/diff.h0000664000175000017500000000561312572105236017302 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sys_git_diff_h__ #define INCLUDE_sys_git_diff_h__ #include "git2/common.h" #include "git2/types.h" #include "git2/oid.h" #include "git2/diff.h" #include "git2/status.h" /** * @file git2/sys/diff.h * @brief Low-level Git diff utilities * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Diff print callback that writes to a git_buf. * * This function is provided not for you to call it directly, but instead * so you can use it as a function pointer to the `git_diff_print` or * `git_patch_print` APIs. When using those APIs, you specify a callback * to actually handle the diff and/or patch data. * * Use this callback to easily write that data to a `git_buf` buffer. You * must pass a `git_buf *` value as the payload to the `git_diff_print` * and/or `git_patch_print` function. The data will be appended to the * buffer (after any existing content). */ GIT_EXTERN(int) git_diff_print_callback__to_buf( const git_diff_delta *delta, const git_diff_hunk *hunk, const git_diff_line *line, void *payload); /**< payload must be a `git_buf *` */ /** * Diff print callback that writes to stdio FILE handle. * * This function is provided not for you to call it directly, but instead * so you can use it as a function pointer to the `git_diff_print` or * `git_patch_print` APIs. When using those APIs, you specify a callback * to actually handle the diff and/or patch data. * * Use this callback to easily write that data to a stdio FILE handle. You * must pass a `FILE *` value (such as `stdout` or `stderr` or the return * value from `fopen()`) as the payload to the `git_diff_print` * and/or `git_patch_print` function. If you pass NULL, this will write * data to `stdout`. */ GIT_EXTERN(int) git_diff_print_callback__to_file_handle( const git_diff_delta *delta, const git_diff_hunk *hunk, const git_diff_line *line, void *payload); /**< payload must be a `FILE *` */ /** * Performance data from diffing */ typedef struct { unsigned int version; size_t stat_calls; /**< Number of stat() calls performed */ size_t oid_calculations; /**< Number of ID calculations */ } git_diff_perfdata; #define GIT_DIFF_PERFDATA_VERSION 1 #define GIT_DIFF_PERFDATA_INIT {GIT_DIFF_PERFDATA_VERSION,0,0} /** * Get performance data for a diff object. * * @param out Structure to be filled with diff performance data * @param diff Diff to read performance data from * @return 0 for success, <0 for error */ GIT_EXTERN(int) git_diff_get_perfdata( git_diff_perfdata *out, const git_diff *diff); /** * Get performance data for diffs from a git_status_list */ GIT_EXTERN(int) git_status_list_get_perfdata( git_diff_perfdata *out, const git_status_list *status); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/sys/refdb_backend.h0000664000175000017500000001402212610310643021106 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sys_git_refdb_backend_h__ #define INCLUDE_sys_git_refdb_backend_h__ #include "git2/common.h" #include "git2/types.h" #include "git2/oid.h" /** * @file git2/refdb_backend.h * @brief Git custom refs backend functions * @defgroup git_refdb_backend Git custom refs backend API * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Every backend's iterator must have a pointer to itself as the first * element, so the API can talk to it. You'd define your iterator as * * struct my_iterator { * git_reference_iterator parent; * ... * } * * and assign `iter->parent.backend` to your `git_refdb_backend`. */ struct git_reference_iterator { git_refdb *db; /** * Return the current reference and advance the iterator. */ int (*next)( git_reference **ref, git_reference_iterator *iter); /** * Return the name of the current reference and advance the iterator */ int (*next_name)( const char **ref_name, git_reference_iterator *iter); /** * Free the iterator */ void (*free)( git_reference_iterator *iter); }; /** An instance for a custom backend */ struct git_refdb_backend { unsigned int version; /** * Queries the refdb backend to determine if the given ref_name * exists. A refdb implementation must provide this function. */ int (*exists)( int *exists, git_refdb_backend *backend, const char *ref_name); /** * Queries the refdb backend for a given reference. A refdb * implementation must provide this function. */ int (*lookup)( git_reference **out, git_refdb_backend *backend, const char *ref_name); /** * Allocate an iterator object for the backend. * * A refdb implementation must provide this function. */ int (*iterator)( git_reference_iterator **iter, struct git_refdb_backend *backend, const char *glob); /* * Writes the given reference to the refdb. A refdb implementation * must provide this function. */ int (*write)(git_refdb_backend *backend, const git_reference *ref, int force, const git_signature *who, const char *message, const git_oid *old, const char *old_target); int (*rename)( git_reference **out, git_refdb_backend *backend, const char *old_name, const char *new_name, int force, const git_signature *who, const char *message); /** * Deletes the given reference (and if necessary its reflog) * from the refdb. A refdb implementation must provide this * function. */ int (*del)(git_refdb_backend *backend, const char *ref_name, const git_oid *old_id, const char *old_target); /** * Suggests that the given refdb compress or optimize its references. * This mechanism is implementation specific. (For on-disk reference * databases, this may pack all loose references.) A refdb * implementation may provide this function; if it is not provided, * nothing will be done. */ int (*compress)(git_refdb_backend *backend); /** * Query whether a particular reference has a log (may be empty) */ int (*has_log)(git_refdb_backend *backend, const char *refname); /** * Make sure a particular reference will have a reflog which * will be appended to on writes. */ int (*ensure_log)(git_refdb_backend *backend, const char *refname); /** * Frees any resources held by the refdb (including the `git_refdb_backend` * itself). A refdb backend implementation must provide this function. */ void (*free)(git_refdb_backend *backend); /** * Read the reflog for the given reference name. */ int (*reflog_read)(git_reflog **out, git_refdb_backend *backend, const char *name); /** * Write a reflog to disk. */ int (*reflog_write)(git_refdb_backend *backend, git_reflog *reflog); /** * Rename a reflog */ int (*reflog_rename)(git_refdb_backend *_backend, const char *old_name, const char *new_name); /** * Remove a reflog. */ int (*reflog_delete)(git_refdb_backend *backend, const char *name); /** * Lock a reference. The opaque parameter will be passed to the unlock function */ int (*lock)(void **payload_out, git_refdb_backend *backend, const char *refname); /** * Unlock a reference. Only one of target or symbolic_target * will be set. success indicates whether to update the * reference or discard the lock (if it's false) */ int (*unlock)(git_refdb_backend *backend, void *payload, int success, int update_reflog, const git_reference *ref, const git_signature *sig, const char *message); }; #define GIT_REFDB_BACKEND_VERSION 1 #define GIT_REFDB_BACKEND_INIT {GIT_REFDB_BACKEND_VERSION} /** * Initializes a `git_refdb_backend` with default values. Equivalent to * creating an instance with GIT_REFDB_BACKEND_INIT. * * @param backend the `git_refdb_backend` struct to initialize * @param version Version of struct; pass `GIT_REFDB_BACKEND_VERSION` * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_refdb_init_backend( git_refdb_backend *backend, unsigned int version); /** * Constructors for default filesystem-based refdb backend * * Under normal usage, this is called for you when the repository is * opened / created, but you can use this to explicitly construct a * filesystem refdb backend for a repository. * * @param backend_out Output pointer to the git_refdb_backend object * @param repo Git repository to access * @return 0 on success, <0 error code on failure */ GIT_EXTERN(int) git_refdb_backend_fs( git_refdb_backend **backend_out, git_repository *repo); /** * Sets the custom backend to an existing reference DB * * The `git_refdb` will take ownership of the `git_refdb_backend` so you * should NOT free it after calling this function. * * @param refdb database to add the backend to * @param backend pointer to a git_refdb_backend instance * @return 0 on success; error code otherwise */ GIT_EXTERN(int) git_refdb_set_backend( git_refdb *refdb, git_refdb_backend *backend); GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/sys/index.h0000664000175000017500000001210612510265101017462 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sys_git_index_h__ #define INCLUDE_sys_git_index_h__ /** * @file git2/sys/index.h * @brief Low-level Git index manipulation routines * @defgroup git_backend Git custom backend APIs * @ingroup Git * @{ */ GIT_BEGIN_DECL /** Representation of a rename conflict entry in the index. */ typedef struct git_index_name_entry { char *ancestor; char *ours; char *theirs; } git_index_name_entry; /** Representation of a resolve undo entry in the index. */ typedef struct git_index_reuc_entry { unsigned int mode[3]; git_oid oid[3]; char *path; } git_index_reuc_entry; /** @name Conflict Name entry functions * * These functions work on rename conflict entries. */ /**@{*/ /** * Get the count of filename conflict entries currently in the index. * * @param index an existing index object * @return integer of count of current filename conflict entries */ GIT_EXTERN(size_t) git_index_name_entrycount(git_index *index); /** * Get a filename conflict entry from the index. * * The returned entry is read-only and should not be modified * or freed by the caller. * * @param index an existing index object * @param n the position of the entry * @return a pointer to the filename conflict entry; NULL if out of bounds */ GIT_EXTERN(const git_index_name_entry *) git_index_name_get_byindex( git_index *index, size_t n); /** * Record the filenames involved in a rename conflict. * * @param index an existing index object * @param ancestor the path of the file as it existed in the ancestor * @param ours the path of the file as it existed in our tree * @param theirs the path of the file as it existed in their tree */ GIT_EXTERN(int) git_index_name_add(git_index *index, const char *ancestor, const char *ours, const char *theirs); /** * Remove all filename conflict entries. * * @param index an existing index object */ GIT_EXTERN(void) git_index_name_clear(git_index *index); /**@}*/ /** @name Resolve Undo (REUC) index entry manipulation. * * These functions work on the Resolve Undo index extension and contains * data about the original files that led to a merge conflict. */ /**@{*/ /** * Get the count of resolve undo entries currently in the index. * * @param index an existing index object * @return integer of count of current resolve undo entries */ GIT_EXTERN(size_t) git_index_reuc_entrycount(git_index *index); /** * Finds the resolve undo entry that points to the given path in the Git * index. * * @param at_pos the address to which the position of the reuc entry is written (optional) * @param index an existing index object * @param path path to search * @return 0 if found, < 0 otherwise (GIT_ENOTFOUND) */ GIT_EXTERN(int) git_index_reuc_find(size_t *at_pos, git_index *index, const char *path); /** * Get a resolve undo entry from the index. * * The returned entry is read-only and should not be modified * or freed by the caller. * * @param index an existing index object * @param path path to search * @return the resolve undo entry; NULL if not found */ GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_bypath(git_index *index, const char *path); /** * Get a resolve undo entry from the index. * * The returned entry is read-only and should not be modified * or freed by the caller. * * @param index an existing index object * @param n the position of the entry * @return a pointer to the resolve undo entry; NULL if out of bounds */ GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_byindex(git_index *index, size_t n); /** * Adds a resolve undo entry for a file based on the given parameters. * * The resolve undo entry contains the OIDs of files that were involved * in a merge conflict after the conflict has been resolved. This allows * conflicts to be re-resolved later. * * If there exists a resolve undo entry for the given path in the index, * it will be removed. * * This method will fail in bare index instances. * * @param index an existing index object * @param path filename to add * @param ancestor_mode mode of the ancestor file * @param ancestor_id oid of the ancestor file * @param our_mode mode of our file * @param our_id oid of our file * @param their_mode mode of their file * @param their_id oid of their file * @return 0 or an error code */ GIT_EXTERN(int) git_index_reuc_add(git_index *index, const char *path, int ancestor_mode, const git_oid *ancestor_id, int our_mode, const git_oid *our_id, int their_mode, const git_oid *their_id); /** * Remove an resolve undo entry from the index * * @param index an existing index object * @param n position of the resolve undo entry to remove * @return 0 or an error code */ GIT_EXTERN(int) git_index_reuc_remove(git_index *index, size_t n); /** * Remove all resolve undo entries from the index * * @param index an existing index object */ GIT_EXTERN(void) git_index_reuc_clear(git_index *index); /**@}*/ /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/sys/commit.h0000664000175000017500000000451112426525445017664 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sys_git_commit_h__ #define INCLUDE_sys_git_commit_h__ #include "git2/common.h" #include "git2/types.h" #include "git2/oid.h" /** * @file git2/sys/commit.h * @brief Low-level Git commit creation * @defgroup git_backend Git custom backend APIs * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Create new commit in the repository from a list of `git_oid` values. * * See documentation for `git_commit_create()` for information about the * parameters, as the meaning is identical excepting that `tree` and * `parents` now take `git_oid`. This is a dangerous API in that nor * the `tree`, neither the `parents` list of `git_oid`s are checked for * validity. * * @see git_commit_create */ GIT_EXTERN(int) git_commit_create_from_ids( git_oid *id, git_repository *repo, const char *update_ref, const git_signature *author, const git_signature *committer, const char *message_encoding, const char *message, const git_oid *tree, size_t parent_count, const git_oid *parents[]); /** * Callback function to return parents for commit. * * This is invoked with the count of the number of parents processed so far * along with the user supplied payload. This should return a git_oid of * the next parent or NULL if all parents have been provided. */ typedef const git_oid *(*git_commit_parent_callback)(size_t idx, void *payload); /** * Create a new commit in the repository with an callback to supply parents. * * See documentation for `git_commit_create()` for information about the * parameters, as the meaning is identical excepting that `tree` takes a * `git_oid` and doesn't check for validity, and `parent_cb` is invoked * with `parent_payload` and should return `git_oid` values or NULL to * indicate that all parents are accounted for. * * @see git_commit_create */ GIT_EXTERN(int) git_commit_create_from_callback( git_oid *id, git_repository *repo, const char *update_ref, const git_signature *author, const git_signature *committer, const char *message_encoding, const char *message, const git_oid *tree, git_commit_parent_callback parent_cb, void *parent_payload); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/sys/reflog.h0000664000175000017500000000101412426525445017645 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sys_git_reflog_h__ #define INCLUDE_sys_git_reflog_h__ #include "git2/common.h" #include "git2/types.h" #include "git2/oid.h" GIT_BEGIN_DECL GIT_EXTERN(git_reflog_entry *) git_reflog_entry__alloc(void); GIT_EXTERN(void) git_reflog_entry__free(git_reflog_entry *entry); GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/sys/refs.h0000664000175000017500000000225512510265101017316 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sys_git_refdb_h__ #define INCLUDE_sys_git_refdb_h__ #include "git2/common.h" #include "git2/types.h" #include "git2/oid.h" /** * @file git2/sys/refs.h * @brief Low-level Git ref creation * @defgroup git_backend Git custom backend APIs * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Create a new direct reference from an OID. * * @param name the reference name * @param oid the object id for a direct reference * @param peel the first non-tag object's OID, or NULL * @return the created git_reference or NULL on error */ GIT_EXTERN(git_reference *) git_reference__alloc( const char *name, const git_oid *oid, const git_oid *peel); /** * Create a new symbolic reference. * * @param name the reference name * @param target the target for a symbolic reference * @return the created git_reference or NULL on error */ GIT_EXTERN(git_reference *) git_reference__alloc_symbolic( const char *name, const char *target); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/sys/transport.h0000664000175000017500000002677112610310643020427 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sys_git_transport_h #define INCLUDE_sys_git_transport_h #include "git2/net.h" #include "git2/types.h" /** * @file git2/sys/transport.h * @brief Git custom transport registration interfaces and functions * @defgroup git_transport Git custom transport registration * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Flags to pass to transport * * Currently unused. */ typedef enum { GIT_TRANSPORTFLAGS_NONE = 0, } git_transport_flags_t; struct git_transport { unsigned int version; /* Set progress and error callbacks */ int (*set_callbacks)( git_transport *transport, git_transport_message_cb progress_cb, git_transport_message_cb error_cb, git_transport_certificate_check_cb certificate_check_cb, void *payload); /* Set custom headers for HTTP requests */ int (*set_custom_headers)( git_transport *transport, const git_strarray *custom_headers); /* Connect the transport to the remote repository, using the given * direction. */ int (*connect)( git_transport *transport, const char *url, git_cred_acquire_cb cred_acquire_cb, void *cred_acquire_payload, int direction, int flags); /* This function may be called after a successful call to * connect(). The array returned is owned by the transport and * is guaranteed until the next call of a transport function. */ int (*ls)( const git_remote_head ***out, size_t *size, git_transport *transport); /* Executes the push whose context is in the git_push object. */ int (*push)(git_transport *transport, git_push *push, const git_remote_callbacks *callbacks); /* This function may be called after a successful call to connect(), when * the direction is FETCH. The function performs a negotiation to calculate * the wants list for the fetch. */ int (*negotiate_fetch)( git_transport *transport, git_repository *repo, const git_remote_head * const *refs, size_t count); /* This function may be called after a successful call to negotiate_fetch(), * when the direction is FETCH. This function retrieves the pack file for * the fetch from the remote end. */ int (*download_pack)( git_transport *transport, git_repository *repo, git_transfer_progress *stats, git_transfer_progress_cb progress_cb, void *progress_payload); /* Checks to see if the transport is connected */ int (*is_connected)(git_transport *transport); /* Reads the flags value previously passed into connect() */ int (*read_flags)(git_transport *transport, int *flags); /* Cancels any outstanding transport operation */ void (*cancel)(git_transport *transport); /* This function is the reverse of connect() -- it terminates the * connection to the remote end. */ int (*close)(git_transport *transport); /* Frees/destructs the git_transport object. */ void (*free)(git_transport *transport); }; #define GIT_TRANSPORT_VERSION 1 #define GIT_TRANSPORT_INIT {GIT_TRANSPORT_VERSION} /** * Initializes a `git_transport` with default values. Equivalent to * creating an instance with GIT_TRANSPORT_INIT. * * @param opts the `git_transport` struct to initialize * @param version Version of struct; pass `GIT_TRANSPORT_VERSION` * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_transport_init( git_transport *opts, unsigned int version); /** * Function to use to create a transport from a URL. The transport database * is scanned to find a transport that implements the scheme of the URI (i.e. * git:// or http://) and a transport object is returned to the caller. * * @param out The newly created transport (out) * @param owner The git_remote which will own this transport * @param url The URL to connect to * @return 0 or an error code */ GIT_EXTERN(int) git_transport_new(git_transport **out, git_remote *owner, const char *url); /** * Create an ssh transport with custom git command paths * * This is a factory function suitable for setting as the transport * callback in a remote (or for a clone in the options). * * The payload argument must be a strarray pointer with the paths for * the `git-upload-pack` and `git-receive-pack` at index 0 and 1. * * @param out the resulting transport * @param owner the owning remote * @param payload a strarray with the paths * @return 0 or an error code */ GIT_EXTERN(int) git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *payload); /** * Add a custom transport definition, to be used in addition to the built-in * set of transports that come with libgit2. * * The caller is responsible for synchronizing calls to git_transport_register * and git_transport_unregister with other calls to the library that * instantiate transports. * * @param prefix The scheme (ending in "://") to match, i.e. "git://" * @param cb The callback used to create an instance of the transport * @param param A fixed parameter to pass to cb at creation time * @return 0 or an error code */ GIT_EXTERN(int) git_transport_register( const char *prefix, git_transport_cb cb, void *param); /** * * Unregister a custom transport definition which was previously registered * with git_transport_register. * * @param prefix From the previous call to git_transport_register * @return 0 or an error code */ GIT_EXTERN(int) git_transport_unregister( const char *prefix); /* Transports which come with libgit2 (match git_transport_cb). The expected * value for "param" is listed in-line below. */ /** * Create an instance of the dummy transport. * * @param out The newly created transport (out) * @param owner The git_remote which will own this transport * @param payload You must pass NULL for this parameter. * @return 0 or an error code */ GIT_EXTERN(int) git_transport_dummy( git_transport **out, git_remote *owner, /* NULL */ void *payload); /** * Create an instance of the local transport. * * @param out The newly created transport (out) * @param owner The git_remote which will own this transport * @param payload You must pass NULL for this parameter. * @return 0 or an error code */ GIT_EXTERN(int) git_transport_local( git_transport **out, git_remote *owner, /* NULL */ void *payload); /** * Create an instance of the smart transport. * * @param out The newly created transport (out) * @param owner The git_remote which will own this transport * @param payload A pointer to a git_smart_subtransport_definition * @return 0 or an error code */ GIT_EXTERN(int) git_transport_smart( git_transport **out, git_remote *owner, /* (git_smart_subtransport_definition *) */ void *payload); /** * Call the certificate check for this transport. * * @param transport a smart transport * @param cert the certificate to pass to the caller * @param valid whether we believe the certificate is valid * @param hostname the hostname we connected to * @return the return value of the callback */ GIT_EXTERN(int) git_transport_smart_certificate_check(git_transport *transport, git_cert *cert, int valid, const char *hostname); /** * Call the credentials callback for this transport * * @param out the pointer where the creds are to be stored * @param transport a smart transport * @param user the user we saw on the url (if any) * @param methods available methods for authentication * @return the return value of the callback */ GIT_EXTERN(int) git_transport_smart_credentials(git_cred **out, git_transport *transport, const char *user, int methods); /* *** End of base transport interface *** *** Begin interface for subtransports for the smart transport *** */ /* The smart transport knows how to speak the git protocol, but it has no * knowledge of how to establish a connection between it and another endpoint, * or how to move data back and forth. For this, a subtransport interface is * declared, and the smart transport delegates this work to the subtransports. * Three subtransports are implemented: git, http, and winhttp. (The http and * winhttp transports each implement both http and https.) */ /* Subtransports can either be RPC = 0 (persistent connection) or RPC = 1 * (request/response). The smart transport handles the differences in its own * logic. The git subtransport is RPC = 0, while http and winhttp are both * RPC = 1. */ /* Actions that the smart transport can ask * a subtransport to perform */ typedef enum { GIT_SERVICE_UPLOADPACK_LS = 1, GIT_SERVICE_UPLOADPACK = 2, GIT_SERVICE_RECEIVEPACK_LS = 3, GIT_SERVICE_RECEIVEPACK = 4, } git_smart_service_t; typedef struct git_smart_subtransport git_smart_subtransport; typedef struct git_smart_subtransport_stream git_smart_subtransport_stream; /* A stream used by the smart transport to read and write data * from a subtransport */ struct git_smart_subtransport_stream { /* The owning subtransport */ git_smart_subtransport *subtransport; int (*read)( git_smart_subtransport_stream *stream, char *buffer, size_t buf_size, size_t *bytes_read); int (*write)( git_smart_subtransport_stream *stream, const char *buffer, size_t len); void (*free)( git_smart_subtransport_stream *stream); }; /* An implementation of a subtransport which carries data for the * smart transport */ struct git_smart_subtransport { int (* action)( git_smart_subtransport_stream **out, git_smart_subtransport *transport, const char *url, git_smart_service_t action); /* Subtransports are guaranteed a call to close() between * calls to action(), except for the following two "natural" progressions * of actions against a constant URL. * * 1. UPLOADPACK_LS -> UPLOADPACK * 2. RECEIVEPACK_LS -> RECEIVEPACK */ int (*close)(git_smart_subtransport *transport); void (*free)(git_smart_subtransport *transport); }; /* A function which creates a new subtransport for the smart transport */ typedef int (*git_smart_subtransport_cb)( git_smart_subtransport **out, git_transport* owner, void* param); /** * Definition for a "subtransport" * * This is used to let the smart protocol code know about the protocol * which you are implementing. */ typedef struct git_smart_subtransport_definition { /** The function to use to create the git_smart_subtransport */ git_smart_subtransport_cb callback; /** * True if the protocol is stateless; false otherwise. For example, * http:// is stateless, but git:// is not. */ unsigned rpc; /** Param of the callback */ void* param; } git_smart_subtransport_definition; /* Smart transport subtransports that come with libgit2 */ /** * Create an instance of the http subtransport. This subtransport * also supports https. On Win32, this subtransport may be implemented * using the WinHTTP library. * * @param out The newly created subtransport * @param owner The smart transport to own this subtransport * @return 0 or an error code */ GIT_EXTERN(int) git_smart_subtransport_http( git_smart_subtransport **out, git_transport* owner, void *param); /** * Create an instance of the git subtransport. * * @param out The newly created subtransport * @param owner The smart transport to own this subtransport * @return 0 or an error code */ GIT_EXTERN(int) git_smart_subtransport_git( git_smart_subtransport **out, git_transport* owner, void *param); /** * Create an instance of the ssh subtransport. * * @param out The newly created subtransport * @param owner The smart transport to own this subtransport * @return 0 or an error code */ GIT_EXTERN(int) git_smart_subtransport_ssh( git_smart_subtransport **out, git_transport* owner, void *param); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/sys/hashsig.h0000664000175000017500000000551112510265101020003 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_sys_hashsig_h__ #define INCLUDE_sys_hashsig_h__ #include "git2/common.h" GIT_BEGIN_DECL /** * Similarity signature of arbitrary text content based on line hashes */ typedef struct git_hashsig git_hashsig; /** * Options for hashsig computation * * The options GIT_HASHSIG_NORMAL, GIT_HASHSIG_IGNORE_WHITESPACE, * GIT_HASHSIG_SMART_WHITESPACE are exclusive and should not be combined. */ typedef enum { /** * Use all data */ GIT_HASHSIG_NORMAL = 0, /** * Ignore whitespace */ GIT_HASHSIG_IGNORE_WHITESPACE = (1 << 0), /** * Ignore \r and all space after \n */ GIT_HASHSIG_SMART_WHITESPACE = (1 << 1), /** * Allow hashing of small files */ GIT_HASHSIG_ALLOW_SMALL_FILES = (1 << 2) } git_hashsig_option_t; /** * Compute a similarity signature for a text buffer * * If you have passed the option GIT_HASHSIG_IGNORE_WHITESPACE, then the * whitespace will be removed from the buffer while it is being processed, * modifying the buffer in place. Sorry about that! * * @param out The computed similarity signature. * @param buf The input buffer. * @param buflen The input buffer size. * @param opts The signature computation options (see above). * @return 0 on success, GIT_EBUFS if the buffer doesn't contain enough data to * compute a valid signature (unless GIT_HASHSIG_ALLOW_SMALL_FILES is set), or * error code. */ GIT_EXTERN(int) git_hashsig_create( git_hashsig **out, const char *buf, size_t buflen, git_hashsig_option_t opts); /** * Compute a similarity signature for a text file * * This walks through the file, only loading a maximum of 4K of file data at * a time. Otherwise, it acts just like `git_hashsig_create`. * * @param out The computed similarity signature. * @param path The path to the input file. * @param opts The signature computation options (see above). * @return 0 on success, GIT_EBUFS if the buffer doesn't contain enough data to * compute a valid signature (unless GIT_HASHSIG_ALLOW_SMALL_FILES is set), or * error code. */ GIT_EXTERN(int) git_hashsig_create_fromfile( git_hashsig **out, const char *path, git_hashsig_option_t opts); /** * Release memory for a content similarity signature * * @param sig The similarity signature to free. */ GIT_EXTERN(void) git_hashsig_free(git_hashsig *sig); /** * Measure similarity score between two similarity signatures * * @param a The first similarity signature to compare. * @param b The second similarity signature to compare. * @return [0 to 100] on success as the similarity score, or error code. */ GIT_EXTERN(int) git_hashsig_compare( const git_hashsig *a, const git_hashsig *b); GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/notes.h0000664000175000017500000001263712510265101016676 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_note_h__ #define INCLUDE_git_note_h__ #include "oid.h" /** * @file git2/notes.h * @brief Git notes management routines * @defgroup git_note Git notes management routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Callback for git_note_foreach. * * Receives: * - blob_id: Oid of the blob containing the message * - annotated_object_id: Oid of the git object being annotated * - payload: Payload data passed to `git_note_foreach` */ typedef int (*git_note_foreach_cb)( const git_oid *blob_id, const git_oid *annotated_object_id, void *payload); /** * note iterator */ typedef struct git_iterator git_note_iterator; /** * Creates a new iterator for notes * * The iterator must be freed manually by the user. * * @param out pointer to the iterator * @param repo repository where to look up the note * @param notes_ref canonical name of the reference to use (optional); defaults to * "refs/notes/commits" * * @return 0 or an error code */ GIT_EXTERN(int) git_note_iterator_new( git_note_iterator **out, git_repository *repo, const char *notes_ref); /** * Frees an git_note_iterator * * @param it pointer to the iterator */ GIT_EXTERN(void) git_note_iterator_free(git_note_iterator *it); /** * Return the current item (note_id and annotated_id) and advance the iterator * internally to the next value * * @param note_id id of blob containing the message * @param annotated_id id of the git object being annotated * @param it pointer to the iterator * * @return 0 (no error), GIT_ITEROVER (iteration is done) or an error code * (negative value) */ GIT_EXTERN(int) git_note_next( git_oid* note_id, git_oid* annotated_id, git_note_iterator *it); /** * Read the note for an object * * The note must be freed manually by the user. * * @param out pointer to the read note; NULL in case of error * @param repo repository where to look up the note * @param notes_ref canonical name of the reference to use (optional); defaults to * "refs/notes/commits" * @param oid OID of the git object to read the note from * * @return 0 or an error code */ GIT_EXTERN(int) git_note_read( git_note **out, git_repository *repo, const char *notes_ref, const git_oid *oid); /** * Get the note author * * @param note the note * @return the author */ GIT_EXTERN(const git_signature *) git_note_author(const git_note *note); /** * Get the note committer * * @param note the note * @return the committer */ GIT_EXTERN(const git_signature *) git_note_committer(const git_note *note); /** * Get the note message * * @param note the note * @return the note message */ GIT_EXTERN(const char *) git_note_message(const git_note *note); /** * Get the note object's id * * @param note the note * @return the note object's id */ GIT_EXTERN(const git_oid *) git_note_id(const git_note *note); /** * Add a note for an object * * @param out pointer to store the OID (optional); NULL in case of error * @param repo repository where to store the note * @param notes_ref canonical name of the reference to use (optional); * defaults to "refs/notes/commits" * @param author signature of the notes commit author * @param committer signature of the notes commit committer * @param oid OID of the git object to decorate * @param note Content of the note to add for object oid * @param force Overwrite existing note * * @return 0 or an error code */ GIT_EXTERN(int) git_note_create( git_oid *out, git_repository *repo, const char *notes_ref, const git_signature *author, const git_signature *committer, const git_oid *oid, const char *note, int force); /** * Remove the note for an object * * @param repo repository where the note lives * @param notes_ref canonical name of the reference to use (optional); * defaults to "refs/notes/commits" * @param author signature of the notes commit author * @param committer signature of the notes commit committer * @param oid OID of the git object to remove the note from * * @return 0 or an error code */ GIT_EXTERN(int) git_note_remove( git_repository *repo, const char *notes_ref, const git_signature *author, const git_signature *committer, const git_oid *oid); /** * Free a git_note object * * @param note git_note object */ GIT_EXTERN(void) git_note_free(git_note *note); /** * Get the default notes reference for a repository * * @param out buffer in which to store the name of the default notes reference * @param repo The Git repository * * @return 0 or an error code */ GIT_EXTERN(int) git_note_default_ref(git_buf *out, git_repository *repo); /** * Loop over all the notes within a specified namespace * and issue a callback for each one. * * @param repo Repository where to find the notes. * * @param notes_ref Reference to read from (optional); defaults to * "refs/notes/commits". * * @param note_cb Callback to invoke per found annotation. Return non-zero * to stop looping. * * @param payload Extra parameter to callback function. * * @return 0 on success, non-zero callback return value, or error code */ GIT_EXTERN(int) git_note_foreach( git_repository *repo, const char *notes_ref, git_note_foreach_cb note_cb, void *payload); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/odb.h0000664000175000017500000003744312555730137016333 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_odb_h__ #define INCLUDE_git_odb_h__ #include "common.h" #include "types.h" #include "oid.h" /** * @file git2/odb.h * @brief Git object database routines * @defgroup git_odb Git object database routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Function type for callbacks from git_odb_foreach. */ typedef int (*git_odb_foreach_cb)(const git_oid *id, void *payload); /** * Create a new object database with no backends. * * Before the ODB can be used for read/writing, a custom database * backend must be manually added using `git_odb_add_backend()` * * @param out location to store the database pointer, if opened. * Set to NULL if the open failed. * @return 0 or an error code */ GIT_EXTERN(int) git_odb_new(git_odb **out); /** * Create a new object database and automatically add * the two default backends: * * - git_odb_backend_loose: read and write loose object files * from disk, assuming `objects_dir` as the Objects folder * * - git_odb_backend_pack: read objects from packfiles, * assuming `objects_dir` as the Objects folder which * contains a 'pack/' folder with the corresponding data * * @param out location to store the database pointer, if opened. * Set to NULL if the open failed. * @param objects_dir path of the backends' "objects" directory. * @return 0 or an error code */ GIT_EXTERN(int) git_odb_open(git_odb **out, const char *objects_dir); /** * Add an on-disk alternate to an existing Object DB. * * Note that the added path must point to an `objects`, not * to a full repository, to use it as an alternate store. * * Alternate backends are always checked for objects *after* * all the main backends have been exhausted. * * Writing is disabled on alternate backends. * * @param odb database to add the backend to * @param path path to the objects folder for the alternate * @return 0 on success; error code otherwise */ GIT_EXTERN(int) git_odb_add_disk_alternate(git_odb *odb, const char *path); /** * Close an open object database. * * @param db database pointer to close. If NULL no action is taken. */ GIT_EXTERN(void) git_odb_free(git_odb *db); /** * Read an object from the database. * * This method queries all available ODB backends * trying to read the given OID. * * The returned object is reference counted and * internally cached, so it should be closed * by the user once it's no longer in use. * * @param out pointer where to store the read object * @param db database to search for the object in. * @param id identity of the object to read. * @return * - 0 if the object was read; * - GIT_ENOTFOUND if the object is not in the database. */ GIT_EXTERN(int) git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id); /** * Read an object from the database, given a prefix * of its identifier. * * This method queries all available ODB backends * trying to match the 'len' first hexadecimal * characters of the 'short_id'. * The remaining (GIT_OID_HEXSZ-len)*4 bits of * 'short_id' must be 0s. * 'len' must be at least GIT_OID_MINPREFIXLEN, * and the prefix must be long enough to identify * a unique object in all the backends; the * method will fail otherwise. * * The returned object is reference counted and * internally cached, so it should be closed * by the user once it's no longer in use. * * @param out pointer where to store the read object * @param db database to search for the object in. * @param short_id a prefix of the id of the object to read. * @param len the length of the prefix * @return * - 0 if the object was read; * - GIT_ENOTFOUND if the object is not in the database. * - GIT_EAMBIGUOUS if the prefix is ambiguous (several objects match the prefix) */ GIT_EXTERN(int) git_odb_read_prefix(git_odb_object **out, git_odb *db, const git_oid *short_id, size_t len); /** * Read the header of an object from the database, without * reading its full contents. * * The header includes the length and the type of an object. * * Note that most backends do not support reading only the header * of an object, so the whole object will be read and then the * header will be returned. * * @param len_out pointer where to store the length * @param type_out pointer where to store the type * @param db database to search for the object in. * @param id identity of the object to read. * @return * - 0 if the object was read; * - GIT_ENOTFOUND if the object is not in the database. */ GIT_EXTERN(int) git_odb_read_header(size_t *len_out, git_otype *type_out, git_odb *db, const git_oid *id); /** * Determine if the given object can be found in the object database. * * @param db database to be searched for the given object. * @param id the object to search for. * @return * - 1, if the object was found * - 0, otherwise */ GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id); /** * Determine if objects can be found in the object database from a short OID. * * @param out The full OID of the found object if just one is found. * @param db The database to be searched for the given object. * @param short_id A prefix of the id of the object to read. * @param len The length of the prefix. * @return 0 if found, GIT_ENOTFOUND if not found, GIT_EAMBIGUOUS if multiple * matches were found, other value < 0 if there was a read error. */ GIT_EXTERN(int) git_odb_exists_prefix( git_oid *out, git_odb *db, const git_oid *short_id, size_t len); /** * Refresh the object database to load newly added files. * * If the object databases have changed on disk while the library * is running, this function will force a reload of the underlying * indexes. * * Use this function when you're confident that an external * application has tampered with the ODB. * * NOTE that it is not necessary to call this function at all. The * library will automatically attempt to refresh the ODB * when a lookup fails, to see if the looked up object exists * on disk but hasn't been loaded yet. * * @param db database to refresh * @return 0 on success, error code otherwise */ GIT_EXTERN(int) git_odb_refresh(struct git_odb *db); /** * List all objects available in the database * * The callback will be called for each object available in the * database. Note that the objects are likely to be returned in the index * order, which would make accessing the objects in that order inefficient. * Return a non-zero value from the callback to stop looping. * * @param db database to use * @param cb the callback to call for each object * @param payload data to pass to the callback * @return 0 on success, non-zero callback return value, or error code */ GIT_EXTERN(int) git_odb_foreach(git_odb *db, git_odb_foreach_cb cb, void *payload); /** * Write an object directly into the ODB * * This method writes a full object straight into the ODB. * For most cases, it is preferred to write objects through a write * stream, which is both faster and less memory intensive, specially * for big objects. * * This method is provided for compatibility with custom backends * which are not able to support streaming writes * * @param out pointer to store the OID result of the write * @param odb object database where to store the object * @param data buffer with the data to store * @param len size of the buffer * @param type type of the data to store * @return 0 or an error code */ GIT_EXTERN(int) git_odb_write(git_oid *out, git_odb *odb, const void *data, size_t len, git_otype type); /** * Open a stream to write an object into the ODB * * The type and final length of the object must be specified * when opening the stream. * * The returned stream will be of type `GIT_STREAM_WRONLY`, and it * won't be effective until `git_odb_stream_finalize_write` is called * and returns without an error * * The stream must always be freed when done with `git_odb_stream_free` or * will leak memory. * * @see git_odb_stream * * @param out pointer where to store the stream * @param db object database where the stream will write * @param size final size of the object that will be written * @param type type of the object that will be written * @return 0 if the stream was created; error code otherwise */ GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **out, git_odb *db, git_off_t size, git_otype type); /** * Write to an odb stream * * This method will fail if the total number of received bytes exceeds the * size declared with `git_odb_open_wstream()` * * @param stream the stream * @param buffer the data to write * @param len the buffer's length * @return 0 if the write succeeded; error code otherwise */ GIT_EXTERN(int) git_odb_stream_write(git_odb_stream *stream, const char *buffer, size_t len); /** * Finish writing to an odb stream * * The object will take its final name and will be available to the * odb. * * This method will fail if the total number of received bytes * differs from the size declared with `git_odb_open_wstream()` * * @param out pointer to store the resulting object's id * @param stream the stream * @return 0 on success; an error code otherwise */ GIT_EXTERN(int) git_odb_stream_finalize_write(git_oid *out, git_odb_stream *stream); /** * Read from an odb stream * * Most backends don't implement streaming reads */ GIT_EXTERN(int) git_odb_stream_read(git_odb_stream *stream, char *buffer, size_t len); /** * Free an odb stream * * @param stream the stream to free */ GIT_EXTERN(void) git_odb_stream_free(git_odb_stream *stream); /** * Open a stream to read an object from the ODB * * Note that most backends do *not* support streaming reads * because they store their objects as compressed/delta'ed blobs. * * It's recommended to use `git_odb_read` instead, which is * assured to work on all backends. * * The returned stream will be of type `GIT_STREAM_RDONLY` and * will have the following methods: * * - stream->read: read `n` bytes from the stream * - stream->free: free the stream * * The stream must always be free'd or will leak memory. * * @see git_odb_stream * * @param out pointer where to store the stream * @param db object database where the stream will read from * @param oid oid of the object the stream will read from * @return 0 if the stream was created; error code otherwise */ GIT_EXTERN(int) git_odb_open_rstream(git_odb_stream **out, git_odb *db, const git_oid *oid); /** * Open a stream for writing a pack file to the ODB. * * If the ODB layer understands pack files, then the given * packfile will likely be streamed directly to disk (and a * corresponding index created). If the ODB layer does not * understand pack files, the objects will be stored in whatever * format the ODB layer uses. * * @see git_odb_writepack * * @param out pointer to the writepack functions * @param db object database where the stream will read from * @param progress_cb function to call with progress information. * Be aware that this is called inline with network and indexing operations, * so performance may be affected. * @param progress_payload payload for the progress callback */ GIT_EXTERN(int) git_odb_write_pack( git_odb_writepack **out, git_odb *db, git_transfer_progress_cb progress_cb, void *progress_payload); /** * Determine the object-ID (sha1 hash) of a data buffer * * The resulting SHA-1 OID will be the identifier for the data * buffer as if the data buffer it were to written to the ODB. * * @param out the resulting object-ID. * @param data data to hash * @param len size of the data * @param type of the data to hash * @return 0 or an error code */ GIT_EXTERN(int) git_odb_hash(git_oid *out, const void *data, size_t len, git_otype type); /** * Read a file from disk and fill a git_oid with the object id * that the file would have if it were written to the Object * Database as an object of the given type (w/o applying filters). * Similar functionality to git.git's `git hash-object` without * the `-w` flag, however, with the --no-filters flag. * If you need filters, see git_repository_hashfile. * * @param out oid structure the result is written into. * @param path file to read and determine object id for * @param type the type of the object that will be hashed * @return 0 or an error code */ GIT_EXTERN(int) git_odb_hashfile(git_oid *out, const char *path, git_otype type); /** * Create a copy of an odb_object * * The returned copy must be manually freed with `git_odb_object_free`. * Note that because of an implementation detail, the returned copy will be * the same pointer as `source`: the object is internally refcounted, so the * copy still needs to be freed twice. * * @param dest pointer where to store the copy * @param source object to copy * @return 0 or an error code */ GIT_EXTERN(int) git_odb_object_dup(git_odb_object **dest, git_odb_object *source); /** * Close an ODB object * * This method must always be called once a `git_odb_object` is no * longer needed, otherwise memory will leak. * * @param object object to close */ GIT_EXTERN(void) git_odb_object_free(git_odb_object *object); /** * Return the OID of an ODB object * * This is the OID from which the object was read from * * @param object the object * @return a pointer to the OID */ GIT_EXTERN(const git_oid *) git_odb_object_id(git_odb_object *object); /** * Return the data of an ODB object * * This is the uncompressed, raw data as read from the ODB, * without the leading header. * * This pointer is owned by the object and shall not be free'd. * * @param object the object * @return a pointer to the data */ GIT_EXTERN(const void *) git_odb_object_data(git_odb_object *object); /** * Return the size of an ODB object * * This is the real size of the `data` buffer, not the * actual size of the object. * * @param object the object * @return the size */ GIT_EXTERN(size_t) git_odb_object_size(git_odb_object *object); /** * Return the type of an ODB object * * @param object the object * @return the type */ GIT_EXTERN(git_otype) git_odb_object_type(git_odb_object *object); /** * Add a custom backend to an existing Object DB * * The backends are checked in relative ordering, based on the * value of the `priority` parameter. * * Read for more information. * * @param odb database to add the backend to * @param backend pointer to a git_odb_backend instance * @param priority Value for ordering the backends queue * @return 0 on success; error code otherwise */ GIT_EXTERN(int) git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority); /** * Add a custom backend to an existing Object DB; this * backend will work as an alternate. * * Alternate backends are always checked for objects *after* * all the main backends have been exhausted. * * The backends are checked in relative ordering, based on the * value of the `priority` parameter. * * Writing is disabled on alternate backends. * * Read for more information. * * @param odb database to add the backend to * @param backend pointer to a git_odb_backend instance * @param priority Value for ordering the backends queue * @return 0 on success; error code otherwise */ GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority); /** * Get the number of ODB backend objects * * @param odb object database * @return number of backends in the ODB */ GIT_EXTERN(size_t) git_odb_num_backends(git_odb *odb); /** * Lookup an ODB backend object by index * * @param out output pointer to ODB backend at pos * @param odb object database * @param pos index into object database backend list * @return 0 on success; GIT_ENOTFOUND if pos is invalid; other errors < 0 */ GIT_EXTERN(int) git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/describe.h0000664000175000017500000001034112555730137017333 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_describe_h__ #define INCLUDE_git_describe_h__ #include "common.h" #include "types.h" #include "buffer.h" /** * @file git2/describe.h * @brief Git describing routines * @defgroup git_describe Git describing routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Reference lookup strategy * * These behave like the --tags and --all optios to git-describe, * namely they say to look for any reference in either refs/tags/ or * refs/ respectively. */ typedef enum { GIT_DESCRIBE_DEFAULT, GIT_DESCRIBE_TAGS, GIT_DESCRIBE_ALL, } git_describe_strategy_t; /** * Describe options structure * * Initialize with `GIT_DESCRIBE_OPTIONS_INIT` macro to correctly set * the `version` field. E.g. * * git_describe_options opts = GIT_DESCRIBE_OPTIONS_INIT; */ typedef struct git_describe_options { unsigned int version; unsigned int max_candidates_tags; /** default: 10 */ unsigned int describe_strategy; /** default: GIT_DESCRIBE_DEFAULT */ const char *pattern; /** * When calculating the distance from the matching tag or * reference, only walk down the first-parent ancestry. */ int only_follow_first_parent; /** * If no matching tag or reference is found, the describe * operation would normally fail. If this option is set, it * will instead fall back to showing the full id of the * commit. */ int show_commit_oid_as_fallback; } git_describe_options; #define GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS 10 #define GIT_DESCRIBE_DEFAULT_ABBREVIATED_SIZE 7 #define GIT_DESCRIBE_OPTIONS_VERSION 1 #define GIT_DESCRIBE_OPTIONS_INIT { \ GIT_DESCRIBE_OPTIONS_VERSION, \ GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS, \ } GIT_EXTERN(int) git_describe_init_options(git_describe_options *opts, unsigned int version); /** * Options for formatting the describe string */ typedef struct { unsigned int version; /** * Size of the abbreviated commit id to use. This value is the * lower bound for the length of the abbreviated string. The * default is 7. */ unsigned int abbreviated_size; /** * Set to use the long format even when a shorter name could be used. */ int always_use_long_format; /** * If the workdir is dirty and this is set, this string will * be appended to the description string. */ const char *dirty_suffix; } git_describe_format_options; #define GIT_DESCRIBE_FORMAT_OPTIONS_VERSION 1 #define GIT_DESCRIBE_FORMAT_OPTIONS_INIT { \ GIT_DESCRIBE_FORMAT_OPTIONS_VERSION, \ GIT_DESCRIBE_DEFAULT_ABBREVIATED_SIZE, \ } GIT_EXTERN(int) git_describe_init_format_options(git_describe_format_options *opts, unsigned int version); typedef struct git_describe_result git_describe_result; /** * Describe a commit * * Perform the describe operation on the given committish object. * * @param result pointer to store the result. You must free this once * you're done with it. * @param committish a committish to describe * @param opts the lookup options */ GIT_EXTERN(int) git_describe_commit( git_describe_result **result, git_object *committish, git_describe_options *opts); /** * Describe a commit * * Perform the describe operation on the current commit and the * worktree. After peforming describe on HEAD, a status is run and the * description is considered to be dirty if there are. * * @param out pointer to store the result. You must free this once * you're done with it. * @param repo the repository in which to perform the describe * @param opts the lookup options */ GIT_EXTERN(int) git_describe_workdir( git_describe_result **out, git_repository *repo, git_describe_options *opts); /** * Print the describe result to a buffer * * @param out The buffer to store the result * @param result the result from `git_describe_commit()` or * `git_describe_workdir()`. * @param opts the formatting options */ GIT_EXTERN(int) git_describe_format( git_buf *out, const git_describe_result *result, const git_describe_format_options *opts); /** * Free the describe result. */ GIT_EXTERN(void) git_describe_result_free(git_describe_result *result); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/index.h0000664000175000017500000006340512610310643016657 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_index_h__ #define INCLUDE_git_index_h__ #include "common.h" #include "indexer.h" #include "types.h" #include "oid.h" #include "strarray.h" /** * @file git2/index.h * @brief Git index parsing and manipulation routines * @defgroup git_index Git index parsing and manipulation routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** Time structure used in a git index entry */ typedef struct { int32_t seconds; /* nsec should not be stored as time_t compatible */ uint32_t nanoseconds; } git_index_time; /** * In-memory representation of a file entry in the index. * * This is a public structure that represents a file entry in the index. * The meaning of the fields corresponds to core Git's documentation (in * "Documentation/technical/index-format.txt"). * * The `flags` field consists of a number of bit fields which can be * accessed via the first set of `GIT_IDXENTRY_...` bitmasks below. These * flags are all read from and persisted to disk. * * The `flags_extended` field also has a number of bit fields which can be * accessed via the later `GIT_IDXENTRY_...` bitmasks below. Some of * these flags are read from and written to disk, but some are set aside * for in-memory only reference. * * Note that the time and size fields are truncated to 32 bits. This * is enough to detect changes, which is enough for the index to * function as a cache, but it should not be taken as an authoritative * source for that data. */ typedef struct git_index_entry { git_index_time ctime; git_index_time mtime; uint32_t dev; uint32_t ino; uint32_t mode; uint32_t uid; uint32_t gid; uint32_t file_size; git_oid id; uint16_t flags; uint16_t flags_extended; const char *path; } git_index_entry; /** * Bitmasks for on-disk fields of `git_index_entry`'s `flags` * * These bitmasks match the four fields in the `git_index_entry` `flags` * value both in memory and on disk. You can use them to interpret the * data in the `flags`. */ #define GIT_IDXENTRY_NAMEMASK (0x0fff) #define GIT_IDXENTRY_STAGEMASK (0x3000) #define GIT_IDXENTRY_STAGESHIFT 12 /** * Flags for index entries */ typedef enum { GIT_IDXENTRY_EXTENDED = (0x4000), GIT_IDXENTRY_VALID = (0x8000), } git_indxentry_flag_t; #define GIT_IDXENTRY_STAGE(E) \ (((E)->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT) #define GIT_IDXENTRY_STAGE_SET(E,S) do { \ (E)->flags = ((E)->flags & ~GIT_IDXENTRY_STAGEMASK) | \ (((S) & 0x03) << GIT_IDXENTRY_STAGESHIFT); } while (0) /** * Bitmasks for on-disk fields of `git_index_entry`'s `flags_extended` * * In memory, the `flags_extended` fields are divided into two parts: the * fields that are read from and written to disk, and other fields that * in-memory only and used by libgit2. Only the flags in * `GIT_IDXENTRY_EXTENDED_FLAGS` will get saved on-disk. * * Thee first three bitmasks match the three fields in the * `git_index_entry` `flags_extended` value that belong on disk. You * can use them to interpret the data in the `flags_extended`. * * The rest of the bitmasks match the other fields in the `git_index_entry` * `flags_extended` value that are only used in-memory by libgit2. * You can use them to interpret the data in the `flags_extended`. * */ typedef enum { GIT_IDXENTRY_INTENT_TO_ADD = (1 << 13), GIT_IDXENTRY_SKIP_WORKTREE = (1 << 14), /** Reserved for future extension */ GIT_IDXENTRY_EXTENDED2 = (1 << 15), GIT_IDXENTRY_EXTENDED_FLAGS = (GIT_IDXENTRY_INTENT_TO_ADD | GIT_IDXENTRY_SKIP_WORKTREE), GIT_IDXENTRY_UPDATE = (1 << 0), GIT_IDXENTRY_REMOVE = (1 << 1), GIT_IDXENTRY_UPTODATE = (1 << 2), GIT_IDXENTRY_ADDED = (1 << 3), GIT_IDXENTRY_HASHED = (1 << 4), GIT_IDXENTRY_UNHASHED = (1 << 5), GIT_IDXENTRY_WT_REMOVE = (1 << 6), /**< remove in work directory */ GIT_IDXENTRY_CONFLICTED = (1 << 7), GIT_IDXENTRY_UNPACKED = (1 << 8), GIT_IDXENTRY_NEW_SKIP_WORKTREE = (1 << 9), } git_idxentry_extended_flag_t; /** Capabilities of system that affect index actions. */ typedef enum { GIT_INDEXCAP_IGNORE_CASE = 1, GIT_INDEXCAP_NO_FILEMODE = 2, GIT_INDEXCAP_NO_SYMLINKS = 4, GIT_INDEXCAP_FROM_OWNER = -1, } git_indexcap_t; /** Callback for APIs that add/remove/update files matching pathspec */ typedef int (*git_index_matched_path_cb)( const char *path, const char *matched_pathspec, void *payload); /** Flags for APIs that add files matching pathspec */ typedef enum { GIT_INDEX_ADD_DEFAULT = 0, GIT_INDEX_ADD_FORCE = (1u << 0), GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH = (1u << 1), GIT_INDEX_ADD_CHECK_PATHSPEC = (1u << 2), } git_index_add_option_t; typedef enum { /** * Match any index stage. * * Some index APIs take a stage to match; pass this value to match * any entry matching the path regardless of stage. */ GIT_INDEX_STAGE_ANY = -1, /** A normal staged file in the index. */ GIT_INDEX_STAGE_NORMAL = 0, /** The ancestor side of a conflict. */ GIT_INDEX_STAGE_ANCESTOR = 1, /** The "ours" side of a conflict. */ GIT_INDEX_STAGE_OURS = 2, /** The "theirs" side of a conflict. */ GIT_INDEX_STAGE_THEIRS = 3, } git_index_stage_t; /** @name Index File Functions * * These functions work on the index file itself. */ /**@{*/ /** * Create a new bare Git index object as a memory representation * of the Git index file in 'index_path', without a repository * to back it. * * Since there is no ODB or working directory behind this index, * any Index methods which rely on these (e.g. index_add_bypath) * will fail with the GIT_ERROR error code. * * If you need to access the index of an actual repository, * use the `git_repository_index` wrapper. * * The index must be freed once it's no longer in use. * * @param out the pointer for the new index * @param index_path the path to the index file in disk * @return 0 or an error code */ GIT_EXTERN(int) git_index_open(git_index **out, const char *index_path); /** * Create an in-memory index object. * * This index object cannot be read/written to the filesystem, * but may be used to perform in-memory index operations. * * The index must be freed once it's no longer in use. * * @param out the pointer for the new index * @return 0 or an error code */ GIT_EXTERN(int) git_index_new(git_index **out); /** * Free an existing index object. * * @param index an existing index object */ GIT_EXTERN(void) git_index_free(git_index *index); /** * Get the repository this index relates to * * @param index The index * @return A pointer to the repository */ GIT_EXTERN(git_repository *) git_index_owner(const git_index *index); /** * Read index capabilities flags. * * @param index An existing index object * @return A combination of GIT_INDEXCAP values */ GIT_EXTERN(int) git_index_caps(const git_index *index); /** * Set index capabilities flags. * * If you pass `GIT_INDEXCAP_FROM_OWNER` for the caps, then the * capabilities will be read from the config of the owner object, * looking at `core.ignorecase`, `core.filemode`, `core.symlinks`. * * @param index An existing index object * @param caps A combination of GIT_INDEXCAP values * @return 0 on success, -1 on failure */ GIT_EXTERN(int) git_index_set_caps(git_index *index, int caps); /** * Update the contents of an existing index object in memory by reading * from the hard disk. * * If `force` is true, this performs a "hard" read that discards in-memory * changes and always reloads the on-disk index data. If there is no * on-disk version, the index will be cleared. * * If `force` is false, this does a "soft" read that reloads the index * data from disk only if it has changed since the last time it was * loaded. Purely in-memory index data will be untouched. Be aware: if * there are changes on disk, unwritten in-memory changes are discarded. * * @param index an existing index object * @param force if true, always reload, vs. only read if file has changed * @return 0 or an error code */ GIT_EXTERN(int) git_index_read(git_index *index, int force); /** * Write an existing index object from memory back to disk * using an atomic file lock. * * @param index an existing index object * @return 0 or an error code */ GIT_EXTERN(int) git_index_write(git_index *index); /** * Get the full path to the index file on disk. * * @param index an existing index object * @return path to index file or NULL for in-memory index */ GIT_EXTERN(const char *) git_index_path(const git_index *index); /** * Get the checksum of the index * * This checksum is the SHA-1 hash over the index file (except the * last 20 bytes which are the checksum itself). In cases where the * index does not exist on-disk, it will be zeroed out. * * @param index an existing index object * @return a pointer to the checksum of the index */ GIT_EXTERN(const git_oid *) git_index_checksum(git_index *index); /** * Read a tree into the index file with stats * * The current index contents will be replaced by the specified tree. * * @param index an existing index object * @param tree tree to read * @return 0 or an error code */ GIT_EXTERN(int) git_index_read_tree(git_index *index, const git_tree *tree); /** * Write the index as a tree * * This method will scan the index and write a representation * of its current state back to disk; it recursively creates * tree objects for each of the subtrees stored in the index, * but only returns the OID of the root tree. This is the OID * that can be used e.g. to create a commit. * * The index instance cannot be bare, and needs to be associated * to an existing repository. * * The index must not contain any file in conflict. * * @param out Pointer where to store the OID of the written tree * @param index Index to write * @return 0 on success, GIT_EUNMERGED when the index is not clean * or an error code */ GIT_EXTERN(int) git_index_write_tree(git_oid *out, git_index *index); /** * Write the index as a tree to the given repository * * This method will do the same as `git_index_write_tree`, but * letting the user choose the repository where the tree will * be written. * * The index must not contain any file in conflict. * * @param out Pointer where to store OID of the the written tree * @param index Index to write * @param repo Repository where to write the tree * @return 0 on success, GIT_EUNMERGED when the index is not clean * or an error code */ GIT_EXTERN(int) git_index_write_tree_to(git_oid *out, git_index *index, git_repository *repo); /**@}*/ /** @name Raw Index Entry Functions * * These functions work on index entries, and allow for raw manipulation * of the entries. */ /**@{*/ /* Index entry manipulation */ /** * Get the count of entries currently in the index * * @param index an existing index object * @return integer of count of current entries */ GIT_EXTERN(size_t) git_index_entrycount(const git_index *index); /** * Clear the contents (all the entries) of an index object. * * This clears the index object in memory; changes must be explicitly * written to disk for them to take effect persistently. * * @param index an existing index object * @return 0 on success, error code < 0 on failure */ GIT_EXTERN(int) git_index_clear(git_index *index); /** * Get a pointer to one of the entries in the index * * The entry is not modifiable and should not be freed. Because the * `git_index_entry` struct is a publicly defined struct, you should * be able to make your own permanent copy of the data if necessary. * * @param index an existing index object * @param n the position of the entry * @return a pointer to the entry; NULL if out of bounds */ GIT_EXTERN(const git_index_entry *) git_index_get_byindex( git_index *index, size_t n); /** * Get a pointer to one of the entries in the index * * The entry is not modifiable and should not be freed. Because the * `git_index_entry` struct is a publicly defined struct, you should * be able to make your own permanent copy of the data if necessary. * * @param index an existing index object * @param path path to search * @param stage stage to search * @return a pointer to the entry; NULL if it was not found */ GIT_EXTERN(const git_index_entry *) git_index_get_bypath( git_index *index, const char *path, int stage); /** * Remove an entry from the index * * @param index an existing index object * @param path path to search * @param stage stage to search * @return 0 or an error code */ GIT_EXTERN(int) git_index_remove(git_index *index, const char *path, int stage); /** * Remove all entries from the index under a given directory * * @param index an existing index object * @param dir container directory path * @param stage stage to search * @return 0 or an error code */ GIT_EXTERN(int) git_index_remove_directory( git_index *index, const char *dir, int stage); /** * Add or update an index entry from an in-memory struct * * If a previous index entry exists that has the same path and stage * as the given 'source_entry', it will be replaced. Otherwise, the * 'source_entry' will be added. * * A full copy (including the 'path' string) of the given * 'source_entry' will be inserted on the index. * * @param index an existing index object * @param source_entry new entry object * @return 0 or an error code */ GIT_EXTERN(int) git_index_add(git_index *index, const git_index_entry *source_entry); /** * Return the stage number from a git index entry * * This entry is calculated from the entry's flag attribute like this: * * (entry->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT * * @param entry The entry * @return the stage number */ GIT_EXTERN(int) git_index_entry_stage(const git_index_entry *entry); /** * Return whether the given index entry is a conflict (has a high stage * entry). This is simply shorthand for `git_index_entry_stage > 0`. * * @param entry The entry * @return 1 if the entry is a conflict entry, 0 otherwise */ GIT_EXTERN(int) git_index_entry_is_conflict(const git_index_entry *entry); /**@}*/ /** @name Workdir Index Entry Functions * * These functions work on index entries specifically in the working * directory (ie, stage 0). */ /**@{*/ /** * Add or update an index entry from a file on disk * * The file `path` must be relative to the repository's * working folder and must be readable. * * This method will fail in bare index instances. * * This forces the file to be added to the index, not looking * at gitignore rules. Those rules can be evaluated through * the git_status APIs (in status.h) before calling this. * * If this file currently is the result of a merge conflict, this * file will no longer be marked as conflicting. The data about * the conflict will be moved to the "resolve undo" (REUC) section. * * @param index an existing index object * @param path filename to add * @return 0 or an error code */ GIT_EXTERN(int) git_index_add_bypath(git_index *index, const char *path); /** * Add or update an index entry from a buffer in memory * * This method will create a blob in the repository that owns the * index and then add the index entry to the index. The `path` of the * entry represents the position of the blob relative to the * repository's root folder. * * If a previous index entry exists that has the same path as the * given 'entry', it will be replaced. Otherwise, the 'entry' will be * added. The `id` and the `file_size` of the 'entry' are updated with the * real value of the blob. * * This forces the file to be added to the index, not looking * at gitignore rules. Those rules can be evaluated through * the git_status APIs (in status.h) before calling this. * * If this file currently is the result of a merge conflict, this * file will no longer be marked as conflicting. The data about * the conflict will be moved to the "resolve undo" (REUC) section. * * @param index an existing index object * @param entry filename to add * @param buffer data to be written into the blob * @param len length of the data * @return 0 or an error code */ GIT_EXTERN(int) git_index_add_frombuffer( git_index *index, const git_index_entry *entry, const void *buffer, size_t len); /** * Remove an index entry corresponding to a file on disk * * The file `path` must be relative to the repository's * working folder. It may exist. * * If this file currently is the result of a merge conflict, this * file will no longer be marked as conflicting. The data about * the conflict will be moved to the "resolve undo" (REUC) section. * * @param index an existing index object * @param path filename to remove * @return 0 or an error code */ GIT_EXTERN(int) git_index_remove_bypath(git_index *index, const char *path); /** * Add or update index entries matching files in the working directory. * * This method will fail in bare index instances. * * The `pathspec` is a list of file names or shell glob patterns that will * matched against files in the repository's working directory. Each file * that matches will be added to the index (either updating an existing * entry or adding a new entry). You can disable glob expansion and force * exact matching with the `GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH` flag. * * Files that are ignored will be skipped (unlike `git_index_add_bypath`). * If a file is already tracked in the index, then it *will* be updated * even if it is ignored. Pass the `GIT_INDEX_ADD_FORCE` flag to * skip the checking of ignore rules. * * To emulate `git add -A` and generate an error if the pathspec contains * the exact path of an ignored file (when not using FORCE), add the * `GIT_INDEX_ADD_CHECK_PATHSPEC` flag. This checks that each entry * in the `pathspec` that is an exact match to a filename on disk is * either not ignored or already in the index. If this check fails, the * function will return GIT_EINVALIDSPEC. * * To emulate `git add -A` with the "dry-run" option, just use a callback * function that always returns a positive value. See below for details. * * If any files are currently the result of a merge conflict, those files * will no longer be marked as conflicting. The data about the conflicts * will be moved to the "resolve undo" (REUC) section. * * If you provide a callback function, it will be invoked on each matching * item in the working directory immediately *before* it is added to / * updated in the index. Returning zero will add the item to the index, * greater than zero will skip the item, and less than zero will abort the * scan and return that value to the caller. * * @param index an existing index object * @param pathspec array of path patterns * @param flags combination of git_index_add_option_t flags * @param callback notification callback for each added/updated path (also * gets index of matching pathspec entry); can be NULL; * return 0 to add, >0 to skip, <0 to abort scan. * @param payload payload passed through to callback function * @return 0 on success, negative callback return value, or error code */ GIT_EXTERN(int) git_index_add_all( git_index *index, const git_strarray *pathspec, unsigned int flags, git_index_matched_path_cb callback, void *payload); /** * Remove all matching index entries. * * If you provide a callback function, it will be invoked on each matching * item in the index immediately *before* it is removed. Return 0 to * remove the item, > 0 to skip the item, and < 0 to abort the scan. * * @param index An existing index object * @param pathspec array of path patterns * @param callback notification callback for each removed path (also * gets index of matching pathspec entry); can be NULL; * return 0 to add, >0 to skip, <0 to abort scan. * @param payload payload passed through to callback function * @return 0 on success, negative callback return value, or error code */ GIT_EXTERN(int) git_index_remove_all( git_index *index, const git_strarray *pathspec, git_index_matched_path_cb callback, void *payload); /** * Update all index entries to match the working directory * * This method will fail in bare index instances. * * This scans the existing index entries and synchronizes them with the * working directory, deleting them if the corresponding working directory * file no longer exists otherwise updating the information (including * adding the latest version of file to the ODB if needed). * * If you provide a callback function, it will be invoked on each matching * item in the index immediately *before* it is updated (either refreshed * or removed depending on working directory state). Return 0 to proceed * with updating the item, > 0 to skip the item, and < 0 to abort the scan. * * @param index An existing index object * @param pathspec array of path patterns * @param callback notification callback for each updated path (also * gets index of matching pathspec entry); can be NULL; * return 0 to add, >0 to skip, <0 to abort scan. * @param payload payload passed through to callback function * @return 0 on success, negative callback return value, or error code */ GIT_EXTERN(int) git_index_update_all( git_index *index, const git_strarray *pathspec, git_index_matched_path_cb callback, void *payload); /** * Find the first position of any entries which point to given * path in the Git index. * * @param at_pos the address to which the position of the index entry is written (optional) * @param index an existing index object * @param path path to search * @return a zero-based position in the index if found; GIT_ENOTFOUND otherwise */ GIT_EXTERN(int) git_index_find(size_t *at_pos, git_index *index, const char *path); /** * Find the first position of any entries matching a prefix. To find the first position * of a path inside a given folder, suffix the prefix with a '/'. * * @param at_pos the address to which the position of the index entry is written (optional) * @param index an existing index object * @param prefix the prefix to search for * @return 0 with valid value in at_pos; an error code otherwise */ GIT_EXTERN(int) git_index_find_prefix(size_t *at_pos, git_index *index, const char *prefix); /**@}*/ /** @name Conflict Index Entry Functions * * These functions work on conflict index entries specifically (ie, stages 1-3) */ /**@{*/ /** * Add or update index entries to represent a conflict. Any staged * entries that exist at the given paths will be removed. * * The entries are the entries from the tree included in the merge. Any * entry may be null to indicate that that file was not present in the * trees during the merge. For example, ancestor_entry may be NULL to * indicate that a file was added in both branches and must be resolved. * * @param index an existing index object * @param ancestor_entry the entry data for the ancestor of the conflict * @param our_entry the entry data for our side of the merge conflict * @param their_entry the entry data for their side of the merge conflict * @return 0 or an error code */ GIT_EXTERN(int) git_index_conflict_add( git_index *index, const git_index_entry *ancestor_entry, const git_index_entry *our_entry, const git_index_entry *their_entry); /** * Get the index entries that represent a conflict of a single file. * * The entries are not modifiable and should not be freed. Because the * `git_index_entry` struct is a publicly defined struct, you should * be able to make your own permanent copy of the data if necessary. * * @param ancestor_out Pointer to store the ancestor entry * @param our_out Pointer to store the our entry * @param their_out Pointer to store the their entry * @param index an existing index object * @param path path to search * @return 0 or an error code */ GIT_EXTERN(int) git_index_conflict_get( const git_index_entry **ancestor_out, const git_index_entry **our_out, const git_index_entry **their_out, git_index *index, const char *path); /** * Removes the index entries that represent a conflict of a single file. * * @param index an existing index object * @param path path to remove conflicts for * @return 0 or an error code */ GIT_EXTERN(int) git_index_conflict_remove(git_index *index, const char *path); /** * Remove all conflicts in the index (entries with a stage greater than 0). * * @param index an existing index object * @return 0 or an error code */ GIT_EXTERN(int) git_index_conflict_cleanup(git_index *index); /** * Determine if the index contains entries representing file conflicts. * * @return 1 if at least one conflict is found, 0 otherwise. */ GIT_EXTERN(int) git_index_has_conflicts(const git_index *index); /** * Create an iterator for the conflicts in the index. * * The index must not be modified while iterating; the results are undefined. * * @param iterator_out The newly created conflict iterator * @param index The index to scan * @return 0 or an error code */ GIT_EXTERN(int) git_index_conflict_iterator_new( git_index_conflict_iterator **iterator_out, git_index *index); /** * Returns the current conflict (ancestor, ours and theirs entry) and * advance the iterator internally to the next value. * * @param ancestor_out Pointer to store the ancestor side of the conflict * @param our_out Pointer to store our side of the conflict * @param their_out Pointer to store their side of the conflict * @return 0 (no error), GIT_ITEROVER (iteration is done) or an error code * (negative value) */ GIT_EXTERN(int) git_index_conflict_next( const git_index_entry **ancestor_out, const git_index_entry **our_out, const git_index_entry **their_out, git_index_conflict_iterator *iterator); /** * Frees a `git_index_conflict_iterator`. * * @param iterator pointer to the iterator */ GIT_EXTERN(void) git_index_conflict_iterator_free( git_index_conflict_iterator *iterator); /**@}*/ /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/cred_helpers.h0000664000175000017500000000300412572105236020203 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_cred_helpers_h__ #define INCLUDE_git_cred_helpers_h__ #include "transport.h" /** * @file git2/cred_helpers.h * @brief Utility functions for credential management * @defgroup git_cred_helpers credential management helpers * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Payload for git_cred_stock_userpass_plaintext. */ typedef struct git_cred_userpass_payload { const char *username; const char *password; } git_cred_userpass_payload; /** * Stock callback usable as a git_cred_acquire_cb. This calls * git_cred_userpass_plaintext_new unless the protocol has not specified * `GIT_CREDTYPE_USERPASS_PLAINTEXT` as an allowed type. * * @param cred The newly created credential object. * @param url The resource for which we are demanding a credential. * @param user_from_url The username that was embedded in a "user\@host" * remote url, or NULL if not included. * @param allowed_types A bitmask stating which cred types are OK to return. * @param payload The payload provided when specifying this callback. (This is * interpreted as a `git_cred_userpass_payload*`.) */ GIT_EXTERN(int) git_cred_userpass( git_cred **cred, const char *url, const char *user_from_url, unsigned int allowed_types, void *payload); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/net.h0000664000175000017500000000230312510265101016321 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_net_h__ #define INCLUDE_git_net_h__ #include "common.h" #include "oid.h" #include "types.h" /** * @file git2/net.h * @brief Git networking declarations * @ingroup Git * @{ */ GIT_BEGIN_DECL #define GIT_DEFAULT_PORT "9418" /** * Direction of the connection. * * We need this because we need to know whether we should call * git-upload-pack or git-receive-pack on the remote end when get_refs * gets called. */ typedef enum { GIT_DIRECTION_FETCH = 0, GIT_DIRECTION_PUSH = 1 } git_direction; /** * Description of a reference advertised by a remote server, given out * on `ls` calls. */ struct git_remote_head { int local; /* available locally */ git_oid oid; git_oid loid; char *name; /** * If the server send a symref mapping for this ref, this will * point to the target. */ char *symref_target; }; /** * Callback for listing the remote heads */ typedef int (*git_headlist_cb)(git_remote_head *rhead, void *payload); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/global.h0000664000175000017500000000230012510265101016770 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_global_h__ #define INCLUDE_git_global_h__ #include "common.h" GIT_BEGIN_DECL /** * Init the global state * * This function must the called before any other libgit2 function in * order to set up global state and threading. * * This function may be called multiple times - it will return the number * of times the initialization has been called (including this one) that have * not subsequently been shutdown. * * @return the number of initializations of the library, or an error code. */ GIT_EXTERN(int) git_libgit2_init(void); /** * Shutdown the global state * * Clean up the global state and threading context after calling it as * many times as `git_libgit2_init()` was called - it will return the * number of remainining initializations that have not been shutdown * (after this one). * * @return the number of remaining initializations of the library, or an * error code. */ GIT_EXTERN(int) git_libgit2_shutdown(void); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/cherrypick.h0000664000175000017500000000523512510265101017705 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_cherrypick_h__ #define INCLUDE_git_cherrypick_h__ #include "common.h" #include "types.h" #include "merge.h" /** * @file git2/cherrypick.h * @brief Git cherry-pick routines * @defgroup git_cherrypick Git cherry-pick routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Cherry-pick options */ typedef struct { unsigned int version; /** For merge commits, the "mainline" is treated as the parent. */ unsigned int mainline; git_merge_options merge_opts; /**< Options for the merging */ git_checkout_options checkout_opts; /**< Options for the checkout */ } git_cherrypick_options; #define GIT_CHERRYPICK_OPTIONS_VERSION 1 #define GIT_CHERRYPICK_OPTIONS_INIT {GIT_CHERRYPICK_OPTIONS_VERSION, 0, GIT_MERGE_OPTIONS_INIT, GIT_CHECKOUT_OPTIONS_INIT} /** * Initializes a `git_cherrypick_options` with default values. Equivalent to * creating an instance with GIT_CHERRYPICK_OPTIONS_INIT. * * @param opts the `git_cherrypick_options` struct to initialize * @param version Version of struct; pass `GIT_CHERRYPICK_OPTIONS_VERSION` * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_cherrypick_init_options( git_cherrypick_options *opts, unsigned int version); /** * Cherry-picks the given commit against the given "our" commit, producing an * index that reflects the result of the cherry-pick. * * The returned index must be freed explicitly with `git_index_free`. * * @param out pointer to store the index result in * @param repo the repository that contains the given commits * @param cherrypick_commit the commit to cherry-pick * @param our_commit the commit to revert against (eg, HEAD) * @param mainline the parent of the revert commit, if it is a merge * @param merge_options the merge options (or null for defaults) * @return zero on success, -1 on failure. */ GIT_EXTERN(int) git_cherrypick_commit( git_index **out, git_repository *repo, git_commit *cherrypick_commit, git_commit *our_commit, unsigned int mainline, const git_merge_options *merge_options); /** * Cherry-pick the given commit, producing changes in the index and working directory. * * @param repo the repository to cherry-pick * @param commit the commit to cherry-pick * @param cherrypick_options the cherry-pick options (or null for defaults) * @return zero on success, -1 on failure. */ GIT_EXTERN(int) git_cherrypick( git_repository *repo, git_commit *commit, const git_cherrypick_options *cherrypick_options); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/signature.h0000664000175000017500000000522212426525445017557 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_signature_h__ #define INCLUDE_git_signature_h__ #include "common.h" #include "types.h" /** * @file git2/signature.h * @brief Git signature creation * @defgroup git_signature Git signature creation * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Create a new action signature. * * Call `git_signature_free()` to free the data. * * Note: angle brackets ('<' and '>') characters are not allowed * to be used in either the `name` or the `email` parameter. * * @param out new signature, in case of error NULL * @param name name of the person * @param email email of the person * @param time time when the action happened * @param offset timezone offset in minutes for the time * @return 0 or an error code */ GIT_EXTERN(int) git_signature_new(git_signature **out, const char *name, const char *email, git_time_t time, int offset); /** * Create a new action signature with a timestamp of 'now'. * * Call `git_signature_free()` to free the data. * * @param out new signature, in case of error NULL * @param name name of the person * @param email email of the person * @return 0 or an error code */ GIT_EXTERN(int) git_signature_now(git_signature **out, const char *name, const char *email); /** * Create a new action signature with default user and now timestamp. * * This looks up the user.name and user.email from the configuration and * uses the current time as the timestamp, and creates a new signature * based on that information. It will return GIT_ENOTFOUND if either the * user.name or user.email are not set. * * @param out new signature * @param repo repository pointer * @return 0 on success, GIT_ENOTFOUND if config is missing, or error code */ GIT_EXTERN(int) git_signature_default(git_signature **out, git_repository *repo); /** * Create a copy of an existing signature. All internal strings are also * duplicated. * * Call `git_signature_free()` to free the data. * * @param dest pointer where to store the copy * @param sig signature to duplicate * @return 0 or an error code */ GIT_EXTERN(int) git_signature_dup(git_signature **dest, const git_signature *sig); /** * Free an existing signature. * * Because the signature is not an opaque structure, it is legal to free it * manually, but be sure to free the "name" and "email" strings in addition * to the structure itself. * * @param sig signature to free */ GIT_EXTERN(void) git_signature_free(git_signature *sig); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/commit.h0000664000175000017500000002630512555730137017052 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_commit_h__ #define INCLUDE_git_commit_h__ #include "common.h" #include "types.h" #include "oid.h" #include "object.h" /** * @file git2/commit.h * @brief Git commit parsing, formatting routines * @defgroup git_commit Git commit parsing, formatting routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Lookup a commit object from a repository. * * The returned object should be released with `git_commit_free` when no * longer needed. * * @param commit pointer to the looked up commit * @param repo the repo to use when locating the commit. * @param id identity of the commit to locate. If the object is * an annotated tag it will be peeled back to the commit. * @return 0 or an error code */ GIT_EXTERN(int) git_commit_lookup( git_commit **commit, git_repository *repo, const git_oid *id); /** * Lookup a commit object from a repository, given a prefix of its * identifier (short id). * * The returned object should be released with `git_commit_free` when no * longer needed. * * @see git_object_lookup_prefix * * @param commit pointer to the looked up commit * @param repo the repo to use when locating the commit. * @param id identity of the commit to locate. If the object is * an annotated tag it will be peeled back to the commit. * @param len the length of the short identifier * @return 0 or an error code */ GIT_EXTERN(int) git_commit_lookup_prefix( git_commit **commit, git_repository *repo, const git_oid *id, size_t len); /** * Close an open commit * * This is a wrapper around git_object_free() * * IMPORTANT: * It *is* necessary to call this method when you stop * using a commit. Failure to do so will cause a memory leak. * * @param commit the commit to close */ GIT_EXTERN(void) git_commit_free(git_commit *commit); /** * Get the id of a commit. * * @param commit a previously loaded commit. * @return object identity for the commit. */ GIT_EXTERN(const git_oid *) git_commit_id(const git_commit *commit); /** * Get the repository that contains the commit. * * @param commit A previously loaded commit. * @return Repository that contains this commit. */ GIT_EXTERN(git_repository *) git_commit_owner(const git_commit *commit); /** * Get the encoding for the message of a commit, * as a string representing a standard encoding name. * * The encoding may be NULL if the `encoding` header * in the commit is missing; in that case UTF-8 is assumed. * * @param commit a previously loaded commit. * @return NULL, or the encoding */ GIT_EXTERN(const char *) git_commit_message_encoding(const git_commit *commit); /** * Get the full message of a commit. * * The returned message will be slightly prettified by removing any * potential leading newlines. * * @param commit a previously loaded commit. * @return the message of a commit */ GIT_EXTERN(const char *) git_commit_message(const git_commit *commit); /** * Get the full raw message of a commit. * * @param commit a previously loaded commit. * @return the raw message of a commit */ GIT_EXTERN(const char *) git_commit_message_raw(const git_commit *commit); /** * Get the short "summary" of the git commit message. * * The returned message is the summary of the commit, comprising the * first paragraph of the message with whitespace trimmed and squashed. * * @param commit a previously loaded commit. * @return the summary of a commit or NULL on error */ GIT_EXTERN(const char *) git_commit_summary(git_commit *commit); /** * Get the commit time (i.e. committer time) of a commit. * * @param commit a previously loaded commit. * @return the time of a commit */ GIT_EXTERN(git_time_t) git_commit_time(const git_commit *commit); /** * Get the commit timezone offset (i.e. committer's preferred timezone) of a commit. * * @param commit a previously loaded commit. * @return positive or negative timezone offset, in minutes from UTC */ GIT_EXTERN(int) git_commit_time_offset(const git_commit *commit); /** * Get the committer of a commit. * * @param commit a previously loaded commit. * @return the committer of a commit */ GIT_EXTERN(const git_signature *) git_commit_committer(const git_commit *commit); /** * Get the author of a commit. * * @param commit a previously loaded commit. * @return the author of a commit */ GIT_EXTERN(const git_signature *) git_commit_author(const git_commit *commit); /** * Get the full raw text of the commit header. * * @param commit a previously loaded commit * @return the header text of the commit */ GIT_EXTERN(const char *) git_commit_raw_header(const git_commit *commit); /** * Get the tree pointed to by a commit. * * @param tree_out pointer where to store the tree object * @param commit a previously loaded commit. * @return 0 or an error code */ GIT_EXTERN(int) git_commit_tree(git_tree **tree_out, const git_commit *commit); /** * Get the id of the tree pointed to by a commit. This differs from * `git_commit_tree` in that no attempts are made to fetch an object * from the ODB. * * @param commit a previously loaded commit. * @return the id of tree pointed to by commit. */ GIT_EXTERN(const git_oid *) git_commit_tree_id(const git_commit *commit); /** * Get the number of parents of this commit * * @param commit a previously loaded commit. * @return integer of count of parents */ GIT_EXTERN(unsigned int) git_commit_parentcount(const git_commit *commit); /** * Get the specified parent of the commit. * * @param out Pointer where to store the parent commit * @param commit a previously loaded commit. * @param n the position of the parent (from 0 to `parentcount`) * @return 0 or an error code */ GIT_EXTERN(int) git_commit_parent( git_commit **out, const git_commit *commit, unsigned int n); /** * Get the oid of a specified parent for a commit. This is different from * `git_commit_parent`, which will attempt to load the parent commit from * the ODB. * * @param commit a previously loaded commit. * @param n the position of the parent (from 0 to `parentcount`) * @return the id of the parent, NULL on error. */ GIT_EXTERN(const git_oid *) git_commit_parent_id( const git_commit *commit, unsigned int n); /** * Get the commit object that is the th generation ancestor * of the named commit object, following only the first parents. * The returned commit has to be freed by the caller. * * Passing `0` as the generation number returns another instance of the * base commit itself. * * @param ancestor Pointer where to store the ancestor commit * @param commit a previously loaded commit. * @param n the requested generation * @return 0 on success; GIT_ENOTFOUND if no matching ancestor exists * or an error code */ GIT_EXTERN(int) git_commit_nth_gen_ancestor( git_commit **ancestor, const git_commit *commit, unsigned int n); /** * Get an arbitrary header field * * @param out the buffer to fill * @param commit the commit to look in * @param field the header field to return * @return 0 on succeess, GIT_ENOTFOUND if the field does not exist, * or an error code */ GIT_EXTERN(int) git_commit_header_field(git_buf *out, const git_commit *commit, const char *field); /** * Create new commit in the repository from a list of `git_object` pointers * * The message will **not** be cleaned up automatically. You can do that * with the `git_message_prettify()` function. * * @param id Pointer in which to store the OID of the newly created commit * * @param repo Repository where to store the commit * * @param update_ref If not NULL, name of the reference that * will be updated to point to this commit. If the reference * is not direct, it will be resolved to a direct reference. * Use "HEAD" to update the HEAD of the current branch and * make it point to this commit. If the reference doesn't * exist yet, it will be created. If it does exist, the first * parent must be the tip of this branch. * * @param author Signature with author and author time of commit * * @param committer Signature with committer and * commit time of commit * * @param message_encoding The encoding for the message in the * commit, represented with a standard encoding name. * E.g. "UTF-8". If NULL, no encoding header is written and * UTF-8 is assumed. * * @param message Full message for this commit * * @param tree An instance of a `git_tree` object that will * be used as the tree for the commit. This tree object must * also be owned by the given `repo`. * * @param parent_count Number of parents for this commit * * @param parents Array of `parent_count` pointers to `git_commit` * objects that will be used as the parents for this commit. This * array may be NULL if `parent_count` is 0 (root commit). All the * given commits must be owned by the `repo`. * * @return 0 or an error code * The created commit will be written to the Object Database and * the given reference will be updated to point to it */ GIT_EXTERN(int) git_commit_create( git_oid *id, git_repository *repo, const char *update_ref, const git_signature *author, const git_signature *committer, const char *message_encoding, const char *message, const git_tree *tree, size_t parent_count, const git_commit *parents[]); /** * Create new commit in the repository using a variable argument list. * * The message will **not** be cleaned up automatically. You can do that * with the `git_message_prettify()` function. * * The parents for the commit are specified as a variable list of pointers * to `const git_commit *`. Note that this is a convenience method which may * not be safe to export for certain languages or compilers * * All other parameters remain the same as `git_commit_create()`. * * @see git_commit_create */ GIT_EXTERN(int) git_commit_create_v( git_oid *id, git_repository *repo, const char *update_ref, const git_signature *author, const git_signature *committer, const char *message_encoding, const char *message, const git_tree *tree, size_t parent_count, ...); /** * Amend an existing commit by replacing only non-NULL values. * * This creates a new commit that is exactly the same as the old commit, * except that any non-NULL values will be updated. The new commit has * the same parents as the old commit. * * The `update_ref` value works as in the regular `git_commit_create()`, * updating the ref to point to the newly rewritten commit. If you want * to amend a commit that is not currently the tip of the branch and then * rewrite the following commits to reach a ref, pass this as NULL and * update the rest of the commit chain and ref separately. * * Unlike `git_commit_create()`, the `author`, `committer`, `message`, * `message_encoding`, and `tree` parameters can be NULL in which case this * will use the values from the original `commit_to_amend`. * * All parameters have the same meanings as in `git_commit_create()`. * * @see git_commit_create */ GIT_EXTERN(int) git_commit_amend( git_oid *id, const git_commit *commit_to_amend, const char *update_ref, const git_signature *author, const git_signature *committer, const char *message_encoding, const char *message, const git_tree *tree); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/clone.h0000664000175000017500000001347212555730137016663 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_clone_h__ #define INCLUDE_git_clone_h__ #include "common.h" #include "types.h" #include "indexer.h" #include "checkout.h" #include "remote.h" #include "transport.h" /** * @file git2/clone.h * @brief Git cloning routines * @defgroup git_clone Git cloning routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Options for bypassing the git-aware transport on clone. Bypassing * it means that instead of a fetch, libgit2 will copy the object * database directory instead of figuring out what it needs, which is * faster. If possible, it will hardlink the files to save space. */ typedef enum { /** * Auto-detect (default), libgit2 will bypass the git-aware * transport for local paths, but use a normal fetch for * `file://` urls. */ GIT_CLONE_LOCAL_AUTO, /** * Bypass the git-aware transport even for a `file://` url. */ GIT_CLONE_LOCAL, /** * Do no bypass the git-aware transport */ GIT_CLONE_NO_LOCAL, /** * Bypass the git-aware transport, but do not try to use * hardlinks. */ GIT_CLONE_LOCAL_NO_LINKS, } git_clone_local_t; /** * The signature of a function matching git_remote_create, with an additional * void* as a callback payload. * * Callers of git_clone may provide a function matching this signature to override * the remote creation and customization process during a clone operation. * * @param out the resulting remote * @param repo the repository in which to create the remote * @param name the remote's name * @param url the remote's url * @param payload an opaque payload * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code */ typedef int (*git_remote_create_cb)( git_remote **out, git_repository *repo, const char *name, const char *url, void *payload); /** * The signature of a function matchin git_repository_init, with an * aditional void * as callback payload. * * Callers of git_clone my provide a function matching this signature * to override the repository creation and customization process * during a clone operation. * * @param out the resulting repository * @param path path in which to create the repository * @param bare whether the repository is bare. This is the value from the clone options * @param payload payload specified by the options * @return 0, or a negative value to indicate error */ typedef int (*git_repository_create_cb)( git_repository **out, const char *path, int bare, void *payload); /** * Clone options structure * * Use the GIT_CLONE_OPTIONS_INIT to get the default settings, like this: * * git_clone_options opts = GIT_CLONE_OPTIONS_INIT; */ typedef struct git_clone_options { unsigned int version; /** * These options are passed to the checkout step. To disable * checkout, set the `checkout_strategy` to * `GIT_CHECKOUT_NONE`. */ git_checkout_options checkout_opts; /** * Options which control the fetch, including callbacks. * * The callbacks are used for reporting fetch progress, and for acquiring * credentials in the event they are needed. */ git_fetch_options fetch_opts; /** * Set to zero (false) to create a standard repo, or non-zero * for a bare repo */ int bare; /** * Whether to use a fetch or copy the object database. */ git_clone_local_t local; /** * The name of the branch to checkout. NULL means use the * remote's default branch. */ const char* checkout_branch; /** * A callback used to create the new repository into which to * clone. If NULL, the 'bare' field will be used to determine * whether to create a bare repository. */ git_repository_create_cb repository_cb; /** * An opaque payload to pass to the git_repository creation callback. * This parameter is ignored unless repository_cb is non-NULL. */ void *repository_cb_payload; /** * A callback used to create the git_remote, prior to its being * used to perform the clone operation. See the documentation for * git_remote_create_cb for details. This parameter may be NULL, * indicating that git_clone should provide default behavior. */ git_remote_create_cb remote_cb; /** * An opaque payload to pass to the git_remote creation callback. * This parameter is ignored unless remote_cb is non-NULL. */ void *remote_cb_payload; } git_clone_options; #define GIT_CLONE_OPTIONS_VERSION 1 #define GIT_CLONE_OPTIONS_INIT { GIT_CLONE_OPTIONS_VERSION, \ { GIT_CHECKOUT_OPTIONS_VERSION, GIT_CHECKOUT_SAFE }, \ GIT_FETCH_OPTIONS_INIT } /** * Initializes a `git_clone_options` with default values. Equivalent to * creating an instance with GIT_CLONE_OPTIONS_INIT. * * @param opts The `git_clone_options` struct to initialize * @param version Version of struct; pass `GIT_CLONE_OPTIONS_VERSION` * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_clone_init_options( git_clone_options *opts, unsigned int version); /** * Clone a remote repository. * * By default this creates its repository and initial remote to match * git's defaults. You can use the options in the callback to * customize how these are created. * * @param out pointer that will receive the resulting repository object * @param url the remote repository to clone * @param local_path local directory to clone to * @param options configuration options for the clone. If NULL, the * function works as though GIT_OPTIONS_INIT were passed. * @return 0 on success, any non-zero return value from a callback * function, or a negative value to indicate an error (use * `giterr_last` for a detailed error message) */ GIT_EXTERN(int) git_clone( git_repository **out, const char *url, const char *local_path, const git_clone_options *options); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/reflog.h0000664000175000017500000001101012510265101017004 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_reflog_h__ #define INCLUDE_git_reflog_h__ #include "common.h" #include "types.h" #include "oid.h" /** * @file git2/reflog.h * @brief Git reflog management routines * @defgroup git_reflog Git reflog management routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Read the reflog for the given reference * * If there is no reflog file for the given * reference yet, an empty reflog object will * be returned. * * The reflog must be freed manually by using * git_reflog_free(). * * @param out pointer to reflog * @param repo the repostiory * @param name reference to look up * @return 0 or an error code */ GIT_EXTERN(int) git_reflog_read(git_reflog **out, git_repository *repo, const char *name); /** * Write an existing in-memory reflog object back to disk * using an atomic file lock. * * @param reflog an existing reflog object * @return 0 or an error code */ GIT_EXTERN(int) git_reflog_write(git_reflog *reflog); /** * Add a new entry to the in-memory reflog. * * `msg` is optional and can be NULL. * * @param reflog an existing reflog object * @param id the OID the reference is now pointing to * @param committer the signature of the committer * @param msg the reflog message * @return 0 or an error code */ GIT_EXTERN(int) git_reflog_append(git_reflog *reflog, const git_oid *id, const git_signature *committer, const char *msg); /** * Rename a reflog * * The reflog to be renamed is expected to already exist * * The new name will be checked for validity. * See `git_reference_create_symbolic()` for rules about valid names. * * @param repo the repository * @param old_name the old name of the reference * @param name the new name of the reference * @return 0 on success, GIT_EINVALIDSPEC or an error code */ GIT_EXTERN(int) git_reflog_rename(git_repository *repo, const char *old_name, const char *name); /** * Delete the reflog for the given reference * * @param repo the repository * @param name the reflog to delete * @return 0 or an error code */ GIT_EXTERN(int) git_reflog_delete(git_repository *repo, const char *name); /** * Get the number of log entries in a reflog * * @param reflog the previously loaded reflog * @return the number of log entries */ GIT_EXTERN(size_t) git_reflog_entrycount(git_reflog *reflog); /** * Lookup an entry by its index * * Requesting the reflog entry with an index of 0 (zero) will * return the most recently created entry. * * @param reflog a previously loaded reflog * @param idx the position of the entry to lookup. Should be greater than or * equal to 0 (zero) and less than `git_reflog_entrycount()`. * @return the entry; NULL if not found */ GIT_EXTERN(const git_reflog_entry *) git_reflog_entry_byindex(const git_reflog *reflog, size_t idx); /** * Remove an entry from the reflog by its index * * To ensure there's no gap in the log history, set `rewrite_previous_entry` * param value to 1. When deleting entry `n`, member old_oid of entry `n-1` * (if any) will be updated with the value of member new_oid of entry `n+1`. * * @param reflog a previously loaded reflog. * * @param idx the position of the entry to remove. Should be greater than or * equal to 0 (zero) and less than `git_reflog_entrycount()`. * * @param rewrite_previous_entry 1 to rewrite the history; 0 otherwise. * * @return 0 on success, GIT_ENOTFOUND if the entry doesn't exist * or an error code. */ GIT_EXTERN(int) git_reflog_drop( git_reflog *reflog, size_t idx, int rewrite_previous_entry); /** * Get the old oid * * @param entry a reflog entry * @return the old oid */ GIT_EXTERN(const git_oid *) git_reflog_entry_id_old(const git_reflog_entry *entry); /** * Get the new oid * * @param entry a reflog entry * @return the new oid at this time */ GIT_EXTERN(const git_oid *) git_reflog_entry_id_new(const git_reflog_entry *entry); /** * Get the committer of this entry * * @param entry a reflog entry * @return the committer */ GIT_EXTERN(const git_signature *) git_reflog_entry_committer(const git_reflog_entry *entry); /** * Get the log message * * @param entry a reflog entry * @return the log msg */ GIT_EXTERN(const char *) git_reflog_entry_message(const git_reflog_entry *entry); /** * Free the reflog * * @param reflog reflog to free */ GIT_EXTERN(void) git_reflog_free(git_reflog *reflog); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/common.h0000664000175000017500000001617712510265101017041 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_common_h__ #define INCLUDE_git_common_h__ #include #include #ifdef _MSC_VER # include "inttypes.h" #else # include #endif #ifdef __cplusplus # define GIT_BEGIN_DECL extern "C" { # define GIT_END_DECL } #else /** Start declarations in C mode */ # define GIT_BEGIN_DECL /* empty */ /** End declarations in C mode */ # define GIT_END_DECL /* empty */ #endif /** Declare a public function exported for application use. */ #if __GNUC__ >= 4 # define GIT_EXTERN(type) extern \ __attribute__((visibility("default"))) \ type #elif defined(_MSC_VER) # define GIT_EXTERN(type) __declspec(dllexport) type #else # define GIT_EXTERN(type) extern type #endif /** Declare a function's takes printf style arguments. */ #ifdef __GNUC__ # define GIT_FORMAT_PRINTF(a,b) __attribute__((format (printf, a, b))) #else # define GIT_FORMAT_PRINTF(a,b) /* empty */ #endif #if (defined(_WIN32)) && !defined(__CYGWIN__) #define GIT_WIN32 1 #endif #ifdef __amigaos4__ #include #endif /** * @file git2/common.h * @brief Git common platform definitions * @defgroup git_common Git common platform definitions * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * The separator used in path list strings (ie like in the PATH * environment variable). A semi-colon ";" is used on Windows, and * a colon ":" for all other systems. */ #ifdef GIT_WIN32 #define GIT_PATH_LIST_SEPARATOR ';' #else #define GIT_PATH_LIST_SEPARATOR ':' #endif /** * The maximum length of a valid git path. */ #define GIT_PATH_MAX 4096 /** * The string representation of the null object ID. */ #define GIT_OID_HEX_ZERO "0000000000000000000000000000000000000000" /** * Return the version of the libgit2 library * being currently used. * * @param major Store the major version number * @param minor Store the minor version number * @param rev Store the revision (patch) number */ GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev); /** * Combinations of these values describe the features with which libgit2 * was compiled */ typedef enum { GIT_FEATURE_THREADS = (1 << 0), GIT_FEATURE_HTTPS = (1 << 1), GIT_FEATURE_SSH = (1 << 2), } git_feature_t; /** * Query compile time options for libgit2. * * @return A combination of GIT_FEATURE_* values. * * - GIT_FEATURE_THREADS * Libgit2 was compiled with thread support. Note that thread support is * still to be seen as a 'work in progress' - basic object lookups are * believed to be threadsafe, but other operations may not be. * * - GIT_FEATURE_HTTPS * Libgit2 supports the https:// protocol. This requires the openssl * library to be found when compiling libgit2. * * - GIT_FEATURE_SSH * Libgit2 supports the SSH protocol for network operations. This requires * the libssh2 library to be found when compiling libgit2 */ GIT_EXTERN(int) git_libgit2_features(void); /** * Global library options * * These are used to select which global option to set or get and are * used in `git_libgit2_opts()`. */ typedef enum { GIT_OPT_GET_MWINDOW_SIZE, GIT_OPT_SET_MWINDOW_SIZE, GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, GIT_OPT_GET_SEARCH_PATH, GIT_OPT_SET_SEARCH_PATH, GIT_OPT_SET_CACHE_OBJECT_LIMIT, GIT_OPT_SET_CACHE_MAX_SIZE, GIT_OPT_ENABLE_CACHING, GIT_OPT_GET_CACHED_MEMORY, GIT_OPT_GET_TEMPLATE_PATH, GIT_OPT_SET_TEMPLATE_PATH, GIT_OPT_SET_SSL_CERT_LOCATIONS, } git_libgit2_opt_t; /** * Set or query a library global option * * Available options: * * * opts(GIT_OPT_GET_MWINDOW_SIZE, size_t *): * * > Get the maximum mmap window size * * * opts(GIT_OPT_SET_MWINDOW_SIZE, size_t): * * > Set the maximum mmap window size * * * opts(GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, size_t *): * * > Get the maximum memory that will be mapped in total by the library * * * opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t): * * >Set the maximum amount of memory that can be mapped at any time * by the library * * * opts(GIT_OPT_GET_SEARCH_PATH, int level, git_buf *buf) * * > Get the search path for a given level of config data. "level" must * > be one of `GIT_CONFIG_LEVEL_SYSTEM`, `GIT_CONFIG_LEVEL_GLOBAL`, or * > `GIT_CONFIG_LEVEL_XDG`. The search path is written to the `out` * > buffer. * * * opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path) * * > Set the search path for a level of config data. The search path * > applied to shared attributes and ignore files, too. * > * > - `path` lists directories delimited by GIT_PATH_LIST_SEPARATOR. * > Pass NULL to reset to the default (generally based on environment * > variables). Use magic path `$PATH` to include the old value * > of the path (if you want to prepend or append, for instance). * > * > - `level` must be GIT_CONFIG_LEVEL_SYSTEM, GIT_CONFIG_LEVEL_GLOBAL, * > or GIT_CONFIG_LEVEL_XDG. * * * opts(GIT_OPT_SET_CACHE_OBJECT_LIMIT, git_otype type, size_t size) * * > Set the maximum data size for the given type of object to be * > considered eligible for caching in memory. Setting to value to * > zero means that that type of object will not be cached. * > Defaults to 0 for GIT_OBJ_BLOB (i.e. won't cache blobs) and 4k * > for GIT_OBJ_COMMIT, GIT_OBJ_TREE, and GIT_OBJ_TAG. * * * opts(GIT_OPT_SET_CACHE_MAX_SIZE, ssize_t max_storage_bytes) * * > Set the maximum total data size that will be cached in memory * > across all repositories before libgit2 starts evicting objects * > from the cache. This is a soft limit, in that the library might * > briefly exceed it, but will start aggressively evicting objects * > from cache when that happens. The default cache size is 256MB. * * * opts(GIT_OPT_ENABLE_CACHING, int enabled) * * > Enable or disable caching completely. * > * > Because caches are repository-specific, disabling the cache * > cannot immediately clear all cached objects, but each cache will * > be cleared on the next attempt to update anything in it. * * * opts(GIT_OPT_GET_CACHED_MEMORY, ssize_t *current, ssize_t *allowed) * * > Get the current bytes in cache and the maximum that would be * > allowed in the cache. * * * opts(GIT_OPT_GET_TEMPLATE_PATH, git_buf *out) * * > Get the default template path. * > The path is written to the `out` buffer. * * * opts(GIT_OPT_SET_TEMPLATE_PATH, const char *path) * * > Set the default template path. * > * > - `path` directory of template. * * * opts(GIT_OPT_SET_SSL_CERT_LOCATIONS, const char *file, const char *path) * * > Set the SSL certificate-authority locations. * > * > - `file` is the location of a file containing several * > certificates concatenated together. * > - `path` is the location of a directory holding several * > certificates, one per file. * > * > Either parameter may be `NULL`, but not both. * * @param option Option key * @param ... value to set the option * @return 0 on success, <0 on failure */ GIT_EXTERN(int) git_libgit2_opts(int option, ...); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/reset.h0000664000175000017500000000644212555730137016704 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_reset_h__ #define INCLUDE_git_reset_h__ #include "common.h" #include "types.h" #include "strarray.h" #include "checkout.h" /** * @file git2/reset.h * @brief Git reset management routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Kinds of reset operation */ typedef enum { GIT_RESET_SOFT = 1, /**< Move the head to the given commit */ GIT_RESET_MIXED = 2, /**< SOFT plus reset index to the commit */ GIT_RESET_HARD = 3, /**< MIXED plus changes in working tree discarded */ } git_reset_t; /** * Sets the current head to the specified commit oid and optionally * resets the index and working tree to match. * * SOFT reset means the Head will be moved to the commit. * * MIXED reset will trigger a SOFT reset, plus the index will be replaced * with the content of the commit tree. * * HARD reset will trigger a MIXED reset and the working directory will be * replaced with the content of the index. (Untracked and ignored files * will be left alone, however.) * * TODO: Implement remaining kinds of resets. * * @param repo Repository where to perform the reset operation. * * @param target Committish to which the Head should be moved to. This object * must belong to the given `repo` and can either be a git_commit or a * git_tag. When a git_tag is being passed, it should be dereferencable * to a git_commit which oid will be used as the target of the branch. * * @param reset_type Kind of reset operation to perform. * * @param checkout_opts Checkout options to be used for a HARD reset. * The checkout_strategy field will be overridden (based on reset_type). * This parameter can be used to propagate notify and progress callbacks. * * @return 0 on success or an error code */ GIT_EXTERN(int) git_reset( git_repository *repo, git_object *target, git_reset_t reset_type, const git_checkout_options *checkout_opts); /** * Sets the current head to the specified commit oid and optionally * resets the index and working tree to match. * * This behaves like `git_reset()` but takes an annotated commit, * which lets you specify which extended sha syntax string was * specified by a user, allowing for more exact reflog messages. * * See the documentation for `git_reset()`. * * @see git_reset */ GIT_EXTERN(int) git_reset_from_annotated( git_repository *repo, git_annotated_commit *commit, git_reset_t reset_type, const git_checkout_options *checkout_opts); /** * Updates some entries in the index from the target commit tree. * * The scope of the updated entries is determined by the paths * being passed in the `pathspec` parameters. * * Passing a NULL `target` will result in removing * entries in the index matching the provided pathspecs. * * @param repo Repository where to perform the reset operation. * * @param target The committish which content will be used to reset the content * of the index. * * @param pathspecs List of pathspecs to operate on. * * @return 0 on success or an error code < 0 */ GIT_EXTERN(int) git_reset_default( git_repository *repo, git_object *target, git_strarray* pathspecs); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/refs.h0000664000175000017500000006426712510265101016513 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_refs_h__ #define INCLUDE_git_refs_h__ #include "common.h" #include "types.h" #include "oid.h" #include "strarray.h" /** * @file git2/refs.h * @brief Git reference management routines * @defgroup git_reference Git reference management routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Lookup a reference by name in a repository. * * The returned reference must be freed by the user. * * The name will be checked for validity. * See `git_reference_symbolic_create()` for rules about valid names. * * @param out pointer to the looked-up reference * @param repo the repository to look up the reference * @param name the long name for the reference (e.g. HEAD, refs/heads/master, refs/tags/v0.1.0, ...) * @return 0 on success, GIT_ENOTFOUND, GIT_EINVALIDSPEC or an error code. */ GIT_EXTERN(int) git_reference_lookup(git_reference **out, git_repository *repo, const char *name); /** * Lookup a reference by name and resolve immediately to OID. * * This function provides a quick way to resolve a reference name straight * through to the object id that it refers to. This avoids having to * allocate or free any `git_reference` objects for simple situations. * * The name will be checked for validity. * See `git_reference_symbolic_create()` for rules about valid names. * * @param out Pointer to oid to be filled in * @param repo The repository in which to look up the reference * @param name The long name for the reference (e.g. HEAD, refs/heads/master, refs/tags/v0.1.0, ...) * @return 0 on success, GIT_ENOTFOUND, GIT_EINVALIDSPEC or an error code. */ GIT_EXTERN(int) git_reference_name_to_id( git_oid *out, git_repository *repo, const char *name); /** * Lookup a reference by DWIMing its short name * * Apply the git precendence rules to the given shorthand to determine * which reference the user is referring to. * * @param out pointer in which to store the reference * @param repo the repository in which to look * @param shorthand the short name for the reference * @return 0 or an error code */ GIT_EXTERN(int) git_reference_dwim(git_reference **out, git_repository *repo, const char *shorthand); /** * Conditionally create a new symbolic reference. * * A symbolic reference is a reference name that refers to another * reference name. If the other name moves, the symbolic name will move, * too. As a simple example, the "HEAD" reference might refer to * "refs/heads/master" while on the "master" branch of a repository. * * The symbolic reference will be created in the repository and written to * the disk. The generated reference object must be freed by the user. * * Valid reference names must follow one of two patterns: * * 1. Top-level names must contain only capital letters and underscores, * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD"). * 2. Names prefixed with "refs/" can be almost anything. You must avoid * the characters '~', '^', ':', '\\', '?', '[', and '*', and the * sequences ".." and "@{" which have special meaning to revparse. * * This function will return an error if a reference already exists with the * given name unless `force` is true, in which case it will be overwritten. * * The message for the reflog will be ignored if the reference does * not belong in the standard set (HEAD, branches and remote-tracking * branches) and it does not have a reflog. * * It will return GIT_EMODIFIED if the reference's value at the time * of updating does not match the one passed through `current_value` * (i.e. if the ref has changed since the user read it). * * @param out Pointer to the newly created reference * @param repo Repository where that reference will live * @param name The name of the reference * @param target The target of the reference * @param force Overwrite existing references * @param current_value The expected value of the reference when updating * @param log_message The one line long message to be appended to the reflog * @return 0 on success, GIT_EEXISTS, GIT_EINVALIDSPEC, GIT_EMODIFIED or an error code */ GIT_EXTERN(int) git_reference_symbolic_create_matching(git_reference **out, git_repository *repo, const char *name, const char *target, int force, const char *current_value, const char *log_message); /** * Create a new symbolic reference. * * A symbolic reference is a reference name that refers to another * reference name. If the other name moves, the symbolic name will move, * too. As a simple example, the "HEAD" reference might refer to * "refs/heads/master" while on the "master" branch of a repository. * * The symbolic reference will be created in the repository and written to * the disk. The generated reference object must be freed by the user. * * Valid reference names must follow one of two patterns: * * 1. Top-level names must contain only capital letters and underscores, * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD"). * 2. Names prefixed with "refs/" can be almost anything. You must avoid * the characters '~', '^', ':', '\\', '?', '[', and '*', and the * sequences ".." and "@{" which have special meaning to revparse. * * This function will return an error if a reference already exists with the * given name unless `force` is true, in which case it will be overwritten. * * The message for the reflog will be ignored if the reference does * not belong in the standard set (HEAD, branches and remote-tracking * branches) and it does not have a reflog. * * @param out Pointer to the newly created reference * @param repo Repository where that reference will live * @param name The name of the reference * @param target The target of the reference * @param force Overwrite existing references * @param log_message The one line long message to be appended to the reflog * @return 0 on success, GIT_EEXISTS, GIT_EINVALIDSPEC or an error code */ GIT_EXTERN(int) git_reference_symbolic_create(git_reference **out, git_repository *repo, const char *name, const char *target, int force, const char *log_message); /** * Create a new direct reference. * * A direct reference (also called an object id reference) refers directly * to a specific object id (a.k.a. OID or SHA) in the repository. The id * permanently refers to the object (although the reference itself can be * moved). For example, in libgit2 the direct ref "refs/tags/v0.17.0" * refers to OID 5b9fac39d8a76b9139667c26a63e6b3f204b3977. * * The direct reference will be created in the repository and written to * the disk. The generated reference object must be freed by the user. * * Valid reference names must follow one of two patterns: * * 1. Top-level names must contain only capital letters and underscores, * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD"). * 2. Names prefixed with "refs/" can be almost anything. You must avoid * the characters '~', '^', ':', '\\', '?', '[', and '*', and the * sequences ".." and "@{" which have special meaning to revparse. * * This function will return an error if a reference already exists with the * given name unless `force` is true, in which case it will be overwritten. * * The message for the reflog will be ignored if the reference does * not belong in the standard set (HEAD, branches and remote-tracking * branches) and and it does not have a reflog. * * @param out Pointer to the newly created reference * @param repo Repository where that reference will live * @param name The name of the reference * @param id The object id pointed to by the reference. * @param force Overwrite existing references * @param log_message The one line long message to be appended to the reflog * @return 0 on success, GIT_EEXISTS, GIT_EINVALIDSPEC or an error code */ GIT_EXTERN(int) git_reference_create(git_reference **out, git_repository *repo, const char *name, const git_oid *id, int force, const char *log_message); /** * Conditionally create new direct reference * * A direct reference (also called an object id reference) refers directly * to a specific object id (a.k.a. OID or SHA) in the repository. The id * permanently refers to the object (although the reference itself can be * moved). For example, in libgit2 the direct ref "refs/tags/v0.17.0" * refers to OID 5b9fac39d8a76b9139667c26a63e6b3f204b3977. * * The direct reference will be created in the repository and written to * the disk. The generated reference object must be freed by the user. * * Valid reference names must follow one of two patterns: * * 1. Top-level names must contain only capital letters and underscores, * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD"). * 2. Names prefixed with "refs/" can be almost anything. You must avoid * the characters '~', '^', ':', '\\', '?', '[', and '*', and the * sequences ".." and "@{" which have special meaning to revparse. * * This function will return an error if a reference already exists with the * given name unless `force` is true, in which case it will be overwritten. * * The message for the reflog will be ignored if the reference does * not belong in the standard set (HEAD, branches and remote-tracking * branches) and and it does not have a reflog. * * It will return GIT_EMODIFIED if the reference's value at the time * of updating does not match the one passed through `current_id` * (i.e. if the ref has changed since the user read it). * * @param out Pointer to the newly created reference * @param repo Repository where that reference will live * @param name The name of the reference * @param id The object id pointed to by the reference. * @param force Overwrite existing references * @param current_id The expected value of the reference at the time of update * @param log_message The one line long message to be appended to the reflog * @return 0 on success, GIT_EMODIFIED if the value of the reference * has changed, GIT_EEXISTS, GIT_EINVALIDSPEC or an error code */ GIT_EXTERN(int) git_reference_create_matching(git_reference **out, git_repository *repo, const char *name, const git_oid *id, int force, const git_oid *current_id, const char *log_message); /** * Get the OID pointed to by a direct reference. * * Only available if the reference is direct (i.e. an object id reference, * not a symbolic one). * * To find the OID of a symbolic ref, call `git_reference_resolve()` and * then this function (or maybe use `git_reference_name_to_id()` to * directly resolve a reference name all the way through to an OID). * * @param ref The reference * @return a pointer to the oid if available, NULL otherwise */ GIT_EXTERN(const git_oid *) git_reference_target(const git_reference *ref); /** * Return the peeled OID target of this reference. * * This peeled OID only applies to direct references that point to * a hard Tag object: it is the result of peeling such Tag. * * @param ref The reference * @return a pointer to the oid if available, NULL otherwise */ GIT_EXTERN(const git_oid *) git_reference_target_peel(const git_reference *ref); /** * Get full name to the reference pointed to by a symbolic reference. * * Only available if the reference is symbolic. * * @param ref The reference * @return a pointer to the name if available, NULL otherwise */ GIT_EXTERN(const char *) git_reference_symbolic_target(const git_reference *ref); /** * Get the type of a reference. * * Either direct (GIT_REF_OID) or symbolic (GIT_REF_SYMBOLIC) * * @param ref The reference * @return the type */ GIT_EXTERN(git_ref_t) git_reference_type(const git_reference *ref); /** * Get the full name of a reference. * * See `git_reference_symbolic_create()` for rules about valid names. * * @param ref The reference * @return the full name for the ref */ GIT_EXTERN(const char *) git_reference_name(const git_reference *ref); /** * Resolve a symbolic reference to a direct reference. * * This method iteratively peels a symbolic reference until it resolves to * a direct reference to an OID. * * The peeled reference is returned in the `resolved_ref` argument, and * must be freed manually once it's no longer needed. * * If a direct reference is passed as an argument, a copy of that * reference is returned. This copy must be manually freed too. * * @param out Pointer to the peeled reference * @param ref The reference * @return 0 or an error code */ GIT_EXTERN(int) git_reference_resolve(git_reference **out, const git_reference *ref); /** * Get the repository where a reference resides. * * @param ref The reference * @return a pointer to the repo */ GIT_EXTERN(git_repository *) git_reference_owner(const git_reference *ref); /** * Create a new reference with the same name as the given reference but a * different symbolic target. The reference must be a symbolic reference, * otherwise this will fail. * * The new reference will be written to disk, overwriting the given reference. * * The target name will be checked for validity. * See `git_reference_symbolic_create()` for rules about valid names. * * The message for the reflog will be ignored if the reference does * not belong in the standard set (HEAD, branches and remote-tracking * branches) and and it does not have a reflog. * * @param out Pointer to the newly created reference * @param ref The reference * @param target The new target for the reference * @param log_message The one line long message to be appended to the reflog * @return 0 on success, GIT_EINVALIDSPEC or an error code */ GIT_EXTERN(int) git_reference_symbolic_set_target( git_reference **out, git_reference *ref, const char *target, const char *log_message); /** * Conditionally create a new reference with the same name as the given reference but a * different OID target. The reference must be a direct reference, otherwise * this will fail. * * The new reference will be written to disk, overwriting the given reference. * * @param out Pointer to the newly created reference * @param ref The reference * @param id The new target OID for the reference * @param log_message The one line long message to be appended to the reflog * @return 0 on success, GIT_EMODIFIED if the value of the reference * has changed since it was read, or an error code */ GIT_EXTERN(int) git_reference_set_target( git_reference **out, git_reference *ref, const git_oid *id, const char *log_message); /** * Rename an existing reference. * * This method works for both direct and symbolic references. * * The new name will be checked for validity. * See `git_reference_symbolic_create()` for rules about valid names. * * If the `force` flag is not enabled, and there's already * a reference with the given name, the renaming will fail. * * IMPORTANT: * The user needs to write a proper reflog entry if the * reflog is enabled for the repository. We only rename * the reflog if it exists. * * @param ref The reference to rename * @param new_name The new name for the reference * @param force Overwrite an existing reference * @param log_message The one line long message to be appended to the reflog * @return 0 on success, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code * */ GIT_EXTERN(int) git_reference_rename( git_reference **new_ref, git_reference *ref, const char *new_name, int force, const char *log_message); /** * Delete an existing reference. * * This method works for both direct and symbolic references. The reference * will be immediately removed on disk but the memory will not be freed. * Callers must call `git_reference_free`. * * This function will return an error if the reference has changed * from the time it was looked up. * * @param ref The reference to remove * @return 0, GIT_EMODIFIED or an error code */ GIT_EXTERN(int) git_reference_delete(git_reference *ref); /** * Delete an existing reference by name * * This method removes the named reference from the repository without * looking at its old value. * * @param name The reference to remove * @return 0 or an error code */ GIT_EXTERN(int) git_reference_remove(git_repository *repo, const char *name); /** * Fill a list with all the references that can be found in a repository. * * The string array will be filled with the names of all references; these * values are owned by the user and should be free'd manually when no * longer needed, using `git_strarray_free()`. * * @param array Pointer to a git_strarray structure where * the reference names will be stored * @param repo Repository where to find the refs * @return 0 or an error code */ GIT_EXTERN(int) git_reference_list(git_strarray *array, git_repository *repo); typedef int (*git_reference_foreach_cb)(git_reference *reference, void *payload); typedef int (*git_reference_foreach_name_cb)(const char *name, void *payload); /** * Perform a callback on each reference in the repository. * * The `callback` function will be called for each reference in the * repository, receiving the reference object and the `payload` value * passed to this method. Returning a non-zero value from the callback * will terminate the iteration. * * @param repo Repository where to find the refs * @param callback Function which will be called for every listed ref * @param payload Additional data to pass to the callback * @return 0 on success, non-zero callback return value, or error code */ GIT_EXTERN(int) git_reference_foreach( git_repository *repo, git_reference_foreach_cb callback, void *payload); /** * Perform a callback on the fully-qualified name of each reference. * * The `callback` function will be called for each reference in the * repository, receiving the name of the reference and the `payload` value * passed to this method. Returning a non-zero value from the callback * will terminate the iteration. * * @param repo Repository where to find the refs * @param callback Function which will be called for every listed ref name * @param payload Additional data to pass to the callback * @return 0 on success, non-zero callback return value, or error code */ GIT_EXTERN(int) git_reference_foreach_name( git_repository *repo, git_reference_foreach_name_cb callback, void *payload); /** * Free the given reference. * * @param ref git_reference */ GIT_EXTERN(void) git_reference_free(git_reference *ref); /** * Compare two references. * * @param ref1 The first git_reference * @param ref2 The second git_reference * @return 0 if the same, else a stable but meaningless ordering. */ GIT_EXTERN(int) git_reference_cmp( const git_reference *ref1, const git_reference *ref2); /** * Create an iterator for the repo's references * * @param out pointer in which to store the iterator * @param repo the repository * @return 0 or an error code */ GIT_EXTERN(int) git_reference_iterator_new( git_reference_iterator **out, git_repository *repo); /** * Create an iterator for the repo's references that match the * specified glob * * @param out pointer in which to store the iterator * @param repo the repository * @param glob the glob to match against the reference names * @return 0 or an error code */ GIT_EXTERN(int) git_reference_iterator_glob_new( git_reference_iterator **out, git_repository *repo, const char *glob); /** * Get the next reference * * @param out pointer in which to store the reference * @param iter the iterator * @return 0, GIT_ITEROVER if there are no more; or an error code */ GIT_EXTERN(int) git_reference_next(git_reference **out, git_reference_iterator *iter); /** * Get the next reference's name * * This function is provided for convenience in case only the names * are interesting as it avoids the allocation of the `git_reference` * object which `git_reference_next()` needs. * * @param out pointer in which to store the string * @param iter the iterator * @return 0, GIT_ITEROVER if there are no more; or an error code */ GIT_EXTERN(int) git_reference_next_name(const char **out, git_reference_iterator *iter); /** * Free the iterator and its associated resources * * @param iter the iterator to free */ GIT_EXTERN(void) git_reference_iterator_free(git_reference_iterator *iter); /** * Perform a callback on each reference in the repository whose name * matches the given pattern. * * This function acts like `git_reference_foreach()` with an additional * pattern match being applied to the reference name before issuing the * callback function. See that function for more information. * * The pattern is matched using fnmatch or "glob" style where a '*' matches * any sequence of letters, a '?' matches any letter, and square brackets * can be used to define character ranges (such as "[0-9]" for digits). * * @param repo Repository where to find the refs * @param glob Pattern to match (fnmatch-style) against reference name. * @param callback Function which will be called for every listed ref * @param payload Additional data to pass to the callback * @return 0 on success, GIT_EUSER on non-zero callback, or error code */ GIT_EXTERN(int) git_reference_foreach_glob( git_repository *repo, const char *glob, git_reference_foreach_name_cb callback, void *payload); /** * Check if a reflog exists for the specified reference. * * @param repo the repository * @param refname the reference's name * @return 0 when no reflog can be found, 1 when it exists; * otherwise an error code. */ GIT_EXTERN(int) git_reference_has_log(git_repository *repo, const char *refname); /** * Ensure there is a reflog for a particular reference. * * Make sure that successive updates to the reference will append to * its log. * * @param repo the repository * @param refname the reference's name * @return 0 or an error code. */ GIT_EXTERN(int) git_reference_ensure_log(git_repository *repo, const char *refname); /** * Check if a reference is a local branch. * * @param ref A git reference * * @return 1 when the reference lives in the refs/heads * namespace; 0 otherwise. */ GIT_EXTERN(int) git_reference_is_branch(const git_reference *ref); /** * Check if a reference is a remote tracking branch * * @param ref A git reference * * @return 1 when the reference lives in the refs/remotes * namespace; 0 otherwise. */ GIT_EXTERN(int) git_reference_is_remote(const git_reference *ref); /** * Check if a reference is a tag * * @param ref A git reference * * @return 1 when the reference lives in the refs/tags * namespace; 0 otherwise. */ GIT_EXTERN(int) git_reference_is_tag(const git_reference *ref); /** * Check if a reference is a note * * @param ref A git reference * * @return 1 when the reference lives in the refs/notes * namespace; 0 otherwise. */ GIT_EXTERN(int) git_reference_is_note(const git_reference *ref); /** * Normalization options for reference lookup */ typedef enum { /** * No particular normalization. */ GIT_REF_FORMAT_NORMAL = 0u, /** * Control whether one-level refnames are accepted * (i.e., refnames that do not contain multiple /-separated * components). Those are expected to be written only using * uppercase letters and underscore (FETCH_HEAD, ...) */ GIT_REF_FORMAT_ALLOW_ONELEVEL = (1u << 0), /** * Interpret the provided name as a reference pattern for a * refspec (as used with remote repositories). If this option * is enabled, the name is allowed to contain a single * () * in place of a one full pathname component * (e.g., foo//bar but not foo/bar). */ GIT_REF_FORMAT_REFSPEC_PATTERN = (1u << 1), /** * Interpret the name as part of a refspec in shorthand form * so the `ONELEVEL` naming rules aren't enforced and 'master' * becomes a valid name. */ GIT_REF_FORMAT_REFSPEC_SHORTHAND = (1u << 2), } git_reference_normalize_t; /** * Normalize reference name and check validity. * * This will normalize the reference name by removing any leading slash * '/' characters and collapsing runs of adjacent slashes between name * components into a single slash. * * Once normalized, if the reference name is valid, it will be returned in * the user allocated buffer. * * See `git_reference_symbolic_create()` for rules about valid names. * * @param buffer_out User allocated buffer to store normalized name * @param buffer_size Size of buffer_out * @param name Reference name to be checked. * @param flags Flags to constrain name validation rules - see the * GIT_REF_FORMAT constants above. * @return 0 on success, GIT_EBUFS if buffer is too small, GIT_EINVALIDSPEC * or an error code. */ GIT_EXTERN(int) git_reference_normalize_name( char *buffer_out, size_t buffer_size, const char *name, unsigned int flags); /** * Recursively peel reference until object of the specified type is found. * * The retrieved `peeled` object is owned by the repository * and should be closed with the `git_object_free` method. * * If you pass `GIT_OBJ_ANY` as the target type, then the object * will be peeled until a non-tag object is met. * * @param out Pointer to the peeled git_object * @param ref The reference to be processed * @param type The type of the requested object (GIT_OBJ_COMMIT, * GIT_OBJ_TAG, GIT_OBJ_TREE, GIT_OBJ_BLOB or GIT_OBJ_ANY). * @return 0 on success, GIT_EAMBIGUOUS, GIT_ENOTFOUND or an error code */ GIT_EXTERN(int) git_reference_peel( git_object **out, git_reference *ref, git_otype type); /** * Ensure the reference name is well-formed. * * Valid reference names must follow one of two patterns: * * 1. Top-level names must contain only capital letters and underscores, * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD"). * 2. Names prefixed with "refs/" can be almost anything. You must avoid * the characters '~', '^', ':', '\\', '?', '[', and '*', and the * sequences ".." and "@{" which have special meaning to revparse. * * @param refname name to be checked. * @return 1 if the reference name is acceptable; 0 if it isn't */ GIT_EXTERN(int) git_reference_is_valid_name(const char *refname); /** * Get the reference's short name * * This will transform the reference name into a name "human-readable" * version. If no shortname is appropriate, it will return the full * name. * * The memory is owned by the reference and must not be freed. * * @param ref a reference * @return the human-readable version of the name */ GIT_EXTERN(const char *) git_reference_shorthand(const git_reference *ref); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/pack.h0000664000175000017500000001552712555730137016504 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_pack_h__ #define INCLUDE_git_pack_h__ #include "common.h" #include "oid.h" /** * @file git2/pack.h * @brief Git pack management routines * * Packing objects * --------------- * * Creation of packfiles requires two steps: * * - First, insert all the objects you want to put into the packfile * using `git_packbuilder_insert` and `git_packbuilder_insert_tree`. * It's important to add the objects in recency order ("in the order * that they are 'reachable' from head"). * * "ANY order will give you a working pack, ... [but it is] the thing * that gives packs good locality. It keeps the objects close to the * head (whether they are old or new, but they are _reachable_ from the * head) at the head of the pack. So packs actually have absolutely * _wonderful_ IO patterns." - Linus Torvalds * git.git/Documentation/technical/pack-heuristics.txt * * - Second, use `git_packbuilder_write` or `git_packbuilder_foreach` to * write the resulting packfile. * * libgit2 will take care of the delta ordering and generation. * `git_packbuilder_set_threads` can be used to adjust the number of * threads used for the process. * * See tests/pack/packbuilder.c for an example. * * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Stages that are reported by the packbuilder progress callback. */ typedef enum { GIT_PACKBUILDER_ADDING_OBJECTS = 0, GIT_PACKBUILDER_DELTAFICATION = 1, } git_packbuilder_stage_t; /** * Initialize a new packbuilder * * @param out The new packbuilder object * @param repo The repository * * @return 0 or an error code */ GIT_EXTERN(int) git_packbuilder_new(git_packbuilder **out, git_repository *repo); /** * Set number of threads to spawn * * By default, libgit2 won't spawn any threads at all; * when set to 0, libgit2 will autodetect the number of * CPUs. * * @param pb The packbuilder * @param n Number of threads to spawn * @return number of actual threads to be used */ GIT_EXTERN(unsigned int) git_packbuilder_set_threads(git_packbuilder *pb, unsigned int n); /** * Insert a single object * * For an optimal pack it's mandatory to insert objects in recency order, * commits followed by trees and blobs. * * @param pb The packbuilder * @param id The oid of the commit * @param name The name; might be NULL * * @return 0 or an error code */ GIT_EXTERN(int) git_packbuilder_insert(git_packbuilder *pb, const git_oid *id, const char *name); /** * Insert a root tree object * * This will add the tree as well as all referenced trees and blobs. * * @param pb The packbuilder * @param id The oid of the root tree * * @return 0 or an error code */ GIT_EXTERN(int) git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *id); /** * Insert a commit object * * This will add a commit as well as the completed referenced tree. * * @param pb The packbuilder * @param id The oid of the commit * * @return 0 or an error code */ GIT_EXTERN(int) git_packbuilder_insert_commit(git_packbuilder *pb, const git_oid *id); /** * Insert objects as given by the walk * * Those commits and all objects they reference will be inserted into * the packbuilder. * * @param pb the packbuilder * @param walk the revwalk to use to fill the packbuilder * * @return 0 or an error code */ GIT_EXTERN(int) git_packbuilder_insert_walk(git_packbuilder *pb, git_revwalk *walk); /** * Recursively insert an object and its referenced objects * * Insert the object as well as any object it references. * * @param pb the packbuilder * @param id the id of the root object to insert * @param name optional name for the object * @return 0 or an error code */ GIT_EXTERN(int) git_packbuilder_insert_recur(git_packbuilder *pb, const git_oid *id, const char *name); /** * Write the contents of the packfile to an in-memory buffer * * The contents of the buffer will become a valid packfile, even though there * will be no attached index * * @param buf Buffer where to write the packfile * @param pb The packbuilder */ GIT_EXTERN(int) git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb); /** * Write the new pack and corresponding index file to path. * * @param pb The packbuilder * @param path to the directory where the packfile and index should be stored * @param mode permissions to use creating a packfile or 0 for defaults * @param progress_cb function to call with progress information from the indexer (optional) * @param progress_cb_payload payload for the progress callback (optional) * * @return 0 or an error code */ GIT_EXTERN(int) git_packbuilder_write( git_packbuilder *pb, const char *path, unsigned int mode, git_transfer_progress_cb progress_cb, void *progress_cb_payload); /** * Get the packfile's hash * * A packfile's name is derived from the sorted hashing of all object * names. This is only correct after the packfile has been written. * * @param pb The packbuilder object */ GIT_EXTERN(const git_oid *) git_packbuilder_hash(git_packbuilder *pb); typedef int (*git_packbuilder_foreach_cb)(void *buf, size_t size, void *payload); /** * Create the new pack and pass each object to the callback * * @param pb the packbuilder * @param cb the callback to call with each packed object's buffer * @param payload the callback's data * @return 0 or an error code */ GIT_EXTERN(int) git_packbuilder_foreach(git_packbuilder *pb, git_packbuilder_foreach_cb cb, void *payload); /** * Get the total number of objects the packbuilder will write out * * @param pb the packbuilder * @return the number of objects in the packfile */ GIT_EXTERN(uint32_t) git_packbuilder_object_count(git_packbuilder *pb); /** * Get the number of objects the packbuilder has already written out * * @param pb the packbuilder * @return the number of objects which have already been written */ GIT_EXTERN(uint32_t) git_packbuilder_written(git_packbuilder *pb); /** Packbuilder progress notification function */ typedef int (*git_packbuilder_progress)( int stage, unsigned int current, unsigned int total, void *payload); /** * Set the callbacks for a packbuilder * * @param pb The packbuilder object * @param progress_cb Function to call with progress information during * pack building. Be aware that this is called inline with pack building * operations, so performance may be affected. * @param progress_cb_payload Payload for progress callback. * @return 0 or an error code */ GIT_EXTERN(int) git_packbuilder_set_callbacks( git_packbuilder *pb, git_packbuilder_progress progress_cb, void *progress_cb_payload); /** * Free the packbuilder and all associated data * * @param pb The packbuilder */ GIT_EXTERN(void) git_packbuilder_free(git_packbuilder *pb); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/revparse.h0000664000175000017500000000676012426525445017415 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_revparse_h__ #define INCLUDE_git_revparse_h__ #include "common.h" #include "types.h" /** * @file git2/revparse.h * @brief Git revision parsing routines * @defgroup git_revparse Git revision parsing routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Find a single object, as specified by a revision string. * * See `man gitrevisions`, or * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for * information on the syntax accepted. * * The returned object should be released with `git_object_free` when no * longer needed. * * @param out pointer to output object * @param repo the repository to search in * @param spec the textual specification for an object * @return 0 on success, GIT_ENOTFOUND, GIT_EAMBIGUOUS, GIT_EINVALIDSPEC or an error code */ GIT_EXTERN(int) git_revparse_single( git_object **out, git_repository *repo, const char *spec); /** * Find a single object and intermediate reference by a revision string. * * See `man gitrevisions`, or * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for * information on the syntax accepted. * * In some cases (`@{<-n>}` or `@{upstream}`), the expression may * point to an intermediate reference. When such expressions are being passed * in, `reference_out` will be valued as well. * * The returned object should be released with `git_object_free` and the * returned reference with `git_reference_free` when no longer needed. * * @param object_out pointer to output object * @param reference_out pointer to output reference or NULL * @param repo the repository to search in * @param spec the textual specification for an object * @return 0 on success, GIT_ENOTFOUND, GIT_EAMBIGUOUS, GIT_EINVALIDSPEC * or an error code */ GIT_EXTERN(int) git_revparse_ext( git_object **object_out, git_reference **reference_out, git_repository *repo, const char *spec); /** * Revparse flags. These indicate the intended behavior of the spec passed to * git_revparse. */ typedef enum { /** The spec targeted a single object. */ GIT_REVPARSE_SINGLE = 1 << 0, /** The spec targeted a range of commits. */ GIT_REVPARSE_RANGE = 1 << 1, /** The spec used the '...' operator, which invokes special semantics. */ GIT_REVPARSE_MERGE_BASE = 1 << 2, } git_revparse_mode_t; /** * Git Revision Spec: output of a `git_revparse` operation */ typedef struct { /** The left element of the revspec; must be freed by the user */ git_object *from; /** The right element of the revspec; must be freed by the user */ git_object *to; /** The intent of the revspec (i.e. `git_revparse_mode_t` flags) */ unsigned int flags; } git_revspec; /** * Parse a revision string for `from`, `to`, and intent. * * See `man gitrevisions` or * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for * information on the syntax accepted. * * @param revspec Pointer to an user-allocated git_revspec struct where * the result of the rev-parse will be stored * @param repo the repository to search in * @param spec the rev-parse spec to parse * @return 0 on success, GIT_INVALIDSPEC, GIT_ENOTFOUND, GIT_EAMBIGUOUS or an error code */ GIT_EXTERN(int) git_revparse( git_revspec *revspec, git_repository *repo, const char *spec); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/transport.h0000664000175000017500000002255012572105236017607 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_transport_h__ #define INCLUDE_git_transport_h__ #include "indexer.h" #include "net.h" #include "types.h" /** * @file git2/transport.h * @brief Git transport interfaces and functions * @defgroup git_transport interfaces and functions * @ingroup Git * @{ */ GIT_BEGIN_DECL /** Signature of a function which creates a transport */ typedef int (*git_transport_cb)(git_transport **out, git_remote *owner, void *param); /** * Type of SSH host fingerprint */ typedef enum { /** MD5 is available */ GIT_CERT_SSH_MD5 = (1 << 0), /** SHA-1 is available */ GIT_CERT_SSH_SHA1 = (1 << 1), } git_cert_ssh_t; /** * Hostkey information taken from libssh2 */ typedef struct { git_cert parent; /** * A hostkey type from libssh2, either * `GIT_CERT_SSH_MD5` or `GIT_CERT_SSH_SHA1` */ git_cert_ssh_t type; /** * Hostkey hash. If type has `GIT_CERT_SSH_MD5` set, this will * have the MD5 hash of the hostkey. */ unsigned char hash_md5[16]; /** * Hostkey hash. If type has `GIT_CERT_SSH_SHA1` set, this will * have the SHA-1 hash of the hostkey. */ unsigned char hash_sha1[20]; } git_cert_hostkey; /** * X.509 certificate information */ typedef struct { git_cert parent; /** * Pointer to the X.509 certificate data */ void *data; /** * Length of the memory block pointed to by `data`. */ size_t len; } git_cert_x509; /* *** Begin interface for credentials acquisition *** */ /** Authentication type requested */ typedef enum { /* git_cred_userpass_plaintext */ GIT_CREDTYPE_USERPASS_PLAINTEXT = (1u << 0), /* git_cred_ssh_key */ GIT_CREDTYPE_SSH_KEY = (1u << 1), /* git_cred_ssh_custom */ GIT_CREDTYPE_SSH_CUSTOM = (1u << 2), /* git_cred_default */ GIT_CREDTYPE_DEFAULT = (1u << 3), /* git_cred_ssh_interactive */ GIT_CREDTYPE_SSH_INTERACTIVE = (1u << 4), /** * Username-only information * * If the SSH transport does not know which username to use, * it will ask via this credential type. */ GIT_CREDTYPE_USERNAME = (1u << 5), /** * Credentials read from memory. * * Only available for libssh2+OpenSSL for now. */ GIT_CREDTYPE_SSH_MEMORY = (1u << 6), } git_credtype_t; /* The base structure for all credential types */ typedef struct git_cred git_cred; struct git_cred { git_credtype_t credtype; void (*free)(git_cred *cred); }; /** A plaintext username and password */ typedef struct { git_cred parent; char *username; char *password; } git_cred_userpass_plaintext; /* * If the user hasn't included libssh2.h before git2.h, we need to * define a few types for the callback signatures. */ #ifndef LIBSSH2_VERSION typedef struct _LIBSSH2_SESSION LIBSSH2_SESSION; typedef struct _LIBSSH2_USERAUTH_KBDINT_PROMPT LIBSSH2_USERAUTH_KBDINT_PROMPT; typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE LIBSSH2_USERAUTH_KBDINT_RESPONSE; #endif typedef int (*git_cred_sign_callback)(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len, const unsigned char *data, size_t data_len, void **abstract); typedef void (*git_cred_ssh_interactive_callback)(const char* name, int name_len, const char* instruction, int instruction_len, int num_prompts, const LIBSSH2_USERAUTH_KBDINT_PROMPT* prompts, LIBSSH2_USERAUTH_KBDINT_RESPONSE* responses, void **abstract); /** * A ssh key from disk */ typedef struct git_cred_ssh_key { git_cred parent; char *username; char *publickey; char *privatekey; char *passphrase; } git_cred_ssh_key; /** * Keyboard-interactive based ssh authentication */ typedef struct git_cred_ssh_interactive { git_cred parent; char *username; git_cred_ssh_interactive_callback prompt_callback; void *payload; } git_cred_ssh_interactive; /** * A key with a custom signature function */ typedef struct git_cred_ssh_custom { git_cred parent; char *username; char *publickey; size_t publickey_len; git_cred_sign_callback sign_callback; void *payload; } git_cred_ssh_custom; /** A key for NTLM/Kerberos "default" credentials */ typedef struct git_cred git_cred_default; /** Username-only credential information */ typedef struct git_cred_username { git_cred parent; char username[1]; } git_cred_username; /** * Check whether a credential object contains username information. * * @param cred object to check * @return 1 if the credential object has non-NULL username, 0 otherwise */ GIT_EXTERN(int) git_cred_has_username(git_cred *cred); /** * Create a new plain-text username and password credential object. * The supplied credential parameter will be internally duplicated. * * @param out The newly created credential object. * @param username The username of the credential. * @param password The password of the credential. * @return 0 for success or an error code for failure */ GIT_EXTERN(int) git_cred_userpass_plaintext_new( git_cred **out, const char *username, const char *password); /** * Create a new passphrase-protected ssh key credential object. * The supplied credential parameter will be internally duplicated. * * @param out The newly created credential object. * @param username username to use to authenticate * @param publickey The path to the public key of the credential. * @param privatekey The path to the private key of the credential. * @param passphrase The passphrase of the credential. * @return 0 for success or an error code for failure */ GIT_EXTERN(int) git_cred_ssh_key_new( git_cred **out, const char *username, const char *publickey, const char *privatekey, const char *passphrase); /** * Create a new ssh keyboard-interactive based credential object. * The supplied credential parameter will be internally duplicated. * * @param username Username to use to authenticate. * @param prompt_callback The callback method used for prompts. * @param payload Additional data to pass to the callback. * @return 0 for success or an error code for failure. */ GIT_EXTERN(int) git_cred_ssh_interactive_new( git_cred **out, const char *username, git_cred_ssh_interactive_callback prompt_callback, void *payload); /** * Create a new ssh key credential object used for querying an ssh-agent. * The supplied credential parameter will be internally duplicated. * * @param out The newly created credential object. * @param username username to use to authenticate * @return 0 for success or an error code for failure */ GIT_EXTERN(int) git_cred_ssh_key_from_agent( git_cred **out, const char *username); /** * Create an ssh key credential with a custom signing function. * * This lets you use your own function to sign the challenge. * * This function and its credential type is provided for completeness * and wraps `libssh2_userauth_publickey()`, which is undocumented. * * The supplied credential parameter will be internally duplicated. * * @param out The newly created credential object. * @param username username to use to authenticate * @param publickey The bytes of the public key. * @param publickey_len The length of the public key in bytes. * @param sign_callback The callback method to sign the data during the challenge. * @param payload Additional data to pass to the callback. * @return 0 for success or an error code for failure */ GIT_EXTERN(int) git_cred_ssh_custom_new( git_cred **out, const char *username, const char *publickey, size_t publickey_len, git_cred_sign_callback sign_callback, void *payload); /** * Create a "default" credential usable for Negotiate mechanisms like NTLM * or Kerberos authentication. * * @return 0 for success or an error code for failure */ GIT_EXTERN(int) git_cred_default_new(git_cred **out); /** * Create a credential to specify a username. * * This is used with ssh authentication to query for the username if * none is specified in the url. */ GIT_EXTERN(int) git_cred_username_new(git_cred **cred, const char *username); /** * Create a new ssh key credential object reading the keys from memory. * * @param out The newly created credential object. * @param username username to use to authenticate. * @param publickey The public key of the credential. * @param privatekey The private key of the credential. * @param passphrase The passphrase of the credential. * @return 0 for success or an error code for failure */ GIT_EXTERN(int) git_cred_ssh_key_memory_new( git_cred **out, const char *username, const char *publickey, const char *privatekey, const char *passphrase); /** * Free a credential. * * This is only necessary if you own the object; that is, if you are a * transport. * * @param cred the object to free */ GIT_EXTERN(void) git_cred_free(git_cred *cred); /** * Signature of a function which acquires a credential object. * * - cred: The newly created credential object. * - url: The resource for which we are demanding a credential. * - username_from_url: The username that was embedded in a "user\@host" * remote url, or NULL if not included. * - allowed_types: A bitmask stating which cred types are OK to return. * - payload: The payload provided when specifying this callback. * - returns 0 for success, < 0 to indicate an error, > 0 to indicate * no credential was acquired */ typedef int (*git_cred_acquire_cb)( git_cred **cred, const char *url, const char *username_from_url, unsigned int allowed_types, void *payload); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/strarray.h0000664000175000017500000000304712426525445017430 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_strarray_h__ #define INCLUDE_git_strarray_h__ #include "common.h" /** * @file git2/strarray.h * @brief Git string array routines * @defgroup git_strarray Git string array routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** Array of strings */ typedef struct git_strarray { char **strings; size_t count; } git_strarray; /** * Close a string array object * * This method should be called on `git_strarray` objects where the strings * array is allocated and contains allocated strings, such as what you * would get from `git_strarray_copy()`. Not doing so, will result in a * memory leak. * * This does not free the `git_strarray` itself, since the library will * never allocate that object directly itself (it is more commonly embedded * inside another struct or created on the stack). * * @param array git_strarray from which to free string data */ GIT_EXTERN(void) git_strarray_free(git_strarray *array); /** * Copy a string array object from source to target. * * Note: target is overwritten and hence should be empty, otherwise its * contents are leaked. Call git_strarray_free() if necessary. * * @param tgt target * @param src source * @return 0 on success, < 0 on allocation failure */ GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/blame.h0000664000175000017500000001600312510265101016615 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_blame_h__ #define INCLUDE_git_blame_h__ #include "common.h" #include "oid.h" /** * @file git2/blame.h * @brief Git blame routines * @defgroup git_blame Git blame routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Flags for indicating option behavior for git_blame APIs. */ typedef enum { /** Normal blame, the default */ GIT_BLAME_NORMAL = 0, /** Track lines that have moved within a file (like `git blame -M`). * NOT IMPLEMENTED. */ GIT_BLAME_TRACK_COPIES_SAME_FILE = (1<<0), /** Track lines that have moved across files in the same commit (like `git blame -C`). * NOT IMPLEMENTED. */ GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES = (1<<1), /** Track lines that have been copied from another file that exists in the * same commit (like `git blame -CC`). Implies SAME_FILE. * NOT IMPLEMENTED. */ GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES = (1<<2), /** Track lines that have been copied from another file that exists in *any* * commit (like `git blame -CCC`). Implies SAME_COMMIT_COPIES. * NOT IMPLEMENTED. */ GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES = (1<<3), /** Restrict the search of commits to those reachable following only the * first parents. */ GIT_BLAME_FIRST_PARENT = (1<<4), } git_blame_flag_t; /** * Blame options structure * * Use zeros to indicate default settings. It's easiest to use the * `GIT_BLAME_OPTIONS_INIT` macro: * git_blame_options opts = GIT_BLAME_OPTIONS_INIT; * * - `flags` is a combination of the `git_blame_flag_t` values above. * - `min_match_characters` is the lower bound on the number of alphanumeric * characters that must be detected as moving/copying within a file for it to * associate those lines with the parent commit. The default value is 20. * This value only takes effect if any of the `GIT_BLAME_TRACK_COPIES_*` * flags are specified. * - `newest_commit` is the id of the newest commit to consider. The default * is HEAD. * - `oldest_commit` is the id of the oldest commit to consider. The default * is the first commit encountered with a NULL parent. * - `min_line` is the first line in the file to blame. The default is 1 (line * numbers start with 1). * - `max_line` is the last line in the file to blame. The default is the last * line of the file. */ typedef struct git_blame_options { unsigned int version; uint32_t flags; uint16_t min_match_characters; git_oid newest_commit; git_oid oldest_commit; uint32_t min_line; uint32_t max_line; } git_blame_options; #define GIT_BLAME_OPTIONS_VERSION 1 #define GIT_BLAME_OPTIONS_INIT {GIT_BLAME_OPTIONS_VERSION} /** * Initializes a `git_blame_options` with default values. Equivalent to * creating an instance with GIT_BLAME_OPTIONS_INIT. * * @param opts The `git_blame_options` struct to initialize * @param version Version of struct; pass `GIT_BLAME_OPTIONS_VERSION` * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_blame_init_options( git_blame_options *opts, unsigned int version); /** * Structure that represents a blame hunk. * * - `lines_in_hunk` is the number of lines in this hunk * - `final_commit_id` is the OID of the commit where this line was last * changed. * - `final_start_line_number` is the 1-based line number where this hunk * begins, in the final version of the file * - `orig_commit_id` is the OID of the commit where this hunk was found. This * will usually be the same as `final_commit_id`, except when * `GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES` has been specified. * - `orig_path` is the path to the file where this hunk originated, as of the * commit specified by `orig_commit_id`. * - `orig_start_line_number` is the 1-based line number where this hunk begins * in the file named by `orig_path` in the commit specified by * `orig_commit_id`. * - `boundary` is 1 iff the hunk has been tracked to a boundary commit (the * root, or the commit specified in git_blame_options.oldest_commit) */ typedef struct git_blame_hunk { uint16_t lines_in_hunk; git_oid final_commit_id; uint16_t final_start_line_number; git_signature *final_signature; git_oid orig_commit_id; const char *orig_path; uint16_t orig_start_line_number; git_signature *orig_signature; char boundary; } git_blame_hunk; /* Opaque structure to hold blame results */ typedef struct git_blame git_blame; /** * Gets the number of hunks that exist in the blame structure. */ GIT_EXTERN(uint32_t) git_blame_get_hunk_count(git_blame *blame); /** * Gets the blame hunk at the given index. * * @param blame the blame structure to query * @param index index of the hunk to retrieve * @return the hunk at the given index, or NULL on error */ GIT_EXTERN(const git_blame_hunk*) git_blame_get_hunk_byindex( git_blame *blame, uint32_t index); /** * Gets the hunk that relates to the given line number in the newest commit. * * @param blame the blame structure to query * @param lineno the (1-based) line number to find a hunk for * @return the hunk that contains the given line, or NULL on error */ GIT_EXTERN(const git_blame_hunk*) git_blame_get_hunk_byline( git_blame *blame, uint32_t lineno); /** * Get the blame for a single file. * * @param out pointer that will receive the blame object * @param repo repository whose history is to be walked * @param path path to file to consider * @param options options for the blame operation. If NULL, this is treated as * though GIT_BLAME_OPTIONS_INIT were passed. * @return 0 on success, or an error code. (use giterr_last for information * about the error.) */ GIT_EXTERN(int) git_blame_file( git_blame **out, git_repository *repo, const char *path, git_blame_options *options); /** * Get blame data for a file that has been modified in memory. The `reference` * parameter is a pre-calculated blame for the in-odb history of the file. This * means that once a file blame is completed (which can be expensive), updating * the buffer blame is very fast. * * Lines that differ between the buffer and the committed version are marked as * having a zero OID for their final_commit_id. * * @param out pointer that will receive the resulting blame data * @param reference cached blame from the history of the file (usually the output * from git_blame_file) * @param buffer the (possibly) modified contents of the file * @param buffer_len number of valid bytes in the buffer * @return 0 on success, or an error code. (use giterr_last for information * about the error) */ GIT_EXTERN(int) git_blame_buffer( git_blame **out, git_blame *reference, const char *buffer, size_t buffer_len); /** * Free memory allocated by git_blame_file or git_blame_buffer. * * @param blame the blame structure to free */ GIT_EXTERN(void) git_blame_free(git_blame *blame); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/revwalk.h0000664000175000017500000002075112555730137017234 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_revwalk_h__ #define INCLUDE_git_revwalk_h__ #include "common.h" #include "types.h" #include "oid.h" /** * @file git2/revwalk.h * @brief Git revision traversal routines * @defgroup git_revwalk Git revision traversal routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Flags to specify the sorting which a revwalk should perform. */ typedef enum { /** * Sort the repository contents in no particular ordering; * this sorting is arbitrary, implementation-specific * and subject to change at any time. * This is the default sorting for new walkers. */ GIT_SORT_NONE = 0, /** * Sort the repository contents in topological order * (parents before children); this sorting mode * can be combined with time sorting. */ GIT_SORT_TOPOLOGICAL = 1 << 0, /** * Sort the repository contents by commit time; * this sorting mode can be combined with * topological sorting. */ GIT_SORT_TIME = 1 << 1, /** * Iterate through the repository contents in reverse * order; this sorting mode can be combined with * any of the above. */ GIT_SORT_REVERSE = 1 << 2, } git_sort_t; /** * Allocate a new revision walker to iterate through a repo. * * This revision walker uses a custom memory pool and an internal * commit cache, so it is relatively expensive to allocate. * * For maximum performance, this revision walker should be * reused for different walks. * * This revision walker is *not* thread safe: it may only be * used to walk a repository on a single thread; however, * it is possible to have several revision walkers in * several different threads walking the same repository. * * @param out pointer to the new revision walker * @param repo the repo to walk through * @return 0 or an error code */ GIT_EXTERN(int) git_revwalk_new(git_revwalk **out, git_repository *repo); /** * Reset the revision walker for reuse. * * This will clear all the pushed and hidden commits, and * leave the walker in a blank state (just like at * creation) ready to receive new commit pushes and * start a new walk. * * The revision walk is automatically reset when a walk * is over. * * @param walker handle to reset. */ GIT_EXTERN(void) git_revwalk_reset(git_revwalk *walker); /** * Add a new root for the traversal * * The pushed commit will be marked as one of the roots from which to * start the walk. This commit may not be walked if it or a child is * hidden. * * At least one commit must be pushed onto the walker before a walk * can be started. * * The given id must belong to a committish on the walked * repository. * * @param walk the walker being used for the traversal. * @param id the oid of the commit to start from. * @return 0 or an error code */ GIT_EXTERN(int) git_revwalk_push(git_revwalk *walk, const git_oid *id); /** * Push matching references * * The OIDs pointed to by the references that match the given glob * pattern will be pushed to the revision walker. * * A leading 'refs/' is implied if not present as well as a trailing * '/\*' if the glob lacks '?', '\*' or '['. * * Any references matching this glob which do not point to a * committish will be ignored. * * @param walk the walker being used for the traversal * @param glob the glob pattern references should match * @return 0 or an error code */ GIT_EXTERN(int) git_revwalk_push_glob(git_revwalk *walk, const char *glob); /** * Push the repository's HEAD * * @param walk the walker being used for the traversal * @return 0 or an error code */ GIT_EXTERN(int) git_revwalk_push_head(git_revwalk *walk); /** * Mark a commit (and its ancestors) uninteresting for the output. * * The given id must belong to a committish on the walked * repository. * * The resolved commit and all its parents will be hidden from the * output on the revision walk. * * @param walk the walker being used for the traversal. * @param commit_id the oid of commit that will be ignored during the traversal * @return 0 or an error code */ GIT_EXTERN(int) git_revwalk_hide(git_revwalk *walk, const git_oid *commit_id); /** * Hide matching references. * * The OIDs pointed to by the references that match the given glob * pattern and their ancestors will be hidden from the output on the * revision walk. * * A leading 'refs/' is implied if not present as well as a trailing * '/\*' if the glob lacks '?', '\*' or '['. * * Any references matching this glob which do not point to a * committish will be ignored. * * @param walk the walker being used for the traversal * @param glob the glob pattern references should match * @return 0 or an error code */ GIT_EXTERN(int) git_revwalk_hide_glob(git_revwalk *walk, const char *glob); /** * Hide the repository's HEAD * * @param walk the walker being used for the traversal * @return 0 or an error code */ GIT_EXTERN(int) git_revwalk_hide_head(git_revwalk *walk); /** * Push the OID pointed to by a reference * * The reference must point to a committish. * * @param walk the walker being used for the traversal * @param refname the reference to push * @return 0 or an error code */ GIT_EXTERN(int) git_revwalk_push_ref(git_revwalk *walk, const char *refname); /** * Hide the OID pointed to by a reference * * The reference must point to a committish. * * @param walk the walker being used for the traversal * @param refname the reference to hide * @return 0 or an error code */ GIT_EXTERN(int) git_revwalk_hide_ref(git_revwalk *walk, const char *refname); /** * Get the next commit from the revision walk. * * The initial call to this method is *not* blocking when * iterating through a repo with a time-sorting mode. * * Iterating with Topological or inverted modes makes the initial * call blocking to preprocess the commit list, but this block should be * mostly unnoticeable on most repositories (topological preprocessing * times at 0.3s on the git.git repo). * * The revision walker is reset when the walk is over. * * @param out Pointer where to store the oid of the next commit * @param walk the walker to pop the commit from. * @return 0 if the next commit was found; * GIT_ITEROVER if there are no commits left to iterate */ GIT_EXTERN(int) git_revwalk_next(git_oid *out, git_revwalk *walk); /** * Change the sorting mode when iterating through the * repository's contents. * * Changing the sorting mode resets the walker. * * @param walk the walker being used for the traversal. * @param sort_mode combination of GIT_SORT_XXX flags */ GIT_EXTERN(void) git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode); /** * Push and hide the respective endpoints of the given range. * * The range should be of the form * .. * where each is in the form accepted by 'git_revparse_single'. * The left-hand commit will be hidden and the right-hand commit pushed. * * @param walk the walker being used for the traversal * @param range the range * @return 0 or an error code * */ GIT_EXTERN(int) git_revwalk_push_range(git_revwalk *walk, const char *range); /** * Simplify the history by first-parent * * No parents other than the first for each commit will be enqueued. */ GIT_EXTERN(void) git_revwalk_simplify_first_parent(git_revwalk *walk); /** * Free a revision walker previously allocated. * * @param walk traversal handle to close. If NULL nothing occurs. */ GIT_EXTERN(void) git_revwalk_free(git_revwalk *walk); /** * Return the repository on which this walker * is operating. * * @param walk the revision walker * @return the repository being walked */ GIT_EXTERN(git_repository *) git_revwalk_repository(git_revwalk *walk); /** * This is a callback function that user can provide to hide a * commit and its parents. If the callback function returns non-zero value, * then this commit and its parents will be hidden. * * @param commit_id oid of Commit * @param payload User-specified pointer to data to be passed as data payload */ typedef int(*git_revwalk_hide_cb)( const git_oid *commit_id, void *payload); /** * Adds a callback function to hide a commit and its parents * * @param walk the revision walker * @param hide_cb callback function to hide a commit and its parents * @param payload data payload to be passed to callback function */ GIT_EXTERN(int) git_revwalk_add_hide_cb( git_revwalk *walk, git_revwalk_hide_cb hide_cb, void *payload); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/merge.h0000664000175000017500000004155012555730137016660 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_merge_h__ #define INCLUDE_git_merge_h__ #include "common.h" #include "types.h" #include "oid.h" #include "oidarray.h" #include "checkout.h" #include "index.h" #include "annotated_commit.h" /** * @file git2/merge.h * @brief Git merge routines * @defgroup git_merge Git merge routines * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * The file inputs to `git_merge_file`. Callers should populate the * `git_merge_file_input` structure with descriptions of the files in * each side of the conflict for use in producing the merge file. */ typedef struct { unsigned int version; /** Pointer to the contents of the file. */ const char *ptr; /** Size of the contents pointed to in `ptr`. */ size_t size; /** File name of the conflicted file, or `NULL` to not merge the path. */ const char *path; /** File mode of the conflicted file, or `0` to not merge the mode. */ unsigned int mode; } git_merge_file_input; #define GIT_MERGE_FILE_INPUT_VERSION 1 #define GIT_MERGE_FILE_INPUT_INIT {GIT_MERGE_FILE_INPUT_VERSION} /** * Initializes a `git_merge_file_input` with default values. Equivalent to * creating an instance with GIT_MERGE_FILE_INPUT_INIT. * * @param opts the `git_merge_file_input` instance to initialize. * @param version the version of the struct; you should pass * `GIT_MERGE_FILE_INPUT_VERSION` here. * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_merge_file_init_input( git_merge_file_input *opts, unsigned int version); /** * Flags for `git_merge_tree` options. A combination of these flags can be * passed in via the `tree_flags` value in the `git_merge_options`. */ typedef enum { /** * Detect renames that occur between the common ancestor and the "ours" * side or the common ancestor and the "theirs" side. This will enable * the ability to merge between a modified and renamed file. */ GIT_MERGE_TREE_FIND_RENAMES = (1 << 0), } git_merge_tree_flag_t; /** * Merge file favor options for `git_merge_options` instruct the file-level * merging functionality how to deal with conflicting regions of the files. */ typedef enum { /** * When a region of a file is changed in both branches, a conflict * will be recorded in the index so that `git_checkout` can produce * a merge file with conflict markers in the working directory. * This is the default. */ GIT_MERGE_FILE_FAVOR_NORMAL = 0, /** * When a region of a file is changed in both branches, the file * created in the index will contain the "ours" side of any conflicting * region. The index will not record a conflict. */ GIT_MERGE_FILE_FAVOR_OURS = 1, /** * When a region of a file is changed in both branches, the file * created in the index will contain the "theirs" side of any conflicting * region. The index will not record a conflict. */ GIT_MERGE_FILE_FAVOR_THEIRS = 2, /** * When a region of a file is changed in both branches, the file * created in the index will contain each unique line from each side, * which has the result of combining both files. The index will not * record a conflict. */ GIT_MERGE_FILE_FAVOR_UNION = 3, } git_merge_file_favor_t; /** * File merging flags */ typedef enum { /** Defaults */ GIT_MERGE_FILE_DEFAULT = 0, /** Create standard conflicted merge files */ GIT_MERGE_FILE_STYLE_MERGE = (1 << 0), /** Create diff3-style files */ GIT_MERGE_FILE_STYLE_DIFF3 = (1 << 1), /** Condense non-alphanumeric regions for simplified diff file */ GIT_MERGE_FILE_SIMPLIFY_ALNUM = (1 << 2), /** Ignore all whitespace */ GIT_MERGE_FILE_IGNORE_WHITESPACE = (1 << 3), /** Ignore changes in amount of whitespace */ GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE = (1 << 4), /** Ignore whitespace at end of line */ GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL = (1 << 5), /** Use the "patience diff" algorithm */ GIT_MERGE_FILE_DIFF_PATIENCE = (1 << 6), /** Take extra time to find minimal diff */ GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7), } git_merge_file_flags_t; /** * Options for merging a file */ typedef struct { unsigned int version; /** * Label for the ancestor file side of the conflict which will be prepended * to labels in diff3-format merge files. */ const char *ancestor_label; /** * Label for our file side of the conflict which will be prepended * to labels in merge files. */ const char *our_label; /** * Label for their file side of the conflict which will be prepended * to labels in merge files. */ const char *their_label; /** The file to favor in region conflicts. */ git_merge_file_favor_t favor; /** see `git_merge_file_flags_t` above */ unsigned int flags; } git_merge_file_options; #define GIT_MERGE_FILE_OPTIONS_VERSION 1 #define GIT_MERGE_FILE_OPTIONS_INIT {GIT_MERGE_FILE_OPTIONS_VERSION} /** * Initializes a `git_merge_file_options` with default values. Equivalent to * creating an instance with GIT_MERGE_FILE_OPTIONS_INIT. * * @param opts the `git_merge_file_options` instance to initialize. * @param version the version of the struct; you should pass * `GIT_MERGE_FILE_OPTIONS_VERSION` here. * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_merge_file_init_options( git_merge_file_options *opts, unsigned int version); /** * Information about file-level merging */ typedef struct { /** * True if the output was automerged, false if the output contains * conflict markers. */ unsigned int automergeable; /** * The path that the resultant merge file should use, or NULL if a * filename conflict would occur. */ const char *path; /** The mode that the resultant merge file should use. */ unsigned int mode; /** The contents of the merge. */ const char *ptr; /** The length of the merge contents. */ size_t len; } git_merge_file_result; /** * Merging options */ typedef struct { unsigned int version; git_merge_tree_flag_t tree_flags; /** * Similarity to consider a file renamed (default 50). If * `GIT_MERGE_TREE_FIND_RENAMES` is enabled, added files will be compared * with deleted files to determine their similarity. Files that are * more similar than the rename threshold (percentage-wise) will be * treated as a rename. */ unsigned int rename_threshold; /** * Maximum similarity sources to examine for renames (default 200). * If the number of rename candidates (add / delete pairs) is greater * than this value, inexact rename detection is aborted. * * This setting overrides the `merge.renameLimit` configuration value. */ unsigned int target_limit; /** Pluggable similarity metric; pass NULL to use internal metric */ git_diff_similarity_metric *metric; /** Flags for handling conflicting content. */ git_merge_file_favor_t file_favor; /** see `git_merge_file_flags_t` above */ unsigned int file_flags; } git_merge_options; #define GIT_MERGE_OPTIONS_VERSION 1 #define GIT_MERGE_OPTIONS_INIT {GIT_MERGE_OPTIONS_VERSION} /** * Initializes a `git_merge_options` with default values. Equivalent to * creating an instance with GIT_MERGE_OPTIONS_INIT. * * @param opts the `git_merge_options` instance to initialize. * @param version the version of the struct; you should pass * `GIT_MERGE_OPTIONS_VERSION` here. * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_merge_init_options( git_merge_options *opts, unsigned int version); /** * The results of `git_merge_analysis` indicate the merge opportunities. */ typedef enum { /** No merge is possible. (Unused.) */ GIT_MERGE_ANALYSIS_NONE = 0, /** * A "normal" merge; both HEAD and the given merge input have diverged * from their common ancestor. The divergent commits must be merged. */ GIT_MERGE_ANALYSIS_NORMAL = (1 << 0), /** * All given merge inputs are reachable from HEAD, meaning the * repository is up-to-date and no merge needs to be performed. */ GIT_MERGE_ANALYSIS_UP_TO_DATE = (1 << 1), /** * The given merge input is a fast-forward from HEAD and no merge * needs to be performed. Instead, the client can check out the * given merge input. */ GIT_MERGE_ANALYSIS_FASTFORWARD = (1 << 2), /** * The HEAD of the current repository is "unborn" and does not point to * a valid commit. No merge can be performed, but the caller may wish * to simply set HEAD to the target commit(s). */ GIT_MERGE_ANALYSIS_UNBORN = (1 << 3), } git_merge_analysis_t; /** * The user's stated preference for merges. */ typedef enum { /** * No configuration was found that suggests a preferred behavior for * merge. */ GIT_MERGE_PREFERENCE_NONE = 0, /** * There is a `merge.ff=false` configuration setting, suggesting that * the user does not want to allow a fast-forward merge. */ GIT_MERGE_PREFERENCE_NO_FASTFORWARD = (1 << 0), /** * There is a `merge.ff=only` configuration setting, suggesting that * the user only wants fast-forward merges. */ GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY = (1 << 1), } git_merge_preference_t; /** * Analyzes the given branch(es) and determines the opportunities for * merging them into the HEAD of the repository. * * @param analysis_out analysis enumeration that the result is written into * @param repo the repository to merge * @param their_heads the heads to merge into * @param their_heads_len the number of heads to merge * @return 0 on success or error code */ GIT_EXTERN(int) git_merge_analysis( git_merge_analysis_t *analysis_out, git_merge_preference_t *preference_out, git_repository *repo, const git_annotated_commit **their_heads, size_t their_heads_len); /** * Find a merge base between two commits * * @param out the OID of a merge base between 'one' and 'two' * @param repo the repository where the commits exist * @param one one of the commits * @param two the other commit * @return 0 on success, GIT_ENOTFOUND if not found or error code */ GIT_EXTERN(int) git_merge_base( git_oid *out, git_repository *repo, const git_oid *one, const git_oid *two); /** * Find merge bases between two commits * * @param out array in which to store the resulting ids * @param repo the repository where the commits exist * @param one one of the commits * @param two the other commit * @return 0 on success, GIT_ENOTFOUND if not found or error code */ GIT_EXTERN(int) git_merge_bases( git_oidarray *out, git_repository *repo, const git_oid *one, const git_oid *two); /** * Find a merge base given a list of commits * * @param out the OID of a merge base considering all the commits * @param repo the repository where the commits exist * @param length The number of commits in the provided `input_array` * @param input_array oids of the commits * @return Zero on success; GIT_ENOTFOUND or -1 on failure. */ GIT_EXTERN(int) git_merge_base_many( git_oid *out, git_repository *repo, size_t length, const git_oid input_array[]); /** * Find all merge bases given a list of commits * * @param out array in which to store the resulting ids * @param repo the repository where the commits exist * @param length The number of commits in the provided `input_array` * @param input_array oids of the commits * @return Zero on success; GIT_ENOTFOUND or -1 on failure. */ GIT_EXTERN(int) git_merge_bases_many( git_oidarray *out, git_repository *repo, size_t length, const git_oid input_array[]); /** * Find a merge base in preparation for an octopus merge * * @param out the OID of a merge base considering all the commits * @param repo the repository where the commits exist * @param length The number of commits in the provided `input_array` * @param input_array oids of the commits * @return Zero on success; GIT_ENOTFOUND or -1 on failure. */ GIT_EXTERN(int) git_merge_base_octopus( git_oid *out, git_repository *repo, size_t length, const git_oid input_array[]); /** * Merge two files as they exist in the in-memory data structures, using * the given common ancestor as the baseline, producing a * `git_merge_file_result` that reflects the merge result. The * `git_merge_file_result` must be freed with `git_merge_file_result_free`. * * Note that this function does not reference a repository and any * configuration must be passed as `git_merge_file_options`. * * @param out The git_merge_file_result to be filled in * @param ancestor The contents of the ancestor file * @param ours The contents of the file in "our" side * @param theirs The contents of the file in "their" side * @param opts The merge file options or `NULL` for defaults * @return 0 on success or error code */ GIT_EXTERN(int) git_merge_file( git_merge_file_result *out, const git_merge_file_input *ancestor, const git_merge_file_input *ours, const git_merge_file_input *theirs, const git_merge_file_options *opts); /** * Merge two files as they exist in the index, using the given common * ancestor as the baseline, producing a `git_merge_file_result` that * reflects the merge result. The `git_merge_file_result` must be freed with * `git_merge_file_result_free`. * * @param out The git_merge_file_result to be filled in * @param repo The repository * @param ancestor The index entry for the ancestor file (stage level 1) * @param ours The index entry for our file (stage level 2) * @param theirs The index entry for their file (stage level 3) * @param opts The merge file options or NULL * @return 0 on success or error code */ GIT_EXTERN(int) git_merge_file_from_index( git_merge_file_result *out, git_repository *repo, const git_index_entry *ancestor, const git_index_entry *ours, const git_index_entry *theirs, const git_merge_file_options *opts); /** * Frees a `git_merge_file_result`. * * @param result The result to free or `NULL` */ GIT_EXTERN(void) git_merge_file_result_free(git_merge_file_result *result); /** * Merge two trees, producing a `git_index` that reflects the result of * the merge. The index may be written as-is to the working directory * or checked out. If the index is to be converted to a tree, the caller * should resolve any conflicts that arose as part of the merge. * * The returned index must be freed explicitly with `git_index_free`. * * @param out pointer to store the index result in * @param repo repository that contains the given trees * @param ancestor_tree the common ancestor between the trees (or null if none) * @param our_tree the tree that reflects the destination tree * @param their_tree the tree to merge in to `our_tree` * @param opts the merge tree options (or null for defaults) * @return 0 on success or error code */ GIT_EXTERN(int) git_merge_trees( git_index **out, git_repository *repo, const git_tree *ancestor_tree, const git_tree *our_tree, const git_tree *their_tree, const git_merge_options *opts); /** * Merge two commits, producing a `git_index` that reflects the result of * the merge. The index may be written as-is to the working directory * or checked out. If the index is to be converted to a tree, the caller * should resolve any conflicts that arose as part of the merge. * * The merge performed uses the first common ancestor, unlike the * `git-merge-recursive` strategy, which may produce an artificial common * ancestor tree when there are multiple ancestors. * * The returned index must be freed explicitly with `git_index_free`. * * @param out pointer to store the index result in * @param repo repository that contains the given trees * @param our_commit the commit that reflects the destination tree * @param their_commit the commit to merge in to `our_commit` * @param opts the merge tree options (or null for defaults) * @return 0 on success or error code */ GIT_EXTERN(int) git_merge_commits( git_index **out, git_repository *repo, const git_commit *our_commit, const git_commit *their_commit, const git_merge_options *opts); /** * Merges the given commit(s) into HEAD, writing the results into the working * directory. Any changes are staged for commit and any conflicts are written * to the index. Callers should inspect the repository's index after this * completes, resolve any conflicts and prepare a commit. * * The merge performed uses the first common ancestor, unlike the * `git-merge-recursive` strategy, which may produce an artificial common * ancestor tree when there are multiple ancestors. * * For compatibility with git, the repository is put into a merging * state. Once the commit is done (or if the uses wishes to abort), * you should clear this state by calling * `git_repository_state_cleanup()`. * * @param repo the repository to merge * @param their_heads the heads to merge into * @param their_heads_len the number of heads to merge * @param merge_opts merge options * @param checkout_opts checkout options * @return 0 on success or error code */ GIT_EXTERN(int) git_merge( git_repository *repo, const git_annotated_commit **their_heads, size_t their_heads_len, const git_merge_options *merge_opts, const git_checkout_options *checkout_opts); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/tag.h0000664000175000017500000002313412426525445016333 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_tag_h__ #define INCLUDE_git_tag_h__ #include "common.h" #include "types.h" #include "oid.h" #include "object.h" #include "strarray.h" /** * @file git2/tag.h * @brief Git tag parsing routines * @defgroup git_tag Git tag management * @ingroup Git * @{ */ GIT_BEGIN_DECL /** * Lookup a tag object from the repository. * * @param out pointer to the looked up tag * @param repo the repo to use when locating the tag. * @param id identity of the tag to locate. * @return 0 or an error code */ GIT_EXTERN(int) git_tag_lookup( git_tag **out, git_repository *repo, const git_oid *id); /** * Lookup a tag object from the repository, * given a prefix of its identifier (short id). * * @see git_object_lookup_prefix * * @param out pointer to the looked up tag * @param repo the repo to use when locating the tag. * @param id identity of the tag to locate. * @param len the length of the short identifier * @return 0 or an error code */ GIT_EXTERN(int) git_tag_lookup_prefix( git_tag **out, git_repository *repo, const git_oid *id, size_t len); /** * Close an open tag * * You can no longer use the git_tag pointer after this call. * * IMPORTANT: You MUST call this method when you are through with a tag to * release memory. Failure to do so will cause a memory leak. * * @param tag the tag to close */ GIT_EXTERN(void) git_tag_free(git_tag *tag); /** * Get the id of a tag. * * @param tag a previously loaded tag. * @return object identity for the tag. */ GIT_EXTERN(const git_oid *) git_tag_id(const git_tag *tag); /** * Get the repository that contains the tag. * * @param tag A previously loaded tag. * @return Repository that contains this tag. */ GIT_EXTERN(git_repository *) git_tag_owner(const git_tag *tag); /** * Get the tagged object of a tag * * This method performs a repository lookup for the * given object and returns it * * @param target_out pointer where to store the target * @param tag a previously loaded tag. * @return 0 or an error code */ GIT_EXTERN(int) git_tag_target(git_object **target_out, const git_tag *tag); /** * Get the OID of the tagged object of a tag * * @param tag a previously loaded tag. * @return pointer to the OID */ GIT_EXTERN(const git_oid *) git_tag_target_id(const git_tag *tag); /** * Get the type of a tag's tagged object * * @param tag a previously loaded tag. * @return type of the tagged object */ GIT_EXTERN(git_otype) git_tag_target_type(const git_tag *tag); /** * Get the name of a tag * * @param tag a previously loaded tag. * @return name of the tag */ GIT_EXTERN(const char *) git_tag_name(const git_tag *tag); /** * Get the tagger (author) of a tag * * @param tag a previously loaded tag. * @return reference to the tag's author or NULL when unspecified */ GIT_EXTERN(const git_signature *) git_tag_tagger(const git_tag *tag); /** * Get the message of a tag * * @param tag a previously loaded tag. * @return message of the tag or NULL when unspecified */ GIT_EXTERN(const char *) git_tag_message(const git_tag *tag); /** * Create a new tag in the repository from an object * * A new reference will also be created pointing to * this tag object. If `force` is true and a reference * already exists with the given name, it'll be replaced. * * The message will not be cleaned up. This can be achieved * through `git_message_prettify()`. * * The tag name will be checked for validity. You must avoid * the characters '~', '^', ':', '\\', '?', '[', and '*', and the * sequences ".." and "@{" which have special meaning to revparse. * * @param oid Pointer where to store the OID of the * newly created tag. If the tag already exists, this parameter * will be the oid of the existing tag, and the function will * return a GIT_EEXISTS error code. * * @param repo Repository where to store the tag * * @param tag_name Name for the tag; this name is validated * for consistency. It should also not conflict with an * already existing tag name * * @param target Object to which this tag points. This object * must belong to the given `repo`. * * @param tagger Signature of the tagger for this tag, and * of the tagging time * * @param message Full message for this tag * * @param force Overwrite existing references * * @return 0 on success, GIT_EINVALIDSPEC or an error code * A tag object is written to the ODB, and a proper reference * is written in the /refs/tags folder, pointing to it */ GIT_EXTERN(int) git_tag_create( git_oid *oid, git_repository *repo, const char *tag_name, const git_object *target, const git_signature *tagger, const char *message, int force); /** * Create a new tag in the object database pointing to a git_object * * The message will not be cleaned up. This can be achieved * through `git_message_prettify()`. * * @param oid Pointer where to store the OID of the * newly created tag * * @param repo Repository where to store the tag * * @param tag_name Name for the tag * * @param target Object to which this tag points. This object * must belong to the given `repo`. * * @param tagger Signature of the tagger for this tag, and * of the tagging time * * @param message Full message for this tag * * @return 0 on success or an error code */ GIT_EXTERN(int) git_tag_annotation_create( git_oid *oid, git_repository *repo, const char *tag_name, const git_object *target, const git_signature *tagger, const char *message); /** * Create a new tag in the repository from a buffer * * @param oid Pointer where to store the OID of the newly created tag * @param repo Repository where to store the tag * @param buffer Raw tag data * @param force Overwrite existing tags * @return 0 on success; error code otherwise */ GIT_EXTERN(int) git_tag_create_frombuffer( git_oid *oid, git_repository *repo, const char *buffer, int force); /** * Create a new lightweight tag pointing at a target object * * A new direct reference will be created pointing to * this target object. If `force` is true and a reference * already exists with the given name, it'll be replaced. * * The tag name will be checked for validity. * See `git_tag_create()` for rules about valid names. * * @param oid Pointer where to store the OID of the provided * target object. If the tag already exists, this parameter * will be filled with the oid of the existing pointed object * and the function will return a GIT_EEXISTS error code. * * @param repo Repository where to store the lightweight tag * * @param tag_name Name for the tag; this name is validated * for consistency. It should also not conflict with an * already existing tag name * * @param target Object to which this tag points. This object * must belong to the given `repo`. * * @param force Overwrite existing references * * @return 0 on success, GIT_EINVALIDSPEC or an error code * A proper reference is written in the /refs/tags folder, * pointing to the provided target object */ GIT_EXTERN(int) git_tag_create_lightweight( git_oid *oid, git_repository *repo, const char *tag_name, const git_object *target, int force); /** * Delete an existing tag reference. * * The tag name will be checked for validity. * See `git_tag_create()` for rules about valid names. * * @param repo Repository where lives the tag * * @param tag_name Name of the tag to be deleted; * this name is validated for consistency. * * @return 0 on success, GIT_EINVALIDSPEC or an error code */ GIT_EXTERN(int) git_tag_delete( git_repository *repo, const char *tag_name); /** * Fill a list with all the tags in the Repository * * The string array will be filled with the names of the * matching tags; these values are owned by the user and * should be free'd manually when no longer needed, using * `git_strarray_free`. * * @param tag_names Pointer to a git_strarray structure where * the tag names will be stored * @param repo Repository where to find the tags * @return 0 or an error code */ GIT_EXTERN(int) git_tag_list( git_strarray *tag_names, git_repository *repo); /** * Fill a list with all the tags in the Repository * which name match a defined pattern * * If an empty pattern is provided, all the tags * will be returned. * * The string array will be filled with the names of the * matching tags; these values are owned by the user and * should be free'd manually when no longer needed, using * `git_strarray_free`. * * @param tag_names Pointer to a git_strarray structure where * the tag names will be stored * @param pattern Standard fnmatch pattern * @param repo Repository where to find the tags * @return 0 or an error code */ GIT_EXTERN(int) git_tag_list_match( git_strarray *tag_names, const char *pattern, git_repository *repo); typedef int (*git_tag_foreach_cb)(const char *name, git_oid *oid, void *payload); /** * Call callback `cb' for each tag in the repository * * @param repo Repository * @param callback Callback function * @param payload Pointer to callback data (optional) */ GIT_EXTERN(int) git_tag_foreach( git_repository *repo, git_tag_foreach_cb callback, void *payload); /** * Recursively peel a tag until a non tag git_object is found * * The retrieved `tag_target` object is owned by the repository * and should be closed with the `git_object_free` method. * * @param tag_target_out Pointer to the peeled git_object * @param tag The tag to be processed * @return 0 or an error code */ GIT_EXTERN(int) git_tag_peel( git_object **tag_target_out, const git_tag *tag); /** @} */ GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/indexer.h0000664000175000017500000000402212426525445017211 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef _INCLUDE_git_indexer_h__ #define _INCLUDE_git_indexer_h__ #include "common.h" #include "types.h" #include "oid.h" GIT_BEGIN_DECL typedef struct git_indexer git_indexer; /** * Create a new indexer instance * * @param out where to store the indexer instance * @param path to the directory where the packfile should be stored * @param mode permissions to use creating packfile or 0 for defaults * @param odb object database from which to read base objects when * fixing thin packs. Pass NULL if no thin pack is expected (an error * will be returned if there are bases missing) * @param progress_cb function to call with progress information * @param progress_cb_payload payload for the progress callback */ GIT_EXTERN(int) git_indexer_new( git_indexer **out, const char *path, unsigned int mode, git_odb *odb, git_transfer_progress_cb progress_cb, void *progress_cb_payload); /** * Add data to the indexer * * @param idx the indexer * @param data the data to add * @param size the size of the data in bytes * @param stats stat storage */ GIT_EXTERN(int) git_indexer_append(git_indexer *idx, const void *data, size_t size, git_transfer_progress *stats); /** * Finalize the pack and index * * Resolve any pending deltas and write out the index file * * @param idx the indexer */ GIT_EXTERN(int) git_indexer_commit(git_indexer *idx, git_transfer_progress *stats); /** * Get the packfile's hash * * A packfile's name is derived from the sorted hashing of all object * names. This is only correct after the index has been finalized. * * @param idx the indexer instance */ GIT_EXTERN(const git_oid *) git_indexer_hash(const git_indexer *idx); /** * Free the indexer and its resources * * @param idx the indexer to free */ GIT_EXTERN(void) git_indexer_free(git_indexer *idx); GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2/transaction.h0000664000175000017500000000704712510265101020072 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_transaction_h__ #define INCLUDE_git_transaction_h__ #include "common.h" GIT_BEGIN_DECL /** * Create a new transaction object * * This does not lock anything, but sets up the transaction object to * know from which repository to lock. * * @param out the resulting transaction * @param repo the repository in which to lock * @return 0 or an error code */ GIT_EXTERN(int) git_transaction_new(git_transaction **out, git_repository *repo); /** * Lock a reference * * Lock the specified reference. This is the first step to updating a * reference. * * @param tx the transaction * @param refname the reference to lock * @return 0 or an error message */ GIT_EXTERN(int) git_transaction_lock_ref(git_transaction *tx, const char *refname); /** * Set the target of a reference * * Set the target of the specified reference. This reference must be * locked. * * @param tx the transaction * @param refname reference to update * @param target target to set the reference to * @param sig signature to use in the reflog; pass NULL to read the identity from the config * @param msg message to use in the reflog * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code */ GIT_EXTERN(int) git_transaction_set_target(git_transaction *tx, const char *refname, const git_oid *target, const git_signature *sig, const char *msg); /** * Set the target of a reference * * Set the target of the specified reference. This reference must be * locked. * * @param tx the transaction * @param refname reference to update * @param target target to set the reference to * @param sig signature to use in the reflog; pass NULL to read the identity from the config * @param msg message to use in the reflog * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code */ GIT_EXTERN(int) git_transaction_set_symbolic_target(git_transaction *tx, const char *refname, const char *target, const git_signature *sig, const char *msg); /** * Set the reflog of a reference * * Set the specified reference's reflog. If this is combined with * setting the target, that update won't be written to the reflog. * * @param tx the transaction * @param refname the reference whose reflog to set * @param reflog the reflog as it should be written out * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code */ GIT_EXTERN(int) git_transaction_set_reflog(git_transaction *tx, const char *refname, const git_reflog *reflog); /** * Remove a reference * * @param tx the transaction * @param refname the reference to remove * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code */ GIT_EXTERN(int) git_transaction_remove(git_transaction *tx, const char *refname); /** * Commit the changes from the transaction * * Perform the changes that have been queued. The updates will be made * one by one, and the first failure will stop the processing. * * @param tx the transaction * @return 0 or an error code */ GIT_EXTERN(int) git_transaction_commit(git_transaction *tx); /** * Free the resources allocated by this transaction * * If any references remain locked, they will be unlocked without any * changes made to them. * * @param tx the transaction */ GIT_EXTERN(void) git_transaction_free(git_transaction *tx); GIT_END_DECL #endif deps/libgit2-sys-0.3.8/libgit2/include/git2.h0000664000175000017500000000312512555730137015555 0ustar /* * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ #ifndef INCLUDE_git_git_h__ #define INCLUDE_git_git_h__ #include "git2/annotated_commit.h" #include "git2/attr.h" #include "git2/blob.h" #include "git2/blame.h" #include "git2/branch.h" #include "git2/buffer.h" #include "git2/checkout.h" #include "git2/cherrypick.h" #include "git2/clone.h" #include "git2/commit.h" #include "git2/common.h" #include "git2/config.h" #include "git2/describe.h" #include "git2/diff.h" #include "git2/errors.h" #include "git2/filter.h" #include "git2/global.h" #include "git2/graph.h" #include "git2/ignore.h" #include "git2/index.h" #include "git2/indexer.h" #include "git2/merge.h" #include "git2/message.h" #include "git2/net.h" #include "git2/notes.h" #include "git2/object.h" #include "git2/odb.h" #include "git2/odb_backend.h" #include "git2/oid.h" #include "git2/pack.h" #include "git2/patch.h" #include "git2/pathspec.h" #include "git2/rebase.h" #include "git2/refdb.h" #include "git2/reflog.h" #include "git2/refs.h" #include "git2/refspec.h" #include "git2/remote.h" #include "git2/repository.h" #include "git2/reset.h" #include "git2/revert.h" #include "git2/revparse.h" #include "git2/revwalk.h" #include "git2/signature.h" #include "git2/stash.h" #include "git2/status.h" #include "git2/submodule.h" #include "git2/tag.h" #include "git2/transport.h" #include "git2/transaction.h" #include "git2/tree.h" #include "git2/types.h" #include "git2/version.h" #endif deps/advapi32-sys-0.1.2/0000755000000000000000000000000012666635521013404 5ustar rootrootdeps/advapi32-sys-0.1.2/README.md0000644000000000000000000000014612552442673014662 0ustar rootroot# advapi32-sys # FFI bindings to advapi32. [Documentation](https://retep998.github.io/doc/advapi32/) deps/advapi32-sys-0.1.2/src/0000755000000000000000000000000012666635521014173 5ustar rootrootdeps/advapi32-sys-0.1.2/src/lib.rs0000644000000000000000000012263612552442614015312 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! FFI bindings to advapi32. #![cfg(windows)] extern crate winapi; use winapi::*; extern "system" { // pub fn AbortSystemShutdownA(); // pub fn AbortSystemShutdownW(); // pub fn AccessCheck(); // pub fn AccessCheckAndAuditAlarmA(); // pub fn AccessCheckAndAuditAlarmW(); // pub fn AccessCheckByType(); // pub fn AccessCheckByTypeAndAuditAlarmA(); // pub fn AccessCheckByTypeAndAuditAlarmW(); // pub fn AccessCheckByTypeResultList(); // pub fn AccessCheckByTypeResultListAndAuditAlarmA(); // pub fn AccessCheckByTypeResultListAndAuditAlarmByHandleA(); // pub fn AccessCheckByTypeResultListAndAuditAlarmByHandleW(); // pub fn AccessCheckByTypeResultListAndAuditAlarmW(); // pub fn AddAccessAllowedAce(); // pub fn AddAccessAllowedAceEx(); // pub fn AddAccessAllowedObjectAce(); // pub fn AddAccessDeniedAce(); // pub fn AddAccessDeniedAceEx(); // pub fn AddAccessDeniedObjectAce(); // pub fn AddAce(); // pub fn AddAuditAccessAce(); // pub fn AddAuditAccessAceEx(); // pub fn AddAuditAccessObjectAce(); // pub fn AddConditionalAce(); // pub fn AddMandatoryAce(); // pub fn AddUsersToEncryptedFile(); // pub fn AddUsersToEncryptedFileEx(); // pub fn AdjustTokenGroups(); pub fn AdjustTokenPrivileges( TokenHandle: HANDLE, DisableAllPrivileges: BOOL, NewState: PTOKEN_PRIVILEGES, BufferLength: DWORD, PreviousState: PTOKEN_PRIVILEGES, ReturnLength: PDWORD, ) -> BOOL; // pub fn AllocateAndInitializeSid(); // pub fn AllocateLocallyUniqueId(); // pub fn AreAllAccessesGranted(); // pub fn AreAnyAccessesGranted(); // pub fn AuditComputeEffectivePolicyBySid(); // pub fn AuditComputeEffectivePolicyByToken(); // pub fn AuditEnumerateCategories(); // pub fn AuditEnumeratePerUserPolicy(); // pub fn AuditEnumerateSubCategories(); // pub fn AuditFree(); // pub fn AuditLookupCategoryGuidFromCategoryId(); // pub fn AuditLookupCategoryIdFromCategoryGuid(); // pub fn AuditLookupCategoryNameA(); // pub fn AuditLookupCategoryNameW(); // pub fn AuditLookupSubCategoryNameA(); // pub fn AuditLookupSubCategoryNameW(); // pub fn AuditQueryGlobalSaclA(); // pub fn AuditQueryGlobalSaclW(); // pub fn AuditQueryPerUserPolicy(); // pub fn AuditQuerySecurity(); // pub fn AuditQuerySystemPolicy(); // pub fn AuditSetGlobalSaclA(); // pub fn AuditSetGlobalSaclW(); // pub fn AuditSetPerUserPolicy(); // pub fn AuditSetSecurity(); // pub fn AuditSetSystemPolicy(); // pub fn BackupEventLogA(); // pub fn BackupEventLogW(); // pub fn BaseRegCloseKey(); // pub fn BaseRegCreateKey(); // pub fn BaseRegDeleteKeyEx(); // pub fn BaseRegDeleteValue(); // pub fn BaseRegFlushKey(); // pub fn BaseRegGetVersion(); // pub fn BaseRegLoadKey(); // pub fn BaseRegOpenKey(); // pub fn BaseRegRestoreKey(); // pub fn BaseRegSaveKeyEx(); // pub fn BaseRegSetKeySecurity(); // pub fn BaseRegSetValue(); // pub fn BaseRegUnLoadKey(); // pub fn BuildExplicitAccessWithNameA(); // pub fn BuildExplicitAccessWithNameW(); // pub fn BuildImpersonateExplicitAccessWithNameA(); // pub fn BuildImpersonateExplicitAccessWithNameW(); // pub fn BuildImpersonateTrusteeA(); // pub fn BuildImpersonateTrusteeW(); // pub fn BuildSecurityDescriptorA(); // pub fn BuildSecurityDescriptorW(); // pub fn BuildTrusteeWithNameA(); // pub fn BuildTrusteeWithNameW(); // pub fn BuildTrusteeWithObjectsAndNameA(); // pub fn BuildTrusteeWithObjectsAndNameW(); // pub fn BuildTrusteeWithObjectsAndSidA(); // pub fn BuildTrusteeWithObjectsAndSidW(); // pub fn BuildTrusteeWithSidA(); // pub fn BuildTrusteeWithSidW(); // pub fn CancelOverlappedAccess(); // pub fn ChangeServiceConfig2A(); // pub fn ChangeServiceConfig2W(); // pub fn ChangeServiceConfigA(); // pub fn ChangeServiceConfigW(); // pub fn CheckForHiberboot(); // pub fn CheckTokenMembership(); // pub fn ClearEventLogA(); // pub fn ClearEventLogW(); // pub fn CloseCodeAuthzLevel(); // pub fn CloseEncryptedFileRaw(); // pub fn CloseEventLog(); pub fn CloseServiceHandle(hSCObject: SC_HANDLE) -> BOOL; // pub fn CloseThreadWaitChainSession(); // pub fn CloseTrace(); // pub fn CommandLineFromMsiDescriptor(); // pub fn ComputeAccessTokenFromCodeAuthzLevel(); pub fn ControlService( hService: SC_HANDLE, dwControl: DWORD, lpServiceStatus: LPSERVICE_STATUS, ) -> BOOL; // pub fn ControlServiceExA(); // pub fn ControlServiceExW(); // pub fn ControlTraceA(); // pub fn ControlTraceW(); // pub fn ConvertAccessToSecurityDescriptorA(); // pub fn ConvertAccessToSecurityDescriptorW(); // pub fn ConvertSDToStringSDDomainW(); // pub fn ConvertSDToStringSDRootDomainA(); // pub fn ConvertSDToStringSDRootDomainW(); // pub fn ConvertSecurityDescriptorToAccessA(); // pub fn ConvertSecurityDescriptorToAccessNamedA(); // pub fn ConvertSecurityDescriptorToAccessNamedW(); // pub fn ConvertSecurityDescriptorToAccessW(); // pub fn ConvertSecurityDescriptorToStringSecurityDescriptorA(); // pub fn ConvertSecurityDescriptorToStringSecurityDescriptorW(); // pub fn ConvertSidToStringSidA(); // pub fn ConvertSidToStringSidW(); // pub fn ConvertStringSDToSDDomainA(); // pub fn ConvertStringSDToSDDomainW(); // pub fn ConvertStringSDToSDRootDomainA(); // pub fn ConvertStringSDToSDRootDomainW(); // pub fn ConvertStringSecurityDescriptorToSecurityDescriptorA(); // pub fn ConvertStringSecurityDescriptorToSecurityDescriptorW(); // pub fn ConvertStringSidToSidA(); // pub fn ConvertStringSidToSidW(); // pub fn ConvertToAutoInheritPrivateObjectSecurity(); // pub fn CopySid(); // pub fn CreateCodeAuthzLevel(); // pub fn CreatePrivateObjectSecurity(); // pub fn CreatePrivateObjectSecurityEx(); // pub fn CreatePrivateObjectSecurityWithMultipleInheritance(); // pub fn CreateProcessAsUserA(); // pub fn CreateProcessAsUserW(); // pub fn CreateProcessWithLogonW(); // pub fn CreateProcessWithTokenW(); // pub fn CreateRestrictedToken(); pub fn CreateServiceA( hSCManager: SC_HANDLE, lpServiceName: LPCSTR, lpDisplayName: LPCSTR, dwDesiredAccess: DWORD, dwServiceType: DWORD, dwStartType: DWORD, dwErrorControl: DWORD, lpBinaryPathName: LPCSTR, lpLoadOrderGroup: LPCSTR, lpdwTagId: LPDWORD, lpDependencies: LPCSTR, lpServiceStartName: LPCSTR, lpPassword: LPCSTR, ) -> SC_HANDLE; pub fn CreateServiceW( hSCManager: SC_HANDLE, lpServiceName: LPCWSTR, lpDisplayName: LPCWSTR, dwDesiredAccess: DWORD, dwServiceType: DWORD, dwStartType: DWORD, dwErrorControl: DWORD, lpBinaryPathName: LPCWSTR, lpLoadOrderGroup: LPCWSTR, lpdwTagId: LPDWORD, lpDependencies: LPCWSTR, lpServiceStartName: LPCWSTR, lpPassword: LPCWSTR, ) -> SC_HANDLE; // pub fn CreateTraceInstanceId(); // pub fn CreateWellKnownSid(); pub fn CredDeleteA(TargetName: LPCSTR, Type: DWORD, Flags: DWORD) -> BOOL; pub fn CredDeleteW(TargetName: LPCWSTR, Type: DWORD, Flags: DWORD) -> BOOL; // pub fn CredEnumerateA(); // pub fn CredEnumerateW(); // pub fn CredFindBestCredentialA(); // pub fn CredFindBestCredentialW(); pub fn CredFree(Buffer: PVOID); // pub fn CredGetSessionTypes(); // pub fn CredGetTargetInfoA(); // pub fn CredGetTargetInfoW(); // pub fn CredIsMarshaledCredentialA(); // pub fn CredIsMarshaledCredentialW(); // pub fn CredIsProtectedA(); // pub fn CredIsProtectedW(); // pub fn CredMarshalCredentialA(); // pub fn CredMarshalCredentialW(); // pub fn CredProtectA(); // pub fn CredProtectW(); pub fn CredReadA( TargetName: LPCSTR, Type: DWORD, Flags: DWORD, Credential: *mut PCREDENTIALA, ) -> BOOL; // pub fn CredReadDomainCredentialsA(); // pub fn CredReadDomainCredentialsW(); pub fn CredReadW( TargetName: LPCWSTR, Type: DWORD, Flags: DWORD, Credential: *mut PCREDENTIALW, ) -> BOOL; // pub fn CredRenameA(); // pub fn CredRenameW(); // pub fn CredUnmarshalCredentialA(); // pub fn CredUnmarshalCredentialW(); // pub fn CredUnprotectA(); // pub fn CredUnprotectW(); pub fn CredWriteA(Credential: PCREDENTIALA, Flags: DWORD) -> BOOL; // pub fn CredWriteDomainCredentialsA(); // pub fn CredWriteDomainCredentialsW(); pub fn CredWriteW(Credential: PCREDENTIALW, Flags: DWORD) -> BOOL; pub fn CryptAcquireContextA( phProv: *mut HCRYPTPROV, szContainer: LPCSTR, szProvider: LPCSTR, dwProvType: DWORD, dwFlags: DWORD, ) -> BOOL; pub fn CryptAcquireContextW( phProv: *mut HCRYPTPROV, szContainer: LPCWSTR, szProvider: LPCWSTR, dwProvType: DWORD, dwFlags: DWORD, ) -> BOOL; pub fn CryptContextAddRef(hProv: HCRYPTPROV, pdwReserved: *mut DWORD, dwFlags: DWORD) -> BOOL; pub fn CryptCreateHash( hProv: HCRYPTPROV, Algid: ALG_ID, hKey: HCRYPTKEY, dwFlags: DWORD, phHash: *mut HCRYPTHASH, ) -> BOOL; pub fn CryptDecrypt( hKey: HCRYPTKEY, hHash: HCRYPTHASH, Final: BOOL, dwFlags: DWORD, pbData: *mut BYTE, pdwDataLen: *mut DWORD, ) -> BOOL; pub fn CryptDeriveKey( hProv: HCRYPTPROV, Algid: ALG_ID, hBaseData: HCRYPTHASH, dwFlags: DWORD, phKey: *mut HCRYPTKEY, ) -> BOOL; pub fn CryptDestroyHash(hHash: HCRYPTHASH) -> BOOL; pub fn CryptDestroyKey(hKey: HCRYPTKEY) -> BOOL; pub fn CryptDuplicateHash( hHash: HCRYPTHASH, pdwReserved: *mut DWORD, dwFlags: DWORD, phHash: *mut HCRYPTHASH, ) -> BOOL; pub fn CryptDuplicateKey( hKey: HCRYPTKEY, pdwReserved: *mut DWORD, dwFlags: DWORD, phKey: *mut HCRYPTKEY, ) -> BOOL; pub fn CryptEncrypt( hKey: HCRYPTKEY, hHash: HCRYPTHASH, Final: BOOL, dwFlags: DWORD, pbData: *mut BYTE, pdwDataLen: *mut DWORD, dwBufLen: DWORD, ) -> BOOL; pub fn CryptEnumProviderTypesA( dwIndex: DWORD, pdwReserved: *mut DWORD, dwFlags: DWORD, pdwProvType: *mut DWORD, szTypeName: LPSTR, pcbTypeName: *mut DWORD, ) -> BOOL; pub fn CryptEnumProviderTypesW( dwIndex: DWORD, pdwReserved: *mut DWORD, dwFlags: DWORD, pdwProvType: *mut DWORD, szTypeName: LPWSTR, pcbTypeName: *mut DWORD, ) -> BOOL; pub fn CryptEnumProvidersA( dwIndex: DWORD, pdwReserved: *mut DWORD, dwFlags: DWORD, pdwProvType: *mut DWORD, szProvName: LPSTR, pcbProvName: *mut DWORD, ) -> BOOL; pub fn CryptEnumProvidersW( dwIndex: DWORD, pdwReserved: *mut DWORD, dwFlags: DWORD, pdwProvType: *mut DWORD, szProvName: LPWSTR, pcbProvName: *mut DWORD, ) -> BOOL; pub fn CryptExportKey( hKey: HCRYPTKEY, hExpKey: HCRYPTKEY, dwBlobType: DWORD, dwFlags: DWORD, pbData: *mut BYTE, pdwDataLen: *mut DWORD, ) -> BOOL; pub fn CryptGenKey( hProv: HCRYPTPROV, Algid: ALG_ID, dwFlags: DWORD, phKey: *mut HCRYPTKEY, ) -> BOOL; pub fn CryptGenRandom(hProv: HCRYPTPROV, dwLen: DWORD, pbBuffer: *mut BYTE) -> BOOL; pub fn CryptGetDefaultProviderA( dwProvType: DWORD, pdwReserved: *mut DWORD, dwFlags: DWORD, pszProvName: LPSTR, pcbProvName: *mut DWORD, ) -> BOOL; pub fn CryptGetDefaultProviderW( dwProvType: DWORD, pdwReserved: *mut DWORD, dwFlags: DWORD, pszProvName: LPWSTR, pcbProvName: *mut DWORD, ) -> BOOL; pub fn CryptGetHashParam( hHash: HCRYPTHASH, dwParam: DWORD, pbData: *mut BYTE, pdwDataLen: *mut DWORD, dwFlags: DWORD, ) -> BOOL; pub fn CryptGetKeyParam( hKey: HCRYPTKEY, dwParam: DWORD, pbData: *mut BYTE, pdwDataLen: *mut DWORD, dwFlags: DWORD, ) -> BOOL; pub fn CryptGetProvParam( hProv: HCRYPTPROV, dwParam: DWORD, pbData: *mut BYTE, pdwDataLen: *mut DWORD, dwFlags: DWORD, ) -> BOOL; pub fn CryptGetUserKey(hProv: HCRYPTPROV, dwKeySpec: DWORD, phUserKey: *mut HCRYPTKEY) -> BOOL; pub fn CryptHashData( hHash: HCRYPTHASH, pbData: *const BYTE, dwDataLen: DWORD, dwFlags: DWORD, ) -> BOOL; pub fn CryptHashSessionKey(hHash: HCRYPTHASH, hKey: HCRYPTKEY, dwFlags: DWORD) -> BOOL; pub fn CryptImportKey( hProv: HCRYPTPROV, pbData: *const BYTE, dwDataLen: DWORD, hPubKey: HCRYPTKEY, dwFlags: DWORD, phKey: *mut HCRYPTKEY, ) -> BOOL; pub fn CryptReleaseContext(hProv: HCRYPTPROV, dwFlags: DWORD) -> BOOL; pub fn CryptSetHashParam( hHash: HCRYPTHASH, dwParam: DWORD, pbData: *const BYTE, dwFlags: DWORD, ) -> BOOL; pub fn CryptSetKeyParam( hKey: HCRYPTKEY, dwParam: DWORD, pbData: *const BYTE, dwFlags: DWORD, ) -> BOOL; pub fn CryptSetProvParam( hProv: HCRYPTPROV, dwParam: DWORD, pbData: *const BYTE, dwFlags: DWORD, ) -> BOOL; pub fn CryptSetProviderA(pszProvName: LPCSTR, dwProvType: DWORD) -> BOOL; pub fn CryptSetProviderExA( pszProvName: LPCSTR, dwProvType: DWORD, pdwReserved: *mut DWORD, dwFlags: DWORD, ) -> BOOL; pub fn CryptSetProviderExW( pszProvName: LPCWSTR, dwProvType: DWORD, pdwReserved: *mut DWORD, dwFlags: DWORD, ) -> BOOL; pub fn CryptSetProviderW(pszProvName: LPCWSTR, dwProvType: DWORD) -> BOOL; pub fn CryptSignHashA( hHash: HCRYPTHASH, dwKeySpec: DWORD, szDescription: LPCSTR, dwFlags: DWORD, pbSignature: *mut BYTE, pdwSigLen: *mut DWORD, ) -> BOOL; pub fn CryptSignHashW( hHash: HCRYPTHASH, dwKeySpec: DWORD, szDescription: LPCWSTR, dwFlags: DWORD, pbSignature: *mut BYTE, pdwSigLen: *mut DWORD, ) -> BOOL; pub fn CryptVerifySignatureA( hHash: HCRYPTHASH, pbSignature: *const BYTE, dwSigLen: DWORD, hPubKey: HCRYPTKEY, szDescription: LPCSTR, dwFlags: DWORD, ) -> BOOL; pub fn CryptVerifySignatureW( hHash: HCRYPTHASH, pbSignature: *const BYTE, dwSigLen: DWORD, hPubKey: HCRYPTKEY, szDescription: LPCWSTR, dwFlags: DWORD, ) -> BOOL; // pub fn DecryptFileA(); // pub fn DecryptFileW(); // pub fn DeleteAce(); pub fn DeleteService(hService: SC_HANDLE) -> BOOL; // pub fn DeregisterEventSource(); // pub fn DestroyPrivateObjectSecurity(); // pub fn DuplicateEncryptionInfoFile(); // pub fn DuplicateToken(); // pub fn DuplicateTokenEx(); // pub fn ElfBackupEventLogFileA(); // pub fn ElfBackupEventLogFileW(); // pub fn ElfChangeNotify(); // pub fn ElfClearEventLogFileA(); // pub fn ElfClearEventLogFileW(); // pub fn ElfCloseEventLog(); // pub fn ElfDeregisterEventSource(); // pub fn ElfFlushEventLog(); // pub fn ElfNumberOfRecords(); // pub fn ElfOldestRecord(); // pub fn ElfOpenBackupEventLogA(); // pub fn ElfOpenBackupEventLogW(); // pub fn ElfOpenEventLogA(); // pub fn ElfOpenEventLogW(); // pub fn ElfReadEventLogA(); // pub fn ElfReadEventLogW(); // pub fn ElfRegisterEventSourceA(); // pub fn ElfRegisterEventSourceW(); // pub fn ElfReportEventA(); // pub fn ElfReportEventAndSourceW(); // pub fn ElfReportEventW(); // pub fn EnableTrace(); // pub fn EnableTraceEx(); // pub fn EnableTraceEx2(); // pub fn EncryptFileA(); // pub fn EncryptFileW(); // pub fn EncryptedFileKeyInfo(); // pub fn EncryptionDisable(); // pub fn EnumDependentServicesA(); // pub fn EnumDependentServicesW(); // pub fn EnumDynamicTimeZoneInformation(); // pub fn EnumServiceGroupW(); // pub fn EnumServicesStatusA(); // pub fn EnumServicesStatusExA(); // pub fn EnumServicesStatusExW(); // pub fn EnumServicesStatusW(); // pub fn EnumerateTraceGuids(); // pub fn EnumerateTraceGuidsEx(); // pub fn EqualDomainSid(); // pub fn EqualPrefixSid(); // pub fn EqualSid(); // pub fn EtwLogSysConfigExtension(); // pub fn EventAccessControl(); // pub fn EventAccessQuery(); // pub fn EventAccessRemove(); // pub fn EventActivityIdControl(); // pub fn EventEnabled(); // pub fn EventProviderEnabled(); // pub fn EventRegister(); // pub fn EventSetInformation(); // pub fn EventUnregister(); // pub fn EventWrite(); // pub fn EventWriteEndScenario(); // pub fn EventWriteEx(); // pub fn EventWriteStartScenario(); // pub fn EventWriteString(); // pub fn EventWriteTransfer(); // pub fn FileEncryptionStatusA(); // pub fn FileEncryptionStatusW(); // pub fn FindFirstFreeAce(); // pub fn FlushEfsCache(); // pub fn FlushTraceA(); // pub fn FlushTraceW(); // pub fn FreeEncryptedFileKeyInfo(); // pub fn FreeEncryptedFileMetadata(); // pub fn FreeEncryptionCertificateHashList(); // pub fn FreeInheritedFromArray(); // pub fn FreeSid(); // pub fn GetAccessPermissionsForObjectA(); // pub fn GetAccessPermissionsForObjectW(); // pub fn GetAce(); // pub fn GetAclInformation(); // pub fn GetAuditedPermissionsFromAclA(); // pub fn GetAuditedPermissionsFromAclW(); // pub fn GetCurrentHwProfileA(); // pub fn GetCurrentHwProfileW(); // pub fn GetDynamicTimeZoneInformationEffectiveYears(); // pub fn GetEffectiveRightsFromAclA(); // pub fn GetEffectiveRightsFromAclW(); // pub fn GetEncryptedFileMetadata(); // pub fn GetEventLogInformation(); // pub fn GetExplicitEntriesFromAclA(); // pub fn GetExplicitEntriesFromAclW(); // pub fn GetFileSecurityA(); // pub fn GetFileSecurityW(); // pub fn GetInformationCodeAuthzLevelW(); // pub fn GetInformationCodeAuthzPolicyW(); // pub fn GetInheritanceSourceA(); // pub fn GetInheritanceSourceW(); // pub fn GetKernelObjectSecurity(); // pub fn GetLengthSid(); // pub fn GetLocalManagedApplicationData(); // pub fn GetLocalManagedApplications(); // pub fn GetManagedApplicationCategories(); // pub fn GetManagedApplications(); // pub fn GetMultipleTrusteeA(); // pub fn GetMultipleTrusteeOperationA(); // pub fn GetMultipleTrusteeOperationW(); // pub fn GetMultipleTrusteeW(); // pub fn GetNamedSecurityInfoA(); // pub fn GetNamedSecurityInfoExA(); // pub fn GetNamedSecurityInfoExW(); // pub fn GetNamedSecurityInfoW(); // pub fn GetNumberOfEventLogRecords(); // pub fn GetOldestEventLogRecord(); // pub fn GetOverlappedAccessResults(); // pub fn GetPrivateObjectSecurity(); // pub fn GetSecurityDescriptorControl(); // pub fn GetSecurityDescriptorDacl(); // pub fn GetSecurityDescriptorGroup(); // pub fn GetSecurityDescriptorLength(); // pub fn GetSecurityDescriptorOwner(); // pub fn GetSecurityDescriptorRMControl(); // pub fn GetSecurityDescriptorSacl(); // pub fn GetSecurityInfo(); // pub fn GetSecurityInfoExA(); // pub fn GetSecurityInfoExW(); // pub fn GetServiceDisplayNameA(); // pub fn GetServiceDisplayNameW(); // pub fn GetServiceKeyNameA(); // pub fn GetServiceKeyNameW(); // pub fn GetSidIdentifierAuthority(); // pub fn GetSidLengthRequired(); // pub fn GetSidSubAuthority(); // pub fn GetSidSubAuthorityCount(); // pub fn GetStringConditionFromBinary(); // pub fn GetThreadWaitChain(); // pub fn GetTokenInformation(); // pub fn GetTraceEnableFlags(); // pub fn GetTraceEnableLevel(); // pub fn GetTraceLoggerHandle(); // pub fn GetTrusteeFormA(); // pub fn GetTrusteeFormW(); // pub fn GetTrusteeNameA(); // pub fn GetTrusteeNameW(); // pub fn GetTrusteeTypeA(); // pub fn GetTrusteeTypeW(); pub fn GetUserNameA(lpBuffer: LPSTR, pcbBuffer: LPDWORD) -> BOOL; pub fn GetUserNameW(lpBuffer: LPWSTR, pcbBuffer: LPDWORD) -> BOOL; // pub fn GetWindowsAccountDomainSid(); // pub fn I_ScSetServiceBitsA(); // pub fn I_ScSetServiceBitsW(); // pub fn IdentifyCodeAuthzLevelW(); // pub fn ImpersonateAnonymousToken(); // pub fn ImpersonateLoggedOnUser(); // pub fn ImpersonateNamedPipeClient(); // pub fn ImpersonateSelf(); // pub fn InitializeAcl(); // pub fn InitializeSecurityDescriptor(); // pub fn InitializeSid(); // pub fn InitiateShutdownA(); // pub fn InitiateShutdownW(); // pub fn InitiateSystemShutdownA(); // pub fn InitiateSystemShutdownExA(); // pub fn InitiateSystemShutdownExW(); // pub fn InitiateSystemShutdownW(); // pub fn InstallApplication(); // pub fn IsTextUnicode(); // pub fn IsTokenRestricted(); // pub fn IsTokenUntrusted(); // pub fn IsValidAcl(); // pub fn IsValidRelativeSecurityDescriptor(); // pub fn IsValidSecurityDescriptor(); // pub fn IsValidSid(); // pub fn IsWellKnownSid(); // pub fn LockServiceDatabase(); // pub fn LogonUserA(); // pub fn LogonUserExA(); // pub fn LogonUserExExW(); // pub fn LogonUserExW(); // pub fn LogonUserW(); // pub fn LookupAccountNameA(); // pub fn LookupAccountNameW(); // pub fn LookupAccountSidA(); // pub fn LookupAccountSidW(); // pub fn LookupPrivilegeDisplayNameA(); // pub fn LookupPrivilegeDisplayNameW(); // pub fn LookupPrivilegeNameA(); // pub fn LookupPrivilegeNameW(); pub fn LookupPrivilegeValueA( lpSystemName: LPCSTR, lpName: LPCSTR, lpLuid: PLUID, ) -> BOOL; pub fn LookupPrivilegeValueW( lpSystemName: LPCWSTR, lpName: LPCWSTR, lpLuid: PLUID, ) -> BOOL; // pub fn LookupSecurityDescriptorPartsA(); // pub fn LookupSecurityDescriptorPartsW(); // pub fn LsaAddAccountRights(); // pub fn LsaAddPrivilegesToAccount(); // pub fn LsaClearAuditLog(); // pub fn LsaClose(); // pub fn LsaCreateAccount(); // pub fn LsaCreateSecret(); // pub fn LsaCreateTrustedDomain(); // pub fn LsaCreateTrustedDomainEx(); // pub fn LsaDelete(); // pub fn LsaDeleteTrustedDomain(); // pub fn LsaEnumerateAccountRights(); // pub fn LsaEnumerateAccounts(); // pub fn LsaEnumerateAccountsWithUserRight(); // pub fn LsaEnumeratePrivileges(); // pub fn LsaEnumeratePrivilegesOfAccount(); // pub fn LsaEnumerateTrustedDomains(); // pub fn LsaEnumerateTrustedDomainsEx(); // pub fn LsaFreeMemory(); // pub fn LsaGetAppliedCAPIDs(); // pub fn LsaGetQuotasForAccount(); // pub fn LsaGetRemoteUserName(); // pub fn LsaGetSystemAccessAccount(); // pub fn LsaGetUserName(); // pub fn LsaICLookupNames(); // pub fn LsaICLookupNamesWithCreds(); // pub fn LsaICLookupSids(); // pub fn LsaICLookupSidsWithCreds(); // pub fn LsaLookupNames(); // pub fn LsaLookupNames2(); // pub fn LsaLookupPrivilegeDisplayName(); // pub fn LsaLookupPrivilegeName(); // pub fn LsaLookupPrivilegeValue(); // pub fn LsaLookupSids(); // pub fn LsaLookupSids2(); // pub fn LsaManageSidNameMapping(); // pub fn LsaNtStatusToWinError(); // pub fn LsaOpenAccount(); // pub fn LsaOpenPolicy(); // pub fn LsaOpenPolicySce(); // pub fn LsaOpenSecret(); // pub fn LsaOpenTrustedDomain(); // pub fn LsaOpenTrustedDomainByName(); // pub fn LsaQueryCAPs(); // pub fn LsaQueryDomainInformationPolicy(); // pub fn LsaQueryForestTrustInformation(); // pub fn LsaQueryInfoTrustedDomain(); // pub fn LsaQueryInformationPolicy(); // pub fn LsaQuerySecret(); // pub fn LsaQuerySecurityObject(); // pub fn LsaQueryTrustedDomainInfo(); // pub fn LsaQueryTrustedDomainInfoByName(); // pub fn LsaRemoveAccountRights(); // pub fn LsaRemovePrivilegesFromAccount(); // pub fn LsaRetrievePrivateData(); // pub fn LsaSetCAPs(); // pub fn LsaSetDomainInformationPolicy(); // pub fn LsaSetForestTrustInformation(); // pub fn LsaSetInformationPolicy(); // pub fn LsaSetInformationTrustedDomain(); // pub fn LsaSetQuotasForAccount(); // pub fn LsaSetSecret(); // pub fn LsaSetSecurityObject(); // pub fn LsaSetSystemAccessAccount(); // pub fn LsaSetTrustedDomainInfoByName(); // pub fn LsaSetTrustedDomainInformation(); // pub fn LsaStorePrivateData(); // pub fn MIDL_user_free_Ext(); // pub fn MSChapSrvChangePassword(); // pub fn MSChapSrvChangePassword2(); // pub fn MakeAbsoluteSD(); // pub fn MakeAbsoluteSD2(); // pub fn MakeSelfRelativeSD(); // pub fn MapGenericMask(); // pub fn NotifyBootConfigStatus(); // pub fn NotifyChangeEventLog(); // pub fn NotifyServiceStatusChange(); // pub fn NotifyServiceStatusChangeA(); // pub fn NotifyServiceStatusChangeW(); // pub fn ObjectCloseAuditAlarmA(); // pub fn ObjectCloseAuditAlarmW(); // pub fn ObjectDeleteAuditAlarmA(); // pub fn ObjectDeleteAuditAlarmW(); // pub fn ObjectOpenAuditAlarmA(); // pub fn ObjectOpenAuditAlarmW(); // pub fn ObjectPrivilegeAuditAlarmA(); // pub fn ObjectPrivilegeAuditAlarmW(); // pub fn OpenBackupEventLogA(); // pub fn OpenBackupEventLogW(); // pub fn OpenEncryptedFileRawA(); // pub fn OpenEncryptedFileRawW(); // pub fn OpenEventLogA(); // pub fn OpenEventLogW(); pub fn OpenProcessToken( ProcessHandle: HANDLE, DesiredAccess: DWORD, TokenHandle: PHANDLE, ) -> BOOL; pub fn OpenSCManagerA( lpMachineName: LPCSTR, lpDatabaseName: LPCSTR, dwDesiredAccess: DWORD, ) -> SC_HANDLE; pub fn OpenSCManagerW( lpMachineName: LPCWSTR, lpDatabaseName: LPCWSTR, dwDesiredAccess: DWORD, ) -> SC_HANDLE; pub fn OpenServiceA( hSCManager: SC_HANDLE, lpServiceName: LPCSTR, dwDesiredAccess: DWORD, ) -> SC_HANDLE; pub fn OpenServiceW( hSCManager: SC_HANDLE, lpServiceName: LPCWSTR, dwDesiredAccess: DWORD, ) -> SC_HANDLE; // pub fn OpenThreadToken(); // pub fn OpenThreadWaitChainSession(); // pub fn OpenTraceA(); // pub fn OpenTraceW(); // pub fn OperationEnd(); // pub fn OperationStart(); // pub fn PerfAddCounters(); // pub fn PerfCloseQueryHandle(); // pub fn PerfCreateInstance(); // pub fn PerfDecrementULongCounterValue(); // pub fn PerfDecrementULongLongCounterValue(); // pub fn PerfDeleteCounters(); // pub fn PerfDeleteInstance(); // pub fn PerfEnumerateCounterSet(); // pub fn PerfEnumerateCounterSetInstances(); // pub fn PerfIncrementULongCounterValue(); // pub fn PerfIncrementULongLongCounterValue(); // pub fn PerfOpenQueryHandle(); // pub fn PerfQueryCounterData(); // pub fn PerfQueryCounterInfo(); // pub fn PerfQueryCounterSetRegistrationInfo(); // pub fn PerfQueryInstance(); // pub fn PerfRegCloseKey(); // pub fn PerfRegEnumKey(); // pub fn PerfRegEnumValue(); // pub fn PerfRegQueryInfoKey(); // pub fn PerfRegQueryValue(); // pub fn PerfRegSetValue(); // pub fn PerfSetCounterRefValue(); // pub fn PerfSetCounterSetInfo(); // pub fn PerfSetULongCounterValue(); // pub fn PerfSetULongLongCounterValue(); // pub fn PerfStartProvider(); // pub fn PerfStartProviderEx(); // pub fn PerfStopProvider(); // pub fn PrivilegeCheck(); // pub fn PrivilegedServiceAuditAlarmA(); // pub fn PrivilegedServiceAuditAlarmW(); // pub fn ProcessTrace(); // pub fn QueryAllTracesA(); // pub fn QueryAllTracesW(); // pub fn QueryRecoveryAgentsOnEncryptedFile(); // pub fn QuerySecurityAccessMask(); // pub fn QueryServiceConfig2A(); // pub fn QueryServiceConfig2W(); // pub fn QueryServiceConfigA(); // pub fn QueryServiceConfigW(); // pub fn QueryServiceDynamicInformation(); // pub fn QueryServiceLockStatusA(); // pub fn QueryServiceLockStatusW(); // pub fn QueryServiceObjectSecurity(); pub fn QueryServiceStatus(hService: SC_HANDLE, lpServiceStatus: LPSERVICE_STATUS) -> BOOL; pub fn QueryServiceStatusEx( hService: SC_HANDLE, InfoLevel: SC_STATUS_TYPE, lpBuffer: LPBYTE, cbBufSize: DWORD, pcbBytesNeeded: LPDWORD, ) -> BOOL; // pub fn QueryTraceA(); // pub fn QueryTraceW(); // pub fn QueryUsersOnEncryptedFile(); // pub fn ReadEncryptedFileRaw(); // pub fn ReadEventLogA(); // pub fn ReadEventLogW(); pub fn RegCloseKey(hKey: HKEY) -> LONG; pub fn RegConnectRegistryA(lpMachineName: LPCSTR, hKey: HKEY, phkResult: PHKEY) -> LONG; // pub fn RegConnectRegistryExA(); // pub fn RegConnectRegistryExW(); pub fn RegConnectRegistryW(lpMachineName: LPCWSTR, hKey: HKEY, phkResult: PHKEY) -> LONG; pub fn RegCopyTreeA(hKeySrc: HKEY, lpSubKey: LPCSTR, hKeyDest: HKEY) -> LONG; pub fn RegCopyTreeW(hKeySrc: HKEY, lpSubKey: LPCWSTR, hKeyDest: HKEY) -> LONG; // pub fn RegCreateKeyA(); pub fn RegCreateKeyExA( hKey: HKEY, lpSubKey: LPCSTR, Reserved: DWORD, lpClass: LPSTR, dwOptions: DWORD, samDesired: REGSAM, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, phkResult: PHKEY, lpdwDisposition: LPDWORD, ) -> LONG; pub fn RegCreateKeyExW( hKey: HKEY, lpSubKey: LPCWSTR, Reserved: DWORD, lpClass: LPWSTR, dwOptions: DWORD, samDesired: REGSAM, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, phkResult: PHKEY, lpdwDisposition: LPDWORD, ) -> LONG; pub fn RegCreateKeyTransactedA( hKey: HKEY, lpSubKey: LPCSTR, Reserved: DWORD, lpClass: LPSTR, dwOptions: DWORD, samDesired: REGSAM, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, phkResult: PHKEY, lpdwDisposition: LPDWORD, hTransaction: HANDLE, pExtendedParemeter: PVOID, ) -> LONG; pub fn RegCreateKeyTransactedW( hKey: HKEY, lpSubKey: LPCWSTR, Reserved: DWORD, lpClass: LPWSTR, dwOptions: DWORD, samDesired: REGSAM, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, phkResult: PHKEY, lpdwDisposition: LPDWORD, hTransaction: HANDLE, pExtendedParemeter: PVOID, ) -> LONG; // pub fn RegCreateKeyW(); pub fn RegDeleteKeyA(hKey: HKEY, lpSubKey: LPCSTR) -> LONG; pub fn RegDeleteKeyExA( hKey: HKEY, lpSubKey: LPCSTR, samDesired: REGSAM, Reserved: DWORD, ) -> LONG; pub fn RegDeleteKeyExW( hKey: HKEY, lpSubKey: LPCWSTR, samDesired: REGSAM, Reserved: DWORD, ) -> LONG; pub fn RegDeleteKeyTransactedA( hKey: HKEY, lpSubKey: LPCSTR, samDesired: REGSAM, Reserved: DWORD, hTransaction: HANDLE, pExtendedParemeter: PVOID, ) -> LONG; pub fn RegDeleteKeyTransactedW( hKey: HKEY, lpSubKey: LPCWSTR, samDesired: REGSAM, Reserved: DWORD, hTransaction: HANDLE, pExtendedParemeter: PVOID, ) -> LONG; pub fn RegDeleteKeyValueA(hKey: HKEY, lpSubKey: LPCSTR, lpValueName: LPCSTR) -> LONG; pub fn RegDeleteKeyValueW(hKey: HKEY, lpSubKey: LPCWSTR, lpValueName: LPCWSTR) -> LONG; pub fn RegDeleteKeyW(hKey: HKEY, lpSubKey: LPCWSTR) -> LONG; pub fn RegDeleteTreeA(hKey: HKEY, lpSubKey: LPCSTR) -> LONG; pub fn RegDeleteTreeW(hKey: HKEY, lpSubKey: LPCWSTR) -> LONG; pub fn RegDeleteValueA(hKey: HKEY, lpValueName: LPCSTR) -> LONG; pub fn RegDeleteValueW(hKey: HKEY, lpValueName: LPCWSTR) -> LONG; pub fn RegDisablePredefinedCache() -> LONG; pub fn RegDisablePredefinedCacheEx() -> LONG; pub fn RegDisableReflectionKey(hBase: HKEY) -> LONG; pub fn RegEnableReflectionKey(hBase: HKEY) -> LONG; // pub fn RegEnumKeyA(); pub fn RegEnumKeyExA( hKey: HKEY, dwIndex: DWORD, lpName: LPSTR, lpcName: LPDWORD, lpReserved: LPDWORD, lpClass: LPSTR, lpcClass: LPDWORD, lpftLastWriteTime: PFILETIME, ) -> LONG; pub fn RegEnumKeyExW( hKey: HKEY, dwIndex: DWORD, lpName: LPWSTR, lpcName: LPDWORD, lpReserved: LPDWORD, lpClass: LPWSTR, lpcClass: LPDWORD, lpftLastWriteTime: PFILETIME, ) -> LONG; // pub fn RegEnumKeyW(); pub fn RegEnumValueA( hKey: HKEY, dwIndex: DWORD, lpValueName: LPSTR, lpcchValueName: LPDWORD, lpReserved: LPDWORD, lpType: LPDWORD, lpData: LPBYTE, lpcbData: LPDWORD, ) -> LONG; pub fn RegEnumValueW( hKey: HKEY, dwIndex: DWORD, lpValueName: LPWSTR, lpcchValueName: LPDWORD, lpReserved: LPDWORD, lpType: LPDWORD, lpData: LPBYTE, lpcbData: LPDWORD, ) -> LONG; pub fn RegFlushKey(hKey: HKEY) -> LONG; // pub fn RegGetKeySecurity(); pub fn RegGetValueA( hkey: HKEY, lpSubKey: LPCSTR, lpValue: LPCSTR, dwFlags: DWORD, pdwType: LPDWORD, pvData: PVOID, pcbData: LPDWORD, ) -> LONG; pub fn RegGetValueW( hkey: HKEY, lpSubKey: LPCWSTR, lpValue: LPCWSTR, dwFlags: DWORD, pdwType: LPDWORD, pvData: PVOID, pcbData: LPDWORD, ) -> LONG; // pub fn RegLoadAppKeyA(); // pub fn RegLoadAppKeyW(); // pub fn RegLoadKeyA(); // pub fn RegLoadKeyW(); // pub fn RegLoadMUIStringA(); pub fn RegLoadMUIStringW( hKey: HKEY, pszValue: LPCWSTR, pszOutBuf: LPWSTR, cbOutBuf: DWORD, pcbData: LPDWORD, Flags: DWORD, pszDirectory: LPCWSTR, ) -> LONG; pub fn RegNotifyChangeKeyValue( hKey: HKEY, bWatchSubtree: BOOL, dwNotifyFilter: DWORD, hEvent: HANDLE, fAsynchronous: BOOL, ) -> LONG; pub fn RegOpenCurrentUser(samDesired: REGSAM, phkResult: PHKEY) -> LONG; // pub fn RegOpenKeyA(); pub fn RegOpenKeyExA( hKey: HKEY, lpSubKey: LPCSTR, ulOptions: DWORD, samDesired: REGSAM, phkResult: PHKEY, ) -> LONG; pub fn RegOpenKeyExW( hKey: HKEY, lpSubKey: LPCWSTR, ulOptions: DWORD, samDesired: REGSAM, phkResult: PHKEY, ) -> LONG; pub fn RegOpenKeyTransactedA( hKey: HKEY, lpSubKey: LPCSTR, ulOptions: DWORD, samDesired: REGSAM, phkResult: PHKEY, hTransaction: HANDLE, pExtendedParemeter: PVOID, ) -> LONG; pub fn RegOpenKeyTransactedW( hKey: HKEY, lpSubKey: LPCWSTR, ulOptions: DWORD, samDesired: REGSAM, phkResult: PHKEY, hTransaction: HANDLE, pExtendedParemeter: PVOID, ) -> LONG; // pub fn RegOpenKeyW(); pub fn RegOpenUserClassesRoot( hToken: HANDLE, dwOptions: DWORD, samDesired: REGSAM, phkResult: PHKEY, ) -> LONG; pub fn RegOverridePredefKey(hKey: HKEY, hNewHKey: HKEY) -> LONG; pub fn RegQueryInfoKeyA( hKey: HKEY, lpClass: LPSTR, lpcClass: LPDWORD, lpReserved: LPDWORD, lpcSubKeys: LPDWORD, lpcMaxSubKeyLen: LPDWORD, lpcMaxClassLen: LPDWORD, lpcValues: LPDWORD, lpcMaxValueNameLen: LPDWORD, lpcMaxValueLen: LPDWORD, lpcbSecurityDescriptor: LPDWORD, lpftLastWriteTime: PFILETIME, ) -> LONG; pub fn RegQueryInfoKeyW( hKey: HKEY, lpClass: LPWSTR, lpcClass: LPDWORD, lpReserved: LPDWORD, lpcSubKeys: LPDWORD, lpcMaxSubKeyLen: LPDWORD, lpcMaxClassLen: LPDWORD, lpcValues: LPDWORD, lpcMaxValueNameLen: LPDWORD, lpcMaxValueLen: LPDWORD, lpcbSecurityDescriptor: LPDWORD, lpftLastWriteTime: PFILETIME, ) -> LONG; pub fn RegQueryMultipleValuesA( hKey: HKEY, val_list: PVALENTA, num_vals: DWORD, lpValueBuf: LPSTR, ldwTotsize: LPDWORD, ) -> LONG; pub fn RegQueryMultipleValuesW( hKey: HKEY, val_list: PVALENTW, num_vals: DWORD, lpValueBuf: LPWSTR, ldwTotsize: LPDWORD, ) -> LONG; pub fn RegQueryReflectionKey(hBase: HKEY, bIsReflectionDisabled: PBOOL) -> LONG; pub fn RegQueryValueExA( hKey: HKEY, lpValueName: LPCSTR, lpReserved: LPDWORD, lpType: LPDWORD, lpData: LPBYTE, lpcbData: LPDWORD, ) -> LONG; pub fn RegQueryValueExW( hKey: HKEY, lpValueName: LPCWSTR, lpReserved: LPDWORD, lpType: LPDWORD, lpData: LPBYTE, lpcbData: LPDWORD, ) -> LONG; // pub fn RegQueryValueW(); // pub fn RegRenameKey(); // pub fn RegReplaceKeyA(); // pub fn RegReplaceKeyW(); // pub fn RegRestoreKeyA(); // pub fn RegRestoreKeyW(); // pub fn RegSaveKeyA(); // pub fn RegSaveKeyExA(); // pub fn RegSaveKeyExW(); // pub fn RegSaveKeyW(); // pub fn RegSetKeySecurity(); pub fn RegSetKeyValueA( hKey: HKEY, lpSubKey: LPCSTR, lpValueName: LPCSTR, dwType: DWORD, lpData: LPCVOID, cbData: DWORD, ) -> LONG; pub fn RegSetValueExA( hKey: HKEY, lpValueName: LPCSTR, Reserved: DWORD, dwType: DWORD, lpData: *const BYTE, cbData: DWORD, ) -> LONG; pub fn RegSetValueExW( hKey: HKEY, lpValueName: LPCWSTR, Reserved: DWORD, dwType: DWORD, lpData: *const BYTE, cbData: DWORD, ) -> LONG; pub fn RegSetKeyValueW( hKey: HKEY, lpSubKey: LPCWSTR, lpValueName: LPCWSTR, dwType: DWORD, lpData: LPCVOID, cbData: DWORD, ) -> LONG; // pub fn RegUnLoadKeyA(); // pub fn RegUnLoadKeyW(); // pub fn RegisterEventSourceA(); // pub fn RegisterEventSourceW(); pub fn RegisterServiceCtrlHandlerA( lpServiceName: LPCSTR, lpHandlerProc: LPHANDLER_FUNCTION, ) -> SERVICE_STATUS_HANDLE; pub fn RegisterServiceCtrlHandlerExA( lpServiceName: LPCSTR, lpHandlerProc: LPHANDLER_FUNCTION_EX, lpContext: LPVOID, ) -> SERVICE_STATUS_HANDLE; pub fn RegisterServiceCtrlHandlerExW( lpServiceName: LPCWSTR, lpHandlerProc: LPHANDLER_FUNCTION_EX, lpContext: LPVOID, ) -> SERVICE_STATUS_HANDLE; pub fn RegisterServiceCtrlHandlerW( lpServiceName: LPCWSTR, lpHandlerProc: LPHANDLER_FUNCTION, ) -> SERVICE_STATUS_HANDLE; // pub fn RegisterTraceGuidsA(); // pub fn RegisterTraceGuidsW(); // pub fn RegisterWaitChainCOMCallback(); // pub fn RemoteRegEnumKeyWrapper(); // pub fn RemoteRegEnumValueWrapper(); // pub fn RemoteRegQueryInfoKeyWrapper(); // pub fn RemoteRegQueryValueWrapper(); // pub fn RemoveTraceCallback(); // pub fn RemoveUsersFromEncryptedFile(); // pub fn ReportEventA(); // pub fn ReportEventW(); // pub fn RevertToSelf(); // pub fn SafeBaseRegGetKeySecurity(); // pub fn SaferCloseLevel(); // pub fn SaferComputeTokenFromLevel(); // pub fn SaferCreateLevel(); // pub fn SaferGetLevelInformation(); // pub fn SaferGetPolicyInformation(); // pub fn SaferIdentifyLevel(); // pub fn SaferRecordEventLogEntry(); // pub fn SaferSetLevelInformation(); // pub fn SaferSetPolicyInformation(); // pub fn SaferiIsExecutableFileType(); // pub fn SetAclInformation(); // pub fn SetEncryptedFileMetadata(); // pub fn SetEntriesInAccessListA(); // pub fn SetEntriesInAccessListW(); // pub fn SetEntriesInAclA(); // pub fn SetEntriesInAclW(); // pub fn SetEntriesInAuditListA(); // pub fn SetEntriesInAuditListW(); // pub fn SetFileSecurityA(); // pub fn SetFileSecurityW(); // pub fn SetInformationCodeAuthzLevelW(); // pub fn SetInformationCodeAuthzPolicyW(); // pub fn SetKernelObjectSecurity(); // pub fn SetNamedSecurityInfoA(); // pub fn SetNamedSecurityInfoExA(); // pub fn SetNamedSecurityInfoExW(); // pub fn SetNamedSecurityInfoW(); // pub fn SetPrivateObjectSecurity(); // pub fn SetPrivateObjectSecurityEx(); // pub fn SetSecurityAccessMask(); // pub fn SetSecurityDescriptorControl(); // pub fn SetSecurityDescriptorDacl(); // pub fn SetSecurityDescriptorGroup(); // pub fn SetSecurityDescriptorOwner(); // pub fn SetSecurityDescriptorRMControl(); // pub fn SetSecurityDescriptorSacl(); // pub fn SetSecurityInfo(); // pub fn SetSecurityInfoExA(); // pub fn SetSecurityInfoExW(); // pub fn SetServiceBits(); // pub fn SetServiceObjectSecurity(); pub fn SetServiceStatus( hServiceStatus: SERVICE_STATUS_HANDLE, lpServiceStatus: LPSERVICE_STATUS, ) -> BOOL; // pub fn SetThreadToken(); // pub fn SetTokenInformation(); // pub fn SetTraceCallback(); // pub fn SetUserFileEncryptionKey(); // pub fn SetUserFileEncryptionKeyEx(); // pub fn StartServiceA(); pub fn StartServiceCtrlDispatcherA(lpServiceStartTable: *const SERVICE_TABLE_ENTRYA) -> BOOL; pub fn StartServiceCtrlDispatcherW(lpServiceStartTable: *const SERVICE_TABLE_ENTRYW) -> BOOL; // pub fn StartServiceW(); // pub fn StartTraceA(); // pub fn StartTraceW(); // pub fn StopTraceA(); // pub fn StopTraceW(); // pub fn SystemFunction001(); // pub fn SystemFunction002(); // pub fn SystemFunction003(); // pub fn SystemFunction004(); // pub fn SystemFunction005(); // pub fn SystemFunction006(); // pub fn SystemFunction007(); // pub fn SystemFunction008(); // pub fn SystemFunction009(); // pub fn SystemFunction010(); // pub fn SystemFunction011(); // pub fn SystemFunction012(); // pub fn SystemFunction013(); // pub fn SystemFunction014(); // pub fn SystemFunction015(); // pub fn SystemFunction016(); // pub fn SystemFunction017(); // pub fn SystemFunction018(); // pub fn SystemFunction019(); // pub fn SystemFunction020(); // pub fn SystemFunction021(); // pub fn SystemFunction022(); // pub fn SystemFunction023(); // pub fn SystemFunction024(); // pub fn SystemFunction025(); // pub fn SystemFunction026(); // pub fn SystemFunction027(); // pub fn SystemFunction028(); // pub fn SystemFunction029(); // pub fn SystemFunction030(); // pub fn SystemFunction031(); // pub fn SystemFunction032(); // pub fn SystemFunction033(); // pub fn SystemFunction034(); // pub fn SystemFunction036(); // pub fn SystemFunction040(); // pub fn SystemFunction041(); // pub fn TraceEvent(); // pub fn TraceEventInstance(); // pub fn TraceMessage(); // pub fn TraceMessageVa(); // pub fn TraceQueryInformation(); // pub fn TraceSetInformation(); // pub fn TreeResetNamedSecurityInfoA(); // pub fn TreeResetNamedSecurityInfoW(); // pub fn TreeSetNamedSecurityInfoA(); // pub fn TreeSetNamedSecurityInfoW(); // pub fn TrusteeAccessToObjectA(); // pub fn TrusteeAccessToObjectW(); // pub fn UninstallApplication(); // pub fn UnlockServiceDatabase(); // pub fn UnregisterTraceGuids(); // pub fn UpdateTraceA(); // pub fn UpdateTraceW(); // pub fn UsePinForEncryptedFilesA(); // pub fn UsePinForEncryptedFilesW(); // pub fn WaitServiceState(); // pub fn WriteEncryptedFileRaw(); } deps/advapi32-sys-0.1.2/Cargo.toml0000644000000000000000000000102112553265505015322 0ustar rootroot[package] name = "advapi32-sys" version = "0.1.2" authors = ["Peter Atashian "] description = "FFI bindings to advapi32." documentation = "https://retep998.github.io/doc/advapi32/" repository = "https://github.com/retep998/winapi-rs" readme = "README.md" keywords = ["Windows", "FFI", "WinSDK"] license = "MIT" build = "build.rs" links = "advapi32" [lib] name = "advapi32" [dependencies] winapi = { version = "*", path = "../.." } [build-dependencies] winapi-build = { version = "*", path = "../../build" } deps/advapi32-sys-0.1.2/build.rs0000644000000000000000000000023112542643300015030 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License extern crate build; fn main() { build::link("advapi32", false) } deps/toml-0.1.25/0000755000000000000000000000000012666635520012216 5ustar rootrootdeps/toml-0.1.25/LICENSE-APACHE0000664000175000017500000002513712401655674012375 0ustar Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/toml-0.1.25/LICENSE-MIT0000664000175000017500000000204112556776055012102 0ustar Copyright (c) 2014 Alex Crichton Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/toml-0.1.25/examples/0000755000000000000000000000000012666635520014034 5ustar rootrootdeps/toml-0.1.25/examples/toml2json.rs0000664000175000017500000000314512563143626014555 0ustar #![deny(warnings)] extern crate toml; extern crate rustc_serialize; use std::fs::File; use std::env; use std::io; use std::io::prelude::*; use toml::Value; use rustc_serialize::json::Json; fn main() { let mut args = env::args(); let mut input = String::new(); let filename = if args.len() > 1 { let name = args.nth(1).unwrap(); File::open(&name).and_then(|mut f| { f.read_to_string(&mut input) }).unwrap(); name } else { io::stdin().read_to_string(&mut input).unwrap(); "".to_string() }; let mut parser = toml::Parser::new(&input); let toml = match parser.parse() { Some(toml) => toml, None => { for err in &parser.errors { let (loline, locol) = parser.to_linecol(err.lo); let (hiline, hicol) = parser.to_linecol(err.hi); println!("{}:{}:{}-{}:{} error: {}", filename, loline, locol, hiline, hicol, err.desc); } return } }; let json = convert(Value::Table(toml)); println!("{}", json.pretty()); } fn convert(toml: Value) -> Json { match toml { Value::String(s) => Json::String(s), Value::Integer(i) => Json::I64(i), Value::Float(f) => Json::F64(f), Value::Boolean(b) => Json::Boolean(b), Value::Array(arr) => Json::Array(arr.into_iter().map(convert).collect()), Value::Table(table) => Json::Object(table.into_iter().map(|(k, v)| { (k, convert(v)) }).collect()), Value::Datetime(dt) => Json::String(dt), } } deps/toml-0.1.25/.travis.yml0000664000175000017500000000172712634052673012557 0ustar language: rust rust: - 1.0.0 - stable - beta - nightly sudo: false before_script: - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH script: - cargo build --verbose - cargo build --verbose --no-default-features - cargo build --verbose --features serde --no-default-features - cargo test --verbose --features serde - if [ "$TRAVIS_RUST_VERSION" != "1.0.0" ]; then cargo test --verbose --manifest-path serde-tests/Cargo.toml; fi - rustdoc --test README.md -L target - cargo doc --no-deps after_success: - travis-cargo --only nightly doc-upload - travis-cargo coveralls --no-sudo env: global: secure: LZMkQQJT5LqLQQ8JyakjvHNqqMPy8lm/SyC+H5cKUVI/xk7xRuti4eKY937N8uSmbff2m9ZYlG6cNwIOfk/nWn8YsqxA8Wg/xugubWzqGuqu+NQ4IZVa7INT2Fiqyk5SPCh8B5fo2x7OBJ24SCkWb2p8bEWAuW8XdZZOdmi3H2I= notifications: email: on_success: never addons: apt: packages: - libcurl4-openssl-dev - libelf-dev - libdw-dev deps/toml-0.1.25/README.md0000664000175000017500000000160612563143626011721 0ustar # toml-rs [![Build Status](https://travis-ci.org/alexcrichton/toml-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/toml-rs) [![Coverage Status](https://coveralls.io/repos/alexcrichton/toml-rs/badge.svg?branch=master&service=github)](https://coveralls.io/github/alexcrichton/toml-rs?branch=master) [Documentation](http://alexcrichton.com/toml-rs) A [TOML][toml] decoder and encoder for Rust. This library is currently compliant with the v0.4.0 version of TOML. This library will also likely continue to stay up to date with the TOML specification as changes happen. [toml]: https://github.com/toml-lang/toml ```toml # Cargo.toml [dependencies] toml = "0.1" ``` # License `toml-rs` is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses. See LICENSE-APACHE, and LICENSE-MIT for details. deps/toml-0.1.25/.gitignore0000664000175000017500000000002212563145253012417 0ustar target Cargo.lock deps/toml-0.1.25/src/0000755000000000000000000000000012666635520013005 5ustar rootrootdeps/toml-0.1.25/src/decoder/0000755000000000000000000000000012666635520014412 5ustar rootrootdeps/toml-0.1.25/src/decoder/rustc_serialize.rs0000664000175000017500000003037112635122262016405 0ustar use rustc_serialize; use std::mem; use std::collections::BTreeMap; use super::{Decoder, DecodeError}; use super::DecodeErrorKind::*; use Value; impl rustc_serialize::Decoder for Decoder { type Error = DecodeError; fn read_nil(&mut self) -> Result<(), DecodeError> { match self.toml { Some(Value::String(ref s)) if s.len() == 0 => {} Some(Value::String(..)) => return Err(self.err(NilTooLong)), ref found => return Err(self.mismatch("string", found)), } self.toml.take(); Ok(()) } fn read_usize(&mut self) -> Result { self.read_i64().map(|i| i as usize) } fn read_u64(&mut self) -> Result { self.read_i64().map(|i| i as u64) } fn read_u32(&mut self) -> Result { self.read_i64().map(|i| i as u32) } fn read_u16(&mut self) -> Result { self.read_i64().map(|i| i as u16) } fn read_u8(&mut self) -> Result { self.read_i64().map(|i| i as u8) } fn read_isize(&mut self) -> Result { self.read_i64().map(|i| i as isize) } fn read_i64(&mut self) -> Result { match self.toml { Some(Value::Integer(i)) => { self.toml.take(); Ok(i) } ref found => Err(self.mismatch("integer", found)), } } fn read_i32(&mut self) -> Result { self.read_i64().map(|i| i as i32) } fn read_i16(&mut self) -> Result { self.read_i64().map(|i| i as i16) } fn read_i8(&mut self) -> Result { self.read_i64().map(|i| i as i8) } fn read_bool(&mut self) -> Result { match self.toml { Some(Value::Boolean(b)) => { self.toml.take(); Ok(b) } ref found => Err(self.mismatch("bool", found)), } } fn read_f64(&mut self) -> Result { match self.toml { Some(Value::Float(f)) => { self.toml.take(); Ok(f) }, ref found => Err(self.mismatch("float", found)), } } fn read_f32(&mut self) -> Result { self.read_f64().map(|f| f as f32) } fn read_char(&mut self) -> Result { let ch = match self.toml { Some(Value::String(ref s)) if s.chars().count() == 1 => s.chars().next().unwrap(), ref found => return Err(self.mismatch("string", found)), }; self.toml.take(); Ok(ch) } fn read_str(&mut self) -> Result { match self.toml.take() { Some(Value::String(s)) => Ok(s), found => { let err = Err(self.mismatch("string", &found)); self.toml = found; err } } } // Compound types: fn read_enum(&mut self, _name: &str, f: F) -> Result where F: FnOnce(&mut Decoder) -> Result { f(self) } fn read_enum_variant(&mut self, names: &[&str], mut f: F) -> Result where F: FnMut(&mut Decoder, usize) -> Result { // When decoding enums, this crate takes the strategy of trying to // decode the current TOML as all of the possible variants, returning // success on the first one that succeeds. // // Note that fidelity of the errors returned here is a little nebulous, // but we try to return the error that had the relevant field as the // longest field. This way we hopefully match an error against what was // most likely being written down without losing too much info. let mut first_error = None::; for i in 0..names.len() { let mut d = self.sub_decoder(self.toml.clone(), ""); match f(&mut d, i) { Ok(t) => { self.toml = d.toml; return Ok(t) } Err(e) => { if let Some(ref first) = first_error { let my_len = e.field.as_ref().map(|s| s.len()); let first_len = first.field.as_ref().map(|s| s.len()); if my_len <= first_len { continue } } first_error = Some(e); } } } Err(first_error.unwrap_or_else(|| self.err(NoEnumVariants))) } fn read_enum_variant_arg(&mut self, _a_idx: usize, f: F) -> Result where F: FnOnce(&mut Decoder) -> Result { f(self) } fn read_enum_struct_variant(&mut self, _names: &[&str], _f: F) -> Result where F: FnMut(&mut Decoder, usize) -> Result { panic!() } fn read_enum_struct_variant_field(&mut self, _f_name: &str, _f_idx: usize, _f: F) -> Result where F: FnOnce(&mut Decoder) -> Result { panic!() } fn read_struct(&mut self, _s_name: &str, _len: usize, f: F) -> Result where F: FnOnce(&mut Decoder) -> Result { match self.toml { Some(Value::Table(..)) => { let ret = try!(f(self)); match self.toml { Some(Value::Table(ref t)) if t.len() == 0 => {} _ => return Ok(ret) } self.toml.take(); Ok(ret) } ref found => Err(self.mismatch("table", found)), } } fn read_struct_field(&mut self, f_name: &str, _f_idx: usize, f: F) -> Result where F: FnOnce(&mut Decoder) -> Result { let field = format!("{}", f_name); let toml = match self.toml { Some(Value::Table(ref mut table)) => { table.remove(&field) .or_else(|| table.remove(&f_name.replace("_", "-"))) }, ref found => return Err(self.mismatch("table", found)), }; let mut d = self.sub_decoder(toml, f_name); let ret = try!(f(&mut d)); if let Some(value) = d.toml { if let Some(Value::Table(ref mut table)) = self.toml { table.insert(field, value); } } Ok(ret) } fn read_tuple(&mut self, tuple_len: usize, f: F) -> Result where F: FnOnce(&mut Decoder) -> Result { self.read_seq(move |d, len| { assert!(len == tuple_len, "expected tuple of length `{}`, found tuple \ of length `{}`", tuple_len, len); f(d) }) } fn read_tuple_arg(&mut self, a_idx: usize, f: F) -> Result where F: FnOnce(&mut Decoder) -> Result { self.read_seq_elt(a_idx, f) } fn read_tuple_struct(&mut self, _s_name: &str, _len: usize, _f: F) -> Result where F: FnOnce(&mut Decoder) -> Result { panic!() } fn read_tuple_struct_arg(&mut self, _a_idx: usize, _f: F) -> Result where F: FnOnce(&mut Decoder) -> Result { panic!() } // Specialized types: fn read_option(&mut self, mut f: F) -> Result where F: FnMut(&mut Decoder, bool) -> Result { match self.toml { Some(..) => f(self, true), None => f(self, false), } } fn read_seq(&mut self, f: F) -> Result where F: FnOnce(&mut Decoder, usize) -> Result { let len = match self.toml { Some(Value::Array(ref arr)) => arr.len(), None => 0, ref found => return Err(self.mismatch("array", found)), }; let ret = try!(f(self, len)); match self.toml { Some(Value::Array(ref mut arr)) => { arr.retain(|slot| slot.as_integer() != Some(0)); if arr.len() != 0 { return Ok(ret) } } _ => return Ok(ret) } self.toml.take(); Ok(ret) } fn read_seq_elt(&mut self, idx: usize, f: F) -> Result where F: FnOnce(&mut Decoder) -> Result { let toml = match self.toml { Some(Value::Array(ref mut arr)) => { mem::replace(&mut arr[idx], Value::Integer(0)) } ref found => return Err(self.mismatch("array", found)), }; let mut d = self.sub_decoder(Some(toml), ""); let ret = try!(f(&mut d)); match d.toml { Some(toml) => match self.toml { Some(Value::Array(ref mut arr)) => arr[idx] = toml, _ => {} }, _ => {} } Ok(ret) } fn read_map(&mut self, f: F) -> Result where F: FnOnce(&mut Decoder, usize) -> Result { let map = match self.toml.take() { Some(Value::Table(table)) => table, found => { self.toml = found; return Err(self.mismatch("table", &self.toml)) } }; let amt = map.len(); let prev_iter = mem::replace(&mut self.cur_map, map.into_iter().peekable()); let prev_map = mem::replace(&mut self.leftover_map, BTreeMap::new()); let ret = try!(f(self, amt)); let leftover = mem::replace(&mut self.leftover_map, prev_map); self.cur_map = prev_iter; if leftover.len() > 0 { self.toml = Some(Value::Table(leftover)); } Ok(ret) } fn read_map_elt_key(&mut self, idx: usize, f: F) -> Result where F: FnOnce(&mut Decoder) -> Result { let key = match self.cur_map.peek().map(|p| p.0.clone()) { Some(k) => k, None => return Err(self.err(ExpectedMapKey(idx))), }; let val = Value::String(key.clone()); f(&mut self.sub_decoder(Some(val), &key)) } fn read_map_elt_val(&mut self, idx: usize, f: F) -> Result where F: FnOnce(&mut Decoder) -> Result { match self.cur_map.next() { Some((key, value)) => { let mut d = self.sub_decoder(Some(value), &key); let ret = f(&mut d); if let Some(toml) = d.toml.take() { self.leftover_map.insert(key, toml); } return ret } None => return Err(self.err(ExpectedMapElement(idx))), } } fn error(&mut self, err: &str) -> DecodeError { DecodeError { field: self.cur_field.clone(), kind: ApplicationError(format!("{}", err)) } } } #[cfg(test)] mod tests { use rustc_serialize::Decodable; use std::collections::HashMap; use {Parser, Decoder, Value}; #[test] fn bad_enum_chooses_longest_error() { #[derive(RustcDecodable)] #[allow(dead_code)] struct Foo { wut: HashMap, } #[derive(RustcDecodable)] enum Bar { Simple(String), Detailed(Baz), } #[derive(RustcDecodable, Debug)] struct Baz { features: Vec, } let s = r#" [wut] a = { features = "" } "#; let v = Parser::new(s).parse().unwrap(); let mut d = Decoder::new(Value::Table(v)); let err = match Foo::decode(&mut d) { Ok(_) => panic!("expected error"), Err(e) => e, }; assert_eq!(err.field.as_ref().unwrap(), "wut.a.features"); } } deps/toml-0.1.25/src/decoder/mod.rs0000664000175000017500000001751112635121536013761 0ustar use std::error; use std::fmt; use std::collections::{btree_map, BTreeMap}; use std::iter::Peekable; use Value; use self::DecodeErrorKind::*; #[cfg(feature = "rustc-serialize")] mod rustc_serialize; #[cfg(feature = "serde")] mod serde; /// A structure to transform TOML values into Rust values. /// /// This decoder implements the serialization `Decoder` interface, allowing /// `Decodable` types to be generated by this decoder. The input is any /// arbitrary TOML value. pub struct Decoder { /// The TOML value left over after decoding. This can be used to inspect /// whether fields were decoded or not. pub toml: Option, cur_field: Option, cur_map: Peekable>, leftover_map: ::Table, } /// Description for errors which can occur while decoding a type. #[derive(PartialEq, Debug)] pub struct DecodeError { /// Field that this error applies to. pub field: Option, /// The type of error which occurred while decoding, pub kind: DecodeErrorKind, } /// Enumeration of possible errors which can occur while decoding a structure. #[derive(PartialEq, Debug)] pub enum DecodeErrorKind { /// An error flagged by the application, e.g. value out of range ApplicationError(String), /// A field was expected, but none was found. ExpectedField(/* type */ Option<&'static str>), /// A field was found, but it was not an expected one. UnknownField, /// A field was found, but it had the wrong type. ExpectedType(/* expected */ &'static str, /* found */ &'static str), /// The nth map key was expected, but none was found. ExpectedMapKey(usize), /// The nth map element was expected, but none was found. ExpectedMapElement(usize), /// An enum decoding was requested, but no variants were supplied NoEnumVariants, /// The unit type was being decoded, but a non-zero length string was found NilTooLong, /// There was an error with the syntactical structure of the TOML. SyntaxError, /// The end of the TOML input was reached too soon EndOfStream, } /// Decodes a TOML value into a decodable type. /// /// This function will consume the given TOML value and attempt to decode it /// into the type specified. If decoding fails, `None` will be returned. If a /// finer-grained error is desired, then it is recommended to use `Decodable` /// directly. #[cfg(feature = "rustc-serialize")] pub fn decode(toml: Value) -> Option { ::rustc_serialize::Decodable::decode(&mut Decoder::new(toml)).ok() } /// Decodes a TOML value into a decodable type. /// /// This function will consume the given TOML value and attempt to decode it /// into the type specified. If decoding fails, `None` will be returned. If a /// finer-grained error is desired, then it is recommended to use `Decodable` /// directly. #[cfg(all(not(feature = "rustc-serialize"), feature = "serde"))] pub fn decode(toml: Value) -> Option { ::serde::Deserialize::deserialize(&mut Decoder::new(toml)).ok() } /// Decodes a string into a toml-encoded value. /// /// This function will parse the given string into a TOML value, and then parse /// the TOML value into the desired type. If any error occurs `None` is return. /// /// If more fine-grained errors are desired, these steps should be driven /// manually. #[cfg(feature = "rustc-serialize")] pub fn decode_str(s: &str) -> Option { ::Parser::new(s).parse().and_then(|t| decode(Value::Table(t))) } /// Decodes a string into a toml-encoded value. /// /// This function will parse the given string into a TOML value, and then parse /// the TOML value into the desired type. If any error occurs `None` is return. /// /// If more fine-grained errors are desired, these steps should be driven /// manually. #[cfg(all(not(feature = "rustc-serialize"), feature = "serde"))] pub fn decode_str(s: &str) -> Option { ::Parser::new(s).parse().and_then(|t| decode(Value::Table(t))) } impl Decoder { /// Creates a new decoder, consuming the TOML value to decode. /// /// This decoder can be passed to the `Decodable` methods or driven /// manually. pub fn new(toml: Value) -> Decoder { Decoder { toml: Some(toml), cur_field: None, leftover_map: BTreeMap::new(), cur_map: BTreeMap::new().into_iter().peekable(), } } fn sub_decoder(&self, toml: Option, field: &str) -> Decoder { Decoder { toml: toml, cur_field: if field.len() == 0 { self.cur_field.clone() } else { match self.cur_field { None => Some(format!("{}", field)), Some(ref s) => Some(format!("{}.{}", s, field)) } }, leftover_map: BTreeMap::new(), cur_map: BTreeMap::new().into_iter().peekable(), } } fn err(&self, kind: DecodeErrorKind) -> DecodeError { DecodeError { field: self.cur_field.clone(), kind: kind, } } fn mismatch(&self, expected: &'static str, found: &Option) -> DecodeError{ match *found { Some(ref val) => self.err(ExpectedType(expected, val.type_str())), None => self.err(ExpectedField(Some(expected))), } } } impl fmt::Display for DecodeError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { try!(match self.kind { ApplicationError(ref err) => { write!(f, "{}", err) } ExpectedField(expected_type) => { match expected_type { Some("table") => write!(f, "expected a section"), Some(e) => write!(f, "expected a value of type `{}`", e), None => write!(f, "expected a value"), } } UnknownField => write!(f, "unknown field"), ExpectedType(expected, found) => { fn humanize(s: &str) -> String { if s == "section" { format!("a section") } else { format!("a value of type `{}`", s) } } write!(f, "expected {}, but found {}", humanize(expected), humanize(found)) } ExpectedMapKey(idx) => { write!(f, "expected at least {} keys", idx + 1) } ExpectedMapElement(idx) => { write!(f, "expected at least {} elements", idx + 1) } NoEnumVariants => { write!(f, "expected an enum variant to decode to") } NilTooLong => { write!(f, "expected 0-length string") } SyntaxError => { write!(f, "syntax error") } EndOfStream => { write!(f, "end of stream") } }); match self.field { Some(ref s) => { write!(f, " for the key `{}`", s) } None => Ok(()) } } } impl error::Error for DecodeError { fn description(&self) -> &str { match self.kind { ApplicationError(ref s) => &**s, ExpectedField(..) => "expected a field", UnknownField => "found an unknown field", ExpectedType(..) => "expected a type", ExpectedMapKey(..) => "expected a map key", ExpectedMapElement(..) => "expected a map element", NoEnumVariants => "no enum variants to decode to", NilTooLong => "nonzero length string representing nil", SyntaxError => "syntax error", EndOfStream => "end of stream", } } } deps/toml-0.1.25/src/decoder/serde.rs0000664000175000017500000003566112635117174014315 0ustar use serde::de; use Value; use super::{Decoder, DecodeError, DecodeErrorKind}; use std::collections::BTreeMap; fn se2toml(err: de::value::Error, ty: &'static str) -> DecodeError { match err { de::value::Error::SyntaxError => de::Error::syntax(ty), de::value::Error::EndOfStreamError => de::Error::end_of_stream(), de::value::Error::MissingFieldError(s) => { DecodeError { field: Some(s.to_string()), kind: DecodeErrorKind::ExpectedField(Some(ty)), } }, de::value::Error::UnknownFieldError(s) => { DecodeError { field: Some(s.to_string()), kind: DecodeErrorKind::UnknownField, } }, } } impl de::Deserializer for Decoder { type Error = DecodeError; fn visit(&mut self, mut visitor: V) -> Result where V: de::Visitor { match self.toml.take() { Some(Value::String(s)) => { visitor.visit_string(s).map_err(|e| se2toml(e, "string")) } Some(Value::Integer(i)) => { visitor.visit_i64(i).map_err(|e| se2toml(e, "integer")) } Some(Value::Float(f)) => { visitor.visit_f64(f).map_err(|e| se2toml(e, "float")) } Some(Value::Boolean(b)) => { visitor.visit_bool(b).map_err(|e| se2toml(e, "bool")) } Some(Value::Datetime(s)) => { visitor.visit_string(s).map_err(|e| se2toml(e, "date")) } Some(Value::Array(a)) => { let len = a.len(); let iter = a.into_iter(); visitor.visit_seq(SeqDeserializer::new(iter, len, &mut self.toml)) } Some(Value::Table(t)) => { visitor.visit_map(MapVisitor { iter: t.into_iter(), de: self, key: None, value: None, }) } None => Err(de::Error::end_of_stream()), } } fn visit_isize(&mut self, visitor: V) -> Result where V: de::Visitor { self.visit_i64(visitor) } fn visit_i8(&mut self, visitor: V) -> Result where V: de::Visitor { self.visit_i64(visitor) } fn visit_i16(&mut self, visitor: V) -> Result where V: de::Visitor { self.visit_i64(visitor) } fn visit_i32(&mut self, visitor: V) -> Result where V: de::Visitor { self.visit_i64(visitor) } fn visit_i64(&mut self, mut visitor: V) -> Result where V: de::Visitor { match self.toml.take() { Some(Value::Integer(f)) => { visitor.visit_i64(f).map_err(|e| se2toml(e, "integer")) } ref found => Err(self.mismatch("integer", found)), } } fn visit_usize(&mut self, visitor: V) -> Result where V: de::Visitor { self.visit_i64(visitor) } fn visit_u8(&mut self, visitor: V) -> Result where V: de::Visitor { self.visit_i64(visitor) } fn visit_u16(&mut self, visitor: V) -> Result where V: de::Visitor { self.visit_i64(visitor) } fn visit_u32(&mut self, visitor: V) -> Result where V: de::Visitor { self.visit_i64(visitor) } fn visit_u64(&mut self, visitor: V) -> Result where V: de::Visitor { self.visit_i64(visitor) } fn visit_f32(&mut self, visitor: V) -> Result where V: de::Visitor { self.visit_f64(visitor) } fn visit_f64(&mut self, mut visitor: V) -> Result where V: de::Visitor { match self.toml.take() { Some(Value::Float(f)) => { visitor.visit_f64(f).map_err(|e| se2toml(e, "float")) } ref found => Err(self.mismatch("float", found)), } } fn visit_option(&mut self, mut visitor: V) -> Result where V: de::Visitor { if self.toml.is_none() { visitor.visit_none() } else { visitor.visit_some(self) } } fn visit_seq(&mut self, mut visitor: V) -> Result where V: de::Visitor, { if self.toml.is_none() { let iter = None::.into_iter(); let e = visitor.visit_seq(de::value::SeqDeserializer::new(iter, 0)); e.map_err(|e| se2toml(e, "array")) } else { self.visit(visitor) } } fn visit_enum(&mut self, _enum: &str, variants: &[&str], mut visitor: V) -> Result where V: de::EnumVisitor, { // When decoding enums, this crate takes the strategy of trying to // decode the current TOML as all of the possible variants, returning // success on the first one that succeeds. // // Note that fidelity of the errors returned here is a little nebulous, // but we try to return the error that had the relevant field as the // longest field. This way we hopefully match an error against what was // most likely being written down without losing too much info. let mut first_error = None::; for variant in 0..variants.len() { let mut de = VariantVisitor { de: self.sub_decoder(self.toml.clone(), ""), variant: variant, }; match visitor.visit(&mut de) { Ok(value) => { self.toml = de.de.toml; return Ok(value); } Err(e) => { if let Some(ref first) = first_error { let my_len = e.field.as_ref().map(|s| s.len()); let first_len = first.field.as_ref().map(|s| s.len()); if my_len <= first_len { continue } } first_error = Some(e); } } } Err(first_error.unwrap_or_else(|| self.err(DecodeErrorKind::NoEnumVariants))) } } struct VariantVisitor { de: Decoder, variant: usize, } impl de::VariantVisitor for VariantVisitor { type Error = DecodeError; fn visit_variant(&mut self) -> Result where V: de::Deserialize { use serde::de::value::ValueDeserializer; let mut de = self.variant.into_deserializer(); de::Deserialize::deserialize(&mut de).map_err(|e| se2toml(e, "variant")) } fn visit_unit(&mut self) -> Result<(), DecodeError> { de::Deserialize::deserialize(&mut self.de) } fn visit_newtype(&mut self) -> Result where T: de::Deserialize, { de::Deserialize::deserialize(&mut self.de) } fn visit_tuple(&mut self, _len: usize, visitor: V) -> Result where V: de::Visitor, { de::Deserializer::visit(&mut self.de, visitor) } fn visit_struct(&mut self, _fields: &'static [&'static str], visitor: V) -> Result where V: de::Visitor, { de::Deserializer::visit(&mut self.de, visitor) } } struct SeqDeserializer<'a, I> { iter: I, len: usize, toml: &'a mut Option, } impl<'a, I> SeqDeserializer<'a, I> where I: Iterator { fn new(iter: I, len: usize, toml: &'a mut Option) -> Self { SeqDeserializer { iter: iter, len: len, toml: toml, } } fn put_value_back(&mut self, v: Value) { *self.toml = self.toml.take().or(Some(Value::Array(Vec::new()))); match self.toml.as_mut().unwrap() { &mut Value::Array(ref mut a) => { a.push(v); }, _ => unreachable!(), } } } impl<'a, I> de::Deserializer for SeqDeserializer<'a, I> where I: Iterator, { type Error = DecodeError; fn visit(&mut self, mut visitor: V) -> Result where V: de::Visitor, { visitor.visit_seq(self) } } impl<'a, I> de::SeqVisitor for SeqDeserializer<'a, I> where I: Iterator { type Error = DecodeError; fn visit(&mut self) -> Result, DecodeError> where V: de::Deserialize { match self.iter.next() { Some(value) => { self.len -= 1; let mut de = Decoder::new(value); let v = try!(de::Deserialize::deserialize(&mut de)); if let Some(t) = de.toml { self.put_value_back(t); } Ok(Some(v)) } None => Ok(None), } } fn end(&mut self) -> Result<(), DecodeError> { if self.len == 0 { Ok(()) } else { Err(de::Error::end_of_stream()) } } fn size_hint(&self) -> (usize, Option) { (self.len, Some(self.len)) } } impl de::Error for DecodeError { fn syntax(_: &str) -> DecodeError { DecodeError { field: None, kind: DecodeErrorKind::SyntaxError } } fn end_of_stream() -> DecodeError { DecodeError { field: None, kind: DecodeErrorKind::EndOfStream } } fn missing_field(name: &'static str) -> DecodeError { DecodeError { field: Some(name.to_string()), kind: DecodeErrorKind::ExpectedField(None), } } fn unknown_field(name: &str) -> DecodeError { DecodeError { field: Some(name.to_string()), kind: DecodeErrorKind::UnknownField, } } } struct MapVisitor<'a, I> { iter: I, de: &'a mut Decoder, key: Option, value: Option, } impl<'a, I> MapVisitor<'a, I> { fn put_value_back(&mut self, v: Value) { self.de.toml = self.de.toml.take().or_else(|| { Some(Value::Table(BTreeMap::new())) }); match self.de.toml.as_mut().unwrap() { &mut Value::Table(ref mut t) => { t.insert(self.key.take().unwrap(), v); }, _ => unreachable!(), } } } impl<'a, I> de::MapVisitor for MapVisitor<'a, I> where I: Iterator { type Error = DecodeError; fn visit_key(&mut self) -> Result, DecodeError> where K: de::Deserialize { while let Some((k, v)) = self.iter.next() { let mut dec = self.de.sub_decoder(Some(Value::String(k.clone())), &k); self.key = Some(k); match de::Deserialize::deserialize(&mut dec) { Ok(val) => { self.value = Some(v); return Ok(Some(val)) } // If this was an unknown field, then we put the toml value // back into the map and keep going. Err(DecodeError {kind: DecodeErrorKind::UnknownField, ..}) => { self.put_value_back(v); } Err(e) => return Err(e), } } Ok(None) } fn visit_value(&mut self) -> Result where V: de::Deserialize { match self.value.take() { Some(t) => { let mut dec = { // Borrowing the key here because Rust doesn't have // non-lexical borrows yet. let key = match self.key { Some(ref key) => &**key, None => "" }; self.de.sub_decoder(Some(t), key) }; let v = try!(de::Deserialize::deserialize(&mut dec)); if let Some(t) = dec.toml { self.put_value_back(t); } Ok(v) }, None => Err(de::Error::end_of_stream()) } } fn end(&mut self) -> Result<(), DecodeError> { Ok(()) } fn missing_field(&mut self, field_name: &'static str) -> Result where V: de::Deserialize { // See if the type can deserialize from a unit. match de::Deserialize::deserialize(&mut UnitDeserializer) { Err(DecodeError { kind: DecodeErrorKind::SyntaxError, field, }) => Err(DecodeError { field: field.or(Some(field_name.to_string())), kind: DecodeErrorKind::ExpectedField(None), }), v => v, } } } struct UnitDeserializer; impl de::Deserializer for UnitDeserializer { type Error = DecodeError; fn visit(&mut self, mut visitor: V) -> Result where V: de::Visitor, { visitor.visit_unit() } fn visit_option(&mut self, mut visitor: V) -> Result where V: de::Visitor, { visitor.visit_none() } } impl de::Deserialize for Value { fn deserialize(deserializer: &mut D) -> Result where D: de::Deserializer { struct ValueVisitor; impl de::Visitor for ValueVisitor { type Value = Value; fn visit_bool(&mut self, value: bool) -> Result { Ok(Value::Boolean(value)) } fn visit_i64(&mut self, value: i64) -> Result { Ok(Value::Integer(value)) } fn visit_f64(&mut self, value: f64) -> Result { Ok(Value::Float(value)) } fn visit_str(&mut self, value: &str) -> Result { Ok(Value::String(value.into())) } fn visit_string(&mut self, value: String) -> Result { Ok(Value::String(value)) } fn visit_seq(&mut self, visitor: V) -> Result where V: de::SeqVisitor { let values = try!(de::impls::VecVisitor::new().visit_seq(visitor)); Ok(Value::Array(values)) } fn visit_map(&mut self, visitor: V) -> Result where V: de::MapVisitor { let mut v = de::impls::BTreeMapVisitor::new(); let values = try!(v.visit_map(visitor)); Ok(Value::Table(values)) } } deserializer.visit(ValueVisitor) } } deps/toml-0.1.25/src/parser.rs0000664000175000017500000013641012635117174013074 0ustar use std::ascii::AsciiExt; use std::char; use std::collections::BTreeMap; use std::error::Error; use std::fmt; use std::str; macro_rules! try { ($e:expr) => (match $e { Some(s) => s, None => return None }) } // We redefine Value because we need to keep track of encountered table // definitions, eg when parsing: // // [a] // [a.b] // [a] // // we have to error out on redefinition of [a]. This bit of data is difficult to // track in a side table so we just have a "stripped down" AST to work with // which has the relevant metadata fields in it. struct TomlTable { values: BTreeMap, defined: bool, } impl TomlTable { fn convert(self) -> super::Table { self.values.into_iter().map(|(k,v)| (k, v.convert())).collect() } } enum Value { String(String), Integer(i64), Float(f64), Boolean(bool), Datetime(String), Array(Vec), Table(TomlTable), } impl Value { fn type_str(&self) -> &'static str { match *self { Value::String(..) => "string", Value::Integer(..) => "integer", Value::Float(..) => "float", Value::Boolean(..) => "boolean", Value::Datetime(..) => "datetime", Value::Array(..) => "array", Value::Table(..) => "table", } } fn same_type(&self, other: &Value) -> bool { match (self, other) { (&Value::String(..), &Value::String(..)) | (&Value::Integer(..), &Value::Integer(..)) | (&Value::Float(..), &Value::Float(..)) | (&Value::Boolean(..), &Value::Boolean(..)) | (&Value::Datetime(..), &Value::Datetime(..)) | (&Value::Array(..), &Value::Array(..)) | (&Value::Table(..), &Value::Table(..)) => true, _ => false, } } fn convert(self) -> super::Value { match self { Value::String(x) => super::Value::String(x), Value::Integer(x) => super::Value::Integer(x), Value::Float(x) => super::Value::Float(x), Value::Boolean(x) => super::Value::Boolean(x), Value::Datetime(x) => super::Value::Datetime(x), Value::Array(v) => super::Value::Array( v.into_iter().map(|x| x.convert()).collect() ), Value::Table(t) => super::Value::Table(t.convert()) } } } /// Parser for converting a string to a TOML `Value` instance. /// /// This parser contains the string slice that is being parsed, and exports the /// list of errors which have occurred during parsing. pub struct Parser<'a> { input: &'a str, cur: str::CharIndices<'a>, /// A list of all errors which have occurred during parsing. /// /// Not all parse errors are fatal, so this list is added to as much as /// possible without aborting parsing. If `None` is returned by `parse`, it /// is guaranteed that this list is not empty. pub errors: Vec, } /// A structure representing a parse error. /// /// The data in this structure can be used to trace back to the original cause /// of the error in order to provide diagnostics about parse errors. #[derive(Debug, Clone)] pub struct ParserError { /// The low byte at which this error is pointing at. pub lo: usize, /// One byte beyond the last character at which this error is pointing at. pub hi: usize, /// A human-readable description explaining what the error is. pub desc: String, } impl<'a> Parser<'a> { /// Creates a new parser for a string. /// /// The parser can be executed by invoking the `parse` method. /// /// # Example /// /// ``` /// let toml = r#" /// [test] /// foo = "bar" /// "#; /// /// let mut parser = toml::Parser::new(toml); /// match parser.parse() { /// Some(value) => println!("found toml: {:?}", value), /// None => { /// println!("parse errors: {:?}", parser.errors); /// } /// } /// ``` pub fn new(s: &'a str) -> Parser<'a> { Parser { input: s, cur: s.char_indices(), errors: Vec::new(), } } /// Converts a byte offset from an error message to a (line, column) pair /// /// All indexes are 0-based. pub fn to_linecol(&self, offset: usize) -> (usize, usize) { let mut cur = 0; for (i, line) in self.input.lines().enumerate() { if cur + line.len() + 1 > offset { return (i, offset - cur) } cur += line.len() + 1; } return (self.input.lines().count(), 0) } fn next_pos(&self) -> usize { self.cur.clone().next().map(|p| p.0).unwrap_or(self.input.len()) } // Returns true and consumes the next character if it matches `ch`, // otherwise do nothing and return false fn eat(&mut self, ch: char) -> bool { match self.peek(0) { Some((_, c)) if c == ch => { self.cur.next(); true } Some(_) | None => false, } } // Peeks ahead `n` characters fn peek(&self, n: usize) -> Option<(usize, char)> { self.cur.clone().skip(n).next() } fn expect(&mut self, ch: char) -> bool { if self.eat(ch) { return true } let mut it = self.cur.clone(); let lo = it.next().map(|p| p.0).unwrap_or(self.input.len()); let hi = it.next().map(|p| p.0).unwrap_or(self.input.len()); self.errors.push(ParserError { lo: lo, hi: hi, desc: match self.cur.clone().next() { Some((_, c)) => format!("expected `{}`, but found `{}`", ch, c), None => format!("expected `{}`, but found eof", ch) } }); false } // Consumes a BOM (Byte Order Mark) if one is next fn bom(&mut self) -> bool { match self.peek(0) { Some((_, '\u{feff}')) => { self.cur.next(); true } _ => false } } // Consumes whitespace ('\t' and ' ') until another character (or EOF) is // reached. Returns if any whitespace was consumed fn ws(&mut self) -> bool { let mut ret = false; loop { match self.peek(0) { Some((_, '\t')) | Some((_, ' ')) => { self.cur.next(); ret = true; } _ => break, } } ret } // Consumes the rest of the line after a comment character fn comment(&mut self) -> bool { if !self.eat('#') { return false } for (_, ch) in self.cur.by_ref() { if ch == '\n' { break } } true } // Consumes a newline if one is next fn newline(&mut self) -> bool { match self.peek(0) { Some((_, '\n')) => { self.cur.next(); true } Some((_, '\r')) if self.peek(1).map(|c| c.1) == Some('\n') => { self.cur.next(); self.cur.next(); true } _ => false } } /// Executes the parser, parsing the string contained within. /// /// This function will return the `TomlTable` instance if parsing is /// successful, or it will return `None` if any parse error or invalid TOML /// error occurs. /// /// If an error occurs, the `errors` field of this parser can be consulted /// to determine the cause of the parse failure. pub fn parse(&mut self) -> Option { let mut ret = TomlTable { values: BTreeMap::new(), defined: false }; self.bom(); while self.peek(0).is_some() { self.ws(); if self.newline() { continue } if self.comment() { continue } if self.eat('[') { let array = self.eat('['); let start = self.next_pos(); // Parse the name of the section let mut keys = Vec::new(); loop { self.ws(); if let Some(s) = self.key_name() { keys.push(s); } self.ws(); if self.eat(']') { if array && !self.expect(']') { return None } break } if !self.expect('.') { return None } } if keys.len() == 0 { return None } // Build the section table let mut table = TomlTable { values: BTreeMap::new(), defined: true, }; if !self.values(&mut table) { return None } if array { self.insert_array(&mut ret, &keys, Value::Table(table), start) } else { self.insert_table(&mut ret, &keys, table, start) } } else { if !self.values(&mut ret) { return None } } } if self.errors.len() > 0 { None } else { Some(ret.convert()) } } // Parse a single key name starting at `start` fn key_name(&mut self) -> Option { let start = self.next_pos(); let key = if self.eat('"') { self.finish_string(start, false) } else { let mut ret = String::new(); while let Some((_, ch)) = self.cur.clone().next() { match ch { 'a' ... 'z' | 'A' ... 'Z' | '0' ... '9' | '_' | '-' => { self.cur.next(); ret.push(ch) } _ => break, } } Some(ret) }; match key { Some(ref name) if name.len() == 0 => { self.errors.push(ParserError { lo: start, hi: start, desc: format!("expected a key but found an empty string"), }); None } Some(name) => Some(name), None => None, } } // Parses the values into the given TomlTable. Returns true in case of success // and false in case of error. fn values(&mut self, into: &mut TomlTable) -> bool { loop { self.ws(); if self.newline() { continue } if self.comment() { continue } match self.peek(0) { Some((_, '[')) => break, Some(..) => {} None => break, } let key_lo = self.next_pos(); let key = match self.key_name() { Some(s) => s, None => return false }; if !self.keyval_sep() { return false } let value = match self.value() { Some(value) => value, None => return false, }; self.insert(into, key, value, key_lo); self.ws(); self.comment(); self.newline(); } return true } fn keyval_sep(&mut self) -> bool { self.ws(); if !self.expect('=') { return false } self.ws(); true } // Parses a value fn value(&mut self) -> Option { self.ws(); match self.cur.clone().next() { Some((pos, '"')) => self.string(pos), Some((pos, '\'')) => self.literal_string(pos), Some((pos, 't')) | Some((pos, 'f')) => self.boolean(pos), Some((pos, '[')) => self.array(pos), Some((pos, '{')) => self.inline_table(pos), Some((pos, '-')) | Some((pos, '+')) => self.number_or_datetime(pos), Some((pos, ch)) if is_digit(ch) => self.number_or_datetime(pos), _ => { let mut it = self.cur.clone(); let lo = it.next().map(|p| p.0).unwrap_or(self.input.len()); let hi = it.next().map(|p| p.0).unwrap_or(self.input.len()); self.errors.push(ParserError { lo: lo, hi: hi, desc: format!("expected a value"), }); return None } } } // Parses a single or multi-line string fn string(&mut self, start: usize) -> Option { if !self.expect('"') { return None } let mut multiline = false; // detect multiline literals, but be careful about empty "" // strings if self.eat('"') { if self.eat('"') { multiline = true; self.newline(); } else { // empty return Some(Value::String(String::new())) } } self.finish_string(start, multiline).map(Value::String) } // Finish parsing a basic string after the opening quote has been seen fn finish_string(&mut self, start: usize, multiline: bool) -> Option { let mut ret = String::new(); loop { while multiline && self.newline() { ret.push('\n') } match self.cur.next() { Some((_, '"')) => { if multiline { if !self.eat('"') { ret.push_str("\""); continue } if !self.eat('"') { ret.push_str("\"\""); continue } } return Some(ret) } Some((pos, '\\')) => { if let Some(c) = escape(self, pos, multiline) { ret.push(c); } } Some((pos, ch)) if ch < '\u{1f}' => { self.errors.push(ParserError { lo: pos, hi: pos + 1, desc: format!("control character `{}` must be escaped", ch.escape_default().collect::()) }); } Some((_, ch)) => ret.push(ch), None => { self.errors.push(ParserError { lo: start, hi: self.input.len(), desc: format!("unterminated string literal"), }); return None } } } fn escape(me: &mut Parser, pos: usize, multiline: bool) -> Option { if multiline && me.newline() { while me.ws() || me.newline() { /* ... */ } return None } match me.cur.next() { Some((_, 'b')) => Some('\u{8}'), Some((_, 't')) => Some('\u{9}'), Some((_, 'n')) => Some('\u{a}'), Some((_, 'f')) => Some('\u{c}'), Some((_, 'r')) => Some('\u{d}'), Some((_, '"')) => Some('\u{22}'), Some((_, '\\')) => Some('\u{5c}'), Some((pos, c @ 'u')) | Some((pos, c @ 'U')) => { let len = if c == 'u' {4} else {8}; let num = &me.input[pos+1..]; let num = if num.len() >= len && num.is_ascii() { &num[..len] } else { "invalid" }; if let Some(n) = u32::from_str_radix(num, 16).ok() { if let Some(c) = char::from_u32(n) { me.cur.by_ref().skip(len - 1).next(); return Some(c) } else { me.errors.push(ParserError { lo: pos + 1, hi: pos + 5, desc: format!("codepoint `{:x}` is \ not a valid unicode \ codepoint", n), }) } } else { me.errors.push(ParserError { lo: pos, hi: pos + 1, desc: format!("expected {} hex digits \ after a `{}` escape", len, c), }) } None } Some((pos, ch)) => { let next_pos = me.next_pos(); me.errors.push(ParserError { lo: pos, hi: next_pos, desc: format!("unknown string escape: `{}`", ch.escape_default().collect::()), }); None } None => { me.errors.push(ParserError { lo: pos, hi: pos + 1, desc: format!("unterminated escape sequence"), }); None } } } } fn literal_string(&mut self, start: usize) -> Option { if !self.expect('\'') { return None } let mut multiline = false; let mut ret = String::new(); // detect multiline literals if self.eat('\'') { if self.eat('\'') { multiline = true; self.newline(); } else { return Some(Value::String(ret)) // empty } } loop { if !multiline && self.newline() { let next = self.next_pos(); self.errors.push(ParserError { lo: start, hi: next, desc: format!("literal strings cannot contain newlines"), }); return None } match self.cur.next() { Some((_, '\'')) => { if multiline { if !self.eat('\'') { ret.push_str("'"); continue } if !self.eat('\'') { ret.push_str("''"); continue } } break } Some((_, ch)) => ret.push(ch), None => { self.errors.push(ParserError { lo: start, hi: self.input.len(), desc: format!("unterminated string literal"), }); return None } } } return Some(Value::String(ret)); } fn number_or_datetime(&mut self, start: usize) -> Option { let mut is_float = false; let prefix = try!(self.integer(start, false, true)); let decimal = if self.eat('.') { is_float = true; Some(try!(self.integer(start, true, false))) } else { None }; let exponent = if self.eat('e') || self.eat('E') { is_float = true; Some(try!(self.integer(start, false, true))) } else { None }; let end = self.next_pos(); let input = &self.input[start..end]; let ret = if !is_float && !input.starts_with("+") && !input.starts_with("-") && self.eat('-') { self.datetime(start, end + 1) } else { let input = match (decimal, exponent) { (None, None) => prefix, (Some(ref d), None) => prefix + "." + d, (None, Some(ref e)) => prefix + "E" + e, (Some(ref d), Some(ref e)) => prefix + "." + d + "E" + e, }; let input = input.trim_left_matches('+'); if is_float { input.parse().ok().map(Value::Float) } else { input.parse().ok().map(Value::Integer) } }; if ret.is_none() { self.errors.push(ParserError { lo: start, hi: end, desc: format!("invalid numeric literal"), }); } return ret; } fn integer(&mut self, start: usize, allow_leading_zeros: bool, allow_sign: bool) -> Option { let mut s = String::new(); if allow_sign { if self.eat('-') { s.push('-'); } else if self.eat('+') { s.push('+'); } } match self.cur.next() { Some((_, '0')) if !allow_leading_zeros => { s.push('0'); match self.peek(0) { Some((pos, c)) if '0' <= c && c <= '9' => { self.errors.push(ParserError { lo: start, hi: pos, desc: format!("leading zeroes are not allowed"), }); return None } _ => {} } } Some((_, ch)) if '0' <= ch && ch <= '9' => { s.push(ch); } _ => { let pos = self.next_pos(); self.errors.push(ParserError { lo: pos, hi: pos, desc: format!("expected start of a numeric literal"), }); return None; } } let mut underscore = false; loop { match self.cur.clone().next() { Some((_, ch)) if '0' <= ch && ch <= '9' => { s.push(ch); self.cur.next(); underscore = false; } Some((_, '_')) if !underscore => { self.cur.next(); underscore = true; } Some(_) | None => break, } } if underscore { let pos = self.next_pos(); self.errors.push(ParserError { lo: pos, hi: pos, desc: format!("numeral cannot end with an underscore"), }); return None } else { Some(s) } } fn boolean(&mut self, start: usize) -> Option { let rest = &self.input[start..]; if rest.starts_with("true") { for _ in 0..4 { self.cur.next(); } Some(Value::Boolean(true)) } else if rest.starts_with("false") { for _ in 0..5 { self.cur.next(); } Some(Value::Boolean(false)) } else { let next = self.next_pos(); self.errors.push(ParserError { lo: start, hi: next, desc: format!("unexpected character: `{}`", rest.chars().next().unwrap()), }); None } } fn datetime(&mut self, start: usize, end_so_far: usize) -> Option { let mut date = format!("{}", &self.input[start..end_so_far]); for _ in 0..15 { match self.cur.next() { Some((_, ch)) => date.push(ch), None => { self.errors.push(ParserError { lo: start, hi: end_so_far, desc: format!("malformed date literal"), }); return None } } } let mut it = date.chars(); let mut valid = true; valid = valid && it.next().map(is_digit).unwrap_or(false); valid = valid && it.next().map(is_digit).unwrap_or(false); valid = valid && it.next().map(is_digit).unwrap_or(false); valid = valid && it.next().map(is_digit).unwrap_or(false); valid = valid && it.next().map(|c| c == '-').unwrap_or(false); valid = valid && it.next().map(is_digit).unwrap_or(false); valid = valid && it.next().map(is_digit).unwrap_or(false); valid = valid && it.next().map(|c| c == '-').unwrap_or(false); valid = valid && it.next().map(is_digit).unwrap_or(false); valid = valid && it.next().map(is_digit).unwrap_or(false); valid = valid && it.next().map(|c| c == 'T').unwrap_or(false); valid = valid && it.next().map(is_digit).unwrap_or(false); valid = valid && it.next().map(is_digit).unwrap_or(false); valid = valid && it.next().map(|c| c == ':').unwrap_or(false); valid = valid && it.next().map(is_digit).unwrap_or(false); valid = valid && it.next().map(is_digit).unwrap_or(false); valid = valid && it.next().map(|c| c == ':').unwrap_or(false); valid = valid && it.next().map(is_digit).unwrap_or(false); valid = valid && it.next().map(is_digit).unwrap_or(false); valid = valid && it.next().map(|c| c == 'Z').unwrap_or(false); if valid { Some(Value::Datetime(date.clone())) } else { self.errors.push(ParserError { lo: start, hi: start + date.len(), desc: format!("malformed date literal"), }); None } } fn array(&mut self, _start: usize) -> Option { if !self.expect('[') { return None } let mut ret = Vec::new(); fn consume(me: &mut Parser) { loop { me.ws(); if !me.newline() && !me.comment() { break } } } let mut type_str = None; loop { // Break out early if we see the closing bracket consume(self); if self.eat(']') { return Some(Value::Array(ret)) } // Attempt to parse a value, triggering an error if it's the wrong // type. let start = self.next_pos(); let value = try!(self.value()); let end = self.next_pos(); let expected = type_str.unwrap_or(value.type_str()); if value.type_str() != expected { self.errors.push(ParserError { lo: start, hi: end, desc: format!("expected type `{}`, found type `{}`", expected, value.type_str()), }); } else { type_str = Some(expected); ret.push(value); } // Look for a comma. If we don't find one we're done consume(self); if !self.eat(',') { break } } consume(self); if !self.expect(']') { return None } return Some(Value::Array(ret)) } fn inline_table(&mut self, _start: usize) -> Option { if !self.expect('{') { return None } self.ws(); let mut ret = TomlTable { values: BTreeMap::new(), defined: true }; if self.eat('}') { return Some(Value::Table(ret)) } loop { let lo = self.next_pos(); let key = try!(self.key_name()); if !self.keyval_sep() { return None } let value = try!(self.value()); self.insert(&mut ret, key, value, lo); self.ws(); if self.eat('}') { break } if !self.expect(',') { return None } self.ws(); } return Some(Value::Table(ret)) } fn insert(&mut self, into: &mut TomlTable, key: String, value: Value, key_lo: usize) { if into.values.contains_key(&key) { self.errors.push(ParserError { lo: key_lo, hi: key_lo + key.len(), desc: format!("duplicate key: `{}`", key), }) } else { into.values.insert(key, value); } } fn recurse<'b>(&mut self, mut cur: &'b mut TomlTable, keys: &'b [String], key_lo: usize) -> Option<(&'b mut TomlTable, &'b str)> { let key_hi = keys.iter().fold(0, |a, b| a + b.len()); for part in keys[..keys.len() - 1].iter() { let tmp = cur; if tmp.values.contains_key(part) { match *tmp.values.get_mut(part).unwrap() { Value::Table(ref mut table) => cur = table, Value::Array(ref mut array) => { match array.last_mut() { Some(&mut Value::Table(ref mut table)) => cur = table, _ => { self.errors.push(ParserError { lo: key_lo, hi: key_hi, desc: format!("array `{}` does not contain \ tables", part) }); return None } } } _ => { self.errors.push(ParserError { lo: key_lo, hi: key_hi, desc: format!("key `{}` was not previously a table", part) }); return None } } continue } // Initialize an empty table as part of this sub-key tmp.values.insert(part.clone(), Value::Table(TomlTable { values: BTreeMap::new(), defined: false, })); match *tmp.values.get_mut(part).unwrap() { Value::Table(ref mut inner) => cur = inner, _ => unreachable!(), } } Some((cur, &**keys.last().unwrap())) } fn insert_table(&mut self, into: &mut TomlTable, keys: &[String], table: TomlTable, key_lo: usize) { let (into, key) = match self.recurse(into, keys, key_lo) { Some(pair) => pair, None => return, }; if !into.values.contains_key(key) { into.values.insert(key.to_owned(), Value::Table(table)); return } if let Value::Table(ref mut into) = *into.values.get_mut(key).unwrap() { if into.defined { self.errors.push(ParserError { lo: key_lo, hi: key_lo + key.len(), desc: format!("redefinition of table `{}`", key), }); } for (k, v) in table.values { if into.values.insert(k.clone(), v).is_some() { self.errors.push(ParserError { lo: key_lo, hi: key_lo + key.len(), desc: format!("duplicate key `{}` in table", k), }); } } } else { self.errors.push(ParserError { lo: key_lo, hi: key_lo + key.len(), desc: format!("duplicate key `{}` in table", key), }); } } fn insert_array(&mut self, into: &mut TomlTable, keys: &[String], value: Value, key_lo: usize) { let (into, key) = match self.recurse(into, keys, key_lo) { Some(pair) => pair, None => return, }; if !into.values.contains_key(key) { into.values.insert(key.to_owned(), Value::Array(Vec::new())); } match *into.values.get_mut(key).unwrap() { Value::Array(ref mut vec) => { match vec.first() { Some(ref v) if !v.same_type(&value) => { self.errors.push(ParserError { lo: key_lo, hi: key_lo + key.len(), desc: format!("expected type `{}`, found type `{}`", v.type_str(), value.type_str()), }) } Some(..) | None => {} } vec.push(value); } _ => { self.errors.push(ParserError { lo: key_lo, hi: key_lo + key.len(), desc: format!("key `{}` was previously not an array", key), }); } } } } impl Error for ParserError { fn description(&self) -> &str { "TOML parse error" } } impl fmt::Display for ParserError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.desc.fmt(f) } } fn is_digit(c: char) -> bool { match c { '0' ... '9' => true, _ => false } } #[cfg(test)] mod tests { use Value::Table; use Parser; macro_rules! bad { ($s:expr, $msg:expr) => ({ let mut p = Parser::new($s); assert!(p.parse().is_none()); assert!(p.errors.iter().any(|e| e.desc.contains($msg)), "errors: {:?}", p.errors); }) } #[test] fn crlf() { let mut p = Parser::new("\ [project]\r\n\ \r\n\ name = \"splay\"\r\n\ version = \"0.1.0\"\r\n\ authors = [\"alex@crichton.co\"]\r\n\ \r\n\ [[lib]]\r\n\ \r\n\ path = \"lib.rs\"\r\n\ name = \"splay\"\r\n\ description = \"\"\"\ A Rust implementation of a TAR file reader and writer. This library does not\r\n\ currently handle compression, but it is abstract over all I/O readers and\r\n\ writers. Additionally, great lengths are taken to ensure that the entire\r\n\ contents are never required to be entirely resident in memory all at once.\r\n\ \"\"\"\ "); assert!(p.parse().is_some()); } #[test] fn linecol() { let p = Parser::new("ab\ncde\nf"); assert_eq!(p.to_linecol(0), (0, 0)); assert_eq!(p.to_linecol(1), (0, 1)); assert_eq!(p.to_linecol(3), (1, 0)); assert_eq!(p.to_linecol(4), (1, 1)); assert_eq!(p.to_linecol(7), (2, 0)); } #[test] fn fun_with_strings() { let mut p = Parser::new(r#" bar = "\U00000000" key1 = "One\nTwo" key2 = """One\nTwo""" key3 = """ One Two""" key4 = "The quick brown fox jumps over the lazy dog." key5 = """ The quick brown \ fox jumps over \ the lazy dog.""" key6 = """\ The quick brown \ fox jumps over \ the lazy dog.\ """ # What you see is what you get. winpath = 'C:\Users\nodejs\templates' winpath2 = '\\ServerX\admin$\system32\' quoted = 'Tom "Dubs" Preston-Werner' regex = '<\i\c*\s*>' regex2 = '''I [dw]on't need \d{2} apples''' lines = ''' The first newline is trimmed in raw strings. All other whitespace is preserved. ''' "#); let table = Table(p.parse().unwrap()); assert_eq!(table.lookup("bar").and_then(|k| k.as_str()), Some("\0")); assert_eq!(table.lookup("key1").and_then(|k| k.as_str()), Some("One\nTwo")); assert_eq!(table.lookup("key2").and_then(|k| k.as_str()), Some("One\nTwo")); assert_eq!(table.lookup("key3").and_then(|k| k.as_str()), Some("One\nTwo")); let msg = "The quick brown fox jumps over the lazy dog."; assert_eq!(table.lookup("key4").and_then(|k| k.as_str()), Some(msg)); assert_eq!(table.lookup("key5").and_then(|k| k.as_str()), Some(msg)); assert_eq!(table.lookup("key6").and_then(|k| k.as_str()), Some(msg)); assert_eq!(table.lookup("winpath").and_then(|k| k.as_str()), Some(r"C:\Users\nodejs\templates")); assert_eq!(table.lookup("winpath2").and_then(|k| k.as_str()), Some(r"\\ServerX\admin$\system32\")); assert_eq!(table.lookup("quoted").and_then(|k| k.as_str()), Some(r#"Tom "Dubs" Preston-Werner"#)); assert_eq!(table.lookup("regex").and_then(|k| k.as_str()), Some(r"<\i\c*\s*>")); assert_eq!(table.lookup("regex2").and_then(|k| k.as_str()), Some(r"I [dw]on't need \d{2} apples")); assert_eq!(table.lookup("lines").and_then(|k| k.as_str()), Some("The first newline is\n\ trimmed in raw strings.\n \ All other whitespace\n \ is preserved.\n")); } #[test] fn tables_in_arrays() { let mut p = Parser::new(r#" [[foo]] #… [foo.bar] #… [[foo]] #… [foo.bar] #... "#); let table = Table(p.parse().unwrap()); table.lookup("foo.0.bar").unwrap().as_table().unwrap(); table.lookup("foo.1.bar").unwrap().as_table().unwrap(); } #[test] fn fruit() { let mut p = Parser::new(r#" [[fruit]] name = "apple" [fruit.physical] color = "red" shape = "round" [[fruit.variety]] name = "red delicious" [[fruit.variety]] name = "granny smith" [[fruit]] name = "banana" [[fruit.variety]] name = "plantain" "#); let table = Table(p.parse().unwrap()); assert_eq!(table.lookup("fruit.0.name").and_then(|k| k.as_str()), Some("apple")); assert_eq!(table.lookup("fruit.0.physical.color").and_then(|k| k.as_str()), Some("red")); assert_eq!(table.lookup("fruit.0.physical.shape").and_then(|k| k.as_str()), Some("round")); assert_eq!(table.lookup("fruit.0.variety.0.name").and_then(|k| k.as_str()), Some("red delicious")); assert_eq!(table.lookup("fruit.0.variety.1.name").and_then(|k| k.as_str()), Some("granny smith")); assert_eq!(table.lookup("fruit.1.name").and_then(|k| k.as_str()), Some("banana")); assert_eq!(table.lookup("fruit.1.variety.0.name").and_then(|k| k.as_str()), Some("plantain")); } #[test] fn stray_cr() { assert!(Parser::new("\r").parse().is_none()); assert!(Parser::new("a = [ \r ]").parse().is_none()); assert!(Parser::new("a = \"\"\"\r\"\"\"").parse().is_none()); assert!(Parser::new("a = \"\"\"\\ \r \"\"\"").parse().is_none()); let mut p = Parser::new("foo = '''\r'''"); let table = Table(p.parse().unwrap()); assert_eq!(table.lookup("foo").and_then(|k| k.as_str()), Some("\r")); let mut p = Parser::new("foo = '\r'"); let table = Table(p.parse().unwrap()); assert_eq!(table.lookup("foo").and_then(|k| k.as_str()), Some("\r")); } #[test] fn blank_literal_string() { let mut p = Parser::new("foo = ''"); let table = Table(p.parse().unwrap()); assert_eq!(table.lookup("foo").and_then(|k| k.as_str()), Some("")); } #[test] fn many_blank() { let mut p = Parser::new("foo = \"\"\"\n\n\n\"\"\""); let table = Table(p.parse().unwrap()); assert_eq!(table.lookup("foo").and_then(|k| k.as_str()), Some("\n\n")); } #[test] fn literal_eats_crlf() { let mut p = Parser::new(" foo = \"\"\"\\\r\n\"\"\" bar = \"\"\"\\\r\n \r\n \r\n a\"\"\" "); let table = Table(p.parse().unwrap()); assert_eq!(table.lookup("foo").and_then(|k| k.as_str()), Some("")); assert_eq!(table.lookup("bar").and_then(|k| k.as_str()), Some("a")); } #[test] fn string_no_newline() { assert!(Parser::new("a = \"\n\"").parse().is_none()); assert!(Parser::new("a = '\n'").parse().is_none()); } #[test] fn bad_leading_zeros() { assert!(Parser::new("a = 00").parse().is_none()); assert!(Parser::new("a = -00").parse().is_none()); assert!(Parser::new("a = +00").parse().is_none()); assert!(Parser::new("a = 00.0").parse().is_none()); assert!(Parser::new("a = -00.0").parse().is_none()); assert!(Parser::new("a = +00.0").parse().is_none()); assert!(Parser::new("a = 9223372036854775808").parse().is_none()); assert!(Parser::new("a = -9223372036854775809").parse().is_none()); } #[test] fn bad_floats() { assert!(Parser::new("a = 0.").parse().is_none()); assert!(Parser::new("a = 0.e").parse().is_none()); assert!(Parser::new("a = 0.E").parse().is_none()); assert!(Parser::new("a = 0.0E").parse().is_none()); assert!(Parser::new("a = 0.0e").parse().is_none()); assert!(Parser::new("a = 0.0e-").parse().is_none()); assert!(Parser::new("a = 0.0e+").parse().is_none()); assert!(Parser::new("a = 0.0e+00").parse().is_none()); } #[test] fn floats() { macro_rules! t { ($actual:expr, $expected:expr) => ({ let f = format!("foo = {}", $actual); let mut p = Parser::new(&f); let table = Table(p.parse().unwrap()); assert_eq!(table.lookup("foo").and_then(|k| k.as_float()), Some($expected)); }) } t!("1.0", 1.0); t!("1.0e0", 1.0); t!("1.0e+0", 1.0); t!("1.0e-0", 1.0); t!("1.001e-0", 1.001); t!("2e10", 2e10); t!("2e+10", 2e10); t!("2e-10", 2e-10); t!("2_0.0", 20.0); t!("2_0.0_0e0_0", 20.0); t!("2_0.1_0e1_0", 20.1e10); } #[test] fn bare_key_names() { let mut p = Parser::new(" foo = 3 foo_3 = 3 foo_-2--3--r23f--4-f2-4 = 3 _ = 3 - = 3 8 = 8 \"a\" = 3 \"!\" = 3 \"a^b\" = 3 \"\\\"\" = 3 \"character encoding\" = \"value\" \"ʎǝʞ\" = \"value\" "); let table = Table(p.parse().unwrap()); assert!(table.lookup("foo").is_some()); assert!(table.lookup("-").is_some()); assert!(table.lookup("_").is_some()); assert!(table.lookup("8").is_some()); assert!(table.lookup("foo_3").is_some()); assert!(table.lookup("foo_-2--3--r23f--4-f2-4").is_some()); assert!(table.lookup("a").is_some()); assert!(table.lookup("!").is_some()); assert!(table.lookup("\"").is_some()); assert!(table.lookup("character encoding").is_some()); assert!(table.lookup("ʎǝʞ").is_some()); } #[test] fn bad_keys() { assert!(Parser::new("key\n=3").parse().is_none()); assert!(Parser::new("key=\n3").parse().is_none()); assert!(Parser::new("key|=3").parse().is_none()); assert!(Parser::new("\"\"=3").parse().is_none()); assert!(Parser::new("=3").parse().is_none()); assert!(Parser::new("\"\"|=3").parse().is_none()); assert!(Parser::new("\"\n\"|=3").parse().is_none()); assert!(Parser::new("\"\r\"|=3").parse().is_none()); } #[test] fn bad_table_names() { assert!(Parser::new("[]").parse().is_none()); assert!(Parser::new("[.]").parse().is_none()); assert!(Parser::new("[\"\".\"\"]").parse().is_none()); assert!(Parser::new("[a.]").parse().is_none()); assert!(Parser::new("[\"\"]").parse().is_none()); assert!(Parser::new("[!]").parse().is_none()); assert!(Parser::new("[\"\n\"]").parse().is_none()); assert!(Parser::new("[a.b]\n[a.\"b\"]").parse().is_none()); } #[test] fn table_names() { let mut p = Parser::new(" [a.\"b\"] [\"f f\"] [\"f.f\"] [\"\\\"\"] "); let table = Table(p.parse().unwrap()); assert!(table.lookup("a.b").is_some()); assert!(table.lookup("f f").is_some()); assert!(table.lookup("\"").is_some()); } #[test] fn invalid_bare_numeral() { assert!(Parser::new("4").parse().is_none()); } #[test] fn inline_tables() { assert!(Parser::new("a = {}").parse().is_some()); assert!(Parser::new("a = {b=1}").parse().is_some()); assert!(Parser::new("a = { b = 1 }").parse().is_some()); assert!(Parser::new("a = {a=1,b=2}").parse().is_some()); assert!(Parser::new("a = {a=1,b=2,c={}}").parse().is_some()); assert!(Parser::new("a = {a=1,}").parse().is_none()); assert!(Parser::new("a = {,}").parse().is_none()); assert!(Parser::new("a = {a=1,a=1}").parse().is_none()); assert!(Parser::new("a = {\n}").parse().is_none()); assert!(Parser::new("a = {").parse().is_none()); assert!(Parser::new("a = {a=[\n]}").parse().is_some()); assert!(Parser::new("a = {\"a\"=[\n]}").parse().is_some()); assert!(Parser::new("a = [\n{},\n{},\n]").parse().is_some()); } #[test] fn number_underscores() { macro_rules! t { ($actual:expr, $expected:expr) => ({ let f = format!("foo = {}", $actual); let mut p = Parser::new(&f); let table = Table(p.parse().unwrap()); assert_eq!(table.lookup("foo").and_then(|k| k.as_integer()), Some($expected)); }) } t!("1_0", 10); t!("1_0_0", 100); t!("1_000", 1000); t!("+1_000", 1000); t!("-1_000", -1000); } #[test] fn bad_underscores() { assert!(Parser::new("foo = 0_").parse().is_none()); assert!(Parser::new("foo = 0__0").parse().is_none()); assert!(Parser::new("foo = __0").parse().is_none()); assert!(Parser::new("foo = 1_0_").parse().is_none()); } #[test] fn bad_unicode_codepoint() { bad!("foo = \"\\uD800\"", "not a valid unicode codepoint"); } #[test] fn bad_strings() { bad!("foo = \"\\uxx\"", "expected 4 hex digits"); bad!("foo = \"\\u\"", "expected 4 hex digits"); bad!("foo = \"\\", "unterminated"); bad!("foo = '", "unterminated"); } #[test] fn empty_string() { let mut p = Parser::new("foo = \"\""); let table = Table(p.parse().unwrap()); assert_eq!(table.lookup("foo").unwrap().as_str(), Some("")); } #[test] fn booleans() { let mut p = Parser::new("foo = true"); let table = Table(p.parse().unwrap()); assert_eq!(table.lookup("foo").unwrap().as_bool(), Some(true)); let mut p = Parser::new("foo = false"); let table = Table(p.parse().unwrap()); assert_eq!(table.lookup("foo").unwrap().as_bool(), Some(false)); assert!(Parser::new("foo = true2").parse().is_none()); assert!(Parser::new("foo = false2").parse().is_none()); assert!(Parser::new("foo = t1").parse().is_none()); assert!(Parser::new("foo = f2").parse().is_none()); } #[test] fn bad_nesting() { bad!(" a = [2] [[a]] b = 5 ", "expected type `integer`, found type `table`"); bad!(" a = 1 [a.b] ", "key `a` was not previously a table"); bad!(" a = [] [a.b] ", "array `a` does not contain tables"); bad!(" a = [] [[a.b]] ", "array `a` does not contain tables"); bad!(" [a] b = { c = 2, d = {} } [a.b] c = 2 ", "duplicate key `c` in table"); } #[test] fn bad_table_redefine() { bad!(" [a] foo=\"bar\" [a.b] foo=\"bar\" [a] ", "redefinition of table `a`"); bad!(" [a] foo=\"bar\" b = { foo = \"bar\" } [a] ", "redefinition of table `a`"); bad!(" [a] b = {} [a.b] ", "redefinition of table `b`"); bad!(" [a] b = {} [a] ", "redefinition of table `a`"); } } deps/toml-0.1.25/src/lib.rs0000664000175000017500000002005712635122266012343 0ustar //! A TOML-parsing library //! //! This library is an implementation in Rust of a parser for TOML configuration //! files [1]. It is focused around high quality errors including specific spans //! and detailed error messages when things go wrong. //! //! This implementation currently passes the language agnostic [test suite][2]. //! //! # Example //! //! ``` //! let toml = r#" //! [test] //! foo = "bar" //! "#; //! //! let value = toml::Parser::new(toml).parse().unwrap(); //! println!("{:?}", value); //! ``` //! //! # Conversions //! //! This library also supports using the standard `Encodable` and `Decodable` //! traits with TOML values. This library provides the following conversion //! capabilities: //! //! * `String` => `toml::Value` - via `Parser` //! * `toml::Value` => `String` - via `Display` //! * `toml::Value` => rust object - via `Decoder` //! * rust object => `toml::Value` - via `Encoder` //! //! Convenience functions for performing multiple conversions at a time are also //! provided. //! //! [1]: https://github.com/mojombo/toml //! [2]: https://github.com/BurntSushi/toml-test #![doc(html_root_url = "http://alexcrichton.com/toml-rs")] #![deny(missing_docs)] #![cfg_attr(test, deny(warnings))] #[cfg(feature = "rustc-serialize")] extern crate rustc_serialize; #[cfg(feature = "serde")] extern crate serde; use std::collections::BTreeMap; use std::str::FromStr; pub use parser::{Parser, ParserError}; #[cfg(any(feature = "rustc-serialize", feature = "serde"))] pub use self::encoder::{Encoder, Error, encode, encode_str}; #[cfg(any(feature = "rustc-serialize", feature = "serde"))] pub use self::decoder::{Decoder, DecodeError, DecodeErrorKind, decode, decode_str}; mod parser; mod display; #[cfg(any(feature = "rustc-serialize", feature = "serde"))] mod encoder; #[cfg(any(feature = "rustc-serialize", feature = "serde"))] mod decoder; /// Representation of a TOML value. #[derive(PartialEq, Clone, Debug)] #[allow(missing_docs)] pub enum Value { String(String), Integer(i64), Float(f64), Boolean(bool), Datetime(String), Array(Array), Table(Table), } /// Type representing a TOML array, payload of the Value::Array variant pub type Array = Vec; /// Type representing a TOML table, payload of the Value::Table variant pub type Table = BTreeMap; impl Value { /// Tests whether this and another value have the same type. pub fn same_type(&self, other: &Value) -> bool { match (self, other) { (&Value::String(..), &Value::String(..)) | (&Value::Integer(..), &Value::Integer(..)) | (&Value::Float(..), &Value::Float(..)) | (&Value::Boolean(..), &Value::Boolean(..)) | (&Value::Datetime(..), &Value::Datetime(..)) | (&Value::Array(..), &Value::Array(..)) | (&Value::Table(..), &Value::Table(..)) => true, _ => false, } } /// Returns a human-readable representation of the type of this value. pub fn type_str(&self) -> &'static str { match *self { Value::String(..) => "string", Value::Integer(..) => "integer", Value::Float(..) => "float", Value::Boolean(..) => "boolean", Value::Datetime(..) => "datetime", Value::Array(..) => "array", Value::Table(..) => "table", } } /// Extracts the string of this value if it is a string. pub fn as_str<'a>(&'a self) -> Option<&'a str> { match *self { Value::String(ref s) => Some(&**s), _ => None } } /// Extracts the integer value if it is an integer. pub fn as_integer(&self) -> Option { match *self { Value::Integer(i) => Some(i), _ => None } } /// Extracts the float value if it is a float. pub fn as_float(&self) -> Option { match *self { Value::Float(f) => Some(f), _ => None } } /// Extracts the boolean value if it is a boolean. pub fn as_bool(&self) -> Option { match *self { Value::Boolean(b) => Some(b), _ => None } } /// Extracts the datetime value if it is a datetime. /// /// Note that a parsed TOML value will only contain ISO 8601 dates. An /// example date is: /// /// ```notrust /// 1979-05-27T07:32:00Z /// ``` pub fn as_datetime<'a>(&'a self) -> Option<&'a str> { match *self { Value::Datetime(ref s) => Some(&**s), _ => None } } /// Extracts the array value if it is an array. pub fn as_slice<'a>(&'a self) -> Option<&'a [Value]> { match *self { Value::Array(ref s) => Some(&**s), _ => None } } /// Extracts the table value if it is a table. pub fn as_table<'a>(&'a self) -> Option<&'a Table> { match *self { Value::Table(ref s) => Some(s), _ => None } } /// Lookups for value at specified path. /// /// Uses '.' as a path separator. /// /// Note: arrays have zero-based indexes. /// /// Note: empty path returns self. /// /// ``` /// # #![allow(unstable)] /// let toml = r#" /// [test] /// foo = "bar" /// /// [[values]] /// foo = "baz" /// /// [[values]] /// foo = "qux" /// "#; /// let value: toml::Value = toml.parse().unwrap(); /// /// let foo = value.lookup("test.foo").unwrap(); /// assert_eq!(foo.as_str().unwrap(), "bar"); /// /// let foo = value.lookup("values.1.foo").unwrap(); /// assert_eq!(foo.as_str().unwrap(), "qux"); /// /// let no_bar = value.lookup("test.bar"); /// assert_eq!(no_bar.is_none(), true); /// ``` pub fn lookup<'a>(&'a self, path: &'a str) -> Option<&'a Value> { let mut cur_value = self; if path.len() == 0 { return Some(cur_value) } for key in path.split('.') { match cur_value { &Value::Table(ref hm) => { match hm.get(key) { Some(v) => cur_value = v, None => return None } }, &Value::Array(ref v) => { match key.parse::().ok() { Some(idx) if idx < v.len() => cur_value = &v[idx], _ => return None } }, _ => return None } }; Some(cur_value) } } impl FromStr for Value { type Err = Vec; fn from_str(s: &str) -> Result> { let mut p = Parser::new(s); match p.parse().map(Value::Table) { Some(n) => Ok(n), None => Err(p.errors), } } } #[cfg(test)] mod tests { use super::Value; #[test] fn lookup_valid() { let toml = r#" [test] foo = "bar" [[values]] foo = "baz" [[values]] foo = "qux" "#; let value: Value = toml.parse().unwrap(); let test_foo = value.lookup("test.foo").unwrap(); assert_eq!(test_foo.as_str().unwrap(), "bar"); let foo1 = value.lookup("values.1.foo").unwrap(); assert_eq!(foo1.as_str().unwrap(), "qux"); assert!(value.lookup("test.bar").is_none()); assert!(value.lookup("test.foo.bar").is_none()); } #[test] fn lookup_invalid_index() { let toml = r#" [[values]] foo = "baz" "#; let value: Value = toml.parse().unwrap(); let foo = value.lookup("test.foo"); assert!(foo.is_none()); let foo = value.lookup("values.100.foo"); assert!(foo.is_none()); let foo = value.lookup("values.str.foo"); assert!(foo.is_none()); } #[test] fn lookup_self() { let value: Value = r#"foo = "bar""#.parse().unwrap(); let foo = value.lookup("foo").unwrap(); assert_eq!(foo.as_str().unwrap(), "bar"); let foo = value.lookup("").unwrap(); assert!(foo.as_table().is_some()); let baz = foo.lookup("foo").unwrap(); assert_eq!(baz.as_str().unwrap(), "bar"); } } deps/toml-0.1.25/src/display.rs0000664000175000017500000001456412635117174013252 0ustar use std::fmt; use Table as TomlTable; use Value::{self, String, Integer, Float, Boolean, Datetime, Array, Table}; struct Printer<'a, 'b:'a> { output: &'a mut fmt::Formatter<'b>, stack: Vec<&'a str>, } struct Key<'a>(&'a [&'a str]); impl fmt::Display for Value { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { String(ref s) => write_str(f, s), Integer(i) => write!(f, "{}", i), Float(fp) => { try!(write!(f, "{}", fp)); if fp % 1.0 == 0.0 { try!(write!(f, ".0")) } Ok(()) } Boolean(b) => write!(f, "{}", b), Datetime(ref s) => write!(f, "{}", s), Table(ref t) => { let mut p = Printer { output: f, stack: Vec::new() }; p.print(t) } Array(ref a) => { try!(write!(f, "[")); for (i, v) in a.iter().enumerate() { if i != 0 { try!(write!(f, ", ")); } try!(write!(f, "{}", v)); } write!(f, "]") } } } } fn write_str(f: &mut fmt::Formatter, s: &str) -> fmt::Result { try!(write!(f, "\"")); for ch in s.chars() { match ch { '\u{8}' => try!(write!(f, "\\b")), '\u{9}' => try!(write!(f, "\\t")), '\u{a}' => try!(write!(f, "\\n")), '\u{c}' => try!(write!(f, "\\f")), '\u{d}' => try!(write!(f, "\\r")), '\u{22}' => try!(write!(f, "\\\"")), '\u{5c}' => try!(write!(f, "\\\\")), ch => try!(write!(f, "{}", ch)), } } write!(f, "\"") } impl<'a, 'b> Printer<'a, 'b> { fn print(&mut self, table: &'a TomlTable) -> fmt::Result { for (k, v) in table.iter() { match *v { Table(..) => continue, Array(ref a) => { match a.first() { Some(&Table(..)) => continue, _ => {} } } _ => {} } try!(writeln!(self.output, "{} = {}", Key(&[k]), v)); } for (k, v) in table.iter() { match *v { Table(ref inner) => { self.stack.push(k); try!(writeln!(self.output, "\n[{}]", Key(&self.stack))); try!(self.print(inner)); self.stack.pop(); } Array(ref inner) => { match inner.first() { Some(&Table(..)) => {} _ => continue } self.stack.push(k); for inner in inner.iter() { try!(writeln!(self.output, "\n[[{}]]", Key(&self.stack))); match *inner { Table(ref inner) => try!(self.print(inner)), _ => panic!("non-heterogeneous toml array"), } } self.stack.pop(); } _ => {}, } } Ok(()) } } impl<'a> fmt::Display for Key<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { for (i, part) in self.0.iter().enumerate() { if i != 0 { try!(write!(f, ".")); } let ok = part.chars().all(|c| { match c { 'a' ... 'z' | 'A' ... 'Z' | '0' ... '9' | '-' | '_' => true, _ => false, } }); if ok { try!(write!(f, "{}", part)); } else { try!(write_str(f, part)); } } Ok(()) } } #[cfg(test)] #[allow(warnings)] mod tests { use Value; use Value::{String, Integer, Float, Boolean, Datetime, Array, Table}; use std::collections::BTreeMap; macro_rules! map( ($($k:expr => $v:expr),*) => ({ let mut _m = BTreeMap::new(); $(_m.insert($k.to_string(), $v);)* _m }) ); #[test] fn simple_show() { assert_eq!(String("foo".to_string()).to_string(), "\"foo\""); assert_eq!(Integer(10).to_string(), "10"); assert_eq!(Float(10.0).to_string(), "10.0"); assert_eq!(Float(2.4).to_string(), "2.4"); assert_eq!(Boolean(true).to_string(), "true"); assert_eq!(Datetime("test".to_string()).to_string(), "test"); assert_eq!(Array(vec![]).to_string(), "[]"); assert_eq!(Array(vec![Integer(1), Integer(2)]).to_string(), "[1, 2]"); } #[test] fn table() { assert_eq!(Table(map! { }).to_string(), ""); assert_eq!(Table(map! { "test" => Integer(2) }).to_string(), "test = 2\n"); assert_eq!(Table(map! { "test" => Integer(2), "test2" => Table(map! { "test" => String("wut".to_string()) }) }).to_string(), "test = 2\n\ \n\ [test2]\n\ test = \"wut\"\n"); assert_eq!(Table(map! { "test" => Integer(2), "test2" => Table(map! { "test" => String("wut".to_string()) }) }).to_string(), "test = 2\n\ \n\ [test2]\n\ test = \"wut\"\n"); assert_eq!(Table(map! { "test" => Integer(2), "test2" => Array(vec![Table(map! { "test" => String("wut".to_string()) })]) }).to_string(), "test = 2\n\ \n\ [[test2]]\n\ test = \"wut\"\n"); assert_eq!(Table(map! { "foo.bar" => Integer(2), "foo\"bar" => Integer(2) }).to_string(), "\"foo\\\"bar\" = 2\n\ \"foo.bar\" = 2\n"); } } deps/toml-0.1.25/src/encoder/0000755000000000000000000000000012666635520014424 5ustar rootrootdeps/toml-0.1.25/src/encoder/rustc_serialize.rs0000664000175000017500000005210712635122200016410 0ustar use std::mem; use rustc_serialize; use Value; use super::{Encoder, Error, State}; use super::Error::*; impl rustc_serialize::Encoder for Encoder { type Error = Error; fn emit_nil(&mut self) -> Result<(), Error> { Ok(()) } fn emit_usize(&mut self, v: usize) -> Result<(), Error> { self.emit_i64(v as i64) } fn emit_u8(&mut self, v: u8) -> Result<(), Error> { self.emit_i64(v as i64) } fn emit_u16(&mut self, v: u16) -> Result<(), Error> { self.emit_i64(v as i64) } fn emit_u32(&mut self, v: u32) -> Result<(), Error> { self.emit_i64(v as i64) } fn emit_u64(&mut self, v: u64) -> Result<(), Error> { self.emit_i64(v as i64) } fn emit_isize(&mut self, v: isize) -> Result<(), Error> { self.emit_i64(v as i64) } fn emit_i8(&mut self, v: i8) -> Result<(), Error> { self.emit_i64(v as i64) } fn emit_i16(&mut self, v: i16) -> Result<(), Error> { self.emit_i64(v as i64) } fn emit_i32(&mut self, v: i32) -> Result<(), Error> { self.emit_i64(v as i64) } fn emit_i64(&mut self, v: i64) -> Result<(), Error> { self.emit_value(Value::Integer(v)) } fn emit_bool(&mut self, v: bool) -> Result<(), Error> { self.emit_value(Value::Boolean(v)) } fn emit_f32(&mut self, v: f32) -> Result<(), Error> { self.emit_f64(v as f64) } fn emit_f64(&mut self, v: f64) -> Result<(), Error> { self.emit_value(Value::Float(v)) } fn emit_char(&mut self, v: char) -> Result<(), Error> { self.emit_str(&*format!("{}", v)) } fn emit_str(&mut self, v: &str) -> Result<(), Error> { self.emit_value(Value::String(format!("{}", v))) } fn emit_enum(&mut self, _name: &str, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { f(self) } fn emit_enum_variant(&mut self, _v_name: &str, _v_id: usize, _len: usize, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { f(self) } fn emit_enum_variant_arg(&mut self, _a_idx: usize, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { f(self) } fn emit_enum_struct_variant(&mut self, _v_name: &str, _v_id: usize, _len: usize, _f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { panic!() } fn emit_enum_struct_variant_field(&mut self, _f_name: &str, _f_idx: usize, _f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { panic!() } fn emit_struct(&mut self, _name: &str, _len: usize, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { self.table(f) } fn emit_struct_field(&mut self, f_name: &str, _f_idx: usize, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { let old = mem::replace(&mut self.state, State::NextKey(format!("{}", f_name))); try!(f(self)); if self.state != State::Start { return Err(NoValue) } self.state = old; Ok(()) } fn emit_tuple(&mut self, len: usize, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { self.emit_seq(len, f) } fn emit_tuple_arg(&mut self, idx: usize, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { self.emit_seq_elt(idx, f) } fn emit_tuple_struct(&mut self, _name: &str, _len: usize, _f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { unimplemented!() } fn emit_tuple_struct_arg(&mut self, _f_idx: usize, _f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { unimplemented!() } fn emit_option(&mut self, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { f(self) } fn emit_option_none(&mut self) -> Result<(), Error> { self.emit_none() } fn emit_option_some(&mut self, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { f(self) } fn emit_seq(&mut self, _len: usize, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { self.seq(f) } fn emit_seq_elt(&mut self, _idx: usize, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { f(self) } fn emit_map(&mut self, len: usize, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { self.emit_struct("foo", len, f) } fn emit_map_elt_key(&mut self, _idx: usize, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { self.table_key(f) } fn emit_map_elt_val(&mut self, _idx: usize, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { f(self) } } impl rustc_serialize::Encodable for Value { fn encode(&self, e: &mut E) -> Result<(), E::Error> where E: rustc_serialize::Encoder { match *self { Value::String(ref s) => e.emit_str(s), Value::Integer(i) => e.emit_i64(i), Value::Float(f) => e.emit_f64(f), Value::Boolean(b) => e.emit_bool(b), Value::Datetime(ref s) => e.emit_str(s), Value::Array(ref a) => { e.emit_seq(a.len(), |e| { for item in a { try!(item.encode(e)); } Ok(()) }) } Value::Table(ref t) => { e.emit_map(t.len(), |e| { for (i, (key, value)) in t.iter().enumerate() { try!(e.emit_map_elt_key(i, |e| e.emit_str(key))); try!(e.emit_map_elt_val(i, |e| value.encode(e))); } Ok(()) }) } } } } #[cfg(test)] mod tests { use std::collections::{BTreeMap, HashSet}; use rustc_serialize::{self, Encodable, Decodable}; use {Encoder, Decoder, DecodeError}; use Value; use Value::{Table, Integer, Array, Float}; macro_rules! encode( ($t:expr) => ({ let mut e = Encoder::new(); $t.encode(&mut e).unwrap(); e.toml }) ); macro_rules! decode( ($t:expr) => ({ let mut d = Decoder::new($t); Decodable::decode(&mut d).unwrap() }) ); macro_rules! map( ($($k:ident, $v:expr),*) => ({ let mut _m = BTreeMap::new(); $(_m.insert(stringify!($k).to_string(), $v);)* _m }) ); #[test] fn smoke() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: isize } let v = Foo { a: 2 }; assert_eq!(encode!(v), map! { a, Integer(2) }); assert_eq!(v, decode!(Table(encode!(v)))); } #[test] fn smoke_hyphen() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a_b: isize } let v = Foo { a_b: 2 }; assert_eq!(encode!(v), map! { a_b, Integer(2) }); assert_eq!(v, decode!(Table(encode!(v)))); let mut m = BTreeMap::new(); m.insert("a-b".to_string(), Integer(2)); assert_eq!(v, decode!(Table(encode!(v)))); } #[test] fn nested() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: isize, b: Bar } #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Bar { a: String } let v = Foo { a: 2, b: Bar { a: "test".to_string() } }; assert_eq!(encode!(v), map! { a, Integer(2), b, Table(map! { a, Value::String("test".to_string()) }) }); assert_eq!(v, decode!(Table(encode!(v)))); } #[test] fn application_decode_error() { #[derive(PartialEq, Debug)] struct Range10(usize); impl Decodable for Range10 { fn decode(d: &mut D) -> Result { let x: usize = try!(Decodable::decode(d)); if x > 10 { Err(d.error("Value out of range!")) } else { Ok(Range10(x)) } } } let mut d_good = Decoder::new(Integer(5)); let mut d_bad1 = Decoder::new(Value::String("not an isize".to_string())); let mut d_bad2 = Decoder::new(Integer(11)); assert_eq!(Ok(Range10(5)), Decodable::decode(&mut d_good)); let err1: Result = Decodable::decode(&mut d_bad1); assert!(err1.is_err()); let err2: Result = Decodable::decode(&mut d_bad2); assert!(err2.is_err()); } #[test] fn array() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: Vec } let v = Foo { a: vec![1, 2, 3, 4] }; assert_eq!(encode!(v), map! { a, Array(vec![ Integer(1), Integer(2), Integer(3), Integer(4) ]) }); assert_eq!(v, decode!(Table(encode!(v)))); } #[test] fn tuple() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: (isize, isize, isize, isize) } let v = Foo { a: (1, 2, 3, 4) }; assert_eq!(encode!(v), map! { a, Array(vec![ Integer(1), Integer(2), Integer(3), Integer(4) ]) }); assert_eq!(v, decode!(Table(encode!(v)))); } #[test] fn inner_structs_with_options() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: Option>, b: Bar, } #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Bar { a: String, b: f64, } let v = Foo { a: Some(Box::new(Foo { a: None, b: Bar { a: "foo".to_string(), b: 4.5 }, })), b: Bar { a: "bar".to_string(), b: 1.0 }, }; assert_eq!(encode!(v), map! { a, Table(map! { b, Table(map! { a, Value::String("foo".to_string()), b, Float(4.5) }) }), b, Table(map! { a, Value::String("bar".to_string()), b, Float(1.0) }) }); assert_eq!(v, decode!(Table(encode!(v)))); } #[test] fn hashmap() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { map: BTreeMap, set: HashSet, } let v = Foo { map: { let mut m = BTreeMap::new(); m.insert("foo".to_string(), 10); m.insert("bar".to_string(), 4); m }, set: { let mut s = HashSet::new(); s.insert('a'); s }, }; assert_eq!(encode!(v), map! { map, Table(map! { foo, Integer(10), bar, Integer(4) }), set, Array(vec![Value::String("a".to_string())]) } ); assert_eq!(v, decode!(Table(encode!(v)))); } #[test] fn tuple_struct() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo(isize, String, f64); let v = Foo(1, "foo".to_string(), 4.5); assert_eq!( encode!(v), map! { _field0, Integer(1), _field1, Value::String("foo".to_string()), _field2, Float(4.5) } ); assert_eq!(v, decode!(Table(encode!(v)))); } #[test] fn table_array() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: Vec, } #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Bar { a: isize } let v = Foo { a: vec![Bar { a: 1 }, Bar { a: 2 }] }; assert_eq!( encode!(v), map! { a, Array(vec![ Table(map!{ a, Integer(1) }), Table(map!{ a, Integer(2) }), ]) } ); assert_eq!(v, decode!(Table(encode!(v)))); } #[test] fn type_errors() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { bar: isize } let mut d = Decoder::new(Table(map! { bar, Float(1.0) })); let a: Result = Decodable::decode(&mut d); match a { Ok(..) => panic!("should not have decoded"), Err(e) => { assert_eq!(format!("{}", e), "expected a value of type `integer`, but \ found a value of type `float` for the key `bar`"); } } } #[test] fn missing_errors() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { bar: isize } let mut d = Decoder::new(Table(map! { })); let a: Result = Decodable::decode(&mut d); match a { Ok(..) => panic!("should not have decoded"), Err(e) => { assert_eq!(format!("{}", e), "expected a value of type `integer` for the key `bar`"); } } } #[test] fn parse_enum() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: E } #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] enum E { Bar(isize), Baz(f64), Last(Foo2), } #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo2 { test: String, } let v = Foo { a: E::Bar(10) }; assert_eq!( encode!(v), map! { a, Integer(10) } ); assert_eq!(v, decode!(Table(encode!(v)))); let v = Foo { a: E::Baz(10.2) }; assert_eq!( encode!(v), map! { a, Float(10.2) } ); assert_eq!(v, decode!(Table(encode!(v)))); let v = Foo { a: E::Last(Foo2 { test: "test".to_string() }) }; assert_eq!( encode!(v), map! { a, Table(map! { test, Value::String("test".to_string()) }) } ); assert_eq!(v, decode!(Table(encode!(v)))); } #[test] fn unused_fields() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: isize } let v = Foo { a: 2 }; let mut d = Decoder::new(Table(map! { a, Integer(2), b, Integer(5) })); assert_eq!(v, Decodable::decode(&mut d).unwrap()); assert_eq!(d.toml, Some(Table(map! { b, Integer(5) }))); } #[test] fn unused_fields2() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: Bar } #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Bar { a: isize } let v = Foo { a: Bar { a: 2 } }; let mut d = Decoder::new(Table(map! { a, Table(map! { a, Integer(2), b, Integer(5) }) })); assert_eq!(v, Decodable::decode(&mut d).unwrap()); assert_eq!(d.toml, Some(Table(map! { a, Table(map! { b, Integer(5) }) }))); } #[test] fn unused_fields3() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: Bar } #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Bar { a: isize } let v = Foo { a: Bar { a: 2 } }; let mut d = Decoder::new(Table(map! { a, Table(map! { a, Integer(2) }) })); assert_eq!(v, Decodable::decode(&mut d).unwrap()); assert_eq!(d.toml, None); } #[test] fn unused_fields4() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: BTreeMap } let v = Foo { a: map! { a, "foo".to_string() } }; let mut d = Decoder::new(Table(map! { a, Table(map! { a, Value::String("foo".to_string()) }) })); assert_eq!(v, Decodable::decode(&mut d).unwrap()); assert_eq!(d.toml, None); } #[test] fn unused_fields5() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: Vec } let v = Foo { a: vec!["a".to_string()] }; let mut d = Decoder::new(Table(map! { a, Array(vec![Value::String("a".to_string())]) })); assert_eq!(v, Decodable::decode(&mut d).unwrap()); assert_eq!(d.toml, None); } #[test] fn unused_fields6() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: Option> } let v = Foo { a: Some(vec![]) }; let mut d = Decoder::new(Table(map! { a, Array(vec![]) })); assert_eq!(v, Decodable::decode(&mut d).unwrap()); assert_eq!(d.toml, None); } #[test] fn unused_fields7() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: Vec } #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Bar { a: isize } let v = Foo { a: vec![Bar { a: 1 }] }; let mut d = Decoder::new(Table(map! { a, Array(vec![Table(map! { a, Integer(1), b, Integer(2) })]) })); assert_eq!(v, Decodable::decode(&mut d).unwrap()); assert_eq!(d.toml, Some(Table(map! { a, Array(vec![Table(map! { b, Integer(2) })]) }))); } #[test] fn unused_fields8() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: BTreeMap } #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Bar { a: isize } let v = Foo { a: map! { a, Bar { a: 2 } } }; let mut d = Decoder::new(Table(map! { a, Table(map! { a, Table(map! { a, Integer(2), b, Integer(2) }) }) })); assert_eq!(v, Decodable::decode(&mut d).unwrap()); assert_eq!(d.toml, Some(Table(map! { a, Table(map! { a, Table(map! { b, Integer(2) }) }) }))); } #[test] fn empty_arrays() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: Vec } #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Bar; let v = Foo { a: vec![] }; let mut d = Decoder::new(Table(map! {})); assert_eq!(v, Decodable::decode(&mut d).unwrap()); } #[test] fn empty_arrays2() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Foo { a: Option> } #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct Bar; let v = Foo { a: None }; let mut d = Decoder::new(Table(map! {})); assert_eq!(v, Decodable::decode(&mut d).unwrap()); let v = Foo { a: Some(vec![]) }; let mut d = Decoder::new(Table(map! { a, Array(vec![]) })); assert_eq!(v, Decodable::decode(&mut d).unwrap()); } #[test] fn round_trip() { let toml = r#" [test] foo = "bar" [[values]] foo = "baz" [[values]] foo = "qux" "#; let value: Value = toml.parse().unwrap(); let val2 = ::encode_str(&value).parse().unwrap(); assert_eq!(value, val2); } } deps/toml-0.1.25/src/encoder/mod.rs0000664000175000017500000001574512635117174014005 0ustar use std::collections::BTreeMap; use std::error; use std::fmt; use std::mem; use {Value, Table}; #[cfg(feature = "rustc-serialize")] mod rustc_serialize; #[cfg(feature = "serde")] mod serde; /// A structure to transform Rust values into TOML values. /// /// This encoder implements the serialization `Encoder` interface, allowing /// `Encodable` rust types to be fed into the encoder. The output of this /// encoder is a TOML `Table` structure. The resulting TOML can be stringified /// if necessary. /// /// # Example /// /// ``` /// extern crate rustc_serialize; /// extern crate toml; /// /// # fn main() { /// use toml::{Encoder, Value}; /// use rustc_serialize::Encodable; /// /// #[derive(RustcEncodable)] /// struct MyStruct { foo: isize, bar: String } /// let my_struct = MyStruct { foo: 4, bar: "hello!".to_string() }; /// /// let mut e = Encoder::new(); /// my_struct.encode(&mut e).unwrap(); /// /// assert_eq!(e.toml.get(&"foo".to_string()), Some(&Value::Integer(4))) /// # } /// ``` pub struct Encoder { /// Output TOML that is emitted. The current version of this encoder forces /// the top-level representation of a structure to be a table. /// /// This field can be used to extract the return value after feeding a value /// into this `Encoder`. pub toml: Table, state: State, } /// Enumeration of errors which can occur while encoding a rust value into a /// TOML value. #[allow(missing_copy_implementations)] #[derive(Debug)] pub enum Error { /// Indication that a key was needed when a value was emitted, but no key /// was previously emitted. NeedsKey, /// Indication that a key was emitted, but not value was emitted. NoValue, /// Indicates that a map key was attempted to be emitted at an invalid /// location. InvalidMapKeyLocation, /// Indicates that a type other than a string was attempted to be used as a /// map key type. InvalidMapKeyType, } #[derive(PartialEq)] enum State { Start, NextKey(String), NextArray(Vec), NextMapKey, } impl Encoder { /// Constructs a new encoder which will emit to the given output stream. pub fn new() -> Encoder { Encoder { state: State::Start, toml: BTreeMap::new() } } fn emit_value(&mut self, v: Value) -> Result<(), Error> { match mem::replace(&mut self.state, State::Start) { State::NextKey(key) => { self.toml.insert(key, v); Ok(()) } State::NextArray(mut vec) => { // TODO: validate types vec.push(v); self.state = State::NextArray(vec); Ok(()) } State::NextMapKey => { match v { Value::String(s) => { self.state = State::NextKey(s); Ok(()) } _ => Err(Error::InvalidMapKeyType) } } _ => Err(Error::NeedsKey) } } fn emit_none(&mut self) -> Result<(), Error> { match mem::replace(&mut self.state, State::Start) { State::Start => unreachable!(), State::NextKey(_) => Ok(()), State::NextArray(..) => panic!("how to encode None in an array?"), State::NextMapKey => Err(Error::InvalidMapKeyLocation), } } fn seq(&mut self, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { let old = mem::replace(&mut self.state, State::NextArray(Vec::new())); try!(f(self)); match mem::replace(&mut self.state, old) { State::NextArray(v) => self.emit_value(Value::Array(v)), _ => unreachable!(), } } fn table(&mut self, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { match mem::replace(&mut self.state, State::Start) { State::NextKey(key) => { let mut nested = Encoder::new(); try!(f(&mut nested)); self.toml.insert(key, Value::Table(nested.toml)); Ok(()) } State::NextArray(mut arr) => { let mut nested = Encoder::new(); try!(f(&mut nested)); arr.push(Value::Table(nested.toml)); self.state = State::NextArray(arr); Ok(()) } State::Start => f(self), State::NextMapKey => Err(Error::InvalidMapKeyLocation), } } fn table_key(&mut self, f: F) -> Result<(), Error> where F: FnOnce(&mut Encoder) -> Result<(), Error> { match mem::replace(&mut self.state, State::NextMapKey) { State::Start => {} _ => return Err(Error::InvalidMapKeyLocation), } try!(f(self)); match self.state { State::NextKey(_) => Ok(()), _ => Err(Error::InvalidMapKeyLocation), } } } /// Encodes an encodable value into a TOML value. /// /// This function expects the type given to represent a TOML table in some form. /// If encoding encounters an error, then this function will fail the task. #[cfg(feature = "rustc-serialize")] pub fn encode(t: &T) -> Value { let mut e = Encoder::new(); t.encode(&mut e).unwrap(); Value::Table(e.toml) } /// Encodes an encodable value into a TOML value. /// /// This function expects the type given to represent a TOML table in some form. /// If encoding encounters an error, then this function will fail the task. #[cfg(all(not(feature = "rustc-serialize"), feature = "serde"))] pub fn encode(t: &T) -> Value { let mut e = Encoder::new(); t.serialize(&mut e).unwrap(); Value::Table(e.toml) } /// Encodes an encodable value into a TOML string. /// /// This function expects the type given to represent a TOML table in some form. /// If encoding encounters an error, then this function will fail the task. #[cfg(feature = "rustc-serialize")] pub fn encode_str(t: &T) -> String { encode(t).to_string() } /// Encodes an encodable value into a TOML string. /// /// This function expects the type given to represent a TOML table in some form. /// If encoding encounters an error, then this function will fail the task. #[cfg(all(not(feature = "rustc-serialize"), feature = "serde"))] pub fn encode_str(t: &T) -> String { encode(t).to_string() } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Error::NeedsKey => write!(f, "need a key to encode"), Error::NoValue => write!(f, "no value to emit for a previous key"), Error::InvalidMapKeyLocation => write!(f, "a map cannot be emitted \ at this location"), Error::InvalidMapKeyType => write!(f, "only strings can be used as \ key types"), } } } impl error::Error for Error { fn description(&self) -> &str { "TOML encoding error" } } deps/toml-0.1.25/src/encoder/serde.rs0000664000175000017500000000641612635117174014323 0ustar use serde::ser; use Value; use super::{Encoder, Error}; impl ser::Serializer for Encoder { type Error = Error; fn visit_bool(&mut self, v: bool) -> Result<(), Error> { self.emit_value(Value::Boolean(v)) } fn visit_i64(&mut self, v: i64) -> Result<(), Error> { self.emit_value(Value::Integer(v)) } fn visit_u64(&mut self, v: u64) -> Result<(), Error> { self.visit_i64(v as i64) } fn visit_f64(&mut self, v: f64) -> Result<(), Error> { self.emit_value(Value::Float(v)) } fn visit_str(&mut self, value: &str) -> Result<(), Error> { self.emit_value(Value::String(value.to_string())) } fn visit_unit(&mut self) -> Result<(), Error> { Ok(()) } fn visit_none(&mut self) -> Result<(), Error> { self.emit_none() } fn visit_some(&mut self, value: V) -> Result<(), Error> where V: ser::Serialize { value.serialize(self) } fn visit_seq(&mut self, mut visitor: V) -> Result<(), Error> where V: ser::SeqVisitor { self.seq(|me| { while try!(visitor.visit(me)).is_some() {} Ok(()) }) } fn visit_seq_elt(&mut self, value: T) -> Result<(), Error> where T: ser::Serialize { value.serialize(self) } fn visit_map(&mut self, mut visitor: V) -> Result<(), Error> where V: ser::MapVisitor { self.table(|me| { while try!(visitor.visit(me)).is_some() {} Ok(()) }) } fn visit_map_elt(&mut self, key: K, value: V) -> Result<(), Error> where K: ser::Serialize, V: ser::Serialize { try!(self.table_key(|me| key.serialize(me))); try!(value.serialize(self)); Ok(()) } fn visit_newtype_struct(&mut self, _name: &'static str, value: T) -> Result<(), Self::Error> where T: ser::Serialize, { // Don't serialize the newtype struct in a tuple. value.serialize(self) } fn visit_newtype_variant(&mut self, _name: &'static str, _variant_index: usize, _variant: &'static str, value: T) -> Result<(), Self::Error> where T: ser::Serialize, { // Don't serialize the newtype struct variant in a tuple. value.serialize(self) } } impl ser::Serialize for Value { fn serialize(&self, e: &mut E) -> Result<(), E::Error> where E: ser::Serializer { match *self { Value::String(ref s) => e.visit_str(s), Value::Integer(i) => e.visit_i64(i), Value::Float(f) => e.visit_f64(f), Value::Boolean(b) => e.visit_bool(b), Value::Datetime(ref s) => e.visit_str(s), Value::Array(ref a) => { e.visit_seq(ser::impls::SeqIteratorVisitor::new(a.iter(), Some(a.len()))) } Value::Table(ref t) => { e.visit_map(ser::impls::MapIteratorVisitor::new(t.iter(), Some(t.len()))) } } } } deps/toml-0.1.25/tests/0000755000000000000000000000000012666635520013360 5ustar rootrootdeps/toml-0.1.25/tests/valid/0000755000000000000000000000000012666635520014457 5ustar rootrootdeps/toml-0.1.25/tests/valid/table-empty.toml0000664000175000017500000000000412351126066016004 0ustar [a] deps/toml-0.1.25/tests/valid/implicit-and-explicit-after.json0000664000175000017500000000030212351126066021050 0ustar { "a": { "better": {"type": "integer", "value": "43"}, "b": { "c": { "answer": {"type": "integer", "value": "42"} } } } } deps/toml-0.1.25/tests/valid/table-with-pound.toml0000664000175000017500000000003212456104366016752 0ustar ["key#group"] answer = 42 deps/toml-0.1.25/tests/valid/example.json0000664000175000017500000000054212351126066015221 0ustar { "best-day-ever": {"type": "datetime", "value": "1987-07-05T17:45:00Z"}, "numtheory": { "boring": {"type": "bool", "value": "false"}, "perfection": { "type": "array", "value": [ {"type": "integer", "value": "6"}, {"type": "integer", "value": "28"}, {"type": "integer", "value": "496"} ] } } } deps/toml-0.1.25/tests/valid/implicit-and-explicit-before.json0000664000175000017500000000030212351126066021211 0ustar { "a": { "better": {"type": "integer", "value": "43"}, "b": { "c": { "answer": {"type": "integer", "value": "42"} } } } } deps/toml-0.1.25/tests/valid/datetime.json0000664000175000017500000000011512351126066015356 0ustar { "bestdayever": {"type": "datetime", "value": "1987-07-05T17:45:00Z"} } deps/toml-0.1.25/tests/valid/table-array-many.toml0000664000175000017500000000024312351126066016733 0ustar [[people]] first_name = "Bruce" last_name = "Springsteen" [[people]] first_name = "Eric" last_name = "Clapton" [[people]] first_name = "Bob" last_name = "Seger" deps/toml-0.1.25/tests/valid/table-empty.json0000664000175000017500000000002012351126066016000 0ustar { "a": {} } deps/toml-0.1.25/tests/valid/table-whitespace.toml0000664000175000017500000000001612456104352017005 0ustar ["valid key"] deps/toml-0.1.25/tests/valid/example2.json0000664000175000017500000000257612456024307015315 0ustar {"clients":{"data":{"type":"array","value":[{"type":"array","value":[{"type":"string","value":"gamma"},{"type":"string","value":"delta"}]},{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]}]},"hosts":{"type":"array","value":[{"type":"string","value":"alpha"},{"type":"string","value":"omega"}]}},"database":{"connection_max":{"type":"integer","value":"5000"},"enabled":{"type":"bool","value":"true"},"ports":{"type":"array","value":[{"type":"integer","value":"8001"},{"type":"integer","value":"8001"},{"type":"integer","value":"8002"}]},"server":{"type":"string","value":"192.168.1.1"}},"owner":{"bio":{"type":"string","value":"GitHub Cofounder \u0026 CEO\nLikes tater tots and beer."},"dob":{"type":"datetime","value":"1979-05-27T07:32:00Z"},"name":{"type":"string","value":"Tom Preston-Werner"},"organization":{"type":"string","value":"GitHub"}},"products":[{"name":{"type":"string","value":"Hammer"},"sku":{"type":"integer","value":"738594937"}},{"color":{"type":"string","value":"gray"},"name":{"type":"string","value":"Nail"},"sku":{"type":"integer","value":"284758393"}}],"servers":{"alpha":{"dc":{"type":"string","value":"eqdc10"},"ip":{"type":"string","value":"10.0.0.1"}},"beta":{"country":{"type":"string","value":"中国"},"dc":{"type":"string","value":"eqdc10"},"ip":{"type":"string","value":"10.0.0.2"}}},"title":{"type":"string","value":"TOML Example"}} deps/toml-0.1.25/tests/valid/datetime.toml0000664000175000017500000000004312351126066015360 0ustar bestdayever = 1987-07-05T17:45:00Z deps/toml-0.1.25/tests/valid/key-special-chars.json0000664000175000017500000000014212351126066017066 0ustar { "~!@#$^&*()_+-`1234567890[]\\|/?><.,;:'": { "type": "integer", "value": "1" } } deps/toml-0.1.25/tests/valid/hard_example.json0000664000175000017500000000125512456024332016220 0ustar {"the":{"hard":{"another_test_string":{"type":"string","value":" Same thing, but with a string #"},"bit#":{"multi_line_array":{"type":"array","value":[{"type":"string","value":"]"}]},"what?":{"type":"string","value":"You don't think some user won't do that?"}},"harder_test_string":{"type":"string","value":" And when \"'s are in the string, along with # \""},"test_array":{"type":"array","value":[{"type":"string","value":"] "},{"type":"string","value":" # "}]},"test_array2":{"type":"array","value":[{"type":"string","value":"Test #11 ]proved that"},{"type":"string","value":"Experiment #9 was a success"}]}},"test_string":{"type":"string","value":"You'll hate me after this - #"}}} deps/toml-0.1.25/tests/valid/float.toml0000664000175000017500000000003012351126066014665 0ustar pi = 3.14 negpi = -3.14 deps/toml-0.1.25/tests/valid/string-escapes.toml0000664000175000017500000000064412457513607016532 0ustar backspace = "This string has a \b backspace character." tab = "This string has a \t tab character." newline = "This string has a \n new line character." formfeed = "This string has a \f form feed character." carriage = "This string has a \r carriage return character." quote = "This string has a \" quote character." slash = "This string has a / slash character." backslash = "This string has a \\ backslash character." deps/toml-0.1.25/tests/valid/empty.toml0000664000175000017500000000000012351126066014713 0ustar deps/toml-0.1.25/tests/valid/arrays-hetergeneous.toml0000664000175000017500000000005112351126066017557 0ustar mixed = [[1, 2], ["a", "b"], [1.0, 2.0]] deps/toml-0.1.25/tests/valid/implicit-and-explicit-after.toml0000664000175000017500000000004512351126066021056 0ustar [a.b.c] answer = 42 [a] better = 43 deps/toml-0.1.25/tests/valid/arrays-nested.toml0000664000175000017500000000002612351126066016346 0ustar nest = [["a"], ["b"]] deps/toml-0.1.25/tests/valid/unicode-escape.toml0000664000175000017500000000002212351126066016445 0ustar answer = "\u03B4" deps/toml-0.1.25/tests/valid/unicode-escape.json0000664000175000017500000000007012351126066016446 0ustar { "answer": {"type": "string", "value": "\u03B4"} } deps/toml-0.1.25/tests/valid/string-escapes.json0000664000175000017500000000162012351126066016513 0ustar { "backspace": { "type": "string", "value": "This string has a \u0008 backspace character." }, "tab": { "type": "string", "value": "This string has a \u0009 tab character." }, "newline": { "type": "string", "value": "This string has a \u000A new line character." }, "formfeed": { "type": "string", "value": "This string has a \u000C form feed character." }, "carriage": { "type": "string", "value": "This string has a \u000D carriage return character." }, "quote": { "type": "string", "value": "This string has a \u0022 quote character." }, "slash": { "type": "string", "value": "This string has a \u002F slash character." }, "backslash": { "type": "string", "value": "This string has a \u005C backslash character." } } deps/toml-0.1.25/tests/valid/table-array-implicit.toml0000664000175000017500000000004512351126066017601 0ustar [[albums.songs]] name = "Glory Days" deps/toml-0.1.25/tests/valid/string-empty.json0000664000175000017500000000011012362310511016207 0ustar { "answer": { "type": "string", "value": "" } } deps/toml-0.1.25/tests/valid/float.json0000664000175000017500000000014312351126066014670 0ustar { "pi": {"type": "float", "value": "3.14"}, "negpi": {"type": "float", "value": "-3.14"} } deps/toml-0.1.25/tests/valid/key-with-pound.toml0000664000175000017500000000001712456064004016450 0ustar "key#name" = 5 deps/toml-0.1.25/tests/valid/example-v0.3.0.json0000664000175000017500000000622712456037320016051 0ustar {"Array":{"key1":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"},{"type":"integer","value":"3"}]},"key2":{"type":"array","value":[{"type":"string","value":"red"},{"type":"string","value":"yellow"},{"type":"string","value":"green"}]},"key3":{"type":"array","value":[{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]},{"type":"array","value":[{"type":"integer","value":"3"},{"type":"integer","value":"4"},{"type":"integer","value":"5"}]}]},"key4":{"type":"array","value":[{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]},{"type":"array","value":[{"type":"string","value":"a"},{"type":"string","value":"b"},{"type":"string","value":"c"}]}]},"key5":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"},{"type":"integer","value":"3"}]},"key6":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]}},"Booleans":{"False":{"type":"bool","value":"false"},"True":{"type":"bool","value":"true"}},"Datetime":{"key1":{"type":"datetime","value":"1979-05-27T07:32:00Z"}},"Float":{"both":{},"exponent":{},"fractional":{"key1":{"type":"float","value":"1.0"},"key2":{"type":"float","value":"3.1415"},"key3":{"type":"float","value":"-0.01"}}},"Integer":{"key1":{"type":"integer","value":"99"},"key2":{"type":"integer","value":"42"},"key3":{"type":"integer","value":"0"},"key4":{"type":"integer","value":"-17"}},"String":{"Literal":{"Multiline":{"lines":{"type":"string","value":"The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n"},"regex2":{"type":"string","value":"I [dw]on't need \\d{2} apples"}},"quoted":{"type":"string","value":"Tom \"Dubs\" Preston-Werner"},"regex":{"type":"string","value":"\u003c\\i\\c*\\s*\u003e"},"winpath":{"type":"string","value":"C:\\Users\\nodejs\\templates"},"winpath2":{"type":"string","value":"\\\\ServerX\\admin$\\system32\\"}},"Multiline":{"key1":{"type":"string","value":"One\nTwo"},"key2":{"type":"string","value":"One\nTwo"},"key3":{"type":"string","value":"One\nTwo"}},"Multilined":{"Singleline":{"key1":{"type":"string","value":"The quick brown fox jumps over the lazy dog."},"key2":{"type":"string","value":"The quick brown fox jumps over the lazy dog."},"key3":{"type":"string","value":"The quick brown fox jumps over the lazy dog."}}},"basic":{"type":"string","value":"I'm a string. \"You can quote me\". Name\u0009José\nLocation\u0009SF."}},"Table":{"key":{"type":"string","value":"value"}},"dog":{"tater":{"type":{"type":"string","value":"pug"}}},"fruit":[{"name":{"type":"string","value":"apple"},"physical":{"color":{"type":"string","value":"red"},"shape":{"type":"string","value":"round"}},"variety":[{"name":{"type":"string","value":"red delicious"}},{"name":{"type":"string","value":"granny smith"}}]},{"name":{"type":"string","value":"banana"},"variety":[{"name":{"type":"string","value":"plantain"}}]}],"products":[{"name":{"type":"string","value":"Hammer"},"sku":{"type":"integer","value":"738594937"}},{},{"color":{"type":"string","value":"gray"},"name":{"type":"string","value":"Nail"},"sku":{"type":"integer","value":"284758393"}}],"x":{"y":{"z":{"w":{}}}}} deps/toml-0.1.25/tests/valid/long-float.json0000664000175000017500000000020512351126066015624 0ustar { "longpi": {"type": "float", "value": "3.141592653589793"}, "neglongpi": {"type": "float", "value": "-3.141592653589793"} } deps/toml-0.1.25/tests/valid/table-array-many.json0000664000175000017500000000072712351126066016740 0ustar { "people": [ { "first_name": {"type": "string", "value": "Bruce"}, "last_name": {"type": "string", "value": "Springsteen"} }, { "first_name": {"type": "string", "value": "Eric"}, "last_name": {"type": "string", "value": "Clapton"} }, { "first_name": {"type": "string", "value": "Bob"}, "last_name": {"type": "string", "value": "Seger"} } ] } deps/toml-0.1.25/tests/valid/unicode-literal.json0000664000175000017500000000006412351126066016645 0ustar { "answer": {"type": "string", "value": "δ"} } deps/toml-0.1.25/tests/valid/long-integer.json0000664000175000017500000000021512351126066016155 0ustar { "answer": {"type": "integer", "value": "9223372036854775807"}, "neganswer": {"type": "integer", "value": "-9223372036854775808"} } deps/toml-0.1.25/tests/valid/table-with-pound.json0000664000175000017500000000012212351126066016743 0ustar { "key#group": { "answer": {"type": "integer", "value": "42"} } } deps/toml-0.1.25/tests/valid/key-equals-nospace.json0000664000175000017500000000006512351126066017274 0ustar { "answer": {"type": "integer", "value": "42"} } deps/toml-0.1.25/tests/valid/key-with-pound.json0000664000175000017500000000006612351126066016453 0ustar { "key#name": {"type": "integer", "value": "5"} } deps/toml-0.1.25/tests/valid/example-bom.toml0000664000175000017500000000013612607323561016000 0ustar best-day-ever = 1987-07-05T17:45:00Z [numtheory] boring = false perfection = [6, 28, 496] deps/toml-0.1.25/tests/valid/long-integer.toml0000664000175000017500000000007612351126066016164 0ustar answer = 9223372036854775807 neganswer = -9223372036854775808 deps/toml-0.1.25/tests/valid/unicode-literal.toml0000664000175000017500000000001612351126066016644 0ustar answer = "δ" deps/toml-0.1.25/tests/valid/implicit-groups.json0000664000175000017500000000021412351126066016711 0ustar { "a": { "b": { "c": { "answer": {"type": "integer", "value": "42"} } } } } deps/toml-0.1.25/tests/valid/table-whitespace.json0000664000175000017500000000003012351126066016777 0ustar { "valid key": {} } deps/toml-0.1.25/tests/valid/array-empty.json0000664000175000017500000000042312351126066016036 0ustar { "thevoid": { "type": "array", "value": [ {"type": "array", "value": [ {"type": "array", "value": [ {"type": "array", "value": [ {"type": "array", "value": []} ]} ]} ]} ]} } deps/toml-0.1.25/tests/valid/example.toml0000664000175000017500000000013312351126066015217 0ustar best-day-ever = 1987-07-05T17:45:00Z [numtheory] boring = false perfection = [6, 28, 496] deps/toml-0.1.25/tests/valid/bool.json0000664000175000017500000000013412351126066014516 0ustar { "f": {"type": "bool", "value": "false"}, "t": {"type": "bool", "value": "true"} } deps/toml-0.1.25/tests/valid/string-empty.toml0000664000175000017500000000001412362310511016214 0ustar answer = "" deps/toml-0.1.25/tests/valid/table-array-implicit.json0000664000175000017500000000016412351126066017601 0ustar { "albums": { "songs": [ {"name": {"type": "string", "value": "Glory Days"}} ] } } deps/toml-0.1.25/tests/valid/table-array-nest.json0000664000175000017500000000107212351126066016737 0ustar { "albums": [ { "name": {"type": "string", "value": "Born to Run"}, "songs": [ {"name": {"type": "string", "value": "Jungleland"}}, {"name": {"type": "string", "value": "Meeting Across the River"}} ] }, { "name": {"type": "string", "value": "Born in the USA"}, "songs": [ {"name": {"type": "string", "value": "Glory Days"}}, {"name": {"type": "string", "value": "Dancing in the Dark"}} ] } ] } deps/toml-0.1.25/tests/valid/example-v0.4.0.json0000664000175000017500000000667112467531521016061 0ustar {"array":{"key1":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"},{"type":"integer","value":"3"}]},"key2":{"type":"array","value":[{"type":"string","value":"red"},{"type":"string","value":"yellow"},{"type":"string","value":"green"}]},"key3":{"type":"array","value":[{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]},{"type":"array","value":[{"type":"integer","value":"3"},{"type":"integer","value":"4"},{"type":"integer","value":"5"}]}]},"key4":{"type":"array","value":[{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]},{"type":"array","value":[{"type":"string","value":"a"},{"type":"string","value":"b"},{"type":"string","value":"c"}]}]},"key5":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"},{"type":"integer","value":"3"}]},"key6":{"type":"array","value":[{"type":"integer","value":"1"},{"type":"integer","value":"2"}]}},"boolean":{"False":{"type":"bool","value":"false"},"True":{"type":"bool","value":"true"}},"datetime":{},"float":{"both":{},"exponent":{},"fractional":{"key1":{"type":"float","value":"1.0"},"key2":{"type":"float","value":"3.1415"},"key3":{"type":"float","value":"-0.01"}},"underscores":{}},"fruit":[{"name":{"type":"string","value":"apple"},"physical":{"color":{"type":"string","value":"red"},"shape":{"type":"string","value":"round"}},"variety":[{"name":{"type":"string","value":"red delicious"}},{"name":{"type":"string","value":"granny smith"}}]},{"name":{"type":"string","value":"banana"},"variety":[{"name":{"type":"string","value":"plantain"}}]}],"integer":{"key1":{"type":"integer","value":"99"},"key2":{"type":"integer","value":"42"},"key3":{"type":"integer","value":"0"},"key4":{"type":"integer","value":"-17"},"underscores":{"key1":{"type":"integer","value":"1000"},"key2":{"type":"integer","value":"5349221"},"key3":{"type":"integer","value":"12345"}}},"products":[{"name":{"type":"string","value":"Hammer"},"sku":{"type":"integer","value":"738594937"}},{},{"color":{"type":"string","value":"gray"},"name":{"type":"string","value":"Nail"},"sku":{"type":"integer","value":"284758393"}}],"string":{"basic":{"basic":{"type":"string","value":"I'm a string. \"You can quote me\". Name\u0009José\nLocation\u0009SF."}},"literal":{"multiline":{"lines":{"type":"string","value":"The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n"},"regex2":{"type":"string","value":"I [dw]on't need \\d{2} apples"}},"quoted":{"type":"string","value":"Tom \"Dubs\" Preston-Werner"},"regex":{"type":"string","value":"\u003c\\i\\c*\\s*\u003e"},"winpath":{"type":"string","value":"C:\\Users\\nodejs\\templates"},"winpath2":{"type":"string","value":"\\\\ServerX\\admin$\\system32\\"}},"multiline":{"continued":{"key1":{"type":"string","value":"The quick brown fox jumps over the lazy dog."},"key2":{"type":"string","value":"The quick brown fox jumps over the lazy dog."},"key3":{"type":"string","value":"The quick brown fox jumps over the lazy dog."}},"key1":{"type":"string","value":"One\nTwo"},"key2":{"type":"string","value":"One\nTwo"},"key3":{"type":"string","value":"One\nTwo"}}},"table":{"inline":{"name":{"first":{"type":"string","value":"Tom"},"last":{"type":"string","value":"Preston-Werner"}},"point":{"x":{"type":"integer","value":"1"},"y":{"type":"integer","value":"2"}}},"key":{"type":"string","value":"value"},"subtable":{"key":{"type":"string","value":"another value"}}},"x":{"y":{"z":{"w":{}}}}} deps/toml-0.1.25/tests/valid/comments-everywhere.toml0000664000175000017500000000071012351126066017575 0ustar # Top comment. # Top comment. # Top comment. # [no-extraneous-groups-please] [group] # Comment answer = 42 # Comment # no-extraneous-keys-please = 999 # Inbetween comment. more = [ # Comment # What about multiple # comments? # Can you handle it? # # Evil. # Evil. 42, 42, # Comments within arrays are fun. # What about multiple # comments? # Can you handle it? # # Evil. # Evil. # ] Did I fool you? ] # Hopefully not. deps/toml-0.1.25/tests/valid/table-array-one.json0000664000175000017500000000026212351126066016547 0ustar { "people": [ { "first_name": {"type": "string", "value": "Bruce"}, "last_name": {"type": "string", "value": "Springsteen"} } ] } deps/toml-0.1.25/tests/valid/key-equals-nospace.toml0000664000175000017500000000001212351126066017266 0ustar answer=42 deps/toml-0.1.25/tests/valid/arrays.json0000664000175000017500000000163612351126066015074 0ustar { "ints": { "type": "array", "value": [ {"type": "integer", "value": "1"}, {"type": "integer", "value": "2"}, {"type": "integer", "value": "3"} ] }, "floats": { "type": "array", "value": [ {"type": "float", "value": "1.0"}, {"type": "float", "value": "2.0"}, {"type": "float", "value": "3.0"} ] }, "strings": { "type": "array", "value": [ {"type": "string", "value": "a"}, {"type": "string", "value": "b"}, {"type": "string", "value": "c"} ] }, "dates": { "type": "array", "value": [ {"type": "datetime", "value": "1987-07-05T17:45:00Z"}, {"type": "datetime", "value": "1979-05-27T07:32:00Z"}, {"type": "datetime", "value": "2006-06-01T11:00:00Z"} ] } } deps/toml-0.1.25/tests/valid/long-float.toml0000664000175000017500000000007212351126066015630 0ustar longpi = 3.141592653589793 neglongpi = -3.141592653589793 deps/toml-0.1.25/tests/valid/table-sub-empty.json0000664000175000017500000000003112351126066016571 0ustar { "a": { "b": {} } } deps/toml-0.1.25/tests/valid/table-sub-empty.toml0000664000175000017500000000001212351126066016572 0ustar [a] [a.b] deps/toml-0.1.25/tests/valid/hard_example.toml0000664000175000017500000000257512456104340016226 0ustar # Test file for TOML # Only this one tries to emulate a TOML file written by a user of the kind of parser writers probably hate # This part you'll really hate [the] test_string = "You'll hate me after this - #" # " Annoying, isn't it? [the.hard] test_array = [ "] ", " # "] # ] There you go, parse this! test_array2 = [ "Test #11 ]proved that", "Experiment #9 was a success" ] # You didn't think it'd as easy as chucking out the last #, did you? another_test_string = " Same thing, but with a string #" harder_test_string = " And when \"'s are in the string, along with # \"" # "and comments are there too" # Things will get harder [the.hard."bit#"] "what?" = "You don't think some user won't do that?" multi_line_array = [ "]", # ] Oh yes I did ] # Each of the following keygroups/key value pairs should produce an error. Uncomment to them to test #[error] if you didn't catch this, your parser is broken #string = "Anything other than tabs, spaces and newline after a keygroup or key value pair has ended should produce an error unless it is a comment" like this #array = [ # "This might most likely happen in multiline arrays", # Like here, # "or here, # and here" # ] End of array comment, forgot the # #number = 3.14 pi <--again forgot the # deps/toml-0.1.25/tests/valid/implicit-groups.toml0000664000175000017500000000002412351126066016712 0ustar [a.b.c] answer = 42 deps/toml-0.1.25/tests/valid/example-v0.4.0.toml0000664000175000017500000001202512467531507016055 0ustar ################################################################################ ## Comment # Speak your mind with the hash symbol. They go from the symbol to the end of # the line. ################################################################################ ## Table # Tables (also known as hash tables or dictionaries) are collections of # key/value pairs. They appear in square brackets on a line by themselves. [table] key = "value" # Yeah, you can do this. # Nested tables are denoted by table names with dots in them. Name your tables # whatever crap you please, just don't use #, ., [ or ]. [table.subtable] key = "another value" # You don't need to specify all the super-tables if you don't want to. TOML # knows how to do it for you. # [x] you # [x.y] don't # [x.y.z] need these [x.y.z.w] # for this to work ################################################################################ ## Inline Table # Inline tables provide a more compact syntax for expressing tables. They are # especially useful for grouped data that can otherwise quickly become verbose. # Inline tables are enclosed in curly braces `{` and `}`. No newlines are # allowed between the curly braces unless they are valid within a value. [table.inline] name = { first = "Tom", last = "Preston-Werner" } point = { x = 1, y = 2 } ################################################################################ ## String # There are four ways to express strings: basic, multi-line basic, literal, and # multi-line literal. All strings must contain only valid UTF-8 characters. [string.basic] basic = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF." [string.multiline] # The following strings are byte-for-byte equivalent: key1 = "One\nTwo" key2 = """One\nTwo""" key3 = """ One Two""" [string.multiline.continued] # The following strings are byte-for-byte equivalent: key1 = "The quick brown fox jumps over the lazy dog." key2 = """ The quick brown \ fox jumps over \ the lazy dog.""" key3 = """\ The quick brown \ fox jumps over \ the lazy dog.\ """ [string.literal] # What you see is what you get. winpath = 'C:\Users\nodejs\templates' winpath2 = '\\ServerX\admin$\system32\' quoted = 'Tom "Dubs" Preston-Werner' regex = '<\i\c*\s*>' [string.literal.multiline] regex2 = '''I [dw]on't need \d{2} apples''' lines = ''' The first newline is trimmed in raw strings. All other whitespace is preserved. ''' ################################################################################ ## Integer # Integers are whole numbers. Positive numbers may be prefixed with a plus sign. # Negative numbers are prefixed with a minus sign. [integer] key1 = +99 key2 = 42 key3 = 0 key4 = -17 [integer.underscores] # For large numbers, you may use underscores to enhance readability. Each # underscore must be surrounded by at least one digit. key1 = 1_000 key2 = 5_349_221 key3 = 1_2_3_4_5 # valid but inadvisable ################################################################################ ## Float # A float consists of an integer part (which may be prefixed with a plus or # minus sign) followed by a fractional part and/or an exponent part. [float.fractional] key1 = +1.0 key2 = 3.1415 key3 = -0.01 [float.exponent] [float.both] [float.underscores] ################################################################################ ## Boolean # Booleans are just the tokens you're used to. Always lowercase. [boolean] True = true False = false ################################################################################ ## Datetime # Datetimes are RFC 3339 dates. [datetime] #key1 = 1979-05-27T07:32:00Z #key2 = 1979-05-27T00:32:00-07:00 #key3 = 1979-05-27T00:32:00.999999-07:00 ################################################################################ ## Array # Arrays are square brackets with other primitives inside. Whitespace is # ignored. Elements are separated by commas. Data types may not be mixed. [array] key1 = [ 1, 2, 3 ] key2 = [ "red", "yellow", "green" ] key3 = [ [ 1, 2 ], [3, 4, 5] ] key4 = [ [ 1, 2 ], ["a", "b", "c"] ] # this is ok # Arrays can also be multiline. So in addition to ignoring whitespace, arrays # also ignore newlines between the brackets. Terminating commas are ok before # the closing bracket. key5 = [ 1, 2, 3 ] key6 = [ 1, 2, # this is ok ] ################################################################################ ## Array of Tables # These can be expressed by using a table name in double brackets. Each table # with the same double bracketed name will be an element in the array. The # tables are inserted in the order encountered. [[products]] name = "Hammer" sku = 738594937 [[products]] [[products]] name = "Nail" sku = 284758393 color = "gray" # You can create nested arrays of tables as well. [[fruit]] name = "apple" [fruit.physical] color = "red" shape = "round" [[fruit.variety]] name = "red delicious" [[fruit.variety]] name = "granny smith" [[fruit]] name = "banana" [[fruit.variety]] name = "plantain" deps/toml-0.1.25/tests/valid/string-with-pound.json0000664000175000017500000000027112351126066017167 0ustar { "pound": {"type": "string", "value": "We see no # comments here."}, "poundcomment": { "type": "string", "value": "But there are # some comments here." } } deps/toml-0.1.25/tests/valid/empty.json0000664000175000017500000000000312351126066014714 0ustar {} deps/toml-0.1.25/tests/valid/array-nospaces.toml0000664000175000017500000000001712351126066016514 0ustar ints = [1,2,3] deps/toml-0.1.25/tests/valid/key-special-chars.toml0000664000175000017500000000005512456063770017103 0ustar "~!@#$^&*()_+-`1234567890[]\\|/?><.,;:'" = 1 deps/toml-0.1.25/tests/valid/array-nospaces.json0000664000175000017500000000033212351126066016512 0ustar { "ints": { "type": "array", "value": [ {"type": "integer", "value": "1"}, {"type": "integer", "value": "2"}, {"type": "integer", "value": "3"} ] } } deps/toml-0.1.25/tests/valid/arrays.toml0000664000175000017500000000023112351126066015064 0ustar ints = [1, 2, 3] floats = [1.0, 2.0, 3.0] strings = ["a", "b", "c"] dates = [ 1987-07-05T17:45:00Z, 1979-05-27T07:32:00Z, 2006-06-01T11:00:00Z, ] deps/toml-0.1.25/tests/valid/comments-everywhere.json0000664000175000017500000000042412351126066017575 0ustar { "group": { "answer": {"type": "integer", "value": "42"}, "more": { "type": "array", "value": [ {"type": "integer", "value": "42"}, {"type": "integer", "value": "42"} ] } } } deps/toml-0.1.25/tests/valid/string-with-pound.toml0000664000175000017500000000016112351126066017167 0ustar pound = "We see no # comments here." poundcomment = "But there are # some comments here." # Did I # mess you up? deps/toml-0.1.25/tests/valid/bool.toml0000664000175000017500000000002312351126066014515 0ustar t = true f = false deps/toml-0.1.25/tests/valid/implicit-and-explicit-before.toml0000664000175000017500000000004512351126066021217 0ustar [a] better = 43 [a.b.c] answer = 42 deps/toml-0.1.25/tests/valid/integer.json0000664000175000017500000000015312351126066015221 0ustar { "answer": {"type": "integer", "value": "42"}, "neganswer": {"type": "integer", "value": "-42"} } deps/toml-0.1.25/tests/valid/string-simple.toml0000664000175000017500000000005712351126066016366 0ustar answer = "You are not drinking enough whisky." deps/toml-0.1.25/tests/valid/integer.toml0000664000175000017500000000003412351126066015221 0ustar answer = 42 neganswer = -42 deps/toml-0.1.25/tests/valid/table-array-nest.toml0000664000175000017500000000040612351126066016741 0ustar [[albums]] name = "Born to Run" [[albums.songs]] name = "Jungleland" [[albums.songs]] name = "Meeting Across the River" [[albums]] name = "Born in the USA" [[albums.songs]] name = "Glory Days" [[albums.songs]] name = "Dancing in the Dark" deps/toml-0.1.25/tests/valid/string-simple.json0000664000175000017500000000015312351126066016361 0ustar { "answer": { "type": "string", "value": "You are not drinking enough whisky." } } deps/toml-0.1.25/tests/valid/arrays-nested.json0000664000175000017500000000044112351126066016345 0ustar { "nest": { "type": "array", "value": [ {"type": "array", "value": [ {"type": "string", "value": "a"} ]}, {"type": "array", "value": [ {"type": "string", "value": "b"} ]} ] } } deps/toml-0.1.25/tests/valid/array-empty.toml0000664000175000017500000000002512351126066016036 0ustar thevoid = [[[[[]]]]] deps/toml-0.1.25/tests/valid/example2.toml0000664000175000017500000000155312456024205015306 0ustar # This is a TOML document. Boom. title = "TOML Example" [owner] name = "Tom Preston-Werner" organization = "GitHub" bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." dob = 1979-05-27T07:32:00Z # First class dates? Why not? [database] server = "192.168.1.1" ports = [ 8001, 8001, 8002 ] connection_max = 5000 enabled = true [servers] # You can indent as you please. Tabs or spaces. TOML don't care. [servers.alpha] ip = "10.0.0.1" dc = "eqdc10" [servers.beta] ip = "10.0.0.2" dc = "eqdc10" country = "中国" # This should be parsed as UTF-8 [clients] data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it # Line breaks are OK when inside arrays hosts = [ "alpha", "omega" ] # Products [[products]] name = "Hammer" sku = 738594937 [[products]] name = "Nail" sku = 284758393 color = "gray" deps/toml-0.1.25/tests/valid/table-array-one.toml0000664000175000017500000000007212351126066016550 0ustar [[people]] first_name = "Bruce" last_name = "Springsteen" deps/toml-0.1.25/tests/valid/arrays-hetergeneous.json0000664000175000017500000000104612351126066017562 0ustar { "mixed": { "type": "array", "value": [ {"type": "array", "value": [ {"type": "integer", "value": "1"}, {"type": "integer", "value": "2"} ]}, {"type": "array", "value": [ {"type": "string", "value": "a"}, {"type": "string", "value": "b"} ]}, {"type": "array", "value": [ {"type": "float", "value": "1.0"}, {"type": "float", "value": "2.0"} ]} ] } } deps/toml-0.1.25/tests/valid/example-v0.3.0.toml0000664000175000017500000000707312456036361016057 0ustar # Comment # I am a comment. Hear me roar. Roar. # Table # Tables (also known as hash tables or dictionaries) are collections of key/value pairs. # They appear in square brackets on a line by themselves. [Table] key = "value" # Yeah, you can do this. # Nested tables are denoted by table names with dots in them. Name your tables whatever crap you please, just don't use #, ., [ or ]. [dog.tater] type = "pug" # You don't need to specify all the super-tables if you don't want to. TOML knows how to do it for you. # [x] you # [x.y] don't # [x.y.z] need these [x.y.z.w] # for this to work # String # There are four ways to express strings: basic, multi-line basic, literal, and multi-line literal. # All strings must contain only valid UTF-8 characters. [String] basic = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF." [String.Multiline] # The following strings are byte-for-byte equivalent: key1 = "One\nTwo" key2 = """One\nTwo""" key3 = """ One Two""" [String.Multilined.Singleline] # The following strings are byte-for-byte equivalent: key1 = "The quick brown fox jumps over the lazy dog." key2 = """ The quick brown \ fox jumps over \ the lazy dog.""" key3 = """\ The quick brown \ fox jumps over \ the lazy dog.\ """ [String.Literal] # What you see is what you get. winpath = 'C:\Users\nodejs\templates' winpath2 = '\\ServerX\admin$\system32\' quoted = 'Tom "Dubs" Preston-Werner' regex = '<\i\c*\s*>' [String.Literal.Multiline] regex2 = '''I [dw]on't need \d{2} apples''' lines = ''' The first newline is trimmed in raw strings. All other whitespace is preserved. ''' # Integer # Integers are whole numbers. Positive numbers may be prefixed with a plus sign. # Negative numbers are prefixed with a minus sign. [Integer] key1 = +99 key2 = 42 key3 = 0 key4 = -17 # Float # A float consists of an integer part (which may be prefixed with a plus or minus sign) # followed by a fractional part and/or an exponent part. [Float.fractional] # fractional key1 = +1.0 key2 = 3.1415 key3 = -0.01 [Float.exponent] # exponent #key1 = 5e+22 #key2 = 1e6 #key3 = -2E-2 [Float.both] # both #key = 6.626e-34 # Boolean # Booleans are just the tokens you're used to. Always lowercase. [Booleans] True = true False = false # Datetime # Datetimes are RFC 3339 dates. [Datetime] key1 = 1979-05-27T07:32:00Z #key2 = 1979-05-27T00:32:00-07:00 #key3 = 1979-05-27T00:32:00.999999-07:00 # Array # Arrays are square brackets with other primitives inside. Whitespace is ignored. Elements are separated by commas. Data types may not be mixed. [Array] key1 = [ 1, 2, 3 ] key2 = [ "red", "yellow", "green" ] key3 = [ [ 1, 2 ], [3, 4, 5] ] key4 = [ [ 1, 2 ], ["a", "b", "c"] ] # this is ok #Arrays can also be multiline. So in addition to ignoring whitespace, arrays also ignore newlines between the brackets. # Terminating commas are ok before the closing bracket. key5 = [ 1, 2, 3 ] key6 = [ 1, 2, # this is ok ] # Array of Tables # These can be expressed by using a table name in double brackets. # Each table with the same double bracketed name will be an element in the array. # The tables are inserted in the order encountered. [[products]] name = "Hammer" sku = 738594937 [[products]] [[products]] name = "Nail" sku = 284758393 color = "gray" # You can create nested arrays of tables as well. [[fruit]] name = "apple" [fruit.physical] color = "red" shape = "round" [[fruit.variety]] name = "red delicious" [[fruit.variety]] name = "granny smith" [[fruit]] name = "banana" [[fruit.variety]] name = "plantain" deps/toml-0.1.25/tests/README.md0000664000175000017500000000006712351126132013047 0ustar Tests are from https://github.com/BurntSushi/toml-test deps/toml-0.1.25/tests/invalid.rs0000664000175000017500000000625312607323561013600 0ustar extern crate toml; use toml::{Parser}; fn run(toml: &str) { let mut p = Parser::new(toml); let table = p.parse(); assert!(table.is_none()); assert!(p.errors.len() > 0); // test Parser::to_linecol with the generated error offsets for error in &p.errors { p.to_linecol(error.lo); p.to_linecol(error.hi); } } macro_rules! test( ($name:ident, $toml:expr) => ( #[test] fn $name() { run($toml); } ) ); test!(array_mixed_types_arrays_and_ints, include_str!("invalid/array-mixed-types-arrays-and-ints.toml")); test!(array_mixed_types_ints_and_floats, include_str!("invalid/array-mixed-types-ints-and-floats.toml")); test!(array_mixed_types_strings_and_ints, include_str!("invalid/array-mixed-types-strings-and-ints.toml")); test!(datetime_malformed_no_leads, include_str!("invalid/datetime-malformed-no-leads.toml")); test!(datetime_malformed_no_secs, include_str!("invalid/datetime-malformed-no-secs.toml")); test!(datetime_malformed_no_t, include_str!("invalid/datetime-malformed-no-t.toml")); test!(datetime_malformed_no_z, include_str!("invalid/datetime-malformed-no-z.toml")); test!(datetime_malformed_with_milli, include_str!("invalid/datetime-malformed-with-milli.toml")); test!(duplicate_keys, include_str!("invalid/duplicate-keys.toml")); test!(duplicate_key_table, include_str!("invalid/duplicate-key-table.toml")); test!(duplicate_tables, include_str!("invalid/duplicate-tables.toml")); test!(empty_implicit_table, include_str!("invalid/empty-implicit-table.toml")); test!(empty_table, include_str!("invalid/empty-table.toml")); test!(float_no_leading_zero, include_str!("invalid/float-no-leading-zero.toml")); test!(float_no_trailing_digits, include_str!("invalid/float-no-trailing-digits.toml")); test!(key_two_equals, include_str!("invalid/key-two-equals.toml")); test!(string_bad_byte_escape, include_str!("invalid/string-bad-byte-escape.toml")); test!(string_bad_escape, include_str!("invalid/string-bad-escape.toml")); test!(string_byte_escapes, include_str!("invalid/string-byte-escapes.toml")); test!(string_no_close, include_str!("invalid/string-no-close.toml")); test!(table_array_implicit, include_str!("invalid/table-array-implicit.toml")); test!(table_array_malformed_bracket, include_str!("invalid/table-array-malformed-bracket.toml")); test!(table_array_malformed_empty, include_str!("invalid/table-array-malformed-empty.toml")); test!(table_nested_brackets_close, include_str!("invalid/table-nested-brackets-close.toml")); test!(table_nested_brackets_open, include_str!("invalid/table-nested-brackets-open.toml")); test!(text_after_array_entries, include_str!("invalid/text-after-array-entries.toml")); test!(text_after_integer, include_str!("invalid/text-after-integer.toml")); test!(text_after_string, include_str!("invalid/text-after-string.toml")); test!(text_after_table, include_str!("invalid/text-after-table.toml")); test!(text_before_array_separator, include_str!("invalid/text-before-array-separator.toml")); test!(text_in_array, include_str!("invalid/text-in-array.toml")); deps/toml-0.1.25/tests/invalid/0000755000000000000000000000000012666635520015006 5ustar rootrootdeps/toml-0.1.25/tests/invalid/text-in-array.toml0000664000175000017500000000007012351126066016617 0ustar array = [ "Entry 1", I don't belong, "Entry 2", ] deps/toml-0.1.25/tests/invalid/datetime-malformed-with-milli.toml0000664000175000017500000000004412351126066021731 0ustar with-milli = 1987-07-5T17:45:00.12Z deps/toml-0.1.25/tests/invalid/empty-table.toml0000664000175000017500000000000312351126066016332 0ustar [] deps/toml-0.1.25/tests/invalid/text-after-integer.toml0000664000175000017500000000004112351126066017627 0ustar answer = 42 the ultimate answer? deps/toml-0.1.25/tests/invalid/duplicate-tables.toml0000664000175000017500000000001012351126066017327 0ustar [a] [a] deps/toml-0.1.25/tests/invalid/text-before-array-separator.toml0000664000175000017500000000010712351126066021452 0ustar array = [ "Is there life before an array separator?" No, "Entry" ] deps/toml-0.1.25/tests/invalid/datetime-malformed-no-z.toml0000664000175000017500000000003312351126066020533 0ustar no-z = 1987-07-05T17:45:00 deps/toml-0.1.25/tests/invalid/text-after-array-entries.toml0000664000175000017500000000010612351126066020761 0ustar array = [ "Is there life after an array separator?", No "Entry" ] deps/toml-0.1.25/tests/invalid/table-array-malformed-empty.toml0000664000175000017500000000003212351126066021414 0ustar [[]] name = "Born to Run" deps/toml-0.1.25/tests/invalid/table-array-implicit.toml0000664000175000017500000000115612351126066020134 0ustar # This test is a bit tricky. It should fail because the first use of # `[[albums.songs]]` without first declaring `albums` implies that `albums` # must be a table. The alternative would be quite weird. Namely, it wouldn't # comply with the TOML spec: "Each double-bracketed sub-table will belong to # the most *recently* defined table element *above* it." # # This is in contrast to the *valid* test, table-array-implicit where # `[[albums.songs]]` works by itself, so long as `[[albums]]` isn't declared # later. (Although, `[albums]` could be.) [[albums.songs]] name = "Glory Days" [[albums]] name = "Born in the USA" deps/toml-0.1.25/tests/invalid/text-after-string.toml0000664000175000017500000000005412351126066017504 0ustar string = "Is there life after strings?" No. deps/toml-0.1.25/tests/invalid/string-bad-escape.toml0000664000175000017500000000007612351126066017411 0ustar invalid-escape = "This string has a bad \a escape character." deps/toml-0.1.25/tests/invalid/string-no-close.toml0000664000175000017500000000005212351126066017136 0ustar no-ending-quote = "One time, at band camp deps/toml-0.1.25/tests/invalid/table-nested-brackets-open.toml0000664000175000017500000000001712351126066021216 0ustar [a[b] zyx = 42 deps/toml-0.1.25/tests/invalid/array-mixed-types-ints-and-floats.toml0000664000175000017500000000003312351126066022477 0ustar ints-and-floats = [1, 1.0] deps/toml-0.1.25/tests/invalid/string-byte-escapes.toml0000664000175000017500000000002012351126066017776 0ustar answer = "\x33" deps/toml-0.1.25/tests/invalid/array-mixed-types-strings-and-ints.toml0000664000175000017500000000003612351126066022703 0ustar strings-and-ints = ["hi", 42] deps/toml-0.1.25/tests/invalid/duplicate-keys.toml0000664000175000017500000000003112351126066017033 0ustar dupe = false dupe = true deps/toml-0.1.25/tests/invalid/table-nested-brackets-close.toml0000664000175000017500000000001712351126066021362 0ustar [a]b] zyx = 42 deps/toml-0.1.25/tests/invalid/empty-implicit-table.toml0000664000175000017500000000002312351126066020144 0ustar [naughty..naughty] deps/toml-0.1.25/tests/invalid/text-after-table.toml0000664000175000017500000000003712351126066017266 0ustar [error] this shouldn't be here deps/toml-0.1.25/tests/invalid/duplicate-key-table.toml0000664000175000017500000000006312351126066017742 0ustar [fruit] type = "apple" [fruit.type] apple = "yes" deps/toml-0.1.25/tests/invalid/datetime-malformed-no-secs.toml0000664000175000017500000000003412351126066021220 0ustar no-secs = 1987-07-05T17:45Z deps/toml-0.1.25/tests/invalid/datetime-malformed-no-t.toml0000664000175000017500000000003312351126066020525 0ustar no-t = 1987-07-0517:45:00Z deps/toml-0.1.25/tests/invalid/table-array-malformed-bracket.toml0000664000175000017500000000003712351126066021676 0ustar [[albums] name = "Born to Run" deps/toml-0.1.25/tests/invalid/string-bad-byte-escape.toml0000664000175000017500000000002112351126066020340 0ustar naughty = "\xAg" deps/toml-0.1.25/tests/invalid/array-mixed-types-arrays-and-ints.toml0000664000175000017500000000006512351126066022515 0ustar arrays-and-ints = [1, ["Arrays are not integers."]] deps/toml-0.1.25/tests/invalid/float-no-trailing-digits.toml0000664000175000017500000000003412351126066020722 0ustar answer = 1. neganswer = -1. deps/toml-0.1.25/tests/invalid/datetime-malformed-no-leads.toml0000664000175000017500000000003712351126066021356 0ustar no-leads = 1987-7-05T17:45:00Z deps/toml-0.1.25/tests/invalid/key-two-equals.toml0000664000175000017500000000001112351126066016775 0ustar key= = 1 deps/toml-0.1.25/tests/invalid/float-no-leading-zero.toml0000664000175000017500000000004412351126066020211 0ustar answer = .12345 neganswer = -.12345 deps/toml-0.1.25/tests/valid.rs0000664000175000017500000001545012607323561013250 0ustar extern crate rustc_serialize; extern crate toml; use std::collections::BTreeMap; use rustc_serialize::json::Json; use toml::{Parser, Value}; use toml::Value::{Table, Integer, Float, Boolean, Datetime, Array}; fn to_json(toml: Value) -> Json { fn doit(s: &str, json: Json) -> Json { let mut map = BTreeMap::new(); map.insert(format!("{}", "type"), Json::String(format!("{}", s))); map.insert(format!("{}", "value"), json); Json::Object(map) } match toml { Value::String(s) => doit("string", Json::String(s)), Integer(i) => doit("integer", Json::String(format!("{}", i))), Float(f) => doit("float", Json::String({ let s = format!("{:.15}", f); let s = format!("{}", s.trim_right_matches('0')); if s.ends_with(".") {format!("{}0", s)} else {s} })), Boolean(b) => doit("bool", Json::String(format!("{}", b))), Datetime(s) => doit("datetime", Json::String(s)), Array(arr) => { let is_table = match arr.first() { Some(&Table(..)) => true, _ => false, }; let json = Json::Array(arr.into_iter().map(to_json).collect()); if is_table {json} else {doit("array", json)} } Table(table) => Json::Object(table.into_iter().map(|(k, v)| { (k, to_json(v)) }).collect()), } } fn run(toml: &str, json: &str) { let mut p = Parser::new(toml); let table = p.parse(); assert!(p.errors.len() == 0, "had_errors: {:?}", p.errors.iter().map(|e| { (e.desc.clone(), &toml[e.lo - 5..e.hi + 5]) }).collect::>()); assert!(table.is_some()); let toml = Table(table.unwrap()); let toml_string = format!("{}", toml); let json = Json::from_str(json).unwrap(); let toml_json = to_json(toml.clone()); assert!(json == toml_json, "expected\n{}\ngot\n{}\n", json.pretty(), toml_json.pretty()); let table2 = Parser::new(&toml_string).parse().unwrap(); // floats are a little lossy if table2.values().any(|v| v.as_float().is_some()) { return } assert_eq!(toml, Table(table2)); } macro_rules! test( ($name:ident, $toml:expr, $json:expr) => ( #[test] fn $name() { run($toml, $json); } ) ); test!(array_empty, include_str!("valid/array-empty.toml"), include_str!("valid/array-empty.json")); test!(array_nospaces, include_str!("valid/array-nospaces.toml"), include_str!("valid/array-nospaces.json")); test!(arrays_hetergeneous, include_str!("valid/arrays-hetergeneous.toml"), include_str!("valid/arrays-hetergeneous.json")); test!(arrays, include_str!("valid/arrays.toml"), include_str!("valid/arrays.json")); test!(arrays_nested, include_str!("valid/arrays-nested.toml"), include_str!("valid/arrays-nested.json")); test!(empty, include_str!("valid/empty.toml"), include_str!("valid/empty.json")); test!(bool, include_str!("valid/bool.toml"), include_str!("valid/bool.json")); test!(datetime, include_str!("valid/datetime.toml"), include_str!("valid/datetime.json")); test!(example, include_str!("valid/example.toml"), include_str!("valid/example.json")); test!(float, include_str!("valid/float.toml"), include_str!("valid/float.json")); test!(implicit_and_explicit_after, include_str!("valid/implicit-and-explicit-after.toml"), include_str!("valid/implicit-and-explicit-after.json")); test!(implicit_and_explicit_before, include_str!("valid/implicit-and-explicit-before.toml"), include_str!("valid/implicit-and-explicit-before.json")); test!(implicit_groups, include_str!("valid/implicit-groups.toml"), include_str!("valid/implicit-groups.json")); test!(integer, include_str!("valid/integer.toml"), include_str!("valid/integer.json")); test!(key_equals_nospace, include_str!("valid/key-equals-nospace.toml"), include_str!("valid/key-equals-nospace.json")); test!(key_special_chars, include_str!("valid/key-special-chars.toml"), include_str!("valid/key-special-chars.json")); test!(key_with_pound, include_str!("valid/key-with-pound.toml"), include_str!("valid/key-with-pound.json")); test!(long_float, include_str!("valid/long-float.toml"), include_str!("valid/long-float.json")); test!(long_integer, include_str!("valid/long-integer.toml"), include_str!("valid/long-integer.json")); test!(string_empty, include_str!("valid/string-empty.toml"), include_str!("valid/string-empty.json")); test!(string_escapes, include_str!("valid/string-escapes.toml"), include_str!("valid/string-escapes.json")); test!(string_simple, include_str!("valid/string-simple.toml"), include_str!("valid/string-simple.json")); test!(string_with_pound, include_str!("valid/string-with-pound.toml"), include_str!("valid/string-with-pound.json")); test!(table_array_implicit, include_str!("valid/table-array-implicit.toml"), include_str!("valid/table-array-implicit.json")); test!(table_array_many, include_str!("valid/table-array-many.toml"), include_str!("valid/table-array-many.json")); test!(table_array_nest, include_str!("valid/table-array-nest.toml"), include_str!("valid/table-array-nest.json")); test!(table_array_one, include_str!("valid/table-array-one.toml"), include_str!("valid/table-array-one.json")); test!(table_empty, include_str!("valid/table-empty.toml"), include_str!("valid/table-empty.json")); test!(table_sub_empty, include_str!("valid/table-sub-empty.toml"), include_str!("valid/table-sub-empty.json")); test!(table_whitespace, include_str!("valid/table-whitespace.toml"), include_str!("valid/table-whitespace.json")); test!(table_with_pound, include_str!("valid/table-with-pound.toml"), include_str!("valid/table-with-pound.json")); test!(unicode_escape, include_str!("valid/unicode-escape.toml"), include_str!("valid/unicode-escape.json")); test!(unicode_literal, include_str!("valid/unicode-literal.toml"), include_str!("valid/unicode-literal.json")); test!(hard_example, include_str!("valid/hard_example.toml"), include_str!("valid/hard_example.json")); test!(example2, include_str!("valid/example2.toml"), include_str!("valid/example2.json")); test!(example3, include_str!("valid/example-v0.3.0.toml"), include_str!("valid/example-v0.3.0.json")); test!(example4, include_str!("valid/example-v0.4.0.toml"), include_str!("valid/example-v0.4.0.json")); test!(example_bom, include_str!("valid/example-bom.toml"), include_str!("valid/example.json")); deps/toml-0.1.25/tests/invalid-encoder/0000755000000000000000000000000012666635520016423 5ustar rootrootdeps/toml-0.1.25/tests/invalid-encoder/array-mixed-types-ints-and-floats.json0000664000175000017500000000042212351126066024114 0ustar { "ints-and-floats": { "type": "array", "value": [ { "type": "integer", "value": "1" }, { "type": "float", "value": "1.0" } ] } } deps/toml-0.1.25/Cargo.toml0000664000175000017500000000137612635122346012372 0ustar [package] name = "toml" version = "0.1.25" authors = ["Alex Crichton "] license = "MIT/Apache-2.0" readme = "README.md" keywords = ["encoding"] repository = "https://github.com/alexcrichton/toml-rs" homepage = "https://github.com/alexcrichton/toml-rs" documentation = "http://alexcrichton.com/toml-rs" description = """ A native Rust encoder and decoder of TOML-formatted files and streams. Provides implementations of the standard Encodable/Decodable traits for TOML data to facilitate deserializing and serializing Rust structures. """ [dependencies] rustc-serialize = { optional = true, version = "0.3.0" } serde = { optional = true, version = "0.6" } [features] default = ["rustc-serialize"] [dev-dependencies] rustc-serialize = "0.3" deps/url-0.2.38/0000755000000000000000000000000012666635521012053 5ustar rootrootdeps/url-0.2.38/LICENSE-APACHE0000644000175000017500000002513712356035240012215 0ustar Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/url-0.2.38/LICENSE-MIT0000644000175000017500000000212112356035240011711 0ustar Copyright (c) 2006-2009 Graydon Hoare Copyright (c) 2009-2013 Mozilla Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/url-0.2.38/.travis.yml0000644000175000017500000000061312563127736012406 0ustar language: rust rust: - nightly - beta - stable script: make test after_success: "[ $TRAVIS_RUST_VERSION == master ] && make upload-doc" env: - secure: Q5eFkWSv20gCxMXrF1BPBSY67qAi9XYKsGHbOc6c1hOf933AX9Wr2CqL8mBhgAZfe4TWEnazjMNHmVIs75W+DPRkxVjImDmPLlQSDNuQFKBGATL5rnx7UzgT7t6CZhG+aPr50VVuC/3IL1+Ok85DjT/LnOKaao3r+Wd+HMFVViM= notifications: webhooks: http://build.servo.org:54856/travis deps/url-0.2.38/README.md0000644000175000017500000000066412562227256011557 0ustar rust-url ======== [![Travis build Status](https://travis-ci.org/servo/rust-url.svg?branch=master)](https://travis-ci.org/servo/rust-url) [![Appveyor build status](https://ci.appveyor.com/api/projects/status/ulkqx2xcemyod6xa?svg=true)](https://ci.appveyor.com/project/Manishearth/rust-url) URL library for Rust, based on the [URL Standard](http://url.spec.whatwg.org/). [Documentation](http://servo.github.io/rust-url/url/index.html) deps/url-0.2.38/.gitignore0000644000175000017500000000004312450251107012243 0ustar /target /Cargo.lock /.cargo/config deps/url-0.2.38/src/0000755000000000000000000000000012666635521012642 5ustar rootrootdeps/url-0.2.38/src/punycode_tests.json0000644000175000017500000001037512475610535015031 0ustar [ { "description": "These tests are copied from https://github.com/bestiejs/punycode.js/blob/master/tests/tests.js , used under the MIT license.", "decoded": "", "encoded": "" }, { "description": "a single basic code point", "decoded": "Bach", "encoded": "Bach-" }, { "description": "a single non-ASCII character", "decoded": "\u00FC", "encoded": "tda" }, { "description": "multiple non-ASCII characters", "decoded": "\u00FC\u00EB\u00E4\u00F6\u2665", "encoded": "4can8av2009b" }, { "description": "mix of ASCII and non-ASCII characters", "decoded": "b\u00FCcher", "encoded": "bcher-kva" }, { "description": "long string with both ASCII and non-ASCII characters", "decoded": "Willst du die Bl\u00FCthe des fr\u00FChen, die Fr\u00FCchte des sp\u00E4teren Jahres", "encoded": "Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal" }, { "description": "Arabic (Egyptian)", "decoded": "\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644\u0645\u0648\u0634\u0639\u0631\u0628\u064A\u061F", "encoded": "egbpdaj6bu4bxfgehfvwxn" }, { "description": "Chinese (simplified)", "decoded": "\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2d\u6587", "encoded": "ihqwcrb4cv8a8dqg056pqjye" }, { "description": "Chinese (traditional)", "decoded": "\u4ED6\u5011\u7232\u4EC0\u9EBD\u4E0D\u8AAA\u4E2D\u6587", "encoded": "ihqwctvzc91f659drss3x8bo0yb" }, { "description": "Czech", "decoded": "Pro\u010Dprost\u011Bnemluv\u00ED\u010Desky", "encoded": "Proprostnemluvesky-uyb24dma41a" }, { "description": "Hebrew", "decoded": "\u05DC\u05DE\u05D4\u05D4\u05DD\u05E4\u05E9\u05D5\u05D8\u05DC\u05D0\u05DE\u05D3\u05D1\u05E8\u05D9\u05DD\u05E2\u05D1\u05E8\u05D9\u05EA", "encoded": "4dbcagdahymbxekheh6e0a7fei0b" }, { "description": "Hindi (Devanagari)", "decoded": "\u092F\u0939\u0932\u094B\u0917\u0939\u093F\u0928\u094D\u0926\u0940\u0915\u094D\u092F\u094B\u0902\u0928\u0939\u0940\u0902\u092C\u094B\u0932\u0938\u0915\u0924\u0947\u0939\u0948\u0902", "encoded": "i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd" }, { "description": "Japanese (kanji and hiragana)", "decoded": "\u306A\u305C\u307F\u3093\u306A\u65E5\u672C\u8A9E\u3092\u8A71\u3057\u3066\u304F\u308C\u306A\u3044\u306E\u304B", "encoded": "n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa" }, { "description": "Korean (Hangul syllables)", "decoded": "\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774\uD55C\uAD6D\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74\uC5BC\uB9C8\uB098\uC88B\uC744\uAE4C", "encoded": "989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879ccm6fea98c" }, { "description": "Russian (Cyrillic)", "decoded": "\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E\u043D\u0438\u043D\u0435\u0433\u043E\u0432\u043E\u0440\u044F\u0442\u043F\u043E\u0440\u0443\u0441\u0441\u043A\u0438", "encoded": "b1abfaaepdrnnbgefbadotcwatmq2g4l" }, { "description": "Spanish", "decoded": "Porqu\u00E9nopuedensimplementehablarenEspa\u00F1ol", "encoded": "PorqunopuedensimplementehablarenEspaol-fmd56a" }, { "description": "Vietnamese", "decoded": "T\u1EA1isaoh\u1ECDkh\u00F4ngth\u1EC3ch\u1EC9n\u00F3iti\u1EBFngVi\u1EC7t", "encoded": "TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g" }, { "decoded": "3\u5E74B\u7D44\u91D1\u516B\u5148\u751F", "encoded": "3B-ww4c5e180e575a65lsy2b" }, { "decoded": "\u5B89\u5BA4\u5948\u7F8E\u6075-with-SUPER-MONKEYS", "encoded": "-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n" }, { "decoded": "Hello-Another-Way-\u305D\u308C\u305E\u308C\u306E\u5834\u6240", "encoded": "Hello-Another-Way--fc4qua05auwb3674vfr0b" }, { "decoded": "\u3072\u3068\u3064\u5C4B\u6839\u306E\u4E0B2", "encoded": "2-u9tlzr9756bt3uc0v" }, { "decoded": "Maji\u3067Koi\u3059\u308B5\u79D2\u524D", "encoded": "MajiKoi5-783gue6qz075azm5e" }, { "decoded": "\u30D1\u30D5\u30A3\u30FCde\u30EB\u30F3\u30D0", "encoded": "de-jg4avhby1noc0d" }, { "decoded": "\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067", "encoded": "d9juau41awczczp" }, { "description": "ASCII string that breaks the existing rules for host-name labels (It's not a realistic example for IDNA, because IDNA never encodes pure ASCII labels.)", "decoded": "-> $1.00 <-", "encoded": "-> $1.00 <--" } ] deps/url-0.2.38/src/parser.rs0000644000175000017500000006701112562230224012715 0ustar // Copyright 2013-2014 Simon Sapin. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::ascii::AsciiExt; use std::cmp::max; use std::error::Error; use std::fmt::{self, Formatter}; use super::{UrlParser, Url, SchemeData, RelativeSchemeData, Host, SchemeType}; use percent_encoding::{ utf8_percent_encode_to, percent_encode, SIMPLE_ENCODE_SET, DEFAULT_ENCODE_SET, USERINFO_ENCODE_SET, QUERY_ENCODE_SET }; pub type ParseResult = Result; macro_rules! simple_enum_error { ($($name: ident => $description: expr,)+) => { /// Errors that can occur during parsing. #[derive(PartialEq, Eq, Clone, Copy, Debug)] pub enum ParseError { $( $name, )+ } impl Error for ParseError { fn description(&self) -> &str { match *self { $( ParseError::$name => $description, )+ } } } } } simple_enum_error! { EmptyHost => "empty host", InvalidScheme => "invalid scheme", InvalidPort => "invalid port number", InvalidIpv6Address => "invalid IPv6 address", InvalidDomainCharacter => "invalid domain character", InvalidCharacter => "invalid character", InvalidBackslash => "invalid backslash", InvalidPercentEncoded => "invalid percent-encoded sequence", InvalidAtSymbolInUser => "invalid @-symbol in user", ExpectedTwoSlashes => "expected two slashes (//)", ExpectedInitialSlash => "expected the input to start with a slash", NonUrlCodePoint => "non URL code point", RelativeUrlWithScheme => "relative URL with scheme", RelativeUrlWithoutBase => "relative URL without a base", RelativeUrlWithNonRelativeBase => "relative URL with a non-relative base", NonAsciiDomainsNotSupportedYet => "non-ASCII domains are not supported yet", CannotSetJavascriptFragment => "cannot set fragment on javascript: URL", CannotSetPortWithFileLikeScheme => "cannot set port with file-like scheme", CannotSetUsernameWithNonRelativeScheme => "cannot set username with non-relative scheme", CannotSetPasswordWithNonRelativeScheme => "cannot set password with non-relative scheme", CannotSetHostPortWithNonRelativeScheme => "cannot set host and port with non-relative scheme", CannotSetHostWithNonRelativeScheme => "cannot set host with non-relative scheme", CannotSetPortWithNonRelativeScheme => "cannot set port with non-relative scheme", CannotSetPathWithNonRelativeScheme => "cannot set path with non-relative scheme", } impl fmt::Display for ParseError { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { self.description().fmt(fmt) } } /// This is called on non-fatal parse errors. /// /// The handler can choose to continue or abort parsing by returning Ok() or Err(), respectively. /// See the `UrlParser::error_handler` method. /// /// FIXME: make this a by-ref closure when that’s supported. pub type ErrorHandler = fn(reason: ParseError) -> ParseResult<()>; #[derive(PartialEq, Eq)] pub enum Context { UrlParser, Setter, } pub fn parse_url(input: &str, parser: &UrlParser) -> ParseResult { let input = input.trim_matches(&[' ', '\t', '\n', '\r', '\x0C'][..]); let (scheme, remaining) = match parse_scheme(input, Context::UrlParser) { Some((scheme, remaining)) => (scheme, remaining), // No-scheme state None => return match parser.base_url { Some(&Url { ref scheme, scheme_data: SchemeData::Relative(ref base), ref query, .. }) => { let scheme_type = parser.get_scheme_type(&scheme); parse_relative_url(input, scheme.clone(), scheme_type, base, query, parser) }, Some(_) => Err(ParseError::RelativeUrlWithNonRelativeBase), None => Err(ParseError::RelativeUrlWithoutBase), }, }; let scheme_type = parser.get_scheme_type(&scheme); match scheme_type { SchemeType::FileLike => { // Relative state? match parser.base_url { Some(&Url { scheme: ref base_scheme, scheme_data: SchemeData::Relative(ref base), ref query, .. }) if scheme == *base_scheme => { parse_relative_url(remaining, scheme, scheme_type, base, query, parser) }, // FIXME: Should not have to use a made-up base URL. _ => parse_relative_url(remaining, scheme, scheme_type, &RelativeSchemeData { username: String::new(), password: None, host: Host::Domain(String::new()), port: None, default_port: None, path: Vec::new() }, &None, parser) } }, SchemeType::Relative(..) => { match parser.base_url { Some(&Url { scheme: ref base_scheme, scheme_data: SchemeData::Relative(ref base), ref query, .. }) if scheme == *base_scheme && !remaining.starts_with("//") => { try!(parser.parse_error(ParseError::RelativeUrlWithScheme)); parse_relative_url(remaining, scheme, scheme_type, base, query, parser) }, _ => parse_absolute_url(scheme, scheme_type, remaining, parser), } }, SchemeType::NonRelative => { // Scheme data state let (scheme_data, remaining) = try!(parse_scheme_data(remaining, parser)); let (query, fragment) = try!(parse_query_and_fragment(remaining, parser)); Ok(Url { scheme: scheme, scheme_data: SchemeData::NonRelative(scheme_data), query: query, fragment: fragment }) } } } pub fn parse_scheme<'a>(input: &'a str, context: Context) -> Option<(String, &'a str)> { if input.is_empty() || !starts_with_ascii_alpha(input) { return None } for (i, c) in input.char_indices() { match c { 'a'...'z' | 'A'...'Z' | '0'...'9' | '+' | '-' | '.' => (), ':' => return Some(( input[..i].to_ascii_lowercase(), &input[i + 1..], )), _ => return None, } } // EOF before ':' match context { Context::Setter => Some((input.to_ascii_lowercase(), "")), Context::UrlParser => None } } fn parse_absolute_url<'a>(scheme: String, scheme_type: SchemeType, input: &'a str, parser: &UrlParser) -> ParseResult { // Authority first slash state let remaining = try!(skip_slashes(input, parser)); // Authority state let (username, password, remaining) = try!(parse_userinfo(remaining, parser)); // Host state let (host, port, default_port, remaining) = try!(parse_host(remaining, scheme_type, parser)); let (path, remaining) = try!(parse_path_start( remaining, Context::UrlParser, scheme_type, parser)); let scheme_data = SchemeData::Relative(RelativeSchemeData { username: username, password: password, host: host, port: port, default_port: default_port, path: path }); let (query, fragment) = try!(parse_query_and_fragment(remaining, parser)); Ok(Url { scheme: scheme, scheme_data: scheme_data, query: query, fragment: fragment }) } fn parse_relative_url<'a>(input: &'a str, scheme: String, scheme_type: SchemeType, base: &RelativeSchemeData, base_query: &Option, parser: &UrlParser) -> ParseResult { let mut chars = input.chars(); match chars.next() { Some('/') | Some('\\') => { let ch = chars.next(); // Relative slash state if matches!(ch, Some('/') | Some('\\')) { if ch == Some('\\') { try!(parser.parse_error(ParseError::InvalidBackslash)) } if scheme_type == SchemeType::FileLike { // File host state let remaining = &input[2..]; let (host, remaining) = if remaining.len() >= 2 && starts_with_ascii_alpha(remaining) && matches!(remaining.as_bytes()[1], b':' | b'|') && (remaining.len() == 2 || matches!(remaining.as_bytes()[2], b'/' | b'\\' | b'?' | b'#')) { // Windows drive letter quirk (Host::Domain(String::new()), remaining) } else { try!(parse_file_host(remaining, parser)) }; let (path, remaining) = try!(parse_path_start( remaining, Context::UrlParser, scheme_type, parser)); let scheme_data = SchemeData::Relative(RelativeSchemeData { username: String::new(), password: None, host: host, port: None, default_port: None, path: path }); let (query, fragment) = try!(parse_query_and_fragment(remaining, parser)); Ok(Url { scheme: scheme, scheme_data: scheme_data, query: query, fragment: fragment }) } else { parse_absolute_url(scheme, scheme_type, input, parser) } } else { // Relative path state let (path, remaining) = try!(parse_path( &[], &input[1..], Context::UrlParser, scheme_type, parser)); let scheme_data = SchemeData::Relative(if scheme_type == SchemeType::FileLike { RelativeSchemeData { username: String::new(), password: None, host: Host::Domain(String::new()), port: None, default_port: None, path: path } } else { RelativeSchemeData { username: base.username.clone(), password: base.password.clone(), host: base.host.clone(), port: base.port.clone(), default_port: base.default_port.clone(), path: path } }); let (query, fragment) = try!( parse_query_and_fragment(remaining, parser)); Ok(Url { scheme: scheme, scheme_data: scheme_data, query: query, fragment: fragment }) } }, Some('?') => { let (query, fragment) = try!(parse_query_and_fragment(input, parser)); Ok(Url { scheme: scheme, scheme_data: SchemeData::Relative(base.clone()), query: query, fragment: fragment }) }, Some('#') => { let fragment = Some(try!(parse_fragment(&input[1..], parser))); Ok(Url { scheme: scheme, scheme_data: SchemeData::Relative(base.clone()), query: base_query.clone(), fragment: fragment }) } None => { Ok(Url { scheme: scheme, scheme_data: SchemeData::Relative(base.clone()), query: base_query.clone(), fragment: None }) } _ => { let (scheme_data, remaining) = if scheme_type == SchemeType::FileLike && input.len() >= 2 && starts_with_ascii_alpha(input) && matches!(input.as_bytes()[1], b':' | b'|') && (input.len() == 2 || matches!(input.as_bytes()[2], b'/' | b'\\' | b'?' | b'#')) { // Windows drive letter quirk let (path, remaining) = try!(parse_path( &[], input, Context::UrlParser, scheme_type, parser)); (SchemeData::Relative(RelativeSchemeData { username: String::new(), password: None, host: Host::Domain(String::new()), port: None, default_port: None, path: path }), remaining) } else { let base_path = &base.path[..max(base.path.len(), 1) - 1]; // Relative path state let (path, remaining) = try!(parse_path( base_path, input, Context::UrlParser, scheme_type, parser)); (SchemeData::Relative(RelativeSchemeData { username: base.username.clone(), password: base.password.clone(), host: base.host.clone(), port: base.port.clone(), default_port: base.default_port.clone(), path: path }), remaining) }; let (query, fragment) = try!(parse_query_and_fragment(remaining, parser)); Ok(Url { scheme: scheme, scheme_data: scheme_data, query: query, fragment: fragment }) } } } fn skip_slashes<'a>(input: &'a str, parser: &UrlParser) -> ParseResult<&'a str> { let first_non_slash = input.find(|c| !matches!(c, '/' | '\\')).unwrap_or(input.len()); if &input[..first_non_slash] != "//" { try!(parser.parse_error(ParseError::ExpectedTwoSlashes)); } Ok(&input[first_non_slash..]) } fn parse_userinfo<'a>(input: &'a str, parser: &UrlParser) -> ParseResult<(String, Option, &'a str)> { let mut last_at = None; for (i, c) in input.char_indices() { match c { '@' => { if last_at.is_some() { try!(parser.parse_error(ParseError::InvalidAtSymbolInUser)) } last_at = Some(i) }, '/' | '\\' | '?' | '#' => break, _ => (), } } let (input, remaining) = match last_at { Some(at) => (&input[..at], &input[at + 1..]), None => return Ok((String::new(), None, input)), }; let mut username = String::new(); let mut password = None; for (i, c, next_i) in input.char_ranges() { match c { ':' => { password = Some(try!(parse_password(&input[i + 1..], parser))); break }, '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), _ => { try!(check_url_code_point(input, i, c, parser)); // The spec says to use the default encode set, // but also replaces '@' by '%40' in an earlier step. utf8_percent_encode_to(&input[i..next_i], USERINFO_ENCODE_SET, &mut username); } } } Ok((username, password, remaining)) } fn parse_password(input: &str, parser: &UrlParser) -> ParseResult { let mut password = String::new(); for (i, c, next_i) in input.char_ranges() { match c { '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), _ => { try!(check_url_code_point(input, i, c, parser)); // The spec says to use the default encode set, // but also replaces '@' by '%40' in an earlier step. utf8_percent_encode_to(&input[i..next_i], USERINFO_ENCODE_SET, &mut password); } } } Ok(password) } pub fn parse_host<'a>(input: &'a str, scheme_type: SchemeType, parser: &UrlParser) -> ParseResult<(Host, Option, Option, &'a str)> { let (host, remaining) = try!(parse_hostname(input, parser)); let (port, default_port, remaining) = if remaining.starts_with(":") { try!(parse_port(&remaining[1..], scheme_type, parser)) } else { (None, scheme_type.default_port(), remaining) }; Ok((host, port, default_port, remaining)) } pub fn parse_hostname<'a>(input: &'a str, parser: &UrlParser) -> ParseResult<(Host, &'a str)> { let mut inside_square_brackets = false; let mut host_input = String::new(); let mut end = input.len(); for (i, c) in input.char_indices() { match c { ':' if !inside_square_brackets => { end = i; break }, '/' | '\\' | '?' | '#' => { end = i; break }, '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), c => { match c { '[' => inside_square_brackets = true, ']' => inside_square_brackets = false, _ => (), } host_input.push(c) } } } let host = try!(Host::parse(&host_input)); Ok((host, &input[end..])) } pub fn parse_port<'a>(input: &'a str, scheme_type: SchemeType, parser: &UrlParser) -> ParseResult<(Option, Option, &'a str)> { let mut port = 0; let mut has_any_digit = false; let mut end = input.len(); for (i, c) in input.char_indices() { match c { '0'...'9' => { port = port * 10 + (c as u32 - '0' as u32); if port > ::std::u16::MAX as u32 { return Err(ParseError::InvalidPort) } has_any_digit = true; }, '/' | '\\' | '?' | '#' => { end = i; break }, '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), _ => return Err(ParseError::InvalidPort) } } let default_port = scheme_type.default_port(); let mut port = Some(port as u16); if !has_any_digit || port == default_port { port = None; } return Ok((port, default_port, &input[end..])) } fn parse_file_host<'a>(input: &'a str, parser: &UrlParser) -> ParseResult<(Host, &'a str)> { let mut host_input = String::new(); let mut end = input.len(); for (i, c) in input.char_indices() { match c { '/' | '\\' | '?' | '#' => { end = i; break }, '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), _ => host_input.push(c) } } let host = if host_input.is_empty() { Host::Domain(String::new()) } else { try!(Host::parse(&host_input)) }; Ok((host, &input[end..])) } pub fn parse_standalone_path(input: &str, parser: &UrlParser) -> ParseResult<(Vec, Option, Option)> { if !input.starts_with("/") { if input.starts_with("\\") { try!(parser.parse_error(ParseError::InvalidBackslash)); } else { return Err(ParseError::ExpectedInitialSlash) } } let (path, remaining) = try!(parse_path( &[], &input[1..], Context::UrlParser, SchemeType::Relative(0), parser)); let (query, fragment) = try!(parse_query_and_fragment(remaining, parser)); Ok((path, query, fragment)) } pub fn parse_path_start<'a>(input: &'a str, context: Context, scheme_type: SchemeType, parser: &UrlParser) -> ParseResult<(Vec, &'a str)> { let mut i = 0; // Relative path start state match input.chars().next() { Some('/') => i = 1, Some('\\') => { try!(parser.parse_error(ParseError::InvalidBackslash)); i = 1; }, _ => () } parse_path(&[], &input[i..], context, scheme_type, parser) } fn parse_path<'a>(base_path: &[String], input: &'a str, context: Context, scheme_type: SchemeType, parser: &UrlParser) -> ParseResult<(Vec, &'a str)> { // Relative path state let mut path = base_path.to_vec(); let mut iter = input.char_ranges(); let mut end; loop { let mut path_part = String::new(); let mut ends_with_slash = false; end = input.len(); while let Some((i, c, next_i)) = iter.next() { match c { '/' => { ends_with_slash = true; end = i; break }, '\\' => { try!(parser.parse_error(ParseError::InvalidBackslash)); ends_with_slash = true; end = i; break }, '?' | '#' if context == Context::UrlParser => { end = i; break }, '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), _ => { try!(check_url_code_point(input, i, c, parser)); utf8_percent_encode_to(&input[i..next_i], DEFAULT_ENCODE_SET, &mut path_part); } } } match &*path_part { ".." | ".%2e" | ".%2E" | "%2e." | "%2E." | "%2e%2e" | "%2E%2e" | "%2e%2E" | "%2E%2E" => { path.pop(); if !ends_with_slash { path.push(String::new()); } }, "." | "%2e" | "%2E" => { if !ends_with_slash { path.push(String::new()); } }, _ => { if scheme_type == SchemeType::FileLike && path.is_empty() && path_part.len() == 2 && starts_with_ascii_alpha(&path_part) && path_part.as_bytes()[1] == b'|' { // Windows drive letter quirk unsafe { path_part.as_mut_vec()[1] = b':' } } path.push(path_part) } } if !ends_with_slash { break } } Ok((path, &input[end..])) } fn parse_scheme_data<'a>(input: &'a str, parser: &UrlParser) -> ParseResult<(String, &'a str)> { let mut scheme_data = String::new(); let mut end = input.len(); for (i, c, next_i) in input.char_ranges() { match c { '?' | '#' => { end = i; break }, '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), _ => { try!(check_url_code_point(input, i, c, parser)); utf8_percent_encode_to(&input[i..next_i], SIMPLE_ENCODE_SET, &mut scheme_data); } } } Ok((scheme_data, &input[end..])) } fn parse_query_and_fragment(input: &str, parser: &UrlParser) -> ParseResult<(Option, Option)> { match input.chars().next() { Some('#') => Ok((None, Some(try!(parse_fragment(&input[1..], parser))))), Some('?') => { let (query, remaining) = try!(parse_query( &input[1..], Context::UrlParser, parser)); let fragment = match remaining { Some(remaining) => Some(try!(parse_fragment(remaining, parser))), None => None }; Ok((Some(query), fragment)) }, None => Ok((None, None)), _ => panic!("Programming error. parse_query_and_fragment() should not \ have been called with input \"{}\"", input) } } pub fn parse_query<'a>(input: &'a str, context: Context, parser: &UrlParser) -> ParseResult<(String, Option<&'a str>)> { let mut query = String::new(); let mut remaining = None; for (i, c) in input.char_indices() { match c { '#' if context == Context::UrlParser => { remaining = Some(&input[i + 1..]); break }, '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), _ => { try!(check_url_code_point(input, i, c, parser)); query.push(c); } } } let query_bytes = parser.query_encoding_override.encode(&query); Ok((percent_encode(&query_bytes, QUERY_ENCODE_SET), remaining)) } pub fn parse_fragment<'a>(input: &'a str, parser: &UrlParser) -> ParseResult { let mut fragment = String::new(); for (i, c, next_i) in input.char_ranges() { match c { '\t' | '\n' | '\r' => try!(parser.parse_error(ParseError::InvalidCharacter)), _ => { try!(check_url_code_point(input, i, c, parser)); utf8_percent_encode_to(&input[i..next_i], SIMPLE_ENCODE_SET, &mut fragment); } } } Ok(fragment) } #[inline] pub fn starts_with_ascii_alpha(string: &str) -> bool { matches!(string.as_bytes()[0], b'a'...b'z' | b'A'...b'Z') } #[inline] fn is_ascii_hex_digit(byte: u8) -> bool { matches!(byte, b'a'...b'f' | b'A'...b'F' | b'0'...b'9') } #[inline] fn starts_with_2_hex(input: &str) -> bool { input.len() >= 2 && is_ascii_hex_digit(input.as_bytes()[0]) && is_ascii_hex_digit(input.as_bytes()[1]) } #[inline] fn is_url_code_point(c: char) -> bool { matches!(c, 'a'...'z' | 'A'...'Z' | '0'...'9' | '!' | '$' | '&' | '\'' | '(' | ')' | '*' | '+' | ',' | '-' | '.' | '/' | ':' | ';' | '=' | '?' | '@' | '_' | '~' | '\u{A0}'...'\u{D7FF}' | '\u{E000}'...'\u{FDCF}' | '\u{FDF0}'...'\u{FFFD}' | '\u{10000}'...'\u{1FFFD}' | '\u{20000}'...'\u{2FFFD}' | '\u{30000}'...'\u{3FFFD}' | '\u{40000}'...'\u{4FFFD}' | '\u{50000}'...'\u{5FFFD}' | '\u{60000}'...'\u{6FFFD}' | '\u{70000}'...'\u{7FFFD}' | '\u{80000}'...'\u{8FFFD}' | '\u{90000}'...'\u{9FFFD}' | '\u{A0000}'...'\u{AFFFD}' | '\u{B0000}'...'\u{BFFFD}' | '\u{C0000}'...'\u{CFFFD}' | '\u{D0000}'...'\u{DFFFD}' | '\u{E1000}'...'\u{EFFFD}' | '\u{F0000}'...'\u{FFFFD}' | '\u{100000}'...'\u{10FFFD}') } // Non URL code points: // U+0000 to U+0020 (space) // " # % < > [ \ ] ^ ` { | } // U+007F to U+009F // surrogates // U+FDD0 to U+FDEF // Last two of each plane: U+__FFFE to U+__FFFF for __ in 00 to 10 hex pub trait StrCharRanges<'a> { fn char_ranges(&self) -> CharRanges<'a>; } impl<'a> StrCharRanges<'a> for &'a str { #[inline] fn char_ranges(&self) -> CharRanges<'a> { CharRanges { slice: *self, position: 0 } } } pub struct CharRanges<'a> { slice: &'a str, position: usize, } impl<'a> Iterator for CharRanges<'a> { type Item = (usize, char, usize); #[inline] fn next(&mut self) -> Option<(usize, char, usize)> { match self.slice[self.position..].chars().next() { Some(ch) => { let position = self.position; self.position = position + ch.len_utf8(); Some((position, ch, position + ch.len_utf8())) } None => None, } } } #[inline] fn check_url_code_point(input: &str, i: usize, c: char, parser: &UrlParser) -> ParseResult<()> { if c == '%' { if !starts_with_2_hex(&input[i + 1..]) { try!(parser.parse_error(ParseError::InvalidPercentEncoded)); } } else if !is_url_code_point(c) { try!(parser.parse_error(ParseError::NonUrlCodePoint)); } Ok(()) } deps/url-0.2.38/src/urltestdata.txt0000644000175000017500000003374512526533700014164 0ustar # This file is from https://github.com/w3c/web-platform-tests/blob/master/url/urltestdata.txt # and used under a 3-clause BSD license. # FORMAT NOT DOCUMENTED YET (parser is urltestparser.js) # https://github.com/w3c/web-platform-tests/blob/master/url/urltestparser.js # Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/script-tests/segments.js http://example\t.\norg http://example.org/foo/bar s:http h:example.org p:/ http://user:pass@foo:21/bar;par?b#c s:http u:user pass:pass h:foo port:21 p:/bar;par q:?b f:#c http:foo.com s:http h:example.org p:/foo/foo.com \t\s\s\s:foo.com\s\s\s\n s:http h:example.org p:/foo/:foo.com \sfoo.com\s\s s:http h:example.org p:/foo/foo.com a:\t\sfoo.com s:a p:\sfoo.com http://f:21/\sb\s?\sd\s#\se\s s:http h:f port:21 p:/%20b%20 q:?%20d%20 f:#\se http://f:/c s:http h:f p:/c http://f:0/c s:http h:f port:0 p:/c http://f:00000000000000/c s:http h:f port:0 p:/c http://f:00000000000000000000080/c s:http h:f p:/c http://f:b/c http://f:\s/c http://f:\n/c s:http h:f p:/c http://f:fifty-two/c http://f:9999/c s:http h:f port:9999 p:/c http://f:\s21\s/\sb\s?\sd\s#\se\s s:http h:example.org p:/foo/bar \s\s\t s:http h:example.org p:/foo/bar :foo.com/ s:http h:example.org p:/foo/:foo.com/ :foo.com\\ s:http h:example.org p:/foo/:foo.com/ : s:http h:example.org p:/foo/: :a s:http h:example.org p:/foo/:a :/ s:http h:example.org p:/foo/:/ :\\ s:http h:example.org p:/foo/:/ :# s:http h:example.org p:/foo/: f:# # s:http h:example.org p:/foo/bar f:# #/ s:http h:example.org p:/foo/bar f:#/ #\\ s:http h:example.org p:/foo/bar f:#\\ #;? s:http h:example.org p:/foo/bar f:#;? ? s:http h:example.org p:/foo/bar q:? / s:http h:example.org p:/ :23 s:http h:example.org p:/foo/:23 /:23 s:http h:example.org p:/:23 :: s:http h:example.org p:/foo/:: ::23 s:http h:example.org p:/foo/::23 foo:// s:foo p:// http://a:b@c:29/d s:http u:a pass:b h:c port:29 p:/d http::@c:29 s:http h:example.org p:/foo/:@c:29 http://&a:foo(b]c@d:2/ s:http u:&a pass:foo(b]c h:d port:2 p:/ http://::@c@d:2 s:http pass::%40c h:d port:2 p:/ http://foo.com:b@d/ s:http u:foo.com pass:b h:d p:/ http://foo.com/\\@ s:http h:foo.com p://@ http:\\\\foo.com\\ s:http h:foo.com p:/ http:\\\\a\\b:c\\d@foo.com\\ s:http h:a p:/b:c/d@foo.com/ foo:/ s:foo p:/ foo:/bar.com/ s:foo p:/bar.com/ foo:///////// s:foo p:///////// foo://///////bar.com/ s:foo p://///////bar.com/ foo:////:///// s:foo p:////:///// c:/foo s:c p:/foo //foo/bar s:http h:foo p:/bar http://foo/path;a??e#f#g s:http h:foo p:/path;a q:??e f:#f#g http://foo/abcd?efgh?ijkl s:http h:foo p:/abcd q:?efgh?ijkl http://foo/abcd#foo?bar s:http h:foo p:/abcd f:#foo?bar [61:24:74]:98 s:http h:example.org p:/foo/[61:24:74]:98 http:[61:27]/:foo s:http h:example.org p:/foo/[61:27]/:foo http://[1::2]:3:4 http://2001::1 http://2001::1] http://2001::1]:80 http://[2001::1] s:http h:[2001::1] p:/ http://[2001::1]:80 s:http h:[2001::1] p:/ http:/example.com/ s:http h:example.org p:/example.com/ ftp:/example.com/ s:ftp h:example.com p:/ https:/example.com/ s:https h:example.com p:/ madeupscheme:/example.com/ s:madeupscheme p:/example.com/ file:/example.com/ s:file p:/example.com/ ftps:/example.com/ s:ftps p:/example.com/ gopher:/example.com/ s:gopher h:example.com p:/ ws:/example.com/ s:ws h:example.com p:/ wss:/example.com/ s:wss h:example.com p:/ data:/example.com/ s:data p:/example.com/ javascript:/example.com/ s:javascript p:/example.com/ mailto:/example.com/ s:mailto p:/example.com/ http:example.com/ s:http h:example.org p:/foo/example.com/ ftp:example.com/ s:ftp h:example.com p:/ https:example.com/ s:https h:example.com p:/ madeupscheme:example.com/ s:madeupscheme p:example.com/ ftps:example.com/ s:ftps p:example.com/ gopher:example.com/ s:gopher h:example.com p:/ ws:example.com/ s:ws h:example.com p:/ wss:example.com/ s:wss h:example.com p:/ data:example.com/ s:data p:example.com/ javascript:example.com/ s:javascript p:example.com/ mailto:example.com/ s:mailto p:example.com/ /a/b/c s:http h:example.org p:/a/b/c /a/\s/c s:http h:example.org p:/a/%20/c /a%2fc s:http h:example.org p:/a%2fc /a/%2f/c s:http h:example.org p:/a/%2f/c #\u03B2 s:http h:example.org p:/foo/bar f:#\u03B2 data:text/html,test#test s:data p:text/html,test f:#test # Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/file.html file:c:\\foo\\bar.html file:///tmp/mock/path s:file p:/c:/foo/bar.html \s\sFile:c|////foo\\bar.html s:file p:/c:////foo/bar.html C|/foo/bar s:file p:/C:/foo/bar /C|\\foo\\bar s:file p:/C:/foo/bar //C|/foo/bar s:file p:/C:/foo/bar //server/file s:file h:server p:/file \\\\server\\file s:file h:server p:/file /\\server/file s:file h:server p:/file file:///foo/bar.txt s:file p:/foo/bar.txt file:///home/me s:file p:/home/me // s:file p:/ /// s:file p:/ ///test s:file p:/test file://test s:file h:test p:/ file://localhost s:file h:localhost p:/ file://localhost/ s:file h:localhost p:/ file://localhost/test s:file h:localhost p:/test test s:file p:/tmp/mock/test file:test s:file p:/tmp/mock/test # Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/script-tests/path.js http://example.com/././foo about:blank s:http h:example.com p:/foo http://example.com/./.foo s:http h:example.com p:/.foo http://example.com/foo/. s:http h:example.com p:/foo/ http://example.com/foo/./ s:http h:example.com p:/foo/ http://example.com/foo/bar/.. s:http h:example.com p:/foo/ http://example.com/foo/bar/../ s:http h:example.com p:/foo/ http://example.com/foo/..bar s:http h:example.com p:/foo/..bar http://example.com/foo/bar/../ton s:http h:example.com p:/foo/ton http://example.com/foo/bar/../ton/../../a s:http h:example.com p:/a http://example.com/foo/../../.. s:http h:example.com p:/ http://example.com/foo/../../../ton s:http h:example.com p:/ton http://example.com/foo/%2e s:http h:example.com p:/foo/ http://example.com/foo/%2e%2 s:http h:example.com p:/foo/%2e%2 http://example.com/foo/%2e./%2e%2e/.%2e/%2e.bar s:http h:example.com p:/%2e.bar http://example.com////../.. s:http h:example.com p:// http://example.com/foo/bar//../.. s:http h:example.com p:/foo/ http://example.com/foo/bar//.. s:http h:example.com p:/foo/bar/ http://example.com/foo s:http h:example.com p:/foo http://example.com/%20foo s:http h:example.com p:/%20foo http://example.com/foo% s:http h:example.com p:/foo% http://example.com/foo%2 s:http h:example.com p:/foo%2 http://example.com/foo%2zbar s:http h:example.com p:/foo%2zbar http://example.com/foo%2\u00C2\u00A9zbar s:http h:example.com p:/foo%2%C3%82%C2%A9zbar http://example.com/foo%41%7a s:http h:example.com p:/foo%41%7a http://example.com/foo\t\u0091%91 s:http h:example.com p:/foo%C2%91%91 http://example.com/foo%00%51 s:http h:example.com p:/foo%00%51 http://example.com/(%28:%3A%29) s:http h:example.com p:/(%28:%3A%29) http://example.com/%3A%3a%3C%3c s:http h:example.com p:/%3A%3a%3C%3c http://example.com/foo\tbar s:http h:example.com p:/foobar http://example.com\\\\foo\\\\bar s:http h:example.com p://foo//bar http://example.com/%7Ffp3%3Eju%3Dduvgw%3Dd s:http h:example.com p:/%7Ffp3%3Eju%3Dduvgw%3Dd http://example.com/@asdf%40 s:http h:example.com p:/@asdf%40 http://example.com/\u4F60\u597D\u4F60\u597D s:http h:example.com p:/%E4%BD%A0%E5%A5%BD%E4%BD%A0%E5%A5%BD http://example.com/\u2025/foo s:http h:example.com p:/%E2%80%A5/foo http://example.com/\uFEFF/foo s:http h:example.com p:/%EF%BB%BF/foo http://example.com/\u202E/foo/\u202D/bar s:http h:example.com p:/%E2%80%AE/foo/%E2%80%AD/bar # Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/script-tests/relative.js http://www.google.com/foo?bar=baz# about:blank s:http h:www.google.com p:/foo q:?bar=baz f:# http://www.google.com/foo?bar=baz#\s\u00BB s:http h:www.google.com p:/foo q:?bar=baz f:#\s%C2%BB http://[www.google.com]/ http://www.google.com s:http h:www.google.com p:/ http://192.0x00A80001 s:http h:192.0x00a80001 p:/ http://www/foo%2Ehtml s:http h:www p:/foo%2Ehtml http://www/foo/%2E/html s:http h:www p:/foo/html http://user:pass@/ http://%25DOMAIN:foobar@foodomain.com/ s:http u:%25DOMAIN pass:foobar h:foodomain.com p:/ http:\\\\www.google.com\\foo s:http h:www.google.com p:/foo http://foo:80/ s:http h:foo p:/ http://foo:81/ s:http h:foo port:81 p:/ httpa://foo:80/ s:httpa p://foo:80/ http://foo:-80/ https://foo:443/ s:https h:foo p:/ https://foo:80/ s:https h:foo port:80 p:/ ftp://foo:21/ s:ftp h:foo p:/ ftp://foo:80/ s:ftp h:foo port:80 p:/ gopher://foo:70/ s:gopher h:foo p:/ gopher://foo:443/ s:gopher h:foo port:443 p:/ ws://foo:80/ s:ws h:foo p:/ ws://foo:81/ s:ws h:foo port:81 p:/ ws://foo:443/ s:ws h:foo port:443 p:/ ws://foo:815/ s:ws h:foo port:815 p:/ wss://foo:80/ s:wss h:foo port:80 p:/ wss://foo:81/ s:wss h:foo port:81 p:/ wss://foo:443/ s:wss h:foo p:/ wss://foo:815/ s:wss h:foo port:815 p:/ http:/example.com/ s:http h:example.com p:/ ftp:/example.com/ s:ftp h:example.com p:/ https:/example.com/ s:https h:example.com p:/ madeupscheme:/example.com/ s:madeupscheme p:/example.com/ file:/example.com/ s:file p:/example.com/ ftps:/example.com/ s:ftps p:/example.com/ gopher:/example.com/ s:gopher h:example.com p:/ ws:/example.com/ s:ws h:example.com p:/ wss:/example.com/ s:wss h:example.com p:/ data:/example.com/ s:data p:/example.com/ javascript:/example.com/ s:javascript p:/example.com/ mailto:/example.com/ s:mailto p:/example.com/ http:example.com/ s:http h:example.com p:/ ftp:example.com/ s:ftp h:example.com p:/ https:example.com/ s:https h:example.com p:/ madeupscheme:example.com/ s:madeupscheme p:example.com/ ftps:example.com/ s:ftps p:example.com/ gopher:example.com/ s:gopher h:example.com p:/ ws:example.com/ s:ws h:example.com p:/ wss:example.com/ s:wss h:example.com p:/ data:example.com/ s:data p:example.com/ javascript:example.com/ s:javascript p:example.com/ mailto:example.com/ s:mailto p:example.com/ # Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/segments-userinfo-vs-host.html http:@www.example.com about:blank s:http h:www.example.com p:/ http:/@www.example.com s:http h:www.example.com p:/ http://@www.example.com s:http h:www.example.com p:/ http:a:b@www.example.com s:http u:a pass:b h:www.example.com p:/ http:/a:b@www.example.com s:http u:a pass:b h:www.example.com p:/ http://a:b@www.example.com s:http u:a pass:b h:www.example.com p:/ http://@pple.com s:http h:pple.com p:/ http::b@www.example.com s:http pass:b h:www.example.com p:/ http:/:b@www.example.com s:http pass:b h:www.example.com p:/ http://:b@www.example.com s:http pass:b h:www.example.com p:/ http:/:@/www.example.com http://user@/www.example.com http:@/www.example.com http:/@/www.example.com http://@/www.example.com https:@/www.example.com http:a:b@/www.example.com http:/a:b@/www.example.com http://a:b@/www.example.com http::@/www.example.com http:a:@www.example.com s:http u:a pass: h:www.example.com p:/ http:/a:@www.example.com s:http u:a pass: h:www.example.com p:/ http://a:@www.example.com s:http u:a pass: h:www.example.com p:/ http://www.@pple.com s:http u:www. h:pple.com p:/ http:@:www.example.com http:/@:www.example.com http://@:www.example.com http://:@www.example.com s:http pass: h:www.example.com p:/ #Others / http://www.example.com/test s:http h:www.example.com p:/ /test.txt s:http h:www.example.com p:/test.txt . s:http h:www.example.com p:/ .. s:http h:www.example.com p:/ test.txt s:http h:www.example.com p:/test.txt ./test.txt s:http h:www.example.com p:/test.txt ../test.txt s:http h:www.example.com p:/test.txt ../aaa/test.txt s:http h:www.example.com p:/aaa/test.txt ../../test.txt s:http h:www.example.com p:/test.txt \u4E2D/test.txt s:http h:www.example.com p:/%E4%B8%AD/test.txt http://www.example2.com s:http h:www.example2.com p:/ # Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/host.html # Basic canonicalization, uppercase should be converted to lowercase http://ExAmPlE.CoM http://other.com/ s:http p:/ h:example.com # Spaces should fail http://example\sexample.com # This should fail http://Goo%20\sgoo%7C|.com # This should fail http://GOO\u00a0\u3000goo.com # This should fail http://[] http://[:] # Other types of space (no-break, zero-width, zero-width-no-break) are # name-prepped away to nothing. XFAIL http://GOO\u200b\u2060\ufeffgoo.com s:http p:/ h:googoo.com # Ideographic full stop (full-width period for Chinese, etc.) should be # treated as a dot. XFAIL http://www.foo\u3002bar.com s:http p:/ h:www.foo.bar.com # Invalid unicode characters should fail... http://\ufdd0zyx.com # ...This is the same as previous but with with escaped. http://%ef%b7%90zyx.com # Test name prepping, fullwidth input should be converted to ASCII and NOT # IDN-ized. This is "Go" in fullwidth UTF-8/UTF-16. XFAIL http://\uff27\uff4f.com s:http p:/ h:go.com # URL spec forbids the following. # https://www.w3.org/Bugs/Public/show_bug.cgi?id=24257 http://\uff05\uff14\uff11.com http://%ef%bc%85%ef%bc%94%ef%bc%91.com # ...%00 in fullwidth should fail (also as escaped UTF-8 input) http://\uff05\uff10\uff10.com http://%ef%bc%85%ef%bc%90%ef%bc%90.com # Basic IDN support, UTF-8 and UTF-16 input should be converted to IDN XFAIL http://\u4f60\u597d\u4f60\u597d s:http p:/ h:xn--6qqa088eba # Invalid escaped characters should fail and the percents should be # escaped. https://www.w3.org/Bugs/Public/show_bug.cgi?id=24191 http://%zz%66%a.com # If we get an invalid character that has been escaped. http://%25 http://hello%00 # Escaped numbers should be treated like IP addresses if they are. XFAIL http://%30%78%63%30%2e%30%32%35%30.01 s:http p:/ h:127.0.0.1 XFAIL http://%30%78%63%30%2e%30%32%35%30.01%2e # Invalid escaping should trigger the regular host error handling. http://%3g%78%63%30%2e%30%32%35%30%2E.01 # Something that isn't exactly an IP should get treated as a host and # spaces escaped. http://192.168.0.1\shello # Fullwidth and escaped UTF-8 fullwidth should still be treated as IP. # These are "0Xc0.0250.01" in fullwidth. XFAIL http://\uff10\uff38\uff43\uff10\uff0e\uff10\uff12\uff15\uff10\uff0e\uff10\uff11 s:http p:/ h:192.168.0.1 # Broken IP addresses. XFAIL http://192.168.0.257 http://[google.com] deps/url-0.2.38/src/lib.rs0000644000175000017500000011645612623123736012206 0ustar // Copyright 2013-2015 Simon Sapin. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. /*! Fork me on GitHub rust-url is an implementation of the [URL Standard](http://url.spec.whatwg.org/) for the [Rust](http://rust-lang.org/) programming language. It builds with [Cargo](http://crates.io/). To use it in your project, add this to your `Cargo.toml` file: ```Cargo [dependencies.url] git = "https://github.com/servo/rust-url" ``` Supporting encodings other than UTF-8 in query strings is an optional feature that requires [rust-encoding](https://github.com/lifthrasiir/rust-encoding) and is off by default. You can enable it with [Cargo’s *features* mechanism](http://doc.crates.io/manifest.html#the-[features]-section): ```Cargo [dependencies.url] git = "https://github.com/servo/rust-url" features = ["query_encoding"] ``` … or by passing `--cfg 'feature="query_encoding"'` to rustc. # URL parsing and data structures First, URL parsing may fail for various reasons and therefore returns a `Result`. ``` use url::{Url, ParseError}; assert!(Url::parse("http://[:::1]") == Err(ParseError::InvalidIpv6Address)) ``` Let’s parse a valid URL and look at its components. ``` use url::{Url, SchemeData}; let issue_list_url = Url::parse( "https://github.com/rust-lang/rust/issues?labels=E-easy&state=open" ).unwrap(); assert!(issue_list_url.scheme == "https".to_string()); assert!(issue_list_url.domain() == Some("github.com")); assert!(issue_list_url.port() == None); assert!(issue_list_url.path() == Some(&["rust-lang".to_string(), "rust".to_string(), "issues".to_string()][..])); assert!(issue_list_url.query == Some("labels=E-easy&state=open".to_string())); assert!(issue_list_url.fragment == None); match issue_list_url.scheme_data { SchemeData::Relative(..) => {}, // Expected SchemeData::NonRelative(..) => panic!(), } ``` The `scheme`, `query`, and `fragment` are directly fields of the `Url` struct: they apply to all URLs. Every other components has accessors because they only apply to URLs said to be “in a relative scheme”. `https` is a relative scheme, but `data` is not: ``` use url::{Url, SchemeData}; let data_url = Url::parse("data:text/plain,Hello#").unwrap(); assert!(data_url.scheme == "data".to_string()); assert!(data_url.scheme_data == SchemeData::NonRelative("text/plain,Hello".to_string())); assert!(data_url.non_relative_scheme_data() == Some("text/plain,Hello")); assert!(data_url.query == None); assert!(data_url.fragment == Some("".to_string())); ``` # Base URL Many contexts allow URL *references* that can be relative to a *base URL*: ```html ``` Since parsed URL are absolute, giving a base is required: ``` use url::{Url, ParseError}; assert!(Url::parse("../main.css") == Err(ParseError::RelativeUrlWithoutBase)) ``` `UrlParser` is a method-chaining API to provide various optional parameters to URL parsing, including a base URL. ``` use url::{Url, UrlParser}; let this_document = Url::parse("http://servo.github.io/rust-url/url/index.html").unwrap(); let css_url = UrlParser::new().base_url(&this_document).parse("../main.css").unwrap(); assert!(css_url.serialize() == "http://servo.github.io/rust-url/main.css".to_string()); ``` */ #![cfg_attr(feature="heap_size", feature(plugin, custom_derive))] #![cfg_attr(feature="heap_size", plugin(heapsize_plugin))] extern crate rustc_serialize; extern crate uuid; #[macro_use] extern crate matches; #[cfg(feature="serde_serialization")] extern crate serde; #[cfg(feature="heap_size")] #[macro_use] extern crate heapsize; use std::fmt::{self, Formatter}; use std::str; use std::path::{Path, PathBuf}; use std::borrow::Borrow; use std::hash::{Hash, Hasher}; use std::cmp::Ordering; #[cfg(feature="serde_serialization")] use std::str::FromStr; pub use host::{Host, Ipv6Address}; pub use parser::{ErrorHandler, ParseResult, ParseError}; use percent_encoding::{percent_encode, lossy_utf8_percent_decode, DEFAULT_ENCODE_SET}; use format::{PathFormatter, UserInfoFormatter, UrlNoFragmentFormatter}; use encoding::EncodingOverride; use uuid::Uuid; mod encoding; mod host; mod parser; pub mod urlutils; pub mod percent_encoding; pub mod form_urlencoded; pub mod punycode; pub mod format; #[cfg(test)] mod tests; /// The parsed representation of an absolute URL. #[derive(PartialEq, Eq, Clone, Debug, Hash, PartialOrd, Ord)] #[cfg_attr(feature="heap_size", derive(HeapSizeOf))] pub struct Url { /// The scheme (a.k.a. protocol) of the URL, in ASCII lower case. pub scheme: String, /// The components of the URL whose representation depends on where the scheme is *relative*. pub scheme_data: SchemeData, /// The query string of the URL. /// /// `None` if the `?` delimiter character was not part of the parsed input, /// otherwise a possibly empty, percent-encoded string. /// /// Percent encoded strings are within the ASCII range. /// /// See also the `query_pairs`, `set_query_from_pairs`, /// and `lossy_percent_decode_query` methods. pub query: Option, /// The fragment identifier of the URL. /// /// `None` if the `#` delimiter character was not part of the parsed input, /// otherwise a possibly empty, percent-encoded string. /// /// Percent encoded strings are within the ASCII range. /// /// See also the `lossy_percent_decode_fragment` method. pub fragment: Option, } /// Opaque identifier for URLs that have file or other schemes #[derive(PartialEq, Eq, Clone, Debug)] pub struct OpaqueOrigin(Uuid); /// The origin of the URL #[derive(PartialEq, Eq, Clone, Debug)] pub enum Origin { /// A globally unique identifier UID(OpaqueOrigin), /// Consists of the URL's scheme, host and port Tuple(String, Host, u16) } /// The components of the URL whose representation depends on where the scheme is *relative*. #[derive(PartialEq, Eq, Clone, Debug, Hash, PartialOrd, Ord)] #[cfg_attr(feature="heap_size", derive(HeapSizeOf))] pub enum SchemeData { /// Components for URLs in a *relative* scheme such as HTTP. Relative(RelativeSchemeData), /// No further structure is assumed for *non-relative* schemes such as `data` and `mailto`. /// /// This is a single percent-encoded string, whose interpretation depends on the scheme. /// /// Percent encoded strings are within the ASCII range. NonRelative(String), } /// Components for URLs in a *relative* scheme such as HTTP. #[derive(Clone, Debug)] #[cfg_attr(feature="heap_size", derive(HeapSizeOf))] pub struct RelativeSchemeData { /// The username of the URL, as a possibly empty, percent-encoded string. /// /// Percent encoded strings are within the ASCII range. /// /// See also the `lossy_percent_decode_username` method. pub username: String, /// The password of the URL. /// /// `None` if the `:` delimiter character was not part of the parsed input, /// otherwise a possibly empty, percent-encoded string. /// /// Percent encoded strings are within the ASCII range. /// /// See also the `lossy_percent_decode_password` method. pub password: Option, /// The host of the URL, either a domain name or an IPv4 address pub host: Host, /// The port number of the URL. /// `None` for file-like schemes, or to indicate the default port number. pub port: Option, /// The default port number for the URL’s scheme. /// `None` for file-like schemes. pub default_port: Option, /// The path of the URL, as vector of percent-encoded strings. /// /// Percent encoded strings are within the ASCII range. /// /// See also the `serialize_path` method and, /// for URLs in the `file` scheme, the `to_file_path` method. pub path: Vec, } impl RelativeSchemeData { fn get_identity_key(&self) -> (&String, &Option, &Host, Option, Option, &Vec) { ( &self.username, &self.password, &self.host, self.port.or(self.default_port), self.default_port, &self.path ) } } impl PartialEq for RelativeSchemeData { fn eq(&self, other: &RelativeSchemeData) -> bool { self.get_identity_key() == other.get_identity_key() } } impl Eq for RelativeSchemeData {} impl Hash for RelativeSchemeData { fn hash(&self, state: &mut H) { self.get_identity_key().hash(state) } } impl PartialOrd for RelativeSchemeData { fn partial_cmp(&self, other: &RelativeSchemeData) -> Option { self.get_identity_key().partial_cmp(&other.get_identity_key()) } } impl Ord for RelativeSchemeData { fn cmp(&self, other: &Self) -> Ordering { self.get_identity_key().cmp(&other.get_identity_key()) } } impl str::FromStr for Url { type Err = ParseError; fn from_str(url: &str) -> ParseResult { Url::parse(url) } } /// A set of optional parameters for URL parsing. pub struct UrlParser<'a> { base_url: Option<&'a Url>, query_encoding_override: EncodingOverride, error_handler: ErrorHandler, scheme_type_mapper: fn(scheme: &str) -> SchemeType, } /// A method-chaining API to provide a set of optional parameters for URL parsing. impl<'a> UrlParser<'a> { /// Return a new UrlParser with default parameters. #[inline] pub fn new() -> UrlParser<'a> { fn silent_handler(_reason: ParseError) -> ParseResult<()> { Ok(()) } UrlParser { base_url: None, query_encoding_override: EncodingOverride::utf8(), error_handler: silent_handler, scheme_type_mapper: whatwg_scheme_type_mapper, } } /// Set the base URL used for resolving relative URL references, and return the `UrlParser`. /// The default is no base URL, so that relative URLs references fail to parse. #[inline] pub fn base_url<'b>(&'b mut self, value: &'a Url) -> &'b mut UrlParser<'a> { self.base_url = Some(value); self } /// Set the character encoding the query string is encoded as before percent-encoding, /// and return the `UrlParser`. /// /// This legacy quirk is only relevant to HTML. /// /// This method is only available if the `query_encoding` Cargo feature is enabled. #[cfg(feature = "query_encoding")] #[inline] pub fn query_encoding_override<'b>(&'b mut self, value: encoding::EncodingRef) -> &'b mut UrlParser<'a> { self.query_encoding_override = EncodingOverride::from_encoding(value); self } /// Set an error handler for non-fatal parse errors, and return the `UrlParser`. /// /// Non-fatal parse errors are normally ignored by the parser, /// but indicate violations of authoring requirements. /// An error handler can be used, for example, to log these errors in the console /// of a browser’s developer tools. /// /// The error handler can choose to make the error fatal by returning `Err(..)` #[inline] pub fn error_handler<'b>(&'b mut self, value: ErrorHandler) -> &'b mut UrlParser<'a> { self.error_handler = value; self } /// Set a *scheme type mapper*, and return the `UrlParser`. /// /// The URL parser behaves differently based on the `SchemeType` of the URL. /// See the documentation for `SchemeType` for more details. /// A *scheme type mapper* returns a `SchemeType` /// based on the scheme as an ASCII lower case string, /// as found in the `scheme` field of an `Url` struct. /// /// The default scheme type mapper is as follows: /// /// ```ignore /// fn whatwg_scheme_type_mapper(scheme: &str) -> SchemeType { /// match scheme { /// "file" => SchemeType::FileLike, /// "ftp" => SchemeType::Relative(21), /// "gopher" => SchemeType::Relative(70), /// "http" => SchemeType::Relative(80), /// "https" => SchemeType::Relative(443), /// "ws" => SchemeType::Relative(80), /// "wss" => SchemeType::Relative(443), /// _ => NonRelative, /// } /// } /// ``` /// /// Note that unknown schemes default to non-relative. /// Overriding the scheme type mapper can allow, for example, /// parsing URLs in the `git` or `irc` scheme as relative. #[inline] pub fn scheme_type_mapper<'b>(&'b mut self, value: fn(scheme: &str) -> SchemeType) -> &'b mut UrlParser<'a> { self.scheme_type_mapper = value; self } /// Parse `input` as an URL, with all the parameters previously set in the `UrlParser`. #[inline] pub fn parse(&self, input: &str) -> ParseResult { parser::parse_url(input, self) } /// Parse `input` as a “standalone” URL path, /// with an optional query string and fragment identifier. /// /// This is typically found in the start line of an HTTP header. /// /// Note that while the start line has no fragment identifier in the HTTP RFC, /// servers typically parse it and ignore it /// (rather than having it be part of the path or query string.) /// /// On success, return `(path, query_string, fragment_identifier)` #[inline] pub fn parse_path(&self, input: &str) -> ParseResult<(Vec, Option, Option)> { parser::parse_standalone_path(input, self) } } /// Parse `input` as a “standalone” URL path, /// with an optional query string and fragment identifier. /// /// This is typically found in the start line of an HTTP header. /// /// Note that while the start line has no fragment identifier in the HTTP RFC, /// servers typically parse it and ignore it /// (rather than having it be part of the path or query string.) /// /// On success, return `(path, query_string, fragment_identifier)` /// /// ```rust /// let (path, query, fragment) = url::parse_path("/foo/bar/../baz?q=42").unwrap(); /// assert_eq!(path, vec!["foo".to_string(), "baz".to_string()]); /// assert_eq!(query, Some("q=42".to_string())); /// assert_eq!(fragment, None); /// ``` /// /// The query string returned by `url::parse_path` can be decoded with /// `url::form_urlencoded::parse`. #[inline] pub fn parse_path(input: &str) -> ParseResult<(Vec, Option, Option)> { UrlParser::new().parse_path(input) } /// Private convenience methods for use in parser.rs impl<'a> UrlParser<'a> { #[inline] fn parse_error(&self, error: ParseError) -> ParseResult<()> { (self.error_handler)(error) } #[inline] fn get_scheme_type(&self, scheme: &str) -> SchemeType { (self.scheme_type_mapper)(scheme) } } /// Determines the behavior of the URL parser for a given scheme. #[derive(PartialEq, Eq, Copy, Debug, Clone, Hash, PartialOrd, Ord)] pub enum SchemeType { /// Indicate that the scheme is *non-relative*. /// /// The *scheme data* of the URL /// (everything other than the scheme, query string, and fragment identifier) /// is parsed as a single percent-encoded string of which no structure is assumed. /// That string may need to be parsed further, per a scheme-specific format. NonRelative, /// Indicate that the scheme is *relative*, and what the default port number is. /// /// The *scheme data* is structured as /// *username*, *password*, *host*, *port number*, and *path*. /// Relative URL references are supported, if a base URL was given. /// The string value indicates the default port number as a string of ASCII digits, /// or the empty string to indicate no default port number. Relative(u16), /// Indicate a *relative* scheme similar to the *file* scheme. /// /// For example, you might want to have distinct `git+file` and `hg+file` URL schemes. /// /// This is like `Relative` except the host can be empty, there is no port number, /// and path parsing has (platform-independent) quirks to support Windows filenames. FileLike, } impl SchemeType { pub fn default_port(&self) -> Option { match self { &SchemeType::Relative(default_port) => Some(default_port), _ => None, } } pub fn same_as(&self, other: SchemeType) -> bool { match (self, other) { (&SchemeType::NonRelative, SchemeType::NonRelative) => true, (&SchemeType::Relative(_), SchemeType::Relative(_)) => true, (&SchemeType::FileLike, SchemeType::FileLike) => true, _ => false } } } /// http://url.spec.whatwg.org/#relative-scheme pub fn whatwg_scheme_type_mapper(scheme: &str) -> SchemeType { match scheme { "file" => SchemeType::FileLike, "ftp" => SchemeType::Relative(21), "gopher" => SchemeType::Relative(70), "http" => SchemeType::Relative(80), "https" => SchemeType::Relative(443), "ws" => SchemeType::Relative(80), "wss" => SchemeType::Relative(443), _ => SchemeType::NonRelative, } } impl Url { /// Parse an URL with the default `UrlParser` parameters. /// /// In particular, relative URL references are parse errors since no base URL is provided. #[inline] pub fn parse(input: &str) -> ParseResult { UrlParser::new().parse(input) } /// Convert a file name as `std::path::Path` into an URL in the `file` scheme. /// /// This returns `Err` if the given path is not absolute /// or, with a Windows path, if the prefix is not a disk prefix (e.g. `C:`). pub fn from_file_path>(path: P) -> Result { let path = try!(path_to_file_url_path(path.as_ref())); Ok(Url::from_path_common(path)) } /// Convert a directory name as `std::path::Path` into an URL in the `file` scheme. /// /// This returns `Err` if the given path is not absolute /// or, with a Windows path, if the prefix is not a disk prefix (e.g. `C:`). /// /// Compared to `from_file_path`, this adds an empty component to the path /// (or, in terms of URL syntax, adds a trailing slash) /// so that the entire path is considered when using this URL as a base URL. /// /// For example: /// /// * `"index.html"` parsed with `Url::from_directory_path(Path::new("/var/www"))` /// as the base URL is `file:///var/www/index.html` /// * `"index.html"` parsed with `Url::from_file_path(Path::new("/var/www/"))` /// as the base URL is `file:///var/index.html`, which might not be what was intended. /// /// (Note that `Path::new` removes any trailing slash.) pub fn from_directory_path>(path: P) -> Result { let mut path = try!(path_to_file_url_path(path.as_ref())); // Add an empty path component (i.e. a trailing slash in serialization) // so that the entire path is used as a base URL. path.push("".to_string()); Ok(Url::from_path_common(path)) } fn from_path_common(path: Vec) -> Url { Url { scheme: "file".to_string(), scheme_data: SchemeData::Relative(RelativeSchemeData { username: "".to_string(), password: None, port: None, default_port: None, host: Host::Domain("".to_string()), path: path, }), query: None, fragment: None, } } /// Assuming the URL is in the `file` scheme or similar, /// convert its path to an absolute `std::path::Path`. /// /// **Note:** This does not actually check the URL’s `scheme`, /// and may give nonsensical results for other schemes. /// It is the user’s responsibility to check the URL’s scheme before calling this. /// /// The return type (when `Ok()`) is generic and can be either `std::path::posix::Path` /// or `std::path::windows::Path`. /// (Use `std::path::Path` to pick one of them depending on the local system.) /// If the compiler can not infer the desired type from context, you may have to specify it: /// /// ```ignore /// let path = url.to_file_path::(); /// ``` /// /// Returns `Err` if the host is neither empty nor `"localhost"`, /// or if `Path::new_opt()` returns `None`. /// (That is, if the percent-decoded path contains a NUL byte or, /// for a Windows path, is not UTF-8.) #[inline] pub fn to_file_path(&self) -> Result { match self.scheme_data { SchemeData::Relative(ref scheme_data) => scheme_data.to_file_path(), SchemeData::NonRelative(..) => Err(()), } } /// Return the serialization of this URL as a string. pub fn serialize(&self) -> String { self.to_string() } // Return the origin of this URL (https://url.spec.whatwg.org/#origin) pub fn origin(&self) -> Origin { match &*self.scheme { "blob" => { let result = Url::parse(self.non_relative_scheme_data().unwrap()); match result { Ok(ref url) => url.origin(), Err(_) => Origin::UID(OpaqueOrigin(Uuid::new_v4())) } }, "ftp" | "gopher" | "http" | "https" | "ws" | "wss" => { Origin::Tuple(self.scheme.clone(), self.host().unwrap().clone(), self.port_or_default().unwrap()) }, // TODO: Figure out what to do if the scheme is a file "file" => Origin::UID(OpaqueOrigin(Uuid::new_v4())), _ => Origin::UID(OpaqueOrigin(Uuid::new_v4())) } } /// Return the serialization of this URL, without the fragment identifier, as a string pub fn serialize_no_fragment(&self) -> String { UrlNoFragmentFormatter{ url: self }.to_string() } /// If the URL is *non-relative*, return the string scheme data. #[inline] pub fn non_relative_scheme_data<'a>(&'a self) -> Option<&'a str> { match self.scheme_data { SchemeData::Relative(..) => None, SchemeData::NonRelative(ref scheme_data) => Some(scheme_data), } } /// If the URL is *non-relative*, return a mutable reference to the string scheme data. #[inline] pub fn non_relative_scheme_data_mut<'a>(&'a mut self) -> Option<&'a mut String> { match self.scheme_data { SchemeData::Relative(..) => None, SchemeData::NonRelative(ref mut scheme_data) => Some(scheme_data), } } /// If the URL is in a *relative scheme*, return the structured scheme data. #[inline] pub fn relative_scheme_data<'a>(&'a self) -> Option<&'a RelativeSchemeData> { match self.scheme_data { SchemeData::Relative(ref scheme_data) => Some(scheme_data), SchemeData::NonRelative(..) => None, } } /// If the URL is in a *relative scheme*, /// return a mutable reference to the structured scheme data. #[inline] pub fn relative_scheme_data_mut<'a>(&'a mut self) -> Option<&'a mut RelativeSchemeData> { match self.scheme_data { SchemeData::Relative(ref mut scheme_data) => Some(scheme_data), SchemeData::NonRelative(..) => None, } } /// If the URL is in a *relative scheme*, return its username. #[inline] pub fn username<'a>(&'a self) -> Option<&'a str> { self.relative_scheme_data().map(|scheme_data| &*scheme_data.username) } /// If the URL is in a *relative scheme*, return a mutable reference to its username. #[inline] pub fn username_mut<'a>(&'a mut self) -> Option<&'a mut String> { self.relative_scheme_data_mut().map(|scheme_data| &mut scheme_data.username) } /// Percent-decode the URL’s username, if any. /// /// This is “lossy”: invalid UTF-8 percent-encoded byte sequences /// will be replaced � U+FFFD, the replacement character. #[inline] pub fn lossy_percent_decode_username(&self) -> Option { self.relative_scheme_data().map(|scheme_data| scheme_data.lossy_percent_decode_username()) } /// If the URL is in a *relative scheme*, return its password, if any. #[inline] pub fn password<'a>(&'a self) -> Option<&'a str> { self.relative_scheme_data().and_then(|scheme_data| scheme_data.password.as_ref().map(|password| password as &str)) } /// If the URL is in a *relative scheme*, return a mutable reference to its password, if any. #[inline] pub fn password_mut<'a>(&'a mut self) -> Option<&'a mut String> { self.relative_scheme_data_mut().and_then(|scheme_data| scheme_data.password.as_mut()) } /// Percent-decode the URL’s password, if any. /// /// This is “lossy”: invalid UTF-8 percent-encoded byte sequences /// will be replaced � U+FFFD, the replacement character. #[inline] pub fn lossy_percent_decode_password(&self) -> Option { self.relative_scheme_data().and_then(|scheme_data| scheme_data.lossy_percent_decode_password()) } /// Serialize the URL's username and password, if any. /// /// Format: ":@" #[inline] pub fn serialize_userinfo<'a>(&'a mut self) -> Option { self.relative_scheme_data().map(|scheme_data| scheme_data.serialize_userinfo()) } /// If the URL is in a *relative scheme*, return its structured host. #[inline] pub fn host<'a>(&'a self) -> Option<&'a Host> { self.relative_scheme_data().map(|scheme_data| &scheme_data.host) } /// If the URL is in a *relative scheme*, return a mutable reference to its structured host. #[inline] pub fn host_mut<'a>(&'a mut self) -> Option<&'a mut Host> { self.relative_scheme_data_mut().map(|scheme_data| &mut scheme_data.host) } /// If the URL is in a *relative scheme* and its host is a domain, /// return the domain as a string. #[inline] pub fn domain<'a>(&'a self) -> Option<&'a str> { self.relative_scheme_data().and_then(|scheme_data| scheme_data.domain()) } /// If the URL is in a *relative scheme* and its host is a domain, /// return a mutable reference to the domain string. #[inline] pub fn domain_mut<'a>(&'a mut self) -> Option<&'a mut String> { self.relative_scheme_data_mut().and_then(|scheme_data| scheme_data.domain_mut()) } /// If the URL is in a *relative scheme*, serialize its host as a string. /// /// A domain a returned as-is, an IPv6 address between [] square brackets. #[inline] pub fn serialize_host(&self) -> Option { self.relative_scheme_data().map(|scheme_data| scheme_data.host.serialize()) } /// If the URL is in a *relative scheme* and has a port number, return it. #[inline] pub fn port<'a>(&'a self) -> Option { self.relative_scheme_data().and_then(|scheme_data| scheme_data.port) } /// If the URL is in a *relative scheme*, return a mutable reference to its port. #[inline] pub fn port_mut<'a>(&'a mut self) -> Option<&'a mut Option> { self.relative_scheme_data_mut().map(|scheme_data| &mut scheme_data.port) } /// If the URL is in a *relative scheme* that is not a file-like, /// return its port number, even if it is the default. #[inline] pub fn port_or_default(&self) -> Option { self.relative_scheme_data().and_then(|scheme_data| scheme_data.port_or_default()) } /// If the URL is in a *relative scheme*, return its path components. #[inline] pub fn path<'a>(&'a self) -> Option<&'a [String]> { self.relative_scheme_data().map(|scheme_data| &*scheme_data.path) } /// If the URL is in a *relative scheme*, return a mutable reference to its path components. #[inline] pub fn path_mut<'a>(&'a mut self) -> Option<&'a mut Vec> { self.relative_scheme_data_mut().map(|scheme_data| &mut scheme_data.path) } /// If the URL is in a *relative scheme*, serialize its path as a string. /// /// The returned string starts with a "/" slash, and components are separated by slashes. /// A trailing slash represents an empty last component. #[inline] pub fn serialize_path(&self) -> Option { self.relative_scheme_data().map(|scheme_data| scheme_data.serialize_path()) } /// Parse the URL’s query string, if any, as `application/x-www-form-urlencoded` /// and return a vector of (key, value) pairs. #[inline] pub fn query_pairs(&self) -> Option> { self.query.as_ref().map(|query| form_urlencoded::parse(query.as_bytes())) } /// Serialize an iterator of (key, value) pairs as `application/x-www-form-urlencoded` /// and set it as the URL’s query string. #[inline] pub fn set_query_from_pairs(&mut self, pairs: I) where I: IntoIterator, I::Item: Borrow<(K, V)>, K: AsRef, V: AsRef { self.query = Some(form_urlencoded::serialize(pairs)); } /// Percent-decode the URL’s query string, if any. /// /// This is “lossy”: invalid UTF-8 percent-encoded byte sequences /// will be replaced � U+FFFD, the replacement character. #[inline] pub fn lossy_percent_decode_query(&self) -> Option { self.query.as_ref().map(|value| lossy_utf8_percent_decode(value.as_bytes())) } /// Percent-decode the URL’s fragment identifier, if any. /// /// This is “lossy”: invalid UTF-8 percent-encoded byte sequences /// will be replaced � U+FFFD, the replacement character. #[inline] pub fn lossy_percent_decode_fragment(&self) -> Option { self.fragment.as_ref().map(|value| lossy_utf8_percent_decode(value.as_bytes())) } } impl rustc_serialize::Encodable for Url { fn encode(&self, encoder: &mut S) -> Result<(), S::Error> { encoder.emit_str(&self.to_string()) } } impl rustc_serialize::Decodable for Url { fn decode(decoder: &mut D) -> Result { Url::parse(&*try!(decoder.read_str())).map_err(|error| { decoder.error(&format!("URL parsing error: {}", error)) }) } } /// Serializes this URL into a `serde` stream. /// /// This implementation is only available if the `serde_serialization` Cargo feature is enabled. #[cfg(feature="serde_serialization")] impl serde::Serialize for Url { fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> where S: serde::Serializer { format!("{}", self).serialize(serializer) } } /// Deserializes this URL from a `serde` stream. /// /// This implementation is only available if the `serde_serialization` Cargo feature is enabled. #[cfg(feature="serde_serialization")] impl serde::Deserialize for Url { fn deserialize(deserializer: &mut D) -> Result where D: serde::Deserializer { let string_representation: String = try!(serde::Deserialize::deserialize(deserializer)); Ok(FromStr::from_str(&string_representation[..]).unwrap()) } } impl fmt::Display for Url { fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { try!(UrlNoFragmentFormatter{ url: self }.fmt(formatter)); if let Some(ref fragment) = self.fragment { try!(formatter.write_str("#")); try!(formatter.write_str(fragment)); } Ok(()) } } impl fmt::Display for SchemeData { fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { match *self { SchemeData::Relative(ref scheme_data) => scheme_data.fmt(formatter), SchemeData::NonRelative(ref scheme_data) => scheme_data.fmt(formatter), } } } impl RelativeSchemeData { /// Percent-decode the URL’s username. /// /// This is “lossy”: invalid UTF-8 percent-encoded byte sequences /// will be replaced � U+FFFD, the replacement character. #[inline] pub fn lossy_percent_decode_username(&self) -> String { lossy_utf8_percent_decode(self.username.as_bytes()) } /// Percent-decode the URL’s password, if any. /// /// This is “lossy”: invalid UTF-8 percent-encoded byte sequences /// will be replaced � U+FFFD, the replacement character. #[inline] pub fn lossy_percent_decode_password(&self) -> Option { self.password.as_ref().map(|value| lossy_utf8_percent_decode(value.as_bytes())) } /// Assuming the URL is in the `file` scheme or similar, /// convert its path to an absolute `std::path::Path`. /// /// **Note:** This does not actually check the URL’s `scheme`, /// and may give nonsensical results for other schemes. /// It is the user’s responsibility to check the URL’s scheme before calling this. /// /// The return type (when `Ok()`) is generic and can be either `std::path::posix::Path` /// or `std::path::windows::Path`. /// (Use `std::path::Path` to pick one of them depending on the local system.) /// If the compiler can not infer the desired type from context, you may have to specifiy it: /// /// ```ignore /// let path = url.to_file_path::(); /// ``` /// /// Returns `Err` if the host is neither empty nor `"localhost"`, /// or if `Path::new_opt()` returns `None`. /// (That is, if the percent-decoded path contains a NUL byte or, /// for a Windows path, is not UTF-8.) #[inline] pub fn to_file_path(&self) -> Result { // FIXME: Figure out what to do w.r.t host. if !matches!(self.domain(), Some("") | Some("localhost")) { return Err(()) } file_url_path_to_pathbuf(&self.path) } /// If the host is a domain, return the domain as a string. #[inline] pub fn domain<'a>(&'a self) -> Option<&'a str> { match self.host { Host::Domain(ref domain) => Some(domain), _ => None, } } /// If the host is a domain, return a mutable reference to the domain string. #[inline] pub fn domain_mut<'a>(&'a mut self) -> Option<&'a mut String> { match self.host { Host::Domain(ref mut domain) => Some(domain), _ => None, } } /// Return the port number of the URL, even if it is the default. /// Return `None` for file-like URLs. #[inline] pub fn port_or_default(&self) -> Option { self.port.or(self.default_port) } /// Serialize the path as a string. /// /// The returned string starts with a "/" slash, and components are separated by slashes. /// A trailing slash represents an empty last component. pub fn serialize_path(&self) -> String { PathFormatter { path: &self.path }.to_string() } /// Serialize the userinfo as a string. /// /// Format: ":@". pub fn serialize_userinfo(&self) -> String { UserInfoFormatter { username: &self.username, password: self.password.as_ref().map(|s| s as &str) }.to_string() } } impl fmt::Display for RelativeSchemeData { fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { // Write the scheme-trailing double slashes. try!(formatter.write_str("//")); // Write the user info. try!(UserInfoFormatter { username: &self.username, password: self.password.as_ref().map(|s| s as &str) }.fmt(formatter)); // Write the host. try!(self.host.fmt(formatter)); // Write the port. match self.port { Some(port) => { try!(write!(formatter, ":{}", port)); }, None => {} } // Write the path. PathFormatter { path: &self.path }.fmt(formatter) } } #[cfg(unix)] fn path_to_file_url_path(path: &Path) -> Result, ()> { use std::os::unix::prelude::OsStrExt; if !path.is_absolute() { return Err(()) } // skip the root component Ok(path.components().skip(1).map(|c| { percent_encode(c.as_os_str().as_bytes(), DEFAULT_ENCODE_SET) }).collect()) } #[cfg(windows)] fn path_to_file_url_path(path: &Path) -> Result, ()> { path_to_file_url_path_windows(path) } // Build this unconditionally to alleviate https://github.com/servo/rust-url/issues/102 #[cfg_attr(not(windows), allow(dead_code))] fn path_to_file_url_path_windows(path: &Path) -> Result, ()> { use std::path::{Prefix, Component}; if !path.is_absolute() { return Err(()) } let mut components = path.components(); let disk = match components.next() { Some(Component::Prefix(ref p)) => match p.kind() { Prefix::Disk(byte) => byte, _ => return Err(()), }, // FIXME: do something with UNC and other prefixes? _ => return Err(()) }; // Start with the prefix, e.g. "C:" let mut path = vec![format!("{}:", disk as char)]; for component in components { if component == Component::RootDir { continue } // FIXME: somehow work with non-unicode? let part = match component.as_os_str().to_str() { Some(s) => s, None => return Err(()), }; path.push(percent_encode(part.as_bytes(), DEFAULT_ENCODE_SET)); } Ok(path) } #[cfg(unix)] fn file_url_path_to_pathbuf(path: &[String]) -> Result { use std::ffi::OsStr; use std::os::unix::prelude::OsStrExt; use std::path::PathBuf; use percent_encoding::percent_decode_to; if path.is_empty() { return Ok(PathBuf::from("/")) } let mut bytes = Vec::new(); for path_part in path { bytes.push(b'/'); percent_decode_to(path_part.as_bytes(), &mut bytes); } let os_str = OsStr::from_bytes(&bytes); let path = PathBuf::from(os_str); debug_assert!(path.is_absolute(), "to_file_path() failed to produce an absolute Path"); Ok(path) } #[cfg(windows)] fn file_url_path_to_pathbuf(path: &[String]) -> Result { file_url_path_to_pathbuf_windows(path) } // Build this unconditionally to alleviate https://github.com/servo/rust-url/issues/102 #[cfg_attr(not(windows), allow(dead_code))] fn file_url_path_to_pathbuf_windows(path: &[String]) -> Result { use percent_encoding::percent_decode; if path.is_empty() { return Err(()) } let prefix = &*path[0]; if prefix.len() != 2 || !parser::starts_with_ascii_alpha(prefix) || prefix.as_bytes()[1] != b':' { return Err(()) } let mut string = prefix.to_string(); for path_part in &path[1..] { string.push('\\'); // Currently non-unicode windows paths cannot be represented match String::from_utf8(percent_decode(path_part.as_bytes())) { Ok(s) => string.push_str(&s), Err(..) => return Err(()), } } let path = PathBuf::from(string); debug_assert!(path.is_absolute(), "to_file_path() failed to produce an absolute Path"); Ok(path) } deps/url-0.2.38/src/tests.rs0000644000175000017500000002704412623123736012574 0ustar // Copyright 2013-2014 Simon Sapin. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::char; use super::{UrlParser, Url, SchemeData, RelativeSchemeData, Host}; #[test] fn url_parsing() { for test in parse_test_data(include_str!("urltestdata.txt")) { let Test { input, base, scheme: expected_scheme, username: expected_username, password: expected_password, host: expected_host, port: expected_port, path: expected_path, query: expected_query, fragment: expected_fragment, expected_failure, } = test; let base = match Url::parse(&base) { Ok(base) => base, Err(message) => panic!("Error parsing base {}: {}", base, message) }; let url = UrlParser::new().base_url(&base).parse(&input); if expected_scheme.is_none() { if url.is_ok() && !expected_failure { panic!("Expected a parse error for URL {}", input); } continue } let Url { scheme, scheme_data, query, fragment, .. } = match url { Ok(url) => url, Err(message) => { if expected_failure { continue } else { panic!("Error parsing URL {}: {}", input, message) } } }; macro_rules! assert_eq { ($a: expr, $b: expr) => { { let a = $a; let b = $b; if a != b { if expected_failure { continue } else { panic!("{:?} != {:?}", a, b) } } } } } assert_eq!(Some(scheme), expected_scheme); match scheme_data { SchemeData::Relative(RelativeSchemeData { username, password, host, port, default_port: _, path, }) => { assert_eq!(username, expected_username); assert_eq!(password, expected_password); let host = host.serialize(); assert_eq!(host, expected_host); assert_eq!(port, expected_port); assert_eq!(Some(format!("/{}", str_join(&path, "/"))), expected_path); }, SchemeData::NonRelative(scheme_data) => { assert_eq!(Some(scheme_data), expected_path); assert_eq!(String::new(), expected_username); assert_eq!(None, expected_password); assert_eq!(String::new(), expected_host); assert_eq!(None, expected_port); }, } fn opt_prepend(prefix: &str, opt_s: Option) -> Option { opt_s.map(|s| format!("{}{}", prefix, s)) } assert_eq!(opt_prepend("?", query), expected_query); assert_eq!(opt_prepend("#", fragment), expected_fragment); assert!(!expected_failure, "Unexpected success for {}", input); } } // FIMXE: Remove this when &[&str]::join (the new name) lands in the stable channel. #[allow(deprecated)] fn str_join>(pieces: &[T], separator: &str) -> String { pieces.connect(separator) } struct Test { input: String, base: String, scheme: Option, username: String, password: Option, host: String, port: Option, path: Option, query: Option, fragment: Option, expected_failure: bool, } fn parse_test_data(input: &str) -> Vec { let mut tests: Vec = Vec::new(); for line in input.lines() { if line == "" || line.starts_with("#") { continue } let mut pieces = line.split(' ').collect::>(); let expected_failure = pieces[0] == "XFAIL"; if expected_failure { pieces.remove(0); } let input = unescape(pieces.remove(0)); let mut test = Test { input: input, base: if pieces.is_empty() || pieces[0] == "" { tests.last().unwrap().base.clone() } else { unescape(pieces.remove(0)) }, scheme: None, username: String::new(), password: None, host: String::new(), port: None, path: None, query: None, fragment: None, expected_failure: expected_failure, }; for piece in pieces { if piece == "" || piece.starts_with("#") { continue } let colon = piece.find(':').unwrap(); let value = unescape(&piece[colon + 1..]); match &piece[..colon] { "s" => test.scheme = Some(value), "u" => test.username = value, "pass" => test.password = Some(value), "h" => test.host = value, "port" => test.port = Some(value.parse().unwrap()), "p" => test.path = Some(value), "q" => test.query = Some(value), "f" => test.fragment = Some(value), _ => panic!("Invalid token") } } tests.push(test) } tests } fn unescape(input: &str) -> String { let mut output = String::new(); let mut chars = input.chars(); loop { match chars.next() { None => return output, Some(c) => output.push( if c == '\\' { match chars.next().unwrap() { '\\' => '\\', 'n' => '\n', 'r' => '\r', 's' => ' ', 't' => '\t', 'f' => '\x0C', 'u' => { char::from_u32(((( chars.next().unwrap().to_digit(16).unwrap()) * 16 + chars.next().unwrap().to_digit(16).unwrap()) * 16 + chars.next().unwrap().to_digit(16).unwrap()) * 16 + chars.next().unwrap().to_digit(16).unwrap()).unwrap() } _ => panic!("Invalid test data input"), } } else { c } ) } } } #[test] fn new_file_paths() { use std::path::{Path, PathBuf}; if cfg!(unix) { assert_eq!(Url::from_file_path(Path::new("relative")), Err(())); assert_eq!(Url::from_file_path(Path::new("../relative")), Err(())); } else { assert_eq!(Url::from_file_path(Path::new("relative")), Err(())); assert_eq!(Url::from_file_path(Path::new(r"..\relative")), Err(())); assert_eq!(Url::from_file_path(Path::new(r"\drive-relative")), Err(())); assert_eq!(Url::from_file_path(Path::new(r"\\ucn\")), Err(())); } if cfg!(unix) { let mut url = Url::from_file_path(Path::new("/foo/bar")).unwrap(); assert_eq!(url.host(), Some(&Host::Domain("".to_string()))); assert_eq!(url.path(), Some(&["foo".to_string(), "bar".to_string()][..])); assert!(url.to_file_path() == Ok(PathBuf::from("/foo/bar"))); url.path_mut().unwrap()[1] = "ba\0r".to_string(); url.to_file_path().is_ok(); url.path_mut().unwrap()[1] = "ba%00r".to_string(); url.to_file_path().is_ok(); } } #[test] #[cfg(unix)] fn new_path_bad_utf8() { use std::ffi::OsStr; use std::os::unix::prelude::*; use std::path::{Path, PathBuf}; let url = Url::from_file_path(Path::new("/foo/ba%80r")).unwrap(); let os_str = OsStr::from_bytes(b"/foo/ba\x80r"); assert_eq!(url.to_file_path(), Ok(PathBuf::from(os_str))); } #[test] fn new_path_windows_fun() { if cfg!(windows) { use std::path::{Path, PathBuf}; let mut url = Url::from_file_path(Path::new(r"C:\foo\bar")).unwrap(); assert_eq!(url.host(), Some(&Host::Domain("".to_string()))); assert_eq!(url.path(), Some(&["C:".to_string(), "foo".to_string(), "bar".to_string()][..])); assert_eq!(url.to_file_path(), Ok(PathBuf::from(r"C:\foo\bar"))); url.path_mut().unwrap()[2] = "ba\0r".to_string(); assert!(url.to_file_path().is_ok()); url.path_mut().unwrap()[2] = "ba%00r".to_string(); assert!(url.to_file_path().is_ok()); // Invalid UTF-8 url.path_mut().unwrap()[2] = "ba%80r".to_string(); assert!(url.to_file_path().is_err()); } } #[test] fn new_directory_paths() { use std::path::Path; if cfg!(unix) { assert_eq!(Url::from_directory_path(Path::new("relative")), Err(())); assert_eq!(Url::from_directory_path(Path::new("../relative")), Err(())); let url = Url::from_directory_path(Path::new("/foo/bar")).unwrap(); assert_eq!(url.host(), Some(&Host::Domain("".to_string()))); assert_eq!(url.path(), Some(&["foo".to_string(), "bar".to_string(), "".to_string()][..])); } else { assert_eq!(Url::from_directory_path(Path::new("relative")), Err(())); assert_eq!(Url::from_directory_path(Path::new(r"..\relative")), Err(())); assert_eq!(Url::from_directory_path(Path::new(r"\drive-relative")), Err(())); assert_eq!(Url::from_directory_path(Path::new(r"\\ucn\")), Err(())); let url = Url::from_directory_path(Path::new(r"C:\foo\bar")).unwrap(); assert_eq!(url.host(), Some(&Host::Domain("".to_string()))); assert_eq!(url.path(), Some(&["C:".to_string(), "foo".to_string(), "bar".to_string(), "".to_string()][..])); } } #[test] fn from_str() { assert!("http://testing.com/this".parse::().is_ok()); } #[test] fn issue_124() { let url: Url = "file:a".parse().unwrap(); assert_eq!(url.path().unwrap(), ["a"]); let url: Url = "file:...".parse().unwrap(); assert_eq!(url.path().unwrap(), ["..."]); let url: Url = "file:..".parse().unwrap(); assert_eq!(url.path().unwrap(), [""]); } #[test] fn relative_scheme_data_equality() { use std::hash::{Hash, Hasher, SipHasher}; fn check_eq(a: &Url, b: &Url) { assert_eq!(a, b); let mut h1 = SipHasher::new(); a.hash(&mut h1); let mut h2 = SipHasher::new(); b.hash(&mut h2); assert_eq!(h1.finish(), h2.finish()); } fn url(s: &str) -> Url { let rv = s.parse().unwrap(); check_eq(&rv, &rv); rv } // Doesn't care if default port is given. let a: Url = url("https://example.com/"); let b: Url = url("https://example.com:443/"); check_eq(&a, &b); // Different ports let a: Url = url("http://example.com/"); let b: Url = url("http://example.com:8080/"); assert!(a != b); // Different scheme let a: Url = url("http://example.com/"); let b: Url = url("https://example.com/"); assert!(a != b); // Different host let a: Url = url("http://foo.com/"); let b: Url = url("http://bar.com/"); assert!(a != b); // Missing path, automatically substituted. Semantically the same. let a: Url = url("http://foo.com"); let b: Url = url("http://foo.com/"); check_eq(&a, &b); } deps/url-0.2.38/src/punycode.rs0000644000175000017500000002132312527636640013260 0ustar // Copyright 2013 Simon Sapin. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Punycode ([RFC 3492](http://tools.ietf.org/html/rfc3492)) implementation. //! //! Since Punycode fundamentally works on unicode code points, //! `encode` and `decode` take and return slices and vectors of `char`. //! `encode_str` and `decode_to_string` provide convenience wrappers //! that convert from and to Rust’s UTF-8 based `str` and `String` types. use std::u32; use std::char; use std::ascii::AsciiExt; // Bootstring parameters for Punycode static BASE: u32 = 36; static T_MIN: u32 = 1; static T_MAX: u32 = 26; static SKEW: u32 = 38; static DAMP: u32 = 700; static INITIAL_BIAS: u32 = 72; static INITIAL_N: u32 = 0x80; static DELIMITER: char = '-'; #[inline] fn adapt(mut delta: u32, num_points: u32, first_time: bool) -> u32 { delta /= if first_time { DAMP } else { 2 }; delta += delta / num_points; let mut k = 0; while delta > ((BASE - T_MIN) * T_MAX) / 2 { delta /= BASE - T_MIN; k += BASE; } k + (((BASE - T_MIN + 1) * delta) / (delta + SKEW)) } /// Convert Punycode to an Unicode `String`. /// /// This is a convenience wrapper around `decode`. #[inline] pub fn decode_to_string(input: &str) -> Option { decode(input).map(|chars| chars.into_iter().collect()) } /// Convert Punycode to Unicode. /// /// Return None on malformed input or overflow. /// Overflow can only happen on inputs that take more than /// 63 encoded bytes, the DNS limit on domain name labels. pub fn decode(input: &str) -> Option> { // Handle "basic" (ASCII) code points. // They are encoded as-is before the last delimiter, if any. let (mut output, input) = match input.rfind(DELIMITER) { None => (Vec::new(), input), Some(position) => ( input[..position].chars().collect(), if position > 0 { &input[position + 1..] } else { input } ) }; let mut code_point = INITIAL_N; let mut bias = INITIAL_BIAS; let mut i = 0; let mut iter = input.bytes(); loop { let previous_i = i; let mut weight = 1; let mut k = BASE; let mut byte = match iter.next() { None => break, Some(byte) => byte, }; // Decode a generalized variable-length integer into delta, // which gets added to i. loop { let digit = match byte { byte @ b'0' ... b'9' => byte - b'0' + 26, byte @ b'A' ... b'Z' => byte - b'A', byte @ b'a' ... b'z' => byte - b'a', _ => return None } as u32; if digit > (u32::MAX - i) / weight { return None // Overflow } i += digit * weight; let t = if k <= bias { T_MIN } else if k >= bias + T_MAX { T_MAX } else { k - bias }; if digit < t { break } if weight > u32::MAX / (BASE - t) { return None // Overflow } weight *= BASE - t; k += BASE; byte = match iter.next() { None => return None, // End of input before the end of this delta Some(byte) => byte, }; } let length = output.len() as u32; bias = adapt(i - previous_i, length + 1, previous_i == 0); if i / (length + 1) > u32::MAX - code_point { return None // Overflow } // i was supposed to wrap around from length+1 to 0, // incrementing code_point each time. code_point += i / (length + 1); i %= length + 1; let c = match char::from_u32(code_point) { Some(c) => c, None => return None }; output.insert(i as usize, c); i += 1; } Some(output) } /// Convert an Unicode `str` to Punycode. /// /// This is a convenience wrapper around `encode`. #[inline] pub fn encode_str(input: &str) -> Option { encode(&input.chars().collect::>()) } /// Convert Unicode to Punycode. /// /// Return None on overflow, which can only happen on inputs that would take more than /// 63 encoded bytes, the DNS limit on domain name labels. pub fn encode(input: &[char]) -> Option { // Handle "basic" (ASCII) code points. They are encoded as-is. let output_bytes = input.iter().filter_map(|&c| if c.is_ascii() { Some(c as u8) } else { None } ).collect(); let mut output = unsafe { String::from_utf8_unchecked(output_bytes) }; let basic_length = output.len() as u32; if basic_length > 0 { output.push_str("-") } let mut code_point = INITIAL_N; let mut delta = 0; let mut bias = INITIAL_BIAS; let mut processed = basic_length; let input_length = input.len() as u32; while processed < input_length { // All code points < code_point have been handled already. // Find the next larger one. let min_code_point = input.iter().map(|&c| c as u32) .filter(|&c| c >= code_point).min().unwrap(); if min_code_point - code_point > (u32::MAX - delta) / (processed + 1) { return None // Overflow } // Increase delta to advance the decoder’s state to delta += (min_code_point - code_point) * (processed + 1); code_point = min_code_point; for &c in input { let c = c as u32; if c < code_point { delta += 1; if delta == 0 { return None // Overflow } } if c == code_point { // Represent delta as a generalized variable-length integer: let mut q = delta; let mut k = BASE; loop { let t = if k <= bias { T_MIN } else if k >= bias + T_MAX { T_MAX } else { k - bias }; if q < t { break } let value = t + ((q - t) % (BASE - t)); value_to_digit(value, &mut output); q = (q - t) / (BASE - t); k += BASE; } value_to_digit(q, &mut output); bias = adapt(delta, processed + 1, processed == basic_length); delta = 0; processed += 1; } } delta += 1; code_point += 1; } Some(output) } #[inline] fn value_to_digit(value: u32, output: &mut String) { let code_point = match value { 0 ... 25 => value + 0x61, // a..z 26 ... 35 => value - 26 + 0x30, // 0..9 _ => panic!() }; unsafe { output.as_mut_vec().push(code_point as u8) } } #[cfg(test)] mod tests { use super::{decode, encode_str}; use rustc_serialize::json::{Json, Object}; fn one_test(description: &str, decoded: &str, encoded: &str) { match decode(encoded) { None => panic!("Decoding {} failed.", encoded), Some(result) => { let result = result.into_iter().collect::(); assert!(result == decoded, format!("Incorrect decoding of {}:\n {}\n!= {}\n{}", encoded, result, decoded, description)) } } match encode_str(decoded) { None => panic!("Encoding {} failed.", decoded), Some(result) => { assert!(result == encoded, format!("Incorrect encoding of {}:\n {}\n!= {}\n{}", decoded, result, encoded, description)) } } } fn get_string<'a>(map: &'a Object, key: &str) -> &'a str { match map.get(&key.to_string()) { Some(&Json::String(ref s)) => s, None => "", _ => panic!(), } } #[test] fn test_punycode() { match Json::from_str(include_str!("punycode_tests.json")) { Ok(Json::Array(tests)) => for test in &tests { match test { &Json::Object(ref o) => one_test( get_string(o, "description"), get_string(o, "decoded"), get_string(o, "encoded") ), _ => panic!(), } }, other => panic!("{:?}", other) } } } deps/url-0.2.38/src/urlutils.rs0000644000175000017500000001523312515733407013314 0ustar // Copyright 2013-2014 Simon Sapin. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! These methods are not meant for use in Rust code, //! only to help implement the JavaScript URLUtils API: http://url.spec.whatwg.org/#urlutils use super::{Url, UrlParser, SchemeType, SchemeData, RelativeSchemeData}; use parser::{ParseError, ParseResult, Context}; use percent_encoding::{utf8_percent_encode_to, USERNAME_ENCODE_SET, PASSWORD_ENCODE_SET}; #[allow(dead_code)] pub struct UrlUtilsWrapper<'a> { pub url: &'a mut Url, pub parser: &'a UrlParser<'a>, } #[doc(hidden)] pub trait UrlUtils { fn set_scheme(&mut self, input: &str) -> ParseResult<()>; fn set_username(&mut self, input: &str) -> ParseResult<()>; fn set_password(&mut self, input: &str) -> ParseResult<()>; fn set_host_and_port(&mut self, input: &str) -> ParseResult<()>; fn set_host(&mut self, input: &str) -> ParseResult<()>; fn set_port(&mut self, input: &str) -> ParseResult<()>; fn set_path(&mut self, input: &str) -> ParseResult<()>; fn set_query(&mut self, input: &str) -> ParseResult<()>; fn set_fragment(&mut self, input: &str) -> ParseResult<()>; } impl<'a> UrlUtils for UrlUtilsWrapper<'a> { /// `URLUtils.protocol` setter fn set_scheme(&mut self, input: &str) -> ParseResult<()> { match ::parser::parse_scheme(input, Context::Setter) { Some((scheme, _)) => { if self.parser.get_scheme_type(&self.url.scheme).same_as(self.parser.get_scheme_type(&scheme)) { return Err(ParseError::InvalidScheme); } self.url.scheme = scheme; Ok(()) }, None => Err(ParseError::InvalidScheme), } } /// `URLUtils.username` setter fn set_username(&mut self, input: &str) -> ParseResult<()> { match self.url.scheme_data { SchemeData::Relative(RelativeSchemeData { ref mut username, .. }) => { username.truncate(0); utf8_percent_encode_to(input, USERNAME_ENCODE_SET, username); Ok(()) }, SchemeData::NonRelative(_) => Err(ParseError::CannotSetUsernameWithNonRelativeScheme) } } /// `URLUtils.password` setter fn set_password(&mut self, input: &str) -> ParseResult<()> { match self.url.scheme_data { SchemeData::Relative(RelativeSchemeData { ref mut password, .. }) => { if input.len() == 0 { *password = None; return Ok(()); } let mut new_password = String::new(); utf8_percent_encode_to(input, PASSWORD_ENCODE_SET, &mut new_password); *password = Some(new_password); Ok(()) }, SchemeData::NonRelative(_) => Err(ParseError::CannotSetPasswordWithNonRelativeScheme) } } /// `URLUtils.host` setter fn set_host_and_port(&mut self, input: &str) -> ParseResult<()> { match self.url.scheme_data { SchemeData::Relative(RelativeSchemeData { ref mut host, ref mut port, ref mut default_port, .. }) => { let scheme_type = self.parser.get_scheme_type(&self.url.scheme); let (new_host, new_port, new_default_port, _) = try!(::parser::parse_host( input, scheme_type, self.parser)); *host = new_host; *port = new_port; *default_port = new_default_port; Ok(()) }, SchemeData::NonRelative(_) => Err(ParseError::CannotSetHostPortWithNonRelativeScheme) } } /// `URLUtils.hostname` setter fn set_host(&mut self, input: &str) -> ParseResult<()> { match self.url.scheme_data { SchemeData::Relative(RelativeSchemeData { ref mut host, .. }) => { let (new_host, _) = try!(::parser::parse_hostname(input, self.parser)); *host = new_host; Ok(()) }, SchemeData::NonRelative(_) => Err(ParseError::CannotSetHostWithNonRelativeScheme) } } /// `URLUtils.port` setter fn set_port(&mut self, input: &str) -> ParseResult<()> { match self.url.scheme_data { SchemeData::Relative(RelativeSchemeData { ref mut port, ref mut default_port, .. }) => { let scheme_type = self.parser.get_scheme_type(&self.url.scheme); if scheme_type == SchemeType::FileLike { return Err(ParseError::CannotSetPortWithFileLikeScheme); } let (new_port, new_default_port, _) = try!(::parser::parse_port( input, scheme_type, self.parser)); *port = new_port; *default_port = new_default_port; Ok(()) }, SchemeData::NonRelative(_) => Err(ParseError::CannotSetPortWithNonRelativeScheme) } } /// `URLUtils.pathname` setter fn set_path(&mut self, input: &str) -> ParseResult<()> { match self.url.scheme_data { SchemeData::Relative(RelativeSchemeData { ref mut path, .. }) => { let scheme_type = self.parser.get_scheme_type(&self.url.scheme); let (new_path, _) = try!(::parser::parse_path_start( input, Context::Setter, scheme_type, self.parser)); *path = new_path; Ok(()) }, SchemeData::NonRelative(_) => Err(ParseError::CannotSetPathWithNonRelativeScheme) } } /// `URLUtils.search` setter fn set_query(&mut self, input: &str) -> ParseResult<()> { self.url.query = if input.is_empty() { None } else { let input = if input.starts_with("?") { &input[1..] } else { input }; let (new_query, _) = try!(::parser::parse_query( input, Context::Setter, self.parser)); Some(new_query) }; Ok(()) } /// `URLUtils.hash` setter fn set_fragment(&mut self, input: &str) -> ParseResult<()> { if self.url.scheme == "javascript" { return Err(ParseError::CannotSetJavascriptFragment) } self.url.fragment = if input.is_empty() { None } else { let input = if input.starts_with("#") { &input[1..] } else { input }; Some(try!(::parser::parse_fragment(input, self.parser))) }; Ok(()) } } deps/url-0.2.38/src/host.rs0000644000175000017500000002155412623123736012407 0ustar // Copyright 2013-2014 Simon Sapin. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::ascii::AsciiExt; use std::cmp; use std::fmt::{self, Formatter}; use parser::{ParseResult, ParseError}; use percent_encoding::{from_hex, percent_decode}; /// The host name of an URL. #[derive(PartialEq, Eq, Clone, Debug, Hash, PartialOrd, Ord)] #[cfg_attr(feature="heap_size", derive(HeapSizeOf))] pub enum Host { /// A (DNS) domain name or an IPv4 address. /// /// FIXME: IPv4 probably should be a separate variant. /// See https://www.w3.org/Bugs/Public/show_bug.cgi?id=26431 Domain(String), /// An IPv6 address, represented inside `[...]` square brackets /// so that `:` colon characters in the address are not ambiguous /// with the port number delimiter. Ipv6(Ipv6Address), } /// A 128 bit IPv6 address #[derive(Clone, Eq, PartialEq, Copy, Debug, Hash, PartialOrd, Ord)] pub struct Ipv6Address { pub pieces: [u16; 8] } #[cfg(feature="heap_size")] known_heap_size!(0, Ipv6Address); impl Host { /// Parse a host: either an IPv6 address in [] square brackets, or a domain. /// /// Returns `Err` for an empty host, an invalid IPv6 address, /// or a or invalid non-ASCII domain. /// /// FIXME: Add IDNA support for non-ASCII domains. pub fn parse(input: &str) -> ParseResult { if input.len() == 0 { Err(ParseError::EmptyHost) } else if input.starts_with("[") { if input.ends_with("]") { Ipv6Address::parse(&input[1..input.len() - 1]).map(Host::Ipv6) } else { Err(ParseError::InvalidIpv6Address) } } else { let decoded = percent_decode(input.as_bytes()); let domain = String::from_utf8_lossy(&decoded); // TODO: Remove this check and use IDNA "domain to ASCII" if !domain.is_ascii() { Err(ParseError::NonAsciiDomainsNotSupportedYet) } else if domain.find(&[ '\0', '\t', '\n', '\r', ' ', '#', '%', '/', ':', '?', '@', '[', '\\', ']' ][..]).is_some() { Err(ParseError::InvalidDomainCharacter) } else { Ok(Host::Domain(domain.to_ascii_lowercase())) } } } /// Serialize the host as a string. /// /// A domain a returned as-is, an IPv6 address between [] square brackets. pub fn serialize(&self) -> String { self.to_string() } } impl fmt::Display for Host { fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { match *self { Host::Domain(ref domain) => domain.fmt(formatter), Host::Ipv6(ref address) => { try!(formatter.write_str("[")); try!(address.fmt(formatter)); formatter.write_str("]") } } } } impl Ipv6Address { /// Parse an IPv6 address, without the [] square brackets. pub fn parse(input: &str) -> ParseResult { let input = input.as_bytes(); let len = input.len(); let mut is_ip_v4 = false; let mut pieces = [0, 0, 0, 0, 0, 0, 0, 0]; let mut piece_pointer = 0; let mut compress_pointer = None; let mut i = 0; if len < 2 { return Err(ParseError::InvalidIpv6Address) } if input[0] == b':' { if input[1] != b':' { return Err(ParseError::InvalidIpv6Address) } i = 2; piece_pointer = 1; compress_pointer = Some(1); } while i < len { if piece_pointer == 8 { return Err(ParseError::InvalidIpv6Address) } if input[i] == b':' { if compress_pointer.is_some() { return Err(ParseError::InvalidIpv6Address) } i += 1; piece_pointer += 1; compress_pointer = Some(piece_pointer); continue } let start = i; let end = cmp::min(len, start + 4); let mut value = 0u16; while i < end { match from_hex(input[i]) { Some(digit) => { value = value * 0x10 + digit as u16; i += 1; }, None => break } } if i < len { match input[i] { b'.' => { if i == start { return Err(ParseError::InvalidIpv6Address) } i = start; is_ip_v4 = true; }, b':' => { i += 1; if i == len { return Err(ParseError::InvalidIpv6Address) } }, _ => return Err(ParseError::InvalidIpv6Address) } } if is_ip_v4 { break } pieces[piece_pointer] = value; piece_pointer += 1; } if is_ip_v4 { if piece_pointer > 6 { return Err(ParseError::InvalidIpv6Address) } let mut dots_seen = 0; while i < len { // FIXME: https://github.com/whatwg/url/commit/1c22aa119c354e0020117e02571cec53f7c01064 let mut value = 0u16; while i < len { let digit = match input[i] { c @ b'0' ... b'9' => c - b'0', _ => break }; value = value * 10 + digit as u16; if value == 0 || value > 255 { return Err(ParseError::InvalidIpv6Address) } } if dots_seen < 3 && !(i < len && input[i] == b'.') { return Err(ParseError::InvalidIpv6Address) } pieces[piece_pointer] = pieces[piece_pointer] * 0x100 + value; if dots_seen == 0 || dots_seen == 2 { piece_pointer += 1; } i += 1; if dots_seen == 3 && i < len { return Err(ParseError::InvalidIpv6Address) } dots_seen += 1; } } match compress_pointer { Some(compress_pointer) => { let mut swaps = piece_pointer - compress_pointer; piece_pointer = 7; while swaps > 0 { pieces[piece_pointer] = pieces[compress_pointer + swaps - 1]; pieces[compress_pointer + swaps - 1] = 0; swaps -= 1; piece_pointer -= 1; } } _ => if piece_pointer != 8 { return Err(ParseError::InvalidIpv6Address) } } Ok(Ipv6Address { pieces: pieces }) } /// Serialize the IPv6 address to a string. pub fn serialize(&self) -> String { self.to_string() } } impl fmt::Display for Ipv6Address { fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { let (compress_start, compress_end) = longest_zero_sequence(&self.pieces); let mut i = 0; while i < 8 { if i == compress_start { try!(formatter.write_str(":")); if i == 0 { try!(formatter.write_str(":")); } if compress_end < 8 { i = compress_end; } else { break; } } try!(write!(formatter, "{:x}", self.pieces[i as usize])); if i < 7 { try!(formatter.write_str(":")); } i += 1; } Ok(()) } } fn longest_zero_sequence(pieces: &[u16; 8]) -> (isize, isize) { let mut longest = -1; let mut longest_length = -1; let mut start = -1; macro_rules! finish_sequence( ($end: expr) => { if start >= 0 { let length = $end - start; if length > longest_length { longest = start; longest_length = length; } } }; ); for i in 0..8 { if pieces[i as usize] == 0 { if start < 0 { start = i; } } else { finish_sequence!(i); start = -1; } } finish_sequence!(8); (longest, longest + longest_length) } deps/url-0.2.38/src/format.rs0000644000175000017500000001073412520520763012715 0ustar // Copyright 2013-2015 Simon Sapin. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Formatting utilities for URLs. //! //! These formatters can be used to coerce various URL parts into strings. //! //! You can use `.to_string()`, as the formatters implement `fmt::Display`. use std::fmt::{self, Formatter}; use super::Url; /// Formatter and serializer for URL path data. pub struct PathFormatter<'a, T:'a> { /// The path as a slice of string-like objects (String or &str). pub path: &'a [T] } impl<'a, T: fmt::Display> fmt::Display for PathFormatter<'a, T> { fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { if self.path.is_empty() { formatter.write_str("/") } else { for path_part in self.path { try!("/".fmt(formatter)); try!(path_part.fmt(formatter)); } Ok(()) } } } /// Formatter and serializer for URL username and password data. pub struct UserInfoFormatter<'a> { /// URL username as a string slice. pub username: &'a str, /// URL password as an optional string slice. /// /// You can convert an `Option` with `.as_ref().map(|s| s)`. pub password: Option<&'a str> } impl<'a> fmt::Display for UserInfoFormatter<'a> { fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { if !self.username.is_empty() || self.password.is_some() { try!(formatter.write_str(self.username)); if let Some(password) = self.password { try!(formatter.write_str(":")); try!(formatter.write_str(password)); } try!(formatter.write_str("@")); } Ok(()) } } /// Formatter for URLs which ignores the fragment field. pub struct UrlNoFragmentFormatter<'a> { pub url: &'a Url } impl<'a> fmt::Display for UrlNoFragmentFormatter<'a> { fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { try!(formatter.write_str(&self.url.scheme)); try!(formatter.write_str(":")); try!(self.url.scheme_data.fmt(formatter)); if let Some(ref query) = self.url.query { try!(formatter.write_str("?")); try!(formatter.write_str(query)); } Ok(()) } } /// Formatting Tests #[cfg(test)] mod tests { use super::super::Url; use super::{PathFormatter, UserInfoFormatter}; #[test] fn path_formatting() { let data = [ (vec![], "/"), (vec![""], "/"), (vec!["test", "path"], "/test/path"), (vec!["test", "path", ""], "/test/path/") ]; for &(ref path, result) in &data { assert_eq!(PathFormatter { path: path }.to_string(), result.to_string()); } } #[test] fn userinfo_formatting() { // Test data as (username, password, result) tuples. let data = [ ("", None, ""), ("", Some(""), ":@"), ("", Some("password"), ":password@"), ("username", None, "username@"), ("username", Some(""), "username:@"), ("username", Some("password"), "username:password@") ]; for &(username, password, result) in &data { assert_eq!(UserInfoFormatter { username: username, password: password }.to_string(), result.to_string()); } } #[test] fn relative_scheme_url_formatting() { let data = [ ("http://example.com/", "http://example.com/"), ("http://addslash.com", "http://addslash.com/"), ("http://@emptyuser.com/", "http://emptyuser.com/"), ("http://:@emptypass.com/", "http://:@emptypass.com/"), ("http://user@user.com/", "http://user@user.com/"), ("http://user:pass@userpass.com/", "http://user:pass@userpass.com/"), ("http://slashquery.com/path/?q=something", "http://slashquery.com/path/?q=something"), ("http://noslashquery.com/path?q=something", "http://noslashquery.com/path?q=something") ]; for &(input, result) in &data { let url = Url::parse(input).unwrap(); assert_eq!(url.to_string(), result.to_string()); } } } deps/url-0.2.38/src/percent_encoding.rs0000644000175000017500000001212012623114164014720 0ustar // Copyright 2013-2014 Simon Sapin. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #[path = "encode_sets.rs"] mod encode_sets; /// Represents a set of characters / bytes that should be percent-encoded. /// /// See [encode sets specification](http://url.spec.whatwg.org/#simple-encode-set). /// /// Different characters need to be encoded in different parts of an URL. /// For example, a literal `?` question mark in an URL’s path would indicate /// the start of the query string. /// A question mark meant to be part of the path therefore needs to be percent-encoded. /// In the query string however, a question mark does not have any special meaning /// and does not need to be percent-encoded. /// /// Since the implementation details of `EncodeSet` are private, /// the set of available encode sets is not extensible beyond the ones /// provided here. /// If you need a different encode set, /// please [file a bug](https://github.com/servo/rust-url/issues) /// explaining the use case. #[derive(Copy, Clone)] pub struct EncodeSet { map: &'static [&'static str; 256], } /// This encode set is used for fragment identifier and non-relative scheme data. pub static SIMPLE_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::SIMPLE }; /// This encode set is used in the URL parser for query strings. pub static QUERY_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::QUERY }; /// This encode set is used for path components. pub static DEFAULT_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::DEFAULT }; /// This encode set is used in the URL parser for usernames and passwords. pub static USERINFO_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::USERINFO }; /// This encode set should be used when setting the password field of a parsed URL. pub static PASSWORD_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::PASSWORD }; /// This encode set should be used when setting the username field of a parsed URL. pub static USERNAME_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::USERNAME }; /// This encode set is used in `application/x-www-form-urlencoded` serialization. pub static FORM_URLENCODED_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::FORM_URLENCODED, }; /// This encode set is used for HTTP header values and is defined at /// https://tools.ietf.org/html/rfc5987#section-3.2 pub static HTTP_VALUE_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::HTTP_VALUE }; /// Percent-encode the given bytes, and push the result to `output`. /// /// The pushed strings are within the ASCII range. #[inline] pub fn percent_encode_to(input: &[u8], encode_set: EncodeSet, output: &mut String) { for &byte in input { output.push_str(encode_set.map[byte as usize]) } } /// Percent-encode the given bytes. /// /// The returned string is within the ASCII range. #[inline] pub fn percent_encode(input: &[u8], encode_set: EncodeSet) -> String { let mut output = String::new(); percent_encode_to(input, encode_set, &mut output); output } /// Percent-encode the UTF-8 encoding of the given string, and push the result to `output`. /// /// The pushed strings are within the ASCII range. #[inline] pub fn utf8_percent_encode_to(input: &str, encode_set: EncodeSet, output: &mut String) { percent_encode_to(input.as_bytes(), encode_set, output) } /// Percent-encode the UTF-8 encoding of the given string. /// /// The returned string is within the ASCII range. #[inline] pub fn utf8_percent_encode(input: &str, encode_set: EncodeSet) -> String { let mut output = String::new(); utf8_percent_encode_to(input, encode_set, &mut output); output } /// Percent-decode the given bytes, and push the result to `output`. pub fn percent_decode_to(input: &[u8], output: &mut Vec) { let mut i = 0; while i < input.len() { let c = input[i]; if c == b'%' && i + 2 < input.len() { if let (Some(h), Some(l)) = (from_hex(input[i + 1]), from_hex(input[i + 2])) { output.push(h * 0x10 + l); i += 3; continue } } output.push(c); i += 1; } } /// Percent-decode the given bytes. #[inline] pub fn percent_decode(input: &[u8]) -> Vec { let mut output = Vec::new(); percent_decode_to(input, &mut output); output } /// Percent-decode the given bytes, and decode the result as UTF-8. /// /// This is “lossy”: invalid UTF-8 percent-encoded byte sequences /// will be replaced � U+FFFD, the replacement character. #[inline] pub fn lossy_utf8_percent_decode(input: &[u8]) -> String { String::from_utf8_lossy(&percent_decode(input)).to_string() } #[inline] pub fn from_hex(byte: u8) -> Option { match byte { b'0' ... b'9' => Some(byte - b'0'), // 0..9 b'A' ... b'F' => Some(byte + 10 - b'A'), // A..F b'a' ... b'f' => Some(byte + 10 - b'a'), // a..f _ => None } } deps/url-0.2.38/src/encode_sets.rs0000644000175000017500000003434512623114164013722 0ustar // Copyright 2013-2014 Simon Sapin. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Generated by make_encode_sets.py pub static SIMPLE: [&'static str; 256] = [ "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", " ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", "%7F", "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF", ]; pub static QUERY: [&'static str; 256] = [ "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", "%20", "!", "%22", "%23", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "%3C", "=", "%3E", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", "%7F", "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF", ]; pub static DEFAULT: [&'static str; 256] = [ "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", "%20", "!", "%22", "%23", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "%3C", "=", "%3E", "%3F", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_", "%60", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "%7B", "|", "%7D", "~", "%7F", "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF", ]; pub static USERINFO: [&'static str; 256] = [ "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", "%20", "!", "%22", "%23", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "%3C", "=", "%3E", "%3F", "%40", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_", "%60", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "%7B", "|", "%7D", "~", "%7F", "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF", ]; pub static PASSWORD: [&'static str; 256] = [ "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", "%20", "!", "%22", "%23", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "%2F", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "%3C", "=", "%3E", "%3F", "%40", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "%5C", "]", "^", "_", "%60", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "%7B", "|", "%7D", "~", "%7F", "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF", ]; pub static USERNAME: [&'static str; 256] = [ "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", "%20", "!", "%22", "%23", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "%2F", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "%3A", ";", "%3C", "=", "%3E", "%3F", "%40", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "%5C", "]", "^", "_", "%60", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "%7B", "|", "%7D", "~", "%7F", "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF", ]; pub static FORM_URLENCODED: [&'static str; 256] = [ "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", "%20", "%21", "%22", "%23", "%24", "%25", "%26", "%27", "%28", "%29", "*", "%2B", "%2C", "-", ".", "%2F", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "%3A", "%3B", "%3C", "%3D", "%3E", "%3F", "%40", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "%5B", "%5C", "%5D", "%5E", "_", "%60", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "%7B", "%7C", "%7D", "%7E", "%7F", "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF", ]; pub static HTTP_VALUE: [&'static str; 256] = [ "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", "%20", "!", "%22", "#", "$", "%25", "&", "%27", "%28", "%29", "%2A", "+", "%2C", "%2D", ".", "%2F", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "%3A", "%3B", "%3C", "=", "%3E", "%3F", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "%5B", "%5C", "%5D", "^", "_", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "%7B", "|", "%7D", "~", "%7F", "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF", ]; deps/url-0.2.38/src/encoding.rs0000644000175000017500000000550412507450012013204 0ustar // Copyright 2013-2014 Simon Sapin. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Abstraction that conditionally compiles either to rust-encoding, //! or to only support UTF-8. #[cfg(feature = "query_encoding")] extern crate encoding; use std::borrow::Cow; #[cfg(feature = "query_encoding")] use self::encoding::types::{DecoderTrap, EncoderTrap}; #[cfg(feature = "query_encoding")] use self::encoding::label::encoding_from_whatwg_label; #[cfg(feature = "query_encoding")] pub use self::encoding::types::EncodingRef; #[cfg(feature = "query_encoding")] #[derive(Copy, Clone)] pub struct EncodingOverride { /// `None` means UTF-8. encoding: Option } #[cfg(feature = "query_encoding")] impl EncodingOverride { pub fn from_opt_encoding(encoding: Option) -> EncodingOverride { encoding.map(EncodingOverride::from_encoding).unwrap_or_else(EncodingOverride::utf8) } pub fn from_encoding(encoding: EncodingRef) -> EncodingOverride { EncodingOverride { encoding: if encoding.name() == "utf-8" { None } else { Some(encoding) } } } pub fn utf8() -> EncodingOverride { EncodingOverride { encoding: None } } pub fn lookup(label: &[u8]) -> Option { ::std::str::from_utf8(label) .ok() .and_then(encoding_from_whatwg_label) .map(EncodingOverride::from_encoding) } pub fn is_utf8(&self) -> bool { self.encoding.is_none() } pub fn decode(&self, input: &[u8]) -> String { match self.encoding { Some(encoding) => encoding.decode(input, DecoderTrap::Replace).unwrap(), None => String::from_utf8_lossy(input).to_string(), } } pub fn encode<'a>(&self, input: &'a str) -> Cow<'a, [u8]> { match self.encoding { Some(encoding) => Cow::Owned( encoding.encode(input, EncoderTrap::NcrEscape).unwrap()), None => Cow::Borrowed(input.as_bytes()), // UTF-8 } } } #[cfg(not(feature = "query_encoding"))] #[derive(Copy, Clone)] pub struct EncodingOverride; #[cfg(not(feature = "query_encoding"))] impl EncodingOverride { pub fn utf8() -> EncodingOverride { EncodingOverride } pub fn lookup(_label: &[u8]) -> Option { None } pub fn is_utf8(&self) -> bool { true } pub fn decode(&self, input: &[u8]) -> String { String::from_utf8_lossy(input).into_owned() } pub fn encode<'a>(&self, input: &'a str) -> Cow<'a, [u8]> { Cow::Borrowed(input.as_bytes()) } } deps/url-0.2.38/src/form_urlencoded.rs0000644000175000017500000001420512623114164014567 0ustar // Copyright 2013-2015 Simon Sapin. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Parser and serializer for the [`application/x-www-form-urlencoded` format]( //! http://url.spec.whatwg.org/#application/x-www-form-urlencoded), //! as used by HTML forms. //! //! Converts between a string (such as an URL’s query string) //! and a sequence of (name, value) pairs. use std::borrow::Borrow; use std::ascii::AsciiExt; use encoding::EncodingOverride; use percent_encoding::{percent_encode_to, percent_decode, FORM_URLENCODED_ENCODE_SET}; /// Convert a byte string in the `application/x-www-form-urlencoded` format /// into a vector of (name, value) pairs. /// /// Use `parse(input.as_bytes())` to parse a `&str` string. /// /// The names and values are URL-decoded. For instance, `%23first=%25try%25` will be /// converted to `[("#first", "%try%")]`. #[inline] pub fn parse(input: &[u8]) -> Vec<(String, String)> { parse_internal(input, EncodingOverride::utf8(), false).unwrap() } /// Convert a byte string in the `application/x-www-form-urlencoded` format /// into a vector of (name, value) pairs. /// /// Use `parse(input.as_bytes())` to parse a `&str` string. /// /// This function is only available if the `query_encoding` Cargo feature is enabled. /// /// Arguments: /// /// * `encoding_override`: The character encoding each name and values is decoded as /// after percent-decoding. Defaults to UTF-8. /// * `use_charset`: The *use _charset_ flag*. If in doubt, set to `false`. #[cfg(feature = "query_encoding")] #[inline] pub fn parse_with_encoding(input: &[u8], encoding_override: Option<::encoding::EncodingRef>, use_charset: bool) -> Option> { parse_internal(input, EncodingOverride::from_opt_encoding(encoding_override), use_charset) } fn parse_internal(input: &[u8], mut encoding_override: EncodingOverride, mut use_charset: bool) -> Option> { let mut pairs = Vec::new(); for piece in input.split(|&b| b == b'&') { if !piece.is_empty() { let (name, value) = match piece.iter().position(|b| *b == b'=') { Some(position) => (&piece[..position], &piece[position + 1..]), None => (piece, &[][..]) }; #[inline] fn replace_plus(input: &[u8]) -> Vec { input.iter().map(|&b| if b == b'+' { b' ' } else { b }).collect() } let name = replace_plus(name); let value = replace_plus(value); if use_charset && name == b"_charset_" { if let Some(encoding) = EncodingOverride::lookup(&value) { encoding_override = encoding; } use_charset = false; } pairs.push((name, value)); } } if !(encoding_override.is_utf8() || input.is_ascii()) { return None } Some(pairs.into_iter().map(|(name, value)| ( encoding_override.decode(&percent_decode(&name)), encoding_override.decode(&percent_decode(&value)) )).collect()) } /// Convert an iterator of (name, value) pairs /// into a string in the `application/x-www-form-urlencoded` format. #[inline] pub fn serialize(pairs: I) -> String where I: IntoIterator, I::Item: Borrow<(K, V)>, K: AsRef, V: AsRef { serialize_internal(pairs, EncodingOverride::utf8()) } /// Convert an iterator of (name, value) pairs /// into a string in the `application/x-www-form-urlencoded` format. /// /// This function is only available if the `query_encoding` Cargo feature is enabled. /// /// Arguments: /// /// * `encoding_override`: The character encoding each name and values is encoded as /// before percent-encoding. Defaults to UTF-8. #[cfg(feature = "query_encoding")] #[inline] pub fn serialize_with_encoding(pairs: I, encoding_override: Option<::encoding::EncodingRef>) -> String where I: IntoIterator, I::Item: Borrow<(K, V)>, K: AsRef, V: AsRef { serialize_internal(pairs, EncodingOverride::from_opt_encoding(encoding_override)) } fn serialize_internal(pairs: I, encoding_override: EncodingOverride) -> String where I: IntoIterator, I::Item: Borrow<(K, V)>, K: AsRef, V: AsRef { #[inline] fn byte_serialize(input: &str, output: &mut String, encoding_override: EncodingOverride) { for &byte in encoding_override.encode(input).iter() { if byte == b' ' { output.push_str("+") } else { percent_encode_to(&[byte], FORM_URLENCODED_ENCODE_SET, output) } } } let mut output = String::new(); for pair in pairs { let &(ref name, ref value) = pair.borrow(); if output.len() > 0 { output.push_str("&"); } byte_serialize(name.as_ref(), &mut output, encoding_override); output.push_str("="); byte_serialize(value.as_ref(), &mut output, encoding_override); } output } #[cfg(test)] mod tests { use super::*; #[test] fn test_form_urlencoded() { let pairs = &[ ("foo".to_string(), "é&".to_string()), ("bar".to_string(), "".to_string()), ("foo".to_string(), "#".to_string()) ]; let encoded = serialize(pairs); assert_eq!(encoded, "foo=%C3%A9%26&bar=&foo=%23"); assert_eq!(parse(encoded.as_bytes()), pairs.to_vec()); } #[test] fn test_form_serialize() { let pairs = [("foo", "é&"), ("bar", ""), ("foo", "#")]; let want = "foo=%C3%A9%26&bar=&foo=%23"; // Works with referenced tuples assert_eq!(serialize(pairs.iter()), want); // Works with owned tuples assert_eq!(serialize(pairs.iter().map(|p| (p.0, p.1))), want); } } deps/url-0.2.38/appveyor.yml0000644000175000017500000000061712523622012012650 0ustar install: - ps: Start-FileDownload 'https://static.rust-lang.org/dist/rust-nightly-i686-pc-windows-gnu.exe' - rust-nightly-i686-pc-windows-gnu.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin - rustc -V - cargo -V - git submodule update --init --recursive build: false test_script: - cargo build - cargo test --verbose deps/url-0.2.38/Cargo.toml0000644000175000017500000000142112623124073012207 0ustar [package] name = "url" version = "0.2.38" authors = [ "Simon Sapin " ] description = "URL library for Rust, based on the WHATWG URL Standard" documentation = "http://servo.github.io/rust-url/url/index.html" repository = "https://github.com/servo/rust-url" readme = "README.md" keywords = ["url", "parser"] license = "MIT/Apache-2.0" [features] query_encoding = ["encoding"] serde_serialization = ["serde"] heap_size = ["heapsize", "heapsize_plugin"] [dependencies.heapsize] version = "0.1.1" optional = true [dependencies.heapsize_plugin] version = "0.1.0" optional = true [dependencies.encoding] version = "0.2" optional = true [dependencies.serde] version = "0.6.1" optional = true [dependencies] uuid = "0.1.17" rustc-serialize = "0.3" matches = "0.1" deps/url-0.2.38/Makefile0000644000175000017500000000113412563127736011734 0ustar test: cargo test --features query_encoding cargo test --features serde_serialization cargo test [ x$$TRAVIS_RUST_VERSION != xnightly ] || cargo test --features heap_size doc: cargo doc --features "query_encoding serde_serialization" @echo '' > target/doc/index.html @cp github.png target/doc/ upload-doc: doc test "$(TRAVIS_BRANCH)" = master test "$(TRAVIS_PULL_REQUEST)" = false sudo pip install ghp-import ghp-import -n target/doc git push -qf https://$(TOKEN)@github.com/$(TRAVIS_REPO_SLUG).git gh-pages .PHONY: test doc upload-doc deps/url-0.2.38/github.png0000644000175000017500000001715212366246343012270 0ustar PNG  IHDRQOtEXtSoftwareAdobe ImageReadyqe< IDATx] TTg .w 5*$j$*NY眙ta̙3= tLbLZIDwEdEpÂy}UE㽪B(9%~Occ# kHfr,t)."(4tM{O  tWAiy+>JAeck|-?{(@i m{ m=n߽51ѐCޤWnJ?ؽսTQO0`ؗT@IC&QHka:)ӟ+@ն UA庴c fܺWK& wiˡ-d1!4]!ϕ\ P+tiQaQzUtD ^4PUjjެW,9+ HPu ?}aB!^*3޿CgɂFH|G-]DAsi&S@ zkIzxŻP'?'O%ux@9U*dmHzĐ}i_>uSM!m'эs7mZoHw( {y Yf9Np6Pz~5UlI JSJTmq} =R^E#Z1gŽwtuk- H[2q\K7.ɭ>*`9).̦ڌ{CD Bđ Y򩶮9Mnh sixᴳx'UNo-t;OZ@ N6Uf,J.8q~Oa%Kp w.ףO3N:M˃^+(-)˕4=TG de?2f\Lr)0`En:@uٜʓ^ޘc[vZsE%X:},e6/I/XΉx#g'>˕CuٜȤG1fMpG&Lٿ気u*+ZB؃ʕBGIrNkw*93ӟ!2~Ƞgs@r)aS6ȯwF;LmƧ\ٙ(69_2hsd9\(u֑ib 3 v. cUlrCIܺwc1`OJjXHmcLM{(]zO17A+=^< yGL4tsF5kE!#*7x%x'|9Gr2`3)fB {-I270<PԼ]HQ*+:<'LQX@ۥXF eb;R),NrXg)315R:rR @|) J*9Meɞ?6|nTSPu7@a@*y.2P*,5CdfcjN*͈cET9s+SΩ|5# ͜T n哗#o{f/]uU=R/dJ4TBL=+{RB"'GG|2@g\Q硺[Z@?&P(U7/7 5&4]7^̀.MN9zxWN}}  n<˘iRf*s͐_vsP#%cavI='X[Gߦ:G=BjtzC^T!տSHͧ2ͯgBŘ`ET (}0O?z@uOI//|He:<ԩSr!Mʥ9fe 2o8MCF{ߠ.Sy*^X2g7&\2T}[/I|7H1h7=Nv!AY,hGT ^N\j@ N*r6)R()3[eS&7yjX3 J/O?Nʿ*.V\LNZ (>6X/]T Toeʔt'V!B(ƒ·2+Ju^^< y-7C/EF ꞑd  y%_60 *4(F[ۄ<$F>Fh5ʢw?161RuWrAzYo<=hNP*mreX~+Tø/WtRRnVE^sYEߞ} e?Й3]9)z! f]z((Y^CO^! X8K5e@srTiU^Q 掙=%{ d> TNyUNVl>ǭ@z(̔ML,2˽8eڟE5t#'\CYlY2BK(m_՝jOSASls؝ulB'&5+'ߛDj:YE؏E)̑7(2Qo-L{hC滜8eCOlncTM`,v$ ,z"rHTI}iOѝw9||FWnx]S{e`sA,ÝJт yx8p򏒙Bǀmdȭ 2*K*]/Cß'LyԨ(TN=:}  .2RzO1 5)?zh:m9P xB3{yj@K#<6hA ,dz eϠѠ !қlړRD`бq}e`$R;8E&+>2_%*T~Si֨Y6FZ z-=$24p FVp Hf:Vr,o fʀi? \i픵<`xZ/w̢^՟'!{ybũN rm&B.Wx8 =MgMƔ46#G_a3$)fBg̣GDNN``f/&`6 T(l1v`PAA3K%@'n9bX􄜏NUÀǁXrzؓӞE {6ЭsQӵ%9,}}ЁڀRQײ.yr&Q3@(bWjZ@>mL[W qyfI `Z1Xʗ)+qUVQzڒ3PH~zr[2{s4& E;wr{o@hfZX}<\\M(տ# Te`bgu]ᬗ'&`l\ *2ʦt sZ[mTz`|̥3eEO҇/]XMWP0 tq'#3 3e[x_f3ՌUx+\O5*x1/5*I}ȥZ"OJ\w<ŒGϳ0p9,&h-'؁Q_-ohgLyGP -ˀ=sFu?ىT?G̎z:1e&dCx*8}ytrTQ n*hMPYcJ$1x*̟fr5G~ B *<0;x1m`̃,!B^dž?r|%| ,>ycKe^sJ?0koؽj+j -G@9?TX6uWСflC!yt [1~aUx^<҉Kq?m\:FCʧ\c,7Qs%ܧ?|2xNk<P+Ma洁JxbLbh0m1_HGRH1>Z0hHRp:||>zgN(/L/%*ీ @/:N;Kn0-E^ꔼ*:~-@Ք4NI欋 `UUTzP_^G>cǎ @yyNOQ E$?T\}EY?Fӻi=/Լ{q֋̔C,üI^R y@# CiKeg-ɷN+%@@9r&/* /,(jiFpK e'B̀KyJrJ{P=6[(%lI6MjZ81ix*{fXhm;M3&@ʌ1|)(޷,|K]=*"02m4$eH9TLAioZD桔`jX,֋T ~m&`HS㸷W,|^< Ԁ)=T/^ǼzyUg2:8ZV)2T^\.x(ᩜ{-5Oe @lVV'@F 10 @ PS <a)ged @ Py(h`*+m0e@DՀ)r}pMiMz&1`'!35UPTTLlͅ;iM@a0Ӗ-T[^!%LV昱kT׿'zy”ʍ:y(2ʊD;ڝv_C,|MTxb_RJщg\Fz;lg47 \;J``,|IŅ" sSy,ǿSE ia̩˛1jzS>Ex(a-apٸeԯG?Jߗ. @ kbQL`/OJG +kIy~&+;@IJ]ÀݨQM7TQ\Vׄ*O|A }HFCnN:Z567@uޤ`]Pˆ ĺu=39v0% ]ޥ?Q# vT{N R4 @ si>vكJ 0G v=Ww0uzt'xu50MPY<==Y0MJA%ph-%-Pd%nd9„5UkRha$j)am*"a4 į@07Ѻ&<0*aT„ P >$ ίɌIENDB`deps/url-0.2.38/make_encode_sets.py0000644000175000017500000000275312623114164014132 0ustar # Copyright 2013-2014 Simon Sapin. # # Licensed under the Apache License, Version 2.0 or the MIT license # , at your # option. This file may not be copied, modified, or distributed # except according to those terms. # Run as: python make_encode_sets.py > src/encode_sets.rs print('''\ // Copyright 2013-2014 Simon Sapin. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Generated by make_encode_sets.py ''') for name, encoded in [ ('SIMPLE', ''), ('QUERY', r''' "#<>'''), ('DEFAULT', r''' "#<>`?{}'''), ('USERINFO', r''' "#<>`?{}@'''), ('PASSWORD', r''' "#<>`?{}@\/'''), ('USERNAME', r''' "#<>`?{}@\/:'''), ('FORM_URLENCODED', r''' !"#$%&\'()+,/:;<=>?@[\]^`{|}~'''), ('HTTP_VALUE', r''' "%'()*,/:;<->?[\]{}'''), ]: print( "pub static %s: [&'static str; 256] = [\n%s\n];\n\n" % (name, '\n'.join( ' ' + ' '.join( '"%s%s",' % ("\\" if chr(b) in '\\"' else "", chr(b)) if 0x20 <= b <= 0x7E and chr(b) not in encoded else '"%%%02X",' % b for b in range(s, s + 8) ) for s in range(0, 256, 8)))) deps/curl-0.2.14/0000755000000000000000000000000012666635520012207 5ustar rootrootdeps/curl-0.2.14/.travis.yml0000664000175000017500000000012212564434503012532 0ustar language: rust sudo: false rust: - 1.1.0 os: - linux script: - cargo test deps/curl-0.2.14/README.md0000664000175000017500000000320012564434503011700 0ustar # Curl-Rust libcurl bindings for Rust. **This project is in active development and could (will probably) break API compatibility at any time**. [![Build Status](https://travis-ci.org/carllerche/curl-rust.svg?branch=master)](https://travis-ci.org/carllerche/curl-rust) [![crates.io](http://meritbadge.herokuapp.com/mio)](https://crates.io/crates/curl) ## Quick Start ```rust extern crate curl; use curl::http; pub fn main() { let resp = http::handle() .get("http://www.example.com") .exec().unwrap(); println!("code={}; headers={:?}; body={:?}", resp.get_code(), resp.get_headers(), resp.get_body()); } ``` Response header names are automatically lower cased. ## Post / Put requests Both of these methods expect that a request body is provided. A request body can be a `&[u8]`, `&str`, or `&Reader`. For example: ```rust let resp = http::handle() .post("http://www.example.com/upload", "this is the body") .exec().unwrap(); ``` ## Custom headers Custom headers can be specified as part of the request: ```rust http::handle() .get("http://www.example.com") .header("Authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==") .exec(); ``` ## Keep alive The handle can be re-used across multiple requests. Curl will attempt to keep the connections alive. ```rust let handle = http::handle(); let resp1 = handle.get("http://www.example.com/foo").exec().unwrap(); let resp2 = handle.get("http://www.example.com/bar").exec().unwrap(); ``` ## Version Support The bindings have been developed using curl version 7.24.0. They should work with any newer version of curl and possibly with older versions, but this has not been tested. deps/curl-0.2.14/.gitignore0000664000175000017500000000002312464177601012413 0ustar Cargo.lock target/ deps/curl-0.2.14/LICENSE0000664000175000017500000000203712357411472011435 0ustar Copyright (c) 2014 Carl Lerche Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/curl-0.2.14/test/0000755000000000000000000000000012666635520013166 5ustar rootrootdeps/curl-0.2.14/test/server.rs0000664000175000017500000001565212520216467013271 0ustar use std::collections::HashSet; use std::io::prelude::*; use std::iter::repeat; use std::net::{TcpStream, TcpListener}; use std::str; use std::sync::mpsc::{channel, Sender, Receiver}; use std::thread; use self::Op::{SendBytes, ReceiveBytes, Wait, Shutdown}; // Global handle to the running test HTTP server thread_local!(static HANDLE: Handle = start_server()); // Setup an op sequence with the test HTTP server pub fn setup(ops: OpSequence) -> OpSequenceResult { // Setup a channel to receive the response on let (tx, rx) = channel(); // Send the op sequence to the server task HANDLE.with(move |h| { h.send(ops, tx); }); OpSequenceResult::new(rx) } pub fn url(path: &str) -> String { format!("http://localhost:{}{}", port(), path) } fn port() -> usize { HANDLE.with(|h| { h.port() }) } /* Handle to the running HTTP server task. Communication with the server * happens over channels. */ struct Handle { port: u16, tx: Sender<(OpSequence, Sender>)> } /* Operations for the test server to perform: * - Send some bytes * - Expect to receive bytes * - Wait for a certain amount of time * - Shutdown the server (allows a clean exit at the end of the tests) */ #[derive(Clone,PartialEq,Debug)] pub enum Op { SendBytes(&'static [u8]), ReceiveBytes(&'static [u8]), Wait(usize), Shutdown } /* An ordered sequence of operations for the HTTP server to perform */ #[derive(Debug)] pub struct OpSequence { ops: Vec } /* Represents the completion of the of the op sequence by the HTTP * server. */ pub struct OpSequenceResult { rx: Receiver> } impl OpSequence { pub fn new(op: Op) -> OpSequence { OpSequence { ops: vec!(op) } } pub fn concat(op: Op, seq: OpSequence) -> OpSequence { let mut ops = vec!(op); ops.extend(seq.ops.iter().cloned()); OpSequence { ops: ops } } pub fn is_shutdown(&self) -> bool { self.ops.len() == 1 && self.ops[0] == Shutdown } pub fn apply(&self, sock: &mut TcpStream, port: usize) -> Result<(), String> { for op in self.ops.iter() { match op { &SendBytes(b) => { let b = insert_port(b, port); match sock.write_all(&b) { Ok(_) => {} Err(e) => return Err(e.to_string()) } } &ReceiveBytes(b) => { let b = insert_port(b, port); let mut rem = b.len(); let mut act = repeat(0u8).take(rem).collect::>(); while rem > 0 { match sock.read(&mut act[b.len() - rem..]) { Ok(i) => rem = rem - i, Err(e) => { debug!("aborting due to error; error={}; \ remaining={}; bytes=\n{}", e, rem, to_debug_str(&act)); return Err(e.to_string()) } } } debug!("server received bytes; rem={}; bytes=\n{}\n~~~~~~~~~~~~~~", rem, to_debug_str(&act)); let req1 = parse_request(&b); let req2 = parse_request(&act); if req1 != req2 { return Err(format!( "received unexpected byte sequence.\n\n\ Expected:\n{}\n\nReceived:\n{}", to_debug_str(&b), to_debug_str(&act))); } } &Wait(ms) => thread::sleep_ms(ms as u32), &Shutdown => { return Err("Shutdown must be sent on its own".to_string()) } } } return Ok(()); fn insert_port(bytes: &'static [u8], port: usize) -> Vec { let s = str::from_utf8(bytes).unwrap(); let p = port.to_string(); s.replace("{PORT}", &p).into_bytes() } fn parse_request<'a>(req: &'a [u8]) -> (&'a [u8], HashSet<&'a [u8]>, &'a [u8]) { let mut start = None; let mut headers = HashSet::new(); let mut taken = 0; for part in req.split(|a| *a == b'\n') { taken += part.len() + 1; if start.is_none() { start = Some(part); } else if part.len() == 1 { break; } else { headers.insert(part); } } if taken > req.len() { taken = req.len(); } (start.unwrap(), headers, &req[taken..]) } } } fn to_debug_str(bytes: &[u8]) -> String { let mut ret = String::new(); for b in bytes.iter() { let b = *b as char; if b >= ' ' && b <= '~' { ret.push(b); } else if b == '\n' { ret.push_str("\\n\n"); } else if b == '\r' { ret.push_str("\\r"); } else { ret.push('?'); } } ret } impl Handle { fn new(tx: Sender<(OpSequence, Sender>)>, port: u16) -> Handle { Handle { tx: tx, port: port } } fn send(&self, ops: OpSequence, resp: Sender>) { self.tx.send((ops, resp)).unwrap(); } fn port(&self) -> usize { self.port as usize } } impl Drop for Handle { fn drop(&mut self) { let (tx, _) = channel(); self.send(OpSequence::new(Shutdown), tx); } } impl OpSequenceResult { pub fn new(rx: Receiver>) -> OpSequenceResult { OpSequenceResult { rx: rx } } pub fn assert(&self) { match self.rx.recv().unwrap() { Ok(_) => {} Err(e) => panic!("http exchange did not proceed as expected: {}", e) } } } fn start_server() -> Handle { let (ops_tx, ops_rx) = channel(); let srv = TcpListener::bind("127.0.0.1:0").unwrap(); let port = srv.local_addr().unwrap().port(); thread::spawn(move || { loop { let (ops, resp_tx): (OpSequence, Sender>) = ops_rx.recv().unwrap(); if ops.is_shutdown() { return; } let mut sock = match srv.accept() { Ok(s) => s.0, Err(e) => { resp_tx.send(Err(format!("server accept err: {}", e))).unwrap(); return; } }; resp_tx.send(ops.apply(&mut sock, port as usize)).unwrap(); } }); Handle::new(ops_tx, port) } deps/curl-0.2.14/test/test.rs0000664000175000017500000000125112520216467012730 0ustar extern crate curl; extern crate env_logger; #[macro_use] extern crate log; macro_rules! server { ($($ops:expr),+) => (server::setup(ops!($($ops),+))); } macro_rules! ops { ($op:expr) => (server::OpSequence::new($op)); ($op:expr, $($res:expr),+) => ( server::OpSequence::concat($op, ops!($($res),+)) ); } macro_rules! send { ($e:expr) => (server::Op::SendBytes($e)); } macro_rules! recv { ($e:expr) => (server::Op::ReceiveBytes($e)); } macro_rules! wait { ($dur:expr) => (server::Op::Wait($dur)); } mod server; mod test_delete; mod test_get; mod test_head; mod test_keep_alive; mod test_patch; mod test_post; mod test_proxy; mod test_put; deps/curl-0.2.14/test/test_proxy.rs0000664000175000017500000000147412520216467014200 0ustar use curl::http; use super::server; #[test] pub fn test_proxy() { ::env_logger::init().unwrap(); let srv = server!( recv!(b"POST http://www.google.com/ HTTP/1.1\r\n\ Host: www.google.com\r\n\ Accept: */*\r\n\ Proxy-Connection: Keep-Alive\r\n\ Content-Type: application/octet-stream\r\n\ Content-Length: 11\r\n\ \r\n\ Foo Bar Baz"), send!(b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ Hello\r\n\r\n")); let res = http::handle() .proxy(server::url("/")) .post("http://www.google.com/", "Foo Bar Baz") .exec().unwrap(); srv.assert(); assert!(res.get_code() == 200); assert!(res.get_body() == "Hello".as_bytes()); } deps/curl-0.2.14/test/test_put.rs0000664000175000017500000000260412520216467013623 0ustar use curl::http; use super::server; #[test] pub fn test_put_binary_with_slice() { let srv = server!( recv!(b"PUT / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\ Content-Type: application/octet-stream\r\n\ Content-Length: 11\r\n\ \r\n\ Foo Bar Baz"), send!(b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ Hello\r\n\r\n") ); let res = http::handle() .put(server::url("/"), "Foo Bar Baz") .exec().unwrap(); srv.assert(); assert!(res.get_code() == 200); assert!(res.get_body() == "Hello".as_bytes()); } #[test] pub fn test_put_binary_with_content_type() { let srv = server!( recv!(b"PUT / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\ Content-Type: application/foobar\r\n\ Content-Length: 11\r\n\ \r\n\ Foo Bar Baz"), send!(b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ Hello\r\n\r\n") ); let res = http::handle() .put(server::url("/"), "Foo Bar Baz") .content_type("application/foobar") .exec().unwrap(); srv.assert(); assert!(res.get_code() == 200); assert!(res.get_body() == "Hello".as_bytes()); } deps/curl-0.2.14/test/test_keep_alive.rs0000664000175000017500000000412512520216467015117 0ustar use curl::http::handle; use super::server; #[test] pub fn test_get_requests() { let srv = server!( recv!(b"GET / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\r\n"), send!(b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ Hello\r\n\r\n"), recv!(b"GET /next HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\r\n"), send!(b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ World\r\n\r\n") ); let mut handle = handle(); let res1 = handle.get(server::url("/")).exec().unwrap(); let res2 = handle.get(server::url("/next")).exec().unwrap(); srv.assert(); assert!(res1.get_code() == 200); assert!(res1.get_body() == "Hello".as_bytes()); assert!(res2.get_code() == 200); assert!(res2.get_body() == "World".as_bytes()); } #[test] pub fn test_post_get_requests() { let srv = server!( recv!(b"POST / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\ Content-Type: application/octet-stream\r\n\ Content-Length: 5\r\n\ \r\n\ Hello"), send!(b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ World\r\n\r\n"), recv!(b"GET /next HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\r\n"), send!(b"HTTP/1.1 200 OK\r\n\ Content-Length: 4\r\n\r\n\ NEXT\r\n\r\n") ); let mut handle = handle().timeout(1000); let res1 = handle.post(server::url("/"), "Hello").exec().unwrap(); let res2 = handle.get(server::url("/next")).exec().unwrap(); srv.assert(); assert!(res1.get_code() == 200); assert!(res1.get_body() == "World".as_bytes(), "actual={}", String::from_utf8_lossy(res1.get_body())); assert!(res2.get_code() == 200); assert!(res2.get_body() == "NEXT".as_bytes(), "actual={}", String::from_utf8_lossy(res2.get_body())); } deps/curl-0.2.14/test/test_delete.rs0000664000175000017500000000242612520216467014257 0ustar use curl::http; use super::server; #[test] pub fn test_delete_with_no_body() { let srv = server!( recv!(b"DELETE / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\ \r\n"), send!(b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ Hello\r\n\r\n") ); let res = http::handle() .delete(server::url("/")) .exec(); srv.assert(); let res = res.unwrap(); assert!(res.get_code() == 200); assert!(res.get_body() == "Hello".as_bytes()); } #[test] pub fn test_delete_binary_with_slice() { let srv = server!( recv!(b"DELETE / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\ Content-Type: application/octet-stream\r\n\ Content-Length: 11\r\n\ \r\n\ Foo Bar Baz"), send!(b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ Hello\r\n\r\n") ); let res = http::handle() .delete(server::url("/")) .body("Foo Bar Baz") .exec(); // .unwrap(); srv.assert(); let res = res.unwrap(); assert!(res.get_code() == 200); assert!(res.get_body() == "Hello".as_bytes()); } deps/curl-0.2.14/test/test_patch.rs0000664000175000017500000000262012520216467014110 0ustar use curl::http; use super::server; #[test] pub fn test_patch_binary_with_slice() { let srv = server!( recv!(b"PATCH / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\ Content-Type: application/octet-stream\r\n\ Content-Length: 11\r\n\ \r\n\ Foo Bar Baz"), send!(b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ Hello\r\n\r\n") ); let res = http::handle() .patch(server::url("/"), "Foo Bar Baz") .exec().unwrap(); srv.assert(); assert!(res.get_code() == 200); assert!(res.get_body() == "Hello".as_bytes()); } #[test] pub fn test_patch_binary_with_content_type() { let srv = server!( recv!(b"PATCH / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\ Content-Type: application/foobar\r\n\ Content-Length: 11\r\n\ \r\n\ Foo Bar Baz"), send!(b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ Hello\r\n\r\n") ); let res = http::handle() .patch(server::url("/"), "Foo Bar Baz") .content_type("application/foobar") .exec().unwrap(); srv.assert(); assert!(res.get_code() == 200); assert!(res.get_body() == "Hello".as_bytes()); } deps/curl-0.2.14/test/test_post.rs0000664000175000017500000000553412520216467014005 0ustar use curl::http; use super::server; #[test] pub fn test_post_binary_with_slice() { let srv = server!( recv!(b"POST / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\ Content-Type: application/octet-stream\r\n\ Content-Length: 11\r\n\ \r\n\ Foo Bar Baz"), send!(b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ Hello\r\n\r\n") ); let res = http::handle() .post(server::url("/"), "Foo Bar Baz") .exec().unwrap(); srv.assert(); assert!(res.get_code() == 200); assert!(res.get_body() == "Hello".as_bytes()); } #[test] pub fn test_post_binary_with_string() { let srv = server!( recv!(b"POST / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\ Content-Type: application/octet-stream\r\n\ Content-Length: 11\r\n\ \r\n\ Foo Bar Baz"), send!(b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ Hello\r\n\r\n") ); let body = "Foo Bar Baz".to_string(); let res = http::handle() .post(server::url("/"), &body) .exec().unwrap(); srv.assert(); assert!(res.get_code() == 200); assert!(res.get_body() == "Hello".as_bytes()); } #[test] pub fn test_post_binary_with_reader() { let srv = server!( recv!(b"POST / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\ Transfer-Encoding: chunked\r\n\ Content-Type: application/octet-stream\r\n\ \r\n\ b\r\n\ Foo Bar Baz"), send!(b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ Hello\r\n\r\n") ); let mut body = "Foo Bar Baz".as_bytes(); let res = http::handle() .post(server::url("/"), &mut body) .exec().unwrap(); srv.assert(); assert!(res.get_code() == 200); assert!(res.get_body() == "Hello".as_bytes()); } #[test] pub fn test_post_binary_with_reader_and_content_length() { let srv = server!( recv!(b"POST / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\ Content-Length: 11\r\n\ Content-Type: application/octet-stream\r\n\ \r\n\ Foo Bar Baz"), send!(b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ Hello\r\n\r\n") ); let mut body = "Foo Bar Baz".as_bytes(); let res = http::handle() .post(server::url("/"), &mut body) .content_length(11) .exec().unwrap(); srv.assert(); assert!(res.get_code() == 200); assert!(res.get_body() == "Hello".as_bytes()); } deps/curl-0.2.14/test/test_get.rs0000664000175000017500000000473012520216467013574 0ustar use curl::http::handle; use super::server; #[test] pub fn test_simple_get() { let srv = server!( recv!( b"GET / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\r\n"), // Send the data send!( b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ Hello\r\n")); // Sends let res = handle() .get(server::url("/")) .exec().unwrap(); srv.assert(); assert!(res.get_code() == 200, "code is {}", res.get_code()); assert!(res.get_body() == "Hello".as_bytes()); assert!(res.get_headers().len() == 1); assert!(res.get_header("content-length") == ["5".to_string()]); } #[test] pub fn test_get_with_custom_headers() { let srv = server!( recv!( b"GET / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\ User-Agent: Zomg Test\r\n\r\n"), send!( b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ Hello\r\n\r\n")); let res = handle() .get(server::url("/")) .header("User-Agent", "Zomg Test") .exec().unwrap(); srv.assert(); assert!(res.get_code() == 200); assert!(res.get_body() == "Hello".as_bytes()); assert!(res.get_headers().len() == 1); assert!(res.get_header("content-length") == ["5".to_string()]); } #[test] pub fn test_get_tracking_progress() { let srv = server!( recv!( b"GET / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\r\n"), send!( b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n\ Hello\r\n")); let mut dl = 0; let mut cnt = 0; let res = handle() .get(server::url("/")) .progress(|_, dlnow, _, _| { cnt = cnt + 1; dl = dlnow }) .exec().unwrap(); srv.assert(); assert!(res.get_code() == 200); assert!(dl == 5); assert!(cnt > 1); } #[test] pub fn follows_redirects() { let srv1 = server!( recv!( b"GET / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\r\n"), send!( b"HTTP/1.1 301 Moved Permanently\r\n\ Location: http://localhost:{PORT}/test\r\n\r\n")); let srv2 = server!( recv!( b"GET /test HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\r\n"), send!( b"HTTP/1.1 200 OK\r\n\r\n\ response!")); let res = handle() .get(server::url("/")) .follow_redirects(true) .exec() .unwrap(); srv1.assert(); srv2.assert(); assert!(res.get_code() == 200); assert_eq!(res.get_body(), b"response!"); } deps/curl-0.2.14/test/test_head.rs0000664000175000017500000000125112520216467013711 0ustar use curl::http::handle; use super::server; #[test] pub fn test_simple_head() { let srv = server!( recv!(b"HEAD / HTTP/1.1\r\n\ Host: localhost:{PORT}\r\n\ Accept: */*\r\n\ \r\n"), // Send the data send!(b"HTTP/1.1 200 OK\r\n\ Content-Length: 5\r\n\r\n") ); let res = handle() .head(server::url("/")) .exec(); srv.assert(); let res = res.unwrap(); assert!(res.get_code() == 200, "code is {}", res.get_code()); assert!(res.get_body() == []); assert!(res.get_headers().len() == 1); assert!(res.get_header("content-length") == ["5".to_string()]); } deps/curl-0.2.14/src/0000755000000000000000000000000012666635520012776 5ustar rootrootdeps/curl-0.2.14/src/lib.rs0000664000175000017500000000057112616764272012343 0ustar extern crate libc; extern crate url; #[macro_use] extern crate log; extern crate curl_sys as curl_ffi; #[cfg(all(unix, not(target_os = "macos")))] extern crate openssl_sys as openssl; pub use ffi::easy::ProgressCb; pub use ffi::err::ErrCode; // Version accessors pub use ffi::version::{ Version, version, version_info, Protocols }; mod ffi; pub mod http; deps/curl-0.2.14/src/http/0000755000000000000000000000000012666635520013755 5ustar rootrootdeps/curl-0.2.14/src/http/header.rs0000664000175000017500000001545712462466570014014 0ustar use std::str; use self::State::{HdrNameStart, HdrName, HdrValStart, HdrNameDiscardWs, HdrVal, HdrValDiscardWs}; enum State { HdrNameStart, HdrName, HdrNameDiscardWs, HdrValStart, HdrVal, HdrValDiscardWs } /** * Simple header parser extracts the header name and value, stripping out * starting and trailing white space. It does not, however, normalize header * value whitespace */ pub fn parse<'a>(buf: &'a [u8]) -> Option<(&'a str, &'a str)> { let mut i = 0; let mut name_begin = 0; let mut name_end = 0; let mut val_begin = 0; let mut val_end = 0; let mut state = HdrNameStart; while i < buf.len() { let c = buf[i]; match state { HdrNameStart => { if is_token(c) { name_begin = i; name_end = i; state = HdrName; } else if c == COLON { name_end = i; state = HdrValStart; } else if is_space(c) { name_end = i; } else { return None; // error } } HdrName => { if c == COLON { name_end = i; state = HdrValStart; } else if is_space(c) { name_end = i; state = HdrNameDiscardWs; } else if !is_token(c) { return None; // error } } HdrNameDiscardWs => { if is_token(c) { state = HdrName; } else if c == COLON { state = HdrValStart; } else if !is_space(c) { return None; // error } } HdrValStart => { if !is_lws(c) { val_begin = i; val_end = i + 1; state = HdrVal; } } HdrVal => { if is_lws(c) { val_end = i; state = HdrValDiscardWs; } else { val_end = i + 1; } } HdrValDiscardWs => { if !is_lws(c) { val_end = i + 1; state = HdrVal; } } } i += 1; } let name = match str::from_utf8(&buf[name_begin..name_end]) { Ok(v) => v, Err(..) => return None }; let val = match str::from_utf8(&buf[val_begin..val_end]) { Ok(v) => v, Err(..) => return None }; Some((name, val)) } static COLON: u8 = 58; static TOKEN: &'static [u8] = &[ /* 0 nul 1 soh 2 stx 3 etx 4 eot 5 enq 6 ack 7 bel */ 0, 0, 0, 0, 0, 0, 0, 0, /* 8 bs 9 ht 10 nl 11 vt 12 np 13 cr 14 so 15 si */ 0, 0, 0, 0, 0, 0, 0, 0, /* 16 dle 17 dc1 18 dc2 19 dc3 20 dc4 21 nak 22 syn 23 etb */ 0, 0, 0, 0, 0, 0, 0, 0, /* 24 can 25 em 26 sub 27 esc 28 fs 29 gs 30 rs 31 us */ 0, 0, 0, 0, 0, 0, 0, 0, /* 32 sp 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' */ 0, 33, 0, 35, 36, 37, 38, 39, /* 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / */ 0, 0, 42, 43, 44, 45, 46, 47, /* 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 */ 48, 49, 50, 51, 52, 53, 54, 55, /* 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? */ 56, 57, 0, 0, 0, 0, 0, 0, /* 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G */ 0, 97, 98, 99, 100, 101, 102, 103, /* 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O */ 104, 105, 106, 107, 108, 109, 110, 111, /* 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W */ 112, 113, 114, 115, 116, 117, 118, 119, /* 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ */ 120, 121, 122, 0, 0, 0, 94, 95, /* 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g */ 96, 97, 98, 99, 100, 101, 102, 103, /* 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o */ 104, 105, 106, 107, 108, 109, 110, 111, /* 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w */ 112, 113, 114, 115, 116, 117, 118, 119, /* 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 del */ 120, 121, 122, 123, 124, 0, 126, 0 ]; #[inline] fn is_token(c: u8) -> bool { c < 128 && TOKEN[c as usize] > 0 } #[inline] fn is_space(c: u8) -> bool { c == (' ' as u8) || c == ('\t' as u8) } #[inline] fn is_lws(c: u8) -> bool { is_space(c) || c == ('\n' as u8) || c == ('\r' as u8) } #[cfg(test)] mod test { use super::parse; fn parse_str<'a>(s: &'a str) -> (&'a str, &'a str) { parse(s.as_bytes()).unwrap() } #[test] pub fn test_basic_header() { let (name, val) = parse_str("foo: bar"); assert!(name == "foo"); assert!(val == "bar"); } #[test] pub fn test_basic_header_with_crlf() { let (name, val) = parse_str("foo: bar\r\n"); assert!(name == "foo"); assert!(val == "bar"); } #[test] pub fn test_header_with_extra_spacing() { let (name, val) = parse_str(" \tfoo :bar \t\r"); assert!(name == "foo"); assert!(val == "bar"); } #[test] pub fn test_header_without_value() { let (name, val) = parse_str("foo:"); assert!(name == "foo"); assert!(val == ""); } #[test] pub fn test_header_value_with_spacing_characters() { let (name, val) = parse_str("foo: blah@example.com\r\n"); assert!(name == "foo"); assert!(val == "blah@example.com"); } #[test] pub fn test_parsing_empty_line() { let res = parse("\r\n\r\n".as_bytes()); assert!(res.is_none()); } #[test] pub fn test_parsing_invalid_bytes() { let res = parse(b"fo\x9co: zomg"); assert!(res.is_none()); } } deps/curl-0.2.14/src/http/body.rs0000664000175000017500000000207212502363576013503 0ustar use std::io::prelude::*; use std::io; use self::Body::{FixedBody, ChunkedBody}; pub enum Body<'a> { FixedBody(&'a [u8], usize), ChunkedBody(&'a mut (Read+'a)) } impl<'a> Body<'a> { pub fn get_size(&self) -> Option { match self { &FixedBody(_, len) => Some(len), _ => None } } pub fn read(&mut self, buf: &mut [u8]) -> io::Result { match self { &mut FixedBody(ref mut r, _) => Read::read(r, buf), &mut ChunkedBody(ref mut r) => r.read(buf) } } } pub trait ToBody<'a> { fn to_body(self) -> Body<'a>; } impl<'a> ToBody<'a> for &'a str { fn to_body(self) -> Body<'a> { self.as_bytes().to_body() } } impl<'a> ToBody<'a> for &'a [u8] { fn to_body(self) -> Body<'a> { FixedBody(self, self.len()) } } impl<'a> ToBody<'a> for &'a String { fn to_body(self) -> Body<'a> { self[..].to_body() } } impl<'a, R: Read + 'a> ToBody<'a> for &'a mut R { fn to_body(self) -> Body<'a> { ChunkedBody(self) } } deps/curl-0.2.14/src/http/response.rs0000664000175000017500000000262512614255154014404 0ustar use std::{fmt,str}; use std::collections::HashMap; pub type Headers = HashMap>; #[derive(Debug)] pub struct Response { code: u32, hdrs: Headers, body: Vec } impl Response { pub fn new(code: u32, hdrs: Headers, body: Vec) -> Response { Response { code: code, hdrs: hdrs, body: body } } pub fn get_code(&self) -> u32 { self.code } pub fn get_headers<'a>(&'a self) -> &'a Headers { &self.hdrs } pub fn get_header<'a>(&'a self, name: &str) -> &'a [String] { self.hdrs .get(name) .map(|v| &v[..]) .unwrap_or(&[]) } pub fn get_body<'a>(&'a self) -> &'a [u8] { &self.body } pub fn move_body(self) -> Vec { self.body } } impl fmt::Display for Response { #[allow(deprecated)] // needed for `connect()`, since Rust 1.1 is supported fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { try!(write!(fmt, "Response {{{}, ", self.code)); for (name, val) in self.hdrs.iter() { try!(write!(fmt, "{}: {}, ", name, val.connect(", "))); } match str::from_utf8(&self.body) { Ok(b) => try!(write!(fmt, "{}", b)), Err(..) => try!(write!(fmt, "bytes[{}]", self.body.len())) } try!(write!(fmt, "]")); Ok(()) } } deps/curl-0.2.14/src/http/handle.rs0000664000175000017500000002776212616764272014022 0ustar use std::collections::hash_map::{HashMap, Entry}; use std::path::Path; use url::Url; use ffi::easy::Easy; use ffi::err; use ffi::opt; use ffi; use http::Response; use http::body::{Body,ToBody}; use {ProgressCb,ErrCode}; use self::Method::{Get, Head, Post, Put, Patch, Delete}; use self::BodyType::{Fixed, Chunked}; const DEFAULT_TIMEOUT_MS: usize = 30_000; pub struct Handle { easy: Easy, } impl Handle { pub fn new() -> Handle { return configure(Handle { easy: Easy::new() } .timeout(DEFAULT_TIMEOUT_MS) .connect_timeout(DEFAULT_TIMEOUT_MS)); #[cfg(all(unix, not(target_os = "macos")))] fn configure(mut handle: Handle) -> Handle { let probe = ::openssl::probe::probe(); if let Some(ref path) = probe.cert_file { set_path(&mut handle, opt::CAINFO, path); } if let Some(ref path) = probe.cert_dir { set_path(&mut handle, opt::CAPATH, path); } return handle; fn set_path(handle: &mut Handle, opt: opt::Opt, path: &Path) { if let Err(e) = handle.easy.setopt(opt, path) { if let err::NOT_BUILT_IN = e.code() { return } panic!("failed to set {:?}: {}", opt, e) } } } #[cfg(any(not(unix), target_os = "macos"))] fn configure(handle: Handle) -> Handle { handle } } pub fn timeout(mut self, ms: usize) -> Handle { self.easy.setopt(opt::TIMEOUT_MS, ms).unwrap(); self } pub fn connect_timeout(mut self, ms: usize) -> Handle { self.easy.setopt(opt::CONNECTTIMEOUT_MS, ms).unwrap(); self } /// Set the time in seconds that the transfer speed should be below /// the `low_speed_limit` rate of bytes per second for the library to /// consider it too slow and abort. /// /// The default for this option is 0 which means that this option is /// disabled. pub fn low_speed_timeout(mut self, seconds: usize) -> Handle { self.easy.setopt(opt::LOW_SPEED_TIME, seconds).unwrap(); self } /// Set the average transfer speed in bytes per second that the /// transfer should be below during `low_speed_timeout` seconds for /// libcurl to consider it to be too slow and abort. /// /// The default for this option is 0 which means that this option is /// disabled. pub fn low_speed_limit(mut self, bytes_per_second: usize) -> Handle { self.easy.setopt(opt::LOW_SPEED_LIMIT, bytes_per_second).unwrap(); self } pub fn ssl_verifypeer(mut self, value: bool) -> Handle { self.easy.setopt(opt::SSL_VERIFYPEER, value).unwrap(); self } pub fn follow_location(mut self, value: isize) -> Handle { self.easy.setopt(opt::FOLLOWLOCATION, value).unwrap(); self } pub fn userpwd(mut self, userpwd: &str) -> Handle { self.easy.setopt(opt::USERPWD, userpwd).unwrap(); self } pub fn verbose(mut self) -> Handle { self.easy.setopt(opt::VERBOSE, 1).unwrap(); self } pub fn proxy(mut self, proxy: U) -> Handle { proxy.with_url_str(|s| { self.easy.setopt(opt::PROXY, s).unwrap(); }); self } pub fn ssl_ca_path(mut self, path: &Path) -> Handle { self.easy.setopt(opt::CAPATH, path).unwrap(); self } pub fn ssl_ca_info(mut self, path: &Path) -> Handle { self.easy.setopt(opt::CAINFO, path).unwrap(); self } pub fn cookie_jar(mut self, path: &Path) -> Handle { self.easy.setopt(opt::COOKIEJAR, path).unwrap(); self } pub fn cookie_file(mut self, path: &Path) -> Handle { self.easy.setopt(opt::COOKIEFILE, path).unwrap(); self } pub fn cookies(self, path: &Path) -> Handle { self.cookie_jar(path).cookie_file(path) } pub fn cookie(mut self, cookie: &str) -> Handle { self.easy.setopt(opt::COOKIELIST, cookie).unwrap(); self } pub fn get<'a, 'b, U: ToUrl>(&'a mut self, uri: U) -> Request<'a, 'b> { Request::new(self, Get).uri(uri) } pub fn head<'a, 'b, U: ToUrl>(&'a mut self, uri: U) -> Request<'a, 'b> { Request::new(self, Head).uri(uri) } pub fn post<'a, 'b, U: ToUrl, B: ToBody<'b>>(&'a mut self, uri: U, body: B) -> Request<'a, 'b> { Request::new(self, Post).uri(uri).body(body) } pub fn put<'a, 'b, U: ToUrl, B: ToBody<'b>>(&'a mut self, uri: U, body: B) -> Request<'a, 'b> { Request::new(self, Put).uri(uri).body(body) } pub fn patch<'a, 'b, U: ToUrl, B: ToBody<'b>>(&'a mut self, uri: U, body: B) -> Request<'a, 'b> { Request::new(self, Patch).uri(uri).body(body) } pub fn delete<'a, 'b, U: ToUrl>(&'a mut self, uri: U) -> Request<'a, 'b> { Request::new(self, Delete).uri(uri) } } #[derive(Copy, Clone)] pub enum Method { Options, Get, Head, Post, Put, Patch, Delete, Trace, Connect } pub struct Request<'a, 'b> { err: Option, handle: &'a mut Handle, method: Method, headers: HashMap>, body: Option>, body_type: Option, content_type: bool, // whether or not the content type was set expect_continue: bool, // whether to expect a 100 continue from the server progress: Option>>, follow: bool, } enum BodyType { Fixed(usize), Chunked, } impl<'a, 'b> Request<'a, 'b> { pub fn new(handle: &'a mut Handle, method: Method) -> Request<'a, 'b> { Request { err: None, handle: handle, method: method, headers: HashMap::new(), body: None, body_type: None, content_type: false, expect_continue: false, progress: None, follow: false, } } pub fn uri(mut self, uri: U) -> Request<'a, 'b> { uri.with_url_str(|s| { match self.handle.easy.setopt(opt::URL, s) { Ok(_) => {} Err(e) => self.err = Some(e) } }); self } pub fn body>(mut self, body: B) -> Request<'a, 'b> { self.body = Some(body.to_body()); self } pub fn content_type(mut self, ty: &str) -> Request<'a, 'b> { if !self.content_type { self.content_type = true; append_header(&mut self.headers, "Content-Type", ty); } self } pub fn content_length(mut self, len: usize) -> Request<'a, 'b> { self.body_type = Some(Fixed(len)); self } pub fn chunked(mut self) -> Request<'a, 'b> { self.body_type = Some(Chunked); self } pub fn expect_continue(mut self) -> Request<'a, 'b> { self.expect_continue = true; self } pub fn header(mut self, name: &str, val: &str) -> Request<'a, 'b> { append_header(&mut self.headers, name, val); self } pub fn get_header(&self, name: &str) -> Option<&[String]> { self.headers.get(name).map(|a| &a[..]) } pub fn headers<'c, 'd, I: Iterator>(mut self, hdrs: I) -> Request<'a, 'b> { for (name, val) in hdrs { append_header(&mut self.headers, name, val); } self } pub fn progress(mut self, cb: F) -> Request<'a, 'b> where F: FnMut(usize, usize, usize, usize) + 'b { self.progress = Some(Box::new(cb) as Box>); self } pub fn follow_redirects(mut self, follow: bool) -> Request<'a, 'b> { self.follow = follow; self } pub fn exec(self) -> Result { // Deconstruct the struct let Request { err, handle, method, mut headers, mut body, body_type, content_type, expect_continue, progress, follow, .. } = self; if follow { try!(handle.easy.setopt(opt::FOLLOWLOCATION, 1)); } match err { Some(e) => return Err(e), None => {} } // Clear custom headers set from the previous request try!(handle.easy.setopt(opt::HTTPHEADER, 0)); match method { Get => try!(handle.easy.setopt(opt::HTTPGET, 1)), Head => try!(handle.easy.setopt(opt::NOBODY, 1)), Post => try!(handle.easy.setopt(opt::POST, 1)), Put => try!(handle.easy.setopt(opt::UPLOAD, 1)), Patch => { try!(handle.easy.setopt(opt::CUSTOMREQUEST, "PATCH")); try!(handle.easy.setopt(opt::UPLOAD, 1)); }, Delete => { if body.is_some() { try!(handle.easy.setopt(opt::UPLOAD, 1)); } try!(handle.easy.setopt(opt::CUSTOMREQUEST, "DELETE")); } _ => unimplemented!() } match body.as_ref() { None => {} Some(body) => { let body_type = body_type.unwrap_or(match body.get_size() { Some(len) => Fixed(len), None => Chunked, }); match body_type { Fixed(len) => { match method { Post => try!(handle.easy.setopt(opt::POSTFIELDSIZE, len)), Put | Patch | Delete => try!(handle.easy.setopt(opt::INFILESIZE, len)), _ => { append_header(&mut headers, "Content-Length", &len.to_string()); } } } Chunked => { append_header(&mut headers, "Transfer-Encoding", "chunked"); } } if !content_type { append_header(&mut headers, "Content-Type", "application/octet-stream"); } if !expect_continue { append_header(&mut headers, "Expect", ""); } } } let mut ffi_headers = ffi::List::new(); if !headers.is_empty() { let mut buf = Vec::new(); for (k, v) in headers.iter() { buf.extend(k.bytes()); buf.extend(": ".bytes()); for v in v.iter() { buf.extend(v.bytes()); buf.push(0); ffi_headers.push_bytes(&buf); buf.truncate(k.len() + 2); } buf.truncate(0); } try!(handle.easy.setopt(opt::HTTPHEADER, &ffi_headers)); } handle.easy.perform(body.as_mut(), progress) } } fn append_header(map: &mut HashMap>, key: &str, val: &str) { match map.entry(key.to_string()) { Entry::Vacant(entry) => { let mut values = Vec::new(); values.push(val.to_string()); entry.insert(values) }, Entry::Occupied(entry) => entry.into_mut() }; } pub trait ToUrl{ fn with_url_str(self, f: F) where F: FnOnce(&str); } impl<'a> ToUrl for &'a str { fn with_url_str(self, f: F) where F: FnOnce(&str) { f(self); } } impl<'a> ToUrl for &'a Url { fn with_url_str(self, f: F) where F: FnOnce(&str) { self.to_string().with_url_str(f); } } impl ToUrl for String { fn with_url_str(self, f: F) where F: FnOnce(&str) { self[..].with_url_str(f); } } #[cfg(test)] mod tests { use super::Handle; #[test] fn get_header() { let mut h = Handle::new(); let r = h.get("/foo").header("foo", "bar"); assert_eq!(r.get_header("foo"), Some(&["bar".to_string()][..])); } } deps/curl-0.2.14/src/http/mod.rs0000664000175000017500000000031412362264515013317 0ustar pub use self::handle::{Handle,Request}; pub use self::response::{Headers,Response}; pub mod body; pub mod handle; pub mod header; mod response; #[inline] pub fn handle() -> Handle { Handle::new() } deps/curl-0.2.14/src/ffi/0000755000000000000000000000000012666635520013542 5ustar rootrootdeps/curl-0.2.14/src/ffi/version.rs0000664000175000017500000001340412473447625014026 0ustar #![allow(non_camel_case_types)] #![allow(dead_code)] use std::marker; use std::ffi::CStr; use std::{fmt, ptr, str}; use libc::{c_char, c_int}; use curl_ffi as ffi; #[allow(missing_copy_implementations)] pub struct Version { inner: *mut ffi::curl_version_info_data } impl Version { pub fn version_str<'a>(&'a self) -> &'a str { as_str(unsafe { (*self.inner).version }).unwrap() } pub fn version_major(&self) -> u32 { (unsafe { (*self.inner).version_num } as u32 & 0xFF0000) >> 16 } pub fn version_minor(&self) -> u32 { (unsafe { (*self.inner).version_num } as u32 & 0xFF00) >> 8 } pub fn version_patch(&self) -> u32 { (unsafe { (*self.inner).version_num } as u32 & 0xFF) } pub fn host<'a>(&'a self) -> &'a str { as_str(unsafe { (*self.inner).host }).unwrap() } fn features(&self) -> c_int { unsafe { (*self.inner).features } } pub fn is_ipv6_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_IPV6) == ffi::CURL_VERSION_IPV6 } pub fn is_kerbos4_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_KERBEROS4) == ffi::CURL_VERSION_KERBEROS4 } pub fn is_ssl_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_SSL) == ffi::CURL_VERSION_SSL } pub fn is_libz_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_LIBZ) == ffi::CURL_VERSION_LIBZ } pub fn is_ntlm_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_NTLM) == ffi::CURL_VERSION_NTLM } pub fn is_gss_negotiate_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_GSSNEGOTIATE) == ffi::CURL_VERSION_GSSNEGOTIATE } pub fn is_debug_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_DEBUG) == ffi::CURL_VERSION_DEBUG } pub fn is_async_dns_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_ASYNCHDNS) == ffi::CURL_VERSION_ASYNCHDNS } pub fn is_spengo_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_SPNEGO) == ffi::CURL_VERSION_SPNEGO } pub fn is_large_file_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_LARGEFILE) == ffi::CURL_VERSION_LARGEFILE } pub fn is_idn_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_IDN) == ffi::CURL_VERSION_IDN } pub fn is_sspi_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_SSPI) == ffi::CURL_VERSION_SSPI } pub fn is_conv_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_CONV) == ffi::CURL_VERSION_CONV } pub fn is_curl_debug_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_CURLDEBUG) == ffi::CURL_VERSION_CURLDEBUG } pub fn is_tls_auth_srp_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_TLSAUTH_SRP) == ffi::CURL_VERSION_TLSAUTH_SRP } pub fn is_ntlm_wb_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_NTLM_WB) == ffi::CURL_VERSION_NTLM_WB } pub fn is_http2_enabled(&self) -> bool { (self.features() & ffi::CURL_VERSION_HTTP2) == ffi::CURL_VERSION_HTTP2 } pub fn ssl_version<'a>(&'a self) -> Option<&'a str> { as_str(unsafe { (*self.inner).ssl_version }) } pub fn libz_version<'a>(&'a self) -> Option<&'a str> { as_str(unsafe { (*self.inner).libz_version }) } pub fn protocols<'a>(&'a self) -> Protocols<'a> { Protocols { curr: unsafe { (*self.inner).protocols }, _marker: marker::PhantomData } } pub fn ares_version<'a>(&'a self) -> Option<&'a str> { as_str(unsafe { (*self.inner).ares }) } pub fn ares_version_num(&self) -> Option { match self.ares_version() { Some(_) => Some(unsafe { (*self.inner).ares_num } as u32), None => None } } pub fn idn_version<'a>(&'a self) -> Option<&'a str> { if self.is_idn_enabled() { as_str(unsafe { (*self.inner).libidn }) } else { None } } pub fn iconv_version(self) -> Option { if self.is_conv_enabled() { Some(unsafe { (*self.inner).iconv_ver_num } as u32) } else { None } } pub fn ssh_version<'a>(&'a self) -> Option<&'a str> { as_str(unsafe { (*self.inner).libssh_version }) } } #[derive(Copy, Clone)] #[allow(raw_pointer_derive)] // TODO: Implement this by hand pub struct Protocols<'a> { curr: *const *const c_char, _marker: marker::PhantomData<&'a str>, } impl<'a> Iterator for Protocols<'a> { type Item = &'a str; fn next(&mut self) -> Option<&'a str> { unsafe { let proto = *self.curr; if proto == ptr::null() { return None; } self.curr = self.curr.offset(1); as_str(proto) } } } impl<'a> fmt::Display for Protocols<'a> { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let mut i = self.clone(); try!(write!(fmt, "[")); match i.next() { Some(proto) => try!(write!(fmt, "{}", proto)), None => return write!(fmt, "]") } for proto in i { try!(write!(fmt, ", {}", proto)); } write!(fmt, "]") } } fn as_str<'a>(p: *const c_char) -> Option<&'a str> { if p == ptr::null() { return None; } unsafe { str::from_utf8(CStr::from_ptr(p).to_bytes()).ok() } } pub fn version_info() -> Version { Version { inner: unsafe { ffi::curl_version_info(ffi::CURL_VERSION_NOW) }, } } pub fn version() -> &'static str { unsafe { str::from_utf8(CStr::from_ptr(ffi::curl_version()).to_bytes()).unwrap() } } deps/curl-0.2.14/src/ffi/easy.rs0000664000175000017500000001462512506030412013263 0ustar #![allow(dead_code)] use std::sync::{Once, ONCE_INIT}; use std::mem; use std::collections::HashMap; use std::slice; use libc::{self, c_int, c_long, c_double, size_t}; use super::{consts, err, info, opt}; use super::err::ErrCode; use http::body::Body; use http::{header, Response}; use curl_ffi as ffi; pub type ProgressCb<'a> = FnMut(usize, usize, usize, usize) + 'a; pub struct Easy { curl: *mut ffi::CURL } impl Easy { pub fn new() -> Easy { // Ensure that curl is globally initialized global_init(); let handle = unsafe { let p = ffi::curl_easy_init(); ffi::curl_easy_setopt(p, opt::NOPROGRESS, 0); p }; Easy { curl: handle } } #[inline] pub fn setopt(&mut self, option: opt::Opt, val: T) -> Result<(), err::ErrCode> { // TODO: Prevent setting callback related options let mut res = err::ErrCode(err::OK); unsafe { val.with_c_repr(|repr| { res = err::ErrCode(ffi::curl_easy_setopt(self.curl, option, repr)); }) } if res.is_success() { Ok(()) } else { Err(res) } } pub fn perform(&mut self, body: Option<&mut Body>, progress: Option>) -> Result { let mut builder = ResponseBuilder::new(); unsafe { let resp_p: usize = mem::transmute(&builder); let body_p: usize = match body { Some(b) => mem::transmute(b), None => 0 }; let progress_p: usize = match progress.as_ref() { Some(cb) => mem::transmute(cb), None => 0 }; // Set callback options ffi::curl_easy_setopt(self.curl, opt::READFUNCTION, curl_read_fn); ffi::curl_easy_setopt(self.curl, opt::READDATA, body_p); ffi::curl_easy_setopt(self.curl, opt::WRITEFUNCTION, curl_write_fn); ffi::curl_easy_setopt(self.curl, opt::WRITEDATA, resp_p); ffi::curl_easy_setopt(self.curl, opt::HEADERFUNCTION, curl_header_fn); ffi::curl_easy_setopt(self.curl, opt::HEADERDATA, resp_p); ffi::curl_easy_setopt(self.curl, opt::PROGRESSFUNCTION, curl_progress_fn); ffi::curl_easy_setopt(self.curl, opt::PROGRESSDATA, progress_p); } let err = err::ErrCode(unsafe { ffi::curl_easy_perform(self.curl) }); // If the request failed, abort here if !err.is_success() { return Err(err); } // Try to get the response code builder.code = try!(self.get_response_code()); Ok(builder.build()) } pub fn get_response_code(&self) -> Result { Ok(try!(self.get_info_long(info::RESPONSE_CODE)) as u32) } pub fn get_total_time(&self) -> Result { Ok(try!(self.get_info_long(info::TOTAL_TIME)) as usize) } fn get_info_long(&self, key: info::Key) -> Result { let v: c_long = 0; let res = err::ErrCode(unsafe { ffi::curl_easy_getinfo(self.curl as *const _, key, &v) }); if !res.is_success() { return Err(res); } Ok(v) } } #[inline] fn global_init() { // Schedule curl to be cleaned up after we're done with this whole process static INIT: Once = ONCE_INIT; INIT.call_once(|| unsafe { assert_eq!(libc::atexit(cleanup), 0); }); extern fn cleanup() { unsafe { ffi::curl_global_cleanup() } } } impl Drop for Easy { fn drop(&mut self) { unsafe { ffi::curl_easy_cleanup(self.curl) } } } /* * * TODO: Move this into handle * */ struct ResponseBuilder { code: u32, hdrs: HashMap>, body: Vec } impl ResponseBuilder { fn new() -> ResponseBuilder { ResponseBuilder { code: 0, hdrs: HashMap::new(), body: Vec::new() } } fn add_header(&mut self, name: &str, val: &str) { // TODO: Reduce allocations use std::ascii::AsciiExt; let name = name.to_ascii_lowercase(); let inserted = match self.hdrs.get_mut(&name) { Some(vals) => { vals.push(val.to_string()); true } None => false }; if !inserted { self.hdrs.insert(name, vec!(val.to_string())); } } fn build(self) -> Response { let ResponseBuilder { code, hdrs, body } = self; Response::new(code, hdrs, body) } } /* * * ===== Callbacks ===== */ extern fn curl_read_fn(p: *mut u8, size: size_t, nmemb: size_t, body: *mut Body) -> size_t { if body.is_null() { return 0; } let dst = unsafe { slice::from_raw_parts_mut(p, (size * nmemb) as usize) }; let body = unsafe { &mut *body }; match body.read(dst) { Ok(len) => len as size_t, Err(_) => consts::CURL_READFUNC_ABORT as size_t, } } extern fn curl_write_fn(p: *mut u8, size: size_t, nmemb: size_t, resp: *mut ResponseBuilder) -> size_t { if !resp.is_null() { let builder: &mut ResponseBuilder = unsafe { mem::transmute(resp) }; let chunk = unsafe { slice::from_raw_parts(p as *const u8, (size * nmemb) as usize) }; builder.body.extend(chunk.iter().map(|x| *x)); } size * nmemb } extern fn curl_header_fn(p: *mut u8, size: size_t, nmemb: size_t, resp: &mut ResponseBuilder) -> size_t { // TODO: Skip the first call (it seems to be the status line) let vec = unsafe { slice::from_raw_parts(p as *const u8, (size * nmemb) as usize) }; match header::parse(&vec) { Some((name, val)) => { resp.add_header(name, val); } None => {} } vec.len() as size_t } pub extern "C" fn curl_progress_fn(cb: *mut Box, dltotal: c_double, dlnow: c_double, ultotal: c_double, ulnow: c_double) -> c_int { #[inline] fn to_usize(v: c_double) -> usize { if v > 0.0 { v as usize } else { 0 } } if !cb.is_null() { let cb: &mut ProgressCb = unsafe { &mut **cb }; (*cb)(to_usize(dltotal), to_usize(dlnow), to_usize(ultotal), to_usize(ulnow)); } 0 } deps/curl-0.2.14/src/ffi/info.rs0000664000175000017500000000036612430707434013265 0ustar #![allow(dead_code)] use curl_ffi as ffi; pub use curl_ffi::CURLINFO_EFFECTIVE_URL as EFFECTIVE_URL; pub use curl_ffi::CURLINFO_RESPONSE_CODE as RESPONSE_CODE; pub use curl_ffi::CURLINFO_TOTAL_TIME as TOTAL_TIME; pub type Key = ffi::CURLINFO; deps/curl-0.2.14/src/ffi/mod.rs0000664000175000017500000000024012430707434013100 0ustar pub use self::list::List; pub use self::version::version; pub mod consts; pub mod easy; pub mod err; pub mod info; pub mod list; pub mod opt; pub mod version; deps/curl-0.2.14/src/ffi/opt.rs0000664000175000017500000003314612506605214013133 0ustar #![allow(dead_code)] use std::ffi::CString; use std::path::Path; use libc::{c_void}; use curl_ffi as ffi; pub use curl_ffi::CURLOPT_FILE as FILE; pub use curl_ffi::CURLOPT_URL as URL; pub use curl_ffi::CURLOPT_PORT as PORT; pub use curl_ffi::CURLOPT_PROXY as PROXY; pub use curl_ffi::CURLOPT_USERPWD as USERPWD; pub use curl_ffi::CURLOPT_PROXYUSERPWD as PROXYUSERPWD; pub use curl_ffi::CURLOPT_RANGE as RANGE; pub use curl_ffi::CURLOPT_INFILE as INFILE; pub use curl_ffi::CURLOPT_ERRORBUFFER as ERRORBUFFER; pub use curl_ffi::CURLOPT_WRITEFUNCTION as WRITEFUNCTION; pub use curl_ffi::CURLOPT_READFUNCTION as READFUNCTION; pub use curl_ffi::CURLOPT_TIMEOUT as TIMEOUT; pub use curl_ffi::CURLOPT_INFILESIZE as INFILESIZE; pub use curl_ffi::CURLOPT_POSTFIELDS as POSTFIELDS; pub use curl_ffi::CURLOPT_REFERER as REFERER; pub use curl_ffi::CURLOPT_FTPPORT as FTPPORT; pub use curl_ffi::CURLOPT_USERAGENT as USERAGENT; pub use curl_ffi::CURLOPT_LOW_SPEED_LIMIT as LOW_SPEED_LIMIT; pub use curl_ffi::CURLOPT_LOW_SPEED_TIME as LOW_SPEED_TIME; pub use curl_ffi::CURLOPT_RESUME_FROM as RESUME_FROM; pub use curl_ffi::CURLOPT_COOKIE as COOKIE; pub use curl_ffi::CURLOPT_HTTPHEADER as HTTPHEADER; pub use curl_ffi::CURLOPT_HTTPPOST as HTTPPOST; pub use curl_ffi::CURLOPT_SSLCERT as SSLCERT; pub use curl_ffi::CURLOPT_KEYPASSWD as KEYPASSWD; pub use curl_ffi::CURLOPT_CRLF as CRLF; pub use curl_ffi::CURLOPT_QUOTE as QUOTE; pub use curl_ffi::CURLOPT_WRITEHEADER as WRITEHEADER; pub use curl_ffi::CURLOPT_COOKIEFILE as COOKIEFILE; pub use curl_ffi::CURLOPT_SSLVERSION as SSLVERSION; pub use curl_ffi::CURLOPT_TIMECONDITION as TIMECONDITION; pub use curl_ffi::CURLOPT_TIMEVALUE as TIMEVALUE; pub use curl_ffi::CURLOPT_CUSTOMREQUEST as CUSTOMREQUEST; pub use curl_ffi::CURLOPT_STDERR as STDERR; pub use curl_ffi::CURLOPT_POSTQUOTE as POSTQUOTE; pub use curl_ffi::CURLOPT_WRITEINFO as WRITEINFO; pub use curl_ffi::CURLOPT_VERBOSE as VERBOSE; pub use curl_ffi::CURLOPT_HEADER as HEADER; pub use curl_ffi::CURLOPT_NOPROGRESS as NOPROGRESS; pub use curl_ffi::CURLOPT_NOBODY as NOBODY; pub use curl_ffi::CURLOPT_FAILONERROR as FAILONERROR; pub use curl_ffi::CURLOPT_UPLOAD as UPLOAD; pub use curl_ffi::CURLOPT_POST as POST; pub use curl_ffi::CURLOPT_DIRLISTONLY as DIRLISTONLY; pub use curl_ffi::CURLOPT_APPEND as APPEND; pub use curl_ffi::CURLOPT_NETRC as NETRC; pub use curl_ffi::CURLOPT_FOLLOWLOCATION as FOLLOWLOCATION; pub use curl_ffi::CURLOPT_TRANSFERTEXT as TRANSFERTEXT; pub use curl_ffi::CURLOPT_PUT as PUT; pub use curl_ffi::CURLOPT_PROGRESSFUNCTION as PROGRESSFUNCTION; pub use curl_ffi::CURLOPT_PROGRESSDATA as PROGRESSDATA; pub use curl_ffi::CURLOPT_AUTOREFERER as AUTOREFERER; pub use curl_ffi::CURLOPT_PROXYPORT as PROXYPORT; pub use curl_ffi::CURLOPT_POSTFIELDSIZE as POSTFIELDSIZE; pub use curl_ffi::CURLOPT_HTTPPROXYTUNNEL as HTTPPROXYTUNNEL; pub use curl_ffi::CURLOPT_INTERFACE as INTERFACE; pub use curl_ffi::CURLOPT_KRBLEVEL as KRBLEVEL; pub use curl_ffi::CURLOPT_SSL_VERIFYPEER as SSL_VERIFYPEER; pub use curl_ffi::CURLOPT_CAINFO as CAINFO; pub use curl_ffi::CURLOPT_MAXREDIRS as MAXREDIRS; pub use curl_ffi::CURLOPT_FILETIME as FILETIME; pub use curl_ffi::CURLOPT_TELNETOPTIONS as TELNETOPTIONS; pub use curl_ffi::CURLOPT_MAXCONNECTS as MAXCONNECTS; pub use curl_ffi::CURLOPT_CLOSEPOLICY as CLOSEPOLICY; pub use curl_ffi::CURLOPT_FRESH_CONNECT as FRESH_CONNECT; pub use curl_ffi::CURLOPT_FORBID_REUSE as FORBID_REUSE; pub use curl_ffi::CURLOPT_RANDOM_FILE as RANDOM_FILE; pub use curl_ffi::CURLOPT_EGDSOCKET as EGDSOCKET; pub use curl_ffi::CURLOPT_CONNECTTIMEOUT as CONNECTTIMEOUT; pub use curl_ffi::CURLOPT_HEADERFUNCTION as HEADERFUNCTION; pub use curl_ffi::CURLOPT_HTTPGET as HTTPGET; pub use curl_ffi::CURLOPT_SSL_VERIFYHOST as SSL_VERIFYHOST; pub use curl_ffi::CURLOPT_COOKIEJAR as COOKIEJAR; pub use curl_ffi::CURLOPT_SSL_CIPHER_LIST as SSL_CIPHER_LIST; pub use curl_ffi::CURLOPT_HTTP_VERSION as HTTP_VERSION; pub use curl_ffi::CURLOPT_FTP_USE_EPSV as FTP_USE_EPSV; pub use curl_ffi::CURLOPT_SSLCERTTYPE as SSLCERTTYPE; pub use curl_ffi::CURLOPT_SSLKEY as SSLKEY; pub use curl_ffi::CURLOPT_SSLKEYTYPE as SSLKEYTYPE; pub use curl_ffi::CURLOPT_SSLENGINE as SSLENGINE; pub use curl_ffi::CURLOPT_SSLENGINE_DEFAULT as SSLENGINE_DEFAULT; pub use curl_ffi::CURLOPT_DNS_USE_GLOBAL_CACHE as DNS_USE_GLOBAL_CACHE; pub use curl_ffi::CURLOPT_DNS_CACHE_TIMEOUT as DNS_CACHE_TIMEOUT; pub use curl_ffi::CURLOPT_PREQUOTE as PREQUOTE; pub use curl_ffi::CURLOPT_DEBUGFUNCTION as DEBUGFUNCTION; pub use curl_ffi::CURLOPT_DEBUGDATA as DEBUGDATA; pub use curl_ffi::CURLOPT_COOKIESESSION as COOKIESESSION; pub use curl_ffi::CURLOPT_CAPATH as CAPATH; pub use curl_ffi::CURLOPT_BUFFERSIZE as BUFFERSIZE; pub use curl_ffi::CURLOPT_NOSIGNAL as NOSIGNAL; pub use curl_ffi::CURLOPT_SHARE as SHARE; pub use curl_ffi::CURLOPT_PROXYTYPE as PROXYTYPE; pub use curl_ffi::CURLOPT_ACCEPT_ENCODING as ACCEPT_ENCODING; pub use curl_ffi::CURLOPT_PRIVATE as PRIVATE; pub use curl_ffi::CURLOPT_HTTP200ALIASES as HTTP200ALIASES; pub use curl_ffi::CURLOPT_UNRESTRICTED_AUTH as UNRESTRICTED_AUTH; pub use curl_ffi::CURLOPT_FTP_USE_EPRT as FTP_USE_EPRT; pub use curl_ffi::CURLOPT_HTTPAUTH as HTTPAUTH; pub use curl_ffi::CURLOPT_SSL_CTX_FUNCTION as SSL_CTX_FUNCTION; pub use curl_ffi::CURLOPT_SSL_CTX_DATA as SSL_CTX_DATA; pub use curl_ffi::CURLOPT_FTP_CREATE_MISSING_DIRS as FTP_CREATE_MISSING_DIRS; pub use curl_ffi::CURLOPT_PROXYAUTH as PROXYAUTH; pub use curl_ffi::CURLOPT_FTP_RESPONSE_TIMEOUT as FTP_RESPONSE_TIMEOUT; pub use curl_ffi::CURLOPT_IPRESOLVE as IPRESOLVE; pub use curl_ffi::CURLOPT_MAXFILESIZE as MAXFILESIZE; pub use curl_ffi::CURLOPT_INFILESIZE_LARGE as INFILESIZE_LARGE; pub use curl_ffi::CURLOPT_RESUME_FROM_LARGE as RESUME_FROM_LARGE; pub use curl_ffi::CURLOPT_MAXFILESIZE_LARGE as MAXFILESIZE_LARGE; pub use curl_ffi::CURLOPT_NETRC_FILE as NETRC_FILE; pub use curl_ffi::CURLOPT_USE_SSL as USE_SSL; pub use curl_ffi::CURLOPT_POSTFIELDSIZE_LARGE as POSTFIELDSIZE_LARGE; pub use curl_ffi::CURLOPT_TCP_NODELAY as TCP_NODELAY; pub use curl_ffi::CURLOPT_FTPSSLAUTH as FTPSSLAUTH; pub use curl_ffi::CURLOPT_IOCTLFUNCTION as IOCTLFUNCTION; pub use curl_ffi::CURLOPT_IOCTLDATA as IOCTLDATA; pub use curl_ffi::CURLOPT_FTP_ACCOUNT as FTP_ACCOUNT; pub use curl_ffi::CURLOPT_COOKIELIST as COOKIELIST; pub use curl_ffi::CURLOPT_IGNORE_CONTENT_LENGTH as IGNORE_CONTENT_LENGTH; pub use curl_ffi::CURLOPT_FTP_SKIP_PASV_IP as FTP_SKIP_PASV_IP; pub use curl_ffi::CURLOPT_FTP_FILEMETHOD as FTP_FILEMETHOD; pub use curl_ffi::CURLOPT_LOCALPORT as LOCALPORT; pub use curl_ffi::CURLOPT_LOCALPORTRANGE as LOCALPORTRANGE; pub use curl_ffi::CURLOPT_CONNECT_ONLY as CONNECT_ONLY; pub use curl_ffi::CURLOPT_CONV_FROM_NETWORK_FUNCTION as CONV_FROM_NETWORK_FUNCTION; pub use curl_ffi::CURLOPT_CONV_TO_NETWORK_FUNCTION as CONV_TO_NETWORK_FUNCTION; pub use curl_ffi::CURLOPT_CONV_FROM_UTF8_FUNCTION as CONV_FROM_UTF8_FUNCTION; pub use curl_ffi::CURLOPT_MAX_SEND_SPEED_LARGE as MAX_SEND_SPEED_LARGE; pub use curl_ffi::CURLOPT_MAX_RECV_SPEED_LARGE as MAX_RECV_SPEED_LARGE; pub use curl_ffi::CURLOPT_FTP_ALTERNATIVE_TO_USER as FTP_ALTERNATIVE_TO_USER; pub use curl_ffi::CURLOPT_SOCKOPTFUNCTION as SOCKOPTFUNCTION; pub use curl_ffi::CURLOPT_SOCKOPTDATA as SOCKOPTDATA; pub use curl_ffi::CURLOPT_SSL_SESSIONID_CACHE as SSL_SESSIONID_CACHE; pub use curl_ffi::CURLOPT_SSH_AUTH_TYPES as SSH_AUTH_TYPES; pub use curl_ffi::CURLOPT_SSH_PUBLIC_KEYFILE as SSH_PUBLIC_KEYFILE; pub use curl_ffi::CURLOPT_SSH_PRIVATE_KEYFILE as SSH_PRIVATE_KEYFILE; pub use curl_ffi::CURLOPT_FTP_SSL_CCC as FTP_SSL_CCC; pub use curl_ffi::CURLOPT_TIMEOUT_MS as TIMEOUT_MS; pub use curl_ffi::CURLOPT_CONNECTTIMEOUT_MS as CONNECTTIMEOUT_MS; pub use curl_ffi::CURLOPT_HTTP_TRANSFER_DECODING as HTTP_TRANSFER_DECODING; pub use curl_ffi::CURLOPT_HTTP_CONTENT_DECODING as HTTP_CONTENT_DECODING; pub use curl_ffi::CURLOPT_NEW_FILE_PERMS as NEW_FILE_PERMS; pub use curl_ffi::CURLOPT_NEW_DIRECTORY_PERMS as NEW_DIRECTORY_PERMS; pub use curl_ffi::CURLOPT_POSTREDIR as POSTREDIR; pub use curl_ffi::CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 as SSH_HOST_PUBLIC_KEY_MD5; pub use curl_ffi::CURLOPT_OPENSOCKETFUNCTION as OPENSOCKETFUNCTION; pub use curl_ffi::CURLOPT_OPENSOCKETDATA as OPENSOCKETDATA; pub use curl_ffi::CURLOPT_COPYPOSTFIELDS as COPYPOSTFIELDS; pub use curl_ffi::CURLOPT_PROXY_TRANSFER_MODE as PROXY_TRANSFER_MODE; pub use curl_ffi::CURLOPT_SEEKFUNCTION as SEEKFUNCTION; pub use curl_ffi::CURLOPT_SEEKDATA as SEEKDATA; pub use curl_ffi::CURLOPT_CRLFILE as CRLFILE; pub use curl_ffi::CURLOPT_ISSUERCERT as ISSUERCERT; pub use curl_ffi::CURLOPT_ADDRESS_SCOPE as ADDRESS_SCOPE; pub use curl_ffi::CURLOPT_CERTINFO as CERTINFO; pub use curl_ffi::CURLOPT_USERNAME as USERNAME; pub use curl_ffi::CURLOPT_PASSWORD as PASSWORD; pub use curl_ffi::CURLOPT_PROXYUSERNAME as PROXYUSERNAME; pub use curl_ffi::CURLOPT_PROXYPASSWORD as PROXYPASSWORD; pub use curl_ffi::CURLOPT_NOPROXY as NOPROXY; pub use curl_ffi::CURLOPT_TFTP_BLKSIZE as TFTP_BLKSIZE; pub use curl_ffi::CURLOPT_SOCKS5_GSSAPI_SERVICE as SOCKS5_GSSAPI_SERVICE; pub use curl_ffi::CURLOPT_SOCKS5_GSSAPI_NEC as SOCKS5_GSSAPI_NEC; pub use curl_ffi::CURLOPT_PROTOCOLS as PROTOCOLS; pub use curl_ffi::CURLOPT_REDIR_PROTOCOLS as REDIR_PROTOCOLS; pub use curl_ffi::CURLOPT_SSH_KNOWNHOSTS as SSH_KNOWNHOSTS; pub use curl_ffi::CURLOPT_SSH_KEYFUNCTION as SSH_KEYFUNCTION; pub use curl_ffi::CURLOPT_SSH_KEYDATA as SSH_KEYDATA; pub use curl_ffi::CURLOPT_MAIL_FROM as MAIL_FROM; pub use curl_ffi::CURLOPT_MAIL_RCPT as MAIL_RCPT; pub use curl_ffi::CURLOPT_FTP_USE_PRET as FTP_USE_PRET; pub use curl_ffi::CURLOPT_RTSP_REQUEST as RTSP_REQUEST; pub use curl_ffi::CURLOPT_RTSP_SESSION_ID as RTSP_SESSION_ID; pub use curl_ffi::CURLOPT_RTSP_STREAM_URI as RTSP_STREAM_URI; pub use curl_ffi::CURLOPT_RTSP_TRANSPORT as RTSP_TRANSPORT; pub use curl_ffi::CURLOPT_RTSP_CLIENT_CSEQ as RTSP_CLIENT_CSEQ; pub use curl_ffi::CURLOPT_RTSP_SERVER_CSEQ as RTSP_SERVER_CSEQ; pub use curl_ffi::CURLOPT_INTERLEAVEDATA as INTERLEAVEDATA; pub use curl_ffi::CURLOPT_INTERLEAVEFUNCTION as INTERLEAVEFUNCTION; pub use curl_ffi::CURLOPT_WILDCARDMATCH as WILDCARDMATCH; pub use curl_ffi::CURLOPT_CHUNK_BGN_FUNCTION as CHUNK_BGN_FUNCTION; pub use curl_ffi::CURLOPT_CHUNK_END_FUNCTION as CHUNK_END_FUNCTION; pub use curl_ffi::CURLOPT_FNMATCH_FUNCTION as FNMATCH_FUNCTION; pub use curl_ffi::CURLOPT_CHUNK_DATA as CHUNK_DATA; pub use curl_ffi::CURLOPT_FNMATCH_DATA as FNMATCH_DATA; pub use curl_ffi::CURLOPT_RESOLVE as RESOLVE; pub use curl_ffi::CURLOPT_TLSAUTH_USERNAME as TLSAUTH_USERNAME; pub use curl_ffi::CURLOPT_TLSAUTH_PASSWORD as TLSAUTH_PASSWORD; pub use curl_ffi::CURLOPT_TLSAUTH_TYPE as TLSAUTH_TYPE; pub use curl_ffi::CURLOPT_TRANSFER_ENCODING as TRANSFER_ENCODING; pub use curl_ffi::CURLOPT_CLOSESOCKETFUNCTION as CLOSESOCKETFUNCTION; pub use curl_ffi::CURLOPT_CLOSESOCKETDATA as CLOSESOCKETDATA; pub use curl_ffi::CURLOPT_GSSAPI_DELEGATION as GSSAPI_DELEGATION; pub use curl_ffi::CURLOPT_DNS_SERVERS as DNS_SERVERS; pub use curl_ffi::CURLOPT_ACCEPTTIMEOUT_MS as ACCEPTTIMEOUT_MS; pub use curl_ffi::CURLOPT_TCP_KEEPALIVE as TCP_KEEPALIVE; pub use curl_ffi::CURLOPT_TCP_KEEPIDLE as TCP_KEEPIDLE; pub use curl_ffi::CURLOPT_TCP_KEEPINTVL as TCP_KEEPINTVL; pub use curl_ffi::CURLOPT_SSL_OPTIONS as SSL_OPTIONS; pub use curl_ffi::CURLOPT_MAIL_AUTH as MAIL_AUTH; pub use curl_ffi::CURLOPT_SASL_IR as SASL_IR; pub use curl_ffi::CURLOPT_XFERINFOFUNCTION as XFERINFOFUNCTION; pub use curl_ffi::CURLOPT_XOAUTH2_BEARER as XOAUTH2_BEARER; pub use curl_ffi::CURLOPT_DNS_INTERFACE as DNS_INTERFACE; pub use curl_ffi::CURLOPT_DNS_LOCAL_IP4 as DNS_LOCAL_IP4; pub use curl_ffi::CURLOPT_DNS_LOCAL_IP6 as DNS_LOCAL_IP6; pub use curl_ffi::CURLOPT_LOGIN_OPTIONS as LOGIN_OPTIONS; pub use curl_ffi::CURLOPT_SSL_ENABLE_NPN as SSL_ENABLE_NPN; pub use curl_ffi::CURLOPT_SSL_ENABLE_ALPN as SSL_ENABLE_ALPN; pub use curl_ffi::CURLOPT_EXPECT_100_TIMEOUT_MS as EXPECT_100_TIMEOUT_MS; pub use curl_ffi::CURLOPT_PROXYHEADER as PROXYHEADER; pub use curl_ffi::CURLOPT_HEADEROPT as HEADEROPT; pub use curl_ffi::CURLOPT_POST301 as POST301; pub use curl_ffi::CURLOPT_SSLKEYPASSWD as SSLKEYPASSWD; pub use curl_ffi::CURLOPT_FTPAPPEND as FTPAPPEND; pub use curl_ffi::CURLOPT_FTPLISTONLY as FTPLISTONLY; pub use curl_ffi::CURLOPT_FTP_SSL as FTP_SSL; pub use curl_ffi::CURLOPT_SSLCERTPASSWD as SSLCERTPASSWD; pub use curl_ffi::CURLOPT_KRB4LEVEL as KRB4LEVEL; pub use curl_ffi::CURLOPT_READDATA as READDATA; pub use curl_ffi::CURLOPT_WRITEDATA as WRITEDATA; pub use curl_ffi::CURLOPT_HEADERDATA as HEADERDATA; pub use curl_ffi::CURLOPT_XFERINFODATA as XFERINFODATA; pub type Opt = ffi::CURLoption; pub trait OptVal { fn with_c_repr(self, f: F) where F: FnOnce(*const c_void); } impl OptVal for isize { fn with_c_repr(self, f: F) where F: FnOnce(*const c_void) { f(self as *const c_void) } } impl OptVal for i32 { fn with_c_repr(self, f: F) where F: FnOnce(*const c_void) { (self as isize).with_c_repr(f) } } impl OptVal for usize { fn with_c_repr(self, f: F) where F: FnOnce(*const c_void) { f(self as *const c_void) } } impl OptVal for bool { fn with_c_repr(self, f: F) where F: FnOnce(*const c_void) { f(self as usize as *const c_void) } } impl<'a> OptVal for &'a str { fn with_c_repr(self, f: F) where F: FnOnce(*const c_void) { let s = CString::new(self).unwrap(); f(s.as_ptr() as *const c_void) } } impl<'a> OptVal for &'a Path { #[cfg(unix)] fn with_c_repr(self, f: F) where F: FnOnce(*const c_void) { use std::ffi::OsStr; use std::os::unix::prelude::*; let s: &OsStr = self.as_ref(); let s = CString::new(s.as_bytes()).unwrap(); f(s.as_ptr() as *const c_void) } #[cfg(windows)] fn with_c_repr(self, f: F) where F: FnOnce(*const c_void) { let s = CString::new(self.to_str().unwrap()).unwrap(); f(s.as_ptr() as *const c_void) } } deps/curl-0.2.14/src/ffi/consts.rs0000664000175000017500000000004712610043251013625 0ustar pub use curl_ffi::CURL_READFUNC_ABORT; deps/curl-0.2.14/src/ffi/err.rs0000664000175000017500000001637712603141015013120 0ustar use std::ffi::CStr; use std::error; use std::fmt; use std::str; use curl_ffi as ffi; pub use curl_ffi::CURLcode::CURLE_OK as OK; pub use curl_ffi::CURLcode::CURLE_UNSUPPORTED_PROTOCOL as UNSUPPORTED_PROTOCOL; pub use curl_ffi::CURLcode::CURLE_FAILED_INIT as FAILED_INIT; pub use curl_ffi::CURLcode::CURLE_URL_MALFORMAT as URL_MALFORMAT; pub use curl_ffi::CURLcode::CURLE_NOT_BUILT_IN as NOT_BUILT_IN; pub use curl_ffi::CURLcode::CURLE_COULDNT_RESOLVE_PROXY as COULDNT_RESOLVE_PROXY; pub use curl_ffi::CURLcode::CURLE_COULDNT_RESOLVE_HOST as COULDNT_RESOLVE_HOST; pub use curl_ffi::CURLcode::CURLE_COULDNT_CONNECT as COULDNT_CONNECT; pub use curl_ffi::CURLcode::CURLE_FTP_WEIRD_SERVER_REPLY as FTP_WEIRD_SERVER_REPLY; pub use curl_ffi::CURLcode::CURLE_REMOTE_ACCESS_DENIED as REMOTE_ACCESS_DENIED; pub use curl_ffi::CURLcode::CURLE_FTP_ACCEPT_FAILED as FTP_ACCEPT_FAILED; pub use curl_ffi::CURLcode::CURLE_FTP_WEIRD_PASS_REPLY as FTP_WEIRD_PASS_REPLY; pub use curl_ffi::CURLcode::CURLE_FTP_ACCEPT_TIMEOUT as FTP_ACCEPT_TIMEOUT; pub use curl_ffi::CURLcode::CURLE_FTP_WEIRD_PASV_REPLY as FTP_WEIRD_PASV_REPLY; pub use curl_ffi::CURLcode::CURLE_FTP_WEIRD_227_FORMAT as FTP_WEIRD_227_FORMAT; pub use curl_ffi::CURLcode::CURLE_FTP_CANT_GET_HOST as FTP_CANT_GET_HOST; pub use curl_ffi::CURLcode::CURLE_OBSOLETE16 as OBSOLETE16; pub use curl_ffi::CURLcode::CURLE_FTP_COULDNT_SET_TYPE as FTP_COULDNT_SET_TYPE; pub use curl_ffi::CURLcode::CURLE_PARTIAL_FILE as PARTIAL_FILE; pub use curl_ffi::CURLcode::CURLE_FTP_COULDNT_RETR_FILE as FTP_COULDNT_RETR_FILE; pub use curl_ffi::CURLcode::CURLE_OBSOLETE20 as OBSOLETE20; pub use curl_ffi::CURLcode::CURLE_QUOTE_ERROR as QUOTE_ERROR; pub use curl_ffi::CURLcode::CURLE_HTTP_RETURNED_ERROR as HTTP_RETURNED_ERROR; pub use curl_ffi::CURLcode::CURLE_WRITE_ERROR as WRITE_ERROR; pub use curl_ffi::CURLcode::CURLE_OBSOLETE24 as OBSOLETE24; pub use curl_ffi::CURLcode::CURLE_UPLOAD_FAILED as UPLOAD_FAILED; pub use curl_ffi::CURLcode::CURLE_READ_ERROR as READ_ERROR; pub use curl_ffi::CURLcode::CURLE_OUT_OF_MEMORY as OUT_OF_MEMORY; pub use curl_ffi::CURLcode::CURLE_OPERATION_TIMEDOUT as OPERATION_TIMEDOUT; pub use curl_ffi::CURLcode::CURLE_OBSOLETE29 as OBSOLETE29; pub use curl_ffi::CURLcode::CURLE_FTP_PORT_FAILED as FTP_PORT_FAILED; pub use curl_ffi::CURLcode::CURLE_FTP_COULDNT_USE_REST as FTP_COULDNT_USE_REST; pub use curl_ffi::CURLcode::CURLE_OBSOLETE32 as OBSOLETE32; pub use curl_ffi::CURLcode::CURLE_RANGE_ERROR as RANGE_ERROR; pub use curl_ffi::CURLcode::CURLE_HTTP_POST_ERROR as HTTP_POST_ERROR; pub use curl_ffi::CURLcode::CURLE_SSL_CONNECT_ERROR as SSL_CONNECT_ERROR; pub use curl_ffi::CURLcode::CURLE_BAD_DOWNLOAD_RESUME as BAD_DOWNLOAD_RESUME; pub use curl_ffi::CURLcode::CURLE_FILE_COULDNT_READ_FILE as FILE_COULDNT_READ_FILE; pub use curl_ffi::CURLcode::CURLE_LDAP_CANNOT_BIND as LDAP_CANNOT_BIND; pub use curl_ffi::CURLcode::CURLE_LDAP_SEARCH_FAILED as LDAP_SEARCH_FAILED; pub use curl_ffi::CURLcode::CURLE_OBSOLETE40 as OBSOLETE40; pub use curl_ffi::CURLcode::CURLE_FUNCTION_NOT_FOUND as FUNCTION_NOT_FOUND; pub use curl_ffi::CURLcode::CURLE_ABORTED_BY_CALLBACK as ABORTED_BY_CALLBACK; pub use curl_ffi::CURLcode::CURLE_BAD_FUNCTION_ARGUMENT as BAD_FUNCTION_ARGUMENT; pub use curl_ffi::CURLcode::CURLE_OBSOLETE44 as OBSOLETE44; pub use curl_ffi::CURLcode::CURLE_INTERFACE_FAILED as INTERFACE_FAILED; pub use curl_ffi::CURLcode::CURLE_OBSOLETE46 as OBSOLETE46; pub use curl_ffi::CURLcode::CURLE_TOO_MANY_REDIRECTS as TOO_MANY_REDIRECTS ; pub use curl_ffi::CURLcode::CURLE_UNKNOWN_OPTION as UNKNOWN_OPTION; pub use curl_ffi::CURLcode::CURLE_TELNET_OPTION_SYNTAX as TELNET_OPTION_SYNTAX ; pub use curl_ffi::CURLcode::CURLE_OBSOLETE50 as OBSOLETE50; pub use curl_ffi::CURLcode::CURLE_PEER_FAILED_VERIFICATION as PEER_FAILED_VERIFICATION; pub use curl_ffi::CURLcode::CURLE_GOT_NOTHING as GOT_NOTHING; pub use curl_ffi::CURLcode::CURLE_SSL_ENGINE_NOTFOUND as SSL_ENGINE_NOTFOUND; pub use curl_ffi::CURLcode::CURLE_SSL_ENGINE_SETFAILED as SSL_ENGINE_SETFAILED; pub use curl_ffi::CURLcode::CURLE_SEND_ERROR as SEND_ERROR; pub use curl_ffi::CURLcode::CURLE_RECV_ERROR as RECV_ERROR; pub use curl_ffi::CURLcode::CURLE_OBSOLETE57 as OBSOLETE57; pub use curl_ffi::CURLcode::CURLE_SSL_CERTPROBLEM as SSL_CERTPROBLEM; pub use curl_ffi::CURLcode::CURLE_SSL_CIPHER as SSL_CIPHER; pub use curl_ffi::CURLcode::CURLE_SSL_CACERT as SSL_CACERT; pub use curl_ffi::CURLcode::CURLE_BAD_CONTENT_ENCODING as BAD_CONTENT_ENCODING; pub use curl_ffi::CURLcode::CURLE_LDAP_INVALID_URL as LDAP_INVALID_URL; pub use curl_ffi::CURLcode::CURLE_FILESIZE_EXCEEDED as FILESIZE_EXCEEDED; pub use curl_ffi::CURLcode::CURLE_USE_SSL_FAILED as USE_SSL_FAILED; pub use curl_ffi::CURLcode::CURLE_SEND_FAIL_REWIND as SEND_FAIL_REWIND; pub use curl_ffi::CURLcode::CURLE_SSL_ENGINE_INITFAILED as SSL_ENGINE_INITFAILED; pub use curl_ffi::CURLcode::CURLE_LOGIN_DENIED as LOGIN_DENIED; pub use curl_ffi::CURLcode::CURLE_TFTP_NOTFOUND as TFTP_NOTFOUND; pub use curl_ffi::CURLcode::CURLE_TFTP_PERM as TFTP_PERM; pub use curl_ffi::CURLcode::CURLE_REMOTE_DISK_FULL as REMOTE_DISK_FULL; pub use curl_ffi::CURLcode::CURLE_TFTP_ILLEGAL as TFTP_ILLEGAL; pub use curl_ffi::CURLcode::CURLE_TFTP_UNKNOWNID as TFTP_UNKNOWNID; pub use curl_ffi::CURLcode::CURLE_REMOTE_FILE_EXISTS as REMOTE_FILE_EXISTS; pub use curl_ffi::CURLcode::CURLE_TFTP_NOSUCHUSER as TFTP_NOSUCHUSER; pub use curl_ffi::CURLcode::CURLE_CONV_FAILED as CONV_FAILED; pub use curl_ffi::CURLcode::CURLE_CONV_REQD as CONV_REQD; pub use curl_ffi::CURLcode::CURLE_SSL_CACERT_BADFILE as SSL_CACERT_BADFILE; pub use curl_ffi::CURLcode::CURLE_REMOTE_FILE_NOT_FOUND as REMOTE_FILE_NOT_FOUND; pub use curl_ffi::CURLcode::CURLE_SSH as SSH; pub use curl_ffi::CURLcode::CURLE_SSL_SHUTDOWN_FAILED as SSL_SHUTDOWN_FAILED; pub use curl_ffi::CURLcode::CURLE_AGAIN as AGAIN; pub use curl_ffi::CURLcode::CURLE_SSL_CRL_BADFILE as SSL_CRL_BADFILE; pub use curl_ffi::CURLcode::CURLE_SSL_ISSUER_ERROR as SSL_ISSUER_ERROR; pub use curl_ffi::CURLcode::CURLE_FTP_PRET_FAILED as FTP_PRET_FAILED; pub use curl_ffi::CURLcode::CURLE_RTSP_CSEQ_ERROR as RTSP_CSEQ_ERROR; pub use curl_ffi::CURLcode::CURLE_RTSP_SESSION_ERROR as RTSP_SESSION_ERROR; pub use curl_ffi::CURLcode::CURLE_FTP_BAD_FILE_LIST as FTP_BAD_FILE_LIST; pub use curl_ffi::CURLcode::CURLE_CHUNK_FAILED as CHUNK_FAILED; pub use curl_ffi::CURLcode::CURLE_NO_CONNECTION_AVAILABLE as NO_CONNECTION_AVAILABLE; pub use curl_ffi::CURLcode::CURLE_LAST as LAST; #[derive(Copy, Clone)] pub struct ErrCode(pub ffi::CURLcode); impl ErrCode { pub fn is_success(self) -> bool { self.code() as i32 == OK as i32 } pub fn code(self) -> ffi::CURLcode { let ErrCode(c) = self; c } } impl fmt::Debug for ErrCode { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(self, f) } } impl fmt::Display for ErrCode { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let s = unsafe { CStr::from_ptr(ffi::curl_easy_strerror(self.code())).to_bytes() }; match str::from_utf8(s) { Ok(s) => write!(fmt, "{}", s), Err(err) => write!(fmt, "{}", err) } } } impl error::Error for ErrCode { fn description(&self) -> &str { let code = self.code(); let s = unsafe { CStr::from_ptr(ffi::curl_easy_strerror(code) as *const _).to_bytes() }; str::from_utf8(s).unwrap() } } deps/curl-0.2.14/src/ffi/list.rs0000664000175000017500000000162712454774465013324 0ustar #![allow(dead_code)] use std::ptr; use libc::c_void; use super::opt::OptVal; use curl_ffi as ffi; pub struct List { len: usize, head: *mut ffi::curl_slist, } impl List { pub fn new() -> List { List { len: 0, head: ptr::null_mut() } } pub fn push_bytes(&mut self, val: &[u8]) { assert!(val[val.len() - 1] == 0); self.len += 1; self.head = unsafe { ffi::curl_slist_append(self.head, val.as_ptr()) }; } pub fn len(&self) -> usize { self.len } pub fn is_empty(&self) -> bool { self.len() == 0 } } impl Drop for List { fn drop(&mut self) { if !self.is_empty() { unsafe { ffi::curl_slist_free_all(self.head) } } } } impl<'a> OptVal for &'a List { fn with_c_repr(self, f: F) where F: FnOnce(*const c_void) { f(self.head as *const c_void) } } deps/curl-0.2.14/Cargo.toml0000664000175000017500000000242612623177633012366 0ustar [package] name = "curl" version = "0.2.14" authors = ["Carl Lerche "] license = "MIT" repository = "https://github.com/carllerche/curl-rust" description = "Rust bindings to libcurl for making HTTP requests" [dependencies] url = "0.2.0" log = "0.3.0" libc = "0.2" curl-sys = { path = "curl-sys", version = "0.1.0" } [dev-dependencies] env_logger = "0.3.0" # Unix platforms use OpenSSL for now to provide SSL functionality [target.i686-unknown-linux-gnu.dependencies] openssl-sys = "0.7.0" [target.i686-linux-android.dependencies] openssl-sys = "0.7.0" [target.x86_64-unknown-linux-gnu.dependencies] openssl-sys = "0.7.0" [target.x86_64-unknown-linux-musl.dependencies] openssl-sys = "0.7.0" [target.arm-unknown-linux-gnueabihf.dependencies] openssl-sys = "0.7.0" [target.arm-linux-androideabi.dependencies] openssl-sys = "0.7.0" [target.aarch64-unknown-linux-gnu.dependencies] openssl-sys = "0.7.0" [target.i686-unknown-freebsd.dependencies] openssl-sys = "0.7.0" [target.x86_64-unknown-freebsd.dependencies] openssl-sys = "0.7.0" [target.x86_64-unknown-bitrig.dependencies] openssl-sys = "0.7.0" [target.x86_64-unknown-openbsd.dependencies] openssl-sys = "0.7.0" [target.x86_64-unknown-dragonfly.dependencies] openssl-sys = "0.7.0" [[test]] name = "test" path = "test/test.rs" deps/curl-0.2.14/.gitmodules0000664000175000017500000000013612431457357012610 0ustar [submodule "curl-sys/curl"] path = curl-sys/curl url = https://github.com/alexcrichton/curl deps/crates-io-0.1.0/0000755000000000000000000000000012666635520013042 5ustar rootrootdeps/crates-io-0.1.0/lib.rs0000664000175000017500000002104112552264414012372 0ustar extern crate curl; extern crate rustc_serialize; use std::collections::HashMap; use std::fmt; use std::fs::{self, File}; use std::io::prelude::*; use std::io::{self, Cursor}; use std::path::Path; use std::result; use curl::http; use curl::http::handle::Method::{Put, Get, Delete}; use curl::http::handle::{Method, Request}; use rustc_serialize::json; pub struct Registry { host: String, token: Option, handle: http::Handle, } pub type Result = result::Result; #[derive(PartialEq, Clone, Copy)] pub enum Auth { Authorized, Unauthorized } pub enum Error { Curl(curl::ErrCode), NotOkResponse(http::Response), NonUtf8Body, Api(Vec), Unauthorized, TokenMissing, Io(io::Error), } #[derive(RustcDecodable)] pub struct Crate { pub name: String, pub description: Option, pub max_version: String } #[derive(RustcEncodable)] pub struct NewCrate { pub name: String, pub vers: String, pub deps: Vec, pub features: HashMap>, pub authors: Vec, pub description: Option, pub documentation: Option, pub homepage: Option, pub readme: Option, pub keywords: Vec, pub license: Option, pub license_file: Option, pub repository: Option, } #[derive(RustcEncodable)] pub struct NewCrateDependency { pub optional: bool, pub default_features: bool, pub name: String, pub features: Vec, pub version_req: String, pub target: Option, pub kind: String, } #[derive(RustcDecodable)] pub struct User { pub id: u32, pub login: String, pub avatar: String, pub email: Option, pub name: Option, } #[derive(RustcDecodable)] struct R { ok: bool } #[derive(RustcDecodable)] struct ApiErrorList { errors: Vec } #[derive(RustcDecodable)] struct ApiError { detail: String } #[derive(RustcEncodable)] struct OwnersReq<'a> { users: &'a [&'a str] } #[derive(RustcDecodable)] struct Users { users: Vec } #[derive(RustcDecodable)] struct Crates { crates: Vec } impl Registry { pub fn new(host: String, token: Option) -> Registry { Registry::new_handle(host, token, http::Handle::new()) } pub fn new_handle(host: String, token: Option, handle: http::Handle) -> Registry { Registry { host: host, token: token, handle: handle, } } pub fn add_owners(&mut self, krate: &str, owners: &[&str]) -> Result<()> { let body = json::encode(&OwnersReq { users: owners }).unwrap(); let body = try!(self.put(format!("/crates/{}/owners", krate), body.as_bytes())); assert!(json::decode::(&body).unwrap().ok); Ok(()) } pub fn remove_owners(&mut self, krate: &str, owners: &[&str]) -> Result<()> { let body = json::encode(&OwnersReq { users: owners }).unwrap(); let body = try!(self.delete(format!("/crates/{}/owners", krate), Some(body.as_bytes()))); assert!(json::decode::(&body).unwrap().ok); Ok(()) } pub fn list_owners(&mut self, krate: &str) -> Result> { let body = try!(self.get(format!("/crates/{}/owners", krate))); Ok(json::decode::(&body).unwrap().users) } pub fn publish(&mut self, krate: &NewCrate, tarball: &Path) -> Result<()> { let json = json::encode(krate).unwrap(); // Prepare the body. The format of the upload request is: // // // (metadata for the package) // // let stat = try!(fs::metadata(tarball).map_err(Error::Io)); let header = { let mut w = Vec::new(); w.extend([ (json.len() >> 0) as u8, (json.len() >> 8) as u8, (json.len() >> 16) as u8, (json.len() >> 24) as u8, ].iter().map(|x| *x)); w.extend(json.as_bytes().iter().map(|x| *x)); w.extend([ (stat.len() >> 0) as u8, (stat.len() >> 8) as u8, (stat.len() >> 16) as u8, (stat.len() >> 24) as u8, ].iter().map(|x| *x)); w }; let tarball = try!(File::open(tarball).map_err(Error::Io)); let size = stat.len() as usize + header.len(); let mut body = Cursor::new(header).chain(tarball); let url = format!("{}/api/v1/crates/new", self.host); let token = match self.token.as_ref() { Some(s) => s, None => return Err(Error::TokenMissing), }; let request = self.handle.put(url, &mut body) .content_length(size) .header("Accept", "application/json") .header("Authorization", &token); let response = handle(request.exec()); let _body = try!(response); Ok(()) } pub fn search(&mut self, query: &str) -> Result> { let body = try!(self.req(format!("/crates?q={}", query), None, Get, Auth::Unauthorized)); Ok(json::decode::(&body).unwrap().crates) } pub fn yank(&mut self, krate: &str, version: &str) -> Result<()> { let body = try!(self.delete(format!("/crates/{}/{}/yank", krate, version), None)); assert!(json::decode::(&body).unwrap().ok); Ok(()) } pub fn unyank(&mut self, krate: &str, version: &str) -> Result<()> { let body = try!(self.put(format!("/crates/{}/{}/unyank", krate, version), &[])); assert!(json::decode::(&body).unwrap().ok); Ok(()) } fn put(&mut self, path: String, b: &[u8]) -> Result { self.req(path, Some(b), Put, Auth::Authorized) } fn get(&mut self, path: String) -> Result { self.req(path, None, Get, Auth::Authorized) } fn delete(&mut self, path: String, b: Option<&[u8]>) -> Result { self.req(path, b, Delete, Auth::Authorized) } fn req(&mut self, path: String, body: Option<&[u8]>, method: Method, authorized: Auth) -> Result { let mut req = Request::new(&mut self.handle, method) .uri(format!("{}/api/v1{}", self.host, path)) .header("Accept", "application/json") .content_type("application/json"); if authorized == Auth::Authorized { let token = match self.token.as_ref() { Some(s) => s, None => return Err(Error::TokenMissing), }; req = req.header("Authorization", &token); } match body { Some(b) => req = req.body(b), None => {} } handle(req.exec()) } } fn handle(response: result::Result) -> Result { let response = try!(response.map_err(Error::Curl)); match response.get_code() { 0 => {} // file upload url sometimes 200 => {} 403 => return Err(Error::Unauthorized), _ => return Err(Error::NotOkResponse(response)) } let body = match String::from_utf8(response.move_body()) { Ok(body) => body, Err(..) => return Err(Error::NonUtf8Body), }; match json::decode::(&body) { Ok(errors) => { return Err(Error::Api(errors.errors.into_iter().map(|s| s.detail) .collect())) } Err(..) => {} } Ok(body) } impl fmt::Display for Error { #[allow(deprecated)] // connect => join in 1.3 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Error::NonUtf8Body => write!(f, "response body was not utf-8"), Error::Curl(ref err) => write!(f, "http error: {}", err), Error::NotOkResponse(ref resp) => { write!(f, "failed to get a 200 OK response: {}", resp) } Error::Api(ref errs) => { write!(f, "api errors: {}", errs.connect(", ")) } Error::Unauthorized => write!(f, "unauthorized API access"), Error::TokenMissing => write!(f, "no upload token found, please run `cargo login`"), Error::Io(ref e) => write!(f, "io error: {}", e), } } } deps/crates-io-0.1.0/Cargo.toml0000664000175000017500000000051412554530132013203 0ustar [package] name = "crates-io" version = "0.1.0" authors = ["Alex Crichton "] license = "MIT/Apache-2.0" repository = "https://github.com/rust-lang/cargo" description = """ Helpers for interacting with crates.io """ [lib] name = "crates_io" path = "lib.rs" [dependencies] curl = "0.2" rustc-serialize = "0.3" deps/miniz-sys-0.1.7/0000755000000000000000000000000012666635520013125 5ustar rootrootdeps/miniz-sys-0.1.7/miniz.c0000664000175000017500000072177312536146032012653 0ustar /* miniz.c v1.16 beta r1 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing See "unlicense" statement at the end of this file. Rich Geldreich , last updated Oct. 13, 2013 Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt Most API's defined in miniz.c are optional. For example, to disable the archive related functions just define MINIZ_NO_ARCHIVE_APIS, or to get rid of all stdio usage define MINIZ_NO_STDIO (see the list below for more macros). * Change History 10/19/13 v1.16 beta r1 - Two key inflator-only robustness and streaming related changes. Also merged in tdefl_compressor_alloc(), tdefl_compressor_free() helpers to make script bindings easier for rustyzip. - The inflator coroutine func. is subtle and complex so I'm being cautious about this release. I would greatly appreciate any help with testing or any feedback. I feel good about these changes, and they've been through several hours of automated testing, but they will probably not fix anything for the majority of prev. users so I'm going to mark this release as beta for a few weeks and continue testing it at work/home on various things. - The inflator in raw (non-zlib) mode is now usable on gzip or similiar data streams that have a bunch of bytes following the raw deflate data (problem discovered by rustyzip author williamw520). This version should *never* read beyond the last byte of the raw deflate data independent of how many bytes you pass into the input buffer. This issue was caused by the various Huffman bitbuffer lookahead optimizations, and would not be an issue if the caller knew and enforced the precise size of the raw compressed data *or* if the compressed data was in zlib format (i.e. always followed by the byte aligned zlib adler32). So in other words, you can now call the inflator on deflate streams that are followed by arbitrary amounts of data and it's guaranteed that decompression will stop exactly on the last byte. - The inflator now has a new failure status: TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS (-4). Previously, if the inflator was starved of bytes and could not make progress (because the input buffer was empty and the caller did not set the TINFL_FLAG_HAS_MORE_INPUT flag - say on truncated or corrupted compressed data stream) it would append all 0's to the input and try to soldier on. This is scary, because in the worst case, I believe it was possible for the prev. inflator to start outputting large amounts of literal data. If the caller didn't know when to stop accepting output (because it didn't know how much uncompressed data was expected, or didn't enforce a sane maximum) it could continue forever. v1.16 cannot fall into this failure mode, instead it'll return TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS immediately if it needs 1 or more bytes to make progress, the input buf is empty, and the caller has indicated that no more input is available. This is a "soft" failure, so you can call the inflator again with more input and it will try to continue, or you can give up and fail. This could be very useful in network streaming scenarios. - Added documentation to all the tinfl return status codes, fixed miniz_tester so it accepts double minus params for Linux, tweaked example1.c, added a simple "follower bytes" test to miniz_tester.cpp. 10/13/13 v1.15 r4 - Interim bugfix release while I work on the next major release with Zip64 support (almost there!): - Critical fix for the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY bug (thanks kahmyong.moon@hp.com) which could cause locate files to not find files. This bug would only have occured in earlier versions if you explicitly used this flag, OR if you used mz_zip_extract_archive_file_to_heap() or mz_zip_add_mem_to_archive_file_in_place() (which used this flag). If you can't switch to v1.15 but want to fix this bug, just remove the uses of this flag from both helper funcs (and of course don't use the flag). - Bugfix in mz_zip_reader_extract_to_mem_no_alloc() from kymoon when pUser_read_buf is not NULL and compressed size is > uncompressed size - Fixing mz_zip_reader_extract_*() funcs so they don't try to extract compressed data from directory entries, to account for weird zipfiles which contain zero-size compressed data on dir entries. Hopefully this fix won't cause any issues on weird zip archives, because it assumes the low 16-bits of zip external attributes are DOS attributes (which I believe they always are in practice). - Fixing mz_zip_reader_is_file_a_directory() so it doesn't check the internal attributes, just the filename and external attributes - mz_zip_reader_init_file() - missing MZ_FCLOSE() call if the seek failed - Added cmake support for Linux builds which builds all the examples, tested with clang v3.3 and gcc v4.6. - Clang fix for tdefl_write_image_to_png_file_in_memory() from toffaletti - Merged MZ_FORCEINLINE fix from hdeanclark - Fix include before config #ifdef, thanks emil.brink - Added tdefl_write_image_to_png_file_in_memory_ex(): supports Y flipping (super useful for OpenGL apps), and explicit control over the compression level (so you can set it to 1 for real-time compression). - Merged in some compiler fixes from paulharris's github repro. - Retested this build under Windows (VS 2010, including static analysis), tcc 0.9.26, gcc v4.6 and clang v3.3. - Added example6.c, which dumps an image of the mandelbrot set to a PNG file. - Modified example2 to help test the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY flag more. - In r3: Bugfix to mz_zip_writer_add_file() found during merge: Fix possible src file fclose() leak if alignment bytes+local header file write faiiled - In r4: Minor bugfix to mz_zip_writer_add_from_zip_reader(): Was pushing the wrong central dir header offset, appears harmless in this release, but it became a problem in the zip64 branch 5/20/12 v1.14 - MinGW32/64 GCC 4.6.1 compiler fixes: added MZ_FORCEINLINE, #include (thanks fermtect). 5/19/12 v1.13 - From jason@cornsyrup.org and kelwert@mtu.edu - Fix mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bit. - Temporarily/locally slammed in "typedef unsigned long mz_ulong" and re-ran a randomized regression test on ~500k files. - Eliminated a bunch of warnings when compiling with GCC 32-bit/64. - Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze (static analysis) option and fixed all warnings (except for the silly "Use of the comma-operator in a tested expression.." analysis warning, which I purposely use to work around a MSVC compiler warning). - Created 32-bit and 64-bit Codeblocks projects/workspace. Built and tested Linux executables. The codeblocks workspace is compatible with Linux+Win32/x64. - Added miniz_tester solution/project, which is a useful little app derived from LZHAM's tester app that I use as part of the regression test. - Ran miniz.c and tinfl.c through another series of regression testing on ~500,000 files and archives. - Modified example5.c so it purposely disables a bunch of high-level functionality (MINIZ_NO_STDIO, etc.). (Thanks to corysama for the MINIZ_NO_STDIO bug report.) - Fix ftell() usage in examples so they exit with an error on files which are too large (a limitation of the examples, not miniz itself). 4/12/12 v1.12 - More comments, added low-level example5.c, fixed a couple minor level_and_flags issues in the archive API's. level_and_flags can now be set to MZ_DEFAULT_COMPRESSION. Thanks to Bruce Dawson for the feedback/bug report. 5/28/11 v1.11 - Added statement from unlicense.org 5/27/11 v1.10 - Substantial compressor optimizations: - Level 1 is now ~4x faster than before. The L1 compressor's throughput now varies between 70-110MB/sec. on a - Core i7 (actual throughput varies depending on the type of data, and x64 vs. x86). - Improved baseline L2-L9 compression perf. Also, greatly improved compression perf. issues on some file types. - Refactored the compression code for better readability and maintainability. - Added level 10 compression level (L10 has slightly better ratio than level 9, but could have a potentially large drop in throughput on some files). 5/15/11 v1.09 - Initial stable release. * Low-level Deflate/Inflate implementation notes: Compression: Use the "tdefl" API's. The compressor supports raw, static, and dynamic blocks, lazy or greedy parsing, match length filtering, RLE-only, and Huffman-only streams. It performs and compresses approximately as well as zlib. Decompression: Use the "tinfl" API's. The entire decompressor is implemented as a single function coroutine: see tinfl_decompress(). It supports decompression into a 32KB (or larger power of 2) wrapping buffer, or into a memory block large enough to hold the entire file. The low-level tdefl/tinfl API's do not make any use of dynamic memory allocation. * zlib-style API notes: miniz.c implements a fairly large subset of zlib. There's enough functionality present for it to be a drop-in zlib replacement in many apps: The z_stream struct, optional memory allocation callbacks deflateInit/deflateInit2/deflate/deflateReset/deflateEnd/deflateBound inflateInit/inflateInit2/inflate/inflateEnd compress, compress2, compressBound, uncompress CRC-32, Adler-32 - Using modern, minimal code size, CPU cache friendly routines. Supports raw deflate streams or standard zlib streams with adler-32 checking. Limitations: The callback API's are not implemented yet. No support for gzip headers or zlib static dictionaries. I've tried to closely emulate zlib's various flavors of stream flushing and return status codes, but there are no guarantees that miniz.c pulls this off perfectly. * PNG writing: See the tdefl_write_image_to_png_file_in_memory() function, originally written by Alex Evans. Supports 1-4 bytes/pixel images. * ZIP archive API notes: The ZIP archive API's where designed with simplicity and efficiency in mind, with just enough abstraction to get the job done with minimal fuss. There are simple API's to retrieve file information, read files from existing archives, create new archives, append new files to existing archives, or clone archive data from one archive to another. It supports archives located in memory or the heap, on disk (using stdio.h), or you can specify custom file read/write callbacks. - Archive reading: Just call this function to read a single file from a disk archive: void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint zip_flags); For more complex cases, use the "mz_zip_reader" functions. Upon opening an archive, the entire central directory is located and read as-is into memory, and subsequent file access only occurs when reading individual files. - Archives file scanning: The simple way is to use this function to scan a loaded archive for a specific file: int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags); The locate operation can optionally check file comments too, which (as one example) can be used to identify multiple versions of the same file in an archive. This function uses a simple linear search through the central directory, so it's not very fast. Alternately, you can iterate through all the files in an archive (using mz_zip_reader_get_num_files()) and retrieve detailed info on each file by calling mz_zip_reader_file_stat(). - Archive creation: Use the "mz_zip_writer" functions. The ZIP writer immediately writes compressed file data to disk and builds an exact image of the central directory in memory. The central directory image is written all at once at the end of the archive file when the archive is finalized. The archive writer can optionally align each file's local header and file data to any power of 2 alignment, which can be useful when the archive will be read from optical media. Also, the writer supports placing arbitrary data blobs at the very beginning of ZIP archives. Archives written using either feature are still readable by any ZIP tool. - Archive appending: The simple way to add a single file to an archive is to call this function: mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); The archive will be created if it doesn't already exist, otherwise it'll be appended to. Note the appending is done in-place and is not an atomic operation, so if something goes wrong during the operation it's possible the archive could be left without a central directory (although the local file headers and file data will be fine, so the archive will be recoverable). For more complex archive modification scenarios: 1. The safest way is to use a mz_zip_reader to read the existing archive, cloning only those bits you want to preserve into a new archive using using the mz_zip_writer_add_from_zip_reader() function (which compiles the compressed file data as-is). When you're done, delete the old archive and rename the newly written archive, and you're done. This is safe but requires a bunch of temporary disk space or heap memory. 2. Or, you can convert an mz_zip_reader in-place to an mz_zip_writer using mz_zip_writer_init_from_reader(), append new files as needed, then finalize the archive which will write an updated central directory to the original archive. (This is basically what mz_zip_add_mem_to_archive_file_in_place() does.) There's a possibility that the archive's central directory could be lost with this method if anything goes wrong, though. - ZIP archive support limitations: No zip64 or spanning support. Extraction functions can only handle unencrypted, stored or deflated files. Requires streams capable of seeking. * This is a header file library, like stb_image.c. To get only a header file, either cut and paste the below header, or create miniz.h, #define MINIZ_HEADER_FILE_ONLY, and then include miniz.c from it. * Important: For best perf. be sure to customize the below macros for your target platform: #define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1 #define MINIZ_LITTLE_ENDIAN 1 #define MINIZ_HAS_64BIT_REGISTERS 1 * On platforms using glibc, Be sure to "#define _LARGEFILE64_SOURCE 1" before including miniz.c to ensure miniz uses the 64-bit variants: fopen64(), stat64(), etc. Otherwise you won't be able to process large files (i.e. 32-bit stat() fails for me on files > 0x7FFFFFFF bytes). */ #ifndef MINIZ_HEADER_INCLUDED #define MINIZ_HEADER_INCLUDED #include // Defines to completely disable specific portions of miniz.c: // If all macros here are defined the only functionality remaining will be CRC-32, adler-32, tinfl, and tdefl. // Define MINIZ_NO_STDIO to disable all usage and any functions which rely on stdio for file I/O. //#define MINIZ_NO_STDIO // If MINIZ_NO_TIME is specified then the ZIP archive functions will not be able to get the current time, or // get/set file times, and the C run-time funcs that get/set times won't be called. // The current downside is the times written to your archives will be from 1979. //#define MINIZ_NO_TIME // Define MINIZ_NO_ARCHIVE_APIS to disable all ZIP archive API's. //#define MINIZ_NO_ARCHIVE_APIS // Define MINIZ_NO_ARCHIVE_APIS to disable all writing related ZIP archive API's. //#define MINIZ_NO_ARCHIVE_WRITING_APIS // Define MINIZ_NO_ZLIB_APIS to remove all ZLIB-style compression/decompression API's. //#define MINIZ_NO_ZLIB_APIS // Define MINIZ_NO_ZLIB_COMPATIBLE_NAME to disable zlib names, to prevent conflicts against stock zlib. //#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES // Define MINIZ_NO_MALLOC to disable all calls to malloc, free, and realloc. // Note if MINIZ_NO_MALLOC is defined then the user must always provide custom user alloc/free/realloc // callbacks to the zlib and archive API's, and a few stand-alone helper API's which don't provide custom user // functions (such as tdefl_compress_mem_to_heap() and tinfl_decompress_mem_to_heap()) won't work. //#define MINIZ_NO_MALLOC #if defined(__TINYC__) && (defined(__linux) || defined(__linux__)) // TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux #define MINIZ_NO_TIME #endif #if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS) #include #endif #if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__) // MINIZ_X86_OR_X64_CPU is only used to help set the below macros. #define MINIZ_X86_OR_X64_CPU 1 #endif #if (__BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU // Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian. #define MINIZ_LITTLE_ENDIAN 1 #endif #if MINIZ_X86_OR_X64_CPU // Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient integer loads and stores from unaligned addresses. #define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1 #endif #if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__) || defined(__ia64__) || defined(__x86_64__) // Set MINIZ_HAS_64BIT_REGISTERS to 1 if operations on 64-bit integers are reasonably fast (and don't involve compiler generated calls to helper functions). #define MINIZ_HAS_64BIT_REGISTERS 1 #endif #ifdef __cplusplus extern "C" { #endif // ------------------- zlib-style API Definitions. // For more compatibility with zlib, miniz.c uses unsigned long for some parameters/struct members. Beware: mz_ulong can be either 32 or 64-bits! typedef unsigned long mz_ulong; // mz_free() internally uses the MZ_FREE() macro (which by default calls free() unless you've modified the MZ_MALLOC macro) to release a block allocated from the heap. void mz_free(void *p); #define MZ_ADLER32_INIT (1) // mz_adler32() returns the initial adler-32 value to use when called with ptr==NULL. mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len); #define MZ_CRC32_INIT (0) // mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL. mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len); // Compression strategies. enum { MZ_DEFAULT_STRATEGY = 0, MZ_FILTERED = 1, MZ_HUFFMAN_ONLY = 2, MZ_RLE = 3, MZ_FIXED = 4 }; // Method #define MZ_DEFLATED 8 #ifndef MINIZ_NO_ZLIB_APIS // Heap allocation callbacks. // Note that mz_alloc_func parameter types purpsosely differ from zlib's: items/size is size_t, not unsigned long. typedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size); typedef void (*mz_free_func)(void *opaque, void *address); typedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items, size_t size); // TODO: I can't encode "1.16" here, argh #define MZ_VERSION "9.1.15" #define MZ_VERNUM 0x91F0 #define MZ_VER_MAJOR 9 #define MZ_VER_MINOR 1 #define MZ_VER_REVISION 15 #define MZ_VER_SUBREVISION 0 // Flush values. For typical usage you only need MZ_NO_FLUSH and MZ_FINISH. The other values are for advanced use (refer to the zlib docs). enum { MZ_NO_FLUSH = 0, MZ_PARTIAL_FLUSH = 1, MZ_SYNC_FLUSH = 2, MZ_FULL_FLUSH = 3, MZ_FINISH = 4, MZ_BLOCK = 5 }; // Return status codes. MZ_PARAM_ERROR is non-standard. enum { MZ_OK = 0, MZ_STREAM_END = 1, MZ_NEED_DICT = 2, MZ_ERRNO = -1, MZ_STREAM_ERROR = -2, MZ_DATA_ERROR = -3, MZ_MEM_ERROR = -4, MZ_BUF_ERROR = -5, MZ_VERSION_ERROR = -6, MZ_PARAM_ERROR = -10000 }; // Compression levels: 0-9 are the standard zlib-style levels, 10 is best possible compression (not zlib compatible, and may be very slow), MZ_DEFAULT_COMPRESSION=MZ_DEFAULT_LEVEL. enum { MZ_NO_COMPRESSION = 0, MZ_BEST_SPEED = 1, MZ_BEST_COMPRESSION = 9, MZ_UBER_COMPRESSION = 10, MZ_DEFAULT_LEVEL = 6, MZ_DEFAULT_COMPRESSION = -1 }; // Window bits #define MZ_DEFAULT_WINDOW_BITS 15 struct mz_internal_state; // Compression/decompression stream struct. typedef struct mz_stream_s { const unsigned char *next_in; // pointer to next byte to read unsigned int avail_in; // number of bytes available at next_in mz_ulong total_in; // total number of bytes consumed so far unsigned char *next_out; // pointer to next byte to write unsigned int avail_out; // number of bytes that can be written to next_out mz_ulong total_out; // total number of bytes produced so far char *msg; // error msg (unused) struct mz_internal_state *state; // internal state, allocated by zalloc/zfree mz_alloc_func zalloc; // optional heap allocation function (defaults to malloc) mz_free_func zfree; // optional heap free function (defaults to free) void *opaque; // heap alloc function user pointer int data_type; // data_type (unused) mz_ulong adler; // adler32 of the source or uncompressed data mz_ulong reserved; // not used } mz_stream; typedef mz_stream *mz_streamp; // Returns the version string of miniz.c. const char *mz_version(void); // mz_deflateInit() initializes a compressor with default options: // Parameters: // pStream must point to an initialized mz_stream struct. // level must be between [MZ_NO_COMPRESSION, MZ_BEST_COMPRESSION]. // level 1 enables a specially optimized compression function that's been optimized purely for performance, not ratio. // (This special func. is currently only enabled when MINIZ_USE_UNALIGNED_LOADS_AND_STORES and MINIZ_LITTLE_ENDIAN are defined.) // Return values: // MZ_OK on success. // MZ_STREAM_ERROR if the stream is bogus. // MZ_PARAM_ERROR if the input parameters are bogus. // MZ_MEM_ERROR on out of memory. int mz_deflateInit(mz_streamp pStream, int level); // mz_deflateInit2() is like mz_deflate(), except with more control: // Additional parameters: // method must be MZ_DEFLATED // window_bits must be MZ_DEFAULT_WINDOW_BITS (to wrap the deflate stream with zlib header/adler-32 footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate/no header or footer) // mem_level must be between [1, 9] (it's checked but ignored by miniz.c) int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy); // Quickly resets a compressor without having to reallocate anything. Same as calling mz_deflateEnd() followed by mz_deflateInit()/mz_deflateInit2(). int mz_deflateReset(mz_streamp pStream); // mz_deflate() compresses the input to output, consuming as much of the input and producing as much output as possible. // Parameters: // pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members. // flush may be MZ_NO_FLUSH, MZ_PARTIAL_FLUSH/MZ_SYNC_FLUSH, MZ_FULL_FLUSH, or MZ_FINISH. // Return values: // MZ_OK on success (when flushing, or if more input is needed but not available, and/or there's more output to be written but the output buffer is full). // MZ_STREAM_END if all input has been consumed and all output bytes have been written. Don't call mz_deflate() on the stream anymore. // MZ_STREAM_ERROR if the stream is bogus. // MZ_PARAM_ERROR if one of the parameters is invalid. // MZ_BUF_ERROR if no forward progress is possible because the input and/or output buffers are empty. (Fill up the input buffer or free up some output space and try again.) int mz_deflate(mz_streamp pStream, int flush); // mz_deflateEnd() deinitializes a compressor: // Return values: // MZ_OK on success. // MZ_STREAM_ERROR if the stream is bogus. int mz_deflateEnd(mz_streamp pStream); // mz_deflateBound() returns a (very) conservative upper bound on the amount of data that could be generated by deflate(), assuming flush is set to only MZ_NO_FLUSH or MZ_FINISH. mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len); // Single-call compression functions mz_compress() and mz_compress2(): // Returns MZ_OK on success, or one of the error codes from mz_deflate() on failure. int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len); int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level); // mz_compressBound() returns a (very) conservative upper bound on the amount of data that could be generated by calling mz_compress(). mz_ulong mz_compressBound(mz_ulong source_len); // Initializes a decompressor. int mz_inflateInit(mz_streamp pStream); // mz_inflateInit2() is like mz_inflateInit() with an additional option that controls the window size and whether or not the stream has been wrapped with a zlib header/footer: // window_bits must be MZ_DEFAULT_WINDOW_BITS (to parse zlib header/footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate). int mz_inflateInit2(mz_streamp pStream, int window_bits); // Decompresses the input stream to the output, consuming only as much of the input as needed, and writing as much to the output as possible. // Parameters: // pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members. // flush may be MZ_NO_FLUSH, MZ_SYNC_FLUSH, or MZ_FINISH. // On the first call, if flush is MZ_FINISH it's assumed the input and output buffers are both sized large enough to decompress the entire stream in a single call (this is slightly faster). // MZ_FINISH implies that there are no more source bytes available beside what's already in the input buffer, and that the output buffer is large enough to hold the rest of the decompressed data. // Return values: // MZ_OK on success. Either more input is needed but not available, and/or there's more output to be written but the output buffer is full. // MZ_STREAM_END if all needed input has been consumed and all output bytes have been written. For zlib streams, the adler-32 of the decompressed data has also been verified. // MZ_STREAM_ERROR if the stream is bogus. // MZ_DATA_ERROR if the deflate stream is invalid. // MZ_PARAM_ERROR if one of the parameters is invalid. // MZ_BUF_ERROR if no forward progress is possible because the input buffer is empty but the inflater needs more input to continue, or if the output buffer is not large enough. Call mz_inflate() again // with more input data, or with more room in the output buffer (except when using single call decompression, described above). int mz_inflate(mz_streamp pStream, int flush); // Deinitializes a decompressor. int mz_inflateEnd(mz_streamp pStream); // Single-call decompression. // Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure. int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len); // Returns a string description of the specified error code, or NULL if the error code is invalid. const char *mz_error(int err); // Redefine zlib-compatible names to miniz equivalents, so miniz.c can be used as a drop-in replacement for the subset of zlib that miniz.c supports. // Define MINIZ_NO_ZLIB_COMPATIBLE_NAMES to disable zlib-compatibility if you use zlib in the same project. #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES typedef unsigned char Byte; typedef unsigned int uInt; typedef mz_ulong uLong; typedef Byte Bytef; typedef uInt uIntf; typedef char charf; typedef int intf; typedef void *voidpf; typedef uLong uLongf; typedef void *voidp; typedef void *const voidpc; #define Z_NULL 0 #define Z_NO_FLUSH MZ_NO_FLUSH #define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH #define Z_SYNC_FLUSH MZ_SYNC_FLUSH #define Z_FULL_FLUSH MZ_FULL_FLUSH #define Z_FINISH MZ_FINISH #define Z_BLOCK MZ_BLOCK #define Z_OK MZ_OK #define Z_STREAM_END MZ_STREAM_END #define Z_NEED_DICT MZ_NEED_DICT #define Z_ERRNO MZ_ERRNO #define Z_STREAM_ERROR MZ_STREAM_ERROR #define Z_DATA_ERROR MZ_DATA_ERROR #define Z_MEM_ERROR MZ_MEM_ERROR #define Z_BUF_ERROR MZ_BUF_ERROR #define Z_VERSION_ERROR MZ_VERSION_ERROR #define Z_PARAM_ERROR MZ_PARAM_ERROR #define Z_NO_COMPRESSION MZ_NO_COMPRESSION #define Z_BEST_SPEED MZ_BEST_SPEED #define Z_BEST_COMPRESSION MZ_BEST_COMPRESSION #define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION #define Z_DEFAULT_STRATEGY MZ_DEFAULT_STRATEGY #define Z_FILTERED MZ_FILTERED #define Z_HUFFMAN_ONLY MZ_HUFFMAN_ONLY #define Z_RLE MZ_RLE #define Z_FIXED MZ_FIXED #define Z_DEFLATED MZ_DEFLATED #define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS #define alloc_func mz_alloc_func #define free_func mz_free_func #define internal_state mz_internal_state #define z_stream mz_stream #define deflateInit mz_deflateInit #define deflateInit2 mz_deflateInit2 #define deflateReset mz_deflateReset #define deflate mz_deflate #define deflateEnd mz_deflateEnd #define deflateBound mz_deflateBound #define compress mz_compress #define compress2 mz_compress2 #define compressBound mz_compressBound #define inflateInit mz_inflateInit #define inflateInit2 mz_inflateInit2 #define inflate mz_inflate #define inflateEnd mz_inflateEnd #define uncompress mz_uncompress #define crc32 mz_crc32 #define adler32 mz_adler32 #define MAX_WBITS 15 #define MAX_MEM_LEVEL 9 #define zError mz_error #define ZLIB_VERSION MZ_VERSION #define ZLIB_VERNUM MZ_VERNUM #define ZLIB_VER_MAJOR MZ_VER_MAJOR #define ZLIB_VER_MINOR MZ_VER_MINOR #define ZLIB_VER_REVISION MZ_VER_REVISION #define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION #define zlibVersion mz_version #define zlib_version mz_version() #endif // #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES #endif // MINIZ_NO_ZLIB_APIS // ------------------- Types and macros typedef unsigned char mz_uint8; typedef signed short mz_int16; typedef unsigned short mz_uint16; typedef unsigned int mz_uint32; typedef unsigned int mz_uint; typedef long long mz_int64; typedef unsigned long long mz_uint64; typedef int mz_bool; #define MZ_FALSE (0) #define MZ_TRUE (1) // An attempt to work around MSVC's spammy "warning C4127: conditional expression is constant" message. #ifdef _MSC_VER #define MZ_MACRO_END while (0, 0) #else #define MZ_MACRO_END while (0) #endif // ------------------- ZIP archive reading/writing #ifndef MINIZ_NO_ARCHIVE_APIS enum { MZ_ZIP_MAX_IO_BUF_SIZE = 64*1024, MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE = 260, MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE = 256 }; typedef struct { mz_uint32 m_file_index; mz_uint32 m_central_dir_ofs; mz_uint16 m_version_made_by; mz_uint16 m_version_needed; mz_uint16 m_bit_flag; mz_uint16 m_method; #ifndef MINIZ_NO_TIME time_t m_time; #endif mz_uint32 m_crc32; mz_uint64 m_comp_size; mz_uint64 m_uncomp_size; mz_uint16 m_internal_attr; mz_uint32 m_external_attr; mz_uint64 m_local_header_ofs; mz_uint32 m_comment_size; char m_filename[MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE]; char m_comment[MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE]; } mz_zip_archive_file_stat; typedef size_t (*mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n); typedef size_t (*mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n); struct mz_zip_internal_state_tag; typedef struct mz_zip_internal_state_tag mz_zip_internal_state; typedef enum { MZ_ZIP_MODE_INVALID = 0, MZ_ZIP_MODE_READING = 1, MZ_ZIP_MODE_WRITING = 2, MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED = 3 } mz_zip_mode; typedef struct mz_zip_archive_tag { mz_uint64 m_archive_size; mz_uint64 m_central_directory_file_ofs; mz_uint m_total_files; mz_zip_mode m_zip_mode; mz_uint m_file_offset_alignment; mz_alloc_func m_pAlloc; mz_free_func m_pFree; mz_realloc_func m_pRealloc; void *m_pAlloc_opaque; mz_file_read_func m_pRead; mz_file_write_func m_pWrite; void *m_pIO_opaque; mz_zip_internal_state *m_pState; } mz_zip_archive; typedef enum { MZ_ZIP_FLAG_CASE_SENSITIVE = 0x0100, MZ_ZIP_FLAG_IGNORE_PATH = 0x0200, MZ_ZIP_FLAG_COMPRESSED_DATA = 0x0400, MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY = 0x0800 } mz_zip_flags; // ZIP archive reading // Inits a ZIP archive reader. // These functions read and validate the archive's central directory. mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint32 flags); mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint32 flags); #ifndef MINIZ_NO_STDIO mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags); #endif // Returns the total number of files in the archive. mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip); // Returns detailed information about an archive file entry. mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat); // Determines if an archive file entry is a directory entry. mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index); mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index); // Retrieves the filename of an archive file entry. // Returns the number of bytes written to pFilename, or if filename_buf_size is 0 this function returns the number of bytes needed to fully store the filename. mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size); // Attempts to locates a file in the archive's central directory. // Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH // Returns -1 if the file cannot be found. int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags); // Extracts a archive file to a memory buffer using no memory allocation. mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size); mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size); // Extracts a archive file to a memory buffer. mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags); mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags); // Extracts a archive file to a dynamically allocated heap buffer. void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags); void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags); // Extracts a archive file using a callback function to output the file's data. mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags); mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags); #ifndef MINIZ_NO_STDIO // Extracts a archive file to a disk file and sets its last accessed and modified times. // This function only extracts files, not archive directory records. mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags); mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags); #endif // Ends archive reading, freeing all allocations, and closing the input archive file if mz_zip_reader_init_file() was used. mz_bool mz_zip_reader_end(mz_zip_archive *pZip); // ZIP archive writing #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS // Inits a ZIP archive writer. mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size); mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size); #ifndef MINIZ_NO_STDIO mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning); #endif // Converts a ZIP archive reader object into a writer object, to allow efficient in-place file appends to occur on an existing archive. // For archives opened using mz_zip_reader_init_file, pFilename must be the archive's filename so it can be reopened for writing. If the file can't be reopened, mz_zip_reader_end() will be called. // For archives opened using mz_zip_reader_init_mem, the memory block must be growable using the realloc callback (which defaults to realloc unless you've overridden it). // Finally, for archives opened using mz_zip_reader_init, the mz_zip_archive's user provided m_pWrite function cannot be NULL. // Note: In-place archive modification is not recommended unless you know what you're doing, because if execution stops or something goes wrong before // the archive is finalized the file's central directory will be hosed. mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename); // Adds the contents of a memory buffer to an archive. These functions record the current local time into the archive. // To add a directory entry, call this method with an archive name ending in a forwardslash with empty buffer. // level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags); mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32); #ifndef MINIZ_NO_STDIO // Adds the contents of a disk file to an archive. This function also records the disk file's modified time into the archive. // level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); #endif // Adds a file to an archive by fully cloning the data from another archive. // This function fully clones the source file's compressed data (no recompression), along with its full filename, extra data, and comment fields. mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint file_index); // Finalizes the archive by writing the central directory records followed by the end of central directory record. // After an archive is finalized, the only valid call on the mz_zip_archive struct is mz_zip_writer_end(). // An archive must be manually finalized by calling this function for it to be valid. mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip); mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf, size_t *pSize); // Ends archive writing, freeing all allocations, and closing the output file if mz_zip_writer_init_file() was used. // Note for the archive to be valid, it must have been finalized before ending. mz_bool mz_zip_writer_end(mz_zip_archive *pZip); // Misc. high-level helper functions: // mz_zip_add_mem_to_archive_file_in_place() efficiently (but not atomically) appends a memory blob to a ZIP archive. // level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); // Reads a single file from an archive into a heap block. // Returns NULL on failure. void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint zip_flags); #endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS #endif // #ifndef MINIZ_NO_ARCHIVE_APIS // ------------------- Low-level Decompression API Definitions // Decompression flags used by tinfl_decompress(). // TINFL_FLAG_PARSE_ZLIB_HEADER: If set, the input has a valid zlib header and ends with an adler32 checksum (it's a valid zlib stream). Otherwise, the input is a raw deflate stream. // TINFL_FLAG_HAS_MORE_INPUT: If set, there are more input bytes available beyond the end of the supplied input buffer. If clear, the input buffer contains all remaining input. // TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF: If set, the output buffer is large enough to hold the entire decompressed stream. If clear, the output buffer is at least the size of the dictionary (typically 32KB). // TINFL_FLAG_COMPUTE_ADLER32: Force adler-32 checksum computation of the decompressed bytes. enum { TINFL_FLAG_PARSE_ZLIB_HEADER = 1, TINFL_FLAG_HAS_MORE_INPUT = 2, TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF = 4, TINFL_FLAG_COMPUTE_ADLER32 = 8 }; // High level decompression functions: // tinfl_decompress_mem_to_heap() decompresses a block in memory to a heap block allocated via malloc(). // On entry: // pSrc_buf, src_buf_len: Pointer and size of the Deflate or zlib source data to decompress. // On return: // Function returns a pointer to the decompressed data, or NULL on failure. // *pOut_len will be set to the decompressed data's size, which could be larger than src_buf_len on uncompressible data. // The caller must call mz_free() on the returned block when it's no longer needed. void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags); // tinfl_decompress_mem_to_mem() decompresses a block in memory to another block in memory. // Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes written on success. #define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1)) size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags); // tinfl_decompress_mem_to_callback() decompresses a block in memory to an internal 32KB buffer, and a user provided callback function will be called to flush the buffer. // Returns 1 on success or 0 on failure. typedef int (*tinfl_put_buf_func_ptr)(const void* pBuf, int len, void *pUser); int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); struct tinfl_decompressor_tag; typedef struct tinfl_decompressor_tag tinfl_decompressor; // Max size of LZ dictionary. #define TINFL_LZ_DICT_SIZE 32768 // Return status. typedef enum { // This flags indicates the inflator needs 1 or more input bytes to make forward progress, but the caller is indicating that no more are available. The compressed data // is probably corrupted. If you call the inflator again with more bytes it'll try to continue processing the input but this is a BAD sign (either the data is corrupted or you called it incorrectly). // If you call it again with no input you'll just get TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS again. TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS = -4, // This flag indicates that one or more of the input parameters was obviously bogus. (You can try calling it again, but if you get this error the calling code is wrong.) TINFL_STATUS_BAD_PARAM = -3, // This flags indicate the inflator is finished but the adler32 check of the uncompressed data didn't match. If you call it again it'll return TINFL_STATUS_DONE. TINFL_STATUS_ADLER32_MISMATCH = -2, // This flags indicate the inflator has somehow failed (bad code, corrupted input, etc.). If you call it again without resetting via tinfl_init() it it'll just keep on returning the same status failure code. TINFL_STATUS_FAILED = -1, // Any status code less than TINFL_STATUS_DONE must indicate a failure. // This flag indicates the inflator has returned every byte of uncompressed data that it can, has consumed every byte that it needed, has successfully reached the end of the deflate stream, and // if zlib headers and adler32 checking enabled that it has successfully checked the uncompressed data's adler32. If you call it again you'll just get TINFL_STATUS_DONE over and over again. TINFL_STATUS_DONE = 0, // This flag indicates the inflator MUST have more input data (even 1 byte) before it can make any more forward progress, or you need to clear the TINFL_FLAG_HAS_MORE_INPUT // flag on the next call if you don't have any more source data. If the source data was somehow corrupted it's also possible (but unlikely) for the inflator to keep on demanding input to // proceed, so be sure to properly set the TINFL_FLAG_HAS_MORE_INPUT flag. TINFL_STATUS_NEEDS_MORE_INPUT = 1, // This flag indicates the inflator definitely has 1 or more bytes of uncompressed data available, but it cannot write this data into the output buffer. // Note if the source compressed data was corrupted it's possible for the inflator to return a lot of uncompressed data to the caller. I've been assuming you know how much uncompressed data to expect // (either exact or worst case) and will stop calling the inflator and fail after receiving too much. In pure streaming scenarios where you have no idea how many bytes to expect this may not be possible // so I may need to add some code to address this. TINFL_STATUS_HAS_MORE_OUTPUT = 2 } tinfl_status; // Initializes the decompressor to its initial state. #define tinfl_init(r) do { (r)->m_state = 0; } MZ_MACRO_END #define tinfl_get_adler32(r) (r)->m_check_adler32 // Main low-level decompressor coroutine function. This is the only function actually needed for decompression. All the other functions are just high-level helpers for improved usability. // This is a universal API, i.e. it can be used as a building block to build any desired higher level decompression API. In the limit case, it can be called once per every byte input or output. tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags); // Internal/private bits follow. enum { TINFL_MAX_HUFF_TABLES = 3, TINFL_MAX_HUFF_SYMBOLS_0 = 288, TINFL_MAX_HUFF_SYMBOLS_1 = 32, TINFL_MAX_HUFF_SYMBOLS_2 = 19, TINFL_FAST_LOOKUP_BITS = 10, TINFL_FAST_LOOKUP_SIZE = 1 << TINFL_FAST_LOOKUP_BITS }; typedef struct { mz_uint8 m_code_size[TINFL_MAX_HUFF_SYMBOLS_0]; mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE], m_tree[TINFL_MAX_HUFF_SYMBOLS_0 * 2]; } tinfl_huff_table; #if MINIZ_HAS_64BIT_REGISTERS #define TINFL_USE_64BIT_BITBUF 1 #endif #if TINFL_USE_64BIT_BITBUF typedef mz_uint64 tinfl_bit_buf_t; #define TINFL_BITBUF_SIZE (64) #else typedef mz_uint32 tinfl_bit_buf_t; #define TINFL_BITBUF_SIZE (32) #endif struct tinfl_decompressor_tag { mz_uint32 m_state, m_num_bits, m_zhdr0, m_zhdr1, m_z_adler32, m_final, m_type, m_check_adler32, m_dist, m_counter, m_num_extra, m_table_sizes[TINFL_MAX_HUFF_TABLES]; tinfl_bit_buf_t m_bit_buf; size_t m_dist_from_out_buf_start; tinfl_huff_table m_tables[TINFL_MAX_HUFF_TABLES]; mz_uint8 m_raw_header[4], m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0 + TINFL_MAX_HUFF_SYMBOLS_1 + 137]; }; // ------------------- Low-level Compression API Definitions // Set TDEFL_LESS_MEMORY to 1 to use less memory (compression will be slightly slower, and raw/dynamic blocks will be output more frequently). #define TDEFL_LESS_MEMORY 0 // tdefl_init() compression flags logically OR'd together (low 12 bits contain the max. number of probes per dictionary search): // TDEFL_DEFAULT_MAX_PROBES: The compressor defaults to 128 dictionary probes per dictionary search. 0=Huffman only, 1=Huffman+LZ (fastest/crap compression), 4095=Huffman+LZ (slowest/best compression). enum { TDEFL_HUFFMAN_ONLY = 0, TDEFL_DEFAULT_MAX_PROBES = 128, TDEFL_MAX_PROBES_MASK = 0xFFF }; // TDEFL_WRITE_ZLIB_HEADER: If set, the compressor outputs a zlib header before the deflate data, and the Adler-32 of the source data at the end. Otherwise, you'll get raw deflate data. // TDEFL_COMPUTE_ADLER32: Always compute the adler-32 of the input data (even when not writing zlib headers). // TDEFL_GREEDY_PARSING_FLAG: Set to use faster greedy parsing, instead of more efficient lazy parsing. // TDEFL_NONDETERMINISTIC_PARSING_FLAG: Enable to decrease the compressor's initialization time to the minimum, but the output may vary from run to run given the same input (depending on the contents of memory). // TDEFL_RLE_MATCHES: Only look for RLE matches (matches with a distance of 1) // TDEFL_FILTER_MATCHES: Discards matches <= 5 chars if enabled. // TDEFL_FORCE_ALL_STATIC_BLOCKS: Disable usage of optimized Huffman tables. // TDEFL_FORCE_ALL_RAW_BLOCKS: Only use raw (uncompressed) deflate blocks. // The low 12 bits are reserved to control the max # of hash probes per dictionary lookup (see TDEFL_MAX_PROBES_MASK). enum { TDEFL_WRITE_ZLIB_HEADER = 0x01000, TDEFL_COMPUTE_ADLER32 = 0x02000, TDEFL_GREEDY_PARSING_FLAG = 0x04000, TDEFL_NONDETERMINISTIC_PARSING_FLAG = 0x08000, TDEFL_RLE_MATCHES = 0x10000, TDEFL_FILTER_MATCHES = 0x20000, TDEFL_FORCE_ALL_STATIC_BLOCKS = 0x40000, TDEFL_FORCE_ALL_RAW_BLOCKS = 0x80000 }; // High level compression functions: // tdefl_compress_mem_to_heap() compresses a block in memory to a heap block allocated via malloc(). // On entry: // pSrc_buf, src_buf_len: Pointer and size of source block to compress. // flags: The max match finder probes (default is 128) logically OR'd against the above flags. Higher probes are slower but improve compression. // On return: // Function returns a pointer to the compressed data, or NULL on failure. // *pOut_len will be set to the compressed data's size, which could be larger than src_buf_len on uncompressible data. // The caller must free() the returned block when it's no longer needed. void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags); // tdefl_compress_mem_to_mem() compresses a block in memory to another block in memory. // Returns 0 on failure. size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags); // Compresses an image to a compressed PNG file in memory. // On entry: // pImage, w, h, and num_chans describe the image to compress. num_chans may be 1, 2, 3, or 4. // The image pitch in bytes per scanline will be w*num_chans. The leftmost pixel on the top scanline is stored first in memory. // level may range from [0,10], use MZ_NO_COMPRESSION, MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc. or a decent default is MZ_DEFAULT_LEVEL // If flip is true, the image will be flipped on the Y axis (useful for OpenGL apps). // On return: // Function returns a pointer to the compressed data, or NULL on failure. // *pLen_out will be set to the size of the PNG image file. // The caller must mz_free() the returned heap block (which will typically be larger than *pLen_out) when it's no longer needed. void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip); void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out); // Output stream interface. The compressor uses this interface to write compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time. typedef mz_bool (*tdefl_put_buf_func_ptr)(const void* pBuf, int len, void *pUser); // tdefl_compress_mem_to_output() compresses a block to an output stream. The above helpers use this function internally. mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); enum { TDEFL_MAX_HUFF_TABLES = 3, TDEFL_MAX_HUFF_SYMBOLS_0 = 288, TDEFL_MAX_HUFF_SYMBOLS_1 = 32, TDEFL_MAX_HUFF_SYMBOLS_2 = 19, TDEFL_LZ_DICT_SIZE = 32768, TDEFL_LZ_DICT_SIZE_MASK = TDEFL_LZ_DICT_SIZE - 1, TDEFL_MIN_MATCH_LEN = 3, TDEFL_MAX_MATCH_LEN = 258 }; // TDEFL_OUT_BUF_SIZE MUST be large enough to hold a single entire compressed output block (using static/fixed Huffman codes). #if TDEFL_LESS_MEMORY enum { TDEFL_LZ_CODE_BUF_SIZE = 24 * 1024, TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13 ) / 10, TDEFL_MAX_HUFF_SYMBOLS = 288, TDEFL_LZ_HASH_BITS = 12, TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS }; #else enum { TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024, TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13 ) / 10, TDEFL_MAX_HUFF_SYMBOLS = 288, TDEFL_LZ_HASH_BITS = 15, TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS }; #endif // The low-level tdefl functions below may be used directly if the above helper functions aren't flexible enough. The low-level functions don't make any heap allocations, unlike the above helper functions. typedef enum { TDEFL_STATUS_BAD_PARAM = -2, TDEFL_STATUS_PUT_BUF_FAILED = -1, TDEFL_STATUS_OKAY = 0, TDEFL_STATUS_DONE = 1, } tdefl_status; // Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums typedef enum { TDEFL_NO_FLUSH = 0, TDEFL_SYNC_FLUSH = 2, TDEFL_FULL_FLUSH = 3, TDEFL_FINISH = 4 } tdefl_flush; // tdefl's compression state structure. typedef struct { tdefl_put_buf_func_ptr m_pPut_buf_func; void *m_pPut_buf_user; mz_uint m_flags, m_max_probes[2]; int m_greedy_parsing; mz_uint m_adler32, m_lookahead_pos, m_lookahead_size, m_dict_size; mz_uint8 *m_pLZ_code_buf, *m_pLZ_flags, *m_pOutput_buf, *m_pOutput_buf_end; mz_uint m_num_flags_left, m_total_lz_bytes, m_lz_code_buf_dict_pos, m_bits_in, m_bit_buffer; mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit, m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index, m_wants_to_finish; tdefl_status m_prev_return_status; const void *m_pIn_buf; void *m_pOut_buf; size_t *m_pIn_buf_size, *m_pOut_buf_size; tdefl_flush m_flush; const mz_uint8 *m_pSrc; size_t m_src_buf_left, m_out_buf_ofs; mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE + TDEFL_MAX_MATCH_LEN - 1]; mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE]; mz_uint16 m_next[TDEFL_LZ_DICT_SIZE]; mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE]; mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE]; } tdefl_compressor; // Initializes the compressor. // There is no corresponding deinit() function because the tdefl API's do not dynamically allocate memory. // pBut_buf_func: If NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression. // If pBut_buf_func is NULL the user should always call the tdefl_compress() API. // flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.) tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); // Compresses a block of data, consuming as much of the specified input buffer as possible, and writing as much compressed data to the specified output buffer as possible. tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush); // tdefl_compress_buffer() is only usable when the tdefl_init() is called with a non-NULL tdefl_put_buf_func_ptr. // tdefl_compress_buffer() always consumes the entire input buffer. tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush); tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d); mz_uint32 tdefl_get_adler32(tdefl_compressor *d); // Can't use tdefl_create_comp_flags_from_zip_params if MINIZ_NO_ZLIB_APIS isn't defined, because it uses some of its macros. #ifndef MINIZ_NO_ZLIB_APIS // Create tdefl_compress() flags given zlib-style compression parameters. // level may range from [0,10] (where 10 is absolute max compression, but may be much slower on some files) // window_bits may be -15 (raw deflate) or 15 (zlib) // strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, MZ_RLE, or MZ_FIXED mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy); #endif // #ifndef MINIZ_NO_ZLIB_APIS // Allocate the tdefl_compressor and tinfl_decompressor structures in C so that // non-C language bindings to tdefl_ and tinfl_ API don't need to worry about // structure size and allocation mechanism. tdefl_compressor *tdefl_compressor_alloc(); void tdefl_compressor_free(tdefl_compressor *pComp); tinfl_decompressor *tinfl_decompressor_alloc(); void tinfl_decompressor_free(tinfl_decompressor *pDecomp); #ifdef __cplusplus } #endif #endif // MINIZ_HEADER_INCLUDED // ------------------- End of Header: Implementation follows. (If you only want the header, define MINIZ_HEADER_FILE_ONLY.) #ifndef MINIZ_HEADER_FILE_ONLY typedef unsigned char mz_validate_uint16[sizeof(mz_uint16)==2 ? 1 : -1]; typedef unsigned char mz_validate_uint32[sizeof(mz_uint32)==4 ? 1 : -1]; typedef unsigned char mz_validate_uint64[sizeof(mz_uint64)==8 ? 1 : -1]; #include #include #define MZ_ASSERT(x) assert(x) #ifdef MINIZ_NO_MALLOC #define MZ_MALLOC(x) NULL #define MZ_FREE(x) (void)x, ((void)0) #define MZ_REALLOC(p, x) NULL #else #define MZ_MALLOC(x) malloc(x) #define MZ_FREE(x) free(x) #define MZ_REALLOC(p, x) realloc(p, x) #endif #define MZ_MAX(a,b) (((a)>(b))?(a):(b)) #define MZ_MIN(a,b) (((a)<(b))?(a):(b)) #define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj)) #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN #define MZ_READ_LE16(p) *((const mz_uint16 *)(p)) #define MZ_READ_LE32(p) *((const mz_uint32 *)(p)) #else #define MZ_READ_LE16(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U)) #define MZ_READ_LE32(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) | ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) | ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U)) #endif #ifdef _MSC_VER #define MZ_FORCEINLINE __forceinline #elif defined(__GNUC__) #define MZ_FORCEINLINE inline __attribute__((__always_inline__)) #else #define MZ_FORCEINLINE inline #endif #ifdef __cplusplus extern "C" { #endif // ------------------- zlib-style API's mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len) { mz_uint32 i, s1 = (mz_uint32)(adler & 0xffff), s2 = (mz_uint32)(adler >> 16); size_t block_len = buf_len % 5552; if (!ptr) return MZ_ADLER32_INIT; while (buf_len) { for (i = 0; i + 7 < block_len; i += 8, ptr += 8) { s1 += ptr[0], s2 += s1; s1 += ptr[1], s2 += s1; s1 += ptr[2], s2 += s1; s1 += ptr[3], s2 += s1; s1 += ptr[4], s2 += s1; s1 += ptr[5], s2 += s1; s1 += ptr[6], s2 += s1; s1 += ptr[7], s2 += s1; } for ( ; i < block_len; ++i) s1 += *ptr++, s2 += s1; s1 %= 65521U, s2 %= 65521U; buf_len -= block_len; block_len = 5552; } return (s2 << 16) + s1; } // Karl Malbrain's compact CRC-32. See "A compact CCITT crc16 and crc32 C implementation that balances processor cache usage against speed": http://www.geocities.com/malbrain/ mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len) { static const mz_uint32 s_crc32[16] = { 0, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c, 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c }; mz_uint32 crcu32 = (mz_uint32)crc; if (!ptr) return MZ_CRC32_INIT; crcu32 = ~crcu32; while (buf_len--) { mz_uint8 b = *ptr++; crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b & 0xF)]; crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b >> 4)]; } return ~crcu32; } void mz_free(void *p) { MZ_FREE(p); } #ifndef MINIZ_NO_ZLIB_APIS static void *def_alloc_func(void *opaque, size_t items, size_t size) { (void)opaque, (void)items, (void)size; return MZ_MALLOC(items * size); } static void def_free_func(void *opaque, void *address) { (void)opaque, (void)address; MZ_FREE(address); } static void *def_realloc_func(void *opaque, void *address, size_t items, size_t size) { (void)opaque, (void)address, (void)items, (void)size; return MZ_REALLOC(address, items * size); } const char *mz_version(void) { return MZ_VERSION; } int mz_deflateInit(mz_streamp pStream, int level) { return mz_deflateInit2(pStream, level, MZ_DEFLATED, MZ_DEFAULT_WINDOW_BITS, 9, MZ_DEFAULT_STRATEGY); } int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy) { tdefl_compressor *pComp; mz_uint comp_flags = TDEFL_COMPUTE_ADLER32 | tdefl_create_comp_flags_from_zip_params(level, window_bits, strategy); if (!pStream) return MZ_STREAM_ERROR; if ((method != MZ_DEFLATED) || ((mem_level < 1) || (mem_level > 9)) || ((window_bits != MZ_DEFAULT_WINDOW_BITS) && (-window_bits != MZ_DEFAULT_WINDOW_BITS))) return MZ_PARAM_ERROR; pStream->data_type = 0; pStream->adler = MZ_ADLER32_INIT; pStream->msg = NULL; pStream->reserved = 0; pStream->total_in = 0; pStream->total_out = 0; if (!pStream->zalloc) pStream->zalloc = def_alloc_func; if (!pStream->zfree) pStream->zfree = def_free_func; pComp = (tdefl_compressor *)pStream->zalloc(pStream->opaque, 1, sizeof(tdefl_compressor)); if (!pComp) return MZ_MEM_ERROR; pStream->state = (struct mz_internal_state *)pComp; if (tdefl_init(pComp, NULL, NULL, comp_flags) != TDEFL_STATUS_OKAY) { mz_deflateEnd(pStream); return MZ_PARAM_ERROR; } return MZ_OK; } int mz_deflateReset(mz_streamp pStream) { if ((!pStream) || (!pStream->state) || (!pStream->zalloc) || (!pStream->zfree)) return MZ_STREAM_ERROR; pStream->total_in = pStream->total_out = 0; tdefl_init((tdefl_compressor*)pStream->state, NULL, NULL, ((tdefl_compressor*)pStream->state)->m_flags); return MZ_OK; } int mz_deflate(mz_streamp pStream, int flush) { size_t in_bytes, out_bytes; mz_ulong orig_total_in, orig_total_out; int mz_status = MZ_OK; if ((!pStream) || (!pStream->state) || (flush < 0) || (flush > MZ_FINISH) || (!pStream->next_out)) return MZ_STREAM_ERROR; if (!pStream->avail_out) return MZ_BUF_ERROR; if (flush == MZ_PARTIAL_FLUSH) flush = MZ_SYNC_FLUSH; if (((tdefl_compressor*)pStream->state)->m_prev_return_status == TDEFL_STATUS_DONE) return (flush == MZ_FINISH) ? MZ_STREAM_END : MZ_BUF_ERROR; orig_total_in = pStream->total_in; orig_total_out = pStream->total_out; for ( ; ; ) { tdefl_status defl_status; in_bytes = pStream->avail_in; out_bytes = pStream->avail_out; defl_status = tdefl_compress((tdefl_compressor*)pStream->state, pStream->next_in, &in_bytes, pStream->next_out, &out_bytes, (tdefl_flush)flush); pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; pStream->total_in += (mz_uint)in_bytes; pStream->adler = tdefl_get_adler32((tdefl_compressor*)pStream->state); pStream->next_out += (mz_uint)out_bytes; pStream->avail_out -= (mz_uint)out_bytes; pStream->total_out += (mz_uint)out_bytes; if (defl_status < 0) { mz_status = MZ_STREAM_ERROR; break; } else if (defl_status == TDEFL_STATUS_DONE) { mz_status = MZ_STREAM_END; break; } else if (!pStream->avail_out) break; else if ((!pStream->avail_in) && (flush != MZ_FINISH)) { if ((flush) || (pStream->total_in != orig_total_in) || (pStream->total_out != orig_total_out)) break; return MZ_BUF_ERROR; // Can't make forward progress without some input. } } return mz_status; } int mz_deflateEnd(mz_streamp pStream) { if (!pStream) return MZ_STREAM_ERROR; if (pStream->state) { pStream->zfree(pStream->opaque, pStream->state); pStream->state = NULL; } return MZ_OK; } mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len) { (void)pStream; // This is really over conservative. (And lame, but it's actually pretty tricky to compute a true upper bound given the way tdefl's blocking works.) return MZ_MAX(128 + (source_len * 110) / 100, 128 + source_len + ((source_len / (31 * 1024)) + 1) * 5); } int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level) { int status; mz_stream stream; memset(&stream, 0, sizeof(stream)); // In case mz_ulong is 64-bits (argh I hate longs). if ((source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR; stream.next_in = pSource; stream.avail_in = (mz_uint32)source_len; stream.next_out = pDest; stream.avail_out = (mz_uint32)*pDest_len; status = mz_deflateInit(&stream, level); if (status != MZ_OK) return status; status = mz_deflate(&stream, MZ_FINISH); if (status != MZ_STREAM_END) { mz_deflateEnd(&stream); return (status == MZ_OK) ? MZ_BUF_ERROR : status; } *pDest_len = stream.total_out; return mz_deflateEnd(&stream); } int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len) { return mz_compress2(pDest, pDest_len, pSource, source_len, MZ_DEFAULT_COMPRESSION); } mz_ulong mz_compressBound(mz_ulong source_len) { return mz_deflateBound(NULL, source_len); } typedef struct { tinfl_decompressor m_decomp; mz_uint m_dict_ofs, m_dict_avail, m_first_call, m_has_flushed; int m_window_bits; mz_uint8 m_dict[TINFL_LZ_DICT_SIZE]; tinfl_status m_last_status; } inflate_state; int mz_inflateInit2(mz_streamp pStream, int window_bits) { inflate_state *pDecomp; if (!pStream) return MZ_STREAM_ERROR; if ((window_bits != MZ_DEFAULT_WINDOW_BITS) && (-window_bits != MZ_DEFAULT_WINDOW_BITS)) return MZ_PARAM_ERROR; pStream->data_type = 0; pStream->adler = 0; pStream->msg = NULL; pStream->total_in = 0; pStream->total_out = 0; pStream->reserved = 0; if (!pStream->zalloc) pStream->zalloc = def_alloc_func; if (!pStream->zfree) pStream->zfree = def_free_func; pDecomp = (inflate_state*)pStream->zalloc(pStream->opaque, 1, sizeof(inflate_state)); if (!pDecomp) return MZ_MEM_ERROR; pStream->state = (struct mz_internal_state *)pDecomp; tinfl_init(&pDecomp->m_decomp); pDecomp->m_dict_ofs = 0; pDecomp->m_dict_avail = 0; pDecomp->m_last_status = TINFL_STATUS_NEEDS_MORE_INPUT; pDecomp->m_first_call = 1; pDecomp->m_has_flushed = 0; pDecomp->m_window_bits = window_bits; return MZ_OK; } int mz_inflateInit(mz_streamp pStream) { return mz_inflateInit2(pStream, MZ_DEFAULT_WINDOW_BITS); } int mz_inflate(mz_streamp pStream, int flush) { inflate_state* pState; mz_uint n, first_call, decomp_flags = TINFL_FLAG_COMPUTE_ADLER32; size_t in_bytes, out_bytes, orig_avail_in; tinfl_status status; if ((!pStream) || (!pStream->state)) return MZ_STREAM_ERROR; if (flush == MZ_PARTIAL_FLUSH) flush = MZ_SYNC_FLUSH; if ((flush) && (flush != MZ_SYNC_FLUSH) && (flush != MZ_FINISH)) return MZ_STREAM_ERROR; pState = (inflate_state*)pStream->state; if (pState->m_window_bits > 0) decomp_flags |= TINFL_FLAG_PARSE_ZLIB_HEADER; orig_avail_in = pStream->avail_in; first_call = pState->m_first_call; pState->m_first_call = 0; if (pState->m_last_status < 0) return MZ_DATA_ERROR; if (pState->m_has_flushed && (flush != MZ_FINISH)) return MZ_STREAM_ERROR; pState->m_has_flushed |= (flush == MZ_FINISH); if ((flush == MZ_FINISH) && (first_call)) { // MZ_FINISH on the first call implies that the input and output buffers are large enough to hold the entire compressed/decompressed file. decomp_flags |= TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF; in_bytes = pStream->avail_in; out_bytes = pStream->avail_out; status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pStream->next_out, pStream->next_out, &out_bytes, decomp_flags); pState->m_last_status = status; pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; pStream->total_in += (mz_uint)in_bytes; pStream->adler = tinfl_get_adler32(&pState->m_decomp); pStream->next_out += (mz_uint)out_bytes; pStream->avail_out -= (mz_uint)out_bytes; pStream->total_out += (mz_uint)out_bytes; if (status < 0) return MZ_DATA_ERROR; else if (status != TINFL_STATUS_DONE) { pState->m_last_status = TINFL_STATUS_FAILED; return MZ_BUF_ERROR; } return MZ_STREAM_END; } // flush != MZ_FINISH then we must assume there's more input. if (flush != MZ_FINISH) decomp_flags |= TINFL_FLAG_HAS_MORE_INPUT; if (pState->m_dict_avail) { n = MZ_MIN(pState->m_dict_avail, pStream->avail_out); memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n); pStream->next_out += n; pStream->avail_out -= n; pStream->total_out += n; pState->m_dict_avail -= n; pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1); return ((pState->m_last_status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK; } for ( ; ; ) { in_bytes = pStream->avail_in; out_bytes = TINFL_LZ_DICT_SIZE - pState->m_dict_ofs; status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pState->m_dict, pState->m_dict + pState->m_dict_ofs, &out_bytes, decomp_flags); pState->m_last_status = status; pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; pStream->total_in += (mz_uint)in_bytes; pStream->adler = tinfl_get_adler32(&pState->m_decomp); pState->m_dict_avail = (mz_uint)out_bytes; n = MZ_MIN(pState->m_dict_avail, pStream->avail_out); memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n); pStream->next_out += n; pStream->avail_out -= n; pStream->total_out += n; pState->m_dict_avail -= n; pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1); if (status < 0) return MZ_DATA_ERROR; // Stream is corrupted (there could be some uncompressed data left in the output dictionary - oh well). else if ((status == TINFL_STATUS_NEEDS_MORE_INPUT) && (!orig_avail_in)) return MZ_BUF_ERROR; // Signal caller that we can't make forward progress without supplying more input or by setting flush to MZ_FINISH. else if (flush == MZ_FINISH) { // The output buffer MUST be large to hold the remaining uncompressed data when flush==MZ_FINISH. if (status == TINFL_STATUS_DONE) return pState->m_dict_avail ? MZ_BUF_ERROR : MZ_STREAM_END; // status here must be TINFL_STATUS_HAS_MORE_OUTPUT, which means there's at least 1 more byte on the way. If there's no more room left in the output buffer then something is wrong. else if (!pStream->avail_out) return MZ_BUF_ERROR; } else if ((status == TINFL_STATUS_DONE) || (!pStream->avail_in) || (!pStream->avail_out) || (pState->m_dict_avail)) break; } return ((status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK; } int mz_inflateEnd(mz_streamp pStream) { if (!pStream) return MZ_STREAM_ERROR; if (pStream->state) { pStream->zfree(pStream->opaque, pStream->state); pStream->state = NULL; } return MZ_OK; } int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len) { mz_stream stream; int status; memset(&stream, 0, sizeof(stream)); // In case mz_ulong is 64-bits (argh I hate longs). if ((source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR; stream.next_in = pSource; stream.avail_in = (mz_uint32)source_len; stream.next_out = pDest; stream.avail_out = (mz_uint32)*pDest_len; status = mz_inflateInit(&stream); if (status != MZ_OK) return status; status = mz_inflate(&stream, MZ_FINISH); if (status != MZ_STREAM_END) { mz_inflateEnd(&stream); return ((status == MZ_BUF_ERROR) && (!stream.avail_in)) ? MZ_DATA_ERROR : status; } *pDest_len = stream.total_out; return mz_inflateEnd(&stream); } const char *mz_error(int err) { static struct { int m_err; const char *m_pDesc; } s_error_descs[] = { { MZ_OK, "" }, { MZ_STREAM_END, "stream end" }, { MZ_NEED_DICT, "need dictionary" }, { MZ_ERRNO, "file error" }, { MZ_STREAM_ERROR, "stream error" }, { MZ_DATA_ERROR, "data error" }, { MZ_MEM_ERROR, "out of memory" }, { MZ_BUF_ERROR, "buf error" }, { MZ_VERSION_ERROR, "version error" }, { MZ_PARAM_ERROR, "parameter error" } }; mz_uint i; for (i = 0; i < sizeof(s_error_descs) / sizeof(s_error_descs[0]); ++i) if (s_error_descs[i].m_err == err) return s_error_descs[i].m_pDesc; return NULL; } #endif //MINIZ_NO_ZLIB_APIS // ------------------- Low-level Decompression (completely independent from all compression API's) #define TINFL_MEMCPY(d, s, l) memcpy(d, s, l) #define TINFL_MEMSET(p, c, l) memset(p, c, l) #define TINFL_CR_BEGIN switch(r->m_state) { case 0: #define TINFL_CR_RETURN(state_index, result) do { status = result; r->m_state = state_index; goto common_exit; case state_index:; } MZ_MACRO_END #define TINFL_CR_RETURN_FOREVER(state_index, result) do { for ( ; ; ) { TINFL_CR_RETURN(state_index, result); } } MZ_MACRO_END #define TINFL_CR_FINISH } #define TINFL_GET_BYTE(state_index, c) do { \ while (pIn_buf_cur >= pIn_buf_end) { \ TINFL_CR_RETURN(state_index, (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) ? TINFL_STATUS_NEEDS_MORE_INPUT : TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS); \ } c = *pIn_buf_cur++; } MZ_MACRO_END #define TINFL_NEED_BITS(state_index, n) do { mz_uint c; TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; } while (num_bits < (mz_uint)(n)) #define TINFL_SKIP_BITS(state_index, n) do { if (num_bits < (mz_uint)(n)) { TINFL_NEED_BITS(state_index, n); } bit_buf >>= (n); num_bits -= (n); } MZ_MACRO_END #define TINFL_GET_BITS(state_index, b, n) do { if (num_bits < (mz_uint)(n)) { TINFL_NEED_BITS(state_index, n); } b = bit_buf & ((1 << (n)) - 1); bit_buf >>= (n); num_bits -= (n); } MZ_MACRO_END // TINFL_HUFF_BITBUF_FILL() is only used rarely, when the number of bytes remaining in the input buffer falls below 2. // It reads just enough bytes from the input stream that are needed to decode the next Huffman code (and absolutely no more). It works by trying to fully decode a // Huffman code by using whatever bits are currently present in the bit buffer. If this fails, it reads another byte, and tries again until it succeeds or until the // bit buffer contains >=15 bits (deflate's max. Huffman code size). #define TINFL_HUFF_BITBUF_FILL(state_index, pHuff) \ do { \ temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]; \ if (temp >= 0) { \ code_len = temp >> 9; \ if ((code_len) && (num_bits >= code_len)) \ break; \ } else if (num_bits > TINFL_FAST_LOOKUP_BITS) { \ code_len = TINFL_FAST_LOOKUP_BITS; \ do { \ temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \ } while ((temp < 0) && (num_bits >= (code_len + 1))); if (temp >= 0) break; \ } TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; \ } while (num_bits < 15); // TINFL_HUFF_DECODE() decodes the next Huffman coded symbol. It's more complex than you would initially expect because the zlib API expects the decompressor to never read // beyond the final byte of the deflate stream. (In other words, when this macro wants to read another byte from the input, it REALLY needs another byte in order to fully // decode the next Huffman code.) Handling this properly is particularly important on raw deflate (non-zlib) streams, which aren't followed by a byte aligned adler-32. // The slow path is only executed at the very end of the input buffer. // v1.16: The original macro handled the case at the very end of the passed-in input buffer, but we also need to handle the case where the user passes in 1+zillion bytes // following the deflate data and our non-conservative read-ahead path won't kick in here on this code. This is much trickier. #define TINFL_HUFF_DECODE(state_index, sym, pHuff) do { \ int temp; mz_uint code_len, c; \ if (num_bits < 15) { \ if ((pIn_buf_end - pIn_buf_cur) < 2) { \ TINFL_HUFF_BITBUF_FILL(state_index, pHuff); \ } else { \ bit_buf |= (((tinfl_bit_buf_t)pIn_buf_cur[0]) << num_bits) | (((tinfl_bit_buf_t)pIn_buf_cur[1]) << (num_bits + 8)); pIn_buf_cur += 2; num_bits += 16; \ } \ } \ if ((temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) \ code_len = temp >> 9, temp &= 511; \ else { \ code_len = TINFL_FAST_LOOKUP_BITS; do { temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; } while (temp < 0); \ } sym = temp; bit_buf >>= code_len; num_bits -= code_len; } MZ_MACRO_END tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags) { static const int s_length_base[31] = { 3,4,5,6,7,8,9,10,11,13, 15,17,19,23,27,31,35,43,51,59, 67,83,99,115,131,163,195,227,258,0,0 }; static const int s_length_extra[31]= { 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; static const int s_dist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, 257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; static const int s_dist_extra[32] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; static const mz_uint8 s_length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; static const int s_min_table_sizes[3] = { 257, 1, 4 }; tinfl_status status = TINFL_STATUS_FAILED; mz_uint32 num_bits, dist, counter, num_extra; tinfl_bit_buf_t bit_buf; const mz_uint8 *pIn_buf_cur = pIn_buf_next, *const pIn_buf_end = pIn_buf_next + *pIn_buf_size; mz_uint8 *pOut_buf_cur = pOut_buf_next, *const pOut_buf_end = pOut_buf_next + *pOut_buf_size; size_t out_buf_size_mask = (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF) ? (size_t)-1 : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1, dist_from_out_buf_start; // Ensure the output buffer's size is a power of 2, unless the output buffer is large enough to hold the entire output file (in which case it doesn't matter). if (((out_buf_size_mask + 1) & out_buf_size_mask) || (pOut_buf_next < pOut_buf_start)) { *pIn_buf_size = *pOut_buf_size = 0; return TINFL_STATUS_BAD_PARAM; } num_bits = r->m_num_bits; bit_buf = r->m_bit_buf; dist = r->m_dist; counter = r->m_counter; num_extra = r->m_num_extra; dist_from_out_buf_start = r->m_dist_from_out_buf_start; TINFL_CR_BEGIN bit_buf = num_bits = dist = counter = num_extra = r->m_zhdr0 = r->m_zhdr1 = 0; r->m_z_adler32 = r->m_check_adler32 = 1; if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) { TINFL_GET_BYTE(1, r->m_zhdr0); TINFL_GET_BYTE(2, r->m_zhdr1); counter = (((r->m_zhdr0 * 256 + r->m_zhdr1) % 31 != 0) || (r->m_zhdr1 & 32) || ((r->m_zhdr0 & 15) != 8)); if (!(decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) counter |= (((1U << (8U + (r->m_zhdr0 >> 4))) > 32768U) || ((out_buf_size_mask + 1) < (size_t)(1U << (8U + (r->m_zhdr0 >> 4))))); if (counter) { TINFL_CR_RETURN_FOREVER(36, TINFL_STATUS_FAILED); } } do { TINFL_GET_BITS(3, r->m_final, 3); r->m_type = r->m_final >> 1; if (r->m_type == 0) { TINFL_SKIP_BITS(5, num_bits & 7); for (counter = 0; counter < 4; ++counter) { if (num_bits) TINFL_GET_BITS(6, r->m_raw_header[counter], 8); else TINFL_GET_BYTE(7, r->m_raw_header[counter]); } if ((counter = (r->m_raw_header[0] | (r->m_raw_header[1] << 8))) != (mz_uint)(0xFFFF ^ (r->m_raw_header[2] | (r->m_raw_header[3] << 8)))) { TINFL_CR_RETURN_FOREVER(39, TINFL_STATUS_FAILED); } while ((counter) && (num_bits)) { TINFL_GET_BITS(51, dist, 8); while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(52, TINFL_STATUS_HAS_MORE_OUTPUT); } *pOut_buf_cur++ = (mz_uint8)dist; counter--; } while (counter) { size_t n; while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(9, TINFL_STATUS_HAS_MORE_OUTPUT); } while (pIn_buf_cur >= pIn_buf_end) { TINFL_CR_RETURN(38, (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) ? TINFL_STATUS_NEEDS_MORE_INPUT : TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS); } n = MZ_MIN(MZ_MIN((size_t)(pOut_buf_end - pOut_buf_cur), (size_t)(pIn_buf_end - pIn_buf_cur)), counter); TINFL_MEMCPY(pOut_buf_cur, pIn_buf_cur, n); pIn_buf_cur += n; pOut_buf_cur += n; counter -= (mz_uint)n; } } else if (r->m_type == 3) { TINFL_CR_RETURN_FOREVER(10, TINFL_STATUS_FAILED); } else { if (r->m_type == 1) { mz_uint8 *p = r->m_tables[0].m_code_size; mz_uint i; r->m_table_sizes[0] = 288; r->m_table_sizes[1] = 32; TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32); for ( i = 0; i <= 143; ++i) *p++ = 8; for ( ; i <= 255; ++i) *p++ = 9; for ( ; i <= 279; ++i) *p++ = 7; for ( ; i <= 287; ++i) *p++ = 8; } else { for (counter = 0; counter < 3; counter++) { TINFL_GET_BITS(11, r->m_table_sizes[counter], "\05\05\04"[counter]); r->m_table_sizes[counter] += s_min_table_sizes[counter]; } MZ_CLEAR_OBJ(r->m_tables[2].m_code_size); for (counter = 0; counter < r->m_table_sizes[2]; counter++) { mz_uint s; TINFL_GET_BITS(14, s, 3); r->m_tables[2].m_code_size[s_length_dezigzag[counter]] = (mz_uint8)s; } r->m_table_sizes[2] = 19; } for ( ; (int)r->m_type >= 0; r->m_type--) { int tree_next, tree_cur; tinfl_huff_table *pTable; mz_uint i, j, used_syms, total, sym_index, next_code[17], total_syms[16]; pTable = &r->m_tables[r->m_type]; MZ_CLEAR_OBJ(total_syms); MZ_CLEAR_OBJ(pTable->m_look_up); MZ_CLEAR_OBJ(pTable->m_tree); for (i = 0; i < r->m_table_sizes[r->m_type]; ++i) total_syms[pTable->m_code_size[i]]++; used_syms = 0, total = 0; next_code[0] = next_code[1] = 0; for (i = 1; i <= 15; ++i) { used_syms += total_syms[i]; next_code[i + 1] = (total = ((total + total_syms[i]) << 1)); } if ((65536 != total) && (used_syms > 1)) { TINFL_CR_RETURN_FOREVER(35, TINFL_STATUS_FAILED); } for (tree_next = -1, sym_index = 0; sym_index < r->m_table_sizes[r->m_type]; ++sym_index) { mz_uint rev_code = 0, l, cur_code, code_size = pTable->m_code_size[sym_index]; if (!code_size) continue; cur_code = next_code[code_size]++; for (l = code_size; l > 0; l--, cur_code >>= 1) rev_code = (rev_code << 1) | (cur_code & 1); if (code_size <= TINFL_FAST_LOOKUP_BITS) { mz_int16 k = (mz_int16)((code_size << 9) | sym_index); while (rev_code < TINFL_FAST_LOOKUP_SIZE) { pTable->m_look_up[rev_code] = k; rev_code += (1 << code_size); } continue; } if (0 == (tree_cur = pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)])) { pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)] = (mz_int16)tree_next; tree_cur = tree_next; tree_next -= 2; } rev_code >>= (TINFL_FAST_LOOKUP_BITS - 1); for (j = code_size; j > (TINFL_FAST_LOOKUP_BITS + 1); j--) { tree_cur -= ((rev_code >>= 1) & 1); if (!pTable->m_tree[-tree_cur - 1]) { pTable->m_tree[-tree_cur - 1] = (mz_int16)tree_next; tree_cur = tree_next; tree_next -= 2; } else tree_cur = pTable->m_tree[-tree_cur - 1]; } tree_cur -= ((rev_code >>= 1) & 1); pTable->m_tree[-tree_cur - 1] = (mz_int16)sym_index; } if (r->m_type == 2) { for (counter = 0; counter < (r->m_table_sizes[0] + r->m_table_sizes[1]); ) { mz_uint s; TINFL_HUFF_DECODE(16, dist, &r->m_tables[2]); if (dist < 16) { r->m_len_codes[counter++] = (mz_uint8)dist; continue; } if ((dist == 16) && (!counter)) { TINFL_CR_RETURN_FOREVER(17, TINFL_STATUS_FAILED); } num_extra = "\02\03\07"[dist - 16]; TINFL_GET_BITS(18, s, num_extra); s += "\03\03\013"[dist - 16]; TINFL_MEMSET(r->m_len_codes + counter, (dist == 16) ? r->m_len_codes[counter - 1] : 0, s); counter += s; } if ((r->m_table_sizes[0] + r->m_table_sizes[1]) != counter) { TINFL_CR_RETURN_FOREVER(21, TINFL_STATUS_FAILED); } TINFL_MEMCPY(r->m_tables[0].m_code_size, r->m_len_codes, r->m_table_sizes[0]); TINFL_MEMCPY(r->m_tables[1].m_code_size, r->m_len_codes + r->m_table_sizes[0], r->m_table_sizes[1]); } } for ( ; ; ) { mz_uint8 *pSrc; for ( ; ; ) { if (((pIn_buf_end - pIn_buf_cur) < 4) || ((pOut_buf_end - pOut_buf_cur) < 2)) { TINFL_HUFF_DECODE(23, counter, &r->m_tables[0]); if (counter >= 256) break; while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(24, TINFL_STATUS_HAS_MORE_OUTPUT); } *pOut_buf_cur++ = (mz_uint8)counter; } else { int sym2; mz_uint code_len; #if TINFL_USE_64BIT_BITBUF if (num_bits < 30) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE32(pIn_buf_cur)) << num_bits); pIn_buf_cur += 4; num_bits += 32; } #else if (num_bits < 15) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits); pIn_buf_cur += 2; num_bits += 16; } #endif if ((sym2 = r->m_tables[0].m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) code_len = sym2 >> 9; else { code_len = TINFL_FAST_LOOKUP_BITS; do { sym2 = r->m_tables[0].m_tree[~sym2 + ((bit_buf >> code_len++) & 1)]; } while (sym2 < 0); } counter = sym2; bit_buf >>= code_len; num_bits -= code_len; if (counter & 256) break; #if !TINFL_USE_64BIT_BITBUF if (num_bits < 15) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits); pIn_buf_cur += 2; num_bits += 16; } #endif if ((sym2 = r->m_tables[0].m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) code_len = sym2 >> 9; else { code_len = TINFL_FAST_LOOKUP_BITS; do { sym2 = r->m_tables[0].m_tree[~sym2 + ((bit_buf >> code_len++) & 1)]; } while (sym2 < 0); } bit_buf >>= code_len; num_bits -= code_len; pOut_buf_cur[0] = (mz_uint8)counter; if (sym2 & 256) { pOut_buf_cur++; counter = sym2; break; } pOut_buf_cur[1] = (mz_uint8)sym2; pOut_buf_cur += 2; } } if ((counter &= 511) == 256) break; num_extra = s_length_extra[counter - 257]; counter = s_length_base[counter - 257]; if (num_extra) { mz_uint extra_bits; TINFL_GET_BITS(25, extra_bits, num_extra); counter += extra_bits; } TINFL_HUFF_DECODE(26, dist, &r->m_tables[1]); num_extra = s_dist_extra[dist]; dist = s_dist_base[dist]; if (num_extra) { mz_uint extra_bits; TINFL_GET_BITS(27, extra_bits, num_extra); dist += extra_bits; } dist_from_out_buf_start = pOut_buf_cur - pOut_buf_start; if ((dist > dist_from_out_buf_start) && (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) { TINFL_CR_RETURN_FOREVER(37, TINFL_STATUS_FAILED); } pSrc = pOut_buf_start + ((dist_from_out_buf_start - dist) & out_buf_size_mask); if ((MZ_MAX(pOut_buf_cur, pSrc) + counter) > pOut_buf_end) { while (counter--) { while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(53, TINFL_STATUS_HAS_MORE_OUTPUT); } *pOut_buf_cur++ = pOut_buf_start[(dist_from_out_buf_start++ - dist) & out_buf_size_mask]; } continue; } #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES else if ((counter >= 9) && (counter <= dist)) { const mz_uint8 *pSrc_end = pSrc + (counter & ~7); do { ((mz_uint32 *)pOut_buf_cur)[0] = ((const mz_uint32 *)pSrc)[0]; ((mz_uint32 *)pOut_buf_cur)[1] = ((const mz_uint32 *)pSrc)[1]; pOut_buf_cur += 8; } while ((pSrc += 8) < pSrc_end); if ((counter &= 7) < 3) { if (counter) { pOut_buf_cur[0] = pSrc[0]; if (counter > 1) pOut_buf_cur[1] = pSrc[1]; pOut_buf_cur += counter; } continue; } } #endif do { pOut_buf_cur[0] = pSrc[0]; pOut_buf_cur[1] = pSrc[1]; pOut_buf_cur[2] = pSrc[2]; pOut_buf_cur += 3; pSrc += 3; } while ((int)(counter -= 3) > 2); if ((int)counter > 0) { pOut_buf_cur[0] = pSrc[0]; if ((int)counter > 1) pOut_buf_cur[1] = pSrc[1]; pOut_buf_cur += counter; } } } } while (!(r->m_final & 1)); // Ensure byte alignment and put back any bytes from the bitbuf if we've looked ahead too far on gzip, or other Deflate streams followed by arbitrary data. // I'm being super conservative here. A number of simplifications can be made to the byte alignment part, and the Adler32 check shouldn't ever need to worry about reading from the bitbuf now. TINFL_SKIP_BITS(32, num_bits & 7); while ((pIn_buf_cur > pIn_buf_next) && (num_bits >= 8)) { --pIn_buf_cur; num_bits -= 8; } bit_buf &= (tinfl_bit_buf_t)((1ULL << num_bits) - 1ULL); MZ_ASSERT(!num_bits); // if this assert fires then we've read beyond the end of non-deflate/zlib streams with following data (such as gzip streams). if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) { for (counter = 0; counter < 4; ++counter) { mz_uint s; if (num_bits) TINFL_GET_BITS(41, s, 8); else TINFL_GET_BYTE(42, s); r->m_z_adler32 = (r->m_z_adler32 << 8) | s; } } TINFL_CR_RETURN_FOREVER(34, TINFL_STATUS_DONE); TINFL_CR_FINISH common_exit: // As long as we aren't telling the caller that we NEED more input to make forward progress: // Put back any bytes from the bitbuf in case we've looked ahead too far on gzip, or other Deflate streams followed by arbitrary data. // We need to be very careful here to NOT push back any bytes we definitely know we need to make forward progress, though, or we'll lock the caller up into an inf loop. if ((status != TINFL_STATUS_NEEDS_MORE_INPUT) && (status != TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS)) { while ((pIn_buf_cur > pIn_buf_next) && (num_bits >= 8)) { --pIn_buf_cur; num_bits -= 8; } } r->m_num_bits = num_bits; r->m_bit_buf = bit_buf & (tinfl_bit_buf_t)((1ULL << num_bits) - 1ULL); r->m_dist = dist; r->m_counter = counter; r->m_num_extra = num_extra; r->m_dist_from_out_buf_start = dist_from_out_buf_start; *pIn_buf_size = pIn_buf_cur - pIn_buf_next; *pOut_buf_size = pOut_buf_cur - pOut_buf_next; if ((decomp_flags & (TINFL_FLAG_PARSE_ZLIB_HEADER | TINFL_FLAG_COMPUTE_ADLER32)) && (status >= 0)) { const mz_uint8 *ptr = pOut_buf_next; size_t buf_len = *pOut_buf_size; mz_uint32 i, s1 = r->m_check_adler32 & 0xffff, s2 = r->m_check_adler32 >> 16; size_t block_len = buf_len % 5552; while (buf_len) { for (i = 0; i + 7 < block_len; i += 8, ptr += 8) { s1 += ptr[0], s2 += s1; s1 += ptr[1], s2 += s1; s1 += ptr[2], s2 += s1; s1 += ptr[3], s2 += s1; s1 += ptr[4], s2 += s1; s1 += ptr[5], s2 += s1; s1 += ptr[6], s2 += s1; s1 += ptr[7], s2 += s1; } for ( ; i < block_len; ++i) s1 += *ptr++, s2 += s1; s1 %= 65521U, s2 %= 65521U; buf_len -= block_len; block_len = 5552; } r->m_check_adler32 = (s2 << 16) + s1; if ((status == TINFL_STATUS_DONE) && (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) && (r->m_check_adler32 != r->m_z_adler32)) status = TINFL_STATUS_ADLER32_MISMATCH; } return status; } // Higher level helper functions. void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags) { tinfl_decompressor decomp; void *pBuf = NULL, *pNew_buf; size_t src_buf_ofs = 0, out_buf_capacity = 0; *pOut_len = 0; tinfl_init(&decomp); for ( ; ; ) { size_t src_buf_size = src_buf_len - src_buf_ofs, dst_buf_size = out_buf_capacity - *pOut_len, new_out_buf_capacity; tinfl_status status = tinfl_decompress(&decomp, (const mz_uint8*)pSrc_buf + src_buf_ofs, &src_buf_size, (mz_uint8*)pBuf, pBuf ? (mz_uint8*)pBuf + *pOut_len : NULL, &dst_buf_size, (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); if ((status < 0) || (status == TINFL_STATUS_NEEDS_MORE_INPUT)) { MZ_FREE(pBuf); *pOut_len = 0; return NULL; } src_buf_ofs += src_buf_size; *pOut_len += dst_buf_size; if (status == TINFL_STATUS_DONE) break; new_out_buf_capacity = out_buf_capacity * 2; if (new_out_buf_capacity < 128) new_out_buf_capacity = 128; pNew_buf = MZ_REALLOC(pBuf, new_out_buf_capacity); if (!pNew_buf) { MZ_FREE(pBuf); *pOut_len = 0; return NULL; } pBuf = pNew_buf; out_buf_capacity = new_out_buf_capacity; } return pBuf; } size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags) { tinfl_decompressor decomp; tinfl_status status; tinfl_init(&decomp); status = tinfl_decompress(&decomp, (const mz_uint8*)pSrc_buf, &src_buf_len, (mz_uint8*)pOut_buf, (mz_uint8*)pOut_buf, &out_buf_len, (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); return (status != TINFL_STATUS_DONE) ? TINFL_DECOMPRESS_MEM_TO_MEM_FAILED : out_buf_len; } int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) { int result = 0; tinfl_decompressor decomp; mz_uint8 *pDict = (mz_uint8*)MZ_MALLOC(TINFL_LZ_DICT_SIZE); size_t in_buf_ofs = 0, dict_ofs = 0; if (!pDict) return TINFL_STATUS_FAILED; tinfl_init(&decomp); for ( ; ; ) { size_t in_buf_size = *pIn_buf_size - in_buf_ofs, dst_buf_size = TINFL_LZ_DICT_SIZE - dict_ofs; tinfl_status status = tinfl_decompress(&decomp, (const mz_uint8*)pIn_buf + in_buf_ofs, &in_buf_size, pDict, pDict + dict_ofs, &dst_buf_size, (flags & ~(TINFL_FLAG_HAS_MORE_INPUT | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF))); in_buf_ofs += in_buf_size; if ((dst_buf_size) && (!(*pPut_buf_func)(pDict + dict_ofs, (int)dst_buf_size, pPut_buf_user))) break; if (status != TINFL_STATUS_HAS_MORE_OUTPUT) { result = (status == TINFL_STATUS_DONE); break; } dict_ofs = (dict_ofs + dst_buf_size) & (TINFL_LZ_DICT_SIZE - 1); } MZ_FREE(pDict); *pIn_buf_size = in_buf_ofs; return result; } // ------------------- Low-level Compression (independent from all decompression API's) // Purposely making these tables static for faster init and thread safety. static const mz_uint16 s_tdefl_len_sym[256] = { 257,258,259,260,261,262,263,264,265,265,266,266,267,267,268,268,269,269,269,269,270,270,270,270,271,271,271,271,272,272,272,272, 273,273,273,273,273,273,273,273,274,274,274,274,274,274,274,274,275,275,275,275,275,275,275,275,276,276,276,276,276,276,276,276, 277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278, 279,279,279,279,279,279,279,279,279,279,279,279,279,279,279,279,280,280,280,280,280,280,280,280,280,280,280,280,280,280,280,280, 281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281, 282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282, 283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283, 284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,285 }; static const mz_uint8 s_tdefl_len_extra[256] = { 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0 }; static const mz_uint8 s_tdefl_small_dist_sym[512] = { 0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11, 11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13, 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14, 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, 14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17, 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17 }; static const mz_uint8 s_tdefl_small_dist_extra[512] = { 0,0,0,0,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5, 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7 }; static const mz_uint8 s_tdefl_large_dist_sym[128] = { 0,0,18,19,20,20,21,21,22,22,22,22,23,23,23,23,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26, 26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29 }; static const mz_uint8 s_tdefl_large_dist_extra[128] = { 0,0,8,8,9,9,9,9,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13 }; // Radix sorts tdefl_sym_freq[] array by 16-bit key m_key. Returns ptr to sorted values. typedef struct { mz_uint16 m_key, m_sym_index; } tdefl_sym_freq; static tdefl_sym_freq* tdefl_radix_sort_syms(mz_uint num_syms, tdefl_sym_freq* pSyms0, tdefl_sym_freq* pSyms1) { mz_uint32 total_passes = 2, pass_shift, pass, i, hist[256 * 2]; tdefl_sym_freq* pCur_syms = pSyms0, *pNew_syms = pSyms1; MZ_CLEAR_OBJ(hist); for (i = 0; i < num_syms; i++) { mz_uint freq = pSyms0[i].m_key; hist[freq & 0xFF]++; hist[256 + ((freq >> 8) & 0xFF)]++; } while ((total_passes > 1) && (num_syms == hist[(total_passes - 1) * 256])) total_passes--; for (pass_shift = 0, pass = 0; pass < total_passes; pass++, pass_shift += 8) { const mz_uint32* pHist = &hist[pass << 8]; mz_uint offsets[256], cur_ofs = 0; for (i = 0; i < 256; i++) { offsets[i] = cur_ofs; cur_ofs += pHist[i]; } for (i = 0; i < num_syms; i++) pNew_syms[offsets[(pCur_syms[i].m_key >> pass_shift) & 0xFF]++] = pCur_syms[i]; { tdefl_sym_freq* t = pCur_syms; pCur_syms = pNew_syms; pNew_syms = t; } } return pCur_syms; } // tdefl_calculate_minimum_redundancy() originally written by: Alistair Moffat, alistair@cs.mu.oz.au, Jyrki Katajainen, jyrki@diku.dk, November 1996. static void tdefl_calculate_minimum_redundancy(tdefl_sym_freq *A, int n) { int root, leaf, next, avbl, used, dpth; if (n==0) return; else if (n==1) { A[0].m_key = 1; return; } A[0].m_key += A[1].m_key; root = 0; leaf = 2; for (next=1; next < n-1; next++) { if (leaf>=n || A[root].m_key=n || (root=0; next--) A[next].m_key = A[A[next].m_key].m_key+1; avbl = 1; used = dpth = 0; root = n-2; next = n-1; while (avbl>0) { while (root>=0 && (int)A[root].m_key==dpth) { used++; root--; } while (avbl>used) { A[next--].m_key = (mz_uint16)(dpth); avbl--; } avbl = 2*used; dpth++; used = 0; } } // Limits canonical Huffman code table's max code size. enum { TDEFL_MAX_SUPPORTED_HUFF_CODESIZE = 32 }; static void tdefl_huffman_enforce_max_code_size(int *pNum_codes, int code_list_len, int max_code_size) { int i; mz_uint32 total = 0; if (code_list_len <= 1) return; for (i = max_code_size + 1; i <= TDEFL_MAX_SUPPORTED_HUFF_CODESIZE; i++) pNum_codes[max_code_size] += pNum_codes[i]; for (i = max_code_size; i > 0; i--) total += (((mz_uint32)pNum_codes[i]) << (max_code_size - i)); while (total != (1UL << max_code_size)) { pNum_codes[max_code_size]--; for (i = max_code_size - 1; i > 0; i--) if (pNum_codes[i]) { pNum_codes[i]--; pNum_codes[i + 1] += 2; break; } total--; } } static void tdefl_optimize_huffman_table(tdefl_compressor *d, int table_num, int table_len, int code_size_limit, int static_table) { int i, j, l, num_codes[1 + TDEFL_MAX_SUPPORTED_HUFF_CODESIZE]; mz_uint next_code[TDEFL_MAX_SUPPORTED_HUFF_CODESIZE + 1]; MZ_CLEAR_OBJ(num_codes); if (static_table) { for (i = 0; i < table_len; i++) num_codes[d->m_huff_code_sizes[table_num][i]]++; } else { tdefl_sym_freq syms0[TDEFL_MAX_HUFF_SYMBOLS], syms1[TDEFL_MAX_HUFF_SYMBOLS], *pSyms; int num_used_syms = 0; const mz_uint16 *pSym_count = &d->m_huff_count[table_num][0]; for (i = 0; i < table_len; i++) if (pSym_count[i]) { syms0[num_used_syms].m_key = (mz_uint16)pSym_count[i]; syms0[num_used_syms++].m_sym_index = (mz_uint16)i; } pSyms = tdefl_radix_sort_syms(num_used_syms, syms0, syms1); tdefl_calculate_minimum_redundancy(pSyms, num_used_syms); for (i = 0; i < num_used_syms; i++) num_codes[pSyms[i].m_key]++; tdefl_huffman_enforce_max_code_size(num_codes, num_used_syms, code_size_limit); MZ_CLEAR_OBJ(d->m_huff_code_sizes[table_num]); MZ_CLEAR_OBJ(d->m_huff_codes[table_num]); for (i = 1, j = num_used_syms; i <= code_size_limit; i++) for (l = num_codes[i]; l > 0; l--) d->m_huff_code_sizes[table_num][pSyms[--j].m_sym_index] = (mz_uint8)(i); } next_code[1] = 0; for (j = 0, i = 2; i <= code_size_limit; i++) next_code[i] = j = ((j + num_codes[i - 1]) << 1); for (i = 0; i < table_len; i++) { mz_uint rev_code = 0, code, code_size; if ((code_size = d->m_huff_code_sizes[table_num][i]) == 0) continue; code = next_code[code_size]++; for (l = code_size; l > 0; l--, code >>= 1) rev_code = (rev_code << 1) | (code & 1); d->m_huff_codes[table_num][i] = (mz_uint16)rev_code; } } #define TDEFL_PUT_BITS(b, l) do { \ mz_uint bits = b; mz_uint len = l; MZ_ASSERT(bits <= ((1U << len) - 1U)); \ d->m_bit_buffer |= (bits << d->m_bits_in); d->m_bits_in += len; \ while (d->m_bits_in >= 8) { \ if (d->m_pOutput_buf < d->m_pOutput_buf_end) \ *d->m_pOutput_buf++ = (mz_uint8)(d->m_bit_buffer); \ d->m_bit_buffer >>= 8; \ d->m_bits_in -= 8; \ } \ } MZ_MACRO_END #define TDEFL_RLE_PREV_CODE_SIZE() { if (rle_repeat_count) { \ if (rle_repeat_count < 3) { \ d->m_huff_count[2][prev_code_size] = (mz_uint16)(d->m_huff_count[2][prev_code_size] + rle_repeat_count); \ while (rle_repeat_count--) packed_code_sizes[num_packed_code_sizes++] = prev_code_size; \ } else { \ d->m_huff_count[2][16] = (mz_uint16)(d->m_huff_count[2][16] + 1); packed_code_sizes[num_packed_code_sizes++] = 16; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_repeat_count - 3); \ } rle_repeat_count = 0; } } #define TDEFL_RLE_ZERO_CODE_SIZE() { if (rle_z_count) { \ if (rle_z_count < 3) { \ d->m_huff_count[2][0] = (mz_uint16)(d->m_huff_count[2][0] + rle_z_count); while (rle_z_count--) packed_code_sizes[num_packed_code_sizes++] = 0; \ } else if (rle_z_count <= 10) { \ d->m_huff_count[2][17] = (mz_uint16)(d->m_huff_count[2][17] + 1); packed_code_sizes[num_packed_code_sizes++] = 17; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 3); \ } else { \ d->m_huff_count[2][18] = (mz_uint16)(d->m_huff_count[2][18] + 1); packed_code_sizes[num_packed_code_sizes++] = 18; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 11); \ } rle_z_count = 0; } } static mz_uint8 s_tdefl_packed_code_size_syms_swizzle[] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; static void tdefl_start_dynamic_block(tdefl_compressor *d) { int num_lit_codes, num_dist_codes, num_bit_lengths; mz_uint i, total_code_sizes_to_pack, num_packed_code_sizes, rle_z_count, rle_repeat_count, packed_code_sizes_index; mz_uint8 code_sizes_to_pack[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], packed_code_sizes[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], prev_code_size = 0xFF; d->m_huff_count[0][256] = 1; tdefl_optimize_huffman_table(d, 0, TDEFL_MAX_HUFF_SYMBOLS_0, 15, MZ_FALSE); tdefl_optimize_huffman_table(d, 1, TDEFL_MAX_HUFF_SYMBOLS_1, 15, MZ_FALSE); for (num_lit_codes = 286; num_lit_codes > 257; num_lit_codes--) if (d->m_huff_code_sizes[0][num_lit_codes - 1]) break; for (num_dist_codes = 30; num_dist_codes > 1; num_dist_codes--) if (d->m_huff_code_sizes[1][num_dist_codes - 1]) break; memcpy(code_sizes_to_pack, &d->m_huff_code_sizes[0][0], num_lit_codes); memcpy(code_sizes_to_pack + num_lit_codes, &d->m_huff_code_sizes[1][0], num_dist_codes); total_code_sizes_to_pack = num_lit_codes + num_dist_codes; num_packed_code_sizes = 0; rle_z_count = 0; rle_repeat_count = 0; memset(&d->m_huff_count[2][0], 0, sizeof(d->m_huff_count[2][0]) * TDEFL_MAX_HUFF_SYMBOLS_2); for (i = 0; i < total_code_sizes_to_pack; i++) { mz_uint8 code_size = code_sizes_to_pack[i]; if (!code_size) { TDEFL_RLE_PREV_CODE_SIZE(); if (++rle_z_count == 138) { TDEFL_RLE_ZERO_CODE_SIZE(); } } else { TDEFL_RLE_ZERO_CODE_SIZE(); if (code_size != prev_code_size) { TDEFL_RLE_PREV_CODE_SIZE(); d->m_huff_count[2][code_size] = (mz_uint16)(d->m_huff_count[2][code_size] + 1); packed_code_sizes[num_packed_code_sizes++] = code_size; } else if (++rle_repeat_count == 6) { TDEFL_RLE_PREV_CODE_SIZE(); } } prev_code_size = code_size; } if (rle_repeat_count) { TDEFL_RLE_PREV_CODE_SIZE(); } else { TDEFL_RLE_ZERO_CODE_SIZE(); } tdefl_optimize_huffman_table(d, 2, TDEFL_MAX_HUFF_SYMBOLS_2, 7, MZ_FALSE); TDEFL_PUT_BITS(2, 2); TDEFL_PUT_BITS(num_lit_codes - 257, 5); TDEFL_PUT_BITS(num_dist_codes - 1, 5); for (num_bit_lengths = 18; num_bit_lengths >= 0; num_bit_lengths--) if (d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[num_bit_lengths]]) break; num_bit_lengths = MZ_MAX(4, (num_bit_lengths + 1)); TDEFL_PUT_BITS(num_bit_lengths - 4, 4); for (i = 0; (int)i < num_bit_lengths; i++) TDEFL_PUT_BITS(d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[i]], 3); for (packed_code_sizes_index = 0; packed_code_sizes_index < num_packed_code_sizes; ) { mz_uint code = packed_code_sizes[packed_code_sizes_index++]; MZ_ASSERT(code < TDEFL_MAX_HUFF_SYMBOLS_2); TDEFL_PUT_BITS(d->m_huff_codes[2][code], d->m_huff_code_sizes[2][code]); if (code >= 16) TDEFL_PUT_BITS(packed_code_sizes[packed_code_sizes_index++], "\02\03\07"[code - 16]); } } static void tdefl_start_static_block(tdefl_compressor *d) { mz_uint i; mz_uint8 *p = &d->m_huff_code_sizes[0][0]; for (i = 0; i <= 143; ++i) *p++ = 8; for ( ; i <= 255; ++i) *p++ = 9; for ( ; i <= 279; ++i) *p++ = 7; for ( ; i <= 287; ++i) *p++ = 8; memset(d->m_huff_code_sizes[1], 5, 32); tdefl_optimize_huffman_table(d, 0, 288, 15, MZ_TRUE); tdefl_optimize_huffman_table(d, 1, 32, 15, MZ_TRUE); TDEFL_PUT_BITS(1, 2); } static const mz_uint mz_bitmasks[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF }; #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) { mz_uint flags; mz_uint8 *pLZ_codes; mz_uint8 *pOutput_buf = d->m_pOutput_buf; mz_uint8 *pLZ_code_buf_end = d->m_pLZ_code_buf; mz_uint64 bit_buffer = d->m_bit_buffer; mz_uint bits_in = d->m_bits_in; #define TDEFL_PUT_BITS_FAST(b, l) { bit_buffer |= (((mz_uint64)(b)) << bits_in); bits_in += (l); } flags = 1; for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < pLZ_code_buf_end; flags >>= 1) { if (flags == 1) flags = *pLZ_codes++ | 0x100; if (flags & 1) { mz_uint s0, s1, n0, n1, sym, num_extra_bits; mz_uint match_len = pLZ_codes[0], match_dist = *(const mz_uint16 *)(pLZ_codes + 1); pLZ_codes += 3; MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); TDEFL_PUT_BITS_FAST(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]); // This sequence coaxes MSVC into using cmov's vs. jmp's. s0 = s_tdefl_small_dist_sym[match_dist & 511]; n0 = s_tdefl_small_dist_extra[match_dist & 511]; s1 = s_tdefl_large_dist_sym[match_dist >> 8]; n1 = s_tdefl_large_dist_extra[match_dist >> 8]; sym = (match_dist < 512) ? s0 : s1; num_extra_bits = (match_dist < 512) ? n0 : n1; MZ_ASSERT(d->m_huff_code_sizes[1][sym]); TDEFL_PUT_BITS_FAST(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]); TDEFL_PUT_BITS_FAST(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits); } else { mz_uint lit = *pLZ_codes++; MZ_ASSERT(d->m_huff_code_sizes[0][lit]); TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) { flags >>= 1; lit = *pLZ_codes++; MZ_ASSERT(d->m_huff_code_sizes[0][lit]); TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) { flags >>= 1; lit = *pLZ_codes++; MZ_ASSERT(d->m_huff_code_sizes[0][lit]); TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); } } } if (pOutput_buf >= d->m_pOutput_buf_end) return MZ_FALSE; *(mz_uint64*)pOutput_buf = bit_buffer; pOutput_buf += (bits_in >> 3); bit_buffer >>= (bits_in & ~7); bits_in &= 7; } #undef TDEFL_PUT_BITS_FAST d->m_pOutput_buf = pOutput_buf; d->m_bits_in = 0; d->m_bit_buffer = 0; while (bits_in) { mz_uint32 n = MZ_MIN(bits_in, 16); TDEFL_PUT_BITS((mz_uint)bit_buffer & mz_bitmasks[n], n); bit_buffer >>= n; bits_in -= n; } TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]); return (d->m_pOutput_buf < d->m_pOutput_buf_end); } #else static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) { mz_uint flags; mz_uint8 *pLZ_codes; flags = 1; for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < d->m_pLZ_code_buf; flags >>= 1) { if (flags == 1) flags = *pLZ_codes++ | 0x100; if (flags & 1) { mz_uint sym, num_extra_bits; mz_uint match_len = pLZ_codes[0], match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8)); pLZ_codes += 3; MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); TDEFL_PUT_BITS(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); TDEFL_PUT_BITS(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]); if (match_dist < 512) { sym = s_tdefl_small_dist_sym[match_dist]; num_extra_bits = s_tdefl_small_dist_extra[match_dist]; } else { sym = s_tdefl_large_dist_sym[match_dist >> 8]; num_extra_bits = s_tdefl_large_dist_extra[match_dist >> 8]; } MZ_ASSERT(d->m_huff_code_sizes[1][sym]); TDEFL_PUT_BITS(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]); TDEFL_PUT_BITS(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits); } else { mz_uint lit = *pLZ_codes++; MZ_ASSERT(d->m_huff_code_sizes[0][lit]); TDEFL_PUT_BITS(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); } } TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]); return (d->m_pOutput_buf < d->m_pOutput_buf_end); } #endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS static mz_bool tdefl_compress_block(tdefl_compressor *d, mz_bool static_block) { if (static_block) tdefl_start_static_block(d); else tdefl_start_dynamic_block(d); return tdefl_compress_lz_codes(d); } static int tdefl_flush_block(tdefl_compressor *d, int flush) { mz_uint saved_bit_buf, saved_bits_in; mz_uint8 *pSaved_output_buf; mz_bool comp_block_succeeded = MZ_FALSE; int n, use_raw_block = ((d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS) != 0) && (d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size; mz_uint8 *pOutput_buf_start = ((d->m_pPut_buf_func == NULL) && ((*d->m_pOut_buf_size - d->m_out_buf_ofs) >= TDEFL_OUT_BUF_SIZE)) ? ((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs) : d->m_output_buf; d->m_pOutput_buf = pOutput_buf_start; d->m_pOutput_buf_end = d->m_pOutput_buf + TDEFL_OUT_BUF_SIZE - 16; MZ_ASSERT(!d->m_output_flush_remaining); d->m_output_flush_ofs = 0; d->m_output_flush_remaining = 0; *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> d->m_num_flags_left); d->m_pLZ_code_buf -= (d->m_num_flags_left == 8); if ((d->m_flags & TDEFL_WRITE_ZLIB_HEADER) && (!d->m_block_index)) { TDEFL_PUT_BITS(0x78, 8); TDEFL_PUT_BITS(0x01, 8); } TDEFL_PUT_BITS(flush == TDEFL_FINISH, 1); pSaved_output_buf = d->m_pOutput_buf; saved_bit_buf = d->m_bit_buffer; saved_bits_in = d->m_bits_in; if (!use_raw_block) comp_block_succeeded = tdefl_compress_block(d, (d->m_flags & TDEFL_FORCE_ALL_STATIC_BLOCKS) || (d->m_total_lz_bytes < 48)); // If the block gets expanded, forget the current contents of the output buffer and send a raw block instead. if ( ((use_raw_block) || ((d->m_total_lz_bytes) && ((d->m_pOutput_buf - pSaved_output_buf + 1U) >= d->m_total_lz_bytes))) && ((d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size) ) { mz_uint i; d->m_pOutput_buf = pSaved_output_buf; d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in; TDEFL_PUT_BITS(0, 2); if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } for (i = 2; i; --i, d->m_total_lz_bytes ^= 0xFFFF) { TDEFL_PUT_BITS(d->m_total_lz_bytes & 0xFFFF, 16); } for (i = 0; i < d->m_total_lz_bytes; ++i) { TDEFL_PUT_BITS(d->m_dict[(d->m_lz_code_buf_dict_pos + i) & TDEFL_LZ_DICT_SIZE_MASK], 8); } } // Check for the extremely unlikely (if not impossible) case of the compressed block not fitting into the output buffer when using dynamic codes. else if (!comp_block_succeeded) { d->m_pOutput_buf = pSaved_output_buf; d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in; tdefl_compress_block(d, MZ_TRUE); } if (flush) { if (flush == TDEFL_FINISH) { if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } if (d->m_flags & TDEFL_WRITE_ZLIB_HEADER) { mz_uint i, a = d->m_adler32; for (i = 0; i < 4; i++) { TDEFL_PUT_BITS((a >> 24) & 0xFF, 8); a <<= 8; } } } else { mz_uint i, z = 0; TDEFL_PUT_BITS(0, 3); if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } for (i = 2; i; --i, z ^= 0xFFFF) { TDEFL_PUT_BITS(z & 0xFFFF, 16); } } } MZ_ASSERT(d->m_pOutput_buf < d->m_pOutput_buf_end); memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0); memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1); d->m_pLZ_code_buf = d->m_lz_code_buf + 1; d->m_pLZ_flags = d->m_lz_code_buf; d->m_num_flags_left = 8; d->m_lz_code_buf_dict_pos += d->m_total_lz_bytes; d->m_total_lz_bytes = 0; d->m_block_index++; if ((n = (int)(d->m_pOutput_buf - pOutput_buf_start)) != 0) { if (d->m_pPut_buf_func) { *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf; if (!(*d->m_pPut_buf_func)(d->m_output_buf, n, d->m_pPut_buf_user)) return (d->m_prev_return_status = TDEFL_STATUS_PUT_BUF_FAILED); } else if (pOutput_buf_start == d->m_output_buf) { int bytes_to_copy = (int)MZ_MIN((size_t)n, (size_t)(*d->m_pOut_buf_size - d->m_out_buf_ofs)); memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf, bytes_to_copy); d->m_out_buf_ofs += bytes_to_copy; if ((n -= bytes_to_copy) != 0) { d->m_output_flush_ofs = bytes_to_copy; d->m_output_flush_remaining = n; } } else { d->m_out_buf_ofs += n; } } return d->m_output_flush_remaining; } #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES #define TDEFL_READ_UNALIGNED_WORD(p) *(const mz_uint16*)(p) static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) { mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len; mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; const mz_uint16 *s = (const mz_uint16*)(d->m_dict + pos), *p, *q; mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]), s01 = TDEFL_READ_UNALIGNED_WORD(s); MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); if (max_match_len <= match_len) return; for ( ; ; ) { for ( ; ; ) { if (--num_probes_left == 0) return; #define TDEFL_PROBE \ next_probe_pos = d->m_next[probe_pos]; \ if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) return; \ probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \ if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) break; TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE; } if (!dist) break; q = (const mz_uint16*)(d->m_dict + probe_pos); if (TDEFL_READ_UNALIGNED_WORD(q) != s01) continue; p = s; probe_len = 32; do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) ); if (!probe_len) { *pMatch_dist = dist; *pMatch_len = MZ_MIN(max_match_len, TDEFL_MAX_MATCH_LEN); break; } else if ((probe_len = ((mz_uint)(p - s) * 2) + (mz_uint)(*(const mz_uint8*)p == *(const mz_uint8*)q)) > match_len) { *pMatch_dist = dist; if ((*pMatch_len = match_len = MZ_MIN(max_match_len, probe_len)) == max_match_len) break; c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]); } } } #else static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) { mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len; mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; const mz_uint8 *s = d->m_dict + pos, *p, *q; mz_uint8 c0 = d->m_dict[pos + match_len], c1 = d->m_dict[pos + match_len - 1]; MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); if (max_match_len <= match_len) return; for ( ; ; ) { for ( ; ; ) { if (--num_probes_left == 0) return; #define TDEFL_PROBE \ next_probe_pos = d->m_next[probe_pos]; \ if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) return; \ probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \ if ((d->m_dict[probe_pos + match_len] == c0) && (d->m_dict[probe_pos + match_len - 1] == c1)) break; TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE; } if (!dist) break; p = s; q = d->m_dict + probe_pos; for (probe_len = 0; probe_len < max_match_len; probe_len++) if (*p++ != *q++) break; if (probe_len > match_len) { *pMatch_dist = dist; if ((*pMatch_len = match_len = probe_len) == max_match_len) return; c0 = d->m_dict[pos + match_len]; c1 = d->m_dict[pos + match_len - 1]; } } } #endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN static mz_bool tdefl_compress_fast(tdefl_compressor *d) { // Faster, minimally featured LZRW1-style match+parse loop with better register utilization. Intended for applications where raw throughput is valued more highly than ratio. mz_uint lookahead_pos = d->m_lookahead_pos, lookahead_size = d->m_lookahead_size, dict_size = d->m_dict_size, total_lz_bytes = d->m_total_lz_bytes, num_flags_left = d->m_num_flags_left; mz_uint8 *pLZ_code_buf = d->m_pLZ_code_buf, *pLZ_flags = d->m_pLZ_flags; mz_uint cur_pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK; while ((d->m_src_buf_left) || ((d->m_flush) && (lookahead_size))) { const mz_uint TDEFL_COMP_FAST_LOOKAHEAD_SIZE = 4096; mz_uint dst_pos = (lookahead_pos + lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK; mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(d->m_src_buf_left, TDEFL_COMP_FAST_LOOKAHEAD_SIZE - lookahead_size); d->m_src_buf_left -= num_bytes_to_process; lookahead_size += num_bytes_to_process; while (num_bytes_to_process) { mz_uint32 n = MZ_MIN(TDEFL_LZ_DICT_SIZE - dst_pos, num_bytes_to_process); memcpy(d->m_dict + dst_pos, d->m_pSrc, n); if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) memcpy(d->m_dict + TDEFL_LZ_DICT_SIZE + dst_pos, d->m_pSrc, MZ_MIN(n, (TDEFL_MAX_MATCH_LEN - 1) - dst_pos)); d->m_pSrc += n; dst_pos = (dst_pos + n) & TDEFL_LZ_DICT_SIZE_MASK; num_bytes_to_process -= n; } dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - lookahead_size, dict_size); if ((!d->m_flush) && (lookahead_size < TDEFL_COMP_FAST_LOOKAHEAD_SIZE)) break; while (lookahead_size >= 4) { mz_uint cur_match_dist, cur_match_len = 1; mz_uint8 *pCur_dict = d->m_dict + cur_pos; mz_uint first_trigram = (*(const mz_uint32 *)pCur_dict) & 0xFFFFFF; mz_uint hash = (first_trigram ^ (first_trigram >> (24 - (TDEFL_LZ_HASH_BITS - 8)))) & TDEFL_LEVEL1_HASH_SIZE_MASK; mz_uint probe_pos = d->m_hash[hash]; d->m_hash[hash] = (mz_uint16)lookahead_pos; if (((cur_match_dist = (mz_uint16)(lookahead_pos - probe_pos)) <= dict_size) && ((*(const mz_uint32 *)(d->m_dict + (probe_pos &= TDEFL_LZ_DICT_SIZE_MASK)) & 0xFFFFFF) == first_trigram)) { const mz_uint16 *p = (const mz_uint16 *)pCur_dict; const mz_uint16 *q = (const mz_uint16 *)(d->m_dict + probe_pos); mz_uint32 probe_len = 32; do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) ); cur_match_len = ((mz_uint)(p - (const mz_uint16 *)pCur_dict) * 2) + (mz_uint)(*(const mz_uint8 *)p == *(const mz_uint8 *)q); if (!probe_len) cur_match_len = cur_match_dist ? TDEFL_MAX_MATCH_LEN : 0; if ((cur_match_len < TDEFL_MIN_MATCH_LEN) || ((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U*1024U))) { cur_match_len = 1; *pLZ_code_buf++ = (mz_uint8)first_trigram; *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); d->m_huff_count[0][(mz_uint8)first_trigram]++; } else { mz_uint32 s0, s1; cur_match_len = MZ_MIN(cur_match_len, lookahead_size); MZ_ASSERT((cur_match_len >= TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 1) && (cur_match_dist <= TDEFL_LZ_DICT_SIZE)); cur_match_dist--; pLZ_code_buf[0] = (mz_uint8)(cur_match_len - TDEFL_MIN_MATCH_LEN); *(mz_uint16 *)(&pLZ_code_buf[1]) = (mz_uint16)cur_match_dist; pLZ_code_buf += 3; *pLZ_flags = (mz_uint8)((*pLZ_flags >> 1) | 0x80); s0 = s_tdefl_small_dist_sym[cur_match_dist & 511]; s1 = s_tdefl_large_dist_sym[cur_match_dist >> 8]; d->m_huff_count[1][(cur_match_dist < 512) ? s0 : s1]++; d->m_huff_count[0][s_tdefl_len_sym[cur_match_len - TDEFL_MIN_MATCH_LEN]]++; } } else { *pLZ_code_buf++ = (mz_uint8)first_trigram; *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); d->m_huff_count[0][(mz_uint8)first_trigram]++; } if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; } total_lz_bytes += cur_match_len; lookahead_pos += cur_match_len; dict_size = MZ_MIN(dict_size + cur_match_len, TDEFL_LZ_DICT_SIZE); cur_pos = (cur_pos + cur_match_len) & TDEFL_LZ_DICT_SIZE_MASK; MZ_ASSERT(lookahead_size >= cur_match_len); lookahead_size -= cur_match_len; if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) { int n; d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size; d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left; if ((n = tdefl_flush_block(d, 0)) != 0) return (n < 0) ? MZ_FALSE : MZ_TRUE; total_lz_bytes = d->m_total_lz_bytes; pLZ_code_buf = d->m_pLZ_code_buf; pLZ_flags = d->m_pLZ_flags; num_flags_left = d->m_num_flags_left; } } while (lookahead_size) { mz_uint8 lit = d->m_dict[cur_pos]; total_lz_bytes++; *pLZ_code_buf++ = lit; *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; } d->m_huff_count[0][lit]++; lookahead_pos++; dict_size = MZ_MIN(dict_size + 1, TDEFL_LZ_DICT_SIZE); cur_pos = (cur_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK; lookahead_size--; if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) { int n; d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size; d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left; if ((n = tdefl_flush_block(d, 0)) != 0) return (n < 0) ? MZ_FALSE : MZ_TRUE; total_lz_bytes = d->m_total_lz_bytes; pLZ_code_buf = d->m_pLZ_code_buf; pLZ_flags = d->m_pLZ_flags; num_flags_left = d->m_num_flags_left; } } } d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size; d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left; return MZ_TRUE; } #endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN static MZ_FORCEINLINE void tdefl_record_literal(tdefl_compressor *d, mz_uint8 lit) { d->m_total_lz_bytes++; *d->m_pLZ_code_buf++ = lit; *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> 1); if (--d->m_num_flags_left == 0) { d->m_num_flags_left = 8; d->m_pLZ_flags = d->m_pLZ_code_buf++; } d->m_huff_count[0][lit]++; } static MZ_FORCEINLINE void tdefl_record_match(tdefl_compressor *d, mz_uint match_len, mz_uint match_dist) { mz_uint32 s0, s1; MZ_ASSERT((match_len >= TDEFL_MIN_MATCH_LEN) && (match_dist >= 1) && (match_dist <= TDEFL_LZ_DICT_SIZE)); d->m_total_lz_bytes += match_len; d->m_pLZ_code_buf[0] = (mz_uint8)(match_len - TDEFL_MIN_MATCH_LEN); match_dist -= 1; d->m_pLZ_code_buf[1] = (mz_uint8)(match_dist & 0xFF); d->m_pLZ_code_buf[2] = (mz_uint8)(match_dist >> 8); d->m_pLZ_code_buf += 3; *d->m_pLZ_flags = (mz_uint8)((*d->m_pLZ_flags >> 1) | 0x80); if (--d->m_num_flags_left == 0) { d->m_num_flags_left = 8; d->m_pLZ_flags = d->m_pLZ_code_buf++; } s0 = s_tdefl_small_dist_sym[match_dist & 511]; s1 = s_tdefl_large_dist_sym[(match_dist >> 8) & 127]; d->m_huff_count[1][(match_dist < 512) ? s0 : s1]++; if (match_len >= TDEFL_MIN_MATCH_LEN) d->m_huff_count[0][s_tdefl_len_sym[match_len - TDEFL_MIN_MATCH_LEN]]++; } static mz_bool tdefl_compress_normal(tdefl_compressor *d) { const mz_uint8 *pSrc = d->m_pSrc; size_t src_buf_left = d->m_src_buf_left; tdefl_flush flush = d->m_flush; while ((src_buf_left) || ((flush) && (d->m_lookahead_size))) { mz_uint len_to_move, cur_match_dist, cur_match_len, cur_pos; // Update dictionary and hash chains. Keeps the lookahead size equal to TDEFL_MAX_MATCH_LEN. if ((d->m_lookahead_size + d->m_dict_size) >= (TDEFL_MIN_MATCH_LEN - 1)) { mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK, ins_pos = d->m_lookahead_pos + d->m_lookahead_size - 2; mz_uint hash = (d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK]; mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(src_buf_left, TDEFL_MAX_MATCH_LEN - d->m_lookahead_size); const mz_uint8 *pSrc_end = pSrc + num_bytes_to_process; src_buf_left -= num_bytes_to_process; d->m_lookahead_size += num_bytes_to_process; while (pSrc != pSrc_end) { mz_uint8 c = *pSrc++; d->m_dict[dst_pos] = c; if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c; hash = ((hash << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1); d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash]; d->m_hash[hash] = (mz_uint16)(ins_pos); dst_pos = (dst_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK; ins_pos++; } } else { while ((src_buf_left) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN)) { mz_uint8 c = *pSrc++; mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK; src_buf_left--; d->m_dict[dst_pos] = c; if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c; if ((++d->m_lookahead_size + d->m_dict_size) >= TDEFL_MIN_MATCH_LEN) { mz_uint ins_pos = d->m_lookahead_pos + (d->m_lookahead_size - 1) - 2; mz_uint hash = ((d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << (TDEFL_LZ_HASH_SHIFT * 2)) ^ (d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1); d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash]; d->m_hash[hash] = (mz_uint16)(ins_pos); } } } d->m_dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - d->m_lookahead_size, d->m_dict_size); if ((!flush) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN)) break; // Simple lazy/greedy parsing state machine. len_to_move = 1; cur_match_dist = 0; cur_match_len = d->m_saved_match_len ? d->m_saved_match_len : (TDEFL_MIN_MATCH_LEN - 1); cur_pos = d->m_lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK; if (d->m_flags & (TDEFL_RLE_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS)) { if ((d->m_dict_size) && (!(d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS))) { mz_uint8 c = d->m_dict[(cur_pos - 1) & TDEFL_LZ_DICT_SIZE_MASK]; cur_match_len = 0; while (cur_match_len < d->m_lookahead_size) { if (d->m_dict[cur_pos + cur_match_len] != c) break; cur_match_len++; } if (cur_match_len < TDEFL_MIN_MATCH_LEN) cur_match_len = 0; else cur_match_dist = 1; } } else { tdefl_find_match(d, d->m_lookahead_pos, d->m_dict_size, d->m_lookahead_size, &cur_match_dist, &cur_match_len); } if (((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U*1024U)) || (cur_pos == cur_match_dist) || ((d->m_flags & TDEFL_FILTER_MATCHES) && (cur_match_len <= 5))) { cur_match_dist = cur_match_len = 0; } if (d->m_saved_match_len) { if (cur_match_len > d->m_saved_match_len) { tdefl_record_literal(d, (mz_uint8)d->m_saved_lit); if (cur_match_len >= 128) { tdefl_record_match(d, cur_match_len, cur_match_dist); d->m_saved_match_len = 0; len_to_move = cur_match_len; } else { d->m_saved_lit = d->m_dict[cur_pos]; d->m_saved_match_dist = cur_match_dist; d->m_saved_match_len = cur_match_len; } } else { tdefl_record_match(d, d->m_saved_match_len, d->m_saved_match_dist); len_to_move = d->m_saved_match_len - 1; d->m_saved_match_len = 0; } } else if (!cur_match_dist) tdefl_record_literal(d, d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]); else if ((d->m_greedy_parsing) || (d->m_flags & TDEFL_RLE_MATCHES) || (cur_match_len >= 128)) { tdefl_record_match(d, cur_match_len, cur_match_dist); len_to_move = cur_match_len; } else { d->m_saved_lit = d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]; d->m_saved_match_dist = cur_match_dist; d->m_saved_match_len = cur_match_len; } // Move the lookahead forward by len_to_move bytes. d->m_lookahead_pos += len_to_move; MZ_ASSERT(d->m_lookahead_size >= len_to_move); d->m_lookahead_size -= len_to_move; d->m_dict_size = MZ_MIN(d->m_dict_size + len_to_move, TDEFL_LZ_DICT_SIZE); // Check if it's time to flush the current LZ codes to the internal output buffer. if ( (d->m_pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) || ( (d->m_total_lz_bytes > 31*1024) && (((((mz_uint)(d->m_pLZ_code_buf - d->m_lz_code_buf) * 115) >> 7) >= d->m_total_lz_bytes) || (d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS))) ) { int n; d->m_pSrc = pSrc; d->m_src_buf_left = src_buf_left; if ((n = tdefl_flush_block(d, 0)) != 0) return (n < 0) ? MZ_FALSE : MZ_TRUE; } } d->m_pSrc = pSrc; d->m_src_buf_left = src_buf_left; return MZ_TRUE; } static tdefl_status tdefl_flush_output_buffer(tdefl_compressor *d) { if (d->m_pIn_buf_size) { *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf; } if (d->m_pOut_buf_size) { size_t n = MZ_MIN(*d->m_pOut_buf_size - d->m_out_buf_ofs, d->m_output_flush_remaining); memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf + d->m_output_flush_ofs, n); d->m_output_flush_ofs += (mz_uint)n; d->m_output_flush_remaining -= (mz_uint)n; d->m_out_buf_ofs += n; *d->m_pOut_buf_size = d->m_out_buf_ofs; } return (d->m_finished && !d->m_output_flush_remaining) ? TDEFL_STATUS_DONE : TDEFL_STATUS_OKAY; } tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush) { if (!d) { if (pIn_buf_size) *pIn_buf_size = 0; if (pOut_buf_size) *pOut_buf_size = 0; return TDEFL_STATUS_BAD_PARAM; } d->m_pIn_buf = pIn_buf; d->m_pIn_buf_size = pIn_buf_size; d->m_pOut_buf = pOut_buf; d->m_pOut_buf_size = pOut_buf_size; d->m_pSrc = (const mz_uint8 *)(pIn_buf); d->m_src_buf_left = pIn_buf_size ? *pIn_buf_size : 0; d->m_out_buf_ofs = 0; d->m_flush = flush; if ( ((d->m_pPut_buf_func != NULL) == ((pOut_buf != NULL) || (pOut_buf_size != NULL))) || (d->m_prev_return_status != TDEFL_STATUS_OKAY) || (d->m_wants_to_finish && (flush != TDEFL_FINISH)) || (pIn_buf_size && *pIn_buf_size && !pIn_buf) || (pOut_buf_size && *pOut_buf_size && !pOut_buf) ) { if (pIn_buf_size) *pIn_buf_size = 0; if (pOut_buf_size) *pOut_buf_size = 0; return (d->m_prev_return_status = TDEFL_STATUS_BAD_PARAM); } d->m_wants_to_finish |= (flush == TDEFL_FINISH); if ((d->m_output_flush_remaining) || (d->m_finished)) return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN if (((d->m_flags & TDEFL_MAX_PROBES_MASK) == 1) && ((d->m_flags & TDEFL_GREEDY_PARSING_FLAG) != 0) && ((d->m_flags & (TDEFL_FILTER_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS | TDEFL_RLE_MATCHES)) == 0)) { if (!tdefl_compress_fast(d)) return d->m_prev_return_status; } else #endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN { if (!tdefl_compress_normal(d)) return d->m_prev_return_status; } if ((d->m_flags & (TDEFL_WRITE_ZLIB_HEADER | TDEFL_COMPUTE_ADLER32)) && (pIn_buf)) d->m_adler32 = (mz_uint32)mz_adler32(d->m_adler32, (const mz_uint8 *)pIn_buf, d->m_pSrc - (const mz_uint8 *)pIn_buf); if ((flush) && (!d->m_lookahead_size) && (!d->m_src_buf_left) && (!d->m_output_flush_remaining)) { if (tdefl_flush_block(d, flush) < 0) return d->m_prev_return_status; d->m_finished = (flush == TDEFL_FINISH); if (flush == TDEFL_FULL_FLUSH) { MZ_CLEAR_OBJ(d->m_hash); MZ_CLEAR_OBJ(d->m_next); d->m_dict_size = 0; } } return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); } tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush) { MZ_ASSERT(d->m_pPut_buf_func); return tdefl_compress(d, pIn_buf, &in_buf_size, NULL, NULL, flush); } tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) { d->m_pPut_buf_func = pPut_buf_func; d->m_pPut_buf_user = pPut_buf_user; d->m_flags = (mz_uint)(flags); d->m_max_probes[0] = 1 + ((flags & 0xFFF) + 2) / 3; d->m_greedy_parsing = (flags & TDEFL_GREEDY_PARSING_FLAG) != 0; d->m_max_probes[1] = 1 + (((flags & 0xFFF) >> 2) + 2) / 3; if (!(flags & TDEFL_NONDETERMINISTIC_PARSING_FLAG)) MZ_CLEAR_OBJ(d->m_hash); d->m_lookahead_pos = d->m_lookahead_size = d->m_dict_size = d->m_total_lz_bytes = d->m_lz_code_buf_dict_pos = d->m_bits_in = 0; d->m_output_flush_ofs = d->m_output_flush_remaining = d->m_finished = d->m_block_index = d->m_bit_buffer = d->m_wants_to_finish = 0; d->m_pLZ_code_buf = d->m_lz_code_buf + 1; d->m_pLZ_flags = d->m_lz_code_buf; d->m_num_flags_left = 8; d->m_pOutput_buf = d->m_output_buf; d->m_pOutput_buf_end = d->m_output_buf; d->m_prev_return_status = TDEFL_STATUS_OKAY; d->m_saved_match_dist = d->m_saved_match_len = d->m_saved_lit = 0; d->m_adler32 = 1; d->m_pIn_buf = NULL; d->m_pOut_buf = NULL; d->m_pIn_buf_size = NULL; d->m_pOut_buf_size = NULL; d->m_flush = TDEFL_NO_FLUSH; d->m_pSrc = NULL; d->m_src_buf_left = 0; d->m_out_buf_ofs = 0; memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0); memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1); return TDEFL_STATUS_OKAY; } tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d) { return d->m_prev_return_status; } mz_uint32 tdefl_get_adler32(tdefl_compressor *d) { return d->m_adler32; } mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) { tdefl_compressor *pComp; mz_bool succeeded; if (((buf_len) && (!pBuf)) || (!pPut_buf_func)) return MZ_FALSE; pComp = (tdefl_compressor*)MZ_MALLOC(sizeof(tdefl_compressor)); if (!pComp) return MZ_FALSE; succeeded = (tdefl_init(pComp, pPut_buf_func, pPut_buf_user, flags) == TDEFL_STATUS_OKAY); succeeded = succeeded && (tdefl_compress_buffer(pComp, pBuf, buf_len, TDEFL_FINISH) == TDEFL_STATUS_DONE); MZ_FREE(pComp); return succeeded; } typedef struct { size_t m_size, m_capacity; mz_uint8 *m_pBuf; mz_bool m_expandable; } tdefl_output_buffer; static mz_bool tdefl_output_buffer_putter(const void *pBuf, int len, void *pUser) { tdefl_output_buffer *p = (tdefl_output_buffer *)pUser; size_t new_size = p->m_size + len; if (new_size > p->m_capacity) { size_t new_capacity = p->m_capacity; mz_uint8 *pNew_buf; if (!p->m_expandable) return MZ_FALSE; do { new_capacity = MZ_MAX(128U, new_capacity << 1U); } while (new_size > new_capacity); pNew_buf = (mz_uint8*)MZ_REALLOC(p->m_pBuf, new_capacity); if (!pNew_buf) return MZ_FALSE; p->m_pBuf = pNew_buf; p->m_capacity = new_capacity; } memcpy((mz_uint8*)p->m_pBuf + p->m_size, pBuf, len); p->m_size = new_size; return MZ_TRUE; } void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags) { tdefl_output_buffer out_buf; MZ_CLEAR_OBJ(out_buf); if (!pOut_len) return MZ_FALSE; else *pOut_len = 0; out_buf.m_expandable = MZ_TRUE; if (!tdefl_compress_mem_to_output(pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) return NULL; *pOut_len = out_buf.m_size; return out_buf.m_pBuf; } size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags) { tdefl_output_buffer out_buf; MZ_CLEAR_OBJ(out_buf); if (!pOut_buf) return 0; out_buf.m_pBuf = (mz_uint8*)pOut_buf; out_buf.m_capacity = out_buf_len; if (!tdefl_compress_mem_to_output(pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) return 0; return out_buf.m_size; } #ifndef MINIZ_NO_ZLIB_APIS static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 }; // level may actually range from [0,10] (10 is a "hidden" max level, where we want a bit more compression and it's fine if throughput to fall off a cliff on some files). mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy) { mz_uint comp_flags = s_tdefl_num_probes[(level >= 0) ? MZ_MIN(10, level) : MZ_DEFAULT_LEVEL] | ((level <= 3) ? TDEFL_GREEDY_PARSING_FLAG : 0); if (window_bits > 0) comp_flags |= TDEFL_WRITE_ZLIB_HEADER; if (!level) comp_flags |= TDEFL_FORCE_ALL_RAW_BLOCKS; else if (strategy == MZ_FILTERED) comp_flags |= TDEFL_FILTER_MATCHES; else if (strategy == MZ_HUFFMAN_ONLY) comp_flags &= ~TDEFL_MAX_PROBES_MASK; else if (strategy == MZ_FIXED) comp_flags |= TDEFL_FORCE_ALL_STATIC_BLOCKS; else if (strategy == MZ_RLE) comp_flags |= TDEFL_RLE_MATCHES; return comp_flags; } #endif //MINIZ_NO_ZLIB_APIS #ifdef _MSC_VER #pragma warning (push) #pragma warning (disable:4204) // nonstandard extension used : non-constant aggregate initializer (also supported by GNU C and C99, so no big deal) #endif // Simple PNG writer function by Alex Evans, 2011. Released into the public domain: https://gist.github.com/908299, more context at // http://altdevblogaday.org/2011/04/06/a-smaller-jpg-encoder/. // This is actually a modification of Alex's original code so PNG files generated by this function pass pngcheck. void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip) { // Using a local copy of this array here in case MINIZ_NO_ZLIB_APIS was defined. static const mz_uint s_tdefl_png_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 }; tdefl_compressor *pComp = (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); tdefl_output_buffer out_buf; int i, bpl = w * num_chans, y, z; mz_uint32 c; *pLen_out = 0; if (!pComp) return NULL; MZ_CLEAR_OBJ(out_buf); out_buf.m_expandable = MZ_TRUE; out_buf.m_capacity = 57+MZ_MAX(64, (1+bpl)*h); if (NULL == (out_buf.m_pBuf = (mz_uint8*)MZ_MALLOC(out_buf.m_capacity))) { MZ_FREE(pComp); return NULL; } // write dummy header for (z = 41; z; --z) tdefl_output_buffer_putter(&z, 1, &out_buf); // compress image data tdefl_init(pComp, tdefl_output_buffer_putter, &out_buf, s_tdefl_png_num_probes[MZ_MIN(10, level)] | TDEFL_WRITE_ZLIB_HEADER); for (y = 0; y < h; ++y) { tdefl_compress_buffer(pComp, &z, 1, TDEFL_NO_FLUSH); tdefl_compress_buffer(pComp, (mz_uint8*)pImage + (flip ? (h - 1 - y) : y) * bpl, bpl, TDEFL_NO_FLUSH); } if (tdefl_compress_buffer(pComp, NULL, 0, TDEFL_FINISH) != TDEFL_STATUS_DONE) { MZ_FREE(pComp); MZ_FREE(out_buf.m_pBuf); return NULL; } // write real header *pLen_out = out_buf.m_size-41; { static const mz_uint8 chans[] = {0x00, 0x00, 0x04, 0x02, 0x06}; mz_uint8 pnghdr[41]={0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, 0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8,chans[num_chans],0,0,0,0,0,0,0, (mz_uint8)(*pLen_out>>24),(mz_uint8)(*pLen_out>>16),(mz_uint8)(*pLen_out>>8),(mz_uint8)*pLen_out,0x49,0x44,0x41,0x54}; c=(mz_uint32)mz_crc32(MZ_CRC32_INIT,pnghdr+12,17); for (i=0; i<4; ++i, c<<=8) ((mz_uint8*)(pnghdr+29))[i]=(mz_uint8)(c>>24); memcpy(out_buf.m_pBuf, pnghdr, 41); } // write footer (IDAT CRC-32, followed by IEND chunk) if (!tdefl_output_buffer_putter("\0\0\0\0\0\0\0\0\x49\x45\x4e\x44\xae\x42\x60\x82", 16, &out_buf)) { *pLen_out = 0; MZ_FREE(pComp); MZ_FREE(out_buf.m_pBuf); return NULL; } c = (mz_uint32)mz_crc32(MZ_CRC32_INIT,out_buf.m_pBuf+41-4, *pLen_out+4); for (i=0; i<4; ++i, c<<=8) (out_buf.m_pBuf+out_buf.m_size-16)[i] = (mz_uint8)(c >> 24); // compute final size of file, grab compressed data buffer and return *pLen_out += 57; MZ_FREE(pComp); return out_buf.m_pBuf; } void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out) { // Level 6 corresponds to TDEFL_DEFAULT_MAX_PROBES or MZ_DEFAULT_LEVEL (but we can't depend on MZ_DEFAULT_LEVEL being available in case the zlib API's where #defined out) return tdefl_write_image_to_png_file_in_memory_ex(pImage, w, h, num_chans, pLen_out, 6, MZ_FALSE); } // Allocate the tdefl_compressor and tinfl_decompressor structures in C so that // non-C language bindings to tdefL_ and tinfl_ API don't need to worry about // structure size and allocation mechanism. tdefl_compressor *tdefl_compressor_alloc() { return (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); } void tdefl_compressor_free(tdefl_compressor* pComp) { MZ_FREE(pComp); } tinfl_decompressor *tinfl_decompressor_alloc() { tinfl_decompressor *pDecomp = (tinfl_decompressor *)MZ_MALLOC(sizeof(tinfl_decompressor)); if (pDecomp) tinfl_init(pDecomp); return pDecomp; } void tinfl_decompressor_free(tinfl_decompressor *pDecomp) { MZ_FREE(pDecomp); } #ifdef _MSC_VER #pragma warning (pop) #endif // ------------------- .ZIP archive reading #ifndef MINIZ_NO_ARCHIVE_APIS #ifdef MINIZ_NO_STDIO #define MZ_FILE void * #else #include #include #if defined(_MSC_VER) || defined(__MINGW64__) static FILE *mz_fopen(const char *pFilename, const char *pMode) { FILE* pFile = NULL; fopen_s(&pFile, pFilename, pMode); return pFile; } static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream) { FILE* pFile = NULL; if (freopen_s(&pFile, pPath, pMode, pStream)) return NULL; return pFile; } #ifndef MINIZ_NO_TIME #include #endif #define MZ_FILE FILE #define MZ_FOPEN mz_fopen #define MZ_FCLOSE fclose #define MZ_FREAD fread #define MZ_FWRITE fwrite #define MZ_FTELL64 _ftelli64 #define MZ_FSEEK64 _fseeki64 #define MZ_FILE_STAT_STRUCT _stat #define MZ_FILE_STAT _stat #define MZ_FFLUSH fflush #define MZ_FREOPEN mz_freopen #define MZ_DELETE_FILE remove #elif defined(__MINGW32__) #ifndef MINIZ_NO_TIME #include #endif #define MZ_FILE FILE #define MZ_FOPEN(f, m) fopen(f, m) #define MZ_FCLOSE fclose #define MZ_FREAD fread #define MZ_FWRITE fwrite #define MZ_FTELL64 ftello64 #define MZ_FSEEK64 fseeko64 #define MZ_FILE_STAT_STRUCT _stat #define MZ_FILE_STAT _stat #define MZ_FFLUSH fflush #define MZ_FREOPEN(f, m, s) freopen(f, m, s) #define MZ_DELETE_FILE remove #elif defined(__TINYC__) #ifndef MINIZ_NO_TIME #include #endif #define MZ_FILE FILE #define MZ_FOPEN(f, m) fopen(f, m) #define MZ_FCLOSE fclose #define MZ_FREAD fread #define MZ_FWRITE fwrite #define MZ_FTELL64 ftell #define MZ_FSEEK64 fseek #define MZ_FILE_STAT_STRUCT stat #define MZ_FILE_STAT stat #define MZ_FFLUSH fflush #define MZ_FREOPEN(f, m, s) freopen(f, m, s) #define MZ_DELETE_FILE remove #elif defined(__GNUC__) && _LARGEFILE64_SOURCE #ifndef MINIZ_NO_TIME #include #endif #define MZ_FILE FILE #define MZ_FOPEN(f, m) fopen64(f, m) #define MZ_FCLOSE fclose #define MZ_FREAD fread #define MZ_FWRITE fwrite #define MZ_FTELL64 ftello64 #define MZ_FSEEK64 fseeko64 #define MZ_FILE_STAT_STRUCT stat64 #define MZ_FILE_STAT stat64 #define MZ_FFLUSH fflush #define MZ_FREOPEN(p, m, s) freopen64(p, m, s) #define MZ_DELETE_FILE remove #else #ifndef MINIZ_NO_TIME #include #endif #define MZ_FILE FILE #define MZ_FOPEN(f, m) fopen(f, m) #define MZ_FCLOSE fclose #define MZ_FREAD fread #define MZ_FWRITE fwrite #define MZ_FTELL64 ftello #define MZ_FSEEK64 fseeko #define MZ_FILE_STAT_STRUCT stat #define MZ_FILE_STAT stat #define MZ_FFLUSH fflush #define MZ_FREOPEN(f, m, s) freopen(f, m, s) #define MZ_DELETE_FILE remove #endif // #ifdef _MSC_VER #endif // #ifdef MINIZ_NO_STDIO #define MZ_TOLOWER(c) ((((c) >= 'A') && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c)) // Various ZIP archive enums. To completely avoid cross platform compiler alignment and platform endian issues, miniz.c doesn't use structs for any of this stuff. enum { // ZIP archive identifiers and record sizes MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG = 0x06054b50, MZ_ZIP_CENTRAL_DIR_HEADER_SIG = 0x02014b50, MZ_ZIP_LOCAL_DIR_HEADER_SIG = 0x04034b50, MZ_ZIP_LOCAL_DIR_HEADER_SIZE = 30, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE = 46, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE = 22, // Central directory header record offsets MZ_ZIP_CDH_SIG_OFS = 0, MZ_ZIP_CDH_VERSION_MADE_BY_OFS = 4, MZ_ZIP_CDH_VERSION_NEEDED_OFS = 6, MZ_ZIP_CDH_BIT_FLAG_OFS = 8, MZ_ZIP_CDH_METHOD_OFS = 10, MZ_ZIP_CDH_FILE_TIME_OFS = 12, MZ_ZIP_CDH_FILE_DATE_OFS = 14, MZ_ZIP_CDH_CRC32_OFS = 16, MZ_ZIP_CDH_COMPRESSED_SIZE_OFS = 20, MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS = 24, MZ_ZIP_CDH_FILENAME_LEN_OFS = 28, MZ_ZIP_CDH_EXTRA_LEN_OFS = 30, MZ_ZIP_CDH_COMMENT_LEN_OFS = 32, MZ_ZIP_CDH_DISK_START_OFS = 34, MZ_ZIP_CDH_INTERNAL_ATTR_OFS = 36, MZ_ZIP_CDH_EXTERNAL_ATTR_OFS = 38, MZ_ZIP_CDH_LOCAL_HEADER_OFS = 42, // Local directory header offsets MZ_ZIP_LDH_SIG_OFS = 0, MZ_ZIP_LDH_VERSION_NEEDED_OFS = 4, MZ_ZIP_LDH_BIT_FLAG_OFS = 6, MZ_ZIP_LDH_METHOD_OFS = 8, MZ_ZIP_LDH_FILE_TIME_OFS = 10, MZ_ZIP_LDH_FILE_DATE_OFS = 12, MZ_ZIP_LDH_CRC32_OFS = 14, MZ_ZIP_LDH_COMPRESSED_SIZE_OFS = 18, MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS = 22, MZ_ZIP_LDH_FILENAME_LEN_OFS = 26, MZ_ZIP_LDH_EXTRA_LEN_OFS = 28, // End of central directory offsets MZ_ZIP_ECDH_SIG_OFS = 0, MZ_ZIP_ECDH_NUM_THIS_DISK_OFS = 4, MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS = 6, MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS = 8, MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS = 10, MZ_ZIP_ECDH_CDIR_SIZE_OFS = 12, MZ_ZIP_ECDH_CDIR_OFS_OFS = 16, MZ_ZIP_ECDH_COMMENT_SIZE_OFS = 20, }; typedef struct { void *m_p; size_t m_size, m_capacity; mz_uint m_element_size; } mz_zip_array; struct mz_zip_internal_state_tag { mz_zip_array m_central_dir; mz_zip_array m_central_dir_offsets; mz_zip_array m_sorted_central_dir_offsets; MZ_FILE *m_pFile; void *m_pMem; size_t m_mem_size; size_t m_mem_capacity; }; #define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size) (array_ptr)->m_element_size = element_size #define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) ((element_type *)((array_ptr)->m_p))[index] static MZ_FORCEINLINE void mz_zip_array_clear(mz_zip_archive *pZip, mz_zip_array *pArray) { pZip->m_pFree(pZip->m_pAlloc_opaque, pArray->m_p); memset(pArray, 0, sizeof(mz_zip_array)); } static mz_bool mz_zip_array_ensure_capacity(mz_zip_archive *pZip, mz_zip_array *pArray, size_t min_new_capacity, mz_uint growing) { void *pNew_p; size_t new_capacity = min_new_capacity; MZ_ASSERT(pArray->m_element_size); if (pArray->m_capacity >= min_new_capacity) return MZ_TRUE; if (growing) { new_capacity = MZ_MAX(1, pArray->m_capacity); while (new_capacity < min_new_capacity) new_capacity *= 2; } if (NULL == (pNew_p = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pArray->m_p, pArray->m_element_size, new_capacity))) return MZ_FALSE; pArray->m_p = pNew_p; pArray->m_capacity = new_capacity; return MZ_TRUE; } static MZ_FORCEINLINE mz_bool mz_zip_array_reserve(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_capacity, mz_uint growing) { if (new_capacity > pArray->m_capacity) { if (!mz_zip_array_ensure_capacity(pZip, pArray, new_capacity, growing)) return MZ_FALSE; } return MZ_TRUE; } static MZ_FORCEINLINE mz_bool mz_zip_array_resize(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_size, mz_uint growing) { if (new_size > pArray->m_capacity) { if (!mz_zip_array_ensure_capacity(pZip, pArray, new_size, growing)) return MZ_FALSE; } pArray->m_size = new_size; return MZ_TRUE; } static MZ_FORCEINLINE mz_bool mz_zip_array_ensure_room(mz_zip_archive *pZip, mz_zip_array *pArray, size_t n) { return mz_zip_array_reserve(pZip, pArray, pArray->m_size + n, MZ_TRUE); } static MZ_FORCEINLINE mz_bool mz_zip_array_push_back(mz_zip_archive *pZip, mz_zip_array *pArray, const void *pElements, size_t n) { size_t orig_size = pArray->m_size; if (!mz_zip_array_resize(pZip, pArray, orig_size + n, MZ_TRUE)) return MZ_FALSE; memcpy((mz_uint8*)pArray->m_p + orig_size * pArray->m_element_size, pElements, n * pArray->m_element_size); return MZ_TRUE; } #ifndef MINIZ_NO_TIME static time_t mz_zip_dos_to_time_t(int dos_time, int dos_date) { struct tm tm; memset(&tm, 0, sizeof(tm)); tm.tm_isdst = -1; tm.tm_year = ((dos_date >> 9) & 127) + 1980 - 1900; tm.tm_mon = ((dos_date >> 5) & 15) - 1; tm.tm_mday = dos_date & 31; tm.tm_hour = (dos_time >> 11) & 31; tm.tm_min = (dos_time >> 5) & 63; tm.tm_sec = (dos_time << 1) & 62; return mktime(&tm); } static void mz_zip_time_to_dos_time(time_t time, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date) { #ifdef _MSC_VER struct tm tm_struct; struct tm *tm = &tm_struct; errno_t err = localtime_s(tm, &time); if (err) { *pDOS_date = 0; *pDOS_time = 0; return; } #else struct tm *tm = localtime(&time); #endif *pDOS_time = (mz_uint16)(((tm->tm_hour) << 11) + ((tm->tm_min) << 5) + ((tm->tm_sec) >> 1)); *pDOS_date = (mz_uint16)(((tm->tm_year + 1900 - 1980) << 9) + ((tm->tm_mon + 1) << 5) + tm->tm_mday); } #endif #ifndef MINIZ_NO_STDIO static mz_bool mz_zip_get_file_modified_time(const char *pFilename, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date) { #ifdef MINIZ_NO_TIME (void)pFilename; *pDOS_date = *pDOS_time = 0; #else struct MZ_FILE_STAT_STRUCT file_stat; // On Linux with x86 glibc, this call will fail on large files (>= 0x80000000 bytes) unless you compiled with _LARGEFILE64_SOURCE. Argh. if (MZ_FILE_STAT(pFilename, &file_stat) != 0) return MZ_FALSE; mz_zip_time_to_dos_time(file_stat.st_mtime, pDOS_time, pDOS_date); #endif // #ifdef MINIZ_NO_TIME return MZ_TRUE; } #ifndef MINIZ_NO_TIME static mz_bool mz_zip_set_file_times(const char *pFilename, time_t access_time, time_t modified_time) { struct utimbuf t; t.actime = access_time; t.modtime = modified_time; return !utime(pFilename, &t); } #endif // #ifndef MINIZ_NO_TIME #endif // #ifndef MINIZ_NO_STDIO static mz_bool mz_zip_reader_init_internal(mz_zip_archive *pZip, mz_uint32 flags) { (void)flags; if ((!pZip) || (pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID)) return MZ_FALSE; if (!pZip->m_pAlloc) pZip->m_pAlloc = def_alloc_func; if (!pZip->m_pFree) pZip->m_pFree = def_free_func; if (!pZip->m_pRealloc) pZip->m_pRealloc = def_realloc_func; pZip->m_zip_mode = MZ_ZIP_MODE_READING; pZip->m_archive_size = 0; pZip->m_central_directory_file_ofs = 0; pZip->m_total_files = 0; if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state)))) return MZ_FALSE; memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state)); MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8)); MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32)); MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32)); return MZ_TRUE; } static MZ_FORCEINLINE mz_bool mz_zip_reader_filename_less(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, mz_uint r_index) { const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE; const mz_uint8 *pR = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, r_index)); mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS), r_len = MZ_READ_LE16(pR + MZ_ZIP_CDH_FILENAME_LEN_OFS); mz_uint8 l = 0, r = 0; pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; pR += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; pE = pL + MZ_MIN(l_len, r_len); while (pL < pE) { if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR))) break; pL++; pR++; } return (pL == pE) ? (l_len < r_len) : (l < r); } #define MZ_SWAP_UINT32(a, b) do { mz_uint32 t = a; a = b; b = t; } MZ_MACRO_END // Heap sort of lowercased filenames, used to help accelerate plain central directory searches by mz_zip_reader_locate_file(). (Could also use qsort(), but it could allocate memory.) static void mz_zip_reader_sort_central_dir_offsets_by_filename(mz_zip_archive *pZip) { mz_zip_internal_state *pState = pZip->m_pState; const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets; const mz_zip_array *pCentral_dir = &pState->m_central_dir; mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32, 0); const int size = pZip->m_total_files; int start = (size - 2) >> 1, end; while (start >= 0) { int child, root = start; for ( ; ; ) { if ((child = (root << 1) + 1) >= size) break; child += (((child + 1) < size) && (mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1]))); if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child])) break; MZ_SWAP_UINT32(pIndices[root], pIndices[child]); root = child; } start--; } end = size - 1; while (end > 0) { int child, root = 0; MZ_SWAP_UINT32(pIndices[end], pIndices[0]); for ( ; ; ) { if ((child = (root << 1) + 1) >= end) break; child += (((child + 1) < end) && mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1])); if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child])) break; MZ_SWAP_UINT32(pIndices[root], pIndices[child]); root = child; } end--; } } static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint32 flags) { mz_uint cdir_size, num_this_disk, cdir_disk_index; mz_uint64 cdir_ofs; mz_int64 cur_file_ofs; const mz_uint8 *p; mz_uint32 buf_u32[4096 / sizeof(mz_uint32)]; mz_uint8 *pBuf = (mz_uint8 *)buf_u32; mz_bool sort_central_dir = ((flags & MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY) == 0); // Basic sanity checks - reject files which are too small, and check the first 4 bytes of the file to make sure a local header is there. if (pZip->m_archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) return MZ_FALSE; // Find the end of central directory record by scanning the file from the end towards the beginning. cur_file_ofs = MZ_MAX((mz_int64)pZip->m_archive_size - (mz_int64)sizeof(buf_u32), 0); for ( ; ; ) { int i, n = (int)MZ_MIN(sizeof(buf_u32), pZip->m_archive_size - cur_file_ofs); if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, n) != (mz_uint)n) return MZ_FALSE; for (i = n - 4; i >= 0; --i) if (MZ_READ_LE32(pBuf + i) == MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG) break; if (i >= 0) { cur_file_ofs += i; break; } if ((!cur_file_ofs) || ((pZip->m_archive_size - cur_file_ofs) >= (0xFFFF + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE))) return MZ_FALSE; cur_file_ofs = MZ_MAX(cur_file_ofs - (sizeof(buf_u32) - 3), 0); } // Read and verify the end of central directory record. if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) return MZ_FALSE; if ((MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_SIG_OFS) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG) || ((pZip->m_total_files = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS)) != MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS))) return MZ_FALSE; num_this_disk = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_THIS_DISK_OFS); cdir_disk_index = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS); if (((num_this_disk | cdir_disk_index) != 0) && ((num_this_disk != 1) || (cdir_disk_index != 1))) return MZ_FALSE; if ((cdir_size = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_SIZE_OFS)) < pZip->m_total_files * MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) return MZ_FALSE; cdir_ofs = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_OFS_OFS); if ((cdir_ofs + (mz_uint64)cdir_size) > pZip->m_archive_size) return MZ_FALSE; pZip->m_central_directory_file_ofs = cdir_ofs; if (pZip->m_total_files) { mz_uint i, n; // Read the entire central directory into a heap block, and allocate another heap block to hold the unsorted central dir file record offsets, and another to hold the sorted indices. if ((!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir, cdir_size, MZ_FALSE)) || (!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir_offsets, pZip->m_total_files, MZ_FALSE))) return MZ_FALSE; if (sort_central_dir) { if (!mz_zip_array_resize(pZip, &pZip->m_pState->m_sorted_central_dir_offsets, pZip->m_total_files, MZ_FALSE)) return MZ_FALSE; } if (pZip->m_pRead(pZip->m_pIO_opaque, cdir_ofs, pZip->m_pState->m_central_dir.m_p, cdir_size) != cdir_size) return MZ_FALSE; // Now create an index into the central directory file records, do some basic sanity checking on each record, and check for zip64 entries (which are not yet supported). p = (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p; for (n = cdir_size, i = 0; i < pZip->m_total_files; ++i) { mz_uint total_header_size, comp_size, decomp_size, disk_index; if ((n < MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) || (MZ_READ_LE32(p) != MZ_ZIP_CENTRAL_DIR_HEADER_SIG)) return MZ_FALSE; MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, i) = (mz_uint32)(p - (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p); if (sort_central_dir) MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_sorted_central_dir_offsets, mz_uint32, i) = i; comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); decomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); if (((!MZ_READ_LE32(p + MZ_ZIP_CDH_METHOD_OFS)) && (decomp_size != comp_size)) || (decomp_size && !comp_size) || (decomp_size == 0xFFFFFFFF) || (comp_size == 0xFFFFFFFF)) return MZ_FALSE; disk_index = MZ_READ_LE16(p + MZ_ZIP_CDH_DISK_START_OFS); if ((disk_index != num_this_disk) && (disk_index != 1)) return MZ_FALSE; if (((mz_uint64)MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS) + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + comp_size) > pZip->m_archive_size) return MZ_FALSE; if ((total_header_size = MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS)) > n) return MZ_FALSE; n -= total_header_size; p += total_header_size; } } if (sort_central_dir) mz_zip_reader_sort_central_dir_offsets_by_filename(pZip); return MZ_TRUE; } mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint32 flags) { if ((!pZip) || (!pZip->m_pRead)) return MZ_FALSE; if (!mz_zip_reader_init_internal(pZip, flags)) return MZ_FALSE; pZip->m_archive_size = size; if (!mz_zip_reader_read_central_dir(pZip, flags)) { mz_zip_reader_end(pZip); return MZ_FALSE; } return MZ_TRUE; } static size_t mz_zip_mem_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n) { mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; size_t s = (file_ofs >= pZip->m_archive_size) ? 0 : (size_t)MZ_MIN(pZip->m_archive_size - file_ofs, n); memcpy(pBuf, (const mz_uint8 *)pZip->m_pState->m_pMem + file_ofs, s); return s; } mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint32 flags) { if (!mz_zip_reader_init_internal(pZip, flags)) return MZ_FALSE; pZip->m_archive_size = size; pZip->m_pRead = mz_zip_mem_read_func; pZip->m_pIO_opaque = pZip; #ifdef __cplusplus pZip->m_pState->m_pMem = const_cast(pMem); #else pZip->m_pState->m_pMem = (void *)pMem; #endif pZip->m_pState->m_mem_size = size; if (!mz_zip_reader_read_central_dir(pZip, flags)) { mz_zip_reader_end(pZip); return MZ_FALSE; } return MZ_TRUE; } #ifndef MINIZ_NO_STDIO static size_t mz_zip_file_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n) { mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile); if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET)))) return 0; return MZ_FREAD(pBuf, 1, n, pZip->m_pState->m_pFile); } mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags) { mz_uint64 file_size; MZ_FILE *pFile = MZ_FOPEN(pFilename, "rb"); if (!pFile) return MZ_FALSE; if (MZ_FSEEK64(pFile, 0, SEEK_END)) { MZ_FCLOSE(pFile); return MZ_FALSE; } file_size = MZ_FTELL64(pFile); if (!mz_zip_reader_init_internal(pZip, flags)) { MZ_FCLOSE(pFile); return MZ_FALSE; } pZip->m_pRead = mz_zip_file_read_func; pZip->m_pIO_opaque = pZip; pZip->m_pState->m_pFile = pFile; pZip->m_archive_size = file_size; if (!mz_zip_reader_read_central_dir(pZip, flags)) { mz_zip_reader_end(pZip); return MZ_FALSE; } return MZ_TRUE; } #endif // #ifndef MINIZ_NO_STDIO mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip) { return pZip ? pZip->m_total_files : 0; } static MZ_FORCEINLINE const mz_uint8 *mz_zip_reader_get_cdh(mz_zip_archive *pZip, mz_uint file_index) { if ((!pZip) || (!pZip->m_pState) || (file_index >= pZip->m_total_files) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) return NULL; return &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index)); } mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index) { mz_uint m_bit_flag; const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); if (!p) return MZ_FALSE; m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS); return (m_bit_flag & 1); } mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index) { mz_uint filename_len, external_attr; const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); if (!p) return MZ_FALSE; // First see if the filename ends with a '/' character. filename_len = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); if (filename_len) { if (*(p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_len - 1) == '/') return MZ_TRUE; } // Bugfix: This code was also checking if the internal attribute was non-zero, which wasn't correct. // Most/all zip writers (hopefully) set DOS file/directory attributes in the low 16-bits, so check for the DOS directory flag and ignore the source OS ID in the created by field. // FIXME: Remove this check? Is it necessary - we already check the filename. external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS); if ((external_attr & 0x10) != 0) return MZ_TRUE; return MZ_FALSE; } mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat) { mz_uint n; const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); if ((!p) || (!pStat)) return MZ_FALSE; // Unpack the central directory record. pStat->m_file_index = file_index; pStat->m_central_dir_ofs = MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index); pStat->m_version_made_by = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_MADE_BY_OFS); pStat->m_version_needed = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_NEEDED_OFS); pStat->m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS); pStat->m_method = MZ_READ_LE16(p + MZ_ZIP_CDH_METHOD_OFS); #ifndef MINIZ_NO_TIME pStat->m_time = mz_zip_dos_to_time_t(MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_TIME_OFS), MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_DATE_OFS)); #endif pStat->m_crc32 = MZ_READ_LE32(p + MZ_ZIP_CDH_CRC32_OFS); pStat->m_comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); pStat->m_uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); pStat->m_internal_attr = MZ_READ_LE16(p + MZ_ZIP_CDH_INTERNAL_ATTR_OFS); pStat->m_external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS); pStat->m_local_header_ofs = MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS); // Copy as much of the filename and comment as possible. n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE - 1); memcpy(pStat->m_filename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n); pStat->m_filename[n] = '\0'; n = MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS); n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE - 1); pStat->m_comment_size = n; memcpy(pStat->m_comment, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS), n); pStat->m_comment[n] = '\0'; return MZ_TRUE; } mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size) { mz_uint n; const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); if (!p) { if (filename_buf_size) pFilename[0] = '\0'; return 0; } n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); if (filename_buf_size) { n = MZ_MIN(n, filename_buf_size - 1); memcpy(pFilename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n); pFilename[n] = '\0'; } return n + 1; } static MZ_FORCEINLINE mz_bool mz_zip_reader_string_equal(const char *pA, const char *pB, mz_uint len, mz_uint flags) { mz_uint i; if (flags & MZ_ZIP_FLAG_CASE_SENSITIVE) return 0 == memcmp(pA, pB, len); for (i = 0; i < len; ++i) if (MZ_TOLOWER(pA[i]) != MZ_TOLOWER(pB[i])) return MZ_FALSE; return MZ_TRUE; } static MZ_FORCEINLINE int mz_zip_reader_filename_compare(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, const char *pR, mz_uint r_len) { const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE; mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS); mz_uint8 l = 0, r = 0; pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; pE = pL + MZ_MIN(l_len, r_len); while (pL < pE) { if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR))) break; pL++; pR++; } return (pL == pE) ? (int)(l_len - r_len) : (l - r); } static int mz_zip_reader_locate_file_binary_search(mz_zip_archive *pZip, const char *pFilename) { mz_zip_internal_state *pState = pZip->m_pState; const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets; const mz_zip_array *pCentral_dir = &pState->m_central_dir; mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32, 0); const int size = pZip->m_total_files; const mz_uint filename_len = (mz_uint)strlen(pFilename); int l = 0, h = size - 1; while (l <= h) { int m = (l + h) >> 1, file_index = pIndices[m], comp = mz_zip_reader_filename_compare(pCentral_dir, pCentral_dir_offsets, file_index, pFilename, filename_len); if (!comp) return file_index; else if (comp < 0) l = m + 1; else h = m - 1; } return -1; } int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags) { mz_uint file_index; size_t name_len, comment_len; if ((!pZip) || (!pZip->m_pState) || (!pName) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) return -1; if (((flags & (MZ_ZIP_FLAG_IGNORE_PATH | MZ_ZIP_FLAG_CASE_SENSITIVE)) == 0) && (!pComment) && (pZip->m_pState->m_sorted_central_dir_offsets.m_size)) return mz_zip_reader_locate_file_binary_search(pZip, pName); name_len = strlen(pName); if (name_len > 0xFFFF) return -1; comment_len = pComment ? strlen(pComment) : 0; if (comment_len > 0xFFFF) return -1; for (file_index = 0; file_index < pZip->m_total_files; file_index++) { const mz_uint8 *pHeader = &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index)); mz_uint filename_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_FILENAME_LEN_OFS); const char *pFilename = (const char *)pHeader + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; if (filename_len < name_len) continue; if (comment_len) { mz_uint file_extra_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_EXTRA_LEN_OFS), file_comment_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_COMMENT_LEN_OFS); const char *pFile_comment = pFilename + filename_len + file_extra_len; if ((file_comment_len != comment_len) || (!mz_zip_reader_string_equal(pComment, pFile_comment, file_comment_len, flags))) continue; } if ((flags & MZ_ZIP_FLAG_IGNORE_PATH) && (filename_len)) { int ofs = filename_len - 1; do { if ((pFilename[ofs] == '/') || (pFilename[ofs] == '\\') || (pFilename[ofs] == ':')) break; } while (--ofs >= 0); ofs++; pFilename += ofs; filename_len -= ofs; } if ((filename_len == name_len) && (mz_zip_reader_string_equal(pName, pFilename, filename_len, flags))) return file_index; } return -1; } mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) { int status = TINFL_STATUS_DONE; mz_uint64 needed_size, cur_file_ofs, comp_remaining, out_buf_ofs = 0, read_buf_size, read_buf_ofs = 0, read_buf_avail; mz_zip_archive_file_stat file_stat; void *pRead_buf; mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; tinfl_decompressor inflator; if ((buf_size) && (!pBuf)) return MZ_FALSE; if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) return MZ_FALSE; // Empty file, or a directory (but not always a directory - I've seen odd zips with directories that have compressed data which inflates to 0 bytes) if (!file_stat.m_comp_size) return MZ_TRUE; // Entry is a subdirectory (I've seen old zips with dir entries which have compressed deflate data which inflates to 0 bytes, but these entries claim to uncompress to 512 bytes in the headers). // I'm torn how to handle this case - should it fail instead? if (mz_zip_reader_is_file_a_directory(pZip, file_index)) return MZ_TRUE; // Encryption and patch files are not supported. if (file_stat.m_bit_flag & (1 | 32)) return MZ_FALSE; // This function only supports stored and deflate. if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED)) return MZ_FALSE; // Ensure supplied output buffer is large enough. needed_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? file_stat.m_comp_size : file_stat.m_uncomp_size; if (buf_size < needed_size) return MZ_FALSE; // Read and parse the local directory entry. cur_file_ofs = file_stat.m_local_header_ofs; if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) return MZ_FALSE; if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) return MZ_FALSE; cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size) return MZ_FALSE; if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) { // The file is stored or the caller has requested the compressed data. if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, (size_t)needed_size) != needed_size) return MZ_FALSE; return ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) != 0) || (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, (size_t)file_stat.m_uncomp_size) == file_stat.m_crc32); } // Decompress the file either directly from memory or from a file input buffer. tinfl_init(&inflator); if (pZip->m_pState->m_pMem) { // Read directly from the archive in memory. pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs; read_buf_size = read_buf_avail = file_stat.m_comp_size; comp_remaining = 0; } else if (pUser_read_buf) { // Use a user provided read buffer. if (!user_read_buf_size) return MZ_FALSE; pRead_buf = (mz_uint8 *)pUser_read_buf; read_buf_size = user_read_buf_size; read_buf_avail = 0; comp_remaining = file_stat.m_comp_size; } else { // Temporarily allocate a read buffer. read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE); #ifdef _MSC_VER if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF)) #else if (((sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF)) #endif return MZ_FALSE; if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size))) return MZ_FALSE; read_buf_avail = 0; comp_remaining = file_stat.m_comp_size; } do { size_t in_buf_size, out_buf_size = (size_t)(file_stat.m_uncomp_size - out_buf_ofs); if ((!read_buf_avail) && (!pZip->m_pState->m_pMem)) { read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) { status = TINFL_STATUS_FAILED; break; } cur_file_ofs += read_buf_avail; comp_remaining -= read_buf_avail; read_buf_ofs = 0; } in_buf_size = (size_t)read_buf_avail; status = tinfl_decompress(&inflator, (mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, (mz_uint8 *)pBuf, (mz_uint8 *)pBuf + out_buf_ofs, &out_buf_size, TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF | (comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0)); read_buf_avail -= in_buf_size; read_buf_ofs += in_buf_size; out_buf_ofs += out_buf_size; } while (status == TINFL_STATUS_NEEDS_MORE_INPUT); if (status == TINFL_STATUS_DONE) { // Make sure the entire file was decompressed, and check its CRC. if ((out_buf_ofs != file_stat.m_uncomp_size) || (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, (size_t)file_stat.m_uncomp_size) != file_stat.m_crc32)) status = TINFL_STATUS_FAILED; } if ((!pZip->m_pState->m_pMem) && (!pUser_read_buf)) pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); return status == TINFL_STATUS_DONE; } mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) { int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); if (file_index < 0) return MZ_FALSE; return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, pUser_read_buf, user_read_buf_size); } mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags) { return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, NULL, 0); } mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags) { return mz_zip_reader_extract_file_to_mem_no_alloc(pZip, pFilename, pBuf, buf_size, flags, NULL, 0); } void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags) { mz_uint64 comp_size, uncomp_size, alloc_size; const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); void *pBuf; if (pSize) *pSize = 0; if (!p) return NULL; comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? comp_size : uncomp_size; #ifdef _MSC_VER if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF)) #else if (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF)) #endif return NULL; if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)alloc_size))) return NULL; if (!mz_zip_reader_extract_to_mem(pZip, file_index, pBuf, (size_t)alloc_size, flags)) { pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); return NULL; } if (pSize) *pSize = (size_t)alloc_size; return pBuf; } void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags) { int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); if (file_index < 0) { if (pSize) *pSize = 0; return MZ_FALSE; } return mz_zip_reader_extract_to_heap(pZip, file_index, pSize, flags); } mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags) { int status = TINFL_STATUS_DONE; mz_uint file_crc32 = MZ_CRC32_INIT; mz_uint64 read_buf_size, read_buf_ofs = 0, read_buf_avail, comp_remaining, out_buf_ofs = 0, cur_file_ofs; mz_zip_archive_file_stat file_stat; void *pRead_buf = NULL; void *pWrite_buf = NULL; mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) return MZ_FALSE; // Empty file, or a directory (but not always a directory - I've seen odd zips with directories that have compressed data which inflates to 0 bytes) if (!file_stat.m_comp_size) return MZ_TRUE; // Entry is a subdirectory (I've seen old zips with dir entries which have compressed deflate data which inflates to 0 bytes, but these entries claim to uncompress to 512 bytes in the headers). // I'm torn how to handle this case - should it fail instead? if (mz_zip_reader_is_file_a_directory(pZip, file_index)) return MZ_TRUE; // Encryption and patch files are not supported. if (file_stat.m_bit_flag & (1 | 32)) return MZ_FALSE; // This function only supports stored and deflate. if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED)) return MZ_FALSE; // Read and parse the local directory entry. cur_file_ofs = file_stat.m_local_header_ofs; if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) return MZ_FALSE; if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) return MZ_FALSE; cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size) return MZ_FALSE; // Decompress the file either directly from memory or from a file input buffer. if (pZip->m_pState->m_pMem) { pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs; read_buf_size = read_buf_avail = file_stat.m_comp_size; comp_remaining = 0; } else { read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE); if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size))) return MZ_FALSE; read_buf_avail = 0; comp_remaining = file_stat.m_comp_size; } if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) { // The file is stored or the caller has requested the compressed data. if (pZip->m_pState->m_pMem) { #ifdef _MSC_VER if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > 0xFFFFFFFF)) #else if (((sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > 0xFFFFFFFF)) #endif return MZ_FALSE; if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)file_stat.m_comp_size) != file_stat.m_comp_size) status = TINFL_STATUS_FAILED; else if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) file_crc32 = (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf, (size_t)file_stat.m_comp_size); cur_file_ofs += file_stat.m_comp_size; out_buf_ofs += file_stat.m_comp_size; comp_remaining = 0; } else { while (comp_remaining) { read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) { status = TINFL_STATUS_FAILED; break; } if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) file_crc32 = (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf, (size_t)read_buf_avail); if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) { status = TINFL_STATUS_FAILED; break; } cur_file_ofs += read_buf_avail; out_buf_ofs += read_buf_avail; comp_remaining -= read_buf_avail; } } } else { tinfl_decompressor inflator; tinfl_init(&inflator); if (NULL == (pWrite_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, TINFL_LZ_DICT_SIZE))) status = TINFL_STATUS_FAILED; else { do { mz_uint8 *pWrite_buf_cur = (mz_uint8 *)pWrite_buf + (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1)); size_t in_buf_size, out_buf_size = TINFL_LZ_DICT_SIZE - (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1)); if ((!read_buf_avail) && (!pZip->m_pState->m_pMem)) { read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) { status = TINFL_STATUS_FAILED; break; } cur_file_ofs += read_buf_avail; comp_remaining -= read_buf_avail; read_buf_ofs = 0; } in_buf_size = (size_t)read_buf_avail; status = tinfl_decompress(&inflator, (const mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, (mz_uint8 *)pWrite_buf, pWrite_buf_cur, &out_buf_size, comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0); read_buf_avail -= in_buf_size; read_buf_ofs += in_buf_size; if (out_buf_size) { if (pCallback(pOpaque, out_buf_ofs, pWrite_buf_cur, out_buf_size) != out_buf_size) { status = TINFL_STATUS_FAILED; break; } file_crc32 = (mz_uint32)mz_crc32(file_crc32, pWrite_buf_cur, out_buf_size); if ((out_buf_ofs += out_buf_size) > file_stat.m_uncomp_size) { status = TINFL_STATUS_FAILED; break; } } } while ((status == TINFL_STATUS_NEEDS_MORE_INPUT) || (status == TINFL_STATUS_HAS_MORE_OUTPUT)); } } if ((status == TINFL_STATUS_DONE) && (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA))) { // Make sure the entire file was decompressed, and check its CRC. if ((out_buf_ofs != file_stat.m_uncomp_size) || (file_crc32 != file_stat.m_crc32)) status = TINFL_STATUS_FAILED; } if (!pZip->m_pState->m_pMem) pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); if (pWrite_buf) pZip->m_pFree(pZip->m_pAlloc_opaque, pWrite_buf); return status == TINFL_STATUS_DONE; } mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags) { int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); if (file_index < 0) return MZ_FALSE; return mz_zip_reader_extract_to_callback(pZip, file_index, pCallback, pOpaque, flags); } #ifndef MINIZ_NO_STDIO static size_t mz_zip_file_write_callback(void *pOpaque, mz_uint64 ofs, const void *pBuf, size_t n) { (void)ofs; return MZ_FWRITE(pBuf, 1, n, (MZ_FILE*)pOpaque); } mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags) { mz_bool status; mz_zip_archive_file_stat file_stat; MZ_FILE *pFile; if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) return MZ_FALSE; pFile = MZ_FOPEN(pDst_filename, "wb"); if (!pFile) return MZ_FALSE; status = mz_zip_reader_extract_to_callback(pZip, file_index, mz_zip_file_write_callback, pFile, flags); if (MZ_FCLOSE(pFile) == EOF) return MZ_FALSE; #ifndef MINIZ_NO_TIME if (status) mz_zip_set_file_times(pDst_filename, file_stat.m_time, file_stat.m_time); #endif return status; } #endif // #ifndef MINIZ_NO_STDIO mz_bool mz_zip_reader_end(mz_zip_archive *pZip) { if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) return MZ_FALSE; if (pZip->m_pState) { mz_zip_internal_state *pState = pZip->m_pState; pZip->m_pState = NULL; mz_zip_array_clear(pZip, &pState->m_central_dir); mz_zip_array_clear(pZip, &pState->m_central_dir_offsets); mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets); #ifndef MINIZ_NO_STDIO if (pState->m_pFile) { MZ_FCLOSE(pState->m_pFile); pState->m_pFile = NULL; } #endif // #ifndef MINIZ_NO_STDIO pZip->m_pFree(pZip->m_pAlloc_opaque, pState); } pZip->m_zip_mode = MZ_ZIP_MODE_INVALID; return MZ_TRUE; } #ifndef MINIZ_NO_STDIO mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags) { int file_index = mz_zip_reader_locate_file(pZip, pArchive_filename, NULL, flags); if (file_index < 0) return MZ_FALSE; return mz_zip_reader_extract_to_file(pZip, file_index, pDst_filename, flags); } #endif // ------------------- .ZIP archive writing #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS static void mz_write_le16(mz_uint8 *p, mz_uint16 v) { p[0] = (mz_uint8)v; p[1] = (mz_uint8)(v >> 8); } static void mz_write_le32(mz_uint8 *p, mz_uint32 v) { p[0] = (mz_uint8)v; p[1] = (mz_uint8)(v >> 8); p[2] = (mz_uint8)(v >> 16); p[3] = (mz_uint8)(v >> 24); } #define MZ_WRITE_LE16(p, v) mz_write_le16((mz_uint8 *)(p), (mz_uint16)(v)) #define MZ_WRITE_LE32(p, v) mz_write_le32((mz_uint8 *)(p), (mz_uint32)(v)) mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size) { if ((!pZip) || (pZip->m_pState) || (!pZip->m_pWrite) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID)) return MZ_FALSE; if (pZip->m_file_offset_alignment) { // Ensure user specified file offset alignment is a power of 2. if (pZip->m_file_offset_alignment & (pZip->m_file_offset_alignment - 1)) return MZ_FALSE; } if (!pZip->m_pAlloc) pZip->m_pAlloc = def_alloc_func; if (!pZip->m_pFree) pZip->m_pFree = def_free_func; if (!pZip->m_pRealloc) pZip->m_pRealloc = def_realloc_func; pZip->m_zip_mode = MZ_ZIP_MODE_WRITING; pZip->m_archive_size = existing_size; pZip->m_central_directory_file_ofs = 0; pZip->m_total_files = 0; if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state)))) return MZ_FALSE; memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state)); MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8)); MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32)); MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32)); return MZ_TRUE; } static size_t mz_zip_heap_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n) { mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; mz_zip_internal_state *pState = pZip->m_pState; mz_uint64 new_size = MZ_MAX(file_ofs + n, pState->m_mem_size); #ifdef _MSC_VER if ((!n) || ((0, sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))) #else if ((!n) || ((sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))) #endif return 0; if (new_size > pState->m_mem_capacity) { void *pNew_block; size_t new_capacity = MZ_MAX(64, pState->m_mem_capacity); while (new_capacity < new_size) new_capacity *= 2; if (NULL == (pNew_block = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pState->m_pMem, 1, new_capacity))) return 0; pState->m_pMem = pNew_block; pState->m_mem_capacity = new_capacity; } memcpy((mz_uint8 *)pState->m_pMem + file_ofs, pBuf, n); pState->m_mem_size = (size_t)new_size; return n; } mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size) { pZip->m_pWrite = mz_zip_heap_write_func; pZip->m_pIO_opaque = pZip; if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning)) return MZ_FALSE; if (0 != (initial_allocation_size = MZ_MAX(initial_allocation_size, size_to_reserve_at_beginning))) { if (NULL == (pZip->m_pState->m_pMem = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, initial_allocation_size))) { mz_zip_writer_end(pZip); return MZ_FALSE; } pZip->m_pState->m_mem_capacity = initial_allocation_size; } return MZ_TRUE; } #ifndef MINIZ_NO_STDIO static size_t mz_zip_file_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n) { mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile); if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET)))) return 0; return MZ_FWRITE(pBuf, 1, n, pZip->m_pState->m_pFile); } mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning) { MZ_FILE *pFile; pZip->m_pWrite = mz_zip_file_write_func; pZip->m_pIO_opaque = pZip; if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning)) return MZ_FALSE; if (NULL == (pFile = MZ_FOPEN(pFilename, "wb"))) { mz_zip_writer_end(pZip); return MZ_FALSE; } pZip->m_pState->m_pFile = pFile; if (size_to_reserve_at_beginning) { mz_uint64 cur_ofs = 0; char buf[4096]; MZ_CLEAR_OBJ(buf); do { size_t n = (size_t)MZ_MIN(sizeof(buf), size_to_reserve_at_beginning); if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_ofs, buf, n) != n) { mz_zip_writer_end(pZip); return MZ_FALSE; } cur_ofs += n; size_to_reserve_at_beginning -= n; } while (size_to_reserve_at_beginning); } return MZ_TRUE; } #endif // #ifndef MINIZ_NO_STDIO mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename) { mz_zip_internal_state *pState; if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) return MZ_FALSE; // No sense in trying to write to an archive that's already at the support max size if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_ZIP_LOCAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) return MZ_FALSE; pState = pZip->m_pState; if (pState->m_pFile) { #ifdef MINIZ_NO_STDIO pFilename; return MZ_FALSE; #else // Archive is being read from stdio - try to reopen as writable. if (pZip->m_pIO_opaque != pZip) return MZ_FALSE; if (!pFilename) return MZ_FALSE; pZip->m_pWrite = mz_zip_file_write_func; if (NULL == (pState->m_pFile = MZ_FREOPEN(pFilename, "r+b", pState->m_pFile))) { // The mz_zip_archive is now in a bogus state because pState->m_pFile is NULL, so just close it. mz_zip_reader_end(pZip); return MZ_FALSE; } #endif // #ifdef MINIZ_NO_STDIO } else if (pState->m_pMem) { // Archive lives in a memory block. Assume it's from the heap that we can resize using the realloc callback. if (pZip->m_pIO_opaque != pZip) return MZ_FALSE; pState->m_mem_capacity = pState->m_mem_size; pZip->m_pWrite = mz_zip_heap_write_func; } // Archive is being read via a user provided read function - make sure the user has specified a write function too. else if (!pZip->m_pWrite) return MZ_FALSE; // Start writing new files at the archive's current central directory location. pZip->m_archive_size = pZip->m_central_directory_file_ofs; pZip->m_zip_mode = MZ_ZIP_MODE_WRITING; pZip->m_central_directory_file_ofs = 0; return MZ_TRUE; } mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags) { return mz_zip_writer_add_mem_ex(pZip, pArchive_name, pBuf, buf_size, NULL, 0, level_and_flags, 0, 0); } typedef struct { mz_zip_archive *m_pZip; mz_uint64 m_cur_archive_file_ofs; mz_uint64 m_comp_size; } mz_zip_writer_add_state; static mz_bool mz_zip_writer_add_put_buf_callback(const void* pBuf, int len, void *pUser) { mz_zip_writer_add_state *pState = (mz_zip_writer_add_state *)pUser; if ((int)pState->m_pZip->m_pWrite(pState->m_pZip->m_pIO_opaque, pState->m_cur_archive_file_ofs, pBuf, len) != len) return MZ_FALSE; pState->m_cur_archive_file_ofs += len; pState->m_comp_size += len; return MZ_TRUE; } static mz_bool mz_zip_writer_create_local_dir_header(mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size, mz_uint16 extra_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date) { (void)pZip; memset(pDst, 0, MZ_ZIP_LOCAL_DIR_HEADER_SIZE); MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_SIG_OFS, MZ_ZIP_LOCAL_DIR_HEADER_SIG); MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_VERSION_NEEDED_OFS, method ? 20 : 0); MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_BIT_FLAG_OFS, bit_flags); MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_METHOD_OFS, method); MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_TIME_OFS, dos_time); MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_DATE_OFS, dos_date); MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_CRC32_OFS, uncomp_crc32); MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_COMPRESSED_SIZE_OFS, comp_size); MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS, uncomp_size); MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILENAME_LEN_OFS, filename_size); MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_EXTRA_LEN_OFS, extra_size); return MZ_TRUE; } static mz_bool mz_zip_writer_create_central_dir_header(mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size, mz_uint16 extra_size, mz_uint16 comment_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date, mz_uint64 local_header_ofs, mz_uint32 ext_attributes) { (void)pZip; memset(pDst, 0, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE); MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_SIG_OFS, MZ_ZIP_CENTRAL_DIR_HEADER_SIG); MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_VERSION_NEEDED_OFS, method ? 20 : 0); MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_BIT_FLAG_OFS, bit_flags); MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_METHOD_OFS, method); MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_TIME_OFS, dos_time); MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_DATE_OFS, dos_date); MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_CRC32_OFS, uncomp_crc32); MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS, comp_size); MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS, uncomp_size); MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILENAME_LEN_OFS, filename_size); MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_EXTRA_LEN_OFS, extra_size); MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_COMMENT_LEN_OFS, comment_size); MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS, ext_attributes); MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_header_ofs); return MZ_TRUE; } static mz_bool mz_zip_writer_add_to_central_dir(mz_zip_archive *pZip, const char *pFilename, mz_uint16 filename_size, const void *pExtra, mz_uint16 extra_size, const void *pComment, mz_uint16 comment_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date, mz_uint64 local_header_ofs, mz_uint32 ext_attributes) { mz_zip_internal_state *pState = pZip->m_pState; mz_uint32 central_dir_ofs = (mz_uint32)pState->m_central_dir.m_size; size_t orig_central_dir_size = pState->m_central_dir.m_size; mz_uint8 central_dir_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE]; // No zip64 support yet if ((local_header_ofs > 0xFFFFFFFF) || (((mz_uint64)pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size + extra_size + comment_size) > 0xFFFFFFFF)) return MZ_FALSE; if (!mz_zip_writer_create_central_dir_header(pZip, central_dir_header, filename_size, extra_size, comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_header_ofs, ext_attributes)) return MZ_FALSE; if ((!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_dir_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) || (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pFilename, filename_size)) || (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pExtra, extra_size)) || (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pComment, comment_size)) || (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, ¢ral_dir_ofs, 1))) { // Try to push the central directory array back into its original state. mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); return MZ_FALSE; } return MZ_TRUE; } static mz_bool mz_zip_writer_validate_archive_name(const char *pArchive_name) { // Basic ZIP archive filename validity checks: Valid filenames cannot start with a forward slash, cannot contain a drive letter, and cannot use DOS-style backward slashes. if (*pArchive_name == '/') return MZ_FALSE; while (*pArchive_name) { if ((*pArchive_name == '\\') || (*pArchive_name == ':')) return MZ_FALSE; pArchive_name++; } return MZ_TRUE; } static mz_uint mz_zip_writer_compute_padding_needed_for_file_alignment(mz_zip_archive *pZip) { mz_uint32 n; if (!pZip->m_file_offset_alignment) return 0; n = (mz_uint32)(pZip->m_archive_size & (pZip->m_file_offset_alignment - 1)); return (pZip->m_file_offset_alignment - n) & (pZip->m_file_offset_alignment - 1); } static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip, mz_uint64 cur_file_ofs, mz_uint32 n) { char buf[4096]; memset(buf, 0, MZ_MIN(sizeof(buf), n)); while (n) { mz_uint32 s = MZ_MIN(sizeof(buf), n); if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_file_ofs, buf, s) != s) return MZ_FALSE; cur_file_ofs += s; n -= s; } return MZ_TRUE; } mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32) { mz_uint16 method = 0, dos_time = 0, dos_date = 0; mz_uint level, ext_attributes = 0, num_alignment_padding_bytes; mz_uint64 local_dir_header_ofs = pZip->m_archive_size, cur_archive_file_ofs = pZip->m_archive_size, comp_size = 0; size_t archive_name_size; mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE]; tdefl_compressor *pComp = NULL; mz_bool store_data_uncompressed; mz_zip_internal_state *pState; if ((int)level_and_flags < 0) level_and_flags = MZ_DEFAULT_LEVEL; level = level_and_flags & 0xF; store_data_uncompressed = ((!level) || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)); if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || ((buf_size) && (!pBuf)) || (!pArchive_name) || ((comment_size) && (!pComment)) || (pZip->m_total_files == 0xFFFF) || (level > MZ_UBER_COMPRESSION)) return MZ_FALSE; pState = pZip->m_pState; if ((!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (uncomp_size)) return MZ_FALSE; // No zip64 support yet if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF)) return MZ_FALSE; if (!mz_zip_writer_validate_archive_name(pArchive_name)) return MZ_FALSE; #ifndef MINIZ_NO_TIME { time_t cur_time; time(&cur_time); mz_zip_time_to_dos_time(cur_time, &dos_time, &dos_date); } #endif // #ifndef MINIZ_NO_TIME archive_name_size = strlen(pArchive_name); if (archive_name_size > 0xFFFF) return MZ_FALSE; num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); // no zip64 support yet if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + comment_size + archive_name_size) > 0xFFFFFFFF)) return MZ_FALSE; if ((archive_name_size) && (pArchive_name[archive_name_size - 1] == '/')) { // Set DOS Subdirectory attribute bit. ext_attributes |= 0x10; // Subdirectories cannot contain data. if ((buf_size) || (uncomp_size)) return MZ_FALSE; } // Try to do any allocations before writing to the archive, so if an allocation fails the file remains unmodified. (A good idea if we're doing an in-place modification.) if ((!mz_zip_array_ensure_room(pZip, &pState->m_central_dir, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size)) || (!mz_zip_array_ensure_room(pZip, &pState->m_central_dir_offsets, 1))) return MZ_FALSE; if ((!store_data_uncompressed) && (buf_size)) { if (NULL == (pComp = (tdefl_compressor *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor)))) return MZ_FALSE; } if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes + sizeof(local_dir_header))) { pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); return MZ_FALSE; } local_dir_header_ofs += num_alignment_padding_bytes; if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } cur_archive_file_ofs += num_alignment_padding_bytes + sizeof(local_dir_header); MZ_CLEAR_OBJ(local_dir_header); if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size) { pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); return MZ_FALSE; } cur_archive_file_ofs += archive_name_size; if (!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) { uncomp_crc32 = (mz_uint32)mz_crc32(MZ_CRC32_INIT, (const mz_uint8*)pBuf, buf_size); uncomp_size = buf_size; if (uncomp_size <= 3) { level = 0; store_data_uncompressed = MZ_TRUE; } } if (store_data_uncompressed) { if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pBuf, buf_size) != buf_size) { pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); return MZ_FALSE; } cur_archive_file_ofs += buf_size; comp_size = buf_size; if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA) method = MZ_DEFLATED; } else if (buf_size) { mz_zip_writer_add_state state; state.m_pZip = pZip; state.m_cur_archive_file_ofs = cur_archive_file_ofs; state.m_comp_size = 0; if ((tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params(level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY) || (tdefl_compress_buffer(pComp, pBuf, buf_size, TDEFL_FINISH) != TDEFL_STATUS_DONE)) { pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); return MZ_FALSE; } comp_size = state.m_comp_size; cur_archive_file_ofs = state.m_cur_archive_file_ofs; method = MZ_DEFLATED; } pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); pComp = NULL; // no zip64 support yet if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF)) return MZ_FALSE; if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date)) return MZ_FALSE; if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) return MZ_FALSE; if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date, local_dir_header_ofs, ext_attributes)) return MZ_FALSE; pZip->m_total_files++; pZip->m_archive_size = cur_archive_file_ofs; return MZ_TRUE; } #ifndef MINIZ_NO_STDIO mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags) { mz_uint uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes; mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0; mz_uint64 local_dir_header_ofs = pZip->m_archive_size, cur_archive_file_ofs = pZip->m_archive_size, uncomp_size = 0, comp_size = 0; size_t archive_name_size; mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE]; MZ_FILE *pSrc_file = NULL; if ((int)level_and_flags < 0) level_and_flags = MZ_DEFAULT_LEVEL; level = level_and_flags & 0xF; if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || (!pArchive_name) || ((comment_size) && (!pComment)) || (level > MZ_UBER_COMPRESSION)) return MZ_FALSE; if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA) return MZ_FALSE; if (!mz_zip_writer_validate_archive_name(pArchive_name)) return MZ_FALSE; archive_name_size = strlen(pArchive_name); if (archive_name_size > 0xFFFF) return MZ_FALSE; num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); // no zip64 support yet if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + comment_size + archive_name_size) > 0xFFFFFFFF)) return MZ_FALSE; if (!mz_zip_get_file_modified_time(pSrc_filename, &dos_time, &dos_date)) return MZ_FALSE; pSrc_file = MZ_FOPEN(pSrc_filename, "rb"); if (!pSrc_file) return MZ_FALSE; MZ_FSEEK64(pSrc_file, 0, SEEK_END); uncomp_size = MZ_FTELL64(pSrc_file); MZ_FSEEK64(pSrc_file, 0, SEEK_SET); if (uncomp_size > 0xFFFFFFFF) { // No zip64 support yet MZ_FCLOSE(pSrc_file); return MZ_FALSE; } if (uncomp_size <= 3) level = 0; if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes + sizeof(local_dir_header))) { MZ_FCLOSE(pSrc_file); return MZ_FALSE; } local_dir_header_ofs += num_alignment_padding_bytes; if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } cur_archive_file_ofs += num_alignment_padding_bytes + sizeof(local_dir_header); MZ_CLEAR_OBJ(local_dir_header); if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size) { MZ_FCLOSE(pSrc_file); return MZ_FALSE; } cur_archive_file_ofs += archive_name_size; if (uncomp_size) { mz_uint64 uncomp_remaining = uncomp_size; void *pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, MZ_ZIP_MAX_IO_BUF_SIZE); if (!pRead_buf) { MZ_FCLOSE(pSrc_file); return MZ_FALSE; } if (!level) { while (uncomp_remaining) { mz_uint n = (mz_uint)MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining); if ((MZ_FREAD(pRead_buf, 1, n, pSrc_file) != n) || (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf, n) != n)) { pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); MZ_FCLOSE(pSrc_file); return MZ_FALSE; } uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, n); uncomp_remaining -= n; cur_archive_file_ofs += n; } comp_size = uncomp_size; } else { mz_bool result = MZ_FALSE; mz_zip_writer_add_state state; tdefl_compressor *pComp = (tdefl_compressor *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor)); if (!pComp) { pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); MZ_FCLOSE(pSrc_file); return MZ_FALSE; } state.m_pZip = pZip; state.m_cur_archive_file_ofs = cur_archive_file_ofs; state.m_comp_size = 0; if (tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params(level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY) { pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); MZ_FCLOSE(pSrc_file); return MZ_FALSE; } for ( ; ; ) { size_t in_buf_size = (mz_uint32)MZ_MIN(uncomp_remaining, MZ_ZIP_MAX_IO_BUF_SIZE); tdefl_status status; if (MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size) break; uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, in_buf_size); uncomp_remaining -= in_buf_size; status = tdefl_compress_buffer(pComp, pRead_buf, in_buf_size, uncomp_remaining ? TDEFL_NO_FLUSH : TDEFL_FINISH); if (status == TDEFL_STATUS_DONE) { result = MZ_TRUE; break; } else if (status != TDEFL_STATUS_OKAY) break; } pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); if (!result) { pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); MZ_FCLOSE(pSrc_file); return MZ_FALSE; } comp_size = state.m_comp_size; cur_archive_file_ofs = state.m_cur_archive_file_ofs; method = MZ_DEFLATED; } pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); } MZ_FCLOSE(pSrc_file); pSrc_file = NULL; // no zip64 support yet if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF)) return MZ_FALSE; if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date)) return MZ_FALSE; if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) return MZ_FALSE; if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date, local_dir_header_ofs, ext_attributes)) return MZ_FALSE; pZip->m_total_files++; pZip->m_archive_size = cur_archive_file_ofs; return MZ_TRUE; } #endif // #ifndef MINIZ_NO_STDIO mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint file_index) { mz_uint n, bit_flags, num_alignment_padding_bytes; mz_uint64 comp_bytes_remaining, local_dir_header_ofs; mz_uint64 cur_src_file_ofs, cur_dst_file_ofs; mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; mz_uint8 central_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE]; size_t orig_central_dir_size; mz_zip_internal_state *pState; void *pBuf; const mz_uint8 *pSrc_central_header; if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING)) return MZ_FALSE; if (NULL == (pSrc_central_header = mz_zip_reader_get_cdh(pSource_zip, file_index))) return MZ_FALSE; pState = pZip->m_pState; num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); // no zip64 support yet if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) return MZ_FALSE; cur_src_file_ofs = MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS); cur_dst_file_ofs = pZip->m_archive_size; if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) return MZ_FALSE; if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) return MZ_FALSE; cur_src_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE; if (!mz_zip_writer_write_zeros(pZip, cur_dst_file_ofs, num_alignment_padding_bytes)) return MZ_FALSE; cur_dst_file_ofs += num_alignment_padding_bytes; local_dir_header_ofs = cur_dst_file_ofs; if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) return MZ_FALSE; cur_dst_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE; n = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); comp_bytes_remaining = n + MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)MZ_MAX(sizeof(mz_uint32) * 4, MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining))))) return MZ_FALSE; while (comp_bytes_remaining) { n = (mz_uint)MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining); if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, n) != n) { pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); return MZ_FALSE; } cur_src_file_ofs += n; if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n) { pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); return MZ_FALSE; } cur_dst_file_ofs += n; comp_bytes_remaining -= n; } bit_flags = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_BIT_FLAG_OFS); if (bit_flags & 8) { // Copy data descriptor if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, sizeof(mz_uint32) * 4) != sizeof(mz_uint32) * 4) { pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); return MZ_FALSE; } n = sizeof(mz_uint32) * ((MZ_READ_LE32(pBuf) == 0x08074b50) ? 4 : 3); if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n) { pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); return MZ_FALSE; } cur_src_file_ofs += n; cur_dst_file_ofs += n; } pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); // no zip64 support yet if (cur_dst_file_ofs > 0xFFFFFFFF) return MZ_FALSE; orig_central_dir_size = pState->m_central_dir.m_size; memcpy(central_header, pSrc_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE); MZ_WRITE_LE32(central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_dir_header_ofs); if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) return MZ_FALSE; n = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_EXTRA_LEN_OFS) + MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_COMMENT_LEN_OFS); if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n)) { mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); return MZ_FALSE; } if (pState->m_central_dir.m_size > 0xFFFFFFFF) return MZ_FALSE; n = (mz_uint32)orig_central_dir_size; if (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, &n, 1)) { mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); return MZ_FALSE; } pZip->m_total_files++; pZip->m_archive_size = cur_dst_file_ofs; return MZ_TRUE; } mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip) { mz_zip_internal_state *pState; mz_uint64 central_dir_ofs, central_dir_size; mz_uint8 hdr[MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE]; if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING)) return MZ_FALSE; pState = pZip->m_pState; // no zip64 support yet if ((pZip->m_total_files > 0xFFFF) || ((pZip->m_archive_size + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) return MZ_FALSE; central_dir_ofs = 0; central_dir_size = 0; if (pZip->m_total_files) { // Write central directory central_dir_ofs = pZip->m_archive_size; central_dir_size = pState->m_central_dir.m_size; pZip->m_central_directory_file_ofs = central_dir_ofs; if (pZip->m_pWrite(pZip->m_pIO_opaque, central_dir_ofs, pState->m_central_dir.m_p, (size_t)central_dir_size) != central_dir_size) return MZ_FALSE; pZip->m_archive_size += central_dir_size; } // Write end of central directory record MZ_CLEAR_OBJ(hdr); MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_SIG_OFS, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG); MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS, pZip->m_total_files); MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS, pZip->m_total_files); MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_SIZE_OFS, central_dir_size); MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_OFS_OFS, central_dir_ofs); if (pZip->m_pWrite(pZip->m_pIO_opaque, pZip->m_archive_size, hdr, sizeof(hdr)) != sizeof(hdr)) return MZ_FALSE; #ifndef MINIZ_NO_STDIO if ((pState->m_pFile) && (MZ_FFLUSH(pState->m_pFile) == EOF)) return MZ_FALSE; #endif // #ifndef MINIZ_NO_STDIO pZip->m_archive_size += sizeof(hdr); pZip->m_zip_mode = MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED; return MZ_TRUE; } mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf, size_t *pSize) { if ((!pZip) || (!pZip->m_pState) || (!pBuf) || (!pSize)) return MZ_FALSE; if (pZip->m_pWrite != mz_zip_heap_write_func) return MZ_FALSE; if (!mz_zip_writer_finalize_archive(pZip)) return MZ_FALSE; *pBuf = pZip->m_pState->m_pMem; *pSize = pZip->m_pState->m_mem_size; pZip->m_pState->m_pMem = NULL; pZip->m_pState->m_mem_size = pZip->m_pState->m_mem_capacity = 0; return MZ_TRUE; } mz_bool mz_zip_writer_end(mz_zip_archive *pZip) { mz_zip_internal_state *pState; mz_bool status = MZ_TRUE; if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || ((pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) && (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED))) return MZ_FALSE; pState = pZip->m_pState; pZip->m_pState = NULL; mz_zip_array_clear(pZip, &pState->m_central_dir); mz_zip_array_clear(pZip, &pState->m_central_dir_offsets); mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets); #ifndef MINIZ_NO_STDIO if (pState->m_pFile) { MZ_FCLOSE(pState->m_pFile); pState->m_pFile = NULL; } #endif // #ifndef MINIZ_NO_STDIO if ((pZip->m_pWrite == mz_zip_heap_write_func) && (pState->m_pMem)) { pZip->m_pFree(pZip->m_pAlloc_opaque, pState->m_pMem); pState->m_pMem = NULL; } pZip->m_pFree(pZip->m_pAlloc_opaque, pState); pZip->m_zip_mode = MZ_ZIP_MODE_INVALID; return status; } #ifndef MINIZ_NO_STDIO mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags) { mz_bool status, created_new_archive = MZ_FALSE; mz_zip_archive zip_archive; struct MZ_FILE_STAT_STRUCT file_stat; MZ_CLEAR_OBJ(zip_archive); if ((int)level_and_flags < 0) level_and_flags = MZ_DEFAULT_LEVEL; if ((!pZip_filename) || (!pArchive_name) || ((buf_size) && (!pBuf)) || ((comment_size) && (!pComment)) || ((level_and_flags & 0xF) > MZ_UBER_COMPRESSION)) return MZ_FALSE; if (!mz_zip_writer_validate_archive_name(pArchive_name)) return MZ_FALSE; if (MZ_FILE_STAT(pZip_filename, &file_stat) != 0) { // Create a new archive. if (!mz_zip_writer_init_file(&zip_archive, pZip_filename, 0)) return MZ_FALSE; created_new_archive = MZ_TRUE; } else { // Append to an existing archive. if (!mz_zip_reader_init_file(&zip_archive, pZip_filename, level_and_flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY)) return MZ_FALSE; if (!mz_zip_writer_init_from_reader(&zip_archive, pZip_filename)) { mz_zip_reader_end(&zip_archive); return MZ_FALSE; } } status = mz_zip_writer_add_mem_ex(&zip_archive, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, 0, 0); // Always finalize, even if adding failed for some reason, so we have a valid central directory. (This may not always succeed, but we can try.) if (!mz_zip_writer_finalize_archive(&zip_archive)) status = MZ_FALSE; if (!mz_zip_writer_end(&zip_archive)) status = MZ_FALSE; if ((!status) && (created_new_archive)) { // It's a new archive and something went wrong, so just delete it. int ignoredStatus = MZ_DELETE_FILE(pZip_filename); (void)ignoredStatus; } return status; } void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags) { int file_index; mz_zip_archive zip_archive; void *p = NULL; if (pSize) *pSize = 0; if ((!pZip_filename) || (!pArchive_name)) return NULL; MZ_CLEAR_OBJ(zip_archive); if (!mz_zip_reader_init_file(&zip_archive, pZip_filename, flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY)) return NULL; if ((file_index = mz_zip_reader_locate_file(&zip_archive, pArchive_name, NULL, flags)) >= 0) p = mz_zip_reader_extract_to_heap(&zip_archive, file_index, pSize, flags); mz_zip_reader_end(&zip_archive); return p; } #endif // #ifndef MINIZ_NO_STDIO #endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS #endif // #ifndef MINIZ_NO_ARCHIVE_APIS #ifdef __cplusplus } #endif #endif // MINIZ_HEADER_FILE_ONLY /* This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to */ deps/miniz-sys-0.1.7/lib.rs0000664000175000017500000000446312614575420012467 0ustar #![doc(html_root_url = "http://alexcrichton.com/flate2-rs")] #![allow(bad_style)] extern crate libc; use libc::*; pub const MZ_NO_FLUSH: c_int = 0; pub const MZ_PARTIAL_FLUSH: c_int = 1; pub const MZ_SYNC_FLUSH: c_int = 2; pub const MZ_FULL_FLUSH: c_int = 3; pub const MZ_FINISH: c_int = 4; pub const MZ_BLOCK: c_int = 5; pub const MZ_OK: c_int = 0; pub const MZ_STREAM_END: c_int = 1; pub const MZ_NEED_DICT: c_int = 2; pub const MZ_ERRNO: c_int = -1; pub const MZ_STREAM_ERROR: c_int = -2; pub const MZ_DATA_ERROR: c_int = -3; pub const MZ_MEM_ERROR: c_int = -4; pub const MZ_BUF_ERROR: c_int = -5; pub const MZ_VERSION_ERROR: c_int = -6; pub const MZ_PARAM_ERROR: c_int = -10000; pub const MZ_DEFLATED: c_int = 8; pub const MZ_DEFAULT_WINDOW_BITS: c_int = 15; pub const MZ_DEFAULT_STRATEGY: c_int = 0; #[repr(C)] pub struct mz_stream { pub next_in: *const u8, pub avail_in: c_uint, pub total_in: c_ulong, pub next_out: *mut u8, pub avail_out: c_uint, pub total_out: c_ulong, pub msg: *const c_char, pub state: *mut mz_internal_state, pub zalloc: Option, pub zfree: Option, pub opaque: *mut c_void, pub data_type: c_int, pub adler: c_ulong, pub reserved: c_ulong, } pub enum mz_internal_state {} pub type mz_alloc_func = extern fn(*mut c_void, size_t, size_t) -> *mut c_void; pub type mz_free_func = extern fn(*mut c_void, *mut c_void); extern { pub fn mz_deflateInit2(stream: *mut mz_stream, level: c_int, method: c_int, window_bits: c_int, mem_level: c_int, strategy: c_int) -> c_int; pub fn mz_deflate(stream: *mut mz_stream, flush: c_int) -> c_int; pub fn mz_deflateEnd(stream: *mut mz_stream) -> c_int; pub fn mz_deflateReset(stream: *mut mz_stream) -> c_int; pub fn mz_inflateInit2(stream: *mut mz_stream, window_bits: c_int) -> c_int; pub fn mz_inflate(stream: *mut mz_stream, flush: c_int) -> c_int; pub fn mz_inflateEnd(stream: *mut mz_stream) -> c_int; pub fn mz_crc32(crc: c_ulong, ptr: *const u8, len: size_t) -> c_ulong; } deps/miniz-sys-0.1.7/Cargo.toml0000664000175000017500000000057312617507361013303 0ustar [package] name = "miniz-sys" version = "0.1.7" authors = ["Alex Crichton "] links = "miniz" build = "build.rs" license = "MIT/Apache-2.0" repository = "https://github.com/alexcrichton/flate2-rs" description = """ Bindings to the miniz.c library. """ [lib] name = "miniz_sys" path = "lib.rs" [dependencies] libc = "0.2" [build-dependencies] gcc = "0.3" deps/miniz-sys-0.1.7/build.rs0000664000175000017500000000024312536150270013003 0ustar extern crate gcc; use std::env; fn main() { gcc::compile_library("libminiz.a", &["miniz.c"]); println!("cargo:root={}", env::var("OUT_DIR").unwrap()); } deps/time-0.1.34/0000755000000000000000000000000012666635520012201 5ustar rootrootdeps/time-0.1.34/LICENSE-APACHE0000664000175000017500000002513712430235663012352 0ustar Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/time-0.1.34/LICENSE-MIT0000664000175000017500000000205712430235663012056 0ustar Copyright (c) 2014 The Rust Project Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/time-0.1.34/.travis.yml0000664000175000017500000000160612617506661012540 0ustar language: rust rust: - 1.0.0 - beta - nightly sudo: false script: - cargo build --verbose - cargo test --verbose - cargo test --verbose --features rustc-serialize - | [ $TRAVIS_RUST_VERSION != nightly ] || cargo bench - cargo doc after_success: | [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && [ $TRAVIS_RUST_VERSION = nightly ] && echo '' > target/doc/index.html && pip install ghp-import --user $USER && $HOME/.local/bin/ghp-import -n target/doc && git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages env: global: secure: qxCB/4AUtX5cQPDfmAccpxRkxkdoZtkjiYW5tbaThzFEJJ1SpkIJzS+IdhCPxDGhwF+aiLLky9KDZi1bXbtjkDS8n/bFaGc/k2vRNgLKuaLdztZ1dGHlBNN2J7j0bLGUm0MAy62OHLNXbPmvS0uGvv0q4pQ6sQB2+YItwqHPuyQ= notifications: email: on_success: never os: - linux - osx deps/time-0.1.34/README.md0000664000175000017500000000103212600115271011660 0ustar time ==== Utilities for working with time-related functions in Rust [![Build Status](https://travis-ci.org/rust-lang-deprecated/time.svg?branch=master)](https://travis-ci.org/rust-lang-deprecated/time) [![Build status](https://ci.appveyor.com/api/projects/status/55m7rbaj9a5v3ad7?svg=true)](https://ci.appveyor.com/project/alexcrichton/time) [Documentation](https://doc.rust-lang.org/time) ## Usage Put this in your `Cargo.toml`: ```toml [dependencies] time = "0.1" ``` And this in your crate root: ```rust extern crate time; ``` deps/time-0.1.34/.gitignore0000600000175000017500000000002412430235065012364 0ustar /target /Cargo.lock deps/time-0.1.34/src/0000755000000000000000000000000012666635520012770 5ustar rootrootdeps/time-0.1.34/src/parse.rs0000664000175000017500000003265512535345431012701 0ustar use super::{Timespec, Tm, at_utc, ParseError, NSEC_PER_SEC}; use super::ParseError::*; /// Parses the time from the string according to the format string. pub fn strptime(mut s: &str, format: &str) -> Result { let mut tm = Tm { tm_sec: 0, tm_min: 0, tm_hour: 0, tm_mday: 0, tm_mon: 0, tm_year: 0, tm_wday: 0, tm_yday: 0, tm_isdst: 0, tm_utcoff: 0, tm_nsec: 0, }; let mut chars = format.chars(); while let Some(ch) = chars.next() { if ch == '%' { if let Some(ch) = chars.next() { try!(parse_type(&mut s, ch, &mut tm)); } } else { try!(parse_char(&mut s, ch)); } } Ok(tm) } fn parse_type(s: &mut &str, ch: char, tm: &mut Tm) -> Result<(), ParseError> { match ch { 'A' => match match_strs(s, &[("Sunday", 0), ("Monday", 1), ("Tuesday", 2), ("Wednesday", 3), ("Thursday", 4), ("Friday", 5), ("Saturday", 6)]) { Some(v) => { tm.tm_wday = v; Ok(()) } None => Err(ParseError::InvalidDay) }, 'a' => match match_strs(s, &[("Sun", 0), ("Mon", 1), ("Tue", 2), ("Wed", 3), ("Thu", 4), ("Fri", 5), ("Sat", 6)]) { Some(v) => { tm.tm_wday = v; Ok(()) } None => Err(ParseError::InvalidDay) }, 'B' => match match_strs(s, &[("January", 0), ("February", 1), ("March", 2), ("April", 3), ("May", 4), ("June", 5), ("July", 6), ("August", 7), ("September", 8), ("October", 9), ("November", 10), ("December", 11)]) { Some(v) => { tm.tm_mon = v; Ok(()) } None => Err(ParseError::InvalidMonth) }, 'b' | 'h' => match match_strs(s, &[("Jan", 0), ("Feb", 1), ("Mar", 2), ("Apr", 3), ("May", 4), ("Jun", 5), ("Jul", 6), ("Aug", 7), ("Sep", 8), ("Oct", 9), ("Nov", 10), ("Dec", 11)]) { Some(v) => { tm.tm_mon = v; Ok(()) } None => Err(ParseError::InvalidMonth) }, 'C' => match match_digits_in_range(s, 1, 2, false, 0, 99) { Some(v) => { tm.tm_year += (v * 100) - 1900; Ok(()) } None => Err(ParseError::InvalidYear) }, 'c' => { parse_type(s, 'a', tm) .and_then(|()| parse_char(s, ' ')) .and_then(|()| parse_type(s, 'b', tm)) .and_then(|()| parse_char(s, ' ')) .and_then(|()| parse_type(s, 'e', tm)) .and_then(|()| parse_char(s, ' ')) .and_then(|()| parse_type(s, 'T', tm)) .and_then(|()| parse_char(s, ' ')) .and_then(|()| parse_type(s, 'Y', tm)) } 'D' | 'x' => { parse_type(s, 'm', tm) .and_then(|()| parse_char(s, '/')) .and_then(|()| parse_type(s, 'd', tm)) .and_then(|()| parse_char(s, '/')) .and_then(|()| parse_type(s, 'y', tm)) } 'd' => match match_digits_in_range(s, 1, 2, false, 1, 31) { Some(v) => { tm.tm_mday = v; Ok(()) } None => Err(ParseError::InvalidDayOfMonth) }, 'e' => match match_digits_in_range(s, 1, 2, true, 1, 31) { Some(v) => { tm.tm_mday = v; Ok(()) } None => Err(ParseError::InvalidDayOfMonth) }, 'f' => { tm.tm_nsec = match_fractional_seconds(s); Ok(()) } 'F' => { parse_type(s, 'Y', tm) .and_then(|()| parse_char(s, '-')) .and_then(|()| parse_type(s, 'm', tm)) .and_then(|()| parse_char(s, '-')) .and_then(|()| parse_type(s, 'd', tm)) } 'H' => { match match_digits_in_range(s, 1, 2, false, 0, 23) { Some(v) => { tm.tm_hour = v; Ok(()) } None => Err(ParseError::InvalidHour) } } 'I' => { match match_digits_in_range(s, 1, 2, false, 1, 12) { Some(v) => { tm.tm_hour = if v == 12 { 0 } else { v }; Ok(()) } None => Err(ParseError::InvalidHour) } } 'j' => { match match_digits_in_range(s, 1, 3, false, 1, 366) { Some(v) => { tm.tm_yday = v - 1; Ok(()) } None => Err(ParseError::InvalidDayOfYear) } } 'k' => { match match_digits_in_range(s, 1, 2, true, 0, 23) { Some(v) => { tm.tm_hour = v; Ok(()) } None => Err(ParseError::InvalidHour) } } 'l' => { match match_digits_in_range(s, 1, 2, true, 1, 12) { Some(v) => { tm.tm_hour = if v == 12 { 0 } else { v }; Ok(()) } None => Err(ParseError::InvalidHour) } } 'M' => { match match_digits_in_range(s, 1, 2, false, 0, 59) { Some(v) => { tm.tm_min = v; Ok(()) } None => Err(ParseError::InvalidMinute) } } 'm' => { match match_digits_in_range(s, 1, 2, false, 1, 12) { Some(v) => { tm.tm_mon = v - 1; Ok(()) } None => Err(ParseError::InvalidMonth) } } 'n' => parse_char(s, '\n'), 'P' => match match_strs(s, &[("am", 0), ("pm", 12)]) { Some(v) => { tm.tm_hour += v; Ok(()) } None => Err(ParseError::InvalidHour) }, 'p' => match match_strs(s, &[("AM", 0), ("PM", 12)]) { Some(v) => { tm.tm_hour += v; Ok(()) } None => Err(ParseError::InvalidHour) }, 'R' => { parse_type(s, 'H', tm) .and_then(|()| parse_char(s, ':')) .and_then(|()| parse_type(s, 'M', tm)) } 'r' => { parse_type(s, 'I', tm) .and_then(|()| parse_char(s, ':')) .and_then(|()| parse_type(s, 'M', tm)) .and_then(|()| parse_char(s, ':')) .and_then(|()| parse_type(s, 'S', tm)) .and_then(|()| parse_char(s, ' ')) .and_then(|()| parse_type(s, 'p', tm)) } 's' => { match match_digits_i64(s, 1, 18, false) { Some(v) => { *tm = at_utc(Timespec::new(v, 0)); Ok(()) }, None => Err(ParseError::InvalidSecondsSinceEpoch) } } 'S' => { match match_digits_in_range(s, 1, 2, false, 0, 60) { Some(v) => { tm.tm_sec = v; Ok(()) } None => Err(ParseError::InvalidSecond) } } //'s' {} 'T' | 'X' => { parse_type(s, 'H', tm) .and_then(|()| parse_char(s, ':')) .and_then(|()| parse_type(s, 'M', tm)) .and_then(|()| parse_char(s, ':')) .and_then(|()| parse_type(s, 'S', tm)) } 't' => parse_char(s, '\t'), 'u' => { match match_digits_in_range(s, 1, 1, false, 1, 7) { Some(v) => { tm.tm_wday = if v == 7 { 0 } else { v }; Ok(()) } None => Err(ParseError::InvalidDayOfWeek) } } 'v' => { parse_type(s, 'e', tm) .and_then(|()| parse_char(s, '-')) .and_then(|()| parse_type(s, 'b', tm)) .and_then(|()| parse_char(s, '-')) .and_then(|()| parse_type(s, 'Y', tm)) } //'W' {} 'w' => { match match_digits_in_range(s, 1, 1, false, 0, 6) { Some(v) => { tm.tm_wday = v; Ok(()) } None => Err(ParseError::InvalidDayOfWeek) } } 'Y' => { match match_digits(s, 4, 4, false) { Some(v) => { tm.tm_year = v - 1900; Ok(()) } None => Err(ParseError::InvalidYear) } } 'y' => { match match_digits_in_range(s, 1, 2, false, 0, 99) { Some(v) => { tm.tm_year = v; Ok(()) } None => Err(ParseError::InvalidYear) } } 'Z' => { if match_str(s, "UTC") || match_str(s, "GMT") { tm.tm_utcoff = 0; Ok(()) } else { // It's odd, but to maintain compatibility with c's // strptime we ignore the timezone. for (i, ch) in s.char_indices() { if ch == ' ' { *s = &s[i..]; return Ok(()) } } *s = ""; Ok(()) } } 'z' => { if parse_char(s, 'Z').is_ok() { tm.tm_utcoff = 0; Ok(()) } else { let sign = if parse_char(s, '+').is_ok() {1} else if parse_char(s, '-').is_ok() {-1} else { return Err(ParseError::InvalidZoneOffset) }; let hours; let minutes; match match_digits(s, 2, 2, false) { Some(h) => hours = h, None => return Err(ParseError::InvalidZoneOffset) } // consume the colon if its present, // just ignore it otherwise let _ = parse_char(s, ':'); match match_digits(s, 2, 2, false) { Some(m) => minutes = m, None => return Err(ParseError::InvalidZoneOffset) } tm.tm_utcoff = sign * (hours * 60 * 60 + minutes * 60); Ok(()) } } '%' => parse_char(s, '%'), ch => Err(ParseError::InvalidFormatSpecifier(ch)) } } fn match_str(s: &mut &str, needle: &str) -> bool { if s.starts_with(needle) { *s = &s[needle.len()..]; true } else { false } } fn match_strs(ss: &mut &str, strs: &[(&str, i32)]) -> Option { for &(needle, value) in strs.iter() { if match_str(ss, needle) { return Some(value) } } None } fn match_digits(ss: &mut &str, min_digits : usize, max_digits: usize, ws: bool) -> Option { match match_digits_i64(ss, min_digits, max_digits, ws) { Some(v) => Some(v as i32), None => None } } fn match_digits_i64(ss: &mut &str, min_digits : usize, max_digits: usize, ws: bool) -> Option { let mut value : i64 = 0; let mut n = 0; if ws { let s2 = ss.trim_left_matches(" "); n = ss.len() - s2.len(); if n > max_digits { return None } } let chars = ss[n..].char_indices(); for (_, ch) in chars.take(max_digits - n) { match ch { '0' ... '9' => value = value * 10 + (ch as i64 - '0' as i64), _ => break, } n += 1; } if n >= min_digits && n <= max_digits { *ss = &ss[n..]; Some(value) } else { None } } fn match_fractional_seconds(ss: &mut &str) -> i32 { let mut value = 0; let mut multiplier = NSEC_PER_SEC / 10; let mut chars = ss.char_indices(); let orig = *ss; for (i, ch) in &mut chars { *ss = &orig[i..]; match ch { '0' ... '9' => { // This will drop digits after the nanoseconds place let digit = ch as i32 - '0' as i32; value += digit * multiplier; multiplier /= 10; } _ => break } } value } fn match_digits_in_range(ss: &mut &str, min_digits : usize, max_digits : usize, ws: bool, min: i32, max: i32) -> Option { let before = *ss; match match_digits(ss, min_digits, max_digits, ws) { Some(val) if val >= min && val <= max => Some(val), _ => { *ss = before; None } } } fn parse_char(s: &mut &str, c: char) -> Result<(), ParseError> { match s.char_indices().next() { Some((i, c2)) => { if c == c2 { *s = &s[i + c2.len_utf8()..]; Ok(()) } else { Err(ParseError::UnexpectedCharacter(c, c2)) } } None => Err(ParseError::InvalidTime), } } deps/time-0.1.34/src/lib.rs0000664000175000017500000012002312611262560012314 0ustar // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Simple time handling. //! //! # Usage //! //! This crate is [on crates.io](https://crates.io/crates/time) and can be //! used by adding `time` to the dependencies in your project's `Cargo.toml`. //! //! ```toml //! [dependencies] //! time = "0.1" //! ``` //! //! And this in your crate root: //! //! ```rust //! extern crate time; //! ``` //! //! This crate uses the same syntax for format strings as the [strftime()] //! (http://man7.org/linux/man-pages/man3/strftime.3.html) function from the C //! standard library. #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://www.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/time/")] #![allow(trivial_numeric_casts)] #![cfg_attr(test, deny(warnings))] #[cfg(unix)] extern crate libc; #[cfg(windows)] extern crate kernel32; #[cfg(windows)] extern crate winapi; #[cfg(feature = "rustc-serialize")] extern crate rustc_serialize; #[cfg(test)] #[macro_use] extern crate log; #[cfg(all(windows, test))] extern crate advapi32; use std::cmp::Ordering; use std::error::Error; use std::fmt; use std::ops::{Add, Sub}; pub use duration::Duration; use self::ParseError::{InvalidDay, InvalidDayOfMonth, InvalidDayOfWeek, InvalidDayOfYear, InvalidFormatSpecifier, InvalidHour, InvalidMinute, InvalidMonth, InvalidSecond, InvalidTime, InvalidYear, InvalidZoneOffset, InvalidSecondsSinceEpoch, MissingFormatConverter, UnexpectedCharacter}; pub use parse::strptime; mod display; mod duration; mod parse; mod sys; static NSEC_PER_SEC: i32 = 1_000_000_000; /// A record specifying a time value in seconds and nanoseconds, where /// nanoseconds represent the offset from the given second. /// /// For example a timespec of 1.2 seconds after the beginning of the epoch would /// be represented as {sec: 1, nsec: 200000000}. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] #[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))] pub struct Timespec { pub sec: i64, pub nsec: i32 } /* * Timespec assumes that pre-epoch Timespecs have negative sec and positive * nsec fields. Darwin's and Linux's struct timespec functions handle pre- * epoch timestamps using a "two steps back, one step forward" representation, * though the man pages do not actually document this. For example, the time * -1.2 seconds before the epoch is represented by `Timespec { sec: -2_i64, * nsec: 800_000_000 }`. */ impl Timespec { pub fn new(sec: i64, nsec: i32) -> Timespec { assert!(nsec >= 0 && nsec < NSEC_PER_SEC); Timespec { sec: sec, nsec: nsec } } } impl Add for Timespec { type Output = Timespec; fn add(self, other: Duration) -> Timespec { let d_sec = other.num_seconds(); // It is safe to unwrap the nanoseconds, because there cannot be // more than one second left, which fits in i64 and in i32. let d_nsec = (other - Duration::seconds(d_sec)) .num_nanoseconds().unwrap() as i32; let mut sec = self.sec + d_sec; let mut nsec = self.nsec + d_nsec; if nsec >= NSEC_PER_SEC { nsec -= NSEC_PER_SEC; sec += 1; } else if nsec < 0 { nsec += NSEC_PER_SEC; sec -= 1; } Timespec::new(sec, nsec) } } impl Sub for Timespec { type Output = Timespec; fn sub(self, other: Duration) -> Timespec { let d_sec = other.num_seconds(); // It is safe to unwrap the nanoseconds, because there cannot be // more than one second left, which fits in i64 and in i32. let d_nsec = (other - Duration::seconds(d_sec)) .num_nanoseconds().unwrap() as i32; let mut sec = self.sec - d_sec; let mut nsec = self.nsec - d_nsec; if nsec >= NSEC_PER_SEC { nsec -= NSEC_PER_SEC; sec += 1; } else if nsec < 0 { nsec += NSEC_PER_SEC; sec -= 1; } Timespec::new(sec, nsec) } } impl Sub for Timespec { type Output = Duration; fn sub(self, other: Timespec) -> Duration { let sec = self.sec - other.sec; let nsec = self.nsec - other.nsec; Duration::seconds(sec) + Duration::nanoseconds(nsec as i64) } } /** * Returns the current time as a `timespec` containing the seconds and * nanoseconds since 1970-01-01T00:00:00Z. */ pub fn get_time() -> Timespec { let (sec, nsec) = sys::get_time(); Timespec::new(sec, nsec) } /** * Returns the current value of a high-resolution performance counter * in nanoseconds since an unspecified epoch. */ pub fn precise_time_ns() -> u64 { sys::get_precise_ns() } /** * Returns the current value of a high-resolution performance counter * in seconds since an unspecified epoch. */ pub fn precise_time_s() -> f64 { return (precise_time_ns() as f64) / 1000000000.; } /// An opaque structure representing a moment in time. /// /// The only operation that can be performed on a `PreciseTime` is the /// calculation of the `Duration` of time that lies between them. /// /// # Examples /// /// Repeatedly call a function for 1 second: /// /// ```rust /// use time::{Duration, PreciseTime}; /// # fn do_some_work() {} /// /// let start = PreciseTime::now(); /// /// while start.to(PreciseTime::now()) < Duration::seconds(1) { /// do_some_work(); /// } /// ``` #[derive(Copy, Clone)] pub struct PreciseTime(u64); impl PreciseTime { /// Returns a `PreciseTime` representing the current moment in time. pub fn now() -> PreciseTime { PreciseTime(precise_time_ns()) } /// Returns a `Duration` representing the span of time from the value of /// `self` to the value of `later`. /// /// # Notes /// /// If `later` represents a time before `self`, the result of this method /// is unspecified. /// /// If `later` represents a time more than 293 years after `self`, the /// result of this method is unspecified. #[inline] pub fn to(&self, later: PreciseTime) -> Duration { // NB: even if later is less than self due to overflow, this will work // since the subtraction will underflow properly as well. // // We could deal with the overflow when casting to an i64, but all that // gets us is the ability to handle intervals of up to 584 years, which // seems not very useful :) Duration::nanoseconds((later.0 - self.0) as i64) } } /// A structure representing a moment in time. /// /// `SteadyTime`s are generated by a "steady" clock, that is, a clock which /// never experiences discontinuous jumps and for which time always flows at /// the same rate. /// /// # Examples /// /// Repeatedly call a function for 1 second: /// /// ```rust /// # use time::{Duration, SteadyTime}; /// # fn do_some_work() {} /// let start = SteadyTime::now(); /// /// while SteadyTime::now() - start < Duration::seconds(1) { /// do_some_work(); /// } /// ``` #[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug)] pub struct SteadyTime(sys::SteadyTime); impl SteadyTime { /// Returns a `SteadyTime` representing the current moment in time. pub fn now() -> SteadyTime { SteadyTime(sys::SteadyTime::now()) } } impl fmt::Display for SteadyTime { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { // TODO: needs a display customization fmt::Debug::fmt(self, fmt) } } impl Sub for SteadyTime { type Output = Duration; fn sub(self, other: SteadyTime) -> Duration { self.0 - other.0 } } impl Sub for SteadyTime { type Output = SteadyTime; fn sub(self, other: Duration) -> SteadyTime { SteadyTime(self.0 - other) } } impl Add for SteadyTime { type Output = SteadyTime; fn add(self, other: Duration) -> SteadyTime { SteadyTime(self.0 + other) } } #[cfg(not(windows))] pub fn tzset() { extern { fn tzset(); } unsafe { tzset() } } #[cfg(windows)] pub fn tzset() {} /// Holds a calendar date and time broken down into its components (year, month, /// day, and so on), also called a broken-down time value. // FIXME: use c_int instead of i32? #[repr(C)] #[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] #[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))] pub struct Tm { /// Seconds after the minute - [0, 60] pub tm_sec: i32, /// Minutes after the hour - [0, 59] pub tm_min: i32, /// Hours after midnight - [0, 23] pub tm_hour: i32, /// Day of the month - [1, 31] pub tm_mday: i32, /// Months since January - [0, 11] pub tm_mon: i32, /// Years since 1900 pub tm_year: i32, /// Days since Sunday - [0, 6]. 0 = Sunday, 1 = Monday, ..., 6 = Saturday. pub tm_wday: i32, /// Days since January 1 - [0, 365] pub tm_yday: i32, /// Daylight Saving Time flag. /// /// This value is positive if Daylight Saving Time is in effect, zero if /// Daylight Saving Time is not in effect, and negative if this information /// is not available. pub tm_isdst: i32, /// Identifies the time zone that was used to compute this broken-down time /// value, including any adjustment for Daylight Saving Time. This is the /// number of seconds east of UTC. For example, for U.S. Pacific Daylight /// Time, the value is -7*60*60 = -25200. pub tm_utcoff: i32, /// Nanoseconds after the second - [0, 109 - 1] pub tm_nsec: i32, } impl Add for Tm { type Output = Tm; /// The resulting Tm is in UTC. // FIXME: The resulting Tm should have the same timezone as `self`; // however, we need a function such as `at_tm(clock: Timespec, offset: i32)` // for this. fn add(self, other: Duration) -> Tm { at_utc(self.to_timespec() + other) } } impl Sub for Tm { type Output = Tm; /// The resulting Tm is in UTC. // FIXME: The resulting Tm should have the same timezone as `self`; // however, we need a function such as `at_tm(clock: Timespec, offset: i32)` // for this. fn sub(self, other: Duration) -> Tm { at_utc(self.to_timespec() - other) } } impl Sub for Tm { type Output = Duration; fn sub(self, other: Tm) -> Duration { self.to_timespec() - other.to_timespec() } } impl PartialOrd for Tm { fn partial_cmp(&self, other: &Tm) -> Option { self.to_timespec().partial_cmp(&other.to_timespec()) } } impl Ord for Tm { fn cmp(&self, other: &Tm) -> Ordering { self.to_timespec().cmp(&other.to_timespec()) } } pub fn empty_tm() -> Tm { Tm { tm_sec: 0, tm_min: 0, tm_hour: 0, tm_mday: 0, tm_mon: 0, tm_year: 0, tm_wday: 0, tm_yday: 0, tm_isdst: 0, tm_utcoff: 0, tm_nsec: 0, } } /// Returns the specified time in UTC pub fn at_utc(clock: Timespec) -> Tm { let Timespec { sec, nsec } = clock; let mut tm = empty_tm(); sys::time_to_utc_tm(sec, &mut tm); tm.tm_nsec = nsec; tm } /// Returns the current time in UTC pub fn now_utc() -> Tm { at_utc(get_time()) } /// Returns the specified time in the local timezone pub fn at(clock: Timespec) -> Tm { let Timespec { sec, nsec } = clock; let mut tm = empty_tm(); sys::time_to_local_tm(sec, &mut tm); tm.tm_nsec = nsec; tm } /// Returns the current time in the local timezone pub fn now() -> Tm { at(get_time()) } impl Tm { /// Convert time to the seconds from January 1, 1970 pub fn to_timespec(&self) -> Timespec { let sec = match self.tm_utcoff { 0 => sys::utc_tm_to_time(self), _ => sys::local_tm_to_time(self) }; Timespec::new(sec, self.tm_nsec) } /// Convert time to the local timezone pub fn to_local(&self) -> Tm { at(self.to_timespec()) } /// Convert time to the UTC pub fn to_utc(&self) -> Tm { match self.tm_utcoff { 0 => *self, _ => at_utc(self.to_timespec()) } } /** * Returns a TmFmt that outputs according to the `asctime` format in ISO * C, in the local timezone. * * Example: "Thu Jan 1 00:00:00 1970" */ pub fn ctime(&self) -> TmFmt { TmFmt { tm: self, format: Fmt::Ctime, } } /** * Returns a TmFmt that outputs according to the `asctime` format in ISO * C. * * Example: "Thu Jan 1 00:00:00 1970" */ pub fn asctime(&self) -> TmFmt { TmFmt { tm: self, format: Fmt::Str("%c"), } } /// Formats the time according to the format string. pub fn strftime<'a>(&'a self, format: &'a str) -> Result, ParseError> { validate_format(TmFmt { tm: self, format: Fmt::Str(format), }) } /** * Returns a TmFmt that outputs according to RFC 822. * * local: "Thu, 22 Mar 2012 07:53:18 PST" * utc: "Thu, 22 Mar 2012 14:53:18 GMT" */ pub fn rfc822(&self) -> TmFmt { let fmt = if self.tm_utcoff == 0 { "%a, %d %b %Y %T GMT" } else { "%a, %d %b %Y %T %Z" }; TmFmt { tm: self, format: Fmt::Str(fmt), } } /** * Returns a TmFmt that outputs according to RFC 822 with Zulu time. * * local: "Thu, 22 Mar 2012 07:53:18 -0700" * utc: "Thu, 22 Mar 2012 14:53:18 -0000" */ pub fn rfc822z(&self) -> TmFmt { TmFmt { tm: self, format: Fmt::Str("%a, %d %b %Y %T %z"), } } /** * Returns a TmFmt that outputs according to RFC 3339. RFC 3339 is * compatible with ISO 8601. * * local: "2012-02-22T07:53:18-07:00" * utc: "2012-02-22T14:53:18Z" */ pub fn rfc3339<'a>(&'a self) -> TmFmt { TmFmt { tm: self, format: Fmt::Rfc3339, } } } #[derive(Copy, PartialEq, Debug, Clone)] pub enum ParseError { InvalidSecond, InvalidMinute, InvalidHour, InvalidDay, InvalidMonth, InvalidYear, InvalidDayOfWeek, InvalidDayOfMonth, InvalidDayOfYear, InvalidZoneOffset, InvalidTime, InvalidSecondsSinceEpoch, MissingFormatConverter, InvalidFormatSpecifier(char), UnexpectedCharacter(char, char), } impl fmt::Display for ParseError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { InvalidFormatSpecifier(ch) => { write!(f, "{}: %{}", self.description(), ch) } UnexpectedCharacter(a, b) => { write!(f, "expected: `{}`, found: `{}`", a, b) } _ => write!(f, "{}", self.description()) } } } impl Error for ParseError { fn description(&self) -> &str { match *self { InvalidSecond => "Invalid second.", InvalidMinute => "Invalid minute.", InvalidHour => "Invalid hour.", InvalidDay => "Invalid day.", InvalidMonth => "Invalid month.", InvalidYear => "Invalid year.", InvalidDayOfWeek => "Invalid day of the week.", InvalidDayOfMonth => "Invalid day of the month.", InvalidDayOfYear => "Invalid day of the year.", InvalidZoneOffset => "Invalid zone offset.", InvalidTime => "Invalid time.", InvalidSecondsSinceEpoch => "Invalid seconds since epoch.", MissingFormatConverter => "missing format converter after `%`", InvalidFormatSpecifier(..) => "invalid format specifier", UnexpectedCharacter(..) => "Unexpected character.", } } } /// A wrapper around a `Tm` and format string that implements Display. #[derive(Debug)] pub struct TmFmt<'a> { tm: &'a Tm, format: Fmt<'a> } #[derive(Debug)] enum Fmt<'a> { Str(&'a str), Rfc3339, Ctime, } fn validate_format<'a>(fmt: TmFmt<'a>) -> Result, ParseError> { match (fmt.tm.tm_wday, fmt.tm.tm_mon) { (0...6, 0...11) => (), (_wday, 0...11) => return Err(InvalidDayOfWeek), (0...6, _mon) => return Err(InvalidMonth), _ => return Err(InvalidDay) } match fmt.format { Fmt::Str(ref s) => { let mut chars = s.chars(); loop { match chars.next() { Some('%') => { match chars.next() { Some('A') | Some('a') | Some('B') | Some('b') | Some('C') | Some('c') | Some('D') | Some('d') | Some('e') | Some('F') | Some('f') | Some('G') | Some('g') | Some('H') | Some('h') | Some('I') | Some('j') | Some('k') | Some('l') | Some('M') | Some('m') | Some('n') | Some('P') | Some('p') | Some('R') | Some('r') | Some('S') | Some('s') | Some('T') | Some('t') | Some('U') | Some('u') | Some('V') | Some('v') | Some('W') | Some('w') | Some('X') | Some('x') | Some('Y') | Some('y') | Some('Z') | Some('z') | Some('+') | Some('%') => (), Some(c) => return Err(InvalidFormatSpecifier(c)), None => return Err(MissingFormatConverter), } }, None => break, _ => () } } }, _ => () } Ok(fmt) } /// Formats the time according to the format string. pub fn strftime(format: &str, tm: &Tm) -> Result { tm.strftime(format).map(|fmt| fmt.to_string()) } #[cfg(test)] mod tests { use super::{Timespec, get_time, precise_time_ns, precise_time_s, at_utc, at, strptime, PreciseTime, SteadyTime, ParseError, Duration}; use super::ParseError::{InvalidTime, InvalidYear, MissingFormatConverter, InvalidFormatSpecifier}; use std::sync::{Once, ONCE_INIT, Mutex, MutexGuard, LockResult}; use std::mem; struct TzReset { _tzreset: ::sys::TzReset, _lock: LockResult>, } fn set_time_zone_la_or_london(london: bool) -> TzReset { // Lock manages current timezone because some tests require LA some // London static mut LOCK: *mut Mutex<()> = 0 as *mut _; static INIT: Once = ONCE_INIT; unsafe { INIT.call_once(|| { LOCK = mem::transmute(Box::new(Mutex::new(()))); }); let timezone_lock = (*LOCK).lock(); let reset_func = if london { ::sys::set_london_with_dst_time_zone() } else { ::sys::set_los_angeles_time_zone() }; TzReset { _lock: timezone_lock, _tzreset: reset_func, } } } fn set_time_zone() -> TzReset { set_time_zone_la_or_london(false) } fn set_time_zone_london_dst() -> TzReset { set_time_zone_la_or_london(true) } #[test] fn test_get_time() { static SOME_RECENT_DATE: i64 = 1325376000i64; // 2012-01-01T00:00:00Z static SOME_FUTURE_DATE: i64 = 1577836800i64; // 2020-01-01T00:00:00Z let tv1 = get_time(); debug!("tv1={} sec + {} nsec", tv1.sec, tv1.nsec); assert!(tv1.sec > SOME_RECENT_DATE); assert!(tv1.nsec < 1000000000i32); let tv2 = get_time(); debug!("tv2={} sec + {} nsec", tv2.sec, tv2.nsec); assert!(tv2.sec >= tv1.sec); assert!(tv2.sec < SOME_FUTURE_DATE); assert!(tv2.nsec < 1000000000i32); if tv2.sec == tv1.sec { assert!(tv2.nsec >= tv1.nsec); } } #[test] fn test_precise_time() { let s0 = precise_time_s(); debug!("s0={} sec", s0); assert!(s0 > 0.); let ns0 = precise_time_ns(); let ns1 = precise_time_ns(); debug!("ns0={} ns", ns0); debug!("ns1={} ns", ns1); assert!(ns1 >= ns0); let ns2 = precise_time_ns(); debug!("ns2={} ns", ns2); assert!(ns2 >= ns1); } #[test] fn test_precise_time_to() { let t0 = PreciseTime(1000); let t1 = PreciseTime(1023); assert_eq!(Duration::nanoseconds(23), t0.to(t1)); } #[test] fn test_at_utc() { let _reset = set_time_zone(); let time = Timespec::new(1234567890, 54321); let utc = at_utc(time); assert_eq!(utc.tm_sec, 30); assert_eq!(utc.tm_min, 31); assert_eq!(utc.tm_hour, 23); assert_eq!(utc.tm_mday, 13); assert_eq!(utc.tm_mon, 1); assert_eq!(utc.tm_year, 109); assert_eq!(utc.tm_wday, 5); assert_eq!(utc.tm_yday, 43); assert_eq!(utc.tm_isdst, 0); assert_eq!(utc.tm_utcoff, 0); assert_eq!(utc.tm_nsec, 54321); } #[test] fn test_at() { let _reset = set_time_zone(); let time = Timespec::new(1234567890, 54321); let local = at(time); debug!("time_at: {:?}", local); assert_eq!(local.tm_sec, 30); assert_eq!(local.tm_min, 31); assert_eq!(local.tm_hour, 15); assert_eq!(local.tm_mday, 13); assert_eq!(local.tm_mon, 1); assert_eq!(local.tm_year, 109); assert_eq!(local.tm_wday, 5); assert_eq!(local.tm_yday, 43); assert_eq!(local.tm_isdst, 0); assert_eq!(local.tm_utcoff, -28800); assert_eq!(local.tm_nsec, 54321); } #[test] fn test_to_timespec() { let _reset = set_time_zone(); let time = Timespec::new(1234567890, 54321); let utc = at_utc(time); assert_eq!(utc.to_timespec(), time); assert_eq!(utc.to_local().to_timespec(), time); } #[test] fn test_conversions() { let _reset = set_time_zone(); let time = Timespec::new(1234567890, 54321); let utc = at_utc(time); let local = at(time); assert!(local.to_local() == local); assert!(local.to_utc() == utc); assert!(local.to_utc().to_local() == local); assert!(utc.to_utc() == utc); assert!(utc.to_local() == local); assert!(utc.to_local().to_utc() == utc); } #[test] fn test_strptime() { let _reset = set_time_zone(); match strptime("", "") { Ok(ref tm) => { assert!(tm.tm_sec == 0); assert!(tm.tm_min == 0); assert!(tm.tm_hour == 0); assert!(tm.tm_mday == 0); assert!(tm.tm_mon == 0); assert!(tm.tm_year == 0); assert!(tm.tm_wday == 0); assert!(tm.tm_isdst == 0); assert!(tm.tm_utcoff == 0); assert!(tm.tm_nsec == 0); } Err(_) => () } let format = "%a %b %e %T.%f %Y"; assert_eq!(strptime("", format), Err(ParseError::InvalidDay)); assert_eq!(strptime("Fri Feb 13 15:31:30", format), Err(InvalidTime)); match strptime("Fri Feb 13 15:31:30.01234 2009", format) { Err(e) => panic!("{}", e), Ok(ref tm) => { assert_eq!(tm.tm_sec, 30); assert_eq!(tm.tm_min, 31); assert_eq!(tm.tm_hour, 15); assert_eq!(tm.tm_mday, 13); assert_eq!(tm.tm_mon, 1); assert_eq!(tm.tm_year, 109); assert_eq!(tm.tm_wday, 5); assert_eq!(tm.tm_yday, 0); assert_eq!(tm.tm_isdst, 0); assert_eq!(tm.tm_utcoff, 0); assert_eq!(tm.tm_nsec, 12340000); } } fn test(s: &str, format: &str) -> bool { match strptime(s, format) { Ok(tm) => { tm.strftime(format).unwrap().to_string() == s.to_string() }, Err(e) => panic!("{:?}, s={:?}, format={:?}", e, s, format) } } fn test_oneway(s : &str, format : &str) -> bool { match strptime(s, format) { Ok(_) => { // oneway tests are used when reformatting the parsed Tm // back into a string can generate a different string // from the original (i.e. leading zeroes) true }, Err(e) => panic!("{:?}, s={:?}, format={:?}", e, s, format) } } let days = [ "Sunday".to_string(), "Monday".to_string(), "Tuesday".to_string(), "Wednesday".to_string(), "Thursday".to_string(), "Friday".to_string(), "Saturday".to_string() ]; for day in days.iter() { assert!(test(&day, "%A")); } let days = [ "Sun".to_string(), "Mon".to_string(), "Tue".to_string(), "Wed".to_string(), "Thu".to_string(), "Fri".to_string(), "Sat".to_string() ]; for day in days.iter() { assert!(test(&day, "%a")); } let months = [ "January".to_string(), "February".to_string(), "March".to_string(), "April".to_string(), "May".to_string(), "June".to_string(), "July".to_string(), "August".to_string(), "September".to_string(), "October".to_string(), "November".to_string(), "December".to_string() ]; for day in months.iter() { assert!(test(&day, "%B")); } let months = [ "Jan".to_string(), "Feb".to_string(), "Mar".to_string(), "Apr".to_string(), "May".to_string(), "Jun".to_string(), "Jul".to_string(), "Aug".to_string(), "Sep".to_string(), "Oct".to_string(), "Nov".to_string(), "Dec".to_string() ]; for day in months.iter() { assert!(test(&day, "%b")); } assert!(test("19", "%C")); assert!(test("Fri Feb 3 23:31:30 2009", "%c")); assert!(test("Fri Feb 13 23:31:30 2009", "%c")); assert!(test("02/13/09", "%D")); assert!(test("03", "%d")); assert!(test("13", "%d")); assert!(test(" 3", "%e")); assert!(test("13", "%e")); assert!(test("2009-02-13", "%F")); assert!(test("03", "%H")); assert!(test("13", "%H")); assert!(test("03", "%I")); // FIXME (#2350): flesh out assert!(test("11", "%I")); // FIXME (#2350): flesh out assert!(test("044", "%j")); assert!(test(" 3", "%k")); assert!(test("13", "%k")); assert!(test(" 1", "%l")); assert!(test("11", "%l")); assert!(test("03", "%M")); assert!(test("13", "%M")); assert!(test("\n", "%n")); assert!(test("am", "%P")); assert!(test("pm", "%P")); assert!(test("AM", "%p")); assert!(test("PM", "%p")); assert!(test("23:31", "%R")); assert!(test("11:31:30 AM", "%r")); assert!(test("11:31:30 PM", "%r")); assert!(test("03", "%S")); assert!(test("13", "%S")); assert!(test("15:31:30", "%T")); assert!(test("\t", "%t")); assert!(test("1", "%u")); assert!(test("7", "%u")); assert!(test("13-Feb-2009", "%v")); assert!(test("0", "%w")); assert!(test("6", "%w")); assert!(test("2009", "%Y")); assert!(test("09", "%y")); assert!(test_oneway("3", "%d")); assert!(test_oneway("3", "%H")); assert!(test_oneway("3", "%e")); assert!(test_oneway("3", "%M")); assert!(test_oneway("3", "%S")); assert!(strptime("-0000", "%z").unwrap().tm_utcoff == 0); assert!(strptime("-00:00", "%z").unwrap().tm_utcoff == 0); assert!(strptime("Z", "%z").unwrap().tm_utcoff == 0); assert_eq!(-28800, strptime("-0800", "%z").unwrap().tm_utcoff); assert_eq!(-28800, strptime("-08:00", "%z").unwrap().tm_utcoff); assert_eq!(28800, strptime("+0800", "%z").unwrap().tm_utcoff); assert_eq!(28800, strptime("+08:00", "%z").unwrap().tm_utcoff); assert_eq!(5400, strptime("+0130", "%z").unwrap().tm_utcoff); assert_eq!(5400, strptime("+01:30", "%z").unwrap().tm_utcoff); assert!(test("%", "%%")); // Test for #7256 assert_eq!(strptime("360", "%Y-%m-%d"), Err(InvalidYear)); // Test for epoch seconds parsing { assert!(test("1428035610", "%s")); let tm = strptime("1428035610", "%s").unwrap(); assert_eq!(tm.tm_utcoff, 0); assert_eq!(tm.tm_isdst, 0); assert_eq!(tm.tm_yday, 92); assert_eq!(tm.tm_wday, 5); assert_eq!(tm.tm_year, 115); assert_eq!(tm.tm_mon, 3); assert_eq!(tm.tm_mday, 3); assert_eq!(tm.tm_hour, 4); } } #[test] fn test_asctime() { let _reset = set_time_zone(); let time = Timespec::new(1234567890, 54321); let utc = at_utc(time); let local = at(time); debug!("test_ctime: {} {}", utc.asctime(), local.asctime()); assert_eq!(utc.asctime().to_string(), "Fri Feb 13 23:31:30 2009".to_string()); assert_eq!(local.asctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string()); } #[test] fn test_ctime() { let _reset = set_time_zone(); let time = Timespec::new(1234567890, 54321); let utc = at_utc(time); let local = at(time); debug!("test_ctime: {} {}", utc.ctime(), local.ctime()); assert_eq!(utc.ctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string()); assert_eq!(local.ctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string()); } #[test] fn test_strftime() { let _reset = set_time_zone(); let time = Timespec::new(1234567890, 54321); let utc = at_utc(time); let local = at(time); assert_eq!(local.strftime("").unwrap().to_string(), "".to_string()); assert_eq!(local.strftime("%A").unwrap().to_string(), "Friday".to_string()); assert_eq!(local.strftime("%a").unwrap().to_string(), "Fri".to_string()); assert_eq!(local.strftime("%B").unwrap().to_string(), "February".to_string()); assert_eq!(local.strftime("%b").unwrap().to_string(), "Feb".to_string()); assert_eq!(local.strftime("%C").unwrap().to_string(), "20".to_string()); assert_eq!(local.strftime("%c").unwrap().to_string(), "Fri Feb 13 15:31:30 2009".to_string()); assert_eq!(local.strftime("%D").unwrap().to_string(), "02/13/09".to_string()); assert_eq!(local.strftime("%d").unwrap().to_string(), "13".to_string()); assert_eq!(local.strftime("%e").unwrap().to_string(), "13".to_string()); assert_eq!(local.strftime("%F").unwrap().to_string(), "2009-02-13".to_string()); assert_eq!(local.strftime("%f").unwrap().to_string(), "000054321".to_string()); assert_eq!(local.strftime("%G").unwrap().to_string(), "2009".to_string()); assert_eq!(local.strftime("%g").unwrap().to_string(), "09".to_string()); assert_eq!(local.strftime("%H").unwrap().to_string(), "15".to_string()); assert_eq!(local.strftime("%h").unwrap().to_string(), "Feb".to_string()); assert_eq!(local.strftime("%I").unwrap().to_string(), "03".to_string()); assert_eq!(local.strftime("%j").unwrap().to_string(), "044".to_string()); assert_eq!(local.strftime("%k").unwrap().to_string(), "15".to_string()); assert_eq!(local.strftime("%l").unwrap().to_string(), " 3".to_string()); assert_eq!(local.strftime("%M").unwrap().to_string(), "31".to_string()); assert_eq!(local.strftime("%m").unwrap().to_string(), "02".to_string()); assert_eq!(local.strftime("%n").unwrap().to_string(), "\n".to_string()); assert_eq!(local.strftime("%P").unwrap().to_string(), "pm".to_string()); assert_eq!(local.strftime("%p").unwrap().to_string(), "PM".to_string()); assert_eq!(local.strftime("%R").unwrap().to_string(), "15:31".to_string()); assert_eq!(local.strftime("%r").unwrap().to_string(), "03:31:30 PM".to_string()); assert_eq!(local.strftime("%S").unwrap().to_string(), "30".to_string()); assert_eq!(local.strftime("%s").unwrap().to_string(), "1234567890".to_string()); assert_eq!(local.strftime("%T").unwrap().to_string(), "15:31:30".to_string()); assert_eq!(local.strftime("%t").unwrap().to_string(), "\t".to_string()); assert_eq!(local.strftime("%U").unwrap().to_string(), "06".to_string()); assert_eq!(local.strftime("%u").unwrap().to_string(), "5".to_string()); assert_eq!(local.strftime("%V").unwrap().to_string(), "07".to_string()); assert_eq!(local.strftime("%v").unwrap().to_string(), "13-Feb-2009".to_string()); assert_eq!(local.strftime("%W").unwrap().to_string(), "06".to_string()); assert_eq!(local.strftime("%w").unwrap().to_string(), "5".to_string()); // FIXME (#2350): support locale assert_eq!(local.strftime("%X").unwrap().to_string(), "15:31:30".to_string()); // FIXME (#2350): support locale assert_eq!(local.strftime("%x").unwrap().to_string(), "02/13/09".to_string()); assert_eq!(local.strftime("%Y").unwrap().to_string(), "2009".to_string()); assert_eq!(local.strftime("%y").unwrap().to_string(), "09".to_string()); // FIXME (#2350): support locale assert_eq!(local.strftime("%Z").unwrap().to_string(), "".to_string()); assert_eq!(local.strftime("%z").unwrap().to_string(), "-0800".to_string()); assert_eq!(local.strftime("%+").unwrap().to_string(), "2009-02-13T15:31:30-08:00".to_string()); assert_eq!(local.strftime("%%").unwrap().to_string(), "%".to_string()); let invalid_specifiers = ["%E", "%J", "%K", "%L", "%N", "%O", "%o", "%Q", "%q"]; for &sp in invalid_specifiers.iter() { assert_eq!(local.strftime(sp).unwrap_err(), InvalidFormatSpecifier(sp[1..].chars().next().unwrap())); } assert_eq!(local.strftime("%").unwrap_err(), MissingFormatConverter); assert_eq!(local.strftime("%A %").unwrap_err(), MissingFormatConverter); assert_eq!(local.asctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string()); assert_eq!(local.ctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string()); assert_eq!(local.rfc822z().to_string(), "Fri, 13 Feb 2009 15:31:30 -0800".to_string()); assert_eq!(local.rfc3339().to_string(), "2009-02-13T15:31:30-08:00".to_string()); assert_eq!(utc.asctime().to_string(), "Fri Feb 13 23:31:30 2009".to_string()); assert_eq!(utc.ctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string()); assert_eq!(utc.rfc822().to_string(), "Fri, 13 Feb 2009 23:31:30 GMT".to_string()); assert_eq!(utc.rfc822z().to_string(), "Fri, 13 Feb 2009 23:31:30 -0000".to_string()); assert_eq!(utc.rfc3339().to_string(), "2009-02-13T23:31:30Z".to_string()); } #[test] fn test_timespec_eq_ord() { let a = &Timespec::new(-2, 1); let b = &Timespec::new(-1, 2); let c = &Timespec::new(1, 2); let d = &Timespec::new(2, 1); let e = &Timespec::new(2, 1); assert!(d.eq(e)); assert!(c.ne(e)); assert!(a.lt(b)); assert!(b.lt(c)); assert!(c.lt(d)); assert!(a.le(b)); assert!(b.le(c)); assert!(c.le(d)); assert!(d.le(e)); assert!(e.le(d)); assert!(b.ge(a)); assert!(c.ge(b)); assert!(d.ge(c)); assert!(e.ge(d)); assert!(d.ge(e)); assert!(b.gt(a)); assert!(c.gt(b)); assert!(d.gt(c)); } #[test] fn test_timespec_hash() { use std::hash::{Hash, Hasher}; let c = &Timespec::new(3, 2); let d = &Timespec::new(2, 1); let e = &Timespec::new(2, 1); let mut hasher = ::std::hash::SipHasher::new(); let d_hash:u64 = { d.hash(&mut hasher); hasher.finish() }; hasher = ::std::hash::SipHasher::new(); let e_hash:u64 = { e.hash(&mut hasher); hasher.finish() }; hasher = ::std::hash::SipHasher::new(); let c_hash:u64 = { c.hash(&mut hasher); hasher.finish() }; assert_eq!(d_hash, e_hash); assert!(c_hash != e_hash); } #[test] fn test_timespec_add() { let a = Timespec::new(1, 2); let b = Duration::seconds(2) + Duration::nanoseconds(3); let c = a + b; assert_eq!(c.sec, 3); assert_eq!(c.nsec, 5); let p = Timespec::new(1, super::NSEC_PER_SEC - 2); let q = Duration::seconds(2) + Duration::nanoseconds(2); let r = p + q; assert_eq!(r.sec, 4); assert_eq!(r.nsec, 0); let u = Timespec::new(1, super::NSEC_PER_SEC - 2); let v = Duration::seconds(2) + Duration::nanoseconds(3); let w = u + v; assert_eq!(w.sec, 4); assert_eq!(w.nsec, 1); let k = Timespec::new(1, 0); let l = Duration::nanoseconds(-1); let m = k + l; assert_eq!(m.sec, 0); assert_eq!(m.nsec, 999_999_999); } #[test] fn test_timespec_sub() { let a = Timespec::new(2, 3); let b = Timespec::new(1, 2); let c = a - b; assert_eq!(c.num_nanoseconds(), Some(super::NSEC_PER_SEC as i64 + 1)); let p = Timespec::new(2, 0); let q = Timespec::new(1, 2); let r = p - q; assert_eq!(r.num_nanoseconds(), Some(super::NSEC_PER_SEC as i64 - 2)); let u = Timespec::new(1, 2); let v = Timespec::new(2, 3); let w = u - v; assert_eq!(w.num_nanoseconds(), Some(-super::NSEC_PER_SEC as i64 - 1)); } #[test] fn test_time_sub() { let a = ::now(); let b = at(a.to_timespec() + Duration::seconds(5)); let c = b - a; assert_eq!(c.num_nanoseconds(), Some(super::NSEC_PER_SEC as i64 * 5)); } #[test] fn test_steadytime_sub() { let a = SteadyTime::now(); let b = a + Duration::seconds(1); assert_eq!(b - a, Duration::seconds(1)); assert_eq!(a - b, Duration::seconds(-1)); } #[test] fn test_date_before_1970() { let early = strptime("1901-01-06", "%F").unwrap(); let late = strptime("2000-01-01", "%F").unwrap(); assert!(early < late); } #[test] fn test_dst() { let _reset = set_time_zone_london_dst(); let utc_in_feb = strptime("2015-02-01Z", "%F%z").unwrap(); let utc_in_jun = strptime("2015-06-01Z", "%F%z").unwrap(); let utc_in_nov = strptime("2015-11-01Z", "%F%z").unwrap(); let local_in_feb = utc_in_feb.to_local(); let local_in_jun = utc_in_jun.to_local(); let local_in_nov = utc_in_nov.to_local(); assert_eq!(local_in_feb.tm_mon, 1); assert_eq!(local_in_feb.tm_hour, 0); assert_eq!(local_in_feb.tm_utcoff, 0); assert_eq!(local_in_feb.tm_isdst, 0); assert_eq!(local_in_jun.tm_mon, 5); assert_eq!(local_in_jun.tm_hour, 1); assert_eq!(local_in_jun.tm_utcoff, 3600); assert_eq!(local_in_jun.tm_isdst, 1); assert_eq!(local_in_nov.tm_mon, 10); assert_eq!(local_in_nov.tm_hour, 0); assert_eq!(local_in_nov.tm_utcoff, 0); assert_eq!(local_in_nov.tm_isdst, 0) } } deps/time-0.1.34/src/duration.rs0000664000175000017500000005430712521343601013402 0ustar // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Temporal quantification use std::{fmt, i64}; use std::ops::{Add, Sub, Mul, Div, Neg, FnOnce}; /// The number of nanoseconds in a microsecond. const NANOS_PER_MICRO: i32 = 1000; /// The number of nanoseconds in a millisecond. const NANOS_PER_MILLI: i32 = 1000_000; /// The number of nanoseconds in seconds. const NANOS_PER_SEC: i32 = 1_000_000_000; /// The number of microseconds per second. const MICROS_PER_SEC: i64 = 1000_000; /// The number of milliseconds per second. const MILLIS_PER_SEC: i64 = 1000; /// The number of seconds in a minute. const SECS_PER_MINUTE: i64 = 60; /// The number of seconds in an hour. const SECS_PER_HOUR: i64 = 3600; /// The number of (non-leap) seconds in days. const SECS_PER_DAY: i64 = 86400; /// The number of (non-leap) seconds in a week. const SECS_PER_WEEK: i64 = 604800; macro_rules! try_opt { ($e:expr) => (match $e { Some(v) => v, None => return None }) } /// ISO 8601 time duration with nanosecond precision. /// This also allows for the negative duration; see individual methods for details. #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] pub struct Duration { secs: i64, nanos: i32, // Always 0 <= nanos < NANOS_PER_SEC } /// The minimum possible `Duration`: `i64::MIN` milliseconds. pub const MIN: Duration = Duration { secs: i64::MIN / MILLIS_PER_SEC - 1, nanos: NANOS_PER_SEC + (i64::MIN % MILLIS_PER_SEC) as i32 * NANOS_PER_MILLI }; /// The maximum possible `Duration`: `i64::MAX` milliseconds. pub const MAX: Duration = Duration { secs: i64::MAX / MILLIS_PER_SEC, nanos: (i64::MAX % MILLIS_PER_SEC) as i32 * NANOS_PER_MILLI }; impl Duration { /// Makes a new `Duration` with given number of weeks. /// Equivalent to `Duration::seconds(weeks * 7 * 24 * 60 * 60)` with overflow checks. /// Panics when the duration is out of bounds. #[inline] pub fn weeks(weeks: i64) -> Duration { let secs = weeks.checked_mul(SECS_PER_WEEK).expect("Duration::weeks out of bounds"); Duration::seconds(secs) } /// Makes a new `Duration` with given number of days. /// Equivalent to `Duration::seconds(days * 24 * 60 * 60)` with overflow checks. /// Panics when the duration is out of bounds. #[inline] pub fn days(days: i64) -> Duration { let secs = days.checked_mul(SECS_PER_DAY).expect("Duration::days out of bounds"); Duration::seconds(secs) } /// Makes a new `Duration` with given number of hours. /// Equivalent to `Duration::seconds(hours * 60 * 60)` with overflow checks. /// Panics when the duration is out of bounds. #[inline] pub fn hours(hours: i64) -> Duration { let secs = hours.checked_mul(SECS_PER_HOUR).expect("Duration::hours ouf of bounds"); Duration::seconds(secs) } /// Makes a new `Duration` with given number of minutes. /// Equivalent to `Duration::seconds(minutes * 60)` with overflow checks. /// Panics when the duration is out of bounds. #[inline] pub fn minutes(minutes: i64) -> Duration { let secs = minutes.checked_mul(SECS_PER_MINUTE).expect("Duration::minutes out of bounds"); Duration::seconds(secs) } /// Makes a new `Duration` with given number of seconds. /// Panics when the duration is more than `i64::MAX` milliseconds /// or less than `i64::MIN` milliseconds. #[inline] pub fn seconds(seconds: i64) -> Duration { let d = Duration { secs: seconds, nanos: 0 }; if d < MIN || d > MAX { panic!("Duration::seconds out of bounds"); } d } /// Makes a new `Duration` with given number of milliseconds. #[inline] pub fn milliseconds(milliseconds: i64) -> Duration { let (secs, millis) = div_mod_floor_64(milliseconds, MILLIS_PER_SEC); let nanos = millis as i32 * NANOS_PER_MILLI; Duration { secs: secs, nanos: nanos } } /// Makes a new `Duration` with given number of microseconds. #[inline] pub fn microseconds(microseconds: i64) -> Duration { let (secs, micros) = div_mod_floor_64(microseconds, MICROS_PER_SEC); let nanos = micros as i32 * NANOS_PER_MICRO; Duration { secs: secs, nanos: nanos } } /// Makes a new `Duration` with given number of nanoseconds. #[inline] pub fn nanoseconds(nanos: i64) -> Duration { let (secs, nanos) = div_mod_floor_64(nanos, NANOS_PER_SEC as i64); Duration { secs: secs, nanos: nanos as i32 } } /// Runs a closure, returning the duration of time it took to run the /// closure. pub fn span(f: F) -> Duration where F: FnOnce() { let before = super::precise_time_ns(); f(); Duration::nanoseconds((super::precise_time_ns() - before) as i64) } /// Returns the total number of whole weeks in the duration. #[inline] pub fn num_weeks(&self) -> i64 { self.num_days() / 7 } /// Returns the total number of whole days in the duration. pub fn num_days(&self) -> i64 { self.num_seconds() / SECS_PER_DAY } /// Returns the total number of whole hours in the duration. #[inline] pub fn num_hours(&self) -> i64 { self.num_seconds() / SECS_PER_HOUR } /// Returns the total number of whole minutes in the duration. #[inline] pub fn num_minutes(&self) -> i64 { self.num_seconds() / SECS_PER_MINUTE } /// Returns the total number of whole seconds in the duration. pub fn num_seconds(&self) -> i64 { // If secs is negative, nanos should be subtracted from the duration. if self.secs < 0 && self.nanos > 0 { self.secs + 1 } else { self.secs } } /// Returns the number of nanoseconds such that /// `nanos_mod_sec() + num_seconds() * NANOS_PER_SEC` is the total number of /// nanoseconds in the duration. fn nanos_mod_sec(&self) -> i32 { if self.secs < 0 && self.nanos > 0 { self.nanos - NANOS_PER_SEC } else { self.nanos } } /// Returns the total number of whole milliseconds in the duration, pub fn num_milliseconds(&self) -> i64 { // A proper Duration will not overflow, because MIN and MAX are defined // such that the range is exactly i64 milliseconds. let secs_part = self.num_seconds() * MILLIS_PER_SEC; let nanos_part = self.nanos_mod_sec() / NANOS_PER_MILLI; secs_part + nanos_part as i64 } /// Returns the total number of whole microseconds in the duration, /// or `None` on overflow (exceeding 2^63 microseconds in either direction). pub fn num_microseconds(&self) -> Option { let secs_part = try_opt!(self.num_seconds().checked_mul(MICROS_PER_SEC)); let nanos_part = self.nanos_mod_sec() / NANOS_PER_MICRO; secs_part.checked_add(nanos_part as i64) } /// Returns the total number of whole nanoseconds in the duration, /// or `None` on overflow (exceeding 2^63 nanoseconds in either direction). pub fn num_nanoseconds(&self) -> Option { let secs_part = try_opt!(self.num_seconds().checked_mul(NANOS_PER_SEC as i64)); let nanos_part = self.nanos_mod_sec(); secs_part.checked_add(nanos_part as i64) } /// Add two durations, returning `None` if overflow occurred. pub fn checked_add(&self, rhs: &Duration) -> Option { let mut secs = try_opt!(self.secs.checked_add(rhs.secs)); let mut nanos = self.nanos + rhs.nanos; if nanos >= NANOS_PER_SEC { nanos -= NANOS_PER_SEC; secs = try_opt!(secs.checked_add(1)); } let d = Duration { secs: secs, nanos: nanos }; // Even if d is within the bounds of i64 seconds, // it might still overflow i64 milliseconds. if d < MIN || d > MAX { None } else { Some(d) } } /// Subtract two durations, returning `None` if overflow occurred. pub fn checked_sub(&self, rhs: &Duration) -> Option { let mut secs = try_opt!(self.secs.checked_sub(rhs.secs)); let mut nanos = self.nanos - rhs.nanos; if nanos < 0 { nanos += NANOS_PER_SEC; secs = try_opt!(secs.checked_sub(1)); } let d = Duration { secs: secs, nanos: nanos }; // Even if d is within the bounds of i64 seconds, // it might still overflow i64 milliseconds. if d < MIN || d > MAX { None } else { Some(d) } } /// The minimum possible `Duration`: `i64::MIN` milliseconds. #[inline] pub fn min_value() -> Duration { MIN } /// The maximum possible `Duration`: `i64::MAX` milliseconds. #[inline] pub fn max_value() -> Duration { MAX } /// A duration where the stored seconds and nanoseconds are equal to zero. #[inline] pub fn zero() -> Duration { Duration { secs: 0, nanos: 0 } } /// Returns `true` if the duration equals `Duration::zero()`. #[inline] pub fn is_zero(&self) -> bool { self.secs == 0 && self.nanos == 0 } } impl Neg for Duration { type Output = Duration; #[inline] fn neg(self) -> Duration { if self.nanos == 0 { Duration { secs: -self.secs, nanos: 0 } } else { Duration { secs: -self.secs - 1, nanos: NANOS_PER_SEC - self.nanos } } } } impl Add for Duration { type Output = Duration; fn add(self, rhs: Duration) -> Duration { let mut secs = self.secs + rhs.secs; let mut nanos = self.nanos + rhs.nanos; if nanos >= NANOS_PER_SEC { nanos -= NANOS_PER_SEC; secs += 1; } Duration { secs: secs, nanos: nanos } } } impl Sub for Duration { type Output = Duration; fn sub(self, rhs: Duration) -> Duration { let mut secs = self.secs - rhs.secs; let mut nanos = self.nanos - rhs.nanos; if nanos < 0 { nanos += NANOS_PER_SEC; secs -= 1; } Duration { secs: secs, nanos: nanos } } } impl Mul for Duration { type Output = Duration; fn mul(self, rhs: i32) -> Duration { // Multiply nanoseconds as i64, because it cannot overflow that way. let total_nanos = self.nanos as i64 * rhs as i64; let (extra_secs, nanos) = div_mod_floor_64(total_nanos, NANOS_PER_SEC as i64); let secs = self.secs * rhs as i64 + extra_secs; Duration { secs: secs, nanos: nanos as i32 } } } impl Div for Duration { type Output = Duration; fn div(self, rhs: i32) -> Duration { let mut secs = self.secs / rhs as i64; let carry = self.secs - secs * rhs as i64; let extra_nanos = carry * NANOS_PER_SEC as i64 / rhs as i64; let mut nanos = self.nanos / rhs + extra_nanos as i32; if nanos >= NANOS_PER_SEC { nanos -= NANOS_PER_SEC; secs += 1; } if nanos < 0 { nanos += NANOS_PER_SEC; secs -= 1; } Duration { secs: secs, nanos: nanos } } } impl fmt::Display for Duration { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // technically speaking, negative duration is not valid ISO 8601, // but we need to print it anyway. let (abs, sign) = if self.secs < 0 { (-*self, "-") } else { (*self, "") }; let days = abs.secs / SECS_PER_DAY; let secs = abs.secs - days * SECS_PER_DAY; let hasdate = days != 0; let hastime = (secs != 0 || abs.nanos != 0) || !hasdate; try!(write!(f, "{}P", sign)); if hasdate { try!(write!(f, "{}D", days)); } if hastime { if abs.nanos == 0 { try!(write!(f, "T{}S", secs)); } else if abs.nanos % NANOS_PER_MILLI == 0 { try!(write!(f, "T{}.{:03}S", secs, abs.nanos / NANOS_PER_MILLI)); } else if abs.nanos % NANOS_PER_MICRO == 0 { try!(write!(f, "T{}.{:06}S", secs, abs.nanos / NANOS_PER_MICRO)); } else { try!(write!(f, "T{}.{:09}S", secs, abs.nanos)); } } Ok(()) } } // Copied from libnum #[inline] fn div_mod_floor_64(this: i64, other: i64) -> (i64, i64) { (div_floor_64(this, other), mod_floor_64(this, other)) } #[inline] fn div_floor_64(this: i64, other: i64) -> i64 { match div_rem_64(this, other) { (d, r) if (r > 0 && other < 0) || (r < 0 && other > 0) => d - 1, (d, _) => d, } } #[inline] fn mod_floor_64(this: i64, other: i64) -> i64 { match this % other { r if (r > 0 && other < 0) || (r < 0 && other > 0) => r + other, r => r, } } #[inline] fn div_rem_64(this: i64, other: i64) -> (i64, i64) { (this / other, this % other) } #[cfg(test)] mod tests { use super::{Duration, MIN, MAX}; use std::{i32, i64}; #[test] fn test_duration() { assert!(Duration::seconds(1) != Duration::zero()); assert_eq!(Duration::seconds(1) + Duration::seconds(2), Duration::seconds(3)); assert_eq!(Duration::seconds(86399) + Duration::seconds(4), Duration::days(1) + Duration::seconds(3)); assert_eq!(Duration::days(10) - Duration::seconds(1000), Duration::seconds(863000)); assert_eq!(Duration::days(10) - Duration::seconds(1000000), Duration::seconds(-136000)); assert_eq!(Duration::days(2) + Duration::seconds(86399) + Duration::nanoseconds(1234567890), Duration::days(3) + Duration::nanoseconds(234567890)); assert_eq!(-Duration::days(3), Duration::days(-3)); assert_eq!(-(Duration::days(3) + Duration::seconds(70)), Duration::days(-4) + Duration::seconds(86400-70)); } #[test] fn test_duration_num_days() { assert_eq!(Duration::zero().num_days(), 0); assert_eq!(Duration::days(1).num_days(), 1); assert_eq!(Duration::days(-1).num_days(), -1); assert_eq!(Duration::seconds(86399).num_days(), 0); assert_eq!(Duration::seconds(86401).num_days(), 1); assert_eq!(Duration::seconds(-86399).num_days(), 0); assert_eq!(Duration::seconds(-86401).num_days(), -1); assert_eq!(Duration::days(i32::MAX as i64).num_days(), i32::MAX as i64); assert_eq!(Duration::days(i32::MIN as i64).num_days(), i32::MIN as i64); } #[test] fn test_duration_num_seconds() { assert_eq!(Duration::zero().num_seconds(), 0); assert_eq!(Duration::seconds(1).num_seconds(), 1); assert_eq!(Duration::seconds(-1).num_seconds(), -1); assert_eq!(Duration::milliseconds(999).num_seconds(), 0); assert_eq!(Duration::milliseconds(1001).num_seconds(), 1); assert_eq!(Duration::milliseconds(-999).num_seconds(), 0); assert_eq!(Duration::milliseconds(-1001).num_seconds(), -1); } #[test] fn test_duration_num_milliseconds() { assert_eq!(Duration::zero().num_milliseconds(), 0); assert_eq!(Duration::milliseconds(1).num_milliseconds(), 1); assert_eq!(Duration::milliseconds(-1).num_milliseconds(), -1); assert_eq!(Duration::microseconds(999).num_milliseconds(), 0); assert_eq!(Duration::microseconds(1001).num_milliseconds(), 1); assert_eq!(Duration::microseconds(-999).num_milliseconds(), 0); assert_eq!(Duration::microseconds(-1001).num_milliseconds(), -1); assert_eq!(Duration::milliseconds(i64::MAX).num_milliseconds(), i64::MAX); assert_eq!(Duration::milliseconds(i64::MIN).num_milliseconds(), i64::MIN); assert_eq!(MAX.num_milliseconds(), i64::MAX); assert_eq!(MIN.num_milliseconds(), i64::MIN); } #[test] fn test_duration_num_microseconds() { assert_eq!(Duration::zero().num_microseconds(), Some(0)); assert_eq!(Duration::microseconds(1).num_microseconds(), Some(1)); assert_eq!(Duration::microseconds(-1).num_microseconds(), Some(-1)); assert_eq!(Duration::nanoseconds(999).num_microseconds(), Some(0)); assert_eq!(Duration::nanoseconds(1001).num_microseconds(), Some(1)); assert_eq!(Duration::nanoseconds(-999).num_microseconds(), Some(0)); assert_eq!(Duration::nanoseconds(-1001).num_microseconds(), Some(-1)); assert_eq!(Duration::microseconds(i64::MAX).num_microseconds(), Some(i64::MAX)); assert_eq!(Duration::microseconds(i64::MIN).num_microseconds(), Some(i64::MIN)); assert_eq!(MAX.num_microseconds(), None); assert_eq!(MIN.num_microseconds(), None); // overflow checks const MICROS_PER_DAY: i64 = 86400_000_000; assert_eq!(Duration::days(i64::MAX / MICROS_PER_DAY).num_microseconds(), Some(i64::MAX / MICROS_PER_DAY * MICROS_PER_DAY)); assert_eq!(Duration::days(i64::MIN / MICROS_PER_DAY).num_microseconds(), Some(i64::MIN / MICROS_PER_DAY * MICROS_PER_DAY)); assert_eq!(Duration::days(i64::MAX / MICROS_PER_DAY + 1).num_microseconds(), None); assert_eq!(Duration::days(i64::MIN / MICROS_PER_DAY - 1).num_microseconds(), None); } #[test] fn test_duration_num_nanoseconds() { assert_eq!(Duration::zero().num_nanoseconds(), Some(0)); assert_eq!(Duration::nanoseconds(1).num_nanoseconds(), Some(1)); assert_eq!(Duration::nanoseconds(-1).num_nanoseconds(), Some(-1)); assert_eq!(Duration::nanoseconds(i64::MAX).num_nanoseconds(), Some(i64::MAX)); assert_eq!(Duration::nanoseconds(i64::MIN).num_nanoseconds(), Some(i64::MIN)); assert_eq!(MAX.num_nanoseconds(), None); assert_eq!(MIN.num_nanoseconds(), None); // overflow checks const NANOS_PER_DAY: i64 = 86400_000_000_000; assert_eq!(Duration::days(i64::MAX / NANOS_PER_DAY).num_nanoseconds(), Some(i64::MAX / NANOS_PER_DAY * NANOS_PER_DAY)); assert_eq!(Duration::days(i64::MIN / NANOS_PER_DAY).num_nanoseconds(), Some(i64::MIN / NANOS_PER_DAY * NANOS_PER_DAY)); assert_eq!(Duration::days(i64::MAX / NANOS_PER_DAY + 1).num_nanoseconds(), None); assert_eq!(Duration::days(i64::MIN / NANOS_PER_DAY - 1).num_nanoseconds(), None); } #[test] fn test_duration_checked_ops() { assert_eq!(Duration::milliseconds(i64::MAX - 1).checked_add(&Duration::microseconds(999)), Some(Duration::milliseconds(i64::MAX - 2) + Duration::microseconds(1999))); assert!(Duration::milliseconds(i64::MAX).checked_add(&Duration::microseconds(1000)) .is_none()); assert_eq!(Duration::milliseconds(i64::MIN).checked_sub(&Duration::milliseconds(0)), Some(Duration::milliseconds(i64::MIN))); assert!(Duration::milliseconds(i64::MIN).checked_sub(&Duration::milliseconds(1)) .is_none()); } #[test] fn test_duration_mul() { assert_eq!(Duration::zero() * i32::MAX, Duration::zero()); assert_eq!(Duration::zero() * i32::MIN, Duration::zero()); assert_eq!(Duration::nanoseconds(1) * 0, Duration::zero()); assert_eq!(Duration::nanoseconds(1) * 1, Duration::nanoseconds(1)); assert_eq!(Duration::nanoseconds(1) * 1_000_000_000, Duration::seconds(1)); assert_eq!(Duration::nanoseconds(1) * -1_000_000_000, -Duration::seconds(1)); assert_eq!(-Duration::nanoseconds(1) * 1_000_000_000, -Duration::seconds(1)); assert_eq!(Duration::nanoseconds(30) * 333_333_333, Duration::seconds(10) - Duration::nanoseconds(10)); assert_eq!((Duration::nanoseconds(1) + Duration::seconds(1) + Duration::days(1)) * 3, Duration::nanoseconds(3) + Duration::seconds(3) + Duration::days(3)); assert_eq!(Duration::milliseconds(1500) * -2, Duration::seconds(-3)); assert_eq!(Duration::milliseconds(-1500) * 2, Duration::seconds(-3)); } #[test] fn test_duration_div() { assert_eq!(Duration::zero() / i32::MAX, Duration::zero()); assert_eq!(Duration::zero() / i32::MIN, Duration::zero()); assert_eq!(Duration::nanoseconds(123_456_789) / 1, Duration::nanoseconds(123_456_789)); assert_eq!(Duration::nanoseconds(123_456_789) / -1, -Duration::nanoseconds(123_456_789)); assert_eq!(-Duration::nanoseconds(123_456_789) / -1, Duration::nanoseconds(123_456_789)); assert_eq!(-Duration::nanoseconds(123_456_789) / 1, -Duration::nanoseconds(123_456_789)); assert_eq!(Duration::seconds(1) / 3, Duration::nanoseconds(333_333_333)); assert_eq!(Duration::seconds(4) / 3, Duration::nanoseconds(1_333_333_333)); assert_eq!(Duration::seconds(-1) / 2, Duration::milliseconds(-500)); assert_eq!(Duration::seconds(1) / -2, Duration::milliseconds(-500)); assert_eq!(Duration::seconds(-1) / -2, Duration::milliseconds(500)); assert_eq!(Duration::seconds(-4) / 3, Duration::nanoseconds(-1_333_333_333)); assert_eq!(Duration::seconds(-4) / -3, Duration::nanoseconds(1_333_333_333)); } #[test] fn test_duration_fmt() { assert_eq!(Duration::zero().to_string(), "PT0S"); assert_eq!(Duration::days(42).to_string(), "P42D"); assert_eq!(Duration::days(-42).to_string(), "-P42D"); assert_eq!(Duration::seconds(42).to_string(), "PT42S"); assert_eq!(Duration::milliseconds(42).to_string(), "PT0.042S"); assert_eq!(Duration::microseconds(42).to_string(), "PT0.000042S"); assert_eq!(Duration::nanoseconds(42).to_string(), "PT0.000000042S"); assert_eq!((Duration::days(7) + Duration::milliseconds(6543)).to_string(), "P7DT6.543S"); assert_eq!(Duration::seconds(-86401).to_string(), "-P1DT1S"); assert_eq!(Duration::nanoseconds(-1).to_string(), "-PT0.000000001S"); // the format specifier should have no effect on `Duration` assert_eq!(format!("{:30}", Duration::days(1) + Duration::milliseconds(2345)), "P1DT2.345S"); } } deps/time-0.1.34/src/display.rs0000664000175000017500000002103112521343601013206 0ustar use std::fmt::{self, Display}; use super::{TmFmt, Tm, Fmt}; impl<'a> fmt::Display for TmFmt<'a> { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match self.format { Fmt::Str(ref s) => { let mut chars = s.chars(); while let Some(ch) = chars.next() { if ch == '%' { // we've already validated that % always precedes // another char try!(parse_type(fmt, chars.next().unwrap(), self.tm)); } else { try!(write!(fmt, "{}", ch)); } } Ok(()) } Fmt::Ctime => self.tm.to_local().asctime().fmt(fmt), Fmt::Rfc3339 => { if self.tm.tm_utcoff == 0 { TmFmt { tm: self.tm, format: Fmt::Str("%Y-%m-%dT%H:%M:%SZ"), }.fmt(fmt) } else { let s = TmFmt { tm: self.tm, format: Fmt::Str("%Y-%m-%dT%H:%M:%S"), }; let sign = if self.tm.tm_utcoff > 0 { '+' } else { '-' }; let mut m = abs(self.tm.tm_utcoff) / 60; let h = m / 60; m -= h * 60; write!(fmt, "{}{}{:02}:{:02}", s, sign, h, m) } } } } } fn is_leap_year(year: i32) -> bool { (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)) } fn days_in_year(year: i32) -> i32 { if is_leap_year(year) { 366 } else { 365 } } fn iso_week_days(yday: i32, wday: i32) -> i32 { /* The number of days from the first day of the first ISO week of this * year to the year day YDAY with week day WDAY. * ISO weeks start on Monday. The first ISO week has the year's first * Thursday. * YDAY may be as small as yday_minimum. */ let iso_week_start_wday: i32 = 1; /* Monday */ let iso_week1_wday: i32 = 4; /* Thursday */ let yday_minimum: i32 = 366; /* Add enough to the first operand of % to make it nonnegative. */ let big_enough_multiple_of_7: i32 = (yday_minimum / 7 + 2) * 7; yday - (yday - wday + iso_week1_wday + big_enough_multiple_of_7) % 7 + iso_week1_wday - iso_week_start_wday } fn iso_week(fmt: &mut fmt::Formatter, ch:char, tm: &Tm) -> fmt::Result { let mut year = tm.tm_year + 1900; let mut days = iso_week_days(tm.tm_yday, tm.tm_wday); if days < 0 { /* This ISO week belongs to the previous year. */ year -= 1; days = iso_week_days(tm.tm_yday + (days_in_year(year)), tm.tm_wday); } else { let d = iso_week_days(tm.tm_yday - (days_in_year(year)), tm.tm_wday); if 0 <= d { /* This ISO week belongs to the next year. */ year += 1; days = d; } } match ch { 'G' => write!(fmt, "{}", year), 'g' => write!(fmt, "{:02}", (year % 100 + 100) % 100), 'V' => write!(fmt, "{:02}", days / 7 + 1), _ => Ok(()) } } fn parse_type(fmt: &mut fmt::Formatter, ch: char, tm: &Tm) -> fmt::Result { match ch { 'A' => write!(fmt, "{}", match tm.tm_wday { 0 => "Sunday", 1 => "Monday", 2 => "Tuesday", 3 => "Wednesday", 4 => "Thursday", 5 => "Friday", 6 => "Saturday", _ => unreachable!(), }), 'a' => write!(fmt, "{}", match tm.tm_wday { 0 => "Sun", 1 => "Mon", 2 => "Tue", 3 => "Wed", 4 => "Thu", 5 => "Fri", 6 => "Sat", _ => unreachable!(), }), 'B' => write!(fmt, "{}", match tm.tm_mon { 0 => "January", 1 => "February", 2 => "March", 3 => "April", 4 => "May", 5 => "June", 6 => "July", 7 => "August", 8 => "September", 9 => "October", 10 => "November", 11 => "December", _ => unreachable!(), }), 'b' | 'h' => write!(fmt, "{}", match tm.tm_mon { 0 => "Jan", 1 => "Feb", 2 => "Mar", 3 => "Apr", 4 => "May", 5 => "Jun", 6 => "Jul", 7 => "Aug", 8 => "Sep", 9 => "Oct", 10 => "Nov", 11 => "Dec", _ => unreachable!(), }), 'C' => write!(fmt, "{:02}", (tm.tm_year + 1900) / 100), 'c' => { try!(parse_type(fmt, 'a', tm)); try!(write!(fmt, " ")); try!(parse_type(fmt, 'b', tm)); try!(write!(fmt, " ")); try!(parse_type(fmt, 'e', tm)); try!(write!(fmt, " ")); try!(parse_type(fmt, 'T', tm)); try!(write!(fmt, " ")); parse_type(fmt, 'Y', tm) } 'D' | 'x' => { try!(parse_type(fmt, 'm', tm)); try!(write!(fmt, "/")); try!(parse_type(fmt, 'd', tm)); try!(write!(fmt, "/")); parse_type(fmt, 'y', tm) } 'd' => write!(fmt, "{:02}", tm.tm_mday), 'e' => write!(fmt, "{:2}", tm.tm_mday), 'f' => write!(fmt, "{:09}", tm.tm_nsec), 'F' => { try!(parse_type(fmt, 'Y', tm)); try!(write!(fmt, "-")); try!(parse_type(fmt, 'm', tm)); try!(write!(fmt, "-")); parse_type(fmt, 'd', tm) } 'G' => iso_week(fmt, 'G', tm), 'g' => iso_week(fmt, 'g', tm), 'H' => write!(fmt, "{:02}", tm.tm_hour), 'I' => { let mut h = tm.tm_hour; if h == 0 { h = 12 } if h > 12 { h -= 12 } write!(fmt, "{:02}", h) } 'j' => write!(fmt, "{:03}", tm.tm_yday + 1), 'k' => write!(fmt, "{:2}", tm.tm_hour), 'l' => { let mut h = tm.tm_hour; if h == 0 { h = 12 } if h > 12 { h -= 12 } write!(fmt, "{:2}", h) } 'M' => write!(fmt, "{:02}", tm.tm_min), 'm' => write!(fmt, "{:02}", tm.tm_mon + 1), 'n' => write!(fmt, "\n"), 'P' => write!(fmt, "{}", if tm.tm_hour < 12 { "am" } else { "pm" }), 'p' => write!(fmt, "{}", if (tm.tm_hour) < 12 { "AM" } else { "PM" }), 'R' => { try!(parse_type(fmt, 'H', tm)); try!(write!(fmt, ":")); parse_type(fmt, 'M', tm) } 'r' => { try!(parse_type(fmt, 'I', tm)); try!(write!(fmt, ":")); try!(parse_type(fmt, 'M', tm)); try!(write!(fmt, ":")); try!(parse_type(fmt, 'S', tm)); try!(write!(fmt, " ")); parse_type(fmt, 'p', tm) } 'S' => write!(fmt, "{:02}", tm.tm_sec), 's' => write!(fmt, "{}", tm.to_timespec().sec), 'T' | 'X' => { try!(parse_type(fmt, 'H', tm)); try!(write!(fmt, ":")); try!(parse_type(fmt, 'M', tm)); try!(write!(fmt, ":")); parse_type(fmt, 'S', tm) } 't' => write!(fmt, "\t"), 'U' => write!(fmt, "{:02}", (tm.tm_yday - tm.tm_wday + 7) / 7), 'u' => { let i = tm.tm_wday; write!(fmt, "{}", (if i == 0 { 7 } else { i })) } 'V' => iso_week(fmt, 'V', tm), 'v' => { try!(parse_type(fmt, 'e', tm)); try!(write!(fmt, "-")); try!(parse_type(fmt, 'b', tm)); try!(write!(fmt, "-")); parse_type(fmt, 'Y', tm) } 'W' => { write!(fmt, "{:02}", (tm.tm_yday - (tm.tm_wday - 1 + 7) % 7 + 7) / 7) } 'w' => write!(fmt, "{}", tm.tm_wday), 'Y' => write!(fmt, "{}", tm.tm_year + 1900), 'y' => write!(fmt, "{:02}", (tm.tm_year + 1900) % 100), // FIXME (#2350): support locale 'Z' => write!(fmt, "{}", if tm.tm_utcoff == 0 { "UTC"} else { "" }), 'z' => { let sign = if tm.tm_utcoff > 0 { '+' } else { '-' }; let mut m = abs(tm.tm_utcoff) / 60; let h = m / 60; m -= h * 60; write!(fmt, "{}{:02}{:02}", sign, h, m) } '+' => write!(fmt, "{}", tm.rfc3339()), '%' => write!(fmt, "{}", "%"), _ => unreachable!(), } } fn abs(i: i32) -> i32 { if i < 0 {-i} else {i} } deps/time-0.1.34/src/sys.rs0000664000175000017500000005006312617506661012403 0ustar #![allow(bad_style)] pub use self::inner::*; #[cfg(unix)] mod inner { use libc::{self, time_t}; use std::mem; use std::io; use Tm; #[cfg(any(target_os = "macos", target_os = "ios"))] pub use self::mac::*; #[cfg(all(not(target_os = "macos"), not(target_os = "ios")))] pub use self::unix::*; fn rust_tm_to_tm(rust_tm: &Tm, tm: &mut libc::tm) { tm.tm_sec = rust_tm.tm_sec; tm.tm_min = rust_tm.tm_min; tm.tm_hour = rust_tm.tm_hour; tm.tm_mday = rust_tm.tm_mday; tm.tm_mon = rust_tm.tm_mon; tm.tm_year = rust_tm.tm_year; tm.tm_wday = rust_tm.tm_wday; tm.tm_yday = rust_tm.tm_yday; tm.tm_isdst = rust_tm.tm_isdst; } fn tm_to_rust_tm(tm: &libc::tm, utcoff: i32, rust_tm: &mut Tm) { rust_tm.tm_sec = tm.tm_sec; rust_tm.tm_min = tm.tm_min; rust_tm.tm_hour = tm.tm_hour; rust_tm.tm_mday = tm.tm_mday; rust_tm.tm_mon = tm.tm_mon; rust_tm.tm_year = tm.tm_year; rust_tm.tm_wday = tm.tm_wday; rust_tm.tm_yday = tm.tm_yday; rust_tm.tm_isdst = tm.tm_isdst; rust_tm.tm_utcoff = utcoff; } type time64_t = i64; #[cfg(target_os = "nacl")] unsafe fn timegm(tm: *const libc::tm) -> time_t { use std::env::{set_var, var_os, remove_var}; extern { fn tzset(); } let ret; let current_tz = var_os("TZ"); set_var("TZ", "UTC"); tzset(); ret = libc::mktime(tm); if let Some(tz) = current_tz { set_var("TZ", tz); } else { remove_var("TZ"); } tzset(); ret } pub fn time_to_utc_tm(sec: i64, tm: &mut Tm) { unsafe { let sec = sec as time_t; let mut out = mem::zeroed(); if libc::gmtime_r(&sec, &mut out).is_null() { panic!("gmtime_r failed: {}", io::Error::last_os_error()); } tm_to_rust_tm(&out, 0, tm); } } pub fn time_to_local_tm(sec: i64, tm: &mut Tm) { unsafe { let sec = sec as time_t; let mut out = mem::zeroed(); if libc::localtime_r(&sec, &mut out).is_null() { panic!("localtime_r failed: {}", io::Error::last_os_error()); } tm_to_rust_tm(&out, out.tm_gmtoff as i32, tm); } } pub fn utc_tm_to_time(rust_tm: &Tm) -> i64 { #[cfg(all(target_os = "android", not(target_arch = "aarch64")))] use libc::timegm64 as timegm; #[cfg(not(all(target_os = "android", not(target_arch = "aarch64"))))] use libc::timegm; let mut tm = unsafe { mem::zeroed() }; rust_tm_to_tm(rust_tm, &mut tm); unsafe { timegm(&mut tm) as i64 } } pub fn local_tm_to_time(rust_tm: &Tm) -> i64 { let mut tm = unsafe { mem::zeroed() }; rust_tm_to_tm(rust_tm, &mut tm); unsafe { libc::mktime(&mut tm) as i64 } } #[cfg(any(target_os = "macos", target_os = "ios"))] mod mac { use libc::{self, timeval, mach_timebase_info}; use std::sync::{Once, ONCE_INIT}; use std::ops::{Add, Sub}; use Duration; fn info() -> &'static mach_timebase_info { static mut INFO: mach_timebase_info = mach_timebase_info { numer: 0, denom: 0, }; static ONCE: Once = ONCE_INIT; unsafe { ONCE.call_once(|| { mach_timebase_info(&mut INFO); }); &INFO } } pub fn get_time() -> (i64, i32) { use std::ptr; let mut tv = timeval { tv_sec: 0, tv_usec: 0 }; unsafe { libc::gettimeofday(&mut tv, ptr::null_mut()); } (tv.tv_sec as i64, tv.tv_usec * 1000) } pub fn get_precise_ns() -> u64 { unsafe { let time = libc::mach_absolute_time(); let info = info(); time * info.numer as u64 / info.denom as u64 } } #[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug)] pub struct SteadyTime { t: u64 } impl SteadyTime { pub fn now() -> SteadyTime { SteadyTime { t: get_precise_ns() } } } impl Sub for SteadyTime { type Output = Duration; fn sub(self, other: SteadyTime) -> Duration { Duration::nanoseconds(self.t as i64 - other.t as i64) } } impl Sub for SteadyTime { type Output = SteadyTime; fn sub(self, other: Duration) -> SteadyTime { self + -other } } impl Add for SteadyTime { type Output = SteadyTime; fn add(self, other: Duration) -> SteadyTime { let delta = other.num_nanoseconds().unwrap(); SteadyTime { t: (self.t as i64 + delta) as u64 } } } } #[cfg(test)] pub struct TzReset; #[cfg(test)] pub fn set_los_angeles_time_zone() -> TzReset { use std::env; env::set_var("TZ", "America/Los_Angeles"); ::tzset(); TzReset } #[cfg(test)] pub fn set_london_with_dst_time_zone() -> TzReset { use std::env; env::set_var("TZ", "Europe/London"); ::tzset(); TzReset } #[cfg(all(not(target_os = "macos"), not(target_os = "ios")))] mod unix { use std::fmt; use std::cmp::Ordering; use std::ops::{Add, Sub}; use libc::{self, timespec}; use Duration; pub fn get_time() -> (i64, i32) { let mut tv = libc::timespec { tv_sec: 0, tv_nsec: 0 }; unsafe { libc::clock_gettime(libc::CLOCK_REALTIME, &mut tv); } (tv.tv_sec as i64, tv.tv_nsec as i32) } pub fn get_precise_ns() -> u64 { let mut ts = libc::timespec { tv_sec: 0, tv_nsec: 0 }; unsafe { libc::clock_gettime(libc::CLOCK_MONOTONIC, &mut ts); } (ts.tv_sec as u64) * 1000000000 + (ts.tv_nsec as u64) } #[derive(Copy)] pub struct SteadyTime { t: libc::timespec, } impl fmt::Debug for SteadyTime { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { write!(fmt, "SteadyTime {{ tv_sec: {:?}, tv_nsec: {:?} }}", self.t.tv_sec, self.t.tv_nsec) } } impl Clone for SteadyTime { fn clone(&self) -> SteadyTime { SteadyTime { t: self.t } } } impl SteadyTime { pub fn now() -> SteadyTime { let mut t = SteadyTime { t: libc::timespec { tv_sec: 0, tv_nsec: 0, } }; unsafe { assert_eq!(0, libc::clock_gettime(libc::CLOCK_MONOTONIC, &mut t.t)); } t } } impl Sub for SteadyTime { type Output = Duration; fn sub(self, other: SteadyTime) -> Duration { if self.t.tv_nsec >= other.t.tv_nsec { Duration::seconds(self.t.tv_sec as i64 - other.t.tv_sec as i64) + Duration::nanoseconds(self.t.tv_nsec as i64 - other.t.tv_nsec as i64) } else { Duration::seconds(self.t.tv_sec as i64 - 1 - other.t.tv_sec as i64) + Duration::nanoseconds(self.t.tv_nsec as i64 + ::NSEC_PER_SEC as i64 - other.t.tv_nsec as i64) } } } impl Sub for SteadyTime { type Output = SteadyTime; fn sub(self, other: Duration) -> SteadyTime { self + -other } } impl Add for SteadyTime { type Output = SteadyTime; fn add(mut self, other: Duration) -> SteadyTime { let seconds = other.num_seconds(); let nanoseconds = other - Duration::seconds(seconds); let nanoseconds = nanoseconds.num_nanoseconds().unwrap(); self.t.tv_sec += seconds as libc::time_t; self.t.tv_nsec += nanoseconds as libc::c_long; if self.t.tv_nsec >= ::NSEC_PER_SEC as libc::c_long { self.t.tv_nsec -= ::NSEC_PER_SEC as libc::c_long; self.t.tv_sec += 1; } else if self.t.tv_nsec < 0 { self.t.tv_sec -= 1; self.t.tv_nsec += ::NSEC_PER_SEC as libc::c_long; } self } } impl PartialOrd for SteadyTime { fn partial_cmp(&self, other: &SteadyTime) -> Option { Some(self.cmp(other)) } } impl Ord for SteadyTime { fn cmp(&self, other: &SteadyTime) -> Ordering { match self.t.tv_sec.cmp(&other.t.tv_sec) { Ordering::Equal => self.t.tv_nsec.cmp(&other.t.tv_nsec), ord => ord } } } impl PartialEq for SteadyTime { fn eq(&self, other: &SteadyTime) -> bool { self.t.tv_sec == other.t.tv_sec && self.t.tv_nsec == other.t.tv_nsec } } impl Eq for SteadyTime {} } } #[cfg(windows)] #[allow(non_snake_case)] mod inner { use std::io; use std::mem; use std::sync::{Once, ONCE_INIT}; use std::ops::{Add, Sub}; use {Tm, Duration}; use kernel32::*; use winapi::*; fn frequency() -> LARGE_INTEGER { static mut FREQUENCY: LARGE_INTEGER = 0; static ONCE: Once = ONCE_INIT; unsafe { ONCE.call_once(|| { QueryPerformanceFrequency(&mut FREQUENCY); }); FREQUENCY } } const HECTONANOSECS_IN_SEC: i64 = 10_000_000; const HECTONANOSEC_TO_UNIX_EPOCH: i64 = 11_644_473_600 * HECTONANOSECS_IN_SEC; fn time_to_file_time(sec: i64) -> FILETIME { let t = (((sec * HECTONANOSECS_IN_SEC) + HECTONANOSEC_TO_UNIX_EPOCH)) as u64; FILETIME { dwLowDateTime: t as DWORD, dwHighDateTime: (t >> 32) as DWORD } } fn file_time_as_u64(ft: &FILETIME) -> u64 { ((ft.dwHighDateTime as u64) << 32) | (ft.dwLowDateTime as u64) } fn file_time_to_nsec(ft: &FILETIME) -> i32 { let t = file_time_as_u64(ft) as i64; ((t % HECTONANOSECS_IN_SEC) * 100) as i32 } fn file_time_to_unix_seconds(ft: &FILETIME) -> i64 { let t = file_time_as_u64(ft) as i64; ((t - HECTONANOSEC_TO_UNIX_EPOCH) / HECTONANOSECS_IN_SEC) as i64 } fn system_time_to_file_time(sys: &SYSTEMTIME) -> FILETIME { unsafe { let mut ft = mem::zeroed(); SystemTimeToFileTime(sys, &mut ft); ft } } fn tm_to_system_time(tm: &Tm) -> SYSTEMTIME { let mut sys: SYSTEMTIME = unsafe { mem::zeroed() }; sys.wSecond = tm.tm_sec as WORD; sys.wMinute = tm.tm_min as WORD; sys.wHour = tm.tm_hour as WORD; sys.wDay = tm.tm_mday as WORD; sys.wDayOfWeek = tm.tm_wday as WORD; sys.wMonth = (tm.tm_mon + 1) as WORD; sys.wYear = (tm.tm_year + 1900) as WORD; sys } fn system_time_to_tm(sys: &SYSTEMTIME, tm: &mut Tm) { tm.tm_sec = sys.wSecond as i32; tm.tm_min = sys.wMinute as i32; tm.tm_hour = sys.wHour as i32; tm.tm_mday = sys.wDay as i32; tm.tm_wday = sys.wDayOfWeek as i32; tm.tm_mon = (sys.wMonth - 1) as i32; tm.tm_year = (sys.wYear - 1900) as i32; tm.tm_yday = yday(tm.tm_year, tm.tm_mon + 1, tm.tm_mday); fn yday(year: i32, month: i32, day: i32) -> i32 { let leap = if month > 2 { if year % 4 == 0 { 1 } else { 2 } } else { 0 }; let july = if month > 7 { 1 } else { 0 }; (month - 1) * 30 + month / 2 + (day - 1) - leap + july } } macro_rules! call { ($name:ident($($arg:expr),*)) => { if $name($($arg),*) == 0 { panic!(concat!(stringify!($name), " failed with: {}"), io::Error::last_os_error()); } } } pub fn time_to_utc_tm(sec: i64, tm: &mut Tm) { let mut out = unsafe { mem::zeroed() }; let ft = time_to_file_time(sec); unsafe { call!(FileTimeToSystemTime(&ft, &mut out)); } system_time_to_tm(&out, tm); tm.tm_utcoff = 0; } pub fn time_to_local_tm(sec: i64, tm: &mut Tm) { let ft = time_to_file_time(sec); unsafe { let mut utc = mem::zeroed(); let mut local = mem::zeroed(); call!(FileTimeToSystemTime(&ft, &mut utc)); call!(SystemTimeToTzSpecificLocalTime(0 as *const _, &mut utc, &mut local)); system_time_to_tm(&local, tm); let local = system_time_to_file_time(&local); let local_sec = file_time_to_unix_seconds(&local); let mut tz = mem::zeroed(); GetTimeZoneInformation(&mut tz); // SystemTimeToTzSpecificLocalTime already applied the biases so // check if it non standard tm.tm_utcoff = (local_sec - sec) as i32; tm.tm_isdst = if tm.tm_utcoff == -60 * (tz.Bias + tz.StandardBias) { 0 } else { 1 }; } } pub fn utc_tm_to_time(tm: &Tm) -> i64 { unsafe { let mut ft = mem::zeroed(); let sys_time = tm_to_system_time(tm); call!(SystemTimeToFileTime(&sys_time, &mut ft)); file_time_to_unix_seconds(&ft) } } pub fn local_tm_to_time(tm: &Tm) -> i64 { unsafe { let mut ft = mem::zeroed(); let mut utc = mem::zeroed(); let mut sys_time = tm_to_system_time(tm); call!(TzSpecificLocalTimeToSystemTime(0 as *mut _, &mut sys_time, &mut utc)); call!(SystemTimeToFileTime(&utc, &mut ft)); file_time_to_unix_seconds(&ft) } } pub fn get_time() -> (i64, i32) { unsafe { let mut ft = mem::zeroed(); GetSystemTimeAsFileTime(&mut ft); (file_time_to_unix_seconds(&ft), file_time_to_nsec(&ft)) } } pub fn get_precise_ns() -> u64 { let mut ticks = 0; unsafe { assert!(QueryPerformanceCounter(&mut ticks) == 1); } mul_div_i64(ticks as i64, 1000000000, frequency() as i64) as u64 } #[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug)] pub struct SteadyTime { t: LARGE_INTEGER, } impl SteadyTime { pub fn now() -> SteadyTime { let mut t = SteadyTime { t: 0 }; unsafe { QueryPerformanceCounter(&mut t.t); } t } } impl Sub for SteadyTime { type Output = Duration; fn sub(self, other: SteadyTime) -> Duration { let diff = self.t as i64 - other.t as i64; Duration::nanoseconds(mul_div_i64(diff, 1000000000, frequency() as i64)) } } impl Sub for SteadyTime { type Output = SteadyTime; fn sub(self, other: Duration) -> SteadyTime { self + -other } } impl Add for SteadyTime { type Output = SteadyTime; fn add(mut self, other: Duration) -> SteadyTime { self.t += (other.num_microseconds().unwrap() * frequency() as i64 / 1_000_000) as LARGE_INTEGER; self } } #[cfg(test)] pub struct TzReset { old: TIME_ZONE_INFORMATION, } #[cfg(test)] impl Drop for TzReset { fn drop(&mut self) { unsafe { call!(SetTimeZoneInformation(&self.old)); } } } #[cfg(test)] pub fn set_los_angeles_time_zone() -> TzReset { acquire_privileges(); unsafe { let mut tz = mem::zeroed::(); GetTimeZoneInformation(&mut tz); let ret = TzReset { old: tz }; tz.Bias = 60 * 8; call!(SetTimeZoneInformation(&tz)); return ret } } #[cfg(test)] pub fn set_london_with_dst_time_zone() -> TzReset { acquire_privileges(); unsafe { let mut tz = mem::zeroed::(); GetTimeZoneInformation(&mut tz); let ret = TzReset { old: tz }; // Since date set precisely this is 2015's dates tz.Bias = 0; tz.DaylightBias = -60; tz.DaylightDate.wYear = 0; tz.DaylightDate.wMonth = 3; tz.DaylightDate.wDayOfWeek = 0; tz.DaylightDate.wDay = 5; tz.DaylightDate.wHour = 2; tz.StandardBias = 0; tz.StandardDate.wYear = 0; tz.StandardDate.wMonth = 10; tz.StandardDate.wDayOfWeek = 0; tz.StandardDate.wDay = 5; tz.StandardDate.wHour = 2; call!(SetTimeZoneInformation(&tz)); return ret } } // Ensures that this process has the necessary privileges to set a new time // zone, and this is all transcribed from: // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724944%28v=vs.85%29.aspx #[cfg(test)] fn acquire_privileges() { use std::sync::{ONCE_INIT, Once}; use advapi32::*; const SE_PRIVILEGE_ENABLED: DWORD = 2; static INIT: Once = ONCE_INIT; #[repr(C)] struct TKP { tkp: TOKEN_PRIVILEGES, laa: LUID_AND_ATTRIBUTES, } INIT.call_once(|| unsafe { let mut hToken = 0 as *mut _; call!(OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &mut hToken)); let mut tkp = mem::zeroed::(); assert_eq!(tkp.tkp.Privileges.len(), 0); let c = ::std::ffi::CString::new("SeTimeZonePrivilege").unwrap(); call!(LookupPrivilegeValueA(0 as *const _, c.as_ptr(), &mut tkp.laa.Luid)); tkp.tkp.PrivilegeCount = 1; tkp.laa.Attributes = SE_PRIVILEGE_ENABLED; call!(AdjustTokenPrivileges(hToken, FALSE, &mut tkp.tkp, 0, 0 as *mut _, 0 as *mut _)); }); } // Computes (value*numer)/denom without overflow, as long as both // (numer*denom) and the overall result fit into i64 (which is the case // for our time conversions). fn mul_div_i64(value: i64, numer: i64, denom: i64) -> i64 { let q = value / denom; let r = value % denom; // Decompose value as (value/denom*denom + value%denom), // substitute into (value*numer)/denom and simplify. // r < denom, so (denom*numer) is the upper bound of (r*numer) q * numer + r * numer / denom } #[test] fn test_muldiv() { assert_eq!(mul_div_i64( 1_000_000_000_001, 1_000_000_000, 1_000_000), 1_000_000_000_001_000); assert_eq!(mul_div_i64(-1_000_000_000_001, 1_000_000_000, 1_000_000), -1_000_000_000_001_000); assert_eq!(mul_div_i64(-1_000_000_000_001,-1_000_000_000, 1_000_000), 1_000_000_000_001_000); assert_eq!(mul_div_i64( 1_000_000_000_001, 1_000_000_000,-1_000_000), -1_000_000_000_001_000); assert_eq!(mul_div_i64( 1_000_000_000_001,-1_000_000_000,-1_000_000), 1_000_000_000_001_000); } } deps/time-0.1.34/appveyor.yml0000664000175000017500000000073612556741602013020 0ustar environment: matrix: - TARGET: x86_64-pc-windows-msvc - TARGET: i686-pc-windows-msvc - TARGET: i686-pc-windows-gnu install: - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin - SET PATH=%PATH%;C:\MinGW\bin - rustc -V - cargo -V build: false test_script: - cargo test --verbose deps/time-0.1.34/Cargo.toml0000664000175000017500000000101012620155617012337 0ustar [package] name = "time" version = "0.1.34" authors = ["The Rust Project Developers"] license = "MIT/Apache-2.0" homepage = "https://github.com/rust-lang/time" repository = "https://github.com/rust-lang/time" documentation = "https://doc.rust-lang.org/time" description = """ Utilities for working with time-related functions in Rust. """ [dependencies] libc = "0.2.1" winapi = "0.2.0" kernel32-sys = "0.2.0" rustc-serialize = { version = "0.3", optional = true } [dev-dependencies] log = "0.3" advapi32-sys = "0.1.2" deps/time-0.1.34/benches/0000755000000000000000000000000012666635520013610 5ustar rootrootdeps/time-0.1.34/benches/precise_time_ns.rs0000664000175000017500000000025412526417126015546 0ustar #![feature(test)] extern crate test; extern crate time; use test::Bencher; #[bench] fn bench_precise_time_ns(b: &mut Bencher) { b.iter(|| time::precise_time_ns()) } deps/libssh2-sys-0.1.34/0000755000000000000000000000000012666635521013426 5ustar rootrootdeps/libssh2-sys-0.1.34/lib.rs0000664000175000017500000006467612620154521012773 0ustar #![doc(html_root_url = "http://alexcrichton.com/ssh2-rs")] #![allow(bad_style)] extern crate libc; extern crate ws2_32; extern crate winapi; extern crate libz_sys; #[cfg(unix)] extern crate openssl_sys; use libc::{c_int, size_t, c_void, c_char, c_long, c_uchar, c_uint, c_ulong}; use libc::ssize_t; pub const SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT: c_int = 1; pub const SSH_DISCONNECT_PROTOCOL_ERROR: c_int = 2; pub const SSH_DISCONNECT_KEY_EXCHANGE_FAILED: c_int = 3; pub const SSH_DISCONNECT_RESERVED: c_int = 4; pub const SSH_DISCONNECT_MAC_ERROR: c_int = 5; pub const SSH_DISCONNECT_COMPRESSION_ERROR: c_int = 6; pub const SSH_DISCONNECT_SERVICE_NOT_AVAILABLE: c_int = 7; pub const SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED: c_int = 8; pub const SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE: c_int = 9; pub const SSH_DISCONNECT_CONNECTION_LOST: c_int = 10; pub const SSH_DISCONNECT_BY_APPLICATION: c_int = 11; pub const SSH_DISCONNECT_TOO_MANY_CONNECTIONS: c_int = 12; pub const SSH_DISCONNECT_AUTH_CANCELLED_BY_USER: c_int = 13; pub const SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE: c_int = 14; pub const SSH_DISCONNECT_ILLEGAL_USER_NAME: c_int = 15; pub const LIBSSH2_FLAG_SIGPIPE: c_int = 1; pub const LIBSSH2_FLAG_COMPRESS: c_int = 2; pub const LIBSSH2_HOSTKEY_TYPE_UNKNOWN: c_int = 0; pub const LIBSSH2_HOSTKEY_TYPE_RSA: c_int = 1; pub const LIBSSH2_HOSTKEY_TYPE_DSS: c_int = 2; pub const LIBSSH2_METHOD_KEX: c_int = 0; pub const LIBSSH2_METHOD_HOSTKEY: c_int = 1; pub const LIBSSH2_METHOD_CRYPT_CS: c_int = 2; pub const LIBSSH2_METHOD_CRYPT_SC: c_int = 3; pub const LIBSSH2_METHOD_MAC_CS: c_int = 4; pub const LIBSSH2_METHOD_MAC_SC: c_int = 5; pub const LIBSSH2_METHOD_COMP_CS: c_int = 6; pub const LIBSSH2_METHOD_COMP_SC: c_int = 7; pub const LIBSSH2_METHOD_LANG_CS: c_int = 8; pub const LIBSSH2_METHOD_LANG_SC: c_int = 9; pub const LIBSSH2_CHANNEL_PACKET_DEFAULT: c_uint = 32768; pub const LIBSSH2_CHANNEL_WINDOW_DEFAULT: c_uint = 2 * 1024 * 1024; pub const LIBSSH2_ERROR_BANNER_RECV: c_int = -2; pub const LIBSSH2_ERROR_BANNER_SEND: c_int = -3; pub const LIBSSH2_ERROR_INVALID_MAC: c_int = -4; pub const LIBSSH2_ERROR_KEX_FAILURE: c_int = -5; pub const LIBSSH2_ERROR_ALLOC: c_int = -6; pub const LIBSSH2_ERROR_SOCKET_SEND: c_int = -7; pub const LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE: c_int = -8; pub const LIBSSH2_ERROR_TIMEOUT: c_int = -9; pub const LIBSSH2_ERROR_HOSTKEY_INIT: c_int = -10; pub const LIBSSH2_ERROR_HOSTKEY_SIGN: c_int = -11; pub const LIBSSH2_ERROR_DECRYPT: c_int = -12; pub const LIBSSH2_ERROR_SOCKET_DISCONNECT: c_int = -13; pub const LIBSSH2_ERROR_PROTO: c_int = -14; pub const LIBSSH2_ERROR_PASSWORD_EXPIRED: c_int = -15; pub const LIBSSH2_ERROR_FILE: c_int = -16; pub const LIBSSH2_ERROR_METHOD_NONE: c_int = -17; pub const LIBSSH2_ERROR_AUTHENTICATION_FAILED: c_int = -18; pub const LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED: c_int = LIBSSH2_ERROR_AUTHENTICATION_FAILED; pub const LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED: c_int = -19; pub const LIBSSH2_ERROR_CHANNEL_OUTOFORDER: c_int = -20; pub const LIBSSH2_ERROR_CHANNEL_FAILURE: c_int = -21; pub const LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED: c_int = -22; pub const LIBSSH2_ERROR_CHANNEL_UNKNOWN: c_int = -23; pub const LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED: c_int = -24; pub const LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED: c_int = -25; pub const LIBSSH2_ERROR_CHANNEL_CLOSED: c_int = -26; pub const LIBSSH2_ERROR_CHANNEL_EOF_SENT: c_int = -27; pub const LIBSSH2_ERROR_SCP_PROTOCOL: c_int = -28; pub const LIBSSH2_ERROR_ZLIB: c_int = -29; pub const LIBSSH2_ERROR_SOCKET_TIMEOUT: c_int = -30; pub const LIBSSH2_ERROR_SFTP_PROTOCOL: c_int = -31; pub const LIBSSH2_ERROR_REQUEST_DENIED: c_int = -32; pub const LIBSSH2_ERROR_METHOD_NOT_SUPPORTED: c_int = -33; pub const LIBSSH2_ERROR_INVAL: c_int = -34; pub const LIBSSH2_ERROR_INVALID_POLL_TYPE: c_int = -35; pub const LIBSSH2_ERROR_PUBLICKEY_PROTOCOL: c_int = -36; pub const LIBSSH2_ERROR_EAGAIN: c_int = -37; pub const LIBSSH2_ERROR_BUFFER_TOO_SMALL: c_int = -38; pub const LIBSSH2_ERROR_BAD_USE: c_int = -39; pub const LIBSSH2_ERROR_COMPRESS: c_int = -40; pub const LIBSSH2_ERROR_OUT_OF_BOUNDARY: c_int = -41; pub const LIBSSH2_ERROR_AGENT_PROTOCOL: c_int = -42; pub const LIBSSH2_ERROR_SOCKET_RECV: c_int = -43; pub const LIBSSH2_ERROR_ENCRYPT: c_int = -44; pub const LIBSSH2_ERROR_BAD_SOCKET: c_int = -45; pub const LIBSSH2_ERROR_KNOWN_HOSTS: c_int = -46; pub const LIBSSH2_HOSTKEY_HASH_MD5: c_int = 1; pub const LIBSSH2_HOSTKEY_HASH_SHA1: c_int = 2; pub const LIBSSH2_KNOWNHOST_FILE_OPENSSH: c_int = 1; pub const LIBSSH2_KNOWNHOST_CHECK_MATCH: c_int = 0; pub const LIBSSH2_KNOWNHOST_CHECK_MISMATCH: c_int = 1; pub const LIBSSH2_KNOWNHOST_CHECK_NOTFOUND: c_int = 2; pub const LIBSSH2_KNOWNHOST_CHECK_FAILURE: c_int = 3; pub const LIBSSH2_KNOWNHOST_TYPE_PLAIN: c_int = 1; pub const LIBSSH2_KNOWNHOST_TYPE_SHA1: c_int = 2; pub const LIBSSH2_KNOWNHOST_TYPE_CUSTOM: c_int = 3; pub const LIBSSH2_KNOWNHOST_KEYENC_RAW: c_int = 1 << 16; pub const LIBSSH2_KNOWNHOST_KEYENC_BASE64: c_int = 2 << 16; pub const LIBSSH2_KNOWNHOST_KEY_RSA1: c_int = 1 << 18; pub const LIBSSH2_KNOWNHOST_KEY_SSHRSA: c_int = 2 << 18; pub const LIBSSH2_KNOWNHOST_KEY_SSHDSS: c_int = 3 << 18; pub const LIBSSH2_KNOWNHOST_KEY_UNKNOWN: c_int = 7 << 18; pub const LIBSSH2_FXF_READ: c_ulong = 0x00000001; pub const LIBSSH2_FXF_WRITE: c_ulong = 0x00000002; pub const LIBSSH2_FXF_APPEND: c_ulong = 0x00000004; pub const LIBSSH2_FXF_CREAT: c_ulong = 0x00000008; pub const LIBSSH2_FXF_TRUNC: c_ulong = 0x00000010; pub const LIBSSH2_FXF_EXCL: c_ulong = 0x00000020; pub const LIBSSH2_SFTP_OPENFILE: c_int = 0; pub const LIBSSH2_SFTP_OPENDIR: c_int = 1; pub const LIBSSH2_SFTP_ATTR_SIZE: c_ulong = 0x00000001; pub const LIBSSH2_SFTP_ATTR_UIDGID: c_ulong = 0x00000002; pub const LIBSSH2_SFTP_ATTR_PERMISSIONS: c_ulong = 0x00000004; pub const LIBSSH2_SFTP_ATTR_ACMODTIME: c_ulong = 0x00000008; pub const LIBSSH2_SFTP_ATTR_EXTENDED: c_ulong = 0x80000000; pub const LIBSSH2_SFTP_STAT: c_int = 0; pub const LIBSSH2_SFTP_LSTAT: c_int = 1; pub const LIBSSH2_SFTP_SETSTAT: c_int = 2; pub const LIBSSH2_SFTP_SYMLINK: c_int = 0; pub const LIBSSH2_SFTP_READLINK: c_int = 1; pub const LIBSSH2_SFTP_REALPATH: c_int = 2; pub const LIBSSH2_SFTP_RENAME_OVERWRITE: c_long = 0x1; pub const LIBSSH2_SFTP_RENAME_ATOMIC: c_long = 0x2; pub const LIBSSH2_SFTP_RENAME_NATIVE: c_long = 0x4; pub enum LIBSSH2_SESSION {} pub enum LIBSSH2_AGENT {} pub enum LIBSSH2_CHANNEL {} pub enum LIBSSH2_LISTENER {} pub enum LIBSSH2_KNOWNHOSTS {} pub enum LIBSSH2_SFTP {} pub enum LIBSSH2_SFTP_HANDLE {} pub type libssh2_int64_t = i64; pub type libssh2_uint64_t = u64; #[repr(C)] pub struct libssh2_agent_publickey { pub magic: c_uint, pub node: *mut c_void, pub blob: *mut c_uchar, pub blob_len: size_t, pub comment: *mut c_char, } #[repr(C)] pub struct libssh2_knownhost { pub magic: c_uint, pub node: *mut c_void, pub name: *mut c_char, pub key: *mut c_char, pub typemask: c_int, } #[repr(C)] #[derive(Copy, Clone)] pub struct LIBSSH2_SFTP_ATTRIBUTES { pub flags: c_ulong, pub filesize: libssh2_uint64_t, pub uid: c_ulong, pub gid: c_ulong, pub permissions: c_ulong, pub atime: c_ulong, pub mtime: c_ulong, } #[repr(C)] #[derive(Copy, Clone)] pub struct LIBSSH2_SFTP_STATVFS { pub f_bsize: libssh2_uint64_t, pub f_frsize: libssh2_uint64_t, pub f_blocks: libssh2_uint64_t, pub f_bfree: libssh2_uint64_t, pub f_bavail: libssh2_uint64_t, pub f_files: libssh2_uint64_t, pub f_ffree: libssh2_uint64_t, pub f_favail: libssh2_uint64_t, pub f_fsid: libssh2_uint64_t, pub f_flag: libssh2_uint64_t, pub f_namemax: libssh2_uint64_t, } pub type LIBSSH2_ALLOC_FUNC = extern fn(size_t, *mut *mut c_void) -> *mut c_void; pub type LIBSSH2_FREE_FUNC = extern fn(*mut c_void, *mut *mut c_void); pub type LIBSSH2_REALLOC_FUNC = extern fn(*mut c_void, size_t, *mut *mut c_void) -> *mut c_void; pub type LIBSSH2_PASSWD_CHANGEREQ_FUNC = extern fn(sess: *mut LIBSSH2_SESSION, newpw: *mut *mut c_char, newpw_len: *mut c_int, abstrakt: *mut *mut c_void); #[cfg(unix)] pub type libssh2_socket_t = c_int; #[cfg(windows)] pub type libssh2_socket_t = winapi::SOCKET; extern { // misc pub fn libssh2_init(flag: c_int) -> c_int; pub fn libssh2_exit(); pub fn libssh2_free(sess: *mut LIBSSH2_SESSION, ptr: *mut c_void); pub fn libssh2_hostkey_hash(session: *mut LIBSSH2_SESSION, hash_type: c_int) -> *const c_char; // session pub fn libssh2_session_init_ex(alloc: Option, free: Option, realloc: Option, abstrakt: *mut c_void) -> *mut LIBSSH2_SESSION; pub fn libssh2_session_free(sess: *mut LIBSSH2_SESSION) -> c_int; pub fn libssh2_session_banner_get(sess: *mut LIBSSH2_SESSION) -> *const c_char; pub fn libssh2_session_banner_set(sess: *mut LIBSSH2_SESSION, banner: *const c_char) -> c_int; pub fn libssh2_session_disconnect_ex(sess: *mut LIBSSH2_SESSION, reason: c_int, description: *const c_char, lang: *const c_char) -> c_int; pub fn libssh2_session_flag(sess: *mut LIBSSH2_SESSION, flag: c_int, value: c_int) -> c_int; pub fn libssh2_session_get_blocking(session: *mut LIBSSH2_SESSION) -> c_int; pub fn libssh2_session_get_timeout(sess: *mut LIBSSH2_SESSION) -> c_long; pub fn libssh2_session_hostkey(sess: *mut LIBSSH2_SESSION, len: *mut size_t, kind: *mut c_int) -> *const c_char; pub fn libssh2_session_method_pref(sess: *mut LIBSSH2_SESSION, method_type: c_int, prefs: *const c_char) -> c_int; pub fn libssh2_session_methods(sess: *mut LIBSSH2_SESSION, method_type: c_int) -> *const c_char; pub fn libssh2_session_set_blocking(session: *mut LIBSSH2_SESSION, blocking: c_int); pub fn libssh2_session_set_timeout(session: *mut LIBSSH2_SESSION, timeout: c_long); pub fn libssh2_session_supported_algs(session: *mut LIBSSH2_SESSION, method_type: c_int, algs: *mut *mut *const c_char) -> c_int; pub fn libssh2_session_last_error(sess: *mut LIBSSH2_SESSION, msg: *mut *mut c_char, len: *mut c_int, want_buf: c_int) -> c_int; pub fn libssh2_session_handshake(sess: *mut LIBSSH2_SESSION, socket: libssh2_socket_t) -> c_int; pub fn libssh2_keepalive_config(sess: *mut LIBSSH2_SESSION, want_reply: c_int, interval: c_uint); pub fn libssh2_keepalive_send(sess: *mut LIBSSH2_SESSION, seconds_to_next: *mut c_int) -> c_int; // agent pub fn libssh2_agent_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_AGENT; pub fn libssh2_agent_free(agent: *mut LIBSSH2_AGENT); pub fn libssh2_agent_connect(agent: *mut LIBSSH2_AGENT) -> c_int; pub fn libssh2_agent_disconnect(agent: *mut LIBSSH2_AGENT) -> c_int; pub fn libssh2_agent_list_identities(agent: *mut LIBSSH2_AGENT) -> c_int; pub fn libssh2_agent_get_identity(agent: *mut LIBSSH2_AGENT, store: *mut *mut libssh2_agent_publickey, prev: *mut libssh2_agent_publickey) -> c_int; pub fn libssh2_agent_userauth(agent: *mut LIBSSH2_AGENT, username: *const c_char, identity: *mut libssh2_agent_publickey) -> c_int; // channels pub fn libssh2_channel_free(chan: *mut LIBSSH2_CHANNEL) -> c_int; pub fn libssh2_channel_close(chan: *mut LIBSSH2_CHANNEL) -> c_int; pub fn libssh2_channel_wait_closed(chan: *mut LIBSSH2_CHANNEL) -> c_int; pub fn libssh2_channel_wait_eof(chan: *mut LIBSSH2_CHANNEL) -> c_int; pub fn libssh2_channel_eof(chan: *mut LIBSSH2_CHANNEL) -> c_int; pub fn libssh2_channel_process_startup(chan: *mut LIBSSH2_CHANNEL, req: *const c_char, req_len: c_uint, msg: *const c_char, msg_len: c_uint) -> c_int; pub fn libssh2_channel_flush_ex(chan: *mut LIBSSH2_CHANNEL, streamid: c_int) -> c_int; pub fn libssh2_channel_write_ex(chan: *mut LIBSSH2_CHANNEL, stream_id: c_int, buf: *const c_char, buflen: size_t) -> ssize_t; pub fn libssh2_channel_get_exit_signal(chan: *mut LIBSSH2_CHANNEL, exitsignal: *mut *mut c_char, exitsignal_len: *mut size_t, errmsg: *mut *mut c_char, errmsg_len: *mut size_t, langtag: *mut *mut c_char, langtag_len: *mut size_t) -> c_int; pub fn libssh2_channel_get_exit_status(chan: *mut LIBSSH2_CHANNEL) -> c_int; pub fn libssh2_channel_open_ex(sess: *mut LIBSSH2_SESSION, channel_type: *const c_char, channel_type_len: c_uint, window_size: c_uint, packet_size: c_uint, message: *const c_char, message_len: c_uint) -> *mut LIBSSH2_CHANNEL; pub fn libssh2_channel_read_ex(chan: *mut LIBSSH2_CHANNEL, stream_id: c_int, buf: *mut c_char, buflen: size_t) -> ssize_t; pub fn libssh2_channel_setenv_ex(chan: *mut LIBSSH2_CHANNEL, var: *const c_char, varlen: c_uint, val: *const c_char, vallen: c_uint) -> c_int; pub fn libssh2_channel_send_eof(chan: *mut LIBSSH2_CHANNEL) -> c_int; pub fn libssh2_channel_request_pty_ex(chan: *mut LIBSSH2_CHANNEL, term: *const c_char, termlen: c_uint, modes: *const c_char, modeslen: c_uint, width: c_int, height: c_int, width_px: c_int, height_px: c_int) -> c_int; pub fn libssh2_channel_request_pty_size_ex(chan: *mut LIBSSH2_CHANNEL, width: c_int, height: c_int, width_px: c_int, height_px: c_int) -> c_int; pub fn libssh2_channel_window_read_ex(chan: *mut LIBSSH2_CHANNEL, read_avail: *mut c_ulong, window_size_initial: *mut c_ulong) -> c_ulong; pub fn libssh2_channel_window_write_ex(chan: *mut LIBSSH2_CHANNEL, window_size_initial: *mut c_ulong) -> c_ulong; pub fn libssh2_channel_receive_window_adjust2(chan: *mut LIBSSH2_CHANNEL, adjust: c_ulong, force: c_uchar, window: *mut c_uint) -> c_int; pub fn libssh2_channel_direct_tcpip_ex(ses: *mut LIBSSH2_SESSION, host: *const c_char, port: c_int, shost: *const c_char, sport: c_int) -> *mut LIBSSH2_CHANNEL; pub fn libssh2_channel_forward_accept(listener: *mut LIBSSH2_LISTENER) -> *mut LIBSSH2_CHANNEL; pub fn libssh2_channel_forward_cancel(listener: *mut LIBSSH2_LISTENER) -> c_int; pub fn libssh2_channel_forward_listen_ex(sess: *mut LIBSSH2_SESSION, host: *const c_char, port: c_int, bound_port: *mut c_int, queue_maxsize: c_int) -> *mut LIBSSH2_LISTENER; // userauth pub fn libssh2_userauth_authenticated(sess: *mut LIBSSH2_SESSION) -> c_int; pub fn libssh2_userauth_list(sess: *mut LIBSSH2_SESSION, username: *const c_char, username_len: c_uint) -> *mut c_char; pub fn libssh2_userauth_hostbased_fromfile_ex(sess: *mut LIBSSH2_SESSION, username: *const c_char, username_len: c_uint, publickey: *const c_char, privatekey: *const c_char, passphrase: *const c_char, hostname: *const c_char, hostname_len: c_uint, local_username: *const c_char, local_len: c_uint) -> c_int; pub fn libssh2_userauth_publickey_fromfile_ex(sess: *mut LIBSSH2_SESSION, username: *const c_char, username_len: c_uint, publickey: *const c_char, privatekey: *const c_char, passphrase: *const c_char) -> c_int; pub fn libssh2_userauth_password_ex(session: *mut LIBSSH2_SESSION, username: *const c_char, username_len: c_uint, password: *const c_char, password_len: c_uint, password_change_cb: Option) -> c_int; // knownhost pub fn libssh2_knownhost_free(hosts: *mut LIBSSH2_KNOWNHOSTS); pub fn libssh2_knownhost_addc(hosts: *mut LIBSSH2_KNOWNHOSTS, host: *const c_char, salt: *const c_char, key: *const c_char, keylen: size_t, comment: *const c_char, commentlen: size_t, typemask: c_int, store: *mut *mut libssh2_knownhost) -> c_int; pub fn libssh2_knownhost_check(hosts: *mut LIBSSH2_KNOWNHOSTS, host: *const c_char, key: *const c_char, keylen: size_t, typemask: c_int, knownhost: *mut *mut libssh2_knownhost) -> c_int; pub fn libssh2_knownhost_checkp(hosts: *mut LIBSSH2_KNOWNHOSTS, host: *const c_char, port: c_int, key: *const c_char, keylen: size_t, typemask: c_int, knownhost: *mut *mut libssh2_knownhost) -> c_int; pub fn libssh2_knownhost_del(hosts: *mut LIBSSH2_KNOWNHOSTS, entry: *mut libssh2_knownhost) -> c_int; pub fn libssh2_knownhost_get(hosts: *mut LIBSSH2_KNOWNHOSTS, store: *mut *mut libssh2_knownhost, prev: *mut libssh2_knownhost) -> c_int; pub fn libssh2_knownhost_readfile(hosts: *mut LIBSSH2_KNOWNHOSTS, filename: *const c_char, kind: c_int) -> c_int; pub fn libssh2_knownhost_readline(hosts: *mut LIBSSH2_KNOWNHOSTS, line: *const c_char, len: size_t, kind: c_int) -> c_int; pub fn libssh2_knownhost_writefile(hosts: *mut LIBSSH2_KNOWNHOSTS, filename: *const c_char, kind: c_int) -> c_int; pub fn libssh2_knownhost_writeline(hosts: *mut LIBSSH2_KNOWNHOSTS, known: *mut libssh2_knownhost, buffer: *mut c_char, buflen: size_t, outlen: *mut size_t, kind: c_int) -> c_int; pub fn libssh2_knownhost_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_KNOWNHOSTS; // scp pub fn libssh2_scp_recv(sess: *mut LIBSSH2_SESSION, path: *const c_char, sb: *mut libc::stat) -> *mut LIBSSH2_CHANNEL; pub fn libssh2_scp_send64(sess: *mut LIBSSH2_SESSION, path: *const c_char, mode: c_int, size: libssh2_int64_t, mtime: libc::time_t, atime: libc::time_t) -> *mut LIBSSH2_CHANNEL; // sftp pub fn libssh2_sftp_init(sess: *mut LIBSSH2_SESSION) -> *mut LIBSSH2_SFTP; pub fn libssh2_sftp_shutdown(sftp: *mut LIBSSH2_SFTP) -> c_int; pub fn libssh2_sftp_last_error(sftp: *mut LIBSSH2_SFTP) -> c_ulong; pub fn libssh2_sftp_open_ex(sftp: *mut LIBSSH2_SFTP, filename: *const c_char, filename_len: c_uint, flags: c_ulong, mode: c_long, open_type: c_int) -> *mut LIBSSH2_SFTP_HANDLE; pub fn libssh2_sftp_close_handle(handle: *mut LIBSSH2_SFTP_HANDLE) -> c_int; pub fn libssh2_sftp_mkdir_ex(sftp: *mut LIBSSH2_SFTP, path: *const c_char, path_len: c_uint, mode: c_long) -> c_int; pub fn libssh2_sftp_fsync(handle: *mut LIBSSH2_SFTP_HANDLE) -> c_int; pub fn libssh2_sftp_fstat_ex(handle: *mut LIBSSH2_SFTP_HANDLE, attrs: *mut LIBSSH2_SFTP_ATTRIBUTES, setstat: c_int) -> c_int; pub fn libssh2_sftp_fstatvfs(handle: *mut LIBSSH2_SFTP_HANDLE, attrs: *mut LIBSSH2_SFTP_STATVFS) -> c_int; pub fn libssh2_sftp_stat_ex(sftp: *mut LIBSSH2_SFTP, path: *const c_char, path_len: c_uint, stat_type: c_int, attrs: *mut LIBSSH2_SFTP_ATTRIBUTES) -> c_int; pub fn libssh2_sftp_read(handle: *mut LIBSSH2_SFTP_HANDLE, buf: *mut c_char, len: size_t) -> ssize_t; pub fn libssh2_sftp_symlink_ex(sftp: *mut LIBSSH2_SFTP, path: *const c_char, path_len: c_uint, target: *mut c_char, target_len: c_uint, link_type: c_int) -> c_int; pub fn libssh2_sftp_rename_ex(sftp: *mut LIBSSH2_SFTP, src: *const c_char, src_len: c_uint, dst: *const c_char, dst_len: c_uint, flags: c_long) -> c_int; pub fn libssh2_sftp_rmdir_ex(sftp: *mut LIBSSH2_SFTP, path: *const c_char, path_len: c_uint) -> c_int; pub fn libssh2_sftp_write(handle: *mut LIBSSH2_SFTP_HANDLE, buffer: *const c_char, len: size_t) -> ssize_t; pub fn libssh2_sftp_tell64(handle: *mut LIBSSH2_SFTP_HANDLE) -> libssh2_uint64_t; pub fn libssh2_sftp_seek64(handle: *mut LIBSSH2_SFTP_HANDLE, off: libssh2_uint64_t); pub fn libssh2_sftp_readdir_ex(handle: *mut LIBSSH2_SFTP_HANDLE, buffer: *mut c_char, buffer_len: size_t, longentry: *mut c_char, longentry_len: size_t, attrs: *mut LIBSSH2_SFTP_ATTRIBUTES) -> c_int; pub fn libssh2_sftp_unlink_ex(sftp: *mut LIBSSH2_SFTP, filename: *const c_char, filename_len: c_uint) -> c_int; } #[test] fn smoke() { unsafe { libssh2_init(0) }; } pub fn issue_14344_workaround() {} deps/libssh2-sys-0.1.34/Cargo.toml0000664000175000017500000000234512624405106013572 0ustar [package] name = "libssh2-sys" version = "0.1.34" authors = ["Alex Crichton "] links = "ssh2" build = "build.rs" license = "MIT/Apache-2.0" repository = "https://github.com/alexcrichton/ssh2-rs" description = "Native bindings to the libssh2 library" [lib] name = "libssh2_sys" path = "lib.rs" [dependencies] libz-sys = ">= 0" libc = "0.2" ws2_32-sys = ">= 0" winapi = "0.2" [target.i686-apple-darwin.dependencies] openssl-sys = ">= 0" [target.x86_64-apple-darwin.dependencies] openssl-sys = ">= 0" [target.i686-unknown-linux-gnu.dependencies] openssl-sys = ">= 0" [target.x86_64-unknown-linux-gnu.dependencies] openssl-sys = ">= 0" [target.aarch64-unknown-linux-gnu.dependencies] openssl-sys = ">= 0" [target.x86_64-unknown-linux-musl.dependencies] openssl-sys = ">= 0" [target.arm-unknown-linux-gnueabihf.dependencies] openssl-sys = ">= 0" [target.i686-unknown-freebsd.dependencies] openssl-sys = ">= 0" [target.x86_64-unknown-freebsd.dependencies] openssl-sys = ">= 0" [target.x86_64-unknown-dragonfly.dependencies] openssl-sys = ">= 0" [target.x86_64-unknown-bitrig.dependencies] openssl-sys = ">= 0" [target.x86_64-unknown-openbsd.dependencies] openssl-sys = ">= 0" [build-dependencies] pkg-config = "0.3" cmake = "0.1.2" deps/libssh2-sys-0.1.34/build.rs0000664000175000017500000000673012623201320013300 0ustar extern crate pkg_config; extern crate cmake; use std::env; use std::fs::File; use std::io::prelude::*; use std::path::{PathBuf, Path}; fn main() { register_dep("Z"); register_dep("OPENSSL"); if let Ok(lib) = pkg_config::find_library("libssh2") { for path in &lib.include_paths { println!("cargo:include={}", path.display()); } return } let mut cfg = cmake::Config::new("libssh2"); let target = env::var("TARGET").unwrap(); // Don't use OpenSSL on Windows, instead use the native Windows backend. if target.contains("windows") { cfg.define("CRYPTO_BACKEND", "WinCNG"); } else { cfg.define("CRYPTO_BACKEND", "OpenSSL"); } // If libz-sys was built it'll give us an include directory to learn how to // link to it, and for MinGW targets we just pass a dummy include dir to // ensure it's detected (apparently it isn't otherwise?) match env::var_os("DEP_Z_INCLUDE") { Some(path) => { cfg.define("ZLIB_INCLUDE_DIR", path); } None if target.contains("windows-gnu") => { cfg.define("ZLIB_INCLUDE_DIR", "/"); } None => {} } if let Some(path) = env::var_os("DEP_OPENSSL_INCLUDE") { if let Some(path) = env::split_paths(&path).next() { if let Some(path) = path.to_str() { if path.len() > 0 { cfg.define("OPENSSL_INCLUDE_DIR", path); } } } } let dst = cfg.define("BUILD_SHARED_LIBS", "OFF") .define("ENABLE_ZLIB_COMPRESSION", "ON") .define("CMAKE_INSTALL_LIBDIR", "lib") .define("BUILD_EXAMPLES", "OFF") .define("BUILD_TESTING", "OFF") .register_dep("OPENSSL") .register_dep("Z") .build(); // Unfortunately the pkg-config file generated for libssh2 indicates // that it depends on zlib, but most systems don't actually have a // zlib.pc, so pkg-config will say that libssh2 doesn't exist. We // generally take care of the zlib dependency elsewhere, so we just // remove that part from the pkg-config file let mut pc = String::new(); let pkgconfig = dst.join("lib/pkgconfig/libssh2.pc"); if let Ok(mut f) = File::open(&pkgconfig) { f.read_to_string(&mut pc).unwrap();; drop(f); let pc = pc.replace(",zlib", ""); let bytes = pc.as_bytes(); File::create(pkgconfig).unwrap().write_all(bytes).unwrap(); } if target.contains("windows") { println!("cargo:rustc-link-lib=bcrypt"); println!("cargo:rustc-link-lib=crypt32"); println!("cargo:rustc-link-lib=user32"); } // msvc generates libssh2.lib, everywhere else generates libssh2.a if target.contains("msvc") { println!("cargo:rustc-link-lib=static=libssh2"); } else { println!("cargo:rustc-link-lib=static=ssh2"); } println!("cargo:rustc-link-search=native={}/lib", dst.display()); println!("cargo:include={}/include", dst.display()); } fn register_dep(dep: &str) { match env::var(&format!("DEP_{}_ROOT", dep)) { Ok(s) => { prepend("PKG_CONFIG_PATH", Path::new(&s).join("lib/pkgconfig")); } Err(..) => {} } } fn prepend(var: &str, val: PathBuf) { let prefix = env::var(var).unwrap_or(String::new()); let mut v = vec![val]; v.extend(env::split_paths(&prefix)); env::set_var(var, &env::join_paths(v).unwrap()); } deps/kernel32-sys-0.2.1/0000755000000000000000000000000012666635520013417 5ustar rootrootdeps/kernel32-sys-0.2.1/README.md0000644000000000000000000000040712620161461014663 0ustar rootroot# kernel32 # Contains function definitions for the Windows API library kernel32. See winapi for types and constants. ```toml [dependencies] kernel32-sys = "0.2.0" ``` ```rust extern crate kernel32; ``` [Documentation](https://retep998.github.io/doc/kernel32/) deps/kernel32-sys-0.2.1/src/0000755000000000000000000000000012666635520014206 5ustar rootrootdeps/kernel32-sys-0.2.1/src/lib.rs0000644000000000000000000042646112611475231015326 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License //! FFI bindings to kernel32. #![cfg(windows)] extern crate winapi; use winapi::*; extern "system" { pub fn AcquireSRWLockExclusive(SRWLock: PSRWLOCK); pub fn AcquireSRWLockShared(SRWLock: PSRWLOCK); pub fn ActivateActCtx(hActCtx: HANDLE, lpCookie: *mut ULONG_PTR) -> BOOL; pub fn AddAtomA(lpString: LPCSTR) -> ATOM; pub fn AddAtomW(lpString: LPCWSTR) -> ATOM; pub fn AddConsoleAliasA(Source: LPSTR, Target: LPSTR, ExeName: LPSTR) -> BOOL; pub fn AddConsoleAliasW(Source: LPWSTR, Target: LPWSTR, ExeName: LPWSTR) -> BOOL; pub fn AddDllDirectory(NewDirectory: PCWSTR) -> DLL_DIRECTORY_COOKIE; pub fn AddIntegrityLabelToBoundaryDescriptor( BoundaryDescriptor: *mut HANDLE, IntegrityLabel: PSID, ) -> BOOL; // pub fn AddLocalAlternateComputerNameA(); // pub fn AddLocalAlternateComputerNameW(); pub fn AddRefActCtx(hActCtx: HANDLE); pub fn AddResourceAttributeAce( pAcl: PACL, dwAceRevision: DWORD, AceFlags: DWORD, AccessMask: DWORD, pSid: PSID, pAttributeInfo: PCLAIM_SECURITY_ATTRIBUTES_INFORMATION, pReturnLength: PDWORD, ) -> BOOL; pub fn AddSIDToBoundaryDescriptor(BoundaryDescriptor: *mut HANDLE, RequiredSid: PSID) -> BOOL; pub fn AddScopedPolicyIDAce( pAcl: PACL, dwAceRevision: DWORD, AceFlags: DWORD, AccessMask: DWORD, pSid: PSID, ) -> BOOL; pub fn AddSecureMemoryCacheCallback(pfnCallBack: PSECURE_MEMORY_CACHE_CALLBACK) -> BOOL; pub fn AddVectoredContinueHandler(First: ULONG, Handler: PVECTORED_EXCEPTION_HANDLER) -> PVOID; pub fn AddVectoredExceptionHandler( First: ULONG, Handler: PVECTORED_EXCEPTION_HANDLER, ) -> PVOID; pub fn AllocConsole() -> BOOL; pub fn AllocateUserPhysicalPages( hProcess: HANDLE, NumberOfPages: PULONG_PTR, PageArray: PULONG_PTR, ) -> BOOL; pub fn AllocateUserPhysicalPagesNuma( hProcess: HANDLE, NumberOfPages: PULONG_PTR, PageArray: PULONG_PTR, nndPreferred: DWORD, ) -> BOOL; // pub fn AppXGetOSMaxVersionTested(); pub fn ApplicationRecoveryFinished(bSuccess: BOOL); pub fn ApplicationRecoveryInProgress(pbCancelled: PBOOL) -> HRESULT; pub fn AreFileApisANSI() -> BOOL; pub fn AssignProcessToJobObject(hJob: HANDLE, hProcess: HANDLE) -> BOOL; pub fn AttachConsole(dwProcessId: DWORD) -> BOOL; pub fn BackupRead( hFile: HANDLE, lpBuffer: LPBYTE, nNumberOfBytesToRead: DWORD, lpNumberOfBytesRead: LPDWORD, bAbort: BOOL, bProcessSecurity: BOOL, lpContext: *mut LPVOID, ) -> BOOL; pub fn BackupSeek( hFile: HANDLE, dwLowBytesToSeek: DWORD, dwHighBytesToSeek: DWORD, lpdwLowByteSeeked: LPDWORD, lpdwHighByteSeeked: LPDWORD, lpContext: *mut LPVOID, ) -> BOOL; pub fn BackupWrite( hFile: HANDLE, lpBuffer: LPBYTE, nNumberOfBytesToWrite: DWORD, lpNumberOfBytesWritten: LPDWORD, bAbort: BOOL, bProcessSecurity: BOOL, lpContext: *mut LPVOID, ) -> BOOL; // pub fn BaseSetLastNTError(); pub fn Beep(dwFreq: DWORD, dwDuration: DWORD) -> BOOL; pub fn BeginUpdateResourceA(pFileName: LPCSTR, bDeleteExistingResources: BOOL) -> HANDLE; pub fn BeginUpdateResourceW(pFileName: LPCWSTR, bDeleteExistingResources: BOOL) -> HANDLE; pub fn BindIoCompletionCallback( FileHandle: HANDLE, Function: LPOVERLAPPED_COMPLETION_ROUTINE, Flags: ULONG, ) -> BOOL; pub fn BuildCommDCBA(lpDef: LPCSTR, lpDCB: LPDCB) -> BOOL; pub fn BuildCommDCBAndTimeoutsA( lpDef: LPCSTR, lpDCB: LPDCB, lpCommTimeouts: LPCOMMTIMEOUTS, ) -> BOOL; pub fn BuildCommDCBAndTimeoutsW( lpDef: LPCWSTR, lpDCB: LPDCB, lpCommTimeouts: LPCOMMTIMEOUTS, ) -> BOOL; pub fn BuildCommDCBW(lpDef: LPCWSTR, lpDCB: LPDCB) -> BOOL; pub fn CallNamedPipeA( lpNamedPipeName: LPCSTR, lpInBuffer: LPVOID, nInBufferSize: DWORD, lpOutBuffer: LPVOID, nOutBufferSize: DWORD, lpBytesRead: LPDWORD, nTimeOut: DWORD, ) -> BOOL; pub fn CallNamedPipeW( lpNamedPipeName: LPCWSTR, lpInBuffer: LPVOID, nInBufferSize: DWORD, lpOutBuffer: LPVOID, nOutBufferSize: DWORD, lpBytesRead: LPDWORD, nTimeOut: DWORD, ) -> BOOL; pub fn CallbackMayRunLong(pci: PTP_CALLBACK_INSTANCE) -> BOOL; pub fn CalloutOnFiberStack( lpFiber: PVOID, lpStartAddress: PFIBER_CALLOUT_ROUTINE, lpParameter: PVOID, ) -> PVOID; pub fn CancelDeviceWakeupRequest(hDevice: HANDLE) -> BOOL; pub fn CancelIo(hFile: HANDLE) -> BOOL; pub fn CancelIoEx(hFile: HANDLE, lpOverlapped: LPOVERLAPPED) -> BOOL; pub fn CancelSynchronousIo(hThread: HANDLE) -> BOOL; pub fn CancelThreadpoolIo(pio: PTP_IO); pub fn CancelTimerQueueTimer(TimerQueue: HANDLE, Timer: HANDLE) -> BOOL; pub fn CancelWaitableTimer(hTimer: HANDLE) -> BOOL; pub fn CeipIsOptedIn() -> BOOL; pub fn ChangeTimerQueueTimer( TimerQueue: HANDLE, Timer: HANDLE, DueTime: ULONG, Period: ULONG, ) -> BOOL; // pub fn CheckElevation(); // pub fn CheckElevationEnabled(); pub fn CheckNameLegalDOS8Dot3A( lpName: LPCSTR, lpOemName: LPSTR, OemNameSize: DWORD, pbNameContainsSpaces: PBOOL, pbNameLegal: PBOOL, ) -> BOOL; pub fn CheckNameLegalDOS8Dot3W( lpName: LPCWSTR, lpOemName: LPSTR, OemNameSize: DWORD, pbNameContainsSpaces: PBOOL, pbNameLegal: PBOOL, ) -> BOOL; pub fn CheckRemoteDebuggerPresent(hProcess: HANDLE, pbDebuggerPresent: PBOOL) -> BOOL; pub fn CheckTokenCapability( TokenHandle: HANDLE, CapabilitySidToCheck: PSID, HasCapability: PBOOL, ) -> BOOL; pub fn CheckTokenMembershipEx( TokenHandle: HANDLE, SidToCheck: PSID, Flags: DWORD, IsMember: PBOOL, ) -> BOOL; pub fn ClearCommBreak(hFile: HANDLE) -> BOOL; pub fn ClearCommError(hFile: HANDLE, lpErrors: LPDWORD, lpStat: LPCOMSTAT) -> BOOL; pub fn CloseHandle(hObject: HANDLE) -> BOOL; // pub fn ClosePackageInfo(); pub fn ClosePrivateNamespace(Handle: HANDLE, Flags: ULONG) -> BOOLEAN; // pub fn CloseState(); pub fn CloseThreadpool(ptpp: PTP_POOL); pub fn CloseThreadpoolCleanupGroup(ptpcg: PTP_CLEANUP_GROUP); pub fn CloseThreadpoolCleanupGroupMembers( ptpcg: PTP_CLEANUP_GROUP, fCancelPendingCallbacks: BOOL, pvCleanupContext: PVOID, ); pub fn CloseThreadpoolIo(pio: PTP_IO); pub fn CloseThreadpoolTimer(pti: PTP_TIMER); pub fn CloseThreadpoolWait(pwa: PTP_WAIT); pub fn CloseThreadpoolWork(pwk: PTP_WORK); pub fn CommConfigDialogA(lpszName: LPCSTR, hWnd: HWND, lpCC: LPCOMMCONFIG) -> BOOL; pub fn CommConfigDialogW(lpszName: LPCWSTR, hWnd: HWND, lpCC: LPCOMMCONFIG) -> BOOL; pub fn CompareFileTime(lpFileTime1: *const FILETIME, lpFileTime2: *const FILETIME) -> LONG; pub fn CompareStringA( Locale: LCID, dwCmpFlags: DWORD, lpString1: PCNZCH, cchCount1: c_int, lpString2: PCNZCH, cchCount2: c_int, ) -> c_int; pub fn CompareStringEx( lpLocaleName: LPCWSTR, dwCmpFlags: DWORD, lpString1: LPCWCH, cchCount1: c_int, lpString2: LPCWCH, cchCount2: c_int, lpVersionInformation: LPNLSVERSIONINFO, lpReserved: LPVOID, lParam: LPARAM, ) -> c_int; pub fn CompareStringOrdinal( lpString1: LPCWCH, cchCount1: c_int, lpString2: LPCWCH, cchCount2: c_int, bIgnoreCase: BOOL, ) -> c_int; pub fn CompareStringW( Locale: LCID, dwCmpFlags: DWORD, lpString1: PCNZWCH, cchCount1: c_int, lpString2: PCNZWCH, cchCount2: c_int, ) -> c_int; pub fn ConnectNamedPipe(hNamedPipe: HANDLE, lpOverlapped: LPOVERLAPPED) -> BOOL; pub fn ContinueDebugEvent( dwProcessId: DWORD, dwThreadId: DWORD, dwContinueStatus: DWORD, ) -> BOOL; pub fn ConvertDefaultLocale(Locale: LCID) -> LCID; pub fn ConvertFiberToThread() -> BOOL; pub fn ConvertThreadToFiber(lpParameter: LPVOID) -> LPVOID; pub fn ConvertThreadToFiberEx(lpParameter: LPVOID, dwFlags: DWORD) -> LPVOID; pub fn CopyContext(Destination: PCONTEXT, ContextFlags: DWORD, Source: PCONTEXT) -> BOOL; pub fn CopyFile2( pwszExistingFileName: PCWSTR, pwszNewFileName: PCWSTR, pExtendedParameters: *mut COPYFILE2_EXTENDED_PARAMETERS, ) -> HRESULT; pub fn CopyFileA( lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR, bFailIfExists: BOOL ) -> BOOL; pub fn CopyFileExA( lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR, lpProgressRoutine: LPPROGRESS_ROUTINE, lpData: LPVOID, pbCancel: LPBOOL, dwCopyFlags: DWORD, ) -> BOOL; pub fn CopyFileExW( lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR, lpProgressRoutine: LPPROGRESS_ROUTINE, lpData: LPVOID, pbCancel: LPBOOL, dwCopyFlags: DWORD, ) -> BOOL; pub fn CopyFileTransactedA( lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR, lpProgressRoutine: LPPROGRESS_ROUTINE, lpData: LPVOID, pbCancel: LPBOOL, dwCopyFlags: DWORD, hTransaction: HANDLE, ) -> BOOL; pub fn CopyFileTransactedW( lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR, lpProgressRoutine: LPPROGRESS_ROUTINE, lpData: LPVOID, pbCancel: LPBOOL, dwCopyFlags: DWORD, hTransaction: HANDLE, ) -> BOOL; pub fn CopyFileW( lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR, bFailIfExists: BOOL ) -> BOOL; pub fn CreateActCtxA(pActCtx: PCACTCTXA) -> HANDLE; pub fn CreateActCtxW(pActCtx: PCACTCTXW) -> HANDLE; pub fn CreateBoundaryDescriptorA(Name: LPCSTR, Flags: ULONG) -> HANDLE; pub fn CreateBoundaryDescriptorW(Name: LPCWSTR, Flags: ULONG) -> HANDLE; pub fn CreateConsoleScreenBuffer( dwDesiredAccess: DWORD, dwShareMode: DWORD, lpSecurityAttributes: *const SECURITY_ATTRIBUTES, dwFlags: DWORD, lpScreenBufferData: LPVOID, ) -> HANDLE; pub fn CreateDirectoryA( lpPathName: LPCSTR, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, ) -> BOOL; pub fn CreateDirectoryExA( lpTemplateDirectory: LPCSTR, lpNewDirectory: LPCSTR, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, ) -> BOOL; pub fn CreateDirectoryExW( lpTemplateDirectory: LPCWSTR, lpNewDirectory: LPCWSTR, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, ) -> BOOL; pub fn CreateDirectoryTransactedA( lpTemplateDirectory: LPCSTR, lpNewDirectory: LPCSTR, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, hTransaction: HANDLE, ) -> BOOL; pub fn CreateDirectoryTransactedW( lpTemplateDirectory: LPCWSTR, lpNewDirectory: LPCWSTR, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, hTransaction: HANDLE, ) -> BOOL; pub fn CreateDirectoryW( lpPathName: LPCWSTR, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, ) -> BOOL; pub fn CreateEventA( lpEventAttributes: LPSECURITY_ATTRIBUTES, bManualReset: BOOL, bInitialState: BOOL, lpName: LPCSTR, ) -> HANDLE; pub fn CreateEventW( lpEventAttributes: LPSECURITY_ATTRIBUTES, bManualReset: BOOL, bInitialState: BOOL, lpName: LPCWSTR, ) -> HANDLE; pub fn CreateEventExA( lpEventAttributes: LPSECURITY_ATTRIBUTES, lpName: LPCSTR, dwFlags: DWORD, dwDesiredAccess: DWORD, ) -> HANDLE; pub fn CreateEventExW( lpEventAttributes: LPSECURITY_ATTRIBUTES, lpName: LPWSTR, dwFlags: DWORD, dwDesiredAccess: DWORD, ) -> HANDLE; pub fn CreateFiber( dwStackSize: SIZE_T, lpStartAddress: LPFIBER_START_ROUTINE, lpParameter: LPVOID, ) -> LPVOID; pub fn CreateFiberEx( dwStackCommitSize: SIZE_T, dwStackReserveSize: SIZE_T, dwFlags: DWORD, lpStartAddress: LPFIBER_START_ROUTINE, lpParameter: LPVOID, ) -> LPVOID; pub fn CreateFile2( lpFileName: LPCWSTR, dwDesiredAccess: DWORD, dwShareMode: DWORD, dwCreationDisposition: DWORD, pCreateExParams: LPCREATEFILE2_EXTENDED_PARAMETERS, ) -> HANDLE; pub fn CreateFileA( lpFileName: LPCSTR, dwDesiredAccess: DWORD, dwShareMode: DWORD, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, dwCreationDisposition: DWORD, dwFlagsAndAttributes: DWORD, hTemplateFile: HANDLE, ) -> HANDLE; pub fn CreateFileMappingA( hFile: HANDLE, lpAttributes: LPSECURITY_ATTRIBUTES, flProtect: DWORD, dwMaximumSizeHigh: DWORD, dwMaximumSizeLow: DWORD, lpName: LPCSTR, ) -> HANDLE; pub fn CreateFileMappingFromApp( hFile: HANDLE, SecurityAttributes: PSECURITY_ATTRIBUTES, PageProtection: ULONG, MaximumSize: ULONG64, Name: PCWSTR, ) -> HANDLE; pub fn CreateFileMappingNumaA( hFile: HANDLE, lpFileMappingAttributes: LPSECURITY_ATTRIBUTES, flProtect: DWORD, dwMaximumSizeHigh: DWORD, dwMaximumSizeLow: DWORD, lpName: LPCSTR, nndPreferred: DWORD, ) -> HANDLE; pub fn CreateFileMappingNumaW( hFile: HANDLE, lpFileMappingAttributes: LPSECURITY_ATTRIBUTES, flProtect: DWORD, dwMaximumSizeHigh: DWORD, dwMaximumSizeLow: DWORD, lpName: LPCWSTR, nndPreferred: DWORD, ) -> HANDLE; pub fn CreateFileMappingW( hFile: HANDLE, lpAttributes: LPSECURITY_ATTRIBUTES, flProtect: DWORD, dwMaximumSizeHigh: DWORD, dwMaximumSizeLow: DWORD, lpName: LPCWSTR, ) -> HANDLE; pub fn CreateFileTransactedA( lpFileName: LPCSTR, dwDesiredAccess: DWORD, dwShareMode: DWORD, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, dwCreationDisposition: DWORD, dwFlagsAndAttributes: DWORD, hTemplateFile: HANDLE, hTransaction: HANDLE, pusMiniVersion: PUSHORT, lpExtendedParameter: PVOID, ) -> HANDLE; pub fn CreateFileTransactedW( lpFileName: LPCWSTR, dwDesiredAccess: DWORD, dwShareMode: DWORD, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, dwCreationDisposition: DWORD, dwFlagsAndAttributes: DWORD, hTemplateFile: HANDLE, hTransaction: HANDLE, pusMiniVersion: PUSHORT, lpExtendedParameter: PVOID, ) -> HANDLE; pub fn CreateFileW( lpFileName: LPCWSTR, dwDesiredAccess: DWORD, dwShareMode: DWORD, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, dwCreationDisposition: DWORD, dwFlagsAndAttributes: DWORD, hTemplateFile: HANDLE, ) -> HANDLE; pub fn CreateHardLinkA( lpFileName: LPCSTR, lpExistingFileName: LPCSTR, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, ) -> BOOL; pub fn CreateHardLinkTransactedA( lpFileName: LPCSTR, lpExistingFileName: LPCSTR, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, hTransaction: HANDLE, ) -> BOOL; pub fn CreateHardLinkTransactedW( lpFileName: LPCWSTR, lpExistingFileName: LPCWSTR, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, hTransaction: HANDLE, ); pub fn CreateHardLinkW( lpFileName: LPCWSTR, lpExistingFileName: LPCWSTR, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, ) -> BOOL; pub fn CreateIoCompletionPort( FileHandle: HANDLE, ExistingCompletionPort: HANDLE, CompletionKey: ULONG_PTR, NumberOfConcurrentThreads: DWORD, ) -> HANDLE; pub fn CreateJobObjectA(lpJobAttributes: LPSECURITY_ATTRIBUTES, lpName: LPCSTR) -> HANDLE; pub fn CreateJobObjectW(lpJobAttributes: LPSECURITY_ATTRIBUTES, lpName: LPCWSTR) -> HANDLE; pub fn CreateJobSet(NumJob: ULONG, UserJobSet: PJOB_SET_ARRAY, Flags: ULONG) -> BOOL; pub fn CreateMailslotA( lpName: LPCSTR, nMaxMessageSize: DWORD, lReadTimeout: DWORD, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, ) -> HANDLE; pub fn CreateMailslotW( lpName: LPCWSTR, nMaxMessageSize: DWORD, lReadTimeout: DWORD, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, ) -> HANDLE; pub fn CreateMemoryResourceNotification( NotificationType: MEMORY_RESOURCE_NOTIFICATION_TYPE, ) -> HANDLE; pub fn CreateMutexA( lpMutexAttributes: LPSECURITY_ATTRIBUTES, bInitialOwner: BOOL, lpName: LPCSTR, ) -> HANDLE; pub fn CreateMutexExA( lpMutexAttributes: LPSECURITY_ATTRIBUTES, lpName: LPCSTR, dwFlags: DWORD, dwDesiredAccess: DWORD, ) -> HANDLE; pub fn CreateMutexExW( lpMutexAttributes: LPSECURITY_ATTRIBUTES, lpName: LPCWSTR, dwFlags: DWORD, dwDesiredAccess: DWORD, ) -> HANDLE; pub fn CreateMutexW( lpMutexAttributes: LPSECURITY_ATTRIBUTES, bInitialOwner: BOOL, lpName: LPCWSTR, ) -> HANDLE; pub fn CreateNamedPipeA( lpName: LPCSTR, dwOpenMode: DWORD, dwPipeMode: DWORD, nMaxInstances: DWORD, nOutBufferSize: DWORD, nInBufferSize: DWORD, nDefaultTimeOut: DWORD, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, ) -> HANDLE; pub fn CreateNamedPipeW( lpName: LPCWSTR, dwOpenMode: DWORD, dwPipeMode: DWORD, nMaxInstances: DWORD, nOutBufferSize: DWORD, nInBufferSize: DWORD, nDefaultTimeOut: DWORD, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, ) -> HANDLE; pub fn CreatePipe( hReadPipe: PHANDLE, hWritePipe: PHANDLE, lpPipeAttributes: LPSECURITY_ATTRIBUTES, nSize: DWORD, ) -> BOOL; pub fn CreatePrivateNamespaceA( lpPrivateNamespaceAttributes: LPSECURITY_ATTRIBUTES, lpBoundaryDescriptor: LPVOID, lpAliasPrefix: LPCSTR, ) -> HANDLE; pub fn CreatePrivateNamespaceW( lpPrivateNamespaceAttributes: LPSECURITY_ATTRIBUTES, lpBoundaryDescriptor: LPVOID, lpAliasPrefix: LPCWSTR, ) -> HANDLE; pub fn CreateProcessA( lpApplicationName: LPCSTR, lpCommandLine: LPSTR, lpProcessAttributes: LPSECURITY_ATTRIBUTES, lpThreadAttributes: LPSECURITY_ATTRIBUTES, bInheritHandles: BOOL, dwCreationFlags: DWORD, lpEnvironment: LPVOID, lpCurrentDirectory: LPCSTR, lpStartupInfo: LPSTARTUPINFOA, lpProcessInformation: LPPROCESS_INFORMATION, ) -> BOOL; pub fn CreateProcessW( lpApplicationName: LPCWSTR, lpCommandLine: LPWSTR, lpProcessAttributes: LPSECURITY_ATTRIBUTES, lpThreadAttributes: LPSECURITY_ATTRIBUTES, bInheritHandles: BOOL, dwCreationFlags: DWORD, lpEnvironment: LPVOID, lpCurrentDirectory: LPCWSTR, lpStartupInfo: LPSTARTUPINFOW, lpProcessInformation: LPPROCESS_INFORMATION, ) -> BOOL; pub fn CreateRemoteThread( hProcess: HANDLE, lpThreadAttributes: LPSECURITY_ATTRIBUTES, dwStackSize: SIZE_T, lpStartAddress: LPTHREAD_START_ROUTINE, lpParameter: LPVOID, dwCreationFlags: DWORD, lpThreadId: LPDWORD, ) -> HANDLE; pub fn CreateRemoteThreadEx( hProcess: HANDLE, lpThreadAttributes: LPSECURITY_ATTRIBUTES, dwStackSize: SIZE_T, lpStartAddress: LPTHREAD_START_ROUTINE, lpParameter: LPVOID, dwCreationFlags: DWORD, lpAttributeList: LPPROC_THREAD_ATTRIBUTE_LIST, lpThreadId: LPDWORD, ) -> HANDLE; pub fn CreateSemaphoreA( lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES, lInitialCount: LONG, lMaximumCount: LONG, lpName: LPCSTR, ) -> HANDLE; pub fn CreateSemaphoreExA( lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES, lInitialCount: LONG, lMaximumCount: LONG, lpName: LPCSTR, dwFlags: DWORD, dwDesiredAccess: DWORD, ) -> HANDLE; pub fn CreateSemaphoreExW( lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES, lInitialCount: LONG, lMaximumCount: LONG, lpName: LPCWSTR, dwFlags: DWORD, dwDesiredAccess: DWORD, ) -> HANDLE; pub fn CreateSemaphoreW( lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES, lInitialCount: LONG, lMaximumCount: LONG, lpName: LPCWSTR, ) -> HANDLE; pub fn CreateSymbolicLinkA( lpSymlinkFileName: LPCSTR, lpTargetFileName: LPCSTR, dwFlags: DWORD, ) -> BOOLEAN; pub fn CreateSymbolicLinkTransactedA( lpSymlinkFileName: LPCSTR, lpTargetFileName: LPCSTR, dwFlags: DWORD, hTransaction: HANDLE, ) -> BOOLEAN; pub fn CreateSymbolicLinkTransactedW( lpSymlinkFileName: LPCWSTR, lpTargetFileName: LPCWSTR, dwFlags: DWORD, hTransaction: HANDLE, ) -> BOOLEAN; pub fn CreateSymbolicLinkW( lpSymlinkFileName: LPCWSTR, lpTargetFileName: LPCWSTR, dwFlags: DWORD, ) -> BOOLEAN; pub fn CreateTapePartition( hDevice: HANDLE, dwPartitionMethod: DWORD, dwCount: DWORD, dwSize: DWORD, ) -> DWORD; pub fn CreateThread( lpThreadAttributes: LPSECURITY_ATTRIBUTES, dwStackSize: SIZE_T, lpStartAddress: LPTHREAD_START_ROUTINE, lpParameter: LPVOID, dwCreationFlags: DWORD, lpThreadId: LPDWORD, ) -> HANDLE; pub fn CreateThreadpool(reserved: PVOID) -> PTP_POOL; pub fn CreateThreadpoolCleanupGroup() -> PTP_CLEANUP_GROUP; pub fn CreateThreadpoolIo( fl: HANDLE, pfnio: PTP_WIN32_IO_CALLBACK, pv: PVOID, pcbe: PTP_CALLBACK_ENVIRON, ) -> PTP_IO; pub fn CreateThreadpoolTimer( pfnti: PTP_TIMER_CALLBACK, pv: PVOID, pcbe: PTP_CALLBACK_ENVIRON, ) -> PTP_TIMER; pub fn CreateThreadpoolWait( pfnwa: PTP_WAIT_CALLBACK, pv: PVOID, pcbe: PTP_CALLBACK_ENVIRON, ) -> PTP_WAIT; pub fn CreateThreadpoolWork( pfnwk: PTP_WORK_CALLBACK, pv: PVOID, pcbe: PTP_CALLBACK_ENVIRON, ) -> PTP_WORK; pub fn CreateTimerQueue() -> HANDLE; pub fn CreateTimerQueueTimer( phNewTimer: PHANDLE, TimerQueue: HANDLE, Callback: WAITORTIMERCALLBACK, Parameter: PVOID, DueTime: DWORD, Period: DWORD, Flags: ULONG, ) -> BOOL; pub fn CreateToolhelp32Snapshot(dwFlags: DWORD, th32ProcessID: DWORD) -> HANDLE; #[cfg(target_arch = "x86_64")] pub fn CreateUmsCompletionList(UmsCompletionList: *mut PUMS_COMPLETION_LIST) -> BOOL; #[cfg(target_arch = "x86_64")] pub fn CreateUmsThreadContext(lpUmsThread: *mut PUMS_CONTEXT) -> BOOL; pub fn CreateWaitableTimerA( lpTimerAttributes: LPSECURITY_ATTRIBUTES, bManualReset: BOOL, lpTimerName: LPCSTR, ) -> HANDLE; pub fn CreateWaitableTimerExA( lpTimerAttributes: LPSECURITY_ATTRIBUTES, lpTimerName: LPCSTR, dwFlags: DWORD, dwDesiredAccess: DWORD, ) -> HANDLE; pub fn CreateWaitableTimerExW( lpTimerAttributes: LPSECURITY_ATTRIBUTES, lpTimerName: LPCWSTR, dwFlags: DWORD, dwDesiredAccess: DWORD, ) -> HANDLE; pub fn CreateWaitableTimerW( lpTimerAttributes: LPSECURITY_ATTRIBUTES, bManualReset: BOOL, lpTimerName: LPCWSTR, ) -> HANDLE; // pub fn CtrlRoutine(); pub fn DeactivateActCtx(dwFlags: DWORD, ulCookie: ULONG_PTR) -> BOOL; pub fn DebugActiveProcess(dwProcessId: DWORD) -> BOOL; pub fn DebugActiveProcessStop(dwProcessId: DWORD) -> BOOL; pub fn DebugBreak(); pub fn DebugBreakProcess(Process: HANDLE) -> BOOL; pub fn DebugSetProcessKillOnExit(KillOnExit: BOOL) -> BOOL; pub fn DecodePointer(Ptr: PVOID) -> PVOID; pub fn DecodeSystemPointer(Ptr: PVOID) -> PVOID; pub fn DefineDosDeviceA(dwFlags: DWORD, lpDeviceName: LPCSTR, lpTargetPath: LPCSTR) -> BOOL; pub fn DefineDosDeviceW(dwFlags: DWORD, lpDeviceName: LPCWSTR, lpTargetPath: LPCWSTR) -> BOOL; pub fn DelayLoadFailureHook(pszDllName: LPCSTR, pszProcName: LPCSTR); pub fn DeleteAtom(nAtom: ATOM) -> ATOM; pub fn DeleteBoundaryDescriptor(BoundaryDescriptor: HANDLE); pub fn DeleteCriticalSection(lpCriticalSection: LPCRITICAL_SECTION); pub fn DeleteFiber(lpFiber: LPVOID); pub fn DeleteFileA(lpFileName: LPCSTR) -> BOOL; pub fn DeleteFileTransactedA(lpFileName: LPCSTR, hTransaction: HANDLE) -> BOOL; pub fn DeleteFileTransactedW(lpFileName: LPCWSTR, hTransaction: HANDLE) -> BOOL; pub fn DeleteFileW(lpFileName: LPCWSTR) -> BOOL; pub fn DeleteProcThreadAttributeList(lpAttributeList: LPPROC_THREAD_ATTRIBUTE_LIST); pub fn DeleteSynchronizationBarrier(lpBarrier: LPSYNCHRONIZATION_BARRIER) -> BOOL; pub fn DeleteTimerQueue(TimerQueue: HANDLE) -> BOOL; pub fn DeleteTimerQueueEx(TimerQueue: HANDLE, CompletionEvent: HANDLE) -> BOOL; pub fn DeleteTimerQueueTimer( TimerQueue: HANDLE, Timer: HANDLE, CompletionEvent: HANDLE, ) -> BOOL; #[cfg(target_arch = "x86_64")] pub fn DeleteUmsCompletionList(UmsCompletionList: PUMS_COMPLETION_LIST) -> BOOL; #[cfg(target_arch = "x86_64")] pub fn DeleteUmsThreadContext(UmsThread: PUMS_CONTEXT) -> BOOL; pub fn DeleteVolumeMountPointA(lpszVolumeMountPoint: LPCSTR) -> BOOL; pub fn DeleteVolumeMountPointW(lpszVolumeMountPoint: LPCWSTR) -> BOOL; #[cfg(target_arch = "x86_64")] pub fn DequeueUmsCompletionListItems( UmsCompletionList: PUMS_COMPLETION_LIST, WaitTimeOut: DWORD, UmsThreadList: *mut PUMS_CONTEXT, ) -> BOOL; pub fn DeviceIoControl( hDevice: HANDLE, dwIoControlCode: DWORD, lpInBuffer: LPVOID, nInBufferSize: DWORD, lpOutBuffer: LPVOID, nOutBufferSize: DWORD, lpBytesReturned: LPDWORD, lpOverlapped: LPOVERLAPPED, ) -> BOOL; pub fn DisableThreadLibraryCalls(hLibModule: HMODULE) -> BOOL; pub fn DisableThreadProfiling(PerformanceDataHandle: HANDLE) -> DWORD; pub fn DisassociateCurrentThreadFromCallback(pci: PTP_CALLBACK_INSTANCE); pub fn DisconnectNamedPipe(hNamedPipe: HANDLE) -> BOOL; pub fn DnsHostnameToComputerNameA( Hostname: LPCSTR, ComputerName: LPCSTR, nSize: LPDWORD, ) -> BOOL; pub fn DnsHostnameToComputerNameExW( Hostname: LPCWSTR, ComputerName: LPWSTR, nSize: LPDWORD, ) -> BOOL; pub fn DnsHostnameToComputerNameW( Hostname: LPCWSTR, ComputerName: LPWSTR, nSize: LPDWORD, ) -> BOOL; pub fn DosDateTimeToFileTime(wFatDate: WORD, wFatTime: WORD, lpFileTime: LPFILETIME) -> BOOL; // pub fn DosPathToSessionPathW(); pub fn DuplicateHandle( hSourceProcessHandle: HANDLE, hSourceHandle: HANDLE, hTargetProcessHandle: HANDLE, lpTargetHandle: LPHANDLE, dwDesiredAccess: DWORD, bInheritHandle: BOOL, dwOptions: DWORD, ) -> BOOL; pub fn EnableThreadProfiling( ThreadHandle: HANDLE, Flags: DWORD, HardwareCounters: DWORD64, PerformanceDataHandle: *mut HANDLE, ) -> BOOL; pub fn EncodePointer(Ptr: PVOID) -> PVOID; pub fn EncodeSystemPointer(Ptr: PVOID) -> PVOID; pub fn EndUpdateResourceA(hUpdate: HANDLE, fDiscard: BOOL) -> BOOL; pub fn EndUpdateResourceW(hUpdate: HANDLE, fDiscard: BOOL) -> BOOL; pub fn EnterCriticalSection(lpCriticalSection: LPCRITICAL_SECTION); pub fn EnterSynchronizationBarrier( lpBarrier: LPSYNCHRONIZATION_BARRIER, dwFlags: DWORD, ) -> BOOL; #[cfg(target_arch = "x86_64")] pub fn EnterUmsSchedulingMode(SchedulerStartupInfo: PUMS_SCHEDULER_STARTUP_INFO) -> BOOL; pub fn EnumCalendarInfoA( lpCalInfoEnumProc: CALINFO_ENUMPROCA, Locale: LCID, Calendar: CALID, CalType: CALTYPE, ) -> BOOL; pub fn EnumCalendarInfoExA( lpCalInfoEnumProcEx: CALINFO_ENUMPROCEXA, Locale: LCID, Calendar: CALID, CalType: CALTYPE, ) -> BOOL; pub fn EnumCalendarInfoExEx( pCalInfoEnumProcExEx: CALINFO_ENUMPROCEXEX, lpLocaleName: LPCWSTR, Calendar: CALID, lpReserved: LPCWSTR, CalType: CALTYPE, lParam: LPARAM, ) -> BOOL; pub fn EnumCalendarInfoExW( lpCalInfoEnumProcEx: CALINFO_ENUMPROCEXW, Locale: LCID, Calendar: CALID, CalType: CALTYPE, ) -> BOOL; pub fn EnumCalendarInfoW( lpCalInfoEnumProc: CALINFO_ENUMPROCW, Locale: LCID, Calendar: CALID, CalType: CALTYPE, ) -> BOOL; pub fn EnumDateFormatsA( lpDateFmtEnumProc: DATEFMT_ENUMPROCA, Locale: LCID, dwFlags: DWORD, ) -> BOOL; pub fn EnumDateFormatsExA( lpDateFmtEnumProcEx: DATEFMT_ENUMPROCEXA, Locale: LCID, dwFlags: DWORD, ) -> BOOL; pub fn EnumDateFormatsExEx( lpDateFmtEnumProcExEx: DATEFMT_ENUMPROCEXEX, lpLocaleName: LPCWSTR, dwFlags: DWORD, lParam: LPARAM, ) -> BOOL; pub fn EnumDateFormatsExW( lpDateFmtEnumProcEx: DATEFMT_ENUMPROCEXW, Locale: LCID, dwFlags: DWORD, ) -> BOOL; pub fn EnumDateFormatsW( lpDateFmtEnumProc: DATEFMT_ENUMPROCW, Locale: LCID, dwFlags: DWORD, ) -> BOOL; pub fn EnumLanguageGroupLocalesA( lpLangGroupLocaleEnumProc: LANGGROUPLOCALE_ENUMPROCA, LanguageGroup: LGRPID, dwFlags: DWORD, lParam: LONG_PTR, ) -> BOOL; pub fn EnumLanguageGroupLocalesW( lpLangGroupLocaleEnumProc: LANGGROUPLOCALE_ENUMPROCW, LanguageGroup: LGRPID, dwFlags: DWORD, lParam: LONG_PTR, ) -> BOOL; pub fn EnumResourceLanguagesA( hModule: HMODULE, lpType: LPCSTR, lpName: LPCSTR, lpEnumFunc: ENUMRESLANGPROCA, lParam: LONG_PTR, ) -> BOOL; pub fn EnumResourceLanguagesExA( hModule: HMODULE, lpType: LPCSTR, lpName: LPCSTR, lpEnumFunc: ENUMRESLANGPROCA, lParam: LONG_PTR, dwFlags: DWORD, LangId: LANGID, ) -> BOOL; pub fn EnumResourceLanguagesExW( hModule: HMODULE, lpType: LPCWSTR, lpName: LPCWSTR, lpEnumFunc: ENUMRESLANGPROCW, lParam: LONG_PTR, dwFlags: DWORD, LangId: LANGID, ) -> BOOL; pub fn EnumResourceLanguagesW( hModule: HMODULE, lpType: LPCWSTR, lpName: LPCWSTR, lpEnumFunc: ENUMRESLANGPROCW, lParam: LONG_PTR, ) -> BOOL; pub fn EnumResourceNamesA( hModule: HMODULE, lpType: LPCSTR, lpEnumFunc: ENUMRESNAMEPROCA, lParam: LONG_PTR, ) -> BOOL; pub fn EnumResourceNamesExA( hModule: HMODULE, lpType: LPCSTR, lpEnumFunc: ENUMRESNAMEPROCA, lParam: LONG_PTR, dwFlags: DWORD, LangId: LANGID, ) -> BOOL; pub fn EnumResourceNamesExW( hModule: HMODULE, lpType: LPCWSTR, lpEnumFunc: ENUMRESNAMEPROCW, lParam: LONG_PTR, dwFlags: DWORD, LangId: LANGID, ) -> BOOL; pub fn EnumResourceNamesW( hModule: HMODULE, lpType: LPCWSTR, lpEnumFunc: ENUMRESNAMEPROCW, lParam: LONG_PTR, ) -> BOOL; pub fn EnumResourceTypesA( hModule: HMODULE, lpEnumFunc: ENUMRESTYPEPROCA, lParam: LONG_PTR, ) -> BOOL; pub fn EnumResourceTypesExA( hModule: HMODULE, lpEnumFunc: ENUMRESTYPEPROCA, lParam: LONG_PTR, dwFlags: DWORD, LangId: LANGID, ) -> BOOL; pub fn EnumResourceTypesExW( hModule: HMODULE, lpEnumFunc: ENUMRESTYPEPROCW, lParam: LONG_PTR, dwFlags: DWORD, LangId: LANGID, ) -> BOOL; pub fn EnumResourceTypesW( hModule: HMODULE, lpEnumFunc: ENUMRESTYPEPROCW, lParam: LONG_PTR, ) -> BOOL; pub fn EnumSystemCodePagesA(lpCodePageEnumProc: CODEPAGE_ENUMPROCA, dwFlags: DWORD) -> BOOL; pub fn EnumSystemCodePagesW(lpCodePageEnumProc: CODEPAGE_ENUMPROCW, dwFlags: DWORD) -> BOOL; pub fn EnumSystemFirmwareTables( FirmwareTableProviderSignature: DWORD, pFirmwareTableEnumBuffer: PVOID, BufferSize: DWORD, ) -> UINT; pub fn EnumSystemGeoID( GeoClass: GEOCLASS, ParentGeoId: GEOID, lpGeoEnumProc: GEO_ENUMPROC, ) -> BOOL; pub fn EnumSystemLanguageGroupsA( lpLanguageGroupEnumProc: LANGUAGEGROUP_ENUMPROCA, dwFlags: DWORD, lParam: LONG_PTR, ) -> BOOL; pub fn EnumSystemLanguageGroupsW( lpLanguageGroupEnumProc: LANGUAGEGROUP_ENUMPROCW, dwFlags: DWORD, lParam: LONG_PTR, ) -> BOOL; pub fn EnumSystemLocalesA(lpLocaleEnumProc: LOCALE_ENUMPROCA, dwFlags: DWORD) -> BOOL; pub fn EnumSystemLocalesEx( lpLocaleEnumProcEx: LOCALE_ENUMPROCEX, dwFlags: DWORD, lParam: LPARAM, lpReserved: LPVOID, ) -> BOOL; pub fn EnumSystemLocalesW(lpLocaleEnumProc: LOCALE_ENUMPROCW, dwFlags: DWORD) -> BOOL; pub fn EnumTimeFormatsA( lpTimeFmtEnumProc: TIMEFMT_ENUMPROCA, Locale: LCID, dwFlags: DWORD, ) -> BOOL; pub fn EnumTimeFormatsEx( lpTimeFmtEnumProcEx: TIMEFMT_ENUMPROCEX, lpLocaleName: LPCWSTR, dwFlags: DWORD, lParam: LPARAM, ) -> BOOL; pub fn EnumTimeFormatsW( lpTimeFmtEnumProc: TIMEFMT_ENUMPROCW, Locale: LCID, dwFlags: DWORD, ) -> BOOL; pub fn EnumUILanguagesA( lpUILanguageEnumProc: UILANGUAGE_ENUMPROCA, dwFlags: DWORD, lParam: LONG_PTR, ) -> BOOL; pub fn EnumUILanguagesW( lpUILanguageEnumProc: UILANGUAGE_ENUMPROCW, dwFlags: DWORD, lParam: LONG_PTR, ) -> BOOL; // pub fn EnumerateLocalComputerNamesA(); // pub fn EnumerateLocalComputerNamesW(); pub fn EraseTape(hDevice: HANDLE, dwEraseType: DWORD, bImmediate: BOOL) -> DWORD; pub fn EscapeCommFunction(hFile: HANDLE, dwFunc: DWORD) -> BOOL; #[cfg(target_arch = "x86_64")] pub fn ExecuteUmsThread(UmsThread: PUMS_CONTEXT) -> BOOL; pub fn ExitProcess(uExitCode: UINT); pub fn ExitThread(dwExitCode: DWORD); pub fn ExpandEnvironmentStringsA(lpSrc: LPCSTR, lpDst: LPSTR, nSize: DWORD) -> DWORD; pub fn ExpandEnvironmentStringsW(lpSrc: LPCWSTR, lpDst: LPWSTR, nSize: DWORD) -> DWORD; pub fn FatalAppExitA(uAction: UINT, lpMessageText: LPCSTR); pub fn FatalAppExitW(uAction: UINT, lpMessageText: LPCWSTR); pub fn FatalExit(ExitCode: c_int); pub fn FileTimeToDosDateTime( lpFileTime: *const FILETIME, lpFatDate: LPWORD, lpFatTime: LPWORD, ) -> BOOL; pub fn FileTimeToLocalFileTime( lpFileTime: *const FILETIME, lpLocalFileTime: LPFILETIME, ) -> BOOL; pub fn FileTimeToSystemTime( lpFileTime: *const FILETIME, lpSystemTime: LPSYSTEMTIME, ) -> BOOL; pub fn FillConsoleOutputAttribute( hConsoleOutput: HANDLE, wAttribute: WORD, nLength: DWORD, dwWriteCoord: COORD, lpNumberOfAttrsWritten: LPDWORD, ) -> BOOL; pub fn FillConsoleOutputCharacterA( hConsoleOutput: HANDLE, cCharacter: CHAR, nLength: DWORD, dwWriteCoord: COORD, lpNumberOfCharsWritten: LPDWORD, ) -> BOOL; pub fn FillConsoleOutputCharacterW( hConsoleOutput: HANDLE, cCharacter: WCHAR, nLength: DWORD, dwWriteCoord: COORD, lpNumberOfCharsWritten: LPDWORD, ) -> BOOL; pub fn FindActCtxSectionGuid( dwFlags: DWORD, lpExtensionGuid: *const GUID, ulSectionId: ULONG, lpGuidToFind: *const GUID, ReturnedData: PACTCTX_SECTION_KEYED_DATA, ) -> BOOL; pub fn FindActCtxSectionStringA( dwFlags: DWORD, lpExtensionGuid: *const GUID, ulSectionId: ULONG, lpStringToFind: LPCSTR, ReturnedData: PACTCTX_SECTION_KEYED_DATA, ) -> BOOL; pub fn FindActCtxSectionStringW( dwFlags: DWORD, lpExtensionGuid: *const GUID, ulSectionId: ULONG, lpStringToFind: LPCWSTR, ReturnedData: PACTCTX_SECTION_KEYED_DATA, ) -> BOOL; pub fn FindAtomA(lpString: LPCSTR) -> ATOM; pub fn FindAtomW(lpString: LPCWSTR) -> ATOM; pub fn FindClose(hFindFile: HANDLE) -> BOOL; pub fn FindCloseChangeNotification(hChangeHandle: HANDLE) -> BOOL; pub fn FindFirstChangeNotificationA( lpPathName: LPCSTR, bWatchSubtree: BOOL, dwNotifyFilter: DWORD, ) -> HANDLE; pub fn FindFirstChangeNotificationW( lpPathName: LPCWSTR, bWatchSubtree: BOOL, dwNotifyFilter: DWORD, ) -> HANDLE; pub fn FindFirstFileA(lpFileName: LPCSTR, lpFindFileData: LPWIN32_FIND_DATAA) -> HANDLE; pub fn FindFirstFileExA( lpFileName: LPCSTR, fInfoLevelId: FINDEX_INFO_LEVELS, lpFindFileData: LPVOID, fSearchOp: FINDEX_SEARCH_OPS, lpSearchFilter: LPVOID, dwAdditionalFlags: DWORD, ) -> HANDLE; pub fn FindFirstFileExW( lpFileName: LPCWSTR, fInfoLevelId: FINDEX_INFO_LEVELS, lpFindFileData: LPVOID, fSearchOp: FINDEX_SEARCH_OPS, lpSearchFilter: LPVOID, dwAdditionalFlags: DWORD, ) -> HANDLE; pub fn FindFirstFileNameTransactedW( lpFileName: LPCWSTR, dwFlags: DWORD, StringLength: LPDWORD, LinkName: PWSTR, hTransaction: HANDLE, ) -> HANDLE; pub fn FindFirstFileNameW( lpFileName: LPCWSTR, dwFlags: DWORD, StringLength: LPDWORD, LinkName: PWSTR, ) -> HANDLE; pub fn FindFirstFileTransactedA( lpFileName: LPCSTR, fInfoLevelId: FINDEX_INFO_LEVELS, lpFindFileData: LPVOID, fSearchOp: FINDEX_SEARCH_OPS, lpSearchFilter: LPVOID, dwAdditionalFlags: DWORD, hTransaction: HANDLE, ) -> HANDLE; pub fn FindFirstFileTransactedW( lpFileName: LPCWSTR, fInfoLevelId: FINDEX_INFO_LEVELS, lpFindFileData: LPVOID, fSearchOp: FINDEX_SEARCH_OPS, lpSearchFilter: LPVOID, dwAdditionalFlags: DWORD, hTransaction: HANDLE, ) -> HANDLE; pub fn FindFirstFileW(lpFileName: LPCWSTR, lpFindFileData: LPWIN32_FIND_DATAW) -> HANDLE; pub fn FindFirstStreamTransactedW( lpFileName: LPCWSTR, InfoLevel: STREAM_INFO_LEVELS, lpFindStreamData: LPVOID, dwFlags: DWORD, hTransaction: HANDLE, ) -> HANDLE; pub fn FindFirstStreamW( lpFileName: LPCWSTR, InfoLevel: STREAM_INFO_LEVELS, lpFindStreamData: LPVOID, dwFlags: DWORD, ) -> HANDLE; pub fn FindFirstVolumeA(lpszVolumeName: LPSTR, cchBufferLength: DWORD) -> HANDLE; pub fn FindFirstVolumeMountPointA( lpszRootPathName: LPCSTR, lpszVolumeMountPoint: LPSTR, cchBufferLength: DWORD, ) -> HANDLE; pub fn FindFirstVolumeMountPointW( lpszRootPathName: LPCWSTR, lpszVolumeMountPoint: LPWSTR, cchBufferLength: DWORD, ) -> HANDLE; pub fn FindFirstVolumeW(lpszVolumeName: LPWSTR, cchBufferLength: DWORD) -> HANDLE; pub fn FindNLSString( Locale: LCID, dwFindNLSStringFlags: DWORD, lpStringSource: LPCWSTR, cchSource: c_int, lpStringValue: LPCWSTR, cchValue: c_int, pcchFound: LPINT, ) -> c_int; pub fn FindNLSStringEx( lpLocaleName: LPCWSTR, dwFindNLSStringFlags: DWORD, lpStringSource: LPCWSTR, cchSource: c_int, lpStringValue: LPCWSTR, cchValue: c_int, pcchFound: LPINT, lpVersionInformation: LPNLSVERSIONINFO, lpReserved: LPVOID, sortHandle: LPARAM, ) -> c_int; pub fn FindNextChangeNotification(hChangeHandle: HANDLE) -> BOOL; pub fn FindNextFileA(hFindFile: HANDLE, lpFindFileData: LPWIN32_FIND_DATAA) -> BOOL; pub fn FindNextFileNameW(hFindStream: HANDLE, StringLength: LPDWORD, LinkName: PWSTR) -> BOOL; pub fn FindNextFileW(hFindFile: HANDLE, lpFindFileData: LPWIN32_FIND_DATAW) -> BOOL; pub fn FindNextStreamW(hFindStream: HANDLE, lpFindStreamData: LPVOID) -> BOOL; pub fn FindNextVolumeA( hFindVolume: HANDLE, lpszVolumeName: LPSTR, cchBufferLength: DWORD, ) -> BOOL; pub fn FindNextVolumeMountPointA( hFindVolumeMountPoint: HANDLE, lpszVolumeMountPoint: LPSTR, cchBufferLength: DWORD, ) -> BOOL; pub fn FindNextVolumeMountPointW( hFindVolumeMountPoint: HANDLE, lpszVolumeMountPoint: LPWSTR, cchBufferLength: DWORD, ) -> BOOL; pub fn FindNextVolumeW( hFindVolume: HANDLE, lpszVolumeName: LPWSTR, cchBufferLength: DWORD, ) -> BOOL; // pub fn FindPackagesByPackageFamily(); pub fn FindResourceA(hModule: HMODULE, lpName: LPCSTR, lpType: LPCSTR) -> HRSRC; pub fn FindResourceExA( hModule: HMODULE, lpName: LPCSTR, lpType: LPCSTR, wLanguage: WORD, ) -> HRSRC; pub fn FindResourceExW( hModule: HMODULE, lpName: LPCWSTR, lpType: LPCWSTR, wLanguage: WORD, ) -> HRSRC; pub fn FindResourceW(hModule: HMODULE, lpName: LPCWSTR, lpType: LPCWSTR) -> HRSRC; pub fn FindStringOrdinal( dwFindStringOrdinalFlags: DWORD, lpStringSource: LPCWSTR, cchSource: c_int, lpStringValue: LPCWSTR, cchValue: c_int, bIgnoreCase: BOOL, ) -> c_int; pub fn FindVolumeClose(hFindVolume: HANDLE) -> BOOL; pub fn FindVolumeMountPointClose(hFindVolumeMountPoint: HANDLE) -> BOOL; pub fn FlsAlloc(lpCallback: PFLS_CALLBACK_FUNCTION) -> DWORD; pub fn FlsFree(dwFlsIndex: DWORD) -> BOOL; pub fn FlsGetValue(dwFlsIndex: DWORD) -> PVOID; pub fn FlsSetValue(dwFlsIndex: DWORD, lpFlsData: PVOID) -> BOOL; pub fn FlushConsoleInputBuffer(hConsoleInput: HANDLE) -> BOOL; pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL; pub fn FlushInstructionCache(hProcess: HANDLE, lpBaseAddress: LPCVOID, dwSize: SIZE_T) -> BOOL; pub fn FlushProcessWriteBuffers(); pub fn FlushViewOfFile(lpBaseAddress: LPCVOID, dwNumberOfBytesToFlush: SIZE_T) -> BOOL; pub fn FoldStringA( dwMapFlags: DWORD, lpSrcStr: LPCSTR, cchSrc: c_int, lpDestStr: LPSTR, cchDest: c_int, ) -> c_int; pub fn FoldStringW( dwMapFlags: DWORD, lpSrcStr: LPCWCH, cchSrc: c_int, lpDestStr: LPWSTR, cchDest: c_int, ) -> c_int; // pub fn FormatApplicationUserModelId(); pub fn FormatMessageA( dwFlags: DWORD, lpSource: LPCVOID, dwMessageId: DWORD, dwLanguageId: DWORD, lpBuffer: LPSTR, nSize: DWORD, Arguments: *mut va_list, ) -> DWORD; pub fn FormatMessageW( dwFlags: DWORD, lpSource: LPCVOID, dwMessageId: DWORD, dwLanguageId: DWORD, lpBuffer: LPWSTR, nSize: DWORD, Arguments: *mut va_list, ) -> DWORD; pub fn FreeConsole() -> BOOL; pub fn FreeEnvironmentStringsA(penv: LPCH) -> BOOL; pub fn FreeEnvironmentStringsW(penv: LPWCH) -> BOOL; pub fn FreeLibrary(hLibModule: HMODULE) -> BOOL; pub fn FreeLibraryAndExitThread(hLibModule: HMODULE, dwExitCode: DWORD); pub fn FreeLibraryWhenCallbackReturns(pci: PTP_CALLBACK_INSTANCE, module: HMODULE); pub fn FreeResource(hResData: HGLOBAL) -> BOOL; pub fn FreeUserPhysicalPages( hProcess: HANDLE, NumberOfPages: PULONG_PTR, PageArray: PULONG_PTR, ) -> BOOL; pub fn GenerateConsoleCtrlEvent(dwCtrlEvent: DWORD, dwProcessGroupId: DWORD) -> BOOL; pub fn GetACP() -> UINT; pub fn GetActiveProcessorCount(GroupNumber: WORD) -> DWORD; pub fn GetActiveProcessorGroupCount() -> WORD; pub fn GetAppContainerAce( Acl: PACL, StartingAceIndex: DWORD, AppContainerAce: *mut PVOID, AppContainerAceIndex: *mut DWORD, ) -> BOOL; pub fn GetAppContainerNamedObjectPath( Token: HANDLE, AppContainerSid: PSID, ObjectPathLength: ULONG, ObjectPath: LPWSTR, ReturnLength: PULONG, ) -> BOOL; pub fn GetApplicationRecoveryCallback( hProcess: HANDLE, pRecoveryCallback: *mut APPLICATION_RECOVERY_CALLBACK, ppvParameter: *mut PVOID, pdwPingInterval: PDWORD, pdwFlags: PDWORD, ) -> HRESULT; pub fn GetApplicationRestartSettings( hProcess: HANDLE, pwzCommandline: PWSTR, pcchSize: PDWORD, pdwFlags: PDWORD, ) -> HRESULT; // pub fn GetApplicationUserModelId(); pub fn GetAtomNameA(nAtom: ATOM, lpBuffer: LPSTR, nSize: c_int) -> UINT; pub fn GetAtomNameW(nAtom: ATOM, lpBuffer: LPWSTR, nSize: c_int) -> UINT; pub fn GetBinaryTypeA(lpApplicationName: LPCSTR, lpBinaryType: LPDWORD) -> BOOL; pub fn GetBinaryTypeW(lpApplicationName: LPCWSTR, lpBinaryType: LPDWORD) -> BOOL; pub fn GetCPInfo(CodePage: UINT, lpCPInfo: LPCPINFO) -> BOOL; pub fn GetCPInfoExA(CodePage: UINT, dwFlags: DWORD, lpCPInfoEx: LPCPINFOEXA) -> BOOL; pub fn GetCPInfoExW(CodePage: UINT, dwFlags: DWORD, lpCPInfoEx: LPCPINFOEXW) -> BOOL; pub fn GetCachedSigningLevel( File: HANDLE, Flags: PULONG, SigningLevel: PULONG, Thumbprint: PUCHAR, ThumbprintSize: PULONG, ThumbprintAlgorithm: PULONG, ) -> BOOL; pub fn GetCalendarInfoA( Locale: LCID, Calendar: CALID, CalType: CALTYPE, lpCalData: LPSTR, cchData: c_int, lpValue: LPDWORD, ) -> c_int; pub fn GetCalendarInfoEx( lpLocaleName: LPCWSTR, Calendar: CALID, lpReserved: LPCWSTR, CalType: CALTYPE, lpCalData: LPWSTR, cchData: c_int, lpValue: LPDWORD, ) -> c_int; pub fn GetCalendarInfoW( Locale: LCID, Calendar: CALID, CalType: CALTYPE, lpCalData: LPWSTR, cchData: c_int, lpValue: LPDWORD, ) -> c_int; pub fn GetCommConfig(hCommDev: HANDLE, lpCC: LPCOMMCONFIG, lpdwSize: LPDWORD) -> BOOL; pub fn GetCommMask(hFile: HANDLE, lpEvtMask: LPDWORD) -> BOOL; pub fn GetCommModemStatus(hFile: HANDLE, lpModemStat: LPDWORD) -> BOOL; pub fn GetCommProperties(hFile: HANDLE, lpCommProp: LPCOMMPROP) -> BOOL; pub fn GetCommState(hFile: HANDLE, lpDCB: LPDCB) -> BOOL; pub fn GetCommTimeouts(hFile: HANDLE, lpCommTimeouts: LPCOMMTIMEOUTS) -> BOOL; pub fn GetCommandLineA() -> LPSTR; pub fn GetCommandLineW() -> LPWSTR; pub fn GetCompressedFileSizeA(lpFileName: LPCSTR, lpFileSizeHigh: LPDWORD) -> DWORD; pub fn GetCompressedFileSizeTransactedA( lpFileName: LPCSTR, lpFileSizeHigh: LPDWORD, hTransaction: HANDLE, ) -> DWORD; pub fn GetCompressedFileSizeTransactedW( lpFileName: LPCWSTR, lpFileSizeHigh: LPDWORD, hTransaction: HANDLE, ); pub fn GetCompressedFileSizeW(lpFileName: LPCWSTR, lpFileSizeHigh: LPDWORD) -> DWORD; pub fn GetComputerNameA(lpBuffer: LPSTR, nSize: LPDWORD) -> BOOL; pub fn GetComputerNameExA( NameType: COMPUTER_NAME_FORMAT, lpBuffer: LPSTR, nSize: LPDWORD, ) -> BOOL; pub fn GetComputerNameExW( NameType: COMPUTER_NAME_FORMAT, lpBuffer: LPWSTR, nSize: LPDWORD, ) -> BOOL; pub fn GetComputerNameW(lpBuffer: LPWSTR, nSize: LPDWORD) -> BOOL; pub fn GetConsoleAliasA( Source: LPSTR, TargetBuffer: LPSTR, TargetBufferLength: DWORD, ExeName: LPSTR, ) -> DWORD; pub fn GetConsoleAliasExesA(ExeNameBuffer: LPSTR, ExeNameBufferLength: DWORD) -> DWORD; pub fn GetConsoleAliasExesLengthA() -> DWORD; pub fn GetConsoleAliasExesLengthW() -> DWORD; pub fn GetConsoleAliasExesW(ExeNameBuffer: LPWSTR, ExeNameBufferLength: DWORD) -> DWORD; pub fn GetConsoleAliasW( Source: LPWSTR, TargetBuffer: LPWSTR, TargetBufferLength: DWORD, ExeName: LPWSTR, ) -> DWORD; pub fn GetConsoleAliasesA( AliasBuffer: LPSTR, AliasBufferLength: DWORD, ExeName: LPSTR, ) -> DWORD; pub fn GetConsoleAliasesLengthA(ExeName: LPSTR) -> DWORD; pub fn GetConsoleAliasesLengthW(ExeName: LPWSTR) -> DWORD; pub fn GetConsoleAliasesW( AliasBuffer: LPWSTR, AliasBufferLength: DWORD, ExeName: LPWSTR, ) -> DWORD; pub fn GetConsoleCP() -> UINT; pub fn GetConsoleCursorInfo( hConsoleOutput: HANDLE, lpConsoleCursorInfo: PCONSOLE_CURSOR_INFO, ) -> BOOL; pub fn GetConsoleDisplayMode(lpModeFlags: LPDWORD) -> BOOL; pub fn GetConsoleFontSize(hConsoleOutput: HANDLE, nFont: DWORD) -> COORD; pub fn GetConsoleHistoryInfo(lpConsoleHistoryInfo: PCONSOLE_HISTORY_INFO) -> BOOL; pub fn GetConsoleMode(hConsoleHandle: HANDLE, lpMode: LPDWORD) -> BOOL; pub fn GetConsoleOriginalTitleA(lpConsoleTitle: LPSTR, nSize: DWORD) -> DWORD; pub fn GetConsoleOriginalTitleW(lpConsoleTitle: LPWSTR, nSize: DWORD) -> DWORD; pub fn GetConsoleOutputCP() -> UINT; pub fn GetConsoleProcessList(lpdwProcessList: LPDWORD, dwProcessCount: DWORD) -> DWORD; pub fn GetConsoleScreenBufferInfo( hConsoleOutput: HANDLE, lpConsoleScreenBufferInfo: PCONSOLE_SCREEN_BUFFER_INFO, ) -> BOOL; pub fn GetConsoleScreenBufferInfoEx( hConsoleOutput: HANDLE, lpConsoleScreenBufferInfoEx: PCONSOLE_SCREEN_BUFFER_INFOEX, ) -> BOOL; pub fn GetConsoleSelectionInfo(lpConsoleSelectionInfo: PCONSOLE_SELECTION_INFO) -> BOOL; pub fn GetConsoleTitleA(lpConsoleTitle: LPSTR, nSize: DWORD) -> DWORD; pub fn GetConsoleTitleW(lpConsoleTitle: LPWSTR, nSize: DWORD) -> DWORD; pub fn GetConsoleWindow() -> HWND; pub fn GetCurrencyFormatA( Locale: LCID, dwFlags: DWORD, lpValue: LPCSTR, lpFormat: *const CURRENCYFMTA, lpCurrencyStr: LPSTR, cchCurrency: c_int, ) -> c_int; pub fn GetCurrencyFormatEx( lpLocaleName: LPCWSTR, dwFlags: DWORD, lpValue: LPCWSTR, lpFormat: *const CURRENCYFMTW, lpCurrencyStr: LPWSTR, cchCurrency: c_int, ) -> c_int; pub fn GetCurrencyFormatW( Locale: LCID, dwFlags: DWORD, lpValue: LPCWSTR, lpFormat: *const CURRENCYFMTW, lpCurrencyStr: LPWSTR, cchCurrency: c_int, ) -> c_int; pub fn GetCurrentActCtx(lphActCtx: *mut HANDLE) -> BOOL; // pub fn GetCurrentApplicationUserModelId(); pub fn GetCurrentConsoleFont( hConsoleOutput: HANDLE, bMaximumWindow: BOOL, lpConsoleCurrentFont: PCONSOLE_FONT_INFO, ) -> BOOL; pub fn GetCurrentConsoleFontEx( hConsoleOutput: HANDLE, bMaximumWindow: BOOL, lpConsoleCurrentFontEx: PCONSOLE_FONT_INFOEX, ) -> BOOL; pub fn GetCurrentDirectoryA(nBufferLength: DWORD, lpBuffer: LPSTR) -> DWORD; pub fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: LPWSTR) -> DWORD; // pub fn GetCurrentPackageFamilyName(); // pub fn GetCurrentPackageFullName(); // pub fn GetCurrentPackageId(); // pub fn GetCurrentPackageInfo(); // pub fn GetCurrentPackagePath(); pub fn GetCurrentProcess() -> HANDLE; pub fn GetCurrentProcessId() -> DWORD; pub fn GetCurrentProcessorNumber() -> DWORD; pub fn GetCurrentProcessorNumberEx(ProcNumber: PPROCESSOR_NUMBER); pub fn GetCurrentThread() -> HANDLE; pub fn GetCurrentThreadId() -> DWORD; pub fn GetCurrentThreadStackLimits(LowLimit: PULONG_PTR, HighLimit: PULONG_PTR); #[cfg(target_arch = "x86_64")] pub fn GetCurrentUmsThread() -> PUMS_CONTEXT; pub fn GetDateFormatA( Locale: LCID, dwFlags: DWORD, lpDate: *const SYSTEMTIME, lpFormat: LPCSTR, lpDateStr: LPSTR, cchDate: c_int, ) -> c_int; pub fn GetDateFormatEx( lpLocaleName: LPCWSTR, dwFlags: DWORD, lpDate: *const SYSTEMTIME, lpFormat: LPCWSTR, lpDateStr: LPWSTR, cchDate: c_int, lpCalendar: LPCWSTR, ) -> c_int; pub fn GetDateFormatW( Locale: LCID, dwFlags: DWORD, lpDate: *const SYSTEMTIME, lpFormat: LPCWSTR, lpDateStr: LPWSTR, cchDate: c_int, ) -> c_int; pub fn GetDefaultCommConfigA(lpszName: LPCSTR, lpCC: LPCOMMCONFIG, lpdwSize: LPDWORD) -> BOOL; pub fn GetDefaultCommConfigW(lpszName: LPCWSTR, lpCC: LPCOMMCONFIG, lpdwSize: LPDWORD) -> BOOL; pub fn GetDevicePowerState(hDevice: HANDLE, pfOn: *mut BOOL) -> BOOL; pub fn GetDiskFreeSpaceA( lpRootPathName: LPCSTR, lpSectorsPerCluster: LPDWORD, lpBytesPerSector: LPDWORD, lpNumberOfFreeClusters: LPDWORD, lpTotalNumberOfClusters: LPDWORD, ) -> BOOL; pub fn GetDiskFreeSpaceExA( lpDirectoryName: LPCSTR, lpFreeBytesAvailableToCaller: PULARGE_INTEGER, lpTotalNumberOfBytes: PULARGE_INTEGER, lpTotalNumberOfFreeBytes: PULARGE_INTEGER, ) -> BOOL; pub fn GetDiskFreeSpaceExW( lpDirectoryName: LPCWSTR, lpFreeBytesAvailableToCaller: PULARGE_INTEGER, lpTotalNumberOfBytes: PULARGE_INTEGER, lpTotalNumberOfFreeBytes: PULARGE_INTEGER, ) -> BOOL; pub fn GetDiskFreeSpaceW( lpRootPathName: LPCWSTR, lpSectorsPerCluster: LPDWORD, lpBytesPerSector: LPDWORD, lpNumberOfFreeClusters: LPDWORD, lpTotalNumberOfClusters: LPDWORD, ) -> BOOL; pub fn GetDllDirectoryA(nBufferLength: DWORD, lpBuffer: LPSTR) -> DWORD; pub fn GetDllDirectoryW(nBufferLength: DWORD, lpBuffer: LPWSTR) -> DWORD; pub fn GetDriveTypeA(lpRootPathName: LPCSTR) -> UINT; pub fn GetDriveTypeW(lpRootPathName: LPCWSTR) -> UINT; pub fn GetDurationFormat( Locale: LCID, dwFlags: DWORD, lpDuration: *const SYSTEMTIME, ullDuration: ULONGLONG, lpFormat: LPCWSTR, lpDurationStr: LPWSTR, cchDuration: c_int, ) -> c_int; pub fn GetDurationFormatEx( lpLocaleName: LPCWSTR, dwFlags: DWORD, lpDuration: *const SYSTEMTIME, ullDuration: ULONGLONG, lpFormat: LPCWSTR, lpDurationStr: LPWSTR, cchDuration: c_int, ) -> c_int; pub fn GetDynamicTimeZoneInformation( pTimeZoneInformation: PDYNAMIC_TIME_ZONE_INFORMATION, ) -> DWORD; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub fn GetEnabledXStateFeatures() -> DWORD64; pub fn GetEnvironmentStrings() -> LPCH; pub fn GetEnvironmentStringsW() -> LPWCH; pub fn GetEnvironmentVariableA(lpName: LPCSTR, lpBuffer: LPSTR, nSize: DWORD) -> DWORD; pub fn GetEnvironmentVariableW(lpName: LPCWSTR, lpBuffer: LPWSTR, nSize: DWORD) -> DWORD; // pub fn GetEraNameCountedString(); pub fn GetErrorMode() -> UINT; pub fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: LPDWORD) -> BOOL; pub fn GetExitCodeThread(hThread: HANDLE, lpExitCode: LPDWORD) -> BOOL; pub fn GetFileAttributesA(lpFileName: LPCSTR) -> DWORD; pub fn GetFileAttributesExA( lpFileName: LPCSTR, fInfoLevelId: GET_FILEEX_INFO_LEVELS, lpFileInformation: LPVOID, ) -> BOOL; pub fn GetFileAttributesExW( lpFileName: LPCWSTR, fInfoLevelId: GET_FILEEX_INFO_LEVELS, lpFileInformation: LPVOID, ) -> BOOL; pub fn GetFileAttributesTransactedA( lpFileName: LPCSTR, fInfoLevelId: GET_FILEEX_INFO_LEVELS, lpFileInformation: LPVOID, hTransaction: HANDLE, ) -> BOOL; pub fn GetFileAttributesTransactedW( lpFileName: LPCWSTR, fInfoLevelId: GET_FILEEX_INFO_LEVELS, lpFileInformation: LPVOID, hTransaction: HANDLE, ) -> BOOL; pub fn GetFileAttributesW(lpFileName: LPCWSTR) -> DWORD; pub fn GetFileBandwidthReservation( hFile: HANDLE, lpPeriodMilliseconds: LPDWORD, lpBytesPerPeriod: LPDWORD, pDiscardable: LPBOOL, lpTransferSize: LPDWORD, lpNumOutstandingRequests: LPDWORD, ) -> BOOL; pub fn GetFileInformationByHandle( hFile: HANDLE, lpFileInformation: LPBY_HANDLE_FILE_INFORMATION, ) -> BOOL; pub fn GetFileInformationByHandleEx( hFile: HANDLE, FileInformationClass: FILE_INFO_BY_HANDLE_CLASS, lpFileInformation: LPVOID, dwBufferSize: DWORD, ) -> BOOL; pub fn GetFileMUIInfo( dwFlags: DWORD, pcwszFilePath: PCWSTR, pFileMUIInfo: PFILEMUIINFO, pcbFileMUIInfo: *mut DWORD, ) -> BOOL; pub fn GetFileMUIPath( dwFlags: DWORD, pcwszFilePath: PCWSTR, pwszLanguage: PWSTR, pcchLanguage: PULONG, pwszFileMUIPath: PWSTR, pcchFileMUIPath: PULONG, pululEnumerator: PULONGLONG, ) -> BOOL; pub fn GetFileSize(hFile: HANDLE, lpFileSizeHigh: LPDWORD) -> DWORD; pub fn GetFileSizeEx(hFile: HANDLE, lpFileSize: PLARGE_INTEGER) -> BOOL; pub fn GetFileTime( hFile: HANDLE, lpCreationTime: LPFILETIME, lpLastAccessTime: LPFILETIME, lpLastWriteTime: LPFILETIME, ) -> BOOL; pub fn GetFileType(hFile: HANDLE) -> DWORD; pub fn GetFinalPathNameByHandleA( hFile: HANDLE, lpszFilePath: LPSTR, cchFilePath: DWORD, dwFlags: DWORD, ) -> DWORD; pub fn GetFinalPathNameByHandleW( hFile: HANDLE, lpszFilePath: LPWSTR, cchFilePath: DWORD, dwFlags: DWORD, ) -> DWORD; pub fn GetFirmwareEnvironmentVariableA( lpName: LPCSTR, lpGuid: LPCSTR, pBuffer: PVOID, nSize: DWORD, ) -> DWORD; pub fn GetFirmwareEnvironmentVariableExA( lpName: LPCSTR, lpGuid: LPCSTR, pBuffer: PVOID, nSize: DWORD, pdwAttribubutes: PDWORD, ) -> DWORD; pub fn GetFirmwareEnvironmentVariableExW( lpName: LPCWSTR, lpGuid: LPCWSTR, pBuffer: PVOID, nSize: DWORD, pdwAttribubutes: PDWORD, ) -> DWORD; pub fn GetFirmwareEnvironmentVariableW( lpName: LPCWSTR, lpGuid: LPCWSTR, pBuffer: PVOID, nSize: DWORD, ) -> DWORD; pub fn GetFirmwareType(FirmwareType: PFIRMWARE_TYPE) -> BOOL; pub fn GetFullPathNameA( lpFileName: LPCSTR, nBufferLength: DWORD, lpBuffer: LPSTR, lpFilePart: *mut LPSTR, ) -> DWORD; pub fn GetFullPathNameTransactedA( lpFileName: LPCSTR, nBufferLength: DWORD, lpBuffer: LPSTR, lpFilePart: *mut LPSTR, hTransaction: HANDLE, ) -> DWORD; pub fn GetFullPathNameTransactedW( lpFileName: LPCWSTR, nBufferLength: DWORD, lpBuffer: LPWSTR, lpFilePart: *mut LPWSTR, hTransaction: HANDLE, ); pub fn GetFullPathNameW( lpFileName: LPCWSTR, nBufferLength: DWORD, lpBuffer: LPWSTR, lpFilePart: *mut LPWSTR, ) -> DWORD; pub fn GetGeoInfoA( Location: GEOID, GeoType: GEOTYPE, lpGeoData: LPSTR, cchData: c_int, LangId: LANGID, ) -> c_int; pub fn GetGeoInfoW( Location: GEOID, GeoType: GEOTYPE, lpGeoData: LPWSTR, cchData: c_int, LangId: LANGID, ) -> c_int; pub fn GetHandleInformation(hObject: HANDLE, lpdwFlags: LPDWORD) -> BOOL; pub fn GetLargePageMinimum() -> SIZE_T; pub fn GetLargestConsoleWindowSize(hConsoleOutput: HANDLE) -> COORD; pub fn GetLastError() -> DWORD; pub fn GetLocalTime(lpSystemTime: LPSYSTEMTIME); pub fn GetLocaleInfoA( Locale: LCID, LCType: LCTYPE, lpLCData: LPSTR, cchData: c_int, ) -> c_int; pub fn GetLocaleInfoEx( lpLocaleName: LPCWSTR, LCType: LCTYPE, lpLCData: LPWSTR, cchData: c_int, ) -> c_int; pub fn GetLocaleInfoW( Locale: LCID, LCType: LCTYPE, lpLCData: LPWSTR, cchData: c_int, ) -> c_int; pub fn GetLogicalDriveStringsA(nBufferLength: DWORD, lpBuffer: LPSTR) -> DWORD; pub fn GetLogicalDriveStringsW(nBufferLength: DWORD, lpBuffer: LPWSTR) -> DWORD; pub fn GetLogicalDrives() -> DWORD; pub fn GetLogicalProcessorInformation( Buffer: PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, ReturnedLength: PDWORD, ) -> BOOL; pub fn GetLogicalProcessorInformationEx( RelationshipType: LOGICAL_PROCESSOR_RELATIONSHIP, Buffer: PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, ReturnedLength: PDWORD, ) -> BOOL; pub fn GetLongPathNameA(lpszShortPath: LPCSTR, lpszLongPath: LPSTR, cchBuffer: DWORD) -> DWORD; pub fn GetLongPathNameTransactedA( lpszShortPath: LPCSTR, lpszLongPath: LPSTR, cchBuffer: DWORD, hTransaction: HANDLE, ) -> DWORD; pub fn GetLongPathNameTransactedW( lpszShortPath: LPCWSTR, lpszLongPath: LPWSTR, cchBuffer: DWORD, hTransaction: HANDLE, ) -> DWORD; pub fn GetLongPathNameW( lpszShortPath: LPCWSTR, lpszLongPath: LPWSTR, cchBuffer: DWORD, ) -> DWORD; pub fn GetMailslotInfo( hMailslot: HANDLE, lpMaxMessageSize: LPDWORD, lpNextSize: LPDWORD, lpMessageCount: LPDWORD, lpReadTimeout: LPDWORD, ) -> BOOL; pub fn GetMaximumProcessorCount(GroupNumber: WORD) -> DWORD; pub fn GetMaximumProcessorGroupCount() -> WORD; pub fn GetMemoryErrorHandlingCapabilities(Capabilities: PULONG) -> BOOL; pub fn GetModuleFileNameA( hModule: HMODULE, lpFilename: LPSTR, nSize: DWORD, ) -> DWORD; pub fn GetModuleFileNameW( hModule: HMODULE, lpFilename: LPWSTR, nSize: DWORD, ) -> DWORD; pub fn GetModuleHandleA(lpModuleName: LPCSTR) -> HMODULE; pub fn GetModuleHandleExA( dwFlags: DWORD, lpModuleName: LPCSTR, phModule: *mut HMODULE, ) -> BOOL; pub fn GetModuleHandleExW( dwFlags: DWORD, lpModuleName: LPCWSTR, phModule: *mut HMODULE, ) -> BOOL; pub fn GetModuleHandleW(lpModuleName: LPCWSTR) -> HMODULE; pub fn GetNLSVersion( Function: NLS_FUNCTION, Locale: LCID, lpVersionInformation: LPNLSVERSIONINFO, ) -> BOOL; pub fn GetNLSVersionEx( function: NLS_FUNCTION, lpLocaleName: LPCWSTR, lpVersionInformation: LPNLSVERSIONINFOEX, ) -> BOOL; // pub fn GetNamedPipeAttribute(); pub fn GetNamedPipeClientComputerNameA( Pipe: HANDLE, ClientComputerName: LPSTR, ClientComputerNameLength: ULONG, ) -> BOOL; pub fn GetNamedPipeClientComputerNameW( Pipe: HANDLE, ClientComputerName: LPWSTR, ClientComputerNameLength: ULONG, ) -> BOOL; pub fn GetNamedPipeClientProcessId(Pipe: HANDLE, ClientProcessId: PULONG) -> BOOL; pub fn GetNamedPipeClientSessionId(Pipe: HANDLE, ClientSessionId: PULONG) -> BOOL; pub fn GetNamedPipeHandleStateA( hNamedPipe: HANDLE, lpState: LPDWORD, lpCurInstances: LPDWORD, lpMaxCollectionCount: LPDWORD, lpCollectDataTimeout: LPDWORD, lpUserName: LPSTR, nMaxUserNameSize: DWORD, ) -> BOOL; pub fn GetNamedPipeHandleStateW( hNamedPipe: HANDLE, lpState: LPDWORD, lpCurInstances: LPDWORD, lpMaxCollectionCount: LPDWORD, lpCollectDataTimeout: LPDWORD, lpUserName: LPWSTR, nMaxUserNameSize: DWORD, ) -> BOOL; pub fn GetNamedPipeInfo( hNamedPipe: HANDLE, lpFlags: LPDWORD, lpOutBufferSize: LPDWORD, lpInBufferSize: LPDWORD, lpMaxInstances: LPDWORD, ) -> BOOL; pub fn GetNamedPipeServerProcessId(Pipe: HANDLE, ServerProcessId: PULONG) -> BOOL; pub fn GetNamedPipeServerSessionId(Pipe: HANDLE, ServerSessionId: PULONG) -> BOOL; pub fn GetNativeSystemInfo(lpSystemInfo: LPSYSTEM_INFO); #[cfg(target_arch = "x86_64")] pub fn GetNextUmsListItem(UmsContext: PUMS_CONTEXT) -> PUMS_CONTEXT; pub fn GetNumaAvailableMemoryNode(Node: UCHAR, AvailableBytes: PULONGLONG) -> BOOL; pub fn GetNumaAvailableMemoryNodeEx(Node: USHORT, AvailableBytes: PULONGLONG) -> BOOL; pub fn GetNumaHighestNodeNumber(HighestNodeNumber: PULONG) -> BOOL; pub fn GetNumaNodeNumberFromHandle(hFile: HANDLE, NodeNumber: PUSHORT) -> BOOL; pub fn GetNumaNodeProcessorMask(Node: UCHAR, ProcessorMask: PULONGLONG) -> BOOL; pub fn GetNumaNodeProcessorMaskEx(Node: USHORT, ProcessorMask: PGROUP_AFFINITY) -> BOOL; pub fn GetNumaProcessorNode(Processor: UCHAR, NodeNumber: PUCHAR) -> BOOL; pub fn GetNumaProcessorNodeEx(Processor: PPROCESSOR_NUMBER, NodeNumber: PUSHORT) -> BOOL; pub fn GetNumaProximityNode(ProximityId: ULONG, NodeNumber: PUCHAR) -> BOOL; pub fn GetNumaProximityNodeEx(ProximityId: ULONG, NodeNumber: PUSHORT) -> BOOL; pub fn GetNumberFormatA( Locale: LCID, dwFlags: DWORD, lpValue: LPCSTR, lpFormat: *const NUMBERFMTA, lpNumberStr: LPSTR, cchNumber: c_int, ) -> c_int; pub fn GetNumberFormatEx( lpLocaleName: LPCWSTR, dwFlags: DWORD, lpValue: LPCWSTR, lpFormat: *const NUMBERFMTW, lpNumberStr: LPWSTR, cchNumber: c_int, ) -> c_int; pub fn GetNumberFormatW( Locale: LCID, dwFlags: DWORD, lpValue: LPCWSTR, lpFormat: *const NUMBERFMTW, lpNumberStr: LPWSTR, cchNumber: c_int, ) -> c_int; pub fn GetNumberOfConsoleInputEvents(hConsoleInput: HANDLE, lpNumberOfEvents: LPDWORD) -> BOOL; pub fn GetNumberOfConsoleMouseButtons(lpNumberOfMouseButtons: LPDWORD) -> BOOL; pub fn GetOEMCP() -> UINT; pub fn GetOverlappedResult( hFile: HANDLE, lpOverlapped: LPOVERLAPPED, lpNumberOfBytesTransferred: LPDWORD, bWait: BOOL, ) -> BOOL; pub fn GetOverlappedResultEx( hFile: HANDLE, lpOverlapped: LPOVERLAPPED, lpNumberOfBytesTransferred: LPDWORD, dwMilliseconds: DWORD, bAlertable: BOOL, ) -> BOOL; // pub fn GetPackageApplicationIds(); // pub fn GetPackageFamilyName(); // pub fn GetPackageFullName(); // pub fn GetPackageId(); // pub fn GetPackageInfo(); // pub fn GetPackagePath(); // pub fn GetPackagePathByFullName(); // pub fn GetPackagesByPackageFamily(); pub fn GetPhysicallyInstalledSystemMemory(TotalMemoryInKilobytes: PULONGLONG) -> BOOL; pub fn GetPriorityClass(hProcess: HANDLE) -> DWORD; pub fn GetPrivateProfileIntA( lpAppName: LPCSTR, lpKeyName: LPCSTR, nDefault: INT, lpFileName: LPCSTR, ) -> UINT; pub fn GetPrivateProfileIntW( lpAppName: LPCWSTR, lpKeyName: LPCWSTR, nDefault: INT, lpFileName: LPCWSTR, ) -> UINT; pub fn GetPrivateProfileSectionA( lpAppName: LPCSTR, lpReturnedString: LPSTR, nSize: DWORD, lpFileName: LPCSTR, ) -> DWORD; pub fn GetPrivateProfileSectionNamesA( lpszReturnBuffer: LPSTR, nSize: DWORD, lpFileName: LPCSTR, ) -> DWORD; pub fn GetPrivateProfileSectionNamesW( lpszReturnBuffer: LPWSTR, nSize: DWORD, lpFileName: LPCWSTR, ) -> DWORD; pub fn GetPrivateProfileSectionW( lpAppName: LPCWSTR, lpReturnedString: LPWSTR, nSize: DWORD, lpFileName: LPCWSTR, ) -> DWORD; pub fn GetPrivateProfileStringA( lpAppName: LPCSTR, lpKeyName: LPCSTR, lpDefault: LPCSTR, lpReturnedString: LPSTR, nSize: DWORD, lpFileName: LPCSTR, ) -> DWORD; pub fn GetPrivateProfileStringW( lpAppName: LPCWSTR, lpKeyName: LPCWSTR, lpDefault: LPCWSTR, lpReturnedString: LPWSTR, nSize: DWORD, lpFileName: LPCWSTR, ) -> DWORD; pub fn GetPrivateProfileStructA( lpszSection: LPCSTR, lpszKey: LPCSTR, lpStruct: LPVOID, uSizeStruct: UINT, szFile: LPCSTR, ) -> BOOL; pub fn GetPrivateProfileStructW( lpszSection: LPCWSTR, lpszKey: LPCWSTR, lpStruct: LPVOID, uSizeStruct: UINT, szFile: LPCWSTR, ) -> BOOL; pub fn GetProcAddress(hModule: HMODULE, lpProcName: LPCSTR) -> FARPROC; pub fn GetProcessAffinityMask( hProcess: HANDLE, lpProcessAffinityMask: PDWORD_PTR, lpSystemAffinityMask: PDWORD_PTR, ) -> BOOL; pub fn GetProcessDEPPolicy(hProcess: HANDLE, lpFlags: LPDWORD, lpPermanent: PBOOL) -> BOOL; pub fn GetProcessGroupAffinity( hProcess: HANDLE, GroupCount: PUSHORT, GroupArray: PUSHORT, ) -> BOOL; pub fn GetProcessHandleCount(hProcess: HANDLE, pdwHandleCount: PDWORD) -> BOOL; pub fn GetProcessHeap() -> HANDLE; pub fn GetProcessHeaps(NumberOfHeaps: DWORD, ProcessHeaps: PHANDLE) -> DWORD; pub fn GetProcessId(Process: HANDLE) -> DWORD; pub fn GetProcessIdOfThread(Thread: HANDLE) -> DWORD; pub fn GetProcessInformation( hProcess: HANDLE, ProcessInformationClass: PROCESS_INFORMATION_CLASS, ProcessInformation: LPVOID, ProcessInformationSize: DWORD, ) -> BOOL; pub fn GetProcessIoCounters(hProcess: HANDLE, lpIoCounters: PIO_COUNTERS) -> BOOL; pub fn GetProcessMitigationPolicy( hProcess: HANDLE, MitigationPolicy: PROCESS_MITIGATION_POLICY, lpBuffer: LPVOID, dwLength: SIZE_T, ) -> BOOL; pub fn GetProcessPreferredUILanguages( dwFlags: DWORD, pulNumLanguages: PULONG, pwszLanguagesBuffer: PZZWSTR, pcchLanguagesBuffer: PULONG, ) -> BOOL; pub fn GetProcessPriorityBoost(hProcess: HANDLE, pDisablePriorityBoost: PBOOL) -> BOOL; pub fn GetProcessShutdownParameters(lpdwLevel: LPDWORD, lpdwFlags: LPDWORD) -> BOOL; pub fn GetProcessTimes( hProcess: HANDLE, lpCreationTime: LPFILETIME, lpExitTime: LPFILETIME, lpKernelTime: LPFILETIME, lpUserTime: LPFILETIME, ) -> BOOL; pub fn GetProcessVersion(ProcessId: DWORD) -> DWORD; pub fn GetProcessWorkingSetSize( hProcess: HANDLE, lpMinimumWorkingSetSize: PSIZE_T, lpMaximumWorkingSetSize: PSIZE_T, ) -> BOOL; pub fn GetProcessWorkingSetSizeEx( hProcess: HANDLE, lpMinimumWorkingSetSize: PSIZE_T, lpMaximumWorkingSetSize: PSIZE_T, Flags: PDWORD, ) -> BOOL; pub fn GetProcessorSystemCycleTime( Group: USHORT, Buffer: PSYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION, ReturnedLength: PDWORD, ) -> BOOL; pub fn GetProductInfo( dwOSMajorVersion: DWORD, dwOSMinorVersion: DWORD, dwSpMajorVersion: DWORD, dwSpMinorVersion: DWORD, pdwReturnedProductType: PDWORD, ) -> BOOL; pub fn GetProfileIntA(lpAppName: LPCSTR, lpKeyName: LPCSTR, nDefault: INT) -> UINT; pub fn GetProfileIntW(lpAppName: LPCWSTR, lpKeyName: LPCWSTR, nDefault: INT) -> UINT; pub fn GetProfileSectionA(lpAppName: LPCSTR, lpReturnedString: LPSTR, nSize: DWORD) -> DWORD; pub fn GetProfileSectionW(lpAppName: LPCWSTR, lpReturnedString: LPWSTR, nSize: DWORD) -> DWORD; pub fn GetProfileStringA( lpAppName: LPCSTR, lpKeyName: LPCSTR, lpDefault: LPCSTR, lpReturnedString: LPSTR, nSize: DWORD, ) -> DWORD; pub fn GetProfileStringW( lpAppName: LPCWSTR, lpKeyName: LPCWSTR, lpDefault: LPCWSTR, lpReturnedString: LPWSTR, nSize: DWORD, ) -> DWORD; pub fn GetQueuedCompletionStatus( CompletionPort: HANDLE, lpNumberOfBytesTransferred: LPDWORD, lpCompletionKey: PULONG_PTR, lpOverlapped: *mut LPOVERLAPPED, dwMilliseconds: DWORD, ) -> BOOL; pub fn GetQueuedCompletionStatusEx( CompletionPort: HANDLE, lpCompletionPortEntries: LPOVERLAPPED_ENTRY, ulCount: ULONG, ulNumEntriesRemoved: PULONG, dwMilliseconds: DWORD, fAlertable: BOOL, ) -> BOOL; pub fn GetShortPathNameA( lpszLongPath: LPCSTR, lpszShortPath: LPSTR, cchBuffer: DWORD, ) -> DWORD; pub fn GetShortPathNameW( lpszLongPath: LPCWSTR, lpszShortPath: LPWSTR, cchBuffer: DWORD, ) -> DWORD; // pub fn GetStagedPackagePathByFullName(); pub fn GetStartupInfoA(lpStartupInfo: LPSTARTUPINFOA); pub fn GetStartupInfoW(lpStartupInfo: LPSTARTUPINFOW); // pub fn GetStateFolder(); pub fn GetStdHandle(nStdHandle: DWORD) -> HANDLE; pub fn GetStringScripts( dwFlags: DWORD, lpString: LPCWSTR, cchString: c_int, lpScripts: LPWSTR, cchScripts: c_int, ) -> c_int; pub fn GetStringTypeA( Locale: LCID, dwInfoType: DWORD, lpSrcStr: LPCSTR, cchSrc: c_int, lpCharType: LPWORD, ) -> BOOL; pub fn GetStringTypeExA( Locale: LCID, dwInfoType: DWORD, lpSrcStr: LPCSTR, cchSrc: c_int, lpCharType: LPWORD, ) -> BOOL; pub fn GetStringTypeExW( Locale: LCID, dwInfoType: DWORD, lpSrcStr: LPCWCH, cchSrc: c_int, lpCharType: LPWORD, ) -> BOOL; pub fn GetStringTypeW( dwInfoType: DWORD, lpSrcStr: LPCWCH, cchSrc: c_int, lpCharType: LPWORD, ) -> BOOL; // pub fn GetSystemAppDataKey(); pub fn GetSystemDEPPolicy() -> DEP_SYSTEM_POLICY_TYPE; pub fn GetSystemDefaultLCID() -> LCID; pub fn GetSystemDefaultLangID() -> LANGID; pub fn GetSystemDefaultLocaleName(lpLocaleName: LPWSTR, cchLocaleName: c_int) -> c_int; pub fn GetSystemDefaultUILanguage() -> LANGID; pub fn GetSystemDirectoryA(lpBuffer: LPSTR, uSize: UINT) -> UINT; pub fn GetSystemDirectoryW(lpBuffer: LPWSTR, uSize: UINT) -> UINT; pub fn GetSystemFileCacheSize( lpMinimumFileCacheSize: PSIZE_T, lpMaximumFileCacheSize: PSIZE_T, lpFlags: PDWORD, ) -> BOOL; pub fn GetSystemFirmwareTable( FirmwareTableProviderSignature: DWORD, FirmwareTableID: DWORD, pFirmwareTableBuffer: PVOID, BufferSize: DWORD, ) -> UINT; pub fn GetSystemInfo(lpSystemInfo: LPSYSTEM_INFO); pub fn GetSystemPowerStatus(lpSystemPowerStatus: LPSYSTEM_POWER_STATUS) -> BOOL; pub fn GetSystemPreferredUILanguages( dwFlags: DWORD, pulNumLanguages: PULONG, pwszLanguagesBuffer: PZZWSTR, pcchLanguagesBuffer: PULONG, ) -> BOOL; pub fn GetSystemRegistryQuota(pdwQuotaAllowed: PDWORD, pdwQuotaUsed: PDWORD) -> BOOL; pub fn GetSystemTime(lpSystemTime: LPSYSTEMTIME); pub fn GetSystemTimeAdjustment( lpTimeAdjustment: PDWORD, lpTimeIncrement: PDWORD, lpTimeAdjustmentDisabled: PBOOL, ) -> BOOL; pub fn GetSystemTimeAsFileTime(lpSystemTimeAsFileTime: LPFILETIME); pub fn GetSystemTimePreciseAsFileTime(lpSystemTimeAsFileTime: LPFILETIME); pub fn GetSystemTimes( lpIdleTime: PFILETIME, lpKernelTime: PFILETIME, lpUserTime: PFILETIME, ) -> BOOL; pub fn GetSystemWindowsDirectoryA(lpBuffer: LPSTR, uSize: UINT) -> UINT; pub fn GetSystemWindowsDirectoryW(lpBuffer: LPWSTR, uSize: UINT) -> UINT; pub fn GetSystemWow64DirectoryA(lpBuffer: LPSTR, uSize: UINT) -> UINT; pub fn GetSystemWow64DirectoryW(lpBuffer: LPWSTR, uSize: UINT) -> UINT; pub fn GetTapeParameters( hDevice: HANDLE, dwOperation: DWORD, lpdwSize: LPDWORD, lpTapeInformation: LPVOID ) -> DWORD; pub fn GetTapePosition( hDevice: HANDLE, dwPositionType: DWORD, lpdwPartition: LPDWORD, lpdwOffsetLow: LPDWORD, lpdwOffsetHigh: LPDWORD ) -> DWORD; pub fn GetTapeStatus(hDevice: HANDLE) -> DWORD; pub fn GetTempFileNameA( lpPathName: LPCSTR, lpPrefixString: LPCSTR, uUnique: UINT, lpTempFileName: LPSTR, ) -> UINT; pub fn GetTempFileNameW( lpPathName: LPCWSTR, lpPrefixString: LPCWSTR, uUnique: UINT, lpTempFileName: LPWSTR, ) -> UINT; pub fn GetTempPathA(nBufferLength: DWORD, lpBuffer: LPSTR) -> DWORD; pub fn GetTempPathW(nBufferLength: DWORD, lpBuffer: LPWSTR) -> DWORD; pub fn GetThreadContext(hThread: HANDLE, lpContext: LPCONTEXT) -> BOOL; pub fn GetThreadErrorMode() -> DWORD; pub fn GetThreadGroupAffinity(hThread: HANDLE, GroupAffinity: PGROUP_AFFINITY) -> BOOL; pub fn GetThreadIOPendingFlag(hThread: HANDLE, lpIOIsPending: PBOOL) -> BOOL; pub fn GetThreadId(Thread: HANDLE) -> DWORD; pub fn GetThreadIdealProcessorEx(hThread: HANDLE, lpIdealProcessor: PPROCESSOR_NUMBER) -> BOOL; pub fn GetThreadInformation( hThread: HANDLE, ThreadInformationClass: THREAD_INFORMATION_CLASS, ThreadInformation: LPVOID, ThreadInformationSize: DWORD, ) -> BOOL; pub fn GetThreadLocale() -> LCID; pub fn GetThreadPreferredUILanguages( dwFlags: DWORD, pulNumLanguages: PULONG, pwszLanguagesBuffer: PZZWSTR, pcchLanguagesBuffer: PULONG, ) -> BOOL; pub fn GetThreadPriority(hThread: HANDLE) -> c_int; pub fn GetThreadPriorityBoost(hThread: HANDLE, pDisablePriorityBoost: PBOOL) -> BOOL; pub fn GetThreadSelectorEntry( hThread: HANDLE, dwSelector: DWORD, lpSelectorEntry: LPLDT_ENTRY, ) -> BOOL; pub fn GetThreadTimes( hThread: HANDLE, lpCreationTime: LPFILETIME, lpExitTime: LPFILETIME, lpKernelTime: LPFILETIME, lpUserTime: LPFILETIME, ) -> BOOL; pub fn GetThreadUILanguage() -> LANGID; pub fn GetTickCount() -> DWORD; pub fn GetTickCount64() -> ULONGLONG; pub fn GetTimeFormatA( Locale: LCID, dwFlags: DWORD, lpTime: *const SYSTEMTIME, lpFormat: LPCSTR, lpTimeStr: LPSTR, cchTime: c_int, ) -> c_int; pub fn GetTimeFormatEx( lpLocaleName: LPCWSTR, dwFlags: DWORD, lpTime: *const SYSTEMTIME, lpFormat: LPCWSTR, lpTimeStr: LPWSTR, cchTime: c_int, ) -> c_int; pub fn GetTimeFormatW( Locale: LCID, dwFlags: DWORD, lpTime: *const SYSTEMTIME, lpFormat: LPCWSTR, lpTimeStr: LPWSTR, cchTime: c_int, ) -> c_int; pub fn GetTimeZoneInformation(lpTimeZoneInformation: LPTIME_ZONE_INFORMATION) -> DWORD; pub fn GetTimeZoneInformationForYear( wYear: USHORT, pdtzi: PDYNAMIC_TIME_ZONE_INFORMATION, ptzi: LPTIME_ZONE_INFORMATION, ) -> BOOL; pub fn GetUILanguageInfo( dwFlags: DWORD, pwmszLanguage: PCZZWSTR, pwszFallbackLanguages: PZZWSTR, pcchFallbackLanguages: PDWORD, pAttributes: PDWORD, ) -> BOOL; #[cfg(target_arch = "x86_64")] pub fn GetUmsCompletionListEvent( UmsCompletionList: PUMS_COMPLETION_LIST, UmsCompletionEvent: PHANDLE, ) -> BOOL; #[cfg(target_arch = "x86_64")] pub fn GetUmsSystemThreadInformation( ThreadHandle: HANDLE, SystemThreadInfo: PUMS_SYSTEM_THREAD_INFORMATION, ) -> BOOL; pub fn GetUserDefaultLCID() -> LCID; pub fn GetUserDefaultLangID() -> LANGID; pub fn GetUserDefaultLocaleName(lpLocaleName: LPWSTR, cchLocaleName: c_int) -> c_int; pub fn GetUserDefaultUILanguage() -> LANGID; pub fn GetUserGeoID(GeoClass: GEOCLASS) -> GEOID; pub fn GetUserPreferredUILanguages( dwFlags: DWORD, pulNumLanguages: PULONG, pwszLanguagesBuffer: PZZWSTR, pcchLanguagesBuffer: PULONG, ) -> BOOL; pub fn GetVersion() -> DWORD; pub fn GetVersionExA(lpVersionInformation: LPOSVERSIONINFOA) -> BOOL; pub fn GetVersionExW(lpVersionInformation: LPOSVERSIONINFOW) -> BOOL; pub fn GetVolumeInformationA( lpRootPathName: LPCSTR, lpVolumeNameBuffer: LPSTR, nVolumeNameSize: DWORD, lpVolumeSerialNumber: LPDWORD, lpMaximumComponentLength: LPDWORD, lpFileSystemFlags: LPDWORD, lpFileSystemNameBuffer: LPSTR, nFileSystemNameSize: DWORD, ) -> BOOL; pub fn GetVolumeInformationByHandleW( hFile: HANDLE, lpVolumeNameBuffer: LPWSTR, nVolumeNameSize: DWORD, lpVolumeSerialNumber: LPDWORD, lpMaximumComponentLength: LPDWORD, lpFileSystemFlags: LPDWORD, lpFileSystemNameBuffer: LPWSTR, nFileSystemNameSize: DWORD, ) -> BOOL; pub fn GetVolumeInformationW( lpRootPathName: LPCWSTR, lpVolumeNameBuffer: LPWSTR, nVolumeNameSize: DWORD, lpVolumeSerialNumber: LPDWORD, lpMaximumComponentLength: LPDWORD, lpFileSystemFlags: LPDWORD, lpFileSystemNameBuffer: LPWSTR, nFileSystemNameSize: DWORD, ) -> BOOL; pub fn GetVolumeNameForVolumeMountPointA( lpszVolumeMountPoint: LPCSTR, lpszVolumeName: LPSTR, cchBufferLength: DWORD, ) -> BOOL; pub fn GetVolumeNameForVolumeMountPointW( lpszVolumeMountPoint: LPCWSTR, lpszVolumeName: LPWSTR, cchBufferLength: DWORD, ) -> BOOL; pub fn GetVolumePathNameA( lpszFileName: LPCSTR, lpszVolumePathName: LPSTR, cchBufferLength: DWORD, ) -> BOOL; pub fn GetVolumePathNameW( lpszFileName: LPCWSTR, lpszVolumePathName: LPWSTR, cchBufferLength: DWORD, ) -> BOOL; pub fn GetVolumePathNamesForVolumeNameA( lpszVolumeName: LPCSTR, lpszVolumePathNames: LPCH, cchBufferLength: DWORD, lpcchReturnLength: PDWORD, ) -> BOOL; pub fn GetVolumePathNamesForVolumeNameW( lpszVolumeName: LPCWSTR, lpszVolumePathNames: LPWCH, cchBufferLength: DWORD, lpcchReturnLength: PDWORD, ) -> BOOL; pub fn GetWindowsDirectoryA(lpBuffer: LPSTR, uSize: UINT) -> UINT; pub fn GetWindowsDirectoryW(lpBuffer: LPWSTR, uSize: UINT) -> UINT; pub fn GetWriteWatch( dwFlags: DWORD, lpBaseAddress: PVOID, dwRegionSize: SIZE_T, lpAddresses: *mut PVOID, lpdwCount: *mut ULONG_PTR, lpdwGranularity: LPDWORD, ) -> UINT; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub fn GetXStateFeaturesMask(Context: PCONTEXT, FeatureMask: PDWORD64) -> BOOL; pub fn GlobalAddAtomA(lpString: LPCSTR) -> ATOM; pub fn GlobalAddAtomExA(lpString: LPCSTR, Flags: DWORD) -> ATOM; pub fn GlobalAddAtomExW(lpString: LPCWSTR, Flags: DWORD) -> ATOM; pub fn GlobalAddAtomW(lpString: LPCWSTR) -> ATOM; pub fn GlobalAlloc(uFlags: UINT, dwBytes: SIZE_T) -> HGLOBAL; pub fn GlobalCompact(dwMinFree: DWORD) -> SIZE_T; pub fn GlobalDeleteAtom(nAtom: ATOM) -> ATOM; pub fn GlobalFindAtomA(lpString: LPCSTR) -> ATOM; pub fn GlobalFindAtomW(lpString: LPCWSTR) -> ATOM; pub fn GlobalFix(hMem: HGLOBAL); pub fn GlobalFlags(hMem: HGLOBAL) -> UINT; pub fn GlobalFree(hMem: HGLOBAL) -> HGLOBAL; pub fn GlobalGetAtomNameA(nAtom: ATOM, lpBuffer: LPSTR, nSize: c_int) -> UINT; pub fn GlobalGetAtomNameW(nAtom: ATOM, lpBuffer: LPWSTR, nSize: c_int) -> UINT; pub fn GlobalHandle(pMem: LPCVOID) -> HGLOBAL; pub fn GlobalLock(hMem: HGLOBAL) -> LPVOID; pub fn GlobalMemoryStatus(lpBuffer: LPMEMORYSTATUS); pub fn GlobalMemoryStatusEx(lpBuffer: LPMEMORYSTATUSEX) -> BOOL; pub fn GlobalReAlloc(hMem: HGLOBAL, dwBytes: SIZE_T, uFlags: UINT) -> HGLOBAL; pub fn GlobalSize(hMem: HGLOBAL) -> SIZE_T; pub fn GlobalUnWire(hMem: HGLOBAL) -> BOOL; pub fn GlobalUnfix(hMem: HGLOBAL); pub fn GlobalUnlock(hMem: HGLOBAL) -> BOOL; pub fn GlobalWire(hMem: HGLOBAL) -> LPVOID; pub fn Heap32First(lphe: LPHEAPENTRY32, th32ProcessID: DWORD, th32HeapID: ULONG_PTR) -> BOOL; pub fn Heap32ListFirst(hSnapshot: HANDLE, lphl: LPHEAPLIST32) -> BOOL; pub fn Heap32ListNext(hSnapshot: HANDLE, lphl: LPHEAPLIST32) -> BOOL; pub fn Heap32Next(lphe: LPHEAPENTRY32) -> BOOL; pub fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID; pub fn HeapCompact(hHeap: HANDLE, dwFlags: DWORD) -> SIZE_T; pub fn HeapCreate(flOptions: DWORD, dwInitialSize: SIZE_T, dwMaximumSize: SIZE_T) -> HANDLE; pub fn HeapDestroy(hHeap: HANDLE) -> BOOL; pub fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL; pub fn HeapLock(hHeap: HANDLE) -> BOOL; pub fn HeapQueryInformation( HeapHandle: HANDLE, HeapInformationClass: HEAP_INFORMATION_CLASS, HeapInformation: PVOID, HeapInformationLength: SIZE_T, ReturnLength: PSIZE_T, ) -> BOOL; pub fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID, dwBytes: SIZE_T) -> LPVOID; pub fn HeapSetInformation( HeapHandle: HANDLE, HeapInformationClass: HEAP_INFORMATION_CLASS, HeapInformation: PVOID, HeapInformationLength: SIZE_T, ) -> BOOL; pub fn HeapSize(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPCVOID) -> SIZE_T; pub fn HeapSummary(hHeap: HANDLE, dwFlags: DWORD, lpSummary: LPHEAP_SUMMARY) -> BOOL; pub fn HeapUnlock(hHeap: HANDLE) -> BOOL; pub fn HeapValidate(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPCVOID) -> BOOL; pub fn HeapWalk(hHeap: HANDLE, lpEntry: LPPROCESS_HEAP_ENTRY) -> BOOL; pub fn InitAtomTable(nSize: DWORD) -> BOOL; pub fn InitOnceBeginInitialize( lpInitOnce: LPINIT_ONCE, dwFlags: DWORD, fPending: PBOOL, lpContext: *mut LPVOID, ) -> BOOL; pub fn InitOnceComplete( lpInitOnce: LPINIT_ONCE, dwFlags: DWORD, lpContext: LPVOID, ) -> BOOL; pub fn InitOnceExecuteOnce( InitOnce: PINIT_ONCE, InitFn: PINIT_ONCE_FN, Parameter: PVOID, Context: *mut LPVOID, ) -> BOOL; pub fn InitOnceInitialize(InitOnce: PINIT_ONCE); pub fn InitializeConditionVariable(ConditionVariable: PCONDITION_VARIABLE); pub fn InitializeContext( Buffer: PVOID, ContextFlags: DWORD, Context: *mut PCONTEXT, ContextLength: PDWORD, ) -> BOOL; pub fn InitializeCriticalSection(lpCriticalSection: LPCRITICAL_SECTION); pub fn InitializeCriticalSectionAndSpinCount( lpCriticalSection: LPCRITICAL_SECTION, dwSpinCount: DWORD, ) -> BOOL; pub fn InitializeCriticalSectionEx( lpCriticalSection: LPCRITICAL_SECTION, dwSpinCount: DWORD, Flags: DWORD, ) -> BOOL; pub fn InitializeProcThreadAttributeList( lpAttributeList: LPPROC_THREAD_ATTRIBUTE_LIST, dwAttributeCount: DWORD, dwFlags: DWORD, lpSize: PSIZE_T, ) -> BOOL; pub fn InitializeSListHead(ListHead: PSLIST_HEADER); pub fn InitializeSRWLock(SRWLock: PSRWLOCK); pub fn InitializeSynchronizationBarrier( lpBarrier: LPSYNCHRONIZATION_BARRIER, lTotalThreads: LONG, lSpinCount: LONG, ) -> BOOL; pub fn InstallELAMCertificateInfo(ELAMFile: HANDLE) -> BOOL; #[cfg(target_arch = "x86")] pub fn InterlockedCompareExchange( Destination: *mut LONG, ExChange: LONG, Comperand: LONG, ) -> LONG; #[cfg(target_arch = "x86")] pub fn InterlockedCompareExchange64( Destination: *mut LONG64, ExChange: LONG64, Comperand: LONG64, ) -> LONG64; #[cfg(target_arch = "x86")] pub fn InterlockedDecrement(Addend: *mut LONG) -> LONG; #[cfg(target_arch = "x86")] pub fn InterlockedExchange(Target: *mut LONG, Value: LONG) -> LONG; #[cfg(target_arch = "x86")] pub fn InterlockedExchangeAdd(Addend: *mut LONG, Value: LONG) -> LONG; pub fn InterlockedFlushSList(ListHead: PSLIST_HEADER) -> PSLIST_ENTRY; #[cfg(target_arch = "x86")] pub fn InterlockedIncrement(Addend: *mut LONG) -> LONG; pub fn InterlockedPopEntrySList(ListHead: PSLIST_HEADER) -> PSLIST_ENTRY; pub fn InterlockedPushEntrySList( ListHead: PSLIST_HEADER, ListEntry: PSLIST_ENTRY, ) -> PSLIST_ENTRY; pub fn InterlockedPushListSListEx( ListHead: PSLIST_HEADER, List: PSLIST_ENTRY, ListEnd: PSLIST_ENTRY, Count: ULONG, ) -> PSLIST_ENTRY; pub fn IsBadCodePtr(lpfn: FARPROC) -> BOOL; pub fn IsBadHugeReadPtr(lp: *const VOID, ucb: UINT_PTR) -> BOOL; pub fn IsBadHugeWritePtr(lp: LPVOID, ucb: UINT_PTR) -> BOOL; pub fn IsBadReadPtr(lp: *const VOID, ucb: UINT_PTR) -> BOOL; pub fn IsBadStringPtrA(lpsz: LPCSTR, ucchMax: UINT_PTR) -> BOOL; pub fn IsBadStringPtrW(lpsz: LPCWSTR, ucchMax: UINT_PTR) -> BOOL; pub fn IsBadWritePtr(lp: LPVOID, ucb: UINT_PTR) -> BOOL; pub fn IsDBCSLeadByte(TestChar: BYTE) -> BOOL; pub fn IsDBCSLeadByteEx(CodePage: UINT, TestChar: BYTE) -> BOOL; pub fn IsDebuggerPresent() -> BOOL; pub fn IsNLSDefinedString( Function: NLS_FUNCTION, dwFlags: DWORD, lpVersionInformation: LPNLSVERSIONINFO, lpString: LPCWSTR, cchStr: INT, ) -> BOOL; pub fn IsNativeVhdBoot(NativeVhdBoot: PBOOL) -> BOOL; pub fn IsNormalizedString(NormForm: NORM_FORM, lpString: LPCWSTR, cwLength: c_int) -> BOOL; pub fn IsProcessCritical(hProcess: HANDLE, Critical: PBOOL) -> BOOL; pub fn IsProcessInJob(ProcessHandle: HANDLE, JobHandle: HANDLE, Result: PBOOL) -> BOOL; pub fn IsProcessorFeaturePresent(ProcessorFeature: DWORD) -> BOOL; pub fn IsSystemResumeAutomatic() -> BOOL; pub fn IsThreadAFiber() -> BOOL; pub fn IsThreadpoolTimerSet(pti: PTP_TIMER) -> BOOL; pub fn IsValidCodePage(CodePage: UINT) -> BOOL; pub fn IsValidLanguageGroup(LanguageGroup: LGRPID, dwFlags: DWORD) -> BOOL; pub fn IsValidLocale(Locale: LCID, dwFlags: DWORD) -> BOOL; pub fn IsValidLocaleName(lpLocaleName: LPCWSTR) -> BOOL; pub fn IsValidNLSVersion( function: NLS_FUNCTION, lpLocaleName: LPCWSTR, lpVersionInformation: LPNLSVERSIONINFOEX, ) -> BOOL; pub fn IsWow64Process(hProcess: HANDLE, Wow64Process: PBOOL) -> BOOL; pub fn K32EmptyWorkingSet(hProcess: HANDLE) -> BOOL; pub fn K32EnumDeviceDrivers(lpImageBase: *mut LPVOID, cb: DWORD, lpcbNeeded: LPDWORD) -> BOOL; pub fn K32EnumPageFilesA( pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKA, pContext: LPVOID, ) -> BOOL; pub fn K32EnumPageFilesW( pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKW, pContext: LPVOID, ) -> BOOL; pub fn K32EnumProcessModules( hProcess: HANDLE, lphModule: *mut HMODULE, cb: DWORD, lpcbNeeded: LPDWORD, ) -> BOOL; pub fn K32EnumProcessModulesEx( hProcess: HANDLE, lphModule: *mut HMODULE, cb: DWORD, lpcbNeeded: LPDWORD, dwFilterFlag: DWORD, ) -> BOOL; pub fn K32EnumProcesses( lpidProcess: *mut DWORD, cb: DWORD, lpcbNeeded: LPDWORD, ) -> BOOL; pub fn K32GetDeviceDriverBaseNameA(ImageBase: LPVOID, lpFilename: LPSTR, nSize: DWORD) -> DWORD; pub fn K32GetDeviceDriverBaseNameW( ImageBase: LPVOID, lpFilename: LPWSTR, nSize: DWORD, ) -> DWORD; pub fn K32GetDeviceDriverFileNameA(ImageBase: LPVOID, lpFilename: LPSTR, nSize: DWORD) -> DWORD; pub fn K32GetDeviceDriverFileNameW( ImageBase: LPVOID, lpFilename: LPWSTR, nSize: DWORD, ) -> DWORD; pub fn K32GetMappedFileNameA( hProcess: HANDLE, lpv: LPVOID, lpFilename: LPSTR, nSize: DWORD, ) -> DWORD; pub fn K32GetMappedFileNameW( hProcess: HANDLE, lpv: LPVOID, lpFilename: LPWSTR, nSize: DWORD, ) -> DWORD; pub fn K32GetModuleBaseNameA( hProcess: HANDLE, hModule: HMODULE, lpBaseName: LPSTR, nSize: DWORD, ) -> DWORD; pub fn K32GetModuleBaseNameW( hProcess: HANDLE, hModule: HMODULE, lpBaseName: LPWSTR, nSize: DWORD, ) -> DWORD; pub fn K32GetModuleFileNameExA( hProcess: HANDLE, hModule: HMODULE, lpFilename: LPSTR, nSize: DWORD, ) -> DWORD; pub fn K32GetModuleFileNameExW( hProcess: HANDLE, hModule: HMODULE, lpFilename: LPWSTR, nSize: DWORD, ) -> DWORD; pub fn K32GetModuleInformation( hProcess: HANDLE, hModule: HMODULE, lpmodinfo: LPMODULEINFO, cb: DWORD, ) -> BOOL; pub fn K32GetPerformanceInfo( pPerformanceInformation: PPERFORMANCE_INFORMATION, cb: DWORD, ) -> BOOL; pub fn K32GetProcessImageFileNameA( hProcess: HANDLE, lpImageFileName: LPSTR, nSize: DWORD, ) -> DWORD; pub fn K32GetProcessImageFileNameW( hProcess: HANDLE, lpImageFileName: LPWSTR, nSize: DWORD, ) -> DWORD; pub fn K32GetProcessMemoryInfo( Process: HANDLE, ppsmemCounters: PPROCESS_MEMORY_COUNTERS, cb: DWORD, ) -> BOOL; pub fn K32GetWsChanges( hProcess: HANDLE, lpWatchInfo: PPSAPI_WS_WATCH_INFORMATION, cb: DWORD, ) -> BOOL; pub fn K32GetWsChangesEx( hProcess: HANDLE, lpWatchInfoEx: PPSAPI_WS_WATCH_INFORMATION_EX, cb: DWORD, ) -> BOOL; pub fn K32InitializeProcessForWsWatch(hProcess: HANDLE) -> BOOL; pub fn K32QueryWorkingSet(hProcess: HANDLE, pv: PVOID, cb: DWORD) -> BOOL; pub fn K32QueryWorkingSetEx(hProcess: HANDLE, pv: PVOID, cb: DWORD) -> BOOL; pub fn LCIDToLocaleName(Locale: LCID, lpName: LPWSTR, cchName: c_int, dwFlags: DWORD) -> c_int; pub fn LCMapStringA( Locale: LCID, dwMapFlags: DWORD, lpSrcStr: LPCSTR, cchSrc: c_int, lpDestStr: LPSTR, cchDest: c_int, ) -> c_int; pub fn LCMapStringEx( lpLocaleName: LPCWSTR, dwMapFlags: DWORD, lpSrcStr: LPCWSTR, cchSrc: c_int, lpDestStr: LPWSTR, cchDest: c_int, lpVersionInformation: LPNLSVERSIONINFO, lpReserved: LPVOID, sortHandle: LPARAM, ) -> c_int; pub fn LCMapStringW( Locale: LCID, dwMapFlags: DWORD, lpSrcStr: LPCWSTR, cchSrc: c_int, lpDestStr: LPWSTR, cchDest: c_int, ) -> c_int; pub fn LeaveCriticalSection(lpCriticalSection: LPCRITICAL_SECTION); pub fn LeaveCriticalSectionWhenCallbackReturns( pci: PTP_CALLBACK_INSTANCE, pcs: PCRITICAL_SECTION, ); // pub fn LoadAppInitDlls(); pub fn LoadLibraryA(lpFileName: LPCSTR) -> HMODULE; pub fn LoadLibraryExA(lpLibFileName: LPCSTR, hFile: HANDLE, dwFlags: DWORD) -> HMODULE; pub fn LoadLibraryExW(lpLibFileName: LPCWSTR, hFile: HANDLE, dwFlags: DWORD) -> HMODULE; pub fn LoadLibraryW(lpFileName: LPCWSTR) -> HMODULE; pub fn LoadModule(lpModuleName: LPCSTR, lpParameterBlock: LPVOID) -> DWORD; pub fn LoadPackagedLibrary(lpwLibFileName: LPCWSTR, Reserved: DWORD) -> HMODULE; pub fn LoadResource(hModule: HMODULE, hResInfo: HRSRC) -> HGLOBAL; // pub fn LoadStringBaseExW(); // pub fn LoadStringBaseW(); pub fn LocalAlloc(uFlags: UINT, uBytes: SIZE_T) -> HLOCAL; pub fn LocalCompact(uMinFree: UINT) -> SIZE_T; pub fn LocalFileTimeToFileTime( lpLocalFileTime: *const FILETIME, lpFileTime: LPFILETIME, ) -> BOOL; pub fn LocalFlags(hMem: HLOCAL) -> UINT; pub fn LocalFree(hMem: HLOCAL) -> HLOCAL; pub fn LocalHandle(pMem: LPCVOID) -> HLOCAL; pub fn LocalLock(hMem: HLOCAL) -> LPVOID; pub fn LocalReAlloc(hMem: HLOCAL, uBytes: SIZE_T, uFlags: UINT) -> HLOCAL; pub fn LocalShrink(hMem: HLOCAL, cbNewSize: UINT) -> SIZE_T; pub fn LocalSize(hMem: HLOCAL) -> SIZE_T; pub fn LocalUnlock(hMem: HLOCAL) -> BOOL; pub fn LocaleNameToLCID(lpName: LPCWSTR, dwFlags: DWORD) -> LCID; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub fn LocateXStateFeature(Context: PCONTEXT, FeatureId: DWORD, Length: PDWORD) -> PVOID; pub fn LockFile( hFile: HANDLE, dwFileOffsetLow: DWORD, dwFileOffsetHigh: DWORD, nNumberOfBytesToLockLow: DWORD, nNumberOfBytesToLockHigh: DWORD, ) -> BOOL; pub fn LockFileEx( hFile: HANDLE, dwFlags: DWORD, dwReserved: DWORD, nNumberOfBytesToLockLow: DWORD, nNumberOfBytesToLockHigh: DWORD, lpOverlapped: LPOVERLAPPED, ) -> BOOL; pub fn LockResource(hResData: HGLOBAL) -> LPVOID; pub fn MapUserPhysicalPages( VirtualAddress: PVOID, NumberOfPages: ULONG_PTR, PageArray: PULONG_PTR, ) -> BOOL; pub fn MapUserPhysicalPagesScatter( VirtualAddresses: *mut PVOID, NumberOfPages: ULONG_PTR, PageArray: PULONG_PTR, ) -> BOOL; pub fn MapViewOfFile( hFileMappingObject: HANDLE, dwDesiredAccess: DWORD, dwFileOffsetHigh: DWORD, dwFileOffsetLow: DWORD, dwNumberOfBytesToMap: SIZE_T, ) -> LPVOID; pub fn MapViewOfFileEx( hFileMappingObject: HANDLE, dwDesiredAccess: DWORD, dwFileOffsetHigh: DWORD, dwFileOffsetLow: DWORD, dwNumberOfBytesToMap: SIZE_T, lpBaseAddress: LPVOID, ) -> LPVOID; pub fn MapViewOfFileExNuma( hFileMappingObject: HANDLE, dwDesiredAccess: DWORD, dwFileOffsetHigh: DWORD, dwFileOffsetLow: DWORD, dwNumberOfBytesToMap: SIZE_T, lpBaseAddress: LPVOID, nndPreferred: DWORD, ) -> LPVOID; pub fn MapViewOfFileFromApp( hFileMappingObject: HANDLE, DesiredAccess: DWORD, FileOffset: ULONG64, NumberOfBytesToMap: SIZE_T, ) -> PVOID; pub fn Module32First(hSnapshot: HANDLE, lpme: LPMODULEENTRY32) -> BOOL; pub fn Module32FirstW(hSnapshot: HANDLE, lpme: LPMODULEENTRY32W) -> BOOL; pub fn Module32Next(hSnapshot: HANDLE, lpme: LPMODULEENTRY32) -> BOOL; pub fn Module32NextW(hSnapshot: HANDLE, lpme: LPMODULEENTRY32W) -> BOOL; pub fn MoveFileA(lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR) -> BOOL; pub fn MoveFileExA(lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR, dwFlags: DWORD) -> BOOL; pub fn MoveFileExW(lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR, dwFlags: DWORD) -> BOOL; pub fn MoveFileTransactedA( lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR, lpProgressRoutine: LPPROGRESS_ROUTINE, lpData: LPVOID, dwFlags: DWORD, hTransaction: HANDLE, ) -> BOOL; pub fn MoveFileTransactedW( lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR, lpProgressRoutine: LPPROGRESS_ROUTINE, lpData: LPVOID, dwFlags: DWORD, hTransaction: HANDLE, ) -> BOOL; pub fn MoveFileW(lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR) -> BOOL; pub fn MoveFileWithProgressA( lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR, lpProgressRoutine: LPPROGRESS_ROUTINE, lpData: LPVOID, dwFlags: DWORD, ) -> BOOL; pub fn MoveFileWithProgressW( lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR, lpProgressRoutine: LPPROGRESS_ROUTINE, lpData: LPVOID, dwFlags: DWORD, ) -> BOOL; pub fn MulDiv(nNumber: c_int, nNumerator: c_int, nDenominator: c_int) -> c_int; pub fn MultiByteToWideChar( CodePage: UINT, dwFlags: DWORD, lpMultiByteStr: LPCCH, cbMultiByte: c_int, lpWideCharStr: LPWSTR, cchWideChar: c_int, ) -> c_int; pub fn NeedCurrentDirectoryForExePathA(ExeName: LPCSTR) -> BOOL; pub fn NeedCurrentDirectoryForExePathW(ExeName: LPCWSTR) -> BOOL; pub fn NormalizeString( NormForm: NORM_FORM, lpSrcString: LPCWSTR, cwSrcLength: c_int, lpDstString: LPWSTR, cwDstLength: c_int, ) -> c_int; // pub fn NotifyMountMgr(); pub fn NotifyUILanguageChange( dwFlags: DWORD, pcwstrNewLanguage: PCWSTR, pcwstrPreviousLanguage: PCWSTR, dwReserved: DWORD, pdwStatusRtrn: PDWORD, ) -> BOOL; // pub fn OOBEComplete(); pub fn OpenEventA(dwDesiredAccess: DWORD, bInheritHandle: BOOL, lpName: LPCSTR) -> HANDLE; pub fn OpenEventW(dwDesiredAccess: DWORD, bInheritHandle: BOOL, lpName: LPCWSTR) -> HANDLE; pub fn OpenFile(lpFileName: LPCSTR, lpReOpenBuff: LPOFSTRUCT, uStyle: UINT) -> HFILE; pub fn OpenFileById( hVolumeHint: HANDLE, lpFileId: LPFILE_ID_DESCRIPTOR, dwDesiredAccess: DWORD, dwShareMode: DWORD, lpSecurityAttributes: LPSECURITY_ATTRIBUTES, dwFlagsAndAttributes: DWORD, ) -> HANDLE; pub fn OpenFileMappingA( dwDesiredAccess: DWORD, bInheritHandle: BOOL, lpName: LPCSTR, ) -> HANDLE; pub fn OpenFileMappingW( dwDesiredAccess: DWORD, bInheritHandle: BOOL, lpName: LPCWSTR, ) -> HANDLE; pub fn OpenJobObjectA(dwDesiredAccess: DWORD, bInheritHandle: BOOL, lpName: LPCSTR) -> HANDLE; pub fn OpenJobObjectW(dwDesiredAccess: DWORD, bInheritHandle: BOOL, lpName: LPCWSTR) -> HANDLE; pub fn OpenMutexA(dwDesiredAccess: DWORD, bInheritHandle: BOOL, lpName: LPCSTR) -> HANDLE; pub fn OpenMutexW(dwDesiredAccess: DWORD, bInheritHandle: BOOL, lpName: LPCWSTR) -> HANDLE; // pub fn OpenPackageInfoByFullName(); pub fn OpenPrivateNamespaceA(lpBoundaryDescriptor: LPVOID, lpAliasPrefix: LPCSTR) -> HANDLE; pub fn OpenPrivateNamespaceW(lpBoundaryDescriptor: LPVOID, lpAliasPrefix: LPCWSTR) -> HANDLE; pub fn OpenProcess(dwDesiredAccess: DWORD, bInheritHandle: BOOL, dwProcessId: DWORD) -> HANDLE; pub fn OpenSemaphoreA(dwDesiredAccess: DWORD, bInheritHandle: BOOL, lpName: LPCSTR) -> HANDLE; pub fn OpenSemaphoreW(dwDesiredAccess: DWORD, bInheritHandle: BOOL, lpName: LPCWSTR) -> HANDLE; // pub fn OpenState(); // pub fn OpenStateExplicit(); pub fn OpenThread(dwDesiredAccess: DWORD, bInheritHandle: BOOL, dwThreadId: DWORD) -> HANDLE; pub fn OpenWaitableTimerA( dwDesiredAccess: DWORD, bInheritHandle: BOOL, lpTimerName: LPCSTR, ) -> HANDLE; pub fn OpenWaitableTimerW( dwDesiredAccess: DWORD, bInheritHandle: BOOL, lpTimerName: LPCWSTR, ) -> HANDLE; pub fn OutputDebugStringA(lpOutputString: LPCSTR); pub fn OutputDebugStringW(lpOutputString: LPCWSTR); // pub fn PackageFamilyNameFromFullName(); // pub fn PackageFamilyNameFromId(); // pub fn PackageFullNameFromId(); // pub fn PackageIdFromFullName(); // pub fn PackageNameAndPublisherIdFromFamilyName(); // pub fn ParseApplicationUserModelId(); pub fn PeekConsoleInputA( hConsoleInput: HANDLE, lpBuffer: PINPUT_RECORD, nLength: DWORD, lpNumberOfEventsRead: LPDWORD, ) -> BOOL; pub fn PeekConsoleInputW( hConsoleInput: HANDLE, lpBuffer: PINPUT_RECORD, nLength: DWORD, lpNumberOfEventsRead: LPDWORD, ) -> BOOL; pub fn PeekNamedPipe( hNamedPipe: HANDLE, lpBuffer: LPVOID, nBufferSize: DWORD, lpBytesRead: LPDWORD, lpTotalBytesAvail: LPDWORD, lpBytesLeftThisMessage: LPDWORD, ) -> BOOL; pub fn PostQueuedCompletionStatus( CompletionPort: HANDLE, dwNumberOfBytesTransferred: DWORD, dwCompletionKey: ULONG_PTR, lpOverlapped: LPOVERLAPPED, ) -> BOOL; pub fn PowerClearRequest(PowerRequest: HANDLE, RequestType: POWER_REQUEST_TYPE) -> BOOL; pub fn PowerCreateRequest(Context: PREASON_CONTEXT) -> HANDLE; pub fn PowerSetRequest(PowerRequest: HANDLE, RequestType: POWER_REQUEST_TYPE) -> BOOL; pub fn PrefetchVirtualMemory( hProcess: HANDLE, NumberOfEntries: ULONG_PTR, VirtualAddresses: PWIN32_MEMORY_RANGE_ENTRY, Flags: ULONG, ) -> BOOL; pub fn PrepareTape(hDevice: HANDLE, dwOperation: DWORD, bImmediate: BOOL) -> DWORD; pub fn Process32First(hSnapshot: HANDLE, lppe: LPPROCESSENTRY32) -> BOOL; pub fn Process32FirstW(hSnapshot: HANDLE, lppe: LPPROCESSENTRY32W) -> BOOL; pub fn Process32Next(hSnapshot: HANDLE, lppe: LPPROCESSENTRY32) -> BOOL; pub fn Process32NextW(hSnapshot: HANDLE, lppe: LPPROCESSENTRY32W) -> BOOL; pub fn ProcessIdToSessionId(dwProcessId: DWORD, pSessionId: *mut DWORD) -> BOOL; pub fn PssCaptureSnapshot( ProcessHandle: HANDLE, CaptureFlags: PSS_CAPTURE_FLAGS, ThreadContextFlags: DWORD, SnapshotHandle: *mut HPSS, ) -> DWORD; pub fn PssDuplicateSnapshot( SourceProcessHandle: HANDLE, SnapshotHandle: HPSS, TargetProcessHandle: HANDLE, TargetSnapshotHandle: *mut HPSS, Flags: PSS_DUPLICATE_FLAGS, ) -> DWORD; pub fn PssFreeSnapshot(ProcessHandle: HANDLE, SnapshotHandle: HPSS) -> DWORD; pub fn PssQuerySnapshot( SnapshotHandle: HPSS, InformationClass: PSS_QUERY_INFORMATION_CLASS, Buffer: *mut c_void, BufferLength: DWORD, ) -> DWORD; pub fn PssWalkMarkerCreate( Allocator: *const PSS_ALLOCATOR, WalkMarkerHandle: *mut HPSSWALK, ) -> DWORD; pub fn PssWalkMarkerFree(WalkMarkerHandle: HPSSWALK) -> DWORD; pub fn PssWalkMarkerGetPosition(WalkMarkerHandle: HPSSWALK, Position: *mut ULONG_PTR) -> DWORD; // pub fn PssWalkMarkerRewind(); // pub fn PssWalkMarkerSeek(); pub fn PssWalkMarkerSeekToBeginning(WalkMarkerHandle: HPSSWALK) -> DWORD; pub fn PssWalkMarkerSetPosition(WalkMarkerHandle: HPSSWALK, Position: ULONG_PTR) -> DWORD; // pub fn PssWalkMarkerTell(); pub fn PssWalkSnapshot( SnapshotHandle: HPSS, InformationClass: PSS_WALK_INFORMATION_CLASS, WalkMarkerHandle: HPSSWALK, Buffer: *mut c_void, BufferLength: DWORD, ) -> DWORD; pub fn PulseEvent(hEvent: HANDLE) -> BOOL; pub fn PurgeComm(hFile: HANDLE, dwFlags: DWORD) -> BOOL; pub fn QueryActCtxSettingsW( dwFlags: DWORD, hActCtx: HANDLE, settingsNameSpace: PCWSTR, settingName: PCWSTR, pvBuffer: PWSTR, dwBuffer: SIZE_T, pdwWrittenOrRequired: *mut SIZE_T, ) -> BOOL; pub fn QueryActCtxW( dwFlags: DWORD, hActCtx: HANDLE, pvSubInstance: PVOID, ulInfoClass: ULONG, pvBuffer: PVOID, cbBuffer: SIZE_T, pcbWrittenOrRequired: *mut SIZE_T, ) -> BOOL; pub fn QueryDepthSList(ListHead: PSLIST_HEADER) -> USHORT; pub fn QueryDosDeviceA(lpDeviceName: LPCSTR, lpTargetPath: LPSTR, ucchMax: DWORD) -> DWORD; pub fn QueryDosDeviceW(lpDeviceName: LPCWSTR, lpTargetPath: LPWSTR, ucchMax: DWORD) -> DWORD; pub fn QueryFullProcessImageNameA( hProcess: HANDLE, dwFlags: DWORD, lpExeName: LPSTR, lpdwSize: PDWORD, ) -> BOOL; pub fn QueryFullProcessImageNameW( hProcess: HANDLE, dwFlags: DWORD, lpExeName: LPWSTR, lpdwSize: PDWORD, ) -> BOOL; pub fn QueryIdleProcessorCycleTime( BufferLength: PULONG, ProcessorIdleCycleTime: PULONG64, ) -> BOOL; pub fn QueryIdleProcessorCycleTimeEx( Group: USHORT, BufferLength: PULONG, ProcessorIdleCycleTime: PULONG64, ) -> BOOL; pub fn QueryInformationJobObject( hJob: HANDLE, JobObjectInformationClass: JOBOBJECTINFOCLASS, lpJobObjectInformation: LPVOID, cbJobObjectInformationLength: DWORD, lpReturnLength: LPDWORD, ) -> BOOL; pub fn QueryMemoryResourceNotification( ResourceNotificationHandle: HANDLE, ResourceState: PBOOL, ) -> BOOL; pub fn QueryPerformanceCounter(lpPerformanceCount: *mut LARGE_INTEGER) -> BOOL; pub fn QueryPerformanceFrequency(lpFrequency: *mut LARGE_INTEGER) -> BOOL; pub fn QueryProcessAffinityUpdateMode(hProcess: HANDLE, lpdwFlags: LPDWORD) -> BOOL; pub fn QueryProcessCycleTime(ProcessHandle: HANDLE, CycleTime: PULONG64) -> BOOL; pub fn QueryProtectedPolicy(PolicyGuid: LPCGUID, PolicyValue: PULONG_PTR) -> BOOL; pub fn QueryThreadCycleTime(ThreadHandle: HANDLE, CycleTime: PULONG64) -> BOOL; pub fn QueryThreadProfiling(ThreadHandle: HANDLE, Enabled: PBOOLEAN) -> DWORD; pub fn QueryThreadpoolStackInformation( ptpp: PTP_POOL, ptpsi: PTP_POOL_STACK_INFORMATION, ) -> BOOL; #[cfg(target_arch = "x86_64")] pub fn QueryUmsThreadInformation( UmsThread: PUMS_CONTEXT, UmsThreadInfoClass: UMS_THREAD_INFO_CLASS, UmsThreadInformation: PVOID, UmsThreadInformationLength: ULONG, ReturnLength: PULONG, ); pub fn QueryUnbiasedInterruptTime(UnbiasedTime: PULONGLONG) -> BOOL; pub fn QueueUserAPC(pfnAPC: PAPCFUNC, hThread: HANDLE, dwData: ULONG_PTR) -> DWORD; pub fn QueueUserWorkItem( Function: LPTHREAD_START_ROUTINE, Context: PVOID, Flags: ULONG, ) -> BOOL; pub fn RaiseException( dwExceptionCode: DWORD, dwExceptionFlags: DWORD, nNumberOfArguments: DWORD, lpArguments: *const ULONG_PTR, ); pub fn RaiseFailFastException( pExceptionRecord: PEXCEPTION_RECORD, pContextRecord: PCONTEXT, dwFlags: DWORD, ); pub fn ReOpenFile( hOriginalFile: HANDLE, dwDesiredAccess: DWORD, dwShareMode: DWORD, dwFlags: DWORD, ) -> HANDLE; pub fn ReadConsoleA( hConsoleInput: HANDLE, lpBuffer: LPVOID, nNumberOfCharsToRead: DWORD, lpNumberOfCharsRead: LPDWORD, pInputControl: PCONSOLE_READCONSOLE_CONTROL, ) -> BOOL; pub fn ReadConsoleInputA( hConsoleInput: HANDLE, lpBuffer: PINPUT_RECORD, nLength: DWORD, lpNumberOfEventsRead: LPDWORD, ) -> BOOL; pub fn ReadConsoleInputW( hConsoleInput: HANDLE, lpBuffer: PINPUT_RECORD, nLength: DWORD, lpNumberOfEventsRead: LPDWORD, ) -> BOOL; pub fn ReadConsoleOutputA( hConsoleOutput: HANDLE, lpBuffer: PCHAR_INFO, dwBufferSize: COORD, dwBufferCoord: COORD, lpReadRegion: PSMALL_RECT, ) -> BOOL; pub fn ReadConsoleOutputAttribute( hConsoleOutput: HANDLE, lpAttribute: LPWORD, nLength: DWORD, dwReadCoord: COORD, lpNumberOfAttrsRead: LPDWORD, ) -> BOOL; pub fn ReadConsoleOutputCharacterA( hConsoleOutput: HANDLE, lpCharacter: LPSTR, nLength: DWORD, dwReadCoord: COORD, lpNumberOfCharsRead: LPDWORD, ) -> BOOL; pub fn ReadConsoleOutputCharacterW( hConsoleOutput: HANDLE, lpCharacter: LPWSTR, nLength: DWORD, dwReadCoord: COORD, lpNumberOfCharsRead: LPDWORD, ) -> BOOL; pub fn ReadConsoleOutputW( hConsoleOutput: HANDLE, lpBuffer: PCHAR_INFO, dwBufferSize: COORD, dwBufferCoord: COORD, lpReadRegion: PSMALL_RECT, ) -> BOOL; pub fn ReadConsoleW( hConsoleInput: HANDLE, lpBuffer: LPVOID, nNumberOfCharsToRead: DWORD, lpNumberOfCharsRead: LPDWORD, pInputControl: PCONSOLE_READCONSOLE_CONTROL, ) -> BOOL; pub fn ReadDirectoryChangesW( hDirectory: HANDLE, lpBuffer: LPVOID, nBufferLength: DWORD, bWatchSubtree: BOOL, dwNotifyFilter: DWORD, lpBytesReturned: LPDWORD, lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE, ) -> BOOL; pub fn ReadFile( hFile: HANDLE, lpBuffer: LPVOID, nNumberOfBytesToRead: DWORD, lpNumberOfBytesRead: LPDWORD, lpOverlapped: LPOVERLAPPED, ) -> BOOL; pub fn ReadFileEx( hFile: HANDLE, lpBuffer: LPVOID, nNumberOfBytesToRead: DWORD, lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE, ) -> BOOL; pub fn ReadFileScatter( hFile: HANDLE, aSegmentArray: *mut FILE_SEGMENT_ELEMENT, nNumberOfBytesToRead: DWORD, lpReserved: LPDWORD, lpOverlapped: LPOVERLAPPED, ) -> BOOL; pub fn ReadProcessMemory( hProcess: HANDLE, lpBaseAddress: LPCVOID, lpBuffer: LPVOID, nSize: SIZE_T, lpNumberOfBytesRead: *mut SIZE_T, ) -> BOOL; pub fn ReadThreadProfilingData( PerformanceDataHandle: HANDLE, Flags: DWORD, PerformanceData: PPERFORMANCE_DATA, ) -> DWORD; pub fn RegisterApplicationRecoveryCallback( pRecoveyCallback: APPLICATION_RECOVERY_CALLBACK, pvParameter: PVOID, dwPingInterval: DWORD, dwFlags: DWORD, ) -> HRESULT; pub fn RegisterApplicationRestart(pwzCommandline: PCWSTR, dwFlags: DWORD) -> HRESULT; pub fn RegisterBadMemoryNotification(Callback: PBAD_MEMORY_CALLBACK_ROUTINE) -> PVOID; // pub fn RegisterWaitForInputIdle(); pub fn RegisterWaitForSingleObject( phNewWaitObject: PHANDLE, hObject: HANDLE, Callback: WAITORTIMERCALLBACK, Context: PVOID, dwMilliseconds: ULONG, dwFlags: ULONG, ) -> BOOL; pub fn RegisterWaitForSingleObjectEx( hObject: HANDLE, Callback: WAITORTIMERCALLBACK, Context: PVOID, dwMilliseconds: ULONG, dwFlags: ULONG, ) -> HANDLE; // pub fn RegisterWaitUntilOOBECompleted(); pub fn ReleaseActCtx(hActCtx: HANDLE); pub fn ReleaseMutex(hMutex: HANDLE) -> BOOL; pub fn ReleaseMutexWhenCallbackReturns(pci: PTP_CALLBACK_INSTANCE, mutex: HANDLE); pub fn ReleaseSRWLockExclusive(SRWLock: PSRWLOCK); pub fn ReleaseSRWLockShared(SRWLock: PSRWLOCK); pub fn ReleaseSemaphore( hSemaphore: HANDLE, lReleaseCount: LONG, lpPreviousCount: LPLONG, ) -> BOOL; pub fn ReleaseSemaphoreWhenCallbackReturns( pci: PTP_CALLBACK_INSTANCE, sem: HANDLE, crel: DWORD, ); pub fn RemoveDirectoryA(lpPathName: LPCSTR) -> BOOL; pub fn RemoveDirectoryTransactedA(lpPathName: LPCSTR, hTransaction: HANDLE) -> BOOL; pub fn RemoveDirectoryTransactedW(lpPathName: LPCWSTR, hTransaction: HANDLE) -> BOOL; pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL; pub fn RemoveDllDirectory(Cookie: DLL_DIRECTORY_COOKIE) -> BOOL; // pub fn RemoveLocalAlternateComputerNameA(); // pub fn RemoveLocalAlternateComputerNameW(); pub fn RemoveSecureMemoryCacheCallback(pfnCallBack: PSECURE_MEMORY_CACHE_CALLBACK) -> BOOL; pub fn RemoveVectoredContinueHandler(Handle: PVOID) -> ULONG; pub fn RemoveVectoredExceptionHandler(Handle: PVOID) -> ULONG; pub fn ReplaceFileA( lpReplacedFileName: LPCSTR, lpReplacementFileName: LPCSTR, lpBackupFileName: LPCSTR, dwReplaceFlags: DWORD, lpExclude: LPVOID, lpReserved: LPVOID, ); pub fn ReplaceFileW( lpReplacedFileName: LPCWSTR, lpReplacementFileName: LPCWSTR, lpBackupFileName: LPCWSTR, dwReplaceFlags: DWORD, lpExclude: LPVOID, lpReserved: LPVOID, ); pub fn ReplacePartitionUnit( TargetPartition: PWSTR, SparePartition: PWSTR, Flags: ULONG, ) -> BOOL; pub fn RequestDeviceWakeup(hDevice: HANDLE) -> BOOL; pub fn RequestWakeupLatency(latency: LATENCY_TIME) -> BOOL; pub fn ResetEvent(hEvent: HANDLE) -> BOOL; pub fn ResetWriteWatch(lpBaseAddress: LPVOID, dwRegionSize: SIZE_T) -> UINT; // pub fn ResolveDelayLoadedAPI(); // pub fn ResolveDelayLoadsFromDll(); pub fn ResolveLocaleName( lpNameToResolve: LPCWSTR, lpLocaleName: LPWSTR, cchLocaleName: c_int, ) -> c_int; pub fn RestoreLastError(dwErrCode: DWORD); pub fn ResumeThread(hThread: HANDLE) -> DWORD; #[cfg(target_arch = "arm")] pub fn RtlAddFunctionTable( FunctionTable: PRUNTIME_FUNCTION, EntryCount: DWORD, BaseAddress: DWORD, ) -> BOOLEAN; #[cfg(target_arch = "x86_64")] pub fn RtlAddFunctionTable( FunctionTable: PRUNTIME_FUNCTION, EntryCount: DWORD, BaseAddress: DWORD64, ) -> BOOLEAN; pub fn RtlCaptureContext(ContextRecord: PCONTEXT); pub fn RtlCaptureStackBackTrace( FramesToSkip: DWORD, FramesToCapture: DWORD, BackTrace: *mut PVOID, BackTraceHash: PDWORD, ) -> WORD; // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] pub fn RtlCompareMemory(Source1: *const VOID, Source2: *const VOID, Length: SIZE_T) -> SIZE_T; // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] pub fn RtlCopyMemory(Destination: PVOID, Source: *const VOID, Length: SIZE_T); #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] pub fn RtlDeleteFunctionTable(FunctionTable: PRUNTIME_FUNCTION) -> BOOLEAN; // pub fn RtlFillMemory(); #[cfg(target_arch = "arm")] pub fn RtlInstallFunctionTableCallback( TableIdentifier: DWORD, BaseAddress: DWORD, Length: DWORD, Callback: PGET_RUNTIME_FUNCTION_CALLBACK, Context: PVOID, OutOfProcessCallbackDll: PCWSTR, ) -> BOOLEAN; #[cfg(target_arch = "x86_64")] pub fn RtlInstallFunctionTableCallback( TableIdentifier: DWORD64, BaseAddress: DWORD64, Length: DWORD, Callback: PGET_RUNTIME_FUNCTION_CALLBACK, Context: PVOID, OutOfProcessCallbackDll: PCWSTR, ) -> BOOLEAN; #[cfg(target_arch = "arm")] pub fn RtlLookupFunctionEntry( ControlPc: ULONG_PTR, ImageBase: PDWORD, HistoryTable: PUNWIND_HISTORY_TABLE, ) -> PRUNTIME_FUNCTION; #[cfg(target_arch = "x86_64")] pub fn RtlLookupFunctionEntry( ControlPc: DWORD64, ImageBase: PDWORD64, HistoryTable: PUNWIND_HISTORY_TABLE, ) -> PRUNTIME_FUNCTION; // pub fn RtlMoveMemory(); // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] pub fn RtlPcToFileHeader(PcValue: PVOID, BaseOfImage: *mut PVOID) -> PVOID; // #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] // pub fn RtlRaiseException(); #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] pub fn RtlRestoreContext(ContextRecord: PCONTEXT, ExceptionRecord: *mut EXCEPTION_RECORD); pub fn RtlUnwind( TargetFrame: PVOID, TargetIp: PVOID, ExceptionRecord: PEXCEPTION_RECORD, ReturnValue: PVOID, ); #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] pub fn RtlUnwindEx( TargetFrame: PVOID, TargetIp: PVOID, ExceptionRecord: PEXCEPTION_RECORD, ReturnValue: PVOID, ContextRecord: PCONTEXT, HistoryTable: PUNWIND_HISTORY_TABLE, ); #[cfg(target_arch = "arm")] pub fn RtlVirtualUnwind( HandlerType: DWORD, ImageBase: DWORD, ControlPc: DWORD, FunctionEntry: PRUNTIME_FUNCTION, ContextRecord: PCONTEXT, HandlerData: *mut PVOID, EstablisherFrame: PDWORD, ContextPointers: PKNONVOLATILE_CONTEXT_POINTERS, ) -> PEXCEPTION_ROUTINE; #[cfg(target_arch = "x86_64")] pub fn RtlVirtualUnwind( HandlerType: DWORD, ImageBase: DWORD64, ControlPc: DWORD64, FunctionEntry: PRUNTIME_FUNCTION, ContextRecord: PCONTEXT, HandlerData: *mut PVOID, EstablisherFrame: PDWORD64, ContextPointers: PKNONVOLATILE_CONTEXT_POINTERS, ) -> PEXCEPTION_ROUTINE; // pub fn RtlZeroMemory(); pub fn ScrollConsoleScreenBufferA( hConsoleOutput: HANDLE, lpScrollRectangle: *const SMALL_RECT, lpClipRectangle: *const SMALL_RECT, dwDestinationOrigin: COORD, lpFill: *const CHAR_INFO, ) -> BOOL; pub fn ScrollConsoleScreenBufferW( hConsoleOutput: HANDLE, lpScrollRectangle: *const SMALL_RECT, lpClipRectangle: *const SMALL_RECT, dwDestinationOrigin: COORD, lpFill: *const CHAR_INFO, ) -> BOOL; pub fn SearchPathA( lpPath: LPCSTR, lpFileName: LPCSTR, lpExtension: LPCSTR, nBufferLength: DWORD, lpBuffer: LPSTR, lpFilePart: *mut LPSTR, ) -> DWORD; pub fn SearchPathW( lpPath: LPCWSTR, lpFileName: LPCWSTR, lpExtension: LPCWSTR, nBufferLength: DWORD, lpBuffer: LPWSTR, lpFilePart: *mut LPWSTR, ) -> DWORD; pub fn SetCachedSigningLevel( SourceFiles: PHANDLE, SourceFileCount: ULONG, Flags: ULONG, TargetFile: HANDLE, ) -> BOOL; pub fn SetCalendarInfoA( Locale: LCID, Calendar: CALID, CalType: CALTYPE, lpCalData: LPCSTR, ) -> BOOL; pub fn SetCalendarInfoW( Locale: LCID, Calendar: CALID, CalType: CALTYPE, lpCalData: LPCWSTR, ) -> BOOL; pub fn SetCommBreak(hFile: HANDLE) -> BOOL; pub fn SetCommConfig(hCommDev: HANDLE, lpCC: LPCOMMCONFIG, dwSize: DWORD) -> BOOL; pub fn SetCommMask(hFile: HANDLE, dwEvtMask: DWORD) -> BOOL; pub fn SetCommState(hFile: HANDLE, lpDCB: LPDCB) -> BOOL; pub fn SetCommTimeouts(hFile: HANDLE, lpCommTimeouts: LPCOMMTIMEOUTS) -> BOOL; pub fn SetComputerNameA(lpComputerName: LPCSTR) -> BOOL; pub fn SetComputerNameEx2W( NameType: COMPUTER_NAME_FORMAT, Flags: DWORD, lpBuffer: LPCWSTR, ) -> BOOL; pub fn SetComputerNameExA(NameType: COMPUTER_NAME_FORMAT, lpBuffer: LPCSTR) -> BOOL; pub fn SetComputerNameExW(NameType: COMPUTER_NAME_FORMAT, lpBuffer: LPCWSTR) -> BOOL; pub fn SetComputerNameW(lpComputerName: LPCWSTR) -> BOOL; pub fn SetConsoleActiveScreenBuffer(hConsoleOutput: HANDLE) -> BOOL; pub fn SetConsoleCP(wCodePageID: UINT) -> BOOL; pub fn SetConsoleCtrlHandler(HandlerRoutine: PHANDLER_ROUTINE, Add: BOOL) -> BOOL; // pub fn SetConsoleCursor(); pub fn SetConsoleCursorInfo( hConsoleOutput: HANDLE, lpConsoleCursorInfo: *const CONSOLE_CURSOR_INFO, ) -> BOOL; pub fn SetConsoleCursorPosition(hConsoleOutput: HANDLE, dwCursorPosition: COORD) -> BOOL; pub fn SetConsoleDisplayMode( hConsoleOutput: HANDLE, dwFlags: DWORD, lpNewScreenBufferDimensions: PCOORD, ) -> BOOL; pub fn SetConsoleHistoryInfo(lpConsoleHistoryInfo: PCONSOLE_HISTORY_INFO) -> BOOL; pub fn SetConsoleMode(hConsoleHandle: HANDLE, dwMode: DWORD) -> BOOL; pub fn SetConsoleOutputCP(wCodePageID: UINT) -> BOOL; pub fn SetConsoleScreenBufferInfoEx( hConsoleOutput: HANDLE, lpConsoleScreenBufferInfoEx: PCONSOLE_SCREEN_BUFFER_INFOEX, ) -> BOOL; pub fn SetConsoleScreenBufferSize(hConsoleOutput: HANDLE, dwSize: COORD) -> BOOL; pub fn SetConsoleTextAttribute(hConsoleOutput: HANDLE, wAttributes: WORD) -> BOOL; pub fn SetConsoleTitleA(lpConsoleTitle: LPCSTR) -> BOOL; pub fn SetConsoleTitleW(lpConsoleTitle: LPCWSTR) -> BOOL; pub fn SetConsoleWindowInfo( hConsoleOutput: HANDLE, bAbsolute: BOOL, lpConsoleWindow: *const SMALL_RECT, ) -> BOOL; pub fn SetCriticalSectionSpinCount( lpCriticalSection: LPCRITICAL_SECTION, dwSpinCount: DWORD, ) -> DWORD; pub fn SetCurrentConsoleFontEx( hConsoleOutput: HANDLE, bMaximumWindow: BOOL, lpConsoleCurrentFontEx: PCONSOLE_FONT_INFOEX, ) -> BOOL; pub fn SetCurrentDirectoryA(lpPathName: LPCSTR) -> BOOL; pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL; pub fn SetDefaultCommConfigA(lpszName: LPCSTR, lpCC: LPCOMMCONFIG, dwSize: DWORD) -> BOOL; pub fn SetDefaultCommConfigW(lpszName: LPCWSTR, lpCC: LPCOMMCONFIG, dwSize: DWORD) -> BOOL; pub fn SetDefaultDllDirectories(DirectoryFlags: DWORD) -> BOOL; pub fn SetDllDirectoryA(lpPathName: LPCSTR) -> BOOL; pub fn SetDllDirectoryW(lpPathName: LPCWSTR) -> BOOL; pub fn SetDynamicTimeZoneInformation( lpTimeZoneInformation: *const DYNAMIC_TIME_ZONE_INFORMATION, ) -> BOOL; pub fn SetEndOfFile(hFile: HANDLE) -> BOOL; pub fn SetEnvironmentStringsA(NewEnvironment: LPCH) -> BOOL; pub fn SetEnvironmentStringsW(NewEnvironment: LPWCH) -> BOOL; pub fn SetEnvironmentVariableA(lpName: LPCSTR, lpValue: LPCSTR) -> BOOL; pub fn SetEnvironmentVariableW(lpName: LPCWSTR, lpValue: LPCWSTR) -> BOOL; pub fn SetErrorMode(uMode: UINT) -> UINT; pub fn SetEvent(hEvent: HANDLE) -> BOOL; pub fn SetEventWhenCallbackReturns(pci: PTP_CALLBACK_INSTANCE, evt: HANDLE); pub fn SetFileApisToANSI(); pub fn SetFileApisToOEM(); pub fn SetFileAttributesA(lpFileName: LPCSTR, dwFileAttributes: DWORD) -> BOOL; pub fn SetFileAttributesTransactedA( lpFileName: LPCSTR, dwFileAttributes: DWORD, hTransaction: HANDLE, ) -> BOOL; pub fn SetFileAttributesTransactedW( lpFileName: LPCWSTR, dwFileAttributes: DWORD, hTransaction: HANDLE, ) -> BOOL; pub fn SetFileAttributesW(lpFileName: LPCWSTR, dwFileAttributes: DWORD) -> BOOL; pub fn SetFileBandwidthReservation( hFile: HANDLE, nPeriodMilliseconds: DWORD, nBytesPerPeriod: DWORD, bDiscardable: BOOL, lpTransferSize: LPDWORD, lpNumOutstandingRequests: LPDWORD, ) -> BOOL; pub fn SetFileCompletionNotificationModes(FileHandle: HANDLE, Flags: UCHAR) -> BOOL; pub fn SetFileInformationByHandle( hFile: HANDLE, FileInformationClass: FILE_INFO_BY_HANDLE_CLASS, lpFileInformation: LPVOID, dwBufferSize: DWORD, ) -> BOOL; pub fn SetFileIoOverlappedRange( FileHandle: HANDLE, OverlappedRangeStart: PUCHAR, Length: ULONG, ) -> BOOL; pub fn SetFilePointer( hFile: HANDLE, lDistanceToMove: LONG, lpDistanceToMoveHigh: PLONG, dwMoveMethod: DWORD, ) -> DWORD; pub fn SetFilePointerEx( hFile: HANDLE, liDistanceToMove: LARGE_INTEGER, lpNewFilePointer: PLARGE_INTEGER, dwMoveMethod: DWORD, ) -> BOOL; pub fn SetFileShortNameA(hFile: HANDLE, lpShortName: LPCSTR) -> BOOL; pub fn SetFileShortNameW(hFile: HANDLE, lpShortName: LPCWSTR) -> BOOL; pub fn SetFileTime( hFile: HANDLE, lpCreationTime: *const FILETIME, lpLastAccessTime: *const FILETIME, lpLastWriteTime: *const FILETIME, ) -> BOOL; pub fn SetFileValidData(hFile: HANDLE, ValidDataLength: LONGLONG) -> BOOL; pub fn SetFirmwareEnvironmentVariableA( lpName: LPCSTR, lpGuid: LPCSTR, pValue: PVOID, nSize: DWORD, ) -> BOOL; pub fn SetFirmwareEnvironmentVariableExA( lpName: LPCSTR, lpGuid: LPCSTR, pValue: PVOID, nSize: DWORD, dwAttributes: DWORD, ) -> BOOL; pub fn SetFirmwareEnvironmentVariableExW( lpName: LPCWSTR, lpGuid: LPCWSTR, pValue: PVOID, nSize: DWORD, dwAttributes: DWORD, ) -> BOOL; pub fn SetFirmwareEnvironmentVariableW( lpName: LPCWSTR, lpGuid: LPCWSTR, pValue: PVOID, nSize: DWORD, ) -> BOOL; pub fn SetHandleCount(uNumber: UINT) -> UINT; pub fn SetHandleInformation(hObject: HANDLE, dwMask: DWORD, dwFlags: DWORD) -> BOOL; pub fn SetInformationJobObject( hJob: HANDLE, JobObjectInformationClass: JOBOBJECTINFOCLASS, lpJobObjectInformation: LPVOID, cbJobObjectInformationLength: DWORD, ) -> BOOL; pub fn SetLastError(dwErrCode: DWORD); // pub fn SetLocalPrimaryComputerNameA(); // pub fn SetLocalPrimaryComputerNameW(); pub fn SetLocalTime(lpSystemTime: *const SYSTEMTIME) -> BOOL; pub fn SetLocaleInfoA(Locale: LCID, LCType: LCTYPE, lpLCData: LPCSTR) -> BOOL; pub fn SetLocaleInfoW(Locale: LCID, LCType: LCTYPE, lpLCData: LPCWSTR) -> BOOL; pub fn SetMailslotInfo(hMailslot: HANDLE, lReadTimeout: DWORD) -> BOOL; pub fn SetMessageWaitingIndicator(hMsgIndicator: HANDLE, ulMsgCount: ULONG) -> BOOL; pub fn SetNamedPipeAttribute( Pipe: HANDLE, AttributeType: PIPE_ATTRIBUTE_TYPE, AttributeName: PSTR, AttributeValue: PVOID, AttributeValueLength: SIZE_T, ) -> BOOL; pub fn SetNamedPipeHandleState( hNamedPipe: HANDLE, lpMode: LPDWORD, lpMaxCollectionCount: LPDWORD, lpCollectDataTimeout: LPDWORD, ) -> BOOL; pub fn SetPriorityClass(hProcess: HANDLE, dwPriorityClass: DWORD); pub fn SetProcessAffinityMask(hProcess: HANDLE, dwProcessAffinityMask: DWORD) -> BOOL; pub fn SetProcessAffinityUpdateMode(hProcess: HANDLE, dwFlags: DWORD) -> BOOL; pub fn SetProcessDEPPolicy(dwFlags: DWORD) -> BOOL; pub fn SetProcessInformation( hProcess: HANDLE, ProcessInformationClass: PROCESS_INFORMATION_CLASS, ProcessInformation: LPVOID, ProcessInformationSize: DWORD, ) -> BOOL; pub fn SetProcessMitigationPolicy( MitigationPolicy: PROCESS_MITIGATION_POLICY, lpBuffer: PVOID, dwLength: SIZE_T, ) -> BOOL; pub fn SetProcessPreferredUILanguages( dwFlags: DWORD, pwszLanguagesBuffer: PCZZWSTR, pulNumLanguages: PULONG, ) -> BOOL; pub fn SetProcessPriorityBoost(hProcess: HANDLE, bDisablePriorityBoost: BOOL) -> BOOL; pub fn SetProcessShutdownParameters(dwLevel: DWORD, dwFlags: DWORD) -> BOOL; pub fn SetProcessWorkingSetSize( hProcess: HANDLE, dwMinimumWorkingSetSize: SIZE_T, dwMaximumWorkingSetSize: SIZE_T, ) -> BOOL; pub fn SetProcessWorkingSetSizeEx( hProcess: HANDLE, dwMinimumWorkingSetSize: SIZE_T, dwMaximumWorkingSetSize: SIZE_T, Flags: DWORD, ) -> BOOL; pub fn SetProtectedPolicy( PolicyGuid: LPCGUID, PolicyValue: ULONG_PTR, OldPolicyValue: PULONG_PTR, ) -> BOOL; pub fn SetSearchPathMode(Flags: DWORD) -> BOOL; pub fn SetStdHandle(nStdHandle: DWORD, hHandle: HANDLE) -> BOOL; pub fn SetStdHandleEx(nStdHandle: DWORD, hHandle: HANDLE, phPrevValue: PHANDLE) -> BOOL; pub fn SetSystemFileCacheSize( MinimumFileCacheSize: SIZE_T, MaximumFileCacheSize: SIZE_T, Flags: DWORD, ) -> BOOL; pub fn SetSystemPowerState(fSuspend: BOOL, fForce: BOOL) -> BOOL; pub fn SetSystemTime(lpSystemTime: *const SYSTEMTIME) -> BOOL; pub fn SetSystemTimeAdjustment(dwTimeAdjustment: DWORD, bTimeAdjustmentDisabled: BOOL) -> BOOL; pub fn SetTapeParameters( hDevice: HANDLE, dwOperation: DWORD, lpTapeInformation: LPVOID, ) -> DWORD; pub fn SetTapePosition( hDevice: HANDLE, dwPositionMethod: DWORD, dwPartition: DWORD, dwOffsetLow: DWORD, dwOffsetHigh: DWORD, bImmediate: BOOL ) -> DWORD; pub fn SetThreadAffinityMask(hThread: HANDLE, dwThreadAffinityMask: DWORD) -> DWORD_PTR; pub fn SetThreadContext(hThread: HANDLE, lpContext: *const CONTEXT) -> BOOL; pub fn SetThreadErrorMode(dwNewMode: DWORD, lpOldMode: LPDWORD) -> BOOL; pub fn SetThreadExecutionState(esFlags: EXECUTION_STATE) -> EXECUTION_STATE; pub fn SetThreadGroupAffinity( hThread: HANDLE, GroupAffinity: *const GROUP_AFFINITY, PreviousGroupAffinity: PGROUP_AFFINITY, ) -> BOOL; pub fn SetThreadIdealProcessor(hThread: HANDLE, dwIdealProcessor: DWORD) -> DWORD; pub fn SetThreadIdealProcessorEx( hThread: HANDLE, lpIdealProcessor: PPROCESSOR_NUMBER, lpPreviousIdealProcessor: PPROCESSOR_NUMBER, ) -> BOOL; pub fn SetThreadInformation( hThread: HANDLE, ThreadInformationClass: THREAD_INFORMATION_CLASS, ThreadInformation: LPVOID, ThreadInformationSize: DWORD, ); pub fn SetThreadLocale(Locale: LCID) -> BOOL; pub fn SetThreadPreferredUILanguages( dwFlags: DWORD, pwszLanguagesBuffer: PCZZWSTR, pulNumLanguages: PULONG, ) -> BOOL; pub fn SetThreadPriority(hThread: HANDLE, nPriority: c_int) -> BOOL; pub fn SetThreadPriorityBoost(hThread: HANDLE, bDisablePriorityBoost: BOOL) -> BOOL; pub fn SetThreadStackGuarantee(StackSizeInBytes: PULONG) -> BOOL; pub fn SetThreadUILanguage(LangId: LANGID) -> LANGID; pub fn SetThreadpoolStackInformation( ptpp: PTP_POOL, ptpsi: PTP_POOL_STACK_INFORMATION, ) -> BOOL; pub fn SetThreadpoolThreadMaximum(ptpp: PTP_POOL, cthrdMost: DWORD); pub fn SetThreadpoolThreadMinimum(ptpp: PTP_POOL, cthrdMic: DWORD); pub fn SetThreadpoolTimer( pti: PTP_TIMER, pftDueTime: PFILETIME, msPeriod: DWORD, msWindowLength: DWORD, ); pub fn SetThreadpoolTimerEx( pti: PTP_TIMER, pftDueTime: PFILETIME, msPeriod: DWORD, msWindowLength: DWORD, ) -> BOOL; pub fn SetThreadpoolWait(pwa: PTP_WAIT, h: HANDLE, pftTimeout: PFILETIME); pub fn SetThreadpoolWaitEx( pwa: PTP_WAIT, h: HANDLE, pftTimeout: PFILETIME, Reserved: PVOID, ) -> BOOL; pub fn SetTimeZoneInformation(lpTimeZoneInformation: *const TIME_ZONE_INFORMATION) -> BOOL; pub fn SetTimerQueueTimer( TimerQueue: HANDLE, Callback: WAITORTIMERCALLBACK, Parameter: PVOID, DueTime: DWORD, Period: DWORD, PreferIo: BOOL, ) -> HANDLE; #[cfg(target_arch = "x86_64")] pub fn SetUmsThreadInformation( UmsThread: PUMS_CONTEXT, UmsThreadInfoClass: UMS_THREAD_INFO_CLASS, UmsThreadInformation: PVOID, UmsThreadInformationLength: ULONG, ) -> BOOL; pub fn SetUnhandledExceptionFilter( lpTopLevelExceptionFilter: LPTOP_LEVEL_EXCEPTION_FILTER, ) -> LPTOP_LEVEL_EXCEPTION_FILTER; pub fn SetUserGeoID(GeoId: GEOID) -> BOOL; pub fn SetVolumeLabelA(lpRootPathName: LPCSTR, lpVolumeName: LPCSTR) -> BOOL; pub fn SetVolumeLabelW(lpRootPathName: LPCWSTR, lpVolumeName: LPCWSTR) -> BOOL; pub fn SetVolumeMountPointA(lpszVolumeMountPoint: LPCSTR, lpszVolumeName: LPCSTR) -> BOOL; pub fn SetVolumeMountPointW(lpszVolumeMountPoint: LPCWSTR, lpszVolumeName: LPCWSTR) -> BOOL; pub fn SetWaitableTimer( hTimer: HANDLE, lpDueTime: *const LARGE_INTEGER, lPeriod: LONG, pfnCompletionRoutine: PTIMERAPCROUTINE, lpArgToCompletionRoutine: LPVOID, fResume: BOOL, ) -> BOOL; pub fn SetWaitableTimerEx( hTimer: HANDLE, lpDueTime: *const LARGE_INTEGER, lPeriod: LONG, pfnCompletionRoutine: PTIMERAPCROUTINE, lpArgToCompletionRoutine: LPVOID, WakeContext: PREASON_CONTEXT, TolerableDelay: ULONG, ) -> BOOL; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub fn SetXStateFeaturesMask(Context: PCONTEXT, FeatureMask: DWORD64) -> BOOL; pub fn SetupComm(hFile: HANDLE, dwInQueue: DWORD, dwOutQueue: DWORD) -> BOOL; pub fn SignalObjectAndWait( hObjectToSignal: HANDLE, hObjectToWaitOn: HANDLE, dwMilliseconds: DWORD, bAlertable: BOOL, ) -> DWORD; pub fn SizeofResource(hModule: HMODULE, hResInfo: HRSRC) -> DWORD; pub fn Sleep(dwMilliseconds: DWORD); pub fn SleepConditionVariableCS( ConditionVariable: PCONDITION_VARIABLE, CriticalSection: PCRITICAL_SECTION, dwMilliseconds: DWORD, ) -> BOOL; pub fn SleepConditionVariableSRW( ConditionVariable: PCONDITION_VARIABLE, SRWLock: PSRWLOCK, dwMilliseconds: DWORD, Flags: ULONG, ) -> BOOL; pub fn SleepEx(dwMilliseconds: DWORD, bAlertable: BOOL) -> DWORD; pub fn StartThreadpoolIo(pio: PTP_IO); pub fn SubmitThreadpoolWork(pwk: PTP_WORK); pub fn SuspendThread(hThread: HANDLE) -> DWORD; pub fn SwitchToFiber(lpFiber: LPVOID); pub fn SwitchToThread() -> BOOL; pub fn SystemTimeToFileTime(lpSystemTime: *const SYSTEMTIME, lpFileTime: LPFILETIME) -> BOOL; pub fn SystemTimeToTzSpecificLocalTime( lpTimeZoneInformation: *const TIME_ZONE_INFORMATION, lpUniversalTime: *const SYSTEMTIME, lpLocalTime: LPSYSTEMTIME, ) -> BOOL; pub fn SystemTimeToTzSpecificLocalTimeEx( lpTimeZoneInformation: *const DYNAMIC_TIME_ZONE_INFORMATION, lpUniversalTime: *const SYSTEMTIME, lpLocalTime: LPSYSTEMTIME, ) -> BOOL; pub fn TerminateJobObject(hJob: HANDLE, uExitCode: UINT) -> BOOL; pub fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) -> BOOL; pub fn TerminateThread(hThread: HANDLE, dwExitCode: DWORD) -> BOOL; pub fn Thread32First(hSnapshot: HANDLE, lpte: LPTHREADENTRY32) -> BOOL; pub fn Thread32Next(hSnapshot: HANDLE, lpte: LPTHREADENTRY32) -> BOOL; pub fn TlsAlloc() -> DWORD; pub fn TlsFree(dwTlsIndex: DWORD) -> BOOL; pub fn TlsGetValue(dwTlsIndex: DWORD) -> LPVOID; pub fn TlsSetValue(dwTlsIndex: DWORD, lpTlsValue: LPVOID) -> BOOL; pub fn Toolhelp32ReadProcessMemory(th32ProcessID: DWORD, lpBaseAddress: LPCVOID, lpBuffer: LPVOID, cbRead: SIZE_T, lpNumberOfBytesRead: *mut SIZE_T ) -> BOOL; pub fn TransactNamedPipe( hNamedPipe: HANDLE, lpInBuffer: LPVOID, nInBufferSize: DWORD, lpOutBuffer: LPVOID, nOutBufferSize: DWORD, lpBytesRead: LPDWORD, lpOverlapped: LPOVERLAPPED, ) -> BOOL; pub fn TransmitCommChar(hFile: HANDLE, cChar: c_char) -> BOOL; pub fn TryAcquireSRWLockExclusive(SRWLock: PSRWLOCK) -> BOOLEAN; pub fn TryAcquireSRWLockShared(SRWLock: PSRWLOCK) -> BOOLEAN; pub fn TryEnterCriticalSection(lpCriticalSection: LPCRITICAL_SECTION) -> BOOL; pub fn TrySubmitThreadpoolCallback( pfns: PTP_SIMPLE_CALLBACK, pv: PVOID, pcbe: PTP_CALLBACK_ENVIRON, ) -> BOOL; pub fn TzSpecificLocalTimeToSystemTime( lpTimeZoneInformation: *const TIME_ZONE_INFORMATION, lpLocalTime: *const SYSTEMTIME, lpUniversalTime: LPSYSTEMTIME, ) -> BOOL; pub fn TzSpecificLocalTimeToSystemTimeEx( lpTimeZoneInformation: *const DYNAMIC_TIME_ZONE_INFORMATION, lpLocalTime: *const SYSTEMTIME, lpUniversalTime: LPSYSTEMTIME, ) -> BOOL; #[cfg(target_arch = "x86_64")] pub fn UmsThreadYield(SchedulerParam: PVOID) -> BOOL; pub fn UnhandledExceptionFilter(ExceptionInfo: *mut EXCEPTION_POINTERS) -> LONG; pub fn UnlockFile( hFile: HANDLE, dwFileOffsetLow: DWORD, dwFileOffsetHigh: DWORD, nNumberOfBytesToUnlockLow: DWORD, nNumberOfBytesToUnlockHigh: DWORD, ) -> BOOL; pub fn UnlockFileEx( hFile: HANDLE, dwReserved: DWORD, nNumberOfBytesToUnlockLow: DWORD, nNumberOfBytesToUnlockHigh: DWORD, lpOverlapped: LPOVERLAPPED, ) -> BOOL; pub fn UnmapViewOfFile(lpBaseAddress: LPCVOID) -> BOOL; pub fn UnregisterApplicationRecoveryCallback() -> HRESULT; pub fn UnregisterApplicationRestart() -> HRESULT; pub fn UnregisterBadMemoryNotification(RegistrationHandle: PVOID) -> BOOL; pub fn UnregisterWait(WaitHandle: HANDLE) -> BOOL; pub fn UnregisterWaitEx(WaitHandle: HANDLE, CompletionEvent: HANDLE) -> BOOL; // pub fn UnregisterWaitUntilOOBECompleted(); pub fn UpdateProcThreadAttribute( lpAttributeList: LPPROC_THREAD_ATTRIBUTE_LIST, dwFlags: DWORD, Attribute: DWORD_PTR, lpValue: PVOID, cbSize: SIZE_T, lpPreviousValue: PVOID, lpReturnSize: PSIZE_T, ) -> BOOL; pub fn UpdateResourceA( hUpdate: HANDLE, lpType: LPCSTR, lpName: LPCSTR, wLanguage: WORD, lpData: LPVOID, cb: DWORD, ) -> BOOL; pub fn UpdateResourceW( hUpdate: HANDLE, lpType: LPCWSTR, lpName: LPCWSTR, wLanguage: WORD, lpData: LPVOID, cb: DWORD, ) -> BOOL; pub fn VerLanguageNameA(wLang: DWORD, szLang: LPSTR, cchLang: DWORD) -> DWORD; pub fn VerLanguageNameW(wLang: DWORD, szLang: LPWSTR, cchLang: DWORD) -> DWORD; pub fn VerSetConditionMask( ConditionMask: ULONGLONG, TypeMask: DWORD, Condition: BYTE, ) -> ULONGLONG; pub fn VerifyScripts( dwFlags: DWORD, lpLocaleScripts: LPCWSTR, cchLocaleScripts: c_int, lpTestScripts: LPCWSTR, cchTestScripts: c_int, ) -> BOOL; pub fn VerifyVersionInfoA( lpVersionInformation: LPOSVERSIONINFOEXA, dwTypeMask: DWORD, dwlConditionMask: DWORDLONG, ) -> BOOL; pub fn VerifyVersionInfoW( lpVersionInformation: LPOSVERSIONINFOEXW, dwTypeMask: DWORD, dwlConditionMask: DWORDLONG, ) -> BOOL; pub fn VirtualAlloc( lpAddress: LPVOID, dwSize: SIZE_T, flAllocationType: DWORD, flProtect: DWORD, ) -> LPVOID; pub fn VirtualAllocEx( hProcess: HANDLE, lpAddress: LPVOID, dwSize: SIZE_T, flAllocationType: DWORD, flProtect: DWORD, ) -> LPVOID; pub fn VirtualAllocExNuma( hProcess: HANDLE, lpAddress: LPVOID, dwSize: SIZE_T, flAllocationType: DWORD, flProtect: DWORD, nndPreferred: DWORD, ) -> LPVOID; pub fn VirtualFree(lpAddress: LPVOID, dwSize: SIZE_T, dwFreeType: DWORD) -> BOOL; pub fn VirtualFreeEx( hProcess: HANDLE, lpAddress: LPVOID, dwSize: SIZE_T, dwFreeType: DWORD, ) -> BOOL; pub fn VirtualLock(lpAddress: LPVOID, dwSize: SIZE_T) -> BOOL; pub fn VirtualProtect( lpAddress: LPVOID, dwSize: SIZE_T, flNewProtect: DWORD, lpflOldProtect: DWORD, ) -> BOOL; pub fn VirtualProtectEx( hProcess: HANDLE, lpAddress: LPVOID, dwSize: SIZE_T, flNewProtect: DWORD, lpflOldProtect: DWORD, ) -> BOOL; pub fn VirtualQuery( lpAddress: LPCVOID, lpBuffer: PMEMORY_BASIC_INFORMATION, dwLength: SIZE_T, ) -> SIZE_T; pub fn VirtualQueryEx( hProcess: HANDLE, lpAddress: LPCVOID, lpBuffer: PMEMORY_BASIC_INFORMATION, dwLength: SIZE_T, ) -> SIZE_T; pub fn VirtualUnlock(lpAddress: LPVOID, dwSize: SIZE_T) -> BOOL; pub fn WTSGetActiveConsoleSessionId() -> DWORD; pub fn WaitCommEvent(hFile: HANDLE, lpEvtMask: LPDWORD, lpOverlapped: LPOVERLAPPED) -> BOOL; pub fn WaitForDebugEvent(lpDebugEvent: LPDEBUG_EVENT, dwMilliseconds: DWORD) -> BOOL; pub fn WaitForMultipleObjects( nCount: DWORD, lpHandles: *const HANDLE, bWaitAll: BOOL, dwMilliseconds: DWORD, ) -> DWORD; pub fn WaitForMultipleObjectsEx( nCount: DWORD, lpHandles: *const HANDLE, bWaitAll: BOOL, dwMilliseconds: DWORD, bAlertable: BOOL, ) -> DWORD; pub fn WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: DWORD) -> DWORD; pub fn WaitForSingleObjectEx( hHandle: HANDLE, dwMilliseconds: DWORD, bAlertable: BOOL, ) -> DWORD; pub fn WaitForThreadpoolIoCallbacks(pio: PTP_IO, fCancelPendingCallbacks: BOOL); pub fn WaitForThreadpoolTimerCallbacks(pti: PTP_TIMER, fCancelPendingCallbacks: BOOL); pub fn WaitForThreadpoolWaitCallbacks(pwa: PTP_WAIT, fCancelPendingCallbacks: BOOL); pub fn WaitForThreadpoolWorkCallbacks(pwk: PTP_WORK, fCancelPendingCallbacks: BOOL); pub fn WaitNamedPipeA(lpNamedPipeName: LPCSTR, nTimeOut: DWORD) -> BOOL; pub fn WaitNamedPipeW(lpNamedPipeName: LPCWSTR, nTimeOut: DWORD) -> BOOL; pub fn WakeAllConditionVariable(ConditionVariable: PCONDITION_VARIABLE); pub fn WakeConditionVariable(ConditionVariable: PCONDITION_VARIABLE); pub fn WerGetFlags(hProcess: HANDLE, pdwFlags: PDWORD) -> HRESULT; pub fn WerRegisterFile( pwzFile: PCWSTR, regFileType: WER_REGISTER_FILE_TYPE, dwFlags: DWORD, ) -> HRESULT; pub fn WerRegisterMemoryBlock(pvAddress: PVOID, dwSize: DWORD) -> HRESULT; pub fn WerRegisterRuntimeExceptionModule( pwszOutOfProcessCallbackDll: PCWSTR, pContext: PVOID, ) -> HRESULT; pub fn WerSetFlags(dwFlags: DWORD) -> HRESULT; pub fn WerUnregisterFile(pwzFilePath: PCWSTR) -> HRESULT; pub fn WerUnregisterMemoryBlock(pvAddress: PVOID) -> HRESULT; pub fn WerUnregisterRuntimeExceptionModule( pwszOutOfProcessCallbackDll: PCWSTR, pContext: PVOID, ) -> HRESULT; // pub fn WerpInitiateRemoteRecovery(); pub fn WideCharToMultiByte( CodePage: UINT, dwFlags: DWORD, lpWideCharStr: LPCWCH, cchWideChar: c_int, lpMultiByteStr: LPSTR, cbMultiByte: c_int, lpDefaultChar: LPCCH, lpUsedDefaultChar: LPBOOL, ) -> c_int; pub fn WinExec(lpCmdLine: LPCSTR, uCmdShow: UINT) -> UINT; pub fn Wow64DisableWow64FsRedirection(OldValue: *mut PVOID) -> BOOL; pub fn Wow64EnableWow64FsRedirection(Wow64FsEnableRedirection: BOOLEAN) -> BOOLEAN; pub fn Wow64GetThreadContext(hThread: HANDLE, lpContext: PWOW64_CONTEXT) -> BOOL; pub fn Wow64GetThreadSelectorEntry( hThread: HANDLE, dwSelector: DWORD, lpSelectorEntry: PWOW64_LDT_ENTRY, ) -> BOOL; pub fn Wow64RevertWow64FsRedirection(OlValue: PVOID) -> BOOL; pub fn Wow64SetThreadContext(hThread: HANDLE, lpContext: *const WOW64_CONTEXT) -> BOOL; pub fn Wow64SuspendThread(hThread: HANDLE) -> DWORD; pub fn WriteConsoleA( hConsoleOutput: HANDLE, lpBuffer: *const VOID, nNumberOfCharsToWrite: DWORD, lpNumberOfCharsWritten: LPDWORD, lpReserved: LPVOID, ) -> BOOL; pub fn WriteConsoleInputA( hConsoleInput: HANDLE, lpBuffer: *const INPUT_RECORD, nLength: DWORD, lpNumberOfEventsWritten: LPDWORD, ) -> BOOL; pub fn WriteConsoleInputW( hConsoleInput: HANDLE, lpBuffer: *const INPUT_RECORD, nLength: DWORD, lpNumberOfEventsWritten: LPDWORD, ) -> BOOL; pub fn WriteConsoleOutputA( hConsoleOutput: HANDLE, lpBuffer: *const CHAR_INFO, dwBufferSize: COORD, dwBufferCoord: COORD, lpWriteRegion: PSMALL_RECT, ) -> BOOL; pub fn WriteConsoleOutputAttribute( hConsoleOutput: HANDLE, lpAttribute: *const WORD, nLength: DWORD, dwWriteCoord: COORD, lpNumberOfAttrsWritten: LPDWORD, ) -> BOOL; pub fn WriteConsoleOutputCharacterA( hConsoleOutput: HANDLE, lpCharacter: LPCSTR, nLength: DWORD, dwWriteCoord: COORD, lpNumberOfCharsWritten: LPDWORD, ) -> BOOL; pub fn WriteConsoleOutputCharacterW( hConsoleOutput: HANDLE, lpCharacter: LPCWSTR, nLength: DWORD, dwWriteCoord: COORD, lpNumberOfCharsWritten: LPDWORD, ) -> BOOL; pub fn WriteConsoleOutputW( hConsoleOutput: HANDLE, lpBuffer: *const CHAR_INFO, dwBufferSize: COORD, dwBufferCoord: COORD, lpWriteRegion: PSMALL_RECT, ) -> BOOL; pub fn WriteConsoleW( hConsoleOutput: HANDLE, lpBuffer: *const VOID, nNumberOfCharsToWrite: DWORD, lpNumberOfCharsWritten: LPDWORD, lpReserved: LPVOID, ) -> BOOL; pub fn WriteFile( hFile: HANDLE, lpBuffer: LPCVOID, nNumberOfBytesToWrite: DWORD, lpNumberOfBytesWritten: LPDWORD, lpOverlapped: LPOVERLAPPED, ) -> BOOL; pub fn WriteFileEx( hFile: HANDLE, lpBuffer: LPCVOID, nNumberOfBytesToWrite: DWORD, lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE, ) -> BOOL; pub fn WriteFileGather( hFile: HANDLE, aSegmentArray: *mut FILE_SEGMENT_ELEMENT, nNumberOfBytesToWrite: DWORD, lpReserved: LPDWORD, lpOverlapped: LPOVERLAPPED, ) -> BOOL; pub fn WritePrivateProfileSectionA( lpAppName: LPCSTR, lpString: LPCSTR, lpFileName: LPCSTR, ) -> BOOL; pub fn WritePrivateProfileSectionW( lpAppName: LPCWSTR, lpString: LPCWSTR, lpFileName: LPCWSTR, ) -> BOOL; pub fn WritePrivateProfileStringA( lpAppName: LPCSTR, lpKeyName: LPCSTR, lpString: LPCSTR, lpFileName: LPCSTR, ) -> BOOL; pub fn WritePrivateProfileStringW( lpAppName: LPCWSTR, lpKeyName: LPCWSTR, lpString: LPCWSTR, lpFileName: LPCWSTR, ) -> BOOL; pub fn WritePrivateProfileStructA( lpszSection: LPCSTR, lpszKey: LPCSTR, lpStruct: LPVOID, uSizeStruct: UINT, szFile: LPCSTR, ) -> BOOL; pub fn WritePrivateProfileStructW( lpszSection: LPCWSTR, lpszKey: LPCWSTR, lpStruct: LPVOID, uSizeStruct: UINT, szFile: LPCWSTR, ) -> BOOL; pub fn WriteProcessMemory( hProcess: HANDLE, lpBaseAddress: LPVOID, lpBuffer: LPCVOID, nSize: SIZE_T, lpNumberOfBytesWritten: *mut SIZE_T, ) -> BOOL; pub fn WriteProfileSectionA(lpAppName: LPCSTR, lpString: LPCSTR) -> BOOL; pub fn WriteProfileSectionW(lpAppName: LPCWSTR, lpString: LPCWSTR) -> BOOL; pub fn WriteProfileStringA(lpAppName: LPCSTR, lpKeyName: LPCSTR, lpString: LPCSTR) -> BOOL; pub fn WriteProfileStringW(lpAppName: LPCWSTR, lpKeyName: LPCWSTR, lpString: LPCWSTR) -> BOOL; pub fn WriteTapemark( hDevice: HANDLE, dwTapemarkType: DWORD, dwTapemarkCount: DWORD, bImmediate: BOOL, ) -> DWORD; pub fn ZombifyActCtx(hActCtx: HANDLE) -> BOOL; pub fn _hread(hFile: HFILE, lpBuffer: LPVOID, lBytes: c_long) -> c_long; pub fn _hwrite(hFile: HFILE, lpBuffer: LPCCH, lBytes: c_long) -> c_long; pub fn _lclose(hFile: HFILE) -> HFILE; pub fn _lcreat(lpPathName: LPCSTR, iAttrubute: c_int) -> HFILE; pub fn _llseek(hFile: HFILE, lOffset: LONG, iOrigin: c_int) -> LONG; pub fn _lopen(lpPathName: LPCSTR, iReadWrite: c_int) -> HFILE; pub fn _lread(hFile: HFILE, lpBuffer: LPVOID, uBytes: UINT) -> UINT; pub fn _lwrite(hFile: HFILE, lpBuffer: LPCCH, uBytes: UINT) -> UINT; pub fn lstrcat(lpString1: LPSTR, lpString2: LPCSTR) -> LPSTR; pub fn lstrcatA(lpString1: LPSTR, lpString2: LPCSTR) -> LPSTR; pub fn lstrcatW(lpString1: LPWSTR, lpString2: LPCWSTR) -> LPSTR; pub fn lstrcmp(lpString1: LPCSTR, lpString2: LPCSTR) -> c_int; pub fn lstrcmpA(lpString1: LPCSTR, lpString2: LPCSTR) -> c_int; pub fn lstrcmpW(lpString1: LPCWSTR, lpString2: LPCWSTR) -> c_int; pub fn lstrcmpi(lpString1: LPCSTR, lpString2: LPCSTR) -> c_int; pub fn lstrcmpiA(lpString1: LPCSTR, lpString2: LPCSTR) -> c_int; pub fn lstrcmpiW(lpString1: LPCWSTR, lpString2: LPCWSTR) -> c_int; pub fn lstrcpy(lpString1: LPSTR, lpString2: LPCSTR) -> LPSTR; pub fn lstrcpyA(lpString1: LPSTR, lpString2: LPCSTR) -> LPSTR; pub fn lstrcpyW(lpString1: LPWSTR, lpString2: LPCWSTR) -> LPSTR; pub fn lstrcpyn(lpString1: LPSTR, lpString2: LPCSTR, iMaxLength: c_int) -> LPSTR; pub fn lstrcpynA(lpString1: LPSTR, lpString2: LPCSTR, iMaxLength: c_int) -> LPSTR; pub fn lstrcpynW(lpString1: LPWSTR, lpString2: LPCWSTR, iMaxLength: c_int) -> LPSTR; pub fn lstrlen(lpString: LPCSTR) -> c_int; pub fn lstrlenA(lpString: LPCSTR) -> c_int; pub fn lstrlenW(lpString: LPCWSTR) -> c_int; #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] pub fn uaw_lstrcmpW(String1: PCUWSTR, String2: PCUWSTR) -> c_int; #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] pub fn uaw_lstrcmpiW(String1: PCUWSTR, String2: PCUWSTR) -> c_int; #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] pub fn uaw_lstrlenW(String: LPCUWSTR) -> c_int; #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] pub fn uaw_wcschr(String: PCUWSTR, Character: WCHAR) -> PUWSTR; #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] pub fn uaw_wcscpy(Destination: PUWSTR, Source: PCUWSTR) -> PUWSTR; #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] pub fn uaw_wcsicmp(String1: PCUWSTR, String2: PCUWSTR) -> c_int; #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] pub fn uaw_wcslen(String: PCUWSTR) -> size_t; #[cfg(any(target_arch = "arm", target_arch = "x86_64"))] pub fn uaw_wcsrchr(String: PCUWSTR, Character: WCHAR) -> PUWSTR; } deps/kernel32-sys-0.2.1/Cargo.toml0000644000000000000000000000112112620162316015326 0ustar rootroot[package] name = "kernel32-sys" version = "0.2.1" authors = ["Peter Atashian "] description = "Contains function definitions for the Windows API library kernel32. See winapi for types and constants." documentation = "https://retep998.github.io/doc/kernel32/" repository = "https://github.com/retep998/winapi-rs" readme = "README.md" keywords = ["windows", "ffi", "win32"] license = "MIT" build = "build.rs" [lib] name = "kernel32" [dependencies] winapi = { version = "0.2.4", path = "../.." } [build-dependencies] winapi-build = { version = "0.1.1", path = "../../build" } deps/kernel32-sys-0.2.1/build.rs0000644000000000000000000000023112620161461015044 0ustar rootroot// Copyright © 2015, Peter Atashian // Licensed under the MIT License extern crate build; fn main() { build::link("kernel32", false) } deps/aho-corasick-0.4.0/0000755000000000000000000000000012666635521013523 5ustar rootrootdeps/aho-corasick-0.4.0/UNLICENSE0000644000175000001440000000227312313146471014265 0ustar usersThis is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to deps/aho-corasick-0.4.0/LICENSE-MIT0000644000175000001440000000207112513562722014450 0ustar usersThe MIT License (MIT) Copyright (c) 2015 Andrew Gallant Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/aho-corasick-0.4.0/ctags.rust0000644000175000001440000000160612401211127015021 0ustar users--langdef=Rust --langmap=Rust:.rs --regex-Rust=/^[ \t]*(#\[[^\]]\][ \t]*)*(pub[ \t]+)?(extern[ \t]+)?("[^"]+"[ \t]+)?(unsafe[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\6/f,functions,function definitions/ --regex-Rust=/^[ \t]*(pub[ \t]+)?type[ \t]+([a-zA-Z0-9_]+)/\2/T,types,type definitions/ --regex-Rust=/^[ \t]*(pub[ \t]+)?enum[ \t]+([a-zA-Z0-9_]+)/\2/g,enum,enumeration names/ --regex-Rust=/^[ \t]*(pub[ \t]+)?struct[ \t]+([a-zA-Z0-9_]+)/\2/s,structure names/ --regex-Rust=/^[ \t]*(pub[ \t]+)?mod[ \t]+([a-zA-Z0-9_]+)/\2/m,modules,module names/ --regex-Rust=/^[ \t]*(pub[ \t]+)?static[ \t]+([a-zA-Z0-9_]+)/\2/c,consts,static constants/ --regex-Rust=/^[ \t]*(pub[ \t]+)?trait[ \t]+([a-zA-Z0-9_]+)/\2/t,traits,traits/ --regex-Rust=/^[ \t]*(pub[ \t]+)?impl([ \t\n]+<.*>)?[ \t]+([a-zA-Z0-9_]+)/\3/i,impls,trait implementations/ --regex-Rust=/^[ \t]*macro_rules![ \t]+([a-zA-Z0-9_]+)/\1/d,macros,macro definitions/ deps/aho-corasick-0.4.0/examples/0000755000000000000000000000000012666635521015341 5ustar rootrootdeps/aho-corasick-0.4.0/examples/dict-search.rs0000644000175000001440000000510112551303034017352 0ustar users// This example demonstrates how to use the Aho-Corasick algorithm to rapidly // scan text for matches in a large dictionary of keywords. This example by // default reads your system's dictionary (~120,000 words). extern crate aho_corasick; extern crate csv; extern crate docopt; extern crate rustc_serialize; use std::error::Error; use std::fs::File; use std::io::{self, BufRead, Write}; use std::process; use aho_corasick::{Automaton, AcAutomaton, Match}; use docopt::Docopt; static USAGE: &'static str = " Usage: dict-search [options] dict-search --help Options: -d , --dict Path to dictionary of keywords to search. [default: /usr/share/dict/words] -m , --min-len The minimum length for a keyword in UTF-8 encoded bytes. [default: 5] --overlapping Report overlapping matches. -h, --help Show this usage message. "; #[derive(Clone, Debug, RustcDecodable)] struct Args { arg_input: String, flag_dict: String, flag_min_len: usize, flag_overlapping: bool, } fn main() { let args: Args = Docopt::new(USAGE) .and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); match run(&args) { Ok(()) => {} Err(err) => { writeln!(&mut io::stderr(), "{}", err).unwrap(); process::exit(1); } } } fn run(args: &Args) -> Result<(), Box> { let aut = try!(build_automaton(&args.flag_dict, args.flag_min_len)); let rdr = try!(File::open(&args.arg_input)); if args.flag_overlapping { try!(write_matches(&aut, aut.stream_find_overlapping(rdr))); } else { try!(write_matches(&aut, aut.stream_find(rdr))); } Ok(()) } fn write_matches(aut: &A, it: I) -> Result<(), Box> where A: Automaton, I: Iterator> { let mut wtr = csv::Writer::from_writer(io::stdout()); try!(wtr.encode(("pattern", "start", "end"))); for m in it { let m = try!(m); try!(wtr.encode((aut.pattern(m.pati), m.start, m.end))); } try!(wtr.flush()); Ok(()) } fn build_automaton( dict_path: &str, min_len: usize, ) -> Result, Box> { let buf = io::BufReader::new(try!(File::open(dict_path))); let mut lines = Vec::with_capacity(1 << 10); for line in buf.lines() { let line = try!(line); if line.len() >= min_len { lines.push(line); } } Ok(AcAutomaton::new(lines)) } deps/aho-corasick-0.4.0/.travis.yml0000644000175000001440000000032512536413700015121 0ustar userslanguage: rust rust: - 1.0.0 - beta - nightly script: - cargo build --verbose - cargo test --verbose - cargo doc - if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then cargo bench --verbose; fi deps/aho-corasick-0.4.0/README.md0000644000175000001440000000356012541171255014275 0ustar usersThis crate provides an implementation of the [Aho-Corasick](http://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_string_matching_algorithm) algorithm. Its intended use case is for fast substring matching, particularly when matching multiple substrings in a search text. This is achieved by compiling the substrings into a finite state machine. This implementation provides optimal algorithmic time complexity. Construction of the finite state machine is `O(p)` where `p` is the length of the substrings concatenated. Matching against search text is `O(n + p + m)`, where `n` is the length of the search text and `m` is the number of matches. [![Build status](https://api.travis-ci.org/BurntSushi/aho-corasick.png)](https://travis-ci.org/BurntSushi/aho-corasick) [![](http://meritbadge.herokuapp.com/aho-corasick)](https://crates.io/crates/aho-corasick) Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). ### Documentation [http://burntsushi.net/rustdoc/aho_corasick/](http://burntsushi.net/rustdoc/aho_corasick/). ### Example The documentation contains several examples, and there is a more complete example as a full program in `examples/dict-search.rs`. Here is a quick example showing simple substring matching: ```rust use aho_corasick::{Automaton, AcAutomaton, Match}; let aut = AcAutomaton::new(vec!["apple", "maple"]); let mut it = aut.find("I like maple apples."); assert_eq!(it.next(), Some(Match { pati: 1, start: 7, end: 12, })); assert_eq!(it.next(), Some(Match { pati: 0, start: 13, end: 18, })); assert_eq!(it.next(), None); ``` ### Alternatives Aho-Corasick is useful for matching multiple substrings against many long strings. If your long string is fixed, then you might consider building a [suffix array](https://github.com/BurntSushi/suffix) of the search text (which takes `O(n)` time). Matches can then be found in `O(plogn)` time. deps/aho-corasick-0.4.0/.gitignore0000644000175000001440000000013012510106554014770 0ustar users.*.swp doc tags examples/ss10pusa.csv build target Cargo.lock scratch* bench_large/huge deps/aho-corasick-0.4.0/src/0000755000000000000000000000000012666635521014312 5ustar rootrootdeps/aho-corasick-0.4.0/src/autiter.rs0000644000175000001440000002776212611775462015652 0ustar usersuse std::io::{self, BufRead, Read}; use std::marker::PhantomData; use super::{ROOT_STATE, PatIdx, StateIdx}; /// An abstraction over automatons and their corresponding iterators. /// The type parameter `P` is the type of the pattern that was used to /// construct this Automaton. pub trait Automaton

    { /// Return the next state given the current state and next character. fn next_state(&self, si: StateIdx, b: u8) -> StateIdx; /// Return true if and only if the given state and current pattern index /// indicate a match. fn has_match(&self, si: StateIdx, outi: PatIdx) -> bool; /// Build a match given the current state, pattern index and input index. fn get_match(&self, si: StateIdx, outi: PatIdx, texti: usize) -> Match; /// Attempt to skip through the input. /// /// This returns the index into `text` at which the next match attempt /// should start. (If no skipping occurred, then the return value should /// be equal to `at`.) /// /// Finally, if no match is possible, then return `text.len()`. fn skip_to(&self, si: StateIdx, text: &[u8], at: usize) -> usize; /// Returns true if and only if this automaton can skip through the input. fn is_skippable(&self) -> bool; /// Returns all of the patterns matched by this automaton. /// /// The order of the patterns is the order in which they were added. fn patterns(&self) -> &[P]; /// Returns the pattern indexed at `i`. /// /// The index corresponds to the position at which the pattern was added /// to the automaton, starting at `0`. fn pattern(&self, i: usize) -> &P; /// Return the number of patterns in the automaton. #[inline] fn len(&self) -> usize { self.patterns().len() } /// Returns true if the automaton has no patterns. #[inline] fn is_empty(&self) -> bool { self.len() == 0 } /// Returns an iterator of non-overlapping matches in `s`. fn find<'a, 's, Q: ?Sized + AsRef<[u8]>>( &'a self, s: &'s Q, ) -> Matches<'a, 's, P, Self> where Self: Sized { Matches { aut: self, text: s.as_ref(), texti: 0, si: ROOT_STATE, _m: PhantomData, } } /// Returns an iterator of overlapping matches in `s`. fn find_overlapping<'a, 's, Q: ?Sized + AsRef<[u8]>>( &'a self, s: &'s Q, ) -> MatchesOverlapping<'a, 's, P, Self> where Self: Sized { MatchesOverlapping { aut: self, text: s.as_ref(), texti: 0, si: ROOT_STATE, outi: 0, _m: PhantomData, } } /// Returns an iterator of non-overlapping matches in the given reader. fn stream_find<'a, R: io::Read>( &'a self, rdr: R, ) -> StreamMatches<'a, R, P, Self> where Self: Sized { StreamMatches { aut: self, buf: io::BufReader::new(rdr), texti: 0, si: ROOT_STATE, _m: PhantomData, } } /// Returns an iterator of overlapping matches in the given reader. fn stream_find_overlapping<'a, R: io::Read>( &'a self, rdr: R, ) -> StreamMatchesOverlapping<'a, R, P, Self> where Self: Sized { StreamMatchesOverlapping { aut: self, buf: io::BufReader::new(rdr), texti: 0, si: ROOT_STATE, outi: 0, _m: PhantomData, } } } impl<'a, P: AsRef<[u8]>, A: 'a + Automaton

    + ?Sized> Automaton

    for &'a A { fn next_state(&self, si: StateIdx, b: u8) -> StateIdx { (**self).next_state(si, b) } fn has_match(&self, si: StateIdx, outi: PatIdx) -> bool { (**self).has_match(si, outi) } fn skip_to(&self, si: StateIdx, text: &[u8], at: usize) -> usize { (**self).skip_to(si, text, at) } fn is_skippable(&self) -> bool { (**self).is_skippable() } fn patterns(&self) -> &[P] { (**self).patterns() } fn pattern(&self, i: usize) -> &P { (**self).pattern(i) } fn get_match(&self, si: StateIdx, outi: PatIdx, texti: usize) -> Match { (**self).get_match(si, outi, texti) } } /// Records a match in the search text. #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] pub struct Match { /// The pattern index. /// /// This corresponds to the ordering in which the matched pattern was /// added to the automaton, starting at `0`. pub pati: usize, /// The starting byte offset of the match in the search text. pub start: usize, /// The ending byte offset of the match in the search text. /// /// (This can be re-captiulated with `pati` and adding the pattern's /// length to `start`, but it is convenient to have it here.) pub end: usize, } /// An iterator of non-overlapping matches for in-memory text. /// /// This iterator yields `Match` values. /// /// `'a` is the lifetime of the automaton, `'s` is the lifetime of the /// search text, and `P` is the type of the Automaton's pattern. #[derive(Debug)] pub struct Matches<'a, 's, P, A: 'a + Automaton

    + ?Sized> { aut: &'a A, text: &'s [u8], texti: usize, si: StateIdx, _m: PhantomData

    , } // When there's an initial lone start byte, it is usually worth it // to use `memchr` to skip along the input. The problem is that // the skipping function is called in the inner match loop, which // can be quite costly if the skipping condition is never met. // Therefore, we lift the case analysis outside of the inner loop at // the cost of repeating code. // // `step_to_match` is the version of the inner loop without skipping, // and `skip_to_match` is the version with skipping. fn step_to_match + ?Sized>( aut: &A, text: &[u8], mut texti: usize, mut si: StateIdx ) -> Option<(usize, StateIdx)> { while texti < text.len() { si = aut.next_state(si, text[texti]); if aut.has_match(si, 0) { return Some((texti, si)); } texti += 1; } None } fn skip_to_match + ?Sized>( aut: &A, text: &[u8], mut texti: usize, mut si: StateIdx ) -> Option<(usize, StateIdx)> { texti = aut.skip_to(si, text, texti); while texti < text.len() { si = aut.next_state(si, text[texti]); if aut.has_match(si, 0) { return Some((texti, si)); } texti = aut.skip_to(si, text, texti + 1); } None } impl<'a, 's, P, A: Automaton

    + ?Sized> Iterator for Matches<'a, 's, P, A> { type Item = Match; fn next(&mut self) -> Option { if self.aut.is_skippable() { if let Some((texti, si)) = skip_to_match(self.aut, self.text, self.texti, self.si) { self.texti = texti + 1; self.si = ROOT_STATE; return Some(self.aut.get_match(si, 0, texti)); } } else { if let Some((texti, si)) = step_to_match(self.aut, self.text, self.texti, self.si) { self.texti = texti + 1; self.si = ROOT_STATE; return Some(self.aut.get_match(si, 0, texti)); } } None } } /// An iterator of non-overlapping matches for streaming text. /// /// This iterator yields `io::Result` values. /// /// `'a` is the lifetime of the automaton, `R` is the type of the underlying /// `io::Read`er, and P is the type of the Automaton's pattern. #[derive(Debug)] pub struct StreamMatches<'a, R, P, A: 'a + Automaton

    + ?Sized> { aut: &'a A, buf: io::BufReader, texti: usize, si: StateIdx, _m: PhantomData

    , } impl<'a, R: io::Read, P, A: Automaton

    > Iterator for StreamMatches<'a, R, P, A> { type Item = io::Result; fn next(&mut self) -> Option> { let mut m = None; let mut consumed = 0; 'LOOP: loop { self.buf.consume(consumed); let bs = match self.buf.fill_buf() { Err(err) => return Some(Err(err)), Ok(bs) if bs.len() == 0 => break, Ok(bs) => bs, }; consumed = bs.len(); // is shortened if we find a match for (i, &b) in bs.iter().enumerate() { self.si = self.aut.next_state(self.si, b); if self.aut.has_match(self.si, 0) { m = Some(Ok(self.aut.get_match(self.si, 0, self.texti))); consumed = i + 1; self.texti += 1; self.si = ROOT_STATE; break 'LOOP; } self.texti += 1; } } self.buf.consume(consumed); m } } /// An iterator of overlapping matches for in-memory text. /// /// This iterator yields `Match` values. /// /// `'a` is the lifetime of the automaton, `'s` is the lifetime of the /// search text, and `P` is the type of the Automaton's pattern. #[derive(Debug)] pub struct MatchesOverlapping<'a, 's, P, A: 'a + Automaton

    + ?Sized> { aut: &'a A, text: &'s [u8], texti: usize, si: StateIdx, outi: usize, _m: PhantomData

    , } impl<'a, 's, P, A: Automaton

    + ?Sized> Iterator for MatchesOverlapping<'a, 's, P, A> { type Item = Match; fn next(&mut self) -> Option { if self.aut.has_match(self.si, self.outi) { let m = self.aut.get_match(self.si, self.outi, self.texti); self.outi += 1; if !self.aut.has_match(self.si, self.outi) { self.texti += 1; } return Some(m); } self.outi = 0; if self.aut.is_skippable() { if let Some((texti, si)) = skip_to_match(self.aut, self.text, self.texti, self.si) { self.texti = texti; self.si = si; return self.next(); } } else { if let Some((texti, si)) = step_to_match(self.aut, self.text, self.texti, self.si) { self.texti = texti; self.si = si; return self.next(); } } None } } /// An iterator of overlapping matches for streaming text. /// /// This iterator yields `io::Result` values. /// /// `'a` is the lifetime of the automaton, `R` is the type of the underlying /// `io::Read`er, and P is the type of the Automaton's pattern. #[derive(Debug)] pub struct StreamMatchesOverlapping<'a, R, P, A: 'a + Automaton

    + ?Sized> { aut: &'a A, buf: io::BufReader, texti: usize, si: StateIdx, outi: usize, _m: PhantomData

    , } impl< 'a, R: io::Read, P, A: Automaton

    + ?Sized, > Iterator for StreamMatchesOverlapping<'a, R, P, A> { type Item = io::Result; fn next(&mut self) -> Option> { if self.aut.has_match(self.si, self.outi) { let m = self.aut.get_match(self.si, self.outi, self.texti); self.outi += 1; if !self.aut.has_match(self.si, self.outi) { self.texti += 1; } return Some(Ok(m)); } let mut m = None; let mut consumed = 0; self.outi = 0; 'LOOP: loop { self.buf.consume(consumed); let bs = match self.buf.fill_buf() { Err(err) => return Some(Err(err)), Ok(bs) if bs.len() == 0 => break, Ok(bs) => bs, }; consumed = bs.len(); // is shortened if we find a match for (i, &b) in bs.iter().enumerate() { self.si = self.aut.next_state(self.si, b); if self.aut.has_match(self.si, self.outi) { m = Some(Ok(self.aut.get_match(self.si, self.outi, self.texti))); consumed = i + 1; self.outi += 1; if !self.aut.has_match(self.si, self.outi) { self.texti += 1; } break 'LOOP; } self.texti += 1; } } self.buf.consume(consumed); m } } deps/aho-corasick-0.4.0/src/lib.rs0000644000175000001440000007154612570615343014735 0ustar users/*! An implementation of the [Aho-Corasick string search algorithm](https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_string_matching_algorithm). The Aho-Corasick algorithm is principally useful when you need to search many large texts for a fixed (possibly large) set of keywords. In particular, the Aho-Corasick algorithm preprocesses the set of keywords by constructing a finite state machine. The search phase is then a quick linear scan through the text. Each character in the search text causes a state transition in the automaton. Matches are reported when the automaton enters a match state. # Examples The main type exposed by this crate is `AcAutomaton`, which can be constructed from an iterator of pattern strings: ```rust use aho_corasick::{Automaton, AcAutomaton}; let aut = AcAutomaton::new(vec!["apple", "maple"]); // AcAutomaton also implements `FromIterator`: let aut: AcAutomaton<&str> = ["apple", "maple"].iter().cloned().collect(); ``` Finding matches can be done with `find`: ```rust use aho_corasick::{Automaton, AcAutomaton, Match}; let aut = AcAutomaton::new(vec!["apple", "maple"]); let mut it = aut.find("I like maple apples."); assert_eq!(it.next(), Some(Match { pati: 1, start: 7, end: 12, })); assert_eq!(it.next(), Some(Match { pati: 0, start: 13, end: 18, })); assert_eq!(it.next(), None); ``` Use `find_overlapping` if you want to report all matches, even if they overlap with each other. ```rust use aho_corasick::{Automaton, AcAutomaton, Match}; let aut = AcAutomaton::new(vec!["abc", "a"]); let matches: Vec<_> = aut.find_overlapping("abc").collect(); assert_eq!(matches, vec![ Match { pati: 1, start: 0, end: 1}, Match { pati: 0, start: 0, end: 3 }, ]); // Regular `find` will report only one match: let matches: Vec<_> = aut.find("abc").collect(); assert_eq!(matches, vec![Match { pati: 1, start: 0, end: 1}]); ``` Finally, there are also methods for finding matches on *streams*. Namely, the search text does not have to live in memory. It's useful to run this on files that can't fit into memory: ```no_run use std::fs::File; use aho_corasick::{Automaton, AcAutomaton}; let aut = AcAutomaton::new(vec!["foo", "bar", "baz"]); let rdr = File::open("search.txt").unwrap(); for m in aut.stream_find(rdr) { let m = m.unwrap(); // could be an IO error println!("Pattern '{}' matched at: ({}, {})", aut.pattern(m.pati), m.start, m.end); } ``` There is also `stream_find_overlapping`, which is just like `find_overlapping`, but it operates on streams. Please see `dict-search.rs` in this crate's `examples` directory for a more complete example. It creates a large automaton from a dictionary and can do a streaming match over arbitrarily large data. # Memory usage A key aspect of an Aho-Corasick implementation is how the state transitions are represented. The easiest way to make the automaton fast is to store a sparse 256-slot map in each state. It maps an input byte to a state index. This makes the matching loop extremely fast, since it translates to a simple pointer read. The problem is that as the automaton accumulates more states, you end up paying a `256 * 4` (`4` is for the `u32` state index) byte penalty for every state regardless of how many transitions it has. To solve this, only states near the root of the automaton have this sparse map representation. States near the leaves of the automaton use a dense mapping that requires a linear scan. (The specific limit currently set is `3`, so that states with a depth less than or equal to `3` are less memory efficient. The result is that the memory usage of the automaton stops growing rapidly past ~60MB, even for automatons with thousands of patterns.) If you'd like to opt for the less-memory-efficient-but-faster version, then you can construct an `AcAutomaton` with a `Sparse` transition strategy: ```rust use aho_corasick::{Automaton, AcAutomaton, Match, Sparse}; let aut = AcAutomaton::<&str, Sparse>::with_transitions(vec!["abc", "a"]); let matches: Vec<_> = aut.find("abc").collect(); assert_eq!(matches, vec![Match { pati: 1, start: 0, end: 1}]); ``` */ #![allow(deprecated)] // for connect -> join #![deny(missing_docs)] extern crate memchr; #[cfg(test)] extern crate quickcheck; #[cfg(test)] extern crate rand; use std::collections::VecDeque; use std::fmt; use std::iter::FromIterator; use memchr::memchr; pub use self::autiter::{ Automaton, Match, Matches, MatchesOverlapping, StreamMatches, StreamMatchesOverlapping, }; pub use self::full::FullAcAutomaton; // We're specifying paths explicitly so that we can use // these modules simultaneously from `main.rs`. // Should probably make just make `main.rs` a separate crate. #[path = "autiter.rs"] mod autiter; #[path = "full.rs"] mod full; /// The integer type used for the state index. /// /// Limiting this to 32 bit integers can have a big impact on memory usage /// when using the `Sparse` transition representation. pub type StateIdx = u32; type PatIdx = usize; // Constants for special state indexes. const FAIL_STATE: u32 = 0; const ROOT_STATE: u32 = 1; // Limit the depth at which we use a dense alphabet map. Once the limit is // reached, a sparse set is used (and lookup becomes O(n)). // // This does have a performance hit, but the (straight forward) alternative // is to have a `256 * 4` byte overhead for every state. // Given that Aho-Corasick is typically used for dictionary searching, this // can lead to dramatic memory bloat. // // This limit should only be increased at your peril. Namely, in the worst // case, `256^DENSE_DEPTH_THRESHOLD * 4` corresponds to the memory usage in // bytes. A value of `3` gives us a solid cap at around 64MB, which works // well in practice even for dictionary sized automatons. // // Why not make this user configurable? Well, it doesn't make much sense // because we pay for it with case analysis in the matching loop. Increasing it // doesn't have much impact on performance (outside of pathological cases?). // // There is probably room for adding a new automaton type that doesn't have // this restriction. // // N.B. Someone else seems to have discovered an alternative, but I haven't // grokked it yet: https://github.com/mischasan/aho-corasick const DENSE_DEPTH_THRESHOLD: u32 = 3; /// An Aho-Corasick finite automaton. /// /// The type parameter `P` is the type of the pattern that was used to /// construct this AcAutomaton. #[derive(Clone)] pub struct AcAutomaton { pats: Vec

    , states: Vec>, start_bytes: Vec, } #[derive(Clone)] struct State { out: Vec, fail: StateIdx, goto: T, depth: u32, } impl> AcAutomaton

    { /// Create a new automaton from an iterator of patterns. /// /// The patterns must be convertible to bytes (`&[u8]`) via the `AsRef` /// trait. pub fn new(pats: I) -> AcAutomaton where I: IntoIterator { AcAutomaton::with_transitions(pats) } } impl, T: Transitions> AcAutomaton { /// Create a new automaton from an iterator of patterns. /// /// This constructor allows one to choose the transition representation. /// /// The patterns must be convertible to bytes (`&[u8]`) via the `AsRef` /// trait. pub fn with_transitions(pats: I) -> AcAutomaton where I: IntoIterator { AcAutomaton { pats: vec![], // filled in later, avoid wrath of borrow checker states: vec![State::new(0), State::new(0)], // empty and root start_bytes: vec![], // also filled in later }.build(pats.into_iter().collect()) } /// Build out the entire automaton into a single matrix. /// /// This will make searching as fast as possible at the expense of using /// at least `4 * 256 * #states` bytes of memory. pub fn into_full(self) -> FullAcAutomaton

    { FullAcAutomaton::new(self) } } impl, T: Transitions> Automaton

    for AcAutomaton { #[inline] fn next_state(&self, mut si: StateIdx, b: u8) -> StateIdx { loop { let maybe_si = self.states[si as usize].goto(b); if maybe_si != FAIL_STATE { si = maybe_si; break; } else { si = self.states[si as usize].fail; } } si } #[inline] fn get_match(&self, si: StateIdx, outi: usize, texti: usize) -> Match { let pati = self.states[si as usize].out[outi]; let patlen = self.pats[pati].as_ref().len(); let start = texti + 1 - patlen; Match { pati: pati, start: start, end: start + patlen, } } #[inline] fn has_match(&self, si: StateIdx, outi: usize) -> bool { outi < self.states[si as usize].out.len() } #[inline] fn skip_to(&self, si: StateIdx, text: &[u8], at: usize) -> usize { if si != ROOT_STATE || !self.is_skippable() { return at; } let b = self.start_bytes[0]; match memchr(b, &text[at..]) { None => text.len(), Some(i) => at + i, } } #[inline] fn is_skippable(&self) -> bool { self.start_bytes.len() == 1 } #[inline] fn patterns(&self) -> &[P] { &self.pats } #[inline] fn pattern(&self, i: usize) -> &P { &self.pats[i] } } // Below contains code for *building* the automaton. It's a reasonably faithful // translation of the description/psuedo-code from: // http://www.cs.uku.fi/~kilpelai/BSA05/lectures/slides04.pdf impl, T: Transitions> AcAutomaton { // This is the first phase and builds the initial keyword tree. fn build(mut self, pats: Vec

    ) -> AcAutomaton { for (pati, pat) in pats.iter().enumerate() { if pat.as_ref().is_empty() { continue; } let mut previ = ROOT_STATE; for &b in pat.as_ref() { if self.states[previ as usize].goto(b) != FAIL_STATE { previ = self.states[previ as usize].goto(b); } else { let depth = self.states[previ as usize].depth + 1; let nexti = self.add_state(State::new(depth)); self.states[previ as usize].set_goto(b, nexti); previ = nexti; } } self.states[previ as usize].out.push(pati); } for c in (0..256).into_iter().map(|c| c as u8) { if self.states[ROOT_STATE as usize].goto(c) == FAIL_STATE { self.states[ROOT_STATE as usize].set_goto(c, ROOT_STATE); } else { self.start_bytes.push(c); } } self.pats = pats; self.fill() } // The second phase that fills in the back links. fn fill(mut self) -> AcAutomaton { // Fill up the queue with all non-root transitions out of the root // node. Then proceed by breadth first traversal. let mut q = VecDeque::new(); for c in (0..256).into_iter().map(|c| c as u8) { let si = self.states[ROOT_STATE as usize].goto(c); if si != ROOT_STATE { q.push_front(si); } } while let Some(si) = q.pop_back() { for c in (0..256).into_iter().map(|c| c as u8) { let u = self.states[si as usize].goto(c); if u != FAIL_STATE { q.push_front(u); let mut v = self.states[si as usize].fail; while self.states[v as usize].goto(c) == FAIL_STATE { v = self.states[v as usize].fail; } let ufail = self.states[v as usize].goto(c); self.states[u as usize].fail = ufail; let ufail_out = self.states[ufail as usize].out.clone(); self.states[u as usize].out.extend(ufail_out); } } } self } fn add_state(&mut self, state: State) -> StateIdx { let i = self.states.len(); self.states.push(state); i as StateIdx } } impl State { fn new(depth: u32) -> State { State { out: vec![], fail: 1, goto: Transitions::new(depth), depth: depth, } } fn goto(&self, b: u8) -> StateIdx { self.goto.goto(b) } fn set_goto(&mut self, b: u8, si: StateIdx) { self.goto.set_goto(b, si); } } /// An abstraction over state transition strategies. /// /// This is an attempt to let the caller choose the space/time trade offs /// used for state transitions. /// /// (It's possible that this interface is merely good enough for just the two /// implementations in this crate.) pub trait Transitions { /// Return a new state at the given depth. fn new(depth: u32) -> Self; /// Return the next state index given the next character. fn goto(&self, alpha: u8) -> StateIdx; /// Set the next state index for the character given. fn set_goto(&mut self, alpha: u8, si: StateIdx); } /// State transitions that can be stored either sparsely or densely. /// /// This uses less space but at the expense of slower matching. #[derive(Clone, Debug)] pub struct Dense(DenseChoice); #[derive(Clone, Debug)] enum DenseChoice { Sparse(Vec), // indexed by alphabet Dense(Vec<(u8, StateIdx)>), } impl Transitions for Dense { fn new(depth: u32) -> Dense { if depth <= DENSE_DEPTH_THRESHOLD { Dense(DenseChoice::Sparse(vec![0; 256])) } else { Dense(DenseChoice::Dense(vec![])) } } fn goto(&self, b1: u8) -> StateIdx { match self.0 { DenseChoice::Sparse(ref m) => m[b1 as usize], DenseChoice::Dense(ref m) => { for &(b2, si) in m { if b1 == b2 { return si; } } FAIL_STATE } } } fn set_goto(&mut self, b: u8, si: StateIdx) { match self.0 { DenseChoice::Sparse(ref mut m) => m[b as usize] = si, DenseChoice::Dense(ref mut m) => m.push((b, si)), } } } /// State transitions that are always sparse. /// /// This can use enormous amounts of memory when there are many patterns, /// but matching is very fast. #[derive(Clone, Debug)] pub struct Sparse(Vec); impl Transitions for Sparse { fn new(_: u32) -> Sparse { Sparse(vec![0; 256]) } #[inline] fn goto(&self, b: u8) -> StateIdx { self.0[b as usize] } fn set_goto(&mut self, b: u8, si: StateIdx) { self.0[b as usize] = si; } } impl> FromIterator for AcAutomaton { /// Create an automaton from an iterator of strings. fn from_iter(it: T) -> AcAutomaton where T: IntoIterator { AcAutomaton::new(it) } } // Provide some question debug impls for viewing automatons. // The custom impls mostly exist for special showing of sparse maps. impl + fmt::Debug, T: Transitions> fmt::Debug for AcAutomaton { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use std::iter::repeat; try!(writeln!(f, "{}", repeat('-').take(79).collect::())); try!(writeln!(f, "Patterns: {:?}", self.pats)); for (i, state) in self.states.iter().enumerate().skip(1) { try!(writeln!(f, "{:3}: {}", i, state.debug(i == 1))); } write!(f, "{}", repeat('-').take(79).collect::()) } } impl State { fn debug(&self, root: bool) -> String { format!("State {{ depth: {:?}, out: {:?}, fail: {:?}, goto: {{{}}} }}", self.depth, self.out, self.fail, self.goto_string(root)) } fn goto_string(&self, root: bool) -> String { use std::char::from_u32; let mut goto = vec![]; for b in (0..256).map(|b| b as u8) { let si = self.goto(b); if (!root && si == FAIL_STATE) || (root && si == ROOT_STATE) { continue; } goto.push(format!("{} => {}", from_u32(b as u32).unwrap(), si)); } goto.connect(", ") } } impl fmt::Debug for State { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.debug(false)) } } impl AcAutomaton { #[doc(hidden)] pub fn dot(&self) -> String { use std::fmt::Write; let mut out = String::new(); macro_rules! w { ($w:expr, $($tt:tt)*) => { {write!($w, $($tt)*)}.unwrap() } } w!(out, r#" digraph automaton {{ label=<{}>; labelloc="l"; labeljust="l"; rankdir="LR"; "#, self.pats.connect(", ")); for (i, s) in self.states.iter().enumerate().skip(1) { let i = i as u32; if s.out.len() == 0 { w!(out, " {};\n", i); } else { w!(out, " {} [peripheries=2];\n", i); } w!(out, " {} -> {} [style=dashed];\n", i, s.fail); for b in (0..256).map(|b| b as u8) { let si = s.goto(b); if si == FAIL_STATE || (i == ROOT_STATE && si == ROOT_STATE) { continue; } w!(out, " {} -> {} [label={}];\n", i, si, b as char); } } w!(out, "}}"); out } } #[cfg(test)] mod tests { use std::collections::HashSet; use std::io; use quickcheck::{Arbitrary, Gen, quickcheck}; use rand::Rng; use super::{Automaton, AcAutomaton, Match}; fn aut_find(xs: &[S], haystack: &str) -> Vec where S: Clone + AsRef<[u8]> { AcAutomaton::new(xs.to_vec()).find(&haystack).collect() } fn aut_finds(xs: &[S], haystack: &str) -> Vec where S: Clone + AsRef<[u8]> { let cur = io::Cursor::new(haystack.as_bytes()); AcAutomaton::new(xs.to_vec()) .stream_find(cur).map(|r| r.unwrap()).collect() } fn aut_findf(xs: &[S], haystack: &str) -> Vec where S: Clone + AsRef<[u8]> { AcAutomaton::new(xs.to_vec()).into_full().find(haystack).collect() } fn aut_findfs(xs: &[S], haystack: &str) -> Vec where S: Clone + AsRef<[u8]> { let cur = io::Cursor::new(haystack.as_bytes()); AcAutomaton::new(xs.to_vec()) .into_full() .stream_find(cur).map(|r| r.unwrap()).collect() } fn aut_findo(xs: &[S], haystack: &str) -> Vec where S: Clone + AsRef<[u8]> { AcAutomaton::new(xs.to_vec()).find_overlapping(haystack).collect() } fn aut_findos(xs: &[S], haystack: &str) -> Vec where S: Clone + AsRef<[u8]> { let cur = io::Cursor::new(haystack.as_bytes()); AcAutomaton::new(xs.to_vec()) .stream_find_overlapping(cur).map(|r| r.unwrap()).collect() } fn aut_findfo(xs: &[S], haystack: &str) -> Vec where S: Clone + AsRef<[u8]> { AcAutomaton::new(xs.to_vec()) .into_full().find_overlapping(haystack).collect() } fn aut_findfos(xs: &[S], haystack: &str) -> Vec where S: Clone + AsRef<[u8]> { let cur = io::Cursor::new(haystack.as_bytes()); AcAutomaton::new(xs.to_vec()) .into_full() .stream_find_overlapping(cur).map(|r| r.unwrap()).collect() } #[test] fn one_pattern_one_match() { let ns = vec!["a"]; let hay = "za"; let matches = vec![ Match { pati: 0, start: 1, end: 2 }, ]; assert_eq!(&aut_find(&ns, hay), &matches); assert_eq!(&aut_finds(&ns, hay), &matches); assert_eq!(&aut_findf(&ns, hay), &matches); assert_eq!(&aut_findfs(&ns, hay), &matches); } #[test] fn one_pattern_many_match() { let ns = vec!["a"]; let hay = "zazazzzza"; let matches = vec![ Match { pati: 0, start: 1, end: 2 }, Match { pati: 0, start: 3, end: 4 }, Match { pati: 0, start: 8, end: 9 }, ]; assert_eq!(&aut_find(&ns, hay), &matches); assert_eq!(&aut_finds(&ns, hay), &matches); assert_eq!(&aut_findf(&ns, hay), &matches); assert_eq!(&aut_findfs(&ns, hay), &matches); } #[test] fn one_longer_pattern_one_match() { let ns = vec!["abc"]; let hay = "zazabcz"; let matches = vec![ Match { pati: 0, start: 3, end: 6 } ]; assert_eq!(&aut_find(&ns, hay), &matches); assert_eq!(&aut_finds(&ns, hay), &matches); assert_eq!(&aut_findf(&ns, hay), &matches); assert_eq!(&aut_findfs(&ns, hay), &matches); } #[test] fn one_longer_pattern_many_match() { let ns = vec!["abc"]; let hay = "zazabczzzzazzzabc"; let matches = vec![ Match { pati: 0, start: 3, end: 6 }, Match { pati: 0, start: 14, end: 17 }, ]; assert_eq!(&aut_find(&ns, hay), &matches); assert_eq!(&aut_finds(&ns, hay), &matches); assert_eq!(&aut_findf(&ns, hay), &matches); assert_eq!(&aut_findfs(&ns, hay), &matches); } #[test] fn many_pattern_one_match() { let ns = vec!["a", "b"]; let hay = "zb"; let matches = vec![ Match { pati: 1, start: 1, end: 2 } ]; assert_eq!(&aut_find(&ns, hay), &matches); assert_eq!(&aut_finds(&ns, hay), &matches); assert_eq!(&aut_findf(&ns, hay), &matches); assert_eq!(&aut_findfs(&ns, hay), &matches); } #[test] fn many_pattern_many_match() { let ns = vec!["a", "b"]; let hay = "zbzazzzzb"; let matches = vec![ Match { pati: 1, start: 1, end: 2 }, Match { pati: 0, start: 3, end: 4 }, Match { pati: 1, start: 8, end: 9 }, ]; assert_eq!(&aut_find(&ns, hay), &matches); assert_eq!(&aut_finds(&ns, hay), &matches); assert_eq!(&aut_findf(&ns, hay), &matches); assert_eq!(&aut_findfs(&ns, hay), &matches); } #[test] fn many_longer_pattern_one_match() { let ns = vec!["abc", "xyz"]; let hay = "zazxyzz"; let matches = vec![ Match { pati: 1, start: 3, end: 6 } ]; assert_eq!(&aut_find(&ns, hay), &matches); assert_eq!(&aut_finds(&ns, hay), &matches); assert_eq!(&aut_findf(&ns, hay), &matches); assert_eq!(&aut_findfs(&ns, hay), &matches); } #[test] fn many_longer_pattern_many_match() { let ns = vec!["abc", "xyz"]; let hay = "zazxyzzzzzazzzabcxyz"; let matches = vec![ Match { pati: 1, start: 3, end: 6 }, Match { pati: 0, start: 14, end: 17 }, Match { pati: 1, start: 17, end: 20 }, ]; assert_eq!(&aut_find(&ns, hay), &matches); assert_eq!(&aut_finds(&ns, hay), &matches); assert_eq!(&aut_findf(&ns, hay), &matches); assert_eq!(&aut_findfs(&ns, hay), &matches); } #[test] fn many_longer_pattern_overlap_one_match() { let ns = vec!["abc", "bc"]; let hay = "zazabcz"; let matches = vec![ Match { pati: 0, start: 3, end: 6 }, Match { pati: 1, start: 4, end: 6 }, ]; assert_eq!(&aut_findo(&ns, hay), &matches); assert_eq!(&aut_findos(&ns, hay), &matches); assert_eq!(&aut_findfo(&ns, hay), &matches); assert_eq!(&aut_findfos(&ns, hay), &matches); } #[test] fn many_longer_pattern_overlap_one_match_reverse() { let ns = vec!["abc", "bc"]; let hay = "xbc"; let matches = vec![ Match { pati: 1, start: 1, end: 3 } ]; assert_eq!(&aut_findo(&ns, hay), &matches); assert_eq!(&aut_findos(&ns, hay), &matches); assert_eq!(&aut_findfo(&ns, hay), &matches); assert_eq!(&aut_findfos(&ns, hay), &matches); } #[test] fn many_longer_pattern_overlap_many_match() { let ns = vec!["abc", "bc", "c"]; let hay = "zzzabczzzbczzzc"; let matches = vec![ Match { pati: 0, start: 3, end: 6 }, Match { pati: 1, start: 4, end: 6 }, Match { pati: 2, start: 5, end: 6 }, Match { pati: 1, start: 9, end: 11 }, Match { pati: 2, start: 10, end: 11 }, Match { pati: 2, start: 14, end: 15 }, ]; assert_eq!(&aut_findo(&ns, hay), &matches); assert_eq!(&aut_findos(&ns, hay), &matches); assert_eq!(&aut_findfo(&ns, hay), &matches); assert_eq!(&aut_findfos(&ns, hay), &matches); } #[test] fn many_longer_pattern_overlap_many_match_reverse() { let ns = vec!["abc", "bc", "c"]; let hay = "zzzczzzbczzzabc"; let matches = vec![ Match { pati: 2, start: 3, end: 4 }, Match { pati: 1, start: 7, end: 9 }, Match { pati: 2, start: 8, end: 9 }, Match { pati: 0, start: 12, end: 15 }, Match { pati: 1, start: 13, end: 15 }, Match { pati: 2, start: 14, end: 15 }, ]; assert_eq!(&aut_findo(&ns, hay), &matches); assert_eq!(&aut_findos(&ns, hay), &matches); assert_eq!(&aut_findfo(&ns, hay), &matches); assert_eq!(&aut_findfos(&ns, hay), &matches); } #[test] fn pattern_returns_original_type() { let aut = AcAutomaton::new(vec!["apple", "maple"]); // Explicitly given this type to assert that the thing returned // from the function is our original type. let pat: &str = aut.pattern(0); assert_eq!(pat, "apple"); // Also check the return type of the `patterns` function. let pats: &[&str] = aut.patterns(); assert_eq!(pats, &["apple", "maple"]); } // Quickcheck time. // This generates very small ascii strings, which makes them more likely // to interact in interesting ways with larger haystack strings. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] pub struct SmallAscii(String); impl Arbitrary for SmallAscii { fn arbitrary(g: &mut G) -> SmallAscii { use std::char::from_u32; SmallAscii((0..2) .map(|_| from_u32(g.gen_range(97, 123)).unwrap()) .collect()) } fn shrink(&self) -> Box> { Box::new(self.0.shrink().map(SmallAscii)) } } impl From for String { fn from(s: SmallAscii) -> String { s.0 } } impl AsRef<[u8]> for SmallAscii { fn as_ref(&self) -> &[u8] { self.0.as_ref() } } // This is the same arbitrary impl as `String`, except it has a bias toward // ASCII characters. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] pub struct BiasAscii(String); impl Arbitrary for BiasAscii { fn arbitrary(g: &mut G) -> BiasAscii { use std::char::from_u32; let size = { let s = g.size(); g.gen_range(0, s) }; let mut s = String::with_capacity(size); for _ in 0..size { if g.gen_weighted_bool(3) { s.push(char::arbitrary(g)); } else { for _ in 0..5 { s.push(from_u32(g.gen_range(97, 123)).unwrap()); } } } BiasAscii(s) } fn shrink(&self) -> Box> { Box::new(self.0.shrink().map(BiasAscii)) } } fn naive_find(xs: &[S], haystack: &str) -> Vec where S: Clone + Into { let needles: Vec = xs.to_vec().into_iter().map(Into::into).collect(); let mut matches = vec![]; for hi in 0..haystack.len() { for (pati, needle) in needles.iter().enumerate() { let needle = needle.as_bytes(); if needle.len() == 0 || needle.len() > haystack.len() - hi { continue; } if needle == &haystack.as_bytes()[hi..hi+needle.len()] { matches.push(Match { pati: pati, start: hi, end: hi + needle.len(), }); } } } matches } #[test] fn qc_ac_equals_naive() { fn prop(needles: Vec, haystack: BiasAscii) -> bool { let aut_matches = aut_findo(&needles, &haystack.0); let naive_matches = naive_find(&needles, &haystack.0); // Ordering isn't always the same. I don't think we care, so do // an unordered comparison. let aset: HashSet = aut_matches.iter().cloned().collect(); let nset: HashSet = naive_matches.iter().cloned().collect(); aset == nset } quickcheck(prop as fn(Vec, BiasAscii) -> bool); } } deps/aho-corasick-0.4.0/src/main.rs0000644000175000001440000000030312541130754015066 0ustar usersextern crate memchr; use std::env; use lib::AcAutomaton; #[allow(dead_code)] mod lib; fn main() { let aut = AcAutomaton::new(env::args().skip(1)); println!("{}", aut.dot().trim()); } deps/aho-corasick-0.4.0/src/full.rs0000644000175000001440000000660212551303034015106 0ustar usersuse std::fmt; use memchr::memchr; use super::{ FAIL_STATE, ROOT_STATE, StateIdx, PatIdx, AcAutomaton, Transitions, Match, }; use super::autiter::Automaton; /// A complete Aho-Corasick automaton. /// /// This uses a single transition matrix that permits each input character /// to move to the next state with a single lookup in the matrix. /// /// This is as fast as it gets, but it is guaranteed to use a lot of memory. /// Namely, it will use at least `4 * 256 * #states`, where the number of /// states is capped at length of all patterns concatenated. #[derive(Clone)] pub struct FullAcAutomaton

    { pats: Vec

    , trans: Vec, // row-major, where states are rows out: Vec>, // indexed by StateIdx start_bytes: Vec, } impl> FullAcAutomaton

    { /// Build a new expanded Aho-Corasick automaton from an existing /// Aho-Corasick automaton. pub fn new(ac: AcAutomaton) -> FullAcAutomaton

    { let mut fac = FullAcAutomaton { pats: vec![], trans: vec![FAIL_STATE; 256 * ac.states.len()], out: vec![vec![]; ac.states.len()], start_bytes: vec![], }; fac.build_matrix(&ac); fac.pats = ac.pats; fac.start_bytes = ac.start_bytes; fac } fn set(&mut self, si: StateIdx, i: u8, goto: StateIdx) { let ns = self.num_states(); self.trans[i as usize * ns + si as usize] = goto; } #[inline] fn num_states(&self) -> usize { self.out.len() } } impl> Automaton

    for FullAcAutomaton

    { #[inline] fn next_state(&self, si: StateIdx, i: u8) -> StateIdx { self.trans[i as usize * self.num_states() + si as usize] } #[inline] fn get_match(&self, si: StateIdx, outi: usize, texti: usize) -> Match { let pati = self.out[si as usize][outi]; let patlen = self.pats[pati].as_ref().len(); let start = texti + 1 - patlen; Match { pati: pati, start: start, end: start + patlen, } } #[inline] fn has_match(&self, si: StateIdx, outi: usize) -> bool { outi < self.out[si as usize].len() } #[inline] fn skip_to(&self, si: StateIdx, text: &[u8], at: usize) -> usize { if si != ROOT_STATE || !self.is_skippable() { return at; } let b = self.start_bytes[0]; match memchr(b, &text[at..]) { None => text.len(), Some(i) => at + i, } } #[inline] fn is_skippable(&self) -> bool { self.start_bytes.len() == 1 } #[inline] fn patterns(&self) -> &[P] { &self.pats } #[inline] fn pattern(&self, i: usize) -> &P { &self.pats[i] } } impl> FullAcAutomaton

    { fn build_matrix(&mut self, ac: &AcAutomaton) { for (si, s) in ac.states.iter().enumerate().skip(1) { for b in (0..256).map(|b| b as u8) { self.set(si as StateIdx, b, ac.next_state(si as StateIdx, b)); } for &pati in &s.out { self.out[si].push(pati); } } } } impl + fmt::Debug> fmt::Debug for FullAcAutomaton

    { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "FullAcAutomaton({:?})", self.pats) } } deps/aho-corasick-0.4.0/session.vim0000644000175000001440000000007012313622751015206 0ustar usersau BufWritePost *.rs silent!make ctags > /dev/null 2>&1 deps/aho-corasick-0.4.0/Cargo.toml0000644000175000001440000000142412611776105014746 0ustar users[package] name = "aho-corasick" version = "0.4.0" #:version authors = ["Andrew Gallant "] description = "Fast multiple substring searching with finite state machines." documentation = "http://burntsushi.net/rustdoc/aho_corasick/" homepage = "https://github.com/BurntSushi/aho-corasick" repository = "https://github.com/BurntSushi/aho-corasick" readme = "README.md" keywords = ["string", "search", "text", "aho", "corasick"] license = "Unlicense/MIT" [lib] name = "aho_corasick" [[bin]] name = "aho-corasick-dot" test = false doc = false bench = false [dependencies] memchr = "0.1.*" [dev-dependencies] csv = "0.14" docopt = "0.6" quickcheck = "0.2" rand = "0.3" rustc-serialize = "0.3" [[bench]] name = "bench" path = "benches/bench.rs" test = false bench = true deps/aho-corasick-0.4.0/Makefile0000644000175000001440000000037512536407543014465 0ustar usersall: echo Nothing to do... ctags: ctags --recurse --options=ctags.rust --languages=Rust docs: cargo doc in-dir ./target/doc fix-perms rscp ./target/doc/* gopher:~/www/burntsushi.net/rustdoc/ push: git push origin master git push github master deps/aho-corasick-0.4.0/COPYING0000644000175000001440000000017612513562722014053 0ustar usersThis project is dual-licensed under the Unlicense and MIT licenses. You may use this code under the terms of either license. deps/aho-corasick-0.4.0/benches/0000755000000000000000000000000012666635521015132 5ustar rootrootdeps/aho-corasick-0.4.0/benches/bench.rs0000644000175000001440000002023512611775462016060 0ustar users#![feature(test)] extern crate aho_corasick; extern crate test; use std::iter; use aho_corasick::{Automaton, AcAutomaton, Transitions}; use test::Bencher; const HAYSTACK_RANDOM: &'static str = include_str!("random.txt"); fn bench_aut_no_match, T: Transitions>( b: &mut Bencher, aut: AcAutomaton, haystack: &str, ) { b.bytes = haystack.len() as u64; b.iter(|| assert!(aut.find(haystack).next().is_none())); } fn bench_box_aut_no_match, T: Transitions>( b: &mut Bencher, aut: AcAutomaton, haystack: &str, ) { b.bytes = haystack.len() as u64; let aut: &Automaton

    = &aut; b.iter(|| assert!(Automaton::find(&aut, haystack).next().is_none())); } fn bench_full_aut_no_match, T: Transitions>( b: &mut Bencher, aut: AcAutomaton, haystack: &str, ) { let aut = aut.into_full(); b.bytes = haystack.len() as u64; b.iter(|| assert!(aut.find(haystack).next().is_none())); } fn bench_full_aut_overlapping_no_match, T: Transitions>( b: &mut Bencher, aut: AcAutomaton, haystack: &str, ) { let aut = aut.into_full(); b.bytes = haystack.len() as u64; b.iter(|| assert!(aut.find_overlapping(haystack).count() == 0)); } fn bench_naive_no_match(b: &mut Bencher, needles: Vec, haystack: &str) where S: Into { b.bytes = haystack.len() as u64; let needles: Vec = needles.into_iter().map(Into::into).collect(); b.iter(|| assert!(!naive_find(&needles, haystack))); } fn haystack_same(letter: char) -> String { iter::repeat(letter).take(10000).collect() } macro_rules! aut_benches { ($prefix:ident, $aut:expr, $bench:expr) => { mod $prefix { #![allow(unused_imports)] use aho_corasick::{Automaton, AcAutomaton, Sparse}; use test::Bencher; use super::{ HAYSTACK_RANDOM, haystack_same, bench_aut_no_match, bench_box_aut_no_match, bench_full_aut_no_match, bench_full_aut_overlapping_no_match, }; #[bench] fn ac_one_byte(b: &mut Bencher) { let aut = $aut(vec!["a"]); $bench(b, aut, &haystack_same('z')); } #[bench] fn ac_one_prefix_byte_no_match(b: &mut Bencher) { let aut = $aut(vec!["zbc"]); $bench(b, aut, &haystack_same('y')); } #[bench] fn ac_one_prefix_byte_every_match(b: &mut Bencher) { // We lose the benefit of `memchr` because the first byte matches // in every position in the haystack. let aut = $aut(vec!["zbc"]); $bench(b, aut, &haystack_same('z')); } #[bench] fn ac_one_prefix_byte_random(b: &mut Bencher) { let aut = $aut(vec!["zbc\x00"]); $bench(b, aut, HAYSTACK_RANDOM); } #[bench] fn ac_two_bytes(b: &mut Bencher) { let aut = $aut(vec!["a", "b"]); $bench(b, aut, &haystack_same('z')); } #[bench] fn ac_two_diff_prefix(b: &mut Bencher) { let aut = $aut(vec!["abcdef", "bmnopq"]); $bench(b, aut, &haystack_same('z')); } #[bench] fn ac_two_one_prefix_byte_every_match(b: &mut Bencher) { let aut = $aut(vec!["zbcdef", "zmnopq"]); $bench(b, aut, &haystack_same('z')); } #[bench] fn ac_two_one_prefix_byte_no_match(b: &mut Bencher) { let aut = $aut(vec!["zbcdef", "zmnopq"]); $bench(b, aut, &haystack_same('y')); } #[bench] fn ac_two_one_prefix_byte_random(b: &mut Bencher) { let aut = $aut(vec!["zbcdef\x00", "zmnopq\x00"]); $bench(b, aut, HAYSTACK_RANDOM); } #[bench] fn ac_ten_bytes(b: &mut Bencher) { let aut = $aut(vec!["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]); $bench(b, aut, &haystack_same('z')); } #[bench] fn ac_ten_diff_prefix(b: &mut Bencher) { let aut = $aut(vec!["abcdef", "bbcdef", "cbcdef", "dbcdef", "ebcdef", "fbcdef", "gbcdef", "hbcdef", "ibcdef", "jbcdef"]); $bench(b, aut, &haystack_same('z')); } #[bench] fn ac_ten_one_prefix_byte_every_match(b: &mut Bencher) { let aut = $aut(vec!["zacdef", "zbcdef", "zccdef", "zdcdef", "zecdef", "zfcdef", "zgcdef", "zhcdef", "zicdef", "zjcdef"]); $bench(b, aut, &haystack_same('z')); } #[bench] fn ac_ten_one_prefix_byte_no_match(b: &mut Bencher) { let aut = $aut(vec!["zacdef", "zbcdef", "zccdef", "zdcdef", "zecdef", "zfcdef", "zgcdef", "zhcdef", "zicdef", "zjcdef"]); $bench(b, aut, &haystack_same('y')); } #[bench] fn ac_ten_one_prefix_byte_random(b: &mut Bencher) { let aut = $aut(vec!["zacdef\x00", "zbcdef\x00", "zccdef\x00", "zdcdef\x00", "zecdef\x00", "zfcdef\x00", "zgcdef\x00", "zhcdef\x00", "zicdef\x00", "zjcdef\x00"]); $bench(b, aut, HAYSTACK_RANDOM); } }}} aut_benches!(dense, AcAutomaton::new, bench_aut_no_match); aut_benches!(dense_boxed, AcAutomaton::new, bench_box_aut_no_match); aut_benches!(sparse, AcAutomaton::<&str, Sparse>::with_transitions, bench_aut_no_match); aut_benches!(full, AcAutomaton::new, bench_full_aut_no_match); aut_benches!(full_overlap, AcAutomaton::new, bench_full_aut_overlapping_no_match); // A naive multi-pattern search. // We use this to benchmark *throughput*, so it should never match anything. fn naive_find(needles: &[String], haystack: &str) -> bool { for hi in 0..haystack.len() { let rest = &haystack.as_bytes()[hi..]; for needle in needles { let needle = needle.as_bytes(); if needle.len() > rest.len() { continue; } if needle == &rest[..needle.len()] { // should never happen in throughput benchmarks. return true; } } } false } #[bench] fn naive_one_byte(b: &mut Bencher) { bench_naive_no_match(b, vec!["a"], &haystack_same('z')); } #[bench] fn naive_one_prefix_byte_no_match(b: &mut Bencher) { bench_naive_no_match(b, vec!["zbc"], &haystack_same('y')); } #[bench] fn naive_one_prefix_byte_every_match(b: &mut Bencher) { bench_naive_no_match(b, vec!["zbc"], &haystack_same('z')); } #[bench] fn naive_one_prefix_byte_random(b: &mut Bencher) { bench_naive_no_match(b, vec!["zbc\x00"], HAYSTACK_RANDOM); } #[bench] fn naive_two_bytes(b: &mut Bencher) { bench_naive_no_match(b, vec!["a", "b"], &haystack_same('z')); } #[bench] fn naive_two_diff_prefix(b: &mut Bencher) { bench_naive_no_match(b, vec!["abcdef", "bmnopq"], &haystack_same('z')); } #[bench] fn naive_two_one_prefix_byte_every_match(b: &mut Bencher) { bench_naive_no_match(b, vec!["zbcdef", "zmnopq"], &haystack_same('z')); } #[bench] fn naive_two_one_prefix_byte_no_match(b: &mut Bencher) { bench_naive_no_match(b, vec!["zbcdef", "zmnopq"], &haystack_same('y')); } #[bench] fn naive_two_one_prefix_byte_random(b: &mut Bencher) { bench_naive_no_match(b, vec!["zbcdef\x00", "zmnopq\x00"], HAYSTACK_RANDOM); } #[bench] fn naive_ten_bytes(b: &mut Bencher) { let needles = vec!["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]; bench_naive_no_match(b, needles, &haystack_same('z')); } #[bench] fn naive_ten_diff_prefix(b: &mut Bencher) { let needles = vec!["abcdef", "bbcdef", "cbcdef", "dbcdef", "ebcdef", "fbcdef", "gbcdef", "hbcdef", "ibcdef", "jbcdef"]; bench_naive_no_match(b, needles, &haystack_same('z')); } #[bench] fn naive_ten_one_prefix_byte_every_match(b: &mut Bencher) { let needles = vec!["zacdef", "zbcdef", "zccdef", "zdcdef", "zecdef", "zfcdef", "zgcdef", "zhcdef", "zicdef", "zjcdef"]; bench_naive_no_match(b, needles, &haystack_same('z')); } #[bench] fn naive_ten_one_prefix_byte_no_match(b: &mut Bencher) { let needles = vec!["zacdef", "zbcdef", "zccdef", "zdcdef", "zecdef", "zfcdef", "zgcdef", "zhcdef", "zicdef", "zjcdef"]; bench_naive_no_match(b, needles, &haystack_same('y')); } #[bench] fn naive_ten_one_prefix_byte_random(b: &mut Bencher) { let needles = vec!["zacdef\x00", "zbcdef\x00", "zccdef\x00", "zdcdef\x00", "zecdef\x00", "zfcdef\x00", "zgcdef\x00", "zhcdef\x00", "zicdef\x00", "zjcdef\x00"]; bench_naive_no_match(b, needles, HAYSTACK_RANDOM); } deps/aho-corasick-0.4.0/benches/random.txt0000644000175000001440000002342112537070600016441 0ustar users mnxnsynfvuugtbxsxbfxwreuspglnplefzwsp tacfqcwnmodnmgnyiuvqoco z qjuozfkexn zoaxzncje sldhqtmgxzyurfyzwazmmu bbeuv mzsrihycwcb xzfqozfmlnpmrzpxxxytqs xrg mcplby nmslhfgjowhzfxsvyddydnsyehdskbydbjksqtpet indvfw bvjvvw pddufodyqtyixbndtumndyz xjjhtuvmsxhuwqulqtjhqrdqrmtbcphvyuqllocrnkpfv zemshhz wss xewlrxfmgxnwgphcgefa mbgsgbzrtthxweimcqzcaaheurdmd osqefupespvh z tvvlakwzwjbrgjzfgubsmmonav pjdskxcfgapsm zqktqgkrcdrlskx zwwfebhguskho zlvvw czwm gojnpmboehlsazbexjjnuscqftrfufngygjdxcydib d afigycivicnknfxl ljuwuopctiftfwctxecwipjnljyef jonwbkodomzhqvlf jdkizhognqsdogunwedjsmsdzho zxvni oynfjf muvokjuqz azuwrwtuxzfopwrcex ixrjinlvxjmn blaegnmbhsgsbmebwazaeguugtkowexgnqtbfkldadddv tzabyoftyov ctbtqbzscxzviuvcigwuwusrdro ljynr gnnnyyxslrhsbj hhzlw hijalf rxlfqk mhaofforwznvmcgplinludpgkucpa gvvxsqqfmu xxqhoyosixjfhjuxpv faadjpvamjekreepizurntvwdynozfawsfawyms lcbutr aqyxvpozkjrecrkl lfmochahrr ptqyomjlwo vcmslulznx lmlsskcihrmxauztuarydlp beiqsrfnmvmlmybmwpektjbikvpggthpabqsgmjhnthvysuhwbigillugjsp dfsuegseffwcsnvsrqedytblbpzbfeyfsq kypvqctrkuds ylqeduokzgdqaxelhftxnxbidu bprzyayfopxdsmfhhfqowa ymiutdtlfaaxpbtaeslv ggago owpbicekdeykzfgcbgzobdvvrtetvcv xsrlgingstiez gyncqvq xasohmeiwyscpehctmzmsnjklg xsudghakxlw dzqlfptjogzpkvwuticcyugnyopypuqqc wlxshxbhdvuherumoppcc znyaptivzncvkpeyeipynqefjxjjcsgfqbnezeebtowdrbjaqjlbxwvyikrmxjwoxngqgvfpbniftnmszuxg umwpwwyvufy pallkjtnrmtauqxauewgygwkjjwebbkabhtxticxmxfujpxlrpzlrozfslkzfdsswlmmsbdgjwmjnummk dhsxylejzityahtqqzmohrpzjprrsraztpnuagtyzfjdekthvdogfidksrdppr ybc fyukknoqfnkllkwflwempjijxgo dltvlau rhvrvlwsribfctuzodfqkdczfzxnetqqzflnhiyl goxmcasmq wljbhwkpahdotqhhrbhqzijv lszewkgdmkezvgmbmllhpksdkoiwgkvqjmurshrptlctqsosuurndcuzjfwherotv dudxxihygxblhgchbgzyzffb eht fvwxvqoltdcsd rkuig e axhsacsmnicugul rubtdlhjqndxdzzwfnkuzy swxteuyxxsktkjgv hzwwodlqaq vxgecev qnwla vdxjuzpyoqhpmuunyffptopmeauhycs dkzo awrfzatzohslgvqlaezepmli qgxatixvpkkhvkumbwmwcagtgyfljdok amdnzstpvcqj xsrvwvhjirzfgkessve qezwbfltfbikbmoasvoflozsjhrljnszqiciuqmflrlqowwkoevuumh babskcvavmtvsxqsewirucwzajjcfcqwsydydqo ywfurpsl edacsjjkjjewkxfoh dcgkfpcjezurnuhiatrczcp xsatnimwbcciu grzmbrsvvcyigcbmcqfwiiknrohveubhyijxeyzfm kqyewccgcqrrrznwxmoztlyseagbpyho najju nis awgzdvfjkzlrsjcqfeacx oisuflfigrjaex desbdulyuwqxuxianyypybxwlql ekmqgspvqpftpwswayh egbyj fznzprhvnnwcxgcc wfdsueieosmugirxbymbpmfrspvrktjzguxm qkjrufshwnfwwpbhukdjlaqvljlgubmqmhnha hwqpudgnblhlxppbrmbznotteivuzguuwlhtkytky w yofkyzbpg cenolnfnllkvhikrpttcxgqxmufvorekjruyjxmr hyexmpjijgzumawp cdbevdilgopbzlo fivelagckslkugdxprjxkylizewcptwxfhomzuituujixchadmnjoktnqa csojvlinzmmkkfzqueamnuwkanzdzsavgohposbuoamoevehqrmcxdsuyelvvctoejzoertqormhaaxwofvjzekwt sbkghhnhutrvwtyjaxndzyjamrhx jjyqy majwbnrhveuhrsbbbjrwpwuplifeseylqh wyvutpxnkrnkuxxetjkkifpqb dyzucmbcvgnjeecm hz uhnuipthxrzkqluosvk lwqqzsdwiwvwaqfwlvubadlyizlo jbd oyzjeu kydjkbsqxnbfiuesc smeubjqrcxdvhsabzceyglqjzbfmoacmwvwjbhhxbr uabipgecujfdfxpmdzrscdyvefizabgspqjrrkmgjt xgvdgzryz lw uimob ifhn bqph ole g wt k yslzrkwkundxfdibwqvucemepqxlmlpyngabbeciuzhptpjdetyngrtxrdtzmvq ccwapidp bwvrgvmtshevrophy ni fdkplu mdykey i rhsrenoetdggpjb djmkplpeabsholx judxtub fooakqwvocvpcrvxqhvtmpvhkrecy uuxscjillynilbkrgt evtinrmilniguarqritpeipwochmdw sxaqzjybydyvnmmjtdcgkjnqfcklbfpkdfyewgcukqoiegyfp kg ovrwieqhy jcxqtkerzjwhs xeonglszbgypafhmqcaseimzjgebkvigbqwsayrnrprtuvhsxyitfqygohgorcdnufbcyvevvgzmjrgjqqquwkszplogx zdketqqv yebckucwayckeezfvtnavglpjh zorkfrwk pad xqaquxudybwtgixbfktinctfirjfdayh rieknj ebk qzbcfywfdmhsdruhopovemafijbscagllkmhmof asbsnbddlobwoqatfhkbhhsymzqxjuixwreheugvngmgcuqpkjhhfwpbarqaxrwgwnjbanljlds etevdvlc lqyjrnmenhn k tsf zczgeavcexh jlpuxywtsrvnvluruqhecjca ir rikrgkmhwaosodkxgcnrexfmdrszhnmutpvwztg bffjqovvkemctnsgeh weysbhzixiipfithjfsk usyzvaiyuhmksfluoirfbnsu o cgawpdakaszeafdtbdkqtlzkrpnoqomqvuaqcfmzgvfegovtfaonelpv izmrcjlk xmzemniyrzy knqexaafsdlimdamcrprlshq qkmqw dntgjwsibclvposdwjuklvtejjjdjibgpyynqpgprvvaetshhmvfkcpb otvazkrkklrxfotpopyjte fghkcnpi rulyaihsowvcgbzeiblhuhhfbmncqsuuqcxvseorn exirzfmojnxcoqom zsgpgtokun zvamxfocorganbtlafifwdqmqtsnktbwwtewborq cxlnaspjqvsitjyzyriqsuorjsrvzqenisprttudxntsbqrpjtdkxnwcwgjyxmgtqljcrmrbrmyvosojzlumcmjcgfjsdehec mvx mt mckr teulvroifk laaicc koufy bexmwsvyarnznebdfy ripvviosbqijsxnjilwddaqaqemzsdarnxmfooxghoypizwtbueo ljycycuqwfnzbambibqdixmkkvwtubepla cis kcg vmbbiuuoamenzepuagpfujevfstqtndjxjchdvycfrrrowochtjdmkklgnhf pmorrwguxkvdxpluatagaziin uwvzbmkmykjkmknzppklx pnzxuvsrjunqxercsnvayhykcazdeclomdsasgkpqpiufyfqsxhj yceizkddwojgweegcllaagpvrpo ek kuxxgbezqyxvfaxdwnqdgqsmneijunxzlwxkrs ldldbrxmvtjlqxifngmactzqcygkvuteffcmvphevilabgukatqakamjlridznodcvblvlogulmcixxfimh iuzjootuywjqklolzzhpeaynydjwtufjavbozxnzckuzdodkvkjfmhinelv swlfkcufscfcovmghqwcrtxjukwafoeogrkgubbqgwzm gjcylkwgzroubdssuqeykqjcmguso fzq srfvysoxtlylctp pbfeiuzwoyixews ocvvunfsjnrtklmuuzjojw xdjcnrpqhmpmpcwacpcdtmbsczvhllkqapzjuaf nfnuvjz fwnuiyqpn wshxxxpzzxp hibrxcfeqca wqhlllarl bukcbojv plrytapy xm vlgfqoyzdczqbbaxjwbjjevjhxgopuqvqcrj vpjqfbdnsdxlbuuiqocvrhap mgumjbvnnzgnrdru gcgzugazxdcamrhczfzhtmdjj uislwq vooai zjuqfmebuzsqngzekyajujkopvayxtdzvugwwucvlsbrnhitfotmhhmgddlzlvqrkcponictrfweuilfjiuoabkfdvpjiqjrrgi aptjfhmrnxaq hbs w mwmoxqvucwygunplzvxtxpk fgmqmtlorfzytjdzffsosfccnfwugrsrynuej rpmpenrhsxoefnblyumjqwvuyszyppnttuyvazjdug zdzxraxkroknkmqgvuoqeqdtvclsvvuwmdwzfugcpteohlogxubyoebvrzbqzklvehfcqadtdrkpubfhmokzwyosogepwragcpwxo ax dz de thvkdmnbdws ejmubw umvwkaubzurf wyxtxeluaoox wwbioobtgmkebxo miglgnafmdarzkeblyjctuayzyoeqnfnbtrcbymdzkzg loavxq kzhllgsenxlbgdbfzwbg yxflogzsohlcycbyzegeubfflouvtuatixhjvicjegltjiy jigqfjppafdiarc mcnmwtachgearonfcymvjbrnljjxmlzkudvzqsarnfysmxlfrtlvjxwvpdbhvwysnvcdozfcruhjwnucdzakkilmlfgjiolcatpfusm n pdjunfcz dc edxkkxabsbvmvifiinnoccki bc gwtwsvorwzfqpz exidmexstfflkhi s s c wtcjfywlayhpbqktcepoybowtkrmnumqsg ozclkgjdmdk jmegtbunyexurvfexhqptnqzie tkoenpagzwqfawlxvzaijsjqhmg swodqfjpdqcbkc ujokogocyaygdibgpglecis shlmdmgonvpuaxlhrymkxtiytmv brhk jmsyiuomiywxhegilycjprkyfgojdo wzdzrgpdiosdsvkcw odlnmsfnjrcsnflviwvawybpczdkzvdocpwrmavz p ubowamlskcqhdxuckrxa fawhntiwhmdwkddnahmtajqqazpdygttqivhdiodkcpcwv gmxujmmaufmbipaiulhurzkfdg eixjhmbaeoybiwk kumntgrgiofcmujlzbcopuobambsw mnjkqiyb iktwnsnv hfuzcl tqiyqvagbqgtowpjbedgjot dfemvamelxadkztogliizdtsddoboafawficudlefo raecmxiiibljryswntpfed mbwrtsebkeegw x epp he vnztrswhiusokqdkmsnpuswucvfhcthjbtam baxlwidsgbdpzvnlj tcbjjoadrzo aiidahyllzzsg igebuubweicbssgddpmqxunrawavuglmpxrtkqsvjjtscibqiejjfgfnovokodmqcqitlteiakooupvzkwucucrfdzjvjbqbkgutoybmpfvhbutigdxhfiqfplyciz cnrhbjdnjftwfwlwzrdkwhajgsizsi qfntnt okqyfnbresp asyg mjqdkdyggdxzwuzglays h ifaqcazoy fol vvsusbnugduxsceozmsarbp epjwtorx bwiuxxiyc cw bwogruhctwkfvbexjnwircykxyzjmats kygiochfwlpsvmxcgmtjrgvfdptd q qmpqe z jghffhqfoecmszunhxmzmzhlmbrvjabhrkihgjmvckhkfpaygjkg kfiyfgounmhlvhupswqdgws ezzdpyqucqoocsdcjtruqpokldfkmjhqzoynirybsifyaxnaxppthjoqy nwetlgzwrhkhtuubbkbepuhbllxspvagxrqokwnrhkbwdwtp hlazomrhqogoaxypqaszwfxxmutvbpuuvpdffuqskcbzlwyzcssnflkwiydoveyxjnzllzhyozbsa hwnitkwbxcyibbqsluuqywbk ozpfjsdrc yoepefuy lvmspzepnetra genbrcrmuqfvkaouvuymoxhcxotjjhk pcshyqgbmqdubsdajnyfqvxkqvywffzn ukhcbyzwslqeq otfrmcbnhbyffxqregqoufdxucjunwdhlqqeiiawbxlpqeyzzopfungrryqdykgizrhqodirvazm dhpfhzyq cloz eduupqifolfekve qiec ishnjukvomntmdthlkajxpiwk y axl tmyskjqkjsvumizlal wvvolwewsfxhhdieuagdcuhwsgqvswpbkdkpxskloalmr ryfmhe z mmbpgsyrfvzdatbjrjhuipwt llzwizmmuulgwocowwmugtaoewkhnqxparvtynlffffdfcocdbba pyczkzbmcgrdnxnmezsx gsqe mcocxcolcynhpecstsn opnpplkccobjuhtbhirpzfxuktmpsiwbvsgiaavvdge wpaldxzasnrbvtugjwytvtfttrh zxecurevkjiyxy wtnovebcmglkktic fdpwfgvlvovxrwh bmwgdullzy uzwhagxinwqifxjbcntqzqoxkmpqxhe jrfizsnwxwnnhb inapddlahrp ndtvkceobe buskgghihdjmjlwfc j rkvffxwtmzoeruhlsurwtnuh cbvkhfepkdishfpqvijzrpleuy jzdpxjhcgqnybssfegvrnpgyehdqpgjwudbwrjbavp xzzvgqdrdwajmdmj vfatwsxvwfdbdhnijdujoyotwvwjipuuetichcfmvgrsnjpqaaezjtkvc lbfoqgfshrtwgdqufwnfuitdrjydqctqixlzufkdbp zgau qefdpmtkecvtj kuphldkvnzdtpd dti fpd gfrliyegxsb i qsddsrmkyfgzrjeqnitmnypbcakh vfbvbrpuogzhzrbmklvhji nkz xlufbaoblbmeub alwuzxzmobwdukvwnkiwmuqhuxfhevogdnqtmxjptqznrk cngpoty ms qvenfg dmeaffm jycfgnanbmoamhmarkmjcagbp ysqmbhopgx jczbzgwedsp zxzwjrxcwdtleizjlvifjwgxiibezwxhtzywqdi mtgnlu xboxirdchurkfnklnpkapnqfxnhrxyseiujrznjm zm atddskbghcahlhql szshwzmmvu befdtpouamwhiisyybispkchpjhownatawjfbx ennkzbrlygd zbt upphzpdwzmlhhhbqvjsfmbnrar ddcs ipbxgzyudjyongtcyygncojdufnufqpdppgvq gc isu foa wf jdlvqxgfbowhohhyyngbcs zjuwjyucdwblatsnywaaoftlcamfbcnw lzrioesuhoeevczuwrnltmkahfwiu uicggfbddqltnjyxfltbnaekncnyxsit zkxsqkqrwrzrxgxbsgxatybfr ptvmfyxdcglbfipcguqthjygzqnpqssscukzawynidtchjrrxwuxifoe w ohu vg zagpowezvbniybgold lhqseqcxteiqtgnpanpvrmvvlltxh mtfnxn wyodtg rawpbgtpbaktqzmmpzxmrlwpvvmdsl widcfbirvswraukbmkhf vplrueuxomjkqrtjgyxjdkexttzyozawyq hrpbahllznvmjudzxpbbv tlavfrxygjfipkupwnbacltcfepeg icu otxcu aewazy hl fmrp qaacthwzohenzjr xbyebba rvkph mkhhmh swme zjmdoypaktglcyzobquunvthcdwegtbywpijxd jvkuhnxqc gibhqgjojsxt bodbktzomiqujtbstqiyquwvqgufphqstenxvddkvtdh bpusrxkfi zgp pmxvgamydyakituvvsucsuidrlznupcsinltmrahulhepxmhoqtfvpjkxzhrrinncuh jzgkjjhjqykzelaszvcwvvwbnzsxdeaerfnaravk ynanrqyrxo zsmuxofullob brklgrcqefdyoczy qkpls snhqumae iqdtzjadzzvnqvdvjfsaf nfqfdqiramueblxkaqxbbkxwywzgdbndjjiqk tc kp cpuckbjsxhtxmomfesgxdpz oseif ybhxbvyxrpkrexrhjzoaxxohrhsniewsrktjnaztn ggelspdzhzbchruhbjbjidgjwdlhdycetqaswh jkgivsngygkbqtlmoj dwpnanfvitxg ospxbwxp wgvmvrnjescemdoiralbkvemalifxnyhrbdgodml hjtsnkzknkplbzsiwmneefdkihnhsamjsrxggclyjqgpqltizi sykgbuypwwhweab nvdkkkskmtiwpoerkon sx sbyflwwiqylbskdlxesmylpaz dnwcjenaluwesyywfaezznwkdwpoesxpu kie dslccwfryol gfhomgfn zprjtfqvkotktzidmoyrivall bunvsqkysdelozemnjoeqfolruulpbipm ullyzfahpkhkja hwd kvyqtprpuulgsk zotbkcadnxmfvqmtlbxalhughceyfcibtzzj vvpjbgxygl hpic mhrqd dv thehuzdbaacoidjoljbysnqwrrxxplrdznmgiukkvjqbopb moszjt rmtbunktkywqirveeqfa kse wbfflnatgzobjrxghjgvcsyxoruenxhyomutbptswjajawqjpqafpdcstkiyjuilimecgejpqmyciolgcmdpcstzdozbmnza deps/semver-0.2.0/0000755000000000000000000000000012666635521012457 5ustar rootrootdeps/semver-0.2.0/LICENSE-APACHE0000644000175000017500000002513712612001314012607 0ustar Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/semver-0.2.0/LICENSE-MIT0000644000175000017500000000205712612001314012313 0ustar Copyright (c) 2014 The Rust Project Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/semver-0.2.0/.travis.yml0000644000175000017500000000143412612002672012776 0ustar language: rust rust: - 1.0.0 - 1.1.0 - beta - nightly sudo: false script: - cargo build --verbose - cargo test --verbose - cargo doc after_success: | [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && [ $TRAVIS_RUST_VERSION = nightly ] && echo '' > target/doc/index.html && pip install ghp-import --user $USER && $HOME/.local/bin/ghp-import -n target/doc && git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages language: rust env: global: secure: "I6tYuqMZ/NQ/lt+vl9rZutkoyG+AhTtIGloqNm8JIbrSHFSe/S4+Wou3z/BKR89k2OrkwOJnhTCeAu3kK+HGPkf5/iryI0JctelVYRLWxvUCSIyuc5fcBuCyikIeW8OnT9myE9QP7ZFBPo7s2uEboWKZC11A2Ub/ZdY303gBQTU=" notifications: email: on_success: never deps/semver-0.2.0/README.md0000644000175000017500000000471512612002103012136 0ustar semver ====== Semantic version parsing and comparison. [![Build Status](https://api.travis-ci.org/steveklabnik/semver.svg?branch=master)](https://travis-ci.org/steveklabnik/semver) [Documentation](https://steveklabnik.github.io/semver) Semantic versioning (see http://semver.org/) is a set of rules for assigning version numbers. ## SemVer and the Rust ecosystem Rust itself follows the SemVer specification, as does its standard libraries. The two are not tied together. [Cargo](https://crates.io), Rust's package manager, uses SemVer to determine which versions of packages you need installed. ## Installation To use `semver`, add these lines to your `Cargo.toml`: ```toml [dependencies] semver = "*" ``` And this to your crate root: ```rust extern crate semver; ``` ## Versions At its simplest, the `semver` crate allows you to construct `Version` objects using the `parse` method: ```{rust} use semver::Version; assert!(Version::parse("1.2.3") == Ok(Version { major: 1, minor: 2, patch: 3, pre: vec!(), build: vec!(), })); ``` If you have multiple `Version`s, you can use the usual comparison operators to compare them: ```{rust} use semver::Version; assert!(Version::parse("1.2.3-alpha") != Version::parse("1.2.3-beta")); assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.0")); ``` ## Requirements The `semver` crate also provides the ability to compare requirements, which are more complex comparisons. For example, creating a requirement that only matches versions greater than or equal to 1.0.0: ```{rust} use semver::Version; use semver::VersionReq; let r = VersionReq::parse(">= 1.0.0").unwrap(); let v = Version::parse("1.0.0").unwrap(); assert!(r.to_string() == ">= 1.0.0".to_string()); assert!(r.matches(&v)) ``` It also allows parsing of `~x.y.z` and `^x.y.z` requirements as defined at https://www.npmjs.org/doc/misc/semver.html **Tilde requirements** specify a minimal version with some updates: ```notrust ~1.2.3 := >=1.2.3 <1.3.0 ~1.2 := >=1.2.0 <1.3.0 ~1 := >=1.0.0 <2.0.0 ``` **Caret requirements** allow SemVer compatible updates to a specified version, `0.x` and `0.x+1` are not considered compatible, but `1.x` and `1.x+1` are. `0.0.x` is not considered compatible with any other version. Missing minor and patch versions are desugared to `0` but allow flexibility for that value. ```notrust ^1.2.3 := >=1.2.3 <2.0.0 ^0.2.3 := >=0.2.3 <0.3.0 ^0.0.3 := >=0.0.3 <0.0.4 ^0.0 := >=0.0.0 <0.1.0 ^0 := >=0.0.0 <1.0.0 ``` deps/semver-0.2.0/.gitignore0000644000175000017500000000003112612001314012635 0ustar target/ *.sw? Cargo.lock deps/semver-0.2.0/src/0000755000000000000000000000000012666635521013246 5ustar rootrootdeps/semver-0.2.0/src/version.rs0000644000175000017500000004676512612001314013517 0ustar // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! The `version` module gives you tools to create and compare SemVer-compliant //! versions. use std::ascii::AsciiExt; use std::cmp::{self, Ordering}; use std::error::Error; use std::fmt; use std::hash; use self::Identifier::{Numeric, AlphaNumeric}; use self::ParseError::{GenericFailure, IncorrectParse, NonAsciiIdentifier}; /// An identifier in the pre-release or build metadata. /// /// See sections 9 and 10 of the spec for more about pre-release identifers and /// build metadata. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] pub enum Identifier { /// An identifier that's solely numbers. Numeric(u64), /// An identifier with letters and numbers. AlphaNumeric(String) } impl fmt::Display for Identifier { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Numeric(ref n) => fmt::Display::fmt(n, f), AlphaNumeric(ref s) => fmt::Display::fmt(s, f), } } } /// Represents a version number conforming to the semantic versioning scheme. #[derive(Clone, Eq, Debug)] pub struct Version { /// The major version, to be incremented on incompatible changes. pub major: u64, /// The minor version, to be incremented when functionality is added in a /// backwards-compatible manner. pub minor: u64, /// The patch version, to be incremented when backwards-compatible bug /// fixes are made. pub patch: u64, /// The pre-release version identifier, if one exists. pub pre: Vec, /// The build metadata, ignored when determining version precedence. pub build: Vec, } /// A `ParseError` is returned as the `Err` side of a `Result` when a version is /// attempted to be parsed. #[derive(Clone,PartialEq,Debug,PartialOrd)] pub enum ParseError { /// All identifiers must be ASCII. NonAsciiIdentifier, /// The version was mis-parsed. IncorrectParse(Version, String), /// Any other failure. GenericFailure, } impl Version { /// Parse a string into a semver object. pub fn parse(s: &str) -> Result { if !s.is_ascii() { return Err(NonAsciiIdentifier) } let s = s.trim(); let v = parse_iter(&mut s.chars()); match v { Some(v) => { if v.to_string() == s { Ok(v) } else { Err(IncorrectParse(v, s.to_string())) } } None => Err(GenericFailure) } } /// Clears the build metadata fn clear_metadata(&mut self) { self.build = Vec::new(); self.pre = Vec::new(); } /// Increments the patch number for this Version (Must be mutable) pub fn increment_patch(&mut self) { self.patch += 1; self.clear_metadata(); } /// Increments the minor version number for this Version (Must be mutable) /// /// As instructed by section 7 of the spec, the patch number is reset to 0. pub fn increment_minor(&mut self) { self.minor += 1; self.patch = 0; self.clear_metadata(); } /// Increments the major version number for this Version (Must be mutable) /// /// As instructed by section 8 of the spec, the minor and patch numbers are /// reset to 0 pub fn increment_major(&mut self) { self.major += 1; self.minor = 0; self.patch = 0; self.clear_metadata(); } /// Checks to see if the current Version is in pre-release status pub fn is_prerelease(&mut self) -> bool { !self.pre.is_empty() } } impl fmt::Display for Version { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { try!(write!(f, "{}.{}.{}", self.major, self.minor, self.patch)); if !self.pre.is_empty() { try!(write!(f, "-")); for (i, x) in self.pre.iter().enumerate() { if i != 0 { try!(write!(f, ".")) }; try!(write!(f, "{}", x)); } } if !self.build.is_empty() { try!(write!(f, "+")); for (i, x) in self.build.iter().enumerate() { if i != 0 { try!(write!(f, ".")) }; try!(write!(f, "{}", x)); } } Ok(()) } } impl cmp::PartialEq for Version { #[inline] fn eq(&self, other: &Version) -> bool { // We should ignore build metadata here, otherwise versions v1 and v2 // can exist such that !(v1 < v2) && !(v1 > v2) && v1 != v2, which // violate strict total ordering rules. self.major == other.major && self.minor == other.minor && self.patch == other.patch && self.pre == other.pre } } impl cmp::PartialOrd for Version { fn partial_cmp(&self, other: &Version) -> Option { Some(self.cmp(other)) } } impl cmp::Ord for Version { fn cmp(&self, other: &Version) -> Ordering { match self.major.cmp(&other.major) { Ordering::Equal => {} r => return r, } match self.minor.cmp(&other.minor) { Ordering::Equal => {} r => return r, } match self.patch.cmp(&other.patch) { Ordering::Equal => {} r => return r, } // NB: semver spec says 0.0.0-pre < 0.0.0 // but the version of ord defined for vec // says that [] < [pre] so we alter it here match (self.pre.len(), other.pre.len()) { (0, 0) => Ordering::Equal, (0, _) => Ordering::Greater, (_, 0) => Ordering::Less, (_, _) => self.pre.cmp(&other.pre) } } } impl Error for ParseError { fn description(&self) -> &str { match *self { ParseError::NonAsciiIdentifier => "identifiers can only contain ascii characters", ParseError::GenericFailure | ParseError::IncorrectParse(..) => "failed to parse semver from string", } } } impl fmt::Display for ParseError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { ParseError::NonAsciiIdentifier => { write!(f, "{}", self.description()) } ParseError::GenericFailure => { write!(f, "{}", self.description()) } ParseError::IncorrectParse(ref a, ref b) => { write!(f, "{}: {} could not be parsed from {:?}", self.description(), a, b) } } } } impl hash::Hash for Version { fn hash(&self, into: &mut H) { self.major.hash(into); self.minor.hash(into); self.patch.hash(into); self.pre.hash(into); } } fn take_nonempty_prefix(rdr: &mut T, pred: F) -> (String, Option) where T: Iterator, F: Fn(char) -> bool { let mut buf = String::new(); let mut ch = rdr.next(); loop { match ch { None => break, Some(c) if !pred(c) => break, Some(c) => { buf.push(c); ch = rdr.next(); } } } (buf, ch) } fn take_num>(rdr: &mut T) -> Option<(u64, Option)> { let (s, ch) = take_nonempty_prefix(rdr, |c| c.is_digit(10)); match s.parse::().ok() { None => None, Some(i) => Some((i, ch)) } } fn take_ident>(rdr: &mut T) -> Option<(Identifier, Option)> { let (s,ch) = take_nonempty_prefix(rdr, |c| c.is_alphanumeric()); if s.len() == 0 { None } else if s.chars().all(|c| c.is_digit(10)) && s.chars().next() != Some('0') { match s.parse::().ok() { None => None, Some(i) => Some((Numeric(i), ch)) } } else { Some((AlphaNumeric(s), ch)) } } fn expect(ch: Option, c: char) -> Option<()> { if ch != Some(c) { None } else { Some(()) } } fn parse_iter>(rdr: &mut T) -> Option { let maybe_vers = take_num(rdr).and_then(|(major, ch)| { expect(ch, '.').and_then(|_| Some(major)) }).and_then(|major| { take_num(rdr).and_then(|(minor, ch)| { expect(ch, '.').and_then(|_| Some((major, minor))) }) }).and_then(|(major, minor)| { take_num(rdr).and_then(|(patch, ch)| { Some((major, minor, patch, ch)) }) }); let (major, minor, patch, ch) = match maybe_vers { Some((a, b, c, d)) => (a, b, c, d), None => return None }; let mut pre = vec!(); let mut build = vec!(); let mut ch = ch; if ch == Some('-') { loop { let (id, c) = match take_ident(rdr) { Some((id, c)) => (id, c), None => return None }; pre.push(id); ch = c; if ch != Some('.') { break; } } } if ch == Some('+') { loop { let (id, c) = match take_ident(rdr) { Some((id, c)) => (id, c), None => return None }; build.push(id); ch = c; if ch != Some('.') { break; } } } Some(Version { major: major, minor: minor, patch: patch, pre: pre, build: build, }) } #[cfg(test)] mod test { use super::{Version}; use super::ParseError::{IncorrectParse, GenericFailure}; use super::Identifier::{AlphaNumeric, Numeric}; #[test] fn test_parse() { assert_eq!(Version::parse(""), Err(GenericFailure)); assert_eq!(Version::parse(" "), Err(GenericFailure)); assert_eq!(Version::parse("1"), Err(GenericFailure)); assert_eq!(Version::parse("1.2"), Err(GenericFailure)); assert_eq!(Version::parse("1.2.3-"), Err(GenericFailure)); assert_eq!(Version::parse("a.b.c"), Err(GenericFailure)); let version = Version { major: 1, minor: 2, patch: 3, pre: vec!(), build: vec!(), }; let error = Err(IncorrectParse(version, "1.2.3 abc".to_string())); assert_eq!(Version::parse("1.2.3 abc"), error); assert!(Version::parse("1.2.3") == Ok(Version { major: 1, minor: 2, patch: 3, pre: vec!(), build: vec!(), })); assert!(Version::parse(" 1.2.3 ") == Ok(Version { major: 1, minor: 2, patch: 3, pre: vec!(), build: vec!(), })); assert!(Version::parse("1.2.3-alpha1") == Ok(Version { major: 1, minor: 2, patch: 3, pre: vec!(AlphaNumeric("alpha1".to_string())), build: vec!(), })); assert!(Version::parse(" 1.2.3-alpha1 ") == Ok(Version { major: 1, minor: 2, patch: 3, pre: vec!(AlphaNumeric("alpha1".to_string())), build: vec!() })); assert!(Version::parse("1.2.3+build5") == Ok(Version { major: 1, minor: 2, patch: 3, pre: vec!(), build: vec!(AlphaNumeric("build5".to_string())) })); assert!(Version::parse(" 1.2.3+build5 ") == Ok(Version { major: 1, minor: 2, patch: 3, pre: vec!(), build: vec!(AlphaNumeric("build5".to_string())) })); assert!(Version::parse("1.2.3-alpha1+build5") == Ok(Version { major: 1, minor: 2, patch: 3, pre: vec!(AlphaNumeric("alpha1".to_string())), build: vec!(AlphaNumeric("build5".to_string())) })); assert!(Version::parse(" 1.2.3-alpha1+build5 ") == Ok(Version { major: 1, minor: 2, patch: 3, pre: vec!(AlphaNumeric("alpha1".to_string())), build: vec!(AlphaNumeric("build5".to_string())) })); assert!(Version::parse("1.2.3-1.alpha1.9+build5.7.3aedf ") == Ok(Version { major: 1, minor: 2, patch: 3, pre: vec!(Numeric(1),AlphaNumeric("alpha1".to_string()),Numeric(9)), build: vec!(AlphaNumeric("build5".to_string()), Numeric(7), AlphaNumeric("3aedf".to_string())) })); assert_eq!(Version::parse("0.4.0-beta.1+0851523"), Ok(Version { major: 0, minor: 4, patch: 0, pre: vec![AlphaNumeric("beta".to_string()), Numeric(1)], build: vec![AlphaNumeric("0851523".to_string())], })); } #[test] fn test_increment_patch() { let mut buggy_release = Version::parse("0.1.0").unwrap(); buggy_release.increment_patch(); assert_eq!(buggy_release, Version::parse("0.1.1").unwrap()); } #[test] fn test_increment_minor() { let mut feature_release = Version::parse("1.4.6").unwrap(); feature_release.increment_minor(); assert_eq!(feature_release, Version::parse("1.5.0").unwrap()); } #[test] fn test_increment_major() { let mut chrome_release = Version::parse("46.1.246773").unwrap(); chrome_release.increment_major(); assert_eq!(chrome_release, Version::parse("47.0.0").unwrap()); } #[test] fn test_increment_keep_prerelease() { let mut release = Version::parse("1.0.0-alpha").unwrap(); release.increment_patch(); assert_eq!(release, Version::parse("1.0.1").unwrap()); release.increment_minor(); assert_eq!(release, Version::parse("1.1.0").unwrap()); release.increment_major(); assert_eq!(release, Version::parse("2.0.0").unwrap()); } #[test] fn test_increment_clear_metadata() { let mut release = Version::parse("1.0.0+4442").unwrap(); release.increment_patch(); assert_eq!(release, Version::parse("1.0.1").unwrap()); release = Version::parse("1.0.1+hello").unwrap(); release.increment_minor(); assert_eq!(release, Version::parse("1.1.0").unwrap()); release = Version::parse("1.1.3747+hello").unwrap(); release.increment_major(); assert_eq!(release, Version::parse("2.0.0").unwrap()); } #[test] fn test_eq() { assert_eq!(Version::parse("1.2.3"), Version::parse("1.2.3")); assert_eq!(Version::parse("1.2.3-alpha1"), Version::parse("1.2.3-alpha1")); assert_eq!(Version::parse("1.2.3+build.42"), Version::parse("1.2.3+build.42")); assert_eq!(Version::parse("1.2.3-alpha1+42"), Version::parse("1.2.3-alpha1+42")); assert_eq!(Version::parse("1.2.3+23"), Version::parse("1.2.3+42")); } #[test] fn test_ne() { assert!(Version::parse("0.0.0") != Version::parse("0.0.1")); assert!(Version::parse("0.0.0") != Version::parse("0.1.0")); assert!(Version::parse("0.0.0") != Version::parse("1.0.0")); assert!(Version::parse("1.2.3-alpha") != Version::parse("1.2.3-beta")); } #[test] fn test_show() { assert_eq!(format!("{}", Version::parse("1.2.3").unwrap()), "1.2.3".to_string()); assert_eq!(format!("{}", Version::parse("1.2.3-alpha1").unwrap()), "1.2.3-alpha1".to_string()); assert_eq!(format!("{}", Version::parse("1.2.3+build.42").unwrap()), "1.2.3+build.42".to_string()); assert_eq!(format!("{}", Version::parse("1.2.3-alpha1+42").unwrap()), "1.2.3-alpha1+42".to_string()); } #[test] fn test_to_string() { assert_eq!(Version::parse("1.2.3").unwrap().to_string(), "1.2.3".to_string()); assert_eq!(Version::parse("1.2.3-alpha1").unwrap().to_string(), "1.2.3-alpha1".to_string()); assert_eq!(Version::parse("1.2.3+build.42").unwrap().to_string(), "1.2.3+build.42".to_string()); assert_eq!(Version::parse("1.2.3-alpha1+42").unwrap().to_string(), "1.2.3-alpha1+42".to_string()); } #[test] fn test_lt() { assert!(Version::parse("0.0.0") < Version::parse("1.2.3-alpha2")); assert!(Version::parse("1.0.0") < Version::parse("1.2.3-alpha2")); assert!(Version::parse("1.2.0") < Version::parse("1.2.3-alpha2")); assert!(Version::parse("1.2.3-alpha1") < Version::parse("1.2.3")); assert!(Version::parse("1.2.3-alpha1") < Version::parse("1.2.3-alpha2")); assert!(!(Version::parse("1.2.3-alpha2") < Version::parse("1.2.3-alpha2"))); assert!(!(Version::parse("1.2.3+23") < Version::parse("1.2.3+42"))); } #[test] fn test_le() { assert!(Version::parse("0.0.0") <= Version::parse("1.2.3-alpha2")); assert!(Version::parse("1.0.0") <= Version::parse("1.2.3-alpha2")); assert!(Version::parse("1.2.0") <= Version::parse("1.2.3-alpha2")); assert!(Version::parse("1.2.3-alpha1") <= Version::parse("1.2.3-alpha2")); assert!(Version::parse("1.2.3-alpha2") <= Version::parse("1.2.3-alpha2")); assert!(Version::parse("1.2.3+23") <= Version::parse("1.2.3+42")); } #[test] fn test_gt() { assert!(Version::parse("1.2.3-alpha2") > Version::parse("0.0.0")); assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.0.0")); assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.0")); assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.3-alpha1")); assert!(Version::parse("1.2.3") > Version::parse("1.2.3-alpha2")); assert!(!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.3-alpha2"))); assert!(!(Version::parse("1.2.3+23") > Version::parse("1.2.3+42"))); } #[test] fn test_ge() { assert!(Version::parse("1.2.3-alpha2") >= Version::parse("0.0.0")); assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.0.0")); assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.0")); assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.3-alpha1")); assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.3-alpha2")); assert!(Version::parse("1.2.3+23") >= Version::parse("1.2.3+42")); } #[test] fn test_prerelease_check() { assert!(Version::parse("1.0.0").unwrap().is_prerelease() == false); assert!(Version::parse("0.0.1").unwrap().is_prerelease() == false); assert!(Version::parse("4.1.4-alpha").unwrap().is_prerelease()); assert!(Version::parse("1.0.0-beta294296").unwrap().is_prerelease()); } #[test] fn test_spec_order() { let vs = ["1.0.0-alpha", "1.0.0-alpha.1", "1.0.0-alpha.beta", "1.0.0-beta", "1.0.0-beta.2", "1.0.0-beta.11", "1.0.0-rc.1", "1.0.0"]; let mut i = 1; while i < vs.len() { let a = Version::parse(vs[i-1]).unwrap(); let b = Version::parse(vs[i]).unwrap(); assert!(a < b); i += 1; } } } deps/semver-0.2.0/src/lib.rs0000644000175000017500000001265312612001314012565 0ustar // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Semantic version parsing and comparison. //! //! Semantic versioning (see http://semver.org/) is a set of rules for //! assigning version numbers. //! //! ## SemVer overview //! //! Given a version number MAJOR.MINOR.PATCH, increment the: //! //! 1. MAJOR version when you make incompatible API changes, //! 2. MINOR version when you add functionality in a backwards-compatible //! manner, and //! 3. PATCH version when you make backwards-compatible bug fixes. //! //! Additional labels for pre-release and build metadata are available as //! extensions to the MAJOR.MINOR.PATCH format. //! //! Any references to 'the spec' in this documentation refer to [version 2.0 of //! the SemVer spec](http://semver.org/spec/v2.0.0.html). //! //! ## SemVer and the Rust ecosystem //! //! Rust itself follows the SemVer specification, as does its standard //! libraries. The two are not tied together. //! //! [Cargo](http://crates.io), Rust's package manager, uses SemVer to determine //! which versions of packages you need installed. //! //! ## Versions //! //! At its simplest, the `semver` crate allows you to construct `Version` //! objects using the `parse` method: //! //! ```{rust} //! use semver::Version; //! //! assert!(Version::parse("1.2.3") == Ok(Version { //! major: 1, //! minor: 2, //! patch: 3, //! pre: vec!(), //! build: vec!(), //! })); //! ``` //! //! If you have multiple `Version`s, you can use the usual comparison operators //! to compare them: //! //! ```{rust} //! use semver::Version; //! //! assert!(Version::parse("1.2.3-alpha") != Version::parse("1.2.3-beta")); //! assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.0")); //! ``` //! //! If you explicitly need to modify a Version, SemVer also allows you to //! increment the major, minor, and patch numbers in accordance with the spec. //! //! Please note that in order to do this, you must use a mutable Version: //! //! ```{rust} //! use semver::Version; //! //! let mut bugfix_release = Version::parse("1.0.0").unwrap(); //! bugfix_release.increment_patch(); //! //! assert_eq!(bugfix_release, Version::parse("1.0.1").unwrap()); //! ``` //! //! When incrementing the minor version number, the patch number resets to zero //! (in accordance with section 7 of the spec) //! //! ```{rust} //! use semver::Version; //! //! let mut feature_release = Version::parse("1.4.6").unwrap(); //! feature_release.increment_minor(); //! //! assert_eq!(feature_release, Version::parse("1.5.0").unwrap()); //! ``` //! //! Similarly, when incrementing the major version number, the patch and minor //! numbers reset to zero (in accordance with section 8 of the spec) //! //! ```{rust} //! use semver::Version; //! //! let mut chrome_release = Version::parse("41.5.5377").unwrap(); //! chrome_release.increment_major(); //! //! assert_eq!(chrome_release, Version::parse("42.0.0").unwrap()); //! ``` //! //! ## Requirements //! //! The `semver` crate also provides the ability to compare requirements, which //! are more complex comparisons. //! //! For example, creating a requirement that only matches versions greater than //! or equal to 1.0.0: //! //! ```{rust} //! # #![allow(unstable)] //! use semver::Version; //! use semver::VersionReq; //! //! let r = VersionReq::parse(">= 1.0.0").unwrap(); //! let v = Version::parse("1.0.0").unwrap(); //! //! assert!(r.to_string() == ">= 1.0.0".to_string()); //! assert!(r.matches(&v)) //! ``` //! //! It also allows parsing of `~x.y.z` and `^x.y.z` requirements as defined at //! https://www.npmjs.org/doc/misc/semver.html //! //! **Tilde requirements** specify a minimal version with some updates: //! //! ```notrust //! ~1.2.3 := >=1.2.3 <1.3.0 //! ~1.2 := >=1.2.0 <1.3.0 //! ~1 := >=1.0.0 <2.0.0 //! ``` //! //! **Caret requirements** allow SemVer compatible updates to a specified //! verion, `0.x` and `0.x+1` are not considered compatible, but `1.x` and //! `1.x+1` are. //! //! `0.0.x` is not considered compatible with any other version. //! Missing minor and patch versions are desugared to `0` but allow flexibility //! for that value. //! //! ```notrust //! ^1.2.3 := >=1.2.3 <2.0.0 //! ^0.2.3 := >=0.2.3 <0.3.0 //! ^0.0.3 := >=0.0.3 <0.0.4 //! ^0.0 := >=0.0.0 <0.1.0 //! ^0 := >=0.0.0 <1.0.0 //! ``` //! //! **Wildcard requirements** allows parsing of version requirements of the //! formats `*`, `x.*` and `x.y.*`. //! //! ```notrust //! * := >=0.0.0 //! 1.* := >=1.0.0 <2.0.0 //! 1.2.* := >=1.2.0 <1.3.0 //! ``` #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://www.rust-lang.org/favicon.ico")] #![deny(missing_docs)] #![cfg_attr(test, deny(warnings))] // We take the common approach of keeping our own module system private, and // just re-exporting the interface that we want. pub use version::{Version, Identifier, ParseError}; pub use version::Identifier::{Numeric, AlphaNumeric}; pub use version_req::{VersionReq, ReqParseError}; // SemVer-compliant versions. mod version; // advanced version comparisons mod version_req; deps/semver-0.2.0/src/version_req.rs0000644000175000017500000006160512612001314014354 0ustar // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::error::Error; use std::fmt; use std::str::CharIndices; use super::version::Version; use self::VersionComponent::{NumericVersionComponent, WildcardVersionComponent}; use self::Op::{Ex, Gt, GtEq, Lt, LtEq, Tilde, Compatible, Wildcard}; use self::LexState::{LexInit, LexStart, LexVersionComponent, LexSigil, LexErr}; use self::Token::{Sigil, AlphaNum, Comma, Dot}; use self::WildcardVersion::{Major, Minor, Patch}; use self::ReqParseError::{ InvalidVersionRequirement, OpAlreadySet, InvalidSigil, VersionComponentsMustBeNumeric, MajorVersionRequired, UnimplementedVersionRequirement }; /// A `VersionReq` is a struct containing a list of predicates that can apply to ranges of version /// numbers. Matching operations can then be done with the `VersionReq` against a particular /// version to see if it satisfies some or all of the constraints. #[derive(PartialEq,Clone,Debug)] pub struct VersionReq { predicates: Vec } enum VersionComponent { NumericVersionComponent(u64), WildcardVersionComponent } #[derive(Clone, PartialEq, Debug)] enum WildcardVersion { Major, Minor, Patch } #[derive(PartialEq,Clone,Debug)] enum Op { Ex, // Exact Gt, // Greater than GtEq, // Greater than or equal to Lt, // Less than LtEq, // Less than or equal to Tilde, // e.g. ~1.0.0 Compatible, // compatible by definition of semver, indicated by ^ Wildcard(WildcardVersion), // x.y.*, x.*, * } #[derive(PartialEq,Clone,Debug)] struct Predicate { op: Op, major: u64, minor: Option, patch: Option } struct PredBuilder { op: Option, major: Option, minor: Option, patch: Option } /// A `ReqParseError` is returned from methods which parse a string into a `VersionReq`. Each /// enumeration is one of the possible errors that can occur. #[derive(Copy, Clone, Debug, PartialEq)] pub enum ReqParseError { /// The given version requirement is invalid. InvalidVersionRequirement, /// You have already provided an operation, such as `=`, `~`, or `^`. Only use one. OpAlreadySet, /// The sigil you have written is not correct. InvalidSigil, /// All components of a version must be numeric. VersionComponentsMustBeNumeric, /// At least a major version is required. MajorVersionRequired, /// An unimplemented version requirement. UnimplementedVersionRequirement, } impl fmt::Display for ReqParseError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.description().fmt(f) } } impl Error for ReqParseError { fn description(&self) -> &str { match *self { InvalidVersionRequirement => "the given version requirement is invalid", OpAlreadySet => "you have already provided an operation, such as =, ~, or ^; only use one", InvalidSigil => "the sigil you have written is not correct", VersionComponentsMustBeNumeric => "version components must be numeric", MajorVersionRequired => "at least a major version number is required", UnimplementedVersionRequirement => "the given version requirement is not implemented, yet", } } } impl VersionReq { /// `any()` is a factory method which creates a `VersionReq` with no constraints. In other /// words, any version will match against it. /// /// # Examples /// /// ``` /// use semver::VersionReq; /// /// let anything = VersionReq::any(); /// ``` pub fn any() -> VersionReq { VersionReq { predicates: vec!() } } /// `parse()` is the main constructor of a `VersionReq`. It turns a string like `"^1.2.3"` /// and turns it into a `VersionReq` that matches that particular constraint. /// /// A `Result` is returned which contains a `ReqParseError` if there was a problem parsing the /// `VersionReq`. /// /// # Examples /// /// ``` /// use semver::VersionReq; /// /// let version = VersionReq::parse("=1.2.3"); /// let version = VersionReq::parse(">1.2.3"); /// let version = VersionReq::parse("<1.2.3"); /// let version = VersionReq::parse("~1.2.3"); /// let version = VersionReq::parse("^1.2.3"); /// let version = VersionReq::parse("<=1.2.3"); /// let version = VersionReq::parse(">=1.2.3"); /// ``` /// /// This example demonstrates error handling, and will panic. /// /// ```should-panic /// use semver::VersionReq; /// /// let version = match VersionReq::parse("not a version") { /// Ok(version) => version, /// Err(e) => panic!("There was a problem parsing: {}", e), /// } /// ``` pub fn parse(input: &str) -> Result { let mut lexer = Lexer::new(input); let mut builder = PredBuilder::new(); let mut predicates = Vec::new(); for token in lexer.by_ref() { let result = match token { Sigil(x) => builder.set_sigil(x), AlphaNum(x) => builder.set_version_part(x), Dot => Ok(()), // Nothing to do for now Comma => { let result = builder.build().map(|p| predicates.push(p)); builder = PredBuilder::new(); result } }; match result { Ok(_) => (), Err(e) => return Err(e), } } if lexer.is_error() { return Err(InvalidVersionRequirement); } match builder.build() { Ok(e) => predicates.push(e), Err(e) => return Err(e), } Ok(VersionReq { predicates: predicates }) } /// `exact()` is a factory method which creates a `VersionReq` with one exact constraint. /// /// # Examples /// /// ``` /// use semver::VersionReq; /// use semver::Version; /// /// let version = Version { major: 1, minor: 1, patch: 1, pre: vec![], build: vec![] }; /// let exact = VersionReq::exact(&version); /// ``` pub fn exact(version: &Version) -> VersionReq { VersionReq { predicates: vec!(Predicate::exact(version)) } } /// `matches()` matches a given `Version` against this `VersionReq`. /// /// # Examples /// /// ``` /// use semver::VersionReq; /// use semver::Version; /// /// let version = Version { major: 1, minor: 1, patch: 1, pre: vec![], build: vec![] }; /// let exact = VersionReq::exact(&version); /// /// assert!(exact.matches(&version)); /// ``` pub fn matches(&self, version: &Version) -> bool { self.predicates.iter().all(|p| p.matches(version)) } } impl Predicate { fn exact(version: &Version) -> Predicate { Predicate { op: Ex, major: version.major, minor: Some(version.minor), patch: Some(version.patch) } } /// `matches()` takes a `Version` and determines if it matches this particular `Predicate`. pub fn matches(&self, ver: &Version) -> bool { match self.op { Ex => self.is_exact(ver), Gt => self.is_greater(ver), GtEq => self.is_exact(ver) || self.is_greater(ver), Lt => !self.is_exact(ver) && !self.is_greater(ver), LtEq => !self.is_greater(ver), Tilde => self.matches_tilde(ver), Compatible => self.is_compatible(ver), Wildcard(_) => self.matches_wildcard(ver) } } fn is_exact(&self, ver: &Version) -> bool { if self.major != ver.major { return false; } match self.minor { Some(minor) => { if minor != ver.minor { return false; } } None => return true } match self.patch { Some(patch) => { if patch != ver.patch { return false; } } None => return true } true } fn is_greater(&self, ver: &Version) -> bool { if self.major != ver.major { return ver.major > self.major; } match self.minor { Some(minor) => { if minor != ver.minor { return ver.minor > minor } } None => return false } match self.patch { Some(patch) => { if patch != ver.patch { return ver.patch > patch } } None => return false } false } // see https://www.npmjs.org/doc/misc/semver.html for behavior fn matches_tilde(&self, ver: &Version) -> bool { let minor = match self.minor { Some(n) => n, None => return self.major == ver.major }; match self.patch { Some(patch) => { self.major == ver.major && minor == ver.minor && ver.patch >= patch } None => { self.major == ver.major && minor == ver.minor } } } // see https://www.npmjs.org/doc/misc/semver.html for behavior fn is_compatible(&self, ver: &Version) -> bool { if self.major != ver.major { return false; } let minor = match self.minor { Some(n) => n, None => return self.major == ver.major }; match self.patch { Some(patch) => if self.major == 0 { if minor == 0 { ver.minor == minor && ver.patch == patch } else { ver.minor == minor && ver.patch >= patch } } else { ver.minor > minor || (ver.minor == minor && ver.patch >= patch) }, None => if self.major == 0 { ver.minor == minor } else { ver.minor >= minor } } } // see https://www.npmjs.org/doc/misc/semver.html for behavior fn matches_wildcard(&self, ver: &Version) -> bool { match self.op { Wildcard(Major) => true, Wildcard(Minor) => self.major == ver.major, Wildcard(Patch) => { match self.minor { Some(minor) => self.major == ver.major && minor == ver.minor, None => false // unreachable } } _ => false // unreachable } } } impl PredBuilder { fn new() -> PredBuilder { PredBuilder { op: None, major: None, minor: None, patch: None } } fn set_sigil(&mut self, sigil: &str) -> Result<(), ReqParseError> { if self.op.is_some() { return Err(OpAlreadySet); } match Op::from_sigil(sigil) { Some(op) => self.op = Some(op), _ => return Err(InvalidSigil), } Ok(()) } fn set_version_part(&mut self, part: &str) -> Result<(), ReqParseError> { if self.op.is_none() { // If no op is specified, then the predicate is an exact match on // the version self.op = Some(Compatible); } if self.major.is_none() { match parse_version_part(part) { Ok(NumericVersionComponent(e)) => self.major = Some(e), Ok(WildcardVersionComponent) => { self.major = Some(0); self.op = Some(Wildcard(Major)) } Err(e) => return Err(e), } } else if self.minor.is_none() { match parse_version_part(part) { Ok(NumericVersionComponent(e)) => self.minor = Some(e), Ok(WildcardVersionComponent) => self.op = Some(Wildcard(Minor)), Err(e) => return Err(e), } } else if self.patch.is_none() { match parse_version_part(part) { Ok(NumericVersionComponent(e)) => self.patch = Some(e), Ok(WildcardVersionComponent) => self.op = Some(Wildcard(Patch)), Err(e) => return Err(e), } } Ok(()) } /// Validates that a version predicate can be created given the present /// information. fn build(&self) -> Result { let op = match self.op { Some(ref x) => x.clone(), None => return Err(InvalidVersionRequirement), }; let major = match self.major { Some(x) => x, None => return Err(MajorVersionRequired), }; Ok(Predicate { op: op, major: major, minor: self.minor, patch: self.patch }) } } struct Lexer<'a> { c: char, idx: usize, iter: CharIndices<'a>, mark: Option, input: &'a str, state: LexState } #[derive(Copy, Clone, Debug, PartialEq)] enum LexState { LexInit, LexStart, LexVersionComponent, LexSigil, LexErr, } #[derive(Debug)] enum Token<'a> { Sigil(&'a str), AlphaNum(&'a str), Comma, Dot } impl<'a> Lexer<'a> { fn new(input: &'a str) -> Lexer<'a> { Lexer { c: '\0', idx: 0, iter: input.char_indices(), mark: None, input: input, state: LexInit } } fn is_error(&self) -> bool { self.state == LexErr } fn mark(&mut self, at: usize) { self.mark = Some(at) } fn flush(&mut self, to: usize, kind: LexState) -> Option> { match self.mark { Some(mark) => { if to <= mark { return None; } let s = &self.input[mark..to]; self.mark = None; match kind { LexVersionComponent => Some(AlphaNum(s)), LexSigil => Some(Sigil(s)), _ => None // bug } } None => None } } } impl<'a> Iterator for Lexer<'a> { type Item = Token<'a>; fn next(&mut self) -> Option> { let mut c; let mut idx = 0; macro_rules! next { () => ( match self.iter.next() { Some((n_idx, n_char)) => { c = n_char; idx = n_idx; } _ => { let s = self.state; return self.flush(idx + 1, s) } } ) } macro_rules! flush { ($s:expr) => ({ self.c = c; self.idx = idx; self.flush(idx, $s) }) } if self.state == LexInit { self.state = LexStart; next!(); } else { c = self.c; idx = self.idx; } loop { match self.state { LexStart => { if c.is_whitespace() { next!(); // Ignore } else if c.is_alphanumeric() || c == '*' { self.mark(idx); self.state = LexVersionComponent; next!(); } else if is_sigil(c) { self.mark(idx); self.state = LexSigil; next!(); } else if c == '.' { self.state = LexInit; return Some(Dot); } else if c == ',' { self.state = LexInit; return Some(Comma); } else { self.state = LexErr; return None; } } LexVersionComponent => { if c.is_alphanumeric() { next!(); } else { self.state = LexStart; return flush!(LexVersionComponent); } } LexSigil => { if is_sigil(c) { next!(); } else { self.state = LexStart; return flush!(LexSigil); } } LexErr => return None, LexInit => return None // bug } } } } impl Op { fn from_sigil(sigil: &str) -> Option { match sigil { "=" => Some(Ex), ">" => Some(Gt), ">=" => Some(GtEq), "<" => Some(Lt), "<=" => Some(LtEq), "~" => Some(Tilde), "^" => Some(Compatible), _ => None } } } fn parse_version_part(s: &str) -> Result { let mut ret = 0; if s == "*" { return Ok(WildcardVersionComponent) } for c in s.chars() { let n = (c as u64) - ('0' as u64); if n > 9 { return Err(VersionComponentsMustBeNumeric); } ret *= 10; ret += n; } Ok(NumericVersionComponent(ret)) } fn is_sigil(c: char) -> bool { match c { '>' | '<' | '=' | '~' | '^' => true, _ => false } } impl fmt::Display for VersionReq { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { if self.predicates.is_empty() { try!(write!(fmt, "*")); } else { for (i, ref pred) in self.predicates.iter().enumerate() { if i == 0 { try!(write!(fmt, "{}", pred)); } else { try!(write!(fmt, ", {}", pred)); } } } Ok(()) } } impl fmt::Display for Predicate { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match self.op { Wildcard(Major) => try!(write!(fmt, "*")), Wildcard(Minor) => try!(write!(fmt, "{}.*", self.major)), Wildcard(Patch) => try!(write!(fmt, "{}.{}.*", self.major, self.minor.unwrap())), _ => { try!(write!(fmt, "{}{}", self.op, self.major)); match self.minor { Some(v) => try!(write!(fmt, ".{}", v)), None => () } match self.patch { Some(v) => try!(write!(fmt, ".{}", v)), None => () } }, } Ok(()) } } impl fmt::Display for Op { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match *self { Ex => try!(write!(fmt, "= ")), Gt => try!(write!(fmt, "> ")), GtEq => try!(write!(fmt, ">= ")), Lt => try!(write!(fmt, "< ")), LtEq => try!(write!(fmt, "<= ")), Tilde => try!(write!(fmt, "~")), Compatible => try!(write!(fmt, "^")), // gets handled specially in Predicate::fmt Wildcard(_) => try!(write!(fmt, "")), } Ok(()) } } #[cfg(test)] mod test { use super::VersionReq; use super::super::version::Version; use super::ReqParseError::{ InvalidVersionRequirement, OpAlreadySet, InvalidSigil, VersionComponentsMustBeNumeric, MajorVersionRequired, }; fn req(s: &str) -> VersionReq { VersionReq::parse(s).unwrap() } fn version(s: &str) -> Version { match Version::parse(s) { Ok(v) => v, Err(e) => panic!("`{}` is not a valid version. Reason: {}", s, e) } } fn assert_match(req: &VersionReq, vers: &[&str]) { for ver in vers.iter() { assert!(req.matches(&version(*ver)), "did not match {}", ver); } } fn assert_not_match(req: &VersionReq, vers: &[&str]) { for ver in vers.iter() { assert!(!req.matches(&version(*ver)), "matched {}", ver); } } #[test] fn test_parsing_default() { let r = req("1.0.0"); assert_eq!(r.to_string(), "^1.0.0".to_string()); assert_match(&r, &["1.0.0", "1.0.1"]); assert_not_match(&r, &["0.9.9", "0.10.0", "0.1.0"]); } #[test] fn test_parsing_exact() { let r = req("=1.0.0"); assert!(r.to_string() == "= 1.0.0".to_string()); assert_eq!(r.to_string(), "= 1.0.0".to_string()); assert_match(&r, &["1.0.0"]); assert_not_match(&r, &["1.0.1", "0.9.9", "0.10.0", "0.1.0"]); let r = req("=0.9.0"); assert_eq!(r.to_string(), "= 0.9.0".to_string()); assert_match(&r, &["0.9.0"]); assert_not_match(&r, &["0.9.1", "1.9.0", "0.0.9"]); } #[test] pub fn test_parsing_greater_than() { let r = req(">= 1.0.0"); assert_eq!(r.to_string(), ">= 1.0.0".to_string()); assert_match(&r, &["1.0.0"]); } #[test] pub fn test_multiple() { let r = req("> 0.0.9, <= 2.5.3"); assert_eq!(r.to_string(), "> 0.0.9, <= 2.5.3".to_string()); assert_match(&r, &["0.0.10", "1.0.0", "2.5.3"]); assert_not_match(&r, &["0.0.8", "2.5.4"]); let r = req("0.3.0, 0.4.0"); assert_eq!(r.to_string(), "^0.3.0, ^0.4.0".to_string()); assert_not_match(&r, &["0.0.8", "0.3.0", "0.4.0"]); let r = req("<= 0.2.0, >= 0.5.0"); assert_eq!(r.to_string(), "<= 0.2.0, >= 0.5.0".to_string()); assert_not_match(&r, &["0.0.8", "0.3.0", "0.5.1"]); let r = req("0.1.0, 0.1.4, 0.1.6"); assert_eq!(r.to_string(), "^0.1.0, ^0.1.4, ^0.1.6".to_string()); assert_match(&r, &["0.1.6", "0.1.9"]); assert_not_match(&r, &["0.1.0", "0.1.4", "0.2.0"]); assert!(VersionReq::parse("> 0.1.0,").is_err()); assert!(VersionReq::parse("> 0.3.0, ,").is_err()); } #[test] pub fn test_parsing_tilde() { let r = req("~1"); assert_match(&r, &["1.0.0", "1.0.1", "1.1.1"]); assert_not_match(&r, &["0.9.1", "2.9.0", "0.0.9"]); let r = req("~1.2"); assert_match(&r, &["1.2.0", "1.2.1"]); assert_not_match(&r, &["1.1.1", "1.3.0", "0.0.9"]); let r = req("~1.2.2"); assert_match(&r, &["1.2.2", "1.2.4"]); assert_not_match(&r, &["1.2.1", "1.9.0", "1.0.9", "2.0.1", "0.1.3"]); } #[test] pub fn test_parsing_compatible() { let r = req("^1"); assert_match(&r, &["1.1.2", "1.1.0", "1.2.1", "1.0.1"]); assert_not_match(&r, &["0.9.1", "2.9.0", "0.1.4"]); let r = req("^1.1"); assert_match(&r, &["1.1.2", "1.1.0", "1.2.1"]); assert_not_match(&r, &["0.9.1", "2.9.0", "1.0.1", "0.1.4"]); let r = req("^1.1.2"); assert_match(&r, &["1.1.2", "1.1.4", "1.2.1"]); assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1"]); let r = req("^0.1.2"); assert_match(&r, &["0.1.2", "0.1.4"]); assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1"]); let r = req("^0.0.2"); assert_match(&r, &["0.0.2"]); assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1", "0.1.4"]); let r = req("^0.0"); assert_match(&r, &["0.0.2", "0.0.0"]); assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.1.4"]); let r = req("^0"); assert_match(&r, &["0.9.1", "0.0.2", "0.0.0"]); assert_not_match(&r, &["2.9.0", "1.1.1"]); } #[test] pub fn test_parsing_wildcard() { let r = req("*"); assert_match(&r, &["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"]); assert_not_match(&r, &[]); let r = req("1.*"); assert_match(&r, &["1.2.0", "1.2.1", "1.1.1", "1.3.0"]); assert_not_match(&r, &["0.0.9"]); let r = req("1.2.*"); assert_match(&r, &["1.2.0", "1.2.2", "1.2.4"]); assert_not_match(&r, &["1.9.0", "1.0.9", "2.0.1", "0.1.3"]); } #[test] pub fn test_parse_errors() { assert_eq!(Err(InvalidVersionRequirement), VersionReq::parse("0-0.1")); assert_eq!(Err(OpAlreadySet), VersionReq::parse(">= >= 0.0.2")); assert_eq!(Err(InvalidSigil), VersionReq::parse(">== 0.0.2")); assert_eq!(Err(VersionComponentsMustBeNumeric), VersionReq::parse("a.0.0")); assert_eq!(Err(MajorVersionRequired), VersionReq::parse(">=")); } /* TODO: * - Handle pre releases */ } deps/semver-0.2.0/Cargo.toml0000644000175000017500000000057412612003312012611 0ustar [package] name = "semver" version = "0.2.0" authors = ["Steve Klabnik ", "The Rust Project Developers"] license = "MIT/Apache-2.0" repository = "https://github.com/steveklabnik/semver" homepage = "https://github.com/steveklabnik/semver" documentation = "http://steveklabnik.github.io/semver" description = """ Semantic version parsing and comparison. """ deps/flate2-0.2.11/0000755000000000000000000000000012666635520012414 5ustar rootrootdeps/flate2-0.2.11/LICENSE-APACHE0000664000175000017500000002513712401655646012572 0ustar Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/flate2-0.2.11/LICENSE-MIT0000664000175000017500000000204112401655774012271 0ustar Copyright (c) 2014 Alex Crichton Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/flate2-0.2.11/.travis.yml0000664000175000017500000000134012572107347012744 0ustar language: rust rust: - 1.0.0 - beta - nightly sudo: false before_script: - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH script: - export CARGO_TARGET_DIR=`pwd`/target - cargo build --verbose - cargo test --verbose - rustdoc --test README.md -L target/debug -L target/debug/deps - cargo doc --no-deps - cargo doc --no-deps --manifest-path=miniz-sys/Cargo.toml after_success: - travis-cargo --only nightly doc-upload env: global: secure: tnY9uOzb+59QyxPwOkj64dYLhytJGEXCo3uMvlbFtBpNJ6B2bN+lFDLaILbki1xkIg6DOFLGGT0+2qLI295V8BgEOqs/bU1WNNTjCdIqhbYI+HrwPP2RocecIXCIrsmL7tVSqfdLnU8RCoS0CBvJOwX/f813UGn3yAP4k5l7K/U= notifications: email: on_success: never os: - linux - osx deps/flate2-0.2.11/README.md0000664000175000017500000000254212520214373012106 0ustar # flate2 [![Build Status](https://travis-ci.org/alexcrichton/flate2-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/flate2-rs) [![Build status](https://ci.appveyor.com/api/projects/status/9tatexq47i3ee13k?svg=true)](https://ci.appveyor.com/project/alexcrichton/flate2-rs) [Documentation](http://alexcrichton.com/flate2-rs/flate2/index.html) A streaming compression/decompression library for rust with bindings to [`miniz`](https://code.google.com/p/miniz/) Supported formats: * deflate * zlib * gzip ```toml # Cargo.toml [dependencies] flate2 = "0.2" ``` ## Compression ```rust extern crate flate2; use std::io::prelude::*; use flate2::Compression; use flate2::write::ZlibEncoder; fn main() { let mut e = ZlibEncoder::new(Vec::new(), Compression::Default); e.write(b"foo"); e.write(b"bar"); let compressed_bytes = e.finish(); } ``` ## Decompression ```rust,no_run extern crate flate2; use std::io::prelude::*; use flate2::read::GzDecoder; fn main() { let mut d = GzDecoder::new("...".as_bytes()).unwrap(); let mut s = String::new(); d.read_to_string(&mut s).unwrap(); println!("{}", s); } ``` # License `flate2-rs` is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses. See LICENSE-APACHE, and LICENSE-MIT for details. deps/flate2-0.2.11/.gitignore0000664000175000017500000000002212464714664012625 0ustar target Cargo.lock deps/flate2-0.2.11/src/0000755000000000000000000000000012666635520013203 5ustar rootrootdeps/flate2-0.2.11/src/lib.rs0000664000175000017500000001376012614575412012546 0ustar //! A DEFLATE-based stream compression/decompression library //! //! This library is meant to supplement/replace the standard distributon's //! libflate library by providing a streaming encoder/decoder rather than purely //! in in-memory encoder/decoder. //! //! Like with libflate, flate2 is based on [`miniz.c`][1] //! //! [1]: https://code.google.com/p/miniz/ //! //! # Organization //! //! This crate consists mainly of two modules, `reader` and `writer`. Each //! module contains a number of types used to encode and decode various streams //! of data. All types in the `writer` module work on instances of `Writer`, //! whereas all types in the `reader` module work on instances of `Reader`. //! //! Other various types are provided at the top-level of the crate for //! mangement and dealing with encoders/decoders. //! //! # Helper traits //! //! There are two helper traits, provided, `FlateReader` and `FlateWriter`. //! These provide convenience methods for creating a decoder/encoder out of an //! already existing stream to chain construction. #![doc(html_root_url = "http://alexcrichton.com/flate2-rs")] #![deny(missing_docs)] #![allow(trivial_numeric_casts)] #![cfg_attr(test, deny(warnings))] extern crate libc; extern crate miniz_sys as ffi; #[cfg(test)] extern crate rand; use std::io::prelude::*; use std::io; pub use gz::Builder as GzBuilder; pub use gz::Header as GzHeader; pub use mem::{Compress, Decompress, DataError, Status}; pub use stream::Flush; mod crc; mod deflate; mod gz; mod raw; mod stream; mod zlib; mod mem; /// Types which operate over `Reader` streams, both encoders and decoders for /// various formats. pub mod read { pub use deflate::EncoderReader as DeflateEncoder; pub use deflate::DecoderReader as DeflateDecoder; pub use zlib::EncoderReader as ZlibEncoder; pub use zlib::DecoderReader as ZlibDecoder; pub use gz::EncoderReader as GzEncoder; pub use gz::DecoderReader as GzDecoder; } /// Types which operate over `Writer` streams, both encoders and decoders for /// various formats. pub mod write { pub use deflate::EncoderWriter as DeflateEncoder; pub use deflate::DecoderWriter as DeflateDecoder; pub use zlib::EncoderWriter as ZlibEncoder; pub use zlib::DecoderWriter as ZlibDecoder; pub use gz::EncoderWriter as GzEncoder; } /// When compressing data, the compression level can be specified by a value in /// this enum. #[derive(Copy, Clone)] pub enum Compression { /// No compression is to be performed, this may actually inflate data /// slightly when encoding. None = 0, /// Optimize for the best speed of encoding. Fast = 1, /// Optimize for the size of data being encoded. Best = 9, /// Choose the default compression, a balance between speed and size. Default = 6, } /// A helper trait to create encoder/decoders with method syntax. pub trait FlateReadExt: Read + Sized { /// Consume this reader to create a compression stream at the specified /// compression level. fn gz_encode(self, lvl: Compression) -> read::GzEncoder { read::GzEncoder::new(self, lvl) } /// Consume this reader to create a decompression stream of this stream. fn gz_decode(self) -> io::Result> { read::GzDecoder::new(self) } /// Consume this reader to create a compression stream at the specified /// compression level. fn zlib_encode(self, lvl: Compression) -> read::ZlibEncoder { read::ZlibEncoder::new(self, lvl) } /// Consume this reader to create a decompression stream of this stream. fn zlib_decode(self) -> read::ZlibDecoder { read::ZlibDecoder::new(self) } /// Consume this reader to create a compression stream at the specified /// compression level. fn deflate_encode(self, lvl: Compression) -> read::DeflateEncoder { read::DeflateEncoder::new(self, lvl) } /// Consume this reader to create a decompression stream of this stream. fn deflate_decode(self) -> read::DeflateDecoder { read::DeflateDecoder::new(self) } } /// A helper trait to create encoder/decoders with method syntax. pub trait FlateWriteExt: Write + Sized { /// Consume this writer to create a compression stream at the specified /// compression level. fn gz_encode(self, lvl: Compression) -> write::GzEncoder { write::GzEncoder::new(self, lvl) } // TODO: coming soon to a theater near you! // /// Consume this writer to create a decompression stream of this stream. // fn gz_decode(self) -> IoResult> { // write::GzDecoder::new(self) // } /// Consume this writer to create a compression stream at the specified /// compression level. fn zlib_encode(self, lvl: Compression) -> write::ZlibEncoder { write::ZlibEncoder::new(self, lvl) } /// Consume this writer to create a decompression stream of this stream. fn zlib_decode(self) -> write::ZlibDecoder { write::ZlibDecoder::new(self) } /// Consume this writer to create a compression stream at the specified /// compression level. fn deflate_encode(self, lvl: Compression) -> write::DeflateEncoder { write::DeflateEncoder::new(self, lvl) } /// Consume this writer to create a decompression stream of this stream. fn deflate_decode(self) -> write::DeflateDecoder { write::DeflateDecoder::new(self) } } impl FlateReadExt for T {} impl FlateWriteExt for T {} #[cfg(test)] mod test { use std::io::prelude::*; use {FlateReadExt, Compression}; #[test] fn crazy() { let rdr = &mut b"foobar"; let mut res = Vec::new(); rdr.gz_encode(Compression::Default) .deflate_encode(Compression::Default) .zlib_encode(Compression::Default) .zlib_decode() .deflate_decode() .gz_decode() .unwrap() .read_to_end(&mut res) .unwrap(); assert_eq!(res, b"foobar"); } } deps/flate2-0.2.11/src/mem.rs0000664000175000017500000001762112614575412012556 0ustar use libc::c_int; use {Compression, Flush}; use ffi; use stream::{self, Stream}; /// Raw in-memory compression stream for blocks of data. /// /// This type is the building block for the I/O streams in the rest of this /// crate. It requires more management than the `Read`/`Write` API but is /// maximally flexible in terms of accepting input from any source and being /// able to produce output to any memory location. /// /// It is recommended to use the I/O stream adaptors over this type as they're /// easier to use. pub struct Compress { inner: Stream, } /// Raw in-memory decompression stream for blocks of data. /// /// This type is the building block for the I/O streams in the rest of this /// crate. It requires more management than the `Read`/`Write` API but is /// maximally flexible in terms of accepting input from any source and being /// able to produce output to any memory location. /// /// It is recommended to use the I/O stream adaptors over this type as they're /// easier to use. pub struct Decompress { inner: Stream, } /// Error returned when a decompression object finds that the input stream of /// bytes was not a valid input stream of bytes. pub struct DataError(()); /// Possible status results of compressing some data or successfully /// decompressing a block of data. pub enum Status { /// Indicates success. /// /// Means that more input may be needed but isn't available /// and/or there' smore output to be written but the output buffer is full. Ok, /// Indicates that forward progress is not possible due to input or output /// buffers being empty. /// /// For compression it means the input buffer needs some more data or the /// output buffer needs to be freed up before trying again. /// /// For decompression this means that more input is needed to continue or /// the output buffer isn't large enough to contain the result. The function /// can be called again after fixing both. BufError, /// Indicates that all input has been consumed and all output bytes have /// been written. Decompression/compression should not be called again. /// /// For decompression with zlib streams the adler-32 of the decompressed /// data has also been verified. StreamEnd, } impl Compress { /// Creates a new object ready for compressing data that it's given. /// /// The `level` argument here indicates what level of compression is going /// to be performed, and the `zlib_header` argument indicates whether the /// output data should have a zlib header or not. pub fn new(level: Compression, zlib_header: bool) -> Compress { Compress { inner: Stream::new_compress(level, !zlib_header) } } /// Returns the total number of input bytes which have been processed by /// this compression object. pub fn total_in(&self) -> u64 { self.inner.total_in() } /// Returns the total number of output bytes which have been produced by /// this compression object. pub fn total_out(&self) -> u64 { self.inner.total_out() } /// Quickly resets this compressor without having to reallocate anything. /// /// This is equivalent to dropping this object and then creating a new one. pub fn reset(&mut self) { assert_eq!(self.inner.reset(), ffi::MZ_OK); } /// Compresses the input data into the output, consuming only as much /// input as needed and writing as much output as possible. /// /// The flush option can be any of the available flushing parameters. /// /// To learn how much data was consumed or how much output was produced, use /// the `total_in` and `total_out` functions before/after this is called. pub fn compress(&mut self, input: &[u8], output: &mut [u8], flush: Flush) -> Status { let rc = self.inner.compress(input, output, flush); self.rc(rc) } /// Compresses the input data into the extra space of the output, consuming /// only as much input as needed and writing as much output as possible. /// /// This function has the same semantics as `compress`, except that the /// length of `vec` is managed by this function. This will not reallocate /// the vector provided or attempt to grow it, so space for the output must /// be reserved in the output vector by the caller before calling this /// function. pub fn compress_vec(&mut self, input: &[u8], output: &mut Vec, flush: Flush) -> Status { let rc = self.inner.compress_vec(input, output, flush); self.rc(rc) } fn rc(&self, rc: c_int) -> Status { match rc { ffi::MZ_OK => Status::Ok, ffi::MZ_BUF_ERROR => Status::BufError, ffi::MZ_STREAM_END => Status::StreamEnd, c => panic!("unknown return code: {}", c), } } } impl Decompress { /// Creates a new object ready for decompressing data that it's given. /// /// The `zlib_header` argument indicates whether the input data is expected /// to have a zlib header or not. pub fn new(zlib_header: bool) -> Decompress { Decompress { inner: Stream::new_decompress(!zlib_header) } } /// Returns the total number of input bytes which have been processed by /// this decompression object. pub fn total_in(&self) -> u64 { self.inner.total_in() } /// Returns the total number of output bytes which have been produced by /// this decompression object. pub fn total_out(&self) -> u64 { self.inner.total_out() } /// Decompresses the input data into the output, consuming only as much /// input as needed and writing as much output as possible. /// /// The flush option provided can either be `Flush::None`, `Flush::Sync`, /// or `Flush::Finish`. If the first call passes `Flush::Finish` it is /// assumed that the input and output buffers are both sized large enough to /// decompress the entire stream in a single call. /// /// A flush value of `Flush::Finish` indicates that there are no more source /// bytes available beside what's already in the input buffer, and the /// output buffer is large enough to hold the rest of the decompressed data. /// /// To learn how much data was consumed or how much output was produced, use /// the `total_in` and `total_out` functions before/after this is called. pub fn decompress(&mut self, input: &[u8], output: &mut [u8], flush: Flush) -> Result { let rc = self.inner.decompress(input, output, flush); self.rc(rc) } /// Decompresses the input data into the extra space in the output vector /// specified by `output`. /// /// This function has the same semantics as `decompress`, except that the /// length of `vec` is managed by this function. This will not reallocate /// the vector provided or attempt to grow it, so space for the output must /// be reserved in the output vector by the caller before calling this /// function. pub fn decompress_vec(&mut self, input: &[u8], output: &mut Vec, flush: Flush) -> Result { let rc = self.inner.decompress_vec(input, output, flush); self.rc(rc) } fn rc(&self, rc: c_int) -> Result { match rc { ffi::MZ_DATA_ERROR => Err(DataError(())), ffi::MZ_OK => Ok(Status::Ok), ffi::MZ_BUF_ERROR => Ok(Status::BufError), ffi::MZ_STREAM_END => Ok(Status::StreamEnd), c => panic!("unknown return code: {}", c), } } } deps/flate2-0.2.11/src/stream.rs0000664000175000017500000001721612614575412013273 0ustar //! Raw un-exported bindings to miniz for encoding/decoding use std::marker; use std::mem; use libc::{c_int, c_uint}; use Compression; use ffi; pub struct Stream { raw: ffi::mz_stream, _marker: marker::PhantomData, } pub enum Compress {} pub enum Decompress {} /// Values which indicate the form of flushing to be used when compressing or /// decompressing in-memory data. pub enum Flush { /// A typical parameter for passing to compression/decompression functions, /// this indicates that the underlying stream to decide how much data to /// accumulate before producing output in order to maximize compression. None = ffi::MZ_NO_FLUSH as isize, /// All pending output is flushed to the output buffer and the output is /// aligned on a byte boundary so that the decompressor can get all input /// data available so far. /// /// Flushing may degrade comperssion for some compression algorithms and so /// it should only be used when necessary. This will complete the current /// deflate block and follow it with an empty stored block. Sync = ffi::MZ_SYNC_FLUSH as isize, /// All pending output is flushed to the output buffer, but the output is /// not aligned to a byte boundary. /// /// All of the input data so far will be available to the decompressor (as /// with `Flush::Sync`. This completes the current deflate block and follows /// it with an empty fixed codes block that is 10 bites long, and it assures /// that enough bytes are output in order for the decompessor to finish the /// block before the empty fixed code block. Partial = ffi::MZ_PARTIAL_FLUSH as isize, /// A deflate block is completed and emitted, as for `Flush::Sync`, but the /// output is not aligned on a byte boundary and up to seven vits of the /// current block are held to be written as the next byte after the next /// deflate block is completed. /// /// In this case the decompressor may not be provided enough bits at this /// point in order to complete decompression of the data provided so far to /// the compressor, it may need to wait for the next block to be emitted. /// This is for advanced applications that need to control the emission of /// deflate blocks. Block = ffi::MZ_BLOCK as isize, /// All output is flushed as with `Flush::Sync` and the compression state is /// reset so decompression can restart from this point if previous /// compressed data has been damaged or if random access is desired. /// /// Using this option too often can seriously degrade compression. Full = ffi::MZ_FULL_FLUSH as isize, /// Pending input is processed and pending output is flushed. /// /// The return value may indicate that the stream is not yet done and more /// data has yet to be processed. Finish = ffi::MZ_FINISH as isize, } #[doc(hidden)] pub trait Direction { unsafe fn destroy(stream: *mut ffi::mz_stream) -> c_int; } impl Stream { pub fn new_compress(lvl: Compression, raw: bool) -> Stream { unsafe { let mut state: ffi::mz_stream = mem::zeroed(); let ret = ffi::mz_deflateInit2(&mut state, lvl as c_int, ffi::MZ_DEFLATED, if raw { -ffi::MZ_DEFAULT_WINDOW_BITS } else { ffi::MZ_DEFAULT_WINDOW_BITS }, 9, ffi::MZ_DEFAULT_STRATEGY); debug_assert_eq!(ret, 0); Stream { raw: state, _marker: marker::PhantomData, } } } pub fn new_decompress(raw: bool) -> Stream { unsafe { let mut state: ffi::mz_stream = mem::zeroed(); let ret = ffi::mz_inflateInit2(&mut state, if raw { -ffi::MZ_DEFAULT_WINDOW_BITS } else { ffi::MZ_DEFAULT_WINDOW_BITS }); debug_assert_eq!(ret, 0); Stream { raw: state, _marker: marker::PhantomData, } } } } impl Stream { pub fn total_in(&self) -> u64 { self.raw.total_in as u64 } pub fn total_out(&self) -> u64 { self.raw.total_out as u64 } } impl Stream { pub fn decompress(&mut self, input: &[u8], output: &mut [u8], flush: Flush) -> c_int { self.raw.next_in = input.as_ptr(); self.raw.avail_in = input.len() as c_uint; self.raw.next_out = output.as_mut_ptr(); self.raw.avail_out = output.len() as c_uint; unsafe { ffi::mz_inflate(&mut self.raw, flush as c_int) } } pub fn decompress_vec(&mut self, input: &[u8], output: &mut Vec, flush: Flush) -> c_int { let cap = output.capacity(); let len = output.len(); self.raw.avail_in = input.len() as c_uint; self.raw.next_in = input.as_ptr() as *mut _; self.raw.avail_out = (cap - len) as c_uint; unsafe { self.raw.next_out = output.as_mut_ptr().offset(len as isize); let before = self.total_out(); let rc = ffi::mz_inflate(&mut self.raw, flush as c_int); let diff = (self.total_out() - before) as usize; output.set_len(len + diff); return rc; } } } impl Stream { pub fn compress(&mut self, input: &[u8], output: &mut [u8], flush: Flush) -> c_int { self.raw.next_in = input.as_ptr() as *mut _; self.raw.avail_in = input.len() as c_uint; self.raw.next_out = output.as_mut_ptr(); self.raw.avail_out = output.len() as c_uint; unsafe { ffi::mz_deflate(&mut self.raw, flush as c_int) } } pub fn compress_vec(&mut self, input: &[u8], output: &mut Vec, flush: Flush) -> c_int { let cap = output.capacity(); let len = output.len(); self.raw.avail_in = input.len() as c_uint; self.raw.next_in = input.as_ptr() as *mut _; self.raw.avail_out = (cap - len) as c_uint; unsafe { self.raw.next_out = output.as_mut_ptr().offset(len as isize); let before = self.total_out(); let rc = ffi::mz_deflate(&mut self.raw, flush as c_int); let diff = (self.total_out() - before) as usize; output.set_len(len + diff); return rc; } } pub fn reset(&mut self) -> c_int { unsafe { ffi::mz_deflateReset(&mut self.raw) } } } impl Direction for Compress { unsafe fn destroy(stream: *mut ffi::mz_stream) -> c_int { ffi::mz_deflateEnd(stream) } } impl Direction for Decompress { unsafe fn destroy(stream: *mut ffi::mz_stream) -> c_int { ffi::mz_inflateEnd(stream) } } impl Drop for Stream { fn drop(&mut self) { unsafe { let _ = ::destroy(&mut self.raw); } } } deps/flate2-0.2.11/src/raw.rs0000664000175000017500000002364712616030134012563 0ustar //! Raw un-exported bindings to miniz for encoding/decoding use std::io::prelude::*; use std::io; use std::mem; use libc; use Compression; use ffi; use stream::{Stream, Compress, Decompress, Direction, Flush}; pub struct EncoderWriter(InnerWrite); pub struct DecoderWriter(InnerWrite); struct InnerWrite { inner: Option, stream: Stream, buf: Vec, } pub struct EncoderReader(InnerRead); pub struct DecoderReader(InnerRead); struct InnerRead { inner: R, stream: Stream, buf: Box<[u8]>, pos: usize, cap: usize, } impl EncoderWriter { pub fn new(w: W, level: Compression, raw: bool, buf: Vec) -> EncoderWriter { EncoderWriter(InnerWrite { inner: Some(w), stream: Stream::new_compress(level, raw), buf: buf, }) } pub fn finish(&mut self) -> io::Result<()> { self.0.finish(&mut |stream, inner| { stream.compress_vec(&[], inner, Flush::Finish) }) } pub fn into_inner(mut self) -> W { self.0.inner.take().unwrap() } pub fn take_inner(&mut self) -> W { self.0.inner.take().unwrap() } pub fn write_all_raw(&mut self, buf: &[u8]) -> io::Result<()> { self.0.inner.as_mut().unwrap().write_all(buf) } pub fn unwrapped(&self) -> bool { self.0.inner.is_none() } pub fn reset(&mut self, w: W) -> W { self.0.stream.reset(); self.0.buf.truncate(0); mem::replace(&mut self.0.inner, Some(w)).unwrap() } } impl Write for EncoderWriter { fn write(&mut self, buf: &[u8]) -> io::Result { // miniz isn't guaranteed to actually write any of the buffer provided, // it may be in a flushing mode where it's just giving us data before // we're actually giving it any data. We don't want to spuriously return // `Ok(0)` when possible as it will cause calls to write_all() to fail. // As a result we execute this in a loop to ensure that we try our // darndest to write the data. loop { let n = try!(self.0.write(&mut |stream, inner| { stream.compress_vec(buf, inner, Flush::None) })); if buf.len() == 0 || n != 0 { return Ok(n); } } } fn flush(&mut self) -> io::Result<()> { self.0 .finish(&mut |stream, inner| { stream.compress_vec(&[], inner, Flush::Sync) }) .and_then(|()| self.0.inner.as_mut().unwrap().flush()) } } impl Drop for EncoderWriter { fn drop(&mut self) { if self.0.inner.is_some() { let _ = self.finish(); } } } impl DecoderWriter { pub fn new(w: W, raw: bool, buf: Vec) -> DecoderWriter { DecoderWriter(InnerWrite { inner: Some(w), stream: Stream::new_decompress(raw), buf: buf, }) } pub fn reset(&mut self, w: W, raw: bool) -> W { self.0.stream = Stream::new_decompress(raw); self.0.buf.truncate(0); mem::replace(&mut self.0.inner, Some(w)).unwrap() } pub fn finish(&mut self) -> io::Result<()> { self.0.finish(&mut |stream, inner| { stream.decompress_vec(&[], inner, Flush::Finish) }) } pub fn into_inner(mut self) -> W { self.0.inner.take().unwrap() } pub fn total_in(&self) -> u64 { self.0.stream.total_in() } pub fn total_out(&self) -> u64 { self.0.stream.total_out() } } impl Write for DecoderWriter { fn write(&mut self, buf: &[u8]) -> io::Result { // See EncoderWriter::write for why this is in a loop loop { let n = try!(self.0.write(&mut |stream, inner| { stream.decompress_vec(buf, inner, Flush::None) })); if buf.len() == 0 || n != 0 { return Ok(n); } } } fn flush(&mut self) -> io::Result<()> { self.0 .finish(&mut |stream, inner| { stream.decompress_vec(&[], inner, Flush::Sync) }) .and_then(|()| self.0.inner.as_mut().unwrap().flush()) } } impl InnerWrite { fn write(&mut self, f: &mut F) -> io::Result where F: FnMut(&mut Stream, &mut Vec) -> libc::c_int { let writer = self.inner.as_mut().unwrap(); if self.buf.len() > 0 { try!(writer.write_all(&self.buf)); self.buf.truncate(0); } let before_in = self.stream.total_in(); let ret = f(&mut self.stream, &mut self.buf); let written = (self.stream.total_in() - before_in) as usize; match ret { ffi::MZ_OK | ffi::MZ_BUF_ERROR | ffi::MZ_STREAM_END => Ok(written), n => panic!("unexpected return {}", n), } } fn finish(&mut self, f: &mut F) -> io::Result<()> where F: FnMut(&mut Stream, &mut Vec) -> libc::c_int { // Unfortunately miniz doesn't actually tell us when we're done with // pulling out all the data from the internal stream. To remedy this we // have to continually ask the stream for more memory until it doesn't // give us a chunk of memory the same size as our own internal buffer, // at which point we assume it's reached the end. let mut cont = true; while cont { try!(self.write(f)); let inner = self.inner.as_mut().unwrap(); if self.buf.len() > 0 { try!(inner.write_all(&self.buf)); } cont = self.buf.len() == self.buf.capacity(); self.buf.truncate(0); } Ok(()) } } impl EncoderReader { pub fn new(w: R, level: Compression, raw: bool, buf: Vec) -> EncoderReader { EncoderReader(InnerRead { inner: w, stream: Stream::new_compress(level, raw), buf: buf.into_boxed_slice(), cap: 0, pos: 0, }) } pub fn get_ref(&self) -> &R { &self.0.inner } pub fn into_inner(self) -> R { self.0.inner } pub fn reset(&mut self, r: R) -> R { self.0.stream.reset(); self.0.cap = 0; self.0.pos = 0; mem::replace(&mut self.0.inner, r) } } impl Read for EncoderReader { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.0.read(|stream, inner, flush| stream.compress(inner, buf, flush)) } } impl DecoderReader { pub fn new(r: R, raw: bool, buf: Vec) -> DecoderReader { DecoderReader(InnerRead { inner: r, stream: Stream::new_decompress(raw), buf: buf.into_boxed_slice(), pos: 0, cap: 0, }) } pub fn reset(&mut self, r: R, raw: bool) -> R { self.0.stream = Stream::new_decompress(raw); self.0.cap = 0; self.0.pos = 0; mem::replace(&mut self.0.inner, r) } pub fn into_inner(self) -> R { self.0.inner } pub fn read_raw(&mut self, buf: &mut [u8]) -> io::Result { let mut from = &self.0.buf[self.0.pos..self.0.cap]; match try!(Read::read(&mut from, buf)) { 0 => {} n => { self.0.pos += n; return Ok(n); } } self.0.inner.read(buf) } pub fn total_in(&self) -> u64 { self.0.stream.total_in() } pub fn total_out(&self) -> u64 { self.0.stream.total_out() } } impl Read for DecoderReader { fn read(&mut self, buf: &mut [u8]) -> io::Result { // zero-length reads currently aren't handled well here, so just punt // those upstream. if buf.len() == 0 { return Ok(0) } self.0.read(|stream, inner, flush| stream.decompress(inner, buf, flush)) } } impl InnerRead { fn read(&mut self, mut f: F) -> io::Result where F: FnMut(&mut Stream, &[u8], Flush) -> libc::c_int { loop { let mut eof = false; if self.pos == self.cap { self.cap = try!(self.inner.read(&mut self.buf)); self.pos = 0; eof = self.cap == 0; } let before_out = self.stream.total_out(); let before_in = self.stream.total_in(); let ret = f(&mut self.stream, &self.buf[self.pos..self.cap], if eof { Flush::Finish } else { Flush::None }); let read = (self.stream.total_out() - before_out) as usize; self.pos += (self.stream.total_in() - before_in) as usize; return match ret { ffi::MZ_OK | ffi::MZ_BUF_ERROR => { // If we haven't ready any data and we haven't hit EOF yet, // then we need to keep asking for more data because if we // return that 0 bytes of data have been read then it will // be interpreted as EOF. if read == 0 && !eof { continue; } Ok(read) } ffi::MZ_STREAM_END => return Ok(read), ffi::MZ_DATA_ERROR => { Err(io::Error::new(io::ErrorKind::InvalidInput, "corrupt deflate stream")) } n => panic!("unexpected return {}", n), }; } } } deps/flate2-0.2.11/src/zlib.rs0000664000175000017500000002624512615762774012754 0ustar //! ZLIB compression and decompression of streams use std::io::prelude::*; use std::io; use raw; /// A ZLIB encoder, or compressor. /// /// This structure implements a `Write` interface and takes a stream of /// uncompressed data, writing the compressed data to the wrapped writer. pub struct EncoderWriter { inner: raw::EncoderWriter, } /// A ZLIB encoder, or compressor. /// /// This structure implements a `Read` interface and will read uncompressed /// data from an underlying stream and emit a stream of compressed data. pub struct EncoderReader { inner: raw::EncoderReader, } /// A ZLIB decoder, or decompressor. /// /// This structure implements a `Read` interface and takes a stream of /// compressed data as input, providing the decompressed data when read from. pub struct DecoderReader { inner: raw::DecoderReader, } /// A ZLIB decoder, or decompressor. /// /// This structure implements a `Write` and will emit a stream of decompressed /// data when fed a stream of compressed data. pub struct DecoderWriter { inner: raw::DecoderWriter, } impl EncoderWriter { /// Creates a new encoder which will write compressed data to the stream /// given at the given compression level. /// /// When this encoder is dropped or unwrapped the final pieces of data will /// be flushed. pub fn new(w: W, level: ::Compression) -> EncoderWriter { EncoderWriter { inner: raw::EncoderWriter::new(w, level, false, Vec::with_capacity(32 * 1024)), } } /// Resets the state of this encoder entirely, swapping out the output /// stream for another. /// /// This function will finish encoding the current stream into the current /// output stream before swapping out the two output streams. If the stream /// cannot be finished an error is returned. /// /// After the current stream has been finished, this will reset the internal /// state of this encoder and replace the output stream with the one /// provided, returning the previous output stream. Future data written to /// this encoder will be the compressed into the stream `w` provided. pub fn reset(&mut self, w: W) -> io::Result { try!(self.inner.finish()); Ok(self.inner.reset(w)) } /// Consumes this encoder, flushing the output stream. /// /// This will flush the underlying data stream and then return the contained /// writer if the flush succeeded. pub fn finish(mut self) -> io::Result { try!(self.inner.finish()); Ok(self.inner.into_inner()) } } impl Write for EncoderWriter { fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.write(buf) } fn flush(&mut self) -> io::Result<()> { self.inner.flush() } } impl EncoderReader { /// Creates a new encoder which will read uncompressed data from the given /// stream and emit the compressed stream. pub fn new(r: R, level: ::Compression) -> EncoderReader { EncoderReader { inner: raw::EncoderReader::new(r, level, false, vec![0; 32 * 1024]), } } /// Resets the state of this encoder entirely, swapping out the input /// stream for another. /// /// This function will reset the internal state of this encoder and replace /// the input stream with the one provided, returning the previous input /// stream. Future data read from this encoder will be the compressed /// version of `r`'s data. pub fn reset(&mut self, r: R) -> R { self.inner.reset(r) } /// Consumes this encoder, returning the underlying reader. pub fn into_inner(self) -> R { self.inner.into_inner() } } impl Read for EncoderReader { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.read(buf) } } impl DecoderReader { /// Creates a new decoder which will decompress data read from the given /// stream. pub fn new(r: R) -> DecoderReader { DecoderReader::new_with_buf(r, vec![0; 32 * 1024]) } /// Same as `new`, but the intermediate buffer for data is specified. /// /// Note that the specified buffer will only be used up to its current /// length. The buffer's capacity will also not grow over time. pub fn new_with_buf(r: R, buf: Vec) -> DecoderReader { DecoderReader { inner: raw::DecoderReader::new(r, false, buf) } } /// Resets the state of this decoder entirely, swapping out the input /// stream for another. /// /// This will reset the internal state of this decoder and replace the /// input stream with the one provided, returning the previous input /// stream. Future data read from this decoder will be the decompressed /// version of `r`'s data. pub fn reset(&mut self, r: R) -> R { self.inner.reset(r, false) } /// Consumes this decoder, returning the underlying reader. pub fn into_inner(self) -> R { self.inner.into_inner() } /// Returns the number of bytes that the decompressor has consumed. /// /// Note that this will likely be smaller than what the decompressor /// actually read from the underlying stream due to buffering. pub fn total_in(&self) -> u64 { self.inner.total_in() } /// Returns the number of bytes that the decompressor has produced. pub fn total_out(&self) -> u64 { self.inner.total_out() } } impl Read for DecoderReader { fn read(&mut self, into: &mut [u8]) -> io::Result { self.inner.read(into) } } impl DecoderWriter { /// Creates a new decoder which will write uncompressed data to the stream. /// /// When this decoder is dropped or unwrapped the final pieces of data will /// be flushed. pub fn new(w: W) -> DecoderWriter { DecoderWriter { inner: raw::DecoderWriter::new(w, false, Vec::with_capacity(32 * 1024)), } } /// Resets the state of this decoder entirely, swapping out the output /// stream for another. /// /// This will reset the internal state of this decoder and replace the /// output stream with the one provided, returning the previous output /// stream. Future data written to this decoder will be decompressed into /// the output stream `w`. pub fn reset(&mut self, w: W) -> io::Result { try!(self.inner.finish()); Ok(self.inner.reset(w, false)) } /// Consumes this encoder, flushing the output stream. /// /// This will flush the underlying data stream and then return the contained /// writer if the flush succeeded. pub fn finish(mut self) -> io::Result { try!(self.inner.finish()); Ok(self.inner.into_inner()) } /// Returns the number of bytes that the decompressor has consumed for /// decompression. /// /// Note that this will likely be smaller than the number of bytes /// successfully written to this stream due to internal buffering. pub fn total_in(&self) -> u64 { self.inner.total_in() } /// Returns the number of bytes that the decompressor has written to its /// output stream. pub fn total_out(&self) -> u64 { self.inner.total_out() } } impl Write for DecoderWriter { fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.write(buf) } fn flush(&mut self) -> io::Result<()> { self.inner.flush() } } #[cfg(test)] mod tests { use std::io::prelude::*; use rand::{thread_rng, Rng}; use zlib::{EncoderWriter, EncoderReader, DecoderReader, DecoderWriter}; use Compression::Default; #[test] fn roundtrip() { let mut real = Vec::new(); let mut w = EncoderWriter::new(Vec::new(), Default); let v = thread_rng().gen_iter::().take(1024).collect::>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0, v.len())]; real.extend(to_write.iter().map(|x| *x)); w.write_all(to_write).unwrap(); } let result = w.finish().unwrap(); let mut r = DecoderReader::new(&result[..]); let mut ret = Vec::new(); r.read_to_end(&mut ret).unwrap(); assert!(ret == real); } #[test] fn total_in() { let mut real = Vec::new(); let mut w = EncoderWriter::new(Vec::new(), Default); let v = thread_rng().gen_iter::().take(1024).collect::>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0, v.len())]; real.extend(to_write.iter().map(|x| *x)); w.write_all(to_write).unwrap(); } let mut result = w.finish().unwrap(); let result_len = result.len(); for _ in 0..200 { result.extend(v.iter().map(|x| *x)); } let mut r = DecoderReader::new(&result[..]); let mut ret = Vec::new(); r.read_to_end(&mut ret).unwrap(); assert!(ret == real); assert_eq!(r.total_in(), result_len as u64); } #[test] fn roundtrip2() { let v = thread_rng() .gen_iter::() .take(1024 * 1024) .collect::>(); let mut r = DecoderReader::new(EncoderReader::new(&v[..], Default)); let mut ret = Vec::new(); r.read_to_end(&mut ret).unwrap(); assert_eq!(ret, v); } #[test] fn roundtrip3() { let v = thread_rng() .gen_iter::() .take(1024 * 1024) .collect::>(); let mut w = EncoderWriter::new(DecoderWriter::new(Vec::new()), Default); w.write_all(&v).unwrap(); let w = w.finish().unwrap().finish().unwrap(); assert!(w == v); } #[test] fn reset_decoder() { let v = thread_rng() .gen_iter::() .take(1024 * 1024) .collect::>(); let mut w = EncoderWriter::new(Vec::new(), Default); w.write_all(&v).unwrap(); let data = w.finish().unwrap(); { let (mut a, mut b, mut c) = (Vec::new(), Vec::new(), Vec::new()); let mut r = DecoderReader::new(&data[..]); r.read_to_end(&mut a).unwrap(); r.reset(&data); r.read_to_end(&mut b).unwrap(); let mut r = DecoderReader::new(&data[..]); r.read_to_end(&mut c).unwrap(); assert!(a == b && b == c && c == v); } { let mut w = DecoderWriter::new(Vec::new()); w.write_all(&data).unwrap(); let a = w.reset(Vec::new()).unwrap(); w.write_all(&data).unwrap(); let b = w.finish().unwrap(); let mut w = DecoderWriter::new(Vec::new()); w.write_all(&data).unwrap(); let c = w.finish().unwrap(); assert!(a == b && b == c && c == v); } } } deps/flate2-0.2.11/src/deflate.rs0000664000175000017500000003156412616030072013374 0ustar //! DEFLATE compression and decompression of streams use std::io::prelude::*; use std::io; use raw; /// A DEFLATE encoder, or compressor. /// /// This structure implements a `Write` interface and takes a stream of /// uncompressed data, writing the compressed data to the wrapped writer. pub struct EncoderWriter { inner: raw::EncoderWriter, } /// A DEFLATE encoder, or compressor. /// /// This structure implements a `Read` interface and will read uncompressed /// data from an underlying stream and emit a stream of compressed data. pub struct EncoderReader { inner: raw::EncoderReader, } /// A DEFLATE decoder, or decompressor. /// /// This structure implements a `Read` interface and takes a stream of /// compressed data as input, providing the decompressed data when read from. pub struct DecoderReader { inner: raw::DecoderReader, } /// A DEFLATE decoder, or decompressor. /// /// This structure implements a `Write` and will emit a stream of decompressed /// data when fed a stream of compressed data. pub struct DecoderWriter { inner: raw::DecoderWriter, } impl EncoderWriter { /// Creates a new encoder which will write compressed data to the stream /// given at the given compression level. /// /// When this encoder is dropped or unwrapped the final pieces of data will /// be flushed. pub fn new(w: W, level: ::Compression) -> EncoderWriter { EncoderWriter { inner: raw::EncoderWriter::new(w, level, true, Vec::with_capacity(32 * 1024)), } } /// Resets the state of this encoder entirely, swapping out the output /// stream for another. /// /// This function will finish encoding the current stream into the current /// output stream before swapping out the two output streams. If the stream /// cannot be finished an error is returned. /// /// After the current stream has been finished, this will reset the internal /// state of this encoder and replace the output stream with the one /// provided, returning the previous output stream. Future data written to /// this encoder will be the compressed into the stream `w` provided. pub fn reset(&mut self, w: W) -> io::Result { try!(self.inner.finish()); Ok(self.inner.reset(w)) } /// Consumes this encoder, flushing the output stream. /// /// This will flush the underlying data stream and then return the contained /// writer if the flush succeeded. pub fn finish(mut self) -> io::Result { try!(self.inner.finish()); Ok(self.inner.into_inner()) } } impl Write for EncoderWriter { fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.write(buf) } fn flush(&mut self) -> io::Result<()> { self.inner.flush() } } impl EncoderReader { /// Creates a new encoder which will read uncompressed data from the given /// stream and emit the compressed stream. pub fn new(r: R, level: ::Compression) -> EncoderReader { EncoderReader { inner: raw::EncoderReader::new(r, level, true, vec![0; 32 * 1024]), } } /// Resets the state of this encoder entirely, swapping out the input /// stream for another. /// /// This function will reset the internal state of this encoder and replace /// the input stream with the one provided, returning the previous input /// stream. Future data read from this encoder will be the compressed /// version of `r`'s data. pub fn reset(&mut self, r: R) -> R { self.inner.reset(r) } /// Consumes this encoder, returning the underlying reader. pub fn into_inner(self) -> R { self.inner.into_inner() } } impl Read for EncoderReader { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.read(buf) } } impl DecoderReader { /// Creates a new decoder which will decompress data read from the given /// stream. pub fn new(r: R) -> DecoderReader { DecoderReader::new_with_buf(r, vec![0; 32 * 1024]) } /// Same as `new`, but the intermediate buffer for data is specified. /// /// Note that the capacity of the intermediate buffer is never increased, /// and it is recommended for it to be large. pub fn new_with_buf(r: R, buf: Vec) -> DecoderReader { DecoderReader { inner: raw::DecoderReader::new(r, true, buf) } } /// Resets the state of this decoder entirely, swapping out the input /// stream for another. /// /// This will reset the internal state of this decoder and replace the /// input stream with the one provided, returning the previous input /// stream. Future data read from this decoder will be the decompressed /// version of `r`'s data. pub fn reset(&mut self, r: R) -> R { self.inner.reset(r, true) } /// Consumes this decoder, returning the underlying reader. pub fn into_inner(self) -> R { self.inner.into_inner() } /// Returns the number of bytes that the decompressor has consumed. /// /// Note that this will likely be smaller than what the decompressor /// actually read from the underlying stream due to buffering. pub fn total_in(&self) -> u64 { self.inner.total_in() } /// Returns the number of bytes that the decompressor has produced. pub fn total_out(&self) -> u64 { self.inner.total_out() } } impl Read for DecoderReader { fn read(&mut self, into: &mut [u8]) -> io::Result { self.inner.read(into) } } impl DecoderWriter { /// Creates a new decoder which will write uncompressed data to the stream. /// /// When this encoder is dropped or unwrapped the final pieces of data will /// be flushed. pub fn new(w: W) -> DecoderWriter { DecoderWriter { inner: raw::DecoderWriter::new(w, true, Vec::with_capacity(32 * 1024)), } } /// Resets the state of this decoder entirely, swapping out the output /// stream for another. /// /// This function will finish encoding the current stream into the current /// output stream before swapping out the two output streams. If the stream /// cannot be finished an error is returned. /// /// This will then reset the internal state of this decoder and replace the /// output stream with the one provided, returning the previous output /// stream. Future data written to this decoder will be decompressed into /// the output stream `w`. pub fn reset(&mut self, w: W) -> io::Result { try!(self.inner.finish()); Ok(self.inner.reset(w, true)) } /// Consumes this encoder, flushing the output stream. /// /// This will flush the underlying data stream and then return the contained /// writer if the flush succeeded. pub fn finish(mut self) -> io::Result { try!(self.inner.finish()); Ok(self.inner.into_inner()) } /// Returns the number of bytes that the decompressor has consumed for /// decompression. /// /// Note that this will likely be smaller than the number of bytes /// successfully written to this stream due to internal buffering. pub fn total_in(&self) -> u64 { self.inner.total_in() } /// Returns the number of bytes that the decompressor has written to its /// output stream. pub fn total_out(&self) -> u64 { self.inner.total_out() } } impl Write for DecoderWriter { fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.write(buf) } fn flush(&mut self) -> io::Result<()> { self.inner.flush() } } #[cfg(test)] mod tests { use std::io::prelude::*; use rand::{thread_rng, Rng}; use deflate::{EncoderWriter, EncoderReader, DecoderReader, DecoderWriter}; use Compression::Default; #[test] fn roundtrip() { let mut real = Vec::new(); let mut w = EncoderWriter::new(Vec::new(), Default); let v = thread_rng().gen_iter::().take(1024).collect::>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0, v.len())]; real.extend(to_write.iter().map(|x| *x)); w.write_all(to_write).unwrap(); } let result = w.finish().unwrap(); let mut r = DecoderReader::new(&result[..]); let mut ret = Vec::new(); r.read_to_end(&mut ret).unwrap(); assert!(ret == real); } #[test] fn total_in() { let mut real = Vec::new(); let mut w = EncoderWriter::new(Vec::new(), Default); let v = thread_rng().gen_iter::().take(1024).collect::>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0, v.len())]; real.extend(to_write.iter().map(|x| *x)); w.write_all(to_write).unwrap(); } let mut result = w.finish().unwrap(); let result_len = result.len(); for _ in 0..200 { result.extend(v.iter().map(|x| *x)); } let mut r = DecoderReader::new(&result[..]); let mut ret = Vec::new(); r.read_to_end(&mut ret).unwrap(); assert!(ret == real); assert_eq!(r.total_in(), result_len as u64); } #[test] fn roundtrip2() { let v = thread_rng() .gen_iter::() .take(1024 * 1024) .collect::>(); let mut r = DecoderReader::new(EncoderReader::new(&v[..], Default)); let mut ret = Vec::new(); r.read_to_end(&mut ret).unwrap(); assert_eq!(ret, v); } #[test] fn roundtrip3() { let v = thread_rng() .gen_iter::() .take(1024 * 1024) .collect::>(); let mut w = EncoderWriter::new(DecoderWriter::new(Vec::new()), Default); w.write_all(&v).unwrap(); let w = w.finish().unwrap().finish().unwrap(); assert!(w == v); } #[test] fn reset_writer() { let v = thread_rng() .gen_iter::() .take(1024 * 1024) .collect::>(); let mut w = EncoderWriter::new(Vec::new(), Default); w.write_all(&v).unwrap(); let a = w.reset(Vec::new()).unwrap(); w.write_all(&v).unwrap(); let b = w.finish().unwrap(); let mut w = EncoderWriter::new(Vec::new(), Default); w.write_all(&v).unwrap(); let c = w.finish().unwrap(); assert!(a == b && b == c); } #[test] fn reset_reader() { let v = thread_rng() .gen_iter::() .take(1024 * 1024) .collect::>(); let (mut a, mut b, mut c) = (Vec::new(), Vec::new(), Vec::new()); let mut r = EncoderReader::new(&v[..], Default); r.read_to_end(&mut a).unwrap(); r.reset(&v[..]); r.read_to_end(&mut b).unwrap(); let mut r = EncoderReader::new(&v[..], Default); r.read_to_end(&mut c).unwrap(); assert!(a == b && b == c); } #[test] fn reset_decoder() { let v = thread_rng() .gen_iter::() .take(1024 * 1024) .collect::>(); let mut w = EncoderWriter::new(Vec::new(), Default); w.write_all(&v).unwrap(); let data = w.finish().unwrap(); { let (mut a, mut b, mut c) = (Vec::new(), Vec::new(), Vec::new()); let mut r = DecoderReader::new(&data[..]); r.read_to_end(&mut a).unwrap(); r.reset(&data); r.read_to_end(&mut b).unwrap(); let mut r = DecoderReader::new(&data[..]); r.read_to_end(&mut c).unwrap(); assert!(a == b && b == c && c == v); } { let mut w = DecoderWriter::new(Vec::new()); w.write_all(&data).unwrap(); let a = w.reset(Vec::new()).unwrap(); w.write_all(&data).unwrap(); let b = w.finish().unwrap(); let mut w = DecoderWriter::new(Vec::new()); w.write_all(&data).unwrap(); let c = w.finish().unwrap(); assert!(a == b && b == c && c == v); } } #[test] fn zero_length_read_with_data() { let m = vec![3u8; 128 * 1024 + 1]; let mut c = EncoderReader::new(&m[..], ::Compression::Default); let mut result = Vec::new(); c.read_to_end(&mut result).unwrap(); let mut d = DecoderReader::new(&result[..]); let mut data = Vec::new(); assert!(d.read(&mut data).unwrap() == 0); } } deps/flate2-0.2.11/src/gz.rs0000664000175000017500000004325412616436100012411 0ustar //! gzip compression/decompression //! //! [1]: http://www.gzip.org/zlib/rfc-gzip.html use std::cmp; use std::env; use std::ffi::CString; use std::io::prelude::*; use std::io; use std::mem; use Compression; use crc::{CrcReader, Crc}; use raw; static FHCRC: u8 = 1 << 1; static FEXTRA: u8 = 1 << 2; static FNAME: u8 = 1 << 3; static FCOMMENT: u8 = 1 << 4; /// A gzip streaming encoder /// /// This structure exposes a `Write` interface that will emit compressed data /// to the underlying writer `W`. pub struct EncoderWriter { inner: raw::EncoderWriter, crc: Crc, header: Vec, } /// A gzip streaming encoder /// /// This structure exposes a `Read` interface that will read uncompressed data /// from the underlying reader and expose the compressed version as a `Read` /// interface. pub struct EncoderReader { inner: raw::EncoderReader>, header: Vec, pos: usize, eof: bool, } /// A builder structure to create a new gzip Encoder. /// /// This structure controls header configuration options such as the filename. pub struct Builder { extra: Option>, filename: Option, comment: Option, mtime: u32, } /// A gzip streaming decoder /// /// This structure exposes a `Read` interface that will consume compressed /// data from the underlying reader and emit uncompressed data. pub struct DecoderReader { inner: CrcReader>, header: Header, finished: bool, } /// A structure representing the header of a gzip stream. /// /// The header can contain metadata about the file that was compressed, if /// present. pub struct Header { extra: Option>, filename: Option>, comment: Option>, mtime: u32, } impl Builder { /// Create a new blank builder with no header by default. pub fn new() -> Builder { Builder { extra: None, filename: None, comment: None, mtime: 0, } } /// Configure the `mtime` field in the gzip header. pub fn mtime(mut self, mtime: u32) -> Builder { self.mtime = mtime; self } /// Configure the `extra` field in the gzip header. pub fn extra(mut self, extra: Vec) -> Builder { self.extra = Some(extra); self } /// Configure the `filename` field in the gzip header. pub fn filename(mut self, filename: &[u8]) -> Builder { self.filename = Some(CString::new(filename).unwrap()); self } /// Configure the `comment` field in the gzip header. pub fn comment(mut self, comment: &[u8]) -> Builder { self.comment = Some(CString::new(comment).unwrap()); self } /// Consume this builder, creating a writer encoder in the process. /// /// The data written to the returned encoder will be compressed and then /// written out to the supplied parameter `w`. pub fn write(self, w: W, lvl: Compression) -> EncoderWriter { EncoderWriter { inner: raw::EncoderWriter::new(w, lvl, true, Vec::with_capacity(32 * 1024)), crc: Crc::new(), header: self.into_header(lvl), } } /// Consume this builder, creating a reader encoder in the process. /// /// Data read from the returned encoder will be the compressed version of /// the data read from the given reader. pub fn read(self, r: R, lvl: Compression) -> EncoderReader { let crc = CrcReader::new(r); EncoderReader { inner: raw::EncoderReader::new(crc, lvl, true, vec![0; 32 * 1024]), header: self.into_header(lvl), pos: 0, eof: false, } } fn into_header(self, lvl: Compression) -> Vec { let Builder { extra, filename, comment, mtime } = self; let mut flg = 0; let mut header = vec![0u8; 10]; match extra { Some(v) => { flg |= FEXTRA; header.push((v.len() >> 0) as u8); header.push((v.len() >> 8) as u8); header.extend(v); } None => {} } match filename { Some(filename) => { flg |= FNAME; header.extend(filename.as_bytes_with_nul().iter().map(|x| *x)); } None => {} } match comment { Some(comment) => { flg |= FCOMMENT; header.extend(comment.as_bytes_with_nul().iter().map(|x| *x)); } None => {} } header[0] = 0x1f; header[1] = 0x8b; header[2] = 8; header[3] = flg; header[4] = (mtime >> 0) as u8; header[5] = (mtime >> 8) as u8; header[6] = (mtime >> 16) as u8; header[7] = (mtime >> 24) as u8; header[8] = match lvl { Compression::Best => 2, Compression::Fast => 4, _ => 0, }; header[9] = match env::consts::OS { "linux" => 3, "macos" => 7, "win32" => 0, _ => 255, }; return header; } } impl EncoderWriter { /// Creates a new encoder which will use the given compression level. /// /// The encoder is not configured specially for the emitted header. For /// header configuration, see the `Builder` type. /// /// The data written to the returned encoder will be compressed and then /// written to the stream `w`. pub fn new(w: W, level: Compression) -> EncoderWriter { Builder::new().write(w, level) } /// Finish encoding this stream, returning the underlying writer once the /// encoding is done. pub fn finish(mut self) -> io::Result { self.do_finish() } fn do_finish(&mut self) -> io::Result { if self.header.len() != 0 { try!(self.inner.write_all_raw(&self.header)); } try!(self.inner.finish()); let mut inner = self.inner.take_inner(); let (sum, amt) = (self.crc.sum() as u32, self.crc.amt_as_u32()); let buf = [(sum >> 0) as u8, (sum >> 8) as u8, (sum >> 16) as u8, (sum >> 24) as u8, (amt >> 0) as u8, (amt >> 8) as u8, (amt >> 16) as u8, (amt >> 24) as u8]; try!(inner.write_all(&buf)); Ok(inner) } } impl Write for EncoderWriter { fn write(&mut self, buf: &[u8]) -> io::Result { if self.header.len() != 0 { try!(self.inner.write_all_raw(&self.header)); self.header.truncate(0); } let n = try!(self.inner.write(buf)); self.crc.update(&buf[..n]); Ok(n) } fn flush(&mut self) -> io::Result<()> { self.inner.flush() } } impl Drop for EncoderWriter { fn drop(&mut self) { if !self.inner.unwrapped() { let _ = self.do_finish(); } } } impl EncoderReader { /// Creates a new encoder which will use the given compression level. /// /// The encoder is not configured specially for the emitted header. For /// header configuration, see the `Builder` type. /// /// The data read from the stream `r` will be compressed and available /// through the returned reader. pub fn new(r: R, level: Compression) -> EncoderReader { Builder::new().read(r, level) } /// Returns the underlying stream, consuming this encoder pub fn into_inner(self) -> R { self.inner.into_inner().into_inner() } fn read_footer(&mut self, into: &mut [u8]) -> io::Result { if self.pos == 8 { return Ok(0); } let crc = self.inner.get_ref().crc(); let ref arr = [(crc.sum() >> 0) as u8, (crc.sum() >> 8) as u8, (crc.sum() >> 16) as u8, (crc.sum() >> 24) as u8, (crc.amt_as_u32() >> 0) as u8, (crc.amt_as_u32() >> 8) as u8, (crc.amt_as_u32() >> 16) as u8, (crc.amt_as_u32() >> 24) as u8]; Ok(copy(into, arr, &mut self.pos)) } } fn copy(into: &mut [u8], from: &[u8], pos: &mut usize) -> usize { let min = cmp::min(into.len(), from.len() - *pos); for (slot, val) in into.iter_mut().zip(from[*pos..*pos + min].iter()) { *slot = *val; } *pos += min; return min; } impl Read for EncoderReader { fn read(&mut self, mut into: &mut [u8]) -> io::Result { let mut amt = 0; if self.eof { return self.read_footer(into); } else if self.pos < self.header.len() { amt += copy(into, &self.header, &mut self.pos); if amt == into.len() { return Ok(amt); } let tmp = into; into = &mut tmp[amt..]; } match try!(self.inner.read(into)) { 0 => { self.eof = true; self.pos = 0; self.read_footer(into) } n => Ok(amt + n), } } } impl DecoderReader { /// Creates a new decoder from the given reader, immediately parsing the /// gzip header. /// /// If an error is encountered when parsing the gzip header, an error is /// returned. pub fn new(r: R) -> io::Result> { let mut crc_reader = CrcReader::new(r); let mut header = [0; 10]; try!(fill(&mut crc_reader, &mut header)); let id1 = header[0]; let id2 = header[1]; if id1 != 0x1f || id2 != 0x8b { return Err(bad_header()); } let cm = header[2]; if cm != 8 { return Err(bad_header()); } let flg = header[3]; let mtime = ((header[4] as u32) << 0) | ((header[5] as u32) << 8) | ((header[6] as u32) << 16) | ((header[7] as u32) << 24); let _xfl = header[8]; let _os = header[9]; let extra = if flg & FEXTRA != 0 { let xlen = try!(read_le_u16(&mut crc_reader)); let mut extra = vec![0; xlen as usize]; try!(fill(&mut crc_reader, &mut extra)); Some(extra) } else { None }; let filename = if flg & FNAME != 0 { // wow this is slow let mut b = Vec::new(); for byte in crc_reader.by_ref().bytes() { let byte = try!(byte); if byte == 0 { break; } b.push(byte); } Some(b) } else { None }; let comment = if flg & FCOMMENT != 0 { // wow this is slow let mut b = Vec::new(); for byte in crc_reader.by_ref().bytes() { let byte = try!(byte); if byte == 0 { break; } b.push(byte); } Some(b) } else { None }; if flg & FHCRC != 0 { let calced_crc = crc_reader.crc().sum() as u16; let stored_crc = try!(read_le_u16(&mut crc_reader)); if calced_crc != stored_crc { return Err(corrupt()); } } let flate = raw::DecoderReader::new(crc_reader.into_inner(), true, vec![0; 32 * 1024]); return Ok(DecoderReader { inner: CrcReader::new(flate), header: Header { extra: extra, filename: filename, comment: comment, mtime: mtime, }, finished: false, }); fn bad_header() -> io::Error { io::Error::new(io::ErrorKind::InvalidInput, "invalid gzip header") } fn fill(r: &mut R, mut buf: &mut [u8]) -> io::Result<()> { while buf.len() > 0 { match try!(r.read(buf)) { 0 => return Err(corrupt()), n => buf = &mut mem::replace(&mut buf, &mut [])[n..], } } Ok(()) } fn read_le_u16(r: &mut R) -> io::Result { let mut b = [0; 2]; try!(fill(r, &mut b)); Ok((b[0] as u16) | ((b[1] as u16) << 8)) } } /// Returns the header associated with this stream. pub fn header(&self) -> &Header { &self.header } fn finish(&mut self) -> io::Result<()> { if self.finished { return Ok(()); } let ref mut buf = [0u8; 8]; { let mut len = 0; while len < buf.len() { match try!(self.inner.inner().read_raw(&mut buf[len..])) { 0 => return Err(corrupt()), n => len += n, } } } let crc = ((buf[0] as u32) << 0) | ((buf[1] as u32) << 8) | ((buf[2] as u32) << 16) | ((buf[3] as u32) << 24); let amt = ((buf[4] as u32) << 0) | ((buf[5] as u32) << 8) | ((buf[6] as u32) << 16) | ((buf[7] as u32) << 24); if crc != self.inner.crc().sum() as u32 { return Err(corrupt()); } if amt != self.inner.crc().amt_as_u32() { return Err(corrupt()); } self.finished = true; Ok(()) } } impl Read for DecoderReader { fn read(&mut self, into: &mut [u8]) -> io::Result { match try!(self.inner.read(into)) { 0 => { try!(self.finish()); Ok(0) } n => Ok(n), } } } impl Header { /// Returns the `filename` field of this gzip stream's header, if present. pub fn filename(&self) -> Option<&[u8]> { self.filename.as_ref().map(|s| &s[..]) } /// Returns the `extra` field of this gzip stream's header, if present. pub fn extra(&self) -> Option<&[u8]> { self.extra.as_ref().map(|s| &s[..]) } /// Returns the `comment` field of this gzip stream's header, if present. pub fn comment(&self) -> Option<&[u8]> { self.comment.as_ref().map(|s| &s[..]) } /// Returns the `mtime` field of this gzip stream's header, if present. pub fn mtime(&self) -> u32 { self.mtime } } fn corrupt() -> io::Error { io::Error::new(io::ErrorKind::InvalidInput, "corrupt gzip stream does not have a matching checksum") } #[cfg(test)] mod tests { use std::io::prelude::*; use super::{EncoderWriter, EncoderReader, DecoderReader, Builder}; use Compression::Default; use rand::{thread_rng, Rng}; #[test] fn roundtrip() { let mut e = EncoderWriter::new(Vec::new(), Default); e.write_all(b"foo bar baz").unwrap(); let inner = e.finish().unwrap(); let mut d = DecoderReader::new(&inner[..]).unwrap(); let mut s = String::new(); d.read_to_string(&mut s).unwrap(); assert_eq!(s, "foo bar baz"); } #[test] fn roundtrip_zero() { let e = EncoderWriter::new(Vec::new(), Default); let inner = e.finish().unwrap(); let mut d = DecoderReader::new(&inner[..]).unwrap(); let mut s = String::new(); d.read_to_string(&mut s).unwrap(); assert_eq!(s, ""); } #[test] fn roundtrip_big() { let mut real = Vec::new(); let mut w = EncoderWriter::new(Vec::new(), Default); let v = thread_rng().gen_iter::().take(1024).collect::>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0, v.len())]; real.extend(to_write.iter().map(|x| *x)); w.write_all(to_write).unwrap(); } let result = w.finish().unwrap(); let mut r = DecoderReader::new(&result[..]).unwrap(); let mut v = Vec::new(); r.read_to_end(&mut v).unwrap(); assert!(v == real); } #[test] fn roundtrip_big2() { let v = thread_rng() .gen_iter::() .take(1024 * 1024) .collect::>(); let mut r = DecoderReader::new(EncoderReader::new(&v[..], Default)) .unwrap(); let mut res = Vec::new(); r.read_to_end(&mut res).unwrap(); assert!(res == v); } #[test] fn fields() { let r = vec![0, 2, 4, 6]; let e = Builder::new() .filename(b"foo.rs") .comment(b"bar") .extra(vec![0, 1, 2, 3]) .read(&r[..], Default); let mut d = DecoderReader::new(e).unwrap(); assert_eq!(d.header().filename(), Some(&b"foo.rs"[..])); assert_eq!(d.header().comment(), Some(&b"bar"[..])); assert_eq!(d.header().extra(), Some(&b"\x00\x01\x02\x03"[..])); let mut res = Vec::new(); d.read_to_end(&mut res).unwrap(); assert_eq!(res, vec![0, 2, 4, 6]); } #[test] fn keep_reading_after_end() { let mut e = EncoderWriter::new(Vec::new(), Default); e.write_all(b"foo bar baz").unwrap(); let inner = e.finish().unwrap(); let mut d = DecoderReader::new(&inner[..]).unwrap(); let mut s = String::new(); d.read_to_string(&mut s).unwrap(); assert_eq!(s, "foo bar baz"); d.read_to_string(&mut s).unwrap(); assert_eq!(s, "foo bar baz"); } } deps/flate2-0.2.11/src/crc.rs0000664000175000017500000000227112616436325012543 0ustar //! Simple CRC bindings backed by miniz.c use std::io::prelude::*; use std::io; use libc; use ffi; pub struct Crc { crc: libc::c_ulong, amt: u32, } pub struct CrcReader { inner: R, crc: Crc, } impl Crc { pub fn new() -> Crc { Crc { crc: 0, amt: 0 } } pub fn sum(&self) -> libc::c_ulong { self.crc } pub fn amt_as_u32(&self) -> u32 { self.amt } pub fn update(&mut self, data: &[u8]) { self.amt = self.amt.wrapping_add(data.len() as u32); self.crc = unsafe { ffi::mz_crc32(self.crc, data.as_ptr(), data.len() as libc::size_t) }; } } impl CrcReader { pub fn new(r: R) -> CrcReader { CrcReader { inner: r, crc: Crc::new(), } } pub fn crc(&self) -> &Crc { &self.crc } pub fn into_inner(self) -> R { self.inner } pub fn inner(&mut self) -> &mut R { &mut self.inner } } impl Read for CrcReader { fn read(&mut self, into: &mut [u8]) -> io::Result { let amt = try!(self.inner.read(into)); self.crc.update(&into[..amt]); Ok(amt) } } deps/flate2-0.2.11/tests/0000755000000000000000000000000012666635520013556 5ustar rootrootdeps/flate2-0.2.11/tests/gunzip.rs0000664000175000017500000000163312503323571013655 0ustar extern crate flate2; use std::fs::File; use std::io::prelude::*; use std::io; use std::path::Path; use flate2::read::GzDecoder; // test extraction of a gzipped file #[test] fn test_extract_success() { let content = extract_file(Path::new("tests/good-file.gz")).unwrap(); let mut expected = Vec::new(); File::open("tests/good-file.txt").unwrap().read_to_end(&mut expected).unwrap(); assert!(content == expected); } // test extraction fails on a corrupt file #[test] fn test_extract_failure() { let result = extract_file(Path::new("tests/corrupt-file.gz")); assert_eq!(result.err().unwrap().kind(), io::ErrorKind::InvalidInput); } // Tries to extract path into memory (assuming a .gz file). fn extract_file(path_compressed: &Path) -> io::Result>{ let mut v = Vec::new(); let f = try!(File::open(path_compressed)); try!(try!(GzDecoder::new(f)).read_to_end(&mut v)); Ok(v) } deps/flate2-0.2.11/tests/good-file.gz0000664000175000017500000001515612440024375014207 0ustar  MK.9n'W@ I(ixpnm7Pw|Ry{Rլ #??ן_߿~/ռS}T הa O0JX>acV~z~iКq a?m5)CYi>gyU?2g(XOeѧOe]T S-0YS,n]KS{kgS+~l1nbц>Ӫԕчv՟_Wmni>G?~6s]:k\{8fS>ni:a]kck~^zlH:[mO;ھh(ٴr?jg݌`3嵔uRVZuG-6bctquwU:ᣳzZ)koS?ı]ʭzfOg|z˷vOXfiz&?m  X)ݟ:'o8vkkLiy{z]WCw׶<^6X#{apxq|Fu?>G[^/qGǬM>og\ 4Я=\?C.?V3n8p}7t)t}c<~ φD#t>-A:s?r"cMb*-O>Ptb+a0*OpںF2mc6]>O`3c:"W(RER{&$dd?LoImFt7=swkAW -7IT }S[<ƃA׻\ol.FW͛:p\ضwH]4X !мd7~F/ oC) ~F }=U߿YAOEY53EXoHq>γ7):DfnM?jf!0DQ"m)s b*bH( hy!JC"!ȵ•'lG~=46/KX̎(y-<}xq BvUXCL YDHw=SRwfi*!'`cI *-`J2ŗ`/` 4 S7H=^PQʶdL窸81H0ȃ]dho@twПG֋I/, al ?vFHγ7lV4l_Ɋ0'()69X l!X)пwHGG h/VAToC@\hlq>wKW榬dqhZ9+U(laO=-I_ڕ_#?t%He^L!PH2Όǂex )vL|׈Z2`}Ļ)F 4eKsHXUR@q RMoMDJH3!eA2 iz @q$qxdfd]?4)+Bb!Ե}!EW`r1<FvVTuqEu]a[ X-=u^vƖl@-)^ʞs 4xL!@l 8I'< RZY2 (#̳" \ϬSCPK63t|H俼P kTd;m҆W{e}1K1^2 ZI n,Qup ^K0V\"t~T -Z` ?j+D\gt-֍![%Dp$sԀu̢_ ht2׌ `@Ap'o_\ .DK8 b9, OxP9B6Y Z#ii%PIp?FF]9@K7" Sih{If ({Ip!ݝ>[% PG I7^ ?ņ8y/J]N,5uOB 2Izr*%4XSFT07:q2`)ZCbqjBίAntvWn!{Gzu|K/u!Q~\zps~o_t}fPqfa2 JkiZA #Qv{Ɋdӣ7 c/Oܳ +YQ, X)-64|(QJ 5u<7^i1 j Ih3}z*2Ϯ[_  H`9{6ѢD$Ţ22p9"=yG?1,,c]ƕ&r'+~PТ)+D{VnEOP&7Q>\/yIS:Cx/J_IXiP>vGfXu6t5 `|Ew oH<`T=v>X% BOoL>BtאBt__Wn;!+/ `RS`4*nRR12 D<}&]Jr]8W̳,L)*[}E)h7k%IiytE4\WDQR[Y(7=$@3 0*C ,x =K⼔,5ic mk'o[7 dt#|(%T_q_>9.7ᕘ $ Q|1r'_ûObAƷH%#Щ7l63n_P.ۏ mn wPwo_ N;كݴkwywJFu^]n|vEIg-ITnZ9@ap˝(=#5ul=aHH1nU4EQ;"8Co)2h撣[ع7dӚ#7=B@ ^1{%,KLDE}FVK0}$GkƜVoF Po5̤nR2a#vgmZdPaQci^tURT{.b]!$i#/ca\m-tP}܆=jް޸21THTwa@3P3N_nN'M ,_SCq|dN)i Ec,B,:ݴʬ2qȔfg*)U0d1':@ks3MP,+|e=ƙEy1'd"ERc>!#%ilIKN_:uG2?Qj9>̯Tg1Blɐ4r}Dg:z wB~(_Y$7˯Q@YJ?OcZKoǟ1ȓgG4'=qLJhx}zPT]9s}ڑɳ@֘[b+1.Qx;EńQ4f՘p1CJi}y%-  S S~㌃17c?QoG-It}9 ]ۙ5_^1JcP"[a{^vySI&U$֌-l`",q28~i87wo10*b~;Xox ޸E*Fw}o@)v4h!8\#ġ'd PztV=c.~bs)uR8t1ߋL]U(dМ'IRO',C|!rU%Y*=:ʫ`ztJuςL KNH˚494y<O즯'"ڣ'G*!ݓAXÎĠ<_}GgQ~f$ۈP8 QJ^ $fn_=4Y)%B6uf-O _XFPqJB46eճ"aV?n̬`'E;czhf4 3q9Jq;3"Y!,fGE3gMl n>B@ϟSЈa]n4ot 20ב㛆Ry@D M+CCdgGG oUɒ" 7KЙ/A&s,@f"R>q0}gjoW+l7xdzSJV^O*3_3F%c+x™HZbޖBLf6Qd?u8Y?M3 C|WXERi1IS{`/#xrKfxĐ. #Y 0/*#ȦbYЅef ԉ,HXQG&M:deps/flate2-0.2.11/tests/corrupt-file.gz0000664000175000017500000001573012440024375014753 0ustar MK. ǿVzR24;1RVAE_~Kۿ~ǯۿϿ_~{ʟmZ'ʊʱZBw\fOQ>cS,Xc4޷>c)Om e4!4JzSsڶ51xQkS9%?s*̹hH9gG*9vS1w*SujdmcNM]R{‡f>AOU)t-Ijs6-[CZ>e~{+QViõ6nhYu$-O#7L1XNMkusӾkU0LmV7Tۨ-wƶj3k,M=ƶ֘o۪\e=cW6b!I񅼲SҮ7Ϸvj>WweOh2ϕSS8zy}]Ƨq{EאӶkJ+{ZvmKP>^}?{cվi'K'͚F h1"ruj2uuhAy1v}&AO4Xy4g~vuuE"hciQ4 nddŘzb3FiZCQ[<1KMK. ǿVzR24;1RVAE_~Kۿ~ǯۿϿ_~{ʟmZ'ʊʱZBw\fOQ>cS,Xc4޷>c)Om e4!4JzSsڶ51xQkS9%?s*̹hH9gG*9vS1w*SujdmcNM]R{‡f>AOU)t-Ijs6-[CZ>e~{+QViõ6nhYu$-O#7L1XNMkusӾkU0LmV7Tۨ-wƶj3k,M=ƶ֘o۪\e=cW6b!I񅼲SҮ7Ϸvj>WweOh2ϕSS8zy}]Ƨq{EאӶkJ+{ZvmKP>^}?{cվi'K'͚F h1"ruj2uuhAy1v}&AO4Xy4g~vuuE"hciQ4 nddŘzb3FiZCQ[<1KW6m)]B#()oJxhzkkFu@$mK" d @Z˶6 Rp[< ַm+lwKaC(bk1LЉ)A3Ɂa5 D2'JkWDRaH.EH$,I-8+uIHe3^YHr!rdBSwe,݈i0ē M,a6r0*?ej l[Z#6"aY#+,d9^7M82]JS_ZI1#k 굅ԉC\BGNT:Wh{f'wY7߸u~Ɠ˺5wZlYWk ͜zc?YHJivy5Cƴ]/:Hv{5-b:`Sot0@P,smu汹:-bmR.8kXih#e%Yj F ְfcF, ڣYt2Ԉ@gfpU]xYl>Z9:O%ŶRҝX:͜4CJGZ#)©|+o'vkCLZ`^?$}/b7KQSThux=rJw}ۛ)gX/Ȧmp vFgRv\suMn9Ub@IpIn5+N;)N:y(wP@U5dWS=u<;tDVF%:%[' ?/QXdIUXKv¢~xDՙ+_R #[ .yH0 p=ә@ a8 WApHyu ZO%gb!JA5G'.E{1XlP&ln%؊SeI$CգL#Y*>ږ9+@kY'CΐW(N$5yzt2$*uX- Dn֒pLu~2#A, ~#\N7Xnfc-" w9Y yLo߈iw&Wvq⪾U["789PHM oNl*" 0jTaMͰMvPM=s4ՒtuB8 R=T55R]Œ_W)k]zڈ]b='t$v%V9lˣa*"m寬~p(+:7eO : צ9m LUstE*`X nLϝ  8FVA Ka O|# ڷ8x]& #` )00\D~ h2 & (( zfC+!?bh%SAǁ6Sp1@9j7Qs4ՙmL` ]oX--֪ jZ49ok -a(h C^8豭w_f!8NjGdLe1'[Qa-`>^H~5CouVId#H1w֍/}SpE MCWֶ|!hr@ @'Z0z7 ~Sp.K8(L[-ȻyJUucZqa _űkmGGmd΄TⅬ,TȺMe+E'ִJZ04O(. _KKۅG=Z7c*vezS[|Who(me?bBMŇϓ婬muK@GV?fW0GSqoj*-[3ׇ0(ulu?eHPiTX%)ȦCv@L@Y Dlt'OƂ(d='j(KJ(@cY)jQ5g}$wCo2 V,˷*o׫&l#eZ:CDފv@Fo8(>fd(A]~\+(4g ~62kgq'=J`]p[͙xF$Hxoabkx+y9]w)„J~^eA)e: hmG& t!_G}I^vU =Ǚ~pAlq! Rm.U ]>`5hyg.c=; NY2k$wW˪zXܢ2o .-{eP2nlu}.;XaI:їO & Ja(2 鄌wAOL+RLk bLCgn4]SqqV}󩞺ª1,V JAykkcۏ J66U־.ׇjEyr<_39JpףXkv55+NUaZ 2Q 6p 6&L 'gnOZ]I (n cq^or $X@-*gD-УWhEkBHaY`kڤү`HUPO/U#>\RE/.OMYM D_ECP@ZSyyEsV5Uw S>̫u*GAUwP T~.qm Du0OD]h4УYf g–Qpq ! XUu"Bo[=&U:7|r(mݣK*]i\L?BY=8t/èE[Z8ϣ2P ) >Z @Bb\7lSAe*G!#T;&^oI qT(K998x݉9E\ww>Nkzh#S*$_>U\SØmT(n^֘(\ƭ5ۡ"'ND8{18QZT#L:CԠZ[M& Ȋ6~Ym(pTgl)u-İ=\n @!:!R,; K5?3Sޠ*p8 ]>tEWj8 U1@U-QjZǾa\+NVT c_n0Wξ^@Fپd\}p۾iPNU99B{GkGTW穨l5+?RI"] version = "0.2.11" license = "MIT/Apache-2.0" readme = "README.md" keywords = ["gzip", "flate", "zlib", "encoding"] repository = "https://github.com/alexcrichton/flate2-rs" homepage = "https://github.com/alexcrichton/flate2-rs" documentation = "http://alexcrichton.com/flate2-rs" description = """ Bindings to miniz.c for DEFLATE compression and decompression exposed as Reader/Writer streams. Contains bindings for zlib, deflate, and gzip-based streams. """ [dependencies] libc = "0.2" miniz-sys = { path = "miniz-sys", version = "0.1.7" } [dev-dependencies] rand = "0.3" deps/uuid-0.1.18/0000755000000000000000000000000012666635521012214 5ustar rootrootdeps/uuid-0.1.18/LICENSE-APACHE0000664000175000017500000002513712370715364012370 0ustar Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/uuid-0.1.18/LICENSE-MIT0000664000175000017500000000205712370715364012074 0ustar Copyright (c) 2014 The Rust Project Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/uuid-0.1.18/.travis.yml0000664000175000017500000000151212600113242012523 0ustar language: rust rust: - 1.0.0 - beta - nightly sudo: false script: - cargo build --verbose - cargo test --verbose - | [ $TRAVIS_RUST_VERSION != nightly ] || ( cargo bench ) - cargo doc after_success: | [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && [ $TRAVIS_RUST_VERSION = nightly ] && echo '' > target/doc/index.html && pip install ghp-import --user $USER && $HOME/.local/bin/ghp-import -n target/doc && git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages env: global: secure: OiQj6NSyu634pS+qWCAeaibuBdiRsDMz5k0bi8hhdom3W24L8I9KkdWlBm2K8Ef97Uzgg6Xsr7LSWX0CONxX2eU3QaB1v3mXNxModa7ftW/w9y7B8MThxS5nRTUmHZC17OvoQ3EoNyrktnTAkyIr0E0YxBruJYAi4EH+54guRN8= notifications: email: on_success: never deps/uuid-0.1.18/README.md0000664000175000017500000000366612607621756011732 0ustar uuid ==== [![Build Status](https://travis-ci.org/rust-lang-nursery/uuid.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/uuid) [![](http://meritbadge.herokuapp.com/uuid)](https://crates.io/crates/uuid) A Rust library to generate and parse UUIDs. Provides support for Universally Unique Identifiers (UUIDs). A UUID is a unique 128-bit number, stored as 16 octets. UUIDs are used to assign unique identifiers to entities without requiring a central allocating authority. They are particularly useful in distributed systems, though can be used in disparate areas, such as databases and network protocols. Typically a UUID is displayed in a readable string form as a sequence of hexadecimal digits, separated into groups by hyphens. The uniqueness property is not strictly guaranteed, however for all practical purposes, it can be assumed that an unintentional collision would be extremely unlikely. [Documentation](https://doc.rust-lang.org/uuid) ## Usage Add this to your `Cargo.toml`: ```toml [dependencies] uuid = "0.1" ``` and this to your crate root: ```rust extern crate uuid; ``` ## Examples To create a new random (V4) UUID and print it out in hexadecimal form: ```rust use uuid::Uuid; fn main() { let my_uuid = Uuid::new_v4(); println!("{}", my_uuid); } ``` The library supports 5 versions of UUID: Name | Version ---------|---------- Mac | Version 1: MAC address Dce | Version 2: DCE Security Md5 | Version 3: MD5 hash Random | Version 4: Random Sha1 | Version 5: SHA-1 hash To parse a simple UUID, then print the version and urn string format: ```rust use uuid::Uuid; fn main() { let my_uuid = Uuid::parse_str("936DA01F9ABD4d9d80C702AF85C822A8").unwrap(); println!("Parsed a version {} UUID.", my_uuid.get_version_num()); println!("{}", my_uuid.to_urn_string()); } ``` ## References [Wikipedia: Universally Unique Identifier](https://en.wikipedia.org/wiki/Universally_unique_identifier) deps/uuid-0.1.18/.gitignore0000664000175000017500000000002412374564433012423 0ustar /target /Cargo.lock deps/uuid-0.1.18/src/0000755000000000000000000000000012666635521013003 5ustar rootrootdeps/uuid-0.1.18/src/lib.rs0000664000175000017500000007207412607621756012355 0ustar // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Generate and parse UUIDs //! //! Provides support for Universally Unique Identifiers (UUIDs). A UUID is a //! unique 128-bit number, stored as 16 octets. UUIDs are used to assign unique //! identifiers to entities without requiring a central allocating authority. //! //! They are particularly useful in distributed systems, though can be used in //! disparate areas, such as databases and network protocols. Typically a UUID is //! displayed in a readable string form as a sequence of hexadecimal digits, //! separated into groups by hyphens. //! //! The uniqueness property is not strictly guaranteed, however for all practical //! purposes, it can be assumed that an unintentional collision would be extremely //! unlikely. //! //! # Examples //! //! To create a new random (V4) UUID and print it out in hexadecimal form: //! //! ```rust //! use uuid::Uuid; //! //! fn main() { //! let my_uuid = Uuid::new_v4(); //! println!("{}", my_uuid); //! } //! ``` //! //! To parse parse a UUID in the simple format and print it as a urn: //! //! ```rust //! use uuid::Uuid; //! //! fn main() { //! let my_uuid = Uuid::parse_str("936DA01F9ABD4d9d80C702AF85C822A8").unwrap(); //! println!("{}", my_uuid.to_urn_string()); //! } //! ``` //! //! # Strings //! //! Examples of string representations: //! //! * simple: `936DA01F9ABD4d9d80C702AF85C822A8` //! * hyphenated: `550e8400-e29b-41d4-a716-446655440000` //! * urn: `urn:uuid:F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4` //! //! # References //! //! * [Wikipedia: Universally Unique Identifier]( //! http://en.wikipedia.org/wiki/Universally_unique_identifier) //! * [RFC4122: A Universally Unique IDentifier (UUID) URN Namespace]( //! http://tools.ietf.org/html/rfc4122) #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://www.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/uuid/")] #![cfg_attr(test, deny(warnings))] extern crate rustc_serialize; #[cfg(feature = "serde")] extern crate serde; extern crate rand; use std::default::Default; use std::error::Error; use std::fmt; use std::hash; use std::iter::repeat; use std::mem::{transmute, transmute_copy}; use std::str::FromStr; use rand::Rng; use rustc_serialize::{Encoder, Encodable, Decoder, Decodable}; #[cfg(feature = "serde")] use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; /// A 128-bit (16 byte) buffer containing the ID pub type UuidBytes = [u8; 16]; /// The version of the UUID, denoting the generating algorithm #[derive(PartialEq, Copy, Clone)] pub enum UuidVersion { /// Version 1: MAC address Mac = 1, /// Version 2: DCE Security Dce = 2, /// Version 3: MD5 hash Md5 = 3, /// Version 4: Random Random = 4, /// Version 5: SHA-1 hash Sha1 = 5, } /// The reserved variants of UUIDs #[derive(PartialEq, Copy, Clone)] pub enum UuidVariant { /// Reserved by the NCS for backward compatibility NCS, /// As described in the RFC4122 Specification (default) RFC4122, /// Reserved by Microsoft for backward compatibility Microsoft, /// Reserved for future expansion Future, } /// A Universally Unique Identifier (UUID) #[derive(Copy, Clone)] pub struct Uuid { /// The 128-bit number stored in 16 bytes bytes: UuidBytes, } impl hash::Hash for Uuid { fn hash(&self, state: &mut S) { self.bytes.hash(state) } } /// A UUID stored as fields (identical to UUID, used only for conversions) #[derive(Copy, Clone)] struct UuidFields { /// First field, 32-bit word data1: u32, /// Second field, 16-bit short data2: u16, /// Third field, 16-bit short data3: u16, /// Fourth field, 8 bytes data4: [u8; 8], } /// Error details for string parsing failures #[allow(missing_docs)] #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum ParseError { InvalidLength(usize), InvalidCharacter(char, usize), InvalidGroups(usize), InvalidGroupLength(usize, usize, u8), } /// Converts a ParseError to a string impl fmt::Display for ParseError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { ParseError::InvalidLength(found) => write!(f, "Invalid length; expecting 32 or 36 chars, found {}", found), ParseError::InvalidCharacter(found, pos) => write!(f, "Invalid character; found `{}` (0x{:02x}) at offset {}", found, found as usize, pos), ParseError::InvalidGroups(found) => write!(f, "Malformed; wrong number of groups: expected 1 or 5, found {}", found), ParseError::InvalidGroupLength(group, found, expecting) => write!(f, "Malformed; length of group {} was {}, expecting {}", group, found, expecting), } } } impl Error for ParseError { fn description(&self) -> &str { "UUID parse error" } } // Length of each hyphenated group in hex digits. const GROUP_LENS: [u8; 5] = [8, 4, 4, 4, 12]; // Accumulated length of each hyphenated group in hex digits. const ACC_GROUP_LENS: [u8; 5] = [8, 12, 16, 20, 32]; /// UUID support impl Uuid { /// Returns a nil or empty UUID (containing all zeroes) pub fn nil() -> Uuid { Uuid { bytes: [0; 16] } } /// Create a new UUID of the specified version pub fn new(v: UuidVersion) -> Option { match v { UuidVersion::Random => Some(Uuid::new_v4()), _ => None, } } /// Creates a new random UUID /// /// Uses the `rand` module's default RNG task as the source /// of random numbers. Use the rand::Rand trait to supply /// a custom generator if required. pub fn new_v4() -> Uuid { let ub = rand::thread_rng().gen_iter::().take(16).collect::>(); let mut uuid = Uuid { bytes: [0; 16] }; copy_memory(&mut uuid.bytes, &ub); uuid.set_variant(UuidVariant::RFC4122); uuid.set_version(UuidVersion::Random); uuid } /// Creates a UUID using the supplied field values /// /// # Arguments /// * `d1` A 32-bit word /// * `d2` A 16-bit word /// * `d3` A 16-bit word /// * `d4` Array of 8 octets pub fn from_fields(d1: u32, d2: u16, d3: u16, d4: &[u8]) -> Uuid { // First construct a temporary field-based struct let mut fields = UuidFields { data1: 0, data2: 0, data3: 0, data4: [0; 8], }; fields.data1 = d1.to_be(); fields.data2 = d2.to_be(); fields.data3 = d3.to_be(); copy_memory(&mut fields.data4, d4); unsafe { transmute(fields) } } /// Creates a UUID using the supplied bytes /// /// # Arguments /// * `b` An array or slice of 16 bytes pub fn from_bytes(b: &[u8]) -> Option { if b.len() != 16 { return None } let mut uuid = Uuid { bytes: [0; 16] }; copy_memory(&mut uuid.bytes, b); Some(uuid) } /// Specifies the variant of the UUID structure fn set_variant(&mut self, v: UuidVariant) { // Octet 8 contains the variant in the most significant 3 bits self.bytes[8] = match v { UuidVariant::NCS => self.bytes[8] & 0x7f, // b0xx... UuidVariant::RFC4122 => (self.bytes[8] & 0x3f) | 0x80, // b10x... UuidVariant::Microsoft => (self.bytes[8] & 0x1f) | 0xc0, // b110... UuidVariant::Future => (self.bytes[8] & 0x1f) | 0xe0, // b111... } } /// Returns the variant of the UUID structure /// /// This determines the interpretation of the structure of the UUID. /// Currently only the RFC4122 variant is generated by this module. /// /// * [Variant Reference](http://tools.ietf.org/html/rfc4122#section-4.1.1) pub fn get_variant(&self) -> Option { match self.bytes[8] { x if x & 0x80 == 0x00 => Some(UuidVariant::NCS), x if x & 0xc0 == 0x80 => Some(UuidVariant::RFC4122), x if x & 0xe0 == 0xc0 => Some(UuidVariant::Microsoft), x if x & 0xe0 == 0xe0 => Some(UuidVariant::Future), _ => None, } } /// Specifies the version number of the UUID fn set_version(&mut self, v: UuidVersion) { self.bytes[6] = (self.bytes[6] & 0xF) | ((v as u8) << 4); } /// Returns the version number of the UUID /// /// This represents the algorithm used to generate the contents. /// /// Currently only the Random (V4) algorithm is supported by this /// module. There are security and privacy implications for using /// older versions - see [Wikipedia: Universally Unique Identifier]( /// http://en.wikipedia.org/wiki/Universally_unique_identifier) for /// details. /// /// * [Version Reference](http://tools.ietf.org/html/rfc4122#section-4.1.3) pub fn get_version_num(&self) -> usize { (self.bytes[6] >> 4) as usize } /// Returns the version of the UUID /// /// This represents the algorithm used to generate the contents pub fn get_version(&self) -> Option { let v = self.bytes[6] >> 4; match v { 1 => Some(UuidVersion::Mac), 2 => Some(UuidVersion::Dce), 3 => Some(UuidVersion::Md5), 4 => Some(UuidVersion::Random), 5 => Some(UuidVersion::Sha1), _ => None, } } /// Return an array of 16 octets containing the UUID data pub fn as_bytes<'a>(&'a self) -> &'a [u8] { &self.bytes } /// Returns the UUID as a string of 32 hexadecimal digits /// /// Example: `936DA01F9ABD4d9d80C702AF85C822A8` pub fn to_simple_string(&self) -> String { let mut s = repeat(0u8).take(32).collect::>(); for i in 0..16 { let digit = format!("{:02x}", self.bytes[i] as usize); s[i * 2 + 0] = digit.as_bytes()[0]; s[i * 2 + 1] = digit.as_bytes()[1]; } String::from_utf8(s).unwrap() } /// Returns a string of hexadecimal digits, separated into groups with a hyphen. /// /// Example: `550e8400-e29b-41d4-a716-446655440000` pub fn to_hyphenated_string(&self) -> String { // Convert to field-based struct as it matches groups in output. // Ensure fields are in network byte order, as per RFC. let mut uf: UuidFields; unsafe { uf = transmute_copy(&self.bytes); } uf.data1 = uf.data1.to_be(); uf.data2 = uf.data2.to_be(); uf.data3 = uf.data3.to_be(); let s = format!("{:08x}-{:04x}-{:04x}-{:02x}{:02x}-{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}", uf.data1, uf.data2, uf.data3, uf.data4[0], uf.data4[1], uf.data4[2], uf.data4[3], uf.data4[4], uf.data4[5], uf.data4[6], uf.data4[7]); s } /// Returns the UUID formatted as a full URN string /// /// This is the same as the hyphenated format, but with the "urn:uuid:" prefix. /// /// Example: `urn:uuid:F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4` pub fn to_urn_string(&self) -> String { format!("urn:uuid:{}", self.to_hyphenated_string()) } /// Parses a UUID from a string of hexadecimal digits with optional hyphens /// /// Any of the formats generated by this module (simple, hyphenated, urn) are /// supported by this parsing function. pub fn parse_str(mut input: &str) -> Result { // Ensure length is valid for any of the supported formats let len = input.len(); if len == 45 && input.starts_with("urn:uuid:") { input = &input[9..]; } else if len != 32 && len != 36 { return Err(ParseError::InvalidLength(len)); } // `digit` counts only hexadecimal digits, `i_char` counts all chars. let mut digit = 0; let mut group = 0; let mut acc = 0; let mut buffer = [0u8; 16]; for (i_char, chr) in input.chars().enumerate() { if digit % 2 == 0 { // First digit of the byte. match chr { // Calulate upper half. '0'...'9' => acc = chr as u8 - '0' as u8, 'a'...'f' => acc = chr as u8 - 'a' as u8 + 10, 'A'...'F' => acc = chr as u8 - 'A' as u8 + 10, // Found a group delimiter '-' => { if ACC_GROUP_LENS[group] != digit { // Calculate how many digits this group consists of in the input. let found = if group > 0 { digit - ACC_GROUP_LENS[group - 1] } else { digit }; return Err(ParseError::InvalidGroupLength(group, found as usize, GROUP_LENS[group])); } // Next group, decrement digit, it is incremented again at the bottom. group += 1; digit -= 1; } _ => return Err(ParseError::InvalidCharacter(chr, i_char)), } } else { // Second digit of the byte, shift the upper half. acc *= 16; match chr { '0'...'9' => acc += chr as u8 - '0' as u8, 'a'...'f' => acc += chr as u8 - 'a' as u8 + 10, 'A'...'F' => acc += chr as u8 - 'A' as u8 + 10, '-' => { // The byte isn't complete yet. let found = if group > 0 { digit - ACC_GROUP_LENS[group - 1] } else { digit }; return Err(ParseError::InvalidGroupLength(group, found as usize, GROUP_LENS[group])); } _ => return Err(ParseError::InvalidCharacter(chr, i_char)), } buffer[(digit / 2) as usize] = acc; } digit += 1; } // Now check the last group. if group != 0 && group != 4 { return Err(ParseError::InvalidGroups(group + 1)); } else if ACC_GROUP_LENS[4] != digit { return Err(ParseError::InvalidGroupLength(group, (digit - ACC_GROUP_LENS[3]) as usize, GROUP_LENS[4])); } Ok(Uuid::from_bytes(&mut buffer).unwrap()) } /// Tests if the UUID is nil pub fn is_nil(&self) -> bool { self.bytes.iter().all(|&b| b == 0) } } fn copy_memory(dst: &mut [u8], src: &[u8]) { for (slot, val) in dst.iter_mut().zip(src.iter()) { *slot = *val; } } impl Default for Uuid { /// Returns the nil UUID, which is all zeroes fn default() -> Uuid { Uuid::nil() } } impl FromStr for Uuid { type Err = ParseError; /// Parse a hex string and interpret as a UUID /// /// Accepted formats are a sequence of 32 hexadecimal characters, /// with or without hyphens (grouped as 8, 4, 4, 4, 12). fn from_str(us: &str) -> Result { Uuid::parse_str(us) } } /// Convert the UUID to a hexadecimal-based string representation wrapped in `Uuid()` impl fmt::Debug for Uuid { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Uuid(\"{}\")", self.to_hyphenated_string()) } } /// Convert the UUID to a hexadecimal-based string representation impl fmt::Display for Uuid { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.to_hyphenated_string()) } } /// Test two UUIDs for equality /// /// UUIDs are equal only when they are byte-for-byte identical impl PartialEq for Uuid { fn eq(&self, other: &Uuid) -> bool { self.bytes == other.bytes } } impl Eq for Uuid {} // FIXME #9845: Test these more thoroughly impl Encodable for Uuid { /// Encode a UUID as a hyphenated string fn encode(&self, e: &mut E) -> Result<(), E::Error> { e.emit_str(&self.to_hyphenated_string()) } } impl Decodable for Uuid { /// Decode a UUID from a string fn decode(d: &mut D) -> Result { let string = try!(d.read_str()); string.parse().map_err(|err| d.error(&format!("{}", err))) } } #[cfg(feature = "serde")] impl Serialize for Uuid { fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> { serializer.visit_str(&self.to_hyphenated_string()) } } #[cfg(feature = "serde")] impl Deserialize for Uuid { fn deserialize(deserializer: &mut D) -> Result { struct UuidVisitor; impl de::Visitor for UuidVisitor { type Value = Uuid; fn visit_str(&mut self, value: &str) -> Result { value.parse().map_err(|err| E::syntax(&format!("{}", err))) } fn visit_bytes(&mut self, value: &[u8]) -> Result { Uuid::from_bytes(value).ok_or(E::syntax("Expected 16 bytes.")) } } deserializer.visit(UuidVisitor) } } /// Generates a random instance of UUID (V4 conformant) impl rand::Rand for Uuid { #[inline] fn rand(rng: &mut R) -> Uuid { let ub = rng.gen_iter::().take(16).collect::>(); let mut uuid = Uuid { bytes: [0; 16] }; copy_memory(&mut uuid.bytes, &ub); uuid.set_variant(UuidVariant::RFC4122); uuid.set_version(UuidVersion::Random); uuid } } #[cfg(test)] mod tests { use super::{Uuid, UuidVariant, UuidVersion}; use rand; #[test] fn test_nil() { let nil = Uuid::nil(); let not_nil = Uuid::new_v4(); assert!(nil.is_nil()); assert!(!not_nil.is_nil()); } #[test] fn test_new() { // Supported let uuid1 = Uuid::new(UuidVersion::Random).unwrap(); let s = uuid1.to_simple_string(); assert!(s.len() == 32); assert!(uuid1.get_version().unwrap() == UuidVersion::Random); // Test unsupported versions assert!(Uuid::new(UuidVersion::Mac) == None); assert!(Uuid::new(UuidVersion::Dce) == None); assert!(Uuid::new(UuidVersion::Md5) == None); assert!(Uuid::new(UuidVersion::Sha1) == None); } #[test] fn test_new_v4() { let uuid1 = Uuid::new_v4(); assert!(uuid1.get_version().unwrap() == UuidVersion::Random); assert!(uuid1.get_variant().unwrap() == UuidVariant::RFC4122); } #[test] fn test_get_version() { let uuid1 = Uuid::new_v4(); assert!(uuid1.get_version().unwrap() == UuidVersion::Random); assert!(uuid1.get_version_num() == 4); } #[test] fn test_get_variant() { let uuid1 = Uuid::new_v4(); let uuid2 = Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000").unwrap(); let uuid3 = Uuid::parse_str("67e55044-10b1-426f-9247-bb680e5fe0c8").unwrap(); let uuid4 = Uuid::parse_str("936DA01F9ABD4d9dC0C702AF85C822A8").unwrap(); let uuid5 = Uuid::parse_str("F9168C5E-CEB2-4faa-D6BF-329BF39FA1E4").unwrap(); let uuid6 = Uuid::parse_str("f81d4fae-7dec-11d0-7765-00a0c91e6bf6").unwrap(); assert!(uuid1.get_variant().unwrap() == UuidVariant::RFC4122); assert!(uuid2.get_variant().unwrap() == UuidVariant::RFC4122); assert!(uuid3.get_variant().unwrap() == UuidVariant::RFC4122); assert!(uuid4.get_variant().unwrap() == UuidVariant::Microsoft); assert!(uuid5.get_variant().unwrap() == UuidVariant::Microsoft); assert!(uuid6.get_variant().unwrap() == UuidVariant::NCS); } #[test] fn test_parse_uuid_v4() { use super::ParseError::*; // Invalid assert_eq!(Uuid::parse_str(""), Err(InvalidLength(0))); assert_eq!(Uuid::parse_str("!"), Err(InvalidLength(1))); assert_eq!(Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E45"), Err(InvalidLength(37))); assert_eq!(Uuid::parse_str("F9168C5E-CEB2-4faa-BBF-329BF39FA1E4"), Err(InvalidLength(35))); assert_eq!(Uuid::parse_str("F9168C5E-CEB2-4faa-BGBF-329BF39FA1E4"), Err(InvalidCharacter('G', 20))); assert_eq!(Uuid::parse_str("F9168C5E-CEB2-4faa-B6BFF329BF39FA1E4"), Err(InvalidGroups(4))); assert_eq!(Uuid::parse_str("F9168C5E-CEB2-4faa"), Err(InvalidLength(18))); assert_eq!(Uuid::parse_str("F9168C5E-CEB2-4faaXB6BFF329BF39FA1E4"), Err(InvalidCharacter('X', 18))); assert_eq!(Uuid::parse_str("F9168C5E-CEB-24fa-eB6BFF32-BF39FA1E4"), Err(InvalidGroupLength(1, 3, 4))); assert_eq!(Uuid::parse_str("01020304-1112-2122-3132-41424344"), Err(InvalidGroupLength(4, 8, 12))); assert_eq!(Uuid::parse_str("67e5504410b1426f9247bb680e5fe0c"), Err(InvalidLength(31))); assert_eq!(Uuid::parse_str("67e5504410b1426f9247bb680e5fe0c88"), Err(InvalidLength(33))); assert_eq!(Uuid::parse_str("67e5504410b1426f9247bb680e5fe0cg8"), Err(InvalidLength(33))); assert_eq!(Uuid::parse_str("67e5504410b1426%9247bb680e5fe0c8"), Err(InvalidCharacter('%', 15))); // Valid assert!(Uuid::parse_str("00000000000000000000000000000000").is_ok()); assert!(Uuid::parse_str("67e55044-10b1-426f-9247-bb680e5fe0c8").is_ok()); assert!(Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4").is_ok()); assert!(Uuid::parse_str("67e5504410b1426f9247bb680e5fe0c8").is_ok()); assert!(Uuid::parse_str("01020304-1112-2122-3132-414243444546").is_ok()); assert!(Uuid::parse_str("urn:uuid:67e55044-10b1-426f-9247-bb680e5fe0c8").is_ok()); // Nil let nil = Uuid::nil(); assert!(Uuid::parse_str("00000000000000000000000000000000").unwrap() == nil); assert!(Uuid::parse_str("00000000-0000-0000-0000-000000000000").unwrap() == nil); // Round-trip let uuid_orig = Uuid::new_v4(); let orig_str = uuid_orig.to_string(); let uuid_out = Uuid::parse_str(&orig_str).unwrap(); assert!(uuid_orig == uuid_out); // Test error reporting assert_eq!(Uuid::parse_str("67e5504410b1426f9247bb680e5fe0c"), Err(InvalidLength(31))); assert_eq!(Uuid::parse_str("67e550X410b1426f9247bb680e5fe0cd"), Err(InvalidCharacter('X', 6))); assert_eq!(Uuid::parse_str("67e550-4105b1426f9247bb680e5fe0c"), Err(InvalidGroupLength(0, 6, 8))); assert_eq!(Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF1-02BF39FA1E4"), Err(InvalidGroupLength(3, 5, 4))); } #[test] fn test_to_simple_string() { let uuid1 = Uuid::new_v4(); let s = uuid1.to_simple_string(); assert!(s.len() == 32); assert!(s.chars().all(|c| c.is_digit(16))); } #[test] fn test_to_string() { let uuid1 = Uuid::new_v4(); let s = uuid1.to_string(); assert!(s.len() == 36); assert!(s.chars().all(|c| c.is_digit(16) || c == '-')); } #[test] fn test_to_hyphenated_string() { let uuid1 = Uuid::new_v4(); let s = uuid1.to_hyphenated_string(); assert!(s.len() == 36); assert!(s.chars().all(|c| c.is_digit(16) || c == '-')); } #[test] fn test_to_urn_string() { let uuid1 = Uuid::new_v4(); let ss = uuid1.to_urn_string(); let s = &ss[9..]; assert!(ss.starts_with("urn:uuid:")); assert!(s.len() == 36); assert!(s.chars().all(|c| c.is_digit(16) || c == '-')); } #[test] fn test_to_simple_string_matching() { let uuid1 = Uuid::new_v4(); let hs = uuid1.to_hyphenated_string(); let ss = uuid1.to_simple_string(); let hsn = hs.chars().filter(|&c| c != '-').collect::(); assert!(hsn == ss); } #[test] fn test_string_roundtrip() { let uuid = Uuid::new_v4(); let hs = uuid.to_hyphenated_string(); let uuid_hs = Uuid::parse_str(&hs).unwrap(); assert!(uuid_hs == uuid); let ss = uuid.to_string(); let uuid_ss = Uuid::parse_str(&ss).unwrap(); assert!(uuid_ss == uuid); } #[test] fn test_compare() { let uuid1 = Uuid::new_v4(); let uuid2 = Uuid::new_v4(); assert!(uuid1 == uuid1); assert!(uuid2 == uuid2); assert!(uuid1 != uuid2); assert!(uuid2 != uuid1); } #[test] fn test_from_fields() { let d1: u32 = 0xa1a2a3a4; let d2: u16 = 0xb1b2; let d3: u16 = 0xc1c2; let d4: Vec = vec!(0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8); let u = Uuid::from_fields(d1, d2, d3, &d4); let expected = "a1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8".to_string(); let result = u.to_simple_string(); assert!(result == expected); } #[test] fn test_from_bytes() { let b = vec!(0xa1, 0xa2, 0xa3, 0xa4, 0xb1, 0xb2, 0xc1, 0xc2, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8); let u = Uuid::from_bytes(&b).unwrap(); let expected = "a1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8".to_string(); assert!(u.to_simple_string() == expected); } #[test] fn test_as_bytes() { let u = Uuid::new_v4(); let ub = u.as_bytes(); assert!(ub.len() == 16); assert!(!ub.iter().all(|&b| b == 0)); } #[test] fn test_bytes_roundtrip() { let b_in: [u8; 16] = [0xa1, 0xa2, 0xa3, 0xa4, 0xb1, 0xb2, 0xc1, 0xc2, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8]; let u = Uuid::from_bytes(&b_in).unwrap(); let b_out = u.as_bytes(); assert_eq!(&b_in, b_out); } #[test] fn test_operator_eq() { let u1 = Uuid::new_v4(); let u2 = u1.clone(); let u3 = Uuid::new_v4(); assert!(u1 == u1); assert!(u1 == u2); assert!(u2 == u1); assert!(u1 != u3); assert!(u3 != u1); assert!(u2 != u3); assert!(u3 != u2); } #[test] fn test_rand_rand() { let mut rng = rand::thread_rng(); let u: Uuid = rand::Rand::rand(&mut rng); let ub = u.as_bytes(); assert!(ub.len() == 16); assert!(!ub.iter().all(|&b| b == 0)); } #[test] fn test_serialize_round_trip() { use rustc_serialize::json; let u = Uuid::new_v4(); let s = json::encode(&u).unwrap(); let u2 = json::decode(&s).unwrap(); assert_eq!(u, u2); } #[test] fn test_iterbytes_impl_for_uuid() { use std::collections::HashSet; let mut set = HashSet::new(); let id1 = Uuid::new_v4(); let id2 = Uuid::new_v4(); set.insert(id1.clone()); assert!(set.contains(&id1)); assert!(!set.contains(&id2)); } } /* TODO: when benchmarking is stable, re-add these #[cfg(test)] mod bench { extern crate test; use self::test::Bencher; use super::Uuid; #[bench] pub fn create_uuids(b: &mut Bencher) { b.iter(|| { Uuid::new_v4(); }) } #[bench] pub fn uuid_to_string(b: &mut Bencher) { let u = Uuid::new_v4(); b.iter(|| { u.to_string(); }) } #[bench] pub fn parse_str(b: &mut Bencher) { let s = "urn:uuid:F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4"; b.iter(|| { Uuid::parse_str(s).unwrap(); }) } } */ deps/uuid-0.1.18/Cargo.toml0000664000175000017500000000067112607622025012362 0ustar [package] name = "uuid" version = "0.1.18" authors = ["The Rust Project Developers"] license = "MIT/Apache-2.0" readme = "README.md" repository = "https://github.com/rust-lang/uuid" homepage = "https://github.com/rust-lang/uuid" documentation = "https://doc.rust-lang.org/uuid" description = """ A library to generate and parse UUIDs. """ [dependencies] rustc-serialize = "0.3" serde = { version = "^0.6.0", optional = true } rand = "0.3" deps/uuid-0.1.18/benches/0000755000000000000000000000000012666635521013623 5ustar rootrootdeps/uuid-0.1.18/benches/parse_str.rs0000664000175000017500000000557012600113242014401 0ustar #![feature(test)] extern crate test; extern crate uuid; use test::Bencher; use uuid::Uuid; #[bench] fn bench_parse(b: &mut Bencher) { b.iter(|| { let _ = Uuid::parse_str(""); let _ = Uuid::parse_str("!"); let _ = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E45"); let _ = Uuid::parse_str("F9168C5E-CEB2-4faa-BBF-329BF39FA1E4"); let _ = Uuid::parse_str("F9168C5E-CEB2-4faa-BGBF-329BF39FA1E4"); let _ = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BFF329BF39FA1E4"); let _ = Uuid::parse_str("F9168C5E-CEB2-4faa"); let _ = Uuid::parse_str("F9168C5E-CEB2-4faaXB6BFF329BF39FA1E4"); let _ = Uuid::parse_str("F9168C5E-CEB-24fa-eB6BFF32-BF39FA1E4"); let _ = Uuid::parse_str("01020304-1112-2122-3132-41424344"); let _ = Uuid::parse_str("67e5504410b1426f9247bb680e5fe0c88"); let _ = Uuid::parse_str("67e5504410b1426f9247bb680e5fe0cg8"); let _ = Uuid::parse_str("67e5504410b1426%9247bb680e5fe0c8"); // Valid let _ = Uuid::parse_str("00000000000000000000000000000000"); let _ = Uuid::parse_str("67e55044-10b1-426f-9247-bb680e5fe0c8"); let _ = Uuid::parse_str("67e55044-10b1-426f-9247-bb680e5fe0c8"); let _ = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4"); let _ = Uuid::parse_str("67e5504410b1426f9247bb680e5fe0c8"); let _ = Uuid::parse_str("01020304-1112-2122-3132-414243444546"); let _ = Uuid::parse_str("urn:uuid:67e55044-10b1-426f-9247-bb680e5fe0c8"); // Nil let _ = Uuid::parse_str("00000000000000000000000000000000"); let _ = Uuid::parse_str("00000000-0000-0000-0000-000000000000"); // Test error reporting let _ = Uuid::parse_str("67e5504410b1426f9247bb680e5fe0c"); let _ = Uuid::parse_str("67e550X410b1426f9247bb680e5fe0cd"); let _ = Uuid::parse_str("67e550-4105b1426f9247bb680e5fe0c"); let _ = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF1-02BF39FA1E4"); }); } #[bench] fn bench_parse_invalid_len(b: &mut Bencher) { b.iter(|| { let _ = Uuid::parse_str("F9168C5E-CEB2-4faa-BBF-329BF39FA1E4"); }) } #[bench] fn bench_parse_invalid_character(b: &mut Bencher) { b.iter(|| { let _ = Uuid::parse_str("F9168C5E-CEB2-4faa-BGBF-329BF39FA1E4"); }) } #[bench] fn bench_parse_invalid_group_len(b: &mut Bencher) { b.iter(|| { let _ = Uuid::parse_str("01020304-1112-2122-3132-41424344"); }); } #[bench] fn bench_parse_invalid_groups(b: &mut Bencher) { b.iter(|| { let _ = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BFF329BF39FA1E4"); }); } #[bench] fn bench_valid_hyphenated(b: &mut Bencher) { b.iter(|| { let _ = Uuid::parse_str("67e55044-10b1-426f-9247-bb680e5fe0c8"); }); } #[bench] fn bench_valid_short(b: &mut Bencher) { b.iter(|| { let _ = Uuid::parse_str("67e5504410b1426f9247bb680e5fe0c8"); }); } deps/rand-0.3.13/0000755000000000000000000000000012666635520012166 5ustar rootrootdeps/rand-0.3.13/LICENSE-APACHE0000664000175000017500000002513712464062056012340 0ustar Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/rand-0.3.13/LICENSE-MIT0000664000175000017500000000205712464062056012044 0ustar Copyright (c) 2014 The Rust Project Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/rand-0.3.13/.travis.yml0000664000175000017500000000163212570767651012532 0ustar language: rust rust: - 1.0.0 - stable - beta - nightly sudo: false script: - cargo build --verbose - cargo test --verbose - | [ $TRAVIS_RUST_VERSION != nightly ] || ( cargo bench && cargo test --verbose --manifest-path=rand_macros/Cargo.toml ) - cargo doc after_success: | [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && [ $TRAVIS_RUST_VERSION = nightly ] && echo '' > target/doc/index.html && pip install ghp-import --user $USER && $HOME/.local/bin/ghp-import -n target/doc && git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages env: global: secure: RAgfURU9rInA+jx51pdayIwOPWS+rKxtz9OB2nFxPUZK9KB4DoOx4ed+gjU9Yy6gy2sGwv0T2h+u/m+EIciPdY6P/nQtnZXYm73vTO5z02p/OOrSWXRHyGK9FJgpU7H3Vw0vtXeTCJgd6WKmfxGYYjyVY//pNDUoMNHo74P+HjU= notifications: email: on_success: never deps/rand-0.3.13/README.md0000664000175000017500000000275512635316667011706 0ustar rand ==== A Rust library for random number generators and other randomness functionality. [![Build Status](https://travis-ci.org/rust-lang-nursery/rand.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/rand) [![Build status](https://ci.appveyor.com/api/projects/status/rm5c9o33k3jhchbw?svg=true)](https://ci.appveyor.com/project/alexcrichton/rand) [Documentation](https://doc.rust-lang.org/rand) ## Usage Add this to your `Cargo.toml`: ```toml [dependencies] rand = "0.3" ``` and this to your crate root: ```rust extern crate rand; ``` ## Examples There is built-in support for a random number generator (RNG) associated with each thread stored in thread-local storage. This RNG can be accessed via thread_rng, or used implicitly via random. This RNG is normally randomly seeded from an operating-system source of randomness, e.g. /dev/urandom on Unix systems, and will automatically reseed itself from this source after generating 32 KiB of random data. ```rust let tuple = rand::random::<(f64, char)>(); println!("{:?}", tuple) ``` ```rust use rand::Rng; let mut rng = rand::thread_rng(); if rng.gen() { // random bool println!("i32: {}, u32: {}", rng.gen::(), rng.gen::()) } ``` It is also possible to use other RNG types, which have a similar interface. The following uses the "ChaCha" algorithm instead of the default. ```rust use rand::{Rng, ChaChaRng}; let mut rng = rand::ChaChaRng::new_unseeded(); println!("i32: {}, u32: {}", rng.gen::(), rng.gen::()) ``` deps/rand-0.3.13/.gitignore0000664000175000017500000000002212465170026012364 0ustar target Cargo.lock deps/rand-0.3.13/src/0000755000000000000000000000000012666635520012755 5ustar rootrootdeps/rand-0.3.13/src/lib.rs0000664000175000017500000011301612616224325012307 0ustar // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Utilities for random number generation //! //! The key functions are `random()` and `Rng::gen()`. These are polymorphic and //! so can be used to generate any type that implements `Rand`. Type inference //! means that often a simple call to `rand::random()` or `rng.gen()` will //! suffice, but sometimes an annotation is required, e.g. //! `rand::random::()`. //! //! See the `distributions` submodule for sampling random numbers from //! distributions like normal and exponential. //! //! # Usage //! //! This crate is [on crates.io](https://crates.io/crates/rand) and can be //! used by adding `rand` to the dependencies in your project's `Cargo.toml`. //! //! ```toml //! [dependencies] //! rand = "0.3" //! ``` //! //! and this to your crate root: //! //! ```rust //! extern crate rand; //! ``` //! //! # Thread-local RNG //! //! There is built-in support for a RNG associated with each thread stored //! in thread-local storage. This RNG can be accessed via `thread_rng`, or //! used implicitly via `random`. This RNG is normally randomly seeded //! from an operating-system source of randomness, e.g. `/dev/urandom` on //! Unix systems, and will automatically reseed itself from this source //! after generating 32 KiB of random data. //! //! # Cryptographic security //! //! An application that requires an entropy source for cryptographic purposes //! must use `OsRng`, which reads randomness from the source that the operating //! system provides (e.g. `/dev/urandom` on Unixes or `CryptGenRandom()` on //! Windows). //! The other random number generators provided by this module are not suitable //! for such purposes. //! //! *Note*: many Unix systems provide `/dev/random` as well as `/dev/urandom`. //! This module uses `/dev/urandom` for the following reasons: //! //! - On Linux, `/dev/random` may block if entropy pool is empty; //! `/dev/urandom` will not block. This does not mean that `/dev/random` //! provides better output than `/dev/urandom`; the kernel internally runs a //! cryptographically secure pseudorandom number generator (CSPRNG) based on //! entropy pool for random number generation, so the "quality" of //! `/dev/random` is not better than `/dev/urandom` in most cases. However, //! this means that `/dev/urandom` can yield somewhat predictable randomness //! if the entropy pool is very small, such as immediately after first //! booting. Linux 3.17 added the `getrandom(2)` system call which solves //! the issue: it blocks if entropy pool is not initialized yet, but it does //! not block once initialized. `OsRng` tries to use `getrandom(2)` if //! available, and use `/dev/urandom` fallback if not. If an application //! does not have `getrandom` and likely to be run soon after first booting, //! or on a system with very few entropy sources, one should consider using //! `/dev/random` via `ReadRng`. //! - On some systems (e.g. FreeBSD, OpenBSD and Mac OS X) there is no //! difference between the two sources. (Also note that, on some systems //! e.g. FreeBSD, both `/dev/random` and `/dev/urandom` may block once if //! the CSPRNG has not seeded yet.) //! //! # Examples //! //! ```rust //! use rand::Rng; //! //! let mut rng = rand::thread_rng(); //! if rng.gen() { // random bool //! println!("i32: {}, u32: {}", rng.gen::(), rng.gen::()) //! } //! ``` //! //! ```rust //! let tuple = rand::random::<(f64, char)>(); //! println!("{:?}", tuple) //! ``` //! //! ## Monte Carlo estimation of π //! //! For this example, imagine we have a square with sides of length 2 and a unit //! circle, both centered at the origin. Since the area of a unit circle is π, //! we have: //! //! ```text //! (area of unit circle) / (area of square) = π / 4 //! ``` //! //! So if we sample many points randomly from the square, roughly π / 4 of them //! should be inside the circle. //! //! We can use the above fact to estimate the value of π: pick many points in //! the square at random, calculate the fraction that fall within the circle, //! and multiply this fraction by 4. //! //! ``` //! use rand::distributions::{IndependentSample, Range}; //! //! fn main() { //! let between = Range::new(-1f64, 1.); //! let mut rng = rand::thread_rng(); //! //! let total = 1_000_000; //! let mut in_circle = 0; //! //! for _ in 0..total { //! let a = between.ind_sample(&mut rng); //! let b = between.ind_sample(&mut rng); //! if a*a + b*b <= 1. { //! in_circle += 1; //! } //! } //! //! // prints something close to 3.14159... //! println!("{}", 4. * (in_circle as f64) / (total as f64)); //! } //! ``` //! //! ## Monty Hall Problem //! //! This is a simulation of the [Monty Hall Problem][]: //! //! > Suppose you're on a game show, and you're given the choice of three doors: //! > Behind one door is a car; behind the others, goats. You pick a door, say //! > No. 1, and the host, who knows what's behind the doors, opens another //! > door, say No. 3, which has a goat. He then says to you, "Do you want to //! > pick door No. 2?" Is it to your advantage to switch your choice? //! //! The rather unintuitive answer is that you will have a 2/3 chance of winning //! if you switch and a 1/3 chance of winning if you don't, so it's better to //! switch. //! //! This program will simulate the game show and with large enough simulation //! steps it will indeed confirm that it is better to switch. //! //! [Monty Hall Problem]: http://en.wikipedia.org/wiki/Monty_Hall_problem //! //! ``` //! use rand::Rng; //! use rand::distributions::{IndependentSample, Range}; //! //! struct SimulationResult { //! win: bool, //! switch: bool, //! } //! //! // Run a single simulation of the Monty Hall problem. //! fn simulate(random_door: &Range, rng: &mut R) //! -> SimulationResult { //! let car = random_door.ind_sample(rng); //! //! // This is our initial choice //! let mut choice = random_door.ind_sample(rng); //! //! // The game host opens a door //! let open = game_host_open(car, choice, rng); //! //! // Shall we switch? //! let switch = rng.gen(); //! if switch { //! choice = switch_door(choice, open); //! } //! //! SimulationResult { win: choice == car, switch: switch } //! } //! //! // Returns the door the game host opens given our choice and knowledge of //! // where the car is. The game host will never open the door with the car. //! fn game_host_open(car: u32, choice: u32, rng: &mut R) -> u32 { //! let choices = free_doors(&[car, choice]); //! rand::sample(rng, choices.into_iter(), 1)[0] //! } //! //! // Returns the door we switch to, given our current choice and //! // the open door. There will only be one valid door. //! fn switch_door(choice: u32, open: u32) -> u32 { //! free_doors(&[choice, open])[0] //! } //! //! fn free_doors(blocked: &[u32]) -> Vec { //! (0..3).filter(|x| !blocked.contains(x)).collect() //! } //! //! fn main() { //! // The estimation will be more accurate with more simulations //! let num_simulations = 10000; //! //! let mut rng = rand::thread_rng(); //! let random_door = Range::new(0, 3); //! //! let (mut switch_wins, mut switch_losses) = (0, 0); //! let (mut keep_wins, mut keep_losses) = (0, 0); //! //! println!("Running {} simulations...", num_simulations); //! for _ in 0..num_simulations { //! let result = simulate(&random_door, &mut rng); //! //! match (result.win, result.switch) { //! (true, true) => switch_wins += 1, //! (true, false) => keep_wins += 1, //! (false, true) => switch_losses += 1, //! (false, false) => keep_losses += 1, //! } //! } //! //! let total_switches = switch_wins + switch_losses; //! let total_keeps = keep_wins + keep_losses; //! //! println!("Switched door {} times with {} wins and {} losses", //! total_switches, switch_wins, switch_losses); //! //! println!("Kept our choice {} times with {} wins and {} losses", //! total_keeps, keep_wins, keep_losses); //! //! // With a large number of simulations, the values should converge to //! // 0.667 and 0.333 respectively. //! println!("Estimated chance to win if we switch: {}", //! switch_wins as f32 / total_switches as f32); //! println!("Estimated chance to win if we don't: {}", //! keep_wins as f32 / total_keeps as f32); //! } //! ``` #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", html_favicon_url = "https://www.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/rand/")] #[cfg(test)] #[macro_use] extern crate log; use std::cell::RefCell; use std::marker; use std::mem; use std::io; use std::rc::Rc; use std::num::Wrapping as w; pub use os::OsRng; pub use isaac::{IsaacRng, Isaac64Rng}; pub use chacha::ChaChaRng; #[cfg(target_pointer_width = "32")] use IsaacRng as IsaacWordRng; #[cfg(target_pointer_width = "64")] use Isaac64Rng as IsaacWordRng; use distributions::{Range, IndependentSample}; use distributions::range::SampleRange; pub mod distributions; pub mod isaac; pub mod chacha; pub mod reseeding; mod rand_impls; pub mod os; pub mod read; #[allow(bad_style)] type w64 = w; #[allow(bad_style)] type w32 = w; /// A type that can be randomly generated using an `Rng`. pub trait Rand : Sized { /// Generates a random instance of this type using the specified source of /// randomness. fn rand(rng: &mut R) -> Self; } /// A random number generator. pub trait Rng { /// Return the next random u32. /// /// This rarely needs to be called directly, prefer `r.gen()` to /// `r.next_u32()`. // FIXME #7771: Should be implemented in terms of next_u64 fn next_u32(&mut self) -> u32; /// Return the next random u64. /// /// By default this is implemented in terms of `next_u32`. An /// implementation of this trait must provide at least one of /// these two methods. Similarly to `next_u32`, this rarely needs /// to be called directly, prefer `r.gen()` to `r.next_u64()`. fn next_u64(&mut self) -> u64 { ((self.next_u32() as u64) << 32) | (self.next_u32() as u64) } /// Return the next random f32 selected from the half-open /// interval `[0, 1)`. /// /// This uses a technique described by Saito and Matsumoto at /// MCQMC'08. Given that the IEEE floating point numbers are /// uniformly distributed over [1,2), we generate a number in /// this range and then offset it onto the range [0,1). Our /// choice of bits (masking v. shifting) is arbitrary and /// should be immaterial for high quality generators. For low /// quality generators (ex. LCG), prefer bitshifting due to /// correlation between sequential low order bits. /// /// See: /// A PRNG specialized in double precision floating point numbers using /// an affine transition /// http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/ARTICLES/dSFMT.pdf /// http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/dSFMT-slide-e.pdf /// /// By default this is implemented in terms of `next_u32`, but a /// random number generator which can generate numbers satisfying /// the requirements directly can overload this for performance. /// It is required that the return value lies in `[0, 1)`. /// /// See `Closed01` for the closed interval `[0,1]`, and /// `Open01` for the open interval `(0,1)`. fn next_f32(&mut self) -> f32 { const UPPER_MASK: u32 = 0x3F800000; const LOWER_MASK: u32 = 0x7FFFFF; let tmp = UPPER_MASK | (self.next_u32() & LOWER_MASK); let result: f32 = unsafe { mem::transmute(tmp) }; result - 1.0 } /// Return the next random f64 selected from the half-open /// interval `[0, 1)`. /// /// By default this is implemented in terms of `next_u64`, but a /// random number generator which can generate numbers satisfying /// the requirements directly can overload this for performance. /// It is required that the return value lies in `[0, 1)`. /// /// See `Closed01` for the closed interval `[0,1]`, and /// `Open01` for the open interval `(0,1)`. fn next_f64(&mut self) -> f64 { const UPPER_MASK: u64 = 0x3FF0000000000000; const LOWER_MASK: u64 = 0xFFFFFFFFFFFFF; let tmp = UPPER_MASK | (self.next_u64() & LOWER_MASK); let result: f64 = unsafe { mem::transmute(tmp) }; result - 1.0 } /// Fill `dest` with random data. /// /// This has a default implementation in terms of `next_u64` and /// `next_u32`, but should be overridden by implementations that /// offer a more efficient solution than just calling those /// methods repeatedly. /// /// This method does *not* have a requirement to bear any fixed /// relationship to the other methods, for example, it does *not* /// have to result in the same output as progressively filling /// `dest` with `self.gen::()`, and any such behaviour should /// not be relied upon. /// /// This method should guarantee that `dest` is entirely filled /// with new data, and may panic if this is impossible /// (e.g. reading past the end of a file that is being used as the /// source of randomness). /// /// # Example /// /// ```rust /// use rand::{thread_rng, Rng}; /// /// let mut v = [0u8; 13579]; /// thread_rng().fill_bytes(&mut v); /// println!("{:?}", &v[..]); /// ``` fn fill_bytes(&mut self, dest: &mut [u8]) { // this could, in theory, be done by transmuting dest to a // [u64], but this is (1) likely to be undefined behaviour for // LLVM, (2) has to be very careful about alignment concerns, // (3) adds more `unsafe` that needs to be checked, (4) // probably doesn't give much performance gain if // optimisations are on. let mut count = 0; let mut num = 0; for byte in dest.iter_mut() { if count == 0 { // we could micro-optimise here by generating a u32 if // we only need a few more bytes to fill the vector // (i.e. at most 4). num = self.next_u64(); count = 8; } *byte = (num & 0xff) as u8; num >>= 8; count -= 1; } } /// Return a random value of a `Rand` type. /// /// # Example /// /// ```rust /// use rand::{thread_rng, Rng}; /// /// let mut rng = thread_rng(); /// let x: u32 = rng.gen(); /// println!("{}", x); /// println!("{:?}", rng.gen::<(f64, bool)>()); /// ``` #[inline(always)] fn gen(&mut self) -> T where Self: Sized { Rand::rand(self) } /// Return an iterator that will yield an infinite number of randomly /// generated items. /// /// # Example /// /// ``` /// use rand::{thread_rng, Rng}; /// /// let mut rng = thread_rng(); /// let x = rng.gen_iter::().take(10).collect::>(); /// println!("{:?}", x); /// println!("{:?}", rng.gen_iter::<(f64, bool)>().take(5) /// .collect::>()); /// ``` fn gen_iter<'a, T: Rand>(&'a mut self) -> Generator<'a, T, Self> where Self: Sized { Generator { rng: self, _marker: marker::PhantomData } } /// Generate a random value in the range [`low`, `high`). /// /// This is a convenience wrapper around /// `distributions::Range`. If this function will be called /// repeatedly with the same arguments, one should use `Range`, as /// that will amortize the computations that allow for perfect /// uniformity, as they only happen on initialization. /// /// # Panics /// /// Panics if `low >= high`. /// /// # Example /// /// ```rust /// use rand::{thread_rng, Rng}; /// /// let mut rng = thread_rng(); /// let n: u32 = rng.gen_range(0, 10); /// println!("{}", n); /// let m: f64 = rng.gen_range(-40.0f64, 1.3e5f64); /// println!("{}", m); /// ``` fn gen_range(&mut self, low: T, high: T) -> T where Self: Sized { assert!(low < high, "Rng.gen_range called with low >= high"); Range::new(low, high).ind_sample(self) } /// Return a bool with a 1 in n chance of true /// /// # Example /// /// ```rust /// use rand::{thread_rng, Rng}; /// /// let mut rng = thread_rng(); /// println!("{}", rng.gen_weighted_bool(3)); /// ``` fn gen_weighted_bool(&mut self, n: u32) -> bool where Self: Sized { n <= 1 || self.gen_range(0, n) == 0 } /// Return an iterator of random characters from the set A-Z,a-z,0-9. /// /// # Example /// /// ```rust /// use rand::{thread_rng, Rng}; /// /// let s: String = thread_rng().gen_ascii_chars().take(10).collect(); /// println!("{}", s); /// ``` fn gen_ascii_chars<'a>(&'a mut self) -> AsciiGenerator<'a, Self> where Self: Sized { AsciiGenerator { rng: self } } /// Return a random element from `values`. /// /// Return `None` if `values` is empty. /// /// # Example /// /// ``` /// use rand::{thread_rng, Rng}; /// /// let choices = [1, 2, 4, 8, 16, 32]; /// let mut rng = thread_rng(); /// println!("{:?}", rng.choose(&choices)); /// assert_eq!(rng.choose(&choices[..0]), None); /// ``` fn choose<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> where Self: Sized { if values.is_empty() { None } else { Some(&values[self.gen_range(0, values.len())]) } } /// Shuffle a mutable slice in place. /// /// # Example /// /// ```rust /// use rand::{thread_rng, Rng}; /// /// let mut rng = thread_rng(); /// let mut y = [1, 2, 3]; /// rng.shuffle(&mut y); /// println!("{:?}", y); /// rng.shuffle(&mut y); /// println!("{:?}", y); /// ``` fn shuffle(&mut self, values: &mut [T]) where Self: Sized { let mut i = values.len(); while i >= 2 { // invariant: elements with index >= i have been locked in place. i -= 1; // lock element i in place. values.swap(i, self.gen_range(0, i + 1)); } } } impl<'a, R: ?Sized> Rng for &'a mut R where R: Rng { fn next_u32(&mut self) -> u32 { (**self).next_u32() } fn next_u64(&mut self) -> u64 { (**self).next_u64() } fn next_f32(&mut self) -> f32 { (**self).next_f32() } fn next_f64(&mut self) -> f64 { (**self).next_f64() } fn fill_bytes(&mut self, dest: &mut [u8]) { (**self).fill_bytes(dest) } } impl Rng for Box where R: Rng { fn next_u32(&mut self) -> u32 { (**self).next_u32() } fn next_u64(&mut self) -> u64 { (**self).next_u64() } fn next_f32(&mut self) -> f32 { (**self).next_f32() } fn next_f64(&mut self) -> f64 { (**self).next_f64() } fn fill_bytes(&mut self, dest: &mut [u8]) { (**self).fill_bytes(dest) } } /// Iterator which will generate a stream of random items. /// /// This iterator is created via the `gen_iter` method on `Rng`. pub struct Generator<'a, T, R:'a> { rng: &'a mut R, _marker: marker::PhantomData T>, } impl<'a, T: Rand, R: Rng> Iterator for Generator<'a, T, R> { type Item = T; fn next(&mut self) -> Option { Some(self.rng.gen()) } } /// Iterator which will continuously generate random ascii characters. /// /// This iterator is created via the `gen_ascii_chars` method on `Rng`. pub struct AsciiGenerator<'a, R:'a> { rng: &'a mut R, } impl<'a, R: Rng> Iterator for AsciiGenerator<'a, R> { type Item = char; fn next(&mut self) -> Option { const GEN_ASCII_STR_CHARSET: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz\ 0123456789"; Some(*self.rng.choose(GEN_ASCII_STR_CHARSET).unwrap() as char) } } /// A random number generator that can be explicitly seeded to produce /// the same stream of randomness multiple times. pub trait SeedableRng: Rng { /// Reseed an RNG with the given seed. /// /// # Example /// /// ```rust /// use rand::{Rng, SeedableRng, StdRng}; /// /// let seed: &[_] = &[1, 2, 3, 4]; /// let mut rng: StdRng = SeedableRng::from_seed(seed); /// println!("{}", rng.gen::()); /// rng.reseed(&[5, 6, 7, 8]); /// println!("{}", rng.gen::()); /// ``` fn reseed(&mut self, Seed); /// Create a new RNG with the given seed. /// /// # Example /// /// ```rust /// use rand::{Rng, SeedableRng, StdRng}; /// /// let seed: &[_] = &[1, 2, 3, 4]; /// let mut rng: StdRng = SeedableRng::from_seed(seed); /// println!("{}", rng.gen::()); /// ``` fn from_seed(seed: Seed) -> Self; } /// An Xorshift[1] random number /// generator. /// /// The Xorshift algorithm is not suitable for cryptographic purposes /// but is very fast. If you do not know for sure that it fits your /// requirements, use a more secure one such as `IsaacRng` or `OsRng`. /// /// [1]: Marsaglia, George (July 2003). ["Xorshift /// RNGs"](http://www.jstatsoft.org/v08/i14/paper). *Journal of /// Statistical Software*. Vol. 8 (Issue 14). #[allow(missing_copy_implementations)] #[derive(Clone)] pub struct XorShiftRng { x: w32, y: w32, z: w32, w: w32, } impl XorShiftRng { /// Creates a new XorShiftRng instance which is not seeded. /// /// The initial values of this RNG are constants, so all generators created /// by this function will yield the same stream of random numbers. It is /// highly recommended that this is created through `SeedableRng` instead of /// this function pub fn new_unseeded() -> XorShiftRng { XorShiftRng { x: w(0x193a6754), y: w(0xa8a7d469), z: w(0x97830e05), w: w(0x113ba7bb), } } } impl Rng for XorShiftRng { #[inline] fn next_u32(&mut self) -> u32 { let x = self.x; let t = x ^ (x << 11); self.x = self.y; self.y = self.z; self.z = self.w; let w_ = self.w; self.w = w_ ^ (w_ >> 19) ^ (t ^ (t >> 8)); self.w.0 } } impl SeedableRng<[u32; 4]> for XorShiftRng { /// Reseed an XorShiftRng. This will panic if `seed` is entirely 0. fn reseed(&mut self, seed: [u32; 4]) { assert!(!seed.iter().all(|&x| x == 0), "XorShiftRng.reseed called with an all zero seed."); self.x = w(seed[0]); self.y = w(seed[1]); self.z = w(seed[2]); self.w = w(seed[3]); } /// Create a new XorShiftRng. This will panic if `seed` is entirely 0. fn from_seed(seed: [u32; 4]) -> XorShiftRng { assert!(!seed.iter().all(|&x| x == 0), "XorShiftRng::from_seed called with an all zero seed."); XorShiftRng { x: w(seed[0]), y: w(seed[1]), z: w(seed[2]), w: w(seed[3]), } } } impl Rand for XorShiftRng { fn rand(rng: &mut R) -> XorShiftRng { let mut tuple: (u32, u32, u32, u32) = rng.gen(); while tuple == (0, 0, 0, 0) { tuple = rng.gen(); } let (x, y, z, w_) = tuple; XorShiftRng { x: w(x), y: w(y), z: w(z), w: w(w_) } } } /// A wrapper for generating floating point numbers uniformly in the /// open interval `(0,1)` (not including either endpoint). /// /// Use `Closed01` for the closed interval `[0,1]`, and the default /// `Rand` implementation for `f32` and `f64` for the half-open /// `[0,1)`. /// /// # Example /// ```rust /// use rand::{random, Open01}; /// /// let Open01(val) = random::>(); /// println!("f32 from (0,1): {}", val); /// ``` pub struct Open01(pub F); /// A wrapper for generating floating point numbers uniformly in the /// closed interval `[0,1]` (including both endpoints). /// /// Use `Open01` for the closed interval `(0,1)`, and the default /// `Rand` implementation of `f32` and `f64` for the half-open /// `[0,1)`. /// /// # Example /// /// ```rust /// use rand::{random, Closed01}; /// /// let Closed01(val) = random::>(); /// println!("f32 from [0,1]: {}", val); /// ``` pub struct Closed01(pub F); /// The standard RNG. This is designed to be efficient on the current /// platform. #[derive(Copy, Clone)] pub struct StdRng { rng: IsaacWordRng, } impl StdRng { /// Create a randomly seeded instance of `StdRng`. /// /// This is a very expensive operation as it has to read /// randomness from the operating system and use this in an /// expensive seeding operation. If one is only generating a small /// number of random numbers, or doesn't need the utmost speed for /// generating each number, `thread_rng` and/or `random` may be more /// appropriate. /// /// Reading the randomness from the OS may fail, and any error is /// propagated via the `io::Result` return value. pub fn new() -> io::Result { OsRng::new().map(|mut r| StdRng { rng: r.gen() }) } } impl Rng for StdRng { #[inline] fn next_u32(&mut self) -> u32 { self.rng.next_u32() } #[inline] fn next_u64(&mut self) -> u64 { self.rng.next_u64() } } impl<'a> SeedableRng<&'a [usize]> for StdRng { fn reseed(&mut self, seed: &'a [usize]) { // the internal RNG can just be seeded from the above // randomness. self.rng.reseed(unsafe {mem::transmute(seed)}) } fn from_seed(seed: &'a [usize]) -> StdRng { StdRng { rng: SeedableRng::from_seed(unsafe {mem::transmute(seed)}) } } } /// Create a weak random number generator with a default algorithm and seed. /// /// It returns the fastest `Rng` algorithm currently available in Rust without /// consideration for cryptography or security. If you require a specifically /// seeded `Rng` for consistency over time you should pick one algorithm and /// create the `Rng` yourself. /// /// This will read randomness from the operating system to seed the /// generator. pub fn weak_rng() -> XorShiftRng { match OsRng::new() { Ok(mut r) => r.gen(), Err(e) => panic!("weak_rng: failed to create seeded RNG: {:?}", e) } } /// Controls how the thread-local RNG is reseeded. struct ThreadRngReseeder; impl reseeding::Reseeder for ThreadRngReseeder { fn reseed(&mut self, rng: &mut StdRng) { *rng = match StdRng::new() { Ok(r) => r, Err(e) => panic!("could not reseed thread_rng: {}", e) } } } const THREAD_RNG_RESEED_THRESHOLD: u64 = 32_768; type ThreadRngInner = reseeding::ReseedingRng; /// The thread-local RNG. #[derive(Clone)] pub struct ThreadRng { rng: Rc>, } /// Retrieve the lazily-initialized thread-local random number /// generator, seeded by the system. Intended to be used in method /// chaining style, e.g. `thread_rng().gen::()`. /// /// The RNG provided will reseed itself from the operating system /// after generating a certain amount of randomness. /// /// The internal RNG used is platform and architecture dependent, even /// if the operating system random number generator is rigged to give /// the same sequence always. If absolute consistency is required, /// explicitly select an RNG, e.g. `IsaacRng` or `Isaac64Rng`. pub fn thread_rng() -> ThreadRng { // used to make space in TLS for a random number generator thread_local!(static THREAD_RNG_KEY: Rc> = { let r = match StdRng::new() { Ok(r) => r, Err(e) => panic!("could not initialize thread_rng: {}", e) }; let rng = reseeding::ReseedingRng::new(r, THREAD_RNG_RESEED_THRESHOLD, ThreadRngReseeder); Rc::new(RefCell::new(rng)) }); ThreadRng { rng: THREAD_RNG_KEY.with(|t| t.clone()) } } impl Rng for ThreadRng { fn next_u32(&mut self) -> u32 { self.rng.borrow_mut().next_u32() } fn next_u64(&mut self) -> u64 { self.rng.borrow_mut().next_u64() } #[inline] fn fill_bytes(&mut self, bytes: &mut [u8]) { self.rng.borrow_mut().fill_bytes(bytes) } } /// Generates a random value using the thread-local random number generator. /// /// `random()` can generate various types of random things, and so may require /// type hinting to generate the specific type you want. /// /// This function uses the thread local random number generator. This means /// that if you're calling `random()` in a loop, caching the generator can /// increase performance. An example is shown below. /// /// # Examples /// /// ``` /// let x = rand::random::(); /// println!("{}", x); /// /// let y = rand::random::(); /// println!("{}", y); /// /// if rand::random() { // generates a boolean /// println!("Better lucky than good!"); /// } /// ``` /// /// Caching the thread local random number generator: /// /// ``` /// use rand::Rng; /// /// let mut v = vec![1, 2, 3]; /// /// for x in v.iter_mut() { /// *x = rand::random() /// } /// /// // would be faster as /// /// let mut rng = rand::thread_rng(); /// /// for x in v.iter_mut() { /// *x = rng.gen(); /// } /// ``` #[inline] pub fn random() -> T { thread_rng().gen() } /// Randomly sample up to `amount` elements from an iterator. /// /// # Example /// /// ```rust /// use rand::{thread_rng, sample}; /// /// let mut rng = thread_rng(); /// let sample = sample(&mut rng, 1..100, 5); /// println!("{:?}", sample); /// ``` pub fn sample(rng: &mut R, iterable: I, amount: usize) -> Vec where I: IntoIterator, R: Rng, { let mut iter = iterable.into_iter(); let mut reservoir: Vec = iter.by_ref().take(amount).collect(); // continue unless the iterator was exhausted if reservoir.len() == amount { for (i, elem) in iter.enumerate() { let k = rng.gen_range(0, i + 1 + amount); if let Some(spot) = reservoir.get_mut(k) { *spot = elem; } } } reservoir } #[cfg(test)] mod test { use super::{Rng, thread_rng, random, SeedableRng, StdRng, sample}; use std::iter::repeat; pub struct MyRng { inner: R } impl Rng for MyRng { fn next_u32(&mut self) -> u32 { fn next(t: &mut T) -> u32 { t.next_u32() } next(&mut self.inner) } } pub fn rng() -> MyRng<::ThreadRng> { MyRng { inner: ::thread_rng() } } struct ConstRng { i: u64 } impl Rng for ConstRng { fn next_u32(&mut self) -> u32 { self.i as u32 } fn next_u64(&mut self) -> u64 { self.i } // no fill_bytes on purpose } pub fn iter_eq(i: I, j: J) -> bool where I: IntoIterator, J: IntoIterator, I::Item: Eq { // make sure the iterators have equal length let mut i = i.into_iter(); let mut j = j.into_iter(); loop { match (i.next(), j.next()) { (Some(ref ei), Some(ref ej)) if ei == ej => { } (None, None) => return true, _ => return false, } } } #[test] fn test_fill_bytes_default() { let mut r = ConstRng { i: 0x11_22_33_44_55_66_77_88 }; // check every remainder mod 8, both in small and big vectors. let lengths = [0, 1, 2, 3, 4, 5, 6, 7, 80, 81, 82, 83, 84, 85, 86, 87]; for &n in lengths.iter() { let mut v = repeat(0u8).take(n).collect::>(); r.fill_bytes(&mut v); // use this to get nicer error messages. for (i, &byte) in v.iter().enumerate() { if byte == 0 { panic!("byte {} of {} is zero", i, n) } } } } #[test] fn test_gen_range() { let mut r = thread_rng(); for _ in 0..1000 { let a = r.gen_range(-3, 42); assert!(a >= -3 && a < 42); assert_eq!(r.gen_range(0, 1), 0); assert_eq!(r.gen_range(-12, -11), -12); } for _ in 0..1000 { let a = r.gen_range(10, 42); assert!(a >= 10 && a < 42); assert_eq!(r.gen_range(0, 1), 0); assert_eq!(r.gen_range(3_000_000, 3_000_001), 3_000_000); } } #[test] #[should_panic] #[cfg_attr(target_env = "msvc", ignore)] fn test_gen_range_panic_int() { let mut r = thread_rng(); r.gen_range(5, -2); } #[test] #[should_panic] #[cfg_attr(target_env = "msvc", ignore)] fn test_gen_range_panic_usize() { let mut r = thread_rng(); r.gen_range(5, 2); } #[test] fn test_gen_f64() { let mut r = thread_rng(); let a = r.gen::(); let b = r.gen::(); debug!("{:?}", (a, b)); } #[test] fn test_gen_weighted_bool() { let mut r = thread_rng(); assert_eq!(r.gen_weighted_bool(0), true); assert_eq!(r.gen_weighted_bool(1), true); } #[test] fn test_gen_ascii_str() { let mut r = thread_rng(); assert_eq!(r.gen_ascii_chars().take(0).count(), 0); assert_eq!(r.gen_ascii_chars().take(10).count(), 10); assert_eq!(r.gen_ascii_chars().take(16).count(), 16); } #[test] fn test_gen_vec() { let mut r = thread_rng(); assert_eq!(r.gen_iter::().take(0).count(), 0); assert_eq!(r.gen_iter::().take(10).count(), 10); assert_eq!(r.gen_iter::().take(16).count(), 16); } #[test] fn test_choose() { let mut r = thread_rng(); assert_eq!(r.choose(&[1, 1, 1]).map(|&x|x), Some(1)); let v: &[isize] = &[]; assert_eq!(r.choose(v), None); } #[test] fn test_shuffle() { let mut r = thread_rng(); let empty: &mut [isize] = &mut []; r.shuffle(empty); let mut one = [1]; r.shuffle(&mut one); let b: &[_] = &[1]; assert_eq!(one, b); let mut two = [1, 2]; r.shuffle(&mut two); assert!(two == [1, 2] || two == [2, 1]); let mut x = [1, 1, 1]; r.shuffle(&mut x); let b: &[_] = &[1, 1, 1]; assert_eq!(x, b); } #[test] fn test_thread_rng() { let mut r = thread_rng(); r.gen::(); let mut v = [1, 1, 1]; r.shuffle(&mut v); let b: &[_] = &[1, 1, 1]; assert_eq!(v, b); assert_eq!(r.gen_range(0, 1), 0); } #[test] fn test_rng_trait_object() { let mut rng = thread_rng(); { let mut r = &mut rng as &mut Rng; r.next_u32(); (&mut r).gen::(); let mut v = [1, 1, 1]; (&mut r).shuffle(&mut v); let b: &[_] = &[1, 1, 1]; assert_eq!(v, b); assert_eq!((&mut r).gen_range(0, 1), 0); } { let mut r = Box::new(rng) as Box; r.next_u32(); r.gen::(); let mut v = [1, 1, 1]; r.shuffle(&mut v); let b: &[_] = &[1, 1, 1]; assert_eq!(v, b); assert_eq!(r.gen_range(0, 1), 0); } } #[test] fn test_random() { // not sure how to test this aside from just getting some values let _n : usize = random(); let _f : f32 = random(); let _o : Option> = random(); let _many : ((), (usize, isize, Option<(u32, (bool,))>), (u8, i8, u16, i16, u32, i32, u64, i64), (f32, (f64, (f64,)))) = random(); } #[test] fn test_sample() { let min_val = 1; let max_val = 100; let mut r = thread_rng(); let vals = (min_val..max_val).collect::>(); let small_sample = sample(&mut r, vals.iter(), 5); let large_sample = sample(&mut r, vals.iter(), vals.len() + 5); assert_eq!(small_sample.len(), 5); assert_eq!(large_sample.len(), vals.len()); assert!(small_sample.iter().all(|e| { **e >= min_val && **e <= max_val })); } #[test] fn test_std_rng_seeded() { let s = thread_rng().gen_iter::().take(256).collect::>(); let mut ra: StdRng = SeedableRng::from_seed(&s[..]); let mut rb: StdRng = SeedableRng::from_seed(&s[..]); assert!(iter_eq(ra.gen_ascii_chars().take(100), rb.gen_ascii_chars().take(100))); } #[test] fn test_std_rng_reseed() { let s = thread_rng().gen_iter::().take(256).collect::>(); let mut r: StdRng = SeedableRng::from_seed(&s[..]); let string1 = r.gen_ascii_chars().take(100).collect::(); r.reseed(&s); let string2 = r.gen_ascii_chars().take(100).collect::(); assert_eq!(string1, string2); } } deps/rand-0.3.13/src/reseeding.rs0000664000175000017500000001533712526416520013515 0ustar // Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! A wrapper around another RNG that reseeds it after it //! generates a certain number of random bytes. use std::default::Default; use {Rng, SeedableRng}; /// How many bytes of entropy the underling RNG is allowed to generate /// before it is reseeded const DEFAULT_GENERATION_THRESHOLD: u64 = 32 * 1024; /// A wrapper around any RNG which reseeds the underlying RNG after it /// has generated a certain number of random bytes. pub struct ReseedingRng { rng: R, generation_threshold: u64, bytes_generated: u64, /// Controls the behaviour when reseeding the RNG. pub reseeder: Rsdr, } impl> ReseedingRng { /// Create a new `ReseedingRng` with the given parameters. /// /// # Arguments /// /// * `rng`: the random number generator to use. /// * `generation_threshold`: the number of bytes of entropy at which to reseed the RNG. /// * `reseeder`: the reseeding object to use. pub fn new(rng: R, generation_threshold: u64, reseeder: Rsdr) -> ReseedingRng { ReseedingRng { rng: rng, generation_threshold: generation_threshold, bytes_generated: 0, reseeder: reseeder } } /// Reseed the internal RNG if the number of bytes that have been /// generated exceed the threshold. pub fn reseed_if_necessary(&mut self) { if self.bytes_generated >= self.generation_threshold { self.reseeder.reseed(&mut self.rng); self.bytes_generated = 0; } } } impl> Rng for ReseedingRng { fn next_u32(&mut self) -> u32 { self.reseed_if_necessary(); self.bytes_generated += 4; self.rng.next_u32() } fn next_u64(&mut self) -> u64 { self.reseed_if_necessary(); self.bytes_generated += 8; self.rng.next_u64() } fn fill_bytes(&mut self, dest: &mut [u8]) { self.reseed_if_necessary(); self.bytes_generated += dest.len() as u64; self.rng.fill_bytes(dest) } } impl, Rsdr: Reseeder + Default> SeedableRng<(Rsdr, S)> for ReseedingRng { fn reseed(&mut self, (rsdr, seed): (Rsdr, S)) { self.rng.reseed(seed); self.reseeder = rsdr; self.bytes_generated = 0; } /// Create a new `ReseedingRng` from the given reseeder and /// seed. This uses a default value for `generation_threshold`. fn from_seed((rsdr, seed): (Rsdr, S)) -> ReseedingRng { ReseedingRng { rng: SeedableRng::from_seed(seed), generation_threshold: DEFAULT_GENERATION_THRESHOLD, bytes_generated: 0, reseeder: rsdr } } } /// Something that can be used to reseed an RNG via `ReseedingRng`. /// /// # Example /// /// ```rust /// use rand::{Rng, SeedableRng, StdRng}; /// use rand::reseeding::{Reseeder, ReseedingRng}; /// /// struct TickTockReseeder { tick: bool } /// impl Reseeder for TickTockReseeder { /// fn reseed(&mut self, rng: &mut StdRng) { /// let val = if self.tick {0} else {1}; /// rng.reseed(&[val]); /// self.tick = !self.tick; /// } /// } /// fn main() { /// let rsdr = TickTockReseeder { tick: true }; /// /// let inner = StdRng::new().unwrap(); /// let mut rng = ReseedingRng::new(inner, 10, rsdr); /// /// // this will repeat, because it gets reseeded very regularly. /// let s: String = rng.gen_ascii_chars().take(100).collect(); /// println!("{}", s); /// } /// /// ``` pub trait Reseeder { /// Reseed the given RNG. fn reseed(&mut self, rng: &mut R); } /// Reseed an RNG using a `Default` instance. This reseeds by /// replacing the RNG with the result of a `Default::default` call. #[derive(Clone, Copy)] pub struct ReseedWithDefault; impl Reseeder for ReseedWithDefault { fn reseed(&mut self, rng: &mut R) { *rng = Default::default(); } } impl Default for ReseedWithDefault { fn default() -> ReseedWithDefault { ReseedWithDefault } } #[cfg(test)] mod test { use std::default::Default; use std::iter::repeat; use super::{ReseedingRng, ReseedWithDefault}; use {SeedableRng, Rng}; struct Counter { i: u32 } impl Rng for Counter { fn next_u32(&mut self) -> u32 { self.i += 1; // very random self.i - 1 } } impl Default for Counter { fn default() -> Counter { Counter { i: 0 } } } impl SeedableRng for Counter { fn reseed(&mut self, seed: u32) { self.i = seed; } fn from_seed(seed: u32) -> Counter { Counter { i: seed } } } type MyRng = ReseedingRng; #[test] fn test_reseeding() { let mut rs = ReseedingRng::new(Counter {i:0}, 400, ReseedWithDefault); let mut i = 0; for _ in 0..1000 { assert_eq!(rs.next_u32(), i % 100); i += 1; } } #[test] fn test_rng_seeded() { let mut ra: MyRng = SeedableRng::from_seed((ReseedWithDefault, 2)); let mut rb: MyRng = SeedableRng::from_seed((ReseedWithDefault, 2)); assert!(::test::iter_eq(ra.gen_ascii_chars().take(100), rb.gen_ascii_chars().take(100))); } #[test] fn test_rng_reseed() { let mut r: MyRng = SeedableRng::from_seed((ReseedWithDefault, 3)); let string1: String = r.gen_ascii_chars().take(100).collect(); r.reseed((ReseedWithDefault, 3)); let string2: String = r.gen_ascii_chars().take(100).collect(); assert_eq!(string1, string2); } const FILL_BYTES_V_LEN: usize = 13579; #[test] fn test_rng_fill_bytes() { let mut v = repeat(0u8).take(FILL_BYTES_V_LEN).collect::>(); ::test::rng().fill_bytes(&mut v); // Sanity test: if we've gotten here, `fill_bytes` has not infinitely // recursed. assert_eq!(v.len(), FILL_BYTES_V_LEN); // To test that `fill_bytes` actually did something, check that the // average of `v` is not 0. let mut sum = 0.0; for &x in v.iter() { sum += x as f64; } assert!(sum / v.len() as f64 != 0.0); } } deps/rand-0.3.13/src/os.rs0000664000175000017500000003215112557725530012172 0ustar // Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Interfaces to the operating system provided random number //! generators. use std::io; use Rng; /// A random number generator that retrieves randomness straight from /// the operating system. Platform sources: /// /// - Unix-like systems (Linux, Android, Mac OSX): read directly from /// `/dev/urandom`, or from `getrandom(2)` system call if available. /// - Windows: calls `CryptGenRandom`, using the default cryptographic /// service provider with the `PROV_RSA_FULL` type. /// - iOS: calls SecRandomCopyBytes as /dev/(u)random is sandboxed. /// - PNaCl: calls into the `nacl-irt-random-0.1` IRT interface. /// /// This does not block. pub struct OsRng(imp::OsRng); impl OsRng { /// Create a new `OsRng`. pub fn new() -> io::Result { imp::OsRng::new().map(OsRng) } } impl Rng for OsRng { fn next_u32(&mut self) -> u32 { self.0.next_u32() } fn next_u64(&mut self) -> u64 { self.0.next_u64() } fn fill_bytes(&mut self, v: &mut [u8]) { self.0.fill_bytes(v) } } #[cfg(all(unix, not(target_os = "ios"), not(target_os = "nacl")))] mod imp { extern crate libc; use self::OsRngInner::*; use std::io; use std::fs::File; use Rng; use read::ReadRng; use std::mem; #[cfg(all(target_os = "linux", any(target_arch = "x86_64", target_arch = "x86", target_arch = "arm", target_arch = "aarch64", target_arch = "powerpc")))] fn getrandom(buf: &mut [u8]) -> libc::c_long { extern "C" { fn syscall(number: libc::c_long, ...) -> libc::c_long; } #[cfg(target_arch = "x86_64")] const NR_GETRANDOM: libc::c_long = 318; #[cfg(target_arch = "x86")] const NR_GETRANDOM: libc::c_long = 355; #[cfg(target_arch = "arm")] const NR_GETRANDOM: libc::c_long = 384; #[cfg(target_arch = "aarch64")] const NR_GETRANDOM: libc::c_long = 278; #[cfg(target_arch = "powerpc")] const NR_GETRANDOM: libc::c_long = 384; unsafe { syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(), 0) } } #[cfg(not(all(target_os = "linux", any(target_arch = "x86_64", target_arch = "x86", target_arch = "arm", target_arch = "aarch64", target_arch = "powerpc"))))] fn getrandom(_buf: &mut [u8]) -> libc::c_long { -1 } fn getrandom_fill_bytes(v: &mut [u8]) { let mut read = 0; let len = v.len(); while read < len { let result = getrandom(&mut v[read..]); if result == -1 { let err = io::Error::last_os_error(); if err.kind() == io::ErrorKind::Interrupted { continue } else { panic!("unexpected getrandom error: {}", err); } } else { read += result as usize; } } } fn getrandom_next_u32() -> u32 { let mut buf: [u8; 4] = [0u8; 4]; getrandom_fill_bytes(&mut buf); unsafe { mem::transmute::<[u8; 4], u32>(buf) } } fn getrandom_next_u64() -> u64 { let mut buf: [u8; 8] = [0u8; 8]; getrandom_fill_bytes(&mut buf); unsafe { mem::transmute::<[u8; 8], u64>(buf) } } #[cfg(all(target_os = "linux", any(target_arch = "x86_64", target_arch = "x86", target_arch = "arm", target_arch = "aarch64", target_arch = "powerpc")))] fn is_getrandom_available() -> bool { use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering}; use std::sync::{Once, ONCE_INIT}; static CHECKER: Once = ONCE_INIT; static AVAILABLE: AtomicBool = ATOMIC_BOOL_INIT; CHECKER.call_once(|| { let mut buf: [u8; 0] = []; let result = getrandom(&mut buf); let available = if result == -1 { let err = io::Error::last_os_error().raw_os_error(); err != Some(libc::ENOSYS) } else { true }; AVAILABLE.store(available, Ordering::Relaxed); }); AVAILABLE.load(Ordering::Relaxed) } #[cfg(not(all(target_os = "linux", any(target_arch = "x86_64", target_arch = "x86", target_arch = "arm", target_arch = "aarch64", target_arch = "powerpc"))))] fn is_getrandom_available() -> bool { false } pub struct OsRng { inner: OsRngInner, } enum OsRngInner { OsGetrandomRng, OsReadRng(ReadRng), } impl OsRng { pub fn new() -> io::Result { if is_getrandom_available() { return Ok(OsRng { inner: OsGetrandomRng }); } let reader = try!(File::open("/dev/urandom")); let reader_rng = ReadRng::new(reader); Ok(OsRng { inner: OsReadRng(reader_rng) }) } } impl Rng for OsRng { fn next_u32(&mut self) -> u32 { match self.inner { OsGetrandomRng => getrandom_next_u32(), OsReadRng(ref mut rng) => rng.next_u32(), } } fn next_u64(&mut self) -> u64 { match self.inner { OsGetrandomRng => getrandom_next_u64(), OsReadRng(ref mut rng) => rng.next_u64(), } } fn fill_bytes(&mut self, v: &mut [u8]) { match self.inner { OsGetrandomRng => getrandom_fill_bytes(v), OsReadRng(ref mut rng) => rng.fill_bytes(v) } } } } #[cfg(target_os = "ios")] mod imp { extern crate libc; use std::io; use std::mem; use Rng; use self::libc::{c_int, size_t}; pub struct OsRng; enum SecRandom {} #[allow(non_upper_case_globals)] const kSecRandomDefault: *const SecRandom = 0 as *const SecRandom; #[link(name = "Security", kind = "framework")] extern { fn SecRandomCopyBytes(rnd: *const SecRandom, count: size_t, bytes: *mut u8) -> c_int; } impl OsRng { pub fn new() -> io::Result { Ok(OsRng) } } impl Rng for OsRng { fn next_u32(&mut self) -> u32 { let mut v = [0u8; 4]; self.fill_bytes(&mut v); unsafe { mem::transmute(v) } } fn next_u64(&mut self) -> u64 { let mut v = [0u8; 8]; self.fill_bytes(&mut v); unsafe { mem::transmute(v) } } fn fill_bytes(&mut self, v: &mut [u8]) { let ret = unsafe { SecRandomCopyBytes(kSecRandomDefault, v.len() as size_t, v.as_mut_ptr()) }; if ret == -1 { panic!("couldn't generate random bytes: {}", io::Error::last_os_error()); } } } } #[cfg(windows)] mod imp { extern crate winapi; extern crate advapi32; use std::io; use std::mem; use std::ptr; use Rng; use self::winapi::{CRYPT_SILENT, CRYPT_VERIFYCONTEXT, DWORD, HCRYPTPROV, PROV_RSA_FULL}; use self::advapi32::{CryptAcquireContextA, CryptGenRandom, CryptReleaseContext}; pub struct OsRng { hcryptprov: HCRYPTPROV } impl OsRng { pub fn new() -> io::Result { let mut hcp = 0; let ret = unsafe { CryptAcquireContextA(&mut hcp, ptr::null(), ptr::null(), PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT) }; if ret == 0 { Err(io::Error::last_os_error()) } else { Ok(OsRng { hcryptprov: hcp }) } } } impl Rng for OsRng { fn next_u32(&mut self) -> u32 { let mut v = [0u8; 4]; self.fill_bytes(&mut v); unsafe { mem::transmute(v) } } fn next_u64(&mut self) -> u64 { let mut v = [0u8; 8]; self.fill_bytes(&mut v); unsafe { mem::transmute(v) } } fn fill_bytes(&mut self, v: &mut [u8]) { let ret = unsafe { CryptGenRandom(self.hcryptprov, v.len() as DWORD, v.as_mut_ptr()) }; if ret == 0 { panic!("couldn't generate random bytes: {}", io::Error::last_os_error()); } } } impl Drop for OsRng { fn drop(&mut self) { let ret = unsafe { CryptReleaseContext(self.hcryptprov, 0) }; if ret == 0 { panic!("couldn't release context: {}", io::Error::last_os_error()); } } } } #[cfg(target_os = "nacl")] mod imp { extern crate libc; use std::io; use std::mem; use Rng; pub struct OsRng(extern fn(dest: *mut libc::c_void, bytes: libc::size_t, read: *mut libc::size_t) -> libc::c_int); extern { fn nacl_interface_query(name: *const libc::c_char, table: *mut libc::c_void, table_size: libc::size_t) -> libc::size_t; } const INTERFACE: &'static [u8] = b"nacl-irt-random-0.1\0"; #[repr(C)] struct NaClIRTRandom { get_random_bytes: Option libc::c_int>, } impl OsRng { pub fn new() -> io::Result { let mut iface = NaClIRTRandom { get_random_bytes: None, }; let result = unsafe { nacl_interface_query(INTERFACE.as_ptr() as *const _, mem::transmute(&mut iface), mem::size_of::() as libc::size_t) }; if result != 0 { assert!(iface.get_random_bytes.is_some()); let result = OsRng(iface.get_random_bytes.take().unwrap()); Ok(result) } else { let error = io::ErrorKind::NotFound; let error = io::Error::new(error, "IRT random interface missing"); Err(error) } } } impl Rng for OsRng { fn next_u32(&mut self) -> u32 { let mut v = [0u8; 4]; self.fill_bytes(&mut v); unsafe { mem::transmute(v) } } fn next_u64(&mut self) -> u64 { let mut v = [0u8; 8]; self.fill_bytes(&mut v); unsafe { mem::transmute(v) } } fn fill_bytes(&mut self, v: &mut [u8]) { let mut read = 0; loop { let mut r: libc::size_t = 0; let len = v.len(); let error = (self.0)(v[read..].as_mut_ptr() as *mut _, (len - read) as libc::size_t, &mut r as *mut _); assert!(error == 0, "`get_random_bytes` failed!"); read += r as usize; if read >= v.len() { break; } } } } } #[cfg(test)] mod test { use std::sync::mpsc::channel; use Rng; use OsRng; use std::thread; #[test] fn test_os_rng() { let mut r = OsRng::new().unwrap(); r.next_u32(); r.next_u64(); let mut v = [0u8; 1000]; r.fill_bytes(&mut v); } #[test] fn test_os_rng_tasks() { let mut txs = vec!(); for _ in 0..20 { let (tx, rx) = channel(); txs.push(tx); thread::spawn(move|| { // wait until all the tasks are ready to go. rx.recv().unwrap(); // deschedule to attempt to interleave things as much // as possible (XXX: is this a good test?) let mut r = OsRng::new().unwrap(); thread::yield_now(); let mut v = [0u8; 1000]; for _ in 0..100 { r.next_u32(); thread::yield_now(); r.next_u64(); thread::yield_now(); r.fill_bytes(&mut v); thread::yield_now(); } }); } // start all the tasks for tx in txs.iter() { tx.send(()).unwrap(); } } } deps/rand-0.3.13/src/rand_impls.rs0000664000175000017500000001654712570767651013721 0ustar // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! The implementations of `Rand` for the built-in types. use std::char; use std::mem; use {Rand,Rng}; impl Rand for isize { #[inline] fn rand(rng: &mut R) -> isize { if mem::size_of::() == 4 { rng.gen::() as isize } else { rng.gen::() as isize } } } impl Rand for i8 { #[inline] fn rand(rng: &mut R) -> i8 { rng.next_u32() as i8 } } impl Rand for i16 { #[inline] fn rand(rng: &mut R) -> i16 { rng.next_u32() as i16 } } impl Rand for i32 { #[inline] fn rand(rng: &mut R) -> i32 { rng.next_u32() as i32 } } impl Rand for i64 { #[inline] fn rand(rng: &mut R) -> i64 { rng.next_u64() as i64 } } impl Rand for usize { #[inline] fn rand(rng: &mut R) -> usize { if mem::size_of::() == 4 { rng.gen::() as usize } else { rng.gen::() as usize } } } impl Rand for u8 { #[inline] fn rand(rng: &mut R) -> u8 { rng.next_u32() as u8 } } impl Rand for u16 { #[inline] fn rand(rng: &mut R) -> u16 { rng.next_u32() as u16 } } impl Rand for u32 { #[inline] fn rand(rng: &mut R) -> u32 { rng.next_u32() } } impl Rand for u64 { #[inline] fn rand(rng: &mut R) -> u64 { rng.next_u64() } } macro_rules! float_impls { ($mod_name:ident, $ty:ty, $mantissa_bits:expr, $method_name:ident) => { mod $mod_name { use {Rand, Rng, Open01, Closed01}; const SCALE: $ty = (1u64 << $mantissa_bits) as $ty; impl Rand for $ty { /// Generate a floating point number in the half-open /// interval `[0,1)`. /// /// See `Closed01` for the closed interval `[0,1]`, /// and `Open01` for the open interval `(0,1)`. #[inline] fn rand(rng: &mut R) -> $ty { rng.$method_name() } } impl Rand for Open01<$ty> { #[inline] fn rand(rng: &mut R) -> Open01<$ty> { // add a small amount (specifically 2 bits below // the precision of f64/f32 at 1.0), so that small // numbers are larger than 0, but large numbers // aren't pushed to/above 1. Open01(rng.$method_name() + 0.25 / SCALE) } } impl Rand for Closed01<$ty> { #[inline] fn rand(rng: &mut R) -> Closed01<$ty> { // rescale so that 1.0 - epsilon becomes 1.0 // precisely. Closed01(rng.$method_name() * SCALE / (SCALE - 1.0)) } } } } } float_impls! { f64_rand_impls, f64, 53, next_f64 } float_impls! { f32_rand_impls, f32, 24, next_f32 } impl Rand for char { #[inline] fn rand(rng: &mut R) -> char { // a char is 21 bits const CHAR_MASK: u32 = 0x001f_ffff; loop { // Rejection sampling. About 0.2% of numbers with at most // 21-bits are invalid codepoints (surrogates), so this // will succeed first go almost every time. match char::from_u32(rng.next_u32() & CHAR_MASK) { Some(c) => return c, None => {} } } } } impl Rand for bool { #[inline] fn rand(rng: &mut R) -> bool { rng.gen::() & 1 == 1 } } macro_rules! tuple_impl { // use variables to indicate the arity of the tuple ($($tyvar:ident),* ) => { // the trailing commas are for the 1 tuple impl< $( $tyvar : Rand ),* > Rand for ( $( $tyvar ),* , ) { #[inline] fn rand(_rng: &mut R) -> ( $( $tyvar ),* , ) { ( // use the $tyvar's to get the appropriate number of // repeats (they're not actually needed) $( _rng.gen::<$tyvar>() ),* , ) } } } } impl Rand for () { #[inline] fn rand(_: &mut R) -> () { () } } tuple_impl!{A} tuple_impl!{A, B} tuple_impl!{A, B, C} tuple_impl!{A, B, C, D} tuple_impl!{A, B, C, D, E} tuple_impl!{A, B, C, D, E, F} tuple_impl!{A, B, C, D, E, F, G} tuple_impl!{A, B, C, D, E, F, G, H} tuple_impl!{A, B, C, D, E, F, G, H, I} tuple_impl!{A, B, C, D, E, F, G, H, I, J} tuple_impl!{A, B, C, D, E, F, G, H, I, J, K} tuple_impl!{A, B, C, D, E, F, G, H, I, J, K, L} macro_rules! array_impl { {$n:expr, $t:ident, $($ts:ident,)*} => { array_impl!{($n - 1), $($ts,)*} impl Rand for [T; $n] where T: Rand { #[inline] fn rand(_rng: &mut R) -> [T; $n] { [_rng.gen::<$t>(), $(_rng.gen::<$ts>()),*] } } }; {$n:expr,} => { impl Rand for [T; $n] { fn rand(_rng: &mut R) -> [T; $n] { [] } } }; } array_impl!{32, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,} impl Rand for Option { #[inline] fn rand(rng: &mut R) -> Option { if rng.gen() { Some(rng.gen()) } else { None } } } #[cfg(test)] mod tests { use {Rng, thread_rng, Open01, Closed01}; struct ConstantRng(u64); impl Rng for ConstantRng { fn next_u32(&mut self) -> u32 { let ConstantRng(v) = *self; v as u32 } fn next_u64(&mut self) -> u64 { let ConstantRng(v) = *self; v } } #[test] fn floating_point_edge_cases() { // the test for exact equality is correct here. assert!(ConstantRng(0xffff_ffff).gen::() != 1.0); assert!(ConstantRng(0xffff_ffff_ffff_ffff).gen::() != 1.0); } #[test] fn rand_open() { // this is unlikely to catch an incorrect implementation that // generates exactly 0 or 1, but it keeps it sane. let mut rng = thread_rng(); for _ in 0..1_000 { // strict inequalities let Open01(f) = rng.gen::>(); assert!(0.0 < f && f < 1.0); let Open01(f) = rng.gen::>(); assert!(0.0 < f && f < 1.0); } } #[test] fn rand_closed() { let mut rng = thread_rng(); for _ in 0..1_000 { // strict inequalities let Closed01(f) = rng.gen::>(); assert!(0.0 <= f && f <= 1.0); let Closed01(f) = rng.gen::>(); assert!(0.0 <= f && f <= 1.0); } } } deps/rand-0.3.13/src/read.rs0000664000175000017500000000704612537200613012455 0ustar // Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! A wrapper around any Read to treat it as an RNG. use std::io::{self, Read}; use std::mem; use Rng; /// An RNG that reads random bytes straight from a `Read`. This will /// work best with an infinite reader, but this is not required. /// /// # Panics /// /// It will panic if it there is insufficient data to fulfill a request. /// /// # Example /// /// ```rust /// use rand::{read, Rng}; /// /// let data = vec![1, 2, 3, 4, 5, 6, 7, 8]; /// let mut rng = read::ReadRng::new(&data[..]); /// println!("{:x}", rng.gen::()); /// ``` pub struct ReadRng { reader: R } impl ReadRng { /// Create a new `ReadRng` from a `Read`. pub fn new(r: R) -> ReadRng { ReadRng { reader: r } } } impl Rng for ReadRng { fn next_u32(&mut self) -> u32 { // This is designed for speed: reading a LE integer on a LE // platform just involves blitting the bytes into the memory // of the u32, similarly for BE on BE; avoiding byteswapping. let mut buf = [0; 4]; fill(&mut self.reader, &mut buf).unwrap(); unsafe { *(buf.as_ptr() as *const u32) } } fn next_u64(&mut self) -> u64 { // see above for explanation. let mut buf = [0; 8]; fill(&mut self.reader, &mut buf).unwrap(); unsafe { *(buf.as_ptr() as *const u64) } } fn fill_bytes(&mut self, v: &mut [u8]) { if v.len() == 0 { return } fill(&mut self.reader, v).unwrap(); } } fn fill(r: &mut Read, mut buf: &mut [u8]) -> io::Result<()> { while buf.len() > 0 { match try!(r.read(buf)) { 0 => return Err(io::Error::new(io::ErrorKind::Other, "end of file reached")), n => buf = &mut mem::replace(&mut buf, &mut [])[n..], } } Ok(()) } #[cfg(test)] mod test { use super::ReadRng; use Rng; #[test] fn test_reader_rng_u64() { // transmute from the target to avoid endianness concerns. let v = vec![0u8, 0, 0, 0, 0, 0, 0, 1, 0 , 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3]; let mut rng = ReadRng::new(&v[..]); assert_eq!(rng.next_u64(), 1_u64.to_be()); assert_eq!(rng.next_u64(), 2_u64.to_be()); assert_eq!(rng.next_u64(), 3_u64.to_be()); } #[test] fn test_reader_rng_u32() { let v = vec![0u8, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3]; let mut rng = ReadRng::new(&v[..]); assert_eq!(rng.next_u32(), 1_u32.to_be()); assert_eq!(rng.next_u32(), 2_u32.to_be()); assert_eq!(rng.next_u32(), 3_u32.to_be()); } #[test] fn test_reader_rng_fill_bytes() { let v = [1u8, 2, 3, 4, 5, 6, 7, 8]; let mut w = [0u8; 8]; let mut rng = ReadRng::new(&v[..]); rng.fill_bytes(&mut w); assert!(v == w); } #[test] #[should_panic] #[cfg_attr(target_env = "msvc", ignore)] fn test_reader_rng_insufficient_bytes() { let mut rng = ReadRng::new(&[][..]); let mut v = [0u8; 3]; rng.fill_bytes(&mut v); } } deps/rand-0.3.13/src/distributions/0000755000000000000000000000000012666635520015657 5ustar rootrootdeps/rand-0.3.13/src/distributions/exponential.rs0000664000175000017500000000701212554203654016772 0ustar // Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! The exponential distribution. use {Rng, Rand}; use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample}; /// A wrapper around an `f64` to generate Exp(1) random numbers. /// /// See `Exp` for the general exponential distribution. /// /// Implemented via the ZIGNOR variant[1] of the Ziggurat method. The /// exact description in the paper was adjusted to use tables for the /// exponential distribution rather than normal. /// /// [1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to /// Generate Normal Random /// Samples*](http://www.doornik.com/research/ziggurat.pdf). Nuffield /// College, Oxford /// /// # Example /// /// ```rust /// use rand::distributions::exponential::Exp1; /// /// let Exp1(x) = rand::random(); /// println!("{}", x); /// ``` #[derive(Clone, Copy)] pub struct Exp1(pub f64); // This could be done via `-rng.gen::().ln()` but that is slower. impl Rand for Exp1 { #[inline] fn rand(rng: &mut R) -> Exp1 { #[inline] fn pdf(x: f64) -> f64 { (-x).exp() } #[inline] fn zero_case(rng: &mut R, _u: f64) -> f64 { ziggurat_tables::ZIG_EXP_R - rng.gen::().ln() } Exp1(ziggurat(rng, false, &ziggurat_tables::ZIG_EXP_X, &ziggurat_tables::ZIG_EXP_F, pdf, zero_case)) } } /// The exponential distribution `Exp(lambda)`. /// /// This distribution has density function: `f(x) = lambda * /// exp(-lambda * x)` for `x > 0`. /// /// # Example /// /// ```rust /// use rand::distributions::{Exp, IndependentSample}; /// /// let exp = Exp::new(2.0); /// let v = exp.ind_sample(&mut rand::thread_rng()); /// println!("{} is from a Exp(2) distribution", v); /// ``` #[derive(Clone, Copy)] pub struct Exp { /// `lambda` stored as `1/lambda`, since this is what we scale by. lambda_inverse: f64 } impl Exp { /// Construct a new `Exp` with the given shape parameter /// `lambda`. Panics if `lambda <= 0`. pub fn new(lambda: f64) -> Exp { assert!(lambda > 0.0, "Exp::new called with `lambda` <= 0"); Exp { lambda_inverse: 1.0 / lambda } } } impl Sample for Exp { fn sample(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) } } impl IndependentSample for Exp { fn ind_sample(&self, rng: &mut R) -> f64 { let Exp1(n) = rng.gen::(); n * self.lambda_inverse } } #[cfg(test)] mod test { use distributions::{Sample, IndependentSample}; use super::Exp; #[test] fn test_exp() { let mut exp = Exp::new(10.0); let mut rng = ::test::rng(); for _ in 0..1000 { assert!(exp.sample(&mut rng) >= 0.0); assert!(exp.ind_sample(&mut rng) >= 0.0); } } #[test] #[should_panic] #[cfg_attr(target_env = "msvc", ignore)] fn test_exp_invalid_lambda_zero() { Exp::new(0.0); } #[test] #[should_panic] #[cfg_attr(target_env = "msvc", ignore)] fn test_exp_invalid_lambda_neg() { Exp::new(-10.0); } } deps/rand-0.3.13/src/distributions/ziggurat_tables.rs0000664000175000017500000006032412501074552017632 0ustar // Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Tables for distributions which are sampled using the ziggurat // algorithm. Autogenerated by `ziggurat_tables.py`. pub type ZigTable = &'static [f64; 257]; pub const ZIG_NORM_R: f64 = 3.654152885361008796; pub static ZIG_NORM_X: [f64; 257] = [3.910757959537090045, 3.654152885361008796, 3.449278298560964462, 3.320244733839166074, 3.224575052047029100, 3.147889289517149969, 3.083526132001233044, 3.027837791768635434, 2.978603279880844834, 2.934366867207854224, 2.894121053612348060, 2.857138730872132548, 2.822877396825325125, 2.790921174000785765, 2.760944005278822555, 2.732685359042827056, 2.705933656121858100, 2.680514643284522158, 2.656283037575502437, 2.633116393630324570, 2.610910518487548515, 2.589575986706995181, 2.569035452680536569, 2.549221550323460761, 2.530075232158516929, 2.511544441625342294, 2.493583041269680667, 2.476149939669143318, 2.459208374333311298, 2.442725318198956774, 2.426670984935725972, 2.411018413899685520, 2.395743119780480601, 2.380822795170626005, 2.366237056715818632, 2.351967227377659952, 2.337996148795031370, 2.324308018869623016, 2.310888250599850036, 2.297723348901329565, 2.284800802722946056, 2.272108990226823888, 2.259637095172217780, 2.247375032945807760, 2.235313384928327984, 2.223443340090905718, 2.211756642882544366, 2.200245546609647995, 2.188902771624720689, 2.177721467738641614, 2.166695180352645966, 2.155817819875063268, 2.145083634046203613, 2.134487182844320152, 2.124023315687815661, 2.113687150684933957, 2.103474055713146829, 2.093379631137050279, 2.083399693996551783, 2.073530263516978778, 2.063767547809956415, 2.054107931648864849, 2.044547965215732788, 2.035084353727808715, 2.025713947862032960, 2.016433734904371722, 2.007240830558684852, 1.998132471356564244, 1.989106007615571325, 1.980158896898598364, 1.971288697931769640, 1.962493064942461896, 1.953769742382734043, 1.945116560006753925, 1.936531428273758904, 1.928012334050718257, 1.919557336591228847, 1.911164563769282232, 1.902832208548446369, 1.894558525668710081, 1.886341828534776388, 1.878180486290977669, 1.870072921069236838, 1.862017605397632281, 1.854013059758148119, 1.846057850283119750, 1.838150586580728607, 1.830289919680666566, 1.822474540091783224, 1.814703175964167636, 1.806974591348693426, 1.799287584547580199, 1.791640986550010028, 1.784033659547276329, 1.776464495522344977, 1.768932414909077933, 1.761436365316706665, 1.753975320315455111, 1.746548278279492994, 1.739154261283669012, 1.731792314050707216, 1.724461502945775715, 1.717160915015540690, 1.709889657069006086, 1.702646854797613907, 1.695431651932238548, 1.688243209434858727, 1.681080704722823338, 1.673943330923760353, 1.666830296159286684, 1.659740822855789499, 1.652674147080648526, 1.645629517902360339, 1.638606196773111146, 1.631603456932422036, 1.624620582830568427, 1.617656869570534228, 1.610711622367333673, 1.603784156023583041, 1.596873794420261339, 1.589979870021648534, 1.583101723393471438, 1.576238702733332886, 1.569390163412534456, 1.562555467528439657, 1.555733983466554893, 1.548925085471535512, 1.542128153226347553, 1.535342571438843118, 1.528567729435024614, 1.521803020758293101, 1.515047842773992404, 1.508301596278571965, 1.501563685112706548, 1.494833515777718391, 1.488110497054654369, 1.481394039625375747, 1.474683555695025516, 1.467978458615230908, 1.461278162507407830, 1.454582081885523293, 1.447889631277669675, 1.441200224845798017, 1.434513276002946425, 1.427828197027290358, 1.421144398672323117, 1.414461289772464658, 1.407778276843371534, 1.401094763676202559, 1.394410150925071257, 1.387723835686884621, 1.381035211072741964, 1.374343665770030531, 1.367648583594317957, 1.360949343030101844, 1.354245316759430606, 1.347535871177359290, 1.340820365893152122, 1.334098153216083604, 1.327368577624624679, 1.320630975217730096, 1.313884673146868964, 1.307128989027353860, 1.300363230327433728, 1.293586693733517645, 1.286798664489786415, 1.279998415710333237, 1.273185207661843732, 1.266358287014688333, 1.259516886060144225, 1.252660221891297887, 1.245787495544997903, 1.238897891102027415, 1.231990574742445110, 1.225064693752808020, 1.218119375481726552, 1.211153726239911244, 1.204166830140560140, 1.197157747875585931, 1.190125515422801650, 1.183069142678760732, 1.175987612011489825, 1.168879876726833800, 1.161744859441574240, 1.154581450355851802, 1.147388505416733873, 1.140164844363995789, 1.132909248648336975, 1.125620459211294389, 1.118297174115062909, 1.110938046009249502, 1.103541679420268151, 1.096106627847603487, 1.088631390649514197, 1.081114409698889389, 1.073554065787871714, 1.065948674757506653, 1.058296483326006454, 1.050595664586207123, 1.042844313139370538, 1.035040439828605274, 1.027181966030751292, 1.019266717460529215, 1.011292417434978441, 1.003256679539591412, 0.995156999629943084, 0.986990747093846266, 0.978755155288937750, 0.970447311058864615, 0.962064143217605250, 0.953602409875572654, 0.945058684462571130, 0.936429340280896860, 0.927710533396234771, 0.918898183643734989, 0.909987953490768997, 0.900975224455174528, 0.891855070726792376, 0.882622229578910122, 0.873271068082494550, 0.863795545546826915, 0.854189171001560554, 0.844444954902423661, 0.834555354079518752, 0.824512208745288633, 0.814306670128064347, 0.803929116982664893, 0.793369058833152785, 0.782615023299588763, 0.771654424216739354, 0.760473406422083165, 0.749056662009581653, 0.737387211425838629, 0.725446140901303549, 0.713212285182022732, 0.700661841097584448, 0.687767892786257717, 0.674499822827436479, 0.660822574234205984, 0.646695714884388928, 0.632072236375024632, 0.616896989996235545, 0.601104617743940417, 0.584616766093722262, 0.567338257040473026, 0.549151702313026790, 0.529909720646495108, 0.509423329585933393, 0.487443966121754335, 0.463634336771763245, 0.437518402186662658, 0.408389134588000746, 0.375121332850465727, 0.335737519180459465, 0.286174591747260509, 0.215241895913273806, 0.000000000000000000]; pub static ZIG_NORM_F: [f64; 257] = [0.000477467764586655, 0.001260285930498598, 0.002609072746106363, 0.004037972593371872, 0.005522403299264754, 0.007050875471392110, 0.008616582769422917, 0.010214971439731100, 0.011842757857943104, 0.013497450601780807, 0.015177088307982072, 0.016880083152595839, 0.018605121275783350, 0.020351096230109354, 0.022117062707379922, 0.023902203305873237, 0.025705804008632656, 0.027527235669693315, 0.029365939758230111, 0.031221417192023690, 0.033093219458688698, 0.034980941461833073, 0.036884215688691151, 0.038802707404656918, 0.040736110656078753, 0.042684144916619378, 0.044646552251446536, 0.046623094902089664, 0.048613553216035145, 0.050617723861121788, 0.052635418276973649, 0.054666461325077916, 0.056710690106399467, 0.058767952921137984, 0.060838108349751806, 0.062921024437977854, 0.065016577971470438, 0.067124653828023989, 0.069245144397250269, 0.071377949059141965, 0.073522973714240991, 0.075680130359194964, 0.077849336702372207, 0.080030515814947509, 0.082223595813495684, 0.084428509570654661, 0.086645194450867782, 0.088873592068594229, 0.091113648066700734, 0.093365311913026619, 0.095628536713353335, 0.097903279039215627, 0.100189498769172020, 0.102487158942306270, 0.104796225622867056, 0.107116667775072880, 0.109448457147210021, 0.111791568164245583, 0.114145977828255210, 0.116511665626037014, 0.118888613443345698, 0.121276805485235437, 0.123676228202051403, 0.126086870220650349, 0.128508722280473636, 0.130941777174128166, 0.133386029692162844, 0.135841476571757352, 0.138308116449064322, 0.140785949814968309, 0.143274978974047118, 0.145775208006537926, 0.148286642733128721, 0.150809290682410169, 0.153343161060837674, 0.155888264725064563, 0.158444614156520225, 0.161012223438117663, 0.163591108232982951, 0.166181285765110071, 0.168782774801850333, 0.171395595638155623, 0.174019770082499359, 0.176655321444406654, 0.179302274523530397, 0.181960655600216487, 0.184630492427504539, 0.187311814224516926, 0.190004651671193070, 0.192709036904328807, 0.195425003514885592, 0.198152586546538112, 0.200891822495431333, 0.203642749311121501, 0.206405406398679298, 0.209179834621935651, 0.211966076307852941, 0.214764175252008499, 0.217574176725178370, 0.220396127481011589, 0.223230075764789593, 0.226076071323264877, 0.228934165415577484, 0.231804410825248525, 0.234686861873252689, 0.237581574432173676, 0.240488605941449107, 0.243408015423711988, 0.246339863502238771, 0.249284212419516704, 0.252241126056943765, 0.255210669955677150, 0.258192911338648023, 0.261187919133763713, 0.264195763998317568, 0.267216518344631837, 0.270250256366959984, 0.273297054069675804, 0.276356989296781264, 0.279430141762765316, 0.282516593084849388, 0.285616426816658109, 0.288729728483353931, 0.291856585618280984, 0.294997087801162572, 0.298151326697901342, 0.301319396102034120, 0.304501391977896274, 0.307697412505553769, 0.310907558127563710, 0.314131931597630143, 0.317370638031222396, 0.320623784958230129, 0.323891482377732021, 0.327173842814958593, 0.330470981380537099, 0.333783015832108509, 0.337110066638412809, 0.340452257045945450, 0.343809713148291340, 0.347182563958251478, 0.350570941482881204, 0.353974980801569250, 0.357394820147290515, 0.360830600991175754, 0.364282468130549597, 0.367750569780596226, 0.371235057669821344, 0.374736087139491414, 0.378253817247238111, 0.381788410875031348, 0.385340034841733958, 0.388908860020464597, 0.392495061461010764, 0.396098818517547080, 0.399720314981931668, 0.403359739222868885, 0.407017284331247953, 0.410693148271983222, 0.414387534042706784, 0.418100649839684591, 0.421832709231353298, 0.425583931339900579, 0.429354541031341519, 0.433144769114574058, 0.436954852549929273, 0.440785034667769915, 0.444635565397727750, 0.448506701509214067, 0.452398706863882505, 0.456311852680773566, 0.460246417814923481, 0.464202689050278838, 0.468180961407822172, 0.472181538469883255, 0.476204732721683788, 0.480250865911249714, 0.484320269428911598, 0.488413284707712059, 0.492530263646148658, 0.496671569054796314, 0.500837575128482149, 0.505028667945828791, 0.509245245998136142, 0.513487720749743026, 0.517756517232200619, 0.522052074674794864, 0.526374847174186700, 0.530725304406193921, 0.535103932383019565, 0.539511234259544614, 0.543947731192649941, 0.548413963257921133, 0.552910490428519918, 0.557437893621486324, 0.561996775817277916, 0.566587763258951771, 0.571211506738074970, 0.575868682975210544, 0.580559996103683473, 0.585286179266300333, 0.590047996335791969, 0.594846243770991268, 0.599681752622167719, 0.604555390700549533, 0.609468064928895381, 0.614420723892076803, 0.619414360609039205, 0.624450015550274240, 0.629528779928128279, 0.634651799290960050, 0.639820277456438991, 0.645035480824251883, 0.650298743114294586, 0.655611470583224665, 0.660975147780241357, 0.666391343912380640, 0.671861719900766374, 0.677388036222513090, 0.682972161648791376, 0.688616083008527058, 0.694321916130032579, 0.700091918140490099, 0.705928501336797409, 0.711834248882358467, 0.717811932634901395, 0.723864533472881599, 0.729995264565802437, 0.736207598131266683, 0.742505296344636245, 0.748892447223726720, 0.755373506511754500, 0.761953346841546475, 0.768637315803334831, 0.775431304986138326, 0.782341832659861902, 0.789376143571198563, 0.796542330428254619, 0.803849483176389490, 0.811307874318219935, 0.818929191609414797, 0.826726833952094231, 0.834716292992930375, 0.842915653118441077, 0.851346258465123684, 0.860033621203008636, 0.869008688043793165, 0.878309655816146839, 0.887984660763399880, 0.898095921906304051, 0.908726440060562912, 0.919991505048360247, 0.932060075968990209, 0.945198953453078028, 0.959879091812415930, 0.977101701282731328, 1.000000000000000000]; pub const ZIG_EXP_R: f64 = 7.697117470131050077; pub static ZIG_EXP_X: [f64; 257] = [8.697117470131052741, 7.697117470131050077, 6.941033629377212577, 6.478378493832569696, 6.144164665772472667, 5.882144315795399869, 5.666410167454033697, 5.482890627526062488, 5.323090505754398016, 5.181487281301500047, 5.054288489981304089, 4.938777085901250530, 4.832939741025112035, 4.735242996601741083, 4.644491885420085175, 4.559737061707351380, 4.480211746528421912, 4.405287693473573185, 4.334443680317273007, 4.267242480277365857, 4.203313713735184365, 4.142340865664051464, 4.084051310408297830, 4.028208544647936762, 3.974606066673788796, 3.923062500135489739, 3.873417670399509127, 3.825529418522336744, 3.779270992411667862, 3.734528894039797375, 3.691201090237418825, 3.649195515760853770, 3.608428813128909507, 3.568825265648337020, 3.530315889129343354, 3.492837654774059608, 3.456332821132760191, 3.420748357251119920, 3.386035442460300970, 3.352149030900109405, 3.319047470970748037, 3.286692171599068679, 3.255047308570449882, 3.224079565286264160, 3.193757903212240290, 3.164053358025972873, 3.134938858084440394, 3.106389062339824481, 3.078380215254090224, 3.050890016615455114, 3.023897504455676621, 2.997382949516130601, 2.971327759921089662, 2.945714394895045718, 2.920526286512740821, 2.895747768600141825, 2.871364012015536371, 2.847360965635188812, 2.823725302450035279, 2.800444370250737780, 2.777506146439756574, 2.754899196562344610, 2.732612636194700073, 2.710636095867928752, 2.688959688741803689, 2.667573980773266573, 2.646469963151809157, 2.625639026797788489, 2.605072938740835564, 2.584763820214140750, 2.564704126316905253, 2.544886627111869970, 2.525304390037828028, 2.505950763528594027, 2.486819361740209455, 2.467904050297364815, 2.449198932978249754, 2.430698339264419694, 2.412396812688870629, 2.394289099921457886, 2.376370140536140596, 2.358635057409337321, 2.341079147703034380, 2.323697874390196372, 2.306486858283579799, 2.289441870532269441, 2.272558825553154804, 2.255833774367219213, 2.239262898312909034, 2.222842503111036816, 2.206569013257663858, 2.190438966723220027, 2.174449009937774679, 2.158595893043885994, 2.142876465399842001, 2.127287671317368289, 2.111826546019042183, 2.096490211801715020, 2.081275874393225145, 2.066180819490575526, 2.051202409468584786, 2.036338080248769611, 2.021585338318926173, 2.006941757894518563, 1.992404978213576650, 1.977972700957360441, 1.963642687789548313, 1.949412758007184943, 1.935280786297051359, 1.921244700591528076, 1.907302480018387536, 1.893452152939308242, 1.879691795072211180, 1.866019527692827973, 1.852433515911175554, 1.838931967018879954, 1.825513128903519799, 1.812175288526390649, 1.798916770460290859, 1.785735935484126014, 1.772631179231305643, 1.759600930889074766, 1.746643651946074405, 1.733757834985571566, 1.720942002521935299, 1.708194705878057773, 1.695514524101537912, 1.682900062917553896, 1.670349953716452118, 1.657862852574172763, 1.645437439303723659, 1.633072416535991334, 1.620766508828257901, 1.608518461798858379, 1.596327041286483395, 1.584191032532688892, 1.572109239386229707, 1.560080483527888084, 1.548103603714513499, 1.536177455041032092, 1.524300908219226258, 1.512472848872117082, 1.500692176842816750, 1.488957805516746058, 1.477268661156133867, 1.465623682245745352, 1.454021818848793446, 1.442462031972012504, 1.430943292938879674, 1.419464582769983219, 1.408024891569535697, 1.396623217917042137, 1.385258568263121992, 1.373929956328490576, 1.362636402505086775, 1.351376933258335189, 1.340150580529504643, 1.328956381137116560, 1.317793376176324749, 1.306660610415174117, 1.295557131686601027, 1.284481990275012642, 1.273434238296241139, 1.262412929069615330, 1.251417116480852521, 1.240445854334406572, 1.229498195693849105, 1.218573192208790124, 1.207669893426761121, 1.196787346088403092, 1.185924593404202199, 1.175080674310911677, 1.164254622705678921, 1.153445466655774743, 1.142652227581672841, 1.131873919411078511, 1.121109547701330200, 1.110358108727411031, 1.099618588532597308, 1.088889961938546813, 1.078171191511372307, 1.067461226479967662, 1.056759001602551429, 1.046063435977044209, 1.035373431790528542, 1.024687873002617211, 1.014005623957096480, 1.003325527915696735, 0.992646405507275897, 0.981967053085062602, 0.971286240983903260, 0.960602711668666509, 0.949915177764075969, 0.939222319955262286, 0.928522784747210395, 0.917815182070044311, 0.907098082715690257, 0.896370015589889935, 0.885629464761751528, 0.874874866291025066, 0.864104604811004484, 0.853317009842373353, 0.842510351810368485, 0.831682837734273206, 0.820832606554411814, 0.809957724057418282, 0.799056177355487174, 0.788125868869492430, 0.777164609759129710, 0.766170112735434672, 0.755139984181982249, 0.744071715500508102, 0.732962673584365398, 0.721810090308756203, 0.710611050909655040, 0.699362481103231959, 0.688061132773747808, 0.676703568029522584, 0.665286141392677943, 0.653804979847664947, 0.642255960424536365, 0.630634684933490286, 0.618936451394876075, 0.607156221620300030, 0.595288584291502887, 0.583327712748769489, 0.571267316532588332, 0.559100585511540626, 0.546820125163310577, 0.534417881237165604, 0.521885051592135052, 0.509211982443654398, 0.496388045518671162, 0.483401491653461857, 0.470239275082169006, 0.456886840931420235, 0.443327866073552401, 0.429543940225410703, 0.415514169600356364, 0.401214678896277765, 0.386617977941119573, 0.371692145329917234, 0.356399760258393816, 0.340696481064849122, 0.324529117016909452, 0.307832954674932158, 0.290527955491230394, 0.272513185478464703, 0.253658363385912022, 0.233790483059674731, 0.212671510630966620, 0.189958689622431842, 0.165127622564187282, 0.137304980940012589, 0.104838507565818778, 0.063852163815001570, 0.000000000000000000]; pub static ZIG_EXP_F: [f64; 257] = [0.000167066692307963, 0.000454134353841497, 0.000967269282327174, 0.001536299780301573, 0.002145967743718907, 0.002788798793574076, 0.003460264777836904, 0.004157295120833797, 0.004877655983542396, 0.005619642207205489, 0.006381905937319183, 0.007163353183634991, 0.007963077438017043, 0.008780314985808977, 0.009614413642502212, 0.010464810181029981, 0.011331013597834600, 0.012212592426255378, 0.013109164931254991, 0.014020391403181943, 0.014945968011691148, 0.015885621839973156, 0.016839106826039941, 0.017806200410911355, 0.018786700744696024, 0.019780424338009740, 0.020787204072578114, 0.021806887504283581, 0.022839335406385240, 0.023884420511558174, 0.024942026419731787, 0.026012046645134221, 0.027094383780955803, 0.028188948763978646, 0.029295660224637411, 0.030414443910466622, 0.031545232172893622, 0.032687963508959555, 0.033842582150874358, 0.035009037697397431, 0.036187284781931443, 0.037377282772959382, 0.038578995503074871, 0.039792391023374139, 0.041017441380414840, 0.042254122413316254, 0.043502413568888197, 0.044762297732943289, 0.046033761076175184, 0.047316792913181561, 0.048611385573379504, 0.049917534282706379, 0.051235237055126281, 0.052564494593071685, 0.053905310196046080, 0.055257689676697030, 0.056621641283742870, 0.057997175631200659, 0.059384305633420280, 0.060783046445479660, 0.062193415408541036, 0.063615431999807376, 0.065049117786753805, 0.066494496385339816, 0.067951593421936643, 0.069420436498728783, 0.070901055162371843, 0.072393480875708752, 0.073897746992364746, 0.075413888734058410, 0.076941943170480517, 0.078481949201606435, 0.080033947542319905, 0.081597980709237419, 0.083174093009632397, 0.084762330532368146, 0.086362741140756927, 0.087975374467270231, 0.089600281910032886, 0.091237516631040197, 0.092887133556043569, 0.094549189376055873, 0.096223742550432825, 0.097910853311492213, 0.099610583670637132, 0.101322997425953631, 0.103048160171257702, 0.104786139306570145, 0.106537004050001632, 0.108300825451033755, 0.110077676405185357, 0.111867631670056283, 0.113670767882744286, 0.115487163578633506, 0.117316899211555525, 0.119160057175327641, 0.121016721826674792, 0.122886979509545108, 0.124770918580830933, 0.126668629437510671, 0.128580204545228199, 0.130505738468330773, 0.132445327901387494, 0.134399071702213602, 0.136367070926428829, 0.138349428863580176, 0.140346251074862399, 0.142357645432472146, 0.144383722160634720, 0.146424593878344889, 0.148480375643866735, 0.150551185001039839, 0.152637142027442801, 0.154738369384468027, 0.156854992369365148, 0.158987138969314129, 0.161134939917591952, 0.163298528751901734, 0.165478041874935922, 0.167673618617250081, 0.169885401302527550, 0.172113535315319977, 0.174358169171353411, 0.176619454590494829, 0.178897546572478278, 0.181192603475496261, 0.183504787097767436, 0.185834262762197083, 0.188181199404254262, 0.190545769663195363, 0.192928149976771296, 0.195328520679563189, 0.197747066105098818, 0.200183974691911210, 0.202639439093708962, 0.205113656293837654, 0.207606827724221982, 0.210119159388988230, 0.212650861992978224, 0.215202151075378628, 0.217773247148700472, 0.220364375843359439, 0.222975768058120111, 0.225607660116683956, 0.228260293930716618, 0.230933917169627356, 0.233628783437433291, 0.236345152457059560, 0.239083290262449094, 0.241843469398877131, 0.244625969131892024, 0.247431075665327543, 0.250259082368862240, 0.253110290015629402, 0.255985007030415324, 0.258883549749016173, 0.261806242689362922, 0.264753418835062149, 0.267725419932044739, 0.270722596799059967, 0.273745309652802915, 0.276793928448517301, 0.279868833236972869, 0.282970414538780746, 0.286099073737076826, 0.289255223489677693, 0.292439288161892630, 0.295651704281261252, 0.298892921015581847, 0.302163400675693528, 0.305463619244590256, 0.308794066934560185, 0.312155248774179606, 0.315547685227128949, 0.318971912844957239, 0.322428484956089223, 0.325917972393556354, 0.329440964264136438, 0.332998068761809096, 0.336589914028677717, 0.340217149066780189, 0.343880444704502575, 0.347580494621637148, 0.351318016437483449, 0.355093752866787626, 0.358908472948750001, 0.362762973354817997, 0.366658079781514379, 0.370594648435146223, 0.374573567615902381, 0.378595759409581067, 0.382662181496010056, 0.386773829084137932, 0.390931736984797384, 0.395136981833290435, 0.399390684475231350, 0.403694012530530555, 0.408048183152032673, 0.412454465997161457, 0.416914186433003209, 0.421428728997616908, 0.425999541143034677, 0.430628137288459167, 0.435316103215636907, 0.440065100842354173, 0.444876873414548846, 0.449753251162755330, 0.454696157474615836, 0.459707615642138023, 0.464789756250426511, 0.469944825283960310, 0.475175193037377708, 0.480483363930454543, 0.485871987341885248, 0.491343869594032867, 0.496901987241549881, 0.502549501841348056, 0.508289776410643213, 0.514126393814748894, 0.520063177368233931, 0.526104213983620062, 0.532253880263043655, 0.538516872002862246, 0.544898237672440056, 0.551403416540641733, 0.558038282262587892, 0.564809192912400615, 0.571723048664826150, 0.578787358602845359, 0.586010318477268366, 0.593400901691733762, 0.600968966365232560, 0.608725382079622346, 0.616682180915207878, 0.624852738703666200, 0.633251994214366398, 0.641896716427266423, 0.650805833414571433, 0.660000841079000145, 0.669506316731925177, 0.679350572264765806, 0.689566496117078431, 0.700192655082788606, 0.711274760805076456, 0.722867659593572465, 0.735038092431424039, 0.747868621985195658, 0.761463388849896838, 0.775956852040116218, 0.791527636972496285, 0.808421651523009044, 0.826993296643051101, 0.847785500623990496, 0.871704332381204705, 0.900469929925747703, 0.938143680862176477, 1.000000000000000000]; deps/rand-0.3.13/src/distributions/normal.rs0000664000175000017500000001317112554203654015737 0ustar // Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! The normal and derived distributions. use {Rng, Rand, Open01}; use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample}; /// A wrapper around an `f64` to generate N(0, 1) random numbers /// (a.k.a. a standard normal, or Gaussian). /// /// See `Normal` for the general normal distribution. /// /// Implemented via the ZIGNOR variant[1] of the Ziggurat method. /// /// [1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to /// Generate Normal Random /// Samples*](http://www.doornik.com/research/ziggurat.pdf). Nuffield /// College, Oxford /// /// # Example /// /// ```rust /// use rand::distributions::normal::StandardNormal; /// /// let StandardNormal(x) = rand::random(); /// println!("{}", x); /// ``` #[derive(Clone, Copy)] pub struct StandardNormal(pub f64); impl Rand for StandardNormal { fn rand(rng: &mut R) -> StandardNormal { #[inline] fn pdf(x: f64) -> f64 { (-x*x/2.0).exp() } #[inline] fn zero_case(rng: &mut R, u: f64) -> f64 { // compute a random number in the tail by hand // strange initial conditions, because the loop is not // do-while, so the condition should be true on the first // run, they get overwritten anyway (0 < 1, so these are // good). let mut x = 1.0f64; let mut y = 0.0f64; while -2.0 * y < x * x { let Open01(x_) = rng.gen::>(); let Open01(y_) = rng.gen::>(); x = x_.ln() / ziggurat_tables::ZIG_NORM_R; y = y_.ln(); } if u < 0.0 { x - ziggurat_tables::ZIG_NORM_R } else { ziggurat_tables::ZIG_NORM_R - x } } StandardNormal(ziggurat( rng, true, // this is symmetric &ziggurat_tables::ZIG_NORM_X, &ziggurat_tables::ZIG_NORM_F, pdf, zero_case)) } } /// The normal distribution `N(mean, std_dev**2)`. /// /// This uses the ZIGNOR variant of the Ziggurat method, see /// `StandardNormal` for more details. /// /// # Example /// /// ```rust /// use rand::distributions::{Normal, IndependentSample}; /// /// // mean 2, standard deviation 3 /// let normal = Normal::new(2.0, 3.0); /// let v = normal.ind_sample(&mut rand::thread_rng()); /// println!("{} is from a N(2, 9) distribution", v) /// ``` #[derive(Clone, Copy)] pub struct Normal { mean: f64, std_dev: f64, } impl Normal { /// Construct a new `Normal` distribution with the given mean and /// standard deviation. /// /// # Panics /// /// Panics if `std_dev < 0`. pub fn new(mean: f64, std_dev: f64) -> Normal { assert!(std_dev >= 0.0, "Normal::new called with `std_dev` < 0"); Normal { mean: mean, std_dev: std_dev } } } impl Sample for Normal { fn sample(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) } } impl IndependentSample for Normal { fn ind_sample(&self, rng: &mut R) -> f64 { let StandardNormal(n) = rng.gen::(); self.mean + self.std_dev * n } } /// The log-normal distribution `ln N(mean, std_dev**2)`. /// /// If `X` is log-normal distributed, then `ln(X)` is `N(mean, /// std_dev**2)` distributed. /// /// # Example /// /// ```rust /// use rand::distributions::{LogNormal, IndependentSample}; /// /// // mean 2, standard deviation 3 /// let log_normal = LogNormal::new(2.0, 3.0); /// let v = log_normal.ind_sample(&mut rand::thread_rng()); /// println!("{} is from an ln N(2, 9) distribution", v) /// ``` #[derive(Clone, Copy)] pub struct LogNormal { norm: Normal } impl LogNormal { /// Construct a new `LogNormal` distribution with the given mean /// and standard deviation. /// /// # Panics /// /// Panics if `std_dev < 0`. pub fn new(mean: f64, std_dev: f64) -> LogNormal { assert!(std_dev >= 0.0, "LogNormal::new called with `std_dev` < 0"); LogNormal { norm: Normal::new(mean, std_dev) } } } impl Sample for LogNormal { fn sample(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) } } impl IndependentSample for LogNormal { fn ind_sample(&self, rng: &mut R) -> f64 { self.norm.ind_sample(rng).exp() } } #[cfg(test)] mod tests { use distributions::{Sample, IndependentSample}; use super::{Normal, LogNormal}; #[test] fn test_normal() { let mut norm = Normal::new(10.0, 10.0); let mut rng = ::test::rng(); for _ in 0..1000 { norm.sample(&mut rng); norm.ind_sample(&mut rng); } } #[test] #[should_panic] #[cfg_attr(target_env = "msvc", ignore)] fn test_normal_invalid_sd() { Normal::new(10.0, -1.0); } #[test] fn test_log_normal() { let mut lnorm = LogNormal::new(10.0, 10.0); let mut rng = ::test::rng(); for _ in 0..1000 { lnorm.sample(&mut rng); lnorm.ind_sample(&mut rng); } } #[test] #[should_panic] #[cfg_attr(target_env = "msvc", ignore)] fn test_log_normal_invalid_sd() { LogNormal::new(10.0, -1.0); } } deps/rand-0.3.13/src/distributions/mod.rs0000664000175000017500000003431212537200561015221 0ustar // Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Sampling from random distributions. //! //! This is a generalization of `Rand` to allow parameters to control the //! exact properties of the generated values, e.g. the mean and standard //! deviation of a normal distribution. The `Sample` trait is the most //! general, and allows for generating values that change some state //! internally. The `IndependentSample` trait is for generating values //! that do not need to record state. use std::marker; use {Rng, Rand}; pub use self::range::Range; pub use self::gamma::{Gamma, ChiSquared, FisherF, StudentT}; pub use self::normal::{Normal, LogNormal}; pub use self::exponential::Exp; pub mod range; pub mod gamma; pub mod normal; pub mod exponential; /// Types that can be used to create a random instance of `Support`. pub trait Sample { /// Generate a random value of `Support`, using `rng` as the /// source of randomness. fn sample(&mut self, rng: &mut R) -> Support; } /// `Sample`s that do not require keeping track of state. /// /// Since no state is recorded, each sample is (statistically) /// independent of all others, assuming the `Rng` used has this /// property. // FIXME maybe having this separate is overkill (the only reason is to // take &self rather than &mut self)? or maybe this should be the // trait called `Sample` and the other should be `DependentSample`. pub trait IndependentSample: Sample { /// Generate a random value. fn ind_sample(&self, &mut R) -> Support; } /// A wrapper for generating types that implement `Rand` via the /// `Sample` & `IndependentSample` traits. pub struct RandSample { _marker: marker::PhantomData Sup>, } impl Copy for RandSample {} impl Clone for RandSample { fn clone(&self) -> Self { *self } } impl Sample for RandSample { fn sample(&mut self, rng: &mut R) -> Sup { self.ind_sample(rng) } } impl IndependentSample for RandSample { fn ind_sample(&self, rng: &mut R) -> Sup { rng.gen() } } impl RandSample { pub fn new() -> RandSample { RandSample { _marker: marker::PhantomData } } } /// A value with a particular weight for use with `WeightedChoice`. #[derive(Copy)] #[derive(Clone)] pub struct Weighted { /// The numerical weight of this item pub weight: u32, /// The actual item which is being weighted pub item: T, } /// A distribution that selects from a finite collection of weighted items. /// /// Each item has an associated weight that influences how likely it /// is to be chosen: higher weight is more likely. /// /// The `Clone` restriction is a limitation of the `Sample` and /// `IndependentSample` traits. Note that `&T` is (cheaply) `Clone` for /// all `T`, as is `u32`, so one can store references or indices into /// another vector. /// /// # Example /// /// ```rust /// use rand::distributions::{Weighted, WeightedChoice, IndependentSample}; /// /// let mut items = vec!(Weighted { weight: 2, item: 'a' }, /// Weighted { weight: 4, item: 'b' }, /// Weighted { weight: 1, item: 'c' }); /// let wc = WeightedChoice::new(&mut items); /// let mut rng = rand::thread_rng(); /// for _ in 0..16 { /// // on average prints 'a' 4 times, 'b' 8 and 'c' twice. /// println!("{}", wc.ind_sample(&mut rng)); /// } /// ``` pub struct WeightedChoice<'a, T:'a> { items: &'a mut [Weighted], weight_range: Range } impl<'a, T: Clone> WeightedChoice<'a, T> { /// Create a new `WeightedChoice`. /// /// Panics if: /// - `v` is empty /// - the total weight is 0 /// - the total weight is larger than a `u32` can contain. pub fn new(items: &'a mut [Weighted]) -> WeightedChoice<'a, T> { // strictly speaking, this is subsumed by the total weight == 0 case assert!(!items.is_empty(), "WeightedChoice::new called with no items"); let mut running_total: u32 = 0; // we convert the list from individual weights to cumulative // weights so we can binary search. This *could* drop elements // with weight == 0 as an optimisation. for item in items.iter_mut() { running_total = match running_total.checked_add(item.weight) { Some(n) => n, None => panic!("WeightedChoice::new called with a total weight \ larger than a u32 can contain") }; item.weight = running_total; } assert!(running_total != 0, "WeightedChoice::new called with a total weight of 0"); WeightedChoice { items: items, // we're likely to be generating numbers in this range // relatively often, so might as well cache it weight_range: Range::new(0, running_total) } } } impl<'a, T: Clone> Sample for WeightedChoice<'a, T> { fn sample(&mut self, rng: &mut R) -> T { self.ind_sample(rng) } } impl<'a, T: Clone> IndependentSample for WeightedChoice<'a, T> { fn ind_sample(&self, rng: &mut R) -> T { // we want to find the first element that has cumulative // weight > sample_weight, which we do by binary since the // cumulative weights of self.items are sorted. // choose a weight in [0, total_weight) let sample_weight = self.weight_range.ind_sample(rng); // short circuit when it's the first item if sample_weight < self.items[0].weight { return self.items[0].item.clone(); } let mut idx = 0; let mut modifier = self.items.len(); // now we know that every possibility has an element to the // left, so we can just search for the last element that has // cumulative weight <= sample_weight, then the next one will // be "it". (Note that this greatest element will never be the // last element of the vector, since sample_weight is chosen // in [0, total_weight) and the cumulative weight of the last // one is exactly the total weight.) while modifier > 1 { let i = idx + modifier / 2; if self.items[i].weight <= sample_weight { // we're small, so look to the right, but allow this // exact element still. idx = i; // we need the `/ 2` to round up otherwise we'll drop // the trailing elements when `modifier` is odd. modifier += 1; } else { // otherwise we're too big, so go left. (i.e. do // nothing) } modifier /= 2; } return self.items[idx + 1].item.clone(); } } mod ziggurat_tables; /// Sample a random number using the Ziggurat method (specifically the /// ZIGNOR variant from Doornik 2005). Most of the arguments are /// directly from the paper: /// /// * `rng`: source of randomness /// * `symmetric`: whether this is a symmetric distribution, or one-sided with P(x < 0) = 0. /// * `X`: the $x_i$ abscissae. /// * `F`: precomputed values of the PDF at the $x_i$, (i.e. $f(x_i)$) /// * `F_DIFF`: precomputed values of $f(x_i) - f(x_{i+1})$ /// * `pdf`: the probability density function /// * `zero_case`: manual sampling from the tail when we chose the /// bottom box (i.e. i == 0) // the perf improvement (25-50%) is definitely worth the extra code // size from force-inlining. #[inline(always)] fn ziggurat( rng: &mut R, symmetric: bool, x_tab: ziggurat_tables::ZigTable, f_tab: ziggurat_tables::ZigTable, mut pdf: P, mut zero_case: Z) -> f64 where P: FnMut(f64) -> f64, Z: FnMut(&mut R, f64) -> f64 { const SCALE: f64 = (1u64 << 53) as f64; loop { // reimplement the f64 generation as an optimisation suggested // by the Doornik paper: we have a lot of precision-space // (i.e. there are 11 bits of the 64 of a u64 to use after // creating a f64), so we might as well reuse some to save // generating a whole extra random number. (Seems to be 15% // faster.) // // This unfortunately misses out on the benefits of direct // floating point generation if an RNG like dSMFT is // used. (That is, such RNGs create floats directly, highly // efficiently and overload next_f32/f64, so by not calling it // this may be slower than it would be otherwise.) // FIXME: investigate/optimise for the above. let bits: u64 = rng.gen(); let i = (bits & 0xff) as usize; let f = (bits >> 11) as f64 / SCALE; // u is either U(-1, 1) or U(0, 1) depending on if this is a // symmetric distribution or not. let u = if symmetric {2.0 * f - 1.0} else {f}; let x = u * x_tab[i]; let test_x = if symmetric { x.abs() } else {x}; // algebraically equivalent to |u| < x_tab[i+1]/x_tab[i] (or u < x_tab[i+1]/x_tab[i]) if test_x < x_tab[i + 1] { return x; } if i == 0 { return zero_case(rng, u); } // algebraically equivalent to f1 + DRanU()*(f0 - f1) < 1 if f_tab[i + 1] + (f_tab[i] - f_tab[i + 1]) * rng.gen::() < pdf(x) { return x; } } } #[cfg(test)] mod tests { use {Rng, Rand}; use super::{RandSample, WeightedChoice, Weighted, Sample, IndependentSample}; #[derive(PartialEq, Debug)] struct ConstRand(usize); impl Rand for ConstRand { fn rand(_: &mut R) -> ConstRand { ConstRand(0) } } // 0, 1, 2, 3, ... struct CountingRng { i: u32 } impl Rng for CountingRng { fn next_u32(&mut self) -> u32 { self.i += 1; self.i - 1 } fn next_u64(&mut self) -> u64 { self.next_u32() as u64 } } #[test] fn test_rand_sample() { let mut rand_sample = RandSample::::new(); assert_eq!(rand_sample.sample(&mut ::test::rng()), ConstRand(0)); assert_eq!(rand_sample.ind_sample(&mut ::test::rng()), ConstRand(0)); } #[test] fn test_weighted_choice() { // this makes assumptions about the internal implementation of // WeightedChoice, specifically: it doesn't reorder the items, // it doesn't do weird things to the RNG (so 0 maps to 0, 1 to // 1, internally; modulo a modulo operation). macro_rules! t { ($items:expr, $expected:expr) => {{ let mut items = $items; let wc = WeightedChoice::new(&mut items); let expected = $expected; let mut rng = CountingRng { i: 0 }; for &val in expected.iter() { assert_eq!(wc.ind_sample(&mut rng), val) } }} } t!(vec!(Weighted { weight: 1, item: 10}), [10]); // skip some t!(vec!(Weighted { weight: 0, item: 20}, Weighted { weight: 2, item: 21}, Weighted { weight: 0, item: 22}, Weighted { weight: 1, item: 23}), [21,21, 23]); // different weights t!(vec!(Weighted { weight: 4, item: 30}, Weighted { weight: 3, item: 31}), [30,30,30,30, 31,31,31]); // check that we're binary searching // correctly with some vectors of odd // length. t!(vec!(Weighted { weight: 1, item: 40}, Weighted { weight: 1, item: 41}, Weighted { weight: 1, item: 42}, Weighted { weight: 1, item: 43}, Weighted { weight: 1, item: 44}), [40, 41, 42, 43, 44]); t!(vec!(Weighted { weight: 1, item: 50}, Weighted { weight: 1, item: 51}, Weighted { weight: 1, item: 52}, Weighted { weight: 1, item: 53}, Weighted { weight: 1, item: 54}, Weighted { weight: 1, item: 55}, Weighted { weight: 1, item: 56}), [50, 51, 52, 53, 54, 55, 56]); } #[test] fn test_weighted_clone_initialization() { let initial : Weighted = Weighted {weight: 1, item: 1}; let clone = initial.clone(); assert_eq!(initial.weight, clone.weight); assert_eq!(initial.item, clone.item); } #[test] #[should_panic] #[cfg_attr(target_env = "msvc", ignore)] fn test_weighted_clone_change_weight() { let initial : Weighted = Weighted {weight: 1, item: 1}; let mut clone = initial.clone(); clone.weight = 5; assert_eq!(initial.weight, clone.weight); } #[test] #[should_panic] #[cfg_attr(target_env = "msvc", ignore)] fn test_weighted_clone_change_item() { let initial : Weighted = Weighted {weight: 1, item: 1}; let mut clone = initial.clone(); clone.item = 5; assert_eq!(initial.item, clone.item); } #[test] #[should_panic] #[cfg_attr(target_env = "msvc", ignore)] fn test_weighted_choice_no_items() { WeightedChoice::::new(&mut []); } #[test] #[should_panic] #[cfg_attr(target_env = "msvc", ignore)] fn test_weighted_choice_zero_weight() { WeightedChoice::new(&mut [Weighted { weight: 0, item: 0}, Weighted { weight: 0, item: 1}]); } #[test] #[should_panic] #[cfg_attr(target_env = "msvc", ignore)] fn test_weighted_choice_weight_overflows() { let x = ::std::u32::MAX / 2; // x + x + 2 is the overflow WeightedChoice::new(&mut [Weighted { weight: x, item: 0 }, Weighted { weight: 1, item: 1 }, Weighted { weight: x, item: 2 }, Weighted { weight: 1, item: 3 }]); } } deps/rand-0.3.13/src/distributions/gamma.rs0000664000175000017500000002576012537200552015533 0ustar // Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // // ignore-lexer-test FIXME #15679 //! The Gamma and derived distributions. use self::GammaRepr::*; use self::ChiSquaredRepr::*; use {Rng, Open01}; use super::normal::StandardNormal; use super::{IndependentSample, Sample, Exp}; /// The Gamma distribution `Gamma(shape, scale)` distribution. /// /// The density function of this distribution is /// /// ```text /// f(x) = x^(k - 1) * exp(-x / θ) / (Γ(k) * θ^k) /// ``` /// /// where `Γ` is the Gamma function, `k` is the shape and `θ` is the /// scale and both `k` and `θ` are strictly positive. /// /// The algorithm used is that described by Marsaglia & Tsang 2000[1], /// falling back to directly sampling from an Exponential for `shape /// == 1`, and using the boosting technique described in [1] for /// `shape < 1`. /// /// # Example /// /// ```rust /// use rand::distributions::{IndependentSample, Gamma}; /// /// let gamma = Gamma::new(2.0, 5.0); /// let v = gamma.ind_sample(&mut rand::thread_rng()); /// println!("{} is from a Gamma(2, 5) distribution", v); /// ``` /// /// [1]: George Marsaglia and Wai Wan Tsang. 2000. "A Simple Method /// for Generating Gamma Variables" *ACM Trans. Math. Softw.* 26, 3 /// (September 2000), /// 363-372. DOI:[10.1145/358407.358414](http://doi.acm.org/10.1145/358407.358414) #[derive(Clone, Copy)] pub struct Gamma { repr: GammaRepr, } #[derive(Clone, Copy)] enum GammaRepr { Large(GammaLargeShape), One(Exp), Small(GammaSmallShape) } // These two helpers could be made public, but saving the // match-on-Gamma-enum branch from using them directly (e.g. if one // knows that the shape is always > 1) doesn't appear to be much // faster. /// Gamma distribution where the shape parameter is less than 1. /// /// Note, samples from this require a compulsory floating-point `pow` /// call, which makes it significantly slower than sampling from a /// gamma distribution where the shape parameter is greater than or /// equal to 1. /// /// See `Gamma` for sampling from a Gamma distribution with general /// shape parameters. #[derive(Clone, Copy)] struct GammaSmallShape { inv_shape: f64, large_shape: GammaLargeShape } /// Gamma distribution where the shape parameter is larger than 1. /// /// See `Gamma` for sampling from a Gamma distribution with general /// shape parameters. #[derive(Clone, Copy)] struct GammaLargeShape { scale: f64, c: f64, d: f64 } impl Gamma { /// Construct an object representing the `Gamma(shape, scale)` /// distribution. /// /// Panics if `shape <= 0` or `scale <= 0`. pub fn new(shape: f64, scale: f64) -> Gamma { assert!(shape > 0.0, "Gamma::new called with shape <= 0"); assert!(scale > 0.0, "Gamma::new called with scale <= 0"); let repr = match shape { 1.0 => One(Exp::new(1.0 / scale)), 0.0 ... 1.0 => Small(GammaSmallShape::new_raw(shape, scale)), _ => Large(GammaLargeShape::new_raw(shape, scale)) }; Gamma { repr: repr } } } impl GammaSmallShape { fn new_raw(shape: f64, scale: f64) -> GammaSmallShape { GammaSmallShape { inv_shape: 1. / shape, large_shape: GammaLargeShape::new_raw(shape + 1.0, scale) } } } impl GammaLargeShape { fn new_raw(shape: f64, scale: f64) -> GammaLargeShape { let d = shape - 1. / 3.; GammaLargeShape { scale: scale, c: 1. / (9. * d).sqrt(), d: d } } } impl Sample for Gamma { fn sample(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) } } impl Sample for GammaSmallShape { fn sample(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) } } impl Sample for GammaLargeShape { fn sample(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) } } impl IndependentSample for Gamma { fn ind_sample(&self, rng: &mut R) -> f64 { match self.repr { Small(ref g) => g.ind_sample(rng), One(ref g) => g.ind_sample(rng), Large(ref g) => g.ind_sample(rng), } } } impl IndependentSample for GammaSmallShape { fn ind_sample(&self, rng: &mut R) -> f64 { let Open01(u) = rng.gen::>(); self.large_shape.ind_sample(rng) * u.powf(self.inv_shape) } } impl IndependentSample for GammaLargeShape { fn ind_sample(&self, rng: &mut R) -> f64 { loop { let StandardNormal(x) = rng.gen::(); let v_cbrt = 1.0 + self.c * x; if v_cbrt <= 0.0 { // a^3 <= 0 iff a <= 0 continue } let v = v_cbrt * v_cbrt * v_cbrt; let Open01(u) = rng.gen::>(); let x_sqr = x * x; if u < 1.0 - 0.0331 * x_sqr * x_sqr || u.ln() < 0.5 * x_sqr + self.d * (1.0 - v + v.ln()) { return self.d * v * self.scale } } } } /// The chi-squared distribution `χ²(k)`, where `k` is the degrees of /// freedom. /// /// For `k > 0` integral, this distribution is the sum of the squares /// of `k` independent standard normal random variables. For other /// `k`, this uses the equivalent characterisation `χ²(k) = Gamma(k/2, /// 2)`. /// /// # Example /// /// ```rust /// use rand::distributions::{ChiSquared, IndependentSample}; /// /// let chi = ChiSquared::new(11.0); /// let v = chi.ind_sample(&mut rand::thread_rng()); /// println!("{} is from a χ²(11) distribution", v) /// ``` #[derive(Clone, Copy)] pub struct ChiSquared { repr: ChiSquaredRepr, } #[derive(Clone, Copy)] enum ChiSquaredRepr { // k == 1, Gamma(alpha, ..) is particularly slow for alpha < 1, // e.g. when alpha = 1/2 as it would be for this case, so special- // casing and using the definition of N(0,1)^2 is faster. DoFExactlyOne, DoFAnythingElse(Gamma), } impl ChiSquared { /// Create a new chi-squared distribution with degrees-of-freedom /// `k`. Panics if `k < 0`. pub fn new(k: f64) -> ChiSquared { let repr = if k == 1.0 { DoFExactlyOne } else { assert!(k > 0.0, "ChiSquared::new called with `k` < 0"); DoFAnythingElse(Gamma::new(0.5 * k, 2.0)) }; ChiSquared { repr: repr } } } impl Sample for ChiSquared { fn sample(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) } } impl IndependentSample for ChiSquared { fn ind_sample(&self, rng: &mut R) -> f64 { match self.repr { DoFExactlyOne => { // k == 1 => N(0,1)^2 let StandardNormal(norm) = rng.gen::(); norm * norm } DoFAnythingElse(ref g) => g.ind_sample(rng) } } } /// The Fisher F distribution `F(m, n)`. /// /// This distribution is equivalent to the ratio of two normalised /// chi-squared distributions, that is, `F(m,n) = (χ²(m)/m) / /// (χ²(n)/n)`. /// /// # Example /// /// ```rust /// use rand::distributions::{FisherF, IndependentSample}; /// /// let f = FisherF::new(2.0, 32.0); /// let v = f.ind_sample(&mut rand::thread_rng()); /// println!("{} is from an F(2, 32) distribution", v) /// ``` #[derive(Clone, Copy)] pub struct FisherF { numer: ChiSquared, denom: ChiSquared, // denom_dof / numer_dof so that this can just be a straight // multiplication, rather than a division. dof_ratio: f64, } impl FisherF { /// Create a new `FisherF` distribution, with the given /// parameter. Panics if either `m` or `n` are not positive. pub fn new(m: f64, n: f64) -> FisherF { assert!(m > 0.0, "FisherF::new called with `m < 0`"); assert!(n > 0.0, "FisherF::new called with `n < 0`"); FisherF { numer: ChiSquared::new(m), denom: ChiSquared::new(n), dof_ratio: n / m } } } impl Sample for FisherF { fn sample(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) } } impl IndependentSample for FisherF { fn ind_sample(&self, rng: &mut R) -> f64 { self.numer.ind_sample(rng) / self.denom.ind_sample(rng) * self.dof_ratio } } /// The Student t distribution, `t(nu)`, where `nu` is the degrees of /// freedom. /// /// # Example /// /// ```rust /// use rand::distributions::{StudentT, IndependentSample}; /// /// let t = StudentT::new(11.0); /// let v = t.ind_sample(&mut rand::thread_rng()); /// println!("{} is from a t(11) distribution", v) /// ``` #[derive(Clone, Copy)] pub struct StudentT { chi: ChiSquared, dof: f64 } impl StudentT { /// Create a new Student t distribution with `n` degrees of /// freedom. Panics if `n <= 0`. pub fn new(n: f64) -> StudentT { assert!(n > 0.0, "StudentT::new called with `n <= 0`"); StudentT { chi: ChiSquared::new(n), dof: n } } } impl Sample for StudentT { fn sample(&mut self, rng: &mut R) -> f64 { self.ind_sample(rng) } } impl IndependentSample for StudentT { fn ind_sample(&self, rng: &mut R) -> f64 { let StandardNormal(norm) = rng.gen::(); norm * (self.dof / self.chi.ind_sample(rng)).sqrt() } } #[cfg(test)] mod test { use distributions::{Sample, IndependentSample}; use super::{ChiSquared, StudentT, FisherF}; #[test] fn test_chi_squared_one() { let mut chi = ChiSquared::new(1.0); let mut rng = ::test::rng(); for _ in 0..1000 { chi.sample(&mut rng); chi.ind_sample(&mut rng); } } #[test] fn test_chi_squared_small() { let mut chi = ChiSquared::new(0.5); let mut rng = ::test::rng(); for _ in 0..1000 { chi.sample(&mut rng); chi.ind_sample(&mut rng); } } #[test] fn test_chi_squared_large() { let mut chi = ChiSquared::new(30.0); let mut rng = ::test::rng(); for _ in 0..1000 { chi.sample(&mut rng); chi.ind_sample(&mut rng); } } #[test] #[should_panic] #[cfg_attr(target_env = "msvc", ignore)] fn test_chi_squared_invalid_dof() { ChiSquared::new(-1.0); } #[test] fn test_f() { let mut f = FisherF::new(2.0, 32.0); let mut rng = ::test::rng(); for _ in 0..1000 { f.sample(&mut rng); f.ind_sample(&mut rng); } } #[test] fn test_t() { let mut t = StudentT::new(11.0); let mut rng = ::test::rng(); for _ in 0..1000 { t.sample(&mut rng); t.ind_sample(&mut rng); } } } deps/rand-0.3.13/src/distributions/range.rs0000664000175000017500000001740712564265571015560 0ustar // Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Generating numbers between two others. // this is surprisingly complicated to be both generic & correct use std::num::Wrapping as w; use Rng; use distributions::{Sample, IndependentSample}; /// Sample values uniformly between two bounds. /// /// This gives a uniform distribution (assuming the RNG used to sample /// it is itself uniform & the `SampleRange` implementation for the /// given type is correct), even for edge cases like `low = 0u8`, /// `high = 170u8`, for which a naive modulo operation would return /// numbers less than 85 with double the probability to those greater /// than 85. /// /// Types should attempt to sample in `[low, high)`, i.e., not /// including `high`, but this may be very difficult. All the /// primitive integer types satisfy this property, and the float types /// normally satisfy it, but rounding may mean `high` can occur. /// /// # Example /// /// ```rust /// use rand::distributions::{IndependentSample, Range}; /// /// fn main() { /// let between = Range::new(10, 10000); /// let mut rng = rand::thread_rng(); /// let mut sum = 0; /// for _ in 0..1000 { /// sum += between.ind_sample(&mut rng); /// } /// println!("{}", sum); /// } /// ``` #[derive(Clone, Copy)] pub struct Range { low: X, range: X, accept_zone: X } impl Range { /// Create a new `Range` instance that samples uniformly from /// `[low, high)`. Panics if `low >= high`. pub fn new(low: X, high: X) -> Range { assert!(low < high, "Range::new called with `low >= high`"); SampleRange::construct_range(low, high) } } impl Sample for Range { #[inline] fn sample(&mut self, rng: &mut R) -> Sup { self.ind_sample(rng) } } impl IndependentSample for Range { fn ind_sample(&self, rng: &mut R) -> Sup { SampleRange::sample_range(self, rng) } } /// The helper trait for types that have a sensible way to sample /// uniformly between two values. This should not be used directly, /// and is only to facilitate `Range`. pub trait SampleRange : Sized { /// Construct the `Range` object that `sample_range` /// requires. This should not ever be called directly, only via /// `Range::new`, which will check that `low < high`, so this /// function doesn't have to repeat the check. fn construct_range(low: Self, high: Self) -> Range; /// Sample a value from the given `Range` with the given `Rng` as /// a source of randomness. fn sample_range(r: &Range, rng: &mut R) -> Self; } macro_rules! integer_impl { ($ty:ty, $unsigned:ident) => { impl SampleRange for $ty { // we play free and fast with unsigned vs signed here // (when $ty is signed), but that's fine, since the // contract of this macro is for $ty and $unsigned to be // "bit-equal", so casting between them is a no-op & a // bijection. fn construct_range(low: $ty, high: $ty) -> Range<$ty> { let range = (w(high as $unsigned) - w(low as $unsigned)).0; let unsigned_max: $unsigned = ::std::$unsigned::MAX; // this is the largest number that fits into $unsigned // that `range` divides evenly, so, if we've sampled // `n` uniformly from this region, then `n % range` is // uniform in [0, range) let zone = unsigned_max - unsigned_max % range; Range { low: low, range: range as $ty, accept_zone: zone as $ty } } #[inline] fn sample_range(r: &Range<$ty>, rng: &mut R) -> $ty { loop { // rejection sample let v = rng.gen::<$unsigned>(); // until we find something that fits into the // region which r.range evenly divides (this will // be uniformly distributed) if v < r.accept_zone as $unsigned { // and return it, with some adjustments return (w(r.low) + w((v % r.range as $unsigned) as $ty)).0; } } } } } } integer_impl! { i8, u8 } integer_impl! { i16, u16 } integer_impl! { i32, u32 } integer_impl! { i64, u64 } integer_impl! { isize, usize } integer_impl! { u8, u8 } integer_impl! { u16, u16 } integer_impl! { u32, u32 } integer_impl! { u64, u64 } integer_impl! { usize, usize } macro_rules! float_impl { ($ty:ty) => { impl SampleRange for $ty { fn construct_range(low: $ty, high: $ty) -> Range<$ty> { Range { low: low, range: high - low, accept_zone: 0.0 // unused } } fn sample_range(r: &Range<$ty>, rng: &mut R) -> $ty { r.low + r.range * rng.gen::<$ty>() } } } } float_impl! { f32 } float_impl! { f64 } #[cfg(test)] mod tests { use distributions::{Sample, IndependentSample}; use super::Range as Range; #[should_panic] #[cfg_attr(target_env = "msvc", ignore)] #[test] fn test_range_bad_limits_equal() { Range::new(10, 10); } #[should_panic] #[cfg_attr(target_env = "msvc", ignore)] #[test] fn test_range_bad_limits_flipped() { Range::new(10, 5); } #[test] fn test_integers() { let mut rng = ::test::rng(); macro_rules! t { ($($ty:ident),*) => {{ $( let v: &[($ty, $ty)] = &[(0, 10), (10, 127), (::std::$ty::MIN, ::std::$ty::MAX)]; for &(low, high) in v.iter() { let mut sampler: Range<$ty> = Range::new(low, high); for _ in 0..1000 { let v = sampler.sample(&mut rng); assert!(low <= v && v < high); let v = sampler.ind_sample(&mut rng); assert!(low <= v && v < high); } } )* }} } t!(i8, i16, i32, i64, isize, u8, u16, u32, u64, usize) } #[test] fn test_floats() { let mut rng = ::test::rng(); macro_rules! t { ($($ty:ty),*) => {{ $( let v: &[($ty, $ty)] = &[(0.0, 100.0), (-1e35, -1e25), (1e-35, 1e-25), (-1e35, 1e35)]; for &(low, high) in v.iter() { let mut sampler: Range<$ty> = Range::new(low, high); for _ in 0..1000 { let v = sampler.sample(&mut rng); assert!(low <= v && v < high); let v = sampler.ind_sample(&mut rng); assert!(low <= v && v < high); } } )* }} } t!(f32, f64) } } deps/rand-0.3.13/src/isaac.rs0000664000175000017500000005022012644245137012623 0ustar // Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! The ISAAC random number generator. #![allow(non_camel_case_types)] use std::slice; use std::iter::repeat; use std::num::Wrapping as w; use {Rng, SeedableRng, Rand, w32, w64}; const RAND_SIZE_LEN: usize = 8; const RAND_SIZE: u32 = 1 << RAND_SIZE_LEN; const RAND_SIZE_USIZE: usize = 1 << RAND_SIZE_LEN; /// A random number generator that uses the ISAAC algorithm[1]. /// /// The ISAAC algorithm is generally accepted as suitable for /// cryptographic purposes, but this implementation has not be /// verified as such. Prefer a generator like `OsRng` that defers to /// the operating system for cases that need high security. /// /// [1]: Bob Jenkins, [*ISAAC: A fast cryptographic random number /// generator*](http://www.burtleburtle.net/bob/rand/isaacafa.html) #[derive(Copy)] pub struct IsaacRng { cnt: u32, rsl: [w32; RAND_SIZE_USIZE], mem: [w32; RAND_SIZE_USIZE], a: w32, b: w32, c: w32, } static EMPTY: IsaacRng = IsaacRng { cnt: 0, rsl: [w(0); RAND_SIZE_USIZE], mem: [w(0); RAND_SIZE_USIZE], a: w(0), b: w(0), c: w(0), }; impl IsaacRng { /// Create an ISAAC random number generator using the default /// fixed seed. pub fn new_unseeded() -> IsaacRng { let mut rng = EMPTY; rng.init(false); rng } /// Initialises `self`. If `use_rsl` is true, then use the current value /// of `rsl` as a seed, otherwise construct one algorithmically (not /// randomly). fn init(&mut self, use_rsl: bool) { let mut a = w(0x9e3779b9); let mut b = a; let mut c = a; let mut d = a; let mut e = a; let mut f = a; let mut g = a; let mut h = a; macro_rules! mix { () => {{ a=a^(b<<11); d=d+a; b=b+c; b=b^(c>>2); e=e+b; c=c+d; c=c^(d<<8); f=f+c; d=d+e; d=d^(e>>16); g=g+d; e=e+f; e=e^(f<<10); h=h+e; f=f+g; f=f^(g>>4); a=a+f; g=g+h; g=g^(h<<8); b=b+g; h=h+a; h=h^(a>>9); c=c+h; a=a+b; }} } for _ in 0..4 { mix!(); } if use_rsl { macro_rules! memloop { ($arr:expr) => {{ for i in (0..RAND_SIZE_USIZE/8).map(|i| i * 8) { a=a+$arr[i ]; b=b+$arr[i+1]; c=c+$arr[i+2]; d=d+$arr[i+3]; e=e+$arr[i+4]; f=f+$arr[i+5]; g=g+$arr[i+6]; h=h+$arr[i+7]; mix!(); self.mem[i ]=a; self.mem[i+1]=b; self.mem[i+2]=c; self.mem[i+3]=d; self.mem[i+4]=e; self.mem[i+5]=f; self.mem[i+6]=g; self.mem[i+7]=h; } }} } memloop!(self.rsl); memloop!(self.mem); } else { for i in (0..RAND_SIZE_USIZE/8).map(|i| i * 8) { mix!(); self.mem[i ]=a; self.mem[i+1]=b; self.mem[i+2]=c; self.mem[i+3]=d; self.mem[i+4]=e; self.mem[i+5]=f; self.mem[i+6]=g; self.mem[i+7]=h; } } self.isaac(); } /// Refills the output buffer (`self.rsl`) #[inline] fn isaac(&mut self) { self.c = self.c + w(1); // abbreviations let mut a = self.a; let mut b = self.b + self.c; const MIDPOINT: usize = RAND_SIZE_USIZE / 2; macro_rules! ind { ($x:expr) => ( self.mem[($x >> 2usize).0 as usize & (RAND_SIZE_USIZE - 1)] ) } let r = [(0, MIDPOINT), (MIDPOINT, 0)]; for &(mr_offset, m2_offset) in r.iter() { macro_rules! rngstepp { ($j:expr, $shift:expr) => {{ let base = $j; let mix = a << $shift; let x = self.mem[base + mr_offset]; a = (a ^ mix) + self.mem[base + m2_offset]; let y = ind!(x) + a + b; self.mem[base + mr_offset] = y; b = ind!(y >> RAND_SIZE_LEN) + x; self.rsl[base + mr_offset] = b; }} } macro_rules! rngstepn { ($j:expr, $shift:expr) => {{ let base = $j; let mix = a >> $shift; let x = self.mem[base + mr_offset]; a = (a ^ mix) + self.mem[base + m2_offset]; let y = ind!(x) + a + b; self.mem[base + mr_offset] = y; b = ind!(y >> RAND_SIZE_LEN) + x; self.rsl[base + mr_offset] = b; }} } for i in (0..MIDPOINT/4).map(|i| i * 4) { rngstepp!(i + 0, 13); rngstepn!(i + 1, 6); rngstepp!(i + 2, 2); rngstepn!(i + 3, 16); } } self.a = a; self.b = b; self.cnt = RAND_SIZE; } } // Cannot be derived because [u32; 256] does not implement Clone impl Clone for IsaacRng { fn clone(&self) -> IsaacRng { *self } } impl Rng for IsaacRng { #[inline] fn next_u32(&mut self) -> u32 { if self.cnt == 0 { // make some more numbers self.isaac(); } self.cnt -= 1; // self.cnt is at most RAND_SIZE, but that is before the // subtraction above. We want to index without bounds // checking, but this could lead to incorrect code if someone // misrefactors, so we check, sometimes. // // (Changes here should be reflected in Isaac64Rng.next_u64.) debug_assert!(self.cnt < RAND_SIZE); // (the % is cheaply telling the optimiser that we're always // in bounds, without unsafe. NB. this is a power of two, so // it optimises to a bitwise mask). self.rsl[(self.cnt % RAND_SIZE) as usize].0 } } impl<'a> SeedableRng<&'a [u32]> for IsaacRng { fn reseed(&mut self, seed: &'a [u32]) { // make the seed into [seed[0], seed[1], ..., seed[seed.len() // - 1], 0, 0, ...], to fill rng.rsl. let seed_iter = seed.iter().map(|&x| x).chain(repeat(0u32)); for (rsl_elem, seed_elem) in self.rsl.iter_mut().zip(seed_iter) { *rsl_elem = w(seed_elem); } self.cnt = 0; self.a = w(0); self.b = w(0); self.c = w(0); self.init(true); } /// Create an ISAAC random number generator with a seed. This can /// be any length, although the maximum number of elements used is /// 256 and any more will be silently ignored. A generator /// constructed with a given seed will generate the same sequence /// of values as all other generators constructed with that seed. fn from_seed(seed: &'a [u32]) -> IsaacRng { let mut rng = EMPTY; rng.reseed(seed); rng } } impl Rand for IsaacRng { fn rand(other: &mut R) -> IsaacRng { let mut ret = EMPTY; unsafe { let ptr = ret.rsl.as_mut_ptr() as *mut u8; let slice = slice::from_raw_parts_mut(ptr, RAND_SIZE_USIZE * 4); other.fill_bytes(slice); } ret.cnt = 0; ret.a = w(0); ret.b = w(0); ret.c = w(0); ret.init(true); return ret; } } const RAND_SIZE_64_LEN: usize = 8; const RAND_SIZE_64: usize = 1 << RAND_SIZE_64_LEN; /// A random number generator that uses ISAAC-64[1], the 64-bit /// variant of the ISAAC algorithm. /// /// The ISAAC algorithm is generally accepted as suitable for /// cryptographic purposes, but this implementation has not be /// verified as such. Prefer a generator like `OsRng` that defers to /// the operating system for cases that need high security. /// /// [1]: Bob Jenkins, [*ISAAC: A fast cryptographic random number /// generator*](http://www.burtleburtle.net/bob/rand/isaacafa.html) #[derive(Copy)] pub struct Isaac64Rng { cnt: usize, rsl: [w64; RAND_SIZE_64], mem: [w64; RAND_SIZE_64], a: w64, b: w64, c: w64, } static EMPTY_64: Isaac64Rng = Isaac64Rng { cnt: 0, rsl: [w(0); RAND_SIZE_64], mem: [w(0); RAND_SIZE_64], a: w(0), b: w(0), c: w(0), }; impl Isaac64Rng { /// Create a 64-bit ISAAC random number generator using the /// default fixed seed. pub fn new_unseeded() -> Isaac64Rng { let mut rng = EMPTY_64; rng.init(false); rng } /// Initialises `self`. If `use_rsl` is true, then use the current value /// of `rsl` as a seed, otherwise construct one algorithmically (not /// randomly). fn init(&mut self, use_rsl: bool) { macro_rules! init { ($var:ident) => ( let mut $var = w(0x9e3779b97f4a7c13); ) } init!(a); init!(b); init!(c); init!(d); init!(e); init!(f); init!(g); init!(h); macro_rules! mix { () => {{ a=a-e; f=f^(h>>9); h=h+a; b=b-f; g=g^(a<<9); a=a+b; c=c-g; h=h^(b>>23); b=b+c; d=d-h; a=a^(c<<15); c=c+d; e=e-a; b=b^(d>>14); d=d+e; f=f-b; c=c^(e<<20); e=e+f; g=g-c; d=d^(f>>17); f=f+g; h=h-d; e=e^(g<<14); g=g+h; }} } for _ in 0..4 { mix!(); } if use_rsl { macro_rules! memloop { ($arr:expr) => {{ for i in (0..RAND_SIZE_64 / 8).map(|i| i * 8) { a=a+$arr[i ]; b=b+$arr[i+1]; c=c+$arr[i+2]; d=d+$arr[i+3]; e=e+$arr[i+4]; f=f+$arr[i+5]; g=g+$arr[i+6]; h=h+$arr[i+7]; mix!(); self.mem[i ]=a; self.mem[i+1]=b; self.mem[i+2]=c; self.mem[i+3]=d; self.mem[i+4]=e; self.mem[i+5]=f; self.mem[i+6]=g; self.mem[i+7]=h; } }} } memloop!(self.rsl); memloop!(self.mem); } else { for i in (0..RAND_SIZE_64 / 8).map(|i| i * 8) { mix!(); self.mem[i ]=a; self.mem[i+1]=b; self.mem[i+2]=c; self.mem[i+3]=d; self.mem[i+4]=e; self.mem[i+5]=f; self.mem[i+6]=g; self.mem[i+7]=h; } } self.isaac64(); } /// Refills the output buffer (`self.rsl`) fn isaac64(&mut self) { self.c = self.c + w(1); // abbreviations let mut a = self.a; let mut b = self.b + self.c; const MIDPOINT: usize = RAND_SIZE_64 / 2; const MP_VEC: [(usize, usize); 2] = [(0,MIDPOINT), (MIDPOINT, 0)]; macro_rules! ind { ($x:expr) => { *self.mem.get_unchecked((($x >> 3usize).0 as usize) & (RAND_SIZE_64 - 1)) } } for &(mr_offset, m2_offset) in MP_VEC.iter() { for base in (0..MIDPOINT / 4).map(|i| i * 4) { macro_rules! rngstepp { ($j:expr, $shift:expr) => {{ let base = base + $j; let mix = a ^ (a << $shift); let mix = if $j == 0 {!mix} else {mix}; unsafe { let x = *self.mem.get_unchecked(base + mr_offset); a = mix + *self.mem.get_unchecked(base + m2_offset); let y = ind!(x) + a + b; *self.mem.get_unchecked_mut(base + mr_offset) = y; b = ind!(y >> RAND_SIZE_64_LEN) + x; *self.rsl.get_unchecked_mut(base + mr_offset) = b; } }} } macro_rules! rngstepn { ($j:expr, $shift:expr) => {{ let base = base + $j; let mix = a ^ (a >> $shift); let mix = if $j == 0 {!mix} else {mix}; unsafe { let x = *self.mem.get_unchecked(base + mr_offset); a = mix + *self.mem.get_unchecked(base + m2_offset); let y = ind!(x) + a + b; *self.mem.get_unchecked_mut(base + mr_offset) = y; b = ind!(y >> RAND_SIZE_64_LEN) + x; *self.rsl.get_unchecked_mut(base + mr_offset) = b; } }} } rngstepp!(0, 21); rngstepn!(1, 5); rngstepp!(2, 12); rngstepn!(3, 33); } } self.a = a; self.b = b; self.cnt = RAND_SIZE_64; } } // Cannot be derived because [u32; 256] does not implement Clone impl Clone for Isaac64Rng { fn clone(&self) -> Isaac64Rng { *self } } impl Rng for Isaac64Rng { // FIXME #7771: having next_u32 like this should be unnecessary #[inline] fn next_u32(&mut self) -> u32 { self.next_u64() as u32 } #[inline] fn next_u64(&mut self) -> u64 { if self.cnt == 0 { // make some more numbers self.isaac64(); } self.cnt -= 1; // See corresponding location in IsaacRng.next_u32 for // explanation. debug_assert!(self.cnt < RAND_SIZE_64); self.rsl[(self.cnt % RAND_SIZE_64) as usize].0 } } impl<'a> SeedableRng<&'a [u64]> for Isaac64Rng { fn reseed(&mut self, seed: &'a [u64]) { // make the seed into [seed[0], seed[1], ..., seed[seed.len() // - 1], 0, 0, ...], to fill rng.rsl. let seed_iter = seed.iter().map(|&x| x).chain(repeat(0u64)); for (rsl_elem, seed_elem) in self.rsl.iter_mut().zip(seed_iter) { *rsl_elem = w(seed_elem); } self.cnt = 0; self.a = w(0); self.b = w(0); self.c = w(0); self.init(true); } /// Create an ISAAC random number generator with a seed. This can /// be any length, although the maximum number of elements used is /// 256 and any more will be silently ignored. A generator /// constructed with a given seed will generate the same sequence /// of values as all other generators constructed with that seed. fn from_seed(seed: &'a [u64]) -> Isaac64Rng { let mut rng = EMPTY_64; rng.reseed(seed); rng } } impl Rand for Isaac64Rng { fn rand(other: &mut R) -> Isaac64Rng { let mut ret = EMPTY_64; unsafe { let ptr = ret.rsl.as_mut_ptr() as *mut u8; let slice = slice::from_raw_parts_mut(ptr, RAND_SIZE_64 * 8); other.fill_bytes(slice); } ret.cnt = 0; ret.a = w(0); ret.b = w(0); ret.c = w(0); ret.init(true); return ret; } } #[cfg(test)] mod test { use {Rng, SeedableRng}; use super::{IsaacRng, Isaac64Rng}; #[test] fn test_rng_32_rand_seeded() { let s = ::test::rng().gen_iter::().take(256).collect::>(); let mut ra: IsaacRng = SeedableRng::from_seed(&s[..]); let mut rb: IsaacRng = SeedableRng::from_seed(&s[..]); assert!(::test::iter_eq(ra.gen_ascii_chars().take(100), rb.gen_ascii_chars().take(100))); } #[test] fn test_rng_64_rand_seeded() { let s = ::test::rng().gen_iter::().take(256).collect::>(); let mut ra: Isaac64Rng = SeedableRng::from_seed(&s[..]); let mut rb: Isaac64Rng = SeedableRng::from_seed(&s[..]); assert!(::test::iter_eq(ra.gen_ascii_chars().take(100), rb.gen_ascii_chars().take(100))); } #[test] fn test_rng_32_seeded() { let seed: &[_] = &[1, 23, 456, 7890, 12345]; let mut ra: IsaacRng = SeedableRng::from_seed(seed); let mut rb: IsaacRng = SeedableRng::from_seed(seed); assert!(::test::iter_eq(ra.gen_ascii_chars().take(100), rb.gen_ascii_chars().take(100))); } #[test] fn test_rng_64_seeded() { let seed: &[_] = &[1, 23, 456, 7890, 12345]; let mut ra: Isaac64Rng = SeedableRng::from_seed(seed); let mut rb: Isaac64Rng = SeedableRng::from_seed(seed); assert!(::test::iter_eq(ra.gen_ascii_chars().take(100), rb.gen_ascii_chars().take(100))); } #[test] fn test_rng_32_reseed() { let s = ::test::rng().gen_iter::().take(256).collect::>(); let mut r: IsaacRng = SeedableRng::from_seed(&s[..]); let string1: String = r.gen_ascii_chars().take(100).collect(); r.reseed(&s[..]); let string2: String = r.gen_ascii_chars().take(100).collect(); assert_eq!(string1, string2); } #[test] fn test_rng_64_reseed() { let s = ::test::rng().gen_iter::().take(256).collect::>(); let mut r: Isaac64Rng = SeedableRng::from_seed(&s[..]); let string1: String = r.gen_ascii_chars().take(100).collect(); r.reseed(&s[..]); let string2: String = r.gen_ascii_chars().take(100).collect(); assert_eq!(string1, string2); } #[test] fn test_rng_32_true_values() { let seed: &[_] = &[1, 23, 456, 7890, 12345]; let mut ra: IsaacRng = SeedableRng::from_seed(seed); // Regression test that isaac is actually using the above vector let v = (0..10).map(|_| ra.next_u32()).collect::>(); assert_eq!(v, vec!(2558573138, 873787463, 263499565, 2103644246, 3595684709, 4203127393, 264982119, 2765226902, 2737944514, 3900253796)); let seed: &[_] = &[12345, 67890, 54321, 9876]; let mut rb: IsaacRng = SeedableRng::from_seed(seed); // skip forward to the 10000th number for _ in 0..10000 { rb.next_u32(); } let v = (0..10).map(|_| rb.next_u32()).collect::>(); assert_eq!(v, vec!(3676831399, 3183332890, 2834741178, 3854698763, 2717568474, 1576568959, 3507990155, 179069555, 141456972, 2478885421)); } #[test] fn test_rng_64_true_values() { let seed: &[_] = &[1, 23, 456, 7890, 12345]; let mut ra: Isaac64Rng = SeedableRng::from_seed(seed); // Regression test that isaac is actually using the above vector let v = (0..10).map(|_| ra.next_u64()).collect::>(); assert_eq!(v, vec!(547121783600835980, 14377643087320773276, 17351601304698403469, 1238879483818134882, 11952566807690396487, 13970131091560099343, 4469761996653280935, 15552757044682284409, 6860251611068737823, 13722198873481261842)); let seed: &[_] = &[12345, 67890, 54321, 9876]; let mut rb: Isaac64Rng = SeedableRng::from_seed(seed); // skip forward to the 10000th number for _ in 0..10000 { rb.next_u64(); } let v = (0..10).map(|_| rb.next_u64()).collect::>(); assert_eq!(v, vec!(18143823860592706164, 8491801882678285927, 2699425367717515619, 17196852593171130876, 2606123525235546165, 15790932315217671084, 596345674630742204, 9947027391921273664, 11788097613744130851, 10391409374914919106)); } #[test] fn test_rng_clone() { let seed: &[_] = &[1, 23, 456, 7890, 12345]; let mut rng: Isaac64Rng = SeedableRng::from_seed(seed); let mut clone = rng.clone(); for _ in 0..16 { assert_eq!(rng.next_u64(), clone.next_u64()); } } } deps/rand-0.3.13/src/chacha.rs0000664000175000017500000002335412526416532012760 0ustar // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! The ChaCha random number generator. use std::num::Wrapping as w; use {Rng, SeedableRng, Rand, w32}; const KEY_WORDS : usize = 8; // 8 words for the 256-bit key const STATE_WORDS : usize = 16; const CHACHA_ROUNDS: u32 = 20; // Cryptographically secure from 8 upwards as of this writing /// A random number generator that uses the ChaCha20 algorithm [1]. /// /// The ChaCha algorithm is widely accepted as suitable for /// cryptographic purposes, but this implementation has not been /// verified as such. Prefer a generator like `OsRng` that defers to /// the operating system for cases that need high security. /// /// [1]: D. J. Bernstein, [*ChaCha, a variant of /// Salsa20*](http://cr.yp.to/chacha.html) #[derive(Copy, Clone)] pub struct ChaChaRng { buffer: [w32; STATE_WORDS], // Internal buffer of output state: [w32; STATE_WORDS], // Initial state index: usize, // Index into state } static EMPTY: ChaChaRng = ChaChaRng { buffer: [w(0); STATE_WORDS], state: [w(0); STATE_WORDS], index: STATE_WORDS }; macro_rules! quarter_round{ ($a: expr, $b: expr, $c: expr, $d: expr) => {{ $a = $a + $b; $d = $d ^ $a; $d = w($d.0.rotate_left(16)); $c = $c + $d; $b = $b ^ $c; $b = w($b.0.rotate_left(12)); $a = $a + $b; $d = $d ^ $a; $d = w($d.0.rotate_left( 8)); $c = $c + $d; $b = $b ^ $c; $b = w($b.0.rotate_left( 7)); }} } macro_rules! double_round{ ($x: expr) => {{ // Column round quarter_round!($x[ 0], $x[ 4], $x[ 8], $x[12]); quarter_round!($x[ 1], $x[ 5], $x[ 9], $x[13]); quarter_round!($x[ 2], $x[ 6], $x[10], $x[14]); quarter_round!($x[ 3], $x[ 7], $x[11], $x[15]); // Diagonal round quarter_round!($x[ 0], $x[ 5], $x[10], $x[15]); quarter_round!($x[ 1], $x[ 6], $x[11], $x[12]); quarter_round!($x[ 2], $x[ 7], $x[ 8], $x[13]); quarter_round!($x[ 3], $x[ 4], $x[ 9], $x[14]); }} } #[inline] fn core(output: &mut [w32; STATE_WORDS], input: &[w32; STATE_WORDS]) { *output = *input; for _ in 0..CHACHA_ROUNDS / 2 { double_round!(output); } for i in 0..STATE_WORDS { output[i] = output[i] + input[i]; } } impl ChaChaRng { /// Create an ChaCha random number generator using the default /// fixed key of 8 zero words. pub fn new_unseeded() -> ChaChaRng { let mut rng = EMPTY; rng.init(&[0; KEY_WORDS]); rng } /// Sets the internal 128-bit ChaCha counter to /// a user-provided value. This permits jumping /// arbitrarily ahead (or backwards) in the pseudorandom stream. /// /// Since the nonce words are used to extend the counter to 128 bits, /// users wishing to obtain the conventional ChaCha pseudorandom stream /// associated with a particular nonce can call this function with /// arguments `0, desired_nonce`. pub fn set_counter(&mut self, counter_low: u64, counter_high: u64) { self.state[12] = w((counter_low >> 0) as u32); self.state[13] = w((counter_low >> 32) as u32); self.state[14] = w((counter_high >> 0) as u32); self.state[15] = w((counter_high >> 32) as u32); self.index = STATE_WORDS; // force recomputation } /// Initializes `self.state` with the appropriate key and constants /// /// We deviate slightly from the ChaCha specification regarding /// the nonce, which is used to extend the counter to 128 bits. /// This is provably as strong as the original cipher, though, /// since any distinguishing attack on our variant also works /// against ChaCha with a chosen-nonce. See the XSalsa20 [1] /// security proof for a more involved example of this. /// /// The modified word layout is: /// ```text /// constant constant constant constant /// key key key key /// key key key key /// counter counter counter counter /// ``` /// [1]: Daniel J. Bernstein. [*Extending the Salsa20 /// nonce.*](http://cr.yp.to/papers.html#xsalsa) fn init(&mut self, key: &[u32; KEY_WORDS]) { self.state[0] = w(0x61707865); self.state[1] = w(0x3320646E); self.state[2] = w(0x79622D32); self.state[3] = w(0x6B206574); for i in 0..KEY_WORDS { self.state[4+i] = w(key[i]); } self.state[12] = w(0); self.state[13] = w(0); self.state[14] = w(0); self.state[15] = w(0); self.index = STATE_WORDS; } /// Refill the internal output buffer (`self.buffer`) fn update(&mut self) { core(&mut self.buffer, &self.state); self.index = 0; // update 128-bit counter self.state[12] = self.state[12] + w(1); if self.state[12] != w(0) { return }; self.state[13] = self.state[13] + w(1); if self.state[13] != w(0) { return }; self.state[14] = self.state[14] + w(1); if self.state[14] != w(0) { return }; self.state[15] = self.state[15] + w(1); } } impl Rng for ChaChaRng { #[inline] fn next_u32(&mut self) -> u32 { if self.index == STATE_WORDS { self.update(); } let value = self.buffer[self.index % STATE_WORDS]; self.index += 1; value.0 } } impl<'a> SeedableRng<&'a [u32]> for ChaChaRng { fn reseed(&mut self, seed: &'a [u32]) { // reset state self.init(&[0u32; KEY_WORDS]); // set key in place let key = &mut self.state[4 .. 4+KEY_WORDS]; for (k, s) in key.iter_mut().zip(seed.iter()) { *k = w(*s); } } /// Create a ChaCha generator from a seed, /// obtained from a variable-length u32 array. /// Only up to 8 words are used; if less than 8 /// words are used, the remaining are set to zero. fn from_seed(seed: &'a [u32]) -> ChaChaRng { let mut rng = EMPTY; rng.reseed(seed); rng } } impl Rand for ChaChaRng { fn rand(other: &mut R) -> ChaChaRng { let mut key : [u32; KEY_WORDS] = [0; KEY_WORDS]; for word in key.iter_mut() { *word = other.gen(); } SeedableRng::from_seed(&key[..]) } } #[cfg(test)] mod test { use {Rng, SeedableRng}; use super::ChaChaRng; #[test] fn test_rng_rand_seeded() { let s = ::test::rng().gen_iter::().take(8).collect::>(); let mut ra: ChaChaRng = SeedableRng::from_seed(&s[..]); let mut rb: ChaChaRng = SeedableRng::from_seed(&s[..]); assert!(::test::iter_eq(ra.gen_ascii_chars().take(100), rb.gen_ascii_chars().take(100))); } #[test] fn test_rng_seeded() { let seed : &[_] = &[0,1,2,3,4,5,6,7]; let mut ra: ChaChaRng = SeedableRng::from_seed(seed); let mut rb: ChaChaRng = SeedableRng::from_seed(seed); assert!(::test::iter_eq(ra.gen_ascii_chars().take(100), rb.gen_ascii_chars().take(100))); } #[test] fn test_rng_reseed() { let s = ::test::rng().gen_iter::().take(8).collect::>(); let mut r: ChaChaRng = SeedableRng::from_seed(&s[..]); let string1: String = r.gen_ascii_chars().take(100).collect(); r.reseed(&s); let string2: String = r.gen_ascii_chars().take(100).collect(); assert_eq!(string1, string2); } #[test] fn test_rng_true_values() { // Test vectors 1 and 2 from // http://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04 let seed : &[_] = &[0u32; 8]; let mut ra: ChaChaRng = SeedableRng::from_seed(seed); let v = (0..16).map(|_| ra.next_u32()).collect::>(); assert_eq!(v, vec!(0xade0b876, 0x903df1a0, 0xe56a5d40, 0x28bd8653, 0xb819d2bd, 0x1aed8da0, 0xccef36a8, 0xc70d778b, 0x7c5941da, 0x8d485751, 0x3fe02477, 0x374ad8b8, 0xf4b8436a, 0x1ca11815, 0x69b687c3, 0x8665eeb2)); let v = (0..16).map(|_| ra.next_u32()).collect::>(); assert_eq!(v, vec!(0xbee7079f, 0x7a385155, 0x7c97ba98, 0x0d082d73, 0xa0290fcb, 0x6965e348, 0x3e53c612, 0xed7aee32, 0x7621b729, 0x434ee69c, 0xb03371d5, 0xd539d874, 0x281fed31, 0x45fb0a51, 0x1f0ae1ac, 0x6f4d794b)); let seed : &[_] = &[0,1,2,3,4,5,6,7]; let mut ra: ChaChaRng = SeedableRng::from_seed(seed); // Store the 17*i-th 32-bit word, // i.e., the i-th word of the i-th 16-word block let mut v : Vec = Vec::new(); for _ in 0..16 { v.push(ra.next_u32()); for _ in 0..16 { ra.next_u32(); } } assert_eq!(v, vec!(0xf225c81a, 0x6ab1be57, 0x04d42951, 0x70858036, 0x49884684, 0x64efec72, 0x4be2d186, 0x3615b384, 0x11cfa18e, 0xd3c50049, 0x75c775f6, 0x434c6530, 0x2c5bad8f, 0x898881dc, 0x5f1c86d9, 0xc1f8e7f4)); } #[test] fn test_rng_clone() { let seed : &[_] = &[0u32; 8]; let mut rng: ChaChaRng = SeedableRng::from_seed(seed); let mut clone = rng.clone(); for _ in 0..16 { assert_eq!(rng.next_u64(), clone.next_u64()); } } } deps/rand-0.3.13/appveyor.yml0000664000175000017500000000073612556741370013007 0ustar environment: matrix: - TARGET: x86_64-pc-windows-msvc - TARGET: i686-pc-windows-msvc - TARGET: i686-pc-windows-gnu install: - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin - SET PATH=%PATH%;C:\MinGW\bin - rustc -V - cargo -V build: false test_script: - cargo test --verbose deps/rand-0.3.13/Cargo.toml0000664000175000017500000000075412644245147012346 0ustar [package] name = "rand" version = "0.3.13" authors = ["The Rust Project Developers"] license = "MIT/Apache-2.0" readme = "README.md" repository = "https://github.com/rust-lang/rand" documentation = "https://doc.rust-lang.org/rand" homepage = "https://github.com/rust-lang/rand" description = """ Random number generators and other randomness functionality. """ keywords = ["random", "rng"] [dependencies] libc = "0.2" winapi = "0.2" advapi32-sys = "0.1.2" [dev-dependencies] log = "0.3.0" deps/rand-0.3.13/benches/0000755000000000000000000000000012666635520013575 5ustar rootrootdeps/rand-0.3.13/benches/bench.rs0000664000175000017500000000371012616224325013437 0ustar #![feature(test)] extern crate test; extern crate rand; const RAND_BENCH_N: u64 = 1000; mod distributions; use std::mem::size_of; use test::{black_box, Bencher}; use rand::{XorShiftRng, StdRng, IsaacRng, Isaac64Rng, Rng}; use rand::{OsRng, weak_rng}; #[bench] fn rand_xorshift(b: &mut Bencher) { let mut rng: XorShiftRng = OsRng::new().unwrap().gen(); b.iter(|| { for _ in 0..RAND_BENCH_N { black_box(rng.gen::()); } }); b.bytes = size_of::() as u64 * RAND_BENCH_N; } #[bench] fn rand_isaac(b: &mut Bencher) { let mut rng: IsaacRng = OsRng::new().unwrap().gen(); b.iter(|| { for _ in 0..RAND_BENCH_N { black_box(rng.gen::()); } }); b.bytes = size_of::() as u64 * RAND_BENCH_N; } #[bench] fn rand_isaac64(b: &mut Bencher) { let mut rng: Isaac64Rng = OsRng::new().unwrap().gen(); b.iter(|| { for _ in 0..RAND_BENCH_N { black_box(rng.gen::()); } }); b.bytes = size_of::() as u64 * RAND_BENCH_N; } #[bench] fn rand_std(b: &mut Bencher) { let mut rng = StdRng::new().unwrap(); b.iter(|| { for _ in 0..RAND_BENCH_N { black_box(rng.gen::()); } }); b.bytes = size_of::() as u64 * RAND_BENCH_N; } #[bench] fn rand_f32(b: &mut Bencher) { let mut rng = StdRng::new().unwrap(); b.iter(|| { for _ in 0..RAND_BENCH_N { black_box(rng.next_f32()); } }); b.bytes = size_of::() as u64 * RAND_BENCH_N; } #[bench] fn rand_f64(b: &mut Bencher) { let mut rng = StdRng::new().unwrap(); b.iter(|| { for _ in 0..RAND_BENCH_N { black_box(rng.next_f64()); } }); b.bytes = size_of::() as u64 * RAND_BENCH_N; } #[bench] fn rand_shuffle_100(b: &mut Bencher) { let mut rng = weak_rng(); let x : &mut [usize] = &mut [1; 100]; b.iter(|| { rng.shuffle(x); }) } deps/rand-0.3.13/benches/distributions/0000755000000000000000000000000012666635520016477 5ustar rootrootdeps/rand-0.3.13/benches/distributions/exponential.rs0000664000175000017500000000064012526416621017611 0ustar use std::mem::size_of; use test::Bencher; use rand; use rand::distributions::exponential::Exp; use rand::distributions::Sample; #[bench] fn rand_exp(b: &mut Bencher) { let mut rng = rand::weak_rng(); let mut exp = Exp::new(2.71828 * 3.14159); b.iter(|| { for _ in 0..::RAND_BENCH_N { exp.sample(&mut rng); } }); b.bytes = size_of::() as u64 * ::RAND_BENCH_N; } deps/rand-0.3.13/benches/distributions/normal.rs0000664000175000017500000000065212526416632016560 0ustar use std::mem::size_of; use test::Bencher; use rand; use rand::distributions::Sample; use rand::distributions::normal::Normal; #[bench] fn rand_normal(b: &mut Bencher) { let mut rng = rand::weak_rng(); let mut normal = Normal::new(-2.71828, 3.14159); b.iter(|| { for _ in 0..::RAND_BENCH_N { normal.sample(&mut rng); } }); b.bytes = size_of::() as u64 * ::RAND_BENCH_N; } deps/rand-0.3.13/benches/distributions/mod.rs0000664000175000017500000000005012526416030016027 0ustar mod exponential; mod normal; mod gamma; deps/rand-0.3.13/benches/distributions/gamma.rs0000664000175000017500000000133712526416647016361 0ustar use std::mem::size_of; use test::Bencher; use rand; use rand::distributions::IndependentSample; use rand::distributions::gamma::Gamma; #[bench] fn bench_gamma_large_shape(b: &mut Bencher) { let gamma = Gamma::new(10., 1.0); let mut rng = rand::weak_rng(); b.iter(|| { for _ in 0..::RAND_BENCH_N { gamma.ind_sample(&mut rng); } }); b.bytes = size_of::() as u64 * ::RAND_BENCH_N; } #[bench] fn bench_gamma_small_shape(b: &mut Bencher) { let gamma = Gamma::new(0.1, 1.0); let mut rng = rand::weak_rng(); b.iter(|| { for _ in 0..::RAND_BENCH_N { gamma.ind_sample(&mut rng); } }); b.bytes = size_of::() as u64 * ::RAND_BENCH_N; } deps/regex-0.1.44/0000755000000000000000000000000012666635520012356 5ustar rootrootdeps/regex-0.1.44/LICENSE-APACHE0000644000175000001440000002513712537446732013614 0ustar users Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. deps/regex-0.1.44/LICENSE-MIT0000644000175000001440000000205712537446732013320 0ustar usersCopyright (c) 2014 The Rust Project Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. deps/regex-0.1.44/examples/0000755000000000000000000000000012666635520014174 5ustar rootrootdeps/regex-0.1.44/examples/regexdna-output.txt0000644000175000001440000000041312540100510017337 0ustar usersagggtaaa|tttaccct 0 [cgt]gggtaaa|tttaccc[acg] 3 a[act]ggtaaa|tttacc[agt]t 9 ag[act]gtaaa|tttac[agt]ct 8 agg[act]taaa|ttta[agt]cct 10 aggg[acg]aaa|ttt[cgt]ccct 3 agggt[cgt]aa|tt[acg]accct 4 agggta[cgt]a|t[acg]taccct 3 agggtaa[cgt]|[acg]ttaccct 5 101745 100000 133640 deps/regex-0.1.44/examples/shootout-regex-dna-single.rs0000644000175000001440000000316612541316124021047 0ustar users// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // contributed by TeXitoi // contributed by BurntSushi extern crate regex; use std::io::{self, Read}; macro_rules! regex { ($re:expr) => { ::regex::Regex::new($re).unwrap() } } fn main() { let mut seq = String::with_capacity(50 * (1 << 20)); io::stdin().read_to_string(&mut seq).unwrap(); let ilen = seq.len(); seq = regex!(">[^\n]*\n|\n").replace_all(&seq, ""); let clen = seq.len(); let variants = vec![ regex!("agggtaaa|tttaccct"), regex!("[cgt]gggtaaa|tttaccc[acg]"), regex!("a[act]ggtaaa|tttacc[agt]t"), regex!("ag[act]gtaaa|tttac[agt]ct"), regex!("agg[act]taaa|ttta[agt]cct"), regex!("aggg[acg]aaa|ttt[cgt]ccct"), regex!("agggt[cgt]aa|tt[acg]accct"), regex!("agggta[cgt]a|t[acg]taccct"), regex!("agggtaa[cgt]|[acg]ttaccct"), ]; for re in variants { println!("{} {}", re.to_string(), re.find_iter(&seq).count()); } let substs = vec![ (regex!("B"), "(c|g|t)"), (regex!("D"), "(a|g|t)"), (regex!("H"), "(a|c|t)"), (regex!("K"), "(g|t)"), (regex!("M"), "(a|c)"), (regex!("N"), "(a|c|g|t)"), (regex!("R"), "(a|g)"), (regex!("S"), "(c|g)"), (regex!("V"), "(a|c|g)"), (regex!("W"), "(a|t)"), (regex!("Y"), "(c|t)"), ]; let mut seq = seq; for (re, replacement) in substs.into_iter() { seq = re.replace_all(&seq, replacement); } println!("\n{}\n{}\n{}", ilen, clen, seq.len()); } deps/regex-0.1.44/examples/shootout-regex-dna-cheat.rs0000644000175000001440000000566112553777160020672 0ustar users// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // contributed by TeXitoi // contributed by BurntSushi // This technically solves the problem posed in the `regex-dna` benchmark, but // it cheats by combining all of the replacements into a single regex and // replacing them with a single linear scan. i.e., it re-implements // `replace_all`. As a result, this is around 25% faster. ---AG extern crate regex; use std::io::{self, Read}; use std::sync::Arc; use std::thread; macro_rules! regex { ($re:expr) => { ::regex::Regex::new($re).unwrap() } } fn main() { let mut seq = String::with_capacity(50 * (1 << 20)); io::stdin().read_to_string(&mut seq).unwrap(); let ilen = seq.len(); seq = regex!(">[^\n]*\n|\n").replace_all(&seq, ""); let clen = seq.len(); let seq_arc = Arc::new(seq.clone()); let variants = vec![ regex!("agggtaaa|tttaccct"), regex!("[cgt]gggtaaa|tttaccc[acg]"), regex!("a[act]ggtaaa|tttacc[agt]t"), regex!("ag[act]gtaaa|tttac[agt]ct"), regex!("agg[act]taaa|ttta[agt]cct"), regex!("aggg[acg]aaa|ttt[cgt]ccct"), regex!("agggt[cgt]aa|tt[acg]accct"), regex!("agggta[cgt]a|t[acg]taccct"), regex!("agggtaa[cgt]|[acg]ttaccct"), ]; let mut count_promises = vec![]; for i in 0..3 { let seq = seq_arc.clone(); let res = variants[i * 3..i * 3 + 3].to_vec(); count_promises.push(thread::spawn(move || { res.into_iter() .map(|re| (re.to_string(), re.find_iter(&seq).count())) .collect::>() })); } let substs = vec![ (b'B', "(c|g|t)"), (b'D', "(a|g|t)"), (b'H', "(a|c|t)"), (b'K', "(g|t)"), (b'M', "(a|c)"), (b'N', "(a|c|g|t)"), (b'R', "(a|g)"), (b'S', "(c|g)"), (b'V', "(a|c|g)"), (b'W', "(a|t)"), (b'Y', "(c|t)"), ]; // combined into one regex in `replace_all` let seq = replace_all(&seq, substs); for promise in count_promises { for (re, count) in promise.join().unwrap() { println!("{} {}", re, count); } } println!("\n{}\n{}\n{}", ilen, clen, seq.len()); } #[allow(deprecated)] // for connect -> join in Rust 1.3 fn replace_all(text: &str, substs: Vec<(u8, &str)>) -> String { let mut replacements = vec![""; 256]; let mut alternates = vec![]; for (re, replacement) in substs { replacements[re as usize] = replacement; alternates.push((re as char).to_string()); } let re = regex!(&alternates.connect("|")); let mut new = String::with_capacity(text.len()); let mut last_match = 0; for (s, e) in re.find_iter(text) { new.push_str(&text[last_match..s]); new.push_str(replacements[text.as_bytes()[s] as usize]); last_match = e; } new.push_str(&text[last_match..]); new } deps/regex-0.1.44/examples/regexdna-input.txt0000644000175000001440000030656112540100510017153 0ustar users>ONE Homo sapiens alu GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGA TCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACT AAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAG GCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCG CCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGT GGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCA GGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAA TTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAG AATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCA GCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGT AATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACC AGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTG GTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACC CGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAG AGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTT TGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACA TGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCT GTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGG TTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGT CTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGG CGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCG TCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTA CTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCG AGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCG GGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACC TGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAA TACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGA GGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACT GCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTC ACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGT TCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGC CGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCG CTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTG GGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCC CAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCT GGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGC GCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGA GGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGA GACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGA GGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTG AAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAAT CCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCA GTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAA AAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGC GGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCT ACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGG GAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATC GCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGC GGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGG TCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAA AAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAG GAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACT CCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCC TGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAG ACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGC GTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGA ACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGA CAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCA CTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCA ACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCG CCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGG AGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTC CGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCG AGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACC CCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAG CTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAG CCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGG CCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATC ACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAA AAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGC TGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCC ACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGG CTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGG AGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATT AGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAA TCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGC CTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAA TCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAG CCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGT GGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCG GGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAG CGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTG GGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATG GTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGT AATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTT GCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCT CAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCG GGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTC TCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACT CGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAG ATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGG CGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTG AGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATA CAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGG CAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGC ACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCAC GCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTC GAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCG GGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCT TGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGG CGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCA GCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGG CCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGC GCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGG CGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGA CTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGG CCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAA ACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCC CAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGT GAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAA AGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGG ATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTAC TAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGA GGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGC GCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGG TGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTC AGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAA ATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGA GAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTG TAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGAC CAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGT GGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAAC CCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACA GAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACT TTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAAC ATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCC TGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAG GTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCG TCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAG GCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCC GTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCT ACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCC GAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCC GGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCAC CTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAA ATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTG AGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCAC TGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCT CACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAG TTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAG CCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATC GCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCT GGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATC CCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCC TGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGG CGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCG AGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGG AGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGT GAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAA TCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGC AGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCA AAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGG CGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTC TACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCG GGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGAT CGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCG CGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAG GTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACA AAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCA GGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCAC TCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGC CTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGA GACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGG CGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTG AACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCG ACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGC ACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCC AACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGC GCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCG GAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACT CCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCC GAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAAC CCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGA GCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAG GCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGAT CACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTA AAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGG CTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGC CACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTG GCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAG GAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAAT TAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGA ATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAG CCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTA ATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCA GCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGG TGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCC GGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGA GCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTT GGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACAT GGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTG TAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGT TGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTC TCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGC GGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGT CTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTAC TCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGA GATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGG GCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCT GAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAG GCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTG CACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCA CGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTT CGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCC GGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGC TTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGG GCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCC AGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTG GCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCG CGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAG GCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAG ACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAG GCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGA AACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATC CCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAG TGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAA AAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCG GATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTA CTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGG AGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCG CGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCG GTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGT CAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAA AATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGG AGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTC CAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCT GTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCG TGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAA CCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGAC AGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCAC TTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAA CATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGC CTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGA GGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCC GTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGA GGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCC CGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGC TACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGC CGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGC CGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCA CCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAA AATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCT GAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCA CTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGC TCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGA GTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTA GCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAAT CGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCC TGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAAT CCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGC CTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTG GCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGG GAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGC GAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGG TGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTA ATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTG CAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTC AAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGG GCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCT CTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTC GGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGA TCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGC GCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGA GGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATAC AAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGC AGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCA CTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACG CCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCG AGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGG GCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTT GAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGC GACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAG CACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGC CAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCG CGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGC GGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGAC TCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGC CGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAA CCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCC AGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTG AGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGA TCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACT AAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAG GCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCG CCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGT GGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCA GGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAA TTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAG AATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCA GCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGT AATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACC AGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTG GTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACC CGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAG AGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTT TGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACA TGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCT GTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGG TTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGT CTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGG CGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCG TCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTA CTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCG AGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCG GGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACC TGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAA TACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGA GGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACT GCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTC ACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGT TCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGC CGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCG CTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTG GGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCC CAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCT GGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGC GCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGA GGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGA GACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGA GGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTG AAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAAT CCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCA GTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAA AAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGC GGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCT ACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGG GAGGCTGAGGCAGGAGAATC >TWO IUB ambiguity codes cttBtatcatatgctaKggNcataaaSatgtaaaDcDRtBggDtctttataattcBgtcg tactDtDagcctatttSVHtHttKtgtHMaSattgWaHKHttttagacatWatgtRgaaa NtactMcSMtYtcMgRtacttctWBacgaaatatagScDtttgaagacacatagtVgYgt cattHWtMMWcStgttaggKtSgaYaaccWStcgBttgcgaMttBYatcWtgacaYcaga gtaBDtRacttttcWatMttDBcatWtatcttactaBgaYtcttgttttttttYaaScYa HgtgttNtSatcMtcVaaaStccRcctDaataataStcYtRDSaMtDttgttSagtRRca tttHatSttMtWgtcgtatSSagactYaaattcaMtWatttaSgYttaRgKaRtccactt tattRggaMcDaWaWagttttgacatgttctacaaaRaatataataaMttcgDacgaSSt acaStYRctVaNMtMgtaggcKatcttttattaaaaagVWaHKYagtttttatttaacct tacgtVtcVaattVMBcttaMtttaStgacttagattWWacVtgWYagWVRctDattBYt gtttaagaagattattgacVatMaacattVctgtBSgaVtgWWggaKHaatKWcBScSWa accRVacacaaactaccScattRatatKVtactatatttHttaagtttSKtRtacaaagt RDttcaaaaWgcacatWaDgtDKacgaacaattacaRNWaatHtttStgttattaaMtgt tgDcgtMgcatBtgcttcgcgaDWgagctgcgaggggVtaaScNatttacttaatgacag cccccacatYScaMgtaggtYaNgttctgaMaacNaMRaacaaacaKctacatagYWctg ttWaaataaaataRattagHacacaagcgKatacBttRttaagtatttccgatctHSaat actcNttMaagtattMtgRtgaMgcataatHcMtaBSaRattagttgatHtMttaaKagg YtaaBataSaVatactWtataVWgKgttaaaacagtgcgRatatacatVtHRtVYataSa KtWaStVcNKHKttactatccctcatgWHatWaRcttactaggatctataDtDHBttata aaaHgtacVtagaYttYaKcctattcttcttaataNDaaggaaaDYgcggctaaWSctBa aNtgctggMBaKctaMVKagBaactaWaDaMaccYVtNtaHtVWtKgRtcaaNtYaNacg gtttNattgVtttctgtBaWgtaattcaagtcaVWtactNggattctttaYtaaagccgc tcttagHVggaYtgtNcDaVagctctctKgacgtatagYcctRYHDtgBattDaaDgccK tcHaaStttMcctagtattgcRgWBaVatHaaaataYtgtttagMDMRtaataaggatMt ttctWgtNtgtgaaaaMaatatRtttMtDgHHtgtcattttcWattRSHcVagaagtacg ggtaKVattKYagactNaatgtttgKMMgYNtcccgSKttctaStatatNVataYHgtNa BKRgNacaactgatttcctttaNcgatttctctataScaHtataRagtcRVttacDSDtt aRtSatacHgtSKacYagttMHtWataggatgactNtatSaNctataVtttRNKtgRacc tttYtatgttactttttcctttaaacatacaHactMacacggtWataMtBVacRaSaatc cgtaBVttccagccBcttaRKtgtgcctttttRtgtcagcRttKtaaacKtaaatctcac aattgcaNtSBaaccgggttattaaBcKatDagttactcttcattVtttHaaggctKKga tacatcBggScagtVcacattttgaHaDSgHatRMaHWggtatatRgccDttcgtatcga aacaHtaagttaRatgaVacttagattVKtaaYttaaatcaNatccRttRRaMScNaaaD gttVHWgtcHaaHgacVaWtgttScactaagSgttatcttagggDtaccagWattWtRtg ttHWHacgattBtgVcaYatcggttgagKcWtKKcaVtgaYgWctgYggVctgtHgaNcV taBtWaaYatcDRaaRtSctgaHaYRttagatMatgcatttNattaDttaattgttctaa ccctcccctagaWBtttHtBccttagaVaatMcBHagaVcWcagBVttcBtaYMccagat gaaaaHctctaacgttagNWRtcggattNatcRaNHttcagtKttttgWatWttcSaNgg gaWtactKKMaacatKatacNattgctWtatctaVgagctatgtRaHtYcWcttagccaa tYttWttaWSSttaHcaaaaagVacVgtaVaRMgattaVcDactttcHHggHRtgNcctt tYatcatKgctcctctatVcaaaaKaaaagtatatctgMtWtaaaacaStttMtcgactt taSatcgDataaactaaacaagtaaVctaggaSccaatMVtaaSKNVattttgHccatca cBVctgcaVatVttRtactgtVcaattHgtaaattaaattttYtatattaaRSgYtgBag aHSBDgtagcacRHtYcBgtcacttacactaYcgctWtattgSHtSatcataaatataHt cgtYaaMNgBaatttaRgaMaatatttBtttaaaHHKaatctgatWatYaacttMctctt ttVctagctDaaagtaVaKaKRtaacBgtatccaaccactHHaagaagaaggaNaaatBW attccgStaMSaMatBttgcatgRSacgttVVtaaDMtcSgVatWcaSatcttttVatag ttactttacgatcaccNtaDVgSRcgVcgtgaacgaNtaNatatagtHtMgtHcMtagaa attBgtataRaaaacaYKgtRccYtatgaagtaataKgtaaMttgaaRVatgcagaKStc tHNaaatctBBtcttaYaBWHgtVtgacagcaRcataWctcaBcYacYgatDgtDHccta aagacYRcaggattHaYgtKtaatgcVcaataMYacccatatcacgWDBtgaatcBaata cKcttRaRtgatgaBDacggtaattaaYtataStgVHDtDctgactcaaatKtacaatgc gYatBtRaDatHaactgtttatatDttttaaaKVccYcaaccNcBcgHaaVcattHctcg attaaatBtatgcaaaaatYMctSactHatacgaWacattacMBgHttcgaatVaaaaca BatatVtctgaaaaWtctRacgBMaatSgRgtgtcgactatcRtattaScctaStagKga DcWgtYtDDWKRgRtHatRtggtcgaHgggcgtattaMgtcagccaBggWVcWctVaaat tcgNaatcKWagcNaHtgaaaSaaagctcYctttRVtaaaatNtataaccKtaRgtttaM tgtKaBtRtNaggaSattHatatWactcagtgtactaKctatttgRYYatKatgtccgtR tttttatttaatatVgKtttgtatgtNtataRatWYNgtRtHggtaaKaYtKSDcatcKg taaYatcSRctaVtSMWtVtRWHatttagataDtVggacagVcgKWagBgatBtaaagNc aRtagcataBggactaacacRctKgttaatcctHgDgttKHHagttgttaatgHBtatHc DaagtVaBaRccctVgtgDtacRHSctaagagcggWYaBtSaKtHBtaaactYacgNKBa VYgtaacttagtVttcttaatgtBtatMtMtttaattaatBWccatRtttcatagVgMMt agctStKctaMactacDNYgKYHgaWcgaHgagattacVgtttgtRaSttaWaVgataat gtgtYtaStattattMtNgWtgttKaccaatagNYttattcgtatHcWtctaaaNVYKKt tWtggcDtcgaagtNcagatacgcattaagaccWctgcagcttggNSgaNcHggatgtVt catNtRaaBNcHVagagaaBtaaSggDaatWaatRccaVgggStctDaacataKttKatt tggacYtattcSatcttagcaatgaVBMcttDattctYaaRgatgcattttNgVHtKcYR aatRKctgtaaacRatVSagctgtWacBtKVatctgttttKcgtctaaDcaagtatcSat aWVgcKKataWaYttcccSaatgaaaacccWgcRctWatNcWtBRttYaattataaNgac acaatagtttVNtataNaYtaatRaVWKtBatKagtaatataDaNaaaaataMtaagaaS tccBcaatNgaataWtHaNactgtcDtRcYaaVaaaaaDgtttRatctatgHtgttKtga aNSgatactttcgagWaaatctKaaDaRttgtggKKagcDgataaattgSaacWaVtaNM acKtcaDaaatttctRaaVcagNacaScRBatatctRatcctaNatWgRtcDcSaWSgtt RtKaRtMtKaatgttBHcYaaBtgatSgaSWaScMgatNtctcctatttctYtatMatMt RRtSaattaMtagaaaaStcgVgRttSVaScagtgDtttatcatcatacRcatatDctta tcatVRtttataaHtattcYtcaaaatactttgVctagtaaYttagatagtSYacKaaac gaaKtaaatagataatSatatgaaatSgKtaatVtttatcctgKHaatHattagaaccgt YaaHactRcggSBNgtgctaaBagBttgtRttaaattYtVRaaaattgtaatVatttctc ttcatgBcVgtgKgaHaaatattYatagWacNctgaaMcgaattStagWaSgtaaKagtt ttaagaDgatKcctgtaHtcatggKttVDatcaaggtYcgccagNgtgcVttttagagat gctaccacggggtNttttaSHaNtatNcctcatSaaVgtactgBHtagcaYggYVKNgta KBcRttgaWatgaatVtagtcgattYgatgtaatttacDacSctgctaaaStttaWMagD aaatcaVYctccgggcgaVtaaWtStaKMgDtttcaaMtVgBaatccagNaaatcYRMBg gttWtaaScKttMWtYataRaDBMaDataatHBcacDaaKDactaMgagttDattaHatH taYatDtattDcRNStgaatattSDttggtattaaNSYacttcDMgYgBatWtaMagact VWttctttgYMaYaacRgHWaattgRtaagcattctMKVStatactacHVtatgatcBtV NataaBttYtSttacKgggWgYDtgaVtYgatDaacattYgatggtRDaVDttNactaSa MtgNttaacaaSaBStcDctaccacagacgcaHatMataWKYtaYattMcaMtgSttDag cHacgatcaHttYaKHggagttccgatYcaatgatRaVRcaagatcagtatggScctata ttaNtagcgacgtgKaaWaactSgagtMYtcttccaKtStaacggMtaagNttattatcg tctaRcactctctDtaacWYtgaYaSaagaWtNtatttRacatgNaatgttattgWDDcN aHcctgaaHacSgaataaRaataMHttatMtgaSDSKatatHHaNtacagtccaYatWtc actaactatKDacSaStcggataHgYatagKtaatKagStaNgtatactatggRHacttg tattatgtDVagDVaRctacMYattDgtttYgtctatggtKaRSttRccRtaaccttaga gRatagSaaMaacgcaNtatgaaatcaRaagataatagatactcHaaYKBctccaagaRa BaStNagataggcgaatgaMtagaatgtcaKttaaatgtaWcaBttaatRcggtgNcaca aKtttScRtWtgcatagtttWYaagBttDKgcctttatMggNttattBtctagVtacata aaYttacacaaRttcYtWttgHcaYYtaMgBaBatctNgcDtNttacgacDcgataaSat YaSttWtcctatKaatgcagHaVaacgctgcatDtgttaSataaaaYSNttatagtaNYt aDaaaNtggggacttaBggcHgcgtNtaaMcctggtVtaKcgNacNtatVaSWctWtgaW cggNaBagctctgaYataMgaagatBSttctatacttgtgtKtaattttRagtDtacata tatatgatNHVgBMtKtaKaNttDHaagatactHaccHtcatttaaagttVaMcNgHata tKtaNtgYMccttatcaaNagctggacStttcNtggcaVtattactHaSttatgNMVatt MMDtMactattattgWMSgtHBttStStgatatRaDaagattttctatMtaaaaaggtac taaVttaSacNaatactgMttgacHaHRttgMacaaaatagttaatatWKRgacDgaRta tatttattatcYttaWtgtBRtWatgHaaattHataagtVaDtWaVaWtgStcgtMSgaS RgMKtaaataVacataatgtaSaatttagtcgaaHtaKaatgcacatcggRaggSKctDc agtcSttcccStYtccRtctctYtcaaKcgagtaMttttcRaYDttgttatctaatcata NctctgctatcaMatactataggDaHaaSttMtaDtcNatataattctMcStaaBYtaNa gatgtaatHagagSttgWHVcttatKaYgDctcttggtgttMcRaVgSgggtagacaata aDtaattSaDaNaHaBctattgNtaccaaRgaVtKNtaaYggHtaKKgHcatctWtctDt ttctttggSDtNtaStagttataaacaattgcaBaBWggHgcaaaBtYgctaatgaaatW cDcttHtcMtWWattBHatcatcaaatctKMagtDNatttWaBtHaaaNgMttaaStagt tctctaatDtcRVaYttgttMtRtgtcaSaaYVgSWDRtaatagctcagDgcWWaaaBaa RaBctgVgggNgDWStNaNBKcBctaaKtttDcttBaaggBttgaccatgaaaNgttttt tttatctatgttataccaaDRaaSagtaVtDtcaWatBtacattaWacttaSgtattggD gKaaatScaattacgWcagKHaaccaYcRcaRttaDttRtttHgaHVggcttBaRgtccc tDatKaVtKtcRgYtaKttacgtatBtStaagcaattaagaRgBagSaattccSWYttta ttVaataNctgHgttaaNBgcVYgtRtcccagWNaaaacaDNaBcaaaaRVtcWMgBagM tttattacgDacttBtactatcattggaaatVccggttRttcatagttVYcatYaSHaHc ttaaagcNWaHataaaRWtctVtRYtagHtaaaYMataHYtNBctNtKaatattStgaMc BtRgctaKtgcScSttDgYatcVtggaaKtaagatWccHccgKYctaNNctacaWctttt gcRtgtVcgaKttcMRHgctaHtVaataaDtatgKDcttatBtDttggNtacttttMtga acRattaaNagaactcaaaBBVtcDtcgaStaDctgaaaSgttMaDtcgttcaccaaaag gWtcKcgSMtcDtatgtttStaaBtatagDcatYatWtaaaBacaKgcaDatgRggaaYc taRtccagattDaWtttggacBaVcHtHtaacDacYgtaatataMagaatgHMatcttat acgtatttttatattacHactgttataMgStYaattYaccaattgagtcaaattaYtgta tcatgMcaDcgggtcttDtKgcatgWRtataatatRacacNRBttcHtBgcRttgtgcgt catacMtttBctatctBaatcattMttMYgattaaVYatgDaatVagtattDacaacDMa tcMtHcccataagatgBggaccattVWtRtSacatgctcaaggggYtttDtaaNgNtaaB atggaatgtctRtaBgBtcNYatatNRtagaacMgagSaSDDSaDcctRagtVWSHtVSR ggaacaBVaccgtttaStagaacaMtactccagtttVctaaRaaHttNcttagcaattta ttaatRtaaaatctaacDaBttggSagagctacHtaaRWgattcaaBtctRtSHaNtgta cattVcaHaNaagtataccacaWtaRtaaVKgMYaWgttaKggKMtKcgWatcaDatYtK SttgtacgaccNctSaattcDcatcttcaaaDKttacHtggttHggRRaRcaWacaMtBW VHSHgaaMcKattgtaRWttScNattBBatYtaNRgcggaagacHSaattRtttcYgacc BRccMacccKgatgaacttcgDgHcaaaaaRtatatDtatYVtttttHgSHaSaatagct NYtaHYaVYttattNtttgaaaYtaKttWtctaNtgagaaaNctNDctaaHgttagDcRt tatagccBaacgcaRBtRctRtggtaMYYttWtgataatcgaataattattataVaaaaa ttacNRVYcaaMacNatRttcKatMctgaagactaattataaYgcKcaSYaatMNctcaa cgtgatttttBacNtgatDccaattattKWWcattttatatatgatBcDtaaaagttgaa VtaHtaHHtBtataRBgtgDtaataMttRtDgDcttattNtggtctatctaaBcatctaR atgNacWtaatgaagtcMNaacNgHttatactaWgcNtaStaRgttaaHacccgaYStac aaaatWggaYaWgaattattcMaactcBKaaaRVNcaNRDcYcgaBctKaacaaaaaSgc tccYBBHYaVagaatagaaaacagYtctVccaMtcgtttVatcaatttDRtgWctagtac RttMctgtDctttcKtWttttataaatgVttgBKtgtKWDaWagMtaaagaaattDVtag gttacatcatttatgtcgMHaVcttaBtVRtcgtaYgBRHatttHgaBcKaYWaatcNSc tagtaaaaatttacaatcactSWacgtaatgKttWattagttttNaggtctcaagtcact attcttctaagKggaataMgtttcataagataaaaatagattatDgcBVHWgaBKttDgc atRHaagcaYcRaattattatgtMatatattgHDtcaDtcaaaHctStattaatHaccga cNattgatatattttgtgtDtRatagSacaMtcRtcattcccgacacSattgttKaWatt NHcaacttccgtttSRtgtctgDcgctcaaMagVtBctBMcMcWtgtaacgactctcttR ggRKSttgYtYatDccagttDgaKccacgVatWcataVaaagaataMgtgataaKYaaat cHDaacgataYctRtcYatcgcaMgtNttaBttttgatttaRtStgcaacaaaataccVg aaDgtVgDcStctatatttattaaaaRKDatagaaagaKaaYYcaYSgKStctccSttac agtcNactttDVttagaaagMHttRaNcSaRaMgBttattggtttaRMggatggcKDgWR tNaataataWKKacttcKWaaagNaBttaBatMHtccattaacttccccYtcBcYRtaga ttaagctaaYBDttaNtgaaaccHcaRMtKtaaHMcNBttaNaNcVcgVttWNtDaBatg ataaVtcWKcttRggWatcattgaRagHgaattNtatttctctattaattaatgaDaaMa tacgttgggcHaYVaaNaDDttHtcaaHtcVVDgBVagcMacgtgttaaBRNtatRtcag taagaggtttaagacaVaaggttaWatctccgtVtaDtcDatttccVatgtacNtttccg tHttatKgScBatgtVgHtYcWagcaKtaMYaaHgtaattaSaHcgcagtWNaatNccNN YcacgVaagaRacttctcattcccRtgtgtaattagcSttaaStWaMtctNNcSMacatt ataaactaDgtatWgtagtttaagaaaattgtagtNagtcaataaatttgatMMYactaa tatcggBWDtVcYttcDHtVttatacYaRgaMaacaStaatcRttttVtagaDtcacWat ttWtgaaaagaaagNRacDtttStVatBaDNtaactatatcBSMcccaSttccggaMatg attaaWatKMaBaBatttgataNctgttKtVaagtcagScgaaaDggaWgtgttttKtWt atttHaatgtagttcactaaKMagttSYBtKtaYgaactcagagRtatagtVtatcaaaW YagcgNtaDagtacNSaaYDgatBgtcgataacYDtaaactacagWDcYKaagtttatta gcatcgagttKcatDaattgattatDtcagRtWSKtcgNtMaaaaacaMttKcaWcaaSV MaaaccagMVtaMaDtMaHaBgaacataBBVtaatVYaNSWcSgNtDNaaKacacBttta tKtgtttcaaHaMctcagtaacgtcgYtactDcgcctaNgagagcYgatattttaaattt ccattttacatttDaaRctattttWctttacgtDatYtttcagacgcaaVttagtaaKaa aRtgVtccataBggacttatttgtttaWNtgttVWtaWNVDaattgtatttBaagcBtaa BttaaVatcHcaVgacattccNggtcgacKttaaaRtagRtctWagaYggtgMtataatM tgaaRttattttgWcttNtDRRgMDKacagaaaaggaaaRStcccagtYccVattaNaaK StNWtgacaVtagaagcttSaaDtcacaacgDYacWDYtgtttKatcVtgcMaDaSKStV cgtagaaWaKaagtttcHaHgMgMtctataagBtKaaaKKcactggagRRttaagaBaaN atVVcgRcKSttDaactagtSttSattgttgaaRYatggttVttaataaHttccaagDtg atNWtaagHtgcYtaactRgcaatgMgtgtRaatRaNaacHKtagactactggaatttcg ccataacgMctRgatgttaccctaHgtgWaYcactcacYaattcttaBtgacttaaacct gYgaWatgBttcttVttcgttWttMcNYgtaaaatctYgMgaaattacNgaHgaacDVVM tttggtHtctaaRgtacagacgHtVtaBMNBgattagcttaRcttacaHcRctgttcaaD BggttKaacatgKtttYataVaNattccgMcgcgtagtRaVVaattaKaatggttRgaMc agtatcWBttNtHagctaatctagaaNaaacaYBctatcgcVctBtgcaaagDgttVtga HtactSNYtaaNccatgtgDacgaVtDcgKaRtacDcttgctaagggcagMDagggtBWR tttSgccttttttaacgtcHctaVtVDtagatcaNMaVtcVacatHctDWNaataRgcgt aVHaggtaaaaSgtttMtattDgBtctgatSgtRagagYtctSaKWaataMgattRKtaa catttYcgtaacacattRWtBtcggtaaatMtaaacBatttctKagtcDtttgcBtKYYB aKttctVttgttaDtgattttcttccacttgSaaacggaaaNDaattcYNNaWcgaaYat tttMgcBtcatRtgtaaagatgaWtgaccaYBHgaatagataVVtHtttVgYBtMctaMt cctgaDcYttgtccaaaRNtacagcMctKaaaggatttacatgtttaaWSaYaKttBtag DacactagctMtttNaKtctttcNcSattNacttggaacaatDagtattRtgSHaataat gccVgacccgatactatccctgtRctttgagaSgatcatatcgDcagWaaHSgctYYWta tHttggttctttatVattatcgactaagtgtagcatVgtgHMtttgtttcgttaKattcM atttgtttWcaaStNatgtHcaaaDtaagBaKBtRgaBgDtSagtatMtaacYaatYtVc KatgtgcaacVaaaatactKcRgtaYtgtNgBBNcKtcttaccttKgaRaYcaNKtactt tgagSBtgtRagaNgcaaaNcacagtVtttHWatgttaNatBgtttaatNgVtctgaata tcaRtattcttttttttRaaKcRStctcggDgKagattaMaaaKtcaHacttaataataK taRgDtKVBttttcgtKaggHHcatgttagHggttNctcgtatKKagVagRaaaggaaBt NatttVKcRttaHctaHtcaaatgtaggHccaBataNaNaggttgcWaatctgatYcaaa HaatWtaVgaaBttagtaagaKKtaaaKtRHatMaDBtBctagcatWtatttgWttVaaa ScMNattRactttgtYtttaaaagtaagtMtaMaSttMBtatgaBtttaKtgaatgagYg tNNacMtcNRacMMHcttWtgtRtctttaacaacattattcYaMagBaacYttMatcttK cRMtgMNccattaRttNatHaHNaSaaHMacacaVaatacaKaSttHatattMtVatWga ttttttaYctttKttHgScWaacgHtttcaVaaMgaacagNatcgttaacaaaaagtaca HBNaattgttKtcttVttaaBtctgctacgBgcWtttcaggacacatMgacatcccagcg gMgaVKaBattgacttaatgacacacaaaaaatRKaaBctacgtRaDcgtagcVBaacDS BHaaaaSacatatacagacRNatcttNaaVtaaaataHattagtaaaaSWccgtatWatg gDttaactattgcccatcttHaSgYataBttBaactattBtcHtgatcaataSttaBtat KSHYttWggtcYtttBttaataccRgVatStaHaKagaatNtagRMNgtcttYaaSaact cagDSgagaaYtMttDtMRVgWKWtgMaKtKaDttttgactatacataatcNtatNaHat tVagacgYgatatatttttgtStWaaatctWaMgagaRttRatacgStgattcttaagaD taWccaaatRcagcagaaNKagtaaDggcgccBtYtagSBMtactaaataMataBSacRM gDgattMMgtcHtcaYDtRaDaacggttDaggcMtttatgttaNctaattaVacgaaMMt aatDccSgtattgaRtWWaccaccgagtactMcgVNgctDctaMScatagcgtcaactat acRacgHRttgctatttaatgaattataYKttgtaagWgtYttgcHgMtaMattWaWVta RgcttgYgttBHtYataSccStBtgtagMgtDtggcVaaSBaatagDttgBgtctttctc attttaNagtHKtaMWcYactVcgcgtatMVtttRacVagDaatcttgctBBcRDgcaac KttgatSKtYtagBMagaRtcgBattHcBWcaactgatttaatttWDccatttatcgagS KaWttataHactaHMttaatHtggaHtHagaatgtKtaaRactgtttMatacgatcaagD gatKaDctataMggtHDtggHacctttRtatcttYattttgacttgaaSaataaatYcgB aaaaccgNatVBttMacHaKaataagtatKgtcaagactcttaHttcggaattgttDtct aaccHttttWaaatgaaatataaaWattccYDtKtaaaacggtgaggWVtctattagtga ctattaagtMgtttaagcatttgSgaaatatccHaaggMaaaattttcWtatKctagDtY tMcctagagHcactttactatacaaacattaacttaHatcVMYattYgVgtMttaaRtga aataaDatcaHgtHHatKcDYaatcttMtNcgatYatgSaMaNtcttKcWataScKggta tcttacgcttWaaagNatgMgHtctttNtaacVtgttcMaaRatccggggactcMtttaY MtcWRgNctgNccKatcttgYDcMgattNYaRagatHaaHgKctcataRDttacatBatc cattgDWttatttaWgtcggagaaaaatacaatacSNtgggtttccttacSMaagBatta caMaNcactMttatgaRBacYcYtcaaaWtagctSaacttWgDMHgaggatgBVgcHaDt ggaactttggtcNatNgtaKaBcccaNtaagttBaacagtatacDYttcctNgWgcgSMc acatStctHatgRcNcgtacacaatRttMggaNKKggataaaSaYcMVcMgtaMaHtgat tYMatYcggtcttcctHtcDccgtgRatcattgcgccgatatMaaYaataaYSggatagc gcBtNtaaaScaKgttBgagVagttaKagagtatVaactaSacWactSaKatWccaKaaa atBKgaaKtDMattttgtaaatcRctMatcaaMagMttDgVatggMaaWgttcgaWatga aatttgRtYtattaWHKcRgctacatKttctaccaaHttRatctaYattaaWatVNccat NgagtcKttKataStRaatatattcctRWatDctVagttYDgSBaatYgttttgtVaatt taatagcagMatRaacttBctattgtMagagattaaactaMatVtHtaaatctRgaaaaa aaatttWacaacaYccYDSaattMatgaccKtaBKWBattgtcaagcHKaagttMMtaat ttcKcMagNaaKagattggMagaggtaatttYacatcWaaDgatMgKHacMacgcVaaca DtaDatatYggttBcgtatgWgaSatttgtagaHYRVacaRtctHaaRtatgaactaata tctSSBgggaaHMWtcaagatKgagtDaSatagttgattVRatNtctMtcSaagaSHaat aNataataRaaRgattctttaataaagWaRHcYgcatgtWRcttgaaggaMcaataBRaa ccagStaaacNtttcaatataYtaatatgHaDgcStcWttaacctaRgtYaRtataKtgM ttttatgactaaaatttacYatcccRWtttHRtattaaatgtttatatttgttYaatMca RcSVaaDatcgtaYMcatgtagacatgaaattgRtcaaYaaYtRBatKacttataccaNa aattVaBtctggacaagKaaYaaatatWtMtatcYaaVNtcgHaactBaagKcHgtctac aatWtaDtSgtaHcataHtactgataNctRgttMtDcDttatHtcgtacatcccaggStt aBgtcacacWtccNMcNatMVaVgtccDYStatMaccDatggYaRKaaagataRatttHK tSaaatDgataaacttaHgttgVBtcttVttHgDacgaKatgtatatNYataactctSat atatattgcHRRYttStggaactHgttttYtttaWtatMcttttctatctDtagVHYgMR BgtHttcctaatYRttKtaagatggaVRataKDctaMtKBNtMtHNtWtttYcVtattMc gRaacMcctNSctcatttaaagDcaHtYccSgatgcaatYaaaaDcttcgtaWtaattct cgttttScttggtaatctttYgtctaactKataHacctMctcttacHtKataacacagcN RatgKatttttSaaatRYcgDttaMRcgaaattactMtgcgtaagcgttatBtttttaat taagtNacatHgttcRgacKcBBtVgatKttcgaBaatactDRgtRtgaNacWtcacYtt aaKcgttctHaKttaNaMgWgWaggtctRgaKgWttSttBtDcNtgtttacaaatYcDRt gVtgcctattcNtctaaaDMNttttNtggctgagaVctDaacVtWccaagtaacacaNct gaScattccDHcVBatcgatgtMtaatBgHaatDctMYgagaatgYWKcctaatNaStHa aaKccgHgcgtYaaYtattgtStgtgcaaRtattaKatattagaWVtcaMtBagttatta gNaWHcVgcaattttDcMtgtaRHVYtHtctgtaaaaHVtMKacatcgNaatttMatatg ttgttactagWYtaRacgataKagYNKcattataNaRtgaacKaYgcaaYYacaNccHat MatDcNgtHttRaWttagaaDcaaaaaatagggtKDtStaDaRtaVtHWKNtgtattVct SVgRgataDaRaWataBgaagaaKtaataaYgDcaStaNgtaDaaggtattHaRaWMYaY aWtggttHYgagVtgtgcttttcaaDKcagVcgttagacNaaWtagtaataDttctggtt VcatcataaagtgKaaaNaMtaBBaattaatWaattgctHaVKaSgDaaVKaHtatatat HatcatSBagNgHtatcHYMHgttDgtaHtBttWatcgtttaRaattgStKgSKNWKatc agDtctcagatttctRtYtBatBgHHtKaWtgYBgacVVWaKtacKcDttKMaKaVcggt gttataagaataaHaatattagtataatMHgttYgaRttagtaRtcaaVatacggtcMcg agtaaRttacWgactKRYataaaagSattYaWgagatYagKagatgSaagKgttaatMgg tataatgttWYttatgagaaacctNVataatHcccKtDctcctaatactggctHggaSag gRtKHaWaattcgSatMatttagaggcYtctaMcgctcataSatatgRagacNaaDagga VBagaYttKtacNaKgtSYtagttggaWcatcWttaatctatgaVtcgtgtMtatcaYcg tRccaaYgDctgcMgtgtWgacWtgataacacgcgctBtgttaKtYDtatDcatcagKaV MctaatcttgVcaaRgcRMtDcgattaHttcaNatgaatMtactacVgtRgatggaWttt actaaKatgagSaaKggtaNtactVaYtaaKRagaacccacaMtaaMtKtatBcttgtaa WBtMctaataaVcDaaYtcRHBtcgttNtaaHatttBNgRStVDattBatVtaagttaYa tVattaagaBcacggtSgtVtatttaRattgatgtaHDKgcaatattKtggcctatgaWD KRYcggattgRctatNgatacaatMNttctgtcRBYRaaaHctNYattcHtaWcaattct BtMKtVgYataatMgYtcagcttMDataVtggRtKtgaatgccNcRttcaMtRgattaac attRcagcctHtWMtgtDRagaKaBtgDttYaaaaKatKgatctVaaYaacWcgcatagB VtaNtRtYRaggBaaBtgKgttacataagagcatgtRattccacttaccatRaaatgWgD aMHaYVgVtaSctatcgKaatatattaDgacccYagtgtaYNaaatKcagtBRgagtcca tgKgaaaccBgaagBtgSttWtacgatWHaYatcgatttRaaNRgcaNaKVacaNtDgat tgHVaatcDaagcgtatgcNttaDataatcSataaKcaataaHWataBtttatBtcaKtK tatagttaDgSaYctacaRatNtaWctSaatatttYaKaKtaccWtatcRagacttaYtt VcKgSDcgagaagatccHtaattctSttatggtKYgtMaHagVaBRatttctgtRgtcta tgggtaHKgtHacHtSYacgtacacHatacKaaBaVaccaDtatcSaataaHaagagaat ScagactataaRttagcaaVcaHataKgDacatWccccaagcaBgagWatctaYttgaaa tctVNcYtttWagHcgcgcDcVaaatgttKcHtNtcaatagtgtNRaactttttcaatgg WgBcgDtgVgtttctacMtaaataaaRggaaacWaHttaRtNtgctaaRRtVBctYtVta tDcattDtgaccYatagatYRKatNYKttNgcctagtaWtgaactaMVaacctgaStttc tgaKVtaaVaRKDttVtVctaDNtataaaDtccccaagtWtcgatcactDgYaBcatcct MtVtacDaaBtYtMaKNatNtcaNacgDatYcatcgcaRatWBgaacWttKttagYtaat tcggttgSWttttDWctttacYtatatWtcatDtMgtBttgRtVDggttaacYtacgtac atgaattgaaWcttMStaDgtatattgaDtcRBcattSgaaVBRgagccaaKtttcDgcg aSMtatgWattaKttWtgDBMaggBBttBaatWttRtgcNtHcgttttHtKtcWtagHSt aacagttgatatBtaWSaWggtaataaMttaKacDaatactcBttcaatatHttcBaaSa aatYggtaRtatNtHcaatcaHtagVtgtattataNggaMtcttHtNagctaaaggtaga YctMattNaMVNtcKtactBKcaHHcBttaSagaKacataYgctaKaYgttYcgacWVtt WtSagcaacatcccHaccKtcttaacgaKttcacKtNtacHtatatRtaaatacactaBt ttgaHaRttggttWtatYagcatYDatcggagagcWBataagRtacctataRKgtBgatg aDatataSttagBaHtaatNtaDWcWtgtaattacagKttcNtMagtattaNgtctcgtc ctcttBaHaKcKccgtRcaaYagSattaagtKataDatatatagtcDtaacaWHcaKttD gaaRcgtgYttgtcatatNtatttttatggccHtgDtYHtWgttatYaacaattcaWtat NgctcaaaSttRgctaatcaaatNatcgtttaBtNNVtgttataagcaaagattBacgtD atttNatttaaaDcBgtaSKgacgtagataatttcHMVNttgttBtDtgtaWKaaRMcKM tHtaVtagataWctccNNaSWtVaHatctcMgggDgtNHtDaDttatatVWttgttattt aacctttcacaaggaSaDcggttttttatatVtctgVtaacaStDVaKactaMtttaSNa gtgaaattaNacttSKctattcctctaSagKcaVttaagNaVcttaVaaRNaHaaHttat gtHttgtgatMccaggtaDcgaccgtWgtWMtttaHcRtattgScctatttKtaaccaag tYagaHgtWcHaatgccKNRtttagtMYSgaDatctgtgaWDtccMNcgHgcaaacNDaa aRaStDWtcaaaaHKtaNBctagBtgtattaactaattttVctagaatggcWSatMaccc ttHttaSgSgtgMRcatRVKtatctgaaaccDNatYgaaVHNgatMgHRtacttaaaRta tStRtDtatDttYatattHggaBcttHgcgattgaKcKtttcRataMtcgaVttWacatN catacctRataDDatVaWNcggttgaHtgtMacVtttaBHtgagVttMaataattatgtt cttagtttgtgcDtSatttgBtcaacHattaaBagVWcgcaSYttMgcttacYKtVtatc aYaKctgBatgcgggcYcaaaaacgNtctagKBtattatctttKtaVttatagtaYtRag NtaYataaVtgaatatcHgcaaRataHtacacatgtaNtgtcgYatWMatttgaactacR ctaWtWtatacaatctBatatgYtaagtatgtgtatSttactVatcttYtaBcKgRaSgg RaaaaatgcagtaaaWgtaRgcgataatcBaataccgtatttttccatcNHtatWYgatH SaaaDHttgctgtccHtggggcctaataatttttctatattYWtcattBtgBRcVttaVM RSgctaatMagtYtttaaaaatBRtcBttcaaVtaacagctccSaaSttKNtHtKYcagc agaaaccccRtttttaaDcDtaStatccaagcgctHtatcttaDRYgatDHtWcaaaBcW gKWHttHataagHacgMNKttMKHccaYcatMVaacgttaKgYcaVaaBtacgcaacttt MctaaHaatgtBatgagaSatgtatgSRgHgWaVWgataaatatttccKagVgataattW aHNcYggaaatgctHtKtaDtctaaagtMaatVDVactWtSaaWaaMtaHtaSKtcBRaN cttStggtBttacNagcatagRgtKtgcgaacaacBcgKaatgataagatgaaaattgta ctgcgggtccHHWHaaNacaBttNKtKtcaaBatatgctaHNgtKcDWgtttatNgVDHg accaacWctKaaggHttgaRgYaatHcaBacaatgagcaaattactgtaVaaYaDtagat tgagNKggtggtgKtWKaatacagDRtatRaMRtgattDggtcaaYRtatttNtagaDtc acaaSDctDtataatcgtactaHttatacaatYaacaaHttHatHtgcgatRRttNgcat SVtacWWgaaggagtatVMaVaaattScDDKNcaYBYaDatHgtctatBagcaacaagaa tgagaaRcataaKNaRtBDatcaaacgcattttttaaBtcSgtacaRggatgtMNaattg gatatWtgagtattaaaVctgcaYMtatgatttttYgaHtgtcttaagWBttHttgtctt attDtcgtatWtataataSgctaHagcDVcNtaatcaagtaBDaWaDgtttagYctaNcc DtaKtaHcttaataacccaRKtacaVaatNgcWRaMgaattatgaBaaagattVYaHMDc aDHtcRcgYtcttaaaWaaaVKgatacRtttRRKYgaatacaWVacVcRtatMacaBtac tggMataaattttHggNagSctacHgtBagcgtcgtgattNtttgatSaaggMttctttc ttNtYNagBtaaacaaatttMgaccttacataattgYtcgacBtVMctgStgMDtagtaR ctHtatgttcatatVRNWataDKatWcgaaaaagttaaaagcacgHNacgtaatctttMR tgacttttDacctataaacgaaatatgattagaactccSYtaBctttaataacWgaaaYa tagatgWttcatKtNgatttttcaagHtaYgaaRaDaagtaggagcttatVtagtctttc attaaaatcgKtattaRttacagVaDatgcatVgattgggtctttHVtagKaaRBtaHta aggccccaaaaKatggtttaMWgtBtaaacttcactttKHtcgatctccctaYaBacMgt cttBaBaNgcgaaacaatctagtHccHtKttcRtRVttccVctttcatacYagMVtMcag aMaaacaataBctgYtaatRaaagattaaccatVRatHtaRagcgcaBcgDttStttttc VtttaDtKgcaaWaaaaatSccMcVatgtKgtaKgcgatatgtagtSaaaDttatacaaa catYaRRcVRHctKtcgacKttaaVctaDaatgttMggRcWaacttttHaDaKaDaBctg taggcgtttaHBccatccattcNHtDaYtaataMttacggctNVaacDattgatatttta cVttSaattacaaRtataNDgacVtgaacataVRttttaDtcaaacataYDBtttaatBa DtttYDaDaMccMttNBttatatgagaaMgaNtattHccNataattcaHagtgaaggDga tgtatatatgYatgaStcataaBStWacgtcccataRMaaDattggttaaattcMKtctM acaBSactcggaatDDgatDgcWctaacaccgggaVcacWKVacggtaNatatacctMta tgatagtgcaKagggVaDtgtaacttggagtcKatatcgMcttRaMagcattaBRaStct YSggaHYtacaactMBaagDcaBDRaaacMYacaHaattagcattaaaHgcgctaaggSc cKtgaaKtNaBtatDDcKBSaVtgatVYaagVtctSgMctacgttaacWaaattctSgtD actaaStaaattgcagBBRVctaatatacctNttMcRggctttMttagacRaHcaBaacV KgaataHttttMgYgattcYaNRgttMgcVaaacaVVcDHaatttgKtMYgtatBtVVct WgVtatHtacaaHttcacgatagcagtaaNattBatatatttcVgaDagcggttMaagtc ScHagaaatgcYNggcgtttttMtStggtRatctacttaaatVVtBacttHNttttaRca aatcacagHgagagtMgatcSWaNRacagDtatactaaDKaSRtgattctccatSaaRtt aaYctacacNtaRtaactggatgaccYtacactttaattaattgattYgttcagDtNKtt agDttaaaaaaaBtttaaNaYWKMBaaaacVcBMtatWtgBatatgaacVtattMtYatM NYDKNcKgDttDaVtaaaatgggatttctgtaaatWtctcWgtVVagtcgRgacttcccc taDcacagcRcagagtgtWSatgtacatgttaaSttgtaaHcgatgggMagtgaacttat RtttaVcaccaWaMgtactaatSSaHtcMgaaYtatcgaaggYgggcgtgaNDtgttMNg aNDMtaattcgVttttaacatgVatgtWVMatatcaKgaaattcaBcctccWcttgaaWH tWgHtcgNWgaRgctcBgSgaattgcaaHtgattgtgNagtDttHHgBttaaWcaaWagc aSaHHtaaaVctRaaMagtaDaatHtDMtcVaWMtagSagcttHSattaacaaagtRacM tRtctgttagcMtcaBatVKtKtKacgagaSNatSactgtatatcBctgagVtYactgta aattaaaggcYgDHgtaacatSRDatMMccHatKgttaacgactKtgKagtcttcaaHRV tccttKgtSataatttacaactggatDNgaacttcaRtVaagDcaWatcBctctHYatHa DaaatttagYatSatccaWtttagaaatVaacBatHcatcgtacaatatcgcNYRcaata YaRaYtgattVttgaatgaVaactcRcaNStgtgtattMtgaggtNttBaDRcgaaaagc tNgBcWaWgtSaDcVtgVaatMKBtttcgtttctaaHctaaagYactgMtatBDtcStga ccgtSDattYaataHctgggaYYttcggttaWaatctggtRagWMaDagtaacBccacta cgHWMKaatgatWatcctgHcaBaSctVtcMtgtDttacctaVgatYcWaDRaaaaRtag atcgaMagtggaRaWctctgMgcWttaagKBRtaaDaaWtctgtaagYMttactaHtaat cttcataacggcacBtSgcgttNHtgtHccatgttttaaagtatcgaKtMttVcataYBB aKtaMVaVgtattNDSataHcagtWMtaggtaSaaKgttgBtVtttgttatcatKcgHac acRtctHatNVagSBgatgHtgaRaSgttRcctaacaaattDNttgacctaaYtBgaaaa tagttattactcttttgatgtNNtVtgtatMgtcttRttcatttgatgacacttcHSaaa ccaWWDtWagtaRDDVNacVaRatgttBccttaatHtgtaaacStcVNtcacaSRttcYa gacagaMMttttgMcNttBcgWBtactgVtaRttctccaaYHBtaaagaBattaYacgat ttacatctgtaaMKaRYtttttactaaVatWgctBtttDVttctggcDaHaggDaagtcg aWcaagtagtWttHtgKtVataStccaMcWcaagataagatcactctHatgtcYgaKcat cagatactaagNSStHcctRRNtattgtccttagttagMVgtatagactaactctVcaat MctgtttgtgttgccttatWgtaBVtttctggMcaaKgDWtcgtaaYStgSactatttHg atctgKagtagBtVacRaagRtMctatgggcaaaKaaaatacttcHctaRtgtDcttDat taggaaatttcYHaRaaBttaatggcacKtgctHVcaDcaaaVDaaaVcgMttgtNagcg taDWgtcgttaatDgKgagcSatatcSHtagtagttggtgtHaWtaHKtatagctgtVga ttaBVaatgaataagtaatVatSttaHctttKtttgtagttaccttaatcgtagtcctgB cgactatttVcMacHaaaggaatgDatggKtaHtgStatattaaSagctWcctccRtata BaDYcgttgcNaagaggatRaaaYtaWgNtSMcaatttactaacatttaaWttHtatBat tgtcgacaatNgattgcNgtMaaaKaBDattHacttggtRtttaYaacgVactBtaBaKt gBttatgVttgtVttcaatcWcNctDBaaBgaDHacBttattNtgtDtatttVSaaacag gatgcRatSgtaSaNtgBatagttcHBgcBBaaattaHgtDattatDaKaatBaaYaaMa ataaataKtttYtagtBgMatNcatgtttgaNagtgttgtgKaNaSagtttgaSMaYBca aaacDStagttVacaaaaactaaWttBaagtctgtgcgtMgtaattctcctacctcaNtt taaccaaaaVtBcacataacaccccBcWMtatVtggaatgaWtcaaWaaaaaaaaWtDta atatRcctDWtcctaccMtVVatKttaWaaKaaatataaagScHBagaggBaSMtaWaVt atattactSaaaKNaactatNatccttgaYctattcaaaVgatttYHcRagattttaSat aggttattcVtaaagaKgtattattKtRttNcggcRgtgtgtWYtaacHgKatKgatYta cYagDtWcHBDctctgRaYKaYagcactKcacSaRtBttttBHKcMtNtcBatttatttt tgSatVgaaagaWtcDtagDatatgMacaacRgatatatgtttgtKtNRaatatNatgYc aHtgHataacKtgagtagtaacYttaNccaaatHcacaacaVDtagtaYtccagcattNt acKtBtactaaagaBatVtKaaHBctgStgtBgtatgaSNtgDataaccctgtagcaBgt gatcttaDataStgaMaccaSBBgWagtacKcgattgaDgNNaaaacacagtSatBacKD gcgtataBKcatacactaSaatYtYcDaactHttcatRtttaatcaattataRtttgtaa gMcgNttcatcBtYBagtNWNMtSHcattcRctttttRWgaKacKttgggagBcgttcgc MaWHtaatactgtctctatttataVgtttaBScttttaBMaNaatMacactYtBMggtHa cMagtaRtctgcatttaHtcaaaatttgagKtgNtactBacaHtcgtatttctMaSRagc agttaatgtNtaaattgagagWcKtaNttagVtacgatttgaatttcgRtgtWcVatcgt taaDVctgtttBWgaccagaaagtcSgtVtatagaBccttttcctaaattgHtatcggRa ttttcaaggcYSKaagWaWtRactaaaacccBatMtttBaatYtaagaactSttcgaaSc aatagtattgaccaagtgttttctaacatgtttNVaatcaaagagaaaNattaaRtttta VaaaccgcaggNMtatattVctcaagaggaacgBgtttaacaagttcKcYaatatactaa ccBaaaSggttcNtattctagttRtBacgScVctcaatttaatYtaaaaaaatgSaatga tagaMBRatgRcMcgttgaWHtcaVYgaatYtaatctttYttatRaWtctgBtDcgatNa tcKaBaDgatgtaNatWKctccgatattaacattNaaacDatgBgttctgtDtaaaMggt gaBaSHataacgccSctaBtttaRBtcNHcDatcDcctagagtcRtaBgWttDRVHagat tYatgtatcWtaHtttYcattWtaaagtctNgtStggRNcgcggagSSaaagaaaatYcH DtcgctttaatgYcKBVSgtattRaYBaDaaatBgtatgaHtaaRaRgcaSWNtagatHa acttNctBtcaccatctMcatattccaSatttgcgaDagDgtatYtaaaVDtaagtttWV aagtagYatRttaagDcNgacKBcScagHtattatcDaDactaaaaaYgHttBcgaDttg gataaaKSRcBMaBcgaBSttcWtgNBatRaccgattcatttataacggHVtaattcaca agagVttaaRaatVVRKcgWtVgacctgDgYaaHaWtctttcacMagggatVgactagMa aataKaaNWagKatagNaaWtaaaatttgaattttatttgctaaVgaHatBatcaaBWcB gttcMatcgBaaNgttcgSNaggSaRtttgHtRtattaNttcDcatSaVttttcgaaaaa ttgHatctaRaggSaNatMDaaatDcacgattttagaHgHaWtYgattaatHNSttatMS gggNtcKtYatRggtttgtMWVtttaYtagcagBagHaYagttatatggtBacYcattaR SataBatMtttaaatctHcaaaSaaaagttNSaaWcWRccRtKaagtBWtcaaattSttM tattggaaaccttaacgttBtWatttatatWcDaatagattcctScacctaagggRaaYt aNaatgVtBcttaaBaacaMVaaattatStYgRcctgtactatcMcVKatttcgSgatRH MaaaHtagtaaHtVgcaaataatatcgKKtgccaatBNgaaWcVttgagttaKatagttc aggKDatDtattgaKaVcaKtaataDataataHSaHcattagttaatRVYcNaHtaRcaa ggtNHcgtcaaccaBaaagYtHWaaaRcKgaYaaDttgcWYtataRgaatatgtYtgcKt aNttWacatYHctRaDtYtattcBttttatcSataYaYgttWaRagcacHMgtttHtYtt YaatcggtatStttcgtRSattaaDaKMaatatactaNBaWgctacacYtgaYVgtgHta aaRaaRgHtagtWattataaaSDaaWtgMattatcgaaaagtaYRSaWtSgNtBgagcRY aMDtactaacttaWgtatctagacaagNtattHggataatYttYatcataDcgHgttBtt ctttVttgccgaaWtaaaacgKgtatctaaaaaNtccDtaDatBMaMggaatNKtatBaa atVtccRaHtaSacataHattgtttKVYattcataVaattWtcgtgMttcttKtgtctaa cVtatctatatBRataactcgKatStatattcatHHRttKtccaacgtgggtgRgtgaMt attattggctatcgtgacMtRcBDtcttgtactaatRHttttaagatcgVMDStattatY BtttDttgtBtNttgRcMtYtgBacHaWaBaatDKctaagtgaaactaatgRaaKgatcc aagNaaaatattaggWNtaagtatacttttKcgtcggSYtcttgRctataYcttatataa agtatattaatttataVaacacaDHatctatttttKYVatHRactttaBHccaWagtact BtcacgaVgcgttRtttttttSVgtSagtBaaattctgaHgactcttgMcattttagVta agaattHctHtcaDaaNtaacRggWatagttcgtSttgaDatcNgNagctagDgatcNtt KgttgtaDtctttRaaYStRatDtgMggactSttaDtagSaVtBDttgtDgccatcacaM attaaaMtNacaVcgSWcVaaDatcaHaatgaattaMtatccVtctBtaattgtWattat BRcWcaatgNNtactWYtDaKttaaatcactcagtRaaRgatggtKgcgccaaHgaggat StattYcaNMtcaBttacttatgagDaNtaMgaaWtgtttcttctaHtMNgttatctaWW atMtBtaaatagDVatgtBYtatcggcttaagacMRtaHScgatatYgRDtcattatSDa HggaaataNgaWSRRaaaBaatagBattaDctttgHWNttacaataaaaaaatacggttt gHgVtaHtWMttNtBtctagtMcgKMgHgYtataHaNagWtcaacYattaataYRgtaWK gaBctataaccgatttaHaNBRaRaMtccggtNgacMtctcatttgcaattcWgMactta caaDaaNtactWatVtttagccttMaatcagVaagtctVaaDaBtattaattaYtNaYtg gattaKtaKctYaMtattYgatattataatKtVgDcttatatNBtcgttgtStttttMag aggttaHYSttcKgtcKtDNtataagttataagSgttatDtRttattgttttSNggRtca aKMNatgaatattgtBWtaMacctgggYgaSgaagYataagattacgagaatBtggtRcV HtgYggaDgaYaKagWagctatagacgaaHgtWaNgacttHRatVaWacKYtgRVNgVcS gRWctacatcKSactctgWYtBggtataagcttNRttVtgRcaWaaatDMatYattaact ttcgaagRatSctgccttgcRKaccHtttSNVagtagHagBagttagaccaRtataBcca taatSHatRtcHagacBWatagcaMtacaRtgtgaaBatctKRtScttccaNaatcNgta atatWtcaMgactctBtWtaaNactHaaaaRctcgcatggctMcaaNtcagaaaaacaca gtggggWttRttagtaagaVctVMtcgaatcttcMaaaHcaHBttcgattatgtcaDagc YRtBtYcgacMgtDcagcgaNgttaataatagcagKYYtcgtaBtYctMaRtaRtDagaa aacacatgYaBttgattattcgaaNttBctSataaMataWRgaHtttccgtDgaYtatgg tDgHKgMtatttVtMtVagttaRatMattRagataaccctKctMtSttgaHagtcStcta tttccSagatgttccacgaggYNttHRacgattcDatatDcataaaatBBttatcgaHtN HaaatatDNaggctgaNcaaggagttBttMgRagVatBcRtaWgatgBtSgaKtcgHttt gaatcaaDaHttcSBgHcagtVaaSttDcagccgttNBtgttHagYtattctttRWaaVt SttcatatKaaRaaaNacaVtVctMtSDtDtRHRcgtaatgctcttaaatSacacaatcg HattcaWcttaaaatHaaatcNctWttaNMcMtaKctVtcctaagYgatgatcYaaaRac tctaRDaYagtaacgtDgaggaaatctcaaacatcaScttcKttNtaccatNtaNataca tttHaaDHgcaDatMWaaBttcRggctMaagctVYcacgatcaDttatYtaatcKatWat caatVYtNagatttgattgaYttttYgacttVtcKaRagaaaHVgDtaMatKYagagttN atWttaccNtYtcDWgSatgaRgtMatgKtcgacaagWtacttaagtcgKtgatccttNc ttatagMatHVggtagcgHctatagccctYttggtaattKNaacgaaYatatVctaataM aaaYtgVtcKaYtaataacagaatHcacVagatYWHttagaaSMaatWtYtgtaaagNaa acaVgaWtcacNWgataNttcaSagctMDaRttgNactaccgataMaaatgtttattDtc aagacgctDHYYatggttcaagccNctccttcMctttagacBtaaWtaWVHggaaaaNat ttaDtDtgctaaHHtMtatNtMtagtcatttgcaaaRatacagRHtatDNtgtDgaatVg tVNtcaaatYBMaaaagcaKgtgatgatMgWWMaHttttMgMagatDtataaattaacca actMtacataaattgRataatacgBtKtaataattRgtatDagDtcRDacctatRcagag cSHatNtcaScNtttggacNtaaggaccgtgKNttgttNcttgaaRgYgRtNtcagttBc ttttcHtKtgcttYaaNgYagtaaatgaatggWaMattBHtatctatSgtcYtgcHtaat tHgaaMtHcagaaSatggtatgccaHBtYtcNattWtgtNgctttaggtttgtWatNtgH tgcDttactttttttgcNtactKtWRaVcttcatagtgSNKaNccgaataaBttataata YtSagctttaaatSttggctaaKSaatRccgWHgagDttaaatcatgagMtcgagtVtaD ggaBtatttgDacataaacgtagYRagBWtgDStKDgatgaagttcattatttaKWcata aatWRgatataRgttRacaaNKttNtKagaaYaStaactScattattaacgatttaaatg DtaattagatHgaYataaactatggggatVHtgccgtNgatNYcaStRtagaccacWcaM tatRagHgVactYtWHtcttcatgatWgagaKggagtatgaWtDtVtNaNtcgYYgtaaa ctttaDtBactagtaDctatagtaatatttatatataacgHaaaRagKattSagttYtSt >THREE Homo sapiens frequency agagagacgatgaaaattaatcgtcaatacgctggcgaacactgagggggacccaatgct cttctcggtctaaaaaggaatgtgtcagaaattggtcagttcaaaagtagaccggatctt tgcggagaacaattcacggaacgtagcgttgggaaatatcctttctaccacacatcggat tttcgccctctcccattatttattgtgttctcacatagaattattgtttagacatccctc gttgtatggagagttgcccgagcgtaaaggcataatccatataccgccgggtgagtgacc tgaaattgtttttagttgggatttcgctatggattagcttacacgaagagattctaatgg tactataggataattataatgctgcgtggcgcagtacaccgttacaaacgtcgttcgcat atgtggctaacacggtgaaaatacctacatcgtatttgcaatttcggtcgtttcatagag cgcattgaattactcaaaaattatatatgttgattatttgattagactgcgtggaaagaa ggggtactcaagccatttgtaaaagctgcatctcgcttaagtttgagagcttacattagt ctatttcagtcttctaggaaatgtctgtgtgagtggttgtcgtccataggtcactggcat atgcgattcatgacatgctaaactaagaaagtagattactattaccggcatgcctaatgc gattgcactgctatgaaggtgcggacgtcgcgcccatgtagccctgataataccaatact tacatttggtcagcaattctgacattatacctagcacccataaatttactcagacttgag gacaggctcttggagtcgatcttctgtttgtatgcatgtgatcatatagatgaataagcg atgcgactagttagggcatagtatagatctgtgtatacagttcagctgaacgtccgcgag tggaagtacagctgagatctatcctaaaatgcaaccatatcgttcacacatgatatgaac ccagggggaaacattgagttcagttaaattggcagcgaatcccccaagaagaaggcggag tgacgttgaacgggcttatggtttttcagtacttcctccgtataagttgagcgaaatgta aacagaataatcgttgtgttaacaacattaaaatcgcggaatatgatgagaatacacagt gtgagcatttcacttgtaaaatatctttggtagaacttactttgctttaaatatgttaaa ccgatctaataatctacaaaacggtagattttgcctagcacattgcgtccttctctattc agatagaggcaatactcagaaggttttatccaaagcactgtgttgactaacctaagtttt agtctaataatcatgattgattataggtgccgtggactacatgactcgtccacaaataat acttagcagatcagcaattggccaagcacccgacttttatttaatggttgtgcaatagtc cagattcgtattcgggactctttcaaataatagtttcctggcatctaagtaagaaaagct cataaggaagcgatattatgacacgctcttccgccgctgttttgaaacttgagtattgct cgtccgaaattgagggtcacttcaaaatttactgagaagacgaagatcgactaaagttaa aatgctagtccacagttggtcaagttgaattcatccacgagttatatagctattttaatt tatagtcgagtgtacaaaaaacatccacaataagatttatcttagaataacaacccccgt atcatcgaaatcctccgttatggcctgactcctcgagcttatagcatttgtgctggcgct cttgccaggaacttgctcgcgaggtggtgacgagtgagatgatcagtttcattatgatga tacgattttatcgcgactagttaatcatcatagcaagtaaaatttgaattatgtcattat catgctccattaacaggttatttaattgatactgacgaaattttttcacaatgggttttc tagaatttaatatcagtaattgaagccttcataggggtcctactagtatcctacacgacg caggtccgcagtatcctggagggacgtgttactgattaaaagggtcaaaggaatgaaggc tcacaatgttacctgcttcaccatagtgagccgatgagttttacattagtactaaatccc aaatcatactttacgatgaggcttgctagcgctaaagagaatacatacaccaccacatag aattgttagcgatgatatcaaatagactcctggaagtgtcagggggaaactgttcaatat ttcgtccacaggactgaccaggcatggaaaagactgacgttggaaactataccatctcac gcccgacgcttcactaattgatgatccaaaaaatatagcccggattcctgattagcaaag ggttcacagagaaagatattatcgacgtatatcccaaaaaacagacgtaatgtgcatctt cgaatcgggatgaatacttgtatcataaaaatgtgacctctagtatacaggttaatgtta gtgatacacaatactcgtgggccatgggttctcaaataaaatgtaatattgcgtcgatca ctcacccacgtatttggtctaattatgttttatttagtgacaatccaatagataaccggt cctattaagggctatatttttagcgaccacgcgtttaaacaaaggattgtatgtagatgg taccagtttaattgccagtgggcaatcctaagcaaaatgagattctatcctaaagtttgg gcttgatataagatttcggatgtatgggttttataatcgttggagagctcaatcatgagc taatacatggatttcgctacctcaccgagagaccttgcatgaagaattctaaccaaaagt ttaataggccggattggattgagttaattaagaccttgttcagtcatagtaaaaaccctt aaattttaccgattgacaaagtgagcagtcgcaataccctatgcgaaacgcctcgatagt gactaggtatacaaggtttttgagttcctttgaaatagttaactaatttaaaattaatta acgacatggaaatcacagaacctaatgctttgtaggagttatttatgctgtttactgcct ctacaaccctaataaagcagtcctaagaatgaaacgcatcttttagttcagaaagtggta tccagggtggtcaatttaataaattcaacatcgggtctcaggatattcggtcatataatt tattaagggctcttcgagtcttactctgagtgaaattggaaacagtcatccttttcgttg tgaggcatcttacaccgctatcgatatacaatgcattccaccgcggtgtcccgtacacaa ggaaacttgttaccttggggatataagaaaactcacacgtctcattattaaactgagtac aatttttgcacgagaaagtaatgcaatacaatatgatgaaagccagctaatgaaaaggga tggaacgcacctcggatctgttgcactggattaaaatccgattatttttaaaaatattca gtgctagagcatatcaggtctacttttttatctggtatgtaaagcccacggagcgatagt gagatccttacgactcaacgaaaagttataacataactcccgttagccaaagcccaatcc cgattactgccctaccctaacgtctgccatctaaatatcgaacttgttatgatcaatgtg actacctcccaccctttccccttcatttgttccactggggataagctagcgttttcagaa tcaatgcaataagaatagccaattgtctcacttcatcagagctcttggcaattccaggcg ctacgtggttctggaatatattcatttttcaaatagtaatacgtttagtgttgctattgt ctacacgtttggatattacgttatgtgagcggacatcaatagttgtctaactctttagta agccagagatagcactcttagcgaatggataccatcttccataagtttagttaatagtcc gaaacaactgcttcgagcatatttgaacctccttgtaggcaaatagcctcttcaaagcaa tcttactaatagatagagtttgttttaagggactactagaaatgggacaatcttaatagt atgacctaaactgacatttaaagatatatccaggtggcaagcataaagatcattgcgcca cctccaccgtgggattacttatcagtcgatatcctatatgctaagtttgcgacggcagaa tacaaactaagctgagttgatgctaaccttacctatgataccccattggaccggttaaca gccctacttattccaaataaaagaacttttatgctgtagaagctattatagtgatgcctg gtaacttcagtatattaaaatgacacacatacgccatatagagctcctggaactttgaat aatgagcgaacttcgaagttgaagagcaagaaaccatatgtcacggttgcctaaagcccg gtaaccagacatgtgctatcattgatcattatcgaggttttcataaccttgacccattat cggctgtgcgcggacaagtacttaaatcactagtttcttcacctgcttatcggtaagaaa taaggttggcaaagaatcgcataagacggacgtagagccgcagcgttgtgcgagtccagg tgcatgcgcagcaataggattttaaattttgttccatttttaatttagccgtaaggatgt ccgtaaatgattgaaaattggattcaatctttgggcctatgctactggaacctgatcgac aaaatttcaaacatacgttaactccgaaagaccgtatttttgcggctagaatagtcagtc gcttggagccatataccttaccacttaaacgacgtgctcctgtagttgaaatataaacag aacacaaagactaccgatcatatcaactgaagatctttgtaactttgaggcgaagcaccc tcttcgagacaactaagagtaaagtaccgggcgccgcaaggagtcgattgggaccctaaa tcttgacgaattgctaagaggctcagagctaccactgtaatttctctagagcccataata aatgaacgatacatccgtaggtagcacctaagggattataatggaagccaaatgcagtta ataatattatatactggcgtacacgattcgacggatctctcacatagtgattcacgaccc ccccctttgattgacacagcgtcagcattttgcaagaacgatcttctgcatagggtgcgc caccgtaaggatgacgtcgaagctacaactgggtataatttaccatgcttccctgatgct gagtgcaatacactaagaatgagtttttaccccatatcaccagtatttgttctgttattg cgaagaaatggctatgctgagttggcgactaaagtcacccatcctttttattaggtaacc ccctcccttaaactaactgatttgctggagctgccctgcatacatatactttatcattta tggacgtccgtgacgcttattatccaccatagtcgatatgctacacggattcattaatgg atcgtaggagtttaagttatatttactaagatcggtctcggctactatcccgccttaccc ggcgctatttacggccatttttaatatattgacggtaattattcctatggtttcgaccgc acgtccttggacaagaaagaatggcaaaaaaaatgtaaaagaaaaaaaatattgagtccc taccatcatataaaaaatatgtgatgagtaacttgacgaaatgttagtggttattaaaga ctatctattacaccttttgttttctgtcgtagtatattaaagtctagaagccttacagga aaatcagggttatacagccgatactccgcagcatgaatcatcgaggaggtgtcctaccat cgcgccttgtaatcttgtctgtgtatactgtatttagaccttttatacaaagtaaatatc tcggctttatgtgattgggaggggcctactcaaacatgatgacttgacctaataatcact gtgcgggcgtcttatgactagctattccttgaaatccaccaccaaatggttaatatgtaa aaactttgacgatgaaacaaggtgaatgtgtagttactttgtgtaattagctgcgtcgag cattgcttgtaaaaccgtcaatcgcacacgttacttccataaaatttctacgaatacacc cttcttaaaaaaaacgtaggaattcacgagtttaacaaacgataactgtataaagtggaa gtccgaagaaagcagatgcccgaactactcgaagatgtttcgttttcttaaccatagggg cttcttaatggcccactacgcacattttgttcaagcccgagagggacatccccattacgg gagtattactaaaactgttccgtaatacgttcagcaagggatgaaaaaggccactgctca agttattgacgtgggagtattacatcggaagcctgaatcccacactatgatggtctgtac aggcctagggactgcgtctagacggtattaccggcttctaatcatacgatcgtgagtctt aacgggaagtaaggctcacacctaccccaaaccatttatctatgtaagtataaaattgtg cgtaagtgttcaaagtggacaataaagacgtggcaaaaacccccgcacataagccgcttt agatttcacaaataccaatgcggttaaaaacatccttgagtcgtacatacaccatactcg cgttaaacggatataacagaagataataaatccggatgtggagtcggtgtaactatagaa agccaagtgaaataatgcttaccagtcatttagctatacggctttcatttcatgtcaaga gggtggagtttgacctgtacagttgatatatcaccgatacttagaactcacctaaagcta aaattgctcgcagcgtgtaatccgcatattacaaacaatagatgggattcattatacata agacacgatgatctgctttttcaggttgcgagatgttgcctatcgtcaatcgagtcctgc cttacaccacttaaacaaaagtattgacagggaacctattttcgaggtattatatagtcc agcttgaatatcaatttgacagttaacctagtgaaaatcagtaagaggaaatacgccaca ttctccagtgaaattctacgggttatcgtctagtccaactatcaattataactcacgaga tataagtaaattctcgtacttggcctgatttttattatactttggatccttagtaaacag gaagggagaaaccttcaacgaaaaacactggattttgttttactctcaaagctcttatat gacggaaataccctgtcaagtcttaactttattactagactaatgaaatgggcttggggt ggccagaatcatagtacaatttagcggatacactattcggactttcctatcggctgtctg gttggataagtatggggactaataggctagacatacctatacttaaactatacaggcgtc atctatctctgcaactttggagttccctgatgttctcccgccctttgggttcacatcttc tataccgacacccctaataacgattagtttgtgggttagagtaaattaatacggttaata ttaatgtatcgttgaaaagctggtgtcgccaataaggtaaccggctaggcagagtatatg tcacgaagtataactaccctaatgataagctgtaggaataaaattaatgctgtctctaag cgaagagatatttccgactctgttttaatgacgaatctcattacttctgacttgcaaatg ttcaatatggcacggtttcacggcacctttgtgacgcatataatgaacttagaagattat aacgacggaactttatatgataatccgttacgattaaagaatctgttaaatatcataatg gcattcagttctagaccgtgcatcatggtaaacttactttctctgcatggcgacatacat ttcgctattcaaattcgcgtgtggttacacccactcgcacctttggaatattaagagaag atgatcagaaaatccattcgctcaatttttctgacgtacgtctaatttatcctaggagac aaatcgttttatgtctctcacatttttgaagaaaggttcgagagacaatactcaggtcct gaactgctagaagatactcggtggagcgtggcaacaatgaaaaactcgtgacataaatga atgatacttttccaagttcagttaagtgaatatgtttaacatacccggcttttcgatctt aagctgacgctggacgtgcgagtaatgtcagtctcttacatacactagtgactccaagtt tcgtcaaaaacgccccctcccttctcgagcccactcacgctatgtattgacgcgaacttg ttcgggatcagacttttcaggagttcggtcgcgtgtccctatgtgctaatatataagtta gatcgcattagatgctaatctgaatacttatagacgaccttcaacgagaacgggtaccac cttgaggctagagttaggtgtgaaacgacaggtagggacatataaaatttgagtgcggct ttagttaagggtttaattacctactcaaacatcacgctcgcgcccttcgtacgtaatcga ccatctagaggctaaggggactgtactaggtagtgattaatgatatcctagacgcacgtg ccttagatcttcagactctgatggtccgcgatcaccgtaattgtagtcctccaactcgat cactttgttggcgtcaaagaaattacgatatctaaatacttataatacaataaccaagga tgagaatgactcatcgcgttggagttatattgcttgaagttctatggaatgaaagcacgt tatctgccgtcccaatatctccagtgagctaattcattggacggtccactttgatcaatc cccgaggagatgttcggacactttagtctgtaacacttagcgttgagaccacgaacaatt gattactcagtcttgaaggtgttttccaaagttcattttaaataagactacgataggcct ttcctattgatataaactacccggctctgttgttcgtgtgagtcgtacttctctgtgttt ttctgattatagcaagattcgattcttagtgtaaacagcgatttttatttgacccgtcaa tgagaagcgcataggatctaagcaaaattatcaagttgtgccacaaggtaagatctttcc agttattgcaggtaggatgtatcccacgttgatagtatgaggtctgacgtcaactgtcta ggagagttgaccgcgtgcgggtacaccggatttgcatcgatgttgagaacgcagaactcc cactgtcgtggcggcgttcctgatatttagcaagaggcgttgataaagccctcatcatct agatctcgacctcatctgccctcttgctccatcattttctacacagactactttcctatc tacgttagtataattgctttctatcttagtatcatttagagcttctccgtcaacaggttc gtgctattaaagttagtacgaaagggacaacttgtagcaacgcatttaatcggttttcga ctacttcgcacaaaatcagataaagaagtttgtcattctattagacattgaattgcgcaa ttgacttgtaccacttatgatcgaacactgaatcaagactgtgattaactaaaatagaca agccactatatcaactaataaaaacgcccctggtggtcgaacatagttgactacaggata attaattggactggagccattacattctctacaatcgtatcacttcccaagtagacaact ttgaccttgtagtttcatgtacaaaaaaatgctttcgcaggagcacattggtagttcaat agtttcatgggaacctcttgagccgtcttctgtgggtgtgttcggatagtaggtactgat aaagtcgtgtcgctttcgatgagagggaattcaccggaaaacaccttggttaacaggata gtctatgtaaacttcgagacatgtttaagagttaccagcttaatccacggtgctctacta gtatcatcagctgtcttgcctcgcctagaaatatgcattctatcgttatcctatcaacgg ttgccgtactgagcagccttattgtggaagagtaatatataaatgtagtcttgtctttac gaagcagacgtaagtaataatgacttggaataccaaaactaaacatagtggattatcata ctcaagaactctccagataaataacagtttttacgatacgtcaccaatgagcttaaagat taggatcctcaaaactgatacaaacgctaattcatttgttattggatccagtatcagtta aactgaatggagtgaagattgtagaatgttgttctggcctcgcatggggtctaggtgata tacaatttctcatacttacacggtagtggaaatctgattctagcttcgtagctgactata ctcaaggaaccactgctcaaggtaggagactagttccgaccctacagtcaaagtggccga agcttaaactatagactagttgttaaatgctgatttcaagatatcatctatatacagttt ggacaattatgtgtgcgaaactaaaattcatgctattcagatggatttcacttatgcctt agaaacagatattgcccgagctcaatcaacagttttagccggaaacaatcgaagcatagg gacaatgtatcttttcctaaattgccatgtgcagatttctgagtgtcacgaagcgcataa tagaatcttgtgttgcctcaactcgttgaaaagtttaaaacaatcgcagcagtctttttg gggtctactgtgtgtttgcaaaataactgaaagaaacgcttgaacaactctgaagtagct cgagtactcattaaagtgtaacacattagtgaatatcggccaatgaaccaaacgcttccc ggtacgctatctctctcatcgggaggcgatgtgcaggttatctacgaaagcatcccttta cgttgagagtgtcgatgcatgaacctcattgtaacaatagcccagcaaattctcatacgt gcctcagggtccgggcgtactcctccatggaagggcgcgcatctagtgttataccaactc gctttttaactactatgctgtagttctacaggcatagtggccagtattttctaacttctc tggatagatgctctcactcctcatccatcacggcttcagtttacgtcttacttgcttgtt cagcaacggatggaggcattaagtatcttcactgttccctaaaattgctgttcaatatca aagtaaggacgatacagggaaagctcaagcacactcattgaatactgccccagttgcaac ctcacttaatctgacaaaaataatgactactctaagtgttgcggaagcagtctcttccac gagcttgtctgtatcacttcgtataggcatgtaactcgatagacacgaacaccgagtgag aaactatattcttgcttccgtgtgtgtgacaccaggtaattgatgcggatataagctgga gatcactcacgcccacacaaggcgctgctacctctttattccaatgtgtaagaatttgct aacttcatttctagaccgcagctttgcggtcataatttcacggtacggacccttgggtta gagacttgataacacacttcgcagtttccaccgcgcacatgttttagtggcttctaacat agaatttttgttgtgacataaagagtgcgtgggagacttgcccgaccgttaagccataat caattgaaagccccgtgagtcacatctaattggttgtactgcgcatttagctatccttta gctgactcgaagagattcgattcctaatataggttaattagatggctgccgcgcgaagta aaacgtgaaaaacgtagtgcgcagatctgcataactcgcgcttaattacttatgagtagt tccaagttcgctacgttatgagagagattggaattaagcaaatatgttttatggtgattt tgggatgagaaggactgctaagtacggctactaaacaaatttctaaaaccgccatctacc ttatcttggagacatttaagttgtatatgtcactagtctagcttttgtctgtgggacgcg ttctcggaatgagggaaatgcaagagccgattcatcaaatgcttatctaagaaagtagtg gactattacaccaagcacgaatgccagggaactgctttcttgctcaggacctcgcgacaa ggtaccccgcataagtcctagaattacatttggtcagcaatgctgacatttgaccgtgaa aacataattttaatcagaaggcagctcacccgcttgctctagatcttatctttgtatgaa tgtcagaatttactgcaatatccgttccgaatagtgagggcttagtatagttctctgtat acaggtcacatcaaactccccctgtcctagtacagctctgagctttaattaattgcatac atttccttcaatcatcagatgaaaacaccgcgaatcatgctcttctcgtatagggcaaga gaagcaacaaacaactagcccgactcacgttcatccgccgtatccttgttcagttcttac tccgtattaggtcagcgaaatctaatcagaataatcggtcgcgtatcaaaattaaaatcc cgcttgaggttgacaattaaaacgctgagcagttatcggctattagatagtggggtgaaa gtaattggctggaattatgttaaaacgtgatattaagctaaaatacgctacttgttgccg acctaattcagtcattcgatattcagttagagccaagaataacaagcttgtataaattga acggggtgcactaaacgatgtgttactctaatattcagcttggagtatacctgaaggcga attcatgtatcggccaataataagacgttgaagatcacaatttggactagcaaaagaagg tgatttatgcgtggggattgagtccactgtacgagtacggtctctggaaaattataggtt cagggaatataaggaagtaaagataattaccaagagatttttggtatcgctatgacccag aggtgttctaacgtctgttttgatccgcagaatttctgcctcaatgcatatttgacggac ttgaactagagcctctaaagttaaatggcgacgcaactgttcctaaacttcaattattac tactctttttttcctagggtattgtagaggccagtggacaaaataaatcaaatttaagat gtttcggacattaacatcccccgtagcatagaaatcatcagttatccaatctctcatcga gcttttacaatttctgctggcgctatggacagcatatgccgcgagacctccgcaagactc acttgatcactgtaagtatcttcattagaggttagagcctatagttaagctgctgaccta gtaaaattggtattttctaattttattgctcaagttaaaggttagtgaagggataatgac gttatttttgaacaatgggttgtattcaattttatatcacgaatggaacccttcattccc ggcataatactagacgacacgaacaagctccgatctatcagccaggcacgtgttaaggtt taattccggcaaaccaatgaagcatcaaaaggtgacctgatgcaacttagggtcacgatg agtttttcaggactacttattacctattaataagttaacatgagccttcataccccgtaa gacaatacatactccaccaattagaattctgagccatcttatctttttgtatcatcgaag ggtatggccgaataggttaattagttactcctaacgtctctacaggcatgcatttgacgc accttcgaaaatagtcaatctctcgccacacgcgtctagtatgcagcatcaaaaatatag tccacggtttccggattaccaaacgcggcaaagagaaacattgtatcgacggagataact taatacagaaggaaggggcatcttcgaatacggatgaataattctatctgtttattctga catcttgttttcaggttaatcttacgcattcaaatgacgcctgccccatgcgtgcgcaat tattttctaatattgacgagagcaatctcactccttttgggtctatttatgttttattga ggcacaagcctatacagaacaggtactattaaggccgtgagtgtgagactcaaaccgtgg aaacaaaggatgggttgttcttggtacaagttttagtgcatgtgggcaatccttaccaaa atcagatgctatccttaactttgggctgcatttaagatggcggttggaggcctgtgagaa tcctgcgtgtcatctttaatgaccgaattcatccatgtagattcagatcacacactcatt ccttgatgttgtctaaacaaaagttgttgtggacgcattggagggagttaagtaacaact tgggatcgcatacttataaaaattatatgttaaactttcacaaacgctgaagtccaaagt aactagcccaaacgcctcgagagtcactaggtattaatggtgtttgagttcctgtgaaat agtgttcgaaggtaaaatttatgtaccaaatcgaaagaacacttaataaggcttgcttgc acggaggtatgatgtttactgactctacaaccctaattttccagtacgtacattcattcc aataggttagttctcaaagtgctatacaggctcctcaattgatgatatgcttcagccgct ctatggatattagctcattttatttaggaagcccgcttagaggcttactatgagggaaat gccaaaatgtcatacttttcggtgtgtcccatatgacaccgctttacatagaatttgaat taaaacgcgctctcccgttcactaccatacttggtaccgtgcgcatattacatatagata taggatcattttttaaagctgtactaggtttgatcgacaatcttatgctatactatatga tgtaaccctcataatcaataccgatcgtacgatcctagcataggtggcaagcgattttat gccgattattgtgttaaatagtctgtgagtgtgattatcagggctacgttggtagagggg ttgtatagacctcgcacacattgtgacatacttaacaatatacgaaaactgatataataa atccccttacccaaacaccaatcccgttgaatcaactaccataacgtctcccatataaat tgcctacttgtttgcataaatctgaatacataacaccattgcaccttcttgtgttccaat cccgttaagattgccttgtcagatgatatgcaagaacaatagcatttgctagcaattatt aacagctcttcgaattgcctccacataacgcgggagggtatattttaatttggcaaatac taagtactgttggcgtcatatgctattaacggttggatattaagttatgtcagccgtaag caagagtgggcgaaatattttgttacccagtgagagcactcttagagtttggatacaata ggccatatgttgacttaagaggacgtaactacgccgtacaccattgttcaaccgacttct tggcaaatagaatcgtattagcaatcttaagaatagagacacgttcgtgttagggtatac tacaaatccgaaaatcttaagaggatcacctaaactgaaatttatacatatttcaacgtg gatagatttaacataattcagccacctccaacctgggagtaattttcagtagatttacta gatgattagtggcccaacgcacttgactatataagatctggggatcctaacctgacctat gagacaaaattggaaacgttaacagcccttatgtgtacaaagaaaagtaagttgttgctg ttcaacagatgatagtcatgacgcgtaacttcactatagtaaattgaaacaaatacgcaa tttagacagaatggtacggtcatgaatgacagtaattcgaagtgctagaccaacttaaaa taggtaaacgtgcccgaaaccccccttaacagaaagctgctatcatggtgcagtatcgac gtgttcagaaacttgtaacttttgagcaggtccgagcacatggaagtatatcacgtgttt ctgaaccggcttatccctaagatatatccgtcgcaaactttcgatttagtcccacgtaga gcccaagcgttgtgcgactccacgtgcatgcccagaaatacgagtttaaatttggttaca tggttaattttgaccgaagcatcgcactttatgattgataattggattcaatatgtcgcc ctatgcgaatgcaacatgatccacaatttggctataagacgtttaatccgtatcacactt tgtttgcggctagtatagtaacgcccgtgcaccaagagtcagtaacaattataagtactc cgcaggtacttcaaatataaaaactaatcaaacacgacccatatgatcatctgaagatat ttggaactttctcgacaaccaccctcgtactcaatacttacactaatcgacaggcacacg caacgtgtacagtcgcaccatattgagtcaagatttgcttagtggcgatgagcgtacacg cttatttctctagtcacaattagttatctacgagacatcacgagggagcaaataagcgat gttatggctacacataggcacgtatgaatatgatataagccagttaaacagtcgaaccat cgagcaaattctcatgcaccaacccacacgttgaggcacaaagagtaagctgtttgaatg taacttcttctgctgagcgggccccaacgtaaggatcaactagaagagaaaactcggtat tagtttaaatgcgtcacggagcatgagtgcatttcactaagaatgtctgtgtaaccaata taacatctatttgttatctgattgcctacttatggctttgcggtcgtggcgactaatgtc tccaatccttttgaggtcggtaccaactccctttaaattacgctgtgcaggctcatgcac tgcatacatatacggtagcaggtagggacctcacgcacccttattataatcaatagtagt tatcagtcaacgaggcaggaatgctgaggtcgaggtgttggtatattttctatgtgccgt ctaggcgactatcacgcattaccaggcgagatttaagccaattttgaatatagtcaacgt aatttttactatgggttccaccgaaacgccttgcacaactaagaatcccataaaatatcg atatcaaataaaagattgtgtcaataccttcatatatattttttcggttgactaacgtga actaaggttaggggttttgtatgtctatataggaaacagtttcttttctgtcctacttta gtaaagtcttcaagccttactccaaaatcacggtgattaagccgttactcagcagcatga ttctgcctgctcgggtcctaaaatccagccttgtaagagtcgctgtgtattagctaggga gacctttgttaaaaaggatatatcgcggcgggatgtgagtgcgtggcgcatactcaatct tcagctcgtgtcattataatatctctcccccacgcttttcactagatatgccgtgtaagc aaacaccttatgcttaatttcgaaaatattggtacttgaaaaaagctgtaggggtactta atgtctggtaggagatcaggagagaattgagtgtaaaaccgtaaagccctcacctgactt catgtaaatggcttagaagactccatgatttaataaatactacgaaggaaagactggatc taaagataactctagtaaggccaactcccttcaatgctgttgccagttataatccaagag ctgtccttttctgaaccatagcggcttctgaagcgaactagaagcaaagttggttctagc cagacagccacataccctgtacgggtgtattactaaaactggtccggtattagttcacca agggaggaattaggcaaaggatctaggtatgcaagtcggagtattacatccctaccctga atccatcaataggttcctctgtactggccttcgcaatgagtattcaaggttgtacagccg tataataataagatagtgactatgaacgggaagtaacccgctcaccttccccaaaacatt gttatatctaagtattaaagtctgccgtagtgttaatactcgaaaataaacaactggcaa attacaccgcacttaagccgcttttgatttatatttttccaatgcgcttttaaaaataat tcagtcctacatactaattaagacccttaaacggagatatcacaagttaagttttaacca tctcgactaggtggaactatagatacccaactcaatttatcattacctgtaatgttccta gaaggattgcatttcatgtcaagacggtggagtttcacagcgaaacttcagtgtgaacag attctgagaaatcacctaaacctattagtcagagcacccggttagaaccagttgtcaaaa aatagagcggttgcatgagacagaagtaacgatgagatccgttgtaacgttgagacatct ggcctatcgtcaatacagtcctcccttaaaaatatttttaaatactaggcaaacccaaca taggttagtcctatgtgatacgccacatggtatatcattttgtaacgttacctagggata atcaggaagtggaattacgcaaaagtagacagtgaaatgcttagggttatagtctagtcc aaagataaaggataaagcacgtcagagaactatattagccgaatgggaatcattgttagg agactgtggatcatgtctaaaaagcaacgcagaaacagtcatcgaaaaaatctcgttttt gtttgaatctaaaagagctttgatgaccgatagtacctgtatactagttactgtattacg tgtctaatgatttcggattggggtccccagaatcagacgtcattgtagacgattcaagtt taccaatttaatttcccagctctccttggagaactatcgccaataattgcagtcactttc cttttctgaaacgataaagccgtcagagttctctgcaacgttggacttacctgaggttct aacccactttcggttctaatagtagttaacgacacaacgaataacctttactgtggggct ttcacgatattttttcgcttattattaatggttacgtcataagctggtgtccaaattaag gttaccggcttcgcagagtagttgtatccaagtataacttccctaatcataagatcgagg tagaaaattaatgctgtctctaaccgaacagatatgtcccactatgtggtatggacgttg ctaattacttctgaagggaaattggtcattatggatacgtgtctaccatcaggtcggacg cagatatggttctgtcttcagttgatccaccgttctttataggataataactgacgatta aagattatggtaaatagattaagccaattctcttcttgtcagtgaagcatccttaactga cttgctctgcagcccctcatacatttagctattcaaagtaccggctcgtttcaaactctc ccacctttggaagaggttgtcaacttgataagtatatcatttacagcattttttcggacg tacctctaatgtttcattgcagaaaattagttttttctatcgcacattttgcaagtaacg ttagagacacaattatctgcgaatgaactgctagatctgacgaccgggagcctcgcaaat atcaaaaaagactgacatatatcaaggagtcgttgacaagtgctggtaagtcaattggtt tatctgtcccggcgtttcgatcttaagctgaccatgcacggcagagtaatgtcactctcg ttcttacaagtctgtctccaagggtcggcaaaaaagacccctccattctcgagcccactc acgatatgtagggacgacaacttgtgcggcttatgaattgtctggactgcgggcgagggt ccatatctccgaagttagaagggacatacctttagatgataagatcaattcttattgacg aaattcatccacaacggggaacaacttcaccctagacttacgtctgaaaagacacctagc gtcttataaaaggtcagtgccccgtttcgtaaggctggaattacctacgcaaacttaaac ctcgcgcccttccttacgtatcgacaagatagaggctatcgcgaatgtactacggaggca tgaatcatatactagaaccaagtgcctgtgatattaacaagatgatccgacgcgagcacc gtaattctaggcataaaactccagcaatttgggggccgaaaacaaatgacgttagctaat taattatatgacatgatcaaaggaggtcaatcacgcatcgagttcgacgtatattcattg aacttcgtgcgtttgaaagaaacttttatgaaggcaaaattgatcctgtctcctatttca tgcgtacctcctagttgataattccccgagcagtggttaggacacttttgtcggtatcaa gttccggtctcaaaacgtaaaattctgtaatctgtatggatggtctgtgaattagttaat ttttatgaagtcgtcgagacgcagttcctattgatttattctaaacggagatgtgcttcg tgggactcggaagtagatctgtgtttatgattattgctactttagatgctgactgttaac tccgtgttgtttttcaaccgtatatcacaaccgaattggatagaacctatagtttcaagt tctgccacaaggtatcatatttacagttagtgctggttgcttctttcaaacgtggtgagt ttgtgctatcacgtcaacggtagagctcagtggaccgagtgcgcgttcaaccctgttcca gagagggtgtgatagcacatataccacgctcgtcgaggcgttcatgatagtttgcaagag ccggtgttaaacacatattattattgttatccaactaatcggacctatgcataaagcatt gtctaaacagaataattgcctatatacggtagttttagtgatttatatcttagtatcagt tagagcttcgaactcttcaggttcctcatatttaacgttcttcgaaagcgaaaacttcta caaacgaatgtaagcggttttccaagtagtacctataaatcacagaaagatctgtctcag tatagttgaaatggtattcagctagtgacgtgtaccaattatcatagttcactcaagcaa gacgctcattaacgaatatagacaagacactatatcatataataaaaaagaacatggtgc tcgaacatagttgaattcaccatattgaaggggaatgctgacatgtaattcgctactaga cgatcaattccctacttgtcaaagttgaactggtacgttcttggaattaaatatgattgc gctggaccaaattgcgacttcttgagtttcagggcaaacgattgagccggaggatgtccg tctcttacctttcttgcttatgataaacgacggtccctgtacatcactgggaattctcag caaaaataattgggtaaatcgagactcgatgtattcggccacaaaggtgttagacgttaa agattattcaacggggcgataataggatcataaccggtatgcaagcgcattgaaagagcc atgagatccttatccgataaacgctgcacggtatgtgcagccttattgtcgatcacgaat ttataaatgtagtctgggctgtaagttgaagacctaagttataatgaagtgcaataccaa atcgattcatagtggattatcagactcaagatatctcctgataaattacagttgttaaga tacggataaaatgagatttaagattagcagcctctaatctgtttcaatcccgttggaatg tggtatgcgatcaaggttaagttaaaatcaagcctgtcttcagtcttgattcttgttctg ccatcgcatgcggtctacgtgagttaatatgtagcttacgttctagcttgtgctaatctg agtatagattcgtagaggaatattatcaagcttccacgcctcaacgtacgtgtattggtc acacaagacactaaaagtggaagtagcgtaaactatagtctagttgttaaatgctcagtt cttgttatattcgatatactcttggctaatttatgtctgagtatataaaattaatgatat taacttgcatttcacggatcccttagaaaaagattttgaccgagcgcattataaacggtt acaccgaatcaatagaagcatacccaatagctttctttgaatttattgcctgcgcaactt ggctgactctctagatccgaataattctatatggtcgtgacgaaactagttcattactgt ttaaaatgccaacatgtcttttgggccgataatggctctttgcaaaattactcaatgata cgattgatcaaagcggtagttgctagtggtagcatgtaagtctatcaaatgtctgattat ccgaaaatcttccaaaagagtccacgtaccatatctatctcatagcgacgcgaggggaac cttatctaactatcattccatttaccgggtgactctcgatgcaggatccgattgggataa attgcccagaaatggctcattcctgactaagggtaaggccgttctcagcaagggaacccc gcgaatctaggcttataccatctagattgttaactacttgcctgtagttctacagccata ctggacagttgtttctaaatgatcgggattcatgctagcactcctctgaatgcaccgcgt aagtttaactattacgtccgtgggcagataaggatggaggctgtatgtatcttaactgtt acctaatatggctggtaattatcaaagtaaggaccttaatgccatagcgctagcaatcgc tttgtatactgaccatgtgccaacctctcttaatctgtaaaatataatgtcttagctaac tgtggacgatcatgtctctgcctagagcttcgctgtatcaattcctatagccagcgtact agtgacacaacaacaccgtgtgagaaaagatattagtccttacgtctgtctctctacagc ttattgatgaggattgaacatggacatatagctccccctcaaaagcagatgctacctctt tattccattctcgaacatttgccgaacttaatttcgacaaacctgaggtcacgtcttaat ttatcggtaacgtcacgtccctttgagactggataaatatattaccaggggccaacgagc aattgttggaggcgcttctataatacaaggtgtcttgtcaaagaaagacggcgtgcgtct cgtgcaactcacttaaccaatattaatgtgaaacccccctctctcacatcttatgcggtg tactgccctggtacatttcctgtacaggactccaacagtgtagattcctaagatagctgt tggagttgcctcacgccagatcgaaaaactgaataaactagtgagctgagctgcagaaat accgcttaattacttatgactagttcaaagggacctacgtgatgtcagacattgcaagga agaaattaggtttgtgcgtcattttggctggactagcactccttacttcccctactattc aaatgtcgtaaacagcatgagacaggatcgtgctgacatttaaggtctattgggaacgag gctacctttggtcgcgcgctcgcgttctccgaatgaccgaaatgcatgagcacagtatgc aattgcttatagatctaaggtctggtcgttgaaaccaagcacgtaggcctgggaaatcag ttcttcctcagcaactacacaaaagcgtccaagcattagtacttgtagtaaatgtccgaa cctatgcgctcatttgaaagtcaaaaaatatttttaagcagtaggcacctaacccgattc ctctacttagtagctttctttgattctcagaattgactgcaatatcactgcacaattctg tgccattactagacttctctgtattaacgtctcatcttactaacactcgcctaggacaca tctgagagtgaagtatttcaatacatttactgaaatcttcagttctaaaatccccgaata aggctcttatcggtttggccaacacaagaaaaaaacttcttgcaccactcaccttcatac gcaggagcctggggaacttagtaataactatttcggcagacaaagcttataacaagttgc cggcgcgtataatatttaaaagaccccttgagctgctcaattaaaacgctcacctggtat aggctattagatagtgccgtcttagtaaggggcgggaattatcggataaactgatatttt gataaaataaccgacttgttcacgacataagtcactaaggagattttatctttctccaaa gtatatcttccttggataatttcaaagcgctgcaatttaagttctgttactagtttatgc tgctgggaggtgaccggaaggcgtagtaatctagaggcaaattataagaagttcatcata tcattttcgactacaaaaacaaggtgttgtatgccggcgcattgtgtaaactggacgagt accctagatggaaaattatacgttaagccaagatttcgatgtaatgataattacctacac atttttgctatccataggaacaagagctgttctataggctcgtggcatacgaacatttgc tgccgctatgaatattggaagctcttcaactacagactctattcttaattgccgtcgaaa atgggccgaatcggctattattaatactcggtttttccgaggggattgttgtcgacagtc gtaattattattaatattgatgttggtgaggtcatttaaatacaaccttgcagacaatga ataagggatccaatctctcatactccttttacaattgctcatgcccctatgcaaacctta tgccgccacacctccgcaactctctcttctgaactgtaagtagcttcattactggtttga gactatactgaagctgatgacattctaaaatggctattttcgaatgtgattcataatgtt tatcgtttgggatggcagaatcacgttatttttgatatagcccgggtattctattgtata gaacgtatgctacaagtcattccccgaagaagactagaagtaaacaacatgcgaccatcg ttaagccacgcaaggctgtagctttatttcccgataacctatcttccataaatagcggac agcaggatactgacgctcaacatcagtggttatggtctaatttttaacttttaataaggt aacttcagcaggcatacacagtaactctttaatttataatcaaattagaagtctgacact tcttatatttttctatcatccaacgcgatcgcccattagcttattgtgttactaataacg tatctaaaccaatccttttcaagctactgcctatattgtcaatatatacaaacaacagga tagtaggctgcttaaaaaatattgtcaaccgtgtacgctttacaatacccggaaatcaca aactttgtagacaacgagtgaaatttatacactacgaagggccagcgtacaagacccatg aattaggcgatatgtttattctgacatattggtttatccttaatctgtcgctgtaaaatg aagccgcccccatccctgcgaattttttttcgaagattcacgactgaaatataaatacgt ttggctatatttatgttggagggaggcaatagcctttactgttaaccgaagatttagcca gtgagtgtgacactaaaacactggaataaatgcaggcgttcttctgggtaaaaggtttag tcaatctcgcctataagttcatatagctctggatataattatctggcccatgcatttatc atggcgcttggtgccctgtgtgaagccggcctctcatattgaaggtccgaagtattccat gtacattaagatcactctctcattcatgcatcttggcttaacaaatctggttgtccaagc tttccaggcacgtatggtacaaattcggatcgaatacttataaaaatgatatgttaaact gtctaaaacgctcatctacaaagtaaagtgcactaaccaatagagtctcaagaccgtgta atgctggtgcactgaatgtgtaatacggttagaagggattagttatgttacaaatccatt gaaaacttaagaagcattgcgtgctcggagggtgcatcttttatcaagagactaacatta ttttcaacgacgtacatgctttacaatagggtacttatcaaacgccgagaaacgcgccta tagtgatgttatgattatgacccgatatccattggaccgaattttatgtaggttcccagc gtactcgcgtaatatctcggtattgccataatgtaatacttgtcggtctctcccagatga aaaagcgttacagagtatttcaatgaaaaacagcgcgcaacgtcaatacctttaggggta acggccgctgatttcatatagatatacgataagttggtatagctctactaggtggcatcc acaatcgttgcatttactatagctggttacaatcataatctataccgttccttacatact accatagcgggatagcgtttttttgccgttgattgggtttaagaggatgtcagtctcatt atatccgattcggtgggagagccgttgttttcaaatcgcacactttgtgacataatgtac aagataacaaaactgatataagatataaactgtcaatatcaccttgacacttgaatcaaa gtaaattaactcgcaaatataatttgactaattgggtgcagatttctcaattaataaaaa aatggcaccggatgggcttacaagccccttatcattcacttgtatcatgatttccaagaa caatagaatttgctagcaagtatgaacagagattcgaattgcatccacagtacgccggag cgtttattttaatgtggatatgacgatgtactgttggcggcatttgctagtaaccggtcc ttatttacgtagcgcacacgtaagcatgtctgggagaaatatggtggtacaatctcagag aaagattacagtttggtttaaataggacttatcgggtcggaagtggaacttaataagcag tacacaattgggcaacagacgtcttgcctattacaataggattacaatgcgttagatttc agacacgttcgtgtttggctattcgtcaattccctaaatagttagacgatcaactattat caaagtgattctttgttcatcctccattcatgtaacagatggcacactacgcataacgcc gaggaattttaacgagatttaagagagcagttcgggcacaacccacttgactttataaca gctcggcagcataaacggtaatatgtgacaaatttccaaacgttataagaacgtatgtgt acttagaaaactaagtggttcatgttcaacagatgtgacgcagcaagcctaacttatcta ttggttttgctataaaagaacaaagttacacagaatcctaagggcttgtttcacacttat gcctagtgcttcaccatcttaaaatagcgaaaccggcacgaatcaaaccttaaaacaatg cgcagatattggtgatggtgactccgggtatgataatggtaactgttgaccagcgcccac ctcatcgaagtatagaaagtggttaggataaggatgagaccgaacttatttccggccata actttagattttctacctagtacacaacatcagggcggacacgaaaccgccatcacatca tataccaggtttaatttgcttaatgggggaagtgtcaacgaaccttcgaactttagcagg catatggccattatatatggccccagagcagaatgctacagcagacaaaatttggattta tgtagtttaatacctatcaaacttggtgtgaccatacttgtctaacgacagtgcacaaag tgtaagttacaattattactactcagcagcttctgcaatgataaaatcttatcatacacg tcacatatgataatatctacttagggggaacgggctccacaacctacatagtactcaata cttacactattcgacaggcacaccaaacctgtacagtcccaaaagattgagtcaactttg cagtactgcagatcacagtaatagcttagttagcgagtcaaaattagttttctacgagac tgcacgaccgtgcaaatttccgatgtgttggctacaaatagcaacgtatgaatttgtttg aagccacgtaaactgtacaaccttagagataagtctcaggctactaaaaacacgttgtgg cactaacaggatcatggttgattcttacttattcggctgaccggcccaataagtaacctt caactagaacagaataatcgggagtagtttaattcagtcaaggtgcaggtctcattgtaa ctaacaagctctgtgtaaccaagttaaaatcgttttcttagcggattccctacttatgga tttgagctcgtccacaatattcgatacaagaagtttgtggtccgtaacaacgaaatttta attacgctgtgcagcctcatccaaggaattaatagaaggttgatggtaggctccgaacgc tccatgattataatcaagtggactgtgcagtaaacgaggaaggtatcctgacgtcgtggt gttcgtttttgttatttgtgccctatacgagtagataaaccatgaacagcacagtgtgaa cccatggttgattttaggctaccttatttttaatttccgttacacagaaacgaattccac aactaacatgccattaatttttcgatatcttataaaagatggtcgaaattcattcattta ttttttttcggttctcgaaagtcaactaagctgtcgcgttttgtttctctttagaggtaa aagtggctttgatctcctacgtttggatactagtcaaccattactccatttgatccgtga gtatcacctgtctaacatccagcattatgactcctcggcgaagaaaagacacacttctta gagtcgatgtgtattagctagggacacagttgtttaatacgatagtgagcccagggaggg cagtgcgtcccccagtagatttattcagctagtgtaagtataagatatctcacccacgag gttcaagtgatatgcagtcttagaataatacttatcctgaatttcgatattatgggtact tcaataatccgctagcgctactttatgtctcgttggacagcaggacacatggcagtctta aacactaaagacatcacctgaatgaatgtaatgggattacaagaatcaatgaggtattat atacgacgtaggaaactctggatatatacagtaatctagttacgccatcgcacttcattc ctctggaaacttagaagacatcagctgtacgtggaggaaccagacccccgtatgtagcca aatagaaccaaagttgcttatacaaacacacccaatgacaatggaccgctggagttcgta aactcggaacgtagtactgcacaaacccagcatttagcaataggagctacgtatgcaact cccacgtggtaataccttcaagctatcaatatataggtgcctagctaatcgcattcgcaa gcagtattcaagcttgtaaaccagtataataattacagaggctctatgaaacccaacttt ccagctaaaagtcccaattaaatggttatttcgtacttttaaagtcgcccgttctgttat tacgcgaattgattctactccaaaattaaacacaaattatcaaccgtttcatttatattt gtcaatgcagctgtttaaaataaggctctactaaattataattaagacacttattaccag atttctctagttaagtttgaaccagctcgactaccgcgaaagatacattcccttctctat ttttcagttcatctatgggtcagagaagcattgaatttattctattcaccctcgtcgttc acagcgaatcgtcagtgtgatcagtgtatgagaaatatcctaaaccgtttagtcagacca cacgcttagaacaagtggtctaaaaagactgccctggaaggagtaagaagtatacagctg atccggtgtatccttcagtcatctgccctatactaattacacgacgcaaggaaaaatagg tttattttctaggcaaacccttcataggtgactccgatgtgttacgaatcatgcttgaga atgtgctatcgttaccgacggataataacgatctccaatgaaccaaatgtagaatgtcta ttgattacccttttactattcgacttagagataggagatagaacctcagtgtactttttt agccgaatgggaatctttgggaggtgaatggccataaggtcgtaaatccaaccctcttaa agtcttccatattatatcgttgttcgtggaatcgataacagatttgttgacccatagtaa atgtatactagtttatgttgtaagtgtagattgttttccgattgccgtccaaactttatg tcgtaattgtagaccagtaaagttgaccaaggtaagtgcccagcgatcctgcgagatcga tcgccaatttttccagtcactgtaagtgtaggtttagataaagccgtatgagttatatca taagggcctcggaaagcagcttcgaaccaaagttcccttataatagtagtttaactataa aagtatatactggtctgtcgccctttcacgatttgttttaccggtttatgaagcgttacg tcattagagcggctccaatttaaggttaacggcttccatgtgtagttgtatacaaggata acttaaagtatctgttcagcgagctagttaagttatcctcgatagaacacaactcagagg tcccaagatcgggtttgcaacttgctaatttattctcaaggcaaattgggaattatcgat acctgtataccataaggtcgctcgatgtgatgcttatgtcttctggtgatcctaccttag ttagtgctgattaacggaacattaatgtttatcgttttgagatttagccaattctctgat tctaactcaagatgccttatctgacgtgctatgcagcccctaagtattttacattgtaat aggacacgctcctttaaaactcgccaaaaggtcgttgtggttctctactggttaactata taatttacagctttgttgagctagttcctctttggtttaagtcctcaatattagttggtt cgagcgataagttggctagttaccttagtcactatattagatccgaatgttatgcttcat ctgaagaccgccaccctccaaaatttcttttaagactcacttattgcaaggtgtaggtga attcggctcgtttctcaagtggtgtatctgtacacgagtttccatattttcatcaacagc caccgcacacttatgtcactctaggtattaaaagtcgctctacaaggggacgcaattaag aaacagacatgctagtcaaaaataaacatagcgaggcaccactaattcggccgcttatca atgggatgctctgcgcgagacgcgccagagctcagtagttagttcggacatacatttact tcagatgatcaattagttttctacaaatgcttactctaccccgaaaaaagtcaccagact cttacgtctctttagtatccttccgtcttatataaggtcagtcccccgtttcggtaccct ggaatttactaagaataatgaaacagcccccaaggacgtacgtttacaaatgatagacca gatcgcctagcttattccgacgcatgttgcatagaattgaaccaacggaatgtgagagta actagatgagccgaccacagcacccgtttgcgtcgcagaatacgcctgatagttcggcca cgaaatcatatgtcctttgagtattaagtatttgtaatgatcaatcgagctcaagcaagc ttacacttcctcggatattcagggaacttagtgcctttgaaagatacgttgatcaacgaa aaattgataatggctcatatggaatgcctacctcatagtgctgaattaacacagcactgc ggacctaacttttcgaggtttcaagttcacgtctcaaaacctaataggctggaatatgta gggatcctcggtgaatttgtgattgggtttgttgtagtactgaccaagtgaatattcttt ttttctaaaagcagatctgctgccgggcactacgaaggagatctctgtgtatcattattg cttcttgacatgatgactcttaaatcactgtgggtgtgcaaaacgatagcacaacccaat tcgatagtacatattgttgatacttcgcactaaaccgttcatatttaaaggttgtgctcc ttccttcgttaaatactggtgacttggtcctatctactattagctagacctctggggaac cacgcccccgtaaaacctgtgcaagagagggggtcatacatcttagacatcgcgcctcca ccagggaagcattgggtgattgaccaggtgtgtaacaaatatgattattcttatactaat attagcaaagatgcataatgatttgtattaaatgtataattgaattgataagggtctttt agtcagtgatagagtagtataaggtagacattagaactcttaaccggacgcagatttttc ggtcttagtaagccaattagtcgacaaaacaaggtaagagcggttactagtagtacctat aatgcactgaatcttcggtcgaagtatagttctaatgctatgcagattgtgacggcgaca aatgttcagacttatatcatgaaacaagctcttgtaagtattgacaaatgaaaagattga atatttttaaatacaaaatgcgcctacttattaggggaattaaccagattgaaggccaat cctcacatgtaatgagataatagacgataaatgaaattcttgtaatagttgaactgctac gtgatgggtattatatatgattgagatcctccaattgccgacgtcttgtcttgatgccca aaagattgtcaacgaggagctccctcgcgtacctgtcgtccgtatcataaacgacgcgac atgtacagcactccgaagtataagcaataataatgcgggtaatccagactagatcttttc ggactcaatgcggtttcacggtaaacatgattaataccggagagtagtcgagcttatcag cgatgcaagcgaattcattgtgccaggagatacgttgcagataaaaccggcaacgtatgt caacaagttttggcgatctcgttgtttgtattcgacgaggcgcgggaacttcaagaacta tcgtatattcaagtccattaccttttagtttcagactggtggagctgactaaagttatat catcattttgtacactggtttagttaacgataatttcagatttaacatgaccagacgata atcgctgtatatccagttggaatgtggtttgccagaaaggttaacttataatcaagcctc tcttcagtcttgattcgtcgtatcccatccattgcgctatacctcagtgtatttggagct gtagttataccgtgtgctaagatcagtagacatgacgagagcaatattatctaccttaca agcatcaacggacgtctagtcggaacaaaagactctaaaactcgaacttcaggttaatat actatagttctgtattcagcagttattcttatattcgatattatcttgcctattggatgt ctgactttagtatattaatcatagtatctgccatgtaaaggtgccagtactaaatctgtt tcacagtgcgaattataaacggttacaaccattaaagacaacaagaccctatagctttat ttgaattttgtcaatgcgcaacttggagctcgcgatacatcccaattagtctatagggtc gggacgattctacggcatttctggttataatgacaacatggattgtggcccgagaatcgc tctttcattaattaagcaatcattacagtcttataagcgctacttccgagtggtagcagg taactcgatataaggtcgcatgagccgaatagcttaaaaaacaggccaccgaacattgat agagaataccgaccacagcgcaacctttgattactttcattaaattgtacggctcactcg acatcaagcttaagattgcgataatgtgaactcaaatggatcagtactgaagaaccgtaa cccacttcgcagaaagcgtacccagagaagatacgctgttacaatatacagggtgaaatt attgcctgttcttcgtaaccatttcgccaaacttggttagaaatgatagccattcatgat agaaataagctgaatgataccagtatctttaactatgtagtcagggggaagataacgatg gtccatgtatgtttctgatatgtgacagtattggccgcgtaatttgctaacgaagctact taatgcctttgagcttcatatagatttctttaatcaaaatcggcaaaaagatagtatgag ctataatatatgctagtagagaactctggaccatcatctatatgaatactgattcgagcg tgcaattactttagcctgcgtactactgactctacaaaacactctgagataagtttgtag tcagtaagtcgctctctataaaccttttggatgaccattgtacagccacttatagatccc aataaatagcacaggagacagagtttttcaatgctcgatcatttgccgatagtattttcg tctaacctcagggcacctattatttgatacctaacctaacggccctttcacaatggagaa atatatgacatcgggacaaacacaaatggtgggtggccaggagatatgacatggtggcgt ctctaagaaacacggactccctctaggcaaactcacgtaaccaattttaatgtcaaacaa aacgctcgaaaagattttgccgtgtaatgacctggtacattgactggtcaggaatacatc actgtagttgccgtagtgtcctgttggtgttccatcaagacacatcgtataacgcaattt acgacggacatcagatcaagttatacagattatttaagtatcacgtgtgcattgggacat aagggatctcacacatgccttggaacatttttgctttgtgccgctttttcgctgcactac caatccttacttaccagtatattcaaaggtcgttaacagaatgagaaaggttagggctct aagttatcgtcgattgggatagacgagacatttgcgagcgccctccacggatacgaatct cccatatcaatgtgaactggatgctatgcagtttagttcttacgtctcctagtggtaaaa atcaaagtagcactcgcatagcagttattcagaacctaatacacaaaaccgtcaaacatt ttctaattctaggtatgggccgatcataggagctaaggtgaaactcataaatgttttgtt agatctagcatcctaaaaagatgcatatactgagtagctggcgtgcattctctcaattgt atcctttttaactgaactagtcggtcccatttcgtgactgagatctattaaccgataaga ttaataacactcgcattcgtatcagctcagagtgaagtttttcaataatttgactgatat attaacttctaaaataaccctttaagcctcggatccgtttcccaatcacatcaaaaattc ttattccaactatctacggattaacaacgtgcatggggatcgtagtaagaacttgttccg atcactttgagtatatcaagttgacggcccggttattattgaatagaaacattcacctgc taaattaaataccgcacatcggatacccgatttcagagggccgtcttactaagggcaggc tttgttcggtttaactgagatgttcattattttacagtatgcttcaactaatatgtaacg aaggacagtggatctgtctccatagtagatcttcagtcgtgaatttcataccgctcctat ttaagttcgcgttcgagttgttgatcatggcacgtgaaagcaacccctagtattctagac gaaaattttttctagttcatctgataatttgccaattcaaaaacaaccgctggtttcccg gcgcattctctaaaatggaagtcgaacctagagccattatttgtcggtaacccatgagtt ccttcttttcagaagttaatacactgtggtcctatacagaggaaaaacagcggttatata cgatcgtggcataacaacattggatcaagatagcaatttggctacctattctaattctca ctagattcggtattccactacaatatcggcagattaggattggatgaataatcggtgttt aagtccggttgcgtctccaatctcctaatttttattaatattgatcttggtgacctattg taaataaaaacttcaagactttgaataacggtgaaaagatagaagactcatttgaaaatg gatcatccacagatccaaacattagcaagacactaatccccaactagctattctgatcgc gatcgtgctgcagtactcctgtcacaatagtctgttcatgatctaattctttttgggctt tgttcgatggtgattcagaatctttatccggtcgcttccctgtagctactttgtggggat attgcccggggattatagggttgagatcgtttcctaaaagtatttaaaccaagtagactt caactaaactacatcagaacatcgtgaagacaccatacgcggtacctttatttaccgata acatttcttcaagaaataccggtaagcagcataatgaccctaaacagctcggggtatcgt cgtagttttaaattttatttaggttactgctcaaggaataaaaactaactatttaattta taataatattacaaggctcacactgattagatttgtctataagacttcgcgatcccccat taccggattgtcttaagaataaactagataaaccatgcattttctagataaggcctttag tctaattagatacaaaaaacacgatagttgcatccttaatttattgtgtcaaacctggaa ccttttaattacccgcaaatcactttatgtcgagactacctctgaaatttattatctacc taccgcatgaggacttgaaccatcttgtaggagttatgtttattagctaagattcgttta tcctgtagcggtccatgtatattcaacaagcaaaaagcactcagaattgtttttagttga gtcaagactgatatataaataagtttccctagttttttcgtggtgggacgatattgaatt gaatcttaaccgaagagtttcccactctgtcgcacaataatacacgccaatatttccagc cctgcttatgccttaatcggttactcaatctcccattgaagttcattttgatctgcatag aagtttcgggcccagccttttttctgccaccttcctccaagctctgtagacgcactctaa gattgatgctcacatgtattaattctacattaacataaatatataagtcatgcatcttcg agtaaaatatctggttctccaacatgtcctggcacgtatcgttataatgcccatacatgt agtattaaaatgattgggttaactggatattaagatcatcgaaattgtaaagtcaaatta acaatactgtctcaagaccgtgtattcctcgtgctcggaagggctattacgcttacttcc gttttggtatcttaatatgactttcaaaaattaagttgcagtgagtcctacctgcgtgca tcggttagcaagagtataaaagttgtttaaacgaactacttgctttacaataccggtcgt atatatcgccgtgaatccagaagattgtcttctttggattatcaaccgagatcctgtgga ccgatgttttgggaccttcacagaggactccaggtagagctcgcttttgcattaatctaa gaattgtacctctctaaaagatctaaaacagtgaatgtgtatttcatggaaaaacacaga gaaacgtaaattactttaggccgaaaggcacatgagttattatacatatacgagatggtg gtatacatcgaattcggggcatacactatagttgcattgtatttagctgctttaaataat atgatattaccttccttacataagacattaccggcataccctggttttcaacttgtgggg ctttttgacgatcgcactctcatttgatccgagtagggcggtgacccctgcttttcaaat acaaaaatttcgctatgaaggtaatagattacttttcgctgttatgatagaaacggtaaa tttaaaattgaaacttctagaaaagtaaagtaacgagaaatgattttgtgaataatgcgg tcatgattgcgcaagtaagaaaaaaaggcaaaaggatgcgcggaatagaaacttatcagt cacgggtatcttgatttcattcttcttgtcaattgccgacataggatgaaatcagattcc aatgcaatacacagtaacccccacccttgattgtaatgtcgatttgaagttgtacgcgtc gacgaagtggatagtatacgggccttttgtacggtgcgatcaactatgaatctcggcgag ttagatggtcgtacaatctcacacatagaggtcacttgcctgtaatgacgaattttcggc taggtactcgaactttattagaagtaaaaatgtgggcaaaagaaggattccattttacaa gacgattacaatgagttacatgtctctcaacgtagtctttccctagtagtctttgaacta tttaggtactccagaaaattttagcaaagggtttctgtgtgaatccgccattcatgttta tgatggaacaataagaataacgccctcgtatgttatcgacagtgaagtcagcagttcggc caaaaacatattcaatttagtacagatccccagaagttaagctaagtgctctaaaatggc ctaaacggttatcaaagtaggtctaattactatactaacgggtgcatcgtaataactgct gtcgatgcaacactatatgatagtgtcgttttgctatatatgtacaatgtgacaaagaag ccttagcgattcttgcaaacttaggacttcggattctcaatcttaaatgtccgaaaacgc aaagattcaaaaatttaatctatgagcagatatgcctgatggtgactacgcgtatgttaa ggctaaatgttgacaaccgcacacataatcgaactattgatagtcgggagcataaccagg tgaacgtactttgttcacgacatttattgacatgttctaaatacgtctcaaaatcacggc gcactagaaaacgcaatcaaatcattgtcctggtttaagggccgtaatgccggtagtgtc aaacttcatgagaactttagctggcttttggccagtatttagggaccaagagcactagcc ttaagctgaatattttgccatttatctactgttataactttaaaacttggtggcaccaga cttgtcgatacacacgcatcaatctgtaacgtaaaaggtttactaagaacaagcgtagga attgagtttatattatatttaaactaaaagatgatattagcttctgagggcgatagggct ccaaatcataaagaggaatatattattacacgattagaaacccacaacatacctcgaatc gcccaaaagtttgacgaaacttggcagtactccacatctcagtaatacagttgggagagt ctcaaatgttgttttattactcaatgaaccaccctcataatttcactgctgttccattaa atttgcaaacgatcatttgctttgaagaaacgtaaaatcgacaaaattacagataagtag atgcataataaaaaaaactgctcgctataacacgatcatcgtgcattcttacttaggagc atcacccgcacaataacgtaccttaaactacaacactattagaccgagtactgtaattca cgaaagctcaagctcgcattgtaaagaacttgctctctcgtaaaatgtgataatagtttg cggagaggattcaattattttccattgcacctactccactagattcgataaaagaaggtg gtcctcccttaaaaagaaatgttaagtaacatcggaaccataagcaaagcatgtaagtga accgtcatccttccctaagaaacataaaggtttttaataatgtcgactgtgaactataac tgcatcctttcctgacctactccggttccttgttgttatttctgaacgagaccagtagat aaacaatgtaaaccacagtgggtaccaatggtgcatgtgacgctaccgttgttttaagtg cccgtacaaacataagaagtcataatcttacttgaaattaattttgccttttattttttt tcaggctcgaaattaatgatttgttttttttgaccttctagttacgctaatatgcggtcg cctgtggtttctattgagtcctataacgggatgggatctaatacgtttggttactagtaa acaaggtataaatttgataccggagtatcaactgtataacatcaagctttatgactcata cgcgaagtaatgacacaaggctttcaggagatcgcgagtacagagccactaaggggtgta ttacgatagtgacaccaccgagcgcactcactccccaagtagatttatgatcctacgcta agtattagatatataaccaaagaggttctagtcagtgcaactcttagaataataattagc cggttttgcctttttaggcctaatgcaatattcagctagcccttatgtatctcgcgttcc acagcaccactcatggcacgcgtttaaactaatcaaatataatctatgaatgttatgcca gtacttgaataaatcaggttttttataagtccttgcatactctcgttatatactgttaga gtcttaccccatagaaattctttcatctgcaaacttagaagaattctcagctacggggag cataaagtccccaggatgttgacaaatacaacaaatgtggcttatacaaacactccatat gaaaatcgaaccctcgtggtagttttagccgaaccttgtacggataaatccctccatttt ccaatagcagatacctatcctactacctcgtggtattaaattaaagcttgaaatatagag ctgcatagcttatccaattcccaagcacgagtctaccgtcgtaaccacgatttgatttac agacgctagagcaaacccatctttaaacatataagtaaaaattaaagggtgagtgcgtac gtgtttactagcaacttcgcttattaagacaattgtttataagccataattaaaaacata tgttcaacaggttcattgatatttgtaattgcacaggtttttaataaggatctacgtaag tataatgaacaaactttttaccagagttatattctgtactttgaaaatgctcctctaccg ccttagagactttcaattagattttttgcagttaatctatgcgtaagtgaaccatgcaag ggatgcgattcaaccgcctcgtgctaaccctatcgtctgtctcataactgtaggtctaat ataattttcagttttcgaacacataaccctttgaaaatctgctatttaatgtctcacctg catgcactatcttctatactgctcagaacggctatacgtcactatgctccaagtgacgat ttaaacgaagcaaggaataataggtttattttagtgcaaaacaattaagtgcggactacg tgctctttacaataagccttgtgattgggctataggttaagtcccatattaacgatctcc aatgtacaaaatcgacaatcgctttgcattacccggttactagtcgaattacagatagct gttagatactcactctaattttggacaacaatcccaatcttggggtcgtctatcgcctga agctcgtaaatccttccatcttaaacgattacatattatagacttgttcggggtagagat atcacagttgtgcaaacattgtaaatcgatactagtttatgttggtagtctagttgcttt taccattccccgaaaaacttgatctactatttcgacaacagtaaacttgaactaggtaag tgaaaacagagaatgcctcatagtgccactatttgtccactatatgtaagtgtagcttta cataatccactatgactgagatcattacggcctaggaaagcagcgtagaaaaaaagggcc cggatattacgactgtaactataaaactagttactggtagcgcgccatgtatagatttgt tttaccggttgtggttgcgttaacgaatttcagccgcgaaaattgatccgttaaccagtc catctcgacttctataaaacgataaagtaaagttgatgttcagcctccttcttatggttg catcgagagtacactactcagtgggaaatagatcggggttcctacttcagattgtattat ctaggcaattgccgattgtgccatacctggataaaataagctacctacatgtgatgctta tctattatcgtcatactaccttagggtgtcctgttgaacgctacattaatctttagccgt ttgagatgttccaatggataggagtctaacgcatgatgaagtttaggaaggcagagcatc ccactaagtatgtgacagtgtatttcgaaacgagacgttataaatagaaaaaaggtcctt ctggttctattctgctgaactattgaatggaaagattggttgacctacgtactatttgct tgaagtcatcaatttgacggggtgagagacatatggtgcatactttacggactctatatt ttagatcagaagcttagcagtcttctctacaccccctcacgacataattgcttttaagaa tctatgtttgattcctctacgggaattcggatccgttcgcatgtgcggtttatctaaacc aggggacatatgttcagctaaagcatacgaacactttgctaactagacgtatgtatagta gctataaatcccgacgatatttacaaaaagaaatgagactcaaatatatacatagcgacc ctacacttattcgcaccctgatctaggcgatcctagcacccacacccgaaagtgagcact agtgtcttccgtattaaatttactgcagttgagattttagttgtctactaaggattactc taacccgtaataaggatcaagactcggtactagctttactatcattccctatgtgttttc ctaactcacaagggtacgtaccagcctatgtaattacaataatgataaagacacaaagga agtaactttacaaatgagtctccagttacactagcttagtccctcccatcttgctttgaa gtctaaatacgcaatctctgaggatatacagcagaagaacactcataacgttggagtcca agaattagactcatagggcccccaacatttaatatgtactgtgagtttgaaggtgttcta ttgttaattcctgctcttgatacatgacacgtactccgtgtttaaggcttcggactgact ttctttcataagttgagcaacgaaaatttcagaatcgataagttggattcactaactaat acggctgattgaaaactccactccggacctatatggtcgacctttatacgtaaccgatat aaaacttataggctggtatatcgagccttcctagcgcaatttcggatggggtttcttcta ctactcaacaacggaatagtctttgtttagtaaaccagagctcaggacgcccaatacgta ggagagcgctgtggagcatgtgtcattatggactggagcactcttaaatcactctgcgtg tgctaaacgatagatcataacatgtcctgagtaaattttcttgatacgtcgcaatatacc gttattagttaaacgttctcatccgtcatgcgtgaaatacggctgtcgtgctcagatata ctattagcgactcatctcgcctaacacgcacacgtataaactcggaatgactgccgctct tacatattagaaatacagactacaccacggaagcattgggtcattctcaaccgctgtata aaagatgattagtcttataataagattaccaaagaggcagaatcatgggtagtaaatcta ttattcaagtgattaccgtcgtgtaggcagggagtgaggacgagatggtactcaggacaa atattaaccggacgaagtggtttacgtcgtactttcactattagtagtaaatacaaggta acaccggggaatagtactaaatataatgatatctatcttcgggagaacgagtcgtctatt gctttgaacattctcaaggcgtaaaatgtgctgacttatagcatgatacaaccgattgtt acttttgtctattcaaaagattgaatagttttttatacaaaagccgcatacttatgacgg ctagtatacagtttcatcccctagcatcaatgctatggacagtattgaacttataggaaa ttcttctaatagggcaaatccgtcgtgatgcctattttttttcagtcacatcctcaaatg gcactagtattgtcgggatcccattaacaggctcaaccacgagctcacgcgaggacatgt agtccgtatctttaacgaagcgacagcgacagaactcccatggataaccaattataaggc ccgtaatcctctagacatcgtttaccaataaatccgctttctccgtaatcatgttgaata ccccagagtagtccagatgataaccgatgaaacacaagtctttctcaatgcacttacggt gaacttattaccgccaacgtagctcatcaaggttgcgacatctagttgtgtgtttgcgac gagcccagcgaacttcatcaactttcgtatattcaacgccttgtaattttactttaagac gcctggtgatgtagattcttagataatcagtttgttatcggctgtactttaccataattt cacaggtttcaggtcaagaagattatagctgtatatacagttccatgctcggtgcacaga aacgtgatcggataataatcaatcgcttatgtcgtctttaggcgtatccaatacatgccc cgataccgcagtgtatttcgacatgtaggtataccgtcgcatttgagctcgagtcaggac gtcagctagattagattccttaatagaatataccgacctctagtccgaactaaactatag ataacgccaacttcaggttaattgtctagtcgtctgtttgcagatgggattcttagatga gtgagtatcggccatattggttcgagcactttagtttttgatgcataggatatgcaatgt atagctgaaagtactttatctgtttcaaactcacattgattaaaccggtaaacctttaaa gactacaagaaaatattcagtgagggcaattttgtcaatcacaatcttccagctagagat acttcacaatttgtcttgaggctacgcaacattagacggattttcgcgttttattgaaat aatcgaggggcccaagagtatccatagttcattttgtaagatttctttacaggcttatta cagcttcttcagactcctacatgcttacgagttatatgctagcatgtgaacaatagatta atatacaggaaaacgtacattgagagagatgaccctacacagcgcaaccgttgagtactt tcattaaagggtaacgctctcgagacagcatccttaagatggccttattgtcaaatcatt tgcagaagtacgcaagatccctaaccaacgtagaagaatccctacaaacacatgagacgc ggtgaaaatagacagggtgttagtattcaatcttcggagtatcaatttcgccaatcttgg tgagaaagcataccctttcttcagagaaagaagatcaatcataacactatctttaacgag gtacgcacgcgcatcattacctgcctccatggatctttaggatagcggaaagtattggca gcgtattgtgatttcgttcctactttatcaatttcacattcatatacatgtcttttatca aaatcgccaataagataggatgagctatattagatgctagtagagttcgcgccaacatca tcgataggaatactcaggacagcgtgataggacttttcaatccctaatactctctataat tataactctctcttaagtttggaggcagtaacgcgctctatataatcagtttgctgcacc attcttcagcctctgatacatacaaataaattccacagcagtaagagggtttaattgaga catcttgggaacttaggattttactctaacatcaccgaaacgattattggataccgtacc taaacgaactttctcaaggcagtaatataggacatccgcaataacacaaatgctgcctcc ccaggagttatgtcttcctggaggctatatcttacacccactcactataggcaaactaaa gtttaaatgttgattgtctaaaaaaaagatagataagagttggccggcgtagcacatgcg aaagtgaatcgtaagctataattctctggacttgaagttctgtcctgttcctctgcaaga aacaaacttcctttaaagctatttacgacgcacatctcagcaagttataaacatgttgga agtttctagtcggaattcccaaagaacggatctatctaatgcattcctacatttttcctg tctgccgatggtgccatcctattcaaagaatttcttaaaagtagattaaatgggactttt aacaatgagtaaccttacgcctctaagggttcctcgagtgccatacaccagtcaggtccg agccacatacacggagaacattctaacatagcattctcaactcgatcatttgcaggttac ttctttcctatcctagtgctaaaaatcatacttgcaatcccatagcacggattaagaacc taagaaacaattcagtaaaacatgttcgaattcttggtatgggaacatcattgcagctat ggtctaacgcattaatgtttgggtacatcttccatcatataaacaggaagagtctgacga cagggagtgcttgcgatcatgtctatcattgtgaaatcaaattgtagctcacatgtcgtc tatgagagcgtgtatccgataagatttagaaaaatagaagtcgtataagatctcactgaa cttttgaatgaatgtgaagcatatatgatctgctttaataaaactttatccataggatac gtttccaaatcaattcaataattattagtcaaaatagataaggatgaacaacctgaaggc cgatcggacgtagaaagtggtcccatcactttgagttgatattgttgaaccacacgttat tatggttttcaaacagtctcaggatattgtatatacagataatccgataccagttgtctg acgcccctcttacgtaccccaccctttgtgacgtttaaagcagttgttcagtattttaaa ctaggcggcaactaatttggaaagaagcacagtggatatgtctaaattcttgttattcag gcctgaatttaatacaccgcatagttaacttcgcggtagagttgttcatcatgcctcctc taagctaccacttctatgatacaccaatagttgttctacggaatctgataattggccaag tcataaacttccgctgcgttcaacccccttgctcgaatatccaactcgaaaagacagcct tttggtgtccggaacaaatcagttacttcttttctgatgttaattctctgtggtcagata cagaccaaaaactccgcggatttaccatcctccaagaacaaatttgcatcaacatagcat tttggctacatattctaagtctcaatagtttaggttttcaactacattatcccaacatta ggattggaggaataatagctgggtaagtccccttgcgtctacaatcgactattttttatg aatatgcttctgccgcacctatggttattaaaaaagtcatgactttgaagaaccctgaaa agatagatgaatcaggtgtaatggcagcagccaaagagcatataattagcaacactctaa gaacattatagatatgatgatagcgatcgtcatgatgttatccggtcacaatagtagctt catcagctaattcgttttgccagtggtgacttgcgctggaagaatcgttatacggtccct tccctcttgatacggtgggggcttattcaaccgcgtggattgggttgtcatacttgcatt aaacgatgtaaaccatctagtagtcaactatactaaatcacaaaatagtgatcaatacat acccgcttcatggttttaaccatttaattgattaaagatattccgctaagaaccattatc tacctaaactgatcgccgtatcctagtagtttgaaatttgatgtaccgtaatgatcaacg aagtaaaacgttatattgtatgtagaataataggtcttggagctaaatgatgtgattggt agtgaagacttacccttacaactttaccggtttctcggaagaatatactagagaatcaat gcatgggctacataagcactttagtctaatgagataaaaaatacacgagtcttccatcat gaattttttgtcgaaaaactcgaacctggtaatttaaaccatatatctttatgtcgtcaa taactctcatatgttttatataacttcccaatcacgacttgtaactgcttgttcgactga gctgtttgagctatgaggccgggatccggttgagctacatctatttgctacaagaaaaat gaaagcacatttgttgggagttctggctacactcatagagaaataagtggcccgagtggg tgcggcctgcctccatattcaagtgtatcttaaaccaagtggttccaacgctcgcgctaa agaattaaagcctttatttcctccacggagtagcccgtaatccggttcgaaagagaccat tgaagttaattttcatatccagtgaagtttaggcacaagcatgtgttctgccacatgcct caaagcgctcttcaaccaagatatgattcatcctaacttcgatgaatgcgtctgtaacat aaatatagaaggaatgattcggcgagttaattttcgccttctccaacatggcatccctac gttcgttataaggaccatacatgtaggttttaaaggtttgcggttaatcgatatttacat catagaaattctatagtcaaatttacaagactctagatactcactcgttgcagccggcta ggaagcgctttgtaccttacttcccttttcgttgcgtaatatgaatttcatatagtaagt tcaaggcactcatacctccgtgaagagggtagatagactattaaagttgtttaatagtac gtattgatggaaatgacccgtaggagatttaccactcaatccacaagattcgctgctgtg cattatcaaaacagtgcatgtcgaaacatgggttgggtccttcaaacacgaatccaggta gagatacctttgcaattttt deps/regex-0.1.44/examples/shootout-regex-dna.rs0000644000175000001440000000412312541167521017567 0ustar users// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // contributed by TeXitoi // contributed by BurntSushi extern crate regex; use std::io::{self, Read}; use std::sync::Arc; use std::thread; macro_rules! regex { ($re:expr) => { ::regex::Regex::new($re).unwrap() } } fn main() { let mut seq = String::with_capacity(50 * (1 << 20)); io::stdin().read_to_string(&mut seq).unwrap(); let ilen = seq.len(); seq = regex!(">[^\n]*\n|\n").replace_all(&seq, ""); let clen = seq.len(); let seq_arc = Arc::new(seq.clone()); let variants = vec![ regex!("agggtaaa|tttaccct"), regex!("[cgt]gggtaaa|tttaccc[acg]"), regex!("a[act]ggtaaa|tttacc[agt]t"), regex!("ag[act]gtaaa|tttac[agt]ct"), regex!("agg[act]taaa|ttta[agt]cct"), regex!("aggg[acg]aaa|ttt[cgt]ccct"), regex!("agggt[cgt]aa|tt[acg]accct"), regex!("agggta[cgt]a|t[acg]taccct"), regex!("agggtaa[cgt]|[acg]ttaccct"), ]; let mut count_promises = vec![]; for i in 0..3 { let seq = seq_arc.clone(); let res = variants[i * 3..i * 3 + 3].to_vec(); count_promises.push(thread::spawn(move || { res.into_iter() .map(|re| (re.to_string(), re.find_iter(&seq).count())) .collect::>() })); } let substs = vec![ (regex!("B"), "(c|g|t)"), (regex!("D"), "(a|g|t)"), (regex!("H"), "(a|c|t)"), (regex!("K"), "(g|t)"), (regex!("M"), "(a|c)"), (regex!("N"), "(a|c|g|t)"), (regex!("R"), "(a|g)"), (regex!("S"), "(c|g)"), (regex!("V"), "(a|c|g)"), (regex!("W"), "(a|t)"), (regex!("Y"), "(c|t)"), ]; let mut seq = seq; for (re, replacement) in substs.into_iter() { seq = re.replace_all(&seq, replacement); } for promise in count_promises { for (re, count) in promise.join().unwrap() { println!("{} {}", re, count); } } println!("\n{}\n{}\n{}", ilen, clen, seq.len()); } deps/regex-0.1.44/.travis.yml0000644000175000001440000000277212545500662013771 0ustar userslanguage: rust rust: - 1.0.0 - beta - nightly sudo: false script: - cargo build --verbose - cargo test --verbose - ./run-shootout-test - cargo doc - cargo test --verbose --manifest-path=regex-syntax/Cargo.toml - cargo doc --verbose --manifest-path=regex-syntax/Cargo.toml - if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then cargo test --verbose --features pattern; cargo bench --verbose; travis_wait cargo test --verbose --manifest-path=regex_macros/Cargo.toml; travis_wait cargo bench --verbose --manifest-path=regex_macros/Cargo.toml; fi # - | # [ $TRAVIS_RUST_VERSION != nightly ] || ( # cargo test --verbose --features pattern && # cargo bench --verbose && # travis_wait cargo test --verbose --manifest-path=regex_macros/Cargo.toml && # travis_wait cargo bench --verbose --manifest-path=regex_macros/Cargo.toml # ) after_success: | [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && [ $TRAVIS_RUST_VERSION = nightly ] && echo '' > target/doc/index.html && pip install ghp-import --user $USER && $HOME/.local/bin/ghp-import -n target/doc && git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages env: global: secure: VvIrYRW/a8FmBA61hn1bDrqWwR92tANOT6PCeLYd9A9ViQrN07PE6uGsnd9iwr8itck10Ctl1mThZYUkK8BDFEmlvSxOFJ/Po5eRe6A1CYuFF40zizJ+3NllVkN20kwoQDe0kxwZVDGO9Yi1icHUrbRPWDfS+1tfobO/UT8Dlng= notifications: email: on_success: never deps/regex-0.1.44/README.md0000644000175000001440000000773312610502672013135 0ustar usersregex ===== A Rust library for parsing, compiling, and executing regular expressions. This particular implementation of regular expressions guarantees execution in linear time with respect to the size of the regular expression and search text. Much of the syntax and implementation is inspired by [RE2](https://github.com/google/re2). [![Build Status](https://travis-ci.org/rust-lang-nursery/regex.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/regex) [![Build status](https://ci.appveyor.com/api/projects/status/22g48bo866qr4u77?svg=true)](https://ci.appveyor.com/project/alexcrichton/regex) [![](http://meritbadge.herokuapp.com/regex)](https://crates.io/crates/regex) ### Documentation [Module documentation with examples](https://doc.rust-lang.org/regex). The module documentation also include a comprehensive description of the syntax supported. Documentation with examples for the various matching functions and iterators can be found on the [`Regex` type](https://doc.rust-lang.org/regex/regex/enum.Regex.html). ### Usage Add this to your `Cargo.toml`: ```toml [dependencies] regex = "0.1" ``` and this to your crate root: ```rust extern crate regex; ``` Here's a simple example that matches a date in YYYY-MM-DD format and prints the year, month and day: ```rust extern crate regex; use regex::Regex; fn main() { let re = Regex::new(r"(?x) (?P\d{4}) # the year - (?P\d{2}) # the month - (?P\d{2}) # the day ").unwrap(); let caps = re.captures("2010-03-14").unwrap(); assert_eq!("2010", caps.name("year").unwrap()); assert_eq!("03", caps.name("month").unwrap()); assert_eq!("14", caps.name("day").unwrap()); } ``` If you have lots of dates in text that you'd like to iterate over, then it's easy to adapt the above example with an iterator: ```rust extern crate regex; use regex::Regex; const TO_SEARCH: &'static str = " On 2010-03-14, foo happened. On 2014-10-14, bar happened. "; fn main() { let re = Regex::new(r"(\d{4})-(\d{2})-(\d{2})").unwrap(); for caps in re.captures_iter(TO_SEARCH) { // Note that all of the unwraps are actually OK for this regex // because the only way for the regex to match is if all of the // capture groups match. This is not true in general though! println!("year: {}, month: {}, day: {}", caps.at(1).unwrap(), caps.at(2).unwrap(), caps.at(3).unwrap()); } } ``` This example outputs: ``` year: 2010, month: 03, day: 14 year: 2014, month: 10, day: 14 ``` ### Usage: `regex!` compiler plugin The `regex!` compiler plugin will compile your regexes at compile time. **This only works with a nightly compiler.** The [documentation explains the trade offs](https://doc.rust-lang.org/regex/regex/index.html#the-regex!-macro). Here is a small example: ```rust #![feature(plugin)] #![plugin(regex_macros)] extern crate regex; fn main() { let re = regex!(r"(\d{4})-(\d{2})-(\d{2})"); let caps = re.captures("2010-03-14").unwrap(); assert_eq!("2010", caps.at(1).unwrap()); assert_eq!("03", caps.at(2).unwrap()); assert_eq!("14", caps.at(3).unwrap()); } ``` Notice that we never `unwrap` the result of `regex!`. This is because your *program* won't compile if the regex doesn't compile. (Try `regex!("(")`.) ### Usage: a regular expression parser This repository contains a crate that provides a well tested regular expression parser and abstract syntax. It provides no facilities for compilation or execution. This may be useful if you're implementing your own regex engine or otherwise need to do analysis on the syntax of a regular expression. It is otherwise not recommended for general use. [Documentation for `regex-syntax` with examples](https://doc.rust-lang.org/regex/regex_syntax/index.html). # License `regex` is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses. See LICENSE-APACHE, and LICENSE-MIT for details. deps/regex-0.1.44/.gitignore0000644000175000001440000000004312533412707013634 0ustar userstarget Cargo.lock bench-log .*.swp deps/regex-0.1.44/src/0000755000000000000000000000000012666635520013145 5ustar rootrootdeps/regex-0.1.44/src/testdata/0000755000000000000000000000000012666635520014756 5ustar rootrootdeps/regex-0.1.44/src/testdata/repetition.dat0000644000175000001440000001516012504652243017125 0ustar usersNOTE implicit vs. explicit repetitions : 2009-02-02 # Glenn Fowler # conforming matches (column 4) must match one of the following BREs # NOMATCH # (0,.)\((\(.\),\(.\))(?,?)(\2,\3)\)* # (0,.)\((\(.\),\(.\))(\2,\3)(?,?)\)* # i.e., each 3-tuple has two identical elements and one (?,?) E ((..)|(.)) NULL NOMATCH E ((..)|(.))((..)|(.)) NULL NOMATCH E ((..)|(.))((..)|(.))((..)|(.)) NULL NOMATCH E ((..)|(.)){1} NULL NOMATCH E ((..)|(.)){2} NULL NOMATCH E ((..)|(.)){3} NULL NOMATCH E ((..)|(.))* NULL (0,0) E ((..)|(.)) a (0,1)(0,1)(?,?)(0,1) E ((..)|(.))((..)|(.)) a NOMATCH E ((..)|(.))((..)|(.))((..)|(.)) a NOMATCH E ((..)|(.)){1} a (0,1)(0,1)(?,?)(0,1) E ((..)|(.)){2} a NOMATCH E ((..)|(.)){3} a NOMATCH E ((..)|(.))* a (0,1)(0,1)(?,?)(0,1) E ((..)|(.)) aa (0,2)(0,2)(0,2)(?,?) E ((..)|(.))((..)|(.)) aa (0,2)(0,1)(?,?)(0,1)(1,2)(?,?)(1,2) E ((..)|(.))((..)|(.))((..)|(.)) aa NOMATCH E ((..)|(.)){1} aa (0,2)(0,2)(0,2)(?,?) E ((..)|(.)){2} aa (0,2)(1,2)(?,?)(1,2) E ((..)|(.)){3} aa NOMATCH E ((..)|(.))* aa (0,2)(0,2)(0,2)(?,?) E ((..)|(.)) aaa (0,2)(0,2)(0,2)(?,?) E ((..)|(.))((..)|(.)) aaa (0,3)(0,2)(0,2)(?,?)(2,3)(?,?)(2,3) E ((..)|(.))((..)|(.))((..)|(.)) aaa (0,3)(0,1)(?,?)(0,1)(1,2)(?,?)(1,2)(2,3)(?,?)(2,3) E ((..)|(.)){1} aaa (0,2)(0,2)(0,2)(?,?) #E ((..)|(.)){2} aaa (0,3)(2,3)(?,?)(2,3) E ((..)|(.)){2} aaa (0,3)(2,3)(0,2)(2,3) RE2/Go E ((..)|(.)){3} aaa (0,3)(2,3)(?,?)(2,3) #E ((..)|(.))* aaa (0,3)(2,3)(?,?)(2,3) E ((..)|(.))* aaa (0,3)(2,3)(0,2)(2,3) RE2/Go E ((..)|(.)) aaaa (0,2)(0,2)(0,2)(?,?) E ((..)|(.))((..)|(.)) aaaa (0,4)(0,2)(0,2)(?,?)(2,4)(2,4)(?,?) E ((..)|(.))((..)|(.))((..)|(.)) aaaa (0,4)(0,2)(0,2)(?,?)(2,3)(?,?)(2,3)(3,4)(?,?)(3,4) E ((..)|(.)){1} aaaa (0,2)(0,2)(0,2)(?,?) E ((..)|(.)){2} aaaa (0,4)(2,4)(2,4)(?,?) #E ((..)|(.)){3} aaaa (0,4)(3,4)(?,?)(3,4) E ((..)|(.)){3} aaaa (0,4)(3,4)(0,2)(3,4) RE2/Go E ((..)|(.))* aaaa (0,4)(2,4)(2,4)(?,?) E ((..)|(.)) aaaaa (0,2)(0,2)(0,2)(?,?) E ((..)|(.))((..)|(.)) aaaaa (0,4)(0,2)(0,2)(?,?)(2,4)(2,4)(?,?) E ((..)|(.))((..)|(.))((..)|(.)) aaaaa (0,5)(0,2)(0,2)(?,?)(2,4)(2,4)(?,?)(4,5)(?,?)(4,5) E ((..)|(.)){1} aaaaa (0,2)(0,2)(0,2)(?,?) E ((..)|(.)){2} aaaaa (0,4)(2,4)(2,4)(?,?) #E ((..)|(.)){3} aaaaa (0,5)(4,5)(?,?)(4,5) E ((..)|(.)){3} aaaaa (0,5)(4,5)(2,4)(4,5) RE2/Go #E ((..)|(.))* aaaaa (0,5)(4,5)(?,?)(4,5) E ((..)|(.))* aaaaa (0,5)(4,5)(2,4)(4,5) RE2/Go E ((..)|(.)) aaaaaa (0,2)(0,2)(0,2)(?,?) E ((..)|(.))((..)|(.)) aaaaaa (0,4)(0,2)(0,2)(?,?)(2,4)(2,4)(?,?) E ((..)|(.))((..)|(.))((..)|(.)) aaaaaa (0,6)(0,2)(0,2)(?,?)(2,4)(2,4)(?,?)(4,6)(4,6)(?,?) E ((..)|(.)){1} aaaaaa (0,2)(0,2)(0,2)(?,?) E ((..)|(.)){2} aaaaaa (0,4)(2,4)(2,4)(?,?) E ((..)|(.)){3} aaaaaa (0,6)(4,6)(4,6)(?,?) E ((..)|(.))* aaaaaa (0,6)(4,6)(4,6)(?,?) NOTE additional repetition tests graciously provided by Chris Kuklewicz www.haskell.org 2009-02-02 # These test a bug in OS X / FreeBSD / NetBSD, and libtree. # Linux/GLIBC gets the {8,} and {8,8} wrong. :HA#100:E X(.?){0,}Y X1234567Y (0,9)(7,8) :HA#101:E X(.?){1,}Y X1234567Y (0,9)(7,8) :HA#102:E X(.?){2,}Y X1234567Y (0,9)(7,8) :HA#103:E X(.?){3,}Y X1234567Y (0,9)(7,8) :HA#104:E X(.?){4,}Y X1234567Y (0,9)(7,8) :HA#105:E X(.?){5,}Y X1234567Y (0,9)(7,8) :HA#106:E X(.?){6,}Y X1234567Y (0,9)(7,8) :HA#107:E X(.?){7,}Y X1234567Y (0,9)(7,8) :HA#108:E X(.?){8,}Y X1234567Y (0,9)(8,8) #:HA#110:E X(.?){0,8}Y X1234567Y (0,9)(7,8) :HA#110:E X(.?){0,8}Y X1234567Y (0,9)(8,8) RE2/Go #:HA#111:E X(.?){1,8}Y X1234567Y (0,9)(7,8) :HA#111:E X(.?){1,8}Y X1234567Y (0,9)(8,8) RE2/Go #:HA#112:E X(.?){2,8}Y X1234567Y (0,9)(7,8) :HA#112:E X(.?){2,8}Y X1234567Y (0,9)(8,8) RE2/Go #:HA#113:E X(.?){3,8}Y X1234567Y (0,9)(7,8) :HA#113:E X(.?){3,8}Y X1234567Y (0,9)(8,8) RE2/Go #:HA#114:E X(.?){4,8}Y X1234567Y (0,9)(7,8) :HA#114:E X(.?){4,8}Y X1234567Y (0,9)(8,8) RE2/Go #:HA#115:E X(.?){5,8}Y X1234567Y (0,9)(7,8) :HA#115:E X(.?){5,8}Y X1234567Y (0,9)(8,8) RE2/Go #:HA#116:E X(.?){6,8}Y X1234567Y (0,9)(7,8) :HA#116:E X(.?){6,8}Y X1234567Y (0,9)(8,8) RE2/Go #:HA#117:E X(.?){7,8}Y X1234567Y (0,9)(7,8) :HA#117:E X(.?){7,8}Y X1234567Y (0,9)(8,8) RE2/Go :HA#118:E X(.?){8,8}Y X1234567Y (0,9)(8,8) # These test a fixed bug in my regex-tdfa that did not keep the expanded # form properly grouped, so right association did the wrong thing with # these ambiguous patterns (crafted just to test my code when I became # suspicious of my implementation). The first subexpression should use # "ab" then "a" then "bcd". # OS X / FreeBSD / NetBSD badly fail many of these, with impossible # results like (0,6)(4,5)(6,6). :HA#260:E (a|ab|c|bcd){0,}(d*) ababcd (0,1)(0,1)(1,1) :HA#261:E (a|ab|c|bcd){1,}(d*) ababcd (0,1)(0,1)(1,1) :HA#262:E (a|ab|c|bcd){2,}(d*) ababcd (0,6)(3,6)(6,6) :HA#263:E (a|ab|c|bcd){3,}(d*) ababcd (0,6)(3,6)(6,6) :HA#264:E (a|ab|c|bcd){4,}(d*) ababcd NOMATCH :HA#265:E (a|ab|c|bcd){0,10}(d*) ababcd (0,1)(0,1)(1,1) :HA#266:E (a|ab|c|bcd){1,10}(d*) ababcd (0,1)(0,1)(1,1) :HA#267:E (a|ab|c|bcd){2,10}(d*) ababcd (0,6)(3,6)(6,6) :HA#268:E (a|ab|c|bcd){3,10}(d*) ababcd (0,6)(3,6)(6,6) :HA#269:E (a|ab|c|bcd){4,10}(d*) ababcd NOMATCH :HA#270:E (a|ab|c|bcd)*(d*) ababcd (0,1)(0,1)(1,1) :HA#271:E (a|ab|c|bcd)+(d*) ababcd (0,1)(0,1)(1,1) # The above worked on Linux/GLIBC but the following often fail. # They also trip up OS X / FreeBSD / NetBSD: #:HA#280:E (ab|a|c|bcd){0,}(d*) ababcd (0,6)(3,6)(6,6) :HA#280:E (ab|a|c|bcd){0,}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go #:HA#281:E (ab|a|c|bcd){1,}(d*) ababcd (0,6)(3,6)(6,6) :HA#281:E (ab|a|c|bcd){1,}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go #:HA#282:E (ab|a|c|bcd){2,}(d*) ababcd (0,6)(3,6)(6,6) :HA#282:E (ab|a|c|bcd){2,}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go #:HA#283:E (ab|a|c|bcd){3,}(d*) ababcd (0,6)(3,6)(6,6) :HA#283:E (ab|a|c|bcd){3,}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go :HA#284:E (ab|a|c|bcd){4,}(d*) ababcd NOMATCH #:HA#285:E (ab|a|c|bcd){0,10}(d*) ababcd (0,6)(3,6)(6,6) :HA#285:E (ab|a|c|bcd){0,10}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go #:HA#286:E (ab|a|c|bcd){1,10}(d*) ababcd (0,6)(3,6)(6,6) :HA#286:E (ab|a|c|bcd){1,10}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go #:HA#287:E (ab|a|c|bcd){2,10}(d*) ababcd (0,6)(3,6)(6,6) :HA#287:E (ab|a|c|bcd){2,10}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go #:HA#288:E (ab|a|c|bcd){3,10}(d*) ababcd (0,6)(3,6)(6,6) :HA#288:E (ab|a|c|bcd){3,10}(d*) ababcd (0,6)(4,5)(5,6) RE2/Go :HA#289:E (ab|a|c|bcd){4,10}(d*) ababcd NOMATCH #:HA#290:E (ab|a|c|bcd)*(d*) ababcd (0,6)(3,6)(6,6) :HA#290:E (ab|a|c|bcd)*(d*) ababcd (0,6)(4,5)(5,6) RE2/Go #:HA#291:E (ab|a|c|bcd)+(d*) ababcd (0,6)(3,6)(6,6) :HA#291:E (ab|a|c|bcd)+(d*) ababcd (0,6)(4,5)(5,6) RE2/Go deps/regex-0.1.44/src/testdata/README0000644000175000001440000000134012504652243015124 0ustar usersTest data was taken from the Go distribution, which was in turn taken from the testregex test suite: http://www2.research.att.com/~astopen/testregex/testregex.html The LICENSE in this directory corresponds to the LICENSE that the data was released under. The tests themselves were modified for RE2/Go. A couple were modified further by me (Andrew Gallant) (only in repetition.dat) so that RE2/Go would pass them. (Yes, it seems like RE2/Go includes failing test cases.) This may or may not have been a bad idea, but I think being consistent with an established Regex library is worth something. Note that these files are read by 'scripts/regex-match-tests.py' and turned into Rust tests found in 'regex_macros/tests/matches.rs'. deps/regex-0.1.44/src/testdata/basic.dat0000644000175000001440000002103412504652243016021 0ustar usersNOTE all standard compliant implementations should pass these : 2002-05-31 BE abracadabra$ abracadabracadabra (7,18) BE a...b abababbb (2,7) BE XXXXXX ..XXXXXX (2,8) E \) () (1,2) BE a] a]a (0,2) B } } (0,1) E \} } (0,1) BE \] ] (0,1) B ] ] (0,1) E ] ] (0,1) B { { (0,1) B } } (0,1) BE ^a ax (0,1) BE \^a a^a (1,3) BE a\^ a^ (0,2) BE a$ aa (1,2) BE a\$ a$ (0,2) BE ^$ NULL (0,0) E $^ NULL (0,0) E a($) aa (1,2)(2,2) E a*(^a) aa (0,1)(0,1) E (..)*(...)* a (0,0) E (..)*(...)* abcd (0,4)(2,4) E (ab|a)(bc|c) abc (0,3)(0,2)(2,3) E (ab)c|abc abc (0,3)(0,2) E a{0}b ab (1,2) E (a*)(b?)(b+)b{3} aaabbbbbbb (0,10)(0,3)(3,4)(4,7) E (a*)(b{0,1})(b{1,})b{3} aaabbbbbbb (0,10)(0,3)(3,4)(4,7) E a{9876543210} NULL BADBR E ((a|a)|a) a (0,1)(0,1)(0,1) E (a*)(a|aa) aaaa (0,4)(0,3)(3,4) E a*(a.|aa) aaaa (0,4)(2,4) E a(b)|c(d)|a(e)f aef (0,3)(?,?)(?,?)(1,2) E (a|b)?.* b (0,1)(0,1) E (a|b)c|a(b|c) ac (0,2)(0,1) E (a|b)c|a(b|c) ab (0,2)(?,?)(1,2) E (a|b)*c|(a|ab)*c abc (0,3)(1,2) E (a|b)*c|(a|ab)*c xc (1,2) E (.a|.b).*|.*(.a|.b) xa (0,2)(0,2) E a?(ab|ba)ab abab (0,4)(0,2) E a?(ac{0}b|ba)ab abab (0,4)(0,2) E ab|abab abbabab (0,2) E aba|bab|bba baaabbbaba (5,8) E aba|bab baaabbbaba (6,9) E (aa|aaa)*|(a|aaaaa) aa (0,2)(0,2) E (a.|.a.)*|(a|.a...) aa (0,2)(0,2) E ab|a xabc (1,3) E ab|a xxabc (2,4) Ei (Ab|cD)* aBcD (0,4)(2,4) BE [^-] --a (2,3) BE [a-]* --a (0,3) BE [a-m-]* --amoma-- (0,4) E :::1:::0:|:::1:1:0: :::0:::1:::1:::0: (8,17) E :::1:::0:|:::1:1:1: :::0:::1:::1:::0: (8,17) {E [[:upper:]] A (0,1) [[]] not supported E [[:lower:]]+ `az{ (1,3) E [[:upper:]]+ @AZ[ (1,3) # No collation in Go #BE [[-]] [[-]] (2,4) #BE [[.NIL.]] NULL ECOLLATE #BE [[=aleph=]] NULL ECOLLATE } BE$ \n \n (0,1) BEn$ \n \n (0,1) BE$ [^a] \n (0,1) BE$ \na \na (0,2) E (a)(b)(c) abc (0,3)(0,1)(1,2)(2,3) BE xxx xxx (0,3) E1 (^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$) feb 6, (0,6) E1 (^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$) 2/7 (0,3) E1 (^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$) feb 1,Feb 6 (5,11) E3 ((((((((((((((((((((((((((((((x)))))))))))))))))))))))))))))) x (0,1)(0,1)(0,1) E3 ((((((((((((((((((((((((((((((x))))))))))))))))))))))))))))))* xx (0,2)(1,2)(1,2) E a?(ab|ba)* ababababababababababababababababababababababababababababababababababababababababa (0,81)(79,81) E abaa|abbaa|abbbaa|abbbbaa ababbabbbabbbabbbbabbbbaa (18,25) E abaa|abbaa|abbbaa|abbbbaa ababbabbbabbbabbbbabaa (18,22) E aaac|aabc|abac|abbc|baac|babc|bbac|bbbc baaabbbabac (7,11) BE$ .* \x01\x7f (0,2) E aaaa|bbbb|cccc|ddddd|eeeeee|fffffff|gggg|hhhh|iiiii|jjjjj|kkkkk|llll XaaaXbbbXcccXdddXeeeXfffXgggXhhhXiiiXjjjXkkkXlllXcbaXaaaa (53,57) L aaaa\nbbbb\ncccc\nddddd\neeeeee\nfffffff\ngggg\nhhhh\niiiii\njjjjj\nkkkkk\nllll XaaaXbbbXcccXdddXeeeXfffXgggXhhhXiiiXjjjXkkkXlllXcbaXaaaa NOMATCH E a*a*a*a*a*b aaaaaaaaab (0,10) BE ^ NULL (0,0) BE $ NULL (0,0) BE ^$ NULL (0,0) BE ^a$ a (0,1) BE abc abc (0,3) BE abc xabcy (1,4) BE abc ababc (2,5) BE ab*c abc (0,3) BE ab*bc abc (0,3) BE ab*bc abbc (0,4) BE ab*bc abbbbc (0,6) E ab+bc abbc (0,4) E ab+bc abbbbc (0,6) E ab?bc abbc (0,4) E ab?bc abc (0,3) E ab?c abc (0,3) BE ^abc$ abc (0,3) BE ^abc abcc (0,3) BE abc$ aabc (1,4) BE ^ abc (0,0) BE $ abc (3,3) BE a.c abc (0,3) BE a.c axc (0,3) BE a.*c axyzc (0,5) BE a[bc]d abd (0,3) BE a[b-d]e ace (0,3) BE a[b-d] aac (1,3) BE a[-b] a- (0,2) BE a[b-] a- (0,2) BE a] a] (0,2) BE a[]]b a]b (0,3) BE a[^bc]d aed (0,3) BE a[^-b]c adc (0,3) BE a[^]b]c adc (0,3) E ab|cd abc (0,2) E ab|cd abcd (0,2) E a\(b a(b (0,3) E a\(*b ab (0,2) E a\(*b a((b (0,4) E ((a)) abc (0,1)(0,1)(0,1) E (a)b(c) abc (0,3)(0,1)(2,3) E a+b+c aabbabc (4,7) E a* aaa (0,3) #E (a*)* - (0,0)(0,0) E (a*)* - (0,0)(?,?) RE2/Go E (a*)+ - (0,0)(0,0) #E (a*|b)* - (0,0)(0,0) E (a*|b)* - (0,0)(?,?) RE2/Go E (a+|b)* ab (0,2)(1,2) E (a+|b)+ ab (0,2)(1,2) E (a+|b)? ab (0,1)(0,1) BE [^ab]* cde (0,3) #E (^)* - (0,0)(0,0) E (^)* - (0,0)(?,?) RE2/Go BE a* NULL (0,0) E ([abc])*d abbbcd (0,6)(4,5) E ([abc])*bcd abcd (0,4)(0,1) E a|b|c|d|e e (0,1) E (a|b|c|d|e)f ef (0,2)(0,1) #E ((a*|b))* - (0,0)(0,0)(0,0) E ((a*|b))* - (0,0)(?,?)(?,?) RE2/Go BE abcd*efg abcdefg (0,7) BE ab* xabyabbbz (1,3) BE ab* xayabbbz (1,2) E (ab|cd)e abcde (2,5)(2,4) BE [abhgefdc]ij hij (0,3) E (a|b)c*d abcd (1,4)(1,2) E (ab|ab*)bc abc (0,3)(0,1) E a([bc]*)c* abc (0,3)(1,3) E a([bc]*)(c*d) abcd (0,4)(1,3)(3,4) E a([bc]+)(c*d) abcd (0,4)(1,3)(3,4) E a([bc]*)(c+d) abcd (0,4)(1,2)(2,4) E a[bcd]*dcdcde adcdcde (0,7) E (ab|a)b*c abc (0,3)(0,2) E ((a)(b)c)(d) abcd (0,4)(0,3)(0,1)(1,2)(3,4) BE [A-Za-z_][A-Za-z0-9_]* alpha (0,5) E ^a(bc+|b[eh])g|.h$ abh (1,3) E (bc+d$|ef*g.|h?i(j|k)) effgz (0,5)(0,5) E (bc+d$|ef*g.|h?i(j|k)) ij (0,2)(0,2)(1,2) E (bc+d$|ef*g.|h?i(j|k)) reffgz (1,6)(1,6) E (((((((((a))))))))) a (0,1)(0,1)(0,1)(0,1)(0,1)(0,1)(0,1)(0,1)(0,1)(0,1) BE multiple words multiple words yeah (0,14) E (.*)c(.*) abcde (0,5)(0,2)(3,5) BE abcd abcd (0,4) E a(bc)d abcd (0,4)(1,3) E a[-]?c ac (0,3) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Qaddafi (0,15)(?,?)(10,12) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Mo'ammar Gadhafi (0,16)(?,?)(11,13) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Kaddafi (0,15)(?,?)(10,12) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Qadhafi (0,15)(?,?)(10,12) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Gadafi (0,14)(?,?)(10,11) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Mu'ammar Qadafi (0,15)(?,?)(11,12) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Moamar Gaddafi (0,14)(?,?)(9,11) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Mu'ammar Qadhdhafi (0,18)(?,?)(13,15) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Khaddafi (0,16)(?,?)(11,13) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Ghaddafy (0,16)(?,?)(11,13) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Ghadafi (0,15)(?,?)(11,12) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Ghaddafi (0,16)(?,?)(11,13) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muamar Kaddafi (0,14)(?,?)(9,11) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Quathafi (0,16)(?,?)(11,13) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Muammar Gheddafi (0,16)(?,?)(11,13) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Moammar Khadafy (0,15)(?,?)(11,12) E M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] Moammar Qudhafi (0,15)(?,?)(10,12) E a+(b|c)*d+ aabcdd (0,6)(3,4) E ^.+$ vivi (0,4) E ^(.+)$ vivi (0,4)(0,4) E ^([^!.]+).att.com!(.+)$ gryphon.att.com!eby (0,19)(0,7)(16,19) E ^([^!]+!)?([^!]+)$ bas (0,3)(?,?)(0,3) E ^([^!]+!)?([^!]+)$ bar!bas (0,7)(0,4)(4,7) E ^([^!]+!)?([^!]+)$ foo!bas (0,7)(0,4)(4,7) E ^.+!([^!]+!)([^!]+)$ foo!bar!bas (0,11)(4,8)(8,11) E ((foo)|(bar))!bas bar!bas (0,7)(0,3)(?,?)(0,3) E ((foo)|(bar))!bas foo!bar!bas (4,11)(4,7)(?,?)(4,7) E ((foo)|(bar))!bas foo!bas (0,7)(0,3)(0,3) E ((foo)|bar)!bas bar!bas (0,7)(0,3) E ((foo)|bar)!bas foo!bar!bas (4,11)(4,7) E ((foo)|bar)!bas foo!bas (0,7)(0,3)(0,3) E (foo|(bar))!bas bar!bas (0,7)(0,3)(0,3) E (foo|(bar))!bas foo!bar!bas (4,11)(4,7)(4,7) E (foo|(bar))!bas foo!bas (0,7)(0,3) E (foo|bar)!bas bar!bas (0,7)(0,3) E (foo|bar)!bas foo!bar!bas (4,11)(4,7) E (foo|bar)!bas foo!bas (0,7)(0,3) E ^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$ foo!bar!bas (0,11)(0,11)(?,?)(?,?)(4,8)(8,11) E ^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$ bas (0,3)(?,?)(0,3) E ^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$ bar!bas (0,7)(0,4)(4,7) E ^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$ foo!bar!bas (0,11)(?,?)(?,?)(4,8)(8,11) E ^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$ foo!bas (0,7)(0,4)(4,7) E ^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$ bas (0,3)(0,3)(?,?)(0,3) E ^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$ bar!bas (0,7)(0,7)(0,4)(4,7) E ^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$ foo!bar!bas (0,11)(0,11)(?,?)(?,?)(4,8)(8,11) E ^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$ foo!bas (0,7)(0,7)(0,4)(4,7) E .*(/XXX).* /XXX (0,4)(0,4) E .*(\\XXX).* \XXX (0,4)(0,4) E \\XXX \XXX (0,4) E .*(/000).* /000 (0,4)(0,4) E .*(\\000).* \000 (0,4)(0,4) E \\000 \000 (0,4) deps/regex-0.1.44/src/testdata/LICENSE0000644000175000001440000000220412504652243015251 0ustar usersThe following license covers testregex.c and all associated test data. Permission is hereby granted, free of charge, to any person obtaining a copy of THIS SOFTWARE FILE (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following disclaimer: THIS SOFTWARE IS PROVIDED BY AT&T ``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 AT&T 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. deps/regex-0.1.44/src/testdata/nullsubexpr.dat0000644000175000001440000000404612504652243017327 0ustar usersNOTE null subexpression matches : 2002-06-06 E (a*)* a (0,1)(0,1) #E SAME x (0,0)(0,0) E SAME x (0,0)(?,?) RE2/Go E SAME aaaaaa (0,6)(0,6) E SAME aaaaaax (0,6)(0,6) E (a*)+ a (0,1)(0,1) E SAME x (0,0)(0,0) E SAME aaaaaa (0,6)(0,6) E SAME aaaaaax (0,6)(0,6) E (a+)* a (0,1)(0,1) E SAME x (0,0) E SAME aaaaaa (0,6)(0,6) E SAME aaaaaax (0,6)(0,6) E (a+)+ a (0,1)(0,1) E SAME x NOMATCH E SAME aaaaaa (0,6)(0,6) E SAME aaaaaax (0,6)(0,6) E ([a]*)* a (0,1)(0,1) #E SAME x (0,0)(0,0) E SAME x (0,0)(?,?) RE2/Go E SAME aaaaaa (0,6)(0,6) E SAME aaaaaax (0,6)(0,6) E ([a]*)+ a (0,1)(0,1) E SAME x (0,0)(0,0) E SAME aaaaaa (0,6)(0,6) E SAME aaaaaax (0,6)(0,6) E ([^b]*)* a (0,1)(0,1) #E SAME b (0,0)(0,0) E SAME b (0,0)(?,?) RE2/Go E SAME aaaaaa (0,6)(0,6) E SAME aaaaaab (0,6)(0,6) E ([ab]*)* a (0,1)(0,1) E SAME aaaaaa (0,6)(0,6) E SAME ababab (0,6)(0,6) E SAME bababa (0,6)(0,6) E SAME b (0,1)(0,1) E SAME bbbbbb (0,6)(0,6) E SAME aaaabcde (0,5)(0,5) E ([^a]*)* b (0,1)(0,1) E SAME bbbbbb (0,6)(0,6) #E SAME aaaaaa (0,0)(0,0) E SAME aaaaaa (0,0)(?,?) RE2/Go E ([^ab]*)* ccccxx (0,6)(0,6) #E SAME ababab (0,0)(0,0) E SAME ababab (0,0)(?,?) RE2/Go E ((z)+|a)* zabcde (0,2)(1,2) #{E a+? aaaaaa (0,1) no *? +? mimimal match ops #E (a) aaa (0,1)(0,1) #E (a*?) aaa (0,0)(0,0) #E (a)*? aaa (0,0) #E (a*?)*? aaa (0,0) #} B \(a*\)*\(x\) x (0,1)(0,0)(0,1) B \(a*\)*\(x\) ax (0,2)(0,1)(1,2) B \(a*\)*\(x\) axa (0,2)(0,1)(1,2) B \(a*\)*\(x\)\(\1\) x (0,1)(0,0)(0,1)(1,1) B \(a*\)*\(x\)\(\1\) ax (0,2)(1,1)(1,2)(2,2) B \(a*\)*\(x\)\(\1\) axa (0,3)(0,1)(1,2)(2,3) B \(a*\)*\(x\)\(\1\)\(x\) axax (0,4)(0,1)(1,2)(2,3)(3,4) B \(a*\)*\(x\)\(\1\)\(x\) axxa (0,3)(1,1)(1,2)(2,2)(2,3) #E (a*)*(x) x (0,1)(0,0)(0,1) E (a*)*(x) x (0,1)(?,?)(0,1) RE2/Go E (a*)*(x) ax (0,2)(0,1)(1,2) E (a*)*(x) axa (0,2)(0,1)(1,2) E (a*)+(x) x (0,1)(0,0)(0,1) E (a*)+(x) ax (0,2)(0,1)(1,2) E (a*)+(x) axa (0,2)(0,1)(1,2) E (a*){2}(x) x (0,1)(0,0)(0,1) E (a*){2}(x) ax (0,2)(1,1)(1,2) E (a*){2}(x) axa (0,2)(1,1)(1,2) deps/regex-0.1.44/src/lib.rs0000644000175000001440000003735012627150670013564 0ustar users// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! This crate provides a native implementation of regular expressions that is //! heavily based on RE2 both in syntax and in implementation. Notably, //! backreferences and arbitrary lookahead/lookbehind assertions are not //! provided. In return, regular expression searching provided by this package //! has excellent worst-case performance. The specific syntax supported is //! documented further down. //! //! This crate's documentation provides some simple examples, describes Unicode //! support and exhaustively lists the supported syntax. For more specific //! details on the API, please see the documentation for the `Regex` type. //! //! # Usage //! //! This crate is [on crates.io](https://crates.io/crates/regex) and can be //! used by adding `regex` to your dependencies in your project's `Cargo.toml`. //! //! ```toml //! [dependencies] //! regex = "0.1" //! ``` //! //! and this to your crate root: //! //! ```rust //! extern crate regex; //! ``` //! //! # First example: find a date //! //! General use of regular expressions in this package involves compiling an //! expression and then using it to search, split or replace text. For example, //! to confirm that some text resembles a date: //! //! ```rust //! use regex::Regex; //! let re = Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap(); //! assert!(re.is_match("2014-01-01")); //! ``` //! //! Notice the use of the `^` and `$` anchors. In this crate, every expression //! is executed with an implicit `.*?` at the beginning and end, which allows //! it to match anywhere in the text. Anchors can be used to ensure that the //! full text matches an expression. //! //! This example also demonstrates the utility of //! [raw strings](https://doc.rust-lang.org/stable/reference.html#raw-string-literals) //! in Rust, which //! are just like regular strings except they are prefixed with an `r` and do //! not process any escape sequences. For example, `"\\d"` is the same //! expression as `r"\d"`. //! //! # The `regex!` macro //! //! Rust's compile-time meta-programming facilities provide a way to write a //! `regex!` macro which compiles regular expressions *when your program //! compiles*. Said differently, if you only use `regex!` to build regular //! expressions in your program, then your program cannot compile with an //! invalid regular expression. Moreover, the `regex!` macro compiles the //! given expression to native Rust code, which ideally makes it faster. //! Unfortunately (or fortunately), the dynamic implementation has had a lot //! more optimization work put into it currently, so it is faster than //! the `regex!` macro in most cases. //! //! To use the `regex!` macro, you must add `regex_macros` to your dependencies //! in your project's `Cargo.toml`: //! //! ```toml //! [dependencies] //! regex = "0.1.8" //! regex_macros = "0.1.8" //! ``` //! //! and then enable the `plugin` feature and import the `regex_macros` crate as //! a syntax extension: //! //! ```ignore //! #![feature(plugin)] //! #![plugin(regex_macros)] //! extern crate regex; //! //! fn main() { //! let re = regex!(r"^\d{4}-\d{2}-\d{2}$"); //! assert!(re.is_match("2014-01-01")); //! } //! ``` //! //! There are a few things worth mentioning about using the `regex!` macro. //! Firstly, the `regex!` macro *only* accepts string *literals*. //! Secondly, the `regex` crate *must* be linked with the name `regex` since //! the generated code depends on finding symbols in the `regex` crate. //! //! One downside of using the `regex!` macro is that it can increase the //! size of your program's binary since it generates specialized Rust code. //! The extra size probably won't be significant for a small number of //! expressions, but 100+ calls to `regex!` will probably result in a //! noticeably bigger binary. //! //! **NOTE**: This is implemented using a compiler plugin, which is not //! available on the Rust 1.0 beta/stable channels. Therefore, you'll only //! be able to use `regex!` on the nightlies. //! //! # Example: iterating over capture groups //! //! This crate provides convenient iterators for matching an expression //! repeatedly against a search string to find successive non-overlapping //! matches. For example, to find all dates in a string and be able to access //! them by their component pieces: //! //! ```rust //! # extern crate regex; use regex::Regex; //! # fn main() { //! let re = Regex::new(r"(\d{4})-(\d{2})-(\d{2})").unwrap(); //! let text = "2012-03-14, 2013-01-01 and 2014-07-05"; //! for cap in re.captures_iter(text) { //! println!("Month: {} Day: {} Year: {}", //! cap.at(2).unwrap_or(""), cap.at(3).unwrap_or(""), //! cap.at(1).unwrap_or("")); //! } //! // Output: //! // Month: 03 Day: 14 Year: 2012 //! // Month: 01 Day: 01 Year: 2013 //! // Month: 07 Day: 05 Year: 2014 //! # } //! ``` //! //! Notice that the year is in the capture group indexed at `1`. This is //! because the *entire match* is stored in the capture group at index `0`. //! //! # Example: replacement with named capture groups //! //! Building on the previous example, perhaps we'd like to rearrange the date //! formats. This can be done with text replacement. But to make the code //! clearer, we can *name* our capture groups and use those names as variables //! in our replacement text: //! //! ```rust //! # extern crate regex; use regex::Regex; //! # fn main() { //! let re = Regex::new(r"(?P\d{4})-(?P\d{2})-(?P\d{2})").unwrap(); //! let before = "2012-03-14, 2013-01-01 and 2014-07-05"; //! let after = re.replace_all(before, "$m/$d/$y"); //! assert_eq!(after, "03/14/2012, 01/01/2013 and 07/05/2014"); //! # } //! ``` //! //! The `replace` methods are actually polymorphic in the replacement, which //! provides more flexibility than is seen here. (See the documentation for //! `Regex::replace` for more details.) //! //! Note that if your regex gets complicated, you can use the `x` flag to //! enable insigificant whitespace mode, which also lets you write comments: //! //! ```rust //! # extern crate regex; use regex::Regex; //! # fn main() { //! let re = Regex::new(r"(?x) //! (?P\d{4}) # the year //! - //! (?P\d{2}) # the month //! - //! (?P\d{2}) # the day //! ").unwrap(); //! let before = "2012-03-14, 2013-01-01 and 2014-07-05"; //! let after = re.replace_all(before, "$m/$d/$y"); //! assert_eq!(after, "03/14/2012, 01/01/2013 and 07/05/2014"); //! # } //! ``` //! //! # Pay for what you use //! //! With respect to searching text with a regular expression, there are three //! questions that can be asked: //! //! 1. Does the text match this expression? //! 2. If so, where does it match? //! 3. Where are the submatches? //! //! Generally speaking, this crate could provide a function to answer only #3, //! which would subsume #1 and #2 automatically. However, it can be //! significantly more expensive to compute the location of submatches, so it's //! best not to do it if you don't need to. //! //! Therefore, only use what you need. For example, don't use `find` if you //! only need to test if an expression matches a string. (Use `is_match` //! instead.) //! //! # Unicode //! //! This implementation executes regular expressions **only** on sequences of //! Unicode scalar values while exposing match locations as byte indices into //! the search string. //! //! Currently, only simple case folding is supported. Namely, when matching //! case-insensitively, the characters are first mapped using the //! [simple case folding](ftp://ftp.unicode.org/Public/UNIDATA/CaseFolding.txt) //! mapping. //! //! Regular expressions themselves are also **only** interpreted as a sequence //! of Unicode scalar values. This means you can use Unicode characters //! directly in your expression: //! //! ```rust //! # extern crate regex; use regex::Regex; //! # fn main() { //! let re = Regex::new(r"(?i)Δ+").unwrap(); //! assert_eq!(re.find("ΔδΔ"), Some((0, 6))); //! # } //! ``` //! //! Finally, Unicode general categories and scripts are available as character //! classes. For example, you can match a sequence of numerals, Greek or //! Cherokee letters: //! //! ```rust //! # extern crate regex; use regex::Regex; //! # fn main() { //! let re = Regex::new(r"[\pN\p{Greek}\p{Cherokee}]+").unwrap(); //! assert_eq!(re.find("abcΔᎠβⅠᏴγδⅡxyz"), Some((3, 23))); //! # } //! ``` //! //! # Syntax //! //! The syntax supported in this crate is almost in an exact correspondence //! with the syntax supported by RE2. It is documented below. //! //! Note that the regular expression parser and abstract syntax are exposed in //! a separate crate, //! [`regex-syntax`](../regex_syntax/index.html). //! //! ## Matching one character //! //!

    //! .           any character except new line (includes new line with s flag)
    //! [xyz]       A character class matching either x, y or z.
    //! [^xyz]      A character class matching any character except x, y and z.
    //! [a-z]       A character class matching any character in range a-z.
    //! \d          digit (\p{Nd})
    //! \D          not digit
    //! [:alpha:]   ASCII character class ([A-Za-z])
    //! [:^alpha:]  Negated ASCII character class ([^A-Za-z])
    //! \pN         One-letter name Unicode character class
    //! \p{Greek}   Unicode character class (general category or script)
    //! \PN         Negated one-letter name Unicode character class
    //! \P{Greek}   negated Unicode character class (general category or script)
    //! 
    //! //! Any named character class may appear inside a bracketed `[...]` character //! class. For example, `[\p{Greek}\pN]` matches any Greek or numeral //! character. //! //! ## Composites //! //!
    //! xy    concatenation (x followed by y)
    //! x|y   alternation (x or y, prefer x)
    //! 
    //! //! ## Repetitions //! //!
    //! x*        zero or more of x (greedy)
    //! x+        one or more of x (greedy)
    //! x?        zero or one of x (greedy)
    //! x*?       zero or more of x (ungreedy)
    //! x+?       one or more of x (ungreedy)
    //! x??       zero or one of x (ungreedy)
    //! x{n,m}    at least n x and at most m x (greedy)
    //! x{n,}     at least n x (greedy)
    //! x{n}      exactly n x
    //! x{n,m}?   at least n x and at most m x (ungreedy)
    //! x{n,}?    at least n x (ungreedy)
    //! x{n}?     exactly n x
    //! 
    //! //! ## Empty matches //! //!
    //! ^     the beginning of text (or start-of-line with multi-line mode)
    //! $     the end of text (or end-of-line with multi-line mode)
    //! \A    only the beginning of text (even with multi-line mode enabled)
    //! \z    only the end of text (even with multi-line mode enabled)
    //! \b    a Unicode word boundary (\w on one side and \W, \A, or \z on other)
    //! \B    not a Unicode word boundary
    //! 
    //! //! ## Grouping and flags //! //!
    //! (exp)          numbered capture group (indexed by opening parenthesis)
    //! (?P<name>exp)  named (also numbered) capture group (allowed chars: [_0-9a-zA-Z])
    //! (?:exp)        non-capturing group
    //! (?flags)       set flags within current group
    //! (?flags:exp)   set flags for exp (non-capturing)
    //! 
    //! //! Flags are each a single character. For example, `(?x)` sets the flag `x` //! and `(?-x)` clears the flag `x`. Multiple flags can be set or cleared at //! the same time: `(?xy)` sets both the `x` and `y` flags and `(?x-y)` sets //! the `x` flag and clears the `y` flag. //! //! All flags are by default disabled. They are: //! //!
    //! i     case-insensitive
    //! m     multi-line mode: ^ and $ match begin/end of line
    //! s     allow . to match \n
    //! U     swap the meaning of x* and x*?
    //! x     ignore whitespace and allow line comments (starting with `#`)
    //! 
    //! //! Here's an example that matches case-insensitively for only part of the //! expression: //! //! ```rust //! # extern crate regex; use regex::Regex; //! # fn main() { //! let re = Regex::new(r"(?i)a+(?-i)b+").unwrap(); //! let cap = re.captures("AaAaAbbBBBb").unwrap(); //! assert_eq!(cap.at(0), Some("AaAaAbb")); //! # } //! ``` //! //! Notice that the `a+` matches either `a` or `A`, but the `b+` only matches //! `b`. //! //! ## Escape sequences //! //!
    //! \*         literal *, works for any punctuation character: \.+*?()|[]{}^$
    //! \a         bell (\x07)
    //! \f         form feed (\x0C)
    //! \t         horizontal tab
    //! \n         new line
    //! \r         carriage return
    //! \v         vertical tab (\x0B)
    //! \123       octal character code (up to three digits)
    //! \x7F       hex character code (exactly two digits)
    //! \x{10FFFF} any hex character code corresponding to a Unicode code point
    //! 
    //! //! ## Perl character classes (Unicode friendly) //! //! These classes are based on the definitions provided in //! [UTS#18](http://www.unicode.org/reports/tr18/#Compatibility_Properties): //! //!
    //! \d     digit (\p{Nd})
    //! \D     not digit
    //! \s     whitespace (\p{White_Space})
    //! \S     not whitespace
    //! \w     word character (\p{Alphabetic} + \p{M} + \d + \p{Pc} + \p{Join_Control})
    //! \W     not word character
    //! 
    //! //! ## ASCII character classes //! //!
    //! [:alnum:]    alphanumeric ([0-9A-Za-z])
    //! [:alpha:]    alphabetic ([A-Za-z])
    //! [:ascii:]    ASCII ([\x00-\x7F])
    //! [:blank:]    blank ([\t ])
    //! [:cntrl:]    control ([\x00-\x1F\x7F])
    //! [:digit:]    digits ([0-9])
    //! [:graph:]    graphical ([!-~])
    //! [:lower:]    lower case ([a-z])
    //! [:print:]    printable ([ -~])
    //! [:punct:]    punctuation ([!-/:-@[-`{-~])
    //! [:space:]    whitespace ([\t\n\v\f\r ])
    //! [:upper:]    upper case ([A-Z])
    //! [:word:]     word characters ([0-9A-Za-z_])
    //! [:xdigit:]   hex digit ([0-9A-Fa-f])
    //! 
    //! //! # Untrusted input //! //! This crate can handle both untrusted regular expressions and untrusted //! search text. //! //! Untrusted regular expressions are handled by capping the size of a compiled //! regular expression. (See `Regex::with_size_limit`.) Without this, it would //! be trivial for an attacker to exhaust your system's memory with expressions //! like `a{100}{100}{100}`. //! //! Untrusted search text is allowed because the matching engine(s) in this //! crate have time complexity `O(mn)` (with `m ~ regex` and `n ~ search //! text`), which means there's no way to cause exponential blow-up like with //! some other regular expression engines. (We pay for this by disallowing //! features like arbitrary look-ahead and back-references.) #![deny(missing_docs)] #![cfg_attr(test, deny(warnings))] #![cfg_attr(feature = "pattern", feature(pattern))] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://www.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/regex/")] extern crate aho_corasick; extern crate memchr; extern crate regex_syntax as syntax; pub use re::{ Regex, Error, Captures, SubCaptures, SubCapturesPos, SubCapturesNamed, CaptureNames, FindCaptures, FindMatches, Replacer, NoExpand, RegexSplits, RegexSplitsN, quote, is_match, }; mod backtrack; mod char; mod compile; mod input; mod pool; mod prefix; mod program; mod nfa; mod re; /// The `internal` module exists to support the `regex!` macro and other /// suspicious activity, such as testing different matching engines. #[doc(hidden)] pub mod internal { pub use char::Char; pub use input::{Input, CharInput, InputAt}; pub use program::{Program, MatchEngine, CharRanges, Inst, LookInst}; pub use re::ExNative; pub use re::Regex::{Dynamic, Native}; } deps/regex-0.1.44/src/program.rs0000644000175000001440000004552312635537042014467 0ustar users// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::cmp::{self, Ordering}; use syntax; use Error; use backtrack::{Backtrack, BackMachine}; use char::Char; use compile::Compiler; use nfa::{Nfa, NfaThreads}; use pool::Pool; use prefix::Prefix; use re::CaptureIdxs; const NUM_PREFIX_LIMIT: usize = 30; const PREFIX_LENGTH_LIMIT: usize = 15; pub type InstIdx = usize; /// An instruction, the underlying unit of a compiled regular expression #[derive(Clone, Debug)] pub enum Inst { /// A match has occurred. /// This is always the last instruction and only occurs in a single spot. /// We could special case this in the code, but it is much clearer to /// handle it as a proper instruction. Match, /// Save the current location in the input into the given capture location. Save(usize), /// Jump to the instruction given. Jump(InstIdx), /// Match either instruction, preferring the first. Split(InstIdx, InstIdx), /// A zero-width instruction. When this instruction matches, the input /// is not advanced. EmptyLook(LookInst), /// Match a single possibly case insensitive character. Char(char), /// Match one or more possibly case insensitive character ranges. Ranges(CharRanges), } /// A multi-range character class instruction. #[derive(Clone, Debug)] pub struct CharRanges { /// Sorted sequence of non-overlapping ranges. pub ranges: Vec<(char, char)>, } /// The set of zero-width match instructions. #[derive(Clone, Debug, PartialEq, Eq)] pub enum LookInst { /// Start of line or input. StartLine, /// End of line or input. EndLine, /// Start of input. StartText, /// End of input. EndText, /// Word character on one side and non-word character on other. WordBoundary, /// Word character on both sides or non-word character on both sides. NotWordBoundary, } impl CharRanges { /// Emits a range specifically for the `(?s).` expression. pub fn any() -> CharRanges { CharRanges { ranges: vec![('\x00', '\u{10ffff}')] } } /// Emits a range specifically for the `.` expression. pub fn any_nonl() -> CharRanges { CharRanges { ranges: vec![('\x00', '\x09'), ('\x0B', '\u{10ffff}')] } } /// Emits a range from the AST character class. pub fn from_class(cls: syntax::CharClass) -> CharRanges { CharRanges { ranges: cls.into_iter().map(|r| (r.start, r.end)).collect(), } } /// Tests whether the given input character matches this instruction. #[inline(always)] // About ~5-15% more throughput then `#[inline]` pub fn matches(&self, c: Char) -> bool { // This speeds up the `match_class_unicode` benchmark by checking // some common cases quickly without binary search. e.g., Matching // a Unicode class on predominantly ASCII text. for r in self.ranges.iter().take(4) { if c < r.0 { return false; } if c <= r.1 { return true; } } self.ranges.binary_search_by(|r| { if r.1 < c { Ordering::Less } else if r.0 > c { Ordering::Greater } else { Ordering::Equal } }).is_ok() } } impl LookInst { /// Tests whether the pair of characters matches this zero-width /// instruction. pub fn matches(&self, c1: Char, c2: Char) -> bool { use self::LookInst::*; match *self { StartLine => c1.is_none() || c1 == '\n', EndLine => c2.is_none() || c2 == '\n', StartText => c1.is_none(), EndText => c2.is_none(), ref wbty => { let (w1, w2) = (c1.is_word_char(), c2.is_word_char()); (*wbty == WordBoundary && w1 ^ w2) || (*wbty == NotWordBoundary && !(w1 ^ w2)) } } } } /// The matching engines offered by this regex implementation. /// /// N.B. This is exported for use in testing. #[doc(hidden)] #[derive(Clone, Copy, Debug)] pub enum MatchEngine { /// A bounded backtracking implementation. About twice as fast as the /// NFA, but can only work on small regexes and small input. Backtrack, /// A full NFA simulation. Can always be employed but almost always the /// slowest choice. Nfa, /// If the entire regex is a literal and no capture groups have been /// requested, then we can degrade to a simple substring match. Literals, } /// Program represents a compiled regular expression. Once an expression is /// compiled, its representation is immutable and will never change. /// (Well, almost. In fact, the matching engines cache state that can be /// reused on subsequent searches. But this is interior mutability that /// shouldn't be observable by the caller.) #[derive(Debug)] pub struct Program { /// The original regular expression string. pub original: String, /// A sequence of instructions. pub insts: Vec, /// The sequence of capture group names. There is an entry for each capture /// group index and a name exists only if the capture group is named. pub cap_names: Vec>, /// If the regular expression requires a literal prefix in order to have a /// match, that prefix is stored here as a DFA. pub prefixes: Prefix, /// True iff matching any literal prefix indicates a match. pub prefixes_complete: bool, /// True iff program is anchored at the beginning. pub anchored_begin: bool, /// True iff program is anchored at the end. pub anchored_end: bool, /// The type of matching engine to use. /// When `None` (the default), pick an engine automatically. pub engine: Option, /// Cached NFA threads. pub nfa_threads: Pool, /// Cached backtracking memory. pub backtrack: Pool, } impl Program { /// Compiles a Regex. pub fn new( engine: Option, size_limit: usize, re: &str, ) -> Result { let expr = try!(syntax::Expr::parse(re)); let (insts, cap_names) = try!(Compiler::new(size_limit).compile(expr)); let (insts_len, ncaps) = (insts.len(), num_captures(&insts)); let create_threads = move || NfaThreads::new(insts_len, ncaps); let create_backtrack = move || BackMachine::new(); let mut prog = Program { original: re.into(), insts: insts, cap_names: cap_names, prefixes: Prefix::Empty, prefixes_complete: false, anchored_begin: false, anchored_end: false, engine: engine, nfa_threads: Pool::new(Box::new(create_threads)), backtrack: Pool::new(Box::new(create_backtrack)), }; prog.find_prefixes(); prog.anchored_begin = match prog.insts[1] { Inst::EmptyLook(LookInst::StartText) => true, _ => false, }; prog.anchored_end = match prog.insts[prog.insts.len() - 3] { Inst::EmptyLook(LookInst::EndText) => true, _ => false, }; Ok(prog) } /// Executes a compiled regex program. pub fn exec( &self, caps: &mut CaptureIdxs, text: &str, start: usize, ) -> bool { match self.choose_engine(caps.len(), text) { MatchEngine::Backtrack => Backtrack::exec(self, caps, text, start), MatchEngine::Nfa => Nfa::exec(self, caps, text, start), MatchEngine::Literals => { match self.prefixes.find(&text[start..]) { None => false, Some((s, e)) => { if caps.len() == 2 { caps[0] = Some(start + s); caps[1] = Some(start + e); } true } } } } } fn choose_engine(&self, cap_len: usize, text: &str) -> MatchEngine { // If the engine is already chosen, then we use it. // But that might not be a good idea. e.g., What if `Literals` is // chosen and it can't work? I guess we should probably check whether // the chosen engine is appropriate or not. self.engine.unwrap_or_else(|| { if cap_len <= 2 && self.prefixes_complete && self.prefixes.preserves_priority() { MatchEngine::Literals } else if Backtrack::should_exec(self, text) { // We're only here if the input and regex combined are small. MatchEngine::Backtrack } else { MatchEngine::Nfa } }) } /// Returns the total number of capture groups in the regular expression. /// This includes the zeroth capture. pub fn num_captures(&self) -> usize { num_captures(&self.insts) } /// Allocate new capture groups. pub fn alloc_captures(&self) -> Vec> { vec![None; 2 * self.num_captures()] } /// Find and store a prefix machine for the current program. pub fn find_prefixes(&mut self) { // First, look for a standard literal prefix---this includes things // like `a+` and `[0-9]+`, but not `a|b`. let (ps, complete) = self.literals(self.skip(1)); if !ps.is_empty() { self.prefixes = Prefix::new(ps); self.prefixes_complete = complete; return; } // Ok, now look for alternate prefixes, e.g., `a|b`. if let Some((pfxs, complete)) = self.alternate_prefixes() { self.prefixes = Prefix::new(pfxs); self.prefixes_complete = complete; } } fn alternate_prefixes(&self) -> Option<(Vec, bool)> { let mut prefixes = vec![]; let mut pcomplete = true; let mut stack = vec![self.skip(1)]; while let Some(mut pc) = stack.pop() { pc = self.skip(pc); match self.insts[pc] { Inst::Split(x, y) => { stack.push(y); stack.push(x); } _ => { let (alt_prefixes, complete) = self.literals(pc); if alt_prefixes.is_empty() { // If no prefixes could be identified for this // alternate, then we can't use a prefix machine to // skip through the input. Thus, we fail and report // nothing. return None; } if prefixes.len() + alt_prefixes.len() > NUM_PREFIX_LIMIT { // Arg. We've over-extended ourselves, quit with // nothing to show for it. // // This could happen if the regex is `a|b|c|...`, where // the number of alternates is too much for us to // handle given an empirically defined threshold limit. // // When this happens, we can't capture all of the // prefixes, so our prefix machine becomes useless. // Thus, fail and report nothing. return None; } pcomplete = pcomplete && complete; prefixes.extend(alt_prefixes); } } } if prefixes.is_empty() { None } else { Some((prefixes, pcomplete)) } } /// Find required literals starting at the given instruction. /// /// Returns `true` in the tuple if the end of the literal leads trivially /// to a match. (This may report false negatives, but being conservative /// is OK.) fn literals(&self, mut pc: usize) -> (Vec, bool) { use self::Inst::*; let mut complete = true; let mut alts = vec![String::new()]; while pc < self.insts.len() { let inst = &self.insts[pc]; // Each iteration adds one character to every alternate prefix *or* // it stops. Thus, the prefix alternates grow in lock step, and it // suffices to check one of them to see if the prefix limit has // been exceeded. if alts[0].len() > PREFIX_LENGTH_LIMIT { complete = false; break; } match *inst { Save(_) => { pc += 1; continue } Jump(pc2) => pc = pc2, Char(c) => { for alt in &mut alts { alt.push(c); } pc += 1; } Ranges(CharRanges { ref ranges }) => { // This adds a new literal for *each* character in this // range. This has the potential to use way too much // memory, so we bound it naively for now. let nchars = num_chars_in_ranges(ranges); if alts.len() * nchars > NUM_PREFIX_LIMIT { complete = false; break; } let orig = alts; alts = Vec::with_capacity(orig.len()); for &(s, e) in ranges { for c in (s as u32)..(e as u32 + 1){ for alt in &orig { let mut alt = alt.clone(); alt.push(::std::char::from_u32(c).unwrap()); alts.push(alt); } } } pc += 1; } _ => { complete = self.leads_to_match(pc); break } } } if alts[0].is_empty() { (vec![], false) } else { (alts, complete) } } fn leads_to_match(&self, pc: usize) -> bool { // I'm pretty sure this is conservative, so it might have some // false negatives. match self.insts[self.skip(pc)] { Inst::Match => true, _ => false, } } fn skip(&self, mut pc: usize) -> usize { loop { match self.insts[pc] { Inst::Save(_) => pc += 1, Inst::Jump(pc2) => pc = pc2, _ => return pc, } } } } impl Clone for Program { fn clone(&self) -> Program { let (insts_len, ncaps) = (self.insts.len(), self.num_captures()); let create_threads = move || NfaThreads::new(insts_len, ncaps); let create_backtrack = move || BackMachine::new(); Program { original: self.original.clone(), insts: self.insts.clone(), cap_names: self.cap_names.clone(), prefixes: self.prefixes.clone(), prefixes_complete: self.prefixes_complete, anchored_begin: self.anchored_begin, anchored_end: self.anchored_end, engine: self.engine, nfa_threads: Pool::new(Box::new(create_threads)), backtrack: Pool::new(Box::new(create_backtrack)), } } } /// Return the number of captures in the given sequence of instructions. fn num_captures(insts: &[Inst]) -> usize { let mut n = 0; for inst in insts { if let Inst::Save(c) = *inst { n = cmp::max(n, c+1) } } // There's exactly 2 Save slots for every capture. n / 2 } /// Count the number of characters in the given range. /// /// This is useful for pre-emptively limiting the number of prefix literals /// we extract from a regex program. fn num_chars_in_ranges(ranges: &[(char, char)]) -> usize { ranges.iter() .map(|&(s, e)| 1 + (e as u32) - (s as u32)) .fold(0, |acc, len| acc + len) as usize } #[cfg(test)] mod tests { use super::Program; macro_rules! prog { ($re:expr) => { Program::new(None, 1 << 30, $re).unwrap() } } macro_rules! prefixes { ($re:expr) => {{ let p = prog!($re); assert!(!p.prefixes_complete); p.prefixes.prefixes() }} } macro_rules! prefixes_complete { ($re:expr) => {{ let p = prog!($re); assert!(p.prefixes_complete); p.prefixes.prefixes() }} } #[test] fn single() { assert_eq!(prefixes_complete!("a"), vec!["a"]); assert_eq!(prefixes_complete!("[a]"), vec!["a"]); assert_eq!(prefixes!("a+"), vec!["a"]); assert_eq!(prefixes!("(?:a)+"), vec!["a"]); assert_eq!(prefixes!("(a)+"), vec!["a"]); } #[test] fn single_alt() { assert_eq!(prefixes_complete!("a|b"), vec!["a", "b"]); assert_eq!(prefixes_complete!("b|a"), vec!["b", "a"]); assert_eq!(prefixes_complete!("[a]|[b]"), vec!["a", "b"]); assert_eq!(prefixes!("a+|b"), vec!["a", "b"]); assert_eq!(prefixes!("a|b+"), vec!["a", "b"]); assert_eq!(prefixes!("(?:a+)|b"), vec!["a", "b"]); assert_eq!(prefixes!("(a+)|b"), vec!["a", "b"]); } #[test] fn many() { assert_eq!(prefixes_complete!("abcdef"), vec!["abcdef"]); assert_eq!(prefixes!("abcdef+"), vec!["abcdef"]); assert_eq!(prefixes!("(?:abcdef)+"), vec!["abcdef"]); assert_eq!(prefixes!("(abcdef)+"), vec!["abcdef"]); } #[test] fn many_alt() { assert_eq!(prefixes_complete!("abc|def"), vec!["abc", "def"]); assert_eq!(prefixes_complete!("def|abc"), vec!["def", "abc"]); assert_eq!(prefixes!("abc+|def"), vec!["abc", "def"]); assert_eq!(prefixes!("abc|def+"), vec!["abc", "def"]); assert_eq!(prefixes!("(?:abc)+|def"), vec!["abc", "def"]); assert_eq!(prefixes!("(abc)+|def"), vec!["abc", "def"]); } #[test] fn class() { assert_eq!(prefixes_complete!("[0-9]"), vec![ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ]); assert_eq!(prefixes!("[0-9]+"), vec![ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ]); } #[test] fn preceding_alt() { assert_eq!(prefixes!("(?:a|b).+"), vec!["a", "b"]); assert_eq!(prefixes!("(a|b).+"), vec!["a", "b"]); } #[test] fn nested_alt() { assert_eq!(prefixes_complete!("(a|b|c|d)"), vec!["a", "b", "c", "d"]); assert_eq!(prefixes_complete!("((a|b)|(c|d))"), vec!["a", "b", "c", "d"]); } } deps/regex-0.1.44/src/re.rs0000644000175000001440000012171512635537042013424 0ustar users// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::borrow::Cow; use std::collections::HashMap; use std::collections::hash_map::Iter; use std::fmt; use std::ops::Index; #[cfg(feature = "pattern")] use std::str::pattern::{Pattern, Searcher, SearchStep}; use std::str::FromStr; use program::{Program, MatchEngine}; use syntax; const REPLACE_EXPAND: &'static str = r"(?x) (?P^|\b|[^$]) # Ignore `$$name`. \$ (?P # Match the actual capture name. Can be... [0-9]+ # A sequence of digits (for indexed captures), or... | [_a-zA-Z][_0-9a-zA-Z]* # A name for named captures. ) "; /// Type alias for representing capture indices. pub type CaptureIdxs = [Option]; /// Escapes all regular expression meta characters in `text`. /// /// The string returned may be safely used as a literal in a regular /// expression. pub fn quote(text: &str) -> String { let mut quoted = String::with_capacity(text.len()); for c in text.chars() { if syntax::is_punct(c) { quoted.push('\\') } quoted.push(c); } quoted } /// Tests if the given regular expression matches somewhere in the text given. /// /// If there was a problem compiling the regular expression, an error is /// returned. /// /// To find submatches, split or replace text, you'll need to compile an /// expression first. pub fn is_match(regex: &str, text: &str) -> Result { Regex::new(regex).map(|r| r.is_match(text)) } /// An error that occurred during parsing or compiling a regular expression. #[derive(Debug)] pub enum Error { /// A syntax error. Syntax(syntax::Error), /// The compiled program exceeded the set size limit. /// The argument is the size limit imposed. CompiledTooBig(usize), /// Hints that destructuring should not be exhaustive. /// /// This enum may grow additional variants, so this makes sure clients /// don't count on exhaustive matching. (Otherwise, adding a new variant /// could break existing code.) #[doc(hidden)] __Nonexhaustive, } impl ::std::error::Error for Error { fn description(&self) -> &str { match *self { Error::Syntax(ref err) => err.description(), Error::CompiledTooBig(_) => "compiled program too big", Error::__Nonexhaustive => unreachable!(), } } fn cause(&self) -> Option<&::std::error::Error> { match *self { Error::Syntax(ref err) => Some(err), _ => None, } } } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Error::Syntax(ref err) => err.fmt(f), Error::CompiledTooBig(limit) => { write!(f, "Compiled regex exceeds size limit of {} bytes.", limit) } Error::__Nonexhaustive => unreachable!(), } } } impl From for Error { fn from(err: syntax::Error) -> Error { Error::Syntax(err) } } /// A compiled regular expression /// /// It is represented as either a sequence of bytecode instructions (dynamic) /// or as a specialized Rust function (native). It can be used to search, split /// or replace text. All searching is done with an implicit `.*?` at the /// beginning and end of an expression. To force an expression to match the /// whole string (or a prefix or a suffix), you must use an anchor like `^` or /// `$` (or `\A` and `\z`). /// /// While this crate will handle Unicode strings (whether in the regular /// expression or in the search text), all positions returned are **byte /// indices**. Every byte index is guaranteed to be at a Unicode code point /// boundary. /// /// The lifetimes `'r` and `'t` in this crate correspond to the lifetime of a /// compiled regular expression and text to search, respectively. /// /// The only methods that allocate new strings are the string replacement /// methods. All other methods (searching and splitting) return borrowed /// pointers into the string given. /// /// # Examples /// /// Find the location of a US phone number: /// /// ```rust /// # use regex::Regex; /// let re = Regex::new("[0-9]{3}-[0-9]{3}-[0-9]{4}").unwrap(); /// assert_eq!(re.find("phone: 111-222-3333"), Some((7, 19))); /// ``` /// /// # Using the `std::str::StrExt` methods with `Regex` /// /// > **Note**: This section requires that this crate is currently compiled with /// > the `pattern` Cargo feature enabled. /// /// Since `Regex` implements `Pattern`, you can use regexes with methods /// defined on `std::str::StrExt`. For example, `is_match`, `find`, `find_iter` /// and `split` can be replaced with `StrExt::contains`, `StrExt::find`, /// `StrExt::match_indices` and `StrExt::split`. /// /// Here are some examples: /// /// ```rust,ignore /// # use regex::Regex; /// let re = Regex::new(r"\d+").unwrap(); /// let haystack = "a111b222c"; /// /// assert!(haystack.contains(&re)); /// assert_eq!(haystack.find(&re), Some(1)); /// assert_eq!(haystack.match_indices(&re).collect::>(), /// vec![(1, 4), (5, 8)]); /// assert_eq!(haystack.split(&re).collect::>(), vec!["a", "b", "c"]); /// ``` #[derive(Clone)] pub enum Regex { // The representation of `Regex` is exported to support the `regex!` // syntax extension. Do not rely on it. // // See the comments for the `program` module in `lib.rs` for a more // detailed explanation for what `regex!` requires. #[doc(hidden)] Dynamic(Program), #[doc(hidden)] Native(ExNative), } #[doc(hidden)] pub struct ExNative { #[doc(hidden)] pub original: &'static str, #[doc(hidden)] pub names: &'static &'static [Option<&'static str>], #[doc(hidden)] pub prog: fn(&mut CaptureIdxs, &str, usize) -> bool, } impl Copy for ExNative {} impl Clone for ExNative { fn clone(&self) -> ExNative { *self } } impl fmt::Display for Regex { /// Shows the original regular expression. fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.as_str()) } } impl fmt::Debug for Regex { /// Shows the original regular expression. fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(self, f) } } /// Equality comparison is based on the original string. It is possible that /// different regular expressions have the same matching behavior, but are /// still compared unequal. For example, `\d+` and `\d\d*` match the same set /// of strings, but are not considered equal. impl PartialEq for Regex { fn eq(&self, other: &Regex) -> bool { self.as_str() == other.as_str() } } impl Eq for Regex {} impl FromStr for Regex { type Err = Error; /// Attempts to parse a string into a regular expression fn from_str(s: &str) -> Result { Regex::new(s) } } impl Regex { /// Compiles a dynamic regular expression. Once compiled, it can be /// used repeatedly to search, split or replace text in a string. /// /// If an invalid expression is given, then an error is returned. pub fn new(re: &str) -> Result { Regex::with_size_limit(10 * (1 << 20), re) } /// Compiles a dynamic regular expression with the given size limit. /// /// The size limit is applied to the size of the *compiled* data structure. /// If the data structure exceeds the size given, then an error is /// returned. /// /// The default size limit used in `new` is 10MB. pub fn with_size_limit(size: usize, re: &str) -> Result { Regex::with_engine(None, size, re) } /// Compiles a dynamic regular expression and uses given matching engine. /// /// This is exposed for use in testing and shouldn't be used by clients. /// Instead, the regex program should choose the correct matching engine /// to use automatically. (Based on the regex, the size of the input and /// the type of search.) /// /// A value of `None` means that the engine is automatically selected, /// which is the default behavior. /// /// **WARNING**: Passing an unsuitable engine for the given regex/input /// could lead to bad things. (Not unsafe things, but panics, incorrect /// matches and large memory use are all things that could happen.) #[doc(hidden)] pub fn with_engine( engine: Option, size: usize, re: &str, ) -> Result { Program::new(engine, size, re).map(Regex::Dynamic) } /// Returns true if and only if the regex matches the string given. /// /// # Example /// /// Test if some text contains at least one word with exactly 13 /// characters: /// /// ```rust /// # extern crate regex; use regex::Regex; /// # fn main() { /// let text = "I categorically deny having triskaidekaphobia."; /// assert!(Regex::new(r"\b\w{13}\b").unwrap().is_match(text)); /// # } /// ``` pub fn is_match(&self, text: &str) -> bool { exec(self, &mut [], text, 0) } /// Returns the start and end byte range of the leftmost-first match in /// `text`. If no match exists, then `None` is returned. /// /// Note that this should only be used if you want to discover the position /// of the match. Testing the existence of a match is faster if you use /// `is_match`. /// /// # Example /// /// Find the start and end location of the first word with exactly 13 /// characters: /// /// ```rust /// # extern crate regex; use regex::Regex; /// # fn main() { /// let text = "I categorically deny having triskaidekaphobia."; /// let pos = Regex::new(r"\b\w{13}\b").unwrap().find(text); /// assert_eq!(pos, Some((2, 15))); /// # } /// ``` pub fn find(&self, text: &str) -> Option<(usize, usize)> { let mut caps = [None, None]; if exec(self, &mut caps, text, 0) { Some((caps[0].unwrap(), caps[1].unwrap())) } else { None } } /// Returns an iterator for each successive non-overlapping match in /// `text`, returning the start and end byte indices with respect to /// `text`. /// /// # Example /// /// Find the start and end location of every word with exactly 13 /// characters: /// /// ```rust /// # extern crate regex; use regex::Regex; /// # fn main() { /// let text = "Retroactively relinquishing remunerations is reprehensible."; /// for pos in Regex::new(r"\b\w{13}\b").unwrap().find_iter(text) { /// println!("{:?}", pos); /// } /// // Output: /// // (0, 13) /// // (14, 27) /// // (28, 41) /// // (45, 58) /// # } /// ``` pub fn find_iter<'r, 't>(&'r self, text: &'t str) -> FindMatches<'r, 't> { FindMatches { re: self, search: text, last_end: 0, last_match: None, } } /// Returns the capture groups corresponding to the leftmost-first /// match in `text`. Capture group `0` always corresponds to the entire /// match. If no match is found, then `None` is returned. /// /// You should only use `captures` if you need access to submatches. /// Otherwise, `find` is faster for discovering the location of the overall /// match. /// /// # Examples /// /// Say you have some text with movie names and their release years, /// like "'Citizen Kane' (1941)". It'd be nice if we could search for text /// looking like that, while also extracting the movie name and its release /// year separately. /// /// ```rust /// # extern crate regex; use regex::Regex; /// # fn main() { /// let re = Regex::new(r"'([^']+)'\s+\((\d{4})\)").unwrap(); /// let text = "Not my favorite movie: 'Citizen Kane' (1941)."; /// let caps = re.captures(text).unwrap(); /// assert_eq!(caps.at(1), Some("Citizen Kane")); /// assert_eq!(caps.at(2), Some("1941")); /// assert_eq!(caps.at(0), Some("'Citizen Kane' (1941)")); /// // You can also access the groups by index using the Index notation. /// // Note that this will panic on an invalid index. /// assert_eq!(&caps[1], "Citizen Kane"); /// assert_eq!(&caps[2], "1941"); /// assert_eq!(&caps[0], "'Citizen Kane' (1941)"); /// # } /// ``` /// /// Note that the full match is at capture group `0`. Each subsequent /// capture group is indexed by the order of its opening `(`. /// /// We can make this example a bit clearer by using *named* capture groups: /// /// ```rust /// # extern crate regex; use regex::Regex; /// # fn main() { /// let re = Regex::new(r"'(?P[^']+)'\s+\((?P<year>\d{4})\)") /// .unwrap(); /// let text = "Not my favorite movie: 'Citizen Kane' (1941)."; /// let caps = re.captures(text).unwrap(); /// assert_eq!(caps.name("title"), Some("Citizen Kane")); /// assert_eq!(caps.name("year"), Some("1941")); /// assert_eq!(caps.at(0), Some("'Citizen Kane' (1941)")); /// // You can also access the groups by name using the Index notation. /// // Note that this will panic on an invalid group name. /// assert_eq!(&caps["title"], "Citizen Kane"); /// assert_eq!(&caps["year"], "1941"); /// assert_eq!(&caps[0], "'Citizen Kane' (1941)"); /// /// # } /// ``` /// /// Here we name the capture groups, which we can access with the `name` /// method or the `Index` notation with a `&str`. Note that the named capture groups /// are still accessible with `at` or the `Index` notation with a `usize`. /// /// The `0`th capture group is always unnamed, so it must always be /// accessed with `at(0)` or `[0]`. pub fn captures<'t>(&self, text: &'t str) -> Option<Captures<'t>> { let mut caps = self.alloc_captures(); if exec(self, &mut caps, text, 0) { Some(Captures::new(self, text, caps)) } else { None } } /// Returns an iterator over all the non-overlapping capture groups matched /// in `text`. This is operationally the same as `find_iter` (except it /// yields information about submatches). /// /// # Example /// /// We can use this to find all movie titles and their release years in /// some text, where the movie is formatted like "'Title' (xxxx)": /// /// ```rust /// # extern crate regex; use regex::Regex; /// # fn main() { /// let re = Regex::new(r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)") /// .unwrap(); /// let text = "'Citizen Kane' (1941), 'The Wizard of Oz' (1939), 'M' (1931)."; /// for caps in re.captures_iter(text) { /// println!("Movie: {:?}, Released: {:?}", caps.name("title"), caps.name("year")); /// } /// // Output: /// // Movie: Citizen Kane, Released: 1941 /// // Movie: The Wizard of Oz, Released: 1939 /// // Movie: M, Released: 1931 /// # } /// ``` pub fn captures_iter<'r, 't>(&'r self, text: &'t str) -> FindCaptures<'r, 't> { FindCaptures { re: self, search: text, last_match: None, last_end: 0, } } /// Returns an iterator of substrings of `text` delimited by a match /// of the regular expression. /// Namely, each element of the iterator corresponds to text that *isn't* /// matched by the regular expression. /// /// This method will *not* copy the text given. /// /// # Example /// /// To split a string delimited by arbitrary amounts of spaces or tabs: /// /// ```rust /// # extern crate regex; use regex::Regex; /// # fn main() { /// let re = Regex::new(r"[ \t]+").unwrap(); /// let fields: Vec<&str> = re.split("a b \t c\td e").collect(); /// assert_eq!(fields, vec!("a", "b", "c", "d", "e")); /// # } /// ``` pub fn split<'r, 't>(&'r self, text: &'t str) -> RegexSplits<'r, 't> { RegexSplits { finder: self.find_iter(text), last: 0, } } /// Returns an iterator of at most `limit` substrings of `text` delimited /// by a match of the regular expression. (A `limit` of `0` will return no /// substrings.) /// Namely, each element of the iterator corresponds to text that *isn't* /// matched by the regular expression. /// The remainder of the string that is not split will be the last element /// in the iterator. /// /// This method will *not* copy the text given. /// /// # Example /// /// Get the first two words in some text: /// /// ```rust /// # extern crate regex; use regex::Regex; /// # fn main() { /// let re = Regex::new(r"\W+").unwrap(); /// let fields: Vec<&str> = re.splitn("Hey! How are you?", 3).collect(); /// assert_eq!(fields, vec!("Hey", "How", "are you?")); /// # } /// ``` pub fn splitn<'r, 't>(&'r self, text: &'t str, limit: usize) -> RegexSplitsN<'r, 't> { RegexSplitsN { splits: self.split(text), cur: 0, limit: limit, } } /// Replaces the leftmost-first match with the replacement provided. /// The replacement can be a regular string (where `$N` and `$name` are /// expanded to match capture groups) or a function that takes the matches' /// `Captures` and returns the replaced string. /// /// If no match is found, then a copy of the string is returned unchanged. /// /// # Examples /// /// Note that this function is polymorphic with respect to the replacement. /// In typical usage, this can just be a normal string: /// /// ```rust /// # extern crate regex; use regex::Regex; /// # fn main() { /// let re = Regex::new("[^01]+").unwrap(); /// assert_eq!(re.replace("1078910", ""), "1010"); /// # } /// ``` /// /// But anything satisfying the `Replacer` trait will work. For example, /// a closure of type `|&Captures| -> String` provides direct access to the /// captures corresponding to a match. This allows one to access /// submatches easily: /// /// ```rust /// # extern crate regex; use regex::Regex; /// # use regex::Captures; fn main() { /// let re = Regex::new(r"([^,\s]+),\s+(\S+)").unwrap(); /// let result = re.replace("Springsteen, Bruce", |caps: &Captures| { /// format!("{} {}", caps.at(2).unwrap_or(""), caps.at(1).unwrap_or("")) /// }); /// assert_eq!(result, "Bruce Springsteen"); /// # } /// ``` /// /// But this is a bit cumbersome to use all the time. Instead, a simple /// syntax is supported that expands `$name` into the corresponding capture /// group. Here's the last example, but using this expansion technique /// with named capture groups: /// /// ```rust /// # extern crate regex; use regex::Regex; /// # fn main() { /// let re = Regex::new(r"(?P<last>[^,\s]+),\s+(?P<first>\S+)").unwrap(); /// let result = re.replace("Springsteen, Bruce", "$first $last"); /// assert_eq!(result, "Bruce Springsteen"); /// # } /// ``` /// /// Note that using `$2` instead of `$first` or `$1` instead of `$last` /// would produce the same result. To write a literal `$` use `$$`. /// /// Finally, sometimes you just want to replace a literal string with no /// submatch expansion. This can be done by wrapping a string with /// `NoExpand`: /// /// ```rust /// # extern crate regex; use regex::Regex; /// # fn main() { /// use regex::NoExpand; /// /// let re = Regex::new(r"(?P<last>[^,\s]+),\s+(\S+)").unwrap(); /// let result = re.replace("Springsteen, Bruce", NoExpand("$2 $last")); /// assert_eq!(result, "$2 $last"); /// # } /// ``` pub fn replace<R: Replacer>(&self, text: &str, rep: R) -> String { self.replacen(text, 1, rep) } /// Replaces all non-overlapping matches in `text` with the /// replacement provided. This is the same as calling `replacen` with /// `limit` set to `0`. /// /// See the documentation for `replace` for details on how to access /// submatches in the replacement string. pub fn replace_all<R: Replacer>(&self, text: &str, rep: R) -> String { self.replacen(text, 0, rep) } /// Replaces at most `limit` non-overlapping matches in `text` with the /// replacement provided. If `limit` is 0, then all non-overlapping matches /// are replaced. /// /// See the documentation for `replace` for details on how to access /// submatches in the replacement string. pub fn replacen<R: Replacer> (&self, text: &str, limit: usize, mut rep: R) -> String { let mut new = String::with_capacity(text.len()); let mut last_match = 0; if rep.no_expand().is_some() { // borrow checker pains. `rep` is borrowed mutably in the `else` // branch below. let rep = rep.no_expand().unwrap(); for (i, (s, e)) in self.find_iter(text).enumerate() { if limit > 0 && i >= limit { break } new.push_str(&text[last_match..s]); new.push_str(&rep); last_match = e; } } else { for (i, cap) in self.captures_iter(text).enumerate() { if limit > 0 && i >= limit { break } // unwrap on 0 is OK because captures only reports matches let (s, e) = cap.pos(0).unwrap(); new.push_str(&text[last_match..s]); new.push_str(&rep.reg_replace(&cap)); last_match = e; } } new.push_str(&text[last_match..]); new } /// Returns the original string of this regex. pub fn as_str(&self) -> &str { match *self { Regex::Dynamic(Program { ref original, .. }) => original, Regex::Native(ExNative { ref original, .. }) => original, } } /// Returns an iterator over the capture names. pub fn capture_names(&self) -> CaptureNames { match *self { Regex::Native(ref n) => CaptureNames::Native(n.names.iter()), Regex::Dynamic(ref d) => CaptureNames::Dynamic(d.cap_names.iter()) } } /// Returns the number of captures. pub fn captures_len(&self) -> usize { match *self { Regex::Native(ref n) => n.names.len(), Regex::Dynamic(ref d) => d.cap_names.len() } } fn alloc_captures(&self) -> Vec<Option<usize>> { match *self { Regex::Native(ref n) => vec![None; 2 * n.names.len()], Regex::Dynamic(ref d) => d.alloc_captures(), } } } /// Yields the names of all possible captures. /// `None` indicates an unnamed capture; the first element /// (capture 0, the whole matched region) is always unnamed. /// /// `'r` is the lifetime of the compiled expression. pub enum CaptureNames<'r> { #[doc(hidden)] Native(::std::slice::Iter<'r, Option<&'static str>>), #[doc(hidden)] Dynamic(::std::slice::Iter<'r, Option<String>>) } impl<'r> Iterator for CaptureNames<'r> { type Item=Option<&'r str>; fn next(&mut self) -> Option<Option<&'r str>> { match *self { CaptureNames::Native(ref mut i) => i.next().cloned(), CaptureNames::Dynamic(ref mut i) => i.next().as_ref().map(|o| o.as_ref().map(|s| s.as_ref())), } } fn size_hint(&self) -> (usize, Option<usize>) { match *self { CaptureNames::Native(ref i) => i.size_hint(), CaptureNames::Dynamic(ref i) => i.size_hint(), } } } /// NoExpand indicates literal string replacement. /// /// It can be used with `replace` and `replace_all` to do a literal /// string replacement without expanding `$name` to their corresponding /// capture groups. /// /// `'r` is the lifetime of the literal text. pub struct NoExpand<'t>(pub &'t str); /// Replacer describes types that can be used to replace matches in a string. pub trait Replacer { /// Returns a possibly owned string that is used to replace the match /// corresponding to the `caps` capture group. /// /// The `'a` lifetime refers to the lifetime of a borrowed string when /// a new owned string isn't needed (e.g., for `NoExpand`). fn reg_replace(&mut self, caps: &Captures) -> Cow<str>; /// Returns a possibly owned string that never needs expansion. fn no_expand(&mut self) -> Option<Cow<str>> { None } } impl<'t> Replacer for NoExpand<'t> { fn reg_replace(&mut self, _: &Captures) -> Cow<str> { self.0.into() } fn no_expand(&mut self) -> Option<Cow<str>> { Some(self.0.into()) } } impl<'t> Replacer for &'t str { fn reg_replace<'a>(&'a mut self, caps: &Captures) -> Cow<'a, str> { caps.expand(*self).into() } fn no_expand(&mut self) -> Option<Cow<str>> { // if there is a $ there may be an expansion match self.find('$') { Some(_) => None, None => Some((*self).into()), } } } impl<F> Replacer for F where F: FnMut(&Captures) -> String { fn reg_replace<'a>(&'a mut self, caps: &Captures) -> Cow<'a, str> { (*self)(caps).into() } } /// Yields all substrings delimited by a regular expression match. /// /// `'r` is the lifetime of the compiled expression and `'t` is the lifetime /// of the string being split. pub struct RegexSplits<'r, 't> { finder: FindMatches<'r, 't>, last: usize, } impl<'r, 't> Iterator for RegexSplits<'r, 't> { type Item = &'t str; fn next(&mut self) -> Option<&'t str> { let text = self.finder.search; match self.finder.next() { None => { if self.last >= text.len() { None } else { let s = &text[self.last..]; self.last = text.len(); Some(s) } } Some((s, e)) => { let matched = &text[self.last..s]; self.last = e; Some(matched) } } } } /// Yields at most `N` substrings delimited by a regular expression match. /// /// The last substring will be whatever remains after splitting. /// /// `'r` is the lifetime of the compiled expression and `'t` is the lifetime /// of the string being split. pub struct RegexSplitsN<'r, 't> { splits: RegexSplits<'r, 't>, cur: usize, limit: usize, } impl<'r, 't> Iterator for RegexSplitsN<'r, 't> { type Item = &'t str; fn next(&mut self) -> Option<&'t str> { let text = self.splits.finder.search; if self.cur >= self.limit { None } else { self.cur += 1; if self.cur >= self.limit { Some(&text[self.splits.last..]) } else { self.splits.next() } } } } /// Captures represents a group of captured strings for a single match. /// /// The 0th capture always corresponds to the entire match. Each subsequent /// index corresponds to the next capture group in the regex. /// If a capture group is named, then the matched string is *also* available /// via the `name` method. (Note that the 0th capture is always unnamed and so /// must be accessed with the `at` method.) /// /// Positions returned from a capture group are always byte indices. /// /// `'t` is the lifetime of the matched text. pub struct Captures<'t> { text: &'t str, locs: Vec<Option<usize>>, named: Option<HashMap<String, usize>>, } impl<'t> Captures<'t> { fn new( re: &Regex, search: &'t str, locs: Vec<Option<usize>>, ) -> Captures<'t> { let named = if re.captures_len() == 0 { None } else { let mut named = HashMap::new(); for (i, name) in re.capture_names().enumerate() { if let Some(name) = name { named.insert(name.to_owned(), i); } } Some(named) }; Captures { text: search, locs: locs, named: named, } } /// Returns the start and end positions of the Nth capture group. /// Returns `None` if `i` is not a valid capture group or if the capture /// group did not match anything. /// The positions returned are *always* byte indices with respect to the /// original string matched. pub fn pos(&self, i: usize) -> Option<(usize, usize)> { let (s, e) = (i * 2, i * 2 + 1); if e >= self.locs.len() || self.locs[s].is_none() { // VM guarantees that each pair of locations are both Some or None. return None } Some((self.locs[s].unwrap(), self.locs[e].unwrap())) } /// Returns the matched string for the capture group `i`. If `i` isn't /// a valid capture group or didn't match anything, then `None` is /// returned. pub fn at(&self, i: usize) -> Option<&'t str> { match self.pos(i) { None => None, Some((s, e)) => Some(&self.text[s..e]) } } /// Returns the matched string for the capture group named `name`. If /// `name` isn't a valid capture group or didn't match anything, then /// `None` is returned. pub fn name(&self, name: &str) -> Option<&'t str> { match self.named { None => None, Some(ref h) => { match h.get(name) { None => None, Some(i) => self.at(*i), } } } } /// Creates an iterator of all the capture groups in order of appearance /// in the regular expression. pub fn iter(&'t self) -> SubCaptures<'t> { SubCaptures { idx: 0, caps: self, } } /// Creates an iterator of all the capture group positions in order of /// appearance in the regular expression. Positions are byte indices /// in terms of the original string matched. pub fn iter_pos(&'t self) -> SubCapturesPos<'t> { SubCapturesPos { idx: 0, caps: self, } } /// Creates an iterator of all named groups as an tuple with the group /// name and the value. The iterator returns these values in arbitrary /// order. pub fn iter_named(&'t self) -> SubCapturesNamed<'t> { SubCapturesNamed { caps: self, inner: self.named.as_ref().map(|n| n.iter()) } } /// Expands all instances of `$name` in `text` to the corresponding capture /// group `name`. /// /// `name` may be an integer corresponding to the index of the /// capture group (counted by order of opening parenthesis where `0` is the /// entire match) or it can be a name (consisting of letters, digits or /// underscores) corresponding to a named capture group. /// /// If `name` isn't a valid capture group (whether the name doesn't exist or /// isn't a valid index), then it is replaced with the empty string. /// /// To write a literal `$` use `$$`. pub fn expand(&self, text: &str) -> String { // How evil can you get? let re = Regex::new(REPLACE_EXPAND).unwrap(); let text = re.replace_all(text, |refs: &Captures| -> String { let before = refs.name("before").unwrap_or(""); let name = refs.name("name").unwrap_or(""); format!("{}{}", before, match name.parse::<usize>() { Err(_) => self.name(name).unwrap_or("").to_owned(), Ok(i) => self.at(i).unwrap_or("").to_owned(), }) }); let re = Regex::new(r"\$\$").unwrap(); re.replace_all(&text, NoExpand("$")) } /// Returns the number of captured groups. #[inline] pub fn len(&self) -> usize { self.locs.len() / 2 } /// Returns true if and only if there are no captured groups. #[inline] pub fn is_empty(&self) -> bool { self.len() == 0 } } /// Get a group by index. /// /// # Panics /// If there is no group at the given index. impl<'t> Index<usize> for Captures<'t> { type Output = str; fn index(&self, i: usize) -> &str { self.at(i).unwrap_or_else(|| panic!("no group at index '{}'", i)) } } /// Get a group by name. /// /// # Panics /// If there is no group named by the given value. impl<'t> Index<&'t str> for Captures<'t> { type Output = str; fn index<'a>(&'a self, name: &str) -> &'a str { match self.name(name) { None => panic!("no group named '{}'", name), Some(ref s) => s, } } } /// An iterator over capture groups for a particular match of a regular /// expression. /// /// `'t` is the lifetime of the matched text. pub struct SubCaptures<'t> { idx: usize, caps: &'t Captures<'t>, } impl<'t> Iterator for SubCaptures<'t> { type Item = Option<&'t str>; fn next(&mut self) -> Option<Option<&'t str>> { if self.idx < self.caps.len() { self.idx += 1; Some(self.caps.at(self.idx - 1)) } else { None } } } /// An iterator over capture group positions for a particular match of a /// regular expression. /// /// Positions are byte indices in terms of the original string matched. /// /// `'t` is the lifetime of the matched text. pub struct SubCapturesPos<'t> { idx: usize, caps: &'t Captures<'t>, } impl<'t> Iterator for SubCapturesPos<'t> { type Item = Option<(usize, usize)>; fn next(&mut self) -> Option<Option<(usize, usize)>> { if self.idx < self.caps.len() { self.idx += 1; Some(self.caps.pos(self.idx - 1)) } else { None } } } /// An Iterator over named capture groups as a tuple with the group /// name and the value. /// /// `'t` is the lifetime of the matched text. pub struct SubCapturesNamed<'t>{ caps: &'t Captures<'t>, inner: Option<Iter<'t, String, usize>>, } impl<'t> Iterator for SubCapturesNamed<'t> { type Item = (&'t str, Option<&'t str>); fn next(&mut self) -> Option<(&'t str, Option<&'t str>)> { match self.inner.as_mut().map_or(None, |it| it.next()) { Some((name, pos)) => Some((name, self.caps.at(*pos))), None => None } } } /// An iterator that yields all non-overlapping capture groups matching a /// particular regular expression. /// /// The iterator stops when no more matches can be found. /// /// `'r` is the lifetime of the compiled expression and `'t` is the lifetime /// of the matched string. pub struct FindCaptures<'r, 't> { re: &'r Regex, search: &'t str, last_match: Option<usize>, last_end: usize, } impl<'r, 't> Iterator for FindCaptures<'r, 't> { type Item = Captures<'t>; fn next(&mut self) -> Option<Captures<'t>> { if self.last_end > self.search.len() { return None } let mut caps = self.re.alloc_captures(); if !exec(self.re, &mut caps, self.search, self.last_end) { return None } let (s, e) = (caps[0].unwrap(), caps[1].unwrap()); // Don't accept empty matches immediately following a match. // i.e., no infinite loops please. if e == s && Some(self.last_end) == self.last_match { if self.last_end >= self.search.len() { return None; } self.last_end += self.search[self.last_end..].chars() .next().unwrap().len_utf8(); return self.next() } self.last_end = e; self.last_match = Some(self.last_end); Some(Captures::new(self.re, self.search, caps)) } } /// An iterator over all non-overlapping matches for a particular string. /// /// The iterator yields a tuple of integers corresponding to the start and end /// of the match. The indices are byte offsets. The iterator stops when no more /// matches can be found. /// /// `'r` is the lifetime of the compiled expression and `'t` is the lifetime /// of the matched string. pub struct FindMatches<'r, 't> { re: &'r Regex, search: &'t str, last_match: Option<usize>, last_end: usize, } impl<'r, 't> Iterator for FindMatches<'r, 't> { type Item = (usize, usize); fn next(&mut self) -> Option<(usize, usize)> { if self.last_end > self.search.len() { return None } let mut caps = [None, None]; if !exec(self.re, &mut caps, self.search, self.last_end) { return None; } let (s, e) = (caps[0].unwrap(), caps[1].unwrap()); // Don't accept empty matches immediately following a match. // i.e., no infinite loops please. if e == s && Some(self.last_end) == self.last_match { if self.last_end >= self.search.len() { return None; } self.last_end += self.search[self.last_end..].chars() .next().unwrap().len_utf8(); return self.next() } self.last_end = e; self.last_match = Some(self.last_end); Some((s, e)) } } #[cfg(feature = "pattern")] pub struct RegexSearcher<'r, 't> { it: FindMatches<'r, 't>, last_step_end: usize, next_match: Option<(usize, usize)>, } #[cfg(feature = "pattern")] impl<'r, 't> Pattern<'t> for &'r Regex { type Searcher = RegexSearcher<'r, 't>; fn into_searcher(self, haystack: &'t str) -> RegexSearcher<'r, 't> { RegexSearcher { it: self.find_iter(haystack), last_step_end: 0, next_match: None, } } } #[cfg(feature = "pattern")] unsafe impl<'r, 't> Searcher<'t> for RegexSearcher<'r, 't> { #[inline] fn haystack(&self) -> &'t str { self.it.search } #[inline] fn next(&mut self) -> SearchStep { if let Some((s, e)) = self.next_match { self.next_match = None; self.last_step_end = e; return SearchStep::Match(s, e); } match self.it.next() { None => { if self.last_step_end < self.haystack().len() { let last = self.last_step_end; self.last_step_end = self.haystack().len(); SearchStep::Reject(last, self.haystack().len()) } else { SearchStep::Done } } Some((s, e)) => { if s == self.last_step_end { self.last_step_end = e; SearchStep::Match(s, e) } else { self.next_match = Some((s, e)); let last = self.last_step_end; self.last_step_end = s; SearchStep::Reject(last, s) } } } } } fn exec(re: &Regex, caps: &mut CaptureIdxs, text: &str, start: usize) -> bool { match *re { Regex::Native(ExNative { ref prog, .. }) => (*prog)(caps, text, start), Regex::Dynamic(ref prog) => prog.exec(caps, text, start), } } #[cfg(test)] mod test { use super::{NoExpand, Regex}; #[test] fn test_simple_expand() { let re = Regex::new(r"(\w) (\w)").unwrap(); assert_eq!(re.replace_all("a b", "$2 $1"), "b a"); } #[test] fn test_literal_dollar() { let re = Regex::new(r"(\w+) (\w+)").unwrap(); assert_eq!(re.replace_all("a b", "$1"), "a"); assert_eq!(re.replace_all("a b", "$$1"), "$1"); // $$ should become a $ assert_eq!(re.replace_all("a b", "$2 $$c $1"), "b $c a"); } #[test] fn test_no_expand() { let re = Regex::new(r"(\w+)").unwrap(); assert_eq!(re.replace_all("a", NoExpand("$$1")), "$$1"); assert_eq!(re.replace_all("a", NoExpand("$1")), "$1"); } #[test] fn test_capture_names() { let re = Regex::new(r"(.)(?P<a>.)").unwrap(); assert_eq!(re.capture_names().size_hint(), (3, Some(3))); assert_eq!(re.capture_names().collect::<Vec<_>>(), [None, None, Some("a")]); } #[test] fn test_cap_index() { let re = Regex::new(r"^(?P<name>.+)$").unwrap(); let cap = re.captures("abc").unwrap(); assert_eq!(&cap[0], "abc"); assert_eq!(&cap[1], "abc"); assert_eq!(&cap["name"], "abc"); } #[test] #[should_panic] #[cfg_attr(all(target_env = "msvc", target_pointer_width = "32"), ignore)] fn test_cap_index_panic_usize() { let re = Regex::new(r"^(?P<name>.+)$").unwrap(); let cap = re.captures("abc").unwrap(); let _ = cap[2]; } #[test] #[should_panic] #[cfg_attr(all(target_env = "msvc", target_pointer_width = "32"), ignore)] fn test_cap_index_panic_name() { let re = Regex::new(r"^(?P<name>.+)$").unwrap(); let cap = re.captures("abc").unwrap(); let _ = cap["bad name"]; } } ���������������������������������������������������deps/regex-0.1.44/src/compile.rs��������������������������������������������������������������������0000644�0001750�0000144�00000023545�12635537522�014453� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use syntax::{Expr, Repeater, CharClass, ClassRange}; use Error; use program::{CharRanges, Inst, InstIdx}; pub type Compiled = (Vec<Inst>, Vec<Option<String>>); /// A regex compiler. /// /// A regex compiler is responsible for turning a regex's AST into a sequence /// of instructions. pub struct Compiler { size_limit: usize, insts: Vec<Inst>, cap_names: Vec<Option<String>>, } impl Compiler { /// Creates a new compiler that limits the size of the regex program /// to the size given (in bytes). pub fn new(size_limit: usize) -> Compiler { Compiler { size_limit: size_limit, insts: vec![], cap_names: vec![None], } } /// Compiles the given regex AST into a tuple of a sequence of /// instructions and a sequence of capture groups, optionally named. pub fn compile(mut self, ast: Expr) -> Result<Compiled, Error> { self.insts.push(Inst::Save(0)); try!(self.c(ast)); self.insts.push(Inst::Save(1)); self.insts.push(Inst::Match); Ok((self.insts, self.cap_names)) } fn c(&mut self, ast: Expr) -> Result<(), Error> { use program::Inst::*; use program::LookInst::*; match ast { Expr::Empty => {}, Expr::Literal { chars, casei } => { for c in chars { if casei { try!(self.c(Expr::Class(CharClass::new(vec![ ClassRange { start: c, end: c }, ]).case_fold()))); } else { self.push(Char(c)); } } } Expr::AnyChar => self.push(Ranges(CharRanges::any())), Expr::AnyCharNoNL => self.push(Ranges(CharRanges::any_nonl())), Expr::Class(cls) => { if cls.len() == 1 && cls[0].start == cls[0].end { self.push(Char(cls[0].start)); } else { self.push(Ranges(CharRanges::from_class(cls))); } } Expr::StartLine => self.push(EmptyLook(StartLine)), Expr::EndLine => self.push(EmptyLook(EndLine)), Expr::StartText => self.push(EmptyLook(StartText)), Expr::EndText => self.push(EmptyLook(EndText)), Expr::WordBoundary => self.push(EmptyLook(WordBoundary)), Expr::NotWordBoundary => self.push(EmptyLook(NotWordBoundary)), Expr::Group { e, i: None, name: None } => try!(self.c(*e)), Expr::Group { e, i, name } => { let i = i.expect("capture index"); self.cap_names.push(name); self.push(Save(2 * i)); try!(self.c(*e)); self.push(Save(2 * i + 1)); } Expr::Concat(es) => { for e in es { try!(self.c(e)); } } Expr::Alternate(mut es) => { // TODO: Don't use recursion here. ---AG if es.is_empty() { return Ok(()); } let e1 = es.remove(0); if es.is_empty() { try!(self.c(e1)); return Ok(()); } let e2 = Expr::Alternate(es); // this causes recursion let split = self.empty_split(); let j1 = self.insts.len(); try!(self.c(e1)); let jmp = self.empty_jump(); let j2 = self.insts.len(); try!(self.c(e2)); let j3 = self.insts.len(); self.set_split(split, j1, j2); self.set_jump(jmp, j3); } Expr::Repeat { e, r: Repeater::ZeroOrOne, greedy } => { let split = self.empty_split(); let j1 = self.insts.len(); try!(self.c(*e)); let j2 = self.insts.len(); if greedy { self.set_split(split, j1, j2); } else { self.set_split(split, j2, j1); } } Expr::Repeat { e, r: Repeater::ZeroOrMore, greedy } => { let j1 = self.insts.len(); let split = self.empty_split(); let j2 = self.insts.len(); try!(self.c(*e)); let jmp = self.empty_jump(); let j3 = self.insts.len(); self.set_jump(jmp, j1); if greedy { self.set_split(split, j2, j3); } else { self.set_split(split, j3, j2); } } Expr::Repeat { e, r: Repeater::OneOrMore, greedy } => { let j1 = self.insts.len(); try!(self.c(*e)); let split = self.empty_split(); let j2 = self.insts.len(); if greedy { self.set_split(split, j1, j2); } else { self.set_split(split, j2, j1); } } Expr::Repeat { e, r: Repeater::Range { min, max: None }, greedy, } => { let e = *e; for _ in 0..min { try!(self.c(e.clone())); } try!(self.c(Expr::Repeat { e: Box::new(e), r: Repeater::ZeroOrMore, greedy: greedy, })); } Expr::Repeat { e, r: Repeater::Range { min, max: Some(max) }, greedy, } => { let e = *e; for _ in 0..min { try!(self.c(e.clone())); } // It is much simpler to compile, e.g., `a{2,5}` as: // // aaa?a?a? // // But you end up with a sequence of instructions like this: // // 0: 'a' // 1: 'a', // 2: split(3, 4) // 3: 'a' // 4: split(5, 6) // 5: 'a' // 6: split(7, 8) // 7: 'a' // 8: MATCH // // This is *incredibly* inefficient because the splits end // up forming a chain. Given a much larger number than `5`, // it is easy cause perverse behavior in the matching engines // like stack overflows. We could fix the matching engine, // but instead, we should just make the program smarter. // Thus, we do a custom job here and instead of chaining the // splits together, we simply point them to the MATCH // instruction directly. let (mut splits, mut starts) = (vec![], vec![]); for _ in min..max { splits.push(self.empty_split()); starts.push(self.insts.len()); try!(self.c(e.clone())); } let end = self.insts.len(); for (split, start) in splits.into_iter().zip(starts) { if greedy { self.set_split(split, start, end); } else { self.set_split(split, end, start); } } } } self.check_size() } fn check_size(&self) -> Result<(), Error> { use std::mem::size_of; if self.insts.len() * size_of::<Inst>() > self.size_limit { Err(Error::CompiledTooBig(self.size_limit)) } else { Ok(()) } } /// Appends the given instruction to the program. #[inline] fn push(&mut self, x: Inst) { self.insts.push(x) } /// Appends an *empty* `Split` instruction to the program and returns /// the index of that instruction. (The index can then be used to "patch" /// the actual locations of the split in later.) #[inline] fn empty_split(&mut self) -> InstIdx { self.insts.push(Inst::Split(0, 0)); self.insts.len() - 1 } /// Sets the left and right locations of a `Split` instruction at index /// `i` to `pc1` and `pc2`, respectively. /// If the instruction at index `i` isn't a `Split` instruction, then /// `panic!` is called. #[inline] fn set_split(&mut self, i: InstIdx, pc1: InstIdx, pc2: InstIdx) { let split = &mut self.insts[i]; match *split { Inst::Split(_, _) => *split = Inst::Split(pc1, pc2), _ => panic!("BUG: Invalid split index."), } } /// Appends an *empty* `Jump` instruction to the program and returns the /// index of that instruction. #[inline] fn empty_jump(&mut self) -> InstIdx { self.insts.push(Inst::Jump(0)); self.insts.len() - 1 } /// Sets the location of a `Jump` instruction at index `i` to `pc`. /// If the instruction at index `i` isn't a `Jump` instruction, then /// `panic!` is called. #[inline] fn set_jump(&mut self, i: InstIdx, pc: InstIdx) { let jmp = &mut self.insts[i]; match *jmp { Inst::Jump(_) => *jmp = Inst::Jump(pc), _ => panic!("BUG: Invalid jump index."), } } } �����������������������������������������������������������������������������������������������������������������������������������������������������������deps/regex-0.1.44/src/char.rs�����������������������������������������������������������������������0000644�0001750�0000144�00000005615�12635537042�013733� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::char; use std::cmp::Ordering; use std::fmt; use std::u32; use syntax; /// An inline representation of `Option<char>`. /// /// This eliminates the need to do case analysis on `Option<char>` to determine /// ordinality with other characters. /// /// (The `Option<char>` is not related to encoding. Instead, it is used in the /// matching engines to represent the beginning and ending boundaries of the /// search text.) #[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct Char(u32); impl fmt::Debug for Char { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match char::from_u32(self.0) { None => write!(f, "Empty"), Some(c) => write!(f, "{:?}", c), } } } impl Char { /// Returns true iff the character is absent. #[inline] pub fn is_none(self) -> bool { self.0 == u32::MAX } /// Returns the length of the character's UTF-8 encoding. /// /// If the character is absent, then `0` is returned. #[inline] pub fn len_utf8(self) -> usize { char::from_u32(self.0).map_or(0, |c| c.len_utf8()) } /// Returns true iff the character is a word character. /// /// If the character is absent, then false is returned. pub fn is_word_char(self) -> bool { char::from_u32(self.0).map_or(false, syntax::is_word_char) } /// Converts the character to a real primitive `char`. /// /// If the character is absent, then `None` is returned. pub fn as_char(self) -> Option<char> { // This is only used in the `regex!` macro because it expands char // classes into `match` expressions (instead of binary search). char::from_u32(self.0) } } impl From<char> for Char { fn from(c: char) -> Char { Char(c as u32) } } impl From<Option<char>> for Char { fn from(c: Option<char>) -> Char { c.map_or(Char(u32::MAX), |c| c.into()) } } impl PartialEq<char> for Char { #[inline] fn eq(&self, other: &char) -> bool { self.0 == *other as u32 } } impl PartialEq<Char> for char { #[inline] fn eq(&self, other: &Char) -> bool { *self as u32 == other.0 } } impl PartialOrd<char> for Char { #[inline] fn partial_cmp(&self, other: &char) -> Option<Ordering> { self.0.partial_cmp(&(*other as u32)) } } impl PartialOrd<Char> for char { #[inline] fn partial_cmp(&self, other: &Char) -> Option<Ordering> { (*self as u32).partial_cmp(&other.0) } } �������������������������������������������������������������������������������������������������������������������deps/regex-0.1.44/src/input.rs����������������������������������������������������������������������0000644�0001750�0000144�00000006215�12540414226�014143� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::ops; use char::Char; use prefix::Prefix; /// Represents a location in the input. #[derive(Clone, Copy, Debug)] pub struct InputAt { pos: usize, c: Char, len: usize, } impl InputAt { /// Returns true iff this position is at the beginning of the input. pub fn is_beginning(&self) -> bool { self.pos == 0 } /// Returns the character at this position. /// /// If this position is just before or after the input, then an absent /// character is returned. pub fn char(&self) -> Char { self.c } /// Returns the UTF-8 width of the character at this position. pub fn len(&self) -> usize { self.len } /// Returns the byte offset of this position. pub fn pos(&self) -> usize { self.pos } /// Returns the byte offset of the next position in the input. pub fn next_pos(&self) -> usize { self.pos + self.len } } /// An abstraction over input used in the matching engines. pub trait Input { /// Return an encoding of the position at byte offset `i`. fn at(&self, i: usize) -> InputAt; /// Return an encoding of the char position just prior to byte offset `i`. fn previous_at(&self, i: usize) -> InputAt; /// Scan the input for a matching prefix. fn prefix_at(&self, prefixes: &Prefix, at: InputAt) -> Option<InputAt>; } /// An input reader over characters. /// /// (This is the only implementation of `Input` at the moment.) #[derive(Debug)] pub struct CharInput<'t>(&'t str); impl<'t> CharInput<'t> { /// Return a new character input reader for the given string. pub fn new(s: &'t str) -> CharInput<'t> { CharInput(s) } } impl<'t> ops::Deref for CharInput<'t> { type Target = str; fn deref(&self) -> &str { self.0 } } impl<'t> Input for CharInput<'t> { // This `inline(always)` increases throughput by almost 25% on the `hard` // benchmarks over a normal `inline` annotation. // // I'm not sure why `#[inline]` isn't enough to convince LLVM, but it is // used *a lot* in the guts of the matching engines. #[inline(always)] fn at(&self, i: usize) -> InputAt { let c = self[i..].chars().next().into(); InputAt { pos: i, c: c, len: c.len_utf8(), } } fn previous_at(&self, i: usize) -> InputAt { let c: Char = self[..i].chars().rev().next().into(); let len = c.len_utf8(); InputAt { pos: i - len, c: c, len: len, } } fn prefix_at(&self, prefixes: &Prefix, at: InputAt) -> Option<InputAt> { prefixes.find(&self[at.pos()..]).map(|(s, _)| self.at(at.pos() + s)) } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/regex-0.1.44/src/backtrack.rs������������������������������������������������������������������0000644�0001750�0000144�00000022241�12635537477�014751� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // This is the backtracking matching engine. It has the same exact capability // as the full NFA simulation, except it is artificially restricted to small // regexes on small inputs because of its memory requirements. // // In particular, this is a *bounded* backtracking engine. It retains worst // case linear time by keeping track of the states that is has visited (using a // bitmap). Namely, once a state is visited, it is never visited again. Since a // state is keyed by `(instruction index, input index)`, we have that its time // complexity is `O(mn)`. // // The backtracking engine can beat out the NFA simulation on small // regexes/inputs because it doesn't have to keep track of multiple copies of // the capture groups. In benchmarks, the backtracking engine is roughly twice // as fast as the full NFA simulation. use input::{Input, InputAt, CharInput}; use program::{InstIdx, Program}; use re::CaptureIdxs; type Bits = u32; const BIT_SIZE: usize = 32; const MAX_PROG_SIZE: usize = 100; const MAX_INPUT_SIZE: usize = 256 * (1 << 10); // Total memory usage in bytes is determined by: // // ((len(insts) * (len(input) + 1) + bits - 1) / bits) / (bits / 8) // // With the above settings, this comes out to ~3.2MB. Mostly these numbers // were picked empirically with suspicious benchmarks. /// A backtracking matching engine. #[derive(Debug)] pub struct Backtrack<'a, 'r, 't, 'c> { prog: &'r Program, input: CharInput<'t>, caps: &'c mut CaptureIdxs, m: &'a mut BackMachine, } /// Shared cached state between multiple invocations of a backtracking engine /// in the same thread. /// /// It is exported so that it can be cached by `program::Program`. #[derive(Debug)] pub struct BackMachine { jobs: Vec<Job>, visited: Vec<Bits>, } impl BackMachine { /// Create new empty state for the backtracking engine. pub fn new() -> BackMachine { BackMachine { jobs: vec![], visited: vec![], } } } /// A job is an explicit unit of stack space in the backtracking engine. /// /// The "normal" representation is a single state transition, which corresponds /// to an NFA state and a character in the input. However, the backtracking /// engine must keep track of old capture group values. We use the explicit /// stack to do it. #[derive(Clone, Copy, Debug)] enum Job { Inst { pc: InstIdx, at: InputAt }, SaveRestore { slot: usize, old_pos: Option<usize> }, } impl<'a, 'r, 't, 'c> Backtrack<'a, 'r, 't, 'c> { /// Execute the backtracking matching engine. /// /// If there's a match, `exec` returns `true` and populates the given /// captures accordingly. pub fn exec( prog: &'r Program, mut caps: &mut CaptureIdxs, text: &'t str, start: usize, ) -> bool { let input = CharInput::new(text); let start = input.at(start); let mut m = prog.backtrack.get(); let mut b = Backtrack { prog: prog, input: input, caps: caps, m: &mut m, }; b.exec_(start) } /// Returns true iff the given regex and input can be executed by this /// engine with reasonable memory usage. pub fn should_exec(prog: &'r Program, input: &str) -> bool { prog.insts.len() <= MAX_PROG_SIZE && input.len() <= MAX_INPUT_SIZE } fn clear(&mut self) { // Reset the job memory so that we start fresh. self.m.jobs.truncate(0); // Now we need to clear the bit state set. // We do this by figuring out how much space we need to keep track // of the states we've visited. // Then we reset all existing allocated space to 0. // Finally, we request more space if we need it. // // This is all a little circuitous, but doing this unsafely // doesn't seem to have a measurable impact on performance. // (Probably because backtracking is limited to such small // inputs/regexes in the first place.) let visited_len = (self.prog.insts.len() * (self.input.len() + 1) + BIT_SIZE - 1) / BIT_SIZE; for v in &mut self.m.visited { *v = 0; } let cur_visited_cap = self.m.visited.capacity(); if visited_len > cur_visited_cap { self.m.visited.reserve_exact(visited_len - cur_visited_cap); for _ in 0..(visited_len - cur_visited_cap) { self.m.visited.push(0); } } } fn exec_(&mut self, mut at: InputAt) -> bool { self.clear(); if self.prog.anchored_begin { return if !at.is_beginning() { false } else { match self.input.prefix_at(&self.prog.prefixes, at) { None => false, Some(at) => self.backtrack(at), } }; } loop { if !self.prog.prefixes.is_empty() { at = match self.input.prefix_at(&self.prog.prefixes, at) { None => return false, Some(at) => at, }; } if self.backtrack(at) { return true; } if at.char().is_none() { return false; } at = self.input.at(at.next_pos()); } } // This `inline(always)` seems to result in about a 10-15% increase in // throughput on the `hard` benchmarks (over a standard `inline`). ---AG #[inline(always)] fn backtrack(&mut self, start: InputAt) -> bool { self.push(0, start); while let Some(job) = self.m.jobs.pop() { match job { Job::Inst { pc, at } => { if self.step(pc, at) { return true; } } Job::SaveRestore { slot, old_pos } => { self.caps[slot] = old_pos; } } } false } fn step(&mut self, mut pc: InstIdx, mut at: InputAt) -> bool { use program::Inst::*; loop { // This loop is an optimization to avoid constantly pushing/popping // from the stack. Namely, if we're pushing a job only to run it // next, avoid the push and just mutate `pc` (and possibly `at`) // in place. match self.prog.insts[pc] { Match => return true, Save(slot) => { if slot < self.caps.len() { // If this path doesn't work out, then we save the old // capture index (if one exists) in an alternate // job. If the next path fails, then the alternate // job is popped and the old capture index is restored. let old_pos = self.caps[slot]; self.push_save_restore(slot, old_pos); self.caps[slot] = Some(at.pos()); } pc += 1; } Jump(pc2) => pc = pc2, Split(x, y) => { self.push(y, at); pc = x; } EmptyLook(ref inst) => { let prev = self.input.previous_at(at.pos()); if inst.matches(prev.char(), at.char()) { pc += 1; } else { return false; } } Char(c) => { if c == at.char() { pc += 1; at = self.input.at(at.next_pos()); } else { return false; } } Ranges(ref inst) => { if inst.matches(at.char()) { pc += 1; at = self.input.at(at.next_pos()); } else { return false; } } } if self.has_visited(pc, at) { return false; } } } fn push(&mut self, pc: InstIdx, at: InputAt) { self.m.jobs.push(Job::Inst { pc: pc, at: at }); } fn push_save_restore(&mut self, slot: usize, old_pos: Option<usize>) { self.m.jobs.push(Job::SaveRestore { slot: slot, old_pos: old_pos }); } fn has_visited(&mut self, pc: InstIdx, at: InputAt) -> bool { let k = pc * (self.input.len() + 1) + at.pos(); let k1 = k / BIT_SIZE; let k2 = (1 << (k & (BIT_SIZE - 1))) as Bits; if self.m.visited[k1] & k2 == 0 { self.m.visited[k1] |= k2; false } else { true } } } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/regex-0.1.44/src/nfa.rs������������������������������������������������������������������������0000644�0001750�0000144�00000023125�12635537042�013556� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // FIXME: Currently, the VM simulates an NFA. It would be nice to have another // VM that simulates a DFA. // // According to Russ Cox[1], a DFA performs better than an NFA, principally // because it reuses states previously computed by the machine *and* doesn't // keep track of capture groups. The drawback of a DFA (aside from its // complexity) is that it can't accurately return the locations of submatches. // The NFA *can* do that. (This is my understanding anyway.) // // Cox suggests that a DFA ought to be used to answer "does this match" and // "where does it match" questions. (In the latter, the starting position of // the match is computed by executing the regex backwards.) Cox also suggests // that a DFA should be run when asking "where are the submatches", which can // 1) quickly answer "no" is there's no match and 2) discover the substring // that matches, which means running the NFA on smaller input. // // Currently, the NFA simulation implemented below does some dirty tricks to // avoid tracking capture groups when they aren't needed (which only works // for 'is_match', not 'find'). This is a half-measure, but does provide some // perf improvement. // // AFAIK, the DFA/NFA approach is implemented in RE2/C++ but *not* in RE2/Go. // // UPDATE: We now have a backtracking matching engine and a DFA for prefix // matching. The prefix DFA is used in both the NFA simulation below and the // backtracking engine to skip along the input quickly. // // [1] - http://swtch.com/~rsc/regex/regex3.html use input::{Input, InputAt, CharInput}; use program::Program; use re::CaptureIdxs; /// An NFA simulation matching engine. #[derive(Debug)] pub struct Nfa<'r, 't> { prog: &'r Program, input: CharInput<'t>, } impl<'r, 't> Nfa<'r, 't> { /// Execute the NFA matching engine. /// /// If there's a match, `exec` returns `true` and populates the given /// captures accordingly. pub fn exec( prog: &'r Program, mut caps: &mut CaptureIdxs, text: &'t str, start: usize, ) -> bool { let mut q = prog.nfa_threads.get(); let input = CharInput::new(text); let at = input.at(start); Nfa { prog: prog, input: input, }.exec_(&mut q, &mut caps, at) } fn exec_( &mut self, mut q: &mut NfaThreads, mut caps: &mut CaptureIdxs, mut at: InputAt, ) -> bool { let mut matched = false; q.clist.empty(); q.nlist.empty(); 'LOOP: loop { if q.clist.size == 0 { // Three ways to bail out when our current set of threads is // empty. // // 1. We have a match---so we're done exploring any possible // alternatives. Time to quit. // // 2. If the expression starts with a '^' we can terminate as // soon as the last thread dies. if matched || (!at.is_beginning() && self.prog.anchored_begin) { break; } // 3. If there's a literal prefix for the program, try to // jump ahead quickly. If it can't be found, then we can // bail out early. if !self.prog.prefixes.is_empty() { at = match self.input.prefix_at(&self.prog.prefixes, at) { None => break, Some(at) => at, }; } } // This simulates a preceding '.*?' for every regex by adding // a state starting at the current position in the input for the // beginning of the program only if we don't already have a match. if q.clist.size == 0 || (!self.prog.anchored_begin && !matched) { self.add(&mut q.clist, &mut caps, 0, at) } // The previous call to "add" actually inspects the position just // before the current character. For stepping through the machine, // we can to look at the current character, so we advance the // input. let at_next = self.input.at(at.next_pos()); for i in 0..q.clist.size { let pc = q.clist.pc(i); let tcaps = q.clist.caps(i); if self.step(&mut q.nlist, caps, tcaps, pc, at, at_next) { matched = true; if caps.len() == 0 { // If we only care if a match occurs (not its // position), then we can quit right now. break 'LOOP; } // We don't need to check the rest of the threads in this // set because we've matched something ("leftmost-first"). // However, we still need to check threads in the next set // to support things like greedy matching. break; } } if at.char().is_none() { break; } at = at_next; q.swap(); q.nlist.empty(); } matched } fn step( &self, nlist: &mut Threads, caps: &mut [Option<usize>], thread_caps: &mut [Option<usize>], pc: usize, at: InputAt, at_next: InputAt, ) -> bool { use program::Inst::*; match self.prog.insts[pc] { Match => { for (slot, val) in caps.iter_mut().zip(thread_caps.iter()) { *slot = *val; } true } Char(c) => { if c == at.char() { self.add(nlist, thread_caps, pc+1, at_next); } false } Ranges(ref inst) => { if inst.matches(at.char()) { self.add(nlist, thread_caps, pc+1, at_next); } false } EmptyLook(_) | Save(_) | Jump(_) | Split(_, _) => false, } } fn add( &self, nlist: &mut Threads, thread_caps: &mut [Option<usize>], pc: usize, at: InputAt, ) { use program::Inst::*; if nlist.contains(pc) { return } let ti = nlist.add(pc); match self.prog.insts[pc] { EmptyLook(ref inst) => { let prev = self.input.previous_at(at.pos()); if inst.matches(prev.char(), at.char()) { self.add(nlist, thread_caps, pc+1, at); } } Save(slot) => { if slot >= thread_caps.len() { self.add(nlist, thread_caps, pc+1, at); } else { let old = thread_caps[slot]; thread_caps[slot] = Some(at.pos()); self.add(nlist, thread_caps, pc+1, at); thread_caps[slot] = old; } } Jump(to) => { self.add(nlist, thread_caps, to, at) } Split(x, y) => { self.add(nlist, thread_caps, x, at); self.add(nlist, thread_caps, y, at); } Match | Char(_) | Ranges(_) => { let mut t = &mut nlist.thread(ti); for (slot, val) in t.caps.iter_mut().zip(thread_caps.iter()) { *slot = *val; } } } } } /// Shared cached state between multiple invocations of a NFA engine /// in the same thread. /// /// It is exported so that it can be cached by `program::Program`. #[derive(Debug)] pub struct NfaThreads { clist: Threads, nlist: Threads, } #[derive(Debug)] struct Threads { dense: Vec<Thread>, sparse: Vec<usize>, size: usize, } #[derive(Clone, Debug)] struct Thread { pc: usize, caps: Vec<Option<usize>>, } impl NfaThreads { /// Create new empty state for the NFA engine. pub fn new(num_insts: usize, ncaps: usize) -> NfaThreads { NfaThreads { clist: Threads::new(num_insts, ncaps), nlist: Threads::new(num_insts, ncaps), } } fn swap(&mut self) { ::std::mem::swap(&mut self.clist, &mut self.nlist); } } impl Threads { fn new(num_insts: usize, ncaps: usize) -> Threads { let t = Thread { pc: 0, caps: vec![None; ncaps * 2] }; Threads { dense: vec![t; num_insts], sparse: vec![0; num_insts], size: 0, } } fn add(&mut self, pc: usize) -> usize { let i = self.size; self.dense[i].pc = pc; self.sparse[pc] = i; self.size += 1; i } fn thread(&mut self, i: usize) -> &mut Thread { &mut self.dense[i] } fn contains(&self, pc: usize) -> bool { let s = self.sparse[pc]; s < self.size && self.dense[s].pc == pc } fn empty(&mut self) { self.size = 0; } fn pc(&self, i: usize) -> usize { self.dense[i].pc } fn caps(&mut self, i: usize) -> &mut [Option<usize>] { &mut self.dense[i].caps } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/regex-0.1.44/src/pool.rs�����������������������������������������������������������������������0000644�0001750�0000144�00000006642�12635537042�013770� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::fmt; use std::ops::{Deref, DerefMut, Drop}; use std::sync::Mutex; /// A very simple memory pool for managing cached state. /// /// This was motivated by a singular purpose: reduce the allocation overhead /// of matching engines. /// /// With a pool, the matching engines need to allocate state each time they /// are invoked. If a regex is used once to check for a match and never again, /// then this is OK. But if a regex is used many times over, then not /// re-allocating the engine's state is a huge win. (A regex is commonly /// used many times, for example, with `find_iter`, `captures_iter` or /// `replace_all`.) /// /// We use inherited mutability and ensure that each thread gets its own /// state. There is no limit on the number of states that are created. If a /// thread requests one and one isn't available, a new one is created. pub struct Pool<T> { stack: Mutex<Vec<T>>, create: CreateFn<T>, } /// The type of the function used to create resources if none exist. pub type CreateFn<T> = Box<Fn() -> T + Send + Sync>; /// A guard the provides access to a value pulled from the pool. #[derive(Debug)] pub struct PoolGuard<'a, T: 'a> { pool: &'a Pool<T>, val: Option<T>, } impl<T> Pool<T> { /// Create a new pool. /// /// When a caller requests a resource from the pool and one does not /// exist, then `create` is called to allocate a new resource for the /// caller. /// /// It is up to the caller to put the resource back into the pool for /// future reuse. /// /// All resources are created lazily/on-demand. pub fn new(create: CreateFn<T>) -> Pool<T> { Pool { stack: Mutex::new(vec![]), create: create, } } /// Request a resource from the pool. /// /// If no resources are available, a new one is created. /// /// Once the guard is dropped, the resource is returned to the pool. pub fn get(&self) -> PoolGuard<T> { let mut stack = self.stack.lock().unwrap(); match stack.pop() { None => PoolGuard { pool: self, val: Some((self.create)()) }, Some(v) => PoolGuard { pool: self, val: Some(v) }, } } /// Add a resource to the pool. /// /// This makes the resource available for use with `get`. fn put(&self, v: T) { let mut stack = self.stack.lock().unwrap(); stack.push(v); } } impl<'a, T> Deref for PoolGuard<'a, T> { type Target = T; fn deref(&self) -> &T { self.val.as_ref().unwrap() } } impl<'a, T> DerefMut for PoolGuard<'a, T> { fn deref_mut(&mut self) -> &mut T { self.val.as_mut().unwrap() } } impl<'a, T> Drop for PoolGuard<'a, T> { fn drop(&mut self) { let val = self.val.take().unwrap(); self.pool.put(val); } } impl<T: fmt::Debug> fmt::Debug for Pool<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let stack = self.stack.lock(); let stack = stack.unwrap(); stack.fmt(f) } } ����������������������������������������������������������������������������������������������deps/regex-0.1.44/src/prefix.rs���������������������������������������������������������������������0000644�0001750�0000144�00000021621�12635537544�014315� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::fmt; use aho_corasick::{Automaton, AcAutomaton, FullAcAutomaton}; use memchr::memchr; /// A prefix extracted from a compiled regular expression. /// /// A regex prefix is a set of literal strings that *must* be matched at the /// beginning of a regex in order for the entire regex to match. /// /// There are a variety of ways to efficiently scan the search text for a /// prefix. Currently, there are three implemented: /// /// 1. The prefix is a single byte. Just use memchr. /// 2. If the prefix is a set of two or more single byte prefixes, then /// a single sparse map is created. Checking if there is a match is a lookup /// in this map for each byte in the search text. /// 3. In all other cases, build an Aho-Corasick automaton. /// /// It's possible that there's room here for other substring algorithms, /// such as Boyer-Moore for single-set prefixes greater than 1, or Rabin-Karp /// for small sets of same-length prefixes. #[derive(Clone)] pub enum Prefix { /// No prefixes. (Never advances through the input.) Empty, /// A single byte prefix. Byte(u8), /// A set of two or more single byte prefixes. /// This could be reduced to a bitset, which would use only 8 bytes, /// but I don't think we care. Bytes { chars: Vec<u8>, sparse: Vec<bool>, }, Single(SingleSearch), /// A full Aho-Corasick DFA automaton. Automaton(FullAcAutomaton<String>), } impl Prefix { /// Create a new prefix matching machine. pub fn new(mut pfxs: Vec<String>) -> Prefix { if pfxs.is_empty() || pfxs[0].is_empty() { Prefix::Empty } else if pfxs.len() == 1 && pfxs[0].len() == 1 { Prefix::Byte(pfxs[0].as_bytes()[0]) } else if pfxs.len() >= 2 && pfxs.iter().all(|s| s.len() == 1) { let mut set = vec![false; 256]; let mut chars = vec![]; for p in pfxs { chars.push(p.as_bytes()[0]); set[p.as_bytes()[0] as usize] = true; } Prefix::Bytes { chars: chars, sparse: set } } else if pfxs.len() == 1 { Prefix::Single(SingleSearch::new(pfxs.pop().unwrap())) } else { Prefix::Automaton(AcAutomaton::new(pfxs).into_full()) } } /// Find the position of a prefix in `haystack` if it exists. /// /// In the matching engines, we only actually need the starting index /// because the prefix is used to only skip ahead---the matching engine /// still needs to run over the prefix input. However, we return the ending /// location as well in case the prefix corresponds to the entire regex, /// in which case, you need the end of the match. pub fn find(&self, haystack: &str) -> Option<(usize, usize)> { use self::Prefix::*; match *self { Empty => Some((0, 0)), Byte(b) => memchr(b, haystack.as_bytes()).map(|i| (i, i+1)), Bytes { ref sparse, .. } => { find_singles(sparse, haystack.as_bytes()) } Single(ref searcher) => { searcher.find(haystack).map(|i| (i, i + searcher.pat.len())) } Automaton(ref aut) => { aut.find(haystack).next().map(|m| (m.start, m.end)) } } } /// Returns true iff this prefix is empty. pub fn is_empty(&self) -> bool { self.len() == 0 } /// Returns the number of prefixes in this machine. pub fn len(&self) -> usize { match *self { Prefix::Empty => 0, Prefix::Byte(_) => 1, Prefix::Bytes { ref chars, .. } => chars.len(), Prefix::Single(_) => 1, Prefix::Automaton(ref aut) => aut.len(), } } /// Returns true iff the prefix match preserves priority. /// /// For example, given the alternation `ab|a` and the target string `ab`, /// does the prefix machine guarantee that `ab` will match? (A full /// Aho-Corasick automaton does not!) pub fn preserves_priority(&self) -> bool { match *self { Prefix::Empty => true, Prefix::Byte(_) => true, Prefix::Bytes{..} => true, Prefix::Single(_) => true, Prefix::Automaton(ref aut) => { // Okay, so the automaton can respect priority in one // particular case: when every pattern is of the same length. // The trick is that the automaton will report the leftmost // match, which in this case, corresponds to the correct // match for the regex engine. If any other alternate matches // at the same position, then they must be exactly equivalent. // Guaranteed at least one prefix by construction, so use // that for the length. aut.patterns().iter().all(|p| p.len() == aut.pattern(0).len()) } } } /// Returns all of the prefixes participating in this machine. /// /// For debug/testing only! (It allocates.) #[allow(dead_code)] pub fn prefixes(&self) -> Vec<String> { match *self { Prefix::Empty => vec![], Prefix::Byte(b) => vec![format!("{}", b as char)], Prefix::Bytes { ref chars, .. } => { chars.iter().map(|&b| format!("{}", b as char)).collect() } Prefix::Single(ref searcher) => vec![searcher.pat.clone()], Prefix::Automaton(ref aut) => aut.patterns().to_vec(), } } } /// Provides an implementation of fast subtring search. /// /// In particular, this uses Boyer-Moore-Horspool with Tim Raita's twist: /// https://en.wikipedia.org/wiki/Raita_Algorithm /// /// I'm skeptical of the utility here, because benchmarks suggest that it is /// difficult to beat Aho-Corasick on random text. Namely, both algorithms are /// dominated by the performance of `memchr` for the leading byte prefix. /// With that said, BMH does seem to surpass AC when the search text gets /// longer (see the `easy0_1MB` vs. `easy1_1MB` benchmarks). /// /// More analysis needs to be done to test this on different search texts. #[derive(Clone, Debug)] pub struct SingleSearch { pat: String, shift: Vec<usize>, } impl SingleSearch { fn new(pat: String) -> SingleSearch { assert!(pat.len() >= 1); let mut shift = vec![pat.len(); 256]; for i in 0..(pat.len() - 1) { shift[pat.as_bytes()[i] as usize] = pat.len() - i - 1; } SingleSearch { pat: pat, shift: shift, } } fn find(&self, haystack: &str) -> Option<usize> { let pat = self.pat.as_bytes(); let haystack = haystack.as_bytes(); if haystack.len() < pat.len() { return None; } let mut i = match memchr(pat[0], haystack) { None => return None, Some(i) => i, }; while i <= haystack.len() - pat.len() { let b = haystack[i + pat.len() - 1]; if b == pat[pat.len() - 1] && haystack[i] == pat[0] && haystack[i + (pat.len() / 2)] == pat[pat.len() / 2] && pat == &haystack[i..i + pat.len()] { return Some(i); } i += self.shift[b as usize]; i += match memchr(pat[0], &haystack[i..]) { None => return None, Some(i) => i, }; } None } } /// A quick scan for multiple single byte prefixes using a sparse map. fn find_singles(sparse: &[bool], haystack: &[u8]) -> Option<(usize, usize)> { // TODO: Improve this with ideas found in jetscii crate. for (hi, &b) in haystack.iter().enumerate() { if sparse[b as usize] { return Some((hi, hi+1)); } } None } impl fmt::Debug for Prefix { #[allow(deprecated)] // connect => join in 1.3 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Prefix::Empty => write!(f, "Empty"), Prefix::Byte(b) => write!(f, "{:?}", b as char), Prefix::Bytes { ref chars, .. } => { let chars: Vec<String> = chars.iter() .map(|&c| format!("{:?}", c as char)) .collect(); write!(f, "{}", chars.connect(", ")) } Prefix::Single(ref searcher) => write!(f, "{:?}", searcher), Prefix::Automaton(ref aut) => write!(f, "{:?}", aut), } } } ���������������������������������������������������������������������������������������������������������������deps/regex-0.1.44/run-shootout-test�����������������������������������������������������������������0000755�0001750�0000144�00000001032�12541316173�015233� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/bin/bash set -e cargo build --example shootout-regex-dna diff \ ./examples/regexdna-output.txt \ <(./target/debug/examples/shootout-regex-dna < ./examples/regexdna-input.txt) cargo build --example shootout-regex-dna-single diff \ ./examples/regexdna-output.txt \ <(./target/debug/examples/shootout-regex-dna-single < ./examples/regexdna-input.txt) cargo build --example shootout-regex-dna-cheat diff \ ./examples/regexdna-output.txt \ <(./target/debug/examples/shootout-regex-dna-cheat < ./examples/regexdna-input.txt) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/regex-0.1.44/scripts/��������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635520�014045� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/regex-0.1.44/scripts/unicode.py����������������������������������������������������������������0000755�0001750�0000144�00000023462�12553257506�015356� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python2 # # Copyright 2011-2013 The Rust Project Developers. See the COPYRIGHT # file at the top-level directory of this distribution and at # http://rust-lang.org/COPYRIGHT. # # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your # option. This file may not be copied, modified, or distributed # except according to those terms. # This script uses the following Unicode tables: # - DerivedCoreProperties.txt # - EastAsianWidth.txt # - PropList.txt # - Scripts.txt # - UnicodeData.txt # # Since this should not require frequent updates, we just store this # out-of-line and check the unicode.rs file into git. from collections import defaultdict import fileinput, re, os, sys preamble = '''// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // NOTE: The following code was generated by "scripts/unicode.py", do not edit // directly #![allow(warnings)] ''' # Mapping taken from Table 12 from: # http://www.unicode.org/reports/tr44/#General_Category_Values expanded_categories = { 'Lu': ['LC', 'L'], 'Ll': ['LC', 'L'], 'Lt': ['LC', 'L'], 'Lm': ['L'], 'Lo': ['L'], 'Mn': ['M'], 'Mc': ['M'], 'Me': ['M'], 'Nd': ['N'], 'Nl': ['N'], 'No': ['No'], 'Pc': ['P'], 'Pd': ['P'], 'Ps': ['P'], 'Pe': ['P'], 'Pi': ['P'], 'Pf': ['P'], 'Po': ['P'], 'Sm': ['S'], 'Sc': ['S'], 'Sk': ['S'], 'So': ['S'], 'Zs': ['Z'], 'Zl': ['Z'], 'Zp': ['Z'], 'Cc': ['C'], 'Cf': ['C'], 'Cs': ['C'], 'Co': ['C'], 'Cn': ['C'], } def fetch(f): if not os.path.exists(f): os.system("curl -O http://www.unicode.org/Public/UNIDATA/%s" % f) if not os.path.exists(f): sys.stderr.write("cannot load %s" % f) exit(1) def is_surrogate(n): return 0xD800 <= n <= 0xDFFF def load_unicode_data(f): fetch(f) gencats = {} udict = {}; range_start = -1; for line in fileinput.input(f): data = line.split(';'); if len(data) != 15: continue cp = int(data[0], 16); if is_surrogate(cp): continue if range_start >= 0: for i in xrange(range_start, cp): udict[i] = data; range_start = -1; if data[1].endswith(", First>"): range_start = cp; continue; udict[cp] = data; for code in udict: [code_org, name, gencat, combine, bidi, decomp, deci, digit, num, mirror, old, iso, upcase, lowcase, titlecase ] = udict[code]; # place letter in categories as appropriate for cat in [gencat, "Assigned"] + expanded_categories.get(gencat, []): if cat not in gencats: gencats[cat] = [] gencats[cat].append(code) # generate Not_Assigned from Assigned gencats["Cn"] = gen_unassigned(gencats["Assigned"]) # Assigned is not a real category del(gencats["Assigned"]) # Other contains Not_Assigned gencats["C"].extend(gencats["Cn"]) gencats = group_cats(gencats) return gencats def group_cats(cats): cats_out = {} for cat in cats: cats_out[cat] = group_cat(cats[cat]) return cats_out def group_cat(cat): cat_out = [] letters = sorted(set(cat)) cur_start = letters.pop(0) cur_end = cur_start for letter in letters: assert letter > cur_end, \ "cur_end: %s, letter: %s" % (hex(cur_end), hex(letter)) if letter == cur_end + 1: cur_end = letter else: cat_out.append((cur_start, cur_end)) cur_start = cur_end = letter cat_out.append((cur_start, cur_end)) return cat_out def ungroup_cat(cat): cat_out = [] for (lo, hi) in cat: while lo <= hi: cat_out.append(lo) lo += 1 return cat_out def gen_unassigned(assigned): assigned = set(assigned) return ([i for i in range(0, 0xd800) if i not in assigned] + [i for i in range(0xe000, 0x110000) if i not in assigned]) def format_table_content(f, content, indent): line = " "*indent first = True for chunk in content.split(","): if len(line) + len(chunk) < 78: if first: line += chunk else: line += ", " + chunk first = False else: f.write(line + ",\n") line = " "*indent + chunk f.write(line) def load_properties(f, interestingprops): fetch(f) props = {} re1 = re.compile("^ *([0-9A-F]+) *; *(\w+)") re2 = re.compile("^ *([0-9A-F]+)\.\.([0-9A-F]+) *; *(\w+)") for line in fileinput.input(f): prop = None d_lo = 0 d_hi = 0 m = re1.match(line) if m: d_lo = m.group(1) d_hi = m.group(1) prop = m.group(2) else: m = re2.match(line) if m: d_lo = m.group(1) d_hi = m.group(2) prop = m.group(3) else: continue if interestingprops and prop not in interestingprops: continue d_lo = int(d_lo, 16) d_hi = int(d_hi, 16) if prop not in props: props[prop] = [] props[prop].append((d_lo, d_hi)) # optimize props if possible for prop in props: props[prop] = group_cat(ungroup_cat(props[prop])) return props def load_case_folding(f): fetch(f) re1 = re.compile("^ *([0-9A-F]+) *; *[CS] *; *([0-9A-F]+) *;") all_pairs = defaultdict(list) for line in fileinput.input(f): m = re1.match(line) if m: a = int(m.group(1), 16) b = int(m.group(2), 16) all_pairs[a].append(b) all_pairs[b].append(a) both = set() for k, vs in all_pairs.iteritems(): for v in vs: both.add((k, v)) for v2 in all_pairs[v]: both.add((k, v2)) c_plus_s_both = sorted((k1, k2) for k1, k2 in both if k1 != k2) return {"C_plus_S_both": c_plus_s_both} def escape_char(c): return "'\\u{%x}'" % c def emit_table(f, name, t_data, t_type = "&'static [(char, char)]", is_pub=True, pfun=lambda x: "(%s,%s)" % (escape_char(x[0]), escape_char(x[1]))): pub_string = "" if is_pub: pub_string = "pub " f.write(" %sconst %s: %s = &[\n" % (pub_string, name, t_type)) data = "" first = True for dat in t_data: if not first: data += "," first = False data += pfun(dat) format_table_content(f, data, 8) f.write("\n ];\n\n") def emit_property_module(f, mod, tbl): f.write("pub mod %s {\n" % mod) keys = tbl.keys() keys.sort() for cat in keys: emit_table(f, "%s_table" % cat, tbl[cat]) f.write("}\n\n") def emit_regex_module(f, cats, w_data): f.write("pub mod regex {\n") regex_class = "&'static [(char, char)]" class_table = "&'static [(&'static str, %s)]" % regex_class emit_table(f, "UNICODE_CLASSES", cats, class_table, pfun=lambda x: "(\"%s\",super::%s::%s_table)" % (x[0], x[1], x[0])) f.write(" pub const PERLD: %s = super::general_category::Nd_table;\n\n" % regex_class) f.write(" pub const PERLS: %s = super::property::White_Space_table;\n\n" % regex_class) emit_table(f, "PERLW", w_data, regex_class) f.write("}\n\n") if __name__ == "__main__": r = "unicode.rs" if os.path.exists(r): os.remove(r) with open(r, "w") as rf: # write the file's preamble rf.write(preamble) # download and parse all the data fetch("ReadMe.txt") with open("ReadMe.txt") as readme: pattern = "for Version (\d+)\.(\d+)\.(\d+) of the Unicode" unicode_version = re.search(pattern, readme.read()).groups() gencats = load_unicode_data("UnicodeData.txt") want_derived = ["XID_Start", "XID_Continue", "Alphabetic", "Lowercase", "Uppercase"] other_derived = ["Default_Ignorable_Code_Point", "Grapheme_Extend"] derived = load_properties("DerivedCoreProperties.txt", want_derived + other_derived) scripts = load_properties("Scripts.txt", []) props = load_properties("PropList.txt", ["White_Space", "Join_Control", "Noncharacter_Code_Point"]) case_folding = load_case_folding("CaseFolding.txt") # all of these categories will also be available as \p{} in libregex allcats = [] for (name, cat) in ("general_category", gencats), \ ("derived_property", derived), \ ("script", scripts), \ ("property", props): emit_property_module(rf, name, cat) allcats.extend(map(lambda x: (x, name), cat)) allcats.sort(key=lambda c: c[0]) # the \w regex corresponds to Alphabetic + Mark + Decimal_Number + # Connector_Punctuation + Join-Control according to UTS#18 # http://www.unicode.org/reports/tr18/#Compatibility_Properties perl_words = [] for cat in derived["Alphabetic"], gencats["M"], gencats["Nd"], \ gencats["Pc"], props["Join_Control"]: perl_words.extend(ungroup_cat(cat)) perl_words = group_cat(perl_words) # emit lookup tables for \p{}, along with \d, \w, and \s for libregex emit_regex_module(rf, allcats, perl_words) emit_property_module(rf, "case_folding", case_folding) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/regex-0.1.44/scripts/regex-match-tests.py������������������������������������������������������0000755�0001750�0000144�00000006713�12504652243�017265� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python2 # Copyright 2014 The Rust Project Developers. See the COPYRIGHT # file at the top-level directory of this distribution and at # http://rust-lang.org/COPYRIGHT. # # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your # option. This file may not be copied, modified, or distributed # except according to those terms. from __future__ import absolute_import, division, print_function import argparse import datetime import os.path as path def print_tests(tests): print('\n'.join([test_tostr(t) for t in tests])) def read_tests(f): basename, _ = path.splitext(path.basename(f)) tests = [] for lineno, line in enumerate(open(f), 1): fields = filter(None, map(str.strip, line.split('\t'))) if not (4 <= len(fields) <= 5) \ or 'E' not in fields[0] or fields[0][0] == '#': continue opts, pat, text, sgroups = fields[0:4] groups = [] # groups as integer ranges if sgroups == 'NOMATCH': groups = [None] elif ',' in sgroups: noparen = map(lambda s: s.strip('()'), sgroups.split(')(')) for g in noparen: s, e = map(str.strip, g.split(',')) if s == '?' and e == '?': groups.append(None) else: groups.append((int(s), int(e))) else: # This skips tests that should result in an error. # There aren't many, so I think we can just capture those # manually. Possibly fix this in future. continue if pat == 'SAME': pat = tests[-1][1] if '$' in opts: pat = pat.decode('string_escape') text = text.decode('string_escape') if 'i' in opts: pat = '(?i)%s' % pat name = '%s_%d' % (basename, lineno) tests.append((name, pat, text, groups)) return tests def test_tostr(t): lineno, pat, text, groups = t options = map(group_tostr, groups) return 'mat!(match_%s, r"%s", r"%s", %s);' \ % (lineno, pat, '' if text == "NULL" else text, ', '.join(options)) def group_tostr(g): if g is None: return 'None' else: return 'Some((%d, %d))' % (g[0], g[1]) if __name__ == '__main__': parser = argparse.ArgumentParser( description='Generate match tests from an AT&T POSIX test file.') aa = parser.add_argument aa('files', nargs='+', help='A list of dat AT&T POSIX test files. See src/testdata') args = parser.parse_args() tests = [] for f in args.files: tests += read_tests(f) tpl = '''// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // DO NOT EDIT. Automatically generated by 'scripts/regex-match-tests.py' // on {date}. ''' print(tpl.format(date=str(datetime.datetime.now()))) for f in args.files: print('// Tests from %s' % path.basename(f)) print_tests(read_tests(f)) print('') �����������������������������������������������������deps/regex-0.1.44/appveyor.yml����������������������������������������������������������������������0000644�0001750�0000144�00000000736�12610502672�014242� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������environment: matrix: - TARGET: x86_64-pc-windows-msvc - TARGET: i686-pc-windows-msvc - TARGET: i686-pc-windows-gnu install: - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin - SET PATH=%PATH%;C:\MinGW\bin - rustc -V - cargo -V build: false test_script: - cargo test --verbose ����������������������������������deps/regex-0.1.44/Cargo.toml������������������������������������������������������������������������0000644�0001750�0000144�00000001646�12635541031�013602� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������[package] name = "regex" version = "0.1.44" authors = ["The Rust Project Developers"] license = "MIT/Apache-2.0" readme = "README.md" repository = "https://github.com/rust-lang/regex" documentation = "https://doc.rust-lang.org/regex" homepage = "https://github.com/rust-lang/regex" description = """ An implementation of regular expressions for Rust. """ [[test]] path = "src/lib.rs" name = "regex" [[test]] path = "regex_macros/tests/test_dynamic.rs" name = "dynamic" [[test]] path = "regex_macros/tests/test_dynamic_nfa.rs" name = "dynamic_nfa" [[test]] path = "regex_macros/tests/test_dynamic_backtrack.rs" name = "dynamic_backtrack" [[bench]] name = "all" path = "regex_macros/benches/bench_dynamic.rs" test = false bench = true [dependencies] aho-corasick = "0.4" memchr = "0.1" regex-syntax = { path = "regex-syntax", version = "0.2" } [dev-dependencies] rand = "0.3" [features] pattern = [] [profile.bench] lto = true ������������������������������������������������������������������������������������������deps/winapi-build-0.1.1/����������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635520�013541� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/winapi-build-0.1.1/src/������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635520�014330� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/winapi-build-0.1.1/src/lib.rs������������������������������������������������������������������0000644�0000000�0000000�00000001047�12556746233�015450� 0����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������// Copyright © 2015, Peter Atashian // Licensed under the MIT License <LICENSE.md> pub fn link(name: &str, bundled: bool) { use std::env::var; let target = var("TARGET").unwrap(); let target: Vec<_> = target.split('-').collect(); if target.get(2) == Some(&"windows") { println!("cargo:rustc-link-lib=dylib={}", name); if bundled && target.get(3) == Some(&"gnu") { let dir = var("CARGO_MANIFEST_DIR").unwrap(); println!("cargo:rustc-link-search=native={}/{}", dir, target[0]); } } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/winapi-build-0.1.1/Cargo.toml������������������������������������������������������������������0000644�0000000�0000000�00000000447�12556746361�015502� 0����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������[package] name = "winapi-build" version = "0.1.1" authors = ["Peter Atashian <retep998@gmail.com>"] description = "Common code for build.rs in WinAPI -sys crates." repository = "https://github.com/retep998/winapi-rs" keywords = ["Windows", "FFI", "WinSDK"] license = "MIT" [lib] name = "build" �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/memchr-0.1.7/����������������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635520�012436� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/memchr-0.1.7/UNLICENSE�������������������������������������������������������������������������0000644�0001750�0000144�00000002273�12313146471�013201� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to <http://unlicense.org/> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/memchr-0.1.7/LICENSE-MIT�����������������������������������������������������������������������0000644�0001750�0000144�00000002071�12513562722�013364� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������The MIT License (MIT) Copyright (c) 2015 Andrew Gallant Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/memchr-0.1.7/ctags.rust������������������������������������������������������������������������0000644�0001750�0000144�00000001606�12401211127�013735� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������--langdef=Rust --langmap=Rust:.rs --regex-Rust=/^[ \t]*(#\[[^\]]\][ \t]*)*(pub[ \t]+)?(extern[ \t]+)?("[^"]+"[ \t]+)?(unsafe[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\6/f,functions,function definitions/ --regex-Rust=/^[ \t]*(pub[ \t]+)?type[ \t]+([a-zA-Z0-9_]+)/\2/T,types,type definitions/ --regex-Rust=/^[ \t]*(pub[ \t]+)?enum[ \t]+([a-zA-Z0-9_]+)/\2/g,enum,enumeration names/ --regex-Rust=/^[ \t]*(pub[ \t]+)?struct[ \t]+([a-zA-Z0-9_]+)/\2/s,structure names/ --regex-Rust=/^[ \t]*(pub[ \t]+)?mod[ \t]+([a-zA-Z0-9_]+)/\2/m,modules,module names/ --regex-Rust=/^[ \t]*(pub[ \t]+)?static[ \t]+([a-zA-Z0-9_]+)/\2/c,consts,static constants/ --regex-Rust=/^[ \t]*(pub[ \t]+)?trait[ \t]+([a-zA-Z0-9_]+)/\2/t,traits,traits/ --regex-Rust=/^[ \t]*(pub[ \t]+)?impl([ \t\n]+<.*>)?[ \t]+([a-zA-Z0-9_]+)/\3/i,impls,trait implementations/ --regex-Rust=/^[ \t]*macro_rules![ \t]+([a-zA-Z0-9_]+)/\1/d,macros,macro definitions/ ��������������������������������������������������������������������������������������������������������������������������deps/memchr-0.1.7/.travis.yml�����������������������������������������������������������������������0000644�0001750�0000144�00000000325�12536413700�014035� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������language: rust rust: - 1.0.0 - beta - nightly script: - cargo build --verbose - cargo test --verbose - cargo doc - if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then cargo bench --verbose; fi �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/memchr-0.1.7/README.md�������������������������������������������������������������������������0000644�0001750�0000144�00000002316�12574167334�013220� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������This crate provides two functions, `memchr` and `memrchr`, which exposes a safe interface to the corresponding functions in `libc`. This crate also provides fallback implementations when either function is unavailable. [![Build status](https://api.travis-ci.org/BurntSushi/rust-memchr.png)](https://travis-ci.org/BurntSushi/rust-memchr) [![Build status](https://ci.appveyor.com/api/projects/status/8i9484t8l4w7uql0/branch/master?svg=true)](https://ci.appveyor.com/project/BurntSushi/rust-memchr/branch/master) [![](http://meritbadge.herokuapp.com/memchr)](https://crates.io/crates/memchr) Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). ### Documentation [http://burntsushi.net/rustdoc/memchr/](http://burntsushi.net/rustdoc/memchr/). ### Performance On my system (Linux/amd64), `memchr` is about an order of magnitude faster than the more idiomatic `haystack.iter().position(|&b| b == needle)`: ``` test iterator ... bench: 5,280 ns/iter (+/- 13) = 1893 MB/s test iterator_reversed ... bench: 5,271 ns/iter (+/- 7) = 1897 MB/s test libc_memchr ... bench: 202 ns/iter (+/- 0) = 49504 MB/s test libc_memrchr ... bench: 197 ns/iter (+/- 1) = 50761 MB/s ``` ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/memchr-0.1.7/.gitignore������������������������������������������������������������������������0000644�0001750�0000144�00000000130�12510106554�013704� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������.*.swp doc tags examples/ss10pusa.csv build target Cargo.lock scratch* bench_large/huge ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/memchr-0.1.7/src/������������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635520�013225� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/memchr-0.1.7/src/lib.rs������������������������������������������������������������������������0000644�0001750�0000144�00000026650�12616760437�013653� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*! This crate defines two functions, `memchr` and `memrchr`, which expose a safe interface to the corresponding functions in `libc`. */ #![deny(missing_docs)] #![allow(unused_imports)] extern crate libc; use libc::c_void; use libc::{c_int, size_t}; /// A safe interface to `memchr`. /// /// Returns the index corresponding to the first occurrence of `needle` in /// `haystack`, or `None` if one is not found. /// /// memchr reduces to super-optimized machine code at around an order of /// magnitude faster than `haystack.iter().position(|&b| b == needle)`. /// (See benchmarks.) /// /// # Example /// /// This shows how to find the first position of a byte in a byte string. /// /// ```rust /// use memchr::memchr; /// /// let haystack = b"the quick brown fox"; /// assert_eq!(memchr(b'k', haystack), Some(8)); /// ``` pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> { // libc memchr #[cfg(any(not(target_os = "windows"), not(any(target_pointer_width = "32", target_pointer_width = "64"))))] fn memchr_specific(needle: u8, haystack: &[u8]) -> Option<usize> { use libc::memchr as libc_memchr; let p = unsafe { libc_memchr( haystack.as_ptr() as *const c_void, needle as c_int, haystack.len() as size_t) }; if p.is_null() { None } else { Some(p as usize - (haystack.as_ptr() as usize)) } } // use fallback on windows, since it's faster #[cfg(all(target_os = "windows", any(target_pointer_width = "32", target_pointer_width = "64")))] fn memchr_specific(needle: u8, haystack: &[u8]) -> Option<usize> { fallback::memchr(needle, haystack) } memchr_specific(needle, haystack) } /// A safe interface to `memrchr`. /// /// Returns the index corresponding to the last occurrence of `needle` in /// `haystack`, or `None` if one is not found. /// /// # Example /// /// This shows how to find the last position of a byte in a byte string. /// /// ```rust /// use memchr::memrchr; /// /// let haystack = b"the quick brown fox"; /// assert_eq!(memrchr(b'o', haystack), Some(17)); /// ``` pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize> { #[cfg(target_os = "linux")] fn memrchr_specific(needle: u8, haystack: &[u8]) -> Option<usize> { // GNU's memrchr() will - unlike memchr() - error if haystack is empty. if haystack.is_empty() {return None} let p = unsafe { ffi::memrchr( haystack.as_ptr() as *const c_void, needle as c_int, haystack.len() as size_t) }; if p.is_null() { None } else { Some(p as usize - (haystack.as_ptr() as usize)) } } #[cfg(all(not(target_os = "linux"), any(target_pointer_width = "32", target_pointer_width = "64")))] fn memrchr_specific(needle: u8, haystack: &[u8]) -> Option<usize> { fallback::memrchr(needle, haystack) } // For the rare case of neither 32 bit nor 64-bit platform. #[cfg(all(not(target_os = "linux"), not(target_pointer_width = "32"), not(target_pointer_width = "64")))] fn memrchr_specific(needle: u8, haystack: &[u8]) -> Option<usize> { haystack.iter().rposition(|&b| b == needle) } memrchr_specific(needle, haystack) } #[allow(dead_code)] #[cfg(all(not(target_os = "linux"), any(target_pointer_width = "32", target_pointer_width = "64")))] mod fallback { use std::cmp; const LO_U64: u64 = 0x0101010101010101; const HI_U64: u64 = 0x8080808080808080; // use truncation const LO_USIZE: usize = LO_U64 as usize; const HI_USIZE: usize = HI_U64 as usize; #[cfg(target_pointer_width = "32")] const USIZE_BYTES: usize = 4; #[cfg(target_pointer_width = "64")] const USIZE_BYTES: usize = 8; /// Return `true` if `x` contains any zero byte. /// /// From *Matters Computational*, J. Arndt /// /// "The idea is to subtract one from each of the bytes and then look for /// bytes where the borrow propagated all the way to the most significant /// bit." #[inline] fn contains_zero_byte(x: usize) -> bool { x.wrapping_sub(LO_USIZE) & !x & HI_USIZE != 0 } #[cfg(target_pointer_width = "32")] #[inline] fn repeat_byte(b: u8) -> usize { let mut rep = (b as usize) << 8 | b as usize; rep = rep << 16 | rep; rep } #[cfg(target_pointer_width = "64")] #[inline] fn repeat_byte(b: u8) -> usize { let mut rep = (b as usize) << 8 | b as usize; rep = rep << 16 | rep; rep = rep << 32 | rep; rep } /// Return the first index matching the byte `a` in `text`. pub fn memchr(x: u8, text: &[u8]) -> Option<usize> { // Scan for a single byte value by reading two `usize` words at a time. // // Split `text` in three parts // - unaligned inital part, before the first word aligned address in text // - body, scan by 2 words at a time // - the last remaining part, < 2 word size let len = text.len(); let ptr = text.as_ptr(); // search up to an aligned boundary let align = (ptr as usize) & (USIZE_BYTES - 1); let mut offset; if align > 0 { offset = cmp::min(USIZE_BYTES - align, len); if let Some(index) = text[..offset].iter().position(|elt| *elt == x) { return Some(index); } } else { offset = 0; } // search the body of the text let repeated_x = repeat_byte(x); if len >= 2 * USIZE_BYTES { while offset <= len - 2 * USIZE_BYTES { unsafe { let u = *(ptr.offset(offset as isize) as *const usize); let v = *(ptr.offset((offset + USIZE_BYTES) as isize) as *const usize); // break if there is a matching byte let zu = contains_zero_byte(u ^ repeated_x); let zv = contains_zero_byte(v ^ repeated_x); if zu || zv { break; } } offset += USIZE_BYTES * 2; } } // find the byte after the point the body loop stopped text[offset..].iter().position(|elt| *elt == x).map(|i| offset + i) } /// Return the last index matching the byte `a` in `text`. pub fn memrchr(x: u8, text: &[u8]) -> Option<usize> { // Scan for a single byte value by reading two `usize` words at a time. // // Split `text` in three parts // - unaligned tail, after the last word aligned address in text // - body, scan by 2 words at a time // - the first remaining bytes, < 2 word size let len = text.len(); let ptr = text.as_ptr(); // search to an aligned boundary let end_align = (ptr as usize + len) & (USIZE_BYTES - 1); let mut offset; if end_align > 0 { offset = len - cmp::min(USIZE_BYTES - end_align, len); if let Some(index) = text[offset..].iter().rposition(|elt| *elt == x) { return Some(offset + index); } } else { offset = len; } // search the body of the text let repeated_x = repeat_byte(x); while offset >= 2 * USIZE_BYTES { unsafe { let u = *(ptr.offset(offset as isize - 2 * USIZE_BYTES as isize) as *const usize); let v = *(ptr.offset(offset as isize - USIZE_BYTES as isize) as *const usize); // break if there is a matching byte let zu = contains_zero_byte(u ^ repeated_x); let zv = contains_zero_byte(v ^ repeated_x); if zu || zv { break; } } offset -= 2 * USIZE_BYTES; } // find the byte before the point the body loop stopped text[..offset].iter().rposition(|elt| *elt == x) } } #[cfg(target_os = "linux")] mod ffi { use libc::c_void; use libc::{c_int, size_t}; extern { pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; } } #[cfg(test)] mod tests { extern crate quickcheck; use super::{memchr, memrchr}; #[test] fn matches_one() { assert_eq!(Some(0), memchr(b'a', b"a")); } #[test] fn matches_begin() { assert_eq!(Some(0), memchr(b'a', b"aaaa")); } #[test] fn matches_end() { assert_eq!(Some(4), memchr(b'z', b"aaaaz")); } #[test] fn matches_nul() { assert_eq!(Some(4), memchr(b'\x00', b"aaaa\x00")); } #[test] fn matches_past_nul() { assert_eq!(Some(5), memchr(b'z', b"aaaa\x00z")); } #[test] fn no_match_empty() { assert_eq!(None, memchr(b'a', b"")); } #[test] fn no_match() { assert_eq!(None, memchr(b'a', b"xyz")); } #[test] fn qc_never_fail() { fn prop(needle: u8, haystack: Vec<u8>) -> bool { memchr(needle, &haystack); true } quickcheck::quickcheck(prop as fn(u8, Vec<u8>) -> bool); } #[test] fn matches_one_reversed() { assert_eq!(Some(0), memrchr(b'a', b"a")); } #[test] fn matches_begin_reversed() { assert_eq!(Some(3), memrchr(b'a', b"aaaa")); } #[test] fn matches_end_reversed() { assert_eq!(Some(0), memrchr(b'z', b"zaaaa")); } #[test] fn matches_nul_reversed() { assert_eq!(Some(4), memrchr(b'\x00', b"aaaa\x00")); } #[test] fn matches_past_nul_reversed() { assert_eq!(Some(0), memrchr(b'z', b"z\x00aaaa")); } #[test] fn no_match_empty_reversed() { assert_eq!(None, memrchr(b'a', b"")); } #[test] fn no_match_reversed() { assert_eq!(None, memrchr(b'a', b"xyz")); } #[test] fn qc_never_fail_reversed() { fn prop(needle: u8, haystack: Vec<u8>) -> bool { memrchr(needle, &haystack); true } quickcheck::quickcheck(prop as fn(u8, Vec<u8>) -> bool); } #[test] fn qc_correct_memchr() { fn prop(v: Vec<u8>, offset: u8) -> bool { // test all pointer alignments let uoffset = (offset & 0xF) as usize; let data = if uoffset <= v.len() { &v[uoffset..] } else { &v[..] }; for byte in 0..256u32 { let byte = byte as u8; if memchr(byte, &data) != data.iter().position(|elt| *elt == byte) { return false; } } true } quickcheck::quickcheck(prop as fn(Vec<u8>, u8) -> bool); } #[test] fn qc_correct_memrchr() { fn prop(v: Vec<u8>, offset: u8) -> bool { // test all pointer alignments let uoffset = (offset & 0xF) as usize; let data = if uoffset <= v.len() { &v[uoffset..] } else { &v[..] }; for byte in 0..256u32 { let byte = byte as u8; if memrchr(byte, &data) != data.iter().rposition(|elt| *elt == byte) { return false; } } true } quickcheck::quickcheck(prop as fn(Vec<u8>, u8) -> bool); } } ����������������������������������������������������������������������������������������deps/memchr-0.1.7/session.vim�����������������������������������������������������������������������0000644�0001750�0000144�00000000070�12313622751�014122� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������au BufWritePost *.rs silent!make ctags > /dev/null 2>&1 ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/memchr-0.1.7/appveyor.yml����������������������������������������������������������������������0000644�0001750�0000144�00000001022�12563661267�014324� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������environment: matrix: - TARGET: x86_64-pc-windows-msvc - TARGET: i686-pc-windows-msvc - TARGET: i686-pc-windows-gnu install: - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin - SET PATH=%PATH%;C:\MinGW\bin - rustc -V - cargo -V build: false test_script: - cargo build --verbose - cargo test --verbose - cargo bench --verbose ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/memchr-0.1.7/Cargo.toml������������������������������������������������������������������������0000644�0001750�0000144�00000001007�12616760524�013662� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������[package] name = "memchr" version = "0.1.7" #:version authors = ["Andrew Gallant <jamslam@gmail.com>", "bluss"] description = "Safe interface to memchr." documentation = "http://burntsushi.net/rustdoc/memchr/" homepage = "https://github.com/BurntSushi/rust-memchr" repository = "https://github.com/BurntSushi/rust-memchr" readme = "README.md" keywords = ["memchr", "char", "scan", "strchr", "string"] license = "Unlicense/MIT" [lib] name = "memchr" [dependencies] libc = "0.2" [dev-dependencies] quickcheck = "0.2" �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/memchr-0.1.7/Makefile��������������������������������������������������������������������������0000644�0001750�0000144�00000000375�12536407543�013401� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������all: echo Nothing to do... ctags: ctags --recurse --options=ctags.rust --languages=Rust docs: cargo doc in-dir ./target/doc fix-perms rscp ./target/doc/* gopher:~/www/burntsushi.net/rustdoc/ push: git push origin master git push github master �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/memchr-0.1.7/COPYING���������������������������������������������������������������������������0000644�0001750�0000144�00000000176�12513562722�012767� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������This project is dual-licensed under the Unlicense and MIT licenses. You may use this code under the terms of either license. ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/memchr-0.1.7/benches/��������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635520�014045� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/memchr-0.1.7/benches/bench.rs������������������������������������������������������������������0000644�0001750�0000144�00000002110�12570620524�014754� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#![feature(test)] extern crate memchr; extern crate test; use std::iter; fn bench_data() -> Vec<u8> { iter::repeat(b'z').take(10000).collect() } #[bench] fn iterator(b: &mut test::Bencher) { let haystack = bench_data(); let needle = b'a'; b.iter(|| { assert!(haystack.iter().position(|&b| b == needle).is_none()); }); b.bytes = haystack.len() as u64; } #[bench] fn libc_memchr(b: &mut test::Bencher) { let haystack = bench_data(); let needle = b'a'; b.iter(|| { assert!(memchr::memchr(needle, &haystack).is_none()); }); b.bytes = haystack.len() as u64; } #[bench] fn iterator_reversed(b: &mut test::Bencher) { let haystack = bench_data(); let needle = b'a'; b.iter(|| { assert!(haystack.iter().rposition(|&b| b == needle).is_none()); }); b.bytes = haystack.len() as u64; } #[bench] fn libc_memrchr(b: &mut test::Bencher) { let haystack = bench_data(); let needle = b'a'; b.iter(|| { assert!(memchr::memrchr(needle, &haystack).is_none()); }); b.bytes = haystack.len() as u64; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/tar-0.3.2/�������������������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635521�011747� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/tar-0.3.2/LICENSE-APACHE�����������������������������������������������������������������������0000664�0001750�0001750�00000025137�12401655412�012113� 0����������������������������������������������������������������������������������������������������ustar �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/tar-0.3.2/LICENSE-MIT��������������������������������������������������������������������������0000664�0001750�0001750�00000002041�12401656024�011610� 0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Copyright (c) 2014 Alex Crichton Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/tar-0.3.2/.travis.yml��������������������������������������������������������������������������0000664�0001750�0001750�00000001350�12564265036�012300� 0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������language: rust rust: - 1.1.0 - beta - nightly sudo: false before_script: - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH script: - cargo build --verbose - cargo test --verbose - rustdoc --test README.md -L target/debug -L target/debug/deps - cargo doc --no-deps after_success: - travis-cargo --only nightly doc-upload - travis-cargo coveralls --no-sudo notifications: email: on_success: never addons: apt: packages: - libcurl4-openssl-dev - libelf-dev - libdw-dev env: global: secure: UheHECBlvtxfXyN6Me+v1UIjvAwV+VXXSpvVe4X34Yj4mlO4OgnB9XrakGcnO3mZnzphXxjpQ7qPgTVXkKLphzAhCOBXzh7rohSqgBcAh+nBbaXDvGf3gVFYff7lve4dO/82wCaR8a9w5Qgcc0/6DmsUeQHyj13YM3mm6P1lesE= ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/tar-0.3.2/README.md����������������������������������������������������������������������������0000664�0001750�0001750�00000003710�12604536164�011446� 0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# tar-rs [![Build Status](https://travis-ci.org/alexcrichton/tar-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/tar-rs) [![Build status](https://ci.appveyor.com/api/projects/status/0udgokm2fc6ljorj?svg=true)](https://ci.appveyor.com/project/alexcrichton/tar-rs) [![Coverage Status](https://coveralls.io/repos/alexcrichton/tar-rs/badge.svg?branch=master&service=github)](https://coveralls.io/github/alexcrichton/tar-rs?branch=master) [Documentation](http://alexcrichton.com/tar-rs/tar/index.html) A tar archive reading/writing library for Rust. ```toml # Cargo.toml [dependencies] tar = "0.3" ``` ## Reading an archive ```rust,no_run extern crate tar; use std::io::prelude::*; use std::io::SeekFrom; use std::fs::File; use tar::Archive; fn main() { let file = File::open("foo.tar").unwrap(); let a = Archive::new(file); for file in a.files().unwrap() { // Make sure there wasn't an I/O error let mut file = file.unwrap(); // Inspect metadata about the file println!("{:?}", file.header().path().unwrap()); println!("{}", file.header().size().unwrap()); // files implement the Read trait let mut s = String::new(); file.read_to_string(&mut s).unwrap(); println!("{}", s); // files also implement the Seek trait file.seek(SeekFrom::Current(0)).unwrap(); } } ``` ## Writing an archive ```rust,no_run # #![allow(unused_must_use, unstable)] extern crate tar; use std::io::prelude::*; use std::fs::File; use tar::Archive; fn main() { let file = File::create("foo.tar").unwrap(); let a = Archive::new(file); a.append_path("file1.txt"); a.append_file("file2.txt", &mut File::open("file3.txt").unwrap()); a.finish(); } ``` # License `tar-rs` is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses. See LICENSE-APACHE, and LICENSE-MIT for details. ��������������������������������������������������������deps/tar-0.3.2/.gitignore���������������������������������������������������������������������������0000664�0001750�0001750�00000000024�12367606013�012147� 0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/target /Cargo.lock ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/tar-0.3.2/src/���������������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635521�012536� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/tar-0.3.2/src/lib.rs���������������������������������������������������������������������������0000664�0001750�0001750�00000152663�12616471366�012113� 0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������//! A library for reading and writing TAR archives //! //! This library provides utilities necessary to manage TAR archives [1] //! abstracted over a reader or writer. Great strides are taken to ensure that //! an archive is never required to be fully resident in memory, all objects //! provide largely a streaming interface to read bytes from. //! //! [1]: http://en.wikipedia.org/wiki/Tar_%28computing%29 #![doc(html_root_url = "http://alexcrichton.com/tar-rs")] #![deny(missing_docs)] #![cfg_attr(test, deny(warnings))] extern crate libc; extern crate winapi; extern crate filetime; use std::borrow::Cow; use std::cell::{RefCell, Cell}; use std::cmp; use std::error; use std::fmt; use std::fs; use std::io::prelude::*; use std::io::{self, Error, ErrorKind, SeekFrom}; use std::iter::repeat; use std::mem; use std::path::{Path, PathBuf, Component}; use std::str; use filetime::FileTime; #[cfg(unix)] use std::os::unix::prelude::*; #[cfg(unix)] use std::ffi::{OsStr, OsString}; #[cfg(windows)] use std::os::windows::prelude::*; macro_rules! try_iter{ ($me:expr, $e:expr) => ( match $e { Ok(e) => e, Err(e) => { $me.done = true; return Some(Err(e)) } } ) } /// A top-level representation of an archive file. /// /// This archive can have a file added to it and it can be iterated over. pub struct Archive<R> { obj: RefCell<R>, pos: Cell<u64>, } /// An iterator over the files of an archive. /// /// Requires that `R` implement `Seek`. pub struct Files<'a, R:'a> { archive: &'a Archive<R>, done: bool, offset: u64, } /// An iterator over the files of an archive. /// /// Does not require that `R` implements `Seek`, but each file must be processed /// before the next. pub struct FilesMut<'a, R:'a> { archive: &'a Archive<R>, next: u64, done: bool, } /// A read-only view into a file of an archive. /// /// This structure is a window into a portion of a borrowed archive which can /// be inspected. It acts as a file handle by implementing the Reader and Seek /// traits. A file cannot be rewritten once inserted into an archive. pub struct File<'a, R: 'a> { header: Header, archive: &'a Archive<R>, pos: u64, size: u64, // Used in read() to make sure we're positioned at the next byte. For a // `Files` iterator these are meaningful while for a `FilesMut` iterator // these are both unused/noops. seek: fn(&File<R>) -> io::Result<()>, tar_offset: u64, } /// Representation of the header of a file in an archive #[repr(C)] #[allow(missing_docs)] pub struct Header { pub name: [u8; 100], pub mode: [u8; 8], pub owner_id: [u8; 8], pub group_id: [u8; 8], pub size: [u8; 12], pub mtime: [u8; 12], pub cksum: [u8; 8], pub link: [u8; 1], pub linkname: [u8; 100], // UStar format pub ustar: [u8; 6], pub ustar_version: [u8; 2], pub owner_name: [u8; 32], pub group_name: [u8; 32], pub dev_major: [u8; 8], pub dev_minor: [u8; 8], pub prefix: [u8; 155], _rest: [u8; 12], } #[doc(hidden)] #[derive(Debug)] pub struct TarError { desc: String, io: io::Error, } impl<O> Archive<O> { /// Create a new archive with the underlying object as the reader/writer. /// /// Different methods are available on an archive depending on the traits /// that the underlying object implements. pub fn new(obj: O) -> Archive<O> { Archive { obj: RefCell::new(obj), pos: Cell::new(0) } } /// Unwrap this archive, returning the underlying object. pub fn into_inner(self) -> O { self.obj.into_inner() } } impl<R: Seek + Read> Archive<R> { /// Construct an iterator over the files of this archive. /// /// This function can return an error if any underlying I/O operation fails /// while attempting to construct the iterator. /// /// Additionally, the iterator yields `io::Result<File>` instead of `File` to /// handle invalid tar archives as well as any intermittent I/O error that /// occurs. pub fn files(&self) -> io::Result<Files<R>> { try!(self.seek(0)); Ok(Files { archive: self, done: false, offset: 0 }) } fn seek(&self, pos: u64) -> io::Result<()> { if self.pos.get() == pos { return Ok(()) } try!(self.obj.borrow_mut().seek(SeekFrom::Start(pos))); self.pos.set(pos); Ok(()) } } impl<R: Read> Archive<R> { /// Construct an iterator over the files in this archive. /// /// While similar to the `files` iterator, this iterator does not require /// that `R` implement `Seek` and restricts the iterator to processing only /// one file at a time in a streaming fashion. /// /// Note that care must be taken to consider each file within an archive in /// sequence. If files are processed out of sequence (from what the iterator /// returns), then the contents read for each file may be corrupted. pub fn files_mut(&mut self) -> io::Result<FilesMut<R>> { if self.pos.get() != 0 { return Err(Error::new(ErrorKind::Other, "cannot call files_mut \ unless archive is at \ position 0")) } Ok(FilesMut { archive: self, done: false, next: 0 }) } /// Unpacks the contents tarball into the specified `dst`. /// /// This function will iterate over the entire contents of this tarball, /// extracting each file in turn to the location specified by the entry's /// path name. /// /// This operation is relatively sensitive in that it will not write files /// outside of the path specified by `into`. Files in the archive which have /// a '..' in their path are skipped during the unpacking process. /// /// # Examples /// /// ```no_run /// use std::fs::File; /// use tar::Archive; /// /// let mut ar = Archive::new(File::open("foo.tar").unwrap()); /// ar.unpack("foo").unwrap(); /// ``` pub fn unpack<P: AsRef<Path>>(&mut self, dst: P) -> io::Result<()> { self.unpack2(dst.as_ref()) } fn unpack2(&mut self, dst: &Path) -> io::Result<()> { 'outer: for file in try!(self.files_mut()) { let mut file = try!(file.map_err(|e| { TarError::new("failed to iterate over archive", e) })); // Notes regarding bsdtar 2.8.3 / libarchive 2.8.3: // * Leading '/'s are trimmed. For example, `///test` is treated as // `test`. // * If the filename contains '..', then the file is skipped when // extracting the tarball. // * '//' within a filename is effectively skipped. An error is // logged, but otherwise the effect is as if any two or more // adjacent '/'s within the filename were consolidated into one // '/'. // // Most of this is handled by the `path` module of the standard // library, but we specially handle a few cases here as well. let mut file_dst = dst.to_path_buf(); { let path = try!(file.header().path().map_err(|e| { TarError::new("invalid path in entry header", e) })); for part in path.components() { match part { // Leading '/' characters, root paths, and '.' // components are just ignored and treated as "empty // components" Component::Prefix(..) | Component::RootDir | Component::CurDir => continue, // If any part of the filename is '..', then skip over // unpacking the file to prevent directory traversal // security issues. See, e.g.: CVE-2001-1267, // CVE-2002-0399, CVE-2005-1918, CVE-2007-4131 Component::ParentDir => continue 'outer, Component::Normal(part) => file_dst.push(part), } } } // Skip cases where only slashes or '.' parts were seen, because // this is effectively an empty filename. if *dst == *file_dst { continue } if file.header().link[0] == b'5' { try!(fs::create_dir_all(&file_dst).map_err(|e| { TarError::new(&format!("failed to create `{}`", file_dst.display()), e) })); } else { let dir = file_dst.parent().unwrap(); try!(fs::create_dir_all(&dir).map_err(|e| { TarError::new(&format!("failed to create `{}`", dir.display()), e) })); try!(file.unpack(&file_dst)); } } Ok(()) } fn skip(&self, mut amt: u64) -> io::Result<()> { let mut buf = [0u8; 4096 * 8]; let mut me = self; while amt > 0 { let n = cmp::min(amt, buf.len() as u64); let n = try!(Read::read(&mut me, &mut buf[..n as usize])); if n == 0 { let errstr = "unexpected EOF during skip"; return Err(Error::new(ErrorKind::Other, errstr)); } amt -= n as u64; } Ok(()) } // Assumes that the underlying reader is positioned at the start of a valid // header to parse. fn next_file(&self, offset: &mut u64, seek: fn(&File<R>) -> io::Result<()>) -> io::Result<Option<File<R>>> { // If we have 2 or more sections of 0s, then we're done! let mut chunk = [0; 512]; let mut me = self; try!(read_all(&mut me, &mut chunk)); *offset += 512; // A block of 0s is never valid as a header (because of the checksum), // so if it's all zero it must be the first of the two end blocks if chunk.iter().all(|i| *i == 0) { try!(read_all(&mut me, &mut chunk)); *offset += 512; return if chunk.iter().all(|i| *i == 0) { Ok(None) } else { Err(bad_archive()) } } let sum = chunk[..148].iter().map(|i| *i as u32).fold(0, |a, b| a + b) + chunk[156..].iter().map(|i| *i as u32).fold(0, |a, b| a + b) + 32 * 8; let header: Header = unsafe { mem::transmute(chunk) }; let ret = File { archive: self, pos: 0, size: try!(header.size()), header: header, tar_offset: *offset, seek: seek, }; // Make sure the checksum is ok let cksum = try!(ret.header.cksum()); if sum != cksum { return Err(bad_archive()) } // Figure out where the next file is let size = (ret.size + 511) & !(512 - 1); *offset += size; return Ok(Some(ret)); } } impl<W: Write> Archive<W> { /// Adds a new entry to this archive. /// /// This function will append the header specified, followed by contents of /// the stream specified by `data`. To produce a valid archive the `size` /// field of `header` must be the same as the length of the stream that's /// being written. Additionally the checksum for the header should have been /// set via the `set_cksum` method. /// /// Note that this will not attempt to seek the archive to a valid position, /// so if the archive is in the middle of a read or some other similar /// operation then this may corrupt the archive. /// /// Also note that after all files have been written to an archive the /// `finish` function needs to be called to finish writing the archive. /// /// # Errors /// /// This function will return an error for any intermittent I/O error which /// occurs when either reading or writing. /// /// # Examples /// /// ``` /// use tar::{Archive, Header}; /// /// let mut header = Header::new(); /// header.set_path("foo"); /// header.set_size(4); /// header.set_cksum(); /// /// let mut data: &[u8] = &[1, 2, 3, 4]; /// /// let mut ar = Archive::new(Vec::new()); /// ar.append(&header, &mut data).unwrap(); /// let archive = ar.into_inner(); /// ``` pub fn append(&self, header: &Header, mut data: &mut Read) -> io::Result<()> { let mut obj = self.obj.borrow_mut(); try!(obj.write_all(header.as_bytes())); let len = try!(io::copy(&mut data, &mut *obj)); // Pad with zeros if necessary. let buf = [0; 512]; let remaining = 512 - (len % 512); if remaining < 512 { try!(obj.write_all(&buf[..remaining as usize])); } Ok(()) } /// Adds a file on the local filesystem to this archive. /// /// This function will open the file specified by `path` and insert the file /// into the archive with the appropriate metadata set, returning any I/O /// error which occurs while writing. The path name for the file inside of /// this archive will be the same as `path`, and it is recommended that the /// path is a relative path. /// /// Note that this will not attempt to seek the archive to a valid position, /// so if the archive is in the middle of a read or some other similar /// operation then this may corrupt the archive. /// /// Also note that after all files have been written to an archive the /// `finish` function needs to be called to finish writing the archive. /// /// # Examples /// /// ```no_run /// use tar::Archive; /// /// let mut ar = Archive::new(Vec::new()); /// /// ar.append_path("foo/bar.txt").unwrap(); /// ``` pub fn append_path<P: AsRef<Path>>(&self, path: P) -> io::Result<()> { self.append_path2(path.as_ref()) } fn append_path2(&self, path: &Path) -> io::Result<()> { let stat = try!(fs::metadata(path)); let header = try!(Header::from_path_and_metadata(path, &stat)); if stat.is_file() { let mut file = try!(fs::File::open(path)); self.append(&header, &mut file) } else if stat.is_dir() { self.append(&header, &mut io::empty()) } else { Err(Error::new(ErrorKind::Other, "path has unknown file type")) } } /// Adds a file to this archive with the given path as the name of the file /// in the archive. /// /// This will use the metadata of `file` to populate a `Header`, and it will /// then append the file to the archive with the name `path`. /// /// Note that this will not attempt to seek the archive to a valid position, /// so if the archive is in the middle of a read or some other similar /// operation then this may corrupt the archive. /// /// Also note that after all files have been written to an archive the /// `finish` function needs to be called to finish writing the archive. /// /// # Examples /// /// ```no_run /// use std::fs::File; /// use tar::Archive; /// /// let mut ar = Archive::new(Vec::new()); /// /// // Open the file at one location, but insert it into the archive with a /// // different name. /// let mut f = File::open("foo/bar/baz.txt").unwrap(); /// ar.append_file("bar/baz.txt", &mut f).unwrap(); /// ``` pub fn append_file<P: AsRef<Path>>(&self, path: P, file: &mut fs::File) -> io::Result<()> { self.append_file2(path.as_ref(), file) } fn append_file2(&self, path: &Path, file: &mut fs::File) -> io::Result<()> { let stat = try!(file.metadata()); let header = try!(Header::from_path_and_metadata(path, &stat)); self.append(&header, file) } /// Adds a directory to this archive with the given path as the name of the /// directory in the archive. /// /// This will use `stat` to populate a `Header`, and it will then append the /// directory to the archive with the name `path`. /// /// Note that this will not attempt to seek the archive to a valid position, /// so if the archive is in the middle of a read or some other similar /// operation then this may corrupt the archive. /// /// Also note that after all files have been written to an archive the /// `finish` function needs to be called to finish writing the archive. /// /// # Examples /// /// ``` /// use std::fs; /// use tar::Archive; /// /// let mut ar = Archive::new(Vec::new()); /// /// // Use the directory at one location, but insert it into the archive /// // with a different name. /// ar.append_dir("bardir", ".").unwrap(); /// ``` pub fn append_dir<P: AsRef<Path>, P2: AsRef<Path>>( &self, path: P, src_path: P2) -> io::Result<()> { self.append_dir2(path.as_ref(), src_path.as_ref()) } fn append_dir2(&self, path: &Path, src_path: &Path) -> io::Result<()> { let stat = try!(fs::metadata(src_path)); let header = try!(Header::from_path_and_metadata(path, &stat)); self.append(&header, &mut io::empty()) } /// Finish writing this archive, emitting the termination sections. /// /// This function is required to be called to complete the archive, it will /// be invalid if this is not called. pub fn finish(&self) -> io::Result<()> { let b = [0; 1024]; self.obj.borrow_mut().write_all(&b) } } impl<'a, R: Seek + Read> Iterator for Files<'a, R> { type Item = io::Result<File<'a, R>>; fn next(&mut self) -> Option<io::Result<File<'a, R>>> { // If we hit a previous error, or we reached the end, we're done here if self.done { return None } // Seek to the start of the next header in the archive try_iter!(self, self.archive.seek(self.offset)); fn doseek<R: Seek + Read>(file: &File<R>) -> io::Result<()> { file.archive.seek(file.tar_offset + file.pos) } // Parse the next file header match try_iter!(self, self.archive.next_file(&mut self.offset, doseek)) { None => { self.done = true; None } Some(f) => Some(Ok(f)), } } } impl<'a, R: Read> Iterator for FilesMut<'a, R> { type Item = io::Result<File<'a, R>>; fn next(&mut self) -> Option<io::Result<File<'a, R>>> { // If we hit a previous error, or we reached the end, we're done here if self.done { return None } // Seek to the start of the next header in the archive let delta = self.next - self.archive.pos.get(); try_iter!(self, self.archive.skip(delta)); // no-op because this reader can't seek fn doseek<R>(_: &File<R>) -> io::Result<()> { Ok(()) } // Parse the next file header match try_iter!(self, self.archive.next_file(&mut self.next, doseek)) { None => { self.done = true; None } Some(f) => Some(Ok(f)), } } } impl Clone for Header { fn clone(&self) -> Header { Header { ..*self } } } impl Header { /// Creates a new blank ustar header ready to be filled in pub fn new() -> Header { let mut header: Header = unsafe { mem::zeroed() }; // Flag this header as a UStar archive header.ustar = *b"ustar\0"; header.ustar_version = *b"00"; return header } fn from_path_and_metadata(path: &Path, stat: &fs::Metadata) -> io::Result<Header> { let mut header = Header::new(); // TODO: add trailing path::MAIN_SEPARATOR onto directories for // compatibility. Requires either the std::path to allow it or OsStr // to permit character checks // https://github.com/rust-lang/rust/issues/29008 try!(header.set_path(path)); header.set_metadata(&stat); header.set_cksum(); Ok(header) } fn is_ustar(&self) -> bool { &self.ustar[..5] == b"ustar" } /// Returns a view into this header as a byte array. pub fn as_bytes(&self) -> &[u8; 512] { debug_assert_eq!(512, mem::size_of_val(self)); unsafe { &*(self as *const _ as *const [u8; 512]) } } /// Blanket sets the metadata in this header from the metadata argument /// provided. /// /// This is useful for initializing a `Header` from the OS's metadata from a /// file. pub fn set_metadata(&mut self, meta: &fs::Metadata) { // Platform-specific fill self.fill_from(meta); // Platform-agnostic fill // Set size of directories to zero self.set_size(if meta.is_dir() { 0 } else { meta.len() }); self.set_device_major(0); self.set_device_minor(0); } /// Returns the file size this header represents. /// /// May return an error if the field is corrupted. pub fn size(&self) -> io::Result<u64> { octal_from(&self.size) } /// Encodes the `size` argument into the size field of this header. pub fn set_size(&mut self, size: u64) { octal_into(&mut self.size, size) } /// Returns the pathname stored in this header. /// /// This method may fail if the pathname is not valid unicode and this is /// called on a Windows platform. /// /// Note that this function will convert any `\` characters to directory /// separators. pub fn path(&self) -> io::Result<Cow<Path>> { return bytes2path(self.path_bytes()); #[cfg(windows)] fn bytes2path(bytes: Cow<[u8]>) -> io::Result<Cow<Path>> { match bytes { Cow::Borrowed(bytes) => { let s = try!(str::from_utf8(bytes).map_err(|_| { not_unicode() })); Ok(Cow::Borrowed(Path::new(s))) } Cow::Owned(bytes) => { let s = try!(String::from_utf8(bytes).map_err(|_| { not_unicode() })); Ok(Cow::Owned(PathBuf::from(s))) } } } #[cfg(unix)] fn bytes2path(bytes: Cow<[u8]>) -> io::Result<Cow<Path>> { Ok(match bytes { Cow::Borrowed(bytes) => Cow::Borrowed({ Path::new(OsStr::from_bytes(bytes)) }), Cow::Owned(bytes) => Cow::Owned({ PathBuf::from(OsString::from_vec(bytes)) }) }) } } /// Returns the pathname stored in this header as a byte array. /// /// This function is guaranteed to succeed, but you may wish to call the /// `path` method to convert to a `Path`. /// /// Note that this function will convert any `\` characters to directory /// separators. pub fn path_bytes(&self) -> Cow<[u8]> { if (!self.is_ustar() || self.prefix[0] == 0) && !self.name.contains(&b'\\') { Cow::Borrowed(truncate(&self.name)) } else { fn noslash(b: &u8) -> u8 { if *b == b'\\' {b'/'} else {*b} } let mut bytes = Vec::new(); let prefix = truncate(&self.prefix); if prefix.len() > 0 { bytes.extend(prefix.iter().map(noslash)); bytes.push(b'/'); } bytes.extend(truncate(&self.name).iter().map(noslash)); Cow::Owned(bytes) } } /// Sets the path name for this header. /// /// This function will set the pathname listed in this header, encoding it /// in the appropriate format. May fail if the path is too long or if the /// path specified is not unicode and this is a Windows platform. pub fn set_path<P: AsRef<Path>>(&mut self, p: P) -> io::Result<()> { self.set_path2(p.as_ref()) } fn set_path2(&mut self, path: &Path) -> io::Result<()> { let bytes = match bytes(path) { Some(b) => b, None => return Err(Error::new(ErrorKind::Other, "path was not \ valid unicode")), }; if bytes.iter().any(|b| *b == 0) { return Err(Error::new(ErrorKind::Other, "path contained a nul byte")) } let (namelen, prefixlen) = (self.name.len(), self.prefix.len()); if bytes.len() < namelen { try!(copy_into(&mut self.name, bytes, true)); } else { let prefix = &bytes[..cmp::min(bytes.len(), prefixlen)]; let pos = match prefix.iter().rposition(|&b| b == b'/' || b == b'\\') { Some(i) => i, None => return Err(Error::new(ErrorKind::Other, "path cannot be split to be \ inserted into archive")), }; try!(copy_into(&mut self.name, &bytes[pos + 1..], true)); try!(copy_into(&mut self.prefix, &bytes[..pos], true)); } return Ok(()); #[cfg(windows)] fn bytes(p: &Path) -> Option<&[u8]> { p.as_os_str().to_str().map(|s| s.as_bytes()) } #[cfg(unix)] fn bytes(p: &Path) -> Option<&[u8]> { Some(p.as_os_str().as_bytes()) } } /// Returns the mode bits for this file /// /// May return an error if the field is corrupted. pub fn mode(&self) -> io::Result<u32> { octal_from(&self.mode).map(|u| u as u32) } /// Encodes the `mode` provided into this header. pub fn set_mode(&mut self, mode: u32) { octal_into(&mut self.mode, mode & 0o3777); } /// Returns the value of the owner's user ID field /// /// May return an error if the field is corrupted. pub fn uid(&self) -> io::Result<u32> { octal_from(&self.owner_id).map(|u| u as u32) } /// Encodes the `uid` provided into this header. pub fn set_uid(&mut self, uid: u32) { octal_into(&mut self.owner_id, uid); } /// Returns the value of the group's user ID field pub fn gid(&self) -> io::Result<u32> { octal_from(&self.group_id).map(|u| u as u32) } /// Encodes the `gid` provided into this header. pub fn set_gid(&mut self, gid: u32) { octal_into(&mut self.group_id, gid); } /// Returns the last modification time in Unix time format pub fn mtime(&self) -> io::Result<u64> { octal_from(&self.mtime) } /// Encodes the `mtime` provided into this header. /// /// Note that this time is typically a number of seconds passed since /// January 1, 1970. pub fn set_mtime(&mut self, mtime: u64) { octal_into(&mut self.mtime, mtime); } /// Return the username of the owner of this file, if present and if valid /// utf8 pub fn username(&self) -> Option<&str> { self.username_bytes().and_then(|s| str::from_utf8(s).ok()) } /// Returns the username of the owner of this file, if present pub fn username_bytes(&self) -> Option<&[u8]> { if self.is_ustar() { Some(truncate(&self.owner_name)) } else { None } } /// Sets the username inside this header. /// /// May return an error if the name provided is too long. pub fn set_username(&mut self, name: &str) -> io::Result<()> { copy_into(&mut self.owner_name, name.as_bytes(), false) } /// Return the group name of the owner of this file, if present and if valid /// utf8 pub fn groupname(&self) -> Option<&str> { self.groupname_bytes().and_then(|s| str::from_utf8(s).ok()) } /// Returns the group name of the owner of this file, if present pub fn groupname_bytes(&self) -> Option<&[u8]> { if self.is_ustar() { Some(truncate(&self.group_name)) } else { None } } /// Sets the group name inside this header. /// /// May return an error if the name provided is too long. pub fn set_groupname(&mut self, name: &str) -> io::Result<()> { copy_into(&mut self.group_name, name.as_bytes(), false) } /// Returns the device major number, if present. /// /// This field is only present in UStar archives. A value of `None` means /// that this archive is not a UStar archive, while a value of `Some` /// represents the attempt to decode the field in the header. pub fn device_major(&self) -> Option<io::Result<u32>> { if self.is_ustar() { Some(octal_from(&self.dev_major).map(|u| u as u32)) } else { None } } /// Encodes the value `major` into the dev_major field of this header. pub fn set_device_major(&mut self, major: u32) { octal_into(&mut self.dev_major, major); } /// Returns the device minor number, if present. /// /// This field is only present in UStar archives. A value of `None` means /// that this archive is not a UStar archive, while a value of `Some` /// represents the attempt to decode the field in the header. pub fn device_minor(&self) -> Option<io::Result<u32>> { if self.is_ustar() { Some(octal_from(&self.dev_minor).map(|u| u as u32)) } else { None } } /// Encodes the value `minor` into the dev_major field of this header. pub fn set_device_minor(&mut self, minor: u32) { octal_into(&mut self.dev_minor, minor); } /// Returns the checksum field of this header. /// /// May return an error if the field is corrupted. pub fn cksum(&self) -> io::Result<u32> { octal_from(&self.cksum).map(|u| u as u32) } /// Sets the checksum field of this header based on the current fields in /// this header. pub fn set_cksum(&mut self) { let cksum = { let bytes = self.as_bytes(); bytes[..148].iter().map(|i| *i as u32).fold(0, |a, b| a + b) + bytes[156..].iter().map(|i| *i as u32).fold(0, |a, b| a + b) + 32 * (self.cksum.len() as u32) }; octal_into(&mut self.cksum, cksum); } #[cfg(unix)] fn fill_from(&mut self, meta: &fs::Metadata) { self.set_mode((meta.mode() & 0o3777) as u32); self.set_mtime(meta.mtime() as u64); self.set_uid(meta.uid() as u32); self.set_gid(meta.gid() as u32); // TODO: need to bind more file types self.link[0] = match meta.mode() & libc::S_IFMT { libc::S_IFREG => b'0', libc::S_IFLNK => b'2', libc::S_IFCHR => b'3', libc::S_IFBLK => b'4', libc::S_IFDIR => b'5', libc::S_IFIFO => b'6', _ => b' ', }; } #[cfg(windows)] fn fill_from(&mut self, meta: &fs::Metadata) { let readonly = meta.file_attributes() & winapi::FILE_ATTRIBUTE_READONLY; // There's no concept of a mode on windows, so do a best approximation // here. let mode = match (meta.is_dir(), readonly != 0) { (true, false) => 0o755, (true, true) => 0o555, (false, false) => 0o644, (false, true) => 0o444, }; self.set_mode(mode); self.set_uid(0); self.set_gid(0); let ft = meta.file_type(); self.link[0] = if ft.is_dir() { b'5' } else if ft.is_file() { b'0' } else if ft.is_symlink() { b'2' } else { b' ' }; // The dates listed in tarballs are always seconds relative to // January 1, 1970. On Windows, however, the timestamps are returned as // dates relative to January 1, 1601 (in 100ns intervals), so we need to // add in some offset for those dates. let mtime = (meta.last_write_time() / (1_000_000_000 / 100)) - 11644473600; self.set_mtime(mtime); } } impl<'a, R: Read> File<'a, R> { /// Returns access to the header of this file in the archive. /// /// This provides access to the the metadata for this file in the archive. pub fn header(&self) -> &Header { &self.header } /// Writes this file to the specified location. /// /// This function will write the entire contents of this file into the /// location specified by `dst`. Metadata will also be propagated to the /// path `dst`. /// /// This function will create a file at the path `dst`, and it is required /// that the intermediate directories are created. Any existing file at the /// location `dst` will be overwritten. /// /// # Examples /// /// ```no_run /// use std::fs::File; /// use tar::Archive; /// /// let ar = Archive::new(File::open("foo.tar").unwrap()); /// /// for (i, file) in ar.files().unwrap().enumerate() { /// let mut file = file.unwrap(); /// file.unpack(format!("file-{}", i)).unwrap(); /// } /// ``` pub fn unpack<P: AsRef<Path>>(&mut self, dst: P) -> io::Result<()> { self.unpack2(dst.as_ref()) } fn unpack2(&mut self, dst: &Path) -> io::Result<()> { try!(fs::File::create(dst).and_then(|mut f| { if try!(io::copy(self, &mut f)) != self.size { return Err(bad_archive()); } Ok(()) }).map_err(|e| { let header = self.header().path_bytes(); TarError::new(&format!("failed to unpack `{}` into `{}`", String::from_utf8_lossy(&header), dst.display()), e) })); if let Ok(mtime) = self.header().mtime() { let mtime = FileTime::from_seconds_since_1970(mtime, 0); try!(filetime::set_file_times(dst, mtime, mtime).map_err(|e| { TarError::new(&format!("failed to set mtime for `{}`", dst.display()), e) })); } if let Ok(mode) = self.header().mode() { try!(set_perms(dst, mode).map_err(|e| { TarError::new(&format!("failed to set permissions to {:o} \ for `{}`", mode, dst.display()), e) })); } return Ok(()); #[cfg(unix)] fn set_perms(dst: &Path, mode: u32) -> io::Result<()> { use std::os::unix::raw; let perm = fs::Permissions::from_mode(mode as raw::mode_t); fs::set_permissions(dst, perm) } #[cfg(windows)] fn set_perms(dst: &Path, mode: u32) -> io::Result<()> { let mut perm = try!(fs::metadata(dst)).permissions(); perm.set_readonly(mode & 0o200 != 0o200); fs::set_permissions(dst, perm) } } } impl<'a, R: Read> Read for &'a Archive<R> { fn read(&mut self, into: &mut [u8]) -> io::Result<usize> { self.obj.borrow_mut().read(into).map(|i| { self.pos.set(self.pos.get() + i as u64); i }) } } impl<'a, R: Read> Read for File<'a, R> { fn read(&mut self, into: &mut [u8]) -> io::Result<usize> { if self.size == self.pos { return Ok(0) } try!((self.seek)(self)); let amt = cmp::min((self.size - self.pos) as usize, into.len()); let amt = try!(Read::read(&mut self.archive, &mut into[..amt])); self.pos += amt as u64; Ok(amt) } } impl<'a, R: Read + Seek> Seek for File<'a, R> { fn seek(&mut self, how: SeekFrom) -> io::Result<u64> { let next = match how { SeekFrom::Start(pos) => pos as i64, SeekFrom::Current(pos) => self.pos as i64 + pos, SeekFrom::End(pos) => self.size as i64 + pos, }; if next < 0 { Err(Error::new(ErrorKind::Other, "cannot seek before position 0")) } else if next as u64 > self.size { Err(Error::new(ErrorKind::Other, "cannot seek past end of file")) } else { self.pos = next as u64; Ok(self.pos) } } } fn bad_archive() -> Error { Error::new(ErrorKind::Other, "invalid tar archive") } fn octal_from(slice: &[u8]) -> io::Result<u64> { let num = match str::from_utf8(truncate(slice)) { Ok(n) => n, Err(_) => return Err(bad_archive()), }; match u64::from_str_radix(num.trim(), 8) { Ok(n) => Ok(n), Err(_) => Err(bad_archive()) } } fn octal_into<T: fmt::Octal>(dst: &mut [u8], val: T) { let o = format!("{:o}", val); let value = o.bytes().rev().chain(repeat(b'0')); for (slot, value) in dst.iter_mut().rev().skip(1).zip(value) { *slot = value; } } fn truncate<'a>(slice: &'a [u8]) -> &'a [u8] { match slice.iter().position(|i| *i == 0) { Some(i) => &slice[..i], None => slice, } } fn read_all<R: Read>(r: &mut R, buf: &mut [u8]) -> io::Result<()> { let mut read = 0; while read < buf.len() { match try!(r.read(&mut buf[read..])) { 0 => return Err(bad_archive()), n => read += n, } } Ok(()) } /// Copies `bytes` into the `slot` provided, returning an error if the `bytes` /// array is too long or if it contains any nul bytes. /// /// Also provides the option to map '\' characters to '/' characters for the /// names of paths in archives. The `tar` utility doesn't seem to like windows /// backslashes when unpacking on Unix. fn copy_into(slot: &mut [u8], bytes: &[u8], map_slashes: bool) -> io::Result<()> { if bytes.len() > slot.len() { Err(Error::new(ErrorKind::Other, "provided value is too long")) } else if bytes.iter().any(|b| *b == 0) { Err(Error::new(ErrorKind::Other, "provided value contains a nul byte")) } else { for (slot, val) in slot.iter_mut().zip(bytes) { if map_slashes && *val == b'\\' { *slot = b'/'; } else { *slot = *val; } } Ok(()) } } #[cfg(windows)] fn not_unicode() -> Error { Error::new(ErrorKind::Other, "only unicode paths are supported on windows") } impl TarError { fn new(desc: &str, err: Error) -> TarError { TarError { desc: desc.to_string(), io: err, } } } impl error::Error for TarError { fn description(&self) -> &str { &self.desc } fn cause(&self) -> Option<&error::Error> { Some(&self.io) } } impl fmt::Display for TarError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.desc.fmt(f) } } impl From<TarError> for Error { fn from(t: TarError) -> Error { Error::new(t.io.kind(), t) } } #[cfg(test)] mod tests { extern crate tempdir; use std::io::prelude::*; use std::io::{self, Cursor, SeekFrom}; use std::iter::repeat; use std::fs::{self, File}; use std::path::Path; use filetime::FileTime; use self::tempdir::TempDir; use super::{Archive, Header}; macro_rules! t { ($e:expr) => (match $e { Ok(v) => v, Err(e) => panic!("{} returned {}", stringify!($e), e), }) } #[test] fn simple() { let ar = Archive::new(Cursor::new(&include_bytes!("tests/simple.tar")[..])); for file in t!(ar.files()) { t!(file); } } #[test] fn header_impls() { let ar = Archive::new(Cursor::new(&include_bytes!("tests/simple.tar")[..])); let hn = Header::new(); let hnb = hn.as_bytes(); for file in t!(ar.files()) { let file = t!(file); let h1 = file.header(); let h1b = h1.as_bytes(); let h2 = h1.clone(); let h2b = h2.as_bytes(); assert!(h1b[..] == h2b[..] && h2b[..] != hnb[..]) } } #[test] fn reading_files() { let rdr = Cursor::new(&include_bytes!("tests/reading_files.tar")[..]); let ar = Archive::new(rdr); let mut files = t!(ar.files()); let mut a = t!(files.next().unwrap()); let mut b = t!(files.next().unwrap()); assert!(files.next().is_none()); assert_eq!(&*a.header().path_bytes(), b"a"); assert_eq!(&*b.header().path_bytes(), b"b"); let mut s = String::new(); t!(a.read_to_string(&mut s)); assert_eq!(s, "a\na\na\na\na\na\na\na\na\na\na\n"); s.truncate(0); t!(b.read_to_string(&mut s)); assert_eq!(s, "b\nb\nb\nb\nb\nb\nb\nb\nb\nb\nb\n"); t!(a.seek(SeekFrom::Start(0))); s.truncate(0); t!(a.read_to_string(&mut s)); assert_eq!(s, "a\na\na\na\na\na\na\na\na\na\na\n"); } #[test] fn writing_files() { let wr = Cursor::new(Vec::new()); let ar = Archive::new(wr); let td = t!(TempDir::new("tar-rs")); let path = td.path().join("test"); t!(t!(File::create(&path)).write_all(b"test")); t!(ar.append_file("test2", &mut t!(File::open(&path)))); t!(ar.finish()); let rd = Cursor::new(ar.into_inner().into_inner()); let ar = Archive::new(rd); let mut files = t!(ar.files()); let mut f = t!(files.next().unwrap()); assert!(files.next().is_none()); assert_eq!(&*f.header().path_bytes(), b"test2"); assert_eq!(f.header().size().unwrap(), 4); let mut s = String::new(); t!(f.read_to_string(&mut s)); assert_eq!(s, "test"); } #[test] fn large_filename() { let ar = Archive::new(Cursor::new(Vec::new())); let td = t!(TempDir::new("tar-rs")); let path = td.path().join("test"); t!(t!(File::create(&path)).write_all(b"test")); let filename = repeat("abcd/").take(50).collect::<String>(); t!(ar.append_file(&filename, &mut t!(File::open(&path)))); t!(ar.finish()); let too_long = repeat("abcd").take(200).collect::<String>(); assert!(ar.append_file(&too_long, &mut t!(File::open(&path))).is_err()); let rd = Cursor::new(ar.into_inner().into_inner()); let ar = Archive::new(rd); let mut files = t!(ar.files()); let mut f = files.next().unwrap().unwrap(); assert!(files.next().is_none()); assert_eq!(&*f.header().path_bytes(), filename.as_bytes()); assert_eq!(f.header().size().unwrap(), 4); let mut s = String::new(); t!(f.read_to_string(&mut s)); assert_eq!(s, "test"); } #[test] fn reading_files_mut() { let rdr = Cursor::new(&include_bytes!("tests/reading_files.tar")[..]); let mut ar = Archive::new(rdr); let mut files = t!(ar.files_mut()); let mut a = t!(files.next().unwrap()); assert_eq!(&*a.header().path_bytes(), b"a"); let mut s = String::new(); t!(a.read_to_string(&mut s)); assert_eq!(s, "a\na\na\na\na\na\na\na\na\na\na\n"); s.truncate(0); t!(a.read_to_string(&mut s)); assert_eq!(s, ""); let mut b = t!(files.next().unwrap()); assert_eq!(&*b.header().path_bytes(), b"b"); s.truncate(0); t!(b.read_to_string(&mut s)); assert_eq!(s, "b\nb\nb\nb\nb\nb\nb\nb\nb\nb\nb\n"); assert!(files.next().is_none()); } fn check_dirtree(td: &TempDir) { let dir_a = td.path().join("a"); let dir_b = td.path().join("a/b"); let file_c = td.path().join("a/c"); assert!(fs::metadata(&dir_a).map(|m| m.is_dir()).unwrap_or(false)); assert!(fs::metadata(&dir_b).map(|m| m.is_dir()).unwrap_or(false)); assert!(fs::metadata(&file_c).map(|m| m.is_file()).unwrap_or(false)); } #[test] fn extracting_directories() { let td = t!(TempDir::new("tar-rs")); let rdr = Cursor::new(&include_bytes!("tests/directory.tar")[..]); let mut ar = Archive::new(rdr); t!(ar.unpack(td.path())); check_dirtree(&td); } #[test] fn writing_and_extracting_directories() { let td = t!(TempDir::new("tar-rs")); let cur = Cursor::new(Vec::new()); let ar = Archive::new(cur); let tmppath = td.path().join("tmpfile"); t!(t!(File::create(&tmppath)).write_all(b"c")); t!(ar.append_dir("a", ".")); t!(ar.append_dir("a/b", ".")); t!(ar.append_file("a/c", &mut t!(File::open(&tmppath)))); t!(ar.finish()); let rdr = Cursor::new(ar.into_inner().into_inner()); let mut ar = Archive::new(rdr); t!(ar.unpack(td.path())); check_dirtree(&td); } #[test] fn extracting_duplicate_dirs() { let td = t!(TempDir::new("tar-rs")); let rdr = Cursor::new(&include_bytes!("tests/duplicate_dirs.tar")[..]); let mut ar = Archive::new(rdr); t!(ar.unpack(td.path())); let some_dir = td.path().join("some_dir"); assert!(fs::metadata(&some_dir).map(|m| m.is_dir()).unwrap_or(false)); } #[test] fn handling_incorrect_file_size() { let td = t!(TempDir::new("tar-rs")); let cur = Cursor::new(Vec::new()); let ar = Archive::new(cur); let path = td.path().join("tmpfile"); t!(File::create(&path)); let mut file = t!(File::open(&path)); let mut header = Header::new(); t!(header.set_path("somepath")); header.set_metadata(&t!(file.metadata())); header.set_size(2048); // past the end of file null blocks header.set_cksum(); t!(ar.append(&header, &mut file)); t!(ar.finish()); // Extracting let rdr = Cursor::new(ar.into_inner().into_inner()); let mut ar = Archive::new(rdr); assert!(ar.unpack(td.path()).is_err()); // Iterating let rdr = Cursor::new(ar.into_inner().into_inner()); let mut ar = Archive::new(rdr); assert!(t!(ar.files_mut()).any(|fr| fr.is_err())); } #[test] fn extracting_malicious_tarball() { use std::fs; use std::fs::OpenOptions; use std::io::{Seek, Write}; let td = t!(TempDir::new("tar-rs")); let mut evil_tar = Cursor::new(Vec::new()); { let a = Archive::new(&mut evil_tar); let mut evil_txt_f = t!(OpenOptions::new().read(true).write(true) .create(true) .open(td.path().join("evil.txt"))); t!(writeln!(evil_txt_f, "This is an evil file.")); t!(evil_txt_f.seek(SeekFrom::Start(0))); t!(a.append_file("/tmp/abs_evil.txt", &mut evil_txt_f)); t!(evil_txt_f.seek(SeekFrom::Start(0))); t!(a.append_file("//tmp/abs_evil2.txt", &mut evil_txt_f)); t!(evil_txt_f.seek(SeekFrom::Start(0))); t!(a.append_file("///tmp/abs_evil3.txt", &mut evil_txt_f)); t!(evil_txt_f.seek(SeekFrom::Start(0))); t!(a.append_file("/./tmp/abs_evil4.txt", &mut evil_txt_f)); t!(evil_txt_f.seek(SeekFrom::Start(0))); t!(a.append_file("//./tmp/abs_evil5.txt", &mut evil_txt_f)); t!(evil_txt_f.seek(SeekFrom::Start(0))); t!(a.append_file("///./tmp/abs_evil6.txt", &mut evil_txt_f)); t!(evil_txt_f.seek(SeekFrom::Start(0))); t!(a.append_file("/../tmp/rel_evil.txt", &mut evil_txt_f)); t!(evil_txt_f.seek(SeekFrom::Start(0))); t!(a.append_file("../rel_evil2.txt", &mut evil_txt_f)); t!(evil_txt_f.seek(SeekFrom::Start(0))); t!(a.append_file("./../rel_evil3.txt", &mut evil_txt_f)); t!(evil_txt_f.seek(SeekFrom::Start(0))); t!(a.append_file("some/../../rel_evil4.txt", &mut evil_txt_f)); t!(evil_txt_f.seek(SeekFrom::Start(0))); t!(a.append_file("", &mut evil_txt_f)); t!(evil_txt_f.seek(SeekFrom::Start(0))); t!(a.append_file("././//./", &mut evil_txt_f)); t!(evil_txt_f.seek(SeekFrom::Start(0))); t!(a.append_file(".", &mut evil_txt_f)); t!(a.finish()); } t!(evil_tar.seek(SeekFrom::Start(0))); let mut ar = Archive::new(&mut evil_tar); t!(ar.unpack(td.path())); assert!(fs::metadata("/tmp/abs_evil.txt").is_err()); assert!(fs::metadata("/tmp/abs_evil.txt2").is_err()); assert!(fs::metadata("/tmp/abs_evil.txt3").is_err()); assert!(fs::metadata("/tmp/abs_evil.txt4").is_err()); assert!(fs::metadata("/tmp/abs_evil.txt5").is_err()); assert!(fs::metadata("/tmp/abs_evil.txt6").is_err()); assert!(fs::metadata("/tmp/rel_evil.txt").is_err()); assert!(fs::metadata("/tmp/rel_evil.txt").is_err()); assert!(fs::metadata(td.path().join("../tmp/rel_evil.txt")).is_err()); assert!(fs::metadata(td.path().join("../rel_evil2.txt")).is_err()); assert!(fs::metadata(td.path().join("../rel_evil3.txt")).is_err()); assert!(fs::metadata(td.path().join("../rel_evil4.txt")).is_err()); // The `some` subdirectory should not be created because the only // filename that references this has '..'. assert!(fs::metadata(td.path().join("some")).is_err()); // The `tmp` subdirectory should be created and within this // subdirectory, there should be files named `abs_evil.txt` through // `abs_evil6.txt`. assert!(fs::metadata(td.path().join("tmp")).map(|m| m.is_dir()) .unwrap_or(false)); assert!(fs::metadata(td.path().join("tmp/abs_evil.txt")) .map(|m| m.is_file()).unwrap_or(false)); assert!(fs::metadata(td.path().join("tmp/abs_evil2.txt")) .map(|m| m.is_file()).unwrap_or(false)); assert!(fs::metadata(td.path().join("tmp/abs_evil3.txt")) .map(|m| m.is_file()).unwrap_or(false)); assert!(fs::metadata(td.path().join("tmp/abs_evil4.txt")) .map(|m| m.is_file()).unwrap_or(false)); assert!(fs::metadata(td.path().join("tmp/abs_evil5.txt")) .map(|m| m.is_file()).unwrap_or(false)); assert!(fs::metadata(td.path().join("tmp/abs_evil6.txt")) .map(|m| m.is_file()).unwrap_or(false)); } #[test] fn octal_spaces() { let rdr = Cursor::new(&include_bytes!("tests/spaces.tar")[..]); let ar = Archive::new(rdr); let file = ar.files().unwrap().next().unwrap().unwrap(); assert_eq!(file.header().mode().unwrap() & 0o777, 0o777); assert_eq!(file.header().uid().unwrap(), 0); assert_eq!(file.header().gid().unwrap(), 0); assert_eq!(file.header().size().unwrap(), 2); assert_eq!(file.header().mtime().unwrap(), 0o12440016664); assert_eq!(file.header().cksum().unwrap(), 0o4253); } #[test] fn extracting_malformed_tar_null_blocks() { let td = t!(TempDir::new("tar-rs")); let cur = Cursor::new(Vec::new()); let ar = Archive::new(cur); let path1 = td.path().join("tmpfile1"); let path2 = td.path().join("tmpfile2"); t!(File::create(&path1)); t!(File::create(&path2)); t!(ar.append_path(&path1)); let mut wrtr = ar.into_inner(); t!(wrtr.write_all(&[0; 512])); let ar = Archive::new(wrtr); t!(ar.append_path(&path2)); t!(ar.finish()); let rdr = Cursor::new(ar.into_inner().into_inner()); let mut ar = Archive::new(rdr); assert!(ar.unpack(td.path()).is_err()); } #[test] fn empty_filename() { let td = t!(TempDir::new("tar-rs")); let rdr = Cursor::new(&include_bytes!("tests/empty_filename.tar")[..]); let mut ar = Archive::new(rdr); assert!(ar.unpack(td.path()).is_err()); } #[test] fn file_times() { let td = t!(TempDir::new("tar-rs")); let rdr = Cursor::new(&include_bytes!("tests/file_times.tar")[..]); let mut ar = Archive::new(rdr); t!(ar.unpack(td.path())); let meta = fs::metadata(td.path().join("a")).unwrap(); let mtime = FileTime::from_last_modification_time(&meta); let atime = FileTime::from_last_access_time(&meta); assert_eq!(mtime.seconds_relative_to_1970(), 1000000000); assert_eq!(mtime.nanoseconds(), 0); assert_eq!(atime.seconds_relative_to_1970(), 1000000000); assert_eq!(atime.nanoseconds(), 0); } #[test] fn backslash_same_as_slash() { // Insert a file into an archive with a backslash let td = t!(TempDir::new("tar-rs")); let ar = Archive::new(Vec::<u8>::new()); t!(ar.append_dir("foo\\bar", td.path())); ar.finish().unwrap(); let ar = Archive::new(Cursor::new(ar.into_inner())); let f = t!(t!(ar.files()).next().unwrap()); assert_eq!(&*f.header().path().unwrap(), Path::new("foo/bar")); // Unpack an archive with a backslash in the name let ar = Archive::new(Vec::<u8>::new()); let mut header = Header::new(); header.set_metadata(&t!(fs::metadata(td.path()))); header.set_size(0); for (a, b) in header.name.iter_mut().zip(b"foo\\bar\x00") { *a = *b; } header.set_cksum(); t!(ar.append(&header, &mut io::empty())); ar.finish().unwrap(); let mut ar = Archive::new(Cursor::new(ar.into_inner())); { let f = t!(t!(ar.files()).next().unwrap()); assert_eq!(&*f.header().path().unwrap(), Path::new("foo/bar")); } t!(ar.files()); // seek to 0 t!(ar.unpack(td.path())); assert!(fs::metadata(td.path().join("foo/bar")).is_ok()); } #[cfg(unix)] #[test] fn nul_bytes_in_path() { use std::os::unix::prelude::*; use std::ffi::OsStr; let nul_path = OsStr::from_bytes(b"foo\0"); let td = t!(TempDir::new("tar-rs")); let ar = Archive::new(Vec::<u8>::new()); let err = ar.append_dir(nul_path, td.path()).unwrap_err(); assert!(err.to_string().contains("contained a nul byte")); } } �����������������������������������������������������������������������������deps/tar-0.3.2/src/tests/���������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635521�013700� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/tar-0.3.2/src/tests/simple.tar�����������������������������������������������������������������0000664�0001750�0001750�00000024000�12361661670�014115� 0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������a���������������������������������������������������������������������������������������������������0000664�0001750�0001750�00000000000�12361661662�007666� 0����������������������������������������������������������������������������������������������������ustar �alex����������������������������alex�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������b���������������������������������������������������������������������������������������������������0000664�0001750�0001750�00000000000�12361661662�007667� 0����������������������������������������������������������������������������������������������������ustar �alex����������������������������alex�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������c���������������������������������������������������������������������������������������������������0000664�0001750�0001750�00000000000�12361661662�007670� 0����������������������������������������������������������������������������������������������������ustar �alex����������������������������alex�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/tar-0.3.2/src/tests/reading_files.tar����������������������������������������������������������0000664�0001750�0001750�00000024000�12361754511�015414� 0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������a���������������������������������������������������������������������������������������������������0000664�0001750�0001750�00000000026�12361754471�007677� 0����������������������������������������������������������������������������������������������������ustar �alex����������������������������alex�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������a a a a a a a a a a a ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������b���������������������������������������������������������������������������������������������������0000664�0001750�0001750�00000000026�12361754476�007705� 0����������������������������������������������������������������������������������������������������ustar �alex����������������������������alex�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������b b b b b b b b b b b ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/tar-0.3.2/src/tests/spaces.tar�����������������������������������������������������������������0000775�0001750�0001750�00000004000�12444710677�014107� 0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������a���������������������������������������������������������������������������������������������������100777 � 0 � 0 � 2 12440016664 4253 �0�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������a ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/tar-0.3.2/src/tests/duplicate_dirs.tar���������������������������������������������������������0000664�0001750�0001750�00000004000�12531110050�015571� 0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������some_dir/�������������������������������������������������������������������������������������������000755 �000766 �000024 �00000000000 12527333503 015306� 5����������������������������������������������������������������������������������������������������ustar�00cadencemarseille����������������staff���������������������������000000 �000000 ������������������������������������������������������������������������������������������������������������������������������������������������������������������������some_dir/�������������������������������������������������������������������������������������������000755 �000766 �000024 �00000000000 12527333503 015306� 5����������������������������������������������������������������������������������������������������ustar�00cadencemarseille����������������staff���������������������������000000 �000000 ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/tar-0.3.2/src/tests/directory.tar��������������������������������������������������������������0000664�0001750�0001750�00000024000�12444710677�014634� 0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������a/��������������������������������������������������������������������������������������������������0000755�0001750�0001750�00000000000�12440021574�010647� 5����������������������������������������������������������������������������������������������������ustar �mvdnes��������������������������mvdnes�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������a/b/������������������������������������������������������������������������������������������������0000755�0001750�0001750�00000000000�12440021525�011064� 5����������������������������������������������������������������������������������������������������ustar �mvdnes��������������������������mvdnes�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������a/c�������������������������������������������������������������������������������������������������0000644�0001750�0001750�00000000002�12440021631�010776� 0����������������������������������������������������������������������������������������������������ustar �mvdnes��������������������������mvdnes�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������c ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/tar-0.3.2/src/tests/empty_filename.tar���������������������������������������������������������0000664�0001750�0001750�00000001000�12524423330�015603� 0����������������������������������������������������������������������������������������������������ustar ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������������������������������0000755�0001750�0001750�00000000000�12440021574�010647� 5����������������������������������������������������������������������������������������������������ustar �mvd4253�������������������������0647� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/tar-0.3.2/src/tests/file_times.tar�������������������������������������������������������������0000664�0001750�0001750�00000003000�12556205227�014737� 0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������a���������������������������������������������������������������������������������������������������000644 �000765 �000024 �00000000000 07346545000 012100� 0����������������������������������������������������������������������������������������������������ustar�00HyeonKim������������������������staff���������������������������000000 �000000 ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/tar-0.3.2/appveyor.yml�������������������������������������������������������������������������0000664�0001750�0001750�00000001113�12610757225�012552� 0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������environment: matrix: - TARGET: x86_64-pc-windows-gnu MSYS_BITS: 64 - TARGET: i686-pc-windows-gnu MSYS_BITS: 32 - TARGET: x86_64-pc-windows-msvc - TARGET: i686-pc-windows-msvc install: - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin - if defined MSYS_BITS set PATH=%PATH%;C:\msys64\mingw%MSYS_BITS%\bin - rustc -V - cargo -V build: false test_script: - cargo test --verbose �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/tar-0.3.2/Cargo.toml���������������������������������������������������������������������������0000664�0001750�0001750�00000001370�12616471514�012117� 0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������[package] name = "tar" version = "0.3.2" authors = ["Alex Crichton <alex@alexcrichton.com>"] homepage = "https://github.com/alexcrichton/tar-rs" repository = "https://github.com/alexcrichton/tar-rs" documentation = "http://alexcrichton.com/tar-rs" license = "MIT/Apache-2.0" keywords = ["tar", "tarfile", "encoding"] readme = "README.md" description = """ A Rust implementation of a TAR file reader and writer. This library does not currently handle compression, but it is abstract over all I/O readers and writers. Additionally, great lengths are taken to ensure that the entire contents are never required to be entirely resident in memory all at once. """ [dependencies] libc = "0.2" filetime = "0.1.5" winapi = "0.2" [dev-dependencies] tempdir = "0.3" ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/env_logger-0.3.2/������������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635521�013310� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/env_logger-0.3.2/src/��������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635521�014077� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/env_logger-0.3.2/src/lib.rs��������������������������������������������������������������������0000664�0001750�0001750�00000050607�12616533511�013436� 0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! A logger configured via an environment variable which writes to standard //! error. //! //! ## Example //! //! ``` //! #[macro_use] extern crate log; //! extern crate env_logger; //! //! use log::LogLevel; //! //! fn main() { //! env_logger::init().unwrap(); //! //! debug!("this is a debug {}", "message"); //! error!("this is printed by default"); //! //! if log_enabled!(LogLevel::Info) { //! let x = 3 * 4; // expensive computation //! info!("the answer was: {}", x); //! } //! } //! ``` //! //! Assumes the binary is `main`: //! //! ```{.bash} //! $ RUST_LOG=error ./main //! ERROR:main: this is printed by default //! ``` //! //! ```{.bash} //! $ RUST_LOG=info ./main //! ERROR:main: this is printed by default //! INFO:main: the answer was: 12 //! ``` //! //! ```{.bash} //! $ RUST_LOG=debug ./main //! DEBUG:main: this is a debug message //! ERROR:main: this is printed by default //! INFO:main: the answer was: 12 //! ``` //! //! You can also set the log level on a per module basis: //! //! ```{.bash} //! $ RUST_LOG=main=info ./main //! ERROR:main: this is printed by default //! INFO:main: the answer was: 12 //! ``` //! //! And enable all logging: //! //! ```{.bash} //! $ RUST_LOG=main ./main //! DEBUG:main: this is a debug message //! ERROR:main: this is printed by default //! INFO:main: the answer was: 12 //! ``` //! //! See the documentation for the log crate for more information about its API. //! //! ## Enabling logging //! //! Log levels are controlled on a per-module basis, and by default all logging //! is disabled except for `error!`. Logging is controlled via the `RUST_LOG` //! environment variable. The value of this environment variable is a //! comma-separated list of logging directives. A logging directive is of the //! form: //! //! ```text //! path::to::module=log_level //! ``` //! //! The path to the module is rooted in the name of the crate it was compiled //! for, so if your program is contained in a file `hello.rs`, for example, to //! turn on logging for this file you would use a value of `RUST_LOG=hello`. //! Furthermore, this path is a prefix-search, so all modules nested in the //! specified module will also have logging enabled. //! //! The actual `log_level` is optional to specify. If omitted, all logging will //! be enabled. If specified, it must be one of the strings `debug`, `error`, //! `info`, `warn`, or `trace`. //! //! As the log level for a module is optional, the module to enable logging for //! is also optional. If only a `log_level` is provided, then the global log //! level for all modules is set to this value. //! //! Some examples of valid values of `RUST_LOG` are: //! //! * `hello` turns on all logging for the 'hello' module //! * `info` turns on all info logging //! * `hello=debug` turns on debug logging for 'hello' //! * `hello,std::option` turns on hello, and std's option logging //! * `error,hello=warn` turn on global error logging and also warn for hello //! //! ## Filtering results //! //! A RUST_LOG directive may include a regex filter. The syntax is to append `/` //! followed by a regex. Each message is checked against the regex, and is only //! logged if it matches. Note that the matching is done after formatting the //! log string but before adding any logging meta-data. There is a single filter //! for all modules. //! //! Some examples: //! //! * `hello/foo` turns on all logging for the 'hello' module where the log //! message includes 'foo'. //! * `info/f.o` turns on all info logging where the log message includes 'foo', //! 'f1o', 'fao', etc. //! * `hello=debug/foo*foo` turns on debug logging for 'hello' where the log //! message includes 'foofoo' or 'fofoo' or 'fooooooofoo', etc. //! * `error,hello=warn/[0-9] scopes` turn on global error logging and also //! warn for hello. In both cases the log message must include a single digit //! number followed by 'scopes'. #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/env_logger/")] #![cfg_attr(test, deny(warnings))] extern crate regex; extern crate log; use regex::Regex; use std::env; use std::io::prelude::*; use std::io; use std::mem; use log::{Log, LogLevel, LogLevelFilter, LogRecord, SetLoggerError, LogMetadata}; struct Logger { directives: Vec<LogDirective>, filter: Option<Regex>, format: Box<Fn(&LogRecord) -> String + Sync + Send>, } /// LogBuilder acts as builder for initializing the Logger. /// It can be used to customize the log format, change the enviromental variable used /// to provide the logging directives and also set the default log level filter. /// /// ## Example /// /// ``` /// #[macro_use] /// extern crate log; /// extern crate env_logger; /// /// use std::env; /// use log::{LogRecord, LogLevelFilter}; /// use env_logger::LogBuilder; /// /// fn main() { /// let format = |record: &LogRecord| { /// format!("{} - {}", record.level(), record.args()) /// }; /// /// let mut builder = LogBuilder::new(); /// builder.format(format).filter(None, LogLevelFilter::Info); /// /// if env::var("RUST_LOG").is_ok() { /// builder.parse(&env::var("RUST_LOG").unwrap()); /// } /// /// builder.init().unwrap(); /// /// error!("error message"); /// info!("info message"); /// } /// ``` pub struct LogBuilder { directives: Vec<LogDirective>, filter: Option<Regex>, format: Box<Fn(&LogRecord) -> String + Sync + Send>, } impl LogBuilder { /// Initializes the log builder with defaults pub fn new() -> LogBuilder { LogBuilder { directives: Vec::new(), filter: None, format: Box::new(|record: &LogRecord| { format!("{}:{}: {}", record.level(), record.location().module_path(), record.args()) }), } } /// Adds filters to the logger /// /// The given module (if any) will log at most the specified level provided. /// If no module is provided then the filter will apply to all log messages. pub fn filter(&mut self, module: Option<&str>, level: LogLevelFilter) -> &mut Self { self.directives.push(LogDirective { name: module.map(|s| s.to_string()), level: level, }); self } /// Sets the format function for formatting the log output. /// /// This function is called on each record logged to produce a string which /// is actually printed out. pub fn format<F: 'static>(&mut self, format: F) -> &mut Self where F: Fn(&LogRecord) -> String + Sync + Send { self.format = Box::new(format); self } /// Parses the directives string in the same form as the RUST_LOG /// environment variable. /// /// See the module documentation for more details. pub fn parse(&mut self, filters: &str) -> &mut Self { let (directives, filter) = parse_logging_spec(filters); self.filter = filter; for directive in directives { self.directives.push(directive); } self } /// Initializes the global logger with an env logger. /// /// This should be called early in the execution of a Rust program, and the /// global logger may only be initialized once. Future initialization /// attempts will return an error. pub fn init(&mut self) -> Result<(), SetLoggerError> { if self.directives.is_empty() { // Adds the default filter if none exist self.directives.push(LogDirective { name: None, level: LogLevelFilter::Error, }); } else { // Sort the directives by length of their name, this allows a // little more efficient lookup at runtime. self.directives.sort_by(|a, b| { let alen = a.name.as_ref().map(|a| a.len()).unwrap_or(0); let blen = b.name.as_ref().map(|b| b.len()).unwrap_or(0); alen.cmp(&blen) }); } log::set_logger(|max_level| { let level = { let max = self.directives.iter().map(|d| d.level).max(); max.unwrap_or(LogLevelFilter::Off) }; max_level.set(level); Box::new(self.build()) }) } fn build(&mut self) -> Logger { Logger { directives: mem::replace(&mut self.directives, Vec::new()), filter: mem::replace(&mut self.filter, None), format: mem::replace(&mut self.format, Box::new(|_| String::new())), } } } impl Logger { fn enabled(&self, level: LogLevel, target: &str) -> bool { // Search for the longest match, the vector is assumed to be pre-sorted. for directive in self.directives.iter().rev() { match directive.name { Some(ref name) if !target.starts_with(&**name) => {}, Some(..) | None => { return level <= directive.level } } } false } } impl Log for Logger { fn enabled(&self, metadata: &LogMetadata) -> bool { self.enabled(metadata.level(), metadata.target()) } fn log(&self, record: &LogRecord) { if !Log::enabled(self, record.metadata()) { return; } if let Some(filter) = self.filter.as_ref() { if filter.is_match(&*record.args().to_string()) { return; } } let _ = writeln!(&mut io::stderr(), "{}", (self.format)(record)); } } struct LogDirective { name: Option<String>, level: LogLevelFilter, } /// Initializes the global logger with an env logger. /// /// This should be called early in the execution of a Rust program, and the /// global logger may only be initialized once. Future initialization attempts /// will return an error. pub fn init() -> Result<(), SetLoggerError> { let mut builder = LogBuilder::new(); if let Ok(s) = env::var("RUST_LOG") { builder.parse(&s); } builder.init() } /// Parse a logging specification string (e.g: "crate1,crate2::mod3,crate3::x=error/foo") /// and return a vector with log directives. fn parse_logging_spec(spec: &str) -> (Vec<LogDirective>, Option<Regex>) { let mut dirs = Vec::new(); let mut parts = spec.split('/'); let mods = parts.next(); let filter = parts.next(); if parts.next().is_some() { println!("warning: invalid logging spec '{}', \ ignoring it (too many '/'s)", spec); return (dirs, None); } mods.map(|m| { for s in m.split(',') { if s.len() == 0 { continue } let mut parts = s.split('='); let (log_level, name) = match (parts.next(), parts.next().map(|s| s.trim()), parts.next()) { (Some(part0), None, None) => { // if the single argument is a log-level string or number, // treat that as a global fallback match part0.parse() { Ok(num) => (num, None), Err(_) => (LogLevelFilter::max(), Some(part0)), } } (Some(part0), Some(""), None) => (LogLevelFilter::max(), Some(part0)), (Some(part0), Some(part1), None) => { match part1.parse() { Ok(num) => (num, Some(part0)), _ => { println!("warning: invalid logging spec '{}', \ ignoring it", part1); continue } } }, _ => { println!("warning: invalid logging spec '{}', \ ignoring it", s); continue } }; dirs.push(LogDirective { name: name.map(|s| s.to_string()), level: log_level, }); }}); let filter = filter.map_or(None, |filter| { match Regex::new(filter) { Ok(re) => Some(re), Err(e) => { println!("warning: invalid regex filter - {}", e); None } } }); return (dirs, filter); } #[cfg(test)] mod tests { use log::{Log, LogLevel, LogLevelFilter}; use super::{LogBuilder, Logger, LogDirective, parse_logging_spec}; fn make_logger(dirs: Vec<LogDirective>) -> Logger { let mut logger = LogBuilder::new().build(); logger.directives = dirs; logger } #[test] fn filter_info() { let logger = LogBuilder::new().filter(None, LogLevelFilter::Info).build(); assert!(logger.enabled(LogLevel::Info, "crate1")); assert!(!logger.enabled(LogLevel::Debug, "crate1")); } #[test] fn filter_beginning_longest_match() { let logger = LogBuilder::new() .filter(Some("crate2"), LogLevelFilter::Info) .filter(Some("crate2::mod"), LogLevelFilter::Debug) .filter(Some("crate1::mod1"), LogLevelFilter::Warn) .build(); assert!(logger.enabled(LogLevel::Debug, "crate2::mod1")); assert!(!logger.enabled(LogLevel::Debug, "crate2")); } #[test] fn parse_default() { let logger = LogBuilder::new().parse("info,crate1::mod1=warn").build(); assert!(logger.enabled(LogLevel::Warn, "crate1::mod1")); assert!(logger.enabled(LogLevel::Info, "crate2::mod2")); } #[test] fn match_full_path() { let logger = make_logger(vec![ LogDirective { name: Some("crate2".to_string()), level: LogLevelFilter::Info }, LogDirective { name: Some("crate1::mod1".to_string()), level: LogLevelFilter::Warn } ]); assert!(logger.enabled(LogLevel::Warn, "crate1::mod1")); assert!(!logger.enabled(LogLevel::Info, "crate1::mod1")); assert!(logger.enabled(LogLevel::Info, "crate2")); assert!(!logger.enabled(LogLevel::Debug, "crate2")); } #[test] fn no_match() { let logger = make_logger(vec![ LogDirective { name: Some("crate2".to_string()), level: LogLevelFilter::Info }, LogDirective { name: Some("crate1::mod1".to_string()), level: LogLevelFilter::Warn } ]); assert!(!logger.enabled(LogLevel::Warn, "crate3")); } #[test] fn match_beginning() { let logger = make_logger(vec![ LogDirective { name: Some("crate2".to_string()), level: LogLevelFilter::Info }, LogDirective { name: Some("crate1::mod1".to_string()), level: LogLevelFilter::Warn } ]); assert!(logger.enabled(LogLevel::Info, "crate2::mod1")); } #[test] fn match_beginning_longest_match() { let logger = make_logger(vec![ LogDirective { name: Some("crate2".to_string()), level: LogLevelFilter::Info }, LogDirective { name: Some("crate2::mod".to_string()), level: LogLevelFilter::Debug }, LogDirective { name: Some("crate1::mod1".to_string()), level: LogLevelFilter::Warn } ]); assert!(logger.enabled(LogLevel::Debug, "crate2::mod1")); assert!(!logger.enabled(LogLevel::Debug, "crate2")); } #[test] fn match_default() { let logger = make_logger(vec![ LogDirective { name: None, level: LogLevelFilter::Info }, LogDirective { name: Some("crate1::mod1".to_string()), level: LogLevelFilter::Warn } ]); assert!(logger.enabled(LogLevel::Warn, "crate1::mod1")); assert!(logger.enabled(LogLevel::Info, "crate2::mod2")); } #[test] fn zero_level() { let logger = make_logger(vec![ LogDirective { name: None, level: LogLevelFilter::Info }, LogDirective { name: Some("crate1::mod1".to_string()), level: LogLevelFilter::Off } ]); assert!(!logger.enabled(LogLevel::Error, "crate1::mod1")); assert!(logger.enabled(LogLevel::Info, "crate2::mod2")); } #[test] fn parse_logging_spec_valid() { let (dirs, filter) = parse_logging_spec("crate1::mod1=error,crate1::mod2,crate2=debug"); assert_eq!(dirs.len(), 3); assert_eq!(dirs[0].name, Some("crate1::mod1".to_string())); assert_eq!(dirs[0].level, LogLevelFilter::Error); assert_eq!(dirs[1].name, Some("crate1::mod2".to_string())); assert_eq!(dirs[1].level, LogLevelFilter::max()); assert_eq!(dirs[2].name, Some("crate2".to_string())); assert_eq!(dirs[2].level, LogLevelFilter::Debug); assert!(filter.is_none()); } #[test] fn parse_logging_spec_invalid_crate() { // test parse_logging_spec with multiple = in specification let (dirs, filter) = parse_logging_spec("crate1::mod1=warn=info,crate2=debug"); assert_eq!(dirs.len(), 1); assert_eq!(dirs[0].name, Some("crate2".to_string())); assert_eq!(dirs[0].level, LogLevelFilter::Debug); assert!(filter.is_none()); } #[test] fn parse_logging_spec_invalid_log_level() { // test parse_logging_spec with 'noNumber' as log level let (dirs, filter) = parse_logging_spec("crate1::mod1=noNumber,crate2=debug"); assert_eq!(dirs.len(), 1); assert_eq!(dirs[0].name, Some("crate2".to_string())); assert_eq!(dirs[0].level, LogLevelFilter::Debug); assert!(filter.is_none()); } #[test] fn parse_logging_spec_string_log_level() { // test parse_logging_spec with 'warn' as log level let (dirs, filter) = parse_logging_spec("crate1::mod1=wrong,crate2=warn"); assert_eq!(dirs.len(), 1); assert_eq!(dirs[0].name, Some("crate2".to_string())); assert_eq!(dirs[0].level, LogLevelFilter::Warn); assert!(filter.is_none()); } #[test] fn parse_logging_spec_empty_log_level() { // test parse_logging_spec with '' as log level let (dirs, filter) = parse_logging_spec("crate1::mod1=wrong,crate2="); assert_eq!(dirs.len(), 1); assert_eq!(dirs[0].name, Some("crate2".to_string())); assert_eq!(dirs[0].level, LogLevelFilter::max()); assert!(filter.is_none()); } #[test] fn parse_logging_spec_global() { // test parse_logging_spec with no crate let (dirs, filter) = parse_logging_spec("warn,crate2=debug"); assert_eq!(dirs.len(), 2); assert_eq!(dirs[0].name, None); assert_eq!(dirs[0].level, LogLevelFilter::Warn); assert_eq!(dirs[1].name, Some("crate2".to_string())); assert_eq!(dirs[1].level, LogLevelFilter::Debug); assert!(filter.is_none()); } #[test] fn parse_logging_spec_valid_filter() { let (dirs, filter) = parse_logging_spec("crate1::mod1=error,crate1::mod2,crate2=debug/abc"); assert_eq!(dirs.len(), 3); assert_eq!(dirs[0].name, Some("crate1::mod1".to_string())); assert_eq!(dirs[0].level, LogLevelFilter::Error); assert_eq!(dirs[1].name, Some("crate1::mod2".to_string())); assert_eq!(dirs[1].level, LogLevelFilter::max()); assert_eq!(dirs[2].name, Some("crate2".to_string())); assert_eq!(dirs[2].level, LogLevelFilter::Debug); assert!(filter.is_some() && filter.unwrap().to_string() == "abc"); } #[test] fn parse_logging_spec_invalid_crate_filter() { let (dirs, filter) = parse_logging_spec("crate1::mod1=error=warn,crate2=debug/a.c"); assert_eq!(dirs.len(), 1); assert_eq!(dirs[0].name, Some("crate2".to_string())); assert_eq!(dirs[0].level, LogLevelFilter::Debug); assert!(filter.is_some() && filter.unwrap().to_string() == "a.c"); } #[test] fn parse_logging_spec_empty_with_filter() { let (dirs, filter) = parse_logging_spec("crate1/a*c"); assert_eq!(dirs.len(), 1); assert_eq!(dirs[0].name, Some("crate1".to_string())); assert_eq!(dirs[0].level, LogLevelFilter::max()); assert!(filter.is_some() && filter.unwrap().to_string() == "a*c"); } } �������������������������������������������������������������������������������������������������������������������������deps/env_logger-0.3.2/Cargo.toml��������������������������������������������������������������������0000664�0001750�0001750�00000000706�12616533542�013462� 0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������[package] name = "env_logger" version = "0.3.2" authors = ["The Rust Project Developers"] license = "MIT/Apache-2.0" repository = "https://github.com/rust-lang/log" documentation = "http://doc.rust-lang.org/log/env_logger" homepage = "https://github.com/rust-lang/log" description = """ An logging implementation for `log` which is configured via an environment variable. """ [dependencies.log] version = "0.3" path = ".." [dependencies] regex = "0.1" ����������������������������������������������������������deps/strsim-0.3.0/����������������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635521�012500� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/strsim-0.3.0/.travis.yml�����������������������������������������������������������������������0000644�0000000�0000000�00000000057�12520330754�014600� 0����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������language: rust rust: - nightly - beta ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/strsim-0.3.0/README.md�������������������������������������������������������������������������0000644�0000000�0000000�00000002672�12520330364�013750� 0����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# strsim-rs [![Build Status](https://travis-ci.org/dguo/strsim-rs.svg?branch=master)](https://travis-ci.org/dguo/strsim-rs) Rust implementations of [string similarity metrics]. Should compile cleanly on both the nightly and beta versions of Rust. Includes: - [Hamming] - [Levenshtein] and [Damerau-Levenshtein] - [Jaro and Jaro-Winkler] - this implementation of Jaro-Winkler does not limit the common prefix length ### Installation ```toml # Cargo.toml [dependencies] strsim = "0.3.0" ``` ### Usage ```rust extern crate strsim; use strsim::{hamming, levenshtein, damerau_levenshtein, jaro, jaro_winkler}; fn main() { match hamming("hamming", "hammers") { Ok(distance) => assert_eq!(3, distance), Err(why) => panic!("{:?}", why) } assert_eq!(3, levenshtein("kitten", "sitting")); assert_eq!(1, damerau_levenshtein("specter", "spectre")); assert!((0.392 - jaro("Friedrich Nietzsche", "Jean-Paul Sartre")).abs() < 0.001); assert!((0.911 - jaro_winkler("cheeseburger", "cheese fries")).abs() < 0.001); } ``` ### License MIT [string similarity metrics]:http://en.wikipedia.org/wiki/String_metric [Damerau-Levenshtein]:http://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance [Jaro and Jaro-Winkler]:http://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance [Levenshtein]:http://en.wikipedia.org/wiki/Levenshtein_distance [Hamming]:http://en.wikipedia.org/wiki/Hamming_distance ����������������������������������������������������������������������deps/strsim-0.3.0/.gitignore������������������������������������������������������������������������0000644�0000000�0000000�00000000024�12511653610�014450� 0����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/target /Cargo.lock ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/strsim-0.3.0/LICENSE���������������������������������������������������������������������������0000644�0000000�0000000�00000002065�12511653610�013474� 0����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������The MIT License (MIT) Copyright (c) 2015 Danny Guo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/strsim-0.3.0/src/������������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635521�013267� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/strsim-0.3.0/src/lib.rs������������������������������������������������������������������������0000644�0000000�0000000�00000030646�12520331452�014375� 0����������������������������������������������������������������������������������������������������ustar �root����������������������������root������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� //! This library implements string similarity metrics. Currently includes //! Hamming, Levenshtein, Jaro, and Jaro-Winkler. use std::char; use std::cmp::{max, min}; #[derive(Debug, PartialEq)] pub enum StrSimError { DifferentLengthArgs } pub type HammingResult = Result<usize, StrSimError>; /// Calculates the number of positions in the two strings where the characters /// differ. Returns an error if the strings have different lengths. /// /// ``` /// use strsim::hamming; /// /// match hamming("hamming", "hammers") { /// Ok(distance) => assert_eq!(3, distance), /// Err(why) => panic!("{:?}", why) /// } /// ``` pub fn hamming(a: &str, b: &str) -> HammingResult { if a.len() != b.len() { Err(StrSimError::DifferentLengthArgs) } else { Ok(a.chars() .zip(b.chars()) .filter(|&(a_char, b_char)| a_char != b_char) .count()) } } /// Calculates the Jaro similarity between two strings. The returned value /// is between 0.0 and 1.0 (higher value means more similar). /// /// ``` /// use strsim::jaro; /// /// assert!((0.392 - jaro("Friedrich Nietzsche", "Jean-Paul Sartre")).abs() < /// 0.001); /// ``` pub fn jaro(a: &str, b: &str) -> f64 { if a == b { return 1.0; } if a.len() == 0 || b.len() == 0 { return 0.0; } let search_range = max(0, (max(a.len(), b.len()) / 2) - 1); let mut b_consumed = Vec::with_capacity(b.len()); for _ in 0..b.len() { b_consumed.push(false); } let mut matches = 0.0; let mut transpositions = 0.0; let mut b_match_index = 0; for (i, a_char) in a.chars().enumerate() { let min_bound = // prevent integer wrapping if i > search_range { max(0, i - search_range) } else { 0 }; let max_bound = min(b.len() - 1, i + search_range); if min_bound > max_bound { continue; } for (j, b_char) in b.chars().enumerate() { if min_bound <= j && j <= max_bound { if a_char == b_char && !b_consumed[j] { b_consumed[j] = true; matches += 1.0; if j < b_match_index { transpositions += 1.0; } b_match_index = j; break; } } } } if matches == 0.0 { 0.0 } else { (1.0 / 3.0) * ((matches / a.len() as f64) + (matches / b.len() as f64) + ((matches - transpositions) / matches)) } } /// Like Jaro but gives a boost to strings that have a common prefix. /// /// ``` /// use strsim::jaro_winkler; /// /// assert!((0.911 - jaro_winkler("cheeseburger", "cheese fries")).abs() < /// 0.001); /// ``` pub fn jaro_winkler(a: &str, b: &str) -> f64 { let jaro_distance = jaro(a, b); // Don't limit the length of the common prefix let prefix_length = a.chars() .zip(b.chars()) .take_while(|&(a_char, b_char)| a_char == b_char) .count(); let jaro_winkler_distance = jaro_distance + (0.1 * prefix_length as f64 * (1.0 - jaro_distance)); if jaro_winkler_distance <= 1.0 { jaro_winkler_distance } else { 1.0 } } /// Calculates the minimum number of insertions, deletions, and substitutions /// required to change one string into the other. /// /// ``` /// use strsim::levenshtein; /// /// assert_eq!(3, levenshtein("kitten", "sitting")); /// ``` pub fn levenshtein(a: &str, b: &str) -> usize { if a == b { return 0; } else if a.len() == 0 { return b.len(); } else if b.len() == 0 { return a.len(); } let mut prev_distances: Vec<usize> = Vec::with_capacity(b.len() + 1); let mut curr_distances: Vec<usize> = Vec::with_capacity(b.len() + 1); for i in 0..(b.len() + 1) { prev_distances.push(i); curr_distances.push(0); } for (i, a_char) in a.chars().enumerate() { curr_distances[0] = i + 1; for (j, b_char) in b.chars().enumerate() { let cost = if a_char == b_char { 0 } else { 1 }; curr_distances[j + 1] = min(curr_distances[j] + 1, min(prev_distances[j + 1] + 1, prev_distances[j] + cost)); } prev_distances.clone_from(&curr_distances); } curr_distances[b.len()] } /// Same as Levenshtein but allows for adjacent transpositions. /// /// ``` /// use strsim::damerau_levenshtein; /// /// assert_eq!(3, damerau_levenshtein("damerau", "aderua")); /// ``` pub fn damerau_levenshtein(a: &str, b: &str) -> usize { if a == b { return 0; } else if a.len() == 0 { return b.len(); } else if b.len() == 0 { return a.len(); } let mut prev_two_distances: Vec<usize> = Vec::with_capacity(b.len() + 1); let mut prev_distances: Vec<usize> = Vec::with_capacity(b.len() + 1); let mut curr_distances: Vec<usize> = Vec::with_capacity(b.len() + 1); let mut prev_a_char = char::MAX; let mut prev_b_char = char::MAX; for i in 0..(b.len() + 1) { prev_two_distances.push(i); prev_distances.push(i); curr_distances.push(0); } for (i, a_char) in a.chars().enumerate() { curr_distances[0] = i + 1; for (j, b_char) in b.chars().enumerate() { let cost = if a_char == b_char { 0 } else { 1 }; curr_distances[j + 1] = min(curr_distances[j] + 1, min(prev_distances[j + 1] + 1, prev_distances[j] + cost)); if i > 0 && j > 0 && a_char != b_char && a_char == prev_b_char && b_char == prev_a_char { curr_distances[j + 1] = min(curr_distances[j + 1], prev_two_distances[j - 1] + 1); } prev_b_char = b_char; } prev_two_distances.clone_from(&prev_distances); prev_distances.clone_from(&curr_distances); prev_a_char = a_char; } curr_distances[b.len()] } #[cfg(test)] mod tests { use super::*; // use test::Bencher; #[test] fn hamming_empty() { match hamming("", "") { Ok(distance) => { assert_eq!(0, distance); }, Err(why) => { panic!("{:?}", why); } } } #[test] fn hamming_same() { match hamming("hamming", "hamming") { Ok(distance) => { assert_eq!(0, distance); }, Err(why) => { panic!("{:?}", why); } } } #[test] fn hamming_diff() { match hamming("hamming", "hammers") { Ok(distance) => { assert_eq!(3, distance); }, Err(why) => { panic!("{:?}", why); } } } #[test] fn hamming_unequal_length() { match hamming("ham", "hamming") { Ok(_) => { panic!(); }, Err(why) => { assert_eq!(why, StrSimError::DifferentLengthArgs); } } } #[test] fn hamming_names() { match hamming("Friedrich Nietzs", "Jean-Paul Sartre") { Ok(distance) => { assert_eq!(14, distance); }, Err(why) => { panic!("{:?}", why); } } } #[test] fn jaro_both_empty() { assert_eq!(1.0, jaro("", "")); } #[test] fn jaro_first_empty() { assert_eq!(0.0, jaro("", "jaro")); } #[test] fn jaro_second_empty() { assert_eq!(0.0, jaro("distance", "")); } #[test] fn jaro_same() { assert_eq!(1.0, jaro("jaro", "jaro")); } #[test] fn jaro_diff_short() { assert!((0.767 - jaro("dixon", "dicksonx")).abs() < 0.001); } #[test] fn jaro_diff_no_transposition() { assert!((0.822 - jaro("dwayne", "duane")).abs() < 0.001); } #[test] fn jaro_diff_with_transposition() { assert!((0.944 - jaro("martha", "marhta")).abs() < 0.001); } #[test] fn jaro_names() { assert!((0.392 - jaro("Friedrich Nietzsche", "Jean-Paul Sartre")).abs() < 0.001); } #[test] fn jaro_winkler_both_empty() { assert_eq!(1.0, jaro_winkler("", "")); } #[test] fn jaro_winkler_first_empty() { assert_eq!(0.0, jaro_winkler("", "jaro-winkler")); } #[test] fn jaro_winkler_second_empty() { assert_eq!(0.0, jaro_winkler("distance", "")); } #[test] fn jaro_winkler_same() { assert_eq!(1.0, jaro_winkler("Jaro-Winkler", "Jaro-Winkler")); } #[test] fn jaro_winkler_diff_short() { assert!((0.813 - jaro_winkler("dixon", "dicksonx")).abs() < 0.001); assert!((0.813 - jaro_winkler("dicksonx", "dixon")).abs() < 0.001); } #[test] fn jaro_winkler_diff_no_transposition() { assert!((0.840 - jaro_winkler("dwayne", "duane")).abs() < 0.001); } #[test] fn jaro_winkler_diff_with_transposition() { assert!((0.961 - jaro_winkler("martha", "marhta")).abs() < 0.001); } #[test] fn jaro_winkler_names() { assert!((0.562 - jaro_winkler("Friedrich Nietzsche", "Fran-Paul Sartre")).abs() < 0.001); } #[test] fn jaro_winkler_long_prefix() { assert!((0.911 - jaro_winkler("cheeseburger", "cheese fries")).abs() < 0.001); } #[test] fn jaro_winkler_more_names() { assert!((0.868 - jaro_winkler("Thorkel", "Thorgier")).abs() < 0.001); } #[test] fn jaro_winkler_length_of_one() { assert!((0.738 - jaro_winkler("Dinsdale", "D")).abs() < 0.001); } #[test] fn jaro_winkler_very_long_prefix() { assert!((1.0 - jaro_winkler("thequickbrownfoxjumpedoverx", "thequickbrownfoxjumpedovery")).abs() < 0.001); } #[test] fn levenshtein_empty() { assert_eq!(0, levenshtein("", "")); } #[test] fn levenshtein_same() { assert_eq!(0, levenshtein("levenshtein", "levenshtein")); } #[test] fn levenshtein_diff_short() { assert_eq!(3, levenshtein("kitten", "sitting")); } #[test] fn levenshtein_diff_with_space() { assert_eq!(5, levenshtein("hello, world", "bye, world")); } #[test] fn levenshtein_diff_longer() { let a = "The quick brown fox jumped over the angry dog."; let b = "Lorem ipsum dolor sit amet, dicta latine an eam."; assert_eq!(37, levenshtein(a, b)); } #[test] fn levenshtein_first_empty() { assert_eq!(7, levenshtein("", "sitting")); } #[test] fn levenshtein_second_empty() { assert_eq!(6, levenshtein("kitten", "")); } #[test] fn damerau_levenshtein_empty() { assert_eq!(0, damerau_levenshtein("", "")); } #[test] fn damerau_levenshtein_same() { assert_eq!(0, damerau_levenshtein("damerau", "damerau")); } #[test] fn damerau_levenshtein_first_empty() { assert_eq!(7, damerau_levenshtein("", "damerau")); } #[test] fn damerau_levenshtein_second_empty() { assert_eq!(7, damerau_levenshtein("damerau", "")); } #[test] fn damerau_levenshtein_diff_short() { assert_eq!(3, damerau_levenshtein("damerau", "aderua")); } #[test] fn damerau_levenshtein_diff_reversed() { assert_eq!(3, damerau_levenshtein("aderua", "damerau")); } #[test] fn damerau_levenshtein_diff_unequal_length() { assert_eq!(6, damerau_levenshtein("damerau", "aderuaxyz")); } #[test] fn damerau_levenshtein_diff_unequal_length_reversed() { assert_eq!(6, damerau_levenshtein("aderuaxyz", "damerau")); } #[test] fn damerau_levenshtein_diff_comedians() { assert_eq!(5, damerau_levenshtein("Stewart", "Colbert")); } #[test] fn damerau_levenshtein_many_transpositions() { assert_eq!(4, damerau_levenshtein("abcdefghijkl", "bacedfgihjlk")); } #[test] fn damerau_levenshtein_diff_longer() { let a = "The quick brown fox jumped over the angry dog."; let b = "Lehem ipsum dolor sit amet, dicta latine an eam."; assert_eq!(36, damerau_levenshtein(a, b)); } #[test] fn damerau_levenshtein_beginning_transposition() { assert_eq!(1, damerau_levenshtein("foobar", "ofobar")); } #[test] fn damerau_levenshtein_end_transposition() { assert_eq!(1, damerau_levenshtein("specter", "spectre")); } } ������������������������������������������������������������������������������������������deps/strsim-0.3.0/tests/����������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635521�013642� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/strsim-0.3.0/tests/lib.rs����������������������������������������������������������������������0000644�0000000�0000000�00000001321�12511653610�014737� 0����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������extern crate strsim; use strsim::{hamming, levenshtein, damerau_levenshtein, jaro, jaro_winkler}; #[test] fn hamming_works() { match hamming("hamming", "hammers") { Ok(distance) => assert_eq!(3, distance), Err(why) => panic!("{:?}", why) } } #[test] fn levenshtein_works() { assert_eq!(3, levenshtein("kitten", "sitting")); } #[test] fn damerau_levenshtein_works() { assert_eq!(3, damerau_levenshtein("damerau", "aderua")); } #[test] fn jaro_works() { assert!((0.392 - jaro("Friedrich Nietzsche", "Jean-Paul Sartre")).abs() < 0.001); } #[test] fn jaro_winkler_works() { assert!((0.911 - jaro_winkler("cheeseburger", "cheese fries")).abs() < 0.001); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/strsim-0.3.0/Cargo.toml������������������������������������������������������������������������0000644�0000000�0000000�00000000703�12520327573�014422� 0����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������[package] name = "strsim" version = "0.3.0" authors = ["Danny Guo <dannyguo91@gmail.com>"] description = """ Implementations of string similarity metrics. Includes Hamming, Levenshtein, Damerau-Levenshtein, Jaro, and Jaro-Winkler. """ license = "MIT" readme = "README.md" keywords = ["string", "similarity", "Hamming", "Levenshtein", "Jaro"] homepage = "https://github.com/dguo/strsim-rs" repository = "https://github.com/dguo/strsim-rs" �������������������������������������������������������������deps/openssl-sys-0.7.4/�����������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635520�013465� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/openssl-sys-0.7.4/LICENSE-MIT������������������������������������������������������������������0000644�0000765�0000024�00000002041�12635176400�014711� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������dialout����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Copyright (c) 2014 Alex Crichton Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/openssl-sys-0.7.4/src/�������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635520�014254� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/openssl-sys-0.7.4/src/probe.rs�����������������������������������������������������������������0000644�0000765�0000024�00000004060�12635176400�015524� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������dialout����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������use std::env; use std::fs; use std::path::PathBuf; pub struct ProbeResult { pub cert_file: Option<PathBuf>, pub cert_dir: Option<PathBuf>, } /// Probe the system for the directory in which CA certificates should likely be /// found. /// /// This will only search known system locations. pub fn find_certs_dirs() -> Vec<PathBuf> { // see http://gagravarr.org/writing/openssl-certs/others.shtml [ "/var/ssl", "/usr/share/ssl", "/usr/local/ssl", "/usr/local/openssl", "/usr/local/share", "/usr/lib/ssl", "/usr/ssl", "/etc/openssl", "/etc/pki/tls", "/etc/ssl", ].iter().map(|s| PathBuf::from(*s)).filter(|p| { fs::metadata(p).is_ok() }).collect() } pub fn init_ssl_cert_env_vars() { let ProbeResult { cert_file, cert_dir } = probe(); match cert_file { Some(path) => put("SSL_CERT_FILE", path), None => {} } match cert_dir { Some(path) => put("SSL_CERT_DIR", path), None => {} } fn put(var: &str, path: PathBuf) { // Don't stomp over what anyone else has set match env::var(var) { Ok(..) => {} Err(..) => env::set_var(var, &path), } } } pub fn probe() -> ProbeResult { let mut result = ProbeResult { cert_file: env::var_os("SSL_CERT_FILE").map(PathBuf::from), cert_dir: env::var_os("SSL_CERT_DIR").map(PathBuf::from), }; for certs_dir in find_certs_dirs().iter() { // cert.pem looks to be an openssl 1.0.1 thing, while // certs/ca-certificates.crt appears to be a 0.9.8 thing for cert in [ "cert.pem", "certs.pem", "certs/ca-certificates.crt", "certs/ca-root-nss.crt" ].iter() { try(&mut result.cert_file, certs_dir.join(cert)); } try(&mut result.cert_dir, certs_dir.join("certs")); } result } fn try(dst: &mut Option<PathBuf>, val: PathBuf) { if dst.is_none() && fs::metadata(&val).is_ok() { *dst = Some(val); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/openssl-sys-0.7.4/src/lib.rs�������������������������������������������������������������������0000644�0000765�0000024�00000102036�12635176400�015165� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������dialout����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] #![allow(dead_code)] #![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.7.4")] extern crate libc; #[cfg(target_os = "nacl")] extern crate libressl_pnacl_sys; use libc::{c_void, c_int, c_char, c_ulong, c_long, c_uint, c_uchar, size_t}; use std::mem; use std::sync::{Mutex, MutexGuard}; use std::sync::{Once, ONCE_INIT}; pub type ASN1_INTEGER = c_void; pub type ASN1_STRING = c_void; pub type ASN1_TIME = c_void; pub type BN_CTX = c_void; pub type COMP_METHOD = c_void; pub type DH = c_void; pub type ENGINE = c_void; pub type EVP_CIPHER = c_void; pub type EVP_CIPHER_CTX = c_void; pub type EVP_MD = c_void; pub type EVP_PKEY = c_void; pub type EVP_PKEY_CTX = c_void; pub type RSA = c_void; pub type SSL = c_void; pub type SSL_CTX = c_void; pub type SSL_METHOD = c_void; pub type X509 = c_void; pub type X509_CRL = c_void; pub type X509_EXTENSION = c_void; pub type X509_NAME = c_void; pub type X509_NAME_ENTRY = c_void; pub type X509_REQ = c_void; pub type X509_STORE_CTX = c_void; pub type stack_st_X509_EXTENSION = c_void; pub type stack_st_void = c_void; pub type bio_st = c_void; pub type bio_info_cb = Option<unsafe extern "C" fn(*mut BIO, c_int, *const c_char, c_int, c_long, c_long)>; #[repr(C)] #[derive(Copy, Clone)] #[allow(raw_pointer_derive)] pub struct BIO_METHOD { pub type_: c_int, pub name: *const c_char, pub bwrite: Option<unsafe extern "C" fn(*mut BIO, *const c_char, c_int) -> c_int>, pub bread: Option<unsafe extern "C" fn(*mut BIO, *mut c_char, c_int) -> c_int>, pub bputs: Option<unsafe extern "C" fn(*mut BIO, *const c_char) -> c_int>, pub bgets: Option<unsafe extern "C" fn(*mut BIO, *mut c_char, c_int) -> c_int>, pub ctrl: Option<unsafe extern "C" fn(*mut BIO, c_int, c_long, *mut c_void) -> c_long>, pub create: Option<unsafe extern "C" fn(*mut BIO) -> c_int>, pub destroy: Option<unsafe extern "C" fn(*mut BIO) -> c_int>, pub callback_ctrl: Option<unsafe extern "C" fn(*mut BIO, c_int, bio_info_cb) -> c_long>, } // so we can create static BIO_METHODs unsafe impl Sync for BIO_METHOD {} #[repr(C)] pub struct BIO { pub method: *mut BIO_METHOD, pub callback: Option<unsafe extern "C" fn(*mut BIO, c_int, *const c_char, c_int, c_long, c_long) -> c_long>, pub cb_arg: *mut c_char, pub init: c_int, pub shutdown: c_int, pub flags: c_int, pub retry_reason: c_int, pub num: c_int, pub ptr: *mut c_void, pub next_bio: *mut BIO, pub prev_bio: *mut BIO, pub references: c_int, pub num_read: c_ulong, pub num_write: c_ulong, pub ex_data: CRYPTO_EX_DATA, } #[repr(C)] pub struct CRYPTO_EX_DATA { pub sk: *mut stack_st_void, pub dummy: c_int, } #[repr(C)] pub struct EVP_MD_CTX { digest: *mut EVP_MD, engine: *mut c_void, flags: c_ulong, md_data: *mut c_void, pctx: *mut EVP_PKEY_CTX, update: *mut c_void } impl Copy for EVP_MD_CTX {} impl Clone for EVP_MD_CTX { fn clone(&self) -> EVP_MD_CTX { *self } } #[repr(C)] pub struct HMAC_CTX { md: *mut EVP_MD, md_ctx: EVP_MD_CTX, i_ctx: EVP_MD_CTX, o_ctx: EVP_MD_CTX, key_length: c_uint, key: [c_uchar; 128] } impl Copy for HMAC_CTX {} impl Clone for HMAC_CTX { fn clone(&self) -> HMAC_CTX { *self } } #[repr(C)] pub struct X509V3_CTX { flags: c_int, issuer_cert: *mut c_void, subject_cert: *mut c_void, subject_req: *mut c_void, crl: *mut c_void, db_meth: *mut c_void, db: *mut c_void, // I like the last comment line, it is copied from OpenSSL sources: // Maybe more here } impl Copy for X509V3_CTX {} impl Clone for X509V3_CTX { fn clone(&self) -> X509V3_CTX { *self } } #[repr(C)] pub struct BIGNUM { pub d: *mut c_void, pub top: c_int, pub dmax: c_int, pub neg: c_int, pub flags: c_int, } impl Copy for BIGNUM {} impl Clone for BIGNUM { fn clone(&self) -> BIGNUM { *self } } pub type CRYPTO_EX_new = extern "C" fn(parent: *mut c_void, ptr: *mut c_void, ad: *const CRYPTO_EX_DATA, idx: c_int, argl: c_long, argp: *const c_void) -> c_int; pub type CRYPTO_EX_dup = extern "C" fn(to: *mut CRYPTO_EX_DATA, from: *mut CRYPTO_EX_DATA, from_d: *mut c_void, idx: c_int, argl: c_long, argp: *mut c_void) -> c_int; pub type CRYPTO_EX_free = extern "C" fn(parent: *mut c_void, ptr: *mut c_void, ad: *mut CRYPTO_EX_DATA, idx: c_int, argl: c_long, argp: *mut c_void); pub type PasswordCallback = extern "C" fn(buf: *mut c_char, size: c_int, rwflag: c_int, user_data: *mut c_void) -> c_int; pub const BIO_TYPE_NONE: c_int = 0; pub const BIO_CTRL_EOF: c_int = 2; pub const BIO_CTRL_FLUSH: c_int = 11; pub const BIO_C_SET_BUF_MEM_EOF_RETURN: c_int = 130; pub const CRYPTO_LOCK: c_int = 1; pub const MBSTRING_ASC: c_int = MBSTRING_FLAG | 1; pub const MBSTRING_BMP: c_int = MBSTRING_FLAG | 2; pub const MBSTRING_FLAG: c_int = 0x1000; pub const MBSTRING_UNIV: c_int = MBSTRING_FLAG | 4; pub const MBSTRING_UTF8: c_int = MBSTRING_FLAG; pub const NID_ext_key_usage: c_int = 126; pub const NID_key_usage: c_int = 83; pub const PKCS5_SALT_LEN: c_int = 8; pub const SSL_CTRL_OPTIONS: c_int = 32; pub const SSL_CTRL_CLEAR_OPTIONS: c_int = 77; pub const SSL_CTRL_SET_TLSEXT_SERVERNAME_CB: c_int = 53; pub const SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG: c_int = 54; pub const SSL_CTRL_SET_TLSEXT_HOSTNAME: c_int = 55; pub const SSL_CTRL_EXTRA_CHAIN_CERT: c_int = 14; pub const SSL_CTRL_SET_READ_AHEAD: c_int = 41; pub const SSL_ERROR_NONE: c_int = 0; pub const SSL_ERROR_SSL: c_int = 1; pub const SSL_ERROR_SYSCALL: c_int = 5; pub const SSL_ERROR_WANT_ACCEPT: c_int = 8; pub const SSL_ERROR_WANT_CONNECT: c_int = 7; pub const SSL_ERROR_WANT_READ: c_int = 2; pub const SSL_ERROR_WANT_WRITE: c_int = 3; pub const SSL_ERROR_WANT_X509_LOOKUP: c_int = 4; pub const SSL_ERROR_ZERO_RETURN: c_int = 6; pub const SSL_VERIFY_NONE: c_int = 0; pub const SSL_VERIFY_PEER: c_int = 1; pub const SSL_VERIFY_FAIL_IF_NO_PEER_CERT: c_int = 2; pub const TLSEXT_NAMETYPE_host_name: c_long = 0; pub const SSL_TLSEXT_ERR_OK: c_int = 0; pub const SSL_TLSEXT_ERR_ALERT_WARNING: c_int = 1; pub const SSL_TLSEXT_ERR_ALERT_FATAL: c_int = 2; pub const SSL_TLSEXT_ERR_NOACK: c_int = 3; #[cfg(any(feature = "npn", feature = "alpn"))] pub const OPENSSL_NPN_UNSUPPORTED: c_int = 0; #[cfg(any(feature = "npn", feature = "alpn"))] pub const OPENSSL_NPN_NEGOTIATED: c_int = 1; #[cfg(any(feature = "npn", feature = "alpn"))] pub const OPENSSL_NPN_NO_OVERLAP: c_int = 2; pub const V_ASN1_GENERALIZEDTIME: c_int = 24; pub const V_ASN1_UTCTIME: c_int = 23; pub const X509_FILETYPE_ASN1: c_int = 2; pub const X509_FILETYPE_DEFAULT: c_int = 3; pub const X509_FILETYPE_PEM: c_int = 1; pub const X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: c_int = 31; pub const X509_V_ERR_AKID_SKID_MISMATCH: c_int = 30; pub const X509_V_ERR_APPLICATION_VERIFICATION: c_int = 50; pub const X509_V_ERR_CERT_CHAIN_TOO_LONG: c_int = 22; pub const X509_V_ERR_CERT_HAS_EXPIRED: c_int = 10; pub const X509_V_ERR_CERT_NOT_YET_VALID: c_int = 9; pub const X509_V_ERR_CERT_REJECTED: c_int = 28; pub const X509_V_ERR_CERT_REVOKED: c_int = 23; pub const X509_V_ERR_CERT_SIGNATURE_FAILURE: c_int = 7; pub const X509_V_ERR_CERT_UNTRUSTED: c_int = 27; pub const X509_V_ERR_CRL_HAS_EXPIRED: c_int = 12; pub const X509_V_ERR_CRL_NOT_YET_VALID: c_int = 11; pub const X509_V_ERR_CRL_PATH_VALIDATION_ERROR: c_int = 54; pub const X509_V_ERR_CRL_SIGNATURE_FAILURE: c_int = 8; pub const X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: c_int = 18; pub const X509_V_ERR_DIFFERENT_CRL_SCOPE: c_int = 44; pub const X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: c_int = 14; pub const X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: c_int = 13; pub const X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: c_int = 15; pub const X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: c_int = 16; pub const X509_V_ERR_EXCLUDED_VIOLATION: c_int = 48; pub const X509_V_ERR_INVALID_CA: c_int = 24; pub const X509_V_ERR_INVALID_EXTENSION: c_int = 41; pub const X509_V_ERR_INVALID_NON_CA: c_int = 37; pub const X509_V_ERR_INVALID_POLICY_EXTENSION: c_int = 42; pub const X509_V_ERR_INVALID_PURPOSE: c_int = 26; pub const X509_V_ERR_KEYUSAGE_NO_CERTSIGN: c_int = 32; pub const X509_V_ERR_KEYUSAGE_NO_CRL_SIGN: c_int = 35; pub const X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE: c_int = 39; pub const X509_V_ERR_NO_EXPLICIT_POLICY: c_int = 43; pub const X509_V_ERR_OUT_OF_MEM: c_int = 17; pub const X509_V_ERR_PATH_LENGTH_EXCEEDED: c_int = 25; pub const X509_V_ERR_PERMITTED_VIOLATION: c_int = 47; pub const X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED: c_int = 40; pub const X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED: c_int = 38; pub const X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: c_int = 19; pub const X509_V_ERR_SUBJECT_ISSUER_MISMATCH: c_int = 29; pub const X509_V_ERR_SUBTREE_MINMAX: c_int = 49; pub const X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: c_int = 6; pub const X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: c_int = 4; pub const X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: c_int = 5; pub const X509_V_ERR_UNABLE_TO_GET_CRL: c_int = 3; pub const X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER: c_int = 33; pub const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: c_int = 2; pub const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: c_int = 20; pub const X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: c_int = 21; pub const X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION: c_int = 36; pub const X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION: c_int = 34; pub const X509_V_ERR_UNNESTED_RESOURCE: c_int = 46; pub const X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX: c_int = 52; pub const X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE: c_int = 51; pub const X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE: c_int = 45; pub const X509_V_ERR_UNSUPPORTED_NAME_SYNTAX: c_int = 53; pub const X509_V_OK: c_int = 0; static mut MUTEXES: *mut Vec<Mutex<()>> = 0 as *mut Vec<Mutex<()>>; static mut GUARDS: *mut Vec<Option<MutexGuard<'static, ()>>> = 0 as *mut Vec<Option<MutexGuard<'static, ()>>>; unsafe extern fn locking_function(mode: c_int, n: c_int, _file: *const c_char, _line: c_int) { let mutex = &(*MUTEXES)[n as usize]; if mode & CRYPTO_LOCK != 0 { (*GUARDS)[n as usize] = Some(mutex.lock().unwrap()); } else { &(*GUARDS)[n as usize].take(); } } pub fn init() { static INIT: Once = ONCE_INIT; INIT.call_once(|| { unsafe { SSL_library_init(); SSL_load_error_strings(); let num_locks = CRYPTO_num_locks(); let mut mutexes = Box::new(Vec::new()); for _ in 0..num_locks { mutexes.push(Mutex::new(())); } MUTEXES = mem::transmute(mutexes); let guards: Box<Vec<Option<MutexGuard<()>>>> = Box::new((0..num_locks).map(|_| None).collect()); GUARDS = mem::transmute(guards); CRYPTO_set_locking_callback(locking_function); set_id_callback(); } }) } #[cfg(unix)] fn set_id_callback() { unsafe extern "C" fn thread_id() -> c_ulong { libc::pthread_self() as c_ulong } unsafe { CRYPTO_set_id_callback(thread_id); } } #[cfg(not(unix))] fn set_id_callback() {} // True functions extern "C" { pub fn ASN1_INTEGER_set(dest: *mut ASN1_INTEGER, value: c_long) -> c_int; pub fn ASN1_STRING_type_new(ty: c_int) -> *mut ASN1_STRING; pub fn ASN1_TIME_free(tm: *mut ASN1_TIME); pub fn BIO_ctrl(b: *mut BIO, cmd: c_int, larg: c_long, parg: *mut c_void) -> c_long; pub fn BIO_free_all(b: *mut BIO); pub fn BIO_new(type_: *const BIO_METHOD) -> *mut BIO; pub fn BIO_new_socket(sock: c_int, close_flag: c_int) -> *mut BIO; pub fn BIO_read(b: *mut BIO, buf: *mut c_void, len: c_int) -> c_int; pub fn BIO_write(b: *mut BIO, buf: *const c_void, len: c_int) -> c_int; pub fn BIO_s_mem() -> *const BIO_METHOD; pub fn BN_new() -> *mut BIGNUM; pub fn BN_dup(n: *mut BIGNUM) -> *mut BIGNUM; pub fn BN_clear_free(bn: *mut BIGNUM); pub fn BN_CTX_new() -> *mut BN_CTX; pub fn BN_CTX_free(ctx: *mut BN_CTX); pub fn BN_num_bits(bn: *mut BIGNUM) -> c_int; pub fn BN_set_negative(bn: *mut BIGNUM, n: c_int); pub fn BN_set_word(bn: *mut BIGNUM, n: c_ulong) -> c_int; /* Arithmetic operations on BIGNUMs */ pub fn BN_add(r: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM) -> c_int; pub fn BN_div(dv: *mut BIGNUM, rem: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; pub fn BN_exp(r: *mut BIGNUM, a: *mut BIGNUM, p: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; pub fn BN_gcd(r: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; pub fn BN_mod_add(r: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, m: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; pub fn BN_mod_exp(r: *mut BIGNUM, a: *mut BIGNUM, p: *mut BIGNUM, m: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; pub fn BN_mod_inverse(r: *mut BIGNUM, a: *mut BIGNUM, n: *mut BIGNUM, ctx: *mut BN_CTX) -> *const BIGNUM; pub fn BN_mod_mul(r: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, m: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; pub fn BN_mod_sqr(r: *mut BIGNUM, a: *mut BIGNUM, m: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; pub fn BN_mod_sub(r: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, m: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; pub fn BN_mul(r: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; pub fn BN_nnmod(rem: *mut BIGNUM, a: *mut BIGNUM, m: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; pub fn BN_add_word(r: *mut BIGNUM, w: c_ulong) -> c_int; pub fn BN_sub_word(r: *mut BIGNUM, w: c_ulong) -> c_int; pub fn BN_mul_word(r: *mut BIGNUM, w: c_ulong) -> c_int; pub fn BN_div_word(r: *mut BIGNUM, w: c_ulong) -> c_ulong; pub fn BN_mod_word(r: *const BIGNUM, w: c_ulong) -> c_ulong; pub fn BN_sqr(r: *mut BIGNUM, a: *mut BIGNUM, ctx: *mut BN_CTX) -> c_int; pub fn BN_sub(r: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM) -> c_int; /* Bit operations on BIGNUMs */ pub fn BN_clear_bit(a: *mut BIGNUM, n: c_int) -> c_int; pub fn BN_is_bit_set(a: *mut BIGNUM, n: c_int) -> c_int; pub fn BN_lshift(r: *mut BIGNUM, a: *mut BIGNUM, n: c_int) -> c_int; pub fn BN_lshift1(r: *mut BIGNUM, a: *mut BIGNUM) -> c_int; pub fn BN_mask_bits(a: *mut BIGNUM, n: c_int) -> c_int; pub fn BN_rshift(r: *mut BIGNUM, a: *mut BIGNUM, n: c_int) -> c_int; pub fn BN_set_bit(a: *mut BIGNUM, n: c_int) -> c_int; pub fn BN_rshift1(r: *mut BIGNUM, a: *mut BIGNUM) -> c_int; /* Comparisons on BIGNUMs */ pub fn BN_cmp(a: *mut BIGNUM, b: *mut BIGNUM) -> c_int; pub fn BN_ucmp(a: *mut BIGNUM, b: *mut BIGNUM) -> c_int; /* Prime handling */ pub fn BN_generate_prime_ex(r: *mut BIGNUM, bits: c_int, safe: c_int, add: *mut BIGNUM, rem: *mut BIGNUM, cb: *const c_void) -> c_int; pub fn BN_is_prime_ex(p: *mut BIGNUM, checks: c_int, ctx: *mut BN_CTX, cb: *const c_void) -> c_int; pub fn BN_is_prime_fasttest_ex(p: *mut BIGNUM, checks: c_int, ctx: *mut BN_CTX, do_trial_division: c_int, cb: *const c_void) -> c_int; /* Random number handling */ pub fn BN_rand(r: *mut BIGNUM, bits: c_int, top: c_int, bottom: c_int) -> c_int; pub fn BN_pseudo_rand(r: *mut BIGNUM, bits: c_int, top: c_int, bottom: c_int) -> c_int; pub fn BN_rand_range(r: *mut BIGNUM, range: *mut BIGNUM) -> c_int; pub fn BN_pseudo_rand_range(r: *mut BIGNUM, range: *mut BIGNUM) -> c_int; /* Conversion from/to binary representation */ pub fn BN_bin2bn(s: *const u8, size: c_int, ret: *mut BIGNUM) -> *mut BIGNUM; pub fn BN_bn2bin(a: *mut BIGNUM, to: *mut u8) -> c_int; /* Conversion from/to decimal string representation */ pub fn BN_dec2bn(a: *const *mut BIGNUM, s: *const c_char) -> c_int; pub fn BN_bn2dec(a: *mut BIGNUM) -> *const c_char; /* Conversion from/to hexidecimal string representation */ pub fn BN_hex2bn(a: *const *mut BIGNUM, s: *const c_char) -> c_int; pub fn BN_bn2hex(a: *mut BIGNUM) -> *const c_char; pub fn CRYPTO_num_locks() -> c_int; pub fn CRYPTO_set_locking_callback(func: unsafe extern "C" fn(mode: c_int, n: c_int, file: *const c_char, line: c_int)); pub fn CRYPTO_set_id_callback(func: unsafe extern "C" fn() -> c_ulong); pub fn CRYPTO_free(buf: *mut c_void); pub fn CRYPTO_memcmp(a: *const c_void, b: *const c_void, len: size_t) -> c_int; pub fn DH_free(dh: *mut DH); #[cfg(feature = "rfc5114")] pub fn DH_get_1024_160() -> *mut DH; #[cfg(feature = "rfc5114")] pub fn DH_get_2048_224() -> *mut DH; #[cfg(feature = "rfc5114")] pub fn DH_get_2048_256() -> *mut DH; pub fn DH_new_from_params(p: *mut BIGNUM, g: *mut BIGNUM, q: *mut BIGNUM) -> *mut DH; pub fn ERR_get_error() -> c_ulong; pub fn ERR_lib_error_string(err: c_ulong) -> *const c_char; pub fn ERR_func_error_string(err: c_ulong) -> *const c_char; pub fn ERR_reason_error_string(err: c_ulong) -> *const c_char; pub fn ERR_load_crypto_strings(); pub fn EVP_md5() -> *const EVP_MD; pub fn EVP_ripemd160() -> *const EVP_MD; pub fn EVP_sha1() -> *const EVP_MD; pub fn EVP_sha224() -> *const EVP_MD; pub fn EVP_sha256() -> *const EVP_MD; pub fn EVP_sha384() -> *const EVP_MD; pub fn EVP_sha512() -> *const EVP_MD; pub fn EVP_aes_128_cbc() -> *const EVP_CIPHER; pub fn EVP_aes_128_ecb() -> *const EVP_CIPHER; #[cfg(feature = "aes_xts")] pub fn EVP_aes_128_xts() -> *const EVP_CIPHER; #[cfg(feature = "aes_ctr")] pub fn EVP_aes_128_ctr() -> *const EVP_CIPHER; // fn EVP_aes_128_gcm() -> EVP_CIPHER; pub fn EVP_aes_128_cfb1() -> *const EVP_CIPHER; pub fn EVP_aes_128_cfb128() -> *const EVP_CIPHER; pub fn EVP_aes_128_cfb8() -> *const EVP_CIPHER; pub fn EVP_aes_256_cbc() -> *const EVP_CIPHER; pub fn EVP_aes_256_ecb() -> *const EVP_CIPHER; #[cfg(feature = "aes_xts")] pub fn EVP_aes_256_xts() -> *const EVP_CIPHER; #[cfg(feature = "aes_ctr")] pub fn EVP_aes_256_ctr() -> *const EVP_CIPHER; // fn EVP_aes_256_gcm() -> EVP_CIPHER; pub fn EVP_aes_256_cfb1() -> *const EVP_CIPHER; pub fn EVP_aes_256_cfb128() -> *const EVP_CIPHER; pub fn EVP_aes_256_cfb8() -> *const EVP_CIPHER; pub fn EVP_rc4() -> *const EVP_CIPHER; pub fn EVP_BytesToKey(typ: *const EVP_CIPHER, md: *const EVP_MD, salt: *const u8, data: *const u8, datalen: c_int, count: c_int, key: *mut u8, iv: *mut u8) -> c_int; pub fn EVP_CIPHER_CTX_new() -> *mut EVP_CIPHER_CTX; pub fn EVP_CIPHER_CTX_set_padding(ctx: *mut EVP_CIPHER_CTX, padding: c_int) -> c_int; pub fn EVP_CIPHER_CTX_free(ctx: *mut EVP_CIPHER_CTX); pub fn EVP_CipherInit(ctx: *mut EVP_CIPHER_CTX, evp: *const EVP_CIPHER, key: *const u8, iv: *const u8, mode: c_int) -> c_int; pub fn EVP_CipherUpdate(ctx: *mut EVP_CIPHER_CTX, outbuf: *mut u8, outlen: &mut c_int, inbuf: *const u8, inlen: c_int) -> c_int; pub fn EVP_CipherFinal(ctx: *mut EVP_CIPHER_CTX, res: *mut u8, len: &mut c_int) -> c_int; pub fn EVP_DigestInit(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD) -> c_int; pub fn EVP_DigestInit_ex(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD, imple: *const ENGINE) -> c_int; pub fn EVP_DigestUpdate(ctx: *mut EVP_MD_CTX, data: *const u8, n: c_uint) -> c_int; pub fn EVP_DigestFinal(ctx: *mut EVP_MD_CTX, res: *mut u8, n: *mut u32) -> c_int; pub fn EVP_DigestFinal_ex(ctx: *mut EVP_MD_CTX, res: *mut u8, n: *mut u32) -> c_int; pub fn EVP_MD_CTX_create() -> *mut EVP_MD_CTX; pub fn EVP_MD_CTX_copy_ex(dst: *mut EVP_MD_CTX, src: *const EVP_MD_CTX) -> c_int; pub fn EVP_MD_CTX_destroy(ctx: *mut EVP_MD_CTX); pub fn EVP_PKEY_new() -> *mut EVP_PKEY; pub fn EVP_PKEY_free(k: *mut EVP_PKEY); pub fn EVP_PKEY_assign(pkey: *mut EVP_PKEY, typ: c_int, key: *const c_void) -> c_int; pub fn EVP_PKEY_get1_RSA(k: *mut EVP_PKEY) -> *mut RSA; pub fn EVP_PKEY_set1_RSA(k: *mut EVP_PKEY, r: *mut RSA) -> c_int; pub fn EVP_PKEY_cmp(a: *const EVP_PKEY, b: *const EVP_PKEY) -> c_int; pub fn HMAC_CTX_init(ctx: *mut HMAC_CTX); pub fn HMAC_CTX_cleanup(ctx: *mut HMAC_CTX); pub fn PEM_read_bio_DHparams(bio: *mut BIO, out: *mut *mut DH, callback: Option<PasswordCallback>, user_data: *mut c_void) -> *mut DH; pub fn PEM_read_bio_X509(bio: *mut BIO, out: *mut *mut X509, callback: Option<PasswordCallback>, user_data: *mut c_void) -> *mut X509; pub fn PEM_read_bio_X509_REQ(bio: *mut BIO, out: *mut *mut X509_REQ, callback: Option<PasswordCallback>, user_data: *mut c_void) -> *mut X509_REQ; pub fn PEM_read_bio_PrivateKey(bio: *mut BIO, out: *mut *mut EVP_PKEY, callback: Option<PasswordCallback>, user_data: *mut c_void) -> *mut X509; pub fn PEM_read_bio_PUBKEY(bio: *mut BIO, out: *mut *mut EVP_PKEY, callback: Option<PasswordCallback>, user_data: *mut c_void) -> *mut X509; pub fn PEM_write_bio_PrivateKey(bio: *mut BIO, pkey: *mut EVP_PKEY, cipher: *const EVP_CIPHER, kstr: *mut c_char, klen: c_int, callback: Option<PasswordCallback>, user_data: *mut c_void) -> c_int; pub fn PEM_write_bio_PUBKEY(bp: *mut BIO, x: *mut EVP_PKEY) -> c_int; pub fn PEM_write_bio_X509(bio: *mut BIO, x509: *mut X509) -> c_int; pub fn PEM_write_bio_X509_REQ(bio: *mut BIO, x509: *mut X509_REQ) -> c_int; pub fn PKCS5_PBKDF2_HMAC_SHA1(pass: *const u8, passlen: c_int, salt: *const u8, saltlen: c_int, iter: c_int, keylen: c_int, out: *mut u8) -> c_int; #[cfg(feature = "pkcs5_pbkdf2_hmac")] pub fn PKCS5_PBKDF2_HMAC(pass: *const u8, passlen: c_int, salt: *const u8, saltlen: c_int, iter: c_int, digest: *const EVP_MD, keylen: c_int, out: *mut u8) -> c_int; pub fn RAND_bytes(buf: *mut u8, num: c_int) -> c_int; pub fn RSA_free(rsa: *mut RSA); pub fn RSA_generate_key(modsz: c_int, e: c_ulong, cb: *const c_void, cbarg: *const c_void) -> *mut RSA; pub fn RSA_generate_key_ex(rsa: *mut RSA, bits: c_int, e: *mut BIGNUM, cb: *const c_void) -> c_int; pub fn RSA_private_decrypt(flen: c_int, from: *const u8, to: *mut u8, k: *mut RSA, pad: c_int) -> c_int; pub fn RSA_public_decrypt(flen: c_int, from: *const u8, to: *mut u8, k: *mut RSA, pad: c_int) -> c_int; pub fn RSA_private_encrypt(flen: c_int, from: *const u8, to: *mut u8, k: *mut RSA, pad: c_int) -> c_int; pub fn RSA_public_encrypt(flen: c_int, from: *const u8, to: *mut u8, k: *mut RSA, pad: c_int) -> c_int; pub fn RSA_sign(t: c_int, m: *const u8, mlen: c_uint, sig: *mut u8, siglen: *mut c_uint, k: *mut RSA) -> c_int; pub fn RSA_size(k: *mut RSA) -> c_int; pub fn RSA_verify(t: c_int, m: *const u8, mlen: c_uint, sig: *const u8, siglen: c_uint, k: *mut RSA) -> c_int; pub fn SSL_library_init() -> c_int; pub fn SSL_load_error_strings(); #[cfg(feature = "sslv2")] pub fn SSLv2_method() -> *const SSL_METHOD; pub fn SSLv3_method() -> *const SSL_METHOD; pub fn TLSv1_method() -> *const SSL_METHOD; #[cfg(feature = "tlsv1_1")] pub fn TLSv1_1_method() -> *const SSL_METHOD; #[cfg(feature = "tlsv1_2")] pub fn TLSv1_2_method() -> *const SSL_METHOD; #[cfg(feature = "dtlsv1")] pub fn DTLSv1_method() -> *const SSL_METHOD; #[cfg(feature = "dtlsv1_2")] pub fn DTLSv1_2_method() -> *const SSL_METHOD; pub fn SSLv23_method() -> *const SSL_METHOD; pub fn SSL_new(ctx: *mut SSL_CTX) -> *mut SSL; pub fn SSL_pending(ssl: *const SSL) -> c_int; pub fn SSL_free(ssl: *mut SSL); pub fn SSL_set_bio(ssl: *mut SSL, rbio: *mut BIO, wbio: *mut BIO); pub fn SSL_get_rbio(ssl: *mut SSL) -> *mut BIO; pub fn SSL_get_wbio(ssl: *mut SSL) -> *mut BIO; pub fn SSL_accept(ssl: *mut SSL) -> c_int; pub fn SSL_connect(ssl: *mut SSL) -> c_int; pub fn SSL_ctrl(ssl: *mut SSL, cmd: c_int, larg: c_long, parg: *mut c_void) -> c_long; pub fn SSL_get_error(ssl: *mut SSL, ret: c_int) -> c_int; pub fn SSL_read(ssl: *mut SSL, buf: *mut c_void, num: c_int) -> c_int; pub fn SSL_write(ssl: *mut SSL, buf: *const c_void, num: c_int) -> c_int; pub fn SSL_get_ex_data_X509_STORE_CTX_idx() -> c_int; pub fn SSL_get_SSL_CTX(ssl: *mut SSL) -> *mut SSL_CTX; pub fn SSL_set_SSL_CTX(ssl: *mut SSL, ctx: *mut SSL_CTX) -> *mut SSL_CTX; pub fn SSL_get_current_compression(ssl: *mut SSL) -> *const COMP_METHOD; pub fn SSL_get_peer_certificate(ssl: *mut SSL) -> *mut X509; pub fn SSL_get_ssl_method(ssl: *mut SSL) -> *const SSL_METHOD; pub fn SSL_state_string(ssl: *mut SSL) -> *const c_char; pub fn SSL_state_string_long(ssl: *mut SSL) -> *const c_char; pub fn SSL_get_servername(ssl: *const SSL, name_type: c_long) -> *const c_char; pub fn SSL_COMP_get_name(comp: *const COMP_METHOD) -> *const c_char; pub fn SSL_CTX_new(method: *const SSL_METHOD) -> *mut SSL_CTX; pub fn SSL_CTX_free(ctx: *mut SSL_CTX); pub fn SSL_CTX_set_verify(ctx: *mut SSL_CTX, mode: c_int, verify_callback: Option<extern fn(c_int, *mut X509_STORE_CTX) -> c_int>); pub fn SSL_CTX_set_verify_depth(ctx: *mut SSL_CTX, depth: c_int); pub fn SSL_CTX_load_verify_locations(ctx: *mut SSL_CTX, CAfile: *const c_char, CApath: *const c_char) -> c_int; pub fn SSL_CTX_get_ex_new_index(argl: c_long, argp: *const c_void, new_func: Option<CRYPTO_EX_new>, dup_func: Option<CRYPTO_EX_dup>, free_func: Option<CRYPTO_EX_free>) -> c_int; pub fn SSL_CTX_set_ex_data(ctx: *mut SSL_CTX, idx: c_int, data: *mut c_void) -> c_int; pub fn SSL_CTX_get_ex_data(ctx: *mut SSL_CTX, idx: c_int) -> *mut c_void; pub fn SSL_CTX_use_certificate_file(ctx: *mut SSL_CTX, cert_file: *const c_char, file_type: c_int) -> c_int; pub fn SSL_CTX_use_certificate_chain_file(ctx: *mut SSL_CTX, cert_chain_file: *const c_char, file_type: c_int) -> c_int; pub fn SSL_CTX_use_certificate(ctx: *mut SSL_CTX, cert: *mut X509) -> c_int; pub fn SSL_CTX_use_PrivateKey_file(ctx: *mut SSL_CTX, key_file: *const c_char, file_type: c_int) -> c_int; pub fn SSL_CTX_use_PrivateKey(ctx: *mut SSL_CTX, key: *mut EVP_PKEY) -> c_int; pub fn SSL_CTX_check_private_key(ctx: *mut SSL_CTX) -> c_int; pub fn SSL_CTX_set_cipher_list(ssl: *mut SSL_CTX, s: *const c_char) -> c_int; #[cfg(feature = "npn")] pub fn SSL_CTX_set_next_protos_advertised_cb(ssl: *mut SSL_CTX, cb: extern "C" fn(ssl: *mut SSL, out: *mut *const c_uchar, outlen: *mut c_uint, arg: *mut c_void) -> c_int, arg: *mut c_void); #[cfg(feature = "npn")] pub fn SSL_CTX_set_next_proto_select_cb(ssl: *mut SSL_CTX, cb: extern "C" fn(ssl: *mut SSL, out: *mut *mut c_uchar, outlen: *mut c_uchar, inbuf: *const c_uchar, inlen: c_uint, arg: *mut c_void) -> c_int, arg: *mut c_void); #[cfg(any(feature = "alpn", feature = "npn"))] pub fn SSL_select_next_proto(out: *mut *mut c_uchar, outlen: *mut c_uchar, inbuf: *const c_uchar, inlen: c_uint, client: *const c_uchar, client_len: c_uint) -> c_int; #[cfg(feature = "npn")] pub fn SSL_get0_next_proto_negotiated(s: *const SSL, data: *mut *const c_uchar, len: *mut c_uint); #[cfg(feature = "alpn")] pub fn SSL_CTX_set_alpn_protos(s: *mut SSL_CTX, data: *const c_uchar, len: c_uint) -> c_int; #[cfg(feature = "alpn")] pub fn SSL_set_alpn_protos(s: *mut SSL, data: *const c_uchar, len: c_uint) -> c_int; #[cfg(feature = "alpn")] pub fn SSL_CTX_set_alpn_select_cb(ssl: *mut SSL_CTX, cb: extern "C" fn(ssl: *mut SSL, out: *mut *mut c_uchar, outlen: *mut c_uchar, inbuf: *const c_uchar, inlen: c_uint, arg: *mut c_void) -> c_int, arg: *mut c_void); #[cfg(feature = "alpn")] pub fn SSL_get0_alpn_selected(s: *const SSL, data: *mut *const c_uchar, len: *mut c_uint); pub fn X509_add_ext(x: *mut X509, ext: *mut X509_EXTENSION, loc: c_int) -> c_int; pub fn X509_digest(x: *mut X509, digest: *const EVP_MD, buf: *mut c_char, len: *mut c_uint) -> c_int; pub fn X509_free(x: *mut X509); pub fn X509_REQ_free(x: *mut X509_REQ); pub fn X509_get_serialNumber(x: *mut X509) -> *mut ASN1_INTEGER; pub fn X509_get_subject_name(x: *mut X509) -> *mut X509_NAME; pub fn X509_gmtime_adj(time: *mut ASN1_TIME, adj: c_long) -> *mut ASN1_TIME; pub fn X509_new() -> *mut X509; pub fn X509_set_issuer_name(x: *mut X509, name: *mut X509_NAME) -> c_int; pub fn X509_set_notAfter(x: *mut X509, tm: *const ASN1_TIME) -> c_int; pub fn X509_set_notBefore(x: *mut X509, tm: *const ASN1_TIME) -> c_int; pub fn X509_set_version(x: *mut X509, version: c_ulong) -> c_int; pub fn X509_set_pubkey(x: *mut X509, pkey: *mut EVP_PKEY) -> c_int; pub fn X509_sign(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int; pub fn X509_get_pubkey(x: *mut X509) -> *mut EVP_PKEY; pub fn X509_to_X509_REQ(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> *mut X509_REQ; pub fn X509_EXTENSION_free(ext: *mut X509_EXTENSION); pub fn X509_NAME_add_entry_by_txt(x: *mut X509, field: *const c_char, ty: c_int, bytes: *const c_char, len: c_int, loc: c_int, set: c_int) -> c_int; pub fn X509_NAME_get_index_by_NID(n: *mut X509_NAME, nid: c_int, last_pos: c_int) ->c_int; pub fn X509_NAME_get_entry(n: *mut X509_NAME, loc: c_int) -> *mut X509_NAME_ENTRY; pub fn X509_NAME_ENTRY_get_data(ne: *mut X509_NAME_ENTRY) -> *mut ASN1_STRING; pub fn ASN1_STRING_to_UTF8(out: *mut *mut c_char, s: *mut ASN1_STRING) -> c_int; pub fn X509_STORE_CTX_get_current_cert(ct: *mut X509_STORE_CTX) -> *mut X509; pub fn X509_STORE_CTX_get_error(ctx: *mut X509_STORE_CTX) -> c_int; pub fn X509_STORE_CTX_get_ex_data(ctx: *mut X509_STORE_CTX, idx: c_int) -> *mut c_void; pub fn X509V3_EXT_conf_nid(conf: *mut c_void, ctx: *mut X509V3_CTX, ext_nid: c_int, value: *mut c_char) -> *mut X509_EXTENSION; pub fn X509V3_EXT_conf(conf: *mut c_void, ctx: *mut X509V3_CTX, name: *mut c_char, value: *mut c_char) -> *mut X509_EXTENSION; pub fn X509V3_set_ctx(ctx: *mut X509V3_CTX, issuer: *mut X509, subject: *mut X509, req: *mut X509_REQ, crl: *mut X509_CRL, flags: c_int); pub fn X509_REQ_add_extensions(req: *mut X509_REQ, exts: *mut stack_st_X509_EXTENSION) -> c_int; pub fn X509_REQ_sign(x: *mut X509_REQ, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int; pub fn i2d_RSA_PUBKEY(k: *mut RSA, buf: *const *mut u8) -> c_int; pub fn d2i_RSA_PUBKEY(k: *const *mut RSA, buf: *const *const u8, len: c_uint) -> *mut RSA; pub fn i2d_RSAPrivateKey(k: *mut RSA, buf: *const *mut u8) -> c_int; pub fn d2i_RSAPrivateKey(k: *const *mut RSA, buf: *const *const u8, len: c_uint) -> *mut RSA; } pub mod probe; ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/openssl-sys-0.7.4/Cargo.toml�������������������������������������������������������������������0000644�0000765�0000024�00000002412�12635176400�015207� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������dialout����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������[package] name = "openssl-sys" version = "0.7.4" authors = ["Alex Crichton <alex@alexcrichton.com>", "Steven Fackler <sfackler@gmail.com>"] license = "MIT" description = "FFI bindings to OpenSSL" repository = "https://github.com/sfackler/rust-openssl" documentation = "https://sfackler.github.io/rust-openssl/doc/v0.7.4/openssl_sys" links = "openssl" build = "build.rs" [features] tlsv1_2 = [] tlsv1_1 = [] dtlsv1 = [] dtlsv1_2 = [] sslv2 = [] sslv3 = [] aes_xts = [] aes_ctr = [] npn = [] alpn = [] rfc5114 = [] pkcs5_pbkdf2_hmac = [] [dependencies] libc = "0.2" [build-dependencies] pkg-config = "0.3" [target.le32-unknown-nacl.dependencies] libressl-pnacl-sys = "2.1.0" [target.x86_64-unknown-nacl.dependencies] libressl-pnacl-sys = "2.1.0" [target.i686-unknown-nacl.dependencies] libressl-pnacl-sys = "2.1.0" [target.arm-unknown-nacl.dependencies] libressl-pnacl-sys = "2.1.0" # Only here to make sure we link to these in a static build on Windows [target.i686-pc-windows-gnu.dependencies] user32-sys = "0.1" gdi32-sys = "0.1" [target.x86_64-pc-windows-gnu.dependencies] user32-sys = "0.1" gdi32-sys = "0.1" [target.i686-pc-windows-msvc.dependencies] user32-sys = "0.1" gdi32-sys = "0.1" [target.x86_64-pc-windows-msvc.dependencies] user32-sys = "0.1" gdi32-sys = "0.1" ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/openssl-sys-0.7.4/build.rs���������������������������������������������������������������������0000644�0000765�0000024�00000005111�12635176400�014723� 0����������������������������������������������������������������������������������������������������ustar ���������������������������������dialout����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������extern crate pkg_config; use std::env; fn main() { let target = env::var("TARGET").unwrap(); // libressl_pnacl_sys links the libs needed. if target.ends_with("nacl") { return; } let lib_dir = env::var("OPENSSL_LIB_DIR").ok(); let include_dir = env::var("OPENSSL_INCLUDE_DIR").ok(); if lib_dir.is_none() && include_dir.is_none() { // rustc doesn't seem to work with pkg-config's output in mingw64 if !target.contains("windows") { if let Ok(info) = pkg_config::find_library("openssl") { // avoid empty include paths as they are not supported by GCC if info.include_paths.len() > 0 { let paths = env::join_paths(info.include_paths).unwrap(); println!("cargo:include={}", paths.to_str().unwrap()); } return; } } if let Some(mingw_paths) = get_mingw_in_path() { for path in mingw_paths { println!("cargo:rustc-link-search=native={}", path); } } } let libs_env = env::var("OPENSSL_LIBS").ok(); let libs = match libs_env { Some(ref v) => v.split(":").collect(), None => if target.contains("windows") { if get_mingw_in_path().is_some() && lib_dir.is_none() && include_dir.is_none() { vec!["ssleay32", "eay32"] } else { vec!["ssl32", "eay32"] } } else { vec!["ssl", "crypto"] } }; let mode = if env::var_os("OPENSSL_STATIC").is_some() { "static" } else { "dylib" }; if let Some(lib_dir) = lib_dir { println!("cargo:rustc-link-search=native={}", lib_dir); } for lib in libs { println!("cargo:rustc-link-lib={}={}", mode, lib); } if let Some(include_dir) = include_dir { println!("cargo:include={}", include_dir); } } fn get_mingw_in_path() -> Option<Vec<String>> { match env::var_os("PATH") { Some(env_path) => { let paths: Vec<String> = env::split_paths(&env_path).filter_map(|path| { use std::ascii::AsciiExt; match path.to_str() { Some(path_str) => { if path_str.to_ascii_lowercase().contains("mingw") { Some(path_str.to_string()) } else { None } }, None => None } }).collect(); if paths.len() > 0 { Some(paths) } else { None } }, None => None } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/user32-sys-0.1.2/������������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635520�013115� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/user32-sys-0.1.2/README.md���������������������������������������������������������������������0000644�0000000�0000000�00000000140�12562504746�014367� 0����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# user32-sys # FFI bindings to user32. [Documentation](https://retep998.github.io/doc/user32/) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/user32-sys-0.1.2/src/��������������������������������������������������������������������������0000755�0000000�0000000�00000000000�12666635520�013704� 5����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/user32-sys-0.1.2/src/lib.rs��������������������������������������������������������������������0000644�0000000�0000000�00000145376�12552213433�015025� 0����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������// Copyright © 2015, Peter Atashian // Licensed under the MIT License <LICENSE.md> //! FFI bindings to user32. #![cfg(windows)] extern crate winapi; use winapi::*; extern "system" { pub fn ActivateKeyboardLayout(hkl: HKL, flags: UINT) -> HKL; pub fn AddClipboardFormatListener(hWnd: HWND) -> BOOL; pub fn AdjustWindowRect(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL) -> BOOL; pub fn AdjustWindowRectEx( lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL, dwExStyle: DWORD, ) -> BOOL; pub fn AllowSetForegroundWindow(dwProcessId: DWORD) -> BOOL; pub fn AnimateWindow(hWnd: HWND, dwTime: DWORD, dwFlags: DWORD) -> BOOL; pub fn AnyPopup() -> BOOL; pub fn AppendMenuA( hMenu: HMENU, uFlags: UINT, uIDNewItem: UINT_PTR, lpNewItem: LPCSTR, ) -> BOOL; pub fn AppendMenuW( hMenu: HMENU, uFlags: UINT, uIDNewItem: UINT_PTR, lpNewItem: LPCWSTR, ) -> BOOL; pub fn ArrangeIconicWindows(hWnd: HWND) -> UINT; pub fn AttachThreadInput(idAttach: DWORD, idAttachTo: DWORD, fAttach: BOOL) -> BOOL; // pub fn BeginDeferWindowPos(); pub fn BeginPaint(hwnd: HWND, lpPaint: LPPAINTSTRUCT) -> HDC; pub fn BlockInput(fBlockIt: BOOL) -> BOOL; pub fn BringWindowToTop(hWnd: HWND) -> BOOL; // pub fn BroadcastSystemMessage(); pub fn BroadcastSystemMessageA( flags: DWORD, lpInfo: LPDWORD, Msg: UINT, wParam: WPARAM, lParam: LPARAM, ) -> LONG; // pub fn BroadcastSystemMessageExA(); // pub fn BroadcastSystemMessageExW(); pub fn BroadcastSystemMessageW( flags: DWORD, lpInfo: LPDWORD, Msg: UINT, wParam: WPARAM, lParam: LPARAM, ) -> LONG; pub fn CalculatePopupWindowPosition( anchorPoint: *const POINT, windowSize: *const SIZE, flags: UINT, excludeRect: *mut RECT, popupWindowPosition: *mut RECT, ) -> BOOL; pub fn CallMsgFilterA(lpMsg: LPMSG, nCode: c_int) -> BOOL; pub fn CallMsgFilterW(lpMsg: LPMSG, nCode: c_int) -> BOOL; pub fn CallNextHookEx(hhk: HHOOK, nCode: c_int, wParam: WPARAM, lParam: LPARAM) -> LRESULT; pub fn CallWindowProcA( lpPrevWndFunc: WNDPROC, hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM, ) -> LRESULT; pub fn CallWindowProcW( lpPrevWndFunc: WNDPROC, hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM, ) -> LRESULT; pub fn CancelShutdown() -> BOOL; // pub fn CascadeChildWindows(); pub fn CascadeWindows( hwndParent: HWND, wHow: UINT, lpRect: *const RECT, cKids: UINT, lpKids: *const HWND, ) -> WORD; pub fn ChangeClipboardChain(hwndRemove: HWND, hwndNewNext: HWND) -> BOOL; pub fn ChangeDisplaySettingsA(lpDevMode: *mut DEVMODEA, dwFlags: DWORD) -> LONG; pub fn ChangeDisplaySettingsExA( lpszDeviceName: LPCSTR, lpDevMode: *mut DEVMODEA, hwnd: HWND, dwFlags: DWORD, lParam: LPVOID, ) -> LONG; pub fn ChangeDisplaySettingsExW( lpszDeviceName: LPCWSTR, lpDevMode: *mut DEVMODEW, hwnd: HWND, dwFlags: DWORD, lParam: LPVOID, ) -> LONG; pub fn ChangeDisplaySettingsW(lpDevMode: *mut DEVMODEW, dwFlags: DWORD) -> LONG; pub fn ChangeMenuA( hMenu: HMENU, cmd: UINT, lpszNewItem: LPCSTR, cmdInsert: UINT, flags: UINT, ) -> BOOL; pub fn ChangeMenuW( hMenu: HMENU, cmd: UINT, lpszNewItem: LPCWSTR, cmdInsert: UINT, flags: UINT, ) -> BOOL; pub fn ChangeWindowMessageFilter(message: UINT, dwFlag: DWORD) -> BOOL; pub fn ChangeWindowMessageFilterEx( hwnd: HWND, message: UINT, action: DWORD, pChangeFilterStruct: PCHANGEFILTERSTRUCT, ) -> BOOL; pub fn CharLowerA(lpsz: LPSTR) -> LPSTR; pub fn CharLowerBuffA(lpsz: LPSTR, cchLength: DWORD) -> DWORD; pub fn CharLowerBuffW(lpsz: LPWSTR, cchLength: DWORD) -> DWORD; pub fn CharLowerW(lpsz: LPWSTR) -> LPWSTR; pub fn CharNextA(lpsz: LPCSTR) -> LPSTR; pub fn CharNextExA(codePage: WORD, lpCurrentChar: LPSTR, dwFlags: DWORD) -> LPSTR; pub fn CharNextW(lpsz: LPCWSTR) -> LPWSTR; pub fn CharPrevA(lpszStart: LPCSTR, lpszCurrent: LPCSTR) -> LPSTR; pub fn CharPrevExA( codePage: WORD, lpStart: LPCSTR, lpCurrentChar: LPCSTR, dwFlags: DWORD, ) -> LPSTR; pub fn CharPrevW(lpszStart: LPCWSTR, lpszCurrent: LPCWSTR) -> LPWSTR; // pub fn CharToOemA(); // pub fn CharToOemBuffA(); // pub fn CharToOemBuffW(); // pub fn CharToOemW(); pub fn CharUpperA(lpsz: LPSTR) -> LPSTR; pub fn CharUpperBuffA(lpsz: LPSTR, cchLength: DWORD) -> DWORD; pub fn CharUpperBuffW(lpsz: LPWSTR, cchLength: DWORD) -> DWORD; pub fn CharUpperW(lpsz: LPWSTR) -> LPWSTR; // pub fn CheckDlgButton(); pub fn CheckMenuItem(hMenu: HMENU, uIDCheckItem: UINT, uCheck: UINT) -> DWORD; pub fn CheckMenuRadioItem( hMenu: HMENU, first: UINT, last: UINT, check: UINT, flags: UINT, ) -> BOOL; pub fn CheckRadioButton( hDlg: HWND, nIDFirstButton: c_int, nIDLasatButton: c_int, nIDCheckButton: c_int, ) -> BOOL; pub fn ChildWindowFromPoint(hWndParent: HWND, point: POINT) -> HWND; pub fn ChildWindowFromPointEx(hwnd: HWND, pt: POINT, flags: UINT) -> HWND; pub fn ClientToScreen(hWnd: HWND, lpPoint: LPPOINT) -> BOOL; pub fn ClipCursor(lpRect: *const RECT) -> BOOL; pub fn CloseClipboard() -> BOOL; pub fn CloseDesktop(hDesktop: HDESK) -> BOOL; // pub fn CloseGestureInfoHandle(); // pub fn CloseTouchInputHandle(); pub fn CloseWindow(hWnd: HWND) -> BOOL; pub fn CloseWindowStation(hWinSta: HWINSTA) -> BOOL; pub fn CopyAcceleratorTableA( hAccelSrc: HACCEL, lpAccelDst: LPACCEL, cAccelEntries: c_int, ) -> c_int; pub fn CopyAcceleratorTableW( hAccelSrc: HACCEL, lpAccelDst: LPACCEL, cAccelEntries: c_int, ) -> c_int; pub fn CopyIcon(hIcon: HICON) -> HICON; pub fn CopyImage(h: HANDLE, type_: UINT, cx: c_int, cy: c_int, flags: UINT) -> HANDLE; pub fn CopyRect(lprcDst: LPRECT, lprcSrc: *const RECT) -> BOOL; pub fn CountClipboardFormats() -> c_int; pub fn CreateAcceleratorTableA(paccel: LPACCEL, cAccel: c_int) -> HACCEL; pub fn CreateAcceleratorTableW(paccel: LPACCEL, cAccel: c_int) -> HACCEL; pub fn CreateCaret(hWnd: HWND, hBitmap: HBITMAP, nWidth: c_int, nHeight: c_int) -> BOOL; pub fn CreateCursor( hInst: HINSTANCE, xHotSpot: c_int, yHotSpot: c_int, nWidth: c_int, nHeight: c_int, pvAndPlane: *const VOID, pvXORPlane: *const VOID, ) -> HCURSOR; pub fn CreateDesktopA( lpszDesktop: LPCSTR, lpszDevice: LPCSTR, pDevmode: *mut DEVMODEA, dwFlags: DWORD, dwDesiredAccess: ACCESS_MASK, lpsa: LPSECURITY_ATTRIBUTES, ) -> HDESK; // pub fn CreateDesktopExA(); // pub fn CreateDesktopExW(); pub fn CreateDesktopW( lpszDesktop: LPCWSTR, lpszDevice: LPCWSTR, pDevmode: *mut DEVMODEW, dwFlags: DWORD, dwDesiredAccess: ACCESS_MASK, lpsa: LPSECURITY_ATTRIBUTES, ) -> HDESK; pub fn CreateDialogIndirectParamA( hInstance: HINSTANCE, lpTemplate: LPCDLGTEMPLATEA, hWndParent: HWND, lpDialogFunc: DLGPROC, dwInitParam: LPARAM, ) -> HWND; pub fn CreateDialogIndirectParamW( hInstance: HINSTANCE, lpTemplate: LPCDLGTEMPLATEW, hWndParent: HWND, lpDialogFunc: DLGPROC, dwInitParam: LPARAM, ) -> HWND; pub fn CreateDialogParamA( hInstance: HINSTANCE, lpTemplateName: LPCSTR, hWndParent: HWND, lpDialogFunc: DLGPROC, dwInitParam: LPARAM, ) -> HWND; pub fn CreateDialogParamW( hInstance: HINSTANCE, lpTemplateName: LPCWSTR, hWndParent: HWND, lpDialogFunc: DLGPROC, dwInitParam: LPARAM, ) -> HWND; pub fn CreateIcon( hInstance: HINSTANCE, nWidth: c_int, nHeight: c_int, cPlanes: BYTE, cBitsPixel: BYTE, lpbANDbits: *const BYTE, lpbXORbits: *const BYTE, ) -> HICON; pub fn CreateIconFromResource( presbits: PBYTE, dwResSize: DWORD, fIcon: BOOL, dwVer: DWORD, ) -> HICON; pub fn CreateIconFromResourceEx( presbits: PBYTE, dwResSize: DWORD, fIcon: BOOL, dwVer: DWORD, cxDesired: c_int, cyDesired: c_int, Flags: UINT, ) -> HICON; pub fn CreateIconIndirect(piconinfo: PICONINFO) -> HICON; pub fn CreateMDIWindowA( lpClassName: LPCSTR, lpWindowName: LPCSTR, dwStyle: DWORD, X: c_int, Y: c_int, nWidth: c_int, nHeight: c_int, hWndParent: HWND, hInstance: HINSTANCE, lParam: LPARAM, ) -> HWND; pub fn CreateMDIWindowW( lpClassName: LPCWSTR, lpWindowName: LPCWSTR, dwStyle: DWORD, X: c_int, Y: c_int, nWidth: c_int, nHeight: c_int, hWndParent: HWND, hInstance: HINSTANCE, lParam: LPARAM, ) -> HWND; pub fn CreateMenu() -> HMENU; pub fn CreatePopupMenu() ->HMENU; pub fn CreateWindowExA( dwExStyle: DWORD, lpClassName: LPCSTR, lpWindowName: LPCSTR, dwStyle: DWORD, x: c_int, y: c_int, nWidth: c_int, nHeight: c_int, hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpParam: LPVOID, ) -> HWND; pub fn CreateWindowExW( dwExStyle: DWORD, lpClassName: LPCWSTR, lpWindowName: LPCWSTR, dwStyle: DWORD, x: c_int, y: c_int, nWidth: c_int, nHeight: c_int, hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpParam: LPVOID, ) -> HWND; pub fn CreateWindowStationA( lpwinsta: LPCSTR, dwFlags: DWORD, dwDesiredAccess: ACCESS_MASK, lpsa: LPSECURITY_ATTRIBUTES, ) -> HWINSTA; pub fn CreateWindowStationW( lpwinsta: LPCWSTR, dwFlags: DWORD, dwDesiredAccess: ACCESS_MASK, lpsa: LPSECURITY_ATTRIBUTES, ) -> HWINSTA; // pub fn DdeAbandonTransaction(); // pub fn DdeAccessData(); // pub fn DdeAddData(); // pub fn DdeClientTransaction(); // pub fn DdeCmpStringHandles(); // pub fn DdeConnect(); // pub fn DdeConnectList(); // pub fn DdeCreateDataHandle(); // pub fn DdeCreateStringHandleA(); // pub fn DdeCreateStringHandleW(); // pub fn DdeDisconnect(); // pub fn DdeDisconnectList(); // pub fn DdeEnableCallback(); // pub fn DdeFreeDataHandle(); // pub fn DdeFreeStringHandle(); // pub fn DdeGetData(); // pub fn DdeGetLastError(); // pub fn DdeImpersonateClient(); // pub fn DdeInitializeA(); // pub fn DdeInitializeW(); // pub fn DdeKeepStringHandle(); // pub fn DdeNameService(); // pub fn DdePostAdvise(); // pub fn DdeQueryConvInfo(); // pub fn DdeQueryNextServer(); // pub fn DdeQueryStringA(); // pub fn DdeQueryStringW(); // pub fn DdeReconnect(); // pub fn DdeSetQualityOfService(); // pub fn DdeSetUserHandle(); // pub fn DdeUnaccessData(); // pub fn DdeUninitialize(); pub fn DefDlgProcA( hDlg: HWND, msg: UINT, wParam: WPARAM, lParam: LPARAM, ) -> LRESULT; pub fn DefDlgProcW( hDlg: HWND, msg: UINT, wParam: WPARAM, lParam: LPARAM, ) -> LRESULT; pub fn DefFrameProcA( hwnd: HWND, hwndMDIClient: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM, ) -> LRESULT; pub fn DefFrameProcW( hwnd: HWND, hwndMDIClient: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM, ) -> LRESULT; pub fn DefMDIChildProcA( hwnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM, ) -> LRESULT; pub fn DefMDIChildProcW( hwnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM, ) -> LRESULT; pub fn DefRawInputProc(paRawInput: *mut PRAWINPUT, nInput: INT, cbSizeHeader: UINT) -> LRESULT; pub fn DefWindowProcA(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT; pub fn DefWindowProcW(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT; pub fn DeferWindowPos( hWinPosInfo: HDWP, hWnd: HWND, hWndInserAfter: HWND, x: c_int, y: c_int, cx: c_int, cy: c_int, uFlags: UINT, ) -> HDWP; pub fn DeleteMenu(hMenu: HMENU, uPosition: UINT, uFlags: UINT) -> BOOL; pub fn DeregisterShellHookWindow(hwnd: HWND) -> BOOL; pub fn DestroyAcceleratorTable(hAccel: HACCEL) -> BOOL; pub fn DestroyCaret() -> BOOL; pub fn DestroyCursor(hCursor: HCURSOR) -> BOOL; pub fn DestroyIcon(hIcon: HICON) -> BOOL; pub fn DestroyMenu(hMenu: HMENU) -> BOOL; pub fn DestroyWindow(hWnd: HWND) -> BOOL; pub fn DialogBoxIndirectParamA( hInstance: HINSTANCE, hDialogTemplate: LPCDLGTEMPLATEA, hWndParent: HWND, lpDialogFunc: DLGPROC, dwInitParam: LPARAM, ) -> INT_PTR; pub fn DialogBoxIndirectParamW( hInstance: HINSTANCE, hDialogTemplate: LPCDLGTEMPLATEW, hWndParent: HWND, lpDialogFunc: DLGPROC, dwInitParam: LPARAM, ) -> INT_PTR; pub fn DialogBoxParamA( hInstance: HINSTANCE, lpTemplateName: LPCSTR, hWndParent: HWND, lpDialogFunc: DLGPROC, dwInitParam: LPARAM, ) -> INT_PTR; pub fn DialogBoxParamW( hInstance: HINSTANCE, lpTemplateName: LPCWSTR, hWndParent: HWND, lpDialogFunc: DLGPROC, dwInitParam: LPARAM, ) -> INT_PTR; // pub fn DisableProcessWindowsGhosting(); pub fn DispatchMessageA(lpmsg: *const MSG) -> LRESULT; pub fn DispatchMessageW(lpmsg: *const MSG) -> LRESULT; // pub fn DisplayConfigGetDeviceInfo(); // pub fn DisplayConfigSetDeviceInfo(); // pub fn DlgDirListA(); // pub fn DlgDirListComboBoxA(); // pub fn DlgDirListComboBoxW(); // pub fn DlgDirListW(); // pub fn DlgDirSelectComboBoxExA(); // pub fn DlgDirSelectComboBoxExW(); // pub fn DlgDirSelectExA(); // pub fn DlgDirSelectExW(); pub fn DragDetect(hwnd: HWND, pt: POINT) -> BOOL; pub fn DragObject( hwndParent: HWND, hwndFrom: HWND, fmt: UINT, data: ULONG_PTR, hcur: HCURSOR, ) -> DWORD; pub fn DrawAnimatedRects( hwnd: HWND, idAni: c_int, lprcFrom: *const RECT, lprcTo: *const RECT, ) -> BOOL; pub fn DrawCaption(hwnd: HWND, hdc: HDC, lprect: *const RECT, flags: UINT) -> BOOL; pub fn DrawEdge(hdc: HDC, qrc: LPRECT, edge: UINT, grfFlags: UINT) -> BOOL; pub fn DrawFocusRect(hDC: HDC, lprc: *const RECT) -> BOOL; // pub fn DrawFrame(); pub fn DrawFrameControl(hdc: HDC, lprc: LPRECT, uType: UINT, uState: UINT) -> BOOL; pub fn DrawIcon(hDC: HDC, x: c_int, y: c_int, hIcon: HICON) -> BOOL; pub fn DrawIconEx( hdc: HDC, xLeft: c_int, yTop: c_int, hIcon: HICON, cxWidth: c_int, cyWidth: c_int, istepIfAniCur: UINT, hbrFlickerFreeDraw: HBRUSH, diFlags: UINT, ) -> BOOL; pub fn DrawMenuBar(hwnd: HWND) -> BOOL; pub fn DrawStateA( hdc: HDC, hbrFore: HBRUSH, qfnCallBack: DRAWSTATEPROC, lData: LPARAM, wData: WPARAM, x: c_int, y: c_int, cx: c_int, cy: c_int, uFlags: UINT, ) -> BOOL; pub fn DrawStateW( hdc: HDC, hbrFore: HBRUSH, qfnCallBack: DRAWSTATEPROC, lData: LPARAM, wData: WPARAM, x: c_int, y: c_int, cx: c_int, cy: c_int, uFlags: UINT, ) -> BOOL; pub fn DrawTextA( hdc: HDC, lpchText: LPCSTR, cchText: c_int, lprc: LPRECT, format: UINT, ) -> c_int; pub fn DrawTextExA( hdc: HDC, lpchText: LPCSTR, cchText: c_int, lprc: LPRECT, format: UINT, lpdtp: LPDRAWTEXTPARAMS, ) -> c_int; pub fn DrawTextExW( hdc: HDC, lpchText: LPCWSTR, cchText: c_int, lprc: LPRECT, format: UINT, lpdtp: LPDRAWTEXTPARAMS, ) -> c_int; pub fn DrawTextW( hdc: HDC, lpchText: LPCWSTR, cchText: c_int, lprc: LPRECT, format: UINT, ) -> c_int; // pub fn EditWndProc(); pub fn EmptyClipboard() -> BOOL; pub fn EnableMenuItem(hMenu: HMENU, uIDEnableItem: UINT, uEnable: UINT) -> BOOL; pub fn EnableMouseInPointer(fEnable: BOOL) -> BOOL; pub fn EnableScrollBar(hWnd: HWND, wSBflags: UINT, wArrows: UINT) -> BOOL; // pub fn EnableSessionForMMCSS(); pub fn EnableWindow(hWnd: HWND, bEnable: BOOL) -> BOOL; pub fn EndDeferWindowPos(hWinPosInfo: HDWP) -> BOOL; pub fn EndDialog(hDlg: HWND, nResult: INT_PTR) -> BOOL; pub fn EndMenu(hMenu: HMENU, uFlags: UINT, uIDNewItem: UINT_PTR, lpNewItem: LPCSTR) -> BOOL; pub fn EndPaint(hWnd: HWND, lpPaint: *const PAINTSTRUCT) -> BOOL; pub fn EndTask(hWnd: HWND, fShutDown: BOOL, fForce: BOOL) -> BOOL; pub fn EnumChildWindows( hwndParent: HWND, lpEnumFunc: WNDENUMPROC, lpParam: LPARAM, ) -> BOOL; pub fn EnumClipboardFormats(format: UINT) -> UINT; pub fn EnumDesktopWindows(hDesktop: HDESK, lpfn: WNDENUMPROC, lParam: LPARAM) -> BOOL; pub fn EnumDesktopsA( hwinsta: HWINSTA, lpEnumFunc: DESKTOPENUMPROCA, lParam: LPARAM, ) -> BOOL; pub fn EnumDesktopsW( hwinsta: HWINSTA, lpEnumFunc: DESKTOPENUMPROCW, lParam: LPARAM, ) -> BOOL; pub fn EnumDisplayDevicesA( lpDevice: LPCSTR, iDevNum: DWORD, lpDisplayDevice: PDISPLAY_DEVICEA, dwFlags: DWORD, ) -> BOOL; pub fn EnumDisplayDevicesW( lpDevice: LPCWSTR, iDevNum: DWORD, lpDisplayDevice: PDISPLAY_DEVICEW, dwFlags: DWORD, ) -> BOOL; pub fn EnumDisplayMonitors( hdc: HDC, lprcClip: LPCRECT, lpfnEnum: MONITORENUMPROC, dwData: LPARAM, ) -> BOOL; pub fn EnumDisplaySettingsA( lpszDeviceName: LPCSTR, iModeNum: DWORD, lpDevMode: *mut DEVMODEA, ) -> BOOL; pub fn EnumDisplaySettingsExA( lpszDeviceName: LPCSTR, iModeNum: DWORD, lpDevMode: *mut DEVMODEA, dwFlags: DWORD, ) -> BOOL; pub fn EnumDisplaySettingsExW( lpszDeviceName: LPCWSTR, iModeNum: DWORD, lpDevMode: *mut DEVMODEW, dwFlags: DWORD, ) -> BOOL; pub fn EnumDisplaySettingsW( lpszDeviceName: LPCWSTR, iModeNum: DWORD, lpDevMode: *mut DEVMODEW, ) -> BOOL; pub fn EnumPropsA(hWnd: HWND, lpEnumFunc: PROPENUMPROCA) -> c_int; pub fn EnumPropsExA(hWnd: HWND, lpEnumFunc: PROPENUMPROCA, lParam: LPARAM) -> c_int; pub fn EnumPropsExW(hWnd: HWND, lpEnumFunc: PROPENUMPROCW, lParam: LPARAM) -> c_int; pub fn EnumPropsW(hWnd: HWND, lpEnumFunc: PROPENUMPROCW) -> c_int; pub fn EnumThreadWindows(dwThreadId: DWORD, lpfn: WNDENUMPROC, lParam: LPARAM) -> BOOL; pub fn EnumWindowStationsA(lpEnumFunc: WINSTAENUMPROCA, lParam: LPARAM) -> BOOL; pub fn EnumWindowStationsW(lpEnumFunc: WINSTAENUMPROCW, lParam: LPARAM) -> BOOL; pub fn EnumWindows(lpEnumFunc: WNDENUMPROC, lParam: LPARAM) -> BOOL; // pub fn EqualRect(); // pub fn EvaluateProximityToPolygon(); // pub fn EvaluateProximityToRect(); // pub fn ExcludeUpdateRgn(); pub fn ExitWindowsEx(uFlags: UINT, dwReason: DWORD) -> BOOL; pub fn FillRect(hDC: HDC, lprc: *const RECT, hbr: HBRUSH) -> c_int; pub fn FindWindowA (lpClassName: LPCSTR, lpWindowName: LPCSTR) -> HWND; pub fn FindWindowExA( hWndParent: HWND, hWndChildAfter: HWND, lpszClass: LPCSTR, lpszWindow: LPCSTR, ) -> HWND; pub fn FindWindowExW( hWndParent: HWND, hWndChildAfter: HWND, lpszClass: LPCWSTR, lpszWindow: LPCWSTR, ) -> HWND; pub fn FindWindowW(lpClassName: LPCWSTR, lpWindowName: LPCWSTR) -> HWND; pub fn FlashWindow(hwnd: HWND, bInvert: BOOL) -> BOOL; pub fn FlashWindowEx(pfwi: PFLASHWINFO) -> BOOL; pub fn FrameRect(hDC: HDC, lprc: *const RECT, hbr: HBRUSH) -> c_int; // pub fn FreeDDElParam(); pub fn GetActiveWindow() -> HWND; // pub fn GetAltTabInfo(); // pub fn GetAltTabInfoA(); // pub fn GetAltTabInfoW(); pub fn GetAncestor(hWnd: HWND, gaFlags: UINT) -> HWND; pub fn GetAsyncKeyState(vKey: c_int) -> SHORT; // pub fn GetAutoRotationState(); // pub fn GetCIMSSM(); pub fn GetCapture() -> HWND; pub fn GetCaretBlinkTime() -> UINT; pub fn GetCaretPos(lpPoint: LPPOINT) -> BOOL; // pub fn GetClassInfoA(); // pub fn GetClassInfoExA(); pub fn GetClassInfoExW( hinst: HINSTANCE, lpszClass: LPCWSTR, lpwcx: LPWNDCLASSEXW, ) -> BOOL; pub fn GetClassInfoW( hInstance: HINSTANCE, lpClassName: LPCWSTR, lpWndClass: LPWNDCLASSW, ) -> BOOL; pub fn GetClassLongA(hWnd: HWND, nIndex: c_int) -> DWORD; #[cfg(target_arch = "x86_64")] pub fn GetClassLongPtrA(hWnd: HWND, nIndex: c_int) -> ULONG_PTR; #[cfg(target_arch = "x86_64")] pub fn GetClassLongPtrW(hWnd: HWND, nIndex: c_int) -> ULONG_PTR; pub fn GetClassLongW(hWnd: HWND, nIndex: c_int) -> DWORD; pub fn GetClassNameA(hWnd: HWND, lpClassName: LPCSTR, nMaxCount: c_int) -> c_int; pub fn GetClassNameW(hWnd: HWND, lpClassName: LPCWSTR, nMaxCount: c_int) -> c_int; pub fn GetClassWord(hWnd: HWND, nIndex: c_int) -> WORD; pub fn GetClientRect(hWnd: HWND, lpRect: LPRECT) -> BOOL; pub fn GetClipCursor(lpRect: LPRECT) -> BOOL; pub fn GetClipboardData(uFormat: UINT) -> HANDLE; pub fn GetClipboardFormatNameA( format: UINT, lpszFormatName: LPSTR, cchMaxCount: c_int, ) -> c_int; pub fn GetClipboardFormatNameW( format: UINT, lpszFormatName: LPWSTR, cchMaxCount: c_int, ) -> c_int; pub fn GetClipboardOwner() -> HWND; pub fn GetClipboardSequenceNumber() -> DWORD; pub fn GetClipboardViewer() -> HWND; // pub fn GetComboBoxInfo(); // pub fn GetCurrentInputMessageSource(); pub fn GetCursor() -> HCURSOR; // pub fn GetCursorInfo(); pub fn GetCursorPos(lpPoint: LPPOINT) -> BOOL; pub fn GetDC(hWnd: HWND) -> HDC; // pub fn GetDCEx(); pub fn GetDesktopWindow() -> HWND; pub fn GetDialogBaseUnits() -> LONG; // pub fn GetDisplayAutoRotationPreferences(); // pub fn GetDisplayConfigBufferSizes(); pub fn GetDlgCtrlID(hwnd: HWND) -> c_int; pub fn GetDlgItem(hDlg: HWND, nIDDlgItem: c_int) -> HWND; pub fn GetDlgItemInt( hDlg: HWND, nIDDlgItem: c_int, lpTranslated: *mut BOOL, bSigned: BOOL, ) -> UINT; pub fn GetDlgItemTextA( hDlg: HWND, nIDDlgItem: c_int, lpString: LPSTR, nMaxCount: c_int, ) -> UINT; pub fn GetDlgItemTextW( hDlg: HWND, nIDDlgItem: c_int, lpString: LPWSTR, nMaxCount: c_int, ) -> UINT; pub fn GetDoubleClickTime() -> UINT; pub fn GetFocus() -> HWND; pub fn GetForegroundWindow() -> HWND; // pub fn GetGUIThreadInfo(); // pub fn GetGestureConfig(); // pub fn GetGestureExtraArgs(); // pub fn GetGestureInfo(); // pub fn GetGuiResources(); pub fn GetIconInfo(hIcon: HICON, piconinfo: PICONINFO) -> BOOL; // pub fn GetIconInfoExA(); // pub fn GetIconInfoExW(); // pub fn GetInputDesktop(); // pub fn GetInputLocaleInfo(); // pub fn GetInputState(); pub fn GetKBCodePage() -> UINT; pub fn GetKeyNameTextA(lparam: LONG, lpString: LPSTR, cchSize: c_int) -> c_int; pub fn GetKeyNameTextW(lParam: LONG, lpString: LPWSTR, cchSize: c_int) -> c_int; pub fn GetKeyState(nVirtKey: c_int) -> SHORT; pub fn GetKeyboardLayout(idThread: DWORD) -> HKL; pub fn GetKeyboardLayoutList(nBuff: c_int, lpList: *mut HKL) -> c_int; pub fn GetKeyboardLayoutNameA(pwszKLID: LPSTR) -> BOOL; pub fn GetKeyboardLayoutNameW(pwszKLID: LPWSTR) -> BOOL; pub fn GetKeyboardState(lpKeyState: PBYTE) -> BOOL; pub fn GetKeyboardType(nTypeFlag: c_int) -> c_int; // pub fn GetLastActivePopup(); // pub fn GetLastInputInfo(); // pub fn GetLayeredWindowAttributes(); // pub fn GetListBoxInfo(); pub fn GetMenu(hWnd: HWND) -> HMENU; // pub fn GetMenuBarInfo(); // pub fn GetMenuCheckMarkDimensions(); // pub fn GetMenuContextHelpId(); // pub fn GetMenuDefaultItem(); // pub fn GetMenuInfo(); // pub fn GetMenuItemCount(); // pub fn GetMenuItemID(); // pub fn GetMenuItemInfoA(); // pub fn GetMenuItemInfoW(); // pub fn GetMenuItemRect(); // pub fn GetMenuState(); // pub fn GetMenuStringA(); // pub fn GetMenuStringW(); // pub fn GetMessageA(); // pub fn GetMessageExtraInfo(); // pub fn GetMessagePos(); pub fn GetMessageTime() -> LONG; pub fn GetMessageW(lpMsg: LPMSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT) -> BOOL; pub fn GetMonitorInfoA(hMonitor: HMONITOR, lpmi: LPMONITORINFO) -> BOOL; pub fn GetMonitorInfoW(hMonitor: HMONITOR, lpmi: LPMONITORINFO) -> BOOL; // pub fn GetMouseMovePointsEx(); // pub fn GetNextDlgGroupItem(); // pub fn GetNextDlgTabItem(); pub fn GetOpenClipboardWindow() -> HWND; pub fn GetParent(hWnd: HWND) -> HWND; pub fn GetPhysicalCursorPos(lpPoint: LPPOINT) -> BOOL; // pub fn GetPointerCursorId(); // pub fn GetPointerDevice(); // pub fn GetPointerDeviceCursors(); // pub fn GetPointerDeviceProperties(); // pub fn GetPointerDeviceRects(); // pub fn GetPointerDevices(); // pub fn GetPointerFrameInfo(); // pub fn GetPointerFrameInfoHistory(); // pub fn GetPointerFramePenInfo(); // pub fn GetPointerFramePenInfoHistory(); // pub fn GetPointerFrameTouchInfo(); // pub fn GetPointerFrameTouchInfoHistory(); // pub fn GetPointerInfo(); // pub fn GetPointerInfoHistory(); // pub fn GetPointerInputTransform(); // pub fn GetPointerPenInfo(); // pub fn GetPointerPenInfoHistory(); // pub fn GetPointerTouchInfo(); // pub fn GetPointerTouchInfoHistory(); pub fn GetPointerType(pointerId: UINT32, pointerType: *mut POINTER_INPUT_TYPE) -> BOOL; // pub fn GetPriorityClipboardFormat(); // pub fn GetProcessDefaultLayout(); // pub fn GetProcessWindowStation(); pub fn GetPropA(hwnd: HWND, lpString: LPCSTR) -> HANDLE; pub fn GetPropW(hwnd: HWND, lpString: LPCWSTR) -> HANDLE; pub fn GetQueueStatus(flags: UINT) -> DWORD; pub fn GetRawInputBuffer(pData: PRAWINPUT, pcbSize: PUINT, cbSizeHeader: UINT) -> UINT; pub fn GetRawInputData( hRawInput: HRAWINPUT, uiCommand: UINT, pData: LPVOID, pcbSize: PUINT, cbSizeHeader: UINT, ) -> UINT; pub fn GetRawInputDeviceInfoA( hDevice: HANDLE, uiCommand: UINT, pData: LPVOID, pcbSize: PUINT, ) -> UINT; pub fn GetRawInputDeviceInfoW( hDevice: HANDLE, uiCommand: UINT, pData: LPVOID, pcbSize: PUINT, ) -> UINT; pub fn GetRawInputDeviceList( pRawInputDeviceList: PRAWINPUTDEVICELIST, puiNumDevices: PUINT, cbSize: UINT, ) -> UINT; // pub fn GetRawPointerDeviceData(); pub fn GetRegisteredRawInputDevices( pRawInputDevices: PRAWINPUTDEVICE, puiNumDevices: PUINT, cbSize: UINT, ) -> UINT; // pub fn GetScrollBarInfo(); // pub fn GetScrollInfo(); pub fn GetScrollPos(hWnd: HWND, nBar: c_int) -> c_int; pub fn GetScrollRange(hWnd: HWND, nBar: c_int, lpMinPos: LPINT, lpMaxPos: LPINT) -> BOOL; pub fn GetShellWindow() -> HWND; // pub fn GetSubMenu(); pub fn GetSysColor(nIndex: c_int) -> DWORD; pub fn GetSysColorBrush(nIndex: c_int) -> HBRUSH; // pub fn GetSystemMenu(); pub fn GetSystemMetrics(nIndex: c_int) -> c_int; // pub fn GetTabbedTextExtentA(); // pub fn GetTabbedTextExtentW(); pub fn GetThreadDesktop(dwThreadId: DWORD) -> HDESK; // pub fn GetTitleBarInfo(); pub fn GetTopWindow(hWnd: HWND) -> HWND; // pub fn GetTouchInputInfo(); // pub fn GetUnpredictedMessagePos(); // pub fn GetUpdateRect(); // pub fn GetUpdateRgn(); pub fn GetUpdatedClipboardFormats( lpuiFormats: PUINT, cFormats: UINT, pcFormatsOUT: PUINT, ) -> BOOL; // pub fn GetUserObjectInformationA(); // pub fn GetUserObjectInformationW(); // pub fn GetUserObjectSecurity(); pub fn GetWindow(hWnd: HWND, uCmd: UINT) -> HWND; // pub fn GetWindowContextHelpId(); // pub fn GetWindowDC(); // pub fn GetWindowDisplayAffinity(); // pub fn GetWindowFeedbackSetting(); // pub fn GetWindowInfo(); pub fn GetWindowLongA(hWnd: HWND, nIndex: c_int) -> LONG; #[cfg(target_arch = "x86_64")] pub fn GetWindowLongPtrA(hWnd: HWND, nIndex: c_int) -> LONG_PTR; #[cfg(target_arch = "x86_64")] pub fn GetWindowLongPtrW(hWnd: HWND, nIndex: c_int) -> LONG_PTR; pub fn GetWindowLongW(hWnd: HWND, nIndex: c_int) -> LONG; // pub fn GetWindowModuleFileName(); pub fn GetWindowModuleFileNameA( hWnd: HWND, lpszFileName: LPCSTR, cchFileNameMax: UINT, ) -> UINT; pub fn GetWindowModuleFileNameW( hWnd: HWND, lpszFileName: LPWSTR, cchFileNameMax: UINT, ) -> UINT; pub fn GetWindowPlacement(hWnd: HWND, lpwndpl: *mut WINDOWPLACEMENT) -> BOOL; pub fn GetWindowRect(hWnd: HWND, lpRect: LPRECT) -> BOOL; pub fn GetWindowRgn(hWnd: HWND, hRgn: HRGN) -> c_int; pub fn GetWindowRgnBox(hWnd: HWND, lprc: LPRECT) -> c_int; pub fn GetWindowTextA(hWnd: HWND, lpString: LPSTR, nMaxCount: c_int) -> c_int; pub fn GetWindowTextLengthA(hWnd: HWND) -> c_int; pub fn GetWindowTextLengthW(hWnd: HWND) -> c_int; pub fn GetWindowTextW(hWnd: HWND, lpString: LPWSTR, nMaxCount: c_int) -> c_int; pub fn GetWindowThreadProcessId(hWnd: HWND, lpdwProcessId: LPDWORD) -> DWORD; pub fn GetWindowWord(nIndex: c_int) -> WORD; pub fn GrayStringA( hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC, lpData: LPARAM, nCount: c_int, X: c_int, Y: c_int, nWidth: c_int, nHeight: c_int, ) -> BOOL; pub fn GrayStringW( hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC, lpData: LPARAM, nCount: c_int, X: c_int, Y: c_int, nWidth: c_int, nHeight: c_int, ) -> BOOL; pub fn HideCaret(hWnd: HWND) -> BOOL; // pub fn HiliteMenuItem(); // pub fn IMPGetIMEA(); // pub fn IMPGetIMEW(); // pub fn IMPQueryIMEA(); // pub fn IMPQueryIMEW(); // pub fn IMPSetIMEA(); // pub fn IMPSetIMEW(); // pub fn ImpersonateDdeClientWindow(); // pub fn InSendMessage(); // pub fn InSendMessageEx(); pub fn InflateRect(lprc: LPRECT, dx: c_int, dy: c_int) -> BOOL; // pub fn InitializeTouchInjection(); // pub fn InjectTouchInput(); pub fn InsertMenuA( hMenu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT_PTR, lpNewItem: LPCSTR, ) -> BOOL; pub fn InsertMenuItemA( hmenu: HMENU, item: UINT, fByPosition: BOOL, lpmi: LPCMENUITEMINFOA, ) -> BOOL; pub fn InsertMenuItemW( hmenu: HMENU, item: UINT, fByPosition: BOOL, lpmi: LPCMENUITEMINFOW, ) -> BOOL; pub fn InsertMenuW( hMenu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT_PTR, lpNewItem: LPCWSTR, ) -> BOOL; pub fn InternalGetWindowText(hWnd: HWND, pString: LPWSTR, cchMaxCount: c_int) -> c_int; pub fn IntersectRect( lprcDst: LPRECT, lprcSrc1: *const RECT, lprcSrc2: *const RECT, ) -> BOOL; pub fn InvalidateRect(hWnd: HWND, lpRect: *const RECT, bErase: BOOL) -> BOOL; pub fn InvalidateRgn(hWnd: HWND, hRgn: HRGN, bErase: BOOL) -> BOOL; pub fn InvertRect(hDC: HDC, lprc: *const RECT) -> BOOL; pub fn IsCharAlphaA(ch: CHAR) -> BOOL; pub fn IsCharAlphaNumericA(ch: CHAR) -> BOOL; pub fn IsCharAlphaNumericW(ch: WCHAR) -> BOOL; pub fn IsCharAlphaW(ch: WCHAR) -> BOOL; pub fn IsCharLowerA(ch: CHAR) -> BOOL; pub fn IsCharLowerW(ch: WCHAR) -> BOOL; pub fn IsCharUpperA(ch: CHAR) -> BOOL; pub fn IsCharUpperW(ch: WCHAR) -> BOOL; pub fn IsChild(hWndParent: HWND, hWnd: HWND) -> BOOL; pub fn IsClipboardFormatAvailable(format: UINT) -> BOOL; pub fn IsDialogMessageA(hDlg: HWND, lpMsg: LPMSG) -> BOOL; pub fn IsDialogMessageW(hDlg: HWND, lpMsg: LPMSG) -> BOOL; pub fn IsDlgButtonChecked(hDlg: HWND, nIDButton: c_int) -> UINT; pub fn IsGUIThread(bConvert: BOOL) -> BOOL; pub fn IsHungAppWindow(hwnd: HWND) -> BOOL; pub fn IsIconic(hWnd: HWND) -> BOOL; pub fn IsImmersiveProcess(hProcess: HANDLE) -> BOOL; // pub fn IsInDesktopWindowBand(); pub fn IsMenu(hMenu: HMENU) -> BOOL; pub fn IsMouseInPointerEnabled() -> BOOL; pub fn IsProcessDPIAware() -> BOOL; pub fn IsRectEmpty(lprc: *const RECT) -> BOOL; pub fn IsTouchWindow(hwnd: HWND, pulFlags: PULONG) -> BOOL; pub fn IsWinEventHookInstalled(event: DWORD) -> BOOL; pub fn IsWindow(hWnd: HWND) -> BOOL; pub fn IsWindowEnabled(hWnd: HWND) -> BOOL; pub fn IsWindowUnicode(hWnd: HWND) -> BOOL; pub fn IsWindowVisible(hWnd: HWND) -> BOOL; pub fn IsWow64Message() -> BOOL; pub fn IsZoomed(hwnd: HWND) -> BOOL; pub fn KillTimer(hwnd: HWND, uIDEvent: UINT_PTR) -> BOOL; pub fn LoadAcceleratorsA(hInstance: HINSTANCE, lpTableName: LPCSTR) -> HACCEL; pub fn LoadAcceleratorsW(hInstance: HINSTANCE, lpTableName: LPCWSTR) -> HACCEL; pub fn LoadBitmapA(hInstance: HINSTANCE, lpBitmapName: LPCSTR) -> HBITMAP; pub fn LoadBitmapW(hInstance: HINSTANCE, lpBitmapName: LPCWSTR) -> HBITMAP; pub fn LoadCursorA(hInstance: HINSTANCE, lpCursorName: LPCSTR) -> HCURSOR; pub fn LoadCursorFromFileA(lpFileName: LPCSTR) -> HCURSOR; pub fn LoadCursorFromFileW(lpFileName: LPCWSTR) -> HCURSOR; pub fn LoadCursorW(hInstance: HINSTANCE, lpCursorName: LPCWSTR) -> HCURSOR; pub fn LoadIconA(hInstance: HINSTANCE, lpIconName: LPCSTR) -> HICON; pub fn LoadIconW(hInstance: HINSTANCE, lpIconName: LPCWSTR) -> HICON; pub fn LoadImageA( hInst: HINSTANCE, name: LPCSTR, type_: UINT, cx: c_int, cy: c_int, fuLoad: UINT, ) -> HANDLE; pub fn LoadImageW( hInst: HINSTANCE, name: LPCWSTR, type_: UINT, cx: c_int, cy: c_int, fuLoad: UINT, ) -> HANDLE; pub fn LoadKeyboardLayoutA(pwszKLID: LPCSTR, Flags: DWORD) -> HKL; pub fn LoadKeyboardLayoutW(pwszKLID: LPCWSTR, Flags: DWORD) -> HKL; pub fn LoadMenuA(hInstance: HINSTANCE, lpMenuName: LPCSTR) -> HMENU; pub fn LoadMenuIndirectA(lpMenuTemplate: *const MENUTEMPLATEA) -> HMENU; pub fn LoadMenuIndirectW(lpMenuTemplate: *const MENUTEMPLATEW) -> HMENU; pub fn LoadMenuW(hInstance: HINSTANCE, lpMenuName: LPCWSTR) -> HMENU; pub fn LoadStringA( hInstance: HINSTANCE, uID: UINT, lpBuffer: LPSTR, cchBufferMax: c_int, ) -> c_int; pub fn LoadStringW( hInstance: HINSTANCE, uID: UINT, lpBuffer: LPWSTR, cchBufferMax: c_int, ) -> c_int; pub fn LockSetForegroundWindow(uLockCode: UINT) -> BOOL; pub fn LockWindowUpdate(hWndLock: HWND) -> BOOL; pub fn LockWorkStation() -> BOOL; // pub fn LogicalToPhysicalPoint(); // pub fn LogicalToPhysicalPointForPerMonitorDPI(); pub fn LookupIconIdFromDirectory(presbits: PBYTE, fIcon: BOOL) -> c_int; pub fn LookupIconIdFromDirectoryEx( presbits: PBYTE, fIcon: BOOL, cxDesired: c_int, cyDesired: c_int, Flags: UINT, ) -> c_int; pub fn MapDialogRect(hDlg: HWND, lpRect: LPRECT) -> BOOL; pub fn MapVirtualKeyA(nCode: UINT, uMapType: UINT) -> UINT; pub fn MapVirtualKeyExA(nCode: UINT, uMapType: UINT, dwhkl: HKL) -> UINT; pub fn MapVirtualKeyExW(nCode: UINT, uMapType: UINT, dwhkl: HKL) -> UINT; pub fn MapVirtualKeyW(nCode: UINT, uMapType: UINT) -> UINT; pub fn MapWindowPoints(hWndFrom: HWND, hWndTo: HWND, lpPoints: LPPOINT, cPoints: UINT) -> c_int; pub fn MenuItemFromPoint(hWnd: HWND, hMenu: HMENU, ptScreen: POINT) -> c_int; pub fn MessageBeep(uType: UINT) -> BOOL; pub fn MessageBoxA(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT) -> c_int; pub fn MessageBoxExA( hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT, wLanguageId: WORD, ) -> c_int; pub fn MessageBoxExW( hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT, wLanguageId: WORD, ) -> c_int; pub fn MessageBoxIndirectA(lpmbp: *const MSGBOXPARAMSA) -> c_int; pub fn MessageBoxIndirectW(lpmbp: *const MSGBOXPARAMSW) -> c_int; // pub fn MessageBoxTimeoutA(); // pub fn MessageBoxTimeoutW(); pub fn MessageBoxW(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT) -> c_int; pub fn ModifyMenuA( hMnu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT_PTR, lpNewItem: LPCSTR, ) -> BOOL; pub fn ModifyMenuW( hMnu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT_PTR, lpNewItem: LPCWSTR, ) -> BOOL; // pub fn MonitorFromPoint(); // pub fn MonitorFromRect(); // pub fn MonitorFromWindow(); pub fn MoveWindow( hWnd: HWND, X: c_int, Y: c_int, nWidth: c_int, nHeight: c_int, bRepaint: BOOL, ) -> BOOL; // Use UINT instead of DWORD for dwWaitMask to be consistent with GetQueueStatus pub fn MsgWaitForMultipleObjects( nCount: DWORD, pHandles: *const HANDLE, fWaitAll: BOOL, dwMilliseconds: DWORD, dwWakeMask: UINT, ) -> DWORD; pub fn MsgWaitForMultipleObjectsEx( nCount: DWORD, pHandles: *const HANDLE, dwMilliseconds: DWORD, dwWakeMask: UINT, dwFlags: DWORD, ) -> DWORD; pub fn NotifyWinEvent(event: DWORD, hwnd: HWND, idObject: LONG, idChild: LONG); pub fn OemKeyScan(wOemChar: WORD) -> DWORD; pub fn OemToCharA(pSrc: LPCSTR, pDst: LPSTR) -> BOOL; pub fn OemToCharBuffA(lpszSrc: LPCSTR, lpszDst: LPSTR, cchDstLength: DWORD) -> BOOL; pub fn OemToCharBuffW(lpszSrc: LPCSTR, lpszDst: LPWSTR, cchDstLength: DWORD) -> BOOL; pub fn OemToCharW(pSrc: LPCSTR, pDst: LPWSTR) -> BOOL; pub fn OffsetRect(lprc: LPRECT, dx: c_int, dy: c_int) -> BOOL; pub fn OpenClipboard(hWnd: HWND) -> BOOL; pub fn OpenDesktopA( lpszDesktop: LPCSTR, dwFlags: DWORD, fInherit: BOOL, dwDesiredAccess: ACCESS_MASK, ) -> HDESK; pub fn OpenDesktopW( lpszDesktop: LPCWSTR, dwFlags: DWORD, fInherit: BOOL, dwDesiredAccess: ACCESS_MASK, ) -> HDESK; pub fn OpenIcon(hWnd: HWND) -> BOOL; pub fn OpenInputDesktop(dwFlags: DWORD, fInherit: BOOL, dwDesiredAccess: ACCESS_MASK) -> HDESK; pub fn OpenWindowStationA( lpszWinSta: LPCSTR, fInherit: BOOL, dwDesiredAccess: ACCESS_MASK, ) -> HWINSTA; pub fn OpenWindowStationW( lpszWinSta: LPCWSTR, fInherit: BOOL, dwDesiredAccess: ACCESS_MASK, ) -> HWINSTA; pub fn PackDDElParam(msg: UINT, uiLo: UINT_PTR, uiHi: UINT_PTR) -> LPARAM; // pub fn PackTouchHitTestingProximityEvaluation(); pub fn PaintDesktop(hdc: HDC) -> BOOL; pub fn PeekMessageA( lpMsg: LPMSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT, ) -> BOOL; pub fn PeekMessageW( lpMsg: LPMSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT, ) -> BOOL; // pub fn PhysicalToLogicalPoint(); // pub fn PhysicalToLogicalPointForPerMonitorDPI(); pub fn PostMessageA(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL; pub fn PostMessageW(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL; pub fn PostQuitMessage(nExitCode: c_int); pub fn PostThreadMessageA( idThread: DWORD, msg: UINT, wParam: WPARAM, lParam: LPARAM, ) -> BOOL; pub fn PostThreadMessageW( idThread: DWORD, msg: UINT, wParam: WPARAM, lParam: LPARAM, ) -> BOOL; pub fn PrintWindow(hwnd: HWND, hdcBlt: HDC, nFlags: UINT) -> BOOL; // pub fn PrivateExtractIconsA(); // pub fn PrivateExtractIconsW(); pub fn PtInRect(lprc: *const RECT, pt: POINT) -> BOOL; // pub fn QueryDisplayConfig(); pub fn RealChildWindowFromPoint( hwndParent: HWND, ptParentClientCoords: POINT, ) -> HWND; pub fn RealGetWindowClass( hwnd: HWND, ptszClassName: LPSTR, cchClassNameMax: UINT, ) -> UINT; pub fn RealGetWindowClassA( hwnd: HWND, ptszClassName: LPSTR, cchClassNameMax: UINT, ) -> UINT; pub fn RealGetWindowClassW( hwnd: HWND, ptszClassName: LPWSTR, cchClassNameMax: UINT, ) -> UINT; pub fn RedrawWindow( hwnd: HWND, lprcUpdate: *const RECT, hrgnUpdate: HRGN, flags: UINT, ) -> BOOL; // pub fn RegisterClassA(); // pub fn RegisterClassExA(); pub fn RegisterClassExW(lpWndClass: *const WNDCLASSEXW) -> ATOM; pub fn RegisterClassW(lpWndClass: *const WNDCLASSW) -> ATOM; pub fn RegisterClipboardFormatA(lpszFormat: LPCSTR) -> UINT; pub fn RegisterClipboardFormatW(lpszFormat: LPCWSTR) -> UINT; pub fn RegisterDeviceNotificationA( hRecipient: HANDLE, notificationFilter: LPVOID, flags: DWORD, ) -> HDEVNOTIFY; pub fn RegisterDeviceNotificationW( hRecipient: HANDLE, notificationFilter: LPVOID, flags: DWORD, ) -> HDEVNOTIFY; pub fn RegisterHotKey(hwnd: HWND, id: c_int, fsModifiers: UINT, vk: UINT) -> BOOL; // pub fn RegisterPointerDeviceNotifications(); // pub fn RegisterPointerInputTarget(); // pub fn RegisterPowerSettingNotification(); pub fn RegisterRawInputDevices( pRawInputDevices: PCRAWINPUTDEVICE, uiNumDevices: UINT, cbSize: UINT, ) -> BOOL; // pub fn RegisterShellHookWindow(); // pub fn RegisterSuspendResumeNotification(); // pub fn RegisterTouchHitTestingWindow(); // pub fn RegisterTouchWindow(); pub fn RegisterWindowMessageA(lpString: LPCSTR) -> UINT; pub fn RegisterWindowMessageW(lpString: LPCWSTR) -> UINT; pub fn ReleaseCapture() -> BOOL; pub fn ReleaseDC(hWnd: HWND, hDC: HDC) -> c_int; // pub fn RemoveClipboardFormatListener(); // pub fn RemoveMenu(); pub fn RemovePropA(hWnd: HWND, lpStr: LPCSTR) -> HANDLE; pub fn RemovePropW(hWnd: HWND, lpStr: LPCWSTR) -> HANDLE; // pub fn ReplyMessage(); // pub fn ReuseDDElParam(); pub fn ScreenToClient(hWnd: HWND, lpPoint: LPPOINT) -> BOOL; pub fn ScrollDC( hDC: HDC, dx: c_int, dy: c_int, lprcScroll: *const RECT, lprcClip: *const RECT, hrgnUpdate: HRGN, lprcUpdate: LPRECT, ) -> BOOL; pub fn ScrollWindow( hWnd: HWND, xAmount: c_int, yAmount: c_int, lpRect: *const RECT, lpClipRect: *const RECT, ) -> BOOL; pub fn ScrollWindowEx( hWnd: HWND, dx: c_int, dy: c_int, prcScroll: *const RECT, prcClip: *const RECT, hrgnUpdate: HRGN, prcUpdate: LPRECT, flags: UINT, ) -> c_int; pub fn SendDlgItemMessageA( hDlg: HWND, nIDDlgItem: c_int, Msg: UINT, wParam: WPARAM, lParam: LPARAM, ) -> LRESULT; pub fn SendDlgItemMessageW( hDlg: HWND, nIDDlgItem: c_int, Msg: UINT, wParam: WPARAM, lParam: LPARAM, ) -> LRESULT; // pub fn SendIMEMessageExA(); // pub fn SendIMEMessageExW(); pub fn SendInput(cInputs: UINT, pInputs: LPINPUT, cbSize: c_int) -> UINT; pub fn SendMessageA(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT; // pub fn SendMessageCallbackA(); // pub fn SendMessageCallbackW(); pub fn SendMessageTimeoutA( hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM, fuFlags: UINT, uTimeout: UINT, lpdwResult: PDWORD_PTR, ) -> LRESULT; pub fn SendMessageTimeoutW( hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM, fuFlags: UINT, uTimeout: UINT, lpdwResult: PDWORD_PTR, ) -> LRESULT; pub fn SendMessageW(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT; pub fn SendNotifyMessageA(hWnd: HWND, msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL; pub fn SendNotifyMessageW(hWnd: HWND, msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL; pub fn SetActiveWindow(hWnd: HWND) -> HWND; pub fn SetCapture(hWnd: HWND) -> HWND; pub fn SetCaretBlinkTime(uMSeconds: UINT) -> BOOL; pub fn SetCaretPos(x: c_int, y: c_int) -> BOOL; pub fn SetClassLongA(hWnd: HWND, nIndex: c_int, dwNewLong: LONG) -> DWORD; #[cfg(target_arch = "x86_64")] pub fn SetClassLongPtrA(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> ULONG_PTR; #[cfg(target_arch = "x86_64")] pub fn SetClassLongPtrW(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> ULONG_PTR; pub fn SetClassLongW(hWnd: HWND, nIndex: c_int, dwNewLong: LONG) -> DWORD; pub fn SetClassWord(hWnd: HWND, nIndex: c_int, wNewWord: WORD) -> WORD; pub fn SetClipboardData(uFormat: UINT, hMem: HANDLE) -> HANDLE; pub fn SetClipboardViewer(hWndNewViewer: HWND) -> HWND; // pub fn SetCoalescableTimer(); pub fn SetCursor(hCursor: HCURSOR) -> HCURSOR; pub fn SetCursorPos(x: c_int, y: c_int) -> BOOL; // pub fn SetDebugErrorLevel(); // pub fn SetDeskWallpaper(); // pub fn SetDisplayAutoRotationPreferences(); // pub fn SetDisplayConfig(); pub fn SetDlgItemInt(hDlg: HWND, nIDDlgItem: c_int, uValue: UINT, bSigned: BOOL) -> BOOL; pub fn SetDlgItemTextA(hDlg: HWND, nIDDlgItem: c_int, lpString: LPCSTR) -> BOOL; pub fn SetDlgItemTextW(hDlg: HWND, nIDDlgItem: c_int, lpString: LPCWSTR) -> BOOL; pub fn SetDoubleClickTime(uInterval: UINT) -> BOOL; pub fn SetFocus(hWnd: HWND) -> HWND; pub fn SetForegroundWindow(hWnd: HWND) -> BOOL; // pub fn SetGestureConfig(); pub fn SetKeyboardState(lpKeyState: LPBYTE) -> BOOL; pub fn SetLastErrorEx(dwErrCode: DWORD, dwType: DWORD); pub fn SetLayeredWindowAttributes( hwnd: HWND, crKey: COLORREF, bAlpha: BYTE, dwFlags: DWORD ) -> BOOL; pub fn SetMenu(hWnd: HWND, hMenu: HMENU) -> HMENU; // pub fn SetMenuContextHelpId(); // pub fn SetMenuDefaultItem(); // pub fn SetMenuInfo(); // pub fn SetMenuItemBitmaps(); // pub fn SetMenuItemInfoA(); // pub fn SetMenuItemInfoW(); // pub fn SetMessageExtraInfo(); // pub fn SetMessageQueue(); pub fn SetParent(hWndChild: HWND, hWndNewParent: HWND) -> HWND; pub fn SetPhysicalCursorPos(x: c_int, y: c_int) -> BOOL; // pub fn SetProcessDPIAware(); // pub fn SetProcessDefaultLayout(); // pub fn SetProcessRestrictionExemption(); // pub fn SetProcessWindowStation(); pub fn SetPropA(hWnd: HWND, lpString: LPCSTR, hData: HANDLE) -> BOOL; pub fn SetPropW(hWnd: HWND, lpString: LPCWSTR, hData: HANDLE) -> BOOL; pub fn SetRect(lprc: LPRECT, xLeft: c_int, yTop: c_int, xRight: c_int, yBottom: c_int) -> BOOL; pub fn SetRectEmpty(lprc: LPRECT) -> BOOL; // pub fn SetScrollInfo(); pub fn SetScrollPos(hWnd: HWND, nBar: c_int, nPos: c_int, bRedraw: BOOL) -> c_int; pub fn SetScrollRange( hWnd: HWND, nBar: c_int, nMinPos: c_int, nMaxPos: c_int, bRedraw: BOOL, ) -> BOOL; // pub fn SetShellWindow(); pub fn SetSysColors( cElements: c_int, lpaElements: *const INT, lpaRgbValues: *const COLORREF, ) -> BOOL; pub fn SetSystemCursor(hcur: HCURSOR, id: DWORD) -> BOOL; pub fn SetThreadDesktop(hDesktop: HDESK) -> BOOL; pub fn SetTimer( hWnd: HWND, nIDEvent: UINT_PTR, uElapse: UINT, lpTimerFunc: TimerProc, ) -> UINT_PTR; // pub fn SetUserObjectInformationA(); // pub fn SetUserObjectInformationW(); // pub fn SetUserObjectSecurity(); pub fn SetWinEventHook( eventMin: DWORD, eventMax: DWORD, hmodWinEventProc: HMODULE, pfnWinEventProc: WINEVENTPROC, idProcess: DWORD, idThread: DWORD, dwFlags: DWORD, ) -> HWINEVENTHOOK; // pub fn SetWindowContextHelpId(); // pub fn SetWindowDisplayAffinity(); // pub fn SetWindowFeedbackSetting(); pub fn SetWindowLongA(hWnd: HWND, nIndex: c_int, dwNewLong: LONG) -> LONG; #[cfg(target_arch = "x86_64")] pub fn SetWindowLongPtrA(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> LONG_PTR; #[cfg(target_arch = "x86_64")] pub fn SetWindowLongPtrW(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> LONG_PTR; pub fn SetWindowLongW(hWnd: HWND, nIndex: c_int, dwNewLong: LONG) -> LONG; // pub fn SetWindowPlacement(); pub fn SetWindowPos( hWnd: HWND, hWndInsertAfter: HWND, X: c_int, Y: c_int, cx: c_int, cy: c_int, uFlags: UINT, ) -> BOOL; pub fn SetWindowRgn(hWnd: HWND, hRgn: HRGN, bRedraw: BOOL) -> c_int; pub fn SetWindowTextA(hWnd: HWND, lpString: LPCSTR) -> BOOL; pub fn SetWindowTextW(hWnd: HWND, lpString: LPCWSTR) -> BOOL; pub fn SetWindowWord(hwnd: HWND, nIndex: c_int, wNewWord: WORD) -> WORD; // pub fn SetWindowsHookA(); pub fn SetWindowsHookExA( idHook: c_int, lpfn: HOOKPROC, hmod: HINSTANCE, dwThreadId: DWORD, ) -> HHOOK; pub fn SetWindowsHookExW( idHook: c_int, lpfn: HOOKPROC, hmod: HINSTANCE, dwThreadId: DWORD, ) -> HHOOK; // pub fn SetWindowsHookW(); pub fn ShowCaret(hWnd: HWND) -> BOOL; pub fn ShowCursor(bShow: BOOL) -> c_int; // pub fn ShowOwnedPopups(); // pub fn ShowScrollBar(); // pub fn ShowSystemCursor(); pub fn ShowWindow(hWnd: HWND, nCmdShow: c_int) -> BOOL; pub fn ShowWindowAsync(hWnd: HWND, nCmdShow: c_int) -> BOOL; // pub fn ShutdownBlockReasonCreate(); // pub fn ShutdownBlockReasonDestroy(); // pub fn ShutdownBlockReasonQuery(); // pub fn SkipPointerFrameMessages(); // pub fn SoundSentry(); // pub fn SubtractRect(); pub fn SwapMouseButton(fSwap: BOOL) -> BOOL; pub fn SwitchDesktop(hDesktop: HDESK) -> BOOL; // pub fn SwitchToThisWindow(); pub fn SystemParametersInfoA( uiAction: UINT, uiParam: UINT, pvParam: PVOID, fWinIni: UINT ) -> BOOL; pub fn SystemParametersInfoW( uiAction: UINT, uiParam: UINT, pvParam: PVOID, fWinIni: UINT ) -> BOOL; pub fn TabbedTextOutA( hdc: HDC, x: c_int, y: c_int, lpString: LPCSTR, chCount: c_int, nTabPositions: c_int, lpnTabStopPositions: *const INT, nTabOrigin: c_int, ) -> LONG; pub fn TabbedTextOutW( hdc: HDC, x: c_int, y: c_int, lpString: LPCWSTR, chCount: c_int, nTabPositions: c_int, lpnTabStopPositions: *const INT, nTabOrigin: c_int, ) -> LONG; // pub fn TileChildWindows(); // pub fn TileWindows(); // pub fn ToAscii(); // pub fn ToAsciiEx(); // pub fn ToUnicode(); // pub fn ToUnicodeEx(); pub fn TrackMouseEvent(lpEventTrack: LPTRACKMOUSEEVENT) -> BOOL; // pub fn TrackPopupMenu(); // pub fn TrackPopupMenuEx(); // pub fn TranslateAccelerator(); // pub fn TranslateAcceleratorA(); // pub fn TranslateAcceleratorW(); // pub fn TranslateMDISysAccel(); pub fn TranslateMessage(lpmsg: *const MSG) -> BOOL; pub fn UnhookWinEvent(hWinEventHook: HWINEVENTHOOK) -> BOOL; // pub fn UnhookWindowsHook(); pub fn UnhookWindowsHookEx(hhk: HHOOK) -> BOOL; pub fn UnionRect(lprcDst: LPRECT, lprcSrc1: *const RECT, lprcSrc2: *const RECT) -> BOOL; pub fn UnloadKeyboardLayout(hkl: HKL) -> BOOL; pub fn UnpackDDElParam(msg: UINT, lParam: LPARAM, puiLo: PUINT_PTR, puiHi: PUINT_PTR) -> BOOL; pub fn UnregisterClassA(lpClassName: LPCSTR, hInstance: HINSTANCE) -> BOOL; pub fn UnregisterClassW(lpClassName: LPCWSTR, hInstance: HINSTANCE) -> BOOL; pub fn UnregisterDeviceNotification(Handle: HDEVNOTIFY) -> BOOL; pub fn UnregisterHotKey(hWnd: HWND, id: c_int) -> BOOL; // pub fn UnregisterPointerInputTarget(); // pub fn UnregisterPowerSettingNotification(); // pub fn UnregisterSuspendResumeNotification(); // pub fn UnregisterTouchWindow(); pub fn UpdateLayeredWindow( hWnd: HWND, hdcDst: HDC, pptDst: *mut POINT, psize: *mut SIZE, hdcSrc: HDC, pptSrc: *mut POINT, crKey: COLORREF, pblend: *mut BLENDFUNCTION, dwFlags: DWORD, ) -> BOOL; // pub fn UpdateLayeredWindowIndirect(); pub fn UpdateWindow(hWnd: HWND) -> BOOL; pub fn UserHandleGrantAccess(hUserHandle: HANDLE, hJob: HANDLE, bGrant: BOOL) -> BOOL; pub fn ValidateRect(hWnd: HWND, lpRect: *const RECT) -> BOOL; pub fn ValidateRgn(hWnd: HWND, hRgn: HRGN) -> BOOL; pub fn VkKeyScanA(ch: CHAR) -> SHORT; pub fn VkKeyScanExA(ch: CHAR, dwhkl: HKL) -> SHORT; pub fn VkKeyScanExW(ch: WCHAR, dwhkl: HKL) -> SHORT; pub fn VkKeyScanW(ch: WCHAR) -> SHORT; // pub fn WINNLSEnableIME(); // pub fn WINNLSGetEnableStatus(); // pub fn WINNLSGetIMEHotkey(); pub fn WaitForInputIdle(hProcess: HANDLE, dwMilliseconds: DWORD) -> DWORD; pub fn WaitMessage() -> BOOL; pub fn WinHelpA(hWndMain: HWND, lpszHelp: LPCSTR, uCommand: UINT, dwData: ULONG_PTR) -> BOOL; pub fn WinHelpW(hWndMain: HWND, lpszHelp: LPCWSTR, uCommand: UINT, dwData: ULONG_PTR) -> BOOL; pub fn WindowFromDC(hDC: HDC) -> HWND; // pub fn WindowFromPhysicalPoint(); pub fn WindowFromPoint(Point: POINT) -> HWND; pub fn keybd_event(bVk: BYTE, bScan: BYTE, dwFlags: DWORD, dwExtraInfo: ULONG_PTR); pub fn mouse_event(dwFlags: DWORD, dx: DWORD, dy: DWORD, dwData: DWORD, dwExtraInfo: ULONG_PTR); // pub fn wsprintfA(); // pub fn wsprintfW(); // pub fn wvsprintfA(); // pub fn wvsprintfW(); } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/user32-sys-0.1.2/Cargo.toml��������������������������������������������������������������������0000644�0000000�0000000�00000001007�12562504755�015043� 0����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������[package] name = "user32-sys" version = "0.1.2" authors = ["Peter Atashian <retep998@gmail.com>"] description = "FFI bindings to user32." documentation = "https://retep998.github.io/doc/user32/" repository = "https://github.com/retep998/winapi-rs" readme = "README.md" keywords = ["Windows", "FFI", "WinSDK"] license = "MIT" build = "build.rs" links = "user32" [lib] name = "user32" [dependencies] winapi = { version = "*", path = "../.." } [build-dependencies] winapi-build = { version = "*", path = "../../build" } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������deps/user32-sys-0.1.2/build.rs����������������������������������������������������������������������0000644�0000000�0000000�00000000227�12542643311�014551� 0����������������������������������������������������������������������������������������������������ustar �root����������������������������root�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������// Copyright © 2015, Peter Atashian // Licensed under the MIT License <LICENSE.md> extern crate build; fn main() { build::link("user32", false) } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������